This is python.info, produced by makeinfo version 7.1 from python.texi.

     Python 3.13.0, 11月 15, 2024

     Author name not set

     Copyright © 2001-2024, Python Software Foundation

INFO-DIR-SECTION Miscellaneous
START-INFO-DIR-ENTRY
* python: (python.info). One line description of project
END-INFO-DIR-ENTRY


   Generated by Sphinx 8.1.3.


File: python.info,  Node: Top,  Next: What's New in Python,  Up: (dir)

Python
******

     Python 3.13.0, 11月 15, 2024

     Author name not set

     Copyright © 2001-2024, Python Software Foundation

* Menu:

* What's New in Python::
* Python チュートリアル::
* Python のセットアップと利用::
* Python 言語リファレンス::
* Python 標準ライブラリ::
* Python インタプリタの拡張と埋め込み::
* Python/C API リファレンスマニュアル::
* Python モジュールのインストール::
* Python HOWTO::
* Python よくある質問::
* Deprecations::
* 用語集: 用語集<2>.
* このドキュメントについて::
* バグへの対処::
* Copyright::
* 歴史とライセンス::
* Pythonモジュール索引::
* 索引::

 -- The Detailed Node Listing --

What's New in Python

* What's New In Python 3.13: What's New In Python 3 13.
* What's New In Python 3.12: What's New In Python 3 12.
* What's New In Python 3.11: What's New In Python 3 11.
* What's New In Python 3.10: What's New In Python 3 10.
* What's New In Python 3.9: What's New In Python 3 9.
* What's New In Python 3.8: What's New In Python 3 8.
* What's New In Python 3.7: What's New In Python 3 7.
* What's New In Python 3.6: What's New In Python 3 6.
* What's New In Python 3.5: What's New In Python 3 5.
* What's New In Python 3.4: What's New In Python 3 4.
* What's New In Python 3.3: What's New In Python 3 3.
* What's New In Python 3.2: What's New In Python 3 2.
* What's New In Python 3.1: What's New In Python 3 1.
* What's New In Python 3.0: What's New In Python 3 0.
* What's New in Python 2.7: What's New in Python 2 7.
* What's New in Python 2.6: What's New in Python 2 6.
* What's New in Python 2.5: What's New in Python 2 5.
* What's New in Python 2.4: What's New in Python 2 4.
* What's New in Python 2.3: What's New in Python 2 3.
* What's New in Python 2.2: What's New in Python 2 2.
* What's New in Python 2.1: What's New in Python 2 1.
* What's New in Python 2.0: What's New in Python 2 0.
* 変更履歴::

What's New In Python 3.13

* Summary: Summary -- Release Highlights. Release Highlights
* New Features::
* Other Language Changes::
* New Modules::
* Improved Modules::
* Optimizations::
* Removed Modules And APIs::
* New Deprecations::
* CPython Bytecode Changes::
* C API Changes::
* Build Changes::
* Porting to Python 3.13: Porting to Python 3 13.
* Regression Test Changes::
* Notable changes in 3.13.1: Notable changes in 3 13 1.

New Features

* A better interactive interpreter::
* Improved error messages::
* Free-threaded CPython::
* An experimental just-in-time (JIT) compiler: An experimental just-in-time JIT compiler.
* Defined mutation semantics for locals(): Defined mutation semantics for locals.
* Support for mobile platforms::

Improved Modules

* argparse::
* array::
* ast::
* asyncio::
* base64::
* compileall::
* concurrent.futures: concurrent futures.
* configparser::
* copy::
* ctypes::
* dbm::
* dis::
* doctest::
* email::
* fractions::
* glob::
* importlib::
* io::
* ipaddress::
* itertools::
* marshal::
* math::
* mimetypes::
* mmap::
* multiprocessing::
* os::
* os.path: os path.
* pathlib::
* pdb::
* queue::
* random::
* re::
* shutil::
* site::
* sqlite3::
* ssl::
* statistics::
* subprocess::
* sys::
* tempfile::
* time::
* tkinter::
* traceback::
* types::
* typing::
* unicodedata::
* venv::
* warnings::
* xml::
* zipimport::

Removed Modules And APIs

* PEP 594; Remove "dead batteries" from the standard library: PEP 594 Remove "dead batteries" from the standard library.
* 2to3::
* builtins::
* configparser: configparser<2>.
* importlib.metadata: importlib metadata.
* locale::
* opcode::
* pathlib: pathlib<2>.
* re: re<2>.
* tkinter.tix: tkinter tix.
* turtle::
* typing: typing<2>.
* unittest::
* urllib::
* webbrowser::

New Deprecations

* Pending Removal in Python 3.14: Pending Removal in Python 3 14.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15.
* Pending removal in Python 3.16: Pending removal in Python 3 16.
* Pending Removal in Future Versions::

C API Changes

* New Features: New Features<2>.
* Changed C APIs::
* Limited C API Changes::
* Removed C APIs::
* Deprecated C APIs::

Deprecated C APIs

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<2>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<2>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<2>.

Porting to Python 3.13

* Changes in the Python API::
* Changes in the C API::

Notable changes in 3.13.1

* sys: sys<2>.

What's New In Python 3.12

* Summary: Summary -- Release highlights. Release highlights
* New Features: New Features<3>.
* New Features Related to Type Hints::
* Other Language Changes: Other Language Changes<2>.
* New Modules: New Modules<2>.
* Improved Modules: Improved Modules<2>.
* Optimizations: Optimizations<2>.
* CPython bytecode changes::
* Demos and Tools::
* Deprecated::
* Removed::
* Porting to Python 3.12: Porting to Python 3 12.
* Build Changes: Build Changes<2>.
* C API Changes: C API Changes<2>.

New Features

* PEP 695; Type Parameter Syntax: PEP 695 Type Parameter Syntax.
* PEP 701; Syntactic formalization of f-strings: PEP 701 Syntactic formalization of f-strings.
* PEP 684; A Per-Interpreter GIL: PEP 684 A Per-Interpreter GIL.
* PEP 669; Low impact monitoring for CPython: PEP 669 Low impact monitoring for CPython.
* PEP 688; Making the buffer protocol accessible in Python: PEP 688 Making the buffer protocol accessible in Python.
* PEP 709; Comprehension inlining: PEP 709 Comprehension inlining.
* Improved Error Messages::

New Features Related to Type Hints

* PEP 692; Using TypedDict for more precise **kwargs typing: PEP 692 Using TypedDict for more precise **kwargs typing.
* PEP 698; Override Decorator for Static Typing: PEP 698 Override Decorator for Static Typing.

Improved Modules

* array: array<2>.
* asyncio: asyncio<2>.
* calendar::
* csv::
* dis: dis<2>.
* fractions: fractions<2>.
* importlib.resources: importlib resources.
* inspect::
* itertools: itertools<2>.
* math: math<2>.
* os: os<2>.
* os.path: os path<2>.
* pathlib: pathlib<3>.
* pdb: pdb<2>.
* random: random<2>.
* shutil: shutil<2>.
* sqlite3: sqlite3<2>.
* statistics: statistics<2>.
* sys: sys<3>.
* tempfile: tempfile<2>.
* threading::
* tkinter: tkinter<2>.
* tokenize::
* types: types<2>.
* typing: typing<3>.
* unicodedata: unicodedata<2>.
* unittest: unittest<2>.
* uuid::

Deprecated

* Pending Removal in Python 3.13: Pending Removal in Python 3 13.
* Pending Removal in Python 3.14: Pending Removal in Python 3 14<3>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<3>.
* Pending removal in Python 3.16: Pending removal in Python 3 16<2>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<3>.

Removed

* asynchat and asyncore::
* configparser: configparser<3>.
* distutils::
* ensurepip::
* enum::
* ftplib::
* gzip::
* hashlib::
* importlib: importlib<2>.
* imp::
* io: io<2>.
* locale: locale<2>.
* smtpd::
* sqlite3: sqlite3<3>.
* ssl: ssl<2>.
* unittest: unittest<3>.
* webbrowser: webbrowser<2>.
* xml.etree.ElementTree: xml etree ElementTree.
* zipimport: zipimport<2>.
* Others::

Porting to Python 3.12

* Changes in the Python API: Changes in the Python API<2>.

C API Changes

* New Features: New Features<4>.
* Porting to Python 3.12: Porting to Python 3 12<2>.
* Deprecated: Deprecated<2>.
* Removed: Removed<2>.

Deprecated

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<4>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<4>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<4>.

What's New In Python 3.11

* 概要: 概要 -- リリースハイライト. リリースハイライト
* 新しい機能::
* 型ヒントに関連する新しい機能::
* その他の言語変更::
* その他の CPython の実装の変更::
* 新たなモジュール::
* 改良されたモジュール::
* 最適化::
* Faster CPython::
* CPython バイトコードの変更::
* 非推奨::
* Pending Removal in Python 3.12: Pending Removal in Python 3 12.
* 削除::
* Porting to Python 3.11: Porting to Python 3 11.
* Build Changes: Build Changes<3>.
* C API の変更::
* Python 3.11.4での重要な変更点: Python 3 11 4での重要な変更点.
* Python 3.11.5での重要な変更点: Python 3 11 5での重要な変更点.

新しい機能

* PEP 657; トレースバックのエラー位置の詳細化: PEP 657 トレースバックのエラー位置の詳細化.
* PEP 654; 例外グループと except*: PEP 654 例外グループと except*.
* PEP 678; ノートによって例外を充実させる: PEP 678 ノートによって例外を充実させる.
* Windows py.exe ランチャーの改善: Windows py exe ランチャーの改善.

型ヒントに関連する新しい機能

* PEP 646; Variadic generics: PEP 646 Variadic generics.
* PEP 655; Marking individual TypedDict items as required or not-required: PEP 655 Marking individual TypedDict items as required or not-required.
* PEP 673; Self 型: PEP 673 Self 型.
* PEP 675; Arbitrary literal string type: PEP 675 Arbitrary literal string type.
* PEP 681; Data class transforms: PEP 681 Data class transforms.
* PEP 563 may not be the future::

改良されたモジュール

* asyncio: asyncio<3>.
* contextlib::
* データクラス::
* datetime::
* enum: enum<2>.
* fcntl::
* fractions: fractions<3>.
* functools::
* gzip: gzip<2>.
* hashlib: hashlib<2>.
* IDLE と idelelib::
* inspect: inspect<2>.
* locale: locale<3>.
* logging::
* math: math<3>.
* operator::
* os: os<3>.
* pathlib: pathlib<4>.
* re: re<3>.
* shutil: shutil<3>.
* socket::
* sqlite3: sqlite3<4>.
* string::
* sys: sys<4>.
* sysconfig::
* tempfile: tempfile<3>.
* threading: threading<2>.
* time: time<2>.
* tkinter: tkinter<3>.
* traceback: traceback<2>.
* typing: typing<4>.
* unicodedata: unicodedata<3>.
* unittest: unittest<4>.
* venv: venv<2>.
* warnings: warnings<2>.
* zipfile::

Faster CPython

* Faster Startup::
* Faster Runtime::
* Misc::
* FAQ::
* About::

Faster Startup

* Frozen imports / Static code objects::

Faster Runtime

* Cheaper, lazy Python frames: Cheaper lazy Python frames.
* Inlined Python function calls::
* PEP 659; Specializing Adaptive Interpreter: PEP 659 Specializing Adaptive Interpreter.

FAQ

* How should I write my code to utilize these speedups?::
* Will CPython 3.11 use more memory?: Will CPython 3 11 use more memory?.
* I don't see any speedups in my workload. Why?: I don't see any speedups in my workload Why?.
* Is there a JIT compiler?::

CPython バイトコードの変更

* New opcodes::
* Replaced opcodes::
* Changed/removed opcodes::

非推奨

* Language/Builtins::
* モジュール::
* Standard Library::

C API の変更

* 新しい機能: 新しい機能<2>.
* Porting to Python 3.11: Porting to Python 3 11<2>.
* 非推奨: 非推奨<2>.
* Pending Removal in Python 3.12: Pending Removal in Python 3 12<2>.
* 削除: 削除<2>.

Python 3.11.4での重要な変更点

* tarfile::

Python 3.11.5での重要な変更点

* OpenSSL::

What's New In Python 3.10

* 概要: 概要 -- リリースハイライト<2>. リリースハイライト
* 新しい機能: 新しい機能<3>.
* 型ヒントに関連する新しい機能: 型ヒントに関連する新しい機能<2>.
* その他の言語変更: その他の言語変更<2>.
* 新たなモジュール: 新たなモジュール<2>.
* 改良されたモジュール: 改良されたモジュール<2>.
* 最適化: 最適化<2>.
* 非推奨: 非推奨<3>.
* 削除: 削除<3>.
* Porting to Python 3.10: Porting to Python 3 10.
* CPython バイトコードの変更: CPython バイトコードの変更<2>.
* Build Changes: Build Changes<4>.
* C API の変更: C API の変更<3>.
* Notable security feature in 3.10.7: Notable security feature in 3 10 7.
* Notable security feature in 3.10.8: Notable security feature in 3 10 8.
* Notable changes in 3.10.12: Notable changes in 3 10 12.

新しい機能

* カッコ内のコンテキストマネージャー::
* エラーメッセージの改善::
* PEP 626; Precise line numbers for debugging and other tools: PEP 626 Precise line numbers for debugging and other tools.
* PEP 634; 構造的パターンマッチ: PEP 634 構造的パターンマッチ.
* Optional EncodingWarning and encoding="locale" option::

エラーメッセージの改善

* SyntaxErrors::
* IndentationErrors::
* AttributeErrors::
* NameErrors::

PEP 634: 構造的パターンマッチ

* Syntax and operations::
* Declarative approach::
* Simple pattern; match to a literal: Simple pattern match to a literal.
* Patterns with a literal and variable::
* Patterns and classes::
* Nested patterns::
* Complex patterns and the wildcard::
* Guard::
* Other Key Features::

Simple pattern: match to a literal

* Behavior without the wildcard::

Patterns and classes

* Patterns with positional parameters::

型ヒントに関連する新しい機能

* PEP 604; New Type Union Operator: PEP 604 New Type Union Operator.
* PEP 612; Parameter Specification Variables: PEP 612 Parameter Specification Variables.
* PEP 613; TypeAlias: PEP 613 TypeAlias.
* PEP 647; User-Defined Type Guards: PEP 647 User-Defined Type Guards.

改良されたモジュール

* asyncio: asyncio<4>.
* argparse: argparse<2>.
* array: array<3>.
* asynchat, asyncore, smtpd: asynchat asyncore smtpd.
* base64: base64<2>.
* bdb::
* bisect::
* codecs::
* collections.abc: collections abc.
* contextlib: contextlib<2>.
* curses::
* データクラス: データクラス<2>.
* distutils: distutils<2>.
* doctest: doctest<2>.
* エンコーディング::
* enum: enum<3>.
* fileinput::
* faulthandler::
* gc::
* glob: glob<2>.
* hashlib: hashlib<3>.
* hmac::
* IDLE と idelelib: IDLE と idelelib<2>.
* importlib.metadata: importlib metadata<2>.
* inspect: inspect<3>.
* itertools: itertools<3>.
* linecache::
* os: os<4>.
* os.path: os path<3>.
* pathlib: pathlib<5>.
* プラットフォーム::
* pprint::
* py_compile::
* pyclbr::
* shelve::
* statistics: statistics<3>.
* site: site<2>.
* socket: socket<2>.
* ssl: ssl<3>.
* sqlite3: sqlite3<5>.
* sys: sys<5>.
* _thread::
* threading: threading<3>.
* traceback: traceback<3>.
* types: types<3>.
* typing: typing<5>.
* unittest: unittest<5>.
* urllib.parse: urllib parse.
* xml: xml<2>.
* zipimport: zipimport<3>.

データクラス

* __slots__::
* Keyword-only fields::

Porting to Python 3.10

* Changes in the Python syntax::
* Python API の変更::
* C API の変更: C API の変更<2>.

C API の変更

* PEP 652; Maintaining the Stable ABI: PEP 652 Maintaining the Stable ABI.
* 新しい機能: 新しい機能<4>.
* Porting to Python 3.10: Porting to Python 3 10<2>.
* 非推奨: 非推奨<4>.
* 削除: 削除<4>.

Notable changes in 3.10.12

* tarfile: tarfile<2>.

What's New In Python 3.9

* 概要: 概要 -- リリースハイライト<3>. リリースハイライト
* コード中の非推奨警告(DeprecationWarning)をチェックして下さい: コード中の非推奨警告 DeprecationWarning をチェックして下さい.
* 新しい機能: 新しい機能<5>.
* その他の言語変更: その他の言語変更<3>.
* 新たなモジュール: 新たなモジュール<3>.
* 改良されたモジュール: 改良されたモジュール<3>.
* 最適化: 最適化<3>.
* 非推奨: 非推奨<5>.
* 削除: 削除<5>.
* Python 3.9への移植: Python 3 9への移植.
* Build Changes: Build Changes<5>.
* C API の変更: C API の変更<5>.
* Python 3.9.1 での重要な変更点: Python 3 9 1 での重要な変更点.
* Python 3.9.2 での重要な変更点: Python 3 9 2 での重要な変更点.
* Python 3.9.3 での重要な変更点: Python 3 9 3 での重要な変更点.
* Python 3.9.5での重要な変更点: Python 3 9 5での重要な変更点.
* Notable security feature in 3.9.14: Notable security feature in 3 9 14.
* Notable changes in 3.9.17: Notable changes in 3 9 17.

新しい機能

* 辞書のマージと更新演算子::
* prefixとsuffixを削除する新しい文字列メソッド::
* 標準コレクション型の型ヒントにおける総称型 (generics) の使用: 標準コレクション型の型ヒントにおける総称型 generics の使用.
* 新しいパーサー::

新たなモジュール

* zoneinfo::
* graphlib::

改良されたモジュール

* ast: ast<2>.
* asyncio: asyncio<5>.
* compileall: compileall<2>.
* concurrent.futures: concurrent futures<2>.
* curses: curses<2>.
* datetime: datetime<2>.
* distutils: distutils<3>.
* fcntl: fcntl<2>.
* ftplib: ftplib<2>.
* gc: gc<2>.
* hashlib: hashlib<4>.
* http::
* IDLE と idelelib: IDLE と idelelib<3>.
* imaplib::
* importlib: importlib<3>.
* inspect: inspect<4>.
* ipaddress: ipaddress<2>.
* math: math<4>.
* multiprocessing: multiprocessing<2>.
* nntplib::
* os: os<5>.
* pathlib: pathlib<6>.
* pdb: pdb<3>.
* poplib::
* pprint: pprint<2>.
* pydoc::
* random: random<3>.
* signal::
* smtplib::
* socket: socket<3>.
* time: time<3>.
* sys: sys<6>.
* tracemalloc::
* typing: typing<6>.
* unicodedata: unicodedata<4>.
* venv: venv<3>.
* xml: xml<3>.

Python 3.9への移植

* Python API の変更: Python API の変更<2>.
* C API の変更: C API の変更<4>.
* CPython バイトコードの変更: CPython バイトコードの変更<3>.

C API の変更

* 新しい機能: 新しい機能<6>.
* Python 3.9への移植: Python 3 9への移植<2>.
* 削除: 削除<6>.

Python 3.9.1 での重要な変更点

* typing: typing<7>.
* macOS 11.0 (Big Sur) と Appleシリコンの Mac のサポート: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート.

Python 3.9.2 での重要な変更点

* collections.abc: collections abc<2>.
* urllib.parse: urllib parse<2>.

Python 3.9.5での重要な変更点

* urllib.parse: urllib parse<3>.

Notable changes in 3.9.17

* tarfile: tarfile<3>.

What's New In Python 3.8

* 概要: 概要 -- リリースハイライト<4>. リリースハイライト
* 新しい機能: 新しい機能<7>.
* その他の言語変更: その他の言語変更<4>.
* 新たなモジュール: 新たなモジュール<4>.
* 改良されたモジュール: 改良されたモジュール<4>.
* 最適化: 最適化<4>.
* ビルドならびに C API の変更::
* 非推奨: 非推奨<6>.
* API と機能の削除::
* Python 3.8 への移植: Python 3 8 への移植.
* Python3.8.1 での重要な変更点: Python3 8 1 での重要な変更点.
* Python3.8.2 での重要な変更点: Python3 8 2 での重要な変更点.
* Notable changes in Python 3.8.3: Notable changes in Python 3 8 3.
* Python3.8.8 での重要な変更点: Python3 8 8 での重要な変更点.
* Notable changes in Python 3.8.9: Notable changes in Python 3 8 9.
* Notable changes in Python 3.8.10: Notable changes in Python 3 8 10.
* Notable changes in Python 3.8.10: Notable changes in Python 3 8 10<2>.
* Notable changes in Python 3.8.12: Notable changes in Python 3 8 12.
* Notable security feature in 3.8.14: Notable security feature in 3 8 14.
* Notable changes in 3.8.17: Notable changes in 3 8 17.

新しい機能

* 代入式::
* 位置専用引数::
* コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム::
* デバッグビルドとリリースビルドのABI 共通化::
* f-string での = を用いたオブジェクトの表現::
* PEP 578; Pythonランタイムの監査フック: PEP 578 Pythonランタイムの監査フック.
* PEP 587; Python 初期化設定: PEP 587 Python 初期化設定.
* PEP 590; Vectorcall; a fast calling protocol for CPython: PEP 590 Vectorcall a fast calling protocol for CPython.
* Pickle プロトコルバージョン 5 による帯域外データバッファ::

改良されたモジュール

* ast: ast<3>.
* asyncio: asyncio<6>.
* builtins: builtins<2>.
* collections::
* cProfile::
* csv: csv<2>.
* curses: curses<3>.
* ctypes: ctypes<2>.
* datetime: datetime<3>.
* functools: functools<2>.
* gc: gc<3>.
* gettext::
* gzip: gzip<3>.
* IDLE と idelelib: IDLE と idelelib<4>.
* inspect: inspect<5>.
* io: io<3>.
* itertools: itertools<4>.
* json.tool: json tool.
* logging: logging<2>.
* math: math<5>.
* mmap: mmap<2>.
* multiprocessing: multiprocessing<3>.
* os: os<6>.
* os.path: os path<4>.
* pathlib: pathlib<7>.
* pickle::
* plistlib::
* pprint: pprint<3>.
* py_compile: py_compile<2>.
* shlex::
* shutil: shutil<4>.
* socket: socket<4>.
* ssl: ssl<4>.
* statistics: statistics<4>.
* sys: sys<7>.
* tarfile: tarfile<4>.
* threading: threading<4>.
* tokenize: tokenize<2>.
* tkinter: tkinter<4>.
* time: time<4>.
* typing: typing<8>.
* unicodedata: unicodedata<5>.
* unittest: unittest<6>.
* venv: venv<4>.
* weakref::
* xml: xml<4>.
* xmlrpc::

Python 3.8 への移植

* Python の挙動の変更::
* Python API の変更: Python API の変更<3>.
* C API の変更: C API の変更<6>.
* CPython バイトコードの変更: CPython バイトコードの変更<4>.
* Demos and Tools: Demos and Tools<2>.

Notable changes in Python 3.8.10

* macOS 11.0 (Big Sur) と Appleシリコンの Mac のサポート: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート<2>.

Notable changes in Python 3.8.10

* urllib.parse: urllib parse<4>.

Notable changes in Python 3.8.12

* Python API の変更: Python API の変更<4>.

Notable changes in 3.8.17

* tarfile: tarfile<5>.

What's New In Python 3.7

* 概要: 概要 -- リリースハイライト<5>. リリースハイライト
* 新しい機能: 新しい機能<8>.
* その他の言語変更: その他の言語変更<5>.
* 新たなモジュール: 新たなモジュール<5>.
* 改良されたモジュール: 改良されたモジュール<5>.
* C API の変更: C API の変更<7>.
* Build Changes: Build Changes<6>.
* 最適化: 最適化<5>.
* その他の CPython の実装の変更: その他の CPython の実装の変更<2>.
* 非推奨の Python の挙動::
* 非推奨の Python モジュール、関数、メソッド::
* C API の非推奨の関数ならびに型::
* サポート対象プラットフォームからの除外::
* API と機能の削除: API と機能の削除<2>.
* Module Removals::
* Windows-only Changes::
* Python 3.7 への移植: Python 3 7 への移植.
* Python 3.7.1 での重要な変更点: Python 3 7 1 での重要な変更点.
* Python 3.7.2 での重要な変更点: Python 3 7 2 での重要な変更点.
* Python 3.7.6 での重要な変更点: Python 3 7 6 での重要な変更点.
* Python 3.7.10 での重要な変更点: Python 3 7 10 での重要な変更点.
* Notable changes in Python 3.7.11: Notable changes in Python 3 7 11.
* Notable security feature in 3.7.14: Notable security feature in 3 7 14.

新しい機能

* PEP 563; アノテーションの遅延評価: PEP 563 アノテーションの遅延評価.
* PEP 538; レガシーな C ロケールの抑圧: PEP 538 レガシーな C ロケールの抑圧.
* PEP 540; 強制 UTF-8 実行モード: PEP 540 強制 UTF-8 実行モード.
* PEP 553; 組み込みの breakpoint(): PEP 553 組み込みの breakpoint.
* PEP 539; スレッドローカルストレージのための新しい C API: PEP 539 スレッドローカルストレージのための新しい C API.
* PEP 562; モジュール属性へのアクセスのカスタマイズ: PEP 562 モジュール属性へのアクセスのカスタマイズ.
* PEP 564; ナノ秒単位の分解能を持つ新しい時間関数: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数.
* PEP 565; Show DeprecationWarning in __main__: PEP 565 Show DeprecationWarning in __main__.
* PEP 560; typing モジュールとジェネリック型に対する言語コアによるサポート: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート.
* PEP 552; Hash-based .pyc Files: PEP 552 Hash-based pyc Files.
* PEP 545; Python Documentation Translations: PEP 545 Python Documentation Translations.
* Python Development Mode (-X dev): Python Development Mode -X dev.

新たなモジュール

* contextvars::
* データクラス: データクラス<3>.
* importlib.resources: importlib resources<2>.

改良されたモジュール

* argparse: argparse<3>.
* asyncio: asyncio<7>.
* binascii::
* calendar: calendar<2>.
* collections: collections<2>.
* compileall: compileall<3>.
* concurrent.futures: concurrent futures<3>.
* contextlib: contextlib<3>.
* cProfile: cProfile<2>.
* crypt::
* datetime: datetime<4>.
* dbm: dbm<2>.
* decimal::
* dis: dis<3>.
* distutils: distutils<4>.
* enum: enum<4>.
* functools: functools<3>.
* gc: gc<4>.
* hmac: hmac<2>.
* http.client: http client.
* http.server: http server.
* idlelib と IDLE::
* importlib: importlib<4>.
* io: io<4>.
* ipaddress: ipaddress<3>.
* itertools: itertools<5>.
* locale: locale<4>.
* logging: logging<3>.
* math: math<6>.
* mimetypes: mimetypes<2>.
* msilib::
* multiprocessing: multiprocessing<4>.
* os: os<7>.
* pathlib: pathlib<8>.
* pdb: pdb<4>.
* py_compile: py_compile<3>.
* pydoc: pydoc<2>.
* queue: queue<2>.
* re: re<4>.
* signal: signal<2>.
* socket: socket<5>.
* socketserver::
* sqlite3: sqlite3<6>.
* ssl: ssl<5>.
* string: string<2>.
* subprocess: subprocess<2>.
* sys: sys<8>.
* time: time<5>.
* tkinter: tkinter<5>.
* tracemalloc: tracemalloc<2>.
* types: types<4>.
* unicodedata: unicodedata<6>.
* unittest: unittest<7>.
* unittest.mock: unittest mock.
* urllib.parse: urllib parse<5>.
* uu::
* uuid: uuid<2>.
* warnings: warnings<3>.
* xml: xml<5>.
* xml.etree: xml etree.
* xmlrpc.server: xmlrpc server.
* zipapp::
* zipfile: zipfile<2>.

非推奨の Python モジュール、関数、メソッド

* aifc::
* asyncio: asyncio<8>.
* collections: collections<3>.
* dbm: dbm<3>.
* enum: enum<5>.
* gettext: gettext<2>.
* importlib: importlib<5>.
* locale: locale<5>.
* macpath::
* threading: threading<5>.
* socket: socket<6>.
* ssl: ssl<6>.
* sunau::
* sys: sys<9>.
* wave::

Python 3.7 への移植

* Python の挙動の変更: Python の挙動の変更<2>.
* Python API の変更: Python API の変更<5>.
* C API の変更: C API の変更<8>.
* CPython バイトコードの変更: CPython バイトコードの変更<5>.
* Windows-only Changes: Windows-only Changes<2>.
* その他の CPython の実装の変更: その他の CPython の実装の変更<3>.

What's New In Python 3.6

* 概要: 概要 -- リリースハイライト<6>. リリースハイライト
* 新しい機能: 新しい機能<9>.
* その他の言語変更: その他の言語変更<6>.
* 新たなモジュール: 新たなモジュール<6>.
* 改良されたモジュール: 改良されたモジュール<6>.
* 最適化: 最適化<6>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<2>.
* その他の改善::
* 非推奨: 非推奨<7>.
* 削除: 削除<7>.
* Python 3.6 への移植: Python 3 6 への移植.
* Notable changes in Python 3.6.2: Notable changes in Python 3 6 2.
* Notable changes in Python 3.6.4: Notable changes in Python 3 6 4.
* Notable changes in Python 3.6.5: Notable changes in Python 3 6 5.
* Notable changes in Python 3.6.7: Notable changes in Python 3 6 7.
* Notable changes in Python 3.6.10: Notable changes in Python 3 6 10.
* Notable changes in Python 3.6.13: Notable changes in Python 3 6 13.
* Notable changes in Python 3.6.14: Notable changes in Python 3 6 14.

新しい機能

* PEP 498; フォーマット済み文字列リテラル: PEP 498 フォーマット済み文字列リテラル.
* PEP 526; 変数アノテーションの文法: PEP 526 変数アノテーションの文法.
* PEP 515; 数値リテラル内のアンダースコア: PEP 515 数値リテラル内のアンダースコア.
* PEP 525; 非同期ジェネレータ: PEP 525 非同期ジェネレータ.
* PEP 530; 非同期内包表記: PEP 530 非同期内包表記.
* PEP 487; Simpler customization of class creation: PEP 487 Simpler customization of class creation.
* PEP 487; 記述子プロトコルの改善: PEP 487 記述子プロトコルの改善.
* PEP 519; ファイルシステムパスプロトコルの追加: PEP 519 ファイルシステムパスプロトコルの追加.
* PEP 495; 地域時間の曖昧さ回避: PEP 495 地域時間の曖昧さ回避.
* PEP 529; Windows ファイルシステムのエンコーディングを UTF-8 に変更: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更.
* PEP 528; Windows コンソールのエンコーディングを UTF-8 に変更: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更.
* PEP 520; クラス属性の定義の順番を保持: PEP 520 クラス属性の定義の順番を保持.
* PEP 468; キーワード引数の順番の保持: PEP 468 キーワード引数の順番の保持.
* 新たな dict 実装::
* PEP 523; CPython にフレーム評価 API を追加: PEP 523 CPython にフレーム評価 API を追加.
* PYTHONMALLOC 環境変数::
* DTrace and SystemTap probing support::

新たなモジュール

* secrets::

改良されたモジュール

* array: array<4>.
* ast: ast<4>.
* asyncio: asyncio<9>.
* binascii: binascii<2>.
* cmath::
* collections: collections<4>.
* concurrent.futures: concurrent futures<4>.
* contextlib: contextlib<4>.
* datetime: datetime<5>.
* decimal: decimal<2>.
* distutils: distutils<5>.
* email: email<2>.
* エンコーディング: エンコーディング<2>.
* enum: enum<6>.
* faulthandler: faulthandler<2>.
* fileinput: fileinput<2>.
* hashlib: hashlib<5>.
* http.client: http client<2>.
* idlelib と IDLE: idlelib と IDLE<2>.
* importlib: importlib<6>.
* inspect: inspect<6>.
* json::
* logging: logging<4>.
* math: math<7>.
* multiprocessing: multiprocessing<5>.
* os: os<8>.
* pathlib: pathlib<9>.
* pdb: pdb<5>.
* pickle: pickle<2>.
* pickletools::
* pydoc: pydoc<3>.
* random: random<4>.
* re: re<5>.
* readline::
* rlcompleter::
* shlex: shlex<2>.
* site: site<3>.
* sqlite3: sqlite3<7>.
* socket: socket<7>.
* socketserver: socketserver<2>.
* ssl: ssl<7>.
* statistics: statistics<5>.
* struct::
* subprocess: subprocess<3>.
* sys: sys<10>.
* telnetlib::
* time: time<6>.
* timeit::
* tkinter: tkinter<6>.
* traceback: traceback<4>.
* tracemalloc: tracemalloc<3>.
* typing: typing<9>.
* unicodedata: unicodedata<7>.
* unittest.mock: unittest mock<2>.
* urllib.request: urllib request.
* urllib.robotparser: urllib robotparser.
* venv: venv<5>.
* warnings: warnings<4>.
* winreg::
* winsound::
* xmlrpc.client: xmlrpc client.
* zipfile: zipfile<3>.
* zlib::

非推奨

* 新たなキーワード::
* 非推奨の Python 挙動::
* 非推奨の Python モジュール、関数、メソッド: 非推奨の Python モジュール、関数、メソッド<2>.
* xml: xml<6>.
* C API の非推奨の関数ならびに型: C API の非推奨の関数ならびに型<2>.
* 非推奨のビルドオプション::

非推奨の Python モジュール、関数、メソッド

* asynchat::
* asyncore::
* dbm: dbm<4>.
* distutils: distutils<6>.
* grp::
* importlib: importlib<7>.
* os: os<9>.
* re: re<6>.
* ssl: ssl<8>.
* tkinter: tkinter<7>.
* venv: venv<6>.

削除

* API と機能の削除: API と機能の削除<3>.

Python 3.6 への移植

* 'python' コマンドの挙動の変更::
* Python API の変更: Python API の変更<6>.
* C API の変更: C API の変更<9>.
* CPython バイトコードの変更: CPython バイトコードの変更<6>.

Notable changes in Python 3.6.2

* New make regen-all build target::
* Removal of make touch build target::

What's New In Python 3.5

* 概要: 概要 -- リリースハイライト<7>. リリースハイライト
* 新しい機能: 新しい機能<10>.
* その他の言語変更: その他の言語変更<7>.
* 新たなモジュール: 新たなモジュール<7>.
* 改良されたモジュール: 改良されたモジュール<7>.
* その他のモジュールレベルの変更::
* 最適化: 最適化<7>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<3>.
* 非推奨: 非推奨<8>.
* 削除: 削除<8>.
* Python 3.5 への移植: Python 3 5 への移植.
* Notable changes in Python 3.5.4: Notable changes in Python 3 5 4.

新しい機能

* PEP 492 - コルーチン、 async と await 構文::
* PEP 465 - 行列の乗算専用の中置演算子::
* PEP 448 - 追加可能なアンパックへの一般化::
* PEP 461 - bytes および bytearray のパーセント書式化サポート::
* PEP 484 - 型ヒント::
* PEP 471 - os.scandir() 関数: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ. より良く、速いディレクトリイテレータ
* PEP 475; EINTR で失敗したシステムコールの再試行: PEP 475 EINTR で失敗したシステムコールの再試行.
* PEP 479; ジェネレータ内の StopIteration の処理の変更: PEP 479 ジェネレータ内の StopIteration の処理の変更.
* PEP 485; 近似的に等しいことを調べる関数: PEP 485 近似的に等しいことを調べる関数.
* PEP 486; Python ランチャーが仮想環境を認識する: PEP 486 Python ランチャーが仮想環境を認識する.
* PEP 488; PYO ファイルの廃止: PEP 488 PYO ファイルの廃止.
* PEP 489; 拡張モジュールの多段階初期化: PEP 489 拡張モジュールの多段階初期化.

新たなモジュール

* typing: typing<10>.
* zipapp: zipapp<2>.

改良されたモジュール

* argparse: argparse<4>.
* asyncio: asyncio<10>.
* bz2::
* cgi::
* cmath: cmath<2>.
* コード::
* collections: collections<5>.
* collections.abc: collections abc<3>.
* compileall: compileall<4>.
* concurrent.futures: concurrent futures<5>.
* configparser: configparser<4>.
* contextlib: contextlib<5>.
* csv: csv<3>.
* curses: curses<4>.
* dbm: dbm<5>.
* difflib::
* distutils: distutils<7>.
* doctest: doctest<3>.
* email: email<3>.
* enum: enum<7>.
* faulthandler: faulthandler<3>.
* functools: functools<4>.
* glob: glob<3>.
* gzip: gzip<4>.
* heapq::
* http: http<2>.
* http.client: http client<3>.
* idlelib と IDLE: idlelib と IDLE<3>.
* imaplib: imaplib<2>.
* imghdr::
* importlib: importlib<8>.
* inspect: inspect<7>.
* io: io<5>.
* ipaddress: ipaddress<4>.
* json: json<2>.
* linecache: linecache<2>.
* locale: locale<6>.
* logging: logging<5>.
* lzma::
* math: math<8>.
* multiprocessing: multiprocessing<6>.
* operator: operator<2>.
* os: os<10>.
* pathlib: pathlib<10>.
* pickle: pickle<3>.
* poplib: poplib<2>.
* re: re<7>.
* readline: readline<2>.
* selectors::
* shutil: shutil<5>.
* signal: signal<3>.
* smtpd: smtpd<2>.
* smtplib: smtplib<2>.
* sndhdr::
* socket: socket<8>.
* ssl: ssl<9>.
* sqlite3: sqlite3<8>.
* subprocess: subprocess<4>.
* sys: sys<11>.
* sysconfig: sysconfig<2>.
* tarfile: tarfile<6>.
* threading: threading<6>.
* time: time<7>.
* timeit: timeit<2>.
* tkinter: tkinter<8>.
* traceback: traceback<5>.
* types: types<5>.
* unicodedata: unicodedata<8>.
* unittest: unittest<8>.
* unittest.mock: unittest mock<3>.
* urllib: urllib<2>.
* wsgiref::
* xmlrpc: xmlrpc<2>.
* xml.sax: xml sax.
* zipfile: zipfile<4>.

ssl

* メモリ BIO サポート::
* Application-Layer Protocol Negotiation Support::
* その他の変更::

非推奨

* 新たなキーワード: 新たなキーワード<2>.
* 非推奨の Python の挙動: 非推奨の Python の挙動<2>.
* サポートされないオペレーティングシステム::
* 非推奨の Python モジュール、関数、メソッド: 非推奨の Python モジュール、関数、メソッド<3>.

削除

* API と機能の削除: API と機能の削除<4>.

Python 3.5 への移植

* Python の挙動の変更: Python の挙動の変更<3>.
* Python API の変更: Python API の変更<7>.
* C API の変更: C API の変更<10>.

Notable changes in Python 3.5.4

* New make regen-all build target: New make regen-all build target<2>.
* Removal of make touch build target: Removal of make touch build target<2>.

What's New In Python 3.4

* 概要: 概要 -- リリースハイライト<8>. リリースハイライト
* 新しい機能: 新しい機能<11>.
* 新たなモジュール: 新たなモジュール<8>.
* 改良されたモジュール: 改良されたモジュール<8>.
* CPython の実装の変更::
* 非推奨: 非推奨<9>.
* 削除: 削除<9>.
* Python 3.4 への移植: Python 3 4 への移植.
* 3.4.3 の変更: 3 4 3 の変更.

新しい機能

* PEP 453; Python インストール時の PIP の明示的なブートストラッピング: PEP 453 Python インストール時の PIP の明示的なブートストラッピング.
* PEP 446; 新規作成されたファイル記述子は継承不可: PEP 446 新規作成されたファイル記述子は継承不可.
* Codec 処理の改良::
* PEP 451; インポートシステムのための ModuleSpec 型: PEP 451 インポートシステムのための ModuleSpec 型.
* その他の言語変更: その他の言語変更<8>.

PEP 453: Python インストール時の PIP の明示的なブートストラッピング

* デフォルトでの pip のブートストラッピング::
* ドキュメントの変更::

新たなモジュール

* asyncio: asyncio<11>.
* ensurepip: ensurepip<2>.
* enum: enum<8>.
* pathlib: pathlib<11>.
* selectors: selectors<2>.
* statistics: statistics<6>.
* tracemalloc: tracemalloc<4>.

改良されたモジュール

* abc::
* aifc: aifc<2>.
* argparse: argparse<5>.
* audioop::
* base64: base64<3>.
* collections: collections<6>.
* colorsys::
* contextlib: contextlib<6>.
* dbm: dbm<6>.
* dis: dis<4>.
* doctest: doctest<4>.
* email: email<4>.
* filecmp::
* functools: functools<5>.
* gc: gc<5>.
* glob: glob<4>.
* hashlib: hashlib<6>.
* hmac: hmac<3>.
* html::
* http: http<3>.
* idlelib と IDLE: idlelib と IDLE<4>.
* importlib: importlib<9>.
* inspect: inspect<8>.
* ipaddress: ipaddress<5>.
* logging: logging<6>.
* marshal: marshal<2>.
* mmap: mmap<3>.
* multiprocessing: multiprocessing<7>.
* operator: operator<3>.
* os: os<11>.
* pdb: pdb<6>.
* pickle: pickle<4>.
* plistlib: plistlib<2>.
* poplib: poplib<3>.
* pprint: pprint<4>.
* pty::
* pydoc: pydoc<4>.
* re: re<8>.
* resource::
* select::
* shelve: shelve<2>.
* shutil: shutil<6>.
* smtpd: smtpd<3>.
* smtplib: smtplib<3>.
* socket: socket<9>.
* sqlite3: sqlite3<9>.
* ssl: ssl<10>.
* stat::
* struct: struct<2>.
* subprocess: subprocess<5>.
* sunau: sunau<2>.
* sys: sys<12>.
* tarfile: tarfile<7>.
* textwrap::
* threading: threading<7>.
* traceback: traceback<6>.
* types: types<6>.
* urllib: urllib<3>.
* unittest: unittest<9>.
* venv: venv<7>.
* wave: wave<2>.
* weakref: weakref<2>.
* xml.etree: xml etree<2>.
* zipfile: zipfile<5>.

CPython の実装の変更

* PEP 445; CPython のメモリアロケータのカスタマイズ: PEP 445 CPython のメモリアロケータのカスタマイズ.
* PEP 442; オブジェクトの安全なファイナライゼーション: PEP 442 オブジェクトの安全なファイナライゼーション.
* PEP 456; 安全で取り換え可能なハッシュアルゴリズム: PEP 456 安全で取り換え可能なハッシュアルゴリズム.
* PEP 436; Argument Clinic: PEP 436 Argument Clinic.
* その他のビルド並びに C API の変更::
* その他の改善: その他の改善<2>.
* 大幅な最適化::

非推奨

* Python API の非推奨項目::
* 非推奨の機能::

削除

* サポートされなくなったオペレーティングシステム::
* API と機能の削除: API と機能の削除<5>.
* コードの整理::

Python 3.4 への移植

* 'python' コマンドの挙動の変更: 'python' コマンドの挙動の変更<2>.
* Python API の変更: Python API の変更<8>.
* C API の変更: C API の変更<11>.

3.4.3 の変更

* PEP 476; stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化.

What's New In Python 3.3

* 概要: 概要 -- リリースハイライト<9>. リリースハイライト
* PEP 405; 仮想環境: PEP 405 仮想環境.
* PEP 420; 暗黙的な名前空間パッケージ: PEP 420 暗黙的な名前空間パッケージ.
* PEP 3118; 新たなメモリビューの実装とバッファプロトコルのドキュメント: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント.
* PEP 393; 文字列の柔軟な表現: PEP 393 文字列の柔軟な表現.
* PEP 397; Windows の Python ランチャ: PEP 397 Windows の Python ランチャ.
* PEP 3151; OS および IO 例外階層の手直し: PEP 3151 OS および IO 例外階層の手直し.
* PEP 380; サブジェネレータへの委譲構文: PEP 380 サブジェネレータへの委譲構文.
* PEP 409; 例外コンテキストの抑制: PEP 409 例外コンテキストの抑制.
* PEP 414; 明示的なユニコードリテラル: PEP 414 明示的なユニコードリテラル.
* PEP 3155; クラスと関数の正規名: PEP 3155 クラスと関数の正規名.
* PEP 412; キー共有辞書: PEP 412 キー共有辞書.
* PEP 362; 関数シグニチャオブジェクト: PEP 362 関数シグニチャオブジェクト.
* PEP 421; sys.implementation の追加: PEP 421 sys implementation の追加.
* インポート実装としての importlib の使用::
* その他の言語変更: その他の言語変更<9>.
* 細粒度のインポートロック::
* 組み込みの関数と型::
* 新たなモジュール: 新たなモジュール<9>.
* 改良されたモジュール: 改良されたモジュール<9>.
* 最適化: 最適化<8>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<4>.
* 非推奨: 非推奨<10>.
* Python 3.3 への移植: Python 3 3 への移植.

PEP 3118: 新たなメモリビューの実装とバッファプロトコルのドキュメント

* フィーチャー::
* API の変更::

PEP 393: 文字列の柔軟な表現

* 機能性::
* 性能およびリソース使用量::

PEP 421: sys.implementation の追加

* SimpleNamespace::

インポート実装としての importlib の使用

* 新たな API::
* 目に見える変化::

新たなモジュール

* faulthandler: faulthandler<4>.
* ipaddress: ipaddress<6>.
* lzma: lzma<2>.

改良されたモジュール

* abc: abc<2>.
* array: array<5>.
* base64: base64<4>.
* binascii: binascii<3>.
* bz2: bz2<2>.
* codecs: codecs<2>.
* collections: collections<7>.
* contextlib: contextlib<7>.
* crypt: crypt<2>.
* curses: curses<5>.
* datetime: datetime<6>.
* decimal: decimal<3>.
* email: email<5>.
* ftplib: ftplib<3>.
* functools: functools<6>.
* gc: gc<6>.
* hmac: hmac<4>.
* http: http<4>.
* html: html<2>.
* imaplib: imaplib<3>.
* inspect: inspect<9>.
* io: io<6>.
* itertools: itertools<6>.
* logging: logging<7>.
* math: math<9>.
* mmap: mmap<4>.
* multiprocessing: multiprocessing<8>.
* nntplib: nntplib<2>.
* os: os<12>.
* pdb: pdb<7>.
* pickle: pickle<5>.
* pydoc: pydoc<5>.
* re: re<9>.
* sched::
* select: select<2>.
* shlex: shlex<3>.
* shutil: shutil<7>.
* signal: signal<4>.
* smtpd: smtpd<4>.
* smtplib: smtplib<4>.
* socket: socket<10>.
* socketserver: socketserver<3>.
* sqlite3: sqlite3<10>.
* ssl: ssl<11>.
* stat: stat<2>.
* struct: struct<3>.
* subprocess: subprocess<6>.
* sys: sys<13>.
* tarfile: tarfile<8>.
* tempfile: tempfile<4>.
* textwrap: textwrap<2>.
* threading: threading<8>.
* time: time<8>.
* types: types<7>.
* unittest: unittest<10>.
* urllib: urllib<4>.
* webbrowser: webbrowser<3>.
* xml.etree.ElementTree: xml etree ElementTree<2>.
* zlib: zlib<2>.

decimal

* フィーチャー: フィーチャー<2>.
* API の変更: API の変更<2>.

email

* ポリシーフレームワーク::
* 新規ヘッダ API を伴った暫定ポリシー::
* その他のAPIの変更::

非推奨

* サポートされないオペレーティングシステム: サポートされないオペレーティングシステム<2>.
* 非推奨の Python モジュール、関数、メソッド: 非推奨の Python モジュール、関数、メソッド<4>.
* C API の非推奨の関数ならびに型: C API の非推奨の関数ならびに型<3>.
* 非推奨の機能: 非推奨の機能<2>.

Python 3.3 への移植

* Python コードの移植::
* C コードの移植::
* C 拡張のビルド::
* コマンドラインスイッチの変更::

What's New In Python 3.2

* PEP 384; 安定 ABI の定義: PEP 384 安定 ABI の定義.
* PEP 389; argparse コマンドライン解析モジュール: PEP 389 argparse コマンドライン解析モジュール.
* PEP 391; logging の辞書ベースの設定: PEP 391 logging の辞書ベースの設定.
* PEP 3148; concurrent.futures モジュール: PEP 3148 concurrent futures モジュール.
* PEP 3147; PYC リポジトリーディレクトリ: PEP 3147 PYC リポジトリーディレクトリ.
* PEP 3149; ABI バージョンでタグ付けされた .so ファイル: PEP 3149 ABI バージョンでタグ付けされた so ファイル.
* PEP 3333; Python Web Server Gateway Interface v1.0.1: PEP 3333 Python Web Server Gateway Interface v1 0 1.
* その他の言語変更: その他の言語変更<10>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール::
* マルチスレッディング::
* 最適化: 最適化<9>.
* Unicode 文字列型::
* Codecs::
* ドキュメント::
* IDLE::
* コードリポジトリ::
* ビルドならびに C API の変更: ビルドならびに C API の変更<5>.
* Python 3.2 への移植: Python 3 2 への移植.

新たなモジュール、改良されたモジュール、非推奨のモジュール

* email: email<6>.
* elementtree::
* functools: functools<7>.
* itertools: itertools<7>.
* collections: collections<8>.
* threading: threading<9>.
* datetime と time::
* math: math<10>.
* abc: abc<3>.
* io: io<7>.
* reprlib::
* logging: logging<8>.
* csv: csv<4>.
* contextlib: contextlib<8>.
* decimal と fractions::
* ftp::
* popen::
* select: select<3>.
* gzip と zipfile::
* tarfile: tarfile<9>.
* hashlib: hashlib<7>.
* ast: ast<5>.
* os: os<13>.
* shutil: shutil<8>.
* sqlite3: sqlite3<11>.
* html: html<3>.
* socket: socket<11>.
* ssl: ssl<12>.
* nntp::
* certificates::
* imaplib: imaplib<4>.
* http.client: http client<4>.
* unittest: unittest<11>.
* random: random<5>.
* poplib: poplib<4>.
* asyncore: asyncore<2>.
* tempfile: tempfile<5>.
* inspect: inspect<10>.
* pydoc: pydoc<6>.
* dis: dis<5>.
* dbm: dbm<7>.
* ctypes: ctypes<3>.
* site: site<4>.
* sysconfig: sysconfig<3>.
* pdb: pdb<8>.
* configparser: configparser<5>.
* urllib.parse: urllib parse<6>.
* mailbox::
* turtledemo::

What's New In Python 3.1

* PEP 372; 順序付き辞書: PEP 372 順序付き辞書.
* PEP 378; 1000区切りのための書式指定子: PEP 378 1000区切りのための書式指定子.
* その他の言語変更: その他の言語変更<11>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>.
* 最適化: 最適化<10>.
* IDLE: IDLE<2>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<6>.
* Python 3.1 への移植: Python 3 1 への移植.

What's New In Python 3.0

* よくある悩みの種::
* 構文の変更の概要::
* Python 2.6 で既にあった変更: Python 2 6 で既にあった変更.
* ライブラリの変更::
* PEP 3101; 文字列整形の新たなアプローチ: PEP 3101 文字列整形の新たなアプローチ.
* 例外に関する変更::
* その他の変更: その他の変更<2>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<7>.
* 性能::
* Python 3.0 への移植: Python 3 0 への移植.

よくある悩みの種

* print関数::
* リストからビューおよびイテレータへ::
* 順序比較::
* 整数::
* Unicode 対 8 ビット、ではなく、テキスト対データに::

構文の変更の概要

* 新たな構文::
* 変更された構文::
* 削除された操作::

その他の変更

* 演算子と特殊メソッド::
* 組み込み::

What's New in Python 2.7

* Python 2.x の今後: Python 2 x の今後.
* Deprecation Warnings の扱いの変更::
* Python 3.1 の機能: Python 3 1 の機能.
* PEP 372; collections に順序付き辞書を追加: PEP 372 collections に順序付き辞書を追加.
* PEP 378; 1000区切りのための書式指定子: PEP 378 1000区切りのための書式指定子<2>.
* PEP 389; コマンドライン解析のための argparse モジュール: PEP 389 コマンドライン解析のための argparse モジュール.
* PEP 391; logging の辞書ベースの設定: PEP 391 logging の辞書ベースの設定<2>.
* PEP 3106; 辞書 View: PEP 3106 辞書 View.
* PEP 3137; memoryview オブジェクト: PEP 3137 memoryview オブジェクト.
* その他の言語変更: その他の言語変更<12>.
* 新しいモジュールと改良されたモジュール::
* ビルドならびに C API の変更: ビルドならびに C API の変更<8>.
* その他の変更と修正::
* Python 2.7 への移植: Python 2 7 への移植.
* Python 2.7 メンテナンスリリースで追加された新機能: Python 2 7 メンテナンスリリースで追加された新機能.
* 謝辞::

その他の言語変更

* インタプリタの変更::
* 最適化: 最適化<11>.

新しいモジュールと改良されたモジュール

* 新しいモジュール; importlib: 新しいモジュール importlib.
* 新しいモジュール; sysconfig: 新しいモジュール sysconfig.
* ttk; Tk のテーマ付きウィジェット: ttk Tk のテーマ付きウィジェット.
* 更新されたモジュール; unittest: 更新されたモジュール unittest.
* 更新されたモジュール; ElementTree 1.3: 更新されたモジュール ElementTree 1 3.

ビルドならびに C API の変更

* カプセル::
* ポート特有の変更; Windows: ポート特有の変更 Windows.
* ポート特有の変更; Mac OS X: ポート特有の変更 Mac OS X.
* ポート特有の変更; FreeBSD: ポート特有の変更 FreeBSD.

Python 2.7 メンテナンスリリースで追加された新機能

* デバッグモード用の2つの新しい環境変数::
* PEP 434; IDLE 拡張についての全てのブランチにおける例外的な扱い: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い.
* PEP 466; Python 2.7 のためのネットワークセキュリティ拡張: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張.
* PEP 477; Python 2.7 への ensurepip (PEP 453) バックポート: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート.
* PEP 476; stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>.
* PEP 493; HTTPS verification migration tools for Python 2.7: PEP 493 HTTPS verification migration tools for Python 2 7.
* New make regen-all build target: New make regen-all build target<3>.
* Removal of make touch build target: Removal of make touch build target<3>.

PEP 477: Python 2.7 への ensurepip (PEP 453) バックポート

* デフォルトでの pip のブートストラッピング: デフォルトでの pip のブートストラッピング<2>.
* ドキュメントの変更: ドキュメントの変更<2>.

What's New in Python 2.6

* Python 3.0: Python 3 0.
* 開発プロセスに関する変更::
* PEP 343; "with" ステートメント: PEP 343 "with" ステートメント.
* PEP 366; メインモジュールからの明示的相対インポート: PEP 366 メインモジュールからの明示的相対インポート.
* PEP 370; ユーザごとの site-packages ディレクトリ: PEP 370 ユーザごとの site-packages ディレクトリ.
* PEP 371; multiprocessing パッケージ: PEP 371 multiprocessing パッケージ.
* PEP 3101; 進化版文字列フォーマッティング: PEP 3101 進化版文字列フォーマッティング.
* PEP 3105; print を関数にする: PEP 3105 print を関数にする.
* PEP 3110; 例外処理の変更: PEP 3110 例外処理の変更.
* PEP 3112; バイトリテラル: PEP 3112 バイトリテラル.
* PEP 3116; 新しい I/O ライブラリ: PEP 3116 新しい I/O ライブラリ.
* PEP 3118; 改訂版バッファプロトコル: PEP 3118 改訂版バッファプロトコル.
* PEP 3119; 抽象基底クラス: PEP 3119 抽象基底クラス.
* PEP 3127; 整数リテラルのサポートと文法: PEP 3127 整数リテラルのサポートと文法.
* PEP 3129; クラスデコレータ: PEP 3129 クラスデコレータ.
* PEP 3141; 数値の型階層: PEP 3141 数値の型階層.
* その他の言語変更: その他の言語変更<13>.
* 新しいモジュールと改良されたモジュール: 新しいモジュールと改良されたモジュール<2>.
* 非推奨と削除::
* ビルドならびに C API の変更: ビルドならびに C API の変更<9>.
* Python 2.6 への移植: Python 2 6 への移植.
* 謝辞: 謝辞<2>.

開発プロセスに関する変更

* 新しい課題トラッカー; Roundup: 新しい課題トラッカー Roundup.
* 新しいドキュメンテーションフォーマット; Sphinx を使っての reStructuredText: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText.

PEP 343: "with" ステートメント

* コンテキストマネージャを書く::
* contextlib モジュール::

PEP 3141: 数値の型階層

* fractions モジュール::

その他の言語変更

* 最適化: 最適化<12>.
* インタプリタの変更: インタプリタの変更<2>.

新しいモジュールと改良されたモジュール

* ast モジュール::
* future_builtins モジュール::
* json モジュール; JavaScript オブジェクト記法: json モジュール JavaScript オブジェクト記法.
* plistlib モジュール; プロパティリストパーサ: plistlib モジュール プロパティリストパーサ.
* ctypes の強化::
* SSL サポートの改善::

ビルドならびに C API の変更

* ポート特有の変更; Windows: ポート特有の変更 Windows<2>.
* ポート特有の変更; Mac OS X: ポート特有の変更 Mac OS X<2>.
* ポート特有の変更; IRIX: ポート特有の変更 IRIX.

What's New in Python 2.5

* PEP 308; 条件式 (Conditional Expressions): PEP 308 条件式 Conditional Expressions.
* PEP 309; 関数の部分適用: PEP 309 関数の部分適用.
* PEP 314; Metadata for Python Software Packages v1.1: PEP 314 Metadata for Python Software Packages v1 1.
* PEP 328; 絶対インポート、相対インポート: PEP 328 絶対インポート、相対インポート.
* PEP 338 - モジュールをスクリプトとして実行する::
* PEP 341; try/except/finally の一体化: PEP 341 try/except/finally の一体化.
* PEP 342; ジェネレータの新機能: PEP 342 ジェネレータの新機能.
* PEP 343; "with" ステートメント: PEP 343 "with" ステートメント<2>.
* PEP 352; 例外の新スタイルクラス化: PEP 352 例外の新スタイルクラス化.
* PEP 353; 添え字型に ssize_t を使う: PEP 353 添え字型に ssize_t を使う.
* PEP 357; '__index__' メソッド: PEP 357 '__index__' メソッド.
* その他の言語変更: その他の言語変更<14>.
* 新たなモジュール、改良されたモジュール、削除されたモジュール::
* ビルドならびに C API の変更: ビルドならびに C API の変更<10>.
* Python 2.5 への移植: Python 2 5 への移植.
* 謝辞: 謝辞<3>.

PEP 343: "with" ステートメント

* コンテキストマネージャを書く: コンテキストマネージャを書く<2>.
* contextlib モジュール: contextlib モジュール<2>.

その他の言語変更

* 対話的なインタプリタの変更::
* 最適化: 最適化<13>.

新たなモジュール、改良されたモジュール、削除されたモジュール

* ctypes パッケージ::
* ElementTree パッケージ::
* hashlib パッケージ::
* sqlite3 パッケージ::
* wsgiref パッケージ::

ビルドならびに C API の変更

* ポート特有の変更::

What's New in Python 2.4

* PEP 218; ビルトインの集合オブジェクト: PEP 218 ビルトインの集合オブジェクト.
* PEP 237; 長整数と整数を一体化していく: PEP 237 長整数と整数を一体化していく.
* PEP 289; ジェネレータ式: PEP 289 ジェネレータ式.
* PEP 292; より単純な文字列置換 (string substitution): PEP 292 より単純な文字列置換 string substitution.
* PEP 318; 関数とメソッドのためのデコレータ: PEP 318 関数とメソッドのためのデコレータ.
* PEP 322; 逆順のイテレーション: PEP 322 逆順のイテレーション.
* PEP 324; 新しい subprocess モジュール: PEP 324 新しい subprocess モジュール.
* PEP 327; Decimal データ型: PEP 327 Decimal データ型.
* PEP 328; マルチラインインポート: PEP 328 マルチラインインポート.
* PEP 331; Locale に依存しない Float/String 変換: PEP 331 Locale に依存しない Float/String 変換.
* その他の言語変更: その他の言語変更<15>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<11>.
* Python 2.4 への移植: Python 2 4 への移植.
* 謝辞: 謝辞<4>.

PEP 327: Decimal データ型

* なぜ Decimal が必要なのか?::
* Decimal 型::
* Context 型::

その他の言語変更

* 最適化: 最適化<14>.

新たなモジュール、改良されたモジュール、非推奨のモジュール

* cookielib::
* doctest: doctest<5>.

ビルドならびに C API の変更

* ポート特有の変更: ポート特有の変更<2>.

What's New in Python 2.3

* PEP 218; 標準の集合データ型: PEP 218 標準の集合データ型.
* PEP 255; 単純なジェネレータ: PEP 255 単純なジェネレータ.
* PEP 263; ソースコードのエンコーディング: PEP 263 ソースコードのエンコーディング.
* PEP 273; Zip アーカイブからモジュールをインポートする: PEP 273 Zip アーカイブからモジュールをインポートする.
* PEP 277; Windows NT での Unicode ファイル名サポート: PEP 277 Windows NT での Unicode ファイル名サポート.
* PEP 278; Universal Newline サポート: PEP 278 Universal Newline サポート.
* PEP 279; enumerate(): PEP 279 enumerate.
* PEP 282; ロギングパッケージ: PEP 282 ロギングパッケージ.
* PEP 285; Boolean 型: PEP 285 Boolean 型.
* PEP 293; コーデックエラーを処理するコールバック: PEP 293 コーデックエラーを処理するコールバック.
* PEP 301; パッケージインデクスと、 Distutils のためのメタデータ: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ.
* PEP 302; 新たなインポートフック: PEP 302 新たなインポートフック.
* PEP 305; カンマ区切り形式ファイル: PEP 305 カンマ区切り形式ファイル.
* PEP 307; Pickle の機能拡張: PEP 307 Pickle の機能拡張.
* 拡張スライス::
* その他の言語変更: その他の言語変更<16>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
* Pymalloc; 特殊化されたオブジェクトアロケータ: Pymalloc 特殊化されたオブジェクトアロケータ.
* ビルドならびに C API の変更: ビルドならびに C API の変更<12>.
* その他の変更と修正: その他の変更と修正<2>.
* Python 2.3 への移植: Python 2 3 への移植.
* 謝辞: 謝辞<5>.

その他の言語変更

* 文字列に関する変更::
* 最適化: 最適化<15>.

新たなモジュール、改良されたモジュール、非推奨のモジュール

* 日付時刻型::
* optparse モジュール::

ビルドならびに C API の変更

* ポート特有の変更: ポート特有の変更<3>.

What's New in Python 2.2

* はじめに::
* PEP 252 と PEP 253; 型とクラスについての変更: PEP 252 と PEP 253 型とクラスについての変更.
* PEP 234; イテレータ: PEP 234 イテレータ.
* PEP 255; 単純なジェネレータ: PEP 255 単純なジェネレータ<2>.
* PEP 237; 長整数と整数を一体化していく: PEP 237 長整数と整数を一体化していく<2>.
* PEP 238; 除算演算子を変更していく: PEP 238 除算演算子を変更していく.
* Unicode の変更::
* PEP 227; 入れ子状のスコープ: PEP 227 入れ子状のスコープ.
* 新しいモジュールと改良されたモジュール: 新しいモジュールと改良されたモジュール<3>.
* インタプリタの変更と修正::
* その他の変更と修正: その他の変更と修正<3>.
* 謝辞: 謝辞<6>.

PEP 252 と PEP 253: 型とクラスについての変更

* 旧と新クラス::
* デスクリプタ::
* 多重継承; ダイヤモンドルール: 多重継承 ダイヤモンドルール.
* 属性アクセス::
* 関連リンク::

What's New in Python 2.1

* はじめに: はじめに<2>.
* PEP 227; 入れ子状のスコープ: PEP 227 入れ子状のスコープ<2>.
* PEP 236; __future__ 指示文: PEP 236 __future__ 指示文.
* PEP 207; 拡張比較: PEP 207 拡張比較.
* PEP 230; 警告フレームワーク: PEP 230 警告フレームワーク.
* PEP 229; 新しいビルドシステム: PEP 229 新しいビルドシステム.
* PEP 205; 弱参照: PEP 205 弱参照.
* PEP 232; 関数の属性: PEP 232 関数の属性.
* PEP 235; 大文字小文字を区別しないプラットフォームでのモジュールの読み込み: PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み.
* PEP 217; 対話モード用 Display Hook: PEP 217 対話モード用 Display Hook.
* PEP 208; 新しい型強制モデル: PEP 208 新しい型強制モデル.
* PEP 241; Pythonソフトウェアパッケージのためのメタデータ: PEP 241 Pythonソフトウェアパッケージのためのメタデータ.
* 新しいモジュールと改良されたモジュール: 新しいモジュールと改良されたモジュール<4>.
* その他の変更と修正: その他の変更と修正<4>.
* 謝辞: 謝辞<7>.

What's New in Python 2.0

* はじめに: はじめに<3>.
* Python 1.6 はいかがですか?: Python 1 6 はいかがですか?.
* 新しい開発プロセス::
* Unicode 文字列型: Unicode 文字列型<2>.
* リストの内包表記::
* 累算代入 (Augmented Assignment): 累算代入 Augmented Assignment.
* 文字列メソッド::
* 循環参照のガベージコレクション::
* その他の言語コアの変更::
* Python 2.0 への移植: Python 2 0 への移植.
* 拡張と埋め込みについての変更::
* Distutils; モジュールの簡単インストール: Distutils モジュールの簡単インストール.
* XML モジュール::
* 更新されたモジュール::
* 新しいモジュール::
* IDLE の改善::
* 削除されたモジュール、非推奨となったモジュール::
* 謝辞: 謝辞<8>.

その他の言語コアの変更

* 言語のマイナー変更::
* ビルトイン関数の変更::

XML モジュール

* SAX2 サポート::
* DOM サポート::
* PyXML との関係::

変更履歴

* Python next::
* Python 3.13.0 final: Python 3 13 0 final.
* Python 3.13.0 release candidate 3: Python 3 13 0 release candidate 3.
* Python 3.13.0 release candidate 2: Python 3 13 0 release candidate 2.
* Python 3.13.0 release candidate 1: Python 3 13 0 release candidate 1.
* Python 3.13.0 beta 4: Python 3 13 0 beta 4.
* Python 3.13.0 beta 3: Python 3 13 0 beta 3.
* Python 3.13.0 beta 2: Python 3 13 0 beta 2.
* Python 3.13.0 beta 1: Python 3 13 0 beta 1.
* Python 3.13.0 alpha 6: Python 3 13 0 alpha 6.
* Python 3.13.0 alpha 5: Python 3 13 0 alpha 5.
* Python 3.13.0 alpha 4: Python 3 13 0 alpha 4.
* Python 3.13.0 alpha 3: Python 3 13 0 alpha 3.
* Python 3.13.0 alpha 2: Python 3 13 0 alpha 2.
* Python 3.13.0 alpha 1: Python 3 13 0 alpha 1.
* Python 3.12.0 beta 1: Python 3 12 0 beta 1.
* Python 3.12.0 alpha 7: Python 3 12 0 alpha 7.
* Python 3.12.0 alpha 6: Python 3 12 0 alpha 6.
* Python 3.12.0 alpha 5: Python 3 12 0 alpha 5.
* Python 3.12.0 alpha 4: Python 3 12 0 alpha 4.
* Python 3.12.0 alpha 3: Python 3 12 0 alpha 3.
* Python 3.12.0 alpha 2: Python 3 12 0 alpha 2.
* Python 3.12.0 alpha 1: Python 3 12 0 alpha 1.
* Python 3.11.0 beta 1: Python 3 11 0 beta 1.
* Python 3.11.0 alpha 7: Python 3 11 0 alpha 7.
* Python 3.11.0 alpha 6: Python 3 11 0 alpha 6.
* Python 3.11.0 alpha 5: Python 3 11 0 alpha 5.
* Python 3.11.0 alpha 4: Python 3 11 0 alpha 4.
* Python 3.11.0 alpha 3: Python 3 11 0 alpha 3.
* Python 3.11.0 alpha 2: Python 3 11 0 alpha 2.
* Python 3.11.0 alpha 1: Python 3 11 0 alpha 1.
* Python 3.10.0 beta 1: Python 3 10 0 beta 1.
* Python 3.10.0 alpha 7: Python 3 10 0 alpha 7.
* Python 3.10.0 alpha 6: Python 3 10 0 alpha 6.
* Python 3.10.0 alpha 5: Python 3 10 0 alpha 5.
* Python 3.10.0 alpha 4: Python 3 10 0 alpha 4.
* Python 3.10.0 alpha 3: Python 3 10 0 alpha 3.
* Python 3.10.0 alpha 2: Python 3 10 0 alpha 2.
* Python 3.10.0 alpha 1: Python 3 10 0 alpha 1.
* Python 3.9.0 beta 1: Python 3 9 0 beta 1.
* Python 3.9.0 alpha 6: Python 3 9 0 alpha 6.
* Python 3.9.0 alpha 5: Python 3 9 0 alpha 5.
* Python 3.9.0 alpha 4: Python 3 9 0 alpha 4.
* Python 3.9.0 alpha 3: Python 3 9 0 alpha 3.
* Python 3.9.0 alpha 2: Python 3 9 0 alpha 2.
* Python 3.9.0 alpha 1: Python 3 9 0 alpha 1.
* Python 3.8.0 beta 1: Python 3 8 0 beta 1.
* Python 3.8.0 alpha 4: Python 3 8 0 alpha 4.
* Python 3.8.0 alpha 3: Python 3 8 0 alpha 3.
* Python 3.8.0 alpha 2: Python 3 8 0 alpha 2.
* Python 3.8.0 alpha 1: Python 3 8 0 alpha 1.
* Python 3.7.0 final: Python 3 7 0 final.
* Python 3.7.0 release candidate 1: Python 3 7 0 release candidate 1.
* Python 3.7.0 beta 5: Python 3 7 0 beta 5.
* Python 3.7.0 beta 4: Python 3 7 0 beta 4.
* Python 3.7.0 beta 3: Python 3 7 0 beta 3.
* Python 3.7.0 beta 2: Python 3 7 0 beta 2.
* Python 3.7.0 beta 1: Python 3 7 0 beta 1.
* Python 3.7.0 alpha 4: Python 3 7 0 alpha 4.
* Python 3.7.0 alpha 3: Python 3 7 0 alpha 3.
* Python 3.7.0 alpha 2: Python 3 7 0 alpha 2.
* Python 3.7.0 alpha 1: Python 3 7 0 alpha 1.
* Python 3.6.6 final: Python 3 6 6 final.
* Python 3.6.6 release candidate 1: Python 3 6 6 release candidate 1.
* Python 3.6.5 final: Python 3 6 5 final.
* Python 3.6.5 release candidate 1: Python 3 6 5 release candidate 1.
* Python 3.6.4 final: Python 3 6 4 final.
* Python 3.6.4 release candidate 1: Python 3 6 4 release candidate 1.
* Python 3.6.3 final: Python 3 6 3 final.
* Python 3.6.3 release candidate 1: Python 3 6 3 release candidate 1.
* Python 3.6.2 final: Python 3 6 2 final.
* Python 3.6.2 release candidate 2: Python 3 6 2 release candidate 2.
* Python 3.6.2 release candidate 1: Python 3 6 2 release candidate 1.
* Python 3.6.1 final: Python 3 6 1 final.
* Python 3.6.1 release candidate 1: Python 3 6 1 release candidate 1.
* Python 3.6.0 final: Python 3 6 0 final.
* Python 3.6.0 release candidate 2: Python 3 6 0 release candidate 2.
* Python 3.6.0 release candidate 1: Python 3 6 0 release candidate 1.
* Python 3.6.0 beta 4: Python 3 6 0 beta 4.
* Python 3.6.0 beta 3: Python 3 6 0 beta 3.
* Python 3.6.0 beta 2: Python 3 6 0 beta 2.
* Python 3.6.0 beta 1: Python 3 6 0 beta 1.
* Python 3.6.0 alpha 4: Python 3 6 0 alpha 4.
* Python 3.6.0 alpha 3: Python 3 6 0 alpha 3.
* Python 3.6.0 alpha 2: Python 3 6 0 alpha 2.
* Python 3.6.0 alpha 1: Python 3 6 0 alpha 1.
* Python 3.5.5 final: Python 3 5 5 final.
* Python 3.5.5 release candidate 1: Python 3 5 5 release candidate 1.
* Python 3.5.4 final: Python 3 5 4 final.
* Python 3.5.4 release candidate 1: Python 3 5 4 release candidate 1.
* Python 3.5.3 final: Python 3 5 3 final.
* Python 3.5.3 release candidate 1: Python 3 5 3 release candidate 1.
* Python 3.5.2 final: Python 3 5 2 final.
* Python 3.5.2 release candidate 1: Python 3 5 2 release candidate 1.
* Python 3.5.1 final: Python 3 5 1 final.
* Python 3.5.1 release candidate 1: Python 3 5 1 release candidate 1.
* Python 3.5.0 final: Python 3 5 0 final.
* Python 3.5.0 release candidate 4: Python 3 5 0 release candidate 4.
* Python 3.5.0 release candidate 3: Python 3 5 0 release candidate 3.
* Python 3.5.0 release candidate 2: Python 3 5 0 release candidate 2.
* Python 3.5.0 release candidate 1: Python 3 5 0 release candidate 1.
* Python 3.5.0 beta 4: Python 3 5 0 beta 4.
* Python 3.5.0 beta 3: Python 3 5 0 beta 3.
* Python 3.5.0 beta 2: Python 3 5 0 beta 2.
* Python 3.5.0 beta 1: Python 3 5 0 beta 1.
* Python 3.5.0 alpha 4: Python 3 5 0 alpha 4.
* Python 3.5.0 alpha 3: Python 3 5 0 alpha 3.
* Python 3.5.0 alpha 2: Python 3 5 0 alpha 2.
* Python 3.5.0 alpha 1: Python 3 5 0 alpha 1.

Python next

* macOS::
* Windows::
* Tools/Demos::
* Tests::
* Security::
* Library::
* IDLE: IDLE<3>.
* Documentation::
* Core and Builtins::
* C API::
* Build::

Python 3.13.0 final

* Core and Builtins: Core and Builtins<2>.

Python 3.13.0 release candidate 3

* macOS: macOS<2>.
* Windows: Windows<2>.
* Tests: Tests<2>.
* Library: Library<2>.
* IDLE: IDLE<4>.
* Documentation: Documentation<2>.
* Core and Builtins: Core and Builtins<3>.
* C API: C API<2>.
* Build: Build<2>.

Python 3.13.0 release candidate 2

* macOS: macOS<3>.
* Windows: Windows<3>.
* Tools/Demos: Tools/Demos<2>.
* Tests: Tests<3>.
* Security: Security<2>.
* Library: Library<3>.
* IDLE: IDLE<5>.
* Core and Builtins: Core and Builtins<4>.
* C API: C API<3>.
* Build: Build<3>.

Python 3.13.0 release candidate 1

* Tests: Tests<4>.
* Security: Security<3>.
* Library: Library<4>.
* IDLE: IDLE<6>.
* Core and Builtins: Core and Builtins<5>.
* C API: C API<4>.
* Build: Build<4>.

Python 3.13.0 beta 4

* Tests: Tests<5>.
* Library: Library<5>.
* IDLE: IDLE<7>.
* Documentation: Documentation<3>.
* Core and Builtins: Core and Builtins<6>.
* C API: C API<5>.
* Build: Build<5>.

Python 3.13.0 beta 3

* Core and Builtins: Core and Builtins<7>.
* Library: Library<6>.
* Build: Build<6>.
* C API: C API<6>.

Python 3.13.0 beta 2

* Security: Security<4>.
* Core and Builtins: Core and Builtins<8>.
* Library: Library<7>.
* Tests: Tests<6>.
* Build: Build<7>.
* Windows: Windows<4>.
* C API: C API<7>.

Python 3.13.0 beta 1

* Security: Security<5>.
* Core and Builtins: Core and Builtins<9>.
* Library: Library<8>.
* Documentation: Documentation<4>.
* Build: Build<8>.
* Windows: Windows<5>.
* macOS: macOS<4>.
* IDLE: IDLE<8>.
* C API: C API<8>.

Python 3.13.0 alpha 6

* Core and Builtins: Core and Builtins<10>.
* Library: Library<9>.
* Documentation: Documentation<5>.
* Tests: Tests<7>.
* Build: Build<9>.
* Windows: Windows<6>.
* C API: C API<9>.

Python 3.13.0 alpha 5

* Security: Security<6>.
* Core and Builtins: Core and Builtins<11>.
* Library: Library<10>.
* Documentation: Documentation<6>.
* Tests: Tests<8>.
* Build: Build<10>.
* Windows: Windows<7>.
* macOS: macOS<5>.
* IDLE: IDLE<9>.
* Tools/Demos: Tools/Demos<3>.
* C API: C API<10>.

Python 3.13.0 alpha 4

* Security: Security<7>.
* Core and Builtins: Core and Builtins<12>.
* Library: Library<11>.
* Documentation: Documentation<7>.
* Tests: Tests<9>.
* Build: Build<11>.
* Windows: Windows<8>.
* macOS: macOS<6>.
* IDLE: IDLE<10>.
* Tools/Demos: Tools/Demos<4>.
* C API: C API<11>.

Python 3.13.0 alpha 3

* Security: Security<8>.
* Core and Builtins: Core and Builtins<13>.
* Library: Library<12>.
* Documentation: Documentation<8>.
* Tests: Tests<10>.
* Build: Build<12>.
* Windows: Windows<9>.
* macOS: macOS<7>.
* IDLE: IDLE<11>.
* C API: C API<12>.

Python 3.13.0 alpha 2

* Core and Builtins: Core and Builtins<14>.
* Library: Library<13>.
* Tests: Tests<11>.
* Build: Build<13>.
* Windows: Windows<10>.
* macOS: macOS<8>.
* IDLE: IDLE<12>.
* Tools/Demos: Tools/Demos<5>.
* C API: C API<13>.

Python 3.13.0 alpha 1

* Security: Security<9>.
* Core and Builtins: Core and Builtins<15>.
* Library: Library<14>.
* Documentation: Documentation<9>.
* Tests: Tests<12>.
* Build: Build<14>.
* Windows: Windows<11>.
* macOS: macOS<9>.
* IDLE: IDLE<13>.
* Tools/Demos: Tools/Demos<6>.
* C API: C API<14>.

Python 3.12.0 beta 1

* Security: Security<10>.
* Core and Builtins: Core and Builtins<16>.
* Library: Library<15>.
* Documentation: Documentation<10>.
* Tests: Tests<13>.
* Build: Build<15>.
* Windows: Windows<12>.
* macOS: macOS<10>.
* IDLE: IDLE<14>.
* Tools/Demos: Tools/Demos<7>.
* C API: C API<15>.

Python 3.12.0 alpha 7

* Core and Builtins: Core and Builtins<17>.
* Library: Library<16>.
* Documentation: Documentation<11>.
* Tests: Tests<14>.
* Build: Build<16>.
* Windows: Windows<13>.
* Tools/Demos: Tools/Demos<8>.
* C API: C API<16>.

Python 3.12.0 alpha 6

* Security: Security<11>.
* Core and Builtins: Core and Builtins<18>.
* Library: Library<17>.
* Documentation: Documentation<12>.
* Tests: Tests<15>.
* Build: Build<17>.
* Windows: Windows<14>.
* macOS: macOS<11>.
* C API: C API<17>.

Python 3.12.0 alpha 5

* Security: Security<12>.
* Core and Builtins: Core and Builtins<19>.
* Library: Library<18>.
* Documentation: Documentation<13>.
* Tests: Tests<16>.
* Build: Build<18>.
* Windows: Windows<15>.

Python 3.12.0 alpha 4

* Core and Builtins: Core and Builtins<20>.
* Library: Library<19>.
* Documentation: Documentation<14>.
* Tests: Tests<17>.
* Build: Build<19>.
* Windows: Windows<16>.
* macOS: macOS<12>.
* Tools/Demos: Tools/Demos<9>.
* C API: C API<18>.

Python 3.12.0 alpha 3

* Security: Security<13>.
* Core and Builtins: Core and Builtins<21>.
* Library: Library<20>.
* Documentation: Documentation<15>.
* Tests: Tests<18>.
* Build: Build<20>.
* Windows: Windows<17>.
* macOS: macOS<13>.
* Tools/Demos: Tools/Demos<10>.
* C API: C API<19>.

Python 3.12.0 alpha 2

* Security: Security<14>.
* Core and Builtins: Core and Builtins<22>.
* Library: Library<21>.
* Documentation: Documentation<16>.
* Tests: Tests<19>.
* Build: Build<21>.
* Windows: Windows<18>.
* macOS: macOS<14>.
* C API: C API<20>.

Python 3.12.0 alpha 1

* Security: Security<15>.
* Core and Builtins: Core and Builtins<23>.
* Library: Library<22>.
* Documentation: Documentation<17>.
* Tests: Tests<20>.
* Build: Build<22>.
* Windows: Windows<19>.
* macOS: macOS<15>.
* IDLE: IDLE<15>.
* Tools/Demos: Tools/Demos<11>.
* C API: C API<21>.

Python 3.11.0 beta 1

* Security: Security<16>.
* Core and Builtins: Core and Builtins<24>.
* Library: Library<23>.
* Documentation: Documentation<18>.
* Tests: Tests<21>.
* Build: Build<23>.
* Windows: Windows<20>.
* macOS: macOS<16>.
* Tools/Demos: Tools/Demos<12>.
* C API: C API<22>.

Python 3.11.0 alpha 7

* Core and Builtins: Core and Builtins<25>.
* Library: Library<24>.
* Documentation: Documentation<19>.
* Tests: Tests<22>.
* Build: Build<24>.
* Windows: Windows<21>.
* macOS: macOS<17>.
* Tools/Demos: Tools/Demos<13>.
* C API: C API<23>.

Python 3.11.0 alpha 6

* Core and Builtins: Core and Builtins<26>.
* Library: Library<25>.
* Documentation: Documentation<20>.
* Tests: Tests<23>.
* Build: Build<25>.
* Windows: Windows<22>.
* IDLE: IDLE<16>.
* C API: C API<24>.

Python 3.11.0 alpha 5

* Core and Builtins: Core and Builtins<27>.
* Library: Library<26>.
* Documentation: Documentation<21>.
* Tests: Tests<24>.
* Build: Build<26>.
* Windows: Windows<23>.
* macOS: macOS<18>.
* IDLE: IDLE<17>.
* C API: C API<25>.

Python 3.11.0 alpha 4

* Core and Builtins: Core and Builtins<28>.
* Library: Library<27>.
* Documentation: Documentation<22>.
* Tests: Tests<25>.
* Build: Build<27>.
* Windows: Windows<24>.
* macOS: macOS<19>.
* C API: C API<26>.

Python 3.11.0 alpha 3

* Core and Builtins: Core and Builtins<29>.
* Library: Library<28>.
* Documentation: Documentation<23>.
* Tests: Tests<26>.
* Build: Build<28>.
* Windows: Windows<25>.
* macOS: macOS<20>.
* C API: C API<27>.

Python 3.11.0 alpha 2

* Core and Builtins: Core and Builtins<30>.
* Library: Library<29>.
* Documentation: Documentation<24>.
* Tests: Tests<27>.
* Build: Build<29>.
* Windows: Windows<26>.
* macOS: macOS<21>.
* IDLE: IDLE<18>.
* C API: C API<28>.

Python 3.11.0 alpha 1

* Security: Security<17>.
* Core and Builtins: Core and Builtins<31>.
* Library: Library<30>.
* Documentation: Documentation<25>.
* Tests: Tests<28>.
* Build: Build<30>.
* Windows: Windows<27>.
* macOS: macOS<22>.
* IDLE: IDLE<19>.
* Tools/Demos: Tools/Demos<14>.
* C API: C API<29>.

Python 3.10.0 beta 1

* Security: Security<18>.
* Core and Builtins: Core and Builtins<32>.
* Library: Library<31>.
* Documentation: Documentation<26>.
* Tests: Tests<29>.
* Build: Build<31>.
* Windows: Windows<28>.
* macOS: macOS<23>.
* IDLE: IDLE<20>.
* C API: C API<30>.

Python 3.10.0 alpha 7

* Security: Security<19>.
* Core and Builtins: Core and Builtins<33>.
* Library: Library<32>.
* Documentation: Documentation<27>.
* Tests: Tests<30>.
* Build: Build<32>.
* Windows: Windows<29>.
* IDLE: IDLE<21>.
* C API: C API<31>.

Python 3.10.0 alpha 6

* Security: Security<20>.
* Core and Builtins: Core and Builtins<34>.
* Library: Library<33>.
* Documentation: Documentation<28>.
* Tests: Tests<31>.
* Build: Build<33>.
* Windows: Windows<30>.
* macOS: macOS<24>.
* IDLE: IDLE<22>.
* C API: C API<32>.

Python 3.10.0 alpha 5

* Security: Security<21>.
* Core and Builtins: Core and Builtins<35>.
* Library: Library<34>.
* Documentation: Documentation<29>.
* Tests: Tests<32>.
* Build: Build<34>.
* Windows: Windows<31>.
* macOS: macOS<25>.
* IDLE: IDLE<23>.
* C API: C API<33>.

Python 3.10.0 alpha 4

* Core and Builtins: Core and Builtins<36>.
* Library: Library<35>.
* Documentation: Documentation<30>.
* Tests: Tests<33>.
* Build: Build<35>.
* macOS: macOS<26>.
* Tools/Demos: Tools/Demos<15>.
* C API: C API<34>.

Python 3.10.0 alpha 3

* Security: Security<22>.
* Core and Builtins: Core and Builtins<37>.
* Library: Library<36>.
* Documentation: Documentation<31>.
* Tests: Tests<34>.
* Build: Build<36>.
* Windows: Windows<32>.
* macOS: macOS<27>.
* IDLE: IDLE<24>.
* Tools/Demos: Tools/Demos<16>.
* C API: C API<35>.

Python 3.10.0 alpha 2

* Security: Security<23>.
* Core and Builtins: Core and Builtins<38>.
* Library: Library<37>.
* Documentation: Documentation<32>.
* Tests: Tests<35>.
* Build: Build<37>.
* Windows: Windows<33>.
* macOS: macOS<28>.
* IDLE: IDLE<25>.
* C API: C API<36>.

Python 3.10.0 alpha 1

* Security: Security<24>.
* Core and Builtins: Core and Builtins<39>.
* Library: Library<38>.
* Documentation: Documentation<33>.
* Tests: Tests<36>.
* Build: Build<38>.
* Windows: Windows<34>.
* macOS: macOS<29>.
* IDLE: IDLE<26>.
* C API: C API<37>.

Python 3.9.0 beta 1

* Security: Security<25>.
* Core and Builtins: Core and Builtins<40>.
* Library: Library<39>.
* Documentation: Documentation<34>.
* Tests: Tests<37>.
* Build: Build<39>.
* Windows: Windows<35>.
* macOS: macOS<30>.
* Tools/Demos: Tools/Demos<17>.
* C API: C API<38>.

Python 3.9.0 alpha 6

* Security: Security<26>.
* Core and Builtins: Core and Builtins<41>.
* Library: Library<40>.
* Documentation: Documentation<35>.
* Tests: Tests<38>.
* Build: Build<40>.
* Windows: Windows<36>.
* macOS: macOS<31>.
* IDLE: IDLE<27>.
* Tools/Demos: Tools/Demos<18>.
* C API: C API<39>.

Python 3.9.0 alpha 5

* Security: Security<27>.
* Core and Builtins: Core and Builtins<42>.
* Library: Library<41>.
* Documentation: Documentation<36>.
* Tests: Tests<39>.
* Build: Build<41>.
* Windows: Windows<37>.
* macOS: macOS<32>.
* IDLE: IDLE<28>.
* Tools/Demos: Tools/Demos<19>.
* C API: C API<40>.

Python 3.9.0 alpha 4

* Security: Security<28>.
* Core and Builtins: Core and Builtins<43>.
* Library: Library<42>.
* Documentation: Documentation<37>.
* Tests: Tests<40>.
* Build: Build<42>.
* Windows: Windows<38>.
* IDLE: IDLE<29>.
* C API: C API<41>.

Python 3.9.0 alpha 3

* Core and Builtins: Core and Builtins<44>.
* Library: Library<43>.
* Documentation: Documentation<38>.
* Build: Build<43>.
* IDLE: IDLE<30>.
* C API: C API<42>.

Python 3.9.0 alpha 2

* Security: Security<29>.
* Core and Builtins: Core and Builtins<45>.
* Library: Library<44>.
* Documentation: Documentation<39>.
* Tests: Tests<41>.
* Build: Build<44>.
* Windows: Windows<39>.
* macOS: macOS<33>.
* IDLE: IDLE<31>.
* C API: C API<43>.

Python 3.9.0 alpha 1

* Security: Security<30>.
* Core and Builtins: Core and Builtins<46>.
* Library: Library<45>.
* Documentation: Documentation<40>.
* Tests: Tests<42>.
* Build: Build<45>.
* Windows: Windows<40>.
* macOS: macOS<34>.
* IDLE: IDLE<32>.
* Tools/Demos: Tools/Demos<20>.
* C API: C API<44>.

Python 3.8.0 beta 1

* Security: Security<31>.
* Core and Builtins: Core and Builtins<47>.
* Library: Library<46>.
* Documentation: Documentation<41>.
* Tests: Tests<43>.
* Build: Build<46>.
* Windows: Windows<41>.
* macOS: macOS<35>.
* IDLE: IDLE<33>.
* Tools/Demos: Tools/Demos<21>.
* C API: C API<45>.

Python 3.8.0 alpha 4

* Security: Security<32>.
* Core and Builtins: Core and Builtins<48>.
* Library: Library<47>.
* Documentation: Documentation<42>.
* Tests: Tests<44>.
* Build: Build<47>.
* Windows: Windows<42>.
* macOS: macOS<36>.
* IDLE: IDLE<34>.
* Tools/Demos: Tools/Demos<22>.
* C API: C API<46>.

Python 3.8.0 alpha 3

* Security: Security<33>.
* Core and Builtins: Core and Builtins<49>.
* Library: Library<48>.
* Documentation: Documentation<43>.
* Tests: Tests<45>.
* Build: Build<48>.
* Windows: Windows<43>.
* IDLE: IDLE<35>.
* Tools/Demos: Tools/Demos<23>.
* C API: C API<47>.

Python 3.8.0 alpha 2

* Core and Builtins: Core and Builtins<50>.
* Library: Library<49>.
* Documentation: Documentation<44>.
* Tests: Tests<46>.
* Windows: Windows<44>.
* IDLE: IDLE<36>.

Python 3.8.0 alpha 1

* Security: Security<34>.
* Core and Builtins: Core and Builtins<51>.
* Library: Library<50>.
* Documentation: Documentation<45>.
* Tests: Tests<47>.
* Build: Build<49>.
* Windows: Windows<45>.
* macOS: macOS<37>.
* IDLE: IDLE<37>.
* Tools/Demos: Tools/Demos<24>.
* C API: C API<48>.

Python 3.7.0 final

* Library: Library<51>.
* C API: C API<49>.

Python 3.7.0 release candidate 1

* Core and Builtins: Core and Builtins<52>.
* Library: Library<52>.
* Documentation: Documentation<46>.
* Build: Build<50>.
* Windows: Windows<46>.
* IDLE: IDLE<38>.

Python 3.7.0 beta 5

* Core and Builtins: Core and Builtins<53>.
* Library: Library<53>.
* Documentation: Documentation<47>.
* Tests: Tests<48>.
* Build: Build<51>.
* macOS: macOS<38>.
* IDLE: IDLE<39>.

Python 3.7.0 beta 4

* Core and Builtins: Core and Builtins<54>.
* Library: Library<54>.
* Documentation: Documentation<48>.
* Tests: Tests<49>.
* Build: Build<52>.
* Windows: Windows<47>.
* macOS: macOS<39>.
* IDLE: IDLE<40>.
* Tools/Demos: Tools/Demos<25>.

Python 3.7.0 beta 3

* Security: Security<35>.
* Core and Builtins: Core and Builtins<55>.
* Library: Library<55>.
* Documentation: Documentation<49>.
* Tests: Tests<50>.
* Build: Build<53>.
* Windows: Windows<48>.
* macOS: macOS<40>.
* IDLE: IDLE<41>.
* Tools/Demos: Tools/Demos<26>.
* C API: C API<50>.

Python 3.7.0 beta 2

* Security: Security<36>.
* Core and Builtins: Core and Builtins<56>.
* Library: Library<56>.
* Documentation: Documentation<50>.
* Tests: Tests<51>.
* Build: Build<54>.
* Windows: Windows<49>.
* macOS: macOS<41>.
* IDLE: IDLE<42>.
* Tools/Demos: Tools/Demos<27>.

Python 3.7.0 beta 1

* Core and Builtins: Core and Builtins<57>.
* Library: Library<57>.
* Documentation: Documentation<51>.
* Tests: Tests<52>.
* Build: Build<55>.
* Windows: Windows<50>.
* macOS: macOS<42>.
* C API: C API<51>.

Python 3.7.0 alpha 4

* Core and Builtins: Core and Builtins<58>.
* Library: Library<58>.
* Documentation: Documentation<52>.
* Tests: Tests<53>.
* Windows: Windows<51>.
* Tools/Demos: Tools/Demos<28>.
* C API: C API<52>.

Python 3.7.0 alpha 3

* Core and Builtins: Core and Builtins<59>.
* Library: Library<59>.
* Documentation: Documentation<53>.
* Tests: Tests<54>.
* Build: Build<56>.
* Windows: Windows<52>.
* macOS: macOS<43>.
* IDLE: IDLE<43>.
* Tools/Demos: Tools/Demos<29>.
* C API: C API<53>.

Python 3.7.0 alpha 2

* Core and Builtins: Core and Builtins<60>.
* Library: Library<60>.
* Documentation: Documentation<54>.
* Build: Build<57>.
* IDLE: IDLE<44>.
* C API: C API<54>.

Python 3.7.0 alpha 1

* Security: Security<37>.
* Core and Builtins: Core and Builtins<61>.
* Library: Library<61>.
* Documentation: Documentation<55>.
* Tests: Tests<55>.
* Build: Build<58>.
* Windows: Windows<53>.
* IDLE: IDLE<45>.
* Tools/Demos: Tools/Demos<30>.
* C API: C API<55>.

Python 3.6.6 release candidate 1

* Core and Builtins: Core and Builtins<62>.
* Library: Library<62>.
* Documentation: Documentation<56>.
* Tests: Tests<56>.
* Build: Build<59>.
* Windows: Windows<54>.
* macOS: macOS<44>.
* IDLE: IDLE<46>.
* Tools/Demos: Tools/Demos<31>.
* C API: C API<56>.

Python 3.6.5 final

* Tests: Tests<57>.
* Build: Build<60>.

Python 3.6.5 release candidate 1

* Security: Security<38>.
* Core and Builtins: Core and Builtins<63>.
* Library: Library<63>.
* Documentation: Documentation<57>.
* Tests: Tests<58>.
* Build: Build<61>.
* Windows: Windows<55>.
* macOS: macOS<45>.
* IDLE: IDLE<47>.
* Tools/Demos: Tools/Demos<32>.
* C API: C API<57>.

Python 3.6.4 release candidate 1

* Core and Builtins: Core and Builtins<64>.
* Library: Library<64>.
* Documentation: Documentation<58>.
* Tests: Tests<59>.
* Build: Build<62>.
* Windows: Windows<56>.
* macOS: macOS<46>.
* IDLE: IDLE<48>.
* Tools/Demos: Tools/Demos<33>.
* C API: C API<58>.

Python 3.6.3 final

* Library: Library<65>.
* Build: Build<63>.

Python 3.6.3 release candidate 1

* Security: Security<39>.
* Core and Builtins: Core and Builtins<65>.
* Library: Library<66>.
* Documentation: Documentation<59>.
* Tests: Tests<60>.
* Build: Build<64>.
* Windows: Windows<57>.
* IDLE: IDLE<49>.
* Tools/Demos: Tools/Demos<34>.

Python 3.6.2 release candidate 2

* Security: Security<40>.

Python 3.6.2 release candidate 1

* Security: Security<41>.
* Core and Builtins: Core and Builtins<66>.
* Library: Library<67>.
* IDLE: IDLE<50>.
* C API: C API<59>.
* Build: Build<65>.
* Documentation: Documentation<60>.
* Tools/Demos: Tools/Demos<35>.
* Tests: Tests<61>.
* Windows: Windows<58>.

Python 3.6.1 final

* Core and Builtins: Core and Builtins<67>.
* Build: Build<66>.

Python 3.6.1 release candidate 1

* Core and Builtins: Core and Builtins<68>.
* Library: Library<68>.
* IDLE: IDLE<51>.
* Windows: Windows<59>.
* C API: C API<60>.
* Documentation: Documentation<61>.
* Tests: Tests<62>.
* Build: Build<67>.

Python 3.6.0 release candidate 2

* Core and Builtins: Core and Builtins<69>.
* Tools/Demos: Tools/Demos<36>.
* Windows: Windows<60>.
* Build: Build<68>.

Python 3.6.0 release candidate 1

* Core and Builtins: Core and Builtins<70>.
* Library: Library<69>.
* C API: C API<61>.
* Documentation: Documentation<62>.
* Tools/Demos: Tools/Demos<37>.

Python 3.6.0 beta 4

* Core and Builtins: Core and Builtins<71>.
* Library: Library<70>.
* Documentation: Documentation<63>.
* Tests: Tests<63>.
* Build: Build<69>.

Python 3.6.0 beta 3

* Core and Builtins: Core and Builtins<72>.
* Library: Library<71>.
* Windows: Windows<61>.
* Build: Build<70>.
* Tests: Tests<64>.

Python 3.6.0 beta 2

* Core and Builtins: Core and Builtins<73>.
* Library: Library<72>.
* Windows: Windows<62>.
* C API: C API<62>.
* Build: Build<71>.
* Tests: Tests<65>.

Python 3.6.0 beta 1

* Core and Builtins: Core and Builtins<74>.
* Library: Library<73>.
* IDLE: IDLE<52>.
* C API: C API<63>.
* Tests: Tests<66>.
* Build: Build<72>.
* Tools/Demos: Tools/Demos<38>.
* Windows: Windows<63>.

Python 3.6.0 alpha 4

* Core and Builtins: Core and Builtins<75>.
* Library: Library<74>.
* IDLE: IDLE<53>.
* Tests: Tests<67>.
* Windows: Windows<64>.
* Build: Build<73>.

Python 3.6.0 alpha 3

* Security: Security<42>.
* Core and Builtins: Core and Builtins<76>.
* Library: Library<75>.
* IDLE: IDLE<54>.
* C API: C API<64>.
* Build: Build<74>.
* Tools/Demos: Tools/Demos<39>.
* Documentation: Documentation<64>.
* Tests: Tests<68>.

Python 3.6.0 alpha 2

* Security: Security<43>.
* Core and Builtins: Core and Builtins<77>.
* Library: Library<76>.
* IDLE: IDLE<55>.
* Documentation: Documentation<65>.
* Tests: Tests<69>.
* Windows: Windows<65>.
* Build: Build<75>.
* C API: C API<65>.
* Tools/Demos: Tools/Demos<40>.

Python 3.6.0 alpha 1

* Security: Security<44>.
* Core and Builtins: Core and Builtins<78>.
* Library: Library<77>.
* IDLE: IDLE<56>.
* Documentation: Documentation<66>.
* Tests: Tests<70>.
* Build: Build<76>.
* Windows: Windows<66>.
* Tools/Demos: Tools/Demos<41>.
* C API: C API<66>.

Python 3.5.5 release candidate 1

* Security: Security<45>.
* Core and Builtins: Core and Builtins<79>.
* Library: Library<78>.

Python 3.5.4 final

* Library: Library<79>.

Python 3.5.4 release candidate 1

* Security: Security<46>.
* Core and Builtins: Core and Builtins<80>.
* Library: Library<80>.
* Documentation: Documentation<67>.
* Tests: Tests<71>.
* Build: Build<77>.
* Windows: Windows<67>.
* C API: C API<67>.

Python 3.5.3 release candidate 1

* Security: Security<47>.
* Core and Builtins: Core and Builtins<81>.
* Library: Library<81>.
* IDLE: IDLE<57>.
* C API: C API<68>.
* Documentation: Documentation<68>.
* Tests: Tests<72>.
* Tools/Demos: Tools/Demos<42>.
* Windows: Windows<68>.
* Build: Build<78>.

Python 3.5.2 final

* Core and Builtins: Core and Builtins<82>.
* Tests: Tests<73>.
* IDLE: IDLE<58>.

Python 3.5.2 release candidate 1

* Security: Security<48>.
* Core and Builtins: Core and Builtins<83>.
* Library: Library<82>.
* IDLE: IDLE<59>.
* Documentation: Documentation<69>.
* Tests: Tests<74>.
* Build: Build<79>.
* Windows: Windows<69>.
* Tools/Demos: Tools/Demos<43>.

Python 3.5.1 final

* Core and Builtins: Core and Builtins<84>.
* Windows: Windows<70>.

Python 3.5.1 release candidate 1

* Core and Builtins: Core and Builtins<85>.
* Library: Library<83>.
* IDLE: IDLE<60>.
* Documentation: Documentation<70>.
* Tests: Tests<75>.
* Build: Build<80>.
* Windows: Windows<71>.
* Tools/Demos: Tools/Demos<44>.

Python 3.5.0 final

* Build: Build<81>.

Python 3.5.0 release candidate 4

* Library: Library<84>.
* Build: Build<82>.

Python 3.5.0 release candidate 3

* Core and Builtins: Core and Builtins<86>.
* Library: Library<85>.

Python 3.5.0 release candidate 2

* Core and Builtins: Core and Builtins<87>.
* Library: Library<86>.

Python 3.5.0 release candidate 1

* Core and Builtins: Core and Builtins<88>.
* Library: Library<87>.
* IDLE: IDLE<61>.
* Documentation: Documentation<71>.
* Tests: Tests<76>.

Python 3.5.0 beta 4

* Core and Builtins: Core and Builtins<89>.
* Library: Library<88>.
* Build: Build<83>.

Python 3.5.0 beta 3

* Core and Builtins: Core and Builtins<90>.
* Library: Library<89>.
* Tests: Tests<77>.
* Documentation: Documentation<72>.
* Build: Build<84>.

Python 3.5.0 beta 2

* Core and Builtins: Core and Builtins<91>.
* Library: Library<90>.

Python 3.5.0 beta 1

* Core and Builtins: Core and Builtins<92>.
* Library: Library<91>.
* IDLE: IDLE<62>.
* Tests: Tests<78>.
* Documentation: Documentation<73>.
* Tools/Demos: Tools/Demos<45>.

Python 3.5.0 alpha 4

* Core and Builtins: Core and Builtins<93>.
* Library: Library<92>.
* Build: Build<85>.
* Tests: Tests<79>.
* Tools/Demos: Tools/Demos<46>.
* C API: C API<69>.

Python 3.5.0 alpha 3

* Core and Builtins: Core and Builtins<94>.
* Library: Library<93>.
* Build: Build<86>.
* Tests: Tests<80>.
* Tools/Demos: Tools/Demos<47>.

Python 3.5.0 alpha 2

* Core and Builtins: Core and Builtins<95>.
* Library: Library<94>.
* Build: Build<87>.
* C API: C API<70>.
* Windows: Windows<72>.

Python 3.5.0 alpha 1

* Core and Builtins: Core and Builtins<96>.
* Library: Library<95>.
* IDLE: IDLE<63>.
* Build: Build<88>.
* C API: C API<71>.
* Documentation: Documentation<74>.
* Tests: Tests<81>.
* Tools/Demos: Tools/Demos<48>.
* Windows: Windows<73>.

Python チュートリアル

* やる気を高めよう::
* Python インタプリタを使う::
* 形式ばらない Python の紹介::
* その他の制御フローツール::
* データ構造::
* モジュール: モジュール<2>.
* 入力と出力::
* エラーと例外::
* クラス::
* 標準ライブラリミニツアー::
* 標準ライブラリミニツアー: 標準ライブラリミニツアー --- その 2. その 2
* 仮想環境とパッケージ::
* さあ何を？::
* 対話入力編集と履歴置換::
* 浮動小数点演算、その問題と制限::
* 付録::

Python インタプリタを使う

* インタプリタを起動する::
* インタプリタとその環境::

インタプリタを起動する

* 引数の受け渡し::
* 対話モード::

インタプリタとその環境

* ソースコードの文字コード::

形式ばらない Python の紹介

* Python を電卓として使う::
* プログラミングへの第一歩::

Python を電卓として使う

* 数::
* テキスト::
* リスト型 (list): リスト型 list.

その他の制御フローツール

* if 文::
* for 文::
* range() 関数: range 関数.
* break and continue Statements::
* else Clauses on Loops::
* pass 文::
* match 文::
* 関数を定義する::
* 関数定義についてもう少し::
* 間奏曲; コーディングスタイル: 間奏曲 コーディングスタイル.

関数定義についてもう少し

* デフォルトの引数値::
* キーワード引数::
* 特殊なパラメータ::
* 任意引数リスト::
* 引数リストのアンパック::
* ラムダ式::
* ドキュメンテーション文字列::
* 関数のアノテーション::

特殊なパラメータ

* 位置またはキーワード引数::
* 位置専用引数: 位置専用引数<2>.
* キーワード専用引数::
* 関数の例::
* 要約::

データ構造

* リスト型についてもう少し::
* del 文::
* タプルとシーケンス::
* 集合型::
* 辞書型 (dictionary): 辞書型 dictionary.
* ループのテクニック::
* 条件についてもう少し::
* シーケンスとその他の型の比較::

リスト型についてもう少し

* リストをスタックとして使う::
* リストをキューとして使う::
* リストの内包表記: リストの内包表記<2>.
* ネストしたリストの内包表記::

モジュール

* モジュールについてもうすこし::
* 標準モジュール::
* dir() 関数: dir 関数.
* パッケージ::

モジュールについてもうすこし

* モジュールをスクリプトとして実行する::
* モジュール検索パス::
* "コンパイル" された Python ファイル::

パッケージ

* パッケージから * を import する::
* パッケージ内参照::
* 複数ディレクトリ中のパッケージ::

入力と出力

* 出力を見やすくフォーマットする::
* ファイルを読み書きする::

出力を見やすくフォーマットする

* フォーマット済み文字列リテラル::
* 文字列の format() メソッド: 文字列の format メソッド.
* 文字列の手作業でのフォーマット::
* 古い文字列書式設定方法::

ファイルを読み書きする

* ファイルオブジェクトのメソッド::
* json による構造化されたデータの保存::

エラーと例外

* 構文エラー::
* 例外::
* 例外を処理する::
* 例外を送出する::
* 例外の連鎖::
* ユーザー定義例外::
* クリーンアップ動作を定義する::
* 定義済みクリーンアップ処理::
* 複数の関連しない例外の送出と処理::
* ノートによって例外を充実させる::

クラス

* 名前とオブジェクトについて::
* Python のスコープと名前空間::
* クラス初見::
* いろいろな注意点::
* 継承::
* プライベート変数::
* 残りのはしばし::
* イテレータ (iterator): イテレータ iterator.
* ジェネレータ (generator): ジェネレータ generator.
* ジェネレータ式::

Python のスコープと名前空間

* スコープと名前空間の例::

クラス初見

* クラス定義の構文::
* クラスオブジェクト::
* インスタンスオブジェクト::
* メソッドオブジェクト::
* クラスとインスタンス変数::

継承

* 多重継承::

標準ライブラリミニツアー

* OSへのインターフェース::
* ファイルのワイルドカード表記::
* コマンドライン引数::
* エラー出力のリダイレクトとプログラムの終了::
* 文字列のパターンマッチング::
* 数学::
* インターネットへのアクセス::
* 日付と時刻::
* データ圧縮::
* パフォーマンスの計測::
* 品質管理::
* バッテリー同梱::

標準ライブラリミニツアー -- その 2

* 出力のフォーマット::
* 文字列テンプレート::
* バイナリデータレコードの操作::
* マルチスレッディング: マルチスレッディング<2>.
* ログ記録::
* 弱参照::
* リスト操作のためのツール::
* 10 進浮動小数演算::

仮想環境とパッケージ

* はじめに: はじめに<4>.
* 仮想環境の作成::
* pip を使ったパッケージ管理::

対話入力編集と履歴置換

* タブ補完と履歴編集::
* 対話的インタープリタの代替::

浮動小数点演算、その問題と制限

* 表現エラー::

付録

* 対話モード: 対話モード<2>.

対話モード

* エラー処理::
* 実行可能な Python スクリプト::
* 対話モード用の起動時実行ファイル::
* カスタマイズ用モジュール::

Python のセットアップと利用

* コマンドラインと環境::
* Unix プラットフォームで Python を使う::
* Python を構成する::
* Windows で Python を使う::
* Using Python on macOS::
* Using Python on Android::
* Using Python on iOS::
* エディタと IDE::

コマンドラインと環境

* コマンドライン::
* 環境変数::

コマンドライン

* インターフェイスオプション::
* 一般オプション::
* その他のオプション::
* 色の制御::
* 使うべきでないオプション::

環境変数

* デバッグモード変数::

Unix プラットフォームで Python を使う

* 最新バージョンの Python の取得とインストール::
* Python のビルド::
* Python に関係するパスとファイル::
* その他::
* Custom OpenSSL::

最新バージョンの Python の取得とインストール

* Linux::
* FreeBSD と OpenBSD::

Python を構成する

* ビルド要件::
* 生成されるファイル::
* Configureオプション::
* Python ビルドシステム::
* Compiler and linker flags::

生成されるファイル

* 構成スクリプト::

Configureオプション

* 一般的なオプション::
* C コンパイラのオプション::
* リンカのオプション::
* サードパーティ依存関係のオプション::
* WebAssembly オプション::
* インストールオプション::
* パフォーマンスに関するオプション::
* Python Debug Build::
* Debug options::
* リンカのオプション: リンカのオプション<2>.
* Libraries options::
* Security Options::
* macOS のオプション::
* iOS のオプション::
* クロスコンパイルのオプション::

Python ビルドシステム

* ビルドシステムの主要なファイル::
* 主要なビルドステップ::
* Main Makefile targets::
* C extensions::

Main Makefile targets

* make::
* make platform::
* make profile-opt::
* make clean::
* make distclean::
* make install::
* make test::
* make buildbottest::
* make regen-all::

Compiler and linker flags

* Preprocessor flags::
* Compiler flags::
* Linker flags::

Windows で Python を使う

* 完全版インストーラ::
* Microsoft ストアパッケージ::
* nuget.org パッケージ: nuget org パッケージ.
* 埋め込み可能なパッケージ::
* 別のバンドル::
* Python を構成する: Python を構成する<2>.
* UTF-8 モード::
* Windows の Python ランチャ::
* モジュールの検索::
* 追加のモジュール::
* Windows 上で Python をコンパイルする::
* ほかのプラットフォーム::

完全版インストーラ

* インストール手順::
* MAX_PATH の制限を除去する::
* インストーラの GUI なしでインストールする::
* ダウンロード不要なインストール::
* インストール後の変更::
* フリースレッドバイナリ (Free-threaded Binaries) のインストール: フリースレッドバイナリ Free-threaded Binaries のインストール.

Microsoft ストアパッケージ

* 既知の問題::

既知の問題

* Redirection of local data, registry, and temporary paths: Redirection of local data registry and temporary paths.

nuget.org パッケージ

* フリースレッドパッケージ (Free-threaded packages): フリースレッドパッケージ Free-threaded packages.

埋め込み可能なパッケージ

* Python アプリケーション::
* Python の埋め込み::

Python を構成する

* 補足; 環境変数の設定: 補足 環境変数の設定.
* Python 実行ファイルを見つける::

Windows の Python ランチャ

* 最初に::
* シェバン (shebang) 行: シェバン shebang 行.
* シェバン行の引数::
* カスタマイズ::
* 診断::
* Dry Run::
* Install on demand::
* Return codes::

最初に

* コマンドラインから起動する::
* 仮想環境 (Virtual environments): 仮想環境 Virtual environments.
* スクリプトから起動する::
* ファイルの関連付けから起動する::

カスタマイズ

* INI ファイルによるカスタマイズ::
* デフォルトのPythonバージョンのカスタマイズ::

追加のモジュール

* PyWin32::
* cx_Freeze::

Using Python on macOS

* Using Python for macOS from python.org: Using Python for macOS from python org.
* Alternative Distributions::
* 追加の Python パッケージのインストール::
* GUI プログラミング::
* 高度なトピック::
* 他のリソース::

Using Python for macOS from python.org

* インストール手順: インストール手順<2>.
* Python スクリプトの実行方法::

高度なトピック

* フリースレッドバイナリ (Free-threaded Binaries) のインストール: フリースレッドバイナリ Free-threaded Binaries のインストール<2>.
* Installing using the command line::
* Python アプリケーションの配布::
* App Store コンプライアンス::

Using Python on Android

* Adding Python to an Android app::

Using Python on iOS

* Python at runtime on iOS::
* Installing Python on iOS::
* App Store Compliance::

Python at runtime on iOS

* iOS version compatibility::
* Platform identification::
* Standard library availability::
* Binary extension modules::
* Compiler stub binaries::

Installing Python on iOS

* Tools for building iOS apps::
* Adding Python to an iOS project::

Python 言語リファレンス

* はじめに: はじめに<5>.
* 字句解析::
* データモデル::
* 実行モデル::
* インポートシステム::
* 式 (expression): 式 expression.
* 単純文 (simple statement): 単純文 simple statement.
* 複合文 (compound statement): 複合文 compound statement.
* トップレベル要素::
* 完全な文法仕様::

はじめに

* 別のPythonの実装::
* 本マニュアルにおける表記法::

字句解析

* 行構造::
* その他のトークン::
* 識別子 (identifier) およびキーワード (keyword): 識別子 identifier およびキーワード keyword.
* リテラル::
* 演算子::
* デリミタ (delimiter): デリミタ delimiter.

行構造

* 論理行 (logical line): 論理行 logical line.
* 物理行 (physical line): 物理行 physical line.
* コメント (Comments): コメント Comments.
* エンコード宣言 (encoding declaration): エンコード宣言 encoding declaration.
* 明示的な行継続::
* 非明示的な行継続::
* 空行::
* インデント::
* トークン間の空白::

識別子 (identifier) およびキーワード (keyword)

* キーワード (keyword): キーワード keyword.
* ソフトキーワード::
* 予約済みの識別子種 (reserved classes of identifiers): 予約済みの識別子種 reserved classes of identifiers.

リテラル

* 文字列およびバイト列リテラル::
* 文字列リテラルの結合 (concatenation): 文字列リテラルの結合 concatenation.
* f-strings::
* 数値リテラル::
* 整数リテラル::
* Floating-point literals::
* 虚数 (imaginary) リテラル: 虚数 imaginary リテラル.

文字列およびバイト列リテラル

* Escape sequences::

データモデル

* オブジェクト、値、および型::
* 標準型の階層::
* 特殊メソッド名::
* コルーチン::

標準型の階層

* None::
* NotImplemented::
* Ellipsis::
* numbers.Number: numbers Number.
* シーケンス型 (sequence): シーケンス型 sequence.
* 集合型: 集合型<2>.
* マッピング型 (mapping): マッピング型 mapping.
* 呼び出し可能型 (callable type): 呼び出し可能型 callable type.
* モジュール: モジュール<3>.
* カスタムクラス型::
* クラスインスタンス (class instance): クラスインスタンス class instance.
* I/O オブジェクト (ファイルオブジェクトの別名): I/O オブジェクト ファイルオブジェクトの別名.
* 内部型 (internal type): 内部型 internal type.

numbers.Number

* numbers.Integral (整数): numbers Integral 整数.
* numbers.Real (float) (実数): numbers Real float 実数.
* numbers.Complex (complex): numbers Complex complex.

シーケンス型 (sequence)

* 変更不能なシーケンス (immutable sequence): 変更不能なシーケンス immutable sequence.
* 変更可能なシーケンス型 (mutable sequence): 変更可能なシーケンス型 mutable sequence.

マッピング型 (mapping)

* 辞書型 (dictionary): 辞書型 dictionary<2>.

呼び出し可能型 (callable type)

* ユーザ定義関数 (user-defined function): ユーザ定義関数 user-defined function.
* インスタンスメソッド::
* ジェネレータ関数 (generator function): ジェネレータ関数 generator function.
* コルーチン関数 (coroutine function): コルーチン関数 coroutine function.
* 非同期ジェネレータ関数 (asynchronous generator function): 非同期ジェネレータ関数 asynchronous generator function.
* 組み込み関数 (built-in function): 組み込み関数 built-in function.
* 組み込みメソッド (built-in method): 組み込みメソッド built-in method.
* クラス: クラス<2>.
* クラスのインスタンス::

ユーザ定義関数 (user-defined function)

* Special read-only attributes::
* Special writable attributes::

モジュール

* Import-related attributes on module objects::
* Other writable attributes on module objects::
* Module dictionaries::

カスタムクラス型

* Special attributes::
* Special methods::

クラスインスタンス (class instance)

* Special attributes: Special attributes<2>.

内部型 (internal type)

* コードオブジェクト::
* フレーム (frame) オブジェクト: フレーム frame オブジェクト.
* トレースバック (traceback) オブジェクト: トレースバック traceback オブジェクト.
* スライス (slice) オブジェクト: スライス slice オブジェクト.
* 静的メソッド (static method) オブジェクト: 静的メソッド static method オブジェクト.
* クラスメソッドオブジェクト::

コードオブジェクト

* Special read-only attributes: Special read-only attributes<2>.
* Methods on code objects::

フレーム (frame) オブジェクト

* Special read-only attributes: Special read-only attributes<3>.
* Special writable attributes: Special writable attributes<2>.
* Frame object methods::

特殊メソッド名

* 基本的なカスタマイズ::
* 属性値アクセスをカスタマイズする::
* クラス生成をカスタマイズする::
* インスタンスのカスタマイズとサブクラスチェック::
* ジェネリック型をエミュレートする::
* 呼び出し可能オブジェクトをエミュレートする::
* コンテナをエミュレートする::
* 数値型をエミュレートする::
* with文とコンテキストマネージャ::
* クラスパターンマッチの位置引数のカスタマイズ::
* Emulating buffer types::
* 特殊メソッド検索::

属性値アクセスをカスタマイズする

* モジュールの属性値アクセスをカスタマイズする::
* デスクリプタ (descriptor) の実装: デスクリプタ descriptor の実装.
* デスクリプタの呼び出し::
* __slots__: __slots__<2>.

クラス生成をカスタマイズする

* メタクラス::
* MRO エントリの解決::
* 適切なメタクラスの決定::
* クラスの名前空間の準備::
* クラス本体の実行::
* クラスオブジェクトの作成::
* メタクラスの用途::

ジェネリック型をエミュレートする

* The purpose of __class_getitem__::
* __class_getitem__ versus __getitem__::

コルーチン

* 待機可能オブジェクト (Awaitable Object): 待機可能オブジェクト Awaitable Object.
* コルーチンオブジェクト::
* 非同期イテレータ (Asynchronous Iterator): 非同期イテレータ Asynchronous Iterator.
* 非同期コンテキストマネージャ (Asynchronous Context Manager): 非同期コンテキストマネージャ Asynchronous Context Manager.

実行モデル

* プログラムの構造::
* 名前づけと束縛 (naming and binding): 名前づけと束縛 naming and binding.
* 例外: 例外<2>.

名前づけと束縛 (naming and binding)

* 名前の束縛::
* 名前解決::
* Annotation scopes::
* Lazy evaluation::
* 組み込みと制限付きの実行::
* 動的な機能とのやりとり::

インポートシステム

* importlib: importlib<10>.
* パッケージ: パッケージ<2>.
* 検索::
* ロード::
* パスベース・ファインダー::
* 標準のインポートシステムを置き換える::
* Package Relative Imports::
* __main__ に対する特別な考慮::
* 参考資料::

パッケージ

* 通常のパッケージ::
* 名前空間パッケージ::

検索

* モジュールキャッシュ::
* ファインダーとローダー::
* インポートフック::
* メタパス::

ロード

* ローダー::
* サブモジュール::
* Module specs::
* __path__ attributes on modules::
* モジュールの repr::
* キャッシュされたバイトコードの無効化::

パスベース・ファインダー

* パスエントリ・ファインダー::
* パスエントリ・ファインダー・プロトコル::

__main__ に対する特別な考慮

* __main__.__spec__: __main__ __spec__.

式 (expression)

* 算術変換 (arithmetic conversion): 算術変換 arithmetic conversion.
* アトム、原子的要素 (atom): アトム、原子的要素 atom.
* プライマリ::
* Await 式::
* べき乗演算 (power operator): べき乗演算 power operator.
* 単項算術演算とビット単位演算 (unary arithmetic and bitwise operation): 単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
* 二項算術演算 (binary arithmetic operation): 二項算術演算 binary arithmetic operation.
* シフト演算 (shifting operation): シフト演算 shifting operation.
* ビット単位演算の二項演算 (binary bitwise operation): ビット単位演算の二項演算 binary bitwise operation.
* 比較::
* ブール演算 (boolean operation): ブール演算 boolean operation.
* 代入式: 代入式<2>.
* 条件式 (Conditional Expressions): 条件式 Conditional Expressions.
* ラムダ (lambda): ラムダ lambda.
* 式のリスト::
* 評価順序::
* 演算子の優先順位::

アトム、原子的要素 (atom)

* 識別子 (identifier、または名前 (name)): 識別子 identifier、または名前 name.
* リテラル: リテラル<2>.
* 丸括弧形式 (parenthesized form): 丸括弧形式 parenthesized form.
* リスト、集合、辞書の表示::
* リスト表示::
* 集合表示::
* 辞書表示::
* ジェネレータ式: ジェネレータ式<2>.
* Yield 式::

識別子 (identifier、または名前 (name))

* Private name mangling::

Yield 式

* ジェネレータ-イテレータメソッド::
* 使用例::
* 非同期ジェネレータ関数 (asynchronous generator function): 非同期ジェネレータ関数 asynchronous generator function<2>.
* 非同期ジェネレータイテレータメソッド::

プライマリ

* 属性参照::
* 添字表記 (subscription): 添字表記 subscription.
* スライス表記 (slicing): スライス表記 slicing.
* 呼び出し (call): 呼び出し call.

比較

* 値の比較::
* 所属検査演算::
* 同一性の比較::

単純文 (simple statement)

* 式文 (expression statement): 式文 expression statement.
* 代入文 (assignment statement): 代入文 assignment statement.
* assert 文::
* pass 文: pass 文<2>.
* del 文: del 文<2>.
* return 文::
* yield 文::
* raise 文::
* break 文::
* continue 文::
* import 文::
* global 文::
* nonlocal 文::
* The type statement::

代入文 (assignment statement)

* 累算代入文 (augmented assignment statement): 累算代入文 augmented assignment statement.
* 注釈付き代入文 (annotated assignment statements): 注釈付き代入文 annotated assignment statements.

import 文

* future 文 (future statement): future 文 future statement.

複合文 (compound statement)

* if 文: if 文<2>.
* while 文::
* for 文: for 文<2>.
* try 文::
* with 文::
* match 文: match 文<2>.
* 関数定義::
* クラス定義::
* コルーチン: コルーチン<2>.
* Type parameter lists::

try 文

* except 節::
* except* 節::
* else 節::
* finally 節::

match 文

* 概要::
* ガード::
* 論駁不可能なケースブロック::
* パターン::

パターン

* OR パターン::
* AS パターン::
* リテラルパターン::
* キャプチャパターン::
* ワイルドカードパターン::
* 値パターン::
* グループパターン::
* シーケンスパターン::
* マッピングパターン::
* クラスパターン::

コルーチン

* コルーチン関数定義::
* async for 文::
* async with 文::

Type parameter lists

* Generic functions::
* Generic classes::
* Generic type aliases::

トップレベル要素

* 完全な Python プログラム::
* ファイル入力::
* 対話的入力::
* 式入力::

Python 標準ライブラリ

* はじめに: はじめに<6>.
* 組み込み関数::
* 組み込み定数::
* 組み込み型::
* 組み込み例外::
* テキスト処理サービス::
* バイナリデータ処理::
* データ型::
* 数値と数学モジュール::
* 関数型プログラミング用モジュール::
* ファイルとディレクトリへのアクセス::
* データの永続化::
* データ圧縮とアーカイブ::
* ファイルフォーマット::
* 暗号関連のサービス::
* 汎用オペレーティングシステムサービス::
* 並行実行::
* ネットワーク通信とプロセス間通信::
* インターネット上のデータの操作::
* 構造化マークアップツール::
* インターネットプロトコルとサポート::
* マルチメディアサービス::
* 国際化::
* プログラムのフレームワーク::
* Tk を用いたグラフィカルユーザーインターフェース::
* 開発ツール::
* デバッグとプロファイル::
* ソフトウェア・パッケージと配布::
* Python ランタイムサービス::
* カスタム Python インタプリタ::
* モジュールのインポート::
* Python言語サービス::
* MS Windows 固有のサービス::
* Unix 固有のサービス::
* モジュールのコマンドラインインターフェース (CLI): モジュールのコマンドラインインターフェース CLI.
* 取って代わられたモジュール群::
* セキュリティで考慮すべき点: セキュリティで考慮すべき点<6>.

はじめに

* 利用可能性について::

利用可能性について

* WebAssembly プラットフォーム::
* Mobile platforms::

組み込み定数

* site モジュールで追加される定数::

組み込み型

* 真理値判定::
* ブール演算: ブール演算 --- and or not. and, or, not
* 比較: 比較<2>.
* 数値型 int, float, complex: 数値型 int float complex.
* ブーリアン型 - bool::
* イテレータ型::
* シーケンス型: シーケンス型 --- list tuple range. list, tuple, range
* テキストシーケンス型: テキストシーケンス型 --- str. str
* バイナリシーケンス型: バイナリシーケンス型 --- bytes bytearray memoryview. bytes, bytearray, memoryview
* set（集合）型: set（集合）型 --- set frozenset. set, frozenset
* マッピング型: マッピング型 --- dict. dict
* コンテキストマネージャ型::
* 型アノテーション型: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン. ジェネリックエイリアス 、 ユニオン
* その他の組み込み型::
* 特殊属性::
* 整数と文字列の変換での長さ制限::

数値型 int, float, complex

* 整数型におけるビット単位演算::
* 整数型における追加のメソッド::
* 浮動小数点数に対する追加のメソッド::
* 数値型のハッシュ化::

イテレータ型

* ジェネレータ型::

シーケンス型 -- list, tuple, range

* 共通のシーケンス演算::
* イミュータブルなシーケンス型::
* ミュータブルなシーケンス型::
* リスト型 (list): リスト型 list<2>.
* タプル型 (tuple): タプル型 tuple.
* range::

テキストシーケンス型 -- str

* 文字列メソッド: 文字列メソッド<2>.
* printf 形式の文字列書式化::

バイナリシーケンス型 -- bytes, bytearray, memoryview

* バイトオブジェクト::
* bytearray オブジェクト::
* bytes と bytearray の操作::
* printf 形式での bytes の書式化::
* メモリビュー::

マッピング型 -- dict

* 辞書ビューオブジェクト::

型アノテーション型 -- ジェネリックエイリアス 、 ユニオン

* ジェネリックエイリアス型::
* Union 型::

ジェネリックエイリアス型

* 標準ジェネリッククラス::
* GenericAlias オブジェクトの特別な属性::

その他の組み込み型

* モジュール: モジュール<4>.
* クラスおよびクラスインスタンス::
* 関数::
* メソッド::
* コードオブジェクト: コードオブジェクト<2>.
* 型オブジェクト::
* ヌルオブジェクト::
* Ellipsis オブジェクト::
* NotImplemented オブジェクト::
* 内部オブジェクト::

整数と文字列の変換での長さ制限

* 影響のあるAPI::
* 上限値を設定する::
* 推奨設定::

組み込み例外

* 例外コンテキスト::
* 組み込み例外から継承する::
* 基底クラス::
* 具象例外::
* 警告::
* 例外グループ::
* 例外のクラス階層::

具象例外

* OS 例外::

テキスト処理サービス

* string: string --- 一般的な文字列操作. 一般的な文字列操作
* re: re --- 正規表現操作. 正規表現操作
* difflib: difflib --- 差分の計算の補助. 差分の計算の補助
* textwrap: textwrap --- テキストの折り返しと詰め込み. テキストの折り返しと詰め込み
* unicodedata: unicodedata --- Unicode データベース. Unicode データベース
* stringprep: stringprep --- インターネットの文字列調製. インターネットの文字列調製
* readline: readline --- GNU readline のインターフェース. GNU readline のインターフェース
* rlcompleter: rlcompleter --- GNU readline の補完機能. GNU readline の補完機能

string -- 一般的な文字列操作

* 文字列定数::
* カスタムの文字列書式化::
* 書式指定文字列の文法::
* テンプレート文字列::
* ヘルパー関数::

書式指定文字列の文法

* 書式指定ミニ言語仕様::
* 書式指定例::

re -- 正規表現操作

* 正規表現のシンタックス::
* モジュールコンテンツ::
* 正規表現オブジェクト::
* マッチオブジェクト::
* 正規表現の例::

モジュールコンテンツ

* フラグ::
* 関数: 関数<2>.
* 例外: 例外<3>.

正規表現の例

* ペアの確認::
* scanf() をシミュレートする: scanf をシミュレートする.
* search() vs. match(): search vs match.
* 電話帳を作る::
* テキストの秘匿::
* 全ての副詞を見つける::
* 全ての副詞とその位置を見つける::
* Raw 文字列記法::
* トークナイザを書く::

difflib -- 差分の計算の補助

* SequenceMatcherオブジェクト::
* SequenceMatcher の例::
* Differ オブジェクト::
* Differ の例::
* difflib のコマンドラインインターフェース::
* ndiff example::

readline -- GNU readline のインターフェース

* 初期化ファイル::
* 行バッファ::
* 履歴ファイル::
* 履歴リスト::
* 開始フック::
* 補完::
* 使用例: 使用例<2>.

バイナリデータ処理

* struct: struct --- バイト列をパックされたバイナリデータとして解釈する. バイト列をパックされたバイナリデータとして解釈する
* codecs: codecs --- codec レジストリと基底クラス. codec レジストリと基底クラス

struct -- バイト列をパックされたバイナリデータとして解釈する

* 関数と例外::
* 書式文字列::
* Applications::
* クラス: クラス<3>.

書式文字列

* バイトオーダ、サイズ、アラインメント::
* 書式指定文字::
* 使用例: 使用例<3>.

Applications

* Native Formats::
* Standard Formats::

codecs -- codec レジストリと基底クラス

* Codec 基底クラス::
* エンコーディングと Unicode::
* 標準エンコーディング::
* Python 特有のエンコーディング::
* encodings.idna: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA. アプリケーションにおける国際化ドメイン名 (IDNA)
* encodings.mbcs: encodings mbcs --- Windows ANSI コードページ. Windows ANSI コードページ
* encodings.utf_8_sig: encodings utf_8_sig --- BOM 印付き UTF-8. BOM 印付き UTF-8

Codec 基底クラス

* エラーハンドラ::
* ステートレスなエンコードとデコード::
* インクリメンタルなエンコードとデコード::
* ストリームのエンコードとデコード::

インクリメンタルなエンコードとデコード

* IncrementalEncoder オブジェクト::
* IncrementalDecoder オブジェクト::

ストリームのエンコードとデコード

* StreamWriter オブジェクト::
* StreamReader オブジェクト::
* StreamReaderWriter オブジェクト::
* StreamRecoder オブジェクト::

Python 特有のエンコーディング

* テキストエンコーディング::
* バイナリ変換 (Binary Transforms): バイナリ変換 Binary Transforms.
* テキスト変換 (Text Transforms): テキスト変換 Text Transforms.

データ型

* datetime: datetime --- 基本的な日付と時間の型. 基本的な日付と時間の型
* zoneinfo: zoneinfo --- IANA タイムゾーンのサポート. IANA タイムゾーンのサポート
* calendar: calendar --- 一般的なカレンダーに関係する機能群. 一般的なカレンダーに関係する機能群
* collections: collections --- コンテナデータ型. コンテナデータ型
* collections.abc: collections abc --- コンテナの抽象基底クラス. コンテナの抽象基底クラス
* heapq: heapq --- ヒープキューアルゴリズム. ヒープキューアルゴリズム
* bisect: bisect --- 配列二分法アルゴリズム. 配列二分法アルゴリズム
* array: array --- 効率的な数値配列. 効率的な数値配列
* weakref: weakref --- 弱参照. 弱参照
* types: types --- 動的な型生成と組み込み型の名前. 動的な型生成と組み込み型の名前
* copy: copy --- 浅いコピーおよび深いコピー操作. 浅いコピーおよび深いコピー操作
* pprint: pprint --- データの整形表示. データの整形表示
* reprlib: reprlib --- もう一つの repr の実装. もう一つの repr() の実装
* enum: enum --- 列挙型のサポート. 列挙型のサポート
* graphlib: graphlib --- グラフ構造を操作する機能. グラフ構造を操作する機能

datetime -- 基本的な日付と時間の型

* Aware オブジェクトと Naive オブジェクト::
* 定数::
* 利用可能なデータ型::
* timedelta オブジェクト::
* date オブジェクト::
* datetime オブジェクト::
* time オブジェクト::
* tzinfo オブジェクト::
* timezone オブジェクト::
* strftime() と strptime() の振る舞い: strftime と strptime の振る舞い.

利用可能なデータ型

* 共通の特徴::
* オブジェクトが Aware なのか Naive なのかの判断::

timedelta オブジェクト

* 使用例; timedelta: 使用例 timedelta.

date オブジェクト

* 使用例; date: 使用例 date.

datetime オブジェクト

* 使用例; datetime: 使用例 datetime.

time オブジェクト

* 使用例; time: 使用例 time.

strftime() と strptime() の振る舞い

* strftime() と strptime() の書式コード: strftime と strptime の書式コード.
* 技術詳細::

zoneinfo -- IANA タイムゾーンのサポート

* ZoneInfo を使用する::
* データソース::
* ZoneInfo クラス::
* 関数: 関数<3>.
* Globals::
* 例外と警告::

データソース

* Configuring the data sources::

Configuring the data sources

* Compile-time configuration::
* Environment configuration::
* Runtime configuration::

ZoneInfo クラス

* 文字列表現::
* Pickle serialization::

calendar -- 一般的なカレンダーに関係する機能群

* コマンドラインからの使用::

collections -- コンテナデータ型

* ChainMap オブジェクト::
* Counter オブジェクト::
* deque オブジェクト::
* defaultdict オブジェクト::
* namedtuple() 名前付きフィールドを持つタプルのファクトリ関数: namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
* OrderedDict オブジェクト::
* UserDict オブジェクト::
* UserList オブジェクト::
* UserString オブジェクト::

ChainMap オブジェクト

* ChainMap の例とレシピ::

deque オブジェクト

* deque のレシピ::

defaultdict オブジェクト

* defaultdict の使用例::

OrderedDict オブジェクト

* OrderedDict の例とレシピ::

collections.abc -- コンテナの抽象基底クラス

* コレクション抽象基底クラス::
* コレクションの抽象基底クラス: コレクションの抽象基底クラス -- 詳細な説明. 詳細な説明
* 例とレシピ::

heapq -- ヒープキューアルゴリズム

* 基本的な例::
* 優先度キュー実装の注釈::
* 理論::

bisect -- 配列二分法アルゴリズム

* パフォーマンスに関するメモ::
* ソート済みリストの探索::
* 使用例: 使用例<4>.

weakref -- 弱参照

* 弱参照オブジェクト::
* 使用例: 使用例<5>.
* ファイナライザオブジェクト::
* Comparing finalizers with __del__() methods: Comparing finalizers with __del__ methods.

types -- 動的な型生成と組み込み型の名前

* 動的な型生成::
* 標準的なインタプリタ型::
* 追加のユーティリティクラスと関数::
* コルーチンユーティリティ関数::

pprint -- データの整形表示

* 関数: 関数<4>.
* PrettyPrinter オブジェクト::
* 使用例: 使用例<6>.

reprlib -- もう一つの repr() の実装

* Reprオブジェクト::
* Reprオブジェクトをサブクラス化する::

enum -- 列挙型のサポート

* モジュールコンテンツ: モジュールコンテンツ<2>.
* データ型: データ型<2>.
* ユーティリティとデコレータ::
* 注釈::

データ型

* __dunder__ 名のサポート::
* _sunder_ 名のサポート::

graphlib -- グラフ構造を操作する機能

* 例外: 例外<4>.

数値と数学モジュール

* numbers: numbers --- 数の抽象基底クラス. 数の抽象基底クラス
* math: math --- 数学関数. 数学関数
* cmath: cmath --- 複素数用の数学関数. 複素数用の数学関数
* decimal: decimal --- 10進固定小数点と浮動小数点の演算. 10進固定小数点と浮動小数点の演算
* fractions: fractions --- 有理数. 有理数
* random: random --- 疑似乱数を生成する. 疑似乱数を生成する
* statistics: statistics --- 数学的統計関数. 数学的統計関数

numbers -- 数の抽象基底クラス

* 数値塔::
* Notes for type implementers::

Notes for type implementers

* さらに数のABCを追加する::
* 算術演算の実装::

math -- 数学関数

* 数論および数表現の関数::
* 指数関数と対数関数::
* 三角関数::
* 角度変換::
* 双曲線関数::
* 特殊関数::
* 定数: 定数<2>.

cmath -- 複素数用の数学関数

* 極座標変換::
* 指数関数と対数関数: 指数関数と対数関数<2>.
* 三角関数: 三角関数<2>.
* 双曲線関数: 双曲線関数<2>.
* 類別関数::
* 定数: 定数<3>.

decimal -- 10進固定小数点と浮動小数点の演算

* クイックスタートチュートリアル::
* Decimal オブジェクト::
* Context オブジェクト::
* 定数: 定数<4>.
* 丸めモード::
* シグナル::
* Floating-Point Notes::
* スレッドを使った処理::
* レシピ::
* Decimal FAQ::

Decimal オブジェクト

* 論理引数::

Floating-Point Notes

* 精度を上げて丸め誤差を抑制する::
* 特殊値::

random -- 疑似乱数を生成する

* 保守 (bookkeeping) 関数: 保守 bookkeeping 関数.
* バイト列用の関数::
* 整数用の関数::
* シーケンス用の関数::
* Discrete distributions::
* 実数分布::
* 他の生成器::
* 再現性について::
* 使用例: 使用例<7>.
* レシピ: レシピ<2>.
* コマンドラインでの使用::
* コマンドラインの例::

statistics -- 数学的統計関数

* 平均及び中心位置の測度::
* 分散の測度::
* 2入力間の関係の統計::
* 関数の詳細::
* 例外: 例外<5>.
* NormalDist オブジェクト::
* 例とレシピ: 例とレシピ<2>.

例とレシピ

* Classic probability problems::
* Monte Carlo inputs for simulations::
* Approximating binomial distributions::
* Naive bayesian classifier::

関数型プログラミング用モジュール

* itertools: itertools --- 効率的なループ用のイテレータ生成関数群. 効率的なループ用のイテレータ生成関数群
* functools: functools --- 高階関数と呼び出し可能オブジェクトの操作. 高階関数と呼び出し可能オブジェクトの操作
* operator: operator --- 関数形式の標準演算子. 関数形式の標準演算子

itertools -- 効率的なループ用のイテレータ生成関数群

* Itertool関数::
* Itertools レシピ::

functools -- 高階関数と呼び出し可能オブジェクトの操作

* partial オブジェクト::

operator -- 関数形式の標準演算子

* 演算子から関数への対応表::
* インプレース (in-place) 演算子: インプレース in-place 演算子.

ファイルとディレクトリへのアクセス

* pathlib: pathlib --- オブジェクト指向のファイルシステムパス. オブジェクト指向のファイルシステムパス
* os.path: os path --- 一般的なパス名操作. 一般的なパス名操作
* fileinput: fileinput --- 複数の入力ストリームをまたいだ行を反復する. 複数の入力ストリームをまたいだ行を反復する
* stat: stat --- stat の結果を解釈する. stat() の結果を解釈する
* filecmp: filecmp --- ファイルとディレクトリの比較. ファイルとディレクトリの比較
* tempfile: tempfile --- 一時ファイルやディレクトリの作成. 一時ファイルやディレクトリの作成
* glob: glob --- Unix 形式のパス名のパターン展開. Unix 形式のパス名のパターン展開
* fnmatch: fnmatch --- Unix のファイル名パターンマッチ. Unix のファイル名パターンマッチ
* linecache: linecache --- テキストラインへのランダムアクセス. テキストラインへのランダムアクセス
* shutil: shutil --- 高水準のファイル操作. 高水準のファイル操作

pathlib -- オブジェクト指向のファイルシステムパス

* 基本的な使い方::
* 例外: 例外<6>.
* 純粋パス::
* 具象パス::
* Pattern language::
* glob モジュールとの比較::
* os と os.path モジュールの比較: os と os path モジュールの比較.

純粋パス

* 全般的な性質::
* 演算子: 演算子<2>.
* 個別の構成要素へのアクセス::
* メソッドとプロパティ::

具象パス

* URIのパースと生成::
* パスの展開と解決::
* ファイルの種類とステータスを問い合わせる::
* ファイルを読み書きする: ファイルを読み書きする<2>.
* ディレクトリを読む::
* ファイルとディレクトリの作成::
* リネームと削除::
* パーミッションと所有者::

os と os.path モジュールの比較

* 対応するツール::

filecmp -- ファイルとディレクトリの比較

* dircmp クラス::

tempfile -- 一時ファイルやディレクトリの作成

* 使用例: 使用例<8>.
* 非推奨の関数と変数::

glob -- Unix 形式のパス名のパターン展開

* 使用例: 使用例<9>.

shutil -- 高水準のファイル操作

* ディレクトリとファイルの操作::
* アーカイブ化操作::
* 出力ターミナルのサイズの取得::

ディレクトリとファイルの操作

* プラットフォーム依存の効率的なコピー操作::
* copytree の例::
* rmtree の例::

アーカイブ化操作

* アーカイブ化の例::
* base_dir を使ったアーカイブ化の例::

データの永続化

* pickle: pickle --- Python オブジェクトの直列化. Python オブジェクトの直列化
* copyreg: copyreg --- pickle サポート関数を登録する. pickle サポート関数を登録する
* shelve: shelve --- Python オブジェクトの永続化. Python オブジェクトの永続化
* marshal: marshal --- 内部使用向けの Python オブジェクト直列化. 内部使用向けの Python オブジェクト直列化
* dbm: dbm --- Unix "データベース" へのインターフェース. Unix "データベース" へのインターフェース
* sqlite3: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース. SQLite データベース用の DB-API 2.0 インターフェース

pickle -- Python オブジェクトの直列化

* 他の Python モジュールとの関係::
* データストリームの形式::
* モジュールインターフェース::
* pickle 化、非 pickle 化できるもの::
* クラスインスタンスの pickle 化::
* 型、関数、その他のオブジェクトに対するリダクションのカスタマイズ::
* アウトオブバウンドバッファ::
* グローバル変数を制限する::
* 性能: 性能<2>.
* 使用例: 使用例<11>.

他の Python モジュールとの関係

* marshal との比較::
* json との比較::

クラスインスタンスの pickle 化

* 外部オブジェクトの永続化::
* ディスパッチテーブル::
* 状態を持つオブジェクトの扱い::

アウトオブバウンドバッファ

* 生産者 API::
* 消費者 API::
* 使用例: 使用例<10>.

copyreg -- pickle サポート関数を登録する

* 使用例: 使用例<12>.

shelve -- Python オブジェクトの永続化

* 制限事項::
* 使用例: 使用例<13>.

dbm -- Unix "データベース" へのインターフェース

* dbm.sqlite3: dbm sqlite3 --- SQLite backend for dbm. SQLite backend for dbm
* dbm.gnu: dbm gnu --- GNU database manager. GNU database manager
* dbm.ndbm: dbm ndbm --- New Database Manager. New Database Manager
* dbm.dumb: dbm dumb --- 可搬性のある DBM 実装. 可搬性のある DBM 実装

sqlite3 -- SQLite データベース用の DB-API 2.0 インターフェース

* チュートリアル::
* リファレンス::
* ハウツー・ガイド::
* 説明::

リファレンス

* モジュール関数::
* モジュール定数::
* Connection オブジェクト::
* Cursor オブジェクト::
* Row オブジェクト::
* Blob オブジェクト::
* PrepareProtocol オブジェクト::
* 例外: 例外<7>.
* SQLite と Python の型::
* デフォルトの適合関数(adapters)とデフォルトの変換関数(converters)(非推奨): デフォルトの適合関数 adapters とデフォルトの変換関数 converters 非推奨.
* コマンドライン・インターフェース::

ハウツー・ガイド

* プレースホルダを使用して SQL クエリに値を結び付ける方法::
* カスタム Python 型を SQLite 値に適合させる方法::
* SQLite 値をカスタム Python 型に変換する方法::
* 適合関数と変換関数のレシピ集::
* 接続(connection)ショートカット・メソッドの使い方: 接続 connection ショートカット・メソッドの使い方.
* 接続(connection)コンテキストマネージャの使い方: 接続 connection コンテキストマネージャの使い方.
* SQLite URI の操作方法::
* 行工場(row factories)の作成方法と使用方法: 行工場 row factories の作成方法と使用方法.
* How to handle non-UTF-8 text encodings::

カスタム Python 型を SQLite 値に適合させる方法

* 適合可能オブジェクトの書き方::
* 適合用呼び出し可能オブジェクト(adapter callables)の登録方法: 適合用呼び出し可能オブジェクト adapter callables の登録方法.

説明

* トランザクション制御::

トランザクション制御

* autocommit 属性に依るトランザクション制御::
* isolation_level 属性に依るトランザクション制御::

データ圧縮とアーカイブ

* zlib: zlib --- gzip 互換の圧縮. gzip 互換の圧縮
* gzip: gzip --- gzip ファイルのサポート. gzip ファイルのサポート
* bz2: bz2 --- bzip2 圧縮のサポート. bzip2 圧縮のサポート
* lzma: lzma --- LZMA アルゴリズムを使用した圧縮. LZMA アルゴリズムを使用した圧縮
* zipfile: zipfile --- ZIP アーカイブの処理. ZIP アーカイブの処理
* tarfile: tarfile --- tar アーカイブファイルの読み書き. tar アーカイブファイルの読み書き

gzip -- gzip ファイルのサポート

* 使い方の例::
* コマンドラインインターフェイス::

コマンドラインインターフェイス

* コマンドラインオプション::

bz2 -- bzip2 圧縮のサポート

* ファイルの圧縮/解凍::
* 逐次圧縮および展開::
* 一括圧縮/解凍::
* 使い方の例: 使い方の例<2>.

lzma -- LZMA アルゴリズムを使用した圧縮

* 圧縮ファイルへの読み書き::
* メモリ上での圧縮と展開::
* その他: その他<2>.
* カスタムフィルタチェインの指定::
* 使用例: 使用例<14>.

zipfile -- ZIP アーカイブの処理

* ZipFile オブジェクト::
* Path オブジェクト::
* PyZipFile オブジェクト::
* ZipInfo オブジェクト::
* コマンドラインインターフェイス: コマンドラインインターフェイス<2>.
* Decompression pitfalls::

コマンドラインインターフェイス

* コマンドラインオプション: コマンドラインオプション<2>.

Decompression pitfalls

* From file itself::
* File System limitations::
* Resources limitations::
* Interruption::
* Default behaviors of extraction::

tarfile -- tar アーカイブファイルの読み書き

* TarFile オブジェクト::
* TarInfo オブジェクト::
* Extraction filters::
* コマンドラインインターフェイス: コマンドラインインターフェイス<3>.
* 使用例: 使用例<15>.
* サポートしている tar フォーマット::
* Unicode に関する問題::

Extraction filters

* Default named filters::
* Filter errors::
* Hints for further verification::
* Supporting older Python versions::
* Stateful extraction filter example::

コマンドラインインターフェイス

* コマンドラインオプション: コマンドラインオプション<3>.

ファイルフォーマット

* csv: csv --- CSV ファイルの読み書き. CSV ファイルの読み書き
* configparser: configparser --- 設定ファイルのパーサー. 設定ファイルのパーサー
* tomllib: tomllib --- TOML ファイルの解析. TOML ファイルの解析
* netrc: netrc --- netrc ファイルの処理. netrc ファイルの処理
* plistlib: plistlib --- Apple plist ファイルを生成・解析する. Apple .plist ファイルを生成・解析する

csv -- CSV ファイルの読み書き

* モジュールコンテンツ: モジュールコンテンツ<3>.
* Dialect クラスと書式化パラメータ::
* reader オブジェクト::
* writer オブジェクト::
* 使用例: 使用例<16>.

configparser -- 設定ファイルのパーサー

* クイックスタート::
* サポートされるデータ型::
* 代替値::
* サポートするINI ファイルの構造::
* Unnamed Sections::
* 値の補間::
* マップ型プロトコルアクセス::
* パーサーの振る舞いをカスタマイズする::
* レガシーな API の例::
* ConfigParser オブジェクト::
* RawConfigParser オブジェクト::
* 例外: 例外<8>.

tomllib -- TOML ファイルの解析

* 使用例: 使用例<17>.
* 変換表::

netrc -- netrc ファイルの処理

* netrc オブジェクト::

plistlib -- Apple .plist ファイルを生成・解析する

* 使用例: 使用例<18>.

暗号関連のサービス

* hashlib: hashlib --- セキュアハッシュとメッセージダイジェスト. セキュアハッシュとメッセージダイジェスト
* hmac: hmac --- メッセージ認証のための鍵付きハッシュ化. メッセージ認証のための鍵付きハッシュ化
* secrets: secrets --- 機密を扱うために安全な乱数を生成する. 機密を扱うために安全な乱数を生成する

hashlib -- セキュアハッシュとメッセージダイジェスト

* ハッシュアルゴリズム::
* 使用法::
* Constructors::
* 属性::
* Hash Objects::
* SHAKE 可変長ダイジェスト::
* File hashing::
* 鍵導出::
* BLAKE2::

BLAKE2

* ハッシュオブジェクトの作成::
* 定数: 定数<5>.
* 使用例: 使用例<19>.
* クレジット;: クレジット.

使用例

* 簡単なハッシュ化::
* Using different digest sizes::
* Keyed hashing::
* Randomized hashing::
* Personalization::
* ツリーモード::

secrets -- 機密を扱うために安全な乱数を生成する

* 乱数::
* トークンの生成::
* その他の関数::
* レシピとベストプラクティス::

トークンの生成

* トークンは何バイト使うべきか？::

汎用オペレーティングシステムサービス

* os: os --- 雑多なオペレーティングシステムインターフェース. 雑多なオペレーティングシステムインターフェース
* io: io --- ストリームを扱うコアツール. ストリームを扱うコアツール
* time: time --- 時刻データへのアクセスと変換. 時刻データへのアクセスと変換
* argparse: argparse --- Parser for command-line options arguments and subcommands. Parser for command-line options, arguments and
                        subcommands
* logging: logging --- Python 用のログ記録手段. Python 用のログ記録手段
* logging.config: logging config --- ログ記録の環境設定. ログ記録の環境設定
* logging.handlers: logging handlers --- ログ記録ハンドラー. ログ記録ハンドラー
* getpass: getpass --- 可搬性のあるパスワード入力機構. 可搬性のあるパスワード入力機構
* curses: curses --- 文字セル表示のターミナル処理. 文字セル表示のターミナル処理
* curses.textpad: curses textpad --- curses プログラムのためのテキスト入力ウィジェット. curses プログラムのためのテキスト入力ウィジェット
* curses.ascii: curses ascii --- ASCII 文字のユーティリティー. ASCII 文字のユーティリティー
* curses.panel: curses panel --- curses のためのパネルスタック拡張. curses のためのパネルスタック拡張
* platform: platform --- 実行中プラットフォームの固有情報を参照する. 実行中プラットフォームの固有情報を参照する
* errno: errno --- 標準の errno システムシンボル. 標準の errno システムシンボル
* ctypes: ctypes --- Python 用の外部関数ライブラリ. Python 用の外部関数ライブラリ

os -- 雑多なオペレーティングシステムインターフェース

* ファイル名、コマンドライン引数、および環境変数::
* Python UTF-8 Mode::
* プロセスのパラメーター::
* ファイルオブジェクトの生成::
* ファイル記述子の操作::
* ファイルとディレクトリ::
* プロセス管理::
* スケジューラーへのインターフェイス::
* 雑多なシステム情報::
* 乱数: 乱数<2>.

ファイル記述子の操作

* ターミナルのサイズの問い合わせ::
* ファイル記述子の継承::

ファイルとディレクトリ

* Timer File Descriptors::
* Linux 拡張属性::

io -- ストリームを扱うコアツール

* 概要: 概要<2>.
* Text Encoding::
* 高水準のモジュールインターフェイス::
* クラス階層::
* 性能: 性能<3>.

概要

* テキスト I/O::
* バイナリ I/O::
* Raw I/O::

Text Encoding

* Opt-in EncodingWarning::

クラス階層

* I/O 基底クラス::
* 生ファイルI/O::
* バッファ付きストリーム::
* テキスト I/O: テキスト I/O<2>.

性能

* バイナリ I/O: バイナリ I/O<2>.
* テキスト I/O: テキスト I/O<3>.
* マルチスレッディング: マルチスレッディング<3>.
* リエントラント性::

time -- 時刻データへのアクセスと変換

* 関数: 関数<5>.
* Clock ID Constants::
* Timezone Constants::

argparse -- Parser for command-line options, arguments and subcommands

* ArgumentParser オブジェクト::
* add_argument() メソッド: add_argument メソッド.
* parse_args() メソッド: parse_args メソッド.
* その他のユーティリティ::
* 例外: 例外<9>.

ArgumentParser オブジェクト

* prog::
* usage::
* description::
* epilog::
* parents::
* formatter_class::
* prefix_chars::
* fromfile_prefix_chars::
* argument_default::
* allow_abbrev::
* conflict_handler::
* add_help::
* exit_on_error::

add_argument() メソッド

* name または flags::
* action::
* nargs::
* const::
* default::
* type::
* choices::
* required::
* help::
* metavar::
* dest::
* deprecated::
* Action クラス::

parse_args() メソッド

* オプション値の文法::
* 不正な引数::
* - を含む引数::
* 引数の短縮形 (先頭文字でのマッチング): 引数の短縮形 先頭文字でのマッチング.
* sys.argv 以外: sys argv 以外.
* Namespace オブジェクト::

その他のユーティリティ

* サブコマンド::
* FileType オブジェクト::
* 引数グループ::
* 相互排他::
* パーサーのデフォルト値::
* ヘルプの表示::
* 部分解析::
* ファイル解析のカスタマイズ::
* 終了メソッド::
* 混在した引数の解析::

例外

* Argparse チュートリアル::
* Upgrading optparse code::

Argparse チュートリアル

* コンセプト::
* 基礎::
* 位置引数の入門::
* Optional引数の導入::
* 位置引数とOptional引数の併用::
* もうちょっとだけ学ぶ::
* argparse の出力を翻訳するには::
* Custom type converters::
* 結び::

Optional引数の導入

* 短いオプション::

もうちょっとだけ学ぶ

* 多義性のある引数の指定::
* 競合するオプション::

logging -- Python 用のログ記録手段

* ロガーオブジェクト::
* ロギングレベル::
* ハンドラオブジェクト::
* フォーマッタオブジェクト::
* フィルタオブジェクト::
* LogRecord オブジェクト::
* LogRecord 属性::
* LoggerAdapter オブジェクト::
* スレッドセーフ性::
* モジュールレベルの関数::
* モジュールレベル属性::
* warnings モジュールとの統合::

logging.config -- ログ記録の環境設定

* 環境設定のための関数::
* セキュリティで考慮すべき点::
* 環境設定辞書スキーマ::
* 環境設定ファイルの書式::

環境設定辞書スキーマ

* 辞書スキーマの詳細::
* 増分設定::
* オブジェクトの接続::
* ユーザ定義オブジェクト::
* ハンドラの設定順序::
* 外部オブジェクトへのアクセス::
* 内部オブジェクトへのアクセス::
* インポート解決とカスタムインポーター::
* Configuring QueueHandler and QueueListener::

logging.handlers -- ログ記録ハンドラー

* StreamHandler::
* FileHandler::
* NullHandler::
* WatchedFileHandler::
* BaseRotatingHandler::
* RotatingFileHandler::
* TimedRotatingFileHandler::
* SocketHandler::
* DatagramHandler::
* SysLogHandler::
* NTEventLogHandler::
* SMTPHandler::
* MemoryHandler::
* HTTPHandler::
* QueueHandler::
* QueueListener::

curses -- 文字セル表示のターミナル処理

* 関数: 関数<6>.
* Window オブジェクト::
* 定数: 定数<6>.

curses.textpad -- curses プログラムのためのテキスト入力ウィジェット

* Textbox オブジェクト::

curses.panel -- curses のためのパネルスタック拡張

* 関数: 関数<7>.
* Panel オブジェクト::

platform --  実行中プラットフォームの固有情報を参照する

* クロスプラットフォーム::
* Java プラットフォーム::
* Windows プラットフォーム::
* macOS プラットフォーム::
* iOS プラットフォーム::
* Unix プラットフォーム::
* Linux プラットフォーム::
* Android プラットフォーム::

ctypes -- Python 用の外部関数ライブラリ

* ctypes チュートリアル::
* ctypesリファレンス::

ctypes チュートリアル

* 動的リンクライブラリをロードする::
* ロードしたdllから関数にアクセスする::
* 関数を呼び出す::
* 基本データ型::
* 続・関数を呼び出す::
* Calling variadic functions::
* 自作のデータ型とともに関数を呼び出す::
* 要求される引数の型を指定する (関数プロトタイプ): 要求される引数の型を指定する 関数プロトタイプ.
* 戻り値の型::
* ポインタを渡す(または、パラメータの参照渡し): ポインタを渡す または、パラメータの参照渡し.
* 構造体と共用体::
* 構造体/共用体アライメントとバイトオーダー::
* 構造体と共用体におけるビットフィールド::
* 配列::
* ポインタ::
* 型変換::
* 不完全型::
* コールバック関数::
* dllからエクスポートされた値へアクセスする::
* びっくり仰天::
* 可変サイズのデータ型::

ctypesリファレンス

* 共有ライブラリを見つける::
* 共有ライブラリをロードする::
* 外部関数::
* 関数プロトタイプ::
* ユーティリティー関数::
* データ型: データ型<3>.
* 基本データ型: 基本データ型<2>.
* 構造化データ型::
* 配列とポインタ::

並行実行

* threading: threading --- スレッドベースの並列処理. スレッドベースの並列処理
* multiprocessing: multiprocessing --- プロセスベースの並列処理. プロセスベースの並列処理
* multiprocessing.shared_memory: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ. プロセス間で直接アクセス可能な共有メモリ
* concurrent パッケージ::
* concurrent.futures: concurrent futures --- 並列タスク実行. 並列タスク実行
* subprocess: subprocess --- サブプロセス管理. サブプロセス管理
* sched: sched --- イベントスケジューラー. イベントスケジューラー
* queue: queue --- 同期キュークラス. 同期キュークラス
* contextvars: contextvars --- コンテキスト変数. コンテキスト変数
* _thread: _thread --- 低水準なスレッド API. 低水準なスレッド API

threading -- スレッドベースの並列処理

* スレッドローカルデータ::
* Thread オブジェクト::
* Lock オブジェクト::
* RLock オブジェクト::
* Condition オブジェクト::
* Semaphore オブジェクト::
* Event オブジェクト::
* Timer オブジェクト::
* バリアオブジェクト::
* with 文でのロック・条件変数・セマフォの使い方::

Semaphore オブジェクト

* Semaphore の例::

multiprocessing -- プロセスベースの並列処理

* はじめに: はじめに<7>.
* リファレンス: リファレンス<2>.
* プログラミングガイドライン::
* 使用例: 使用例<20>.

はじめに

* Process クラス::
* コンテキストと開始方式::
* プロセス間でのオブジェクト交換::
* プロセス間の同期::
* プロセス間での状態の共有::
* ワーカープロセスのプールを使用::

リファレンス

* Process クラスと例外::
* パイプ (Pipe) とキュー (Queue): パイプ Pipe とキュー Queue.
* その他: その他<3>.
* Connection オブジェクト: Connection オブジェクト<2>.
* 同期プリミティブ::
* 共有 ctypes オブジェクト::
* マネージャー::
* Proxy オブジェクト::
* プロセスプール::
* リスナーとクライアント::
* 認証キー::
* ログ記録: ログ記録<2>.
* multiprocessing.dummy モジュール: multiprocessing dummy モジュール.

共有 ctypes オブジェクト

* multiprocessing.sharedctypes モジュール: multiprocessing sharedctypes モジュール.

マネージャー

* カスタマイズされたマネージャー::
* リモートマネージャーを使用する::

Proxy オブジェクト

* クリーンアップ::

リスナーとクライアント

* アドレスフォーマット::

プログラミングガイドライン

* すべての開始方式について::
* 開始方式が spawn および forkserver の場合::

concurrent.futures -- 並列タスク実行

* Executor オブジェクト::
* ThreadPoolExecutor::
* ProcessPoolExecutor::
* Future オブジェクト::
* モジュール関数: モジュール関数<2>.
* 例外クラス::

ThreadPoolExecutor

* ThreadPoolExecutor の例::

ProcessPoolExecutor

* ProcessPoolExecutor の例::

subprocess -- サブプロセス管理

* subprocess モジュールを使う::
* セキュリティで考慮すべき点: セキュリティで考慮すべき点<2>.
* Popen オブジェクト::
* Windows Popen ヘルパー::
* 古い高水準 API::
* 古い関数を subprocess モジュールで置き換える::
* レガシーなシェル呼び出し関数::
* 注釈: 注釈<2>.

subprocess モジュールを使う

* よく使われる引数::
* Popen コンストラクター::
* 例外: 例外<10>.

Windows Popen ヘルパー

* Windows Constants::

古い関数を subprocess モジュールで置き換える

* Replacing /bin/sh shell command substitution::
* シェルのパイプラインを置き換える::
* os.system() を置き換える: os system を置き換える.
* os.spawn 関数群を置き換える: os spawn 関数群を置き換える.
* os.popen(), os.popen2(), os.popen3() を置き換える: os popen os popen2 os popen3 を置き換える.
* Replacing functions from the popen2 module::

注釈

* Windows における引数シーケンスから文字列への変換::
* Disabling use of vfork() or posix_spawn(): Disabling use of vfork or posix_spawn.

sched -- イベントスケジューラー

* スケジューラオブジェクト::

queue -- 同期キュークラス

* キューオブジェクト::
* SimpleQueue オブジェクト::

キューオブジェクト

* Terminating queues::

contextvars -- コンテキスト変数

* コンテキスト変数::
* マニュアルでのコンテキスト管理::
* asyncio サポート::

ネットワーク通信とプロセス間通信

* asyncio: asyncio --- 非同期 I/O. 非同期 I/O
* socket: socket --- 低水準ネットワークインターフェース. 低水準ネットワークインターフェース
* ssl: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー. ソケットオブジェクト用の TLS/SSL ラッパー
* select: select --- I/O 完了の待機. I/O 完了の待機
* selectors: selectors --- 高水準の I/O 多重化. 高水準の I/O 多重化
* signal: signal --- 非同期イベントにハンドラーを設定する. 非同期イベントにハンドラーを設定する
* mmap: mmap --- メモリマップファイルのサポート. メモリマップファイルのサポート

asyncio -- 非同期 I/O

* Runners::
* コルーチンと Task::
* ストリーム::
* 同期プリミティブ: 同期プリミティブ<2>.
* サブプロセス::
* キュー::
* 例外: 例外<12>.
* イベントループ::
* Future::
* トランスポートとプロトコル::
* ポリシー::
* プラットフォームでのサポート::
* Extending::
* 高水準の API インデックス::
* 低水準の API インデックス::
* asyncio での開発::

Runners

* 非同期プログラムの実行::
* Runner context manager::
* Handling Keyboard Interruption::

コルーチンと Task

* コルーチン: コルーチン<3>.
* Awaitable::
* Task の作成::
* タスクのキャンセル::
* Task Groups::
* スリープ::
* 並行な Task 実行::
* Eager Task Factory::
* キャンセルからの保護::
* タイムアウト::
* 要素の終了待機::
* スレッド内での実行::
* 外部スレッドからのスケジュール::
* イントロスペクション::
* Task オブジェクト::

Task Groups

* Terminating a Task Group::

ストリーム

* StreamReader::
* StreamWriter::
* 使用例: 使用例<21>.

使用例

* ストリームを使った TCP Echo クライアント::
* ストリームを使った TCP Echo サーバー::
* HTTP ヘッダーの取得::
* ストリームを使ってデータを待つオープンソケットの登録::

同期プリミティブ

* Lock::
* Event::
* Condition::
* Semaphore::
* BoundedSemaphore::
* Barrier::

サブプロセス

* サブプロセスの生成::
* 定数: 定数<7>.
* サブプロセスとやりとりする::

サブプロセスとやりとりする

* サブプロセスとスレッド::
* 使用例: 使用例<22>.

キュー

* Queue::
* 優先度付きのキュー::
* LIFO キュー::
* 例外: 例外<11>.
* 使用例: 使用例<23>.

イベントループ

* イベントループのメソッド::
* コールバックのハンドル::
* Serverオブジェクト::
* イベントループの実装::
* 使用例: 使用例<24>.

イベントループのメソッド

* ループの開始と停止::
* コールバックのスケジューリング::
* 遅延コールバックのスケジューリング::
* フューチャーとタスクの生成::
* ネットワーク接続の確立::
* ネットワークサーバの生成::
* ファイルの転送::
* TLS へのアップグレード::
* ファイル記述子の監視::
* ソケットオブジェクトと直接やりとりする::
* DNS::
* パイプとやりとりする::
* Unix シグナル::
* スレッドまたはプロセスプールでコードを実行する::
* エラーハンドリング API::
* デバッグモードの有効化::
* サブプロセスの実行::

使用例

* call_soon() を使った Hello World: call_soon を使った Hello World.
* call_later() で現在の日時を表示する: call_later で現在の日時を表示する.
* 読み込みイベント用ファイル記述子の監視::
* SIGINT および SIGTERM 用のシグナルハンドラーの設定::

Future

* Future の関数::
* Future オブジェクト: Future オブジェクト<2>.

トランスポートとプロトコル

* トランスポート::
* プロトコル::
* 使用例: 使用例<25>.

トランスポート

* トランスポートのクラス階層構造::
* 基底トランスポート::
* 読み出し専用のトランスポート::
* 書き込み専用のトランスポート::
* データグラムトランスポート::
* サブプロセス化されたトランスポート::

プロトコル

* 基底プロトコル::
* 基底プロトコル: 基底プロトコル<2>.
* ストリーミングプロトコル::
* バッファリングされたストリーミングプロトコル::
* データグラムプロトコル::
* サブプロセスプロトコル::

使用例

* TCP エコーサーバー::
* TCP エコークライアント::
* UDP エコーサーバー::
* UDP エコークライアント::
* 既存のソケットへの接続::
* loop.subprocess_exec() と SubprocessProtocol: loop subprocess_exec と SubprocessProtocol.

ポリシー

* ポリシーの取得と設定::
* ポリシーオブジェクト::
* プロセスのウオッチャー::
* ポリシーのカスタマイズ::

プラットフォームでのサポート

* 全てのプラットホーム::
* Windows: Windows<74>.
* macOS: macOS<47>.

Windows

* Windows におけるサブプロセスのサポート::

Extending

* Writing a Custom Event Loop::
* Future and Task private constructors::
* Task lifetime support::

高水準の API インデックス

* Task::
* キュー: キュー<2>.
* サブプロセス: サブプロセス<2>.
* ストリーム: ストリーム<2>.
* 同期::
* 例外: 例外<13>.

低水準の API インデックス

* イベントループの取得::
* イベントループのメソッド: イベントループのメソッド<2>.
* トランスポート: トランスポート<2>.
* プロトコル: プロトコル<2>.
* イベントループのポリシー::

asyncio での開発

* デバッグモード::
* 並行処理とマルチスレッド処理::
* ブロッキングコードの実行::
* ログ記録: ログ記録<3>.
* 待ち受け処理を伴わないコルーチンの検出::
* 回収されない例外の検出::

socket -- 低水準ネットワークインターフェース

* ソケットファミリー::
* モジュールの内容::
* socket オブジェクト::
* ソケットタイムアウトの注意事項::
* 使用例: 使用例<26>.

モジュールの内容

* 例外: 例外<14>.
* 定数: 定数<8>.
* 関数: 関数<8>.

関数

* ソケットの作成::
* その他の関数: その他の関数<2>.

ソケットタイムアウトの注意事項

* タイムアウトと connect メソッド::
* タイムアウトと accept メソッド::

ssl -- ソケットオブジェクト用の TLS/SSL ラッパー

* 関数、定数、例外::
* SSL ソケット::
* SSL コンテキスト::
* 証明書::
* 使用例: 使用例<27>.
* ノンブロッキングソケットについての注意事項::
* メモリ BIO サポート: メモリ BIO サポート<2>.
* SSL セッション::
* セキュリティで考慮すべき点: セキュリティで考慮すべき点<3>.
* TLS 1.3: TLS 1 3.

関数、定数、例外

* ソケットの作成: ソケットの作成<2>.
* コンテキストの作成::
* 例外: 例外<15>.
* 乱数生成::
* 証明書の取り扱い::
* 定数: 定数<9>.

証明書

* 証明書チェイン::
* CA 証明書::
* 秘密鍵と証明書の組み合わせ::
* 自己署名証明書::

使用例

* SSLサポートをテストする::
* クライアントサイドの処理::
* サーバサイドの処理::

セキュリティで考慮すべき点

* 最善のデフォルト値::
* 手動での設定::
* マルチプロセス化::

手動での設定

* 証明書の検証::
* プロトコルのバージョン::
* 暗号の選択::

select -- I/O 完了の待機

* /dev/poll ポーリングオブジェクト::
* エッジおよびレベルトリガポーリング (epoll) オブジェクト: エッジおよびレベルトリガポーリング epoll オブジェクト.
* ポーリングオブジェクト::
* kqueue オブジェクト::
* kevent オブジェクト::

selectors -- 高水準の I/O 多重化

* はじめに: はじめに<8>.
* クラス: クラス<4>.
* 使用例: 使用例<28>.

signal -- 非同期イベントにハンドラーを設定する

* 一般的なルール::
* モジュールの内容: モジュールの内容<2>.
* 使用例: 使用例<29>.
* Note on SIGPIPE::
* Note on Signal Handlers and Exceptions::

一般的なルール

* Python のシグナルハンドラの実行::
* シグナルとスレッド::

mmap -- メモリマップファイルのサポート

* MADV_* 定数::
* MAP_* 定数::

インターネット上のデータの操作

* email: email --- 電子メールと MIME 処理のためのパッケージ. 電子メールと MIME 処理のためのパッケージ
* json: json --- JSON エンコーダーとデコーダー. JSON エンコーダーとデコーダー
* mailbox: mailbox --- 様々な形式のメールボックスを操作する. 様々な形式のメールボックスを操作する
* mimetypes: mimetypes --- ファイル名を MIME タイプへマップする. ファイル名を MIME タイプへマップする
* base64: base64 --- Base16 Base32 Base64 Base85 データのエンコード. Base16, Base32, Base64, Base85 データのエンコード
* binascii: binascii --- バイナリ と ASCII 間の変換. バイナリ と ASCII 間の変換
* quopri: quopri --- MIME quoted-printable データのエンコードとデコード. MIME quoted-printable データのエンコードとデコード

email -- 電子メールと MIME 処理のためのパッケージ

* email.message; Representing an email message: email message Representing an email message.
* email.parser; Parsing email messages: email parser Parsing email messages.
* email.generator; Generating MIME documents: email generator Generating MIME documents.
* email.policy; Policy Objects: email policy Policy Objects.
* email.errors; Exception and Defect classes: email errors Exception and Defect classes.
* email.headerregistry; Custom Header Objects: email headerregistry Custom Header Objects.
* email.contentmanager; Managing MIME Content: email contentmanager Managing MIME Content.
* email; 使用例: email 使用例.
* email.message.Message; compat32 API を使用した電子メールメッセージの表現: email message Message compat32 API を使用した電子メールメッセージの表現.
* email.mime; Creating email and MIME objects from scratch: email mime Creating email and MIME objects from scratch.
* email.header; 国際化されたヘッダー: email header 国際化されたヘッダー.
* email.charset; 文字集合の表現: email charset 文字集合の表現.
* email.encoders; エンコーダー: email encoders エンコーダー.
* email.utils; Miscellaneous utilities: email utils Miscellaneous utilities.
* email.iterators; イテレータ: email iterators イテレータ.

email.parser: Parsing email messages

* FeedParser API::
* Parser API::
* 追記事項::

email.contentmanager: Managing MIME Content

* Content Manager Instances::

json -- JSON エンコーダーとデコーダー

* 基本的な使い方: 基本的な使い方<2>.
* エンコーダとデコーダ::
* 例外: 例外<16>.
* 標準への準拠と互換性::
* コマンドラインインターフェイス: コマンドラインインターフェイス<4>.

標準への準拠と互換性

* 文字エンコーディング::
* 無限および NaN の数値::
* オブジェクト中に重複した名前の扱い::
* トップレベルの非オブジェクト、非配列の値の扱い::
* 実装の制限::

コマンドラインインターフェイス

* コマンドラインオプション: コマンドラインオプション<4>.

mailbox -- 様々な形式のメールボックスを操作する

* Mailbox オブジェクト::
* Message オブジェクト::
* 例外: 例外<17>.
* 使用例: 使用例<30>.

Mailbox オブジェクト

* Maildir オブジェクト::
* mbox オブジェクト::
* MH オブジェクト::
* Babyl オブジェクト::
* MMDF オブジェクト::

Message オブジェクト

* MaildirMessage オブジェクト::
* mboxMessage オブジェクト::
* MHMessage オブジェクト::
* BabylMessage オブジェクト::
* MMDFMessage オブジェクト::

mimetypes -- ファイル名を MIME タイプへマップする

* Mime 型オブジェクト::

base64 -- Base16, Base32, Base64, Base85 データのエンコード

* セキュリティで考慮すべき点: セキュリティで考慮すべき点<4>.

構造化マークアップツール

* html: html --- HyperText Markup Language のサポート. HyperText Markup Language のサポート
* html.parser: html parser --- HTML と XHTML のシンプルなパーサー. HTML と XHTML のシンプルなパーサー
* html.entities: html entities --- HTML 一般実体の定義. HTML 一般実体の定義
* XMLを扱うモジュール群::
* xml.etree.ElementTree: xml etree ElementTree --- ElementTree XML API. ElementTree XML API
* xml.dom: xml dom --- ドキュメントオブジェクトモデル API. ドキュメントオブジェクトモデル API
* xml.dom.minidom: xml dom minidom --- 最小限の DOM の実装. 最小限の DOM の実装
* xml.dom.pulldom: xml dom pulldom --- 部分的な DOM ツリー構築のサポート. 部分的な DOM ツリー構築のサポート
* xml.sax: xml sax --- SAX2 バーサーのサポート. SAX2 バーサーのサポート
* xml.sax.handler: xml sax handler --- SAX ハンドラーの基底クラス. SAX ハンドラーの基底クラス
* xml.sax.saxutils: xml sax saxutils --- SAX ユーティリティー. SAX ユーティリティー
* xml.sax.xmlreader: xml sax xmlreader --- XML パーサーのインターフェース. XML パーサーのインターフェース
* xml.parsers.expat: xml parsers expat --- Expat を使用した高速な XML 解析. Expat を使用した高速な XML 解析

html.parser -- HTML と XHTML のシンプルなパーサー

* HTML パーサーアプリケーションの例::
* HTMLParser メソッド::
* 使用例: 使用例<31>.

XMLを扱うモジュール群

* XML の脆弱性::
* defusedxml パッケージ::

xml.etree.ElementTree -- ElementTree XML API

* チュートリアル: チュートリアル<2>.
* XPath サポート::
* リファレンス: リファレンス<3>.
* XInclude サポート::
* リファレンス: リファレンス<4>.

チュートリアル

* XML 木構造と要素::
* XML の解析::
* 非ブロックパースのためのプル API::
* 関心ある要素の検索::
* XML ファイルの編集::
* XML 文書の構築::
* 名前空間のある XML の解析::

XPath サポート

* 使用例: 使用例<32>.
* サポートされている XPath 構文::

リファレンス

* 関数: 関数<9>.

XInclude サポート

* 使用例: 使用例<33>.

リファレンス

* 関数: 関数<10>.
* Element オブジェクト::
* ElementTree オブジェクト::
* QName オブジェクト::
* TreeBuilder オブジェクト::
* XMLParser オブジェクト::
* XMLPullParser オブジェクト::
* 例外: 例外<18>.

xml.dom -- ドキュメントオブジェクトモデル API

* モジュールコンテンツ: モジュールコンテンツ<4>.
* DOM 内のオブジェクト::
* 適合性::

DOM 内のオブジェクト

* DOMImplementation オブジェクト::
* Node オブジェクト::
* NodeList オブジェクト::
* DocumentType オブジェクト::
* Document オブジェクト::
* Element オブジェクト: Element オブジェクト<2>.
* Attr オブジェクト::
* NamedNodeMap Objects::
* Comment オブジェクト::
* Text オブジェクトおよび CDATASection オブジェクト::
* ProcessingInstruction オブジェクト::
* 例外: 例外<19>.

適合性

* 型の対応付け::
* アクセサメソッド::

xml.dom.minidom -- 最小限の DOM の実装

* DOM オブジェクト::
* DOM の例::
* minidom と DOM 標準::

xml.dom.pulldom -- 部分的な DOM ツリー構築のサポート

* DOMEventStream オブジェクト::

xml.sax -- SAX2 バーサーのサポート

* SAXException オブジェクト::

xml.sax.handler -- SAX ハンドラーの基底クラス

* ContentHandler オブジェクト::
* DTDHandler オブジェクト::
* EntityResolver オブジェクト::
* ErrorHandler オブジェクト::
* LexicalHandler Objects::

xml.sax.xmlreader -- XML パーサーのインターフェース

* XMLReader オブジェクト::
* IncrementalParser オブジェクト::
* Locator オブジェクト::
* InputSource オブジェクト::
* Attributes インターフェース::
* AttributesNS インターフェース::

xml.parsers.expat -- Expat を使用した高速な XML 解析

* XMLParser オブジェクト: XMLParser オブジェクト<2>.
* ExpatError 例外::
* 使用例: 使用例<34>.
* 内容モデルの記述::
* Expat エラー定数::

インターネットプロトコルとサポート

* webbrowser: webbrowser --- 便利なウェブブラウザコントローラー. 便利なウェブブラウザコントローラー
* wsgiref: wsgiref --- WSGI ユーティリティとリファレンス実装. WSGI ユーティリティとリファレンス実装
* urllib: urllib --- URL を扱うモジュール群. URL を扱うモジュール群
* urllib.request: urllib request --- URL を開くための大規模なライブラリ. URL を開くための大規模なライブラリ
* urllib.response: urllib response --- urllib で使用するレスポンスクラス. urllib で使用するレスポンスクラス
* urllib.parse: urllib parse --- URL を構成要素に解析する. URL を構成要素に解析する
* urllib.error: urllib error --- urllib request によって送出される例外クラス. urllib.request によって送出される例外クラス
* urllib.robotparser: urllib robotparser --- robots txt 用のパーサー. robots.txt 用のパーサー
* http: http --- HTTP モジュール群. HTTP モジュール群
* http.client: http client --- HTTP プロトコルクライアント. HTTP プロトコルクライアント
* ftplib: ftplib --- FTP プロトコルクライアント. FTP プロトコルクライアント
* poplib: poplib --- POP3 プロトコルクライアント. POP3 プロトコルクライアント
* imaplib: imaplib --- IMAP4 プロトコルクライアント. IMAP4 プロトコルクライアント
* smtplib: smtplib --- SMTP プロトコルクライアント. SMTP プロトコルクライアント
* uuid: uuid --- RFC 4122 に従った UUID オブジェクト. RFC 4122 に従った UUID オブジェクト
* socketserver: socketserver --- ネットワークサーバーのフレームワーク. ネットワークサーバーのフレームワーク
* http.server: http server --- HTTP サーバー. HTTP サーバー
* http.cookies: http cookies --- HTTP の状態管理. HTTP の状態管理
* http.cookiejar: http cookiejar --- HTTP クライアント用の Cookie 処理. HTTP クライアント用の Cookie 処理
* xmlrpc: xmlrpc --- XMLRPC サーバーとクライアントモジュール群. XMLRPC サーバーとクライアントモジュール群
* xmlrpc.client: xmlrpc client --- XML-RPC クライアントアクセス. XML-RPC クライアントアクセス
* xmlrpc.server: xmlrpc server --- 基本的な XML-RPC サーバー. 基本的な XML-RPC サーバー
* ipaddress: ipaddress --- IPv4/IPv6 操作ライブラリ. IPv4/IPv6 操作ライブラリ

webbrowser -- 便利なウェブブラウザコントローラー

* ブラウザコントローラーオブジェクト::

wsgiref -- WSGI ユーティリティとリファレンス実装

* wsgiref.util: wsgiref util -- WSGI 環境のユーティリティ. WSGI 環境のユーティリティ
* wsgiref.headers: wsgiref headers -- WSGI レスポンスヘッダツール群. WSGI レスポンスヘッダツール群
* wsgiref.simple_server: wsgiref simple_server -- シンプルな WSGI HTTP サーバ. シンプルな WSGI HTTP サーバ
* wsgiref.validate: wsgiref validate --- WSGI 準拠チェッカー. WSGI 準拠チェッカー
* wsgiref.handlers: wsgiref handlers -- サーバ／ゲートウェイのベースクラス. サーバ／ゲートウェイのベースクラス
* wsgiref.types: wsgiref types -- WSGI types for static type checking. WSGI types for static type checking
* 使用例: 使用例<35>.

urllib.request -- URL を開くための大規模なライブラリ

* Request オブジェクト::
* OpenerDirector オブジェクト::
* BaseHandler オブジェクト::
* HTTPRedirectHandler オブジェクト::
* HTTPCookieProcessor オブジェクト::
* ProxyHandler オブジェクト::
* HTTPPasswordMgr オブジェクト::
* HTTPPasswordMgrWithPriorAuth オブジェクト::
* AbstractBasicAuthHandler オブジェクト::
* HTTPBasicAuthHandler オブジェクト::
* ProxyBasicAuthHandler オブジェクト::
* AbstractDigestAuthHandler オブジェクト::
* HTTPDigestAuthHandler オブジェクト::
* ProxyDigestAuthHandler オブジェクト::
* HTTPHandler オブジェクト::
* HTTPSHandler オブジェクト::
* FileHandler オブジェクト::
* DataHandler オブジェクト::
* FTPHandler オブジェクト::
* CacheFTPHandler オブジェクト::
* UnknownHandler オブジェクト::
* HTTPErrorProcessor オブジェクト::
* 使用例: 使用例<36>.
* レガシーインターフェース::
* urllib.request の制限事項: urllib request の制限事項.

urllib.parse -- URL を構成要素に解析する

* URL の解析::
* URL parsing security::
* ASCII エンコードバイト列の解析::
* 構造化された解析結果::
* URL のクオート::

http -- HTTP モジュール群

* HTTP ステータスコード::
* HTTP ステータスコードカテゴリ::
* HTTP メソッド::

http.client -- HTTP プロトコルクライアント

* HTTPConnection オブジェクト::
* HTTPResponse オブジェクト::
* 使用例: 使用例<37>.
* HTTPMessage オブジェクト::

ftplib -- FTP プロトコルクライアント

* リファレンス: リファレンス<5>.

リファレンス

* FTP オブジェクト::
* FTP_TLS オブジェクト::
* モジュール変数::

poplib -- POP3 プロトコルクライアント

* POP3 オブジェクト::
* POP3 の例::

imaplib -- IMAP4 プロトコルクライアント

* IMAP4 オブジェクト::
* IMAP4 の使用例::

smtplib -- SMTP プロトコルクライアント

* SMTP オブジェクト::
* SMTP 使用例::

uuid -- RFC 4122 に従った UUID オブジェクト

* コマンドラインからの使用: コマンドラインからの使用<2>.
* 使用例: 使用例<38>.
* Command-Line Example::

socketserver -- ネットワークサーバーのフレームワーク

* サーバ生成に関するノート::
* Serverオブジェクト: Serverオブジェクト<2>.
* Request Handler Objects::
* 使用例: 使用例<39>.

使用例

* socketserver.TCPServer の例: socketserver TCPServer の例.
* socketserver.UDPServer の例: socketserver UDPServer の例.
* 非同期処理の Mix-in::

http.server -- HTTP サーバー

* セキュリティで考慮すべき点: セキュリティで考慮すべき点<5>.

http.cookies -- HTTP の状態管理

* Cookieオブジェクト::
* Morselオブジェクト::
* 使用例: 使用例<40>.

http.cookiejar -- HTTP クライアント用の Cookie 処理

* CookieJar および FileCookieJar オブジェクト::
* FileCookieJar のサブクラスと web ブラウザとの連携::
* CookiePolicy オブジェクト::
* DefaultCookiePolicy オブジェクト::
* Cookieオブジェクト: Cookieオブジェクト<2>.
* 使用例: 使用例<41>.

xmlrpc.client -- XML-RPC クライアントアクセス

* ServerProxy オブジェクト::
* DateTime オブジェクト::
* Binary オブジェクト::
* Fault オブジェクト::
* ProtocolError オブジェクト::
* MultiCall オブジェクト::
* 補助関数::
* クライアントのサンプル::
* クライアントとサーバーの利用例::

xmlrpc.server -- 基本的な XML-RPC サーバー

* SimpleXMLRPCServer オブジェクト::
* CGIXMLRPCRequestHandler::
* XMLRPC サーバの文書化::
* DocXMLRPCServer オブジェクト::
* DocCGIXMLRPCRequestHandler::

SimpleXMLRPCServer オブジェクト

* SimpleXMLRPCServer の例::

ipaddress -- IPv4/IPv6 操作ライブラリ

* 便利なファクトリ関数::
* IP アドレス::
* IP ネットワーク定義::
* インターフェイスオブジェクト::
* その他のモジュールレベル関数::
* Custom Exceptions::

IP アドレス

* Address オブジェクト::
* 文字列と整数への変換::
* 演算子: 演算子<3>.

演算子

* 比較演算子::
* 算術演算::

IP ネットワーク定義

* プリフィックス, ネットマスク、ホストマスク: プリフィックス ネットマスク、ホストマスク.
* Network オブジェクト::
* 演算子: 演算子<4>.

演算子

* 論理演算子::
* イテレーション::
* アドレスのコンテナとしてのネットワーク::

インターフェイスオブジェクト

* 演算子: 演算子<5>.

演算子

* 論理演算子: 論理演算子<2>.

マルチメディアサービス

* wave: wave --- WAV ファイルの読み書き. WAV ファイルの読み書き
* colorsys: colorsys --- 色体系間の変換. 色体系間の変換

wave -- WAV ファイルの読み書き

* Wave_read オブジェクト::
* Wave_write オブジェクト::

国際化

* gettext: gettext --- 多言語国際化サービス. 多言語国際化サービス
* locale: locale --- 国際化サービス. 国際化サービス

gettext -- 多言語国際化サービス

* GNU gettext API::
* クラス形式の API::
* プログラムやモジュールを国際化する::
* 謝辞: 謝辞<9>.

クラス形式の API

* NullTranslations クラス::
* GNUTranslations クラス::
* Solaris メッセージカタログ機構のサポート::
* Catalog コンストラクタ::

プログラムやモジュールを国際化する

* モジュールを地域化する::
* アプリケーションを地域化する::
* 動作中 (on the fly) に言語を切り替える: 動作中 on the fly に言語を切り替える.
* 翻訳処理の遅延解決::

locale -- 国際化サービス

* ロケールの背景、詳細、ヒント、助言および補足説明::
* Python 拡張の作者と、Python を埋め込むようなプログラムに関して::
* メッセージカタログへのアクセス::

プログラムのフレームワーク

* turtle: turtle --- タートルグラフィックス. タートルグラフィックス
* cmd: cmd --- 行指向のコマンドインタープリターのサポート. 行指向のコマンドインタープリターのサポート
* shlex: shlex --- 単純な字句解析. 単純な字句解析

turtle -- タートルグラフィックス

* はじめに: はじめに<9>.
* Get started::
* チュートリアル: チュートリアル<3>.
* How to...: How to.
* Turtle graphics reference::
* RawTurtle/Turtle のメソッドと対応する関数::
* TurtleScreen/Screen のメソッドと対応する関数::
* Public classes::
* 説明: 説明<2>.
* ヘルプと設定::
* turtledemo: turtledemo --- デモスクリプト. デモスクリプト
* python 2.6からの変更点: python 2 6からの変更点.
* python 3.0からの変更点: python 3 0からの変更点.

チュートリアル

* Starting a turtle environment::
* Basic drawing::
* Making algorithmic patterns::

Basic drawing

* Pen の制御::
* The turtle's position::

How to...

* Get started as quickly as possible::
* Use the turtle module namespace::
* Use turtle graphics in a script::
* Use object-oriented turtle graphics::

Turtle graphics reference

* Turtle のメソッド::
* TurtleScreen/Screen のメソッド::

RawTurtle/Turtle のメソッドと対応する関数

* Turtle の動き::
* Turtle の状態を知る::
* 設定と計測::
* Pen の制御: Pen の制御<2>.
* タートルの状態::
* イベントを利用する::
* 特別な Turtle のメソッド::
* Compound shapes::

Pen の制御

* 描画状態::
* 色の制御: 色の制御<2>.
* 塗りつぶし::
* さらなる描画の制御::

タートルの状態

* 可視性::
* 見た目::

TurtleScreen/Screen のメソッドと対応する関数

* ウィンドウの制御::
* アニメーションの制御::
* スクリーンイベントを利用する::
* 入力メソッド::
* 設定と特殊なメソッド::
* Screen 独自のメソッド、TurtleScreen から継承したもの以外::

ヘルプと設定

* ヘルプの使い方::
* ドキュメント文字列の翻訳::
* Screen および Turtle の設定方法::

cmd -- 行指向のコマンドインタープリターのサポート

* Cmdオブジェクト::
* Cmd の例::

shlex -- 単純な字句解析

* shlex オブジェクト::
* 解析規則::
* Improved Compatibility with Shells::

Tk を用いたグラフィカルユーザーインターフェース

* tkinter: tkinter --- Tcl/Tk の Python インターフェース. Tcl/Tk の Python インターフェース
* tkinter.colorchooser: tkinter colorchooser --- カラー選択ダイアログ. カラー選択ダイアログ
* tkinter.font: tkinter font --- Tkinter フォントラッパー. Tkinter フォントラッパー
* Tkinter ダイアログ::
* tkinter.messagebox: tkinter messagebox --- Tkinter メッセージプロンプト. Tkinter メッセージプロンプト
* tkinter.scrolledtext: tkinter scrolledtext --- スクロール可能なテキストウィジェット. スクロール可能なテキストウィジェット
* tkinter.dnd: tkinter dnd --- ドラッグアンドドロップのサポート. ドラッグアンドドロップのサポート
* tkinter.ttk: tkinter ttk --- Tk のテーマ付きウィジェット. Tk のテーマ付きウィジェット
* IDLE: IDLE<64>.

tkinter -- Tcl/Tk の Python インターフェース

* Architecture::
* Tkinter モジュール::
* Tkinter お助け手帳::
* Threading model::
* 簡単なリファレンス::
* ファイルハンドラ::

Tkinter お助け手帳

* A Hello World Program::
* Important Tk Concepts::
* Understanding How Tkinter Wraps Tcl/Tk::
* How do I...? What option does...?: How do I ? What option does ?.
* Navigating the Tcl/Tk Reference Manual::

簡単なリファレンス

* オプションの設定::
* Packer::
* Packer のオプション::
* ウィジェット変数を関連付ける::
* ウィンドウマネージャ::
* Tk オプションデータ型::
* バインドとイベント::
* index パラメータ::
* 画像::

Tkinter ダイアログ

* tkinter.simpledialog: tkinter simpledialog --- 標準 Tkinter 入力ダイアログ. 標準 Tkinter 入力ダイアログ
* tkinter.filedialog: tkinter filedialog --- ファイル選択ダイアログ. ファイル選択ダイアログ
* tkinter.commondialog: tkinter commondialog --- Dialog window templates. Dialog window templates

tkinter.filedialog -- ファイル選択ダイアログ

* ネイティブの読み込み/保存ダイアログ::

tkinter.ttk -- Tk のテーマ付きウィジェット

* Ttk を使う::
* Ttk ウィジェット::
* ウィジェット::
* コンボボックス::
* Spinbox::
* ノートブック::
* プログレスバー::
* セパレータ::
* サイズグリップ::
* ツリービュー::
* Ttk スタイル::

ウィジェット

* 標準オプション::
* スクロール可能ウィジェットのオプション::
* ラベルオプション::
* 互換性オプション::
* ウィジェットの状態::
* ttk.Widget: ttk Widget.

コンボボックス

* オプション::
* 仮想イベント::
* ttk.Combobox: ttk Combobox.

Spinbox

* オプション: オプション<2>.
* 仮想イベント: 仮想イベント<2>.
* ttk.Spinbox: ttk Spinbox.

ノートブック

* オプション: オプション<3>.
* タブオプション::
* タブ識別子::
* 仮想イベント: 仮想イベント<3>.
* ttk.Notebook: ttk Notebook.

プログレスバー

* オプション: オプション<4>.
* ttk.Progressbar: ttk Progressbar.

セパレータ

* オプション: オプション<5>.

サイズグリップ

* プラットフォーム固有のメモ::
* バグ::

ツリービュー

* オプション: オプション<6>.
* 要素オプション::
* タグオプション::
* カラム識別子::
* 仮想イベント: 仮想イベント<4>.
* ttk.Treeview: ttk Treeview.

Ttk スタイル

* レイアウト::

IDLE

* メニュー::
* Editing and Navigation::
* Startup and Code Execution::
* Help and Preferences::
* idlelib::

メニュー

* File メニュー (Shell ウィンドウ、Editor ウィンドウ): File メニュー Shell ウィンドウ、Editor ウィンドウ.
* Edit メニュー (Shell ウィンドウ、Editor ウィンドウ): Edit メニュー Shell ウィンドウ、Editor ウィンドウ.
* Format メニュー (Shell ウィンドウ、Editor ウィンドウ): Format メニュー Shell ウィンドウ、Editor ウィンドウ.
* Run メニュー (Editor ウィンドウのみ): Run メニュー Editor ウィンドウのみ.
* Shell メニュー (Shell ウィンドウのみ): Shell メニュー Shell ウィンドウのみ.
* Debug メニュー (Shell ウィンドウのみ): Debug メニュー Shell ウィンドウのみ.
* Options メニュー (Shell ウィンドウ、Editor ウィンドウ): Options メニュー Shell ウィンドウ、Editor ウィンドウ.
* Window メニュー (Shell ウィンドウ、Editor ウィンドウ): Window メニュー Shell ウィンドウ、Editor ウィンドウ.
* Help メニュー (Shell ウィンドウ、Editor ウィンドウ): Help メニュー Shell ウィンドウ、Editor ウィンドウ.
* Context menus::

Editing and Navigation

* Editor windows::
* Key bindings::
* 自動的な字下げ::
* 検索と置換::
* 補完 (Completions): 補完 Completions.
* 呼び出しヒント (Calltips): 呼び出しヒント Calltips.
* Code Context::
* Shell window::
* テキストの色::

Startup and Code Execution

* コマンドラインの使い方::
* Startup failure::
* Running user code::
* User output in Shell::
* Developing tkinter applications::
* サブプロセスを起こさずに起動する::

Help and Preferences

* Help sources::
* Setting preferences [お好み設定]::
* IDLE on macOS::
* Extensions [拡張]::

開発ツール

* typing: typing --- 型ヒントのサポート. 型ヒントのサポート
* pydoc: pydoc --- ドキュメント生成とオンラインヘルプシステム. ドキュメント生成とオンラインヘルプシステム
* Python 開発モード::
* doctest: doctest --- 対話型の Python の例をテストする. 対話型の Python の例をテストする
* unittest: unittest --- ユニットテストフレームワーク. ユニットテストフレームワーク
* unittest.mock: unittest mock --- モックオブジェクトライブラリ. モックオブジェクトライブラリ
* unittest.mock: unittest mock --- 入門. 入門
* test: test --- Regression tests package for Python. Regression tests package for Python
* test.support: test support --- テストのためのユーティリティ関数. テストのためのユーティリティ関数
* test.support.socket_helper: test support socket_helper --- Utilities for socket tests. Utilities for socket tests
* test.support.script_helper: test support script_helper --- Utilities for the Python execution tests. Utilities for the Python execution tests
* test.support.bytecode_helper: test support bytecode_helper --- Support tools for testing correct bytecode generation. Support tools for testing correct bytecode
                                generation
* test.support.threading_helper: test support threading_helper --- Utilities for threading tests. Utilities for threading tests
* test.support.os_helper: test support os_helper --- Utilities for os tests. Utilities for os tests
* test.support.import_helper: test support import_helper --- Utilities for import tests. Utilities for import tests
* test.support.warnings_helper: test support warnings_helper --- Utilities for warnings tests. Utilities for warnings tests

typing -- 型ヒントのサポート

* Python 型システムの仕様::
* 型エイリアス::
* NewType::
* 呼び出し可能オブジェクトのアノテーション::
* ジェネリクス::
* タプルのアノテーション::
* クラスオブジェクトの型::
* Annotating generators and coroutines::
* ユーザー定義のジェネリック型::
* Any 型::
* 名前的部分型 vs 構造的部分型::
* モジュールの内容: モジュールの内容<3>.
* メジャーな機能の非推奨時系列::

モジュールの内容

* 特殊型付けプリミティブ::
* プロトコル: プロトコル<3>.
* ABCs for working with IO::
* Functions and decorators::
* Introspection helpers::
* 定数: 定数<10>.
* 非推奨のエイリアス::

特殊型付けプリミティブ

* 特殊型::
* 特殊形式::
* Building generic types and type aliases::
* Other special directives::

非推奨のエイリアス

* Aliases to built-in types::
* Aliases to types in collections::
* Aliases to other concrete types::
* Aliases to container ABCs in collections.abc: Aliases to container ABCs in collections abc.
* Aliases to asynchronous ABCs in collections.abc: Aliases to asynchronous ABCs in collections abc.
* Aliases to other ABCs in collections.abc: Aliases to other ABCs in collections abc.
* Aliases to contextlib ABCs::

Python 開発モード

* Effects of the Python Development Mode::
* ResourceWarning Example::
* Bad file descriptor error example::

doctest -- 対話型の Python の例をテストする

* 簡単な利用法; docstring 中の実行例をチェックする: 簡単な利用法 docstring 中の実行例をチェックする.
* 簡単な利用法; テキストファイル中の実行例をチェックする: 簡単な利用法 テキストファイル中の実行例をチェックする.
* doctest のからくり::
* 基本 API::
* 単体テスト API::
* 拡張 API::
* デバッグ::
* アドバイス::

doctest のからくり

* どの docstring が検証されるのか?::
* docstring 内の実行例をどのように認識するのか?::
* 実行コンテキストとは何か?::
* 例外はどう扱えばよいか?::
* オプションフラグ::
* ディレクティブ (Directives): ディレクティブ Directives.
* 警告: 警告<2>.

拡張 API

* DocTest オブジェクト::
* Example オブジェクト::
* DocTestFinder オブジェクト::
* DocTestParser オブジェクト::
* TestResults objects::
* DocTestRunner オブジェクト::
* OutputChecker オブジェクト::

unittest -- ユニットテストフレームワーク

* 基本的な例: 基本的な例<2>.
* コマンドラインインターフェイス: コマンドラインインターフェイス<5>.
* テストディスカバリ::
* テストコードの構成::
* 既存テストコードの再利用::
* テストのスキップと予期された失敗::
* サブテストを利用して繰り返しテストの区別を付ける::
* クラスと関数::
* クラスとモジュールのフィクスチャ::
* シグナルハンドリング::

コマンドラインインターフェイス

* コマンドラインオプション: コマンドラインオプション<5>.

クラスと関数

* テストクラス::
* テストのグループ化::
* テストのロードと起動::

テストのロードと起動

* load_tests プロトコル::

クラスとモジュールのフィクスチャ

* setUpClass と tearDownClass::
* setUpModule と tearDownModule::

unittest.mock -- モックオブジェクトライブラリ

* クイックガイド::
* Mock クラス::
* patcher::
* MagicMock と magic method のサポート::
* ヘルパー::
* Order of precedence of side_effect, return_value and wraps: Order of precedence of side_effect return_value and wraps.

Mock クラス

* 呼び出し::
* 属性の削除::
* Mock の名前と name 属性::
* 属性として設定されるモック::

patcher

* patch::
* patch.object: patch object.
* patch.dict: patch dict.
* patch.multiple: patch multiple.
* patch のメソッド; start と stop: patch のメソッド start と stop.
* ビルトインをパッチする::
* TEST_PREFIX::
* patch デコレータをネストする::
* どこにパッチするか::
* デスクリプタやプロキシオブジェクトにパッチする::

MagicMock と magic method のサポート

* Magic Method をモックする::
* Magic Mock::

ヘルパー

* sentinel::
* DEFAULT::
* call::
* create_autospec::
* ANY::
* FILTER_DIR::
* mock_open::
* autospec を使う::
* Sealing mocks::

unittest.mock -- 入門

* Mock を使う::
* patch デコレータ::
* さらなる例::

Mock を使う

* Mock のパッチ用メソッド::
* オブジェクトのメソッド呼び出しに対するモック::
* クラスをモックする::
* モックに名前をつける::
* 全ての呼び出しのトラッキング::
* 戻り値や属性を設定する::
* モックから例外を発生させる::
* side_effect の関数と iterable::
* 非同期イテレータをモックする::
* 非同期コンテキストマネージャをモックする::
* 既存のオブジェクトから Mock を作る::
* Using side_effect to return per file content::

さらなる例

* chained call をモックする::
* 部分的なモック::
* ジェネレータメソッドをモックする::
* 同じパッチを全てのメソッドに適用する::
* Unboundメソッドをモックする::
* モックで複数回の呼び出しをチェックする::
* ミュータブルな引数に対処する::
* patch をネストする::
* MagicMock で辞書をモックする::
* Mock のサブクラスと属性::
* patch.dict で import をモックする: patch dict で import をモックする.
* Tracking order of calls and less verbose call assertions::
* More complex argument matching::

test -- Regression tests package for Python

* test パッケージのためのユニットテストを書く::
* コマンドラインインターフェースを利用してテストを実行する::

デバッグとプロファイル

* 監査イベント表::
* bdb: bdb --- デバッガーフレームワーク. デバッガーフレームワーク
* faulthandler: faulthandler --- Python トレースバックをダンプする. Python トレースバックをダンプする
* pdb: pdb --- Python デバッガ. Python デバッガ
* Python プロファイラ::
* timeit: timeit --- 小さなコードスニペットの実行時間計測. 小さなコードスニペットの実行時間計測
* trace: trace --- Python 文実行のトレースと追跡. Python 文実行のトレースと追跡
* tracemalloc: tracemalloc --- メモリ割り当ての追跡. メモリ割り当ての追跡

faulthandler -- Python トレースバックをダンプする

* tracebackのダンプ::
* フォールトハンドラの状態::
* タイムアウト後にtracebackをダンプする::
* ユーザシグナルに対してtracebackをダンプする::
* ファイル記述子の問題::
* 使用例: 使用例<42>.

pdb -- Python デバッガ

* デバッガコマンド::

Python プロファイラ

* プロファイラとは::
* かんたんユーザマニュアル::
* リファレンスマニュアル: リファレンスマニュアル -- profile と cProfile. profile と cProfile
* Stats クラス::
* 決定論的プロファイリングとは::
* 制限事項: 制限事項<2>.
* キャリブレーション (補正): キャリブレーション 補正.
* カスタムな時刻取得用関数を使う::

timeit -- 小さなコードスニペットの実行時間計測

* 基本的な例: 基本的な例<3>.
* Python インターフェイス::
* コマンドラインインターフェイス: コマンドラインインターフェイス<6>.
* 使用例: 使用例<43>.

trace -- Python 文実行のトレースと追跡

* コマンドラインからの使用: コマンドラインからの使用<3>.
* プログラミングインターフェース::

コマンドラインからの使用

* 主要なオプション::
* 修飾的オプション::
* フィルターオプション::

tracemalloc -- メモリ割り当ての追跡

* 使用例: 使用例<44>.
* API::

使用例

* 上位10を表示する::
* 差を計算する::
* メモリブロックのトレースバックを取得する::
* top を整形化する::

top を整形化する

* Record the current and peak size of all traced memory blocks::

API

* 関数: 関数<11>.
* DomainFilter::
* Filter::
* Frame::
* Snapshot::
* Statistic::
* StatisticDiff::
* Trace::
* Traceback::

ソフトウェア・パッケージと配布

* ensurepip: ensurepip --- pip インストーラーのブートストラップ. pip インストーラーのブートストラップ
* venv: venv --- 仮想環境の作成. 仮想環境の作成
* zipapp: zipapp --- 実行可能な Python zip アーカイブを管理する. 実行可能な Python zip アーカイブを管理する

ensurepip -- pip インストーラーのブートストラップ

* コマンドラインインターフェイス: コマンドラインインターフェイス<7>.
* モジュール API::

venv -- 仮想環境の作成

* 仮想環境の作成: 仮想環境の作成<2>.
* 仮想環境のしくみ::
* API: API<2>.
* EnvBuilder を拡張する例::

zipapp -- 実行可能な Python zip アーカイブを管理する

* 基本的な例: 基本的な例<4>.
* コマンドラインインターフェイス: コマンドラインインターフェイス<8>.
* Python API::
* 使用例: 使用例<45>.
* インタープリタの指定::
* Creating Standalone Applications with zipapp::
* The Python Zip Application Archive Format::

Creating Standalone Applications with zipapp

* Caveats::

Python ランタイムサービス

* sys: sys --- システム固有のパラメーターと関数. システム固有のパラメーターと関数
* sys.monitoring: sys monitoring --- Execution event monitoring. Execution event monitoring
* sysconfig: sysconfig --- Python の構成情報へのアクセスを提供する. Python の構成情報へのアクセスを提供する
* builtins: builtins --- 組み込みオブジェクト. 組み込みオブジェクト
* __main__: __main__ --- トップレベルのコード環境. トップレベルのコード環境
* warnings: warnings --- 警告の制御. 警告の制御
* dataclasses: dataclasses --- データクラス. データクラス
* contextlib: contextlib --- with 文コンテキスト用ユーティリティ. with 文コンテキスト用ユーティリティ
* abc: abc --- 抽象基底クラス. 抽象基底クラス
* atexit: atexit --- 終了ハンドラー. 終了ハンドラー
* traceback: traceback --- スタックトレースの表示または取得. スタックトレースの表示または取得
* __future__: __future__ --- future 文の定義. future 文の定義
* gc: gc --- ガベージコレクターインターフェース. ガベージコレクターインターフェース
* inspect: inspect --- 活動中のオブジェクトを調査する. 活動中のオブジェクトを調査する
* site: site --- サイト固有の設定フック. サイト固有の設定フック

sys.monitoring -- Execution event monitoring

* Tool identifiers::
* Events::
* Turning events on and off::
* Registering callback functions::

Tool identifiers

* Registering and using tools::

Events

* Local events::
* Ancillary events::
* Other events::
* The STOP_ITERATION event::

Turning events on and off

* Setting events globally::
* Per code object events::
* Disabling events::

Registering callback functions

* Callback function arguments::

sysconfig -- Python の構成情報へのアクセスを提供する

* 構成変数::
* インストールパス::
* User scheme::
* Home scheme::
* Prefix scheme::
* Installation path functions::
* その他の関数: その他の関数<3>.
* sysconfig をスクリプトとして使う::

User scheme

* posix_user::
* nt_user::
* osx_framework_user::

Home scheme

* posix_home::

Prefix scheme

* posix_prefix::
* nt::

__main__ -- トップレベルのコード環境

* __name__ == '__main__'::
* __main__.py in Python Packages: __main__ py in Python Packages.
* import __main__::

__name__ == '__main__'

* 「トップレベルのスクリプト環境」とは::
* 通常の使われ方::
* パッケージングで考慮すべき点::

__main__.py in Python Packages

* 通常の使われ方: 通常の使われ方<2>.

warnings -- 警告の制御

* 警告カテゴリ::
* 警告フィルタ::
* 一時的に警告を抑制する::
* 警告のテスト::
* Updating Code For New Versions of Dependencies::
* 利用可能な関数::
* 利用可能なコンテキストマネージャー::

警告フィルタ

* Repeated Warning Suppression Criteria::
* Describing Warning Filters::
* デフォルトの警告フィルタ::
* Overriding the default filter::

dataclasses -- データクラス

* モジュールの内容: モジュールの内容<4>.
* 初期化後の処理::
* クラス変数::
* 初期化限定変数::
* 凍結されたインスタンス::
* 継承: 継承<2>.
* Re-ordering of keyword-only parameters in __init__(): Re-ordering of keyword-only parameters in __init__.
* デフォルトファクトリ関数::
* 可変なデフォルト値::
* Descriptor-typed fields::

contextlib -- with 文コンテキスト用ユーティリティ

* ユーティリティ::
* 例とレシピ: 例とレシピ<3>.
* 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ::

例とレシピ

* 可変数個のコンテキストマネージャーをサポートする::
* __enter__ メソッドからの例外をキャッチする::
* __enter__ 実装内のクリーンアップ::
* try-finally + flag 変数パターンを置き換える::
* コンテキストマネージャーを関数デコレーターとして使う::

単回使用、再利用可能、およびリエントラントなコンテキストマネージャ

* リエントラントなコンテキストマネージャ::
* 再利用可能なコンテキストマネージャ::

atexit -- 終了ハンドラー

* atexit の例::

traceback -- スタックトレースの表示または取得

* モジュールレベルの関数: モジュールレベルの関数<2>.
* TracebackException オブジェクト::
* StackSummary オブジェクト::
* FrameSummary オブジェクト::
* Examples of Using the Module-Level Functions::
* Examples of Using TracebackException::

__future__ -- future 文の定義

* モジュールコンテンツ: モジュールコンテンツ<5>.

inspect -- 活動中のオブジェクトを調査する

* 型とメンバー::
* ソースコードの情報取得::
* Signature オブジェクトで呼び出し可能オブジェクトを内省する::
* クラスと関数: クラスと関数<2>.
* インタープリタスタック::
* 属性の静的なフェッチ::
* Current State of Generators, Coroutines, and Asynchronous Generators: Current State of Generators Coroutines and Asynchronous Generators.
* Code Objects Bit Flags::
* Buffer flags::
* コマンドラインインターフェイス: コマンドラインインターフェイス<9>.

site -- サイト固有の設定フック

* sitecustomize::
* usercustomize::
* readline の設定::
* モジュールの内容: モジュールの内容<5>.
* コマンドラインインターフェイス: コマンドラインインターフェイス<10>.

カスタム Python インタプリタ

* code: code --- インタープリター基底クラス. インタープリター基底クラス
* codeop: codeop --- Python コードをコンパイルする. Python コードをコンパイルする

code -- インタープリター基底クラス

* 対話的なインタプリタオブジェクト::
* 対話的なコンソールオブジェクト::

モジュールのインポート

* zipimport: zipimport --- Zip アーカイブからモジュールをインポートする. Zip アーカイブからモジュールをインポートする
* pkgutil: pkgutil --- パッケージ拡張ユーティリティ. パッケージ拡張ユーティリティ
* modulefinder: modulefinder --- スクリプト中で使用されているモジュールの検索. スクリプト中で使用されているモジュールの検索
* runpy: runpy --- Python モジュールの位置特定と実行. Python モジュールの位置特定と実行
* importlib: importlib --- import の実装. import の実装
* importlib.resources: importlib resources -- パッケージリソースの読み取り、オープン、アクセス. パッケージリソースの読み取り、オープン、アクセス
* importlib.resources.abc: importlib resources abc -- リソースの抽象基底クラス. リソースの抽象基底クラス
* importlib.metadata: importlib metadata -- パッケージメタデータへのアクセス. パッケージメタデータへのアクセス
* sys.path モジュール検索パスの初期化: sys path モジュール検索パスの初期化.

zipimport -- Zip アーカイブからモジュールをインポートする

* zipimporter オブジェクト::
* 使用例: 使用例<46>.

modulefinder -- スクリプト中で使用されているモジュールの検索

* ModuleFinder の使用例::

importlib -- import の実装

* はじめに: はじめに<10>.
* 関数: 関数<12>.
* importlib.abc: importlib abc -- インポートに関連する抽象基底クラス. インポートに関連する抽象基底クラス
* importlib.machinery: importlib machinery -- インポータおよびパスフック. インポータおよびパスフック
* importlib.util: importlib util -- インポータのためのユーティリティコード. インポータのためのユーティリティコード
* 使用例: 使用例<47>.

使用例

* プログラムからのインポート::
* モジュールがインポートできるか確認する::
* ソースファイルから直接インポートする::
* Implementing lazy imports::
* インポーターのセットアップ::
* Approximating importlib.import_module(): Approximating importlib import_module.

importlib.resources - パッケージリソースの読み取り、オープン、アクセス

* 関数 API::

importlib.metadata - パッケージメタデータへのアクセス

* 概要: 概要<3>.
* 機能 API::
* Distributions::
* Distribution Discovery::
* 検索アルゴリズムの拡張::

機能 API

* エントリポイント::
* 配布物メタデータ::
* 配布物バージョン::
* 配布物ファイル::
* 配布物の要件::
* Mapping import to distribution packages::

検索アルゴリズムの拡張

* 使用例: 使用例<48>.

sys.path モジュール検索パスの初期化

* 仮想環境::
* _pth files::
* 埋め込みの Python::

Python言語サービス

* ast: ast --- 抽象構文木. 抽象構文木
* symtable: symtable --- コンパイラーの記号表へのアクセス. コンパイラーの記号表へのアクセス
* token: token --- Python 解析木で使われる定数. Python 解析木で使われる定数
* keyword: keyword --- Python キーワードのテスト. Python キーワードのテスト
* tokenize: tokenize --- Python ソース用のトークナイザー. Python ソース用のトークナイザー
* tabnanny: tabnanny --- あいまいなインデントの検出. あいまいなインデントの検出
* pyclbr: pyclbr --- Python モジュールブラウザーサポート. Python モジュールブラウザーサポート
* py_compile: py_compile --- Python ソースファイルをコンパイルする. Python ソースファイルをコンパイルする
* compileall: compileall --- Python ライブラリをバイトコンパイルする. Python ライブラリをバイトコンパイルする
* dis: dis --- Python バイトコードの逆アセンブラー. Python バイトコードの逆アセンブラー
* pickletools: pickletools --- pickle 開発者用のツール群. pickle 開発者用のツール群

ast -- 抽象構文木

* 抽象文法 (Abstract Grammar): 抽象文法 Abstract Grammar.
* Node クラス::
* ast ヘルパー::
* コンパイラフラグ::
* コマンドラインからの使用: コマンドラインからの使用<4>.

Node クラス

* Root nodes::
* リテラル: リテラル<3>.
* 変数::
* 式 (expression): 式 expression<2>.
* 文 (Statements): 文 Statements.
* 制御フロー::
* Pattern matching::
* Type parameters::
* 関数およびクラス定義::
* async と await::

式 (expression)

* 配列要素の参照 (Subscripting): 配列要素の参照 Subscripting.
* 内包表記 (Comprehension): 内包表記 Comprehension.

文 (Statements)

* インポート::

symtable -- コンパイラーの記号表へのアクセス

* 記号表の生成::
* 記号表の検査::
* コマンドラインからの使用: コマンドラインからの使用<5>.

tokenize -- Python ソース用のトークナイザー

* 入力のトークナイズ::
* コマンドラインからの使用: コマンドラインからの使用<6>.
* 使用例: 使用例<49>.

pyclbr -- Python モジュールブラウザーサポート

* Function オブジェクト::
* クラスオブジェクト: クラスオブジェクト<2>.

py_compile -- Python ソースファイルをコンパイルする

* コマンドラインインターフェイス: コマンドラインインターフェイス<11>.

compileall -- Python ライブラリをバイトコンパイルする

* コマンドラインでの使用: コマンドラインでの使用<2>.
* パブリックな関数::

dis -- Python バイトコードの逆アセンブラー

* コマンドライン・インターフェース: コマンドライン・インターフェース<2>.
* バイトコード解析::
* 解析関数::
* Python バイトコード命令::
* 命令コードコレクション::

pickletools -- pickle 開発者用のツール群

* コマンドラインの使い方: コマンドラインの使い方<2>.
* プログラミングインターフェース: プログラミングインターフェース<2>.

コマンドラインの使い方

* コマンドラインオプション: コマンドラインオプション<6>.

MS Windows 固有のサービス

* msvcrt: msvcrt --- MS VC++ ランタイムの有用なルーチン群. MS VC++ ランタイムの有用なルーチン群
* winreg: winreg --- Windows レジストリへのアクセス. Windows レジストリへのアクセス
* winsound: winsound --- Windows 用の音声再生インターフェース. Windows 用の音声再生インターフェース

msvcrt -- MS VC++ ランタイムの有用なルーチン群

* ファイル操作関連::
* コンソール I/O 関連::
* その多の関数::

winreg -- Windows レジストリへのアクセス

* 関数: 関数<13>.
* 定数: 定数<11>.
* レジストリハンドルオブジェクト::

定数

* HKEY_* 定数::
* アクセス権限::
* 値の型::

アクセス権限

* 64-bit 特有のアクセス権::

Unix 固有のサービス

* posix: posix --- 最も一般的な POSIX システムコール群. 最も一般的な POSIX システムコール群
* pwd: pwd --- パスワードデータベース. パスワードデータベース
* grp: grp --- グループデータベース. グループデータベース
* termios: termios --- POSIX スタイルの端末制御. POSIX スタイルの端末制御
* tty: tty --- 端末制御用の関数群. 端末制御用の関数群
* pty: pty --- 擬似端末ユーティリティ. 擬似端末ユーティリティ
* fcntl: fcntl --- fcntl および ioctl システムコール. fcntl および ioctl システムコール
* resource: resource --- リソース使用情報. リソース使用情報
* syslog: syslog --- Unix syslog ライブラリルーチン群. Unix syslog ライブラリルーチン群

posix -- 最も一般的な POSIX システムコール群

* ラージファイルのサポート::
* 注目すべきモジュールの内容::

termios -- POSIX スタイルの端末制御

* 使用例: 使用例<50>.

pty -- 擬似端末ユーティリティ

* 使用例: 使用例<51>.

resource -- リソース使用情報

* リソースの制限::
* リソースの使用状態::

syslog -- Unix syslog ライブラリルーチン群

* 使用例: 使用例<52>.

使用例

* シンプルな例::

取って代わられたモジュール群

* getopt: getopt --- C-style parser for command line options. C-style parser for command line options
* optparse: optparse --- Parser for command line options. Parser for command line options

optparse -- Parser for command line options

* 背景::
* チュートリアル: チュートリアル<4>.
* リファレンスガイド::
* オプション処理コールバック::
* optparse の拡張::
* 例外: 例外<20>.

背景

* 用語集::
* オプションとは何か::
* 位置引数とは何か::

チュートリアル

* オプション・アクションを理解する::
* store アクション::
* ブール値 (フラグ) オプションの処理: ブール値 フラグ オプションの処理.
* その他のアクション::
* デフォルト値::
* ヘルプの生成::
* バージョン番号の出力::
* optparse のエラー処理法::
* 全てをつなぎ合わせる::

ヘルプの生成

* オプションをグループ化する::

リファレンスガイド

* parserを作る::
* パーザへのオプション追加::
* オプションの定義::
* オプション属性::
* 標準的なオプション・アクション::
* 標準のオプション型::
* 引数を解析する::
* オプション解析器への問い合わせと操作::
* オプション間の衝突::
* クリーンアップ: クリーンアップ<2>.
* その他のメソッド::

オプション処理コールバック

* callbackオプションの定義::
* コールバック関数はどのように呼び出されるか::
* コールバック中で例外を送出する::
* コールバックの例 1; ありふれたコールバック: コールバックの例 1 ありふれたコールバック.
* コールバックの例 2; オプションの順番をチェックする: コールバックの例 2 オプションの順番をチェックする.
* コールバックの例 3; オプションの順番をチェックする (汎用的): コールバックの例 3 オプションの順番をチェックする 汎用的.
* コールバックの例 4; 任意の条件をチェックする: コールバックの例 4 任意の条件をチェックする.
* コールバックの例5; 固定引数: コールバックの例5 固定引数.
* コールバックの例6; 可変個の引数: コールバックの例6 可変個の引数.

optparse の拡張

* 新しい型の追加::
* 新しいアクションの追加::

Python インタプリタの拡張と埋め込み

* おすすめのサードパーティツール::
* サードパーティツールなしで拡張を作る::
* 大規模なアプリケーションへの Python ランタイムの埋め込み::

サードパーティツールなしで拡張を作る

* C や C++ による Python の拡張::
* 拡張の型の定義; チュートリアル: 拡張の型の定義 チュートリアル.
* 拡張の型の定義; 雑多なトピック: 拡張の型の定義 雑多なトピック.
* C および C++ 拡張のビルド::
* Windows 上での C および C++ 拡張モジュールのビルド::

C や C++ による Python の拡張

* 簡単な例::
* 幕間小話; エラーと例外: 幕間小話 エラーと例外.
* 例に戻る::
* モジュールのメソッドテーブルと初期化関数::
* コンパイルとリンク::
* C から Python 関数を呼び出す::
* 拡張モジュール関数でのパラメタ展開::
* 拡張モジュール関数のキーワードパラメタ::
* 任意の値を構築する::
* 参照カウント法::
* C++での拡張モジュール作成::
* 拡張モジュールに C API を提供する::

参照カウント法

* Python における参照カウント法::
* 所有権にまつわる規則::
* 薄氷::
* NULL ポインタ::

拡張の型の定義: チュートリアル

* 基本的なこと::
* 基本のサンプルにデータとメソッドを追加する::
* データ属性をこまかく制御する::
* 循環ガベージコレクションをサポートする::
* 他の型のサブクラスを作る::

拡張の型の定義: 雑多なトピック

* ファイナライズとメモリ解放::
* オブジェクト表現::
* 属性を管理する::
* オブジェクトの比較::
* 抽象的なプロトコルのサポート::
* 弱参照(Weak Reference)のサポート: 弱参照 Weak Reference のサポート.
* その他いろいろ::

属性を管理する

* 総称的な属性を管理する::
* 特定の型に特化した属性の管理::

C および C++ 拡張のビルド

* setuptools による C および C++ 拡張のビルド::

Windows 上での C および C++ 拡張モジュールのビルド

* 型どおりのアプローチ::
* Unix と Windows の相違点::
* DLL 使用の実際::

大規模なアプリケーションへの Python ランタイムの埋め込み

* 他のアプリケーションへの Python の埋め込み::

他のアプリケーションへの Python の埋め込み

* 高水準の埋め込み::
* 超高水準の埋め込みから踏み出す; 概要: 超高水準の埋め込みから踏み出す 概要.
* 純粋な埋め込み::
* 埋め込まれた Python の拡張::
* C++による Python の埋め込み::
* Unix 系システムにおけるコンパイルとリンク::

Python/C API リファレンスマニュアル

* はじめに: はじめに<11>.
* C API の安定性::
* 超高水準レイヤ::
* 参照カウント::
* 例外処理::
* ユーティリティ: ユーティリティ<2>.
* 抽象オブジェクトレイヤ (Abstract Objects Layer): 抽象オブジェクトレイヤ Abstract Objects Layer.
* 具象オブジェクト (concrete object) レイヤ: 具象オブジェクト concrete object レイヤ.
* 初期化 (initialization)、終了処理 (finalization)、スレッド: 初期化 initialization 、終了処理 finalization 、スレッド.
* Python 初期化設定::
* メモリ管理::
* オブジェクト実装サポート (object implementation support): オブジェクト実装サポート object implementation support.
* API と ABI のバージョニング::
* Monitoring C API::
* Generating Execution Events::

はじめに

* コーディング基準::
* インクルードファイル::
* 便利なマクロ::
* オブジェクト、型および参照カウント::
* 例外: 例外<21>.
* Python の埋め込み: Python の埋め込み<2>.
* デバッグ版ビルド (Debugging Builds): デバッグ版ビルド Debugging Builds.

オブジェクト、型および参照カウント

* 参照カウント法: 参照カウント法<2>.
* 型::

参照カウント法

* 参照カウントの詳細::

C API の安定性

* Unstable C API::
* 安定 ABI (Stable Appliction Binary Interface): 安定 ABI Stable Appliction Binary Interface.
* プラットフォームで考慮すべき点::
* 限定版APIの内容::

安定 ABI (Stable Appliction Binary Interface)

* Limited C API::
* Stable ABI::
* APIスコープとパフォーマンスの制限::
* 制限付きAPIの注意点::

例外処理

* 出力とクリア::
* 例外の送出::
* 警告: 警告<3>.
* エラーインジケータの問い合わせ::
* シグナルハンドリング: シグナルハンドリング<2>.
* 例外クラス: 例外クラス<2>.
* 例外オブジェクト::
* Unicode 例外オブジェクト::
* 再帰の管理::
* 標準例外::
* 標準警告カテゴリ::

ユーティリティ

* オペレーティングシステム関連のユーティリティ::
* システム関数::
* プロセス制御::
* モジュールのインポート: モジュールのインポート<2>.
* データ整列化 (data marshalling) のサポート: データ整列化 data marshalling のサポート.
* 引数の解釈と値の構築::
* 文字列の変換と書式化::
* PyHash API::
* リフレクション::
* codec レジストリとサポート関数::
* PyTime C API::
* Support for Perf Maps::

引数の解釈と値の構築

* 引数を解析する: 引数を解析する<2>.
* 値の構築::

引数を解析する

* 文字列とバッファ::
* 数: 数<2>.
* その他のオブジェクト::
* API 関数::

codec レジストリとサポート関数

* コーデック検索API::
* Unicode エラーハンドラ用レジストリ API::

PyTime C API

* Types::
* Clock Functions::
* Raw Clock Functions::
* Conversion functions::

抽象オブジェクトレイヤ (Abstract Objects Layer)

* オブジェクトプロトコル (object protocol): オブジェクトプロトコル object protocol.
* Call プロトコル::
* 数値型プロトコル (number protocol): 数値型プロトコル number protocol.
* シーケンス型プロトコル (sequence protocol): シーケンス型プロトコル sequence protocol.
* マップ型プロトコル (mapping protocol): マップ型プロトコル mapping protocol.
* イテレータプロトコル (iterator protocol): イテレータプロトコル iterator protocol.
* バッファプロトコル (buffer Protocol): バッファプロトコル buffer Protocol.

Call プロトコル

* The tp_call Protocol::
* The Vectorcall Protocol::
* Object Calling API::
* Call Support API::

The Vectorcall Protocol

* 再帰の管理: 再帰の管理<2>.
* Vectorcall Support API::

バッファプロトコル (buffer Protocol)

* buffer 構造体::
* バッファリクエストのタイプ::
* 複雑な配列::
* バッファ関連の関数::

バッファリクエストのタイプ

* リクエストに依存しないフィールド::
* readonly, format: readonly format.
* shape, strides, suboffsets: shape strides suboffsets.
* 隣接性のリクエスト::
* 複合リクエスト::

複雑な配列

* NumPy スタイル; shape, strides: NumPy スタイル shape strides.
* PIL スタイル; shape, strides, suboffsets: PIL スタイル shape strides suboffsets.

具象オブジェクト (concrete object) レイヤ

* 基本オブジェクト (fundamental object): 基本オブジェクト fundamental object.
* 数値型オブジェクト (numeric object): 数値型オブジェクト numeric object.
* シーケンスオブジェクト (sequence object): シーケンスオブジェクト sequence object.
* Container オブジェクト::
* Function オブジェクト: Function オブジェクト<2>.
* その他のオブジェクト: その他のオブジェクト<2>.

基本オブジェクト (fundamental object)

* 型オブジェクト: 型オブジェクト<2>.
* None オブジェクト::

型オブジェクト

* Creating Heap-Allocated Types::

数値型オブジェクト (numeric object)

* 整数型オブジェクト (integer object): 整数型オブジェクト integer object.
* Boolean オブジェクト::
* Floating-Point Objects::
* 複素数オブジェクト::

Floating-Point Objects

* Pack and Unpack functions::

Pack and Unpack functions

* Pack functions::
* Unpack functions::

複素数オブジェクト

* C 構造体としての複素数::
* Python オブジェクトとしての複素数型::

シーケンスオブジェクト (sequence object)

* バイトオブジェクト: バイトオブジェクト<2>.
* bytearray オブジェクト: bytearray オブジェクト<2>.
* Unicode オブジェクトと codec::
* タプルオブジェクト (tuple object): タプルオブジェクト tuple object.
* Struct Sequence オブジェクト::
* リストオブジェクト::

bytearray オブジェクト

* 型チェックマクロ::
* ダイレクト API 関数::
* マクロ::

Unicode オブジェクトと codec

* Unicode オブジェクト::
* 組み込み codec (built-in codec): 組み込み codec built-in codec.
* メソッドおよびスロット関数 (slot function): メソッドおよびスロット関数 slot function.

Unicode オブジェクト

* Unicode 型::
* Unicode 文字プロパティ::
* Unicode 文字列の生成とアクセス::
* ロケールエンコーディング::
* ファイルシステムエンコーディング::
* wchar_t サポート::

組み込み codec (built-in codec)

* 汎用 codec::
* UTF-8 Codecs::
* UTF-32 Codecs::
* UTF-16 Codecs::
* UTF-7 Codecs::
* Unicode-Escape Codecs::
* Raw-Unicode-Escape Codecs::
* Latin-1 Codecs::
* ASCII Codecs::
* Character Map Codecs::
* Windows 用の MBCS codec::
* メソッドとスロット::

Container オブジェクト

* 辞書オブジェクト (dictionary object): 辞書オブジェクト dictionary object.
* Set オブジェクト::

Function オブジェクト

* Function オブジェクト: Function オブジェクト<3>.
* インスタンスメソッドオブジェクト(Instance Method Objects): インスタンスメソッドオブジェクト Instance Method Objects.
* メソッドオブジェクト: メソッドオブジェクト<2>.
* セルオブジェクト (cell object): セルオブジェクト cell object.
* コードオブジェクト: コードオブジェクト<3>.
* Extra information::

その他のオブジェクト

* ファイルオブジェクト::
* モジュールオブジェクト (module object): モジュールオブジェクト module object.
* イテレータオブジェクト (iterator object): イテレータオブジェクト iterator object.
* デスクリプタオブジェクト (descriptor object): デスクリプタオブジェクト descriptor object.
* スライスオブジェクト (slice object): スライスオブジェクト slice object.
* memoryview オブジェクト::
* 弱参照オブジェクト: 弱参照オブジェクト<2>.
* カプセル: カプセル<2>.
* フレーム (frame) オブジェクト: フレーム frame オブジェクト<2>.
* ジェネレータオブジェクト::
* コルーチンオブジェクト: コルーチンオブジェクト<2>.
* コンテキスト変数オブジェクト::
* DateTime オブジェクト: DateTime オブジェクト<2>.
* 型ヒントのためのオブジェクト::

モジュールオブジェクト (module object)

* Cモジュールの初期化::
* モジュール検索::

Cモジュールの初期化

* 一段階初期化::
* 多段階初期化::
* 低水準モジュール作成関数::
* サポート関数::

スライスオブジェクト (slice object)

* Ellipsis オブジェクト: Ellipsis オブジェクト<2>.

フレーム (frame) オブジェクト

* Internal Frames::

初期化 (initialization)、終了処理 (finalization)、スレッド

* Python 初期化以前::
* グローバルな設定変数::
* インタープリタの初期化と終了処理::
* プロセスワイドのパラメータ::
* スレッド状態 (thread state) とグローバルインタプリタロック (global interpreter lock): スレッド状態 thread state とグローバルインタプリタロック global interpreter lock.
* サブインタプリタサポート::
* 非同期通知::
* プロファイルとトレース (profiling and tracing): プロファイルとトレース profiling and tracing.
* Reference tracing::
* 高度なデバッガサポート (advanced debugger support): 高度なデバッガサポート advanced debugger support.
* スレッドローカルストレージのサポート::
* 同期プリミティブ: 同期プリミティブ<3>.

スレッド状態 (thread state) とグローバルインタプリタロック (global interpreter lock)

* 拡張コード内で GIL を解放する::
* Python 以外で作られたスレッド::
* Cautions about fork(): Cautions about fork.
* 高レベルAPI::
* 低レベルAPI::

サブインタプリタサポート

* A Per-Interpreter GIL::
* バグと注意事項::

スレッドローカルストレージのサポート

* スレッド固有ストレージ (Thread Specific Storage, TSS) API: スレッド固有ストレージ Thread Specific Storage TSS API.
* スレッドローカルストレージ (TLS) API: スレッドローカルストレージ TLS API.

スレッド固有ストレージ (Thread Specific Storage, TSS) API

* 動的メモリ確保::
* メソッド: メソッド<2>.

同期プリミティブ

* Python Critical Section API::

Python 初期化設定

* 使用例: 使用例<53>.
* PyWideStringList::
* PyStatus::
* PyPreConfig::
* Preinitialize Python with PyPreConfig::
* PyConfig::
* Initialization with PyConfig::
* Isolated Configuration::
* Python Configuration::
* Python Path Configuration::
* Py_GetArgcArgv(): Py_GetArgcArgv.
* Multi-Phase Initialization Private Provisional API::

メモリ管理

* 概要: 概要<4>.
* Allocator Domains::
* 生メモリインターフェース::
* メモリインターフェース::
* オブジェクトアロケータ::
* Default Memory Allocators::
* メモリアロケータをカスタマイズする::
* Debug hooks on the Python memory allocators::
* pymalloc アロケータ::
* The mimalloc allocator::
* tracemalloc C API::
* 使用例: 使用例<54>.

pymalloc アロケータ

* pymalloc アリーナアロケータのカスタマイズ::

オブジェクト実装サポート (object implementation support)

* オブジェクトをヒープ上にメモリ確保する::
* 共通のオブジェクト構造体 (common object structure): 共通のオブジェクト構造体 common object structure.
* 型オブジェクト: 型オブジェクト<3>.
* 循環参照ガベージコレクションをサポートする::

共通のオブジェクト構造体 (common object structure)

* Base object types and macros::
* Implementing functions and methods::
* Accessing attributes of extension types::

Accessing attributes of extension types

* Member flags::
* Member types::
* Defining Getters and Setters::

型オブジェクト

* クイックリファレンス::
* PyTypeObject 定義::
* PyObject スロット::
* PyVarObject スロット::
* PyTypeObject スロット::
* Static Types::
* Heap Types::
* 数値オブジェクト構造体::
* マップオブジェクト構造体::
* シーケンスオブジェクト構造体::
* バッファオブジェクト構造体 (buffer object structure): バッファオブジェクト構造体 buffer object structure.
* async オブジェクト構造体::
* Slot Type typedefs::
* 使用例: 使用例<55>.

クイックリファレンス

* tp スロット::
* sub-slots::
* スロットの定義型 (typedef): スロットの定義型 typedef.

循環参照ガベージコレクションをサポートする

* Controlling the Garbage Collector State::
* Querying Garbage Collector State::

Generating Execution Events

* Managing the Monitoring State::

Python モジュールのインストール

* 重要用語集::
* 基本的な使い方: 基本的な使い方<3>.
* どうすればいいの...？: どうすればいいの ？.
* よくあるインストールに関する問題::

どうすればいいの...？

* ... pip を 3.4 より前のバージョンの Python でインストールするには？: pip を 3 4 より前のバージョンの Python でインストールするには？.
* ... パッケージを現在のユーザ用のみにインストールするには？: パッケージを現在のユーザ用のみにインストールするには？.
* ... 科学技術計算用の Python パッケージをインストールするには？: 科学技術計算用の Python パッケージをインストールするには？.
* ... インストールされた複数のバージョンの Python を並行して使うには？: インストールされた複数のバージョンの Python を並行して使うには？.

よくあるインストールに関する問題

* Linux で、システムの Python 内にインストールする::
* pip がインストールされていない::
* バイナリの拡張のインストール::

Python HOWTO

* Python 3 への拡張モジュール移植::
* Python で Curses プログラミング::
* デスクリプタ ガイド::
* Debugging C API extensions and CPython Internals with GDB::
* 列挙型 HOWTO::
* 関数型プログラミング HOWTO::
* Logging HOWTO::
* Logging クックブック::
* 正規表現 HOWTO::
* ソケットプログラミング HOWTO::
* ソートのテクニック::
* Unicode HOWTO::
* urllib パッケージを使ってインターネット上のリソースを取得するには::
* ipaddressモジュールの紹介::
* DTrace と SystemTap で CPython を測定する::
* Python support for the Linux perf profiler::
* Annotations Best Practices::
* 拡張モジュールを分離する::
* timer file descriptor HOWTO::
* The Python 2.3 Method Resolution Order: The Python 2 3 Method Resolution Order.
* Python experimental support for free threading::
* C API Extension Support for Free Threading::

Python で Curses プログラミング

* curses ってなに?::
* curses アプリケーションの起動と終了::
* ウィンドウとパッド::
* テキストの表示::
* ユーザ入力::
* より多くの情報::

curses ってなに?

* Python の curses module::

テキストの表示

* 属性とカラー::

デスクリプタ ガイド

* 入門::
* 実践的なサンプル::
* 技術的なチュートリアル::
* ピュアPythonの等価実装::

入門

* シンプルな例; 定数を返すデスクリプタ: シンプルな例 定数を返すデスクリプタ.
* 動的なルックアップ::
* 管理された属性::
* 名前のカスタマイズ::
* まとめ::

実践的なサンプル

* バリデータクラス::
* カスタムバリデータ::
* 実践的なアプリケーション::

技術的なチュートリアル

* 概要: 概要<5>.
* 定義と導入::
* デスクリプタプロトコル::
* デスクリプタ呼び出しの概要::
* インスタンスからの呼び出し::
* クラスからの呼び出し::
* superからの呼び出し::
* 呼び出しロジックのまとめ::
* 自動的の名前の伝達::
* ORMのサンプル::

ピュアPythonの等価実装

* プロパティ::
* 関数とメソッド::
* メソッドの種類::
* 静的メソッド::
* クラスメソッド::
* メンバーオブジェクトと __slots__::

Debugging C API extensions and CPython Internals with GDB

* Prerequisites::
* Using the Debug build and Development mode::
* Using the python-gdb extension::
* Use with GDB commands::

Prerequisites

* Setup with Python built from source::
* Setup for Python from a Linux distro::

Using the python-gdb extension

* Pretty-printers::
* py-list::
* py-up and py-down::
* py-bt::
* py-print::
* py-locals::

列挙型 HOWTO

* 列挙型メンバーおよびそれらの属性へのプログラム的アクセス::
* 列挙型メンバーと値の重複::
* 番号付けの値が一意であることの確認::
* 値の自動設定を使う::
* イテレーション: イテレーション<2>.
* 比較: 比較<3>.
* 列挙型で許されるメンバーと属性::
* Enumのサブクラス化の制限::
* データクラスのサポート::
* Pickle 化::
* 関数 API: 関数 API<2>.
* 派生列挙型::
* __new__() と __init__() のどちらを使うべきか: __new__ と __init__ のどちらを使うべきか.
* EnumとFlagはどう違うのか？::
* Enum クックブック::
* EnumType のサブクラスを作る::

派生列挙型

* IntEnum::
* StrEnum::
* IntFlag::
* Flag::
* その他: その他<4>.

__new__() と __init__() のどちらを使うべきか

* 細かい点::

細かい点

* __dunder__ 名のサポート: __dunder__ 名のサポート<2>.
* _sunder_ 名のサポート: _sunder_ 名のサポート<2>.
* _Private__names::
* Enum メンバー型::
* Creating members that are mixed with other data types::
* Enum クラスとメンバーの真偽値::
* メソッド付きの Enum クラス::
* Flag のメンバーの組み合わせ::
* Flag and IntFlag minutia::

EnumとFlagはどう違うのか？

* Enum クラス::
* Flag クラス::
* Enum メンバー (インスタンス): Enum メンバー インスタンス.
* Flag メンバー::

Enum クックブック

* 値の省略::
* OrderedEnum::
* DuplicateFreeEnum::
* MultiValueEnum::
* Planet::
* TimePeriod::

値の省略

* auto を使う::
* object を使う::
* 解説文字列を使う::
* 独自の __new__() を使う: 独自の __new__ を使う.

関数型プログラミング HOWTO

* はじめに: はじめに<12>.
* イテレータ (iterator): イテレータ iterator<2>.
* ジェネレータ式とリスト内包表記::
* ジェネレータ (generator): ジェネレータ generator<2>.
* 組み込み関数 (built-in function): 組み込み関数 built-in function<2>.
* itertools モジュール::
* functools モジュール::
* 小さな関数とラムダ式::
* 更新履歴と謝辞::
* 参考資料: 参考資料<2>.

はじめに

* 形式的証明可能性::
* モジュラー性::
* デバッグやテストの簡単さ::
* 結合性::

イテレータ (iterator)

* イテレータ対応のデータ型::

ジェネレータ (generator)

* ジェネレータに値を渡す::

itertools モジュール

* 新しいイテレータを作る::
* 要素に対して関数を呼ぶ::
* 要素を選択する::
* 組合せ関数::
* 要素をグループ分けする::

functools モジュール

* operator モジュール::

参考資料

* 一般論::
* Python 特有の話::
* Python 文書::

Logging HOWTO

* 基本 logging チュートリアル::
* 上級ロギングチュートリアル::
* ロギングレベル: ロギングレベル<2>.
* 便利なハンドラ::
* ログ記録中に発生する例外::
* 任意のオブジェクトをメッセージに使用する::
* 最適化: 最適化<16>.
* その他のリソース::

基本 logging チュートリアル

* logging を使うとき::
* 簡単な例: 簡単な例<2>.
* ファイルへの logging::
* 変数データのロギング::
* 表示されるメッセージのフォーマットの変更::
* メッセージ内での日付と時刻の表示::
* 次のステップ::

上級ロギングチュートリアル

* Logging Flow::
* ロガー::
* ハンドラ::
* フォーマッタ::
* ロギングの環境設定::
* 環境設定が与えられないとどうなるか::
* ライブラリのためのロギングの設定::

ロギングレベル

* カスタムレベル::

Logging クックブック

* 複数のモジュールで logging を使う::
* 複数のスレッドからのロギング::
* 複数の handler と formatter::
* 複数の出力先にログを出力する::
* ログレベルのカスタム処理::
* 設定サーバの例::
* ブロックする handler を扱う::
* ネットワーク越しの logging イベントの送受信::
* コンテキスト情報をログ記録出力に付加する::
* contextvars の利用::
* ハンドラ内でのコンテキスト情報の付与::
* 複数のプロセスからの単一ファイルへのログ記録::
* ファイルをローテートする::
* 別の format スタイルを利用する::
* LogRecord のカスタマイズ::
* Subclassing QueueHandler and QueueListener- a ZeroMQ example::
* Subclassing QueueHandler and QueueListener- a pynng example::
* 辞書ベースで構成する例::
* rotator と namer を使ってログローテートをカスタマイズする::
* より手の込んだ multiprocessing の例::
* SysLogHandler に送るメッセージに BOM を挿入する::
* 構造化ログを実装する::
* handler を dictConfig() を使ってカスタマイズする: handler を dictConfig を使ってカスタマイズする.
* 固有の書式化スタイルをアプリケーション全体で使う::
* filter を dictConfig() を使ってカスタマイズする: filter を dictConfig を使ってカスタマイズする.
* 例外の書式化をカスタマイズする::
* ロギングメッセージを喋る::
* ロギングメッセージをバッファリングし、条件に従って出力する::
* バッファリングしながらロギングメッセージを email で送信する::
* 設定によって時刻を UTC(GMT) で書式化する: 設定によって時刻を UTC GMT で書式化する.
* ロギングの選択にコンテキストマネージャを使う::
* CLIアプリケーションスターターテンプレート::
* Qt GUIのログ出力::
* RFC5424 をサポートする syslog へのロギング::
* ロガーを出力ストリームのように取り扱う方法::
* 避けるべきパターン::
* その他のリソース: その他のリソース<2>.

ネットワーク越しの logging イベントの送受信

* 作成中のロギングソケットのリスナーを実行する::

コンテキスト情報をログ記録出力に付加する

* LoggerAdapter を使ったコンテキスト情報の伝達::
* Filter を使ったコンテキスト情報の伝達::

LoggerAdapter を使ったコンテキスト情報の伝達

* コンテキスト情報を渡すために dict 以外のオブジェクトを使う::

複数のプロセスからの単一ファイルへのログ記録

* concurrent.futures.ProcessPoolExecutorの利用: concurrent futures ProcessPoolExecutorの利用.
* Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ::

Subclassing QueueHandler and QueueListener- a ZeroMQ example

* Subclass QueueHandler::
* Subclass QueueListener::

Subclassing QueueHandler and QueueListener- a pynng example

* Subclass QueueListener: Subclass QueueListener<2>.
* Subclass QueueHandler: Subclass QueueHandler<2>.

固有の書式化スタイルをアプリケーション全体で使う

* LogRecord ファクトリを使う::
* カスタムなメッセージオブジェクトを使う::

避けるべきパターン

* 同じログファイルを何度も開く::
* ロガーをクラスの属性にするか、パラメータで渡す::
* ライブラリ内でロガーに NullHandler 以外のハンドラーを追加する::
* 大量のロガーを作成する::

正規表現 HOWTO

* はじめに: はじめに<13>.
* 単純なパターン::
* 正規表現を使う::
* パターンの能力をさらに::
* 文字列を変更する::
* よくある問題::
* フィードバック::

単純なパターン

* 文字のマッチング::
* 繰り返し::

正規表現を使う

* 正規表現をコンパイルする::
* バックスラッシュ感染症::
* マッチの実行::
* モジュールレベルの関数: モジュールレベルの関数<3>.
* コンパイルフラグ::

パターンの能力をさらに

* さらなる特殊文字::
* グルーピング::
* 取り出さないグループと名前つきグループ::
* 先読みアサーション (Lookahead Assertions): 先読みアサーション Lookahead Assertions.

文字列を変更する

* 文字列の分割::
* 検索と置換: 検索と置換<2>.

よくある問題

* 文字列メソッドを利用する::
* match() 対 search(): match 対 search.
* 貪欲 (greedy) 対非貪欲 (non-greedy): 貪欲 greedy 対非貪欲 non-greedy.
* re.VERBOSE の利用: re VERBOSE の利用.

ソケットプログラミング HOWTO

* ソケット::
* ソケットの作成: ソケットの作成<3>.
* ソケットの利用::
* 切断::
* ノンブロッキングソケット::

ソケット

* 歴史::

ソケットの作成

* IPC::

ソケットの利用

* バイナリデータ::

切断

* ソケットが死ぬと::

ソートのテクニック

* ソートの基本::
* Key 関数::
* operator モジュールの関数や partial 関数による評価::
* 昇順と降順::
* ソートの安定性と複合的なソート::
* デコレート - ソート - アンデコレート (DSU): デコレート - ソート - アンデコレート DSU.
* 比較関数::
* 残りのはしばし: 残りのはしばし<2>.
* 部分的なソート::

Unicode HOWTO

* Unicode 入門::
* Python の Unicode サポート::
* Unicode データを読み書きする::
* 謝辞: 謝辞<10>.

Unicode 入門

* 定義::
* エンコーディング: エンコーディング<3>.
* 参考資料: 参考資料<3>.

Python の Unicode サポート

* 文字列型::
* バイト列への変換::
* Python ソースコード内の Unicode リテラル::
* Unicode プロパティ::
* Comparing Strings::
* Unicode 正規表現::
* 参考資料: 参考資料<4>.

Unicode データを読み書きする

* Unicode ファイル名::
* Unicode 対応のプログラムを書くための Tips::
* 参考資料: 参考資料<5>.

Unicode 対応のプログラムを書くための Tips

* ファイルエンコーディングの変換::
* 不明なエンコーディングのファイル::

urllib パッケージを使ってインターネット上のリソースを取得するには

* はじめに: はじめに<14>.
* URL を取得する::
* 例外を処理する: 例外を処理する<2>.
* info と geturl::
* Openers と Handlers::
* Basic 認証::
* プロキシ::
* ソケットとレイヤー::
* 脚注::

URL を取得する

* データ::
* ヘッダ::

例外を処理する

* URLError::
* HTTPError::
* エラーをラップする::

HTTPError

* エラーコード::

エラーをラップする

* その1::
* その2::

ipaddressモジュールの紹介

* アドレス/ネットワーク/インターフェースオブジェクトの作成::
* アドレス/ネットワーク/インターフェースオブジェクト::
* アドレスのリストとしてのネットワーク::
* 比較: 比較<4>.
* 他のモジュールでIPアドレスを使用する::
* インスタンスの生成に失敗した場合にさらに詳細を取得する::

アドレス/ネットワーク/インターフェースオブジェクトの作成

* IPバージョンについての注意::
* IPホストアドレス::
* ネットワークを定義する::
* ホストインターフェース::

DTrace と SystemTap で CPython を測定する

* 静的マーカーの有効化::
* 静的 DTrace プローブ::
* 静的 SystemTap マーカー::
* 利用可能な静的マーカー::
* SystemTap Tapset::
* 使用例: 使用例<56>.

Python support for the Linux perf profiler

* How to enable perf profiling support::
* How to obtain the best results::
* How to work without frame pointers::

Annotations Best Practices

* Accessing The Annotations Dict Of An Object In Python 3.10 And Newer: Accessing The Annotations Dict Of An Object In Python 3 10 And Newer.
* Accessing The Annotations Dict Of An Object In Python 3.9 And Older: Accessing The Annotations Dict Of An Object In Python 3 9 And Older.
* Manually Un-Stringizing Stringized Annotations::
* Best Practices For __annotations__ In Any Python Version::
* __annotations__ Quirks::

拡張モジュールを分離する

* Who should read this::
* 背景: 背景<2>.
* Making Modules Safe with Multiple Interpreters::
* Heap Types: Heap Types<2>.
* 取り掛かり中の問題::

背景

* Enter Per-Module State::
* Isolated Module Objects::
* Surprising Edge Cases::

Making Modules Safe with Multiple Interpreters

* Managing Global State::
* Managing Per-Module State::
* Opt-Out; Limiting to One Module Object per Process: Opt-Out Limiting to One Module Object per Process.
* Module State Access from Functions::

Heap Types

* Changing Static Types to Heap Types::
* Defining Heap Types::
* Garbage-Collection Protocol::
* Module State Access from Classes::
* Module State Access from Regular Methods::
* Module State Access from Slot Methods, Getters and Setters: Module State Access from Slot Methods Getters and Setters.
* Lifetime of the Module State::

Garbage-Collection Protocol

* tp_traverse in Python 3.8 and lower: tp_traverse in Python 3 8 and lower.
* Delegating tp_traverse::
* Defining tp_dealloc::
* Not overriding tp_free::
* Avoiding PyObject_New::

取り掛かり中の問題

* Per-Class Scope::
* Lossless Conversion to Heap Types::

timer file descriptor HOWTO

* Examples::

The Python 2.3 Method Resolution Order

* The beginning::
* The C3 Method Resolution Order::
* Examples: Examples<2>.
* Bad Method Resolution Orders::
* The end::
* Resources::

Python experimental support for free threading

* Installation::
* Identifying free-threaded Python::
* The global interpreter lock in free-threaded Python::
* Thread safety::
* Known limitations::

Known limitations

* Immortalization::
* Frame objects::
* Iterators::
* Single-threaded performance::

C API Extension Support for Free Threading

* Identifying the Free-Threaded Build in C::
* Module Initialization::
* General API Guidelines::
* Borrowed References::
* Memory Allocation APIs::
* Thread State and GIL APIs::
* Protecting Internal Extension State::
* Building Extensions for the Free-Threaded Build::

Module Initialization

* Multi-Phase Initialization::
* Single-Phase Initialization::

General API Guidelines

* Container Thread Safety::

Container Thread Safety

* PyDict_Next::

Building Extensions for the Free-Threaded Build

* Limited C API and Stable ABI::
* Windows: Windows<75>.

Python よくある質問

* 一般 Python FAQ::
* プログラミング FAQ::
* デザインと歴史 FAQ::
* ライブラリと拡張 FAQ::
* 拡張と埋め込み FAQ::
* Windows 上の Python FAQ::
* グラフィックユーザインターフェース FAQ::
* "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ::

一般 Python FAQ

* 一般情報::
* 現実世界での Python::

一般情報

* Python とは何ですか？::
* Python Software Foundation とは何ですか？::
* Python を使うのに著作権の制限はありますか？::
* そもそも Python は何故創られたのですか？::
* Python は何をするのに向いていますか？::
* Python のバージョン番号の仕組みはどうなっているのですか？::
* Python のソースのコピーはどこで手に入りますか？::
* Python のドキュメントはどこで手に入りますか？::
* プログラミングをしたことがないのですが、Python のチュートリアルはありますか？::
* Python のためのニュースグループやメーリングリストはありますか？::
* Python のベータテスト版はどこで手に入りますか？::
* Python のバグ報告やパッチを上げるにはどうしたら良いですか？::
* Python について発行された記事を何か参照できますか？::
* Python の本はありますか？::
* www.python.org は世界のどこにあるのですか？: www python org は世界のどこにあるのですか？.
* なぜ Python という名前なのですか？::
* 『空飛ぶモンティ・パイソン』を好きでなくてはいけませんか？::

現実世界での Python

* Python はどれくらい安定していますか？::
* どれくらいの人が Python を使っていますか？::
* Python で行われた大きなプロジェクトはありますか？::
* 将来 Python にどのような新しい開発が期待されますか？::
* Python の互換性を無くすような提案をしてもいいのですか？::
* Python は初心者プログラマに向いている言語ですか？::

プログラミング FAQ

* 一般的な質問::
* コア言語::
* 数と文字列::
* 性能: 性能<4>.
* シーケンス(タプル/リスト): シーケンス タプル/リスト.
* オブジェクト::
* モジュール: モジュール<5>.

一般的な質問

* ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？::
* バグの発見や静的解析に役立つツールはありますか？::
* どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？::
* Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？::

コア言語

* なぜ変数に値があるのに UnboundLocalError が出るのですか？::
* Python のローカルとグローバル変数のルールは何ですか？::
* ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか？::
* グローバル変数をモジュール間で共有するにはどうしたらいいですか？::
* モジュールで import を使う際の「ベストプラクティス」は何ですか？::
* なぜオブジェクト間でデフォルト値が共有されるのですか？::
* オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？::
* 実引数と仮引数の違いは何ですか?::
* なぜ list 'y' を変更すると list 'x' も変更されるのですか?::
* 出力引数のある関数 (参照渡し) はどのように書きますか？: 出力引数のある関数 参照渡し はどのように書きますか？.
* Python で高次関数はどのようにつくりますか？::
* Python のオブジェクトはどのようにコピーしますか？::
* オブジェクトのメソッドや属性はどのように見つけますか？::
* コードはどのようにオブジェクトの名前を見つけるのですか？::
* カンマ演算子はなぜ優先されるのですか？::
* C の "?;" 三項演算子と等価なものはありますか？: C の "? " 三項演算子と等価なものはありますか？.
* Python で解し難いワンライナーを書くことはできますか？::
* 関数の引数リストにあるスラッシュ (/) は何を意味しますか？: 関数の引数リストにあるスラッシュ / は何を意味しますか？.

数と文字列

* 十六進数や八進数を指定するにはどうしたらいいですか？::
* なぜ -22 // 10 は -3 を返すのですか？::
* どうすれば SyntaxError を起こさずに整数リテラルの属性を得られますか？::
* 文字列を数に変換するにはどうしたらいいですか？::
* 数を文字列に変換するにはどうしたらいいですか？::
* 文字列をインプレースに変更するにはどうしたらいいですか？::
* 関数やメソッドを呼ぶのに文字列を使うにはどうしたらいいですか？::
* 文字列から後端の改行を取り除く Perl の chomp() に相当するものはありますか？: 文字列から後端の改行を取り除く Perl の chomp に相当するものはありますか？.
* scanf() や sscanf() と同等なものはありますか？: scanf や sscanf と同等なものはありますか？.
* 'UnicodeDecodeError' や 'UnicodeEncodeError' はどういう意味ですか？::
* raw string を奇数個のバックスラッシュで終えることはできますか？::

性能

* プログラムが遅すぎます。どうしたら速くなりますか？::
* 多くの文字列を結合するのに最も効率的な方法は何ですか？::

シーケンス(タプル/リスト)

* タプル、リスト間の変更はどのようにするのですか？::
* 負の添え字は何ですか？::
* シーケンスを逆順にイテレートするにはどうしたらいいですか？::
* リストから重複を取り除くにはどうしますか？::
* リストから複数のアイテムを取り除く方法::
* Python で配列を作るにはどうしますか？::
* 多次元のリストを作るにはどうしますか？::
* オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか？::
* なぜ加算はされるのに a_tuple[i] += ['item'] は例外を送出するのですか?::
* 複雑なソートがしたいのですが、Python でシュワルツ変換はできますか？::
* リストを別のリストの値によってソートするにはどうしますか？::

オブジェクト

* クラスとは何ですか？::
* メソッドとは何ですか？::
* self とは何ですか？::
* あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを調べるにはどうしますか？::
* 委譲とは何ですか？::
* 基底クラスで定義されたメソッドを、そのクラスを継承した派生クラスから呼び出すにはどうしますか？::
* 基底クラスの名前を変えやすいコードを書くにはどうしますか？::
* 静的なクラスデータや静的なクラスメソッドを作るにはどうしますか？::
* Python でコンストラクタ(やメソッド)をオーバーロードするにはどうしたらいいですか？: Python でコンストラクタ やメソッド をオーバーロードするにはどうしたらいいですか？.
* __spam を使おうとしたら _SomeClassName__spam からエラーがでました。::
* クラスに __del__ メソッドを定義しているのですが、オブジェクトを削除したときに呼ばれません。::
* 与えられたクラスのすべてのインスタンスのリストを得るにはどうしますか？::
* なぜ id() の結果は一意でないように見えるのですか?: なぜ id の結果は一意でないように見えるのですか?.
* いつ is 演算子での同一性テストが頼れますか？::
* どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御できますか？::
* メソッド呼び出しをキャッシュするには どうしたらいいですか？::

モジュール

* .pyc ファイルを作るにはどうしますか？: pyc ファイルを作るにはどうしますか？.
* 現在のモジュール名を知るにはどうしますか？::
* 相互にインポートしあうモジュールを作るにはどうしたらいいですか？::
* __import__('x.y.z') は <module 'x'> を返しますが、z を得るためにはどうしますか？: __import__ 'x y z' は <module 'x'> を返しますが、z を得るためにはどうしますか？.
* インポートされたモジュールを編集してから再インポートしましたが、変化が現れません。なぜですか？::

デザインと歴史 FAQ

* Python はなぜ文のグループ化にインデントを使うのですか？::
* なぜ単純な算術演算が奇妙な結果になるのですか？::
* なぜ浮動小数点数の計算はこんなに不正確なんですか？::
* なぜ Python の文字列はイミュータブルなのですか？::
* なぜメソッドの定義や呼び出しにおいて 'self' を明示しなければならないのですか？::
* 式中で代入ができないのはなぜですか？::
* Python にメソッドを使う機能 (list.index() 等) と関数を使う機能 (len(list) 等) があるのはなぜですか？: Python にメソッドを使う機能 list index 等 と関数を使う機能 len list 等 があるのはなぜですか？.
* join() がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？: join がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？.
* 例外はどれくらい速いのですか？::
* Python に switch や case 文がないのはなぜですか？::
* OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？::
* なぜラムダ式は文を含むことができないのですか?::
* Python は C やその他の言語のように機械語にコンパイルできますか？::
* Python はメモリをどのように管理するのですか？::
* CPython はなぜ伝統的なガベージコレクションスキームを使わないのですか？::
* なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか？::
* なぜタプルとリストという別のデータ型が用意されているのですか？::
* CPythonでリストはどのように実装されているのですか？::
* CPythonで辞書はどのように実装されていますか？::
* なぜ辞書のキーはイミュータブルでなくてはならないのですか？::
* なぜ list.sort() はソートされたリストを返さないのですか？: なぜ list sort はソートされたリストを返さないのですか？.
* Python ではどのようにインターフェース仕様を特定し適用するのですか？::
* なぜ goto が無いのですか？::
* なぜ raw 文字列 (r-strings) はバックスラッシュで終わってはいけないのですか？: なぜ raw 文字列 r-strings はバックスラッシュで終わってはいけないのですか？.
* 属性の代入に "with" 文が使えないのはなぜですか？::
* なぜジェネレータは with 文をサポートしないのですか？::
* if/while/def/class 文にコロンが必要なのはなぜですか？::
* なぜ Python ではリストやタプルの最後にカンマがあっても良いのですか？::

ライブラリと拡張 FAQ

* ライブラリ一般の質問::
* よくある作業::
* スレッド::
* 入力と出力: 入力と出力<2>.
* ネットワーク/インターネットプログラミング::
* データベース::
* 数学と数::

ライブラリ一般の質問

* 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？::
* math.py (socket.py, regex.py, etc.) のソースファイルはどこにありますか？: math py socket py regex py etc のソースファイルはどこにありますか？.
* Python のスクリプトを Unix で実行可能にするにはどうしますか？::
* Python には curses/termcap パッケージはありますか？::
* Python には C の onexit() に相当するものはありますか？: Python には C の onexit に相当するものはありますか？.
* シグナルハンドラが動かないのですがなぜですか？::

よくある作業

* Python のプログラムやコンポーネントをテストするにはどうしますか？::
* Python のドキュメント文字列からドキュメントを生成するにはどうしますか？::
* 一度に一つの押鍵を取得するにはどうしますか？::

スレッド

* スレッドを使ったプログラムを書くにはどうしますか？::
* スレッドが一つも実行されていないようです。なぜですか？::
* たくさんのワーカースレッドに作業を割り振るにはどうしますか？::
* グローバルな値のどんな種類の変更がスレッドセーフになるのですか？::
* グローバルインタプリタロック (Global Interpreter Lock) を取り除くことはできないのですか？: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？.

入力と出力

* ファイルを削除するにはどうしますか？ (その他、ファイルに関する質問...): ファイルを削除するにはどうしますか？ その他、ファイルに関する質問.
* ファイルをコピーするにはどうしますか？::
* バイナリデータを読み書きするにはどうしますか？::
* os.popen() によって作られたパイプで os.read() が使われていないようです。なぜですか？: os popen によって作られたパイプで os read が使われていないようです。なぜですか？.
* シリアル (RS232) ポートにアクセスするにはどうしますか？: シリアル RS232 ポートにアクセスするにはどうしますか？.
* sys.stdout (stdin, stderr) を閉じようとしても実際に閉じられないのはなぜですか？: sys stdout stdin stderr を閉じようとしても実際に閉じられないのはなぜですか？.

ネットワーク/インターネットプログラミング

* Python の WWW ツールには何がありますか？::
* どのモジュールが HTML の生成の役に立ちますか？::
* Python のスクリプトからメールを送るにはどうしますか？::
* ソケットの connect() メソッドでブロッキングされなくするにはどうしますか？: ソケットの connect メソッドでブロッキングされなくするにはどうしますか？.

データベース

* Python にはデータベースパッケージへのインターフェースはありますか？::
* Python で永続的なオブジェクトを実装するにはどうしますか？::

数学と数

* Python で乱数を生成するにはどうしますか？::

拡張と埋め込み FAQ

* C で独自の関数を作ることはできますか？::
* C++ で独自の関数を作ることはできますか？::
* C を書くのは大変です。他の方法はありませんか？::
* C から任意の Python 文を実行するにはどうしますか？::
* C から任意の Python 式を評価するにはどうしますか？::
* Python オブジェクトから C の値を取り出すにはどうしますか？::
* Py_BuildValue() で任意長のタプルを作るにはどうしますか？: Py_BuildValue で任意長のタプルを作るにはどうしますか？.
* C からオブジェクトのメソッドを呼び出すにはどうしますか？::
* PyErr_Print() (その他 stdout/stderr に印字するもの) からの出力を受け取るにはどうしますか？: PyErr_Print その他 stdout/stderr に印字するもの からの出力を受け取るにはどうしますか？.
* C から Python で書かれたモジュールにアクセスするにはどうしますか？::
* Python から C++ へインターフェースするにはどうしますか？::
* セットアップファイルでモジュールを追加しようとしたらメイクに失敗しました。なぜですか？::
* 拡張をデバッグするにはどうしますか？::
* Linux システムで Python モジュールをコンパイルしたいのですが、見つからないファイルがあります。なぜですか？::
* "不完全 (incomplete) な入力" を "不適切 (invalid) な入力" から区別するにはどうしますか？: "不完全 incomplete な入力" を "不適切 invalid な入力" から区別するにはどうしますか？.
* 未定義の g++ シンボル __builtin_new や __pure_virtual を見つけるにはどうしますか？::
* メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを (継承などで) 作ることはできますか？: メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを 継承などで 作ることはできますか？.

Windows 上の Python FAQ

* Python プログラムを Windows で動かすにはどうしますか？::
* Python スクリプトを実行可能にするにはどうしますか？::
* Python の起動に時間がかかることがあるのはなぜですか？::
* どうすれば Python スクリプトを EXE に出来ますか?::
* *.pyd ファイルは DLL と同じですか？: * pyd ファイルは DLL と同じですか？.
* Python を Windows アプリケーションに埋め込むにはどうしたらいいですか？::
* エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？::
* ブロックすることなく押鍵を検出するにはどうしますか？::
* missing api-ms-win-crt-runtime-l1-1-0.dll エラーを解決するにはどうしますか？: missing api-ms-win-crt-runtime-l1-1-0 dll エラーを解決するにはどうしますか？.

グラフィックユーザインターフェース FAQ

* 一般的な GUI の質問::
* Python の GUI ツールキットには何がありますか？::
* Tkinter の質問::

Tkinter の質問

* Tkinter アプリケーションを凍結するにはどうしますか？::
* I/O を待つ間に扱われる Tk イベントを作れますか？::
* Tkinter で働くキーバインディングが得られません。なぜですか？::

"なぜ Python が私のコンピュータにインストールされているのですか？" FAQ

* Python とは何ですか？: Python とは何ですか？<2>.
* なぜ Python が私のマシンにインストールされているのですか？::
* Python を削除してもいいですか？::

Deprecations

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<5>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<5>.
* Pending removal in Python 3.16: Pending removal in Python 3 16<3>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<5>.
* C API Deprecations::

C API Deprecations

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<6>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<6>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<6>.

このドキュメントについて

* Pythonドキュメント 貢献者::

バグへの対処

* ドキュメントの不備::
* Python の課題管理システムを使う::
* Python への貢献をはじめる::

歴史とライセンス

* Python の歴史::
* Terms and conditions for accessing or otherwise using Python::
* Licenses and Acknowledgements for Incorporated Software::

Terms and conditions for accessing or otherwise using Python

* PSF LICENSE AGREEMENT FOR PYTHON 3.13.0: PSF LICENSE AGREEMENT FOR PYTHON 3 13 0.
* BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0: BEOPEN COM LICENSE AGREEMENT FOR PYTHON 2 0.
* CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1: CNRI LICENSE AGREEMENT FOR PYTHON 1 6 1.
* CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2: CWI LICENSE AGREEMENT FOR PYTHON 0 9 0 THROUGH 1 2.
* ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3.13.0 DOCUMENTATION: ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3 13 0 DOCUMENTATION.

Licenses and Acknowledgements for Incorporated Software

* Mersenne Twister::
* ソケット: ソケット<2>.
* Asynchronous socket services::
* Cookie management::
* Execution tracing::
* UUencode and UUdecode functions::
* XML Remote Procedure Calls::
* test_epoll::
* Select kqueue::
* SipHash24::
* strtod と dtoa::
* OpenSSL: OpenSSL<2>.
* expat::
* libffi::
* zlib: zlib<3>.
* cfuhash::
* libmpdec::
* W3C C14N test suite::
* mimalloc::
* asyncio: asyncio<12>.
* Global Unbounded Sequences (GUS): Global Unbounded Sequences GUS.



File: python.info,  Node: What's New in Python,  Next: Python チュートリアル,  Prev: Top,  Up: Top

1 What's New in Python
**********************

この"What's New in Python"という一連の文書はPythonのメジャーバージョンに
おける最も重要な変更点を紹介します。新しくリリースされた後でも最新の状態
であり続けたい人にとって必読のものです。

* Menu:

* What's New In Python 3.13: What's New In Python 3 13.
* What's New In Python 3.12: What's New In Python 3 12.
* What's New In Python 3.11: What's New In Python 3 11.
* What's New In Python 3.10: What's New In Python 3 10.
* What's New In Python 3.9: What's New In Python 3 9.
* What's New In Python 3.8: What's New In Python 3 8.
* What's New In Python 3.7: What's New In Python 3 7.
* What's New In Python 3.6: What's New In Python 3 6.
* What's New In Python 3.5: What's New In Python 3 5.
* What's New In Python 3.4: What's New In Python 3 4.
* What's New In Python 3.3: What's New In Python 3 3.
* What's New In Python 3.2: What's New In Python 3 2.
* What's New In Python 3.1: What's New In Python 3 1.
* What's New In Python 3.0: What's New In Python 3 0.
* What's New in Python 2.7: What's New in Python 2 7.
* What's New in Python 2.6: What's New in Python 2 6.
* What's New in Python 2.5: What's New in Python 2 5.
* What's New in Python 2.4: What's New in Python 2 4.
* What's New in Python 2.3: What's New in Python 2 3.
* What's New in Python 2.2: What's New in Python 2 2.
* What's New in Python 2.1: What's New in Python 2 1.
* What's New in Python 2.0: What's New in Python 2 0.
* 変更履歴::


File: python.info,  Node: What's New In Python 3 13,  Next: What's New In Python 3 12,  Up: What's New in Python

1.1 What's New In Python 3.13
=============================


Editors: Adam Turner and Thomas Wouters

This article explains the new features in Python 3.13, compared to 3.12.
Python 3.13 was released on October 7, 2024.  For full details, see the
*note changelog: 122.

参考
....

PEP 719(1) - Python 3.13 Release Schedule

* Menu:

* Summary: Summary -- Release Highlights. Release Highlights
* New Features::
* Other Language Changes::
* New Modules::
* Improved Modules::
* Optimizations::
* Removed Modules And APIs::
* New Deprecations::
* CPython Bytecode Changes::
* C API Changes::
* Build Changes::
* Porting to Python 3.13: Porting to Python 3 13.
* Regression Test Changes::
* Notable changes in 3.13.1: Notable changes in 3 13 1.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0719/


File: python.info,  Node: Summary -- Release Highlights,  Next: New Features,  Up: What's New In Python 3 13

1.1.1 Summary - Release Highlights
----------------------------------

Python 3.13 is the latest stable release of the Python programming
language, with a mix of changes to the language, the implementation and
the standard library.  The biggest changes include a new *note
interactive interpreter: 124., experimental support for running in a
*note free-threaded mode: 125.( PEP 703(1)), and a *note Just-In-Time
compiler: 126.( PEP 744(2)).

Error messages continue to improve, with tracebacks now highlighted in
color by default.  The *note locals(): 127. builtin now has *note
defined semantics: 128. for changing the returned mapping, and type
parameters now support default values.

The library changes contain removal of deprecated APIs and modules, as
well as the usual improvements in user-friendliness and correctness.
Several legacy standard library modules have now *note been removed:
129.following their deprecation in Python 3.11 ( PEP 594(3)).

This article doesn't attempt to provide a complete specification of all
new features, but instead gives a convenient overview.  For full details
refer to the documentation, such as the *note Library Reference: 12a.
and *note Language Reference: 12b.  To understand the complete
implementation and design rationale for a change, refer to the PEP for a
particular new feature; but note that PEPs usually are not kept
up-to-date once a feature has been fully implemented.  See *note Porting
to Python 3.13: 12c. for guidance on upgrading from earlier versions of
Python.

__________________________________________________________________

Interpreter improvements:

   * A greatly improved *note interactive interpreter: 124. and *note
     improved error messages: 12d.

   * PEP 667(4): The *note locals(): 127. builtin now has *note defined
     semantics: 128. when mutating the returned mapping.  Python
     debuggers and similar tools may now more reliably update local
     variables in optimized scopes even during concurrent code
     execution.

   * PEP 703(5): CPython 3.13 has experimental support for running with
     the *note global interpreter lock: 12e. disabled.  See *note
     Free-threaded CPython: 125. for more details.

   * PEP 744(6): A basic *note JIT compiler: 126. was added.  It is
     currently disabled by default (though we may turn it on later).
     Performance improvements are modest - we expect to improve this
     over the next few releases.

   * Color support in the new *note interactive interpreter: 124, as
     well as in *note tracebacks: 12d. and *note doctest: 12f. output.
     This can be disabled through the *note PYTHON_COLORS: 130. and
     NO_COLOR(7) environment variables.

Python data model improvements:

   * *note __static_attributes__: 131. stores the names of attributes
     accessed through ‘self.X’ in any function in a class body.

   * *note __firstlineno__: 132. records the first line number of a
     class definition.

Significant improvements in the standard library:

   * Add a new *note PythonFinalizationError: 133. exception, raised
     when an operation is blocked during *note finalization: 134.

   * The *note argparse: 5. module now supports deprecating command-line
     options, positional arguments, and subcommands.

   * The new functions *note base64.z85encode(): 135. and *note
     base64.z85decode(): 136. support encoding and decoding Z85 data(8).

   * The *note copy: 1e. module now has a *note copy.replace(): 137.
     function, with support for many builtin types and any class
     defining the *note __replace__(): 138. method.

   * The new *note dbm.sqlite3: 2d. module is now the default *note dbm:
     29. backend.

   * The *note os: 91. module has a *note suite of new functions: 139.
     for working with Linux's timer notification file descriptors.

   * The *note random: a6. module now has a *note command-line
     interface: 13a.

Security improvements:

   * *note ssl.create_default_context(): 13b. sets *note
     ssl.VERIFY_X509_PARTIAL_CHAIN: 13c. and *note
     ssl.VERIFY_X509_STRICT: 13d. as default flags.

C API improvements:

   * The *note Py_mod_gil: 13e. slot is now used to indicate that an
     extension module supports running with the *note GIL: 13f.
     disabled.

   * The *note PyTime C API: 140. has been added, providing access to
     system clocks.

   * *note PyMutex: 141. is a new lightweight mutex that occupies a
     single byte.

   * There is a new *note suite of functions: 142. for generating PEP
     669(9) monitoring events in the C API.

New typing features:

   * PEP 696(10): Type parameters (*note typing.TypeVar: 143, *note
     typing.ParamSpec: 144, and *note typing.TypeVarTuple: 145.) now
     support defaults.

   * PEP 702(11): The new *note warnings.deprecated(): 146. decorator
     adds support for marking deprecations in the type system and at
     runtime.

   * PEP 705(12): *note typing.ReadOnly: 147. can be used to mark an
     item of a *note typing.TypedDict: 148. as read-only for type
     checkers.

   * PEP 742(13): *note typing.TypeIs: 149. provides more intuitive type
     narrowing behavior, as an alternative to *note typing.TypeGuard:
     14a.

Platform support:

   * PEP 730(14): Apple's iOS is now an *note officially supported
     platform: 14b, at tier 3(15).

   * PEP 738(16): Android is now an *note officially supported platform:
     14b, at tier 3(17).

   * ‘wasm32-wasi’ is now supported as a tier 2(18) platform.

   * ‘wasm32-emscripten’ is no longer an officially supported platform.

Important removals:

   * *note PEP 594: 129.: The remaining 19 "dead batteries" (legacy
     stdlib modules) have been removed from the standard library:
     ‘aifc’, ‘audioop’, ‘cgi’, ‘cgitb’, ‘chunk’, ‘crypt’, ‘imghdr’,
     ‘mailcap’, ‘msilib’, ‘nis’, ‘nntplib’, ‘ossaudiodev’, ‘pipes’,
     ‘sndhdr’, ‘spwd’, ‘sunau’, ‘telnetlib’, ‘uu’ and ‘xdrlib’.

   * Remove the ‘2to3’ tool and ‘lib2to3’ module (deprecated in Python
     3.11).

   * Remove the ‘tkinter.tix’ module (deprecated in Python 3.6).

   * Remove the ‘locale.resetlocale()’ function.

   * Remove the ‘typing.io’ and ‘typing.re’ namespaces.

   * Remove chained *note classmethod: 14c. descriptors.

Release schedule changes:

PEP 602(19) ("Annual Release Cycle for Python") has been updated to
extend the full support ('bugfix') period for new releases to two years.
This updated policy means that:

   * Python 3.9-3.12 have one and a half years of full support, followed
     by three and a half years of security fixes.

   * Python 3.13 and later have two years of full support, followed by
     three years of security fixes.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0703/

   (2) https://peps.python.org/pep-0744/

   (3) https://peps.python.org/pep-0594/

   (4) https://peps.python.org/pep-0667/

   (5) https://peps.python.org/pep-0703/

   (6) https://peps.python.org/pep-0744/

   (7) https://no-color.org/

   (8) https://rfc.zeromq.org/spec/32/

   (9) https://peps.python.org/pep-0669/

   (10) https://peps.python.org/pep-0696/

   (11) https://peps.python.org/pep-0702/

   (12) https://peps.python.org/pep-0705/

   (13) https://peps.python.org/pep-0742/

   (14) https://peps.python.org/pep-0730/

   (15) https://peps.python.org/pep-0011/#tier-3

   (16) https://peps.python.org/pep-0738/

   (17) https://peps.python.org/pep-0011/#tier-3

   (18) https://peps.python.org/pep-0011/#tier-2

   (19) https://peps.python.org/pep-0602/


File: python.info,  Node: New Features,  Next: Other Language Changes,  Prev: Summary -- Release Highlights,  Up: What's New In Python 3 13

1.1.2 New Features
------------------

* Menu:

* A better interactive interpreter::
* Improved error messages::
* Free-threaded CPython::
* An experimental just-in-time (JIT) compiler: An experimental just-in-time JIT compiler.
* Defined mutation semantics for locals(): Defined mutation semantics for locals.
* Support for mobile platforms::


File: python.info,  Node: A better interactive interpreter,  Next: Improved error messages,  Up: New Features

1.1.2.1 A better interactive interpreter
........................................

Python now uses a new *note interactive: 14f. shell by default, based on
code from the PyPy project(1).  When the user starts the *note REPL:
150. from an interactive terminal, the following new features are now
supported:

   * Multiline editing with history preservation.

   * Direct support for REPL-specific commands like ‘help’, ‘exit’, and
     ‘quit’, without the need to call them as functions.

   * Prompts and tracebacks with *note color enabled by default: 151.

   * Interactive help browsing using ‘F1’ with a separate command
     history.

   * History browsing using ‘F2’ that skips output as well as the *note
     >>>: 152. and *note ...: 153. prompts.

   * "Paste mode" with ‘F3’ that makes pasting larger blocks of code
     easier (press ‘F3’ again to return to the regular prompt).

To disable the new interactive shell, set the *note PYTHON_BASIC_REPL:
154. environment variable.  For more on interactive mode, see *note
対話モード: 155.

(Contributed by Pablo Galindo Salgado, Łukasz Langa, and Lysandros
Nikolaou in gh-111201(2) based on code from the PyPy project.  Windows
support contributed by Dino Viehland and Anthony Shaw.)

   ---------- Footnotes ----------

   (1) https://pypy.org/

   (2) https://github.com/python/cpython/issues/111201


File: python.info,  Node: Improved error messages,  Next: Free-threaded CPython,  Prev: A better interactive interpreter,  Up: New Features

1.1.2.2 Improved error messages
...............................

   * The interpreter now uses color by default when displaying
     tracebacks in the terminal.  This feature *note can be controlled:
     151. via the new *note PYTHON_COLORS: 130. environment variable as
     well as the canonical NO_COLOR(1) and FORCE_COLOR(2) environment
     variables.  (Contributed by Pablo Galindo Salgado in gh-112730(3).)

   * A common mistake is to write a script with the same name as a
     standard library module.  When this results in errors, we now
     display a more helpful error message:

          $ python random.py
          Traceback (most recent call last):
            File "/home/me/random.py", line 1, in <module>
              import random
            File "/home/me/random.py", line 3, in <module>
              print(random.randint(5))
                    ^^^^^^^^^^^^^^
          AttributeError: module 'random' has no attribute 'randint' (consider renaming '/home/me/random.py' since it has the same name as the standard library module named 'random' and prevents importing that standard library module)

     Similarly, if a script has the same name as a third-party module
     that it attempts to import and this results in errors, we also
     display a more helpful error message:

          $ python numpy.py
          Traceback (most recent call last):
            File "/home/me/numpy.py", line 1, in <module>
              import numpy as np
            File "/home/me/numpy.py", line 3, in <module>
              np.array([1, 2, 3])
              ^^^^^^^^
          AttributeError: module 'numpy' has no attribute 'array' (consider renaming '/home/me/numpy.py' if it has the same name as a library you intended to import)

     (Contributed by Shantanu Jain in gh-95754(4).)

   * The error message now tries to suggest the correct keyword argument
     when an incorrect keyword argument is passed to a function.

          >>> "Better error messages!".split(max_split=1)
          Traceback (most recent call last):
            File "<python-input-0>", line 1, in <module>
              "Better error messages!".split(max_split=1)
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
          TypeError: split() got an unexpected keyword argument 'max_split'. Did you mean 'maxsplit'?

     (Contributed by Pablo Galindo Salgado and Shantanu Jain in
     gh-107944(5).)

   ---------- Footnotes ----------

   (1) https://no-color.org/

   (2) https://force-color.org/

   (3) https://github.com/python/cpython/issues/112730

   (4) https://github.com/python/cpython/issues/95754

   (5) https://github.com/python/cpython/issues/107944


File: python.info,  Node: Free-threaded CPython,  Next: An experimental just-in-time JIT compiler,  Prev: Improved error messages,  Up: New Features

1.1.2.3 Free-threaded CPython
.............................

CPython now has experimental support for running in a free-threaded
mode, with the *note global interpreter lock: 12e. (GIL) disabled.  This
is an experimental feature and therefore is not enabled by default.  The
free-threaded mode requires a different executable, usually called
‘python3.13t’ or ‘python3.13t.exe’.  Pre-built binaries marked as
'free-threaded' can be installed as part of the official *note Windows:
158. and *note macOS: 159. installers, or CPython can be built from
source with the *note -disable-gil: 15a. option.

Free-threaded execution allows for full utilization of the available
processing power by running threads in parallel on available CPU cores.
While not all software will benefit from this automatically, programs
designed with threading in mind will run faster on multi-core hardware.
'The free-threaded mode is experimental' and work is ongoing to improve
it: expect some bugs and a substantial single-threaded performance hit.
Free-threaded builds of CPython support optionally running with the GIL
enabled at runtime using the environment variable *note PYTHON_GIL: 15b.
or the command-line option *note -X gil=1: 15c.

To check if the current interpreter supports free-threading, *note
python -VV: 15d. and *note sys.version: 15e. contain "experimental
free-threading build".  The new ‘sys._is_gil_enabled()’ function can be
used to check whether the GIL is actually disabled in the running
process.

C-API extension modules need to be built specifically for the
free-threaded build.  Extensions that support running with the *note
GIL: 13f. disabled should use the *note Py_mod_gil: 13e. slot.
Extensions using single-phase init should use *note
PyUnstable_Module_SetGIL(): 15f. to indicate whether they support
running with the GIL disabled.  Importing C extensions that don't use
these mechanisms will cause the GIL to be enabled, unless the GIL was
explicitly disabled with the *note PYTHON_GIL: 15b. environment variable
or the *note -X gil=0: 15c. option.  pip 24.1 or newer is required to
install packages with C extensions in the free-threaded build.

This work was made possible thanks to many individuals and
organizations, including the large community of contributors to Python
and third-party projects to test and enable free-threading support.
Notable contributors include: Sam Gross, Ken Jin, Donghee Na, Itamar
Oren, Matt Page, Brett Simmers, Dino Viehland, Carl Meyer, Nathan
Goldbaum, Ralf Gommers, Lysandros Nikolaou, and many others.  Many of
these contributors are employed by Meta, which has provided significant
engineering resources to support this project.

参考
....

PEP 703(1) "Making the Global Interpreter Lock Optional in CPython"
contains rationale and information surrounding this work.

Porting Extension Modules to Support Free-Threading(2): A
community-maintained porting guide for extension authors.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0703/

   (2) https://py-free-threading.github.io/porting/


File: python.info,  Node: An experimental just-in-time JIT compiler,  Next: Defined mutation semantics for locals,  Prev: Free-threaded CPython,  Up: New Features

1.1.2.4 An experimental just-in-time (JIT) compiler
...................................................

When CPython is configured and built using the
‘--enable-experimental-jit’ option, a just-in-time (JIT) compiler is
added which may speed up some Python programs.  On Windows, use
‘PCbuild/build.bat --experimental-jit’ to enable the JIT or
‘--experimental-jit-interpreter’ to enable the Tier 2 interpreter.
Build requirements and further supporting information are contained
at(1) ‘Tools/jit/README.md’.

The ‘--enable-experimental-jit’ option takes these (optional) values,
defaulting to ‘yes’ if ‘--enable-experimental-jit’ is present without
the optional value.

   * ‘no’: Disable the entire Tier 2 and JIT pipeline.

   * ‘yes’: Enable the JIT. To disable the JIT at runtime, pass the
     environment variable ‘PYTHON_JIT=0’.

   * ‘yes-off’: Build the JIT but disable it by default.  To enable the
     JIT at runtime, pass the environment variable ‘PYTHON_JIT=1’.

   * ‘interpreter’: Enable the Tier 2 interpreter but disable the JIT.
     The interpreter can be disabled by running with ‘PYTHON_JIT=0’.

The internal architecture is roughly as follows:

   * We start with specialized 'Tier 1 bytecode'.  See *note What's new
     in 3.11: 161. for details.

   * When the Tier 1 bytecode gets hot enough, it gets translated to a
     new purely internal intermediate representation (IR), called the
     'Tier 2 IR', and sometimes referred to as micro-ops ("uops").

   * The Tier 2 IR uses the same stack-based virtual machine as Tier 1,
     but the instruction format is better suited to translation to
     machine code.

   * We have several optimization passes for Tier 2 IR, which are
     applied before it is interpreted or translated to machine code.

   * There is a Tier 2 interpreter, but it is mostly intended for
     debugging the earlier stages of the optimization pipeline.  The
     Tier 2 interpreter can be enabled by configuring Python with
     ‘--enable-experimental-jit=interpreter’.

   * When the JIT is enabled, the optimized Tier 2 IR is translated to
     machine code, which is then executed.

   * The machine code translation process uses a technique called
     'copy-and-patch'.  It has no runtime dependencies, but there is a
     new build-time dependency on LLVM.

参考
....

PEP 744(2)

(JIT by Brandt Bucher, inspired by a paper by Haoran Xu and Fredrik
Kjolstad.  Tier 2 IR by Mark Shannon and Guido van Rossum.  Tier 2
optimizer by Ken Jin.)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/blob/main/Tools/jit/README.md

   (2) https://peps.python.org/pep-0744/


File: python.info,  Node: Defined mutation semantics for locals,  Next: Support for mobile platforms,  Prev: An experimental just-in-time JIT compiler,  Up: New Features

1.1.2.5 Defined mutation semantics for ‘locals()’
.................................................

Historically, the expected result of mutating the return value of *note
locals(): 127. has been left to individual Python implementations to
define.  Starting from Python 3.13, PEP 667(1) standardises the
historical behavior of CPython for most code execution scopes, but
changes *note optimized scopes: 163. (functions, generators, coroutines,
comprehensions, and generator expressions) to explicitly return
independent snapshots of the currently assigned local variables,
including locally referenced nonlocal variables captured in closures.

This change to the semantics of *note locals(): 127. in optimized scopes
also affects the default behavior of code execution functions that
implicitly target ‘locals()’ if no explicit namespace is provided (such
as *note exec(): 164. and *note eval(): 165.).  In previous versions,
whether or not changes could be accessed by calling ‘locals()’ after
calling the code execution function was implementation-dependent.  In
CPython specifically, such code would typically appear to work as
desired, but could sometimes fail in optimized scopes based on other
code (including debuggers and code execution tracing tools) potentially
resetting the shared snapshot in that scope.  Now, the code will always
run against an independent snapshot of the local variables in optimized
scopes, and hence the changes will never be visible in subsequent calls
to ‘locals()’.  To access the changes made in these cases, an explicit
namespace reference must now be passed to the relevant function.
Alternatively, it may make sense to update affected code to use a higher
level code execution API that returns the resulting code execution
namespace (e.g.  *note runpy.run_path(): 166. when executing Python
files from disk).

To ensure debuggers and similar tools can reliably update local
variables in scopes affected by this change, *note FrameType.f_locals:
167. now returns a write-through proxy to the frame's local and locally
referenced nonlocal variables in these scopes, rather than returning an
inconsistently updated shared ‘dict’ instance with undefined runtime
semantics.

See PEP 667(2) for more details, including related C API changes and
deprecations.  Porting notes are also provided below for the affected
*note Python APIs: 168. and *note C APIs: 169.

(PEP and implementation contributed by Mark Shannon and Tian Gao in
gh-74929(3).  Documentation updates provided by Guido van Rossum and
Alyssa Coghlan.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0667/

   (2) https://peps.python.org/pep-0667/

   (3) https://github.com/python/cpython/issues/74929


File: python.info,  Node: Support for mobile platforms,  Prev: Defined mutation semantics for locals,  Up: New Features

1.1.2.6 Support for mobile platforms
....................................

PEP 730(1): iOS is now a PEP 11(2) supported platform, with the
‘arm64-apple-ios’ and ‘arm64-apple-ios-simulator’ targets at tier 3
(iPhone and iPad devices released after 2013 and the Xcode iOS simulator
running on Apple silicon hardware, respectively).
‘x86_64-apple-ios-simulator’ (the Xcode iOS simulator running on older
‘x86_64’ hardware) is not a tier 3 supported platform, but will have
best-effort support.  (PEP written and implementation contributed by
Russell Keith-Magee in gh-114099(3).)

PEP 738(4): Android is now a PEP 11(5) supported platform, with the
‘aarch64-linux-android’ and ‘x86_64-linux-android’ targets at tier 3.
The 32-bit targets ‘arm-linux-androideabi’ and ‘i686-linux-android’ are
not tier 3 supported platforms, but will have best-effort support.  (PEP
written and implementation contributed by Malcolm Smith in
gh-116622(6).)

参考
....

PEP 730(7), PEP 738(8)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0730/

   (2) https://peps.python.org/pep-0011/

   (3) https://github.com/python/cpython/issues/114099

   (4) https://peps.python.org/pep-0738/

   (5) https://peps.python.org/pep-0011/

   (6) https://github.com/python/cpython/issues/116622

   (7) https://peps.python.org/pep-0730/

   (8) https://peps.python.org/pep-0738/


File: python.info,  Node: Other Language Changes,  Next: New Modules,  Prev: New Features,  Up: What's New In Python 3 13

1.1.3 Other Language Changes
----------------------------

   * The compiler now strips common leading whitespace from every line
     in a docstring.  This reduces the size of the *note bytecode cache:
     16c. (such as ‘.pyc’ files), with reductions in file size of around
     5%, for example in ‘sqlalchemy.orm.session’ from SQLAlchemy 2.0.
     This change affects tools that use docstrings, such as *note
     doctest: 31.

          >>> def spam():
          ...     """
          ...         This is a docstring with
          ...           leading whitespace.
          ...
          ...         It even has multiple paragraphs!
          ...     """
          ...
          >>> spam.__doc__
          '\nThis is a docstring with\n  leading whitespace.\n\nIt even has multiple paragraphs!\n'

     (Contributed by Inada Naoki in gh-81283(1).)

   * *note Annotation scopes: 16d. within class scopes can now contain
     lambdas and comprehensions.  Comprehensions that are located within
     class scopes are not inlined into their parent scope.

          class C[T]:
              type Alias = lambda: T

     (Contributed by Jelle Zijlstra in gh-109118(2) and gh-118160(3).)

   * *note Future statements: 16e. are no longer triggered by relative
     imports of the *note __future__: 0. module, meaning that statements
     of the form ‘from .__future__ import ...’ are now simply standard
     relative imports, with no special features activated.  (Contributed
     by Jeremiah Gabriel Pascual in gh-118216(4).)

   * *note global: 16f. declarations are now permitted in *note except:
     170. blocks when that global is used in the *note else: 171. block.
     Previously this raised an erroneous *note SyntaxError: 172.
     (Contributed by Irit Katriel in gh-111123(5).)

   * Add *note PYTHON_FROZEN_MODULES: 173, a new environment variable
     that determines whether frozen modules are ignored by the import
     machinery, equivalent to the *note -X frozen_modules: 15c.
     command-line option.  (Contributed by Yilei Yang in gh-111374(6).)

   * Add *note support for the perf profiler: 174. working without frame
     pointers(7) through the new environment variable *note
     PYTHON_PERF_JIT_SUPPORT: 175. and command-line option *note -X
     perf_jit: 15c.  (Contributed by Pablo Galindo in gh-118518(8).)

   * The location of a ‘.python_history’ file can be changed via the new
     *note PYTHON_HISTORY: 176. environment variable.  (Contributed by
     Levi Sabah, Zackery Spytz and Hugo van Kemenade in gh-73965(9).)

   * Classes have a new *note __static_attributes__: 131. attribute.
     This is populated by the compiler with a tuple of the class's
     attribute names which are assigned through ‘self.<name>’ from any
     function in its body.  (Contributed by Irit Katriel in
     gh-115775(10).)

   * The compiler now creates a ‘__firstlineno__’ attribute on classes
     with the line number of the first line of the class definition.
     (Contributed by Serhiy Storchaka in gh-118465(11).)

   * The *note exec(): 164. and *note eval(): 165. builtins now accept
     the 'globals' and 'locals' arguments as keywords.  (Contributed by
     Raphael Gaschignard in gh-105879(12))

   * The *note compile(): 177. builtin now accepts a new flag,
     ‘ast.PyCF_OPTIMIZED_AST’, which is similar to ‘ast.PyCF_ONLY_AST’
     except that the returned AST is optimized according to the value of
     the 'optimize' argument.  (Contributed by Irit Katriel in
     gh-108113(13)).

   * Add a *note __name__: 178. attribute on *note property: 179.
     objects.  (Contributed by Eugene Toder in gh-101860(14).)

   * Add *note PythonFinalizationError: 133, a new exception derived
     from *note RuntimeError: 17a. and used to signal when operations
     are blocked during *note finalization: 134.  The following
     callables now raise ‘PythonFinalizationError’, instead of *note
     RuntimeError: 17a.:

        * *note _thread.start_new_thread(): 17b.

        * *note os.fork(): 17c.

        * *note os.forkpty(): 17d.

        * *note subprocess.Popen: 17e.

     (Contributed by Victor Stinner in gh-114570(15).)

   * Allow the 'count' argument of *note str.replace(): 17f. to be a
     keyword.  (Contributed by Hugo van Kemenade in gh-106487(16).)

   * Many functions now emit a warning if a boolean value is passed as a
     file descriptor argument.  This can help catch some errors earlier.
     (Contributed by Serhiy Storchaka in gh-82626(17).)

   * Added ‘name’ and ‘mode’ attributes for compressed and archived
     file-like objects in the *note bz2: f, *note lzma: 7e, *note
     tarfile: c8, and *note zipfile: 117. modules.  (Contributed by
     Serhiy Storchaka in gh-115961(18).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/81283

   (2) https://github.com/python/cpython/issues/109118

   (3) https://github.com/python/cpython/issues/118160

   (4) https://github.com/python/cpython/issues/118216

   (5) https://github.com/python/cpython/issues/111123

   (6) https://github.com/python/cpython/issues/111374

   (7) https://en.wikipedia.org/wiki/Call_stack

   (8) https://github.com/python/cpython/issues/118518

   (9) https://github.com/python/cpython/issues/73965

   (10) https://github.com/python/cpython/issues/115775

   (11) https://github.com/python/cpython/issues/118465

   (12) https://github.com/python/cpython/issues/105879

   (13) https://github.com/python/cpython/issues/108113

   (14) https://github.com/python/cpython/issues/101860

   (15) https://github.com/python/cpython/issues/114570

   (16) https://github.com/python/cpython/issues/106487

   (17) https://github.com/python/cpython/issues/82626

   (18) https://github.com/python/cpython/issues/115961


File: python.info,  Node: New Modules,  Next: Improved Modules,  Prev: Other Language Changes,  Up: What's New In Python 3 13

1.1.4 New Modules
-----------------

   * *note dbm.sqlite3: 2d.: An SQLite backend for *note dbm: 29.
     (Contributed by Raymond Hettinger and Erlend E. Aasland in
     gh-100414(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100414


File: python.info,  Node: Improved Modules,  Next: Optimizations,  Prev: New Modules,  Up: What's New In Python 3 13

1.1.5 Improved Modules
----------------------

* Menu:

* argparse::
* array::
* ast::
* asyncio::
* base64::
* compileall::
* concurrent.futures: concurrent futures.
* configparser::
* copy::
* ctypes::
* dbm::
* dis::
* doctest::
* email::
* fractions::
* glob::
* importlib::
* io::
* ipaddress::
* itertools::
* marshal::
* math::
* mimetypes::
* mmap::
* multiprocessing::
* os::
* os.path: os path.
* pathlib::
* pdb::
* queue::
* random::
* re::
* shutil::
* site::
* sqlite3::
* ssl::
* statistics::
* subprocess::
* sys::
* tempfile::
* time::
* tkinter::
* traceback::
* types::
* typing::
* unicodedata::
* venv::
* warnings::
* xml::
* zipimport::


File: python.info,  Node: argparse,  Next: array,  Up: Improved Modules

1.1.5.1 argparse
................

   * Add the 'deprecated' parameter to the *note add_argument(): 183.
     and ‘add_parser()’ methods, to enable deprecating command-line
     options, positional arguments, and subcommands.  (Contributed by
     Serhiy Storchaka in gh-83648(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/83648


File: python.info,  Node: array,  Next: ast,  Prev: argparse,  Up: Improved Modules

1.1.5.2 array
.............

   * Add the ‘'w'’ type code (‘Py_UCS4’) for Unicode characters.  It
     should be used instead of the deprecated ‘'u'’ type code.
     (Contributed by Inada Naoki in gh-80480(1).)

   * Register *note array.array: 185. as a *note MutableSequence: 186.
     by implementing the *note clear(): 187. method.  (Contributed by
     Mike Zimin in gh-114894(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/80480

   (2) https://github.com/python/cpython/issues/114894


File: python.info,  Node: ast,  Next: asyncio,  Prev: array,  Up: Improved Modules

1.1.5.3 ast
...........

   * The constructors of node types in the *note ast: 7. module are now
     stricter in the arguments they accept, with more intuitive behavior
     when arguments are omitted.

     If an optional field on an AST node is not included as an argument
     when constructing an instance, the field will now be set to ‘None’.
     Similarly, if a list field is omitted, that field will now be set
     to an empty list, and if an ‘expr_context’ field is omitted, it
     defaults to *note Load(): 189.  (Previously, in all cases, the
     attribute would be missing on the newly constructed AST node
     instance.)

     In all other cases, where a required argument is omitted, the node
     constructor will emit a *note DeprecationWarning: 18a.  This will
     raise an exception in Python 3.15.  Similarly, passing a keyword
     argument to the constructor that does not map to a field on the AST
     node is now deprecated, and will raise an exception in Python 3.15.

     These changes do not apply to user-defined subclasses of *note
     ast.AST: 18b. unless the class opts in to the new behavior by
     defining the *note AST._field_types: 18c. mapping.

     (Contributed by Jelle Zijlstra in gh-105858(1), gh-117486(2), and
     gh-118851(3).)

   * *note ast.parse(): 18d. now accepts an optional argument 'optimize'
     which is passed on to *note compile(): 177.  This makes it possible
     to obtain an optimized AST. (Contributed by Irit Katriel in
     gh-108113(4).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/105858

   (2) https://github.com/python/cpython/issues/117486

   (3) https://github.com/python/cpython/issues/118851

   (4) https://github.com/python/cpython/issues/108113


File: python.info,  Node: asyncio,  Next: base64,  Prev: ast,  Up: Improved Modules

1.1.5.4 asyncio
...............

   * *note asyncio.as_completed(): 18f. now returns an object that is
     both an *note asynchronous iterator: 190. and a plain *note
     iterator: 191. of *note awaitables: 192.  The awaitables yielded by
     asynchronous iteration include original task or future objects that
     were passed in, making it easier to associate results with the
     tasks being completed.  (Contributed by Justin Arthur in
     gh-77714(1).)

   * *note asyncio.loop.create_unix_server(): 193. will now
     automatically remove the Unix socket when the server is closed.
     (Contributed by Pierre Ossman in gh-111246(2).)

   * *note DatagramTransport.sendto(): 194. will now send zero-length
     datagrams if called with an empty bytes object.  The transport flow
     control also now accounts for the datagram header when calculating
     the buffer size.  (Contributed by Jamie Phan in gh-115199(3).)

   * Add *note Queue.shutdown: 195. and *note QueueShutDown: 196. to
     manage queue termination.  (Contributed by Laurie Opperman and Yves
     Duprat in gh-104228(4).)

   * Add the *note Server.close_clients(): 197. and *note
     Server.abort_clients(): 198. methods, which more forcefully close
     an asyncio server.  (Contributed by Pierre Ossman in gh-113538(5).)

   * Accept a tuple of separators in *note StreamReader.readuntil():
     199, stopping when any one of them is encountered.  (Contributed by
     Bruce Merry in gh-81322(6).)

   * Improve the behavior of *note TaskGroup: 19a. when an external
     cancellation collides with an internal cancellation.  For example,
     when two task groups are nested and both experience an exception in
     a child task simultaneously, it was possible that the outer task
     group would hang, because its internal cancellation was swallowed
     by the inner task group.

     In the case where a task group is cancelled externally and also
     must raise an *note ExceptionGroup: 19b, it will now call the
     parent task's *note cancel(): 19c. method.  This ensures that a
     *note CancelledError: 19d. will be raised at the next *note await:
     19e, so the cancellation is not lost.

     An added benefit of these changes is that task groups now preserve
     the cancellation count (*note cancelling(): 19f.).

     In order to handle some corner cases, *note uncancel(): 1a0. may
     now reset the undocumented ‘_must_cancel’ flag when the
     cancellation count reaches zero.

     (Inspired by an issue reported by Arthur Tacca in gh-116720(7).)

   * When *note TaskGroup.create_task(): 1a1. is called on an inactive
     *note TaskGroup: 19a, the given coroutine will be closed (which
     prevents a *note RuntimeWarning: 1a2. about the given coroutine
     being never awaited).  (Contributed by Arthur Tacca and Jason Zhang
     in gh-115957(8).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/77714

   (2) https://github.com/python/cpython/issues/111246

   (3) https://github.com/python/cpython/issues/115199

   (4) https://github.com/python/cpython/issues/104228

   (5) https://github.com/python/cpython/issues/113538

   (6) https://github.com/python/cpython/issues/81322

   (7) https://github.com/python/cpython/issues/116720

   (8) https://github.com/python/cpython/issues/115957


File: python.info,  Node: base64,  Next: compileall,  Prev: asyncio,  Up: Improved Modules

1.1.5.5 base64
..............

   * Add *note z85encode(): 135. and *note z85decode(): 136. functions
     for encoding *note bytes: 1a4. as Z85 data(1) and decoding
     Z85-encoded data to ‘bytes’.  (Contributed by Matan Perelman in
     gh-75299(2).)

   ---------- Footnotes ----------

   (1) https://rfc.zeromq.org/spec/32/

   (2) https://github.com/python/cpython/issues/75299


File: python.info,  Node: compileall,  Next: concurrent futures,  Prev: base64,  Up: Improved Modules

1.1.5.6 compileall
..................

   * The default number of worker threads and processes is now selected
     using *note os.process_cpu_count(): 1a6. instead of *note
     os.cpu_count(): 1a7.  (Contributed by Victor Stinner in
     gh-109649(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109649


File: python.info,  Node: concurrent futures,  Next: configparser,  Prev: compileall,  Up: Improved Modules

1.1.5.7 concurrent.futures
..........................

   * The default number of worker threads and processes is now selected
     using *note os.process_cpu_count(): 1a6. instead of *note
     os.cpu_count(): 1a7.  (Contributed by Victor Stinner in
     gh-109649(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109649


File: python.info,  Node: configparser,  Next: copy,  Prev: concurrent futures,  Up: Improved Modules

1.1.5.8 configparser
....................

   * *note ConfigParser: 1aa. now has support for unnamed sections,
     which allows for top-level key-value pairs.  This can be enabled
     with the new 'allow_unnamed_section' parameter.  (Contributed by
     Pedro Sousa Lacerda in gh-66449(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/66449


File: python.info,  Node: copy,  Next: ctypes,  Prev: configparser,  Up: Improved Modules

1.1.5.9 copy
............

   * The new *note replace(): 137. function and the *note replace
     protocol: 138. make creating modified copies of objects much
     simpler.  This is especially useful when working with immutable
     objects.  The following types support the *note replace(): 137.
     function and implement the replace protocol:

        * *note collections.namedtuple(): 1ac.

        * *note dataclasses.dataclass: 1ad.

        * *note datetime.datetime: 1ae, *note datetime.date: 1af, *note
          datetime.time: 1b0.

        * *note inspect.Signature: 1b1, *note inspect.Parameter: 1b2.

        * *note types.SimpleNamespace: 1b3.

        * *note code objects: 1b4.

     Any user-defined class can also support *note copy.replace(): 137.
     by defining the *note __replace__(): 138. method.  (Contributed by
     Serhiy Storchaka in gh-108751(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/108751


File: python.info,  Node: ctypes,  Next: dbm,  Prev: copy,  Up: Improved Modules

1.1.5.10 ctypes
...............

   * As a consequence of necessary internal refactoring, initialization
     of internal metaclasses now happens in ‘__init__’ rather than in
     ‘__new__’.  This affects projects that subclass these internal
     metaclasses to provide custom initialization.  Generally:

        - Custom logic that was done in ‘__new__’ after calling
          ‘super().__new__’ should be moved to ‘__init__’.

        - To create a class, call the metaclass, not only the
          metaclass's ‘__new__’ method.

     See gh-124520(1) for discussion and links to changes in some
     affected projects.

   * *note ctypes.Structure: 1b6. objects have a new *note _align_: 1b7.
     attribute which allows the alignment of the structure being packed
     to/from memory to be specified explicitly.  (Contributed by Matt
     Sanderson in gh-112433(2))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124520

   (2) https://github.com/python/cpython/issues/112433


File: python.info,  Node: dbm,  Next: dis,  Prev: ctypes,  Up: Improved Modules

1.1.5.11 dbm
............

   * Add *note dbm.sqlite3: 2d, a new module which implements an SQLite
     backend, and make it the default ‘dbm’ backend.  (Contributed by
     Raymond Hettinger and Erlend E. Aasland in gh-100414(1).)

   * Allow removing all items from the database through the new *note
     gdbm.clear(): 1b9. and *note ndbm.clear(): 1ba. methods.
     (Contributed by Donghee Na in gh-107122(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100414

   (2) https://github.com/python/cpython/issues/107122


File: python.info,  Node: dis,  Next: doctest,  Prev: dbm,  Up: Improved Modules

1.1.5.12 dis
............

   * Change the output of *note dis: 30. module functions to show
     logical labels for jump targets and exception handlers, rather than
     offsets.  The offsets can be added with the new *note -O: 1bc.
     command-line option or the 'show_offsets' argument.  (Contributed
     by Irit Katriel in gh-112137(1).)

   * *note get_instructions(): 1bd. no longer represents cache entries
     as separate instructions.  Instead, it returns them as part of the
     *note Instruction: 1be, in the new 'cache_info' field.  The
     'show_caches' argument to *note get_instructions(): 1bd. is
     deprecated and no longer has any effect.  (Contributed by Irit
     Katriel in gh-112962(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/112137

   (2) https://github.com/python/cpython/issues/112962


File: python.info,  Node: doctest,  Next: email,  Prev: dis,  Up: Improved Modules

1.1.5.13 doctest
................

   * *note doctest: 31. output is now colored by default.  This can be
     controlled via the new *note PYTHON_COLORS: 130. environment
     variable as well as the canonical NO_COLOR(1) and FORCE_COLOR(2)
     environment variables.  See also *note 色の制御: 151.  (Contributed
     by Hugo van Kemenade in gh-117225(3).)

   * The *note DocTestRunner.run(): 1c0. method now counts the number of
     skipped tests.  Add the *note DocTestRunner.skips: 1c1. and *note
     TestResults.skipped: 1c2. attributes.  (Contributed by Victor
     Stinner in gh-108794(4).)

   ---------- Footnotes ----------

   (1) https://no-color.org/

   (2) https://force-color.org/

   (3) https://github.com/python/cpython/issues/117225

   (4) https://github.com/python/cpython/issues/108794


File: python.info,  Node: email,  Next: fractions,  Prev: doctest,  Up: Improved Modules

1.1.5.14 email
..............

   * Headers with embedded newlines are now quoted on output.  The *note
     generator: 37. will now refuse to serialize (write) headers that
     are improperly folded or delimited, such that they would be parsed
     as multiple headers or joined with adjacent data.  If you need to
     turn this safety feature off, set *note verify_generated_headers:
     1c4.  (Contributed by Bas Bloemsaat and Petr Viktorin in
     gh-121650(1).)

   * *note getaddresses(): 1c5. and *note parseaddr(): 1c6. now return
     ‘('', '')’ pairs in more situations where invalid email addresses
     are encountered instead of potentially inaccurate values.  The two
     functions have a new optional 'strict' parameter (default ‘True’).
     To get the old behavior (accepting malformed input), use
     ‘strict=False’.  ‘getattr(email.utils, 'supports_strict_parsing',
     False)’ can be used to check if the 'strict' parameter is
     available.  (Contributed by Thomas Dwyer and Victor Stinner for
     gh-102988(2) to improve the CVE 2023-27043(3) fix.)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/121650

   (2) https://github.com/python/cpython/issues/102988

   (3) https://www.cve.org/CVERecord?id=CVE-2023-27043


File: python.info,  Node: fractions,  Next: glob,  Prev: email,  Up: Improved Modules

1.1.5.15 fractions
..................

   * *note Fraction: 1c8. objects now support the standard *note format
     specification mini-language: 1c9. rules for fill, alignment, sign
     handling, minimum width, and grouping.  (Contributed by Mark
     Dickinson in gh-111320(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111320


File: python.info,  Node: glob,  Next: importlib,  Prev: fractions,  Up: Improved Modules

1.1.5.16 glob
.............

   * Add *note translate(): 1cb, a function to convert a path
     specification with shell-style wildcards to a regular expression.
     (Contributed by Barney Gale in gh-72904(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/72904


File: python.info,  Node: importlib,  Next: io,  Prev: glob,  Up: Improved Modules

1.1.5.17 importlib
..................

   * The following functions in *note importlib.resources: 6f. now allow
     accessing a directory (or tree) of resources, using multiple
     positional arguments (the 'encoding' and 'errors' arguments in the
     text-reading functions are now keyword-only):

        * *note is_resource(): 1cd.

        * *note open_binary(): 1ce.

        * *note open_text(): 1cf.

        * *note path(): 1d0.

        * *note read_binary(): 1d1.

        * *note read_text(): 1d2.

     These functions are no longer deprecated and are not scheduled for
     removal.  (Contributed by Petr Viktorin in gh-116608(1).)

   * *note contents(): 1d3. remains deprecated in favor of the
     fully-featured *note Traversable: 1d4. API. However, there is now
     no plan to remove it.  (Contributed by Petr Viktorin in
     gh-116608(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116608

   (2) https://github.com/python/cpython/issues/116608


File: python.info,  Node: io,  Next: ipaddress,  Prev: importlib,  Up: Improved Modules

1.1.5.18 io
...........

   * The *note IOBase: 1d6. finalizer now logs any errors raised by the
     *note close(): 1d7. method with *note sys.unraisablehook: 1d8.
     Previously, errors were ignored silently by default, and only
     logged in *note Python Development Mode: 1d9. or when using a *note
     Python debug build: 1da.  (Contributed by Victor Stinner in
     gh-62948(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/62948


File: python.info,  Node: ipaddress,  Next: itertools,  Prev: io,  Up: Improved Modules

1.1.5.19 ipaddress
..................

   * Add the *note IPv4Address.ipv6_mapped: 1dc. property, which returns
     the IPv4-mapped IPv6 address.  (Contributed by Charles Machalow in
     gh-109466(1).)

   * Fix ‘is_global’ and ‘is_private’ behavior in *note IPv4Address:
     1dd, *note IPv6Address: 1de, *note IPv4Network: 1df, and *note
     IPv6Network: 1e0.  (Contributed by Jakub Stasiak in gh-113171(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109466

   (2) https://github.com/python/cpython/issues/113171


File: python.info,  Node: itertools,  Next: marshal,  Prev: ipaddress,  Up: Improved Modules

1.1.5.20 itertools
..................

   * *note batched(): 1e2. has a new 'strict' parameter, which raises a
     *note ValueError: 1e3. if the final batch is shorter than the
     specified batch size.  (Contributed by Raymond Hettinger in
     gh-113202(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/113202


File: python.info,  Node: marshal,  Next: math,  Prev: itertools,  Up: Improved Modules

1.1.5.21 marshal
................

   * Add the 'allow_code' parameter in module functions.  Passing
     ‘allow_code=False’ prevents serialization and de-serialization of
     code objects which are incompatible between Python versions.
     (Contributed by Serhiy Storchaka in gh-113626(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/113626


File: python.info,  Node: math,  Next: mimetypes,  Prev: marshal,  Up: Improved Modules

1.1.5.22 math
.............

   * The new function *note fma(): 1e6. performs fused multiply-add
     operations.  This computes ‘x * y + z’ with only a single round,
     and so avoids any intermediate loss of precision.  It wraps the
     ‘fma()’ function provided by C99, and follows the specification of
     the IEEE 754 "fusedMultiplyAdd" operation for special cases.
     (Contributed by Mark Dickinson and Victor Stinner in gh-73468(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/73468


File: python.info,  Node: mimetypes,  Next: mmap,  Prev: math,  Up: Improved Modules

1.1.5.23 mimetypes
..................

   * Add the *note guess_file_type(): 1e8. function to guess a MIME type
     from a filesystem path.  Using paths with *note guess_type(): 1e9.
     is now *note soft deprecated: 1ea.  (Contributed by Serhiy
     Storchaka in gh-66543(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/66543


File: python.info,  Node: mmap,  Next: multiprocessing,  Prev: mimetypes,  Up: Improved Modules

1.1.5.24 mmap
.............

   * *note mmap: 1ec. is now protected from crashing on Windows when the
     mapped memory is inaccessible due to file system errors or access
     violations.  (Contributed by Jannis Weigend in gh-118209(1).)

   * *note mmap: 1ec. has a new *note seekable(): 1ed. method that can
     be used when a seekable file-like object is required.  The *note
     seek(): 1ee. method now returns the new absolute position.
     (Contributed by Donghee Na and Sylvie Liberman in gh-111835(2).)

   * The new UNIX-only 'trackfd' parameter for *note mmap: 1ec. controls
     file descriptor duplication; if false, the file descriptor
     specified by 'fileno' will not be duplicated.  (Contributed by
     Zackery Spytz and Petr Viktorin in gh-78502(3).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118209

   (2) https://github.com/python/cpython/issues/111835

   (3) https://github.com/python/cpython/issues/78502


File: python.info,  Node: multiprocessing,  Next: os,  Prev: mmap,  Up: Improved Modules

1.1.5.25 multiprocessing
........................

   * The default number of worker threads and processes is now selected
     using *note os.process_cpu_count(): 1a6. instead of *note
     os.cpu_count(): 1a7.  (Contributed by Victor Stinner in
     gh-109649(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109649


File: python.info,  Node: os,  Next: os path,  Prev: multiprocessing,  Up: Improved Modules

1.1.5.26 os
...........

   * Add *note process_cpu_count(): 1a6. function to get the number of
     logical CPU cores usable by the calling thread of the current
     process.  (Contributed by Victor Stinner in gh-109649(1).)

   * *note cpu_count(): 1a7. and *note process_cpu_count(): 1a6. can be
     overridden through the new environment variable *note
     PYTHON_CPU_COUNT: 1f1. or the new command-line option *note -X
     cpu_count: 15c.  This option is useful for users who need to limit
     CPU resources of a container system without having to modify
     application code or the container itself.  (Contributed by Donghee
     Na in gh-109595(2).)

   * Add a *note low level interface: 139. to Linux's ‘timer file
     descriptors(3)’ via *note timerfd_create(): 1f2, *note
     timerfd_settime(): 1f3, *note timerfd_settime_ns(): 1f4, *note
     timerfd_gettime(): 1f5, *note timerfd_gettime_ns(): 1f6, *note
     TFD_NONBLOCK: 1f7, *note TFD_CLOEXEC: 1f8, *note TFD_TIMER_ABSTIME:
     1f9, and *note TFD_TIMER_CANCEL_ON_SET: 1fa. (Contributed by Masaru
     Tsuchiyama in gh-108277(4).)

   * *note lchmod(): 1fb. and the 'follow_symlinks' argument of *note
     chmod(): 1fc. are both now available on Windows.  Note that the
     default value of 'follow_symlinks' in ‘lchmod()’ is ‘False’ on
     Windows.  (Contributed by Serhiy Storchaka in gh-59616(5).)

   * *note fchmod(): 1fd. and support for file descriptors in *note
     chmod(): 1fc. are both now available on Windows.  (Contributed by
     Serhiy Storchaka in gh-113191(6).)

   * On Windows, *note mkdir(): 1fe. and *note makedirs(): 1ff. now
     support passing a 'mode' value of ‘0o700’ to apply access control
     to the new directory.  This implicitly affects *note
     tempfile.mkdtemp(): 200. and is a mitigation for CVE 2024-4030(7).
     Other values for 'mode' continue to be ignored.  (Contributed by
     Steve Dower in gh-118486(8).)

   * *note posix_spawn(): 201. now accepts ‘None’ for the 'env'
     argument, which makes the newly spawned process use the current
     process environment.  (Contributed by Jakub Kulik in gh-113119(9).)

   * *note posix_spawn(): 201. can now use the *note
     POSIX_SPAWN_CLOSEFROM: 202. attribute in the 'file_actions'
     parameter on platforms that support
     ‘posix_spawn_file_actions_addclosefrom_np()’.  (Contributed by
     Jakub Kulik in gh-113117(10).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109649

   (2) https://github.com/python/cpython/issues/109595

   (3) https://manpages.debian.org/timerfd_create(2)

   (4) https://github.com/python/cpython/issues/108277

   (5) https://github.com/python/cpython/issues/59616

   (6) https://github.com/python/cpython/issues/113191

   (7) https://www.cve.org/CVERecord?id=CVE-2024-4030

   (8) https://github.com/python/cpython/issues/118486

   (9) https://github.com/python/cpython/issues/113119

   (10) https://github.com/python/cpython/issues/113117


File: python.info,  Node: os path,  Next: pathlib,  Prev: os,  Up: Improved Modules

1.1.5.27 os.path
................

   * Add *note isreserved(): 204. to check if a path is reserved on the
     current system.  This function is only available on Windows.
     (Contributed by Barney Gale in gh-88569(1).)

   * On Windows, *note isabs(): 205. no longer considers paths starting
     with exactly one slash (‘\’ or ‘/’) to be absolute.  (Contributed
     by Barney Gale and Jon Foster in gh-44626(2).)

   * *note realpath(): 206. now resolves MS-DOS style file names even if
     the file is not accessible.  (Contributed by Moonsik Park in
     gh-82367(3).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/88569

   (2) https://github.com/python/cpython/issues/44626

   (3) https://github.com/python/cpython/issues/82367


File: python.info,  Node: pathlib,  Next: pdb,  Prev: os path,  Up: Improved Modules

1.1.5.28 pathlib
................

   * Add *note UnsupportedOperation: 208, which is raised instead of
     *note NotImplementedError: 209. when a path operation isn't
     supported.  (Contributed by Barney Gale in gh-89812(1).)

   * Add a new constructor for creating *note Path: 20a. objects from
     'file' URIs (‘file:///’), *note Path.from_uri(): 20b.  (Contributed
     by Barney Gale in gh-107465(2).)

   * Add *note PurePath.full_match(): 20c. for matching paths with
     shell-style wildcards, including the recursive wildcard "‘**’".
     (Contributed by Barney Gale in gh-73435(3).)

   * Add the *note PurePath.parser: 20d. class attribute to store the
     implementation of *note os.path: 92. used for low-level path
     parsing and joining.  This will be either ‘posixpath’ or ‘ntpath’.

   * Add 'recurse_symlinks' keyword-only argument to *note Path.glob():
     20e. and *note rglob(): 20f.  (Contributed by Barney Gale in
     gh-77609(4).)

   * *note Path.glob(): 20e. and *note rglob(): 20f. now return files
     and directories when given a pattern that ends with "‘**’".
     Previously, only directories were returned.  (Contributed by Barney
     Gale in gh-70303(5).)

   * Add the 'follow_symlinks' keyword-only argument to *note
     Path.is_file: 210, *note Path.is_dir: 211, *note Path.owner(): 212,
     and *note Path.group(): 213.  (Contributed by Barney Gale in
     gh-105793(6) and Kamil Turek in gh-107962(7).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89812

   (2) https://github.com/python/cpython/issues/107465

   (3) https://github.com/python/cpython/issues/73435

   (4) https://github.com/python/cpython/issues/77609

   (5) https://github.com/python/cpython/issues/70303

   (6) https://github.com/python/cpython/issues/105793

   (7) https://github.com/python/cpython/issues/107962


File: python.info,  Node: pdb,  Next: queue,  Prev: pathlib,  Up: Improved Modules

1.1.5.29 pdb
............

   * *note breakpoint(): 215. and *note set_trace(): 216. now enter the
     debugger immediately rather than on the next line of code to be
     executed.  This change prevents the debugger from breaking outside
     of the context when ‘breakpoint()’ is positioned at the end of the
     context.  (Contributed by Tian Gao in gh-118579(1).)

   * ‘sys.path[0]’ is no longer replaced by the directory of the script
     being debugged when *note sys.flags.safe_path: 217. is set.
     (Contributed by Tian Gao and Christian Walther in gh-111762(2).)

   * *note zipapp: 116. is now supported as a debugging target.
     (Contributed by Tian Gao in gh-118501(3).)

   * Add ability to move between chained exceptions during post-mortem
     debugging in *note pm(): 218. using the new *note exceptions
     [exc_number]: 219. command for Pdb.  (Contributed by Matthias
     Bussonnier in gh-106676(4).)

   * Expressions and statements whose prefix is a pdb command are now
     correctly identified and executed.  (Contributed by Tian Gao in
     gh-108464(5).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118579

   (2) https://github.com/python/cpython/issues/111762

   (3) https://github.com/python/cpython/issues/118501

   (4) https://github.com/python/cpython/issues/106676

   (5) https://github.com/python/cpython/issues/108464


File: python.info,  Node: queue,  Next: random,  Prev: pdb,  Up: Improved Modules

1.1.5.30 queue
..............

   * Add *note Queue.shutdown: 21b. and *note ShutDown: 21c. to manage
     queue termination.  (Contributed by Laurie Opperman and Yves Duprat
     in gh-104750(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104750


File: python.info,  Node: random,  Next: re,  Prev: queue,  Up: Improved Modules

1.1.5.31 random
...............

   * Add a *note command-line interface: 13a.  (Contributed by Hugo van
     Kemenade in gh-118131(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118131


File: python.info,  Node: re,  Next: shutil,  Prev: random,  Up: Improved Modules

1.1.5.32 re
...........

   * Rename ‘re.error’ to *note PatternError: 21f. for improved clarity.
     ‘re.error’ is kept for backward compatibility.


File: python.info,  Node: shutil,  Next: site,  Prev: re,  Up: Improved Modules

1.1.5.33 shutil
...............

   * Support the 'dir_fd' and 'follow_symlinks' keyword arguments in
     *note chown(): 221.  (Contributed by Berker Peksag and Tahia K in
     gh-62308(1))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/62308


File: python.info,  Node: site,  Next: sqlite3,  Prev: shutil,  Up: Improved Modules

1.1.5.34 site
.............

   * ‘.pth’ files are now decoded using UTF-8 first, and then with the
     *note locale encoding: 223. if UTF-8 decoding fails.  (Contributed
     by Inada Naoki in gh-117802(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/117802


File: python.info,  Node: sqlite3,  Next: ssl,  Prev: site,  Up: Improved Modules

1.1.5.35 sqlite3
................

   * A *note ResourceWarning: 225. is now emitted if a *note Connection:
     226. object is not *note closed: 227. explicitly.  (Contributed by
     Erlend E. Aasland in gh-105539(1).)

   * Add the 'filter' keyword-only parameter to *note
     Connection.iterdump(): 228. for filtering database objects to dump.
     (Contributed by Mariusz Felisiak in gh-91602(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/105539

   (2) https://github.com/python/cpython/issues/91602


File: python.info,  Node: ssl,  Next: statistics,  Prev: sqlite3,  Up: Improved Modules

1.1.5.36 ssl
............

   * The *note create_default_context(): 13b. API now includes *note
     VERIFY_X509_PARTIAL_CHAIN: 13c. and *note VERIFY_X509_STRICT: 13d.
     in its default flags.

          注釈: *note VERIFY_X509_STRICT: 13d. may reject pre- RFC
          5280(1) or malformed certificates that the underlying OpenSSL
          implementation might otherwise accept.  Whilst disabling this
          is not recommended, you can do so using:

               import ssl

               ctx = ssl.create_default_context()
               ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT

     (Contributed by William Woodruff in gh-112389(2).)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5280.html

   (2) https://github.com/python/cpython/issues/112389


File: python.info,  Node: statistics,  Next: subprocess,  Prev: ssl,  Up: Improved Modules

1.1.5.37 statistics
...................

   * Add *note kde(): 22b. for kernel density estimation.  This makes it
     possible to estimate a continuous probability density function from
     a fixed number of discrete samples.  (Contributed by Raymond
     Hettinger in gh-115863(1).)

   * Add *note kde_random(): 22c. for sampling from an estimated
     probability density function created by *note kde(): 22b.
     (Contributed by Raymond Hettinger in gh-115863(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115863

   (2) https://github.com/python/cpython/issues/115863


File: python.info,  Node: subprocess,  Next: sys,  Prev: statistics,  Up: Improved Modules

1.1.5.38 subprocess
...................

   * The *note subprocess: c1. module now uses the *note posix_spawn():
     201. function in more situations.

     Notably, when 'close_fds' is ‘True’ (the default), *note
     posix_spawn(): 201. will be used when the C library provides
     ‘posix_spawn_file_actions_addclosefrom_np()’, which includes recent
     versions of Linux, FreeBSD, and Solaris.  On Linux, this should
     perform similarly to the existing Linux ‘vfork()’ based code.

     A private control knob ‘subprocess._USE_POSIX_SPAWN’ can be set to
     ‘False’ if you need to force *note subprocess: c1. to never use
     *note posix_spawn(): 201.  Please report your reason and platform
     details in the *note issue tracker: 22f. if you set this so that we
     can improve our API selection logic for everyone.  (Contributed by
     Jakub Kulik in gh-113117(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/113117


File: python.info,  Node: sys,  Next: tempfile,  Prev: subprocess,  Up: Improved Modules

1.1.5.39 sys
............

   * Add the *note _is_interned(): 231. function to test if a string was
     interned.  This function is not guaranteed to exist in all
     implementations of Python.  (Contributed by Serhiy Storchaka in
     gh-78573(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/78573


File: python.info,  Node: tempfile,  Next: time,  Prev: sys,  Up: Improved Modules

1.1.5.40 tempfile
.................

   * On Windows, the default mode ‘0o700’ used by *note
     tempfile.mkdtemp(): 200. now limits access to the new directory due
     to changes to *note os.mkdir(): 1fe.  This is a mitigation for CVE
     2024-4030(1).  (Contributed by Steve Dower in gh-118486(2).)

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2024-4030

   (2) https://github.com/python/cpython/issues/118486


File: python.info,  Node: time,  Next: tkinter,  Prev: tempfile,  Up: Improved Modules

1.1.5.41 time
.............

   * On Windows, *note monotonic(): 234. now uses the
     ‘QueryPerformanceCounter()’ clock for a resolution of 1
     microsecond, instead of the ‘GetTickCount64()’ clock which has a
     resolution of 15.6 milliseconds.  (Contributed by Victor Stinner in
     gh-88494(1).)

   * On Windows, *note time(): 235. now uses the
     ‘GetSystemTimePreciseAsFileTime()’ clock for a resolution of 1
     microsecond, instead of the ‘GetSystemTimeAsFileTime()’ clock which
     has a resolution of 15.6 milliseconds.  (Contributed by Victor
     Stinner in gh-63207(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/88494

   (2) https://github.com/python/cpython/issues/63207


File: python.info,  Node: tkinter,  Next: traceback,  Prev: time,  Up: Improved Modules

1.1.5.42 tkinter
................

   * Add *note tkinter: d9. widget methods: ‘tk_busy_hold()’,
     ‘tk_busy_configure()’, ‘tk_busy_cget()’, ‘tk_busy_forget()’,
     ‘tk_busy_current()’, and ‘tk_busy_status()’.  (Contributed by
     Miguel, klappnase and Serhiy Storchaka in gh-72684(1).)

   * The *note tkinter: d9. widget method ‘wm_attributes()’ now accepts
     the attribute name without the minus prefix to get window
     attributes, for example ‘w.wm_attributes('alpha')’ and allows
     specifying attributes and values to set as keyword arguments, for
     example ‘w.wm_attributes(alpha=0.5)’.  (Contributed by Serhiy
     Storchaka in gh-43457(2).)

   * ‘wm_attributes()’ can now return attributes as a *note dict: 237,
     by using the new optional keyword-only parameter
     'return_python_dict'.  (Contributed by Serhiy Storchaka in
     gh-43457(3).)

   * ‘Text.count()’ can now return a simple *note int: 238. when the new
     optional keyword-only parameter 'return_ints' is used.  Otherwise,
     the single count is returned as a 1-tuple or ‘None’.  (Contributed
     by Serhiy Storchaka in gh-97928(4).)

   * Support the "vsapi" element type in the *note element_create():
     239. method of *note tkinter.ttk.Style: 23a.  (Contributed by
     Serhiy Storchaka in gh-68166(5).)

   * Add the ‘after_info()’ method for Tkinter widgets.  (Contributed by
     Cheryl Sabella in gh-77020(6).)

   * Add a new ‘copy_replace()’ method to ‘PhotoImage’ to copy a region
     from one image to another, possibly with pixel zooming,
     subsampling, or both.  (Contributed by Serhiy Storchaka in
     gh-118225(7).)

   * Add 'from_coords' parameter to the ‘PhotoImage’ methods ‘copy()’,
     ‘zoom()’ and ‘subsample()’.  Add 'zoom' and 'subsample' parameters
     to the ‘PhotoImage’ method ‘copy()’.  (Contributed by Serhiy
     Storchaka in gh-118225(8).)

   * Add the ‘PhotoImage’ methods ‘read()’ to read an image from a file
     and ‘data()’ to get the image data.  Add 'background' and
     'grayscale' parameters to the ‘write()’ method.  (Contributed by
     Serhiy Storchaka in gh-118271(9).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/72684

   (2) https://github.com/python/cpython/issues/43457

   (3) https://github.com/python/cpython/issues/43457

   (4) https://github.com/python/cpython/issues/97928

   (5) https://github.com/python/cpython/issues/68166

   (6) https://github.com/python/cpython/issues/77020

   (7) https://github.com/python/cpython/issues/118225

   (8) https://github.com/python/cpython/issues/118225

   (9) https://github.com/python/cpython/issues/118271


File: python.info,  Node: traceback,  Next: types,  Prev: tkinter,  Up: Improved Modules

1.1.5.43 traceback
..................

   * Add the *note exc_type_str: 23c. attribute to *note
     TracebackException: 23d, which holds a string display of the
     'exc_type'.  Deprecate the *note exc_type: 23e. attribute, which
     holds the type object itself.  Add parameter 'save_exc_type'
     (default ‘True’) to indicate whether ‘exc_type’ should be saved.
     (Contributed by Irit Katriel in gh-112332(1).)

   * Add a new 'show_group' keyword-only parameter to *note
     TracebackException.format_exception_only(): 23f. to (recursively)
     format the nested exceptions of a *note BaseExceptionGroup: 240.
     instance.  (Contributed by Irit Katriel in gh-105292(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/112332

   (2) https://github.com/python/cpython/issues/105292


File: python.info,  Node: types,  Next: typing,  Prev: traceback,  Up: Improved Modules

1.1.5.44 types
..............

   * *note SimpleNamespace: 1b3. can now take a single positional
     argument to initialise the namespace's arguments.  This argument
     must either be a mapping or an iterable of key-value pairs.
     (Contributed by Serhiy Storchaka in gh-108191(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/108191


File: python.info,  Node: typing,  Next: unicodedata,  Prev: types,  Up: Improved Modules

1.1.5.45 typing
...............

   * PEP 705(1): Add *note ReadOnly: 147, a special typing construct to
     mark a *note TypedDict: 148. item as read-only for type checkers.

   * PEP 742(2): Add *note TypeIs: 149, a typing construct that can be
     used to instruct a type checker how to narrow a type.

   * Add *note NoDefault: 243, a sentinel object used to represent the
     defaults of some parameters in the *note typing: ed. module.
     (Contributed by Jelle Zijlstra in gh-116126(3).)

   * Add *note get_protocol_members(): 244. to return the set of members
     defining a *note typing.Protocol: 245.  (Contributed by Jelle
     Zijlstra in gh-104873(4).)

   * Add *note is_protocol(): 246. to check whether a class is a *note
     Protocol: 245.  (Contributed by Jelle Zijlstra in gh-104873(5).)

   * *note ClassVar: 247. can now be nested in *note Final: 248, and
     vice versa.  (Contributed by Mehdi Drissi in gh-89547(6).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0705/

   (2) https://peps.python.org/pep-0742/

   (3) https://github.com/python/cpython/issues/116126

   (4) https://github.com/python/cpython/issues/104873

   (5) https://github.com/python/cpython/issues/104873

   (6) https://github.com/python/cpython/issues/89547


File: python.info,  Node: unicodedata,  Next: venv,  Prev: typing,  Up: Improved Modules

1.1.5.46 unicodedata
....................

   * Update the Unicode database to version 15.1.0(1).  (Contributed by
     James Gerity in gh-109559(2).)

   ---------- Footnotes ----------

   (1) https://www.unicode.org/versions/Unicode15.1.0/

   (2) https://github.com/python/cpython/issues/109559


File: python.info,  Node: venv,  Next: warnings,  Prev: unicodedata,  Up: Improved Modules

1.1.5.47 venv
.............

   * Add support for creating source control management (SCM) ignore
     files in a virtual environment's directory.  By default, Git is
     supported.  This is implemented as opt-in via the API, which can be
     extended to support other SCMs (*note EnvBuilder: 24b. and *note
     create(): 24c.), and opt-out via the CLI, using
     ‘--without-scm-ignore-files’.  (Contributed by Brett Cannon in
     gh-108125(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/108125


File: python.info,  Node: warnings,  Next: xml,  Prev: venv,  Up: Improved Modules

1.1.5.48 warnings
.................

   * PEP 702(1): The new *note warnings.deprecated(): 146. decorator
     provides a way to communicate deprecations to a *note static type
     checker: 24e. and to warn on usage of deprecated classes and
     functions.  A *note DeprecationWarning: 18a. may also be emitted
     when a decorated function or class is used at runtime.
     (Contributed by Jelle Zijlstra in gh-104003(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0702/

   (2) https://github.com/python/cpython/issues/104003


File: python.info,  Node: xml,  Next: zipimport,  Prev: warnings,  Up: Improved Modules

1.1.5.49 xml
............

   * Allow controlling Expat >=2.6.0 reparse deferral ( CVE
     2023-52425(1)) by adding five new methods:

        * *note xml.etree.ElementTree.XMLParser.flush(): 250.

        * *note xml.etree.ElementTree.XMLPullParser.flush(): 251.

        * *note xml.parsers.expat.xmlparser.GetReparseDeferralEnabled():
          252.

        * *note xml.parsers.expat.xmlparser.SetReparseDeferralEnabled():
          253.

        * ‘xml.sax.expatreader.ExpatParser.flush()’

     (Contributed by Sebastian Pipping in gh-115623(2).)

   * Add the ‘close()’ method for the iterator returned by *note
     iterparse(): 254. for explicit cleanup.  (Contributed by Serhiy
     Storchaka in gh-69893(3).)

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2023-52425

   (2) https://github.com/python/cpython/issues/115623

   (3) https://github.com/python/cpython/issues/69893


File: python.info,  Node: zipimport,  Prev: xml,  Up: Improved Modules

1.1.5.50 zipimport
..................

   * Add support for ZIP64(1) format files.  Everybody loves huge data,
     right?  (Contributed by Tim Hatch in gh-94146(2).)

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Zip_(file_format)#ZIP64

   (2) https://github.com/python/cpython/issues/94146


File: python.info,  Node: Optimizations,  Next: Removed Modules And APIs,  Prev: Improved Modules,  Up: What's New In Python 3 13

1.1.6 Optimizations
-------------------

   * Several standard library modules have had their import times
     significantly improved.  For example, the import time of the *note
     typing: ed. module has been reduced by around a third by removing
     dependencies on *note re: a7. and *note contextlib: 1c.  Other
     modules to enjoy import-time speedups include *note email.utils:
     47, *note enum: 4c, *note functools: 55, *note importlib.metadata:
     6e, and *note threading: d6.  (Contributed by Alex Waygood,
     Shantanu Jain, Adam Turner, Daniel Hollas, and others in
     gh-109653(1).)

   * *note textwrap.indent(): 257. is now around 30% faster than before
     for large input.  (Contributed by Inada Naoki in gh-107369(2).)

   * The *note subprocess: c1. module now uses the *note posix_spawn():
     201. function in more situations, including when 'close_fds' is
     ‘True’ (the default) on many modern platforms.  This should provide
     a notable performance increase when launching processes on FreeBSD
     and Solaris.  See the *note subprocess: 22e. section above for
     details.  (Contributed by Jakub Kulik in gh-113117(3).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109653

   (2) https://github.com/python/cpython/issues/107369

   (3) https://github.com/python/cpython/issues/113117


File: python.info,  Node: Removed Modules And APIs,  Next: New Deprecations,  Prev: Optimizations,  Up: What's New In Python 3 13

1.1.7 Removed Modules And APIs
------------------------------

* Menu:

* PEP 594; Remove "dead batteries" from the standard library: PEP 594 Remove "dead batteries" from the standard library.
* 2to3::
* builtins::
* configparser: configparser<2>.
* importlib.metadata: importlib metadata.
* locale::
* opcode::
* pathlib: pathlib<2>.
* re: re<2>.
* tkinter.tix: tkinter tix.
* turtle::
* typing: typing<2>.
* unittest::
* urllib::
* webbrowser::


File: python.info,  Node: PEP 594 Remove "dead batteries" from the standard library,  Next: 2to3,  Up: Removed Modules And APIs

1.1.7.1 PEP 594: Remove "dead batteries" from the standard library
..................................................................

PEP 594(1) proposed removing 19 modules from the standard library,
colloquially referred to as 'dead batteries' due to their historic,
obsolete, or insecure status.  All of the following modules were
deprecated in Python 3.11, and are now removed:

   * ‘aifc’

   * ‘audioop’

   * ‘chunk’

   * ‘cgi’ and ‘cgitb’

        * ‘cgi.FieldStorage’ can typically be replaced with *note
          urllib.parse.parse_qsl(): 25a. for ‘GET’ and ‘HEAD’ requests,
          and the *note email.message: 3b. module or the multipart(2)
          library for ‘POST’ and ‘PUT’ requests.

        * ‘cgi.parse()’ can be replaced by calling *note
          urllib.parse.parse_qs(): 25b. directly on the desired query
          string, unless the input is ‘multipart/form-data’, which
          should be replaced as described below for
          ‘cgi.parse_multipart()’.

        * ‘cgi.parse_header()’ can be replaced with the functionality in
          the *note email: 32. package, which implements the same MIME
          RFCs.  For example, with *note email.message.EmailMessage:
          25c.:

               from email.message import EmailMessage

               msg = EmailMessage()
               msg['content-type'] = 'application/json; charset="utf8"'
               main, params = msg.get_content_type(), msg['content-type'].params

        * ‘cgi.parse_multipart()’ can be replaced with the functionality
          in the *note email: 32. package, which implements the same
          MIME RFCs, or with the multipart(3) library.  For example, the
          *note email.message.EmailMessage: 25c. and *note
          email.message.Message: 25d. classes.

   * ‘crypt’ and the private ‘_crypt’ extension.  The *note hashlib: 5e.
     module may be an appropriate replacement when simply hashing a
     value is required.  Otherwise, various third-party libraries on
     PyPI are available:

        * bcrypt(4): Modern password hashing for your software and your
          servers.

        * passlib(5): Comprehensive password hashing framework
          supporting over 30 schemes.

        * argon2-cffi(6): The secure Argon2 password hashing algorithm.

        * legacycrypt(7): *note ctypes: 22. wrapper to the POSIX crypt
          library call and associated functionality.

        * crypt_r(8): Fork of the ‘crypt’ module, wrapper to the
          ‘crypt_r(3)(9)’ library call and associated functionality.

   * ‘imghdr’: The filetype(10), puremagic(11), or python-magic(12)
     libraries should be used as replacements.  For example, the
     ‘puremagic.what()’ function can be used to replace the
     ‘imghdr.what()’ function for all file formats that were supported
     by ‘imghdr’.

   * ‘mailcap’: Use the *note mimetypes: 82. module instead.

   * ‘msilib’

   * ‘nis’

   * ‘nntplib’: Use the pynntp(13) library from PyPI instead.

   * ‘ossaudiodev’: For audio playback, use the pygame(14) library from
     PyPI instead.

   * ‘pipes’: Use the *note subprocess: c1. module instead.  Use *note
     shlex.quote(): 25e. to replace the undocumented ‘pipes.quote’
     function.

   * ‘sndhdr’: The filetype(15), puremagic(16), or python-magic(17)
     libraries should be used as replacements.

   * ‘spwd’: Use the python-pam(18) library from PyPI instead.

   * ‘sunau’

   * ‘telnetlib’, Use the telnetlib3(19) or Exscript(20) libraries from
     PyPI instead.

   * ‘uu’: Use the *note base64: a. module instead, as a modern
     alternative.

   * ‘xdrlib’

(Contributed by Victor Stinner and Zachary Ware in gh-104773(21) and
gh-104780(22).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0594/

   (2) https://pypi.org/project/multipart/

   (3) https://pypi.org/project/multipart/

   (4) https://pypi.org/project/bcrypt/

   (5) https://pypi.org/project/passlib/

   (6) https://pypi.org/project/argon2-cffi/

   (7) https://pypi.org/project/legacycrypt/

   (8) https://pypi.org/project/crypt_r/

   (9) https://manpages.debian.org/crypt_r(3)

   (10) https://pypi.org/project/filetype/

   (11) https://pypi.org/project/puremagic/

   (12) https://pypi.org/project/python-magic/

   (13) https://pypi.org/project/pynntp/

   (14) https://pypi.org/project/pygame/

   (15) https://pypi.org/project/filetype/

   (16) https://pypi.org/project/puremagic/

   (17) https://pypi.org/project/python-magic/

   (18) https://pypi.org/project/python-pam/

   (19) https://pypi.org/project/telnetlib3/

   (20) https://pypi.org/project/Exscript/

   (21) https://github.com/python/cpython/issues/104773

   (22) https://github.com/python/cpython/issues/104780


File: python.info,  Node: 2to3,  Next: builtins,  Prev: PEP 594 Remove "dead batteries" from the standard library,  Up: Removed Modules And APIs

1.1.7.2 2to3
............

   * Remove the ‘2to3’ program and the ‘lib2to3’ module, previously
     deprecated in Python 3.11.  (Contributed by Victor Stinner in
     gh-104780(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104780


File: python.info,  Node: builtins,  Next: configparser<2>,  Prev: 2to3,  Up: Removed Modules And APIs

1.1.7.3 builtins
................

   * Remove support for chained *note classmethod: 14c. descriptors
     (introduced in gh-63272(1)).  These can no longer be used to wrap
     other descriptors, such as *note property: 179.  The core design of
     this feature was flawed and led to several problems.  To
     "pass-through" a *note classmethod: 14c, consider using the
     ‘__wrapped__’ attribute that was added in Python 3.10.
     (Contributed by Raymond Hettinger in gh-89519(2).)

   * Raise a *note RuntimeError: 17a. when calling *note frame.clear():
     261. on a suspended frame (as has always been the case for an
     executing frame).  (Contributed by Irit Katriel in gh-79932(3).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/63272

   (2) https://github.com/python/cpython/issues/89519

   (3) https://github.com/python/cpython/issues/79932


File: python.info,  Node: configparser<2>,  Next: importlib metadata,  Prev: builtins,  Up: Removed Modules And APIs

1.1.7.4 configparser
....................

   * Remove the undocumented ‘LegacyInterpolation’ class, deprecated in
     the docstring since Python 3.2, and at runtime since Python 3.11.
     (Contributed by Hugo van Kemenade in gh-104886(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104886


File: python.info,  Node: importlib metadata,  Next: locale,  Prev: configparser<2>,  Up: Removed Modules And APIs

1.1.7.5 importlib.metadata
..........................

   * Remove deprecated subscript (*note __getitem__(): 264.) access for
     *note EntryPoint: 265. objects.  (Contributed by Jason R. Coombs in
     gh-113175(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/113175


File: python.info,  Node: locale,  Next: opcode,  Prev: importlib metadata,  Up: Removed Modules And APIs

1.1.7.6 locale
..............

   * Remove the ‘locale.resetlocale()’ function, deprecated in Python
     3.11.  Use ‘locale.setlocale(locale.LC_ALL, "")’ instead.
     (Contributed by Victor Stinner in gh-104783(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104783


File: python.info,  Node: opcode,  Next: pathlib<2>,  Prev: locale,  Up: Removed Modules And APIs

1.1.7.7 opcode
..............

   * Move ‘opcode.ENABLE_SPECIALIZATION’ to
     ‘_opcode.ENABLE_SPECIALIZATION’.  This field was added in 3.12, it
     was never documented, and is not intended for external use.
     (Contributed by Irit Katriel in gh-105481(1).)

   * Remove ‘opcode.is_pseudo()’, ‘opcode.MIN_PSEUDO_OPCODE’, and
     ‘opcode.MAX_PSEUDO_OPCODE’, which were added in Python 3.12, but
     were neither documented nor exposed through *note dis: 30, and were
     not intended to be used externally.  (Contributed by Irit Katriel
     in gh-105481(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/105481

   (2) https://github.com/python/cpython/issues/105481


File: python.info,  Node: pathlib<2>,  Next: re<2>,  Prev: opcode,  Up: Removed Modules And APIs

1.1.7.8 pathlib
...............

   * Remove the ability to use *note Path: 20a. objects as context
     managers.  This functionality was deprecated and has had no effect
     since Python 3.9.  (Contributed by Barney Gale in gh-83863(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/83863


File: python.info,  Node: re<2>,  Next: tkinter tix,  Prev: pathlib<2>,  Up: Removed Modules And APIs

1.1.7.9 re
..........

   * Remove the undocumented, deprecated, and broken ‘re.template()’
     function and ‘re.TEMPLATE’ / ‘re.T’ flag.  (Contributed by Serhiy
     Storchaka and Nikita Sobolev in gh-105687(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/105687


File: python.info,  Node: tkinter tix,  Next: turtle,  Prev: re<2>,  Up: Removed Modules And APIs

1.1.7.10 tkinter.tix
....................

   * Remove the ‘tkinter.tix’ module, deprecated in Python 3.6.  The
     third-party Tix library which the module wrapped is unmaintained.
     (Contributed by Zachary Ware in gh-75552(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/75552


File: python.info,  Node: turtle,  Next: typing<2>,  Prev: tkinter tix,  Up: Removed Modules And APIs

1.1.7.11 turtle
...............

   * Remove the ‘RawTurtle.settiltangle()’ method, deprecated in the
     documentation since Python 3.1 and at runtime since Python 3.11.
     (Contributed by Hugo van Kemenade in gh-104876(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104876


File: python.info,  Node: typing<2>,  Next: unittest,  Prev: turtle,  Up: Removed Modules And APIs

1.1.7.12 typing
...............

   * Remove the ‘typing.io’ and ‘typing.re’ namespaces, deprecated since
     Python 3.8.  The items in those namespaces can be imported directly
     from the *note typing: ed. module.  (Contributed by Sebastian
     Rittau in gh-92871(1).)

   * Remove the keyword-argument method of creating *note TypedDict:
     148. types, deprecated in Python 3.11.  (Contributed by Tomas Roun
     in gh-104786(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92871

   (2) https://github.com/python/cpython/issues/104786


File: python.info,  Node: unittest,  Next: urllib,  Prev: typing<2>,  Up: Removed Modules And APIs

1.1.7.13 unittest
.................

   * Remove the following *note unittest: ef. functions, deprecated in
     Python 3.11:

        * ‘unittest.findTestCases()’

        * ‘unittest.makeSuite()’

        * ‘unittest.getTestCaseNames()’

     Use *note TestLoader: 26e. methods instead:

        * *note loadTestsFromModule(): 26f.

        * *note loadTestsFromTestCase(): 270.

        * *note getTestCaseNames(): 271.

     (Contributed by Hugo van Kemenade in gh-104835(1).)

   * Remove the untested and undocumented ‘TestProgram.usageExit()’
     method, deprecated in Python 3.11.  (Contributed by Hugo van
     Kemenade in gh-104992(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104835

   (2) https://github.com/python/cpython/issues/104992


File: python.info,  Node: urllib,  Next: webbrowser,  Prev: unittest,  Up: Removed Modules And APIs

1.1.7.14 urllib
...............

   * Remove the 'cafile', 'capath', and 'cadefault' parameters of the
     *note urllib.request.urlopen(): 273. function, deprecated in Python
     3.6.  Use the 'context' parameter instead with an *note SSLContext:
     274. instance.  The *note ssl.SSLContext.load_cert_chain(): 275.
     function can be used to load specific certificates, or let *note
     ssl.create_default_context(): 13b. select the operating system's
     trusted certificate authority (CA) certificates.  (Contributed by
     Victor Stinner in gh-105382(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/105382


File: python.info,  Node: webbrowser,  Prev: urllib,  Up: Removed Modules And APIs

1.1.7.15 webbrowser
...................

   * Remove the untested and undocumented ‘MacOSX’ class, deprecated in
     Python 3.11.  Use the ‘MacOSXOSAScript’ class (introduced in Python
     3.2) instead.  (Contributed by Hugo van Kemenade in gh-104804(1).)

   * Remove the deprecated ‘MacOSXOSAScript._name’ attribute.  Use the
     *note MacOSXOSAScript.name: 277. attribute instead.  (Contributed
     by Nikita Sobolev in gh-105546(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104804

   (2) https://github.com/python/cpython/issues/105546


File: python.info,  Node: New Deprecations,  Next: CPython Bytecode Changes,  Prev: Removed Modules And APIs,  Up: What's New In Python 3 13

1.1.8 New Deprecations
----------------------

   * *note User-defined functions: 279.:

        * Deprecate assignment to a function's *note __code__: 27a.
          attribute, where the new code object's type does not match the
          function's type.  The different types are: plain function,
          generator, async generator, and coroutine.  (Contributed by
          Irit Katriel in gh-81137(1).)

   * *note array: 6.:

        * Deprecate the ‘'u'’ format code (‘wchar_t’) at runtime.  This
          format code has been deprecated in documentation since Python
          3.3, and will be removed in Python 3.16.  Use the ‘'w'’ format
          code (*note Py_UCS4: 27b.) for Unicode characters instead.
          (Contributed by Hugo van Kemenade in gh-80480(2).)

   * *note ctypes: 22.:

        * Deprecate the undocumented ‘SetPointerType()’ function, to be
          removed in Python 3.15.  (Contributed by Victor Stinner in
          gh-105733(3).)

        * *note Soft-deprecate: 1ea. the *note ARRAY(): 27c. function in
          favour of ‘type * length’ multiplication.  (Contributed by
          Victor Stinner in gh-105733(4).)

   * *note decimal: 2e.:

        * Deprecate the non-standard and undocumented *note Decimal:
          27d. format specifier ‘'N'’, which is only supported in the
          ‘decimal’ module's C implementation.  (Contributed by Serhiy
          Storchaka in gh-89902(5).)

   * *note dis: 30.:

        * Deprecate the ‘HAVE_ARGUMENT’ separator.  Check membership in
          *note hasarg: 27e. instead.  (Contributed by Irit Katriel in
          gh-109319(6).)

   * *note getopt: 57. and *note optparse: 90.:

        * Both modules are now *note soft deprecated: 1ea, with *note
          argparse: 5. preferred for new projects.  This is a new
          soft-deprecation for the ‘getopt’ module, whereas the
          ‘optparse’ module was already 'de facto' soft deprecated.
          (Contributed by Victor Stinner in gh-106535(7).)

   * *note gettext: 59.:

        * Deprecate non-integer numbers as arguments to functions and
          methods that consider plural forms in the ‘gettext’ module,
          even if no translation was found.  (Contributed by Serhiy
          Storchaka in gh-88434(8).)

   * *note glob: 5a.:

        * Deprecate the undocumented ‘glob0()’ and ‘glob1()’ functions.
          Use *note glob(): 27f. and pass a *note path-like object: 280.
          specifying the root directory to the 'root_dir' parameter
          instead.  (Contributed by Barney Gale in gh-117337(9).)

   * *note http.server: 68.:

        * Deprecate *note CGIHTTPRequestHandler: 281, to be removed in
          Python 3.15.  Process-based CGI HTTP servers have been out of
          favor for a very long time.  This code was outdated,
          unmaintained, and rarely used.  It has a high potential for
          both security and functionality bugs.  (Contributed by Gregory
          P. Smith in gh-109096(10).)

        * Deprecate the ‘--cgi’ flag to the ‘python -m http.server’
          command-line interface, to be removed in Python 3.15.
          (Contributed by Gregory P. Smith in gh-109096(11).)

   * *note mimetypes: 82.:

        * *note Soft-deprecate: 1ea. file path arguments to *note
          guess_type(): 1e9, use *note guess_file_type(): 1e8. instead.
          (Contributed by Serhiy Storchaka in gh-66543(12).)

   * *note re: a7.:

        * Deprecate passing the optional 'maxsplit', 'count', or 'flags'
          arguments as positional arguments to the module-level *note
          split(): 282, *note sub(): 283, and *note subn(): 284.
          functions.  These parameters will become *note keyword-only:
          285. in a future version of Python.  (Contributed by Serhiy
          Storchaka in gh-56166(13).)

   * *note pathlib: 93.:

        * Deprecate *note PurePath.is_reserved(): 286, to be removed in
          Python 3.15.  Use *note os.path.isreserved(): 204. to detect
          reserved paths on Windows.  (Contributed by Barney Gale in
          gh-88569(14).)

   * *note platform: 98.:

        * Deprecate *note java_ver(): 287, to be removed in Python 3.15.
          This function is only useful for Jython support, has a
          confusing API, and is largely untested.  (Contributed by
          Nikita Sobolev in gh-116349(15).)

   * *note pydoc: a3.:

        * Deprecate the undocumented ‘ispackage()’ function.
          (Contributed by Zackery Spytz in gh-64020(16).)

   * *note sqlite3: ba.:

        * Deprecate passing more than one positional argument to the
          *note connect(): 288. function and the *note Connection: 226.
          constructor.  The remaining parameters will become
          keyword-only in Python 3.15.  (Contributed by Erlend E.
          Aasland in gh-107948(17).)

        * Deprecate passing name, number of arguments, and the callable
          as keyword arguments for *note Connection.create_function():
          289. and *note Connection.create_aggregate(): 28a. These
          parameters will become positional-only in Python 3.15.
          (Contributed by Erlend E. Aasland in gh-108278(18).)

        * Deprecate passing the callback callable by keyword for the
          *note set_authorizer(): 28b, *note set_progress_handler():
          28c, and *note set_trace_callback(): 28d. *note Connection:
          226. methods.  The callback callables will become
          positional-only in Python 3.15.  (Contributed by Erlend E.
          Aasland in gh-108278(19).)

   * *note sys: c3.:

        * Deprecate the *note _enablelegacywindowsfsencoding(): 28e.
          function, to be removed in Python 3.16.  Use the *note
          PYTHONLEGACYWINDOWSFSENCODING: 28f. environment variable
          instead.  (Contributed by Inada Naoki in gh-73427(20).)

   * *note tarfile: c8.:

        * Deprecate the undocumented and unused ‘TarFile.tarfile’
          attribute, to be removed in Python 3.16.  (Contributed in
          gh-115256(21).)

   * *note traceback: e7.:

        * Deprecate the *note TracebackException.exc_type: 23e.
          attribute.  Use *note TracebackException.exc_type_str: 23c.
          instead.  (Contributed by Irit Katriel in gh-112332(22).)

   * *note typing: ed.:

        * Deprecate the undocumented keyword argument syntax for
          creating *note NamedTuple: 290. classes (e.g.  ‘Point =
          NamedTuple("Point", x=int, y=int)’), to be removed in Python
          3.15.  Use the class-based syntax or the functional syntax
          instead.  (Contributed by Alex Waygood in gh-105566(23).)

        * Deprecate omitting the 'fields' parameter when creating a
          *note NamedTuple: 290. or *note typing.TypedDict: 148. class,
          and deprecate passing ‘None’ to the 'fields' parameter of both
          types.  Python 3.15 will require a valid sequence for the
          'fields' parameter.  To create a NamedTuple class with zero
          fields, use ‘class NT(NamedTuple): pass’ or ‘NT =
          NamedTuple("NT", ())’.  To create a TypedDict class with zero
          fields, use ‘class TD(TypedDict): pass’ or ‘TD =
          TypedDict("TD", {})’.  (Contributed by Alex Waygood in
          gh-105566(24) and gh-105570(25).)

        * Deprecate the *note typing.no_type_check_decorator(): 291.
          decorator function, to be removed in in Python 3.15.  After
          eight years in the *note typing: ed. module, it has yet to be
          supported by any major type checker.  (Contributed by Alex
          Waygood in gh-106309(26).)

        * Deprecate *note typing.AnyStr: 292.  In Python 3.16, it will
          be removed from ‘typing.__all__’, and a *note
          DeprecationWarning: 18a. will be emitted at runtime when it is
          imported or accessed.  It will be removed entirely in Python
          3.18.  Use the new *note type parameter syntax: 293. instead.
          (Contributed by Michael The in gh-107116(27).)

   * *note wave: fb.:

        * Deprecate the *note getmark(): 294, ‘setmark()’, and *note
          getmarkers(): 295. methods of the *note Wave_read: 296. and
          *note Wave_write: 297. classes, to be removed in Python 3.15.
          (Contributed by Victor Stinner in gh-105096(28).)

* Menu:

* Pending Removal in Python 3.14: Pending Removal in Python 3 14.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15.
* Pending removal in Python 3.16: Pending removal in Python 3 16.
* Pending Removal in Future Versions::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/81137

   (2) https://github.com/python/cpython/issues/80480

   (3) https://github.com/python/cpython/issues/105733

   (4) https://github.com/python/cpython/issues/105733

   (5) https://github.com/python/cpython/issues/89902

   (6) https://github.com/python/cpython/issues/109319

   (7) https://github.com/python/cpython/issues/106535

   (8) https://github.com/python/cpython/issues/88434

   (9) https://github.com/python/cpython/issues/117337

   (10) https://github.com/python/cpython/issues/109096

   (11) https://github.com/python/cpython/issues/109096

   (12) https://github.com/python/cpython/issues/66543

   (13) https://github.com/python/cpython/issues/56166

   (14) https://github.com/python/cpython/issues/88569

   (15) https://github.com/python/cpython/issues/116349

   (16) https://github.com/python/cpython/issues/64020

   (17) https://github.com/python/cpython/issues/107948

   (18) https://github.com/python/cpython/issues/108278

   (19) https://github.com/python/cpython/issues/108278

   (20) https://github.com/python/cpython/issues/73427

   (21) https://github.com/python/cpython/issues/115256

   (22) https://github.com/python/cpython/issues/112332

   (23) https://github.com/python/cpython/issues/105566

   (24) https://github.com/python/cpython/issues/105566

   (25) https://github.com/python/cpython/issues/105570

   (26) https://github.com/python/cpython/issues/106309

   (27) https://github.com/python/cpython/issues/107116

   (28) https://github.com/python/cpython/issues/105096


File: python.info,  Node: Pending Removal in Python 3 14,  Next: Pending Removal in Python 3 15,  Up: New Deprecations

1.1.8.1 Pending Removal in Python 3.14
......................................

   * *note argparse: 5.: The 'type', 'choices', and 'metavar' parameters
     of ‘argparse.BooleanOptionalAction’ are deprecated and will be
     removed in 3.14.  (Contributed by Nikita Sobolev in gh-92248(1).)

   * *note ast: 7.: The following features have been deprecated in
     documentation since Python 3.8, now cause a *note
     DeprecationWarning: 18a. to be emitted at runtime when they are
     accessed or used, and will be removed in Python 3.14:

        * ‘ast.Num’

        * ‘ast.Str’

        * ‘ast.Bytes’

        * ‘ast.NameConstant’

        * ‘ast.Ellipsis’

     Use *note ast.Constant: 299. instead.  (Contributed by Serhiy
     Storchaka in gh-90953(2).)

   * *note asyncio: 8.:

        * The child watcher classes *note MultiLoopChildWatcher: 29a,
          *note FastChildWatcher: 29b, *note AbstractChildWatcher: 29c.
          and *note SafeChildWatcher: 29d. are deprecated and will be
          removed in Python 3.14.  (Contributed by Kumar Aditya in
          gh-94597(3).)

        * *note asyncio.set_child_watcher(): 29e, *note
          asyncio.get_child_watcher(): 29f, *note
          asyncio.AbstractEventLoopPolicy.set_child_watcher(): 2a0. and
          *note asyncio.AbstractEventLoopPolicy.get_child_watcher():
          2a1. are deprecated and will be removed in Python 3.14.
          (Contributed by Kumar Aditya in gh-94597(4).)

        * The *note get_event_loop(): 2a2. method of the default event
          loop policy now emits a *note DeprecationWarning: 18a. 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(5).)

   * *note collections.abc: 17.: Deprecated *note ByteString: 2a3.
     Prefer ‘Sequence’ or *note Buffer: 2a4.  For use in typing, prefer
     a union, like ‘bytes | bytearray’, or *note collections.abc.Buffer:
     2a4.  (Contributed by Shantanu Jain in gh-91896(6).)

   * *note email: 32.: Deprecated the 'isdst' parameter in *note
     email.utils.localtime(): 2a5.  (Contributed by Alan Williams in
     gh-72346(7).)

   * *note importlib.abc: 6c. deprecated classes:

        * ‘importlib.abc.ResourceReader’

        * ‘importlib.abc.Traversable’

        * ‘importlib.abc.TraversableResources’

     Use *note importlib.resources.abc: 70. classes instead:

        * *note importlib.resources.abc.Traversable: 1d4.

        * *note importlib.resources.abc.TraversableResources: 2a6.

     (Contributed by Jason R. Coombs and Hugo van Kemenade in
     gh-93963(8).)

   * *note itertools: 75. 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(9).)

   * *note multiprocessing: 86.: The default start method will change to
     a safer one on Linux, BSDs, and other non-macOS POSIX platforms
     where ‘'fork'’ is currently the default (gh-84559(10)).  Adding a
     runtime warning about this was deemed too disruptive as the
     majority of code is not expected to care.  Use the *note
     get_context(): 2a7. or *note set_start_method(): 2a8. APIs to
     explicitly specify when your code 'requires' ‘'fork'’.  See *note
     コンテキストと開始方式: 2a9.

   * *note pathlib: 93.: *note is_relative_to(): 2aa. and *note
     relative_to(): 2ab.: passing additional arguments is deprecated.

   * *note pkgutil: 97.: *note find_loader(): 2ac. and *note
     get_loader(): 2ad. now raise *note DeprecationWarning: 18a.; use
     *note importlib.util.find_spec(): 2ae. instead.  (Contributed by
     Nikita Sobolev in gh-97850(11).)

   * *note pty: 9f.:

        * ‘master_open()’: use *note pty.openpty(): 2af.

        * ‘slave_open()’: use *note pty.openpty(): 2af.

   * *note sqlite3: ba.:

        * *note version: 2b0. and *note version_info: 2b1.

        * *note execute(): 2b2. and *note executemany(): 2b3. if *note
          named placeholders: 2b4. are used and 'parameters' is a
          sequence instead of a *note dict: 237.

   * *note typing: ed.: *note ByteString: 2b5, deprecated since Python
     3.9, now causes a *note DeprecationWarning: 18a. to be emitted when
     it is used.

   * *note urllib: f1.: ‘urllib.parse.Quoter’ is deprecated: it was not
     intended to be a public API. (Contributed by Gregory P. Smith in
     gh-88168(12).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92248

   (2) https://github.com/python/cpython/issues/90953

   (3) https://github.com/python/cpython/issues/94597

   (4) https://github.com/python/cpython/issues/94597

   (5) https://github.com/python/cpython/issues/100160

   (6) https://github.com/python/cpython/issues/91896

   (7) https://github.com/python/cpython/issues/72346

   (8) https://github.com/python/cpython/issues/93963

   (9) https://github.com/python/cpython/issues/101588

   (10) https://github.com/python/cpython/issues/84559

   (11) https://github.com/python/cpython/issues/97850

   (12) https://github.com/python/cpython/issues/88168


File: python.info,  Node: Pending Removal in Python 3 15,  Next: Pending removal in Python 3 16,  Prev: Pending Removal in Python 3 14,  Up: New Deprecations

1.1.8.2 Pending Removal in Python 3.15
......................................

   * The import system:

        * Setting *note __cached__: 2b7. on a module while failing to
          set *note __spec__.cached: 2b8. 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(1))

        * Setting *note __package__: 2b9. on a module while failing to
          set *note __spec__.parent: 2ba. is deprecated.  In Python
          3.15, ‘__package__’ will cease to be set or take into
          consideration by the import system or standard library.
          (gh-97879(2))

   * *note ctypes: 22.:

        * The undocumented ‘ctypes.SetPointerType()’ function has been
          deprecated since Python 3.13.

   * *note http.server: 68.:

        * The obsolete and rarely used *note CGIHTTPRequestHandler: 281.
          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.

        * The ‘--cgi’ flag to the ‘python -m http.server’ command-line
          interface has been deprecated since Python 3.13.

   * *note locale: 7a.:

        * The *note getdefaultlocale(): 2bb. function has been
          deprecated since Python 3.11.  Its removal was originally
          planned for Python 3.13 (gh-90817(3)), but has been postponed
          to Python 3.15.  Use *note getlocale(): 2bc, *note
          setlocale(): 2bd, and *note getencoding(): 2be. instead.
          (Contributed by Hugo van Kemenade in gh-111187(4).)

   * *note pathlib: 93.:

        * *note PurePath.is_reserved(): 286. has been deprecated since
          Python 3.13.  Use *note os.path.isreserved(): 204. to detect
          reserved paths on Windows.

   * *note platform: 98.:

        * *note java_ver(): 287. has been deprecated since Python 3.13.
          This function is only useful for Jython support, has a
          confusing API, and is largely untested.

   * *note threading: d6.:

        * *note RLock(): 2bf. 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.

   * *note types: ec.:

        * *note types.CodeType: 2c0.: Accessing *note co_lnotab: 2c1.
          was deprecated in PEP 626(5) since 3.10 and was planned to be
          removed in 3.12, but it only got a proper *note
          DeprecationWarning: 18a. in 3.12.  May be removed in 3.15.
          (Contributed by Nikita Sobolev in gh-101866(6).)

   * *note typing: ed.:

        * The undocumented keyword argument syntax for creating *note
          NamedTuple: 290. classes (e.g.  ‘Point = NamedTuple("Point",
          x=int, y=int)’) has been deprecated since Python 3.13.  Use
          the class-based syntax or the functional syntax instead.

        * The *note typing.no_type_check_decorator(): 291. decorator
          function has been deprecated since Python 3.13.  After eight
          years in the *note typing: ed. module, it has yet to be
          supported by any major type checker.

   * *note wave: fb.:

        * The *note getmark(): 294, ‘setmark()’, and *note getmarkers():
          295. methods of the *note Wave_read: 296. and *note
          Wave_write: 297. classes have been deprecated since Python
          3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97879

   (2) https://github.com/python/cpython/issues/97879

   (3) https://github.com/python/cpython/issues/90817

   (4) https://github.com/python/cpython/issues/111187

   (5) https://peps.python.org/pep-0626/

   (6) https://github.com/python/cpython/issues/101866


File: python.info,  Node: Pending removal in Python 3 16,  Next: Pending Removal in Future Versions,  Prev: Pending Removal in Python 3 15,  Up: New Deprecations

1.1.8.3 Pending removal in Python 3.16
......................................

   * The import system:

        * Setting *note __loader__: 2c3. on a module while failing to
          set *note __spec__.loader: 2c4. is deprecated.  In Python
          3.16, ‘__loader__’ will cease to be set or taken into
          consideration by the import system or the standard library.

   * *note array: 6.:

        * The ‘'u'’ format code (‘wchar_t’) has been deprecated in
          documentation since Python 3.3 and at runtime since Python
          3.13.  Use the ‘'w'’ format code (*note Py_UCS4: 27b.) for
          Unicode characters instead.

   * *note asyncio: 8.:

        * ‘asyncio.iscoroutinefunction()’ is deprecated and will be
          removed in Python 3.16, use *note
          inspect.iscoroutinefunction(): 2c5. instead.  (Contributed by
          Jiahao Li and Kumar Aditya in gh-122875(1).)

   * *note builtins: e.:

        * Bitwise inversion on boolean types, ‘~True’ or ‘~False’ has
          been deprecated since Python 3.12, as it produces surprising
          and unintuitive results (‘-2’ and ‘-1’).  Use ‘not x’ instead
          for the logical negation of a Boolean.  In the rare case that
          you need the bitwise inversion of the underlying integer,
          convert to ‘int’ explicitly (‘~int(x)’).

   * *note shutil: b3.:

        * The ‘ExecError’ exception has been deprecated since Python
          3.14.  It has not been used by any function in ‘shutil’ since
          Python 3.4, and is now an alias of *note RuntimeError: 17a.

   * *note symtable: c2.:

        * The *note Class.get_methods: 2c6. method has been deprecated
          since Python 3.14.

   * *note sys: c3.:

        * The *note _enablelegacywindowsfsencoding(): 28e. function has
          been deprecated since Python 3.13.  Use the *note
          PYTHONLEGACYWINDOWSFSENCODING: 28f. environment variable
          instead.

   * *note tarfile: c8.:

        * The undocumented and unused ‘TarFile.tarfile’ attribute has
          been deprecated since Python 3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122875


File: python.info,  Node: Pending Removal in Future Versions,  Prev: Pending removal in Python 3 16,  Up: New Deprecations

1.1.8.4 Pending Removal in Future Versions
..........................................

The following APIs will be removed in the future, although there is
currently no date scheduled for their removal.

   * *note argparse: 5.: Nesting argument groups and nesting mutually
     exclusive groups are deprecated.

   * *note array: 6.'s ‘'u'’ format code (gh-57281(1))

   * *note builtins: e.:

        * ‘bool(NotImplemented)’.

        * Generators: ‘throw(type, exc, tb)’ and ‘athrow(type, exc, tb)’
          signature is deprecated: use ‘throw(exc)’ and ‘athrow(exc)’
          instead, the single argument signature.

        * Currently Python accepts numeric literals immediately followed
          by keywords, for example ‘0in x’, ‘1or x’, ‘0if 1else 2’.  It
          allows confusing and ambiguous expressions like ‘[0x1for x in
          y]’ (which can be interpreted as ‘[0x1 for x in y]’ or ‘[0x1f
          or x in y]’).  A syntax warning is raised if the numeric
          literal is immediately followed by one of keywords *note and:
          2c8, *note else: 171, *note for: 2c9, *note if: 2ca, *note in:
          2cb, *note is: 2cc. and *note or: 2cd.  In a future release it
          will be changed to a syntax error.  (gh-87999(2))

        * Support for ‘__index__()’ and ‘__int__()’ method returning
          non-int type: these methods will be required to return an
          instance of a strict subclass of *note int: 238.

        * Support for ‘__float__()’ method returning a strict subclass
          of *note float: 2ce.: these methods will be required to return
          an instance of *note float: 2ce.

        * Support for ‘__complex__()’ method returning a strict subclass
          of *note complex: 2cf.: these methods will be required to
          return an instance of *note complex: 2cf.

        * Delegation of ‘int()’ to ‘__trunc__()’ method.

        * Passing a complex number as the 'real' or 'imag' argument in
          the *note complex(): 2cf. constructor is now deprecated; it
          should only be passed as a single positional argument.
          (Contributed by Serhiy Storchaka in gh-109218(3).)

   * *note calendar: 10.: ‘calendar.January’ and ‘calendar.February’
     constants are deprecated and replaced by *note calendar.JANUARY:
     2d0. and *note calendar.FEBRUARY: 2d1.  (Contributed by Prince
     Roshan in gh-103636(4).)

   * *note codeobject.co_lnotab: 2c1.: use the *note
     codeobject.co_lines(): 2d2. method instead.

   * *note datetime: 28.:

        * *note utcnow(): 2d3.: use
          ‘datetime.datetime.now(tz=datetime.UTC)’.

        * *note utcfromtimestamp(): 2d4.: use
          ‘datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)’.

   * *note gettext: 59.: Plural value must be an integer.

   * *note importlib: 6b.:

        * ‘load_module()’ method: use ‘exec_module()’ instead.

        * *note cache_from_source(): 2d5. 'debug_override' parameter is
          deprecated: use the 'optimization' parameter instead.

   * *note importlib.metadata: 6e.:

        * ‘EntryPoints’ tuple interface.

        * Implicit ‘None’ on return values.

   * *note logging: 7b.: the ‘warn()’ method has been deprecated since
     Python 3.3, use *note warning(): 2d6. instead.

   * *note mailbox: 7f.: Use of StringIO input and text mode is
     deprecated, use BytesIO and binary mode instead.

   * *note os: 91.: Calling *note os.register_at_fork(): 2d7. in
     multi-threaded process.

   * ‘pydoc.ErrorDuringImport’: A tuple value for 'exc_info' parameter
     is deprecated, use an exception instance.

   * *note re: a7.: More strict rules are now applied for numerical
     group references and group names in regular expressions.  Only
     sequence of ASCII digits is now accepted as a numerical reference.
     The group name in bytes patterns and replacement strings can now
     only contain ASCII letters and digits and underscore.  (Contributed
     by Serhiy Storchaka in gh-91760(5).)

   * ‘sre_compile’, ‘sre_constants’ and ‘sre_parse’ modules.

   * *note shutil: b3.: *note rmtree(): 2d8.'s 'onerror' parameter is
     deprecated in Python 3.12; use the 'onexc' parameter instead.

   * *note ssl: bb. options and protocols:

        * *note ssl.SSLContext: 274. without protocol argument is
          deprecated.

        * *note ssl.SSLContext: 274.: *note set_npn_protocols(): 2d9.
          and ‘selected_npn_protocol()’ are deprecated: use ALPN
          instead.

        * ‘ssl.OP_NO_SSL*’ options

        * ‘ssl.OP_NO_TLS*’ options

        * ‘ssl.PROTOCOL_SSLv3’

        * ‘ssl.PROTOCOL_TLS’

        * ‘ssl.PROTOCOL_TLSv1’

        * ‘ssl.PROTOCOL_TLSv1_1’

        * ‘ssl.PROTOCOL_TLSv1_2’

        * ‘ssl.TLSVersion.SSLv3’

        * ‘ssl.TLSVersion.TLSv1’

        * ‘ssl.TLSVersion.TLSv1_1’

   * *note sysconfig.is_python_build(): 2da. 'check_home' parameter is
     deprecated and ignored.

   * *note threading: d6. methods:

        * ‘threading.Condition.notifyAll()’: use *note notify_all():
          2db.

        * ‘threading.Event.isSet()’: use *note is_set(): 2dc.

        * ‘threading.Thread.isDaemon()’, *note
          threading.Thread.setDaemon(): 2dd.: use *note
          threading.Thread.daemon: 2de. attribute.

        * ‘threading.Thread.getName()’, *note
          threading.Thread.setName(): 2df.: use *note
          threading.Thread.name: 2e0. attribute.

        * ‘threading.currentThread()’: use *note
          threading.current_thread(): 2e1.

        * ‘threading.activeCount()’: use *note threading.active_count():
          2e2.

   * *note typing.Text: 2e3. (gh-92332(6)).

   * *note unittest.IsolatedAsyncioTestCase: 2e4.: it is deprecated to
     return a value that is not ‘None’ from a test case.

   * *note urllib.parse: f3. deprecated functions: *note urlparse():
     2e5. instead

        * ‘splitattr()’

        * ‘splithost()’

        * ‘splitnport()’

        * ‘splitpasswd()’

        * ‘splitport()’

        * ‘splitquery()’

        * ‘splittag()’

        * ‘splittype()’

        * ‘splituser()’

        * ‘splitvalue()’

        * ‘to_bytes()’

   * *note urllib.request: f4.: *note URLopener: 2e6. and *note
     FancyURLopener: 2e7. style of invoking requests is deprecated.  Use
     newer *note urlopen(): 273. functions and methods.

   * *note wsgiref: 100.: ‘SimpleHandler.stdout.write()’ should not do
     partial writes.

   * *note xml.etree.ElementTree: 10c.: Testing the truth value of an
     *note Element: 2e8. is deprecated.  In a future release it will
     always return ‘True’.  Prefer explicit ‘len(elem)’ or ‘elem is not
     None’ tests instead.

   * *note zipimport.zipimporter.load_module(): 2e9. is deprecated: use
     *note exec_module(): 2ea. instead.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/57281

   (2) https://github.com/python/cpython/issues/87999

   (3) https://github.com/python/cpython/issues/109218

   (4) https://github.com/python/cpython/issues/103636

   (5) https://github.com/python/cpython/issues/91760

   (6) https://github.com/python/cpython/issues/92332


File: python.info,  Node: CPython Bytecode Changes,  Next: C API Changes,  Prev: New Deprecations,  Up: What's New In Python 3 13

1.1.9 CPython Bytecode Changes
------------------------------

   * The oparg of *note YIELD_VALUE: 2ec. is now ‘1’ if the yield is
     part of a yield-from or await, and ‘0’ otherwise.  The oparg of
     *note RESUME: 2ed. was changed to add a bit indicating if the
     except-depth is 1, which is needed to optimize closing of
     generators.  (Contributed by Irit Katriel in gh-111354(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111354


File: python.info,  Node: C API Changes,  Next: Build Changes,  Prev: CPython Bytecode Changes,  Up: What's New In Python 3 13

1.1.10 C API Changes
--------------------

* Menu:

* New Features: New Features<2>.
* Changed C APIs::
* Limited C API Changes::
* Removed C APIs::
* Deprecated C APIs::


File: python.info,  Node: New Features<2>,  Next: Changed C APIs,  Up: C API Changes

1.1.10.1 New Features
.....................

   * Add the *note PyMonitoring C API: 142. for generating PEP 669(1)
     monitoring events:

        * *note PyMonitoringState: 2f0.

        * *note PyMonitoring_FirePyStartEvent(): 2f1.

        * *note PyMonitoring_FirePyResumeEvent(): 2f2.

        * *note PyMonitoring_FirePyReturnEvent(): 2f3.

        * *note PyMonitoring_FirePyYieldEvent(): 2f4.

        * *note PyMonitoring_FireCallEvent(): 2f5.

        * *note PyMonitoring_FireLineEvent(): 2f6.

        * *note PyMonitoring_FireJumpEvent(): 2f7.

        * *note PyMonitoring_FireBranchEvent(): 2f8.

        * *note PyMonitoring_FireCReturnEvent(): 2f9.

        * *note PyMonitoring_FirePyThrowEvent(): 2fa.

        * *note PyMonitoring_FireRaiseEvent(): 2fb.

        * *note PyMonitoring_FireCRaiseEvent(): 2fc.

        * *note PyMonitoring_FireReraiseEvent(): 2fd.

        * *note PyMonitoring_FireExceptionHandledEvent(): 2fe.

        * *note PyMonitoring_FirePyUnwindEvent(): 2ff.

        * *note PyMonitoring_FireStopIterationEvent(): 300.

        * *note PyMonitoring_EnterScope(): 301.

        * *note PyMonitoring_ExitScope(): 302.

     (Contributed by Irit Katriel in gh-111997(2)).

   * Add *note PyMutex: 141, a lightweight mutex that occupies a single
     byte, and the new *note PyMutex_Lock(): 303. and *note
     PyMutex_Unlock(): 304. functions.  ‘PyMutex_Lock()’ will release
     the *note GIL: 13f. (if currently held) if the operation needs to
     block.  (Contributed by Sam Gross in gh-108724(3).)

   * Add the *note PyTime C API: 305. to provide access to system
     clocks:

        * *note PyTime_t: 306.

        * *note PyTime_MIN: 307. and *note PyTime_MAX: 308.

        * *note PyTime_AsSecondsDouble(): 309.

        * *note PyTime_Monotonic(): 30a.

        * *note PyTime_MonotonicRaw(): 30b.

        * *note PyTime_PerfCounter(): 30c.

        * *note PyTime_PerfCounterRaw(): 30d.

        * *note PyTime_Time(): 30e.

        * *note PyTime_TimeRaw(): 30f.

     (Contributed by Victor Stinner and Petr Viktorin in gh-110850(4).)

   * Add the *note PyDict_ContainsString(): 310. function with the same
     behavior as *note PyDict_Contains(): 311, but 'key' is specified as
     a const char* UTF-8 encoded bytes string, rather than a *note
     PyObject: 312.*.  (Contributed by Victor Stinner in gh-108314(5).)

   * Add the *note PyDict_GetItemRef(): 313. and *note
     PyDict_GetItemStringRef(): 314. functions, which behave similarly
     to *note PyDict_GetItemWithError(): 315, but return a *note strong
     reference: 316. instead of a *note borrowed reference: 317.
     Moreover, these functions return ‘-1’ on error, removing the need
     to check ‘PyErr_Occurred()’.  (Contributed by Victor Stinner in
     gh-106004(6).)

   * Add the *note PyDict_SetDefaultRef(): 318. function, which behaves
     similarly to *note PyDict_SetDefault(): 319, but returns a *note
     strong reference: 316. instead of a *note borrowed reference: 317.
     This function returns ‘-1’ on error, ‘0’ on insertion, and ‘1’ if
     the key was already present in the dictionary.  (Contributed by Sam
     Gross in gh-112066(7).)

   * Add the *note PyDict_Pop(): 31a. and *note PyDict_PopString(): 31b.
     functions to remove a key from a dictionary and optionally return
     the removed value.  This is similar to *note dict.pop(): 31c,
     though there is no default value, and *note KeyError: 31d. is not
     raised for missing keys.  (Contributed by Stefan Behnel and Victor
     Stinner in gh-111262(8).)

   * Add the *note PyMapping_GetOptionalItem(): 31e. and *note
     PyMapping_GetOptionalItemString(): 31f. functions as alternatives
     to *note PyObject_GetItem(): 320. and *note
     PyMapping_GetItemString(): 321. respectively.  The new functions do
     not raise *note KeyError: 31d. if the requested key is missing from
     the mapping.  These variants are more convenient and faster if a
     missing key should not be treated as a failure.  (Contributed by
     Serhiy Storchaka in gh-106307(9).)

   * Add the *note PyObject_GetOptionalAttr(): 322. and *note
     PyObject_GetOptionalAttrString(): 323. functions as alternatives to
     *note PyObject_GetAttr(): 324. and *note PyObject_GetAttrString():
     325. respectively.  The new functions do not raise *note
     AttributeError: 326. if the requested attribute is not found on the
     object.  These variants are more convenient and faster if the
     missing attribute should not be treated as a failure.  (Contributed
     by Serhiy Storchaka in gh-106521(10).)

   * Add the *note PyErr_FormatUnraisable(): 327. function as an
     extension to *note PyErr_WriteUnraisable(): 328. that allows
     customizing the warning message.  (Contributed by Serhiy Storchaka
     in gh-108082(11).)

   * Add new functions that return a *note strong reference: 316.
     instead of a *note borrowed reference: 317. for frame locals,
     globals, and builtins, as part of *note PEP 667: 128.:

        * *note PyEval_GetFrameBuiltins(): 329. replaces *note
          PyEval_GetBuiltins(): 32a.

        * *note PyEval_GetFrameGlobals(): 32b. replaces *note
          PyEval_GetGlobals(): 32c.

        * *note PyEval_GetFrameLocals(): 32d. replaces *note
          PyEval_GetLocals(): 32e.

     (Contributed by Mark Shannon and Tian Gao in gh-74929(12).)

   * Add the *note Py_GetConstant(): 32f. and *note
     Py_GetConstantBorrowed(): 330. functions to get *note strong: 316.
     or *note borrowed: 317. references to constants.  For example,
     ‘Py_GetConstant(Py_CONSTANT_ZERO)’ returns a strong reference to
     the constant zero.  (Contributed by Victor Stinner in
     gh-115754(13).)

   * Add the *note PyImport_AddModuleRef(): 331. function as a
     replacement for *note PyImport_AddModule(): 332. that returns a
     *note strong reference: 316. instead of a *note borrowed reference:
     317.  (Contributed by Victor Stinner in gh-105922(14).)

   * Add the *note Py_IsFinalizing(): 333. function to check whether the
     main Python interpreter is *note shutting down: 134.  (Contributed
     by Victor Stinner in gh-108014(15).)

   * Add the *note PyList_GetItemRef(): 334. function as a replacement
     for *note PyList_GetItem(): 335. that returns a *note strong
     reference: 316. instead of a *note borrowed reference: 317.
     (Contributed by Sam Gross in gh-114329(16).)

   * Add the *note PyList_Extend(): 336. and *note PyList_Clear(): 337.
     functions, mirroring the Python ‘list.extend()’ and ‘list.clear()’
     methods.  (Contributed by Victor Stinner in gh-111138(17).)

   * Add the *note PyLong_AsInt(): 338. function.  It behaves similarly
     to *note PyLong_AsLong(): 339, but stores the result in a C int
     instead of a C long.  (Contributed by Victor Stinner in
     gh-108014(18).)

   * Add the *note PyLong_AsNativeBytes(): 33a, *note
     PyLong_FromNativeBytes(): 33b, and *note
     PyLong_FromUnsignedNativeBytes(): 33c. functions to simplify
     converting between native integer types and Python *note int: 238.
     objects.  (Contributed by Steve Dower in gh-111140(19).)

   * Add *note PyModule_Add(): 33d. function, which is similar to *note
     PyModule_AddObjectRef(): 33e. and *note PyModule_AddObject(): 33f,
     but always steals a reference to the value.  (Contributed by Serhiy
     Storchaka in gh-86493(20).)

   * Add the *note PyObject_GenericHash(): 340. function that implements
     the default hashing function of a Python object.  (Contributed by
     Serhiy Storchaka in gh-113024(21).)

   * Add the *note Py_HashPointer(): 341. function to hash a raw
     pointer.  (Contributed by Victor Stinner in gh-111545(22).)

   * Add the *note PyObject_VisitManagedDict(): 342. and *note
     PyObject_ClearManagedDict(): 343. functions.  which must be called
     by the traverse and clear functions of a type using the *note
     Py_TPFLAGS_MANAGED_DICT: 344. flag.  The pythoncapi-compat
     project(23) can be used to use these functions with Python 3.11 and
     3.12.  (Contributed by Victor Stinner in gh-107073(24).)

   * Add the *note PyRefTracer_SetTracer(): 345. and *note
     PyRefTracer_GetTracer(): 346. functions, which enable tracking
     object creation and destruction in the same way that the *note
     tracemalloc: e8. module does.  (Contributed by Pablo Galindo in
     gh-93502(25).)

   * Add the *note PySys_AuditTuple(): 347. function as an alternative
     to *note PySys_Audit(): 348. that takes event arguments as a Python
     *note tuple: 349. object.  (Contributed by Victor Stinner in
     gh-85283(26).)

   * Add the *note PyThreadState_GetUnchecked(): 34a. function as an
     alternative to *note PyThreadState_Get(): 34b. that doesn't kill
     the process with a fatal error if it is ‘NULL’.  The caller is
     responsible for checking if the result is ‘NULL’.  (Contributed by
     Victor Stinner in gh-108867(27).)

   * Add the *note PyType_GetFullyQualifiedName(): 34c. function to get
     the type's fully qualified name.  The module name is prepended if
     *note type.__module__: 34d. is a string and is not equal to either
     ‘'builtins'’ or ‘'__main__'’.  (Contributed by Victor Stinner in
     gh-111696(28).)

   * Add the *note PyType_GetModuleName(): 34e. function to get the
     type's module name.  This is equivalent to getting the *note
     type.__module__: 34d. attribute.  (Contributed by Eric Snow and
     Victor Stinner in gh-111696(29).)

   * Add the *note PyUnicode_EqualToUTF8AndSize(): 34f. and *note
     PyUnicode_EqualToUTF8(): 350. functions to compare a Unicode object
     with a const char* UTF-8 encoded string and ‘1’ if they are equal
     or ‘0’ otherwise.  These functions do not raise exceptions.
     (Contributed by Serhiy Storchaka in gh-110289(30).)

   * Add the *note PyWeakref_GetRef(): 351. function as an alternative
     to *note PyWeakref_GetObject(): 352. that returns a *note strong
     reference: 316. or ‘NULL’ if the referent is no longer live.
     (Contributed by Victor Stinner in gh-105927(31).)

   * Add fixed variants of functions which silently ignore errors:

        * *note PyObject_HasAttrWithError(): 353. replaces *note
          PyObject_HasAttr(): 354.

        * *note PyObject_HasAttrStringWithError(): 355. replaces *note
          PyObject_HasAttrString(): 356.

        * *note PyMapping_HasKeyWithError(): 357. replaces *note
          PyMapping_HasKey(): 358.

        * *note PyMapping_HasKeyStringWithError(): 359. replaces *note
          PyMapping_HasKeyString(): 35a.

     The new functions return ‘-1’ for errors and the standard ‘1’ for
     true and ‘0’ for false.

     (Contributed by Serhiy Storchaka in gh-108511(32).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0669/

   (2) https://github.com/python/cpython/issues/111997

   (3) https://github.com/python/cpython/issues/108724

   (4) https://github.com/python/cpython/issues/110850

   (5) https://github.com/python/cpython/issues/108314

   (6) https://github.com/python/cpython/issues/106004

   (7) https://github.com/python/cpython/issues/112066

   (8) https://github.com/python/cpython/issues/111262

   (9) https://github.com/python/cpython/issues/106307

   (10) https://github.com/python/cpython/issues/106521

   (11) https://github.com/python/cpython/issues/108082

   (12) https://github.com/python/cpython/issues/74929

   (13) https://github.com/python/cpython/issues/115754

   (14) https://github.com/python/cpython/issues/105922

   (15) https://github.com/python/cpython/issues/108014

   (16) https://github.com/python/cpython/issues/114329

   (17) https://github.com/python/cpython/issues/111138

   (18) https://github.com/python/cpython/issues/108014

   (19) https://github.com/python/cpython/issues/111140

   (20) https://github.com/python/cpython/issues/86493

   (21) https://github.com/python/cpython/issues/113024

   (22) https://github.com/python/cpython/issues/111545

   (23) https://github.com/python/pythoncapi-compat/

   (24) https://github.com/python/cpython/issues/107073

   (25) https://github.com/python/cpython/issues/93502

   (26) https://github.com/python/cpython/issues/85283

   (27) https://github.com/python/cpython/issues/108867

   (28) https://github.com/python/cpython/issues/111696

   (29) https://github.com/python/cpython/issues/111696

   (30) https://github.com/python/cpython/issues/110289

   (31) https://github.com/python/cpython/issues/105927

   (32) https://github.com/python/cpython/issues/108511


File: python.info,  Node: Changed C APIs,  Next: Limited C API Changes,  Prev: New Features<2>,  Up: C API Changes

1.1.10.2 Changed C APIs
.......................

   * The 'keywords' parameter of *note PyArg_ParseTupleAndKeywords():
     35c. and *note PyArg_VaParseTupleAndKeywords(): 35d. now has type
     char *const* in C and const char *const* in C++, instead of char**.
     In C++, this makes these functions compatible with arguments of
     type const char *const*, const char**, or char *const* without an
     explicit type cast.  In C, the functions only support arguments of
     type char *const*.  This can be overridden with the *note
     PY_CXX_CONST: 35e. macro.  (Contributed by Serhiy Storchaka in
     gh-65210(1).)

   * *note PyArg_ParseTupleAndKeywords(): 35c. now supports non-ASCII
     keyword parameter names.  (Contributed by Serhiy Storchaka in
     gh-110815(2).)

   * The ‘PyCode_GetFirstFree()’ function is now unstable API and is now
     named *note PyUnstable_Code_GetFirstFree(): 35f.  (Contributed by
     Bogdan Romanyuk in gh-115781(3).)

   * The *note PyDict_GetItem(): 360, *note PyDict_GetItemString(): 361,
     *note PyMapping_HasKey(): 358, *note PyMapping_HasKeyString(): 35a,
     *note PyObject_HasAttr(): 354, *note PyObject_HasAttrString(): 356,
     and *note PySys_GetObject(): 362. functions, each of which clears
     all errors which occurred when calling them now reports these
     errors using *note sys.unraisablehook(): 1d8.  You may replace them
     with other functions as recommended in the documentation.
     (Contributed by Serhiy Storchaka in gh-106672(4).)

   * Add support for the ‘%T’, ‘%#T’, ‘%N’ and ‘%#N’ formats to *note
     PyUnicode_FromFormat(): 363.:

        * ‘%T’: Get the fully qualified name of an object type

        * ‘%#T’: As above, but use a colon as the separator

        * ‘%N’: Get the fully qualified name of a type

        * ‘%#N’: As above, but use a colon as the separator

     See PEP 737(5) for more information.  (Contributed by Victor
     Stinner in gh-111696(6).)

   * You no longer have to define the ‘PY_SSIZE_T_CLEAN’ macro before
     including ‘Python.h’ when using ‘#’ formats in *note format codes:
     364.  APIs accepting the format codes always use ‘Py_ssize_t’ for
     ‘#’ formats.  (Contributed by Inada Naoki in gh-104922(7).)

   * If Python is built in *note debug mode: 1da. or *note with
     assertions: 365, *note PyTuple_SET_ITEM(): 366. and *note
     PyList_SET_ITEM(): 367. now check the index argument with an
     assertion.  (Contributed by Victor Stinner in gh-106168(8).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/65210

   (2) https://github.com/python/cpython/issues/110815

   (3) https://github.com/python/cpython/issues/115781

   (4) https://github.com/python/cpython/issues/106672

   (5) https://peps.python.org/pep-0737/

   (6) https://github.com/python/cpython/issues/111696

   (7) https://github.com/python/cpython/issues/104922

   (8) https://github.com/python/cpython/issues/106168


File: python.info,  Node: Limited C API Changes,  Next: Removed C APIs,  Prev: Changed C APIs,  Up: C API Changes

1.1.10.3 Limited C API Changes
..............................

   * The following functions are now included in the Limited C API:

        * *note PyMem_RawMalloc(): 369.

        * *note PyMem_RawCalloc(): 36a.

        * *note PyMem_RawRealloc(): 36b.

        * *note PyMem_RawFree(): 36c.

        * *note PySys_Audit(): 348.

        * *note PySys_AuditTuple(): 347.

        * *note PyType_GetModuleByDef(): 36d.

     (Contributed by Victor Stinner in gh-85283(1), gh-85283(2), and
     gh-116936(3).)

   * Python built with *note -with-trace-refs: 36e. (tracing references)
     now supports the *note Limited API: 36f.  (Contributed by Victor
     Stinner in gh-108634(4).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/85283

   (2) https://github.com/python/cpython/issues/85283

   (3) https://github.com/python/cpython/issues/116936

   (4) https://github.com/python/cpython/issues/108634


File: python.info,  Node: Removed C APIs,  Next: Deprecated C APIs,  Prev: Limited C API Changes,  Up: C API Changes

1.1.10.4 Removed C APIs
.......................

   * Remove several functions, macros, variables, etc with names
     prefixed by ‘_Py’ or ‘_PY’ (which are considered private).  If your
     project is affected by one of these removals and you believe that
     the removed API should remain available, please *note open a new
     issue: 22f. to request a public C API and add ‘cc: @vstinner’ to
     the issue to notify Victor Stinner.  (Contributed by Victor Stinner
     in gh-106320(1).)

   * Remove old buffer protocols deprecated in Python 3.0.  Use *note
     バッファプロトコル (buffer Protocol): 371. instead.

        * ‘PyObject_CheckReadBuffer()’: Use *note
          PyObject_CheckBuffer(): 372. to test whether the object
          supports the buffer protocol.  Note that *note
          PyObject_CheckBuffer(): 372. doesn't guarantee that *note
          PyObject_GetBuffer(): 373. will succeed.  To test if the
          object is actually readable, see the next example of *note
          PyObject_GetBuffer(): 373.

        * ‘PyObject_AsCharBuffer()’, ‘PyObject_AsReadBuffer()’: Use
          *note PyObject_GetBuffer(): 373. and *note PyBuffer_Release():
          374. instead:

               Py_buffer view;
               if (PyObject_GetBuffer(obj, &view, PyBUF_SIMPLE) < 0) {
                   return NULL;
               }
               // Use `view.buf` and `view.len` to read from the buffer.
               // You may need to cast buf as `(const char*)view.buf`.
               PyBuffer_Release(&view);

        * ‘PyObject_AsWriteBuffer()’: Use *note PyObject_GetBuffer():
          373. and *note PyBuffer_Release(): 374. instead:

               Py_buffer view;
               if (PyObject_GetBuffer(obj, &view, PyBUF_WRITABLE) < 0) {
                   return NULL;
               }
               // Use `view.buf` and `view.len` to write to the buffer.
               PyBuffer_Release(&view);

     (Contributed by Inada Naoki in gh-85275(2).)

   * Remove various functions deprecated in Python 3.9:

        * ‘PyEval_CallObject()’, ‘PyEval_CallObjectWithKeywords()’: Use
          *note PyObject_CallNoArgs(): 375. or *note PyObject_Call():
          376. instead.

               警告: In *note PyObject_Call(): 376, positional arguments
               must be a *note tuple: 349. and must not be ‘NULL’, and
               keyword arguments must be a *note dict: 237. or ‘NULL’,
               whereas the removed functions checked argument types and
               accepted ‘NULL’ positional and keyword arguments.  To
               replace ‘PyEval_CallObjectWithKeywords(func, NULL,
               kwargs)’ with *note PyObject_Call(): 376, pass an empty
               tuple as positional arguments using *note PyTuple_New(0):
               377.

        * ‘PyEval_CallFunction()’: Use *note PyObject_CallFunction():
          378. instead.

        * ‘PyEval_CallMethod()’: Use *note PyObject_CallMethod(): 379.
          instead.

        * ‘PyCFunction_Call()’: Use *note PyObject_Call(): 376. instead.

     (Contributed by Victor Stinner in gh-105107(3).)

   * Remove the following old functions to configure the Python
     initialization, deprecated in Python 3.11:

        * ‘PySys_AddWarnOptionUnicode()’: Use *note
          PyConfig.warnoptions: 37a. instead.

        * ‘PySys_AddWarnOption()’: Use *note PyConfig.warnoptions: 37a.
          instead.

        * ‘PySys_AddXOption()’: Use *note PyConfig.xoptions: 37b.
          instead.

        * ‘PySys_HasWarnOptions()’: Use *note PyConfig.xoptions: 37b.
          instead.

        * ‘PySys_SetPath()’: Set *note PyConfig.module_search_paths:
          37c. instead.

        * ‘Py_SetPath()’: Set *note PyConfig.module_search_paths: 37c.
          instead.

        * ‘Py_SetStandardStreamEncoding()’: Set *note
          PyConfig.stdio_encoding: 37d. instead, and set also maybe
          *note PyConfig.legacy_windows_stdio: 37e. (on Windows).

        * ‘_Py_SetProgramFullPath()’: Set *note PyConfig.executable:
          37f. instead.

     Use the new *note PyConfig: 380. API of the *note Python
     Initialization Configuration: 381. instead ( PEP 587(4)), added to
     Python 3.8.  (Contributed by Victor Stinner in gh-105145(5).)

   * Remove ‘PyEval_AcquireLock()’ and ‘PyEval_ReleaseLock()’ functions,
     deprecated in Python 3.2.  They didn't update the current thread
     state.  They can be replaced with:

        * *note PyEval_SaveThread(): 382. and *note
          PyEval_RestoreThread(): 383.;

        * low-level *note PyEval_AcquireThread(): 384. and *note
          PyEval_RestoreThread(): 383.;

        * or *note PyGILState_Ensure(): 385. and *note
          PyGILState_Release(): 386.

     (Contributed by Victor Stinner in gh-105182(6).)

   * Remove the ‘PyEval_ThreadsInitialized()’ function, deprecated in
     Python 3.9.  Since Python 3.7, ‘Py_Initialize()’ always creates the
     GIL: calling ‘PyEval_InitThreads()’ does nothing and
     ‘PyEval_ThreadsInitialized()’ always returns non-zero.
     (Contributed by Victor Stinner in gh-105182(7).)

   * Remove the ‘_PyInterpreterState_Get()’ alias to *note
     PyInterpreterState_Get(): 387. which was kept for backward
     compatibility with Python 3.8.  The pythoncapi-compat project(8)
     can be used to get *note PyInterpreterState_Get(): 387. on Python
     3.8 and older.  (Contributed by Victor Stinner in gh-106320(9).)

   * Remove the private ‘_PyObject_FastCall()’ function: use
     ‘PyObject_Vectorcall()’ which is available since Python 3.8 ( PEP
     590(10)).  (Contributed by Victor Stinner in gh-106023(11).)

   * Remove the ‘cpython/pytime.h’ header file, which only contained
     private functions.  (Contributed by Victor Stinner in
     gh-106316(12).)

   * Remove the undocumented ‘PY_TIMEOUT_MAX’ constant from the limited
     C API. (Contributed by Victor Stinner in gh-110014(13).)

   * Remove the old trashcan macros ‘Py_TRASHCAN_SAFE_BEGIN’ and
     ‘Py_TRASHCAN_SAFE_END’.  Replace both with the new macros
     ‘Py_TRASHCAN_BEGIN’ and ‘Py_TRASHCAN_END’.  (Contributed by Irit
     Katriel in gh-105111(14).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/106320

   (2) https://github.com/python/cpython/issues/85275

   (3) https://github.com/python/cpython/issues/105107

   (4) https://peps.python.org/pep-0587/

   (5) https://github.com/python/cpython/issues/105145

   (6) https://github.com/python/cpython/issues/105182

   (7) https://github.com/python/cpython/issues/105182

   (8) https://github.com/python/pythoncapi-compat/

   (9) https://github.com/python/cpython/issues/106320

   (10) https://peps.python.org/pep-0590/

   (11) https://github.com/python/cpython/issues/106023

   (12) https://github.com/python/cpython/issues/106316

   (13) https://github.com/python/cpython/issues/110014

   (14) https://github.com/python/cpython/issues/105111


File: python.info,  Node: Deprecated C APIs,  Prev: Removed C APIs,  Up: C API Changes

1.1.10.5 Deprecated C APIs
..........................

   * Deprecate old Python initialization functions:

        * *note PySys_ResetWarnOptions(): 389.: Clear *note
          sys.warnoptions: 38a. and ‘warnings.filters’ instead.

        * *note Py_GetExecPrefix(): 38b.: Get *note sys.exec_prefix:
          38c. instead.

        * *note Py_GetPath(): 38d.: Get *note sys.path: 38e. instead.

        * *note Py_GetPrefix(): 38f.: Get *note sys.prefix: 390.
          instead.

        * *note Py_GetProgramFullPath(): 391.: Get *note sys.executable:
          392. instead.

        * *note Py_GetProgramName(): 393.: Get *note sys.executable:
          392. instead.

        * *note Py_GetPythonHome(): 394.: Get *note PyConfig.home: 395.
          or the *note PYTHONHOME: 396. environment variable instead.

     (Contributed by Victor Stinner in gh-105145(1).)

   * *note Soft deprecate: 1ea. the *note PyEval_GetBuiltins(): 32a,
     *note PyEval_GetGlobals(): 32c, and *note PyEval_GetLocals(): 32e.
     functions, which return a *note borrowed reference: 317.  (Soft
     deprecated as part of PEP 667(2).)

   * Deprecate the *note PyImport_ImportModuleNoBlock(): 397. function,
     which is just an alias to *note PyImport_ImportModule(): 398. since
     Python 3.3.  (Contributed by Victor Stinner in gh-105396(3).)

   * *note Soft deprecate: 1ea. the *note PyModule_AddObject(): 33f.
     function.  It should be replaced with *note PyModule_Add(): 33d. or
     *note PyModule_AddObjectRef(): 33e.  (Contributed by Serhiy
     Storchaka in gh-86493(4).)

   * Deprecate the old ‘Py_UNICODE’ and ‘PY_UNICODE_TYPE’ types and the
     ‘Py_UNICODE_WIDE’ define.  Use the ‘wchar_t’ type directly instead.
     Since Python 3.3, ‘Py_UNICODE’ and ‘PY_UNICODE_TYPE’ are just
     aliases to ‘wchar_t’.  (Contributed by Victor Stinner in
     gh-105156(5).)

   * Deprecate the *note PyWeakref_GetObject(): 352. and *note
     PyWeakref_GET_OBJECT(): 399. functions, which return a *note
     borrowed reference: 317.  Replace them with the new *note
     PyWeakref_GetRef(): 351. function, which returns a *note strong
     reference: 316.  The pythoncapi-compat project(6) can be used to
     get *note PyWeakref_GetRef(): 351. on Python 3.12 and older.
     (Contributed by Victor Stinner in gh-105927(7).)

* Menu:

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<2>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<2>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<2>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/105145

   (2) https://peps.python.org/pep-0667/

   (3) https://github.com/python/cpython/issues/105396

   (4) https://github.com/python/cpython/issues/86493

   (5) https://github.com/python/cpython/issues/105156

   (6) https://github.com/python/pythoncapi-compat/

   (7) https://github.com/python/cpython/issues/105927


File: python.info,  Node: Pending Removal in Python 3 14<2>,  Next: Pending Removal in Python 3 15<2>,  Up: Deprecated C APIs

1.1.10.6 Pending Removal in Python 3.14
.......................................

   * The ‘ma_version_tag’ field in *note PyDictObject: 39b. for
     extension modules ( PEP 699(1); gh-101193(2)).

   * Creating *note immutable types: 39c. with mutable bases
     (gh-95388(3)).

   * Functions to configure Python's initialization, deprecated in
     Python 3.11:

        * ‘PySys_SetArgvEx()’: Set *note PyConfig.argv: 39d. instead.

        * ‘PySys_SetArgv()’: Set *note PyConfig.argv: 39d. instead.

        * ‘Py_SetProgramName()’: Set *note PyConfig.program_name: 39e.
          instead.

        * ‘Py_SetPythonHome()’: Set *note PyConfig.home: 395. instead.

     The *note Py_InitializeFromConfig(): 39f. API should be used with
     *note PyConfig: 380. instead.

   * Global configuration variables:

        * *note Py_DebugFlag: 3a0.: Use *note PyConfig.parser_debug:
          3a1. instead.

        * *note Py_VerboseFlag: 3a2.: Use *note PyConfig.verbose: 3a3.
          instead.

        * *note Py_QuietFlag: 3a4.: Use *note PyConfig.quiet: 3a5.
          instead.

        * *note Py_InteractiveFlag: 3a6.: Use *note
          PyConfig.interactive: 3a7. instead.

        * *note Py_InspectFlag: 3a8.: Use *note PyConfig.inspect: 3a9.
          instead.

        * *note Py_OptimizeFlag: 3aa.: Use *note
          PyConfig.optimization_level: 3ab. instead.

        * *note Py_NoSiteFlag: 3ac.: Use *note PyConfig.site_import:
          3ad. instead.

        * *note Py_BytesWarningFlag: 3ae.: Use *note
          PyConfig.bytes_warning: 3af. instead.

        * *note Py_FrozenFlag: 3b0.: Use *note
          PyConfig.pathconfig_warnings: 3b1. instead.

        * *note Py_IgnoreEnvironmentFlag: 3b2.: Use *note
          PyConfig.use_environment: 3b3. instead.

        * *note Py_DontWriteBytecodeFlag: 3b4.: Use *note
          PyConfig.write_bytecode: 3b5. instead.

        * *note Py_NoUserSiteDirectory: 3b6.: Use *note
          PyConfig.user_site_directory: 3b7. instead.

        * *note Py_UnbufferedStdioFlag: 3b8.: Use *note
          PyConfig.buffered_stdio: 3b9. instead.

        * *note Py_HashRandomizationFlag: 3ba.: Use *note
          PyConfig.use_hash_seed: 3bb. and *note PyConfig.hash_seed:
          3bc. instead.

        * *note Py_IsolatedFlag: 3bd.: Use *note PyConfig.isolated: 3be.
          instead.

        * *note Py_LegacyWindowsFSEncodingFlag: 3bf.: Use *note
          PyPreConfig.legacy_windows_fs_encoding: 3c0. instead.

        * *note Py_LegacyWindowsStdioFlag: 3c1.: Use *note
          PyConfig.legacy_windows_stdio: 37e. instead.

        * ‘Py_FileSystemDefaultEncoding’: Use *note
          PyConfig.filesystem_encoding: 3c2. instead.

        * ‘Py_HasFileSystemDefaultEncoding’: Use *note
          PyConfig.filesystem_encoding: 3c2. instead.

        * ‘Py_FileSystemDefaultEncodeErrors’: Use *note
          PyConfig.filesystem_errors: 3c3. instead.

        * ‘Py_UTF8Mode’: Use *note PyPreConfig.utf8_mode: 3c4. instead.
          (see *note Py_PreInitialize(): 3c5.)

     The *note Py_InitializeFromConfig(): 39f. API should be used with
     *note PyConfig: 380. instead.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0699/

   (2) https://github.com/python/cpython/issues/101193

   (3) https://github.com/python/cpython/issues/95388


File: python.info,  Node: Pending Removal in Python 3 15<2>,  Next: Pending Removal in Future Versions<2>,  Prev: Pending Removal in Python 3 14<2>,  Up: Deprecated C APIs

1.1.10.7 Pending Removal in Python 3.15
.......................................

   * The bundled copy of ‘libmpdecimal’.

   * The *note PyImport_ImportModuleNoBlock(): 397.: Use *note
     PyImport_ImportModule(): 398. instead.

   * *note PyWeakref_GetObject(): 352. and *note PyWeakref_GET_OBJECT():
     399.: Use *note PyWeakref_GetRef(): 351. instead.

   * *note Py_UNICODE: 3c7. type and the ‘Py_UNICODE_WIDE’ macro: Use
     ‘wchar_t’ instead.

   * Python initialization functions:

        * *note PySys_ResetWarnOptions(): 389.: Clear *note
          sys.warnoptions: 38a. and ‘warnings.filters’ instead.

        * *note Py_GetExecPrefix(): 38b.: Get *note
          sys.base_exec_prefix: 3c8. and *note sys.exec_prefix: 38c.
          instead.

        * *note Py_GetPath(): 38d.: Get *note sys.path: 38e. instead.

        * *note Py_GetPrefix(): 38f.: Get *note sys.base_prefix: 3c9.
          and *note sys.prefix: 390. instead.

        * *note Py_GetProgramFullPath(): 391.: Get *note sys.executable:
          392. instead.

        * *note Py_GetProgramName(): 393.: Get *note sys.executable:
          392. instead.

        * *note Py_GetPythonHome(): 394.: Get *note PyConfig.home: 395.
          or the *note PYTHONHOME: 396. environment variable instead.


File: python.info,  Node: Pending Removal in Future Versions<2>,  Prev: Pending Removal in Python 3 15<2>,  Up: Deprecated C APIs

1.1.10.8 Pending Removal in Future Versions
...........................................

The following APIs are deprecated and will be removed, although there is
currently no date scheduled for their removal.

   * *note Py_TPFLAGS_HAVE_FINALIZE: 3cb.: Unneeded since Python 3.8.

   * *note PyErr_Fetch(): 3cc.: Use *note PyErr_GetRaisedException():
     3cd. instead.

   * *note PyErr_NormalizeException(): 3ce.: Use *note
     PyErr_GetRaisedException(): 3cd. instead.

   * *note PyErr_Restore(): 3cf.: Use *note PyErr_SetRaisedException():
     3d0. instead.

   * *note PyModule_GetFilename(): 3d1.: Use *note
     PyModule_GetFilenameObject(): 3d2. instead.

   * *note PyOS_AfterFork(): 3d3.: Use *note PyOS_AfterFork_Child():
     3d4. instead.

   * *note PySlice_GetIndicesEx(): 3d5.: Use *note PySlice_Unpack():
     3d6. and *note PySlice_AdjustIndices(): 3d7. instead.

   * ‘PyUnicode_AsDecodedObject()’: Use *note PyCodec_Decode(): 3d8.
     instead.

   * ‘PyUnicode_AsDecodedUnicode()’: Use *note PyCodec_Decode(): 3d8.
     instead.

   * ‘PyUnicode_AsEncodedObject()’: Use *note PyCodec_Encode(): 3d9.
     instead.

   * ‘PyUnicode_AsEncodedUnicode()’: Use *note PyCodec_Encode(): 3d9.
     instead.

   * *note PyUnicode_READY(): 3da.: Unneeded since Python 3.12

   * ‘PyErr_Display()’: Use *note PyErr_DisplayException(): 3db.
     instead.

   * ‘_PyErr_ChainExceptions()’: Use ‘_PyErr_ChainExceptions1()’
     instead.

   * ‘PyBytesObject.ob_shash’ member: call *note PyObject_Hash(): 3dc.
     instead.

   * ‘PyDictObject.ma_version_tag’ member.

   * Thread Local Storage (TLS) API:

        * *note PyThread_create_key(): 3dd.: Use *note
          PyThread_tss_alloc(): 3de. instead.

        * *note PyThread_delete_key(): 3df.: Use *note
          PyThread_tss_free(): 3e0. instead.

        * *note PyThread_set_key_value(): 3e1.: Use *note
          PyThread_tss_set(): 3e2. instead.

        * *note PyThread_get_key_value(): 3e3.: Use *note
          PyThread_tss_get(): 3e4. instead.

        * *note PyThread_delete_key_value(): 3e5.: Use *note
          PyThread_tss_delete(): 3e6. instead.

        * *note PyThread_ReInitTLS(): 3e7.: Unneeded since Python 3.7.


File: python.info,  Node: Build Changes,  Next: Porting to Python 3 13,  Prev: C API Changes,  Up: What's New In Python 3 13

1.1.11 Build Changes
--------------------

   * ‘arm64-apple-ios’ and ‘arm64-apple-ios-simulator’ are both now PEP
     11(1) tier 3 platforms.  (*note PEP 730: 14b. written and
     implementation contributed by Russell Keith-Magee in gh-114099(2).)

   * ‘aarch64-linux-android’ and ‘x86_64-linux-android’ are both now PEP
     11(3) tier 3 platforms.  (*note PEP 738: 14b. written and
     implementation contributed by Malcolm Smith in gh-116622(4).)

   * ‘wasm32-wasi’ is now a PEP 11(5) tier 2 platform.  (Contributed by
     Brett Cannon in gh-115192(6).)

   * ‘wasm32-emscripten’ is no longer a PEP 11(7) supported platform.
     (Contributed by Brett Cannon in gh-115192(8).)

   * Building CPython now requires a compiler with support for the C11
     atomic library, GCC built-in atomic functions, or MSVC interlocked
     intrinsics.

   * Autoconf 2.71 and aclocal 1.16.5 are now required to regenerate the
     ‘configure’ script.  (Contributed by Christian Heimes in
     gh-89886(9) and by Victor Stinner in gh-112090(10).)

   * SQLite 3.15.2 or newer is required to build the *note sqlite3: ba.
     extension module.  (Contributed by Erlend Aasland in
     gh-105875(11).)

   * CPython now bundles the mimalloc library(12) by default.  It is
     licensed under the MIT license; see *note mimalloc license: 3ea.
     The bundled mimalloc has custom changes, see gh-113141(13) for
     details.  (Contributed by Dino Viehland in gh-109914(14).)

   * The ‘configure’ option *note -with-system-libmpdec: 3eb. now
     defaults to ‘yes’.  The bundled copy of ‘libmpdecimal’ will be
     removed in Python 3.15.

   * Python built with ‘configure’ *note -with-trace-refs: 36e. (tracing
     references) is now ABI compatible with the Python release build and
     *note debug build: 1da.  (Contributed by Victor Stinner in
     gh-108634(15).)

   * On POSIX systems, the pkg-config (‘.pc’) filenames now include the
     ABI flags.  For example, the free-threaded build generates
     ‘python-3.13t.pc’ and the debug build generates ‘python-3.13d.pc’.

   * The ‘errno’, ‘fcntl’, ‘grp’, ‘md5’, ‘pwd’, ‘resource’, ‘termios’,
     ‘winsound’, ‘_ctypes_test’, ‘_multiprocessing.posixshmem’,
     ‘_scproxy’, ‘_stat’, ‘_statistics’, ‘_testconsole’,
     ‘_testimportmultiple’ and ‘_uuid’ C extensions are now built with
     the *note limited C API: 36f.  (Contributed by Victor Stinner in
     gh-85283(16).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0011/

   (2) https://github.com/python/cpython/issues/114099

   (3) https://peps.python.org/pep-0011/

   (4) https://github.com/python/cpython/issues/116622

   (5) https://peps.python.org/pep-0011/

   (6) https://github.com/python/cpython/issues/115192

   (7) https://peps.python.org/pep-0011/

   (8) https://github.com/python/cpython/issues/115192

   (9) https://github.com/python/cpython/issues/89886

   (10) https://github.com/python/cpython/issues/112090

   (11) https://github.com/python/cpython/issues/105875

   (12) https://github.com/microsoft/mimalloc/

   (13) https://github.com/python/cpython/issues/113141

   (14) https://github.com/python/cpython/issues/109914

   (15) https://github.com/python/cpython/issues/108634

   (16) https://github.com/python/cpython/issues/85283


File: python.info,  Node: Porting to Python 3 13,  Next: Regression Test Changes,  Prev: Build Changes,  Up: What's New In Python 3 13

1.1.12 Porting to Python 3.13
-----------------------------

This section lists previously described changes and other bugfixes that
may require changes to your code.

* Menu:

* Changes in the Python API::
* Changes in the C API::


File: python.info,  Node: Changes in the Python API,  Next: Changes in the C API,  Up: Porting to Python 3 13

1.1.12.1 Changes in the Python API
..................................

   * *note PEP 667: 128. introduces several changes to the semantics of
     *note locals(): 127. and *note f_locals: 167.:

        * Calling *note locals(): 127. in an *note optimized scope: 163.
          now produces an independent snapshot on each call, and hence
          no longer implicitly updates previously returned references.
          Obtaining the legacy CPython behavior now requires explicit
          calls to update the initially returned dictionary with the
          results of subsequent calls to ‘locals()’.  Code execution
          functions that implicitly target ‘locals()’ (such as ‘exec’
          and ‘eval’) must be passed an explicit namespace to access
          their results in an optimized scope.  (Changed as part of PEP
          667(1).)

        * Calling *note locals(): 127. from a comprehension at module or
          class scope (including via ‘exec’ or ‘eval’) once more behaves
          as if the comprehension were running as an independent nested
          function (i.e.  the local variables from the containing scope
          are not included).  In Python 3.12, this had changed to
          include the local variables from the containing scope when
          implementing PEP 709(2).  (Changed as part of PEP 667(3).)

        * Accessing *note FrameType.f_locals: 167. in an *note optimized
          scope: 163. now returns a write-through proxy rather than a
          snapshot that gets updated at ill-specified times.  If a
          snapshot is desired, it must be created explicitly with ‘dict’
          or the proxy's ‘.copy()’ method.  (Changed as part of PEP
          667(4).)

   * *note functools.partial: 3ed. now emits a *note FutureWarning: 3ee.
     when used as a method.  The behavior will change in future Python
     versions.  Wrap it in *note staticmethod(): 3ef. if you want to
     preserve the old behavior.  (Contributed by Serhiy Storchaka in
     gh-121027(5).)

   * An *note OSError: 3f0. is now raised by *note getpass.getuser():
     3f1. for any failure to retrieve a username, instead of *note
     ImportError: 3f2. on non-Unix platforms or *note KeyError: 31d. on
     Unix platforms where the password database is empty.

   * The value of the ‘mode’ attribute of *note gzip.GzipFile: 3f3. is
     now a string (‘'rb'’ or ‘'wb'’) instead of an integer (‘1’ or ‘2’).
     The value of the ‘mode’ attribute of the readable file-like object
     returned by *note zipfile.ZipFile.open(): 3f4. is now ‘'rb'’
     instead of ‘'r'’.  (Contributed by Serhiy Storchaka in
     gh-115961(6).)

   * *note mailbox.Maildir: 3f5. now ignores files with a leading dot
     (‘.’).  (Contributed by Zackery Spytz in gh-65559(7).)

   * *note pathlib.Path.glob(): 20e. and *note rglob(): 20f. now return
     both files and directories if a pattern that ends with "‘**’" is
     given, rather than directories only.  Add a trailing slash to keep
     the previous behavior and only match directories.

   * The *note threading: d6. module now expects the ‘_thread’ module to
     have an ‘_is_main_interpreter()’ function.  This function takes no
     arguments and returns ‘True’ if the current interpreter is the main
     interpreter.

     Any library or application that provides a custom ‘_thread’ module
     must provide ‘_is_main_interpreter()’, just like the module's other
     "private" attributes.  (gh-112826(8).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0667/

   (2) https://peps.python.org/pep-0709/

   (3) https://peps.python.org/pep-0667/

   (4) https://peps.python.org/pep-0667/

   (5) https://github.com/python/cpython/issues/121027

   (6) https://github.com/python/cpython/issues/115961

   (7) https://github.com/python/cpython/issues/65559

   (8) https://github.com/python/cpython/issues/112826


File: python.info,  Node: Changes in the C API,  Prev: Changes in the Python API,  Up: Porting to Python 3 13

1.1.12.2 Changes in the C API
.............................

   * ‘Python.h’ no longer includes the ‘<ieeefp.h>’ standard header.  It
     was included for the ‘finite()’ function which is now provided by
     the ‘<math.h>’ header.  It should now be included explicitly if
     needed.  Remove also the ‘HAVE_IEEEFP_H’ macro.  (Contributed by
     Victor Stinner in gh-108765(1).)

   * ‘Python.h’ no longer includes these standard header files:
     ‘<time.h>’, ‘<sys/select.h>’ and ‘<sys/time.h>’.  If needed, they
     should now be included explicitly.  For example, ‘<time.h>’
     provides the ‘clock()’ and ‘gmtime()’ functions, ‘<sys/select.h>’
     provides the ‘select()’ function, and ‘<sys/time.h>’ provides the
     ‘futimes()’, ‘gettimeofday()’ and ‘setitimer()’ functions.
     (Contributed by Victor Stinner in gh-108765(2).)

   * On Windows, ‘Python.h’ no longer includes the ‘<stddef.h>’ standard
     header file.  If needed, it should now be included explicitly.  For
     example, it provides ‘offsetof()’ function, and ‘size_t’ and
     ‘ptrdiff_t’ types.  Including ‘<stddef.h>’ explicitly was already
     needed by all other platforms, the ‘HAVE_STDDEF_H’ macro is only
     defined on Windows.  (Contributed by Victor Stinner in
     gh-108765(3).)

   * If the *note Py_LIMITED_API: 3f7. macro is defined,
     ‘Py_BUILD_CORE’, ‘Py_BUILD_CORE_BUILTIN’ and ‘Py_BUILD_CORE_MODULE’
     macros are now undefined by ‘<Python.h>’.  (Contributed by Victor
     Stinner in gh-85283(4).)

   * The old trashcan macros ‘Py_TRASHCAN_SAFE_BEGIN’ and
     ‘Py_TRASHCAN_SAFE_END’ were removed.  They should be replaced by
     the new macros ‘Py_TRASHCAN_BEGIN’ and ‘Py_TRASHCAN_END’.

     A ‘tp_dealloc’ function that has the old macros, such as:

          static void
          mytype_dealloc(mytype *p)
          {
              PyObject_GC_UnTrack(p);
              Py_TRASHCAN_SAFE_BEGIN(p);
              ...
              Py_TRASHCAN_SAFE_END
          }

     should migrate to the new macros as follows:

          static void
          mytype_dealloc(mytype *p)
          {
              PyObject_GC_UnTrack(p);
              Py_TRASHCAN_BEGIN(p, mytype_dealloc)
              ...
              Py_TRASHCAN_END
          }

     Note that ‘Py_TRASHCAN_BEGIN’ has a second argument which should be
     the deallocation function it is in.  The new macros were added in
     Python 3.8 and the old macros were deprecated in Python 3.11.
     (Contributed by Irit Katriel in gh-105111(5).)

   * *note PEP 667: 128. introduces several changes to frame-related
     functions:

        * The effects of mutating the dictionary returned from *note
          PyEval_GetLocals(): 32e. in an *note optimized scope: 163.
          have changed.  New dict entries added this way will now 'only'
          be visible to subsequent *note PyEval_GetLocals(): 32e. calls
          in that frame, as *note PyFrame_GetLocals(): 3f8, *note
          locals(): 127, and *note FrameType.f_locals: 167. no longer
          access the same underlying cached dictionary.  Changes made to
          entries for actual variable names and names added via the
          write-through proxy interfaces will be overwritten on
          subsequent calls to *note PyEval_GetLocals(): 32e. in that
          frame.  The recommended code update depends on how the
          function was being used, so refer to the deprecation notice on
          the function for details.

        * Calling *note PyFrame_GetLocals(): 3f8. in an *note optimized
          scope: 163. now returns a write-through proxy rather than a
          snapshot that gets updated at ill-specified times.  If a
          snapshot is desired, it must be created explicitly (e.g.  with
          *note PyDict_Copy(): 3f9.), or by calling the new *note
          PyEval_GetFrameLocals(): 32d. API.

        * ‘PyFrame_FastToLocals()’ and ‘PyFrame_FastToLocalsWithError()’
          no longer have any effect.  Calling these functions has been
          redundant since Python 3.11, when *note PyFrame_GetLocals():
          3f8. was first introduced.

        * ‘PyFrame_LocalsToFast()’ no longer has any effect.  Calling
          this function is redundant now that *note PyFrame_GetLocals():
          3f8. returns a write-through proxy for *note optimized scopes:
          163.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/108765

   (2) https://github.com/python/cpython/issues/108765

   (3) https://github.com/python/cpython/issues/108765

   (4) https://github.com/python/cpython/issues/85283

   (5) https://github.com/python/cpython/issues/105111


File: python.info,  Node: Regression Test Changes,  Next: Notable changes in 3 13 1,  Prev: Porting to Python 3 13,  Up: What's New In Python 3 13

1.1.13 Regression Test Changes
------------------------------

   * Python built with ‘configure’ *note -with-pydebug: 3fb. now
     supports a *note -X presite=package.module: 15c. command-line
     option.  If used, it specifies a module that should be imported
     early in the lifecycle of the interpreter, before ‘site.py’ is
     executed.  (Contributed by Łukasz Langa in gh-110769(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/110769


File: python.info,  Node: Notable changes in 3 13 1,  Prev: Regression Test Changes,  Up: What's New In Python 3 13

1.1.14 Notable changes in 3.13.1
--------------------------------

* Menu:

* sys: sys<2>.


File: python.info,  Node: sys<2>,  Up: Notable changes in 3 13 1

1.1.14.1 sys
............

   * The previously undocumented special function *note
     sys.getobjects(): 3fe, which only exists in specialized builds of
     Python, may now return objects from other interpreters than the one
     it's called in.


File: python.info,  Node: What's New In Python 3 12,  Next: What's New In Python 3 11,  Prev: What's New In Python 3 13,  Up: What's New in Python

1.2 What's New In Python 3.12
=============================


Editor: Adam Turner

This article explains the new features in Python 3.12, compared to 3.11.
Python 3.12 was released on October 2, 2023.  For full details, see the
*note changelog: 122.

参考
....

PEP 693(1) - Python 3.12 Release Schedule

* Menu:

* Summary: Summary -- Release highlights. Release highlights
* New Features: New Features<3>.
* New Features Related to Type Hints::
* Other Language Changes: Other Language Changes<2>.
* New Modules: New Modules<2>.
* Improved Modules: Improved Modules<2>.
* Optimizations: Optimizations<2>.
* CPython bytecode changes::
* Demos and Tools::
* Deprecated::
* Removed::
* Porting to Python 3.12: Porting to Python 3 12.
* Build Changes: Build Changes<2>.
* C API Changes: C API Changes<2>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0693/


File: python.info,  Node: Summary -- Release highlights,  Next: New Features<3>,  Up: What's New In Python 3 12

1.2.1 Summary - Release highlights
----------------------------------

Python 3.12 is a stable release of the Python programming language, with
a mix of changes to the language and the standard library.  The library
changes focus on cleaning up deprecated APIs, usability, and
correctness.  Of note, the ‘distutils’ package has been removed from the
standard library.  Filesystem support in *note os: 91. and *note
pathlib: 93. has seen a number of improvements, and several modules have
better performance.

The language changes focus on usability, as *note f-strings: 402. have
had many limitations removed and 'Did you mean ...'  suggestions
continue to improve.  The new *note type parameter syntax: 403. and
*note type: 404. statement improve ergonomics for using *note generic
types: 405. and *note type aliases: 406. with static type checkers.

This article doesn't attempt to provide a complete specification of all
new features, but instead gives a convenient overview.  For full
details, you should refer to the documentation, such as the *note
Library Reference: 12a. and *note Language Reference: 12b.  If you want
to understand the complete implementation and design rationale for a
change, refer to the PEP for a particular new feature; but note that
PEPs usually are not kept up-to-date once a feature has been fully
implemented.

__________________________________________________________________

New syntax features:

   * *note PEP 695: 403, type parameter syntax and the *note type: 404.
     statement

New grammar features:

   * *note PEP 701: 407, *note f-strings: 402. in the grammar

Interpreter improvements:

   * *note PEP 684: 408, a unique per-interpreter *note GIL: 12e.

   * *note PEP 669: 409, low impact monitoring

   * *note Improved 'Did you mean ...'  suggestions: 40a.for *note
     NameError: 40b, *note ImportError: 3f2, and *note SyntaxError: 172.
     exceptions

Python data model improvements:

   * *note PEP 688: 40c, using the *note buffer protocol: 371. from
     Python

Significant improvements in the standard library:

   * The *note pathlib.Path: 20a. class now supports subclassing

   * The *note os: 91. module received several improvements for Windows
     support

   * A *note command-line interface: 40d. has been added to the *note
     sqlite3: ba. module

   * *note isinstance(): 40e. checks against *note runtime-checkable
     protocols: 40f. enjoy a speed up of between two and 20 times

   * The *note asyncio: 8. package has had a number of performance
     improvements, with some benchmarks showing a 75% speed up.

   * A *note command-line interface: 410. has been added to the *note
     uuid: f8. module

   * Due to the changes in *note PEP 701: 407, producing tokens via the
     *note tokenize: e4. module is up to 64% faster.

Security improvements:

   * Replace the builtin *note hashlib: 5e. implementations of SHA1,
     SHA3, SHA2-384, SHA2-512, and MD5 with formally verified code from
     the HACL*(1) project.  These builtin implementations remain as
     fallbacks that are only used when OpenSSL does not provide them.

C API improvements:

   * *note PEP 697: 411, unstable C API tier

   * *note PEP 683: 412, immortal objects

CPython implementation improvements:

   * *note PEP 709: 413, comprehension inlining

   * *note CPython support: 174. for the Linux ‘perf’ profiler

   * Implement stack overflow protection on supported platforms

New typing features:

   * *note PEP 692: 414, using *note TypedDict: 148. to annotate *note
     **kwargs: 415.

   * *note PEP 698: 416, *note typing.override(): 417. decorator

Important deprecations, removals or restrictions:

   * PEP 623(2): Remove ‘wstr’ from Unicode objects in Python's C API,
     reducing the size of every *note str: 418. object by at least 8
     bytes.

   * PEP 632(3): Remove the ‘distutils’ package.  See the migration
     guide(4) for advice replacing the APIs it provided.  The
     third-party Setuptools(5) package continues to provide ‘distutils’,
     if you still require it in Python 3.12 and beyond.

   * gh-95299(6): Do not pre-install ‘setuptools’ in virtual
     environments created with *note venv: f9.  This means that
     ‘distutils’, ‘setuptools’, ‘pkg_resources’, and ‘easy_install’ will
     no longer available by default; to access these run ‘pip install
     setuptools’ in the *note activated: 419. virtual environment.

   * The ‘asynchat’, ‘asyncore’, and ‘imp’ modules have been removed,
     along with several *note unittest.TestCase: 41a. *note method
     aliases: 41b..

   ---------- Footnotes ----------

   (1) https://github.com/hacl-star/hacl-star/

   (2) https://peps.python.org/pep-0623/

   (3) https://peps.python.org/pep-0632/

   (4) https://peps.python.org/pep-0632/#migration-advice

   (5) 
https://setuptools.pypa.io/en/latest/deprecated/distutils-legacy.html

   (6) https://github.com/python/cpython/issues/95299


File: python.info,  Node: New Features<3>,  Next: New Features Related to Type Hints,  Prev: Summary -- Release highlights,  Up: What's New In Python 3 12

1.2.2 New Features
------------------

* Menu:

* PEP 695; Type Parameter Syntax: PEP 695 Type Parameter Syntax.
* PEP 701; Syntactic formalization of f-strings: PEP 701 Syntactic formalization of f-strings.
* PEP 684; A Per-Interpreter GIL: PEP 684 A Per-Interpreter GIL.
* PEP 669; Low impact monitoring for CPython: PEP 669 Low impact monitoring for CPython.
* PEP 688; Making the buffer protocol accessible in Python: PEP 688 Making the buffer protocol accessible in Python.
* PEP 709; Comprehension inlining: PEP 709 Comprehension inlining.
* Improved Error Messages::


File: python.info,  Node: PEP 695 Type Parameter Syntax,  Next: PEP 701 Syntactic formalization of f-strings,  Up: New Features<3>

1.2.2.1 PEP 695: Type Parameter Syntax
......................................

Generic classes and functions under PEP 484(1) were declared using a
verbose syntax that left the scope of type parameters unclear and
required explicit declarations of variance.

PEP 695(2) introduces a new, more compact and explicit way to create
*note generic classes: 41e. and *note functions: 41f.:

     def max[T](args: Iterable[T]) -> T:
         ...

     class list[T]:
         def __getitem__(self, index: int, /) -> T:
             ...

         def append(self, element: T) -> None:
             ...

In addition, the PEP introduces a new way to declare *note type aliases:
420. using the *note type: 404. statement, which creates an instance of
*note TypeAliasType: 421.:

     type Point = tuple[float, float]

Type aliases can also be *note generic: 422.:

     type Point[T] = tuple[T, T]

The new syntax allows declaring *note TypeVarTuple: 145. and *note
ParamSpec: 144. parameters, as well as *note TypeVar: 143. parameters
with bounds or constraints:

     type IntFunc[**P] = Callable[P, int]  # ParamSpec
     type LabeledTuple[*Ts] = tuple[str, *Ts]  # TypeVarTuple
     type HashableSequence[T: Hashable] = Sequence[T]  # TypeVar with bound
     type IntOrStrSequence[T: (int, str)] = Sequence[T]  # TypeVar with constraints

The value of type aliases and the bound and constraints of type
variables created through this syntax are evaluated only on demand (see
*note lazy evaluation: 423.).  This means type aliases are able to refer
to other types defined later in the file.

Type parameters declared through a type parameter list are visible
within the scope of the declaration and any nested scopes, but not in
the outer scope.  For example, they can be used in the type annotations
for the methods of a generic class or in the class body.  However, they
cannot be used in the module scope after the class is defined.  See
*note Type parameter lists: 293. for a detailed description of the
runtime semantics of type parameters.

In order to support these scoping semantics, a new kind of scope is
introduced, the *note annotation scope: 16d.  Annotation scopes behave
for the most part like function scopes, but interact differently with
enclosing class scopes.  In Python 3.13, *note annotations: 424. will
also be evaluated in annotation scopes.

See PEP 695(3) for more details.

(PEP written by Eric Traut.  Implementation by Jelle Zijlstra, Eric
Traut, and others in gh-103764(4).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0695/

   (3) https://peps.python.org/pep-0695/

   (4) https://github.com/python/cpython/issues/103764


File: python.info,  Node: PEP 701 Syntactic formalization of f-strings,  Next: PEP 684 A Per-Interpreter GIL,  Prev: PEP 695 Type Parameter Syntax,  Up: New Features<3>

1.2.2.2 PEP 701: Syntactic formalization of f-strings
.....................................................

PEP 701(1) lifts some restrictions on the usage of *note f-strings: 402.
Expression components inside f-strings can now be any valid Python
expression, including strings reusing the same quote as the containing
f-string, multi-line expressions, comments, backslashes, and unicode
escape sequences.  Let's cover these in detail:

   * Quote reuse: in Python 3.11, reusing the same quotes as the
     enclosing f-string raises a *note SyntaxError: 172, forcing the
     user to either use other available quotes (like using double quotes
     or triple quotes if the f-string uses single quotes).  In Python
     3.12, you can now do things like this:

          >>> songs = ['Take me back to Eden', 'Alkaline', 'Ascensionism']
          >>> f"This is the playlist: {", ".join(songs)}"
          'This is the playlist: Take me back to Eden, Alkaline, Ascensionism'

     Note that before this change there was no explicit limit in how
     f-strings can be nested, but the fact that string quotes cannot be
     reused inside the expression component of f-strings made it
     impossible to nest f-strings arbitrarily.  In fact, this is the
     most nested f-string that could be written:

          >>> f"""{f'''{f'{f"{1+1}"}'}'''}"""
          '2'

     As now f-strings can contain any valid Python expression inside
     expression components, it is now possible to nest f-strings
     arbitrarily:

          >>> f"{f"{f"{f"{f"{f"{1+1}"}"}"}"}"}"
          '2'

   * Multi-line expressions and comments: In Python 3.11, f-string
     expressions must be defined in a single line, even if the
     expression within the f-string could normally span multiple lines
     (like literal lists being defined over multiple lines), making them
     harder to read.  In Python 3.12 you can now define f-strings
     spanning multiple lines, and add inline comments:

          >>> f"This is the playlist: {", ".join([
          ...     'Take me back to Eden',  # My, my, those eyes like fire
          ...     'Alkaline',              # Not acid nor alkaline
          ...     'Ascensionism'           # Take to the broken skies at last
          ... ])}"
          'This is the playlist: Take me back to Eden, Alkaline, Ascensionism'

   * Backslashes and unicode characters: before Python 3.12 f-string
     expressions couldn't contain any ‘\’ character.  This also affected
     unicode *note escape sequences: 426. (such as ‘\N{snowman}’) as
     these contain the ‘\N’ part that previously could not be part of
     expression components of f-strings.  Now, you can define
     expressions like this:

          >>> print(f"This is the playlist: {"\n".join(songs)}")
          This is the playlist: Take me back to Eden
          Alkaline
          Ascensionism
          >>> print(f"This is the playlist: {"\N{BLACK HEART SUIT}".join(songs)}")
          This is the playlist: Take me back to Eden♥Alkaline♥Ascensionism

See PEP 701(2) for more details.

As a positive side-effect of how this feature has been implemented (by
parsing f-strings with the PEG parser(3)), now error messages for
f-strings are more precise and include the exact location of the error.
For example, in Python 3.11, the following f-string raises a *note
SyntaxError: 172.:

     >>> my_string = f"{x z y}" + f"{1 + 1}"
       File "<stdin>", line 1
         (x z y)
          ^^^
     SyntaxError: f-string: invalid syntax. Perhaps you forgot a comma?

but the error message doesn't include the exact location of the error
within the line and also has the expression artificially surrounded by
parentheses.  In Python 3.12, as f-strings are parsed with the PEG
parser, error messages can be more precise and show the entire line:

     >>> my_string = f"{x z y}" + f"{1 + 1}"
       File "<stdin>", line 1
         my_string = f"{x z y}" + f"{1 + 1}"
                        ^^^
     SyntaxError: invalid syntax. Perhaps you forgot a comma?

(Contributed by Pablo Galindo, Batuhan Taskaya, Lysandros Nikolaou,
Cristián Maureira-Fredes and Marta Gómez in gh-102856(4).  PEP written
by Pablo Galindo, Batuhan Taskaya, Lysandros Nikolaou and Marta Gómez).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0701/

   (2) https://peps.python.org/pep-0701/

   (3) https://peps.python.org/pep-0617/

   (4) https://github.com/python/cpython/issues/102856


File: python.info,  Node: PEP 684 A Per-Interpreter GIL,  Next: PEP 669 Low impact monitoring for CPython,  Prev: PEP 701 Syntactic formalization of f-strings,  Up: New Features<3>

1.2.2.3 PEP 684: A Per-Interpreter GIL
......................................

PEP 684(1) introduces a per-interpreter *note GIL: 12e, so that
sub-interpreters may now be created with a unique GIL per interpreter.
This allows Python programs to take full advantage of multiple CPU
cores.  This is currently only available through the C-API, though a
Python API is anticipated for 3.13(2).

Use the new *note Py_NewInterpreterFromConfig(): 428. function to create
an interpreter with its own GIL:

     PyInterpreterConfig config = {
         .check_multi_interp_extensions = 1,
         .gil = PyInterpreterConfig_OWN_GIL,
     };
     PyThreadState *tstate = NULL;
     PyStatus status = Py_NewInterpreterFromConfig(&tstate, &config);
     if (PyStatus_Exception(status)) {
         return -1;
     }
     /* The new interpreter is now active in the current thread. */

For further examples how to use the C-API for sub-interpreters with a
per-interpreter GIL, see ‘Modules/_xxsubinterpretersmodule.c’.

(Contributed by Eric Snow in gh-104210(3), etc.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0684/

   (2) https://peps.python.org/pep-0554/

   (3) https://github.com/python/cpython/issues/104210


File: python.info,  Node: PEP 669 Low impact monitoring for CPython,  Next: PEP 688 Making the buffer protocol accessible in Python,  Prev: PEP 684 A Per-Interpreter GIL,  Up: New Features<3>

1.2.2.4 PEP 669: Low impact monitoring for CPython
..................................................

PEP 669(1) defines a new *note API: c4. for profilers, debuggers, and
other tools to monitor events in CPython.  It covers a wide range of
events, including calls, returns, lines, exceptions, jumps, and more.
This means that you only pay for what you use, providing support for
near-zero overhead debuggers and coverage tools.  See *note
sys.monitoring: c4. for details.

(Contributed by Mark Shannon in gh-103082(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0669/

   (2) https://github.com/python/cpython/issues/103082


File: python.info,  Node: PEP 688 Making the buffer protocol accessible in Python,  Next: PEP 709 Comprehension inlining,  Prev: PEP 669 Low impact monitoring for CPython,  Up: New Features<3>

1.2.2.5 PEP 688: Making the buffer protocol accessible in Python
................................................................

PEP 688(1) introduces a way to use the *note buffer protocol: 371. from
Python code.  Classes that implement the *note __buffer__(): 42b. method
are now usable as buffer types.

The new *note collections.abc.Buffer: 2a4. ABC provides a standard way
to represent buffer objects, for example in type annotations.  The new
*note inspect.BufferFlags: 42c. enum represents the flags that can be
used to customize buffer creation.  (Contributed by Jelle Zijlstra in
gh-102500(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0688/

   (2) https://github.com/python/cpython/issues/102500


File: python.info,  Node: PEP 709 Comprehension inlining,  Next: Improved Error Messages,  Prev: PEP 688 Making the buffer protocol accessible in Python,  Up: New Features<3>

1.2.2.6 PEP 709: Comprehension inlining
.......................................

Dictionary, list, and set comprehensions are now inlined, rather than
creating a new single-use function object for each execution of the
comprehension.  This speeds up execution of a comprehension by up to two
times.  See PEP 709(1) for further details.

Comprehension iteration variables remain isolated and don't overwrite a
variable of the same name in the outer scope, nor are they visible after
the comprehension.  Inlining does result in a few visible behavior
changes:

   * There is no longer a separate frame for the comprehension in
     tracebacks, and tracing/profiling no longer shows the comprehension
     as a function call.

   * The *note symtable: c2. module will no longer produce child symbol
     tables for each comprehension; instead, the comprehension's locals
     will be included in the parent function's symbol table.

   * Calling *note locals(): 127. inside a comprehension now includes
     variables from outside the comprehension, and no longer includes
     the synthetic ‘.0’ variable for the comprehension "argument".

   * A comprehension iterating directly over ‘locals()’ (e.g.  ‘[k for k
     in locals()]’) may see "RuntimeError: dictionary changed size
     during iteration" when run under tracing (e.g.  code coverage
     measurement).  This is the same behavior already seen in e.g.  ‘for
     k in locals():’.  To avoid the error, first create a list of keys
     to iterate over: ‘keys = list(locals()); [k for k in keys]’.

(Contributed by Carl Meyer and Vladimir Matveev in PEP 709(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0709/

   (2) https://peps.python.org/pep-0709/


File: python.info,  Node: Improved Error Messages,  Prev: PEP 709 Comprehension inlining,  Up: New Features<3>

1.2.2.7 Improved Error Messages
...............................

   * Modules from the standard library are now potentially suggested as
     part of the error messages displayed by the interpreter when a
     *note NameError: 40b. is raised to the top level.  (Contributed by
     Pablo Galindo in gh-98254(1).)

          >>> sys.version_info
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          NameError: name 'sys' is not defined. Did you forget to import 'sys'?

   * Improve the error suggestion for *note NameError: 40b. exceptions
     for instances.  Now if a *note NameError: 40b. is raised in a
     method and the instance has an attribute that's exactly equal to
     the name in the exception, the suggestion will include
     ‘self.<NAME>’ instead of the closest match in the method scope.
     (Contributed by Pablo Galindo in gh-99139(2).)

          >>> class A:
          ...    def __init__(self):
          ...        self.blech = 1
          ...
          ...    def foo(self):
          ...        somethin = blech
          ...
          >>> A().foo()
          Traceback (most recent call last):
            File "<stdin>", line 1
              somethin = blech
                         ^^^^^
          NameError: name 'blech' is not defined. Did you mean: 'self.blech'?

   * Improve the *note SyntaxError: 172. error message when the user
     types ‘import x from y’ instead of ‘from y import x’.  (Contributed
     by Pablo Galindo in gh-98931(3).)

          >>> import a.y.z from b.y.z
          Traceback (most recent call last):
            File "<stdin>", line 1
              import a.y.z from b.y.z
              ^^^^^^^^^^^^^^^^^^^^^^^
          SyntaxError: Did you mean to use 'from ... import ...' instead?

   * *note ImportError: 3f2. exceptions raised from failed ‘from
     <module> import <name>’ statements now include suggestions for the
     value of ‘<name>’ based on the available names in ‘<module>’.
     (Contributed by Pablo Galindo in gh-91058(4).)

          >>> from collections import chainmap
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          ImportError: cannot import name 'chainmap' from 'collections'. Did you mean: 'ChainMap'?

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98254

   (2) https://github.com/python/cpython/issues/99139

   (3) https://github.com/python/cpython/issues/98931

   (4) https://github.com/python/cpython/issues/91058


File: python.info,  Node: New Features Related to Type Hints,  Next: Other Language Changes<2>,  Prev: New Features<3>,  Up: What's New In Python 3 12

1.2.3 New Features Related to Type Hints
----------------------------------------

This section covers major changes affecting type hints(1) and the *note
typing: ed. module.

* Menu:

* PEP 692; Using TypedDict for more precise **kwargs typing: PEP 692 Using TypedDict for more precise **kwargs typing.
* PEP 698; Override Decorator for Static Typing: PEP 698 Override Decorator for Static Typing.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/


File: python.info,  Node: PEP 692 Using TypedDict for more precise **kwargs typing,  Next: PEP 698 Override Decorator for Static Typing,  Up: New Features Related to Type Hints

1.2.3.1 PEP 692: Using ‘TypedDict’ for more precise ‘**kwargs’ typing
.....................................................................

Typing ‘**kwargs’ in a function signature as introduced by PEP 484(1)
allowed for valid annotations only in cases where all of the ‘**kwargs’
were of the same type.

PEP 692(2) specifies a more precise way of typing ‘**kwargs’ by relying
on typed dictionaries:

     from typing import TypedDict, Unpack

     class Movie(TypedDict):
       name: str
       year: int

     def foo(**kwargs: Unpack[Movie]): ...

See PEP 692(3) for more details.

(Contributed by Franek Magiera in gh-103629(4).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0692/

   (3) https://peps.python.org/pep-0692/

   (4) https://github.com/python/cpython/issues/103629


File: python.info,  Node: PEP 698 Override Decorator for Static Typing,  Prev: PEP 692 Using TypedDict for more precise **kwargs typing,  Up: New Features Related to Type Hints

1.2.3.2 PEP 698: Override Decorator for Static Typing
.....................................................

A new decorator *note typing.override(): 417. has been added to the
*note typing: ed. module.  It indicates to type checkers that the method
is intended to override a method in a superclass.  This allows type
checkers to catch mistakes where a method that is intended to override
something in a base class does not in fact do so.

Example:

     from typing import override

     class Base:
       def get_color(self) -> str:
         return "blue"

     class GoodChild(Base):
       @override  # ok: overrides Base.get_color
       def get_color(self) -> str:
         return "yellow"

     class BadChild(Base):
       @override  # type checker error: does not override Base.get_color
       def get_colour(self) -> str:
         return "red"

See PEP 698(1) for more details.

(Contributed by Steven Troxler in gh-101561(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0698/

   (2) https://github.com/python/cpython/issues/101561


File: python.info,  Node: Other Language Changes<2>,  Next: New Modules<2>,  Prev: New Features Related to Type Hints,  Up: What's New In Python 3 12

1.2.4 Other Language Changes
----------------------------

   * The parser now raises *note SyntaxError: 172. when parsing source
     code containing null bytes.  (Contributed by Pablo Galindo in
     gh-96670(1).)

   * A backslash-character pair that is not a valid escape sequence now
     generates a *note SyntaxWarning: 432, instead of *note
     DeprecationWarning: 18a.  For example, ‘re.compile("\d+\.\d+")’ now
     emits a *note SyntaxWarning: 432. (‘"\d"’ is an invalid escape
     sequence, use raw strings for regular expression:
     ‘re.compile(r"\d+\.\d+")’).  In a future Python version, *note
     SyntaxError: 172. will eventually be raised, instead of *note
     SyntaxWarning: 432.  (Contributed by Victor Stinner in
     gh-98401(2).)

   * Octal escapes with value larger than ‘0o377’ (ex: ‘"\477"’),
     deprecated in Python 3.11, now produce a *note SyntaxWarning: 432,
     instead of *note DeprecationWarning: 18a.  In a future Python
     version they will be eventually a *note SyntaxError: 172.
     (Contributed by Victor Stinner in gh-98401(3).)

   * Variables used in the target part of comprehensions that are not
     stored to can now be used in assignment expressions (‘:=’).  For
     example, in ‘[(b := 1) for a, b.prop in some_iter]’, the assignment
     to ‘b’ is now allowed.  Note that assigning to variables stored to
     in the target part of comprehensions (like ‘a’) is still
     disallowed, as per PEP 572(4).  (Contributed by Nikita Sobolev in
     gh-100581(5).)

   * Exceptions raised in a class or type's ‘__set_name__’ method are no
     longer wrapped by a *note RuntimeError: 17a.  Context information
     is added to the exception as a PEP 678(6) note.  (Contributed by
     Irit Katriel in gh-77757(7).)

   * When a ‘try-except*’ construct handles the entire *note
     ExceptionGroup: 19b. and raises one other exception, that exception
     is no longer wrapped in an *note ExceptionGroup: 19b.  Also changed
     in version 3.11.4.  (Contributed by Irit Katriel in gh-103590(8).)

   * The Garbage Collector now runs only on the eval breaker mechanism
     of the Python bytecode evaluation loop instead of object
     allocations.  The GC can also run when *note PyErr_CheckSignals():
     433. is called so C extensions that need to run for a long time
     without executing any Python code also have a chance to execute the
     GC periodically.  (Contributed by Pablo Galindo in gh-97922(9).)

   * All builtin and extension callables expecting boolean parameters
     now accept arguments of any type instead of just *note bool: 434.
     and *note int: 238.  (Contributed by Serhiy Storchaka in
     gh-60203(10).)

   * *note memoryview: 435. now supports the half-float type (the "e"
     format code).  (Contributed by Donghee Na and Antoine Pitrou in
     gh-90751(11).)

   * *note slice: 436. objects are now hashable, allowing them to be
     used as dict keys and set items.  (Contributed by Will Bradshaw,
     Furkan Onder, and Raymond Hettinger in gh-101264(12).)

   * *note sum(): 437. now uses Neumaier summation to improve accuracy
     and commutativity when summing floats or mixed ints and floats.
     (Contributed by Raymond Hettinger in gh-100425(13).)

   * *note ast.parse(): 18d. now raises *note SyntaxError: 172. instead
     of *note ValueError: 1e3. when parsing source code containing null
     bytes.  (Contributed by Pablo Galindo in gh-96670(14).)

   * The extraction methods in *note tarfile: c8, and *note
     shutil.unpack_archive(): 438, have a new a 'filter' argument that
     allows limiting tar features than may be surprising or dangerous,
     such as creating files outside the destination directory.  See
     *note tarfile extraction filters: 439. for details.  In Python
     3.14, the default will switch to ‘'data'’.  (Contributed by Petr
     Viktorin in PEP 706(15).)

   * *note types.MappingProxyType: 43a. instances are now hashable if
     the underlying mapping is hashable.  (Contributed by Serhiy
     Storchaka in gh-87995(16).)

   * Add *note support for the perf profiler: 174. through the new
     environment variable *note PYTHONPERFSUPPORT: 43b. and command-line
     option *note -X perf: 15c, as well as the new *note
     sys.activate_stack_trampoline(): 43c, *note
     sys.deactivate_stack_trampoline(): 43d, and *note
     sys.is_stack_trampoline_active(): 43e. functions.  (Design by Pablo
     Galindo.  Contributed by Pablo Galindo and Christian Heimes with
     contributions from Gregory P. Smith [Google] and Mark Shannon in
     gh-96123(17).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/96670

   (2) https://github.com/python/cpython/issues/98401

   (3) https://github.com/python/cpython/issues/98401

   (4) https://peps.python.org/pep-0572/

   (5) https://github.com/python/cpython/issues/100581

   (6) https://peps.python.org/pep-0678/

   (7) https://github.com/python/cpython/issues/77757

   (8) https://github.com/python/cpython/issues/103590

   (9) https://github.com/python/cpython/issues/97922

   (10) https://github.com/python/cpython/issues/60203

   (11) https://github.com/python/cpython/issues/90751

   (12) https://github.com/python/cpython/issues/101264

   (13) https://github.com/python/cpython/issues/100425

   (14) https://github.com/python/cpython/issues/96670

   (15) https://peps.python.org/pep-0706/

   (16) https://github.com/python/cpython/issues/87995

   (17) https://github.com/python/cpython/issues/96123


File: python.info,  Node: New Modules<2>,  Next: Improved Modules<2>,  Prev: Other Language Changes<2>,  Up: What's New In Python 3 12

1.2.5 New Modules
-----------------

   * None.


File: python.info,  Node: Improved Modules<2>,  Next: Optimizations<2>,  Prev: New Modules<2>,  Up: What's New In Python 3 12

1.2.6 Improved Modules
----------------------

* Menu:

* array: array<2>.
* asyncio: asyncio<2>.
* calendar::
* csv::
* dis: dis<2>.
* fractions: fractions<2>.
* importlib.resources: importlib resources.
* inspect::
* itertools: itertools<2>.
* math: math<2>.
* os: os<2>.
* os.path: os path<2>.
* pathlib: pathlib<3>.
* pdb: pdb<2>.
* random: random<2>.
* shutil: shutil<2>.
* sqlite3: sqlite3<2>.
* statistics: statistics<2>.
* sys: sys<3>.
* tempfile: tempfile<2>.
* threading::
* tkinter: tkinter<2>.
* tokenize::
* types: types<2>.
* typing: typing<3>.
* unicodedata: unicodedata<2>.
* unittest: unittest<2>.
* uuid::


File: python.info,  Node: array<2>,  Next: asyncio<2>,  Up: Improved Modules<2>

1.2.6.1 array
.............

   * The *note array.array: 185. class now supports subscripting, making
     it a *note generic type: 405.  (Contributed by Jelle Zijlstra in
     gh-98658(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98658


File: python.info,  Node: asyncio<2>,  Next: calendar,  Prev: array<2>,  Up: Improved Modules<2>

1.2.6.2 asyncio
...............

   * The performance of writing to sockets in *note asyncio: 8. has been
     significantly improved.  ‘asyncio’ now avoids unnecessary copying
     when writing to sockets and uses *note sendmsg(): 443. if the
     platform supports it.  (Contributed by Kumar Aditya in
     gh-91166(1).)

   * Add *note asyncio.eager_task_factory(): 444. and *note
     asyncio.create_eager_task_factory(): 445. functions to allow opting
     an event loop in to eager task execution, making some use-cases 2x
     to 5x faster.  (Contributed by Jacob Bower & Itamar Oren in
     gh-102853(2), gh-104140(3), and gh-104138(4))

   * On Linux, *note asyncio: 8. uses *note asyncio.PidfdChildWatcher:
     446. by default if *note os.pidfd_open(): 447. is available and
     functional instead of *note asyncio.ThreadedChildWatcher: 448.
     (Contributed by Kumar Aditya in gh-98024(5).)

   * The event loop now uses the best available child watcher for each
     platform (*note asyncio.PidfdChildWatcher: 446. if supported and
     *note asyncio.ThreadedChildWatcher: 448. otherwise), so manually
     configuring a child watcher is not recommended.  (Contributed by
     Kumar Aditya in gh-94597(6).)

   * Add 'loop_factory' parameter to *note asyncio.run(): 449. to allow
     specifying a custom event loop factory.  (Contributed by Kumar
     Aditya in gh-99388(7).)

   * Add C implementation of *note asyncio.current_task(): 44a. for
     4x-6x speedup.  (Contributed by Itamar Oren and Pranav Thulasiram
     Bhat in gh-100344(8).)

   * *note asyncio.iscoroutine(): 44b. now returns ‘False’ for
     generators as *note asyncio: 8. does not support legacy
     generator-based coroutines.  (Contributed by Kumar Aditya in
     gh-102748(9).)

   * *note asyncio.wait(): 44c. and *note asyncio.as_completed(): 18f.
     now accepts generators yielding tasks.  (Contributed by Kumar
     Aditya in gh-78530(10).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/91166

   (2) https://github.com/python/cpython/issues/102853

   (3) https://github.com/python/cpython/issues/104140

   (4) https://github.com/python/cpython/issues/104138

   (5) https://github.com/python/cpython/issues/98024

   (6) https://github.com/python/cpython/issues/94597

   (7) https://github.com/python/cpython/issues/99388

   (8) https://github.com/python/cpython/issues/100344

   (9) https://github.com/python/cpython/issues/102748

   (10) https://github.com/python/cpython/issues/78530


File: python.info,  Node: calendar,  Next: csv,  Prev: asyncio<2>,  Up: Improved Modules<2>

1.2.6.3 calendar
................

   * Add enums *note calendar.Month: 44e. and *note calendar.Day: 44f.
     defining months of the year and days of the week.  (Contributed by
     Prince Roshan in gh-103636(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/103636


File: python.info,  Node: csv,  Next: dis<2>,  Prev: calendar,  Up: Improved Modules<2>

1.2.6.4 csv
...........

   * Add *note csv.QUOTE_NOTNULL: 451. and *note csv.QUOTE_STRINGS: 452.
     flags to provide finer grained control of ‘None’ and empty strings
     by *note reader: 453. and *note writer: 454. objects.


File: python.info,  Node: dis<2>,  Next: fractions<2>,  Prev: csv,  Up: Improved Modules<2>

1.2.6.5 dis
...........

   * Pseudo instruction opcodes (which are used by the compiler but do
     not appear in executable bytecode) are now exposed in the *note
     dis: 30. module.  *note HAVE_ARGUMENT: 456. is still relevant to
     real opcodes, but it is not useful for pseudo instructions.  Use
     the new *note dis.hasarg: 27e. collection instead.  (Contributed by
     Irit Katriel in gh-94216(1).)

   * Add the *note dis.hasexc: 457. collection to signify instructions
     that set an exception handler.  (Contributed by Irit Katriel in
     gh-94216(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94216

   (2) https://github.com/python/cpython/issues/94216


File: python.info,  Node: fractions<2>,  Next: importlib resources,  Prev: dis<2>,  Up: Improved Modules<2>

1.2.6.6 fractions
.................

   * Objects of type *note fractions.Fraction: 1c8. now support
     float-style formatting.  (Contributed by Mark Dickinson in
     gh-100161(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100161


File: python.info,  Node: importlib resources,  Next: inspect,  Prev: fractions<2>,  Up: Improved Modules<2>

1.2.6.7 importlib.resources
...........................

   * *note importlib.resources.as_file(): 45a. now supports resource
     directories.  (Contributed by Jason R. Coombs in gh-97930(1).)

   * Rename first parameter of *note importlib.resources.files(): 45b.
     to 'anchor'.  (Contributed by Jason R. Coombs in gh-100598(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97930

   (2) https://github.com/python/cpython/issues/100598


File: python.info,  Node: inspect,  Next: itertools<2>,  Prev: importlib resources,  Up: Improved Modules<2>

1.2.6.8 inspect
...............

   * Add *note inspect.markcoroutinefunction(): 45d. to mark sync
     functions that return a *note coroutine: 45e. for use with *note
     inspect.iscoroutinefunction(): 2c5.  (Contributed by Carlton Gibson
     in gh-99247(1).)

   * Add *note inspect.getasyncgenstate(): 45f. and *note
     inspect.getasyncgenlocals(): 460. for determining the current state
     of asynchronous generators.  (Contributed by Thomas Krennwallner in
     gh-79940(2).)

   * The performance of *note inspect.getattr_static(): 461. has been
     considerably improved.  Most calls to the function should be at
     least 2x faster than they were in Python 3.11.  (Contributed by
     Alex Waygood in gh-103193(3).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99247

   (2) https://github.com/python/cpython/issues/79940

   (3) https://github.com/python/cpython/issues/103193


File: python.info,  Node: itertools<2>,  Next: math<2>,  Prev: inspect,  Up: Improved Modules<2>

1.2.6.9 itertools
.................

   * Add *note itertools.batched(): 1e2. for collecting into even-sized
     tuples where the last batch may be shorter than the rest.
     (Contributed by Raymond Hettinger in gh-98363(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98363


File: python.info,  Node: math<2>,  Next: os<2>,  Prev: itertools<2>,  Up: Improved Modules<2>

1.2.6.10 math
.............

   * Add *note math.sumprod(): 464. for computing a sum of products.
     (Contributed by Raymond Hettinger in gh-100485(1).)

   * Extend *note math.nextafter(): 465. to include a 'steps' argument
     for moving up or down multiple steps at a time.  (Contributed by
     Matthias Goergens, Mark Dickinson, and Raymond Hettinger in
     gh-94906(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100485

   (2) https://github.com/python/cpython/issues/94906


File: python.info,  Node: os<2>,  Next: os path<2>,  Prev: math<2>,  Up: Improved Modules<2>

1.2.6.11 os
...........

   * Add *note os.PIDFD_NONBLOCK: 467. to open a file descriptor for a
     process with *note os.pidfd_open(): 447. in non-blocking mode.
     (Contributed by Kumar Aditya in gh-93312(1).)

   * *note os.DirEntry: 468. now includes an *note
     os.DirEntry.is_junction(): 469. method to check if the entry is a
     junction.  (Contributed by Charles Machalow in gh-99547(2).)

   * Add *note os.listdrives(): 46a, *note os.listvolumes(): 46b. and
     *note os.listmounts(): 46c. functions on Windows for enumerating
     drives, volumes and mount points.  (Contributed by Steve Dower in
     gh-102519(3).)

   * *note os.stat(): 46d. and *note os.lstat(): 46e. are now more
     accurate on Windows.  The ‘st_birthtime’ field will now be filled
     with the creation time of the file, and ‘st_ctime’ is deprecated
     but still contains the creation time (but in the future will return
     the last metadata change, for consistency with other platforms).
     ‘st_dev’ may be up to 64 bits and ‘st_ino’ up to 128 bits depending
     on your file system, and ‘st_rdev’ is always set to zero rather
     than incorrect values.  Both functions may be significantly faster
     on newer releases of Windows.  (Contributed by Steve Dower in
     gh-99726(4).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/93312

   (2) https://github.com/python/cpython/issues/99547

   (3) https://github.com/python/cpython/issues/102519

   (4) https://github.com/python/cpython/issues/99726


File: python.info,  Node: os path<2>,  Next: pathlib<3>,  Prev: os<2>,  Up: Improved Modules<2>

1.2.6.12 os.path
................

   * Add *note os.path.isjunction(): 470. to check if a given path is a
     junction.  (Contributed by Charles Machalow in gh-99547(1).)

   * Add *note os.path.splitroot(): 471. to split a path into a triad
     ‘(drive, root, tail)’.  (Contributed by Barney Gale in
     gh-101000(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99547

   (2) https://github.com/python/cpython/issues/101000


File: python.info,  Node: pathlib<3>,  Next: pdb<2>,  Prev: os path<2>,  Up: Improved Modules<2>

1.2.6.13 pathlib
................

   * Add support for subclassing *note pathlib.PurePath: 473. and *note
     pathlib.Path: 20a, plus their Posix- and Windows-specific variants.
     Subclasses may override the *note pathlib.PurePath.with_segments():
     474. method to pass information between path instances.

   * Add *note pathlib.Path.walk(): 475. for walking the directory trees
     and generating all file or directory names within them, similar to
     *note os.walk(): 476.  (Contributed by Stanislav Zmiev in
     gh-90385(1).)

   * Add 'walk_up' optional parameter to *note
     pathlib.PurePath.relative_to(): 2ab. to allow the insertion of ‘..’
     entries in the result; this behavior is more consistent with *note
     os.path.relpath(): 477.  (Contributed by Domenico Ragusa in
     gh-84538(2).)

   * Add *note pathlib.Path.is_junction(): 478. as a proxy to *note
     os.path.isjunction(): 470.  (Contributed by Charles Machalow in
     gh-99547(3).)

   * Add 'case_sensitive' optional parameter to *note
     pathlib.Path.glob(): 20e, *note pathlib.Path.rglob(): 20f. and
     *note pathlib.PurePath.match(): 479. for matching the path's case
     sensitivity, allowing for more precise control over the matching
     process.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/90385

   (2) https://github.com/python/cpython/issues/84538

   (3) https://github.com/python/cpython/issues/99547


File: python.info,  Node: pdb<2>,  Next: random<2>,  Prev: pathlib<3>,  Up: Improved Modules<2>

1.2.6.14 pdb
............

   * Add convenience variables to hold values temporarily for debug
     session and provide quick access to values like the current frame
     or the return value.  (Contributed by Tian Gao in gh-103693(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/103693


File: python.info,  Node: random<2>,  Next: shutil<2>,  Prev: pdb<2>,  Up: Improved Modules<2>

1.2.6.15 random
...............

   * Add *note random.binomialvariate(): 47c.  (Contributed by Raymond
     Hettinger in gh-81620(1).)

   * Add a default of ‘lambd=1.0’ to *note random.expovariate(): 47d.
     (Contributed by Raymond Hettinger in gh-100234(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/81620

   (2) https://github.com/python/cpython/issues/100234


File: python.info,  Node: shutil<2>,  Next: sqlite3<2>,  Prev: random<2>,  Up: Improved Modules<2>

1.2.6.16 shutil
...............

   * *note shutil.make_archive(): 47f. now passes the 'root_dir'
     argument to custom archivers which support it.  In this case it no
     longer temporarily changes the current working directory of the
     process to 'root_dir' to perform archiving.  (Contributed by Serhiy
     Storchaka in gh-74696(1).)

   * *note shutil.rmtree(): 2d8. now accepts a new argument 'onexc'
     which is an error handler like 'onerror' but which expects an
     exception instance rather than a '(typ, val, tb)' triplet.
     'onerror' is deprecated.  (Contributed by Irit Katriel in
     gh-102828(2).)

   * *note shutil.which(): 480. now consults the 'PATHEXT' environment
     variable to find matches within 'PATH' on Windows even when the
     given 'cmd' includes a directory component.  (Contributed by
     Charles Machalow in gh-103179(3).)

     *note shutil.which(): 480. will call
     ‘NeedCurrentDirectoryForExePathW’ when querying for executables on
     Windows to determine if the current working directory should be
     prepended to the search path.  (Contributed by Charles Machalow in
     gh-103179(4).)

     *note shutil.which(): 480. will return a path matching the 'cmd'
     with a component from ‘PATHEXT’ prior to a direct match elsewhere
     in the search path on Windows.  (Contributed by Charles Machalow in
     gh-103179(5).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/74696

   (2) https://github.com/python/cpython/issues/102828

   (3) https://github.com/python/cpython/issues/103179

   (4) https://github.com/python/cpython/issues/103179

   (5) https://github.com/python/cpython/issues/103179


File: python.info,  Node: sqlite3<2>,  Next: statistics<2>,  Prev: shutil<2>,  Up: Improved Modules<2>

1.2.6.17 sqlite3
................

   * Add a *note command-line interface: 40d.  (Contributed by Erlend E.
     Aasland in gh-77617(1).)

   * Add the *note sqlite3.Connection.autocommit: 482. attribute to
     *note sqlite3.Connection: 226. and the 'autocommit' parameter to
     *note sqlite3.connect(): 288. to control PEP 249(2)-compliant *note
     transaction handling: 483.  (Contributed by Erlend E. Aasland in
     gh-83638(3).)

   * Add 'entrypoint' keyword-only parameter to *note
     sqlite3.Connection.load_extension(): 484, for overriding the SQLite
     extension entry point.  (Contributed by Erlend E. Aasland in
     gh-103015(4).)

   * Add *note sqlite3.Connection.getconfig(): 485. and *note
     sqlite3.Connection.setconfig(): 486. to *note sqlite3.Connection:
     226. to make configuration changes to a database connection.
     (Contributed by Erlend E. Aasland in gh-103489(5).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/77617

   (2) https://peps.python.org/pep-0249/

   (3) https://github.com/python/cpython/issues/83638

   (4) https://github.com/python/cpython/issues/103015

   (5) https://github.com/python/cpython/issues/103489


File: python.info,  Node: statistics<2>,  Next: sys<3>,  Prev: sqlite3<2>,  Up: Improved Modules<2>

1.2.6.18 statistics
...................

   * Extend *note statistics.correlation(): 488. to include as a
     ‘ranked’ method for computing the Spearman correlation of ranked
     data.  (Contributed by Raymond Hettinger in gh-95861(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/95861


File: python.info,  Node: sys<3>,  Next: tempfile<2>,  Prev: statistics<2>,  Up: Improved Modules<2>

1.2.6.19 sys
............

   * Add the *note sys.monitoring: c4. namespace to expose the new *note
     PEP 669: 409. monitoring API. (Contributed by Mark Shannon in
     gh-103082(1).)

   * Add *note sys.activate_stack_trampoline(): 43c. and *note
     sys.deactivate_stack_trampoline(): 43d. for activating and
     deactivating stack profiler trampolines, and *note
     sys.is_stack_trampoline_active(): 43e. for querying if stack
     profiler trampolines are active.  (Contributed by Pablo Galindo and
     Christian Heimes with contributions from Gregory P. Smith [Google]
     and Mark Shannon in gh-96123(2).)

   * Add *note sys.last_exc: 48a. which holds the last unhandled
     exception that was raised (for post-mortem debugging use cases).
     Deprecate the three fields that have the same information in its
     legacy form: *note sys.last_type: 48b, *note sys.last_value: 48c.
     and *note sys.last_traceback: 48d.  (Contributed by Irit Katriel in
     gh-102778(3).)

   * *note sys._current_exceptions(): 48e. now returns a mapping from
     thread-id to an exception instance, rather than to a ‘(typ, exc,
     tb)’ tuple.  (Contributed by Irit Katriel in gh-103176(4).)

   * *note sys.setrecursionlimit(): 48f. and *note
     sys.getrecursionlimit(): 490.  The recursion limit now applies only
     to Python code.  Builtin functions do not use the recursion limit,
     but are protected by a different mechanism that prevents recursion
     from causing a virtual machine crash.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/103082

   (2) https://github.com/python/cpython/issues/96123

   (3) https://github.com/python/cpython/issues/102778

   (4) https://github.com/python/cpython/issues/103176


File: python.info,  Node: tempfile<2>,  Next: threading,  Prev: sys<3>,  Up: Improved Modules<2>

1.2.6.20 tempfile
.................

   * The *note tempfile.NamedTemporaryFile: 492. function has a new
     optional parameter 'delete_on_close' (Contributed by Evgeny Zorin
     in gh-58451(1).)

   * *note tempfile.mkdtemp(): 200. now always returns an absolute path,
     even if the argument provided to the 'dir' parameter is a relative
     path.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/58451


File: python.info,  Node: threading,  Next: tkinter<2>,  Prev: tempfile<2>,  Up: Improved Modules<2>

1.2.6.21 threading
..................

   * Add *note threading.settrace_all_threads(): 494. and *note
     threading.setprofile_all_threads(): 495. that allow to set tracing
     and profiling functions in all running threads in addition to the
     calling one.  (Contributed by Pablo Galindo in gh-93503(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/93503


File: python.info,  Node: tkinter<2>,  Next: tokenize,  Prev: threading,  Up: Improved Modules<2>

1.2.6.22 tkinter
................

   * ‘tkinter.Canvas.coords()’ now flattens its arguments.  It now
     accepts not only coordinates as separate arguments (‘x1, y1, x2,
     y2, ...’) and a sequence of coordinates (‘[x1, y1, x2, y2, ...]’),
     but also coordinates grouped in pairs (‘(x1, y1), (x2, y2), ...’
     and ‘[(x1, y1), (x2, y2), ...]’), like ‘create_*()’ methods.
     (Contributed by Serhiy Storchaka in gh-94473(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94473


File: python.info,  Node: tokenize,  Next: types<2>,  Prev: tkinter<2>,  Up: Improved Modules<2>

1.2.6.23 tokenize
.................

   * The *note tokenize: e4. module includes the changes introduced in
     PEP 701(1).  (Contributed by Marta Gómez Macías and Pablo Galindo
     in gh-102856(2).)  See *note Porting to Python 3.12: 498. for more
     information on the changes to the *note tokenize: e4. module.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0701/

   (2) https://github.com/python/cpython/issues/102856


File: python.info,  Node: types<2>,  Next: typing<3>,  Prev: tokenize,  Up: Improved Modules<2>

1.2.6.24 types
..............

   * Add *note types.get_original_bases(): 49a. to allow for further
     introspection of *note ユーザー定義のジェネリック型: 49b. when
     subclassed.  (Contributed by James Hilton-Balfe and Alex Waygood in
     gh-101827(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101827


File: python.info,  Node: typing<3>,  Next: unicodedata<2>,  Prev: types<2>,  Up: Improved Modules<2>

1.2.6.25 typing
...............

   * *note isinstance(): 40e. checks against *note runtime-checkable
     protocols: 40f. now use *note inspect.getattr_static(): 461. rather
     than *note hasattr(): 49e. to lookup whether attributes exist.
     This means that descriptors and *note __getattr__(): 49f. methods
     are no longer unexpectedly evaluated during ‘isinstance()’ checks
     against runtime-checkable protocols.  However, it may also mean
     that some objects which used to be considered instances of a
     runtime-checkable protocol may no longer be considered instances of
     that protocol on Python 3.12+, and vice versa.  Most users are
     unlikely to be affected by this change.  (Contributed by Alex
     Waygood in gh-102433(1).)

   * The members of a runtime-checkable protocol are now considered
     "frozen" at runtime as soon as the class has been created.
     Monkey-patching attributes onto a runtime-checkable protocol will
     still work, but will have no impact on *note isinstance(): 40e.
     checks comparing objects to the protocol.  For example:

          >>> from typing import Protocol, runtime_checkable
          >>> @runtime_checkable
          ... class HasX(Protocol):
          ...     x = 1
          ...
          >>> class Foo: ...
          ...
          >>> f = Foo()
          >>> isinstance(f, HasX)
          False
          >>> f.x = 1
          >>> isinstance(f, HasX)
          True
          >>> HasX.y = 2
          >>> isinstance(f, HasX)  # unchanged, even though HasX now also has a "y" attribute
          True

     This change was made in order to speed up ‘isinstance()’ checks
     against runtime-checkable protocols.

   * The performance profile of *note isinstance(): 40e. checks against
     *note runtime-checkable protocols: 40f. has changed significantly.
     Most ‘isinstance()’ checks against protocols with only a few
     members should be at least 2x faster than in 3.11, and some may be
     20x faster or more.  However, ‘isinstance()’ checks against
     protocols with many members may be slower than in Python 3.11.
     (Contributed by Alex Waygood in gh-74690(2) and gh-103193(3).)

   * All *note typing.TypedDict: 148. and *note typing.NamedTuple: 290.
     classes now have the ‘__orig_bases__’ attribute.  (Contributed by
     Adrian Garcia Badaracco in gh-103699(4).)

   * Add ‘frozen_default’ parameter to *note
     typing.dataclass_transform(): 4a0.  (Contributed by Erik De Bonte
     in gh-99957(5).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102433

   (2) https://github.com/python/cpython/issues/74690

   (3) https://github.com/python/cpython/issues/103193

   (4) https://github.com/python/cpython/issues/103699

   (5) https://github.com/python/cpython/issues/99957


File: python.info,  Node: unicodedata<2>,  Next: unittest<2>,  Prev: typing<3>,  Up: Improved Modules<2>

1.2.6.26 unicodedata
....................

   * The Unicode database has been updated to version 15.0.0.
     (Contributed by Benjamin Peterson in gh-96734(1)).

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/96734


File: python.info,  Node: unittest<2>,  Next: uuid,  Prev: unicodedata<2>,  Up: Improved Modules<2>

1.2.6.27 unittest
.................

Add a ‘--durations’ command line option, showing the N slowest test
cases:

     python3 -m unittest --durations=3 lib.tests.test_threading
     .....
     Slowest test durations
     ----------------------------------------------------------------------
     1.210s     test_timeout (Lib.test.test_threading.BarrierTests)
     1.003s     test_default_timeout (Lib.test.test_threading.BarrierTests)
     0.518s     test_timeout (Lib.test.test_threading.EventTests)

     (0.000 durations hidden.  Use -v to show these durations.)
     ----------------------------------------------------------------------
     Ran 158 tests in 9.869s

     OK (skipped=3)

(Contributed by Giampaolo Rodola in gh-48330(1))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/48330


File: python.info,  Node: uuid,  Prev: unittest<2>,  Up: Improved Modules<2>

1.2.6.28 uuid
.............

   * Add a *note command-line interface: 410.  (Contributed by Adam
     Chhina in gh-88597(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/88597


File: python.info,  Node: Optimizations<2>,  Next: CPython bytecode changes,  Prev: Improved Modules<2>,  Up: What's New In Python 3 12

1.2.7 Optimizations
-------------------

   * Remove ‘wstr’ and ‘wstr_length’ members from Unicode objects.  It
     reduces object size by 8 or 16 bytes on 64bit platform.  ( PEP
     623(1)) (Contributed by Inada Naoki in gh-92536(2).)

   * Add experimental support for using the BOLT binary optimizer in the
     build process, which improves performance by 1-5%.  (Contributed by
     Kevin Modzelewski in gh-90536(3) and tuned by Donghee Na in
     gh-101525(4))

   * Speed up the regular expression substitution (functions *note
     re.sub(): 283. and *note re.subn(): 284. and corresponding
     ‘re.Pattern’ methods) for replacement strings containing group
     references by 2-3 times.  (Contributed by Serhiy Storchaka in
     gh-91524(5).)

   * Speed up *note asyncio.Task: 4a5. creation by deferring expensive
     string formatting.  (Contributed by Itamar Oren in gh-103793(6).)

   * The *note tokenize.tokenize(): 4a6. and *note
     tokenize.generate_tokens(): 4a7. functions are up to 64% faster as
     a side effect of the changes required to cover PEP 701(7) in the
     *note tokenize: e4. module.  (Contributed by Marta Gómez Macías and
     Pablo Galindo in gh-102856(8).)

   * Speed up *note super(): 4a8. method calls and attribute loads via
     the new *note LOAD_SUPER_ATTR: 4a9. instruction.  (Contributed by
     Carl Meyer and Vladimir Matveev in gh-103497(9).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0623/

   (2) https://github.com/python/cpython/issues/92536

   (3) https://github.com/python/cpython/issues/90536

   (4) https://github.com/python/cpython/issues/101525

   (5) https://github.com/python/cpython/issues/91524

   (6) https://github.com/python/cpython/issues/103793

   (7) https://peps.python.org/pep-0701/

   (8) https://github.com/python/cpython/issues/102856

   (9) https://github.com/python/cpython/issues/103497


File: python.info,  Node: CPython bytecode changes,  Next: Demos and Tools,  Prev: Optimizations<2>,  Up: What's New In Python 3 12

1.2.8 CPython bytecode changes
------------------------------

   * Remove the ‘LOAD_METHOD’ instruction.  It has been merged into
     *note LOAD_ATTR: 4ab.  *note LOAD_ATTR: 4ab. will now behave like
     the old ‘LOAD_METHOD’ instruction if the low bit of its oparg is
     set.  (Contributed by Ken Jin in gh-93429(1).)

   * Remove the ‘JUMP_IF_FALSE_OR_POP’ and ‘JUMP_IF_TRUE_OR_POP’
     instructions.  (Contributed by Irit Katriel in gh-102859(2).)

   * Remove the ‘PRECALL’ instruction.  (Contributed by Mark Shannon in
     gh-92925(3).)

   * Add the *note BINARY_SLICE: 4ac. and *note STORE_SLICE: 4ad.
     instructions.  (Contributed by Mark Shannon in gh-94163(4).)

   * Add the *note CALL_INTRINSIC_1: 4ae. instructions.  (Contributed by
     Mark Shannon in gh-99005(5).)

   * Add the *note CALL_INTRINSIC_2: 4af. instruction.  (Contributed by
     Irit Katriel in gh-101799(6).)

   * Add the *note CLEANUP_THROW: 4b0. instruction.  (Contributed by
     Brandt Bucher in gh-90997(7).)

   * Add the ‘END_SEND’ instruction.  (Contributed by Mark Shannon in
     gh-103082(8).)

   * Add the *note LOAD_FAST_AND_CLEAR: 4b1. instruction as part of the
     implementation of PEP 709(9).  (Contributed by Carl Meyer in
     gh-101441(10).)

   * Add the *note LOAD_FAST_CHECK: 4b2. instruction.  (Contributed by
     Dennis Sweeney in gh-93143(11).)

   * Add the *note LOAD_FROM_DICT_OR_DEREF: 4b3, *note
     LOAD_FROM_DICT_OR_GLOBALS: 4b4, and *note LOAD_LOCALS: 4b5. opcodes
     as part of the implementation of PEP 695(12).  Remove the
     ‘LOAD_CLASSDEREF’ opcode, which can be replaced with *note
     LOAD_LOCALS: 4b5. plus *note LOAD_FROM_DICT_OR_DEREF: 4b3.
     (Contributed by Jelle Zijlstra in gh-103764(13).)

   * Add the *note LOAD_SUPER_ATTR: 4a9. instruction.  (Contributed by
     Carl Meyer and Vladimir Matveev in gh-103497(14).)

   * Add the *note RETURN_CONST: 4b6. instruction.  (Contributed by
     Wenyang Wang in gh-101632(15).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/93429

   (2) https://github.com/python/cpython/issues/102859

   (3) https://github.com/python/cpython/issues/92925

   (4) https://github.com/python/cpython/issues/94163

   (5) https://github.com/python/cpython/issues/99005

   (6) https://github.com/python/cpython/issues/101799

   (7) https://github.com/python/cpython/issues/90997

   (8) https://github.com/python/cpython/issues/103082

   (9) https://peps.python.org/pep-0709/

   (10) https://github.com/python/cpython/issues/101441

   (11) https://github.com/python/cpython/issues/93143

   (12) https://peps.python.org/pep-0695/

   (13) https://github.com/python/cpython/issues/103764

   (14) https://github.com/python/cpython/issues/103497

   (15) https://github.com/python/cpython/issues/101632


File: python.info,  Node: Demos and Tools,  Next: Deprecated,  Prev: CPython bytecode changes,  Up: What's New In Python 3 12

1.2.9 Demos and Tools
---------------------

   * Remove the ‘Tools/demo/’ directory which contained old demo
     scripts.  A copy can be found in the old-demos project(1).
     (Contributed by Victor Stinner in gh-97681(2).)

   * Remove outdated example scripts of the ‘Tools/scripts/’ directory.
     A copy can be found in the old-demos project(3).  (Contributed by
     Victor Stinner in gh-97669(4).)

   ---------- Footnotes ----------

   (1) https://github.com/gvanrossum/old-demos

   (2) https://github.com/python/cpython/issues/97681

   (3) https://github.com/gvanrossum/old-demos

   (4) https://github.com/python/cpython/issues/97669


File: python.info,  Node: Deprecated,  Next: Removed,  Prev: Demos and Tools,  Up: What's New In Python 3 12

1.2.10 Deprecated
-----------------

   * *note argparse: 5.: The 'type', 'choices', and 'metavar' parameters
     of ‘argparse.BooleanOptionalAction’ are deprecated and will be
     removed in 3.14.  (Contributed by Nikita Sobolev in gh-92248(1).)

   * *note ast: 7.: The following *note ast: 7. features have been
     deprecated in documentation since Python 3.8, now cause a *note
     DeprecationWarning: 18a. to be emitted at runtime when they are
     accessed or used, and will be removed in Python 3.14:

        * ‘ast.Num’

        * ‘ast.Str’

        * ‘ast.Bytes’

        * ‘ast.NameConstant’

        * ‘ast.Ellipsis’

     Use *note ast.Constant: 299. instead.  (Contributed by Serhiy
     Storchaka in gh-90953(2).)

   * *note asyncio: 8.:

        * The child watcher classes *note asyncio.MultiLoopChildWatcher:
          29a, *note asyncio.FastChildWatcher: 29b, *note
          asyncio.AbstractChildWatcher: 29c. and *note
          asyncio.SafeChildWatcher: 29d. are deprecated and will be
          removed in Python 3.14.  (Contributed by Kumar Aditya in
          gh-94597(3).)

        * *note asyncio.set_child_watcher(): 29e, *note
          asyncio.get_child_watcher(): 29f, *note
          asyncio.AbstractEventLoopPolicy.set_child_watcher(): 2a0. and
          *note asyncio.AbstractEventLoopPolicy.get_child_watcher():
          2a1. are deprecated and will be removed in Python 3.14.
          (Contributed by Kumar Aditya in gh-94597(4).)

        * The *note get_event_loop(): 2a2. method of the default event
          loop policy now emits a *note DeprecationWarning: 18a. 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(5).)

   * *note calendar: 10.: ‘calendar.January’ and ‘calendar.February’
     constants are deprecated and replaced by *note calendar.JANUARY:
     2d0. and *note calendar.FEBRUARY: 2d1.  (Contributed by Prince
     Roshan in gh-103636(6).)

   * *note collections.abc: 17.: Deprecated *note
     collections.abc.ByteString: 2a3.  Prefer ‘Sequence’ or *note
     collections.abc.Buffer: 2a4.  For use in typing, prefer a union,
     like ‘bytes | bytearray’, or *note collections.abc.Buffer: 2a4.
     (Contributed by Shantanu Jain in gh-91896(7).)

   * *note datetime: 28.: *note datetime.datetime: 1ae.'s *note
     utcnow(): 2d3. and *note utcfromtimestamp(): 2d4. are deprecated
     and will be removed in a future version.  Instead, use
     timezone-aware objects to represent datetimes in UTC: respectively,
     call *note now(): 4b9. and *note fromtimestamp(): 4ba. with the
     'tz' parameter set to *note datetime.UTC: 4bb.  (Contributed by
     Paul Ganssle in gh-103857(8).)

   * *note email: 32.: Deprecate the 'isdst' parameter in *note
     email.utils.localtime(): 2a5.  (Contributed by Alan Williams in
     gh-72346(9).)

   * *note importlib.abc: 6c.: Deprecated the following classes,
     scheduled for removal in Python 3.14:

        * ‘importlib.abc.ResourceReader’

        * ‘importlib.abc.Traversable’

        * ‘importlib.abc.TraversableResources’

     Use *note importlib.resources.abc: 70. classes instead:

        * *note importlib.resources.abc.Traversable: 1d4.

        * *note importlib.resources.abc.TraversableResources: 2a6.

     (Contributed by Jason R. Coombs and Hugo van Kemenade in
     gh-93963(10).)

   * *note itertools: 75.: Deprecate the support for copy, deepcopy, and
     pickle operations, which is undocumented, inefficient, historically
     buggy, and inconsistent.  This will be removed in 3.14 for a
     significant reduction in code volume and maintenance burden.
     (Contributed by Raymond Hettinger in gh-101588(11).)

   * *note multiprocessing: 86.: In Python 3.14, the default *note
     multiprocessing: 86. start method will change to a safer one on
     Linux, BSDs, and other non-macOS POSIX platforms where ‘'fork'’ is
     currently the default (gh-84559(12)).  Adding a runtime warning
     about this was deemed too disruptive as the majority of code is not
     expected to care.  Use the *note get_context(): 2a7. or *note
     set_start_method(): 2a8. APIs to explicitly specify when your code
     'requires' ‘'fork'’.  See *note contexts and start methods: 2a9.

   * *note pkgutil: 97.: *note pkgutil.find_loader(): 2ac. and *note
     pkgutil.get_loader(): 2ad. are deprecated and will be removed in
     Python 3.14; use *note importlib.util.find_spec(): 2ae. instead.
     (Contributed by Nikita Sobolev in gh-97850(13).)

   * *note pty: 9f.: The module has two undocumented ‘master_open()’ and
     ‘slave_open()’ functions that have been deprecated since Python 2
     but only gained a proper *note DeprecationWarning: 18a. in 3.12.
     Remove them in 3.14.  (Contributed by Soumendra Ganguly and Gregory
     P. Smith in gh-85984(14).)

   * *note os: 91.:

        * The ‘st_ctime’ fields return by *note os.stat(): 46d. and
          *note os.lstat(): 46e. on Windows are deprecated.  In a future
          release, they will contain the last metadata change time,
          consistent with other platforms.  For now, they still contain
          the creation time, which is also available in the new
          ‘st_birthtime’ field.  (Contributed by Steve Dower in
          gh-99726(15).)

        * On POSIX platforms, *note os.fork(): 17c. can now raise a
          *note DeprecationWarning: 18a. when it can detect being called
          from a multithreaded process.  There has always been a
          fundamental incompatibility with the POSIX platform when doing
          so.  Even if such code 'appeared' to work.  We added the
          warning to raise awareness as issues encountered by code doing
          this are becoming more frequent.  See the *note os.fork():
          17c. documentation for more details along with this discussion
          on fork being incompatible with threads(16) for 'why' we're
          now surfacing this longstanding platform compatibility problem
          to developers.

     When this warning appears due to usage of *note multiprocessing:
     86. or *note concurrent.futures: 1a. the fix is to use a different
     *note multiprocessing: 86. start method such as ‘"spawn"’ or
     ‘"forkserver"’.

   * *note shutil: b3.: The 'onerror' argument of *note shutil.rmtree():
     2d8. is deprecated; use 'onexc' instead.  (Contributed by Irit
     Katriel in gh-102828(17).)

   * *note sqlite3: ba.:

        * *note default adapters and converters: 4bc. are now
          deprecated.  Instead, use the *note
          適合関数と変換関数のレシピ集: 4bd. and tailor them to your
          needs.  (Contributed by Erlend E. Aasland in gh-90016(18).)

        * In *note execute(): 2b2, *note DeprecationWarning: 18a. is now
          emitted when *note named placeholders: 2b4. are used together
          with parameters supplied as a *note sequence: 4be. instead of
          as a *note dict: 237.  Starting from Python 3.14, using named
          placeholders with parameters supplied as a sequence will raise
          a *note ProgrammingError: 4bf.  (Contributed by Erlend E.
          Aasland in gh-101698(19).)

   * *note sys: c3.: The *note sys.last_type: 48b, *note sys.last_value:
     48c. and *note sys.last_traceback: 48d. fields are deprecated.  Use
     *note sys.last_exc: 48a. instead.  (Contributed by Irit Katriel in
     gh-102778(20).)

   * *note tarfile: c8.: Extracting tar archives without specifying
     'filter' is deprecated until Python 3.14, when ‘'data'’ filter will
     become the default.  See *note Extraction filters: 439. for
     details.

   * *note typing: ed.:

        * *note typing.Hashable: 4c0. and *note typing.Sized: 4c1,
          aliases for *note collections.abc.Hashable: 4c2. and *note
          collections.abc.Sized: 4c3. respectively, are deprecated.
          (gh-94309(21).)

        * *note typing.ByteString: 2b5, deprecated since Python 3.9, now
          causes a *note DeprecationWarning: 18a. to be emitted when it
          is used.  (Contributed by Alex Waygood in gh-91896(22).)

   * *note xml.etree.ElementTree: 10c.: The module now emits *note
     DeprecationWarning: 18a. when testing the truth value of an *note
     xml.etree.ElementTree.Element: 2e8.  Before, the Python
     implementation emitted *note FutureWarning: 3ee, and the C
     implementation emitted nothing.  (Contributed by Jacob Walls in
     gh-83122(23).)

   * The 3-arg signatures (type, value, traceback) of *note coroutine
     throw(): 4c4, *note generator throw(): 4c5. and *note async
     generator throw(): 4c6. are deprecated and may be removed in a
     future version of Python.  Use the single-arg versions of these
     functions instead.  (Contributed by Ofey Chan in gh-89874(24).)

   * *note DeprecationWarning: 18a. is now raised when *note
     __package__: 2b9. on a module differs from *note __spec__.parent:
     2ba. (previously it was *note ImportWarning: 4c7.).  (Contributed
     by Brett Cannon in gh-65961(25).)

   * Setting *note __package__: 2b9. or *note __cached__: 2b7. on a
     module is deprecated, and will cease to be set or taken into
     consideration by the import system in Python 3.14.  (Contributed by
     Brett Cannon in gh-65961(26).)

   * The bitwise inversion operator (‘~’) on bool is deprecated.  It
     will throw an error in Python 3.16.  Use ‘not’ for logical negation
     of bools instead.  In the rare case that you really need the
     bitwise inversion of the underlying ‘int’, convert to int
     explicitly: ‘~int(x)’.  (Contributed by Tim Hoffmann in
     gh-103487(27).)

   * Accessing *note co_lnotab: 2c1. on code objects was deprecated in
     Python 3.10 via PEP 626(28), but it only got a proper *note
     DeprecationWarning: 18a. in 3.12.  May be removed in 3.15.
     (Contributed by Nikita Sobolev in gh-101866(29).)

* Menu:

* Pending Removal in Python 3.13: Pending Removal in Python 3 13.
* Pending Removal in Python 3.14: Pending Removal in Python 3 14<3>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<3>.
* Pending removal in Python 3.16: Pending removal in Python 3 16<2>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<3>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92248

   (2) https://github.com/python/cpython/issues/90953

   (3) https://github.com/python/cpython/issues/94597

   (4) https://github.com/python/cpython/issues/94597

   (5) https://github.com/python/cpython/issues/100160

   (6) https://github.com/python/cpython/issues/103636

   (7) https://github.com/python/cpython/issues/91896

   (8) https://github.com/python/cpython/issues/103857

   (9) https://github.com/python/cpython/issues/72346

   (10) https://github.com/python/cpython/issues/93963

   (11) https://github.com/python/cpython/issues/101588

   (12) https://github.com/python/cpython/issues/84559

   (13) https://github.com/python/cpython/issues/97850

   (14) https://github.com/python/cpython/issues/85984

   (15) https://github.com/python/cpython/issues/99726

   (16) 
https://discuss.python.org/t/concerns-regarding-deprecation-of-fork-with-alive-threads/33555

   (17) https://github.com/python/cpython/issues/102828

   (18) https://github.com/python/cpython/issues/90016

   (19) https://github.com/python/cpython/issues/101698

   (20) https://github.com/python/cpython/issues/102778

   (21) https://github.com/python/cpython/issues/94309

   (22) https://github.com/python/cpython/issues/91896

   (23) https://github.com/python/cpython/issues/83122

   (24) https://github.com/python/cpython/issues/89874

   (25) https://github.com/python/cpython/issues/65961

   (26) https://github.com/python/cpython/issues/65961

   (27) https://github.com/python/cpython/issues/103487

   (28) https://peps.python.org/pep-0626/

   (29) https://github.com/python/cpython/issues/101866


File: python.info,  Node: Pending Removal in Python 3 13,  Next: Pending Removal in Python 3 14<3>,  Up: Deprecated

1.2.10.1 Pending Removal in Python 3.13
.......................................

Modules (see PEP 594(1)):

   * ‘aifc’

   * ‘audioop’

   * ‘cgi’

   * ‘cgitb’

   * ‘chunk’

   * ‘crypt’

   * ‘imghdr’

   * ‘mailcap’

   * ‘msilib’

   * ‘nis’

   * ‘nntplib’

   * ‘ossaudiodev’

   * ‘pipes’

   * ‘sndhdr’

   * ‘spwd’

   * ‘sunau’

   * ‘telnetlib’

   * ‘uu’

   * ‘xdrlib’

Other modules:

   * ‘lib2to3’, and the ‘2to3’ program (gh-84540(2))

APIs:

   * ‘configparser.LegacyInterpolation’ (gh-90765(3))

   * ‘locale.resetlocale()’ (gh-90817(4))

   * ‘turtle.RawTurtle.settiltangle()’ (gh-50096(5))

   * ‘unittest.findTestCases()’ (gh-50096(6))

   * ‘unittest.getTestCaseNames()’ (gh-50096(7))

   * ‘unittest.makeSuite()’ (gh-50096(8))

   * ‘unittest.TestProgram.usageExit()’ (gh-67048(9))

   * ‘webbrowser.MacOSX’ (gh-86421(10))

   * *note classmethod: 14c. descriptor chaining (gh-89519(11))

   * *note importlib.resources: 6f. deprecated methods:

        * ‘contents()’

        * ‘is_resource()’

        * ‘open_binary()’

        * ‘open_text()’

        * ‘path()’

        * ‘read_binary()’

        * ‘read_text()’

     Use *note importlib.resources.files(): 45b. instead.  Refer to
     importlib-resources: Migrating from Legacy(12) (gh-106531(13))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0594/

   (2) https://github.com/python/cpython/issues/84540

   (3) https://github.com/python/cpython/issues/90765

   (4) https://github.com/python/cpython/issues/90817

   (5) https://github.com/python/cpython/issues/50096

   (6) https://github.com/python/cpython/issues/50096

   (7) https://github.com/python/cpython/issues/50096

   (8) https://github.com/python/cpython/issues/50096

   (9) https://github.com/python/cpython/issues/67048

   (10) https://github.com/python/cpython/issues/86421

   (11) https://github.com/python/cpython/issues/89519

   (12) 
https://importlib-resources.readthedocs.io/en/latest/using.html#migrating-from-legacy

   (13) https://github.com/python/cpython/issues/106531


File: python.info,  Node: Pending Removal in Python 3 14<3>,  Next: Pending Removal in Python 3 15<3>,  Prev: Pending Removal in Python 3 13,  Up: Deprecated

1.2.10.2 Pending Removal in Python 3.14
.......................................

   * *note argparse: 5.: The 'type', 'choices', and 'metavar' parameters
     of ‘argparse.BooleanOptionalAction’ are deprecated and will be
     removed in 3.14.  (Contributed by Nikita Sobolev in gh-92248(1).)

   * *note ast: 7.: The following features have been deprecated in
     documentation since Python 3.8, now cause a *note
     DeprecationWarning: 18a. to be emitted at runtime when they are
     accessed or used, and will be removed in Python 3.14:

        * ‘ast.Num’

        * ‘ast.Str’

        * ‘ast.Bytes’

        * ‘ast.NameConstant’

        * ‘ast.Ellipsis’

     Use *note ast.Constant: 299. instead.  (Contributed by Serhiy
     Storchaka in gh-90953(2).)

   * *note asyncio: 8.:

        * The child watcher classes *note MultiLoopChildWatcher: 29a,
          *note FastChildWatcher: 29b, *note AbstractChildWatcher: 29c.
          and *note SafeChildWatcher: 29d. are deprecated and will be
          removed in Python 3.14.  (Contributed by Kumar Aditya in
          gh-94597(3).)

        * *note asyncio.set_child_watcher(): 29e, *note
          asyncio.get_child_watcher(): 29f, *note
          asyncio.AbstractEventLoopPolicy.set_child_watcher(): 2a0. and
          *note asyncio.AbstractEventLoopPolicy.get_child_watcher():
          2a1. are deprecated and will be removed in Python 3.14.
          (Contributed by Kumar Aditya in gh-94597(4).)

        * The *note get_event_loop(): 2a2. method of the default event
          loop policy now emits a *note DeprecationWarning: 18a. 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(5).)

   * *note collections.abc: 17.: Deprecated *note ByteString: 2a3.
     Prefer ‘Sequence’ or *note Buffer: 2a4.  For use in typing, prefer
     a union, like ‘bytes | bytearray’, or *note collections.abc.Buffer:
     2a4.  (Contributed by Shantanu Jain in gh-91896(6).)

   * *note email: 32.: Deprecated the 'isdst' parameter in *note
     email.utils.localtime(): 2a5.  (Contributed by Alan Williams in
     gh-72346(7).)

   * *note importlib.abc: 6c. deprecated classes:

        * ‘importlib.abc.ResourceReader’

        * ‘importlib.abc.Traversable’

        * ‘importlib.abc.TraversableResources’

     Use *note importlib.resources.abc: 70. classes instead:

        * *note importlib.resources.abc.Traversable: 1d4.

        * *note importlib.resources.abc.TraversableResources: 2a6.

     (Contributed by Jason R. Coombs and Hugo van Kemenade in
     gh-93963(8).)

   * *note itertools: 75. 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(9).)

   * *note multiprocessing: 86.: The default start method will change to
     a safer one on Linux, BSDs, and other non-macOS POSIX platforms
     where ‘'fork'’ is currently the default (gh-84559(10)).  Adding a
     runtime warning about this was deemed too disruptive as the
     majority of code is not expected to care.  Use the *note
     get_context(): 2a7. or *note set_start_method(): 2a8. APIs to
     explicitly specify when your code 'requires' ‘'fork'’.  See *note
     コンテキストと開始方式: 2a9.

   * *note pathlib: 93.: *note is_relative_to(): 2aa. and *note
     relative_to(): 2ab.: passing additional arguments is deprecated.

   * *note pkgutil: 97.: *note find_loader(): 2ac. and *note
     get_loader(): 2ad. now raise *note DeprecationWarning: 18a.; use
     *note importlib.util.find_spec(): 2ae. instead.  (Contributed by
     Nikita Sobolev in gh-97850(11).)

   * *note pty: 9f.:

        * ‘master_open()’: use *note pty.openpty(): 2af.

        * ‘slave_open()’: use *note pty.openpty(): 2af.

   * *note sqlite3: ba.:

        * *note version: 2b0. and *note version_info: 2b1.

        * *note execute(): 2b2. and *note executemany(): 2b3. if *note
          named placeholders: 2b4. are used and 'parameters' is a
          sequence instead of a *note dict: 237.

   * *note typing: ed.: *note ByteString: 2b5, deprecated since Python
     3.9, now causes a *note DeprecationWarning: 18a. to be emitted when
     it is used.

   * *note urllib: f1.: ‘urllib.parse.Quoter’ is deprecated: it was not
     intended to be a public API. (Contributed by Gregory P. Smith in
     gh-88168(12).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92248

   (2) https://github.com/python/cpython/issues/90953

   (3) https://github.com/python/cpython/issues/94597

   (4) https://github.com/python/cpython/issues/94597

   (5) https://github.com/python/cpython/issues/100160

   (6) https://github.com/python/cpython/issues/91896

   (7) https://github.com/python/cpython/issues/72346

   (8) https://github.com/python/cpython/issues/93963

   (9) https://github.com/python/cpython/issues/101588

   (10) https://github.com/python/cpython/issues/84559

   (11) https://github.com/python/cpython/issues/97850

   (12) https://github.com/python/cpython/issues/88168


File: python.info,  Node: Pending Removal in Python 3 15<3>,  Next: Pending removal in Python 3 16<2>,  Prev: Pending Removal in Python 3 14<3>,  Up: Deprecated

1.2.10.3 Pending Removal in Python 3.15
.......................................

   * The import system:

        * Setting *note __cached__: 2b7. on a module while failing to
          set *note __spec__.cached: 2b8. 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(1))

        * Setting *note __package__: 2b9. on a module while failing to
          set *note __spec__.parent: 2ba. is deprecated.  In Python
          3.15, ‘__package__’ will cease to be set or take into
          consideration by the import system or standard library.
          (gh-97879(2))

   * *note ctypes: 22.:

        * The undocumented ‘ctypes.SetPointerType()’ function has been
          deprecated since Python 3.13.

   * *note http.server: 68.:

        * The obsolete and rarely used *note CGIHTTPRequestHandler: 281.
          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.

        * The ‘--cgi’ flag to the ‘python -m http.server’ command-line
          interface has been deprecated since Python 3.13.

   * *note locale: 7a.:

        * The *note getdefaultlocale(): 2bb. function has been
          deprecated since Python 3.11.  Its removal was originally
          planned for Python 3.13 (gh-90817(3)), but has been postponed
          to Python 3.15.  Use *note getlocale(): 2bc, *note
          setlocale(): 2bd, and *note getencoding(): 2be. instead.
          (Contributed by Hugo van Kemenade in gh-111187(4).)

   * *note pathlib: 93.:

        * *note PurePath.is_reserved(): 286. has been deprecated since
          Python 3.13.  Use *note os.path.isreserved(): 204. to detect
          reserved paths on Windows.

   * *note platform: 98.:

        * *note java_ver(): 287. has been deprecated since Python 3.13.
          This function is only useful for Jython support, has a
          confusing API, and is largely untested.

   * *note threading: d6.:

        * *note RLock(): 2bf. 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.

   * *note types: ec.:

        * *note types.CodeType: 2c0.: Accessing *note co_lnotab: 2c1.
          was deprecated in PEP 626(5) since 3.10 and was planned to be
          removed in 3.12, but it only got a proper *note
          DeprecationWarning: 18a. in 3.12.  May be removed in 3.15.
          (Contributed by Nikita Sobolev in gh-101866(6).)

   * *note typing: ed.:

        * The undocumented keyword argument syntax for creating *note
          NamedTuple: 290. classes (e.g.  ‘Point = NamedTuple("Point",
          x=int, y=int)’) has been deprecated since Python 3.13.  Use
          the class-based syntax or the functional syntax instead.

        * The *note typing.no_type_check_decorator(): 291. decorator
          function has been deprecated since Python 3.13.  After eight
          years in the *note typing: ed. module, it has yet to be
          supported by any major type checker.

   * *note wave: fb.:

        * The *note getmark(): 294, ‘setmark()’, and *note getmarkers():
          295. methods of the *note Wave_read: 296. and *note
          Wave_write: 297. classes have been deprecated since Python
          3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97879

   (2) https://github.com/python/cpython/issues/97879

   (3) https://github.com/python/cpython/issues/90817

   (4) https://github.com/python/cpython/issues/111187

   (5) https://peps.python.org/pep-0626/

   (6) https://github.com/python/cpython/issues/101866


File: python.info,  Node: Pending removal in Python 3 16<2>,  Next: Pending Removal in Future Versions<3>,  Prev: Pending Removal in Python 3 15<3>,  Up: Deprecated

1.2.10.4 Pending removal in Python 3.16
.......................................

   * The import system:

        * Setting *note __loader__: 2c3. on a module while failing to
          set *note __spec__.loader: 2c4. is deprecated.  In Python
          3.16, ‘__loader__’ will cease to be set or taken into
          consideration by the import system or the standard library.

   * *note array: 6.:

        * The ‘'u'’ format code (‘wchar_t’) has been deprecated in
          documentation since Python 3.3 and at runtime since Python
          3.13.  Use the ‘'w'’ format code (*note Py_UCS4: 27b.) for
          Unicode characters instead.

   * *note asyncio: 8.:

        * ‘asyncio.iscoroutinefunction()’ is deprecated and will be
          removed in Python 3.16, use *note
          inspect.iscoroutinefunction(): 2c5. instead.  (Contributed by
          Jiahao Li and Kumar Aditya in gh-122875(1).)

   * *note builtins: e.:

        * Bitwise inversion on boolean types, ‘~True’ or ‘~False’ has
          been deprecated since Python 3.12, as it produces surprising
          and unintuitive results (‘-2’ and ‘-1’).  Use ‘not x’ instead
          for the logical negation of a Boolean.  In the rare case that
          you need the bitwise inversion of the underlying integer,
          convert to ‘int’ explicitly (‘~int(x)’).

   * *note shutil: b3.:

        * The ‘ExecError’ exception has been deprecated since Python
          3.14.  It has not been used by any function in ‘shutil’ since
          Python 3.4, and is now an alias of *note RuntimeError: 17a.

   * *note symtable: c2.:

        * The *note Class.get_methods: 2c6. method has been deprecated
          since Python 3.14.

   * *note sys: c3.:

        * The *note _enablelegacywindowsfsencoding(): 28e. function has
          been deprecated since Python 3.13.  Use the *note
          PYTHONLEGACYWINDOWSFSENCODING: 28f. environment variable
          instead.

   * *note tarfile: c8.:

        * The undocumented and unused ‘TarFile.tarfile’ attribute has
          been deprecated since Python 3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122875


File: python.info,  Node: Pending Removal in Future Versions<3>,  Prev: Pending removal in Python 3 16<2>,  Up: Deprecated

1.2.10.5 Pending Removal in Future Versions
...........................................

The following APIs will be removed in the future, although there is
currently no date scheduled for their removal.

   * *note argparse: 5.: Nesting argument groups and nesting mutually
     exclusive groups are deprecated.

   * *note array: 6.'s ‘'u'’ format code (gh-57281(1))

   * *note builtins: e.:

        * ‘bool(NotImplemented)’.

        * Generators: ‘throw(type, exc, tb)’ and ‘athrow(type, exc, tb)’
          signature is deprecated: use ‘throw(exc)’ and ‘athrow(exc)’
          instead, the single argument signature.

        * Currently Python accepts numeric literals immediately followed
          by keywords, for example ‘0in x’, ‘1or x’, ‘0if 1else 2’.  It
          allows confusing and ambiguous expressions like ‘[0x1for x in
          y]’ (which can be interpreted as ‘[0x1 for x in y]’ or ‘[0x1f
          or x in y]’).  A syntax warning is raised if the numeric
          literal is immediately followed by one of keywords *note and:
          2c8, *note else: 171, *note for: 2c9, *note if: 2ca, *note in:
          2cb, *note is: 2cc. and *note or: 2cd.  In a future release it
          will be changed to a syntax error.  (gh-87999(2))

        * Support for ‘__index__()’ and ‘__int__()’ method returning
          non-int type: these methods will be required to return an
          instance of a strict subclass of *note int: 238.

        * Support for ‘__float__()’ method returning a strict subclass
          of *note float: 2ce.: these methods will be required to return
          an instance of *note float: 2ce.

        * Support for ‘__complex__()’ method returning a strict subclass
          of *note complex: 2cf.: these methods will be required to
          return an instance of *note complex: 2cf.

        * Delegation of ‘int()’ to ‘__trunc__()’ method.

        * Passing a complex number as the 'real' or 'imag' argument in
          the *note complex(): 2cf. constructor is now deprecated; it
          should only be passed as a single positional argument.
          (Contributed by Serhiy Storchaka in gh-109218(3).)

   * *note calendar: 10.: ‘calendar.January’ and ‘calendar.February’
     constants are deprecated and replaced by *note calendar.JANUARY:
     2d0. and *note calendar.FEBRUARY: 2d1.  (Contributed by Prince
     Roshan in gh-103636(4).)

   * *note codeobject.co_lnotab: 2c1.: use the *note
     codeobject.co_lines(): 2d2. method instead.

   * *note datetime: 28.:

        * *note utcnow(): 2d3.: use
          ‘datetime.datetime.now(tz=datetime.UTC)’.

        * *note utcfromtimestamp(): 2d4.: use
          ‘datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)’.

   * *note gettext: 59.: Plural value must be an integer.

   * *note importlib: 6b.:

        * ‘load_module()’ method: use ‘exec_module()’ instead.

        * *note cache_from_source(): 2d5. 'debug_override' parameter is
          deprecated: use the 'optimization' parameter instead.

   * *note importlib.metadata: 6e.:

        * ‘EntryPoints’ tuple interface.

        * Implicit ‘None’ on return values.

   * *note logging: 7b.: the ‘warn()’ method has been deprecated since
     Python 3.3, use *note warning(): 2d6. instead.

   * *note mailbox: 7f.: Use of StringIO input and text mode is
     deprecated, use BytesIO and binary mode instead.

   * *note os: 91.: Calling *note os.register_at_fork(): 2d7. in
     multi-threaded process.

   * ‘pydoc.ErrorDuringImport’: A tuple value for 'exc_info' parameter
     is deprecated, use an exception instance.

   * *note re: a7.: More strict rules are now applied for numerical
     group references and group names in regular expressions.  Only
     sequence of ASCII digits is now accepted as a numerical reference.
     The group name in bytes patterns and replacement strings can now
     only contain ASCII letters and digits and underscore.  (Contributed
     by Serhiy Storchaka in gh-91760(5).)

   * ‘sre_compile’, ‘sre_constants’ and ‘sre_parse’ modules.

   * *note shutil: b3.: *note rmtree(): 2d8.'s 'onerror' parameter is
     deprecated in Python 3.12; use the 'onexc' parameter instead.

   * *note ssl: bb. options and protocols:

        * *note ssl.SSLContext: 274. without protocol argument is
          deprecated.

        * *note ssl.SSLContext: 274.: *note set_npn_protocols(): 2d9.
          and ‘selected_npn_protocol()’ are deprecated: use ALPN
          instead.

        * ‘ssl.OP_NO_SSL*’ options

        * ‘ssl.OP_NO_TLS*’ options

        * ‘ssl.PROTOCOL_SSLv3’

        * ‘ssl.PROTOCOL_TLS’

        * ‘ssl.PROTOCOL_TLSv1’

        * ‘ssl.PROTOCOL_TLSv1_1’

        * ‘ssl.PROTOCOL_TLSv1_2’

        * ‘ssl.TLSVersion.SSLv3’

        * ‘ssl.TLSVersion.TLSv1’

        * ‘ssl.TLSVersion.TLSv1_1’

   * *note sysconfig.is_python_build(): 2da. 'check_home' parameter is
     deprecated and ignored.

   * *note threading: d6. methods:

        * ‘threading.Condition.notifyAll()’: use *note notify_all():
          2db.

        * ‘threading.Event.isSet()’: use *note is_set(): 2dc.

        * ‘threading.Thread.isDaemon()’, *note
          threading.Thread.setDaemon(): 2dd.: use *note
          threading.Thread.daemon: 2de. attribute.

        * ‘threading.Thread.getName()’, *note
          threading.Thread.setName(): 2df.: use *note
          threading.Thread.name: 2e0. attribute.

        * ‘threading.currentThread()’: use *note
          threading.current_thread(): 2e1.

        * ‘threading.activeCount()’: use *note threading.active_count():
          2e2.

   * *note typing.Text: 2e3. (gh-92332(6)).

   * *note unittest.IsolatedAsyncioTestCase: 2e4.: it is deprecated to
     return a value that is not ‘None’ from a test case.

   * *note urllib.parse: f3. deprecated functions: *note urlparse():
     2e5. instead

        * ‘splitattr()’

        * ‘splithost()’

        * ‘splitnport()’

        * ‘splitpasswd()’

        * ‘splitport()’

        * ‘splitquery()’

        * ‘splittag()’

        * ‘splittype()’

        * ‘splituser()’

        * ‘splitvalue()’

        * ‘to_bytes()’

   * *note urllib.request: f4.: *note URLopener: 2e6. and *note
     FancyURLopener: 2e7. style of invoking requests is deprecated.  Use
     newer *note urlopen(): 273. functions and methods.

   * *note wsgiref: 100.: ‘SimpleHandler.stdout.write()’ should not do
     partial writes.

   * *note xml.etree.ElementTree: 10c.: Testing the truth value of an
     *note Element: 2e8. is deprecated.  In a future release it will
     always return ‘True’.  Prefer explicit ‘len(elem)’ or ‘elem is not
     None’ tests instead.

   * *note zipimport.zipimporter.load_module(): 2e9. is deprecated: use
     *note exec_module(): 2ea. instead.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/57281

   (2) https://github.com/python/cpython/issues/87999

   (3) https://github.com/python/cpython/issues/109218

   (4) https://github.com/python/cpython/issues/103636

   (5) https://github.com/python/cpython/issues/91760

   (6) https://github.com/python/cpython/issues/92332


File: python.info,  Node: Removed,  Next: Porting to Python 3 12,  Prev: Deprecated,  Up: What's New In Python 3 12

1.2.11 Removed
--------------

* Menu:

* asynchat and asyncore::
* configparser: configparser<3>.
* distutils::
* ensurepip::
* enum::
* ftplib::
* gzip::
* hashlib::
* importlib: importlib<2>.
* imp::
* io: io<2>.
* locale: locale<2>.
* smtpd::
* sqlite3: sqlite3<3>.
* ssl: ssl<2>.
* unittest: unittest<3>.
* webbrowser: webbrowser<2>.
* xml.etree.ElementTree: xml etree ElementTree.
* zipimport: zipimport<2>.
* Others::


File: python.info,  Node: asynchat and asyncore,  Next: configparser<3>,  Up: Removed

1.2.11.1 asynchat and asyncore
..............................

   * These two modules have been removed according to the schedule in
     PEP 594(1), having been deprecated in Python 3.6.  Use *note
     asyncio: 8. instead.  (Contributed by Nikita Sobolev in
     gh-96580(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0594/

   (2) https://github.com/python/cpython/issues/96580


File: python.info,  Node: configparser<3>,  Next: distutils,  Prev: asynchat and asyncore,  Up: Removed

1.2.11.2 configparser
.....................

   * Several names deprecated in the *note configparser: 1b. way back in
     3.2 have been removed per gh-89336(1):

        * *note configparser.ParsingError: 4d0. no longer has a
          ‘filename’ attribute or argument.  Use the ‘source’ attribute
          and argument instead.

        * *note configparser: 1b. no longer has a ‘SafeConfigParser’
          class.  Use the shorter *note ConfigParser: 1aa. name instead.

        * *note configparser.ConfigParser: 1aa. no longer has a ‘readfp’
          method.  Use *note read_file(): 4d1. instead.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89336


File: python.info,  Node: distutils,  Next: ensurepip,  Prev: configparser<3>,  Up: Removed

1.2.11.3 distutils
..................

   * Remove the ‘distutils’ package.  It was deprecated in Python 3.10
     by PEP 632(1) "Deprecate distutils module".  For projects still
     using ‘distutils’ and cannot be updated to something else, the
     ‘setuptools’ project can be installed: it still provides
     ‘distutils’.  (Contributed by Victor Stinner in gh-92584(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0632/

   (2) https://github.com/python/cpython/issues/92584


File: python.info,  Node: ensurepip,  Next: enum,  Prev: distutils,  Up: Removed

1.2.11.4 ensurepip
..................

   * Remove the bundled setuptools wheel from *note ensurepip: 4b, and
     stop installing setuptools in environments created by *note venv:
     f9.

     ‘pip (>= 22.1)’ does not require setuptools to be installed in the
     environment.  ‘setuptools’-based (and ‘distutils’-based) packages
     can still be used with ‘pip install’, since pip will provide
     ‘setuptools’ in the build environment it uses for building a
     package.

     ‘easy_install’, ‘pkg_resources’, ‘setuptools’ and ‘distutils’ are
     no longer provided by default in environments created with ‘venv’
     or bootstrapped with ‘ensurepip’, since they are part of the
     ‘setuptools’ package.  For projects relying on these at runtime,
     the ‘setuptools’ project should be declared as a dependency and
     installed separately (typically, using pip).

     (Contributed by Pradyun Gedam in gh-95299(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/95299


File: python.info,  Node: enum,  Next: ftplib,  Prev: ensurepip,  Up: Removed

1.2.11.5 enum
.............

   * Remove *note enum: 4c.'s ‘EnumMeta.__getattr__’, which is no longer
     needed for enum attribute access.  (Contributed by Ethan Furman in
     gh-95083(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/95083


File: python.info,  Node: ftplib,  Next: gzip,  Prev: enum,  Up: Removed

1.2.11.6 ftplib
...............

   * Remove *note ftplib: 54.'s ‘FTP_TLS.ssl_version’ class attribute:
     use the 'context' parameter instead.  (Contributed by Victor
     Stinner in gh-94172(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94172


File: python.info,  Node: gzip,  Next: hashlib,  Prev: ftplib,  Up: Removed

1.2.11.7 gzip
.............

   * Remove the ‘filename’ attribute of *note gzip: 5d.'s *note
     gzip.GzipFile: 3f3, deprecated since Python 2.6, use the *note
     name: 4d7. attribute instead.  In write mode, the ‘filename’
     attribute added ‘'.gz'’ file extension if it was not present.
     (Contributed by Victor Stinner in gh-94196(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94196


File: python.info,  Node: hashlib,  Next: importlib<2>,  Prev: gzip,  Up: Removed

1.2.11.8 hashlib
................

   * Remove the pure Python implementation of *note hashlib: 5e.'s *note
     hashlib.pbkdf2_hmac(): 4d9, deprecated in Python 3.10.  Python 3.10
     and newer requires OpenSSL 1.1.1 ( PEP 644(1)): this OpenSSL
     version provides a C implementation of *note pbkdf2_hmac(): 4d9.
     which is faster.  (Contributed by Victor Stinner in gh-94199(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0644/

   (2) https://github.com/python/cpython/issues/94199


File: python.info,  Node: importlib<2>,  Next: imp,  Prev: hashlib,  Up: Removed

1.2.11.9 importlib
..................

   * Many previously deprecated cleanups in *note importlib: 6b. have
     now been completed:

        * References to, and support for ‘module_repr()’ has been
          removed.  (Contributed by Barry Warsaw in gh-97850(1).)

        * ‘importlib.util.set_package’, ‘importlib.util.set_loader’ and
          ‘importlib.util.module_for_loader’ have all been removed.
          (Contributed by Brett Cannon and Nikita Sobolev in gh-65961(2)
          and gh-97850(3).)

        * Support for ‘find_loader()’ and ‘find_module()’ APIs have been
          removed.  (Contributed by Barry Warsaw in gh-98040(4).)

        * ‘importlib.abc.Finder’, ‘pkgutil.ImpImporter’, and
          ‘pkgutil.ImpLoader’ have been removed.  (Contributed by Barry
          Warsaw in gh-98040(5).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97850

   (2) https://github.com/python/cpython/issues/65961

   (3) https://github.com/python/cpython/issues/97850

   (4) https://github.com/python/cpython/issues/98040

   (5) https://github.com/python/cpython/issues/98040


File: python.info,  Node: imp,  Next: io<2>,  Prev: importlib<2>,  Up: Removed

1.2.11.10 imp
.............

   * The ‘imp’ module has been removed.  (Contributed by Barry Warsaw in
     gh-98040(1).)

     To migrate, consult the following correspondence table:

          imp                                   importlib
                                                
          -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                                                
          ‘imp.NullImporter’                    Insert ‘None’ into ‘sys.path_importer_cache’
                                                
                                                
          ‘imp.cache_from_source()’             *note importlib.util.cache_from_source(): 2d5.
                                                
                                                
          ‘imp.find_module()’                   *note importlib.util.find_spec(): 2ae.
                                                
                                                
          ‘imp.get_magic()’                     *note importlib.util.MAGIC_NUMBER: 4dc.
                                                
                                                
          ‘imp.get_suffixes()’                  *note importlib.machinery.SOURCE_SUFFIXES: 4dd, *note importlib.machinery.EXTENSION_SUFFIXES: 4de, and
                                                *note importlib.machinery.BYTECODE_SUFFIXES: 4df.
                                                
                                                
          ‘imp.get_tag()’                       *note sys.implementation.cache_tag: 4e0.
                                                
                                                
          ‘imp.load_module()’                   *note importlib.import_module(): 4e1.
                                                
                                                
          ‘imp.new_module(name)’                ‘types.ModuleType(name)’
                                                
                                                
          ‘imp.reload()’                        *note importlib.reload(): 4e2.
                                                
                                                
          ‘imp.source_from_cache()’             *note importlib.util.source_from_cache(): 4e3.
                                                
                                                
          ‘imp.load_source()’                   'See below'
                                                

     Replace ‘imp.load_source()’ with:

          import importlib.util
          import importlib.machinery

          def load_source(modname, filename):
              loader = importlib.machinery.SourceFileLoader(modname, filename)
              spec = importlib.util.spec_from_file_location(modname, filename, loader=loader)
              module = importlib.util.module_from_spec(spec)
              # The module is always executed and not cached in sys.modules.
              # Uncomment the following line to cache the module.
              # sys.modules[module.__name__] = module
              loader.exec_module(module)
              return module

   * Remove ‘imp’ functions and attributes with no replacements:

        * Undocumented functions:

             * ‘imp.init_builtin()’

             * ‘imp.load_compiled()’

             * ‘imp.load_dynamic()’

             * ‘imp.load_package()’

        * ‘imp.lock_held()’, ‘imp.acquire_lock()’, ‘imp.release_lock()’:
          the locking scheme has changed in Python 3.3 to per-module
          locks.

        * ‘imp.find_module()’ constants: ‘SEARCH_ERROR’, ‘PY_SOURCE’,
          ‘PY_COMPILED’, ‘C_EXTENSION’, ‘PY_RESOURCE’, ‘PKG_DIRECTORY’,
          ‘C_BUILTIN’, ‘PY_FROZEN’, ‘PY_CODERESOURCE’, ‘IMP_HOOK’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98040


File: python.info,  Node: io<2>,  Next: locale<2>,  Prev: imp,  Up: Removed

1.2.11.11 io
............

   * Remove *note io: 73.'s ‘io.OpenWrapper’ and ‘_pyio.OpenWrapper’,
     deprecated in Python 3.10: just use *note open(): 4e5. instead.
     The *note open(): 4e5. (*note io.open(): 4e6.) function is a
     built-in function.  Since Python 3.10, ‘_pyio.open()’ is also a
     static method.  (Contributed by Victor Stinner in gh-94169(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94169


File: python.info,  Node: locale<2>,  Next: smtpd,  Prev: io<2>,  Up: Removed

1.2.11.12 locale
................

   * Remove *note locale: 7a.'s ‘locale.format()’ function, deprecated
     in Python 3.7: use *note locale.format_string(): 4e8. instead.
     (Contributed by Victor Stinner in gh-94226(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94226


File: python.info,  Node: smtpd,  Next: sqlite3<3>,  Prev: locale<2>,  Up: Removed

1.2.11.13 smtpd
...............

   * The ‘smtpd’ module has been removed according to the schedule in
     PEP 594(1), having been deprecated in Python 3.4.7 and 3.5.4.  Use
     the aiosmtpd(2) PyPI module or any other *note asyncio: 8.-based
     server instead.  (Contributed by Oleg Iarygin in gh-93243(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0594/

   (2) https://pypi.org/project/aiosmtpd/

   (3) https://github.com/python/cpython/issues/93243


File: python.info,  Node: sqlite3<3>,  Next: ssl<2>,  Prev: smtpd,  Up: Removed

1.2.11.14 sqlite3
.................

   * The following undocumented *note sqlite3: ba. features, deprecated
     in Python 3.10, are now removed:

        * ‘sqlite3.enable_shared_cache()’

        * ‘sqlite3.OptimizedUnicode’

     If a shared cache must be used, open the database in URI mode using
     the ‘cache=shared’ query parameter.

     The ‘sqlite3.OptimizedUnicode’ text factory has been an alias for
     *note str: 418. since Python 3.3.  Code that previously set the
     text factory to ‘OptimizedUnicode’ can either use ‘str’ explicitly,
     or rely on the default value which is also ‘str’.

     (Contributed by Erlend E. Aasland in gh-92548(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92548


File: python.info,  Node: ssl<2>,  Next: unittest<3>,  Prev: sqlite3<3>,  Up: Removed

1.2.11.15 ssl
.............

   * Remove *note ssl: bb.'s ‘ssl.RAND_pseudo_bytes()’ function,
     deprecated in Python 3.6: use *note os.urandom(): 4ec. or *note
     ssl.RAND_bytes(): 4ed. instead.  (Contributed by Victor Stinner in
     gh-94199(1).)

   * Remove the ‘ssl.match_hostname()’ function.  It was deprecated in
     Python 3.7.  OpenSSL performs hostname matching since Python 3.7,
     Python no longer uses the ‘ssl.match_hostname()’ function.
     (Contributed by Victor Stinner in gh-94199(2).)

   * Remove the ‘ssl.wrap_socket()’ function, deprecated in Python 3.7:
     instead, create a *note ssl.SSLContext: 274. object and call its
     *note ssl.SSLContext.wrap_socket: 4ee. method.  Any package that
     still uses ‘ssl.wrap_socket()’ is broken and insecure.  The
     function neither sends a SNI TLS extension nor validates the server
     hostname.  Code is subject to CWE 295(3) (Improper Certificate
     Validation).  (Contributed by Victor Stinner in gh-94199(4).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94199

   (2) https://github.com/python/cpython/issues/94199

   (3) https://cwe.mitre.org/data/definitions/295.html

   (4) https://github.com/python/cpython/issues/94199


File: python.info,  Node: unittest<3>,  Next: webbrowser<2>,  Prev: ssl<2>,  Up: Removed

1.2.11.16 unittest
..................

   * Remove many long-deprecated *note unittest: ef. features:

        * A number of *note TestCase: 41a. method aliases:

          Deprecated alias                 Method Name                         Deprecated in
                                                                               
          -----------------------------------------------------------------------------------------
                                                                               
          ‘failUnless’                     *note assertTrue(): 4f0.            3.1
                                                                               
                                                                               
          ‘failIf’                         *note assertFalse(): 4f1.           3.1
                                                                               
                                                                               
          ‘failUnlessEqual’                *note assertEqual(): 4f2.           3.1
                                                                               
                                                                               
          ‘failIfEqual’                    *note assertNotEqual(): 4f3.        3.1
                                                                               
                                                                               
          ‘failUnlessAlmostEqual’          *note assertAlmostEqual(): 4f4.     3.1
                                                                               
                                                                               
          ‘failIfAlmostEqual’              *note assertNotAlmostEqual(): 4f5.  3.1
                                                                               
                                                                               
          ‘failUnlessRaises’               *note assertRaises(): 4f6.          3.1
                                                                               
                                                                               
          ‘assert_’                        *note assertTrue(): 4f0.            3.2
                                                                               
                                                                               
          ‘assertEquals’                   *note assertEqual(): 4f2.           3.2
                                                                               
                                                                               
          ‘assertNotEquals’                *note assertNotEqual(): 4f3.        3.2
                                                                               
                                                                               
          ‘assertAlmostEquals’             *note assertAlmostEqual(): 4f4.     3.2
                                                                               
                                                                               
          ‘assertNotAlmostEquals’          *note assertNotAlmostEqual(): 4f5.  3.2
                                                                               
                                                                               
          ‘assertRegexpMatches’            *note assertRegex(): 4f7.           3.2
                                                                               
                                                                               
          ‘assertRaisesRegexp’             *note assertRaisesRegex(): 4f8.     3.2
                                                                               
                                                                               
          ‘assertNotRegexpMatches’         *note assertNotRegex(): 4f9.        3.5
                                                                               

          You can use ‘https://github.com/isidentical/teyit’ to
          automatically modernise your unit tests.

        * Undocumented and broken *note TestCase: 41a. method
          ‘assertDictContainsSubset’ (deprecated in Python 3.2).

        * Undocumented *note TestLoader.loadTestsFromModule: 26f.
          parameter 'use_load_tests' (deprecated and ignored since
          Python 3.5).

        * An alias of the *note TextTestResult: 4fa. class:
          ‘_TextTestResult’ (deprecated in Python 3.2).

     (Contributed by Serhiy Storchaka in gh-89325(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89325


File: python.info,  Node: webbrowser<2>,  Next: xml etree ElementTree,  Prev: unittest<3>,  Up: Removed

1.2.11.17 webbrowser
....................

   * Remove support for obsolete browsers from *note webbrowser: fd.
     The removed browsers include: Grail, Mosaic, Netscape, Galeon,
     Skipstone, Iceape, Firebird, and Firefox versions 35 and below
     (gh-102871(1)).

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102871


File: python.info,  Node: xml etree ElementTree,  Next: zipimport<2>,  Prev: webbrowser<2>,  Up: Removed

1.2.11.18 xml.etree.ElementTree
...............................

   * Remove the ‘ElementTree.Element.copy()’ method of the pure Python
     implementation, deprecated in Python 3.10, use the *note
     copy.copy(): 4fd. function instead.  The C implementation of *note
     xml.etree.ElementTree: 10c. has no ‘copy()’ method, only a
     ‘__copy__()’ method.  (Contributed by Victor Stinner in
     gh-94383(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94383


File: python.info,  Node: zipimport<2>,  Next: Others,  Prev: xml etree ElementTree,  Up: Removed

1.2.11.19 zipimport
...................

   * Remove *note zipimport: 118.'s ‘find_loader()’ and ‘find_module()’
     methods, deprecated in Python 3.10: use the ‘find_spec()’ method
     instead.  See PEP 451(1) for the rationale.  (Contributed by Victor
     Stinner in gh-94379(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0451/

   (2) https://github.com/python/cpython/issues/94379


File: python.info,  Node: Others,  Prev: zipimport<2>,  Up: Removed

1.2.11.20 Others
................

   * Remove the ‘suspicious’ rule from the documentation ‘Makefile’ and
     ‘Doc/tools/rstlint.py’, both in favor of sphinx-lint(1).
     (Contributed by Julien Palard in gh-98179(2).)

   * Remove the 'keyfile' and 'certfile' parameters from the *note
     ftplib: 54, *note imaplib: 6a, *note poplib: 9a. and *note smtplib:
     b7. modules, and the 'key_file', 'cert_file' and 'check_hostname'
     parameters from the *note http.client: 65. module, all deprecated
     since Python 3.6.  Use the 'context' parameter ('ssl_context' in
     *note imaplib: 6a.) instead.  (Contributed by Victor Stinner in
     gh-94172(3).)

   * Remove ‘Jython’ compatibility hacks from several stdlib modules and
     tests.  (Contributed by Nikita Sobolev in gh-99482(4).)

   * Remove ‘_use_broken_old_ctypes_structure_semantics_’ flag from
     *note ctypes: 22. module.  (Contributed by Nikita Sobolev in
     gh-99285(5).)

   ---------- Footnotes ----------

   (1) https://github.com/sphinx-contrib/sphinx-lint

   (2) https://github.com/python/cpython/issues/98179

   (3) https://github.com/python/cpython/issues/94172

   (4) https://github.com/python/cpython/issues/99482

   (5) https://github.com/python/cpython/issues/99285


File: python.info,  Node: Porting to Python 3 12,  Next: Build Changes<2>,  Prev: Removed,  Up: What's New In Python 3 12

1.2.12 Porting to Python 3.12
-----------------------------

This section lists previously described changes and other bugfixes that
may require changes to your code.

* Menu:

* Changes in the Python API: Changes in the Python API<2>.


File: python.info,  Node: Changes in the Python API<2>,  Up: Porting to Python 3 12

1.2.12.1 Changes in the Python API
..................................

   * More strict rules are now applied for numerical group references
     and group names in regular expressions.  Only sequence of ASCII
     digits is now accepted as a numerical reference.  The group name in
     bytes patterns and replacement strings can now only contain ASCII
     letters and digits and underscore.  (Contributed by Serhiy
     Storchaka in gh-91760(1).)

   * Remove ‘randrange()’ functionality deprecated since Python 3.10.
     Formerly, ‘randrange(10.0)’ losslessly converted to
     ‘randrange(10)’.  Now, it raises a *note TypeError: 502.  Also, the
     exception raised for non-integer values such as ‘randrange(10.5)’
     or ‘randrange('10')’ has been changed from *note ValueError: 1e3.
     to *note TypeError: 502.  This also prevents bugs where
     ‘randrange(1e25)’ would silently select from a larger range than
     ‘randrange(10**25)’.  (Originally suggested by Serhiy Storchaka
     gh-86388(2).)

   * *note argparse.ArgumentParser: 503. changed encoding and error
     handler for reading arguments from file (e.g.
     ‘fromfile_prefix_chars’ option) from default text encoding (e.g.
     *note locale.getpreferredencoding(False): 504.) to *note filesystem
     encoding and error handler: 505.  Argument files should be encoded
     in UTF-8 instead of ANSI Codepage on Windows.

   * Remove the ‘asyncore’-based ‘smtpd’ module deprecated in Python
     3.4.7 and 3.5.4.  A recommended replacement is the *note asyncio:
     8.-based aiosmtpd(3) PyPI module.

   * *note shlex.split(): 506.: Passing ‘None’ for 's' argument now
     raises an exception, rather than reading *note sys.stdin: 507.  The
     feature was deprecated in Python 3.9.  (Contributed by Victor
     Stinner in gh-94352(4).)

   * The *note os: 91. module no longer accepts bytes-like paths, like
     *note bytearray: 508. and *note memoryview: 435. types: only the
     exact *note bytes: 1a4. type is accepted for bytes strings.
     (Contributed by Victor Stinner in gh-98393(5).)

   * *note syslog.openlog(): 509. and *note syslog.closelog(): 50a. now
     fail if used in subinterpreters.  *note syslog.syslog(): 50b. may
     still be used in subinterpreters, but now only if *note
     syslog.openlog(): 509. has already been called in the main
     interpreter.  These new restrictions do not apply to the main
     interpreter, so only a very small set of users might be affected.
     This change helps with interpreter isolation.  Furthermore, *note
     syslog: c6. is a wrapper around process-global resources, which are
     best managed from the main interpreter.  (Contributed by Donghee Na
     in gh-99127(6).)

   * The undocumented locking behavior of *note cached_property(): 50c.
     is removed, because it locked across all instances of the class,
     leading to high lock contention.  This means that a cached property
     getter function could now run more than once for a single instance,
     if two threads race.  For most simple cached properties (e.g.
     those that are idempotent and simply calculate a value based on
     other attributes of the instance) this will be fine.  If
     synchronization is needed, implement locking within the cached
     property getter function or around multi-threaded access points.

   * *note sys._current_exceptions(): 48e. now returns a mapping from
     thread-id to an exception instance, rather than to a ‘(typ, exc,
     tb)’ tuple.  (Contributed by Irit Katriel in gh-103176(7).)

   * When extracting tar files using *note tarfile: c8. or *note
     shutil.unpack_archive(): 438, pass the 'filter' argument to limit
     features that may be surprising or dangerous.  See *note Extraction
     filters: 439. for details.

   * The output of the *note tokenize.tokenize(): 4a6. and *note
     tokenize.generate_tokens(): 4a7. functions is now changed due to
     the changes introduced in PEP 701(8).  This means that ‘STRING’
     tokens are not emitted any more for f-strings and the tokens
     described in PEP 701(9) are now produced instead: ‘FSTRING_START’,
     ‘FSTRING_MIDDLE’ and ‘FSTRING_END’ are now emitted for f-string
     "string" parts in addition to the appropriate tokens for the
     tokenization in the expression components.  For example for the
     f-string ‘f"start {1+1} end"’ the old version of the tokenizer
     emitted:

          1,0-1,18:           STRING         'f"start {1+1} end"'

     while the new version emits:

          1,0-1,2:            FSTRING_START  'f"'
          1,2-1,8:            FSTRING_MIDDLE 'start '
          1,8-1,9:            OP             '{'
          1,9-1,10:           NUMBER         '1'
          1,10-1,11:          OP             '+'
          1,11-1,12:          NUMBER         '1'
          1,12-1,13:          OP             '}'
          1,13-1,17:          FSTRING_MIDDLE ' end'
          1,17-1,18:          FSTRING_END    '"'

     Additionally, there may be some minor behavioral changes as a
     consequence of the changes required to support PEP 701(10).  Some
     of these changes include:

        * The ‘type’ attribute of the tokens emitted when tokenizing
          some invalid Python characters such as ‘!’ has changed from
          ‘ERRORTOKEN’ to ‘OP’.

        * Incomplete single-line strings now also raise *note
          tokenize.TokenError: 50d. as incomplete multiline strings do.

        * Some incomplete or invalid Python code now raises *note
          tokenize.TokenError: 50d. instead of returning arbitrary
          ‘ERRORTOKEN’ tokens when tokenizing it.

        * Mixing tabs and spaces as indentation in the same file is not
          supported anymore and will raise a *note TabError: 50e.

   * The *note threading: d6. module now expects the ‘_thread’ module to
     have an ‘_is_main_interpreter’ attribute.  It is a function with no
     arguments that returns ‘True’ if the current interpreter is the
     main interpreter.

     Any library or application that provides a custom ‘_thread’ module
     should provide ‘_is_main_interpreter()’.  (See gh-112826(11).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/91760

   (2) https://github.com/python/cpython/issues/86388

   (3) https://pypi.org/project/aiosmtpd/

   (4) https://github.com/python/cpython/issues/94352

   (5) https://github.com/python/cpython/issues/98393

   (6) https://github.com/python/cpython/issues/99127

   (7) https://github.com/python/cpython/issues/103176

   (8) https://peps.python.org/pep-0701/

   (9) https://peps.python.org/pep-0701/

   (10) https://peps.python.org/pep-0701/

   (11) https://github.com/python/cpython/issues/112826


File: python.info,  Node: Build Changes<2>,  Next: C API Changes<2>,  Prev: Porting to Python 3 12,  Up: What's New In Python 3 12

1.2.13 Build Changes
--------------------

   * Python no longer uses ‘setup.py’ to build shared C extension
     modules.  Build parameters like headers and libraries are detected
     in ‘configure’ script.  Extensions are built by ‘Makefile’.  Most
     extensions use ‘pkg-config’ and fall back to manual detection.
     (Contributed by Christian Heimes in gh-93939(1).)

   * ‘va_start()’ with two parameters, like ‘va_start(args, format),’ is
     now required to build Python.  ‘va_start()’ is no longer called
     with a single parameter.  (Contributed by Kumar Aditya in
     gh-93207(2).)

   * CPython now uses the ThinLTO option as the default link time
     optimization policy if the Clang compiler accepts the flag.
     (Contributed by Donghee Na in gh-89536(3).)

   * Add ‘COMPILEALL_OPTS’ variable in ‘Makefile’ to override *note
     compileall: 19. options (default: ‘-j0’) in ‘make install’.  Also
     merged the 3 ‘compileall’ commands into a single command to build
     .pyc files for all optimization levels (0, 1, 2) at once.
     (Contributed by Victor Stinner in gh-99289(4).)

   * Add platform triplets for 64-bit LoongArch:

        * loongarch64-linux-gnusf

        * loongarch64-linux-gnuf32

        * loongarch64-linux-gnu

     (Contributed by Zhang Na in gh-90656(5).)

   * ‘PYTHON_FOR_REGEN’ now require Python 3.10 or newer.

   * Autoconf 2.71 and aclocal 1.16.4 is now required to regenerate
     ‘!configure’.  (Contributed by Christian Heimes in gh-89886(6).)

   * Windows builds and macOS installers from python.org now use OpenSSL
     3.0.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/93939

   (2) https://github.com/python/cpython/issues/93207

   (3) https://github.com/python/cpython/issues/89536

   (4) https://github.com/python/cpython/issues/99289

   (5) https://github.com/python/cpython/issues/90656

   (6) https://github.com/python/cpython/issues/89886


File: python.info,  Node: C API Changes<2>,  Prev: Build Changes<2>,  Up: What's New In Python 3 12

1.2.14 C API Changes
--------------------

* Menu:

* New Features: New Features<4>.
* Porting to Python 3.12: Porting to Python 3 12<2>.
* Deprecated: Deprecated<2>.
* Removed: Removed<2>.


File: python.info,  Node: New Features<4>,  Next: Porting to Python 3 12<2>,  Up: C API Changes<2>

1.2.14.1 New Features
.....................

   * PEP 697(1): Introduce the *note Unstable C API tier: 512, intended
     for low-level tools like debuggers and JIT compilers.  This API may
     change in each minor release of CPython without deprecation
     warnings.  Its contents are marked by the ‘PyUnstable_’ prefix in
     names.

     Code object constructors:

        - ‘PyUnstable_Code_New()’ (renamed from ‘PyCode_New’)

        - ‘PyUnstable_Code_NewWithPosOnlyArgs()’ (renamed from
          ‘PyCode_NewWithPosOnlyArgs’)

     Extra storage for code objects ( PEP 523(2)):

        - ‘PyUnstable_Eval_RequestCodeExtraIndex()’ (renamed from
          ‘_PyEval_RequestCodeExtraIndex’)

        - ‘PyUnstable_Code_GetExtra()’ (renamed from ‘_PyCode_GetExtra’)

        - ‘PyUnstable_Code_SetExtra()’ (renamed from ‘_PyCode_SetExtra’)

     The original names will continue to be available until the
     respective API changes.

     (Contributed by Petr Viktorin in gh-101101(3).)

   * PEP 697(4): Add an API for extending types whose instance memory
     layout is opaque:

        - *note PyType_Spec.basicsize: 513. can be zero or negative to
          specify inheriting or extending the base class size.

        - *note PyObject_GetTypeData(): 514. and *note
          PyType_GetTypeDataSize(): 515. added to allow access to
          subclass-specific instance data.

        - *note Py_TPFLAGS_ITEMS_AT_END: 516. and *note
          PyObject_GetItemData(): 517. added to allow safely extending
          certain variable-sized types, including *note PyType_Type:
          518.

        - *note Py_RELATIVE_OFFSET: 519. added to allow defining *note
          members: 51a. in terms of a subclass-specific struct.

     (Contributed by Petr Viktorin in gh-103509(5).)

   * Add the new *note limited C API: 36f. function *note
     PyType_FromMetaclass(): 51b, which generalizes the existing *note
     PyType_FromModuleAndSpec(): 51c. using an additional metaclass
     argument.  (Contributed by Wenzel Jakob in gh-93012(6).)

   * API for creating objects that can be called using *note the
     vectorcall protocol: 51d. was added to the *note Limited API: 51e.:

        * *note Py_TPFLAGS_HAVE_VECTORCALL: 51f.

        * *note PyVectorcall_NARGS(): 520.

        * *note PyVectorcall_Call(): 521.

        * *note vectorcallfunc: 522.

     The *note Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag is now removed from
     a class when the class's *note __call__(): 523. method is
     reassigned.  This makes vectorcall safe to use with mutable types
     (i.e.  heap types without the immutable flag, *note
     Py_TPFLAGS_IMMUTABLETYPE: 39c.).  Mutable types that do not
     override *note tp_call: 524. now inherit the
     ‘Py_TPFLAGS_HAVE_VECTORCALL’ flag.  (Contributed by Petr Viktorin
     in gh-93274(7).)

     The *note Py_TPFLAGS_MANAGED_DICT: 344. and *note
     Py_TPFLAGS_MANAGED_WEAKREF: 525. flags have been added.  This
     allows extensions classes to support object *note __dict__: 526.
     and weakrefs with less bookkeeping, using less memory and with
     faster access.

   * API for performing calls using *note the vectorcall protocol: 51d.
     was added to the *note Limited API: 51e.:

        * *note PyObject_Vectorcall(): 527.

        * *note PyObject_VectorcallMethod(): 528.

        * *note PY_VECTORCALL_ARGUMENTS_OFFSET: 529.

     This means that both the incoming and outgoing ends of the vector
     call protocol are now available in the *note Limited API: 51e.
     (Contributed by Wenzel Jakob in gh-98586(8).)

   * Add two new public functions, *note PyEval_SetProfileAllThreads():
     52a. and *note PyEval_SetTraceAllThreads(): 52b, that allow to set
     tracing and profiling functions in all running threads in addition
     to the calling one.  (Contributed by Pablo Galindo in gh-93503(9).)

   * Add new function *note PyFunction_SetVectorcall(): 52c. to the C
     API which sets the vectorcall field of a given *note
     PyFunctionObject: 52d.  (Contributed by Andrew Frost in
     gh-92257(10).)

   * The C API now permits registering callbacks via *note
     PyDict_AddWatcher(): 52e, *note PyDict_Watch(): 52f. and related
     APIs to be called whenever a dictionary is modified.  This is
     intended for use by optimizing interpreters, JIT compilers, or
     debuggers.  (Contributed by Carl Meyer in gh-91052(11).)

   * Add *note PyType_AddWatcher(): 530. and *note PyType_Watch(): 531.
     API to register callbacks to receive notification on changes to a
     type.  (Contributed by Carl Meyer in gh-91051(12).)

   * Add *note PyCode_AddWatcher(): 532. and *note
     PyCode_ClearWatcher(): 533. APIs to register callbacks to receive
     notification on creation and destruction of code objects.
     (Contributed by Itamar Oren in gh-91054(13).)

   * Add *note PyFrame_GetVar(): 534. and *note PyFrame_GetVarString():
     535. functions to get a frame variable by its name.  (Contributed
     by Victor Stinner in gh-91248(14).)

   * Add *note PyErr_GetRaisedException(): 3cd. and *note
     PyErr_SetRaisedException(): 3d0. for saving and restoring the
     current exception.  These functions return and accept a single
     exception object, rather than the triple arguments of the
     now-deprecated *note PyErr_Fetch(): 3cc. and *note PyErr_Restore():
     3cf.  This is less error prone and a bit more efficient.
     (Contributed by Mark Shannon in gh-101578(15).)

   * Add ‘_PyErr_ChainExceptions1’, which takes an exception instance,
     to replace the legacy-API ‘_PyErr_ChainExceptions’, which is now
     deprecated.  (Contributed by Mark Shannon in gh-101578(16).)

   * Add *note PyException_GetArgs(): 536. and *note
     PyException_SetArgs(): 537. as convenience functions for retrieving
     and modifying the *note args: 538. passed to the exception's
     constructor.  (Contributed by Mark Shannon in gh-101578(17).)

   * Add *note PyErr_DisplayException(): 3db, which takes an exception
     instance, to replace the legacy-api ‘PyErr_Display()’.
     (Contributed by Irit Katriel in gh-102755(18)).

   * PEP 683(19): Introduce 'Immortal Objects', which allows objects to
     bypass reference counts, and related changes to the C-API:

        - 
          ‘_Py_IMMORTAL_REFCNT’: The reference count that defines an object

               as immortal.

        - ‘_Py_IsImmortal’ Checks if an object has the immortal
          reference count.

        - 
          ‘PyObject_HEAD_INIT’ This will now initialize reference count to

               ‘_Py_IMMORTAL_REFCNT’ when used with ‘Py_BUILD_CORE’.

        - 
          ‘SSTATE_INTERNED_IMMORTAL’ An identifier for interned unicode objects

               that are immortal.

        - 
          ‘SSTATE_INTERNED_IMMORTAL_STATIC’ An identifier for interned unicode

               objects that are immortal and static

        - 
          ‘sys.getunicodeinternedsize’ This returns the total number of unicode

               objects that have been interned.  This is now needed for
               ‘refleak.py’ to correctly track reference counts and
               allocated blocks

     (Contributed by Eddie Elizondo in gh-84436(20).)

   * PEP 684(21): Add the new *note Py_NewInterpreterFromConfig(): 428.
     function and *note PyInterpreterConfig: 539, which may be used to
     create sub-interpreters with their own GILs.  (See *note PEP 684; A
     Per-Interpreter GIL: 408. for more info.)  (Contributed by Eric
     Snow in gh-104110(22).)

   * In the limited C API version 3.12, *note Py_INCREF(): 53a. and
     *note Py_DECREF(): 53b. functions are now implemented as opaque
     function calls to hide implementation details.  (Contributed by
     Victor Stinner in gh-105387(23).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0697/

   (2) https://peps.python.org/pep-0523/

   (3) https://github.com/python/cpython/issues/101101

   (4) https://peps.python.org/pep-0697/

   (5) https://github.com/python/cpython/issues/103509

   (6) https://github.com/python/cpython/issues/93012

   (7) https://github.com/python/cpython/issues/93274

   (8) https://github.com/python/cpython/issues/98586

   (9) https://github.com/python/cpython/issues/93503

   (10) https://github.com/python/cpython/issues/92257

   (11) https://github.com/python/cpython/issues/91052

   (12) https://github.com/python/cpython/issues/91051

   (13) https://github.com/python/cpython/issues/91054

   (14) https://github.com/python/cpython/issues/91248

   (15) https://github.com/python/cpython/issues/101578

   (16) https://github.com/python/cpython/issues/101578

   (17) https://github.com/python/cpython/issues/101578

   (18) https://github.com/python/cpython/issues/102755

   (19) https://peps.python.org/pep-0683/

   (20) https://github.com/python/cpython/issues/84436

   (21) https://peps.python.org/pep-0684/

   (22) https://github.com/python/cpython/issues/104110

   (23) https://github.com/python/cpython/issues/105387


File: python.info,  Node: Porting to Python 3 12<2>,  Next: Deprecated<2>,  Prev: New Features<4>,  Up: C API Changes<2>

1.2.14.2 Porting to Python 3.12
...............................

   * Legacy Unicode APIs based on ‘Py_UNICODE*’ representation has been
     removed.  Please migrate to APIs based on UTF-8 or ‘wchar_t*’.

   * Argument parsing functions like *note PyArg_ParseTuple(): 53d.
     doesn't support ‘Py_UNICODE*’ based format (e.g.  ‘u’, ‘Z’)
     anymore.  Please migrate to other formats for Unicode like ‘s’,
     ‘z’, ‘es’, and ‘U’.

   * ‘tp_weaklist’ for all static builtin types is always ‘NULL’.  This
     is an internal-only field on ‘PyTypeObject’ but we're pointing out
     the change in case someone happens to be accessing the field
     directly anyway.  To avoid breakage, consider using the existing
     public C-API instead, or, if necessary, the (internal-only)
     ‘_PyObject_GET_WEAKREFS_LISTPTR()’ macro.

   * This internal-only *note PyTypeObject.tp_subclasses: 53e. may now
     not be a valid object pointer.  Its type was changed to void* to
     reflect this.  We mention this in case someone happens to be
     accessing the internal-only field directly.

     To get a list of subclasses, call the Python method *note
     __subclasses__(): 53f. (using *note PyObject_CallMethod(): 379, for
     example).

   * Add support of more formatting options (left aligning, octals,
     uppercase hexadecimals, ‘intmax_t’, ‘ptrdiff_t’, ‘wchar_t’ C
     strings, variable width and precision) in *note
     PyUnicode_FromFormat(): 363. and *note PyUnicode_FromFormatV():
     540.  (Contributed by Serhiy Storchaka in gh-98836(1).)

   * An unrecognized format character in *note PyUnicode_FromFormat():
     363. and *note PyUnicode_FromFormatV(): 540. now sets a *note
     SystemError: 541.  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.  (Contributed by Serhiy Storchaka in
     gh-95781(2).)

   * Fix wrong sign placement in *note PyUnicode_FromFormat(): 363. and
     *note PyUnicode_FromFormatV(): 540.  (Contributed by Philip Georgi
     in gh-95504(3).)

   * Extension classes wanting to add a *note __dict__: 526. or weak
     reference slot should use *note Py_TPFLAGS_MANAGED_DICT: 344. and
     *note Py_TPFLAGS_MANAGED_WEAKREF: 525. instead of ‘tp_dictoffset’
     and ‘tp_weaklistoffset’, respectively.  The use of ‘tp_dictoffset’
     and ‘tp_weaklistoffset’ is still supported, but does not fully
     support multiple inheritance (gh-95589(4)), and performance may be
     worse.  Classes declaring *note Py_TPFLAGS_MANAGED_DICT: 344. must
     call ‘_PyObject_VisitManagedDict()’ and
     ‘_PyObject_ClearManagedDict()’ to traverse and clear their
     instance's dictionaries.  To clear weakrefs, call *note
     PyObject_ClearWeakRefs(): 542, as before.

   * The *note PyUnicode_FSDecoder(): 543. function no longer accepts
     bytes-like paths, like *note bytearray: 508. and *note memoryview:
     435. types: only the exact *note bytes: 1a4. type is accepted for
     bytes strings.  (Contributed by Victor Stinner in gh-98393(5).)

   * The *note Py_CLEAR: 544, *note Py_SETREF: 545. and *note
     Py_XSETREF: 546. macros now only evaluate their arguments once.  If
     an argument has side effects, these side effects are no longer
     duplicated.  (Contributed by Victor Stinner in gh-98724(6).)

   * The interpreter's error indicator is now always normalized.  This
     means that *note PyErr_SetObject(): 547, *note PyErr_SetString():
     548. and the other functions that set the error indicator now
     normalize the exception before storing it.  (Contributed by Mark
     Shannon in gh-101578(7).)

   * ‘_Py_RefTotal’ is no longer authoritative and only kept around for
     ABI compatibility.  Note that it is an internal global and only
     available on debug builds.  If you happen to be using it then
     you'll need to start using ‘_Py_GetGlobalRefTotal()’.

   * The following functions now select an appropriate metaclass for the
     newly created type:

        * *note PyType_FromSpec(): 549.

        * *note PyType_FromSpecWithBases(): 54a.

        * *note PyType_FromModuleAndSpec(): 51c.

     Creating classes whose metaclass overrides *note tp_new: 54b. is
     deprecated, and in Python 3.14+ it will be disallowed.  Note that
     these functions ignore ‘tp_new’ of the metaclass, possibly allowing
     incomplete initialization.

     Note that *note PyType_FromMetaclass(): 51b. (added in Python 3.12)
     already disallows creating classes whose metaclass overrides
     ‘tp_new’ (*note __new__(): 54c. in Python).

     Since ‘tp_new’ overrides almost everything ‘PyType_From*’ functions
     do, the two are incompatible with each other.  The existing
     behavior - ignoring the metaclass for several steps of type
     creation - is unsafe in general, since (meta)classes assume that
     ‘tp_new’ was called.  There is no simple general workaround.  One
     of the following may work for you:

        - If you control the metaclass, avoid using ‘tp_new’ in it:

             - If initialization can be skipped, it can be done in *note
               tp_init: 54d. instead.

             - If the metaclass doesn't need to be instantiated from
               Python, set its ‘tp_new’ to ‘NULL’ using the *note
               Py_TPFLAGS_DISALLOW_INSTANTIATION: 54e. flag.  This makes
               it acceptable for ‘PyType_From*’ functions.

        - Avoid ‘PyType_From*’ functions: if you don't need C-specific
          features (slots or setting the instance size), create types by
          *note calling: 54f. the metaclass.

        - If you 'know' the ‘tp_new’ can be skipped safely, filter the
          deprecation warning out using *note warnings.catch_warnings():
          550. from Python.

   * *note PyOS_InputHook: 551. and *note PyOS_ReadlineFunctionPointer:
     552. are no longer called in *note subinterpreters: 553.  This is
     because clients generally rely on process-wide global state (since
     these callbacks have no way of recovering extension module state).

     This also avoids situations where extensions may find themselves
     running in a subinterpreter that they don't support (or haven't yet
     been loaded in).  See gh-104668(8) for more info.

   * *note PyLongObject: 554. has had its internals changed for better
     performance.  Although the internals of *note PyLongObject: 554.
     are private, they are used by some extension modules.  The internal
     fields should no longer be accessed directly, instead the API
     functions beginning ‘PyLong_...’ should be used instead.  Two new
     'unstable' API functions are provided for efficient access to the
     value of *note PyLongObject: 554.s which fit into a single machine
     word:

        * *note PyUnstable_Long_IsCompact(): 555.

        * *note PyUnstable_Long_CompactValue(): 556.

   * Custom allocators, set via *note PyMem_SetAllocator(): 557, are now
     required to be thread-safe, regardless of memory domain.
     Allocators that don't have their own state, including "hooks", are
     not affected.  If your custom allocator is not already thread-safe
     and you need guidance then please create a new GitHub issue and CC
     ‘@ericsnowcurrently’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98836

   (2) https://github.com/python/cpython/issues/95781

   (3) https://github.com/python/cpython/issues/95504

   (4) https://github.com/python/cpython/issues/95589

   (5) https://github.com/python/cpython/issues/98393

   (6) https://github.com/python/cpython/issues/98724

   (7) https://github.com/python/cpython/issues/101578

   (8) https://github.com/python/cpython/issues/104668


File: python.info,  Node: Deprecated<2>,  Next: Removed<2>,  Prev: Porting to Python 3 12<2>,  Up: C API Changes<2>

1.2.14.3 Deprecated
...................

   * In accordance with PEP 699(1), the ‘ma_version_tag’ field in *note
     PyDictObject: 39b. is deprecated for extension modules.  Accessing
     this field will generate a compiler warning at compile time.  This
     field will be removed in Python 3.14.  (Contributed by Ramvikrams
     and Kumar Aditya in gh-101193(2).  PEP by Ken Jin.)

   * Deprecate global configuration variable:

        * *note Py_DebugFlag: 3a0.: use *note PyConfig.parser_debug:
          3a1.

        * *note Py_VerboseFlag: 3a2.: use *note PyConfig.verbose: 3a3.

        * *note Py_QuietFlag: 3a4.: use *note PyConfig.quiet: 3a5.

        * *note Py_InteractiveFlag: 3a6.: use *note
          PyConfig.interactive: 3a7.

        * *note Py_InspectFlag: 3a8.: use *note PyConfig.inspect: 3a9.

        * *note Py_OptimizeFlag: 3aa.: use *note
          PyConfig.optimization_level: 3ab.

        * *note Py_NoSiteFlag: 3ac.: use *note PyConfig.site_import:
          3ad.

        * *note Py_BytesWarningFlag: 3ae.: use *note
          PyConfig.bytes_warning: 3af.

        * *note Py_FrozenFlag: 3b0.: use *note
          PyConfig.pathconfig_warnings: 3b1.

        * *note Py_IgnoreEnvironmentFlag: 3b2.: use *note
          PyConfig.use_environment: 3b3.

        * *note Py_DontWriteBytecodeFlag: 3b4.: use *note
          PyConfig.write_bytecode: 3b5.

        * *note Py_NoUserSiteDirectory: 3b6.: use *note
          PyConfig.user_site_directory: 3b7.

        * *note Py_UnbufferedStdioFlag: 3b8.: use *note
          PyConfig.buffered_stdio: 3b9.

        * *note Py_HashRandomizationFlag: 3ba.: use *note
          PyConfig.use_hash_seed: 3bb. and *note PyConfig.hash_seed:
          3bc.

        * *note Py_IsolatedFlag: 3bd.: use *note PyConfig.isolated: 3be.

        * *note Py_LegacyWindowsFSEncodingFlag: 3bf.: use *note
          PyPreConfig.legacy_windows_fs_encoding: 3c0.

        * *note Py_LegacyWindowsStdioFlag: 3c1.: use *note
          PyConfig.legacy_windows_stdio: 37e.

        * ‘Py_FileSystemDefaultEncoding’: use *note
          PyConfig.filesystem_encoding: 3c2.

        * ‘Py_HasFileSystemDefaultEncoding’: use *note
          PyConfig.filesystem_encoding: 3c2.

        * ‘Py_FileSystemDefaultEncodeErrors’: use *note
          PyConfig.filesystem_errors: 3c3.

        * ‘Py_UTF8Mode’: use *note PyPreConfig.utf8_mode: 3c4. (see
          *note Py_PreInitialize(): 3c5.)

     The *note Py_InitializeFromConfig(): 39f. API should be used with
     *note PyConfig: 380. instead.  (Contributed by Victor Stinner in
     gh-77782(3).)

   * Creating *note immutable types: 39c. with mutable bases is
     deprecated and will be disabled in Python 3.14.  (gh-95388(4))

   * The ‘structmember.h’ header is deprecated, though it continues to
     be available and there are no plans to remove it.

     Its contents are now available just by including ‘Python.h’, with a
     ‘Py’ prefix added if it was missing:

        - *note PyMemberDef: 51a, *note PyMember_GetOne(): 559. and
          *note PyMember_SetOne(): 55a.

        - Type macros like *note Py_T_INT: 55b, *note Py_T_DOUBLE: 55c,
          etc.  (previously ‘T_INT’, ‘T_DOUBLE’, etc.)

        - The flags *note Py_READONLY: 55d. (previously ‘READONLY’) and
          *note Py_AUDIT_READ: 55e. (previously all uppercase)

     Several items are not exposed from ‘Python.h’:

        - *note T_OBJECT: 55f. (use *note Py_T_OBJECT_EX: 560.)

        - *note T_NONE: 561. (previously undocumented, and pretty
          quirky)

        - The macro ‘WRITE_RESTRICTED’ which does nothing.

        - The macros ‘RESTRICTED’ and ‘READ_RESTRICTED’, equivalents of
          *note Py_AUDIT_READ: 55e.

        - In some configurations, ‘<stddef.h>’ is not included from
          ‘Python.h’.  It should be included manually when using
          ‘offsetof()’.

     The deprecated header continues to provide its original contents
     under the original names.  Your old code can stay unchanged, unless
     the extra include and non-namespaced macros bother you greatly.

     (Contributed in gh-47146(5) by Petr Viktorin, based on earlier work
     by Alexander Belopolsky and Matthias Braun.)

   * *note PyErr_Fetch(): 3cc. and *note PyErr_Restore(): 3cf. are
     deprecated.  Use *note PyErr_GetRaisedException(): 3cd. and *note
     PyErr_SetRaisedException(): 3d0. instead.  (Contributed by Mark
     Shannon in gh-101578(6).)

   * ‘PyErr_Display()’ is deprecated.  Use *note
     PyErr_DisplayException(): 3db. instead.  (Contributed by Irit
     Katriel in gh-102755(7)).

   * ‘_PyErr_ChainExceptions’ is deprecated.  Use
     ‘_PyErr_ChainExceptions1’ instead.  (Contributed by Irit Katriel in
     gh-102192(8).)

   * Using *note PyType_FromSpec(): 549, *note
     PyType_FromSpecWithBases(): 54a. or *note
     PyType_FromModuleAndSpec(): 51c. to create a class whose metaclass
     overrides *note tp_new: 54b. is deprecated.  Call the metaclass
     instead.

* Menu:

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<4>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<4>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<4>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0699/

   (2) https://github.com/python/cpython/issues/101193

   (3) https://github.com/python/cpython/issues/77782

   (4) https://github.com/python/cpython/issues/95388

   (5) https://github.com/python/cpython/issues/47146

   (6) https://github.com/python/cpython/issues/101578

   (7) https://github.com/python/cpython/issues/102755

   (8) https://github.com/python/cpython/issues/102192


File: python.info,  Node: Pending Removal in Python 3 14<4>,  Next: Pending Removal in Python 3 15<4>,  Up: Deprecated<2>

1.2.14.4 Pending Removal in Python 3.14
.......................................

   * The ‘ma_version_tag’ field in *note PyDictObject: 39b. for
     extension modules ( PEP 699(1); gh-101193(2)).

   * Creating *note immutable types: 39c. with mutable bases
     (gh-95388(3)).

   * Functions to configure Python's initialization, deprecated in
     Python 3.11:

        * ‘PySys_SetArgvEx()’: Set *note PyConfig.argv: 39d. instead.

        * ‘PySys_SetArgv()’: Set *note PyConfig.argv: 39d. instead.

        * ‘Py_SetProgramName()’: Set *note PyConfig.program_name: 39e.
          instead.

        * ‘Py_SetPythonHome()’: Set *note PyConfig.home: 395. instead.

     The *note Py_InitializeFromConfig(): 39f. API should be used with
     *note PyConfig: 380. instead.

   * Global configuration variables:

        * *note Py_DebugFlag: 3a0.: Use *note PyConfig.parser_debug:
          3a1. instead.

        * *note Py_VerboseFlag: 3a2.: Use *note PyConfig.verbose: 3a3.
          instead.

        * *note Py_QuietFlag: 3a4.: Use *note PyConfig.quiet: 3a5.
          instead.

        * *note Py_InteractiveFlag: 3a6.: Use *note
          PyConfig.interactive: 3a7. instead.

        * *note Py_InspectFlag: 3a8.: Use *note PyConfig.inspect: 3a9.
          instead.

        * *note Py_OptimizeFlag: 3aa.: Use *note
          PyConfig.optimization_level: 3ab. instead.

        * *note Py_NoSiteFlag: 3ac.: Use *note PyConfig.site_import:
          3ad. instead.

        * *note Py_BytesWarningFlag: 3ae.: Use *note
          PyConfig.bytes_warning: 3af. instead.

        * *note Py_FrozenFlag: 3b0.: Use *note
          PyConfig.pathconfig_warnings: 3b1. instead.

        * *note Py_IgnoreEnvironmentFlag: 3b2.: Use *note
          PyConfig.use_environment: 3b3. instead.

        * *note Py_DontWriteBytecodeFlag: 3b4.: Use *note
          PyConfig.write_bytecode: 3b5. instead.

        * *note Py_NoUserSiteDirectory: 3b6.: Use *note
          PyConfig.user_site_directory: 3b7. instead.

        * *note Py_UnbufferedStdioFlag: 3b8.: Use *note
          PyConfig.buffered_stdio: 3b9. instead.

        * *note Py_HashRandomizationFlag: 3ba.: Use *note
          PyConfig.use_hash_seed: 3bb. and *note PyConfig.hash_seed:
          3bc. instead.

        * *note Py_IsolatedFlag: 3bd.: Use *note PyConfig.isolated: 3be.
          instead.

        * *note Py_LegacyWindowsFSEncodingFlag: 3bf.: Use *note
          PyPreConfig.legacy_windows_fs_encoding: 3c0. instead.

        * *note Py_LegacyWindowsStdioFlag: 3c1.: Use *note
          PyConfig.legacy_windows_stdio: 37e. instead.

        * ‘Py_FileSystemDefaultEncoding’: Use *note
          PyConfig.filesystem_encoding: 3c2. instead.

        * ‘Py_HasFileSystemDefaultEncoding’: Use *note
          PyConfig.filesystem_encoding: 3c2. instead.

        * ‘Py_FileSystemDefaultEncodeErrors’: Use *note
          PyConfig.filesystem_errors: 3c3. instead.

        * ‘Py_UTF8Mode’: Use *note PyPreConfig.utf8_mode: 3c4. instead.
          (see *note Py_PreInitialize(): 3c5.)

     The *note Py_InitializeFromConfig(): 39f. API should be used with
     *note PyConfig: 380. instead.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0699/

   (2) https://github.com/python/cpython/issues/101193

   (3) https://github.com/python/cpython/issues/95388


File: python.info,  Node: Pending Removal in Python 3 15<4>,  Next: Pending Removal in Future Versions<4>,  Prev: Pending Removal in Python 3 14<4>,  Up: Deprecated<2>

1.2.14.5 Pending Removal in Python 3.15
.......................................

   * The bundled copy of ‘libmpdecimal’.

   * The *note PyImport_ImportModuleNoBlock(): 397.: Use *note
     PyImport_ImportModule(): 398. instead.

   * *note PyWeakref_GetObject(): 352. and *note PyWeakref_GET_OBJECT():
     399.: Use *note PyWeakref_GetRef(): 351. instead.

   * *note Py_UNICODE: 3c7. type and the ‘Py_UNICODE_WIDE’ macro: Use
     ‘wchar_t’ instead.

   * Python initialization functions:

        * *note PySys_ResetWarnOptions(): 389.: Clear *note
          sys.warnoptions: 38a. and ‘warnings.filters’ instead.

        * *note Py_GetExecPrefix(): 38b.: Get *note
          sys.base_exec_prefix: 3c8. and *note sys.exec_prefix: 38c.
          instead.

        * *note Py_GetPath(): 38d.: Get *note sys.path: 38e. instead.

        * *note Py_GetPrefix(): 38f.: Get *note sys.base_prefix: 3c9.
          and *note sys.prefix: 390. instead.

        * *note Py_GetProgramFullPath(): 391.: Get *note sys.executable:
          392. instead.

        * *note Py_GetProgramName(): 393.: Get *note sys.executable:
          392. instead.

        * *note Py_GetPythonHome(): 394.: Get *note PyConfig.home: 395.
          or the *note PYTHONHOME: 396. environment variable instead.


File: python.info,  Node: Pending Removal in Future Versions<4>,  Prev: Pending Removal in Python 3 15<4>,  Up: Deprecated<2>

1.2.14.6 Pending Removal in Future Versions
...........................................

The following APIs are deprecated and will be removed, although there is
currently no date scheduled for their removal.

   * *note Py_TPFLAGS_HAVE_FINALIZE: 3cb.: Unneeded since Python 3.8.

   * *note PyErr_Fetch(): 3cc.: Use *note PyErr_GetRaisedException():
     3cd. instead.

   * *note PyErr_NormalizeException(): 3ce.: Use *note
     PyErr_GetRaisedException(): 3cd. instead.

   * *note PyErr_Restore(): 3cf.: Use *note PyErr_SetRaisedException():
     3d0. instead.

   * *note PyModule_GetFilename(): 3d1.: Use *note
     PyModule_GetFilenameObject(): 3d2. instead.

   * *note PyOS_AfterFork(): 3d3.: Use *note PyOS_AfterFork_Child():
     3d4. instead.

   * *note PySlice_GetIndicesEx(): 3d5.: Use *note PySlice_Unpack():
     3d6. and *note PySlice_AdjustIndices(): 3d7. instead.

   * ‘PyUnicode_AsDecodedObject()’: Use *note PyCodec_Decode(): 3d8.
     instead.

   * ‘PyUnicode_AsDecodedUnicode()’: Use *note PyCodec_Decode(): 3d8.
     instead.

   * ‘PyUnicode_AsEncodedObject()’: Use *note PyCodec_Encode(): 3d9.
     instead.

   * ‘PyUnicode_AsEncodedUnicode()’: Use *note PyCodec_Encode(): 3d9.
     instead.

   * *note PyUnicode_READY(): 3da.: Unneeded since Python 3.12

   * ‘PyErr_Display()’: Use *note PyErr_DisplayException(): 3db.
     instead.

   * ‘_PyErr_ChainExceptions()’: Use ‘_PyErr_ChainExceptions1()’
     instead.

   * ‘PyBytesObject.ob_shash’ member: call *note PyObject_Hash(): 3dc.
     instead.

   * ‘PyDictObject.ma_version_tag’ member.

   * Thread Local Storage (TLS) API:

        * *note PyThread_create_key(): 3dd.: Use *note
          PyThread_tss_alloc(): 3de. instead.

        * *note PyThread_delete_key(): 3df.: Use *note
          PyThread_tss_free(): 3e0. instead.

        * *note PyThread_set_key_value(): 3e1.: Use *note
          PyThread_tss_set(): 3e2. instead.

        * *note PyThread_get_key_value(): 3e3.: Use *note
          PyThread_tss_get(): 3e4. instead.

        * *note PyThread_delete_key_value(): 3e5.: Use *note
          PyThread_tss_delete(): 3e6. instead.

        * *note PyThread_ReInitTLS(): 3e7.: Unneeded since Python 3.7.


File: python.info,  Node: Removed<2>,  Prev: Deprecated<2>,  Up: C API Changes<2>

1.2.14.7 Removed
................

   * Remove the ‘token.h’ header file.  There was never any public
     tokenizer C API. The ‘token.h’ header file was only designed to be
     used by Python internals.  (Contributed by Victor Stinner in
     gh-92651(1).)

   * Legacy Unicode APIs have been removed.  See PEP 623(2) for detail.

        * ‘PyUnicode_WCHAR_KIND’

        * ‘PyUnicode_AS_UNICODE()’

        * ‘PyUnicode_AsUnicode()’

        * ‘PyUnicode_AsUnicodeAndSize()’

        * ‘PyUnicode_AS_DATA()’

        * ‘PyUnicode_FromUnicode()’

        * ‘PyUnicode_GET_SIZE()’

        * ‘PyUnicode_GetSize()’

        * ‘PyUnicode_GET_DATA_SIZE()’

   * Remove the ‘PyUnicode_InternImmortal()’ function macro.
     (Contributed by Victor Stinner in gh-85858(3).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92651

   (2) https://peps.python.org/pep-0623/

   (3) https://github.com/python/cpython/issues/85858


File: python.info,  Node: What's New In Python 3 11,  Next: What's New In Python 3 10,  Prev: What's New In Python 3 12,  Up: What's New in Python

1.3 What's New In Python 3.11
=============================


編集者: Pablo Galindo Salgado

この記事では Python 3.10 と比較した Python 3.11 の新機能を解説します。
Python 3.11 は2022年10月24日にリリースされました。全詳細については *note
変更履歴: 122. をご覧ください。

* Menu:

* 概要: 概要 -- リリースハイライト. リリースハイライト
* 新しい機能::
* 型ヒントに関連する新しい機能::
* その他の言語変更::
* その他の CPython の実装の変更::
* 新たなモジュール::
* 改良されたモジュール::
* 最適化::
* Faster CPython::
* CPython バイトコードの変更::
* 非推奨::
* Pending Removal in Python 3.12: Pending Removal in Python 3 12.
* 削除::
* Porting to Python 3.11: Porting to Python 3 11.
* Build Changes: Build Changes<3>.
* C API の変更::
* Python 3.11.4での重要な変更点: Python 3 11 4での重要な変更点.
* Python 3.11.5での重要な変更点: Python 3 11 5での重要な変更点.


File: python.info,  Node: 概要 -- リリースハイライト,  Next: 新しい機能,  Up: What's New In Python 3 11

1.3.1 概要 - リリースハイライト
-------------------------------

   * Python 3.11 は Python 3.10 とくらべて 10-60% 高速です。平均的には、
     標準ベンチマークスイートでは 1.25倍の高速化を計測しました。詳細につ
     いては *note Faster CPython: 56a. を見てください。

新たな文法機能:

   * *note PEP 654; 例外グループと except*: 56b.

新たな組み込み機能:

   * *note PEP 678; ノートによって例外を充実させる: 56c.

新しい標準ライブラリのモジュール：

   * PEP 680(1): *note tomllib: e5. — TOML(2) のパースを標準ライブラリで
     サポート

インタープリタの改善:

   * *note PEP 657; トレースバックのエラー位置の詳細化: 56d.

   * 新しい *note -P: 56e. コマンドライン引数と *note PYTHONSAFEPATH:
     56f. 環境変数により、 *note 安全でない可能性のあるパス: 570. を
     *note sys.path: 38e. に自動的に先頭に付加しないようにします。

新しい型ヒントの機能:

   * *note PEP 646; Variadic generics: 571.

   * *note PEP 655; Marking individual TypedDict items as required or
     not-required: 572.

   * *note PEP 673; Self 型: 573.

   * *note PEP 675; Arbitrary literal string type: 574.

   * *note PEP 681; Data class transforms: 575.

重要な非推奨化、削除と制限：

   * PEP 594(3): *note
     たくさんのレガシーの標準ライブラリのモジュールが非推奨になり: 576.
     Python 3.13 で削除されます

   * PEP 624(4): *note Py_UNICODE エンコーダー API は削除されました:
     577.

   * PEP 670(5): *note 静的インライン関数に変換されたマクロ: 578.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0680/

   (2) https://toml.io/

   (3) https://peps.python.org/pep-0594/

   (4) https://peps.python.org/pep-0624/

   (5) https://peps.python.org/pep-0670/


File: python.info,  Node: 新しい機能,  Next: 型ヒントに関連する新しい機能,  Prev: 概要 -- リリースハイライト,  Up: What's New In Python 3 11

1.3.2 新しい機能
----------------

* Menu:

* PEP 657; トレースバックのエラー位置の詳細化: PEP 657 トレースバックのエラー位置の詳細化.
* PEP 654; 例外グループと except*: PEP 654 例外グループと except*.
* PEP 678; ノートによって例外を充実させる: PEP 678 ノートによって例外を充実させる.
* Windows py.exe ランチャーの改善: Windows py exe ランチャーの改善.


File: python.info,  Node: PEP 657 トレースバックのエラー位置の詳細化,  Next: PEP 654 例外グループと except*,  Up: 新しい機能

1.3.2.1 PEP 657: トレースバックのエラー位置の詳細化
...................................................

トレースバックの出力時に、インタープリタはエラーを送出した行だけでなく正
確な式を指し示すようになりました。たとえば:

     Traceback (most recent call last):
       File "distance.py", line 11, in <module>
         print(manhattan_distance(p1, p2))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
       File "distance.py", line 6, in manhattan_distance
         return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
                                ^^^^^^^^^
     AttributeError: 'NoneType' object has no attribute 'x'

以前のバージョンのインタープリタはその行だけを指していたため、どのオブジ
ェクトが ‘None’ であるかが曖昧でした。これらの強化されたエラーは、深くネ
ストされた *note dict: 237. オブジェクトや複数の関数呼び出しを処理すると
きにも役立ちます:

     Traceback (most recent call last):
       File "query.py", line 37, in <module>
         magic_arithmetic('foo')
       File "query.py", line 18, in magic_arithmetic
         return add_counts(x) / 25
                ^^^^^^^^^^^^^
       File "query.py", line 24, in add_counts
         return 25 + query_user(user1) + query_user(user2)
                     ^^^^^^^^^^^^^^^^^
       File "query.py", line 32, in query_user
         return 1 + query_count(db, response['a']['b']['c']['user'], retry=True)
                                    ~~~~~~~~~~~~~~~~~~^^^^^
     TypeError: 'NoneType' object is not subscriptable

複雑な算術式と同様に:

     Traceback (most recent call last):
       File "calculation.py", line 54, in <module>
         result = (x / y / z) * (a / b / c)
                   ~~~~~~^~~
     ZeroDivisionError: division by zero

さらに、強化されたトレースバック機能で使用される情報は、一般的な API を
介して利用可能になり、 *note bytecode: 16c. *note 命令: 57c. とソースコ
ードの場所を関連付けるために使用できます。この情報は次を使用して取得でき
ます:

   - Python の *note codeobject.co_positions(): 57d. メソッド。

   - C API の *note PyCode_Addr2Location(): 57e. 関数。

詳細は PEP 657(1) を参照してください。(Pablo Galindo, Batuhan Taskaya,
Ammar Askar の貢献による bpo-43950(2))

     注釈: この機能は *note コードオブジェクト: 57f. に列の位置を保存す
     る必要があり、その結果コンパイルされた Pthon ファイルのインタープリ
     タのメモリ使用量とディスク使用量がわずかに増加する可能性があります
     。余分な情報を保存せず、余分なトレースバック情報を表示しないように
     するには *note -X no_debug_ranges: 15c. コマンドライン引数または
     *note PYTHONNODEBUGRANGES: 580. 環境変数を使用してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0657/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43950


File: python.info,  Node: PEP 654 例外グループと except*,  Next: PEP 678 ノートによって例外を充実させる,  Prev: PEP 657 トレースバックのエラー位置の詳細化,  Up: 新しい機能

1.3.2.2 PEP 654: 例外グループと ‘except*’
.........................................

PEP 654(1) では、プログラムが無関係な複数の例外を同時に送出させて処理で
きるようにする言語機能が導入されています。組み込み型 *note
ExceptionGroup: 19b. と *note BaseExceptionGroup: 240. を使用すると、例
外をグループ化して一緒に送出することができます。また、新しい *note
except*: 582. 構文は、 *note except: 170. を例外グループのサブグループに
マッチするように一般化したものです。

より詳しくは PEP 654(2) を参照してください。

(Irit Katriel の貢献による bpo-45292(3)。PEP はIrit Katriel, Yury
Selivanov, Guido van Rossum によって作成されました。)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0654/

   (2) https://peps.python.org/pep-0654/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45292


File: python.info,  Node: PEP 678 ノートによって例外を充実させる,  Next: Windows py exe ランチャーの改善,  Prev: PEP 654 例外グループと except*,  Up: 新しい機能

1.3.2.3 PEP 678: ノートによって例外を充実させる
...............................................

*note BaseException: 584. に *note add_note(): 585. メソッドが追加されま
した。これは例外が送出された時点では利用できないコンテキスト情報を例外に
付与するために使用できます。追加された注釈はデフォルトのトレースバックに
表示されます。

より詳しくは PEP 678(1) を参照してください。

(Irit Katriel の貢献による bpo-45607(2)。PEP は Zac Hatfield-Dodds によ
って作成されました。)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0678/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45607


File: python.info,  Node: Windows py exe ランチャーの改善,  Prev: PEP 678 ノートによって例外を充実させる,  Up: 新しい機能

1.3.2.4 Windows ‘py.exe’ ランチャーの改善
.........................................

Python 3.11 に含まれる *note Windows の Python ランチャ: 588. のコピーが
大幅に更新されました。 PEP 514(1) で定義されているように、制限付きの
‘-<MAJOR>.<MINOR>’ の代わりに ‘-V:<COMPANY>/<TAG>’ 引数を使用した
company/tag 構文をサポートするようになりました。これにより、
python.org(2) でホストされている ‘PythonCore’ 以外のディストリビューショ
ンを起動できるようになります。

When using ‘-V:’ selectors, either company or tag can be omitted, but
all installs will be searched.  For example, ‘-V:OtherPython/’ will
select the "best" tag registered for ‘OtherPython’, while ‘-V:3.11’ or
‘-V:/3.11’ will select the "best" distribution with tag ‘3.11’.

When using the legacy ‘-<MAJOR>’, ‘-<MAJOR>.<MINOR>’,
‘-<MAJOR>-<BITNESS>’ or ‘-<MAJOR>.<MINOR>-<BITNESS>’ arguments, all
existing behaviour should be preserved from past versions, and only
releases from ‘PythonCore’ will be selected.  However, the ‘-64’ suffix
now implies "not 32-bit" (not necessarily x86-64), as there are multiple
supported 64-bit platforms.  32-bit runtimes are detected by checking
the runtime's tag for a ‘-32’ suffix.  All releases of Python since 3.5
have included this in their 32-bit builds.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0514/

   (2) https://www.python.org


File: python.info,  Node: 型ヒントに関連する新しい機能,  Next: その他の言語変更,  Prev: 新しい機能,  Up: What's New In Python 3 11

1.3.3 型ヒントに関連する新しい機能
----------------------------------

This section covers major changes affecting PEP 484(1) type hints and
the *note typing: ed. module.

* Menu:

* PEP 646; Variadic generics: PEP 646 Variadic generics.
* PEP 655; Marking individual TypedDict items as required or not-required: PEP 655 Marking individual TypedDict items as required or not-required.
* PEP 673; Self 型: PEP 673 Self 型.
* PEP 675; Arbitrary literal string type: PEP 675 Arbitrary literal string type.
* PEP 681; Data class transforms: PEP 681 Data class transforms.
* PEP 563 may not be the future::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/


File: python.info,  Node: PEP 646 Variadic generics,  Next: PEP 655 Marking individual TypedDict items as required or not-required,  Up: 型ヒントに関連する新しい機能

1.3.3.1 PEP 646: Variadic generics
..................................

PEP 484(1) previously introduced *note TypeVar: 143, enabling creation
of generics parameterised with a single type.  PEP 646(2) adds *note
TypeVarTuple: 145, enabling parameterisation with an 'arbitrary' number
of types.  In other words, a *note TypeVarTuple: 145. is a 'variadic'
type variable, enabling 'variadic' generics.

This enables a wide variety of use cases.  In particular, it allows the
type of array-like structures in numerical computing libraries such as
NumPy and TensorFlow to be parameterised with the array 'shape'.  Static
type checkers will now be able to catch shape-related bugs in code that
uses these libraries.

より詳しくは PEP 646(3) を参照してください。

(Contributed by Matthew Rahtz in bpo-43224(4), with contributions by
Serhiy Storchaka and Jelle Zijlstra.  PEP written by Mark Mendoza,
Matthew Rahtz, Pradeep Kumar Srinivasan, and Vincent Siles.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0646/

   (3) https://peps.python.org/pep-0646/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43224


File: python.info,  Node: PEP 655 Marking individual TypedDict items as required or not-required,  Next: PEP 673 Self 型,  Prev: PEP 646 Variadic generics,  Up: 型ヒントに関連する新しい機能

1.3.3.2 PEP 655: Marking individual ‘TypedDict’ items as required or not-required
.................................................................................

*note Required: 58e. and *note NotRequired: 58f. provide a
straightforward way to mark whether individual items in a *note
TypedDict: 148. must be present.  Previously, this was only possible
using inheritance.

All fields are still required by default, unless the 'total' parameter
is set to ‘False’, in which case all fields are still not-required by
default.  For example, the following specifies a ‘TypedDict’ with one
required and one not-required key:

     class Movie(TypedDict):
        title: str
        year: NotRequired[int]

     m1: Movie = {"title": "Black Panther", "year": 2018}  # OK
     m2: Movie = {"title": "Star Wars"}  # OK (year is not required)
     m3: Movie = {"year": 2022}  # ERROR (missing required field title)

The following definition is equivalent:

     class Movie(TypedDict, total=False):
        title: Required[str]
        year: int

より詳しくは PEP 655(1) を参照してください。

(Contributed by David Foster and Jelle Zijlstra in bpo-47087(2).  PEP
written by David Foster.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0655/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=47087


File: python.info,  Node: PEP 673 Self 型,  Next: PEP 675 Arbitrary literal string type,  Prev: PEP 655 Marking individual TypedDict items as required or not-required,  Up: 型ヒントに関連する新しい機能

1.3.3.3 PEP 673: ‘Self’ 型
..........................

The new *note Self: 591. annotation provides a simple and intuitive way
to annotate methods that return an instance of their class.  This
behaves the same as the *note TypeVar: 143.-based approach specified in
PEP 484(1), but is more concise and easier to follow.

Common use cases include alternative constructors provided as *note
classmethod: 14c.s, and *note __enter__(): 592. methods that return
‘self’:

     class MyLock:
         def __enter__(self) -> Self:
             self.lock()
             return self

         ...

     class MyInt:
         @classmethod
         def fromhex(cls, s: str) -> Self:
             return cls(int(s, 16))

         ...

*note Self: 591. can also be used to annotate method parameters or
attributes of the same type as their enclosing class.

より詳しくは PEP 673(2) を参照してください。

(Contributed by James Hilton-Balfe in bpo-46534(3).  PEP written by
Pradeep Kumar Srinivasan and James Hilton-Balfe.)

   ---------- Footnotes ----------

   (1) 
https://peps.python.org/pep-0484/#annotating-instance-and-class-methods

   (2) https://peps.python.org/pep-0673/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46534


File: python.info,  Node: PEP 675 Arbitrary literal string type,  Next: PEP 681 Data class transforms,  Prev: PEP 673 Self 型,  Up: 型ヒントに関連する新しい機能

1.3.3.4 PEP 675: Arbitrary literal string type
..............................................

The new *note LiteralString: 594. annotation may be used to indicate
that a function parameter can be of any literal string type.  This
allows a function to accept arbitrary literal string types, as well as
strings created from other literal strings.  Type checkers can then
enforce that sensitive functions, such as those that execute SQL
statements or shell commands, are called only with static arguments,
providing protection against injection attacks.

For example, a SQL query function could be annotated as follows:

     def run_query(sql: LiteralString) -> ...
         ...

     def caller(
         arbitrary_string: str,
         query_string: LiteralString,
         table_name: LiteralString,
     ) -> None:
         run_query("SELECT * FROM students")       # ok
         run_query(query_string)                   # ok
         run_query("SELECT * FROM " + table_name)  # ok
         run_query(arbitrary_string)               # type checker error
         run_query(                                # type checker error
             f"SELECT * FROM students WHERE name = {arbitrary_string}"
         )

より詳しくは PEP 675(1) を参照してください。

(Contributed by Jelle Zijlstra in bpo-47088(2).  PEP written by Pradeep
Kumar Srinivasan and Graham Bleaney.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0675/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=47088


File: python.info,  Node: PEP 681 Data class transforms,  Next: PEP 563 may not be the future,  Prev: PEP 675 Arbitrary literal string type,  Up: 型ヒントに関連する新しい機能

1.3.3.5 PEP 681: Data class transforms
......................................

*note dataclass_transform: 4a0. may be used to decorate a class,
metaclass, or a function that is itself a decorator.  The presence of
‘@dataclass_transform()’ tells a static type checker that the decorated
object performs runtime "magic" that transforms a class, giving it *note
dataclass: 1ad.-like behaviors.

例えば:

     # The create_model decorator is defined by a library.
     @typing.dataclass_transform()
     def create_model(cls: Type[T]) -> Type[T]:
         cls.__init__ = ...
         cls.__eq__ = ...
         cls.__ne__ = ...
         return cls

     # The create_model decorator can now be used to create new model classes:
     @create_model
     class CustomerModel:
         id: int
         name: str

     c = CustomerModel(id=327, name="Eric Idle")

より詳しくは PEP 681(1) を参照してください。

(Contributed by Jelle Zijlstra in gh-91860(2).  PEP written by Erik De
Bonte and Eric Traut.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0681/

   (2) https://github.com/python/cpython/issues/91860


File: python.info,  Node: PEP 563 may not be the future,  Prev: PEP 681 Data class transforms,  Up: 型ヒントに関連する新しい機能

1.3.3.6 PEP 563 may not be the future
.....................................

PEP 563(1) Postponed Evaluation of Annotations (the ‘from __future__
import annotations’ *note future statement: 16e.) that was originally
planned for release in Python 3.10 has been put on hold indefinitely.
See this message from the Steering Council(2) for more information.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0563/

   (2) 
https://mail.python.org/archives/list/python-dev@python.org/message/VIZEBX5EYMSYIJNDBF6DMUMZOCWHARSO/


File: python.info,  Node: その他の言語変更,  Next: その他の CPython の実装の変更,  Prev: 型ヒントに関連する新しい機能,  Up: What's New In Python 3 11

1.3.4 その他の言語変更
----------------------

   * Starred unpacking expressions can now be used in *note for: 2c9.
     statements.  (See bpo-46725(1) for more details.)

   * Asynchronous *note comprehensions: 59a. are now allowed inside
     comprehensions in *note asynchronous functions: 59b.  Outer
     comprehensions implicitly become asynchronous in this case.
     (Contributed by Serhiy Storchaka in bpo-33346(2).)

   * A *note TypeError: 502. is now raised instead of an *note
     AttributeError: 326. in *note with: 59c. statements and *note
     contextlib.ExitStack.enter_context(): 59d. for objects that do not
     support the *note context manager: 59e. protocol, and in *note
     async with: 59f. statements and *note
     contextlib.AsyncExitStack.enter_async_context(): 5a0. for objects
     not supporting the *note asynchronous context manager: 5a1.
     protocol.  (Contributed by Serhiy Storchaka in bpo-12022(3) and
     bpo-44471(4).)

   * Added *note object.__getstate__(): 5a2, which provides the default
     implementation of the ‘__getstate__()’ method.  *note copy: 1e.ing
     and *note pickle: 95.ing instances of subclasses of builtin types
     *note bytearray: 508, *note set: 5a3, *note frozenset: 5a4, *note
     collections.OrderedDict: 5a5, *note collections.deque: 5a6, *note
     weakref.WeakSet: 5a7, and *note datetime.tzinfo: 5a8. now copies
     and pickles instance attributes implemented as *note slots: 5a9.
     This change has an unintended side effect: It trips up a small
     minority of existing Python projects not expecting *note
     object.__getstate__(): 5a2. to exist.  See the later comments on
     gh-70766(5) for discussions of what workarounds such code may need.
     (Contributed by Serhiy Storchaka in bpo-26579(6).)

   * Added a *note -P: 56e. command line option and a *note
     PYTHONSAFEPATH: 56f. environment variable, which disable the
     automatic prepending to *note sys.path: 38e. of the script's
     directory when running a script, or the current directory when
     using *note -c: 5aa. and *note -m: 5ab.  This ensures only stdlib
     and installed modules are picked up by *note import: 5ac, and
     avoids unintentionally or maliciously shadowing modules with those
     in a local (and typically user-writable) directory.  (Contributed
     by Victor Stinner in gh-57684(7).)

   * A ‘"z"’ option was added to the *note 書式指定ミニ言語仕様: 1c9.
     that coerces negative to positive zero after rounding to the format
     precision.  See PEP 682(8) for more details.  (Contributed by John
     Belmonte in gh-90153(9).)

   * Bytes are no longer accepted on *note sys.path: 38e.  Support broke
     sometime between Python 3.2 and 3.6, with no one noticing until
     after Python 3.10.0 was released.  In addition, bringing back
     support would be problematic due to interactions between *note -b:
     5ad. and *note sys.path_importer_cache: 5ae. when there is a
     mixture of *note str: 418. and *note bytes: 1a4. keys.
     (Contributed by Thomas Grainger in gh-91181(10).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46725

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33346

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12022

   (4) https://bugs.python.org/issue?@action=redirect&bpo=44471

   (5) https://github.com/python/cpython/issues/70766

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26579

   (7) https://github.com/python/cpython/issues/57684

   (8) https://peps.python.org/pep-0682/

   (9) https://github.com/python/cpython/issues/90153

   (10) https://github.com/python/cpython/issues/91181


File: python.info,  Node: その他の CPython の実装の変更,  Next: 新たなモジュール,  Prev: その他の言語変更,  Up: What's New In Python 3 11

1.3.5 その他の CPython の実装の変更
-----------------------------------

   * The special methods *note __complex__(): 5b1. for *note complex:
     2cf. and *note __bytes__(): 5b2. for *note bytes: 1a4. are
     implemented to support the *note typing.SupportsComplex: 5b3. and
     *note typing.SupportsBytes: 5b4. protocols.  (Contributed by Mark
     Dickinson and Donghee Na in bpo-24234(1).)

   * ‘siphash13’ is added as a new internal hashing algorithm.  It has
     similar security properties as ‘siphash24’, but it is slightly
     faster for long inputs.  *note str: 418, *note bytes: 1a4, and some
     other types now use it as the default algorithm for *note hash():
     5b5.  PEP 552(2) *note hash-based .pyc files: 5b6. now use
     ‘siphash13’ too.  (Contributed by Inada Naoki in bpo-29410(3).)

   * When an active exception is re-raised by a *note raise: 5b7.
     statement with no parameters, the traceback attached to this
     exception is now always ‘sys.exc_info()[1].__traceback__’.  This
     means that changes made to the traceback in the current *note
     except: 170. clause are reflected in the re-raised exception.
     (Contributed by Irit Katriel in bpo-45711(4).)

   * The interpreter state's representation of handled exceptions (aka
     ‘exc_info’ or ‘_PyErr_StackItem’) now only has the ‘exc_value’
     field; ‘exc_type’ and ‘exc_traceback’ have been removed, as they
     can be derived from ‘exc_value’.  (Contributed by Irit Katriel in
     bpo-45711(5).)

   * A new *note command line option: 5b8, ‘AppendPath’, has been added
     for the Windows installer.  It behaves similarly to ‘PrependPath’,
     but appends the install and scripts directories instead of
     prepending them.  (Contributed by Bastian Neuburger in
     bpo-44934(6).)

   * The *note PyConfig.module_search_paths_set: 5b9. field must now be
     set to ‘1’ for initialization to use *note
     PyConfig.module_search_paths: 37c. to initialize *note sys.path:
     38e.  Otherwise, initialization will recalculate the path and
     replace any values added to ‘module_search_paths’.

   * The output of the *note -help: 5ba. option now fits in 50 lines/80
     columns.  Information about *note Python environment variables:
     5bb. and *note -X: 15c. options is now available using the
     respective *note -help-env: 5bc. and *note -help-xoptions: 5bd.
     flags, and with the new *note -help-all: 5be.  (Contributed by Éric
     Araujo in bpo-46142(7).)

   * Converting between *note int: 238. and *note str: 418. in bases
     other than 2 (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such
     as base 10 (decimal) now raises a *note ValueError: 1e3. if the
     number of digits in string form is above a limit to avoid potential
     denial of service attacks due to the algorithmic complexity.  This
     is a mitigation for CVE 2020-10735(8).  This limit can be
     configured or disabled by environment variable, command line flag,
     or *note sys: c3. APIs.  See the *note integer string conversion
     length limitation: 5bf. documentation.  The default limit is 4300
     digits in string form.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24234

   (2) https://peps.python.org/pep-0552/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29410

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (6) https://bugs.python.org/issue?@action=redirect&bpo=44934

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46142

   (8) https://www.cve.org/CVERecord?id=CVE-2020-10735


File: python.info,  Node: 新たなモジュール,  Next: 改良されたモジュール,  Prev: その他の CPython の実装の変更,  Up: What's New In Python 3 11

1.3.6 新たなモジュール
----------------------

   * *note tomllib: e5.: For parsing TOML(1). See PEP 680(2) for more
     details.  (Contributed by Taneli Hukkinen in bpo-40059(3).)

   * *note wsgiref.types: 104.: WSGI(4)-specific types for static type
     checking.  (Contributed by Sebastian Rittau in bpo-42012(5).)

   ---------- Footnotes ----------

   (1) https://toml.io/

   (2) https://peps.python.org/pep-0680/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40059

   (4) https://peps.python.org/pep-3333/

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42012


File: python.info,  Node: 改良されたモジュール,  Next: 最適化,  Prev: 新たなモジュール,  Up: What's New In Python 3 11

1.3.7 改良されたモジュール
--------------------------

* Menu:

* asyncio: asyncio<3>.
* contextlib::
* データクラス::
* datetime::
* enum: enum<2>.
* fcntl::
* fractions: fractions<3>.
* functools::
* gzip: gzip<2>.
* hashlib: hashlib<2>.
* IDLE と idelelib::
* inspect: inspect<2>.
* locale: locale<3>.
* logging::
* math: math<3>.
* operator::
* os: os<3>.
* pathlib: pathlib<4>.
* re: re<3>.
* shutil: shutil<3>.
* socket::
* sqlite3: sqlite3<4>.
* string::
* sys: sys<4>.
* sysconfig::
* tempfile: tempfile<3>.
* threading: threading<2>.
* time: time<2>.
* tkinter: tkinter<3>.
* traceback: traceback<2>.
* typing: typing<4>.
* unicodedata: unicodedata<3>.
* unittest: unittest<4>.
* venv: venv<2>.
* warnings: warnings<2>.
* zipfile::


File: python.info,  Node: asyncio<3>,  Next: contextlib,  Up: 改良されたモジュール

1.3.7.1 asyncio
...............

   * Added the *note TaskGroup: 19a. class, an *note asynchronous
     context manager: 5c6. holding a group of tasks that will wait for
     all of them upon exit.  For new code this is recommended over using
     *note create_task(): 5c7. and *note gather(): 5c8. directly.
     (Contributed by Yury Selivanov and others in gh-90908(1).)

   * Added *note timeout(): 5c9, an asynchronous context manager for
     setting a timeout on asynchronous operations.  For new code this is
     recommended over using *note wait_for(): 5ca. directly.
     (Contributed by Andrew Svetlov in gh-90927(2).)

   * Added the *note Runner: 5cb. class, which exposes the machinery
     used by *note run(): 449.  (Contributed by Andrew Svetlov in
     gh-91218(3).)

   * Added the *note Barrier: 5cc. class to the synchronization
     primitives in the asyncio library, and the related *note
     BrokenBarrierError: 5cd. exception.  (Contributed by Yves Duprat
     and Andrew Svetlov in gh-87518(4).)

   * Added keyword argument 'all_errors' to *note
     asyncio.loop.create_connection(): 5ce. so that multiple connection
     errors can be raised as an *note ExceptionGroup: 19b.

   * Added the *note asyncio.StreamWriter.start_tls(): 5cf. method for
     upgrading existing stream-based connections to TLS. (Contributed by
     Ian Good in bpo-34975(5).)

   * Added raw datagram socket functions to the event loop: *note
     sock_sendto(): 5d0, *note sock_recvfrom(): 5d1. and *note
     sock_recvfrom_into(): 5d2.  These have implementations in *note
     SelectorEventLoop: 5d3. and *note ProactorEventLoop: 5d4.
     (Contributed by Alex Grönholm in bpo-46805(6).)

   * Added *note cancelling(): 19f. and *note uncancel(): 1a0. methods
     to *note Task: 4a5.  These are primarily intended for internal use,
     notably by *note TaskGroup: 19a.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/90908

   (2) https://github.com/python/cpython/issues/90927

   (3) https://github.com/python/cpython/issues/91218

   (4) https://github.com/python/cpython/issues/87518

   (5) https://bugs.python.org/issue?@action=redirect&bpo=34975

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46805


File: python.info,  Node: contextlib,  Next: データクラス,  Prev: asyncio<3>,  Up: 改良されたモジュール

1.3.7.2 contextlib
..................

   * Added non parallel-safe *note chdir(): 5d7. context manager to
     change the current working directory and then restore it on exit.
     Simple wrapper around *note chdir(): 5d8.  (Contributed by Filipe
     Laíns in bpo-25625(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25625


File: python.info,  Node: データクラス,  Next: datetime,  Prev: contextlib,  Up: 改良されたモジュール

1.3.7.3 データクラス
....................

   * Change field default mutability check, allowing only defaults which
     are *note hashable: 5db. instead of any object which is not an
     instance of *note dict: 237, *note list: 5dc. or *note set: 5a3.
     (Contributed by Eric V. Smith in bpo-44674(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44674


File: python.info,  Node: datetime,  Next: enum<2>,  Prev: データクラス,  Up: 改良されたモジュール

1.3.7.4 datetime
................

   * Add *note datetime.UTC: 4bb, a convenience alias for *note
     datetime.timezone.utc: 5df.  (Contributed by Kabir Kwatra in
     gh-91973(1).)

   * *note datetime.date.fromisoformat(): 5e0, *note
     datetime.time.fromisoformat(): 5e1. and *note
     datetime.datetime.fromisoformat(): 5e2. can now be used to parse
     most ISO 8601 formats (barring only those that support fractional
     hours and minutes).  (Contributed by Paul Ganssle in gh-80010(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/91973

   (2) https://github.com/python/cpython/issues/80010


File: python.info,  Node: enum<2>,  Next: fcntl,  Prev: datetime,  Up: 改良されたモジュール

1.3.7.5 enum
............

   * Renamed ‘EnumMeta’ to *note EnumType: 5e5. (‘EnumMeta’ kept as an
     alias).

   * Added *note StrEnum: 5e6, with members that can be used as (and
     must be) strings.

   * Added *note ReprEnum: 5e7, which only modifies the *note
     __repr__(): 5e8. of members while returning their literal values
     (rather than names) for *note __str__(): 5e9. and *note
     __format__(): 5ea. (used by *note str(): 418, *note format(): 5eb.
     and *note f-string: 402.s).

   * Changed *note Enum.__format__(): 5ec. (the default for *note
     format(): 5eb, *note str.format(): 5ed. and *note f-string: 402.s)
     to always produce the same result as *note Enum.__str__(): 5ee.:
     for enums inheriting from *note ReprEnum: 5e7. it will be the
     member's value; for all other enums it will be the enum and member
     name (e.g.  ‘Color.RED’).

   * Added a new 'boundary' class parameter to *note Flag: 5ef. enums
     and the *note FlagBoundary: 5f0. enum with its options, to control
     how to handle out-of-range flag values.

   * Added the *note verify(): 5f1. enum decorator and the *note
     EnumCheck: 5f2. enum with its options, to check enum classes
     against several specific constraints.

   * Added the *note member(): 5f3. and *note nonmember(): 5f4.
     decorators, to ensure the decorated object is/is not converted to
     an enum member.

   * Added the *note property(): 5f5. decorator, which works like *note
     property(): 179. except for enums.  Use this instead of *note
     types.DynamicClassAttribute(): 5f6.

   * Added the *note global_enum(): 5f7. enum decorator, which adjusts
     *note __repr__(): 5e8. and *note __str__(): 5e9. to show values as
     members of their module rather than the enum class.  For example,
     ‘'re.ASCII'’ for the *note ASCII: 5f8. member of *note
     re.RegexFlag: 5f9. rather than ‘'RegexFlag.ASCII'’.

   * Enhanced *note Flag: 5ef. to support *note len(): 5fa, iteration
     and *note in: 2cb./*note not in: 5fb. on its members.  For example,
     the following now works: ‘len(AFlag(3)) == 2 and list(AFlag(3)) ==
     (AFlag.ONE, AFlag.TWO)’

   * Changed *note Enum: 5fc. and *note Flag: 5ef. so that members are
     now defined before *note __init_subclass__(): 5fd. is called; *note
     dir(): 5fe. now includes methods, etc., from mixed-in data types.

   * Changed *note Flag: 5ef. to only consider primary values (power of
     two) canonical while composite values (‘3’, ‘6’, ‘10’, etc.)  are
     considered aliases; inverted flags are coerced to their positive
     equivalent.


File: python.info,  Node: fcntl,  Next: fractions<3>,  Prev: enum<2>,  Up: 改良されたモジュール

1.3.7.6 fcntl
.............

   * On FreeBSD, the ‘F_DUP2FD’ and ‘F_DUP2FD_CLOEXEC’ flags
     respectively are supported, the former equals to ‘dup2’ usage while
     the latter set the ‘FD_CLOEXEC’ flag in addition.


File: python.info,  Node: fractions<3>,  Next: functools,  Prev: fcntl,  Up: 改良されたモジュール

1.3.7.7 fractions
.................

   * Support PEP 515(1)-style initialization of *note Fraction: 1c8.
     from string.  (Contributed by Sergey B Kirpichev in bpo-44258(2).)

   * *note Fraction: 1c8. now implements an ‘__int__’ method, so that an
     ‘isinstance(some_fraction, typing.SupportsInt)’ check passes.
     (Contributed by Mark Dickinson in bpo-44547(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0515/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=44258

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44547


File: python.info,  Node: functools,  Next: gzip<2>,  Prev: fractions<3>,  Up: 改良されたモジュール

1.3.7.8 functools
.................

   * *note functools.singledispatch(): 605. now supports *note
     types.UnionType: 606. and *note typing.Union: 607. as annotations
     to the dispatch argument.:

          >>> from functools import singledispatch
          >>> @singledispatch
          ... def fun(arg, verbose=False):
          ...     if verbose:
          ...         print("Let me just say,", end=" ")
          ...     print(arg)
          ...
          >>> @fun.register
          ... def _(arg: int | float, verbose=False):
          ...     if verbose:
          ...         print("Strength in numbers, eh?", end=" ")
          ...     print(arg)
          ...
          >>> from typing import Union
          >>> @fun.register
          ... def _(arg: Union[list, set], verbose=False):
          ...     if verbose:
          ...         print("Enumerate this:")
          ...     for i, elem in enumerate(arg):
          ...         print(i, elem)
          ...

     (Contributed by Yurii Karabas in bpo-46014(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46014


File: python.info,  Node: gzip<2>,  Next: hashlib<2>,  Prev: functools,  Up: 改良されたモジュール

1.3.7.9 gzip
............

   * The *note gzip.compress(): 60a. function is now faster when used
     with the 'mtime=0' argument as it delegates the compression
     entirely to a single *note zlib.compress(): 60b. operation.  There
     is one side effect of this change: The gzip file header contains an
     "OS" byte in its header.  That was traditionally always set to a
     value of 255 representing "unknown" by the *note gzip: 5d. module.
     Now, when using *note compress(): 60a. with 'mtime=0', it may be
     set to a different value by the underlying zlib C library Python
     was linked against.  (See gh-112346(1) for details on the side
     effect.)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/112346


File: python.info,  Node: hashlib<2>,  Next: IDLE と idelelib,  Prev: gzip<2>,  Up: 改良されたモジュール

1.3.7.10 hashlib
................

   * *note hashlib.blake2b(): 60e. and *note hashlib.blake2s(): 60f. now
     prefer libb2(1) over Python's vendored copy.  (Contributed by
     Christian Heimes in bpo-47095(2).)

   * The internal ‘_sha3’ module with SHA3 and SHAKE algorithms now uses
     'tiny_sha3' instead of the 'Keccak Code Package' to reduce code and
     binary size.  The *note hashlib: 5e. module prefers optimized SHA3
     and SHAKE implementations from OpenSSL. The change affects only
     installations without OpenSSL support.  (Contributed by Christian
     Heimes in bpo-47098(3).)

   * Add *note hashlib.file_digest(): 610, a helper function for
     efficient hashing of files or file-like objects.  (Contributed by
     Christian Heimes in gh-89313(4).)

   ---------- Footnotes ----------

   (1) https://www.blake2.net/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=47095

   (3) https://bugs.python.org/issue?@action=redirect&bpo=47098

   (4) https://github.com/python/cpython/issues/89313


File: python.info,  Node: IDLE と idelelib,  Next: inspect<2>,  Prev: hashlib<2>,  Up: 改良されたモジュール

1.3.7.11 IDLE と idelelib
.........................

   * Apply syntax highlighting to ‘.pyi’ files.  (Contributed by Alex
     Waygood and Terry Jan Reedy in bpo-45447(1).)

   * Include prompts when saving Shell with inputs and outputs.
     (Contributed by Terry Jan Reedy in gh-95191(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45447

   (2) https://github.com/python/cpython/issues/95191


File: python.info,  Node: inspect<2>,  Next: locale<3>,  Prev: IDLE と idelelib,  Up: 改良されたモジュール

1.3.7.12 inspect
................

   * Add *note getmembers_static(): 615. to return all members without
     triggering dynamic lookup via the descriptor protocol.
     (Contributed by Weipeng Hong in bpo-30533(1).)

   * Add *note ismethodwrapper(): 616. for checking if the type of an
     object is a *note MethodWrapperType: 617.  (Contributed by Hakan
     Çelik in bpo-29418(2).)

   * Change the frame-related functions in the *note inspect: 72. module
     to return new *note FrameInfo: 618. and *note Traceback: 619. class
     instances (backwards compatible with the previous *note named
     tuple: 61a.-like interfaces) that includes the extended PEP 657(3)
     position information (end line number, column and end column).  The
     affected functions are:

        * *note inspect.getframeinfo(): 61b.

        * *note inspect.getouterframes(): 61c.

        * *note inspect.getinnerframes(): 61d,

        * *note inspect.stack(): 61e.

        * *note inspect.trace(): 61f.

     (Contributed by Pablo Galindo in gh-88116(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30533

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29418

   (3) https://peps.python.org/pep-0657/

   (4) https://github.com/python/cpython/issues/88116


File: python.info,  Node: locale<3>,  Next: logging,  Prev: inspect<2>,  Up: 改良されたモジュール

1.3.7.13 locale
...............

   * Add *note locale.getencoding(): 2be. to get the current locale
     encoding.  It is similar to ‘locale.getpreferredencoding(False)’
     but ignores the *note Python UTF-8 Mode: 622.


File: python.info,  Node: logging,  Next: math<3>,  Prev: locale<3>,  Up: 改良されたモジュール

1.3.7.14 logging
................

   * Added *note getLevelNamesMapping(): 625. to return a mapping from
     logging level names (e.g.  ‘'CRITICAL'’) to the values of their
     corresponding *note ロギングレベル: 626. (e.g.  ‘50’, by default).
     (Contributed by Andrei Kulakovin in gh-88024(1).)

   * Added a *note createSocket(): 627. method to *note SysLogHandler:
     628, to match *note SocketHandler.createSocket(): 629.  It is
     called automatically during handler initialization and when
     emitting an event, if there is no active socket.  (Contributed by
     Kirill Pinchuk in gh-88457(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/88024

   (2) https://github.com/python/cpython/issues/88457


File: python.info,  Node: math<3>,  Next: operator,  Prev: logging,  Up: 改良されたモジュール

1.3.7.15 math
.............

   * Add *note math.exp2(): 62c.: return 2 raised to the power of x.
     (Contributed by Gideon Mitchell in bpo-45917(1).)

   * Add *note math.cbrt(): 62d.: return the cube root of x.
     (Contributed by Ajith Ramachandran in bpo-44357(2).)

   * The behaviour of two *note math.pow(): 62e. corner cases was
     changed, for consistency with the IEEE 754 specification.  The
     operations ‘math.pow(0.0, -math.inf)’ and ‘math.pow(-0.0,
     -math.inf)’ now return ‘inf’.  Previously they raised *note
     ValueError: 1e3.  (Contributed by Mark Dickinson in bpo-44339(3).)

   * The *note math.nan: 62f. value is now always available.
     (Contributed by Victor Stinner in bpo-46917(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45917

   (2) https://bugs.python.org/issue?@action=redirect&bpo=44357

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44339

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46917


File: python.info,  Node: operator,  Next: os<3>,  Prev: math<3>,  Up: 改良されたモジュール

1.3.7.16 operator
.................

   * A new function ‘operator.call’ has been added, such that
     ‘operator.call(obj, *args, **kwargs) == obj(*args, **kwargs)’.
     (Contributed by Antony Lee in bpo-44019(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44019


File: python.info,  Node: os<3>,  Next: pathlib<4>,  Prev: operator,  Up: 改良されたモジュール

1.3.7.17 os
...........

   * On Windows, *note os.urandom(): 4ec. now uses ‘BCryptGenRandom()’,
     instead of ‘CryptGenRandom()’ which is deprecated.  (Contributed by
     Donghee Na in bpo-44611(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44611


File: python.info,  Node: pathlib<4>,  Next: re<3>,  Prev: os<3>,  Up: 改良されたモジュール

1.3.7.18 pathlib
................

   * *note glob(): 20e. and *note rglob(): 20f. return only directories
     if 'pattern' ends with a pathname components separator: *note sep:
     636. or *note altsep: 637.  (Contributed by Eisuke Kawasima in
     bpo-22276(1) and bpo-33392(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22276

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33392


File: python.info,  Node: re<3>,  Next: shutil<3>,  Prev: pathlib<4>,  Up: 改良されたモジュール

1.3.7.19 re
...........

   * Atomic grouping (‘(?>...)’) and possessive quantifiers (‘*+’, ‘++’,
     ‘?+’, ‘{m,n}+’) are now supported in regular expressions.
     (Contributed by Jeffrey C. Jacobs and Serhiy Storchaka in
     bpo-433030(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=433030


File: python.info,  Node: shutil<3>,  Next: socket,  Prev: re<3>,  Up: 改良されたモジュール

1.3.7.20 shutil
...............

   * Add optional parameter 'dir_fd' in *note shutil.rmtree(): 2d8.
     (Contributed by Serhiy Storchaka in bpo-46245(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46245


File: python.info,  Node: socket,  Next: sqlite3<4>,  Prev: shutil<3>,  Up: 改良されたモジュール

1.3.7.21 socket
...............

   * Add CAN Socket support for NetBSD. (Contributed by Thomas Klausner
     in bpo-30512(1).)

   * *note create_connection(): 63e. has an option to raise, in case of
     failure to connect, an *note ExceptionGroup: 19b. containing all
     errors instead of only raising the last error.  (Contributed by
     Irit Katriel in bpo-29980(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30512

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29980


File: python.info,  Node: sqlite3<4>,  Next: string,  Prev: socket,  Up: 改良されたモジュール

1.3.7.22 sqlite3
................

   * You can now disable the authorizer by passing *note None: 641. to
     *note set_authorizer(): 28b.  (Contributed by Erlend E. Aasland in
     bpo-44491(1).)

   * Collation name *note create_collation(): 642. can now contain any
     Unicode character.  Collation names with invalid characters now
     raise *note UnicodeEncodeError: 643. instead of *note
     sqlite3.ProgrammingError: 4bf.  (Contributed by Erlend E. Aasland
     in bpo-44688(2).)

   * *note sqlite3: ba. exceptions now include the SQLite extended error
     code as *note sqlite_errorcode: 644. and the SQLite error name as
     *note sqlite_errorname: 645.  (Contributed by Aviv Palivoda, Daniel
     Shahaf, and Erlend E. Aasland in bpo-16379(3) and bpo-24139(4).)

   * Add *note setlimit(): 646. and *note getlimit(): 647. to *note
     sqlite3.Connection: 226. for setting and getting SQLite limits by
     connection basis.  (Contributed by Erlend E. Aasland in
     bpo-45243(5).)

   * *note sqlite3: ba. now sets *note sqlite3.threadsafety: 648. based
     on the default threading mode the underlying SQLite library has
     been compiled with.  (Contributed by Erlend E. Aasland in
     bpo-45613(6).)

   * *note sqlite3: ba. C callbacks now use unraisable exceptions if
     callback tracebacks are enabled.  Users can now register an *note
     unraisable hook handler: 1d8. to improve their debug experience.
     (Contributed by Erlend E. Aasland in bpo-45828(7).)

   * Fetch across rollback no longer raises *note InterfaceError: 649.
     Instead we leave it to the SQLite library to handle these cases.
     (Contributed by Erlend E. Aasland in bpo-44092(8).)

   * Add *note serialize(): 64a. and *note deserialize(): 64b. to *note
     sqlite3.Connection: 226. for serializing and deserializing
     databases.  (Contributed by Erlend E. Aasland in bpo-41930(9).)

   * Add *note create_window_function(): 64c. to *note
     sqlite3.Connection: 226. for creating aggregate window functions.
     (Contributed by Erlend E. Aasland in bpo-34916(10).)

   * Add *note blobopen(): 64d. to *note sqlite3.Connection: 226.  *note
     sqlite3.Blob: 64e. allows incremental I/O operations on blobs.
     (Contributed by Aviv Palivoda and Erlend E. Aasland in
     bpo-24905(11).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44491

   (2) https://bugs.python.org/issue?@action=redirect&bpo=44688

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16379

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24139

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45243

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45613

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45828

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44092

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41930

   (10) https://bugs.python.org/issue?@action=redirect&bpo=34916

   (11) https://bugs.python.org/issue?@action=redirect&bpo=24905


File: python.info,  Node: string,  Next: sys<4>,  Prev: sqlite3<4>,  Up: 改良されたモジュール

1.3.7.23 string
...............

   * Add *note get_identifiers(): 651. and *note is_valid(): 652. to
     *note string.Template: 653, which respectively return all valid
     placeholders, and whether any invalid placeholders are present.
     (Contributed by Ben Kehoe in gh-90465(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/90465


File: python.info,  Node: sys<4>,  Next: sysconfig,  Prev: string,  Up: 改良されたモジュール

1.3.7.24 sys
............

   * *note sys.exc_info(): 656. now derives the ‘type’ and ‘traceback’
     fields from the ‘value’ (the exception instance), so when an
     exception is modified while it is being handled, the changes are
     reflected in the results of subsequent calls to ‘exc_info()’.
     (Contributed by Irit Katriel in bpo-45711(1).)

   * Add *note sys.exception(): 657. which returns the active exception
     instance (equivalent to ‘sys.exc_info()[1]’).  (Contributed by Irit
     Katriel in bpo-46328(2).)

   * Add the *note sys.flags.safe_path: 658. flag.  (Contributed by
     Victor Stinner in gh-57684(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46328

   (3) https://github.com/python/cpython/issues/57684


File: python.info,  Node: sysconfig,  Next: tempfile<3>,  Prev: sys<4>,  Up: 改良されたモジュール

1.3.7.25 sysconfig
..................

   * Three new *note installation schemes: 65b. ('posix_venv', 'nt_venv'
     and 'venv') were added and are used when Python creates new virtual
     environments or when it is running from a virtual environment.  The
     first two schemes ('posix_venv' and 'nt_venv') are OS-specific for
     non-Windows and Windows, the 'venv' is essentially an alias to one
     of them according to the OS Python runs on.  This is useful for
     downstream distributors who modify *note
     sysconfig.get_preferred_scheme(): 65c.  Third party code that
     creates new virtual environments should use the new 'venv'
     installation scheme to determine the paths, as does *note venv: f9.
     (Contributed by Miro Hrončok in bpo-45413(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45413


File: python.info,  Node: tempfile<3>,  Next: threading<2>,  Prev: sysconfig,  Up: 改良されたモジュール

1.3.7.26 tempfile
.................

   * *note SpooledTemporaryFile: 65f. objects now fully implement the
     methods of *note io.BufferedIOBase: 660. or *note io.TextIOBase:
     661. (depending on file mode).  This lets them work correctly with
     APIs that expect file-like objects, such as compression modules.
     (Contributed by Carey Metcalfe in gh-70363(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/70363


File: python.info,  Node: threading<2>,  Next: time<2>,  Prev: tempfile<3>,  Up: 改良されたモジュール

1.3.7.27 threading
..................

   * On Unix, if the ‘sem_clockwait()’ function is available in the C
     library (glibc 2.30 and newer), the *note threading.Lock.acquire():
     664. method now uses the monotonic clock (*note
     time.CLOCK_MONOTONIC: 665.) for the timeout, rather than using the
     system clock (*note time.CLOCK_REALTIME: 666.), to not be affected
     by system clock changes.  (Contributed by Victor Stinner in
     bpo-41710(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41710


File: python.info,  Node: time<2>,  Next: tkinter<3>,  Prev: threading<2>,  Up: 改良されたモジュール

1.3.7.28 time
.............

   * On Unix, *note time.sleep(): 669. now uses the ‘clock_nanosleep()’
     or ‘nanosleep()’ function, if available, which has a resolution of
     1 nanosecond (10^-9 seconds), rather than using ‘select()’ which
     has a resolution of 1 microsecond (10^-6 seconds).  (Contributed by
     Benjamin Szőke and Victor Stinner in bpo-21302(1).)

   * On Windows 8.1 and newer, *note time.sleep(): 669. now uses a
     waitable timer based on high-resolution timers(2) which has a
     resolution of 100 nanoseconds (10^-7 seconds).  Previously, it had
     a resolution of 1 millisecond (10^-3 seconds).  (Contributed by
     Benjamin Szőke, Donghee Na, Eryk Sun and Victor Stinner in
     bpo-21302(3) and bpo-45429(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21302

   (2) 
https://docs.microsoft.com/en-us/windows-hardware/drivers/kernel/high-resolution-timers

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21302

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45429


File: python.info,  Node: tkinter<3>,  Next: traceback<2>,  Prev: time<2>,  Up: 改良されたモジュール

1.3.7.29 tkinter
................

   * Added method ‘info_patchlevel()’ which returns the exact version of
     the Tcl library as a named tuple similar to *note sys.version_info:
     66c.  (Contributed by Serhiy Storchaka in gh-91827(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/91827


File: python.info,  Node: traceback<2>,  Next: typing<4>,  Prev: tkinter<3>,  Up: 改良されたモジュール

1.3.7.30 traceback
..................

   * Add *note traceback.StackSummary.format_frame_summary(): 66f. to
     allow users to override which frames appear in the traceback, and
     how they are formatted.  (Contributed by Ammar Askar in
     bpo-44569(1).)

   * Add *note traceback.TracebackException.print(): 670, which prints
     the formatted *note TracebackException: 23d. instance to a file.
     (Contributed by Irit Katriel in bpo-33809(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44569

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33809


File: python.info,  Node: typing<4>,  Next: unicodedata<3>,  Prev: traceback<2>,  Up: 改良されたモジュール

1.3.7.31 typing
...............

For major changes, see *note 型ヒントに関連する新しい機能: 589.

   * Add *note typing.assert_never(): 673. and *note typing.Never: 674.
     *note typing.assert_never(): 673. is useful for asking a type
     checker to confirm that a line of code is not reachable.  At
     runtime, it raises an *note AssertionError: 675.  (Contributed by
     Jelle Zijlstra in gh-90633(1).)

   * Add *note typing.reveal_type(): 676.  This is useful for asking a
     type checker what type it has inferred for a given expression.  At
     runtime it prints the type of the received value.  (Contributed by
     Jelle Zijlstra in gh-90572(2).)

   * Add *note typing.assert_type(): 677.  This is useful for asking a
     type checker to confirm that the type it has inferred for a given
     expression matches the given type.  At runtime it simply returns
     the received value.  (Contributed by Jelle Zijlstra in
     gh-90638(3).)

   * *note typing.TypedDict: 148. types can now be generic.
     (Contributed by Samodya Abeysiriwardane in gh-89026(4).)

   * *note NamedTuple: 290. types can now be generic.  (Contributed by
     Serhiy Storchaka in bpo-43923(5).)

   * Allow subclassing of *note typing.Any: 678.  This is useful for
     avoiding type checker errors related to highly dynamic class, such
     as mocks.  (Contributed by Shantanu Jain in gh-91154(6).)

   * The *note typing.final(): 679. decorator now sets the ‘__final__’
     attributed on the decorated object.  (Contributed by Jelle Zijlstra
     in gh-90500(7).)

   * The *note typing.get_overloads(): 67a. function can be used for
     introspecting the overloads of a function.  *note
     typing.clear_overloads(): 67b. can be used to clear all registered
     overloads of a function.  (Contributed by Jelle Zijlstra in
     gh-89263(8).)

   * The *note __init__(): 67c. method of *note Protocol: 245.
     subclasses is now preserved.  (Contributed by Adrian Garcia
     Badarasco in gh-88970(9).)

   * The representation of empty tuple types (‘Tuple[()]’) is
     simplified.  This affects introspection, e.g.
     ‘get_args(Tuple[()])’ now evaluates to ‘()’ instead of ‘((),)’.
     (Contributed by Serhiy Storchaka in gh-91137(10).)

   * Loosen runtime requirements for type annotations by removing the
     callable check in the private ‘typing._type_check’ function.
     (Contributed by Gregory Beauregard in gh-90802(11).)

   * *note typing.get_type_hints(): 67d. now supports evaluating strings
     as forward references in *note PEP 585 generic aliases: 67e.
     (Contributed by Niklas Rosenstein in gh-85542(12).)

   * *note typing.get_type_hints(): 67d. no longer adds *note Optional:
     67f. to parameters with ‘None’ as a default.  (Contributed by
     Nikita Sobolev in gh-90353(13).)

   * *note typing.get_type_hints(): 67d. now supports evaluating bare
     stringified *note ClassVar: 247. annotations.  (Contributed by
     Gregory Beauregard in gh-90711(14).)

   * *note typing.no_type_check(): 680. no longer modifies external
     classes and functions.  It also now correctly marks classmethods as
     not to be type checked.  (Contributed by Nikita Sobolev in
     gh-90729(15).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/90633

   (2) https://github.com/python/cpython/issues/90572

   (3) https://github.com/python/cpython/issues/90638

   (4) https://github.com/python/cpython/issues/89026

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43923

   (6) https://github.com/python/cpython/issues/91154

   (7) https://github.com/python/cpython/issues/90500

   (8) https://github.com/python/cpython/issues/89263

   (9) https://github.com/python/cpython/issues/88970

   (10) https://github.com/python/cpython/issues/91137

   (11) https://github.com/python/cpython/issues/90802

   (12) https://github.com/python/cpython/issues/85542

   (13) https://github.com/python/cpython/issues/90353

   (14) https://github.com/python/cpython/issues/90711

   (15) https://github.com/python/cpython/issues/90729


File: python.info,  Node: unicodedata<3>,  Next: unittest<4>,  Prev: typing<4>,  Up: 改良されたモジュール

1.3.7.32 unicodedata
....................

   * The Unicode database has been updated to version 14.0.0.
     (Contributed by Benjamin Peterson in bpo-45190(1)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45190


File: python.info,  Node: unittest<4>,  Next: venv<2>,  Prev: unicodedata<3>,  Up: 改良されたモジュール

1.3.7.33 unittest
.................

   * Added methods *note enterContext(): 685. and *note
     enterClassContext(): 686. of class *note TestCase: 41a, method
     *note enterAsyncContext(): 687. of class *note
     IsolatedAsyncioTestCase: 2e4. and function *note
     unittest.enterModuleContext(): 688.  (Contributed by Serhiy
     Storchaka in bpo-45046(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45046


File: python.info,  Node: venv<2>,  Next: warnings<2>,  Prev: unittest<4>,  Up: 改良されたモジュール

1.3.7.34 venv
.............

   * When new Python virtual environments are created, the 'venv' *note
     sysconfig installation scheme: 65b. is used to determine the paths
     inside the environment.  When Python runs in a virtual environment,
     the same installation scheme is the default.  That means that
     downstream distributors can change the default sysconfig install
     scheme without changing behavior of virtual environments.  Third
     party code that also creates new virtual environments should do the
     same.  (Contributed by Miro Hrončok in bpo-45413(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45413


File: python.info,  Node: warnings<2>,  Next: zipfile,  Prev: venv<2>,  Up: 改良されたモジュール

1.3.7.35 warnings
.................

   * *note warnings.catch_warnings(): 550. now accepts arguments for
     *note warnings.simplefilter(): 68d, providing a more concise way to
     locally ignore warnings or convert them to errors.  (Contributed by
     Zac Hatfield-Dodds in bpo-47074(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=47074


File: python.info,  Node: zipfile,  Prev: warnings<2>,  Up: 改良されたモジュール

1.3.7.36 zipfile
................

   * Added support for specifying member name encoding for reading
     metadata in a *note ZipFile: 690.'s directory and file headers.
     (Contributed by Stephen J. Turnbull and Serhiy Storchaka in
     bpo-28080(1).)

   * Added *note ZipFile.mkdir(): 691. for creating new directories
     inside ZIP archives.  (Contributed by Sam Ezeh in gh-49083(2).)

   * Added *note stem: 692, *note suffix: 693. and *note suffixes: 694.
     to *note zipfile.Path: 695.  (Contributed by Miguel Brito in
     gh-88261(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28080

   (2) https://github.com/python/cpython/issues/49083

   (3) https://github.com/python/cpython/issues/88261


File: python.info,  Node: 最適化,  Next: Faster CPython,  Prev: 改良されたモジュール,  Up: What's New In Python 3 11

1.3.8 最適化
------------

This section covers specific optimizations independent of the *note
Faster CPython: 56a. project, which is covered in its own section.

   * The compiler now optimizes simple *note printf-style % formatting:
     698. on string literals containing only the format codes ‘%s’, ‘%r’
     and ‘%a’ and makes it as fast as a corresponding *note f-string:
     402. expression.  (Contributed by Serhiy Storchaka in
     bpo-28307(1).)

   * Integer division (‘//’) is better tuned for optimization by
     compilers.  It is now around 20% faster on x86-64 when dividing an
     *note int: 238. by a value smaller than ‘2**30’.  (Contributed by
     Gregory P. Smith and Tim Peters in gh-90564(2).)

   * *note sum(): 437. is now nearly 30% faster for integers smaller
     than ‘2**30’.  (Contributed by Stefan Behnel in gh-68264(3).)

   * Resizing lists is streamlined for the common case, speeding up
     ‘list.append()’ by ≈15% and simple *note list comprehension: 699.s
     by up to 20-30% (Contributed by Dennis Sweeney in gh-91165(4).)

   * Dictionaries don't store hash values when all keys are Unicode
     objects, decreasing *note dict: 237. size.  For example,
     ‘sys.getsizeof(dict.fromkeys("abcdefg"))’ is reduced from 352 bytes
     to 272 bytes (23% smaller) on 64-bit platforms.  (Contributed by
     Inada Naoki in bpo-46845(5).)

   * Using *note asyncio.DatagramProtocol: 69a. is now orders of
     magnitude faster when transferring large files over UDP, with
     speeds over 100 times higher for a ≈60 MiB file.  (Contributed by
     msoxzw in gh-91487(6).)

   * *note math: 81. functions *note comb(): 69b. and *note perm(): 69c.
     are now ≈10 times faster for large arguments (with a larger speedup
     for larger 'k').  (Contributed by Serhiy Storchaka in
     bpo-37295(7).)

   * The *note statistics: bd. functions *note mean(): 69d, *note
     variance(): 69e. and *note stdev(): 69f. now consume iterators in
     one pass rather than converting them to a *note list: 5dc. first.
     This is twice as fast and can save substantial memory.
     (Contributed by Raymond Hettinger in gh-90415(8).)

   * *note unicodedata.normalize(): 6a0. now normalizes pure-ASCII
     strings in constant time.  (Contributed by Donghee Na in
     bpo-44987(9).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28307

   (2) https://github.com/python/cpython/issues/90564

   (3) https://github.com/python/cpython/issues/68264

   (4) https://github.com/python/cpython/issues/91165

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46845

   (6) https://github.com/python/cpython/issues/91487

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37295

   (8) https://github.com/python/cpython/issues/90415

   (9) https://bugs.python.org/issue?@action=redirect&bpo=44987


File: python.info,  Node: Faster CPython,  Next: CPython バイトコードの変更,  Prev: 最適化,  Up: What's New In Python 3 11

1.3.9 Faster CPython
--------------------

CPython 3.11 is an average of 25% faster(1) than CPython 3.10 as
measured with the pyperformance(2) benchmark suite, when compiled with
GCC on Ubuntu Linux.  Depending on your workload, the overall speedup
could be 10-60%.

This project focuses on two major areas in Python: *note Faster Startup:
6a2. and *note Faster Runtime: 6a3.  Optimizations not covered by this
project are listed separately under *note 最適化: 697.

* Menu:

* Faster Startup::
* Faster Runtime::
* Misc::
* FAQ::
* About::

   ---------- Footnotes ----------

   (1) https://github.com/faster-cpython/ideas#published-results

   (2) https://github.com/python/pyperformance


File: python.info,  Node: Faster Startup,  Next: Faster Runtime,  Up: Faster CPython

1.3.9.1 Faster Startup
......................

* Menu:

* Frozen imports / Static code objects::


File: python.info,  Node: Frozen imports / Static code objects,  Up: Faster Startup

1.3.9.2 Frozen imports / Static code objects
............................................

Python caches *note bytecode: 16c. in the *note __pycache__: 6a7.
directory to speed up module loading.

Previously in 3.10, Python module execution looked like this:

     Read __pycache__ -> Unmarshal -> Heap allocated code object -> Evaluate

In Python 3.11, the core modules essential for Python startup are
"frozen".  This means that their *note コードオブジェクト: 57f. (and
bytecode) are statically allocated by the interpreter.  This reduces the
steps in module execution process to:

     Statically allocated code object -> Evaluate

Interpreter startup is now 10-15% faster in Python 3.11.  This has a big
impact for short-running programs using Python.

(Contributed by Eric Snow, Guido van Rossum and Kumar Aditya in many
issues.)


File: python.info,  Node: Faster Runtime,  Next: Misc,  Prev: Faster Startup,  Up: Faster CPython

1.3.9.3 Faster Runtime
......................

* Menu:

* Cheaper, lazy Python frames: Cheaper lazy Python frames.
* Inlined Python function calls::
* PEP 659; Specializing Adaptive Interpreter: PEP 659 Specializing Adaptive Interpreter.


File: python.info,  Node: Cheaper lazy Python frames,  Next: Inlined Python function calls,  Up: Faster Runtime

1.3.9.4 Cheaper, lazy Python frames
...................................

Python frames, holding execution information, are created whenever
Python calls a Python function.  The following are new frame
optimizations:

   - Streamlined the frame creation process.

   - Avoided memory allocation by generously re-using frame space on the
     C stack.

   - Streamlined the internal frame struct to contain only essential
     information.  Frames previously held extra debugging and memory
     management information.

Old-style *note frame objects: 6ab. are now created only when requested
by debuggers or by Python introspection functions such as *note
sys._getframe(): 6ac. and *note inspect.currentframe(): 6ad.  For most
user code, no frame objects are created at all.  As a result, nearly all
Python functions calls have sped up significantly.  We measured a 3-7%
speedup in pyperformance.

(Contributed by Mark Shannon in bpo-44590(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44590


File: python.info,  Node: Inlined Python function calls,  Next: PEP 659 Specializing Adaptive Interpreter,  Prev: Cheaper lazy Python frames,  Up: Faster Runtime

1.3.9.5 Inlined Python function calls
.....................................

During a Python function call, Python will call an evaluating C function
to interpret that function's code.  This effectively limits pure Python
recursion to what's safe for the C stack.

In 3.11, when CPython detects Python code calling another Python
function, it sets up a new frame, and "jumps" to the new code inside the
new frame.  This avoids calling the C interpreting function altogether.

Most Python function calls now consume no C stack space, speeding them
up.  In simple recursive functions like fibonacci or factorial, we
observed a 1.7x speedup.  This also means recursive functions can
recurse significantly deeper (if the user increases the recursion limit
with *note sys.setrecursionlimit(): 48f.).  We measured a 1-3%
improvement in pyperformance.

(Contributed by Pablo Galindo and Mark Shannon in bpo-45256(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45256


File: python.info,  Node: PEP 659 Specializing Adaptive Interpreter,  Prev: Inlined Python function calls,  Up: Faster Runtime

1.3.9.6 PEP 659: Specializing Adaptive Interpreter
..................................................

PEP 659(1) is one of the key parts of the Faster CPython project.  The
general idea is that while Python is a dynamic language, most code has
regions where objects and types rarely change.  This concept is known as
'type stability'.

At runtime, Python will try to look for common patterns and type
stability in the executing code.  Python will then replace the current
operation with a more specialized one.  This specialized operation uses
fast paths available only to those use cases/types, which generally
outperform their generic counterparts.  This also brings in another
concept called 'inline caching', where Python caches the results of
expensive operations directly in the *note bytecode: 16c.

The specializer will also combine certain common instruction pairs into
one superinstruction, reducing the overhead during execution.

Python will only specialize when it sees code that is "hot" (executed
multiple times).  This prevents Python from wasting time on run-once
code.  Python can also de-specialize when code is too dynamic or when
the use changes.  Specialization is attempted periodically, and
specialization attempts are not too expensive, allowing specialization
to adapt to new circumstances.

(PEP written by Mark Shannon, with ideas inspired by Stefan Brunthaler.
See PEP 659(2) for more information.  Implementation by Mark Shannon and
Brandt Bucher, with additional help from Irit Katriel and Dennis
Sweeney.)

演算                形式                     Specialization                                              Operation speedup (up   Contributor(s)
                                                                                                         to)                     
                                                                                                         
---------------------------------------------------------------------------------------------------------------------------------------------------------
                                                                                                                                 
Binary operations   ‘x + x’                  Binary add, multiply and subtract for common types such     10%                     Mark Shannon, Donghee
                                             as *note int: 238, *note float: 2ce. and *note str: 418.                            Na, Brandt Bucher,
                    ‘x - x’                  take custom fast paths for their underlying types.                                  Dennis Sweeney
                                                                                                                                 
                    ‘x * x’
                    
                                                                                                                                 
Subscript           ‘a[i]’                   Subscripting container types such as *note list: 5dc,       10-25%                  Irit Katriel, Mark
                                             *note tuple: 349. and *note dict: 237. directly index the                           Shannon
                                             underlying data structures.                                                         
                                             
                                             Subscripting custom *note __getitem__(): 264. is also
                                             inlined similar to
                                             *note Inlined Python function calls: 6ae.
                                             
                                                                                                                                 
Store subscript     ‘a[i] = z’               Similar to subscripting specialization above.               10-25%                  Dennis Sweeney
                                                                                                                                 
                                                                                                                                 
呼び出し (call)     ‘f(arg)’                 Calls to common builtin (C) functions and types such as     20%                     Mark Shannon, Ken Jin
                                             *note len(): 5fa. and *note str: 418. directly call their                           
                    ‘C(arg)’                 underlying C version.  This avoids going through the
                                             internal calling convention.
                                             
                                                                                                                                 
Load global         ‘print’                  The object's index in the globals/builtins namespace is     (3)                     Mark Shannon
variable                                     cached.  Loading globals and builtins require zero                                  
                    ‘len’                    namespace lookups.
                                             
                                                                                                                                 
Load attribute      ‘o.attr’                 Similar to loading global variables.  The attribute's       (4)                     Mark Shannon
                                             index inside the class/object's namespace is cached.  In                            
                                             most cases, attribute loading will require zero namespace
                                             lookups.
                                             
                                                                                                                                 
Load methods for    ‘o.meth()’               The actual address of the method is cached.  Method         10-20%                  Ken Jin, Mark Shannon
call                                         loading now has no namespace lookups - even for classes                             
                                             with long inheritance chains.
                                             
                                                                                                                                 
Store attribute     ‘o.attr = z’             Similar to load attribute optimization.                     2% in pyperformance     Mark Shannon
                                                                                                                                 
                                                                                                                                 
Unpack Sequence     ‘*seq’                   Specialized for common containers such as                   8%                      Brandt Bucher
                                             *note list: 5dc. and *note tuple: 349.  Avoids internal                             
                                             calling convention.
                                             

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0659/

   (2) https://peps.python.org/pep-0659/

   (3) A similar optimization already existed since Python 3.8.  3.11
specializes for more forms and reduces some overhead.

   (4) A similar optimization already existed since Python 3.10.  3.11
specializes for more forms.  Furthermore, all attribute loads should be
sped up by bpo-45947
(https://bugs.python.org/issue?@action=redirect&bpo=45947).


File: python.info,  Node: Misc,  Next: FAQ,  Prev: Faster Runtime,  Up: Faster CPython

1.3.9.7 Misc
............

   * Objects now require less memory due to lazily created object
     namespaces.  Their namespace dictionaries now also share keys more
     freely.  (Contributed Mark Shannon in bpo-45340(1) and
     bpo-40116(2).)

   * "Zero-cost" exceptions are implemented, eliminating the cost of
     *note try: 6b4. statements when no exception is raised.
     (Contributed by Mark Shannon in bpo-40222(3).)

   * A more concise representation of exceptions in the interpreter
     reduced the time required for catching an exception by about 10%.
     (Contributed by Irit Katriel in bpo-45711(4).)

   * *note re: a7.'s regular expression matching engine has been
     partially refactored, and now uses computed gotos (or "threaded
     code") on supported platforms.  As a result, Python 3.11 executes
     the pyperformance regular expression benchmarks(5) up to 10% faster
     than Python 3.10.  (Contributed by Brandt Bucher in gh-91404(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45340

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40116

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40222

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (5) https://pyperformance.readthedocs.io/benchmarks.html#regex-dna

   (6) https://github.com/python/cpython/issues/91404


File: python.info,  Node: FAQ,  Next: About,  Prev: Misc,  Up: Faster CPython

1.3.9.8 FAQ
...........

* Menu:

* How should I write my code to utilize these speedups?::
* Will CPython 3.11 use more memory?: Will CPython 3 11 use more memory?.
* I don't see any speedups in my workload. Why?: I don't see any speedups in my workload Why?.
* Is there a JIT compiler?::


File: python.info,  Node: How should I write my code to utilize these speedups?,  Next: Will CPython 3 11 use more memory?,  Up: FAQ

1.3.9.9 How should I write my code to utilize these speedups?
.............................................................

Write Pythonic code that follows common best practices; you don't have
to change your code.  The Faster CPython project optimizes for common
code patterns we observe.


File: python.info,  Node: Will CPython 3 11 use more memory?,  Next: I don't see any speedups in my workload Why?,  Prev: How should I write my code to utilize these speedups?,  Up: FAQ

1.3.9.10 Will CPython 3.11 use more memory?
...........................................

Maybe not; we don't expect memory use to exceed 20% higher than 3.10.
This is offset by memory optimizations for frame objects and object
dictionaries as mentioned above.


File: python.info,  Node: I don't see any speedups in my workload Why?,  Next: Is there a JIT compiler?,  Prev: Will CPython 3 11 use more memory?,  Up: FAQ

1.3.9.11 I don't see any speedups in my workload. Why?
......................................................

Certain code won't have noticeable benefits.  If your code spends most
of its time on I/O operations, or already does most of its computation
in a C extension library like NumPy, there won't be significant
speedups.  This project currently benefits pure-Python workloads the
most.

Furthermore, the pyperformance figures are a geometric mean.  Even
within the pyperformance benchmarks, certain benchmarks have slowed down
slightly, while others have sped up by nearly 2x!


File: python.info,  Node: Is there a JIT compiler?,  Prev: I don't see any speedups in my workload Why?,  Up: FAQ

1.3.9.12 Is there a JIT compiler?
.................................

No.  We're still exploring other optimizations.


File: python.info,  Node: About,  Prev: FAQ,  Up: Faster CPython

1.3.9.13 About
..............

Faster CPython explores optimizations for *note CPython: 6c1.  The main
team is funded by Microsoft to work on this full-time.  Pablo Galindo
Salgado is also funded by Bloomberg LP to work on the project part-time.
Finally, many contributors are volunteers from the community.


File: python.info,  Node: CPython バイトコードの変更,  Next: 非推奨,  Prev: Faster CPython,  Up: What's New In Python 3 11

1.3.10 CPython バイトコードの変更
---------------------------------

The bytecode now contains inline cache entries, which take the form of
the newly-added *note CACHE: 6c4. instructions.  Many opcodes expect to
be followed by an exact number of caches, and instruct the interpreter
to skip over them at runtime.  Populated caches can look like arbitrary
instructions, so great care should be taken when reading or modifying
raw, adaptive bytecode containing quickened data.

* Menu:

* New opcodes::
* Replaced opcodes::
* Changed/removed opcodes::


File: python.info,  Node: New opcodes,  Next: Replaced opcodes,  Up: CPython バイトコードの変更

1.3.10.1 New opcodes
....................

   * ‘ASYNC_GEN_WRAP’, *note RETURN_GENERATOR: 6c7. and *note SEND: 6c8,
     used in generators and co-routines.

   * *note COPY_FREE_VARS: 6c9, which avoids needing special caller-side
     code for closures.

   * *note JUMP_BACKWARD_NO_INTERRUPT: 6ca, for use in certain loops
     where handling interrupts is undesirable.

   * *note MAKE_CELL: 6cb, to create *note セルオブジェクト (cell
     object): 6cc.

   * *note CHECK_EG_MATCH: 6cd. and ‘PREP_RERAISE_STAR’, to handle the
     *note new exception groups and except*: 56b. added in PEP 654(1).

   * *note PUSH_EXC_INFO: 6ce, for use in exception handlers.

   * *note RESUME: 2ed, a no-op, for internal tracing, debugging and
     optimization checks.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0654/


File: python.info,  Node: Replaced opcodes,  Next: Changed/removed opcodes,  Prev: New opcodes,  Up: CPython バイトコードの変更

1.3.10.2 Replaced opcodes
.........................

Replaced Opcode(s)                       New Opcode(s)                            注釈
                                                                                  
--------------------------------------------------------------------------------------------------------------------------------
                                                                                  
     ‘BINARY_*’                          *note BINARY_OP: 6d1.                    Replaced all numeric binary/in-place
     ‘INPLACE_*’                                                                  opcodes with a single opcode
                                                                                  
                                                                                  
     ‘CALL_FUNCTION’                          *note CALL: 6d2.                    Decouples argument shifting for methods
     ‘CALL_FUNCTION_KW’                       ‘KW_NAMES’                          from handling of keyword arguments; allows
     ‘CALL_METHOD’                            ‘PRECALL’                           better specialization of calls
                                              *note PUSH_NULL: 6d3.               
                                         
                                                                                  
     ‘DUP_TOP’                                *note COPY: 6d4.                    Stack manipulation instructions
     ‘DUP_TOP_TWO’                            *note SWAP: 6d5.                    
     ‘ROT_TWO’                           
     ‘ROT_THREE’
     ‘ROT_FOUR’
     ‘ROT_N’

     ‘JUMP_IF_NOT_EXC_MATCH’                  *note CHECK_EXC_MATCH: 6d6.         Now performs check but doesn't jump
                                                                                  
                                                                                  
     ‘JUMP_ABSOLUTE’                          *note JUMP_BACKWARD: 6d7.           See (1); ‘TRUE’, ‘FALSE’, ‘NONE’ and
     ‘POP_JUMP_IF_FALSE’                      ‘POP_JUMP_BACKWARD_IF_*’            ‘NOT_NONE’ variants for each direction
     ‘POP_JUMP_IF_TRUE’                       ‘POP_JUMP_FORWARD_IF_*’             
                                         
                                                                                  
     ‘SETUP_WITH’                        *note BEFORE_WITH: 6d8.                  *note with: 59c. block setup
     ‘SETUP_ASYNC_WITH’                                                           

   ---------- Footnotes ----------

   (1) All jump opcodes are now relative, including the existing
‘JUMP_IF_TRUE_OR_POP’ and ‘JUMP_IF_FALSE_OR_POP’.  The argument is now
an offset from the current instruction rather than an absolute location.


File: python.info,  Node: Changed/removed opcodes,  Prev: Replaced opcodes,  Up: CPython バイトコードの変更

1.3.10.3 Changed/removed opcodes
................................

   * Changed *note MATCH_CLASS: 6dd. and *note MATCH_KEYS: 6de. to no
     longer push an additional boolean value to indicate
     success/failure.  Instead, ‘None’ is pushed on failure in place of
     the tuple of extracted values.

   * Changed opcodes that work with exceptions to reflect them now being
     represented as one item on the stack instead of three (see
     gh-89874(1)).

   * Removed ‘COPY_DICT_WITHOUT_KEYS’, ‘GEN_START’, ‘POP_BLOCK’,
     ‘SETUP_FINALLY’ and ‘YIELD_FROM’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89874


File: python.info,  Node: 非推奨,  Next: Pending Removal in Python 3 12,  Prev: CPython バイトコードの変更,  Up: What's New In Python 3 11

1.3.11 非推奨
-------------

This section lists Python APIs that have been deprecated in Python 3.11.

Deprecated C APIs are *note listed separately: 6e2.
* Menu:

* Language/Builtins::
* モジュール::
* Standard Library::


File: python.info,  Node: Language/Builtins,  Next: モジュール,  Up: 非推奨

1.3.11.1 Language/Builtins
..........................

   * Chaining *note classmethod: 14c. descriptors (introduced in
     bpo-19072(1)) is now deprecated.  It can no longer be used to wrap
     other descriptors such as *note property: 179.  The core design of
     this feature was flawed and caused a number of downstream problems.
     To "pass-through" a *note classmethod: 14c, consider using the
     ‘__wrapped__’ attribute that was added in Python 3.10.
     (Contributed by Raymond Hettinger in gh-89519(2).)

   * Octal escapes in string and bytes literals with values larger than
     ‘0o377’ (255 in decimal) now produce a *note DeprecationWarning:
     18a.  In a future Python version, they will raise a *note
     SyntaxWarning: 432. and eventually a *note SyntaxError: 172.
     (Contributed by Serhiy Storchaka in gh-81548(3).)

   * The delegation of *note int(): 238. to *note __trunc__(): 6e6. is
     now deprecated.  Calling ‘int(a)’ when ‘type(a)’ implements
     ‘__trunc__()’ but not *note __int__(): 6e7. or *note __index__():
     6e8. now raises a *note DeprecationWarning: 18a.  (Contributed by
     Zackery Spytz in bpo-44977(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19072

   (2) https://github.com/python/cpython/issues/89519

   (3) https://github.com/python/cpython/issues/81548

   (4) https://bugs.python.org/issue?@action=redirect&bpo=44977


File: python.info,  Node: モジュール,  Next: Standard Library,  Prev: Language/Builtins,  Up: 非推奨

1.3.11.2 モジュール
...................

   * PEP 594(1) led to the deprecations of the following modules slated
     for removal in Python 3.13:

     ‘aifc’                    ‘chunk’                   ‘msilib’                  ‘pipes’                   ‘telnetlib’
                                                                                                             
                                                                                                             
     ‘audioop’                 ‘crypt’                   ‘nis’                     ‘sndhdr’                  ‘uu’
                                                                                                             
                                                                                                             
     ‘cgi’                     ‘imghdr’                  ‘nntplib’                 ‘spwd’                    ‘xdrlib’
                                                                                                             
                                                                                                             
     ‘cgitb’                   ‘mailcap’                 ‘ossaudiodev’             ‘sunau’
                                                                                   

     (Contributed by Brett Cannon in bpo-47061(2) and Victor Stinner in
     gh-68966(3).)

   * The ‘asynchat’, ‘asyncore’ and ‘smtpd’ modules have been deprecated
     since at least Python 3.6.  Their documentation and deprecation
     warnings have now been updated to note they will be removed in
     Python 3.12.  (Contributed by Hugo van Kemenade in bpo-47022(4).)

   * The ‘lib2to3’ package and ‘2to3’ tool are now deprecated and may
     not be able to parse Python 3.10 or newer.  See PEP 617(5),
     introducing the new PEG parser, for details.  (Contributed by
     Victor Stinner in bpo-40360(6).)

   * Undocumented modules ‘sre_compile’, ‘sre_constants’ and ‘sre_parse’
     are now deprecated.  (Contributed by Serhiy Storchaka in
     bpo-47152(7).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0594/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=47061

   (3) https://github.com/python/cpython/issues/68966

   (4) https://bugs.python.org/issue?@action=redirect&bpo=47022

   (5) https://peps.python.org/pep-0617/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40360

   (7) https://bugs.python.org/issue?@action=redirect&bpo=47152


File: python.info,  Node: Standard Library,  Prev: モジュール,  Up: 非推奨

1.3.11.3 Standard Library
.........................

   * The following have been deprecated in *note configparser: 1b. since
     Python 3.2.  Their deprecation warnings have now been updated to
     note they will be removed in Python 3.12:

        * the ‘configparser.SafeConfigParser’ class

        * the ‘configparser.ParsingError.filename’ property

        * the ‘configparser.RawConfigParser.readfp()’ method

     (Contributed by Hugo van Kemenade in bpo-45173(1).)

   * ‘configparser.LegacyInterpolation’ has been deprecated in the
     docstring since Python 3.2, and is not listed in the *note
     configparser: 1b. documentation.  It now emits a *note
     DeprecationWarning: 18a. and will be removed in Python 3.13.  Use
     *note configparser.BasicInterpolation: 6ed. or *note
     configparser.ExtendedInterpolation: 6ee. instead.  (Contributed by
     Hugo van Kemenade in bpo-46607(2).)

   * The older set of *note importlib.resources: 6f. functions were
     deprecated in favor of the replacements added in Python 3.9 and
     will be removed in a future Python version, due to not supporting
     resources located within package subdirectories:

        * ‘importlib.resources.contents()’

        * ‘importlib.resources.is_resource()’

        * ‘importlib.resources.open_binary()’

        * ‘importlib.resources.open_text()’

        * ‘importlib.resources.read_binary()’

        * ‘importlib.resources.read_text()’

        * ‘importlib.resources.path()’

   * The *note locale.getdefaultlocale(): 2bb. function is deprecated
     and will be removed in Python 3.15.  Use *note locale.setlocale():
     2bd, *note locale.getpreferredencoding(False): 504. and *note
     locale.getlocale(): 2bc. functions instead.  (Contributed by Victor
     Stinner in gh-90817(3).)

   * The ‘locale.resetlocale()’ function is deprecated and will be
     removed in Python 3.13.  Use ‘locale.setlocale(locale.LC_ALL, "")’
     instead.  (Contributed by Victor Stinner in gh-90817(4).)

   * Stricter rules will now be applied for numerical group references
     and group names in *note regular expressions: 6ef.  Only sequences
     of ASCII digits will now be accepted as a numerical reference, and
     the group name in *note bytes: 1a4. patterns and replacement
     strings can only contain ASCII letters, digits and underscores.
     For now, a deprecation warning is raised for syntax violating these
     rules.  (Contributed by Serhiy Storchaka in gh-91760(5).)

   * In the *note re: a7. module, the ‘re.template()’ function and the
     corresponding ‘re.TEMPLATE’ and ‘re.T’ flags are deprecated, as
     they were undocumented and lacked an obvious purpose.  They will be
     removed in Python 3.13.  (Contributed by Serhiy Storchaka and Miro
     Hrončok in gh-92728(6).)

   * ‘turtle.settiltangle()’ has been deprecated since Python 3.1; it
     now emits a deprecation warning and will be removed in Python 3.13.
     Use *note turtle.tiltangle(): 6f0. instead (it was earlier
     incorrectly marked as deprecated, and its docstring is now
     corrected).  (Contributed by Hugo van Kemenade in bpo-45837(7).)

   * *note typing.Text: 2e3, which exists solely to provide
     compatibility support between Python 2 and Python 3 code, is now
     deprecated.  Its removal is currently unplanned, but users are
     encouraged to use *note str: 418. instead wherever possible.
     (Contributed by Alex Waygood in gh-92332(8).)

   * The keyword argument syntax for constructing *note
     typing.TypedDict: 148. types is now deprecated.  Support will be
     removed in Python 3.13.  (Contributed by Jingchen Ye in
     gh-90224(9).)

   * ‘webbrowser.MacOSX’ is deprecated and will be removed in Python
     3.13.  It is untested, undocumented, and not used by *note
     webbrowser: fd. itself.  (Contributed by Donghee Na in
     bpo-42255(10).)

   * The behavior of returning a value from a *note TestCase: 41a. and
     *note IsolatedAsyncioTestCase: 2e4. test methods (other than the
     default ‘None’ value) is now deprecated.

   * Deprecated the following not-formally-documented *note unittest:
     ef. functions, scheduled for removal in Python 3.13:

        * ‘unittest.findTestCases()’

        * ‘unittest.makeSuite()’

        * ‘unittest.getTestCaseNames()’

     Use *note TestLoader: 26e. methods instead:

        * *note unittest.TestLoader.loadTestsFromModule(): 26f.

        * *note unittest.TestLoader.loadTestsFromTestCase(): 270.

        * *note unittest.TestLoader.getTestCaseNames(): 271.

     (Contributed by Erlend E. Aasland in bpo-5846(11).)

   * ‘unittest.TestProgram.usageExit()’ is marked deprecated, to be
     removed in 3.13.  (Contributed by Carlos Damázio in gh-67048(12).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45173

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46607

   (3) https://github.com/python/cpython/issues/90817

   (4) https://github.com/python/cpython/issues/90817

   (5) https://github.com/python/cpython/issues/91760

   (6) https://github.com/python/cpython/issues/92728

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45837

   (8) https://github.com/python/cpython/issues/92332

   (9) https://github.com/python/cpython/issues/90224

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42255

   (11) https://bugs.python.org/issue?@action=redirect&bpo=5846

   (12) https://github.com/python/cpython/issues/67048


File: python.info,  Node: Pending Removal in Python 3 12,  Next: 削除,  Prev: 非推奨,  Up: What's New In Python 3 11

1.3.12 Pending Removal in Python 3.12
-------------------------------------

The following Python APIs have been deprecated in earlier Python
releases, and will be removed in Python 3.12.

C APIs pending removal are *note listed separately: 6f4.

   * The ‘asynchat’ module

   * The ‘asyncore’ module

   * The *note entire distutils package: 6f5.

   * The ‘imp’ module

   * The *note typing.io: 6f6. namespace

   * The *note typing.re: 6f7. namespace

   * ‘cgi.log()’

   * ‘importlib.find_loader()’

   * ‘importlib.abc.Loader.module_repr()’

   * ‘importlib.abc.MetaPathFinder.find_module()’

   * ‘importlib.abc.PathEntryFinder.find_loader()’

   * ‘importlib.abc.PathEntryFinder.find_module()’

   * ‘importlib.machinery.BuiltinImporter.find_module()’

   * ‘importlib.machinery.BuiltinLoader.module_repr()’

   * ‘importlib.machinery.FileFinder.find_loader()’

   * ‘importlib.machinery.FileFinder.find_module()’

   * ‘importlib.machinery.FrozenImporter.find_module()’

   * ‘importlib.machinery.FrozenLoader.module_repr()’

   * ‘importlib.machinery.PathFinder.find_module()’

   * ‘importlib.machinery.WindowsRegistryFinder.find_module()’

   * ‘importlib.util.module_for_loader()’

   * ‘importlib.util.set_loader_wrapper()’

   * ‘importlib.util.set_package_wrapper()’

   * ‘pkgutil.ImpImporter’

   * ‘pkgutil.ImpLoader’

   * ‘pathlib.Path.link_to()’

   * ‘sqlite3.enable_shared_cache()’

   * ‘sqlite3.OptimizedUnicode()’

   * ‘PYTHONTHREADDEBUG’ environment variable

   * The following deprecated aliases in *note unittest: ef.:

          非推奨のエイリアス               メソッド名                          非推奨となるバー
                                                                               ジョン
                                                                               
          -----------------------------------------------------------------------------------------
                                                                               
          ‘failUnless’                     *note assertTrue(): 4f0.            3.1
                                                                               
                                                                               
          ‘failIf’                         *note assertFalse(): 4f1.           3.1
                                                                               
                                                                               
          ‘failUnlessEqual’                *note assertEqual(): 4f2.           3.1
                                                                               
                                                                               
          ‘failIfEqual’                    *note assertNotEqual(): 4f3.        3.1
                                                                               
                                                                               
          ‘failUnlessAlmostEqual’          *note assertAlmostEqual(): 4f4.     3.1
                                                                               
                                                                               
          ‘failIfAlmostEqual’              *note assertNotAlmostEqual(): 4f5.  3.1
                                                                               
                                                                               
          ‘failUnlessRaises’               *note assertRaises(): 4f6.          3.1
                                                                               
                                                                               
          ‘assert_’                        *note assertTrue(): 4f0.            3.2
                                                                               
                                                                               
          ‘assertEquals’                   *note assertEqual(): 4f2.           3.2
                                                                               
                                                                               
          ‘assertNotEquals’                *note assertNotEqual(): 4f3.        3.2
                                                                               
                                                                               
          ‘assertAlmostEquals’             *note assertAlmostEqual(): 4f4.     3.2
                                                                               
                                                                               
          ‘assertNotAlmostEquals’          *note assertNotAlmostEqual(): 4f5.  3.2
                                                                               
                                                                               
          ‘assertRegexpMatches’            *note assertRegex(): 4f7.           3.2
                                                                               
                                                                               
          ‘assertRaisesRegexp’             *note assertRaisesRegex(): 4f8.     3.2
                                                                               
                                                                               
          ‘assertNotRegexpMatches’         *note assertNotRegex(): 4f9.        3.5
                                                                               


File: python.info,  Node: 削除,  Next: Porting to Python 3 11,  Prev: Pending Removal in Python 3 12,  Up: What's New In Python 3 11

1.3.13 削除
-----------

This section lists Python APIs that have been removed in Python 3.11.

Removed C APIs are *note listed separately: 6fb.

   * Removed the ‘@asyncio.coroutine()’ *note decorator: 6fc. enabling
     legacy generator-based coroutines to be compatible with *note
     async: 6fd. / *note await: 19e. code.  The function has been
     deprecated since Python 3.8 and the removal was initially scheduled
     for Python 3.10.  Use *note async def: 59b. instead.  (Contributed
     by Illia Volochii in bpo-43216(1).)

   * Removed ‘asyncio.coroutines.CoroWrapper’ used for wrapping legacy
     generator-based coroutine objects in the debug mode.  (Contributed
     by Illia Volochii in bpo-43216(2).)

   * Due to significant security concerns, the 'reuse_address' parameter
     of *note asyncio.loop.create_datagram_endpoint(): 6fe, disabled in
     Python 3.9, is now entirely removed.  This is because of the
     behavior of the socket option ‘SO_REUSEADDR’ in UDP. (Contributed
     by Hugo van Kemenade in bpo-45129(3).)

   * Removed the ‘binhex’ module, deprecated in Python 3.9.  Also
     removed the related, similarly-deprecated *note binascii: c.
     functions:

        * ‘binascii.a2b_hqx()’

        * ‘binascii.b2a_hqx()’

        * ‘binascii.rlecode_hqx()’

        * ‘binascii.rldecode_hqx()’

     The *note binascii.crc_hqx(): 6ff. function remains available.

     (Contributed by Victor Stinner in bpo-45085(4).)

   * Removed the ‘distutils’ ‘bdist_msi’ command deprecated in Python
     3.9.  Use ‘bdist_wheel’ (wheel packages) instead.  (Contributed by
     Hugo van Kemenade in bpo-45124(5).)

   * Removed the *note __getitem__(): 264. methods of *note
     xml.dom.pulldom.DOMEventStream: 700, *note
     wsgiref.util.FileWrapper: 701. and *note fileinput.FileInput: 702,
     deprecated since Python 3.9.  (Contributed by Hugo van Kemenade in
     bpo-45132(6).)

   * Removed the deprecated *note gettext: 59. functions ‘lgettext()’,
     ‘ldgettext()’, ‘lngettext()’ and ‘ldngettext()’.  Also removed the
     ‘bind_textdomain_codeset()’ function, the
     ‘NullTranslations.output_charset()’ and
     ‘NullTranslations.set_output_charset()’ methods, and the 'codeset'
     parameter of ‘translation()’ and ‘install()’, since they are only
     used for the ‘l*gettext()’ functions.  (Contributed by Donghee Na
     and Serhiy Storchaka in bpo-44235(7).)

   * Removed from the *note inspect: 72. module:

        * The ‘getargspec()’ function, deprecated since Python 3.0; use
          *note inspect.signature(): 703. or *note
          inspect.getfullargspec(): 704. instead.

        * The ‘formatargspec()’ function, deprecated since Python 3.5;
          use the *note inspect.signature(): 703. function or the *note
          inspect.Signature: 1b1. object directly.

        * The undocumented ‘Signature.from_builtin()’ and
          ‘Signature.from_function()’ methods, deprecated since Python
          3.5; use the *note Signature.from_callable(): 705. method
          instead.

     (Contributed by Hugo van Kemenade in bpo-45320(8).)

   * Removed the *note __class_getitem__(): 706. method from *note
     pathlib.PurePath: 473, because it was not used and added by mistake
     in previous versions.  (Contributed by Nikita Sobolev in
     bpo-46483(9).)

   * Removed the ‘MailmanProxy’ class in the ‘smtpd’ module, as it is
     unusable without the external ‘mailman’ package.  (Contributed by
     Donghee Na in bpo-35800(10).)

   * Removed the deprecated ‘split()’ method of ‘_tkinter.TkappType’.
     (Contributed by Erlend E. Aasland in bpo-38371(11).)

   * Removed namespace package support from *note unittest: ef.
     discovery.  It was introduced in Python 3.4 but has been broken
     since Python 3.7.  (Contributed by Inada Naoki in bpo-23882(12).)

   * Removed the undocumented private ‘float.__set_format__()’ method,
     previously known as ‘float.__setformat__()’ in Python 3.7.  Its
     docstring said: "You probably don't want to use this function.  It
     exists mainly to be used in Python's test suite."  (Contributed by
     Victor Stinner in bpo-46852(13).)

   * The ‘--experimental-isolated-subinterpreters’ configure flag (and
     corresponding ‘EXPERIMENTAL_ISOLATED_SUBINTERPRETERS’ macro) have
     been removed.

   * Pynche(14) -- The Pythonically Natural Color and Hue Editor -- has
     been moved out of ‘Tools/scripts’ and is being developed
     independently(15) from the Python source tree.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43216

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43216

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45129

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45085

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45124

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45132

   (7) https://bugs.python.org/issue?@action=redirect&bpo=44235

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45320

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46483

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35800

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38371

   (12) https://bugs.python.org/issue?@action=redirect&bpo=23882

   (13) https://bugs.python.org/issue?@action=redirect&bpo=46852

   (14) https://pypi.org/project/Pynche/

   (15) https://gitlab.com/warsaw/pynche/-/tree/main


File: python.info,  Node: Porting to Python 3 11,  Next: Build Changes<3>,  Prev: 削除,  Up: What's New In Python 3 11

1.3.14 Porting to Python 3.11
-----------------------------

This section lists previously described changes and other bugfixes in
the Python API that may require changes to your Python code.

Porting notes for the C API are *note listed separately: 70a.

   * *note open(): 4e5, *note io.open(): 4e6, *note codecs.open(): 70b.
     and *note fileinput.FileInput: 702. no longer accept ‘'U'’
     ("universal newline") in the file mode.  In Python 3, "universal
     newline" mode is used by default whenever a file is opened in text
     mode, and the ‘'U'’ flag has been deprecated since Python 3.3.  The
     *note newline parameter: 70c. to these functions controls how
     universal newlines work.  (Contributed by Victor Stinner in
     bpo-37330(1).)

   * *note ast.AST: 18b. node positions are now validated when provided
     to *note compile(): 177. and other related functions.  If invalid
     positions are detected, a *note ValueError: 1e3. will be raised.
     (Contributed by Pablo Galindo in gh-93351(2))

   * Prohibited passing non-*note concurrent.futures.ThreadPoolExecutor:
     70d. executors to *note asyncio.loop.set_default_executor(): 70e.
     following a deprecation in Python 3.8.  (Contributed by Illia
     Volochii in bpo-43234(3).)

   * *note calendar: 10.: The *note calendar.LocaleTextCalendar: 70f.
     and *note calendar.LocaleHTMLCalendar: 710. classes now use *note
     locale.getlocale(): 2bc, instead of using *note
     locale.getdefaultlocale(): 2bb, if no locale is specified.
     (Contributed by Victor Stinner in bpo-46659(4).)

   * The *note pdb: 94. module now reads the ‘.pdbrc’ configuration file
     with the ‘'UTF-8'’ encoding.  (Contributed by Srinivas Reddy
     Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) in bpo-41137(5).)

   * The 'population' parameter of *note random.sample(): 711. must be a
     sequence, and automatic conversion of *note set: 5a3.s to *note
     list: 5dc.s is no longer supported.  Also, if the sample size is
     larger than the population size, a *note ValueError: 1e3. is
     raised.  (Contributed by Raymond Hettinger in bpo-40465(6).)

   * The 'random' optional parameter of *note random.shuffle(): 712. was
     removed.  It was previously an arbitrary random function to use for
     the shuffle; now, *note random.random(): 713. (its previous
     default) will always be used.

   * In *note re: a7. *note 正規表現のシンタックス: 6ef, global inline
     flags (e.g.  ‘(?i)’) can now only be used at the start of regular
     expressions.  Using them elsewhere has been deprecated since Python
     3.6.  (Contributed by Serhiy Storchaka in bpo-47066(7).)

   * In the *note re: a7. module, several long-standing bugs where fixed
     that, in rare cases, could cause capture groups to get the wrong
     result.  Therefore, this could change the captured output in these
     cases.  (Contributed by Ma Lin in bpo-35859(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37330

   (2) https://github.com/python/cpython/issues/93351

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43234

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46659

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41137

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40465

   (7) https://bugs.python.org/issue?@action=redirect&bpo=47066

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35859


File: python.info,  Node: Build Changes<3>,  Next: C API の変更,  Prev: Porting to Python 3 11,  Up: What's New In Python 3 11

1.3.15 Build Changes
--------------------

   * CPython now has PEP 11(1) Tier 3 support(2) for cross compiling to
     the WebAssembly(3) platforms Emscripten(4)
     (‘wasm32-unknown-emscripten’, i.e.  Python in the browser) and
     WebAssembly System Interface (WASI)(5) (‘wasm32-unknown-wasi’).
     The effort is inspired by previous work like Pyodide(6).  These
     platforms provide a limited subset of POSIX APIs; Python standard
     libraries features and modules related to networking, processes,
     threading, signals, mmap, and users/groups are not available or
     don't work.  (Emscripten contributed by Christian Heimes and Ethan
     Smith in gh-84461(7) and WASI contributed by Christian Heimes in
     gh-90473(8); platforms promoted in gh-95085(9))

   * Building CPython now requires:

        * A C11(10) compiler and standard library.  Optional C11
          features(11) are not required.  (Contributed by Victor Stinner
          in bpo-46656(12), bpo-45440(13) and bpo-46640(14).)

        * Support for IEEE 754(15) floating-point numbers.  (Contributed
          by Victor Stinner in bpo-46917(16).)

   * The ‘Py_NO_NAN’ macro has been removed.  Since CPython now requires
     IEEE 754 floats, NaN values are always available.  (Contributed by
     Victor Stinner in bpo-46656(17).)

   * The *note tkinter: d9. package now requires Tcl/Tk(18) version
     8.5.12 or newer.  (Contributed by Serhiy Storchaka in
     bpo-46996(19).)

   * Build dependencies, compiler flags, and linker flags for most
     stdlib extension modules are now detected by ‘configure’.  libffi,
     libnsl, libsqlite3, zlib, bzip2, liblzma, libcrypt, Tcl/Tk, and
     uuid flags are detected by pkg-config(20) (when available).  *note
     tkinter: d9. now requires a pkg-config command to detect
     development settings for Tcl/Tk(21) headers and libraries.
     (Contributed by Christian Heimes and Erlend Egeberg Aasland in
     bpo-45847(22), bpo-45747(23), and bpo-45763(24).)

   * libpython is no longer linked against libcrypt.  (Contributed by
     Mike Gilbert in bpo-45433(25).)

   * CPython can now be built with the ThinLTO(26) option via passing
     ‘thin’ to *note -with-lto: 716, i.e.  ‘--with-lto=thin’.
     (Contributed by Donghee Na and Brett Holman in bpo-44340(27).)

   * Freelists for object structs can now be disabled.  A new
     ‘configure’ option *note -without-freelists: 717. can be used to
     disable all freelists except empty tuple singleton.  (Contributed
     by Christian Heimes in bpo-45522(28).)

   * ‘Modules/Setup’ and ‘Modules/makesetup’ have been improved and tied
     up.  Extension modules can now be built through ‘makesetup’.  All
     except some test modules can be linked statically into a main
     binary or library.  (Contributed by Brett Cannon and Christian
     Heimes in bpo-45548(29), bpo-45570(30), bpo-45571(31), and
     bpo-43974(32).)

          注釈: Use the environment variables ‘TCLTK_CFLAGS’ and
          ‘TCLTK_LIBS’ to manually specify the location of Tcl/Tk
          headers and libraries.  The ‘configure’ options
          ‘--with-tcltk-includes’ and ‘--with-tcltk-libs’ have been
          removed.

          On RHEL 7 and CentOS 7 the development packages do not provide
          ‘tcl.pc’ and ‘tk.pc’; use ‘TCLTK_LIBS="-ltk8.5 -ltkstub8.5
          -ltcl8.5"’.  The directory ‘Misc/rhel7’ contains ‘.pc’ files
          and instructions on how to build Python with RHEL 7's and
          CentOS 7's Tcl/Tk and OpenSSL.

   * CPython will now use 30-bit digits by default for the Python *note
     int: 238. implementation.  Previously, the default was to use
     30-bit digits on platforms with ‘SIZEOF_VOID_P >= 8’, and 15-bit
     digits otherwise.  It's still possible to explicitly request use of
     15-bit digits via either the *note -enable-big-digits: 718. option
     to the configure script or (for Windows) the ‘PYLONG_BITS_IN_DIGIT’
     variable in ‘PC/pyconfig.h’, but this option may be removed at some
     point in the future.  (Contributed by Mark Dickinson in
     bpo-45569(33).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0011/

   (2) https://peps.python.org/pep-0011/#tier-3

   (3) https://webassembly.org/

   (4) https://emscripten.org/

   (5) https://wasi.dev/

   (6) https://pyodide.org/

   (7) https://github.com/python/cpython/issues/84461

   (8) https://github.com/python/cpython/issues/90473

   (9) https://github.com/python/cpython/issues/95085

   (10) https://en.cppreference.com/w/c/11

   (11) 
https://en.wikipedia.org/wiki/C11_(C_standard_revision)#Optional_features

   (12) https://bugs.python.org/issue?@action=redirect&bpo=46656

   (13) https://bugs.python.org/issue?@action=redirect&bpo=45440

   (14) https://bugs.python.org/issue?@action=redirect&bpo=46640

   (15) https://en.wikipedia.org/wiki/IEEE_754

   (16) https://bugs.python.org/issue?@action=redirect&bpo=46917

   (17) https://bugs.python.org/issue?@action=redirect&bpo=46656

   (18) https://www.tcl.tk

   (19) https://bugs.python.org/issue?@action=redirect&bpo=46996

   (20) https://www.freedesktop.org/wiki/Software/pkg-config/

   (21) https://www.tcl.tk

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45847

   (23) https://bugs.python.org/issue?@action=redirect&bpo=45747

   (24) https://bugs.python.org/issue?@action=redirect&bpo=45763

   (25) https://bugs.python.org/issue?@action=redirect&bpo=45433

   (26) https://clang.llvm.org/docs/ThinLTO.html

   (27) https://bugs.python.org/issue?@action=redirect&bpo=44340

   (28) https://bugs.python.org/issue?@action=redirect&bpo=45522

   (29) https://bugs.python.org/issue?@action=redirect&bpo=45548

   (30) https://bugs.python.org/issue?@action=redirect&bpo=45570

   (31) https://bugs.python.org/issue?@action=redirect&bpo=45571

   (32) https://bugs.python.org/issue?@action=redirect&bpo=43974

   (33) https://bugs.python.org/issue?@action=redirect&bpo=45569


File: python.info,  Node: C API の変更,  Next: Python 3 11 4での重要な変更点,  Prev: Build Changes<3>,  Up: What's New In Python 3 11

1.3.16 C API の変更
-------------------

* Menu:

* 新しい機能: 新しい機能<2>.
* Porting to Python 3.11: Porting to Python 3 11<2>.
* 非推奨: 非推奨<2>.
* Pending Removal in Python 3.12: Pending Removal in Python 3 12<2>.
* 削除: 削除<2>.


File: python.info,  Node: 新しい機能<2>,  Next: Porting to Python 3 11<2>,  Up: C API の変更

1.3.16.1 新しい機能
...................

   * Add a new *note PyType_GetName(): 71d. function to get type's short
     name.  (Contributed by Hai Shi in bpo-42035(1).)

   * Add a new *note PyType_GetQualName(): 71e. function to get type's
     qualified name.  (Contributed by Hai Shi in bpo-42035(2).)

   * Add new *note PyThreadState_EnterTracing(): 71f. and *note
     PyThreadState_LeaveTracing(): 720. functions to the limited C API
     to suspend and resume tracing and profiling.  (Contributed by
     Victor Stinner in bpo-43760(3).)

   * Added the *note Py_Version: 721. constant which bears the same
     value as *note PY_VERSION_HEX: 722.  (Contributed by Gabriele N.
     Tornetta in bpo-43931(4).)

   * *note Py_buffer: 723. and APIs are now part of the limited API and
     the stable ABI:

        * *note PyObject_CheckBuffer(): 372.

        * *note PyObject_GetBuffer(): 373.

        * *note PyBuffer_GetPointer(): 724.

        * *note PyBuffer_SizeFromFormat(): 725.

        * *note PyBuffer_ToContiguous(): 726.

        * *note PyBuffer_FromContiguous(): 727.

        * *note PyObject_CopyData(): 728.

        * *note PyBuffer_IsContiguous(): 729.

        * *note PyBuffer_FillContiguousStrides(): 72a.

        * *note PyBuffer_FillInfo(): 72b.

        * *note PyBuffer_Release(): 374.

        * *note PyMemoryView_FromBuffer(): 72c.

        * *note bf_getbuffer: 72d. and *note bf_releasebuffer: 72e. type
          slots

     (Contributed by Christian Heimes in bpo-45459(5).)

   * Added the *note PyType_GetModuleByDef(): 36d. function, used to get
     the module in which a method was defined, in cases where this
     information is not available directly (via *note PyCMethod: 72f.).
     (Contributed by Petr Viktorin in bpo-46613(6).)

   * Add new functions to pack and unpack C double (serialize and
     deserialize): *note PyFloat_Pack2(): 730, *note PyFloat_Pack4():
     731, *note PyFloat_Pack8(): 732, *note PyFloat_Unpack2(): 733,
     *note PyFloat_Unpack4(): 734. and *note PyFloat_Unpack8(): 735.
     (Contributed by Victor Stinner in bpo-46906(7).)

   * Add new functions to get frame object attributes: *note
     PyFrame_GetBuiltins(): 736, *note PyFrame_GetGenerator(): 737,
     *note PyFrame_GetGlobals(): 738, *note PyFrame_GetLasti(): 739.

   * Added two new functions to get and set the active exception
     instance: *note PyErr_GetHandledException(): 73a. and *note
     PyErr_SetHandledException(): 73b.  These are alternatives to *note
     PyErr_SetExcInfo(): 73c. and *note PyErr_GetExcInfo(): 73d. which
     work with the legacy 3-tuple representation of exceptions.
     (Contributed by Irit Katriel in bpo-46343(8).)

   * Added the *note PyConfig.safe_path: 73e. member.  (Contributed by
     Victor Stinner in gh-57684(9).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42035

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42035

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43760

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43931

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45459

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46613

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46906

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46343

   (9) https://github.com/python/cpython/issues/57684


File: python.info,  Node: Porting to Python 3 11<2>,  Next: 非推奨<2>,  Prev: 新しい機能<2>,  Up: C API の変更

1.3.16.2 Porting to Python 3.11
...............................

   * Some macros have been converted to static inline functions to avoid
     macro pitfalls(1).  The change should be mostly transparent to
     users, as the replacement functions will cast their arguments to
     the expected types to avoid compiler warnings due to static type
     checks.  However, when the limited C API is set to >=3.11, these
     casts are not done, and callers will need to cast arguments to
     their expected types.  See PEP 670(2) for more details.
     (Contributed by Victor Stinner and Erlend E. Aasland in
     gh-89653(3).)

   * *note PyErr_SetExcInfo(): 73c. no longer uses the ‘type’ and
     ‘traceback’ arguments, the interpreter now derives those values
     from the exception instance (the ‘value’ argument).  The function
     still steals references of all three arguments.  (Contributed by
     Irit Katriel in bpo-45711(4).)

   * *note PyErr_GetExcInfo(): 73d. now derives the ‘type’ and
     ‘traceback’ fields of the result from the exception instance (the
     ‘value’ field).  (Contributed by Irit Katriel in bpo-45711(5).)

   * *note _frozen: 740. has a new ‘is_package’ field to indicate
     whether or not the frozen module is a package.  Previously, a
     negative value in the ‘size’ field was the indicator.  Now only
     non-negative values be used for ‘size’.  (Contributed by Kumar
     Aditya in bpo-46608(6).)

   * *note _PyFrameEvalFunction(): 741. now takes ‘_PyInterpreterFrame*’
     as its second parameter, instead of ‘PyFrameObject*’.  See PEP
     523(7) for more details of how to use this function pointer type.

   * ‘PyCode_New()’ and ‘PyCode_NewWithPosOnlyArgs()’ now take an
     additional ‘exception_table’ argument.  Using these functions
     should be avoided, if at all possible.  To get a custom code
     object: create a code object using the compiler, then get a
     modified version with the ‘replace’ method.

   * *note PyCodeObject: 742. no longer has the ‘co_code’,
     ‘co_varnames’, ‘co_cellvars’ and ‘co_freevars’ fields.  Instead,
     use *note PyCode_GetCode(): 743, *note PyCode_GetVarnames(): 744,
     *note PyCode_GetCellvars(): 745. and *note PyCode_GetFreevars():
     746. respectively to access them via the C API. (Contributed by
     Brandt Bucher in bpo-46841(8) and Ken Jin in gh-92154(9) and
     gh-94936(10).)

   * The old trashcan macros
     (‘Py_TRASHCAN_SAFE_BEGIN’/‘Py_TRASHCAN_SAFE_END’) are now
     deprecated.  They should be replaced by the new macros
     ‘Py_TRASHCAN_BEGIN’ and ‘Py_TRASHCAN_END’.

     A tp_dealloc function that has the old macros, such as:

          static void
          mytype_dealloc(mytype *p)
          {
              PyObject_GC_UnTrack(p);
              Py_TRASHCAN_SAFE_BEGIN(p);
              ...
              Py_TRASHCAN_SAFE_END
          }

     should migrate to the new macros as follows:

          static void
          mytype_dealloc(mytype *p)
          {
              PyObject_GC_UnTrack(p);
              Py_TRASHCAN_BEGIN(p, mytype_dealloc)
              ...
              Py_TRASHCAN_END
          }

     Note that ‘Py_TRASHCAN_BEGIN’ has a second argument which should be
     the deallocation function it is in.

     To support older Python versions in the same codebase, you can
     define the following macros and use them throughout the code
     (credit: these were copied from the ‘mypy’ codebase):

          #if PY_VERSION_HEX >= 0x03080000
          #  define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_BEGIN(op, dealloc)
          #  define CPy_TRASHCAN_END(op) Py_TRASHCAN_END
          #else
          #  define CPy_TRASHCAN_BEGIN(op, dealloc) Py_TRASHCAN_SAFE_BEGIN(op)
          #  define CPy_TRASHCAN_END(op) Py_TRASHCAN_SAFE_END(op)
          #endif

   * The *note PyType_Ready(): 747. function now raises an error if a
     type is defined with the *note Py_TPFLAGS_HAVE_GC: 748. flag set
     but has no traverse function (*note PyTypeObject.tp_traverse:
     749.).  (Contributed by Victor Stinner in bpo-44263(11).)

   * Heap types with the *note Py_TPFLAGS_IMMUTABLETYPE: 39c. flag can
     now inherit the PEP 590(12) vectorcall protocol.  Previously, this
     was only possible for *note static types: 74a.  (Contributed by
     Erlend E. Aasland in bpo-43908(13))

   * Since *note Py_TYPE(): 74b. is changed to a inline static function,
     ‘Py_TYPE(obj) = new_type’ must be replaced with ‘Py_SET_TYPE(obj,
     new_type)’: see the *note Py_SET_TYPE(): 74c. function (available
     since Python 3.9).  For backward compatibility, this macro can be
     used:

          #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
          static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
          { ob->ob_type = type; }
          #define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type)
          #endif

     (Contributed by Victor Stinner in bpo-39573(14).)

   * Since *note Py_SIZE(): 74d. is changed to a inline static function,
     ‘Py_SIZE(obj) = new_size’ must be replaced with ‘Py_SET_SIZE(obj,
     new_size)’: see the *note Py_SET_SIZE(): 74e. function (available
     since Python 3.9).  For backward compatibility, this macro can be
     used:

          #if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE)
          static inline void _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)
          { ob->ob_size = size; }
          #define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject*)(ob), size)
          #endif

     (Contributed by Victor Stinner in bpo-39573(15).)

   * ‘<Python.h>’ no longer includes the header files ‘<stdlib.h>’,
     ‘<stdio.h>’, ‘<errno.h>’ and ‘<string.h>’ when the ‘Py_LIMITED_API’
     macro is set to ‘0x030b0000’ (Python 3.11) or higher.  C extensions
     should explicitly include the header files after ‘#include
     <Python.h>’.  (Contributed by Victor Stinner in bpo-45434(16).)

   * The non-limited API files ‘cellobject.h’, ‘classobject.h’,
     ‘code.h’, ‘context.h’, ‘funcobject.h’, ‘genobject.h’ and
     ‘longintrepr.h’ have been moved to the ‘Include/cpython’ directory.
     Moreover, the ‘eval.h’ header file was removed.  These files must
     not be included directly, as they are already included in
     ‘Python.h’: *note Include Files: 74f.  If they have been included
     directly, consider including ‘Python.h’ instead.  (Contributed by
     Victor Stinner in bpo-35134(17).)

   * The ‘PyUnicode_CHECK_INTERNED()’ macro has been excluded from the
     limited C API. It was never usable there, because it used internal
     structures which are not available in the limited C API.
     (Contributed by Victor Stinner in bpo-46007(18).)

   * The following frame functions and type are now directly available
     with ‘#include <Python.h>’, it's no longer needed to add ‘#include
     <frameobject.h>’:

        * *note PyFrame_Check(): 750.

        * *note PyFrame_GetBack(): 751.

        * *note PyFrame_GetBuiltins(): 736.

        * *note PyFrame_GetGenerator(): 737.

        * *note PyFrame_GetGlobals(): 738.

        * *note PyFrame_GetLasti(): 739.

        * *note PyFrame_GetLocals(): 3f8.

        * *note PyFrame_Type: 752.

     (Contributed by Victor Stinner in gh-93937(19).)

   * The *note PyFrameObject: 754. structure members have been removed
     from the public C API.

     While the documentation notes that the *note PyFrameObject: 754.
     fields are subject to change at any time, they have been stable for
     a long time and were used in several popular extensions.

     In Python 3.11, the frame struct was reorganized to allow
     performance optimizations.  Some fields were removed entirely, as
     they were details of the old implementation.

     *note PyFrameObject: 754. fields:

        * ‘f_back’: use *note PyFrame_GetBack(): 751.

        * ‘f_blockstack’: removed.

        * ‘f_builtins’: use *note PyFrame_GetBuiltins(): 736.

        * ‘f_code’: use *note PyFrame_GetCode(): 755.

        * ‘f_gen’: use *note PyFrame_GetGenerator(): 737.

        * ‘f_globals’: use *note PyFrame_GetGlobals(): 738.

        * ‘f_iblock’: removed.

        * ‘f_lasti’: use *note PyFrame_GetLasti(): 739.  Code using
          ‘f_lasti’ with ‘PyCode_Addr2Line()’ should use *note
          PyFrame_GetLineNumber(): 756. instead; it may be faster.

        * ‘f_lineno’: use *note PyFrame_GetLineNumber(): 756.

        * ‘f_locals’: use *note PyFrame_GetLocals(): 3f8.

        * ‘f_stackdepth’: removed.

        * ‘f_state’: no public API (renamed to ‘f_frame.f_state’).

        * ‘f_trace’: no public API.

        * ‘f_trace_lines’: use ‘PyObject_GetAttrString((PyObject*)frame,
          "f_trace_lines")’.

        * ‘f_trace_opcodes’: use
          ‘PyObject_GetAttrString((PyObject*)frame, "f_trace_opcodes")’.

        * ‘f_localsplus’: no public API (renamed to
          ‘f_frame.localsplus’).

        * ‘f_valuestack’: removed.

     The Python frame object is now created lazily.  A side effect is
     that the *note f_back: 757. member must not be accessed directly,
     since its value is now also computed lazily.  The *note
     PyFrame_GetBack(): 751. function must be called instead.

     Debuggers that accessed the *note f_locals: 167. directly 'must'
     call *note PyFrame_GetLocals(): 3f8. instead.  They no longer need
     to call ‘PyFrame_FastToLocalsWithError()’ or
     ‘PyFrame_LocalsToFast()’, in fact they should not call those
     functions.  The necessary updating of the frame is now managed by
     the virtual machine.

     Code defining ‘PyFrame_GetCode()’ on Python 3.8 and older:

          #if PY_VERSION_HEX < 0x030900B1
          static inline PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
          {
              Py_INCREF(frame->f_code);
              return frame->f_code;
          }
          #endif

     Code defining ‘PyFrame_GetBack()’ on Python 3.8 and older:

          #if PY_VERSION_HEX < 0x030900B1
          static inline PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
          {
              Py_XINCREF(frame->f_back);
              return frame->f_back;
          }
          #endif

     Or use the pythoncapi_compat project(20) to get these two functions
     on older Python versions.

   * Changes of the *note PyThreadState: 758. structure members:

        * ‘frame’: removed, use *note PyThreadState_GetFrame(): 759.
          (function added to Python 3.9 by bpo-40429(21)).  Warning: the
          function returns a *note strong reference: 316, need to call
          *note Py_XDECREF(): 75a.

        * ‘tracing’: changed, use *note PyThreadState_EnterTracing():
          71f. and *note PyThreadState_LeaveTracing(): 720. (functions
          added to Python 3.11 by bpo-43760(22)).

        * ‘recursion_depth’: removed, use ‘(tstate->recursion_limit -
          tstate->recursion_remaining)’ instead.

        * ‘stackcheck_counter’: removed.

     Code defining ‘PyThreadState_GetFrame()’ on Python 3.8 and older:

          #if PY_VERSION_HEX < 0x030900B1
          static inline PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate)
          {
              Py_XINCREF(tstate->frame);
              return tstate->frame;
          }
          #endif

     Code defining ‘PyThreadState_EnterTracing()’ and
     ‘PyThreadState_LeaveTracing()’ on Python 3.10 and older:

          #if PY_VERSION_HEX < 0x030B00A2
          static inline void PyThreadState_EnterTracing(PyThreadState *tstate)
          {
              tstate->tracing++;
          #if PY_VERSION_HEX >= 0x030A00A1
              tstate->cframe->use_tracing = 0;
          #else
              tstate->use_tracing = 0;
          #endif
          }

          static inline void PyThreadState_LeaveTracing(PyThreadState *tstate)
          {
              int use_tracing = (tstate->c_tracefunc != NULL || tstate->c_profilefunc != NULL);
              tstate->tracing--;
          #if PY_VERSION_HEX >= 0x030A00A1
              tstate->cframe->use_tracing = use_tracing;
          #else
              tstate->use_tracing = use_tracing;
          #endif
          }
          #endif

     Or use the pythoncapi-compat project(23) to get these functions on
     old Python functions.

   * Distributors are encouraged to build Python with the optimized
     Blake2 library libb2(24).

   * The *note PyConfig.module_search_paths_set: 5b9. field must now be
     set to 1 for initialization to use *note
     PyConfig.module_search_paths: 37c. to initialize *note sys.path:
     38e.  Otherwise, initialization will recalculate the path and
     replace any values added to ‘module_search_paths’.

   * *note PyConfig_Read(): 75b. no longer calculates the initial search
     path, and will not fill any values into *note
     PyConfig.module_search_paths: 37c.  To calculate default paths and
     then modify them, finish initialization and use *note
     PySys_GetObject(): 362. to retrieve *note sys.path: 38e. as a
     Python list object and modify it directly.

   ---------- Footnotes ----------

   (1) https://gcc.gnu.org/onlinedocs/cpp/Macro-Pitfalls.html

   (2) https://peps.python.org/pep-0670/

   (3) https://github.com/python/cpython/issues/89653

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46608

   (7) https://peps.python.org/pep-0523/

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (9) https://github.com/python/cpython/issues/92154

   (10) https://github.com/python/cpython/issues/94936

   (11) https://bugs.python.org/issue?@action=redirect&bpo=44263

   (12) https://peps.python.org/pep-0590/

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43908

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (15) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (16) https://bugs.python.org/issue?@action=redirect&bpo=45434

   (17) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (18) https://bugs.python.org/issue?@action=redirect&bpo=46007

   (19) https://github.com/python/cpython/issues/93937

   (20) https://github.com/python/pythoncapi-compat

   (21) https://bugs.python.org/issue?@action=redirect&bpo=40429

   (22) https://bugs.python.org/issue?@action=redirect&bpo=43760

   (23) https://github.com/python/pythoncapi-compat

   (24) https://www.blake2.net/


File: python.info,  Node: 非推奨<2>,  Next: Pending Removal in Python 3 12<2>,  Prev: Porting to Python 3 11<2>,  Up: C API の変更

1.3.16.3 非推奨
...............

   * Deprecate the following functions to configure the Python
     initialization:

        * ‘PySys_AddWarnOptionUnicode()’

        * ‘PySys_AddWarnOption()’

        * ‘PySys_AddXOption()’

        * ‘PySys_HasWarnOptions()’

        * ‘PySys_SetArgvEx()’

        * ‘PySys_SetArgv()’

        * ‘PySys_SetPath()’

        * ‘Py_SetPath()’

        * ‘Py_SetProgramName()’

        * ‘Py_SetPythonHome()’

        * ‘Py_SetStandardStreamEncoding()’

        * ‘_Py_SetProgramFullPath()’

     Use the new *note PyConfig: 380. API of the *note Python
     Initialization Configuration: 381. instead ( PEP 587(1)).
     (Contributed by Victor Stinner in gh-88279(2).)

   * Deprecate the ‘ob_shash’ member of the *note PyBytesObject: 75d.
     Use *note PyObject_Hash(): 3dc. instead.  (Contributed by Inada
     Naoki in bpo-46864(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0587/

   (2) https://github.com/python/cpython/issues/88279

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46864


File: python.info,  Node: Pending Removal in Python 3 12<2>,  Next: 削除<2>,  Prev: 非推奨<2>,  Up: C API の変更

1.3.16.4 Pending Removal in Python 3.12
.......................................

The following C APIs have been deprecated in earlier Python releases,
and will be removed in Python 3.12.

   * ‘PyUnicode_AS_DATA()’

   * ‘PyUnicode_AS_UNICODE()’

   * ‘PyUnicode_AsUnicodeAndSize()’

   * ‘PyUnicode_AsUnicode()’

   * ‘PyUnicode_FromUnicode()’

   * ‘PyUnicode_GET_DATA_SIZE()’

   * ‘PyUnicode_GET_SIZE()’

   * ‘PyUnicode_GetSize()’

   * ‘PyUnicode_IS_COMPACT()’

   * ‘PyUnicode_IS_READY()’

   * *note PyUnicode_READY(): 3da.

   * ‘PyUnicode_WSTR_LENGTH()’

   * ‘_PyUnicode_AsUnicode()’

   * ‘PyUnicode_WCHAR_KIND’

   * *note PyUnicodeObject: 75f.

   * ‘PyUnicode_InternImmortal()’


File: python.info,  Node: 削除<2>,  Prev: Pending Removal in Python 3 12<2>,  Up: C API の変更

1.3.16.5 削除
.............

   * ‘PyFrame_BlockSetup()’ and ‘PyFrame_BlockPop()’ have been removed.
     (Contributed by Mark Shannon in bpo-40222(1).)

   * Remove the following math macros using the ‘errno’ variable:

        * ‘Py_ADJUST_ERANGE1()’

        * ‘Py_ADJUST_ERANGE2()’

        * ‘Py_OVERFLOWED()’

        * ‘Py_SET_ERANGE_IF_OVERFLOW()’

        * ‘Py_SET_ERRNO_ON_MATH_ERROR()’

     (Victor Stinner の貢献による bpo-45412(2))

   * Remove ‘Py_UNICODE_COPY()’ and ‘Py_UNICODE_FILL()’ macros,
     deprecated since Python 3.3.  Use ‘PyUnicode_CopyCharacters()’ or
     ‘memcpy()’ (‘wchar_t*’ string), and ‘PyUnicode_Fill()’ functions
     instead.  (Contributed by Victor Stinner in bpo-41123(3).)

   * Remove the ‘pystrhex.h’ header file.  It only contains private
     functions.  C extensions should only include the main ‘<Python.h>’
     header file.  (Contributed by Victor Stinner in bpo-45434(4).)

   * Remove the ‘Py_FORCE_DOUBLE()’ macro.  It was used by the
     ‘Py_IS_INFINITY()’ macro.  (Contributed by Victor Stinner in
     bpo-45440(5).)

   * The following items are no longer available when *note
     Py_LIMITED_API: 3f7. is defined:

        * *note PyMarshal_WriteLongToFile(): 761.

        * *note PyMarshal_WriteObjectToFile(): 762.

        * *note PyMarshal_ReadObjectFromString(): 763.

        * *note PyMarshal_WriteObjectToString(): 764.

        * ‘Py_MARSHAL_VERSION’ マクロ

     These are not part of the *note limited API: 765.

     (Contributed by Victor Stinner in bpo-45474(6).)

   * Exclude *note PyWeakref_GET_OBJECT(): 399. from the limited C API.
     It never worked since the ‘PyWeakReference’ structure is opaque in
     the limited C API. (Contributed by Victor Stinner in bpo-35134(7).)

   * Remove the ‘PyHeapType_GET_MEMBERS()’ macro.  It was exposed in the
     public C API by mistake, it must only be used by Python internally.
     Use the ‘PyTypeObject.tp_members’ member instead.  (Contributed by
     Victor Stinner in bpo-40170(8).)

   * Remove the ‘HAVE_PY_SET_53BIT_PRECISION’ macro (moved to the
     internal C API). (Contributed by Victor Stinner in bpo-45412(9).)

   * Remove the *note Py_UNICODE: 3c7. encoder APIs, as they have been
     deprecated since Python 3.3, are little used and are inefficient
     relative to the recommended alternatives.

     削除された関数は以下の通りです:

        * ‘PyUnicode_Encode()’

        * ‘PyUnicode_EncodeASCII()’

        * ‘PyUnicode_EncodeLatin1()’

        * ‘PyUnicode_EncodeUTF7()’

        * ‘PyUnicode_EncodeUTF8()’

        * ‘PyUnicode_EncodeUTF16()’

        * ‘PyUnicode_EncodeUTF32()’

        * ‘PyUnicode_EncodeUnicodeEscape()’

        * ‘PyUnicode_EncodeRawUnicodeEscape()’

        * ‘PyUnicode_EncodeCharmap()’

        * ‘PyUnicode_TranslateCharmap()’

        * ‘PyUnicode_EncodeDecimal()’

        * ‘PyUnicode_TransformDecimalToASCII()’

     See PEP 624(10) for details and migration guidance(11).
     (Contributed by Inada Naoki in bpo-44029(12).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40222

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45412

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41123

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45434

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45440

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45474

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45412

   (10) https://peps.python.org/pep-0624/

   (11) https://peps.python.org/pep-0624/#alternative-apis

   (12) https://bugs.python.org/issue?@action=redirect&bpo=44029


File: python.info,  Node: Python 3 11 4での重要な変更点,  Next: Python 3 11 5での重要な変更点,  Prev: C API の変更,  Up: What's New In Python 3 11

1.3.17 Python 3.11.4での重要な変更点
------------------------------------

* Menu:

* tarfile::


File: python.info,  Node: tarfile,  Up: Python 3 11 4での重要な変更点

1.3.17.1 tarfile
................

   * The extraction methods in *note tarfile: c8, and *note
     shutil.unpack_archive(): 438, have a new a 'filter' argument that
     allows limiting tar features than may be surprising or dangerous,
     such as creating files outside the destination directory.  See
     *note Extraction filters: 439. for details.  In Python 3.12, use
     without the 'filter' argument will show a *note DeprecationWarning:
     18a.  In Python 3.14, the default will switch to ‘'data'’.
     (Contributed by Petr Viktorin in PEP 706(1).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0706/


File: python.info,  Node: Python 3 11 5での重要な変更点,  Prev: Python 3 11 4での重要な変更点,  Up: What's New In Python 3 11

1.3.18 Python 3.11.5での重要な変更点
------------------------------------

* Menu:

* OpenSSL::


File: python.info,  Node: OpenSSL,  Up: Python 3 11 5での重要な変更点

1.3.18.1 OpenSSL
................

   * Windows builds and macOS installers from python.org now use OpenSSL
     3.0.


File: python.info,  Node: What's New In Python 3 10,  Next: What's New In Python 3 9,  Prev: What's New In Python 3 11,  Up: What's New in Python

1.4 What's New In Python 3.10
=============================


編集者: Pablo Galindo Salgado

この記事では Python 3.9 と比較した Python 3.10 の新機能を解説します。
Python 3.10 は2021年10月4日にリリースされました。全詳細については *note
変更履歴: 122. をご覧ください。

* Menu:

* 概要: 概要 -- リリースハイライト<2>. リリースハイライト
* 新しい機能: 新しい機能<3>.
* 型ヒントに関連する新しい機能: 型ヒントに関連する新しい機能<2>.
* その他の言語変更: その他の言語変更<2>.
* 新たなモジュール: 新たなモジュール<2>.
* 改良されたモジュール: 改良されたモジュール<2>.
* 最適化: 最適化<2>.
* 非推奨: 非推奨<3>.
* 削除: 削除<3>.
* Porting to Python 3.10: Porting to Python 3 10.
* CPython バイトコードの変更: CPython バイトコードの変更<2>.
* Build Changes: Build Changes<4>.
* C API の変更: C API の変更<3>.
* Notable security feature in 3.10.7: Notable security feature in 3 10 7.
* Notable security feature in 3.10.8: Notable security feature in 3 10 8.
* Notable changes in 3.10.12: Notable changes in 3 10 12.


File: python.info,  Node: 概要 -- リリースハイライト<2>,  Next: 新しい機能<3>,  Up: What's New In Python 3 10

1.4.1 概要 - リリースハイライト
-------------------------------

新たな文法機能:

   * PEP 634(1)、構造的パターンマッチ: 仕様

   * PEP 635(2)、構造的パターンマッチ: モチベーションと原理

   * PEP 636(3)、構造的パターンマッチ: チュートリアル

   * bpo-12782(4)、カッコ内のコンテキストマネージャーが正式にサポート

標準ライブラリの新機能:

   * PEP 618(5)、zipに長さチェックのオプション引数が追加

インタプリタの改善:

   * PEP 626(6), Precise line numbers for debugging and other tools.

新しい型ヒントの機能:

   * PEP 604(7), Allow writing union types as X | Y

   * PEP 612(8), Parameter Specification Variables

   * PEP 613(9), Explicit Type Aliases

   * PEP 647(10), User-Defined Type Guards

重要な非推奨化、削除または制限:

   * PEP 644(11), Require OpenSSL 1.1.1 or newer

   * PEP 632(12), Deprecate distutils module.

   * PEP 623(13), Deprecate and prepare for the removal of the wstr
     member in PyUnicodeObject.

   * PEP 624(14), Remove Py_UNICODE encoder APIs

   * PEP 597(15), Add optional EncodingWarning

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0634/

   (2) https://peps.python.org/pep-0635/

   (3) https://peps.python.org/pep-0636/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=12782

   (5) https://peps.python.org/pep-0618/

   (6) https://peps.python.org/pep-0626/

   (7) https://peps.python.org/pep-0604/

   (8) https://peps.python.org/pep-0612/

   (9) https://peps.python.org/pep-0613/

   (10) https://peps.python.org/pep-0647/

   (11) https://peps.python.org/pep-0644/

   (12) https://peps.python.org/pep-0632/

   (13) https://peps.python.org/pep-0623/

   (14) https://peps.python.org/pep-0624/

   (15) https://peps.python.org/pep-0597/


File: python.info,  Node: 新しい機能<3>,  Next: 型ヒントに関連する新しい機能<2>,  Prev: 概要 -- リリースハイライト<2>,  Up: What's New In Python 3 10

1.4.2 新しい機能
----------------

* Menu:

* カッコ内のコンテキストマネージャー::
* エラーメッセージの改善::
* PEP 626; Precise line numbers for debugging and other tools: PEP 626 Precise line numbers for debugging and other tools.
* PEP 634; 構造的パターンマッチ: PEP 634 構造的パターンマッチ.
* Optional EncodingWarning and encoding="locale" option::


File: python.info,  Node: カッコ内のコンテキストマネージャー,  Next: エラーメッセージの改善,  Up: 新しい機能<3>

1.4.2.1 カッコ内のコンテキストマネージャー
..........................................

コンテキストマネージャーを複数行で継続して記述する場合に、カッコで囲むこ
とができるようになりました。複数行でたくさんのコンテキストマネージャーを
記述するときに、従来のimport文と同じようにフォーマットできます。たとえば
、以下のすべての例は有効です:

     with (CtxManager() as example):
         ...

     with (
         CtxManager1(),
         CtxManager2()
     ):
         ...

     with (CtxManager1() as example,
           CtxManager2()):
         ...

     with (CtxManager1(),
           CtxManager2() as example):
         ...

     with (
         CtxManager1() as example1,
         CtxManager2() as example2
     ):
         ...

カッコに囲まれたグループの最後の要素に対する、末尾のカンマも指定可能です
。

     with (
         CtxManager1() as example1,
         CtxManager2() as example2,
         CtxManager3() as example3,
     ):
         ...

この新しい構文は、新パーサーによるLL(1)以外の能力を使用しています。詳細
は PEP 617(1) を参照してください。

(Guido van Rossum、Pablo Galindo、Lysandros Nikolaou の貢献による
bpo-12782(2)、bpo-40334(3))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0617/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12782

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40334


File: python.info,  Node: エラーメッセージの改善,  Next: PEP 626 Precise line numbers for debugging and other tools,  Prev: カッコ内のコンテキストマネージャー,  Up: 新しい機能<3>

1.4.2.2 エラーメッセージの改善
..............................

* Menu:

* SyntaxErrors::
* IndentationErrors::
* AttributeErrors::
* NameErrors::


File: python.info,  Node: SyntaxErrors,  Next: IndentationErrors,  Up: エラーメッセージの改善

1.4.2.3 SyntaxErrors
....................

When parsing code that contains unclosed parentheses or brackets the
interpreter now includes the location of the unclosed bracket of
parentheses instead of displaying 'SyntaxError: unexpected EOF while
parsing' or pointing to some incorrect location.  For instance, consider
the following code (notice the unclosed '{'):

     expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4,
                 38: 4, 39: 4, 45: 5, 46: 5, 47: 5, 48: 5, 49: 5, 54: 6,
     some_other_code = foo()

以前のバージョンのインタープリタは、構文エラーの位置として混乱する場所を
報告していました:

     File "example.py", line 3
         some_other_code = foo()
                         ^
     SyntaxError: invalid syntax

しかしPython 3.10ではより有益なエラーが出力されます:

     File "example.py", line 1
         expected = {9: 1, 18: 2, 19: 2, 27: 3, 28: 3, 29: 3, 36: 4, 37: 4,
                    ^
     SyntaxError: '{' was never closed

In a similar way, errors involving unclosed string literals (single and
triple quoted) now point to the start of the string instead of reporting
EOF/EOL.

These improvements are inspired by previous work in the PyPy
interpreter.

(Pablo Galindoの貢献による bpo-42864(1)、Batuhan Taskayaの貢献による
bpo-40176(2))

*note SyntaxError: 172. exceptions raised by the interpreter will now
highlight the full error range of the expression that constitutes the
syntax error itself, instead of just where the problem is detected.  In
this way, instead of displaying (before Python 3.10):

     >>> foo(x, z for z in range(10), t, w)
       File "<stdin>", line 1
         foo(x, z for z in range(10), t, w)
                ^
     SyntaxError: Generator expression must be parenthesized

now Python 3.10 will display the exception as:

     >>> foo(x, z for z in range(10), t, w)
       File "<stdin>", line 1
         foo(x, z for z in range(10), t, w)
                ^^^^^^^^^^^^^^^^^^^^
     SyntaxError: Generator expression must be parenthesized

This improvement was contributed by Pablo Galindo in bpo-43914(3).

A considerable amount of new specialized messages for *note SyntaxError:
172. exceptions have been incorporated.  Some of the most notable ones
are as follows:

   * ブロックの前の ‘:’ が存在しない:

          >>> if rocket.position > event_horizon
            File "<stdin>", line 1
              if rocket.position > event_horizon
                                                ^
          SyntaxError: expected ':'

     (Pablo Galindo の貢献による bpo-42997(4))

   * 内包表記のターゲットにカッコのないタプルを使用:

          >>> {x,y for x,y in zip('abcd', '1234')}
            File "<stdin>", line 1
              {x,y for x,y in zip('abcd', '1234')}
               ^
          SyntaxError: did you forget parentheses around the comprehension target?

     (Pablo Galindo の貢献による bpo-43017(5))

   * コレクションリテラルや式の間のカンマが存在しない:

          >>> items = {
          ... x: 1,
          ... y: 2
          ... z: 3,
            File "<stdin>", line 3
              y: 2
                 ^
          SyntaxError: invalid syntax. Perhaps you forgot a comma?

     (Pablo Galindo の貢献による bpo-43822(6))

   * 複数の例外の型をカッコで囲んでいない:

          >>> try:
          ...     build_dyson_sphere()
          ... except NotEnoughScienceError, NotEnoughResourcesError:
            File "<stdin>", line 3
              except NotEnoughScienceError, NotEnoughResourcesError:
                     ^
          SyntaxError: multiple exception types must be parenthesized

     (Pablo Galindo の貢献による bpo-43149(7))

   * 辞書のリテラルで ‘:’ と値が存在しない:

          >>> values = {
          ... x: 1,
          ... y: 2,
          ... z:
          ... }
            File "<stdin>", line 4
              z:
               ^
          SyntaxError: expression expected after dictionary key and ':'

          >>> values = {x:1, y:2, z w:3}
            File "<stdin>", line 1
              values = {x:1, y:2, z w:3}
                                  ^
          SyntaxError: ':' expected after dictionary key

     (Pablo Galindo の貢献による bpo-43823(8))

   * ‘try’ ブロックに ‘except’ または ‘finally’ ブロックが存在しない:

          >>> try:
          ...     x = 2
          ... something = 3
            File "<stdin>", line 3
              something  = 3
              ^^^^^^^^^
          SyntaxError: expected 'except' or 'finally' block

     (Pablo Galindo の貢献による bpo-44305(9))

   * 比較で ‘==’ の代わりに ‘=’ を使用している:

          >>> if rocket.position = event_horizon:
            File "<stdin>", line 1
              if rocket.position = event_horizon:
                                 ^
          SyntaxError: cannot assign to attribute here. Maybe you meant '==' instead of '='?

     (Pablo Galindo の貢献による bpo-43797(10))

   * f-stringで ‘*’ を使用している:

          >>> f"Black holes {*all_black_holes} and revelations"
            File "<stdin>", line 1
              (*all_black_holes)
               ^
          SyntaxError: f-string: cannot use starred expression here

     (Pablo Galindo の貢献による bpo-41064(11))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42864

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40176

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43914

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42997

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43017

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43822

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43149

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43823

   (9) https://bugs.python.org/issue?@action=redirect&bpo=44305

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43797

   (11) https://bugs.python.org/issue?@action=redirect&bpo=41064


File: python.info,  Node: IndentationErrors,  Next: AttributeErrors,  Prev: SyntaxErrors,  Up: エラーメッセージの改善

1.4.2.4 IndentationErrors
.........................

Many *note IndentationError: 773. exceptions now have more context
regarding what kind of block was expecting an indentation, including the
location of the statement:

     >>> def foo():
     ...    if lel:
     ...    x = 2
       File "<stdin>", line 3
         x = 2
         ^
     IndentationError: expected an indented block after 'if' statement in line 2


File: python.info,  Node: AttributeErrors,  Next: NameErrors,  Prev: IndentationErrors,  Up: エラーメッセージの改善

1.4.2.5 AttributeErrors
.......................

When printing *note AttributeError: 326, ‘PyErr_Display()’ will offer
suggestions of similar attribute names in the object that the exception
was raised from:

     >>> collections.namedtoplo
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     AttributeError: module 'collections' has no attribute 'namedtoplo'. Did you mean: namedtuple?

(Pablo Galindo の貢献による bpo-38530(1))

     警告: Notice this won't work if ‘PyErr_Display()’ is not called to
     display the error which can happen if some other custom error
     display function is used.  This is a common scenario in some REPLs
     like IPython.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38530


File: python.info,  Node: NameErrors,  Prev: AttributeErrors,  Up: エラーメッセージの改善

1.4.2.6 NameErrors
..................

When printing *note NameError: 40b. raised by the interpreter,
‘PyErr_Display()’ will offer suggestions of similar variable names in
the function that the exception was raised from:

     >>> schwarzschild_black_hole = None
     >>> schwarschild_black_hole
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     NameError: name 'schwarschild_black_hole' is not defined. Did you mean: schwarzschild_black_hole?

(Pablo Galindo の貢献による bpo-38530(1))

     警告: Notice this won't work if ‘PyErr_Display()’ is not called to
     display the error, which can happen if some other custom error
     display function is used.  This is a common scenario in some REPLs
     like IPython.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38530


File: python.info,  Node: PEP 626 Precise line numbers for debugging and other tools,  Next: PEP 634 構造的パターンマッチ,  Prev: エラーメッセージの改善,  Up: 新しい機能<3>

1.4.2.7 PEP 626: Precise line numbers for debugging and other tools
...................................................................

PEP 626 brings more precise and reliable line numbers for debugging,
profiling and coverage tools.  Tracing events, with the correct line
number, are generated for all lines of code executed and only for lines
of code that are executed.

The *note f_lineno: 777. attribute of frame objects will always contain
the expected line number.

The *note co_lnotab: 2c1. attribute of *note code objects: 1b4. is
deprecated and will be removed in 3.12.  Code that needs to convert from
offset to line number should use the new *note co_lines(): 2d2. method
instead.


File: python.info,  Node: PEP 634 構造的パターンマッチ,  Next: Optional EncodingWarning and encoding="locale" option,  Prev: PEP 626 Precise line numbers for debugging and other tools,  Up: 新しい機能<3>

1.4.2.8 PEP 634: 構造的パターンマッチ
.....................................

Structural pattern matching has been added in the form of a 'match
statement' and 'case statements' of patterns with associated actions.
Patterns consist of sequences, mappings, primitive data types as well as
class instances.  Pattern matching enables programs to extract
information from complex data types, branch on the structure of data,
and apply specific actions based on different forms of data.

* Menu:

* Syntax and operations::
* Declarative approach::
* Simple pattern; match to a literal: Simple pattern match to a literal.
* Patterns with a literal and variable::
* Patterns and classes::
* Nested patterns::
* Complex patterns and the wildcard::
* Guard::
* Other Key Features::


File: python.info,  Node: Syntax and operations,  Next: Declarative approach,  Up: PEP 634 構造的パターンマッチ

1.4.2.9 Syntax and operations
.............................

The generic syntax of pattern matching is:

     match subject:
         case <pattern_1>:
             <action_1>
         case <pattern_2>:
             <action_2>
         case <pattern_3>:
             <action_3>
         case _:
             <action_wildcard>

A match statement takes an expression and compares its value to
successive patterns given as one or more case blocks.  Specifically,
pattern matching operates by:

  1. using data with type and shape (the ‘subject’)

  2. evaluating the ‘subject’ in the ‘match’ statement

  3. comparing the subject with each pattern in a ‘case’ statement from
     top to bottom until a match is confirmed.

  4. executing the action associated with the pattern of the confirmed
     match

  5. If an exact match is not confirmed, the last case, a wildcard ‘_’,
     if provided, will be used as the matching case.  If an exact match
     is not confirmed and a wildcard case does not exist, the entire
     match block is a no-op.


File: python.info,  Node: Declarative approach,  Next: Simple pattern match to a literal,  Prev: Syntax and operations,  Up: PEP 634 構造的パターンマッチ

1.4.2.10 Declarative approach
.............................

Readers may be aware of pattern matching through the simple example of
matching a subject (data object) to a literal (pattern) with the switch
statement found in C, Java or JavaScript (and many other languages).
Often the switch statement is used for comparison of an
object/expression with case statements containing literals.

More powerful examples of pattern matching can be found in languages
such as Scala and Elixir.  With structural pattern matching, the
approach is "declarative" and explicitly states the conditions (the
patterns) for data to match.

While an "imperative" series of instructions using nested "if"
statements could be used to accomplish something similar to structural
pattern matching, it is less clear than the "declarative" approach.
Instead the "declarative" approach states the conditions to meet for a
match and is more readable through its explicit patterns.  While
structural pattern matching can be used in its simplest form comparing a
variable to a literal in a case statement, its true value for Python
lies in its handling of the subject's type and shape.


File: python.info,  Node: Simple pattern match to a literal,  Next: Patterns with a literal and variable,  Prev: Declarative approach,  Up: PEP 634 構造的パターンマッチ

1.4.2.11 Simple pattern: match to a literal
...........................................

Let's look at this example as pattern matching in its simplest form: a
value, the subject, being matched to several literals, the patterns.  In
the example below, ‘status’ is the subject of the match statement.  The
patterns are each of the case statements, where literals represent
request status codes.  The associated action to the case is executed
after a match:

     def http_error(status):
         match status:
             case 400:
                 return "Bad request"
             case 404:
                 return "Not found"
             case 418:
                 return "I'm a teapot"
             case _:
                 return "Something's wrong with the internet"

If the above function is passed a ‘status’ of 418, "I'm a teapot" is
returned.  If the above function is passed a ‘status’ of 500, the case
statement with ‘_’ will match as a wildcard, and "Something's wrong with
the internet" is returned.  Note the last block: the variable name, ‘_’,
acts as a 'wildcard' and insures the subject will always match.  The use
of ‘_’ is optional.

複数のリテラルを''|'' ("or")を使用して組み合わせて1つのパターンにできま
す。

     case 401 | 403 | 404:
         return "Not allowed"

* Menu:

* Behavior without the wildcard::


File: python.info,  Node: Behavior without the wildcard,  Up: Simple pattern match to a literal

1.4.2.12 Behavior without the wildcard
......................................

If we modify the above example by removing the last case block, the
example becomes:

     def http_error(status):
         match status:
             case 400:
                 return "Bad request"
             case 404:
                 return "Not found"
             case 418:
                 return "I'm a teapot"

Without the use of ‘_’ in a case statement, a match may not exist.  If
no match exists, the behavior is a no-op.  For example, if ‘status’ of
500 is passed, a no-op occurs.


File: python.info,  Node: Patterns with a literal and variable,  Next: Patterns and classes,  Prev: Simple pattern match to a literal,  Up: PEP 634 構造的パターンマッチ

1.4.2.13 Patterns with a literal and variable
.............................................

Patterns can look like unpacking assignments, and a pattern may be used
to bind variables.  In this example, a data point can be unpacked to its
x-coordinate and y-coordinate:

     # point is an (x, y) tuple
     match point:
         case (0, 0):
             print("Origin")
         case (0, y):
             print(f"Y={y}")
         case (x, 0):
             print(f"X={x}")
         case (x, y):
             print(f"X={x}, Y={y}")
         case _:
             raise ValueError("Not a point")

The first pattern has two literals, ‘(0, 0)’, and may be thought of as
an extension of the literal pattern shown above.  The next two patterns
combine a literal and a variable, and the variable 'binds' a value from
the subject (‘point’).  The fourth pattern captures two values, which
makes it conceptually similar to the unpacking assignment ‘(x, y) =
point’.


File: python.info,  Node: Patterns and classes,  Next: Nested patterns,  Prev: Patterns with a literal and variable,  Up: PEP 634 構造的パターンマッチ

1.4.2.14 Patterns and classes
.............................

If you are using classes to structure your data, you can use as a
pattern the class name followed by an argument list resembling a
constructor.  This pattern has the ability to capture class attributes
into variables:

     class Point:
         x: int
         y: int

     def location(point):
         match point:
             case Point(x=0, y=0):
                 print("Origin is the point's location.")
             case Point(x=0, y=y):
                 print(f"Y={y} and the point is on the y-axis.")
             case Point(x=x, y=0):
                 print(f"X={x} and the point is on the x-axis.")
             case Point():
                 print("The point is located somewhere else on the plane.")
             case _:
                 print("Not a point")

* Menu:

* Patterns with positional parameters::


File: python.info,  Node: Patterns with positional parameters,  Up: Patterns and classes

1.4.2.15 Patterns with positional parameters
............................................

いくつかの組み込みクラスでは位置引数が使用でき、属性の順番を提供します
(例: データクラス)。クラスの ‘__match_args__’ 特殊属性でによって、パター
ンの中で属性の明確な位置を定義することもできます。("x", "y")が設定された
場合、以下のすべてのパターンは等価です(すべて属性 ‘y’ が ‘var’ 変数に関
連づけられます):

     Point(1, var)
     Point(1, y=var)
     Point(x=1, y=var)
     Point(y=var, x=1)


File: python.info,  Node: Nested patterns,  Next: Complex patterns and the wildcard,  Prev: Patterns and classes,  Up: PEP 634 構造的パターンマッチ

1.4.2.16 Nested patterns
........................

Patterns can be arbitrarily nested.  For example, if our data is a short
list of points, it could be matched like this:

     match points:
         case []:
             print("No points in the list.")
         case [Point(0, 0)]:
             print("The origin is the only point in the list.")
         case [Point(x, y)]:
             print(f"A single point {x}, {y} is in the list.")
         case [Point(0, y1), Point(0, y2)]:
             print(f"Two points on the Y axis at {y1}, {y2} are in the list.")
         case _:
             print("Something else is found in the list.")


File: python.info,  Node: Complex patterns and the wildcard,  Next: Guard,  Prev: Nested patterns,  Up: PEP 634 構造的パターンマッチ

1.4.2.17 Complex patterns and the wildcard
..........................................

To this point, the examples have used ‘_’ alone in the last case
statement.  A wildcard can be used in more complex patterns, such as
‘('error', code, _)’.  For example:

     match test_variable:
         case ('warning', code, 40):
             print("A warning has been received.")
         case ('error', code, _):
             print(f"An error {code} occurred.")

In the above case, ‘test_variable’ will match for ('error', code, 100)
and ('error', code, 800).


File: python.info,  Node: Guard,  Next: Other Key Features,  Prev: Complex patterns and the wildcard,  Up: PEP 634 構造的パターンマッチ

1.4.2.18 Guard
..............

パターンに ‘if’ 節を追加できます。これは "ガード" と呼ばれます。ガードが
falseの場合、‘match’ は次のcaseブロックの処理に移動します。ガードを評価
する前に値が取り出されることに注意してください:

     match point:
         case Point(x, y) if x == y:
             print(f"The point is located on the diagonal Y=X at {x}.")
         case Point(x, y):
             print(f"Point is not on the diagonal.")


File: python.info,  Node: Other Key Features,  Prev: Guard,  Up: PEP 634 構造的パターンマッチ

1.4.2.19 Other Key Features
...........................

Several other key features:

   - Like unpacking assignments, tuple and list patterns have exactly
     the same meaning and actually match arbitrary sequences.
     Technically, the subject must be a sequence.  Therefore, an
     important exception is that patterns don't match iterators.  Also,
     to prevent a common mistake, sequence patterns don't match strings.

   - Sequence patterns support wildcards: ‘[x, y, *rest]’ and ‘(x, y,
     *rest)’ work similar to wildcards in unpacking assignments.  The
     name after ‘*’ may also be ‘_’, so ‘(x, y, *_)’ matches a sequence
     of at least two items without binding the remaining items.

   - Mapping patterns: ‘{"bandwidth": b, "latency": l}’ captures the
     ‘"bandwidth"’ and ‘"latency"’ values from a dict.  Unlike sequence
     patterns, extra keys are ignored.  A wildcard ‘**rest’ is also
     supported.  (But ‘**_’ would be redundant, so is not allowed.)

   - サブパターンでは ‘as’ キーワードを使用して値を取り込みます:

          case (Point(x1, y1), Point(x2, y2) as p2): ...

     This binds x1, y1, x2, y2 like you would expect without the ‘as’
     clause, and p2 to the entire second item of the subject.

   - Most literals are compared by equality.  However, the singletons
     ‘True’, ‘False’ and ‘None’ are compared by identity.

   - Named constants may be used in patterns.  These named constants
     must be dotted names to prevent the constant from being interpreted
     as a capture variable:

          from enum import Enum
          class Color(Enum):
              RED = 0
              GREEN = 1
              BLUE = 2

          color = Color.GREEN
          match color:
              case Color.RED:
                  print("I see red!")
              case Color.GREEN:
                  print("Grass is green")
              case Color.BLUE:
                  print("I'm feeling the blues :(")

For the full specification see PEP 634(1).  Motivation and rationale are
in PEP 635(2), and a longer tutorial is in PEP 636(3).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0634/

   (2) https://peps.python.org/pep-0635/

   (3) https://peps.python.org/pep-0636/


File: python.info,  Node: Optional EncodingWarning and encoding="locale" option,  Prev: PEP 634 構造的パターンマッチ,  Up: 新しい機能<3>

1.4.2.20 Optional ‘EncodingWarning’ and ‘encoding="locale"’ option
..................................................................

The default encoding of *note TextIOWrapper: 786. and *note open(): 4e5.
is platform and locale dependent.  Since UTF-8 is used on most Unix
platforms, omitting ‘encoding’ option when opening UTF-8 files (e.g.
JSON, YAML, TOML, Markdown) is a very common bug.  For example:

     # BUG: "rb" mode or encoding="utf-8" should be used.
     with open("data.json") as f:
         data = json.load(f)

To find this type of bug, an optional ‘EncodingWarning’ is added.  It is
emitted when *note sys.flags.warn_default_encoding: 658. is true and
locale-specific default encoding is used.

‘-X warn_default_encoding’ option and *note PYTHONWARNDEFAULTENCODING:
787. are added to enable the warning.

See *note Text Encoding: 788. for more information.


File: python.info,  Node: 型ヒントに関連する新しい機能<2>,  Next: その他の言語変更<2>,  Prev: 新しい機能<3>,  Up: What's New In Python 3 10

1.4.3 型ヒントに関連する新しい機能
----------------------------------

This section covers major changes affecting PEP 484(1) type hints and
the *note typing: ed. module.

* Menu:

* PEP 604; New Type Union Operator: PEP 604 New Type Union Operator.
* PEP 612; Parameter Specification Variables: PEP 612 Parameter Specification Variables.
* PEP 613; TypeAlias: PEP 613 TypeAlias.
* PEP 647; User-Defined Type Guards: PEP 647 User-Defined Type Guards.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/


File: python.info,  Node: PEP 604 New Type Union Operator,  Next: PEP 612 Parameter Specification Variables,  Up: 型ヒントに関連する新しい機能<2>

1.4.3.1 PEP 604: New Type Union Operator
........................................

A new type union operator was introduced which enables the syntax ‘X |
Y’.  This provides a cleaner way of expressing 'either type X or type Y'
instead of using *note typing.Union: 607, especially in type hints.

In previous versions of Python, to apply a type hint for functions
accepting arguments of multiple types, *note typing.Union: 607. was
used:

     def square(number: Union[int, float]) -> Union[int, float]:
         return number ** 2

Type hints can now be written in a more succinct manner:

     def square(number: int | float) -> int | float:
         return number ** 2

This new syntax is also accepted as the second argument to *note
isinstance(): 40e. and *note issubclass(): 78c.:

     >>> isinstance(1, int | str)
     True

See *note Union 型: 78d. and PEP 604(1) for more details.

(Contributed by Maggie Moss and Philippe Prados in bpo-41428(2), with
additions by Yurii Karabas and Serhiy Storchaka in bpo-44490(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0604/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41428

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44490


File: python.info,  Node: PEP 612 Parameter Specification Variables,  Next: PEP 613 TypeAlias,  Prev: PEP 604 New Type Union Operator,  Up: 型ヒントに関連する新しい機能<2>

1.4.3.2 PEP 612: Parameter Specification Variables
..................................................

Two new options to improve the information provided to static type
checkers for PEP 484(1)'s ‘Callable’ have been added to the *note
typing: ed. module.

The first is the parameter specification variable.  They are used to
forward the parameter types of one callable to another callable - a
pattern commonly found in higher order functions and decorators.
Examples of usage can be found in *note typing.ParamSpec: 144.
Previously, there was no easy way to type annotate dependency of
parameter types in such a precise manner.

The second option is the new ‘Concatenate’ operator.  It's used in
conjunction with parameter specification variables to type annotate a
higher order callable which adds or removes parameters of another
callable.  Examples of usage can be found in *note typing.Concatenate:
78f.

See *note typing.Callable: 790, *note typing.ParamSpec: 144, *note
typing.Concatenate: 78f, *note typing.ParamSpecArgs: 791, *note
typing.ParamSpecKwargs: 792, and PEP 612(2) for more details.

(Contributed by Ken Jin in bpo-41559(3), with minor enhancements by
Jelle Zijlstra in bpo-43783(4).  PEP written by Mark Mendoza.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0612/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41559

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43783


File: python.info,  Node: PEP 613 TypeAlias,  Next: PEP 647 User-Defined Type Guards,  Prev: PEP 612 Parameter Specification Variables,  Up: 型ヒントに関連する新しい機能<2>

1.4.3.3 PEP 613: TypeAlias
..........................

PEP 484(1) introduced the concept of type aliases, only requiring them
to be top-level unannotated assignments.  This simplicity sometimes made
it difficult for type checkers to distinguish between type aliases and
ordinary assignments, especially when forward references or invalid
types were involved.  Compare:

     StrCache = 'Cache[str]'  # a type alias
     LOG_PREFIX = 'LOG[DEBUG]'  # a module constant

Now the *note typing: ed. module has a special value *note TypeAlias:
794. which lets you declare type aliases more explicitly:

     StrCache: TypeAlias = 'Cache[str]'  # a type alias
     LOG_PREFIX = 'LOG[DEBUG]'  # a module constant

より詳しくは、 PEP 613(2) をご覧ください。

(Contributed by Mikhail Golubev in bpo-41923(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0613/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41923


File: python.info,  Node: PEP 647 User-Defined Type Guards,  Prev: PEP 613 TypeAlias,  Up: 型ヒントに関連する新しい機能<2>

1.4.3.4 PEP 647: User-Defined Type Guards
.........................................

*note TypeGuard: 14a. has been added to the *note typing: ed. module to
annotate type guard functions and improve information provided to static
type checkers during type narrowing.  For more information, please see
*note TypeGuard: 14a.'s documentation, and PEP 647(1).

(Contributed by Ken Jin and Guido van Rossum in bpo-43766(2).  PEP
written by Eric Traut.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0647/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43766


File: python.info,  Node: その他の言語変更<2>,  Next: 新たなモジュール<2>,  Prev: 型ヒントに関連する新しい機能<2>,  Up: What's New In Python 3 10

1.4.4 その他の言語変更
----------------------

   * The *note int: 238. type has a new method *note int.bit_count():
     797, returning the number of ones in the binary expansion of a
     given integer, also known as the population count.  (Contributed by
     Niklas Fiekas in bpo-29882(1).)

   * The views returned by *note dict.keys(): 798, *note dict.values():
     799. and *note dict.items(): 79a. now all have a ‘mapping’
     attribute that gives a *note types.MappingProxyType: 43a. object
     wrapping the original dictionary.  (Contributed by Dennis Sweeney
     in bpo-40890(2).)

   * PEP 618(3): The *note zip(): 79b. function now has an optional
     ‘strict’ flag, used to require that all the iterables have an equal
     length.

   * Builtin and extension functions that take integer arguments no
     longer accept *note Decimal: 27d.s, *note Fraction: 1c8.s and other
     objects that can be converted to integers only with a loss (e.g.
     that have the *note __int__(): 6e7. method but do not have the
     *note __index__(): 6e8. method).  (Contributed by Serhiy Storchaka
     in bpo-37999(4).)

   * If *note object.__ipow__(): 79c. returns *note NotImplemented: 79d,
     the operator will correctly fall back to *note object.__pow__():
     79e. and *note object.__rpow__(): 79f. as expected.  (Contributed
     by Alex Shkop in bpo-38302(5).)

   * Assignment expressions can now be used unparenthesized within set
     literals and set comprehensions, as well as in sequence indexes
     (but not slices).

   * Functions have a new ‘__builtins__’ attribute which is used to look
     for builtin symbols when a function is executed, instead of looking
     into ‘__globals__['__builtins__']’.  The attribute is initialized
     from ‘__globals__["__builtins__"]’ if it exists, else from the
     current builtins.  (Contributed by Mark Shannon in bpo-42990(6).)

   * Two new builtin functions - *note aiter(): 7a0. and *note anext():
     7a1. have been added to provide asynchronous counterparts to *note
     iter(): 7a2. and *note next(): 7a3, respectively.  (Contributed by
     Joshua Bronson, Daniel Pope, and Justin Wang in bpo-31861(7).)

   * Static methods (*note @staticmethod: 3ef.) and class methods (*note
     @classmethod: 14c.) now inherit the method attributes
     (‘__module__’, ‘__name__’, ‘__qualname__’, ‘__doc__’,
     ‘__annotations__’) and have a new ‘__wrapped__’ attribute.
     Moreover, static methods are now callable as regular functions.
     (Contributed by Victor Stinner in bpo-43682(8).)

   * Annotations for complex targets (everything beside ‘simple name’
     targets defined by PEP 526(9)) no longer cause any runtime effects
     with ‘from __future__ import annotations’.  (Contributed by Batuhan
     Taskaya in bpo-42737(10).)

   * Class and module objects now lazy-create empty annotations dicts on
     demand.  The annotations dicts are stored in the object’s
     ‘__dict__’ for backwards compatibility.  This improves the best
     practices for working with ‘__annotations__’; for more information,
     please see *note Annotations Best Practices: 7a4.  (Contributed by
     Larry Hastings in bpo-43901(11).)

   * Annotations consist of ‘yield’, ‘yield from’, ‘await’ or named
     expressions are now forbidden under ‘from __future__ import
     annotations’ due to their side effects.  (Contributed by Batuhan
     Taskaya in bpo-42725(12).)

   * Usage of unbound variables, ‘super()’ and other expressions that
     might alter the processing of symbol table as annotations are now
     rendered effectless under ‘from __future__ import annotations’.
     (Contributed by Batuhan Taskaya in bpo-42725(13).)

   * Hashes of NaN values of both *note float: 2ce. type and *note
     decimal.Decimal: 27d. type now depend on object identity.
     Formerly, they always hashed to ‘0’ even though NaN values are not
     equal to one another.  This caused potentially quadratic runtime
     behavior due to excessive hash collisions when creating
     dictionaries and sets containing multiple NaNs.  (Contributed by
     Raymond Hettinger in bpo-43475(14).)

   * A *note SyntaxError: 172. (instead of a *note NameError: 40b.) will
     be raised when deleting the *note __debug__: 7a5. constant.
     (Contributed by Donghee Na in bpo-45000(15).)

   * *note SyntaxError: 172. exceptions now have ‘end_lineno’ and
     ‘end_offset’ attributes.  They will be ‘None’ if not determined.
     (Contributed by Pablo Galindo in bpo-43914(16).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29882

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40890

   (3) https://peps.python.org/pep-0618/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37999

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38302

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42990

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31861

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43682

   (9) https://peps.python.org/pep-0526/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42737

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43901

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42725

   (13) https://bugs.python.org/issue?@action=redirect&bpo=42725

   (14) https://bugs.python.org/issue?@action=redirect&bpo=43475

   (15) https://bugs.python.org/issue?@action=redirect&bpo=45000

   (16) https://bugs.python.org/issue?@action=redirect&bpo=43914


File: python.info,  Node: 新たなモジュール<2>,  Next: 改良されたモジュール<2>,  Prev: その他の言語変更<2>,  Up: What's New In Python 3 10

1.4.5 新たなモジュール
----------------------

   * None.


File: python.info,  Node: 改良されたモジュール<2>,  Next: 最適化<2>,  Prev: 新たなモジュール<2>,  Up: What's New In Python 3 10

1.4.6 改良されたモジュール
--------------------------

* Menu:

* asyncio: asyncio<4>.
* argparse: argparse<2>.
* array: array<3>.
* asynchat, asyncore, smtpd: asynchat asyncore smtpd.
* base64: base64<2>.
* bdb::
* bisect::
* codecs::
* collections.abc: collections abc.
* contextlib: contextlib<2>.
* curses::
* データクラス: データクラス<2>.
* distutils: distutils<2>.
* doctest: doctest<2>.
* エンコーディング::
* enum: enum<3>.
* fileinput::
* faulthandler::
* gc::
* glob: glob<2>.
* hashlib: hashlib<3>.
* hmac::
* IDLE と idelelib: IDLE と idelelib<2>.
* importlib.metadata: importlib metadata<2>.
* inspect: inspect<3>.
* itertools: itertools<3>.
* linecache::
* os: os<4>.
* os.path: os path<3>.
* pathlib: pathlib<5>.
* プラットフォーム::
* pprint::
* py_compile::
* pyclbr::
* shelve::
* statistics: statistics<3>.
* site: site<2>.
* socket: socket<2>.
* ssl: ssl<3>.
* sqlite3: sqlite3<5>.
* sys: sys<5>.
* _thread::
* threading: threading<3>.
* traceback: traceback<3>.
* types: types<3>.
* typing: typing<5>.
* unittest: unittest<5>.
* urllib.parse: urllib parse.
* xml: xml<2>.
* zipimport: zipimport<3>.


File: python.info,  Node: asyncio<4>,  Next: argparse<2>,  Up: 改良されたモジュール<2>

1.4.6.1 asyncio
...............

Add missing ‘connect_accepted_socket()’ method.  (Contributed by Alex
Grönholm in bpo-41332(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41332


File: python.info,  Node: argparse<2>,  Next: array<3>,  Prev: asyncio<4>,  Up: 改良されたモジュール<2>

1.4.6.2 argparse
................

Misleading phrase "optional arguments" was replaced with "options" in
argparse help.  Some tests might require adaptation if they rely on
exact output match.  (Contributed by Raymond Hettinger in bpo-9694(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9694


File: python.info,  Node: array<3>,  Next: asynchat asyncore smtpd,  Prev: argparse<2>,  Up: 改良されたモジュール<2>

1.4.6.3 array
.............

The *note index(): 7ab. method of *note array.array: 185. now has
optional 'start' and 'stop' parameters.  (Contributed by Anders
Lorentsen and Zackery Spytz in bpo-31956(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31956


File: python.info,  Node: asynchat asyncore smtpd,  Next: base64<2>,  Prev: array<3>,  Up: 改良されたモジュール<2>

1.4.6.4 asynchat, asyncore, smtpd
.................................

These modules have been marked as deprecated in their module
documentation since Python 3.6.  An import-time *note
DeprecationWarning: 18a. has now been added to all three of these
modules.


File: python.info,  Node: base64<2>,  Next: bdb,  Prev: asynchat asyncore smtpd,  Up: 改良されたモジュール<2>

1.4.6.5 base64
..............

Add *note base64.b32hexencode(): 7ae. and *note base64.b32hexdecode():
7af. to support the Base32 Encoding with Extended Hex Alphabet.


File: python.info,  Node: bdb,  Next: bisect,  Prev: base64<2>,  Up: 改良されたモジュール<2>

1.4.6.6 bdb
...........

Add ‘clearBreakpoints()’ to reset all set breakpoints.  (Contributed by
Irit Katriel in bpo-24160(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24160


File: python.info,  Node: bisect,  Next: codecs,  Prev: bdb,  Up: 改良されたモジュール<2>

1.4.6.7 bisect
..............

Added the possibility of providing a 'key' function to the APIs in the
*note bisect: d. module.  (Contributed by Raymond Hettinger in
bpo-4356(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4356


File: python.info,  Node: codecs,  Next: collections abc,  Prev: bisect,  Up: 改良されたモジュール<2>

1.4.6.8 codecs
..............

Add a *note codecs.unregister(): 7b3. function to unregister a codec
search function.  (Contributed by Hai Shi in bpo-41842(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41842


File: python.info,  Node: collections abc,  Next: contextlib<2>,  Prev: codecs,  Up: 改良されたモジュール<2>

1.4.6.9 collections.abc
.......................

The ‘__args__’ of the *note parameterized generic: 67e. for *note
collections.abc.Callable: 7b5. are now consistent with *note
typing.Callable: 790.  *note collections.abc.Callable: 7b5. generic now
flattens type parameters, similar to what *note typing.Callable: 790.
currently does.  This means that ‘collections.abc.Callable[[int, str],
str]’ will have ‘__args__’ of ‘(int, str, str)’; previously this was
‘([int, str], str)’.  To allow this change, *note types.GenericAlias:
7b6. can now be subclassed, and a subclass will be returned when
subscripting the *note collections.abc.Callable: 7b5. type.  Note that a
*note TypeError: 502. may be raised for invalid forms of parameterizing
*note collections.abc.Callable: 7b5. which may have passed silently in
Python 3.9.  (Contributed by Ken Jin in bpo-42195(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42195


File: python.info,  Node: contextlib<2>,  Next: curses,  Prev: collections abc,  Up: 改良されたモジュール<2>

1.4.6.10 contextlib
...................

Add a *note contextlib.aclosing(): 7b8. context manager to safely close
async generators and objects representing asynchronously released
resources.  (Contributed by Joongi Kim and John Belmonte in
bpo-41229(1).)

Add asynchronous context manager support to *note
contextlib.nullcontext(): 7b9.  (Contributed by Tom Gringauz in
bpo-41543(2).)

Add *note AsyncContextDecorator: 7ba, for supporting usage of async
context managers as decorators.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41229

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41543


File: python.info,  Node: curses,  Next: データクラス<2>,  Prev: contextlib<2>,  Up: 改良されたモジュール<2>

1.4.6.11 curses
...............

The extended color functions added in ncurses 6.1 will be used
transparently by *note curses.color_content(): 7bc, *note
curses.init_color(): 7bd, *note curses.init_pair(): 7be, and *note
curses.pair_content(): 7bf.  A new function, *note
curses.has_extended_color_support(): 7c0, indicates whether extended
color support is provided by the underlying ncurses library.
(Contributed by Jeffrey Kintscher and Hans Petter Jansson in
bpo-36982(1).)

The ‘BUTTON5_*’ constants are now exposed in the *note curses: 23.
module if they are provided by the underlying curses library.
(Contributed by Zackery Spytz in bpo-39273(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36982

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39273


File: python.info,  Node: データクラス<2>,  Next: distutils<2>,  Prev: curses,  Up: 改良されたモジュール<2>

1.4.6.12 データクラス
.....................

* Menu:

* __slots__::
* Keyword-only fields::


File: python.info,  Node: __slots__,  Next: Keyword-only fields,  Up: データクラス<2>

1.4.6.13 __slots__
..................

Added ‘slots’ parameter in *note dataclasses.dataclass(): 1ad.
decorator.  (Contributed by Yurii Karabas in bpo-42269(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42269


File: python.info,  Node: Keyword-only fields,  Prev: __slots__,  Up: データクラス<2>

1.4.6.14 Keyword-only fields
............................

dataclasses now supports fields that are keyword-only in the generated
__init__ method.  There are a number of ways of specifying keyword-only
fields.

You can say that every field is keyword-only:

     from dataclasses import dataclass

     @dataclass(kw_only=True)
     class Birthday:
         name: str
         birthday: datetime.date

Both ‘name’ and ‘birthday’ are keyword-only parameters to the generated
__init__ method.

You can specify keyword-only on a per-field basis:

     from dataclasses import dataclass, field

     @dataclass
     class Birthday:
         name: str
         birthday: datetime.date = field(kw_only=True)

Here only ‘birthday’ is keyword-only.  If you set ‘kw_only’ on
individual fields, be aware that there are rules about re-ordering
fields due to keyword-only fields needing to follow non-keyword-only
fields.  See the full dataclasses documentation for details.

You can also specify that all fields following a KW_ONLY marker are
keyword-only.  This will probably be the most common usage:

     from dataclasses import dataclass, KW_ONLY

     @dataclass
     class Point:
         x: float
         y: float
         _: KW_ONLY
         z: float = 0.0
         t: float = 0.0

Here, ‘z’ and ‘t’ are keyword-only parameters, while ‘x’ and ‘y’ are
not.  (Contributed by Eric V. Smith in bpo-43532(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43532


File: python.info,  Node: distutils<2>,  Next: doctest<2>,  Prev: データクラス<2>,  Up: 改良されたモジュール<2>

1.4.6.15 distutils
..................

The entire ‘distutils’ package is deprecated, to be removed in Python
3.12.  Its functionality for specifying package builds has already been
completely replaced by third-party packages ‘setuptools’ and
‘packaging’, and most other commonly used APIs are available elsewhere
in the standard library (such as *note platform: 98, *note shutil: b3,
*note subprocess: c1. or *note sysconfig: c5.).  There are no plans to
migrate any other functionality from ‘distutils’, and applications that
are using other functions should plan to make private copies of the
code.  Refer to PEP 632(1) for discussion.

The ‘bdist_wininst’ command deprecated in Python 3.8 has been removed.
The ‘bdist_wheel’ command is now recommended to distribute binary
packages on Windows.  (Contributed by Victor Stinner in bpo-42802(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0632/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42802


File: python.info,  Node: doctest<2>,  Next: エンコーディング,  Prev: distutils<2>,  Up: 改良されたモジュール<2>

1.4.6.16 doctest
................

When a module does not define ‘__loader__’, fall back to
‘__spec__.loader’.  (Contributed by Brett Cannon in bpo-42133(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42133


File: python.info,  Node: エンコーディング,  Next: enum<3>,  Prev: doctest<2>,  Up: 改良されたモジュール<2>

1.4.6.17 エンコーディング
.........................

‘encodings.normalize_encoding()’ now ignores non-ASCII characters.
(Contributed by Hai Shi in bpo-39337(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39337


File: python.info,  Node: enum<3>,  Next: fileinput,  Prev: エンコーディング,  Up: 改良されたモジュール<2>

1.4.6.18 enum
.............

*note Enum: 5fc. *note __repr__(): 5e8. now returns
‘enum_name.member_name’ and *note __str__(): 5e9. now returns
‘member_name’.  Stdlib enums available as module constants have a *note
repr(): 7c8. of ‘module_name.member_name’.  (Contributed by Ethan Furman
in bpo-40066(1).)

Add *note enum.StrEnum: 5e6. for enums where all members are strings.
(Contributed by Ethan Furman in bpo-41816(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40066

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41816


File: python.info,  Node: fileinput,  Next: faulthandler,  Prev: enum<3>,  Up: 改良されたモジュール<2>

1.4.6.19 fileinput
..................

Add 'encoding' and 'errors' parameters in *note fileinput.input(): 7ca.
and *note fileinput.FileInput: 702.  (Contributed by Inada Naoki in
bpo-43712(1).)

*note fileinput.hook_compressed(): 7cb. now returns *note TextIOWrapper:
786. object when 'mode' is "r" and file is compressed, like uncompressed
files.  (Contributed by Inada Naoki in bpo-5758(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43712

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5758


File: python.info,  Node: faulthandler,  Next: gc,  Prev: fileinput,  Up: 改良されたモジュール<2>

1.4.6.20 faulthandler
.....................

The *note faulthandler: 4e. module now detects if a fatal error occurs
during a garbage collector collection.  (Contributed by Victor Stinner
in bpo-44466(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44466


File: python.info,  Node: gc,  Next: glob<2>,  Prev: faulthandler,  Up: 改良されたモジュール<2>

1.4.6.21 gc
...........

Add audit hooks for *note gc.get_objects(): 7ce, *note
gc.get_referrers(): 7cf. and *note gc.get_referents(): 7d0.
(Contributed by Pablo Galindo in bpo-43439(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43439


File: python.info,  Node: glob<2>,  Next: hashlib<3>,  Prev: gc,  Up: 改良されたモジュール<2>

1.4.6.22 glob
.............

Add the 'root_dir' and 'dir_fd' parameters in *note glob(): 27f. and
*note iglob(): 7d2. which allow to specify the root directory for
searching.  (Contributed by Serhiy Storchaka in bpo-38144(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38144


File: python.info,  Node: hashlib<3>,  Next: hmac,  Prev: glob<2>,  Up: 改良されたモジュール<2>

1.4.6.23 hashlib
................

The hashlib module requires OpenSSL 1.1.1 or newer.  (Contributed by
Christian Heimes in PEP 644(1) and bpo-43669(2).)

The hashlib module has preliminary support for OpenSSL 3.0.0.
(Contributed by Christian Heimes in bpo-38820(3) and other issues.)

The pure-Python fallback of *note pbkdf2_hmac(): 4d9. is deprecated.  In
the future PBKDF2-HMAC will only be available when Python has been built
with OpenSSL support.  (Contributed by Christian Heimes in
bpo-43880(4).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0644/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43669

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38820

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43880


File: python.info,  Node: hmac,  Next: IDLE と idelelib<2>,  Prev: hashlib<3>,  Up: 改良されたモジュール<2>

1.4.6.24 hmac
.............

The hmac module now uses OpenSSL's HMAC implementation internally.
(Contributed by Christian Heimes in bpo-40645(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40645


File: python.info,  Node: IDLE と idelelib<2>,  Next: importlib metadata<2>,  Prev: hmac,  Up: 改良されたモジュール<2>

1.4.6.25 IDLE と idelelib
.........................

Make IDLE invoke *note sys.excepthook(): 7d6. (when started without
'-n').  User hooks were previously ignored.  (Contributed by Ken Hilton
in bpo-43008(1).)

Rearrange the settings dialog.  Split the General tab into Windows and
Shell/Ed tabs.  Move help sources, which extend the Help menu, to the
Extensions tab.  Make space for new options and shorten the dialog.  The
latter makes the dialog better fit small screens.  (Contributed by Terry
Jan Reedy in bpo-40468(2).)  Move the indent space setting from the Font
tab to the new Windows tab.  (Contributed by Mark Roseman and Terry Jan
Reedy in bpo-33962(3).)

The changes above were backported to a 3.9 maintenance release.

Add a Shell sidebar.  Move the primary prompt ('>>>') to the sidebar.
Add secondary prompts ('...')  to the sidebar.  Left click and optional
drag selects one or more lines of text, as with the editor line number
sidebar.  Right click after selecting text lines displays a context menu
with 'copy with prompts'.  This zips together prompts from the sidebar
with lines from the selected text.  This option also appears on the
context menu for the text.  (Contributed by Tal Einat in bpo-37903(4).)

Use spaces instead of tabs to indent interactive code.  This makes
interactive code entries 'look right'.  Making this feasible was a major
motivation for adding the shell sidebar.  (Contributed by Terry Jan
Reedy in bpo-37892(5).)

Highlight the new *note soft keywords: 7d7. *note match: 7d8, *note
case: 7d8, and *note _: 7d9. in pattern-matching statements.  However,
this highlighting is not perfect and will be incorrect in some rare
cases, including some ‘_’-s in ‘case’ patterns.  (Contributed by Tal
Einat in bpo-44010(6).)

New in 3.10 maintenance releases.

Apply syntax highlighting to ‘.pyi’ files.  (Contributed by Alex Waygood
and Terry Jan Reedy in bpo-45447(7).)

Include prompts when saving Shell with inputs and outputs.  (Contributed
by Terry Jan Reedy in gh-95191(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43008

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40468

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33962

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37903

   (5) https://bugs.python.org/issue?@action=redirect&bpo=37892

   (6) https://bugs.python.org/issue?@action=redirect&bpo=44010

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45447

   (8) https://github.com/python/cpython/issues/95191


File: python.info,  Node: importlib metadata<2>,  Next: inspect<3>,  Prev: IDLE と idelelib<2>,  Up: 改良されたモジュール<2>

1.4.6.26 importlib.metadata
...........................

Feature parity with ‘importlib_metadata’ 4.6 (history(1)).

*note importlib.metadata entry points: 265. now provide a nicer
experience for selecting entry points by group and name through a new
*note importlib.metadata.EntryPoints: 265. class.  See the Compatibility
Note in the docs for more info on the deprecation and usage.

Added *note importlib.metadata.packages_distributions(): 7db. for
resolving top-level Python modules and packages to their *note
importlib.metadata.Distribution: 7dc.

   ---------- Footnotes ----------

   (1) https://importlib-metadata.readthedocs.io/en/latest/history.html


File: python.info,  Node: inspect<3>,  Next: itertools<3>,  Prev: importlib metadata<2>,  Up: 改良されたモジュール<2>

1.4.6.27 inspect
................

When a module does not define ‘__loader__’, fall back to
‘__spec__.loader’.  (Contributed by Brett Cannon in bpo-42133(1).)

Add *note inspect.get_annotations(): 7de, which safely computes the
annotations defined on an object.  It works around the quirks of
accessing the annotations on various types of objects, and makes very
few assumptions about the object it examines.  *note
inspect.get_annotations(): 7de. can also correctly un-stringize
stringized annotations.  *note inspect.get_annotations(): 7de. is now
considered best practice for accessing the annotations dict defined on
any Python object; for more information on best practices for working
with annotations, please see *note Annotations Best Practices: 7a4.
Relatedly, *note inspect.signature(): 703, *note
inspect.Signature.from_callable(): 705, and
‘inspect.Signature.from_function()’ now call *note
inspect.get_annotations(): 7de. to retrieve annotations.  This means
*note inspect.signature(): 703. and *note
inspect.Signature.from_callable(): 705. can also now un-stringize
stringized annotations.  (Contributed by Larry Hastings in
bpo-43817(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42133

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43817


File: python.info,  Node: itertools<3>,  Next: linecache,  Prev: inspect<3>,  Up: 改良されたモジュール<2>

1.4.6.28 itertools
..................

Add *note itertools.pairwise(): 7e0.  (Contributed by Raymond Hettinger
in bpo-38200(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38200


File: python.info,  Node: linecache,  Next: os<4>,  Prev: itertools<3>,  Up: 改良されたモジュール<2>

1.4.6.29 linecache
..................

When a module does not define ‘__loader__’, fall back to
‘__spec__.loader’.  (Contributed by Brett Cannon in bpo-42133(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42133


File: python.info,  Node: os<4>,  Next: os path<3>,  Prev: linecache,  Up: 改良されたモジュール<2>

1.4.6.30 os
...........

Add *note os.cpu_count(): 1a7. support for VxWorks RTOS. (Contributed by
Peixing Xin in bpo-41440(1).)

Add a new function *note os.eventfd(): 7e3. and related helpers to wrap
the ‘eventfd2’ syscall on Linux.  (Contributed by Christian Heimes in
bpo-41001(2).)

Add *note os.splice(): 7e4. that allows to move data between two file
descriptors without copying between kernel address space and user
address space, where one of the file descriptors must refer to a pipe.
(Contributed by Pablo Galindo in bpo-41625(3).)

Add *note O_EVTONLY: 7e5, *note O_FSYNC: 7e6, *note O_SYMLINK: 7e7. and
*note O_NOFOLLOW_ANY: 7e8. for macOS. (Contributed by Donghee Na in
bpo-43106(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41440

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41001

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41625

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43106


File: python.info,  Node: os path<3>,  Next: pathlib<5>,  Prev: os<4>,  Up: 改良されたモジュール<2>

1.4.6.31 os.path
................

*note os.path.realpath(): 206. now accepts a 'strict' keyword-only
argument.  When set to ‘True’, *note OSError: 3f0. is raised if a path
doesn't exist or a symlink loop is encountered.  (Contributed by Barney
Gale in bpo-43757(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43757


File: python.info,  Node: pathlib<5>,  Next: プラットフォーム,  Prev: os path<3>,  Up: 改良されたモジュール<2>

1.4.6.32 pathlib
................

Add slice support to *note PurePath.parents: 7eb.  (Contributed by
Joshua Cannon in bpo-35498(1).)

Add negative indexing support to *note PurePath.parents: 7eb.
(Contributed by Yaroslav Pankovych in bpo-21041(2).)

Add *note Path.hardlink_to: 7ec. method that supersedes ‘link_to()’.
The new method has the same argument order as *note symlink_to(): 7ed.
(Contributed by Barney Gale in bpo-39950(3).)

*note pathlib.Path.stat(): 7ee. and *note chmod(): 7ef. now accept a
'follow_symlinks' keyword-only argument for consistency with
corresponding functions in the *note os: 91. module.  (Contributed by
Barney Gale in bpo-39906(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35498

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21041

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39950

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39906


File: python.info,  Node: プラットフォーム,  Next: pprint,  Prev: pathlib<5>,  Up: 改良されたモジュール<2>

1.4.6.33 プラットフォーム
.........................

Add *note platform.freedesktop_os_release(): 7f1. to retrieve operation
system identification from freedesktop.org os-release(1) standard file.
(Contributed by Christian Heimes in bpo-28468(2).)

   ---------- Footnotes ----------

   (1) https://www.freedesktop.org/software/systemd/man/os-release.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28468


File: python.info,  Node: pprint,  Next: py_compile,  Prev: プラットフォーム,  Up: 改良されたモジュール<2>

1.4.6.34 pprint
...............

*note pprint.pprint(): 7f3. now accepts a new ‘underscore_numbers’
keyword argument.  (Contributed by sblondon in bpo-42914(1).)

*note pprint: 9c. can now pretty-print *note dataclasses.dataclass: 1ad.
instances.  (Contributed by Lewis Gaul in bpo-43080(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42914

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43080


File: python.info,  Node: py_compile,  Next: pyclbr,  Prev: pprint,  Up: 改良されたモジュール<2>

1.4.6.35 py_compile
...................

Add ‘--quiet’ option to command-line interface of *note py_compile: a1.
(Contributed by Gregory Schevchenko in bpo-38731(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38731


File: python.info,  Node: pyclbr,  Next: shelve,  Prev: py_compile,  Up: 改良されたモジュール<2>

1.4.6.36 pyclbr
...............

Add an ‘end_lineno’ attribute to the ‘Function’ and ‘Class’ objects in
the tree returned by *note pyclbr.readmodule(): 7f6. and *note
pyclbr.readmodule_ex(): 7f7.  It matches the existing (start) ‘lineno’.
(Contributed by Aviral Srivastava in bpo-38307(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38307


File: python.info,  Node: shelve,  Next: statistics<3>,  Prev: pyclbr,  Up: 改良されたモジュール<2>

1.4.6.37 shelve
...............

The *note shelve: b1. module now uses *note pickle.DEFAULT_PROTOCOL:
7f9. by default instead of *note pickle: 95. protocol ‘3’ when creating
shelves.  (Contributed by Zackery Spytz in bpo-34204(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34204


File: python.info,  Node: statistics<3>,  Next: site<2>,  Prev: shelve,  Up: 改良されたモジュール<2>

1.4.6.38 statistics
...................

Add *note covariance(): 7fb, Pearson's *note correlation(): 488, and
simple *note linear_regression(): 7fc. functions.  (Contributed by
Tymoteusz Wołodźko in bpo-38490(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38490


File: python.info,  Node: site<2>,  Next: socket<2>,  Prev: statistics<3>,  Up: 改良されたモジュール<2>

1.4.6.39 site
.............

When a module does not define ‘__loader__’, fall back to
‘__spec__.loader’.  (Contributed by Brett Cannon in bpo-42133(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42133


File: python.info,  Node: socket<2>,  Next: ssl<3>,  Prev: site<2>,  Up: 改良されたモジュール<2>

1.4.6.40 socket
...............

The exception *note socket.timeout: 7ff. is now an alias of *note
TimeoutError: 800.  (Contributed by Christian Heimes in bpo-42413(1).)

Add option to create MPTCP sockets with ‘IPPROTO_MPTCP’ (Contributed by
Rui Cunha in bpo-43571(2).)

Add ‘IP_RECVTOS’ option to receive the type of service (ToS) or DSCP/ECN
fields (Contributed by Georg Sauthoff in bpo-44077(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42413

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43571

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44077


File: python.info,  Node: ssl<3>,  Next: sqlite3<5>,  Prev: socket<2>,  Up: 改良されたモジュール<2>

1.4.6.41 ssl
............

The ssl module requires OpenSSL 1.1.1 or newer.  (Contributed by
Christian Heimes in PEP 644(1) and bpo-43669(2).)

The ssl module has preliminary support for OpenSSL 3.0.0 and new option
*note OP_IGNORE_UNEXPECTED_EOF: 802.  (Contributed by Christian Heimes
in bpo-38820(3), bpo-43794(4), bpo-43788(5), bpo-43791(6), bpo-43799(7),
bpo-43920(8), bpo-43789(9), and bpo-43811(10).)

Deprecated function and use of deprecated constants now result in a
*note DeprecationWarning: 18a.  *note ssl.SSLContext.options: 803. has
*note OP_NO_SSLv2: 804. and *note OP_NO_SSLv3: 805. set by default and
therefore cannot warn about setting the flag again.  The *note
deprecation section: 806. has a list of deprecated features.
(Contributed by Christian Heimes in bpo-43880(11).)

The ssl module now has more secure default settings.  Ciphers without
forward secrecy or SHA-1 MAC are disabled by default.  Security level 2
prohibits weak RSA, DH, and ECC keys with less than 112 bits of
security.  *note SSLContext: 274. defaults to minimum protocol version
TLS 1.2.  Settings are based on Hynek Schlawack's research.
(Contributed by Christian Heimes in bpo-43998(12).)

The deprecated protocols SSL 3.0, TLS 1.0, and TLS 1.1 are no longer
officially supported.  Python does not block them actively.  However
OpenSSL build options, distro configurations, vendor patches, and cipher
suites may prevent a successful handshake.

Add a 'timeout' parameter to the *note ssl.get_server_certificate():
807. function.  (Contributed by Zackery Spytz in bpo-31870(13).)

The ssl module uses heap-types and multi-phase initialization.
(Contributed by Christian Heimes in bpo-42333(14).)

A new verify flag *note VERIFY_X509_PARTIAL_CHAIN: 13c. has been added.
(Contributed by l0x in bpo-40849(15).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0644/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43669

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38820

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43794

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43788

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43791

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43799

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43920

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43789

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43811

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43880

   (12) https://bugs.python.org/issue?@action=redirect&bpo=43998

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31870

   (14) https://bugs.python.org/issue?@action=redirect&bpo=42333

   (15) https://bugs.python.org/issue?@action=redirect&bpo=40849


File: python.info,  Node: sqlite3<5>,  Next: sys<5>,  Prev: ssl<3>,  Up: 改良されたモジュール<2>

1.4.6.42 sqlite3
................

Add audit events for ‘connect/handle()’, *note enable_load_extension():
809, and *note load_extension(): 484.  (Contributed by Erlend E. Aasland
in bpo-43762(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43762


File: python.info,  Node: sys<5>,  Next: _thread,  Prev: sqlite3<5>,  Up: 改良されたモジュール<2>

1.4.6.43 sys
............

Add *note sys.orig_argv: 80b. attribute: the list of the original
command line arguments passed to the Python executable.  (Contributed by
Victor Stinner in bpo-23427(1).)

Add *note sys.stdlib_module_names: 80c, containing the list of the
standard library module names.  (Contributed by Victor Stinner in
bpo-42955(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23427

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42955


File: python.info,  Node: _thread,  Next: threading<3>,  Prev: sys<5>,  Up: 改良されたモジュール<2>

1.4.6.44 _thread
................

*note _thread.interrupt_main(): 80e. now takes an optional signal number
to simulate (the default is still *note signal.SIGINT: 80f.).
(Contributed by Antoine Pitrou in bpo-43356(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43356


File: python.info,  Node: threading<3>,  Next: traceback<3>,  Prev: _thread,  Up: 改良されたモジュール<2>

1.4.6.45 threading
..................

Add *note threading.gettrace(): 811. and *note threading.getprofile():
812. to retrieve the functions set by *note threading.settrace(): 813.
and *note threading.setprofile(): 814. respectively.  (Contributed by
Mario Corchero in bpo-42251(1).)

Add *note threading.__excepthook__: 815. to allow retrieving the
original value of *note threading.excepthook(): 816. in case it is set
to a broken or a different value.  (Contributed by Mario Corchero in
bpo-42308(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42251

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42308


File: python.info,  Node: traceback<3>,  Next: types<3>,  Prev: threading<3>,  Up: 改良されたモジュール<2>

1.4.6.46 traceback
..................

The *note format_exception(): 818, *note format_exception_only(): 819,
and *note print_exception(): 81a. functions can now take an exception
object as a positional-only argument.  (Contributed by Zackery Spytz and
Matthias Bussonnier in bpo-26389(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26389


File: python.info,  Node: types<3>,  Next: typing<5>,  Prev: traceback<3>,  Up: 改良されたモジュール<2>

1.4.6.47 types
..............

Reintroduce the *note types.EllipsisType: 81c, *note types.NoneType:
81d. and *note types.NotImplementedType: 81e. classes, providing a new
set of types readily interpretable by type checkers.  (Contributed by
Bas van Beek in bpo-41810(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41810


File: python.info,  Node: typing<5>,  Next: unittest<5>,  Prev: types<3>,  Up: 改良されたモジュール<2>

1.4.6.48 typing
...............

For major changes, see *note 型ヒントに関連する新しい機能: 789.

The behavior of *note typing.Literal: 820. was changed to conform with
PEP 586(1) and to match the behavior of static type checkers specified
in the PEP.

  1. ‘Literal’ now de-duplicates parameters.

  2. Equality comparisons between ‘Literal’ objects are now order
     independent.

  3. ‘Literal’ comparisons now respect types.  For example, ‘Literal[0]
     == Literal[False]’ previously evaluated to ‘True’.  It is now
     ‘False’.  To support this change, the internally used type cache
     now supports differentiating types.

  4. ‘Literal’ objects will now raise a *note TypeError: 502. exception
     during equality comparisons if any of their parameters are not
     *note hashable: 5db.  Note that declaring ‘Literal’ with unhashable
     parameters will not throw an error:

          >>> from typing import Literal
          >>> Literal[{0}]
          >>> Literal[{0}] == Literal[{False}]
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          TypeError: unhashable type: 'set'

(bpo-42345(2) でのYurii Karabasの貢献による)

Add new function *note typing.is_typeddict(): 821. to introspect if an
annotation is a *note typing.TypedDict: 148.  (Contributed by Patrick
Reader in bpo-41792(3).)

Subclasses of ‘typing.Protocol’ which only have data variables declared
will now raise a ‘TypeError’ when checked with ‘isinstance’ unless they
are decorated with *note runtime_checkable(): 40f.  Previously, these
checks passed silently.  Users should decorate their subclasses with the
‘runtime_checkable()’ decorator if they want runtime protocols.
(Contributed by Yurii Karabas in bpo-38908(4).)

Importing from the ‘typing.io’ and ‘typing.re’ submodules will now emit
*note DeprecationWarning: 18a.  These submodules have been deprecated
since Python 3.8 and will be removed in a future version of Python.
Anything belonging to those submodules should be imported directly from
*note typing: ed. instead.  (Contributed by Sebastian Rittau in
bpo-38291(5).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0586/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42345

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41792

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38908

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38291


File: python.info,  Node: unittest<5>,  Next: urllib parse,  Prev: typing<5>,  Up: 改良されたモジュール<2>

1.4.6.49 unittest
.................

Add new method *note assertNoLogs(): 823. to complement the existing
*note assertLogs(): 824.  (Contributed by Kit Yan Choi in bpo-39385(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39385


File: python.info,  Node: urllib parse,  Next: xml<2>,  Prev: unittest<5>,  Up: 改良されたモジュール<2>

1.4.6.50 urllib.parse
.....................

Python versions earlier than Python 3.10 allowed using both ‘;’ and ‘&’
as query parameter separators in *note urllib.parse.parse_qs(): 25b. and
*note urllib.parse.parse_qsl(): 25a.  Due to security concerns, and to
conform with newer W3C recommendations, this has been changed to allow
only a single separator key, with ‘&’ as the default.  This change also
affects ‘cgi.parse()’ and ‘cgi.parse_multipart()’ as they use the
affected functions internally.  For more details, please see their
respective documentation.  (Contributed by Adam Goldschmidt, Senthil
Kumaran and Ken Jin in bpo-42967(1).)

The presence of newline or tab characters in parts of a URL allows for
some forms of attacks.  Following the WHATWG specification that updates
RFC 3986(2), ASCII newline ‘\n’, ‘\r’ and tab ‘\t’ characters are
stripped from the URL by the parser in *note urllib.parse: f3.
preventing such attacks.  The removal characters are controlled by a new
module level variable ‘urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE’.  (See
gh-88048(3))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42967

   (2) https://datatracker.ietf.org/doc/html/rfc3986.html

   (3) https://github.com/python/cpython/issues/88048


File: python.info,  Node: xml<2>,  Next: zipimport<3>,  Prev: urllib parse,  Up: 改良されたモジュール<2>

1.4.6.51 xml
............

Add a *note LexicalHandler: 827. class to the *note xml.sax.handler:
111. module.  (Contributed by Jonathan Gossage and Zackery Spytz in
bpo-35018(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35018


File: python.info,  Node: zipimport<3>,  Prev: xml<2>,  Up: 改良されたモジュール<2>

1.4.6.52 zipimport
..................

Add methods related to PEP 451(1): *note find_spec(): 829, *note
zipimport.zipimporter.create_module(): 82a, and *note
zipimport.zipimporter.exec_module(): 2ea.  (Contributed by Brett Cannon
in bpo-42131(2).)

Add *note invalidate_caches(): 82b. method.  (Contributed by Desmond
Cheong in bpo-14678(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0451/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42131

   (3) https://bugs.python.org/issue?@action=redirect&bpo=14678


File: python.info,  Node: 最適化<2>,  Next: 非推奨<3>,  Prev: 改良されたモジュール<2>,  Up: What's New In Python 3 10

1.4.7 最適化
------------

   * Constructors *note str(): 418, *note bytes(): 1a4. and *note
     bytearray(): 508. are now faster (around 30-40% for small objects).
     (Contributed by Serhiy Storchaka in bpo-41334(1).)

   * The *note runpy: ac. module now imports fewer modules.  The
     ‘python3 -m module-name’ command startup time is 1.4x faster in
     average.  On Linux, ‘python3 -I -m module-name’ imports 69 modules
     on Python 3.9, whereas it only imports 51 modules (-18) on Python
     3.10.  (Contributed by Victor Stinner in bpo-41006(2) and
     bpo-41718(3).)

   * The ‘LOAD_ATTR’ instruction now uses new "per opcode cache"
     mechanism.  It is about 36% faster now for regular attributes and
     44% faster for slots.  (Contributed by Pablo Galindo and Yury
     Selivanov in bpo-42093(4) and Guido van Rossum in bpo-42927(5),
     based on ideas implemented originally in PyPy and MicroPython.)

   * When building Python with *note -enable-optimizations: 82d. now
     ‘-fno-semantic-interposition’ is added to both the compile and link
     line.  This speeds builds of the Python interpreter created with
     *note -enable-shared: 82e. with ‘gcc’ by up to 30%.  See this
     article(6) for more details.  (Contributed by Victor Stinner and
     Pablo Galindo in bpo-38980(7).)

   * Use a new output buffer management code for *note bz2: f. / *note
     lzma: 7e. / *note zlib: 119. modules, and add ‘.readall()’ function
     to ‘_compression.DecompressReader’ class.  bz2 decompression is now
     1.09x ~ 1.17x faster, lzma decompression 1.20x ~ 1.32x faster,
     ‘GzipFile.read(-1)’ 1.11x ~ 1.18x faster.  (Contributed by Ma Lin,
     reviewed by Gregory P. Smith, in bpo-41486(8))

   * When using stringized annotations, annotations dicts for functions
     are no longer created when the function is created.  Instead, they
     are stored as a tuple of strings, and the function object lazily
     converts this into the annotations dict on demand.  This
     optimization cuts the CPU time needed to define an annotated
     function by half.  (Contributed by Yurii Karabas and Inada Naoki in
     bpo-42202(9).)

   * Substring search functions such as ‘str1 in str2’ and
     ‘str2.find(str1)’ now sometimes use Crochemore & Perrin's "Two-Way"
     string searching algorithm to avoid quadratic behavior on long
     strings.  (Contributed by Dennis Sweeney in bpo-41972(10))

   * Add micro-optimizations to ‘_PyType_Lookup()’ to improve type
     attribute cache lookup performance in the common case of cache
     hits.  This makes the interpreter 1.04 times faster on average.
     (Contributed by Dino Viehland in bpo-43452(11).)

   * The following built-in functions now support the faster PEP 590(12)
     vectorcall calling convention: *note map(): 82f, *note filter():
     830, *note reversed(): 831, *note bool(): 434. and *note float():
     2ce.  (Contributed by Donghee Na and Jeroen Demeyer in
     bpo-43575(13), bpo-43287(14), bpo-41922(15), bpo-41873(16) and
     bpo-41870(17).)

   * *note BZ2File: 832. performance is improved by removing internal
     ‘RLock’.  This makes ‘BZ2File’ thread unsafe in the face of
     multiple simultaneous readers or writers, just like its equivalent
     classes in *note gzip: 5d. and *note lzma: 7e. have always been.
     (Contributed by Inada Naoki in bpo-43785(18).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41334

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41006

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41718

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42093

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42927

   (6) 
https://developers.redhat.com/blog/2020/06/25/red-hat-enterprise-linux-8-2-brings-faster-python-3-8-run-speeds/

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38980

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41486

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42202

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41972

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43452

   (12) https://peps.python.org/pep-0590/

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43575

   (14) https://bugs.python.org/issue?@action=redirect&bpo=43287

   (15) https://bugs.python.org/issue?@action=redirect&bpo=41922

   (16) https://bugs.python.org/issue?@action=redirect&bpo=41873

   (17) https://bugs.python.org/issue?@action=redirect&bpo=41870

   (18) https://bugs.python.org/issue?@action=redirect&bpo=43785


File: python.info,  Node: 非推奨<3>,  Next: 削除<3>,  Prev: 最適化<2>,  Up: What's New In Python 3 10

1.4.8 非推奨
------------

   * Currently Python accepts numeric literals immediately followed by
     keywords, for example ‘0in x’, ‘1or x’, ‘0if 1else 2’.  It allows
     confusing and ambiguous expressions like ‘[0x1for x in y]’ (which
     can be interpreted as ‘[0x1 for x in y]’ or ‘[0x1f or x in y]’).
     Starting in this release, a deprecation warning is raised if the
     numeric literal is immediately followed by one of keywords *note
     and: 2c8, *note else: 171, *note for: 2c9, *note if: 2ca, *note in:
     2cb, *note is: 2cc. and *note or: 2cd.  In future releases it will
     be changed to syntax warning, and finally to syntax error.
     (Contributed by Serhiy Storchaka in bpo-43833(1).)

   * Starting in this release, there will be a concerted effort to begin
     cleaning up old import semantics that were kept for Python 2.7
     compatibility.  Specifically, ‘find_loader()’/‘find_module()’
     (superseded by *note find_spec(): 834.), *note load_module(): 835.
     (superseded by *note exec_module(): 836.), ‘module_repr()’ (which
     the import system takes care of for you), the ‘__package__’
     attribute (superseded by ‘__spec__.parent’), the ‘__loader__’
     attribute (superseded by ‘__spec__.loader’), and the ‘__cached__’
     attribute (superseded by ‘__spec__.cached’) will slowly be removed
     (as well as other classes and methods in *note importlib: 6b.).
     *note ImportWarning: 4c7. and/or *note DeprecationWarning: 18a.
     will be raised as appropriate to help identify code which needs
     updating during this transition.

   * The entire ‘distutils’ namespace is deprecated, to be removed in
     Python 3.12.  Refer to the *note module changes: 6f5. section for
     more information.

   * Non-integer arguments to *note random.randrange(): 837. are
     deprecated.  The *note ValueError: 1e3. is deprecated in favor of a
     *note TypeError: 502.  (Contributed by Serhiy Storchaka and Raymond
     Hettinger in bpo-37319(2).)

   * The various ‘load_module()’ methods of *note importlib: 6b. have
     been documented as deprecated since Python 3.6, but will now also
     trigger a *note DeprecationWarning: 18a.  Use *note exec_module():
     836. instead.  (Contributed by Brett Cannon in bpo-26131(3).)

   * ‘zimport.zipimporter.load_module()’ has been deprecated in
     preference for *note exec_module(): 2ea.  (Contributed by Brett
     Cannon in bpo-26131(4).)

   * The use of *note load_module(): 835. by the import system now
     triggers an *note ImportWarning: 4c7. as *note exec_module(): 836.
     is preferred.  (Contributed by Brett Cannon in bpo-26131(5).)

   * The use of ‘importlib.abc.MetaPathFinder.find_module()’ and
     ‘importlib.abc.PathEntryFinder.find_module()’ by the import system
     now trigger an *note ImportWarning: 4c7. as *note
     importlib.abc.MetaPathFinder.find_spec(): 834. and *note
     importlib.abc.PathEntryFinder.find_spec(): 838. are preferred,
     respectively.  You can use *note importlib.util.spec_from_loader():
     839. to help in porting.  (Contributed by Brett Cannon in
     bpo-42134(6).)

   * The use of ‘importlib.abc.PathEntryFinder.find_loader()’ by the
     import system now triggers an *note ImportWarning: 4c7. as *note
     importlib.abc.PathEntryFinder.find_spec(): 838. is preferred.  You
     can use *note importlib.util.spec_from_loader(): 839. to help in
     porting.  (Contributed by Brett Cannon in bpo-43672(7).)

   * The various implementations of
     ‘importlib.abc.MetaPathFinder.find_module()’ (
     ‘importlib.machinery.BuiltinImporter.find_module()’,
     ‘importlib.machinery.FrozenImporter.find_module()’,
     ‘importlib.machinery.WindowsRegistryFinder.find_module()’,
     ‘importlib.machinery.PathFinder.find_module()’,
     ‘importlib.abc.MetaPathFinder.find_module()’ ),
     ‘importlib.abc.PathEntryFinder.find_module()’ (
     ‘importlib.machinery.FileFinder.find_module()’ ), and
     ‘importlib.abc.PathEntryFinder.find_loader()’ (
     ‘importlib.machinery.FileFinder.find_loader()’ ) now raise *note
     DeprecationWarning: 18a. and are slated for removal in Python 3.12
     (previously they were documented as deprecated in Python 3.4).
     (Contributed by Brett Cannon in bpo-42135(8).)

   * ‘importlib.abc.Finder’ is deprecated (including its sole method,
     ‘find_module()’).  Both *note importlib.abc.MetaPathFinder: 83a.
     and *note importlib.abc.PathEntryFinder: 83b. no longer inherit
     from the class.  Users should inherit from one of these two classes
     as appropriate instead.  (Contributed by Brett Cannon in
     bpo-42135(9).)

   * The deprecations of ‘imp’, ‘importlib.find_loader()’,
     ‘importlib.util.set_package_wrapper()’,
     ‘importlib.util.set_loader_wrapper()’,
     ‘importlib.util.module_for_loader()’, ‘pkgutil.ImpImporter’, and
     ‘pkgutil.ImpLoader’ have all been updated to list Python 3.12 as
     the slated version of removal (they began raising *note
     DeprecationWarning: 18a. in previous versions of Python).
     (Contributed by Brett Cannon in bpo-43720(10).)

   * The import system now uses the ‘__spec__’ attribute on modules
     before falling back on ‘module_repr()’ for a module's ‘__repr__()’
     method.  Removal of the use of ‘module_repr()’ is scheduled for
     Python 3.12.  (Contributed by Brett Cannon in bpo-42137(11).)

   * ‘importlib.abc.Loader.module_repr()’,
     ‘importlib.machinery.FrozenLoader.module_repr()’, and
     ‘importlib.machinery.BuiltinLoader.module_repr()’ are deprecated
     and slated for removal in Python 3.12.  (Contributed by Brett
     Cannon in bpo-42136(12).)

   * ‘sqlite3.OptimizedUnicode’ has been undocumented and obsolete since
     Python 3.3, when it was made an alias to *note str: 418.  It is now
     deprecated, scheduled for removal in Python 3.12.  (Contributed by
     Erlend E. Aasland in bpo-42264(13).)

   * The undocumented built-in function ‘sqlite3.enable_shared_cache’ is
     now deprecated, scheduled for removal in Python 3.12.  Its use is
     strongly discouraged by the SQLite3 documentation.  See the SQLite3
     docs(14) for more details.  If a shared cache must be used, open
     the database in URI mode using the ‘cache=shared’ query parameter.
     (Contributed by Erlend E. Aasland in bpo-24464(15).)

   * The following ‘threading’ methods are now deprecated:

        * ‘threading.currentThread’ => *note threading.current_thread():
          2e1.

        * ‘threading.activeCount’ => *note threading.active_count():
          2e2.

        * ‘threading.Condition.notifyAll’ => *note
          threading.Condition.notify_all(): 2db.

        * ‘threading.Event.isSet’ => *note threading.Event.is_set():
          2dc.

        * ‘threading.Thread.setName’ => *note threading.Thread.name:
          2e0.

        * ‘threading.thread.getName’ => *note threading.Thread.name:
          2e0.

        * ‘threading.Thread.isDaemon’ => *note threading.Thread.daemon:
          2de.

        * ‘threading.Thread.setDaemon’ => *note threading.Thread.daemon:
          2de.

     (Contributed by Jelle Zijlstra in gh-87889(16).)

   * ‘pathlib.Path.link_to()’ is deprecated and slated for removal in
     Python 3.12.  Use *note pathlib.Path.hardlink_to(): 7ec. instead.
     (Contributed by Barney Gale in bpo-39950(17).)

   * ‘cgi.log()’ is deprecated and slated for removal in Python 3.12.
     (Contributed by Inada Naoki in bpo-41139(18).)

   * The following *note ssl: bb. features have been deprecated since
     Python 3.6, Python 3.7, or OpenSSL 1.1.0 and will be removed in
     3.11:

        * ‘OP_NO_SSLv2’, ‘OP_NO_SSLv3’, ‘OP_NO_TLSv1’, ‘OP_NO_TLSv1_1’,
          ‘OP_NO_TLSv1_2’, and ‘OP_NO_TLSv1_3’ are replaced by *note
          minimum_version: 83c. and *note maximum_version: 83d.

        * ‘PROTOCOL_SSLv2’, ‘PROTOCOL_SSLv3’, ‘PROTOCOL_SSLv23’,
          ‘PROTOCOL_TLSv1’, ‘PROTOCOL_TLSv1_1’, ‘PROTOCOL_TLSv1_2’, and
          ‘PROTOCOL_TLS’ are deprecated in favor of *note
          PROTOCOL_TLS_CLIENT: 83e. and *note PROTOCOL_TLS_SERVER: 83f.

        * ‘wrap_socket()’ is replaced by *note
          ssl.SSLContext.wrap_socket(): 4ee.

        * ‘match_hostname()’

        * ‘RAND_pseudo_bytes()’, ‘RAND_egd()’

        * NPN features like *note ssl.SSLSocket.selected_npn_protocol():
          840. and *note ssl.SSLContext.set_npn_protocols(): 2d9. are
          replaced by ALPN.

   * The threading debug (‘PYTHONTHREADDEBUG’ environment variable) is
     deprecated in Python 3.10 and will be removed in Python 3.12.  This
     feature requires a *note debug build of Python: 1da.  (Contributed
     by Victor Stinner in bpo-44584(19).)

   * Importing from the ‘typing.io’ and ‘typing.re’ submodules will now
     emit *note DeprecationWarning: 18a.  These submodules will be
     removed in a future version of Python.  Anything belonging to these
     submodules should be imported directly from *note typing: ed.
     instead.  (Contributed by Sebastian Rittau in bpo-38291(20).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43833

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37319

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26131

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26131

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26131

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42134

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43672

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42135

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42135

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43720

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42137

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42136

   (13) https://bugs.python.org/issue?@action=redirect&bpo=42264

   (14) https://sqlite.org/c3ref/enable_shared_cache.html

   (15) https://bugs.python.org/issue?@action=redirect&bpo=24464

   (16) https://github.com/python/cpython/issues/87889

   (17) https://bugs.python.org/issue?@action=redirect&bpo=39950

   (18) https://bugs.python.org/issue?@action=redirect&bpo=41139

   (19) https://bugs.python.org/issue?@action=redirect&bpo=44584

   (20) https://bugs.python.org/issue?@action=redirect&bpo=38291


File: python.info,  Node: 削除<3>,  Next: Porting to Python 3 10,  Prev: 非推奨<3>,  Up: What's New In Python 3 10

1.4.9 削除
----------

   * Removed special methods ‘__int__’, ‘__float__’, ‘__floordiv__’,
     ‘__mod__’, ‘__divmod__’, ‘__rfloordiv__’, ‘__rmod__’ and
     ‘__rdivmod__’ of the *note complex: 2cf. class.  They always raised
     a *note TypeError: 502.  (Contributed by Serhiy Storchaka in
     bpo-41974(1).)

   * The ‘ParserBase.error()’ method from the private and undocumented
     ‘_markupbase’ module has been removed.  *note
     html.parser.HTMLParser: 843. is the only subclass of ‘ParserBase’
     and its ‘error()’ implementation was already removed in Python 3.5.
     (Contributed by Berker Peksag in bpo-31844(2).)

   * Removed the ‘unicodedata.ucnhash_CAPI’ attribute which was an
     internal PyCapsule object.  The related private
     ‘_PyUnicode_Name_CAPI’ structure was moved to the internal C API.
     (Contributed by Victor Stinner in bpo-42157(3).)

   * Removed the ‘parser’ module, which was deprecated in 3.9 due to the
     switch to the new PEG parser, as well as all the C source and
     header files that were only being used by the old parser, including
     ‘node.h’, ‘parser.h’, ‘graminit.h’ and ‘grammar.h’.

   * Removed the Public C API functions
     ‘PyParser_SimpleParseStringFlags’,
     ‘PyParser_SimpleParseStringFlagsFilename’,
     ‘PyParser_SimpleParseFileFlags’ and ‘PyNode_Compile’ that were
     deprecated in 3.9 due to the switch to the new PEG parser.

   * Removed the ‘formatter’ module, which was deprecated in Python 3.4.
     It is somewhat obsolete, little used, and not tested.  It was
     originally scheduled to be removed in Python 3.6, but such removals
     were delayed until after Python 2.7 EOL. Existing users should copy
     whatever classes they use into their code.  (Contributed by Donghee
     Na and Terry J. Reedy in bpo-42299(4).)

   * Removed the ‘PyModule_GetWarningsModule()’ function that was
     useless now due to the ‘_warnings’ module was converted to a
     builtin module in 2.6.  (Contributed by Hai Shi in bpo-42599(5).)

   * Remove deprecated aliases to *note コレクション抽象基底クラス: 844.
     from the *note collections: 16. module.  (Contributed by Victor
     Stinner in bpo-37324(6).)

   * The ‘loop’ parameter has been removed from most of *note asyncio:
     8.'s *note high-level API: 845. following deprecation in Python
     3.8.  The motivation behind this change is multifold:

       1. This simplifies the high-level API.

       2. The functions in the high-level API have been implicitly
          getting the current thread's running event loop since Python
          3.7.  There isn't a need to pass the event loop to the API in
          most normal use cases.

       3. Event loop passing is error-prone especially when dealing with
          loops running in different threads.

     Note that the low-level API will still accept ‘loop’.  See *note
     Python API の変更: 846. for examples of how to replace existing
     code.

     (Contributed by Yurii Karabas, Andrew Svetlov, Yury Selivanov and
     Kyle Stanley in bpo-42392(7).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41974

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31844

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42157

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42299

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42599

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37324

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42392


File: python.info,  Node: Porting to Python 3 10,  Next: CPython バイトコードの変更<2>,  Prev: 削除<3>,  Up: What's New In Python 3 10

1.4.10 Porting to Python 3.10
-----------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* Changes in the Python syntax::
* Python API の変更::
* C API の変更: C API の変更<2>.


File: python.info,  Node: Changes in the Python syntax,  Next: Python API の変更,  Up: Porting to Python 3 10

1.4.10.1 Changes in the Python syntax
.....................................

   * Deprecation warning is now emitted when compiling previously valid
     syntax if the numeric literal is immediately followed by a keyword
     (like in ‘0in x’).  In future releases it will be changed to syntax
     warning, and finally to a syntax error.  To get rid of the warning
     and make the code compatible with future releases just add a space
     between the numeric literal and the following keyword.
     (Contributed by Serhiy Storchaka in bpo-43833(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43833


File: python.info,  Node: Python API の変更,  Next: C API の変更<2>,  Prev: Changes in the Python syntax,  Up: Porting to Python 3 10

1.4.10.2 Python API の変更
..........................

   * The 'etype' parameters of the *note format_exception(): 818, *note
     format_exception_only(): 819, and *note print_exception(): 81a.
     functions in the *note traceback: e7. module have been renamed to
     'exc'.  (Contributed by Zackery Spytz and Matthias Bussonnier in
     bpo-26389(1).)

   * *note atexit: 9.: At Python exit, if a callback registered with
     *note atexit.register(): 84a. fails, its exception is now logged.
     Previously, only some exceptions were logged, and the last
     exception was always silently ignored.  (Contributed by Victor
     Stinner in bpo-42639(2).)

   * *note collections.abc.Callable: 7b5. generic now flattens type
     parameters, similar to what *note typing.Callable: 790. currently
     does.  This means that ‘collections.abc.Callable[[int, str], str]’
     will have ‘__args__’ of ‘(int, str, str)’; previously this was
     ‘([int, str], str)’.  Code which accesses the arguments via *note
     typing.get_args(): 84b. or ‘__args__’ need to account for this
     change.  Furthermore, *note TypeError: 502. may be raised for
     invalid forms of parameterizing *note collections.abc.Callable:
     7b5. which may have passed silently in Python 3.9.  (Contributed by
     Ken Jin in bpo-42195(3).)

   * *note socket.htons(): 84c. and *note socket.ntohs(): 84d. now raise
     *note OverflowError: 84e. instead of *note DeprecationWarning: 18a.
     if the given parameter will not fit in a 16-bit unsigned integer.
     (Contributed by Erlend E. Aasland in bpo-42393(4).)

   * The ‘loop’ parameter has been removed from most of *note asyncio:
     8.'s *note high-level API: 845. following deprecation in Python
     3.8.

     A coroutine that currently looks like this:

          async def foo(loop):
              await asyncio.sleep(1, loop=loop)

     Should be replaced with this:

          async def foo():
              await asyncio.sleep(1)

     If ‘foo()’ was specifically designed 'not' to run in the current
     thread's running event loop (e.g.  running in another thread's
     event loop), consider using *note
     asyncio.run_coroutine_threadsafe(): 84f. instead.

     (Contributed by Yurii Karabas, Andrew Svetlov, Yury Selivanov and
     Kyle Stanley in bpo-42392(5).)

   * The *note types.FunctionType: 850. constructor now inherits the
     current builtins if the 'globals' dictionary has no
     ‘"__builtins__"’ key, rather than using ‘{"None": None}’ as
     builtins: same behavior as *note eval(): 165. and *note exec():
     164. functions.  Defining a function with ‘def function(...): ...’
     in Python is not affected, globals cannot be overridden with this
     syntax: it also inherits the current builtins.  (Contributed by
     Victor Stinner in bpo-42990(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26389

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42639

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42195

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42393

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42392

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42990


File: python.info,  Node: C API の変更<2>,  Prev: Python API の変更,  Up: Porting to Python 3 10

1.4.10.3 C API の変更
.....................

   * The C API functions ‘PyParser_SimpleParseStringFlags’,
     ‘PyParser_SimpleParseStringFlagsFilename’,
     ‘PyParser_SimpleParseFileFlags’, ‘PyNode_Compile’ and the type used
     by these functions, ‘struct _node’, were removed due to the switch
     to the new PEG parser.

     Source should be now be compiled directly to a code object using,
     for example, *note Py_CompileString(): 852.  The resulting code
     object can then be evaluated using, for example, *note
     PyEval_EvalCode(): 853.

     Specifically:

        * A call to ‘PyParser_SimpleParseStringFlags’ followed by
          ‘PyNode_Compile’ can be replaced by calling *note
          Py_CompileString(): 852.

        * There is no direct replacement for
          ‘PyParser_SimpleParseFileFlags’.  To compile code from a ‘FILE
          *’ argument, you will need to read the file in C and pass the
          resulting buffer to *note Py_CompileString(): 852.

        * To compile a file given a ‘char *’ filename, explicitly open
          the file, read it and compile the result.  One way to do this
          is using the *note io: 73. module with *note
          PyImport_ImportModule(): 398, *note PyObject_CallMethod():
          379, *note PyBytes_AsString(): 854. and *note
          Py_CompileString(): 852, as sketched below.  (Declarations and
          error handling are omitted.)

               io_module = Import_ImportModule("io");
               fileobject = PyObject_CallMethod(io_module, "open", "ss", filename, "rb");
               source_bytes_object = PyObject_CallMethod(fileobject, "read", "");
               result = PyObject_CallMethod(fileobject, "close", "");
               source_buf = PyBytes_AsString(source_bytes_object);
               code = Py_CompileString(source_buf, filename, Py_file_input);

        * For ‘FrameObject’ objects, the *note f_lasti: 855. member now
          represents a wordcode offset instead of a simple offset into
          the bytecode string.  This means that this number needs to be
          multiplied by 2 to be used with APIs that expect a byte offset
          instead (like *note PyCode_Addr2Line(): 856. for example).
          Notice as well that the ‘f_lasti’ member of ‘FrameObject’
          objects is not considered stable: please use *note
          PyFrame_GetLineNumber(): 756. instead.


File: python.info,  Node: CPython バイトコードの変更<2>,  Next: Build Changes<4>,  Prev: Porting to Python 3 10,  Up: What's New In Python 3 10

1.4.11 CPython バイトコードの変更
---------------------------------

   * The ‘MAKE_FUNCTION’ instruction now accepts either a dict or a
     tuple of strings as the function's annotations.  (Contributed by
     Yurii Karabas and Inada Naoki in bpo-42202(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42202


File: python.info,  Node: Build Changes<4>,  Next: C API の変更<3>,  Prev: CPython バイトコードの変更<2>,  Up: What's New In Python 3 10

1.4.12 Build Changes
--------------------

   * PEP 644(1): Python now requires OpenSSL 1.1.1 or newer.  OpenSSL
     1.0.2 is no longer supported.  (Contributed by Christian Heimes in
     bpo-43669(2).)

   * The C99 functions ‘snprintf()’ and ‘vsnprintf()’ are now required
     to build Python.  (Contributed by Victor Stinner in bpo-36020(3).)

   * *note sqlite3: ba. requires SQLite 3.7.15 or higher.  (Contributed
     by Sergey Fedoseev and Erlend E. Aasland in bpo-40744(4) and
     bpo-40810(5).)

   * The *note atexit: 9. module must now always be built as a built-in
     module.  (Contributed by Victor Stinner in bpo-42639(6).)

   * Add *note -disable-test-modules: 859. option to the ‘configure’
     script: don't build nor install test modules.  (Contributed by
     Xavier de Gaye, Thomas Petazzoni and Peixing Xin in bpo-27640(7).)

   * Add *note -with-wheel-pkg-dir=PATH option: 85a. to the
     ‘./configure’ script.  If specified, the *note ensurepip: 4b.
     module looks for ‘setuptools’ and ‘pip’ wheel packages in this
     directory: if both are present, these wheel packages are used
     instead of ensurepip bundled wheel packages.

     Some Linux distribution packaging policies recommend against
     bundling dependencies.  For example, Fedora installs wheel packages
     in the ‘/usr/share/python-wheels/’ directory and don't install the
     ‘ensurepip._bundled’ package.

     (Contributed by Victor Stinner in bpo-42856(8).)

   * Add a new *note configure -without-static-libpython option: 85b. to
     not build the ‘libpythonMAJOR.MINOR.a’ static library and not
     install the ‘python.o’ object file.

     (Contributed by Victor Stinner in bpo-43103(9).)

   * The ‘configure’ script now uses the ‘pkg-config’ utility, if
     available, to detect the location of Tcl/Tk headers and libraries.
     As before, those locations can be explicitly specified with the
     ‘--with-tcltk-includes’ and ‘--with-tcltk-libs’ configuration
     options.  (Contributed by Manolis Stamatogiannakis in
     bpo-42603(10).)

   * Add *note -with-openssl-rpath: 85c. option to ‘configure’ script.
     The option simplifies building Python with a custom OpenSSL
     installation, e.g.  ‘./configure --with-openssl=/path/to/openssl
     --with-openssl-rpath=auto’.  (Contributed by Christian Heimes in
     bpo-43466(11).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0644/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43669

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36020

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40744

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40810

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42639

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27640

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42856

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43103

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42603

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43466


File: python.info,  Node: C API の変更<3>,  Next: Notable security feature in 3 10 7,  Prev: Build Changes<4>,  Up: What's New In Python 3 10

1.4.13 C API の変更
-------------------

* Menu:

* PEP 652; Maintaining the Stable ABI: PEP 652 Maintaining the Stable ABI.
* 新しい機能: 新しい機能<4>.
* Porting to Python 3.10: Porting to Python 3 10<2>.
* 非推奨: 非推奨<4>.
* 削除: 削除<4>.


File: python.info,  Node: PEP 652 Maintaining the Stable ABI,  Next: 新しい機能<4>,  Up: C API の変更<3>

1.4.13.1 PEP 652: Maintaining the Stable ABI
............................................

The Stable ABI (Application Binary Interface) for extension modules or
embedding Python is now explicitly defined.  *note C API の安定性: 51e.
describes C API and ABI stability guarantees along with best practices
for using the Stable ABI.

(Contributed by Petr Viktorin in PEP 652(1) and bpo-43795(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0652/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43795


File: python.info,  Node: 新しい機能<4>,  Next: Porting to Python 3 10<2>,  Prev: PEP 652 Maintaining the Stable ABI,  Up: C API の変更<3>

1.4.13.2 新しい機能
...................

   * The result of *note PyNumber_Index(): 860. now always has exact
     type *note int: 238.  Previously, the result could have been an
     instance of a subclass of ‘int’.  (Contributed by Serhiy Storchaka
     in bpo-40792(1).)

   * Add a new *note orig_argv: 861. member to the *note PyConfig: 380.
     structure: the list of the original command line arguments passed
     to the Python executable.  (Contributed by Victor Stinner in
     bpo-23427(2).)

   * The *note PyDateTime_DATE_GET_TZINFO(): 862. and *note
     PyDateTime_TIME_GET_TZINFO(): 863. macros have been added for
     accessing the ‘tzinfo’ attributes of *note datetime.datetime: 1ae.
     and *note datetime.time: 1b0. objects.  (Contributed by Zackery
     Spytz in bpo-30155(3).)

   * Add a *note PyCodec_Unregister(): 864. function to unregister a
     codec search function.  (Contributed by Hai Shi in bpo-41842(4).)

   * The *note PyIter_Send(): 865. function was added to allow sending
     value into iterator without raising ‘StopIteration’ exception.
     (Contributed by Vladimir Matveev in bpo-41756(5).)

   * Add *note PyUnicode_AsUTF8AndSize(): 866. to the limited C API.
     (Contributed by Alex Gaynor in bpo-41784(6).)

   * Add *note PyModule_AddObjectRef(): 33e. function: similar to *note
     PyModule_AddObject(): 33f. but don't steal a reference to the value
     on success.  (Contributed by Victor Stinner in bpo-1635741(7).)

   * Add *note Py_NewRef(): 867. and *note Py_XNewRef(): 868. functions
     to increment the reference count of an object and return the
     object.  (Contributed by Victor Stinner in bpo-42262(8).)

   * The *note PyType_FromSpecWithBases(): 54a. and *note
     PyType_FromModuleAndSpec(): 51c. functions now accept a single
     class as the 'bases' argument.  (Contributed by Serhiy Storchaka in
     bpo-42423(9).)

   * The *note PyType_FromModuleAndSpec(): 51c. function now accepts
     NULL ‘tp_doc’ slot.  (Contributed by Hai Shi in bpo-41832(10).)

   * The *note PyType_GetSlot(): 869. function can accept *note static
     types: 74a.  (Contributed by Hai Shi and Petr Viktorin in
     bpo-41073(11).)

   * Add a new *note PySet_CheckExact(): 86a. function to the C-API to
     check if an object is an instance of *note set: 5a3. but not an
     instance of a subtype.  (Contributed by Pablo Galindo in
     bpo-43277(12).)

   * Add *note PyErr_SetInterruptEx(): 86b. which allows passing a
     signal number to simulate.  (Contributed by Antoine Pitrou in
     bpo-43356(13).)

   * The limited C API is now supported if *note Python is built in
     debug mode: 1da. (if the ‘Py_DEBUG’ macro is defined).  In the
     limited C API, the *note Py_INCREF(): 53a. and *note Py_DECREF():
     53b. functions are now implemented as opaque function calls, rather
     than accessing directly the *note PyObject.ob_refcnt: 86c. member,
     if Python is built in debug mode and the ‘Py_LIMITED_API’ macro
     targets Python 3.10 or newer.  It became possible to support the
     limited C API in debug mode because the *note PyObject: 312.
     structure is the same in release and debug mode since Python 3.8
     (see bpo-36465(14)).

     The limited C API is still not supported in the *note
     -with-trace-refs: 36e. special build (‘Py_TRACE_REFS’ macro).
     (Contributed by Victor Stinner in bpo-43688(15).)

   * Add the *note Py_Is(x, y): 86d. function to test if the 'x' object
     is the 'y' object, the same as ‘x is y’ in Python.  Add also the
     *note Py_IsNone(): 86e, *note Py_IsTrue(): 86f, *note Py_IsFalse():
     870. functions to test if an object is, respectively, the ‘None’
     singleton, the ‘True’ singleton or the ‘False’ singleton.
     (Contributed by Victor Stinner in bpo-43753(16).)

   * Add new functions to control the garbage collector from C code:
     *note PyGC_Enable(): 871, *note PyGC_Disable(): 872, *note
     PyGC_IsEnabled(): 873.  These functions allow to activate,
     deactivate and query the state of the garbage collector from C code
     without having to import the *note gc: 56. module.

   * Add a new *note Py_TPFLAGS_DISALLOW_INSTANTIATION: 54e. type flag
     to disallow creating type instances.  (Contributed by Victor
     Stinner in bpo-43916(17).)

   * Add a new *note Py_TPFLAGS_IMMUTABLETYPE: 39c. type flag for
     creating immutable type objects: type attributes cannot be set nor
     deleted.  (Contributed by Victor Stinner and Erlend E. Aasland in
     bpo-43908(18).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40792

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23427

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30155

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41842

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41756

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41784

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42262

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42423

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41832

   (11) https://bugs.python.org/issue?@action=redirect&bpo=41073

   (12) https://bugs.python.org/issue?@action=redirect&bpo=43277

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43356

   (14) https://bugs.python.org/issue?@action=redirect&bpo=36465

   (15) https://bugs.python.org/issue?@action=redirect&bpo=43688

   (16) https://bugs.python.org/issue?@action=redirect&bpo=43753

   (17) https://bugs.python.org/issue?@action=redirect&bpo=43916

   (18) https://bugs.python.org/issue?@action=redirect&bpo=43908


File: python.info,  Node: Porting to Python 3 10<2>,  Next: 非推奨<4>,  Prev: 新しい機能<4>,  Up: C API の変更<3>

1.4.13.3 Porting to Python 3.10
...............................

   * The ‘PY_SSIZE_T_CLEAN’ macro must now be defined to use *note
     PyArg_ParseTuple(): 53d. and *note Py_BuildValue(): 875. formats
     which use ‘#’: ‘es#’, ‘et#’, ‘s#’, ‘u#’, ‘y#’, ‘z#’, ‘U#’ and ‘Z#’.
     See *note 引数の解釈と値の構築: 876. and PEP 353(1).  (Contributed
     by Victor Stinner in bpo-40943(2).)

   * Since *note Py_REFCNT(): 877. is changed to the inline static
     function, ‘Py_REFCNT(obj) = new_refcnt’ must be replaced with
     ‘Py_SET_REFCNT(obj, new_refcnt)’: see *note Py_SET_REFCNT(): 878.
     (available since Python 3.9).  For backward compatibility, this
     macro can be used:

          #if PY_VERSION_HEX < 0x030900A4
          #  define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)
          #endif

     (Contributed by Victor Stinner in bpo-39573(3).)

   * Calling *note PyDict_GetItem(): 360. without *note GIL: 13f. held
     had been allowed for historical reason.  It is no longer allowed.
     (Contributed by Victor Stinner in bpo-40839(4).)

   * ‘PyUnicode_FromUnicode(NULL, size)’ and
     ‘PyUnicode_FromStringAndSize(NULL, size)’ raise
     ‘DeprecationWarning’ now.  Use *note PyUnicode_New(): 879. to
     allocate Unicode object without initial data.  (Contributed by
     Inada Naoki in bpo-36346(5).)

   * The private ‘_PyUnicode_Name_CAPI’ structure of the PyCapsule API
     ‘unicodedata.ucnhash_CAPI’ has been moved to the internal C API.
     (Contributed by Victor Stinner in bpo-42157(6).)

   * *note Py_GetPath(): 38d, *note Py_GetPrefix(): 38f, *note
     Py_GetExecPrefix(): 38b, *note Py_GetProgramFullPath(): 391, *note
     Py_GetPythonHome(): 394. and *note Py_GetProgramName(): 393.
     functions now return ‘NULL’ if called before *note Py_Initialize():
     87a. (before Python is initialized).  Use the new *note Python
     初期化設定: 381. API to get the *note Python Path Configuration:
     87b.  (Contributed by Victor Stinner in bpo-42260(7).)

   * *note PyList_SET_ITEM(): 367, *note PyTuple_SET_ITEM(): 366. and
     *note PyCell_SET(): 87c. macros can no longer be used as l-value or
     r-value.  For example, ‘x = PyList_SET_ITEM(a, b, c)’ and
     ‘PyList_SET_ITEM(a, b, c) = x’ now fail with a compiler error.  It
     prevents bugs like ‘if (PyList_SET_ITEM (a, b, c) < 0) ...’ test.
     (Contributed by Zackery Spytz and Victor Stinner in bpo-30459(8).)

   * The non-limited API files ‘odictobject.h’, ‘parser_interface.h’,
     ‘picklebufobject.h’, ‘pyarena.h’, ‘pyctype.h’, ‘pydebug.h’,
     ‘pyfpe.h’, and ‘pytime.h’ have been moved to the ‘Include/cpython’
     directory.  These files must not be included directly, as they are
     already included in ‘Python.h’; see *note インクルードファイル:
     74f.  If they have been included directly, consider including
     ‘Python.h’ instead.  (Contributed by Nicholas Sim in bpo-35134(9).)

   * Use the *note Py_TPFLAGS_IMMUTABLETYPE: 39c. type flag to create
     immutable type objects.  Do not rely on *note Py_TPFLAGS_HEAPTYPE:
     87d. to decide if a type object is mutable or not; check if *note
     Py_TPFLAGS_IMMUTABLETYPE: 39c. is set instead.  (Contributed by
     Victor Stinner and Erlend E. Aasland in bpo-43908(10).)

   * The undocumented function ‘Py_FrozenMain’ has been removed from the
     limited API. The function is mainly useful for custom builds of
     Python.  (Contributed by Petr Viktorin in bpo-26241(11).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0353/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40943

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40839

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36346

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42157

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42260

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30459

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43908

   (11) https://bugs.python.org/issue?@action=redirect&bpo=26241


File: python.info,  Node: 非推奨<4>,  Next: 削除<4>,  Prev: Porting to Python 3 10<2>,  Up: C API の変更<3>

1.4.13.4 非推奨
...............

   * The ‘PyUnicode_InternImmortal()’ function is now deprecated and
     will be removed in Python 3.12: use *note
     PyUnicode_InternInPlace(): 87f. instead.  (Contributed by Victor
     Stinner in bpo-41692(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41692


File: python.info,  Node: 削除<4>,  Prev: 非推奨<4>,  Up: C API の変更<3>

1.4.13.5 削除
.............

   * Removed ‘Py_UNICODE_str*’ functions manipulating ‘Py_UNICODE*’
     strings.  (Contributed by Inada Naoki in bpo-41123(1).)

        * ‘Py_UNICODE_strlen’: use *note PyUnicode_GetLength(): 881. or
          *note PyUnicode_GET_LENGTH: 882.

        * ‘Py_UNICODE_strcat’: use *note PyUnicode_CopyCharacters():
          883. or *note PyUnicode_FromFormat(): 363.

        * ‘Py_UNICODE_strcpy’, ‘Py_UNICODE_strncpy’: use *note
          PyUnicode_CopyCharacters(): 883. or *note
          PyUnicode_Substring(): 884.

        * ‘Py_UNICODE_strcmp’: use *note PyUnicode_Compare(): 885.

        * ‘Py_UNICODE_strncmp’: use *note PyUnicode_Tailmatch(): 886.

        * ‘Py_UNICODE_strchr’, ‘Py_UNICODE_strrchr’: use *note
          PyUnicode_FindChar(): 887.

   * Removed ‘PyUnicode_GetMax()’.  Please migrate to new ( PEP 393(2))
     APIs.  (Contributed by Inada Naoki in bpo-41103(3).)

   * Removed ‘PyLong_FromUnicode()’.  Please migrate to *note
     PyLong_FromUnicodeObject(): 888.  (Contributed by Inada Naoki in
     bpo-41103(4).)

   * Removed ‘PyUnicode_AsUnicodeCopy()’.  Please use *note
     PyUnicode_AsUCS4Copy(): 889. or *note PyUnicode_AsWideCharString():
     88a. (Contributed by Inada Naoki in bpo-41103(5).)

   * Removed ‘_Py_CheckRecursionLimit’ variable: it has been replaced by
     ‘ceval.recursion_limit’ of the *note PyInterpreterState: 88b.
     structure.  (Contributed by Victor Stinner in bpo-41834(6).)

   * Removed undocumented macros ‘Py_ALLOW_RECURSION’ and
     ‘Py_END_ALLOW_RECURSION’ and the ‘recursion_critical’ field of the
     *note PyInterpreterState: 88b. structure.  (Contributed by Serhiy
     Storchaka in bpo-41936(7).)

   * Removed the undocumented ‘PyOS_InitInterrupts()’ function.
     Initializing Python already implicitly installs signal handlers:
     see *note PyConfig.install_signal_handlers: 88c.  (Contributed by
     Victor Stinner in bpo-41713(8).)

   * Remove the ‘PyAST_Validate()’ function.  It is no longer possible
     to build a AST object (‘mod_ty’ type) with the public C API. The
     function was already excluded from the limited C API ( PEP 384(9)).
     (Contributed by Victor Stinner in bpo-43244(10).)

   * Remove the ‘symtable.h’ header file and the undocumented functions:

        * ‘PyST_GetScope()’

        * ‘PySymtable_Build()’

        * ‘PySymtable_BuildObject()’

        * ‘PySymtable_Free()’

        * ‘Py_SymtableString()’

        * ‘Py_SymtableStringObject()’

     The ‘Py_SymtableString()’ function was part the stable ABI by
     mistake but it could not be used, because the ‘symtable.h’ header
     file was excluded from the limited C API.

     Use Python *note symtable: c2. module instead.  (Contributed by
     Victor Stinner in bpo-43244(11).)

   * Remove *note PyOS_ReadlineFunctionPointer(): 552. from the limited
     C API headers and from ‘python3.dll’, the library that provides the
     stable ABI on Windows.  Since the function takes a ‘FILE*’
     argument, its ABI stability cannot be guaranteed.  (Contributed by
     Petr Viktorin in bpo-43868(12).)

   * Remove ‘ast.h’, ‘asdl.h’, and ‘Python-ast.h’ header files.  These
     functions were undocumented and excluded from the limited C API.
     Most names defined by these header files were not prefixed by ‘Py’
     and so could create names conflicts.  For example, ‘Python-ast.h’
     defined a ‘Yield’ macro which was conflict with the ‘Yield’ name
     used by the Windows ‘<winbase.h>’ header.  Use the Python *note
     ast: 7. module instead.  (Contributed by Victor Stinner in
     bpo-43244(13).)

   * Remove the compiler and parser functions using ‘struct _mod’ type,
     because the public AST C API was removed:

        * ‘PyAST_Compile()’

        * ‘PyAST_CompileEx()’

        * ‘PyAST_CompileObject()’

        * ‘PyFuture_FromAST()’

        * ‘PyFuture_FromASTObject()’

        * ‘PyParser_ASTFromFile()’

        * ‘PyParser_ASTFromFileObject()’

        * ‘PyParser_ASTFromFilename()’

        * ‘PyParser_ASTFromString()’

        * ‘PyParser_ASTFromStringObject()’

     These functions were undocumented and excluded from the limited C
     API. (Contributed by Victor Stinner in bpo-43244(14).)

   * Remove the ‘pyarena.h’ header file with functions:

        * ‘PyArena_New()’

        * ‘PyArena_Free()’

        * ‘PyArena_Malloc()’

        * ‘PyArena_AddPyObject()’

     These functions were undocumented, excluded from the limited C API,
     and were only used internally by the compiler.  (Contributed by
     Victor Stinner in bpo-43244(15).)

   * The ‘PyThreadState.use_tracing’ member has been removed to optimize
     Python.  (Contributed by Mark Shannon in bpo-43760(16).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41123

   (2) https://peps.python.org/pep-0393/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41103

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41103

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41103

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41834

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41936

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41713

   (9) https://peps.python.org/pep-0384/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (12) https://bugs.python.org/issue?@action=redirect&bpo=43868

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (14) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (15) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (16) https://bugs.python.org/issue?@action=redirect&bpo=43760


File: python.info,  Node: Notable security feature in 3 10 7,  Next: Notable security feature in 3 10 8,  Prev: C API の変更<3>,  Up: What's New In Python 3 10

1.4.14 Notable security feature in 3.10.7
-----------------------------------------

Converting between *note int: 238. and *note str: 418. in bases other
than 2 (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10
(decimal) now raises a *note ValueError: 1e3. if the number of digits in
string form is above a limit to avoid potential denial of service
attacks due to the algorithmic complexity.  This is a mitigation for CVE
2020-10735(1).  This limit can be configured or disabled by environment
variable, command line flag, or *note sys: c3. APIs.  See the *note
integer string conversion length limitation: 5bf. documentation.  The
default limit is 4300 digits in string form.

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2020-10735


File: python.info,  Node: Notable security feature in 3 10 8,  Next: Notable changes in 3 10 12,  Prev: Notable security feature in 3 10 7,  Up: What's New In Python 3 10

1.4.15 Notable security feature in 3.10.8
-----------------------------------------

The deprecated ‘mailcap’ module now refuses to inject unsafe text
(filenames, MIME types, parameters) into shell commands.  Instead of
using such text, it will warn and act as if a match was not found (or
for test commands, as if the test failed).  (Contributed by Petr
Viktorin in gh-98966(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98966


File: python.info,  Node: Notable changes in 3 10 12,  Prev: Notable security feature in 3 10 8,  Up: What's New In Python 3 10

1.4.16 Notable changes in 3.10.12
---------------------------------

* Menu:

* tarfile: tarfile<2>.


File: python.info,  Node: tarfile<2>,  Up: Notable changes in 3 10 12

1.4.16.1 tarfile
................

   * The extraction methods in *note tarfile: c8, and *note
     shutil.unpack_archive(): 438, have a new a 'filter' argument that
     allows limiting tar features than may be surprising or dangerous,
     such as creating files outside the destination directory.  See
     *note Extraction filters: 439. for details.  In Python 3.12, use
     without the 'filter' argument will show a *note DeprecationWarning:
     18a.  In Python 3.14, the default will switch to ‘'data'’.
     (Contributed by Petr Viktorin in PEP 706(1).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0706/


File: python.info,  Node: What's New In Python 3 9,  Next: What's New In Python 3 8,  Prev: What's New In Python 3 10,  Up: What's New in Python

1.5 What's New In Python 3.9
============================


編集者: Łukasz Langa

This article explains the new features in Python 3.9, compared to 3.8.
Python 3.9 was released on October 5, 2020.  For full details, see the
*note changelog: 122.

参考
....

PEP 596(1) - Python 3.9 リリーススケジュール

* Menu:

* 概要: 概要 -- リリースハイライト<3>. リリースハイライト
* コード中の非推奨警告(DeprecationWarning)をチェックして下さい: コード中の非推奨警告 DeprecationWarning をチェックして下さい.
* 新しい機能: 新しい機能<5>.
* その他の言語変更: その他の言語変更<3>.
* 新たなモジュール: 新たなモジュール<3>.
* 改良されたモジュール: 改良されたモジュール<3>.
* 最適化: 最適化<3>.
* 非推奨: 非推奨<5>.
* 削除: 削除<5>.
* Python 3.9への移植: Python 3 9への移植.
* Build Changes: Build Changes<5>.
* C API の変更: C API の変更<5>.
* Python 3.9.1 での重要な変更点: Python 3 9 1 での重要な変更点.
* Python 3.9.2 での重要な変更点: Python 3 9 2 での重要な変更点.
* Python 3.9.3 での重要な変更点: Python 3 9 3 での重要な変更点.
* Python 3.9.5での重要な変更点: Python 3 9 5での重要な変更点.
* Notable security feature in 3.9.14: Notable security feature in 3 9 14.
* Notable changes in 3.9.17: Notable changes in 3 9 17.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0596/


File: python.info,  Node: 概要 -- リリースハイライト<3>,  Next: コード中の非推奨警告 DeprecationWarning をチェックして下さい,  Up: What's New In Python 3 9

1.5.1 概要 - リリースハイライト
-------------------------------

新たな文法機能:

   * PEP 584(1)、 ‘dict’ に和集合の演算子が追加されました。

   * PEP 585(2)、標準コレクション型の型ヒントにおける総称型 (generics) の
     使用。

   * PEP 614(3)、デコレータの適用における文法的制約の緩和。

新たな組み込み機能:

   * PEP 616(4)、prefixとsuffixを削除する文字列メソッド。

標準ライブラリの新機能:

   * PEP 593(5)、より柔軟な変数・関数アノテーション (訳注: ‘Annotated’ の
     導入)。

   * *note os.pidfd_open(): 447. が追加され、レースやシグナルを使わずに
     プロセス管理ができるようになりました。

インタプリタの改善:

   * PEP 573(6), fast access to module state from methods of C extension
     types;

   * PEP 617(7)、CPython における PEG (Parser Expression Grammar) ベース
     の新しい構文解析器の使用。

   * いくつかのPythonの組み込み型（range, tuple, set, frozenset, list,
     dict） を PEP 590(8) vectorcall を用いて高速化しました。

   * garbage collection does not block on resurrected objects;

   * a number of Python modules (‘_abc’, ‘audioop’, ‘_bz2’, ‘_codecs’,
     ‘_contextvars’, ‘_crypt’, ‘_functools’, ‘_json’, ‘_locale’, *note
     math: 81, *note operator: 8f, *note resource: aa, *note time: d7,
     ‘_weakref’) now use multiphase initialization as defined by PEP
     489;

   * a number of standard library modules (‘audioop’, *note ast: 7,
     *note grp: 5c, ‘_hashlib’, *note pwd: a0, ‘_posixsubprocess’, *note
     random: a6, *note select: af, *note struct: c0, *note termios: ca,
     *note zlib: 119.) are now using the stable ABI defined by PEP 384.

新たなライブラリモジュール:

   * PEP 615(9)、IANAのTime Zone Databaseが標準ライブラリの *note
     zoneinfo: 11a. モジュールで提供されるようになりました。

   * an implementation of a topological sort of a graph is now provided
     in the new *note graphlib: 5b. module.

リリースプロセスの変更:

   * PEP 602(10)、CPythonは年次のリリースサイクルを採用します。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0584/

   (2) https://peps.python.org/pep-0585/

   (3) https://peps.python.org/pep-0614/

   (4) https://peps.python.org/pep-0616/

   (5) https://peps.python.org/pep-0593/

   (6) https://peps.python.org/pep-0573/

   (7) https://peps.python.org/pep-0617/

   (8) https://peps.python.org/pep-0590/

   (9) https://peps.python.org/pep-0615/

   (10) https://peps.python.org/pep-0602/


File: python.info,  Node: コード中の非推奨警告 DeprecationWarning をチェックして下さい,  Next: 新しい機能<5>,  Prev: 概要 -- リリースハイライト<3>,  Up: What's New In Python 3 9

1.5.2 コード中の非推奨警告(DeprecationWarning)をチェックして下さい
------------------------------------------------------------------

Python 2.7がまだサポートされていた期間、Python 3の多くの機能はPython
2.7との後方互換性を保っていました。Python 2サポートの終了とともに、この
後方互換性レイヤは除去されたか、間もなく除去されます。ここ数年で、それら
の多くは警告 *note DeprecationWarning: 18a. を出すようになりました。例え
ば、2012年にリリースされたPython 3.3以降、‘collections.abc.Mapping’ の代
りに ‘collections.Mapping’ を使うと、警告 *note DeprecationWarning: 18a.
が出ます。

警告 *note DeprecationWarning: 18a. および *note
PendingDeprecationWarning: 895. を確認するために、 *note -W: 896.
‘default’ コマンドラインオプションを付けて、あなたのアプリケーションをテ
ストして下さい。あるいは、*note -W: 896. ‘error’ で警告をエラーとして扱
うこともできます。サードパーティによるコードの警告を無視するには、*note
Warnings Filter: 897. を使うことができます。

Python 3.9は、Python 2後方互換性レイヤを提供する最後のバージョンです。こ
のレイヤは、Pythonプロジェクトの保守管理者に、Python 2サポートを止めて
Python 3.9サポートを追加する時間的な余裕を与えるためのものです。

Aliases to *note Abstract Base Classes: 844. in the *note collections:
16. module, like ‘collections.Mapping’ alias to *note
collections.abc.Mapping: 898, are kept for one last release for backward
compatibility.  They will be removed from Python 3.10.

より一般的には、あなたのコードが次のバージョンのPythonと互換性を保てるよ
う、*note Python Development Mode: 1d9. でテストするようにしてください。

注釈: Pythonのこのバージョンで、既存の多くの非推奨機能が削除されました。
詳しくは *note 削除: 899. を見て下さい。


File: python.info,  Node: 新しい機能<5>,  Next: その他の言語変更<3>,  Prev: コード中の非推奨警告 DeprecationWarning をチェックして下さい,  Up: What's New In Python 3 9

1.5.3 新しい機能
----------------

* Menu:

* 辞書のマージと更新演算子::
* prefixとsuffixを削除する新しい文字列メソッド::
* 標準コレクション型の型ヒントにおける総称型 (generics) の使用: 標準コレクション型の型ヒントにおける総称型 generics の使用.
* 新しいパーサー::


File: python.info,  Node: 辞書のマージと更新演算子,  Next: prefixとsuffixを削除する新しい文字列メソッド,  Up: 新しい機能<5>

1.5.3.1 辞書のマージと更新演算子
................................

組み込みの *note dict: 237. クラスにマージ(‘|’)と更新(‘|=’)演算子が追加
されました。この演算子は、辞書をマージする既存の方法 ‘dict.update’ と
‘{**d1, **d2}’ を補完します。

以下はプログラム例です:

     >>> x = {"key1": "value1 from x", "key2": "value2 from x"}
     >>> y = {"key2": "value2 from y", "key3": "value3 from y"}
     >>> x | y
     {'key1': 'value1 from x', 'key2': 'value2 from y', 'key3': 'value3 from y'}
     >>> y | x
     {'key2': 'value2 from x', 'key3': 'value3 from y', 'key1': 'value1 from x'}

詳細は PEP 584(1) を参照してください。(Brandt Bucher の貢献による
bpo-36144(2))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0584/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36144


File: python.info,  Node: prefixとsuffixを削除する新しい文字列メソッド,  Next: 標準コレクション型の型ヒントにおける総称型 generics の使用,  Prev: 辞書のマージと更新演算子,  Up: 新しい機能<5>

1.5.3.2 prefixとsuffixを削除する新しい文字列メソッド
....................................................

文字列から不要な prefix や suffix を簡単に削除する *note
str.removeprefix(prefix): 89d. と *note str.removesuffix(suffix): 89e. が
追加されました。 ‘bytes’, ‘bytearray’, ‘collections.UserString’ にも同様
のメソッドが追加されました。詳細は PEP 616(1) を参照してください。
(Dennis Sweeney の貢献による bpo-39939(2))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0616/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39939


File: python.info,  Node: 標準コレクション型の型ヒントにおける総称型 generics の使用,  Next: 新しいパーサー,  Prev: prefixとsuffixを削除する新しい文字列メソッド,  Up: 新しい機能<5>

1.5.3.3 標準コレクション型の型ヒントにおける総称型 (generics) の使用
....................................................................

型アノテーションで、‘typing’ モジュールからインポートしていた大文字の型
（‘List’ や ‘Dict’）の代わりに、総称型（generics）で ‘list’ や ‘dict’ と
いった標準コレクション型が使用できるようになりました。いくつかの他の標準
ライブラリの型（‘queue.Queue’ など）も総称型として使用できます。

例:

     def greet_all(names: list[str]) -> None:
         for name in names:
             print("Hello", name)

詳細は PEP 585(1) を参照してください。(Guido van Rossum、Ethan Smith、
Batuhan Taşkaya の貢献による bpo-39481(2))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39481


File: python.info,  Node: 新しいパーサー,  Prev: 標準コレクション型の型ヒントにおける総称型 generics の使用,  Up: 新しい機能<5>

1.5.3.4 新しいパーサー
......................

Python 3.9は、 LL(1)(1) に代えて PEG(2) に基づく新しいパーサーを採用して
います。新しいパーサーのパフォーマンスは古いパーサーとほぼ同程度ですが、
新しい言語の機能を設計する際に、PEGの形式主義はより柔軟です。我々は、こ
の柔軟性をPython 3.10以降に使い始める予定です。

*note ast: 7. モジュールは、新しいパーサーを使って古いパーサーと同じ
ASTを生成します。

In Python 3.10, the old parser will be deleted and so will all
functionality that depends on it (primarily the ‘parser’ module, which
has long been deprecated).  In Python 3.9 'only', you can switch back to
the LL(1) parser using a command line switch (‘-X oldparser’) or an
environment variable (‘PYTHONOLDPARSER=1’).

詳細は PEP 617(3) を参照してください。(Guido van Rossum,、Pablo Galindo、
およびLysandros Nikolaouの貢献による bpo-40334(4))

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/LL_parser

   (2) https://en.wikipedia.org/wiki/Parsing_expression_grammar

   (3) https://peps.python.org/pep-0617/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40334


File: python.info,  Node: その他の言語変更<3>,  Next: 新たなモジュール<3>,  Prev: 新しい機能<5>,  Up: What's New In Python 3 9

1.5.4 その他の言語変更
----------------------

   * *note __import__(): 8a2. now raises *note ImportError: 3f2. instead
     of *note ValueError: 1e3, which used to occur when a relative
     import went past its top-level package.  (Contributed by Ngalim
     Siregar in bpo-37444(1).)

   * Python now gets the absolute path of the script filename specified
     on the command line (ex: ‘python3 script.py’): the ‘__file__’
     attribute of the *note __main__: 1. module became an absolute path,
     rather than a relative path.  These paths now remain valid after
     the current directory is changed by *note os.chdir(): 5d8.  As a
     side effect, the traceback also displays the absolute path for
     *note __main__: 1. module frames in this case.  (Contributed by
     Victor Stinner in bpo-20443(2).)

   * In the *note Python Development Mode: 1d9. and in *note debug
     build: 1da, the 'encoding' and 'errors' arguments are now checked
     for string encoding and decoding operations.  Examples: *note
     open(): 4e5, *note str.encode(): 8a3. and *note bytes.decode():
     8a4.

     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.  (Contributed by
     Victor Stinner in bpo-37388(3).)

   * ‘"".replace("", s, n)’ now returns ‘s’ instead of an empty string
     for all non-zero ‘n’.  It is now consistent with ‘"".replace("",
     s)’.  There are similar changes for *note bytes: 1a4. and *note
     bytearray: 508. objects.  (Contributed by Serhiy Storchaka in
     bpo-28029(4).)

   * Any valid expression can now be used as a *note decorator: 6fc.
     Previously, the grammar was much more restrictive.  See PEP 614(5)
     for details.  (Contributed by Brandt Bucher in bpo-39702(6).)

   * Improved help for the *note typing: ed. module.  Docstrings are now
     shown for all special forms and special generic aliases (like
     ‘Union’ and ‘List’).  Using *note help(): 8a5. with generic alias
     like ‘List[int]’ will show the help for the correspondent concrete
     type (‘list’ in this case).  (Contributed by Serhiy Storchaka in
     bpo-40257(7).)

   * Parallel running of *note aclose(): 8a6. / *note asend(): 8a7. /
     *note athrow(): 4c6. is now prohibited, and ‘ag_running’ now
     reflects the actual running status of the async generator.
     (Contributed by Yury Selivanov in bpo-30773(8).)

   * Unexpected errors in calling the ‘__iter__’ method are no longer
     masked by ‘TypeError’ in the *note in: 2cb. operator and functions
     *note contains(): 8a8, *note indexOf(): 8a9. and *note countOf():
     8aa. of the *note operator: 8f. module.  (Contributed by Serhiy
     Storchaka in bpo-40824(9).)

   * Unparenthesized lambda expressions can no longer be the expression
     part in an ‘if’ clause in comprehensions and generator expressions.
     See bpo-41848(10) and bpo-43755(11) for details.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37444

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20443

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37388

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28029

   (5) https://peps.python.org/pep-0614/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39702

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40257

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30773

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40824

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41848

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43755


File: python.info,  Node: 新たなモジュール<3>,  Next: 改良されたモジュール<3>,  Prev: その他の言語変更<3>,  Up: What's New In Python 3 9

1.5.5 新たなモジュール
----------------------

* Menu:

* zoneinfo::
* graphlib::


File: python.info,  Node: zoneinfo,  Next: graphlib,  Up: 新たなモジュール<3>

1.5.5.1 zoneinfo
................

*note zoneinfo: 11a. モジュールにより標準ライブラリにIANAのタイムゾーン
データベースへのサポートを導入されます。*note zoneinfo.ZoneInfo: 8ad. と
いう、システムのタイムゾーンデータを背景とした具体的な *note
datetime.tzinfo: 5a8. の実装が追加されます。

以下はプログラム例です:

     >>> from zoneinfo import ZoneInfo
     >>> from datetime import datetime, timedelta

     >>> # Daylight saving time
     >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles"))
     >>> print(dt)
     2020-10-31 12:00:00-07:00
     >>> dt.tzname()
     'PDT'

     >>> # Standard time
     >>> dt += timedelta(days=7)
     >>> print(dt)
     2020-11-07 12:00:00-08:00
     >>> print(dt.tzname())
     PST

As a fall-back source of data for platforms that don't ship the IANA
database, the tzdata(1) module was released as a first-party package -
distributed via PyPI and maintained by the CPython core team.

参考
....

PEP 615(2) - Support for the IANA Time Zone Database in the Standard Library

     PEP作成と実装は Paul Ganssle による。

   ---------- Footnotes ----------

   (1) https://pypi.org/project/tzdata/

   (2) https://peps.python.org/pep-0615/


File: python.info,  Node: graphlib,  Prev: zoneinfo,  Up: 新たなモジュール<3>

1.5.5.2 graphlib
................

A new module, *note graphlib: 5b, was added that contains the *note
graphlib.TopologicalSorter: 8af. class to offer functionality to perform
topological sorting of graphs.  (Contributed by Pablo Galindo, Tim
Peters and Larry Hastings in bpo-17005(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17005


File: python.info,  Node: 改良されたモジュール<3>,  Next: 最適化<3>,  Prev: 新たなモジュール<3>,  Up: What's New In Python 3 9

1.5.6 改良されたモジュール
--------------------------

* Menu:

* ast: ast<2>.
* asyncio: asyncio<5>.
* compileall: compileall<2>.
* concurrent.futures: concurrent futures<2>.
* curses: curses<2>.
* datetime: datetime<2>.
* distutils: distutils<3>.
* fcntl: fcntl<2>.
* ftplib: ftplib<2>.
* gc: gc<2>.
* hashlib: hashlib<4>.
* http::
* IDLE と idelelib: IDLE と idelelib<3>.
* imaplib::
* importlib: importlib<3>.
* inspect: inspect<4>.
* ipaddress: ipaddress<2>.
* math: math<4>.
* multiprocessing: multiprocessing<2>.
* nntplib::
* os: os<5>.
* pathlib: pathlib<6>.
* pdb: pdb<3>.
* poplib::
* pprint: pprint<2>.
* pydoc::
* random: random<3>.
* signal::
* smtplib::
* socket: socket<3>.
* time: time<3>.
* sys: sys<6>.
* tracemalloc::
* typing: typing<6>.
* unicodedata: unicodedata<4>.
* venv: venv<3>.
* xml: xml<3>.


File: python.info,  Node: ast<2>,  Next: asyncio<5>,  Up: 改良されたモジュール<3>

1.5.6.1 ast
...........

Added the 'indent' option to *note dump(): 8b2. which allows it to
produce a multiline indented output.  (Contributed by Serhiy Storchaka
in bpo-37995(1).)

Added *note ast.unparse(): 8b3. as a function in the *note ast: 7.
module that can be used to unparse an *note ast.AST: 18b. object and
produce a string with code that would produce an equivalent *note
ast.AST: 18b. object when parsed.  (Contributed by Pablo Galindo and
Batuhan Taskaya in bpo-38870(2).)

Added docstrings to AST nodes that contains the ASDL signature used to
construct that node.  (Contributed by Batuhan Taskaya in bpo-39638(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37995

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38870

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39638


File: python.info,  Node: asyncio<5>,  Next: compileall<2>,  Prev: ast<2>,  Up: 改良されたモジュール<3>

1.5.6.2 asyncio
...............

セキュリティ上の重大な懸念により、*note
asyncio.loop.create_datagram_endpoint(): 6fe. での 'reuse_address' 引数
は無効になりました。これはソケットオプション ‘SO_REUSEADDR'’ のUDP にお
ける挙動が原因です。詳しくは、‘loop.create_datagram_endpoint()’ のドキュ
メントを参照してください。(Kyle Stanley, Antoine Pitrou, Yury Selivanov
による貢献 bpo-37228(1))

Added a new *note coroutine: 45e. *note shutdown_default_executor():
8b5. that schedules a shutdown for the default executor that waits on
the *note ThreadPoolExecutor: 70d. to finish closing.  Also, *note
asyncio.run(): 449. has been updated to use the new *note coroutine:
45e.  (Contributed by Kyle Stanley in bpo-34037(2).)

Added *note asyncio.PidfdChildWatcher: 446, a Linux-specific child
watcher implementation that polls process file descriptors.
(bpo-38692(3))

Added a new *note coroutine: 45e. *note asyncio.to_thread(): 8b6.  It is
mainly used for running IO-bound functions in a separate thread to avoid
blocking the event loop, and essentially works as a high-level version
of *note run_in_executor(): 8b7. that can directly take keyword
arguments.  (Contributed by Kyle Stanley and Yury Selivanov in
bpo-32309(4).)

When cancelling the task due to a timeout, *note asyncio.wait_for():
5ca. will now wait until the cancellation is complete also in the case
when 'timeout' is <= 0, like it does with positive timeouts.
(Contributed by Elvis Pranskevichus in bpo-32751(5).)

*note asyncio: 8. now raises *note TypeError: 502. when calling
incompatible methods with an *note ssl.SSLSocket: 8b8. socket.
(Contributed by Ido Michael in bpo-37404(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37228

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34037

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38692

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32309

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32751

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37404


File: python.info,  Node: compileall<2>,  Next: concurrent futures<2>,  Prev: asyncio<5>,  Up: 改良されたモジュール<3>

1.5.6.3 compileall
..................

Added new possibility to use hardlinks for duplicated ‘.pyc’ files:
'hardlink_dupes' parameter and -hardlink-dupes command line option.
(Contributed by Lumír 'Frenzy' Balhar in bpo-40495(1).)

Added new options for path manipulation in resulting ‘.pyc’ files:
'stripdir', 'prependdir', 'limit_sl_dest' parameters and -s, -p, -e
command line options.  Added the possibility to specify the option for
an optimization level multiple times.  (Contributed by Lumír 'Frenzy'
Balhar in bpo-38112(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40495

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38112


File: python.info,  Node: concurrent futures<2>,  Next: curses<2>,  Prev: compileall<2>,  Up: 改良されたモジュール<3>

1.5.6.4 concurrent.futures
..........................

Added a new 'cancel_futures' parameter to *note
concurrent.futures.Executor.shutdown(): 8bb. that cancels all pending
futures which have not started running, instead of waiting for them to
complete before shutting down the executor.  (Contributed by Kyle
Stanley in bpo-39349(1).)

Removed daemon threads from *note ThreadPoolExecutor: 70d. and *note
ProcessPoolExecutor: 8bc.  This improves compatibility with
subinterpreters and predictability in their shutdown processes.
(Contributed by Kyle Stanley in bpo-39812(2).)

Workers in *note ProcessPoolExecutor: 8bc. are now spawned on demand,
only when there are no available idle workers to reuse.  This optimizes
startup overhead and reduces the amount of lost CPU time to idle
workers.  (Contributed by Kyle Stanley in bpo-39207(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39349

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39812

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39207


File: python.info,  Node: curses<2>,  Next: datetime<2>,  Prev: concurrent futures<2>,  Up: 改良されたモジュール<3>

1.5.6.5 curses
..............

*note curses.get_escdelay(): 8be, *note curses.set_escdelay(): 8bf,
*note curses.get_tabsize(): 8c0, *note curses.set_tabsize(): 8c1. の関数
が追加されました。(Anthony Sottileによる bpo-38312(1) でのコントリビュー
ト。)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38312


File: python.info,  Node: datetime<2>,  Next: distutils<3>,  Prev: curses<2>,  Up: 改良されたモジュール<3>

1.5.6.6 datetime
................

The *note isocalendar(): 8c3. of *note datetime.date: 1af. and *note
isocalendar(): 8c4. of *note datetime.datetime: 1ae. methods now returns
a *note namedtuple(): 1ac. instead of a *note tuple: 349.  (Contributed
by Donghee Na in bpo-24416(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24416


File: python.info,  Node: distutils<3>,  Next: fcntl<2>,  Prev: datetime<2>,  Up: 改良されたモジュール<3>

1.5.6.7 distutils
.................

The ‘upload’ command now creates SHA2-256 and Blake2b-256 hash digests.
It skips MD5 on platforms that block MD5 digest.  (Contributed by
Christian Heimes in bpo-40698(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40698


File: python.info,  Node: fcntl<2>,  Next: ftplib<2>,  Prev: distutils<3>,  Up: 改良されたモジュール<3>

1.5.6.8 fcntl
.............

Added constants ‘F_OFD_GETLK’, ‘F_OFD_SETLK’ and ‘F_OFD_SETLKW’.
(Contributed by Donghee Na in bpo-38602(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38602


File: python.info,  Node: ftplib<2>,  Next: gc<2>,  Prev: fcntl<2>,  Up: 改良されたモジュール<3>

1.5.6.9 ftplib
..............

*note FTP: 8c8. and *note FTP_TLS: 8c9. now raise a *note ValueError:
1e3. if the given timeout for their constructor is zero to prevent the
creation of a non-blocking socket.  (Contributed by Donghee Na in
bpo-39259(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39259


File: python.info,  Node: gc<2>,  Next: hashlib<4>,  Prev: ftplib<2>,  Up: 改良されたモジュール<3>

1.5.6.10 gc
...........

When the garbage collector makes a collection in which some objects
resurrect (they are reachable from outside the isolated cycles after the
finalizers have been executed), do not block the collection of all
objects that are still unreachable.  (Contributed by Pablo Galindo and
Tim Peters in bpo-38379(1).)

Added a new function *note gc.is_finalized(): 8cb. to check if an object
has been finalized by the garbage collector.  (Contributed by Pablo
Galindo in bpo-39322(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38379

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39322


File: python.info,  Node: hashlib<4>,  Next: http,  Prev: gc<2>,  Up: 改良されたモジュール<3>

1.5.6.11 hashlib
................

The *note hashlib: 5e. module can now use SHA3 hashes and SHAKE XOF from
OpenSSL when available.  (Contributed by Christian Heimes in
bpo-37630(1).)

Builtin hash modules can now be disabled with ‘./configure
--without-builtin-hashlib-hashes’ or selectively enabled with e.g.
‘./configure --with-builtin-hashlib-hashes=sha3,blake2’ to force use of
OpenSSL based implementation.  (Contributed by Christian Heimes in
bpo-40479(2))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37630

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40479


File: python.info,  Node: http,  Next: IDLE と idelelib<3>,  Prev: hashlib<4>,  Up: 改良されたモジュール<3>

1.5.6.12 http
.............

HTTP status codes ‘103 EARLY_HINTS’, ‘418 IM_A_TEAPOT’ and ‘425
TOO_EARLY’ are added to *note http.HTTPStatus: 8ce.  (Contributed by
Donghee Na in bpo-39509(1) and Ross Rhodes in bpo-39507(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39509

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39507


File: python.info,  Node: IDLE と idelelib<3>,  Next: imaplib,  Prev: http,  Up: 改良されたモジュール<3>

1.5.6.13 IDLE と idelelib
.........................

Added option to toggle cursor blink off.  (Contributed by Zackery Spytz
in bpo-4603(1).)

Escape key now closes IDLE completion windows.  (Contributed by Johnny
Najera in bpo-38944(2).)

Added keywords to module name completion list.  (Contributed by Terry J.
Reedy in bpo-37765(3).)

New in 3.9 maintenance releases

Make IDLE invoke *note sys.excepthook(): 7d6. (when started without
'-n').  User hooks were previously ignored.  (Contributed by Ken Hilton
in bpo-43008(4).)

The changes above have been backported to 3.8 maintenance releases.

Rearrange the settings dialog.  Split the General tab into Windows and
Shell/Ed tabs.  Move help sources, which extend the Help menu, to the
Extensions tab.  Make space for new options and shorten the dialog.  The
latter makes the dialog better fit small screens.  (Contributed by Terry
Jan Reedy in bpo-40468(5).)  Move the indent space setting from the Font
tab to the new Windows tab.  (Contributed by Mark Roseman and Terry Jan
Reedy in bpo-33962(6).)

Apply syntax highlighting to ‘.pyi’ files.  (Contributed by Alex Waygood
and Terry Jan Reedy in bpo-45447(7).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4603

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38944

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37765

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43008

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40468

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33962

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45447


File: python.info,  Node: imaplib,  Next: importlib<3>,  Prev: IDLE と idelelib<3>,  Up: 改良されたモジュール<3>

1.5.6.14 imaplib
................

*note IMAP4: 8d1. and *note IMAP4_SSL: 8d2. now have an optional
'timeout' parameter for their constructors.  Also, the *note open():
8d3. method now has an optional 'timeout' parameter with this change.
The overridden methods of *note IMAP4_SSL: 8d2. and *note IMAP4_stream:
8d4. were applied to this change.  (Contributed by Donghee Na in
bpo-38615(1).)

*note imaplib.IMAP4.unselect(): 8d5. is added.  *note
imaplib.IMAP4.unselect(): 8d5. frees server's resources associated with
the selected mailbox and returns the server to the authenticated state.
This command performs the same actions as *note imaplib.IMAP4.close():
8d6, except that no messages are permanently removed from the currently
selected mailbox.  (Contributed by Donghee Na in bpo-40375(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38615

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40375


File: python.info,  Node: importlib<3>,  Next: inspect<4>,  Prev: imaplib,  Up: 改良されたモジュール<3>

1.5.6.15 importlib
..................

To improve consistency with import statements, *note
importlib.util.resolve_name(): 8d8. now raises *note ImportError: 3f2.
instead of *note ValueError: 1e3. for invalid relative import attempts.
(Contributed by Ngalim Siregar in bpo-37444(1).)

Import loaders which publish immutable module objects can now publish
immutable packages in addition to individual modules.  (Contributed by
Dino Viehland in bpo-39336(2).)

Added *note importlib.resources.files(): 45b. function with support for
subdirectories in package data, matching backport in
‘importlib_resources’ version 1.5.  (Contributed by Jason R. Coombs in
bpo-39791(3).)

Refreshed ‘importlib.metadata’ from ‘importlib_metadata’ version 1.6.1.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37444

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39336

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39791


File: python.info,  Node: inspect<4>,  Next: ipaddress<2>,  Prev: importlib<3>,  Up: 改良されたモジュール<3>

1.5.6.16 inspect
................

*note inspect.BoundArguments.arguments: 8da. は ‘OrderedDict’ から標準の
dictに変更されました。(Inada Naoki の貢献による bpo-36350(1),
bpo-39775(2))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36350

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39775


File: python.info,  Node: ipaddress<2>,  Next: math<4>,  Prev: inspect<4>,  Up: 改良されたモジュール<3>

1.5.6.17 ipaddress
..................

*note ipaddress: 74. now supports IPv6 Scoped Addresses (IPv6 address
with suffix ‘%<scope_id>’).

Scoped IPv6 addresses can be parsed using *note ipaddress.IPv6Address:
1de.  If present, scope zone ID is available through the *note scope_id:
8dc. attribute.  (Contributed by Oleksandr Pavliuk in bpo-34788(1).)

Starting with Python 3.9.5 the *note ipaddress: 74. module no longer
accepts any leading zeros in IPv4 address strings.  (Contributed by
Christian Heimes in bpo-36384(2)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34788

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36384


File: python.info,  Node: math<4>,  Next: multiprocessing<2>,  Prev: ipaddress<2>,  Up: 改良されたモジュール<3>

1.5.6.18 math
.............

Expanded the *note math.gcd(): 8de. function to handle multiple
arguments.  Formerly, it only supported two arguments.  (Contributed by
Serhiy Storchaka in bpo-39648(1).)

Added *note math.lcm(): 8df.: return the least common multiple of
specified arguments.  (Contributed by Mark Dickinson, Ananthakrishnan
and Serhiy Storchaka in bpo-39479(2) and bpo-39648(3).)

Added *note math.nextafter(): 465.: return the next floating-point value
after 'x' towards 'y'.  (Contributed by Victor Stinner in bpo-39288(4).)

Added *note math.ulp(): 8e0.: return the value of the least significant
bit of a float.  (Contributed by Victor Stinner in bpo-39310(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39648

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39479

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39648

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39288

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39310


File: python.info,  Node: multiprocessing<2>,  Next: nntplib,  Prev: math<4>,  Up: 改良されたモジュール<3>

1.5.6.19 multiprocessing
........................

The *note multiprocessing.SimpleQueue: 8e2. class has a new *note
close(): 8e3. method to explicitly close the queue.  (Contributed by
Victor Stinner in bpo-30966(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30966


File: python.info,  Node: nntplib,  Next: os<5>,  Prev: multiprocessing<2>,  Up: 改良されたモジュール<3>

1.5.6.20 nntplib
................

‘NNTP’ and ‘NNTP_SSL’ now raise a *note ValueError: 1e3. if the given
timeout for their constructor is zero to prevent the creation of a
non-blocking socket.  (Contributed by Donghee Na in bpo-39259(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39259


File: python.info,  Node: os<5>,  Next: pathlib<6>,  Prev: nntplib,  Up: 改良されたモジュール<3>

1.5.6.21 os
...........

Added *note CLD_KILLED: 8e6. and *note CLD_STOPPED: 8e7. for ‘si_code’.
(Contributed by Donghee Na in bpo-38493(1).)

Exposed the Linux-specific *note os.pidfd_open(): 447. (bpo-38692(2))
and *note os.P_PIDFD: 8e8. (bpo-38713(3)) for process management with
file descriptors.

*note os.unsetenv(): 8e9. 関数が、Windowsでも使えるようになりました。
(bpo-39413(4) におけるVictor Stinnerの貢献による)

*note os.putenv(): 8ea. と *note os.unsetenv(): 8e9. 関数が、常に利用で
きるようになりました。(bpo-39395(5) におけるVictor Stinnerの貢献による)

Added *note os.waitstatus_to_exitcode(): 8eb. function: convert a wait
status to an exit code.  (Contributed by Victor Stinner in
bpo-40094(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38493

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38692

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38713

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39413

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39395

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40094


File: python.info,  Node: pathlib<6>,  Next: pdb<3>,  Prev: os<5>,  Up: 改良されたモジュール<3>

1.5.6.22 pathlib
................

Added *note pathlib.Path.readlink(): 8ed. which acts similarly to *note
os.readlink(): 8ee.  (Contributed by Girts Folkmanis in bpo-30618(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30618


File: python.info,  Node: pdb<3>,  Next: poplib,  Prev: pathlib<6>,  Up: 改良されたモジュール<3>

1.5.6.23 pdb
............

On Windows now *note Pdb: 8f0. supports ‘~/.pdbrc’.  (Contributed by Tim
Hopper and Dan Lidral-Porter in bpo-20523(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20523


File: python.info,  Node: poplib,  Next: pprint<2>,  Prev: pdb<3>,  Up: 改良されたモジュール<3>

1.5.6.24 poplib
...............

*note POP3: 8f2. and *note POP3_SSL: 8f3. now raise a *note ValueError:
1e3. if the given timeout for their constructor is zero to prevent the
creation of a non-blocking socket.  (Contributed by Donghee Na in
bpo-39259(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39259


File: python.info,  Node: pprint<2>,  Next: pydoc,  Prev: poplib,  Up: 改良されたモジュール<3>

1.5.6.25 pprint
...............

*note pprint: 9c. can now pretty-print *note types.SimpleNamespace: 1b3.
(Contributed by Carl Bordum Hansen in bpo-37376(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37376


File: python.info,  Node: pydoc,  Next: random<3>,  Prev: pprint<2>,  Up: 改良されたモジュール<3>

1.5.6.26 pydoc
..............

The documentation string is now shown not only for class, function,
method etc, but for any object that has its own *note __doc__: 8f6.
attribute.  (Contributed by Serhiy Storchaka in bpo-40257(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40257


File: python.info,  Node: random<3>,  Next: signal,  Prev: pydoc,  Up: 改良されたモジュール<3>

1.5.6.27 random
...............

ランダムなbytesを生成する ‘random.Random.randbytes’ メソッドが追加されま
した。(Victor Stinner による貢献 bpo-40286(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40286


File: python.info,  Node: signal,  Next: smtplib,  Prev: random<3>,  Up: 改良されたモジュール<3>

1.5.6.28 signal
...............

Exposed the Linux-specific *note signal.pidfd_send_signal(): 8f9. for
sending to signals to a process using a file descriptor instead of a
pid.  (bpo-38712(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38712


File: python.info,  Node: smtplib,  Next: socket<3>,  Prev: signal,  Up: 改良されたモジュール<3>

1.5.6.29 smtplib
................

*note SMTP: 8fb. and *note SMTP_SSL: 8fc. now raise a *note ValueError:
1e3. if the given timeout for their constructor is zero to prevent the
creation of a non-blocking socket.  (Contributed by Donghee Na in
bpo-39259(1).)

*note LMTP: 8fd. constructor now has an optional 'timeout' parameter.
(Contributed by Donghee Na in bpo-39329(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39259

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39329


File: python.info,  Node: socket<3>,  Next: time<3>,  Prev: smtplib,  Up: 改良されたモジュール<3>

1.5.6.30 socket
...............

The *note socket: b8. module now exports the *note CAN_RAW_JOIN_FILTERS:
8ff. constant on Linux 4.1 and greater.  (Contributed by Stefan
Tatschner and Zackery Spytz in bpo-25780(1).)

The socket module now supports the *note CAN_J1939: 900. protocol on
platforms that support it.  (Contributed by Karl Ding in bpo-40291(2).)

The socket module now has the *note socket.send_fds(): 901. and *note
socket.recv_fds(): 902. functions.  (Contributed by Joannah Nanjekye,
Shinya Okano and Victor Stinner in bpo-28724(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25780

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40291

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28724


File: python.info,  Node: time<3>,  Next: sys<6>,  Prev: socket<3>,  Up: 改良されたモジュール<3>

1.5.6.31 time
.............

On AIX, *note thread_time(): 904. is now implemented with
‘thread_cputime()’ which has nanosecond resolution, rather than
‘clock_gettime(CLOCK_THREAD_CPUTIME_ID)’ which has a resolution of 10
milliseconds.  (Contributed by Batuhan Taskaya in bpo-40192(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40192


File: python.info,  Node: sys<6>,  Next: tracemalloc,  Prev: time<3>,  Up: 改良されたモジュール<3>

1.5.6.32 sys
............

Added a new *note sys.platlibdir: 906. attribute: 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.  (Contributed by Jan Matějek, Matěj Cepl,
Charalampos Stratakis and Victor Stinner in bpo-1294959(1).)

Previously, *note sys.stderr: 907. was block-buffered when
non-interactive.  Now ‘stderr’ defaults to always being line-buffered.
(Contributed by Jendrik Seipp in bpo-13601(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1294959

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13601


File: python.info,  Node: tracemalloc,  Next: typing<6>,  Prev: sys<6>,  Up: 改良されたモジュール<3>

1.5.6.33 tracemalloc
....................

Added *note tracemalloc.reset_peak(): 909. to set the peak size of
traced memory blocks to the current size, to measure the peak of
specific pieces of code.  (Contributed by Huon Wilson in bpo-40630(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40630


File: python.info,  Node: typing<6>,  Next: unicodedata<4>,  Prev: tracemalloc,  Up: 改良されたモジュール<3>

1.5.6.34 typing
...............

PEP 593(1) introduced an *note typing.Annotated: 90b. type to decorate
existing types with context-specific metadata and new ‘include_extras’
parameter to *note typing.get_type_hints(): 67d. to access the metadata
at runtime.  (Contributed by Till Varoquaux and Konstantin Kashin.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0593/


File: python.info,  Node: unicodedata<4>,  Next: venv<3>,  Prev: typing<6>,  Up: 改良されたモジュール<3>

1.5.6.35 unicodedata
....................

Unicode データベースが、バージョン 13.0.0 に更新されました。
(bpo-39926(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39926


File: python.info,  Node: venv<3>,  Next: xml<3>,  Prev: unicodedata<4>,  Up: 改良されたモジュール<3>

1.5.6.36 venv
.............

The activation scripts provided by *note venv: f9. now all specify their
prompt customization consistently by always using the value specified by
‘__VENV_PROMPT__’.  Previously some scripts unconditionally used
‘__VENV_PROMPT__’, others only if it happened to be set (which was the
default case), and one used ‘__VENV_NAME__’ instead.  (Contributed by
Brett Cannon in bpo-37663(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37663


File: python.info,  Node: xml<3>,  Prev: venv<3>,  Up: 改良されたモジュール<3>

1.5.6.37 xml
............

White space characters within attributes are now preserved when
serializing *note xml.etree.ElementTree: 10c. to XML file.  EOLNs are no
longer normalized to "n".  This is the result of discussion about how to
interpret section 2.11 of XML spec.  (Contributed by Mefistotelis in
bpo-39011(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39011


File: python.info,  Node: 最適化<3>,  Next: 非推奨<5>,  Prev: 改良されたモジュール<3>,  Up: What's New In Python 3 9

1.5.7 最適化
------------

   * Optimized the idiom for assignment a temporary variable in
     comprehensions.  Now ‘for y in [expr]’ in comprehensions is as fast
     as a simple assignment ‘y = expr’.  For example:

          sums = [s for s in [0] for x in data for s in [s + x]]

     Unlike the ‘:=’ operator this idiom does not leak a variable to the
     outer scope.

     (Contributed by Serhiy Storchaka in bpo-32856(1).)

   * Optimized signal handling in multithreaded applications.  If a
     thread different than the main thread gets a signal, the bytecode
     evaluation loop is no longer interrupted at each bytecode
     instruction to check for pending signals which cannot be handled.
     Only the main thread of the main interpreter can handle signals.

     Previously, the bytecode evaluation loop was interrupted at each
     instruction until the main thread handles signals.  (Contributed by
     Victor Stinner in bpo-40010(2).)

   * Optimized the *note subprocess: c1. module on FreeBSD using
     ‘closefrom()’.  (Contributed by Ed Maste, Conrad Meyer, Kyle Evans,
     Kubilay Kocak and Victor Stinner in bpo-38061(3).)

   * *note PyLong_FromDouble(): 910. is now up to 1.87x faster for
     values that fit into long.  (Contributed by Sergey Fedoseev in
     bpo-37986(4).)

   * A number of Python builtins (*note range: 911, *note tuple: 349,
     *note set: 5a3, *note frozenset: 5a4, *note list: 5dc, *note dict:
     237.) are now sped up by using PEP 590(5) vectorcall protocol.
     (Contributed by Donghee Na, Mark Shannon, Jeroen Demeyer and Petr
     Viktorin in bpo-37207(6).)

   * Optimized ‘difference_update()’ for the case when the other set is
     much larger than the base set.  (Suggested by Evgeny Kapun with
     code contributed by Michele Orrù in bpo-8425(7).)

   * Python's small object allocator (‘obmalloc.c’) now allows (no more
     than) one empty arena to remain available for immediate reuse,
     without returning it to the OS. This prevents thrashing in simple
     loops where an arena could be created and destroyed anew on each
     iteration.  (Contributed by Tim Peters in bpo-37257(8).)

   * *note floor division: 912. of float operation now has a better
     performance.  Also the message of *note ZeroDivisionError: 913. for
     this operation is updated.  (Contributed by Donghee Na in
     bpo-39434(9).)

   * Decoding short ASCII strings with UTF-8 and ascii codecs is now
     about 15% faster.  (Contributed by Inada Naoki in bpo-37348(10).)

Here's a summary of performance improvements from Python 3.4 through
Python 3.9:

     Python version                       3.4     3.5     3.6     3.7     3.8    3.9
     --------------                       ---     ---     ---     ---     ---    ---

     Variable and attribute read access:
         read_local                       7.1     7.1     5.4     5.1     3.9    3.9
         read_nonlocal                    7.1     8.1     5.8     5.4     4.4    4.5
         read_global                     15.5    19.0    14.3    13.6     7.6    7.8
         read_builtin                    21.1    21.6    18.5    19.0     7.5    7.8
         read_classvar_from_class        25.6    26.5    20.7    19.5    18.4   17.9
         read_classvar_from_instance     22.8    23.5    18.8    17.1    16.4   16.9
         read_instancevar                32.4    33.1    28.0    26.3    25.4   25.3
         read_instancevar_slots          27.8    31.3    20.8    20.8    20.2   20.5
         read_namedtuple                 73.8    57.5    45.0    46.8    18.4   18.7
         read_boundmethod                37.6    37.9    29.6    26.9    27.7   41.1

     Variable and attribute write access:
         write_local                      8.7     9.3     5.5     5.3     4.3    4.3
         write_nonlocal                  10.5    11.1     5.6     5.5     4.7    4.8
         write_global                    19.7    21.2    18.0    18.0    15.8   16.7
         write_classvar                  92.9    96.0   104.6   102.1    39.2   39.8
         write_instancevar               44.6    45.8    40.0    38.9    35.5   37.4
         write_instancevar_slots         35.6    36.1    27.3    26.6    25.7   25.8

     Data structure read access:
         read_list                       24.2    24.5    20.8    20.8    19.0   19.5
         read_deque                      24.7    25.5    20.2    20.6    19.8   20.2
         read_dict                       24.3    25.7    22.3    23.0    21.0   22.4
         read_strdict                    22.6    24.3    19.5    21.2    18.9   21.5

     Data structure write access:
         write_list                      27.1    28.5    22.5    21.6    20.0   20.0
         write_deque                     28.7    30.1    22.7    21.8    23.5   21.7
         write_dict                      31.4    33.3    29.3    29.2    24.7   25.4
         write_strdict                   28.4    29.9    27.5    25.2    23.1   24.5

     Stack (or queue) operations:
         list_append_pop                 93.4   112.7    75.4    74.2    50.8   50.6
         deque_append_pop                43.5    57.0    49.4    49.2    42.5   44.2
         deque_append_popleft            43.7    57.3    49.7    49.7    42.8   46.4

     Timing loop:
         loop_overhead                    0.5     0.6     0.4     0.3     0.3    0.3

These results were generated from the variable access benchmark script
at: ‘Tools/scripts/var_access_benchmark.py’.  The benchmark script
displays timings in nanoseconds.  The benchmarks were measured on an
Intel® Core™ i7-4960HQ processor(11) running the macOS 64-bit builds
found at python.org(12).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32856

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40010

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38061

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37986

   (5) https://peps.python.org/pep-0590/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (7) https://bugs.python.org/issue?@action=redirect&bpo=8425

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37257

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39434

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37348

   (11) 
https://ark.intel.com/content/www/us/en/ark/products/76088/intel-core-i7-4960hq-processor-6m-cache-up-to-3-80-ghz.html

   (12) https://www.python.org/downloads/macos/


File: python.info,  Node: 非推奨<5>,  Next: 削除<5>,  Prev: 最適化<3>,  Up: What's New In Python 3 9

1.5.8 非推奨
------------

   * distutilsの ‘bdist_msi’ コマンドは、現在非推奨です。代わりに、
     ‘bdist_wheel’ (wheelパッケージ)を使って下さい。 ( bpo-39586(1) での
     Hugo van Kemenadeによる貢献による)

   * Currently *note math.factorial(): 915. accepts *note float: 2ce.
     instances with non-negative integer values (like ‘5.0’).  It raises
     a *note ValueError: 1e3. for non-integral and negative floats.  It
     is now deprecated.  In future Python versions it will raise a *note
     TypeError: 502. for all floats.  (Contributed by Serhiy Storchaka
     in bpo-37315(2).)

   * The ‘parser’ and ‘symbol’ modules are deprecated and will be
     removed in future versions of Python.  For the majority of use
     cases, users can leverage the Abstract Syntax Tree (AST) generation
     and compilation stage, using the *note ast: 7. module.

   * The Public C API functions ‘PyParser_SimpleParseStringFlags()’,
     ‘PyParser_SimpleParseStringFlagsFilename()’,
     ‘PyParser_SimpleParseFileFlags()’ and ‘PyNode_Compile()’ are
     deprecated and will be removed in Python 3.10 together with the old
     parser.

   * Using *note NotImplemented: 79d. in a boolean context has been
     deprecated, as it is almost exclusively the result of incorrect
     rich comparator implementations.  It will be made a *note
     TypeError: 502. in a future version of Python.  (Contributed by
     Josh Rosenberg in bpo-35712(3).)

   * The *note random: a6. module currently accepts any hashable type as
     a possible seed value.  Unfortunately, some of those types are not
     guaranteed to have a deterministic hash value.  After Python 3.9,
     the module will restrict its seeds to *note None: 641, *note int:
     238, *note float: 2ce, *note str: 418, *note bytes: 1a4, and *note
     bytearray: 508.

   * Opening the *note GzipFile: 3f3. file for writing without
     specifying the 'mode' argument is deprecated.  In future Python
     versions it will always be opened for reading by default.  Specify
     the 'mode' argument for opening it for writing and silencing a
     warning.  (Contributed by Serhiy Storchaka in bpo-28286(4).)

   * Deprecated the ‘split()’ method of ‘_tkinter.TkappType’ in favour
     of the ‘splitlist()’ method which has more consistent and
     predictable behavior.  (Contributed by Serhiy Storchaka in
     bpo-38371(5).)

   * The explicit passing of coroutine objects to *note asyncio.wait():
     44c. has been deprecated and will be removed in version 3.11.
     (Contributed by Yury Selivanov and Kyle Stanley in bpo-34790(6).)

   * binhex4 and hexbin4 standards are now deprecated.  The ‘binhex’
     module and the following *note binascii: c. functions are now
     deprecated:

        * ‘b2a_hqx()’, ‘a2b_hqx()’

        * ‘rlecode_hqx()’, ‘rledecode_hqx()’

     (Contributed by Victor Stinner in bpo-39353(7).)

   * *note ast: 7. classes ‘slice’, ‘Index’ and ‘ExtSlice’ are
     considered deprecated and will be removed in future Python
     versions.  ‘value’ itself should be used instead of ‘Index(value)’.
     ‘Tuple(slices, Load())’ should be used instead of
     ‘ExtSlice(slices)’.  (Contributed by Serhiy Storchaka in
     bpo-34822(8).)

   * *note ast: 7. classes ‘Suite’, ‘Param’, ‘AugLoad’ and ‘AugStore’
     are considered deprecated and will be removed in future Python
     versions.  They were not generated by the parser and not accepted
     by the code generator in Python 3.  (Contributed by Batuhan Taskaya
     in bpo-39639(9) and bpo-39969(10) and Serhiy Storchaka in
     bpo-39988(11).)

   * The ‘PyEval_InitThreads()’ and ‘PyEval_ThreadsInitialized()’
     functions are now deprecated and will be removed in Python 3.11.
     Calling ‘PyEval_InitThreads()’ now does nothing.  The *note GIL:
     13f. is initialized by *note Py_Initialize(): 87a. since Python
     3.7.  (Contributed by Victor Stinner in bpo-39877(12).)

   * Passing ‘None’ as the first argument to the *note shlex.split():
     506. function has been deprecated.  (Contributed by Zackery Spytz
     in bpo-33262(13).)

   * ‘smtpd.MailmanProxy()’ is now deprecated as it is unusable without
     an external module, ‘mailman’.  (Contributed by Samuel Colvin in
     bpo-35800(14).)

   * The ‘lib2to3’ module now emits a *note PendingDeprecationWarning:
     895.  Python 3.9 switched to a PEG parser (see PEP 617(15)), and
     Python 3.10 may include new language syntax that is not parsable by
     lib2to3's LL(1) parser.  The ‘lib2to3’ module may be removed from
     the standard library in a future Python version.  Consider
     third-party alternatives such as LibCST(16) or parso(17).
     (Contributed by Carl Meyer in bpo-40360(18).)

   * *note random.shuffle(): 712. の*random* パラメータは非推奨になりま
     した。(Raymond Hettingerの貢献による bpo-40465(19))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39586

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37315

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35712

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28286

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38371

   (6) https://bugs.python.org/issue?@action=redirect&bpo=34790

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39353

   (8) https://bugs.python.org/issue?@action=redirect&bpo=34822

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39639

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39969

   (11) https://bugs.python.org/issue?@action=redirect&bpo=39988

   (12) https://bugs.python.org/issue?@action=redirect&bpo=39877

   (13) https://bugs.python.org/issue?@action=redirect&bpo=33262

   (14) https://bugs.python.org/issue?@action=redirect&bpo=35800

   (15) https://peps.python.org/pep-0617/

   (16) https://libcst.readthedocs.io/

   (17) https://parso.readthedocs.io/

   (18) https://bugs.python.org/issue?@action=redirect&bpo=40360

   (19) https://bugs.python.org/issue?@action=redirect&bpo=40465


File: python.info,  Node: 削除<5>,  Next: Python 3 9への移植,  Prev: 非推奨<5>,  Up: What's New In Python 3 9

1.5.9 削除
----------

   * The erroneous version at ‘unittest.mock.__version__’ has been
     removed.

   * ‘nntplib.NNTP’: ‘xpath()’ and ‘xgtitle()’ methods have been
     removed.  These methods are deprecated since Python 3.3.
     Generally, these extensions are not supported or not enabled by
     NNTP server administrators.  For ‘xgtitle()’, please use
     ‘nntplib.NNTP.descriptions()’ or ‘nntplib.NNTP.description()’
     instead.  (Contributed by Donghee Na in bpo-39366(1).)

   * *note array.array: 185.: ‘tostring()’ and ‘fromstring()’ methods
     have been removed.  They were aliases to ‘tobytes()’ and
     ‘frombytes()’, deprecated since Python 3.2.  (Contributed by Victor
     Stinner in bpo-38916(2).)

   * The undocumented ‘sys.callstats()’ function has been removed.
     Since Python 3.7, it was deprecated and always returned *note None:
     641.  It required a special build option ‘CALL_PROFILE’ which was
     already removed in Python 3.7.  (Contributed by Victor Stinner in
     bpo-37414(3).)

   * The ‘sys.getcheckinterval()’ and ‘sys.setcheckinterval()’ functions
     have been removed.  They were deprecated since Python 3.2.  Use
     *note sys.getswitchinterval(): 917. and *note
     sys.setswitchinterval(): 918. instead.  (Contributed by Victor
     Stinner in bpo-37392(4).)

   * The C function ‘PyImport_Cleanup()’ has been removed.  It was
     documented as: "Empty the module table.  For internal use only."
     (Contributed by Victor Stinner in bpo-36710(5).)

   * ‘_dummy_thread’ and ‘dummy_threading’ modules have been removed.
     These modules were deprecated since Python 3.7 which requires
     threading support.  (Contributed by Victor Stinner in
     bpo-37312(6).)

   * ‘aifc.openfp()’ alias to ‘aifc.open()’, ‘sunau.openfp()’ alias to
     ‘sunau.open()’, and ‘wave.openfp()’ alias to *note wave.open():
     919. have been removed.  They were deprecated since Python 3.7.
     (Contributed by Victor Stinner in bpo-37320(7).)

   * The ‘isAlive()’ method of *note threading.Thread: 91a. has been
     removed.  It was deprecated since Python 3.8.  Use *note
     is_alive(): 91b. instead.  (Contributed by Donghee Na in
     bpo-37804(8).)

   * Methods ‘getchildren()’ and ‘getiterator()’ of classes *note
     ElementTree: 91c. and *note Element: 2e8. in the *note ElementTree:
     10c. module have been removed.  They were deprecated in Python 3.2.
     Use ‘iter(x)’ or ‘list(x)’ instead of ‘x.getchildren()’ and
     ‘x.iter()’ or ‘list(x.iter())’ instead of ‘x.getiterator()’.
     (Contributed by Serhiy Storchaka in bpo-36543(9).)

   * The old *note plistlib: 99. API has been removed, it was deprecated
     since Python 3.4.  Use the *note load(): 91d, *note loads(): 91e,
     *note dump(): 91f, and *note dumps(): 920. functions.
     Additionally, the 'use_builtin_types' parameter was removed,
     standard *note bytes: 1a4. objects are always used instead.
     (Contributed by Jon Janzen in bpo-36409(10).)

   * The C function ‘PyGen_NeedsFinalizing’ has been removed.  It was
     not documented, tested, or used anywhere within CPython after the
     implementation of PEP 442(11).  Patch by Joannah Nanjekye.
     (Contributed by Joannah Nanjekye in bpo-15088(12))

   * ‘base64.encodestring()’ and ‘base64.decodestring()’, aliases
     deprecated since Python 3.1, have been removed: use *note
     base64.encodebytes(): 921. and *note base64.decodebytes(): 922.
     instead.  (Contributed by Victor Stinner in bpo-39351(13).)

   * ‘fractions.gcd()’ function has been removed, it was deprecated
     since Python 3.5 (bpo-22486(14)): use *note math.gcd(): 8de.
     instead.  (Contributed by Victor Stinner in bpo-39350(15).)

   * The 'buffering' parameter of *note bz2.BZ2File: 832. has been
     removed.  Since Python 3.0, it was ignored and using it emitted a
     *note DeprecationWarning: 18a.  Pass an open file object to control
     how the file is opened.  (Contributed by Victor Stinner in
     bpo-39357(16).)

   * The 'encoding' parameter of *note json.loads(): 923. has been
     removed.  As of Python 3.1, it was deprecated and ignored; using it
     has emitted a *note DeprecationWarning: 18a. since Python 3.8.
     (Contributed by Inada Naoki in bpo-39377(17))

   * ‘with (await asyncio.lock):’ and ‘with (yield from asyncio.lock):’
     statements are not longer supported, use ‘async with lock’ instead.
     The same is correct for ‘asyncio.Condition’ and
     ‘asyncio.Semaphore’.  (Contributed by Andrew Svetlov in
     bpo-34793(18).)

   * The ‘sys.getcounts()’ function, the ‘-X showalloccount’ command
     line option and the ‘show_alloc_count’ field of the C structure
     *note PyConfig: 380. have been removed.  They required a special
     Python build by defining ‘COUNT_ALLOCS’ macro.  (Contributed by
     Victor Stinner in bpo-39489(19).)

   * The ‘_field_types’ attribute of the *note typing.NamedTuple: 290.
     class has been removed.  It was deprecated since Python 3.8.  Use
     the ‘__annotations__’ attribute instead.  (Contributed by Serhiy
     Storchaka in bpo-40182(20).)

   * The ‘symtable.SymbolTable.has_exec()’ method has been removed.  It
     was deprecated since 2006, and only returning ‘False’ when it's
     called.  (Contributed by Batuhan Taskaya in bpo-40208(21))

   * The ‘asyncio.Task.current_task()’ and ‘asyncio.Task.all_tasks()’
     have been removed.  They were deprecated since Python 3.7 and you
     can use *note asyncio.current_task(): 44a. and *note
     asyncio.all_tasks(): 924. instead.  (Contributed by Rémi Lapeyre in
     bpo-40967(22))

   * The ‘unescape()’ method in the *note html.parser.HTMLParser: 843.
     class has been removed (it was deprecated since Python 3.4).  *note
     html.unescape(): 925. should be used for converting character
     references to the corresponding unicode characters.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39366

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38916

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37414

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37392

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36710

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37312

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37320

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37804

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36543

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36409

   (11) https://peps.python.org/pep-0442/

   (12) https://bugs.python.org/issue?@action=redirect&bpo=15088

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39351

   (14) https://bugs.python.org/issue?@action=redirect&bpo=22486

   (15) https://bugs.python.org/issue?@action=redirect&bpo=39350

   (16) https://bugs.python.org/issue?@action=redirect&bpo=39357

   (17) https://bugs.python.org/issue?@action=redirect&bpo=39377

   (18) https://bugs.python.org/issue?@action=redirect&bpo=34793

   (19) https://bugs.python.org/issue?@action=redirect&bpo=39489

   (20) https://bugs.python.org/issue?@action=redirect&bpo=40182

   (21) https://bugs.python.org/issue?@action=redirect&bpo=40208

   (22) https://bugs.python.org/issue?@action=redirect&bpo=40967


File: python.info,  Node: Python 3 9への移植,  Next: Build Changes<5>,  Prev: 削除<5>,  Up: What's New In Python 3 9

1.5.10 Python 3.9への移植
-------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* Python API の変更: Python API の変更<2>.
* C API の変更: C API の変更<4>.
* CPython バイトコードの変更: CPython バイトコードの変更<3>.


File: python.info,  Node: Python API の変更<2>,  Next: C API の変更<4>,  Up: Python 3 9への移植

1.5.10.1 Python API の変更
..........................

   * *note __import__(): 8a2. and *note importlib.util.resolve_name():
     8d8. now raise *note ImportError: 3f2. where it previously raised
     *note ValueError: 1e3.  Callers catching the specific exception
     type and supporting both Python 3.9 and earlier versions will need
     to catch both using ‘except (ImportError, ValueError):’.

   * The *note venv: f9. activation scripts no longer special-case when
     ‘__VENV_PROMPT__’ is set to ‘""’.

   * The *note select.epoll.unregister(): 928. method no longer ignores
     the *note EBADF: 929. error.  (Contributed by Victor Stinner in
     bpo-39239(1).)

   * The 'compresslevel' parameter of *note bz2.BZ2File: 832. became
     keyword-only, since the 'buffering' parameter has been removed.
     (Contributed by Victor Stinner in bpo-39357(2).)

   * Simplified AST for subscription.  Simple indices will be
     represented by their value, extended slices will be represented as
     tuples.  ‘Index(value)’ will return a ‘value’ itself,
     ‘ExtSlice(slices)’ will return ‘Tuple(slices, Load())’.
     (Contributed by Serhiy Storchaka in bpo-34822(3).)

   * The *note importlib: 6b. module now ignores the *note PYTHONCASEOK:
     92a. environment variable when the *note -E: 92b. or *note -I: 92c.
     command line options are being used.

   * The 'encoding' parameter has been added to the classes *note
     ftplib.FTP: 8c8. and *note ftplib.FTP_TLS: 8c9. as a keyword-only
     parameter, and the default encoding is changed from Latin-1 to
     UTF-8 to follow RFC 2640(4).

   * *note asyncio.loop.shutdown_default_executor(): 8b5. has been added
     to *note AbstractEventLoop: 92d, meaning alternative event loops
     that inherit from it should have this method defined.  (Contributed
     by Kyle Stanley in bpo-34037(5).)

   * The constant values of future flags in the *note __future__: 0.
     module is updated in order to prevent collision with compiler
     flags.  Previously ‘PyCF_ALLOW_TOP_LEVEL_AWAIT’ was clashing with
     ‘CO_FUTURE_DIVISION’.  (Contributed by Batuhan Taskaya in
     bpo-39562(6))

   * ‘array('u')’ now uses ‘wchar_t’ as C type instead of ‘Py_UNICODE’.
     This change doesn't affect to its behavior because ‘Py_UNICODE’ is
     alias of ‘wchar_t’ since Python 3.3.  (Contributed by Inada Naoki
     in bpo-34538(7).)

   * The *note logging.getLogger(): 92e. API now returns the root logger
     when passed the name ‘'root'’, whereas previously it returned a
     non-root logger named ‘'root'’.  This could affect cases where user
     code explicitly wants a non-root logger named ‘'root'’, or
     instantiates a logger using ‘logging.getLogger(__name__)’ in some
     top-level module called ‘'root.py'’.  (Contributed by Vinay Sajip
     in bpo-37742(8).)

   * Division handling of *note PurePath: 473. now returns *note
     NotImplemented: 79d. instead of raising a *note TypeError: 502.
     when passed something other than an instance of ‘str’ or *note
     PurePath: 473.  This allows creating compatible classes that don't
     inherit from those mentioned types.  (Contributed by Roger Aiudi in
     bpo-34775(9)).

   * Starting with Python 3.9.5 the *note ipaddress: 74. module no
     longer accepts any leading zeros in IPv4 address strings.  Leading
     zeros are ambiguous and interpreted as octal notation by some
     libraries.  For example the legacy function *note
     socket.inet_aton(): 92f. treats leading zeros as octal notatation.
     glibc implementation of modern *note inet_pton(): 930. does not
     accept any leading zeros.  (Contributed by Christian Heimes in
     bpo-36384(10)).

   * *note codecs.lookup(): 931. now normalizes the encoding name the
     same way as ‘encodings.normalize_encoding()’, except that *note
     codecs.lookup(): 931. also converts the name to lower case.  For
     example, ‘"latex+latin1"’ encoding name is now normalized to
     ‘"latex_latin1"’.  (Contributed by Jordon Xu in bpo-37751(11).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39239

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39357

   (3) https://bugs.python.org/issue?@action=redirect&bpo=34822

   (4) https://datatracker.ietf.org/doc/html/rfc2640.html

   (5) https://bugs.python.org/issue?@action=redirect&bpo=34037

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39562

   (7) https://bugs.python.org/issue?@action=redirect&bpo=34538

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37742

   (9) https://bugs.python.org/issue?@action=redirect&bpo=34775

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36384

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37751


File: python.info,  Node: C API の変更<4>,  Next: CPython バイトコードの変更<3>,  Prev: Python API の変更<2>,  Up: Python 3 9への移植

1.5.10.2 C API の変更
.....................

   * Instances of *note heap-allocated types: 933. (such as those
     created with *note PyType_FromSpec(): 549. and similar APIs) hold a
     reference to their type object since Python 3.8.  As indicated in
     the "Changes in the C API" of Python 3.8, for the vast majority of
     cases, there should be no side effect but for types that have a
     custom *note tp_traverse: 749. function, ensure that all custom
     ‘tp_traverse’ functions of heap-allocated types visit the object's
     type.

          例:

               int
               foo_traverse(foo_struct *self, visitproc visit, void *arg) {
               // Rest of the traverse function
               #if PY_VERSION_HEX >= 0x03090000
                   // This was not needed before Python 3.9 (Python issue 35810 and 40217)
                   Py_VISIT(Py_TYPE(self));
               #endif
               }

     If your traverse function delegates to ‘tp_traverse’ of its base
     class (or another type), ensure that ‘Py_TYPE(self)’ is visited
     only once.  Note that only *note heap type: 933. are expected to
     visit the type in ‘tp_traverse’.

          For example, if your ‘tp_traverse’ function includes:

               base->tp_traverse(self, visit, arg)

          then add:

               #if PY_VERSION_HEX >= 0x03090000
                   // This was not needed before Python 3.9 (bpo-35810 and bpo-40217)
                   if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) {
                       // a heap type's tp_traverse already visited Py_TYPE(self)
                   } else {
                       Py_VISIT(Py_TYPE(self));
                   }
               #else

     (See bpo-35810(1) and bpo-40217(2) for more information.)

   * The functions ‘PyEval_CallObject’, ‘PyEval_CallFunction’,
     ‘PyEval_CallMethod’ and ‘PyEval_CallObjectWithKeywords’ are
     deprecated.  Use *note PyObject_Call(): 376. and its variants
     instead.  (See more details in bpo-29548(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35810

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40217

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29548


File: python.info,  Node: CPython バイトコードの変更<3>,  Prev: C API の変更<4>,  Up: Python 3 9への移植

1.5.10.3 CPython バイトコードの変更
...................................

   * The *note LOAD_ASSERTION_ERROR: 935. opcode was added for handling
     the *note assert: 936. statement.  Previously, the assert statement
     would not work correctly if the *note AssertionError: 675.
     exception was being shadowed.  (Contributed by Zackery Spytz in
     bpo-34880(1).)

   * The *note COMPARE_OP: 937. opcode was split into four distinct
     instructions:

        * ‘COMPARE_OP’ for rich comparisons

        * ‘IS_OP’ for 'is' and 'is not' tests

        * ‘CONTAINS_OP’ for 'in' and 'not in' tests

        * ‘JUMP_IF_NOT_EXC_MATCH’ for checking exceptions in
          'try-except' statements.

     (Contributed by Mark Shannon in bpo-39156(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34880

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39156


File: python.info,  Node: Build Changes<5>,  Next: C API の変更<5>,  Prev: Python 3 9への移植,  Up: What's New In Python 3 9

1.5.11 Build Changes
--------------------

   * Added ‘--with-platlibdir’ option to the ‘configure’ script: name of
     the platform-specific library directory, stored in the new *note
     sys.platlibdir: 906. attribute.  See *note sys.platlibdir: 906.
     attribute for more information.  (Contributed by Jan Matějek, Matěj
     Cepl, Charalampos Stratakis and Victor Stinner in bpo-1294959(1).)

   * The ‘COUNT_ALLOCS’ special build macro has been removed.
     (Contributed by Victor Stinner in bpo-39489(2).)

   * On non-Windows platforms, the ‘setenv()’ and ‘unsetenv()’ functions
     are now required to build Python.  (Contributed by Victor Stinner
     in bpo-39395(3).)

   * On non-Windows platforms, creating ‘bdist_wininst’ installers is
     now officially unsupported.  (See bpo-10945(4) for more details.)

   * When building Python on macOS from source, ‘_tkinter’ now links
     with non-system Tcl and Tk frameworks if they are installed in
     ‘/Library/Frameworks’, as had been the case on older releases of
     macOS. If a macOS SDK is explicitly configured, by using *note
     -enable-universalsdk: 939. or ‘-isysroot’, only the SDK itself is
     searched.  The default behavior can still be overridden with
     ‘--with-tcltk-includes’ and ‘--with-tcltk-libs’.  (Contributed by
     Ned Deily in bpo-34956(5).)

   * Python can now be built for Windows 10 ARM64.  (Contributed by
     Steve Dower in bpo-33125(6).)

   * Some individual tests are now skipped when ‘--pgo’ is used.  The
     tests in question increased the PGO task time significantly and
     likely didn't help improve optimization of the final executable.
     This speeds up the task by a factor of about 15x.  Running the full
     unit test suite is slow.  This change may result in a slightly less
     optimized build since not as many code branches will be executed.
     If you are willing to wait for the much slower build, the old
     behavior can be restored using ‘./configure [..] PROFILE_TASK="-m
     test --pgo-extended"’.  We make no guarantees as to which PGO task
     set produces a faster build.  Users who care should run their own
     relevant benchmarks as results can depend on the environment,
     workload, and compiler tool chain.  (See bpo-36044(7) and
     bpo-37707(8) for more details.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1294959

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39489

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39395

   (4) https://bugs.python.org/issue?@action=redirect&bpo=10945

   (5) https://bugs.python.org/issue?@action=redirect&bpo=34956

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33125

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36044

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37707


File: python.info,  Node: C API の変更<5>,  Next: Python 3 9 1 での重要な変更点,  Prev: Build Changes<5>,  Up: What's New In Python 3 9

1.5.12 C API の変更
-------------------

* Menu:

* 新しい機能: 新しい機能<6>.
* Python 3.9への移植: Python 3 9への移植<2>.
* 削除: 削除<6>.


File: python.info,  Node: 新しい機能<6>,  Next: Python 3 9への移植<2>,  Up: C API の変更<5>

1.5.12.1 新しい機能
...................

   * PEP 573(1): Added *note PyType_FromModuleAndSpec(): 51c. to
     associate a module with a class; *note PyType_GetModule(): 93c. and
     *note PyType_GetModuleState(): 93d. to retrieve the module and its
     state; and *note PyCMethod: 72f. and *note METH_METHOD: 93e. to
     allow a method to access the class it was defined in.  (Contributed
     by Marcel Plch and Petr Viktorin in bpo-38787(2).)

   * Added *note PyFrame_GetCode(): 755. function: get a frame code.
     Added *note PyFrame_GetBack(): 751. function: get the frame next
     outer frame.  (Contributed by Victor Stinner in bpo-40421(3).)

   * Added *note PyFrame_GetLineNumber(): 756. to the limited C API.
     (Contributed by Victor Stinner in bpo-40421(4).)

   * Added *note PyThreadState_GetInterpreter(): 93f. and *note
     PyInterpreterState_Get(): 387. functions to get the interpreter.
     Added *note PyThreadState_GetFrame(): 759. function to get the
     current frame of a Python thread state.  Added *note
     PyThreadState_GetID(): 940. function: get the unique identifier of
     a Python thread state.  (Contributed by Victor Stinner in
     bpo-39947(5).)

   * Added a new public *note PyObject_CallNoArgs(): 375. function to
     the C API, which calls a callable Python object without any
     arguments.  It is the most efficient way to call a callable Python
     object without any argument.  (Contributed by Victor Stinner in
     bpo-37194(6).)

   * Changes in the limited C API (if ‘Py_LIMITED_API’ macro is
     defined):

        * Provide *note Py_EnterRecursiveCall(): 941. and *note
          Py_LeaveRecursiveCall(): 942. as regular functions for the
          limited API. Previously, there were defined as macros, but
          these macros didn't compile with the limited C API which
          cannot access ‘PyThreadState.recursion_depth’ field (the
          structure is opaque in the limited C API).

        * ‘PyObject_INIT()’ and ‘PyObject_INIT_VAR()’ become regular
          "opaque" function to hide implementation details.

     (Contributed by Victor Stinner in bpo-38644(7) and bpo-39542(8).)

   * The *note PyModule_AddType(): 943. function is added to help adding
     a type to a module.  (Contributed by Donghee Na in bpo-40024(9).)

   * Added the functions *note PyObject_GC_IsTracked(): 944. and *note
     PyObject_GC_IsFinalized(): 945. to the public API to allow to query
     if Python objects are being currently tracked or have been already
     finalized by the garbage collector respectively.  (Contributed by
     Pablo Galindo Salgado in bpo-40241(10).)

   * Added ‘_PyObject_FunctionStr()’ to get a user-friendly string
     representation of a function-like object.  (Patch by Jeroen Demeyer
     in bpo-37645(11).)

   * Added *note PyObject_CallOneArg(): 946. for calling an object with
     one positional argument (Patch by Jeroen Demeyer in bpo-37483(12).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0573/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38787

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40421

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40421

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39947

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37194

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38644

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39542

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40024

   (10) https://bugs.python.org/issue?@action=redirect&bpo=40241

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37645

   (12) https://bugs.python.org/issue?@action=redirect&bpo=37483


File: python.info,  Node: Python 3 9への移植<2>,  Next: 削除<6>,  Prev: 新しい機能<6>,  Up: C API の変更<5>

1.5.12.2 Python 3.9への移植
...........................

   * ‘PyInterpreterState.eval_frame’ ( PEP 523(1)) now requires a new
     mandatory 'tstate' parameter (‘PyThreadState*’).  (Contributed by
     Victor Stinner in bpo-38500(2).)

   * Extension modules: *note m_traverse: 948, *note m_clear: 949. and
     *note m_free: 94a. functions of *note PyModuleDef: 94b. are no
     longer called if the module state was requested but is not
     allocated yet.  This is the case immediately after the module is
     created and before the module is executed (*note Py_mod_exec: 94c.
     function).  More precisely, these functions are not called if *note
     m_size: 94d. is greater than 0 and the module state (as returned by
     *note PyModule_GetState(): 94e.) is ‘NULL’.

     Extension modules without module state (‘m_size <= 0’) are not
     affected.

   * If *note Py_AddPendingCall(): 94f. is called in a subinterpreter,
     the function 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.
     (Contributed by Victor Stinner in bpo-39984(3).)

   * The Windows registry is no longer used to initialize *note
     sys.path: 38e. when the ‘-E’ option is used (if *note
     PyConfig.use_environment: 3b3. is set to ‘0’).  This is significant
     when embedding Python on Windows.  (Contributed by Zackery Spytz in
     bpo-8901(4).)

   * The global variable *note PyStructSequence_UnnamedField: 950. is
     now a constant and refers to a constant string.  (Contributed by
     Serhiy Storchaka in bpo-38650(5).)

   * The ‘PyGC_Head’ structure is now opaque.  It is only defined in the
     internal C API (‘pycore_gc.h’).  (Contributed by Victor Stinner in
     bpo-40241(6).)

   * The ‘Py_UNICODE_COPY’, ‘Py_UNICODE_FILL’, ‘PyUnicode_WSTR_LENGTH’,
     ‘PyUnicode_FromUnicode()’, ‘PyUnicode_AsUnicode()’,
     ‘_PyUnicode_AsUnicode’, and ‘PyUnicode_AsUnicodeAndSize()’ are
     marked as deprecated in C. They have been deprecated by PEP 393(7)
     since Python 3.3.  (Contributed by Inada Naoki in bpo-36346(8).)

   * The *note Py_FatalError(): 951. function is replaced with a macro
     which logs automatically the name of the current function, unless
     the ‘Py_LIMITED_API’ macro is defined.  (Contributed by Victor
     Stinner in bpo-39882(9).)

   * The vectorcall protocol now requires that the caller passes only
     strings as keyword names.  (See bpo-37540(10) for more
     information.)

   * Implementation details of a number of macros and functions are now
     hidden:

        * *note PyObject_IS_GC(): 952. macro was converted to a
          function.

        * The ‘PyObject_NEW()’ macro becomes an alias to the *note
          PyObject_New: 953. macro, and the ‘PyObject_NEW_VAR()’ macro
          becomes an alias to the *note PyObject_NewVar: 954. macro.
          They no longer access directly the *note
          PyTypeObject.tp_basicsize: 955. member.

        * ‘PyObject_GET_WEAKREFS_LISTPTR()’ macro was converted to a
          function: the macro accessed directly the *note
          PyTypeObject.tp_weaklistoffset: 956. member.

        * *note PyObject_CheckBuffer(): 372. macro was converted to a
          function: the macro accessed directly the *note
          PyTypeObject.tp_as_buffer: 957. member.

        * *note PyIndex_Check(): 958. is now always declared as an
          opaque function to hide implementation details: removed the
          ‘PyIndex_Check()’ macro.  The macro accessed directly the
          *note PyTypeObject.tp_as_number: 959. member.

     (See bpo-40170(11) for more details.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0523/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38500

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39984

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8901

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38650

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40241

   (7) https://peps.python.org/pep-0393/

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36346

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39882

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37540

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40170


File: python.info,  Node: 削除<6>,  Prev: Python 3 9への移植<2>,  Up: C API の変更<5>

1.5.12.3 削除
.............

   * Excluded ‘PyFPE_START_PROTECT()’ and ‘PyFPE_END_PROTECT()’ macros
     of ‘pyfpe.h’ from the limited C API. (Contributed by Victor Stinner
     in bpo-38835(1).)

   * The ‘tp_print’ slot of *note PyTypeObject: 95b. has been removed.
     It was used for printing objects to files in Python 2.7 and before.
     Since Python 3.0, it has been ignored and unused.  (Contributed by
     Jeroen Demeyer in bpo-36974(2).)

   * Changes in the limited C API (if ‘Py_LIMITED_API’ macro is
     defined):

        * Excluded the following functions from the limited C API:

             * ‘PyThreadState_DeleteCurrent()’ (Contributed by Joannah
               Nanjekye in bpo-37878(3).)

             * ‘_Py_CheckRecursionLimit’

             * ‘_Py_NewReference()’

             * ‘_Py_ForgetReference()’

             * ‘_PyTraceMalloc_NewReference()’

             * ‘_Py_GetRefTotal()’

             * The trashcan mechanism which never worked in the limited
               C API.

             * ‘PyTrash_UNWIND_LEVEL’

             * ‘Py_TRASHCAN_BEGIN_CONDITION’

             * ‘Py_TRASHCAN_BEGIN’

             * ‘Py_TRASHCAN_END’

             * ‘Py_TRASHCAN_SAFE_BEGIN’

             * ‘Py_TRASHCAN_SAFE_END’

        * Moved following functions and definitions to the internal C
          API:

             * ‘_PyDebug_PrintTotalRefs()’

             * ‘_Py_PrintReferences()’

             * ‘_Py_PrintReferenceAddresses()’

             * ‘_Py_tracemalloc_config’

             * ‘_Py_AddToAllObjects()’ (specific to ‘Py_TRACE_REFS’
               build)

     (Contributed by Victor Stinner in bpo-38644(4) and bpo-39542(5).)

   * Removed ‘_PyRuntime.getframe’ hook and removed
     ‘_PyThreadState_GetFrame’ macro which was an alias to
     ‘_PyRuntime.getframe’.  They were only exposed by the internal C
     API. Removed also ‘PyThreadFrameGetter’ type.  (Contributed by
     Victor Stinner in bpo-39946(6).)

   * Removed the following functions from the C API. Call *note
     PyGC_Collect(): 95c. explicitly to clear all free lists.
     (Contributed by Inada Naoki and Victor Stinner in bpo-37340(7),
     bpo-38896(8) and bpo-40428(9).)

        * ‘PyAsyncGen_ClearFreeLists()’

        * ‘PyContext_ClearFreeList()’

        * ‘PyDict_ClearFreeList()’

        * ‘PyFloat_ClearFreeList()’

        * ‘PyFrame_ClearFreeList()’

        * ‘PyList_ClearFreeList()’

        * ‘PyMethod_ClearFreeList()’ and ‘PyCFunction_ClearFreeList()’:
          the free lists of bound method objects have been removed.

        * ‘PySet_ClearFreeList()’: the set free list has been removed in
          Python 3.4.

        * ‘PyTuple_ClearFreeList()’

        * ‘PyUnicode_ClearFreeList()’: the Unicode free list has been
          removed in Python 3.3.

   * Removed ‘_PyUnicode_ClearStaticStrings()’ function.  (Contributed
     by Victor Stinner in bpo-39465(10).)

   * Removed ‘Py_UNICODE_MATCH’.  It has been deprecated by PEP 393(11),
     and broken since Python 3.3.  The *note PyUnicode_Tailmatch(): 886.
     function can be used instead.  (Contributed by Inada Naoki in
     bpo-36346(12).)

   * Cleaned header files of interfaces defined but with no
     implementation.  The public API symbols being removed are:
     ‘_PyBytes_InsertThousandsGroupingLocale’,
     ‘_PyBytes_InsertThousandsGrouping’, ‘_Py_InitializeFromArgs’,
     ‘_Py_InitializeFromWideArgs’, ‘_PyFloat_Repr’, ‘_PyFloat_Digits’,
     ‘_PyFloat_DigitsInit’, ‘PyFrame_ExtendStack’,
     ‘_PyAIterWrapper_Type’, ‘PyNullImporter_Type’, ‘PyCmpWrapper_Type’,
     ‘PySortWrapper_Type’, ‘PyNoArgsFunction’.  (Contributed by Pablo
     Galindo Salgado in bpo-39372(13).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38835

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36974

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37878

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38644

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39542

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39946

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37340

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38896

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40428

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39465

   (11) https://peps.python.org/pep-0393/

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36346

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39372


File: python.info,  Node: Python 3 9 1 での重要な変更点,  Next: Python 3 9 2 での重要な変更点,  Prev: C API の変更<5>,  Up: What's New In Python 3 9

1.5.13 Python 3.9.1 での重要な変更点
------------------------------------

* Menu:

* typing: typing<7>.
* macOS 11.0 (Big Sur) と Appleシリコンの Mac のサポート: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート.


File: python.info,  Node: typing<7>,  Next: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート,  Up: Python 3 9 1 での重要な変更点

1.5.13.1 typing
...............

The behavior of *note typing.Literal: 820. was changed to conform with
PEP 586(1) and to match the behavior of static type checkers specified
in the PEP.

  1. ‘Literal’ now de-duplicates parameters.

  2. Equality comparisons between ‘Literal’ objects are now order
     independent.

  3. ‘Literal’ comparisons now respect types.  For example, ‘Literal[0]
     == Literal[False]’ previously evaluated to ‘True’.  It is now
     ‘False’.  To support this change, the internally used type cache
     now supports differentiating types.

  4. ‘Literal’ objects will now raise a *note TypeError: 502. exception
     during equality comparisons if any of their parameters are not
     *note hashable: 5db.  Note that declaring ‘Literal’ with mutable
     parameters will not throw an error:

          >>> from typing import Literal
          >>> Literal[{0}]
          >>> Literal[{0}] == Literal[{False}]
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          TypeError: unhashable type: 'set'

(bpo-42345(2) でのYurii Karabasの貢献による)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0586/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42345


File: python.info,  Node: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート,  Prev: typing<7>,  Up: Python 3 9 1 での重要な変更点

1.5.13.2 macOS 11.0 (Big Sur) と Appleシリコンの Mac のサポート
...............................................................

As of 3.9.1, Python now fully supports building and running on macOS
11.0 (Big Sur) and on Apple Silicon Macs (based on the ‘ARM64’
architecture).  A new universal build variant, ‘universal2’, is now
available to natively support both ‘ARM64’ and ‘Intel 64’ in one set of
executables.  Binaries can also now be built on current versions of
macOS to be deployed on a range of older macOS versions (tested to 10.9)
while making some newer OS functions and options conditionally available
based on the operating system version in use at runtime ("weaklinking").

(bpo-41100(1) でのRonald OussorenとLawrence D'Annaの貢献による)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41100


File: python.info,  Node: Python 3 9 2 での重要な変更点,  Next: Python 3 9 3 での重要な変更点,  Prev: Python 3 9 1 での重要な変更点,  Up: What's New In Python 3 9

1.5.14 Python 3.9.2 での重要な変更点
------------------------------------

* Menu:

* collections.abc: collections abc<2>.
* urllib.parse: urllib parse<2>.


File: python.info,  Node: collections abc<2>,  Next: urllib parse<2>,  Up: Python 3 9 2 での重要な変更点

1.5.14.1 collections.abc
........................

*note collections.abc.Callable: 7b5. generic now flattens type
parameters, similar to what *note typing.Callable: 790. currently does.
This means that ‘collections.abc.Callable[[int, str], str]’ will have
‘__args__’ of ‘(int, str, str)’; previously this was ‘([int, str],
str)’.  To allow this change, *note types.GenericAlias: 7b6. can now be
subclassed, and a subclass will be returned when subscripting the *note
collections.abc.Callable: 7b5. type.  Code which accesses the arguments
via *note typing.get_args(): 84b. or ‘__args__’ need to account for this
change.  A *note DeprecationWarning: 18a. may be emitted for invalid
forms of parameterizing *note collections.abc.Callable: 7b5. which may
have passed silently in Python 3.9.1.  This *note DeprecationWarning:
18a. will become a *note TypeError: 502. in Python 3.10.  (Contributed
by Ken Jin in bpo-42195(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42195


File: python.info,  Node: urllib parse<2>,  Prev: collections abc<2>,  Up: Python 3 9 2 での重要な変更点

1.5.14.2 urllib.parse
.....................

Earlier Python versions allowed using both ‘;’ and ‘&’ as query
parameter separators in *note urllib.parse.parse_qs(): 25b. and *note
urllib.parse.parse_qsl(): 25a.  Due to security concerns, and to conform
with newer W3C recommendations, this has been changed to allow only a
single separator key, with ‘&’ as the default.  This change also affects
‘cgi.parse()’ and ‘cgi.parse_multipart()’ as they use the affected
functions internally.  For more details, please see their respective
documentation.  (Contributed by Adam Goldschmidt, Senthil Kumaran and
Ken Jin in bpo-42967(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42967


File: python.info,  Node: Python 3 9 3 での重要な変更点,  Next: Python 3 9 5での重要な変更点,  Prev: Python 3 9 2 での重要な変更点,  Up: What's New In Python 3 9

1.5.15 Python 3.9.3 での重要な変更点
------------------------------------

A security fix alters the *note ftplib.FTP: 8c8. behavior to not trust
the IPv4 address sent from the remote server when setting up a passive
data channel.  We reuse the ftp server IP address instead.  For unusual
code requiring the old behavior, set a ‘trust_server_pasv_ipv4_address’
attribute on your FTP instance to ‘True’.  (See gh-87451(1))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/87451


File: python.info,  Node: Python 3 9 5での重要な変更点,  Next: Notable security feature in 3 9 14,  Prev: Python 3 9 3 での重要な変更点,  Up: What's New In Python 3 9

1.5.16 Python 3.9.5での重要な変更点
-----------------------------------

* Menu:

* urllib.parse: urllib parse<3>.


File: python.info,  Node: urllib parse<3>,  Up: Python 3 9 5での重要な変更点

1.5.16.1 urllib.parse
.....................

The presence of newline or tab characters in parts of a URL allows for
some forms of attacks.  Following the WHATWG specification that updates
RFC 3986(1), ASCII newline ‘\n’, ‘\r’ and tab ‘\t’ characters are
stripped from the URL by the parser in *note urllib.parse: f3.
preventing such attacks.  The removal characters are controlled by a new
module level variable ‘urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE’.  (See
gh-88048(2))

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3986.html

   (2) https://github.com/python/cpython/issues/88048


File: python.info,  Node: Notable security feature in 3 9 14,  Next: Notable changes in 3 9 17,  Prev: Python 3 9 5での重要な変更点,  Up: What's New In Python 3 9

1.5.17 Notable security feature in 3.9.14
-----------------------------------------

Converting between *note int: 238. and *note str: 418. in bases other
than 2 (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10
(decimal) now raises a *note ValueError: 1e3. if the number of digits in
string form is above a limit to avoid potential denial of service
attacks due to the algorithmic complexity.  This is a mitigation for CVE
2020-10735(1).  This limit can be configured or disabled by environment
variable, command line flag, or *note sys: c3. APIs.  See the *note
integer string conversion length limitation: 5bf. documentation.  The
default limit is 4300 digits in string form.

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2020-10735


File: python.info,  Node: Notable changes in 3 9 17,  Prev: Notable security feature in 3 9 14,  Up: What's New In Python 3 9

1.5.18 Notable changes in 3.9.17
--------------------------------

* Menu:

* tarfile: tarfile<3>.


File: python.info,  Node: tarfile<3>,  Up: Notable changes in 3 9 17

1.5.18.1 tarfile
................

   * The extraction methods in *note tarfile: c8, and *note
     shutil.unpack_archive(): 438, have a new a 'filter' argument that
     allows limiting tar features than may be surprising or dangerous,
     such as creating files outside the destination directory.  See
     *note Extraction filters: 439. for details.  In Python 3.12, use
     without the 'filter' argument will show a *note DeprecationWarning:
     18a.  In Python 3.14, the default will switch to ‘'data'’.
     (Contributed by Petr Viktorin in PEP 706(1).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0706/


File: python.info,  Node: What's New In Python 3 8,  Next: What's New In Python 3 7,  Prev: What's New In Python 3 9,  Up: What's New in Python

1.6 What's New In Python 3.8
============================


編集者: Raymond Hettinger

This article explains the new features in Python 3.8, compared to 3.7.
Python 3.8 was released on October 14, 2019.  For full details, see the
*note changelog: 122.

* Menu:

* 概要: 概要 -- リリースハイライト<4>. リリースハイライト
* 新しい機能: 新しい機能<7>.
* その他の言語変更: その他の言語変更<4>.
* 新たなモジュール: 新たなモジュール<4>.
* 改良されたモジュール: 改良されたモジュール<4>.
* 最適化: 最適化<4>.
* ビルドならびに C API の変更::
* 非推奨: 非推奨<6>.
* API と機能の削除::
* Python 3.8 への移植: Python 3 8 への移植.
* Python3.8.1 での重要な変更点: Python3 8 1 での重要な変更点.
* Python3.8.2 での重要な変更点: Python3 8 2 での重要な変更点.
* Notable changes in Python 3.8.3: Notable changes in Python 3 8 3.
* Python3.8.8 での重要な変更点: Python3 8 8 での重要な変更点.
* Notable changes in Python 3.8.9: Notable changes in Python 3 8 9.
* Notable changes in Python 3.8.10: Notable changes in Python 3 8 10.
* Notable changes in Python 3.8.10: Notable changes in Python 3 8 10<2>.
* Notable changes in Python 3.8.12: Notable changes in Python 3 8 12.
* Notable security feature in 3.8.14: Notable security feature in 3 8 14.
* Notable changes in 3.8.17: Notable changes in 3 8 17.


File: python.info,  Node: 概要 -- リリースハイライト<4>,  Next: 新しい機能<7>,  Up: What's New In Python 3 8

1.6.1 概要 - リリースハイライト
-------------------------------


File: python.info,  Node: 新しい機能<7>,  Next: その他の言語変更<4>,  Prev: 概要 -- リリースハイライト<4>,  Up: What's New In Python 3 8

1.6.2 新しい機能
----------------

* Menu:

* 代入式::
* 位置専用引数::
* コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム::
* デバッグビルドとリリースビルドのABI 共通化::
* f-string での = を用いたオブジェクトの表現::
* PEP 578; Pythonランタイムの監査フック: PEP 578 Pythonランタイムの監査フック.
* PEP 587; Python 初期化設定: PEP 587 Python 初期化設定.
* PEP 590; Vectorcall; a fast calling protocol for CPython: PEP 590 Vectorcall a fast calling protocol for CPython.
* Pickle プロトコルバージョン 5 による帯域外データバッファ::


File: python.info,  Node: 代入式,  Next: 位置専用引数,  Up: 新しい機能<7>

1.6.2.1 代入式
..............

大きな構文の一部として、変数に値を割り当てる新しい構文 ‘:=’ が追加されま
した。 この構文は セイウチの目と牙(1) に似ているため、「セイウチ演算子」
の愛称で知られています。

以下の例では、代入式により *note len(): 5fa. 関数を二重に呼びだすことを
回避しています:

     if (n := len(a)) > 10:
         print(f"List is too long ({n} elements, expected <= 10)")

同様の利点が、マッチがしたかどうかの判定とサブグループの取得とで2回マッ
チオブジェクトが必要になる、正規表現によるマッチでも、発揮されます:

     discount = 0.0
     if (mo := re.search(r'(\d+)% discount', advertisement)):
         discount = float(mo.group(1)) / 100.0

この演算子は、生成した値をループ終了の判定とループ本体の両方で使用するよ
うな while 文においても、有用です:

     # Loop over fixed length blocks
     while (block := f.read(256)) != '':
         process(block)

動機となったもう 1 つのユースケースは、リスト内包表記においてフィルター
条件の中で計算した値が式の本体でも必要になるところから出てきます:

     [clean_name.title() for name in names
      if (clean_name := normalize('NFC', name)) in allowed_names]

セイウチ演算子の使用は、複雑さを減らしたり可読性を向上させる綺麗なケース
に限るよう努めてください。

完全な説明は PEP 572(2) を参照してください。

(Emily Morehouse の貢献による bpo-35224(3))

   ---------- Footnotes ----------

   (1) 
https://en.wikipedia.org/wiki/Walrus#/media/File:Pacific_Walrus_-_Bull_(8247646168).jpg

   (2) https://peps.python.org/pep-0572/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35224


File: python.info,  Node: 位置専用引数,  Next: コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム,  Prev: 代入式,  Up: 新しい機能<7>

1.6.2.2 位置専用引数
....................

There is a new function parameter syntax ‘/’ to indicate that some
function parameters must be specified positionally and cannot be used as
keyword arguments.  This is the same notation shown by ‘help()’ for C
functions annotated with Larry Hastings' Argument Clinic(1) tool.

以下の例では、引数 'a' と 'b' が位置専用、 'c' と 'd' が位置引数でもキー
ワード引数でも可、'e' と 'f' はキーワード引数専用です:

     def f(a, b, /, c, d, *, e, f):
         print(a, b, c, d, e, f)

以下は正しい関数呼び出しです:

     f(10, 20, 30, d=40, e=50, f=60)

一方、以下は不正です:

     f(10, b=20, c=30, d=40, e=50, f=60)   # b cannot be a keyword argument
     f(10, 20, 30, 40, 50, f=60)           # e must be a keyword argument

One use case for this notation is that it allows pure Python functions
to fully emulate behaviors of existing C coded functions.  For example,
the built-in *note divmod(): 96f. function does not accept keyword
arguments:

     def divmod(a, b, /):
         "Emulate the built in divmod() function"
         return (a // b, a % b)

もう一つのユースケースは、引数名が有用ではない場合にキーワード引数として
の利用を排除することです。例えば組み込み関数 *note len(): 5fa. は
‘len(obj, /)’ というシグニチャです。これにより、以下のようなぎこちない呼
び出しが排除されます:

     len(obj='hello')  # The "obj" keyword argument impairs readability

引数を位置専用とすることは、のちに引数名を変更する際に呼び出し側のコード
を壊してしまう心配がないという利点があります。例えば、*note statistics:
bd. モジュールでは、'dist' という引数名が将来変更される可能性があります
。これは、関数が以下のような定義だからこそ可能なことです:

     def quantiles(dist, /, *, n=4, method='exclusive')
         ...

Since the parameters to the left of ‘/’ are not exposed as possible
keywords, the parameters names remain available for use in ‘**kwargs’:

     >>> def f(a, b, /, **kwargs):
     ...     print(a, b, kwargs)
     ...
     >>> f(10, 20, a=1, b=2, c=3)         # a and b are used in two ways
     10 20 {'a': 1, 'b': 2, 'c': 3}

これにより、任意のキーワード引数を受け取る関数やメソッドを定義するのが、
ぐんとシンプルになります。例えば、これは *note collections: 16. モジュー
ルから抜き出したコードです：

     class Counter(dict):

         def __init__(self, iterable=None, /, **kwds):
             # Note "iterable" is a possible keyword argument

詳細は PEP 570(2) を参照してください。

(Pablo Galindo の貢献による bpo-36540(3)。)

   ---------- Footnotes ----------

   (1) https://devguide.python.org/development-tools/clinic/

   (2) https://peps.python.org/pep-0570/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36540


File: python.info,  Node: コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム,  Next: デバッグビルドとリリースビルドのABI 共通化,  Prev: 位置専用引数,  Up: 新しい機能<7>

1.6.2.3 コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム
....................................................................................

暗黙のバイトコードキャッシュは、デフォルトでは各ソースコードのディレクト
リ内の ‘__pycache__’ サブディレクトリを使用しますが、新たに追加された環
境変数 *note PYTHONPYCACHEPREFIX: 971. （またはコマンドラインオプション
*note -X: 15c. ‘pycache_prefix’) を指定すると、ソースコードと分離された
ディレクトリツリーに格納されるようになります。

キャッシュの場所は *note sys.pycache_prefix: 972. で参照できます（
‘__pycache__’ を使用する場合は *note None: 641. になります）。

（Carl Meyer の貢献による bpo-33499(1)）

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33499


File: python.info,  Node: デバッグビルドとリリースビルドのABI 共通化,  Next: f-string での = を用いたオブジェクトの表現,  Prev: コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム,  Up: 新しい機能<7>

1.6.2.4 デバッグビルドとリリースビルドのABI 共通化
..................................................

Python はリリースモード、デバッグモード両方のビルドにおいて、同じABI を
用いるようになりました。Unix において、Python がデバッグモードでビルドさ
れている場合、リリースモードで、あるいは安定ABI を用いて、ビルドされた
C拡張モジュールを読み込むことができます。

Release builds and *note debug builds: 1da. are now ABI compatible:
defining the ‘Py_DEBUG’ macro no longer implies the ‘Py_TRACE_REFS’
macro, which introduces the only ABI incompatibility.  The
‘Py_TRACE_REFS’ macro, which adds the *note sys.getobjects(): 3fe.
function and the *note PYTHONDUMPREFS: 974. environment variable, can be
set using the new *note ./configure -with-trace-refs: 36e. build option.
(Contributed by Victor Stinner in bpo-36465(1).)

Unix においては、Android とCygwin を除き、C拡張モジュールはlibpython に
リンクされなくなりました。静的リンクされたPython は、Python 共有ライブラ
リを用いてビルドされたC拡張モジュールを読み込めます。(Victor Stinner の
貢献による bpo-21536(2).)

Unix において、Python がデバッグモードでビルドされている場合、インポート
は、リリースモードで、あるいは安定ABI を用いて、ビルドされたC拡張モジュ
ールを探すようになりました。(Victor Stinner の貢献による bpo-36722(3).)

Python をアプリケーション内に組み込むためには、新しい ‘--embed’ オプショ
ンを有効にして ‘python3-config --libs --embed’ とすると、 ‘-lpython3.8’
を有効にできます。(アプリケーションがlibpython にリンクされます)
Python3.8 以前との互換性を保つためには、 ‘python3-config --libs --embed’
をまず試みてから、失敗した場合 ‘python3-config --libs’ (‘--embed’ なし)
にフォールバックしてください。

Python をアプリケーションに組み込むために、‘python-3.8-embed’ pkg-config
モジュールが追加されました: ‘pkg-config python-3.8-embed --libs’ の出力
は、‘-lpython3.8’ を含みます。 Python3.8 以前との互換性を保つためには、
‘pkg-config python-X.Y-embed --libs’ をまず試みてから、失敗した場合
‘pkg-config python-X.Y --libs’ (‘--embed’ なし) にフォールバックしてくだ
さい。(‘X.Y’ を使用するPython のバージョンに置き換えてください)

一方で、‘pkg-config python3.8 --libs’ は出力に ‘-lpython3.8’ を含まなく
なりました。C拡張モジュールは、libpython にリンクされるべきではありませ
ん。 (スクリプトによって処理される、Android とCygwin を除く) この変更で
は、意図的に後方互換性をなくしています。(Victor Stinner の貢献による
bpo-36721(4))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36465

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21536

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36722

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36721


File: python.info,  Node: f-string での = を用いたオブジェクトの表現,  Next: PEP 578 Pythonランタイムの監査フック,  Prev: デバッグビルドとリリースビルドのABI 共通化,  Up: 新しい機能<7>

1.6.2.5 'f-string' での ‘=’ を用いたオブジェクトの表現
......................................................

フォーマット済み文字列リテラル(*note f-string: 402.) において ‘=’ 指定子
が有効になりました。‘f'{expr=}'’ のようなf-string は、f-string に書かれ
た式、イコール記号、式を評価されたものの文字列表現、の順で表示されます。
例えば:

     >>> user = 'eric_idle'
     >>> member_since = date(1975, 7, 31)
     >>> f'{user=} {member_since=}'
     "user='eric_idle' member_since=datetime.date(1975, 7, 31)"

通常の *note f-string 書式指定子: 977. を用いると、より柔軟に式の結果の
表示方法を変えられます:

     >>> delta = date.today() - member_since
     >>> f'{user=!s}  {delta.days=:,d}'
     'user=eric_idle  delta.days=16,075'

‘=’ 指定子は式すべてを表示するので、次のような計算も表示できます:

     >>> print(f'{theta=}  {cos(radians(theta))=:.3f}')
     theta=30  cos(radians(theta))=0.866

(Eric V. Smith, Larry Hastings の貢献による bpo-36817(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36817


File: python.info,  Node: PEP 578 Pythonランタイムの監査フック,  Next: PEP 587 Python 初期化設定,  Prev: f-string での = を用いたオブジェクトの表現,  Up: 新しい機能<7>

1.6.2.6 PEP 578: Pythonランタイムの監査フック
.............................................

このPEP は、監査用フックと信頼された Open のためのフックを追加します。こ
れらは Python およびネイティブコードから利用できます。純粋に Python で書
かれたフレームワークやアプリケーションはコードに関する追加情報を得ること
ができ、システム管理者や埋め込みでの利用者は Python のビルドを常に監査が
有効な状態で利用できます。

詳細は PEP 578(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0578/


File: python.info,  Node: PEP 587 Python 初期化設定,  Next: PEP 590 Vectorcall a fast calling protocol for CPython,  Prev: PEP 578 Pythonランタイムの監査フック,  Up: 新しい機能<7>

1.6.2.7 PEP 587: Python 初期化設定
..................................

PEP 587(1) による C API の改善により、Python 初期化時に、すべての初期化
設定に対するより良い制御と改善されたエラー報告が得られます。

新たな構造体:

   * *note PyConfig: 380.

   * *note PyPreConfig: 97a.

   * *note PyStatus: 97b.

   * *note PyWideStringList: 97c.

新たな関数:

   * *note PyConfig_Clear(): 97d.

   * *note PyConfig_InitIsolatedConfig(): 97e.

   * *note PyConfig_InitPythonConfig(): 97f.

   * *note PyConfig_Read(): 75b.

   * *note PyConfig_SetArgv(): 980.

   * *note PyConfig_SetBytesArgv(): 981.

   * *note PyConfig_SetBytesString(): 982.

   * *note PyConfig_SetString(): 983.

   * *note PyPreConfig_InitIsolatedConfig(): 984.

   * *note PyPreConfig_InitPythonConfig(): 985.

   * *note PyStatus_Error(): 986.

   * *note PyStatus_Exception(): 987.

   * *note PyStatus_Exit(): 988.

   * *note PyStatus_IsError(): 989.

   * *note PyStatus_IsExit(): 98a.

   * *note PyStatus_NoMemory(): 98b.

   * *note PyStatus_Ok(): 98c.

   * *note PyWideStringList_Append(): 98d.

   * *note PyWideStringList_Insert(): 98e.

   * *note Py_BytesMain(): 98f.

   * *note Py_ExitStatusException(): 990.

   * *note Py_InitializeFromConfig(): 39f.

   * *note Py_PreInitialize(): 3c5.

   * *note Py_PreInitializeFromArgs(): 991.

   * *note Py_PreInitializeFromBytesArgs(): 992.

   * *note Py_RunMain(): 993.

このPEP は、‘_PyRuntimeState.preconfig’ (*note PyPreConfig: 97a. 型) と
‘PyInterpreterState.config’ (*note PyConfig: 380. 型) を内部構造体に加え
ます。‘PyInterpreterState.config’ は新たな参照設定となり、グローバル設定
や他の内部変数を置き換えます。

*note Python 初期化設定: 381. も参照してください。

詳細は PEP 587(2) を参照してください。

(Victor Stinner の貢献による bpo-36763(3))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0587/

   (2) https://peps.python.org/pep-0587/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36763


File: python.info,  Node: PEP 590 Vectorcall a fast calling protocol for CPython,  Next: Pickle プロトコルバージョン 5 による帯域外データバッファ,  Prev: PEP 587 Python 初期化設定,  Up: 新しい機能<7>

1.6.2.8 PEP 590: Vectorcall: a fast calling protocol for CPython
................................................................

*note The Vectorcall Protocol: 51d. is added to the Python/C API. It is
meant to formalize existing optimizations which were already done for
various classes.  Any *note static type: 74a. implementing a callable
can use this protocol.

これは現在、暫定版です。Python3.9 から公開で使われることを目ざしています
。

詳細は PEP 590(1) を参照してください。

(Contributed by Jeroen Demeyer, Mark Shannon and Petr Viktorin in
bpo-36974(2).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0590/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36974


File: python.info,  Node: Pickle プロトコルバージョン 5 による帯域外データバッファ,  Prev: PEP 590 Vectorcall a fast calling protocol for CPython,  Up: 新しい機能<7>

1.6.2.9 Pickle プロトコルバージョン 5 による帯域外データバッファ
................................................................

*note pickle: 95. モジュールが Python のプロセス間での大容量データ転送で
マルチコアないしマルチマシンでの利点を得るためには、メモリコピーの削減の
ほか、データ種別に応じた圧縮などの個別に合わせた最適化が重要です。

*note pickle: 95. プロトコルバージョン5 は、 PEP 3118(1) 互換であるよう
なデータが、メインのpickle ストリームとは別の独立した通信レイヤで転送さ
れるような、帯域外バッファを提供します。

詳細は PEP 574(2) を参照してください。

(Antoine Pitrou の貢献による bpo-36785(3))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3118/

   (2) https://peps.python.org/pep-0574/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36785


File: python.info,  Node: その他の言語変更<4>,  Next: 新たなモジュール<4>,  Prev: 新しい機能<7>,  Up: What's New In Python 3 8

1.6.3 その他の言語変更
----------------------

   * 実装上の問題により、*note finally: 997. 節での *note continue: 998.
     文は不正でした。Python3.8 では、この制限は取り除かれています。
     (Serhiy Storchaka の貢献による bpo-32489(1))

   * *note bool: 434, *note int: 238, *note fractions.Fraction: 1c8. タ
     イプは、*note float: 2ce. や *note decimal.Decimal: 27d. と同様の
     *note as_integer_ratio(): 999. メソッドを持つようになりました。この
     API の拡張によって、‘numerator, denominator = x.as_integer_ratio()’
     のようなコードがより多くの数値型で動作します。 (Lisa Roach の貢献に
     よる bpo-33073(2) および Raymond Hettinger の貢献による
     bpo-37819(3))

   * *note int: 238, *note float: 2ce, *note complex: 2cf. のコンストラ
     クタは、可能ならば *note __index__(): 6e8. 特殊メソッドを利用し、そ
     の場合は対応する *note __int__(): 6e7, *note __float__(): 99a. や
     *note __complex__(): 5b1. は使用できません。(Serhiy Storchaka の貢
     献による bpo-20092(4))

   * Added support of ‘\N{NAME}’ escapes in *note regular expressions:
     a7.:

          >>> notice = 'Copyright © 2019'
          >>> copyright_year_pattern = re.compile(r'\N{copyright sign}\s*(\d{4})')
          >>> int(copyright_year_pattern.search(notice).group(1))
          2019

     (Jonathan Eunice, Serhiy Storchaka の貢献による bpo-30688(5))

   * dict と dictview は、*note reversed(): 831. を使って逆順でイテレー
     トすることが可能になりました。(Rémi Lapeyre の貢献による
     bpo-33462(6))

   * 関数内でのキーワード名に関する構文の制限が強化されました。具体的に
     は、‘f((keyword)=arg)’ の表現が許容されなくなりました。キーワード引
     数への代入の際、左側にキーワードそのまま以外の表現を許可する意図は
     、以前からありませんでした。 (Benjamin Peterson の貢献による
     bpo-34641(7))

   * *note yield: 99b. 文と *note return: 99c. 文における一般化されたイ
     テラブルへの展開のために、全体を覆うかっこが不要になりました。これ
     は 'yield' と 'return' の表現を、一般の展開と同様のわかりやすい形式
     にします:

          >>> def parse(family):
                  lastname, *members = family.split()
                  return lastname.upper(), *members

          >>> parse('simpsons homer marge bart lisa maggie')
          ('SIMPSONS', 'homer', 'marge', 'bart', 'lisa', 'maggie')

     (David Cuthbert, Jordan Chapman の貢献による bpo-32117(8))

   * ‘[(10, 20) (30, 40)]’ のようなコードでコンマが無い場合、コンパイラ
     は *note SyntaxWarning: 432. を、分かりやすい形式で表示します。これ
     で、最初のタプルが呼び出し可能ではないことを *note TypeError: 502.
     で表示するよりもわかりやすくなります。(Serhiy Storchaka の貢献によ
     る bpo-15248(9))

   * *note datetime.date: 1af, *note datetime.datetime: 1ae, *note
     datetime.timedelta: 99d. オブジェクトのサブクラス間の算術演算は、基
     底クラスではなくサブクラスのインスタンスを返すようになりました。こ
     の変更は、*note astimezone(): 99e. のような、*note
     datetime.timedelta: 99d. に対する算術演算を直接ないし間接的に使用す
     る実装の戻り値の型に影響します。(Paul Ganssle の貢献による
     bpo-32417(10))

   * Python インタープリタがCtrl-C (SIGINT) によって中断され、*note
     KeyboardInterrupt: 99f. 例外の結果が捕捉されなかった場合、Python プ
     ロセスはSIGINT シグナルか、呼び出したプロセスが、Ctrl-C によって終
     了したことを判別できるような適切な終了コードで終了するようになりま
     した。　POSIX とWindows 上のシェルは、非対話セッション内でスクリプ
     トの終了処理を適切に行うために、これを利用できます。(Gregory P.
     Smith を通してGoogle の貢献による bpo-1054041(11))

   * 先進的なプログラミングにおいて、既存の関数の *note types.CodeType:
     2c0. オブジェクトを更新する必要が生じます。code オブジェクトはイミ
     ュータブルなので、既存のオブジェクトがあるにもかかわらず、新しい
     code オブジェクトを生成する必要がありました。パラメータが19もあるの
     で、一から作成するのは非合理的です。新しい ‘replace()’ メソッドを使
     えば、更新すべきパラメータを書くだけで、新しいクローンを作成するこ
     とができます。

     ここでは、*note statistics.mean(): 69d. 関数がキーワード引数として
     'data' を使えないように変更する例を見てみましょう:

          >>> from statistics import mean
          >>> mean(data=[10, 20, 90])
          40
          >>> mean.__code__ = mean.__code__.replace(co_posonlyargcount=1)
          >>> mean(data=[10, 20, 90])
          Traceback (most recent call last):
            ...
          TypeError: mean() got some positional-only arguments passed as keyword arguments: 'data'

     (Victor Stinner の貢献による bpo-37032(12))

   * For integers, the three-argument form of the *note pow(): 9a0.
     function now permits the exponent to be negative in the case where
     the base is relatively prime to the modulus.  It then computes a
     modular inverse to the base when the exponent is ‘-1’, and a
     suitable power of that inverse for other negative exponents.  For
     example, to compute the modular multiplicative inverse(13) of 38
     modulo 137, write:

          >>> pow(38, -1, 137)
          119
          >>> 119 * 38 % 137
          1

     Modular inverses arise in the solution of linear Diophantine
     equations(14).  For example, to find integer solutions for ‘4258𝑥 +
     147𝑦 = 369’, first rewrite as ‘4258𝑥 ≡ 369 (mod 147)’ then solve:

          >>> x = 369 * pow(4258, -1, 147) % 147
          >>> y = (4258 * x - 369) // -147
          >>> 4258 * x + 147 * y
          369

     (Mark Dickinson の貢献による bpo-36027(15))

   * 辞書内包表現は辞書リテラルと同期されたため、まずキーが解釈され、次
     に値が解釈されます:

          >>> # Dict comprehension
          >>> cast = {input('role? '): input('actor? ') for i in range(2)}
          role? King Arthur
          actor? Chapman
          role? Black Knight
          actor? Cleese

          >>> # Dict literal
          >>> cast = {input('role? '): input('actor? ')}
          role? Sir Robin
          actor? Eric Idle

     この実行順の保証は代入式の役に立ち、キーの表現で代入されたものは、
     値の表現で使用することができます:

          >>> names = ['Martin von Löwis', 'Łukasz Langa', 'Walter Dörwald']
          >>> {(n := normalize('NFC', name)).casefold() : n for name in names}
          {'martin von löwis': 'Martin von Löwis',
           'łukasz langa': 'Łukasz Langa',
           'walter dörwald': 'Walter Dörwald'}

     (Jörn Heissler の貢献による bpo-35224(16))

   * The *note object.__reduce__(): 9a1. method can now return a tuple
     from two to six elements long.  Formerly, five was the limit.  The
     new, optional sixth element is a callable with a ‘(obj, state)’
     signature.  This allows the direct control over the state-updating
     behavior of a specific object.  If not 'None', this callable will
     have priority over the object's ‘__setstate__()’ method.
     (Contributed by Pierre Glaser and Olivier Grisel in bpo-35900(17).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32489

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33073

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37819

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20092

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30688

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33462

   (7) https://bugs.python.org/issue?@action=redirect&bpo=34641

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32117

   (9) https://bugs.python.org/issue?@action=redirect&bpo=15248

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32417

   (11) https://bugs.python.org/issue?@action=redirect&bpo=1054041

   (12) https://bugs.python.org/issue?@action=redirect&bpo=37032

   (13) https://en.wikipedia.org/wiki/Modular_multiplicative_inverse

   (14) https://en.wikipedia.org/wiki/Diophantine_equation

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36027

   (16) https://bugs.python.org/issue?@action=redirect&bpo=35224

   (17) https://bugs.python.org/issue?@action=redirect&bpo=35900


File: python.info,  Node: 新たなモジュール<4>,  Next: 改良されたモジュール<4>,  Prev: その他の言語変更<4>,  Up: What's New In Python 3 8

1.6.4 新たなモジュール
----------------------

   * 新しい *note importlib.metadata: 6e. モジュールは、サードパーティパ
     ッケージからのメタデータ読み込みをサポートします。これは暫定版です
     。例えば、インストールされたパッケージのバージョンを得たり、エント
     リーポイントの一覧を得たりできます:

          >>> # Note following example requires that the popular "requests"
          >>> # package has been installed.
          >>>
          >>> from importlib.metadata import version, requires, files
          >>> version('requests')
          '2.22.0'
          >>> list(requires('requests'))
          ['chardet (<3.1.0,>=3.0.2)']
          >>> list(files('requests'))[:5]
          [PackagePath('requests-2.22.0.dist-info/INSTALLER'),
           PackagePath('requests-2.22.0.dist-info/LICENSE'),
           PackagePath('requests-2.22.0.dist-info/METADATA'),
           PackagePath('requests-2.22.0.dist-info/RECORD'),
           PackagePath('requests-2.22.0.dist-info/WHEEL')]

     (Barry Warsaw, Jason R. Coombs の貢献による bpo-34632(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34632


File: python.info,  Node: 改良されたモジュール<4>,  Next: 最適化<4>,  Prev: 新たなモジュール<4>,  Up: What's New In Python 3 8

1.6.5 改良されたモジュール
--------------------------

* Menu:

* ast: ast<3>.
* asyncio: asyncio<6>.
* builtins: builtins<2>.
* collections::
* cProfile::
* csv: csv<2>.
* curses: curses<3>.
* ctypes: ctypes<2>.
* datetime: datetime<3>.
* functools: functools<2>.
* gc: gc<3>.
* gettext::
* gzip: gzip<3>.
* IDLE と idelelib: IDLE と idelelib<4>.
* inspect: inspect<5>.
* io: io<3>.
* itertools: itertools<4>.
* json.tool: json tool.
* logging: logging<2>.
* math: math<5>.
* mmap: mmap<2>.
* multiprocessing: multiprocessing<3>.
* os: os<6>.
* os.path: os path<4>.
* pathlib: pathlib<7>.
* pickle::
* plistlib::
* pprint: pprint<3>.
* py_compile: py_compile<2>.
* shlex::
* shutil: shutil<4>.
* socket: socket<4>.
* ssl: ssl<4>.
* statistics: statistics<4>.
* sys: sys<7>.
* tarfile: tarfile<4>.
* threading: threading<4>.
* tokenize: tokenize<2>.
* tkinter: tkinter<4>.
* time: time<4>.
* typing: typing<8>.
* unicodedata: unicodedata<5>.
* unittest: unittest<6>.
* venv: venv<4>.
* weakref::
* xml: xml<4>.
* xmlrpc::


File: python.info,  Node: ast<3>,  Next: asyncio<6>,  Up: 改良されたモジュール<4>

1.6.5.1 ast
...........

AST ノードは ‘end_lineno’ と ‘end_col_offset’ の属性を持つようになりまし
た。これは、正確なノードの終端位置を提供します。(これは、‘lineno’ と
‘col_offset’ の属性を持つノードにのみ有効です)

新しい *note ast.get_source_segment(): 9a5. 関数は、特定の AST ノードの
ソースコードを返します。

(Ivan Levkivskyi の貢献による bpo-33416(1))

*note ast.parse(): 18d. 関数の新しいフラグが有効になりました:

   * ‘type_comments=True’ は、そのAST ノードに関連する、 PEP 484(2) と
     PEP 526(3) に規定されるような型コメントを返します;

   * ‘mode='func_type'’ can be used to parse PEP 484(4) "signature type
     comments" (returned for function definition AST nodes);

   * ‘feature_version=(3, N)’ を使うと、以前の Python 3 バージョンを指定
     できます。例えば、‘feature_version=(3, 4)’ とすると、*note async:
     6fd. と *note await: 19e. キーワードは、予約語ではないとして扱われ
     ます。

(Guido van Rossum の貢献による bpo-35766(5))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33416

   (2) https://peps.python.org/pep-0484/

   (3) https://peps.python.org/pep-0526/

   (4) https://peps.python.org/pep-0484/

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35766


File: python.info,  Node: asyncio<6>,  Next: builtins<2>,  Prev: ast<3>,  Up: 改良されたモジュール<4>

1.6.5.2 asyncio
...............

*note asyncio.run(): 449. は暫定から安定API に移動しました。この関数は
*note coroutine: 45e. の実行と、イベントループを管理しながら自動的に結果
を返すことに使用できます。例えば:

     import asyncio

     async def main():
         await asyncio.sleep(0)
         return 42

     asyncio.run(main())

これは、だいたい次と等価です

     import asyncio

     async def main():
         await asyncio.sleep(0)
         return 42

     loop = asyncio.new_event_loop()
     asyncio.set_event_loop(loop)
     try:
         loop.run_until_complete(main())
     finally:
         asyncio.set_event_loop(None)
         loop.close()

実装はこれよりもずっと複雑なものになっています。ですが、 *note
asyncio.run(): 449. は非同期IOプログラムを動かす際にまず選ぶべき選択肢で
す。

(Yury Selivanov の貢献による bpo-32314(1))

‘python -m asyncio’ を実行すると、ネイティブ async 対話型インタプリタが
起動します。高水準キーワード *note await: 19e. を使うコードの試験を簡単
に行えます。すべての呼び出しに対して新しいイベントループを作る
‘asyncio.run()’ を呼び出す必要はありません:

     $ python -m asyncio
     asyncio REPL 3.8.0
     Use "await" directly instead of "asyncio.run()".
     Type "help", "copyright", "credits" or "license" for more information.
     >>> import asyncio
     >>> await asyncio.sleep(10, result='hello')
     hello

(Yury Selivanov の貢献による bpo-37028(2))

The exception *note asyncio.CancelledError: 19d. now inherits from *note
BaseException: 584. rather than *note Exception: 9a7. and no longer
inherits from *note concurrent.futures.CancelledError: 9a8.
(Contributed by Yury Selivanov in bpo-32528(3).)

Windows では、イベントループのデフォルトが *note ProactorEventLoop: 5d4.
になりました。(Victor Stinner の貢献による bpo-34687(4))

*note ProactorEventLoop: 5d4. はUDP もサポートするようになりました。
(Adam Meily, Andrew Svetlov の貢献による bpo-29883(5))

*note ProactorEventLoop: 5d4. は *note KeyboardInterrupt: 99f.
("CTRL+C") によって中断できるようになりました。(Vladimir Matveev の貢献
による bpo-23057(6))

*note asyncio.Task: 4a5. 内で、内包されたコルーチンを得られる *note
asyncio.Task.get_coro(): 9a9. メソッドが追加されました。(Alex Grönholm の
貢献による bpo-36999(7))

*note asyncio.create_task(): 5c7. 関数か *note create_task(): 9aa. の
‘name’ 引数を指定するか、もしくはタスクに対して *note set_name(): 9ab. メ
ソッドを呼ぶことによって、asyncio タスクに名前をつけることができます。タ
スクの名前は、*note asyncio.Task: 4a5. の ‘repr()’ 出力で、または *note
get_name(): 9ac. メソッドで確認することができます。(Alex Grönholm の貢献
による bpo-34270(8))

*note asyncio.loop.create_connection(): 5ce. は、Happy Eyeballs(9) をサ
ポートするようになりました。挙動を定義するため、2つの新しいパラメータ:
'happy_eyeballs_delay' と 'interleave' が加えられます。Happy Eyeballs ア
ルゴリズムは、アプリケーションが IPv4 と IPv6 をサポートする場合、その両
方を使って接続を保つことによって、アプリケーションの応答性を向上させます
。(twisteroid ambassador の貢献による bpo-33530(10))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32314

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37028

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32528

   (4) https://bugs.python.org/issue?@action=redirect&bpo=34687

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29883

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23057

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36999

   (8) https://bugs.python.org/issue?@action=redirect&bpo=34270

   (9) https://en.wikipedia.org/wiki/Happy_Eyeballs

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33530


File: python.info,  Node: builtins<2>,  Next: collections,  Prev: asyncio<6>,  Up: 改良されたモジュール<4>

1.6.5.3 builtins
................

組み込み関数 *note compile(): 177. が、‘ast.PyCF_ALLOW_TOP_LEVEL_AWAIT’
フラグを受け取るようになりました。このフラグが有効である場合、*note
compile(): 177. は、一般には有効な公文ではない、トップレベルの ‘await’,
‘async for’, ‘async with’ 構文が有効になります。この場合、‘CO_COROUTINE’
フラグを持つ非同期コードオブジェクトが返されるでしょう。(Matthias
Bussonnier の貢献による bpo-34616(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34616


File: python.info,  Node: collections,  Next: cProfile,  Prev: builtins<2>,  Up: 改良されたモジュール<4>

1.6.5.4 collections
...................

*note collections.namedtuple(): 1ac. の *note _asdict(): 9af. メソッドは
、*note collections.OrderedDict: 5a5. ではなく *note dict: 237. を返すよ
うになりました。Python 3.7 からは一般に辞書の順番が保証されるため、この
ような変更が可能です。‘OrderedDict’ 特有の機能を使いたい場合は、結果を
‘OrderedDict(nt._asdict())’ 型にキャストして使用することを推奨します。
(Raymond Hettinger の貢献による bpo-35864(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35864


File: python.info,  Node: cProfile,  Next: csv<2>,  Prev: collections,  Up: 改良されたモジュール<4>

1.6.5.5 cProfile
................

*note cProfile.Profile: 9b1. クラスは、コンテキストマネージャとして使用
できるようになりました。このようにしてコードブロックをプロファイルします
:

     import cProfile

     with cProfile.Profile() as profiler:
           # code to be profiled
           ...

(Scott Sanderson の貢献による bpo-29235(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29235


File: python.info,  Node: csv<2>,  Next: curses<3>,  Prev: cProfile,  Up: 改良されたモジュール<4>

1.6.5.6 csv
...........

*note csv.DictReader: 9b3. は、*note collections.OrderedDict: 5a5. では
なく *note dict: 237. のインスタンスを返すようになりました。この変更によ
って、順序を保ちながら、より高速にかつメモリの使用量を減らして実行できま
す。(Michael Selik の貢献による bpo-34003(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34003


File: python.info,  Node: curses<3>,  Next: ctypes<2>,  Prev: csv<2>,  Up: 改良されたモジュール<4>

1.6.5.7 curses
..............

ncurses ライブラリの、構造化されたバージョン情報を保持する変数を追加しま
した: *note ncurses_version: 9b5.　 (Serhiy Storchaka の貢献による
bpo-31680(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31680


File: python.info,  Node: ctypes<2>,  Next: datetime<3>,  Prev: curses<3>,  Up: 改良されたモジュール<4>

1.6.5.8 ctypes
..............

Windows では、*note CDLL: 9b7. とそのサブクラスが 'winmode' 引数を受け取
り、根底の ‘LoadLibraryEx’ 呼び出しのフラグを指定できるようになりました
。デフォルトでは、フラグは (フルパスか部分パスが初期DLL を読み込むのに使
われていた場合) そのDLL が保存されている場所を含んだ信頼済みの場所と、
*note add_dll_directory(): 9b8. によって加えられた場所からのみ、DLL を読
み込むようになっています。(Steve Dower の貢献による bpo-36085(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36085


File: python.info,  Node: datetime<3>,  Next: functools<2>,  Prev: ctypes<2>,  Up: 改良されたモジュール<4>

1.6.5.9 datetime
................

Added new alternate constructors *note datetime.date.fromisocalendar():
9ba. and *note datetime.datetime.fromisocalendar(): 9bb, which construct
*note date: 1af. and *note datetime: 1ae. objects respectively from ISO
year, week number, and weekday; these are the inverse of each class's
‘isocalendar’ method.  (Contributed by Paul Ganssle in bpo-36004(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36004


File: python.info,  Node: functools<2>,  Next: gc<3>,  Prev: datetime<3>,  Up: 改良されたモジュール<4>

1.6.5.10 functools
..................

*note functools.lru_cache(): 9bd. は、デコレータを返す関数としての使い方
に加えて、デコレータそのものとしても使えるようになりました。両方の使い方
ができます:

     @lru_cache
     def f(x):
         ...

     @lru_cache(maxsize=256)
     def f(x):
         ...

(Raymond Hettinger の貢献による bpo-36772(1))

インスタンスが存在する間、計算型プロパティをキャッシュする *note
functools.cached_property(): 50c. デコレータが追加されました:

     import functools
     import statistics

     class Dataset:
        def __init__(self, sequence_of_numbers):
           self.data = sequence_of_numbers

        @functools.cached_property
        def variance(self):
           return statistics.variance(self.data)

(Carl Meyer の貢献による bpo-21145(2))

*note single dispatch: 9be. を利用して、メソッドを *note
ジェネリック関数: 9bf. に変換する *note
functools.singledispatchmethod(): 9c0. デコレータが追加されました:

     from functools import singledispatchmethod
     from contextlib import suppress

     class TaskManager:

         def __init__(self, tasks):
             self.tasks = list(tasks)

         @singledispatchmethod
         def discard(self, value):
             with suppress(ValueError):
                 self.tasks.remove(value)

         @discard.register(list)
         def _(self, tasks):
             targets = set(tasks)
             self.tasks = [x for x in self.tasks if x not in targets]

(Ethan Smith の貢献による bpo-32380(3))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36772

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21145

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32380


File: python.info,  Node: gc<3>,  Next: gettext,  Prev: functools<2>,  Up: 改良されたモジュール<4>

1.6.5.11 gc
...........

*note get_objects(): 7ce. は、オブジェクトを得る世代を指定するオプション
のパラメータ引数 'generation' を受け取るようになりました。(Pablo Galindo
の貢献による bpo-36016(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36016


File: python.info,  Node: gettext,  Next: gzip<3>,  Prev: gc<3>,  Up: 改良されたモジュール<4>

1.6.5.12 gettext
................

*note pgettext(): 9c3. を含む、類似のいくつかの関数が追加されました。
(Franz Glasner, Éric Araujo, Cheryl Sabella の貢献による bpo-2504(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2504


File: python.info,  Node: gzip<3>,  Next: IDLE と idelelib<4>,  Prev: gettext,  Up: 改良されたモジュール<4>

1.6.5.13 gzip
.............

出力の再現性のために、*note gzip.compress(): 60a. に 'mtime' パラメータ
が追加されました。 (Guo Ci Teo の貢献による bpo-34898(1))

不正な、あるいは破損した gzip ファイルのうち、所定の種類のものについて、
*note OSError: 3f0. にかわって *note BadGzipFile: 9c5. 例外が送出される
ようになりました。(Filip Gruszczyński, Michele Orrù, Zackery Spytz の貢
献による bpo-6584(2))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34898

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6584


File: python.info,  Node: IDLE と idelelib<4>,  Next: inspect<5>,  Prev: gzip<3>,  Up: 改良されたモジュール<4>

1.6.5.14 IDLE と idelelib
.........................

Output over N lines (50 by default) is squeezed down to a button.  N can
be changed in the PyShell section of the General page of the Settings
dialog.  Fewer, but possibly extra long, lines can be squeezed by right
clicking on the output.  Squeezed output can be expanded in place by
double-clicking the button or into the clipboard or a separate window by
right-clicking the button.  (Contributed by Tal Einat in
bpo-1529353(1).)

Add "Run Customized" to the Run menu to run a module with customized
settings.  Any command line arguments entered are added to sys.argv.
They also re-appear in the box for the next customized run.  One can
also suppress the normal Shell main module restart.  (Contributed by
Cheryl Sabella, Terry Jan Reedy, and others in bpo-5680(2) and
bpo-37627(3).)

Added optional line numbers for IDLE editor windows.  Windows open
without line numbers unless set otherwise in the General tab of the
configuration dialog.  Line numbers for an existing window are shown and
hidden in the Options menu.  (Contributed by Tal Einat and Saimadhav
Heblikar in bpo-17535(4).)

OS native encoding is now used for converting between Python strings and
Tcl objects.  This allows IDLE to work with emoji and other non-BMP
characters.  These characters can be displayed or copied and pasted to
or from the clipboard.  Converting strings from Tcl to Python and back
now never fails.  (Many people worked on this for eight years but the
problem was finally solved by Serhiy Storchaka in bpo-13153(5).)

New in 3.8.1:

Add option to toggle cursor blink off.  (Contributed by Zackery Spytz in
bpo-4603(6).)

Escape key now closes IDLE completion windows.  (Contributed by Johnny
Najera in bpo-38944(7).)

上で挙げた変更は 3.7 のメンテナンスリリースにバックポートされました。

Add keywords to module name completion list.  (Contributed by Terry J.
Reedy in bpo-37765(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1529353

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5680

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37627

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17535

   (5) https://bugs.python.org/issue?@action=redirect&bpo=13153

   (6) https://bugs.python.org/issue?@action=redirect&bpo=4603

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38944

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37765


File: python.info,  Node: inspect<5>,  Next: io<3>,  Prev: IDLE と idelelib<4>,  Up: 改良されたモジュール<4>

1.6.5.15 inspect
................

*note inspect.getdoc(): 9c8. 関数は、‘__slots__’ 属性に値が docstrings で
あるような *note dict: 237. がある場合、docstrings の内容を探索できるよ
うになりました。これは、既に *note property(): 179.、*note
classmethod(): 14c.、*note staticmethod(): 3ef. に現在あるような、ドキュ
メント生成の選択肢を提供します:

     class AudioClip:
         __slots__ = {'bit_rate': 'expressed in kilohertz to one decimal place',
                      'duration': 'in seconds, rounded up to an integer'}
         def __init__(self, bit_rate, duration):
             self.bit_rate = round(bit_rate / 1000.0, 1)
             self.duration = ceil(duration)

(Raymond Hettinger の貢献による bpo-36326(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36326


File: python.info,  Node: io<3>,  Next: itertools<4>,  Prev: inspect<5>,  Up: 改良されたモジュール<4>

1.6.5.16 io
...........

In development mode (*note -X: 15c. ‘env’) and in *note debug build:
1da, the *note io.IOBase: 1d6. finalizer now logs the exception if the
‘close()’ method fails.  The exception is ignored silently by default in
release build.  (Contributed by Victor Stinner in bpo-18748(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18748


File: python.info,  Node: itertools<4>,  Next: json tool,  Prev: io<3>,  Up: 改良されたモジュール<4>

1.6.5.17 itertools
..................

*note itertools.accumulate(): 9cb. 関数に、初期値を定める、オプションの
'initial' キーワード引数が追加されました:

     >>> from itertools import accumulate
     >>> list(accumulate([10, 5, 30, 15], initial=1000))
     [1000, 1010, 1015, 1045, 1060]

(Lisa Roach の貢献による bpo-34659(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34659


File: python.info,  Node: json tool,  Next: logging<2>,  Prev: itertools<4>,  Up: 改良されたモジュール<4>

1.6.5.18 json.tool
..................

一行ごとに別々の JSON オブジェクトへ解析をする ‘--json-lines’ オプション
が追加されました。(Weipeng Hong の貢献による bpo-31553(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31553


File: python.info,  Node: logging<2>,  Next: math<5>,  Prev: json tool,  Up: 改良されたモジュール<4>

1.6.5.19 logging
................

Added a 'force' keyword argument to *note logging.basicConfig(): 9ce.
When set to true, any existing handlers attached to the root logger are
removed and closed before carrying out the configuration specified by
the other arguments.

This solves a long-standing problem.  Once a logger or 'basicConfig()'
had been called, subsequent calls to 'basicConfig()' were silently
ignored.  This made it difficult to update, experiment with, or teach
the various logging configuration options using the interactive prompt
or a Jupyter notebook.

(Suggested by Raymond Hettinger, implemented by Donghee Na, and reviewed
by Vinay Sajip in bpo-33897(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33897


File: python.info,  Node: math<5>,  Next: mmap<2>,  Prev: logging<2>,  Up: 改良されたモジュール<4>

1.6.5.20 math
.............

二点間のユークリッド距離を計算する *note math.dist(): 9d0. 関数が追加さ
れました。(Raymond Hettinger の貢献による bpo-33089(1))

*note math.hypot(): 9d1. 関数は、3次元以上を扱えるように拡張されました。
以前は、二次元の場合のみに対応していました。(Raymond Hettinger の貢献に
よる bpo-33089(2))

*note sum(): 437. に類似する関数として、初期値(デフォルトは1) に対してイ
テレート可能なオブジェクトの数を掛けていく *note math.prod(): 9d2. 関数
が追加されました:

     >>> prior = 0.8
     >>> likelihoods = [0.625, 0.84, 0.30]
     >>> math.prod(likelihoods, start=prior)
     0.126

(Pablo Galindo の貢献による bpo-35606(3))

2つの組み合わせの関数 *note math.perm(): 69c. と *note math.comb(): 69b.
が追加されました:

     >>> math.perm(10, 3)    # Permutations of 10 things taken 3 at a time
     720
     >>> math.comb(10, 3)    # Combinations of 10 things taken 3 at a time
     120

(Yash Aggarwal, Keller Fuchs, Serhiy Storchaka, Raymond Hettinger の貢献
による bpo-37128(4), bpo-37178(5), bpo-35431(6))

浮動小数点数を介することなく、正確な整数の二乗根を計算する関数 *note
math.isqrt(): 9d3. が追加されました。この関数は、巨大な整数にも使用でき
ます。‘floor(sqrt(n))’ より高速ですが、*note math.sqrt(): 9d4. より少し
遅いです:

     >>> r = 650320427
     >>> s = r ** 2
     >>> isqrt(s - 1)         # correct
     650320426
     >>> floor(sqrt(s - 1))   # incorrect
     650320427

(Mark Dickinson の貢献による bpo-36887(7))

*note math.factorial(): 915. 関数は、引数に int、またはそれに類似するも
の以外を受け取らなくなりました。(Pablo Galindo の貢献による
bpo-33083(8))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33089

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33089

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35606

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37128

   (5) https://bugs.python.org/issue?@action=redirect&bpo=37178

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35431

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36887

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33083


File: python.info,  Node: mmap<2>,  Next: multiprocessing<3>,  Prev: math<5>,  Up: 改良されたモジュール<4>

1.6.5.21 mmap
.............

The *note mmap.mmap: 1ec. class now has an *note madvise(): 9d6. method
to access the ‘madvise()’ system call.  (Contributed by Zackery Spytz in
bpo-32941(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32941


File: python.info,  Node: multiprocessing<3>,  Next: os<6>,  Prev: mmap<2>,  Up: 改良されたモジュール<4>

1.6.5.22 multiprocessing
........................

Added new *note multiprocessing.shared_memory: 8b. module.  (Contributed
by Davin Potts in bpo-35813(1).)

On macOS, the 'spawn' start method is now used by default.  (Contributed
by Victor Stinner in bpo-33725(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35813

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33725


File: python.info,  Node: os<6>,  Next: os path<4>,  Prev: multiprocessing<3>,  Up: 改良されたモジュール<4>

1.6.5.23 os
...........

Added new function *note add_dll_directory(): 9b8. on Windows for
providing additional search paths for native dependencies when importing
extension modules or loading DLLs using *note ctypes: 22.  (Contributed
by Steve Dower in bpo-36085(1).)

A new *note os.memfd_create(): 9d9. function was added to wrap the
‘memfd_create()’ syscall.  (Contributed by Zackery Spytz and Christian
Heimes in bpo-26836(2).)

On Windows, much of the manual logic for handling reparse points
(including symlinks and directory junctions) has been delegated to the
operating system.  Specifically, *note os.stat(): 46d. will now traverse
anything supported by the operating system, while *note os.lstat(): 46e.
will only open reparse points that identify as "name surrogates" while
others are opened as for *note os.stat(): 46d.  In all cases,
‘stat_result.st_mode’ will only have ‘S_IFLNK’ set for symbolic links
and not other kinds of reparse points.  To identify other kinds of
reparse point, check the new ‘stat_result.st_reparse_tag’ attribute.

On Windows, *note os.readlink(): 8ee. is now able to read directory
junctions.  Note that *note islink(): 9da. will return ‘False’ for
directory junctions, and so code that checks ‘islink’ first will
continue to treat junctions as directories, while code that handles
errors from *note os.readlink(): 8ee. may now treat junctions as links.

(Contributed by Steve Dower in bpo-37834(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36085

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26836

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37834


File: python.info,  Node: os path<4>,  Next: pathlib<7>,  Prev: os<6>,  Up: 改良されたモジュール<4>

1.6.5.24 os.path
................

*note os.path: 92. functions that return a boolean result like *note
exists(): 9dc, *note lexists(): 9dd, *note isdir(): 9de, *note isfile():
9df, *note islink(): 9da, and *note ismount(): 9e0. now return ‘False’
instead of raising *note ValueError: 1e3. or its subclasses *note
UnicodeEncodeError: 643. and *note UnicodeDecodeError: 9e1. for paths
that contain characters or bytes unrepresentable at the OS level.
(Contributed by Serhiy Storchaka in bpo-33721(1).)

*note expanduser(): 9e2. on Windows now prefers the ‘USERPROFILE’
environment variable and does not use ‘HOME’, which is not normally set
for regular user accounts.  (Contributed by Anthony Sottile in
bpo-36264(2).)

*note isdir(): 9de. on Windows no longer returns ‘True’ for a link to a
non-existent directory.

*note realpath(): 206. on Windows now resolves reparse points, including
symlinks and directory junctions.

(Contributed by Steve Dower in bpo-37834(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33721

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36264

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37834


File: python.info,  Node: pathlib<7>,  Next: pickle,  Prev: os path<4>,  Up: 改良されたモジュール<4>

1.6.5.25 pathlib
................

*note pathlib.Path: 20a. methods that return a boolean result like *note
exists(): 9e4, *note is_dir(): 211, *note is_file(): 210, *note
is_mount(): 9e5, *note is_symlink(): 9e6, *note is_block_device(): 9e7,
*note is_char_device(): 9e8, *note is_fifo(): 9e9, *note is_socket():
9ea. now return ‘False’ instead of raising *note ValueError: 1e3. or its
subclass *note UnicodeEncodeError: 643. for paths that contain
characters unrepresentable at the OS level.  (Contributed by Serhiy
Storchaka in bpo-33721(1).)

Added ‘pathlib.Path.link_to()’ which creates a hard link pointing to a
path.  (Contributed by Joannah Nanjekye in bpo-26978(2)) Note that
‘link_to’ was deprecated in 3.10 and removed in 3.12 in favor of a
‘hardlink_to’ method added in 3.10 which matches the semantics of the
existing ‘symlink_to’ method.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33721

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26978


File: python.info,  Node: pickle,  Next: plistlib,  Prev: pathlib<7>,  Up: 改良されたモジュール<4>

1.6.5.26 pickle
...............

*note pickle: 95. extensions subclassing the C-optimized *note Pickler:
9ec. can now override the pickling logic of functions and classes by
defining the special *note reducer_override(): 9ed. method.
(Contributed by Pierre Glaser and Olivier Grisel in bpo-35900(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35900


File: python.info,  Node: plistlib,  Next: pprint<3>,  Prev: pickle,  Up: 改良されたモジュール<4>

1.6.5.27 plistlib
.................

Added new *note plistlib.UID: 9ef. and enabled support for reading and
writing NSKeyedArchiver-encoded binary plists.  (Contributed by Jon
Janzen in bpo-26707(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26707


File: python.info,  Node: pprint<3>,  Next: py_compile<2>,  Prev: plistlib,  Up: 改良されたモジュール<4>

1.6.5.28 pprint
...............

The *note pprint: 9c. module added a 'sort_dicts' parameter to several
functions.  By default, those functions continue to sort dictionaries
before rendering or printing.  However, if 'sort_dicts' is set to false,
the dictionaries retain the order that keys were inserted.  This can be
useful for comparison to JSON inputs during debugging.

In addition, there is a convenience new function, *note pprint.pp():
9f1. that is like *note pprint.pprint(): 7f3. but with 'sort_dicts'
defaulting to ‘False’:

     >>> from pprint import pprint, pp
     >>> d = dict(source='input.txt', operation='filter', destination='output.txt')
     >>> pp(d, width=40)                  # Original order
     {'source': 'input.txt',
      'operation': 'filter',
      'destination': 'output.txt'}
     >>> pprint(d, width=40)              # Keys sorted alphabetically
     {'destination': 'output.txt',
      'operation': 'filter',
      'source': 'input.txt'}

(Contributed by Rémi Lapeyre in bpo-30670(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30670


File: python.info,  Node: py_compile<2>,  Next: shlex,  Prev: pprint<3>,  Up: 改良されたモジュール<4>

1.6.5.29 py_compile
...................

*note py_compile.compile(): 9f3. now supports silent mode.  (Contributed
by Joannah Nanjekye in bpo-22640(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22640


File: python.info,  Node: shlex,  Next: shutil<4>,  Prev: py_compile<2>,  Up: 改良されたモジュール<4>

1.6.5.30 shlex
..............

The new *note shlex.join(): 9f5. function acts as the inverse of *note
shlex.split(): 506.  (Contributed by Bo Bayles in bpo-32102(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32102


File: python.info,  Node: shutil<4>,  Next: socket<4>,  Prev: shlex,  Up: 改良されたモジュール<4>

1.6.5.31 shutil
...............

*note shutil.copytree(): 9f7. now accepts a new ‘dirs_exist_ok’ keyword
argument.  (Contributed by Josh Bronson in bpo-20849(1).)

*note shutil.make_archive(): 47f. now defaults to the modern pax
(POSIX.1-2001) format for new archives to improve portability and
standards conformance, inherited from the corresponding change to the
*note tarfile: c8. module.  (Contributed by C.A.M. Gerlach in
bpo-30661(2).)

*note shutil.rmtree(): 2d8. on Windows now removes directory junctions
without recursively removing their contents first.  (Contributed by
Steve Dower in bpo-37834(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20849

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30661

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37834


File: python.info,  Node: socket<4>,  Next: ssl<4>,  Prev: shutil<4>,  Up: 改良されたモジュール<4>

1.6.5.32 socket
...............

Added *note create_server(): 9f9. and *note has_dualstack_ipv6(): 9fa.
convenience functions to automate the necessary tasks usually involved
when creating a server socket, including accepting both IPv4 and IPv6
connections on the same socket.  (Contributed by Giampaolo Rodolà in
bpo-17561(1).)

The *note socket.if_nameindex(): 9fb, *note socket.if_nametoindex():
9fc, and *note socket.if_indextoname(): 9fd. functions have been
implemented on Windows.  (Contributed by Zackery Spytz in bpo-37007(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17561

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37007


File: python.info,  Node: ssl<4>,  Next: statistics<4>,  Prev: socket<4>,  Up: 改良されたモジュール<4>

1.6.5.33 ssl
............

Added *note post_handshake_auth: 9ff. to enable and *note
verify_client_post_handshake(): a00. to initiate TLS 1.3 post-handshake
authentication.  (Contributed by Christian Heimes in bpo-34670(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34670


File: python.info,  Node: statistics<4>,  Next: sys<7>,  Prev: ssl<4>,  Up: 改良されたモジュール<4>

1.6.5.34 statistics
...................

Added *note statistics.fmean(): a02. as a faster, floating-point variant
of *note statistics.mean(): 69d.  (Contributed by Raymond Hettinger and
Steven D'Aprano in bpo-35904(1).)

Added *note statistics.geometric_mean(): a03. (Contributed by Raymond
Hettinger in bpo-27181(2).)

Added *note statistics.multimode(): a04. that returns a list of the most
common values.  (Contributed by Raymond Hettinger in bpo-35892(3).)

Added *note statistics.quantiles(): a05. that divides data or a
distribution in to equiprobable intervals (e.g.  quartiles, deciles, or
percentiles).  (Contributed by Raymond Hettinger in bpo-36546(4).)

Added *note statistics.NormalDist: a06, a tool for creating and
manipulating normal distributions of a random variable.  (Contributed by
Raymond Hettinger in bpo-36018(5).)

     >>> temperature_feb = NormalDist.from_samples([4, 12, -3, 2, 7, 14])
     >>> temperature_feb.mean
     6.0
     >>> temperature_feb.stdev
     6.356099432828281

     >>> temperature_feb.cdf(3)            # Chance of being under 3 degrees
     0.3184678262814532
     >>> # Relative chance of being 7 degrees versus 10 degrees
     >>> temperature_feb.pdf(7) / temperature_feb.pdf(10)
     1.2039930378537762

     >>> el_niño = NormalDist(4, 2.5)
     >>> temperature_feb += el_niño        # Add in a climate effect
     >>> temperature_feb
     NormalDist(mu=10.0, sigma=6.830080526611674)

     >>> temperature_feb * (9/5) + 32      # Convert to Fahrenheit
     NormalDist(mu=50.0, sigma=12.294144947901014)
     >>> temperature_feb.samples(3)        # Generate random samples
     [7.672102882379219, 12.000027119750287, 4.647488369766392]

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35904

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27181

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35892

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36546

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36018


File: python.info,  Node: sys<7>,  Next: tarfile<4>,  Prev: statistics<4>,  Up: 改良されたモジュール<4>

1.6.5.35 sys
............

Add new *note sys.unraisablehook(): 1d8. function which can be
overridden to control how "unraisable exceptions" are handled.  It is
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 (*note gc.collect(): a08.).  (Contributed by Victor
Stinner in bpo-36829(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36829


File: python.info,  Node: tarfile<4>,  Next: threading<4>,  Prev: sys<7>,  Up: 改良されたモジュール<4>

1.6.5.36 tarfile
................

The *note tarfile: c8. module now defaults to the modern pax
(POSIX.1-2001) format for new archives, instead of the previous
GNU-specific one.  This improves cross-platform portability with a
consistent encoding (UTF-8) in a standardized and extensible format, and
offers several other benefits.  (Contributed by C.A.M. Gerlach in
bpo-36268(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36268


File: python.info,  Node: threading<4>,  Next: tokenize<2>,  Prev: tarfile<4>,  Up: 改良されたモジュール<4>

1.6.5.37 threading
..................

Add a new *note threading.excepthook(): 816. function which handles
uncaught *note threading.Thread.run(): a0b. exception.  It can be
overridden to control how uncaught *note threading.Thread.run(): a0b.
exceptions are handled.  (Contributed by Victor Stinner in
bpo-1230540(1).)

Add a new *note threading.get_native_id(): a0c. function and a *note
native_id: a0d. attribute to the *note threading.Thread: 91a. class.
These return the native integral Thread ID of the current thread
assigned by the kernel.  This feature is only available on certain
platforms, see *note get_native_id: a0c. for more information.
(Contributed by Jake Tesler in bpo-36084(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1230540

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36084


File: python.info,  Node: tokenize<2>,  Next: tkinter<4>,  Prev: threading<4>,  Up: 改良されたモジュール<4>

1.6.5.38 tokenize
.................

The *note tokenize: e4. module now implicitly emits a ‘NEWLINE’ token
when provided with input that does not have a trailing new line.  This
behavior now matches what the C tokenizer does internally.  (Contributed
by Ammar Askar in bpo-33899(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33899


File: python.info,  Node: tkinter<4>,  Next: time<4>,  Prev: tokenize<2>,  Up: 改良されたモジュール<4>

1.6.5.39 tkinter
................

Added methods ‘selection_from()’, ‘selection_present()’,
‘selection_range()’ and ‘selection_to()’ in the ‘tkinter.Spinbox’ class.
(Contributed by Juliette Monsel in bpo-34829(1).)

Added method ‘moveto()’ in the ‘tkinter.Canvas’ class.  (Contributed by
Juliette Monsel in bpo-23831(2).)

The ‘tkinter.PhotoImage’ class now has ‘transparency_get()’ and
‘transparency_set()’ methods.  (Contributed by Zackery Spytz in
bpo-25451(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34829

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23831

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25451


File: python.info,  Node: time<4>,  Next: typing<8>,  Prev: tkinter<4>,  Up: 改良されたモジュール<4>

1.6.5.40 time
.............

Added new clock *note CLOCK_UPTIME_RAW: a11. for macOS 10.12.
(Contributed by Joannah Nanjekye in bpo-35702(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35702


File: python.info,  Node: typing<8>,  Next: unicodedata<5>,  Prev: time<4>,  Up: 改良されたモジュール<4>

1.6.5.41 typing
...............

The *note typing: ed. module incorporates several new features:

   * A dictionary type with per-key types.  See PEP 589(1) and *note
     typing.TypedDict: 148.  TypedDict uses only string keys.  By
     default, every key is required to be present.  Specify
     "total=False" to allow keys to be optional:

          class Location(TypedDict, total=False):
              lat_long: tuple
              grid_square: str
              xy_coordinate: tuple

   * Literal types.  See PEP 586(2) and *note typing.Literal: 820.
     Literal types indicate that a parameter or return value is
     constrained to one or more specific literal values:

          def get_status(port: int) -> Literal['connected', 'disconnected']:
              ...

   * "Final" variables, functions, methods and classes.  See PEP 591(3),
     *note typing.Final: 248. and *note typing.final(): 679.  The final
     qualifier instructs a static type checker to restrict subclassing,
     overriding, or reassignment:

          pi: Final[float] = 3.1415926536

   * Protocol definitions.  See PEP 544(4), *note typing.Protocol: 245.
     and *note typing.runtime_checkable(): 40f.  Simple ABCs like *note
     typing.SupportsInt: a13. are now ‘Protocol’ subclasses.

   * New protocol class *note typing.SupportsIndex: a14.

   * New functions *note typing.get_origin(): a15. and *note
     typing.get_args(): 84b.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0589/

   (2) https://peps.python.org/pep-0586/

   (3) https://peps.python.org/pep-0591/

   (4) https://peps.python.org/pep-0544/


File: python.info,  Node: unicodedata<5>,  Next: unittest<6>,  Prev: typing<8>,  Up: 改良されたモジュール<4>

1.6.5.42 unicodedata
....................

The *note unicodedata: ee. module has been upgraded to use the Unicode
12.1.0(1) release.

New function *note is_normalized(): a17. can be used to verify a string
is in a specific normal form, often much faster than by actually
normalizing the string.  (Contributed by Max Belanger, David Euresti,
and Greg Price in bpo-32285(2) and bpo-37966(3)).

   ---------- Footnotes ----------

   (1) https://blog.unicode.org/2019/05/unicode-12-1-en.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32285

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37966


File: python.info,  Node: unittest<6>,  Next: venv<4>,  Prev: unicodedata<5>,  Up: 改良されたモジュール<4>

1.6.5.43 unittest
.................

Added *note AsyncMock: a19. to support an asynchronous version of *note
Mock: a1a.  Appropriate new assert functions for testing have been added
as well.  (Contributed by Lisa Roach in bpo-26467(1)).

Added *note addModuleCleanup(): a1b. and *note addClassCleanup(): a1c.
to unittest to support cleanups for ‘setUpModule()’ and *note
setUpClass(): a1d.  (Contributed by Lisa Roach in bpo-24412(2).)

Several mock assert functions now also print a list of actual calls upon
failure.  (Contributed by Petter Strandmark in bpo-35047(3).)

*note unittest: ef. module gained support for coroutines to be used as
test cases with *note unittest.IsolatedAsyncioTestCase: 2e4.
(Contributed by Andrew Svetlov in bpo-32972(4).)

以下はプログラム例です:

     import unittest


     class TestRequest(unittest.IsolatedAsyncioTestCase):

         async def asyncSetUp(self):
             self.connection = await AsyncConnection()

         async def test_get(self):
             response = await self.connection.get("https://example.com")
             self.assertEqual(response.status_code, 200)

         async def asyncTearDown(self):
             await self.connection.close()


     if __name__ == "__main__":
         unittest.main()

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26467

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24412

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35047

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32972


File: python.info,  Node: venv<4>,  Next: weakref,  Prev: unittest<6>,  Up: 改良されたモジュール<4>

1.6.5.44 venv
.............

*note venv: f9. now includes an ‘Activate.ps1’ script on all platforms
for activating virtual environments under PowerShell Core 6.1.
(Contributed by Brett Cannon in bpo-32718(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32718


File: python.info,  Node: weakref,  Next: xml<4>,  Prev: venv<4>,  Up: 改良されたモジュール<4>

1.6.5.45 weakref
................

The proxy objects returned by *note weakref.proxy(): a20. now support
the matrix multiplication operators ‘@’ and ‘@=’ in addition to the
other numeric operators.  (Contributed by Mark Dickinson in
bpo-36669(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36669


File: python.info,  Node: xml<4>,  Next: xmlrpc,  Prev: weakref,  Up: 改良されたモジュール<4>

1.6.5.46 xml
............

As mitigation against DTD and external entity retrieval, the *note
xml.dom.minidom: 109. and *note xml.sax: 110. modules no longer process
external entities by default.  (Contributed by Christian Heimes in
bpo-17239(1).)

The ‘.find*()’ methods in the *note xml.etree.ElementTree: 10c. module
support wildcard searches like ‘{*}tag’ which ignores the namespace and
‘{namespace}*’ which returns all tags in the given namespace.
(Contributed by Stefan Behnel in bpo-28238(2).)

The *note xml.etree.ElementTree: 10c. module provides a new function
‘–xml.etree.ElementTree.canonicalize()’ that implements C14N 2.0.
(Contributed by Stefan Behnel in bpo-13611(3).)

The target object of *note xml.etree.ElementTree.XMLParser: a22. can
receive namespace declaration events through the new callback methods
‘start_ns()’ and ‘end_ns()’.  Additionally, the *note
xml.etree.ElementTree.TreeBuilder: a23. target can be configured to
process events about comments and processing instructions to include
them in the generated tree.  (Contributed by Stefan Behnel in
bpo-36676(4) and bpo-36673(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17239

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28238

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13611

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36676

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36673


File: python.info,  Node: xmlrpc,  Prev: xml<4>,  Up: 改良されたモジュール<4>

1.6.5.47 xmlrpc
...............

*note xmlrpc.client.ServerProxy: a25. now supports an optional 'headers'
keyword argument for a sequence of HTTP headers to be sent with each
request.  Among other things, this makes it possible to upgrade from
default basic authentication to faster session authentication.
(Contributed by Cédric Krier in bpo-35153(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35153


File: python.info,  Node: 最適化<4>,  Next: ビルドならびに C API の変更,  Prev: 改良されたモジュール<4>,  Up: What's New In Python 3 8

1.6.6 最適化
------------

   * The *note subprocess: c1. module can now use the *note
     os.posix_spawn(): 201. function in some cases for better
     performance.  Currently, it is only used on macOS and Linux (using
     glibc 2.24 or newer) if all these conditions are met:

        * 'close_fds' is false;

        * 'preexec_fn', 'pass_fds', 'cwd' and 'start_new_session'
          parameters are not set;

        * the 'executable' path contains a directory.

     (Contributed by Joannah Nanjekye and Victor Stinner in
     bpo-35537(1).)

   * *note shutil.copyfile(): a27, *note shutil.copy(): a28, *note
     shutil.copy2(): a29, *note shutil.copytree(): 9f7. and *note
     shutil.move(): a2a. use platform-specific "fast-copy" syscalls on
     Linux and macOS in order to copy the file more efficiently.
     "fast-copy" means that the copying operation occurs within the
     kernel, avoiding the use of userspace buffers in Python as in
     "‘outfd.write(infd.read())’".  On Windows *note shutil.copyfile():
     a27. uses a bigger default buffer size (1 MiB instead of 16 KiB)
     and a *note memoryview(): 435.-based variant of *note
     shutil.copyfileobj(): a2b. is used.  The speedup for copying a 512
     MiB file within the same partition is about +26% on Linux, +50% on
     macOS and +40% on Windows.  Also, much less CPU cycles are
     consumed.  See *note プラットフォーム依存の効率的なコピー操作: a2c.
     section.  (Contributed by Giampaolo Rodolà in bpo-33671(2).)

   * *note shutil.copytree(): 9f7. uses *note os.scandir(): a2d.
     function and all copy functions depending from it use cached *note
     os.stat(): 46d. values.  The speedup for copying a directory with
     8000 files is around +9% on Linux, +20% on Windows and +30% on a
     Windows SMB share.  Also the number of *note os.stat(): 46d.
     syscalls is reduced by 38% making *note shutil.copytree(): 9f7.
     especially faster on network filesystems.  (Contributed by
     Giampaolo Rodolà in bpo-33695(3).)

   * The default protocol in the *note pickle: 95. module is now
     Protocol 4, first introduced in Python 3.4.  It offers better
     performance and smaller size compared to Protocol 3 available since
     Python 3.0.

   * Removed one *note Py_ssize_t: a2e. member from ‘PyGC_Head’.  All GC
     tracked objects (e.g.  tuple, list, dict) size is reduced 4 or 8
     bytes.  (Contributed by Inada Naoki in bpo-33597(4).)

   * *note uuid.UUID: a2f. now uses ‘__slots__’ to reduce its memory
     footprint.  (Contributed by Wouter Bolsterlee and Tal Einat in
     bpo-30977(5))

   * Improved performance of *note operator.itemgetter(): a30. by 33%.
     Optimized argument handling and added a fast path for the common
     case of a single non-negative integer index into a tuple (which is
     the typical use case in the standard library).  (Contributed by
     Raymond Hettinger in bpo-35664(6).)

   * Sped-up field lookups in *note collections.namedtuple(): 1ac.  They
     are now more than two times faster, making them the fastest form of
     instance variable lookup in Python.  (Contributed by Raymond
     Hettinger, Pablo Galindo, and Joe Jevnik, Serhiy Storchaka in
     bpo-32492(7).)

   * The *note list: 5dc. constructor does not overallocate the internal
     item buffer if the input iterable has a known length (the input
     implements ‘__len__’).  This makes the created list 12% smaller on
     average.  (Contributed by Raymond Hettinger and Pablo Galindo in
     bpo-33234(8).)

   * Doubled the speed of class variable writes.  When a non-dunder
     attribute was updated, there was an unnecessary call to update
     slots.  (Contributed by Stefan Behnel, Pablo Galindo Salgado,
     Raymond Hettinger, Neil Schemenauer, and Serhiy Storchaka in
     bpo-36012(9).)

   * Reduced an overhead of converting arguments passed to many builtin
     functions and methods.  This sped up calling some simple builtin
     functions and methods up to 20-50%.  (Contributed by Serhiy
     Storchaka in bpo-23867(10), bpo-35582(11) and bpo-36127(12).)

   * ‘LOAD_GLOBAL’ instruction now uses new "per opcode cache"
     mechanism.  It is about 40% faster now.  (Contributed by Yury
     Selivanov and Inada Naoki in bpo-26219(13).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35537

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33671

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33695

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33597

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30977

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35664

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32492

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33234

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36012

   (10) https://bugs.python.org/issue?@action=redirect&bpo=23867

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35582

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36127

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26219


File: python.info,  Node: ビルドならびに C API の変更,  Next: 非推奨<6>,  Prev: 最適化<4>,  Up: What's New In Python 3 8

1.6.7 ビルドならびに C API の変更
---------------------------------

   * Default *note sys.abiflags: a32. became an empty string: the ‘m’
     flag for pymalloc became useless (builds with and without pymalloc
     are ABI compatible) and so has been removed.  (Contributed by
     Victor Stinner in bpo-36707(1).)

     Example of changes:

        * Only ‘python3.8’ program is installed, ‘python3.8m’ program is
          gone.

        * Only ‘python3.8-config’ script is installed,
          ‘python3.8m-config’ script is gone.

        * The ‘m’ flag has been removed from the suffix of dynamic
          library filenames: extension modules in the standard library
          as well as those produced and installed by third-party
          packages, like those downloaded from PyPI. On Linux, for
          example, the Python 3.7 suffix
          ‘.cpython-37m-x86_64-linux-gnu.so’ became
          ‘.cpython-38-x86_64-linux-gnu.so’ in Python 3.8.

   * The header files have been reorganized to better separate the
     different kinds of APIs:

        * ‘Include/*.h’ should be the portable public stable C API.

        * ‘Include/cpython/*.h’ should be the unstable C API specific to
          CPython; public API, with some private API prefixed by ‘_Py’
          or ‘_PY’.

        * ‘Include/internal/*.h’ is the private internal C API very
          specific to CPython.  This API comes with no backward
          compatibility warranty and should not be used outside CPython.
          It is only exposed for very specific needs like debuggers and
          profiles which has to access to CPython internals without
          calling functions.  This API is now installed by ‘make
          install’.

     (Contributed by Victor Stinner in bpo-35134(2) and bpo-35081(3),
     work initiated by Eric Snow in Python 3.7.)

   * Some macros have been converted to static inline functions:
     parameter types and return type are well defined, they don't have
     issues specific to macros, variables have a local scopes.
     Examples:

        * *note Py_INCREF(): 53a, *note Py_DECREF(): 53b.

        * *note Py_XINCREF(): a33, *note Py_XDECREF(): 75a.

        * ‘PyObject_INIT()’, ‘PyObject_INIT_VAR()’

        * Private functions: ‘_PyObject_GC_TRACK()’,
          ‘_PyObject_GC_UNTRACK()’, ‘_Py_Dealloc()’

     (Contributed by Victor Stinner in bpo-35059(4).)

   * The ‘PyByteArray_Init()’ and ‘PyByteArray_Fini()’ functions have
     been removed.  They did nothing since Python 2.7.4 and Python
     3.2.0, were excluded from the limited API (stable ABI), and were
     not documented.  (Contributed by Victor Stinner in bpo-35713(5).)

   * The result of ‘PyExceptionClass_Name()’ is now of type ‘const char
     *’ rather of ‘char *’.  (Contributed by Serhiy Storchaka in
     bpo-33818(6).)

   * The duality of ‘Modules/Setup.dist’ and ‘Modules/Setup’ has been
     removed.  Previously, when updating the CPython source tree, one
     had to manually copy ‘Modules/Setup.dist’ (inside the source tree)
     to ‘Modules/Setup’ (inside the build tree) in order to reflect any
     changes upstream.  This was of a small benefit to packagers at the
     expense of a frequent annoyance to developers following CPython
     development, as forgetting to copy the file could produce build
     failures.

     Now the build system always reads from ‘Modules/Setup’ inside the
     source tree.  People who want to customize that file are encouraged
     to maintain their changes in a git fork of CPython or as patch
     files, as they would do for any other change to the source tree.

     (Contributed by Antoine Pitrou in bpo-32430(7).)

   * Functions that convert Python number to C integer like *note
     PyLong_AsLong(): 339. and argument parsing functions like *note
     PyArg_ParseTuple(): 53d. with integer converting format units like
     ‘'i'’ will now use the *note __index__(): 6e8. special method
     instead of *note __int__(): 6e7, if available.  The deprecation
     warning will be emitted for objects with the ‘__int__()’ method but
     without the ‘__index__()’ method (like *note Decimal: 27d. and
     *note Fraction: 1c8.).  *note PyNumber_Check(): a34. will now
     return ‘1’ for objects implementing ‘__index__()’.  *note
     PyNumber_Long(): a35, *note PyNumber_Float(): a36. and *note
     PyFloat_AsDouble(): a37. also now use the ‘__index__()’ method if
     available.  (Contributed by Serhiy Storchaka in bpo-36048(8) and
     bpo-20092(9).)

   * Heap-allocated type objects will now increase their reference count
     in *note PyObject_Init(): a38. (and its parallel macro
     ‘PyObject_INIT’) instead of in *note PyType_GenericAlloc(): a39.
     Types that modify instance allocation or deallocation may need to
     be adjusted.  (Contributed by Eddie Elizondo in bpo-35810(10).)

   * The new function ‘PyCode_NewWithPosOnlyArgs()’ allows to create
     code objects like ‘PyCode_New()’, but with an extra
     'posonlyargcount' parameter for indicating the number of
     positional-only arguments.  (Contributed by Pablo Galindo in
     bpo-37221(11).)

   * ‘Py_SetPath()’ now sets *note sys.executable: 392. to the program
     full path (*note Py_GetProgramFullPath(): 391.) rather than to the
     program name (*note Py_GetProgramName(): 393.).  (Contributed by
     Victor Stinner in bpo-38234(12).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36707

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35081

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35059

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35713

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33818

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32430

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36048

   (9) https://bugs.python.org/issue?@action=redirect&bpo=20092

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35810

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37221

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38234


File: python.info,  Node: 非推奨<6>,  Next: API と機能の削除,  Prev: ビルドならびに C API の変更,  Up: What's New In Python 3 8

1.6.8 非推奨
------------

   * The distutils ‘bdist_wininst’ command is now deprecated, use
     ‘bdist_wheel’ (wheel packages) instead.  (Contributed by Victor
     Stinner in bpo-37481(1).)

   * Deprecated methods ‘getchildren()’ and ‘getiterator()’ in the *note
     ElementTree: 10c. module now emit a *note DeprecationWarning: 18a.
     instead of *note PendingDeprecationWarning: 895.  They will be
     removed in Python 3.9.  (Contributed by Serhiy Storchaka in
     bpo-29209(2).)

   * Passing an object that is not an instance of *note
     concurrent.futures.ThreadPoolExecutor: 70d. to *note
     loop.set_default_executor(): 70e. is deprecated and will be
     prohibited in Python 3.9.  (Contributed by Elvis Pranskevichus in
     bpo-34075(3).)

   * The *note __getitem__(): 264. methods of *note
     xml.dom.pulldom.DOMEventStream: 700, *note
     wsgiref.util.FileWrapper: 701. and *note fileinput.FileInput: 702.
     have been deprecated.

     Implementations of these methods have been ignoring their 'index'
     parameter, and returning the next item instead.  (Contributed by
     Berker Peksag in bpo-9372(4).)

   * The *note typing.NamedTuple: 290. class has deprecated the
     ‘_field_types’ attribute in favor of the ‘__annotations__’
     attribute which has the same information.  (Contributed by Raymond
     Hettinger in bpo-36320(5).)

   * *note ast: 7. classes ‘Num’, ‘Str’, ‘Bytes’, ‘NameConstant’ and
     ‘Ellipsis’ are considered deprecated and will be removed in future
     Python versions.  *note Constant: 299. should be used instead.
     (Contributed by Serhiy Storchaka in bpo-32892(6).)

   * *note ast.NodeVisitor: a3b. methods ‘visit_Num()’, ‘visit_Str()’,
     ‘visit_Bytes()’, ‘visit_NameConstant()’ and ‘visit_Ellipsis()’ are
     deprecated now and will not be called in future Python versions.
     Add the *note visit_Constant(): a3c. method to handle all constant
     nodes.  (Contributed by Serhiy Storchaka in bpo-36917(7).)

   * The ‘asyncio.coroutine()’ *note decorator: 6fc. is deprecated and
     will be removed in version 3.10.  Instead of ‘@asyncio.coroutine’,
     use *note async def: 59b. instead.  (Contributed by Andrew Svetlov
     in bpo-36921(8).)

   * In *note asyncio: 8, the explicit passing of a 'loop' argument has
     been deprecated and will be removed in version 3.10 for the
     following: *note asyncio.sleep(): a3d, *note asyncio.gather(): 5c8,
     *note asyncio.shield(): a3e, *note asyncio.wait_for(): 5ca, *note
     asyncio.wait(): 44c, *note asyncio.as_completed(): 18f, *note
     asyncio.Task: 4a5, *note asyncio.Lock: a3f, *note asyncio.Event:
     a40, *note asyncio.Condition: a41, *note asyncio.Semaphore: a42,
     *note asyncio.BoundedSemaphore: a43, *note asyncio.Queue: a44,
     *note asyncio.create_subprocess_exec(): a45, and *note
     asyncio.create_subprocess_shell(): a46.

   * The explicit passing of coroutine objects to *note asyncio.wait():
     44c. has been deprecated and will be removed in version 3.11.
     (Contributed by Yury Selivanov in bpo-34790(9).)

   * The following functions and methods are deprecated in the *note
     gettext: 59. module: ‘lgettext()’, ‘ldgettext()’, ‘lngettext()’ and
     ‘ldngettext()’.  They return encoded bytes, and it's possible that
     you will get unexpected Unicode-related exceptions if there are
     encoding problems with the translated strings.  It's much better to
     use alternatives which return Unicode strings in Python 3.  These
     functions have been broken for a long time.

     Function ‘bind_textdomain_codeset()’, methods ‘output_charset()’
     and ‘set_output_charset()’, and the 'codeset' parameter of
     functions *note translation(): a47. and *note install(): a48. are
     also deprecated, since they are only used for the ‘l*gettext()’
     functions.  (Contributed by Serhiy Storchaka in bpo-33710(10).)

   * The ‘isAlive()’ method of *note threading.Thread: 91a. has been
     deprecated.  (Contributed by Donghee Na in bpo-35283(11).)

   * Many builtin and extension functions that take integer arguments
     will now emit a deprecation warning for *note Decimal: 27d.s, *note
     Fraction: 1c8.s and any other objects that can be converted to
     integers only with a loss (e.g.  that have the *note __int__():
     6e7. method but do not have the *note __index__(): 6e8. method).
     In future version they will be errors.  (Contributed by Serhiy
     Storchaka in bpo-36048(12).)

   * Deprecated passing the following arguments as keyword arguments:

        - 'func' in *note functools.partialmethod(): a49, *note
          weakref.finalize(): a4a, *note profile.Profile.runcall(): a4b,
          ‘cProfile.Profile.runcall()’, *note bdb.Bdb.runcall(): a4c,
          *note trace.Trace.runfunc(): a4d. and *note curses.wrapper():
          a4e.

        - 'function' in *note unittest.TestCase.addCleanup(): a4f.

        - 'fn' in the *note submit(): a50. method of *note
          concurrent.futures.ThreadPoolExecutor: 70d. and *note
          concurrent.futures.ProcessPoolExecutor: 8bc.

        - 'callback' in *note contextlib.ExitStack.callback(): a51,
          ‘contextlib.AsyncExitStack.callback()’ and *note
          contextlib.AsyncExitStack.push_async_callback(): a52.

        - 'c' and 'typeid' in the ‘create()’ method of
          ‘multiprocessing.managers.Server’ and
          ‘multiprocessing.managers.SharedMemoryServer’.

        - 'obj' in *note weakref.finalize(): a4a.

     In future releases of Python, they will be *note positional-only:
     a53.  (Contributed by Serhiy Storchaka in bpo-36492(13).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37481

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29209

   (3) https://bugs.python.org/issue?@action=redirect&bpo=34075

   (4) https://bugs.python.org/issue?@action=redirect&bpo=9372

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36320

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32892

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36917

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36921

   (9) https://bugs.python.org/issue?@action=redirect&bpo=34790

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33710

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35283

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36048

   (13) https://bugs.python.org/issue?@action=redirect&bpo=36492


File: python.info,  Node: API と機能の削除,  Next: Python 3 8 への移植,  Prev: 非推奨<6>,  Up: What's New In Python 3 8

1.6.9 API と機能の削除
----------------------

The following features and APIs have been removed from Python 3.8:

   * Starting with Python 3.3, importing ABCs from *note collections:
     16. was deprecated, and importing should be done from *note
     collections.abc: 17.  Being able to import from collections was
     marked for removal in 3.8, but has been delayed to 3.9.  (See
     gh-81134(1).)

   * The ‘macpath’ module, deprecated in Python 3.7, has been removed.
     (Contributed by Victor Stinner in bpo-35471(2).)

   * The function ‘platform.popen()’ has been removed, after having been
     deprecated since Python 3.3: use *note os.popen(): a55. instead.
     (Contributed by Victor Stinner in bpo-35345(3).)

   * The function ‘time.clock()’ has been removed, after having been
     deprecated since Python 3.3: use *note time.perf_counter(): a56. or
     *note time.process_time(): a57. instead, depending on your
     requirements, to have well-defined behavior.  (Contributed by
     Matthias Bussonnier in bpo-36895(4).)

   * The ‘pyvenv’ script has been removed in favor of ‘python3.8 -m
     venv’ to help eliminate confusion as to what Python interpreter the
     ‘pyvenv’ script is tied to.  (Contributed by Brett Cannon in
     bpo-25427(5).)

   * ‘parse_qs’, ‘parse_qsl’, and ‘escape’ are removed from the ‘cgi’
     module.  They are deprecated in Python 3.2 or older.  They should
     be imported from the ‘urllib.parse’ and ‘html’ modules instead.

   * ‘filemode’ function is removed from the *note tarfile: c8. module.
     It is not documented and deprecated since Python 3.3.

   * The *note XMLParser: a22. constructor no longer accepts the 'html'
     argument.  It never had an effect and was deprecated in Python 3.4.
     All other parameters are now *note keyword-only: 285.  (Contributed
     by Serhiy Storchaka in bpo-29209(6).)

   * Removed the ‘doctype()’ method of *note XMLParser: a22.
     (Contributed by Serhiy Storchaka in bpo-29209(7).)

   * "unicode_internal" codec is removed.  (Contributed by Inada Naoki
     in bpo-36297(8).)

   * The ‘Cache’ and ‘Statement’ objects of the *note sqlite3: ba.
     module are not exposed to the user.  (Contributed by Aviv Palivoda
     in bpo-30262(9).)

   * The ‘bufsize’ keyword argument of *note fileinput.input(): 7ca. and
     *note fileinput.FileInput(): 702. which was ignored and deprecated
     since Python 3.6 has been removed.  bpo-36952(10) (Contributed by
     Matthias Bussonnier.)

   * The functions ‘sys.set_coroutine_wrapper()’ and
     ‘sys.get_coroutine_wrapper()’ deprecated in Python 3.7 have been
     removed; bpo-36933(11) (Contributed by Matthias Bussonnier.)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/81134

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35471

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35345

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36895

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25427

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29209

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29209

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36297

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30262

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36952

   (11) https://bugs.python.org/issue?@action=redirect&bpo=36933


File: python.info,  Node: Python 3 8 への移植,  Next: Python3 8 1 での重要な変更点,  Prev: API と機能の削除,  Up: What's New In Python 3 8

1.6.10 Python 3.8 への移植
--------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* Python の挙動の変更::
* Python API の変更: Python API の変更<3>.
* C API の変更: C API の変更<6>.
* CPython バイトコードの変更: CPython バイトコードの変更<4>.
* Demos and Tools: Demos and Tools<2>.


File: python.info,  Node: Python の挙動の変更,  Next: Python API の変更<3>,  Up: Python 3 8 への移植

1.6.10.1 Python の挙動の変更
............................

   * Yield expressions (both ‘yield’ and ‘yield from’ clauses) are now
     disallowed in comprehensions and generator expressions (aside from
     the iterable expression in the leftmost ‘for’ clause).
     (Contributed by Serhiy Storchaka in bpo-10544(1).)

   * The compiler now produces a *note SyntaxWarning: 432. when identity
     checks (‘is’ and ‘is not’) are used with certain types of literals
     (e.g.  strings, numbers).  These can often work by accident in
     CPython, but are not guaranteed by the language spec.  The warning
     advises users to use equality tests (‘==’ and ‘!=’) instead.
     (Contributed by Serhiy Storchaka in bpo-34850(2).)

   * The CPython interpreter can swallow exceptions in some
     circumstances.  In Python 3.8 this happens in fewer cases.  In
     particular, exceptions raised when getting the attribute from the
     type dictionary are no longer ignored.  (Contributed by Serhiy
     Storchaka in bpo-35459(3).)

   * Removed ‘__str__’ implementations from builtin types *note bool:
     434, *note int: 238, *note float: 2ce, *note complex: 2cf. and few
     classes from the standard library.  They now inherit ‘__str__()’
     from *note object: a5a.  As result, defining the ‘__repr__()’
     method in the subclass of these classes will affect their string
     representation.  (Contributed by Serhiy Storchaka in bpo-36793(4).)

   * On AIX, *note sys.platform: a5b. doesn't contain the major version
     anymore.  It is always ‘'aix'’, instead of ‘'aix3'’ ..  ‘'aix7'’.
     Since older Python versions include the version number, so it is
     recommended to always use ‘sys.platform.startswith('aix')’.
     (Contributed by M. Felt in bpo-36588(5).)

   * ‘PyEval_AcquireLock()’ and ‘PyEval_AcquireThread()’ now terminate
     the current thread if called while the interpreter is finalizing,
     making them consistent with *note PyEval_RestoreThread(): 383,
     *note Py_END_ALLOW_THREADS(): a5c, and *note PyGILState_Ensure():
     385.  If this behavior is not desired, guard the call by checking
     ‘_Py_IsFinalizing()’ or *note sys.is_finalizing(): a5d.
     (Contributed by Joannah Nanjekye in bpo-36475(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10544

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34850

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35459

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36793

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36588

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36475


File: python.info,  Node: Python API の変更<3>,  Next: C API の変更<6>,  Prev: Python の挙動の変更,  Up: Python 3 8 への移植

1.6.10.2 Python API の変更
..........................

   * The *note os.getcwdb(): a5f. function now uses the UTF-8 encoding
     on Windows, rather than the ANSI code page: see PEP 529(1) for the
     rationale.  The function is no longer deprecated on Windows.
     (Contributed by Victor Stinner in bpo-37412(2).)

   * *note subprocess.Popen: 17e. can now use *note os.posix_spawn():
     201. in some cases for better performance.  On Windows Subsystem
     for Linux and QEMU User Emulation, the ‘Popen’ constructor using
     *note os.posix_spawn(): 201. no longer raises an exception on
     errors like "missing program".  Instead the child process fails
     with a non-zero ‘returncode’.  (Contributed by Joannah Nanjekye and
     Victor Stinner in bpo-35537(3).)

   * The 'preexec_fn' argument of * *note subprocess.Popen: 17e. is no
     longer compatible with subinterpreters.  The use of the parameter
     in a subinterpreter now raises *note RuntimeError: 17a.
     (Contributed by Eric Snow in bpo-34651(4), modified by Christian
     Heimes in bpo-37951(5).)

   * The ‘imap.IMAP4.logout()’ method no longer silently ignores
     arbitrary exceptions.  (Contributed by Victor Stinner in
     bpo-36348(6).)

   * The function ‘platform.popen()’ has been removed, after having been
     deprecated since Python 3.3: use *note os.popen(): a55. instead.
     (Contributed by Victor Stinner in bpo-35345(7).)

   * The *note statistics.mode(): a60. function no longer raises an
     exception when given multimodal data.  Instead, it returns the
     first mode encountered in the input data.  (Contributed by Raymond
     Hettinger in bpo-35892(8).)

   * The *note selection(): a61. method of the *note
     tkinter.ttk.Treeview: a62. class no longer takes arguments.  Using
     it with arguments for changing the selection was deprecated in
     Python 3.6.  Use specialized methods like *note selection_set():
     a63. for changing the selection.  (Contributed by Serhiy Storchaka
     in bpo-31508(9).)

   * The ‘writexml()’, ‘toxml()’ and ‘toprettyxml()’ methods of *note
     xml.dom.minidom: 109, and the ‘write()’ method of ‘xml.etree’, now
     preserve the attribute order specified by the user.  (Contributed
     by Diego Rojas and Raymond Hettinger in bpo-34160(10).)

   * A *note dbm.dumb: 2a. database opened with flags ‘'r'’ is now
     read-only.  *note dbm.dumb.open(): a64. with flags ‘'r'’ and ‘'w'’
     no longer creates a database if it does not exist.  (Contributed by
     Serhiy Storchaka in bpo-32749(11).)

   * The ‘doctype()’ method defined in a subclass of *note XMLParser:
     a22. will no longer be called and will emit a *note RuntimeWarning:
     1a2. instead of a *note DeprecationWarning: 18a.  Define the *note
     doctype(): a65. method on a target for handling an XML doctype
     declaration.  (Contributed by Serhiy Storchaka in bpo-29209(12).)

   * A *note RuntimeError: 17a. is now raised when the custom metaclass
     doesn't provide the ‘__classcell__’ entry in the namespace passed
     to ‘type.__new__’.  A *note DeprecationWarning: 18a. was emitted in
     Python 3.6-3.7.  (Contributed by Serhiy Storchaka in
     bpo-23722(13).)

   * The ‘cProfile.Profile’ class can now be used as a context manager.
     (Contributed by Scott Sanderson in bpo-29235(14).)

   * *note shutil.copyfile(): a27, *note shutil.copy(): a28, *note
     shutil.copy2(): a29, *note shutil.copytree(): 9f7. and *note
     shutil.move(): a2a. use platform-specific "fast-copy" syscalls (see
     *note プラットフォーム依存の効率的なコピー操作: a2c. section).

   * *note shutil.copyfile(): a27. default buffer size on Windows was
     changed from 16 KiB to 1 MiB.

   * The ‘PyGC_Head’ struct has changed completely.  All code that
     touched the struct member should be rewritten.  (See
     bpo-33597(15).)

   * The *note PyInterpreterState: 88b. struct has been moved into the
     "internal" header files (specifically
     Include/internal/pycore_pystate.h).  An opaque ‘PyInterpreterState’
     is still available as part of the public API (and stable ABI). The
     docs indicate that none of the struct's fields are public, so we
     hope no one has been using them.  However, if you do rely on one or
     more of those private fields and have no alternative then please
     open a BPO issue.  We'll work on helping you adjust (possibly
     including adding accessor functions to the public API). (See
     bpo-35886(16).)

   * The *note mmap.flush(): a66. method now returns ‘None’ on success
     and raises an exception on error under all platforms.  Previously,
     its behavior was platform-dependent: a nonzero value was returned
     on success; zero was returned on error under Windows.  A zero value
     was returned on success; an exception was raised on error under
     Unix.  (Contributed by Berker Peksag in bpo-2122(17).)

   * *note xml.dom.minidom: 109. and *note xml.sax: 110. modules no
     longer process external entities by default.  (Contributed by
     Christian Heimes in bpo-17239(18).)

   * Deleting a key from a read-only *note dbm: 29. database (*note
     dbm.dumb: 2a, *note dbm.gnu: 2b. or *note dbm.ndbm: 2c.) raises
     ‘error’ (*note dbm.dumb.error: a67, *note dbm.gnu.error: a68. or
     *note dbm.ndbm.error: a69.) instead of *note KeyError: 31d.
     (Contributed by Xiang Zhang in bpo-33106(19).)

   * Simplified AST for literals.  All constants will be represented as
     *note ast.Constant: 299. instances.  Instantiating old classes
     ‘Num’, ‘Str’, ‘Bytes’, ‘NameConstant’ and ‘Ellipsis’ will return an
     instance of ‘Constant’.  (Contributed by Serhiy Storchaka in
     bpo-32892(20).)

   * *note expanduser(): 9e2. on Windows now prefers the ‘USERPROFILE’
     environment variable and does not use ‘HOME’, which is not normally
     set for regular user accounts.  (Contributed by Anthony Sottile in
     bpo-36264(21).)

   * The exception *note asyncio.CancelledError: 19d. now inherits from
     *note BaseException: 584. rather than *note Exception: 9a7. and no
     longer inherits from *note concurrent.futures.CancelledError: 9a8.
     (Contributed by Yury Selivanov in bpo-32528(22).)

   * The function *note asyncio.wait_for(): 5ca. now correctly waits for
     cancellation when using an instance of *note asyncio.Task: 4a5.
     Previously, upon reaching 'timeout', it was cancelled and
     immediately returned.  (Contributed by Elvis Pranskevichus in
     bpo-32751(23).)

   * The function *note asyncio.BaseTransport.get_extra_info(): a6a. now
     returns a safe to use socket object when 'socket' is passed to the
     'name' parameter.  (Contributed by Yury Selivanov in
     bpo-37027(24).)

   * *note asyncio.BufferedProtocol: a6b. has graduated to the stable
     API.

   * DLL dependencies for extension modules and DLLs loaded with *note
     ctypes: 22. on Windows are now resolved more securely.  Only the
     system paths, the directory containing the DLL or PYD file, and
     directories added with *note add_dll_directory(): 9b8. are searched
     for load-time dependencies.  Specifically, ‘PATH’ and the current
     working directory are no longer used, and modifications to these
     will no longer have any effect on normal DLL resolution.  If your
     application relies on these mechanisms, you should check for *note
     add_dll_directory(): 9b8. and if it exists, use it to add your DLLs
     directory while loading your library.  Note that Windows 7 users
     will need to ensure that Windows Update KB2533623 has been
     installed (this is also verified by the installer).  (Contributed
     by Steve Dower in bpo-36085(25).)

   * The header files and functions related to pgen have been removed
     after its replacement by a pure Python implementation.
     (Contributed by Pablo Galindo in bpo-36623(26).)

   * *note types.CodeType: 2c0. has a new parameter in the second
     position of the constructor ('posonlyargcount') to support
     positional-only arguments defined in PEP 570(27).  The first
     argument ('argcount') now represents the total number of positional
     arguments (including positional-only arguments).  The new
     ‘replace()’ method of *note types.CodeType: 2c0. can be used to
     make the code future-proof.

   * The parameter ‘digestmod’ for *note hmac.new(): a6d. no longer uses
     the MD5 digest by default.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0529/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37412

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35537

   (4) https://bugs.python.org/issue?@action=redirect&bpo=34651

   (5) https://bugs.python.org/issue?@action=redirect&bpo=37951

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36348

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35345

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35892

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31508

   (10) https://bugs.python.org/issue?@action=redirect&bpo=34160

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32749

   (12) https://bugs.python.org/issue?@action=redirect&bpo=29209

   (13) https://bugs.python.org/issue?@action=redirect&bpo=23722

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29235

   (15) https://bugs.python.org/issue?@action=redirect&bpo=33597

   (16) https://bugs.python.org/issue?@action=redirect&bpo=35886

   (17) https://bugs.python.org/issue?@action=redirect&bpo=2122

   (18) https://bugs.python.org/issue?@action=redirect&bpo=17239

   (19) https://bugs.python.org/issue?@action=redirect&bpo=33106

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32892

   (21) https://bugs.python.org/issue?@action=redirect&bpo=36264

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32528

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32751

   (24) https://bugs.python.org/issue?@action=redirect&bpo=37027

   (25) https://bugs.python.org/issue?@action=redirect&bpo=36085

   (26) https://bugs.python.org/issue?@action=redirect&bpo=36623

   (27) https://peps.python.org/pep-0570/


File: python.info,  Node: C API の変更<6>,  Next: CPython バイトコードの変更<4>,  Prev: Python API の変更<3>,  Up: Python 3 8 への移植

1.6.10.3 C API の変更
.....................

   * The *note PyCompilerFlags: a6f. structure got a new
     'cf_feature_version' field.  It should be initialized to
     ‘PY_MINOR_VERSION’.  The field is ignored by default, and is used
     if and only if ‘PyCF_ONLY_AST’ flag is set in 'cf_flags'.
     (Contributed by Guido van Rossum in bpo-35766(1).)

   * The ‘PyEval_ReInitThreads()’ function has been removed from the C
     API. It should not be called explicitly: use *note
     PyOS_AfterFork_Child(): 3d4. instead.  (Contributed by Victor
     Stinner in bpo-36728(2).)

   * On Unix, C extensions are no longer linked to libpython except on
     Android and Cygwin.  When Python is embedded, ‘libpython’ must not
     be loaded with ‘RTLD_LOCAL’, but ‘RTLD_GLOBAL’ instead.
     Previously, using ‘RTLD_LOCAL’, it was already not possible to load
     C extensions which were not linked to ‘libpython’, like C
     extensions of the standard library built by the ‘*shared*’ section
     of ‘Modules/Setup’.  (Contributed by Victor Stinner in
     bpo-21536(3).)

   * Use of ‘#’ variants of formats in parsing or building value (e.g.
     *note PyArg_ParseTuple(): 53d, *note Py_BuildValue(): 875, *note
     PyObject_CallFunction(): 378, etc.)  without ‘PY_SSIZE_T_CLEAN’
     defined raises ‘DeprecationWarning’ now.  It will be removed in
     3.10 or 4.0.  Read *note 引数の解釈と値の構築: 876. for detail.
     (Contributed by Inada Naoki in bpo-36381(4).)

   * Instances of heap-allocated types (such as those created with *note
     PyType_FromSpec(): 549.) hold a reference to their type object.
     Increasing the reference count of these type objects has been moved
     from *note PyType_GenericAlloc(): a39. to the more low-level
     functions, *note PyObject_Init(): a38. and ‘PyObject_INIT()’.  This
     makes types created through *note PyType_FromSpec(): 549. behave
     like other classes in managed code.

     *note Statically allocated types: 74a. are not affected.

     For the vast majority of cases, there should be no side effect.
     However, types that manually increase the reference count after
     allocating an instance (perhaps to work around the bug) may now
     become immortal.  To avoid this, these classes need to call
     Py_DECREF on the type object during instance deallocation.

     To correctly port these types into 3.8, please apply the following
     changes:

        * Remove *note Py_INCREF: 53a. on the type object after
          allocating an instance - if any.  This may happen after
          calling *note PyObject_New: 953, *note PyObject_NewVar: 954,
          *note PyObject_GC_New(): a70, *note PyObject_GC_NewVar(): a71,
          or any other custom allocator that uses *note PyObject_Init():
          a38. or ‘PyObject_INIT()’.

          例:

               static foo_struct *
               foo_new(PyObject *type) {
                   foo_struct *foo = PyObject_GC_New(foo_struct, (PyTypeObject *) type);
                   if (foo == NULL)
                       return NULL;
               #if PY_VERSION_HEX < 0x03080000
                   // Workaround for Python issue 35810; no longer necessary in Python 3.8
                   PY_INCREF(type)
               #endif
                   return foo;
               }

        * Ensure that all custom ‘tp_dealloc’ functions of
          heap-allocated types decrease the type's reference count.

          例:

               static void
               foo_dealloc(foo_struct *instance) {
                   PyObject *type = Py_TYPE(instance);
                   PyObject_GC_Del(instance);
               #if PY_VERSION_HEX >= 0x03080000
                   // This was not needed before Python 3.8 (Python issue 35810)
                   Py_DECREF(type);
               #endif
               }

     (Contributed by Eddie Elizondo in bpo-35810(5).)

   * The *note Py_DEPRECATED(): a72. macro has been implemented for
     MSVC.  The macro now must be placed before the symbol name.

     例:

          Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);

     (Contributed by Zackery Spytz in bpo-33407(6).)

   * The interpreter does not pretend to support binary compatibility of
     extension types across feature releases, anymore.  A *note
     PyTypeObject: a73. exported by a third-party extension module is
     supposed to have all the slots expected in the current Python
     version, including *note tp_finalize: a74. (*note
     Py_TPFLAGS_HAVE_FINALIZE: 3cb. is not checked anymore before
     reading *note tp_finalize: a74.).

     (Contributed by Antoine Pitrou in bpo-32388(7).)

   * The functions ‘PyNode_AddChild()’ and ‘PyParser_AddToken()’ now
     accept two additional ‘int’ arguments 'end_lineno' and
     'end_col_offset'.

   * The ‘libpython38.a’ file to allow MinGW tools to link directly
     against ‘python38.dll’ is no longer included in the regular Windows
     distribution.  If you require this file, it may be generated with
     the ‘gendef’ and ‘dlltool’ tools, which are part of the MinGW
     binutils package:

          gendef - python38.dll > tmp.def
          dlltool --dllname python38.dll --def tmp.def --output-lib libpython38.a

     The location of an installed ‘pythonXY.dll’ will depend on the
     installation options and the version and language of Windows.  See
     *note Windows で Python を使う: a75. for more information.  The
     resulting library should be placed in the same directory as
     ‘pythonXY.lib’, which is generally the ‘libs’ directory under your
     Python installation.

     (Contributed by Steve Dower in bpo-37351(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35766

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36728

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21536

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36381

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35810

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33407

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32388

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37351


File: python.info,  Node: CPython バイトコードの変更<4>,  Next: Demos and Tools<2>,  Prev: C API の変更<6>,  Up: Python 3 8 への移植

1.6.10.4 CPython バイトコードの変更
...................................

   * The interpreter loop has been simplified by moving the logic of
     unrolling the stack of blocks into the compiler.  The compiler
     emits now explicit instructions for adjusting the stack of values
     and calling the cleaning-up code for *note break: a77, *note
     continue: 998. and *note return: 99c.

     Removed opcodes ‘BREAK_LOOP’, ‘CONTINUE_LOOP’, ‘SETUP_LOOP’ and
     ‘SETUP_EXCEPT’.  Added new opcodes ‘ROT_FOUR’, ‘BEGIN_FINALLY’,
     ‘CALL_FINALLY’ and ‘POP_FINALLY’.  Changed the behavior of
     ‘END_FINALLY’ and ‘WITH_CLEANUP_START’.

     (Contributed by Mark Shannon, Antoine Pitrou and Serhiy Storchaka
     in bpo-17611(1).)

   * Added new opcode *note END_ASYNC_FOR: a78. for handling exceptions
     raised when awaiting a next item in an *note async for: a79. loop.
     (Contributed by Serhiy Storchaka in bpo-33041(2).)

   * The *note MAP_ADD: a7a. now expects the value as the first element
     in the stack and the key as the second element.  This change was
     made so the key is always evaluated before the value in dictionary
     comprehensions, as proposed by PEP 572(3).  (Contributed by Jörn
     Heissler in bpo-35224(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17611

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33041

   (3) https://peps.python.org/pep-0572/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35224


File: python.info,  Node: Demos and Tools<2>,  Prev: CPython バイトコードの変更<4>,  Up: Python 3 8 への移植

1.6.10.5 Demos and Tools
........................

Added a benchmark script for timing various ways to access variables:
‘Tools/scripts/var_access_benchmark.py’.  (Contributed by Raymond
Hettinger in bpo-35884(1).)

Here's a summary of performance improvements since Python 3.3:

     Python version                       3.3     3.4     3.5     3.6     3.7     3.8
     --------------                       ---     ---     ---     ---     ---     ---

     Variable and attribute read access:
         read_local                       4.0     7.1     7.1     5.4     5.1     3.9
         read_nonlocal                    5.3     7.1     8.1     5.8     5.4     4.4
         read_global                     13.3    15.5    19.0    14.3    13.6     7.6
         read_builtin                    20.0    21.1    21.6    18.5    19.0     7.5
         read_classvar_from_class        20.5    25.6    26.5    20.7    19.5    18.4
         read_classvar_from_instance     18.5    22.8    23.5    18.8    17.1    16.4
         read_instancevar                26.8    32.4    33.1    28.0    26.3    25.4
         read_instancevar_slots          23.7    27.8    31.3    20.8    20.8    20.2
         read_namedtuple                 68.5    73.8    57.5    45.0    46.8    18.4
         read_boundmethod                29.8    37.6    37.9    29.6    26.9    27.7

     Variable and attribute write access:
         write_local                      4.6     8.7     9.3     5.5     5.3     4.3
         write_nonlocal                   7.3    10.5    11.1     5.6     5.5     4.7
         write_global                    15.9    19.7    21.2    18.0    18.0    15.8
         write_classvar                  81.9    92.9    96.0   104.6   102.1    39.2
         write_instancevar               36.4    44.6    45.8    40.0    38.9    35.5
         write_instancevar_slots         28.7    35.6    36.1    27.3    26.6    25.7

     Data structure read access:
         read_list                       19.2    24.2    24.5    20.8    20.8    19.0
         read_deque                      19.9    24.7    25.5    20.2    20.6    19.8
         read_dict                       19.7    24.3    25.7    22.3    23.0    21.0
         read_strdict                    17.9    22.6    24.3    19.5    21.2    18.9

     Data structure write access:
         write_list                      21.2    27.1    28.5    22.5    21.6    20.0
         write_deque                     23.8    28.7    30.1    22.7    21.8    23.5
         write_dict                      25.9    31.4    33.3    29.3    29.2    24.7
         write_strdict                   22.9    28.4    29.9    27.5    25.2    23.1

     Stack (or queue) operations:
         list_append_pop                144.2    93.4   112.7    75.4    74.2    50.8
         deque_append_pop                30.4    43.5    57.0    49.4    49.2    42.5
         deque_append_popleft            30.8    43.7    57.3    49.7    49.7    42.8

     Timing loop:
         loop_overhead                    0.3     0.5     0.6     0.4     0.3     0.3

The benchmarks were measured on an Intel® Core™ i7-4960HQ processor(2)
running the macOS 64-bit builds found at python.org(3).  The benchmark
script displays timings in nanoseconds.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35884

   (2) 
https://ark.intel.com/content/www/us/en/ark/products/76088/intel-core-i7-4960hq-processor-6m-cache-up-to-3-80-ghz.html

   (3) https://www.python.org/downloads/macos/


File: python.info,  Node: Python3 8 1 での重要な変更点,  Next: Python3 8 2 での重要な変更点,  Prev: Python 3 8 への移植,  Up: What's New In Python 3 8

1.6.11 Python3.8.1 での重要な変更点
-----------------------------------

セキュリティ上の重大な懸念により、*note
asyncio.loop.create_datagram_endpoint(): 6fe. での 'reuse_address' 引数
は無効になりました。これはソケットオプション ‘SO_REUSEADDR'’ のUDP にお
ける挙動が原因です。詳しくは、‘loop.create_datagram_endpoint()’ のドキュ
メントを参照してください。(Kyle Stanley, Antoine Pitrou, Yury Selivanov
による貢献 bpo-37228(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37228


File: python.info,  Node: Python3 8 2 での重要な変更点,  Next: Notable changes in Python 3 8 3,  Prev: Python3 8 1 での重要な変更点,  Up: What's New In Python 3 8

1.6.12 Python3.8.2 での重要な変更点
-----------------------------------

Fixed a regression with the ‘ignore’ callback of *note
shutil.copytree(): 9f7.  The argument types are now str and List[str]
again.  (Contributed by Manuel Barkhau and Giampaolo Rodola in
gh-83571(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/83571


File: python.info,  Node: Notable changes in Python 3 8 3,  Next: Python3 8 8 での重要な変更点,  Prev: Python3 8 2 での重要な変更点,  Up: What's New In Python 3 8

1.6.13 Notable changes in Python 3.8.3
--------------------------------------

The constant values of future flags in the *note __future__: 0. module
are updated in order to prevent collision with compiler flags.
Previously ‘PyCF_ALLOW_TOP_LEVEL_AWAIT’ was clashing with
‘CO_FUTURE_DIVISION’.  (Contributed by Batuhan Taskaya in gh-83743(1))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/83743


File: python.info,  Node: Python3 8 8 での重要な変更点,  Next: Notable changes in Python 3 8 9,  Prev: Notable changes in Python 3 8 3,  Up: What's New In Python 3 8

1.6.14 Python3.8.8 での重要な変更点
-----------------------------------

Earlier Python versions allowed using both ‘;’ and ‘&’ as query
parameter separators in *note urllib.parse.parse_qs(): 25b. and *note
urllib.parse.parse_qsl(): 25a.  Due to security concerns, and to conform
with newer W3C recommendations, this has been changed to allow only a
single separator key, with ‘&’ as the default.  This change also affects
‘cgi.parse()’ and ‘cgi.parse_multipart()’ as they use the affected
functions internally.  For more details, please see their respective
documentation.  (Contributed by Adam Goldschmidt, Senthil Kumaran and
Ken Jin in bpo-42967(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42967


File: python.info,  Node: Notable changes in Python 3 8 9,  Next: Notable changes in Python 3 8 10,  Prev: Python3 8 8 での重要な変更点,  Up: What's New In Python 3 8

1.6.15 Notable changes in Python 3.8.9
--------------------------------------

A security fix alters the *note ftplib.FTP: 8c8. behavior to not trust
the IPv4 address sent from the remote server when setting up a passive
data channel.  We reuse the ftp server IP address instead.  For unusual
code requiring the old behavior, set a ‘trust_server_pasv_ipv4_address’
attribute on your FTP instance to ‘True’.  (See gh-87451(1))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/87451


File: python.info,  Node: Notable changes in Python 3 8 10,  Next: Notable changes in Python 3 8 10<2>,  Prev: Notable changes in Python 3 8 9,  Up: What's New In Python 3 8

1.6.16 Notable changes in Python 3.8.10
---------------------------------------

* Menu:

* macOS 11.0 (Big Sur) と Appleシリコンの Mac のサポート: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート<2>.


File: python.info,  Node: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート<2>,  Up: Notable changes in Python 3 8 10

1.6.16.1 macOS 11.0 (Big Sur) と Appleシリコンの Mac のサポート
...............................................................

As of 3.8.10, Python now supports building and running on macOS 11 (Big
Sur) and on Apple Silicon Macs (based on the ‘ARM64’ architecture).  A
new universal build variant, ‘universal2’, is now available to natively
support both ‘ARM64’ and ‘Intel 64’ in one set of executables.  Note
that support for "weaklinking", building binaries targeted for newer
versions of macOS that will also run correctly on older versions by
testing at runtime for missing features, is not included in this
backport from Python 3.9; to support a range of macOS versions, continue
to target for and build on the oldest version in the range.

(Originally contributed by Ronald Oussoren and Lawrence D'Anna in
gh-85272(1), with fixes by FX Coudert and Eli Rykoff, and backported to
3.8 by Maxime Bélanger and Ned Deily)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/85272


File: python.info,  Node: Notable changes in Python 3 8 10<2>,  Next: Notable changes in Python 3 8 12,  Prev: Notable changes in Python 3 8 10,  Up: What's New In Python 3 8

1.6.17 Notable changes in Python 3.8.10
---------------------------------------

* Menu:

* urllib.parse: urllib parse<4>.


File: python.info,  Node: urllib parse<4>,  Up: Notable changes in Python 3 8 10<2>

1.6.17.1 urllib.parse
.....................

The presence of newline or tab characters in parts of a URL allows for
some forms of attacks.  Following the WHATWG specification that updates
RFC 3986(1), ASCII newline ‘\n’, ‘\r’ and tab ‘\t’ characters are
stripped from the URL by the parser in *note urllib.parse: f3.
preventing such attacks.  The removal characters are controlled by a new
module level variable ‘urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE’.  (See
bpo-43882(2))

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3986.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43882


File: python.info,  Node: Notable changes in Python 3 8 12,  Next: Notable security feature in 3 8 14,  Prev: Notable changes in Python 3 8 10<2>,  Up: What's New In Python 3 8

1.6.18 Notable changes in Python 3.8.12
---------------------------------------

* Menu:

* Python API の変更: Python API の変更<4>.


File: python.info,  Node: Python API の変更<4>,  Up: Notable changes in Python 3 8 12

1.6.18.1 Python API の変更
..........................

Starting with Python 3.8.12 the *note ipaddress: 74. module no longer
accepts any leading zeros in IPv4 address strings.  Leading zeros are
ambiguous and interpreted as octal notation by some libraries.  For
example the legacy function *note socket.inet_aton(): 92f. treats
leading zeros as octal notation.  glibc implementation of modern *note
inet_pton(): 930. does not accept any leading zeros.

(Originally contributed by Christian Heimes in bpo-36384(1), and
backported to 3.8 by Achraf Merzouki.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36384


File: python.info,  Node: Notable security feature in 3 8 14,  Next: Notable changes in 3 8 17,  Prev: Notable changes in Python 3 8 12,  Up: What's New In Python 3 8

1.6.19 Notable security feature in 3.8.14
-----------------------------------------

Converting between *note int: 238. and *note str: 418. in bases other
than 2 (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10
(decimal) now raises a *note ValueError: 1e3. if the number of digits in
string form is above a limit to avoid potential denial of service
attacks due to the algorithmic complexity.  This is a mitigation for CVE
2020-10735(1).  This limit can be configured or disabled by environment
variable, command line flag, or *note sys: c3. APIs.  See the *note
integer string conversion length limitation: 5bf. documentation.  The
default limit is 4300 digits in string form.

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2020-10735


File: python.info,  Node: Notable changes in 3 8 17,  Prev: Notable security feature in 3 8 14,  Up: What's New In Python 3 8

1.6.20 Notable changes in 3.8.17
--------------------------------

* Menu:

* tarfile: tarfile<5>.


File: python.info,  Node: tarfile<5>,  Up: Notable changes in 3 8 17

1.6.20.1 tarfile
................

   * The extraction methods in *note tarfile: c8, and *note
     shutil.unpack_archive(): 438, have a new a 'filter' argument that
     allows limiting tar features than may be surprising or dangerous,
     such as creating files outside the destination directory.  See
     *note Extraction filters: 439. for details.  In Python 3.12, use
     without the 'filter' argument will show a *note DeprecationWarning:
     18a.  In Python 3.14, the default will switch to ‘'data'’.
     (Contributed by Petr Viktorin in PEP 706(1).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0706/


File: python.info,  Node: What's New In Python 3 7,  Next: What's New In Python 3 6,  Prev: What's New In Python 3 8,  Up: What's New in Python

1.7 What's New In Python 3.7
============================


編集者: Elvis Pranskevichus <<elvis@magic.io>>

この記事では Python 3.6 と比較した Python 3.7 の新機能を解説します。
Python 3.7 は2018年6月27日にリリースされました。全詳細については *note
変更履歴: 122. をご覧ください。

* Menu:

* 概要: 概要 -- リリースハイライト<5>. リリースハイライト
* 新しい機能: 新しい機能<8>.
* その他の言語変更: その他の言語変更<5>.
* 新たなモジュール: 新たなモジュール<5>.
* 改良されたモジュール: 改良されたモジュール<5>.
* C API の変更: C API の変更<7>.
* Build Changes: Build Changes<6>.
* 最適化: 最適化<5>.
* その他の CPython の実装の変更: その他の CPython の実装の変更<2>.
* 非推奨の Python の挙動::
* 非推奨の Python モジュール、関数、メソッド::
* C API の非推奨の関数ならびに型::
* サポート対象プラットフォームからの除外::
* API と機能の削除: API と機能の削除<2>.
* Module Removals::
* Windows-only Changes::
* Python 3.7 への移植: Python 3 7 への移植.
* Python 3.7.1 での重要な変更点: Python 3 7 1 での重要な変更点.
* Python 3.7.2 での重要な変更点: Python 3 7 2 での重要な変更点.
* Python 3.7.6 での重要な変更点: Python 3 7 6 での重要な変更点.
* Python 3.7.10 での重要な変更点: Python 3 7 10 での重要な変更点.
* Notable changes in Python 3.7.11: Notable changes in Python 3 7 11.
* Notable security feature in 3.7.14: Notable security feature in 3 7 14.


File: python.info,  Node: 概要 -- リリースハイライト<5>,  Next: 新しい機能<8>,  Up: What's New In Python 3 7

1.7.1 概要 - リリースハイライト
-------------------------------

新たな文法機能:

   * *note PEP 563: a8d. 、型アノテーションの評価の遅延。

後方非互換な文法の変更:

   * *note async: 6fd. と *note await: 19e. は予約されたキーワードになり
     ました。

新たなライブラリモジュール:

   * *note contextvars: 1d.: *note PEP 567 - コンテキスト変数: a8e.

   * *note dataclasses: 27.: *note PEP 557 - データクラス: a8f.

   * *note importlib.resources: a90.

新たな組み込み機能:

   * *note PEP 553: a91. 、新しい *note breakpoint(): 215. 関数。

Python のデータモデルの改善:

   * *note PEP 562: a92. 、モジュール属性へのアクセスのカスタマイズ。

   * *note PEP 560: a93. 、typing モジュールとジェネリック型に対する言語
     コアによるサポート。

   * *note dict: a94. オブジェクトの挿入順序を保存するという性質が、公式
     に Python 言語仕様の一部であると 宣言されました ('has been
     declared(1))。

標準ライブラリーの顕著な改善

   * *note asyncio: 8. モジュールに新しい機能が加わりました。 顕著な
     *note 使い勝手とパフォーマンスの改善: a95. です。

   * *note time: d7. モジュールが *note ナノ秒単位の分解能を持つ関数:
     a96. をサポートするようになりました。

CPython の実装の改善:

   * デフォルトのテキストエンコーディングとして ASCII を使わなくなりまし
     た:

        * *note PEP 538: a97. 、レガシーな C ロケールの抑圧

        * *note PEP 540: a98, UTF-8 実行時モードの強制

   * *note PEP 552: a99. 、決定論的な .pyc

   * *note New Python Development Mode: a9a.

   * *note PEP 565: a9b. 、 *note DeprecationWarning: 18a. の取り扱いの
     改善

C API の改善:

   * *note PEP 539: a9c. 、スレッドローカルなストレージのための新しい C
     API

ドキュメントの改善:

   * *note PEP 545: a9d. 、 Python ドキュメント翻訳

   * 新しいドキュメント翻訳: 日本語(2) 、 フランス語(3) 、 韓国語(4) 。

このリリースの特色は、多くの領域での特筆すべきパフォーマンスの改善です。
*note 最適化: a9e. 節に詳細な一覧があります。

1つ前にリリースされた Python との互換性に影響を持つ変更の一覧については
、 *note Python 3.7 への移植: a9f. 節を参照してください。

   ---------- Footnotes ----------

   (1) 
https://mail.python.org/pipermail/python-dev/2017-December/151283.html

   (2) https://docs.python.org/ja/

   (3) https://docs.python.org/fr/

   (4) https://docs.python.org/ko/


File: python.info,  Node: 新しい機能<8>,  Next: その他の言語変更<5>,  Prev: 概要 -- リリースハイライト<5>,  Up: What's New In Python 3 7

1.7.2 新しい機能
----------------

* Menu:

* PEP 563; アノテーションの遅延評価: PEP 563 アノテーションの遅延評価.
* PEP 538; レガシーな C ロケールの抑圧: PEP 538 レガシーな C ロケールの抑圧.
* PEP 540; 強制 UTF-8 実行モード: PEP 540 強制 UTF-8 実行モード.
* PEP 553; 組み込みの breakpoint(): PEP 553 組み込みの breakpoint.
* PEP 539; スレッドローカルストレージのための新しい C API: PEP 539 スレッドローカルストレージのための新しい C API.
* PEP 562; モジュール属性へのアクセスのカスタマイズ: PEP 562 モジュール属性へのアクセスのカスタマイズ.
* PEP 564; ナノ秒単位の分解能を持つ新しい時間関数: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数.
* PEP 565; Show DeprecationWarning in __main__: PEP 565 Show DeprecationWarning in __main__.
* PEP 560; typing モジュールとジェネリック型に対する言語コアによるサポート: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート.
* PEP 552; Hash-based .pyc Files: PEP 552 Hash-based pyc Files.
* PEP 545; Python Documentation Translations: PEP 545 Python Documentation Translations.
* Python Development Mode (-X dev): Python Development Mode -X dev.


File: python.info,  Node: PEP 563 アノテーションの遅延評価,  Next: PEP 538 レガシーな C ロケールの抑圧,  Up: 新しい機能<8>

1.7.2.1 PEP 563: アノテーションの遅延評価
.........................................

Python における型ヒントの到来により、 PEP 3107(1) で追加され PEP 526(2)
でさらに改善されたアノテーションの機能について、使い勝手に関する 2 つの
明白な問題が明らかになりました:

   * アノテーションには現在のスコープで既に使える状態になっている名前し
     か使えない。言い換えれば、どんな種類の前方参照もサポートしない。

   * ソースコードに注釈を付けるのは Python プログラムの起動時間に好まし
     くない影響がある。

これらの問題はどちらもアノテーションの評価を遅延することで解決します。 ア
ノテーションの定義時に、アノテーションに含まれる式を評価するコードをコン
パイルする代わりに、コンパイラは当該の式の AST と同等な文字列形式でアノ
テーションを保存します。 必要であれば、 *note typing.get_type_hints():
67d. を使って実行時にアノテーションを解決できます。 たいていのケースでは
その必要は無く、(短い文字列はインタプリタによって格納されるので) アノテ
ーションを保存するコストはより安くなり、起動時間がより速くなります。

使い勝手の点では、アノテーションは前方参照をサポートするようになり、次の
文法が妥当なものになりました:

     class C:
         @classmethod
         def from_string(cls, source: str) -> C:
             ...

         def validate_b(self, obj: B) -> bool:
             ...

     class B:
         ...

この変更は後方互換性を壊してしまうので、新しい振る舞いは Python 3.7 では
*note __future__: 0. インポートを使いモジュールごとに有効化する必要があ
ります:

     from __future__ import annotations

この振る舞いは Python 3.10 でデフォルトになります。

参考
....

PEP 563(3) - アノテーションの遅延評価

     PEP written and implemented by Łukasz Langa.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3107/

   (2) https://peps.python.org/pep-0526/

   (3) https://peps.python.org/pep-0563/


File: python.info,  Node: PEP 538 レガシーな C ロケールの抑圧,  Next: PEP 540 強制 UTF-8 実行モード,  Prev: PEP 563 アノテーションの遅延評価,  Up: 新しい機能<8>

1.7.2.2 PEP 538: レガシーな C ロケールの抑圧
............................................

Python 3 シリーズにおける継続中の課題の一つは、非 Windows プラットフォー
ムではデフォルトの C ロケールつまり POSIX ロケールの使用から現在のところ
必然的に導かれてしまう "7-bit ASCII" テキストエンコーディングの仮定を取
り扱う賢明なデフォルトの方針を決定することです。

PEP 538(1) はインタープリタのデフォルトのコマンドラインインターフェース
を更新し、新しく加わった *note PYTHONCOERCECLOCALE: aa3. 環境変数のドキ
ュメントにある通り、自動的にロケールを UTF-8 に基づいた利用可能なロケー
ルへ強制します。 この方法で ‘LC_CTYPE’ を自動的に設定すると、コアのイン
タープリタと (*note readline: a8. などの) ロケールを考慮する C 拡張はデ
フォルトのテキストエンコーディングとして ASCII ではなく UTF-8 を使うこと
になります。

PEP 11(2) にあるプラットフォームのサポート定義も、適切に設定された非
ASCII に基づくロケールだけにテキスト処理の完全なサポートを制限するよう更
新されました。

この変更の一部として、強制対象として定義されたのロケール (現時点では
‘C.UTF-8’, ‘C.utf8’, ‘UTF-8’) を使っているときの *note stdin: 507. と
*note stdout: aa4. のデフォルトのエラーハンドラは (‘strict’ ではなく)
‘surrogateescape’ になります。 *note stderr: 907. のデフォルトのエラーハ
ンドラは、ロケールに関係無く引き続き ‘backslashreplace’ です。

デフォルトではロケールの強制は暗黙に行われますが、ロケールが関係する結合
における問題のデバッグを支援するために、 ‘PYTHONCOERCECLOCALE=warn’ を設
定することで (*note stderr: 907. に直接出力される) 明示的な警告を要求で
きます。 この設定を有効にしていると、コアのインタプリタの初期化時にレガ
シーな C ロケールが有効なままの場合、 Python 実行器が警告を出力します。

PEP 538(3) のロケール強制には、(非 Python アプリケーションや古いバージョ
ンの Python で動くのも含めた) 子プロセスに加え (GNU ‘readline’ などの) 影
響を受ける拡張モジュールにも利益がある一方、適切な対象ロケールが実行する
システムに存在することを要求するという負の面もあります。 (例えば、
RHEL/CentOS 7 で起きているように) 適切な対象ロケールで利用可能なものが無
いケースにきちんと対処するために、 Python 3.7 には *note PEP 540; 強制
UTF-8 実行モード: a98. も実装されています。

参考
....

PEP 538(4) - レガシーな C ロケールから UTF-8 ベースのロケールへの強制

     PEP written and implemented by Nick Coghlan.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0538/

   (2) https://peps.python.org/pep-0011/

   (3) https://peps.python.org/pep-0538/

   (4) https://peps.python.org/pep-0538/


File: python.info,  Node: PEP 540 強制 UTF-8 実行モード,  Next: PEP 553 組み込みの breakpoint,  Prev: PEP 538 レガシーな C ロケールの抑圧,  Up: 新しい機能<8>

1.7.2.3 PEP 540: 強制 UTF-8 実行モード
......................................

The new *note -X: 15c. ‘utf8’ command line option and *note PYTHONUTF8:
aa6. environment variable can be used to enable the *note Python UTF-8
Mode: 622.

When in UTF-8 mode, CPython ignores the locale settings, and uses the
UTF-8 encoding by default.  The error handlers for *note sys.stdin: 507.
and *note sys.stdout: aa4. streams are set to ‘surrogateescape’.

The forced UTF-8 mode can be used to change the text handling behavior
in an embedded Python interpreter without changing the locale settings
of an embedding application.

While PEP 540(1)'s UTF-8 mode has the benefit of working regardless of
which locales are available on the running system, it has the downside
of having no effect on extension modules (such as GNU ‘readline’), child
processes running non-Python applications, and child processes running
older versions of Python.  To reduce the risk of corrupting text data
when communicating with such components, Python 3.7 also implements
*note PEP 540; 強制 UTF-8 実行モード: a98.).

The UTF-8 mode is enabled by default when the locale is ‘C’ or ‘POSIX’,
and the PEP 538(2) locale coercion feature fails to change it to a UTF-8
based alternative (whether that failure is due to
‘PYTHONCOERCECLOCALE=0’ being set, ‘LC_ALL’ being set, or the lack of a
suitable target locale).

参考
....

PEP 540(3) - 新しい UTF-8 モードの追加

     PEP written and implemented by Victor Stinner

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0540/

   (2) https://peps.python.org/pep-0538/

   (3) https://peps.python.org/pep-0540/


File: python.info,  Node: PEP 553 組み込みの breakpoint,  Next: PEP 539 スレッドローカルストレージのための新しい C API,  Prev: PEP 540 強制 UTF-8 実行モード,  Up: 新しい機能<8>

1.7.2.4 PEP 553: 組み込みの ‘breakpoint()’
..........................................

Python 3.7 には、 Python デバッガへ入って行くための簡単で一貫した手段で
ある、新しい組み込みの *note breakpoint(): 215. 関数があります。

Built-in ‘breakpoint()’ calls *note sys.breakpointhook(): aa8.  By
default, the latter imports *note pdb: 94. and then calls
‘pdb.set_trace()’, but by binding ‘sys.breakpointhook()’ to the function
of your choosing, ‘breakpoint()’ can enter any debugger.  Additionally,
the environment variable *note PYTHONBREAKPOINT: aa9. can be set to the
callable of your debugger of choice.  Set ‘PYTHONBREAKPOINT=0’ to
completely disable built-in ‘breakpoint()’.

参考
....

PEP 553(1) - 組み込みの breakpoint()

     PEP written and implemented by Barry Warsaw

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0553/


File: python.info,  Node: PEP 539 スレッドローカルストレージのための新しい C API,  Next: PEP 562 モジュール属性へのアクセスのカスタマイズ,  Prev: PEP 553 組み込みの breakpoint,  Up: 新しい機能<8>

1.7.2.5 PEP 539: スレッドローカルストレージのための新しい C API
...............................................................

While Python provides a C API for thread-local storage support; the
existing *note Thread Local Storage (TLS) API: aab. has used int to
represent TLS keys across all platforms.  This has not generally been a
problem for officially support platforms, but that is neither
POSIX-compliant, nor portable in any practical sense.

PEP 539(1) changes this by providing a new *note Thread Specific Storage
(TSS) API: aac. to CPython which supersedes use of the existing TLS API
within the CPython interpreter, while deprecating the existing API. The
TSS API uses a new type *note Py_tss_t: aad. instead of int to represent
TSS keys-an opaque type the definition of which may depend on the
underlying TLS implementation.  Therefore, this will allow to build
CPython on platforms where the native TLS key is defined in a way that
cannot be safely cast to int.

Note that on platforms where the native TLS key is defined in a way that
cannot be safely cast to int, all functions of the existing TLS API will
be no-op and immediately return failure.  This indicates clearly that
the old API is not supported on platforms where it cannot be used
reliably, and that no effort will be made to add such support.

参考
....

PEP 539(2) - A New C-API for Thread-Local Storage in CPython

     PEP written by Erik M. Bray; implementation by Masayuki Yamamoto.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0539/

   (2) https://peps.python.org/pep-0539/


File: python.info,  Node: PEP 562 モジュール属性へのアクセスのカスタマイズ,  Next: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数,  Prev: PEP 539 スレッドローカルストレージのための新しい C API,  Up: 新しい機能<8>

1.7.2.6 PEP 562: モジュール属性へのアクセスのカスタマイズ
.........................................................

Python 3.7 ではモジュールに ‘__getattr__()’ が定義でき、モジュール属性が
あるときでも無いときでもこのメソッドが呼び出されます。 ‘__dir__()’ メソ
ッドもモジュールに定義できます。

この機能が役に立つ典型的な実例はモジュール属性の非推奨化と遅延読み込みで
す。

参考
....

PEP 562(1) - モジュールの ‘__getattr__’ と ‘__dir__’

     PEP written and implemented by Ivan Levkivskyi

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0562/


File: python.info,  Node: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数,  Next: PEP 565 Show DeprecationWarning in __main__,  Prev: PEP 562 モジュール属性へのアクセスのカスタマイズ,  Up: 新しい機能<8>

1.7.2.7 PEP 564: ナノ秒単位の分解能を持つ新しい時間関数
.......................................................

The resolution of clocks in modern systems can exceed the limited
precision of a floating-point number returned by the *note time.time():
235. function and its variants.  To avoid loss of precision, PEP 564(1)
adds six new "nanosecond" variants of the existing timer functions to
the *note time: d7. module:

   * *note time.clock_gettime_ns(): ab0.

   * *note time.clock_settime_ns(): ab1.

   * *note time.monotonic_ns(): ab2.

   * *note time.perf_counter_ns(): ab3.

   * *note time.process_time_ns(): ab4.

   * *note time.time_ns(): ab5.

新しい関数は、整数値としてナノ秒単位の数値を返します。

Measurements(2) show that on Linux and Windows the resolution of *note
time.time_ns(): ab5. is approximately 3 times better than that of *note
time.time(): 235.

参考
....

PEP 564(3) - ナノ秒単位の分解能を持つ新しい時間関数の追加

     PEP written and implemented by Victor Stinner

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0564/

   (2) 
https://peps.python.org/pep-0564/#annex-clocks-resolution-in-python

   (3) https://peps.python.org/pep-0564/


File: python.info,  Node: PEP 565 Show DeprecationWarning in __main__,  Next: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート,  Prev: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数,  Up: 新しい機能<8>

1.7.2.8 PEP 565: Show DeprecationWarning in ‘__main__’
......................................................

The default handling of *note DeprecationWarning: 18a. has been changed
such that these warnings are once more shown by default, but only when
the code triggering them is running directly in the *note __main__: 1.
module.  As a result, developers of single file scripts and those using
Python interactively should once again start seeing deprecation warnings
for the APIs they use, but deprecation warnings triggered by imported
application, library and framework modules will continue to be hidden by
default.

As a result of this change, the standard library now allows developers
to choose between three different deprecation warning behaviours:

   * *note FutureWarning: 3ee.: always displayed by default, recommended
     for warnings intended to be seen by application end users (e.g.
     for deprecated application configuration settings).

   * *note DeprecationWarning: 18a.: displayed by default only in *note
     __main__: 1. and when running tests, recommended for warnings
     intended to be seen by other Python developers where a version
     upgrade may result in changed behaviour or an error.

   * *note PendingDeprecationWarning: 895.: displayed by default only
     when running tests, intended for cases where a future version
     upgrade will change the warning category to *note
     DeprecationWarning: 18a. or *note FutureWarning: 3ee.

Previously both *note DeprecationWarning: 18a. and *note
PendingDeprecationWarning: 895. were only visible when running tests,
which meant that developers primarily writing single file scripts or
using Python interactively could be surprised by breaking changes in the
APIs they used.

参考
....

PEP 565(1) - Show DeprecationWarning in ‘__main__’

     PEP written and implemented by Nick Coghlan

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0565/


File: python.info,  Node: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート,  Next: PEP 552 Hash-based pyc Files,  Prev: PEP 565 Show DeprecationWarning in __main__,  Up: 新しい機能<8>

1.7.2.9 PEP 560: ‘typing’ モジュールとジェネリック型に対する言語コアによるサポート
..................................................................................

当初 PEP 484(1) は、 CPython のインタプリタのコア部分に 'どんな' 変更も
施さないような方法で設計されていました。 今では型ヒントと *note typing:
ed. モジュールはコミュニティに広く使われるようになったため、この制限は取
り除かれました。 この PEP では、2 つの特殊メソッド ‘__class_getitem__()’
と ‘__mro_entries__’ が導入され、これらのメソッドはほとんどのクラスと
*note typing: ed. にある特別な構成物に使われています。 その結果、型に関
する様々な操作の速度が最大で 7 倍にまでなり、ジェネリック型はメタクラス
の衝突を起こさずに使えるようになり、 *note typing: ed. にずっとあったい
くつかのバグが修正されました。

参考
....

PEP 560(2) - typing モジュールとジェネリック型に対する言語コアによるサポート

     PEP written and implemented by Ivan Levkivskyi

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0560/


File: python.info,  Node: PEP 552 Hash-based pyc Files,  Next: PEP 545 Python Documentation Translations,  Prev: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート,  Up: 新しい機能<8>

1.7.2.10 PEP 552: Hash-based .pyc Files
.......................................

Python has traditionally checked the up-to-dateness of bytecode cache
files (i.e., ‘.pyc’ files) by comparing the source metadata
(last-modified timestamp and size) with source metadata saved in the
cache file header when it was generated.  While effective, this
invalidation method has its drawbacks.  When filesystem timestamps are
too coarse, Python can miss source updates, leading to user confusion.
Additionally, having a timestamp in the cache file is problematic for
build reproducibility(1) and content-based build systems.

PEP 552(2) extends the pyc format to allow the hash of the source file
to be used for invalidation instead of the source timestamp.  Such
‘.pyc’ files are called "hash-based".  By default, Python still uses
timestamp-based invalidation and does not generate hash-based ‘.pyc’
files at runtime.  Hash-based ‘.pyc’ files may be generated with *note
py_compile: a1. or *note compileall: 19.

Hash-based ‘.pyc’ files come in two variants: checked and unchecked.
Python validates checked hash-based ‘.pyc’ files against the
corresponding source files at runtime but doesn't do so for unchecked
hash-based pycs.  Unchecked hash-based ‘.pyc’ files are a useful
performance optimization for environments where a system external to
Python (e.g., the build system) is responsible for keeping ‘.pyc’ files
up-to-date.

See *note キャッシュされたバイトコードの無効化: 5b6. for more
information.

参考
....

PEP 552(3) - Deterministic pycs

     PEP written and implemented by Benjamin Peterson

   ---------- Footnotes ----------

   (1) https://reproducible-builds.org/

   (2) https://peps.python.org/pep-0552/

   (3) https://peps.python.org/pep-0552/


File: python.info,  Node: PEP 545 Python Documentation Translations,  Next: Python Development Mode -X dev,  Prev: PEP 552 Hash-based pyc Files,  Up: 新しい機能<8>

1.7.2.11 PEP 545: Python Documentation Translations
...................................................

PEP 545(1) describes the process of creating and maintaining Python
documentation translations.

Three new translations have been added:

   - 日本語: ‘https://docs.python.org/ja/’

   - フランス語: ‘https://docs.python.org/fr/’

   - 韓国語: ‘https://docs.python.org/ko/’

参考
....

PEP 545(2) - Python ドキュメント翻訳

     PEP written and implemented by Julien Palard, Inada Naoki, and
     Victor Stinner.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0545/

   (2) https://peps.python.org/pep-0545/


File: python.info,  Node: Python Development Mode -X dev,  Prev: PEP 545 Python Documentation Translations,  Up: 新しい機能<8>

1.7.2.12 Python Development Mode (-X dev)
.........................................

The new *note -X: 15c. ‘dev’ command line option or the new *note
PYTHONDEVMODE: abb. environment variable can be used to enable *note
Python Development Mode: 1d9.  When in development mode, Python performs
additional runtime checks that are too expensive to be enabled by
default.  See *note Python Development Mode: 1d9. documentation for the
full description.


File: python.info,  Node: その他の言語変更<5>,  Next: 新たなモジュール<5>,  Prev: 新しい機能<8>,  Up: What's New In Python 3 7

1.7.3 その他の言語変更
----------------------

   * An *note await: 19e. expression and comprehensions containing an
     *note async for: a79. clause were illegal in the expressions in
     *note formatted string literals: 977. due to a problem with the
     implementation.  In Python 3.7 this restriction was lifted.

   * More than 255 arguments can now be passed to a function, and a
     function can now have more than 255 parameters.  (Contributed by
     Serhiy Storchaka in bpo-12844(1) and bpo-18896(2).)

   * *note bytes.fromhex(): abd. and *note bytearray.fromhex(): abe. now
     ignore all ASCII whitespace, not only spaces.  (Contributed by
     Robert Xiao in bpo-28927(3).)

   * *note str: 418, *note bytes: 1a4, and *note bytearray: 508. gained
     support for the new *note isascii(): abf. method, which can be used
     to test if a string or bytes contain only the ASCII characters.
     (Contributed by INADA Naoki in bpo-32677(4).)

   * *note ImportError: 3f2. now displays module name and module
     ‘__file__’ path when ‘from ... import ...’ fails.  (Contributed by
     Matthias Bussonnier in bpo-29546(5).)

   * Circular imports involving absolute imports with binding a
     submodule to a name are now supported.  (Contributed by Serhiy
     Storchaka in bpo-30024(6).)

   * ‘object.__format__(x, '')’ is now equivalent to ‘str(x)’ rather
     than ‘format(str(self), '')’.  (Contributed by Serhiy Storchaka in
     bpo-28974(7).)

   * In order to better support dynamic creation of stack traces, *note
     types.TracebackType: ac0. can now be instantiated from Python code,
     and the *note tb_next: ac1. attribute on *note tracebacks: ac2. is
     now writable.  (Contributed by Nathaniel J. Smith in bpo-30579(8).)

   * When using the *note -m: 5ab. switch, ‘sys.path[0]’ is now eagerly
     expanded to the full starting directory path, rather than being
     left as the empty directory (which allows imports from the
     'current' working directory at the time when an import occurs)
     (Contributed by Nick Coghlan in bpo-33053(9).)

   * The new *note -X: 15c. ‘importtime’ option or the *note
     PYTHONPROFILEIMPORTTIME: ac3. environment variable can be used to
     show the timing of each module import.  (Contributed by Inada Naoki
     in bpo-31415(10).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12844

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18896

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28927

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32677

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29546

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30024

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28974

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30579

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33053

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31415


File: python.info,  Node: 新たなモジュール<5>,  Next: 改良されたモジュール<5>,  Prev: その他の言語変更<5>,  Up: What's New In Python 3 7

1.7.4 新たなモジュール
----------------------

* Menu:

* contextvars::
* データクラス: データクラス<3>.
* importlib.resources: importlib resources<2>.


File: python.info,  Node: contextvars,  Next: データクラス<3>,  Up: 新たなモジュール<5>

1.7.4.1 contextvars
...................

The new *note contextvars: 1d. module and a set of *note new C APIs:
ac6. introduce support for 'context variables'.  Context variables are
conceptually similar to thread-local variables.  Unlike TLS, context
variables support asynchronous code correctly.

The *note asyncio: 8. and *note decimal: 2e. modules have been updated
to use and support context variables out of the box.  Particularly the
active decimal context is now stored in a context variable, which allows
decimal operations to work with the correct context in asynchronous
code.

参考
....

PEP 567(1) - コンテキスト変数

     PEP written and implemented by Yury Selivanov

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0567/


File: python.info,  Node: データクラス<3>,  Next: importlib resources<2>,  Prev: contextvars,  Up: 新たなモジュール<5>

1.7.4.2 データクラス
....................

新しい *note dataclass(): 1ad. デコレータにより 'データクラス' を宣言す
る方法が提供されます。 データクラスは属性を記述するのに、クラス変数アノ
テーションを使います。 コンストラクタや他の *note __repr__(): 5e8, *note
__eq__(): ac8, *note __hash__(): ac9. などのマジックメソッドは自動で生成
されます。

以下はプログラム例です:

     @dataclass
     class Point:
         x: float
         y: float
         z: float = 0.0

     p = Point(1.5, 2.5)
     print(p)   # produces "Point(x=1.5, y=2.5, z=0.0)"

参考
....

PEP 557(1) - データクラス

     PEP written and implemented by Eric V. Smith

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0557/


File: python.info,  Node: importlib resources<2>,  Prev: データクラス<3>,  Up: 新たなモジュール<5>

1.7.4.3 importlib.resources
...........................

The new *note importlib.resources: 6f. module provides several new APIs
and one new ABC for access to, opening, and reading 'resources' inside
packages.  Resources are roughly similar to files inside packages, but
they needn't be actual files on the physical file system.  Module
loaders can provide a ‘get_resource_reader()’ function which returns a
*note importlib.abc.ResourceReader: acb. instance to support this new
API. Built-in file path loaders and zip file loaders both support this.

Contributed by Barry Warsaw and Brett Cannon in bpo-32248(1).

参考
....

importlib_resources(2) - a PyPI backport for earlier Python versions.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32248

   (2) https://importlib-resources.readthedocs.io/en/latest/


File: python.info,  Node: 改良されたモジュール<5>,  Next: C API の変更<7>,  Prev: 新たなモジュール<5>,  Up: What's New In Python 3 7

1.7.5 改良されたモジュール
--------------------------

* Menu:

* argparse: argparse<3>.
* asyncio: asyncio<7>.
* binascii::
* calendar: calendar<2>.
* collections: collections<2>.
* compileall: compileall<3>.
* concurrent.futures: concurrent futures<3>.
* contextlib: contextlib<3>.
* cProfile: cProfile<2>.
* crypt::
* datetime: datetime<4>.
* dbm: dbm<2>.
* decimal::
* dis: dis<3>.
* distutils: distutils<4>.
* enum: enum<4>.
* functools: functools<3>.
* gc: gc<4>.
* hmac: hmac<2>.
* http.client: http client.
* http.server: http server.
* idlelib と IDLE::
* importlib: importlib<4>.
* io: io<4>.
* ipaddress: ipaddress<3>.
* itertools: itertools<5>.
* locale: locale<4>.
* logging: logging<3>.
* math: math<6>.
* mimetypes: mimetypes<2>.
* msilib::
* multiprocessing: multiprocessing<4>.
* os: os<7>.
* pathlib: pathlib<8>.
* pdb: pdb<4>.
* py_compile: py_compile<3>.
* pydoc: pydoc<2>.
* queue: queue<2>.
* re: re<4>.
* signal: signal<2>.
* socket: socket<5>.
* socketserver::
* sqlite3: sqlite3<6>.
* ssl: ssl<5>.
* string: string<2>.
* subprocess: subprocess<2>.
* sys: sys<8>.
* time: time<5>.
* tkinter: tkinter<5>.
* tracemalloc: tracemalloc<2>.
* types: types<4>.
* unicodedata: unicodedata<6>.
* unittest: unittest<7>.
* unittest.mock: unittest mock.
* urllib.parse: urllib parse<5>.
* uu::
* uuid: uuid<2>.
* warnings: warnings<3>.
* xml: xml<5>.
* xml.etree: xml etree.
* xmlrpc.server: xmlrpc server.
* zipapp::
* zipfile: zipfile<2>.


File: python.info,  Node: argparse<3>,  Next: asyncio<7>,  Up: 改良されたモジュール<5>

1.7.5.1 argparse
................

The new *note ArgumentParser.parse_intermixed_args(): ace. method allows
intermixing options and positional arguments.  (Contributed by paul.j3
in bpo-14191(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14191


File: python.info,  Node: asyncio<7>,  Next: binascii,  Prev: argparse<3>,  Up: 改良されたモジュール<5>

1.7.5.2 asyncio
...............

The *note asyncio: 8. module has received many new features, usability
and *note performance improvements: ad0.  Notable changes include:

   * The new *note provisional: ad1. *note asyncio.run(): 449. function
     can be used to run a coroutine from synchronous code by
     automatically creating and destroying the event loop.  (Contributed
     by Yury Selivanov in bpo-32314(1).)

   * asyncio gained support for *note contextvars: 1d.  *note
     loop.call_soon(): ad2, *note loop.call_soon_threadsafe(): ad3,
     *note loop.call_later(): ad4, *note loop.call_at(): ad5, and *note
     Future.add_done_callback(): ad6. have a new optional keyword-only
     'context' parameter.  *note Tasks: 4a5. now track their context
     automatically.  See PEP 567(2) for more details.  (Contributed by
     Yury Selivanov in bpo-32436(3).)

   * The new *note asyncio.create_task(): 5c7. function has been added
     as a shortcut to ‘asyncio.get_event_loop().create_task()’.
     (Contributed by Andrew Svetlov in bpo-32311(4).)

   * The new *note loop.start_tls(): ad7. method can be used to upgrade
     an existing connection to TLS. (Contributed by Yury Selivanov in
     bpo-23749(5).)

   * The new *note loop.sock_recv_into(): ad8. method allows reading
     data from a socket directly into a provided buffer making it
     possible to reduce data copies.  (Contributed by Antoine Pitrou in
     bpo-31819(6).)

   * The new *note asyncio.current_task(): 44a. function returns the
     currently running *note Task: 4a5. instance, and the new *note
     asyncio.all_tasks(): 924. function returns a set of all existing
     ‘Task’ instances in a given loop.  The ‘Task.current_task()’ and
     ‘Task.all_tasks()’ methods have been deprecated.  (Contributed by
     Andrew Svetlov in bpo-32250(7).)

   * The new 'provisional' *note BufferedProtocol: a6b. class allows
     implementing streaming protocols with manual control over the
     receive buffer.  (Contributed by Yury Selivanov in bpo-32251(8).)

   * The new *note asyncio.get_running_loop(): ad9. function returns the
     currently running loop, and raises a *note RuntimeError: 17a. if no
     loop is running.  This is in contrast with *note
     asyncio.get_event_loop(): 2a2, which will 'create' a new event loop
     if none is running.  (Contributed by Yury Selivanov in
     bpo-32269(9).)

   * The new *note StreamWriter.wait_closed(): ada. coroutine method
     allows waiting until the stream writer is closed.  The new *note
     StreamWriter.is_closing(): adb. method can be used to determine if
     the writer is closing.  (Contributed by Andrew Svetlov in
     bpo-32391(10).)

   * The new *note loop.sock_sendfile(): adc. coroutine method allows
     sending files using *note os.sendfile: add. when possible.
     (Contributed by Andrew Svetlov in bpo-32410(11).)

   * The new *note Future.get_loop(): ade. and ‘Task.get_loop()’ methods
     return the instance of the loop on which a task or a future were
     created.  *note Server.get_loop(): adf. allows doing the same for
     *note asyncio.Server: ae0. objects.  (Contributed by Yury Selivanov
     in bpo-32415(12) and Srinivas Reddy Thatiparthy in bpo-32418(13).)

   * It is now possible to control how instances of *note
     asyncio.Server: ae0. begin serving.  Previously, the server would
     start serving immediately when created.  The new 'start_serving'
     keyword argument to *note loop.create_server(): ae1. and *note
     loop.create_unix_server(): 193, as well as *note
     Server.start_serving(): ae2, and *note Server.serve_forever(): ae3.
     can be used to decouple server instantiation and serving.  The new
     *note Server.is_serving(): ae4. method returns ‘True’ if the server
     is serving.  *note Server: ae0. objects are now asynchronous
     context managers:

          srv = await loop.create_server(...)

          async with srv:
              # some code

          # At this point, srv is closed and no longer accepts new connections.

     (Contributed by Yury Selivanov in bpo-32662(14).)

   * Callback objects returned by *note loop.call_later(): ad4. gained
     the new *note when(): ae5. method which returns an absolute
     scheduled callback timestamp.  (Contributed by Andrew Svetlov in
     bpo-32741(15).)

   * The *note loop.create_datagram_endpoint(): 6fe. method gained
     support for Unix sockets.  (Contributed by Quentin Dawans in
     bpo-31245(16).)

   * The *note asyncio.open_connection(): ae6, *note
     asyncio.start_server(): ae7. functions, *note
     loop.create_connection(): 5ce, *note loop.create_server(): ae1,
     *note loop.create_accepted_socket(): ae8. methods and their
     corresponding UNIX socket variants now accept the
     'ssl_handshake_timeout' keyword argument.  (Contributed by Neil
     Aspinall in bpo-29970(17).)

   * The new *note Handle.cancelled(): ae9. method returns ‘True’ if the
     callback was cancelled.  (Contributed by Marat Sharafutdinov in
     bpo-31943(18).)

   * The asyncio source has been converted to use the *note async:
     6fd./*note await: 19e. syntax.  (Contributed by Andrew Svetlov in
     bpo-32193(19).)

   * The new *note ReadTransport.is_reading(): aea. method can be used
     to determine the reading state of the transport.  Additionally,
     calls to *note ReadTransport.resume_reading(): aeb. and *note
     ReadTransport.pause_reading(): aec. are now idempotent.
     (Contributed by Yury Selivanov in bpo-32356(20).)

   * Loop methods which accept socket paths now support passing *note
     path-like objects: 280.  (Contributed by Yury Selivanov in
     bpo-32066(21).)

   * In *note asyncio: 8. TCP sockets on Linux are now created with
     ‘TCP_NODELAY’ flag set by default.  (Contributed by Yury Selivanov
     and Victor Stinner in bpo-27456(22).)

   * Exceptions occurring in cancelled tasks are no longer logged.
     (Contributed by Yury Selivanov in bpo-30508(23).)

   * New ‘WindowsSelectorEventLoopPolicy’ and
     ‘WindowsProactorEventLoopPolicy’ classes.  (Contributed by Yury
     Selivanov in bpo-33792(24).)

Several ‘asyncio’ APIs have been *note deprecated: aed.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32314

   (2) https://peps.python.org/pep-0567/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32436

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32311

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23749

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31819

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32250

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32251

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32269

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32391

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32410

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32415

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32418

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32662

   (15) https://bugs.python.org/issue?@action=redirect&bpo=32741

   (16) https://bugs.python.org/issue?@action=redirect&bpo=31245

   (17) https://bugs.python.org/issue?@action=redirect&bpo=29970

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31943

   (19) https://bugs.python.org/issue?@action=redirect&bpo=32193

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32356

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32066

   (22) https://bugs.python.org/issue?@action=redirect&bpo=27456

   (23) https://bugs.python.org/issue?@action=redirect&bpo=30508

   (24) https://bugs.python.org/issue?@action=redirect&bpo=33792


File: python.info,  Node: binascii,  Next: calendar<2>,  Prev: asyncio<7>,  Up: 改良されたモジュール<5>

1.7.5.3 binascii
................

The *note b2a_uu(): aef. function now accepts an optional 'backtick'
keyword argument.  When it's true, zeros are represented by ‘'`'’
instead of spaces.  (Contributed by Xiang Zhang in bpo-30103(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30103


File: python.info,  Node: calendar<2>,  Next: collections<2>,  Prev: binascii,  Up: 改良されたモジュール<5>

1.7.5.4 calendar
................

*note HTMLCalendar: af1. クラスに、作成された HTML カレンダーの CSS クラ
スのカスタマイズを容易にするクラス属性が新しく加わりました。
(Contributed by Oz Tiram in bpo-30095(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30095


File: python.info,  Node: collections<2>,  Next: compileall<3>,  Prev: calendar<2>,  Up: 改良されたモジュール<5>

1.7.5.5 collections
...................

‘collections.namedtuple()’ がデフォルト値をサポートするようになりました
。 (Contributed by Raymond Hettinger in bpo-32320(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32320


File: python.info,  Node: compileall<3>,  Next: concurrent futures<3>,  Prev: collections<2>,  Up: 改良されたモジュール<5>

1.7.5.6 compileall
..................

*note compileall.compile_dir(): af4. learned the new 'invalidation_mode'
parameter, which can be used to enable *note hash-based .pyc
invalidation: a99.  The invalidation mode can also be specified on the
command line using the new ‘--invalidation-mode’ argument.  (Contributed
by Benjamin Peterson in bpo-31650(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31650


File: python.info,  Node: concurrent futures<3>,  Next: contextlib<3>,  Prev: compileall<3>,  Up: 改良されたモジュール<5>

1.7.5.7 concurrent.futures
..........................

*note ProcessPoolExecutor: 8bc. と *note ThreadPoolExecutor: 70d. が新し
いコンストラクタ引数 'initializer' と 'initargs' をサポートするようにな
りました。 (Contributed by Antoine Pitrou in bpo-21423(1).)

*note ProcessPoolExecutor: 8bc. が新しい 'mp_context' 引数を通して
multiprocessing の context を受け取れるようになりました。 (Contributed
by Thomas Moreau in bpo-31540(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21423

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31540


File: python.info,  Node: contextlib<3>,  Next: cProfile<2>,  Prev: concurrent futures<3>,  Up: 改良されたモジュール<5>

1.7.5.8 contextlib
..................

The new *note nullcontext(): 7b9. is a simpler and faster no-op context
manager than *note ExitStack: af7.  (Contributed by Jesse-Bakker in
bpo-10049(1).)

The new *note asynccontextmanager(): af8, *note
AbstractAsyncContextManager: af9, and *note AsyncExitStack: afa. have
been added to complement their synchronous counterparts.  (Contributed
by Jelle Zijlstra in bpo-29679(2) and bpo-30241(3), and by Alexander
Mohr and Ilya Kulakov in bpo-29302(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10049

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29679

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30241

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29302


File: python.info,  Node: cProfile<2>,  Next: crypt,  Prev: contextlib<3>,  Up: 改良されたモジュール<5>

1.7.5.9 cProfile
................

The *note cProfile: 20. command line now accepts ‘-m module_name’ as an
alternative to script path.  (Contributed by Sanyam Khurana in
bpo-21862(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21862


File: python.info,  Node: crypt,  Next: datetime<4>,  Prev: cProfile<2>,  Up: 改良されたモジュール<5>

1.7.5.10 crypt
..............

The ‘crypt’ module now supports the Blowfish hashing method.
(Contributed by Serhiy Storchaka in bpo-31664(1).)

The ‘mksalt()’ function now allows specifying the number of rounds for
hashing.  (Contributed by Serhiy Storchaka in bpo-31702(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31664

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31702


File: python.info,  Node: datetime<4>,  Next: dbm<2>,  Prev: crypt,  Up: 改良されたモジュール<5>

1.7.5.11 datetime
.................

The new *note datetime.fromisoformat(): 5e2. method constructs a *note
datetime: 1ae. object from a string in one of the formats output by
*note datetime.isoformat(): afe.  (Contributed by Paul Ganssle in
bpo-15873(1).)

The *note tzinfo: 5a8. class now supports sub-minute offsets.
(Contributed by Alexander Belopolsky in bpo-5288(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15873

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5288


File: python.info,  Node: dbm<2>,  Next: decimal,  Prev: datetime<4>,  Up: 改良されたモジュール<5>

1.7.5.12 dbm
............

*note dbm.dumb: 2a. now supports reading read-only files and no longer
writes the index file when it is not changed.


File: python.info,  Node: decimal,  Next: dis<3>,  Prev: dbm<2>,  Up: 改良されたモジュール<5>

1.7.5.13 decimal
................

The *note decimal: 2e. module now uses *note context variables: a8e. to
store the decimal context.  (Contributed by Yury Selivanov in
bpo-32630(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32630


File: python.info,  Node: dis<3>,  Next: distutils<4>,  Prev: decimal,  Up: 改良されたモジュール<5>

1.7.5.14 dis
............

The *note dis(): b02. function is now able to disassemble nested code
objects (the code of comprehensions, generator expressions and nested
functions, and the code used for building nested classes).  The maximum
depth of disassembly recursion is controlled by the new 'depth'
parameter.  (Contributed by Serhiy Storchaka in bpo-11822(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11822


File: python.info,  Node: distutils<4>,  Next: enum<4>,  Prev: dis<3>,  Up: 改良されたモジュール<5>

1.7.5.15 distutils
..................

‘README.rst’ is now included in the list of distutils standard READMEs
and therefore included in source distributions.  (Contributed by Ryan
Gonzalez in bpo-11913(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11913


File: python.info,  Node: enum<4>,  Next: functools<3>,  Prev: distutils<4>,  Up: 改良されたモジュール<5>

1.7.5.16 enum
.............

The *note Enum: 5fc. learned the new ‘_ignore_’ class property, which
allows listing the names of properties which should not become enum
members.  (Contributed by Ethan Furman in bpo-31801(1).)

In Python 3.8, attempting to check for non-Enum objects in ‘Enum’
classes will raise a *note TypeError: 502. (e.g.  ‘1 in Color’);
similarly, attempting to check for non-Flag objects in a ‘Flag’ member
will raise *note TypeError: 502. (e.g.  ‘1 in Perm.RW’); currently, both
operations return *note False: b05. instead and are deprecated.
(Contributed by Ethan Furman in bpo-33217(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31801

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33217


File: python.info,  Node: functools<3>,  Next: gc<4>,  Prev: enum<4>,  Up: 改良されたモジュール<5>

1.7.5.17 functools
..................

*note functools.singledispatch(): 605. now supports registering
implementations using type annotations.  (Contributed by Łukasz Langa in
bpo-32227(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32227


File: python.info,  Node: gc<4>,  Next: hmac<2>,  Prev: functools<3>,  Up: 改良されたモジュール<5>

1.7.5.18 gc
...........

The new *note gc.freeze(): b08. function allows freezing all objects
tracked by the garbage collector and excluding them from future
collections.  This can be used before a POSIX ‘fork()’ call to make the
GC copy-on-write friendly or to speed up collection.  The new *note
gc.unfreeze(): b09. functions reverses this operation.  Additionally,
*note gc.get_freeze_count(): b0a. can be used to obtain the number of
frozen objects.  (Contributed by Li Zekun in bpo-31558(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31558


File: python.info,  Node: hmac<2>,  Next: http client,  Prev: gc<4>,  Up: 改良されたモジュール<5>

1.7.5.19 hmac
.............

The *note hmac: 60. module now has an optimized one-shot *note digest():
b0c. function, which is up to three times faster than ‘HMAC()’.
(Contributed by Christian Heimes in bpo-32433(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32433


File: python.info,  Node: http client,  Next: http server,  Prev: hmac<2>,  Up: 改良されたモジュール<5>

1.7.5.20 http.client
....................

*note HTTPConnection: b0e. and *note HTTPSConnection: b0f. now support
the new 'blocksize' argument for improved upload throughput.
(Contributed by Nir Soffer in bpo-31945(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31945


File: python.info,  Node: http server,  Next: idlelib と IDLE,  Prev: http client,  Up: 改良されたモジュール<5>

1.7.5.21 http.server
....................

*note SimpleHTTPRequestHandler: b11. now supports the HTTP
‘If-Modified-Since’ header.  The server returns the 304 response status
if the target file was not modified after the time specified in the
header.  (Contributed by Pierre Quentel in bpo-29654(1).)

*note SimpleHTTPRequestHandler: b11. accepts the new 'directory'
argument, in addition to the new ‘--directory’ command line argument.
With this parameter, the server serves the specified directory, by
default it uses the current working directory.  (Contributed by Stéphane
Wirtel and Julien Palard in bpo-28707(2).)

The new *note ThreadingHTTPServer: b12. class uses threads to handle
requests using ‘ThreadingMixin’.  It is used when ‘http.server’ is run
with ‘-m’.  (Contributed by Julien Palard in bpo-31639(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29654

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28707

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31639


File: python.info,  Node: idlelib と IDLE,  Next: importlib<4>,  Prev: http server,  Up: 改良されたモジュール<5>

1.7.5.22 idlelib と IDLE
........................

自動補完におけるいくつもの修正。 (Contributed by Louie Lu in
bpo-15786(1).)

Module Browser (on the File menu, formerly called Class Browser), now
displays nested functions and classes in addition to top-level functions
and classes.  (Contributed by Guilherme Polo, Cheryl Sabella, and Terry
Jan Reedy in bpo-1612262(2).)

The Settings dialog (Options, Configure IDLE) has been partly rewritten
to improve both appearance and function.  (Contributed by Cheryl Sabella
and Terry Jan Reedy in multiple issues.)

The font sample now includes a selection of non-Latin characters so that
users can better see the effect of selecting a particular font.
(Contributed by Terry Jan Reedy in bpo-13802(3).)  The sample can be
edited to include other characters.  (Contributed by Serhiy Storchaka in
bpo-31860(4).)

The IDLE features formerly implemented as extensions have been
reimplemented as normal features.  Their settings have been moved from
the Extensions tab to other dialog tabs.  (Contributed by Charles
Wohlganger and Terry Jan Reedy in bpo-27099(5).)

Editor code context option revised.  Box displays all context lines up
to maxlines.  Clicking on a context line jumps the editor to that line.
Context colors for custom themes is added to Highlights tab of Settings
dialog.  (Contributed by Cheryl Sabella and Terry Jan Reedy in
bpo-33642(6), bpo-33768(7), and bpo-33679(8).)

On Windows, a new API call tells Windows that tk scales for DPI. On
Windows 8.1+ or 10, with DPI compatibility properties of the Python
binary unchanged, and a monitor resolution greater than 96 DPI, this
should make text and lines sharper.  It should otherwise have no effect.
(Contributed by Terry Jan Reedy in bpo-33656(9).)

New in 3.7.1:

Output over N lines (50 by default) is squeezed down to a button.  N can
be changed in the PyShell section of the General page of the Settings
dialog.  Fewer, but possibly extra long, lines can be squeezed by right
clicking on the output.  Squeezed output can be expanded in place by
double-clicking the button or into the clipboard or a separate window by
right-clicking the button.  (Contributed by Tal Einat in
bpo-1529353(10).)

上で挙げた変更は 3.6 のメンテナンスリリースにバックポートされました。

NEW in 3.7.4:

Add "Run Customized" to the Run menu to run a module with customized
settings.  Any command line arguments entered are added to sys.argv.
They re-appear in the box for the next customized run.  One can also
suppress the normal Shell main module restart.  (Contributed by Cheryl
Sabella, Terry Jan Reedy, and others in bpo-5680(11) and bpo-37627(12).)

New in 3.7.5:

Add optional line numbers for IDLE editor windows.  Windows open without
line numbers unless set otherwise in the General tab of the
configuration dialog.  Line numbers for an existing window are shown and
hidden in the Options menu.  (Contributed by Tal Einat and Saimadhav
Heblikar in bpo-17535(13).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15786

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1612262

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13802

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31860

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27099

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33642

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33768

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33679

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33656

   (10) https://bugs.python.org/issue?@action=redirect&bpo=1529353

   (11) https://bugs.python.org/issue?@action=redirect&bpo=5680

   (12) https://bugs.python.org/issue?@action=redirect&bpo=37627

   (13) https://bugs.python.org/issue?@action=redirect&bpo=17535


File: python.info,  Node: importlib<4>,  Next: io<4>,  Prev: idlelib と IDLE,  Up: 改良されたモジュール<5>

1.7.5.23 importlib
..................

The *note importlib.abc.ResourceReader: acb. ABC was introduced to
support the loading of resources from packages.  See also *note
importlib.resources: a90.  (Contributed by Barry Warsaw, Brett Cannon in
bpo-32248(1).)

*note importlib.reload(): 4e2. now raises *note ModuleNotFoundError:
b15. if the module lacks a spec.  (Contributed by Garvit Khatri in
bpo-29851(2).)

‘importlib.find_spec()’ now raises *note ModuleNotFoundError: b15.
instead of *note AttributeError: 326. if the specified parent module is
not a package (i.e.  lacks a ‘__path__’ attribute).  (Contributed by
Milan Oberkirch in bpo-30436(3).)

The new ‘importlib.source_hash()’ can be used to compute the hash of the
passed source.  A *note hash-based .pyc file: a99. embeds the value
returned by this function.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32248

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29851

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30436


File: python.info,  Node: io<4>,  Next: ipaddress<3>,  Prev: importlib<4>,  Up: 改良されたモジュール<5>

1.7.5.24 io
...........

The new *note TextIOWrapper.reconfigure(): b17. method can be used to
reconfigure the text stream with the new settings.  (Contributed by
Antoine Pitrou in bpo-30526(1) and INADA Naoki in bpo-15216(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30526

   (2) https://bugs.python.org/issue?@action=redirect&bpo=15216


File: python.info,  Node: ipaddress<3>,  Next: itertools<5>,  Prev: io<4>,  Up: 改良されたモジュール<5>

1.7.5.25 ipaddress
..................

The new ‘subnet_of()’ and ‘supernet_of()’ methods of *note
ipaddress.IPv6Network: 1e0. and *note ipaddress.IPv4Network: 1df. can be
used for network containment tests.  (Contributed by Michel Albert and
Cheryl Sabella in bpo-20825(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20825


File: python.info,  Node: itertools<5>,  Next: locale<4>,  Prev: ipaddress<3>,  Up: 改良されたモジュール<5>

1.7.5.26 itertools
..................

*note itertools.islice(): b1a. now accepts *note integer-like objects:
6e8. as start, stop, and slice arguments.  (Contributed by Will Roberts
in bpo-30537(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30537


File: python.info,  Node: locale<4>,  Next: logging<3>,  Prev: itertools<5>,  Up: 改良されたモジュール<5>

1.7.5.27 locale
...............

The new 'monetary' argument to *note locale.format_string(): 4e8. can be
used to make the conversion use monetary thousands separators and
grouping strings.  (Contributed by Garvit in bpo-10379(1).)

The *note locale.getpreferredencoding(): 504. function now always
returns ‘'UTF-8'’ on Android or when in the *note forced UTF-8 mode:
a98.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10379


File: python.info,  Node: logging<3>,  Next: math<6>,  Prev: locale<4>,  Up: 改良されたモジュール<5>

1.7.5.28 logging
................

*note Logger: b1d. インスタンスが pickle 化できるようになりました。
(Contributed by Vinay Sajip in bpo-30520(1).)

The new *note StreamHandler.setStream(): b1e. method can be used to
replace the logger stream after handler creation.  (Contributed by Vinay
Sajip in bpo-30522(2).)

It is now possible to specify keyword arguments to handler constructors
in configuration passed to *note logging.config.fileConfig(): b1f.
(Contributed by Preston Landers in bpo-31080(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30520

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30522

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31080


File: python.info,  Node: math<6>,  Next: mimetypes<2>,  Prev: logging<3>,  Up: 改良されたモジュール<5>

1.7.5.29 math
.............

新しい *note math.remainder(): b21. 関数が IEEE 754 方式の剰余演算で実装
されています。 Contributed by Mark Dickinson in bpo-29962(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29962


File: python.info,  Node: mimetypes<2>,  Next: msilib,  Prev: math<6>,  Up: 改良されたモジュール<5>

1.7.5.30 mimetypes
..................

The MIME type of .bmp has been changed from ‘'image/x-ms-bmp'’ to
‘'image/bmp'’.  (Contributed by Nitish Chandra in bpo-22589(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22589


File: python.info,  Node: msilib,  Next: multiprocessing<4>,  Prev: mimetypes<2>,  Up: 改良されたモジュール<5>

1.7.5.31 msilib
...............

The new ‘Database.Close()’ method can be used to close the MSI database.
(Contributed by Berker Peksag in bpo-20486(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20486


File: python.info,  Node: multiprocessing<4>,  Next: os<7>,  Prev: msilib,  Up: 改良されたモジュール<5>

1.7.5.32 multiprocessing
........................

The new *note Process.close(): b25. method explicitly closes the process
object and releases all resources associated with it.  *note ValueError:
1e3. is raised if the underlying process is still running.  (Contributed
by Antoine Pitrou in bpo-30596(1).)

The new *note Process.kill(): b26. method can be used to terminate the
process using the ‘SIGKILL’ signal on Unix.  (Contributed by Vitor
Pereira in bpo-30794(2).)

Non-daemonic threads created by *note Process: b27. are now joined on
process exit.  (Contributed by Antoine Pitrou in bpo-18966(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30596

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30794

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18966


File: python.info,  Node: os<7>,  Next: pathlib<8>,  Prev: multiprocessing<4>,  Up: 改良されたモジュール<5>

1.7.5.33 os
...........

*note os.fwalk(): b29. now accepts the 'path' argument as *note bytes:
1a4.  (Contributed by Serhiy Storchaka in bpo-28682(1).)

*note os.scandir(): a2d. gained support for *note file descriptors: b2a.
(Contributed by Serhiy Storchaka in bpo-25996(2).)

The new *note register_at_fork(): 2d7. function allows registering
Python callbacks to be executed at process fork.  (Contributed by
Antoine Pitrou in bpo-16500(3).)

Added *note os.preadv(): b2b. (combine the functionality of *note
os.readv(): b2c. and *note os.pread(): b2d.) and *note os.pwritev():
b2e. functions (combine the functionality of *note os.writev(): b2f. and
*note os.pwrite(): b30.).  (Contributed by Pablo Galindo in
bpo-31368(4).)

The mode argument of *note os.makedirs(): 1ff. no longer affects the
file permission bits of newly created intermediate-level directories.
(Contributed by Serhiy Storchaka in bpo-19930(5).)

*note os.dup2(): b31. now returns the new file descriptor.  Previously,
‘None’ was always returned.  (Contributed by Benjamin Peterson in
bpo-32441(6).)

The structure returned by *note os.stat(): 46d. now contains the *note
st_fstype: b32. attribute on Solaris and its derivatives.  (Contributed
by Jesús Cea Avión in bpo-32659(7).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28682

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25996

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16500

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31368

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19930

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32441

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32659


File: python.info,  Node: pathlib<8>,  Next: pdb<4>,  Prev: os<7>,  Up: 改良されたモジュール<5>

1.7.5.34 pathlib
................

The new *note Path.is_mount(): 9e5. method is now available on POSIX
systems and can be used to determine whether a path is a mount point.
(Contributed by Cooper Ry Lees in bpo-30897(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30897


File: python.info,  Node: pdb<4>,  Next: py_compile<3>,  Prev: pathlib<8>,  Up: 改良されたモジュール<5>

1.7.5.35 pdb
............

*note pdb.set_trace(): 216. now takes an optional 'header' keyword-only
argument.  If given, it is printed to the console just before debugging
begins.  (Contributed by Barry Warsaw in bpo-31389(1).)

*note pdb: 94. command line now accepts ‘-m module_name’ as an
alternative to script file.  (Contributed by Mario Corchero in
bpo-32206(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31389

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32206


File: python.info,  Node: py_compile<3>,  Next: pydoc<2>,  Prev: pdb<4>,  Up: 改良されたモジュール<5>

1.7.5.36 py_compile
...................

*note py_compile.compile(): 9f3. - and by extension, *note compileall:
19. - now respects the ‘SOURCE_DATE_EPOCH’ environment variable by
unconditionally creating ‘.pyc’ files for hash-based validation.  This
allows for guaranteeing reproducible builds(1) of ‘.pyc’ files when they
are created eagerly.  (Contributed by Bernhard M. Wiedemann in
bpo-29708(2).)

   ---------- Footnotes ----------

   (1) https://reproducible-builds.org/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29708


File: python.info,  Node: pydoc<2>,  Next: queue<2>,  Prev: py_compile<3>,  Up: 改良されたモジュール<5>

1.7.5.37 pydoc
..............

The pydoc server can now bind to an arbitrary hostname specified by the
new ‘-n’ command-line argument.  (Contributed by Feanil Patel in
bpo-31128(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31128


File: python.info,  Node: queue<2>,  Next: re<4>,  Prev: pydoc<2>,  Up: 改良されたモジュール<5>

1.7.5.38 queue
..............

The new *note SimpleQueue: b38. class is an unbounded FIFO queue.
(Contributed by Antoine Pitrou in bpo-14976(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14976


File: python.info,  Node: re<4>,  Next: signal<2>,  Prev: queue<2>,  Up: 改良されたモジュール<5>

1.7.5.39 re
...........

The flags *note re.ASCII: 5f8, *note re.LOCALE: b3a. and *note
re.UNICODE: b3b. can be set within the scope of a group.  (Contributed
by Serhiy Storchaka in bpo-31690(1).)

*note re.split(): 282. now supports splitting on a pattern like ‘r'\b'’,
‘'^$'’ or ‘(?=-)’ that matches an empty string.  (Contributed by Serhiy
Storchaka in bpo-25054(2).)

Regular expressions compiled with the *note re.LOCALE: b3a. flag no
longer depend on the locale at compile time.  Locale settings are
applied only when the compiled regular expression is used.  (Contributed
by Serhiy Storchaka in bpo-30215(3).)

*note FutureWarning: 3ee. is now emitted if a regular expression
contains character set constructs that will change semantically in the
future, such as nested sets and set operations.  (Contributed by Serhiy
Storchaka in bpo-30349(4).)

Compiled regular expression and match objects can now be copied using
*note copy.copy(): 4fd. and *note copy.deepcopy(): b3c.  (Contributed by
Serhiy Storchaka in bpo-10076(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31690

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25054

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30215

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30349

   (5) https://bugs.python.org/issue?@action=redirect&bpo=10076


File: python.info,  Node: signal<2>,  Next: socket<5>,  Prev: re<4>,  Up: 改良されたモジュール<5>

1.7.5.40 signal
...............

The new 'warn_on_full_buffer' argument to the *note
signal.set_wakeup_fd(): b3e. function makes it possible to specify
whether Python prints a warning on stderr when the wakeup buffer
overflows.  (Contributed by Nathaniel J. Smith in bpo-30050(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30050


File: python.info,  Node: socket<5>,  Next: socketserver,  Prev: signal<2>,  Up: 改良されたモジュール<5>

1.7.5.41 socket
...............

The new *note socket.getblocking(): b40. method returns ‘True’ if the
socket is in blocking mode and ‘False’ otherwise.  (Contributed by Yury
Selivanov in bpo-32373(1).)

The new *note socket.close(): b41. function closes the passed socket
file descriptor.  This function should be used instead of *note
os.close(): b42. for better compatibility across platforms.
(Contributed by Christian Heimes in bpo-32454(2).)

The *note socket: b8. module now exposes the ‘socket.TCP_CONGESTION’
(Linux 2.6.13), ‘socket.TCP_USER_TIMEOUT’ (Linux 2.6.37), and
‘socket.TCP_NOTSENT_LOWAT’ (Linux 3.12) constants.  (Contributed by Omar
Sandoval in bpo-26273(3) and Nathaniel J. Smith in bpo-29728(4).)

Support for *note socket.AF_VSOCK: b43. sockets has been added to allow
communication between virtual machines and their hosts.  (Contributed by
Cathy Avery in bpo-27584(5).)

Sockets now auto-detect family, type and protocol from file descriptor
by default.  (Contributed by Christian Heimes in bpo-28134(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32373

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32454

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26273

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29728

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27584

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28134


File: python.info,  Node: socketserver,  Next: sqlite3<6>,  Prev: socket<5>,  Up: 改良されたモジュール<5>

1.7.5.42 socketserver
.....................

‘socketserver.ThreadingMixIn.server_close()’ now waits until all
non-daemon threads complete.  ‘socketserver.ForkingMixIn.server_close()’
now waits until all child processes complete.

Add a new ‘socketserver.ForkingMixIn.block_on_close’ class attribute to
*note socketserver.ForkingMixIn: b45. and *note
socketserver.ThreadingMixIn: b46. classes.  Set the class attribute to
‘False’ to get the pre-3.7 behaviour.


File: python.info,  Node: sqlite3<6>,  Next: ssl<5>,  Prev: socketserver,  Up: 改良されたモジュール<5>

1.7.5.43 sqlite3
................

*note sqlite3.Connection: 226. now exposes the *note backup(): b48.
method when the underlying SQLite library is at version 3.6.11 or
higher.  (Contributed by Lele Gaifax in bpo-27645(1).)

The 'database' argument of *note sqlite3.connect(): 288. now accepts any
*note path-like object: 280, instead of just a string.  (Contributed by
Anders Lorentsen in bpo-31843(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27645

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31843


File: python.info,  Node: ssl<5>,  Next: string<2>,  Prev: sqlite3<6>,  Up: 改良されたモジュール<5>

1.7.5.44 ssl
............

The *note ssl: bb. module now uses OpenSSL's builtin API instead of
‘match_hostname()’ to check a host name or an IP address.  Values are
validated during TLS handshake.  Any certificate validation error
including failing the host name check now raises *note
SSLCertVerificationError: b4a. and aborts the handshake with a proper
TLS Alert message.  The new exception contains additional information.
Host name validation can be customized with *note
SSLContext.hostname_checks_common_name: b4b.  (Contributed by Christian
Heimes in bpo-31399(1).)

     注釈: The improved host name check requires a 'libssl'
     implementation compatible with OpenSSL 1.0.2 or 1.1.  Consequently,
     OpenSSL 0.9.8 and 1.0.1 are no longer supported (see *note
     サポート対象プラットフォームからの除外: b4c. for more details).
     The ssl module is mostly compatible with LibreSSL 2.7.2 and newer.

The ‘ssl’ module no longer sends IP addresses in SNI TLS extension.
(Contributed by Christian Heimes in bpo-32185(2).)

‘match_hostname()’ no longer supports partial wildcards like
‘www*.example.org’.  (Contributed by Mandeep Singh in bpo-23033(3) and
Christian Heimes in bpo-31399(4).)

The default cipher suite selection of the ‘ssl’ module now uses a
blacklist approach rather than a hard-coded whitelist.  Python no longer
re-enables ciphers that have been blocked by OpenSSL security updates.
Default cipher suite selection can be configured at compile time.
(Contributed by Christian Heimes in bpo-31429(5).)

Validation of server certificates containing internationalized domain
names (IDNs) is now supported.  As part of this change, the *note
SSLSocket.server_hostname: b4d. attribute now stores the expected
hostname in A-label form (‘"xn--pythn-mua.org"’), rather than the
U-label form (‘"pythön.org"’).  (Contributed by Nathaniel J. Smith and
Christian Heimes in bpo-28414(6).)

The ‘ssl’ module has preliminary and experimental support for TLS 1.3
and OpenSSL 1.1.1.  At the time of Python 3.7.0 release, OpenSSL 1.1.1
is still under development and TLS 1.3 hasn't been finalized yet.  The
TLS 1.3 handshake and protocol behaves slightly differently than TLS 1.2
and earlier, see *note TLS 1.3: b4e.  (Contributed by Christian Heimes
in bpo-32947(7), bpo-20995(8), bpo-29136(9), bpo-30622(10) and
bpo-33618(11))

*note SSLSocket: 8b8. and *note SSLObject: b4f. no longer have a public
constructor.  Direct instantiation was never a documented and supported
feature.  Instances must be created with *note SSLContext: 274. methods
*note wrap_socket(): 4ee. and *note wrap_bio(): b50.  (Contributed by
Christian Heimes in bpo-32951(12))

OpenSSL 1.1 APIs for setting the minimum and maximum TLS protocol
version are available as *note SSLContext.minimum_version: 83c. and
*note SSLContext.maximum_version: 83d.  Supported protocols are
indicated by several new flags, such as *note HAS_TLSv1_1: b51.
(Contributed by Christian Heimes in bpo-32609(13).)

Added *note ssl.SSLContext.post_handshake_auth: 9ff. to enable and *note
ssl.SSLSocket.verify_client_post_handshake(): a00. to initiate TLS 1.3
post-handshake authentication.  (Contributed by Christian Heimes in
gh-78851(14).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31399

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32185

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23033

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31399

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31429

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28414

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32947

   (8) https://bugs.python.org/issue?@action=redirect&bpo=20995

   (9) https://bugs.python.org/issue?@action=redirect&bpo=29136

   (10) https://bugs.python.org/issue?@action=redirect&bpo=30622

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33618

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32951

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32609

   (14) https://github.com/python/cpython/issues/78851


File: python.info,  Node: string<2>,  Next: subprocess<2>,  Prev: ssl<5>,  Up: 改良されたモジュール<5>

1.7.5.45 string
...............

*note string.Template: 653. now lets you to optionally modify the
regular expression pattern for braced placeholders and non-braced
placeholders separately.  (Contributed by Barry Warsaw in
bpo-1198569(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1198569


File: python.info,  Node: subprocess<2>,  Next: sys<8>,  Prev: string<2>,  Up: 改良されたモジュール<5>

1.7.5.46 subprocess
...................

The *note subprocess.run(): b54. function accepts the new
'capture_output' keyword argument.  When true, stdout and stderr will be
captured.  This is equivalent to passing *note subprocess.PIPE: b55. as
'stdout' and 'stderr' arguments.  (Contributed by Bo Bayles in
bpo-32102(1).)

The ‘subprocess.run’ function and the *note subprocess.Popen: 17e.
constructor now accept the 'text' keyword argument as an alias to
'universal_newlines'.  (Contributed by Andrew Clegg in bpo-31756(2).)

On Windows the default for 'close_fds' was changed from ‘False’ to
‘True’ when redirecting the standard handles.  It's now possible to set
'close_fds' to true when redirecting the standard handles.  See *note
subprocess.Popen: 17e.  This means that 'close_fds' now defaults to
‘True’ on all supported platforms.  (Contributed by Segev Finer in
bpo-19764(3).)

The subprocess module is now more graceful when handling *note
KeyboardInterrupt: 99f. during *note subprocess.call(): b56, *note
subprocess.run(): b54, or in a *note Popen: 17e. context manager.  It
now waits a short amount of time for the child to exit, before
continuing the handling of the ‘KeyboardInterrupt’ exception.
(Contributed by Gregory P. Smith in bpo-25942(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32102

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31756

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19764

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25942


File: python.info,  Node: sys<8>,  Next: time<5>,  Prev: subprocess<2>,  Up: 改良されたモジュール<5>

1.7.5.47 sys
............

The new *note sys.breakpointhook(): aa8. hook function is called by the
built-in *note breakpoint(): 215.  (Contributed by Barry Warsaw in
bpo-31353(1).)

On Android, the new *note sys.getandroidapilevel(): b58. returns the
build-time Android API version.  (Contributed by Victor Stinner in
bpo-28740(2).)

The new *note sys.get_coroutine_origin_tracking_depth(): b59. function
returns the current coroutine origin tracking depth, as set by the new
*note sys.set_coroutine_origin_tracking_depth(): b5a.  *note asyncio: 8.
has been converted to use this new API instead of the deprecated
‘sys.set_coroutine_wrapper()’.  (Contributed by Nathaniel J. Smith in
bpo-32591(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31353

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28740

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32591


File: python.info,  Node: time<5>,  Next: tkinter<5>,  Prev: sys<8>,  Up: 改良されたモジュール<5>

1.7.5.48 time
.............

PEP 564(1) adds six new functions with nanosecond resolution to the
*note time: d7. module:

   * *note time.clock_gettime_ns(): ab0.

   * *note time.clock_settime_ns(): ab1.

   * *note time.monotonic_ns(): ab2.

   * *note time.perf_counter_ns(): ab3.

   * *note time.process_time_ns(): ab4.

   * *note time.time_ns(): ab5.

New clock identifiers have been added:

   * *note time.CLOCK_BOOTTIME: b5c. (Linux): Identical to *note
     time.CLOCK_MONOTONIC: 665, except it also includes any time that
     the system is suspended.

   * *note time.CLOCK_PROF: b5d. (FreeBSD, NetBSD and OpenBSD):
     High-resolution per-process CPU timer.

   * *note time.CLOCK_UPTIME: b5e. (FreeBSD, OpenBSD): Time whose
     absolute value is the time the system has been running and not
     suspended, providing accurate uptime measurement.

The new *note time.thread_time(): 904. and *note time.thread_time_ns():
b5f. functions can be used to get per-thread CPU time measurements.
(Contributed by Antoine Pitrou in bpo-32025(2).)

The new *note time.pthread_getcpuclockid(): b60. function returns the
clock ID of the thread-specific CPU-time clock.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0564/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32025


File: python.info,  Node: tkinter<5>,  Next: tracemalloc<2>,  Prev: time<5>,  Up: 改良されたモジュール<5>

1.7.5.49 tkinter
................

The new *note tkinter.ttk.Spinbox: b62. class is now available.
(Contributed by Alan Moore in bpo-32585(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32585


File: python.info,  Node: tracemalloc<2>,  Next: types<4>,  Prev: tkinter<5>,  Up: 改良されたモジュール<5>

1.7.5.50 tracemalloc
....................

*note tracemalloc.Traceback: b64. behaves more like regular tracebacks,
sorting the frames from oldest to most recent.  *note
Traceback.format(): b65. now accepts negative 'limit', truncating the
result to the ‘abs(limit)’ oldest frames.  To get the old behaviour, use
the new 'most_recent_first' argument to ‘Traceback.format()’.
(Contributed by Jesse Bakker in bpo-32121(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32121


File: python.info,  Node: types<4>,  Next: unicodedata<6>,  Prev: tracemalloc<2>,  Up: 改良されたモジュール<5>

1.7.5.51 types
..............

The new *note WrapperDescriptorType: b67, *note MethodWrapperType: 617,
*note MethodDescriptorType: b68, and *note ClassMethodDescriptorType:
b69. classes are now available.  (Contributed by Manuel Krebber and
Guido van Rossum in bpo-29377(1), and Serhiy Storchaka in bpo-32265(2).)

The new *note types.resolve_bases(): b6a. function resolves MRO entries
dynamically as specified by PEP 560(3).  (Contributed by Ivan Levkivskyi
in bpo-32717(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29377

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32265

   (3) https://peps.python.org/pep-0560/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32717


File: python.info,  Node: unicodedata<6>,  Next: unittest<7>,  Prev: types<4>,  Up: 改良されたモジュール<5>

1.7.5.52 unicodedata
....................

The internal *note unicodedata: ee. database has been upgraded to use
Unicode 11(1).  (Contributed by Benjamin Peterson.)

   ---------- Footnotes ----------

   (1) https://www.unicode.org/versions/Unicode11.0.0/


File: python.info,  Node: unittest<7>,  Next: unittest mock,  Prev: unicodedata<6>,  Up: 改良されたモジュール<5>

1.7.5.53 unittest
.................

The new ‘-k’ command-line option allows filtering tests by a name
substring or a Unix shell-like pattern.  For example, ‘python -m
unittest -k foo’ runs ‘foo_tests.SomeTest.test_something’,
‘bar_tests.SomeTest.test_foo’, but not
‘bar_tests.FooTest.test_something’.  (Contributed by Jonas Haag in
bpo-32071(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32071


File: python.info,  Node: unittest mock,  Next: urllib parse<5>,  Prev: unittest<7>,  Up: 改良されたモジュール<5>

1.7.5.54 unittest.mock
......................

The *note sentinel: b6e. attributes now preserve their identity when
they are *note copied: 1e. or *note pickled: 95.  (Contributed by Serhiy
Storchaka in bpo-20804(1).)

The new *note seal(): b6f. function allows sealing *note Mock: a1a.
instances, which will disallow further creation of attribute mocks.  The
seal is applied recursively to all attributes that are themselves mocks.
(Contributed by Mario Corchero in bpo-30541(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20804

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30541


File: python.info,  Node: urllib parse<5>,  Next: uu,  Prev: unittest mock,  Up: 改良されたモジュール<5>

1.7.5.55 urllib.parse
.....................

*note urllib.parse.quote(): b71. has been updated from RFC 2396(1) to
RFC 3986(2), adding ‘~’ to the set of characters that are never quoted
by default.  (Contributed by Christian Theune and Ratnadeep Debnath in
bpo-16285(3).)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2396.html

   (2) https://datatracker.ietf.org/doc/html/rfc3986.html

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16285


File: python.info,  Node: uu,  Next: uuid<2>,  Prev: urllib parse<5>,  Up: 改良されたモジュール<5>

1.7.5.56 uu
...........

The ‘uu.encode()’ function now accepts an optional 'backtick' keyword
argument.  When it's true, zeros are represented by ‘'`'’ instead of
spaces.  (Contributed by Xiang Zhang in bpo-30103(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30103


File: python.info,  Node: uuid<2>,  Next: warnings<3>,  Prev: uu,  Up: 改良されたモジュール<5>

1.7.5.57 uuid
.............

The new *note UUID.is_safe: b74. attribute relays information from the
platform about whether generated UUIDs are generated with a
multiprocessing-safe method.  (Contributed by Barry Warsaw in
bpo-22807(1).)

*note uuid.getnode(): b75. now prefers universally administered MAC
addresses over locally administered MAC addresses.  This makes a better
guarantee for global uniqueness of UUIDs returned from *note
uuid.uuid1(): b76.  If only locally administered MAC addresses are
available, the first such one found is returned.  (Contributed by Barry
Warsaw in bpo-32107(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22807

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32107


File: python.info,  Node: warnings<3>,  Next: xml<5>,  Prev: uuid<2>,  Up: 改良されたモジュール<5>

1.7.5.58 warnings
.................

The initialization of the default warnings filters has changed as
follows:

   * warnings enabled via command line options (including those for
     *note -b: 5ad. and the new CPython-specific *note -X: 15c. ‘dev’
     option) are always passed to the warnings machinery via the *note
     sys.warnoptions: 38a. attribute.

   * warnings filters enabled via the command line or the environment
     now have the following order of precedence:

        * the ‘BytesWarning’ filter for *note -b: 5ad. (or ‘-bb’)

        * any filters specified with the *note -W: 896. option

        * any filters specified with the *note PYTHONWARNINGS: b78.
          environment variable

        * any other CPython specific filters (e.g.  the ‘default’ filter
          added for the new ‘-X dev’ mode)

        * any implicit filters defined directly by the warnings
          machinery

   * in *note CPython debug builds: 1da, all warnings are now displayed
     by default (the implicit filter list is empty)

(Contributed by Nick Coghlan and Victor Stinner in bpo-20361(1),
bpo-32043(2), and bpo-32230(3).)

Deprecation warnings are once again shown by default in single-file
scripts and at the interactive prompt.  See *note PEP 565; Show
DeprecationWarning in __main__: a9b. for details.  (Contributed by Nick
Coghlan in bpo-31975(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20361

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32043

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32230

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31975


File: python.info,  Node: xml<5>,  Next: xml etree,  Prev: warnings<3>,  Up: 改良されたモジュール<5>

1.7.5.59 xml
............

As mitigation against DTD and external entity retrieval, the *note
xml.dom.minidom: 109. and *note xml.sax: 110. modules no longer process
external entities by default.  (Contributed by Christian Heimes in
gh-61441(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/61441


File: python.info,  Node: xml etree,  Next: xmlrpc server,  Prev: xml<5>,  Up: 改良されたモジュール<5>

1.7.5.60 xml.etree
..................

*note ElementPath: b7b. predicates in the ‘find()’ methods can now
compare text of the current node with ‘[. = "text"]’, not only text in
children.  Predicates also allow adding spaces for better readability.
(Contributed by Stefan Behnel in bpo-31648(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31648


File: python.info,  Node: xmlrpc server,  Next: zipapp,  Prev: xml etree,  Up: 改良されたモジュール<5>

1.7.5.61 xmlrpc.server
......................

‘SimpleXMLRPCDispatcher.register_function’ can now be used as a
decorator.  (Contributed by Xiang Zhang in bpo-7769(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=7769


File: python.info,  Node: zipapp,  Next: zipfile<2>,  Prev: xmlrpc server,  Up: 改良されたモジュール<5>

1.7.5.62 zipapp
...............

Function *note create_archive(): b7e. now accepts an optional 'filter'
argument to allow the user to select which files should be included in
the archive.  (Contributed by Irmen de Jong in bpo-31072(1).)

Function *note create_archive(): b7e. now accepts an optional
'compressed' argument to generate a compressed archive.  A command line
option ‘--compress’ has also been added to support compression.
(Contributed by Zhiming Wang in bpo-31638(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31072

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31638


File: python.info,  Node: zipfile<2>,  Prev: zipapp,  Up: 改良されたモジュール<5>

1.7.5.63 zipfile
................

*note ZipFile: 690. now accepts the new 'compresslevel' parameter to
control the compression level.  (Contributed by Bo Bayles in
bpo-21417(1).)

Subdirectories in archives created by ‘ZipFile’ are now stored in
alphabetical order.  (Contributed by Bernhard M. Wiedemann in
bpo-30693(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21417

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30693


File: python.info,  Node: C API の変更<7>,  Next: Build Changes<6>,  Prev: 改良されたモジュール<5>,  Up: What's New In Python 3 7

1.7.6 C API の変更
------------------

A new API for thread-local storage has been implemented.  See *note PEP
539; スレッドローカルストレージのための新しい C API: a9c. for an
overview and *note スレッド固有ストレージ (Thread Specific Storage, TSS)
API: aac. for a complete reference.  (Contributed by Masayuki Yamamoto
in bpo-25658(1).)

The new *note context variables: a8e. functionality exposes a number of
*note new C APIs: ac6.

The new *note PyImport_GetModule(): b81. function returns the previously
imported module with the given name.  (Contributed by Eric Snow in
bpo-28411(2).)

The new *note Py_RETURN_RICHCOMPARE: b82. macro eases writing rich
comparison functions.  (Contributed by Petr Victorin in bpo-23699(3).)

The new *note Py_UNREACHABLE: b83. macro can be used to mark unreachable
code paths.  (Contributed by Barry Warsaw in bpo-31338(4).)

The *note tracemalloc: e8. now exposes a C API through the new *note
PyTraceMalloc_Track(): b84. and *note PyTraceMalloc_Untrack(): b85.
functions.  (Contributed by Victor Stinner in bpo-30054(5).)

The new ‘import__find__load__start()’ and ‘import__find__load__done()’
static markers can be used to trace module imports.  (Contributed by
Christian Heimes in bpo-31574(6).)

The fields ‘name’ and ‘doc’ of structures *note PyMemberDef: 51a, *note
PyGetSetDef: b86, *note PyStructSequence_Field: b87, *note
PyStructSequence_Desc: b88, and ‘wrapperbase’ are now of type ‘const
char *’ rather of ‘char *’.  (Contributed by Serhiy Storchaka in
bpo-28761(7).)

The result of *note PyUnicode_AsUTF8AndSize(): 866. and *note
PyUnicode_AsUTF8(): b89. is now of type ‘const char *’ rather of ‘char
*’.  (Contributed by Serhiy Storchaka in bpo-28769(8).)

The result of *note PyMapping_Keys(): b8a, *note PyMapping_Values():
b8b. and *note PyMapping_Items(): b8c. is now always a list, rather than
a list or a tuple.  (Contributed by Oren Milman in bpo-28280(9).)

Added functions *note PySlice_Unpack(): 3d6. and *note
PySlice_AdjustIndices(): 3d7.  (Contributed by Serhiy Storchaka in
bpo-27867(10).)

*note PyOS_AfterFork(): 3d3. is deprecated in favour of the new
functions *note PyOS_BeforeFork(): b8d, *note PyOS_AfterFork_Parent():
b8e. and *note PyOS_AfterFork_Child(): 3d4.  (Contributed by Antoine
Pitrou in bpo-16500(11).)

The ‘PyExc_RecursionErrorInst’ singleton that was part of the public API
has been removed as its members being never cleared may cause a segfault
during finalization of the interpreter.  Contributed by Xavier de Gaye
in bpo-22898(12) and bpo-30697(13).

Added C API support for timezones with timezone constructors *note
PyTimeZone_FromOffset(): b8f. and *note PyTimeZone_FromOffsetAndName():
b90, and access to the UTC singleton with *note PyDateTime_TimeZone_UTC:
b91.  Contributed by Paul Ganssle in bpo-10381(14).

The type of results of ‘PyThread_start_new_thread()’ and
‘PyThread_get_thread_ident()’, and the 'id' parameter of *note
PyThreadState_SetAsyncExc(): b92. changed from long to unsigned long.
(Contributed by Serhiy Storchaka in bpo-6532(15).)

*note PyUnicode_AsWideCharString(): 88a. now raises a *note ValueError:
1e3. if the second argument is ‘NULL’ and the wchar_t* string contains
null characters.  (Contributed by Serhiy Storchaka in bpo-30708(16).)

Changes to the startup sequence and the management of dynamic memory
allocators mean that the long documented requirement to call *note
Py_Initialize(): 87a. before calling most C API functions is now relied
on more heavily, and failing to abide by it may lead to segfaults in
embedding applications.  See the *note Python 3.7 への移植: a9f. section
in this document and the *note Python 初期化以前: b93. section in the C
API documentation for more details.

The new *note PyInterpreterState_GetID(): b94. returns the unique ID for
a given interpreter.  (Contributed by Eric Snow in bpo-29102(17).)

*note Py_DecodeLocale(): b95, *note Py_EncodeLocale(): b96. now use the
UTF-8 encoding when the *note UTF-8 mode: a98. is enabled.  (Contributed
by Victor Stinner in bpo-29240(18).)

*note PyUnicode_DecodeLocaleAndSize(): b97. and *note
PyUnicode_EncodeLocale(): b98. now use the current locale encoding for
‘surrogateescape’ error handler.  (Contributed by Victor Stinner in
bpo-29240(19).)

The 'start' and 'end' parameters of *note PyUnicode_FindChar(): 887. are
now adjusted to behave like string slices.  (Contributed by Xiang Zhang
in bpo-28822(20).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25658

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28411

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23699

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31338

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30054

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31574

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28761

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28769

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28280

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27867

   (11) https://bugs.python.org/issue?@action=redirect&bpo=16500

   (12) https://bugs.python.org/issue?@action=redirect&bpo=22898

   (13) https://bugs.python.org/issue?@action=redirect&bpo=30697

   (14) https://bugs.python.org/issue?@action=redirect&bpo=10381

   (15) https://bugs.python.org/issue?@action=redirect&bpo=6532

   (16) https://bugs.python.org/issue?@action=redirect&bpo=30708

   (17) https://bugs.python.org/issue?@action=redirect&bpo=29102

   (18) https://bugs.python.org/issue?@action=redirect&bpo=29240

   (19) https://bugs.python.org/issue?@action=redirect&bpo=29240

   (20) https://bugs.python.org/issue?@action=redirect&bpo=28822


File: python.info,  Node: Build Changes<6>,  Next: 最適化<5>,  Prev: C API の変更<7>,  Up: What's New In Python 3 7

1.7.7 Build Changes
-------------------

Support for building ‘--without-threads’ has been removed.  The *note
threading: d6. module is now always available.  (Contributed by Antoine
Pitrou in bpo-31370(1).).

A full copy of libffi is no longer bundled for use when building the
*note _ctypes: 22. module on non-OSX UNIX platforms.  An installed copy
of libffi is now required when building ‘_ctypes’ on such platforms.
(Contributed by Zachary Ware in bpo-27979(2).)

The Windows build process no longer depends on Subversion to pull in
external sources, a Python script is used to download zipfiles from
GitHub instead.  If Python 3.6 is not found on the system (via ‘py
-3.6’), NuGet is used to download a copy of 32-bit Python for this
purpose.  (Contributed by Zachary Ware in bpo-30450(3).)

The *note ssl: bb. module requires OpenSSL 1.0.2 or 1.1 compatible
libssl.  OpenSSL 1.0.1 has reached end of lifetime on 2016-12-31 and is
no longer supported.  LibreSSL is temporarily not supported as well.
LibreSSL releases up to version 2.6.4 are missing required OpenSSL 1.0.2
APIs.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31370

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27979

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30450


File: python.info,  Node: 最適化<5>,  Next: その他の CPython の実装の変更<2>,  Prev: Build Changes<6>,  Up: What's New In Python 3 7

1.7.8 最適化
------------

The overhead of calling many methods of various standard library classes
implemented in C has been significantly reduced by porting more code to
use the ‘METH_FASTCALL’ convention.  (Contributed by Victor Stinner in
bpo-29300(1), bpo-29507(2), bpo-29452(3), and bpo-29286(4).)

Various optimizations have reduced Python startup time by 10% on Linux
and up to 30% on macOS. (Contributed by Victor Stinner, INADA Naoki in
bpo-29585(5), and Ivan Levkivskyi in bpo-31333(6).)

Method calls are now up to 20% faster due to the bytecode changes which
avoid creating bound method instances.  (Contributed by Yury Selivanov
and INADA Naoki in bpo-26110(7).)  The *note asyncio: 8. module received
a number of notable optimizations for commonly used functions:

   * The *note asyncio.get_event_loop(): 2a2. function has been
     reimplemented in C to make it up to 15 times faster.  (Contributed
     by Yury Selivanov in bpo-32296(8).)

   * *note asyncio.Future: b9b. callback management has been optimized.
     (Contributed by Yury Selivanov in bpo-32348(9).)

   * *note asyncio.gather(): 5c8. is now up to 15% faster.  (Contributed
     by Yury Selivanov in bpo-32355(10).)

   * *note asyncio.sleep(): a3d. is now up to 2 times faster when the
     'delay' argument is zero or negative.  (Contributed by Andrew
     Svetlov in bpo-32351(11).)

   * The performance overhead of asyncio debug mode has been reduced.
     (Contributed by Antoine Pitrou in bpo-31970(12).)

As a result of *note PEP 560 work: a93, the import time of *note typing:
ed. has been reduced by a factor of 7, and many typing operations are
now faster.  (Contributed by Ivan Levkivskyi in bpo-32226(13).)

*note sorted(): b9c. and *note list.sort(): b9d. have been optimized for
common cases to be up to 40-75% faster.  (Contributed by Elliot
Gorokhovsky in bpo-28685(14).)

*note dict.copy(): b9e. is now up to 5.5 times faster.  (Contributed by
Yury Selivanov in bpo-31179(15).)

*note hasattr(): 49e. and *note getattr(): b9f. are now about 4 times
faster when 'name' is not found and 'obj' does not override *note
object.__getattr__(): 49f. or *note object.__getattribute__(): ba0.
(Contributed by INADA Naoki in bpo-32544(16).)

Searching for certain Unicode characters (like Ukrainian capital "Є") in
a string was up to 25 times slower than searching for other characters.
It is now only 3 times slower in the worst case.  (Contributed by Serhiy
Storchaka in bpo-24821(17).)

The *note collections.namedtuple(): 1ac. factory has been reimplemented
to make the creation of named tuples 4 to 6 times faster.  (Contributed
by Jelle Zijlstra with further improvements by INADA Naoki, Serhiy
Storchaka, and Raymond Hettinger in bpo-28638(18).)

‘date.fromordinal()’ and ‘date.fromtimestamp()’ are now up to 30% faster
in the common case.  (Contributed by Paul Ganssle in bpo-32403(19).)

The *note os.fwalk(): b29. function is now up to 2 times faster thanks
to the use of *note os.scandir(): a2d.  (Contributed by Serhiy Storchaka
in bpo-25996(20).)

The speed of the *note shutil.rmtree(): 2d8. function has been improved
by 20-40% thanks to the use of the *note os.scandir(): a2d. function.
(Contributed by Serhiy Storchaka in bpo-28564(21).)

Optimized case-insensitive matching and searching of *note regular
expressions: a7.  Searching some patterns can now be up to 20 times
faster.  (Contributed by Serhiy Storchaka in bpo-30285(22).)

*note re.compile(): ba1. now converts ‘flags’ parameter to int object if
it is ‘RegexFlag’.  It is now as fast as Python 3.5, and faster than
Python 3.6 by about 10% depending on the pattern.  (Contributed by INADA
Naoki in bpo-31671(23).)

The *note modify(): ba2. methods of classes *note
selectors.EpollSelector: ba3, *note selectors.PollSelector: ba4. and
*note selectors.DevpollSelector: ba5. may be around 10% faster under
heavy loads.  (Contributed by Giampaolo Rodola' in bpo-30014(24))

Constant folding has been moved from the peephole optimizer to the new
AST optimizer, which is able perform optimizations more consistently.
(Contributed by Eugene Toder and INADA Naoki in bpo-29469(25) and
bpo-11549(26).)

Most functions and methods in *note abc: 4. have been rewritten in C.
This makes creation of abstract base classes, and calling *note
isinstance(): 40e. and *note issubclass(): 78c. on them 1.5x faster.
This also reduces Python start-up time by up to 10%.  (Contributed by
Ivan Levkivskyi and INADA Naoki in bpo-31333(27))

Significant speed improvements to alternate constructors for *note
datetime.date: 1af. and *note datetime.datetime: 1ae. by using fast-path
constructors when not constructing subclasses.  (Contributed by Paul
Ganssle in bpo-32403(28))

The speed of comparison of *note array.array: 185. instances has been
improved considerably in certain cases.  It is now from 10x to 70x
faster when comparing arrays holding values of the same integer type.
(Contributed by Adrian Wielgosik in bpo-24700(29).)

The *note math.erf(): ba6. and *note math.erfc(): ba7. functions now use
the (faster) C library implementation on most platforms.  (Contributed
by Serhiy Storchaka in bpo-26121(30).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29300

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29507

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29452

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29286

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29585

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31333

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26110

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32296

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32348

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32355

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32351

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31970

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32226

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28685

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31179

   (16) https://bugs.python.org/issue?@action=redirect&bpo=32544

   (17) https://bugs.python.org/issue?@action=redirect&bpo=24821

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28638

   (19) https://bugs.python.org/issue?@action=redirect&bpo=32403

   (20) https://bugs.python.org/issue?@action=redirect&bpo=25996

   (21) https://bugs.python.org/issue?@action=redirect&bpo=28564

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30285

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31671

   (24) https://bugs.python.org/issue?@action=redirect&bpo=30014

   (25) https://bugs.python.org/issue?@action=redirect&bpo=29469

   (26) https://bugs.python.org/issue?@action=redirect&bpo=11549

   (27) https://bugs.python.org/issue?@action=redirect&bpo=31333

   (28) https://bugs.python.org/issue?@action=redirect&bpo=32403

   (29) https://bugs.python.org/issue?@action=redirect&bpo=24700

   (30) https://bugs.python.org/issue?@action=redirect&bpo=26121


File: python.info,  Node: その他の CPython の実装の変更<2>,  Next: 非推奨の Python の挙動,  Prev: 最適化<5>,  Up: What's New In Python 3 7

1.7.9 その他の CPython の実装の変更
-----------------------------------

   * Trace hooks may now opt out of receiving the ‘line’ and opt into
     receiving the ‘opcode’ events from the interpreter by setting the
     corresponding new *note f_trace_lines: ba9. and *note
     f_trace_opcodes: baa. attributes on the frame being traced.
     (Contributed by Nick Coghlan in bpo-31344(1).)

   * Fixed some consistency problems with namespace package module
     attributes.  Namespace module objects now have an ‘__file__’ that
     is set to ‘None’ (previously unset), and their ‘__spec__.origin’ is
     also set to ‘None’ (previously the string ‘"namespace"’).  See
     bpo-32305(2).  Also, the namespace module object's
     ‘__spec__.loader’ is set to the same value as ‘__loader__’
     (previously, the former was set to ‘None’).  See bpo-32303(3).

   * The *note locals(): 127. dictionary now displays in the lexical
     order that variables were defined.  Previously, the order was
     undefined.  (Contributed by Raymond Hettinger in bpo-32690(4).)

   * The ‘distutils’ ‘upload’ command no longer tries to change CR
     end-of-line characters to CRLF. This fixes a corruption issue with
     sdists that ended with a byte equivalent to CR. (Contributed by Bo
     Bayles in bpo-32304(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31344

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32305

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32303

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32690

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32304


File: python.info,  Node: 非推奨の Python の挙動,  Next: 非推奨の Python モジュール、関数、メソッド,  Prev: その他の CPython の実装の変更<2>,  Up: What's New In Python 3 7

1.7.10 非推奨の Python の挙動
-----------------------------

Yield expressions (both ‘yield’ and ‘yield from’ clauses) are now
deprecated in comprehensions and generator expressions (aside from the
iterable expression in the leftmost ‘for’ clause).  This ensures that
comprehensions always immediately return a container of the appropriate
type (rather than potentially returning a *note generator iterator: bac.
object), while generator expressions won't attempt to interleave their
implicit output with the output from any explicit yield expressions.  In
Python 3.7, such expressions emit *note DeprecationWarning: 18a. when
compiled, in Python 3.8 this will be a *note SyntaxError: 172.
(Contributed by Serhiy Storchaka in bpo-10544(1).)

Returning a subclass of *note complex: 2cf. from *note
object.__complex__(): 5b1. is deprecated and will be an error in future
Python versions.  This makes ‘__complex__()’ consistent with *note
object.__int__(): 6e7. and *note object.__float__(): 99a.  (Contributed
by Serhiy Storchaka in bpo-28894(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10544

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28894


File: python.info,  Node: 非推奨の Python モジュール、関数、メソッド,  Next: C API の非推奨の関数ならびに型,  Prev: 非推奨の Python の挙動,  Up: What's New In Python 3 7

1.7.11 非推奨の Python モジュール、関数、メソッド
-------------------------------------------------

* Menu:

* aifc::
* asyncio: asyncio<8>.
* collections: collections<3>.
* dbm: dbm<3>.
* enum: enum<5>.
* gettext: gettext<2>.
* importlib: importlib<5>.
* locale: locale<5>.
* macpath::
* threading: threading<5>.
* socket: socket<6>.
* ssl: ssl<6>.
* sunau::
* sys: sys<9>.
* wave::


File: python.info,  Node: aifc,  Next: asyncio<8>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.1 aifc
.............

‘aifc.openfp()’ has been deprecated and will be removed in Python 3.9.
Use ‘aifc.open()’ instead.  (Contributed by Brian Curtin in
bpo-31985(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31985


File: python.info,  Node: asyncio<8>,  Next: collections<3>,  Prev: aifc,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.2 asyncio
................

Support for directly ‘await’-ing instances of *note asyncio.Lock: a3f.
and other asyncio synchronization primitives has been deprecated.  An
asynchronous context manager must be used in order to acquire and
release the synchronization resource.  (Contributed by Andrew Svetlov in
bpo-32253(1).)

The ‘asyncio.Task.current_task()’ and ‘asyncio.Task.all_tasks()’ methods
have been deprecated.  (Contributed by Andrew Svetlov in bpo-32250(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32253

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32250


File: python.info,  Node: collections<3>,  Next: dbm<3>,  Prev: asyncio<8>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.3 collections
....................

In Python 3.8, the abstract base classes in *note collections.abc: 17.
will no longer be exposed in the regular *note collections: 16. module.
This will help create a clearer distinction between the concrete classes
and the abstract base classes.  (Contributed by Serhiy Storchaka in
bpo-25988(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25988


File: python.info,  Node: dbm<3>,  Next: enum<5>,  Prev: collections<3>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.4 dbm
............

*note dbm.dumb: 2a. now supports reading read-only files and no longer
writes the index file when it is not changed.  A deprecation warning is
now emitted if the index file is missing and recreated in the ‘'r'’ and
‘'w'’ modes (this will be an error in future Python releases).
(Contributed by Serhiy Storchaka in bpo-28847(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28847


File: python.info,  Node: enum<5>,  Next: gettext<2>,  Prev: dbm<3>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.5 enum
.............

In Python 3.8, attempting to check for non-Enum objects in ‘Enum’
classes will raise a *note TypeError: 502. (e.g.  ‘1 in Color’);
similarly, attempting to check for non-Flag objects in a ‘Flag’ member
will raise *note TypeError: 502. (e.g.  ‘1 in Perm.RW’); currently, both
operations return *note False: b05. instead.  (Contributed by Ethan
Furman in bpo-33217(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33217


File: python.info,  Node: gettext<2>,  Next: importlib<5>,  Prev: enum<5>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.6 gettext
................

Using non-integer value for selecting a plural form in *note gettext:
59. is now deprecated.  It never correctly worked.  (Contributed by
Serhiy Storchaka in bpo-28692(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28692


File: python.info,  Node: importlib<5>,  Next: locale<5>,  Prev: gettext<2>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.7 importlib
..................

Methods ‘MetaPathFinder.find_module()’ (replaced by *note
MetaPathFinder.find_spec(): 834.) and ‘PathEntryFinder.find_loader()’
(replaced by *note PathEntryFinder.find_spec(): 838.) both deprecated in
Python 3.4 now emit *note DeprecationWarning: 18a.  (Contributed by
Matthias Bussonnier in bpo-29576(1).)

The *note importlib.abc.ResourceLoader: bb5. ABC has been deprecated in
favour of *note importlib.abc.ResourceReader: acb.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29576


File: python.info,  Node: locale<5>,  Next: macpath,  Prev: importlib<5>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.8 locale
...............

‘locale.format()’ has been deprecated, use *note locale.format_string():
4e8. instead.  (Contributed by Garvit in bpo-10379(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10379


File: python.info,  Node: macpath,  Next: threading<5>,  Prev: locale<5>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.9 macpath
................

The ‘macpath’ is now deprecated and will be removed in Python 3.8.
(Contributed by Chi Hsuan Yen in bpo-9850(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9850


File: python.info,  Node: threading<5>,  Next: socket<6>,  Prev: macpath,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.10 threading
...................

‘dummy_threading’ and ‘_dummy_thread’ have been deprecated.  It is no
longer possible to build Python with threading disabled.  Use *note
threading: d6. instead.  (Contributed by Antoine Pitrou in
bpo-31370(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31370


File: python.info,  Node: socket<6>,  Next: ssl<6>,  Prev: threading<5>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.11 socket
................

The silent argument value truncation in *note socket.htons(): 84c. and
*note socket.ntohs(): 84d. has been deprecated.  In future versions of
Python, if the passed argument is larger than 16 bits, an exception will
be raised.  (Contributed by Oren Milman in bpo-28332(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28332


File: python.info,  Node: ssl<6>,  Next: sunau,  Prev: socket<6>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.12 ssl
.............

‘ssl.wrap_socket()’ is deprecated.  Use *note
ssl.SSLContext.wrap_socket(): 4ee. instead.  (Contributed by Christian
Heimes in bpo-28124(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28124


File: python.info,  Node: sunau,  Next: sys<9>,  Prev: ssl<6>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.13 sunau
...............

‘sunau.openfp()’ has been deprecated and will be removed in Python 3.9.
Use ‘sunau.open()’ instead.  (Contributed by Brian Curtin in
bpo-31985(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31985


File: python.info,  Node: sys<9>,  Next: wave,  Prev: sunau,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.14 sys
.............

Deprecated ‘sys.set_coroutine_wrapper()’ and
‘sys.get_coroutine_wrapper()’.

The undocumented ‘sys.callstats()’ function has been deprecated and will
be removed in a future Python version.  (Contributed by Victor Stinner
in bpo-28799(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28799


File: python.info,  Node: wave,  Prev: sys<9>,  Up: 非推奨の Python モジュール、関数、メソッド

1.7.11.15 wave
..............

‘wave.openfp()’ has been deprecated and will be removed in Python 3.9.
Use *note wave.open(): 919. instead.  (Contributed by Brian Curtin in
bpo-31985(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31985


File: python.info,  Node: C API の非推奨の関数ならびに型,  Next: サポート対象プラットフォームからの除外,  Prev: 非推奨の Python モジュール、関数、メソッド,  Up: What's New In Python 3 7

1.7.12 C API の非推奨の関数ならびに型
-------------------------------------

Function *note PySlice_GetIndicesEx(): 3d5. is deprecated and replaced
with a macro if ‘Py_LIMITED_API’ is not set or set to a value in the
range between ‘0x03050400’ and ‘0x03060000’ (not inclusive), or is
‘0x03060100’ or higher.  (Contributed by Serhiy Storchaka in
bpo-27867(1).)

*note PyOS_AfterFork(): 3d3. has been deprecated.  Use *note
PyOS_BeforeFork(): b8d, *note PyOS_AfterFork_Parent(): b8e. or *note
PyOS_AfterFork_Child(): 3d4. instead.  (Contributed by Antoine Pitrou in
bpo-16500(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27867

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16500


File: python.info,  Node: サポート対象プラットフォームからの除外,  Next: API と機能の削除<2>,  Prev: C API の非推奨の関数ならびに型,  Up: What's New In Python 3 7

1.7.13 サポート対象プラットフォームからの除外
---------------------------------------------

   * FreeBSD 9 とそれ以前のバージョンは公式にはサポートされなくなりまし
     た。

   * For full Unicode support, including within extension modules, *nix
     platforms are now expected to provide at least one of ‘C.UTF-8’
     (full locale), ‘C.utf8’ (full locale) or ‘UTF-8’ (‘LC_CTYPE’-only
     locale) as an alternative to the legacy ‘ASCII’-based ‘C’ locale.

   * OpenSSL 0.9.8 and 1.0.1 are no longer supported, which means
     building CPython 3.7 with SSL/TLS support on older platforms still
     using these versions requires custom build options that link to a
     more recent version of OpenSSL.

     Notably, this issue affects the Debian 8 (aka "jessie") and Ubuntu
     14.04 (aka "Trusty") LTS Linux distributions, as they still use
     OpenSSL 1.0.1 by default.

     Debian 9 ("stretch") and Ubuntu 16.04 ("xenial"), as well as recent
     releases of other LTS Linux releases (e.g.  RHEL/CentOS 7.5, SLES
     12-SP3), use OpenSSL 1.0.2 or later, and remain supported in the
     default build configuration.

     CPython's own CI configuration file(1) provides an example of using
     the SSL compatibility testing infrastructure(2) in CPython's test
     suite to build and link against OpenSSL 1.1.0 rather than an
     outdated system provided OpenSSL.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/blob/v3.7.13/.travis.yml

   (2) 
https://github.com/python/cpython/tree/3.13/Tools/ssl/multissltests.py


File: python.info,  Node: API と機能の削除<2>,  Next: Module Removals,  Prev: サポート対象プラットフォームからの除外,  Up: What's New In Python 3 7

1.7.14 API と機能の削除
-----------------------

The following features and APIs have been removed from Python 3.7:

   * The ‘os.stat_float_times()’ function has been removed.  It was
     introduced in Python 2.3 for backward compatibility with Python
     2.2, and was deprecated since Python 3.1.

   * Unknown escapes consisting of ‘'\'’ and an ASCII letter in
     replacement templates for *note re.sub(): 283. were deprecated in
     Python 3.5, and will now cause an error.

   * Removed support of the 'exclude' argument in *note
     tarfile.TarFile.add(): bc1.  It was deprecated in Python 2.7 and
     3.2.  Use the 'filter' argument instead.

   * The ‘ntpath.splitunc()’ function was deprecated in Python 3.1, and
     has now been removed.  Use *note splitdrive(): bc2. instead.

   * *note collections.namedtuple(): 1ac. no longer supports the
     'verbose' parameter or ‘_source’ attribute which showed the
     generated source code for the named tuple class.  This was part of
     an optimization designed to speed-up class creation.  (Contributed
     by Jelle Zijlstra with further improvements by INADA Naoki, Serhiy
     Storchaka, and Raymond Hettinger in bpo-28638(1).)

   * Functions *note bool(): 434, *note float(): 2ce, *note list(): 5dc.
     and *note tuple(): 349. no longer take keyword arguments.  The
     first argument of *note int(): 238. can now be passed only as
     positional argument.

   * Removed previously deprecated in Python 2.4 classes ‘Plist’, ‘Dict’
     and ‘_InternalDict’ in the *note plistlib: 99. module.  Dict values
     in the result of functions ‘readPlist()’ and ‘readPlistFromBytes()’
     are now normal dicts.  You no longer can use attribute access to
     access items of these dictionaries.

   * The ‘asyncio.windows_utils.socketpair()’ function has been removed.
     Use the *note socket.socketpair(): bc3. function instead, it is
     available on all platforms since Python 3.5.
     ‘asyncio.windows_utils.socketpair’ was just an alias to
     ‘socket.socketpair’ on Python 3.5 and newer.

   * *note asyncio: 8. no longer exports the *note selectors: b0. and
     ‘_overlapped’ modules as ‘asyncio.selectors’ and
     ‘asyncio._overlapped’.  Replace ‘from asyncio import selectors’
     with ‘import selectors’.

   * Direct instantiation of *note ssl.SSLSocket: 8b8. and *note
     ssl.SSLObject: b4f. objects is now prohibited.  The constructors
     were never documented, tested, or designed as public constructors.
     Users were supposed to use ‘ssl.wrap_socket()’ or *note
     ssl.SSLContext: 274.  (Contributed by Christian Heimes in
     bpo-32951(2).)

   * The unused ‘distutils’ ‘install_misc’ command has been removed.
     (Contributed by Eric N. Vander Weele in bpo-29218(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28638

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32951

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29218


File: python.info,  Node: Module Removals,  Next: Windows-only Changes,  Prev: API と機能の削除<2>,  Up: What's New In Python 3 7

1.7.15 Module Removals
----------------------

The ‘fpectl’ module has been removed.  It was never enabled by default,
never worked correctly on x86-64, and it changed the Python ABI in ways
that caused unexpected breakage of C extensions.  (Contributed by
Nathaniel J. Smith in bpo-29137(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29137


File: python.info,  Node: Windows-only Changes,  Next: Python 3 7 への移植,  Prev: Module Removals,  Up: What's New In Python 3 7

1.7.16 Windows-only Changes
---------------------------

The python launcher, (py.exe), can accept 32 & 64 bit specifiers
'without' having to specify a minor version as well.  So ‘py -3-32’ and
‘py -3-64’ become valid as well as ‘py -3.7-32’, also the -'m'-64 and
-'m.n'-64 forms are now accepted to force 64 bit python even if 32 bit
would have otherwise been used.  If the specified version is not
available py.exe will error exit.  (Contributed by Steve Barnes in
bpo-30291(1).)

The launcher can be run as ‘py -0’ to produce a list of the installed
pythons, 'with default marked with an asterisk'.  Running ‘py -0p’ will
include the paths.  If py is run with a version specifier that cannot be
matched it will also print the 'short form' list of available
specifiers.  (Contributed by Steve Barnes in bpo-30362(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30291

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30362


File: python.info,  Node: Python 3 7 への移植,  Next: Python 3 7 1 での重要な変更点,  Prev: Windows-only Changes,  Up: What's New In Python 3 7

1.7.17 Python 3.7 への移植
--------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* Python の挙動の変更: Python の挙動の変更<2>.
* Python API の変更: Python API の変更<5>.
* C API の変更: C API の変更<8>.
* CPython バイトコードの変更: CPython バイトコードの変更<5>.
* Windows-only Changes: Windows-only Changes<2>.
* その他の CPython の実装の変更: その他の CPython の実装の変更<3>.


File: python.info,  Node: Python の挙動の変更<2>,  Next: Python API の変更<5>,  Up: Python 3 7 への移植

1.7.17.1 Python の挙動の変更
............................

   * *note async: 6fd. and *note await: 19e. names are now reserved
     keywords.  Code using these names as identifiers will now raise a
     *note SyntaxError: 172.  (Contributed by Jelle Zijlstra in
     bpo-30406(1).)

   * PEP 479(2) is enabled for all code in Python 3.7, meaning that
     *note StopIteration: bc8. exceptions raised directly or indirectly
     in coroutines and generators are transformed into *note
     RuntimeError: 17a. exceptions.  (Contributed by Yury Selivanov in
     bpo-32670(3).)

   * *note object.__aiter__(): bc9. methods can no longer be declared as
     asynchronous.  (Contributed by Yury Selivanov in bpo-31709(4).)

   * 以前のバージョンの Python で、誤って以下の構文を許容してしまってい
     ました:

          f(1 for x in [1],)

          class C(1 for x in [1]):
              pass

     Python 3.7 now correctly raises a *note SyntaxError: 172, as a
     generator expression always needs to be directly inside a set of
     parentheses and cannot have a comma on either side, and the
     duplication of the parentheses can be omitted only on calls.
     (Contributed by Serhiy Storchaka in bpo-32012(5) and bpo-32023(6).)

   * When using the *note -m: 5ab. switch, the initial working directory
     is now added to *note sys.path: 38e, rather than an empty string
     (which dynamically denoted the current working directory at the
     time of each import).  Any programs that are checking for the empty
     string, or otherwise relying on the previous behaviour, will need
     to be updated accordingly (e.g.  by also checking for ‘os.getcwd()’
     or ‘os.path.dirname(__main__.__file__)’, depending on why the code
     was checking for the empty string in the first place).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30406

   (2) https://peps.python.org/pep-0479/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32670

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31709

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32012

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32023


File: python.info,  Node: Python API の変更<5>,  Next: C API の変更<8>,  Prev: Python の挙動の変更<2>,  Up: Python 3 7 への移植

1.7.17.2 Python API の変更
..........................

   * ‘socketserver.ThreadingMixIn.server_close()’ now waits until all
     non-daemon threads complete.  Set the new *note
     socketserver.ThreadingMixIn.block_on_close: bcb. class attribute to
     ‘False’ to get the pre-3.7 behaviour.  (Contributed by Victor
     Stinner in bpo-31233(1) and bpo-33540(2).)

   * ‘socketserver.ForkingMixIn.server_close()’ now waits until all
     child processes complete.  Set the new
     ‘socketserver.ForkingMixIn.block_on_close’ class attribute to
     ‘False’ to get the pre-3.7 behaviour.  (Contributed by Victor
     Stinner in bpo-31151(3) and bpo-33540(4).)

   * The *note locale.localeconv(): bcc. function now temporarily sets
     the ‘LC_CTYPE’ locale to the value of ‘LC_NUMERIC’ in some cases.
     (Contributed by Victor Stinner in bpo-31900(5).)

   * *note pkgutil.walk_packages(): bcd. now raises a *note ValueError:
     1e3. if 'path' is a string.  Previously an empty list was returned.
     (Contributed by Sanyam Khurana in bpo-24744(6).)

   * A format string argument for *note string.Formatter.format(): bce.
     is now *note positional-only: a53.  Passing it as a keyword
     argument was deprecated in Python 3.5.  (Contributed by Serhiy
     Storchaka in bpo-29193(7).)

   * Attributes *note key: bcf, *note value: bd0. and *note coded_value:
     bd1. of class *note http.cookies.Morsel: bd2. are now read-only.
     Assigning to them was deprecated in Python 3.5.  Use the *note
     set(): bd3. method for setting them.  (Contributed by Serhiy
     Storchaka in bpo-29192(8).)

   * The 'mode' argument of *note os.makedirs(): 1ff. no longer affects
     the file permission bits of newly created intermediate-level
     directories.  To set their file permission bits you can set the
     umask before invoking ‘makedirs()’.  (Contributed by Serhiy
     Storchaka in bpo-19930(9).)

   * The *note struct.Struct.format: bd4. type is now *note str: 418.
     instead of *note bytes: 1a4.  (Contributed by Victor Stinner in
     bpo-21071(10).)

   * ‘cgi.parse_multipart()’ now accepts the 'encoding' and 'errors'
     arguments and returns the same results as ‘FieldStorage’: for
     non-file fields, the value associated to a key is a list of
     strings, not bytes.  (Contributed by Pierre Quentel in
     bpo-29979(11).)

   * Due to internal changes in *note socket: b8, calling *note
     socket.fromshare(): bd5. on a socket created by *note socket.share:
     bd6. in older Python versions is not supported.

   * ‘repr’ for *note BaseException: 584. has changed to not include the
     trailing comma.  Most exceptions are affected by this change.
     (Contributed by Serhiy Storchaka in bpo-30399(12).)

   * ‘repr’ for *note datetime.timedelta: 99d. has changed to include
     the keyword arguments in the output.  (Contributed by Utkarsh
     Upadhyay in bpo-30302(13).)

   * Because *note shutil.rmtree(): 2d8. is now implemented using the
     *note os.scandir(): a2d. function, the user specified handler
     'onerror' is now called with the first argument ‘os.scandir’
     instead of ‘os.listdir’ when listing the directory is failed.

   * Support for nested sets and set operations in regular expressions
     as in Unicode Technical Standard #18(14) might be added in the
     future.  This would change the syntax.  To facilitate this future
     change a *note FutureWarning: 3ee. will be raised in ambiguous
     cases for the time being.  That include sets starting with a
     literal ‘'['’ or containing literal character sequences ‘'--'’,
     ‘'&&'’, ‘'~~'’, and ‘'||'’.  To avoid a warning, escape them with a
     backslash.  (Contributed by Serhiy Storchaka in bpo-30349(15).)

   * The result of splitting a string on a *note regular expression: a7.
     that could match an empty string has been changed.  For example
     splitting on ‘r'\s*'’ will now split not only on whitespaces as it
     did previously, but also on empty strings before all non-whitespace
     characters and just before the end of the string.  The previous
     behavior can be restored by changing the pattern to ‘r'\s+'’.  A
     *note FutureWarning: 3ee. was emitted for such patterns since
     Python 3.5.

     For patterns that match both empty and non-empty strings, the
     result of searching for all matches may also be changed in other
     cases.  For example in the string ‘'a\n\n'’, the pattern
     ‘r'(?m)^\s*?$'’ will not only match empty strings at positions 2
     and 3, but also the string ‘'\n'’ at positions 2-3.  To match only
     blank lines, the pattern should be rewritten as
     ‘r'(?m)^[^\S\n]*$'’.

     *note re.sub(): 283. now replaces empty matches adjacent to a
     previous non-empty match.  For example ‘re.sub('x*', '-', 'abxd')’
     returns now ‘'-a-b--d-'’ instead of ‘'-a-b-d-'’ (the first minus
     between 'b' and 'd' replaces 'x', and the second minus replaces an
     empty string between 'x' and 'd').

     (Contributed by Serhiy Storchaka in bpo-25054(16) and
     bpo-32308(17).)

   * Change *note re.escape(): bd7. to only escape regex special
     characters instead of escaping all characters other than ASCII
     letters, numbers, and ‘'_'’.  (Contributed by Serhiy Storchaka in
     bpo-29995(18).)

   * *note tracemalloc.Traceback: b64. frames are now sorted from oldest
     to most recent to be more consistent with *note traceback: e7.
     (Contributed by Jesse Bakker in bpo-32121(19).)

   * On OSes that support *note socket.SOCK_NONBLOCK: bd8. or *note
     socket.SOCK_CLOEXEC: bd9. bit flags, the *note socket.type: bda. no
     longer has them applied.  Therefore, checks like ‘if sock.type ==
     socket.SOCK_STREAM’ work as expected on all platforms.
     (Contributed by Yury Selivanov in bpo-32331(20).)

   * On Windows the default for the 'close_fds' argument of *note
     subprocess.Popen: 17e. was changed from *note False: b05. to *note
     True: bdb. when redirecting the standard handles.  If you
     previously depended on handles being inherited when using *note
     subprocess.Popen: 17e. with standard io redirection, you will have
     to pass ‘close_fds=False’ to preserve the previous behaviour, or
     use *note STARTUPINFO.lpAttributeList: bdc.

   * *note importlib.machinery.PathFinder.invalidate_caches(): bdd. -
     which implicitly affects *note importlib.invalidate_caches(): bde.
     - now deletes entries in *note sys.path_importer_cache: 5ae. which
     are set to ‘None’.  (Contributed by Brett Cannon in bpo-33169(21).)

   * In *note asyncio: 8, *note loop.sock_recv(): bdf, *note
     loop.sock_sendall(): be0, *note loop.sock_accept(): be1, *note
     loop.getaddrinfo(): be2, *note loop.getnameinfo(): be3. have been
     changed to be proper coroutine methods to match their
     documentation.  Previously, these methods returned *note
     asyncio.Future: b9b. instances.  (Contributed by Yury Selivanov in
     bpo-32327(22).)

   * *note asyncio.Server.sockets: be4. now returns a copy of the
     internal list of server sockets, instead of returning it directly.
     (Contributed by Yury Selivanov in bpo-32662(23).)

   * *note Struct.format: bd4. is now a *note str: 418. instance instead
     of a *note bytes: 1a4. instance.  (Contributed by Victor Stinner in
     bpo-21071(24).)

   * *note argparse: 5. subparsers can now be made mandatory by passing
     ‘required=True’ to *note ArgumentParser.add_subparsers(): be5.
     (Contributed by Anthony Sottile in bpo-26510(25).)

   * *note ast.literal_eval(): be6. is now stricter.  Addition and
     subtraction of arbitrary numbers are no longer allowed.
     (Contributed by Serhiy Storchaka in bpo-31778(26).)

   * *note Calendar.itermonthdates: be7. will now consistently raise an
     exception when a date falls outside of the ‘0001-01-01’ through
     ‘9999-12-31’ range.  To support applications that cannot tolerate
     such exceptions, the new *note Calendar.itermonthdays3: be8. and
     *note Calendar.itermonthdays4: be9. can be used.  The new methods
     return tuples and are not restricted by the range supported by
     *note datetime.date: 1af.  (Contributed by Alexander Belopolsky in
     bpo-28292(27).)

   * *note collections.ChainMap: bea. now preserves the order of the
     underlying mappings.  (Contributed by Raymond Hettinger in
     bpo-32792(28).)

   * The ‘submit()’ method of *note
     concurrent.futures.ThreadPoolExecutor: 70d. and *note
     concurrent.futures.ProcessPoolExecutor: 8bc. now raises a *note
     RuntimeError: 17a. if called during interpreter shutdown.
     (Contributed by Mark Nemec in bpo-33097(29).)

   * The *note configparser.ConfigParser: 1aa. constructor now uses
     ‘read_dict()’ to process the default values, making its behavior
     consistent with the rest of the parser.  Non-string keys and values
     in the defaults dictionary are now being implicitly converted to
     strings.  (Contributed by James Tocknell in bpo-23835(30).)

   * Several undocumented internal imports were removed.  One example is
     that ‘os.errno’ is no longer available; use ‘import errno’ directly
     instead.  Note that such undocumented internal imports may be
     removed any time without notice, even in micro version releases.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31233

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33540

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31151

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33540

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31900

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24744

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29193

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29192

   (9) https://bugs.python.org/issue?@action=redirect&bpo=19930

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21071

   (11) https://bugs.python.org/issue?@action=redirect&bpo=29979

   (12) https://bugs.python.org/issue?@action=redirect&bpo=30399

   (13) https://bugs.python.org/issue?@action=redirect&bpo=30302

   (14) https://unicode.org/reports/tr18/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=30349

   (16) https://bugs.python.org/issue?@action=redirect&bpo=25054

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32308

   (18) https://bugs.python.org/issue?@action=redirect&bpo=29995

   (19) https://bugs.python.org/issue?@action=redirect&bpo=32121

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32331

   (21) https://bugs.python.org/issue?@action=redirect&bpo=33169

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32327

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32662

   (24) https://bugs.python.org/issue?@action=redirect&bpo=21071

   (25) https://bugs.python.org/issue?@action=redirect&bpo=26510

   (26) https://bugs.python.org/issue?@action=redirect&bpo=31778

   (27) https://bugs.python.org/issue?@action=redirect&bpo=28292

   (28) https://bugs.python.org/issue?@action=redirect&bpo=32792

   (29) https://bugs.python.org/issue?@action=redirect&bpo=33097

   (30) https://bugs.python.org/issue?@action=redirect&bpo=23835


File: python.info,  Node: C API の変更<8>,  Next: CPython バイトコードの変更<5>,  Prev: Python API の変更<5>,  Up: Python 3 7 への移植

1.7.17.3 C API の変更
.....................

The function *note PySlice_GetIndicesEx(): 3d5. is considered unsafe for
resizable sequences.  If the slice indices are not instances of *note
int: 238, but objects that implement the ‘__index__()’ method, the
sequence can be resized after passing its length to
‘PySlice_GetIndicesEx()’.  This can lead to returning indices out of the
length of the sequence.  For avoiding possible problems use new
functions *note PySlice_Unpack(): 3d6. and *note
PySlice_AdjustIndices(): 3d7.  (Contributed by Serhiy Storchaka in
bpo-27867(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27867


File: python.info,  Node: CPython バイトコードの変更<5>,  Next: Windows-only Changes<2>,  Prev: C API の変更<8>,  Up: Python 3 7 への移植

1.7.17.4 CPython バイトコードの変更
...................................

There are two new opcodes: *note LOAD_METHOD: bed. and ‘CALL_METHOD’.
(Contributed by Yury Selivanov and INADA Naoki in bpo-26110(1).)

The ‘STORE_ANNOTATION’ opcode has been removed.  (Contributed by Mark
Shannon in bpo-32550(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26110

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32550


File: python.info,  Node: Windows-only Changes<2>,  Next: その他の CPython の実装の変更<3>,  Prev: CPython バイトコードの変更<5>,  Up: Python 3 7 への移植

1.7.17.5 Windows-only Changes
.............................

The file used to override *note sys.path: 38e. is now called
‘<python-executable>._pth’ instead of ‘'sys.path'’.  See *note
モジュールの検索: bef. for more information.  (Contributed by Steve
Dower in bpo-28137(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28137


File: python.info,  Node: その他の CPython の実装の変更<3>,  Prev: Windows-only Changes<2>,  Up: Python 3 7 への移植

1.7.17.6 その他の CPython の実装の変更
......................................

In preparation for potential future changes to the public CPython
runtime initialization API (see PEP 432(1) for an initial, but somewhat
outdated, draft), CPython's internal startup and configuration
management logic has been significantly refactored.  While these updates
are intended to be entirely transparent to both embedding applications
and users of the regular CPython CLI, they're being mentioned here as
the refactoring changes the internal order of various operations during
interpreter startup, and hence may uncover previously latent defects,
either in embedding applications, or in CPython itself.  (Initially
contributed by Nick Coghlan and Eric Snow as part of bpo-22257(2), and
further updated by Nick, Eric, and Victor Stinner in a number of other
issues).  Some known details affected:

   * ‘PySys_AddWarnOptionUnicode()’ is not currently usable by embedding
     applications due to the requirement to create a Unicode object
     prior to calling ‘Py_Initialize’.  Use ‘PySys_AddWarnOption()’
     instead.

   * warnings filters added by an embedding application with
     ‘PySys_AddWarnOption()’ should now more consistently take
     precedence over the default filters set by the interpreter

Due to changes in the way the default warnings filters are configured,
setting *note Py_BytesWarningFlag: 3ae. to a value greater than one is
no longer sufficient to both emit *note BytesWarning: bf1. messages and
have them converted to exceptions.  Instead, the flag must be set (to
cause the warnings to be emitted in the first place), and an explicit
‘error::BytesWarning’ warnings filter added to convert them to
exceptions.

Due to a change in the way docstrings are handled by the compiler, the
implicit ‘return None’ in a function body consisting solely of a
docstring is now marked as occurring on the same line as the docstring,
not on the function's header line.

The current exception state has been moved from the frame object to the
co-routine.  This simplified the interpreter and fixed a couple of
obscure bugs caused by having swap exception state when entering or
exiting a generator.  (Contributed by Mark Shannon in bpo-25612(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0432/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22257

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25612


File: python.info,  Node: Python 3 7 1 での重要な変更点,  Next: Python 3 7 2 での重要な変更点,  Prev: Python 3 7 への移植,  Up: What's New In Python 3 7

1.7.18 Python 3.7.1 での重要な変更点
------------------------------------

Starting in 3.7.1, *note Py_Initialize(): 87a. now consistently reads
and respects all of the same environment settings as *note Py_Main():
bf3. (in earlier Python versions, it respected an ill-defined subset of
those environment variables, while in Python 3.7.0 it didn't read any of
them due to bpo-34247(1)).  If this behavior is unwanted, set *note
Py_IgnoreEnvironmentFlag: 3b2. to 1 before calling *note
Py_Initialize(): 87a.

In 3.7.1 the C API for Context Variables *note was updated: bf4. to use
*note PyObject: 312. pointers.  See also bpo-34762(2).

In 3.7.1 the *note tokenize: e4. module now implicitly emits a ‘NEWLINE’
token when provided with input that does not have a trailing new line.
This behavior now matches what the C tokenizer does internally.
(Contributed by Ammar Askar in bpo-33899(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34247

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34762

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33899


File: python.info,  Node: Python 3 7 2 での重要な変更点,  Next: Python 3 7 6 での重要な変更点,  Prev: Python 3 7 1 での重要な変更点,  Up: What's New In Python 3 7

1.7.19 Python 3.7.2 での重要な変更点
------------------------------------

In 3.7.2, *note venv: f9. on Windows no longer copies the original
binaries, but creates redirector scripts named ‘python.exe’ and
‘pythonw.exe’ instead.  This resolves a long standing issue where all
virtual environments would have to be upgraded or recreated with each
Python update.  However, note that this release will still require
recreation of virtual environments in order to get the new scripts.


File: python.info,  Node: Python 3 7 6 での重要な変更点,  Next: Python 3 7 10 での重要な変更点,  Prev: Python 3 7 2 での重要な変更点,  Up: What's New In Python 3 7

1.7.20 Python 3.7.6 での重要な変更点
------------------------------------

セキュリティ上の重大な懸念により、*note
asyncio.loop.create_datagram_endpoint(): 6fe. での 'reuse_address' 引数
は無効になりました。これはソケットオプション ‘SO_REUSEADDR'’ のUDP にお
ける挙動が原因です。詳しくは、‘loop.create_datagram_endpoint()’ のドキュ
メントを参照してください。(Kyle Stanley, Antoine Pitrou, Yury Selivanov
による貢献 bpo-37228(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37228


File: python.info,  Node: Python 3 7 10 での重要な変更点,  Next: Notable changes in Python 3 7 11,  Prev: Python 3 7 6 での重要な変更点,  Up: What's New In Python 3 7

1.7.21 Python 3.7.10 での重要な変更点
-------------------------------------

Earlier Python versions allowed using both ‘;’ and ‘&’ as query
parameter separators in *note urllib.parse.parse_qs(): 25b. and *note
urllib.parse.parse_qsl(): 25a.  Due to security concerns, and to conform
with newer W3C recommendations, this has been changed to allow only a
single separator key, with ‘&’ as the default.  This change also affects
‘cgi.parse()’ and ‘cgi.parse_multipart()’ as they use the affected
functions internally.  For more details, please see their respective
documentation.  (Contributed by Adam Goldschmidt, Senthil Kumaran and
Ken Jin in bpo-42967(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42967


File: python.info,  Node: Notable changes in Python 3 7 11,  Next: Notable security feature in 3 7 14,  Prev: Python 3 7 10 での重要な変更点,  Up: What's New In Python 3 7

1.7.22 Notable changes in Python 3.7.11
---------------------------------------

A security fix alters the *note ftplib.FTP: 8c8. behavior to not trust
the IPv4 address sent from the remote server when setting up a passive
data channel.  We reuse the ftp server IP address instead.  For unusual
code requiring the old behavior, set a ‘trust_server_pasv_ipv4_address’
attribute on your FTP instance to ‘True’.  (See gh-87451(1))

The presence of newline or tab characters in parts of a URL allows for
some forms of attacks.  Following the WHATWG specification that updates
RFC 3986, ASCII newline ‘\n’, ‘\r’ and tab ‘\t’ characters are stripped
from the URL by the parser *note urllib.parse(): f3. preventing such
attacks.  The removal characters are controlled by a new module level
variable ‘urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE’.  (See gh-88048(2))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/87451

   (2) https://github.com/python/cpython/issues/88048


File: python.info,  Node: Notable security feature in 3 7 14,  Prev: Notable changes in Python 3 7 11,  Up: What's New In Python 3 7

1.7.23 Notable security feature in 3.7.14
-----------------------------------------

Converting between *note int: 238. and *note str: 418. in bases other
than 2 (binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10
(decimal) now raises a *note ValueError: 1e3. if the number of digits in
string form is above a limit to avoid potential denial of service
attacks due to the algorithmic complexity.  This is a mitigation for CVE
2020-10735(1).  This limit can be configured or disabled by environment
variable, command line flag, or *note sys: c3. APIs.  See the *note
integer string conversion length limitation: 5bf. documentation.  The
default limit is 4300 digits in string form.

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2020-10735


File: python.info,  Node: What's New In Python 3 6,  Next: What's New In Python 3 5,  Prev: What's New In Python 3 7,  Up: What's New in Python

1.8 What's New In Python 3.6
============================


エディタ: Elvis Pranskevichus <<elvis@magic.io>>, Yury Selivanov
<<yury@magic.io>>

この記事では 3.5 と比較した Python 3.6 の新機能を解説します。 Python 3.6
は2016年12月23日にリリースされました。 全詳細については 変更履歴(1) をご
覧ください。

参考
....

PEP 494(2) - Python 3.6 リリーススケジュール

* Menu:

* 概要: 概要 -- リリースハイライト<6>. リリースハイライト
* 新しい機能: 新しい機能<9>.
* その他の言語変更: その他の言語変更<6>.
* 新たなモジュール: 新たなモジュール<6>.
* 改良されたモジュール: 改良されたモジュール<6>.
* 最適化: 最適化<6>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<2>.
* その他の改善::
* 非推奨: 非推奨<7>.
* 削除: 削除<7>.
* Python 3.6 への移植: Python 3 6 への移植.
* Notable changes in Python 3.6.2: Notable changes in Python 3 6 2.
* Notable changes in Python 3.6.4: Notable changes in Python 3 6 4.
* Notable changes in Python 3.6.5: Notable changes in Python 3 6 5.
* Notable changes in Python 3.6.7: Notable changes in Python 3 6 7.
* Notable changes in Python 3.6.10: Notable changes in Python 3 6 10.
* Notable changes in Python 3.6.13: Notable changes in Python 3 6 13.
* Notable changes in Python 3.6.14: Notable changes in Python 3 6 14.

   ---------- Footnotes ----------

   (1) https://docs.python.org/3.6/whatsnew/changelog.html

   (2) https://peps.python.org/pep-0494/


File: python.info,  Node: 概要 -- リリースハイライト<6>,  Next: 新しい機能<9>,  Up: What's New In Python 3 6

1.8.1 概要 - リリースハイライト
-------------------------------

新たな文法機能:

   * *note PEP 498: bfd.、フォーマット済み文字列リテラル。

   * *note PEP 515: bfe.、数値リテラル内のアンダースコア。

   * *note PEP 526: bff.、変数アノテーションの文法。

   * *note PEP 525: c00.、非同期ジェネレータ。

   * *note PEP 530: c01.: 非同期内包表記

新たなライブラリモジュール:

   * *note secrets: ae.: *note PEP 506 - 標準ライブラリーに Secrets
     モジュールを追加: c02.

CPython の実装の改善:

   * *note dict: a94. 型は、 Raymond Hettinger(1) の提案に基づき、 PyPy
     dict implementation(2) と同様の *note よりコンパクトな表現: c03. を
     使うように再実装されました。 その結果、 Python 3.5 と比較して辞書が
     使うメモリ 20% から 25% 減少しました。

   * *note 新しいプロトコル: c04. により、クラス生成のカスタマイズがより
     簡単になりました。

   * クラス属性の定義の順番が *note 保持されるようになりました: c05.。

   * ‘**kwargs’ の要素の順序が、キーワード引数が関数に渡されたときの
     *note 順序に一致した: c06. ものになりました。

   * DTrace と SystemTap の *note プローブのサポート: c07. が追加されま
     した。

   * 新しい *note PYTHONMALLOC: c08.  環境変数が、インタープリタのメモリ
     確保とメモリアクセスエラーのデバッグに使えるようになりました。

標準ライブラリーの顕著な改善

   * The *note asyncio: 8. module has received new features, significant
     usability and performance improvements, and a fair amount of bug
     fixes.  Starting with Python 3.6 the ‘asyncio’ module is no longer
     provisional and its API is considered stable.

   * A new *note file system path protocol: c09. has been implemented to
     support *note path-like objects: 280.  All standard library
     functions operating on paths have been updated to work with the new
     protocol.

   * *note datetime: 28. モジュールで *note 地域時間の曖昧さ回避: c0a. が
     サポートされました。

   * *note typing: ed. モジュールに数多くの *note 改善: c0b. がなされま
     した。

   * *note tracemalloc: e8. モジュールが大幅に書き直され、改善されたメモ
     リ割り当てエラーの診断プログラムの提供だけでなく、 *note
     ResourceWarning: 225. の出力メッセージも改善されています。 より詳し
     いことは *note PYTHONMALLOC 節: c08. を参照してください。

セキュリティの改善:

   * The new *note secrets: ae. module has been added to simplify the
     generation of cryptographically strong pseudo-random numbers
     suitable for managing secrets such as account authentication,
     tokens, and similar.

   * On Linux, *note os.urandom(): 4ec. now blocks until the system
     urandom entropy pool is initialized to increase the security.  See
     the PEP 524(3) for the rationale.

   * *note hashlib: 5e. および *note ssl: bb. モジュールは OpenSSL 1.1.0
     をサポートしました。

   * *note ssl: bb. モジュールのデフォルトの設定と機能群が改善されました
     。

   * *note hashlib: 5e. モジュールで BLAKE2, SHA-3, SHAKE ハッシュアルゴ
     リズムと *note scrypt(): c0c. キー導出関数がサポートされるようにな
     りました。

Windows の改善:

   * *note PEP 528: c0d. および *note PEP 529: c0e.、 Windows のファイル
     システムとコンソールのエンコーディングを UTF-8 に変更しました。

   * ‘py.exe’ ランチャーを対話的に使うときに、 (コマンドライン引数や設定
     ファイルで) バージョンを指定しないと Python 3 よりも Python 2 を選
     択するということはなくなりました。 シェバン行の扱いは以前のままで、
     "python" とあった場合は Python 2 を指しています。

   * ‘python.exe’ and ‘pythonw.exe’ have been marked as long-path aware,
     which means that the 260 character path limit may no longer apply.
     See *note removing the MAX_PATH limitation: c0f. for details.

   * A ‘._pth’ file can be added to force isolated mode and fully
     specify all search paths to avoid registry and environment lookup.
     See *note the documentation: bef. for more information.

   * A ‘python36.zip’ file now works as a landmark to infer *note
     PYTHONHOME: 396.  See *note the documentation: bef. for more
     information.

   ---------- Footnotes ----------

   (1) 
https://mail.python.org/pipermail/python-dev/2012-December/123028.html

   (2) 
https://morepypy.blogspot.com/2015/01/faster-more-memory-efficient-and-more.html

   (3) https://peps.python.org/pep-0524/


File: python.info,  Node: 新しい機能<9>,  Next: その他の言語変更<6>,  Prev: 概要 -- リリースハイライト<6>,  Up: What's New In Python 3 6

1.8.2 新しい機能
----------------

* Menu:

* PEP 498; フォーマット済み文字列リテラル: PEP 498 フォーマット済み文字列リテラル.
* PEP 526; 変数アノテーションの文法: PEP 526 変数アノテーションの文法.
* PEP 515; 数値リテラル内のアンダースコア: PEP 515 数値リテラル内のアンダースコア.
* PEP 525; 非同期ジェネレータ: PEP 525 非同期ジェネレータ.
* PEP 530; 非同期内包表記: PEP 530 非同期内包表記.
* PEP 487; Simpler customization of class creation: PEP 487 Simpler customization of class creation.
* PEP 487; 記述子プロトコルの改善: PEP 487 記述子プロトコルの改善.
* PEP 519; ファイルシステムパスプロトコルの追加: PEP 519 ファイルシステムパスプロトコルの追加.
* PEP 495; 地域時間の曖昧さ回避: PEP 495 地域時間の曖昧さ回避.
* PEP 529; Windows ファイルシステムのエンコーディングを UTF-8 に変更: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更.
* PEP 528; Windows コンソールのエンコーディングを UTF-8 に変更: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更.
* PEP 520; クラス属性の定義の順番を保持: PEP 520 クラス属性の定義の順番を保持.
* PEP 468; キーワード引数の順番の保持: PEP 468 キーワード引数の順番の保持.
* 新たな dict 実装::
* PEP 523; CPython にフレーム評価 API を追加: PEP 523 CPython にフレーム評価 API を追加.
* PYTHONMALLOC 環境変数::
* DTrace and SystemTap probing support::


File: python.info,  Node: PEP 498 フォーマット済み文字列リテラル,  Next: PEP 526 変数アノテーションの文法,  Up: 新しい機能<9>

1.8.2.1 PEP 498: フォーマット済み文字列リテラル
...............................................

PEP 498(1) は新たな種類の文字列リテラル、すなわち 'f-strings'、 *note
フォーマット済み文字列リテラル: 977. を導入しました。

フォーマット済み文字列リテラルはプレフィックスに ‘'f'’ をとり *note
str.format(): 5ed. による書式文字列に似ています。これらには中括弧で囲ま
れた置換フィールドがあります。置換フィールドは実行時に評価される式で、
*note format(): 5eb. プロトコルによってフォーマットされます:

     >>> name = "Fred"
     >>> f"He said his name is {name}."
     'He said his name is Fred.'
     >>> width = 10
     >>> precision = 4
     >>> value = decimal.Decimal("12.34567")
     >>> f"result: {value:{width}.{precision}}"  # nested fields
     'result:      12.35'

参考
....

PEP 498(2) - Literal String Interpolation.

     PEP written and implemented by Eric V. Smith.

*note Feature documentation: 977.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0498/

   (2) https://peps.python.org/pep-0498/


File: python.info,  Node: PEP 526 変数アノテーションの文法,  Next: PEP 515 数値リテラル内のアンダースコア,  Prev: PEP 498 フォーマット済み文字列リテラル,  Up: 新しい機能<9>

1.8.2.2 PEP 526: 変数アノテーションの文法
.........................................

PEP 484(1) は関数の仮引数の型アノテーション、型ヒント、の標準を導入しま
した。この PEP は Python に、クラス変数およびインスタンス変数を含む変数
の型アノテーションの構文を追加しました:

     primes: List[int] = []

     captain: str  # Note: no initial value!

     class Starship:
         stats: Dict[str, int] = {}

関数アノテーションと同様に、Python インタープリタは変数アノテーションに
特定の意味を付加せず、クラスやモジュールの ‘__annotations__’ 属性に保存
するだけです。

静的型付け言語の変数定義とは対照的に、アノテーションシンタックスの目的は
抽象構文木および ‘__annotations__’ 属性を通じて、サードパーティツールや
ライブラリーに型の構造化されたメタデータを指定する簡単な方法を提供するこ
とです。

参考
....

PEP 526(2) - Syntax for variable annotations

     PEP written by Ryan Gonzalez, Philip House, Ivan Levkivskyi, Lisa
     Roach, and Guido van Rossum.  Implemented by Ivan Levkivskyi.

新構文を使用あるいは使用予定のツール: mypy(3), pytype(4), PyCharm などな
ど。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0526/

   (3) https://www.mypy-lang.org/

   (4) https://github.com/google/pytype


File: python.info,  Node: PEP 515 数値リテラル内のアンダースコア,  Next: PEP 525 非同期ジェネレータ,  Prev: PEP 526 変数アノテーションの文法,  Up: 新しい機能<9>

1.8.2.3 PEP 515: 数値リテラル内のアンダースコア
...............................................

PEP 515(1) により、可読性向上のために数値リテラル内でアンダースコアを使
えるようになりました。例えば:

     >>> 1_000_000_000_000_000
     1000000000000000
     >>> 0x_FF_FF_FF_FF
     4294967295

単一のアンダースコアは数字の間と基数指定子の後で許されます。先頭、末尾、
あるいは複数のアンダースコアを列内で使用することはできません。

The *note string formatting: 1c9. language also now has support for the
‘'_'’ option to signal the use of an underscore for a thousands
separator for floating-point presentation types and for integer
presentation type ‘'d'’.  For integer presentation types ‘'b'’, ‘'o'’,
‘'x'’, and ‘'X'’, underscores will be inserted every 4 digits:

     >>> '{:_}'.format(1000000)
     '1_000_000'
     >>> '{:_x}'.format(0xFFFFFFFF)
     'ffff_ffff'

参考
....

PEP 515(2) - 数値リテラル内のアンダースコア

     PEP written by Georg Brandl and Serhiy Storchaka.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0515/

   (2) https://peps.python.org/pep-0515/


File: python.info,  Node: PEP 525 非同期ジェネレータ,  Next: PEP 530 非同期内包表記,  Prev: PEP 515 数値リテラル内のアンダースコア,  Up: 新しい機能<9>

1.8.2.4 PEP 525: 非同期ジェネレータ
...................................

PEP 492(1) で Python 3.5 はネイティブなコルーチンならびに ‘async’ /
‘await’ 構文をサポートしました。Python 3.5 実装における大きな制約は同一
の関数実体内で ‘await’ と ‘yield’ を使えないことでした。Python 3.6 では
この制約はなくなり、 '非同期ジェネレータ' を定義できるようになりました:

     async def ticker(delay, to):
         """Yield numbers from 0 to *to* every *delay* seconds."""
         for i in range(to):
             yield i
             await asyncio.sleep(delay)

新たな構文のおかげでより速く、より簡潔にコードを書くことができます。

参考
....

PEP 525(2) - 非同期ジェネレータ

     PEP written and implemented by Yury Selivanov.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0492/

   (2) https://peps.python.org/pep-0525/


File: python.info,  Node: PEP 530 非同期内包表記,  Next: PEP 487 Simpler customization of class creation,  Prev: PEP 525 非同期ジェネレータ,  Up: 新しい機能<9>

1.8.2.5 PEP 530: 非同期内包表記
...............................

PEP 530(1) によりリスト、セット、辞書内包表記ならびにジェネレータ式内で
の ‘async for’ の使用がサポートされました:

     result = [i async for i in aiter() if i % 2]

加えて、 ‘await’ 式が全ての内包表記でサポートされました:

     result = [await fun() for fun in funcs if await condition()]

参考
....

PEP 530(2) - 非同期内包表記

     PEP written and implemented by Yury Selivanov.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0530/

   (2) https://peps.python.org/pep-0530/


File: python.info,  Node: PEP 487 Simpler customization of class creation,  Next: PEP 487 記述子プロトコルの改善,  Prev: PEP 530 非同期内包表記,  Up: 新しい機能<9>

1.8.2.6 PEP 487: Simpler customization of class creation
........................................................

It is now possible to customize subclass creation without using a
metaclass.  The new ‘__init_subclass__’ classmethod will be called on
the base class whenever a new subclass is created:

     class PluginBase:
         subclasses = []

         def __init_subclass__(cls, **kwargs):
             super().__init_subclass__(**kwargs)
             cls.subclasses.append(cls)

     class Plugin1(PluginBase):
         pass

     class Plugin2(PluginBase):
         pass

In order to allow zero-argument *note super(): 4a8. calls to work
correctly from *note __init_subclass__(): 5fd. implementations, custom
metaclasses must ensure that the new ‘__classcell__’ namespace entry is
propagated to ‘type.__new__’ (as described in *note
クラスオブジェクトの作成: c18.).

参考
....

PEP 487(1) - Simpler customization of class creation

     PEP 著と実装 Martin Teichmann.

*note Feature documentation: c19.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0487/


File: python.info,  Node: PEP 487 記述子プロトコルの改善,  Next: PEP 519 ファイルシステムパスプロトコルの追加,  Prev: PEP 487 Simpler customization of class creation,  Up: 新しい機能<9>

1.8.2.7 PEP 487: 記述子プロトコルの改善
.......................................

PEP 487(1) extends the descriptor protocol to include the new optional
*note __set_name__(): c1c. method.  Whenever a new class is defined, the
new method will be called on all descriptors included in the definition,
providing them with a reference to the class being defined and the name
given to the descriptor within the class namespace.  In other words,
instances of descriptors can now know the attribute name of the
descriptor in the owner class:

     class IntField:
         def __get__(self, instance, owner):
             return instance.__dict__[self.name]

         def __set__(self, instance, value):
             if not isinstance(value, int):
                 raise ValueError(f'expecting integer in {self.name}')
             instance.__dict__[self.name] = value

         # this is the new initializer:
         def __set_name__(self, owner, name):
             self.name = name

     class Model:
         int_field = IntField()

参考
....

PEP 487(2) - Simpler customization of class creation

     PEP 著と実装 Martin Teichmann.

*note Feature documentation: c1d.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0487/

   (2) https://peps.python.org/pep-0487/


File: python.info,  Node: PEP 519 ファイルシステムパスプロトコルの追加,  Next: PEP 495 地域時間の曖昧さ回避,  Prev: PEP 487 記述子プロトコルの改善,  Up: 新しい機能<9>

1.8.2.8 PEP 519: ファイルシステムパスプロトコルの追加
.....................................................

File system paths have historically been represented as *note str: 418.
or *note bytes: 1a4. objects.  This has led to people who write code
which operate on file system paths to assume that such objects are only
one of those two types (an *note int: 238. representing a file
descriptor does not count as that is not a file path).  Unfortunately
that assumption prevents alternative object representations of file
system paths like *note pathlib: 93. from working with pre-existing
code, including Python's standard library.

To fix this situation, a new interface represented by *note os.PathLike:
c1f. has been defined.  By implementing the *note __fspath__(): c20.
method, an object signals that it represents a path.  An object can then
provide a low-level representation of a file system path as a *note str:
418. or *note bytes: 1a4. object.  This means an object is considered
*note path-like: 280. if it implements *note os.PathLike: c1f. or is a
*note str: 418. or *note bytes: 1a4. object which represents a file
system path.  Code can use *note os.fspath(): c21, *note os.fsdecode():
c22, or *note os.fsencode(): c23. to explicitly get a *note str: 418.
and/or *note bytes: 1a4. representation of a path-like object.

The built-in *note open(): 4e5. function has been updated to accept
*note os.PathLike: c1f. objects, as have all relevant functions in the
*note os: 91. and *note os.path: 92. modules, and most other functions
and classes in the standard library.  The *note os.DirEntry: 468. class
and relevant classes in *note pathlib: 93. have also been updated to
implement *note os.PathLike: c1f.

The hope is that updating the fundamental functions for operating on
file system paths will lead to third-party code to implicitly support
all *note path-like objects: 280. without any code changes, or at least
very minimal ones (e.g.  calling *note os.fspath(): c21. at the
beginning of code before operating on a path-like object).

Here are some examples of how the new interface allows for *note
pathlib.Path: 20a. to be used more easily and transparently with
pre-existing code:

     >>> import pathlib
     >>> with open(pathlib.Path("README")) as f:
     ...     contents = f.read()
     ...
     >>> import os.path
     >>> os.path.splitext(pathlib.Path("some_file.txt"))
     ('some_file', '.txt')
     >>> os.path.join("/a/b", pathlib.Path("c"))
     '/a/b/c'
     >>> import os
     >>> os.fspath(pathlib.Path("some_file.txt"))
     'some_file.txt'

(Implemented by Brett Cannon, Ethan Furman, Dusty Phillips, and Jelle
Zijlstra.)

参考
....

PEP 519(1) - ファイルシステムパスプロトコルの追加

     PEP written by Brett Cannon and Koos Zevenhoven.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0519/


File: python.info,  Node: PEP 495 地域時間の曖昧さ回避,  Next: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更,  Prev: PEP 519 ファイルシステムパスプロトコルの追加,  Up: 新しい機能<9>

1.8.2.9 PEP 495: 地域時間の曖昧さ回避
.....................................

世界の大抵の場所で、地域時計が1日繰り下げられることがこれまでありました
し、これからもあるでしょう。そういった時に、同じ日に同じ時間を指す区間が
あります。そういった状況では地域時計が表示する (あるいは Python の
datetime インスタンスが格納する) 情報では、時間内の特定の瞬間を識別する
ことはできません。

PEP 495(1) は時間内の地域時間が同じ二つの瞬間を区別するために、新たな
'fold' 属性を *note datetime.datetime: 1ae. インスタンスならびに *note
datetime.time: 1b0. クラスに追加しました。

     >>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)
     >>> for i in range(4):
     ...     u = u0 + i*HOUR
     ...     t = u.astimezone(Eastern)
     ...     print(u.time(), 'UTC =', t.time(), t.tzname(), t.fold)
     ...
     04:00:00 UTC = 00:00:00 EDT 0
     05:00:00 UTC = 01:00:00 EDT 0
     06:00:00 UTC = 01:00:00 EST 1
     07:00:00 UTC = 02:00:00 EST 0

*note fold: c25. 属性の値は、曖昧な場合に時間内の二番目の (年代的) 瞬間
を表しているものを除く全てのインスタンスで ‘0’ です。

参考
....

PEP 495(2) - 地域時間の曖昧さ回避

     PEP written by Alexander Belopolsky and Tim Peters, implementation
     by Alexander Belopolsky.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0495/

   (2) https://peps.python.org/pep-0495/


File: python.info,  Node: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更,  Next: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更,  Prev: PEP 495 地域時間の曖昧さ回避,  Up: 新しい機能<9>

1.8.2.10 PEP 529: Windows ファイルシステムのエンコーディングを UTF-8 に変更
...........................................................................

Representing filesystem paths is best performed with str (Unicode)
rather than bytes.  However, there are some situations where using bytes
is sufficient and correct.

Prior to Python 3.6, data loss could result when using bytes paths on
Windows.  With this change, using bytes to represent paths is now
supported on Windows, provided those bytes are encoded with the encoding
returned by *note sys.getfilesystemencoding(): c27, which now defaults
to ‘'utf-8'’.

Applications that do not use str to represent paths should use *note
os.fsencode(): c23. and *note os.fsdecode(): c22. to ensure their bytes
are correctly encoded.  To revert to the previous behaviour, set *note
PYTHONLEGACYWINDOWSFSENCODING: 28f. or call *note
sys._enablelegacywindowsfsencoding(): 28e.

See PEP 529(1) for more information and discussion of code modifications
that may be required.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0529/


File: python.info,  Node: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更,  Next: PEP 520 クラス属性の定義の順番を保持,  Prev: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更,  Up: 新しい機能<9>

1.8.2.11 PEP 528: Windows コンソールのエンコーディングを UTF-8 に変更
.....................................................................

The default console on Windows will now accept all Unicode characters
and provide correctly read str objects to Python code.  ‘sys.stdin’,
‘sys.stdout’ and ‘sys.stderr’ now default to utf-8 encoding.

This change only applies when using an interactive console, and not when
redirecting files or pipes.  To revert to the previous behaviour for
interactive console use, set *note PYTHONLEGACYWINDOWSSTDIO: c29.

参考
....

PEP 528(1) - Windows コンソールのエンコーディングを UTF-8 に変更

     PEP written and implemented by Steve Dower.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0528/


File: python.info,  Node: PEP 520 クラス属性の定義の順番を保持,  Next: PEP 468 キーワード引数の順番の保持,  Prev: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更,  Up: 新しい機能<9>

1.8.2.12 PEP 520: クラス属性の定義の順番を保持
..............................................

Attributes in a class definition body have a natural ordering: the same
order in which the names appear in the source.  This order is now
preserved in the new class's *note __dict__: c2b. attribute.

Also, the effective default class 'execution' namespace (returned from
*note type.__prepare__(): c2c.) is now an insertion-order-preserving
mapping.

参考
....

PEP 520(1) - クラス属性の定義の順番を保持

     PEP written and implemented by Eric Snow.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0520/


File: python.info,  Node: PEP 468 キーワード引数の順番の保持,  Next: 新たな dict 実装,  Prev: PEP 520 クラス属性の定義の順番を保持,  Up: 新しい機能<9>

1.8.2.13 PEP 468: キーワード引数の順番の保持
............................................

関数シグニチャにおける ‘**kwargs’ は挿入順序を保存するマッピングであるこ
とが保証されるようになりました。

参考
....

PEP 468(1) - キーワード引数の順番の保持

     PEP written and implemented by Eric Snow.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0468/


File: python.info,  Node: 新たな dict 実装,  Next: PEP 523 CPython にフレーム評価 API を追加,  Prev: PEP 468 キーワード引数の順番の保持,  Up: 新しい機能<9>

1.8.2.14 新たな dict 実装
.........................

The *note dict: a94. type now uses a "compact" representation based on a
proposal by Raymond Hettinger(1) which was first implemented by PyPy(2).
The memory usage of the new *note dict(): 237. is between 20% and 25%
smaller compared to Python 3.5.

The order-preserving aspect of this new implementation is considered an
implementation detail and should not be relied upon (this may change in
the future, but it is desired to have this new dict implementation in
the language for a few releases before changing the language spec to
mandate order-preserving semantics for all current and future Python
implementations; this also helps preserve backwards-compatibility with
older versions of the language where random iteration order is still in
effect, e.g.  Python 3.5).

(Contributed by INADA Naoki in bpo-27350(3).  Idea originally suggested
by Raymond Hettinger(4).)

   ---------- Footnotes ----------

   (1) 
https://mail.python.org/pipermail/python-dev/2012-December/123028.html

   (2) 
https://morepypy.blogspot.com/2015/01/faster-more-memory-efficient-and-more.html

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27350

   (4) 
https://mail.python.org/pipermail/python-dev/2012-December/123028.html


File: python.info,  Node: PEP 523 CPython にフレーム評価 API を追加,  Next: PYTHONMALLOC 環境変数,  Prev: 新たな dict 実装,  Up: 新しい機能<9>

1.8.2.15 PEP 523: CPython にフレーム評価 API を追加
...................................................

While Python provides extensive support to customize how code executes,
one place it has not done so is in the evaluation of frame objects.  If
you wanted some way to intercept frame evaluation in Python there really
wasn't any way without directly manipulating function pointers for
defined functions.

PEP 523(1) changes this by providing an API to make frame evaluation
pluggable at the C level.  This will allow for tools such as debuggers
and JITs to intercept frame evaluation before the execution of Python
code begins.  This enables the use of alternative evaluation
implementations for Python code, tracking frame evaluation, etc.

This API is not part of the limited C API and is marked as private to
signal that usage of this API is expected to be limited and only
applicable to very select, low-level use-cases.  Semantics of the API
will change with Python as necessary.

参考
....

PEP 523(2) - Adding a frame evaluation API to CPython

     PEP written by Brett Cannon and Dino Viehland.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0523/

   (2) https://peps.python.org/pep-0523/


File: python.info,  Node: PYTHONMALLOC 環境変数,  Next: DTrace and SystemTap probing support,  Prev: PEP 523 CPython にフレーム評価 API を追加,  Up: 新しい機能<9>

1.8.2.16 PYTHONMALLOC 環境変数
..............................

新たな環境変数 *note PYTHONMALLOC: c32. により Python メモリアロケータの
設定とデバッグフックの導入ができます。

‘PYTHONMALLOC=debug’ を使用してリリースモードでコンパイルされた Python で
、Python メモリアロケータにデバッグフックを導入できるようになりました。
デバッグフックの効果は:

   * 新たに割り当てられたメモリを ‘0xCB’ バイトで埋めます

   * 解放されたメモリを ‘0xDB’ バイトで埋めます

   * Python メモリアロケータ API の違反を検知します。例えば *note
     PyMem_Malloc(): c33. で割り当てられたメモリブロックに *note
     PyObject_Free(): c34. を呼ぶこと。

   * バッファ開始前の書き込み (バッファアンダーフロー) を検知します

   * バッファ終端後の書き込み (バッファオーバーフロー) を検知します

   * Check that the *note GIL: 12e. is held when allocator functions of
     *note PYMEM_DOMAIN_OBJ: c35. (ex: *note PyObject_Malloc(): c36.)
     and *note PYMEM_DOMAIN_MEM: c37. (ex: *note PyMem_Malloc(): c33.)
     domains are called.

Checking if the GIL is held is also a new feature of Python 3.6.

See the *note PyMem_SetupDebugHooks(): c38. function for debug hooks on
Python memory allocators.

It is now also possible to force the usage of the ‘malloc()’ allocator
of the C library for all Python memory allocations using
‘PYTHONMALLOC=malloc’.  This is helpful when using external memory
debuggers like Valgrind on a Python compiled in release mode.

On error, the debug hooks on Python memory allocators now use the *note
tracemalloc: e8. module to get the traceback where a memory block was
allocated.

Example of fatal error on buffer overflow using ‘python3.6 -X
tracemalloc=5’ (store 5 frames in traces):

     Debug memory block at address p=0x7fbcd41666f8: API 'o'
         4 bytes originally requested
         The 7 pad bytes at p-7 are FORBIDDENBYTE, as expected.
         The 8 pad bytes at tail=0x7fbcd41666fc are not all FORBIDDENBYTE (0xfb):
             at tail+0: 0x02 *** OUCH
             at tail+1: 0xfb
             at tail+2: 0xfb
             at tail+3: 0xfb
             at tail+4: 0xfb
             at tail+5: 0xfb
             at tail+6: 0xfb
             at tail+7: 0xfb
         The block was made by call #1233329 to debug malloc/realloc.
         Data at p: 1a 2b 30 00

     Memory block allocated at (most recent call first):
       File "test/test_bytes.py", line 323
       File "unittest/case.py", line 600
       File "unittest/case.py", line 648
       File "unittest/suite.py", line 122
       File "unittest/suite.py", line 84

     Fatal Python error: bad trailing pad byte

     Current thread 0x00007fbcdbd32700 (most recent call first):
       File "test/test_bytes.py", line 323 in test_hex
       File "unittest/case.py", line 600 in run
       File "unittest/case.py", line 648 in __call__
       File "unittest/suite.py", line 122 in run
       File "unittest/suite.py", line 84 in __call__
       File "unittest/suite.py", line 122 in run
       File "unittest/suite.py", line 84 in __call__
       ...

(Contributed by Victor Stinner in bpo-26516(1) and bpo-26564(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26516

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26564


File: python.info,  Node: DTrace and SystemTap probing support,  Prev: PYTHONMALLOC 環境変数,  Up: 新しい機能<9>

1.8.2.17 DTrace and SystemTap probing support
.............................................

Python can now be built ‘--with-dtrace’ which enables static markers for
the following events in the interpreter:

   * 関数の呼び出し/復帰

   * ガベージコレクションの開始/終了

   * 実行されたコードの行。

This can be used to instrument running interpreters in production,
without the need to recompile specific *note debug builds: 1da. or
providing application-specific profiling/debugging code.

詳細については *note DTrace と SystemTap で CPython を測定する: c3a. を
参照してください。

The current implementation is tested on Linux and macOS. Additional
markers may be added in the future.

(Contributed by Łukasz Langa in bpo-21590(1), based on patches by Jesús
Cea Avión, David Malcolm, and Nikhil Benesch.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21590


File: python.info,  Node: その他の言語変更<6>,  Next: 新たなモジュール<6>,  Prev: 新しい機能<9>,  Up: What's New In Python 3 6

1.8.3 その他の言語変更
----------------------

Python 言語コアに小さな変更がいくつか行われました:

   * A ‘global’ or ‘nonlocal’ statement must now textually appear before
     the first use of the affected name in the same scope.  Previously
     this was a *note SyntaxWarning: 432.

   * It is now possible to set a *note special method: c3c. to ‘None’ to
     indicate that the corresponding operation is not available.  For
     example, if a class sets ‘__iter__()’ to ‘None’, the class is not
     iterable.  (Contributed by Andrew Barnert and Ivan Levkivskyi in
     bpo-25958(1).)

   * Long sequences of repeated traceback lines are now abbreviated as
     ‘"[Previous line repeated {count} more times]"’ (see *note
     traceback: c3d. for an example).  (Contributed by Emanuel Barry in
     bpo-26823(2).)

   * Import now raises the new exception *note ModuleNotFoundError: b15.
     (subclass of *note ImportError: 3f2.) when it cannot find a module.
     Code that currently checks for ImportError (in try-except) will
     still work.  (Contributed by Eric Snow in bpo-15767(3).)

   * Class methods relying on zero-argument ‘super()’ will now work
     correctly when called from metaclass methods during class creation.
     (Contributed by Martin Teichmann in bpo-23722(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25958

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26823

   (3) https://bugs.python.org/issue?@action=redirect&bpo=15767

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23722


File: python.info,  Node: 新たなモジュール<6>,  Next: 改良されたモジュール<6>,  Prev: その他の言語変更<6>,  Up: What's New In Python 3 6

1.8.4 新たなモジュール
----------------------

* Menu:

* secrets::


File: python.info,  Node: secrets,  Up: 新たなモジュール<6>

1.8.4.1 secrets
...............

The main purpose of the new *note secrets: ae. module is to provide an
obvious way to reliably generate cryptographically strong pseudo-random
values suitable for managing secrets, such as account authentication,
tokens, and similar.

     警告: Note that the pseudo-random generators in the *note random:
     a6. module should 'NOT' be used for security purposes.  Use *note
     secrets: ae. on Python 3.6+ and *note os.urandom(): 4ec. on Python
     3.5 and earlier.

参考
....

PEP 506(1) - Adding A Secrets Module To The Standard Library

     PEP written and implemented by Steven D'Aprano.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0506/


File: python.info,  Node: 改良されたモジュール<6>,  Next: 最適化<6>,  Prev: 新たなモジュール<6>,  Up: What's New In Python 3 6

1.8.5 改良されたモジュール
--------------------------

* Menu:

* array: array<4>.
* ast: ast<4>.
* asyncio: asyncio<9>.
* binascii: binascii<2>.
* cmath::
* collections: collections<4>.
* concurrent.futures: concurrent futures<4>.
* contextlib: contextlib<4>.
* datetime: datetime<5>.
* decimal: decimal<2>.
* distutils: distutils<5>.
* email: email<2>.
* エンコーディング: エンコーディング<2>.
* enum: enum<6>.
* faulthandler: faulthandler<2>.
* fileinput: fileinput<2>.
* hashlib: hashlib<5>.
* http.client: http client<2>.
* idlelib と IDLE: idlelib と IDLE<2>.
* importlib: importlib<6>.
* inspect: inspect<6>.
* json::
* logging: logging<4>.
* math: math<7>.
* multiprocessing: multiprocessing<5>.
* os: os<8>.
* pathlib: pathlib<9>.
* pdb: pdb<5>.
* pickle: pickle<2>.
* pickletools::
* pydoc: pydoc<3>.
* random: random<4>.
* re: re<5>.
* readline::
* rlcompleter::
* shlex: shlex<2>.
* site: site<3>.
* sqlite3: sqlite3<7>.
* socket: socket<7>.
* socketserver: socketserver<2>.
* ssl: ssl<7>.
* statistics: statistics<5>.
* struct::
* subprocess: subprocess<3>.
* sys: sys<10>.
* telnetlib::
* time: time<6>.
* timeit::
* tkinter: tkinter<6>.
* traceback: traceback<4>.
* tracemalloc: tracemalloc<3>.
* typing: typing<9>.
* unicodedata: unicodedata<7>.
* unittest.mock: unittest mock<2>.
* urllib.request: urllib request.
* urllib.robotparser: urllib robotparser.
* venv: venv<5>.
* warnings: warnings<4>.
* winreg::
* winsound::
* xmlrpc.client: xmlrpc client.
* zipfile: zipfile<3>.
* zlib::


File: python.info,  Node: array<4>,  Next: ast<4>,  Up: 改良されたモジュール<6>

1.8.5.1 array
.............

Exhausted iterators of *note array.array: 185. will now stay exhausted
even if the iterated array is extended.  This is consistent with the
behavior of other mutable sequences.

Contributed by Serhiy Storchaka in bpo-26492(1).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26492


File: python.info,  Node: ast<4>,  Next: asyncio<9>,  Prev: array<4>,  Up: 改良されたモジュール<6>

1.8.5.2 ast
...........

The new *note ast.Constant: 299. AST node has been added.  It can be
used by external AST optimizers for the purposes of constant folding.

Contributed by Victor Stinner in bpo-26146(1).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26146


File: python.info,  Node: asyncio<9>,  Next: binascii<2>,  Prev: ast<4>,  Up: 改良されたモジュール<6>

1.8.5.3 asyncio
...............

Starting with Python 3.6 the ‘asyncio’ module is no longer provisional
and its API is considered stable.

Notable changes in the *note asyncio: 8. module since Python 3.5.0 (all
backported to 3.5.x due to the provisional status):

   * The *note get_event_loop(): 2a2. function has been changed to
     always return the currently running loop when called from
     coroutines and callbacks.  (Contributed by Yury Selivanov in
     bpo-28613(1).)

   * The *note ensure_future(): c44. function and all functions that use
     it, such as *note loop.run_until_complete(): c45, now accept all
     kinds of *note awaitable objects: 192.  (Contributed by Yury
     Selivanov.)

   * 他のスレッドからコルーチンをイベントループに送信するための新たな
     *note run_coroutine_threadsafe(): 84f. 関数。 (Contributed by
     Vincent Michel.)

   * New *note Transport.is_closing(): c46. method to check if the
     transport is closing or closed.  (Contributed by Yury Selivanov.)

   * The *note loop.create_server(): ae1. method can now accept a list
     of hosts.  (Contributed by Yann Sionneau.)

   * New *note loop.create_future(): c47. method to create Future
     objects.  This allows alternative event loop implementations, such
     as uvloop(2), to provide a faster *note asyncio.Future: b9b.
     implementation.  (Contributed by Yury Selivanov in bpo-27041(3).)

   * New *note loop.get_exception_handler(): c48. method to get the
     current exception handler.  (Contributed by Yury Selivanov in
     bpo-27040(4).)

   * 新しい *note StreamReader.readuntil(): 199. メソッドで、区切りとな
     るバイトの並びが出てくるまでストリームからデータを読み取れるように
     なりました。 (Contributed by Mark Korenberg.)

   * The performance of *note StreamReader.readexactly(): c49. has been
     improved.  (Contributed by Mark Korenberg in bpo-28370(5).)

   * The *note loop.getaddrinfo(): be2. method is optimized to avoid
     calling the system ‘getaddrinfo’ function if the address is already
     resolved.  (Contributed by A. Jesse Jiryu Davis.)

   * The *note loop.stop(): c4a. method has been changed to stop the
     loop immediately after the current iteration.  Any new callbacks
     scheduled as a result of the last iteration will be discarded.
     (Contributed by Guido van Rossum in bpo-25593(6).)

   * ‘Future.set_exception’ will now raise *note TypeError: 502. when
     passed an instance of the *note StopIteration: bc8. exception.
     (Contributed by Chris Angelico in bpo-26221(7).)

   * New *note loop.connect_accepted_socket(): ae8. method to be used by
     servers that accept connections outside of asyncio, but that use
     asyncio to handle them.  (Contributed by Jim Fulton in
     bpo-27392(8).)

   * ‘TCP_NODELAY’ flag is now set for all TCP transports by default.
     (Contributed by Yury Selivanov in bpo-27456(9).)

   * New *note loop.shutdown_asyncgens(): c4b. to properly close pending
     asynchronous generators before closing the loop.  (Contributed by
     Yury Selivanov in bpo-28003(10).)

   * *note Future: b9b. and *note Task: 4a5. classes now have an
     optimized C implementation which makes asyncio code up to 30%
     faster.  (Contributed by Yury Selivanov and INADA Naoki in
     bpo-26081(11) and bpo-28544(12).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28613

   (2) https://github.com/MagicStack/uvloop

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27041

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27040

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28370

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25593

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26221

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27392

   (9) https://bugs.python.org/issue?@action=redirect&bpo=27456

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28003

   (11) https://bugs.python.org/issue?@action=redirect&bpo=26081

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28544


File: python.info,  Node: binascii<2>,  Next: cmath,  Prev: asyncio<9>,  Up: 改良されたモジュール<6>

1.8.5.4 binascii
................

The *note b2a_base64(): c4d. function now accepts an optional 'newline'
keyword argument to control whether the newline character is appended to
the return value.  (Contributed by Victor Stinner in bpo-25357(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25357


File: python.info,  Node: cmath,  Next: collections<4>,  Prev: binascii<2>,  Up: 改良されたモジュール<6>

1.8.5.5 cmath
.............

The new *note cmath.tau: c4f. ('τ') constant has been added.
(Contributed by Lisa Roach in bpo-12345(1), see PEP 628(2) for details.)

新たに定数が追加されました。 *note math.inf: c50. と *note math.nan:
62f. に対応する *note cmath.inf: c51. と *note cmath.nan: c52.。複素数の
repr が使用する書式に対応する *note cmath.infj: c53. と *note
cmath.nanj: c54.。 (Contributed by Mark Dickinson in bpo-23229(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12345

   (2) https://peps.python.org/pep-0628/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23229


File: python.info,  Node: collections<4>,  Next: concurrent futures<4>,  Prev: cmath,  Up: 改良されたモジュール<6>

1.8.5.6 collections
...................

The new *note Collection: c56. abstract base class has been added to
represent sized iterable container classes.  (Contributed by Ivan
Levkivskyi, docs by Neil Girdhar in bpo-27598(1).)

The new *note Reversible: c57. abstract base class represents iterable
classes that also provide the ‘__reversed__()’ method.  (Contributed by
Ivan Levkivskyi in bpo-25987(2).)

The new *note AsyncGenerator: c58. abstract base class represents
asynchronous generators.  (Contributed by Yury Selivanov in
bpo-28720(3).)

The *note namedtuple(): 1ac. function now accepts an optional keyword
argument 'module', which, when specified, is used for the *note
__module__: 34d. attribute of the returned named tuple class.
(Contributed by Raymond Hettinger in bpo-17941(4).)

The 'verbose' and 'rename' arguments for *note namedtuple(): 1ac. are
now keyword-only.  (Contributed by Raymond Hettinger in bpo-25628(5).)

Recursive *note collections.deque: 5a6. instances can now be pickled.
(Contributed by Serhiy Storchaka in bpo-26482(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27598

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25987

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28720

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17941

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25628

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26482


File: python.info,  Node: concurrent futures<4>,  Next: contextlib<4>,  Prev: collections<4>,  Up: 改良されたモジュール<6>

1.8.5.7 concurrent.futures
..........................

The *note ThreadPoolExecutor: 70d. class constructor now accepts an
optional 'thread_name_prefix' argument to make it possible to customize
the names of the threads created by the pool.  (Contributed by Gregory
P.  Smith in bpo-27664(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27664


File: python.info,  Node: contextlib<4>,  Next: datetime<5>,  Prev: concurrent futures<4>,  Up: 改良されたモジュール<6>

1.8.5.8 contextlib
..................

The *note contextlib.AbstractContextManager: c5b. class has been added
to provide an abstract base class for context managers.  It provides a
sensible default implementation for ‘__enter__()’ which returns ‘self’
and leaves ‘__exit__()’ an abstract method.  A matching class has been
added to the *note typing: ed. module as *note typing.ContextManager:
c5c.  (Contributed by Brett Cannon in bpo-25609(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25609


File: python.info,  Node: datetime<5>,  Next: decimal<2>,  Prev: contextlib<4>,  Up: 改良されたモジュール<6>

1.8.5.9 datetime
................

The *note datetime: 1ae. and *note time: 1b0. classes have the new
‘fold’ attribute used to disambiguate local time when necessary.  Many
functions in the *note datetime: 28. have been updated to support local
time disambiguation.  See *note Local Time Disambiguation: c0a. section
for more information.  (Contributed by Alexander Belopolsky in
bpo-24773(1).)

The *note datetime.strftime(): c5e. and *note date.strftime(): c5f.
methods now support ISO 8601 date directives ‘%G’, ‘%u’ and ‘%V’.
(Contributed by Ashley Anderson in bpo-12006(2).)

The *note datetime.isoformat(): afe. function now accepts an optional
'timespec' argument that specifies the number of additional components
of the time value to include.  (Contributed by Alessandro Cucci and
Alexander Belopolsky in bpo-19475(3).)

The *note datetime.combine(): c60. now accepts an optional 'tzinfo'
argument.  (Contributed by Alexander Belopolsky in bpo-27661(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24773

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12006

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19475

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27661


File: python.info,  Node: decimal<2>,  Next: distutils<5>,  Prev: datetime<5>,  Up: 改良されたモジュール<6>

1.8.5.10 decimal
................

New *note Decimal.as_integer_ratio(): c62. method that returns a pair
‘(n, d)’ of integers that represent the given *note Decimal: 27d.
instance as a fraction, in lowest terms and with a positive denominator:

     >>> Decimal('-3.14').as_integer_ratio()
     (-157, 50)

(Contributed by Stefan Krah amd Mark Dickinson in bpo-25928(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25928


File: python.info,  Node: distutils<5>,  Next: email<2>,  Prev: decimal<2>,  Up: 改良されたモジュール<6>

1.8.5.11 distutils
..................

The ‘default_format’ attribute has been removed from
‘distutils.command.sdist.sdist’ and the ‘formats’ attribute defaults to
‘['gztar']’.  Although not anticipated, any code relying on the presence
of ‘default_format’ may need to be adapted.  See bpo-27819(1) for more
details.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27819


File: python.info,  Node: email<2>,  Next: エンコーディング<2>,  Prev: distutils<5>,  Up: 改良されたモジュール<6>

1.8.5.12 email
..............

The new email API, enabled via the 'policy' keyword to various
constructors, is no longer provisional.  The *note email: 32.
documentation has been reorganized and rewritten to focus on the new
API, while retaining the old documentation for the legacy API.
(Contributed by R. David Murray in bpo-24277(1).)

The *note email.mime: 3c. classes now all accept an optional 'policy'
keyword.  (Contributed by Berker Peksag in bpo-27331(2).)

The *note DecodedGenerator: c65. now supports the 'policy' keyword.

There is a new *note policy: 46. attribute, *note message_factory: c66,
that controls what class is used by default when the parser creates new
message objects.  For the *note email.policy.compat32: c67. policy this
is *note Message: 25d, for the new policies it is *note EmailMessage:
25c.  (Contributed by R. David Murray in bpo-20476(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24277

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27331

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20476


File: python.info,  Node: エンコーディング<2>,  Next: enum<6>,  Prev: email<2>,  Up: 改良されたモジュール<6>

1.8.5.13 エンコーディング
.........................

On Windows, added the ‘'oem'’ encoding to use ‘CP_OEMCP’, and the
‘'ansi'’ alias for the existing ‘'mbcs'’ encoding, which uses the
‘CP_ACP’ code page.  (Contributed by Steve Dower in bpo-27959(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27959


File: python.info,  Node: enum<6>,  Next: faulthandler<2>,  Prev: エンコーディング<2>,  Up: 改良されたモジュール<6>

1.8.5.14 enum
.............

Two new enumeration base classes have been added to the *note enum: 4c.
module: *note Flag: 5ef. and ‘IntFlags’.  Both are used to define
constants that can be combined using the bitwise operators.
(Contributed by Ethan Furman in bpo-23591(1).)

Many standard library modules have been updated to use the ‘IntFlags’
class for their constants.

The new *note enum.auto: c6a. value can be used to assign values to enum
members automatically:

     >>> from enum import Enum, auto
     >>> class Color(Enum):
     ...     red = auto()
     ...     blue = auto()
     ...     green = auto()
     ...
     >>> list(Color)
     [<Color.red: 1>, <Color.blue: 2>, <Color.green: 3>]

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23591


File: python.info,  Node: faulthandler<2>,  Next: fileinput<2>,  Prev: enum<6>,  Up: 改良されたモジュール<6>

1.8.5.15 faulthandler
.....................

On Windows, the *note faulthandler: 4e. module now installs a handler
for Windows exceptions: see *note faulthandler.enable(): c6c.
(Contributed by Victor Stinner in bpo-23848(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23848


File: python.info,  Node: fileinput<2>,  Next: hashlib<5>,  Prev: faulthandler<2>,  Up: 改良されたモジュール<6>

1.8.5.16 fileinput
..................

*note hook_encoded(): c6e. now supports the 'errors' argument.
(Contributed by Joseph Hackman in bpo-25788(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25788


File: python.info,  Node: hashlib<5>,  Next: http client<2>,  Prev: fileinput<2>,  Up: 改良されたモジュール<6>

1.8.5.17 hashlib
................

*note hashlib: 5e. supports OpenSSL 1.1.0.  The minimum recommend
version is 1.0.2.  (Contributed by Christian Heimes in bpo-26470(1).)

BLAKE2 hash functions were added to the module.  *note blake2b(): 60e.
and *note blake2s(): 60f. are always available and support the full
feature set of BLAKE2.  (Contributed by Christian Heimes in bpo-26798(2)
based on code by Dmitry Chestnykh and Samuel Neves.  Documentation
written by Dmitry Chestnykh.)

The SHA-3 hash functions *note sha3_224(): c70, *note sha3_256(): c71,
*note sha3_384(): c72, *note sha3_512(): c73, and SHAKE hash functions
*note shake_128(): c74. and *note shake_256(): c75. were added.
(Contributed by Christian Heimes in bpo-16113(3).  Keccak Code Package
by Guido Bertoni, Joan Daemen, Michaël Peeters, Gilles Van Assche, and
Ronny Van Keer.)

The password-based key derivation function *note scrypt(): c0c. is now
available with OpenSSL 1.1.0 and newer.  (Contributed by Christian
Heimes in bpo-27928(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26470

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26798

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16113

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27928


File: python.info,  Node: http client<2>,  Next: idlelib と IDLE<2>,  Prev: hashlib<5>,  Up: 改良されたモジュール<6>

1.8.5.18 http.client
....................

*note HTTPConnection.request(): c77. and *note endheaders(): c78. both
now support chunked encoding request bodies.  (Contributed by Demian
Brecht and Rolf Krahl in bpo-12319(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12319


File: python.info,  Node: idlelib と IDLE<2>,  Next: importlib<6>,  Prev: http client<2>,  Up: 改良されたモジュール<6>

1.8.5.19 idlelib と IDLE
........................

The idlelib package is being modernized and refactored to make IDLE look
and work better and to make the code easier to understand, test, and
improve.  Part of making IDLE look better, especially on Linux and Mac,
is using ttk widgets, mostly in the dialogs.  As a result, IDLE no
longer runs with tcl/tk 8.4.  It now requires tcl/tk 8.5 or 8.6.  We
recommend running the latest release of either.

'Modernizing' includes renaming and consolidation of idlelib modules.
The renaming of files with partial uppercase names is similar to the
renaming of, for instance, Tkinter and TkFont to tkinter and
tkinter.font in 3.0.  As a result, imports of idlelib files that worked
in 3.5 will usually not work in 3.6.  At least a module name change will
be needed (see idlelib/README.txt), sometimes more.  (Name changes
contributed by Al Swiegart and Terry Reedy in bpo-24225(1).  Most
idlelib patches since have been and will be part of the process.)

In compensation, the eventual result with be that some idlelib classes
will be easier to use, with better APIs and docstrings explaining them.
Additional useful information will be added to idlelib when available.

New in 3.6.2:

自動補完におけるいくつもの修正。 (Contributed by Louie Lu in
bpo-15786(2).)

New in 3.6.3:

Module Browser (on the File menu, formerly called Class Browser), now
displays nested functions and classes in addition to top-level functions
and classes.  (Contributed by Guilherme Polo, Cheryl Sabella, and Terry
Jan Reedy in bpo-1612262(3).)

The IDLE features formerly implemented as extensions have been
reimplemented as normal features.  Their settings have been moved from
the Extensions tab to other dialog tabs.  (Contributed by Charles
Wohlganger and Terry Jan Reedy in bpo-27099(4).)

The Settings dialog (Options, Configure IDLE) has been partly rewritten
to improve both appearance and function.  (Contributed by Cheryl Sabella
and Terry Jan Reedy in multiple issues.)

New in 3.6.4:

The font sample now includes a selection of non-Latin characters so that
users can better see the effect of selecting a particular font.
(Contributed by Terry Jan Reedy in bpo-13802(5).)  The sample can be
edited to include other characters.  (Contributed by Serhiy Storchaka in
bpo-31860(6).)

New in 3.6.6:

Editor code context option revised.  Box displays all context lines up
to maxlines.  Clicking on a context line jumps the editor to that line.
Context colors for custom themes is added to Highlights tab of Settings
dialog.  (Contributed by Cheryl Sabella and Terry Jan Reedy in
bpo-33642(7), bpo-33768(8), and bpo-33679(9).)

On Windows, a new API call tells Windows that tk scales for DPI. On
Windows 8.1+ or 10, with DPI compatibility properties of the Python
binary unchanged, and a monitor resolution greater than 96 DPI, this
should make text and lines sharper.  It should otherwise have no effect.
(Contributed by Terry Jan Reedy in bpo-33656(10).)

New in 3.6.7:

Output over N lines (50 by default) is squeezed down to a button.  N can
be changed in the PyShell section of the General page of the Settings
dialog.  Fewer, but possibly extra long, lines can be squeezed by right
clicking on the output.  Squeezed output can be expanded in place by
double-clicking the button or into the clipboard or a separate window by
right-clicking the button.  (Contributed by Tal Einat in
bpo-1529353(11).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24225

   (2) https://bugs.python.org/issue?@action=redirect&bpo=15786

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1612262

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27099

   (5) https://bugs.python.org/issue?@action=redirect&bpo=13802

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31860

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33642

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33768

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33679

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33656

   (11) https://bugs.python.org/issue?@action=redirect&bpo=1529353


File: python.info,  Node: importlib<6>,  Next: inspect<6>,  Prev: idlelib と IDLE<2>,  Up: 改良されたモジュール<6>

1.8.5.20 importlib
..................

Import now raises the new exception *note ModuleNotFoundError: b15.
(subclass of *note ImportError: 3f2.) when it cannot find a module.
Code that current checks for ‘ImportError’ (in try-except) will still
work.  (Contributed by Eric Snow in bpo-15767(1).)

*note importlib.util.LazyLoader: c7b. now calls *note create_module():
c7c. on the wrapped loader, removing the restriction that *note
importlib.machinery.BuiltinImporter: c7d. and *note
importlib.machinery.ExtensionFileLoader: c7e. couldn't be used with
*note importlib.util.LazyLoader: c7b.

*note importlib.util.cache_from_source(): 2d5, *note
importlib.util.source_from_cache(): 4e3, and *note
importlib.util.spec_from_file_location(): c7f. now accept a *note
path-like object: 280.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15767


File: python.info,  Node: inspect<6>,  Next: json,  Prev: importlib<6>,  Up: 改良されたモジュール<6>

1.8.5.21 inspect
................

The *note inspect.signature(): 703. function now reports the implicit
‘.0’ parameters generated by the compiler for comprehension and
generator expression scopes as if they were positional-only parameters
called ‘implicit0’.  (Contributed by Jelle Zijlstra in bpo-19611(1).)

To reduce code churn when upgrading from Python 2.7 and the legacy
‘inspect.getargspec()’ API, the previously documented deprecation of
*note inspect.getfullargspec(): 704. has been reversed.  While this
function is convenient for single/source Python 2/3 code bases, the
richer *note inspect.signature(): 703. interface remains the recommended
approach for new code.  (Contributed by Nick Coghlan in bpo-27172(2))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19611

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27172


File: python.info,  Node: json,  Next: logging<4>,  Prev: inspect<6>,  Up: 改良されたモジュール<6>

1.8.5.22 json
.............

*note json.load(): c82. と *note json.loads(): 923. は、バイナリ入力をサ
ポートしました。エンコード済みのJSON は、 UTF-8, UTF-16, UTF-32のいずれ
かを返すべきです。 (Contributed by Serhiy Storchaka in bpo-17909(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17909


File: python.info,  Node: logging<4>,  Next: math<7>,  Prev: json,  Up: 改良されたモジュール<6>

1.8.5.23 logging
................

新しく *note WatchedFileHandler.reopenIfNeeded(): c84. メソッドが追加さ
れ、ログファイルを再オープンする必要があるかどうかをチェックする機能が追
加れました。(Contributed by Marian Horban in bpo-24884(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24884


File: python.info,  Node: math<7>,  Next: multiprocessing<5>,  Prev: logging<4>,  Up: 改良されたモジュール<6>

1.8.5.24 math
.............

The tau ('τ') constant has been added to the *note math: 81. and *note
cmath: 11. modules.  (Contributed by Lisa Roach in bpo-12345(1), see PEP
628(2) for details.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12345

   (2) https://peps.python.org/pep-0628/


File: python.info,  Node: multiprocessing<5>,  Next: os<8>,  Prev: math<7>,  Up: 改良されたモジュール<6>

1.8.5.25 multiprocessing
........................

*note Proxy Objects: c87. returned by *note multiprocessing.Manager():
c88. can now be nested.  (Contributed by Davin Potts in bpo-6766(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6766


File: python.info,  Node: os<8>,  Next: pathlib<9>,  Prev: multiprocessing<5>,  Up: 改良されたモジュール<6>

1.8.5.26 os
...........

See the summary of *note PEP 519: c09. for details on how the *note os:
91. and *note os.path: 92. modules now support *note path-like objects:
280.

*note scandir(): a2d. now supports *note bytes: 1a4. paths on Windows.

A new *note close(): c8a. method allows explicitly closing a *note
scandir(): a2d. iterator.  The *note scandir(): a2d. iterator now
supports the *note context manager: 59e. protocol.  If a ‘scandir()’
iterator is neither exhausted nor explicitly closed a *note
ResourceWarning: 225. will be emitted in its destructor.  (Contributed
by Serhiy Storchaka in bpo-25994(1).)

On Linux, *note os.urandom(): 4ec. now blocks until the system urandom
entropy pool is initialized to increase the security.  See the PEP
524(2) for the rationale.

The Linux ‘getrandom()’ syscall (get random bytes) is now exposed as the
new *note os.getrandom(): c8b. function.  (Contributed by Victor
Stinner, part of the PEP 524(3))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25994

   (2) https://peps.python.org/pep-0524/

   (3) https://peps.python.org/pep-0524/


File: python.info,  Node: pathlib<9>,  Next: pdb<5>,  Prev: os<8>,  Up: 改良されたモジュール<6>

1.8.5.27 pathlib
................

*note pathlib: 93. は *note path-like objects: 280. をサポートしました。
(Contributed by Brett Cannon in bpo-27186(1).)

詳細は、 *note PEP 519: c09. の要約を参照してください。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27186


File: python.info,  Node: pdb<5>,  Next: pickle<2>,  Prev: pathlib<9>,  Up: 改良されたモジュール<6>

1.8.5.28 pdb
............

*note Pdb: 8f0. クラスのコンストラクタに、新しくオプション引数 'readrc'
が増えました。この引数は、 ‘.pdbrc’ ファイルを読み込むかどうかを指定しま
す。


File: python.info,  Node: pickle<2>,  Next: pickletools,  Prev: pdb<5>,  Up: 改良されたモジュール<6>

1.8.5.29 pickle
...............

Objects that need ‘__new__’ called with keyword arguments can now be
pickled using *note pickle protocols: c8f. older than protocol version
4.  Protocol version 4 already supports this case.  (Contributed by
Serhiy Storchaka in bpo-24164(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24164


File: python.info,  Node: pickletools,  Next: pydoc<3>,  Prev: pickle<2>,  Up: 改良されたモジュール<6>

1.8.5.30 pickletools
....................

*note pickletools.dis(): c91. now outputs the implicit memo index for
the ‘MEMOIZE’ opcode.  (Contributed by Serhiy Storchaka in
bpo-25382(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25382


File: python.info,  Node: pydoc<3>,  Next: random<4>,  Prev: pickletools,  Up: 改良されたモジュール<6>

1.8.5.31 pydoc
..............

The *note pydoc: a3. module has learned to respect the ‘MANPAGER’
environment variable.  (Contributed by Matthias Klose in bpo-8637(1).)

*note help(): 8a5. and *note pydoc: a3. can now list named tuple fields
in the order they were defined rather than alphabetically.  (Contributed
by Raymond Hettinger in bpo-24879(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8637

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24879


File: python.info,  Node: random<4>,  Next: re<5>,  Prev: pydoc<3>,  Up: 改良されたモジュール<6>

1.8.5.32 random
...............

The new *note choices(): c94. function returns a list of elements of
specified size from the given population with optional weights.
(Contributed by Raymond Hettinger in bpo-18844(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18844


File: python.info,  Node: re<5>,  Next: readline,  Prev: random<4>,  Up: 改良されたモジュール<6>

1.8.5.33 re
...........

Added support of modifier spans in regular expressions.  Examples:
‘'(?i:p)ython'’ matches ‘'python'’ and ‘'Python'’, but not ‘'PYTHON'’;
‘'(?i)g(?-i:v)r'’ matches ‘'GvR'’ and ‘'gvr'’, but not ‘'GVR'’.
(Contributed by Serhiy Storchaka in bpo-433028(1).)

Match object groups can be accessed by ‘__getitem__’, which is
equivalent to ‘group()’.  So ‘mo['name']’ is now equivalent to
‘mo.group('name')’.  (Contributed by Eric Smith in bpo-24454(2).)

*note Match: c96. objects now support *note index-like objects: 6e8. as
group indices.  (Contributed by Jeroen Demeyer and Xiang Zhang in
bpo-27177(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=433028

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24454

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27177


File: python.info,  Node: readline,  Next: rlcompleter,  Prev: re<5>,  Up: 改良されたモジュール<6>

1.8.5.34 readline
.................

Added *note set_auto_history(): c98. to enable or disable automatic
addition of input to the history list.  (Contributed by Tyler Crompton
in bpo-26870(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26870


File: python.info,  Node: rlcompleter,  Next: shlex<2>,  Prev: readline,  Up: 改良されたモジュール<6>

1.8.5.35 rlcompleter
....................

Private and special attribute names now are omitted unless the prefix
starts with underscores.  A space or a colon is added after some
completed keywords.  (Contributed by Serhiy Storchaka in bpo-25011(1)
and bpo-25209(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25011

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25209


File: python.info,  Node: shlex<2>,  Next: site<3>,  Prev: rlcompleter,  Up: 改良されたモジュール<6>

1.8.5.36 shlex
..............

The *note shlex: c9b. has much *note improved shell compatibility: c9c.
through the new 'punctuation_chars' argument to control which characters
are treated as punctuation.  (Contributed by Vinay Sajip in
bpo-1521950(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1521950


File: python.info,  Node: site<3>,  Next: sqlite3<7>,  Prev: shlex<2>,  Up: 改良されたモジュール<6>

1.8.5.37 site
.............

When specifying paths to add to *note sys.path: 38e. in a ‘.pth’ file,
you may now specify file paths on top of directories (e.g.  zip files).
(Contributed by Wolfgang Langner in bpo-26587(1)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26587


File: python.info,  Node: sqlite3<7>,  Next: socket<7>,  Prev: site<3>,  Up: 改良されたモジュール<6>

1.8.5.38 sqlite3
................

*note sqlite3.Cursor.lastrowid: c9f. は、 ‘REPLACE’ 文をサポートしました
。 (Contributed by Alex LordThorsen in bpo-16864(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16864


File: python.info,  Node: socket<7>,  Next: socketserver<2>,  Prev: sqlite3<7>,  Up: 改良されたモジュール<6>

1.8.5.39 socket
...............

The *note ioctl(): ca1. function now supports the *note
SIO_LOOPBACK_FAST_PATH: ca2. control code.  (Contributed by Daniel
Stokes in bpo-26536(1).)

The *note getsockopt(): ca3. constants ‘SO_DOMAIN’, ‘SO_PROTOCOL’,
‘SO_PEERSEC’, and ‘SO_PASSSEC’ are now supported.  (Contributed by
Christian Heimes in bpo-26907(2).)

The *note setsockopt(): ca4. now supports the ‘setsockopt(level,
optname, None, optlen: int)’ form.  (Contributed by Christian Heimes in
bpo-27744(3).)

The socket module now supports the address family *note AF_ALG: ca5. to
interface with Linux Kernel crypto API. ‘ALG_*’, ‘SOL_ALG’ and *note
sendmsg_afalg(): ca6. were added.  (Contributed by Christian Heimes in
bpo-27744(4) with support from Victor Stinner.)

New Linux constants ‘TCP_USER_TIMEOUT’ and ‘TCP_CONGESTION’ were added.
(Contributed by Omar Sandoval, bpo-26273(5)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26536

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26907

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27744

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27744

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26273


File: python.info,  Node: socketserver<2>,  Next: ssl<7>,  Prev: socket<7>,  Up: 改良されたモジュール<6>

1.8.5.40 socketserver
.....................

Servers based on the *note socketserver: b9. module, including those
defined in *note http.server: 68, *note xmlrpc.server: 115. and *note
wsgiref.simple_server: 103, now support the *note context manager: 59e.
protocol.  (Contributed by Aviv Palivoda in bpo-26404(1).)

The ‘wfile’ attribute of *note StreamRequestHandler: ca8. classes now
implements the *note io.BufferedIOBase: 660. writable interface.  In
particular, calling *note write(): ca9. is now guaranteed to send the
data in full.  (Contributed by Martin Panter in bpo-26721(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26404

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26721


File: python.info,  Node: ssl<7>,  Next: statistics<5>,  Prev: socketserver<2>,  Up: 改良されたモジュール<6>

1.8.5.41 ssl
............

*note ssl: bb. supports OpenSSL 1.1.0.  The minimum recommend version is
1.0.2.  (Contributed by Christian Heimes in bpo-26470(1).)

3DES has been removed from the default cipher suites and ChaCha20
Poly1305 cipher suites have been added.  (Contributed by Christian
Heimes in bpo-27850(2) and bpo-27766(3).)

*note SSLContext: 274. has better default configuration for options and
ciphers.  (Contributed by Christian Heimes in bpo-28043(4).)

SSL session can be copied from one client-side connection to another
with the new *note SSLSession: cab. class.  TLS session resumption can
speed up the initial handshake, reduce latency and improve performance
(Contributed by Christian Heimes in bpo-19500(5) based on a draft by
Alex Warhawk.)

The new *note get_ciphers(): cac. method can be used to get a list of
enabled ciphers in order of cipher priority.

All constants and flags have been converted to *note IntEnum: cad. and
‘IntFlags’.  (Contributed by Christian Heimes in bpo-28025(6).)

Server and client-side specific TLS protocols for *note SSLContext: 274.
were added.  (Contributed by Christian Heimes in bpo-28085(7).)

Added *note ssl.SSLContext.post_handshake_auth: 9ff. to enable and *note
ssl.SSLSocket.verify_client_post_handshake(): a00. to initiate TLS 1.3
post-handshake authentication.  (Contributed by Christian Heimes in
gh-78851(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26470

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27850

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27766

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28043

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19500

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28025

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28085

   (8) https://github.com/python/cpython/issues/78851


File: python.info,  Node: statistics<5>,  Next: struct,  Prev: ssl<7>,  Up: 改良されたモジュール<6>

1.8.5.42 statistics
...................

A new *note harmonic_mean(): caf. function has been added.  (Contributed
by Steven D'Aprano in bpo-27181(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27181


File: python.info,  Node: struct,  Next: subprocess<3>,  Prev: statistics<5>,  Up: 改良されたモジュール<6>

1.8.5.43 struct
...............

*note struct: c0. now supports IEEE 754 half-precision floats via the
‘'e'’ format specifier.  (Contributed by Eli Stevens, Mark Dickinson in
bpo-11734(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11734


File: python.info,  Node: subprocess<3>,  Next: sys<10>,  Prev: struct,  Up: 改良されたモジュール<6>

1.8.5.44 subprocess
...................

*note subprocess.Popen: 17e. destructor now emits a *note
ResourceWarning: 225. warning if the child process is still running.
Use the context manager protocol (‘with proc: ...’) or explicitly call
the *note wait(): cb2. method to read the exit status of the child
process.  (Contributed by Victor Stinner in bpo-26741(1).)

The *note subprocess.Popen: 17e. constructor and all functions that pass
arguments through to it now accept 'encoding' and 'errors' arguments.
Specifying either of these will enable text mode for the 'stdin',
'stdout' and 'stderr' streams.  (Contributed by Steve Dower in
bpo-6135(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26741

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6135


File: python.info,  Node: sys<10>,  Next: telnetlib,  Prev: subprocess<3>,  Up: 改良されたモジュール<6>

1.8.5.45 sys
............

The new *note getfilesystemencodeerrors(): cb4. function returns the
name of the error mode used to convert between Unicode filenames and
bytes filenames.  (Contributed by Steve Dower in bpo-27781(1).)

On Windows the return value of the *note getwindowsversion(): cb5.
function now includes the 'platform_version' field which contains the
accurate major version, minor version and build number of the current
operating system, rather than the version that is being emulated for the
process (Contributed by Steve Dower in bpo-27932(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27781

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27932


File: python.info,  Node: telnetlib,  Next: time<6>,  Prev: sys<10>,  Up: 改良されたモジュール<6>

1.8.5.46 telnetlib
..................

‘telnetlib.Telnet’ is now a context manager (contributed by Stéphane
Wirtel in bpo-25485(1)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25485


File: python.info,  Node: time<6>,  Next: timeit,  Prev: telnetlib,  Up: 改良されたモジュール<6>

1.8.5.47 time
.............

*note struct_time: cb8. の属性 ‘tm_gmtoff’ および ‘tm_zone’ が全てのプラ
ットフォームで利用できるようになりました。


File: python.info,  Node: timeit,  Next: tkinter<6>,  Prev: time<6>,  Up: 改良されたモジュール<6>

1.8.5.48 timeit
...............

The new *note Timer.autorange(): cba. convenience method has been added
to call *note Timer.timeit(): cbb. repeatedly so that the total run time
is greater or equal to 200 milliseconds.  (Contributed by Steven
D'Aprano in bpo-6422(1).)

*note timeit: d8. now warns when there is substantial (4x) variance
between best and worst times.  (Contributed by Serhiy Storchaka in
bpo-23552(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6422

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23552


File: python.info,  Node: tkinter<6>,  Next: traceback<4>,  Prev: timeit,  Up: 改良されたモジュール<6>

1.8.5.49 tkinter
................

Added methods ‘trace_add()’, ‘trace_remove()’ and ‘trace_info()’ in the
‘tkinter.Variable’ class.  They replace old methods ‘trace_variable()’,
‘trace()’, ‘trace_vdelete()’ and ‘trace_vinfo()’ that use obsolete Tcl
commands and might not work in future versions of Tcl.  (Contributed by
Serhiy Storchaka in bpo-22115(1)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22115


File: python.info,  Node: traceback<4>,  Next: tracemalloc<3>,  Prev: tkinter<6>,  Up: 改良されたモジュール<6>

1.8.5.50 traceback
..................

Both the traceback module and the interpreter's builtin exception
display now abbreviate long sequences of repeated lines in tracebacks as
shown in the following example:

     >>> def f(): f()
     ...
     >>> f()
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 1, in f
       File "<stdin>", line 1, in f
       File "<stdin>", line 1, in f
       [Previous line repeated 995 more times]
     RecursionError: maximum recursion depth exceeded

(Contributed by Emanuel Barry in bpo-26823(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26823


File: python.info,  Node: tracemalloc<3>,  Next: typing<9>,  Prev: traceback<4>,  Up: 改良されたモジュール<6>

1.8.5.51 tracemalloc
....................

The *note tracemalloc: e8. module now supports tracing memory
allocations in multiple different address spaces.

The new *note DomainFilter: cbf. filter class has been added to filter
block traces by their address space (domain).

(Contributed by Victor Stinner in bpo-26588(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26588


File: python.info,  Node: typing<9>,  Next: unicodedata<7>,  Prev: tracemalloc<3>,  Up: 改良されたモジュール<6>

1.8.5.52 typing
...............

Since the *note typing: ed. module is *note provisional: ad1, all
changes introduced in Python 3.6 have also been backported to Python
3.5.x.

The *note typing: ed. module has a much improved support for generic
type aliases.  For example ‘Dict[str, Tuple[S, T]]’ is now a valid type
annotation.  (Contributed by Guido van Rossum in Github #195(1).)

The *note typing.ContextManager: c5c. class has been added for
representing *note contextlib.AbstractContextManager: c5b.  (Contributed
by Brett Cannon in bpo-25609(2).)

The *note typing.Collection: cc1. class has been added for representing
*note collections.abc.Collection: c56.  (Contributed by Ivan Levkivskyi
in bpo-27598(3).)

The *note typing.ClassVar: 247. type construct has been added to mark
class variables.  As introduced in PEP 526(4), a variable annotation
wrapped in ClassVar indicates that a given attribute is intended to be
used as a class variable and should not be set on instances of that
class.  (Contributed by Ivan Levkivskyi in Github #280(5).)

A new *note TYPE_CHECKING: cc2. constant that is assumed to be ‘True’ by
the static type checkers, but is ‘False’ at runtime.  (Contributed by
Guido van Rossum in Github #230(6).)

A new *note NewType(): cc3. helper function has been added to create
lightweight distinct types for annotations:

     from typing import NewType

     UserId = NewType('UserId', int)
     some_id = UserId(524313)

The static type checker will treat the new type as if it were a subclass
of the original type.  (Contributed by Ivan Levkivskyi in Github
#189(7).)

   ---------- Footnotes ----------

   (1) https://github.com/python/typing/pull/195

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25609

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27598

   (4) https://peps.python.org/pep-0526/

   (5) https://github.com/python/typing/pull/280

   (6) https://github.com/python/typing/issues/230

   (7) https://github.com/python/typing/issues/189


File: python.info,  Node: unicodedata<7>,  Next: unittest mock<2>,  Prev: typing<9>,  Up: 改良されたモジュール<6>

1.8.5.53 unicodedata
....................

The *note unicodedata: ee. module now uses data from Unicode 9.0.0(1).
(Contributed by Benjamin Peterson.)

   ---------- Footnotes ----------

   (1) https://unicode.org/versions/Unicode9.0.0/


File: python.info,  Node: unittest mock<2>,  Next: urllib request,  Prev: unicodedata<7>,  Up: 改良されたモジュール<6>

1.8.5.54 unittest.mock
......................

*note Mock: a1a. クラスは、次の改善が行われました。

   * *note Mock.assert_called(): cc6. と *note
     Mock.assert_called_once(): cc7. は、mockオブジェクトが呼ばれたかど
     うかを確認します。 (Contributed by Amit Saha in bpo-26323(1).)

   * The *note Mock.reset_mock(): cc8. method now has two optional
     keyword only arguments: 'return_value' and 'side_effect'.
     (Contributed by Kushal Das in bpo-21271(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26323

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21271


File: python.info,  Node: urllib request,  Next: urllib robotparser,  Prev: unittest mock<2>,  Up: 改良されたモジュール<6>

1.8.5.55 urllib.request
.......................

If a HTTP request has a file or iterable body (other than a bytes
object) but no ‘Content-Length’ header, rather than throwing an error,
‘AbstractHTTPHandler’ now falls back to use chunked transfer encoding.
(Contributed by Demian Brecht and Rolf Krahl in bpo-12319(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12319


File: python.info,  Node: urllib robotparser,  Next: venv<5>,  Prev: urllib request,  Up: 改良されたモジュール<6>

1.8.5.56 urllib.robotparser
...........................

*note RobotFileParser: ccb. now supports the ‘Crawl-delay’ and
‘Request-rate’ extensions.  (Contributed by Nikolay Bogoychev in
bpo-16099(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16099


File: python.info,  Node: venv<5>,  Next: warnings<4>,  Prev: urllib robotparser,  Up: 改良されたモジュール<6>

1.8.5.57 venv
.............

‘venv は、新しいパラメータ `’-prompt'' を受け入れました。このパラメータ
は、 仮想環境を表すプリフィックスを指定します。 (Proposed by Łukasz
Balcerzak and ported to 3.6 by Stéphane Wirtel in bpo-22829(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22829


File: python.info,  Node: warnings<4>,  Next: winreg,  Prev: venv<5>,  Up: 改良されたモジュール<6>

1.8.5.58 warnings
.................

A new optional 'source' parameter has been added to the *note
warnings.warn_explicit(): cce. function: the destroyed object which
emitted a *note ResourceWarning: 225.  A 'source' attribute has also
been added to ‘warnings.WarningMessage’ (contributed by Victor Stinner
in bpo-26568(1) and bpo-26567(2)).

When a *note ResourceWarning: 225. warning is logged, the *note
tracemalloc: e8. module is now used to try to retrieve the traceback
where the destroyed object was allocated.

スクリプト ‘example.py’ での例:

     import warnings

     def func():
         return open(__file__)

     f = func()
     f = None

Output of the command ‘python3.6 -Wd -X tracemalloc=5 example.py’:

     example.py:7: ResourceWarning: unclosed file <_io.TextIOWrapper name='example.py' mode='r' encoding='UTF-8'>
       f = None
     Object allocated at (most recent call first):
       File "example.py", lineno 4
         return open(__file__)
       File "example.py", lineno 6
         f = func()

The "Object allocated at" traceback is new and is only displayed if
*note tracemalloc: e8. is tracing Python memory allocations and if the
*note warnings: fa. module was already imported.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26568

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26567


File: python.info,  Node: winreg,  Next: winsound,  Prev: warnings<4>,  Up: 改良されたモジュール<6>

1.8.5.59 winreg
...............

Added the 64-bit integer type *note REG_QWORD: cd0.  (Contributed by
Clement Rouault in bpo-23026(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23026


File: python.info,  Node: winsound,  Next: xmlrpc client,  Prev: winreg,  Up: 改良されたモジュール<6>

1.8.5.60 winsound
.................

Allowed keyword arguments to be passed to *note Beep: cd2, *note
MessageBeep: cd3, and *note PlaySound: cd4. (bpo-27982(1)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27982


File: python.info,  Node: xmlrpc client,  Next: zipfile<3>,  Prev: winsound,  Up: 改良されたモジュール<6>

1.8.5.61 xmlrpc.client
......................

The *note xmlrpc.client: 114. module now supports unmarshalling
additional data types used by the Apache XML-RPC implementation for
numerics and ‘None’.  (Contributed by Serhiy Storchaka in bpo-26885(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26885


File: python.info,  Node: zipfile<3>,  Next: zlib,  Prev: xmlrpc client,  Up: 改良されたモジュール<6>

1.8.5.62 zipfile
................

A new *note ZipInfo.from_file(): cd7. class method allows making a *note
ZipInfo: cd8. instance from a filesystem file.  A new *note
ZipInfo.is_dir(): cd9. method can be used to check if the *note ZipInfo:
cd8. instance represents a directory.  (Contributed by Thomas Kluyver in
bpo-26039(1).)

The *note ZipFile.open(): 3f4. method can now be used to write data into
a ZIP file, as well as for extracting data.  (Contributed by Thomas
Kluyver in bpo-26039(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26039

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26039


File: python.info,  Node: zlib,  Prev: zipfile<3>,  Up: 改良されたモジュール<6>

1.8.5.63 zlib
.............

The *note compress(): 60b. and *note decompress(): cdb. functions now
accept keyword arguments.  (Contributed by Aviv Palivoda in bpo-26243(1)
and Xiang Zhang in bpo-16764(2) respectively.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26243

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16764


File: python.info,  Node: 最適化<6>,  Next: ビルドならびに C API の変更<2>,  Prev: 改良されたモジュール<6>,  Up: What's New In Python 3 6

1.8.6 最適化
------------

   * The Python interpreter now uses a 16-bit wordcode instead of
     bytecode which made a number of opcode optimizations possible.
     (Contributed by Demur Rumed with input and reviews from Serhiy
     Storchaka and Victor Stinner in bpo-26647(1) and bpo-28050(2).)

   * The *note asyncio.Future: b9b. class now has an optimized C
     implementation.  (Contributed by Yury Selivanov and INADA Naoki in
     bpo-26081(3).)

   * The *note asyncio.Task: 4a5. class now has an optimized C
     implementation.  (Contributed by Yury Selivanov in bpo-28544(4).)

   * Various implementation improvements in the *note typing: ed. module
     (such as caching of generic types) allow up to 30 times performance
     improvements and reduced memory footprint.

   * The ASCII decoder is now up to 60 times as fast for error handlers
     ‘surrogateescape’, ‘ignore’ and ‘replace’ (Contributed by Victor
     Stinner in bpo-24870(5)).

   * The ASCII and the Latin1 encoders are now up to 3 times as fast for
     the error handler ‘surrogateescape’ (Contributed by Victor Stinner
     in bpo-25227(6)).

   * The UTF-8 encoder is now up to 75 times as fast for error handlers
     ‘ignore’, ‘replace’, ‘surrogateescape’, ‘surrogatepass’
     (Contributed by Victor Stinner in bpo-25267(7)).

   * The UTF-8 decoder is now up to 15 times as fast for error handlers
     ‘ignore’, ‘replace’ and ‘surrogateescape’ (Contributed by Victor
     Stinner in bpo-25301(8)).

   * ‘bytes % args’ is now up to 2 times faster.  (Contributed by Victor
     Stinner in bpo-25349(9)).

   * ‘bytearray % args’ is now between 2.5 and 5 times faster.
     (Contributed by Victor Stinner in bpo-25399(10)).

   * Optimize *note bytes.fromhex(): abd. and *note bytearray.fromhex():
     abe.: they are now between 2x and 3.5x faster.  (Contributed by
     Victor Stinner in bpo-25401(11)).

   * Optimize ‘bytes.replace(b'', b'.')’ and ‘bytearray.replace(b'',
     b'.')’: up to 80% faster.  (Contributed by Josh Snider in
     bpo-26574(12)).

   * Allocator functions of the *note PyMem_Malloc(): c33. domain (*note
     PYMEM_DOMAIN_MEM: c37.) now use the *note pymalloc memory
     allocator: cdd. instead of ‘malloc()’ function of the C library.
     The pymalloc allocator is optimized for objects smaller or equal to
     512 bytes with a short lifetime, and use ‘malloc()’ for larger
     memory blocks.  (Contributed by Victor Stinner in bpo-26249(13)).

   * *note pickle.load(): cde. and *note pickle.loads(): cdf. are now up
     to 10% faster when deserializing many small objects (Contributed by
     Victor Stinner in bpo-27056(14)).

   * Passing *note keyword arguments: ce0. to a function has an overhead
     in comparison with passing *note positional arguments: ce1.  Now in
     extension functions implemented with using Argument Clinic this
     overhead is significantly decreased.  (Contributed by Serhiy
     Storchaka in bpo-27574(15)).

   * Optimized *note glob(): 27f. and *note iglob(): 7d2. functions in
     the *note glob: 5a. module; they are now about 3-6 times faster.
     (Contributed by Serhiy Storchaka in bpo-25596(16)).

   * Optimized globbing in *note pathlib: 93. by using *note
     os.scandir(): a2d.; it is now about 1.5-4 times faster.
     (Contributed by Serhiy Storchaka in bpo-26032(17)).

   * *note xml.etree.ElementTree: 10c. parsing, iteration and deepcopy
     performance has been significantly improved.  (Contributed by
     Serhiy Storchaka in bpo-25638(18), bpo-25873(19), and
     bpo-25869(20).)

   * Creation of *note fractions.Fraction: 1c8. instances from floats
     and decimals is now 2 to 3 times faster.  (Contributed by Serhiy
     Storchaka in bpo-25971(21).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26647

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28050

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26081

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28544

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24870

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25227

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25267

   (8) https://bugs.python.org/issue?@action=redirect&bpo=25301

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25349

   (10) https://bugs.python.org/issue?@action=redirect&bpo=25399

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25401

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26574

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26249

   (14) https://bugs.python.org/issue?@action=redirect&bpo=27056

   (15) https://bugs.python.org/issue?@action=redirect&bpo=27574

   (16) https://bugs.python.org/issue?@action=redirect&bpo=25596

   (17) https://bugs.python.org/issue?@action=redirect&bpo=26032

   (18) https://bugs.python.org/issue?@action=redirect&bpo=25638

   (19) https://bugs.python.org/issue?@action=redirect&bpo=25873

   (20) https://bugs.python.org/issue?@action=redirect&bpo=25869

   (21) https://bugs.python.org/issue?@action=redirect&bpo=25971


File: python.info,  Node: ビルドならびに C API の変更<2>,  Next: その他の改善,  Prev: 最適化<6>,  Up: What's New In Python 3 6

1.8.7 ビルドならびに C API の変更
---------------------------------

   * Python now requires some C99 support in the toolchain to build.
     Most notably, Python now uses standard integer types and macros in
     place of custom macros like ‘PY_LONG_LONG’.  For more information,
     see PEP 7(1) and bpo-17884(2).

   * Cross-compiling CPython with the Android NDK and the Android API
     level set to 21 (Android 5.0 Lollipop) or greater runs
     successfully.  While Android is not yet a supported platform, the
     Python test suite runs on the Android emulator with only about 16
     tests failures.  See the Android meta-issue bpo-26865(3).

   * The ‘--enable-optimizations’ configure flag has been added.
     Turning it on will activate expensive optimizations like PGO.
     (Original patch by Alecsandru Patrascu of Intel in bpo-26359(4).)

   * The *note GIL: 12e. must now be held when allocator functions of
     *note PYMEM_DOMAIN_OBJ: c35. (ex: *note PyObject_Malloc(): c36.)
     and *note PYMEM_DOMAIN_MEM: c37. (ex: *note PyMem_Malloc(): c33.)
     domains are called.

   * New *note Py_FinalizeEx(): ce3. API which indicates if flushing
     buffered data failed.  (Contributed by Martin Panter in
     bpo-5319(5).)

   * *note PyArg_ParseTupleAndKeywords(): 35c. now supports *note
     positional-only parameters: a53.  Positional-only parameters are
     defined by empty names.  (Contributed by Serhiy Storchaka in
     bpo-26282(6)).

   * ‘PyTraceback_Print’ method now abbreviates long sequences of
     repeated lines as ‘"[Previous line repeated {count} more times]"’.
     (Contributed by Emanuel Barry in bpo-26823(7).)

   * The new *note PyErr_SetImportErrorSubclass(): ce4. function allows
     for specifying a subclass of *note ImportError: 3f2. to raise.
     (Contributed by Eric Snow in bpo-15767(8).)

   * The new *note PyErr_ResourceWarning(): ce5. function can be used to
     generate a *note ResourceWarning: 225. providing the source of the
     resource allocation.  (Contributed by Victor Stinner in
     bpo-26567(9).)

   * The new *note PyOS_FSPath(): ce6. function returns the file system
     representation of a *note path-like object: 280.  (Contributed by
     Brett Cannon in bpo-27186(10).)

   * The *note PyUnicode_FSConverter(): ce7. and *note
     PyUnicode_FSDecoder(): 543. functions will now accept *note
     path-like objects: 280.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0007/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17884

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26865

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26359

   (5) https://bugs.python.org/issue?@action=redirect&bpo=5319

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26282

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26823

   (8) https://bugs.python.org/issue?@action=redirect&bpo=15767

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26567

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27186


File: python.info,  Node: その他の改善,  Next: 非推奨<7>,  Prev: ビルドならびに C API の変更<2>,  Up: What's New In Python 3 6

1.8.8 その他の改善
------------------

   * *note -version: ce9. (短縮系: *note -V: 15d.) が2回与えられた場合、
     Python は *note sys.version: 15e. で詳細な情報を出力します。

          $ ./python -VV
          Python 3.6.0b4+ (3.6:223967b49e49+, Nov 21 2016, 20:55:04)
          [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]


File: python.info,  Node: 非推奨<7>,  Next: 削除<7>,  Prev: その他の改善,  Up: What's New In Python 3 6

1.8.9 非推奨
------------

* Menu:

* 新たなキーワード::
* 非推奨の Python 挙動::
* 非推奨の Python モジュール、関数、メソッド: 非推奨の Python モジュール、関数、メソッド<2>.
* xml: xml<6>.
* C API の非推奨の関数ならびに型: C API の非推奨の関数ならびに型<2>.
* 非推奨のビルドオプション::


File: python.info,  Node: 新たなキーワード,  Next: 非推奨の Python 挙動,  Up: 非推奨<7>

1.8.9.1 新たなキーワード
........................

‘async’ および ‘await’ を変数、クラス、関数、モジュール名として使用する
ことは推奨されません。‘async’ と ‘await’ は Python 3.5 で PEP 492(1) に
より導入され、Python 3.7 で正式にキーワードとなります。Python 3.6 から
‘async’ や ‘await’ を変数名に使用すると *note DeprecationWarning: 18a. が
出ます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0492/


File: python.info,  Node: 非推奨の Python 挙動,  Next: 非推奨の Python モジュール、関数、メソッド<2>,  Prev: 新たなキーワード,  Up: 非推奨<7>

1.8.9.2 非推奨の Python 挙動
............................

Raising the *note StopIteration: bc8. exception inside a generator will
now generate a *note DeprecationWarning: 18a, and will trigger a *note
RuntimeError: 17a. in Python 3.7.  See *note PEP 479; ジェネレータ内の
StopIteration の処理の変更: ced. for details.

The ‘__aiter__()’ method is now expected to return an asynchronous
iterator directly instead of returning an awaitable as previously.
Doing the former will trigger a *note DeprecationWarning: 18a.  Backward
compatibility will be removed in Python 3.7.  (Contributed by Yury
Selivanov in bpo-27243(1).)

A backslash-character pair that is not a valid escape sequence now
generates a *note DeprecationWarning: 18a.  Although this will
eventually become a *note SyntaxError: 172, that will not be for several
Python releases.  (Contributed by Emanuel Barry in bpo-27364(2).)

When performing a relative import, falling back on ‘__name__’ and
‘__path__’ from the calling module when ‘__spec__’ or ‘__package__’ are
not defined now raises an *note ImportWarning: 4c7.  (Contributed by
Rose Ames in bpo-25791(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27243

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27364

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25791


File: python.info,  Node: 非推奨の Python モジュール、関数、メソッド<2>,  Next: xml<6>,  Prev: 非推奨の Python 挙動,  Up: 非推奨<7>

1.8.9.3 非推奨の Python モジュール、関数、メソッド
..................................................

* Menu:

* asynchat::
* asyncore::
* dbm: dbm<4>.
* distutils: distutils<6>.
* grp::
* importlib: importlib<7>.
* os: os<9>.
* re: re<6>.
* ssl: ssl<8>.
* tkinter: tkinter<7>.
* venv: venv<6>.


File: python.info,  Node: asynchat,  Next: asyncore,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.4 asynchat
................

The ‘asynchat’ has been deprecated in favor of *note asyncio: 8.
(Contributed by Mariatta in bpo-25002(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25002


File: python.info,  Node: asyncore,  Next: dbm<4>,  Prev: asynchat,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.5 asyncore
................

The ‘asyncore’ has been deprecated in favor of *note asyncio: 8.
(Contributed by Mariatta in bpo-25002(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25002


File: python.info,  Node: dbm<4>,  Next: distutils<6>,  Prev: asyncore,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.6 dbm
...........

Unlike other *note dbm: 29. implementations, the *note dbm.dumb: 2a.
module creates databases with the ‘'rw'’ mode and allows modifying the
database opened with the ‘'r'’ mode.  This behavior is now deprecated
and will be removed in 3.8.  (Contributed by Serhiy Storchaka in
bpo-21708(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21708


File: python.info,  Node: distutils<6>,  Next: grp,  Prev: dbm<4>,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.7 distutils
.................

The undocumented ‘extra_path’ argument to the ‘distutils.Distribution’
constructor is now considered deprecated and will raise a warning if
set.  Support for this parameter will be removed in a future Python
release.  See bpo-27919(1) for details.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27919


File: python.info,  Node: grp,  Next: importlib<7>,  Prev: distutils<6>,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.8 grp
...........

*note getgrgid(): cf4. の非整数の引数のサポートは非推奨になりました。
(Contributed by Serhiy Storchaka in bpo-26129(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26129


File: python.info,  Node: importlib<7>,  Next: os<9>,  Prev: grp,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.9 importlib
.................

The *note importlib.machinery.SourceFileLoader.load_module(): cf6. and
*note importlib.machinery.SourcelessFileLoader.load_module(): cf7.
methods are now deprecated.  They were the only remaining
implementations of *note importlib.abc.Loader.load_module(): 835. in
*note importlib: 6b. that had not been deprecated in previous versions
of Python in favour of *note importlib.abc.Loader.exec_module(): 836.

The *note importlib.machinery.WindowsRegistryFinder: cf8. class is now
deprecated.  As of 3.6.0, it is still added to *note sys.meta_path: cf9.
by default (on Windows), but this may change in future releases.


File: python.info,  Node: os<9>,  Next: re<6>,  Prev: importlib<7>,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.10 os
...........

Undocumented support of general *note bytes-like objects: cfb. as paths
in *note os: 91. functions, *note compile(): 177. and similar functions
is now deprecated.  (Contributed by Serhiy Storchaka in bpo-25791(1) and
bpo-26754(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25791

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26754


File: python.info,  Node: re<6>,  Next: ssl<8>,  Prev: os<9>,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.11 re
...........

Support for inline flags ‘(?letters)’ in the middle of the regular
expression has been deprecated and will be removed in a future Python
version.  Flags at the start of a regular expression are still allowed.
(Contributed by Serhiy Storchaka in bpo-22493(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22493


File: python.info,  Node: ssl<8>,  Next: tkinter<7>,  Prev: re<6>,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.12 ssl
............

OpenSSLの0.9.8, 1.0.0 ,1.0.1 は非推奨となっており、長い間サポートされて
いません。将来的に *note ssl: bb. モジュールは、OpenSSLの1.0.2 もしくは
1.1.0が必須になります。

SSL-related arguments like ‘certfile’, ‘keyfile’ and ‘check_hostname’ in
*note ftplib: 54, *note http.client: 65, *note imaplib: 6a, *note
poplib: 9a, and *note smtplib: b7. have been deprecated in favor of
‘context’.  (Contributed by Christian Heimes in bpo-28022(1).)

A couple of protocols and functions of the *note ssl: bb. module are now
deprecated.  Some features will no longer be available in future
versions of OpenSSL. Other features are deprecated in favor of a
different API. (Contributed by Christian Heimes in bpo-28022(2) and
bpo-26470(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28022

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28022

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26470


File: python.info,  Node: tkinter<7>,  Next: venv<6>,  Prev: ssl<8>,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.13 tkinter
................

The ‘tkinter.tix’ module is now deprecated.  *note tkinter: d9. users
should use *note tkinter.ttk: e2. instead.


File: python.info,  Node: venv<6>,  Prev: tkinter<7>,  Up: 非推奨の Python モジュール、関数、メソッド<2>

1.8.9.14 venv
.............

The ‘pyvenv’ script has been deprecated in favour of ‘python3 -m venv’.
This prevents confusion as to what Python interpreter ‘pyvenv’ is
connected to and thus what Python interpreter will be used by the
virtual environment.  (Contributed by Brett Cannon in bpo-25154(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25154


File: python.info,  Node: xml<6>,  Next: C API の非推奨の関数ならびに型<2>,  Prev: 非推奨の Python モジュール、関数、メソッド<2>,  Up: 非推奨<7>

1.8.9.15 xml
............

   * As mitigation against DTD and external entity retrieval, the *note
     xml.dom.minidom: 109. and *note xml.sax: 110. modules no longer
     process external entities by default.  (Contributed by Christian
     Heimes in gh-61441(1).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/61441


File: python.info,  Node: C API の非推奨の関数ならびに型<2>,  Next: 非推奨のビルドオプション,  Prev: xml<6>,  Up: 非推奨<7>

1.8.9.16 C API の非推奨の関数ならびに型
.......................................

Undocumented functions ‘PyUnicode_AsEncodedObject()’,
‘PyUnicode_AsDecodedObject()’, ‘PyUnicode_AsEncodedUnicode()’ and
‘PyUnicode_AsDecodedUnicode()’ are deprecated now.  Use the *note
generic codec based API: d03. instead.


File: python.info,  Node: 非推奨のビルドオプション,  Prev: C API の非推奨の関数ならびに型<2>,  Up: 非推奨<7>

1.8.9.17 非推奨のビルドオプション
.................................

The ‘--with-system-ffi’ configure flag is now on by default on non-macOS
UNIX platforms.  It may be disabled by using ‘--without-system-ffi’, but
using the flag is deprecated and will not be accepted in Python 3.7.
macOS is unaffected by this change.  Note that many OS distributors
already use the ‘--with-system-ffi’ flag when building their system
Python.


File: python.info,  Node: 削除<7>,  Next: Python 3 6 への移植,  Prev: 非推奨<7>,  Up: What's New In Python 3 6

1.8.10 削除
-----------

* Menu:

* API と機能の削除: API と機能の削除<3>.


File: python.info,  Node: API と機能の削除<3>,  Up: 削除<7>

1.8.10.1 API と機能の削除
.........................

   * Unknown escapes consisting of ‘'\'’ and an ASCII letter in regular
     expressions will now cause an error.  In replacement templates for
     *note re.sub(): 283. they are still allowed, but deprecated.  The
     *note re.LOCALE: b3a. flag can now only be used with binary
     patterns.

   * ‘inspect.getmoduleinfo()’ was removed (was deprecated since CPython
     3.3).  *note inspect.getmodulename(): d07. should be used for
     obtaining the module name for a given path.  (Contributed by Yury
     Selivanov in bpo-13248(1).)

   * ‘traceback.Ignore’ class and ‘traceback.usage’,
     ‘traceback.modname’, ‘traceback.fullmodname’,
     ‘traceback.find_lines_from_code’, ‘traceback.find_lines’,
     ‘traceback.find_strings’, ‘traceback.find_executable_lines’ methods
     were removed from the *note traceback: e7. module.  They were
     undocumented methods deprecated since Python 3.2 and equivalent
     functionality is available from private methods.

   * The ‘tk_menuBar()’ and ‘tk_bindForTraversal()’ dummy methods in
     *note tkinter: d9. widget classes were removed (corresponding Tk
     commands were obsolete since Tk 4.0).

   * The *note open(): 3f4. method of the *note zipfile.ZipFile: 690.
     class no longer supports the ‘'U'’ mode (was deprecated since
     Python 3.4).  Use *note io.TextIOWrapper: 786. for reading
     compressed text files in *note universal newlines: d08. mode.

   * The undocumented ‘IN’, ‘CDROM’, ‘DLFCN’, ‘TYPES’, ‘CDIO’, and
     ‘STROPTS’ modules have been removed.  They had been available in
     the platform specific ‘Lib/plat-*/’ directories, but were
     chronically out of date, inconsistently available across platforms,
     and unmaintained.  The script that created these modules is still
     available in the source distribution at Tools/scripts/h2py.py(2).

   * 非推奨の ‘asynchat.fifo’ クラスは削除されました。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13248

   (2) 
https://github.com/python/cpython/blob/v3.6.15/Tools/scripts/h2py.py


File: python.info,  Node: Python 3 6 への移植,  Next: Notable changes in Python 3 6 2,  Prev: 削除<7>,  Up: What's New In Python 3 6

1.8.11 Python 3.6 への移植
--------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* 'python' コマンドの挙動の変更::
* Python API の変更: Python API の変更<6>.
* C API の変更: C API の変更<9>.
* CPython バイトコードの変更: CPython バイトコードの変更<6>.


File: python.info,  Node: 'python' コマンドの挙動の変更,  Next: Python API の変更<6>,  Up: Python 3 6 への移植

1.8.11.1 'python' コマンドの挙動の変更
......................................

   * The output of a special Python build with defined ‘COUNT_ALLOCS’,
     ‘SHOW_ALLOC_COUNT’ or ‘SHOW_TRACK_COUNT’ macros is now off by
     default.  It can be re-enabled using the ‘-X showalloccount’
     option.  It now outputs to ‘stderr’ instead of ‘stdout’.
     (Contributed by Serhiy Storchaka in bpo-23034(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23034


File: python.info,  Node: Python API の変更<6>,  Next: C API の変更<9>,  Prev: 'python' コマンドの挙動の変更,  Up: Python 3 6 への移植

1.8.11.2 Python API の変更
..........................

   * *note open(): 4e5. will no longer allow combining the ‘'U'’ mode
     flag with ‘'+'’.  (Contributed by Jeff Balogh and John O'Connor in
     bpo-2091(1).)

   * *note sqlite3: ba. no longer implicitly commits an open transaction
     before DDL statements.

   * On Linux, *note os.urandom(): 4ec. now blocks until the system
     urandom entropy pool is initialized to increase the security.

   * When *note importlib.abc.Loader.exec_module(): 836. is defined,
     *note importlib.abc.Loader.create_module(): c7c. must also be
     defined.

   * *note PyErr_SetImportError(): d0c. now sets *note TypeError: 502.
     when its 'msg' argument is not set.  Previously only ‘NULL’ was
     returned.

   * The format of the *note co_lnotab: 2c1. attribute of code objects
     changed to support a negative line number delta.  By default,
     Python does not emit bytecode with a negative line number delta.
     Functions using *note frame.f_lineno: 777,
     ‘PyFrame_GetLineNumber()’ or ‘PyCode_Addr2Line()’ are not affected.
     Functions directly decoding ‘co_lnotab’ should be updated to use a
     signed 8-bit integer type for the line number delta, but this is
     only required to support applications using a negative line number
     delta.  See ‘Objects/lnotab_notes.txt’ for the ‘co_lnotab’ format
     and how to decode it, and see the PEP 511(2) for the rationale.

   * The functions in the *note compileall: 19. module now return
     booleans instead of ‘1’ or ‘0’ to represent success or failure,
     respectively.  Thanks to booleans being a subclass of integers,
     this should only be an issue if you were doing identity checks for
     ‘1’ or ‘0’.  See bpo-25768(3).

   * Reading the ‘port’ attribute of *note urllib.parse.urlsplit(): d0d.
     and *note urlparse(): 2e5. results now raises *note ValueError:
     1e3. for out-of-range values, rather than returning *note None:
     641.  See bpo-20059(4).

   * The ‘imp’ module now raises a *note DeprecationWarning: 18a.
     instead of *note PendingDeprecationWarning: 895.

   * The following modules have had missing APIs added to their
     ‘__all__’ attributes to match the documented APIs: *note calendar:
     10, ‘cgi’, *note csv: 21, *note ElementTree: 10c, *note enum: 4c,
     *note fileinput: 51, *note ftplib: 54, *note logging: 7b, *note
     mailbox: 7f, *note mimetypes: 82, *note optparse: 90, *note
     plistlib: 99, ‘smtpd’, *note subprocess: c1, *note tarfile: c8,
     *note threading: d6. and *note wave: fb.  This means they will
     export new symbols when ‘import *’ is used.  (Contributed by Joel
     Taddei and Jacek Kołodziej in bpo-23883(5).)

   * When performing a relative import, if ‘__package__’ does not
     compare equal to ‘__spec__.parent’ then *note ImportWarning: 4c7.
     is raised.  (Contributed by Brett Cannon in bpo-25791(6).)

   * When a relative import is performed and no parent package is known,
     then *note ImportError: 3f2. will be raised.  Previously, *note
     SystemError: 541. could be raised.  (Contributed by Brett Cannon in
     bpo-18018(7).)

   * Servers based on the *note socketserver: b9. module, including
     those defined in *note http.server: 68, *note xmlrpc.server: 115.
     and *note wsgiref.simple_server: 103, now only catch exceptions
     derived from *note Exception: 9a7.  Therefore if a request handler
     raises an exception like *note SystemExit: d0e. or *note
     KeyboardInterrupt: 99f, *note handle_error(): d0f. is no longer
     called, and the exception will stop a single-threaded server.
     (Contributed by Martin Panter in bpo-23430(8).)

   * ‘spwd.getspnam()’ now raises a *note PermissionError: d10. instead
     of *note KeyError: 31d. if the user doesn't have privileges.

   * The *note socket.socket.close(): d11. method now raises an
     exception if an error (e.g.  ‘EBADF’) was reported by the
     underlying system call.  (Contributed by Martin Panter in
     bpo-26685(9).)

   * The 'decode_data' argument for the ‘smtpd.SMTPChannel’ and
     ‘smtpd.SMTPServer’ constructors is now ‘False’ by default.  This
     means that the argument passed to ‘process_message()’ is now a
     bytes object by default, and ‘process_message()’ will be passed
     keyword arguments.  Code that has already been updated in
     accordance with the deprecation warning generated by 3.5 will not
     be affected.

   * All optional arguments of the *note dump(): d12, *note dumps():
     d13, *note load(): c82. and *note loads(): 923. functions and *note
     JSONEncoder: d14. and *note JSONDecoder: d15. class constructors in
     the *note json: 76. module are now *note keyword-only: 285.
     (Contributed by Serhiy Storchaka in bpo-18726(10).)

   * ‘type.__new__’ をオーバーライドしていない *note type: d16. のサブク
     ラスは、オブジェクトの型を得るのに１引数形式を利用することができま
     せん。

   * As part of PEP 487(11), the handling of keyword arguments passed to
     *note type: d16. (other than the metaclass hint, ‘metaclass’) is
     now consistently delegated to *note object.__init_subclass__():
     5fd.  This means that ‘type.__new__()’ and ‘type.__init__()’ both
     now accept arbitrary keyword arguments, but *note
     object.__init_subclass__(): 5fd. (which is called from
     ‘type.__new__()’) will reject them by default.  Custom metaclasses
     accepting additional keyword arguments will need to adjust their
     calls to ‘type.__new__()’ (whether direct or via *note super: 4a8.)
     accordingly.

   * In ‘distutils.command.sdist.sdist’, the ‘default_format’ attribute
     has been removed and is no longer honored.  Instead, the gzipped
     tarfile format is the default on all platforms and no
     platform-specific selection is made.  In environments where
     distributions are built on Windows and zip distributions are
     required, configure the project with a ‘setup.cfg’ file containing
     the following:

          [sdist]
          formats=zip

     この挙動は Setuptools 26.0.0 により以前の Python バージョンにバック
     ポートされました。

   * In the *note urllib.request: f4. module and the *note
     http.client.HTTPConnection.request(): c77. method, if no
     Content-Length header field has been specified and the request body
     is a file object, it is now sent with HTTP 1.1 chunked encoding.
     If a file object has to be sent to a HTTP 1.0 server, the
     Content-Length value now has to be specified by the caller.
     (Contributed by Demian Brecht and Rolf Krahl with tweaks from
     Martin Panter in bpo-12319(12).)

   * The *note DictReader: 9b3. now returns rows of type *note
     OrderedDict: 5a5.  (Contributed by Steve Holden in bpo-27842(13).)

   * The ‘crypt.METHOD_CRYPT’ will no longer be added to ‘crypt.methods’
     if unsupported by the platform.  (Contributed by Victor Stinner in
     bpo-25287(14).)

   * The 'verbose' and 'rename' arguments for *note namedtuple(): 1ac.
     are now keyword-only.  (Contributed by Raymond Hettinger in
     bpo-25628(15).)

   * On Linux, *note ctypes.util.find_library(): d17. now looks in
     ‘LD_LIBRARY_PATH’ for shared libraries.  (Contributed by Vinay
     Sajip in bpo-9998(16).)

   * The *note imaplib.IMAP4: 8d1. class now handles flags containing
     the ‘']'’ character in messages sent from the server to improve
     real-world compatibility.  (Contributed by Lita Cho in
     bpo-21815(17).)

   * The ‘mmap.write()’ function now returns the number of bytes written
     like other write methods.  (Contributed by Jakub Stasiak in
     bpo-26335(18).)

   * The *note pkgutil.iter_modules(): d18. and *note
     pkgutil.walk_packages(): bcd. functions now return *note
     ModuleInfo: d19. named tuples.  (Contributed by Ramchandra Apte in
     bpo-17211(19).)

   * *note re.sub(): 283. now raises an error for invalid numerical
     group references in replacement templates even if the pattern is
     not found in the string.  The error message for invalid group
     references now includes the group index and the position of the
     reference.  (Contributed by SilentGhost, Serhiy Storchaka in
     bpo-25953(20).)

   * *note zipfile.ZipFile: 690. will now raise *note
     NotImplementedError: 209. for unrecognized compression values.
     Previously a plain *note RuntimeError: 17a. was raised.
     Additionally, calling *note ZipFile: 690. methods on a closed
     ZipFile or calling the *note write(): d1a. method on a ZipFile
     created with mode ‘'r'’ will raise a *note ValueError: 1e3.
     Previously, a *note RuntimeError: 17a. was raised in those
     scenarios.

   * when custom metaclasses are combined with zero-argument *note
     super(): 4a8. or direct references from methods to the implicit
     ‘__class__’ closure variable, the implicit ‘__classcell__’
     namespace entry must now be passed up to ‘type.__new__’ for
     initialisation.  Failing to do so will result in a *note
     DeprecationWarning: 18a. in Python 3.6 and a *note RuntimeError:
     17a. in Python 3.8.

   * With the introduction of *note ModuleNotFoundError: b15, import
     system consumers may start expecting import system replacements to
     raise that more specific exception when appropriate, rather than
     the less-specific *note ImportError: 3f2.  To provide future
     compatibility with such consumers, implementers of alternative
     import systems that completely replace *note __import__(): 8a2.
     will need to update their implementations to raise the new subclass
     when a module can't be found at all.  Implementers of compliant
     plugins to the default import system shouldn't need to make any
     changes, as the default import system will raise the new subclass
     when appropriate.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2091

   (2) https://peps.python.org/pep-0511/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25768

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20059

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23883

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25791

   (7) https://bugs.python.org/issue?@action=redirect&bpo=18018

   (8) https://bugs.python.org/issue?@action=redirect&bpo=23430

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26685

   (10) https://bugs.python.org/issue?@action=redirect&bpo=18726

   (11) https://peps.python.org/pep-0487/

   (12) https://bugs.python.org/issue?@action=redirect&bpo=12319

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27842

   (14) https://bugs.python.org/issue?@action=redirect&bpo=25287

   (15) https://bugs.python.org/issue?@action=redirect&bpo=25628

   (16) https://bugs.python.org/issue?@action=redirect&bpo=9998

   (17) https://bugs.python.org/issue?@action=redirect&bpo=21815

   (18) https://bugs.python.org/issue?@action=redirect&bpo=26335

   (19) https://bugs.python.org/issue?@action=redirect&bpo=17211

   (20) https://bugs.python.org/issue?@action=redirect&bpo=25953


File: python.info,  Node: C API の変更<9>,  Next: CPython バイトコードの変更<6>,  Prev: Python API の変更<6>,  Up: Python 3 6 への移植

1.8.11.3 C API の変更
.....................

   * The *note PyMem_Malloc(): c33. allocator family now uses the *note
     pymalloc allocator: cdd. rather than the system ‘malloc()’.
     Applications calling *note PyMem_Malloc(): c33. without holding the
     GIL can now crash.  Set the *note PYTHONMALLOC: c32. environment
     variable to ‘debug’ to validate the usage of memory allocators in
     your application.  See bpo-26249(1).

   * *note Py_Exit(): d1c. (and the main interpreter) now override the
     exit status with 120 if flushing buffered data failed.  See
     bpo-5319(2).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26249

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5319


File: python.info,  Node: CPython バイトコードの変更<6>,  Prev: C API の変更<9>,  Up: Python 3 6 への移植

1.8.11.4 CPython バイトコードの変更
...................................

There have been several major changes to the *note bytecode: 16c. in
Python 3.6.

   * The Python interpreter now uses a 16-bit wordcode instead of
     bytecode.  (Contributed by Demur Rumed with input and reviews from
     Serhiy Storchaka and Victor Stinner in bpo-26647(1) and
     bpo-28050(2).)

   * The new ‘FORMAT_VALUE’ and *note BUILD_STRING: d1e. opcodes as part
     of the *note formatted string literal: bfd. implementation.
     (Contributed by Eric Smith in bpo-25483(3) and Serhiy Storchaka in
     bpo-27078(4).)

   * The new *note BUILD_CONST_KEY_MAP: d1f. opcode to optimize the
     creation of dictionaries with constant keys.  (Contributed by
     Serhiy Storchaka in bpo-27140(5).)

   * The function call opcodes have been heavily reworked for better
     performance and simpler implementation.  The *note MAKE_FUNCTION:
     d20, ‘CALL_FUNCTION’, ‘CALL_FUNCTION_KW’ and
     ‘BUILD_MAP_UNPACK_WITH_CALL’ opcodes have been modified, the new
     *note CALL_FUNCTION_EX: d21. and ‘BUILD_TUPLE_UNPACK_WITH_CALL’
     have been added, and ‘CALL_FUNCTION_VAR’, ‘CALL_FUNCTION_VAR_KW’
     and ‘MAKE_CLOSURE’ opcodes have been removed.  (Contributed by
     Demur Rumed in bpo-27095(6), and Serhiy Storchaka in bpo-27213(7),
     bpo-28257(8).)

   * The new *note SETUP_ANNOTATIONS: d22. and ‘STORE_ANNOTATION’
     opcodes have been added to support the new *note variable
     annotation: d23. syntax.  (Contributed by Ivan Levkivskyi in
     bpo-27985(9).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26647

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28050

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25483

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27078

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27140

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27095

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27213

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28257

   (9) https://bugs.python.org/issue?@action=redirect&bpo=27985


File: python.info,  Node: Notable changes in Python 3 6 2,  Next: Notable changes in Python 3 6 4,  Prev: Python 3 6 への移植,  Up: What's New In Python 3 6

1.8.12 Notable changes in Python 3.6.2
--------------------------------------

* Menu:

* New make regen-all build target::
* Removal of make touch build target::


File: python.info,  Node: New make regen-all build target,  Next: Removal of make touch build target,  Up: Notable changes in Python 3 6 2

1.8.12.1 New ‘make regen-all’ build target
..........................................

To simplify cross-compilation, and to ensure that CPython can reliably
be compiled without requiring an existing version of Python to already
be available, the autotools-based build system no longer attempts to
implicitly recompile generated files based on file modification times.

Instead, a new ‘make regen-all’ command has been added to force
regeneration of these files when desired (e.g.  after an initial version
of Python has already been built based on the pregenerated versions).

More selective regeneration targets are also defined - see
Makefile.pre.in(1) for details.

(Victor Stinner の貢献による bpo-23404(2))

Added in version 3.6.2.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Makefile.pre.in

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23404


File: python.info,  Node: Removal of make touch build target,  Prev: New make regen-all build target,  Up: Notable changes in Python 3 6 2

1.8.12.2 Removal of ‘make touch’ build target
.............................................

The ‘make touch’ build target previously used to request implicit
regeneration of generated files by updating their modification times has
been removed.

It has been replaced by the new ‘make regen-all’ target.

(Victor Stinner の貢献による bpo-23404(1))

バージョン 3.6.2 で変更.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23404


File: python.info,  Node: Notable changes in Python 3 6 4,  Next: Notable changes in Python 3 6 5,  Prev: Notable changes in Python 3 6 2,  Up: What's New In Python 3 6

1.8.13 Notable changes in Python 3.6.4
--------------------------------------

The ‘PyExc_RecursionErrorInst’ singleton that was part of the public API
has been removed as its members being never cleared may cause a segfault
during finalization of the interpreter.  (Contributed by Xavier de Gaye
in bpo-22898(1) and bpo-30697(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22898

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30697


File: python.info,  Node: Notable changes in Python 3 6 5,  Next: Notable changes in Python 3 6 7,  Prev: Notable changes in Python 3 6 4,  Up: What's New In Python 3 6

1.8.14 Notable changes in Python 3.6.5
--------------------------------------

The *note locale.localeconv(): bcc. function now sets temporarily the
‘LC_CTYPE’ locale to the ‘LC_NUMERIC’ locale in some cases.
(Contributed by Victor Stinner in bpo-31900(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31900


File: python.info,  Node: Notable changes in Python 3 6 7,  Next: Notable changes in Python 3 6 10,  Prev: Notable changes in Python 3 6 5,  Up: What's New In Python 3 6

1.8.15 Notable changes in Python 3.6.7
--------------------------------------

*note xml.dom.minidom: 109. and *note xml.sax: 110. modules no longer
process external entities by default.  See also gh-61441(1).

In 3.6.7 the *note tokenize: e4. module now implicitly emits a ‘NEWLINE’
token when provided with input that does not have a trailing new line.
This behavior now matches what the C tokenizer does internally.
(Contributed by Ammar Askar in bpo-33899(2).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/61441

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33899


File: python.info,  Node: Notable changes in Python 3 6 10,  Next: Notable changes in Python 3 6 13,  Prev: Notable changes in Python 3 6 7,  Up: What's New In Python 3 6

1.8.16 Notable changes in Python 3.6.10
---------------------------------------

セキュリティ上の重大な懸念により、*note
asyncio.loop.create_datagram_endpoint(): 6fe. での 'reuse_address' 引数
は無効になりました。これはソケットオプション ‘SO_REUSEADDR'’ のUDP にお
ける挙動が原因です。詳しくは、‘loop.create_datagram_endpoint()’ のドキュ
メントを参照してください。(Kyle Stanley, Antoine Pitrou, Yury Selivanov
による貢献 bpo-37228(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37228


File: python.info,  Node: Notable changes in Python 3 6 13,  Next: Notable changes in Python 3 6 14,  Prev: Notable changes in Python 3 6 10,  Up: What's New In Python 3 6

1.8.17 Notable changes in Python 3.6.13
---------------------------------------

Earlier Python versions allowed using both ‘;’ and ‘&’ as query
parameter separators in *note urllib.parse.parse_qs(): 25b. and *note
urllib.parse.parse_qsl(): 25a.  Due to security concerns, and to conform
with newer W3C recommendations, this has been changed to allow only a
single separator key, with ‘&’ as the default.  This change also affects
‘cgi.parse()’ and ‘cgi.parse_multipart()’ as they use the affected
functions internally.  For more details, please see their respective
documentation.  (Contributed by Adam Goldschmidt, Senthil Kumaran and
Ken Jin in bpo-42967(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42967


File: python.info,  Node: Notable changes in Python 3 6 14,  Prev: Notable changes in Python 3 6 13,  Up: What's New In Python 3 6

1.8.18 Notable changes in Python 3.6.14
---------------------------------------

A security fix alters the *note ftplib.FTP: 8c8. behavior to not trust
the IPv4 address sent from the remote server when setting up a passive
data channel.  We reuse the ftp server IP address instead.  For unusual
code requiring the old behavior, set a ‘trust_server_pasv_ipv4_address’
attribute on your FTP instance to ‘True’.  (See gh-87451(1))

The presence of newline or tab characters in parts of a URL allows for
some forms of attacks.  Following the WHATWG specification that updates
RFC 3986, ASCII newline ‘\n’, ‘\r’ and tab ‘\t’ characters are stripped
from the URL by the parser *note urllib.parse(): f3. preventing such
attacks.  The removal characters are controlled by a new module level
variable ‘urllib.parse._UNSAFE_URL_BYTES_TO_REMOVE’.  (See gh-88048(2))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/87451

   (2) https://github.com/python/cpython/issues/88048


File: python.info,  Node: What's New In Python 3 5,  Next: What's New In Python 3 4,  Prev: What's New In Python 3 6,  Up: What's New in Python

1.9 What's New In Python 3.5
============================


エディタ: Elvis Pranskevichus <<elvis@magic.io>>, Yury Selivanov
<<yury@magic.io>>

この記事では 3.4 と比較した Python 3.5 の新機能を解説します。 Python 3.5
は2015年9月13日にリリースされました。 全詳細については 変更履歴(1) をご
覧ください。

参考
....

PEP 478(2) - Python 3.5 リリーススケジュール

* Menu:

* 概要: 概要 -- リリースハイライト<7>. リリースハイライト
* 新しい機能: 新しい機能<10>.
* その他の言語変更: その他の言語変更<7>.
* 新たなモジュール: 新たなモジュール<7>.
* 改良されたモジュール: 改良されたモジュール<7>.
* その他のモジュールレベルの変更::
* 最適化: 最適化<7>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<3>.
* 非推奨: 非推奨<8>.
* 削除: 削除<8>.
* Python 3.5 への移植: Python 3 5 への移植.
* Notable changes in Python 3.5.4: Notable changes in Python 3 5 4.

   ---------- Footnotes ----------

   (1) https://docs.python.org/3.5/whatsnew/changelog.html

   (2) https://peps.python.org/pep-0478/


File: python.info,  Node: 概要 -- リリースハイライト<7>,  Next: 新しい機能<10>,  Up: What's New In Python 3 5

1.9.1 概要 - リリースハイライト
-------------------------------

新たな文法機能:

   * *note PEP 492: d30.、コルーチン、async 構文と await 構文。

   * *note PEP 465: d31.、新たな行列乗算演算子 ‘a @ b’。

   * *note PEP 448: d32.、追加可能なアンパックへの一般化。

新たなライブラリモジュール:

   * *note typing: ed.: *note PEP 484 - 型ヒント: d33.。

   * *note zipapp: 116.: *note PEP 441 Python ZIP
     アプリケーションのサポートの改善: d34.。

新たな組み込み機能:

   * ‘bytes % args’, ‘bytearray % args’: *note PEP 461: d35. - bytes と
     bytearray に ‘%’ 書式化を追加。

   * 新たな *note bytes.hex(): d36, *note bytearray.hex(): d37. *note
     memoryview.hex(): d38. メソッド。 (Contributed by Arnon Yaari in
     bpo-9951(1).)

   * *note memoryview: 435. クラスが、(複数次元の場合を含んだ) タプルの
     添字をサポートするようになりました。 (bpo-23632(2) におけるAntoine
     Pitrouによる貢献です。)

   * ジェネレータに ‘gi_yieldfrom’ 属性が新しく追加され、これは ‘yield
     from’ 式で反復処理されるオブジェクトを返します。 (Contributed by
     Benno Leslie and Yury Selivanov in bpo-24450(3).)

   * 新たな例外 *note RecursionError: d39. が最長再帰深度に到達した際に
     送出されるようになりました。 (Contributed by Georg Brandl in
     bpo-19235(4).)

CPython の実装の改善:

   * ‘LC_TYPE’ ロケールが POSIX ロケール (‘C’ ロケール) のとき、 *note
     sys.stdin: 507. および *note sys.stdout: aa4. は ‘strict’ エラーハ
     ンドラではなく ‘surrogateescape’ を使うようになりました。
     (Contributed by Victor Stinner in bpo-19977(5).)

   * ‘.pyo’ ファイルは使われなくなり、‘.pyc’ ファイル名に最適化レベルが
     明示される、より柔軟な仕組みに置き換えられました。(*note PEP 488
     の概要: d3a. を参照してください。)

   * 組み込みおよび拡張モジュールが多段階で初期化されるようになりました
     。これは Python モジュールのロード方法と同じです。 (*note PEP 489
     の概要: d3b. を参照してください。)

標準ライブラリーの顕著な改善

   * *note collections.OrderedDict: 5a5. が *note C で実装されました:
     d3c.。 これにより 4 倍から 100 倍高速になりました。

   * *note ssl: bb. モジュールに *note メモリ BIO サポート: d3d. が追加
     されました。これにより SSL プロトコルの処理と ネットワーク IO が分
     離されました。

   * 新たな関数 *note os.scandir(): a2d. はディレクトリー走査の *note
     改良され非常に速い方法: d3e. を提供します。

   * *note functools.lru_cache(): 9bd. の大部分が *note C で再実装: d3f.
     され、性能が大幅に向上しました。

   * 新たな関数 *note subprocess.run(): b54. は *note
     サブプロセスを実行する合理的な方法: d40. を提供します。

   * *note traceback: e7. モジュールは性能と開発者の利便性が向上し、大い
     に *note 強化され: d41. ました。

セキュリティの改善:

   * SSLv3 が標準ライブラリ全体を通じて無効化されました。ただし *note
     ssl.SSLContext: 274. を手動でインスタンス化することによってなら今で
     も有効には出来ます。 (詳細に関しては bpo-22638(6) を参照してくださ
     い。この変更は CPython 3.4 と 2.7 にもバックポートされました。)

   * 潜在的なインジェクション攻撃からの防御のために、HTTP クッキーの解析
     がより厳密に行われるようになりました。 (Contributed by Antoine
     Pitrou in bpo-22796(7).)

Windows の改善:

   * Windows のインストーラが新しくなり古い MSI を置き換えました。さらに
     詳しい情報は *note Windows で Python を使う: a75. をご覧ください。

   * Windows のビルドに Microsoft Visual C++ 14.0 を使うようになっていま
     す。拡張モジュールも同じものを使うべきです。

以降は、たくさんのほかの小さな改善、CPython での最適化、非推奨リスト、潜
在的な移植性問題を含む、ユーザ向けの変更の包括的なリストになっています。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9951

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23632

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24450

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19235

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19977

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22638

   (7) https://bugs.python.org/issue?@action=redirect&bpo=22796


File: python.info,  Node: 新しい機能<10>,  Next: その他の言語変更<7>,  Prev: 概要 -- リリースハイライト<7>,  Up: What's New In Python 3 5

1.9.2 新しい機能
----------------

* Menu:

* PEP 492 - コルーチン、 async と await 構文::
* PEP 465 - 行列の乗算専用の中置演算子::
* PEP 448 - 追加可能なアンパックへの一般化::
* PEP 461 - bytes および bytearray のパーセント書式化サポート::
* PEP 484 - 型ヒント::
* PEP 471 - os.scandir() 関数: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ. より良く、速いディレクトリイテレータ
* PEP 475; EINTR で失敗したシステムコールの再試行: PEP 475 EINTR で失敗したシステムコールの再試行.
* PEP 479; ジェネレータ内の StopIteration の処理の変更: PEP 479 ジェネレータ内の StopIteration の処理の変更.
* PEP 485; 近似的に等しいことを調べる関数: PEP 485 近似的に等しいことを調べる関数.
* PEP 486; Python ランチャーが仮想環境を認識する: PEP 486 Python ランチャーが仮想環境を認識する.
* PEP 488; PYO ファイルの廃止: PEP 488 PYO ファイルの廃止.
* PEP 489; 拡張モジュールの多段階初期化: PEP 489 拡張モジュールの多段階初期化.


File: python.info,  Node: PEP 492 - コルーチン、 async と await 構文,  Next: PEP 465 - 行列の乗算専用の中置演算子,  Up: 新しい機能<10>

1.9.2.1 PEP 492 - コルーチン、 async と await 構文
..................................................

PEP 492(1) で *note 待機可能オブジェクト: 192.、*note コルーチン関数:
d44.、*note 非同期イテレーション: d45.、*note
非同期コンテキストマネージャ: 5a1. が追加され、Python における非同期プロ
グラミングを大幅に向上しました。

コルーチン関数は新たな構文 *note async def: 59b. を用いて定義されます:

     >>> async def coro():
     ...     return 'spam'

コルーチン関数内で、新たな *note await: 19e. 式を用いることで結果が利用
可能になるまでコルーチンの実行を停止することが出来ます。‘__await__()’ メ
ソッドを定義して *note awaitable: 192. プロトコルを実装する限り、あらゆ
るオブジェクトは '待機可能' です。

PEP 492 により *note async for: a79. 文も追加されました。非同期イテラブ
ルを反復するのに便利です。

新たな構文を用いた初歩的な HTTP クライアントの例です:

     import asyncio

     async def http_get(domain):
         reader, writer = await asyncio.open_connection(domain, 80)

         writer.write(b'\r\n'.join([
             b'GET / HTTP/1.1',
             b'Host: %b' % domain.encode('latin-1'),
             b'Connection: close',
             b'', b''
         ]))

         async for line in reader:
             print('>>>', line)

         writer.close()

     loop = asyncio.get_event_loop()
     try:
         loop.run_until_complete(http_get('example.com'))
     finally:
         loop.close()

非同期イテレーションと同様に、非同期なコンテキストマネージャの新たな構文
があります。以下のスクリプト:

     import asyncio

     async def coro(name, lock):
         print('coro {}: waiting for lock'.format(name))
         async with lock:
             print('coro {}: holding the lock'.format(name))
             await asyncio.sleep(1)
             print('coro {}: releasing the lock'.format(name))

     loop = asyncio.get_event_loop()
     lock = asyncio.Lock()
     coros = asyncio.gather(coro(1, lock), coro(2, lock))
     try:
         loop.run_until_complete(coros)
     finally:
         loop.close()

の出力は:

     coro 2: waiting for lock
     coro 2: holding the lock
     coro 1: waiting for lock
     coro 2: releasing the lock
     coro 1: holding the lock
     coro 1: releasing the lock

*note async for: a79. と *note async with: 59f. は両方とも、 *note async
def: 59b. で宣言されたコルーチン関数内でのみ使えることに注意してください
。

コルーチン関数は *note asyncio loop: d46. のような適したイベントループ内
で実行させるためのものです。

     注釈: 
     バージョン 3.5.2 で変更: CPython 3.5.2 以降では、 ‘__aiter__’ は
     *note 非同期イテレータ: 190. を直接返せます。 *note awaitable: 192.
     オブジェクトを返すと *note PendingDeprecationWarning: 895. が送出さ
     れます。

     より詳細なことはドキュメントの *note 非同期イテレータ (Asynchronous
     Iterator): d47. 節を参照してください。

参考
....

PEP 492(2) - コルーチン、 async 構文と await 構文

     PEP written and implemented by Yury Selivanov.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0492/

   (2) https://peps.python.org/pep-0492/


File: python.info,  Node: PEP 465 - 行列の乗算専用の中置演算子,  Next: PEP 448 - 追加可能なアンパックへの一般化,  Prev: PEP 492 - コルーチン、 async と await 構文,  Up: 新しい機能<10>

1.9.2.2 PEP 465 - 行列の乗算専用の中置演算子
............................................

PEP 465(1) により ‘@’ 行列の乗算のための中置演算子が追加されました。 現
在のところ Python の型はこの演算子を実装していませんが、‘__matmul__()’、
‘__rmatmul__()’、‘__imatmul__()’ (それぞれ通常の乗算、反射した乗算、イン
プレースの乗算) を定義することで実装することが出来ます。 これらのメソッ
ドのセマンティクスは他の中置算術演算子のものと類似です。

行列の乗算は数学、科学、工学の多くの分野では非常に一般的です。 ‘@’ の追
加によりコードをより綺麗に書くことが出来ます:

     S = (H @ beta - r).T @ inv(H @ V @ H.T) @ (H @ beta - r)

これはたとえば NumPy を使っても、以下のように書く必要がありました:

     S = dot((dot(H, beta) - r).T,
             dot(inv(dot(dot(H, V), H.T)), dot(H, beta) - r))

NumPy 1.10 はこの新たな演算子をサポートしています:

     >>> import numpy

     >>> x = numpy.ones(3)
     >>> x
     array([ 1., 1., 1.])

     >>> m = numpy.eye(3)
     >>> m
     array([[ 1., 0., 0.],
            [ 0., 1., 0.],
            [ 0., 0., 1.]])

     >>> x @ m
     array([ 1., 1., 1.])

参考
....

PEP 465(2) - 行列乗算専用の中置演算子

     PEP written by Nathaniel J. Smith; implemented by Benjamin
     Peterson.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0465/

   (2) https://peps.python.org/pep-0465/


File: python.info,  Node: PEP 448 - 追加可能なアンパックへの一般化,  Next: PEP 461 - bytes および bytearray のパーセント書式化サポート,  Prev: PEP 465 - 行列の乗算専用の中置演算子,  Up: 新しい機能<10>

1.9.2.3 PEP 448 - 追加可能なアンパックへの一般化
................................................

PEP 448(1) によって、 ‘*’ イテラブルアンパック演算子と ‘**’ 辞書アンパッ
ク演算子の利用方法が拡張されました。 *note 関数呼び出し: d4a. で任意の数
のアンパックで使えるようになりました:

     >>> print(*[1], *[2], 3, *[4, 5])
     1 2 3 4 5

     >>> def fn(a, b, c, d):
     ...     print(a, b, c, d)
     ...

     >>> fn(**{'a': 1, 'c': 3}, **{'b': 2, 'd': 4})
     1 2 3 4

同様に、タプル、リスト、集合、辞書表現でも複数のアンパックが使えます
(*note 式のリスト: d4b. および *note 辞書表示: d4c. を参照してください):

     >>> *range(4), 4
     (0, 1, 2, 3, 4)

     >>> [*range(4), 4]
     [0, 1, 2, 3, 4]

     >>> {*range(4), 4, *(5, 6, 7)}
     {0, 1, 2, 3, 4, 5, 6, 7}

     >>> {'x': 1, **{'y': 2}}
     {'x': 1, 'y': 2}

参考
....

PEP 448(2) - 追加可能なアンパックへの一般化

     PEP written by Joshua Landau; implemented by Neil Girdhar, Thomas
     Wouters, and Joshua Landau.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0448/

   (2) https://peps.python.org/pep-0448/


File: python.info,  Node: PEP 461 - bytes および bytearray のパーセント書式化サポート,  Next: PEP 484 - 型ヒント,  Prev: PEP 448 - 追加可能なアンパックへの一般化,  Up: 新しい機能<10>

1.9.2.4 PEP 461 - bytes および bytearray のパーセント書式化サポート
...................................................................

PEP 461(1) によって、 *note bytes: 1a4. と *note bytearray: 508. に ‘%’
*note 補間演算子: d4e. のサポートが追加されます。

補間は通常は文字列演算だと考えられていますが、 ‘bytes’ や ‘bytearrays’ 上
の補間が意味を持つ場合もあって、この機能が無いと余計な作業が必要になりコ
ードの全体の可読性が損なわれます。 この問題は特にワイヤフォーマットプロ
トコルの取り扱いにおいて重要で、バイナリとASCII互換のテキストが入り交じ
ったものがよく出てきます。

例:

     >>> b'Hello %b!' % b'World'
     b'Hello World!'

     >>> b'x=%i y=%f' % (1, 2.5)
     b'x=1 y=2.500000'

Unicode に対して ‘%b’ は使えませんが、 ‘%a’ であれば使えます
(‘repr(obj).encode('ascii', 'backslashreplace')’ と同等):

     >>> b'Hello %b!' % 'World'
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: %b requires bytes, or an object that implements __bytes__, not 'str'

     >>> b'price: %a' % '10€'
     b"price: '10\\u20ac'"

‘%s’ および ‘%r’ 変換型はサポートはされますが、 Python 2 との互換性を持
たせる必要のあるコードベースでのみ使われるべきだということに注意してくだ
さい。

参考
....

PEP 461(2) - bytes と bytearray への % 書式化の追加

     PEP written by Ethan Furman; implemented by Neil Schemenauer and
     Ethan Furman.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0461/

   (2) https://peps.python.org/pep-0461/


File: python.info,  Node: PEP 484 - 型ヒント,  Next: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ,  Prev: PEP 461 - bytes および bytearray のパーセント書式化サポート,  Up: 新しい機能<10>

1.9.2.5 PEP 484 - 型ヒント
..........................

関数アノテーション構文はバージョン 3.0 ( PEP 3107(1)) から Python の仕様
になりましたが、アノテーションのセマンティクスは未定義のままでした。

経験的に、関数アノテーションの使用の大半は関数の引数と返り値の型ヒントを
提供するためのものです。 標準ライブラリーが型アノテーションの基本的な定
義とツールを持てば、Python ユーザに有益であることは明白となりました。

PEP 484(2) introduces a *note provisional module: ad1. to provide these
standard definitions and tools, along with some conventions for
situations where annotations are not available.

例えば、こちらは引数と返り値の型がアノテーションで定義されている簡単な関
数です:

     def greeting(name: str) -> str:
         return 'Hello ' + name

While these annotations are available at runtime through the usual
‘__annotations__’ attribute, 'no automatic type checking happens at
runtime'.  Instead, it is assumed that a separate off-line type checker
(e.g.  mypy(3)) will be used for on-demand source code analysis.

型システムはユニオン、一般型、そして *note Any: 678. という全ての型と互
換な (すなわち代入可能) 特殊型をサポートしています。

参考
....

   * *note typing: ed. モジュールのドキュメント

   * 
     PEP 484(4) - 型ヒント

          PEP 著 Guido van Rossum, Jukka Lehtosalo, Łukasz Langa; 実装
          Guido van Rossum。

   * 
     PEP 483(5) - 型ヒントの理論

          PEP written by Guido van Rossum

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3107/

   (2) https://peps.python.org/pep-0484/

   (3) https://mypy-lang.org

   (4) https://peps.python.org/pep-0484/

   (5) https://peps.python.org/pep-0483/


File: python.info,  Node: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ,  Next: PEP 475 EINTR で失敗したシステムコールの再試行,  Prev: PEP 484 - 型ヒント,  Up: 新しい機能<10>

1.9.2.6 PEP 471 - os.scandir() 関数 - より良く、速いディレクトリイテレータ
..........................................................................

PEP 471(1) により新しいディレクトリ反復関数 *note os.scandir(): a2d. が
標準ライブラリへ追加されました。 さらに、 ‘scandir’ を使い *note
os.walk(): 476. が実装され、 POSIX システムで3倍から5倍、 Windows システ
ムで7倍から20倍高速になりました。 これは主に、ディレクトリツリーを走査す
るのに必要な *note os.stat(): 46d. の呼び出し回数をかなり減らしたことに
よるものです。

これの他にも、 ‘scandir’ ファイル名のリストではなくイテレータを返すよう
になり、非常に大きなディレクトリ群の走査をするときのメモリ効率が改善され
ました。

次の例では、 *note os.scandir(): a2d. を使用して、与えられた 'path' 内の
先頭が ‘'.'’ でないすべてのファイル (ディレクトリを除く) を表示します。
*note entry.is_file(): d51. を呼び出しても、通常は追加のシステムコールは
行われません:

     for entry in os.scandir(path):
         if not entry.name.startswith('.') and entry.is_file():
             print(entry.name)

参考
....

PEP 471(2) - os.scandir() 関数 - より良く、速いディレクトリイテレータ

     PEP 著・実装 Ben Hoyt 補佐 Victor Stinner。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0471/

   (2) https://peps.python.org/pep-0471/


File: python.info,  Node: PEP 475 EINTR で失敗したシステムコールの再試行,  Next: PEP 479 ジェネレータ内の StopIteration の処理の変更,  Prev: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ,  Up: 新しい機能<10>

1.9.2.7 PEP 475: EINTR で失敗したシステムコールの再試行
.......................................................

An *note errno.EINTR: d54. error code is returned whenever a system
call, that is waiting for I/O, is interrupted by a signal.  Previously,
Python would raise *note InterruptedError: d55. in such cases.  This
meant that, when writing a Python application, the developer had two
choices:

  1. ‘InterruptedError’ を無視する。

  2. 呼び出し箇所の全てで ‘InterruptedError’ を処理し、中断されたシステ
     ムコールの再開を試みる。

最初の選択肢では、アプリケーションは断続的に失敗します。 二つ目の選択肢
では、定型処理を大量に追加せねばならず、コードの可読性が著しく下がります
。 次の2つを比べてみてください:

     print("Hello World")

および:

     while True:
         try:
             print("Hello World")
             break
         except InterruptedError:
             continue

PEP 475(1) は ‘EINTR’ を受けた場合のシステムコールの自動再試行を実装して
います。 これはほとんどの場合ユーザコードでの ‘EINTR’ や *note
InterruptedError: d55. を扱う負担をなくし、標準ライブラリを含む Python プ
ログラムをより堅牢にします。 シグナルハンドラが例外を投げない場合にのみ
システムコールを再試行することに注意してください。

下記は、シグナルで中断された際に再試行をするようになった関数のリストです
:

   * *note open(): 4e5. および *note io.open(): 4e6.;

   * *note faulthandler: 4e. モジュールの関数;

   * *note os: 91. モジュールの関数: *note fchdir(): d56, *note
     fchmod(): 1fd, *note fchown(): d57, *note fdatasync(): d58, *note
     fstat(): d59, *note fstatvfs(): d5a, *note fsync(): d5b, *note
     ftruncate(): d5c, *note mkfifo(): d5d, *note mknod(): d5e, *note
     open(): d5f, *note posix_fadvise(): d60, *note posix_fallocate():
     d61, *note pread(): b2d, *note pwrite(): b30, *note read(): d62,
     *note readv(): b2c, *note sendfile(): add, *note wait3(): d63,
     *note wait4(): d64, *note wait(): d65, *note waitid(): d66, *note
     waitpid(): d67, *note write(): d68, *note writev(): b2f.;

   * special cases: *note os.close(): b42. and *note os.dup2(): b31. now
     ignore *note EINTR: d54. errors; the syscall is not retried (see
     the PEP for the rationale);

   * *note select: af. モジュール関数: *note devpoll.poll(): d69, *note
     epoll.poll(): d6a, *note kqueue.control(): d6b, *note poll.poll():
     d6c, *note select(): d6d.;

   * *note socket: d6e. クラスのメソッド: *note accept(): d6f, *note
     connect(): d70. (ノンブロッキングソケットを除く), *note recv():
     d71, *note recvfrom(): d72, *note recvmsg(): d73, *note send():
     d74, *note sendall(): d75, *note sendmsg(): 443, *note sendto():
     d76.;

   * *note signal.sigtimedwait(): d77. および *note
     signal.sigwaitinfo(): d78.;

   * *note time.sleep(): 669.

参考
....

PEP 475(2) - EINTR で失敗したシステムコールの再試行

     Antoine Pitrou の協力のもと、 PEP および実装は Charles-François
     Natali と Victor Stinner によって書かれました (『フレンチ・コネクシ
     ョン』)。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/

   (2) https://peps.python.org/pep-0475/


File: python.info,  Node: PEP 479 ジェネレータ内の StopIteration の処理の変更,  Next: PEP 485 近似的に等しいことを調べる関数,  Prev: PEP 475 EINTR で失敗したシステムコールの再試行,  Up: 新しい機能<10>

1.9.2.8 PEP 479: ジェネレータ内の StopIteration の処理の変更
............................................................

Python 3.4 以前では、ジェネレータと *note StopIteration: bc8. の組み合わ
せが驚くような動作をし、分かりづらいバグを隠すことがありました。 以前は
、ジェネレータ関数内でうっかり ‘StopIteration’ が送出されると、そのジェ
ネレータの反復処理をしているループ構造が終端に達したと解釈されていました
。

PEP 479(1) によってジェネレータのこの振る舞いが変更されました: ジェネレ
ータ内部で ‘StopIteration’ 例外が送出されたときは、ジェネレータのフレー
ムを抜ける前に *note RuntimeError: 17a. に置き換えられます。 この変更の
一番の目的は、保護されていない *note next(): 7a3. の呼び出しが
‘StopIteration’ を送出し、ジェネレータを回している反復処理が黙って終了し
てしまうような状況で、デバッグをしやすくすることです。 これは ‘yield
from’ 構造と組み合わさったとき特に有害になります。

これは後方互換性の無い変更ですので、この新しい振る舞いを有効にするには
*note __future__: d7a. のインポートが必要です:

     >>> from __future__ import generator_stop

     >>> def gen():
     ...     next(iter([]))
     ...     yield
     ...
     >>> next(gen())
     Traceback (most recent call last):
       File "<stdin>", line 2, in gen
     StopIteration

     The above exception was the direct cause of the following exception:

     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     RuntimeError: generator raised StopIteration

‘__future__’ をインポートしておらず、ジェネレータの内部で *note
StopIteration: bc8. 例外が送出されたときには *note
PendingDeprecationWarning: 895. が送出されます。

参考
....

PEP 479(2) - ジェネレータ内の StopIteration の処理の変更

     PEP written by Chris Angelico and Guido van Rossum.  Implemented by
     Chris Angelico, Yury Selivanov and Nick Coghlan.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0479/

   (2) https://peps.python.org/pep-0479/


File: python.info,  Node: PEP 485 近似的に等しいことを調べる関数,  Next: PEP 486 Python ランチャーが仮想環境を認識する,  Prev: PEP 479 ジェネレータ内の StopIteration の処理の変更,  Up: 新しい機能<10>

1.9.2.9 PEP 485: 近似的に等しいことを調べる関数
...............................................

PEP 485(1) により、2値が互いに近似的に等しいか "近い" ことを調べる関数
*note math.isclose(): d7d. 及び *note cmath.isclose(): d7e. が追加されま
した。 2値が近いと判断されるかどうかは与えられた絶対及び相対許容差で決ま
ります。 相対許容差は ‘isclose’ 引数間で許される、絶対値の大きい方に対す
る最大の差です:

     >>> import math
     >>> a = 5.0
     >>> b = 4.99998
     >>> math.isclose(a, b, rel_tol=1e-5)
     True
     >>> math.isclose(a, b, rel_tol=1e-6)
     False

2値を絶対許容差で比較することも出来ます。絶対許容差は非負数でなければな
りません:

     >>> import math
     >>> a = 5.0
     >>> b = 4.99998
     >>> math.isclose(a, b, abs_tol=0.00003)
     True
     >>> math.isclose(a, b, abs_tol=0.00001)
     False

参考
....

PEP 485(2) - A function for testing approximate equality

     PEP written by Christopher Barker; implemented by Chris Barker and
     Tal Einat.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0485/

   (2) https://peps.python.org/pep-0485/


File: python.info,  Node: PEP 486 Python ランチャーが仮想環境を認識する,  Next: PEP 488 PYO ファイルの廃止,  Prev: PEP 485 近似的に等しいことを調べる関数,  Up: 新しい機能<10>

1.9.2.10 PEP 486: Python ランチャーが仮想環境を認識する
.......................................................

PEP 486(1) により、 Windows ランチャー ( PEP 397(2) を参照してください)
が有効になっている仮想環境を認識するようになりました。 デフォルトのイン
タプリタを使っていて、 ‘VIRTUAL_ENV’ 環境変数が設定されているときは、仮
想環境のインタプリタが使われます。

参考
....

PEP 486(3) - Python ランチャーが仮想環境を認識する

     PEP written and implemented by Paul Moore.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0486/

   (2) https://peps.python.org/pep-0397/

   (3) https://peps.python.org/pep-0486/


File: python.info,  Node: PEP 488 PYO ファイルの廃止,  Next: PEP 489 拡張モジュールの多段階初期化,  Prev: PEP 486 Python ランチャーが仮想環境を認識する,  Up: 新しい機能<10>

1.9.2.11 PEP 488: PYO ファイルの廃止
....................................

PEP 488(1) は ‘.pyo’ ファイルという概念を廃止しました。 つまり、‘.pyc’ フ
ァイルは最適化されていないバイトコードと最適化されたバイトコードの両方を
指すということです。 バイトコードファイルを何度も再生成する必要がないよ
う、バイトコードが最適化されたときは ‘.pyc’ ファイルは任意の ‘opt-’ タグ
を名前に持つようになりました。 この副作用で、*note -O: d82. と *note
-OO: d83. のいずれかで実行した場合でも、バイトコードのファイル名が衝突し
ないようになりました。 それにより、*note -O: d82. および *note -OO: d83.
で生成したバイトコードは同時に存在できるようになりました。 *note
importlib.util.cache_from_source(): 2d5. にの API は更新され、この変更に
役立ちます。

参考
....

PEP 488(2) - PYO ファイルの廃止

     PEP written and implemented by Brett Cannon.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0488/

   (2) https://peps.python.org/pep-0488/


File: python.info,  Node: PEP 489 拡張モジュールの多段階初期化,  Prev: PEP 488 PYO ファイルの廃止,  Up: 新しい機能<10>

1.9.2.12 PEP 489: 拡張モジュールの多段階初期化
..............................................

PEP 489(1) により拡張モジュールの初期化方式が更新され、 Python 3.4 で
PEP 451(2) によって導入された2段階でモジュールを読み込む仕組みが活用でき
るようになりました。

この変更によって、新しい仕組みを使うことを選択した拡張モジュールのインポ
ートの動作が、 Python のソースコードやバイトコードでできたモジュールにか
なり近くなり、これまで ASCII に制限されていたモジュール名に任意の識別子
が使えるようになりました。

参考
....

PEP 489(3) - 拡張モジュールの多段階初期化

     PEP 著 Petr Viktorin, Stefan Behnel, Nick Coghlan; 実装 Petr
     Viktorin.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0489/

   (2) https://peps.python.org/pep-0451/

   (3) https://peps.python.org/pep-0489/


File: python.info,  Node: その他の言語変更<7>,  Next: 新たなモジュール<7>,  Prev: 新しい機能<10>,  Up: What's New In Python 3 5

1.9.3 その他の言語変更
----------------------

Python 言語コアに小さな変更がいくつか行われました:

   * ‘"namereplace"’ エラーハンドラが追加されました。
     ‘"backslashreplace"’ エラーハンドラはデコードと変換で動くようになり
     ました。 (Contributed by Serhiy Storchaka in bpo-19676(1) and
     bpo-22286(2).)

   * *note -b: 5ad. オプションが *note bytes: 1a4. と *note int: 238. の
     比較に影響するようになりました。 (Contributed by Serhiy Storchaka
     in bpo-23681(3).)

   * 新たなカザフ語 ‘kz1048’ 及びタジク語 ‘koi8_t’ *note コーデックス:
     d86.。 (Contributed by Serhiy Storchaka in bpo-22682(4) and
     bpo-22681(5).)

   * プロパティのドキュメンテーション文字列が書き込み可能になりました。
     これは特に *note collections.namedtuple(): 1ac. のドキュメンテーシ
     ョン文字列で有用です。 (Contributed by Berker Peksag in
     bpo-24064(6).)

   * 相対インポートに関する循環インポートがサポートされました。
     (Contributed by Brett Cannon and Antoine Pitrou in bpo-17636(7).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19676

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22286

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23681

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22682

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22681

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24064

   (7) https://bugs.python.org/issue?@action=redirect&bpo=17636


File: python.info,  Node: 新たなモジュール<7>,  Next: 改良されたモジュール<7>,  Prev: その他の言語変更<7>,  Up: What's New In Python 3 5

1.9.4 新たなモジュール
----------------------

* Menu:

* typing: typing<10>.
* zipapp: zipapp<2>.


File: python.info,  Node: typing<10>,  Next: zipapp<2>,  Up: 新たなモジュール<7>

1.9.4.1 typing
..............

The new *note typing: ed. *note provisional: ad1. module provides
standard definitions and tools for function type annotations.  See *note
Type Hints: d33. for more information.


File: python.info,  Node: zipapp<2>,  Prev: typing<10>,  Up: 新たなモジュール<7>

1.9.4.2 zipapp
..............

新たな *note zipapp: 116. モジュール ( PEP 441(1) で仕様定義) は実行可能
な Python Zip アプリケーションを作成するための API とコマンドラインツー
ルを提供します。 Python Zip アプリケーションは Python 2.6 の
bpo-1739468(2) で導入されましたが、それ以降もあまり知られていませんでし
た。

この新しいモジュールを使ったアプリケーションのバンドル方法は単純で、
‘__main__.py’ ファイルを含む全てのファイルをディレクトリ ‘myapp’ に置き
、次のように実行します:

     $ python -m zipapp myapp
     $ python myapp.pyz

モジュールの実装は bpo-23491(3) の Paul Moore による貢献です。

参考
....

PEP 441(4) - Python ZIP アプリケーションのサポートの改善
<whatsnew-zipapp>'

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0441/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1739468

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23491

   (4) https://peps.python.org/pep-0441/


File: python.info,  Node: 改良されたモジュール<7>,  Next: その他のモジュールレベルの変更,  Prev: 新たなモジュール<7>,  Up: What's New In Python 3 5

1.9.5 改良されたモジュール
--------------------------

* Menu:

* argparse: argparse<4>.
* asyncio: asyncio<10>.
* bz2::
* cgi::
* cmath: cmath<2>.
* コード::
* collections: collections<5>.
* collections.abc: collections abc<3>.
* compileall: compileall<4>.
* concurrent.futures: concurrent futures<5>.
* configparser: configparser<4>.
* contextlib: contextlib<5>.
* csv: csv<3>.
* curses: curses<4>.
* dbm: dbm<5>.
* difflib::
* distutils: distutils<7>.
* doctest: doctest<3>.
* email: email<3>.
* enum: enum<7>.
* faulthandler: faulthandler<3>.
* functools: functools<4>.
* glob: glob<3>.
* gzip: gzip<4>.
* heapq::
* http: http<2>.
* http.client: http client<3>.
* idlelib と IDLE: idlelib と IDLE<3>.
* imaplib: imaplib<2>.
* imghdr::
* importlib: importlib<8>.
* inspect: inspect<7>.
* io: io<5>.
* ipaddress: ipaddress<4>.
* json: json<2>.
* linecache: linecache<2>.
* locale: locale<6>.
* logging: logging<5>.
* lzma::
* math: math<8>.
* multiprocessing: multiprocessing<6>.
* operator: operator<2>.
* os: os<10>.
* pathlib: pathlib<10>.
* pickle: pickle<3>.
* poplib: poplib<2>.
* re: re<7>.
* readline: readline<2>.
* selectors::
* shutil: shutil<5>.
* signal: signal<3>.
* smtpd: smtpd<2>.
* smtplib: smtplib<2>.
* sndhdr::
* socket: socket<8>.
* ssl: ssl<9>.
* sqlite3: sqlite3<8>.
* subprocess: subprocess<4>.
* sys: sys<11>.
* sysconfig: sysconfig<2>.
* tarfile: tarfile<6>.
* threading: threading<6>.
* time: time<7>.
* timeit: timeit<2>.
* tkinter: tkinter<8>.
* traceback: traceback<5>.
* types: types<5>.
* unicodedata: unicodedata<8>.
* unittest: unittest<8>.
* unittest.mock: unittest mock<3>.
* urllib: urllib<2>.
* wsgiref::
* xmlrpc: xmlrpc<2>.
* xml.sax: xml sax.
* zipfile: zipfile<4>.


File: python.info,  Node: argparse<4>,  Next: asyncio<10>,  Up: 改良されたモジュール<7>

1.9.5.1 argparse
................

*note ArgumentParser: 503. クラスは、*note allow_abbrev: d8c. を ‘False’
に設定することでロングオプションの *note 短縮使用: d8d. を無効化できるよ
うになりました。 (Contributed by Jonathan Paugh, Steven Bethard, paul j3
and Daniel Eriksson in bpo-14910(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14910


File: python.info,  Node: asyncio<10>,  Next: bz2,  Prev: argparse<4>,  Up: 改良されたモジュール<7>

1.9.5.2 asyncio
...............

Since the *note asyncio: 8. module is *note provisional: ad1, all
changes introduced in Python 3.5 have also been backported to Python
3.4.x.

Python 3.4.0 以後の *note asyncio: 8. モジュールの重要な変更点:

   * 新たなデバッグ API: *note loop.set_debug(): d8f. と *note
     loop.get_debug(): d90. メソッド。 (Contributed by Victor Stinner.)

   * proactor イベントループが SSL をサポートしました。 (Contributed by
     Antoine Pitrou and Victor Stinner in bpo-22560(1).)

   * イベントループが閉じているかどうか調べる新たな *note
     loop.is_closed(): d91. メソッド。 (Contributed by Victor Stinner in
     bpo-21326(2).)

   * コルーチンの新しい *note Task: 4a5. を便利に作成しスケジュールする
     ための新たな *note loop.create_task(): 9aa.。 ‘create_task’ メソッ
     ドは コルーチンをタスクにラップする全ての asyncio 関数、たとえば
     *note asyncio.wait(): 44c, *note asyncio.gather(): 5c8.、にも使われ
     ます。 (Contributed by Victor Stinner.)

   * A new *note transport.get_write_buffer_limits(): d92. method to
     inquire for 'high-' and 'low-' water limits of the flow control.
     (Contributed by Victor Stinner.)

   * ‘async()’ 関数は *note ensure_future(): c44. により非推奨になりまし
     た。(Contributed by Yury Selivanov.)

   * *note loop.create_task(): 9aa. メソッドが使うタスクファクトリーをカ
     スタマイズするための新たな *note loop.set_task_factory(): d93. メソ
     ッドと *note loop.get_task_factory(): d94. メソッド。 (Yury
     Selivanovによる貢献。)

   * 新たな *note Queue.join(): d95. および *note Queue.task_done():
     d96. キューメソッド。(Contributed by Victor Stinner.)

   * ‘JoinableQueue’ クラスは *note asyncio.Queue: a44. クラスにより削除
     されました。 (Contributed by Victor Stinner.)

3.5.1 での変更:

   * The *note ensure_future(): c44. function and all functions that use
     it, such as *note loop.run_until_complete(): c45, now accept all
     kinds of *note awaitable objects: 192.  (Contributed by Yury
     Selivanov.)

   * 他のスレッドからコルーチンをイベントループに送信するための新たな
     *note run_coroutine_threadsafe(): 84f. 関数。 (Contributed by
     Vincent Michel.)

   * New *note Transport.is_closing(): c46. method to check if the
     transport is closing or closed.  (Contributed by Yury Selivanov.)

   * The *note loop.create_server(): ae1. method can now accept a list
     of hosts.  (Contributed by Yann Sionneau.)

3.5.2 での変更:

   * New *note loop.create_future(): c47. method to create Future
     objects.  This allows alternative event loop implementations, such
     as uvloop(3), to provide a faster *note asyncio.Future: b9b.
     implementation.  (Contributed by Yury Selivanov.)

   * New *note loop.get_exception_handler(): c48. method to get the
     current exception handler.  (Contributed by Yury Selivanov.)

   * 新しい *note StreamReader.readuntil(): 199. メソッドで、区切りとな
     るバイトの並びが出てくるまでストリームからデータを読み取れるように
     なりました。 (Contributed by Mark Korenberg.)

   * The *note loop.create_connection(): 5ce. and *note
     loop.create_server(): ae1. methods are optimized to avoid calling
     the system ‘getaddrinfo’ function if the address is already
     resolved.  (Contributed by A. Jesse Jiryu Davis.)

   * The *note loop.sock_connect(sock, address): d97. no longer requires
     the 'address' to be resolved prior to the call.  (Contributed by A.
     Jesse Jiryu Davis.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22560

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21326

   (3) https://github.com/MagicStack/uvloop


File: python.info,  Node: bz2,  Next: cgi,  Prev: asyncio<10>,  Up: 改良されたモジュール<7>

1.9.5.3 bz2
...........

*note BZ2Decompressor.decompress: d99. メソッドがオプション引数
'max_length' を取れるようになり、展開されたデータの最大サイズが制限でき
るようになりました。 (Contributed by Nikolaus Rath in bpo-15955(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15955


File: python.info,  Node: cgi,  Next: cmath<2>,  Prev: bz2,  Up: 改良されたモジュール<7>

1.9.5.4 cgi
...........

The ‘FieldStorage’ class now supports the *note context manager: 59e.
protocol.  (Contributed by Berker Peksag in bpo-20289(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20289


File: python.info,  Node: cmath<2>,  Next: コード,  Prev: cgi,  Up: 改良されたモジュール<7>

1.9.5.5 cmath
.............

新たな関数 *note isclose(): d7e. は近似的に等しいかどうかを判断する方法
を提供します。 (Contributed by Chris Barker and Tal Einat in
bpo-24270(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24270


File: python.info,  Node: コード,  Next: collections<5>,  Prev: cmath<2>,  Up: 改良されたモジュール<7>

1.9.5.6 コード
..............

*note InteractiveInterpreter.showtraceback(): d9d. メソッドが、対話的イ
ンタープリタのように連なったスタックトレース全体を表示するようになりまし
た。 (Contributed by Claudiu Popa in bpo-17442(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17442


File: python.info,  Node: collections<5>,  Next: collections abc<3>,  Prev: コード,  Up: 改良されたモジュール<7>

1.9.5.7 collections
...................

*note collections.OrderedDict: 5a5. が C で実装されました。 これにより
4倍 から 100 倍高速になりました。 (Contributed by Eric Snow in
bpo-16991(1).)

‘OrderedDict.items()’, ‘OrderedDict.keys()’, ‘OrderedDict.values()’ ビュ
ーが *note reversed(): 831. イテレーションをサポートしました。
(Contributed by Serhiy Storchaka in bpo-19505(2).)

*note deque: 5a6. クラスが *note index(): d9f.、 *note insert(): da0.、
*note copy(): da1. を定義し、‘+’ と ‘*’ 演算をサポートしました。 これに
より deque インスタンスは *note MutableSequence: 186. と認識され、list と
の代替性が向上しました。 (Contributed by Raymond Hettinger in
bpo-23704(3).)

*note namedtuple(): 1ac. で生成されたドキュメンテーション文字列が更新可
能となりました:

     Point = namedtuple('Point', ['x', 'y'])
     Point.__doc__ += ': Cartesian coordinate'
     Point.x.__doc__ = 'abscissa'
     Point.y.__doc__ = 'ordinate'

(Contributed by Berker Peksag in bpo-24064(4).)

The *note UserString: da2. class now implements the ‘__getnewargs__()’,
‘__rmod__()’, *note casefold(): da3, *note format_map(): da4, *note
isprintable(): da5, and *note maketrans(): da6. methods to match the
corresponding methods of *note str: 418.  (Contributed by Joe Jevnik in
bpo-22189(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16991

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19505

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23704

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24064

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22189


File: python.info,  Node: collections abc<3>,  Next: compileall<4>,  Prev: collections<5>,  Up: 改良されたモジュール<7>

1.9.5.8 collections.abc
.......................

The ‘Sequence.index()’ method now accepts 'start' and 'stop' arguments
to match the corresponding methods of *note tuple: 349, *note list: 5dc,
etc.  (Contributed by Devin Jeanpierre in bpo-23086(1).)

新たに *note Generator: da8. 抽象基底クラスが追加されました。
(Contributed by Stefan Behnel in bpo-24018(2).)

新たに *note Awaitable: da9, *note Coroutine: daa, *note AsyncIterator:
dab, *note AsyncIterable: dac. 抽象基底クラスが追加されました。
(Contributed by Yury Selivanov in bpo-24184(3).)

For earlier Python versions, a backport of the new ABCs is available in
an external PyPI package(4).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23086

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24018

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24184

   (4) https://pypi.org/project/backports_abc/


File: python.info,  Node: compileall<4>,  Next: concurrent futures<5>,  Prev: collections abc<3>,  Up: 改良されたモジュール<7>

1.9.5.9 compileall
..................

A new *note compileall: 19. option, ‘-j N’, allows running 'N' workers
simultaneously to perform parallel bytecode compilation.  The *note
compile_dir(): af4. function has a corresponding ‘workers’ parameter.
(Contributed by Claudiu Popa in bpo-16104(1).)

Another new option, ‘-r’, allows controlling the maximum recursion level
for subdirectories.  (Contributed by Claudiu Popa in bpo-19628(2).)

The ‘-q’ command line option can now be specified more than once, in
which case all output, including errors, will be suppressed.  The
corresponding ‘quiet’ parameter in *note compile_dir(): af4, *note
compile_file(): dae, and *note compile_path(): daf. can now accept an
integer value indicating the level of output suppression.  (Contributed
by Thomas Kluyver in bpo-21338(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16104

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19628

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21338


File: python.info,  Node: concurrent futures<5>,  Next: configparser<4>,  Prev: compileall<4>,  Up: 改良されたモジュール<7>

1.9.5.10 concurrent.futures
...........................

The *note Executor.map(): db1. method now accepts a 'chunksize' argument
to allow batching of tasks to improve performance when *note
ProcessPoolExecutor(): 8bc. is used.  (Contributed by Dan O'Reilly in
bpo-11271(1).)

The number of workers in the *note ThreadPoolExecutor: 70d. constructor
is optional now.  The default value is 5 times the number of CPUs.
(Contributed by Claudiu Popa in bpo-21527(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11271

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21527


File: python.info,  Node: configparser<4>,  Next: contextlib<5>,  Prev: concurrent futures<5>,  Up: 改良されたモジュール<7>

1.9.5.11 configparser
.....................

*note configparser: 1b. now provides a way to customize the conversion
of values by specifying a dictionary of converters in the *note
ConfigParser: 1aa. constructor, or by defining them as methods in
‘ConfigParser’ subclasses.  Converters defined in a parser instance are
inherited by its section proxies.

以下はプログラム例です:

     >>> import configparser
     >>> conv = {}
     >>> conv['list'] = lambda v: [e.strip() for e in v.split() if e.strip()]
     >>> cfg = configparser.ConfigParser(converters=conv)
     >>> cfg.read_string("""
     ... [s]
     ... list = a b c d e f g
     ... """)
     >>> cfg.get('s', 'list')
     'a b c d e f g'
     >>> cfg.getlist('s', 'list')
     ['a', 'b', 'c', 'd', 'e', 'f', 'g']
     >>> section = cfg['s']
     >>> section.getlist('list')
     ['a', 'b', 'c', 'd', 'e', 'f', 'g']

(Contributed by Łukasz Langa in bpo-18159(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18159


File: python.info,  Node: contextlib<5>,  Next: csv<3>,  Prev: configparser<4>,  Up: 改良されたモジュール<7>

1.9.5.12 contextlib
...................

新規 *note context manager: 59e. の *note contextlib.redirect_stderr():
db4. は、ユーティリティスクリプトにて、その出力を *note sys.stderr: 907.
に書き出す一方でその向き先を変えれない頑固な API の扱いを簡単にしてくれ
ます (*note redirect_stdout(): db5. と対となるものです)。:

     >>> import contextlib, io, logging
     >>> f = io.StringIO()
     >>> with contextlib.redirect_stderr(f):
     ...     logging.warning('warning')
     ...
     >>> f.getvalue()
     'WARNING:root:warning\n'

(Contributed by Berker Peksag in bpo-22389(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22389


File: python.info,  Node: csv<3>,  Next: curses<4>,  Prev: contextlib<5>,  Up: 改良されたモジュール<7>

1.9.5.13 csv
............

*note writerow(): db7. メソッドは、シーケンスだけでなく、 任意のイテラブ
ルをサポートしました。(Contributed by Serhiy Storchaka in bpo-23171(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23171


File: python.info,  Node: curses<4>,  Next: dbm<5>,  Prev: csv<3>,  Up: 改良されたモジュール<7>

1.9.5.14 curses
...............

The new *note update_lines_cols(): db9. function updates the ‘LINES’ and
‘COLS’ module variables.  This is useful for detecting manual screen
resizing.  (Contributed by Arnon Yaari in bpo-4254(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4254


File: python.info,  Node: dbm<5>,  Next: difflib,  Prev: curses<4>,  Up: 改良されたモジュール<7>

1.9.5.15 dbm
............

*note dumb.open: a64. always creates a new database when the flag has
the value ‘"n"’.  (Contributed by Claudiu Popa in bpo-18039(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18039


File: python.info,  Node: difflib,  Next: distutils<7>,  Prev: dbm<5>,  Up: 改良されたモジュール<7>

1.9.5.16 difflib
................

The charset of HTML documents generated by *note HtmlDiff.make_file():
dbc. can now be customized by using a new 'charset' keyword-only
argument.  The default charset of HTML document changed from
‘"ISO-8859-1"’ to ‘"utf-8"’.  (Contributed by Berker Peksag in
bpo-2052(1).)

The *note diff_bytes(): dbd. function can now compare lists of byte
strings.  This fixes a regression from Python 2.  (Contributed by Terry
J. Reedy and Greg Ward in bpo-17445(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2052

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17445


File: python.info,  Node: distutils<7>,  Next: doctest<3>,  Prev: difflib,  Up: 改良されたモジュール<7>

1.9.5.17 distutils
..................

Both the ‘build’ and ‘build_ext’ commands now accept a ‘-j’ option to
enable parallel building of extension modules.  (Contributed by Antoine
Pitrou in bpo-5309(1).)

The ‘distutils’ module now supports ‘xz’ compression, and can be enabled
by passing ‘xztar’ as an argument to ‘bdist --format’.  (Contributed by
Serhiy Storchaka in bpo-16314(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5309

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16314


File: python.info,  Node: doctest<3>,  Next: email<3>,  Prev: distutils<7>,  Up: 改良されたモジュール<7>

1.9.5.18 doctest
................

*note DocTestSuite(): dc0. 関数が、 'module' がドキュメンテーション文字
列(docstrings)を含まない場合に *note ValueError: 1e3. を送出するのではな
く空の *note unittest.TestSuite: dc1. を返すようになりました。
(Contributed by Glenn Jones in bpo-15916(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15916


File: python.info,  Node: email<3>,  Next: enum<7>,  Prev: doctest<3>,  Up: 改良されたモジュール<7>

1.9.5.19 email
..............

A new policy option *note Policy.mangle_from_: dc3. controls whether or
not lines that start with ‘"From "’ in email bodies are prefixed with a
‘">"’ character by generators.  The default is ‘True’ for *note
compat32: c67. and ‘False’ for all other policies.  (Contributed by
Milan Oberkirch in bpo-20098(1).)

A new *note Message.get_content_disposition(): dc4. method provides easy
access to a canonical value for the ‘Content-Disposition’ header.
(Contributed by Abhilash Raj in bpo-21083(2).)

A new policy option *note EmailPolicy.utf8: dc5. can be set to ‘True’ to
encode email headers using the UTF-8 charset instead of using encoded
words.  This allows ‘Messages’ to be formatted according to RFC 6532(3)
and used with an SMTP server that supports the RFC 6531(4) ‘SMTPUTF8’
extension.  (Contributed by R. David Murray in bpo-24211(5).)

The *note mime.text.MIMEText: dc6. constructor now accepts a *note
charset.Charset: dc7. instance.  (Contributed by Claude Paroz and Berker
Peksag in bpo-16324(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20098

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21083

   (3) https://datatracker.ietf.org/doc/html/rfc6532.html

   (4) https://datatracker.ietf.org/doc/html/rfc6531.html

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24211

   (6) https://bugs.python.org/issue?@action=redirect&bpo=16324


File: python.info,  Node: enum<7>,  Next: faulthandler<3>,  Prev: email<3>,  Up: 改良されたモジュール<7>

1.9.5.20 enum
.............

*note Enum: 5fc. 呼び出し可能オブジェクトは、'names' のみが与えられた場
合に enum 値の初期値を指定する新たな引数 'start' を持ちます:

     >>> Animal = enum.Enum('Animal', 'cat dog', start=10)
     >>> Animal.cat
     <Animal.cat: 10>
     >>> Animal.dog
     <Animal.dog: 11>

(Contributed by Ethan Furman in bpo-21706(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21706


File: python.info,  Node: faulthandler<3>,  Next: functools<4>,  Prev: enum<7>,  Up: 改良されたモジュール<7>

1.9.5.21 faulthandler
.....................

関数 *note enable(): c6c, *note register(): dca, *note dump_traceback():
dcb, *note dump_traceback_later(): dcc. が、ファイル様オブジェクトだけで
なくファイル記述子を受け取るようになりました。 (Contributed by Wei Wu in
bpo-23566(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23566


File: python.info,  Node: functools<4>,  Next: glob<3>,  Prev: faulthandler<3>,  Up: 改良されたモジュール<7>

1.9.5.22 functools
..................

*note lru_cache(): 9bd. 機構の多くが C で実装されました。これにより速度
が大幅に向上しました。 (Contributed by Matt Joiner, Alexey Kachayev, and
Serhiy Storchaka in bpo-14373(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14373


File: python.info,  Node: glob<3>,  Next: gzip<4>,  Prev: functools<4>,  Up: 改良されたモジュール<7>

1.9.5.23 glob
.............

*note iglob(): 7d2. 関数と *note glob(): 27f. 関数は、 ‘"**"’ パターンを
使ったサブディレクトリの再帰的な検索をサポートしました。(Contributed by
Serhiy Storchaka in bpo-13968(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13968


File: python.info,  Node: gzip<4>,  Next: heapq,  Prev: glob<3>,  Up: 改良されたモジュール<7>

1.9.5.24 gzip
.............

*note GzipFile: 3f3. コンストラクタの 'mode' 引数が排他的作成を要求する
‘"x"’ を受け取るようになりました。 (Contributed by Tim Heaney in
bpo-19222(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19222


File: python.info,  Node: heapq,  Next: http<2>,  Prev: gzip<4>,  Up: 改良されたモジュール<7>

1.9.5.25 heapq
..............

Element comparison in *note merge(): dd1. can now be customized by
passing a *note key function: dd2. in a new optional 'key' keyword
argument, and a new optional 'reverse' keyword argument can be used to
reverse element comparison:

     >>> import heapq
     >>> a = ['9', '777', '55555']
     >>> b = ['88', '6666']
     >>> list(heapq.merge(a, b, key=len))
     ['9', '88', '777', '6666', '55555']
     >>> list(heapq.merge(reversed(a), reversed(b), key=len, reverse=True))
     ['55555', '6666', '777', '88', '9']

(Contributed by Raymond Hettinger in bpo-13742(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13742


File: python.info,  Node: http<2>,  Next: http client<3>,  Prev: heapq,  Up: 改良されたモジュール<7>

1.9.5.26 http
.............

新しい *note HTTPStatus: 8ce. のenum は、HTTPステータスコードのセットで
、その理由句と詳細な説明は、英語で記載されています。(Contributed by
Demian Brecht in bpo-21793(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21793


File: python.info,  Node: http client<3>,  Next: idlelib と IDLE<3>,  Prev: http<2>,  Up: 改良されたモジュール<7>

1.9.5.27 http.client
....................

*note HTTPConnection.getresponse(): dd5. now raises a *note
RemoteDisconnected: dd6. exception when a remote server connection is
closed unexpectedly.  Additionally, if a *note ConnectionError: dd7. (of
which ‘RemoteDisconnected’ is a subclass) is raised, the client socket
is now closed automatically, and will reconnect on the next request:

     import http.client
     conn = http.client.HTTPConnection('www.python.org')
     for retries in range(3):
         try:
             conn.request('GET', '/')
             resp = conn.getresponse()
         except http.client.RemoteDisconnected:
             pass

(Contributed by Martin Panter in bpo-3566(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3566


File: python.info,  Node: idlelib と IDLE<3>,  Next: imaplib<2>,  Prev: http client<3>,  Up: 改良されたモジュール<7>

1.9.5.28 idlelib と IDLE
........................

idlelib は IDLE シェルとエディタを実装するものであってほかのプログラムか
らインポートされることを意図してはいないので、改善は毎度のリリースごとに
行われます。3.4.0 から始まり、また将来の 3.5.x リリースになされる累積的
な変更リストは ‘Lib/idlelib/NEWS.txt’ で読むことが出来ます。このファイル
は IDLE で Help ‣ About IDLE からも辿り着けます。


File: python.info,  Node: imaplib<2>,  Next: imghdr,  Prev: idlelib と IDLE<3>,  Up: 改良されたモジュール<7>

1.9.5.29 imaplib
................

*note IMAP4: 8d1. クラスが *note context manager: 59e. プロトコルをサポ
ートするようになりました。 *note with: 59c. 文とともに使うと、 IMAP4
‘LOGOUT’ コマンドがブロックの終了時に自動的に呼び出されます。
(Contributed by Tarek Ziadé and Serhiy Storchaka in bpo-4972(1).)

The *note imaplib: 6a. module now supports RFC 5161(2) (ENABLE
Extension) and RFC 6855(3) (UTF-8 Support) via the *note IMAP4.enable():
dda. method.  A new *note IMAP4.utf8_enabled: ddb. attribute tracks
whether or not RFC 6855(4) support is enabled.  (Contributed by Milan
Oberkirch, R. David Murray, and Maciej Szulik in bpo-21800(5).)

The *note imaplib: 6a. module now automatically encodes non-ASCII string
usernames and passwords using UTF-8, as recommended by the RFCs.
(Contributed by Milan Oberkirch in bpo-21800(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4972

   (2) https://datatracker.ietf.org/doc/html/rfc5161.html

   (3) https://datatracker.ietf.org/doc/html/rfc6855.html

   (4) https://datatracker.ietf.org/doc/html/rfc6855.html

   (5) https://bugs.python.org/issue?@action=redirect&bpo=21800

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21800


File: python.info,  Node: imghdr,  Next: importlib<8>,  Prev: imaplib<2>,  Up: 改良されたモジュール<7>

1.9.5.30 imghdr
...............

The ‘what()’ function now recognizes the OpenEXR(1) format (contributed
by Martin Vignali and Claudiu Popa in bpo-20295(2)), and the WebP(3)
format (contributed by Fabrice Aneche and Claudiu Popa in bpo-20197(4).)

   ---------- Footnotes ----------

   (1) https://www.openexr.com

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20295

   (3) https://en.wikipedia.org/wiki/WebP

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20197


File: python.info,  Node: importlib<8>,  Next: inspect<7>,  Prev: imghdr,  Up: 改良されたモジュール<7>

1.9.5.31 importlib
..................

The *note util.LazyLoader: c7b. class allows for lazy loading of modules
in applications where startup time is important.  (Contributed by Brett
Cannon in bpo-17621(1).)

The *note abc.InspectLoader.source_to_code(): dde. method is now a
static method.  This makes it easier to initialize a module object with
code compiled from a string by running ‘exec(code, module.__dict__)’.
(Contributed by Brett Cannon in bpo-21156(2).)

The new *note util.module_from_spec(): ddf. function is now the
preferred way to create a new module.  As opposed to creating a *note
types.ModuleType: de0. instance directly, this new function will set the
various import-controlled attributes based on the passed-in spec object.
(Contributed by Brett Cannon in bpo-20383(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17621

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21156

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20383


File: python.info,  Node: inspect<7>,  Next: io<5>,  Prev: importlib<8>,  Up: 改良されたモジュール<7>

1.9.5.32 inspect
................

Both the *note Signature: 1b1. and *note Parameter: 1b2. classes are now
picklable and hashable.  (Contributed by Yury Selivanov in bpo-20726(1)
and bpo-20334(2).)

A new *note BoundArguments.apply_defaults(): de2. method provides a way
to set default values for missing arguments:

     >>> def foo(a, b='ham', *args): pass
     >>> ba = inspect.signature(foo).bind('spam')
     >>> ba.apply_defaults()
     >>> ba.arguments
     OrderedDict([('a', 'spam'), ('b', 'ham'), ('args', ())])

(Contributed by Yury Selivanov in bpo-24190(3).)

A new class method *note Signature.from_callable(): 705. makes
subclassing of *note Signature: 1b1. easier.  (Contributed by Yury
Selivanov and Eric Snow in bpo-17373(4).)

The *note signature(): 703. function now accepts a 'follow_wrapped'
optional keyword argument, which, when set to ‘False’, disables
automatic following of ‘__wrapped__’ links.  (Contributed by Yury
Selivanov in bpo-20691(5).)

A set of new functions to inspect *note coroutine functions: d44. and
*note coroutine objects: 45e. has been added: *note iscoroutine(): de3,
*note iscoroutinefunction(): 2c5, *note isawaitable(): de4, *note
getcoroutinelocals(): de5, and *note getcoroutinestate(): de6.
(Contributed by Yury Selivanov in bpo-24017(6) and bpo-24400(7).)

The *note stack(): 61e, *note trace(): 61f, *note getouterframes(): 61c,
and *note getinnerframes(): 61d. functions now return a list of named
tuples.  (Contributed by Daniel Shahaf in bpo-16808(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20726

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20334

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24190

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17373

   (5) https://bugs.python.org/issue?@action=redirect&bpo=20691

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24017

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24400

   (8) https://bugs.python.org/issue?@action=redirect&bpo=16808


File: python.info,  Node: io<5>,  Next: ipaddress<4>,  Prev: inspect<7>,  Up: 改良されたモジュール<7>

1.9.5.33 io
...........

A new *note BufferedIOBase.readinto1(): de8. method, that uses at most
one call to the underlying raw stream's *note RawIOBase.read(): de9. or
*note RawIOBase.readinto(): dea. methods.  (Contributed by Nikolaus Rath
in bpo-20578(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20578


File: python.info,  Node: ipaddress<4>,  Next: json<2>,  Prev: io<5>,  Up: 改良されたモジュール<7>

1.9.5.34 ipaddress
..................

Both the *note IPv4Network: 1df. and *note IPv6Network: 1e0. classes now
accept an ‘(address, netmask)’ tuple argument, so as to easily construct
network objects from existing addresses:

     >>> import ipaddress
     >>> ipaddress.IPv4Network(('127.0.0.0', 8))
     IPv4Network('127.0.0.0/8')
     >>> ipaddress.IPv4Network(('127.0.0.0', '255.0.0.0'))
     IPv4Network('127.0.0.0/8')

(Contributed by Peter Moody and Antoine Pitrou in bpo-16531(1).)

A new ‘reverse_pointer’ attribute for the *note IPv4Network: 1df. and
*note IPv6Network: 1e0. classes returns the name of the reverse DNS PTR
record:

     >>> import ipaddress
     >>> addr = ipaddress.IPv4Address('127.0.0.1')
     >>> addr.reverse_pointer
     '1.0.0.127.in-addr.arpa'
     >>> addr6 = ipaddress.IPv6Address('::1')
     >>> addr6.reverse_pointer
     '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa'

(Contributed by Leon Weber in bpo-20480(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16531

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20480


File: python.info,  Node: json<2>,  Next: linecache<2>,  Prev: ipaddress<4>,  Up: 改良されたモジュール<7>

1.9.5.35 json
.............

The *note json.tool: 77. command line interface now preserves the order
of keys in JSON objects passed in input.  The new ‘--sort-keys’ option
can be used to sort the keys alphabetically.  (Contributed by Berker
Peksag in bpo-21650(1).)

JSON decoder now raises *note JSONDecodeError: ded. instead of *note
ValueError: 1e3. to provide better context information about the error.
(Contributed by Serhiy Storchaka in bpo-19361(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21650

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19361


File: python.info,  Node: linecache<2>,  Next: locale<6>,  Prev: json<2>,  Up: 改良されたモジュール<7>

1.9.5.36 linecache
..................

A new *note lazycache(): def. function can be used to capture
information about a non-file-based module to permit getting its lines
later via *note getline(): df0.  This avoids doing I/O until a line is
actually needed, without having to carry the module globals around
indefinitely.  (Contributed by Robert Collins in bpo-17911(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17911


File: python.info,  Node: locale<6>,  Next: logging<5>,  Prev: linecache<2>,  Up: 改良されたモジュール<7>

1.9.5.37 locale
...............

A new *note delocalize(): df2. function can be used to convert a string
into a normalized number string, taking the ‘LC_NUMERIC’ settings into
account:

     >>> import locale
     >>> locale.setlocale(locale.LC_NUMERIC, 'de_DE.UTF-8')
     'de_DE.UTF-8'
     >>> locale.delocalize('1.234,56')
     '1234.56'
     >>> locale.setlocale(locale.LC_NUMERIC, 'en_US.UTF-8')
     'en_US.UTF-8'
     >>> locale.delocalize('1,234.56')
     '1234.56'

(Contributed by Cédric Krier in bpo-13918(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13918


File: python.info,  Node: logging<5>,  Next: lzma,  Prev: locale<6>,  Up: 改良されたモジュール<7>

1.9.5.38 logging
................

All logging methods (*note Logger: b1d. *note log(): df4, *note
exception(): df5, *note critical(): df6, *note debug(): df7, etc.), now
accept exception instances as an 'exc_info' argument, in addition to
boolean values and exception tuples:

     >>> import logging
     >>> try:
     ...     1/0
     ... except ZeroDivisionError as ex:
     ...     logging.error('exception', exc_info=ex)
     ERROR:root:exception

(Contributed by Yury Selivanov in bpo-20537(1).)

The *note handlers.HTTPHandler: df8. class now accepts an optional *note
ssl.SSLContext: 274. instance to configure SSL settings used in an HTTP
connection.  (Contributed by Alex Gaynor in bpo-22788(2).)

The *note handlers.QueueListener: df9. class now takes a
'respect_handler_level' keyword argument which, if set to ‘True’, will
pass messages to handlers taking handler levels into account.
(Contributed by Vinay Sajip.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20537

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22788


File: python.info,  Node: lzma,  Next: math<8>,  Prev: logging<5>,  Up: 改良されたモジュール<7>

1.9.5.39 lzma
.............

The *note LZMADecompressor.decompress(): dfb. method now accepts an
optional 'max_length' argument to limit the maximum size of decompressed
data.  (Contributed by Martin Panter in bpo-15955(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15955


File: python.info,  Node: math<8>,  Next: multiprocessing<6>,  Prev: lzma,  Up: 改良されたモジュール<7>

1.9.5.40 math
.............

*note math: 81. モジュールに定数 *note inf: c50. および *note nan: 62f.
が追加されました。 (Contributed by Mark Dickinson in bpo-23185(1).)

新たな関数 *note isclose(): d7d. は近似的に等しいことを調べる方法を提供
します。 (Contributed by Chris Barker and Tal Einat in bpo-24270(2).)

新たに関数 *note gcd(): 8de. が追加されました。 関数 ‘fractions.gcd()’ は
非推奨です。 (Contributed by Mark Dickinson and Serhiy Storchaka in
bpo-22486(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23185

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24270

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22486


File: python.info,  Node: multiprocessing<6>,  Next: operator<2>,  Prev: math<8>,  Up: 改良されたモジュール<7>

1.9.5.41 multiprocessing
........................

*note sharedctypes.synchronized(): dfe. オブジェクトが *note
コンテキストマネージャ: 59e. プロトコルをサポートするようになりました。
(Contributed by Charles-François Natali in bpo-21565(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21565


File: python.info,  Node: operator<2>,  Next: os<10>,  Prev: multiprocessing<6>,  Up: 改良されたモジュール<7>

1.9.5.42 operator
.................

*note attrgetter(): e00, *note itemgetter(): a30, and *note
methodcaller(): e01. objects now support pickling.  (Contributed by Josh
Rosenberg and Serhiy Storchaka in bpo-22955(1).)

行列乗算を行う *note matmul(): e02. 関数と *note imatmul(): e03. 関数が
新しく追加されました。 (Contributed by Benjamin Peterson in
bpo-21176(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22955

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21176


File: python.info,  Node: os<10>,  Next: pathlib<10>,  Prev: operator<2>,  Up: 改良されたモジュール<7>

1.9.5.43 os
...........

The new *note scandir(): a2d. function returning an iterator of *note
DirEntry: 468. objects has been added.  If possible, *note scandir():
a2d. extracts file attributes while scanning a directory, removing the
need to perform subsequent system calls to determine file type or
attributes, which may significantly improve performance.  (Contributed
by Ben Hoyt with the help of Victor Stinner in bpo-22524(1).)

Windows において、新たに *note stat_result.st_file_attributes: e05. 属性
が利用可能です。これは Windows API の ‘GetFileInformationByHandle()’ か
ら返る ‘BY_HANDLE_FILE_INFORMATION’ 構造体のメンバ ‘dwFileAttributes’ に
対応します。 (Contributed by Ben Hoyt in bpo-21719(2).)

*note urandom(): 4ec. 関数が、Linux 3.17 以降ではシステムコール
‘getrandom()’ を、OpenBSD 5.6 以降ではシステムコール ‘getentropy()’ を使
うようになりました。これは ‘/dev/urandom’ を使う必要性をなくし、潜在的に
は起こり得たファイル記述子を使い果たすことによる失敗を避けることに繋がり
ます。 (Contributed by Victor Stinner in bpo-22181(3).)

New *note get_blocking(): e06. and *note set_blocking(): e07. functions
allow getting and setting a file descriptor's blocking mode (*note
O_NONBLOCK: e08.)  (Contributed by Victor Stinner in bpo-22054(4).)

*note truncate(): e09. と *note ftruncate(): d5c. が Windows でサポート
されるようになりました。 (Contributed by Steve Dower in bpo-23668(5).)

There is a new *note os.path.commonpath(): e0a. function returning the
longest common sub-path of each passed pathname.  Unlike the *note
os.path.commonprefix(): e0b. function, it always returns a valid path:

     >>> os.path.commonprefix(['/usr/lib', '/usr/local/lib'])
     '/usr/l'

     >>> os.path.commonpath(['/usr/lib', '/usr/local/lib'])
     '/usr'

(Contributed by Rafik Draoui and Serhiy Storchaka in bpo-10395(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22524

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21719

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22181

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22054

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23668

   (6) https://bugs.python.org/issue?@action=redirect&bpo=10395


File: python.info,  Node: pathlib<10>,  Next: pickle<3>,  Prev: os<10>,  Up: 改良されたモジュール<7>

1.9.5.44 pathlib
................

The new *note Path.samefile(): e0d. method can be used to check whether
the path points to the same file as another path, which can be either
another *note Path: 20a. object, or a string:

     >>> import pathlib
     >>> p1 = pathlib.Path('/etc/hosts')
     >>> p2 = pathlib.Path('/etc/../etc/hosts')
     >>> p1.samefile(p2)
     True

(Contributed by Vajrasky Kok and Antoine Pitrou in bpo-19775(1).)

The *note Path.mkdir(): e0e. method now accepts a new optional
'exist_ok' argument to match ‘mkdir -p’ and *note os.makedirs(): 1ff.
functionality.  (Contributed by Berker Peksag in bpo-21539(2).)

There is a new *note Path.expanduser(): e0f. method to expand ‘~’ and
‘~user’ prefixes.  (Contributed by Serhiy Storchaka and Claudiu Popa in
bpo-19776(3).)

A new *note Path.home(): e10. class method can be used to get a *note
Path: 20a. instance representing the user’s home directory.
(Contributed by Victor Salgado and Mayank Tripathi in bpo-19777(4).)

New *note Path.write_text(): e11, *note Path.read_text(): e12, *note
Path.write_bytes(): e13, *note Path.read_bytes(): e14. methods to
simplify read/write operations on files.

The following code snippet will create or rewrite existing file
‘~/spam42’:

     >>> import pathlib
     >>> p = pathlib.Path('~/spam42')
     >>> p.expanduser().write_text('ham')
     3

(Contributed by Christopher Welborn in bpo-20218(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19775

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21539

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19776

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19777

   (5) https://bugs.python.org/issue?@action=redirect&bpo=20218


File: python.info,  Node: pickle<3>,  Next: poplib<2>,  Prev: pathlib<10>,  Up: 改良されたモジュール<7>

1.9.5.45 pickle
...............

Nested objects, such as unbound methods or nested classes, can now be
pickled using *note pickle protocols: c8f. older than protocol version
4.  Protocol version 4 already supports these cases.  (Contributed by
Serhiy Storchaka in bpo-23611(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23611


File: python.info,  Node: poplib<2>,  Next: re<7>,  Prev: pickle<3>,  Up: 改良されたモジュール<7>

1.9.5.46 poplib
...............

A new *note POP3.utf8(): e17. command enables RFC 6856(1)
(Internationalized Email) support, if a POP server supports it.
(Contributed by Milan OberKirch in bpo-21804(2).)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc6856.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21804


File: python.info,  Node: re<7>,  Next: readline<2>,  Prev: poplib<2>,  Up: 改良されたモジュール<7>

1.9.5.47 re
...........

References and conditional references to groups with fixed length are
now allowed in lookbehind assertions:

     >>> import re
     >>> pat = re.compile(r'(a|b).(?<=\1)c')
     >>> pat.match('aac')
     <_sre.SRE_Match object; span=(0, 3), match='aac'>
     >>> pat.match('bbc')
     <_sre.SRE_Match object; span=(0, 3), match='bbc'>

(Contributed by Serhiy Storchaka in bpo-9179(1).)

The number of capturing groups in regular expressions is no longer
limited to 100.  (Contributed by Serhiy Storchaka in bpo-22437(2).)

The *note sub(): 283. and *note subn(): 284. functions now replace
unmatched groups with empty strings instead of raising an exception.
(Contributed by Serhiy Storchaka in bpo-1519638(3).)

The ‘re.error’ exceptions have new attributes, ‘msg’, ‘pattern’, ‘pos’,
‘lineno’, and ‘colno’, that provide better context information about the
error:

     >>> re.compile("""
     ...     (?x)
     ...     .++
     ... """)
     Traceback (most recent call last):
        ...
     sre_constants.error: multiple repeat at position 16 (line 3, column 7)

(Contributed by Serhiy Storchaka in bpo-22578(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9179

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22437

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1519638

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22578


File: python.info,  Node: readline<2>,  Next: selectors,  Prev: re<7>,  Up: 改良されたモジュール<7>

1.9.5.48 readline
.................

A new *note append_history_file(): e1a. function can be used to append
the specified number of trailing elements in history to the given file.
(Contributed by Bruno Cauet in bpo-22940(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22940


File: python.info,  Node: selectors,  Next: shutil<5>,  Prev: readline<2>,  Up: 改良されたモジュール<7>

1.9.5.49 selectors
..................

The new *note DevpollSelector: ba5. supports efficient ‘/dev/poll’
polling on Solaris.  (Contributed by Giampaolo Rodola' in bpo-18931(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18931


File: python.info,  Node: shutil<5>,  Next: signal<3>,  Prev: selectors,  Up: 改良されたモジュール<7>

1.9.5.50 shutil
...............

The *note move(): a2a. function now accepts a 'copy_function' argument,
allowing, for example, the *note copy(): a28. function to be used
instead of the default *note copy2(): a29. if there is a need to ignore
file metadata when moving.  (Contributed by Claudiu Popa in
bpo-19840(1).)

The *note make_archive(): 47f. function now supports the 'xztar' format.
(Contributed by Serhiy Storchaka in bpo-5411(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19840

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5411


File: python.info,  Node: signal<3>,  Next: smtpd<2>,  Prev: shutil<5>,  Up: 改良されたモジュール<7>

1.9.5.51 signal
...............

Windows において、 *note set_wakeup_fd(): b3e. 関数がソケットハンドルも
サポートするようになりました。 (Contributed by Victor Stinner in
bpo-22018(1).)

Various ‘SIG*’ constants in the *note signal: b4. module have been
converted into *note Enums: 4c.  This allows meaningful names to be
printed during debugging, instead of integer "magic numbers".
(Contributed by Giampaolo Rodola' in bpo-21076(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22018

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21076


File: python.info,  Node: smtpd<2>,  Next: smtplib<2>,  Prev: signal<3>,  Up: 改良されたモジュール<7>

1.9.5.52 smtpd
..............

Both the ‘SMTPServer’ and ‘SMTPChannel’ classes now accept a
'decode_data' keyword argument to determine if the ‘DATA’ portion of the
SMTP transaction is decoded using the ‘"utf-8"’ codec or is instead
provided to the ‘SMTPServer.process_message()’ method as a byte string.
The default is ‘True’ for backward compatibility reasons, but will
change to ‘False’ in Python 3.6.  If 'decode_data' is set to ‘False’,
the ‘process_message’ method must be prepared to accept keyword
arguments.  (Contributed by Maciej Szulik in bpo-19662(1).)

The ‘SMTPServer’ class now advertises the ‘8BITMIME’ extension ( RFC
6152(2)) if 'decode_data' has been set ‘True’.  If the client specifies
‘BODY=8BITMIME’ on the ‘MAIL’ command, it is passed to
‘SMTPServer.process_message()’ via the 'mail_options' keyword.
(Contributed by Milan Oberkirch and R. David Murray in bpo-21795(3).)

The ‘SMTPServer’ class now also supports the ‘SMTPUTF8’ extension ( RFC
6531(4): Internationalized Email).  If the client specified ‘SMTPUTF8
BODY=8BITMIME’ on the ‘MAIL’ command, they are passed to
‘SMTPServer.process_message()’ via the 'mail_options' keyword.  It is
the responsibility of the ‘process_message’ method to correctly handle
the ‘SMTPUTF8’ data.  (Contributed by Milan Oberkirch in bpo-21725(5).)

It is now possible to provide, directly or via name resolution, IPv6
addresses in the ‘SMTPServer’ constructor, and have it successfully
connect.  (Contributed by Milan Oberkirch in bpo-14758(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19662

   (2) https://datatracker.ietf.org/doc/html/rfc6152.html

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21795

   (4) https://datatracker.ietf.org/doc/html/rfc6531.html

   (5) https://bugs.python.org/issue?@action=redirect&bpo=21725

   (6) https://bugs.python.org/issue?@action=redirect&bpo=14758


File: python.info,  Node: smtplib<2>,  Next: sndhdr,  Prev: smtpd<2>,  Up: 改良されたモジュール<7>

1.9.5.53 smtplib
................

A new *note SMTP.auth(): e20. method provides a convenient way to
implement custom authentication mechanisms.  (Contributed by Milan
Oberkirch in bpo-15014(1).)

The *note SMTP.set_debuglevel(): e21. method now accepts an additional
debuglevel (2), which enables timestamps in debug messages.
(Contributed by Gavin Chappell and Maciej Szulik in bpo-16914(2).)

Both the *note SMTP.sendmail(): e22. and *note SMTP.send_message(): e23.
methods now support RFC 6531(3) (SMTPUTF8).  (Contributed by Milan
Oberkirch and R. David Murray in bpo-22027(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15014

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16914

   (3) https://datatracker.ietf.org/doc/html/rfc6531.html

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22027


File: python.info,  Node: sndhdr,  Next: socket<8>,  Prev: smtplib<2>,  Up: 改良されたモジュール<7>

1.9.5.54 sndhdr
...............

The ‘what()’ and ‘whathdr()’ functions now return a *note namedtuple():
1ac.  (Contributed by Claudiu Popa in bpo-18615(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18615


File: python.info,  Node: socket<8>,  Next: ssl<9>,  Prev: sndhdr,  Up: 改良されたモジュール<7>

1.9.5.55 socket
...............

Functions with timeouts now use a monotonic clock, instead of a system
clock.  (Contributed by Victor Stinner in bpo-22043(1).)

A new *note socket.sendfile(): e26. method allows sending a file over a
socket by using the high-performance *note os.sendfile(): add. function
on UNIX, resulting in uploads being from 2 to 3 times faster than when
using plain *note socket.send(): d74.  (Contributed by Giampaolo Rodola'
in bpo-17552(2).)

The *note socket.sendall(): d75. method no longer resets the socket
timeout every time bytes are received or sent.  The socket timeout is
now the maximum total duration to send all data.  (Contributed by Victor
Stinner in bpo-23853(3).)

The 'backlog' argument of the *note socket.listen(): e27. method is now
optional.  By default it is set to *note SOMAXCONN: e28. or to ‘128’,
whichever is less.  (Contributed by Charles-François Natali in
bpo-21455(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22043

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17552

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23853

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21455


File: python.info,  Node: ssl<9>,  Next: sqlite3<8>,  Prev: socket<8>,  Up: 改良されたモジュール<7>

1.9.5.56 ssl
............

* Menu:

* メモリ BIO サポート::
* Application-Layer Protocol Negotiation Support::
* その他の変更::


File: python.info,  Node: メモリ BIO サポート,  Next: Application-Layer Protocol Negotiation Support,  Up: ssl<9>

1.9.5.57 メモリ BIO サポート
............................

(Contributed by Geert Jansen in bpo-21965(1).)

The new *note SSLObject: b4f. class has been added to provide SSL
protocol support for cases when the network I/O capabilities of *note
SSLSocket: 8b8. are not necessary or are suboptimal.  ‘SSLObject’
represents an SSL protocol instance, but does not implement any network
I/O methods, and instead provides a memory buffer interface.  The new
*note MemoryBIO: e2b. class can be used to pass data between Python and
an SSL protocol instance.

The memory BIO SSL support is primarily intended to be used in
frameworks implementing asynchronous I/O for which *note SSLSocket:
8b8.'s readiness model ("select/poll") is inefficient.

A new *note SSLContext.wrap_bio(): b50. method can be used to create a
new ‘SSLObject’ instance.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21965


File: python.info,  Node: Application-Layer Protocol Negotiation Support,  Next: その他の変更,  Prev: メモリ BIO サポート,  Up: ssl<9>

1.9.5.58 Application-Layer Protocol Negotiation Support
.......................................................

(Contributed by Benjamin Peterson in bpo-20188(1).)

Where OpenSSL support is present, the *note ssl: bb. module now
implements the 'Application-Layer Protocol Negotiation' TLS extension as
described in RFC 7301(2).

The new *note SSLContext.set_alpn_protocols(): e2d. can be used to
specify which protocols a socket should advertise during the TLS
handshake.

The new *note SSLSocket.selected_alpn_protocol(): e2e. returns the
protocol that was selected during the TLS handshake.  The *note
HAS_ALPN: e2f. flag indicates whether ALPN support is present.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20188

   (2) https://datatracker.ietf.org/doc/html/rfc7301.html


File: python.info,  Node: その他の変更,  Prev: Application-Layer Protocol Negotiation Support,  Up: ssl<9>

1.9.5.59 その他の変更
.....................

There is a new *note SSLSocket.version(): e31. method to query the
actual protocol version in use.  (Contributed by Antoine Pitrou in
bpo-20421(1).)

The *note SSLSocket: 8b8. class now implements a ‘SSLSocket.sendfile()’
method.  (Contributed by Giampaolo Rodola' in bpo-17552(2).)

The ‘SSLSocket.send()’ method now raises either the *note
ssl.SSLWantReadError: e32. or *note ssl.SSLWantWriteError: e33.
exception on a non-blocking socket if the operation would block.
Previously, it would return ‘0’.  (Contributed by Nikolaus Rath in
bpo-20951(3).)

The *note cert_time_to_seconds(): e34. function now interprets the input
time as UTC and not as local time, per RFC 5280(4).  Additionally, the
return value is always an *note int: 238.  (Contributed by Akira Li in
bpo-19940(5).)

New ‘SSLObject.shared_ciphers()’ and *note SSLSocket.shared_ciphers():
e35. methods return the list of ciphers sent by the client during the
handshake.  (Contributed by Benjamin Peterson in bpo-23186(6).)

The *note SSLSocket.do_handshake(): e36, *note SSLSocket.read(): e37,
‘SSLSocket.shutdown()’, and *note SSLSocket.write(): e38. methods of the
*note SSLSocket: 8b8. class no longer reset the socket timeout every
time bytes are received or sent.  The socket timeout is now the maximum
total duration of the method.  (Contributed by Victor Stinner in
bpo-23853(7).)

The ‘match_hostname()’ function now supports matching of IP addresses.
(Contributed by Antoine Pitrou in bpo-23239(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20421

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17552

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20951

   (4) https://datatracker.ietf.org/doc/html/rfc5280.html

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19940

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23186

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23853

   (8) https://bugs.python.org/issue?@action=redirect&bpo=23239


File: python.info,  Node: sqlite3<8>,  Next: subprocess<4>,  Prev: ssl<9>,  Up: 改良されたモジュール<7>

1.9.5.60 sqlite3
................

The *note Row: e3a. class now fully supports the sequence protocol, in
particular *note reversed(): 831. iteration and slice indexing.
(Contributed by Claudiu Popa in bpo-10203(1); by Lucas Sinclair, Jessica
McKellar, and Serhiy Storchaka in bpo-13583(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10203

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13583


File: python.info,  Node: subprocess<4>,  Next: sys<11>,  Prev: sqlite3<8>,  Up: 改良されたモジュール<7>

1.9.5.61 subprocess
...................

新たに *note run(): b54. 関数が追加されました。 これは指定されたコマンド
を実行し *note CompletedProcess: e3c. オブジェクトを返します。 オブジェ
クトは終了したプロセスを記述します。 新たな API はより一貫的で、古いバー
ジョンとの互換性を必要としない Python コードでサブプロセスを起動するのに
推奨される方法です。 (Contributed by Thomas Kluyver in bpo-23342(1).)

例:

     >>> subprocess.run(["ls", "-l"])  # doesn't capture output
     CompletedProcess(args=['ls', '-l'], returncode=0)

     >>> subprocess.run("exit 1", shell=True, check=True)
     Traceback (most recent call last):
       ...
     subprocess.CalledProcessError: Command 'exit 1' returned non-zero exit status 1

     >>> subprocess.run(["ls", "-l", "/dev/null"], stdout=subprocess.PIPE)
     CompletedProcess(args=['ls', '-l', '/dev/null'], returncode=0,
     stdout=b'crw-rw-rw- 1 root root 1, 3 Jan 23 16:23 /dev/null\n')

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23342


File: python.info,  Node: sys<11>,  Next: sysconfig<2>,  Prev: subprocess<4>,  Up: 改良されたモジュール<7>

1.9.5.62 sys
............

A new ‘set_coroutine_wrapper()’ function allows setting a global hook
that will be called whenever a *note coroutine object: 45e. is created
by an *note async def: 59b. function.  A corresponding
‘get_coroutine_wrapper()’ can be used to obtain a currently set wrapper.
Both functions are *note provisional: ad1, and are intended for
debugging purposes only.  (Contributed by Yury Selivanov in
bpo-24017(1).)

A new *note is_finalizing(): a5d. function can be used to check if the
Python interpreter is *note shutting down: 134.  (Contributed by Antoine
Pitrou in bpo-22696(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24017

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22696


File: python.info,  Node: sysconfig<2>,  Next: tarfile<6>,  Prev: sys<11>,  Up: 改良されたモジュール<7>

1.9.5.63 sysconfig
..................

The name of the user scripts directory on Windows now includes the first
two components of the Python version.  (Contributed by Paul Moore in
bpo-23437(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23437


File: python.info,  Node: tarfile<6>,  Next: threading<6>,  Prev: sysconfig<2>,  Up: 改良されたモジュール<7>

1.9.5.64 tarfile
................

*note open(): e40. 関数の 'mode' 引数が排他的作成を要求する ‘"x"’ を受け
取るようになりました。 (Contributed by Berker Peksag in bpo-21717(1).)

The *note TarFile.extractall(): e41. and *note TarFile.extract(): e42.
methods now take a keyword argument 'numeric_owner'.  If set to ‘True’,
the extracted files and directories will be owned by the numeric ‘uid’
and ‘gid’ from the tarfile.  If set to ‘False’ (the default, and the
behavior in versions prior to 3.5), they will be owned by the named user
and group in the tarfile.  (Contributed by Michael Vogt and Eric Smith
in bpo-23193(2).)

The *note TarFile.list(): e43. now accepts an optional 'members' keyword
argument that can be set to a subset of the list returned by *note
TarFile.getmembers(): e44.  (Contributed by Serhiy Storchaka in
bpo-21549(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21717

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23193

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21549


File: python.info,  Node: threading<6>,  Next: time<7>,  Prev: tarfile<6>,  Up: 改良されたモジュール<7>

1.9.5.65 threading
..................

*note Lock.acquire(): 664. と *note RLock.acquire(): e46. の両メソッドが
タイムアウトの管理に単調時計を使用するようになりました。 (Contributed by
Victor Stinner in bpo-22043(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22043


File: python.info,  Node: time<7>,  Next: timeit<2>,  Prev: threading<6>,  Up: 改良されたモジュール<7>

1.9.5.66 time
.............

*note monotonic(): 234. 関数が常に利用出来るようになりました。
(Contributed by Victor Stinner in bpo-22043(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22043


File: python.info,  Node: timeit<2>,  Next: tkinter<8>,  Prev: time<7>,  Up: 改良されたモジュール<7>

1.9.5.67 timeit
...............

新たなコマンドラインオプション ‘-u’ 又は ‘--unit=U’ を使用してタイマーの
出力の単位を指定できます。 サポートされたオプションは ‘usec’, ‘msec’,
‘sec’ です。 (Contributed by Julian Gindi in bpo-18983(1).)

*note timeit(): e49. 関数に引数 'globals' が追加されました。 これにより
コードが実行される名前空間を指定します。 (Contributed by Ben Roberts in
bpo-2527(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18983

   (2) https://bugs.python.org/issue?@action=redirect&bpo=2527


File: python.info,  Node: tkinter<8>,  Next: traceback<5>,  Prev: timeit<2>,  Up: 改良されたモジュール<7>

1.9.5.68 tkinter
................

The ‘tkinter._fix’ module used for setting up the Tcl/Tk environment on
Windows has been replaced by a private function in the ‘_tkinter’ module
which makes no permanent changes to environment variables.  (Contributed
by Zachary Ware in bpo-20035(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20035


File: python.info,  Node: traceback<5>,  Next: types<5>,  Prev: tkinter<8>,  Up: 改良されたモジュール<7>

1.9.5.69 traceback
..................

New *note walk_stack(): e4c. and *note walk_tb(): e4d. functions to
conveniently traverse frame and *note traceback objects: ac2.
(Contributed by Robert Collins in bpo-17911(1).)

New lightweight classes: *note TracebackException: 23d, *note
StackSummary: e4e, and *note FrameSummary: e4f.  (Contributed by Robert
Collins in bpo-17911(2).)

Both the *note print_tb(): e50. and *note print_stack(): e51. functions
now support negative values for the 'limit' argument.  (Contributed by
Dmitry Kazakov in bpo-22619(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17911

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17911

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22619


File: python.info,  Node: types<5>,  Next: unicodedata<8>,  Prev: traceback<5>,  Up: 改良されたモジュール<7>

1.9.5.70 types
..............

新たに *note coroutine(): e53. 関数が追加されました。 *note
ジェネレータ: bac. と *note ジェネレータ様: da8. オブジェクトを *note
awaitable: 192. に変換します。 (Contributed by Yury Selivanov in
bpo-24017(1).)

新たに型 *note CoroutineType: e54. が追加されました。 *note async def:
59b. 関数で作られた *note coroutine: 45e. オブジェクトに使われます。
(Contributed by Yury Selivanov in bpo-24400(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24017

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24400


File: python.info,  Node: unicodedata<8>,  Next: unittest<8>,  Prev: types<5>,  Up: 改良されたモジュール<7>

1.9.5.71 unicodedata
....................

The *note unicodedata: ee. module now uses data from Unicode 8.0.0(1).

   ---------- Footnotes ----------

   (1) https://unicode.org/versions/Unicode8.0.0/


File: python.info,  Node: unittest<8>,  Next: unittest mock<3>,  Prev: unicodedata<8>,  Up: 改良されたモジュール<7>

1.9.5.72 unittest
.................

The *note TestLoader.loadTestsFromModule(): 26f. method now accepts a
keyword-only argument 'pattern' which is passed to ‘load_tests’ as the
third argument.  Found packages are now checked for ‘load_tests’
regardless of whether their path matches 'pattern', because it is
impossible for a package name to match the default pattern.
(Contributed by Robert Collins and Barry A. Warsaw in bpo-16662(1).)

Unittest discovery errors now are exposed in the *note
TestLoader.errors: e57. attribute of the *note TestLoader: 26e.
instance.  (Contributed by Robert Collins in bpo-19746(2).)

A new command line option ‘--locals’ to show local variables in
tracebacks.  (Contributed by Robert Collins in bpo-22936(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16662

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19746

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22936


File: python.info,  Node: unittest mock<3>,  Next: urllib<2>,  Prev: unittest<8>,  Up: 改良されたモジュール<7>

1.9.5.73 unittest.mock
......................

*note Mock: a1a. クラスは、次の改善が行われました。

   * The class constructor has a new 'unsafe' parameter, which causes
     mock objects to raise *note AttributeError: 326. on attribute names
     starting with ‘"assert"’.  (Contributed by Kushal Das in
     bpo-21238(1).)

   * A new *note Mock.assert_not_called(): e59. method to check if the
     mock object was called.  (Contributed by Kushal Das in
     bpo-21262(2).)

The *note MagicMock: e5a. class now supports ‘__truediv__()’,
‘__divmod__()’ and ‘__matmul__()’ operators.  (Contributed by Johannes
Baiter in bpo-20968(3), and Håkan Lövdahl in bpo-23581(4) and
bpo-23568(5).)

It is no longer necessary to explicitly pass ‘create=True’ to the *note
patch(): e5b. function when patching builtin names.  (Contributed by
Kushal Das in bpo-17660(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21238

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21262

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20968

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23581

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23568

   (6) https://bugs.python.org/issue?@action=redirect&bpo=17660


File: python.info,  Node: urllib<2>,  Next: wsgiref,  Prev: unittest mock<3>,  Up: 改良されたモジュール<7>

1.9.5.74 urllib
...............

A new *note request.HTTPPasswordMgrWithPriorAuth: e5d. class allows HTTP
Basic Authentication credentials to be managed so as to eliminate
unnecessary ‘401’ response handling, or to unconditionally send
credentials on the first request in order to communicate with servers
that return a ‘404’ response instead of a ‘401’ if the ‘Authorization’
header is not sent.  (Contributed by Matej Cepl in bpo-19494(1) and
Akshit Khurana in bpo-7159(2).)

A new 'quote_via' argument for the *note parse.urlencode(): e5e.
function provides a way to control the encoding of query parts if
needed.  (Contributed by Samwyse and Arnon Yaari in bpo-13866(3).)

The *note request.urlopen(): 273. function accepts an *note
ssl.SSLContext: 274. object as a 'context' argument, which will be used
for the HTTPS connection.  (Contributed by Alex Gaynor in bpo-22366(4).)

The *note parse.urljoin(): e5f. was updated to use the RFC 3986(5)
semantics for the resolution of relative URLs, rather than RFC 1808(6)
and RFC 2396(7).  (Contributed by Demian Brecht and Senthil Kumaran in
bpo-22118(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19494

   (2) https://bugs.python.org/issue?@action=redirect&bpo=7159

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13866

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22366

   (5) https://datatracker.ietf.org/doc/html/rfc3986.html

   (6) https://datatracker.ietf.org/doc/html/rfc1808.html

   (7) https://datatracker.ietf.org/doc/html/rfc2396.html

   (8) https://bugs.python.org/issue?@action=redirect&bpo=22118


File: python.info,  Node: wsgiref,  Next: xmlrpc<2>,  Prev: urllib<2>,  Up: 改良されたモジュール<7>

1.9.5.75 wsgiref
................

The 'headers' argument of the *note headers.Headers: e61. class
constructor is now optional.  (Contributed by Pablo Torres Navarrete and
SilentGhost in bpo-5800(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5800


File: python.info,  Node: xmlrpc<2>,  Next: xml sax,  Prev: wsgiref,  Up: 改良されたモジュール<7>

1.9.5.76 xmlrpc
...............

*note client.ServerProxy: a25. クラスが *note コンテキストマネージャ:
59e. プロトコルをサポートするようになりました。 (Contributed by Claudiu
Popa in bpo-20627(1).)

*note client.ServerProxy: a25. コンストラクタは任意の *note
ssl.SSLContext: 274. インスタンスを受け取るようになりました。
(Contributed by Alex Gaynor in bpo-22960(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20627

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22960


File: python.info,  Node: xml sax,  Next: zipfile<4>,  Prev: xmlrpc<2>,  Up: 改良されたモジュール<7>

1.9.5.77 xml.sax
................

SAX パーサは *note xmlreader.InputSource: e64. オブジェクトの文字ストリ
ームをサポートしました。 (Contributed by Serhiy Storchaka in
bpo-2175(1).)

*note parseString(): e65. が *note str: 418. インスタンスを受け取るよう
になりました。 (Contributed by Serhiy Storchaka in bpo-10590(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2175

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10590


File: python.info,  Node: zipfile<4>,  Prev: xml sax,  Up: 改良されたモジュール<7>

1.9.5.78 zipfile
................

ZIP output can now be written to unseekable streams.  (Contributed by
Serhiy Storchaka in bpo-23252(1).)

*note ZipFile.open(): 3f4. メソッドの 'mode' 引数が排他的作成を要求する
‘"x"’ を受け取るようになりました。 (Contributed by Serhiy Storchaka in
bpo-21717(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23252

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21717


File: python.info,  Node: その他のモジュールレベルの変更,  Next: 最適化<7>,  Prev: 改良されたモジュール<7>,  Up: What's New In Python 3 5

1.9.6 その他のモジュールレベルの変更
------------------------------------

Many functions in the *note mmap: 83, ‘ossaudiodev’, *note socket: b8,
*note ssl: bb, and *note codecs: 14. modules now accept writable *note
bytes-like objects: cfb.  (Contributed by Serhiy Storchaka in
bpo-23001(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23001


File: python.info,  Node: 最適化<7>,  Next: ビルドならびに C API の変更<3>,  Prev: その他のモジュールレベルの変更,  Up: What's New In Python 3 5

1.9.7 最適化
------------

The *note os.walk(): 476. function has been sped up by 3 to 5 times on
POSIX systems, and by 7 to 20 times on Windows.  This was done using the
new *note os.scandir(): a2d. function, which exposes file information
from the underlying ‘readdir’ or ‘FindFirstFile’/‘FindNextFile’ system
calls.  (Contributed by Ben Hoyt with help from Victor Stinner in
bpo-23605(1).)

Construction of ‘bytes(int)’ (filled by zero bytes) is faster and uses
less memory for large objects.  ‘calloc()’ is used instead of ‘malloc()’
to allocate memory for these objects.  (Contributed by Victor Stinner in
bpo-21233(2).)

Some operations on *note ipaddress: 74. *note IPv4Network: 1df. and
*note IPv6Network: 1e0. have been massively sped up, such as *note
subnets(): e69, *note supernet(): e6a, *note summarize_address_range():
e6b, *note collapse_addresses(): e6c.  The speed up can range from 3 to
15 times.  (Contributed by Antoine Pitrou, Michel Albert, and Markus in
bpo-21486(3), bpo-21487(4), bpo-20826(5), bpo-23266(6).)

Pickling of *note ipaddress: 74. objects was optimized to produce
significantly smaller output.  (Contributed by Serhiy Storchaka in
bpo-23133(7).)

*note io.BytesIO: e6d. の多くの操作が 50% から 100% 速くなりました。
(Contributed by Serhiy Storchaka in bpo-15381(8) and David Wilson in
bpo-22003(9).)

The *note marshal.dumps(): e6e. function is now faster: 65-85% with
versions 3 and 4, 20-25% with versions 0 to 2 on typical data, and up to
5 times in best cases.  (Contributed by Serhiy Storchaka in
bpo-20416(10) and bpo-23344(11).)

UTF-32 エンコーダが 3 から 7 倍速くなりました。 (Contributed by Serhiy
Storchaka in bpo-15027(12).)

正規表現のパースが最高で 10% 速くなりました。 (Contributed by Serhiy
Storchaka in bpo-19380(13).)

The *note json.dumps(): d13. function was optimized to run with
‘ensure_ascii=False’ as fast as with ‘ensure_ascii=True’.  (Contributed
by Naoki Inada in bpo-23206(14).)

The *note PyObject_IsInstance(): e6f. and *note PyObject_IsSubclass():
e70. functions have been sped up in the common case that the second
argument has *note type: d16. as its metaclass.  (Contributed Georg
Brandl by in bpo-22540(15).)

メソッドのキャッシュが少し改良されました。ベンチマークによっては性能が最
高で 5% 向上しました。 (Contributed by Antoine Pitrou in bpo-22847(16).)

*note random: a6. モジュールのオブジェクトのメモリ使用量が 64-bit ビルド
で 50% 減少しました。 (Contributed by Serhiy Storchaka in
bpo-23488(17).)

*note property(): 179. ゲッタの呼び出しが最高で 25% 速くなりました。
(Contributed by Joe Jevnik in bpo-23910(18).)

*note fractions.Fraction: 1c8. のインスタンス化が最高で 30% 速くなりまし
た。 (Contributed by Stefan Behnel in bpo-22464(19).)

String methods *note find(): e71, *note rfind(): e72, *note split():
e73, *note partition(): e74. and the *note in: 2cb. string operator are
now significantly faster for searching 1-character substrings.
(Contributed by Serhiy Storchaka in bpo-23573(20).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23605

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21233

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21486

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21487

   (5) https://bugs.python.org/issue?@action=redirect&bpo=20826

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23266

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23133

   (8) https://bugs.python.org/issue?@action=redirect&bpo=15381

   (9) https://bugs.python.org/issue?@action=redirect&bpo=22003

   (10) https://bugs.python.org/issue?@action=redirect&bpo=20416

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23344

   (12) https://bugs.python.org/issue?@action=redirect&bpo=15027

   (13) https://bugs.python.org/issue?@action=redirect&bpo=19380

   (14) https://bugs.python.org/issue?@action=redirect&bpo=23206

   (15) https://bugs.python.org/issue?@action=redirect&bpo=22540

   (16) https://bugs.python.org/issue?@action=redirect&bpo=22847

   (17) https://bugs.python.org/issue?@action=redirect&bpo=23488

   (18) https://bugs.python.org/issue?@action=redirect&bpo=23910

   (19) https://bugs.python.org/issue?@action=redirect&bpo=22464

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23573


File: python.info,  Node: ビルドならびに C API の変更<3>,  Next: 非推奨<8>,  Prev: 最適化<7>,  Up: What's New In Python 3 5

1.9.8 ビルドならびに C API の変更
---------------------------------

新たな ‘calloc’ 関数が追加されました:

   * *note PyMem_RawCalloc(): 36a,

   * *note PyMem_Calloc(): e76,

   * *note PyObject_Calloc(): e77.

(Contributed by Victor Stinner in bpo-21233(1).)

新たなエンコーディング/デコーディングヘルパ関数:

   * *note Py_DecodeLocale(): b95. (‘_Py_char2wchar()’ の代わり),

   * *note Py_EncodeLocale(): b96. (‘_Py_wchar2char()’ の代わり).

(Contributed by Victor Stinner in bpo-18395(2).)

A new *note PyCodec_NameReplaceErrors(): e78. function to replace the
unicode encode error with ‘\N{...}’ escapes.  (Contributed by Serhiy
Storchaka in bpo-19676(3).)

A new *note PyErr_FormatV(): e79. function similar to *note
PyErr_Format(): e7a, but accepts a ‘va_list’ argument.  (Contributed by
Antoine Pitrou in bpo-18711(4).)

A new ‘PyExc_RecursionError’ exception.  (Contributed by Georg Brandl in
bpo-19235(5).)

New *note PyModule_FromDefAndSpec(): e7b, *note
PyModule_FromDefAndSpec2(): e7c, and *note PyModule_ExecDef(): e7d.
functions introduced by PEP 489(6) - multi-phase extension module
initialization.  (Contributed by Petr Viktorin in bpo-24268(7).)

New *note PyNumber_MatrixMultiply(): e7e. and *note
PyNumber_InPlaceMatrixMultiply(): e7f. functions to perform matrix
multiplication.  (Contributed by Benjamin Peterson in bpo-21176(8).  See
also PEP 465(9) for details.)

The *note PyTypeObject.tp_finalize: a74. slot is now part of the stable
ABI.

Windows builds now require Microsoft Visual C++ 14.0, which is available
as part of Visual Studio 2015(10).

いくつかのプラットフォームにおいて、拡張モジュールのファイル名にプラット
フォームについての情報をタグとして含むようになりました (タグはオプショナ
ルであり、CPython は、タグが含まれていて実行しようとしているプラットフォ
ームとミスマッチな場合にその拡張をロードしようとしない一方で、拡張をそれ
が含まれていなくてもインポートします):

   * Linux では拡張モジュールのファイル名は
     ‘.cpython-<major><minor>m-<architecture>-<os>.pyd’ で終わります:

        * ‘<major>’ は Python バージョンのメジャー番号です。Python 3.5 で
          は ‘3’ です。

        * ‘<minor>’ は Python バージョンのマイナー番号です。Python 3.5 で
          は ‘5’ です。

        * ‘<architecture>’ は拡張モジュールがどのハードウェアアーキテク
          チャ向けに動作するようビルドされたのかを表します。32-bit Intel
          プラットフォーム向けの ‘i386’ か 64-bit Intel (及び AMD) プラ
          ットフォーム向けの ‘x86_64’ がもっとも一般的です。

        * ‘<os>’ は原則として ‘linux-gnu’ ですが、64-bit プラットフォー
          ムにおいて 32-bit ABI で動作するようビルドされた拡張モジュール
          の場合は ‘linux-gnu32’ になります (この場合 ‘<architecture>’ は
          ‘x86_64’ となるでしょう)。

   * Windows では拡張モジュールのファイル名は
     ‘<debug>.cp<major><minor>-<platform>.pyd’ で終わります:

        * ‘<major>’ は Python バージョンのメジャー番号です。Python 3.5 で
          は ‘3’ です。

        * ‘<minor>’ は Python バージョンのマイナー番号です。Python 3.5 で
          は ‘5’ です。

        * ‘<platform>’ は拡張モジュールがどのプラットフォーム向けにビル
          ドされたものなのかを表し、 Win32 用の ‘win32’ , Win64 用の
          ‘win_amd64’ , Windows Itanium 64 用の ‘win_ia64’ , Windows on
          ARM 用の ‘win_arm’ のいずれかです。

        * デバッグモードでビルドされた場合は ‘<debug>’ は ‘_d’ となり、
          それ以外の場合はブランクです。

   * OS X プラットフォームでは拡張モジュールのファイル名は ‘-darwin.so’
     で終わります。

   * 他のすべてのプラットフォームでは、拡張モジュールのファイル名は
     Python 3.4 でのものと同じです。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21233

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18395

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19676

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18711

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19235

   (6) https://peps.python.org/pep-0489/

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24268

   (8) https://bugs.python.org/issue?@action=redirect&bpo=21176

   (9) https://peps.python.org/pep-0465/

   (10) 
https://visualstudio.microsoft.com/en/vs/older-downloads/#visual-studio-2015-and-other-products


File: python.info,  Node: 非推奨<8>,  Next: 削除<8>,  Prev: ビルドならびに C API の変更<3>,  Up: What's New In Python 3 5

1.9.9 非推奨
------------

* Menu:

* 新たなキーワード: 新たなキーワード<2>.
* 非推奨の Python の挙動: 非推奨の Python の挙動<2>.
* サポートされないオペレーティングシステム::
* 非推奨の Python モジュール、関数、メソッド: 非推奨の Python モジュール、関数、メソッド<3>.


File: python.info,  Node: 新たなキーワード<2>,  Next: 非推奨の Python の挙動<2>,  Up: 非推奨<8>

1.9.9.1 新たなキーワード
........................

‘async’ および ‘await’ を変数、クラス、関数、ならびにモジュールの名前に
使用することは推奨されません。 それらは Python 3.5 で PEP 492(1) により
導入され、Python 3.7 で正式にキーワードになります。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0492/


File: python.info,  Node: 非推奨の Python の挙動<2>,  Next: サポートされないオペレーティングシステム,  Prev: 新たなキーワード<2>,  Up: 非推奨<8>

1.9.9.2 非推奨の Python の挙動
..............................

ジェネレータ内で *note StopIteration: bc8. 例外を送出すると現在は静かな
*note PendingDeprecationWarning: 895. が発生します。 これは、Python 3.6
では静かでない非推奨の警告となり、Python 3.7 では *note RuntimeError:
17a. を起こします。 詳細は *note PEP 479; Change StopIteration handling
inside generators: ced. を参照してください。


File: python.info,  Node: サポートされないオペレーティングシステム,  Next: 非推奨の Python モジュール、関数、メソッド<3>,  Prev: 非推奨の Python の挙動<2>,  Up: 非推奨<8>

1.9.9.3 サポートされないオペレーティングシステム
................................................

Windows XP は Microsoft によって既にサポートされていません。このため PEP
11(1) により、CPython 3.5 ではこの OS をもはや公式にはサポートしません。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0011/


File: python.info,  Node: 非推奨の Python モジュール、関数、メソッド<3>,  Prev: サポートされないオペレーティングシステム,  Up: 非推奨<8>

1.9.9.4 非推奨の Python モジュール、関数、メソッド
..................................................

‘formatter’ モジュールは完全に非推奨になり、Python 3.6 で削除される予定
です。

‘asyncio.async()’ 関数は *note ensure_future(): c44. により非推奨になり
ました。

The ‘smtpd’ module has in the past always decoded the DATA portion of
email messages using the ‘utf-8’ codec.  This can now be controlled by
the new 'decode_data' keyword to ‘SMTPServer’.  The default value is
‘True’, but this default is deprecated.  Specify the 'decode_data'
keyword with an appropriate value to avoid the deprecation warning.

*note http.cookies.Morsel: bd2. オブジェクトの *note key: bcf, *note
value: bd0, *note coded_value: bd1. に対して直接代入することは非推奨です
。 *note set(): bd3. メソッドを使うようにしてください。また、 *note
set(): bd3. のドキュメントされていなかった 'LegalChars' パラメータは非推
奨となり、無視されます。

*note string.Formatter: e85. クラスの *note format(): bce. メソッドに対
し、キーワード引数 'format_string' としてフォーマット文字列を渡すことは
非推奨となりました。 (Contributed by Serhiy Storchaka in bpo-23671(1).)

関数 ‘platform.dist()’ と ‘platform.linux_distribution()’ が非推奨となり
ました。Linux ディストリビューションが自分自身を記述する方法があまりにも
多様なため、この機能は外部パッケージに任せることとなりました(訳注: ここ
では distro(2) のことを指している)。 (Contributed by Vajrasky Kok and
Berker Peksag in bpo-1322(3).)

*note inspect.Signature: 1b1. の、以前からドキュメントされていなかったメ
ソッド ‘from_function’ と ‘from_builtin’ は非推奨です。新しい *note
Signature.from_callable(): 705. を代わりに使ってください。 (Contributed
by Yury Selivanov in bpo-24248(4).)

‘inspect.getargspec()’ 関数は非推奨となり、Python 3.6 で削除されることが
予定されています。 (See bpo-20438(5) for details.)

The *note inspect: 72. *note getfullargspec(): 704, *note getcallargs():
e86, and ‘formatargspec()’ functions are deprecated in favor of the
*note inspect.signature(): 703. API. (Contributed by Yury Selivanov in
bpo-20438(6).)

*note getargvalues(): e87. and *note formatargvalues(): e88. functions
were inadvertently marked as deprecated with the release of Python
3.5.0.

str のパターンとともに *note re.LOCALE: b3a. や *note re.ASCII: 5f8. フ
ラグを使用することは非推奨となりました。 (Contributed by Serhiy
Storchaka in bpo-22407(7).)

‘'\'’ と ASCII 文字からなる認識出来ない特殊シーケンスが正規表現内と置き
換えパターン内で使われた場合に、非推奨警告を出すようになりました。Python
3.6 では禁止されるようになります。 (Contributed by Serhiy Storchaka in
bpo-23622(8).)

*note unittest.TestLoader.loadTestsFromModule(): 26f. メソッドのドキュメ
ントされておらず非公式の 'use_load_tests' デフォルト引数は非推奨となり、
無視されます。 (Contributed by Robert Collins and Barry A. Warsaw in
bpo-16662(9).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23671

   (2) https://github.com/nir0s/distro

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1322

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24248

   (5) https://bugs.python.org/issue?@action=redirect&bpo=20438

   (6) https://bugs.python.org/issue?@action=redirect&bpo=20438

   (7) https://bugs.python.org/issue?@action=redirect&bpo=22407

   (8) https://bugs.python.org/issue?@action=redirect&bpo=23622

   (9) https://bugs.python.org/issue?@action=redirect&bpo=16662


File: python.info,  Node: 削除<8>,  Next: Python 3 5 への移植,  Prev: 非推奨<8>,  Up: What's New In Python 3 5

1.9.10 削除
-----------

* Menu:

* API と機能の削除: API と機能の削除<4>.


File: python.info,  Node: API と機能の削除<4>,  Up: 削除<8>

1.9.10.1 API と機能の削除
.........................

時代遅れとなり、以前に既に非推奨となった以下の API と機能が削除されまし
た:

   * email パッケージの ‘__version__’ 属性は削除されました。email パッケ
     ージが標準ライブラリとは別々にリリースされていたのは遥か昔の話であ
     り、ここのところ何回かのリリースにいたっては ‘__version__’ 文字列が
     更新されていませんでした。

   * 3.4 で非推奨となっていた *note ftplib: 54. モジュール内の内部クラス
     ‘Netrc’ が削除されました。 (Contributed by Matt Chaput in
     bpo-6623(1).)

   * ‘.pyo’ ファイルのコンセプトは削除されました。

   * 暫定 *note asyncio: 8. モジュールで 3.4.4 で非推奨となった
     JoinableQueue は削除されました。 (Contributed by A. Jesse Jiryu
     Davis in bpo-23464(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6623

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23464


File: python.info,  Node: Python 3 5 への移植,  Next: Notable changes in Python 3 5 4,  Prev: 削除<8>,  Up: What's New In Python 3 5

1.9.11 Python 3.5 への移植
--------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* Python の挙動の変更: Python の挙動の変更<3>.
* Python API の変更: Python API の変更<7>.
* C API の変更: C API の変更<10>.


File: python.info,  Node: Python の挙動の変更<3>,  Next: Python API の変更<7>,  Up: Python 3 5 への移植

1.9.11.1 Python の挙動の変更
............................

   * 以前のバージョンの Python で、誤って以下の構文を許容してしまってい
     ました:

          f(1 for x in [1], *args)
          f(1 for x in [1], **kwargs)

     Python 3.5 は正しく *note SyntaxError: 172. を投げます。ジェネレー
     タ式は関数への唯一の引数でない場合には、括弧で囲まなければならない
     のです。(--訳注: 一応。3.5 以前も ‘ff(str(i) for i in range(5),
     "5")’ は SyntaxError です。上の例の通り ‘gg(str(i) for i in
     range(5), *["1", "2"])’ や ‘hh(str(i) for i in range(5), **{"k1":
     "1", "k2": "2"})’ が SytaxError ではなかった、という話です。--)


File: python.info,  Node: Python API の変更<7>,  Next: C API の変更<10>,  Prev: Python の挙動の変更<3>,  Up: Python 3 5 への移植

1.9.11.2 Python API の変更
..........................

   * PEP 475(1): Python シグナルハンドラが例外を送出しなければ、システム
     コールがシグナルに中断された場合に、 *note InterruptedError: d55. を
     送出せずにシステムコールを再試行するようになりました。

   * Python 3.5 以前は、 *note time: 1b0. オブジェクトは UTC で深夜を表
     すときに偽とみなされていました。 この挙動は分かりにくく、エラーの元
     となると考えられ、Python 3.5 で削除されました。 全詳細については
     bpo-13936(2) を参照してください。

   * The ‘ssl.SSLSocket.send()’ method now raises either *note
     ssl.SSLWantReadError: e32. or *note ssl.SSLWantWriteError: e33. on
     a non-blocking socket if the operation would block.  Previously, it
     would return ‘0’.  (Contributed by Nikolaus Rath in bpo-20951(3).)

   * ジェネレータの ‘__name__’ 属性の値として、以前は code オブジェクト
     の名前から取っていましたが、関数名からセットされるようになりました
     。code の方が所望の場合は ‘gen.gi_code.co_name’ から取得してくださ
     い。ジェネレータは新たに ‘__qualname__’ 属性も持つようになりました
     。これはジェネレータの正規名であり、ジェネレータの表現をする際
     (‘repr(gen)’) にこれを用いるようになりました。 (Contributed by
     Victor Stinner in bpo-21205(4).)

   * The deprecated "strict" mode and argument of *note HTMLParser: 843,
     ‘HTMLParser.error()’, and the ‘HTMLParserError’ exception have been
     removed.  (Contributed by Ezio Melotti in bpo-15114(5).)  The
     'convert_charrefs' argument of *note HTMLParser: 843. is now ‘True’
     by default.  (Contributed by Berker Peksag in bpo-21047(6).)

   * API の公式な部分とは言えないものの、移植性への考慮のために (つまり
     テストの修正) に、エラーメッセージの変更に注意を払っておいてくださ
     い。かつて "'sometype' does not support the buffer protocol" の形だ
     ったものが、いまでは "a *note bytes-like object: cfb. is required,
     not 'sometype'" の形になっています。 (Contributed by Ezio Melotti
     in bpo-16518(7).)

   * 既に存在していないディレクトリをカレントディレクトリとして指してい
     た場合に、 *note find_spec(): e8e. は以前は *note
     FileNotFoundError: e8f. 例外を送出していましたが、そうではなく
     ‘None’ を返却するようになりました。この際 *note
     sys.path_importer_cache: 5ae. に ‘None’ を 'キャッシュはしません' 。
     これは典型的なケースとは違います(訳注: msg231477(8))。
     (bpo-22834(9))

   * *note http.client: 65. モジュールと *note http.server: 68. モジュー
     ルに散らばっていた HTTP ステータスコードと対応するメッセージを、共
     通の *note HTTPStatus: 8ce. enum としてまとめ直しました。*note
     http.client: 65. 、 *note http.server: 68. にあったもとの値も後方互
     換性のために残してあります。 (Contributed by Demian Brecht in
     bpo-21793(10).)

   * インポートローダが ‘importlib.machinery.Loader.exec_module()’ を定
     義する場合は、同時に ‘create_module()’ も定義されていることを要求す
     るように変更されました (今のところ *note DeprecationWarning: 18a. と
     なりますが、Python 3.6 ではエラーとなります)。ローダが *note
     importlib.abc.Loader: e90. を継承していれば特にこの変更の影響を受け
     ることはありません。そうでないならば、 ‘None’ を返すだけの
     ‘create_module()’ を定義してください。 (Contributed by Brett Cannon
     in bpo-23014(11).)

   * *note re.split(): 282. 関数は常に空のパターンマッチを無視してきまし
     た。ですからパターン ‘"x*"’ はパターン ‘"x+"’ と同じように動作し、
     パターン ‘"\b"’ は決して動作しませんでした。今後は *note
     re.split(): 282. はパターンが空文字列に合致しうる場合に警告を出しま
     す。互換性のためには空文字列とはマッチしえないパターンを使ってくだ
     さい(たとえば ‘"x*"’ ではなく ‘"x+"’ を使ってください)。空文字列と
     しかマッチしえないパターン(例えば ‘"\b"’)はエラーとなります。
     (Contributed by Serhiy Storchaka in bpo-22818(12).)

   * *note http.cookies.Morsel: bd2. 辞書風インターフェイスのそれ自身で
     の一貫性を持たせるようにしました: morsel の比較に *note key: bcf. と
     *note value: bd0. を考慮するようにし、 *note copy(): e91. は *note
     dict: 237. を返さずに *note Morsel: bd2. インスタンスを返すようにし
     、 *note update(): e92. は更新する辞書内のいずれかのキーが不正(訳注
     : RFC 2109(13) として不正なキーのことで、update 以外のインターフェ
     イスでは変更前も拒絶される)であれば例外を投げるようにしています。加
     えて、ドキュメントされていない *note set(): bd3. の 'LegalChars' パ
     ラメータは非推奨となり、また指定しても無視されます。 (Contributed
     by Demian Brecht in bpo-2211(14).)

   * PEP 488(15) has removed ‘.pyo’ files from Python and introduced the
     optional ‘opt-’ tag in ‘.pyc’ file names.  The *note
     importlib.util.cache_from_source(): 2d5. has gained an
     'optimization' parameter to help control the ‘opt-’ tag.  Because
     of this, the 'debug_override' parameter of the function is now
     deprecated.  ‘.pyo’ files are also no longer supported as a file
     argument to the Python interpreter and thus serve no purpose when
     distributed on their own (i.e.  sourceless code distribution).  Due
     to the fact that the magic number for bytecode has changed in
     Python 3.5, all old ‘.pyo’ files from previous versions of Python
     are invalid regardless of this PEP.

   * The *note socket: b8. module now exports the *note
     CAN_RAW_FD_FRAMES: e93. constant on linux 3.6 and greater.

   * RFC 5280(16) に基づき、 *note ssl.cert_time_to_seconds(): e34. 関数
     が入力の時刻をローカル時刻ではなく UTC として解釈するようになりまし
     た。また、戻り値は常に *note int: 238. となります。 (Contributed by
     Akira Li in bpo-19940(17).)

   * ‘pygettext.py’ ツールが POT-Creation-Date ヘッダ内のタイムゾーン形
     式として、標準の +NNNN 形式を使うようになりました。

   * *note smtplib: b7. モジュールは以前はデバッグ出力のためにモジュール
     レベルの ‘stderr’ 変数を使っていましたが、 *note sys.stderr: 907. を
     使うようになりました。もしもあなたの(テスト)プログラムが、そのデバ
     ッグ出力をキャプチャするためにこのモジュールレベル変数に依存してた
     のであれば、今後は sys.stderr をキャプチャするようにする必要があり
     ます。

   * *note str.startswith(): e94. と *note str.endswith(): e95. メソッド
     は空文字列を見つけた場合と完全に範囲外のインデクスが渡された場合に
     ‘True’ を返すことはしなくなりました。 (Contributed by Serhiy
     Storchaka in bpo-24284(18).)

   * *note inspect.getdoc(): 9c8. 関数が基底クラスから継承したドキュメン
     テーション文字列を返すようになりました。その継承したドキュメンテー
     ション文字列が相応しいのであれば、もはやそれを繰り返して記述する必
     要はありません。継承されたそれを抑制するには、空の文字列を記述しな
     ければなりません(もしくは然るべきドキュメンテーションを埋めれば良い
     です)。この変更は *note pydoc: a3. モジュールと *note help(): 8a5.
     関数の出力に影響します。 (Contributed by Serhiy Storchaka in
     bpo-15582(19).)

   * ネストされた *note functools.partial(): 3ed. 呼び出しは平坦化される
     ようになりました。以前の振る舞いに依存していたのであれば *note
     functools.partial(): 3ed. オブジェクトに属性を追加するか、または
     *note functools.partial(): 3ed. をサブクラス化することで出来ます。
     (-訳注: 後半が意味がある内容を言ってるようには思えません。「以前の
     振る舞い」とはおそらく ‘partial’ オブジェクトの ‘func’ 属性が
     functools.partial そのものになることを指していて、「似たことをした
     ければ ‘partial’ オブジェクトに別の属性を付ければりゃいんじゃね?」
     程度の無責任な代替案を言ってるだけのような気がします。そもそも後者
     の「サブクラス化」は出来ないと思いますし。 -) (Contributed by
     Alexander Belopolsky in bpo-7830(20).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13936

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20951

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21205

   (5) https://bugs.python.org/issue?@action=redirect&bpo=15114

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21047

   (7) https://bugs.python.org/issue?@action=redirect&bpo=16518

   (8) https://bugs.python.org/issue22834#msg231477

   (9) https://bugs.python.org/issue?@action=redirect&bpo=22834

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21793

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23014

   (12) https://bugs.python.org/issue?@action=redirect&bpo=22818

   (13) https://datatracker.ietf.org/doc/html/rfc2109.html

   (14) https://bugs.python.org/issue?@action=redirect&bpo=2211

   (15) https://peps.python.org/pep-0488/

   (16) https://datatracker.ietf.org/doc/html/rfc5280.html

   (17) https://bugs.python.org/issue?@action=redirect&bpo=19940

   (18) https://bugs.python.org/issue?@action=redirect&bpo=24284

   (19) https://bugs.python.org/issue?@action=redirect&bpo=15582

   (20) https://bugs.python.org/issue?@action=redirect&bpo=7830


File: python.info,  Node: C API の変更<10>,  Prev: Python API の変更<7>,  Up: Python 3 5 への移植

1.9.11.3 C API の変更
.....................

   * The undocumented ‘format’ member of the (non-public)
     ‘PyMemoryViewObject’ structure has been removed.  All extensions
     relying on the relevant parts in ‘memoryobject.h’ must be rebuilt.

   * ‘PyMemAllocator’ 構造体が *note PyMemAllocatorEx: e97. にリネームさ
     れた上で ‘calloc’ フィールドが追加されました。

   * Removed non-documented macro ‘PyObject_REPR()’ which leaked
     references.  Use format character ‘%R’ in *note
     PyUnicode_FromFormat(): 363.-like functions to format the *note
     repr(): 7c8. of the object.  (Contributed by Serhiy Storchaka in
     bpo-22453(1).)

   * Because the lack of the *note __module__: 34d. attribute breaks
     pickling and introspection, a deprecation warning is now raised for
     builtin types without the *note __module__: 34d. attribute.  This
     will be an *note AttributeError: 326. in the future.  (Contributed
     by Serhiy Storchaka in bpo-20204(2).)

   * As part of the PEP 492(3) implementation, the ‘tp_reserved’ slot of
     *note PyTypeObject: a73. was replaced with a *note tp_as_async:
     e98. slot.  Refer to *note コルーチンオブジェクト: e99. for new
     types, structures and functions.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22453

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20204

   (3) https://peps.python.org/pep-0492/


File: python.info,  Node: Notable changes in Python 3 5 4,  Prev: Python 3 5 への移植,  Up: What's New In Python 3 5

1.9.12 Notable changes in Python 3.5.4
--------------------------------------

* Menu:

* New make regen-all build target: New make regen-all build target<2>.
* Removal of make touch build target: Removal of make touch build target<2>.


File: python.info,  Node: New make regen-all build target<2>,  Next: Removal of make touch build target<2>,  Up: Notable changes in Python 3 5 4

1.9.12.1 New ‘make regen-all’ build target
..........................................

To simplify cross-compilation, and to ensure that CPython can reliably
be compiled without requiring an existing version of Python to already
be available, the autotools-based build system no longer attempts to
implicitly recompile generated files based on file modification times.

Instead, a new ‘make regen-all’ command has been added to force
regeneration of these files when desired (e.g.  after an initial version
of Python has already been built based on the pregenerated versions).

More selective regeneration targets are also defined - see
Makefile.pre.in(1) for details.

(Victor Stinner の貢献による bpo-23404(2))

Added in version 3.5.4.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Makefile.pre.in

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23404


File: python.info,  Node: Removal of make touch build target<2>,  Prev: New make regen-all build target<2>,  Up: Notable changes in Python 3 5 4

1.9.12.2 Removal of ‘make touch’ build target
.............................................

The ‘make touch’ build target previously used to request implicit
regeneration of generated files by updating their modification times has
been removed.

It has been replaced by the new ‘make regen-all’ target.

(Victor Stinner の貢献による bpo-23404(1))

バージョン 3.5.4 で変更.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23404


File: python.info,  Node: What's New In Python 3 4,  Next: What's New In Python 3 3,  Prev: What's New In Python 3 5,  Up: What's New in Python

1.10 What's New In Python 3.4
=============================


著者: R. David Murray <<rdmurray@bitdance.com>> (編集者)

この記事では 3.3 と比較した Python 3.4 の新機能を解説します。 Python 3.4
は2014年3月16日にリリースされました。全詳細については 変更履歴(1) をご覧
ください。

参考
....

PEP 429(2) - Python 3.4 リリーススケジュール

* Menu:

* 概要: 概要 -- リリースハイライト<8>. リリースハイライト
* 新しい機能: 新しい機能<11>.
* 新たなモジュール: 新たなモジュール<8>.
* 改良されたモジュール: 改良されたモジュール<8>.
* CPython の実装の変更::
* 非推奨: 非推奨<9>.
* 削除: 削除<9>.
* Python 3.4 への移植: Python 3 4 への移植.
* 3.4.3 の変更: 3 4 3 の変更.

   ---------- Footnotes ----------

   (1) https://docs.python.jp/3.4/whatsnew/changelog.html

   (2) https://peps.python.org/pep-0429/


File: python.info,  Node: 概要 -- リリースハイライト<8>,  Next: 新しい機能<11>,  Up: What's New In Python 3 4

1.10.1 概要 - リリースハイライト
--------------------------------

新たな文法機能:

   * Python 3.4 に追加された新しい文法機能はありません。

その他の新しい機能:

   * *note pip が常に利用可能であることが保障されるようになりました:
     ea0. ( PEP 453(1))。

   * *note 新しく作成されたファイル記述子が継承不可能 （non-inheritable）
     になりました: ea1. ( PEP 446(2))。

   * *note 隔離モード (isolated mode): ea2. の為のコマンドラインオプショ
     ン (bpo-16499(3))。

   * 非テキストエンコーディングでの *note Codec 処理の改良: ea3. (複数の
     issue に関係).

   * インポートシステムのための *note ModuleSpec 型: ea4. ( PEP 451(4)).
     (インポーターの作者に影響します)

   * *note marshal: 80. フォーマットが *note よりコンパクトで効率的に:
     ea5. なりました (bpo-16475(5))。

新たなライブラリモジュール:

   * *note asyncio: 8.: *note 非同期 IO のための新たな暫定 API: ea6. (
     PEP 3156(6))。

   * *note ensurepip: 4b.: *note pip インストーラのブートストラップ:
     ea7. ( PEP 453(7))。

   * *note enum: 4c.: *note 列挙型のサポート: ea8. ( PEP 435(8))。

   * *note pathlib: 93.: *note オブジェクト指向のファイルシステムパス:
     ea9. ( PEP 428(9))。

   * *note selectors: b0.: *note 高水準で効率的な I/O の多重化: eaa.、
     *note select: af. モジュールプリミティブを基にしています ( PEP
     3156(10) の一部)。

   * *note statistics: bd.: 基礎的な *note 数値的に安定な統計ライブラリ:
     eab. ( PEP 450(11))。

   * *note tracemalloc: e8.: *note Python のメモリ割り当てのトレース:
     eac. ( PEP 454(12))。

大幅に改善されたライブラリモジュール:

   * *note functools: 55. の *note シングルディスパッチジェネリック関数:
     ead. ( PEP 443(13))。

   * *note pickle: 95. の新しい *note プロトコル 4: eae. ( PEP
     3154(14)).

   * *note multiprocessing: 86. が *note Unix で os.fork
     の使用を避けるオプションを持つようになりました: eaf.
     (bpo-8713(15))。

   * *note email: 32. にサブモジュール *note contentmanager: 34. が追加
     され、また、 *note Message: 25d. のサブクラス (‘EmailMessage’) が追
     加されました。これは *note MIME 処理を簡単にします: eb0. 。
     (bpo-18891(16))

   * *note inspect: 72. と *note pydoc: a3. が以前よりも遥かに幅広い種類
     の callable オブジェクトを正しくイントロスペクション出来るようにな
     り、これは Python *note help(): 8a5. システムを改善することになりま
     した。

   * *note ipaddress: 74. モジュール API は安定だと宣言されました。

セキュリティの改善:

   * *note 安全で取り替え可能なハッシュアルゴリズム: eb1. ( PEP
     456(17))。

   * ファイル記述子が子プロセスにリークするのを防ぐために *note
     新しく作成されたファイル記述子が継承不可になりました: ea1. ( PEP
     446(18))。

   * *note 隔離モード (isolated mode): ea2. のための新たなコマンドライン
     オプション (bpo-16499(19))。

   * *note multiprocessing: 86. が *note Unix で os.fork
     の使用を避けるオプション: eaf. を持つようになりました。 子プロセス
     とのデータ共有を避けるため 'spawn' と 'forkserver' はより安全です。

   * Windows での *note multiprocessing: 86. 子プロセスはもはや、必要な
     ものを除いて親の継承可能なハンドルを継承しません。

   * 新たな関数 *note hashlib.pbkdf2_hmac(): 4d9. は PKCS#5 パスワードベ
     ースの鍵導出関数２(20) を提供します。

   * *note ssl: bb. での *note TLSv1.1、 TLSv1.2 サポート: eb2. の追加。

   * *note ssl: bb. での *note Windows
     のシステム証明書ストアよりの証明書抽出サポート: eb3. の追加。

   * *note ssl: bb. での *note サーバサイド SNI (Server Name Indication)
     サポート: eb4. の追加。

   * *note ssl.SSLContext: 274. クラスに *note 多数の改善: eb5. がなされ
     ました。

   * SSL をサポートする全ての標準ライブラリモジュールは今や、ホスト名の
     マッチング (‘ssl.match_hostname()’) と証明書失効リスト
     (CRLs=certification revocation lists。 *note
     ssl.SSLContext.load_verify_locations(): eb6. 参照) を含むサーバ証明
     書検証をサポートします。

CPython の実装の改善:

   * *note オブジェクトの安全なファイナライゼーション: eb7. ( PEP
     442(21))。

   * PEP 442(22) を活用することで、ほとんどのケースで *note
     モジュールのグローバルがファイナライゼーション中に None
     がセットされることはなくなりました: eb7. (bpo-18214(23))。

   * *note 設定可能なメモリアロケータ: eb8. ( PEP 445(24))。

   * *note Argument Clinic: eb9. ( PEP 436(25))。

以降は、たくさんのほかの小さな改善、CPython での最適化、非推奨リスト、潜
在的な移植性問題を含む、ユーザ向けの変更の包括的なリストになっています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0453/

   (2) https://peps.python.org/pep-0446/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16499

   (4) https://peps.python.org/pep-0451/

   (5) https://bugs.python.org/issue?@action=redirect&bpo=16475

   (6) https://peps.python.org/pep-3156/

   (7) https://peps.python.org/pep-0453/

   (8) https://peps.python.org/pep-0435/

   (9) https://peps.python.org/pep-0428/

   (10) https://peps.python.org/pep-3156/

   (11) https://peps.python.org/pep-0450/

   (12) https://peps.python.org/pep-0454/

   (13) https://peps.python.org/pep-0443/

   (14) https://peps.python.org/pep-3154/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=8713

   (16) https://bugs.python.org/issue?@action=redirect&bpo=18891

   (17) https://peps.python.org/pep-0456/

   (18) https://peps.python.org/pep-0446/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=16499

   (20) https://en.wikipedia.org/wiki/PBKDF2

   (21) https://peps.python.org/pep-0442/

   (22) https://peps.python.org/pep-0442/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=18214

   (24) https://peps.python.org/pep-0445/

   (25) https://peps.python.org/pep-0436/


File: python.info,  Node: 新しい機能<11>,  Next: 新たなモジュール<8>,  Prev: 概要 -- リリースハイライト<8>,  Up: What's New In Python 3 4

1.10.2 新しい機能
-----------------

* Menu:

* PEP 453; Python インストール時の PIP の明示的なブートストラッピング: PEP 453 Python インストール時の PIP の明示的なブートストラッピング.
* PEP 446; 新規作成されたファイル記述子は継承不可: PEP 446 新規作成されたファイル記述子は継承不可.
* Codec 処理の改良::
* PEP 451; インポートシステムのための ModuleSpec 型: PEP 451 インポートシステムのための ModuleSpec 型.
* その他の言語変更: その他の言語変更<8>.


File: python.info,  Node: PEP 453 Python インストール時の PIP の明示的なブートストラッピング,  Next: PEP 446 新規作成されたファイル記述子は継承不可,  Up: 新しい機能<11>

1.10.2.1 PEP 453: Python インストール時の PIP の明示的なブートストラッピング
............................................................................

* Menu:

* デフォルトでの pip のブートストラッピング::
* ドキュメントの変更::


File: python.info,  Node: デフォルトでの pip のブートストラッピング,  Next: ドキュメントの変更,  Up: PEP 453 Python インストール時の PIP の明示的なブートストラッピング

1.10.2.2 デフォルトでの pip のブートストラッピング
..................................................

新しい *note ensurepip: 4b. モジュール( PEP 453(1) で定義されています)は
標準のクロスプラットフォームのメカニズムで、Python インストールと仮想環
境に pip インストーラをブートストラップします。Python 3.4.0 に含まれる
‘pip’ のバージョンは ‘pip’ 1.5.4 で、将来の 3.4.x メンテナンスリリースで
は Python のリリース候補の作成時点で入手出来る最新バージョンの ‘pip’ が
バンドルされる予定です。

デフォルトでは ‘pipX’ , ‘pipX.Y’ コマンドが全てのプラットフォームに、
Python パッケージ ‘pip’ とその依存物とともにインストールされます(X. Y は
インストールされる Python のバージョン)。Windows 実環境と全てのプラット
フォームの仮想環境には、バージョンが名前に付与されない ‘pip’ コマンドも
インストールされます。ほかのプラットフォームでは、システムワイドでバージ
ョンが名前に付与されない ‘pip’ コマンドは、典型的には Python 2 を別途イ
ンストールした際のものを指しています。

‘pyvenv’ コマンドラインユーティリティと *note venv: f9. モジュールは、仮
想環境で ‘pip’ が使えるようにするために *note ensurepip: 4b. モジュール
を使います。 コマンドラインユーティリティを使う際は ‘pip’ はデフォルトで
インストールされます。 *note venv: f9. モジュールの *note API: ebd. を使
う際は、 ‘pip’ のインストールは明示的に要求しなければなりません。

CPython の *note source builds on POSIX systems: ebe. では ‘make
install’, ‘make altinstall’ コマンドはデフォルトで ‘pip’ ブートストラッ
プを行います。この振る舞いは configure のオプションを変更して Makefile を
作ることで変更できます。

Windows と Mac OS X では CPython インストーラはそれ自身と一緒に ‘pip’ を
デフォルトでインストールするようになっています(ユーザはインストールプロ
セスで除外するかもしれませんが)。Windows ユーザは ‘pip’ がコマンドライン
からデフォルトで利用可能なように ‘PATH’ の自動修正するかの選択を求められ
ます。そうしない場合でも Windows のための Python ランチャで ‘py -m pip’
のようにすれば良いです。

As discussed in the PEP(2) platform packagers may choose not to install
these commands by default, as long as, when invoked, they provide clear
and simple directions on how to install them on that platform (usually
using the system package manager).

     注釈: Python 2 と Python 3 の共存インストールでの衝突を避けるために
     、 ‘ensurepip’ を直接呼び出した場合のデフォルトでは、バージョン付け
     された ‘pip3’, ‘pip3.4’ コマンドだけがインストールされます。バージ
     ョン付けのない ‘pip’ コマンドもインストールしたければ、
     ‘--default-pip’ オプションが必要です。 ‘pyvenv’ と Windows インスト
     ーラは修飾のない ‘pip’ コマンドがそれら環境で利用可能となるように保
     障しますし、また、複数の Python がインストールされたシステムで曖昧
     さを避けようと直接コマンドを呼び出す代わりに、 ‘pip’ は ‘-m’ スイッ
     チ経由でいつでも呼び出せます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0453/

   (2) 
https://peps.python.org/pep-0453/#recommendations-for-downstream-distributors


File: python.info,  Node: ドキュメントの変更,  Prev: デフォルトでの pip のブートストラッピング,  Up: PEP 453 Python インストール時の PIP の明示的なブートストラッピング

1.10.2.3 ドキュメントの変更
...........................

この変更の一部は、 *note Python モジュールのインストール: ec0. と
distributing-index セクションがより手短な始め方として完全にデザインし直
されたことと、FAQ ドキュメントです。ほとんどのパッケージングについてのド
キュメンテーションは Python Packaging User Guide(1) が保守している
Python Packaging Authority に移動されて、独立したプロジェクトのドキュメ
ンテーションになっています。

However, as this migration is currently still incomplete, the legacy
versions of those guides remaining available as *note setuptools による
C および C++ 拡張のビルド: ec1. and *note setuptools による C および C++
拡張のビルド: ec2.

参考
....

PEP 453(2) - Python インストールの際の明示的なpipのブートストラッピング

     PEP は Donald Stufft と Nick Coghlan によって書かれ、Donald Stufft,
     Nick Coghlan, Martin von Löwis, Ned Deily により実装されました。

   ---------- Footnotes ----------

   (1) https://packaging.python.org

   (2) https://peps.python.org/pep-0453/


File: python.info,  Node: PEP 446 新規作成されたファイル記述子は継承不可,  Next: Codec 処理の改良,  Prev: PEP 453 Python インストール時の PIP の明示的なブートストラッピング,  Up: 新しい機能<11>

1.10.2.4 PEP 446: 新規作成されたファイル記述子は継承不可
........................................................

PEP 446(1) により、新規作成するファイル記述子は *note 継承不可
(non-inheritable): ec4. となります。一般的にはこれこそがアプリケーション
が望む振る舞いです。新たにプロセスを生成する際に、現在開いているファイル
を起こした子プロセスでも開くことは、検出が困難なあらゆるバグや潜在的なセ
キュリティ問題を引き起こしかねません。

そうはいっても継承することが望ましい場合もあります。それらのケースをサポ
ートするために、以下の新規関数とメソッドが利用出来ます:

   * *note os.get_inheritable(): ec5, *note os.set_inheritable(): ec6.

   * *note os.get_handle_inheritable(): ec7, *note
     os.set_handle_inheritable(): ec8.

   * *note socket.socket.get_inheritable(): ec9, *note
     socket.socket.set_inheritable(): eca.

参考
....

PEP 446(2) - 新規作成されたファイル記述子を継承不可にする

     PEP written and implemented by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0446/

   (2) https://peps.python.org/pep-0446/


File: python.info,  Node: Codec 処理の改良,  Next: PEP 451 インポートシステムのための ModuleSpec 型,  Prev: PEP 446 新規作成されたファイル記述子は継承不可,  Up: 新しい機能<11>

1.10.2.5 Codec 処理の改良
.........................

その最初の導入からずっと、 *note codecs: 14. モジュールとはいつなんどき
も、型に中立で動的なエンコーディング・デコーディングシステムとして働くも
のであったのです。そうなのですがその Python テキストモデルとの密接な結合
、特に組み込み型 *note str: 418, *note bytes: 1a4, *note bytearray: 508.
にある型に制限があるコンビニエンスメソッドのおかげで、歴史的にその本来の
意図を曖昧にしてきたのでした。

そんな状況を清く正しくするための重要な一歩として、今ではコンビニエンス関
数 *note codecs.encode(): ecc, *note codecs.decode(): ecd. が Python
2.7、3.3、3.4 で適切にドキュメントされました。これら関数は *note codecs:
14. モジュールに Python 2.4 からずっと存在している (うえに回帰テストスイ
ートでもずっと網羅してきた) のですが、以前はドキュメントされていなかった
わけなので、実行時イントロスペクションでようやく見つけられるというものだ
ったわけです。

*note str: 418, *note bytes: 1a4, *note bytearray: 508. でのコンビニエン
スメソッドが Python 3 では Unicode テキストエンコーディングに制限され、
Python 2 では ‘basestring’ <-> ‘basestring’ 変換に制限されるのとは違うの
です。 *note codecs: 14. のコンビニエンス関数は Python 2 と Python 3 の
両方で任意のコーデックをサポートするのです。

Python 3.4 では、インタプリタは標準ライブラリで提供している非テキストエ
ンコーディングについて知っています。そして以下のように適宜、それら汎用目
的のコンビニエンス関数へユーザを誘導します:

     >>> b"abcdef".decode("hex")
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     LookupError: 'hex' is not a text encoding; use codecs.decode() to handle arbitrary codecs

     >>> "hello".encode("rot13")
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     LookupError: 'rot13' is not a text encoding; use codecs.encode() to handle arbitrary codecs

     >>> open("foo.txt", encoding="hex")
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     LookupError: 'hex' is not a text encoding; use codecs.open() to handle arbitrary codecs

関連する変更で、後方互換性を壊すことなくそれが相応しい場合にはいつでも、
エンコーディング・デコーディング操作中に起こる例外は、同じ例外型でありエ
ラーを発生させることになった原因コーデックの名前に言及する連鎖例外内に包
まれます:

     >>> import codecs

     >>> codecs.decode(b"abcdefgh", "hex")
     Traceback (most recent call last):
       File "/usr/lib/python3.4/encodings/hex_codec.py", line 20, in hex_decode
         return (binascii.a2b_hex(input), len(input))
     binascii.Error: Non-hexadecimal digit found

     The above exception was the direct cause of the following exception:

     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     binascii.Error: decoding with 'hex' codec failed (Error: Non-hexadecimal digit found)

     >>> codecs.encode("hello", "bz2")
     Traceback (most recent call last):
       File "/usr/lib/python3.4/encodings/bz2_codec.py", line 17, in bz2_encode
         return (bz2.compress(input), len(input))
       File "/usr/lib/python3.4/bz2.py", line 498, in compress
         return comp.compress(data) + comp.flush()
     TypeError: 'str' does not support the buffer interface

     The above exception was the direct cause of the following exception:

     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: encoding with 'bz2' codec failed (TypeError: 'str' does not support the buffer interface)

そしてついに、ここまで実例で見てきたような的確な誘導による改善が、それ自
体は Python 3.2 で復活していた非 Unicode コーデックへのコンビニエンスの
エイリアスの復活を可能にしました。(--訳注: Python 3.0 で一度非 Unicode エ
ンコーディングは消滅し、3.2 でそれらコーデックそのものは復活したものの、
Lib/encodings/aliases.py(1) のマッピングからは除外されたままだった。--)
つまり、バイナリデータの 16 進表現エンコードとそのデコード (たとえば、で
す) は、今ではこう書けるということです:

     >>> from codecs import encode, decode
     >>> encode(b"hello", "hex")
     b'68656c6c6f'
     >>> decode(b"68656c6c6f", "hex")
     b'hello'

標準ライブラリで提供されるバイナリ変換とテキスト変換は、 *note
バイナリ変換 (Binary Transforms): ece. と *note テキスト変換 (Text
Transforms): ecf. に詳細記述されました。

(Contributed by Nick Coghlan in bpo-7475(2), bpo-17827(3), bpo-17828(4)
and bpo-19619(5).)

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/encodings/aliases.py

   (2) https://bugs.python.org/issue?@action=redirect&bpo=7475

   (3) https://bugs.python.org/issue?@action=redirect&bpo=17827

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17828

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19619


File: python.info,  Node: PEP 451 インポートシステムのための ModuleSpec 型,  Next: その他の言語変更<8>,  Prev: Codec 処理の改良,  Up: 新しい機能<11>

1.10.2.6 PEP 451: インポートシステムのための ModuleSpec 型
..........................................................

PEP 451(1) は、インポート機構がロードに使うモジュールに関する情報 (つま
りモジュールの仕様) のカプセル化を提供します。これはインポートの実装とイ
ンポート関連 API の両方を単純化するのに役立ちます。この変更は、 いくつか
の将来のインポート関連の改善(2) の足掛かりでもあります。

この PEP による公な側面での変化は完全に後方互換です。さらにそれらは、イ
ンポーターの作者以外にとっては透過的であるはずです。鍵となるファインダと
ローダのメソッドはまだ動作し続けますが非推奨となりました。新しいインポー
タは PEP に記述された新メソッドを使うべきです。既存のインポータは新メソ
ッドを実装するように更新すべきです。置き換えられるべきメソッドとその代わ
りとなるメソッドのリストについては *note 非推奨: ed1. を参照してください
。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0451/

   (2) 
https://mail.python.org/pipermail/python-dev/2013-November/130111.html


File: python.info,  Node: その他の言語変更<8>,  Prev: PEP 451 インポートシステムのための ModuleSpec 型,  Up: 新しい機能<11>

1.10.2.7 その他の言語変更
.........................

Python 言語コアに小さな変更がいくつか行われました:

   * Unicode データベースを UCD バージョン 6.3 にアップグレードしました
     。

   * *note min(): ed3. と *note max(): ed4. にキーワード専用引数
     'default' が追加されました。これにはイテラブルが要素なしであると評
     価される場合に返す値を指定出来ます。 (Contributed by Julian Berman
     in bpo-18111(1).)

   * Module objects are now *note weakly referenceable: ed5.

   * モジュールの ‘__file__’ 属性 (と関連する値) にはデフォルトでは常に
     絶対パスを含むようになりました。ただし、スクリプトがコマンドライン
     から相対パスを使って直接実行された際の ‘__main__.__file__’ は唯一の
     例外です。 (Contributed by Brett Cannon in bpo-18416(2).)

   * UTF-16 デコーダ (妥当なサロゲートペアを受け付ける) と UTF-16 エンコ
     ーダ (非 BMP 文字のエンコードでサロゲートペアを生成) 以外の、(UTF-7
     を除く) 全ての UTF-* コーデックが、エラーハンドラ ‘surrogatepass’ を
     使わない限りはエンコーディングとデコーディングの両方でサロゲートペ
     アを拒絶するようになりました。(Contributed by Victor Stinner,
     Kang-Hao (Kenny) Lu and Serhiy Storchaka in bpo-12892(3).)

   * 新規ドイツ語 EBCDIC *note codec: d86. ‘cp273’.  (Contributed by
     Michael Bierenfeld and Andrew Kuchling in bpo-1097797(4).)

   * 新規ウクライナ語 *note codec: d86. ‘cp1125’.  (Contributed by
     Serhiy Storchaka in bpo-19668(5).)

   * *note bytes: 1a4.join() と *note bytearray: 508.join() が引数として
     任意のバッファオブジェクトを受け取れるようになりました。
     (Contributed by Antoine Pitrou in bpo-15958(6).)

   * *note int: 238. コンストラクタの 'base' 引数に、 ‘__index__’ メソッ
     ドを持つ任意のオブジェクトを渡せるようになりました。(Contributed by
     Mark Dickinson in bpo-16772(7).)  (--訳注: *note Python API の変更:
     ed6. に同じ bpo-16772(8) を発端とする変更が書かれているのでそちらも
     参照して下さい。 --)

   * フレームオブジェクトに、ローカル変数への全ての参照をフレームからク
     リアするメソッド *note clear(): 261. が追加されました。(Contributed
     by Antoine Pitrou in bpo-17934(9).)

   * *note memoryview: 435. が *note Sequence: 17. として登録され、また
     、組み込み関数 *note reversed(): 831. をサポートするようになりまし
     た。 (Contributed by Nick Coghlan and Claudiu Popa in bpo-18690(10)
     and bpo-19078(11).)

   * Argument Clinic の導入、 *note inspect: 72. と *note pydoc: a3. に
     なされた他の変更の結果、多くの場合で *note help(): 8a5. が報告する
     シグニチャが修正・改善されました。

   * *note __length_hint__(): ed7. が、公式な言語仕様の一部になりました
     (see PEP 424(12))。 (Contributed by Armin Ronacher in
     bpo-16148(13).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18111

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18416

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12892

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1097797

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19668

   (6) https://bugs.python.org/issue?@action=redirect&bpo=15958

   (7) https://bugs.python.org/issue?@action=redirect&bpo=16772

   (8) https://bugs.python.org/issue?@action=redirect&bpo=16772

   (9) https://bugs.python.org/issue?@action=redirect&bpo=17934

   (10) https://bugs.python.org/issue?@action=redirect&bpo=18690

   (11) https://bugs.python.org/issue?@action=redirect&bpo=19078

   (12) https://peps.python.org/pep-0424/

   (13) https://bugs.python.org/issue?@action=redirect&bpo=16148


File: python.info,  Node: 新たなモジュール<8>,  Next: 改良されたモジュール<8>,  Prev: 新しい機能<11>,  Up: What's New In Python 3 4

1.10.3 新たなモジュール
-----------------------

* Menu:

* asyncio: asyncio<11>.
* ensurepip: ensurepip<2>.
* enum: enum<8>.
* pathlib: pathlib<11>.
* selectors: selectors<2>.
* statistics: statistics<6>.
* tracemalloc: tracemalloc<4>.


File: python.info,  Node: asyncio<11>,  Next: ensurepip<2>,  Up: 新たなモジュール<8>

1.10.3.1 asyncio
................

*note asyncio: 8. モジュールが追加されました ( PEP 3156(1) で定義されて
います)。これは Python のための標準的で抜き挿し可能なイベントループモデ
ルを、標準ライブラリに信頼出来る非同期 I/O サポートを追加することで提供
し、また、ほかのイベントループ実装を標準ライブラリと相互運用することを容
易にします。

Python 3.4 では、このモジュールは *note 暫定 API: ad1. であるとみなされ
ています。

参考
....

PEP 3156(2) - 非同期 IO サポートの再起動: "asyncio" モジュール

     PEP written and implementation led by Guido van Rossum.  (訳注: PEP
     タイトルの「Asynchronous IO Support Rebooted: the "asyncio" Module」
     は PEP 3153(3) の焼き直しのため。)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3156/

   (2) https://peps.python.org/pep-3156/

   (3) https://peps.python.org/pep-3153/


File: python.info,  Node: ensurepip<2>,  Next: enum<8>,  Prev: asyncio<11>,  Up: 新たなモジュール<8>

1.10.3.2 ensurepip
..................

新規の *note ensurepip: 4b. モジュールは PEP 453(1) 実装のための本質的な
基盤です。通常はエンドユーザはこのモジュールを弄ぶ必要はありません。です
が、 ‘pip’ のインストレーションや仮想環境に対する自動ブートストラップを
拒否していた場合には、手動でそれをブートストラップするのに使えます。

*note ensurepip: 4b. は ‘pip’ のバンドルされたコピーを含んでいて、これは
CPython リリースの最初のリリース候補時点での最新です (このことはメンテナ
ンスリリース、feature リリースの両方に適用されます)。 ‘ensurepip’ 自身は
インターネットアクセスしません。依存パッケージ解決のためのインターネット
アクセスを要するならばそれは ‘ensurepip’ 実行の後の ‘pip’ で行いますし、
‘pip’ そのもののアップグレードも ‘pip’ 自身で行います。(そのようなアップ
グレード版 ‘pip’ は個別のインストールパッケージとみなされて、Python がア
ンインストールされても削除されないことを付記しておきます。)

このモジュールが「 'ensure (保障する)' 」を名前に冠するのは、 ‘pip’ がイ
ンストール済みならば何もしないからです。このモジュールは ‘--upgrade’ オ
プションを持ちますが、これは既存のインストール版 ‘pip’ がこのモジュール
にバンドルされたコピーよりも古い場合に、バンドルされたコピー版 ‘pip’ を
インストールします。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0453/


File: python.info,  Node: enum<8>,  Next: pathlib<11>,  Prev: ensurepip<2>,  Up: 新たなモジュール<8>

1.10.3.3 enum
.............

*note enum: 4c. モジュール ( PEP 435(1) にて定義) は標準の列挙型実装を提
供します。これにより (*note socket: b8. のような) ほかのモジュールが、不
透明な整数定数を後方互換を保ったまま列挙値に置き換えることによって、より
情報に富むエラーメッセージを提供したり、より良いデバッグサポートを行える
ようになります。

参考
....

PEP 435(2) - Python 標準ライブラリに enum 型を追加

     PEP written by Barry Warsaw, Eli Bendersky and Ethan Furman,
     implemented by Ethan Furman.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0435/

   (2) https://peps.python.org/pep-0435/


File: python.info,  Node: pathlib<11>,  Next: selectors<2>,  Prev: enum<8>,  Up: 新たなモジュール<8>

1.10.3.4 pathlib
................

新規モジュール *note pathlib: 93. は、異なるオペレーティングシステムごと
に適切な意味付けでファイルシステムパスを表現するクラス群を提供しています
。パスのクラス群は '純粋パス' と '具象パス' に分離されています。前者は
I/O を伴わない純粋なパス計算操作を提供するもので、後者は純粋パスを派生し
ますが I/O 操作も提供します。

Python 3.4 では、このモジュールは *note 暫定 API: ad1. であるとみなされ
ています。

参考
....

PEP 428(1) - pathlib モジュール - オブジェクト指向のファイルシステムパス

     PEP written and implemented by Antoine Pitrou.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0428/


File: python.info,  Node: selectors<2>,  Next: statistics<6>,  Prev: pathlib<11>,  Up: 新たなモジュール<8>

1.10.3.5 selectors
..................

新規モジュール *note selectors: b0. ( PEP 3156(1) の一部として作成されま
した)　は、高水準で効率的な I/O の多重化を行います。これは *note select:
af. モジュールプリミティブに基いています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3156/


File: python.info,  Node: statistics<6>,  Next: tracemalloc<4>,  Prev: selectors<2>,  Up: 新たなモジュール<8>

1.10.3.6 statistics
...................

新規モジュール *note statistics: bd. ( PEP 450(1) で定義) は統計を扱う中
核機能のいくつかを標準ライブラリで直接提供します。このモジュールはデータ
系列の平均、中央値、最頻値、分散、標準偏差の計算をサポートします。

参考
....

PEP 450(2) - 標準ライブラリに統計モジュールを追加

     PEP written and implemented by Steven D'Aprano

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0450/

   (2) https://peps.python.org/pep-0450/


File: python.info,  Node: tracemalloc<4>,  Prev: statistics<6>,  Up: 新たなモジュール<8>

1.10.3.7 tracemalloc
....................

新たな *note tracemalloc: e8. モジュール ( PEP 454(1) で定義) は Python
が割り当てたメモリブロックをトレースするためのデバッグツールです。 以下
の情報を提供します:

   * オブジェクトが割り当てられた場所をトレースする

   * ファイル名ごと、及び行ごとに割り当てられたメモリブロックの以下の統
     計を取ります：総サイズ、ブロック数、割り当てられたブロックの平均サ
     イズ

   * メモリリークを検出するために2つのスナップショットの差を計算します。

参考
....

PEP 454(2) - Python メモリ割り当てをトレースするための tracemalloc モジュールの追加

     PEP written and implemented by Victor Stinner

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0454/

   (2) https://peps.python.org/pep-0454/


File: python.info,  Node: 改良されたモジュール<8>,  Next: CPython の実装の変更,  Prev: 新たなモジュール<8>,  Up: What's New In Python 3 4

1.10.4 改良されたモジュール
---------------------------

* Menu:

* abc::
* aifc: aifc<2>.
* argparse: argparse<5>.
* audioop::
* base64: base64<3>.
* collections: collections<6>.
* colorsys::
* contextlib: contextlib<6>.
* dbm: dbm<6>.
* dis: dis<4>.
* doctest: doctest<4>.
* email: email<4>.
* filecmp::
* functools: functools<5>.
* gc: gc<5>.
* glob: glob<4>.
* hashlib: hashlib<6>.
* hmac: hmac<3>.
* html::
* http: http<3>.
* idlelib と IDLE: idlelib と IDLE<4>.
* importlib: importlib<9>.
* inspect: inspect<8>.
* ipaddress: ipaddress<5>.
* logging: logging<6>.
* marshal: marshal<2>.
* mmap: mmap<3>.
* multiprocessing: multiprocessing<7>.
* operator: operator<3>.
* os: os<11>.
* pdb: pdb<6>.
* pickle: pickle<4>.
* plistlib: plistlib<2>.
* poplib: poplib<3>.
* pprint: pprint<4>.
* pty::
* pydoc: pydoc<4>.
* re: re<8>.
* resource::
* select::
* shelve: shelve<2>.
* shutil: shutil<6>.
* smtpd: smtpd<3>.
* smtplib: smtplib<3>.
* socket: socket<9>.
* sqlite3: sqlite3<9>.
* ssl: ssl<10>.
* stat::
* struct: struct<2>.
* subprocess: subprocess<5>.
* sunau: sunau<2>.
* sys: sys<12>.
* tarfile: tarfile<7>.
* textwrap::
* threading: threading<7>.
* traceback: traceback<6>.
* types: types<6>.
* urllib: urllib<3>.
* unittest: unittest<9>.
* venv: venv<7>.
* wave: wave<2>.
* weakref: weakref<2>.
* xml.etree: xml etree<2>.
* zipfile: zipfile<5>.


File: python.info,  Node: abc,  Next: aifc<2>,  Up: 改良されたモジュール<8>

1.10.4.1 abc
............

新規関数 *note abc.get_cache_token(): ee2. は、オブジェクトグラフ内での
変化の影響を受けるキャッシュをいつ無効化すれば良いかを知るために使えます
。 (Contributed by Łukasz Langa in bpo-16832(1).)

新規クラス *note ABC: ee3. はそのメタクラスとして *note ABCMeta: ee4. を
持ちます。この ‘ABC’ を基底クラスとして使うことは
‘metaclass=abc.ABCMeta’ を指定するのと本質的に同じ効果を持ちますが、少な
いタイプ数で単純に書ける上に読みやすいものになります。(Contributed by
Bruno Dupuis in bpo-16049(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16832

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16049


File: python.info,  Node: aifc<2>,  Next: argparse<5>,  Prev: abc,  Up: 改良されたモジュール<8>

1.10.4.2 aifc
.............

The ‘getparams()’ method now returns a namedtuple rather than a plain
tuple.  (Contributed by Claudiu Popa in bpo-17818(1).)

‘aifc.open()’ now supports the context management protocol: when used in
a *note with: 59c. block, the ‘close()’ method of the returned object
will be called automatically at the end of the block.  (Contributed by
Serhiy Storchacha in bpo-16486(2).)

The ‘writeframesraw()’ and ‘writeframes()’ methods now accept any *note
bytes-like object: cfb.  (Contributed by Serhiy Storchaka in
bpo-8311(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17818

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16486

   (3) https://bugs.python.org/issue?@action=redirect&bpo=8311


File: python.info,  Node: argparse<5>,  Next: audioop,  Prev: aifc<2>,  Up: 改良されたモジュール<8>

1.10.4.3 argparse
.................

*note FileType: ee7. クラスが 'encoding' 引数、 'errors' 引数を受け付け
るようになりました。これは *note open(): 4e5. にそのまま渡されます。
(Contributed by Lucas Maystre in bpo-11175(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11175


File: python.info,  Node: audioop,  Next: base64<3>,  Prev: argparse<5>,  Up: 改良されたモジュール<8>

1.10.4.4 audioop
................

‘audioop’ now supports 24-bit samples.  (Contributed by Serhiy Storchaka
in bpo-12866(1).)

New ‘byteswap()’ function converts big-endian samples to little-endian
and vice versa.  (Contributed by Serhiy Storchaka in bpo-19641(2).)

All ‘audioop’ functions now accept any *note bytes-like object: cfb.
Strings are not accepted: they didn't work before, now they raise an
error right away.  (Contributed by Serhiy Storchaka in bpo-16685(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12866

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19641

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16685


File: python.info,  Node: base64<3>,  Next: collections<6>,  Prev: audioop,  Up: 改良されたモジュール<8>

1.10.4.5 base64
...............

*note base64: a. のエンコード・デコード関数が任意の *note bytes-like
object: cfb. オブジェクトを受け取れるようになりました。以前は *note
bytes: 1a4. または *note bytearray: 508. インスタンスである必要がありま
した。 (Contributed by Nick Coghlan in bpo-17839(1).)

新規関数 *note a85encode(): eea, *note a85decode(): eeb. は ‘Ascii85’ フ
ォーマットの、 *note b85encode(): eec, *note b85decode(): eed. は
git/mercurial の ‘Base85’ フォーマットの、バイナリデータのエンコード・バ
イナリデータへのデコードを提供します。 ‘a85’ 関数は、Abobe 方言を含む
‘Ascii85’ エンコーディングの変種と互換性を持たせるためのオプションを持っ
ています。(Contributed by Martin Morrison, the Mercurial project, Serhiy
Storchaka, and Antoine Pitrou in bpo-17618(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17839

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17618


File: python.info,  Node: collections<6>,  Next: colorsys,  Prev: base64<3>,  Up: 改良されたモジュール<8>

1.10.4.6 collections
....................

*note ChainMap.new_child(): eef. メソッドが、チェーンに追加する子マップ
を指定する 'm' 引数を取るようになりました。これにより、以前は組み込み辞
書が必ず maps の先頭になっていましたが、カスタムマッピング型も使えるよう
になります。(Contributed by Vinay Sajip in bpo-16613(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16613


File: python.info,  Node: colorsys,  Next: contextlib<6>,  Prev: collections<6>,  Up: 改良されたモジュール<8>

1.10.4.7 colorsys
.................

RGB -- YIQ 変換の係数の桁数が FCC NTSC version(1) に合うように広げられま
した。結果としての変化は 1% 未満のはずで、また、ほかの処理系での結果とよ
り合致するでしょう。 (Contributed by Brian Landers and Serhiy Storchaka
in bpo-14323(2).)

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/YIQ#FCC_version_of_NTSC_standard

   (2) https://bugs.python.org/issue?@action=redirect&bpo=14323


File: python.info,  Node: contextlib<6>,  Next: dbm<6>,  Prev: colorsys,  Up: 改良されたモジュール<8>

1.10.4.8 contextlib
...................

新規コンテキストマネージャ *note contextlib.suppress: ef2. によって、意
図して単独ステートメントからの例外を抑制しているというコードの意図をはっ
きりと読み手に伝えることが出来ます。 (Contributed by Raymond Hettinger
in bpo-15806(1) and Zero Piraeus in bpo-19266(2).)

新規コンテキストマネージャ *note contextlib.redirect_stdout(): db5. は、
ユーティリティスクリプトにて、その出力を *note sys.stdout: aa4. に書き出
す一方でその向き先を変えれない頑固な API の扱いを簡単にしてくれます。こ
れを使うと、 *note sys.stdout: aa4. 出力をなにかほかのストリームに振り替
えたり、あるいは *note io.StringIO: ef3. と組み合わせて文字列化したり出
来ます。後者などは特に便利で、たとえば元々はコマンドラインインターフェイ
スとして実装された関数からの出力を取り込む、などということが出来ます。こ
のコンテキストマネージャはユーティリティスクリプト以外では使わない方が肝
要です。というのもこれは *note sys.stdout: aa4. の大域的な状態に影響を与
えてしまうからです。 (Contributed by Raymond Hettinger in bpo-15805(3).)

*note contextlib: 1c. ドキュメントにも改善が行われ、コンテキストマネージ
ャを単独で使うのと再利用したり再入可能(リエントラント)するのとの違いにつ
いての *note 議論: ef4. が追加されました。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15806

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19266

   (3) https://bugs.python.org/issue?@action=redirect&bpo=15805


File: python.info,  Node: dbm<6>,  Next: dis<4>,  Prev: contextlib<6>,  Up: 改良されたモジュール<8>

1.10.4.9 dbm
............

*note dbm.open(): ef6. がコンテキスト管理プロトコルをサポートするように
なりました: *note with: 59c. ブロックで使うとデータベースオブジェクトの
‘close’ メソッドがブロックの終了時に自動的に呼び出されます。
(Contributed by Claudiu Popa and Nick Coghlan in bpo-19282(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19282


File: python.info,  Node: dis<4>,  Next: doctest<4>,  Prev: dbm<6>,  Up: 改良されたモジュール<8>

1.10.4.10 dis
.............

関数 *note show_code(): ef8, *note dis(): b02, ‘distb()’, *note
disassemble(): ef9. が新たにキーワード専用引数 'file' を受け取ります。こ
れは出力先を制御します。

*note dis: 30. モジュールはいまでは *note Instruction: 1be. クラスを中心
に据えて構築されています。これは個々のバイトコード操作の詳細に対し、オブ
ジェクト指向的なアクセスを提供するクラスです。

新規メソッド *note get_instructions(): 1bd. が、与えた Python コード片に
ついての命令 (インストラクション) ストリームを発行するイテレータを提供し
ます。これを使えば、*note dis: 30. モジュール自身が提供しているのとは違
った方法で、バイトコードオブジェクトを調べたり加工するようなプログラムを
書くことが出来ます。例えばこのように書けます:

     >>> import dis
     >>> for instr in dis.get_instructions(lambda x: x + 1):
     ...     print(instr.opname)
     LOAD_FAST
     LOAD_CONST
     BINARY_ADD
     RETURN_VALUE

*note dis: 30. モジュールにある色々な表示ツールが、これらの新しい構成要
素でもって書き直されました。

アプリケーションフレンドリな *note Bytecode: efa. クラスも追加されていま
す。これはバイトコードを調べるのに、人が読める形式としてもインストラクシ
ョン列をイテレートするのにも優しい、オブジェクト指向的な API になってい
ます。 *note Bytecode: efa. コンストラクタは ‘get_instruction()’ と同じ
引数 (と、追加でオプショナルな 'current_offset') を受け取って、結果のオ
ブジェクトは *note Instruction: 1be. オブジェクトを生成するイテレータと
して振舞うことが出来ます。このオブジェクトは、 *note dis: b02. にコンス
トラクタ引数を渡して呼び出すのと等価な *note dis: efb. メソッドも持って
いますが、マルチライン文字列で返します:

     >>> bytecode = dis.Bytecode(lambda x: x + 1, current_offset=3)
     >>> for instr in bytecode:
     ...     print('{} ({})'.format(instr.opname, instr.opcode))
     LOAD_FAST (124)
     LOAD_CONST (100)
     BINARY_ADD (23)
     RETURN_VALUE (83)
     >>> bytecode.dis().splitlines()
     ['  1           0 LOAD_FAST                0 (x)',
      '      -->     3 LOAD_CONST               1 (1)',
      '              6 BINARY_ADD',
      '              7 RETURN_VALUE']

*note Bytecode: efa. にはクラスメソッド *note from_traceback(): efc. も
あります。トレースバックから *note Bytecode: efa. を構築します。
(‘print(Bytecode.from_traceback(tb).dis())’ は ‘distb()’ を使って
‘distb(tb)’ とするのと同じです。)

(Contributed by Nick Coghlan, Ryan Kelly and Thomas Kluyver in
bpo-11816(1) and Claudiu Popa in bpo-17916(2).)

新規関数 *note stack_effect(): efd. は与えられた opcode (命令コード) と
引数の Python スタックへの effect を計算します。この情報は他からは得られ
ません。 (Contributed by Larry Hastings in bpo-19722(3).)  (--訳注:
‘PyCompile_OpcodeStackEffect’ として C API として曝した上で Python から
アクセス出来るようにしたものらしいです。 stackdepth_walk での使用箇所(4)
参照。--)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11816

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17916

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19722

   (4) 
https://hg.python.org/cpython/file/5fe72b9ed48e/Python/compile.c#l3838


File: python.info,  Node: doctest<4>,  Next: email<4>,  Prev: dis<4>,  Up: 改良されたモジュール<8>

1.10.4.11 doctest
.................

A new *note option flag: eff, *note FAIL_FAST: f00, halts test running
as soon as the first failure is detected.  (Contributed by R. David
Murray and Daniel Urban in bpo-16522(1).)

*note doctest: 31. コマンドラインインターフェイスは *note argparse: 5. を
使うようになりました。2 つの新オプション ‘-o’ と ‘-f’ が追加されています
。 ‘-o’ によりコマンドラインから *note doctest オプション: eff. を指定す
ることが出来ます。 ‘-f’ は ‘-o FAIL_FAST’ の速記法です (*note unittest:
ef. CLI でサポートされる似たオプション *note
サポートされる同じオプション: f01. に似せるためです)。 (Contributed by
R.  David Murray in bpo-11390(2).)

*note doctest: 31. はいまや、拡張モジュールの ‘__doc__’ 文字列から
doctest を見つけることが出来ます。 (Contributed by Zachary Ware in
bpo-3158(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16522

   (2) https://bugs.python.org/issue?@action=redirect&bpo=11390

   (3) https://bugs.python.org/issue?@action=redirect&bpo=3158


File: python.info,  Node: email<4>,  Next: filecmp,  Prev: doctest<4>,  Up: 改良されたモジュール<8>

1.10.4.12 email
...............

*note as_string(): f03. メソッドが、その文字列表現を生成するのに使うデフ
ォルトポリシーを上書き出来る 'policy' 引数を取るようになりました。つまり
*note Message: 25d. を作り直したり ‘flattern’ メソッドの書式化パラメータ
のためだけに *note generator: 37. を使うことなしに、 ‘as_string’ をより
多くの状況で使えるということになります。(Contributed by R. David Murray
in bpo-18600(1).)

*note as_bytes(): f04. メソッドが追加されました。これは ‘as_string’ が文
字列表現を生成するのと似たやり方で、メッセージの bytes 表現を生成します
。これは 'maxheaderlen' 引数を取りませんが、 'unixfrom' 引数と 'policy'
引数を取ります。 *note Message: 25d. の *note __bytes__(): f05. がこれを
呼び出すようにしたので、 ‘bytes(mymsg)’ は今や直感に反しない結果、つまり
完全にフォーマットされたメッセージを生成します。(Contributed by R. David
Murray in bpo-18600(2).)

*note Message.set_param(): f06. メソッドにキーワード引数 'replace' が追
加されました。真を渡すとヘッダリスト内のその位置を変更せずに関連ヘッダを
更新します。後方互換のためにデフォルトは ‘False’ です。 (Contributed by
R. David Murray in bpo-18891(3).)  サブモジュール *note contentmanager:
34. と *note policy: 46. 属性の *note content_manager: f07. の追加と併せ
て、 *note Message: 25d. の対となる二つのサブクラス (*note EmailMessage:
25c. と *note MIMEPart: f08.) が追加されました。 全てのドキュメントは、
email の新規 *note 暫定 API: ad1. の構成要素として追加されたこの新しいモ
ジュールにあります。 これらのクラスは、 email メッセージからの内容抽出や
挿入を遥かに簡単に行える、数多くの新規メソッドを提供しています。 詳細は
*note contentmanager: 34. のドキュメントと *note email; 使用例: f09. を
参照してください。 これらの API の追加作業により email6 プロジェクトの一
部として計画されていた作業は、その大部分が完了しました。 現在のところ、
暫定 API 状態は Python 3.5 で最後となる予定です (可能性としてはエラー処
理あたりのゾーンでは少々の些細な追加は残るかもしれません)。 (Contributed
by R. David Murray in bpo-18891(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18600

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18600

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18891

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18891


File: python.info,  Node: filecmp,  Next: functools<5>,  Prev: email<4>,  Up: 改良されたモジュール<8>

1.10.4.13 filecmp
.................

*note clear_cache(): f0b. 関数が追加されました。 *note filecmp: 50. は
*note os.stat(): 46d. 情報をキャッシュして最後の比較時点からのファイルの
変化をみていますが、このキャッシュをクリアします。これはたとえば、ファイ
ルシステムのタイムスタンプフィールドの解像度未満の時間差で再比較したい場
合に使えるでしょう。(Contributed by Mark Levitt in bpo-18149(1).)

New module attribute *note DEFAULT_IGNORES: f0c. provides the list of
directories that are used as the default value for the 'ignore'
parameter of the *note dircmp(): f0d. function.  (Contributed by Eli
Bendersky in bpo-15442(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18149

   (2) https://bugs.python.org/issue?@action=redirect&bpo=15442


File: python.info,  Node: functools<5>,  Next: gc<5>,  Prev: filecmp,  Up: 改良されたモジュール<8>

1.10.4.14 functools
...................

新たな *note partialmethod(): a49. デスクリプタは、ちょうど普通の
callable に対して *note partial(): 3ed. がするように、デスクリプタへの引
数部分適用を可能にします。この新しいデスクリプタをクラス定義内で使うと、
簡単に (*note partial(): 3ed. インスタンスを含む) 任意の callable を普通
のインスタンスメソッドのように振舞わせることも出来ます。(Contributed by
Alon Horev and Nick Coghlan in bpo-4331(1).)  新たな *note
singledispatch(): 605. デコレータは、Python 標準ライブラリにシングルディ
スパッチのジェネリック関数のサポートを追加します。オブジェクト指向プログ
ラミングは共通データ集合についての複数操作をまとめあげてクラスに押し込め
ようとしますが、ジェネリック関数は '異なった' 種類のデータに対して動作さ
せたい操作の複数実装をひとつにまとめあげる考え方です。(--訳注: ここで「
ジェネリック関数」と呼んでいるものを他の言語との類推で理解しようとすると
、「呼び出す側目線」では同じで、「呼び出される側」目線では違うかもしれま
せん。例えば C++ ユーザは「template の特殊化」もしくは「型ごとのオーバロ
ード」との類推で理解してください。--)

参考
....

PEP 443(2) - シングルディスパッチのジェネリック関数

     PEP written and implemented by Łukasz Langa.

*note total_ordering(): f0f. now supports a return value of *note
NotImplemented: 79d. from the underlying comparison function.
(Contributed by Katie Miller in bpo-10042(3).)

*note partial(): 3ed. 関数のピュア Python 版が標準ライブラリに追加されま
した。CPython の場合は C による高速版で置き換えられますが、ほかの Python
実装で利用出来ます。 (Contributed by Brian Thorne in bpo-12428(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4331

   (2) https://peps.python.org/pep-0443/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=10042

   (4) https://bugs.python.org/issue?@action=redirect&bpo=12428


File: python.info,  Node: gc<5>,  Next: glob<4>,  Prev: functools<5>,  Up: 改良されたモジュール<8>

1.10.4.15 gc
............

新規関数 *note get_stats(): f11. は、インタプリタが開始してからの、世代
ごと回収統計を持つ辞書の、3 世代ぶんのリストを返します。(Contributed by
Antoine Pitrou in bpo-16351(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16351


File: python.info,  Node: glob<4>,  Next: hashlib<6>,  Prev: gc<5>,  Up: 改良されたモジュール<8>

1.10.4.16 glob
..............

新規関数 *note escape(): f13. は、glob 的な展開がなされないようにして字
句通りの合致をするように、ファイル名に含まれる特殊文字をエスケープする手
段となります。(Contributed by Serhiy Storchaka in bpo-8402(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8402


File: python.info,  Node: hashlib<6>,  Next: hmac<3>,  Prev: glob<4>,  Up: 改良されたモジュール<8>

1.10.4.17 hashlib
.................

新たな関数 *note hashlib.pbkdf2_hmac(): 4d9. は PKCS#5 パスワードベース
の鍵導出関数２(1) を提供します。 (Contributed by Christian Heimes in
bpo-18582(2).)

*note hashlib: 5e. のハッシュオブジェクトの *note name: f15. 属性が、公
式にサポートされるインターフェイスになりました。これは CPython の *note
hashlib: 5e. には以前から存在していました (ただしサポートされるハッシュ
の名前を必ずしも小文字で返してはいませんでした) が、公開インターフェイス
としていなかったために、ほかのいくつかの Python 実装では以前はサポートさ
れていませんでした。(Contributed by Jason R. Coombs in bpo-18532(3).)

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/PBKDF2

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18582

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18532


File: python.info,  Node: hmac<3>,  Next: html,  Prev: hashlib<6>,  Up: 改良されたモジュール<8>

1.10.4.18 hmac
..............

*note hmac: 60. は、 *note new(): a6d. の 'key' 引数として ‘bytearray’ と
‘bytes’ を許容するようになり、また、 *note new(): a6d. 関数と *note
update(): f17. メソッドの両方への 'msg' パラメータとして、 *note
hashlib: 5e. モジュールがサポートする任意の型を許容するようになりました
。(Contributed by Jonas Borgström in bpo-18240(1).)

*note hmac.new(): a6d. 関数への 'digestmod' 引数には、*note hashlib: 5e.
が認識する任意のハッシュダイジェスト名を渡せるようになりました。これとと
もに、 'digestmod' のデフォルトとして ‘MD5’ を使う現在の振る舞いは非推奨
です。将来のバージョンの Python ではこれのデフォルト値はなくなり、指定が
必須になります。 (Contributed by Christian Heimes in bpo-17276(2).)

*note block_size: f18. 属性と *note name: f19. 属性 (と *note
digest_size: f1a. 属性の公式ドキュメント) の追加をもって、 *note hmac:
60. モジュールは完全に PEP 247(3) API を遵守するものとなりました。
(Contributed by Christian Heimes in bpo-18775(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18240

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17276

   (3) https://peps.python.org/pep-0247/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18775


File: python.info,  Node: html,  Next: http<3>,  Prev: hmac<3>,  Up: 改良されたモジュール<8>

1.10.4.19 html
..............

新規関数 *note unescape(): 925. は HTML5 文字参照を対応する Unicode 文字
に変換します。 (Contributed by Ezio Melotti in bpo-2927(1).)

*note HTMLParser: 843. が新規キーワード引数 'convert_charrefs' を受け取
ります。これが ‘True’ の場合に、全ての文字参照が自動的に変換されます。後
方互換性の問題から今はこのデフォルトを ‘False’ にしてありますが、将来バ
ージョンの Python でこれを ‘True’ に変えます。ですから値は明示的にセット
してこの新しい機能を使うように更新しておくと良いです。(Contributed by
Ezio Melotti in bpo-13633(2).)

*note HTMLParser: 843. の 'strict' 引数が非推奨となりました。
(Contributed by Ezio Melotti in bpo-15114(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2927

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13633

   (3) https://bugs.python.org/issue?@action=redirect&bpo=15114


File: python.info,  Node: http<3>,  Next: idlelib と IDLE<4>,  Prev: html,  Up: 改良されたモジュール<8>

1.10.4.20 http
..............

*note send_error(): f1d. がオプショナルなパラメータ 'explain' を受け付け
るようになりました。指定されると、拡張のエラー説明を提供するにあたって、
ハードコードされたデフォルトの代わりに使われます。この拡張のエラー説明は
‘error_message_format’ 属性を使ってフォーマットされて、エラーレスポンス
のメッセージボディとして送信されます。(Contributed by Karl Cow in
bpo-12921(1).)

*note http.server: 68. の *note コマンドラインインターフェイス: f1e. に
‘-b/--bind’ オプションが追加されました。これは特定のアドレスで listen す
ることを指示します。 (Contributed by Malte Swart in bpo-17764(2).)  (--訳
注: ネットワークプログラミングに詳しい人ほど混乱しそうなので一応。
‘--bind’ というオプション名が示すとおり、より正確に表現するなら「ユーザ
指定のネットワークインターフェイスに bind」。コミットログの表現「Expose
-bind argument for http.server, enable http.server to bind to a user
specified network interface.」の方がわかりやすいかと。 --)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12921

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17764


File: python.info,  Node: idlelib と IDLE<4>,  Next: importlib<9>,  Prev: http<3>,  Up: 改良されたモジュール<8>

1.10.4.21 idlelib と IDLE
.........................

idlelib は IDLE シェルとエディタを実装するものであってほかのプログラムか
らインポートされることを意図してはいないので、改善は毎度のリリースごとに
行われます。3.3.0 から始まり、また将来の 3.4.x リリースになされる累積的
な変更リストは ‘Lib/idlelib/NEWS.txt’ で読むことが出来ます。このファイル
は IDLE で Help ‣ About IDLE からも辿り着けます。


File: python.info,  Node: importlib<9>,  Next: inspect<8>,  Prev: idlelib と IDLE<4>,  Up: 改良されたモジュール<8>

1.10.4.22 importlib
...................

*note InspectLoader: f21. ABC に新規メソッド *note source_to_code():
dde. が追加されました。ソースデータとパスを受け取り、コードオブジェクト
を返します。これのデフォルト実装は ‘compile(data, path, 'exec',
dont_inherit=True)’ と同じです。 (Contributed by Eric Snow and Brett
Cannon in bpo-15627(1).)

*note InspectLoader: f21. では *note get_code(): f22. メソッドへのデフォ
ルト実装追加も行われました。とはいえ性能面の理由より、通常はデフォルト実
装をオーバライドすることが望ましいです。 (Contributed by Brett Cannon in
bpo-18072(2).)

The *note reload(): 4e2. function has been moved from ‘imp’ to *note
importlib: 6b. as part of the ‘imp’ module deprecation.  (Contributed by
Berker Peksag in bpo-18193(3).)

*note importlib.util: 71. now has a *note MAGIC_NUMBER: 4dc. attribute
providing access to the bytecode version number.  This replaces the
‘get_magic()’ function in the deprecated ‘imp’ module.  (Contributed by
Brett Cannon in bpo-18192(4).)

New *note importlib.util: 71. functions *note cache_from_source(): 2d5.
and *note source_from_cache(): 4e3. replace the same-named functions in
the deprecated ‘imp’ module.  (Contributed by Brett Cannon in
bpo-18194(5).)

*note importlib: 6b. ブートストラップ *note NamespaceLoader: f23. が
*note InspectLoader: f21. ABC に従うようになりました。つまりこれにより
‘runpy’ と ‘python -m’ が名前空間パッケージに対して使えるようになりまし
た。(Contributed by Brett Cannon in bpo-18058(6).)  (訳注: 3.3 以降の名
前空間パッケージについては What's New In Python 3.3 ( PEP 420(7)) 参照。
)

*note importlib.util: 71. に *note decode_source(): f24. 関数が追加され
ました。 *note universal newlines: d08. 処理を使って bytes からソースを
デコードします。 *note InspectLoader.get_source(): f25. メソッドを実装す
るのに便利です。

*note importlib.machinery.ExtensionFileLoader: c7e. に *note
get_filename(): f26. メソッドが追加されました。これは本来実装されるべき
ものでしたが見落とされていました。(Contributed by Eric Snow in
bpo-19152(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15627

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18072

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18193

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18192

   (5) https://bugs.python.org/issue?@action=redirect&bpo=18194

   (6) https://bugs.python.org/issue?@action=redirect&bpo=18058

   (7) https://peps.python.org/pep-0420/

   (8) https://bugs.python.org/issue?@action=redirect&bpo=19152


File: python.info,  Node: inspect<8>,  Next: ipaddress<5>,  Prev: importlib<9>,  Up: 改良されたモジュール<8>

1.10.4.23 inspect
.................

*note inspect: 72. モジュールに、ソースコードおよびモジュール・クラス・
関数についてのその他情報を手早く表示するための、基礎的な *note
コマンドラインインターフェイス: f28. が追加されました。 (Contributed by
Claudiu Popa and Nick Coghlan in bpo-18626(1).)

新規の *note unwrap(): f29. で、 *note functools.wraps(): f2a. (やラッパ
ー関数に ‘__wrapped__’ 属性をセットするその他 API) で作られたラッパー関
数のチェインを、簡単にほどくことが出来ます。 (Contributed by Daniel
Urban, Aaron Iles and Nick Coghlan in bpo-13266(2).)  (--訳注: 「簡単に
」の意味するところについて、 *note Python API の変更: ed6. に記述されて
いる ‘functools.update_wrapper()’ と ‘functools.wraps()’ の変更も参照し
て下さい。--)

新規 *note enum: 4c. モジュールが実装されたことを受け *note inspect: 72.
モジュールは、カスタム ‘__dir__’ メソッドに対する、またメタクラスを介し
て提供される動的クラス属性に対する、ずっと良いサポートを提供出来るように
なりました。 (Contributed by Ethan Furman in bpo-18929(3) and
bpo-19030(4).)

*note getfullargspec(): 704. と ‘getargspec()’ が *note signature():
703. API を使うようになりました。このことで、以前より遥かに幅広い
callable をサポートするようになっています。それには ‘__signature__’ 属性
を含むもの、 Argument Clinic で提供されるメタデータを含むもの、あるいは
*note functools.partial(): 3ed. オブジェクト、なども含まれます。 *note
signature(): 703. そのものとは違い、今でも *note getfullargspec(): 704,
‘getargspec()’ は ‘__wrapped__’ 属性を無視し、そして束縛されたメソッドで
最初に束縛された引数を報告するので、それが望みでないならば *note
signature(): 703. を直接使うようにあなたのコードを更新する必要があります
。(Contributed by Yury Selivanov in bpo-17481(5).)  (--訳注: What's New
In Python 3.5 を参照してください。 *note signature(): 703. により *note
getfullargspec(): 704. と ‘getargspec()’ は結果として非推奨となりました
。--)

*note signature(): 703. が CPython 関数のダックタイプをサポートするよう
になりました。これは Cython でコンパイルされた関数をサポートすることにな
ります。 (Contributed by Stefan Behnel and Yury Selivanov in
bpo-17159(6).)  (--訳注: duck type はここでは「 ‘types.FunctionType’ で
あることを要求しない」の意味。 _signature_is_functionlike(7) 参照。 --)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18626

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13266

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18929

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19030

   (5) https://bugs.python.org/issue?@action=redirect&bpo=17481

   (6) https://bugs.python.org/issue?@action=redirect&bpo=17159

   (7) 
https://hg.python.org/cpython/file/32a660a52aae/Lib/inspect.py#l1604


File: python.info,  Node: ipaddress<5>,  Next: logging<6>,  Prev: inspect<8>,  Up: 改良されたモジュール<8>

1.10.4.24 ipaddress
...................

*note ipaddress: 74. は Python 3.3 で標準ライブラリに *note 暫定 API:
ad1. として追加されました。Python 3.4 リリースで、この但し書きは削除され
ました: *note ipaddress: 74. は今や安定 API とみなされ、今後は通常の標準
ライブラリの後方互換性維持要件に従います。

新規のプロパティ *note is_global: f2c. は、アドレスが routeable である場
合に ‘True’ を返します。 (Contributed by Peter Moody in bpo-17400(1).)
(--訳注: リファレンスマニュアルでは routeable という表現ではなく「アドレ
スがパブリックネットワークに割り当てられている場合」。--)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17400


File: python.info,  Node: logging<6>,  Next: marshal<2>,  Prev: ipaddress<5>,  Up: 改良されたモジュール<8>

1.10.4.25 logging
.................

*note TimedRotatingFileHandler: f2e. に 'atTime' パラメータが追加されま
した。ロールオーバ対象となる日付での時刻を指定します。 (Contributed by
Ronald Oussoren in bpo-9556(1).)

*note SocketHandler: f2f. と *note DatagramHandler: f30. が Unix ドメイ
ンソケットをサポートするようになりました ('port' に ‘None’ をセットする
ことで)。 (Contributed by Vinay Sajip in commit ce46195b56a9(2) .)

*note fileConfig(): b1f. が 'fname' パラメータとして *note
configparser.RawConfigParser: f31. のサブクラスを許容するようになりまし
た。これはロギングの設定がアプリケーション全体の設定の一部に過ぎない場合
や、 *note fileConfig(): b1f. に渡す前にアプリケーションが設定を修正する
ような場合でも設定ファイルを使用することを容易にします。(Contributed by
Vinay Sajip in bpo-16110(3).)

*note logging.config.listen(): f32. 関数経由でソケットから受信したロギン
グ設定データを、処理前に検証出来るようになりました。新規のキーワード引数
'verify' に検証関数を渡すことで可能です。(Contributed by Vinay Sajip in
bpo-15452(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9556

   (2) https://hg.python.org/cpython/rev/ce46195b56a9

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16110

   (4) https://bugs.python.org/issue?@action=redirect&bpo=15452


File: python.info,  Node: marshal<2>,  Next: mmap<3>,  Prev: logging<6>,  Up: 改良されたモジュール<8>

1.10.4.26 marshal
.................

*note marshal: 80. のバージョンが 3 に上げられました。新バージョンを実装
しているコードは、intern された文字列をただ一つのコピーだけ記録しておき
デシリアライズでその intern を維持するという Python 2 での振舞いを復活さ
せつつ、「ただ一つのコピー」を文字列型のみならず任意のオブジェクト型に
(再帰参照の処理も含め) 拡張しています。これは ‘.pyc’ ファイルのサイズを
削減し、また、 ‘.pyc’ (または ‘.pyo’) ファイルからロードされる際にモジュ
ールが占めるメモリ量を削減します。(Contributed by Kristján Valur Jónsson
in bpo-16475(1), with additional speedups by Antoine Pitrou in
bpo-19219(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16475

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19219


File: python.info,  Node: mmap<3>,  Next: multiprocessing<7>,  Prev: marshal<2>,  Up: 改良されたモジュール<8>

1.10.4.27 mmap
..............

mmap objects are now *note weakly referenceable: ed5.  (Contributed by
Valerie Lambert in bpo-4885(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4885


File: python.info,  Node: multiprocessing<7>,  Next: operator<3>,  Prev: mmap<3>,  Up: 改良されたモジュール<8>

1.10.4.28 multiprocessing
.........................

*note multiprocessing: 86. を使ってプロセスを開始する *note 開始方式:
2a9. として、Unix において 2 つ、 ‘spawn’ と ‘forkserver’ が追加されまし
た。これらはスレッドとプロセスのミックスをより堅牢にし、また、 ‘spawn’ は
multiprocessing が以前から常に Windows で使ってきたセマンティクスと一致
します。新規関数の、 *note get_all_start_methods(): f36. はプラットフォ
ームで利用出来るすべての開始方式を報告し、 *note get_start_method():
f37. は現在設定されている開始方式を報告し、 *note set_start_method():
2a8. は開始方式を設定します。(Contributed by Richard Oudkerk in
bpo-8713(1).)

*note multiprocessing: 86. には、子プロセスがどのように作られるかを決定
する ‘context’ のコンセプトが追加されています。新規関数 *note
get_context(): 2a7. は指定した開始方式を使うコンテキストを返します。コン
テキストは *note multiprocessing: 86. モジュール自身と同じ API を持って
いるので、コンテキスト内で操作する *note Pool: f38. や他のオブジェクトを
、それを使って作成することが出来ます。コンテキストによって、フレームワー
クとアプリケーションあるいは同じアプリケーションの別の部分が相互に干渉し
あわないようにして multiprocessing を使うことが出来ます。(Contributed by
Richard Oudkerk in bpo-18999(2).)

昔からの 'fork' 開始方式を除き、子プロセスはもはや必要のないハンドル・フ
ァイル記述子をその親から継承しません。 (part of bpo-8713(3)).

*note multiprocessing: 86. が開始方式に ‘spawn’ または ‘forkserver’ を使
う場合に、子プロセスで適切に ‘__main__’ を初期化するために *note runpy:
ac. (これが ‘-m’ スイッチを実装しています) に頼るようになりました。これ
は、 multiprocessing と ‘-m’ コマンドラインスイッチ・明示的な相対インポ
ートを組み合わせると子プロセスが不可解に失敗していたような、いくつかの際
どい問題を解決します。 (Contributed by Nick Coghlan in bpo-19946(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8713

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18999

   (3) https://bugs.python.org/issue?@action=redirect&bpo=8713

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19946


File: python.info,  Node: operator<3>,  Next: os<11>,  Prev: multiprocessing<7>,  Up: 改良されたモジュール<8>

1.10.4.29 operator
..................

新規関数 *note length_hint(): f3a. は、言語仕様となった特殊メソッド
*note __length_hint__(): ed7. の PEP 424(1) 公式仕様の一環として、それが
どのように使われるのかについて詳述する実装を提供します。(Contributed by
Armin Ronacher in bpo-16148(2).)

参照実装として、また Python 実装の代替として用いることが出来る、 *note
operator: 8f. モジュールのピュア Python 版が書かれました。 (Contributed
by Zachary Ware in bpo-16694(3).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0424/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16148

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16694


File: python.info,  Node: os<11>,  Next: pdb<6>,  Prev: operator<3>,  Up: 改良されたモジュール<8>

1.10.4.30 os
............

新規関数により *note 継承可能フラグ: ec4. を制御出来るようになりました。
ファイル記述子には *note os.get_inheritable(): ec5, *note
os.set_inheritable(): ec6. を、Windows のハンドルには *note
os.get_handle_inheritable(): ec7, *note os.set_handle_inheritable():
ec8. を使います。

関数 *note cpu_count(): 1a7. が追加されました。これは Python を実行して
いるプラットフォームで利用可能な CPU 数を返します (決定できない場合は
‘None’ を返します)。既存の *note multiprocessing.cpu_count(): f3c. はこ
の関数の値を返すようになりました。(Contributed by Trent Nelson, Yogesh
Chaudhari, Victor Stinner, and Charles-François Natali in bpo-17914(1).)

*note os.path.samestat(): f3d. が Windows プラットフォームでも動作するよ
うになりました (また、 *note os.path.samefile(): f3e. の実装は Unix と
Windows で共有されました)。 (Contributed by Brian Curtin in
bpo-11939(2).)

*note os.path.ismount(): 9e0. が Windows において、ドライブルートよりも
下にあるマウントポイントを認識するようになりました。 (Contributed by Tim
Golden in bpo-9035(3).)

*note os.open(): d5f. supports two new flags on platforms that provide
them, *note O_PATH: f3f. (un-opened file descriptor), and *note
O_TMPFILE: f40. (unnamed temporary file; as of 3.4.0 release available
only on Linux systems with a kernel version of 3.11 or newer that have
uapi headers).  (Contributed by Christian Heimes in bpo-18673(4) and
Benjamin Peterson, respectively.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17914

   (2) https://bugs.python.org/issue?@action=redirect&bpo=11939

   (3) https://bugs.python.org/issue?@action=redirect&bpo=9035

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18673


File: python.info,  Node: pdb<6>,  Next: pickle<4>,  Prev: os<11>,  Up: 改良されたモジュール<8>

1.10.4.31 pdb
.............

*note pdb: 94. が、ジェネレータ、 *note yield: 99b. 、 ‘yield from’ をよ
り価値ある方法で処理するように強化されました。これは *note asyncio: 8. ベ
ースのプログラムをデバッグする際にとりわけ助けとなります。 (Contributed
by Andrew Svetlov and Xavier de Gaye in bpo-16596(1).)

*note pdb: 94. から ‘print’ コマンドは削除され、pdb コマンドラインからの
Python *note print(): f42. 関数へのアクセスを取り戻しました。 Python 2 の
‘pdb’ には ‘print’ コマンドはなく ‘print’ の入力は Python 2 の ‘print’ 文
を実行していました。 Python 3 で pdb の *note p: f43. コマンドへのエイリ
アスとして ‘print’ を作ったのが間違いでした。 ‘p’ はその引数の ‘repr’ を
表示するのであって、Python 2 での ‘print’ コマンドがしていた ‘str’ を表
示するのではありません。さらに悪いことに、Python 3 の ‘pdb print’ コマン
ドは Python 3 の ‘print’ 関数を隠してしまい、 ‘pdb’ プロンプトからのアク
セスを出来なくしていたのでした。 (Contributed by Connor Osborn in
bpo-18764(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16596

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18764


File: python.info,  Node: pickle<4>,  Next: plistlib<2>,  Prev: pdb<6>,  Up: 改良されたモジュール<8>

1.10.4.32 pickle
................

*note pickle: 95. で新 pickle プロトコル 4 が追加されました (デフォルト
にはされていません)。この新プロトコルは、入れ子のクラスや巨大な文字列・
コンテナやキーワード専用引数を取る ‘__new__()’ メソッドを持つクラスなど
にまつわるシリアライズの問題など、以前のプロトコルに存在していた数多くの
問題を措置しています。ほかにもいくつか効率面での改善が入っています。

参考
....

PEP 3154(1) - Pickle プロトコル 4

     PEP written by Antoine Pitrou and implemented by Alexandre
     Vassalotti.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3154/


File: python.info,  Node: plistlib<2>,  Next: poplib<3>,  Prev: pickle<4>,  Up: 改良されたモジュール<8>

1.10.4.33 plistlib
..................

*note plistlib: 99. now has an API that is similar to the standard
pattern for stdlib serialization protocols, with new *note load(): 91d,
*note dump(): 91f, *note loads(): 91e, and *note dumps(): 920.
functions.  (The older API is now deprecated.)  In addition to the
already supported XML plist format (*note FMT_XML: f46.), it also now
supports the binary plist format (*note FMT_BINARY: f47.).  (Contributed
by Ronald Oussoren and others in bpo-14455(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14455


File: python.info,  Node: poplib<3>,  Next: pprint<4>,  Prev: plistlib<2>,  Up: 改良されたモジュール<8>

1.10.4.34 poplib
................

*note poplib: 9a. に 2 つの新規メソッドが追加されました。 *note capa():
f49. は POP サーバにより公表された機能リストを返します。 *note stls():
f4a. は平文 POP3 セッションを、POP サーバがサポートしていれば暗号化され
た POP3 セッションに切り替えます。 (Contributed by Lorenzo Catucci in
bpo-4473(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4473


File: python.info,  Node: pprint<4>,  Next: pty,  Prev: poplib<3>,  Up: 改良されたモジュール<8>

1.10.4.35 pprint
................

*note pprint: 9c. モジュールの、 *note PrettyPrinter: f4c. クラス、
*note pformat(): f4d. 関数、 *note pprint(): 7f3. 関数に、新規オプション
'compact' が追加されました。これは出力方法を制御するもので、今のところの
これの ‘True’ での振舞いは、個々の (インデントされた) 行を 'width' 幅で
出来るだけ多くのシーケンスの要素が収まるように出力します。 (Contributed
by Serhiy Storchaka in bpo-19132(1).)

長い文字列が Python の普通の行継続構文で折り返されるようになりました。
(Contributed by Antoine Pitrou in bpo-17150(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19132

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17150


File: python.info,  Node: pty,  Next: pydoc<4>,  Prev: pprint<4>,  Up: 改良されたモジュール<8>

1.10.4.36 pty
.............

*note pty.spawn(): f4f. が ‘None’ ではなく *note os.waitpid(): d67. から
の戻り値から取ったステータス値を返すようになりました。 (Contributed by
Gregory P. Smith.)


File: python.info,  Node: pydoc<4>,  Next: re<8>,  Prev: pty,  Up: 改良されたモジュール<8>

1.10.4.37 pydoc
...............

*note pydoc: a3. モジュールがイントロスペクション API *note
inspect.signature(): 703. に直接基くようになりました。これによりより幅広
く callable オブジェクトのシグニチャ情報を提供出来るようになりました。こ
の変更は、ヘルプ情報表示の際に ‘__wrapped__’ 属性も考慮に入れられること
も意味しています。(Contributed by Larry Hastings in bpo-19674(1).)

*note pydoc: a3. モジュールはもはや既に束縛済みのメソッドでは ‘self’ パ
ラメータを表示しません。それよりも、与えられた callable の正確な現在のシ
グニチャを常に表示しようとします。 (Contributed by Larry Hastings in
bpo-20710(2).)

*note pydoc: a3. に直接なされた変更に加え、背後の *note inspect: 72. モ
ジュールの改善が、カスタム ‘__dir__’ メソッドやさまざまなデスクリプタの
扱いについての振る舞いの大幅な改善に寄与しました。

組み込み *note help(): 8a5. は *note pydoc: a3. モジュールに基いているの
で、上記変更は *note help(): 8a5. の振る舞いにも影響します。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19674

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20710


File: python.info,  Node: re<8>,  Next: resource,  Prev: pydoc<4>,  Up: 改良されたモジュール<8>

1.10.4.38 re
............

*note fullmatch(): f52. 関数と ‘regex.fullmatch()’ メソッドが追加されま
した。これはパターンを合致する文字列の両端に固定します。コード変更や既存
の正規表現になにか代わりとなるものを追加したりする際に、末尾に ‘$’ を入
れ忘れるといった類のバグは気付きにくいものです。これらの関数で、合致すべ
き終端をはっきり伝えることが出来ます。 (Contributed by Matthew Barnett
in bpo-16203(1).)

*note 正規表現オブジェクト: f53. の repr にパターンとフラグを含めるよう
になりました。 *note match オブジェクト: f54. の repr に start、end と合
致した部分文字列を含むようになりました。 (Contributed by Hugo Lopes
Tavares and Serhiy Storchaka in bpo-13592(2) and bpo-17087(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16203

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13592

   (3) https://bugs.python.org/issue?@action=redirect&bpo=17087


File: python.info,  Node: resource,  Next: select,  Prev: re<8>,  Up: 改良されたモジュール<8>

1.10.4.39 resource
..................

新規関数 *note prlimit(): f56. は、指定プロセスのリソースリミットの問い
合わせとセットを、一度の呼び出しで行えます。カーネルバージョン 2.6.36 以
降で glibc 2.13 以降の Linux プラットフォームで利用可能です。
(Contributed by Christian Heimes in bpo-16595(1).)

On Linux kernel version 2.6.36 or later, there are also some new Linux
specific constants: *note RLIMIT_MSGQUEUE: f57, *note RLIMIT_NICE: f58,
*note RLIMIT_RTPRIO: f59, *note RLIMIT_RTTIME: f5a, and *note
RLIMIT_SIGPENDING: f5b.  (Contributed by Christian Heimes in
bpo-19324(2).)

On FreeBSD version 9 and later, there some new FreeBSD specific
constants: *note RLIMIT_SBSIZE: f5c, *note RLIMIT_SWAP: f5d, and *note
RLIMIT_NPTS: f5e.  (Contributed by Claudiu Popa in bpo-19343(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16595

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19324

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19343


File: python.info,  Node: select,  Next: shelve<2>,  Prev: resource,  Up: 改良されたモジュール<8>

1.10.4.40 select
................

*note epoll: f60. がコンテキスト管理プロトコルをサポートするようになりま
した: *note with: 59c. ブロックで使うと *note close(): f61. メソッドがブ
ロックの終了時に自動的に呼び出されます。 (Contributed by Serhiy
Storchaka in bpo-16488(1).)

*note devpoll: f62. オブジェクトに、メソッド *note fileno(): f63. とメソ
ッド *note close(): f64. 、それに属性 *note closed: f65. が追加されまし
た。 (Contributed by Victor Stinner in bpo-18794(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16488

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18794


File: python.info,  Node: shelve<2>,  Next: shutil<6>,  Prev: select,  Up: 改良されたモジュール<8>

1.10.4.41 shelve
................

*note Shelf: f67. がコンテキスト管理プロトコルをサポートするようになりま
した: ‘with’ ブロックで使うとブロックの終了時に自動的にクローズされます
。 (Contributed by Filip Gruszczyński in bpo-13896(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13896


File: python.info,  Node: shutil<6>,  Next: smtpd<3>,  Prev: shelve<2>,  Up: 改良されたモジュール<8>

1.10.4.42 shutil
................

*note copyfile(): a27. が、コピー元とコピー先が同じファイルの場合に
*note Error: f69. の限定されたサブクラスである *note SameFileError: f6a.
を投げるようになりました。これにより、アプリケーションはこの特定のエラー
でそれに相応しいアクションを取れます。 (Contributed by Atsuo Ishimoto
and Hynek Schlawack in bpo-1492704(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1492704


File: python.info,  Node: smtpd<3>,  Next: smtplib<3>,  Prev: shutil<6>,  Up: 改良されたモジュール<8>

1.10.4.43 smtpd
...............

The ‘SMTPServer’ and ‘SMTPChannel’ classes now accept a 'map' keyword
argument which, if specified, is passed in to ‘asynchat.async_chat’ as
its 'map' argument.  This allows an application to avoid affecting the
global socket map.  (Contributed by Vinay Sajip in bpo-11959(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11959


File: python.info,  Node: smtplib<3>,  Next: socket<9>,  Prev: smtpd<3>,  Up: 改良されたモジュール<8>

1.10.4.44 smtplib
.................

*note SMTPException: f6d. が *note OSError: 3f0. のサブクラスになりまし
た。これによって、とにかくエラーが起こったのだということにしか関心がない
コードが、ソケット階層でのエラーと SMTP プロトコル階層の両エラーを一撃の
try/except 文で捕捉出来るようになりました。 (Contributed by Ned Jackson
Lovely in bpo-2118(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2118


File: python.info,  Node: socket<9>,  Next: sqlite3<9>,  Prev: smtplib<3>,  Up: 改良されたモジュール<8>

1.10.4.45 socket
................

The socket module now supports the *note CAN_BCM: f6f. protocol on
platforms that support it.  (Contributed by Brian Thorne in
bpo-15359(1).)

ソケットオブジェクトで *note 継承可能フラグ: ec4. を制御出来るようになり
ました。 *note get_inheritable(): ec9. で取得し、 *note
set_inheritable(): eca. でセットします。

定数値の ‘socket.AF_*’ と ‘socket.SOCK_*’ が、新規の *note enum: 4c. モ
ジュールを使った列挙値になりました。つまりデバッグなどで魑魅魍魎な整数で
はなく徳高い名前で表示されるということです。

The *note AF_LINK: f70. constant is now available on BSD and OSX.

*note inet_pton(): 930. と *note inet_ntop(): f71. が Windows でサポート
されるようになりました。 (Contributed by Atsuo Ishimoto in bpo-7171(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15359

   (2) https://bugs.python.org/issue?@action=redirect&bpo=7171


File: python.info,  Node: sqlite3<9>,  Next: ssl<10>,  Prev: socket<9>,  Up: 改良されたモジュール<8>

1.10.4.46 sqlite3
.................

*note connect(): 288. 関数に新規の真偽値パラメータ 'uri' が追加されまし
た。これを真にセットすると 'database' パラメータを URI として解釈させる
ことが出来ます。 (SQLite の URI のドキュメント(1) を参照してください)。
(Contributed by poq in bpo-13773(2).)

   ---------- Footnotes ----------

   (1) https://www.sqlite.org/uri.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13773


File: python.info,  Node: ssl<10>,  Next: stat,  Prev: sqlite3<9>,  Up: 改良されたモジュール<8>

1.10.4.47 ssl
.............

*note PROTOCOL_TLSv1_1: f74. と *note PROTOCOL_TLSv1_2: f75. (TLSv1.1 と
TLSv1.2 のサポート) が追加されました。これらプロトコルのサポートは
Python が OpenSSL 1.0.1 以降とリンクしている場合にのみ利用可能です。
(Contributed by Michele Orrù and Antoine Pitrou in bpo-16692(1).)  新規
関数 *note create_default_context(): 13b. は、互換性とセキュリティの間の
程よいバランスとなるよう調整された *note SSLContext: 274. を得るための標
準手段として追加されました。それらの設定は *note SSLContext: 274. コンス
トラクタが与えるデフォルトよりも厳しく、そして将来的にセキュリティにおけ
るベストプラクティスによる要請が変化すれば、事前予告なしで調整されるかも
しれません。SSL をサポートする標準ライブラリの使用においての新しいベスト
プラクティスとして、 *note SSLContext: 274. を得るのには *note
create_default_context(): 13b. を使うことが推奨です。必要に応じ、対応す
る標準ライブラリ API の 'context' 引数に渡すためにそれを使うよう修正して
ください。(Contributed by Christian Heimes in bpo-19689(2).)

*note SSLContext: 274. のメソッド *note load_verify_locations(): eb6. に
オプショナル引数 'cadata' が追加されました。これには PEM あるいは DER エ
ンコードの証明書を直接指定できます。前者の場合は文字列で、後者では *note
bytes-like object: cfb. で指定します。(Contributed by Christian Heimes
in bpo-18138(3).)

関数 *note get_default_verify_paths(): f76. が追加されました。これは
*note set_default_verify_paths(): f77. メソッドが OpenSSL デフォルトの
‘cafile’ と ‘capath’ をセットするのに使うパスと環境変数から成る名前付き
タプルを返します。デフォルトの検証にまつわる問題をデバッグするのに使える
でしょう。(Contributed by Christian Heimes in bpo-18143(4).)

*note SSLContext: 274. の新規メソッド *note cert_store_stats(): f78. は
ロードされた ‘X.509’ 証明書、 ‘X.509 CA’ 証明書、証明書失効リスト
(‘crl’) を報告し、また、新規メソッド *note get_ca_certs(): f79. はロード
された ‘CA’ 証明書のリストを返します。(Contributed by Christian Heimes
in bpo-18147(5).)

If OpenSSL 0.9.8 or later is available, *note SSLContext: 274. has a new
attribute *note verify_flags: f7a. that can be used to control the
certificate verification process by setting it to some combination of
the new constants *note VERIFY_DEFAULT: f7b, *note
VERIFY_CRL_CHECK_LEAF: f7c, *note VERIFY_CRL_CHECK_CHAIN: f7d, or *note
VERIFY_X509_STRICT: 13d.  OpenSSL does not do any CRL verification by
default.  (Contributed by Christien Heimes in bpo-8813(6).)

*note SSLContext: 274. の新規メソッド *note load_default_certs(): f7e. は
、プラットフォームによって異なるデフォルトの場所から “認証局”
(CA=certification authority) 証明書ファイル一式をロードします。クライア
ントがサーバを検証するための TLS web サーバ証明の証明書をロード
(‘purpose=’*note SERVER_AUTH: f7f.) することも、サーバがクライアント証明
書を検証するのに用いる証明書をロード (‘purpose=’*note CLIENT_AUTH: f80.)
することも出来ます。(Contributed by Christian Heimes in bpo-19292(7).)
Windows だけで利用出来る関数が 2 つ追加されました。 *note
enum_certificates(): f81. と *note enum_crls(): f82. で Windows のシステ
ム証明書ストアから、証明書、証明書の情報、CRLs (certification
revocation=証明書失効リスト) を抽出出来ます。(Contributed by Christian
Heimes in bpo-17134(8).)  新規メソッド *note
ssl.SSLContext.set_servername_callback(): f83. によるサーバサイド SNI
(Server Name Indication) サポートが追加されました。 (Contributed by
Daniel Black in bpo-8109(9).)

*note SSLSocket.getpeercert(): f84. が返す辞書に ‘X509v3’ 拡張アイテムを
含むようになりました: ‘crlDistributionPoints’, ‘caIssuers’, ‘OCSP’ URI。
(Contributed by Christian Heimes in bpo-18379(10).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16692

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19689

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18138

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18143

   (5) https://bugs.python.org/issue?@action=redirect&bpo=18147

   (6) https://bugs.python.org/issue?@action=redirect&bpo=8813

   (7) https://bugs.python.org/issue?@action=redirect&bpo=19292

   (8) https://bugs.python.org/issue?@action=redirect&bpo=17134

   (9) https://bugs.python.org/issue?@action=redirect&bpo=8109

   (10) https://bugs.python.org/issue?@action=redirect&bpo=18379


File: python.info,  Node: stat,  Next: struct<2>,  Prev: ssl<10>,  Up: 改良されたモジュール<8>

1.10.4.48 stat
..............

The *note stat: bc. module is now backed by a C implementation in
‘_stat’.  A C implementation is required as most of the values aren't
standardized and are platform-dependent.  (Contributed by Christian
Heimes in bpo-11016(1).)

The module supports new *note ST_MODE: f86. flags, *note S_IFDOOR: f87,
*note S_IFPORT: f88, and *note S_IFWHT: f89.  (Contributed by Christian
Hiemes in bpo-11016(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11016

   (2) https://bugs.python.org/issue?@action=redirect&bpo=11016


File: python.info,  Node: struct<2>,  Next: subprocess<5>,  Prev: stat,  Up: 改良されたモジュール<8>

1.10.4.49 struct
................

関数 *note iter_unpack: f8b. と、コンパイル済フォーマットでのメソッド
*note struct.Struct.iter_unpack(): f8c. が追加されました。これは、与えら
れたデータフォーマットの繰り返しインスタンスを含むバッファを逐次的にアン
パックします。 (Contributed by Antoine Pitrou in bpo-17804(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17804


File: python.info,  Node: subprocess<5>,  Next: sunau<2>,  Prev: struct<2>,  Up: 改良されたモジュール<8>

1.10.4.50 subprocess
....................

*note check_output(): f8e. が 'input' 引数を受け付けるようになりました。
これは実行するコマンドにとっての ‘stdin’ を供給するのに使われます (訳注:
*note run(): b54. のドキュメント参照)。 (Contributed by Zack Weinberg in
bpo-16624(1).)

‘getstatus()’ と *note getstatusoutput(): f8f. が Windows でも動作するよ
うになりました。ただしこの変更は実際には、不注意で 3.3.4 に対して既に行
われました。 (Contributed by Tim Golden in bpo-10197(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16624

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10197


File: python.info,  Node: sunau<2>,  Next: sys<12>,  Prev: subprocess<5>,  Up: 改良されたモジュール<8>

1.10.4.51 sunau
...............

The ‘getparams()’ method now returns a namedtuple rather than a plain
tuple.  (Contributed by Claudiu Popa in bpo-18901(1).)

‘sunau.open()’ now supports the context management protocol: when used
in a *note with: 59c. block, the ‘close’ method of the returned object
will be called automatically at the end of the block.  (Contributed by
Serhiy Storchaka in bpo-18878(2).)

24 ビットサンプルの出力をサポートしました。つまり
‘AU_write.setsampwidth()’ に 24 ビットに対応する値をセット出来ます。
(Contributed by Serhiy Storchaka in bpo-19261(3).)

The ‘writeframesraw()’ and ‘writeframes()’ methods now accept any *note
bytes-like object: cfb.  (Contributed by Serhiy Storchaka in
bpo-8311(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18901

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18878

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19261

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8311


File: python.info,  Node: sys<12>,  Next: tarfile<7>,  Prev: sunau<2>,  Up: 改良されたモジュール<8>

1.10.4.52 sys
.............

新規関数 *note sys.getallocatedblocks(): f92. は、現在インタプリタにより
アロケートされているブロック数を返します (デフォルトの ‘--with-pymalloc’
設定での CPython では、これは *note PyObject_Malloc(): c36. API によるア
ロケーションです)。これはメモリリークの追跡に、とりわけテストスイートで
自動化されている場合はなおさら有用です。 (Contributed by Antoine Pitrou
in bpo-13390(1).)

Python インタプリタが *note 対話モード: f93. で開始する際に *note sys:
c3. モジュールの属性 *note __interactivehook__: f94. をチェックするよう
になりました。この属性があると、対話モード開始直前にその設定値が引数なし
で呼び出されます。このチェックは *note PYTHONSTARTUP: f95. ファイルが読
み込まれたあとで行われるので、そのファイル内でセット出来ます。 *note
site: b5. モジュールは *note readline: a8. をサポートするプラットフォー
ムではタブ補完と (‘~/.python-history’ への) 履歴保存を有効にする関数を
*note __interactivehook__ にセットします: f96. 。この (新たな) 振る舞い
がお気に召さなければ、 *note PYTHONSTARTUP: f95, *note sitecustomize:
b6, *note usercustomize: f7. のいずれかで *note sys: c3. からこの属性を
削除 (あるいはほかのなにか callable をセット) してください。
(Contributed by Éric Araujo and Antoine Pitrou in bpo-5845(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13390

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5845


File: python.info,  Node: tarfile<7>,  Next: textwrap,  Prev: sys<12>,  Up: 改良されたモジュール<8>

1.10.4.53 tarfile
.................

*note tarfile: c8. モジュールはスクリプトや直接 ‘-m’ で呼ばれた場合、簡
単な *note コマンドラインインターフェイス: f98. をサポートするようになり
ました。 これにより tar ファイルアーカイブの作成や解凍が可能です。
(Contributed by Berker Peksag in bpo-13477(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13477


File: python.info,  Node: textwrap,  Next: threading<7>,  Prev: tarfile<7>,  Up: 改良されたモジュール<8>

1.10.4.54 textwrap
..................

*note TextWrapper: f9a. に 2 つ新しい制御変数が追加されていて、これらは
属性値であり、コンストラクタ引数に渡せます。それぞれ *note max_lines:
f9b. が最大出力行数、 *note placeholder: f9c. が 'max_lines' により切り
詰める場合に出力の最終行に置くテキストです。これら機能を使った新規のコン
ビニエンス関数 *note shorten(): f9d. が追加されています。これは入力に含
まれる全ての空白文字を単一の空白に置き換え、また幅 'width' に収めて、切
り詰める場合は末尾を 'placeholder' (デフォルトで ‘[...]’) で置き換えて、
単一行で返します。(Contributed by Antoine Pitrou and Serhiy Storchaka in
bpo-18585(1) and bpo-18725(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18585

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18725


File: python.info,  Node: threading<7>,  Next: traceback<6>,  Prev: textwrap,  Up: 改良されたモジュール<8>

1.10.4.55 threading
...................

メインスレッドを表現する *note Thread: 91a. オブジェクトを、新規関数
*note main_thread(): f9f. で得られるようになりました。通常の条件であれば
これは Python インタプリタを開始したスレッドになります。 (Contributed by
Andrew Svetlov in bpo-18882(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18882


File: python.info,  Node: traceback<6>,  Next: types<6>,  Prev: threading<7>,  Up: 改良されたモジュール<8>

1.10.4.56 traceback
...................

新規関数 *note traceback.clear_frames(): fa1. は、トレースバックオブジェ
クトを受け取って、それが参照している全てのフレーム内のローカル変数をクリ
アすることで、メモリ消費量を削減します。 (Contributed by Andrew Kuchling
in bpo-1565525(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1565525


File: python.info,  Node: types<6>,  Next: urllib<3>,  Prev: traceback<6>,  Up: 改良されたモジュール<8>

1.10.4.57 types
...............

新規デスクリプタ *note DynamicClassAttribute(): 5f6. は、そのアクセスが
インスタンスからの場合には普通に振舞いつつクラスからのアクセスでは 'クラ
ス' の __getattr__ メソッドに振り向ける属性、これを定義する手段を提供し
ます。このことにより、インスタンス上ではアクティブなプロパティを持ち、ク
ラス上では同名の仮想的属性を持つ、といったことが出来ます (*note Enum:
5fc. がこれの実例になっています)。 (Contributed by Ethan Furman in
bpo-19030(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19030


File: python.info,  Node: urllib<3>,  Next: unittest<9>,  Prev: types<6>,  Up: 改良されたモジュール<8>

1.10.4.58 urllib
................

*note urllib.request: f4. が新規クラス *note DataHandler: fa4. を介して
‘data:’ URL をサポートするようになりました。 (Contributed by Mathias
Panzenböck in bpo-16423(1).)

*note Request: fa5. クラスで使われる HTTP メソッドを、サブクラスで *note
method: fa6. 属性をセットすることにより指定出来るようになりました。
(Contributed by Jason R Coombs in bpo-18978(2).)  (--訳注: *note method:
fa6. は 3.3 で追加されたが、コンストラクタに渡されたものが設定されるだけ
だった。--)

*note Request: fa5. オブジェクトは今では再利用可能です: *note full_url:
fa7. あるいは *note data: fa8. 属性などが変更されると、関連する全ての内
部プロパティが更新されます。このことによって今や、例えば、 *note
Request: fa5. オブジェクトを、異なる 'data' 引数での *note
OpenerDirector.open(): fa9. の複数回呼び出し内で使ったり、あるいは、まっ
さらから作り直すのではなく *note Request: fa5. の ‘url’ を書き換えて使っ
たり出来ます。新たに *note remove_header(): faa. メソッドも追加されてい
て、これは *note Request: fa5. からヘッダを取り除きます。 (Contributed
by Alexey Kachayev in bpo-16464(3), Daniel Wozniak in bpo-17485(4), and
Damien Brecht and Senthil Kumaran in bpo-17272(5).)

*note HTTPError: fab. オブジェクトに、エラーに関係する HTTP レスポンスヘ
ッダへのアクセスを提供する *note headers: fac. 属性が追加されました。
(Contributed by Berker Peksag in bpo-15701(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16423

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18978

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16464

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17485

   (5) https://bugs.python.org/issue?@action=redirect&bpo=17272

   (6) https://bugs.python.org/issue?@action=redirect&bpo=15701


File: python.info,  Node: unittest<9>,  Next: venv<7>,  Prev: urllib<3>,  Up: 改良されたモジュール<8>

1.10.4.59 unittest
..................

The *note TestCase: 41a. class has a new method, *note subTest(): fae,
that produces a context manager whose *note with: 59c. block becomes a
"sub-test".  This context manager allows a test method to dynamically
generate subtests by, say, calling the ‘subTest’ context manager inside
a loop.  A single test method can thereby produce an indefinite number
of separately identified and separately counted tests, all of which will
run even if one or more of them fail.  For example:

     class NumbersTest(unittest.TestCase):
         def test_even(self):
             for i in range(6):
                 with self.subTest(i=i):
                     self.assertEqual(i % 2, 0)

これは 6 つのサブテストとなり、それぞれは unittest 内の冗長出力において
、変数名 ‘i’ とその変数への個々の値 (‘i=0’, ‘i=1’, など) からなるラベル
で識別されます。この例の完全なバージョンが *note
サブテストを利用して繰り返しテストの区別を付ける: faf. にあります。
(Contributed by Antoine Pitrou in bpo-16997(1).)

*note unittest.main(): fb0. の 'defaultTest' に、テスト名からなるイテラ
ブルを渡せるようになりました。以前は文字列で単一のテスト名を渡せるだけで
した。 (Contributed by Jyrki Pulliainen in bpo-15132(2).)

テストディスカバリ最中に発生する *note SkipTest: fb1. (これはテストファ
イル内のモジュールレベルで起こせます) を、エラーとしてではなくスキップと
して報告するようになりました。 (Contributed by Zach Ware in
bpo-16935(3).)

*note discover(): fb2. が発見したファイルをソートするようになったので、
一貫したテスト順でテスト出来ます。 (Contributed by Martin Melin and Jeff
Ramnani in bpo-16709(4).)

*note TestSuite: dc1. がその実行完了次第すぐに、テスト成功していれば、テ
ストへの参照を取り除くようになりました。ガーベージコレクションを行う
Python インタプリタ上ではこの振る舞いによって、テストへの参照を保持して
いるものが他にない場合のテストのガーベージコレクトを可能にします。この振
る舞いは *note TestSuite: dc1. をサブクラス化して何もしない
‘_removeTestAtIndex’ を定義することで上書き出来ます。 (Contributed by
Tom Wardill, Matt McClure, and Andrew Svetlov in bpo-11798(5).)

テストアサーションの新規コンテキストマネージャ *note assertLogs(): 824.
が追加されました。これはコードブロックが *note logging: 7b. を使ってログ
メッセージを発行しているか確認します。デフォルトでは任意のロガーからの
‘INFO’ 以上のプライオリティを持つメッセージを取れますが、ロガー名と最小
プライオリティの両方とも指定可能です。コンテキストマネージャからの戻りオ
ブジェクトに対して、ログされた *note LogRecord: fb3. とフォーマットされ
たメッセージの両方あるいはどちらかを問い合わせることが出来ます。
(Contributed by Antoine Pitrou in bpo-18937(6).)

テストディスカバリが名前空間パッケージで動作するようになりました。
(Contributed by Claudiu Popa in bpo-17457(7).)

*note unittest.mock: f0. オブジェクトが、呼び出しが合致する際に仕様とし
てのシグニチャを検査するようになりました。これはつまり、以前は位置引数だ
けの合致だったものが、位置引数と名前の両方で合致できるようになったという
ことです。(Contributed by Antoine Pitrou in bpo-17015(8).)

‘mock_open()’ オブジェクトに ‘readline’ メソッドと ‘readlines’ メソッド
が追加されました。 (Contributed by Toshio Kuratomi in bpo-17467(9).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16997

   (2) https://bugs.python.org/issue?@action=redirect&bpo=15132

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16935

   (4) https://bugs.python.org/issue?@action=redirect&bpo=16709

   (5) https://bugs.python.org/issue?@action=redirect&bpo=11798

   (6) https://bugs.python.org/issue?@action=redirect&bpo=18937

   (7) https://bugs.python.org/issue?@action=redirect&bpo=17457

   (8) https://bugs.python.org/issue?@action=redirect&bpo=17015

   (9) https://bugs.python.org/issue?@action=redirect&bpo=17467


File: python.info,  Node: venv<7>,  Next: wave<2>,  Prev: unittest<9>,  Up: 改良されたモジュール<8>

1.10.4.60 venv
..............

*note venv: f9. に ‘csh’ と ‘fish’ シェルの有効化スクリプトが追加されま
した。 (Contributed by Andrew Svetlov in bpo-15417(1).)

*note EnvBuilder: 24b. クラスとコンビニエンス関数 *note create(): 24c. が
新規キーワード引数 'with_pip' を取るようになりました。デフォルトは
‘False’ です。これは *note EnvBuilder: 24b. が仮想環境に ‘pip’ がインス
トールされていることを保証するかどうかを制御します。(Contributed by Nick
Coghlan in bpo-19552(2) as part of the PEP 453(3) implementation.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15417

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19552

   (3) https://peps.python.org/pep-0453/


File: python.info,  Node: wave<2>,  Next: weakref<2>,  Prev: venv<7>,  Up: 改良されたモジュール<8>

1.10.4.61 wave
..............

‘getparams()’ メソッドがプレインなタプルではなく *note namedtuple: 1ac.
を返すようになりました。 (Contributed by Claudiu Popa in bpo-17487(1).)

*note wave.open(): 919. がコンテキスト管理プロトコルをサポートするように
なりました。 (Contributed by Claudiu Popa in bpo-17616(2).)

*note wave: fb. は *note シーク不能なファイルへの書き出しが出来るように:
fb6. なりました。 (Contributed by David Jones, Guilherme Polo, and
Serhiy Storchaka in bpo-5202(3).)

*note writeframesraw(): fb7. メソッドと *note writeframes(): fb8. メソッ
ドが *note bytes-like object: cfb. を受け付けるようになりました。
(Contributed by Serhiy Storchaka in bpo-8311(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17487

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17616

   (3) https://bugs.python.org/issue?@action=redirect&bpo=5202

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8311


File: python.info,  Node: weakref<2>,  Next: xml etree<2>,  Prev: wave<2>,  Up: 改良されたモジュール<8>

1.10.4.62 weakref
.................

新規 *note WeakMethod: fba. クラスは、インスタンスメソッドへの弱参照をシ
ミュレートします。 (Contributed by Antoine Pitrou in bpo-14631(1).)

新規クラス *note finalize: a4a. は、弱参照自身のライフサイクルを注意深く
管理する必要性なしに、オブジェクトがガーベージコレクトされる際に呼び出さ
れるコールバックを登録することを可能にします。 (Contributed by Richard
Oudkerk in bpo-15528(2).)

*note ref: fbb. に関連付いたコールバック (あれば) を、新規属性 *note
__callback__: fbc. で取得出来るようになりました。(Contributed by Mark
Dickinson in bpo-17643(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14631

   (2) https://bugs.python.org/issue?@action=redirect&bpo=15528

   (3) https://bugs.python.org/issue?@action=redirect&bpo=17643


File: python.info,  Node: xml etree<2>,  Next: zipfile<5>,  Prev: weakref<2>,  Up: 改良されたモジュール<8>

1.10.4.63 xml.etree
...................

ノンブロッキングなアプリケーションでの XML ドキュメントの解析に、新規パ
ーサ *note XMLPullParser: fbe. を利用出来ます。実例は *note
非ブロックパースのためのプル API: fbf. をみてください。 (Contributed by
Antoine Pitrou in bpo-17741(1).)

*note xml.etree.ElementTree: 10c. の関数 *note tostring(): fc0. 、*note
tostringlist(): fc1. と、 *note ElementTree: 91c. クラスの *note
write(): fc2. メソッドに、 *note キーワード専用引数: 285. の
'short_empty_elements' が追加されました。これはコンテンツを持たない要素
を省略形 (‘<tag />’) で書き出すか展開された形 (‘<tag></tag>’) で書き出す
かを制御します。(Contributed by Ariel Poliak and Serhiy Storchaka in
bpo-14377(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17741

   (2) https://bugs.python.org/issue?@action=redirect&bpo=14377


File: python.info,  Node: zipfile<5>,  Prev: xml etree<2>,  Up: 改良されたモジュール<8>

1.10.4.64 zipfile
.................

*note PyZipFile: fc4. クラスの *note writepy(): fc5. メソッドに
'filterfunc' オプションが追加されました。これはアーカイブにどのディレク
トリ・ファイルを加えるのかをコントロールするのに使うことが出来ます。例え
ばテスト用ファイルをアーカイブから除外する、などということが出来ます。
(Contributed by Christian Tismer in bpo-19274(1).)

*note ZipFile: 690. クラスと ‘PyZipfile’ クラスの 'allowZip64' パラメー
タのデフォルトが ‘True’ に変更されました。 (Contributed by William
Mallard in bpo-17201(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19274

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17201


File: python.info,  Node: CPython の実装の変更,  Next: 非推奨<9>,  Prev: 改良されたモジュール<8>,  Up: What's New In Python 3 4

1.10.5 CPython の実装の変更
---------------------------

* Menu:

* PEP 445; CPython のメモリアロケータのカスタマイズ: PEP 445 CPython のメモリアロケータのカスタマイズ.
* PEP 442; オブジェクトの安全なファイナライゼーション: PEP 442 オブジェクトの安全なファイナライゼーション.
* PEP 456; 安全で取り換え可能なハッシュアルゴリズム: PEP 456 安全で取り換え可能なハッシュアルゴリズム.
* PEP 436; Argument Clinic: PEP 436 Argument Clinic.
* その他のビルド並びに C API の変更::
* その他の改善: その他の改善<2>.
* 大幅な最適化::


File: python.info,  Node: PEP 445 CPython のメモリアロケータのカスタマイズ,  Next: PEP 442 オブジェクトの安全なファイナライゼーション,  Up: CPython の実装の変更

1.10.5.1 PEP 445: CPython のメモリアロケータのカスタマイズ
..........................................................

PEP 445(1) は、CPython インタープリタのメモリ割り当てをカスタマイズする
ために新たな C 水準のインターフェイスを追加しました。

参考
....

PEP 445(2) - Python メモリアロケータをカスタマイズするための新 API 追加

     PEP written and implemented by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0445/

   (2) https://peps.python.org/pep-0445/


File: python.info,  Node: PEP 442 オブジェクトの安全なファイナライゼーション,  Next: PEP 456 安全で取り換え可能なハッシュアルゴリズム,  Prev: PEP 445 CPython のメモリアロケータのカスタマイズ,  Up: CPython の実装の変更

1.10.5.2 PEP 442: オブジェクトの安全なファイナライゼーション
............................................................

PEP 442(1) は、 CPython でのオブジェクトのファイナライゼーションにまつわ
る現在の制限と奇癖を取り除きます。これによって、 ‘__del__()’ メソッドを
持つオブジェクトと *note finally: 997. 節を持つジェネレータが、それらが
循環参照に含まれる場合もファイナライズ出来ます。(--訳注: ジェネレータの
例については bpo-17468(2) から派生した bpo-17807(3) での修正 changeset
83688:c89febab4648(4) の ‘Lib/test/test_generators.py’ に追加されたテス
ト参照。--)

この変更の一環で、モジュールのグローバルは、ほとんどのケースではインタプ
リタのシャットダウン中に強制的に *note None: 641. がセットされることはな
くなり、代わりに循環ガーベージコレクタの通常のオペレーションに委ねます。
このことは、循環 GC が最初に導入されて以来悩みの種だった、普通 ‘__del__’
メソッドを巻き込んだ「インタプリタシャットダウン時エラーの類」全体を回避
します。(--訳注: bpo-18214(5) (superseder for bpo-812369(6)), changeset
84936:79e2f5bbc30c(7) --)

参考
....

PEP 442(8) - オブジェクトの安全なファイナライゼーション

     PEP written and implemented by Antoine Pitrou.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0442/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17468

   (3) https://bugs.python.org/issue?@action=redirect&bpo=17807

   (4) https://hg.python.org/cpython/rev/c89febab4648

   (5) https://bugs.python.org/issue?@action=redirect&bpo=18214

   (6) https://bugs.python.org/issue?@action=redirect&bpo=812369

   (7) https://hg.python.org/cpython/rev/79e2f5bbc30c/

   (8) https://peps.python.org/pep-0442/


File: python.info,  Node: PEP 456 安全で取り換え可能なハッシュアルゴリズム,  Next: PEP 436 Argument Clinic,  Prev: PEP 442 オブジェクトの安全なファイナライゼーション,  Up: CPython の実装の変更

1.10.5.3 PEP 456: 安全で取り換え可能なハッシュアルゴリズム
..........................................................

PEP 456(1) は、Python のハッシュアルゴリズムで行われた以前のセキュリティ
修正作業 -- これは公に曝されている辞書検索に裏打ちされた API が標的にな
るかもしれない、特定の DOS 攻撃に対処するものです -- に追従するものです
(この改善の現在ラウンドの事の起こりについては bpo-14621(2) を見てくださ
い)。この PEP では、 CPython のハッシュのコードをパッケージャが異なるハ
ッシュアルゴリズムへの差し替えを容易にするために一元化し、そして Python
のデフォルト実装としては 64 ビットデータ型を持つプラットフォームで
SipHash に乗り換えます。以前の FNV アルゴリズムと比較したどんなパフォー
マンスの差異も、些細なものです。

The PEP adds additional fields to the *note sys.hash_info: fca. named
tuple to describe the hash algorithm in use by the currently executing
binary.  Otherwise, the PEP does not alter any existing CPython APIs.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0456/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=14621


File: python.info,  Node: PEP 436 Argument Clinic,  Next: その他のビルド並びに C API の変更,  Prev: PEP 456 安全で取り換え可能なハッシュアルゴリズム,  Up: CPython の実装の変更

1.10.5.4 PEP 436: Argument Clinic
.................................

「Argument Clinic」( PEP 436(1)) は CPython ビルドプロセスの新たな鍋の具
です。ビルトインと標準ライブラリの拡張モジュールが C で実装されるにあた
って、正確なシグニチャを定義し保守管理するプロセスを単純化するのに使えま
す。

Python 3.4 では既にいくつかの標準ライブラリ拡張モジュールが Argument
Clinic を使うように変換されていて、またこれの結果として *note pydoc: a3.
と *note inspect: 72. が更新されました。

Python 3.4 メンテナンスリリースでの更新の一部として C で実装されている
callable に対して、プログラム的なイントロスペクションのためのシグニチャ
メタデータの追加が、さらに追加で行われることが期待されています。

     注釈: Argument Clinic の PEP は、実装されている状態に対して完全には
     最新のものとはなっていません。Argument Clinic は Python 3.4 ではサ
     ードパーティに向けた公開 API として利用可能とする予定ではないので、
     このケースではリリース管理者とコア開発チームによって許容出来るとみ
     なされました。

参考
....

PEP 436(2) - The Argument Clinic DSL (訳注: DSL=Domain-Specific Language)

     PEP written and implemented by Larry Hastings.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0436/

   (2) https://peps.python.org/pep-0436/


File: python.info,  Node: その他のビルド並びに C API の変更,  Next: その他の改善<2>,  Prev: PEP 436 Argument Clinic,  Up: CPython の実装の変更

1.10.5.5 その他のビルド並びに C API の変更
..........................................

   * *note PyType_GetSlot(): 869. 関数が、安定 ABI に追加されました。こ
     れにより、制限 API を使う際に名前の付いた型のスロットから関数ポイン
     タを取り出すことが出来ます。(Contributed by Martin von Löwis in
     bpo-17162(1).)  (--訳注: 安定 ABI, 制限 API については What's New
     In Python 3.2 ( PEP 384(2)) を参照。--)

   * The new ‘Py_SetStandardStreamEncoding()’ pre-initialization API
     allows applications embedding the CPython interpreter to reliably
     force a particular encoding and error handler for the standard
     streams.  (Contributed by Bastien Montagne and Nick Coghlan in
     bpo-16129(3).)

   * 文字列引数を変更することのない Python C API のほとんどが、 ‘char *’
     ではなく適切に ‘const char *’ として宣言されました。 (Contributed
     by Serhiy Storchaka in bpo-1772673(4).)

   * Python インタプリタが利用出来ない場合 (例えばクロスコンパイルのシナ
     リオ) であっても使える、シェルで書き直したバージョンの
     ‘python-config’ が追加されました。

   * *note PyUnicode_FromFormat(): 363. が ‘%s’, ‘%A’, ‘%U’, ‘%V’, ‘%S’,
     ‘%R’ についての幅と精度の指定をサポートするようになりました。
     (Contributed by Ysj Ray and Victor Stinner in bpo-7330(5).)

   * 既存の *note PyStructSequence_InitType(): fcd. 関数を補うものとして
     、 *note PyStructSequence_InitType2(): fce. が追加されました。違い
     は、これは成功時に ‘0’ 、失敗時に ‘-1’ を返すことです。

   * CPython のソースを、最近の GCC と clang のアドレスサニティチェック
     機能を使ってコンパイル出来るようにしました: 小さなオブジェクト用ア
     ロケータで起こっていた偽の警報を黙らせました。 (Contributed by
     Dhiru Kholia in bpo-18596(6).)

   * Windows ビルドに アドレス空間配置のランダム化(7) と データ実行防止
     (8) を使うようにしました。 (Contributed by Christian Heimes in
     bpo-16632(9).)

   * *note operator.length_hint(): f3a. と等価な C API 関数 *note
     PyObject_LengthHint(): fcf. が追加されました。 (Contributed by
     Armin Ronacher in bpo-16148(10).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17162

   (2) https://peps.python.org/pep-0384/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=16129

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1772673

   (5) https://bugs.python.org/issue?@action=redirect&bpo=7330

   (6) https://bugs.python.org/issue?@action=redirect&bpo=18596

   (7) https://en.wikipedia.org/wiki/Address_space_layout_randomization

   (8) https://en.wikipedia.org/wiki/Data_Execution_Prevention

   (9) https://bugs.python.org/issue?@action=redirect&bpo=16632

   (10) https://bugs.python.org/issue?@action=redirect&bpo=16148


File: python.info,  Node: その他の改善<2>,  Next: 大幅な最適化,  Prev: その他のビルド並びに C API の変更,  Up: CPython の実装の変更

1.10.5.6 その他の改善
.....................

   * The *note python: fd2. command has a new *note option: fd3, ‘-I’,
     which causes it to run in "isolated mode", which means that *note
     sys.path: 38e. contains neither the script's directory nor the
     user's ‘site-packages’ directory, and all ‘PYTHON*’ environment
     variables are ignored (it implies both ‘-s’ and ‘-E’).  Other
     restrictions may also be applied in the future, with the goal being
     to isolate the execution of a script from the user's environment.
     This is appropriate, for example, when Python is used to run a
     system script.  On most POSIX systems it can and should be used in
     the ‘#!’ line of system scripts.  (Contributed by Christian Heimes
     in bpo-16499(1).)

   * *note readline: a8. をサポートするプラットフォームで、対話インタプ
     リタでの ‘Tab’ キーでの補完がデフォルトで有効になりました。履歴もデ
     フォルトで有効となり、 ‘~/.python-history’ に書き込まれ (そしてそこ
     から読み込まれ) ます。 (Contributed by Antoine Pitrou and Éric
     Araujo in bpo-5845(2).)

   * Python インタプリタの ‘--version’ での起動時、標準エラーではなく標
     準出力にバージョン情報を出力するようになりました (bpo-18338(3))。同
     じ変更は *note argparse: 5. モジュールに対して (bpo-18920(4))、また
     、スクリプトとして呼び出せる機能を持つモジュールに対して
     (bpo-18922(5)) も行われました。

   * CPython の Windows インストーラが、拡張子を登録する際に ‘PATHEXT’ に
     ‘.py’ を追加するようになりました。これをするとユーザは、 Windows コ
     マンドプロンプトから Python スクリプトを、 ‘.py’ 拡張子なしでその名
     前だけタイプして実行出来ます。 (Contributed by Paul Moore in
     bpo-18569(6).)

   * A new ‘make’ target coverage-report(7) will build python, run the
     test suite, and generate an HTML coverage report for the C codebase
     using ‘gcov’ and lcov(8).

   * The ‘-R’ option to the *note python regression test suite: fd4. now
     also checks for memory allocation leaks, using *note
     sys.getallocatedblocks(): f92.  (Contributed by Antoine Pitrou in
     bpo-13390(9).)

   * ‘python -m’ が名前空間パッケージで動くようになりました。

   * *note stat: bc. モジュールが C で実装されました。これは以前問題であ
     った Python モジュール内で値をハードコードすることなく、定数を C ヘ
     ッダファイルから取りこめることを意味しています。(--訳注:
     bpo-11016(10) 、特に msg127114(11) 以降参照。--)

   * 単一の OS モジュール (POSIX の ‘.so’ と Windows の ‘.dll’) からの複
     数 Python モジュールのロードを正しく行えるようになりました (以前は
     黙ってファイル内の最初のモジュールだけが返されていました)。
     (Contributed by Václav Šmilauer in bpo-16421(12).)

   * 新しい命令コード ‘LOAD_CLASSDEREF’ が追加されました。これは *note
     __prepare__: c2c. のある種の使い方で起こりうる、クラス本体内の自由
     変数のロードでのバグを修正するために導入されました。(Contributed by
     Benjamin Peterson in bpo-17853(13).)

   * Victor Stinner が、彼の PEP 445(14) ベースの ‘pyfailmalloc’ ツール
     を用いて数多くのメモリエラー関連のクラッシュを特定し、そして修正し
     ました。 (bpo-18408(15), bpo-18520(16))

   * ‘pyvenv’ コマンドに、シンボリックリンクがデフォルトのシステムでもそ
     うせずにコピーを使うようにするための ‘--copies’ オプションが追加さ
     れました。 (Contributed by Vinay Sajip in bpo-18807(17).)

   * ‘pyvenv’ コマンドにはさらに、そうしなければ自動的に仮想環境に pip が
     ブートストラップされてしまうのを抑制するための、 ‘--without-pip’ オ
     プションが追加されました。(Contributed by Nick Coghlan in
     bpo-19552(18) as part of the PEP 453(19) implementation.)

   * 環境変数 *note PYTHONIOENCODING: fd5. の値内で、エンコーディング名
     を省略出来るようになりました。つまり、デフォルトエンコーディングを
     変更することなしにエラーハンドラだけをセット出来ます。 (Contributed
     by Serhiy Storchaka in bpo-18818(20).)

   * *note bz2: f.、*note lzma: 7e.、*note gzip: 5d. モジュールの ‘open’
     関数が ‘x’ (排他的作成) モードをサポートするようになりました。
     (Contributed by Tim Heaney and Vajrasky Kok in bpo-19201(21),
     bpo-19222(22), and bpo-19223(23).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16499

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5845

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18338

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18920

   (5) https://bugs.python.org/issue?@action=redirect&bpo=18922

   (6) https://bugs.python.org/issue?@action=redirect&bpo=18569

   (7) 
https://devguide.python.org/coverage/#measuring-coverage-of-c-code-with-gcov-and-lcov

   (8) https://github.com/linux-test-project/lcov

   (9) https://bugs.python.org/issue?@action=redirect&bpo=13390

   (10) https://bugs.python.org/issue?@action=redirect&bpo=11016

   (11) https://bugs.python.org/issue11016#msg127114

   (12) https://bugs.python.org/issue?@action=redirect&bpo=16421

   (13) https://bugs.python.org/issue?@action=redirect&bpo=17853

   (14) https://peps.python.org/pep-0445/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=18408

   (16) https://bugs.python.org/issue?@action=redirect&bpo=18520

   (17) https://bugs.python.org/issue?@action=redirect&bpo=18807

   (18) https://bugs.python.org/issue?@action=redirect&bpo=19552

   (19) https://peps.python.org/pep-0453/

   (20) https://bugs.python.org/issue?@action=redirect&bpo=18818

   (21) https://bugs.python.org/issue?@action=redirect&bpo=19201

   (22) https://bugs.python.org/issue?@action=redirect&bpo=19222

   (23) https://bugs.python.org/issue?@action=redirect&bpo=19223


File: python.info,  Node: 大幅な最適化,  Prev: その他の改善<2>,  Up: CPython の実装の変更

1.10.5.7 大幅な最適化
.....................

   * UTF-32 デコーダが3-4倍速くなりました。 (Contributed by Serhiy
     Storchaka in bpo-14625(1).)

   * 集合に対するハッシュ衝突のコストが削減されました。ハッシュテーブル
     の個々の検査 (probe) で、ハッシュテーブル全体を通したランダムな検査
     を行う前に、連続する隣接したキー/ハッシュペアをチェックするようにな
     りました。これは、キャッシュ局所性を利用して衝突解決のコストを減ら
     します。この衝突解決戦略は、リニア検査とオープンアドレッシング法の
     ハイブリッドとして説明できます。追加的なリニア検査の数はデフォルト
     では 9 です。この値は、コンパイル時に LINEAR_PROBES を定義すること
     で任意の値に変更できます。リニア検査を完全に無効にするには
     LINEAR_PROBES=0 を設定してください。 (Contributed by Raymond
     Hettinger in bpo-18771(2).)

   * インタプリタの起動が約 30% 高速化されました。この速度向上は、いくつ
     かの手段によってもたらされました。インタプリタは起動時により少数の
     モジュールをロードするようになりました。例えば *note re: a7, *note
     collections: 16, *note locale: 7a. モジュール、およびそれらの依存モ
     ジュールは、デフォルトではインポートされません。 marshal モジュール
     は、コンパイルされた Python コードをより高速にロードできるように改
     善されました。 (Contributed by Antoine Pitrou, Christian Heimes and
     Victor Stinner in bpo-19219(3), bpo-19218(4), bpo-19209(5),
     bpo-19205(6) and bpo-9548(7).)

   * *note bz2.BZ2File: 832. が大半の場合 Python2 のバージョン以上に速く
     なりました。*note lzma.LZMAFile: fd7. も最適化されました。
     (Contributed by Serhiy Storchaka and Nadeem Vawda in bpo-16034(8).)

   * *note random.getrandbits(): fd8. が (通常使用される) 小さな整数に対
     して20%-40% 早くなりました。 (Contributed by Serhiy Storchaka in
     bpo-16674(9).)

   * 文字列のストレージ形式を変更したことにより、文字列のピックル化は非
     常に速くなりました。(Contributed by Victor Stinner and Antoine
     Pitrou in bpo-15596(10).)

   * ‘io.FileIO.readall()’ の性能問題が解決されました。これは特に
     Windows に影響し、 *note subprocess: c1. を通して大量のデータをパイ
     プで渡しているケースでかなり速度向上します。 (Contributed by
     Richard Oudkerk in bpo-15758(11).)

   * *note html.escape(): fd9. が10倍速くなりました。(Contributed by
     Matt Bryant in bpo-18020(12).)

   * Windows において、 ‘obmalloc’ で CRT の ‘malloc’ の代わりにネイティ
     ブの ‘VirtualAlloc’ を使うようになりました。人工的なベンチマーク結
     果は、メモリー消費が 3% 減ったことを示しています。

   * *note os.urandom(): 4ec. now uses a lazily opened persistent file
     descriptor so as to avoid using many file descriptors when run in
     parallel from multiple threads.  (Contributed by Antoine Pitrou in
     bpo-18756(13).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14625

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18771

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19219

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19218

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19209

   (6) https://bugs.python.org/issue?@action=redirect&bpo=19205

   (7) https://bugs.python.org/issue?@action=redirect&bpo=9548

   (8) https://bugs.python.org/issue?@action=redirect&bpo=16034

   (9) https://bugs.python.org/issue?@action=redirect&bpo=16674

   (10) https://bugs.python.org/issue?@action=redirect&bpo=15596

   (11) https://bugs.python.org/issue?@action=redirect&bpo=15758

   (12) https://bugs.python.org/issue?@action=redirect&bpo=18020

   (13) https://bugs.python.org/issue?@action=redirect&bpo=18756


File: python.info,  Node: 非推奨<9>,  Next: 削除<9>,  Prev: CPython の実装の変更,  Up: What's New In Python 3 4

1.10.6 非推奨
-------------

このセクションでは、Python 3.4 で非推奨となり Python 3.5 以降で削除予定
となる、様々な API とその他機能性についてをカバーします。(全てではありま
せんが) ほとんどのケースで、非推奨に対する警告を (たとえば ‘-Wd’ を使っ
て) 有効にしたインタプリタ起動時、非推奨 API を使うと *note
DeprecationWarning: 18a. を励起します。

* Menu:

* Python API の非推奨項目::
* 非推奨の機能::


File: python.info,  Node: Python API の非推奨項目,  Next: 非推奨の機能,  Up: 非推奨<9>

1.10.6.1 Python API の非推奨項目
................................

   * As mentioned in *note PEP 451; インポートシステムのための
     ModuleSpec 型: ea4, a number of *note importlib: 6b. methods and
     functions are deprecated: ‘importlib.find_loader()’ is replaced by
     *note importlib.util.find_spec(): 2ae.;
     ‘importlib.machinery.PathFinder.find_module()’ is replaced by *note
     importlib.machinery.PathFinder.find_spec(): fdc.;
     ‘importlib.abc.MetaPathFinder.find_module()’ is replaced by *note
     importlib.abc.MetaPathFinder.find_spec(): 834.;
     ‘importlib.abc.PathEntryFinder.find_loader()’ and ‘find_module()’
     are replaced by *note importlib.abc.PathEntryFinder.find_spec():
     838.; all of the ‘XXXLoader’ ABC ‘load_module’ methods
     (‘importlib.abc.Loader.load_module()’,
     ‘importlib.abc.InspectLoader.load_module()’,
     ‘importlib.abc.FileLoader.load_module()’,
     ‘importlib.abc.SourceLoader.load_module()’) should no longer be
     implemented, instead loaders should implement an ‘exec_module’
     method (*note importlib.abc.Loader.exec_module(): 836, *note
     importlib.abc.InspectLoader.exec_module(): fdd. *note
     importlib.abc.SourceLoader.exec_module(): fde.) and let the import
     system take care of the rest; and
     ‘importlib.abc.Loader.module_repr()’,
     ‘importlib.util.module_for_loader()’,
     ‘importlib.util.set_loader()’, and ‘importlib.util.set_package()’
     are no longer needed because their functions are now handled
     automatically by the import system.

   * The ‘imp’ module is pending deprecation.  To keep compatibility
     with Python 2/3 code bases, the module's removal is currently not
     scheduled.

   * ‘formatter’ モジュールが撤廃保留中で、Python 3.6 での削除が計画され
     ています。

   * *note hmac.new(): a6d. 関数の 'digestmod' がデフォルトで暗黙に
     ‘MD5’ を使う仕様は撤廃されます。Python 3.6 では 'digestmod' 引数に
     は明示的にダイジェスト名かコンストラクタを渡すことが求められます。

   * *note ftplib: 54. モジュール内の内部クラス ‘Netrc’ はずっと長いこと
     そのドキュメンテーション文字列内で非推奨であることを謳ってきました
     。これは今や *note DeprecationWarning: 18a. を発行します。Python
     3.5 ではこのクラスは完全に削除されます。

   * *note subprocess.Popen.wait(): cb2. の文書化されていない引数
     'endtime' は本来曝してはいけないものでしたので、使用されていないこ
     とを願っています。これは非推奨ですし、確実に Python 3.5 では削除さ
     れるのではないでしょうか。(--訳注: 3.5 では削除はされませんでしたが
     、もちろん使用しないでください。これは内部用です。--)

   * *note HTMLParser: 843. の 'strict' 引数は非推奨です。

   * *note plistlib: 99. モジュールに追加された *note load(): 91d, *note
     dump(): 91f, *note loads(): 91e, *note dumps(): 920. により、対応す
     る ‘readPlist()’, ‘writePlist()’, ‘readPlistFromBytes()’,
     ‘writePlistToBytes()’ が非推奨となりました。同じく単に *note bytes:
     1a4. コンストラクタを使えば良いので ‘Data()’ が非推奨となりました。

   * *note sysconfig: c5. のキー ‘SO’ は非推奨です。これは ‘EXT_SUFFIX’
     に取って代わられました。

   * 種々の ‘open’ 関数で受け付けられていた ‘U’ モードは非推奨となりまし
     た。Python 3 ではこれは何も役に立つことはしません。 *note
     io.TextIOWrapper: 786. (必要ならば)、 'newline' 引数を適切に使うこ
     とによって置き換えられるはずです。

   * *note xml.etree.ElementTree.iterparse(): 254. の 'parser' 引数と
     *note XMLParser(): a22. の 'html' 引数が非推奨となりました。後者は
     (訳注: 第一引数のため) 削除に備えて ‘XMLParser’ への全ての引数はキ
     ーワード引数として渡すようにしてください。


File: python.info,  Node: 非推奨の機能,  Prev: Python API の非推奨項目,  Up: 非推奨<9>

1.10.6.2 非推奨の機能
.....................

   * *note IDLE: fe0. の ‘-n’ フラグでの実行 (サブプロセスを起こさない)
     は非推奨となりました。ただし、この機能は bpo-18823(1) が解決するま
     では削除はされません。

   * *note site: b5. モジュールは "site-python" ディレクトリが存在すれば
     これを sys.path に加えていましたが、これは非推奨となりました。
     (bpo-19375(2))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18823

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19375


File: python.info,  Node: 削除<9>,  Next: Python 3 4 への移植,  Prev: 非推奨<9>,  Up: What's New In Python 3 4

1.10.7 削除
-----------

* Menu:

* サポートされなくなったオペレーティングシステム::
* API と機能の削除: API と機能の削除<5>.
* コードの整理::


File: python.info,  Node: サポートされなくなったオペレーティングシステム,  Next: API と機能の削除<5>,  Up: 削除<9>

1.10.7.1 サポートされなくなったオペレーティングシステム
.......................................................

以下の OS 向けのソースとビルドツールは削除されました。

   * OS/2 (bpo-16135(1))。

   * Windows 2000 (changeset e52df05b496a(2))。

   * ‘COMSPEC’ が ‘command.com’ を指している Windows システム
     (bpo-14470(3)).

   * VMS (bpo-16136(4))。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16135

   (2) https://hg.python.org/cpython/rev/e52df05b496a

   (3) https://bugs.python.org/issue?@action=redirect&bpo=14470

   (4) https://bugs.python.org/issue?@action=redirect&bpo=16136


File: python.info,  Node: API と機能の削除<5>,  Next: コードの整理,  Prev: サポートされなくなったオペレーティングシステム,  Up: 削除<9>

1.10.7.2 API と機能の削除
.........................

時代遅れとなり、以前に既に非推奨となった以下の API と機能が削除されまし
た:

   * 保守されていなかった ‘Misc/TextMate’ と ‘Misc/vim’ ディレクトリは削
     除されました (代わりに何が使えるかの提案は devguide(1) をみてくださ
     い -- 訳注: おそらく Additional Resources(2) に挙げられている
     wiki(3) を指している --)。

   * makefile のマクロ ‘SO’ は削除されました (これは ‘SHLIB_SUFFIX’ マク
     ロと ‘EXT_SUFFIX’ マクロで置き換えられました) (bpo-16754(4))。

   * ‘PyThreadState.tick_counter’ フィールドは削除されました。これは
     Python 3.2 で「新しい GIL」が導入された際に意味をなくしていました。
     (bpo-19199(5)).

   * ‘PyLoader’ と ‘PyPycLoader’ が *note importlib: 6b. から削除されま
     した。 (Contributed by Taras Lyapun in bpo-15641(6).)

   * *note HTTPConnection: b0e. と *note HTTPSConnection: b0f. の
     'strict' 引数は削除されました。 HTTP 0.9 スタイルの 「Simple
     Responses」はもはやサポートされません。

   * *note urllib.request.Request: fa5. の非推奨となっていた
     getter/setter メソッドの ‘add_data’, ‘has_data’, ‘get_data’,
     ‘get_type’, ‘get_host’, ‘get_selector’, ‘set_proxy’,
     ‘get_origin_req_host’, ‘is_unverifiable’ は削除されました (代わりに
     属性アクセスを直接使ってください)。

   * 非推奨の ‘TYPE_INT64’ ロードのサポートが *note marshal: 80. から削
     除されました。 (Contributed by Dan Riti in bpo-15480(7).)

   * *note inspect.Signature: 1b1.: 位置専用パラメータを示すのに今では正
     当な名前が必要です。

   * object 自身の *note object.__format__(): 5ea. はもはや空でないフォ
     ーマット文字列を受け付けず、 *note TypeError: 502. を投げます。空で
     ない文字列を渡すことは既に Python 3.2 で非推奨となっていました。こ
     の変更は以前は動作した (そして正しくない) コードが、オブジェクトが
     __format__ メソッドを得ることで処理に失敗し始めていた状況を防ぐ目的
     でなされました。この変更が意味することはあなたのコードにとって、そ
     れを処理する __format__ メソッドを持たないオブジェクトに ‘s’ フォー
     マットコードを使うと *note TypeError: 502. を起こしうるようになった
     、ということです。背景については bpo-7994(8) を参照して下さい。
     (--訳注: このパラグラフの中盤が非常にわかりにくい表現で訳者も意味を
     取りきれていませんが、おそらく Python 2.6/3.0 で動作していた例えば
     ‘format(1+1j, '10s')’ が Python 2.7/3.1 で動作しなくなったことを指
     しているのだと思います。問題にされているのは動作しなくなったことで
     はなくてむしろ動作していたことで、そして object.__format__ が
     return str(self).__format__(fmt) で実現されていること。このコードで
     は fmt は何らの意味も持っていませんので、これは一貫性に欠ける要因で
     ある、とのことで、「わかりやすく拒絶する」ことが真意であるようです
     --)

   * Python 3.2 で非推奨となった ‘difflib.SequenceMatcher.isbjunk()’ お
     よび ‘difflib.SequenceMatcher.isbpopular()’ は削除されました: 'sm'
     が *note SequenceMatcher: fe4. であるとして、 ‘x in sm.bjunk’ と ‘x
     in sm.bpopular’ を使うようにしてください。 (bpo-13248(9))

   ---------- Footnotes ----------

   (1) https://devguide.python.org

   (2) https://devguide.python.org/#additional-resources

   (3) https://wiki.python.org/moin/PythonEditors

   (4) https://bugs.python.org/issue?@action=redirect&bpo=16754

   (5) https://bugs.python.org/issue?@action=redirect&bpo=19199

   (6) https://bugs.python.org/issue?@action=redirect&bpo=15641

   (7) https://bugs.python.org/issue?@action=redirect&bpo=15480

   (8) https://bugs.python.org/issue?@action=redirect&bpo=7994

   (9) https://bugs.python.org/issue?@action=redirect&bpo=13248


File: python.info,  Node: コードの整理,  Prev: API と機能の削除<5>,  Up: 削除<9>

1.10.7.3 コードの整理
.....................

   * *note pydoc: a3. モジュールで、使用されておらず文書化もされていなか
     った内部的な ‘Scanner’ クラスが削除されました。

   * ひどく壊れていた OSX システムで呼ばれる可能性があるのみだった *note
     platform: 98. モジュールの非公開関数 ‘_mac_ver_lookup’,
     ‘_mac_ver_gstalt’, ‘_bcd2str’ とあわせて、非公開かつ実質的に未使用
     だった ‘_gestalt’ モジュールが削除されました。 (see bpo-18393(1))

   * *note tarfile: c8. モジュールの名前空間内に *note stat: bc. 定数群
     がハードコードでコピーされていましたが、これは削除されました。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18393


File: python.info,  Node: Python 3 4 への移植,  Next: 3 4 3 の変更,  Prev: 削除<9>,  Up: What's New In Python 3 4

1.10.8 Python 3.4 への移植
--------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* 'python' コマンドの挙動の変更: 'python' コマンドの挙動の変更<2>.
* Python API の変更: Python API の変更<8>.
* C API の変更: C API の変更<11>.


File: python.info,  Node: 'python' コマンドの挙動の変更<2>,  Next: Python API の変更<8>,  Up: Python 3 4 への移植

1.10.8.1 'python' コマンドの挙動の変更
......................................

   * POSIX シェルでは、環境変数 ‘PATH’ に空の値をセットすることは、何も
     セットしないことと同じです。ところが *note PYTHONPATH: fe8. に空の
     値をセットすることは、何もセットしないことと 'まったく同じではあり
     ませんでした': *note PYTHONPATH: fe8. に空の値をセットすると、 ‘.’
     をセットしたのと同じ意味になっていて、これは ‘PATH’ での振舞いから
     類推しようとすると混乱を招くものでした。この振る舞いは ‘PATH’ での
     POSIX の慣習に従うように改められました。

   * CPython インタプリタのデバッグビルド (‘--with-pydebug’) での出力 [X
     refs, Y blocks] がデフォルトではオフになりました。 ‘-X
     showrefcount’ オプション起動で再度有効に出来ます。 (Contributed by
     Ezio Melotti in bpo-17323(1).)

   * ‘python’ コマンドとほとんどの標準ライブラリスクリプト (また *note
     argparse: 5. も) において、 ‘--version’ が情報出力を ‘stderr’ では
     なく ‘stdout’ に行うようになりました (issue へのリンクは *note
     その他の改善: fd1. セクション内参照)。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17323


File: python.info,  Node: Python API の変更<8>,  Next: C API の変更<11>,  Prev: 'python' コマンドの挙動の変更<2>,  Up: Python 3 4 への移植

1.10.8.2 Python API の変更
..........................

   * *note importlib.abc: 6c. 内に定義されている ABC は、無分別に *note
     NotImplementedError: 209. を投げるのではなく、相応しい例外を投げる
     かデフォルト値を返すかのどちらかになりました。このことは *note
     super(): 4a8. を呼び出して ABC がするがままに任せているコードにのみ
     影響します。互換性のために、必要であれば *note NotImplementedError:
     209. とその投げられる新たな例外の両方を捕捉してください。

   * The module type now initializes the *note __package__: 2b9. and
     *note __loader__: 2c3. attributes to ‘None’ by default.  To
     determine if these attributes were set in a backwards-compatible
     fashion, use e.g.  ‘getattr(module, '__loader__', None) is not
     None’.  (bpo-17115(1).)

   * ‘importlib.util.module_for_loader()’ now sets ‘__loader__’ and
     ‘__package__’ unconditionally to properly support reloading.  If
     this is not desired then you will need to set these attributes
     manually.  You can use ‘importlib.util.module_to_load()’ for module
     management.

   * インポートがリロードの際に無条件に関連属性 (例えば ‘__name__’,
     ‘__loader__’, ‘__package__’, ‘__file__’, ‘__cached__’) をリセットす
     るようになりました。これは、3.3 以前のリロードの際にモジュールを再
     発見する振る舞いと同じものを復元するものであるということを注記して
     おきます。 (bpo-19413(2))

   * 凍結パッケージ (frozen package) はもはや ‘__path__’ にパッケージ名
     を含むリストをセットせず、空リストをセットします。この以前の振る舞
     いは、凍結パッケージと同じ名前を持つディレクトリが存在する場合のサ
     ブモジュールのインポートで、インポートシステムが間違ったことを起こ
     しうるものでした。モジュールがパッケージなのかそうでないのかを決め
     る正しい方法は、 ‘hasattr(module, '__path__')’ を使うことです。
     (bpo-18065(3))

   * Frozen modules no longer define a ‘__file__’ attribute.  It's
     semantically incorrect for frozen modules to set the attribute as
     they are not loaded from any explicit location.  If you must know
     that a module comes from frozen code then you can see if the
     module's ‘__spec__.location’ is set to ‘'frozen'’, check if the
     loader is a subclass of *note importlib.machinery.FrozenImporter:
     fe9, or if Python 2 compatibility is necessary you can use
     ‘imp.is_frozen()’.

   * *note py_compile.compile(): 9f3. が書き込み先ファイルパスがシンボリ
     ックリンクか非レギュラーファイルの場合に *note FileExistsError:
     fea. を投げるようになりました。これは、警告の役割を果たすためです、
     インポートがファイルパスの元のファイルタイプが何かによらずに、それ
     らファイルをレギュラーファイルで上書きすることの。

   * ソースコードをロードしようとして *note SyntaxError: 172. かもしくは
     *note UnicodeDecodeError: 9e1. を引き起こした場合に、 *note
     importlib.abc.SourceLoader.get_source(): feb. はそれを *note
     ImportError: 3f2. に読み替えて投げることをしなくなりました。 *note
     ImportError: 3f2. はそうあるべきなのに見つからない場合にのみ投げら
     れるべきなので、ソースコードが見つかったけれども正しくない構造であ
     る場合の意味にまで及ぶのは、手を伸ばし過ぎで過負荷です。ImportError
     を捕捉していたコードで今後とも構文エラーとデコーディングの問題を無
     視したいと望むならば、これら 3 つ全ての例外を捕捉するようにしてくだ
     さい。 (訳注: changeset 84172:e353f64dfd95(4) )

   * *note functools.update_wrapper(): fec. と *note functools.wraps():
     f2a. が、たとえその関数も ‘__wrapped__’ を持っていたとしても正しく
     その関数が包まれるように ‘__wrapped__’ 属性値をセットするようになり
     ました。つまり ‘__wrapped__’ 属性は、以前のようにチェイン内の全ての
     ‘__wrapped__’ 属性が最も内側の関数を参照するのではなく、デコレート
     された関数の積み上げを正しくリンクするようになったということです。
     以前の振る舞いが意図されたものであると思い込んでいたイントロスペク
     ションライブラリの作者は、チェインの中の最初の関数 (‘__wrapped__’ 属
     性を持たない) にアクセスするのに *note inspect.unwrap(): f29. を使
     えます。(--訳注: bpo-17482(5).  わかりにくいので実例で。中で適切に
     @wrap を使うデコレータ @deco1、@deco2 があるとして、my_func をこの
     両方でデコレートするとします。この場合に、Python 3.3 までは
     ‘my_func.__wrapped__.__wrapped__’ が AttributeError になります。今
     回のこの修正で ‘my_func.__wrapped__.__wrapped__’ は期待通りに振舞い
     ます。 --)

   * *note inspect.getfullargspec(): 704. は、 *note
     inspect.signature(): 703. を前提とした再実装がなされました。これに
     より、かつて扱えていたよりも遥かに広い種類の呼び出し可能 (callable)
     を扱うようになりました (訳注: 例えば *note open(): 4e5. などは
     Python 3.3 までは扱えなかった)。Python 3.4 系列の経過のなかで、追加
     で組み込みや拡張モジュールの callable がシグニチャのメタデータを持
     つことが期待されています。 *note inspect.getfullargspec(): 704. が
     非 Python callable で失敗することを前提としたコードは、適宜調整の必
     要があるかもしれません。

   * *note importlib.machinery.PathFinder: fed. は *note sys.path_hooks:
     fee. 内のオブジェクトに、空文字列の場合は現在作業ディレクトリを渡す
     ようになりました。結果の *note sys.path_importer_cache: 5ae. が決し
     て ‘''’ を含まないことになるので、 *note sys.path: 38e. に基いて
     *note sys.path_importer_cache: 5ae. を巡回しても全てのキーを見つけ
     られません。インタプリタを ‘-m’ で起動した場合も含め、現在作業ディ
     レクトリ内でインポートされた際のモジュールの ‘__file__’ も絶対パス
     で持つようになりました (ただしスクリプトがコマンドラインから相対パ
     スを使って直接実行された際の ‘__main__.__file__’ を除きます
     (Contributed by Brett Cannon in bpo-18416(6)))。 (bpo-18416(7))

   * *note HTTPConnection: b0e. と *note HTTPSConnection: b0f. から
     'strict' 引数が削除されたことは、残りの引数をキーワード引数としてで
     はなく位置引数として使っていたなら意味が変わってしまいます。非推奨
     警告に注意を払ってきたのであれば、あなたのコードは既に全てのオプシ
     ョナル引数をキーワードで渡しているはずです。

   * ‘from __future__ import ...’ ステートメントの間に文字列が含まれる場
     合に '常に' *note SyntaxError: 172. となるようになりました。以前は
     モジュールの docstring が先頭にある場合とない場合で振る舞いが違って
     いて、ない場合にこのエラーが意図せず無視される場合がありました。こ
     の修正は CPython を言語仕様に準拠させるものです。Jython と PyPy で
     は既にこれが行われています。 (bpo-17434(8))

   * *note ssl.SSLSocket.getpeercert(): f84. と *note
     ssl.SSLSocket.do_handshake(): e36. は、 ‘SSLSocket’ が未接続時に以
     前は *note AttributeError: 326. を投げていましたが、 ‘ENOTCONN’ を
     持った *note OSError: 3f0. を投げるように改められました。加えて
     *note getpeercert(): f84. はハンドシェイクが未実施の場合に *note
     ValueError: 1e3. を投げるようになりました。

   * *note base64.b32decode(): fef. が入力文字列が非 b32 文字を含む場合
     に *note TypeError: 502. ではなく *note binascii.Error: ff0. を投げ
     るようになりました。今回のこの *note TypeError: 502. はほか (訳注:
     if the input is incorrectly padded のとき) の *note TypeError: 502.
     が置き換えられた際に置き換え忘れられたものでした。 (Contributed by
     Serhiy Storchaka in bpo-18011(9).)  注意: この修正は後方互換性を保
     てないので本来メンテナンスリリースの Python 3.3 には入るべきではな
     かったのですが、不注意で Python 3.3.3 にも行われてしまいました。

   * The ‘file’ attribute is now automatically closed when the creating
     ‘cgi.FieldStorage’ instance is garbage collected.  If you were
     pulling the file object out separately from the ‘cgi.FieldStorage’
     instance and not keeping the instance alive, then you should either
     store the entire ‘cgi.FieldStorage’ instance or read the contents
     of the file before the ‘cgi.FieldStorage’ instance is garbage
     collected.

   * クローズ済みの SSL ソケットに対する ‘read’ や ‘write’ 呼び出しで、
     以前のようなミステリアスな *note AttributeError: 326. ではなく、役
     に立つ *note ValueError: 1e3. を投げるようになりました。
     (bpo-9177(10))

   * *note slice.indices(): ff1. が巨大な値で *note OverflowError: 84e.
     を起こすことはなくなりました。この修正からの流れで *note
     slice.indices(): ff1. は負の値に対して *note ValueError: 1e3. を投
     げるようになっています。以前はこれは馬鹿げた値を返していました。
     (bpo-14794(11))

   * 特殊メソッド ‘__complex__’ が複素数ではなく *note float: 2ce. を返
     す実装をしているオブジェクトを渡すと *note cmath: 11. 関数ではエラ
     ーとなり、 *note complex: 2cf. コンストラクタでは受け容れられていま
     したが、これはいずれも *note TypeError: 502. となるように改められま
     した。(bpo-16290(12).)

   * 3.2 と 3.3 での *note int: 238. コンストラクタが 'base' パラメータ
     として誤って *note float: 2ce. を許容してしまっていました。それをわ
     ざわざやっているとも思えないですが、そうしていたなら今後は *note
     TypeError: 502. になります。 (bpo-16772(13))

   * キーワード専用引数へのデフォルト値が、通常のキーワード引数へのデフ
     ォルト値評価の 'あとで' 評価されるようになりました。前ではなく。望
     むらくは誰一人以前のバギーな振る舞いに頼っちゃうおバカなコードを書
     いていませんように。願います。 (bpo-16967(14))

   * 古いスレッド状態が *note fork(): 17c. 後にクリアされるようになりま
     した。これにより、以前は不適切に永遠に生き残ってしまっていたいくつ
     かのシステムリソース (たとえば、スレッドローカル記憶内に維持された
     データベース接続) が解放されるようになります。 (bpo-17094(15).)

   * Parameter names in ‘__annotations__’ dicts are now mangled
     properly, similarly to *note __kwdefaults__: ff2.  (Contributed by
     Yury Selivanov in bpo-20625(16).)

   * *note hashlib.hash.name: f15. が識別子を常に小文字で返すようになり
     ました。以前はいくつかの組み込みハッシュが大文字名を持っていました
     が、公式インターフェイスであることから、命名に一貫性を持たせるよう
     にしました。 (bpo-18532(17))

   * Because *note unittest.TestSuite: dc1. now drops references to
     tests after they are run, test harnesses that reuse a *note
     TestSuite: dc1. to re-run a set of tests may fail.  Test suites
     should not be re-used in this fashion since it means state is
     retained between test runs, breaking the test isolation that *note
     unittest: ef. is designed to provide.  However, if the lack of
     isolation is considered acceptable, the old behavior can be
     restored by creating a *note TestSuite: dc1. subclass that defines
     a ‘_removeTestAtIndex’ method that does nothing (see *note
     TestSuite.__iter__(): ff3.) (bpo-11798(18)).

   * *note unittest: ef. がコマンドライン解析に *note argparse: 5. を使
     うようになりました。このことで、以前は動作していた不当なコマンド形
     式で許されなくなったものがあります。理屈から言えばこれは後方互換性
     の問題ではないはずです。許されなくなったコマンド形式は意味をなして
     いなかったものですから、使われていたとは思えません。

   * 関数 *note re.split(): 282, *note re.findall(): ff4, *note
     re.sub(): 283. と、 ‘match’ オブジェクトのメソッド ‘group()’,
     ‘groups()’ は、操作対象が *note bytes-like object: cfb. である場合
     に常に 'bytes' オブジェクトを返すようになりました。以前は戻り値型は
     入力型に合わせられていました。戻り値の型がたとえば ‘bytearray’ にな
     ることに依存していたのであれば、コードを修正する必要があります。

   * ‘audioop’ functions now raise an error immediately if passed string
     input, instead of failing randomly later on (bpo-16685(19)).

   * *note HTMLParser: 843. の新規引数 'convert_charrefs' は現在は後方互
     換性維持のために ‘False’ をデフォルトとしていますが、最終的には
     ‘True’ がデフォルトになります。あなたのコードでは *note HTMLParser:
     843. の全ての呼び出しでこれをキーワード引数として明示することをお勧
     めします。 (bpo-13633(20))

   * *note hmac.new(): a6d. 関数の 'digestmod' 引数からデフォルト値が消
     える予定です。ので、 *note hmac.new(): a6d. 呼び出しは常に
     'digestmod' を明示するように修正すべきです。 (bpo-17276(21))

   * *note sysconfig.get_config_var(): ff5. にキー ‘SO’ を渡すことと
     *note sysconfig.get_config_vars(): ff6. の呼び出し結果から ‘SO’ キ
     ーを探すことは非推奨です。このキーは文脈依存の ‘EXT_SUFFIX’ または
     ‘SHLIB_SUFFIX’ で置き換えられるべきです。 (bpo-19555(22))

   * ‘open’ 系関数にモード ‘U’ を使っていたコードは修正すべきです。 ‘U’
     は Python 3 では無力であり、いずれはこれの使用は例外を投げるように
     なる予定です。使う関数に依存しますが、 'newline' 引数を使うか、ある
     いは必要であればストリームを *note TextIOWrapper: 786. でラップして
     その 'newline' 引数を使うことで、その古い Python 2 の振る舞いと同等
     なものを実現出来ます。 (bpo-15204(23))

   * スクリプト内から ‘pyvenv’ を使っていて、pip がインストール 'されな
     い' ことを望むならば、コマンド呼び出しに ‘--without-pip’ を追加しな
     ければなりません。

   * indent を明示した場合の *note json.dump(): d12. と *note
     json.dumps(): d13. のデフォルトの振る舞いが変更されました。要素を区
     切るカンマが行末に来る場合の後ろに、空白を追加しなくなりました。こ
     れはその出力のテストを空白に繊細な比較をすることで行っている場合に
     だけ問題になります。 (bpo-16333(24))

   * *note doctest: 31. が拡張モジュールの ‘__doc__’ 文字列から doctest
     を見つけるようになったので、doctest のテストディスカバリが拡張モジ
     ュールを含んでいてその中で doctest のようにみえるものが含まれている
     と、テスト実行時にこれまで見かけたことのないテスト失敗を目にするか
     もしれません。 (bpo-3158(25))

   * *note collections.abc: 17. モジュールが、Python スタートアップの改
     善の一環で少々リファクタリングが行われました。これの結果として
     *note collections: 16. は自動で *note collections.abc: 17. をインポ
     ートしなくなりました。もしもこの (文書化されていなかった) 暗黙での
     インポートに依存していたのであれば、 ‘import collections.abc’ とし
     て明示的にインポートを追加する必要があります。 (bpo-20784(26))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17115

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19413

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18065

   (4) https://hg.python.org/cpython/rev/e353f64dfd95

   (5) https://bugs.python.org/issue?@action=redirect&bpo=17482

   (6) https://bugs.python.org/issue?@action=redirect&bpo=18416

   (7) https://bugs.python.org/issue?@action=redirect&bpo=18416

   (8) https://bugs.python.org/issue?@action=redirect&bpo=17434

   (9) https://bugs.python.org/issue?@action=redirect&bpo=18011

   (10) https://bugs.python.org/issue?@action=redirect&bpo=9177

   (11) https://bugs.python.org/issue?@action=redirect&bpo=14794

   (12) https://bugs.python.org/issue?@action=redirect&bpo=16290

   (13) https://bugs.python.org/issue?@action=redirect&bpo=16772

   (14) https://bugs.python.org/issue?@action=redirect&bpo=16967

   (15) https://bugs.python.org/issue?@action=redirect&bpo=17094

   (16) https://bugs.python.org/issue?@action=redirect&bpo=20625

   (17) https://bugs.python.org/issue?@action=redirect&bpo=18532

   (18) https://bugs.python.org/issue?@action=redirect&bpo=11798

   (19) https://bugs.python.org/issue?@action=redirect&bpo=16685

   (20) https://bugs.python.org/issue?@action=redirect&bpo=13633

   (21) https://bugs.python.org/issue?@action=redirect&bpo=17276

   (22) https://bugs.python.org/issue?@action=redirect&bpo=19555

   (23) https://bugs.python.org/issue?@action=redirect&bpo=15204

   (24) https://bugs.python.org/issue?@action=redirect&bpo=16333

   (25) https://bugs.python.org/issue?@action=redirect&bpo=3158

   (26) https://bugs.python.org/issue?@action=redirect&bpo=20784


File: python.info,  Node: C API の変更<11>,  Prev: Python API の変更<8>,  Up: Python 3 4 への移植

1.10.8.3 C API の変更
.....................

   * いくつかの内部 C API とともに *note PyEval_EvalFrameEx(): ff8,
     *note PyObject_Repr(): ff9, *note PyObject_Str(): ffa. に、現在アク
     ティブな例外を黙殺する状況で使われていないことを確かにするためのデ
     バッグアサーションが仕込まれました。アクティブな例外を捨てることが
     期待されて望ましいケース (たとえば、既にローカルに *note
     PyErr_Fetch(): 3cc. で保存済みであるとか、異なる例外に置き換えるこ
     とが意図である場合) は、アサーション有効でコンパイルされている
     Python バージョンで実行して、(直接的・間接的によらず) それら操作呼
     び出しがそのアサーションを発行するのを、明示的に *note
     PyErr_Clear(): ffb. 呼び出しをすることで潰してください。

   * *note PyErr_SetImportError(): d0c. が 'msg' がセットされていない場
     合に *note TypeError: 502. をセットするようになりました。以前は例外
     をセットすることなく ‘NULL’ を返すだけでした。

   * *note PyOS_ReadlineFunctionPointer: 552. コールバックは、エラー時に
     ‘NULL’ を返すか *note PyMem_RawMalloc(): 369. または *note
     PyMem_RawRealloc(): 36b. でアロケートした文字列を返さなければなりま
     せん。 *note PyMem_Malloc(): c33. や *note PyMem_Realloc(): ffc. で
     アロケートした文字列はダメです。 (bpo-16742(1))

   * *note PyThread_set_key_value(): 3e1. が必ず値をセットするようになり
     ました。Python 3.3 ではこの関数はキーが既存 (で現在値が ‘NULL’ ポイ
     ンタでない) の場合には何もしませんでした。

   * *note PyFrameObject: 754. 構造体のフィールド ‘f_tstate’ (thread
     state) が、バグをフィックスするために削除されました: 論拠については
     bpo-14432(2) を参照してください。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16742

   (2) https://bugs.python.org/issue?@action=redirect&bpo=14432


File: python.info,  Node: 3 4 3 の変更,  Prev: Python 3 4 への移植,  Up: What's New In Python 3 4

1.10.9 3.4.3 の変更
-------------------

* Menu:

* PEP 476; stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化.


File: python.info,  Node: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化,  Up: 3 4 3 の変更

1.10.9.1 PEP 476: stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化
....................................................................................

*note http.client: 65. とこのモジュールを使っている例えば *note
urllib.request: f4. や *note xmlrpc.client: 114. が、サーバをプラットフ
ォームが持つ信頼ストアにある CA により署名された証明書で検証し、そのホス
ト名がリクエストされたホスト名かどうかのチェックをデフォルトで行うように
なりました。これは多くのアプリケーションにとって大幅なセキュリティ改善に
なります。

以前の古い振る舞いが必要なアプリケーションでは、代わりとなるコンテキスト
を渡せます:

     import urllib.request
     import ssl

     # This disables all verification
     context = ssl._create_unverified_context()

     # This allows using a specific certificate for the host, which doesn't need
     # to be in the trust store
     context = ssl.create_default_context(cafile="/path/to/file.crt")

     urllib.request.urlopen("https://invalid-cert", context=context)


File: python.info,  Node: What's New In Python 3 3,  Next: What's New In Python 3 2,  Prev: What's New In Python 3 4,  Up: What's New in Python

1.11 What's New In Python 3.3
=============================

この記事では 3.2 と比較した Python 3.3 の新機能を解説します。 Python 3.3
は2012年9月29日にリリースされました。全詳細については 変更履歴(1) をご覧
ください。

参考
....

PEP 398(2) - Python 3.3 リリーススケジュール

* Menu:

* 概要: 概要 -- リリースハイライト<9>. リリースハイライト
* PEP 405; 仮想環境: PEP 405 仮想環境.
* PEP 420; 暗黙的な名前空間パッケージ: PEP 420 暗黙的な名前空間パッケージ.
* PEP 3118; 新たなメモリビューの実装とバッファプロトコルのドキュメント: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント.
* PEP 393; 文字列の柔軟な表現: PEP 393 文字列の柔軟な表現.
* PEP 397; Windows の Python ランチャ: PEP 397 Windows の Python ランチャ.
* PEP 3151; OS および IO 例外階層の手直し: PEP 3151 OS および IO 例外階層の手直し.
* PEP 380; サブジェネレータへの委譲構文: PEP 380 サブジェネレータへの委譲構文.
* PEP 409; 例外コンテキストの抑制: PEP 409 例外コンテキストの抑制.
* PEP 414; 明示的なユニコードリテラル: PEP 414 明示的なユニコードリテラル.
* PEP 3155; クラスと関数の正規名: PEP 3155 クラスと関数の正規名.
* PEP 412; キー共有辞書: PEP 412 キー共有辞書.
* PEP 362; 関数シグニチャオブジェクト: PEP 362 関数シグニチャオブジェクト.
* PEP 421; sys.implementation の追加: PEP 421 sys implementation の追加.
* インポート実装としての importlib の使用::
* その他の言語変更: その他の言語変更<9>.
* 細粒度のインポートロック::
* 組み込みの関数と型::
* 新たなモジュール: 新たなモジュール<9>.
* 改良されたモジュール: 改良されたモジュール<9>.
* 最適化: 最適化<8>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<4>.
* 非推奨: 非推奨<10>.
* Python 3.3 への移植: Python 3 3 への移植.

   ---------- Footnotes ----------

   (1) https://docs.python.jp/3.3/whatsnew/changelog.html

   (2) https://peps.python.org/pep-0398/


File: python.info,  Node: 概要 -- リリースハイライト<9>,  Next: PEP 405 仮想環境,  Up: What's New In Python 3 3

1.11.1 概要 - リリースハイライト
--------------------------------

新たな文法機能:

   * *note ジェネレータの委譲: 1003.  のための新しい ‘yield from’ 式

   * *note str: 418. オブジェクト向けの ‘u'unicode'’ 文法の再適用

新たなライブラリモジュール:

   * *note faulthandler: 4e. (低水準のクラッシュのデバッグを補助する)

   * *note ipaddress: 74. (IPアドレスとマスクを表す高水準オブジェクト)

   * *note lzma: 7e. (XZ / LZMA アルゴリズムを使用したデータ圧縮)

   * *note unittest.mock: f0. (テスト向けにシステムの一部をモックオブジ
     ェクトで置き換える)

   * *note venv: f9. (人気の ‘virtualenv’ パッケージのような、Python
     *note virtual environments: 1004.)

新たな組み込み機能:

   * *note I/O 例外階層: 1005. の手直し

実装の改善:

   * *note インポート機構: 1006. を、 *note importlib: 6b. を元に書き換
     え

   * よりコンパクトな *note ユニコード文字列: 1007.

   * よりコンパクトな *note 属性辞書: 1008.

ライブラリモジュールの大幅な改善:

   * *note decimal: 1009. モジュールのCによる高速化

   * *note email: 100a. モジュールでのより良いユニコード処理 (*note
     暫定版: 100b.)

セキュリティの改善:

   * ハッシュのランダム化がデフォルトで有効になりました。

以降はユーザ向けの変更の包括的なリストになっています。


File: python.info,  Node: PEP 405 仮想環境,  Next: PEP 420 暗黙的な名前空間パッケージ,  Prev: 概要 -- リリースハイライト<9>,  Up: What's New In Python 3 3

1.11.2 PEP 405: 仮想環境
------------------------

仮想環境 (virtual environment) は隔離されたPython環境を作成する手助けを
します。 一方で保守を容易にするために、システム全体のインストールを共有
します。 仮想環境はそれ自身の site packages (つまりローカルにインストー
ルされたライブラリ) を持ちつつ、任意でシステム全体の site packages と分
離できます。 このコンセプトと実装は、人気のサードパーティパッケージであ
る ‘virtualenv’ を元にしていますが、インタプリタコアとの統合による恩恵を
受けています。

この PEP はプログラムからのアクセス用の *note venv: f9. モジュールと、コ
マンドラインからのアクセスと管理向けの ‘pyvenv’ スクリプトを追加します。
Pythonインタプリタは仮想環境のディレクトリツリーの存在を示す
‘pyvenv.cfg’ をチェックします。

参考
....

PEP 405(1) - Python Virtual Environments

     PEP written by Carl Meyer; implementation by Carl Meyer and Vinay
     Sajip

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0405/


File: python.info,  Node: PEP 420 暗黙的な名前空間パッケージ,  Next: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント,  Prev: PEP 405 仮想環境,  Up: What's New In Python 3 3

1.11.3 PEP 420: 暗黙的な名前空間パッケージ
------------------------------------------

‘__init__.py’ マーカーファイルを必要としないパッケージディレクトリと、複
数のモジュールパスをネイティブでサポートします( PEP 420(1) に記載された
様々なサードパーティでの名前空間のアプローチに影響されています)

参考
....

PEP 420(2) - Implicit Namespace Packages

     PEP written by Eric V. Smith; implementation by Eric V. Smith and
     Barry Warsaw

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0420/

   (2) https://peps.python.org/pep-0420/


File: python.info,  Node: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント,  Next: PEP 393 文字列の柔軟な表現,  Prev: PEP 420 暗黙的な名前空間パッケージ,  Up: What's New In Python 3 3

1.11.4 PEP 3118: 新たなメモリビューの実装とバッファプロトコルのドキュメント
---------------------------------------------------------------------------

PEP 3118(1) の実装が大幅に改善されました。

新しい memoryview 実装が、Py_buffer 構造体内にフィールドを動的にアロケー
トする際に多数のクラッシュの報告をもたらしていた全ての所有権問題、ライフ
タイム問題を包括的に解決しました。加えて、不連続もしくは多次元の入力に対
してクラッシュしたり誤った結果を返していた多数の関数が修正されました。

memoryview オブジェクトに、 PEP-3118 準拠の getbufferproc() が追加されて
います (訳注: *note バッファオブジェクト構造体 (buffer object
structure): 1010. 参照)。これはコンシューマの要求型をチェックします。多
くの新機能が追加されており、これらのほとんどが不連続配列とサブオフセット
を持つ配列に完全な一般化をもたらすものです。

*note ドキュメント: 371. が更新され、エキスポータ(提供側)とコンシューマ
(利用側)両方についての責務をより明確に詳細化しています。 *note
バッファ要求のフラグ: 1011. が、基本フラグと組合せフラグでグループ分けさ
れています。不連続配列と多次元の NumPy スタイル行列のメモリレイアウトに
ついて説明されています。

* Menu:

* フィーチャー::
* API の変更::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3118/


File: python.info,  Node: フィーチャー,  Next: API の変更,  Up: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント

1.11.4.1 フィーチャー
.....................

   * struct モジュールの構文の全ての native *note 書式指定文字: 1013. を
     サポートするようになりました ('@' プレフィクスが付いていても良いで
     す)。 (訳注: *note format: 1014. 参照。)

   * いくつかの制限はありますが、 *note cast(): 1015. メソッドでフォーマ
     ット変更と C-*note contiguous: 1016. 配列の形状 (shape) の変更を行
     うことが出来ます。

   * 任意の配列型で多次元のリスト表現がサポートされるようになっています
     。

   * 任意の配列型で多次元の比較がサポートされるようになっています。

   * 'B', 'b', 'c' いずれかのフォーマットの *note hashable: 5db. な (読
     み出し専用の) 型の1次元メモリビューもまた、 hashable です。
     (Contributed by Antoine Pitrou in bpo-13411(1).)

   * Arbitrary slicing of any 1-D arrays type is supported.  For
     example, it is now possible to reverse a memoryview in 'O'(1) by
     using a negative step.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13411


File: python.info,  Node: API の変更,  Prev: フィーチャー,  Up: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント

1.11.4.2 API の変更
...................

   * 最大 *note 次元: 1018. は公式に 64 に制限されています。

   * 空の *note shape: 1019, 空の *note strides: 101a, 空の *note
     suboffsets: 101b. を表現するのに以前は ‘None’ を用いていましたが今
     ではこれは空のタプルです。

   * フォーマット 'B' (unsigned bytes) での memoryview 要素へのアクセス
     は整数を返すようになりました (struct モジュールでの構文に従っていま
     す)。bytes オブジェクトが欲しければまずビューを 'c' で *note
     cast(): 1015. しなければなりません。

   * memoryview どうしの比較は被演算対象の論理構造を使って行うようになり
     、また、全ての配列要素は値で比較されます。struct モジュールの構文の
     全てのフォーマット文字でサポートされます。認識出来ないフォーマット
     文字でのビューは今でも許されていますが、ビューの指す中身によらずこ
     れは常に等しくないとされます。

   * ほかの変更については、 *note ビルドならびに C API の変更: 101c. と
     *note C コードの移植: 101d. を参照してください。

(Contributed by Stefan Krah in bpo-10181(1).)

参考
....

PEP 3118(2) - Revising the Buffer Protocol

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10181

   (2) https://peps.python.org/pep-3118/


File: python.info,  Node: PEP 393 文字列の柔軟な表現,  Next: PEP 397 Windows の Python ランチャ,  Prev: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント,  Up: What's New In Python 3 3

1.11.5 PEP 393: 文字列の柔軟な表現
----------------------------------

Unicode 文字列型が、複数の内部表現 (1、2 または 4 バイトで表現される
Unicode 序数(ordinal) の最大値依存) を、表現される文字列内でサポートする
ように変更されました (訳注: 以前までは Python のビルド時に固定で決めてい
ました)。このことは全てのシステムにおいて、一般のケースでは空間効率の良
い表現をしながらも UCS-4 へのフルアクセスを与えます。既存の API との互換
性のために複数の表現が並行で存在することになりますが、徐々にこの互換性は
なくされていくはずです。

Python 側にはこの変更による不都合は何もないはずです。

C API 側では PEP 393(1) は完全に後方互換です。レガシーな API は最低 5 年
は残されるはずです。レガシー API を使うアプリケーションはメモリ削減の効
能が完全には得られないか、あるいは最悪の場合には少し余計なメモリを使うか
もしれません。これは Python がそれぞれの文字列の二つのバージョン (レガシ
ーなフォーマットと新しい効率的な格納方法) を維持する必要があるかもしれな
いからです

* Menu:

* 機能性::
* 性能およびリソース使用量::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/


File: python.info,  Node: 機能性,  Next: 性能およびリソース使用量,  Up: PEP 393 文字列の柔軟な表現

1.11.5.1 機能性
...............

PEP 393(1) でなされた変更は以下の通りです:

   * Python は今や非 BMP 面の文字を含む Unicode コードポイントの完全な範
     囲 (つまり ‘U+0000’ から ‘U+10FFFF’ まで) を常にサポートします。
     narrow ビルド / wide ビルドという区別は今では存在していないため、
     Python は今ではいつでもかつての wide ビルドのように振る舞い、
     Windows でもこれは例外ではありません。

   * narrow ビルドとの決別は、それに付き物だった問題も解決しました。例え
     ば:

        * *note len(): 5fa. は今では非 BMP 面文字について必ず 1 を返しま
          す。つまり ‘len('\U0010FFFF') == 1’ です;

        * サロゲートペアが文字列リテラル内で再結合されることはありません
          。つまり ‘'\uDBFF\uDFFF' != '\U0010FFFF'’ です;

        * 非 BMP 面文字を指すインデクスやスライスは期待通りの値を返しま
          す。つまり ‘'\U0010FFFF'[0]’ は今では ‘'\uDBFF'’ ではなく
          ‘'\U0010FFFF'’ を返します;

        * ほかの全ての標準ライブラリ関数が今では正しく非 BMP コードポイ
          ントを処理します。

   * *note sys.maxunicode: 1020. の値は今やいつでも ‘1114111’ (十六進で
     ‘0x10FFFF’) です。後方互換性のために C API の ‘PyUnicode_GetMax()’
     関数は今でも ‘0xFFFF’ か ‘0x10FFFF’ のどちらかを返すようになっては
     いますが、新しい Unicode API とともには使ってはいけません (see
     bpo-13054(2))。

   * ‘./configure’ スクリプトのフラグ ‘--with-wide-unicode’ は削除されま
     した。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13054


File: python.info,  Node: 性能およびリソース使用量,  Prev: 機能性,  Up: PEP 393 文字列の柔軟な表現

1.11.5.2 性能およびリソース使用量
.................................

Unicode 文字列の記憶域サイズが文字列内のコードポイント最大値に依存するよ
うになったということです:

   * 純粋な ASCII と Latin1 文字列 (‘U+0000-U+00FF’) はコードポイントご
     とに 1 バイトを占めます;

   * BMP 文字列 (‘U+0000-U+FFFF’) はコードポイントごとに 2 バイトを占め
     ます;

   * 非 BMP 文字列 (‘U+10000-U+10FFFF’) はコードポイントごとに 4 バイト
     を占めます。

結局のところほとんどのアプリケーションにとってのこれの効能は、文字列記憶
のためのメモリ使用量が激減することで、これは以前の wide unicode ビルドと
比較して顕著です。これは多くの場合、インターナショナルな文脈であってもな
お純粋な ASCII が使われるであろうことに関係があります。(というのも多くの
文字列が人間向けでない言語として格納されるからです。例えば XML フラグメ
ンツや HTTP ヘッダ、JSON エンコードされたデータ、などなど。)同じ理由から
、大きなアプリケーションで CPU キャッシュ活用効率を高めるであろうことも
期待出来ます。Python 3.3 のメモリ使用は Python 3.2 の 2 倍から 3 倍小さ
く、また、Python 2.7 よりも少し良いことが Django ベンチマークでわかって
います (詳細は PEP をみてください)。

参考
....

PEP 393(1) - 文字列の柔軟な表現 (Flexible String Representation)

     PEP written by Martin von Löwis; implementation by Torsten Becker
     and Martin von Löwis.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/


File: python.info,  Node: PEP 397 Windows の Python ランチャ,  Next: PEP 3151 OS および IO 例外階層の手直し,  Prev: PEP 393 文字列の柔軟な表現,  Up: What's New In Python 3 3

1.11.6 PEP 397: Windows の Python ランチャ
------------------------------------------

Python 3.3 の Windows インストーラが、ランチャアプリケーションの ‘py’ を
インストールするようになりました。これは Python をバージョンに依存しない
方法で起動するのに使われます。

ランチャは ‘*.py’ ファイルをダブルクリックすると暗黙のうちに呼び出されま
す。システムにインストールされているのが単一の Python バージョンであれば
、そのバージョンがファイルの実行に使われます。複数バージョンがインストー
ルされていればデフォルトでは最新バージョンが使われますが、Python スクリ
プト内で Unix スタイルの「shebang 行 ( ‘#!’ )」を含めることでオーバライ
ド出来ます。

ランチャは明示的にコマンドラインから ‘py’ アプリケーションとして使うこと
も出来ます。 ‘py’ の実行は暗黙にスクリプトを起動するバージョン選択のルー
ルに従いますが、与えるコマンドライン引数により狙ったバージョンを選択出来
ます (たとえば ‘-3’ は Python 2 もインストールされている際に Python 3 を
要求し、 ‘-2.6’ はもっと新しいバージョンがインストールされている場合に特
定の古いバージョンを要求します)。

ランチャに加え、Windows インストーラには新しくインストールする Python を
システムの PATH に追加するオプションが含まれるようになりました。
(Contributed by Brian Curtin in bpo-3561(1).)

参考
....

PEP 397(2) - Python Launcher for Windows

     PEP written by Mark Hammond and Martin v.  Löwis; implementation by
     Vinay Sajip.

ランチャのドキュメント: *note Windows の Python ランチャ: 588.

インストーラ PATH の調整: *note Python 実行ファイルを見つける: 1024.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3561

   (2) https://peps.python.org/pep-0397/


File: python.info,  Node: PEP 3151 OS および IO 例外階層の手直し,  Next: PEP 380 サブジェネレータへの委譲構文,  Prev: PEP 397 Windows の Python ランチャ,  Up: What's New In Python 3 3

1.11.7 PEP 3151: OS および IO 例外階層の手直し
----------------------------------------------

OS エラーが送出する例外の階層が単純化され、粒度が下げられました。

*note OSError: 3f0.、*note IOError: 1026.、*note EnvironmentError:
1027.、*note WindowsError: 1028.、‘mmap.error’、*note socket.error:
1029.、そして *note select.error: 102a. の中から適切な例外の型を選ぶのに
心配する必要はもうありません。 上記の例外の型は全てたった1つ *note
OSError: 3f0. になりました。 *note OSError: 3f0. 以外の名前は互換性のた
めにエイリアスとして残されています。

また、特定のエラー条件を捕捉するのが容易になりました。 ‘errno’ 属性 (ま
たは ‘args[0]’) の特定の定数を *note errno: 4d. モジュールから調べる代わ
りに、適切な *note OSError: 3f0. 派生クラスを捕捉することが出来ます。 利
用可能な派生クラスは以下の通りです:

   * *note BlockingIOError: 102b.

   * *note ChildProcessError: 102c.

   * *note ConnectionError: dd7.

   * *note FileExistsError: fea.

   * *note FileNotFoundError: e8f.

   * *note InterruptedError: d55.

   * *note IsADirectoryError: 102d.

   * *note NotADirectoryError: 102e.

   * *note PermissionError: d10.

   * *note ProcessLookupError: 102f.

   * *note TimeoutError: 800.

*note ConnectionError: dd7. 自身には細かな派生クラスがあります:

   * *note BrokenPipeError: 1030.

   * *note ConnectionAbortedError: 1031.

   * *note ConnectionRefusedError: 1032.

   * *note ConnectionResetError: 1033.

新たな例外のおかげで *note errno: 4d. の一般的な使い方を避けることが出来
ます。 例えば、Python 3.2 向けに書かれた以下のコード:

     from errno import ENOENT, EACCES, EPERM

     try:
         with open("document.txt") as f:
             content = f.read()
     except IOError as err:
         if err.errno == ENOENT:
             print("document.txt file is missing")
         elif err.errno in (EACCES, EPERM):
             print("You are not allowed to read document.txt")
         else:
             raise

は *note errno: 4d. をインポートしたり手動で例外属性を調べたりせずに書く
ことが出来ます:

     try:
         with open("document.txt") as f:
             content = f.read()
     except FileNotFoundError:
         print("document.txt file is missing")
     except PermissionError:
         print("You are not allowed to read document.txt")

参考
....

PEP 3151(1) - Reworking the OS and IO Exception Hierarchy

     PEP written and implemented by Antoine Pitrou

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3151/


File: python.info,  Node: PEP 380 サブジェネレータへの委譲構文,  Next: PEP 409 例外コンテキストの抑制,  Prev: PEP 3151 OS および IO 例外階層の手直し,  Up: What's New In Python 3 3

1.11.8 PEP 380: サブジェネレータへの委譲構文
--------------------------------------------

PEP 380 は ‘yield from’ 式を追加します。これは *note ジェネレータ: 1035.
に、その操作の一部をほかのジェネレータに委譲するための式です。これによっ
て *note yield: 99b. を含んでいるコードのセクションをほかのジェネレータ
に移動出来るでしょう。加えてサブジェネレータは値を伴って戻ることが出来、
その戻り値は委譲した側のジェネレータで使えます。

‘yield from’ 式がデザインされた主たる動機はサブジェネレータへの委譲とし
て使うことではありますが、実際には任意のサブイテレータに委譲することも出
来ます。

単純なイテレータに対して、 ‘yield from iterable’ は本質的には ‘for item
in iterable: yield item’ への単なる速記法です:

     >>> def g(x):
     ...     yield from range(x, 0, -1)
     ...     yield from range(x)
     ...
     >>> list(g(5))
     [5, 4, 3, 2, 1, 0, 1, 2, 3, 4]

ですが普通のループとは違って ‘yield from’ ではサブジェネレータは、呼び出
し側スコープから *note send(): 1036. されたり *note throw(): 4c5. された
値を直接受け取ることができ、また、外側のジェネレータに最終的な値を返せま
す:

     >>> def accumulate():
     ...     tally = 0
     ...     while 1:
     ...         next = yield
     ...         if next is None:
     ...             return tally
     ...         tally += next
     ...
     >>> def gather_tallies(tallies):
     ...     while 1:
     ...         tally = yield from accumulate()
     ...         tallies.append(tally)
     ...
     >>> tallies = []
     >>> acc = gather_tallies(tallies)
     >>> next(acc)  # Ensure the accumulator is ready to accept values
     >>> for i in range(4):
     ...     acc.send(i)
     ...
     >>> acc.send(None)  # Finish the first tally
     >>> for i in range(5):
     ...     acc.send(i)
     ...
     >>> acc.send(None)  # Finish the second tally
     >>> tallies
     [6, 10]

この変更を推し進める一番本質にあったものは、たとえ ‘send’ メソッドや
‘throw’ メソッドとともに使われることを前提に設計されたジェネレータであっ
ても、大きな関数を複数のサブ関数に分割するのと同じくらいに、ジェネレータ
を簡単に複数のサブジェネレータに分割出来るようにすることでした。

参考
....

PEP 380(1) - サブジェネレータへの委譲構文

     PEP written by Greg Ewing; implementation by Greg Ewing, integrated
     into 3.3 by Renaud Blanch, Ryan Kelly and Nick Coghlan;
     documentation by Zbigniew Jędrzejewski-Szmek and Nick Coghlan

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0380/


File: python.info,  Node: PEP 409 例外コンテキストの抑制,  Next: PEP 414 明示的なユニコードリテラル,  Prev: PEP 380 サブジェネレータへの委譲構文,  Up: What's New In Python 3 3

1.11.9 PEP 409: 例外コンテキストの抑制
--------------------------------------

PEP 409 は、チェインされた例外コンテキストの表示を無効にするための新構文
を導入します。これを使えば例外翻訳して投げ直すようなアプリケーションで、
エラーメッセージをわかりやすくすることが出来ます:

     >>> class D:
     ...     def __init__(self, extra):
     ...         self._extra_attributes = extra
     ...     def __getattr__(self, attr):
     ...         try:
     ...             return self._extra_attributes[attr]
     ...         except KeyError:
     ...             raise AttributeError(attr) from None
     ...
     >>> D({}).x
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 8, in __getattr__
     AttributeError: x

元となる要因例外を抑制する ‘from None’ を後置しなければ、もとの例外はデ
フォルトで表示されます:

     >>> class C:
     ...     def __init__(self, extra):
     ...         self._extra_attributes = extra
     ...     def __getattr__(self, attr):
     ...         try:
     ...             return self._extra_attributes[attr]
     ...         except KeyError:
     ...             raise AttributeError(attr)
     ...
     >>> C({}).x
     Traceback (most recent call last):
       File "<stdin>", line 6, in __getattr__
     KeyError: 'x'

     During handling of the above exception, another exception occurred:

     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 8, in __getattr__
     AttributeError: x

抑制することでデバッグ能力が失われるというわけではなくて、元々の例外コン
テキストは利用可能なままです。(例えば介在するライブラリが有益な背後の詳
細を不適切に隠してしまっているなど、必要な場合はあるでしょう。)

     >>> try:
     ...     D({}).x
     ... except AttributeError as exc:
     ...     print(repr(exc.__context__))
     ...
     KeyError('x',)

参考
....

PEP 409(1) - 例外コンテキストの抑制

     PEP written by Ethan Furman; implemented by Ethan Furman and Nick
     Coghlan.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0409/


File: python.info,  Node: PEP 414 明示的なユニコードリテラル,  Next: PEP 3155 クラスと関数の正規名,  Prev: PEP 409 例外コンテキストの抑制,  Up: What's New In Python 3 3

1.11.10 PEP 414: 明示的なユニコードリテラル
-------------------------------------------

Unicode を意識する Python アプリケーションが Python 2 で Unicode リテラ
ルを多用しているとしても Python 3 への移行を容易にするために、Python 3.3
では文字列リテラルへの "‘u’" 前置を再びサポートすることにしました。この
前置は Python 3 自身では何らの意味も持ちはせず、Python 3 への移行におい
て純粋な機械的変更を要する事項を単に減らすためだけのために提供されます。
開発者はもっと重要な意味的変更 (たとえばバイナリとテキストの厳密な区別)
に集中すべきなのです。

参考
....

PEP 414(1) - 明示的なユニコードリテラル

     PEP written by Armin Ronacher.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0414/


File: python.info,  Node: PEP 3155 クラスと関数の正規名,  Next: PEP 412 キー共有辞書,  Prev: PEP 414 明示的なユニコードリテラル,  Up: What's New In Python 3 3

1.11.11 PEP 3155: クラスと関数の正規名
--------------------------------------

Functions and class objects have a new *note __qualname__: 103a.
attribute representing the "path" from the module top-level to their
definition.  For global functions and classes, this is the same as *note
__name__: 103b.  For other functions and classes, it provides better
information about where they were actually defined, and how they might
be accessible from the global scope.

(束縛されていない) メソッドでの例:

     >>> class C:
     ...     def meth(self):
     ...         pass
     ...
     >>> C.meth.__name__
     'meth'
     >>> C.meth.__qualname__
     'C.meth'

入れ子のクラスでの例:

     >>> class C:
     ...     class D:
     ...         def meth(self):
     ...             pass
     ...
     >>> C.D.__name__
     'D'
     >>> C.D.__qualname__
     'C.D'
     >>> C.D.meth.__name__
     'meth'
     >>> C.D.meth.__qualname__
     'C.D.meth'

入れ子の関数の例:

     >>> def outer():
     ...     def inner():
     ...         pass
     ...     return inner
     ...
     >>> outer().__name__
     'inner'
     >>> outer().__qualname__
     'outer.<locals>.inner'

それらオブジェクトの文字列表現も、この新しくてより正確な情報を含むように
変更されています:

     >>> str(C.D)
     "<class '__main__.C.D'>"
     >>> str(C.D.meth)
     '<function C.D.meth at 0x7f46b9fe31e0>'

参考
....

PEP 3155(1) - クラスと関数の正規名 (qualified name)

     PEP written and implemented by Antoine Pitrou.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3155/


File: python.info,  Node: PEP 412 キー共有辞書,  Next: PEP 362 関数シグニチャオブジェクト,  Prev: PEP 3155 クラスと関数の正規名,  Up: What's New In Python 3 3

1.11.12 PEP 412: キー共有辞書
-----------------------------

オブジェクト属性を記憶するのに使われる辞書が、内部記憶域の一部 (キーとそ
れに対応するハッシュ値) を互いに共有出来るようになりました。これにより、
組み込みでない型のインスタンスをたくさん作るプログラムのメモリ消費が少な
くなります。

参考
....

PEP 412(1) - キー共有辞書

     PEP written and implemented by Mark Shannon.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0412/


File: python.info,  Node: PEP 362 関数シグニチャオブジェクト,  Next: PEP 421 sys implementation の追加,  Prev: PEP 412 キー共有辞書,  Up: What's New In Python 3 3

1.11.13 PEP 362: 関数シグニチャオブジェクト
-------------------------------------------

新たに追加された関数 *note inspect.signature(): 703. は、Python 呼び出し
可能オブジェクト (callable) を調べることを簡単で直接的なものにしてくれま
す。幅広い callable をサポートしています:デコレートされているかどうかに
よらず関数、クラス、 *note functools.partial(): 3ed. オブジェクト。新た
に追加されたクラス群 *note inspect.Signature: 1b1, *note
inspect.Parameter: 1b2, *note inspect.BoundArguments: 103e. は、アノテー
ション、デフォルト値、パラメータの種類、束縛されている引数などのような呼
び出しシグニチャについての情報を保持し、これによって、デコレータを書いた
りあるいは呼び出しシグニチャや引数を検証したり改訂したりするコードを書く
ことが、非常に単純になります。

参考
....

PEP 362(1): - 関数シグニチャオブジェクト

     PEP written by Brett Cannon, Yury Selivanov, Larry Hastings, Jiwon
     Seo; implemented by Yury Selivanov.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0362/


File: python.info,  Node: PEP 421 sys implementation の追加,  Next: インポート実装としての importlib の使用,  Prev: PEP 362 関数シグニチャオブジェクト,  Up: What's New In Python 3 3

1.11.14 PEP 421: sys.implementation の追加
------------------------------------------

*note sys: c3. モジュールに新規属性が追加され、これは現在動作中のインタ
ープリタ実装に固有の詳細を公開します。その *note sys.implementation:
4e0. 属性の手始めの集合として、 ‘name’, ‘version’, ‘hexversion’,
‘cache_tag’ が定義されています。

‘sys.implementation’ の真意は、標準ライブラリによって利用される実装固有
の情報を一つの名前空間で一元管理することにあります。このことにより異なる
Python 実装が単一の標準ライブラリのコードベースを共有することが、もっと
ずっと簡単になります。今時点での初期状態では ‘sys.implementation’ は実装
固有データのごく一部を保持しているだけです。標準ライブラリの移植性がもっ
と高くなるように、徐々にこの比率が変わっていくでしょう。

標準ライブラリの移植性を改善した一例が ‘cache_tag’ です。Python 3.3 以降
は ‘sys.implementation.cache_tag’ が PEP 3147(1) をサポートするために
*note importlib: 6b. により使われます。組み込みのインポートシステムのた
めに ‘importlib’ を使う全ての Python 実装が、モジュールのキャッシュの振
る舞いを制御するのに ‘cache_tag’ を利用できます。

* Menu:

* SimpleNamespace::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3147/


File: python.info,  Node: SimpleNamespace,  Up: PEP 421 sys implementation の追加

1.11.14.1 SimpleNamespace
.........................

‘sys.implementation’ の実現に伴って Python に新たな型 *note
types.SimpleNamespace: 1b3. が導入されることとなりました。 *note dict:
237. のようなマッピングベースの名前空間とは対照的に、 ‘SimpleNamespace’
は *note object: a5a. のような属性ベースです。ですが ‘object’ とは違って
‘SimpleNamespace’ インスタンスは書き込み可能です。つまり普通の属性アクセ
スを通じて名前空間に追加したり削除したり修正したりできます。

参考
....

PEP 421(1) - sys.implementation の追加

     PEP written and implemented by Eric Snow.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0421/


File: python.info,  Node: インポート実装としての importlib の使用,  Next: その他の言語変更<9>,  Prev: PEP 421 sys implementation の追加,  Up: What's New In Python 3 3

1.11.15 インポート実装としての importlib の使用
-----------------------------------------------

bpo-2377(1) - Replace __import__ w/ importlib.__import__ bpo-13959(2) -
Re-implement parts of ‘imp’ in pure Python bpo-14605(3) - Make import
machinery explicit bpo-14646(4) - Require loaders set __loader__ and
__package__

*note __import__(): 8a2. 関数を *note importlib.__import__(): 1042. によ
って実現するようにしました。これは PEP 302(5) の「第二段階」を完了させる
ものです。この変更には複数の恩恵があります。まず最初にこれはインポートの
機構を、C コードの奥深くで暗黙に秘密裏に行うのではなく、より透明化します
。このことで、Python 3.3 をサポートする全ての Python VM で単一の実装を用
いることが出来るようになり、インポートのセマンティクスにおける VM 固有の
逸脱と決別する助けともなります。そしてこれはインポート機構の保守をより容
易とし、将来起こりうる進化を促します。

一般のユーザにとっては、セマンティクスにおいて目に見える変化はないはずで
す。今時点でインポートを操作したりインポート呼び出しをプログラム的に行っ
ている場合は、このドキュメントの *note Python コードの移植: 1043. でカバ
ーしているコードの修正が必要になるかもしれません。

* Menu:

* 新たな API::
* 目に見える変化::

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2377

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13959

   (3) https://bugs.python.org/issue?@action=redirect&bpo=14605

   (4) https://bugs.python.org/issue?@action=redirect&bpo=14646

   (5) https://peps.python.org/pep-0302/


File: python.info,  Node: 新たな API,  Next: 目に見える変化,  Up: インポート実装としての importlib の使用

1.11.15.1 新たな API
....................

この変更による一番大きな恩恵の一つは、インポート文の動作に何が介在するの
かについて露になったことです。つまりかつては様々なインポータが暗黙で行っ
ていたことが、今では完全に *note importlib: 6b. パッケージの一部として公
開されています。

The abstract base classes defined in *note importlib.abc: 6c. have been
expanded to properly delineate between *note meta path finders: 1045.
and *note path entry finders: 1046. by introducing *note
importlib.abc.MetaPathFinder: 83a. and *note
importlib.abc.PathEntryFinder: 83b, respectively.  The old ABC of
‘importlib.abc.Finder’ is now only provided for backwards-compatibility
and does not enforce any method requirements.

In terms of finders, *note importlib.machinery.FileFinder: 1047. exposes
the mechanism used to search for source and bytecode files of a module.
Previously this class was an implicit member of *note sys.path_hooks:
fee.

ローダ (loader) については、新規の抽象基底クラス *note
importlib.abc.FileLoader: 1048. が、モジュールのコードを格納する機構とし
てのファイルシステムを使うローダを書く助けとなります。ソースファイルのロ
ーダ (*note importlib.machinery.SourceFileLoader: 1049.)、ソースを持たな
いバイトコードのためのローダ (*note
importlib.machinery.SourcelessFileLoader: 104a.)、そして拡張モジュールの
ためのローダ (*note importlib.machinery.ExtensionFileLoader: c7e.) が今
では直接的に利用出来ます。

*note ImportError: 3f2. には属性 ‘name’ と ‘path’ が追加されて、これには
提供すべき関連データがある場合にセットされます。インポート失敗時のメッセ
ージも、これまでのようにモジュール名の末尾だけを与えるのではなく、モジュ
ールの完全名を提供するようになりました。

The *note importlib.invalidate_caches(): bde. function will now call the
method with the same name on all finders cached in *note
sys.path_importer_cache: 5ae. to help clean up any stored state as
necessary.


File: python.info,  Node: 目に見える変化,  Prev: 新たな API,  Up: インポート実装としての importlib の使用

1.11.15.2 目に見える変化
........................

潜在的に必要となるかもしれないコード修正については、 *note Python
コードの移植: 1043. セクションを参照してください。

*note importlib: 6b. によって公開されるものが拡がったことによる、インポ
ートについてのほかの目に見える変化があります。最大の変化は *note
sys.meta_path: cf9. と *note sys.path_hooks: fee. が、インポートで使われ
る meta path finder と path entry hook の全てを格納するようになったこと
です。以前はファインダは直接的に公開されるのではなく、インポートの C コ
ード内に暗黙のものとして隠されていました。このことによって、今では望めば
要件に合うようファインダを取り除いたり順序を変えたりといったことが簡単に
行えるようになっています。

もう一つの変化は、モジュール生成時に使われたローダを格納する
‘__loader__’ 属性を、全てのモジュールが持つようになったことです。 PEP
302(1) はローダの実装においてこの属性をセットすることを必須とするよう更
新されました。ですので今後サードパーティのローダが更新されれば、この属性
の存在に依存出来るようになります。ですがそのときが来るまでは、インポート
処理がモジュールのロードの後処理としてセットします。

さらにローダが PEP 366(2) よりの ‘__package__’ 属性を設定することも期待
出来るようになりました。繰り返しになりますがインポート処理自身が既にこれ
を全てのローダで *note importlib: 6b. より行っていて、また、インポート処
理自身がこの属性をロードの後処理としてセットしています。

‘None’ is now inserted into *note sys.path_importer_cache: 5ae. when no
finder can be found on *note sys.path_hooks: fee.  Since
‘imp.NullImporter’ is not directly exposed on *note sys.path_hooks: fee.
it could no longer be relied upon to always be available to use as a
value representing no finder found.

全てのほかの変更は、Python 3.3 へのコードの更新の際に考慮すべきセマンテ
ィクスの変更に関係しています。ですのでそららについて、このドキュメントの
*note Python コードの移植: 1043. セクションを読むべきです。

(Implementation by Brett Cannon)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0302/

   (2) https://peps.python.org/pep-0366/


File: python.info,  Node: その他の言語変更<9>,  Next: 細粒度のインポートロック,  Prev: インポート実装としての importlib の使用,  Up: What's New In Python 3 3

1.11.16 その他の言語変更
------------------------

Python 言語コアに小さな変更がいくつか行われました:

   * Added support for Unicode name aliases and named sequences.  Both
     *note unicodedata.lookup(): 104d. and ‘'\N{...}'’ now resolve name
     aliases, and *note unicodedata.lookup(): 104d. resolves named
     sequences too.

     (Contributed by Ezio Melotti in bpo-12753(1).)

   * Unicode データベースを UCD バージョン 6.1.0 にアップグレードしまし
     た。

   * *note range(): 911. オブジェクトどうしの等値性比較が、それぞれの
     range オブジェクトによって生成されるシーケンスの等値性を反映して行
     われるようになりました (bpo-13201(2))。

   * *note bytes: 1a4. と *note bytearray: 508. オブジェクトのメソッド
     ‘count()’, ‘find()’, ‘rfind()’, ‘index()’, ‘rindex()’ が、第一引数
     に 0 から 255 の整数を受け付けるようになりました。

     (Contributed by Petri Lehtinen in bpo-12170(3).)

   * *note bytes: 1a4. と *note bytearray: 508. オブジェクトのメソッド
     ‘rjust()’, ‘ljust()’, ‘center()’ が、 ‘fill’ 引数として *note
     bytearray: 508. を受け付けるようになりました (Contributed by Petri
     Lehtinen in bpo-12380(4).)。

   * *note list: 5dc. と *note bytearray: 508. に新規メソッド ‘copy()’,
     ‘clear()’ が追加されました (bpo-10516(5))。これに伴い *note
     MutableSequence: 186. にも ‘clear()’ メソッドが追加されました
     (bpo-11388(6))。

   * raw bytes リテラルとして ‘br"..."’ だけでなく ‘rb"..."’ とも書ける
     ようになりました。

     (Contributed by Antoine Pitrou in bpo-13748(7).)

   * *note dict.setdefault(): 104e. が与えられたキーのルックアップを一度
     しか行わないようになったので、組み込み型でのこれの使用はアトミック
     になります。(訳注: 外部観察可能な変化で説明すると、以前はこの呼び出
     しが、キーの2回の __hash__、__eq__ 呼び出しを引き起こしていたものが
     、1回になった。)

     (Contributed by Filip Gruszczyński in bpo-13521(8).)

   * 関数呼び出しが関数シグニチャに合致しない場合のエラーメッセージがか
     なり改善されました。

     (Contributed by Benjamin Peterson.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12753

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13201

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12170

   (4) https://bugs.python.org/issue?@action=redirect&bpo=12380

   (5) https://bugs.python.org/issue?@action=redirect&bpo=10516

   (6) https://bugs.python.org/issue?@action=redirect&bpo=11388

   (7) https://bugs.python.org/issue?@action=redirect&bpo=13748

   (8) https://bugs.python.org/issue?@action=redirect&bpo=13521


File: python.info,  Node: 細粒度のインポートロック,  Next: 組み込みの関数と型,  Prev: その他の言語変更<9>,  Up: What's New In Python 3 3

1.11.17 細粒度のインポートロック
--------------------------------

以前のバージョンの CPython では、常に大域的なインポートロックを当てにし
ていました。このことは意図せず頭痛の種を持ち込むこと繋がっていました。た
とえば、モジュールをインポートすることで副作用として異なるスレッドでのコ
ード実行を引き起こす際に起こる、デッドロックといったことです。不恰好な回
避策がときどき採用されてきました。C API 関数 *note
PyImport_ImportModuleNoBlock(): 397. などです。

Python 3.3 ではモジュールのインポートでは、モジュール単位でのロックを採
用しています。このことによって複数スレッドからの指定モジュールのインポー
トは (モジュールが不完全な初期化のまま曝されるのを防いで) 正しく直列化さ
れて、前述の頭痛の種は取り除かれています。

(Contributed by Antoine Pitrou in bpo-9260(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9260


File: python.info,  Node: 組み込みの関数と型,  Next: 新たなモジュール<9>,  Prev: 細粒度のインポートロック,  Up: What's New In Python 3 3

1.11.18 組み込みの関数と型
--------------------------

   * *note open(): 4e5. gets a new 'opener' parameter: the underlying
     file descriptor for the file object is then obtained by calling
     'opener' with ('file', 'flags').  It can be used to use custom
     flags like *note os.O_CLOEXEC: 1051. for example.  The ‘'x'’ mode
     was added: open for exclusive creation, failing if the file already
     exists.

   * *note print(): f42.: 'flush' キーワード引数が追加されました。
     'flush' キーワード引数が真の場合ストリームは強制的にフラッシュされ
     ます。

   * *note hash(): 5b5.: ハッシュのランダム化がデフォルトで有効になりま
     した。 *note object.__hash__(): ac9. と環境変数 *note
     PYTHONHASHSEED: 1052. を参照してください。

   * *note str: 418. 型に *note casefold(): da3. メソッドが追加されまし
     た。文字列の casefold されたコピーを返します。casefold された文字列
     は、大文字小文字に関係ないマッチに使えます。例えば ‘'ß'.casefold()’
     は ‘'ss'’ を返します。

   * シーケンスについてのドキュメントを大幅に書き換えました。バイナリの
     シーケンスとテキストのシーケンスについての区別についてより良い説明
     を加え、また、個々の組み込みシーケンスに関して個別のドキュメントを
     提供しています (bpo-4966(1))。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4966


File: python.info,  Node: 新たなモジュール<9>,  Next: 改良されたモジュール<9>,  Prev: 組み込みの関数と型,  Up: What's New In Python 3 3

1.11.19 新たなモジュール
------------------------

* Menu:

* faulthandler: faulthandler<4>.
* ipaddress: ipaddress<6>.
* lzma: lzma<2>.


File: python.info,  Node: faulthandler<4>,  Next: ipaddress<6>,  Up: 新たなモジュール<9>

1.11.19.1 faulthandler
......................

この新規モジュール *note faulthandler: 4e. には、異常 (セグメンテーショ
ン違反のようなクラッシュ) 時、タイムアウト時、ユーザシグナルの発生時など
のタイミングで Python traceback を明示的にダンプするための関数が含まれて
います。シグナル ‘SIGSEGV’, ‘SIGFPE’, ‘SIGABRT’, ‘SIGBUS’, ‘SIGILL’ に対
するフォールトハンドラをインストールするには、 *note
faulthandler.enable(): c6c. を呼び出してください。インタプリタ開始時点で
も有効に出来ます。それには環境変数 *note PYTHONFAULTHANDLER: 1055. をセ
ットするか、コマンドラインオプション *note -X: 15c. ‘faulthandler’ を与
えます。

Linuxでのセグメンテーションフォールト時の例:

     $ python -q -X faulthandler
     >>> import ctypes
     >>> ctypes.string_at(0)
     Fatal Python error: Segmentation fault

     Current thread 0x00007fb899f39700:
       File "/home/python/cpython/Lib/ctypes/__init__.py", line 486 in string_at
       File "<stdin>", line 1 in <module>
     Segmentation fault


File: python.info,  Node: ipaddress<6>,  Next: lzma<2>,  Prev: faulthandler<4>,  Up: 新たなモジュール<9>

1.11.19.2 ipaddress
...................

新規モジュール *note ipaddress: 74. は、IPv4/IPv6 アドレス、ネットワーク
、インターフェース (すなわち固有の IP サブネットで関連付けられる IP アド
レス) を表現するオブジェクトを生成したり加工したりするための道具立てを提
供します。

(Contributed by Google and Peter Moody in PEP 3144(1).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3144/


File: python.info,  Node: lzma<2>,  Prev: ipaddress<6>,  Up: 新たなモジュール<9>

1.11.19.3 lzma
..............

The newly added *note lzma: 7e. module provides data compression and
decompression using the LZMA algorithm, including support for the ‘.xz’
and ‘.lzma’ file formats.

(Contributed by Nadeem Vawda and Per Øyvind Karlsen in bpo-6715(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6715


File: python.info,  Node: 改良されたモジュール<9>,  Next: 最適化<8>,  Prev: 新たなモジュール<9>,  Up: What's New In Python 3 3

1.11.20 改良されたモジュール
----------------------------

* Menu:

* abc: abc<2>.
* array: array<5>.
* base64: base64<4>.
* binascii: binascii<3>.
* bz2: bz2<2>.
* codecs: codecs<2>.
* collections: collections<7>.
* contextlib: contextlib<7>.
* crypt: crypt<2>.
* curses: curses<5>.
* datetime: datetime<6>.
* decimal: decimal<3>.
* email: email<5>.
* ftplib: ftplib<3>.
* functools: functools<6>.
* gc: gc<6>.
* hmac: hmac<4>.
* http: http<4>.
* html: html<2>.
* imaplib: imaplib<3>.
* inspect: inspect<9>.
* io: io<6>.
* itertools: itertools<6>.
* logging: logging<7>.
* math: math<9>.
* mmap: mmap<4>.
* multiprocessing: multiprocessing<8>.
* nntplib: nntplib<2>.
* os: os<12>.
* pdb: pdb<7>.
* pickle: pickle<5>.
* pydoc: pydoc<5>.
* re: re<9>.
* sched::
* select: select<2>.
* shlex: shlex<3>.
* shutil: shutil<7>.
* signal: signal<4>.
* smtpd: smtpd<4>.
* smtplib: smtplib<4>.
* socket: socket<10>.
* socketserver: socketserver<3>.
* sqlite3: sqlite3<10>.
* ssl: ssl<11>.
* stat: stat<2>.
* struct: struct<3>.
* subprocess: subprocess<6>.
* sys: sys<13>.
* tarfile: tarfile<8>.
* tempfile: tempfile<4>.
* textwrap: textwrap<2>.
* threading: threading<8>.
* time: time<8>.
* types: types<7>.
* unittest: unittest<10>.
* urllib: urllib<4>.
* webbrowser: webbrowser<3>.
* xml.etree.ElementTree: xml etree ElementTree<2>.
* zlib: zlib<2>.


File: python.info,  Node: abc<2>,  Next: array<5>,  Up: 改良されたモジュール<9>

1.11.20.1 abc
.............

抽象メソッドで構成されるデスクリプタを含む抽象基底クラスのサポートが改善
されています。抽象デスクリプタを宣言するために推奨されるアプローチは今後
は、動的に更新されるプロパティとして ‘__isabstractmethod__’ を提供するこ
とです。この結果として、組み込みのデスクリプタが更新されました。

   * *note abc.abstractproperty: 105a. は非推奨となりました。代わりに
     *note abc.abstractmethod(): 105b. に *note property: 179. を渡して
     使ってください。

   * *note abc.abstractclassmethod: 105c. は非推奨となりました。代わりに
     *note abc.abstractmethod(): 105b. に *note classmethod: 14c. を渡し
     て使ってください。

   * *note abc.abstractstaticmethod: 105d. は非推奨となりました。代わり
     に *note abc.abstractmethod(): 105b. に *note staticmethod: 3ef. を
     渡して使ってください。

(Contributed by Darren Dale in bpo-11610(1).)

*note abc.ABCMeta.register(): 105e. が登録されたサブクラスを返すようにな
りました。つまりクラスデコレータとして使うことができるようになったという
ことです (bpo-10868(2))。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11610

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10868


File: python.info,  Node: array<5>,  Next: base64<4>,  Prev: abc<2>,  Up: 改良されたモジュール<9>

1.11.20.2 array
...............

The *note array: 6. module supports the long long type using ‘q’ and ‘Q’
type codes.

(Contributed by Oren Tirosh and Hirokazu Yamamoto in bpo-1172711(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1172711


File: python.info,  Node: base64<4>,  Next: binascii<3>,  Prev: array<5>,  Up: 改良されたモジュール<9>

1.11.20.3 base64
................

*note base64: a. モジュールのモダンなインターフェイスのほうのデコード関
数が、ASCII 文字のみで構成された Unicode 文字列を受け付けるようになりま
した。たとえば ‘base64.b64decode('YWJj')’ は ‘b'abc'’ を返します。
(Contributed by Catalin Iacob in bpo-13641(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13641


File: python.info,  Node: binascii<3>,  Next: bz2<2>,  Prev: base64<4>,  Up: 改良されたモジュール<9>

1.11.20.4 binascii
..................

‘a2b_’ 関数が、バイナリオブジェクトだけでなく ASCII 文字のみで構成された
Unicode 文字列を入力として受け付けるようになりました。 (Contributed by
Antoine Pitrou in bpo-13637(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13637


File: python.info,  Node: bz2<2>,  Next: codecs<2>,  Prev: binascii<3>,  Up: 改良されたモジュール<9>

1.11.20.5 bz2
.............

*note bz2: f. モジュールが最初から書き直されました。その過程で新機能がい
くつか追加されました。

   * 新たな *note bz2.open(): 1063. 関数: bzip2 で圧縮されたファイルをバ
     イナリかテキストモードで開きます。

   * *note bz2.BZ2File: 832. が、コンストラクタの 'fileobj' 引数で、任意
     のファイル様オブジェクトの読み書きが出来るようになりました。

     (Contributed by Nadeem Vawda in bpo-5863(1).)

   * *note bz2.BZ2File: 832. と *note bz2.decompress(): 1064. が
     (‘pbzip2’ ツールで生成されたような) マルチストリームの入力を展開出
     来るようになりました。同時に *note bz2.BZ2File: 832. は、 ‘'a'’ (追
     記) モードを使ってこのタイプの圧縮ファイルを作るのに使えるようにな
     りました。

     (Contributed by Nir Aides in bpo-1625(2).)

   * *note bz2.BZ2File: 832. が、 *note io.BufferedIOBase: 660. API で規
     定されているメソッドや属性のうち、 ‘detach()’ と ‘truncate()’ を除
     くすべてを実装するようになりました。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5863

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1625


File: python.info,  Node: codecs<2>,  Next: collections<7>,  Prev: bz2<2>,  Up: 改良されたモジュール<9>

1.11.20.6 codecs
................

*note mbcs: 49. コーデックが、全ての Windows バージョンでエラーハンドラ
‘replace’ と ‘ignore’ を正しく処理するように書き換えられました。 *note
mbcs: 49. コーデックは以前は、エンコードでは ‘replace’ のみ、デコードで
は ‘ignore’ のみでしたが、これにより全てのエラーハンドラがサポートされま
す。

新たに Windows のみ用のコーデック ‘cp65001’ が追加されました
(bpo-13216(1))。これは Windows コードページ 65001 (Windows UTF-8,
‘CP_UTF8’) です。例えばこれはコンソール出力のコードページが (例えば
‘chcp 65001’ コマンドを使って) cp65001 にセットされている場合に
‘sys.stdout’ で使われます。

マルチバイト CJK デコーダの再同期が高速になりました。これは不正なバイト
シーケンスが最初のバイトであれば無視するだけです。例えば
‘b'\xff\n'.decode('gb2312', 'replace')’ は文字置き換えののちに ‘\n’ を返
すようになっています。

(bpo-12016(2))

漸増的 CJK コーデックのエンコーダは以前は encode() メソッド呼び出しのた
びにリセットしていましたが、リセットしなくなりました。例えば:

     >>> import codecs
     >>> encoder = codecs.getincrementalencoder('hz')('strict')
     >>> b''.join(encoder.encode(x) for x in '\u52ff\u65bd\u65bc\u4eba\u3002 Bye.')
     b'~{NpJ)l6HK!#~} Bye.'

この例の場合は以前の Python では ‘b'~{Np~}~{J)~}~{l6~}~{HK~}~{!#~}
Bye.'’ となっていました。

(bpo-12100(3))

‘unicode_internal’ コーデックは非推奨となりました。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13216

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12016

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12100


File: python.info,  Node: collections<7>,  Next: contextlib<7>,  Prev: codecs<2>,  Up: 改良されたモジュール<9>

1.11.20.7 collections
.....................

新たに追加されたクラス *note ChainMap: bea. は、複数のマッピングをひとま
とまりに扱えるようにします。 (Written by Raymond Hettinger for
bpo-11089(1), made public in bpo-11297(2).)

抽象基底クラス群は新しいモジュール *note collections.abc: 17. に移動しま
した。抽象コレクションと具象コレクションを識別しやすくするためです。これ
をインポートしている既存のコードを維持するために、 ABC の別名群が *note
collections: 16. モジュール内に残されています。 (bpo-11085(3))

*note Counter: 1067. クラスが、単項 ‘+’ 演算子、単項 ‘-’ 演算子、インプ
レイス演算子の ‘+=’, ‘-=’, ‘|=’, ‘&=’ をサポートするようになりました。
(Contributed by Raymond Hettinger in bpo-13121(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11089

   (2) https://bugs.python.org/issue?@action=redirect&bpo=11297

   (3) https://bugs.python.org/issue?@action=redirect&bpo=11085

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13121


File: python.info,  Node: contextlib<7>,  Next: crypt<2>,  Prev: collections<7>,  Up: 改良されたモジュール<9>

1.11.20.8 contextlib
....................

コンテキストマネージャをプログラム的に操作することと、これと類似のクリー
ンアップの機能性について、*note ExitStack: af7. が今後は確かな基礎を提供
します。かつての (非推奨となり削除された) ‘contextlib.nested’ API とは違
って、この新しい API は、コンテキストマネージャがリソースを (たとえばフ
ァイルオブジェクトなどを) ‘__init__’ メソッドで獲得したのか、あるいは (た
とえば *note threading: d6. モジュールからの同期オブジェクトを)
‘__enter__’ メソッドで獲得したのかとは無関係に正しく動作するように設計さ
れました。

(bpo-13585(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13585


File: python.info,  Node: crypt<2>,  Next: curses<5>,  Prev: contextlib<7>,  Up: 改良されたモジュール<9>

1.11.20.9 crypt
...............

Addition of salt and modular crypt format (hashing method) and the
‘mksalt()’ function to the ‘crypt’ module.

(bpo-10924(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10924


File: python.info,  Node: curses<5>,  Next: datetime<6>,  Prev: crypt<2>,  Up: 改良されたモジュール<9>

1.11.20.10 curses
.................

   * *note curses: 23. モジュールが ncursesw ライブラリとリンクしている
     場合に、 Unicode 文字列や Unicode 文字が渡されれば Unicode 関数 (例
     えば ‘waddwstr()’)、それ以外の場合はバイト列用関数 (例えば
     ‘waddstr()’) を呼び出すようにしました。

   * Unicode 文字列をエンコードするのに ‘utf-8’ ではなく locale のエンコ
     ーディングを使うようになりました。(--訳注: bpo-12567(1) に対応した
     説明と思います。とすればこれは 'ワイド文字を受け取らない C 関数に渡
     す' 際に Unicode をエンコードする際の話。このときに以前は暗黙で
     ‘utf-8’ でエンコードしていたのは「誤りである」ということのようです
     。 --)

   * ‘curses.window’ クラスに属性 *note curses.window.encoding: 106b. が
     追加されました。

   * ‘curses.window’ クラスに *note get_wch(): 106c. メソッドが追加され
     ました。これはワイド文字を一つ取得します。

   * *note curses: 23. モジュールに関数 *note unget_wch(): 106d. が追加
     されました。これはワイド文字をプッシュし、次に *note get_wch():
     106c. を呼び出した時にその値が返るようにします。

(Contributed by Iñigo Serna in bpo-6755(2).)  (--訳注: 最初の2つはおそら
く bpo-12567(3) -)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12567

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6755

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12567


File: python.info,  Node: datetime<6>,  Next: decimal<3>,  Prev: curses<5>,  Up: 改良されたモジュール<9>

1.11.20.11 datetime
...................

   * naive な *note datetime: 1ae. インスタンスと aware な *note
     datetime: 1ae. インスタンスの等価比較で、 *note TypeError: 502. を
     投げずに *note False: b05. を返すようになりました。 (bpo-15006(1)).

   * 新規メソッド *note datetime.datetime.timestamp(): 106f.: *note
     datetime: 1ae. インスタンスに対応する POSIX タイムスタンプを返しま
     す。

   * *note datetime.datetime.strftime(): c5e. メソッドが 1000 年よりも前
     の書式化をサポートしました。(--訳注: What's New in Python 3.2 での
     変更も参照してみてください。--)

   * *note datetime.datetime.astimezone(): 99e. メソッドを引数なしで呼び
     出せるようになりました。これは datetime インスタンスをシステムのタ
     イムゾーンに変換します。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15006


File: python.info,  Node: decimal<3>,  Next: email<5>,  Prev: datetime<6>,  Up: 改良されたモジュール<9>

1.11.20.12 decimal
..................

bpo-7652(1) - decimal 算術演算の、高速なネイティブ 実装の統合

     C-module and libmpdec written by Stefan Krah.

The new C version of the decimal module integrates the high speed
libmpdec library for arbitrary precision correctly rounded decimal
floating-point arithmetic.  libmpdec conforms to IBM's General Decimal
Arithmetic Specification.

Performance gains range from 10x for database applications to 100x for
numerically intensive applications.  These numbers are expected gains
for standard precisions used in decimal floating-point arithmetic.
Since the precision is user configurable, the exact figures may vary.
For example, in integer bignum arithmetic the differences can be
significantly higher.

The following table is meant as an illustration.  Benchmarks are
available at ‘https://www.bytereef.org/mpdecimal/quickstart.html’.

                   decimal.py        _decimal           speedup
                                                        
     ---------------------------------------------------------------------
                                                        
     pi            42.02s            0.345s             120x
                                                        
                                                        
     telco         172.19s           5.68s              30x
                                                        
                                                        
     psycopg       3.57s             0.29s              12x
                                                        

* Menu:

* フィーチャー: フィーチャー<2>.
* API の変更: API の変更<2>.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=7652


File: python.info,  Node: フィーチャー<2>,  Next: API の変更<2>,  Up: decimal<3>

1.11.20.13 フィーチャー
.......................

   * *note FloatOperation: 1072. *note シグナル: 1073. により、float と
     Decimal の混合の厳密なセマンティクスを有効に出来ます。(--訳注: 使用
     例が *note クイックスタートチュートリアル: 1074. にあります。--)

   * If Python is compiled without threads, the C version automatically
     disables the expensive thread local context machinery.  In this
     case, the variable *note HAVE_THREADS: 1075. is set to ‘False’.


File: python.info,  Node: API の変更<2>,  Prev: フィーチャー<2>,  Up: decimal<3>

1.11.20.14 API の変更
.....................

   * C モジュールはマシンアーキテクチャに依存する以下のコンテキストの制
     限を持ちます:

                                  32-bit               64-bit
                                                       
          ---------------------------------------------------------------------------
                                                       
          ‘MAX_PREC’              ‘425000000’          ‘999999999999999999’
                                                       
                                                       
          ‘MAX_EMAX’              ‘425000000’          ‘999999999999999999’
                                                       
                                                       
          ‘MIN_EMIN’              ‘-425000000’         ‘-999999999999999999’
                                                       

   * In the context templates (*note DefaultContext: 1077, *note
     BasicContext: 1078. and *note ExtendedContext: 1079.) the magnitude
     of ‘Emax’ and ‘Emin’ has changed to ‘999999’.

   * decimal.py の *note Decimal: 27d. コンストラクタは上記のコンテキス
     ト制限に無知で、任意の指数や精度で正確に変換しようとします。C 版は
     内部の制限を持っていますので、次の規則が使われます: 可能ならば値は
     正確に変換され、そうでない場合 *note InvalidOperation: 107a. が送出
     されて結果が NaN となります。後者のケースは丸めあるいは不正確な値を
     得るために *note create_decimal(): 107b. を使うことでいつでも可能で
     す。(--訳注: わかりにくい表現ですがコンテキストで InvalidOperation
     をトラップしていれば結果が NaN で受け取れて(そうでなければ
     InvalidOperation が投げられて)、その制御は create_decimal で明示的
     に行える、ということを言っています。--)

   * The power function in decimal.py is always correctly rounded.  In
     the C version, it is defined in terms of the correctly rounded
     *note exp(): 107c. and *note ln(): 107d. functions, but the final
     result is only "almost always correctly rounded".

   * C 版ではシグナルを含む辞書は *note MutableMapping: 107e. です。速度
     的な理由により ‘flags’ と ‘traps’ はコンテキストが初期化された時点
     での *note MutableMapping: 107e. を参照し続けます。新たなシグナル辞
     書を ‘flags’ に ‘traps’ 割り当てれば新しい値で更新はされるものの、
     コンテキストはそれら右辺の辞書を参照しません。

   * *note Context: 107f. を pickle 化するとこれまでとは異なる出力をしま
     す。これは Python 版と C 版で共通の交換フォーマットを実現するためで
     す。

   * *note Context: 107f. コンストタクタの引数順が *note repr(): 7c8. で
     の表示順に合うように改められました。

   * *note quantize(): 1080. メソッドの ‘watchexp’ パラメータが非推奨と
     なりました。


File: python.info,  Node: email<5>,  Next: ftplib<3>,  Prev: decimal<3>,  Up: 改良されたモジュール<9>

1.11.20.15 email
................

* Menu:

* ポリシーフレームワーク::
* 新規ヘッダ API を伴った暫定ポリシー::
* その他のAPIの変更::


File: python.info,  Node: ポリシーフレームワーク,  Next: 新規ヘッダ API を伴った暫定ポリシー,  Up: email<5>

1.11.20.16 ポリシーフレームワーク
.................................

email パッケージに *note policy: 46. フレームワークが追加されました。
*note Policy: 1083. は、 email パッケージがどのように振舞うのかを制御す
るための多数のメソッドとプロパティを持つオブジェクトです。Python 3.3 の
ための最初のポリシーは *note Compat32: 1084. で、これは Python 3.2 の
email パッケージとの後方互換性を提供します。 ‘policy’ は、 *note parser:
45. によって email メッセージが解析される際、あるいは *note Message:
25d. オブジェクトを生成する際、あるいは *note generator: 37. を用いて
email がシリアライズする際に指定出来ます。オーバライドしない限りは、
‘parser’ に渡されたポリシーは全ての ‘Message’ オブジェクトと ‘parser’ が
生成したサブオブジェクトに引き継がれます。デフォルトでは ‘generator’ は
、シリアライズしようとする ‘Message’ オブジェクトのポリシーを使います。
デフォルトのポリシーは *note compat32: c67. です。

すべての ‘policy’ オブジェクトで実装される制御の最小限のセットは以下です
:

max_line_length     ‘Message’ がシリアライズされる際に各行が持ちうる、linesep
                    文字(列)を含まない最大の行幅です。デフォルトでは 78 です
                    。
                    
                    
linesep             ‘Message’ がシリアライズされる際に各行を分割するのに使わ
                    れる文字です。デフォルトは ‘\n’ です。
                    
                    
cte_type            ‘7bit’ または ‘8bit’ 。 ‘8bit’ は ‘Bytes’ ‘generator’ に
                    対してのみ適用され、プロトコルが許す場所 (あるいはオリジ
                    ナルの入力に含まれる場所) には非 ASCII が使われうることを
                    示します。
                    
                    
raise_on_defect     ‘parser’ が異常を検出した場合に、 ‘Message’ オブジェクト
                    の ‘defects’ リストに追加するのではなく例外を送出するよう
                    にします。
                    

新たな設定値を持つ新しいポリシーインスタンスは、ポリシーオブジェクトの
*note clone(): 1085. メソッドを使って作られます。 ‘clone’ は任意の上記制
御値をキーワード引数として受け取ります。この呼び出しで指定されない制御は
デフォルトのまま残されます。ですので linesep 文字列として ‘\r\n’ を使う
ポリシーをこのようにして作れます:

     mypolicy = compat32.clone(linesep='\r\n')

ポリシーは、あなたのアプリケーションが必要とするフォーマットでメッセージ
を生成するのを簡単にしてくれます。 ‘generator’ を呼び出す全ての場所で
‘linesep='\r\n'’ を指定するのを忘れないようにする代わりに、あなたのプロ
グラムが ‘Message’ オブジェクトを作成するために使う ‘parser’ あるいは
‘Message’ がポリシーを要求する一箇所だけで指定すれば良いのです。もちろん
一方ではメッセージを複数の形式で生成する必要があれば、 ‘generator’ 呼び
出しのたびにパラメータで指定する必要があります。もしくは、あなた固有のケ
ースのためにカスタムなポリシーを作って、 ‘generator’ 作成の際にそれを渡
すことも出来ます。


File: python.info,  Node: 新規ヘッダ API を伴った暫定ポリシー,  Next: その他のAPIの変更,  Prev: ポリシーフレームワーク,  Up: email<5>

1.11.20.17 新規ヘッダ API を伴った暫定ポリシー
..............................................

ポリシーフレームワーク単品でもまったくもって価値があるものではありますが
、その導入の主たる動機は、それを使わないコードに対しての後方互換を壊さな
いやり方で、email パッケージに新機能を実現する新しいポリシーを作れるよう
にすることでした。その新しいポリシーは新規 API を導入するものなので、私
たちはそれらを Python 3.3 での *note 暫定ポリシー: 100b. としてリリース
しました。コア開発者が必要と判断すれば、後方互換性を破壊する (コードの破
棄さえも含む) 変更が起こりえます。

その新規ポリシーは *note EmailPolicy: 1087. のインスタンス (訳注: *note
email.policy.default: 1088. や *note email.policy.SMTP: 1089. など) です
。これには以下の制御が追加されています:

refold_source       *note parser: 45. により解析されたヘッダを、
                    *note generator: 37. が折り返しし直す (refold) かどうかを
                    制御します。 ‘none’, ‘long’, ‘all’ のいずれかを指定します
                    。デフォルトは ‘long’ で、ソースのヘッダで
                    ‘max_line_length’ よりも長い行を refold します。 ‘none’ は
                    どの行も refold しません。 ‘all’ は全ての行を refold しま
                    す。
                    
                    
header_factory      ‘name’ と ‘value’ を引数に取り、カスタムなヘッダオブジェ
                    クトを生成する呼び出し可能 (callable) です。
                    

‘header_factory’ が、この新規ポリシーにより提供される新機能の要です。こ
の新規ポリシーの一つが使われると、 ‘Message’ オブジェクトから抽出された
すべてのヘッダは ‘header_factory’ で生成されるオブジェクトであり、また、
‘Message’ にヘッダをセットする場合のいつでも、それは ‘header_factory’ で
生成されるオブジェクトになります。すべてのその種のヘッダオブジェクトは、
ヘッダ名と同名の ‘name’ 属性を持ちます。アドレスヘッダと日付ヘッダは、ヘ
ッダの解析済み日付にアクセス出来るよう、追加の属性群を持ちます。以下のよ
うに使えます:

     >>> m = Message(policy=SMTP)
     >>> m['To'] = 'Éric <foo@example.com>'
     >>> m['to']
     'Éric <foo@example.com>'
     >>> m['to'].addresses
     (Address(display_name='Éric', username='foo', domain='example.com'),)
     >>> m['to'].addresses[0].username
     'foo'
     >>> m['to'].addresses[0].display_name
     'Éric'
     >>> m['Date'] = email.utils.localtime()
     >>> m['Date'].datetime
     datetime.datetime(2012, 5, 25, 21, 39, 24, 465484, tzinfo=datetime.timezone(datetime.timedelta(-1, 72000), 'EDT'))
     >>> m['Date']
     'Fri, 25 May 2012 21:44:27 -0400'
     >>> print(m)
     To: =?utf-8?q?=C3=89ric?= <foo@example.com>
     Date: Fri, 25 May 2012 21:44:27 -0400

Unicode の display name が、メッセージがシリアライズされる際に自動的に
‘utf-8’ (訳注: 実行例の場合は「の MIME ヘッダエンコード」) でエンコード
され、ヘッダに直接アクセスすると Unicode で返ることに気付くと思います。
つまり *note email.header: 38. の *note decode_header(): 108a. 関数や
*note make_header(): 108b. 関数を取り扱う必要性を取り除いてくれています
。

アドレスを部品から組み立てることも出来ます:

     >>> m['cc'] = [Group('pals', [Address('Bob', 'bob', 'example.com'),
     ...                           Address('Sally', 'sally', 'example.com')]),
     ...            Address('Bonzo', addr_spec='bonz@laugh.com')]
     >>> print(m)
     To: =?utf-8?q?=C3=89ric?= <foo@example.com>
     Date: Fri, 25 May 2012 21:44:27 -0400
     cc: pals: Bob <bob@example.com>, Sally <sally@example.com>;, Bonzo <bonz@laugh.com>

Unicode へデコードするのは自動で行われます:

     >>> m2 = message_from_string(str(m))
     >>> m2['to']
     'Éric <foo@example.com>'

メッセージ解析の際、グループと個々のアドレスにアクセスするのにヘッダオブ
ジェクトの ‘addresses’ 属性と ‘groups’ 属性を使えます:

     >>> m2['cc'].addresses
     (Address(display_name='Bob', username='bob', domain='example.com'), Address(display_name='Sally', username='sally', domain='example.com'), Address(display_name='Bonzo', username='bonz', domain='laugh.com'))
     >>> m2['cc'].groups
     (Group(display_name='pals', addresses=(Address(display_name='Bob', username='bob', domain='example.com'), Address(display_name='Sally', username='sally', domain='example.com')), Group(display_name=None, addresses=(Address(display_name='Bonzo', username='bonz', domain='laugh.com'),))

要するに新規ポリシーのどれか一つを使うことは、ヘッダ操作をこのようなもの
にしてくれるということです: あなたのアプリケーションは Unicode 文字列で
お仕事をし、email パッケージは Unicode のエンコード/デコードを透過的に行
って RFC 標準 Content Transfer Encoding との相互変換をやってのける、と。


File: python.info,  Node: その他のAPIの変更,  Prev: 新規ヘッダ API を伴った暫定ポリシー,  Up: email<5>

1.11.20.18 その他のAPIの変更
............................

*note BytesHeaderParser: 108d. が *note parser: 45. モジュールに追加され
ました。これは *note HeaderParser: 108e. を補足するものであり、また、
bytes API を完全にする (訳注: What's New in Python 3.2 での email の変更
内容参照) ものです。

新しいユーティリティ関数:

   * *note format_datetime(): 108f.: *note datetime: 1ae. を与えると
     email ヘッダで使われる書式でフォーマットした文字列を生成します。

   * *note parsedate_to_datetime(): 1090.: email ヘッダからの日付文字列
     を渡すと、 aware な、または naive な *note datetime: 1ae. に変換し
     ます。オフセットが ‘-0000’ の場合に naive で返します。

   * *note localtime(): 2a5.: 引数なしで呼び出すと、ローカル *note
     timezone: 1091. を使った aware な *note datetime: 1ae. として現在ロ
     ーカル時間を返します。aware な *note datetime: 1ae. を渡して呼び出
     すと、ローカル *note timezone: 1091. を使った aware な *note
     datetime: 1ae. に変換します。


File: python.info,  Node: ftplib<3>,  Next: functools<6>,  Prev: email<5>,  Up: 改良されたモジュール<9>

1.11.20.19 ftplib
.................

   * *note ftplib.FTP: 8c8. に新しいキーワード引数 ‘source_address’ が追
     加されました。 ‘(host, port)’ の形で指定し、これは外に向かうソケッ
     トを作成する際に *note bind(): 1093. 呼び出し内でのソースアドレスと
     して用いられます。 (Contributed by Giampaolo Rodolà in
     bpo-8594(1).)

   * *note FTP_TLS: 8c9. クラスに、制御チャネルを平文に戻すための *note
     ccc(): 1094. 関数が追加されました。これは、固定ポートで開くことなく
     非セキュア FTP で NAT を処理する方法を知っているファイアウォールを
     利用するのに有用となりえます。(Contributed by Giampaolo Rodolà in
     bpo-12139(2).)

   * 新規メソッド *note ftplib.FTP.mlsd(): 1095. は機械で読めるディレク
     トリリスティングのフォーマットを提供し、 *note ftplib.FTP.nlst():
     1096. と *note ftplib.FTP.dir(): 1097. に取って代わるものとなりまし
     た。(Contributed by Giampaolo Rodolà in bpo-11072(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8594

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12139

   (3) https://bugs.python.org/issue?@action=redirect&bpo=11072


File: python.info,  Node: functools<6>,  Next: gc<6>,  Prev: ftplib<3>,  Up: 改良されたモジュール<9>

1.11.20.20 functools
....................

*note functools.lru_cache(): 9bd. デコレータにキーワード引数 ‘typed’ を
指定出来るようになりました (デフォルトは ‘False’ です)。これは異なった型
の等値比較のキャッシュ値を別々のキャッシュスロットに置くかどうかを決めま
す。(Contributed by Raymond Hettinger in bpo-13227(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13227


File: python.info,  Node: gc<6>,  Next: hmac<4>,  Prev: functools<6>,  Up: 改良されたモジュール<9>

1.11.20.21 gc
.............

ガーベージコレクタが回収前後に呼び出すコールバックを登録出来るようになり
ました。新規属性 *note callbacks: 109a. リストに登録します。


File: python.info,  Node: hmac<4>,  Next: http<4>,  Prev: gc<6>,  Up: 改良されたモジュール<9>

1.11.20.22 hmac
...............

タイミング解析によるダイジェストに対する サイドチャンネル攻撃(1) からの
防御のために、 *note compare_digest(): 109c. 関数が追加されました。
(Contributed by Nick Coghlan and Christian Heimes in bpo-15061(2).)

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Side-channel_attack

   (2) https://bugs.python.org/issue?@action=redirect&bpo=15061


File: python.info,  Node: http<4>,  Next: html<2>,  Prev: hmac<4>,  Up: 改良されたモジュール<9>

1.11.20.23 http
...............

*note http.server.BaseHTTPRequestHandler: 109e. がヘッダをバッファするよ
うになり、 *note end_headers(): 109f. 呼び出し時に一度に全てをまとめて書
き出すようになりました。新規のメソッド *note flush_headers(): 10a0. は、
集積したヘッダを送信する場合の管理に直接使うことが出来ます。(Contributed
by Andrew Schaaf in bpo-3709(1).)

*note http.server: 68. が正当な ‘HTML 4.01 strict’ 出力を生成するように
なりました。 (Contributed by Ezio Melotti in bpo-13295(2).)

*note http.client.HTTPResponse: 10a1. にメソッド *note readinto(): 10a2.
が追加されました。つまりこのクラスを *note io.RawIOBase: 10a3. のように
扱えるということです。 (Contributed by John Kuhn in bpo-13464(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3709

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13295

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13464


File: python.info,  Node: html<2>,  Next: imaplib<3>,  Prev: http<4>,  Up: 改良されたモジュール<9>

1.11.20.24 html
...............

*note html.parser.HTMLParser: 843. が壊れたマークアップをエラーなしで解
析出来るようになりました。これによりコンストラクタの 'strict' 引数と
‘HTMLParseError’ 例外が撤廃されました。この壊れたマークアップを解析出来
る能力は数多くのバグフィックスからの結果であり、それらは Python 2.7/3.2
の最新バグフィックスリリースでも利用可能です。(Contributed by Ezio
Melotti in bpo-15114(1), and bpo-14538(2), bpo-13993(3), bpo-13960(4),
bpo-13358(5), bpo-1745761(6), bpo-755670(7), bpo-13357(8), bpo-12629(9),
bpo-1200313(10), bpo-670664(11), bpo-13273(12), bpo-12888(13),
bpo-7311(14).)

*note html.entities: 62. モジュールに、HTML5 名前付き文字参照と Unicode
文字(列) とを対応付ける *note html5: 10a5. 辞書が追加されました (例:
‘html5['gt;'] == '>'’)。この辞書は既に *note HTMLParser: 843. が使ってい
ます。 (Contributed by Ezio Melotti in bpo-11113(15) and bpo-15156(16).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15114

   (2) https://bugs.python.org/issue?@action=redirect&bpo=14538

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13993

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13960

   (5) https://bugs.python.org/issue?@action=redirect&bpo=13358

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1745761

   (7) https://bugs.python.org/issue?@action=redirect&bpo=755670

   (8) https://bugs.python.org/issue?@action=redirect&bpo=13357

   (9) https://bugs.python.org/issue?@action=redirect&bpo=12629

   (10) https://bugs.python.org/issue?@action=redirect&bpo=1200313

   (11) https://bugs.python.org/issue?@action=redirect&bpo=670664

   (12) https://bugs.python.org/issue?@action=redirect&bpo=13273

   (13) https://bugs.python.org/issue?@action=redirect&bpo=12888

   (14) https://bugs.python.org/issue?@action=redirect&bpo=7311

   (15) https://bugs.python.org/issue?@action=redirect&bpo=11113

   (16) https://bugs.python.org/issue?@action=redirect&bpo=15156


File: python.info,  Node: imaplib<3>,  Next: inspect<9>,  Prev: html<2>,  Up: 改良されたモジュール<9>

1.11.20.25 imaplib
..................

*note IMAP4_SSL: 8d2. コンストラクタが SSLContext パラメータを受け取るよ
うになりました。これはセキュアなチャネルのパラメータを制御します。

(Contributed by Sijin Joseph in bpo-8808(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8808


File: python.info,  Node: inspect<9>,  Next: io<6>,  Prev: imaplib<3>,  Up: 改良されたモジュール<9>

1.11.20.26 inspect
..................

*note getclosurevars(): 10a8. 関数が追加されました。この関数は、指定した
関数の関数本体から参照されている現在束縛されている全ての名前と、それら名
前が解決された場所 (訳注: globals, builtins など) を報告します。これによ
り、ステートフルなクロージャに依存するコードをテストするのに、正しい内部
状態を検証するのが容易になります。

(Contributed by Meador Inge and Nick Coghlan in bpo-13062(1).)

*note getgeneratorlocals(): 10a9. 関数が追加されました。この関数は、指定
したジェネレータのスタックフレーム内のローカル変数の、現在束縛されている
ものを報告します。これにより、ジェネレータをテストするのに、正しい内部状
態を検証するのが容易になります。

(Contributed by Meador Inge in bpo-15153(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13062

   (2) https://bugs.python.org/issue?@action=redirect&bpo=15153


File: python.info,  Node: io<6>,  Next: itertools<6>,  Prev: inspect<9>,  Up: 改良されたモジュール<9>

1.11.20.27 io
.............

*note open(): 4e6. 関数に排他的作成に使用する新たな ‘'x'’ モードが追加さ
れました。ファイルが既に存在する場合は *note FileExistsError: fea. を送
出します。 C11 fopen() の 'x' モードに基づいています。

(Contributed by David Townshend in bpo-12760(1).)

*note TextIOWrapper: 786. のコンストラクタにオプショナルな引数
'write_through' が追加されました。 'write_through' が ‘True’ の場合、
‘write()’ の呼び出しはバッファされないことが保証されます。
‘TextIOWrapper’ オブジェクトに書かれた全てのデータは直ちに下層のバイナリ
'buffer' に処理されます。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12760


File: python.info,  Node: itertools<6>,  Next: logging<7>,  Prev: io<6>,  Up: 改良されたモジュール<9>

1.11.20.28 itertools
....................

*note accumulate(): 9cb. がユーザ提供二項関数を渡すためのオプショナル引
数 ‘func’ を受け付けるようになりました。


File: python.info,  Node: logging<7>,  Next: math<9>,  Prev: itertools<6>,  Up: 改良されたモジュール<9>

1.11.20.29 logging
..................

*note basicConfig(): 9ce. 関数がオプショナルな ‘handlers’ 引数をサポート
するようになりました。これはルートロガーに追加するハンドラ群の *note
イテラブル: 10ad. です。

*note SysLogHandler: 628. クラスに、クラスレベル属性の ‘append_nul’ が追
加されました。これは syslog レコードに ‘NUL’ (‘\000’) バイトを追加するか
どうかを制御します。これはあるデーモンはこれで終端することが必要な一方で
ほかはメッセージの一部として NUL を通すという、デーモンによって振る舞い
が異なることに対応するためです。


File: python.info,  Node: math<9>,  Next: mmap<4>,  Prev: logging<7>,  Up: 改良されたモジュール<9>

1.11.20.30 math
...............

*note math: 81. モジュールに新たな関数 *note log2(): 10af. が追加されま
した。'x' の 2 を底とする対数を返します。

(Written by Mark Dickinson in bpo-11888(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11888


File: python.info,  Node: mmap<4>,  Next: multiprocessing<8>,  Prev: math<9>,  Up: 改良されたモジュール<9>

1.11.20.31 mmap
...............

*note read(): 10b1. メソッドの他のファイルライクなオブジェクトとの互換性
が増しました。引数が省略されるか ‘None’ の場合に、ファイルの現在位置から
マッピングの末尾までのバイト列を返すようになっています。(Contributed by
Petri Lehtinen in bpo-12021(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12021


File: python.info,  Node: multiprocessing<8>,  Next: nntplib<2>,  Prev: mmap<4>,  Up: 改良されたモジュール<9>

1.11.20.32 multiprocessing
..........................

関数 *note multiprocessing.connection.wait(): 10b3. が追加されました。こ
れは複数の (接続やソケット、パイプのような) オブジェクトをタイムアウト付
きでポーリングします。(Contributed by Richard Oudkerk in bpo-12328(1).)

プロセス間で　(訳注: ‘Connection.send()’ と ‘Connection.recv()’ で)
‘multiprocessing.Connection’ オブジェクトを相互に転送出来るようになりま
した。 (Contributed by Richard Oudkerk in bpo-4892(2).)

*note multiprocessing.Process: b27. がキーワード引数 ‘daemon’ を取るよう
になりました。これは親プロセスから ‘daemon’ フラグを継承するデフォルトの
振る舞いをオーバライドします (bpo-6064(3))。

属性 *note multiprocessing.Process.sentinel: 10b4. が追加されました。こ
れを用いることで、ふさわしい OS プリミティブ (例えば POSIX システムでの
*note select: af.) を使った一括での複数 *note Process: b27. オブジェクト
待ちが可能です。

*note map(): 82f. と *note itertools.starmap(): 10b5. との関係と同じ、既
存の *note multiprocessing.pool.Pool.map(): 10b6. と *note map_async():
10b7. に対応する *note multiprocessing.pool.Pool.starmap(): 10b8. と
*note starmap_async(): 10b9. が追加されました。 (Contributed by Hynek
Schlawack in bpo-12708(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12328

   (2) https://bugs.python.org/issue?@action=redirect&bpo=4892

   (3) https://bugs.python.org/issue?@action=redirect&bpo=6064

   (4) https://bugs.python.org/issue?@action=redirect&bpo=12708


File: python.info,  Node: nntplib<2>,  Next: os<12>,  Prev: multiprocessing<8>,  Up: 改良されたモジュール<9>

1.11.20.33 nntplib
..................

The ‘nntplib.NNTP’ class now supports the context management protocol to
unconditionally consume *note socket.error: 1029. exceptions and to
close the NNTP connection when done:

     >>> from nntplib import NNTP
     >>> with NNTP('news.gmane.org') as n:
     ...     n.group('gmane.comp.python.committers')
     ...
     ('211 1755 1 1755 gmane.comp.python.committers', 1755, 1, 1755, 'gmane.comp.python.committers')
     >>>

(Contributed by Giampaolo Rodolà in bpo-9795(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9795


File: python.info,  Node: os<12>,  Next: pdb<7>,  Prev: nntplib<2>,  Up: 改良されたモジュール<9>

1.11.20.34 os
.............

   * The *note os: 91. module has a new *note pipe2(): 10bc. function
     that makes it possible to create a pipe with *note O_CLOEXEC: 1051.
     or *note O_NONBLOCK: e08. flags set atomically.  This is especially
     useful to avoid race conditions in multi-threaded programs.

   * *note os: 91. モジュールに *note sendfile(): add. 関数が追加されま
     した。これはあるファイル (またはソケット) 記述子からのコピーを、効
     率的な「ゼロコピー」で行います。「ゼロコピー」という言い回しは、こ
     れは二つの記述子間でのデータのコピー全てが完全にカーネルによって行
     われる、という事実について指しています。データコピーにユーザ空間の
     バッファは使われません。 *note sendfile(): add. は例えばファイルの
     ダウンロードのような、ディスク上のファイルとネットワークソケット間
     での効率的なデータコピーに使うことが出来ます。

     (Patch submitted by Ross Lagerwall and Giampaolo Rodolà in
     bpo-10882(1).)

   * シンボリックリンク攻撃や一時ファイル、一時ディレクトリにまつわる問
     題のような競合状態を避けるには、ファイル名の代わりにファイル記述子
     を操作することがより信頼出来ます (そして高速でもあります)。 Python
     3.3 はファイル記述子で動作するよう既存関数の強化と新規関数の追加を
     行ないました。 (bpo-4761(2), bpo-10755(3) and bpo-14626(4))

        - *note os: 91. モジュールの新規関数 *note fwalk(): b29. は
          *note walk(): 476. と似ていますが、これは訪問するディレクトリ
          を指すファイル記述子も yield します。これは特にシンボリックリ
          ンクの競合を避けるために有用です。

        - 関数 *note access(): 10bd, *note chflags(): 10be, *note
          chmod(): 1fc, *note chown(): 10bf, *note link(): 10c0, *note
          lstat(): 46e, *note mkdir(): 1fe, *note mkfifo(): d5d, *note
          mknod(): d5e, *note open(): d5f, *note readlink(): 8ee, *note
          remove(): 10c1, *note rename(): 10c2, *note replace(): 10c3,
          *note rmdir(): 10c4, *note stat(): 46d, *note symlink(): 10c5,
          *note unlink(): 10c6, *note utime(): 10c7. が、新たな 2 つのオ
          プショナルなキーワード引数のどちらか、または両方をサポートする
          ようになりました。 'dir_fd' (*note paths relative to directory
          descriptors: 10c8.) と 'follow_symlinks' (*note not following
          symlinks: 10c9.) です。プラットフォームがそれらパラメータをサ
          ポートするかどうかは *note os.supports_dir_fd: 10ca. と *note
          os.supports_follow_symlinks: 10cb. を調べることでわかります。

        - 関数 *note chdir(): 5d8, *note chmod(): 1fc, *note chown():
          10bf, *note execve(): 10cc, *note listdir(): 10cd, *note
          pathconf(): 10ce, *note exists(): 9dc, *note stat(): 46d,
          *note statvfs(): 10cf, *note utime(): 10c7. が、パス引数として
          ファイル記述子をサポートするようになりました。これをプラットフ
          ォームがサポートするかどうかは *note os.supports_fd: 10d0. を
          調べることでわかります。

   * *note access(): 10bd. がキーワード引数 ‘effective_ids’ を受け取るよ
     うになりました。これは実 uid/gid の代わりに実効 uid/gid を使ってア
     クセスチェックを行うように振る舞いを変更します。これをプラットフォ
     ームがサポートするかどうかは *note supports_effective_ids: 10d1. を
     調べることでわかります。

   * *note os: 91. モジュールに 2 つの関数が追加されました。 *note
     getpriority(): 10d2. と *note setpriority(): 10d3. です。これらはプ
     ロセスのナイス値/優先度 (niceness/priority) を *note os.nice():
     10d4. と似た方法で取得・設定しますが、現在プロセスだけのものだけで
     はなく全てのプロセスに対して使えるよう拡張されています。

     (Patch submitted by Giampaolo Rodolà in bpo-10784(5).)

   * 新規関数 *note os.replace(): 10c3. は変更先の上書きにおいてクロスプ
     ラットフォームな方法でファイル名変更を行えます。既存の *note
     os.rename(): 10c2. では、変更先が既存のファイルの場合に POSIX では
     上書き、Windows ではエラーとなります。(Contributed by Antoine
     Pitrou in bpo-8828(6).)

   * stat 系関数 (*note stat(): 46d, *note fstat(): d59, *note lstat():
     46e.) がファイルのタイムスタンプのナノ秒精度を読み取れるようになり
     ました。これと対となる *note utime(): 10c7. もファイルのタイムスタ
     ンプをナノ秒精度で書き出せるようになりました。 (Contributed by
     Larry Hastings in bpo-14127(7).)

   * 新規関数 *note os.get_terminal_size(): 10d5. はファイル記述子が接続
     しているターミナルウィンドウのサイズを取得します。 *note
     shutil.get_terminal_size(): 10d6. も参照して下さい。 (Contributed
     by Zbigniew Jędrzejewski-Szmek in bpo-13609(8).)

   * Linux 拡張属性をサポートするための新たな関数 (bpo-12720(9)): *note
     getxattr(): 10d7, *note listxattr(): 10d8, *note removexattr():
     10d9, *note setxattr(): 10da.

   * スケジューラに対する新たなインターフェイス。これら関数はプロセスに
     対する OS による CPU 時間割り当てを制御します。新規関数: *note
     sched_get_priority_max(): 10db, *note sched_get_priority_min():
     10dc, *note sched_getaffinity(): 10dd, *note sched_getparam():
     10de, *note sched_getscheduler(): 10df, *note
     sched_rr_get_interval(): 10e0, *note sched_setaffinity(): 10e1,
     *note sched_setparam(): 10e2, *note sched_setscheduler(): 10e3,
     *note sched_yield(): 10e4,

   * ファイルシステムを制御する新たな関数:

        * *note posix_fadvise(): d60.: データへアクセスする意思を、パタ
          ーンを指定して宣言します。これによりカーネルが最適化を行えるよ
          うになります。

        * *note posix_fallocate(): d61.: ファイルを割り当てるに十分なデ
          ィスクスペースを確保します。

        * *note sync(): 10e5.: ディスクへの全ての書き込みを強制します。

   * 追加された新たな POSIX 関数:

        * *note lockf(): 10e6.: オープンされたファイル記述子に対して、
          POSIX ロックの適用、テスト、解除を行います。

        * *note pread(): b2d.: ファイル記述子の指定オフセット位置から読
          み込みます。ファイルオフセットは変化しません。

        * *note pwrite(): b30.: ファイル記述子に対し、指定オフセット位置
          から書き出します。ファイルオフセットは変化しません。

        * *note readv(): b2c.: ファイル記述子からデータを読みこんで複数
          の書き込み可能なバッファに書き込みます。

        * *note truncate(): e09.: 'path' に対応するファイルを、サイズが
          最大で 'length' バイトになるよう切り詰めます。

        * *note waitid(): d66.: 一つ以上の子プロセスの完了を待ちます。

        * *note writev(): b2f.: 'buffers' の内容をファイル記述子へ書き出
          します。 'buffer' は任意のバッファのシーケンスです。

        * *note getgrouplist(): 10e7. (bpo-9344(10)): 指定したユーザが属
          するグループ ID のリストを返します。

   * *note times(): 10e8. および *note uname(): 10e9.: 戻り値の型がタプ
     ルから属性名のついたタプルライクオブジェクトに変更されました。

   * いくつかのプラットフォームにおいて、 *note lseek(): 10ea. 関数で使
     う追加の定数をサポートするようになりました。 ‘os.SEEK_HOLE’ や
     ‘os.SEEK_DATA’ などです。

   * New constants *note RTLD_LAZY: 10eb, *note RTLD_NOW: 10ec, *note
     RTLD_GLOBAL: 10ed, *note RTLD_LOCAL: 10ee, *note RTLD_NODELETE:
     10ef, *note RTLD_NOLOAD: 10f0, and *note RTLD_DEEPBIND: 10f1. are
     available on platforms that support them.  These are for use with
     the *note sys.setdlopenflags(): 10f2. function, and supersede the
     similar constants defined in *note ctypes: 22. and ‘DLFCN’.
     (Contributed by Victor Stinner in bpo-13226(11).)

   * クロスプラットフォームのサポートを簡単にするために、非 Windows 環境
     でも *note os.symlink(): 10c5. がキーワード引数
     ‘target_is_directory’ を受け付けるようになりました (単に無視します
     )。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10882

   (2) https://bugs.python.org/issue?@action=redirect&bpo=4761

   (3) https://bugs.python.org/issue?@action=redirect&bpo=10755

   (4) https://bugs.python.org/issue?@action=redirect&bpo=14626

   (5) https://bugs.python.org/issue?@action=redirect&bpo=10784

   (6) https://bugs.python.org/issue?@action=redirect&bpo=8828

   (7) https://bugs.python.org/issue?@action=redirect&bpo=14127

   (8) https://bugs.python.org/issue?@action=redirect&bpo=13609

   (9) https://bugs.python.org/issue?@action=redirect&bpo=12720

   (10) https://bugs.python.org/issue?@action=redirect&bpo=9344

   (11) https://bugs.python.org/issue?@action=redirect&bpo=13226


File: python.info,  Node: pdb<7>,  Next: pickle<5>,  Prev: os<12>,  Up: 改良されたモジュール<9>

1.11.20.35 pdb
..............

‘Tab’ キーでの補完がコマンド名だけでなくその引数に対しても使えるようにな
りました。例えば ‘break’ コマンドに対しては、関数、ファイル名が補完され
ます。

(Contributed by Georg Brandl in bpo-14210(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14210


File: python.info,  Node: pickle<5>,  Next: pydoc<5>,  Prev: pdb<7>,  Up: 改良されたモジュール<9>

1.11.20.36 pickle
.................

*note pickle.Pickler: 9ec. オブジェクトに pickler ごとのリダクション関数
を設定する、オプショナルな *note dispatch_table: 10f5. 属性が追加されま
した。

(Contributed by Richard Oudkerk in bpo-14166(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14166


File: python.info,  Node: pydoc<5>,  Next: re<9>,  Prev: pickle<5>,  Up: 改良されたモジュール<9>

1.11.20.37 pydoc
................

Tk GUI と ‘serve()’ 関数は *note pydoc: a3. モジュールから削除されました
。 ‘pydoc -g’ と ‘serve()’ は Python 3.2 から既に非推奨となっていました
。


File: python.info,  Node: re<9>,  Next: sched,  Prev: pydoc<5>,  Up: 改良されたモジュール<9>

1.11.20.38 re
.............

*note str: 418. 正規表現が ‘\u’ および ‘\U’ エスケープをサポートしました
。

(Contributed by Serhiy Storchaka in bpo-3665(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3665


File: python.info,  Node: sched,  Next: select<2>,  Prev: re<9>,  Up: 改良されたモジュール<9>

1.11.20.39 sched
................

   * *note run(): 10f9. が 'blocking' パラメータを取るようになりました。
     これを偽にセットすると、このメソッドは既に実行予定時間になっている
     イベント (もしあれば) を実行してすぐに戻ります。 これは *note
     scheduler: 10fa. を非ブロッキングなアプリケーションで使いたい場合に
     有用です。 (Contributed by Giampaolo Rodolà in bpo-13449(1).)  (--訳
     注: 原文の表現がわかりにくいですが、これは ‘blocking=False’ 時はス
     ケジュールされた時間になっているタスクがあれば通常は 'delayfunc' を
     呼び出すところをそうせずに、一番早く次の予定時間に達するタスクの予
     定時間までの時間差を返します。--)

   * *note scheduler: 10fa. クラスをマルチスレッド環境で安全に使えるよう
     になりました。 (Contributed by Josiah Carlson and Giampaolo Rodolà
     in bpo-8684(2).)

   * *note scheduler: 10fa. クラスのコンストラクタでのパラメータ
     'timefunc' と 'delayfunc' が省略可能になりました。それぞれデフォル
     トで順に *note time.time(): 235, *note time.sleep(): 669. が使われ
     ます。 (Contributed by Chris Clark in bpo-13245(3).)

   * *note enter(): 10fb. と *note enterabs(): 10fc. の 'argument' パラ
     メータが省略可能になりました。 (Contributed by Chris Clark in
     bpo-13245(4).)

   * *note enter(): 10fb. と *note enterabs(): 10fc. が 'kwargs' パラメ
     ータを受け付けるようになりました。 (Contributed by Chris Clark in
     bpo-13245(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13449

   (2) https://bugs.python.org/issue?@action=redirect&bpo=8684

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13245

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13245

   (5) https://bugs.python.org/issue?@action=redirect&bpo=13245


File: python.info,  Node: select<2>,  Next: shlex<3>,  Prev: sched,  Up: 改良されたモジュール<9>

1.11.20.40 select
.................

Solaris とその派生プラットフォームにおいて、新規クラス *note
select.devpoll: f62. が追加されました。これはハイパフォーマンスな非同期
ソケットを ‘/dev/poll’ 経由で提供するものです。 (Contributed by Jesús
Cea Avión in bpo-6397(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6397


File: python.info,  Node: shlex<3>,  Next: shutil<7>,  Prev: select<2>,  Up: 改良されたモジュール<9>

1.11.20.41 shlex
................

The previously undocumented helper function ‘quote’ from the ‘pipes’
modules has been moved to the *note shlex: b2. module and documented.
*note quote(): 25e. properly escapes all characters in a string that
might be otherwise given special meaning by the shell.


File: python.info,  Node: shutil<7>,  Next: signal<4>,  Prev: shlex<3>,  Up: 改良されたモジュール<9>

1.11.20.42 shutil
.................

   * 新たな関数:

        * *note disk_usage(): 1100.: ディスクの利用状況について、トータ
          ル、使用中、空きの容量を返します。 (Contributed by Giampaolo
          Rodolà in bpo-12442(1).)

        * *note chown(): 221.: 指定された path のユーザ、グループの両方
          あるいは一方を変更します。ユーザ、グループは名前もしくは数値で
          の ID (uid, gid) で指定します。(Contributed by Sandro Tosi in
          bpo-12191(2).)

        * *note shutil.get_terminal_size(): 10d6.: インタプリタが接続し
          ているターミナルウィンドウのサイズを取得します。 (Contributed
          by Zbigniew Jędrzejewski-Szmek in bpo-13609(3).)

   * *note copy2(): a29. と *note copystat(): 1101. がファイルのタイムス
     タンプを、それをサポートするプラットフォームではナノ秒精度も維持す
     るようになりました。また、Linux ではこれらは「拡張属性 (extended
     attributes)」もコピーするようになりました。 (Contributed by Larry
     Hastings in bpo-14127(4) and bpo-15238(5).)

   * いくつかの関数がオプショナルな ‘symlinks’ 引数を取るようになりまし
     た。これが真の場合、シンボリックリンクの指す先を解決するのではなく
     シンボリックそのものに対しての操作をします (そうすることが必要であ
     ればシンボリックリンク作成もします)。(Contributed by Hynek
     Schlawack in bpo-12715(6).)

   * ファイルシステムをまたがったファイルのコピーの際に、 *note move():
     a2a. がシンボリックリンクを POSIX の ‘move’ コマンドが行うのと同じ
     やり方で扱うようになりました。つまりターゲットのファイルの中身をコ
     ピーするのではなくシンボリックリンクを再作成します。(Contributed by
     Jonathan Niehof in bpo-9993(7).)  また、 *note move(): a2a. は
     ‘dst’ 引数を戻り値として返すようになりました。

   * *note os.open(): d5f. と *note os.unlink(): 10c6. が新パラメータ
     ‘dir_fd’ をサポートしているプラットフォームでは、 *note rmtree():
     2d8. は今では シンボリックリンク攻撃に耐性を持ちます。 (Contributed
     by Martin von Löwis and Hynek Schlawack in bpo-4489(8).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12442

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12191

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13609

   (4) https://bugs.python.org/issue?@action=redirect&bpo=14127

   (5) https://bugs.python.org/issue?@action=redirect&bpo=15238

   (6) https://bugs.python.org/issue?@action=redirect&bpo=12715

   (7) https://bugs.python.org/issue?@action=redirect&bpo=9993

   (8) https://bugs.python.org/issue?@action=redirect&bpo=4489


File: python.info,  Node: signal<4>,  Next: smtpd<4>,  Prev: shutil<7>,  Up: 改良されたモジュール<9>

1.11.20.43 signal
.................

   * *note signal: b4. モジュールに新規関数が追加されました:

        * *note pthread_sigmask(): 1103.: これを呼び出すスレッドにセット
          されているシグナルマスクを取り出したり変更したりします
          (Contributed by Jean-Paul Calderone in bpo-8407(1));

        * *note pthread_kill(): 1104.: スレッドにシグナルを送ります;

        * *note sigpending(): 1105.: 保留中のシグナルを調べます;

        * *note sigwait(): 1106.: シグナルを待ちます;

        * *note sigwaitinfo(): d78.: シグナルを待ちますが、それについて
          の詳細情報を返します;

        * *note sigtimedwait(): d77.: *note sigwaitinfo(): d78. と似てい
          ますがタイムアウト指定できます。

   * シグナルハンドラは wakeup ファイル記述子に以前は ‘\0’ を書き込んで
     いましたが、シグナル番号を 1 バイト整数として書き込むようにしました
     。これにより、一つ以上のシグナルを待った上でどのシグナルが発生した
     のかあとから調べるといったことが出来ます。

   * *note signal.signal(): 1107. と *note signal.siginterrupt(): 1108.
     は RuntimeError ではなく *note OSError: 3f0. を投げるようになりまし
     た: OSError は errno 属性を持っています。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8407


File: python.info,  Node: smtpd<4>,  Next: smtplib<4>,  Prev: signal<4>,  Up: 改良されたモジュール<9>

1.11.20.44 smtpd
................

The ‘smtpd’ module now supports RFC 5321(1) (extended SMTP) and RFC
1870(2) (size extension).  Per the standard, these extensions are
enabled if and only if the client initiates the session with an ‘EHLO’
command.

(Initial ‘ELHO’ support by Alberto Trevino.  Size extension by Juhana
Jauhiainen.  Substantial additional work on the patch contributed by
Michele Orrù and Dan Boswell.  bpo-8739(3))

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5321.html

   (2) https://datatracker.ietf.org/doc/html/rfc1870.html

   (3) https://bugs.python.org/issue?@action=redirect&bpo=8739


File: python.info,  Node: smtplib<4>,  Next: socket<10>,  Prev: smtpd<4>,  Up: 改良されたモジュール<9>

1.11.20.45 smtplib
..................

クラス *note SMTP: 8fb, *note SMTP_SSL: 8fc, *note LMTP: 8fd. に新しいキ
ーワード引数 ‘source_address’ が追加されました。 ‘(host, port)’ の形で指
定し、これは外に向かうソケットを作成する際に *note bind(): 1093. 呼び出
し内でのソースアドレスとして用いられます。(Contributed by Paulo Scardine
in bpo-11281(1).)

*note SMTP: 8fb. がコンテキスト管理プロトコルをサポートするようになった
ので ‘SMTP’ のインスタンスを ‘with’ 文で使えます。 (Contributed by
Giampaolo Rodolà in bpo-11289(2).)

*note SMTP_SSL: 8fc. コンストラクタと *note starttls(): 110b. メソッドが
SSLContext パラメータを受け取るようになりました。これはセキュアなチャネ
ルのパラメータを制御します。 (Contributed by Kasun Herath in
bpo-8809(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11281

   (2) https://bugs.python.org/issue?@action=redirect&bpo=11289

   (3) https://bugs.python.org/issue?@action=redirect&bpo=8809


File: python.info,  Node: socket<10>,  Next: socketserver<3>,  Prev: smtplib<4>,  Up: 改良されたモジュール<9>

1.11.20.46 socket
.................

   * *note socket: d6e. クラスが、前提となるプラットフォームがサポートし
     ていれば従属的なデータを処理する追加のメソッドを公開しました:

        * *note sendmsg(): 443.

        * *note recvmsg(): d73.

        * *note recvmsg_into(): 110d.

     (Contributed by David Watson in bpo-6560(1), based on an earlier
     patch by Heiko Wundram)

   * *note socket: d6e. クラスが Linux で
     (‘https://lwn.net/Articles/253425’) PF_CAN プロトコルファミリ
     (‘https://en.wikipedia.org/wiki/Socketcan’) をサポートしました。

     (Contributed by Matthias Fuchs, updated by Tiago Gonçalves in
     bpo-10141(2).)

   * The *note socket: d6e. class now supports the PF_RDS protocol
     family (‘https://en.wikipedia.org/wiki/Reliable_Datagram_Sockets’
     and https://oss.oracle.com/projects/rds(3)).

   * *note socket: d6e. クラスが OS X で ‘PF_SYSTEM’ プロトコルファミリ
     をサポートするようになりました。 (Contributed by Michael Goderbauer
     in bpo-13777(4).)

   * New function *note sethostname(): 110e. allows the hostname to be
     set on Unix systems if the calling process has sufficient
     privileges.  (Contributed by Ross Lagerwall in bpo-10866(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6560

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10141

   (3) 
https://web.archive.org/web/20130115155505/https://oss.oracle.com/projects/rds/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13777

   (5) https://bugs.python.org/issue?@action=redirect&bpo=10866


File: python.info,  Node: socketserver<3>,  Next: sqlite3<10>,  Prev: socket<10>,  Up: 改良されたモジュール<9>

1.11.20.47 socketserver
.......................

*note BaseServer: 1110. がオーバライド可能な *note service_actions():
1111. メソッドを持つようになり、これは *note serve_forever(): 1112. によ
りサービスループ内で呼び出されます。 *note ForkingMixIn: b45. がこれをゾ
ンビ化した子プロセスのクリーンアップに使っています。 (Contributed by
Justin Warkentin in bpo-11109(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11109


File: python.info,  Node: sqlite3<10>,  Next: ssl<11>,  Prev: socketserver<3>,  Up: 改良されたモジュール<9>

1.11.20.48 sqlite3
..................

*note sqlite3.Connection: 226. の新規のメソッド *note
set_trace_callback(): 28d. を使うと sqlite3 により処理されるすべての sql
コマンドの足跡 (トレース) をキャプチャ出来ます。(Contributed by Torsten
Landschoff in bpo-11688(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11688


File: python.info,  Node: ssl<11>,  Next: stat<2>,  Prev: sqlite3<10>,  Up: 改良されたモジュール<9>

1.11.20.49 ssl
..............

   * *note ssl: bb. モジュールに新たに 2 つの乱数生成関数が追加されまし
     た:

        * *note RAND_bytes(): 4ed.: 暗号学的に強固な擬似乱数バイト列を生
          成します。

        * ‘RAND_pseudo_bytes()’: 擬似乱数バイト列を生成します。

     (Contributed by Victor Stinner in bpo-12049(1).)

   * *note ssl: bb. モジュールがより粒度の細かい例外階層を公開するように
     なり、これにより様々な種類のエラーを調べることが容易になります。
     (Contributed by Antoine Pitrou in bpo-11183(2).)

   * *note load_cert_chain(): 275. が 'password' 引数を受け付けるように
     なりました。これは秘密鍵が暗号化されている場合に使われます。
     (Contributed by Adam Simpkins in bpo-12803(3).)

   * ディフィー・ヘルマン鍵共有の、通常のものと楕円曲線ベースのもの両方
     が *note load_dh_params(): 1115. メソッドと *note set_ecdh_curve():
     1116. メソッドを通じてサポートされるようになりました。(Contributed
     by Antoine Pitrou in bpo-13626(4) and bpo-13627(5).)

   * SSL ソケットに新規メソッド *note get_channel_binding(): 1117. が追
     加されました。これは SCRAM-SHA-1-PLUS (訳注: RFC 5802(6) など参照)
     のようなある種の認証メカニズムの実装で拡張されることを想定したもの
     です。(Contributed by Jacek Konieczny in bpo-12551(7).)

   * You can query the SSL compression algorithm used by an SSL socket,
     thanks to its new *note compression(): 1118. method.  The new
     attribute *note OP_NO_COMPRESSION: 1119. can be used to disable
     compression.  (Contributed by Antoine Pitrou in bpo-13634(8).)

   * *note ssl.SSLContext.set_npn_protocols(): 2d9. による Next Protocol
     Negotiation 拡張のサポートが追加されました。 (Contributed by Colin
     Marc in bpo-14204(9).)

   * 属性 *note library: 111a. と *note reason: 111b. が追加されたので、
     SSL のエラーは以前よりもっと簡単に調べることが出来るようになりまし
     た。(Contributed by Antoine Pitrou in bpo-14837(10).)

   * *note get_server_certificate(): 807. 関数が IPv6 をサポートするよう
     になりました。 (Contributed by Charles-François Natali in
     bpo-11811(11).)

   * New attribute *note OP_CIPHER_SERVER_PREFERENCE: 111c. allows
     setting SSLv3 server sockets to use the server's cipher ordering
     preference rather than the client's (bpo-13635(12)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12049

   (2) https://bugs.python.org/issue?@action=redirect&bpo=11183

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12803

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13626

   (5) https://bugs.python.org/issue?@action=redirect&bpo=13627

   (6) https://datatracker.ietf.org/doc/html/rfc5802.html

   (7) https://bugs.python.org/issue?@action=redirect&bpo=12551

   (8) https://bugs.python.org/issue?@action=redirect&bpo=13634

   (9) https://bugs.python.org/issue?@action=redirect&bpo=14204

   (10) https://bugs.python.org/issue?@action=redirect&bpo=14837

   (11) https://bugs.python.org/issue?@action=redirect&bpo=11811

   (12) https://bugs.python.org/issue?@action=redirect&bpo=13635


File: python.info,  Node: stat<2>,  Next: struct<3>,  Prev: ssl<11>,  Up: 改良されたモジュール<9>

1.11.20.50 stat
...............

ドキュメントされていなかった ‘tarfile.filemode’ 関数が *note
stat.filemode(): 111e. に移動されました。これはファイルモードを
'-rwxrwxrwx' 形式の文字列に変換するのに使えます。

(Contributed by Giampaolo Rodolà in bpo-14807(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14807


File: python.info,  Node: struct<3>,  Next: subprocess<6>,  Prev: stat<2>,  Up: 改良されたモジュール<9>

1.11.20.51 struct
.................

The *note struct: c0. module now supports ‘ssize_t’ and ‘size_t’ via the
new codes ‘n’ and ‘N’, respectively.  (Contributed by Antoine Pitrou in
bpo-3163(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3163


File: python.info,  Node: subprocess<6>,  Next: sys<13>,  Prev: struct<3>,  Up: 改良されたモジュール<9>

1.11.20.52 subprocess
.....................

POSIX プラットフォームにおいて、コマンド文字列として bytes オブジェクト
を渡せるようになりました。 (Contributed by Victor Stinner in
bpo-8513(1).)

A new constant *note DEVNULL: 1121. allows suppressing output in a
platform-independent fashion.  (Contributed by Ross Lagerwall in
bpo-5870(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8513

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5870


File: python.info,  Node: sys<13>,  Next: tarfile<8>,  Prev: subprocess<6>,  Up: 改良されたモジュール<9>

1.11.20.53 sys
..............

*note sys: c3. モジュールに、スレッドの実装に関する情報が格納された
*note 名前付きタプル: 61a. を保持する *note thread_info: 1123. が追加さ
れました。 (bpo-11223(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=11223


File: python.info,  Node: tarfile<8>,  Next: tempfile<4>,  Prev: sys<13>,  Up: 改良されたモジュール<9>

1.11.20.54 tarfile
..................

*note tarfile: c8. が *note lzma: 7e. モジュールにより ‘lzma’ エンコーデ
ィングをサポートするようになりました (Contributed by Lars Gustäbel in
bpo-5689(1).)。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5689


File: python.info,  Node: tempfile<4>,  Next: textwrap<2>,  Prev: tarfile<8>,  Up: 改良されたモジュール<9>

1.11.20.55 tempfile
...................

*note tempfile.SpooledTemporaryFile: 65f. の ‘truncate()’ メソッドが
‘size’ 引数を受け取るようになりました。 (Contributed by Ryan Kelly in
bpo-9957(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9957


File: python.info,  Node: textwrap<2>,  Next: threading<8>,  Prev: tempfile<4>,  Up: 改良されたモジュール<9>

1.11.20.56 textwrap
...................

*note textwrap: d5. モジュールに *note indent(): 257. が追加されました。
これはテキストのブロック内の選択行に共通のプレフィクスを追加する簡単な方
法になります。(bpo-13857(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13857


File: python.info,  Node: threading<8>,  Next: time<8>,  Prev: textwrap<2>,  Up: 改良されたモジュール<9>

1.11.20.57 threading
....................

いずれもかつてインスタンスを返すファクトリ関数であった *note
threading.Condition: 1128, *note threading.Semaphore: 1129, *note
threading.BoundedSemaphore: 112a, *note threading.Event: 112b, *note
threading.Timer: 112c. がクラスになったので、サブクラス化出来るようにな
りました。 (Contributed by Éric Araujo in bpo-10968(1).)

*note threading.Thread: 91a. コンストラクタがキーワード引数 ‘daemon’ を
取るようになりました。これは親スレッドから ‘daemon’ フラグを継承するデフ
ォルトの振る舞いをオーバライドします (bpo-6064(2))。

かつての非公開関数 ‘_thread.get_ident’ が公開関数 *note
threading.get_ident(): 112d. として利用可能となっています。これは標準ラ
イブラリにおいて多数の ‘_thread’ モジュールへの直接アクセスを取り除く結
果になりました。 ‘_thread.get_ident’ を使っているサードパーティのコード
も同じように、新しく公開化されたインターフェイスに乗り換えるべきです。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10968

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6064


File: python.info,  Node: time<8>,  Next: types<7>,  Prev: threading<8>,  Up: 改良されたモジュール<9>

1.11.20.58 time
...............

PEP 418(1) が *note time: d7. モジュールに新たな関数を追加しました:

   * *note get_clock_info(): 112f.: クロックの情報を取得します。

   * *note monotonic(): 234.: 単調なクロック (逆行しない)、システムクロ
     ックの更新の影響を受けません。

   * *note perf_counter(): a56.: 短期間の計測のために利用可能な最高の解
     像度を持つパフォーマンスカウンタです。

   * *note process_time(): a57.: 現在のプロセスの system と user CPU 時
     間の和です。

その他の新たな関数:

   * *note clock_getres(): 1130, *note clock_gettime(): 1131. and *note
     clock_settime(): 1132. functions with ‘CLOCK_XXX’ constants.
     (Contributed by Victor Stinner in bpo-10278(2).)

クロスプラットフォーム間での一貫性を改善するために、 *note sleep(): 669.
が負の値を渡すと *note ValueError: 1e3. を投げるように変更されています。
以前から POSIX システムではエラーでしたが、Windows の場合に無限に sleep
していました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0418/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10278


File: python.info,  Node: types<7>,  Next: unittest<10>,  Prev: time<8>,  Up: 改良されたモジュール<9>

1.11.20.59 types
................

新規クラス *note types.MappingProxyType: 43a. の追加: 読み出し専用のマッ
ピングのプロキシです。 (bpo-14386(1))

新規関数 *note types.new_class(): 1134. と *note types.prepare_class():
1135. は PEP 3115(2) 準拠の動的な型の生成サポートを提供します。
(bpo-14588(3))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14386

   (2) https://peps.python.org/pep-3115/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=14588


File: python.info,  Node: unittest<10>,  Next: urllib<4>,  Prev: types<7>,  Up: 改良されたモジュール<9>

1.11.20.60 unittest
...................

メソッド *note assertRaises(): 4f6, *note assertRaisesRegex(): 4f8,
*note assertWarns(): 1137, *note assertWarnsRegex(): 1138. が、コンテキ
ストマネージャとして使われる際にキーワード引数 'msg' を受け付けるように
なりました。 (Contributed by Ezio Melotti and Winston Ewert in
bpo-10775(1).)

*note unittest.TestCase.run(): 1139. が *note TestResult: 113a. オブジェ
クトを返すようになりました。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10775


File: python.info,  Node: urllib<4>,  Next: webbrowser<3>,  Prev: unittest<10>,  Up: 改良されたモジュール<9>

1.11.20.61 urllib
.................

*note Request: fa5. クラスが *note get_method(): 113c. で使われる
'method' 引数を受け付けるようになりました。これはどの HTTP メソッドが使
われるべきかを指定します。例えば以下は ‘'HEAD'’ リクエストを送信します:

     >>> urlopen(Request('https://www.python.org', method='HEAD'))

(bpo-1673007(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1673007


File: python.info,  Node: webbrowser<3>,  Next: xml etree ElementTree<2>,  Prev: urllib<4>,  Up: 改良されたモジュール<9>

1.11.20.62 webbrowser
.....................

*note webbrowser: fd. モジュールがさらに多くの "browsers" をサポートしま
した: Google Chrome (バージョンと OS 依存で名前が ‘chrome’, ‘chromium’,
‘chrome-browser’, あるいは ‘chromium-browser’) と、汎用のランチャ
‘xdg-open’ (FreeDesktop.org プロジェクトのもの) と ‘gvfs-open’ (GNOME 3
のデフォルト URI ハンドラ)。 (The former contributed by Arnaud Calmettes
in bpo-13620(1), the latter by Matthias Klose in bpo-14493(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13620

   (2) https://bugs.python.org/issue?@action=redirect&bpo=14493


File: python.info,  Node: xml etree ElementTree<2>,  Next: zlib<2>,  Prev: webbrowser<3>,  Up: 改良されたモジュール<9>

1.11.20.63 xml.etree.ElementTree
................................

*note xml.etree.ElementTree: 10c. モジュールはデフォルトで C 実装による
高速版をインポートするようになりました; もう明示的に
‘xml.etree.cElementTree’ をインポートする必要はありません (cElementTree
モジュールは後方互換のために残されますが非推奨となりました)。また、
*note Element: 2e8. クラスの ‘iter’ 系のメソッドに最適化が施されました
(C で再実装されました)。また、このモジュールのドキュメントは大幅に改善さ
れて、実例が追加され、さらに詳細なリファレンスになりました。


File: python.info,  Node: zlib<2>,  Prev: xml etree ElementTree<2>,  Up: 改良されたモジュール<9>

1.11.20.64 zlib
...............

New attribute *note zlib.Decompress.eof: 1140. makes it possible to
distinguish between a properly formed compressed stream and an
incomplete or truncated one.  (Contributed by Nadeem Vawda in
bpo-12646(1).)

New attribute *note zlib.ZLIB_RUNTIME_VERSION: 1141. reports the version
string of the underlying ‘zlib’ library that is loaded at runtime.
(Contributed by Torsten Landschoff in bpo-12306(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12646

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12306


File: python.info,  Node: 最適化<8>,  Next: ビルドならびに C API の変更<4>,  Prev: 改良されたモジュール<9>,  Up: What's New In Python 3 3

1.11.21 最適化
--------------

大きな性能向上がありました:

   * PEP 393(1) により、Unicode 文字列に対する操作が最適化されました:

        * メモリフットプリントはテキストに依存して 1/2 から 1/4 になりま
          した

        * ASCII 文字列を UTF-8 にエンコードするのに文字をエンコードする
          必要はなくなりました、UTF-8 表現は ASCII 表現と共有されます

        * UTF-8 エンコーダが最適化されました

        * 単一の ASCII 文字を繰り返して ASCII 文字列の部分列を得るのは 4
          倍速くなりました

   * UTF-8 が2倍から4倍速くなりました。UTF-16 のエンコーディングが最大で
     10倍速くなりました。

     (Contributed by Serhiy Storchaka, bpo-14624(2), bpo-14738(3) and
     bpo-15026(4).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=14624

   (3) https://bugs.python.org/issue?@action=redirect&bpo=14738

   (4) https://bugs.python.org/issue?@action=redirect&bpo=15026


File: python.info,  Node: ビルドならびに C API の変更<4>,  Next: 非推奨<10>,  Prev: 最適化<8>,  Up: What's New In Python 3 3

1.11.22 ビルドならびに C API の変更
-----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * 新しい PEP 3118(1) 関連の関数:

        * *note PyMemoryView_FromMemory(): 1143.

   * PEP 393(2) により追加された新たな Unicode 型、マクロ、関数:

        * 高水準 API:

             * *note PyUnicode_CopyCharacters(): 883.

             * *note PyUnicode_FindChar(): 887.

             * *note PyUnicode_GetLength(): 881, *note
               PyUnicode_GET_LENGTH: 882.

             * *note PyUnicode_New(): 879.

             * *note PyUnicode_Substring(): 884.

             * *note PyUnicode_ReadChar(): 1144, *note
               PyUnicode_WriteChar(): 1145.

        * 低水準 API:

             * 型 *note Py_UCS1: 1146, *note Py_UCS2: 1147, *note
               Py_UCS4: 27b.

             * 構造体 *note PyASCIIObject: 1148. と *note
               PyCompactUnicodeObject: 1149.

             * *note PyUnicode_READY: 3da.

             * *note PyUnicode_FromKindAndData(): 114a.

             * *note PyUnicode_AsUCS4(): 114b, *note
               PyUnicode_AsUCS4Copy(): 889.

             * *note PyUnicode_DATA: 114c, *note PyUnicode_1BYTE_DATA:
               114d, *note PyUnicode_2BYTE_DATA: 114e, *note
               PyUnicode_4BYTE_DATA: 114f.

             * *note PyUnicode_KIND: 1150. with ‘PyUnicode_Kind’ enum:
               ‘PyUnicode_WCHAR_KIND’, *note PyUnicode_1BYTE_KIND: 1151,
               *note PyUnicode_2BYTE_KIND: 1152, *note
               PyUnicode_4BYTE_KIND: 1153.

             * *note PyUnicode_READ: 1154, *note PyUnicode_READ_CHAR:
               1155, *note PyUnicode_WRITE: 1156.

             * *note PyUnicode_MAX_CHAR_VALUE: 1157.

   * *note PyArg_ParseTuple: 53d. が ‘c’ フォーマットとして *note
     bytearray: 508. を許容するようになりました (bpo-12380(3))。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3118/

   (2) https://peps.python.org/pep-0393/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12380


File: python.info,  Node: 非推奨<10>,  Next: Python 3 3 への移植,  Prev: ビルドならびに C API の変更<4>,  Up: What's New In Python 3 3

1.11.23 非推奨
--------------

* Menu:

* サポートされないオペレーティングシステム: サポートされないオペレーティングシステム<2>.
* 非推奨の Python モジュール、関数、メソッド: 非推奨の Python モジュール、関数、メソッド<4>.
* C API の非推奨の関数ならびに型: C API の非推奨の関数ならびに型<3>.
* 非推奨の機能: 非推奨の機能<2>.


File: python.info,  Node: サポートされないオペレーティングシステム<2>,  Next: 非推奨の Python モジュール、関数、メソッド<4>,  Up: 非推奨<10>

1.11.23.1 サポートされないオペレーティングシステム
..................................................

保守する者がいないため OS/2 ならびに VMS はもはやサポートされません。

保守の負担のため WIndows 2000 および ‘COMSPEC’ を ‘command.com’ に設定し
ている Windows プラットフォームはもはやサポートされません。

3.2 で非推奨だった OSF のサポートが完全に削除されました。


File: python.info,  Node: 非推奨の Python モジュール、関数、メソッド<4>,  Next: C API の非推奨の関数ならびに型<3>,  Prev: サポートされないオペレーティングシステム<2>,  Up: 非推奨<10>

1.11.23.2 非推奨の Python モジュール、関数、メソッド
....................................................

   * object 型そのものの ‘object.__format__()’ に空でない文字列が渡すこ
     とは非推奨となりました。Python 3.4 ではこれは *note TypeError: 502.
     となります (bpo-9856(1))。

   * PEP 393(2) により、 ‘unicode_internal’ コーデックは非推奨となりまし
     た。UTF-8, UTF-16 (‘utf-16-le’ または ‘utf-16-be’), あるいは UTF-32
     (‘utf-32-le’ または ‘utf-32-be’) を使ってください。

   * *note ftplib.FTP.nlst(): 1096. および *note ftplib.FTP.dir():
     1097.: *note ftplib.FTP.mlsd(): 1095. を使ってください

   * ‘platform.popen()’: *note subprocess: c1. モジュールを使ってくださ
     い。 *note 古い関数を subprocess モジュールで置き換える: 115b. を是
     非お読みください (bpo-11377(3))。

   * bpo-13374(4): *note os: 91. モジュールにある Windows のバイト列 API
     は非推奨となりました。ANSI コードページに依存しないようにしてあらゆ
     るファイル名をサポートするために、バイト列文字列のファイル名ではな
     く Unicode ファイル名を使ってください。

   * bpo-13988(5): ‘xml.etree.cElementTree’ モジュールは非推奨です。利用
     できる際はいつでも自動的にアクセラレータを使用します。

   * ‘time.clock()’ の振る舞いがプラットフォーム依存のため、今後は要件に
     応じて新たに追加された *note time.perf_counter(): a56. または *note
     time.process_time(): a57. を使ってください。これらの振る舞いは良く
     定義されています(well defined)。

   * ‘os.stat_float_times()’ 関数は非推奨です。

   * *note abc: 4. モジュール:

        * *note abc.abstractproperty: 105a. は非推奨となりました。代わり
          に *note abc.abstractmethod(): 105b. に *note property: 179. を
          渡して使ってください。

        * *note abc.abstractclassmethod: 105c. は非推奨となりました。代
          わりに *note abc.abstractmethod(): 105b. に *note classmethod:
          14c. を渡して使ってください。

        * *note abc.abstractstaticmethod: 105d. は非推奨となりました。代
          わりに *note abc.abstractmethod(): 105b. に *note
          staticmethod: 3ef. を渡して使ってください。

   * *note importlib: 6b. パッケージ:

        * バイトコードファイルとしての *note
          importlib.abc.SourceLoader.path_stats(): 115c. によりコンパイ
          ル時点の修正時刻とソースファイルサイズの両方を格納するようにな
          ったので、 *note importlib.abc.SourceLoader.path_mtime():
          115d. は非推奨となりました。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9856

   (2) https://peps.python.org/pep-0393/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=11377

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13374

   (5) https://bugs.python.org/issue?@action=redirect&bpo=13988


File: python.info,  Node: C API の非推奨の関数ならびに型<3>,  Next: 非推奨の機能<2>,  Prev: 非推奨の Python モジュール、関数、メソッド<4>,  Up: 非推奨<10>

1.11.23.3 C API の非推奨の関数ならびに型
........................................

PEP 393(1) で *note Py_UNICODE: 3c7. は非推奨になり、Python 4 で削除され
ます。この型を使用している全ての関数は非推奨です。

Unicode functions and methods using *note Py_UNICODE: 3c7. and *note
Py_UNICODE: 3c7.* types:

   * ‘PyUnicode_FromUnicode’: use *note PyUnicode_FromWideChar(): 115f.
     or *note PyUnicode_FromKindAndData(): 114a.

   * ‘PyUnicode_AS_UNICODE’, ‘PyUnicode_AsUnicode()’,
     ‘PyUnicode_AsUnicodeAndSize()’: use *note
     PyUnicode_AsWideCharString(): 88a.

   * ‘PyUnicode_AS_DATA’: use *note PyUnicode_DATA: 114c. with *note
     PyUnicode_READ: 1154. and *note PyUnicode_WRITE: 1156.

   * ‘PyUnicode_GET_SIZE’, ‘PyUnicode_GetSize()’: use *note
     PyUnicode_GET_LENGTH: 882. or *note PyUnicode_GetLength(): 881.

   * ‘PyUnicode_GET_DATA_SIZE’: use ‘PyUnicode_GET_LENGTH(str) *
     PyUnicode_KIND(str)’ (only work on ready strings)

   * ‘PyUnicode_AsUnicodeCopy()’: use *note PyUnicode_AsUCS4Copy(): 889.
     or *note PyUnicode_AsWideCharString(): 88a.

   * ‘PyUnicode_GetMax()’

Py_UNICODE* 文字列を操作する関数ならびにマクロ:

   * ‘Py_UNICODE_strlen()’: use *note PyUnicode_GetLength(): 881. or
     *note PyUnicode_GET_LENGTH: 882.

   * ‘Py_UNICODE_strcat()’: use *note PyUnicode_CopyCharacters(): 883.
     or *note PyUnicode_FromFormat(): 363.

   * ‘Py_UNICODE_strcpy()’, ‘Py_UNICODE_strncpy()’, ‘Py_UNICODE_COPY()’:
     use *note PyUnicode_CopyCharacters(): 883. or *note
     PyUnicode_Substring(): 884.

   * ‘Py_UNICODE_strcmp()’: use *note PyUnicode_Compare(): 885.

   * ‘Py_UNICODE_strncmp()’: use *note PyUnicode_Tailmatch(): 886.

   * ‘Py_UNICODE_strchr()’, ‘Py_UNICODE_strrchr()’: use *note
     PyUnicode_FindChar(): 887.

   * ‘Py_UNICODE_FILL()’: use *note PyUnicode_Fill(): 1160.

   * ‘Py_UNICODE_MATCH’

エンコーダ:

   * ‘PyUnicode_Encode()’: use ‘PyUnicode_AsEncodedObject()’

   * ‘PyUnicode_EncodeUTF7()’

   * ‘PyUnicode_EncodeUTF8()’: use *note PyUnicode_AsUTF8(): b89. or
     *note PyUnicode_AsUTF8String(): 1161.

   * ‘PyUnicode_EncodeUTF32()’

   * ‘PyUnicode_EncodeUTF16()’

   * ‘PyUnicode_EncodeUnicodeEscape()’ use *note
     PyUnicode_AsUnicodeEscapeString(): 1162.

   * ‘PyUnicode_EncodeRawUnicodeEscape()’ use *note
     PyUnicode_AsRawUnicodeEscapeString(): 1163.

   * ‘PyUnicode_EncodeLatin1()’: use *note PyUnicode_AsLatin1String():
     1164.

   * ‘PyUnicode_EncodeASCII()’: use *note PyUnicode_AsASCIIString():
     1165.

   * ‘PyUnicode_EncodeCharmap()’

   * ‘PyUnicode_TranslateCharmap()’

   * ‘PyUnicode_EncodeMBCS()’: use *note PyUnicode_AsMBCSString(): 1166.
     or *note PyUnicode_EncodeCodePage(): 1167. (with ‘CP_ACP’
     code_page)

   * ‘PyUnicode_EncodeDecimal()’, ‘PyUnicode_TransformDecimalToASCII()’

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/


File: python.info,  Node: 非推奨の機能<2>,  Prev: C API の非推奨の関数ならびに型<3>,  Up: 非推奨<10>

1.11.23.4 非推奨の機能
......................

*note array: 6. モジュールの ‘'u'’ 書式化コードは非推奨となりました。
Python 4 ではほかの (*note Py_UNICODE: 3c7.) API と一緒に削除されるでし
ょう。


File: python.info,  Node: Python 3 3 への移植,  Prev: 非推奨<10>,  Up: What's New In Python 3 3

1.11.24 Python 3.3 への移植
---------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

* Menu:

* Python コードの移植::
* C コードの移植::
* C 拡張のビルド::
* コマンドラインスイッチの変更::


File: python.info,  Node: Python コードの移植,  Next: C コードの移植,  Up: Python 3 3 への移植

1.11.24.1 Python コードの移植
.............................

   * ハッシュのランダム化がデフォルトで有効になりました。これを無効にす
     るには環境変数 *note PYTHONHASHSEED: 1052. を ‘0’ にセットして下さ
     い。 *note object.__hash__(): ac9. メソッドも参照して下さい。

   * bpo-12326(1): Linux では、 *note sys.platform: a5b. はもはやメジャ
     ーバージョン番号を含みません。 これは今では常に 'linux' です。以前
     はこれは Python のビルドに使われた Linux バージョンに依存した
     ‘'linux2'’ や ‘'linux3'’ でした。 ‘sys.platform == 'linux2'’ などと
     するのではなく、 ‘sys.platform.startswith('linux')’ とするか、古い
     Python バージョンのサポートが不要であれば直接的に ‘sys.platform ==
     'linux'’ として下さい。

   * bpo-13847(2), bpo-14180(3): *note time: d7. および *note datetime:
     28.: タイムスタンプが範囲外の場合に、 *note ValueError: 1e3. ではな
     く *note OverflowError: 84e. を送出するようになりました。また、C 関
     数の ‘gmtime()’ あるいは ‘localtime()’ が失敗した場合には *note
     OSError: 3f0. を送出するようになりました。

   * インポートで使われるデフォルトのファインダが、特定のディレクトリに
     何が含まれるのかについてのキャッシュを利用するようになっています。
     実行中に Python ソースファイルやバイトコードファイルを作ったら、キ
     ャッシュをクリアしてファインダが新しく作られたファイルに気付けるよ
     うに、 *note importlib.invalidate_caches(): bde. を呼ぶ必要があるこ
     とに注意してください。

   * *note ImportError: 3f2. がインポートを試みたモジュール名として完全
     名を使うようになっています。ImportError のメッセージをチェックする
     doctest は、モジュール名をその末尾の名前ではなく完全な名前を使うよ
     うに更新する必要があります。

   * *note __import__(): 8a2. の引数 'index' のデフォルトが -1 ではなく
     0 となり、また、もはや負の値はサポートされません。デフォルト値が -1
     で残されたのは(訳注: つまり絶対、相対インポートの両方を試みるように
     したのは) PEP 328(4) を実装した際の過失でした。絶対インポートに先立
     って相対インポートを実行する振る舞いがまだ必要なのであれば、index を
     1 にして相対インポートを実行して、その後で index 0 のインポートをす
     るようにしてください。そうなのですが、 *note __import__(): 8a2. を
     直接呼び出すのではなく、 *note importlib.import_module(): 4e1. を使
     うことが望ましいやり方です。

   * *note __import__(): 8a2. の index に、トップレベルモジュールに対し
     て 0 でなく 1 を与えることは今では許されません。例えば
     ‘__import__('sys', level=1)’ はエラーです。

   * Because *note sys.meta_path: cf9. and *note sys.path_hooks: fee.
     now have finders on them by default, you will most likely want to
     use ‘list.insert()’ instead of ‘list.append()’ to add to those
     lists.

   * Because ‘None’ is now inserted into *note sys.path_importer_cache:
     5ae, if you are clearing out entries in the dictionary of paths
     that do not have a finder, you will need to remove keys paired with
     values of ‘None’ 'and' ‘imp.NullImporter’ to be
     backwards-compatible.  This will lead to extra overhead on older
     versions of Python that re-insert ‘None’ into *note
     sys.path_importer_cache: 5ae. where it represents the use of
     implicit finders, but semantically it should not change anything.

   * ‘importlib.abc.Finder’ no longer specifies a ‘find_module()’
     abstract method that must be implemented.  If you were relying on
     subclasses to implement that method, make sure to check for the
     method's existence first.  You will probably want to check for
     ‘find_loader()’ first, though, in the case of working with *note
     path entry finders: 1046.

   * *note pkgutil: 97. は、内部的に *note importlib: 6b. を使うように変
     更されました。このことは、 PEP 302(5) インポートエミュレーションの
     古い振る舞いが本物のインポートシステムの振る舞いに合わせるのに失敗
     していた数多くの特殊ケースの問題を取り除きます。インポートエミュレ
     ーションそのものはまだ存在しますが、今では非推奨です。 *note
     pkgutil.iter_importers(): 116b. 関数と *note
     pkgutil.walk_packages(): bcd. 関数は標準インポートフックを特別に扱
     うので、ファインダの ‘iter_modules()’ メソッドは標準ではないにも関
     わらず、まだサポートされます。

   * *note email.header.decode_header(): 108a. によってなされる解析に長
     い間存在していた RFC 非準拠のバグ (bpo-1079(6)) が修正されました。
     エンコードされたヘッダを Unicode に変換するための標準的なイディオム
     (‘str(make_header(decode_header(h))’) を使うコードからは変化はみえ
     ません。ですが、 decode_header から返される個々のタプル要素を見てい
     るコードでは、 ‘ASCII’ セクションの前後の空白が ‘ASCII’ 内に含まれ
     るようになったことがわかります。 ‘make_header’ は入力文字列に既に存
     在していなければ ‘ASCII’ 非 ‘ASCII’ セクション間に以前と同じく空白
     を追加するので、 ‘make_header’ を使ってヘッダを構築するコードは変更
     なしで動作するはずです。

   * *note email.utils.formataddr(): 116c. は非 ASCII の display name に
     対し正しい content transfer encoding の扱いをするようになっています
     。かつての、フォーマット後文字列内に非 ASCII Unicode を維持してしま
     う誤った振る舞いに依存するすべてのコードは、変更の必要があります。
     (bpo-1690608(7))

   * *note poplib.POP3.quit(): 116d. メソッドもほかの全ての ‘poplib’ の
     メソッドと同じく、今ではプロトコルエラーを送出し得ます。 ‘quit’ が
     *note poplib.error_proto: 116e. エラーを送出しないことをあてにして
     いたコードは、 ‘quit’ でのエラーが特定のアプリケーションにとって問
     題となるようであれば、修正の必要があるかもしれません
     (bpo-11291(8))。

   * Python 2.4 から非推奨となっていた、 *note email.parser.Parser:
     116f. への ‘strict’ 引数はついに削除されました。

   * 非推奨となっていたメソッド ‘unittest.TestCase.assertSameElements’ は
     削除されました。

   * 非推奨となっていた変数 ‘time.accept2dyear’ は削除されました。

   * 非推奨となっていた ‘Context._clamp’ 属性が *note decimal: 2e. モジ
     ュールから削除されました。以前に既にこれは公開属性 ‘clamp’ に置き換
     えられていました (bpo-8540(9) 参照)。

   * 文書化されていなかった内部ヘルパクラス ‘SSLFakeFile’ が *note
     smtplib: b7. モジュールより削除されました。この機能はずっと以前から
     *note socket.socket.makefile(): 1170. によって直接的に提供されてい
     ます。

   * Windows では *note time.sleep(): 669. に負値を与えた場合に無限に眠
     っていましたが、今ではこれは例外を送出します。POSIX ではこれは以前
     より常に例外です。

   * The ‘ast.__version__’ constant has been removed.  If you need to
     make decisions affected by the AST version, use *note
     sys.version_info: 66c. to make the decision.

   * *note threading: d6. モジュールの、非公開クラスをサブクラス化するフ
     ァクトリ関数を迂回していたコードは、今では公開クラスになったので修
     正の必要があります。

   * threading モジュール内の文書化されていなかったデバッグ機構を削除し
     てコードを単純化しました。このことが製品コードに影響することがあっ
     てはなりませんが、これと連携していたアプリケーションデバッグフレー
     ムワークのケースがありうるので、言及しておきます (bpo-13550(10))。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=12326

   (2) https://bugs.python.org/issue?@action=redirect&bpo=13847

   (3) https://bugs.python.org/issue?@action=redirect&bpo=14180

   (4) https://peps.python.org/pep-0328/

   (5) https://peps.python.org/pep-0302/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1079

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1690608

   (8) https://bugs.python.org/issue?@action=redirect&bpo=11291

   (9) https://bugs.python.org/issue?@action=redirect&bpo=8540

   (10) https://bugs.python.org/issue?@action=redirect&bpo=13550


File: python.info,  Node: C コードの移植,  Next: C 拡張のビルド,  Prev: Python コードの移植,  Up: Python 3 3 への移植

1.11.24.2 C コードの移植
........................

   * In the course of changes to the buffer API the undocumented
     ‘smalltable’ member of the *note Py_buffer: 723. structure has been
     removed and the layout of the ‘PyMemoryViewObject’ has changed.

     ‘memoryobject.h’ あるいは ‘object.h’ での関係する部分に依存する全て
     の拡張は、再ビルドが必要です。

   * *note PEP 393: 1007. により、 *note Py_UNICODE: 3c7. 型とこの型を使
     う全ての関数は非推奨となりました (ただし最低 5 年は利用可能なまま保
     たれます)。Unicode オブジェクトの構築とアクセスに低水準 Unicode API
     をこれまで使っていて、 PEP 393(1) によって提供されるメモリフットプ
     リント削減の恩恵を受けたければ、新しい *note Unicode API: 1171. に
     乗り換える必要があります。

     一方で *note PyUnicode_Concat(): 1172. 、 *note PyUnicode_Join():
     1173. あるいは *note PyUnicode_FromFormat(): 363. といった高水準関
     数のみを使ってきたのであれば、あなたのコードは自動的に新しい
     Unicode 表現に便乗できます。

   * *note PyImport_GetMagicNumber(): 1174. は失敗時に ‘-1’ を返すように
     なりました。

   * *note __import__(): 8a2. の 'level' 引数に負値を渡すことはもはや有
     効ではないので、対応する *note PyImport_ImportModuleLevel(): 1175.
     でも同じです。このことは *note PyImport_ImportModuleEx(): 1176. に
     使われる 'level' の値が ‘-1’ ではなく ‘0’ を使うようになったことも
     意味しています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/


File: python.info,  Node: C 拡張のビルド,  Next: コマンドラインスイッチの変更,  Prev: C コードの移植,  Up: Python 3 3 への移植

1.11.24.3 C 拡張のビルド
........................

   * C 拡張のファイル名として認められる範囲が狭められました。滅多に使わ
     れてこなかった命名は取りやめられました: POSIX では、
     ‘xxxmodule.so’, ‘xxxmodule.abi3.so’, ‘xxxmodule.cpython-*.so’ 命名
     は今後 ‘xxx’ モジュールの実装とは認識されません。これまでそのような
     ファイルを作ってきたのであれば、別の命名に乗り換えてください (つま
     り ‘module’ 文字列をファイル名から取り除いてください)。

     (implemented in bpo-14040(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14040


File: python.info,  Node: コマンドラインスイッチの変更,  Prev: C 拡張のビルド,  Up: Python 3 3 への移植

1.11.24.4 コマンドラインスイッチの変更
......................................

   * ‘-Q’ コマンドラインスイッチとそれに関係するものは削除されました。
     ‘sys.flags.division_warning’ をチェックしているコードは修正する必要
     があります。

     (bpo-10998(1), contributed by Éric Araujo.)

   * *note -S: 1179. スイッチ付きで ‘python’ を開始すると、 ‘import
     site’ がモジュール検索パスにサイト固有のパスを追加しなくなります。
     以前のバージョンではそれをしていました。

     (bpo-11591(2), contributed by Carl Meyer with editions by Éric
     Araujo.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10998

   (2) https://bugs.python.org/issue?@action=redirect&bpo=11591


File: python.info,  Node: What's New In Python 3 2,  Next: What's New In Python 3 1,  Prev: What's New In Python 3 3,  Up: What's New in Python

1.12 What's New In Python 3.2
=============================


著者: Raymond Hettinger

This article explains the new features in Python 3.2 as compared to 3.1.
Python 3.2 was released on February 20, 2011.  It focuses on a few
highlights and gives a few examples.  For full details, see the
Misc/NEWS(1) file.

参考
....

PEP 392(2) - Python 3.2 リリーススケジュール

* Menu:

* PEP 384; 安定 ABI の定義: PEP 384 安定 ABI の定義.
* PEP 389; argparse コマンドライン解析モジュール: PEP 389 argparse コマンドライン解析モジュール.
* PEP 391; logging の辞書ベースの設定: PEP 391 logging の辞書ベースの設定.
* PEP 3148; concurrent.futures モジュール: PEP 3148 concurrent futures モジュール.
* PEP 3147; PYC リポジトリーディレクトリ: PEP 3147 PYC リポジトリーディレクトリ.
* PEP 3149; ABI バージョンでタグ付けされた .so ファイル: PEP 3149 ABI バージョンでタグ付けされた so ファイル.
* PEP 3333; Python Web Server Gateway Interface v1.0.1: PEP 3333 Python Web Server Gateway Interface v1 0 1.
* その他の言語変更: その他の言語変更<10>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール::
* マルチスレッディング::
* 最適化: 最適化<9>.
* Unicode 文字列型::
* Codecs::
* ドキュメント::
* IDLE::
* コードリポジトリ::
* ビルドならびに C API の変更: ビルドならびに C API の変更<5>.
* Python 3.2 への移植: Python 3 2 への移植.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/blob/076ca6c3c8df3030307e548d9be792ce3c1c6eea/Misc/NEWS

   (2) https://peps.python.org/pep-0392/


File: python.info,  Node: PEP 384 安定 ABI の定義,  Next: PEP 389 argparse コマンドライン解析モジュール,  Up: What's New In Python 3 2

1.12.1 PEP 384: 安定 ABI の定義
-------------------------------

かつて、ある Python バージョンでビルドされた拡張モジュールは、ほかの
Python バージョンでは使えないことがありました。特に Windows では、全ての
Python 公式リリースごとに、使いたい全ての拡張モジュールを再ビルドする必
要がありました。これは、拡張モジュールが Python インタプリタの内部実装に
自由にアクセス出来たことからの結果でした。

Python 3.2 より、このことに関する別のアプローチが利用可能になりました。
(*note Py_LIMITED_API: 3f7. を定義することで) 制限された API のみ使うよ
うにする拡張モジュールは、数多くの内部実装を利用出来ない代わりに将来のい
くつものリリースで安定であることを約束された API 集合だけ使うことになり
ます。結果として、このモードで 3.2 のためにビルドされた拡張モジュールは
3.3、3.4、…でも動作するでしょう。なお、メモリ構造の詳細を曝すような拡張
モジュールでは、相変わらず全ての Python 公式リリースごとに再ビルドする必
要があるでしょう。

参考
....

PEP 384(1) - 安定 ABI の定義

     PEP written by Martin von Löwis.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0384/


File: python.info,  Node: PEP 389 argparse コマンドライン解析モジュール,  Next: PEP 391 logging の辞書ベースの設定,  Prev: PEP 384 安定 ABI の定義,  Up: What's New In Python 3 2

1.12.2 PEP 389: argparse コマンドライン解析モジュール
-----------------------------------------------------

コマンドライン解析のために、新たに *note argparse: 5. モジュールが *note
optparse: 90. の制限を克服するものとして導入されました。optparse には (オ
プションだけでなく) 位置引数のサポートはなく、サブコマンドも作れず、必須
のオプションやその他オプション指定と検証に共通するパターンについてのサポ
ートもありませんでした。

このモジュールはコミュニティにおいて既に広く行き渡っていたサードパーティ
のモジュールでした。その先駆者たちよりももっと完全な機能性を持ったことで
、 *note argparse: 5. モジュールは今ではコマンドライン解析での推奨モジュ
ールとなりました。古いモジュールは、それに依存しているレガシーなコードが
大量にあるため、今後も利用可能なまま保たれます。

以下に注釈付きで示したパーサは、有限個の選択肢から選ばせ、 'metavar' で
ヘルプ表示を指定し、一つ以上の位置引数があるかを検証し、必須オプションを
設けている実例になっています:

     import argparse
     parser = argparse.ArgumentParser(
                 description = 'Manage servers',         # main description for help
                 epilog = 'Tested on Solaris and Linux') # displayed after help
     parser.add_argument('action',                       # argument name
                 choices = ['deploy', 'start', 'stop'],  # three allowed values
                 help = 'action on each target')         # help msg
     parser.add_argument('targets',
                 metavar = 'HOSTNAME',                   # var name used in help msg
                 nargs = '+',                            # require one or more targets
                 help = 'url for target machines')       # help msg explanation
     parser.add_argument('-u', '--user',                 # -u or --user option
                 required = True,                        # make it a required argument
                 help = 'login as user')

コマンド文字列とともにこのパーサを呼び出してみます:

     >>> cmd = 'deploy sneezy.example.com sleepy.example.com -u skycaptain'
     >>> result = parser.parse_args(cmd.split())
     >>> result.action
     'deploy'
     >>> result.targets
     ['sneezy.example.com', 'sleepy.example.com']
     >>> result.user
     'skycaptain'

このパーサが自動的に作り出したヘルプはこのようになります:

     >>> parser.parse_args('-h'.split())

     usage: manage_cloud.py [-h] -u USER
                            {deploy,start,stop} HOSTNAME [HOSTNAME ...]

     Manage servers

     positional arguments:
       {deploy,start,stop}   action on each target
       HOSTNAME              url for target machines

     optional arguments:
       -h, --help            show this help message and exit
       -u USER, --user USER  login as user

     Tested on Solaris and Linux

*note argparse: 5. 機能でとりわけ素晴らしいのはサブパーサを定義出来るこ
とです。それらはそれぞれ自身固有の引数パターンを持ち、ヘルプ表示をします
:

     import argparse
     parser = argparse.ArgumentParser(prog='HELM')
     subparsers = parser.add_subparsers()

     parser_l = subparsers.add_parser('launch', help='Launch Control')   # first subgroup
     parser_l.add_argument('-m', '--missiles', action='store_true')
     parser_l.add_argument('-t', '--torpedos', action='store_true')

     parser_m = subparsers.add_parser('move', help='Move Vessel',        # second subgroup
                                      aliases=('steer', 'turn'))         # equivalent names
     parser_m.add_argument('-c', '--course', type=int, required=True)
     parser_m.add_argument('-s', '--speed', type=int, default=0)

     $ ./helm.py --help                         # top level help (launch and move)
     $ ./helm.py launch --help                  # help for launch options
     $ ./helm.py launch --missiles              # set missiles=True and torpedos=False
     $ ./helm.py steer --course 180 --speed 5   # set movement parameters

参考
....

PEP 389(1) - 新しいコマンドライン解析モジュール

     PEP written by Steven Bethard.

*note Upgrading optparse code: 117e. に *note optparse: 90. との違いが詳
しく書かれています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0389/


File: python.info,  Node: PEP 391 logging の辞書ベースの設定,  Next: PEP 3148 concurrent futures モジュール,  Prev: PEP 389 argparse コマンドライン解析モジュール,  Up: What's New In Python 3 2

1.12.3 PEP 391: logging の辞書ベースの設定
------------------------------------------

The *note logging: 7b. module provided two kinds of configuration, one
style with function calls for each option or another style driven by an
external file saved in a *note configparser: 1b. format.  Those options
did not provide the flexibility to create configurations from JSON or
YAML files, nor did they support incremental configuration, which is
needed for specifying logger options from a command line.

もっと柔軟な設定をサポートするために、新たに *note
logging.config.dictConfig(): 1180. が追加されました。これはロギングの設
定を通常の Python 辞書で指定します。設定オプションにはフォーマッタ、ハン
ドラ、フィルタ、そしてロガーが含まれます。以下は設定辞書の動作する実例で
す:

     {"version": 1,
      "formatters": {"brief": {"format": "%(levelname)-8s: %(name)-15s: %(message)s"},
                     "full": {"format": "%(asctime)s %(name)-15s %(levelname)-8s %(message)s"}
                     },
      "handlers": {"console": {
                        "class": "logging.StreamHandler",
                        "formatter": "brief",
                        "level": "INFO",
                        "stream": "ext://sys.stdout"},
                   "console_priority": {
                        "class": "logging.StreamHandler",
                        "formatter": "full",
                        "level": "ERROR",
                        "stream": "ext://sys.stderr"}
                   },
      "root": {"level": "DEBUG", "handlers": ["console", "console_priority"]}}

その辞書が ‘conf.json’ ファイルに格納されているのであれば、コードからこ
のように呼び出してロード出来ます:

     >>> import json, logging.config
     >>> with open('conf.json') as f:
     ...     conf = json.load(f)
     ...
     >>> logging.config.dictConfig(conf)
     >>> logging.info("Transaction completed normally")
     INFO    : root           : Transaction completed normally
     >>> logging.critical("Abnormal termination")
     2011-02-17 11:14:36,694 root            CRITICAL Abnormal termination

参考
....

PEP 391(1) - logging の辞書ベースの設定

     PEP written by Vinay Sajip.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0391/


File: python.info,  Node: PEP 3148 concurrent futures モジュール,  Next: PEP 3147 PYC リポジトリーディレクトリ,  Prev: PEP 391 logging の辞書ベースの設定,  Up: What's New In Python 3 2

1.12.4 PEP 3148: ‘concurrent.futures’ モジュール
------------------------------------------------

同時並行性 (concurrency) を生成・管理するコードはトップレベルの新しい名
前空間 'concurrent' に集められることになりました。その最初のメンバーが
'futures' パッケージです。これはスレッドとプロセス管理の統一的な高水準イ
ンターフェイスを提供します。

*note concurrent.futures: 1a. の設計は Java の 'java.util.concurrent' パ
ッケージに触発されました。そのモデルでは、実行する呼び出しとその結果は
*note Future: 1182. オブジェクトで表現され、これはスレッド、プロセス、遠
隔手続呼び出しの共通的な側面を抽象化しています。そのオブジェクトはステー
タスのチェック (実行中あるいは完了かどうか)、タイムアウト、キャンセル、
コールバックの追加、そして結果や例外へのアクセスをサポートします。

この新モジュールで提供される最も基本となるのが、呼び出しの実行と管理のた
めの 2 つの executor クラスです。これら executor の目標は、これまでにも
あった道具立てでの並列呼び出しを、もっと簡単にすることです。リソースプー
ルをお膳立てしたり呼び出しを実行したり、結果のキューを作ったり、あるいは
タイムアウトのハンドラを追加したり、スレッドやプロセスや遠隔手続呼び出し
の総数を制限したり、といったことを、これらを使えば、その労力を小さく出来
ます。

理想的にはそれぞれのアプリケーションは、プロセスとスレッドの制限が確実に
管理されるように、複数コンポーネントをまたがって単一の executor を共有す
べきです。そうしておけば、個々のコンポーネントがリソース管理についての競
合する戦略を持つ場合に起こる設計の難題は解決出来ます。

どちらの executor クラスとも 3 つのメソッドを持つ共通インターフェイスを
持ちます。 *note submit(): a50. メソッドは呼び出し可能オブジェクトをスケ
ジュールし、 *note Future: 1182. オブジェクトを返します。 *note map():
db1. メソッドは一気に複数の非同期呼び出しをスケジュールします。 *note
shutdown(): 8bb. メソッドはリソースを解放します。これらクラスは *note
context manager: 59e. なので *note with: 59c. 文とともに使うことが出来、
現時点で保留中の future が実行を終えた際にリソースが自動的に解放されるこ
とを保障出来ます。

以下はファイルコピーを行う 4 つの並列スレッドを実行する、 *note
ThreadPoolExecutor: 70d. の単純な使用例です:

     import concurrent.futures, shutil
     with concurrent.futures.ThreadPoolExecutor(max_workers=4) as e:
         e.submit(shutil.copy, 'src1.txt', 'dest1.txt')
         e.submit(shutil.copy, 'src2.txt', 'dest2.txt')
         e.submit(shutil.copy, 'src3.txt', 'dest3.txt')
         e.submit(shutil.copy, 'src3.txt', 'dest4.txt')

参考
....

PEP 3148(1) - Futures - 計算の非同期な実行

     PEP written by Brian Quinlan.

*note ThreadPoolExecutor の例: 1183. はスレッド並列でウェブページを取得
する実例コードです。

*note ProcessPoolExecutor: 8bc. の実例を *note
並列で素数計算するコード例: 1184. として挙げています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3148/


File: python.info,  Node: PEP 3147 PYC リポジトリーディレクトリ,  Next: PEP 3149 ABI バージョンでタグ付けされた so ファイル,  Prev: PEP 3148 concurrent futures モジュール,  Up: What's New In Python 3 2

1.12.5 PEP 3147: PYC リポジトリーディレクトリ
---------------------------------------------

バイトコードを '.pyc' ファイルとしてキャッシュする Python の方法は、複数
の Python インタプリタ環境ではうまく働きませんでした。一つのインタプリタ
がもう一つのインタプリタによって作られたキャッシュファイルに出会うと、そ
のインタプリタはソースを再コンパイルしてキャッシュファイルを上書きするわ
けですから、これではキャッシュの価値は台無しです。

「pyc ファイト」問題は、複数バージョンの Python を載せる Linux ディスト
リビューションにありふれたこととなったよりももっと表立って来ました。これ
ら衝突は Unladen Swallow(1) のような CPython 以外の実装でも起こります。

この問題を解決するために、Python のインポート機構はそれぞれのインタプリ
タごとに区別された名前を使うように拡張されました。Python 3.2、Python
3.3、 Unladen Swallow でそれぞれ競合するファイル名 "mymodule.pyc" を使う
のではなく、それぞれ "mymodule.cpython-32.pyc",
"mymodule.cpython-33.pyc", "mymodule.unladen10.pyc" を使うようになりまし
た。同時にこれらの新しいファイルがソースディレクトリを散らかすのを防ぐた
めに、 'pyc' ファイルはパッケージディレクトリの下の "__pycache__" ディレ
クトリに収集するようになりました。

ファイル名と格納先ディレクトリは別にして、この新方式にはプログラマ目線で
の目に見える変化が少しあります:

   * Imported modules now have a *note __cached__: 2b7. attribute which
     stores the name of the actual file that was imported:

          >>> import collections
          >>> collections.__cached__
          'c:/py32/lib/__pycache__/collections.cpython-32.pyc'

   * The tag that is unique to each interpreter is accessible from the
     ‘imp’ module:

          >>> import imp
          >>> imp.get_tag()
          'cpython-32'

   * Scripts that try to deduce source filename from the imported file
     now need to be smarter.  It is no longer sufficient to simply strip
     the "c" from a ".pyc" filename.  Instead, use the new functions in
     the ‘imp’ module:

          >>> imp.source_from_cache('c:/py32/lib/__pycache__/collections.cpython-32.pyc')
          'c:/py32/lib/collections.py'
          >>> imp.cache_from_source('c:/py32/lib/collections.py')
          'c:/py32/lib/__pycache__/collections.cpython-32.pyc'

   * *note py_compile: a1. と *note compileall: 19. モジュールはこの新命
     名規則とターゲットディレクトリを反映するよう更新されました。
     'compileall' のコマンドラインからの起動には新しいオプションが追加さ
     れました。 ‘-i’ はコンパイルするファイルとディレクトリのリストを指
     定します。 ‘-b’ はバイトコードファイルを '__pycache__' ではなく伝統
     的な場所に書き出します。

   * The *note importlib.abc: 6c. module has been updated with new *note
     abstract base classes: 1186. for loading bytecode files.  The
     obsolete ABCs, ‘PyLoader’ and ‘PyPycLoader’, have been deprecated
     (instructions on how to stay Python 3.1 compatible are included
     with the documentation).

参考
....

PEP 3147(2) - PYC リポジトリーディレクトリー

     PEP written by Barry Warsaw.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Unladen_Swallow#Project_activity

   (2) https://peps.python.org/pep-3147/


File: python.info,  Node: PEP 3149 ABI バージョンでタグ付けされた so ファイル,  Next: PEP 3333 Python Web Server Gateway Interface v1 0 1,  Prev: PEP 3147 PYC リポジトリーディレクトリ,  Up: What's New In Python 3 2

1.12.6 PEP 3149: ABI バージョンでタグ付けされた .so ファイル
------------------------------------------------------------

PYC レポジトリーディレクトリでは複数バイトコードのキャッシュファイルを共
存できます。この PEP は共有オブジェクトについての同じようなメカニズムを
実装します。それには共通のディレクトリを使い、個々のバージョンごとの名前
の区別をします。

共通ディレクトリは "pyshared" です。また、ファイル名は Python 実装 (例え
ば CPython、PyPy、Jython など)、メジャー・マイナーバージョン番号やオプシ
ョナルなビルドフラグ (例えばデバッグビルドでの "d"、 pymalloc ビルドの
"m"、ワイド幅 Unicode の "u") を特定することで区別するように命名されます
。任意のパッケージ "foo" について、配布パッケージがインストールされると
これらファイルは例えばこのような具合でしょう:

     /usr/share/pyshared/foo.cpython-32m.so
     /usr/share/pyshared/foo.cpython-33md.so

Python 自身からこのタグに、 *note sysconfig: c5. モジュールにある関数で
アクセス出来ます:

     >>> import sysconfig
     >>> sysconfig.get_config_var('SOABI')       # find the version tag
     'cpython-32mu'
     >>> sysconfig.get_config_var('EXT_SUFFIX')  # find the full filename extension
     '.cpython-32mu.so'

参考
....

PEP 3149(1) - ABI バージョンでタグ付けされた .so ファイル

     PEP written by Barry Warsaw.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3149/


File: python.info,  Node: PEP 3333 Python Web Server Gateway Interface v1 0 1,  Next: その他の言語変更<10>,  Prev: PEP 3149 ABI バージョンでタグ付けされた so ファイル,  Up: What's New In Python 3 2

1.12.7 PEP 3333: Python Web Server Gateway Interface v1.0.1
-----------------------------------------------------------

この情報 PEP は、 WSGI プロトコルによってどのようにバイト列/テキストの問
題が処理されるべきかを明確化しています。HTTP プロトコルそのものはバイト
列指向であっても、Python 3 にあってほとんど *note str: 418. 型で便利に文
字列処理出来るようにすることが挑戦でした。

この PEP では、リクエスト/レスポンスヘッダとメタデータに使われるいわゆる
'ネイティブ文字列(native strings)' と、リクエストとレスポンスのボディに
使われる 'バイト列文字列(byte strings)' を区別します。

The 'native strings' are always of type *note str: 418. but are
restricted to code points between 'U+0000' through 'U+00FF' which are
translatable to bytes using 'Latin-1' encoding.  These strings are used
for the keys and values in the environment dictionary and for response
headers and statuses in the ‘start_response()’ function.  They must
follow RFC 2616(1) with respect to encoding.  That is, they must either
be 'ISO-8859-1' characters or use RFC 2047(2) MIME encoding.

WSGI アプリケーションを Python 2 から移植する開発者は、とりわけ以下に注
意してください:

   * Python 2 でヘッダとしてネイティブ文字列を既に使っているアプリケーシ
     ョンは変更の必要はありません。(--訳注: 原文は「If the app already
     used strings for headers ...」。native strings としないと意味が通り
     ません。 --)

   * そうではなくアプリケーションが出力ヘッダをエンコードしていたり、入
     力ヘッダをデコードしていたのであれば、ヘッダは Latin-1 に再エンコー
     ドする必要があります。たとえば ‘h.encode('utf-8')’ により utf-8 で
     エンコードされた出力ヘッダは、バイト列からネイティブ文字列に
     ‘h.encode('utf-8').decode('latin-1')’ で変換する必要があります。
     (--訳注: この原文は h が元々 latin-1 で表現出来る文字セットであるこ
     とを暗黙で仮定しているようです。--)

   * Values yielded by an application or sent using the ‘write()’ method
     must be byte strings.  The ‘start_response()’ function and environ
     must use native strings.  The two cannot be mixed.

For server implementers writing CGI-to-WSGI pathways or other CGI-style
protocols, the users must to be able access the environment using native
strings even though the underlying platform may have a different
convention.  To bridge this gap, the *note wsgiref: 100. module has a
new function, *note wsgiref.handlers.read_environ(): 1189. for
transcoding CGI variables from *note os.environ: 118a. into native
strings and returning a new dictionary.

参考
....

PEP 3333(3) - Python Web Server Gateway Interface v1.0.1

     PEP written by Phillip Eby.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2616.html

   (2) https://datatracker.ietf.org/doc/html/rfc2047.html

   (3) https://peps.python.org/pep-3333/


File: python.info,  Node: その他の言語変更<10>,  Next: 新たなモジュール、改良されたモジュール、非推奨のモジュール,  Prev: PEP 3333 Python Web Server Gateway Interface v1 0 1,  Up: What's New In Python 3 2

1.12.8 その他の言語変更
-----------------------

Python 言語コアに小さな変更がいくつか行われました:

   * *note format(): 5eb. と *note str.format(): 5ed. のフォーマット文字
     '#' が拡張されました。以前から二進、八進、十六進整数に対して順にそ
     れぞれ '0b', '0o', '0x' を冠する出力をしていましたが、これは浮動小
     数点数、複素数、 Decimal に対しても処理するようになり、これはあとに
     続く桁がなくても必ず小数点を出力します。

          >>> format(20, '#o')
          '0o24'
          >>> format(12.34, '#5.0f')
          '  12.'

     (Suggested by Mark Dickinson and implemented by Eric Smith in
     bpo-7094(1).)

   * 新たに追加された *note str.format_map(): da4. メソッドも既存の
     *note str.format(): 5ed. メソッドの能力を拡大します。これは任意の
     *note mapping: 118c. を受け付けます。この新規メソッドは Python の数
     多くの「辞書的な」オブジェクトとともに文字列書式化を使うことを可能
     にします。たとえば *note defaultdict: 118d, *note Shelf: f67, *note
     ConfigParser: 1aa, あるいは *note dbm: 29. などで使えるということで
     す。カスタムな *note dict: 237. のサブクラスと一緒に使うのも便利で
     、例えばルックアップの前にキーを正規化してみたり、未知のキーを
     ‘__missing__()’ メソッドで補ってみたりなど出来ます:

          >>> import shelve
          >>> d = shelve.open('tmp.shl')
          >>> 'The {project_name} status is {status} as of {date}'.format_map(d)
          'The testing project status is green as of February 15, 2011'

          >>> class LowerCasedDict(dict):
          ...     def __getitem__(self, key):
          ...         return dict.__getitem__(self, key.lower())
          ...
          >>> lcd = LowerCasedDict(part='widgets', quantity=10)
          >>> 'There are {QUANTITY} {Part} in stock'.format_map(lcd)
          'There are 10 widgets in stock'

          >>> class PlaceholderDict(dict):
          ...     def __missing__(self, key):
          ...         return '<{}>'.format(key)
          ...
          >>> 'Hello {name}, welcome to {location}'.format_map(PlaceholderDict())
          'Hello <name>, welcome to <location>'

     (Suggested by Raymond Hettinger and implemented by Eric Smith in
     bpo-6081(2).)

   * The interpreter can now be started with a quiet option, ‘-q’, to
     prevent the copyright and version information from being displayed
     in the interactive mode.  The option can be introspected using the
     *note sys.flags: 658. attribute:

          $ python -q
          >>> sys.flags
          sys.flags(debug=0, division_warning=0, inspect=0, interactive=0,
          optimize=0, dont_write_bytecode=0, no_user_site=0, no_site=0,
          ignore_environment=0, verbose=0, bytes_warning=0, quiet=1)

     (Contributed by Marcin Wojdyr in bpo-1772833(3)).

   * The *note hasattr(): 49e. function works by calling *note
     getattr(): b9f. and detecting whether an exception is raised.  This
     technique allows it to detect methods created dynamically by *note
     __getattr__(): 49f. or *note __getattribute__(): ba0. which would
     otherwise be absent from the class dictionary.  Formerly, 'hasattr'
     would catch any exception, possibly masking genuine errors.  Now,
     'hasattr' has been tightened to only catch *note AttributeError:
     326. and let other exceptions pass through:

          >>> class A:
          ...     @property
          ...     def f(self):
          ...         return 1 // 0
          ...
          >>> a = A()
          >>> hasattr(a, 'f')
          Traceback (most recent call last):
            ...
          ZeroDivisionError: integer division or modulo by zero

     (Discovered by Yury Selivanov and fixed by Benjamin Peterson;
     bpo-9666(4).)

   * 浮動小数点数または複素数に対する *note str(): 418. は *note repr():
     7c8. 表現と同じになりました。以前は *note str(): 418. 形式のほうが
     短い表現になっていましたがこれは単に困惑させるものでした。 *note
     repr(): 7c8. がデフォルトで可能ななかでの一番短い表現をするようにな
     ったので、 *note str(): 418. があえて短い表現を取ろうとする必要性が
     なくなりました。

          >>> import math
          >>> repr(math.pi)
          '3.141592653589793'
          >>> str(math.pi)
          '3.141592653589793'

     (Proposed and implemented by Mark Dickinson; bpo-9337(5).)

   * *note memoryview: 435. objects now have a *note release(): 118e.
     method and they also now support the context management protocol.
     This allows timely release of any resources that were acquired when
     requesting a buffer from the original object.

          >>> with memoryview(b'abcdefgh') as v:
          ...     print(v.tolist())
          [97, 98, 99, 100, 101, 102, 103, 104]

     (Added by Antoine Pitrou; bpo-9757(6).)

   * 以前は、入れ子になったブロック内である名前が自由変数として現れる場
     合、局所名前空間からその名前を削除することは不正でした。

          def outer(x):
              def inner():
                  return x
              inner()
              del x

     これは可能になりました。 *note except: 170. 節の対象が消去されるこ
     とを思い出せば、 Python 2.6 では動き、Python 3.1 では *note
     SyntaxError: 172. を送出するこのコードは再び動きます:

          def f():
              def print_error():
                  print(e)
              try:
                  something
              except Exception as e:
                  print_error()
                  # implicit "del e" here

     (bpo-4617(7) を参照してください。)

   * *note Struct sequence types: 118f. are now subclasses of tuple.
     This means that C structures like those returned by *note
     os.stat(): 46d, *note time.gmtime(): 1190, and *note
     sys.version_info: 66c. now work like a *note named tuple: 61a. and
     now work with functions and methods that expect a tuple as an
     argument.  This is a big step forward in making the C structures as
     flexible as their pure Python counterparts:

          >>> import sys
          >>> isinstance(sys.version_info, tuple)
          True
          >>> 'Version %d.%d.%d %s(%d)' % sys.version_info
          'Version 3.2.0 final(0)'

     (Suggested by Arfrever Frehtes Taifersar Arahesis and implemented
     by Benjamin Peterson in bpo-8413(8).)

   * 警告の制御を以前より簡単に出来るようになりました。環境変数 *note
     PYTHONWARNINGS: b78. を使えば、コマンドラインで ‘-W’ を使うより簡単
     です:

          $ export PYTHONWARNINGS='ignore::RuntimeWarning::,once::UnicodeWarning::'

     (Suggested by Barry Warsaw and implemented by Philip Jenvey in
     bpo-7301(9).)

   * 新たな警告カテゴリ *note ResourceWarning: 225. が追加されました。こ
     れはリソース消費やクリーンアップについての潜在的な問題が検出される
     と発行されます。これは通常のリリースビルドではデフォルトでは黙殺し
     ますが、 *note warnings: fa. モジュールで意味付けを変更 (訳注:
     *note 警告フィルタ: 897. 参照) するかコマンドラインオプションで有効
     に出来ます。

     A *note ResourceWarning: 225. is issued at interpreter shutdown if
     the *note gc.garbage: 1191. list isn't empty, and if *note
     gc.DEBUG_UNCOLLECTABLE: 1192. is set, all uncollectable objects are
     printed.  This is meant to make the programmer aware that their
     code contains object finalization issues.

     *note ResourceWarning: 225. は明示的にクローズされなかった *note
     file object: 1193. が破壊される際にも発行されます。そのようなオブジ
     ェクトのデアロケータは背後の OS リソース (大抵はファイル記述子) を
     閉じることを保障はしますが、オブジェクトのデアロケートの遅れは様々
     な問題を産み落とし、とりわけ Windows でこれは顕著です。コマンドライ
     ンからこの警告を有効にするには例えばこのようにします:

          $ python -q -Wdefault
          >>> f = open("foo", "wb")
          >>> del f
          __main__:1: ResourceWarning: unclosed file <_io.BufferedWriter name='foo'>

     (Added by Antoine Pitrou and Georg Brandl in bpo-10093(10) and
     bpo-477863(11).)

   * *note range: 911. objects now support 'index' and 'count' methods.
     This is part of an effort to make more objects fully implement the
     *note collections.Sequence: 1194. *note abstract base class: 1186.
     As a result, the language will have a more uniform API. In
     addition, *note range: 911. objects now support slicing and
     negative indices, even with values larger than *note sys.maxsize:
     1195.  This makes 'range' more interoperable with lists:

          >>> range(0, 100, 2).count(10)
          1
          >>> range(0, 100, 2).index(10)
          5
          >>> range(0, 100, 2)[5]
          10
          >>> range(0, 100, 2)[0:5]
          range(0, 10, 2)

     (Contributed by Daniel Stutzbach in bpo-9213(12), by Alexander
     Belopolsky in bpo-2690(13), and by Nick Coghlan in bpo-10889(14).)

   * Py2.x から *note callable(): 1196. 組み込み関数が復活しました。 こ
     の関数は ‘isinstance(x, collections.Callable)’ のように式内で *note
     抽象基底クラス: 1186. を使用するよりも、簡潔で可読性の高い手段を提
     供します:

          >>> callable(max)
          True
          >>> callable(20)
          False

     (bpo-10518(15) を参照してください。)

   * Python のインポート機構が、パス名に非 ASCII 文字を含むディレクトリ
     にインストールされたモジュールをロードできるようになりました。これ
     はユーザ名に非 ASCII 文字を含むユーザにとっての、ホームディレクトリ
     にまつわる腹立たしい問題を解決しました。

     (Required extensive work by Victor Stinner in bpo-9425(16).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=7094

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6081

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1772833

   (4) https://bugs.python.org/issue?@action=redirect&bpo=9666

   (5) https://bugs.python.org/issue?@action=redirect&bpo=9337

   (6) https://bugs.python.org/issue?@action=redirect&bpo=9757

   (7) https://bugs.python.org/issue?@action=redirect&bpo=4617

   (8) https://bugs.python.org/issue?@action=redirect&bpo=8413

   (9) https://bugs.python.org/issue?@action=redirect&bpo=7301

   (10) https://bugs.python.org/issue?@action=redirect&bpo=10093

   (11) https://bugs.python.org/issue?@action=redirect&bpo=477863

   (12) https://bugs.python.org/issue?@action=redirect&bpo=9213

   (13) https://bugs.python.org/issue?@action=redirect&bpo=2690

   (14) https://bugs.python.org/issue?@action=redirect&bpo=10889

   (15) https://bugs.python.org/issue?@action=redirect&bpo=10518

   (16) https://bugs.python.org/issue?@action=redirect&bpo=9425


File: python.info,  Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール,  Next: マルチスレッディング,  Prev: その他の言語変更<10>,  Up: What's New In Python 3 2

1.12.9 新たなモジュール、改良されたモジュール、非推奨のモジュール
-----------------------------------------------------------------

Python の標準ライブラリは保守の努力と質の向上を大きく受けています。

The biggest news for Python 3.2 is that the *note email: 32. package,
*note mailbox: 7f. module, and ‘nntplib’ modules now work correctly with
the bytes/text model in Python 3.  For the first time, there is correct
handling of messages with mixed encodings.

標準ライブラリ全体を通じて、エンコーディング問題とテキスト対バイト列問題
に関してより注意深い配慮がなされました。とりわけオペレーティングシステム
との連携では、Windows の MBCS エンコーディングやロケールに配慮するエンコ
ーディング、あるいは UTF-8 を使う非 ASCII のデータ交換はより良く行えるよ
うになりました。

もうひとつの目覚しい勝利は、 'SSL' 接続とセキュリティ証明書サポートの大
幅な改善です。

さらに、以前よりももっと多くのクラスが今では *note context manager: 59e.
を実装し、 *note with: 59c. 文を使った便利で信頼出来るリソースのクリーン
アップをサポートしています。

* Menu:

* email: email<6>.
* elementtree::
* functools: functools<7>.
* itertools: itertools<7>.
* collections: collections<8>.
* threading: threading<9>.
* datetime と time::
* math: math<10>.
* abc: abc<3>.
* io: io<7>.
* reprlib::
* logging: logging<8>.
* csv: csv<4>.
* contextlib: contextlib<8>.
* decimal と fractions::
* ftp::
* popen::
* select: select<3>.
* gzip と zipfile::
* tarfile: tarfile<9>.
* hashlib: hashlib<7>.
* ast: ast<5>.
* os: os<13>.
* shutil: shutil<8>.
* sqlite3: sqlite3<11>.
* html: html<3>.
* socket: socket<11>.
* ssl: ssl<12>.
* nntp::
* certificates::
* imaplib: imaplib<4>.
* http.client: http client<4>.
* unittest: unittest<11>.
* random: random<5>.
* poplib: poplib<4>.
* asyncore: asyncore<2>.
* tempfile: tempfile<5>.
* inspect: inspect<10>.
* pydoc: pydoc<6>.
* dis: dis<5>.
* dbm: dbm<7>.
* ctypes: ctypes<3>.
* site: site<4>.
* sysconfig: sysconfig<3>.
* pdb: pdb<8>.
* configparser: configparser<5>.
* urllib.parse: urllib parse<6>.
* mailbox::
* turtledemo::


File: python.info,  Node: email<6>,  Next: elementtree,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.1 email
..............

R. David Murray による多大なる尽力により、Python 3 における *note email:
32. パッケージの適応可能性の問題は、ほとんど修正されました。問題は、
email が典型的には *note str: 418. テキストよりも *note bytes: 1a4. 形式
で格納され、読まれることであり、一つの email の中に複数のエンコーディン
グを含みうることでした。ですから email パッケージは email メッセージの解
析と生成を bytes フォーマットで拡張される必要がありました。

   * 新規関数 *note message_from_bytes(): 1199, *note
     message_from_binary_file(): 119a. 、それに新規クラス *note
     BytesFeedParser: 119b, *note BytesParser: 119c. が、バイナリメッセ
     ージデータをパースしてモデルオブジェクトに読み込みます。

   * bytes の入力をモデルに与えると *note get_payload(): 119d. は、デフ
     ォルトでは '8 ビット' の ‘Content-Transfer-Encoding’ MIME ヘッダを
     もったメッセージボディをそのヘッダで指定された文字セットを使い、デ
     コードして結果文字列を返します。

   * bytes の入力をモデルに与えると *note Generator: 119e. は、 '8 ビッ
     ト' の ‘Content-Transfer-Encoding’ MIME ヘッダをもったメッセージボ
     ディを、 '7 ビット' の ‘Content-Transfer-Encoding’ を持つものに変換
     します。

     エンコードされていない非 ASCII バイト列を持つヘッダは '未知の 8 ビ
     ット' 文字セットを使った RFC 2047(1) エンコードであると見做されます
     。

   * 新規クラス *note BytesGenerator: 119f. は出力としてバイト列を生成し
     ます。これはモデルを構築するのに使った入力にあった非 ASCII データを
     そのままにし、 '8ビットの' ‘Content-Transfer-Encoding’ を持つメッセ
     ージボディに含めます。

   * *note smtplib: b7. モジュールの *note SMTP: 8fb. クラスが *note
     sendmail(): e22. メソッドの 'msg' 引数としてバイト列文字列を受け付
     けるようになりました。新しく追加されたメソッド *note
     send_message(): e23. は 'msg' 引数に *note Message: 25d. オブジェク
     トを受け付けます。このメソッドは 'msg' にあたえたオブジェクトから
     'from_addr' アドレスと 'to_addrs' アドレスを直接取ることが出来ます
     。

(Proposed and implemented by R. David Murray, bpo-4661(2) and
bpo-10321(3).)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2047.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=4661

   (3) https://bugs.python.org/issue?@action=redirect&bpo=10321


File: python.info,  Node: elementtree,  Next: functools<7>,  Prev: email<6>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.2 elementtree
....................

The *note xml.etree.ElementTree: 10c. package and its
‘xml.etree.cElementTree’ counterpart have been updated to version 1.3.

有用な関数とメソッドが幾つか新たに追加されました:

   * *note xml.etree.ElementTree.fromstringlist(): 11a1.、断片のシーケン
     スから XML 文書を組み立てます

   * *note xml.etree.ElementTree.register_namespace(): 11a2.、大域名前空
     間接頭辞を登録するのに使用します

   * *note xml.etree.ElementTree.tostringlist(): fc1.、全サブリストを含
     めた文字列表記に使用します

   * *note xml.etree.ElementTree.Element.extend(): 11a3.、ゼロ以上の要素
     のシークエンスを追加するのに使用します

   * *note xml.etree.ElementTree.Element.iterfind(): 11a4.、要素と子要素
     を検索します

   * *note xml.etree.ElementTree.Element.itertext(): 11a5.、要素と子要素
     を走るテキストイテレータを作成します

   * *note xml.etree.ElementTree.TreeBuilder.end(): 11a6.、現在の要素を
     閉じます

   * *note xml.etree.ElementTree.TreeBuilder.doctype(): a65.、doctype 定
     義を処理します

2つのメソッドが非推奨になりました:

   * ‘xml.etree.ElementTree.getchildren()’ use ‘list(elem)’ instead.

   * ‘xml.etree.ElementTree.getiterator()’ use ‘Element.iter’ instead.

For details of the update, see Introducing ElementTree(1) on Fredrik
Lundh's website.

(Contributed by Florent Xicluna and Fredrik Lundh, bpo-6472(2).)

   ---------- Footnotes ----------

   (1) 
https://web.archive.org/web/20200703234532/http://effbot.org/zone/elementtree-13-intro.htm

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6472


File: python.info,  Node: functools<7>,  Next: itertools<7>,  Prev: elementtree,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.3 functools
..................

   * *note functools: 55. モジュールに関数呼び出しをキャッシュするデコレ
     ータが追加されています。 *note functools.lru_cache(): 9bd. を使うと
     、同じ結果が期待される場合の外部リソースへの問い合わせ繰り返しを防
     ぐことができます。

     たとえばデータベース問い合わせ関数をキャッシュするデコレータで修飾
     すれば、人気の検索のデータベースアクセスを省けます:

          >>> import functools
          >>> @functools.lru_cache(maxsize=300)
          ... def get_phone_number(name):
          ...     c = conn.cursor()
          ...     c.execute('SELECT phonenumber FROM phonelist WHERE name=?', (name,))
          ...     return c.fetchone()[0]

          >>> for name in user_requests:
          ...     get_phone_number(name)        # cached lookup

     効果的なキャッシュサイズを選択する助けとなるよう、ラップされた関数
     はキャッシュの統計を追跡する道具にもなっています:

          >>> get_phone_number.cache_info()
          CacheInfo(hits=4805, misses=980, maxsize=300, currsize=300)

     テーブル phonelist が更新されたのであれば、内容が古くなったキャッシ
     ュをクリアできます:

          >>> get_phone_number.cache_clear()

     (Contributed by Raymond Hettinger and incorporating design ideas
     from Jim Baker, Miki Tebeka, and Nick Coghlan; see recipe
     498245(1), recipe 577479(2), bpo-10586(3), and bpo-10593(4).)

   * The *note functools.wraps(): f2a. decorator now adds a
     ‘__wrapped__’ attribute pointing to the original callable function.
     This allows wrapped functions to be introspected.  It also copies
     *note __annotations__: 11a8. if defined.  And now it also
     gracefully skips over missing attributes such as *note __doc__:
     11a9. which might not be defined for the wrapped callable.

     上の例の場合、キャッシュは元の関数を復元することで削除できます:

          >>> get_phone_number = get_phone_number.__wrapped__    # uncached function

     (By Nick Coghlan and Terrence Cole; bpo-9567(5), bpo-3445(6), and
     bpo-8814(7).)

   * 拡張比較 (rich comparison) メソッドを持つクラスを書く助けとなるよう
     、新たなデコレータ *note functools.total_ordering(): f0f. が追加さ
     れました。これは既存の等式と不等式メソッドを使って残りのメソッドを
     埋めます。

     例えば '__eq__' と '__lt__' を与えると、 *note total_ordering():
     f0f. は '__le__', '__gt__', '__ge__' を補います:

          @total_ordering
          class Student:
              def __eq__(self, other):
                  return ((self.lastname.lower(), self.firstname.lower()) ==
                          (other.lastname.lower(), other.firstname.lower()))

              def __lt__(self, other):
                  return ((self.lastname.lower(), self.firstname.lower()) <
                          (other.lastname.lower(), other.firstname.lower()))

     'total_ordering' デコレータが残りの比較メソッドを自動的に補います。

     (Contributed by Raymond Hettinger.)

   * Python 2 からのプログラムの移植のために使える、 *note
     functools.cmp_to_key(): 11aa. 関数が追加されました。これは旧式の比
     較関数をモダンな *note key function: dd2. に変換します:

          >>> # locale-aware sort order
          >>> sorted(iterable, key=cmp_to_key(locale.strcoll))

     ソートの例と簡単なチュートリアルは *note ソートのテクニック: 11ab.
     を参照して下さい。

     (Contributed by Raymond Hettinger.)

   ---------- Footnotes ----------

   (1) 
https://code.activestate.com/recipes/498245-lru-and-lfu-cache-decorators/

   (2) 
https://code.activestate.com/recipes/577479-simple-caching-decorator/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=10586

   (4) https://bugs.python.org/issue?@action=redirect&bpo=10593

   (5) https://bugs.python.org/issue?@action=redirect&bpo=9567

   (6) https://bugs.python.org/issue?@action=redirect&bpo=3445

   (7) https://bugs.python.org/issue?@action=redirect&bpo=8814


File: python.info,  Node: itertools<7>,  Next: collections<8>,  Prev: functools<7>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.4 itertools
..................

   * *note itertools: 75. モジュールに、 APL(1) の 'scan' 演算子や
     NumPy(2) の 'accumulate' 関数をモデルにした *note accumulate():
     9cb. が新しく追加されました:

          >>> from itertools import accumulate
          >>> list(accumulate([8, 2, 50]))
          [8, 10, 60]

          >>> prob_dist = [0.1, 0.4, 0.2, 0.3]
          >>> list(accumulate(prob_dist))      # cumulative probability distribution
          [0.1, 0.5, 0.7, 1.0]

     *note accumulate(): 9cb. の使用例が *note examples for the random
     module: 11ad. にあります。

     (Contributed by Raymond Hettinger and incorporating design
     suggestions from Mark Dickinson.)

   ---------- Footnotes ----------

   (1) https://ja.wikipedia.org/wiki/APL

   (2) http://www.numpy.org/


File: python.info,  Node: collections<8>,  Next: threading<9>,  Prev: itertools<7>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.5 collections
....................

   * *note collections.Counter: 1067. クラスに 2 つの形式のインプレイス
     減算が追加されました。 saturating subtraction(1) (訳注: 結果を
     [min, max] に収める演算) を行う既存の '-=' 演算子に加え、新しく追加
     された *note subtract(): 11af. メソッドは通常の減算を行います。前者
     は要素数に正しか持たない 多重集合(2) に用いるのに適していて、後者は
     要素数に負を許容するユースケースにより適しています。

          >>> from collections import Counter
          >>> tally = Counter(dogs=5, cats=3)
          >>> tally -= Counter(dogs=2, cats=8)    # saturating subtraction
          >>> tally
          Counter({'dogs': 3})

          >>> tally = Counter(dogs=5, cats=3)
          >>> tally.subtract(dogs=2, cats=8)      # regular subtraction
          >>> tally
          Counter({'dogs': 3, 'cats': -5})

     (Contributed by Raymond Hettinger.)

   * *note collections.OrderedDict: 5a5. クラスに *note move_to_end():
     11b0. メソッド (訳注: 「end」は「端」) が追加されました。これは既存
     のキーを受け取って、順序付けされたシーケンスの最初の位置か最後の位
     置に移動します。

     デフォルトでは要素は最後の位置に移動します。これはエントリを ‘od[k]
     = od.pop(k)’ で入れ替えるのと同じです。

     高速な端への移動操作はエントリの並べなおしに便利です。例えば、最も
     最近使った順序でエントリを年齢付けすることによってアクセス順を追跡
     するのに、順序付けされた辞書を使えます。

          >>> from collections import OrderedDict
          >>> d = OrderedDict.fromkeys(['a', 'b', 'X', 'd', 'e'])
          >>> list(d)
          ['a', 'b', 'X', 'd', 'e']
          >>> d.move_to_end('X')
          >>> list(d)
          ['a', 'b', 'd', 'e', 'X']

     (Contributed by Raymond Hettinger.)

   * *note collections.deque: 5a6. クラスに 2 つのメソッド *note
     count(): 11b1. と *note reverse(): 11b2. が追加されました。これでさ
     らに *note list: 5dc. との置換可能性が増しました:

          >>> from collections import deque
          >>> d = deque('simsalabim')
          >>> d.count('s')
          2
          >>> d.reverse()
          >>> d
          deque(['m', 'i', 'b', 'a', 'l', 'a', 's', 'm', 'i', 's'])

     (Contributed by Raymond Hettinger.)

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Saturation_arithmetic

   (2) 
https://ja.wikipedia.org/wiki/%E5%A4%9A%E9%87%8D%E9%9B%86%E5%90%88


File: python.info,  Node: threading<9>,  Next: datetime と time,  Prev: collections<8>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.6 threading
..................

*note threading: d6. モジュールに新たに同期クラス *note Barrier: 11b4. が
追加されました。これは多重のスレッドに、それら全てが共通のバリアポイント
に到達するまで待たせます。バリアは、複数の事前条件を持ったタスクを、その
前任タスクの全てが完了するまで走らせたくない場合に有用です。

バリアは任意の数のスレッドに対して使えます。これは Rendezvous(1) を一般
化したもので、それは 2 つのスレッドに対してのみに定義されていました。

二段階の周期バリアとしての実装なので、 *note Barrier: 11b4. オブジェクト
はループ内での利用に適しています。分けられた 'filling (満杯にする)' 段階
と 'draining (排出する)' 段階は、スレッドのどれか一つが元に戻ってバリア
に再び入る前に、全てのスレッドが解放 (排出) されることを保障します。バリ
アはそれぞれの周期のあとに完全にリセットされます。

バリアは例えばこのように使います:

     from threading import Barrier, Thread

     def get_votes(site):
         ballots = conduct_election(site)
         all_polls_closed.wait()        # do not count until all polls are closed
         totals = summarize(ballots)
         publish(site, totals)

     all_polls_closed = Barrier(len(sites))
     for site in sites:
         Thread(target=get_votes, args=(site,)).start()

この例ではバリアは、全ての投票所が閉じるまではどの投票サイトでも得票を数
えないルールを強制しています。バリアを使ったソリューションが *note
threading.Thread.join(): 11b5. でのそれといかに似ているか気付くと思いま
す。ですがバリアポイントを通過した後に、スレッドは生き続けて (投票を集計
する (summarizing ballots) という) 仕事を続けます。

いずれかの前任タスクがハングしたり遅延したりしうるのであれば、バリアを
'timeout' 付きで作ることができます。全ての前任タスクがバリアポイントに到
達する前にタイムアウトの期間が経過すると、全ての待機スレッドは解放されて
*note BrokenBarrierError: 11b6. 例外が発生します:

     def get_votes(site):
         ballots = conduct_election(site)
         try:
             all_polls_closed.wait(timeout=midnight - time.now())
         except BrokenBarrierError:
             lockbox = seal_ballots(ballots)
             queue.put(lockbox)
         else:
             totals = summarize(ballots)
             publish(site, totals)

この例ではバリアは、もっと手堅いルールを強制しています。選挙サイトのどれ
かが午前零時前に終了しなかった場合バリアがタイムアウトし、投票用紙は密封
されて後の処理のためのキューに預けられます。

See Barrier Synchronization Patterns(2) for more examples of how
barriers can be used in parallel computing.  Also, there is a simple but
thorough explanation of barriers in The Little Book of Semaphores(3),
'section 3.6'.

(Contributed by Kristján Valur Jónsson with an API review by Jeffrey
Yasskin in bpo-8777(4).)

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Synchronous_rendezvous

   (2) 
https://osl.cs.illinois.edu/media/papers/karmani-2009-barrier_synchronization_pattern.pdf

   (3) https://greenteapress.com/semaphores/LittleBookOfSemaphores.pdf

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8777


File: python.info,  Node: datetime と time,  Next: math<10>,  Prev: threading<9>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.7 datetime と time
.........................

   * *note datetime: 28. モジュールに新たに *note timezone: 1091. 型が追
     加されています。これは *note tzinfo: 5a8. インターフェイスを実装し
     、UTC からの固定オフセットとタイムゾーン名を返します。これによりタ
     イムゾーンを意識する (timezone-aware な) datetime オブジェクトを容
     易に作れます:

          >>> from datetime import datetime, timezone

          >>> datetime.now(timezone.utc)
          datetime.datetime(2010, 12, 8, 21, 4, 2, 923754, tzinfo=datetime.timezone.utc)

          >>> datetime.strptime("01/01/2000 12:00 +0000", "%m/%d/%Y %H:%M %z")
          datetime.datetime(2000, 1, 1, 12, 0, tzinfo=datetime.timezone.utc)

   * さらに、 *note timedelta: 99d. オブジェクトは今では *note float:
     2ce. を掛けることができ、 *note float: 2ce. や *note int: 238. で割
     ることができます。また、 *note timedelta: 99d. オブジェクトは別の
     *note timedelta: 99d. で割ることが出来ます。

   * *note datetime.date.strftime(): c5f. メソッドにはもう 1900 年以降と
     いう制限はありません。新しくサポートされる年の範囲は 1000 以上 9999
     以下です。

   * Whenever a two-digit year is used in a time tuple, the
     interpretation has been governed by ‘time.accept2dyear’.  The
     default is ‘True’ which means that for a two-digit year, the
     century is guessed according to the POSIX rules governing the ‘%y’
     strptime format.

     Starting with Py3.2, use of the century guessing heuristic will
     emit a *note DeprecationWarning: 18a.  Instead, it is recommended
     that ‘time.accept2dyear’ be set to ‘False’ so that large date
     ranges can be used without guesswork:

          >>> import time, warnings
          >>> warnings.resetwarnings()      # remove the default warning filters

          >>> time.accept2dyear = True      # guess whether 11 means 11 or 2011
          >>> time.asctime((11, 1, 1, 12, 34, 56, 4, 1, 0))
          Warning (from warnings module):
            ...
          DeprecationWarning: Century info guessed for a 2-digit year.
          'Fri Jan  1 12:34:56 2011'

          >>> time.accept2dyear = False     # use the full range of allowable dates
          >>> time.asctime((11, 1, 1, 12, 34, 56, 4, 1, 0))
          'Fri Jan  1 12:34:56 11'

     Several functions now have significantly expanded date ranges.
     When ‘time.accept2dyear’ is false, the *note time.asctime(): 11b8.
     function will accept any year that fits in a C int, while the *note
     time.mktime(): 11b9. and *note time.strftime(): 11ba. functions
     will accept the full range supported by the corresponding operating
     system functions.

(Contributed by Alexander Belopolsky and Victor Stinner in
bpo-1289118(1), bpo-5094(2), bpo-6641(3), bpo-2706(4), bpo-1777412(5),
bpo-8013(6), and bpo-10827(7).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1289118

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5094

   (3) https://bugs.python.org/issue?@action=redirect&bpo=6641

   (4) https://bugs.python.org/issue?@action=redirect&bpo=2706

   (5) https://bugs.python.org/issue?@action=redirect&bpo=1777412

   (6) https://bugs.python.org/issue?@action=redirect&bpo=8013

   (7) https://bugs.python.org/issue?@action=redirect&bpo=10827


File: python.info,  Node: math<10>,  Next: abc<3>,  Prev: datetime と time,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.8 math
.............

*note math: 81. モジュールがアップデートされ、C99 標準に触発されて6つの
新たな関数が追加されました。

*note isfinite(): 11bc. 関数は特殊値を確実に、かつ高速に検出する方法を提
供します。通常の数には ‘True’ を、'Nan' や 'Infinity' には ‘False’ を返
します:

     >>> from math import isfinite
     >>> [isfinite(x) for x in (123, 4.56, float('Nan'), float('Inf'))]
     [True, True, False, False]

*note expm1(): 11bd. 関数は小さな 'x' に対しても精度を失うこと (訳注: 桁
落ち) なく ‘e**x-1’ を計算します。 通常、桁落ちは非常に近い数の引き算で
起こります。

     >>> from math import expm1
     >>> expm1(0.013671875)   # more accurate way to compute e**x-1 for a small x
     0.013765762467652909

*note erf(): ba6. 関数は確率積分、すなわち 誤差関数(1) を返します。 相補
誤差関数 *note erfc(): ba7. は ‘1 - erf(x)’ です:

     >>> from math import erf, erfc, sqrt
     >>> erf(1.0/sqrt(2.0))   # portion of normal distribution within 1 standard deviation
     0.682689492137086
     >>> erfc(1.0/sqrt(2.0))  # portion of normal distribution outside 1 standard deviation
     0.31731050786291404
     >>> erf(1.0/sqrt(2.0)) + erfc(1.0/sqrt(2.0))
     1.0

*note gamma(): 11be. 関数は階乗を連続的に拡張したものです。詳細は ガンマ
関数(2) を参照してください。ガンマ関数は階乗に関係しているため、小さな
'x' でも大きくなります。そのため、ガンマ関数の自然対数を計算する *note
lgamma(): 11bf. 関数があります。

     >>> from math import gamma, lgamma
     >>> gamma(7.0)           # six factorial
     720.0
     >>> lgamma(801.0)        # log(800 factorial)
     4551.950730698041

(Contributed by Mark Dickinson.)

   ---------- Footnotes ----------

   (1) 
https://ja.wikipedia.org/wiki/%E8%AA%A4%E5%B7%AE%E9%96%A2%E6%95%B0

   (2) 
https://ja.wikipedia.org/wiki/%E3%82%AC%E3%83%B3%E3%83%9E%E9%96%A2%E6%95%B0


File: python.info,  Node: abc<3>,  Next: io<7>,  Prev: math<10>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.9 abc
............

*note abc: 4. モジュールは *note abstractclassmethod(): 105c. と *note
abstractstaticmethod(): 105d. をサポートしました。

これらのツールによって特定の *note classmethod(): 14c. や *note
staticmethod(): 3ef. を実装する必要のある *note 抽象基底クラス: 1186. を
定義することが出来ます。

     class Temperature(metaclass=abc.ABCMeta):
         @abc.abstractclassmethod
         def from_fahrenheit(cls, t):
             ...
         @abc.abstractclassmethod
         def from_celsius(cls, t):
             ...

(Patch submitted by Daniel Urban; bpo-5867(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5867


File: python.info,  Node: io<7>,  Next: reprlib,  Prev: abc<3>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.10 io
............

*note io.BytesIO: e6d. に *note memoryview(): 435. と同様の機能を提供す
る新たなメソッド *note getbuffer(): 11c2. が追加されました。 このメソッ
ドはコピーせずにデータの編集可能なビューを作成します。 バッファのランダ
ムアクセスとスライス記法のサポートはインプレースな編集に適しています:

     >>> REC_LEN, LOC_START, LOC_LEN = 34, 7, 11

     >>> def change_location(buffer, record_number, location):
     ...     start = record_number * REC_LEN + LOC_START
     ...     buffer[start: start+LOC_LEN] = location

     >>> import io

     >>> byte_stream = io.BytesIO(
     ...     b'G3805  storeroom  Main chassis    '
     ...     b'X7899  shipping   Reserve cog     '
     ...     b'L6988  receiving  Primary sprocket'
     ... )
     >>> buffer = byte_stream.getbuffer()
     >>> change_location(buffer, 1, b'warehouse  ')
     >>> change_location(buffer, 0, b'showroom   ')
     >>> print(byte_stream.getvalue())
     b'G3805  showroom   Main chassis    '
     b'X7899  warehouse  Reserve cog     '
     b'L6988  receiving  Primary sprocket'

(Contributed by Antoine Pitrou in bpo-5506(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5506


File: python.info,  Node: reprlib,  Next: logging<8>,  Prev: io<7>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.11 reprlib
.................

When writing a *note __repr__(): 5e8. method for a custom container, it
is easy to forget to handle the case where a member refers back to the
container itself.  Python's builtin objects such as *note list: 5dc. and
*note set: 5a3. handle self-reference by displaying "..."  in the
recursive part of the representation string.

To help write such *note __repr__(): 5e8. methods, the *note reprlib:
a9. module has a new decorator, *note recursive_repr(): 11c4, for
detecting recursive calls to ‘__repr__()’ and substituting a placeholder
string instead:

     >>> class MyList(list):
     ...     @recursive_repr()
     ...     def __repr__(self):
     ...         return '<' + '|'.join(map(repr, self)) + '>'
     ...
     >>> m = MyList('abc')
     >>> m.append(m)
     >>> m.append('x')
     >>> print(m)
     <'a'|'b'|'c'|...|'x'>

(Contributed by Raymond Hettinger in bpo-9826(1) and bpo-9840(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9826

   (2) https://bugs.python.org/issue?@action=redirect&bpo=9840


File: python.info,  Node: logging<8>,  Next: csv<4>,  Prev: reprlib,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.12 logging
.................

上記の辞書ベースの設定に加え、*note logging: 7b. パッケージには他にも多
くの改良があります。

ロギングのドキュメントは *note 基本チュートリアル: 11c6. 、 *note
上級チュートリアル: 11c7. 、 *note クックブック: 11c8. により増強されて
きました。ロギングについて学習するにはこれらのドキュメントが最速の方法で
す。

セットアップ関数 *note logging.basicConfig(): 9ce. に 'style' 引数が追加
され、これにより異なる 3 つのタイプの文字列書式化がサポートされます。デ
フォルトは伝統的な % 書式化を使う "%" で、 *note str.format(): 5ed. スタ
イルの "{" 、 *note string.Template: 653. で提供されるシェルスタイルの
"$" をセット出来ます。以下の 3 つの設定は等価です:

     >>> from logging import basicConfig
     >>> basicConfig(style='%', format="%(name)s -> %(levelname)s: %(message)s")
     >>> basicConfig(style='{', format="{name} -> {levelname} {message}")
     >>> basicConfig(style='$', format="$name -> $levelname: $message")

If no configuration is set-up before a logging event occurs, there is
now a default configuration using a *note StreamHandler: 11c9. directed
to *note sys.stderr: 907. for events of ‘WARNING’ level or higher.
Formerly, an event occurring before a configuration was set-up would
either raise an exception or silently drop the event depending on the
value of *note logging.raiseExceptions: 11ca.  The new default handler
is stored in *note logging.lastResort: 11cb.

フィルタの利用は単純になりました。 *note Filter: 11cc. オブジェクトを作
る代わりに、 ‘True’ か ‘False’ を返す任意の Python 呼び出し可能オブジェ
クトを述語 (predicate) として利用出来ます。

ほかにも柔軟性を高め、設定を単純化する数多くの改善がありました。Python
3.2 での全ての変更についてはモジュールのドキュメントを参照してください。


File: python.info,  Node: csv<4>,  Next: contextlib<8>,  Prev: logging<8>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.13 csv
.............

*note csv: 21. モジュールは新たな方言 *note unix_dialect: 11ce. をサポー
トしました。 この方言は全フィールドをクォートし、行末を伝統的な Unix 形
式の ‘'\n'’ にします。 登録された方言名は ‘unix’ です。

*note csv.DictWriter: 11cf. に新たなメソッド *note writeheader(): 11d0.
が追加されました。 最初の列をドキュメントのフィールド名に書き出すのに使
用します:

     >>> import csv, sys
     >>> w = csv.DictWriter(sys.stdout, ['name', 'dept'], dialect='unix')
     >>> w.writeheader()
     "name","dept"
     >>> w.writerows([
     ...     {'name': 'tom', 'dept': 'accounting'},
     ...     {'name': 'susan', 'dept': 'Salesl'}])
     "tom","accounting"
     "susan","sales"

(New dialect suggested by Jay Talbot in bpo-5975(1), and the new method
suggested by Ed Abraham in bpo-1537721(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5975

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1537721


File: python.info,  Node: contextlib<8>,  Next: decimal と fractions,  Prev: csv<4>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.14 contextlib
....................

新しく追加され、そして少しばかりハートを揺さぶるツール *note
ContextDecorator: 11d2. は、関数デコレータとしての任務も果たす *note
context manager: 59e. を作るのに役立つものです。

利便性のためにこの新機能は *note contextmanager(): 11d3. で使われている
ので、両方の役割をサポートするのにことさら労力は要しません。

基本的なアイディアは、コンテキストマネージャも関数デコレータも、ともに事
前アクション・事後アクションラッパーとして使うことが出来るというものです
。コンテキストマネージャは *note with: 59c. 文を使ったステートメント (文
) のグループを包みますし、関数デコレータは関数に取り囲まれたステートメン
トのグループを包みます。そうです、どちらかの役割で使える事前アクションあ
るいは事後アクションラッパーを書く必要性は、しばしば起こることです。

たとえば関数やステートメントのグループをロガーで包んで、開始時刻と終了時
刻を追跡できるようにするとしばしば便利です。このタスクをこなすために関数
デコレータとコンテキストマネージャの両方を書く代わりに、 *note
contextmanager(): 11d3. が単一の定義に両方の能力をもたらしてくれます:

     from contextlib import contextmanager
     import logging

     logging.basicConfig(level=logging.INFO)

     @contextmanager
     def track_entry_and_exit(name):
         logging.info('Entering: %s', name)
         yield
         logging.info('Exiting: %s', name)

ContextDecorator が使われる前の 3.1 までの *note contextmanager(): 11d3.
では、これはコンテキストマネージャとして使えるだけでした:

     with track_entry_and_exit('widget loader'):
         print('Some time consuming activity goes here')
         load_widget()

今ではこれはデコレータとしても使えます:

     @track_entry_and_exit('widget loader')
     def activity():
         print('Some time consuming activity goes here')
         load_widget()

一つの場所に二重の責務を持たせることには普通ある種の制約を持ち込みます。
コンテキストマネージャには普通は *note with: 59c. 文で使える値を返せる柔
軟性を持ちますが、関数デコレータにはそれに匹敵するものはありません。

上の例の場合は、'track_entry_and_exit' コンテキストマネージャが、取り囲
まれたステートメント本体で使えるロギングのインスタンスを返す綺麗な方法は
ありません。

(Contributed by Michael Foord in bpo-9110(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9110


File: python.info,  Node: decimal と fractions,  Next: ftp,  Prev: contextlib<8>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.15 decimal と fractions
..............................

Mark Dickinson は、異なる数値データの型が実際の値が等しい場合は常に同じ
ハッシュ値を持つことを保証する、エレガントで効率的なスキームを作り上げま
した (bpo-8188(1)):

     assert hash(Fraction(3, 2)) == hash(1.5) == \
            hash(Decimal("1.5")) == hash(complex(1.5, 0))

Some of the hashing details are exposed through a new attribute, *note
sys.hash_info: fca, which describes the bit width of the hash value, the
prime modulus, the hash values for 'infinity' and 'nan', and the
multiplier used for the imaginary part of a number:

     >>> sys.hash_info
     sys.hash_info(width=64, modulus=2305843009213693951, inf=314159, nan=0, imag=1000003)

An early decision to limit the interoperability of various numeric types
has been relaxed.  It is still unsupported (and ill-advised) to have
implicit mixing in arithmetic expressions such as ‘Decimal('1.1') +
float('1.1')’ because the latter loses information in the process of
constructing the binary float.  However, since existing floating-point
value can be converted losslessly to either a decimal or rational
representation, it makes sense to add them to the constructor and to
support mixed-type comparisons.

   * *note decimal.Decimal: 27d. コンストラクタに *note float: 2ce. オブ
     ジェクトを直接渡せるようになりました。これにより *note
     from_float(): 11d5. メソッドを使う必要はなくなりました
     (bpo-8257(2))。

   * 型違いの比較はいまでは完全にサポートされたので、 *note Decimal:
     27d. オブジェクトを直接 *note float: 2ce. や *note
     fractions.Fraction: 1c8. と比較出来ます (bpo-2531(3) and
     bpo-8188(4))。

Similar changes were made to *note fractions.Fraction: 1c8. so that the
*note from_float(): 11d6. and *note from_decimal(): 11d7. methods are no
longer needed (bpo-8294(5)):

     >>> from decimal import Decimal
     >>> from fractions import Fraction
     >>> Decimal(1.1)
     Decimal('1.100000000000000088817841970012523233890533447265625')
     >>> Fraction(1.1)
     Fraction(2476979795053773, 2251799813685248)

Another useful change for the *note decimal: 2e. module is that the
‘Context.clamp’ attribute is now public.  This is useful in creating
contexts that correspond to the decimal interchange formats specified in
IEEE 754 (see bpo-8540(6)).

(Contributed by Mark Dickinson and Raymond Hettinger.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8188

   (2) https://bugs.python.org/issue?@action=redirect&bpo=8257

   (3) https://bugs.python.org/issue?@action=redirect&bpo=2531

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8188

   (5) https://bugs.python.org/issue?@action=redirect&bpo=8294

   (6) https://bugs.python.org/issue?@action=redirect&bpo=8540


File: python.info,  Node: ftp,  Next: popen,  Prev: decimal と fractions,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.16 ftp
.............

*note ftplib.FTP: 8c8. クラスがコンテキスト管理プロトコルをサポートする
ようになりました。with ブロックを抜ける際に無条件に FTP 接続をクローズし
ます (クローズ処理で発生する *note socket.error: 1029. は無視されます)。
:

     >>> from ftplib import FTP
     >>> with FTP("ftp1.at.proftpd.org") as ftp:
             ftp.login()
             ftp.dir()

     '230 Anonymous login ok, restrictions apply.'
     dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 .
     dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 ..
     dr-xr-xr-x   5 ftp      ftp          4096 May  6 10:43 CentOS
     dr-xr-xr-x   3 ftp      ftp            18 Jul 10  2008 Fedora

ちなみに *note mmap.mmap: 1ec. や *note fileinput.input(): 7ca. のような
ほかのファイルライクなオブジェクトも自動クローズするコンテキスト管理プロ
トコルをサポートするようになっていたりします:

     with fileinput.input(files=('log1.txt', 'log2.txt')) as f:
         for line in f:
             process(line)

(Contributed by Tarek Ziadé and Giampaolo Rodolà in bpo-4972(1), and by
Georg Brandl in bpo-8046(2) and bpo-1286(3).)

*note FTP_TLS: 8c9. クラスが 'context' パラメータを受け取れるようになり
ました。これには *note ssl.SSLContext: 274. オブジェクトを渡します。これ
は SSL コンフィグレーションオプション、証明書、秘密鍵を単一の (たぶん長
生きの) 構造にまとめあげてくれるものです。

(Contributed by Giampaolo Rodolà; bpo-8806(4).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4972

   (2) https://bugs.python.org/issue?@action=redirect&bpo=8046

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1286

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8806


File: python.info,  Node: popen,  Next: select<3>,  Prev: ftp,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.17 popen
...............

*note os.popen(): a55. ならびに *note subprocess.Popen(): 17e. 関数が自
動的にファイル記述子を閉じる *note with: 59c. 文をサポートしました。

(Contributed by Antoine Pitrou and Brian Curtin in bpo-7461(1) and
bpo-10554(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=7461

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10554


File: python.info,  Node: select<3>,  Next: gzip と zipfile,  Prev: popen,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.18 select
................

The *note select: af. module now exposes a new, constant attribute,
*note PIPE_BUF: 11db, which gives the minimum number of bytes which are
guaranteed not to block when *note select.select(): d6d. says a pipe is
ready for writing.

     >>> import select
     >>> select.PIPE_BUF
     512

(Available on Unix systems.  Patch by Sébastien Sablé in bpo-9862(1))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9862


File: python.info,  Node: gzip と zipfile,  Next: tarfile<9>,  Prev: select<3>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.19 gzip と zipfile
.........................

*note gzip.GzipFile: 3f3. が *note io.BufferedIOBase: 660. *note
抽象基底クラス: 1186. を継承しました (‘truncate()’ をのぞく)。 *note
peek(): 11dd. メソッドが追加され、シーク不能なファイルオブジェクトならび
にゼロ埋めされたファイルオブジェクトをサポートしました。

また、*note gzip: 5d. モジュールにより簡便でインメモリな圧縮および解凍を
行う *note compress(): 60a. ならびに *note decompress(): 11de. 関数が追
加されました。 圧縮や解凍の前に *note bytes: 1a4. としてエンコードしなけ
ればならない点に注意してください:

     >>> import gzip
     >>> s = 'Three shall be the number thou shalt count, '
     >>> s += 'and the number of the counting shall be three'
     >>> b = s.encode()                        # convert to utf-8
     >>> len(b)
     89
     >>> c = gzip.compress(b)
     >>> len(c)
     77
     >>> gzip.decompress(c).decode()[:42]      # decompress and convert to text
     'Three shall be the number thou shalt count'

(Contributed by Anand B. Pillai in bpo-3488(1); and by Antoine Pitrou,
Nir Aides and Brian Curtin in bpo-9962(2), bpo-1675951(3), bpo-7471(4)
and bpo-2846(5).)

Also, the *note zipfile.ZipExtFile: 3f4. class was reworked internally
to represent files stored inside an archive.  The new implementation is
significantly faster and can be wrapped in an *note io.BufferedReader:
11df. object for more speedups.  It also solves an issue where
interleaved calls to 'read' and 'readline' gave the wrong results.

(Patch submitted by Nir Aides in bpo-7610(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3488

   (2) https://bugs.python.org/issue?@action=redirect&bpo=9962

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1675951

   (4) https://bugs.python.org/issue?@action=redirect&bpo=7471

   (5) https://bugs.python.org/issue?@action=redirect&bpo=2846

   (6) https://bugs.python.org/issue?@action=redirect&bpo=7610


File: python.info,  Node: tarfile<9>,  Next: hashlib<7>,  Prev: gzip と zipfile,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.20 tarfile
.................

*note TarFile: 11e1. クラスは今ではコンテキストマネージャとして使えます
。加えて、その *note add(): bc1. メソッドに新しいオプション 'filter' が
追加されました。これはファイルをアーカイブに追加するかどうかを制御し、ま
た、ファイルのメタデータを編集するのにも使えます。

'filter' オプションは古くて柔軟性に欠ける 'exclude' パラメータを置き換え
るものであり、 'exclude' は非推奨となりました。 'filter' を指定する場合
は *note keyword argument: ce0. として渡さなければなりません。ユーザ指定
の filter 関数は *note TarInfo: 11e2. オブジェクトを受け取り、更新した
*note TarInfo: 11e2. オブジェクトを返すか、あるいはアーカイブから除外し
たければ ‘None’ を返してください。

     >>> import tarfile, glob

     >>> def myfilter(tarinfo):
     ...     if tarinfo.isfile():             # only save real files
     ...         tarinfo.uname = 'monty'      # redact the user name
     ...         return tarinfo

     >>> with tarfile.open(name='myarchive.tar.gz', mode='w:gz') as tf:
     ...     for filename in glob.glob('*.txt'):
     ...         tf.add(filename, filter=myfilter)
     ...     tf.list()
     -rw-r--r-- monty/501        902 2011-01-26 17:59:11 annotations.txt
     -rw-r--r-- monty/501        123 2011-01-26 17:59:11 general_questions.txt
     -rw-r--r-- monty/501       3514 2011-01-26 17:59:11 prion.txt
     -rw-r--r-- monty/501        124 2011-01-26 17:59:11 py_todo.txt
     -rw-r--r-- monty/501       1399 2011-01-26 17:59:11 semaphore_notes.txt

(Proposed by Tarek Ziadé and implemented by Lars Gustäbel in
bpo-6856(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6856


File: python.info,  Node: hashlib<7>,  Next: ast<5>,  Prev: tarfile<9>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.21 hashlib
.................

*note hashlib: 5e. モジュールに、2 つの定数属性が追加されました。全ての
実装で利用可能であることが保障されているハッシュアルゴリズムのリストと、
現在の実装で利用可能なそれらリストの 2 つです:

     >>> import hashlib

     >>> hashlib.algorithms_guaranteed
     {'sha1', 'sha224', 'sha384', 'sha256', 'sha512', 'md5'}

     >>> hashlib.algorithms_available
     {'md2', 'SHA256', 'SHA512', 'dsaWithSHA', 'mdc2', 'SHA224', 'MD4', 'sha256',
     'sha512', 'ripemd160', 'SHA1', 'MDC2', 'SHA', 'SHA384', 'MD2',
     'ecdsa-with-SHA1','md4', 'md5', 'sha1', 'DSA-SHA', 'sha224',
     'dsaEncryption', 'DSA', 'RIPEMD160', 'sha', 'MD5', 'sha384'}

(Suggested by Carl Chenet in bpo-7418(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=7418


File: python.info,  Node: ast<5>,  Next: os<13>,  Prev: hashlib<7>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.22 ast
.............

*note ast: 7. モジュールには、Python リテラル構文を使った式文字列を安全
に評価できる、汎用目的の素晴らしい道具が含まれています。その *note
ast.literal_eval(): be6. 関数は、悪用されやすい組み込み関数 *note
eval(): 165. の安全な代替品として働いてくれます。Python 3.2 はこれのサポ
ート型に *note bytes: 1a4. と *note set: 5a3. を加えました。結果サポート
する型は全部でこれらになりました: 文字列型、バイト列文字列型、数値型、タ
プル型、リスト型、辞書型、集合型、真偽値型、‘None’。

     >>> from ast import literal_eval

     >>> request = "{'req': 3, 'func': 'pow', 'args': (2, 0.5)}"
     >>> literal_eval(request)
     {'args': (2, 0.5), 'req': 3, 'func': 'pow'}

     >>> request = "os.system('do something harmful')"
     >>> literal_eval(request)
     Traceback (most recent call last):
       ...
     ValueError: malformed node or string: <_ast.Call object at 0x101739a10>

(Implemented by Benjamin Peterson and Georg Brandl.)


File: python.info,  Node: os<13>,  Next: shutil<8>,  Prev: ast<5>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.23 os
............

ファイル名と環境変数に使われるエンコーディングは OS ごとに様々です。
*note os: 91. モジュールは新たに 2 つの関数 *note fsencode(): c23. と
*note fsdecode(): c22. を追加しました。それぞれファイル名のエンコード、
デコードを行います:

     >>> import os
     >>> filename = 'Sehenswürdigkeiten'
     >>> os.fsencode(filename)
     b'Sehensw\xc3\xbcrdigkeiten'

Some operating systems allow direct access to encoded bytes in the
environment.  If so, the *note os.supports_bytes_environ: 11e6. constant
will be true.

エンコードされた環境変数への直接アクセス (可能な場合) には、新規関数
*note os.getenvb(): 11e7. または *note os.environb: 11e8. を使ってくださ
い。これは *note os.environ: 118a. のバイト列バージョンです。

(Contributed by Victor Stinner.)


File: python.info,  Node: shutil<8>,  Next: sqlite3<11>,  Prev: os<13>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.24 shutil
................

*note shutil.copytree(): 9f7. 関数に新たに 2 つのオプションが追加されま
した:

   * 'ignore_dangling_symlinks': ‘symlinks=False’ とするとこの関数は、フ
     ァイルがシンボリックリンクだった場合にリンクそのものではなくそれが
     指しているファイルをコピーします。 'ignore_dangling_symlinks' を真
     にすると、そのファイルが存在しない場合のエラーを無視します。

   * 'copy_function': これはファイルをコピーするのに使われる呼び出し可能
     オブジェクトです。デフォルトでは *note shutil.copy2(): a29. が使わ
     れます。

(Contributed by Tarek Ziadé.)

これらに加え、 *note shutil: b3. モジュールは ZIP ファイル、未圧縮の tar
ファイル、gzip 圧縮の tar、 bzip 圧縮の tar のための *note archiving
operations: 11ea. を新たにサポートします。また、追加のアーカイブファイル
フォーマットを登録する関数もあります (例えば xz 圧縮の tar やカスタムフ
ォーマット)。

そのメインとなるのが *note make_archive(): 47f. と *note
unpack_archive(): 438. です。デフォルトではカレントディレクトリ (*note
os.chdir(): 5d8. で変えれます) とそのサブディレクトリの両方を処理します
。アーカイブファイル名はフルパス名で指定しなければなりません(訳注: これ
の真偽不明。リファレンスに対応する記述なし)。アーカイブするステップは非
破壊的です (つまりオリジナルのファイルは変更されずにそのままにされます
)。

     >>> import shutil, pprint

     >>> os.chdir('mydata')  # change to the source directory
     >>> f = shutil.make_archive('/var/backup/mydata',
     ...                         'zip')      # archive the current directory
     >>> f                                   # show the name of archive
     '/var/backup/mydata.zip'
     >>> os.chdir('tmp')                     # change to an unpacking
     >>> shutil.unpack_archive('/var/backup/mydata.zip')  # recover the data

     >>> pprint.pprint(shutil.get_archive_formats())  # display known formats
     [('bztar', "bzip2'ed tar-file"),
      ('gztar', "gzip'ed tar-file"),
      ('tar', 'uncompressed tar file'),
      ('zip', 'ZIP file')]

     >>> shutil.register_archive_format(     # register a new archive format
     ...     name='xz',
     ...     function=xz.compress,           # callable archiving function
     ...     extra_args=[('level', 8)],      # arguments to the function
     ...     description='xz compression'
     ... )

(Contributed by Tarek Ziadé.)


File: python.info,  Node: sqlite3<11>,  Next: html<3>,  Prev: shutil<8>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.25 sqlite3
.................

*note sqlite3: ba. モジュールが pysqlite バージョン 2.6.0 に更新されまし
た。これには 2 つの新機能があります。

   * The ‘sqlite3.Connection.in_transit’ attribute is true if there is
     an active transaction for uncommitted changes.

   * *note sqlite3.Connection.enable_load_extension(): 809. メソッドと
     *note sqlite3.Connection.load_extension(): 484. メソッドにより
     ".so" ファイルから SQLite 拡張をロードできます。良く知られた拡張の
     一つとして、SQLite と一緒に配布されている全文検索拡張があります。

(Contributed by R. David Murray and Shashwat Anand; bpo-8845(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8845


File: python.info,  Node: html<3>,  Next: socket<11>,  Prev: sqlite3<11>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.26 html
..............

ただ一つの関数 *note escape(): fd9. が提供される、新しい *note html: 61.
モジュールが導入されました。これは HTML マークアップから予約されている文
字をエスケープするのに使います:

     >>> import html
     >>> html.escape('x > 2 && x < 7')
     'x &gt; 2 &amp;&amp; x &lt; 7'


File: python.info,  Node: socket<11>,  Next: ssl<12>,  Prev: html<3>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.27 socket
................

*note socket: b8. モジュールに新たに二つの改善がありました。

   * Socket objects now have a *note detach(): 11ee. method which puts
     the socket into closed state without actually closing the
     underlying file descriptor.  The latter can then be reused for
     other purposes.  (Added by Antoine Pitrou; bpo-8524(1).)

   * *note socket.create_connection(): 63e. がコンテキスト管理プロトコル
     をサポートするようになりました。with ブロックを抜ける際に無条件にソ
     ケットをクローズします (クローズ処理で発生する *note socket.error:
     1029. は無視されます)。 (Contributed by Giampaolo Rodolà;
     bpo-9794(2).)  (--訳注: リファレンスもそうなのですが、「 *note
     socket.create_connection(): 63e. が with をサポート」というのは実態
     とは違うんじゃないかと思います(この関数のユーザからは同じにみえたと
     しても)。実際には *note socket.socket: d6e. がコンテキストマネージ
     ャをサポートしています。 socket.py(3) 参照。-)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8524

   (2) https://bugs.python.org/issue?@action=redirect&bpo=9794

   (3) https://hg.python.org/cpython/file/3.2/Lib/socket.py


File: python.info,  Node: ssl<12>,  Next: nntp,  Prev: socket<11>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.28 ssl
.............

*note ssl: bb. モジュールは、セキュアな (暗号化され、認証された) インタ
ーネット接続のために共通の要求を満足するための数多くの機能を追加していま
す:

   * 新規クラス *note SSLContext: 274. は、プロトコル設定や証明書、秘密
     鍵やそのた色々なオプションのような、永続的 SSL データの容器として働
     きます。その中のメソッド *note wrap_socket(): 4ee. を使うと、 SSL コ
     ンテキストから SSL ソケットを作れます。

   * A new function, ‘ssl.match_hostname()’, supports server identity
     verification for higher-level protocols by implementing the rules
     of HTTPS (from RFC 2818(1)) which are also suitable for other
     protocols.

   * The *note ssl.wrap_socket(): 4ee. constructor function now takes a
     'ciphers' argument.  The 'ciphers' string lists the allowed
     encryption algorithms using the format described in the OpenSSL
     documentation(2).

   * 最新版の OpenSSL にリンクしていれば、 *note ssl: bb. モジュールは
     TLS プロトコルに対する Server Name Indication 拡張 (訳注: SNI, RFC
     4366(3)) をサポートします。これは単一の IP ポートで異なった証明書を
     使った複数「バーチャルホスト」をもたらすものです。この拡張はクライ
     アントモードでのみサポートされ、 *note
     ssl.SSLContext.wrap_socket(): 4ee. の 'server_hostname' を渡すこと
     で活性化されます。

   * *note ssl: bb. モジュールに色々オプションが追加されました。例えば
     *note OP_NO_SSLv2: 804. は安全でなく時代遅れの SSLv2 を無効にします
     。

   * 拡張はOpenSSL の全ての暗号とメッセージダイジェストアルゴリズムをロ
     ードします。SSL 証明書の中に検証できないものがある場合、"unknown
     algorithm" エラーを報告します。

   * The version of OpenSSL being used is now accessible using the
     module attributes *note ssl.OPENSSL_VERSION: 11f0. (a string),
     *note ssl.OPENSSL_VERSION_INFO: 11f1. (a 5-tuple), and *note
     ssl.OPENSSL_VERSION_NUMBER: 11f2. (an integer).

(Contributed by Antoine Pitrou in bpo-8850(4), bpo-1589(5), bpo-8322(6),
bpo-5639(7), bpo-4870(8), bpo-8484(9), and bpo-8321(10).)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2818.html

   (2) https://docs.openssl.org/1.0.2/man1/ciphers/#cipher-list-format

   (3) https://datatracker.ietf.org/doc/html/rfc4366.html

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8850

   (5) https://bugs.python.org/issue?@action=redirect&bpo=1589

   (6) https://bugs.python.org/issue?@action=redirect&bpo=8322

   (7) https://bugs.python.org/issue?@action=redirect&bpo=5639

   (8) https://bugs.python.org/issue?@action=redirect&bpo=4870

   (9) https://bugs.python.org/issue?@action=redirect&bpo=8484

   (10) https://bugs.python.org/issue?@action=redirect&bpo=8321


File: python.info,  Node: nntp,  Next: certificates,  Prev: ssl<12>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.29 nntp
..............

The ‘nntplib’ module has a revamped implementation with better bytes and
text semantics as well as more practical APIs.  These improvements break
compatibility with the nntplib version in Python 3.1, which was partly
dysfunctional in itself.

Support for secure connections through both implicit (using
‘nntplib.NNTP_SSL’) and explicit (using ‘nntplib.NNTP.starttls()’) TLS
has also been added.

(Contributed by Antoine Pitrou in bpo-9360(1) and Andrew Vant in
bpo-1926(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9360

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1926


File: python.info,  Node: certificates,  Next: imaplib<4>,  Prev: nntp,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.30 certificates
......................

*note http.client.HTTPSConnection: b0f, *note
urllib.request.HTTPSHandler: 11f5. *note urllib.request.urlopen(): 273.
はサーバ証明書を証明書認証局 (Certification Authority (CA)) セットと照合
するためのオプショナル引数を取るようになりました。これは HTTPS の公共利
用で推奨されるものです。(--訳注: これは 'check_hostname' パラメータのこ
とを指していますが、3.4.3 でこれの扱いが変わっているのでリファレンスを注
意深く読んで下さい。-)

(Added by Antoine Pitrou, bpo-9003(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9003


File: python.info,  Node: imaplib<4>,  Next: http client<4>,  Prev: certificates,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.31 imaplib
.................

標準 IMAP4 接続での明示的な TLS 使用を新規メソッド *note
imaplib.IMAP4.starttls: 11f7. で出来るようになりました。

(Contributed by Lorenzo M. Catucci and Antoine Pitrou, bpo-4471(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4471


File: python.info,  Node: http client<4>,  Next: unittest<11>,  Prev: imaplib<4>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.32 http.client
.....................

*note http.client: 65. モジュールに数多くの小さな API 改善がなされていま
す。旧式 HTTP 0.9 の単純な応答 (HTTP 0.9 simple responses) はもうサポー
トされず、また、 'strict' パラメータは全てのクラスで非推奨となりました。

*note HTTPConnection: b0e. クラスと *note HTTPSConnection: b0f. クラスが
'source_address' パラメータを取るようになりました。これには HTTP(S) 接続
の接続元を表す (host, port) のタプルを渡します。

*note HTTPSConnection: b0f. に、証明書検証と HTTPS バーチャルホストのサ
ポートが追加されました。

接続オブジェクトの *note request(): c77. メソッドのオプショナルな 'body'
引数には、リクエストのコンテンツを与えるために *note file object: 1193.
を渡すことが出来ました。便利のためにこれに *note iterable: 10ad. も渡す
ことが出来るようになりました。ただしこの場合は明示的に ‘Content-Length’
ヘッダを加えなければなりません。この拡張されたインターフェイスは以前より
も遥かに柔軟です。

プロキシサーバ経由で HTTPS 接続を確立するために、新規メソッド *note
set_tunnel(): 11f9. が追加されています。これにより HTTP 接続トンネリング
のためのホストとポートをセットします。

*note http.server: 68. の振る舞いと合わせ、HTTP クライアントライブラリも
ヘッダを ISO-8859-1 (Latin-1) エンコーディングでエンコードするようになり
ました。これは既に incoming (外から来る方) ヘッダに対して行われています
が、今ではこの振る舞いは incoming、outgoing (外へ向かう方) トラフィック
の両方で一貫しています (bpo-10980(1) 内の Armin Ronacher による仕事を参
照)。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10980


File: python.info,  Node: unittest<11>,  Next: random<5>,  Prev: http client<4>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.33 unittest
..................

unittest モジュールに数多くの改善がありました。パッケージに対する test
discovery のサポートが追加され、対話プロンプトから実験しやすくなり、新し
いメソッドが追加され、テスト失敗時の診断メッセージが改善され、そしてメソ
ッド名がより良いものになりました。

   * The command-line call ‘python -m unittest’ can now accept file
     paths instead of module names for running specific tests
     (bpo-10620(1)).  The new test discovery can find tests within
     packages, locating any test importable from the top-level
     directory.  The top-level directory can be specified with the ‘-t’
     option, a pattern for matching files with ‘-p’, and a directory to
     start discovery with ‘-s’:

          $ python -m unittest discover -s my_proj_dir -p _test.py

     (Contributed by Michael Foord.)

   * Experimentation at the interactive prompt is now easier because the
     *note unittest.TestCase: 41a. class can now be instantiated without
     arguments:

          >>> from unittest import TestCase
          >>> TestCase().assertEqual(pow(2, 3), 8)

     (Contributed by Michael Foord.)

   * *note unittest: ef. モジュールは 2 つの新メソッド *note
     assertWarns(): 1137. と *note assertWarnsRegex(): 1138. を持ちます
     。これらはテストのもとでコードによって所与の警告が発行されるかどう
     かを検証します:

          with self.assertWarns(DeprecationWarning):
              legacy_function('XYZ')

     (Contributed by Antoine Pitrou, bpo-9754(2).)

     もう一つの新メソッド *note assertCountEqual(): 11fb. は 2 つのイテ
     ラブルを比較して、要素の出現回数が同じか (順序に関わらず同じ要素が
     同じ数だけ出現するかどうか) をテストします:

          def test_anagram(self):
              self.assertCountEqual('algorithm', 'logarithm')

     (Contributed by Raymond Hettinger.)

   * unittest モジュールの大事な特長は、テスト失敗時の有意義な診断を生成
     するよう腐心してくれることです。可能ならば失敗は期待値と実際の出力
     との差分と一緒に記録されます。これは失敗したテスト実行の解析に特に
     役に立ちますが、差分は時々とてつもなく大きくもなりますので、新たに
     追加した属性 *note maxDiff: 11fc. に差分の最大長をセットすることで
     表示を制御できるようになりました。

   * さらにモジュールのメソッド名に数多くのクリーンアップを行いました。

     For example, *note assertRegex(): 4f7. is the new name for
     ‘assertRegexpMatches()’ which was misnamed because the test uses
     *note re.search(): 11fd, not *note re.match(): 11fe.  Other methods
     using regular expressions are now named using short form "Regex" in
     preference to "Regexp" - this matches the names used in other
     unittest implementations, matches Python's old name for the *note
     re: a7. module, and it has unambiguous camel-casing.

     (Contributed by Raymond Hettinger and implemented by Ezio Melotti.)

   * 一貫性を向上させるために、長年使用されたメソッドエイリアスが推奨名
     に対し非推奨になりました:

          以前の名前                          推奨名
                                              
          -----------------------------------------------------------------------
                                              
          ‘assert_()’                         *note assertTrue(): 4f0.
                                              
                                              
          ‘assertEquals()’                    *note assertEqual(): 4f2.
                                              
                                              
          ‘assertNotEquals()’                 *note assertNotEqual(): 4f3.
                                              
                                              
          ‘assertAlmostEquals()’              *note assertAlmostEqual(): 4f4.
                                              
                                              
          ‘assertNotAlmostEquals()’           *note assertNotAlmostEqual(): 4f5.
                                              

     Likewise, the ‘TestCase.fail*’ methods deprecated in Python 3.1 are
     expected to be removed in Python 3.3.

     (Contributed by Ezio Melotti; bpo-9424(3).)

   * The ‘assertDictContainsSubset()’ method was deprecated because it
     was misimplemented with the arguments in the wrong order.  This
     created hard-to-debug optical illusions where tests like
     ‘TestCase().assertDictContainsSubset({'a':1, 'b':2}, {'a':1})’
     would fail.

     (Contributed by Raymond Hettinger.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10620

   (2) https://bugs.python.org/issue?@action=redirect&bpo=9754

   (3) https://bugs.python.org/issue?@action=redirect&bpo=9424


File: python.info,  Node: random<5>,  Next: poplib<4>,  Prev: unittest<11>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.34 random
................

*note random: a6. モジュールの整数メソッドの一様分布の生成が改善されまし
た。 以前は ‘int(n*random())’ を計算していました。 この方法では 'n' が
2の冪乗でない限り僅かにバイアスがあります。 現在の方法では次の2の冪乗の
範囲まで複数の選択肢を作成し、‘0 <= x < n’ の範囲に入ったもののみを保持
します。 影響を受ける関数やメソッドは *note randrange(): 837.、*note
randint(): 1200.、*note choice(): 1201.、*note shuffle(): 712. ならびに
*note sample(): 711. です。

(Contributed by Raymond Hettinger; bpo-9025(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9025


File: python.info,  Node: poplib<4>,  Next: asyncore<2>,  Prev: random<5>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.35 poplib
................

*note POP3_SSL: 8f3. クラスが 'context' パラメータを受け取れるようになり
ました。これには *note ssl.SSLContext: 274. オブジェクトを渡します。これ
は SSL コンフィグレーションオプション、証明書、秘密鍵を単一の (たぶん長
生きの) 構造にまとめあげてくれるものです。

(Contributed by Giampaolo Rodolà; bpo-8807(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8807


File: python.info,  Node: asyncore<2>,  Next: tempfile<5>,  Prev: poplib<4>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.36 asyncore
..................

‘asyncore.dispatcher’ now provides a ‘handle_accepted()’ method
returning a ‘(sock, addr)’ pair which is called when a connection has
actually been established with a new remote endpoint.  This is supposed
to be used as a replacement for old ‘handle_accept()’ and avoids the
user to call ‘accept()’ directly.

(Contributed by Giampaolo Rodolà; bpo-6706(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6706


File: python.info,  Node: tempfile<5>,  Next: inspect<10>,  Prev: asyncore<2>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.37 tempfile
..................

*note tempfile: c9. モジュールに新たなコンテキストマネージャ *note
TemporaryDirectory: 1205. が追加されました。一時ディレクトリの確実な後片
付けを容易に行えます:

     with tempfile.TemporaryDirectory() as tmpdirname:
         print('created temporary dir:', tmpdirname)

(Contributed by Neil Schemenauer and Nick Coghlan; bpo-5178(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5178


File: python.info,  Node: inspect<10>,  Next: pydoc<6>,  Prev: tempfile<5>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.38 inspect
.................

   * *note inspect: 72. モジュールに新たな関数 *note
     getgeneratorstate(): 1207. が追加されました。これで簡単にジェネレー
     タイテレータの現在状態を識別出来ます (--訳注: generator-iterator と
     いう用語を使っている箇所は Python ドキュメント全体通して多くはない
     のですが 2.x の *note yield 文: 99b. 説明中に登場します。ジェネレー
     タと同じ意味です。なお getgeneratorstate はジェネレータでないイテレ
     ータには使えません。--):

          >>> from inspect import getgeneratorstate
          >>> def gen():
          ...     yield 'demo'
          ...
          >>> g = gen()
          >>> getgeneratorstate(g)
          'GEN_CREATED'
          >>> next(g)
          'demo'
          >>> getgeneratorstate(g)
          'GEN_SUSPENDED'
          >>> next(g, None)
          >>> getgeneratorstate(g)
          'GEN_CLOSED'

     (Contributed by Rodolpho Eckhardt and Nick Coghlan, bpo-10220(1).)

   * 動的な属性を活性化することなく検索するのをサポートするために、
     *note inspect: 72. モジュールに *note getattr_static(): 461. 関数が
     追加されました。 *note hasattr(): 49e. とは違ってこれは本当に読み出
     しのみの検索であり、検索中に状態変更しないことが保障されています:

          >>> class A:
          ...     @property
          ...     def f(self):
          ...         print('Running')
          ...         return 10
          ...
          >>> a = A()
          >>> getattr(a, 'f')
          Running
          10
          >>> inspect.getattr_static(a, 'f')
          <property object at 0x1022bd788>

     (Contributed by Michael Foord.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10220


File: python.info,  Node: pydoc<6>,  Next: dis<5>,  Prev: inspect<10>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.39 pydoc
...............

The *note pydoc: a3. module now provides a much-improved web server
interface, as well as a new command-line option ‘-b’ to automatically
open a browser window to display that server:

     $ pydoc3.2 -b

(Contributed by Ron Adam; bpo-2001(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2001


File: python.info,  Node: dis<5>,  Next: dbm<7>,  Prev: pydoc<6>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.40 dis
.............

*note dis: 30. モジュールに、コードを調べるための 2 つの新しい関数 *note
code_info(): 120a. と *note show_code(): ef8. が追加されました。ともに、
与えられた関数、メソッド、ソースコード文字列、コードオブジェクトについて
の詳細なコードオブジェクト情報を提供します。前者はそれを文字列で返し、後
者は印字します:

     >>> import dis, random
     >>> dis.show_code(random.choice)
     Name:              choice
     Filename:          /Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/random.py
     Argument count:    2
     Kw-only arguments: 0
     Number of locals:  3
     Stack size:        11
     Flags:             OPTIMIZED, NEWLOCALS, NOFREE
     Constants:
        0: 'Choose a random element from a non-empty sequence.'
        1: 'Cannot choose from an empty sequence'
     Names:
        0: _randbelow
        1: len
        2: ValueError
        3: IndexError
     Variable names:
        0: self
        1: seq
        2: i

また、 *note dis(): b02. 関数が文字列引数を取れるようになり、これによっ
て、よくあるイディオム ‘dis(compile(s, '', 'eval'))’ は ‘dis(s)’ で一撃
です:

     >>> dis('3*x+1 if x%2==1 else x//2')
       1           0 LOAD_NAME                0 (x)
                   3 LOAD_CONST               0 (2)
                   6 BINARY_MODULO
                   7 LOAD_CONST               1 (1)
                  10 COMPARE_OP               2 (==)
                  13 POP_JUMP_IF_FALSE       28
                  16 LOAD_CONST               2 (3)
                  19 LOAD_NAME                0 (x)
                  22 BINARY_MULTIPLY
                  23 LOAD_CONST               1 (1)
                  26 BINARY_ADD
                  27 RETURN_VALUE
             >>   28 LOAD_NAME                0 (x)
                  31 LOAD_CONST               0 (2)
                  34 BINARY_FLOOR_DIVIDE
                  35 RETURN_VALUE

要はこれらによって、CPython がどう実装されているか探索してみたり、言語構
文が裏方で何をするのか見てみたりすることがより簡単になったということです
。

(Contributed by Nick Coghlan in bpo-9147(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9147


File: python.info,  Node: dbm<7>,  Next: ctypes<3>,  Prev: dis<5>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.41 dbm
.............

All database modules now support the ‘get()’ and ‘setdefault()’ methods.

(Suggested by Ray Allen in bpo-9523(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9523


File: python.info,  Node: ctypes<3>,  Next: site<4>,  Prev: dbm<7>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.42 ctypes
................

C ‘ssize_t’ データ型を表現する新たな型 *note ctypes.c_ssize_t: 120d. が
追加されました。


File: python.info,  Node: site<4>,  Next: sysconfig<3>,  Prev: ctypes<3>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.43 site
..............

*note site: b5. モジュールに、Python インストレーションの詳細を報告する
のに有益な3つの新たな関数が追加されました。

   * *note getsitepackages(): 120f. は全てのグローバルな site-packages デ
     ィレクトリを一覧します。

   * *note getuserbase(): 1210. は、ユーザのデータを格納できるベースディ
     レクトリを報告します。

   * *note getusersitepackages(): 1211. はユーザ固有の site-packages デ
     ィレクトリのパスを明らかにします。

     >>> import site
     >>> site.getsitepackages()
     ['/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/site-packages',
      '/Library/Frameworks/Python.framework/Versions/3.2/lib/site-python',
      '/Library/Python/3.2/site-packages']
     >>> site.getuserbase()
     '/Users/raymondhettinger/Library/Python/3.2'
     >>> site.getusersitepackages()
     '/Users/raymondhettinger/Library/Python/3.2/lib/python/site-packages'

便宜のために、いくつかの site の機能はコマンドラインから直接アクセス可能
です:

     $ python -m site --user-base
     /Users/raymondhettinger/.local
     $ python -m site --user-site
     /Users/raymondhettinger/.local/lib/python3.2/site-packages

(Contributed by Tarek Ziadé in bpo-6693(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6693


File: python.info,  Node: sysconfig<3>,  Next: pdb<8>,  Prev: site<4>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.44 sysconfig
...................

新しい *note sysconfig: c5. モジュールは、プラットフォームやインストレー
ションごとに変わるインストールパスや環境設定変数への、直接的なアクセスを
提供します。

このモジュールはプラットフォームとバージョンの情報へのシンプルなアクセス
関数を持っています:

   * *note get_platform(): 1213. は 'linux-i586' や 'macosx-10.6-ppc' と
     いった値を返します。

   * *note get_python_version(): 1214. は Python バージョンを文字列で
     "3.2" のように返します。

It also provides access to the paths and variables corresponding to one
of seven named schemes used by ‘distutils’.  Those include
'posix_prefix', 'posix_home', 'posix_user', 'nt', 'nt_user', 'os2',
'os2_home':

   * *note get_paths(): 1215. は現在のインストールスキームに関するインス
     トールパスを含むディレクトリ名を作ります。

   * *note get_config_vars(): ff6. はプラットフォーム依存変数の辞書を返
     します。

便利なコマンドラインインターフェースもあります:

     C:\Python32>python -m sysconfig
     Platform: "win32"
     Python version: "3.2"
     Current installation scheme: "nt"

     Paths:
             data = "C:\Python32"
             include = "C:\Python32\Include"
             platinclude = "C:\Python32\Include"
             platlib = "C:\Python32\Lib\site-packages"
             platstdlib = "C:\Python32\Lib"
             purelib = "C:\Python32\Lib\site-packages"
             scripts = "C:\Python32\Scripts"
             stdlib = "C:\Python32\Lib"

     Variables:
             BINDIR = "C:\Python32"
             BINLIBDEST = "C:\Python32\Lib"
             EXE = ".exe"
             INCLUDEPY = "C:\Python32\Include"
             LIBDEST = "C:\Python32\Lib"
             SO = ".pyd"
             VERSION = "32"
             abiflags = ""
             base = "C:\Python32"
             exec_prefix = "C:\Python32"
             platbase = "C:\Python32"
             prefix = "C:\Python32"
             projectbase = "C:\Python32"
             py_version = "3.2"
             py_version_nodot = "32"
             py_version_short = "3.2"
             srcdir = "C:\Python32"
             userbase = "C:\Documents and Settings\Raymond\Application Data\Python"

(Moved out of Distutils by Tarek Ziadé.)


File: python.info,  Node: pdb<8>,  Next: configparser<5>,  Prev: sysconfig<3>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.45 pdb
.............

*note pdb: 94. デバッガモジュールに数多くのユーザビリティの改善がなされ
ました:

   * ‘pdb.py’ は ‘-c’ オプションで指定した ‘.pdbrc’ スクリプトファイルを
     実行できるようになっています。

   * ‘.pdbrc’ スクリプトファイルにはデバッグを継続する ‘continue’ コマン
     ドと ‘next’ コマンドを含むことができます。

   * The *note Pdb: 8f0. class constructor now accepts a 'nosigint'
     argument.

   * 新コマンド: ‘l(list)’, ‘ll(long list)’, ‘source’ はソースコードを出
     力します。

   * 新コマンド: ‘display’, ‘undisplay’ は、変更があった場合の式の値の表
     示/非表示を切り替えます。

   * 新コマンド: ‘interact’ は現在のスコープで見つかったグローバルおよび
     ローカル名を含む対話型インタプリタを開始します。

   * ブレイクポイントをブレイクポイント番号指定でクリア出来ます。

(Contributed by Georg Brandl, Antonio Cuni and Ilya Sandler.)


File: python.info,  Node: configparser<5>,  Next: urllib parse<6>,  Prev: pdb<8>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.46 configparser
......................

The *note configparser: 1b. module was modified to improve usability and
predictability of the default parser and its supported INI syntax.  The
old ‘ConfigParser’ class was removed in favor of ‘SafeConfigParser’
which has in turn been renamed to *note ConfigParser: 1aa.  Support for
inline comments is now turned off by default and section or option
duplicates are not allowed in a single configuration source.

Config parsers はマッピングプロトコルにもとづく新しい API を獲得しました
:

     >>> parser = ConfigParser()
     >>> parser.read_string("""
     ... [DEFAULT]
     ... location = upper left
     ... visible = yes
     ... editable = no
     ... color = blue
     ...
     ... [main]
     ... title = Main Menu
     ... color = green
     ...
     ... [options]
     ... title = Options
     ... """)
     >>> parser['main']['color']
     'green'
     >>> parser['main']['editable']
     'no'
     >>> section = parser['options']
     >>> section['title']
     'Options'
     >>> section['title'] = 'Options (editable: %(editable)s)'
     >>> section['title']
     'Options (editable: no)'

新しい API は旧式 API の上に実装されているので、カスタムなパーサーサブク
ラスは変更なしで使えるはずです。

config parser によって受け付けられる INI ファイルの構造は今ではカスタマ
イズ出来ます。ユーザは、オプションと値を区切る代替のデリミタやコメントの
プレフィクスを指定でき、 'DEFAULT' セクションの名前を変えることができ、
あるいは補間の構文を切り替えられます。

抜き挿し可能 (pluggable) な補間サポートがあって、これには追加の補間ハン
ドラ *note ExtendedInterpolation: 6ee. が含まれています:

     >>> parser = ConfigParser(interpolation=ExtendedInterpolation())
     >>> parser.read_dict({'buildout': {'directory': '/home/ambv/zope9'},
     ...                   'custom': {'prefix': '/usr/local'}})
     >>> parser.read_string("""
     ... [buildout]
     ... parts =
     ...   zope9
     ...   instance
     ... find-links =
     ...   ${buildout:directory}/downloads/dist
     ...
     ... [zope9]
     ... recipe = plone.recipe.zope9install
     ... location = /opt/zope
     ...
     ... [instance]
     ... recipe = plone.recipe.zope9instance
     ... zope9-location = ${zope9:location}
     ... zope-conf = ${custom:prefix}/etc/zope.conf
     ... """)
     >>> parser['buildout']['find-links']
     '\n/home/ambv/zope9/downloads/dist'
     >>> parser['instance']['zope-conf']
     '/usr/local/etc/zope.conf'
     >>> instance = parser['instance']
     >>> instance['zope-conf']
     '/usr/local/etc/zope.conf'
     >>> instance['zope9-location']
     '/opt/zope'

小さな機能もたくさん導入されています。例えば読み込み操作内でのエンコーデ
ィング指定のサポート、取得関数でのフォールバック値の指定、あるいは辞書や
文字列から直接的に読むことなどです。

(All changes contributed by Łukasz Langa.)


File: python.info,  Node: urllib parse<6>,  Next: mailbox,  Prev: configparser<5>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.47 urllib.parse
......................

数多くのユーザビリティーの改善が *note urllib.parse: f3. モジュールにな
されました。

*note urlparse(): 2e5. 関数が RFC 2732(1) にて記述されている IPv6(2) ア
ドレスをサポートするようになりました:

     >>> import urllib.parse
     >>> urllib.parse.urlparse('http://[dead:beef:cafe:5417:affe:8FA3:deaf:feed]/foo/')
     ParseResult(scheme='http',
                 netloc='[dead:beef:cafe:5417:affe:8FA3:deaf:feed]',
                 path='/foo/',
                 params='',
                 query='',
                 fragment='')

*note urldefrag(): 1219. 関数は、今や *note named tuple: 61a. を返します
:

     >>> r = urllib.parse.urldefrag('http://python.org/about/#target')
     >>> r
     DefragResult(url='http://python.org/about/', fragment='target')
     >>> r[0]
     'http://python.org/about/'
     >>> r.fragment
     'target'

また、 *note urlencode(): e5e. 関数はさらに柔軟になり、 'query' 引数とし
ては文字列とバイト列のどちらも受け付けます。文字列で渡した場合、パラメー
タ 'safe', 'encoding', 'error' がエンコードのために *note quote_plus():
121a. に送られます:

     >>> urllib.parse.urlencode([
     ...      ('type', 'telenovela'),
     ...      ('name', '¿Dónde Está Elisa?')],
     ...      encoding='latin-1')
     'type=telenovela&name=%BFD%F3nde+Est%E1+Elisa%3F'

*note ASCII エンコードバイト列の解析: 121b. に詳細に書きましたが、全ての
*note urllib.parse: f3. 関数は今では ASCII エンコードされたバイト文字列
を (通常の文字列と混ぜない限り) 入力として受け付けます。ASCII エンコード
されたバイト文字列がパラメータとして与えられると、戻り値の型も ASCII エ
ンコードされたバイト文字列になります:

     >>> urllib.parse.urlparse(b'http://www.python.org:80/about/')
     ParseResultBytes(scheme=b'http', netloc=b'www.python.org:80',
                      path=b'/about/', params=b'', query=b'', fragment=b'')

(Work by Nick Coghlan, Dan Mahn, and Senthil Kumaran in bpo-2987(3),
bpo-5468(4), and bpo-9873(5).)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2732.html

   (2) https://ja.wikipedia.org/wiki/IPv6

   (3) https://bugs.python.org/issue?@action=redirect&bpo=2987

   (4) https://bugs.python.org/issue?@action=redirect&bpo=5468

   (5) https://bugs.python.org/issue?@action=redirect&bpo=9873


File: python.info,  Node: mailbox,  Next: turtledemo,  Prev: urllib parse<6>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.48 mailbox
.................

R. David Murray がコミュニティの調整に尽力したおかげで、 *note mailbox:
7f. が Python 3.2 のために修正されました。闘いを挑んだ相手はもともとの
mailbox 設計のテキストインターフェイスでした。ですが email メッセージは
個々の異なるパートが異なるエンコーディングを持ち得ますから、 *note
bytes: 1a4. が最良の表現です。

解決のためには任意の email メッセージをパースするために、 *note email:
32. パッケージのバイナリサポートが利用されました (--訳注: *note
BytesGenerator: 119f. や *note message_from_bytes(): 1199. など)。また、
API の変更も必要となりました。

*note mailbox.Mailbox: 121d. オブジェクトの *note add(): 121e. メソッド
は、今や期待通りにバイナリ入力を受け付けます。

*note StringIO: ef3. とテキストファイルでの入力は非推奨となりました。ま
た、文字列での入力は、非 ASCII 文字が使用されていると早々に失敗します。
以前は後のほうのステップで email が処理される際にようやく失敗していまし
た。

バイナリ出力のサポートもあります。 *note get_file(): 121f. メソッドは今
ではバイナリモードのファイルを返します (これまでは不適切にテキストモード
が使われていました)。また、新しい *note get_bytes(): 1220. メソッドは、
指定した 'key' に対応するメッセージの *note bytes: 1a4. 表現を返します。

今でも古い API の *note get_string(): 1221. を使って非バイナリ出力は可能
ですが、そのアプローチはあまり役に立ちません。そうではなく *note
Message: 1222. オブジェクトからメッセージを抽出するか、それらをバイナリ
入力からロードするのが最善です。

(Contributed by R. David Murray, with efforts from Steffen Daode
Nurpmeso and an initial patch by Victor Stinner in bpo-9124(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=9124


File: python.info,  Node: turtledemo,  Prev: mailbox,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール

1.12.9.49 turtledemo
....................

The demonstration code for the *note turtle: ea. module was moved from
the 'Demo' directory to main library.  It includes over a dozen sample
scripts with lively displays.  Being on *note sys.path: 38e, it can now
be run directly from the command-line:

     $ python -m turtledemo

(Moved from the Demo directory by Alexander Belopolsky in bpo-10199(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10199


File: python.info,  Node: マルチスレッディング,  Next: 最適化<9>,  Prev: 新たなモジュール、改良されたモジュール、非推奨のモジュール,  Up: What's New In Python 3 2

1.12.10 マルチスレッディング
----------------------------

   * The mechanism for serializing execution of concurrently running
     Python threads (generally known as the *note GIL: 13f. or Global
     Interpreter Lock) has been rewritten.  Among the objectives were
     more predictable switching intervals and reduced overhead due to
     lock contention and the number of ensuing system calls.  The notion
     of a "check interval" to allow thread switches has been abandoned
     and replaced by an absolute duration expressed in seconds.  This
     parameter is tunable through *note sys.setswitchinterval(): 918.
     It currently defaults to 5 milliseconds.

     この実装に関するさらなる詳細は python-dev mailing-list message(1) で
     読むことが出来ます (ただしこのメッセージで言っている "priority
     requests" は含められませんでした)。

     (Contributed by Antoine Pitrou.)

   * 通常のロックと再帰的なロックが、*note acquire(): 664. メソッドでオ
     プションで 'timeout' 引数を受け取るようになりました。 (Contributed
     by Antoine Pitrou; bpo-7316(2).)

   * 同様に、*note threading.Semaphore.acquire(): 1225. にも 'timeout' 引
     数が追加されました。 (Contributed by Torsten Landschoff;
     bpo-850728(3).)

   * 通常のロックと再帰的なロックの獲得に、 Pthreads を使用するプラット
     フォームでシグナルが割り込めるようになりました。これでロック獲得時
     にデッドロックしていた Python プログラムは、プロセスに SIGINT (ほと
     んどのシェルでは ‘Ctrl+C’ で) を繰り返し送ることで殺せます。
     (Contributed by Reid Kleckner; bpo-8844(4).)

   ---------- Footnotes ----------

   (1) 
https://mail.python.org/pipermail/python-dev/2009-October/093321.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=7316

   (3) https://bugs.python.org/issue?@action=redirect&bpo=850728

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8844


File: python.info,  Node: 最適化<9>,  Next: Unicode 文字列型,  Prev: マルチスレッディング,  Up: What's New In Python 3 2

1.12.11 最適化
--------------

小さな性能向上が多く追加されました:

   * Python's peephole optimizer now recognizes patterns such ‘x in {1,
     2, 3}’ as being a test for membership in a set of constants.  The
     optimizer recasts the *note set: 5a3. as a *note frozenset: 5a4.
     and stores the pre-built constant.

     Now that the speed penalty is gone, it is practical to start
     writing membership tests using set-notation.  This style is both
     semantically clear and operationally fast:

          extension = name.rpartition('.')[2]
          if extension in {'xml', 'html', 'xhtml', 'css'}:
              handle(name)

     (Patch and additional tests contributed by Dave Malcolm;
     bpo-6690(1)).

   * *note pickle: 95. モジュールを用いたデータのシリアライズ・デシリア
     ライズが数倍速くなりました。

     (Contributed by Alexandre Vassalotti, Antoine Pitrou and the
     Unladen Swallow team in bpo-9410(2) and bpo-3873(3).)

   * The Timsort algorithm(4) used in *note list.sort(): b9d. and *note
     sorted(): b9c. now runs faster and uses less memory when called
     with a *note key function: dd2.  Previously, every element of a
     list was wrapped with a temporary object that remembered the key
     value associated with each element.  Now, two arrays of keys and
     values are sorted in parallel.  This saves the memory consumed by
     the sort wrappers, and it saves time lost to delegating
     comparisons.

     (Patch by Daniel Stutzbach in bpo-9915(5).)

   * JSON decoding performance is improved and memory consumption is
     reduced whenever the same string is repeated for multiple keys.
     Also, JSON encoding now uses the C speedups when the ‘sort_keys’
     argument is true.

     (Contributed by Antoine Pitrou in bpo-7451(6) and by Raymond
     Hettinger and Antoine Pitrou in bpo-10314(7).)

   * 再帰的ロック (*note threading.RLock(): 2bf. API により生成) は C で
     実装されたことにより、以前の純粋な Python 実装より10から15倍速くな
     り、通常のロックと同じくらいになりました。

     (Contributed by Antoine Pitrou; bpo-3001(8).)

   * The fast-search algorithm in stringlib is now used by the *note
     split(): e73, *note rsplit(): 1227, *note splitlines(): 1228. and
     *note replace(): 17f. methods on *note bytes: 1a4, *note bytearray:
     508. and *note str: 418. objects.  Likewise, the algorithm is also
     used by *note rfind(): e72, *note rindex(): 1229, *note rsplit():
     1227. and *note rpartition(): 122a.

     (Patch by Florent Xicluna in bpo-7622(9) and bpo-7462(10).)

   * Integer to string conversions now work two "digits" at a time,
     reducing the number of division and modulo operations.

     (bpo-6713(11) by Gawain Bolton, Mark Dickinson, and Victor
     Stinner.)

There were several other minor optimizations.  Set differencing now runs
faster when one operand is much larger than the other (patch by Andress
Bennetts in bpo-8685(12)).  The ‘array.repeat()’ method has a faster
implementation (bpo-1569291(13) by Alexander Belopolsky).  The *note
BaseHTTPRequestHandler: 109e. has more efficient buffering (bpo-3709(14)
by Andrew Schaaf).  The *note operator.attrgetter(): e00. function has
been sped-up (bpo-10160(15) by Christos Georgiou).  And *note
ConfigParser: 1aa. loads multi-line arguments a bit faster (bpo-7113(16)
by Łukasz Langa).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6690

   (2) https://bugs.python.org/issue?@action=redirect&bpo=9410

   (3) https://bugs.python.org/issue?@action=redirect&bpo=3873

   (4) https://en.wikipedia.org/wiki/Timsort

   (5) https://bugs.python.org/issue?@action=redirect&bpo=9915

   (6) https://bugs.python.org/issue?@action=redirect&bpo=7451

   (7) https://bugs.python.org/issue?@action=redirect&bpo=10314

   (8) https://bugs.python.org/issue?@action=redirect&bpo=3001

   (9) https://bugs.python.org/issue?@action=redirect&bpo=7622

   (10) https://bugs.python.org/issue?@action=redirect&bpo=7462

   (11) https://bugs.python.org/issue?@action=redirect&bpo=6713

   (12) https://bugs.python.org/issue?@action=redirect&bpo=8685

   (13) https://bugs.python.org/issue?@action=redirect&bpo=1569291

   (14) https://bugs.python.org/issue?@action=redirect&bpo=3709

   (15) https://bugs.python.org/issue?@action=redirect&bpo=10160

   (16) https://bugs.python.org/issue?@action=redirect&bpo=7113


File: python.info,  Node: Unicode 文字列型,  Next: Codecs,  Prev: 最適化<9>,  Up: What's New In Python 3 2

1.12.12 Unicode 文字列型
------------------------

Python has been updated to Unicode 6.0.0(1).  The update to the standard
adds over 2,000 new characters including emoji(2) symbols which are
important for mobile phones.

In addition, the updated standard has altered the character properties
for two Kannada characters (U+0CF1, U+0CF2) and one New Tai Lue numeric
character (U+19DA), making the former eligible for use in identifiers
while disqualifying the latter.  For more information, see Unicode
Character Database Changes(3).

   ---------- Footnotes ----------

   (1) https://unicode.org/versions/Unicode6.0.0/

   (2) https://en.wikipedia.org/wiki/Emoji

   (3) https://www.unicode.org/versions/Unicode6.0.0/#Database_Changes


File: python.info,  Node: Codecs,  Next: ドキュメント,  Prev: Unicode 文字列型,  Up: What's New In Python 3 2

1.12.13 Codecs
--------------

'cp720' アラビア DOS エンコードがサポートされました (bpo-1616979(1))。

MBCS エンコーディングはもうエラーハンドラ引数を無視することはありません
。デフォルトの strict モードでは、デコード出来ないバイト列に対して *note
UnicodeDecodeError: 9e1. を、エンコードできない文字に対して *note
UnicodeEncodeError: 643. を投げます。

MBCS コーデックはエラーハンドラとして、デコードでの ‘'strict'’ と
‘'ignore'’ 、エンコードでの ‘'strict'’ と ‘'replace'’ をサポートします。

Python 3.1 での MBCS エンコーディングを模擬したければデコードでは
‘'ignore'’ ハンドラを、エンコードでは ‘'replace'’ ハンドラを選んでくださ
い。

Mac OS X では Python は、コマンドライン引数をロケールのエンコーディング
ではなく ‘'utf-8'’ でデコードします。

*note tarfile: c8. はデフォルトで、Windows では (‘'mbcs'’ ではなく)
‘'utf-8'’ エンコーディングを使い、また、全ての OS でエラーハンドラ
‘'surrogateescape'’ を使います。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1616979


File: python.info,  Node: ドキュメント,  Next: IDLE,  Prev: Codecs,  Up: What's New In Python 3 2

1.12.14 ドキュメント
--------------------

ドキュメントの改善が引き続き行われています。

   * *note 組み込み関数: 122e. のような長大なセクションには先頭にクイッ
     クリンクの表が追加されました。 *note itertools: 75. のようなケース
     では cheatsheet(1) スタイルの表からリンクが張られていて、これで要約
     がわかりますし、ドキュメント全体を読む必要なく記憶を呼び覚ますこと
     が出来ます。

   * ある種のケースではピュア Python のソースコードが文書化の助手として
     便利に働いてくれますので、今では多くのモジュールがソースコードの最
     新バージョンへのクイックリンクを客演させています。例えば *note
     functools: 55. モジュールのドキュメントは先頭にこのようにクイックリ
     ンクを置いています:

          'ソースコード' Lib/functools.py(2).

     (Contributed by Raymond Hettinger; see rationale(3).)

   * ドキュメントには今ではもっと実例とレシピが含まれています。特に
     *note re: a7. モジュールのものには大掛かりなセクション *note
     正規表現の例: 122f. があります。同じように *note itertools: 75. で
     は新しい *note Itertools レシピ: 1230. で更新され続けます。

   * *note datetime: 28. モジュールは今ではピュア Python による補助実装
     を持っています。機能に違いはありません。これは読みやすい代替の実装
     を提供するだけのものです。

     (Contributed by Alexander Belopolsky in bpo-9528(4).)

   * 保守されていなかった ‘Demo’ ディレクトリは削除されました。いくつか
     のデモはドキュメントに統合され、いくつかは ‘Tools/demo’ ディレクト
     リに移動し、ほかのものは一緒に削除されました。

     (Contributed by Georg Brandl in bpo-7962(5).)

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Cheat_sheet

   (2) https://github.com/python/cpython/tree/3.13/Lib/functools.py

   (3) 
https://rhettinger.wordpress.com/2011/01/28/open-your-source-more/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=9528

   (5) https://bugs.python.org/issue?@action=redirect&bpo=7962


File: python.info,  Node: IDLE,  Next: コードリポジトリ,  Prev: ドキュメント,  Up: What's New In Python 3 2

1.12.15 IDLE
------------

   * IDLE のフォーマットメニューに、ソースコードから末尾の空白を取り除く
     ことが出来るオプションが追加されました。

     (Contributed by Raymond Hettinger; bpo-5150(1).)

   * Mac OS X 上の IDLE が Carbon AquaTk と Cocoa AquaTk の両方で動くよ
     うになりました。

     (Contributed by Kevin Walzer, Ned Deily, and Ronald Oussoren;
     bpo-6075(2).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5150

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6075


File: python.info,  Node: コードリポジトリ,  Next: ビルドならびに C API の変更<5>,  Prev: IDLE,  Up: What's New In Python 3 2

1.12.16 コードリポジトリ
------------------------

In addition to the existing Subversion code repository at
‘https://svn.python.org’ there is now a Mercurial(1) repository at
‘https://hg.python.org/’.

3.2 のリリース後に、主要なリポジトリを Mercurial に移行する計画がありま
す。 この分散バージョン管理システムによってコミュニティメンバが容易に外
部 changeset を作成したり共有したりすることが出来ます。 詳細は PEP
385(2) を参照してください。

To learn to use the new version control system, see the Quick Start(3)
or the Guide to Mercurial Workflows(4).

   ---------- Footnotes ----------

   (1) https://www.mercurial-scm.org/

   (2) https://peps.python.org/pep-0385/

   (3) https://www.mercurial-scm.org/wiki/QuickStart

   (4) https://www.mercurial-scm.org/guide


File: python.info,  Node: ビルドならびに C API の変更<5>,  Next: Python 3 2 への移植,  Prev: コードリポジトリ,  Up: What's New In Python 3 2

1.12.17 ビルドならびに C API の変更
-----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * スクリプト 'idle', 'pydoc', '2to3' が ‘make altinstall’ 時にバージ
     ョン固有のサフィックスを付けてインストールされるようになりました
     (bpo-10679(1))。

   * Unicode データベースにアクセスする関数 (Py_UNICODE_TOLOWER,
     Py_UNICODE_ISDECIMAL, ほか) が、たとえ narrow Unicode ビルドであっ
     ても full Unicode 範囲を受け付け、返すようになりました。Python から
     目に見える違いとしては、大きなコードポイントについて *note
     unicodedata.numeric(): 1234. が正しい値を返し、 *note repr(): 7c8.
     はより多くの文字を表示可能と考えるようになりました。

     (Reported by Bupjoe Lee and fixed by Amaury Forgeot D'Arc;
     bpo-5127(2).)

   * Computed gotos are now enabled by default on supported compilers
     (which are detected by the configure script).  They can still be
     disabled selectively by specifying ‘--without-computed-gotos’.

     (Contributed by Antoine Pitrou; bpo-9203(3).)

   * オプション ‘--with-wctype-functions’ は削除されました。今では組み込
     みの Unicode データベースが全ての関数のために使われます。

     (Contributed by Amaury Forgeot D'Arc; bpo-9210(4).)

   * ハッシュ値として新しい型 *note Py_hash_t: 1235. を使うようになりま
     した。これはポインタと同じサイズになるように定義されています。以前
     は long 型を使っていましたが、これはいくつかの 64 ビット OS でも 32
     ビット長のままでした。この修正の結果、64 ビットポインタでビルドすれ
     ば *note set: 5a3. と *note dict: 237. が ‘2**32’ 以上のエントリを
     持てるようになりました (以前もそのサイズを入れることは出来ましたが
     、悲劇的なパフォーマンス低下を起こしていました)。

     (Suggested by Raymond Hettinger and implemented by Benjamin
     Peterson; bpo-9778(5).)

   * A new macro ‘Py_VA_COPY’ copies the state of the variable argument
     list.  It is equivalent to C99 'va_copy' but available on all
     Python platforms (bpo-2443(6)).

   * A new C API function ‘PySys_SetArgvEx()’ allows an embedded
     interpreter to set *note sys.argv: 1236. without also modifying
     *note sys.path: 38e. (bpo-5753(7)).

   * ‘PyEval_CallObject()’ is now only available in macro form.  The
     function declaration, which was kept for backwards compatibility
     reasons, is now removed - the macro was introduced in 1997
     (bpo-8276(8)).

   * *note PyLong_AsLongAndOverflow(): 1237. の姉妹品の *note
     PyLong_AsLongLongAndOverflow(): 1238. 関数が追加されました。両方と
     も Python *note int: 238. を C ネイティブの固定幅型に変換しますが、
     変換が幅に合わないことを検出します (bpo-7767(9))。

   * *note PyUnicode_CompareWithASCIIString(): 1239. 関数が、Python 文字
     列が 'NUL' 終端である場合に「 '等しくない' 」を返すようになりました
     。

   * 新しい関数 *note PyErr_NewExceptionWithDoc(): 123a. は *note
     PyErr_NewException(): 123b. と似ていますが、ドキュメンテーション文
     字列を受け付けます。これは C 拡張に、対応するピュア Python と同じ自
     己文書化 (self-documenting) 能力を与えます (bpo-7033(10))。

   * ‘--with-valgrind’ オプションとともにコンパイル時、 Valgrind のもと
     での実行時に自動的に pymalloc アロケータが無効になるようになりまし
     た。ほかの状況では pymalloc は有利ですが、Valgrind 配下での実行時の
     メモリリーク検出では無効化したほうが良い結果が得られます
     (bpo-2422(11))。

   * 'PyArg_Parse' 関数から書式文字列 ‘O?’ が削除されました。これはもう
     使われていませんし、今まで一度も文書化されたことはありません
     (bpo-8837(12))。

There were a number of other small changes to the C-API. See the
Misc/NEWS(13) file for a complete list.

Also, there were a number of updates to the Mac OS X build, see
Mac/BuildScript/README.txt(14) for details.  For users running a
32/64-bit build, there is a known problem with the default Tcl/Tk on Mac
OS X 10.6.  Accordingly, we recommend installing an updated alternative
such as ActiveState Tcl/Tk 8.5.9(15).  See
‘https://www.python.org/download/mac/tcltk/’ for additional details.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10679

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5127

   (3) https://bugs.python.org/issue?@action=redirect&bpo=9203

   (4) https://bugs.python.org/issue?@action=redirect&bpo=9210

   (5) https://bugs.python.org/issue?@action=redirect&bpo=9778

   (6) https://bugs.python.org/issue?@action=redirect&bpo=2443

   (7) https://bugs.python.org/issue?@action=redirect&bpo=5753

   (8) https://bugs.python.org/issue?@action=redirect&bpo=8276

   (9) https://bugs.python.org/issue?@action=redirect&bpo=7767

   (10) https://bugs.python.org/issue?@action=redirect&bpo=7033

   (11) https://bugs.python.org/issue?@action=redirect&bpo=2422

   (12) https://bugs.python.org/issue?@action=redirect&bpo=8837

   (13) https://github.com/python/cpython/blob/v3.2.6/Misc/NEWS

   (14) 
https://github.com/python/cpython/blob/v3.2.6/Mac/BuildScript/README.txt

   (15) 
https://web.archive.org/web/20101208191259/https://www.activestate.com/activetcl/downloads


File: python.info,  Node: Python 3 2 への移植,  Prev: ビルドならびに C API の変更<5>,  Up: What's New In Python 3 2

1.12.18 Python 3.2 への移植
---------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

   * The *note configparser: 1b. module has a number of clean-ups.  The
     major change is to replace the old ‘ConfigParser’ class with
     long-standing preferred alternative ‘SafeConfigParser’.  In
     addition there are a number of smaller incompatibilities:

        * 補間 (interpolation) の構文は今では *note get(): 123d. と
          *note set(): 123e. の操作で検証されます。デフォルトの補間スキ
          ームでは、パーセント記号を使ったただ二つのトークンのみが正当で
          す: ‘%(name)s’ と ‘%%’ 、後者はエスケープされたパーセント記号
          自身。

        * *note set(): 123e. メソッドと *note add_section(): 123f. メソ
          ッドは今ではその値が実際に文字列かどうかを検証します。以前はサ
          ポートされない型が意図せず持ち込まれる可能性がありました。

        * 単一ソースからのセクションまたはオプションの複製 (重複) に対し
          、今では *note DuplicateSectionError: 1240. もしくは *note
          DuplicateOptionError: 1241. を投げます。以前は重複は黙って以前
          のエントリを上書きしていました。

        * インラインコメントは今ではデフォルトで無効なので、 ';' 文字を
          安全に値のなかで使えます。

        * コメントを字下げ出来るようになっています。このことにより、値が
          継続行となる場合の後続行の字下げ開始位置に ';' または '#' を置
          くには、補間を使う必要があります。こうすればコメントのプレフィ
          クス文字が値内に現れて誤ってコメントと解釈されるのを防げます。

        * ‘""’ は今では合法な値なので、もはや自動的に空文字列に変換され
          ることはありません。空文字列のためには行内で ‘"option ="’ と書
          いてください。

   * The ‘nntplib’ module was reworked extensively, meaning that its
     APIs are often incompatible with the 3.1 APIs.

   * *note bytearray: 508. オブジェクトはもうファイル名には使えません。
     代わりに *note bytes: 1a4. に変換しなければいけません。

   * The ‘array.tostring()’ and ‘array.fromstring()’ have been renamed
     to *note array.tobytes(): 1242. and *note array.frombytes(): 1243.
     for clarity.  The old names have been deprecated.  (See
     bpo-8990(1).)

   * ‘PyArg_Parse*()’ 系関数:

        * 書式文字列 "t#" の削除: 代わりに "s#" もしくは "s*" を使ってく
          ださい。

        * 書式文字列 "w" および "w#" の削除: 代わりに "w*" を使ってくだ
          さい。

   * The ‘PyCObject’ type, deprecated in 3.1, has been removed.  To wrap
     opaque C pointers in Python objects, the *note PyCapsule: 1244. API
     should be used instead; the new type has a well-defined interface
     for passing typing safety information and a less complicated
     signature for calling a destructor.

   * The ‘sys.setfilesystemencoding()’ function was removed because it
     had a flawed design.

   * *note random.seed(): 1245. 関数とメソッドが、salt に文字列やバイト
     列を与えた場合に内部で sha512 ハッシュ関数を使うようになりました。
     Python 3.1 シーケンスを再現するのに以前のバージョンの 'seed' が必要
     であれば、 'version' 引数を '1' にしてください。 ‘random.seed(s,
     version=1)’ のように。

   * The previously deprecated ‘string.maketrans()’ function has been
     removed in favor of the static methods *note bytes.maketrans():
     1246. and *note bytearray.maketrans(): 1247.  This change solves
     the confusion around which types were supported by the *note
     string: be. module.  Now, *note str: 418, *note bytes: 1a4, and
     *note bytearray: 508. each have their own 'maketrans' and
     'translate' methods with intermediate translation tables of the
     appropriate type.

     (Contributed by Georg Brandl; bpo-5675(2).)

   * The previously deprecated ‘contextlib.nested()’ function has been
     removed in favor of a plain *note with: 59c. statement which can
     accept multiple context managers.  The latter technique is faster
     (because it is built-in), and it does a better job finalizing
     multiple context managers when one of them raises an exception:

          with open('mylog.txt') as infile, open('a.out', 'w') as outfile:
              for line in infile:
                  if '<critical>' in line:
                      outfile.write(line)

     (Georg Brandl と Mattias Brändström の貢献; appspot issue
     53094(3).)

   * *note struct.pack(): 1248. は、文字列パックコード ‘s’ で bytes のみ
     を許容するようになりました。以前はテキスト引数を受け取って暗黙に
     UTF-8 でエンコードして bytes に変換していました。特定のエンコーディ
     ングを前提にするのは間違っていますし、可変長のエンコーディングは構
     造体の固定長セグメントへの書き込みで失敗しうるので、これは問題でし
     た。

     例えば ‘struct.pack('<6sHHBBB', 'GIF87a', x, y)’ としているならば、
     テキストではなく bytes を使うように ‘struct.pack('<6sHHBBB',
     b'GIF87a', x, y)’ と書き換えなければなりません。

     (Discovered by David Beazley and fixed by Victor Stinner;
     bpo-10783(4).)

   * パース失敗時に *note xml.etree.ElementTree: 10c. クラスが *note
     xml.etree.ElementTree.ParseError: 1249. を投げるようになりました。
     以前は *note xml.parsers.expat.ExpatError: 124a. を投げていました。

   * 浮動小数点数と複素数に対する *note str(): 418. が以前より長い表現を
     するようになったことで、古いフォーマットに依存する doctest は壊れる
     かもしれません。

   * *note subprocess.Popen: 17e. の 'close_fds' のデフォルトが、Unix で
     は ‘True’ になりました。Windows では 3 つの標準ストリームに ‘None’
     がセットされている場合には ‘True’ 、以外の場合は ‘False’ になりまし
     た。以前は 'close_fds' のデフォルトはいつでも ‘False’ でした。これ
     は開いているファイル記述子が子プロセスに漏れた場合に解決が難しいバ
     グや競合状態を生み出していました。

   * レガシーな HTTP 0.9 のサポートが *note urllib.request: f4. と *note
     http.client: 65. から削除されました。このサポートはサーバサイドでは
     まだ健在です (*note http.server: 68. 内)。

     (Contributed by Antoine Pitrou, bpo-10711(5).)

   * タイムアウトモード時の SSL ソケットでタイムアウトした場合に、汎用の
     *note SSLError: 124b. ではなく *note socket.timeout: 7ff. を投げる
     ようになりました。

     (Contributed by Antoine Pitrou, bpo-10272(6).)

   * The misleading functions ‘PyEval_AcquireLock()’ and
     ‘PyEval_ReleaseLock()’ have been officially deprecated.  The
     thread-state aware APIs (such as *note PyEval_SaveThread(): 382.
     and *note PyEval_RestoreThread(): 383.) should be used instead.

   * Due to security risks, ‘asyncore.handle_accept()’ has been
     deprecated, and a new function, ‘asyncore.handle_accepted()’, was
     added to replace it.

     (Contributed by Giampaolo Rodola in bpo-6706(7).)

   * Due to the new *note GIL: 13f. implementation,
     ‘PyEval_InitThreads()’ cannot be called before *note
     Py_Initialize(): 87a. anymore.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8990

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5675

   (3) https://codereview.appspot.com/53094

   (4) https://bugs.python.org/issue?@action=redirect&bpo=10783

   (5) https://bugs.python.org/issue?@action=redirect&bpo=10711

   (6) https://bugs.python.org/issue?@action=redirect&bpo=10272

   (7) https://bugs.python.org/issue?@action=redirect&bpo=6706


File: python.info,  Node: What's New In Python 3 1,  Next: What's New In Python 3 0,  Prev: What's New In Python 3 2,  Up: What's New in Python

1.13 What's New In Python 3.1
=============================


著者: Raymond Hettinger

この記事では 3.0 と比較した Python 3.1 の新機能を解説します。Python 3.1
は2009年6月27日にリリースされました。

* Menu:

* PEP 372; 順序付き辞書: PEP 372 順序付き辞書.
* PEP 378; 1000区切りのための書式指定子: PEP 378 1000区切りのための書式指定子.
* その他の言語変更: その他の言語変更<11>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>.
* 最適化: 最適化<10>.
* IDLE: IDLE<2>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<6>.
* Python 3.1 への移植: Python 3 1 への移植.


File: python.info,  Node: PEP 372 順序付き辞書,  Next: PEP 378 1000区切りのための書式指定子,  Up: What's New In Python 3 1

1.13.1 PEP 372: 順序付き辞書
----------------------------

通常の Python 辞書は、 key/value ペアを不定の順序でイテレートします。何
年にもわたり、いろいろな人が key の挿入順を保存する辞書の別実装を書いて
きました。その経験に基づき、新しい *note OrderedDict: 5a5. クラスが導入
されました。

OrderedDict API は通常の辞書と同じインターフェースを提供していますが、
key/value をイテレートするときに key が最初に挿入された順番になることが
保証されています。新しいエントリが既存のエントリを上書きした場合は、元の
挿入順序が保持されます。エントリを削除して再挿入すると、順序は一番最後に
移動します。

標準ライブラリのいくつかのモジュールで、順序付き辞書の利用がサポートされ
ています。*note configparser: 1b. モジュールはデフォルトで順序付き辞書を
使います。設定ファイルを読み込み、編集した後、元の順序で書きなおすことが
できます。*note collections.namedtuple(): 1ac. の '_asdict()' メソッドは
、タプルの順序と同じ順序の順序付き辞書を返すようになりました。*note
json: 76. モジュールのデコーダーが OrderedDict をビルドするのをサポート
するために、 *note JSONDecoder: d15. クラスのコンストラクタに
'object_pairs_hook' 引数が追加されました。 PyYAML(1) などの外部のライブ
ラリでもサポートされています。

参考
....

PEP 372(2) - 順序付き辞書

     PEP written by Armin Ronacher and Raymond Hettinger.
     Implementation written by Raymond Hettinger.

順序付き辞書は挿入順序を記憶するので、ソートと組み合わせて使うことで、ソ
ートされた辞書を作れます:

     >>> # regular unsorted dictionary
     >>> d = {'banana': 3, 'apple':4, 'pear': 1, 'orange': 2}

     >>> # dictionary sorted by key
     >>> OrderedDict(sorted(d.items(), key=lambda t: t[0]))
     OrderedDict([('apple', 4), ('banana', 3), ('orange', 2), ('pear', 1)])

     >>> # dictionary sorted by value
     >>> OrderedDict(sorted(d.items(), key=lambda t: t[1]))
     OrderedDict([('pear', 1), ('orange', 2), ('banana', 3), ('apple', 4)])

     >>> # dictionary sorted by length of the key string
     >>> OrderedDict(sorted(d.items(), key=lambda t: len(t[0])))
     OrderedDict([('pear', 1), ('apple', 4), ('orange', 2), ('banana', 3)])

この新しい順序付き辞書は、項目が削除されてもソートされた順序を保持します
。しかし、キーが追加されるとき、そのキーは最後に追加され、ソートは保持さ
れません。

   ---------- Footnotes ----------

   (1) https://pyyaml.org/

   (2) https://peps.python.org/pep-0372/


File: python.info,  Node: PEP 378 1000区切りのための書式指定子,  Next: その他の言語変更<11>,  Prev: PEP 372 順序付き辞書,  Up: What's New In Python 3 1

1.13.2 PEP 378: 1000区切りのための書式指定子
--------------------------------------------

組み込みの *note format(): 5eb. 関数と *note str.format(): 5ed. メソッド
が使うミニ言語に、単純でロケールに依存しない 1000 区切りカンマの書式化が
追加されました。これによって簡単にプログラムの出力を、その玄人ちっくな見
た目を改善してひとさまにとって読みやすいものに出来ます:

     >>> format(1234567, ',d')
     '1,234,567'
     >>> format(1234567.89, ',.2f')
     '1,234,567.89'
     >>> format(12345.6 + 8901234.12j, ',f')
     '12,345.600000+8,901,234.120000j'
     >>> format(Decimal('1234567.89'), ',f')
     '1,234,567.89'

これをサポートする型は *note int: 238, *note float: 2ce, *note complex:
2cf. , *note decimal.Decimal: 27d. です。

ドットやら空白やらアポストロフィやらあるいはアンダースコアなどの他のセパ
レータをどうやって指定するかの議論は水面下にありますが、ロケールに従う必
要があるアプリケーションは、1000区切りセパレータについていくつかのサポー
トを既に持っている既存の 'n' 指定子を使うべきです。

参考
....

PEP 378(1) - 1000区切りのための書式指定子

     PEP written by Raymond Hettinger and implemented by Eric Smith and
     Mark Dickinson.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0378/


File: python.info,  Node: その他の言語変更<11>,  Next: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>,  Prev: PEP 378 1000区切りのための書式指定子,  Up: What's New In Python 3 1

1.13.3 その他の言語変更
-----------------------

Python 言語コアに小さな変更がいくつか行われました:

   * ‘__main__.py’ を含むディレクトと zip アーカイブを、その名前をインタ
     プリタに渡すことで直接実行出来るようになりました。そのディレクトリ
     と zip ファイルは自動的に sys.path エントリの先頭に挿入されます。
     (Suggestion and initial patch by Andy Chu; revised patch by Phillip
     J. Eby and Nick Coghlan; bpo-1739468(1).)

   * *note int(): 238. 型に ‘bit_length’ メソッドが追加されました。 この
     メソッドはその値を二進数で表現するのに必要なビット数を返します:

          >>> n = 37
          >>> bin(37)
          '0b100101'
          >>> n.bit_length()
          6
          >>> n = 2**123-1
          >>> n.bit_length()
          123
          >>> (n+1).bit_length()
          124

     (Contributed by Fredrik Johansson, Victor Stinner, Raymond
     Hettinger, and Mark Dickinson; bpo-3439(2).)

   * *note format(): 5eb. 文字列のフィールドに自動的に番号が振られるよう
     になりました:

          >>> 'Sir {} of {}'.format('Gallahad', 'Camelot')
          'Sir Gallahad of Camelot'

     以前は、文字列は ‘'Sir {0} of {1}'’ のようにフィールドに番号を振ら
     なければなりませんでした。

     (Contributed by Eric Smith; bpo-5237(3).)

   * The ‘string.maketrans()’ function is deprecated and is replaced by
     new static methods, *note bytes.maketrans(): 1246. and *note
     bytearray.maketrans(): 1247.  This change solves the confusion
     around which types were supported by the *note string: be. module.
     Now, *note str: 418, *note bytes: 1a4, and *note bytearray: 508.
     each have their own 'maketrans' and 'translate' methods with
     intermediate translation tables of the appropriate type.

     (Contributed by Georg Brandl; bpo-5675(4).)

   * *note with: 59c. 文のシンタックスは一つの文で複数のコンテキストマネ
     ージャを使えるようになりました:

          >>> with open('mylog.txt') as infile, open('a.out', 'w') as outfile:
          ...     for line in infile:
          ...         if '<critical>' in line:
          ...             outfile.write(line)

     With the new syntax, the ‘contextlib.nested()’ function is no
     longer needed and is now deprecated.

     (Georg Brandl と Mattias Brändström の貢献; appspot issue
     53094(5).)

   * ‘round(x, n)’ は 'x' が整数の場合、整数を返すようになりました。以前
     は浮動小数点を返していました:

          >>> round(1123, -2)
          1100

     (Contributed by Mark Dickinson; bpo-4707(6).)

   * Python now uses David Gay's algorithm for finding the shortest
     floating-point representation that doesn't change its value.  This
     should help mitigate some of the confusion surrounding binary
     floating-point numbers.

     The significance is easily seen with a number like ‘1.1’ which does
     not have an exact equivalent in binary floating point.  Since there
     is no exact equivalent, an expression like ‘float('1.1')’ evaluates
     to the nearest representable value which is ‘0x1.199999999999ap+0’
     in hex or ‘1.100000000000000088817841970012523233890533447265625’
     in decimal.  That nearest value was and still is used in subsequent
     floating-point calculations.

     What is new is how the number gets displayed.  Formerly, Python
     used a simple approach.  The value of ‘repr(1.1)’ was computed as
     ‘format(1.1, '.17g')’ which evaluated to ‘'1.1000000000000001'’.
     The advantage of using 17 digits was that it relied on IEEE-754
     guarantees to assure that ‘eval(repr(1.1))’ would round-trip
     exactly to its original value.  The disadvantage is that many
     people found the output to be confusing (mistaking intrinsic
     limitations of binary floating-point representation as being a
     problem with Python itself).

     新しいアルゴリズムでは ‘repr(1.1)’ はより賢明で ‘'1.1'’ を返します
     。実際的には、これは全ての等価な文字列表現 (前提となる同じ浮動小数
     点数に戻るもの) を探し、そして一番短い表現を返します。

     新アルゴリズムは、可能な限りよりわかりやすい表現を生み出す傾向があ
     りますが、元の値を変更しません。ですから ‘1.1 + 2.2 != 3.3’ は表示
     がどうであれ、今でも問題です。

     The new algorithm depends on certain features in the underlying
     floating-point implementation.  If the required features are not
     found, the old algorithm will continue to be used.  Also, the text
     pickle protocols assure cross-platform portability by using the old
     algorithm.

     (Contributed by Eric Smith and Mark Dickinson; bpo-1580(7))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1739468

   (2) https://bugs.python.org/issue?@action=redirect&bpo=3439

   (3) https://bugs.python.org/issue?@action=redirect&bpo=5237

   (4) https://bugs.python.org/issue?@action=redirect&bpo=5675

   (5) https://codereview.appspot.com/53094

   (6) https://bugs.python.org/issue?@action=redirect&bpo=4707

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1580


File: python.info,  Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>,  Next: 最適化<10>,  Prev: その他の言語変更<11>,  Up: What's New In Python 3 1

1.13.4 新たなモジュール、改良されたモジュール、非推奨のモジュール
-----------------------------------------------------------------

   * シーケンスまたはイテラブル内にある一意な要素を数え上げるのに便利な
     *note collections.Counter: 1067. クラスが追加されました:

          >>> Counter(['red', 'blue', 'red', 'green', 'blue', 'blue'])
          Counter({'blue': 3, 'red': 2, 'green': 1})

     (Contributed by Raymond Hettinger; bpo-1696199(1).)

   * Tk のテーマ付きウィジェットへのアクセスを提供する、新しい *note
     tkinter.ttk: e2. モジュールが追加されました。 *note tkinter.ttk:
     e2. の基本的なアイディアは、拡張可能性のためにウィジェットの動作を
     実装するコードと見た目を記述するコードを分離することです。

     (Contributed by Guilherme Polo; bpo-2983(2).)

   * *note gzip.GzipFile: 3f3. と *note bz2.BZ2File: 832. クラスはコンテ
     キストマネジメントプロトコルをサポートするようになりました:

          >>> # Automatically close file after writing
          >>> with gzip.GzipFile(filename, "wb") as f:
          ...     f.write(b"xxx")

     (Contributed by Antoine Pitrou.)

   * *note decimal: 2e. モジュールが二進 *note float: 2ce. から decimal
     オブジェクトを生成するメソッドをサポートしました。 変換は正確ですが
     時に意外なことがあります:

          >>> Decimal.from_float(1.1)
          Decimal('1.100000000000000088817841970012523233890533447265625')

     長い十進の結果が、 '1.1' を記憶するための現実の二進での端数を表して
     います。 '1.1' は二進数で正確に表現出来ないので、端数は十進表現でと
     ても多くの桁数になっています。

     (Contributed by Raymond Hettinger and Mark Dickinson.)

   * *note itertools: 75. に 2 つの関数が追加されました。 *note
     itertools.combinations_with_replacement(): 1252. 関数は、置換 (順列
     , permutation) や直積 (Cartesian product) を含む組合せ論の 4 つの生
     成関数のうちの 1 つです。 *note itertools.compress(): 1253. 関数は
     APL(3) の同名機能の模倣品です。また、既存の *note
     itertools.count(): 1254. 関数は新たにオプショナルな 'step' 引数を取
     るようになり、そして数え方に *note fractions.Fraction: 1c8. や
     *note decimal.Decimal: 27d. を含む任意の数値型を使えるようになりま
     した。

          >>> [p+q for p,q in combinations_with_replacement('LOVE', 2)]
          ['LL', 'LO', 'LV', 'LE', 'OO', 'OV', 'OE', 'VV', 'VE', 'EE']

          >>> list(compress(data=range(10), selectors=[0,0,1,1,0,1,0,1,0,0]))
          [2, 3, 5, 7]

          >>> c = count(start=Fraction(1,2), step=Fraction(1,6))
          >>> [next(c), next(c), next(c), next(c)]
          [Fraction(1, 2), Fraction(2, 3), Fraction(5, 6), Fraction(1, 1)]

     (Contributed by Raymond Hettinger.)

   * *note collections.namedtuple(): 1ac. が新たにキーワード引数
     'rename' をサポートし、これにより不正なフィールド名を自動で _0, _1,
     ...  といった位置による名前に変換することが出来ます。これはフィール
     ド名が何か外部ソースに基いて作られる場合に有用です。例えば CSV のヘ
     ッダ、SQL のフィールドリスト、あるいはユーザ入力などです:

          >>> query = input()
          SELECT region, dept, count(*) FROM main GROUPBY region, dept

          >>> cursor.execute(query)
          >>> query_fields = [desc[0] for desc in cursor.description]
          >>> UserQuery = namedtuple('UserQuery', query_fields, rename=True)
          >>> pprint.pprint([UserQuery(*row) for row in cursor])
          [UserQuery(region='South', dept='Shipping', _2=185),
           UserQuery(region='North', dept='Accounting', _2=37),
           UserQuery(region='West', dept='Sales', _2=419)]

     (Contributed by Raymond Hettinger; bpo-1818(4).)

   * *note re.sub(): 283.、*note re.subn(): 284. および *note
     re.split(): 282. 関数は flags 引数を受け取るようになりました。

     (Contributed by Gregory Smith.)

   * logging を自身では使わずとも使用ライブラリがそうしているようなアプ
     リケーションのために、 *note logging: 7b. モジュールが単純な *note
     logging.NullHandler: 1255. を実装しました。null ハンドラをセットア
     ップすることは、 "No handlers could be found for logger foo" のよう
     な警告を抑制します。

          >>> h = logging.NullHandler()
          >>> logging.getLogger("foo").addHandler(h)

     (Contributed by Vinay Sajip; bpo-4384(5)).

   * コマンドラインスイッチ ‘-m’ をサポートしている *note runpy: ac. が
     パッケージの実行をサポートするようになりました。パッケージ名が与え
     られると ‘__main__’ サブモジュールを探し出して実行します。

     (Contributed by Andi Vajda; bpo-4195(6).)

   * *note pdb: 94. モジュールが *note zipimport: 118. (あるいはなにかほ
     かの PEP 302(7) 準拠ローダ) でロードされたモジュールのソースコード
     にアクセスでき、表示できるようになりました。

     (Contributed by Alexander Belopolsky; bpo-4201(8).)

   * *note functools.partial: 3ed. オブジェクトが pickle 化出来るように
     なりました。

     (Suggested by Antoine Pitrou and Jesse Noller.  Implemented by Jack
     Diederich; bpo-5228(9).)

   * シンボルのための *note pydoc: a3. ヘルプトピックが追加されました。
     これで対話環境で ‘help('@')’ などが期待通りの働きをします (--訳注:
     実装としては pydoc_data パッケージのこと。 ‘pydoc_data/topics.py’ に
     docstring からは生成出来ない、シンボルについてのドキュメントが収め
     られています --)。

     (Contributed by David Laban; bpo-4739(10).)

   * *note unittest: ef. に特定のテストメソッドやテストクラス全体をスキ
     ップする仕組みのサポートが追加されました。さらに、この機能はテスト
     結果を「意図的な失敗」とすることができ、テストが失敗しても
     ‘TestResult’ の失敗数にはカウントされなくなります:

          class TestGizmo(unittest.TestCase):

              @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
              def test_gizmo_on_windows(self):
                  ...

              @unittest.expectedFailure
              def test_gimzo_without_required_library(self):
                  ...

     また例外についてのテストが、 *note with: 59c. 文で使えるコンテキス
     トマネージャとして増強されました:

          def test_division_by_zero(self):
              with self.assertRaises(ZeroDivisionError):
                  x / 0

     In addition, several new assertion methods were added including
     *note assertSetEqual(): 1256, *note assertDictEqual(): 1257,
     ‘assertDictContainsSubset()’, *note assertListEqual(): 1258, *note
     assertTupleEqual(): 1259, *note assertSequenceEqual(): 125a, *note
     assertRaisesRegexp(): 4f8, *note assertIsNone(): 125b, and *note
     assertIsNotNone(): 125c.

     (Contributed by Benjamin Peterson and Antoine Pitrou.)

   * The *note io: 73. module has three new constants for the *note
     seek(): 125d. method: *note SEEK_SET: 125e, *note SEEK_CUR: 125f,
     and *note SEEK_END: 1260.

   * *note sys.version_info: 66c. タプルが名前付きタプルになりました。

          >>> sys.version_info
          sys.version_info(major=3, minor=1, micro=0, releaselevel='alpha', serial=2)

     (Contributed by Ross Light; bpo-4285(11).)

   * The ‘nntplib’ and *note imaplib: 6a. modules now support IPv6.

     (Contributed by Derek Morr; bpo-1655(12) and bpo-1664(13).)

   * *note pickle: 95. を、プロトコル 2 以下を使う際に Python 2.x との相
     互運用に順応するようにしました。標準ライブラリの再編成はたくさんの
     オブジェクトへの公式な参照を変えました。例えば Python 2 の
     ‘__builtin__.set’ は Python 3 では ‘builtins.set’ です。この変化は
     異なる Python バージョン間でのデータ共有の取り組みを複雑にしました
     。ですが今回のこの修正により、プロトコル 2 以下を選んだ場合は
     pickler は自動的にロード時もダンプ時も古い Python 2 命名を使うよう
     になります。この再マッピングはデフォルトで有効になりますが、
     'fix_imports' オプションで無効に出来ます:

          >>> s = {1, 2, 3}
          >>> pickle.dumps(s, protocol=0)
          b'c__builtin__\nset\np0\n((lp1\nL1L\naL2L\naL3L\natp2\nRp3\n.'
          >>> pickle.dumps(s, protocol=0, fix_imports=False)
          b'cbuiltins\nset\np0\n((lp1\nL1L\naL2L\naL3L\natp2\nRp3\n.'

     不幸にも、そして避けられないこの変更による副作用は、Python 3.1 によ
     って生成されたプロトコル 2 pickle が Python 3.0 で読めなくなるであ
     ろうことです。Python 2.x との互換性を維持するつもりがないのであれば
     、Python 3.x 実装間でのデータ移行では最新 pickle プロトコルバージョ
     ン 3 を使うべきです。

     (Contributed by Alexandre Vassalotti and Antoine Pitrou,
     bpo-6137(14).)

   * 新規モジュール *note importlib: 6b. が追加されました。 *note
     import: 5ac. 文とその相棒の *note __import__(): 8a2. 関数の、完全で
     移植性が高いピュア Python 参照実装を提供しています。これはインポー
     トで行う動作の文書化と定義における、確かな前進です。

     (Contributed by Brett Cannon.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1696199

   (2) https://bugs.python.org/issue?@action=redirect&bpo=2983

   (3) https://ja.wikipedia.org/wiki/APL

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1818

   (5) https://bugs.python.org/issue?@action=redirect&bpo=4384

   (6) https://bugs.python.org/issue?@action=redirect&bpo=4195

   (7) https://peps.python.org/pep-0302/

   (8) https://bugs.python.org/issue?@action=redirect&bpo=4201

   (9) https://bugs.python.org/issue?@action=redirect&bpo=5228

   (10) https://bugs.python.org/issue?@action=redirect&bpo=4739

   (11) https://bugs.python.org/issue?@action=redirect&bpo=4285

   (12) https://bugs.python.org/issue?@action=redirect&bpo=1655

   (13) https://bugs.python.org/issue?@action=redirect&bpo=1664

   (14) https://bugs.python.org/issue?@action=redirect&bpo=6137


File: python.info,  Node: 最適化<10>,  Next: IDLE<2>,  Prev: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>,  Up: What's New In Python 3 1

1.13.5 最適化
-------------

大きな性能向上がありました:

   * The new I/O library (as defined in PEP 3116(1)) was mostly written
     in Python and quickly proved to be a problematic bottleneck in
     Python 3.0.  In Python 3.1, the I/O library has been entirely
     rewritten in C and is 2 to 20 times faster depending on the task at
     hand.  The pure Python version is still available for
     experimentation purposes through the ‘_pyio’ module.

     (Contributed by Amaury Forgeot d'Arc and Antoine Pitrou.)

   * Added a heuristic so that tuples and dicts containing only
     untrackable objects are not tracked by the garbage collector.  This
     can reduce the size of collections and therefore the garbage
     collection overhead on long-running programs, depending on their
     particular use of datatypes.

     (Contributed by Antoine Pitrou, bpo-4688(2).)

   * Enabling a configure option named ‘--with-computed-gotos’ on
     compilers that support it (notably: gcc, SunPro, icc), the bytecode
     evaluation loop is compiled with a new dispatch mechanism which
     gives speedups of up to 20%, depending on the system, the compiler,
     and the benchmark.

     (Contributed by Antoine Pitrou along with a number of other
     participants, bpo-4753(3)).

   * UTF-8, UTF-16 ならびに LATIN-1 のデコーディングが2から4倍速くなりま
     した。

     (Antoine Pitrou と Amaury Forgeot d'Arc の貢献, bpo-4868(4).)

   * The *note json: 76. module now has a C extension to substantially
     improve its performance.  In addition, the API was modified so that
     json works only with *note str: 418, not with *note bytes: 1a4.
     That change makes the module closely match the JSON
     specification(5) which is defined in terms of Unicode.

     (Contributed by Bob Ippolito and converted to Py3.1 by Antoine
     Pitrou and Benjamin Peterson; bpo-4136(6).)

   * Unpickling now interns the attribute names of pickled objects.
     This saves memory and allows pickles to be smaller.

     (Contributed by Jake McGuire and Antoine Pitrou; bpo-5084(7).)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3116/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=4688

   (3) https://bugs.python.org/issue?@action=redirect&bpo=4753

   (4) https://bugs.python.org/issue?@action=redirect&bpo=4868

   (5) https://json.org/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=4136

   (7) https://bugs.python.org/issue?@action=redirect&bpo=5084


File: python.info,  Node: IDLE<2>,  Next: ビルドならびに C API の変更<6>,  Prev: 最適化<10>,  Up: What's New In Python 3 1

1.13.6 IDLE
-----------

   * IDLE のフォーマットメニューに、ソースコードから末尾の空白を取り除く
     ことが出来るオプションが追加されました。

     (Contributed by Roger D. Serwy; bpo-5150(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5150


File: python.info,  Node: ビルドならびに C API の変更<6>,  Next: Python 3 1 への移植,  Prev: IDLE<2>,  Up: What's New In Python 3 1

1.13.7 ビルドならびに C API の変更
----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * 整数の内部格納方式が ‘2**15’ ベースと ‘2**30’ ベースのいずれかにな
     りました。 これはビルド時に決定されます。 以前は常に ‘2**15’ ベース
     で格納されていました。 ‘2**30’ ベースにすると 64 bit マシンでは性能
     が有意に向上しますが、 32 bit マシンでのベンチマーク結果には向上も
     低下もあります。 そのため、デフォルトでは 64 bit マシンで ‘2**30’ ベ
     ースを、 32 bit マシンで ‘2**15’ ベースを使用します。 Unix では新た
     な configure オプション ‘--enable-big-digits’ が追加されました。 こ
     れにより上記のデフォルトを上書き出来ます。

     この変更は性能向上以外ではエンドユーザには分からないはずですが、例
     外が1つあります。 テストおよびデバッグ目的で内部形式の情報を提供す
     る *note sys.int_info: 1264. が追加されましたが、これにより数字あた
     りのビット数と各数字の格納に使われる C の型のバイトサイズが分かりま
     す:

          >>> import sys
          >>> sys.int_info
          sys.int_info(bits_per_digit=30, sizeof_digit=4)

     (Contributed by Mark Dickinson; bpo-4258(1).)

   * *note PyLong_AsUnsignedLongLong(): 1265. 関数は負の 'pylong' に対し
     *note TypeError: 502. ではなく *note OverflowError: 84e. を送出する
     ようになりました。

     (Contributed by Mark Dickinson and Lisandro Dalcrin; bpo-5175(2).)

   * ‘PyNumber_Int()’ が非推奨になりました。代わりに *note
     PyNumber_Long(): a35. を使用してください。

     (Contributed by Mark Dickinson; bpo-4910(3).)

   * 非推奨の関数 ‘PyOS_ascii_strtod()’ および ‘PyOS_ascii_atof()’ を置
     き換えるために新しく *note PyOS_string_to_double(): 1266. 関数が追
     加されました。

     (Contributed by Mark Dickinson; bpo-5914(4).)

   * ‘PyCObject’ API を置き換えるものとして、 *note PyCapsule: 1244. が
     追加されました。主な違いとしては、新しい型は、型安全に情報を渡すた
     めの良く定義されたインターフェースを持ち、また、デストラクタの呼び
     出しのシグネチャの複雑さが小さくなっています。古い型は問題のある
     API で、今では非推奨です。

     (Contributed by Larry Hastings; bpo-5630(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4258

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5175

   (3) https://bugs.python.org/issue?@action=redirect&bpo=4910

   (4) https://bugs.python.org/issue?@action=redirect&bpo=5914

   (5) https://bugs.python.org/issue?@action=redirect&bpo=5630


File: python.info,  Node: Python 3 1 への移植,  Prev: ビルドならびに C API の変更<6>,  Up: What's New In Python 3 1

1.13.8 Python 3.1 への移植
--------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

   * The new floating-point string representations can break existing
     doctests.  For example:

          def e():
              '''Compute the base of natural logarithms.

              >>> e()
              2.7182818284590451

              '''
              return sum(1/math.factorial(x) for x in reversed(range(30)))

          doctest.testmod()

          **********************************************************************
          Failed example:
              e()
          Expected:
              2.7182818284590451
          Got:
              2.718281828459045
          **********************************************************************

   * pickle モジュールがプロトコルバージョン 2 以下で自動的に名前の再対
     応付けを行うので、Python 3.1 で pickle 化すると Python 3.0 で読めな
     くなります。一つの解決策はプロトコル 3 を使うことです。もう一つは
     'fix_imports' オプションを ‘False’ にセットすることです。上述の議論
     を参照してください。


File: python.info,  Node: What's New In Python 3 0,  Next: What's New in Python 2 7,  Prev: What's New In Python 3 1,  Up: What's New in Python

1.14 What's New In Python 3.0
=============================


著者: Guido van Rossum

この記事では 2.6 と比較した Python 3.0 での新機能を解説します。 Python
3.0、あるいは "Python 3000"、 "Py3K" は初めて '意図的に後方非互換にした'
Python のリリースです。 Python 3.0 は2008年12月3日にリリースされました。
通常のリリースよりも多くの変更があり、全ての Python ユーザにとって重要で
す。 しかし、変更について理解したら Python に実際にはそれほど変更がない
ことが分かるでしょう。 全体的に見れば、よく知られた悩みの種が概ね解決さ
れ、昔の粗雑なものが取り除かれています。

この記事は全ての新機能を完璧な仕様を示そうとはしませんが、便利な概要につ
いては説明しようとしています。 全詳細については Python 3.0 のドキュメン
トや、本編で引かれている多くの PEP を参照してください。 特定の機能の実装
や設計原理について完全に理解したいなら、通常のドキュメントよりも詳しいこ
とが書いてある PEP を見るとよいでしょう。 しかし、一旦機能が完全に実装さ
れると、普通 PEP は最新の状態に保たれないことに注意してください。

この文書で全項目に触れるべきなのですが、時間の制約のためそうではありませ
ん。 いつもの新リリースのように、 ソース配布の ‘Misc/NEWS’ には些細な変
更についても詳細な情報があります。

* Menu:

* よくある悩みの種::
* 構文の変更の概要::
* Python 2.6 で既にあった変更: Python 2 6 で既にあった変更.
* ライブラリの変更::
* PEP 3101; 文字列整形の新たなアプローチ: PEP 3101 文字列整形の新たなアプローチ.
* 例外に関する変更::
* その他の変更: その他の変更<2>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<7>.
* 性能::
* Python 3.0 への移植: Python 3 0 への移植.


File: python.info,  Node: よくある悩みの種,  Next: 構文の変更の概要,  Up: What's New In Python 3 0

1.14.1 よくある悩みの種
-----------------------

このセクションは Python 2.5 に慣れていたら躓いてしまいそうな少数の変更の
一覧です。

* Menu:

* print関数::
* リストからビューおよびイテレータへ::
* 順序比較::
* 整数::
* Unicode 対 8 ビット、ではなく、テキスト対データに::


File: python.info,  Node: print関数,  Next: リストからビューおよびイテレータへ,  Up: よくある悩みの種

1.14.1.1 print関数
..................

‘print’ 文は *note print(): f42. 関数に置き換えられ、古い ‘print’ 文の特
殊な文法の殆どがキーワード引数で置き換えられています ( PEP 3105(1))。 例
:

     Old: print "The answer is", 2*2
     New: print("The answer is", 2*2)

     Old: print x,           # Trailing comma suppresses newline
     New: print(x, end=" ")  # Appends a space instead of a newline

     Old: print              # Prints a newline
     New: print()            # You must call the function!

     Old: print >>sys.stderr, "fatal error"
     New: print("fatal error", file=sys.stderr)

     Old: print (x, y)       # prints repr((x, y))
     New: print((x, y))      # Not the same as print(x, y)!

項目間の区切りをカスタマイズすることもできます。例:

     print("There are <", 2**32, "> possibilities!", sep="")

これは以下を出力します :

     There are <4294967296> possibilities!

注釈:

   * *note print(): f42. 関数は、古い ‘print’ 文の "ソフトスペース" 機能
     をサポートしません。例えば Python 2.x では、 ‘print "A\n", "B"’ は
     ‘"A\nB\n"’ を出力していましたが、 Python 3.0 では、 ‘print("A\n",
     "B")’ は ‘"A\n B\n"’ を出力します。

   * 最初は、対話モードで古い ‘print x’ を何回もタイプしてしまうでしょう
     。代わりに ‘print(x)’ とタイプするよう再教育してください。

   * ‘2to3’ ソース変換ツールを使うと、すべての ‘print’ 文が *note
     print(): f42. 関数呼び出しに自動的に置換されるので、大きなプロジェ
     クトでもさほど問題にならないでしょう。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3105/


File: python.info,  Node: リストからビューおよびイテレータへ,  Next: 順序比較,  Prev: print関数,  Up: よくある悩みの種

1.14.1.2 リストからビューおよびイテレータへ
...........................................

いくつかの良く使われている API はもはやリストを返しません:

   * *note dict: 237. の *note dict.keys(): 798, *note dict.items():
     79a. そして *note dict.values(): 799. メソッドはリストの代わりに
     "views" を返します。 例えば: ‘k = d.keys(); k.sort()’ は上手く動き
     ません。 代わりに ‘k = sorted(d)’ を使ってください (これは Python
     2.5 でも動作し、効率的です)。

   * ‘dict.iterkeys()’、 ‘dict.iteritems()’、 ‘dict.itervalues()’ メソッ
     ドはもうサポートされません。

   * *note map(): 82f. と *note filter(): 830. はイテレータを返します。
     もしも本物のリストが必要で、全ての入力シーケンスが同じ長さの場合で
     あれば、簡単に直すなら *note map(): 82f. を *note list(): 5dc. で包
     みます。例えば ‘list(map(...))’ という具合。ですがより良いのは、大
     抵はリスト内包を使うことです (特に元々のコードが *note lambda:
     126d. を使っている場合)。あるいはコードを、リストを全く必要としない
     ように書き換えましょう。とりわけトリッキーなのは、関数に副作用を起
     こさせるために呼び出される *note map(): 82f. です; この場合確実な変
     換は普通に *note for: 2c9. ループを使うことです (そもそもリストを作
     ること自体が無駄遣いでしょう)。

     入力シーケンスの長さが同じとは限らないならば、 *note map(): 82f. は
     最も短いシーケンスが消費されつくすと処理をやめます。Python 2.x での
     *note map(): 82f. 用法と全く互換にするにはシーケンスを *note
     itertools.zip_longest(): 126e. で包んでください。例えば ‘map(func,
     *sequences)’ を ‘list(map(func,
     itertools.zip_longest(*sequences)))’ とします。

   * *note range(): 911. は ‘xrange()’ のように振る舞います。ただし、任
     意のサイズの値で動作します。 ‘xrange()’ は削除されました。

   * *note zip(): 79b. はイテレータを返します。


File: python.info,  Node: 順序比較,  Next: 整数,  Prev: リストからビューおよびイテレータへ,  Up: よくある悩みの種

1.14.1.3 順序比較
.................

Python 3.0 で順序比較のルールが簡単になりました。

   * 順序比較演算子 (‘<’, ‘<=’, ‘>=’, ‘>’) は、そのオペランドが自然な順
     序づけを持たない場合 TypeError 例外を送出します。 ‘1 < ''’, ‘0 >
     None’ または ‘len <= len’ のような式は無効になり、 ‘None < None’ は
     ‘False’ を返す代わりに *note TypeError: 502. を送出します。その結果
     、 不均一なリスト（訳注：比較不能な型からなる要素が混在するリスト）
     のソートは意味がなくなりました。 - 全ての要素は互いに比較できなけれ
     ばなりません。これは ‘==’ と ‘!=’ 演算子には適用されないことに注意
     してください: 別々の比較不可能な型のオブジェクトを比較すると常に、
     互いに等しくないと評価されます。

   * ‘builtin.sorted()’ と *note list.sort(): b9d. メソッドは比較関数を
     与える 'cmp' 引数を受け取らなくなりました。 かわりに 'key' 引数を使
     用してください。 'key' と 'reverse' 引数は "キーワード専用" となっ
     たことに注意してください。

   * ‘cmp()’ 関数は廃止され、 ‘__cmp__()’ 特殊関数はもはやサポートされま
     せん。ソートには ‘__lt__()’ を使用し、 ‘__hash__()’ には ‘__eq__()’
     を 、必要に応じて他の高級比較 (rich comparison) を使用してください
     。 (もし ‘cmp()’ の機能が必要なら、 式 ‘(a > b) - (a < b)’ を
     ‘cmp(a, b)’ の代わに使用できるはずです)


File: python.info,  Node: 整数,  Next: Unicode 対 8 ビット、ではなく、テキスト対データに,  Prev: 順序比較,  Up: よくある悩みの種

1.14.1.4 整数
.............

   * PEP 237(1): 基本的には、 ‘long’ は *note int: 238. に改名されました
     。これは、整数型の唯一の組み込み型になり、 *note int: 238. と名付け
     られていますが、古い ‘long’ 型とほぼ同じように振る舞います。

   * PEP 238(2): An expression like ‘1/2’ returns a float.  Use ‘1//2’
     to get the truncating behavior.  (The latter syntax has existed for
     years, at least since Python 2.2.)

   * 整数の上限がなくなったため、‘sys.maxint’ 定数は削除されました。しか
     しながら、通常のリストや文字列の添え字よりも大きい整数として *note
     sys.maxsize: 1195. を使うことができます。 *note sys.maxsize: 1195.
     は実装の "自然な" 整数の大きさに一致し、同じプラットフォームでは (同
     じビルドオプションなら) 過去のリリースの ‘sys.maxint’ と普通は同じ
     です。

   * long 整数の *note repr(): 7c8. はもはや末尾に ‘L’ を持ちません。そ
     のため、無条件に "L" を取り除くコードは代わりに最後の数字を取り除い
     てしまうでしょう。 (代わりに *note str(): 418. を使用してください。
     )

   * 8進数リテラルが ‘0720’ の形でなくなりました。代わりに ‘0o720’ を使
     ってください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0237/

   (2) https://peps.python.org/pep-0238/


File: python.info,  Node: Unicode 対 8 ビット、ではなく、テキスト対データに,  Prev: 整数,  Up: よくある悩みの種

1.14.1.5 Unicode 対 8 ビット、ではなく、テキスト対データに
..........................................................

バイナリと Unicode について知っていると思っている全てが変わりました。

   * Python 3.0 でのコンセプトは、Unicode 文字列と 8 ビット文字列、とい
     う対比ではなくて、 'テキスト' と (バイナリ) 'データ' の違いと考える
     、というものです。全てのテキストは Unicode です; 一方で 'エンコード
     された' Unicode はバイナリデータとして表現されます。テキストを保持
     するのに使われる型は *note str: 418. で、データには *note bytes:
     1a4. を使います。2.x での状況との最大の違いは、Python 3.0 でテキス
     トとデータを混ぜようとすれば *note TypeError: 502. となることです。
     Python 2.x では Unicode と 8 ビット文字列を混ぜたとすれば、8 ビット
     文字列がたまたま 7 ビット (ASCII) バイトだけから出来ていれば動くし
     非 ASCII バイトがあれば *note UnicodeDecodeError: 9e1. となっていた
     でしょう。この、データ値に依存した振る舞いが、何年にも渡って夥しい
     数の悲劇を生み出していました。

   * この変更からの帰結として、Unicode、エンコーディング、あるいはバイナ
     リデータを使うほとんど全てのコードは、原則として修正する必要がある
     と思います。この変更は進歩のための破壊です。というのも 2.x 世界には
     、エンコードされたテキストとそうでないものをごっちゃにしている膨大
     な数のバグがあるはずだからです。Python 2.x のうちから準備しておくに
     は、まずは全てのエンコードしていないテキストに ‘unicode’ を使い、
     *note str: 418. はバイナリとエンコードされたデータだけに対して使う
     ことから始めてください。そうしておけば ‘2to3’ ツールがあなたのため
     にほとんどの仕事をしてくれるでしょう。

   * Unicode テキストのリテラルに ‘u"..."’ を使うことはもはやできません
     。しかし、バイナリーデータのリテラルには ‘b"..."’ を使わなければな
     りません。(--訳注: この ‘u"..."’ は Python 3.3 で再び使えるようにな
     りました。 --)

   * *note str: 418. 型と *note bytes: 1a4. 型を混ぜて使うことは出来ませ
     んから、それらはいつでも明示的に変換しなければいけません。 *note
     str: 418. から *note bytes: 1a4. にするには *note str.encode():
     8a3. を使ってください。そして *note bytes: 1a4. から *note str:
     418. にするには *note bytes.decode(): 8a4. を使います。それぞれ
     ‘bytes(s, encoding=...)’ 、 ‘str(b, encoding=...)’ を使うことも出来
     ます。

   * *note str: 418. がそうであるように、 *note bytes: 1a4. は *note
     immutable: 1272. です。これとは独立させて *note mutable: 1273. 型と
     して、バッファ化されたバイナリデータを保持するための *note
     bytearray: 508. が用意してあります。 *note bytes: 1a4. を受け付ける
     API のほぼ全てが *note bytearray: 508. も許容します。その mutable
     API は ‘collections.MutableSequence’ に基づいています。

   * raw 文字列リテラル内にある全てのバックスラッシュが「字句通り」に解
     釈されます。つまり ‘'\U'’ も ‘'\u'’ も、 raw 文字列内にあっては何ら
     特別に扱われないということです。例えば ‘r'\u20ac'’ は Python 3.0 で
     は 6 文字の文字列です。Python 2.x では ‘ur'\u20ac'’ が単一の「ユー
     ロ」文字であったのにです。(無論この変更は raw 文字列リテラルについ
     てだけのもので、ユーロ文字は Python 3.0 で ‘'\u20ac'’ です。)

   * 組み込みであった ‘basestring’ 抽象型なんてものは削除されたのです。
     *note str: 418. をお使いなさい。 *note str: 418. と *note bytes:
     1a4. は基底クラスを共有するのを正当化するのに足るほどには、機能的に
     共通していないのです。 ‘2to3’ ツール (後述) は ‘basestring’ を片っ
     端から *note str: 418. に置き換えてくれます。

   * テキストファイルとして開かれたファイル (これは従来どおり *note
     open(): 4e5. でのデフォルトのモード) は、 (メモリ内の) 文字列と (デ
     ィスクでの) バイト列との写像をするのに、常にエンコーディングを使い
     ます。バイナリファイル (モードに ‘b’ を付けて開いたもの) はメモリ内
     では常にバイト列を使います。このことで、もしもファイルが誤ったモー
     ドやエンコーディングで開かれようとすると、I/O はきっと口やかましく
     失敗します。こっそり正しくないデータを生み出すのではなく。それに加
     えて、ファイルを開く際には Unix ユーザでさえもこれからは、 (テキス
     トかバイナリかの) 正しいモードを選択する必要があるということです。
     プラットフォームにはそれ特有のデフォルトエンコーディングがあります
     。Unix 的プラットフォームではこれは環境変数 ‘LANG’ にセットされてい
     るかもしれません (あるいは時々ほかのプラットフォーム特有の、ロケー
     ルに関係した環境変数にもセットされています)。全てとは言いませんが多
     くの場合は、システムのデフォルトは UTF-8 です; ですが決してこのデフ
     ォルトを当てにすべきではありません。純粋な ASCII テキスト以上のもの
     を読み書きするどんなアプリケーションも、きっとエンコーディングをオ
     ーバライド出来る手段を持つべきです。 *note codecs: 14. 内にあるエン
     コーディングを熟知したストリームを使うことは、今ではもう必要なくな
     りました。

   * *note sys.stdin: 507, *note sys.stdout: aa4, *note sys.stderr: 907.
     の初期値はいまでは Unicode のみのテキストファイルです (つまりそれら
     は *note io.TextIOBase: 661. のインスタンスです)。バイト列データを
     それらのストリームで読み書きするには、 *note io.TextIOBase.buffer:
     1274. 属性を使う必要があります。

   * ファイル名は、API へは (Unicode) 文字列を渡し、 (Unicode) 文字列が
     返ります。これにはプラットフォーム特有の問題があるかもしれません。
     というのも、いくつかのプラットフォームではファイル名は任意のバイト
     文字列だからです。(他方では、Windows ではファイル名はネイティブに
     Unicode で格納されています。) 次善策として、ほとんどの API (たとえ
     ば *note open(): 4e5. と *note os: 91. モジュール内の多くの関数) は
     ファイル名として、文字列だけでなく *note bytes: 1a4. を受け付け、そ
     して少しの API は *note bytes: 1a4. を返すかどうかを要求出来る手段
     を持っています。それゆえに *note os.listdir(): 10cd. は引数が *note
     bytes: 1a4. インスタンスであれば *note bytes: 1a4. のリストで返し、
     *note os.getcwdb(): a5f. はカレントディレクトリを *note bytes: 1a4.
     で返します。 *note os.listdir(): 10cd. が文字列のリストで返す際、適
     切にデコード出来ないファイル名は *note UnicodeError: 1275. とはせず
     に無視されることにご注意ください。

   * *note os.environ: 118a. や *note sys.argv: 1236. のようないくつかの
     システム API にも問題がありえます。システムにより利用可能とされるべ
     きバイト列がデフォルトエンコーディングで解釈不能な場合です。環境変
     数 ‘LANG’ をセットしてプログラムを再実行することが、おそらく最善の
     アプローチです。

   * PEP 3138(1): 文字列への *note repr(): 7c8. はもう非 ASCII 文字をエ
     スケープしません。ただし、制御文字、Unicode 標準で印字不可状態のコ
     ードポイントは今でもエスケープされます。

   * PEP 3120(2): ソースのエンコードのデフォルトが UTF-8 になりました。

   * PEP 3131(3): 非 ASCII 文字を識別子として使用することが出来るように
     なりました。 (そうはいっても標準ライブラリは、コメント内での貢献者
     の名前以外では ASCII だけのままです。)

   * ‘StringIO’ および ‘cStringIO’ モジュールは廃止されました。その代わ
     り *note io: 73. モジュールをインポートして、テキストやデータには
     *note io.StringIO: ef3. や *note io.BytesIO: e6d. を使用してくださ
     い。

   * *note Unicode HOWTO: 1276. を参照してください。Python 3.0 向けに更
     新されました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3138/

   (2) https://peps.python.org/pep-3120/

   (3) https://peps.python.org/pep-3131/


File: python.info,  Node: 構文の変更の概要,  Next: Python 2 6 で既にあった変更,  Prev: よくある悩みの種,  Up: What's New In Python 3 0

1.14.2 構文の変更の概要
-----------------------

このセクションは Python 3.0 における全ての '構文の' 変更についての簡単な
概要です。

* Menu:

* 新たな構文::
* 変更された構文::
* 削除された操作::


File: python.info,  Node: 新たな構文,  Next: 変更された構文,  Up: 構文の変更の概要

1.14.2.1 新たな構文
...................

   * PEP 3107(1): Function argument and return value annotations.  This
     provides a standardized way of annotating a function's parameters
     and return value.  There are no semantics attached to such
     annotations except that they can be introspected at runtime using
     the ‘__annotations__’ attribute.  The intent is to encourage
     experimentation through metaclasses, decorators or frameworks.

   * PEP 3102(2): キーワード専用引数。 パラメータリスト中で ‘*args’ のあ
     とに現れる名前付きパラメータは、呼び出す際には '必ず' キーワード引
     数の構文を使う必要があります (--訳注: ‘def fun(*a, kw):’ という定義
     で ‘fun(1, 2, 3)’ は NG で ‘fun(1, 2, kw=3)’ としなければならない。
     ここまでは 2.x と同じ --)。 この PEP により、可変引数リストを受け取
     らずにキーワード専用引数だけを許したい場合にそれを主張するために剥
     き出しの ‘*’ をパラメータリスト内に書けるようになりました (--訳注:
     ‘def fun(*, kw):’ と定義出来る。この定義では ‘fun(kw=1)’ としてしか
     呼び出せない。 ‘fun(1)’ はダメ。--)。

   * クラス定義内で、基底クラスのリストのあとでキーワード引数が許される
     ようになりました。これは metaclass を指定するための新しい規約 (次セ
     クション参照) に使われるものですが、 metaclass サポートだけのためだ
     けでなく他の目的に使うことも出来ます。

   * PEP 3104(3): *note nonlocal: 1279. 文。 ‘nonlocal x’ を使うと外側の
     (ただしグローバルでない) スコープから、直接変数を代入することが出来
     るようになります。 ‘nonlocal’ は新しく予約語になりました。

   * PEP 3132(4): 拡張されたイテレータのアンパック。 ‘a, b, *rest =
     some_sequence’ のようなことを書けるようになりました。 ‘*rest, a =
     stuff’ も出来ます。 ‘rest’ オブジェクトは常に (空かもしれなくても)
     リストです; 右辺には任意のイテラブルを置けます。例えば:

          (a, *rest, b) = range(5)

     これは 'a' に ‘0’ を、 'b' に ‘4’ を、そして 'rest' に ‘[1, 2, 3]’
     をセットします。

   * 辞書内包表記: ‘{k: v for k, v in stuff}’ は ‘dict(stuff)’ と同じ意
     味ですが、より柔軟です。 (これは PEP 274(5) で支持されています。)

   * セットリテラル、例えば ‘{1, 2}’。‘{}’ は空の辞書であることに注意し
     てください。空のセットには ‘set()’ を使用してください。セットの内包
     表記もサポートされました。例えば ‘{x for x in stuff}’ は
     ‘set(stuff)’ と同じ意味ですが、より柔軟です。

   * 新たな8進数リテラル、e.g.  ‘0o720’ (2.6 で既にありました)。古い8進
     数リテラル (‘0720’) は廃止されました。

   * 新たなバイナリリテラル、e.g.  ‘0b1010’ (2.6 で既にありました) と、
     関連する新しい組み込み関数 *note bin(): 127a. が導入されました。

   * ‘b’ または ‘B’ で始まるバイトリテラルと、関連する新しい組み込み関数
     *note bytes(): 1a4. が導入されました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3107/

   (2) https://peps.python.org/pep-3102/

   (3) https://peps.python.org/pep-3104/

   (4) https://peps.python.org/pep-3132/

   (5) https://peps.python.org/pep-0274/


File: python.info,  Node: 変更された構文,  Next: 削除された操作,  Prev: 新たな構文,  Up: 構文の変更の概要

1.14.2.2 変更された構文
.......................

   * PEP 3109(1) と PEP 3134(2): 新たな *note raise: 5b7. 文のシンタック
     ス: ‘raise [EXPR [from EXPR]]’。以下を参照してください。

   * ‘as’ と *note with: 59c. は予約語になりました。 (実際には 2.6 から)

   * ‘True’、‘False’、および ‘None’ が予約語になりました。(2.6 では既に
     ‘None’ が部分的に制限されていました)

   * Change from *note except: 170. 'exc', 'var' to ‘except’ 'exc' ‘as’
     'var'.  See PEP 3110(3).

   * PEP 3115(4): 新たなメタクラスのシンタックス．以下の;

          class C:
              __metaclass__ = M
              ...

     代わりに次のようにしてください:

          class C(metaclass=M):
              ...

     モジュールグローバルの ‘__metaclass__’ 変数はもうサポートされません
     。(これは *note object: a5a. を派生しない全てのクラスのデフォルトを
     簡単に新スタイルクラス化するための「松葉杖」でした。) (--訳注: 「新
     /旧スタイルクラス」は Python 2.x 固有の概念。Python 2.1 までの旧式
     クラスと、Python 2.2 で導入された、現在まで続く *note object: a5a.
     を派生する (当時の旧からみた) 新スタイル。Python 2.2 から 2.7 では
     ‘class Clazz:’ は (モジュールグローバルの ‘__metaclass__’ を使わな
     い限り) *note object: a5a. を派生しない旧スタイルクラスでしたが、
     Python 3.x にはもはや「旧スタイルクラス」がないのでこれは Python
     2.2 から 2.7 での ‘class Clazz(object):’ と同じ意味です。--)

   * リスト内包表記はもう ‘[... for VAR in ITEM1, ITEM2, ...]’ という構
     文形をサポートしません。代わりに ‘[... for VAR in (ITEM1, ITEM2,
     ...)]’ を使用してください。また、リスト内包表記は異なるセマンティク
     スを持つことに注意してください。リスト内包表記は *note list(): 5dc.
     コンストラクタ内のジェネレータ式の糖衣構文に近く、特にループの制御
     変数はスコープ外ではもう使用することができません。

   * 'ellipsis' (‘...’) はどこででも原子的な式として使うことが出来ます。
     (以前はスライス内でのみ許されていました。) また、‘...’ と書かなけれ
     ば 'ならなく' なりました。 (以前は文法の些細な偶然により ‘. . .’ と
     書くことも出来ました。)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3109/

   (2) https://peps.python.org/pep-3134/

   (3) https://peps.python.org/pep-3110/

   (4) https://peps.python.org/pep-3115/


File: python.info,  Node: 削除された操作,  Prev: 変更された構文,  Up: 構文の変更の概要

1.14.2.3 削除された操作
.......................

   * PEP 3113(1): タプル引数のアンパックが削除されました.  ‘def foo(a,
     (b, c)): ...’ のように書くことはできません。かわりに ‘def foo(a,
     b_c): b, c = b_c’ を使用してください。

   * バッククオートが削除されました (代わりに *note repr(): 7c8. を使用
     してください)。

   * ‘<>’ が削除されました (代わりに ‘!=’ を使用してください)。

   * 削除されたキーワード: *note exec(): 164. はキーワードでなくなりまし
     たが、関数として残りました。 (幸運にも関数のシンタックスは 2.x でも
     許容されています。) また、 *note exec(): 164. はストリーム引数を受
     け取らなくなりました。‘exec(f)’ の代わりに ‘exec(f.read())’ を使う
     ことができます。

   * ‘l’ または ‘L’ で終わる整数リテラルはサポートされません。

   * ‘u’ or ‘U’ で始まる文字列リテラルはサポートされません。(--訳注: こ
     の ‘u"..."’ は Python 3.3 で再び使えるようになりました。 --)

   * *note from: 127d. 'module' *note import: 5ac. ‘*’ はモジュールレベ
     ルでのみ許され、関数内での使用は許されません。

   * 相対インポートに許される構文は ‘from .[MODULE] import NAME’ のみで
     す。 ‘.’ で始まらない形の全ての *note import: 5ac. は絶対インポート
     と解釈されます。 ( PEP 328(2))

   * 古い形式のクラスはサポートされません。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3113/

   (2) https://peps.python.org/pep-0328/


File: python.info,  Node: Python 2 6 で既にあった変更,  Next: ライブラリの変更,  Prev: 構文の変更の概要,  Up: What's New In Python 3 0

1.14.3 Python 2.6 で既にあった変更
----------------------------------

おそらく多くのユーザが一足飛びに Python 2.5 から Python 3.0 に移行しよう
とするでしょうから、このセクションでは、もともとは Python 3.0 のためにデ
ザインされたものの Python 2.6 にバックポートされた新機能について、読者に
思い出してもらいましょう。 *note What's New in Python 2.6: 127f. 内の対
応するセクションにはもっと長い説明が書かれています。

   * *note PEP 343; "with" ステートメント: 1280.  *note with: 59c. 文は
     今では標準機能となったので、 *note __future__: 0. からインポートす
     る必要はもうありません。 *note コンテキストマネージャを書く: 1281.
     と *note contextlib モジュール: 1282. も見てください。

   * *note PEP 366; メインモジュールからの明示的相対インポート: 1283.
     *note -m: 5ab. オプションの有用性を強化します。パッケージ内にあるモ
     ジュールを参照している際に関係します。

   * *note PEP 370; ユーザごとの site-packages ディレクトリ: 1284.

   * *note PEP 371; multiprocessing パッケージ: 1285.

   * *note PEP 3101; 進化版文字列フォーマッティング: 1286.  注意: 2.6 の
     記述では *note format(): 5eb. メソッドが 8 ビット文字列と Unicode 文
     字列両方について述べていますが、3.0 では *note str: 418. 型
     (Unicode サポートを持ったテキスト文字列) だけがこのメソッドをサポー
     トしています。 *note bytes: 1a4. 型にはありません。計画では最終的に
     はこれだけが唯一の文字列フォーマットの API になり、Python 3.1 では
     ‘%’ 演算子は非推奨扱いを開始する予定です。(-- 訳注: ‘%’ 演算子の撤
     廃は影響が大き過ぎるからか、現実には (ドキュメントでの軽い記述を除
     き) 実行時に特別に非推奨扱いされることは 3.5 になってさえもいまだあ
     りません。 --)

   * *note PEP 3105; print を関数にする: 1287.  これはもはや標準機能とな
     ったので、 *note __future__: 0. からインポートする必要はありません
     。詳細はこのドキュメントの上の方に書いてあります。

   * *note PEP 3110; 例外処理の変更: 1288.  The *note except: 170. 'exc'
     ‘as’ 'var' syntax is now standard and ‘except’ 'exc', 'var' is no
     longer supported.  (Of course, the ‘as’ 'var' part is still
     optional.)

   * *note PEP 3112; バイトリテラル: 1289.  文字列リテラル ‘b"..."’ 表記
     (とそのお仲間 ‘b'...'’, ‘b"""..."""’, ‘br"..."’ など) は今では
     *note bytes: 1a4. 型です。

   * *note PEP 3116; 新しい I/O ライブラリ: 128a.  *note io: 73. モジュ
     ールが今ではファイル I/O の標準手段です。組み込みの *note open():
     4e5. は今では *note io.open(): 4e6. へのエイリアスであり、また、追
     加のキーワード引数 'encoding', 'errors', 'newline', 'closefd' を持
     ちます。不正な 'mode' 引数で *note IOError: 1026. ではなく *note
     ValueError: 1e3. を投げるようになったことにも注意してください。テキ
     ストファイルオブジェクトの背後にあるバイナリファイルオブジェクトに
     は、 ‘f.buffer’ でアクセスできます。(ただしエンコーディング・デコー
     ディング操作の高速化のために、テキストオブジェクトは自身のバッファ
     を保守管理していることに注意してください。)

   * *note PEP 3118; 改訂版バッファプロトコル: 128b.  古いビルトインの
     ‘buffer()’ は本当になくなりました; 新しいビルトイン *note
     memoryview(): 435. が (ほぼ) 同様の機能性を提供します。

   * *note PEP 3119; 抽象基底クラス: 128c.  *note collections: 16. モジ
     ュール内で定義されている *note abc: 4. モジュールと ABC 群が今では
     言語においてもっと目立った役割を演じるようになっていて、たとえば
     *note dict: 237. や *note list: 5dc. のようなビルトインのコレクショ
     ン型はそれぞれ ‘collections.MutableMapping’ と
     ‘collections.MutableSequence’ の ABC に従うようになっています。

   * *note PEP 3127; 整数リテラルのサポートと文法: 128d.  上述のとおり、
     新しい 8 進数リテラル表現だけが唯一の 8 進数リテラル表現となり、ま
     た、バイナリリテラルが追加されました。

   * *note PEP 3129; クラスデコレータ: 128e.

   * *note PEP 3141; 数値の型階層: 128f.  *note numbers: 8e. が、もう一
     つの新しく ABC を使うモジュールで、Python の「数値塔 (numeric
     tower)」を定義しています。新しい *note fractions: 53. モジュールが
     *note numbers.Rational: 1290. を実装していることにも注目してくださ
     い。


File: python.info,  Node: ライブラリの変更,  Next: PEP 3101 文字列整形の新たなアプローチ,  Prev: Python 2 6 で既にあった変更,  Up: What's New In Python 3 0

1.14.4 ライブラリの変更
-----------------------

時間の制約により、この文書は標準ライブラリの非常に幅広い変更について徹底
的に取り上げてはいません。 ライブラリの大きな変更については PEP 3108(1)
を参照してください。 ここでは要約を示します:

   * 多くの古いモジュールは削除されました。 ‘gopherlib’ (もう使われませ
     ん) や ‘md5’ (*note hashlib: 5e. に代替されました) 等のいくつかのモ
     ジュールは PEP 4(2) で既に廃止予定でした。 他のモジュールは、Irix、
     BeOS ならびに Mac OS 9 等のプラットフォームでのサポートが打ち切られ
     た ( PEP 11(3) 参照) ために削除されました。 いくつかのモジュールは
     使われなかったり、より良い代用品があるため Python 3.0 で削除されま
     した 網羅的なリストは PEP 3108(4) を参照してください。

   * The ‘bsddb3’ package was removed because its presence in the core
     standard library has proved over time to be a particular burden for
     the core developers due to testing instability and Berkeley DB's
     release schedule.  However, the package is alive and well,
     externally maintained at
     ‘https://www.jcea.es/programacion/pybsddb.htm’.

   * いくつかのモジュールは PEP 8(5) に従っていないか、その他の理由によ
     り名前が変更されました:

     以前の名前                  新しい名前
                                 
     --------------------------------------------------------
                                 
     _winreg                     winreg
                                 
                                 
     ConfigParser                configparser
                                 
                                 
     copy_reg                    copyreg
                                 
                                 
     Queue                       queue
                                 
                                 
     SocketServer                socketserver
                                 
                                 
     markupbase                  _markupbase
                                 
                                 
     repr                        reprlib
                                 
                                 
     test.test_support           test.support
                                 

   * A common pattern in Python 2.x is to have one version of a module
     implemented in pure Python, with an optional accelerated version
     implemented as a C extension; for example, *note pickle: 95. and
     ‘cPickle’.  This places the burden of importing the accelerated
     version and falling back on the pure Python version on each user of
     these modules.  In Python 3.0, the accelerated versions are
     considered implementation details of the pure Python versions.
     Users should always import the standard version, which attempts to
     import the accelerated version and falls back to the pure Python
     version.  The *note pickle: 95. / ‘cPickle’ pair received this
     treatment.  The *note profile: 9d. module is on the list for 3.1.
     The ‘StringIO’ module has been turned into a class in the *note io:
     73. module.

   * 関連のあるモジュールのいくつかはパッケージにまとめられ、ふつうサブ
     モジュール名は単純化されました。結果として以下のようなパッケージが
     出来ました:

        * *note dbm: 29. (‘anydbm’, ‘dbhash’, ‘dbm’, ‘dumbdbm’, ‘gdbm’,
          ‘whichdb’).

        * *note html: 61. (‘HTMLParser’, ‘htmlentitydefs’).

        * *note http: 64. (‘httplib’, ‘BaseHTTPServer’, ‘CGIHTTPServer’,
          ‘SimpleHTTPServer’, ‘Cookie’, ‘cookielib’).

        * *note tkinter: d9. (*note turtle: ea. を除く全ての ‘Tkinter’ 関
          連のモジュール)。 *note turtle: ea. の対象読者は *note
          tkinter: d9. にそれほど関心がありません。 また、Python 2.6 以
          降では *note turtle: ea. の機能は大幅に向上しました。

        * *note urllib: f1. (‘urllib’, ‘urllib2’, ‘urlparse’,
          ‘robotparse’).

        * ‘xmlrpc’ (‘xmlrpclib’, ‘DocXMLRPCServer’,
          ‘SimpleXMLRPCServer’).

PEP 3108(6) で取り上げられていない標準ライブラリーの他の変更:

   * Killed ‘sets’.  Use the built-in *note set(): 5a3. class.

   * *note sys: c3. モジュールの整理: ‘sys.exitfunc()’,
     ‘sys.exc_clear()’, ‘sys.exc_type’, ‘sys.exc_value’,
     ‘sys.exc_traceback’ は削除されました。(*note sys.last_type: 48b. 等
     はまだあります。)

   * *note array.array: 185. 型の整理: ‘read()’ ならびに ‘write()’ メソ
     ッドは廃止されました。代わりに ‘fromfile()’ ならびに ‘tofile()’ を
     使用してください。また、array 向けの ‘'c'’ タイプコードは廃止されま
     した。バイトには ‘'b'’ 、Unicode 文字には ‘'u'’ を使用してください
     。

   * *note operator: 8f. モジュールの整理: ‘sequenceIncludes()’ および
     ‘isCallable()’ は削除されました。

   * Cleanup of the ‘thread’ module: ‘acquire_lock()’ and
     ‘release_lock()’ are gone; use *note acquire(): 664. and *note
     release(): 1292. instead.

   * *note random: a6. モジュールの整理: ‘jumpahead()’ API は削除されま
     した。

   * The ‘new’ module is gone.

   * 関数 ‘os.tmpnam()’、‘os.tempnam()’ および ‘os.tmpfile()’ は *note
     tempfile: c9. のため削除されました。

   * *note tokenize: e4. モジュールはバイトでも機能するように変更されま
     した。メインのエントリポイントは generate_tokens から *note
     tokenize.tokenize(): 4a6. になりました。

   * ‘string.letters’ and its friends (‘string.lowercase’ and
     ‘string.uppercase’) are gone.  Use *note string.ascii_letters:
     1293. etc.  instead.  (The reason for the removal is that
     ‘string.letters’ and friends had locale-specific behavior, which is
     a bad idea for such attractively named global "constants".)

   * モジュール ‘__builtin__’ が *note builtins: e. にリネームされました
     (アンダースコアの削除と 's' の追加)。 大半の大域名前空間における
     ‘__builtins__’ 変数は変更されていません。 組み込みを変更するには
     ‘__builtins__’ でなく *note builtins: e. を使わなければなりません。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3108/

   (2) https://peps.python.org/pep-0004/

   (3) https://peps.python.org/pep-0011/

   (4) https://peps.python.org/pep-3108/

   (5) https://peps.python.org/pep-0008/

   (6) https://peps.python.org/pep-3108/


File: python.info,  Node: PEP 3101 文字列整形の新たなアプローチ,  Next: 例外に関する変更,  Prev: ライブラリの変更,  Up: What's New In Python 3 0

'PEP 3101': 文字列整形の新たなアプローチ

   * 組み込みの新しい文字列書式化操作で、文字列の ‘%’ 演算子を置き換える
     ものです。(しかしながら ‘%’ 演算子はまだサポートされます; Python
     3.1 で非推奨となり、将来のいつかの時点で削除されます。) 完全な詳細
     は PEP 3101(1) をお読み下さい。 (-- 訳注: *note Python 2.6
     で既にあった変更: 127e. での対応する記述に書いた訳注を参照。--)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3101/


File: python.info,  Node: 例外に関する変更,  Next: その他の変更<2>,  Prev: PEP 3101 文字列整形の新たなアプローチ,  Up: What's New In Python 3 0

1.14.6 例外に関する変更
-----------------------

例外の送出や捕捉を行う API は整理され、 強力な新機能が追加されました:

   * PEP 352(1): 全ての例外は (直接的にまたは間接的に) *note
     BaseException: 584. を継承しなければなりません。 *note
     BaseException: 584. は例外階層の根です。 これは勧告としては新しくあ
     りませんが、*note BaseException: 584. 継承の '要求' は新しいです。
     (Python 2.6 は依然として昔のクラスを送出するのを許容しており、捕捉
     するものについての制限はありません。) 結果として文字列例外は終に本
     当の意味で、完全になくなりました。

   * ほとんど全ての例外は、実際は *note Exception: 9a7. を継承すべきです
     。 *note BaseException: 584. は最上位で扱われるべき例外、例えば
     *note SystemExit: d0e. や *note KeyboardInterrupt: 99f. の基底クラ
     スとしてのみ使われるべきでしす。上記カテゴリーを除く全ての例外を処
     理するのに推奨されるイディオムは *note except: 170. *note
     Exception: 9a7. です。

   * ‘StandardError’ は削除されました。

   * 例外はシーケンスとして振る舞わなくなりました。代わりに ‘args’ 属性
     を使用してください。

   * PEP 3109(2): Raising exceptions.  You must now use ‘raise
     EXCEPTION(ARGS)’ instead of ‘raise EXCEPTION, ARGS’.  Additionally,
     you can no longer explicitly specify a traceback; instead, if you
     'have' to do this, you can assign directly to the *note
     __traceback__: 1296. attribute (see below).

   * PEP 3110(3): 例外の捕捉。 ‘except SOMEEXCEPTION, VARIABLE’ ではなく
     ‘except SOMEEXCEPTION as VARIABLE’ としなければなりません。 その上
     *note except: 170. ブロックがある場合 'variable' は明示的に削除され
     ます。

   * PEP 3134(4): Exception chaining.  There are two cases: implicit
     chaining and explicit chaining.  Implicit chaining happens when an
     exception is raised in an *note except: 170. or *note finally: 997.
     handler block.  This usually happens due to a bug in the handler
     block; we call this a 'secondary' exception.  In this case, the
     original exception (that was being handled) is saved as the *note
     __context__: 1297. attribute of the secondary exception.  Explicit
     chaining is invoked with this syntax:

          raise SecondaryException() from primary_exception

     (where 'primary_exception' is any expression that produces an
     exception object, probably an exception that was previously
     caught).  In this case, the primary exception is stored on the
     *note __cause__: 1298. attribute of the secondary exception.  The
     traceback printed when an unhandled exception occurs walks the
     chain of ‘__cause__’ and *note __context__: 1297. attributes and
     prints a separate traceback for each component of the chain, with
     the primary exception at the top.  (Java users may recognize this
     behavior.)

   * PEP 3134(5): Exception objects now store their traceback as the
     *note __traceback__: 1296. attribute.  This means that an exception
     object now contains all the information pertaining to an exception,
     and there are fewer reasons to use *note sys.exc_info(): 656.
     (though the latter is not removed).

   * Windows が拡張モジュールのロードに失敗したときの例外メッセージが少
     し改善しました。 例えば、‘error code 193’ は ‘%1 is not a valid
     Win32 application’ になりました。 文字列は英語でないロケールを扱え
     るようになりました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0352/

   (2) https://peps.python.org/pep-3109/

   (3) https://peps.python.org/pep-3110/

   (4) https://peps.python.org/pep-3134/

   (5) https://peps.python.org/pep-3134/


File: python.info,  Node: その他の変更<2>,  Next: ビルドならびに C API の変更<7>,  Prev: 例外に関する変更,  Up: What's New In Python 3 0

1.14.7 その他の変更
-------------------

* Menu:

* 演算子と特殊メソッド::
* 組み込み::


File: python.info,  Node: 演算子と特殊メソッド,  Next: 組み込み,  Up: その他の変更<2>

1.14.7.1 演算子と特殊メソッド
.............................

   * ‘!=’ は ‘==’ と逆の結果をかえします（‘==’ が *note NotImplemented:
     79d. を返さなければ）。

   * 「非束縛メソッド (unbound methods)」という概念は言語から削除されま
     した。クラス属性としてのメソッドを参照しても今では普通の関数オブジ
     ェクトが得られます。

   * ‘__getslice__()’, ‘__setslice__()’, ‘__delslice__()’ はお亡くなりに
     なりました。構文 ‘a[i:j]’ は今では ‘a.__getitem__(slice(i, j))’ と
     解釈されます (または代入や削除で使われる場合は順に ‘__setitem__()’
     か ‘__delitem__()’)。

   * PEP 3114(1): *note next(): 7a3. 標準メソッドは *note __next__():
     129b. に改名されました。

   * ‘__oct__()’ ならびに ‘__hex__()’ 特殊メソッドは削除されました。
     *note oct(): 129c. ならびに *note hex(): 129d. は ‘__index__()’ を
     使って引数を整数に変換します。

   * ‘__members__’ と ‘__methods__’ は削除されました。

   * The function attributes named ‘func_X’ have been renamed to use the
     ‘__X__’ form, freeing up these names in the function attribute
     namespace for user-defined attributes.  To wit, ‘func_closure’,
     ‘func_code’, ‘func_defaults’, ‘func_dict’, ‘func_doc’,
     ‘func_globals’, ‘func_name’ were renamed to *note __closure__:
     129e, *note __code__: 27a, *note __defaults__: 129f, *note
     __dict__: 12a0, *note __doc__: 11a9, *note __globals__: 12a1, *note
     __name__: 12a2, respectively.

   * ‘__nonzero__()’ is now *note __bool__(): 12a3.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3114/


File: python.info,  Node: 組み込み,  Prev: 演算子と特殊メソッド,  Up: その他の変更<2>

1.14.7.2 組み込み
.................

   * PEP 3135(1): 新しくなった *note super(): 4a8. 。今では *note
     super(): 4a8. は引数なしで呼び出せます。(これが *note class: 12a5.
     内で定義される通常のインスタンスメソッド内であると仮定して) 正しい
     クラスとインスタンスが自動的に選択されます。引数ありの場合の *note
     super(): 4a8. の振る舞いには変更はありません。

   * PEP 3111(2): ‘raw_input()’ が *note input(): 12a6. にリネームされま
     した。つまり、新しい *note input(): 12a6. 関数は *note sys.stdin:
     507. から行を読み、末尾の改行を取り除いて返します。入力が時期尚早に
     終わってしまったら *note EOFError: 12a7. になります。昔の *note
     input(): 12a6. の振る舞いが欲しければ ‘eval(input())’ としてくださ
     い。

   * 新しい組み込み関数 *note next(): 7a3. が追加されました。 オブジェク
     トの *note __next__(): 129b. メソッドを呼び出します。

   * *note round(): 12a8. 関数の丸めの戦略と戻り値の型が変更されました。
     ど真ん中の場合に、四捨五入ではなく最近接偶数への丸めをするようにな
     りました。(例えば ‘round(2.5)’ は今では ‘2’ を返します。 ‘3’ ではな
     く。) (--訳注: 丸めモードについては Wikipedia(3) 参照。--)
     ‘round(x[, n])’ は常に浮動小数点数の結果を返す代わりに、
     ‘x.__round__([n])’ に処理を委譲するようになりました。これは一般的に
     、単一引数で呼ばれた際に整数を返し、二つの引数で呼ばれた場合は ‘x’
     と同じ型の値として返します。

   * ‘intern()’ は *note sys.intern(): 12a9. に移動しました。

   * ‘apply()’ は削除されました。 ‘apply(f, args)’ の代わりに ‘f(*args)’
     を使用してください。

   * *note callable(): 1196. は削除されました。 ‘callable(f)’ のかわりに
     ‘isinstance(f, collections.Callable)’ を使用してください。
     ‘operator.isCallable()’ も削除されました。

   * ‘coerce()’ は削除されました。古い形式のクラスが削除されたため、この
     関数は必要ありません。

   * ‘execfile()’ は削除されました。 ‘execfile(fn)’ の代わりに
     ‘exec(open(fn).read())’ を使用してください。

   * Removed the ‘file’ type.  Use *note open(): 4e5.  There are now
     several different kinds of streams that open can return in the
     *note io: 73. module.

   * ‘reduce()’ は削除されました。もし本当に必要なら *note
     functools.reduce(): 12aa. を使用してください。ほぼ間違いなく *note
     for: 2c9. ループのほうがより可読性が高いでしょう。

   * Removed ‘reload()’.  Use ‘imp.reload()’.

   * ‘dict.has_key()’ は削除されました - 代わりに *note in: 2cb. 演算子
     を使用してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3135/

   (2) https://peps.python.org/pep-3111/

   (3) https://en.wikipedia.org/wiki/Rounding#Tie-breaking


File: python.info,  Node: ビルドならびに C API の変更<7>,  Next: 性能,  Prev: その他の変更<2>,  Up: What's New In Python 3 0

1.14.8 ビルドならびに C API の変更
----------------------------------

時間がないため、以下のC APIへの変更点のリストは 'かなり' 不完全です。

   * Mac OS 9, BeOS, RISCOS, Irix, Tru64 に限らず、いくつものプラットフ
     ォームのサポートが打ち切られました。

   * PEP 3118(1): 新たなバッファ API。

   * PEP 3121(2): 例外モジュールの初期化と最終化

   * PEP 3123(3): *note PyObject_HEAD: 12ac. を標準的な C に一致。

   * 制限付き実行 の C API サポートはこれ以上されません。

   * ‘PyNumber_Coerce()’, ‘PyNumber_CoerceEx()’, ‘PyMember_Get()’, and
     ‘PyMember_Set()’ C APIs are removed.

   * 新たな C API *note PyImport_ImportModuleNoBlock(): 397.、*note
     PyImport_ImportModule(): 398. のように動きますが、インポートロック
     でブロックしません (代わりにエラーを返します)。

   * ブール変換の C 水準のスロットとメソッドがリネームされました:
     ‘nb_nonzero’ が ‘nb_bool’ になりました。

   * Removed ‘METH_OLDARGS’ and ‘WITH_CYCLE_GC’ from the C API.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3118/

   (2) https://peps.python.org/pep-3121/

   (3) https://peps.python.org/pep-3123/


File: python.info,  Node: 性能,  Next: Python 3 0 への移植,  Prev: ビルドならびに C API の変更<7>,  Up: What's New In Python 3 0

1.14.9 性能
-----------

3.0 の可搬化 (generalization) による正味の結果は、Python 3.0 を pystone
ベンチマークすると Python 2.5 より 10% 遅くなる、というものでした。これ
はどうやら小さい整数についての特殊処理を削除したことに一番大きな要因があ
るようです。これには改善の余地がありますが、それは 3.0 リリース以降でし
ょう!


File: python.info,  Node: Python 3 0 への移植,  Prev: 性能,  Up: What's New In Python 3 0

1.14.10 Python 3.0 への移植
---------------------------

(--訳注: 今では独立したクックブック pyporting-howto があるのでそちらをご
覧下さい。--) 既存の Python 2.5 や 2.6 のソースコードを Python 3.0 に移
植する最良の策は以下の通りです:

  0. (必須:) 優秀なテストカバレッジから始めてください。

  1. Python 2.6 に移植します。Python 2.x を Python 2.(x+1) に移植する普
     通の作業以上のことをしてはいけません。確実に全てのテストを通してく
     ださい。

  2. (まだ 2.6 を使います:) コマンドラインに ‘-3’ オプションを渡します。
     これは 3.0 で削除された (または変更された) 機能についての警告発行を
     有効にします。再びテストスイートを実行して、そして警告が出たコード
     をそれがなくなるまで修正し、全てのテストをパスさせます。

  3. Run the ‘2to3’ source-to-source translator over your source code
     tree.  Run the result of the translation under Python 3.0.
     Manually fix up any remaining issues, fixing problems until all
     tests pass again.

Python 2.6 と 3.0 両方で変更なしに動作するコードを書こうとすることはお奨
め出来ません; それをするととても捻じ曲がったコーディングスタイルを使う必
要があるでしょう。例えば ‘print’ やメタクラスを避けたりとかそんな。
Python 2.6 と 3.0 両バージョンともに対するサポートを必要とするライブラリ
を保守しているのであれば、最良のアプローチは上記スリーステップを修正して
、2.6 版のソースコードを編集して ‘2to3’ する、を繰り返すことです。これは
3.0 版のソースコードを編集するより良いです。(--訳注: ここで言っているこ
とは正論なのですが、 ‘2to3’ は「Python 3 では動くが Python 2 では動かな
い (かもしれない)」ものを生成します。2016 時点でも Python 2.7 はかなり元
気 (予定では 2020 年までは公式にサポートされる) ですので両バージョン (た
だし今だと 2.7 と 3.2 以降) で変更なしで動作するものを必要とすることは、
残念ながらまだ多いでしょう (あなたが作っているのがライブラリであるならば
)。これについては pyporting-howto に少し書かれています。 --)

C 拡張を Python 3.0 に移植するには、 *note Python 3
への拡張モジュール移植: 12af. を参照してください。


File: python.info,  Node: What's New in Python 2 7,  Next: What's New in Python 2 6,  Prev: What's New In Python 3 0,  Up: What's New in Python

1.15 What's New in Python 2.7
=============================


著者: A.M. Kuchling (amk at amk.ca)

この文書は Python 2.7 の新機能について解説します。Python 2.7 は 2010 年
7 月 3 日にリリースされました。

数値周りの扱いが、浮動小数点数でも *note Decimal: 27d. クラスでもいろい
ろな点で改良されました、標準ライブラリにいくつかの有用な追加が行われまし
た。 *note unittest: ef. モジュールが大幅に改良され、コマンドラインオプ
ション解析の *note argparse: 5. モジュールが追加され、 *note
collections: 16. モジュールに便利な *note OrderedDict: 5a5. と *note
Counter: 1067. が追加され、他にもたくさんの改良が行われています。

Python 2.7 は 2.x の最終リリースになることが予定されているので、私たちは
このリリースを長期にわたって良いものになるように努力してきました。Python
3 への移植を助けるため、いくつかの新機能が Python 3.x から Python 2.7 に
取り込まれています。

このドキュメントは新機能の完全な詳細を提供するのではなくて、簡易な概要を
提供することを目的にしています。完全な詳細が知りたければ、
‘https://docs.python.org’ の Python 2.7 のドキュメントを参照してください
。設計と実装の根拠を理解したい場合は、新機能に関する PEP を参照するか、
‘https://bugs.python.org’ に議論したい機能について登録してください。可能
な限り、 "What's New in Python" は各変更の bug や patch に対してリンクし
ています。

* Menu:

* Python 2.x の今後: Python 2 x の今後.
* Deprecation Warnings の扱いの変更::
* Python 3.1 の機能: Python 3 1 の機能.
* PEP 372; collections に順序付き辞書を追加: PEP 372 collections に順序付き辞書を追加.
* PEP 378; 1000区切りのための書式指定子: PEP 378 1000区切りのための書式指定子<2>.
* PEP 389; コマンドライン解析のための argparse モジュール: PEP 389 コマンドライン解析のための argparse モジュール.
* PEP 391; logging の辞書ベースの設定: PEP 391 logging の辞書ベースの設定<2>.
* PEP 3106; 辞書 View: PEP 3106 辞書 View.
* PEP 3137; memoryview オブジェクト: PEP 3137 memoryview オブジェクト.
* その他の言語変更: その他の言語変更<12>.
* 新しいモジュールと改良されたモジュール::
* ビルドならびに C API の変更: ビルドならびに C API の変更<8>.
* その他の変更と修正::
* Python 2.7 への移植: Python 2 7 への移植.
* Python 2.7 メンテナンスリリースで追加された新機能: Python 2 7 メンテナンスリリースで追加された新機能.
* 謝辞::


File: python.info,  Node: Python 2 x の今後,  Next: Deprecation Warnings の扱いの変更,  Up: What's New in Python 2 7

1.15.1 Python 2.x の今後
------------------------

Python 2.7 は 2.x シリーズの最後のメジャーリリースになります。Python の
メンテナは既に Python 3.x シリーズへの新機能の開発に焦点をシフトしていま
す。Python 2 は今後もバグフィックスを受け容れ、新しいハードウェアやサポ
ートしている OS のバージョンでのビルドが出来るように保つ一方で、言語や標
準ライブラリの新しい完全な機能のリリースは行いません。

しかしながら、Python 2.7 と Python 3 の間の共通の大きなサブセットがあっ
て、その共通サブセットあるいは直接的に Python 3 のものへの移行に伴う多く
の変更が安全に自動的に行える一方で、その他の変更(Unicode の扱いに関係す
るものに顕著ですが)入念な検討を必要とし、移行を有効に行うためには堅牢な
回帰テストスイートが望まれることでしょう。

これは Python 2.7 が長期間に渡って依然として有効であり、安定性と、Python
3 がいまだに移植されていないような製品システムのベースプラットフォームの
サポートを提供し続けることを意味しています。Python 2.7 シリーズに望まれ
ているライフサイクルについての完全な詳細は、 PEP 373(1) に記述されていま
す。

2.7 が長期的に重要なリリースになるので、いくつかの結論があります:

   * 上述のように、 2.7 リリースは以前の 2.x バージョンに較べて遥かに長
     期間のメンテナンスとなります。Python 2.7 は現在では、最低でも 2020
     年までコア開発チームによって(セキュリティアップデートやほかのバグフ
     ィックスの)サポートがなされ続けることが求められています(最初のリリ
     ースから 10 年後です。普通であれば 18-24 ヶ月なのに)。

   * Python 2.7 標準ライブラリが年老いていくに従い、(直接であれ再配布で
     あれ) Python Package Index の効果的な利用が Python 2 ユーザにとって
     ますます重要になっています。さまざまなタスクをこなすありとあらゆる
     サードパーティパッケージに加え、Python 2 互換の、Python 3 標準ライ
     ブラリからバックポートした新しいモジュールや機能を含むパッケージ、
     Python 3 への移行を容易にするための様々なツールやライブラリが入手出
     来ます。Python Packaging User Guide(2) は Python Package Index から
     ソフトウェアをダウンロード・インストールする際のガイダンスです。

   * Python 2 を拡張するための望ましいアプローチは現在では Python
     Package Index に新しいパッケージを公開することである一方で、このア
     プローチが全てのケースで求められるわけではありません。特にそれがネ
     ットワークセキュリティに関係している場合には。PyPI に新規もしくは更
     新パッケージを公開することでは十分ではない例外的なケースにおいては
     、Python 2 標準ライブラリに直接新機能を追加するために Python
     Enhancement Proposal プロセスが使われるでしょう。そのような追加の全
     てと、それらが追加されたメンテナンスリリースは、下の方の *note
     Python 2.7 メンテナンスリリースで追加された新機能: 12b4. セクション
     で言及されます。

Python 2 から Python 3 へ乗り換えたいと望むプロジェクトあるいはPython 2
と Python 3 両方のユーザをサポートしたいと願うライブラリやフレームワーク
の開発者向けに、さまざまなツールやガイドがあります。これらは、相応しいア
プローチを決めたりある種複雑な技術的詳細の管理をする手助けとなるでしょう
。まず手始めには pyporting-howto HOWTO ガイドをご覧になることをお奨めし
ます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0373/

   (2) https://packaging.python.org


File: python.info,  Node: Deprecation Warnings の扱いの変更,  Next: Python 3 1 の機能,  Prev: Python 2 x の今後,  Up: What's New in Python 2 7

1.15.2 Deprecation Warnings の扱いの変更
----------------------------------------

Python 2.7 では開発者向けの警告をデフォルトで抑止するポリシーが取られま
した。 *note DeprecationWarning: 18a. とそれを継承した警告は、指定されな
い限りは無視され、アプリケーションのユーザーがその警告を見ないですむよう
になりました。この変更は Python 3.2 ブランチにも適用されました。
(stdlib-sig で討議され、 bpo-7319(1) になりました)

以前のリリースでは、 *note DeprecationWarning: 18a. メッセージはデフォル
トで有効になっており、 Python 開発者に、将来のバージョンの Python でその
コードのどこが動かなくなるかを明確に知らせていました。

しかし、 Python で開発されたアプリケーションの利用者であって開発には携わ
っていない人がどんどん増えてきました。 *note DeprecationWarning: 18a. メ
ッセージはそれらのユーザーには無関係で、彼らをアプリケーションが本当に正
しく動いているのか不安にさせ、ユーザーの質問に応えるための開発者の負担も
増やしていました。

*note DeprecationWarning: 18a. メッセージの表示を有効にするには、 *note
-Wdefault: 896. (短い形式: *note -Wd: 896.) スイッチか、Python を実行す
る前に *note PYTHONWARNINGS: b78. 環境変数を ‘"default"’ (か、 ‘"d"’)に
設定します。 Python コードから有効にする場合は
‘warnings.simplefilter('default')’ とします。

‘unittest’ モジュールもテスト実行時に自動的に deprecation warnings を有
効にします。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=7319


File: python.info,  Node: Python 3 1 の機能,  Next: PEP 372 collections に順序付き辞書を追加,  Prev: Deprecation Warnings の扱いの変更,  Up: What's New in Python 2 7

1.15.3 Python 3.1 の機能
------------------------

Python 2.6 は Python 3.0 から多くの機能を取り込み、Python 2.7 は Python
3.1 の新しい機能のいくつかを取り込みました。2.x シリーズは 3.x シリーズ
への移行のためのツールを提供し続けています。

Python 2.7 に取り込まれた 3.1 の機能の不完全なリスト:

   * 集合のリテラル文法 (‘{1,2,3}’ は mutable set になります)

   * 辞書と集合の内包表記 (‘{i: i*2 for i in range(3)}’).

   * 1つの *note with: 59c. 文で複数のコンテキストマネージャを扱えるよう
     に。

   * *note io: 73. ライブラリの新バージョン。パフォーマンスのためにC言語
     で描き直されています。

   * *note PEP 372; collections に順序付き辞書を追加: 12b7. で解説されて
     いる順序付き辞書

   * *note PEP 378; 1000区切りのための書式指定子: 12b8. で解説されている
     新しい ‘","’ フォーマット指定子

   * *note memoryview: 435. オブジェクト

   * *note importlib: 6b. モジュールの小さいサブセット。 *note
     下に説明があります: 12b9.

   * float ‘x’ の *note repr(): 7c8. が多くの場合に短くなりました。これ
     は ‘x’ に戻せることが保証される最小の10進文字列です。以前のバージョ
     ンの Python では、 ‘float(repr(x))’ が ‘x’ になることだけが保証され
     ていました。

   * float から文字列、文字列から float への変換が正しく丸められるように
     なりました。 *note round(): 12a8. 関数も正しく丸めるようになりまし
     た。

   * 拡張モジュールが C API を提供するための、 *note PyCapsule: 1244. 型

   * *note PyLong_AsLongAndOverflow(): 1237. C API 関数

新しい Python3 モード Warning:

   * ‘operator.isCallable()’ と ‘operator.sequenceIncludes()’ は 3.x で
     はサポートされず、警告が表示されます。

   * ‘-3’ スイッチは、整数または長整数での古い除算方式を使用した場合に警
     告を出力するようになる ‘-Qwarn’ スイッチを有効にするようになりまし
     た。


File: python.info,  Node: PEP 372 collections に順序付き辞書を追加,  Next: PEP 378 1000区切りのための書式指定子<2>,  Prev: Python 3 1 の機能,  Up: What's New in Python 2 7

1.15.4 PEP 372: collections に順序付き辞書を追加
------------------------------------------------

通常の Python 辞書は、 key/value ペアを不定の順序でイテレートします。何
年にもわたり、いろいろな人が key の挿入順を保存する辞書の別実装を書いて
きました。その経験に基づき、 2.7 は *note collections: 16. モジュールに
新しい *note OrderedDict: 5a5. クラスを追加しました。

*note OrderedDict: 5a5. API は通常の辞書と同じインターフェースを提供して
いますが、 key/value をイテレートするときに key が最初に挿入された順番に
なることが保証されています。

     >>> from collections import OrderedDict
     >>> d = OrderedDict([('first', 1),
     ...                  ('second', 2),
     ...                  ('third', 3)])
     >>> d.items()
     [('first', 1), ('second', 2), ('third', 3)]

新しいエントリが既存のエントリを上書きした場合は、元の挿入順序が保持され
ます。:

     >>> d['second'] = 4
     >>> d.items()
     [('first', 1), ('second', 4), ('third', 3)]

エントリを削除して再挿入すると、順序は一番最後に移動します。:

     >>> del d['second']
     >>> d['second'] = 5
     >>> d.items()
     [('first', 1), ('third', 3), ('second', 5)]

*note popitem(): 12bb. メソッドは、オプションの 'last' 引数を持ち、でフ
ォルトで ‘True’ になっています。 'last' が真の場合、一番最近に追加された
key が返され、削除されます。偽の場合、最も古い key が選ばれます:

     >>> od = OrderedDict([(x,0) for x in range(20)])
     >>> od.popitem()
     (19, 0)
     >>> od.popitem()
     (18, 0)
     >>> od.popitem(last=False)
     (0, 0)
     >>> od.popitem(last=False)
     (1, 0)

2つの順序付き辞書を比較するときは、key/value だけでなく、挿入順も比較さ
れます。:

     >>> od1 = OrderedDict([('first', 1),
     ...                    ('second', 2),
     ...                    ('third', 3)])
     >>> od2 = OrderedDict([('third', 3),
     ...                    ('first', 1),
     ...                    ('second', 2)])
     >>> od1 == od2
     False
     >>> # Move 'third' key to the end
     >>> del od2['third']; od2['third'] = 3
     >>> od1 == od2
     True

*note OrderedDict: 5a5. を通常の辞書と比較すると、挿入順は無視されて単に
key/value だけが比較されます。

How does the *note OrderedDict: 5a5. work?  It maintains a doubly linked
list of keys, appending new keys to the list as they're inserted.  A
secondary dictionary maps keys to their corresponding list node, so
deletion doesn't have to traverse the entire linked list and therefore
remains 'O'(1).

標準ライブラリのいくつかのモジュールで、順序付き辞書の利用がサポートされ
ています。

   * The *note ConfigParser: 1b. module uses them by default, meaning
     that configuration files can now be read, modified, and then
     written back in their original order.

   * The *note _asdict(): 9af. method for *note
     collections.namedtuple(): 1ac. now returns an ordered dictionary
     with the values appearing in the same order as the underlying tuple
     indices.

   * The *note json: 76. module's *note JSONDecoder: d15. class
     constructor was extended with an 'object_pairs_hook' parameter to
     allow ‘OrderedDict’ instances to be built by the decoder.  Support
     was also added for third-party tools like PyYAML(1).

参考
....

PEP 372(2) - collections に順序付き辞書を追加

     PEP written by Armin Ronacher and Raymond Hettinger; implemented by
     Raymond Hettinger.

   ---------- Footnotes ----------

   (1) https://pyyaml.org/

   (2) https://peps.python.org/pep-0372/


File: python.info,  Node: PEP 378 1000区切りのための書式指定子<2>,  Next: PEP 389 コマンドライン解析のための argparse モジュール,  Prev: PEP 372 collections に順序付き辞書を追加,  Up: What's New in Python 2 7

1.15.5 PEP 378: 1000区切りのための書式指定子
--------------------------------------------

大きい数値に区切り文字を追加して、18446744073709551616 の代わりに
18,446,744,073,709,551,616 と出力すると、プログラムの出力を読みやすくで
きます。

これを行う一般的な方法は *note locale: 7a. モジュールを使うことで、複数
の区切り文字 (北米では "," で、ヨーロッパでは ".")  を使ったり、複数のグ
ループの大きさを使うことができます。しかし、 *note locale: 7a. の利用方
法は複雑ですし、スレッドごとに異なるロケールの出力を行うプログラムでは利
用することができません。

そのため、シンプルなカンマによるグループ化機構が *note str.format():
5ed. メソッドのミニ言語に追加されました。浮動小数点数をフォーマットする
場合、シンプルにカンマを幅と精度の間に置きます。

     >>> '{:20,.2f}'.format(18446744073709551616.0)
     '18,446,744,073,709,551,616.00'

整数をフォーマットする場合は、幅の後にカンマを追加します。

     >>> '{:20,d}'.format(18446744073709551616)
     '18,446,744,073,709,551,616'

この機構は全く柔軟性を持っていません。区切り文字は常にカンマですし、グル
ープは常に数字3つになります。カンマ書式機構は *note locale: 7a. ほど汎用
ではありませんが、手軽に使うことができます。

参考
....

PEP 378(1) - 1000区切りのための書式指定子

     PEP written by Raymond Hettinger; implemented by Eric Smith.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0378/


File: python.info,  Node: PEP 389 コマンドライン解析のための argparse モジュール,  Next: PEP 391 logging の辞書ベースの設定<2>,  Prev: PEP 378 1000区切りのための書式指定子<2>,  Up: What's New in Python 2 7

1.15.6 PEP 389: コマンドライン解析のための argparse モジュール
--------------------------------------------------------------

コマンドライン引数の解析のための *note argparse: 5. モジュールが、 *note
optparse: 90. モジュールのより強力な代替として追加されました。

This means Python now supports three different modules for parsing
command-line arguments: *note getopt: 57, *note optparse: 90, and *note
argparse: 5.  The *note getopt: 57. module closely resembles the C
library's ‘getopt()’ function, so it remains useful if you're writing a
Python prototype that will eventually be rewritten in C. *note optparse:
90. becomes redundant, but there are no plans to remove it because there
are many scripts still using it, and there's no automated way to update
these scripts.  (Making the *note argparse: 5. API consistent with *note
optparse: 90.'s interface was discussed but rejected as too messy and
difficult.)

古いバージョンの Python との互換性を気にすること無く新しいスクリプトを書
く時は、 *note optparse: 90. の代わりに *note argparse: 5. を使ってくだ
さい。

以下はこの使用例です:

     import argparse

     parser = argparse.ArgumentParser(description='Command-line example.')

     # Add optional switches
     parser.add_argument('-v', action='store_true', dest='is_verbose',
                         help='produce verbose output')
     parser.add_argument('-o', action='store', dest='output',
                         metavar='FILE',
                         help='direct output to FILE instead of stdout')
     parser.add_argument('-C', action='store', type=int, dest='context',
                         metavar='NUM', default=0,
                         help='display NUM lines of added context')

     # Allow any number of additional arguments.
     parser.add_argument(nargs='*', action='store', dest='inputs',
                         help='input filenames (default is stdin)')

     args = parser.parse_args()
     print args.__dict__

オーバーライドしない限り、 ‘-h’ と ‘--help’ スイッチが自動的に追加され、
綺麗にフォーマットした出力を生成します。

     -> ./python.exe argparse-example.py --help
     usage: argparse-example.py [-h] [-v] [-o FILE] [-C NUM] [inputs [inputs ...]]

     Command-line example.

     positional arguments:
       inputs      input filenames (default is stdin)

     optional arguments:
       -h, --help  show this help message and exit
       -v          produce verbose output
       -o FILE     direct output to FILE instead of stdout
       -C NUM      display NUM lines of added context

*note optparse: 90. と同じく、コマンドラインスイッチと引数は、 'dest' 引
数の名前の属性をもったオブジェクトとして返されます。

     -> ./python.exe argparse-example.py -v
     {'output': None,
      'is_verbose': True,
      'context': 0,
      'inputs': []}

     -> ./python.exe argparse-example.py -v -o /tmp/output -C 4 file1 file2
     {'output': '/tmp/output',
      'is_verbose': True,
      'context': 4,
      'inputs': ['file1', 'file2']}

*note argparse: 5. は *note optparse: 90. よりも多くの便利なバリデーショ
ンを持っています。引数の正確な数を整数で指定したり、 ‘'*'’ で0以上の数を
指定したり、 ‘'+'’ で1以上の数を指定したり、 ‘'?'’ でオプションにしたり
できます。トップレベルのパーサーはサブパーサーを持つことができ、 ‘svn
commit’, ‘svn checkout’ のように異なるオプションを持ったサブコマンドを定
義できます。引数のタイプに *note FileType: ee7. を指定することで、自動で
ファイルを開き、 ‘'-'’ が指定されたときに標準入出力だと判断することがで
きます。

参考
....

*note argparse: 5. のドキュメント

     argparse モジュールのドキュメント

*note Upgrading optparse code: 117e.

     *note optparse: 90. を使うコードを変換する方法を説明した Python の
     ドキュメントの一部

PEP 389(1) - argparse コマンドライン解析モジュール

     PEP written and implemented by Steven Bethard.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0389/


File: python.info,  Node: PEP 391 logging の辞書ベースの設定<2>,  Next: PEP 3106 辞書 View,  Prev: PEP 389 コマンドライン解析のための argparse モジュール,  Up: What's New in Python 2 7

1.15.7 PEP 391: logging の辞書ベースの設定
------------------------------------------

*note logging: 7b. モジュールは非常に柔軟です。アプリケーションは
logging のサブシステムのツリーを定義できます。このツリーの各ロガーはいく
つかのメッセージをフィルターし、異なるフォーマットを行い、メッセージを沢
山の種類のハンドラーに渡します。

All this flexibility can require a lot of configuration.  You can write
Python statements to create objects and set their properties, but a
complex set-up requires verbose but boring code.  *note logging: 7b.
also supports a *note fileConfig(): b1f. function that parses a file,
but the file format doesn't support configuring filters, and it's
messier to generate programmatically.

Python 2.7 adds a *note dictConfig(): 1180. function that uses a
dictionary to configure logging.  There are many ways to produce a
dictionary from different sources: construct one with code; parse a file
containing JSON; or use a YAML parsing library if one is installed.  For
more information see *note 環境設定のための関数: 12bf.

以下は、2つのロガー、 root logger と "network" という名前の logger を設
定する例です。root logger に送られたメッセージは syslog プロトコルを利用
してシステムログに送られ、 "network" logger に送られたメッセージは 1 MB
ごとにローテートされる ‘network.log’ ファイルに書きこまれます。

     import logging
     import logging.config

     configdict = {
      'version': 1,    # Configuration schema in use; must be 1 for now
      'formatters': {
          'standard': {
              'format': ('%(asctime)s %(name)-15s '
                         '%(levelname)-8s %(message)s')}},

      'handlers': {'netlog': {'backupCount': 10,
                          'class': 'logging.handlers.RotatingFileHandler',
                          'filename': '/logs/network.log',
                          'formatter': 'standard',
                          'level': 'INFO',
                          'maxBytes': 1000000},
                   'syslog': {'class': 'logging.handlers.SysLogHandler',
                              'formatter': 'standard',
                              'level': 'ERROR'}},

      # Specify all the subordinate loggers
      'loggers': {
                  'network': {
                              'handlers': ['netlog']
                  }
      },
      # Specify properties of the root logger
      'root': {
               'handlers': ['syslog']
      },
     }

     # Set up configuration
     logging.config.dictConfig(configdict)

     # As an example, log two error messages
     logger = logging.getLogger('/')
     logger.error('Database not found')

     netlogger = logging.getLogger('network')
     netlogger.error('Connection failed')

他にも、 *note logging: 7b. モジュールには Vinary Sajip によって実装され
た 3 つの改良があります。

   * *note SysLogHandler: 628. クラスは TCP 経由の syslog をサポートしま
     す。コンストラクタの 'socktype' 引数は使用するソケットの種類として
     、 UDP を使う *note socket.SOCK_DGRAM: 12c0. と TCP を使う *note
     socket.SOCK_STREAM: 12c1. のどちらかを取ります。デフォルトはUDPのま
     まです。

   * *note Logger: b1d. インスタンスに *note getChild(): 12c2. メソッド
     が追加されました。これは、相対パスで下位の logger を返します。 例え
     ば、 ‘log = getLogger('app')’ として logger を取得した後、
     ‘log.getChild('network.listen')’ は
     ‘getLogger('app.network.listen')’ と同じになります。

   * The *note LoggerAdapter: 12c3. class gained an *note
     isEnabledFor(): 12c4. method that takes a 'level' and returns
     whether the underlying logger would process a message of that level
     of importance.

参考
....

PEP 391(1) - logging の辞書ベースの設定

     PEP written and implemented by Vinay Sajip.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0391/


File: python.info,  Node: PEP 3106 辞書 View,  Next: PEP 3137 memoryview オブジェクト,  Prev: PEP 391 logging の辞書ベースの設定<2>,  Up: What's New in Python 2 7

1.15.8 PEP 3106: 辞書 View
--------------------------

辞書の *note keys(): 798, *note values(): 799, *note items(): 79a. メソ
ッドは Python 3.x では動作が代わり、完全に実体化されたリストの代わりに、
'view' と呼ばれるオブジェクトを返すようになりました。

It's not possible to change the return values of *note keys(): 798,
*note values(): 799, and *note items(): 79a. in Python 2.7 because too
much code would break.  Instead the 3.x versions were added under the
new names ‘viewkeys()’, ‘viewvalues()’, and ‘viewitems()’.

     >>> d = dict((i*10, chr(65+i)) for i in range(26))
     >>> d
     {0: 'A', 130: 'N', 10: 'B', 140: 'O', 20: ..., 250: 'Z'}
     >>> d.viewkeys()
     dict_keys([0, 130, 10, 140, 20, 150, 30, ..., 250])

View はイテレートするだけでなく、set と似た利用をすることもできます。‘&’
演算子で共通部分集合を、‘|’ 演算子で話集合を取ることができます。

     >>> d1 = dict((i*10, chr(65+i)) for i in range(26))
     >>> d2 = dict((i**.5, i) for i in range(1000))
     >>> d1.viewkeys() & d2.viewkeys()
     set([0.0, 10.0, 20.0, 30.0])
     >>> d1.viewkeys() | range(0, 30)
     set([0, 1, 130, 3, 4, 5, 6, ..., 120, 250])

view は辞書とその辞書の変化に追随しています。:

     >>> vk = d.viewkeys()
     >>> vk
     dict_keys([0, 130, 10, ..., 250])
     >>> d[260] = '&'
     >>> vk
     dict_keys([0, 130, 260, 10, ..., 250])

ただし、view をイテレートしている間に key の追加や削除ができないことに気
を付けてください。:

     >>> for k in vk:
     ...     d[k*2] = k
     ...
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     RuntimeError: dictionary changed size during iteration

Python 2.x で view メソッドを利用すると、 2to3 が自動的にそれを通常の
*note keys(): 798, *note values(): 799, *note items(): 79a. メソッドに書
き換えてくれます。

参考
....

PEP 3106(1) - Revamping dict.keys(), .values() and .items()

     PEP written by Guido van Rossum.  Backported to 2.7 by Alexandre
     Vassalotti; bpo-1967(2).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3106/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1967


File: python.info,  Node: PEP 3137 memoryview オブジェクト,  Next: その他の言語変更<12>,  Prev: PEP 3106 辞書 View,  Up: What's New in Python 2 7

1.15.9 PEP 3137: memoryview オブジェクト
----------------------------------------

*note memoryview: 435. オブジェクトは、他のオブジェクトのメモリの内容に
対する *note bytes: 1a4. 型のインターフェースに合わせた view を提供しま
す。

     >>> import string
     >>> m = memoryview(string.letters)
     >>> m
     <memory at 0x37f850>
     >>> len(m)           # Returns length of underlying object
     52
     >>> m[0], m[25], m[26]   # Indexing returns one byte
     ('a', 'z', 'A')
     >>> m2 = m[0:26]         # Slicing returns another memoryview
     >>> m2
     <memory at 0x37f080>

view の内容は bytes 型の文字列か整数のリストに変換することができます。

     >>> m2.tobytes()
     'abcdefghijklmnopqrstuvwxyz'
     >>> m2.tolist()
     [97, 98, 99, 100, 101, 102, 103, ... 121, 122]
     >>>

*note memoryview: 435. オブジェクトは、対象となる背後のオブジェクトが変
更可能 (mutable) な場合は、その変更を許可しています。

     >>> m2[0] = 75
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: cannot modify read-only memory
     >>> b = bytearray(string.letters)  # Creating a mutable object
     >>> b
     bytearray(b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
     >>> mb = memoryview(b)
     >>> mb[0] = '*'         # Assign to view, changing the bytearray.
     >>> b[0:5]              # The bytearray has been changed.
     bytearray(b'*bcde')
     >>>

参考
....

PEP 3137(1) - Immutable Bytes and Mutable Buffer

     PEP written by Guido van Rossum.  Implemented by Travis Oliphant,
     Antoine Pitrou and others.  Backported to 2.7 by Antoine Pitrou;
     bpo-2396(2).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3137/

   (2) https://bugs.python.org/issue?@action=redirect&bpo=2396


File: python.info,  Node: その他の言語変更<12>,  Next: 新しいモジュールと改良されたモジュール,  Prev: PEP 3137 memoryview オブジェクト,  Up: What's New in Python 2 7

1.15.10 その他の言語変更
------------------------

Python 言語コアに小さな変更がいくつか行われました:

   * set リテラルのためのシンタックスが Python 3.x からバックポートされ
     ました。内容を波括弧で囲うと mutable set になります。dict リテラル
     との区別は、コロンと value が存在しないことで行われます。なので、
     ‘{}’ は引き続き空の dict になります。空の set を作るときには
     ‘set()’ を使ってください。

          >>> {1, 2, 3, 4, 5}
          set([1, 2, 3, 4, 5])
          >>> set() # empty set
          set([])
          >>> {}    # empty dict
          {}

     Backported by Alexandre Vassalotti; bpo-2335(1).

   * dict と set の内包表記も Python 3.x からバックポートされました。
     list と generator の内包表記を set と dict にも使えるように一般化さ
     せています。

          >>> {x: x*x for x in range(6)}
          {0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
          >>> {('a'*x) for x in range(6)}
          set(['', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa'])

     Backported by Alexandre Vassalotti; bpo-2333(2).

   * *note with: 59c. 文が1つの文で複数のコンテキストマネージャーを使え
     るようになりました。コンテキストマネージャーは左から右へ処理され、
     それぞれが新しい ‘with’ 文の開始となるように扱われます。つまり:

          with A() as a, B() as b:
              ... suite of statements ...

     は、以下と同じです

          with A() as a:
              with B() as b:
                  ... suite of statements ...

     The ‘contextlib.nested()’ function provides a very similar
     function, so it's no longer necessary and has been deprecated.

     (Proposed in ‘https://codereview.appspot.com/53094’; implemented by
     Georg Brandl.)

   * 浮動小数点数と文字列の間の変換がほとんどのプラットフォームで正しく
     丸められるようになりました。この変換はいろいろな場面で発生します:
     float 型や complex 型に対する *note str(): 418. 関数の適用、 *note
     float: 2ce. や *note complex: 2cf. コンストラクタ、数値フォーマット
     、 *note marshal: 80, *note pickle: 95, *note json: 76. モジュール
     を使ってのシリアライズとデシリアライズ、 Python コード中の float や
     imaginary リテラルの解析、 *note Decimal: 27d. から float への変換
     などです。

     これに関連して、浮動小数点数 'x' の *note repr(): 7c8. は、
     (round-half-to-even 丸めモードで)正しく丸め処理をした場合に元の 'x'
     に戻せる最小の 10進文字列になりました。以前は 'x' を17桁の10進文字
     列に丸めていました。

     丸めライブラリが、この改善が Windows や gcc, icc, suncc を使った
     Unix 環境で動かす役目をおっています。このライブラリの正確な動作が保
     証できない少しの環境があるので、そういったシステムではこのライブラ
     リは利用されません。 *note sys.float_repr_style: 12c8. が ‘short’ な
     ら新しいコードが利用されていて、 ‘legacy’ なら利用されていません。

     Implemented by Eric Smith and Mark Dickinson, using David Gay's
     ‘dtoa.c’ library; bpo-7117(3).

   * 多倍長整数や通常の整数から浮動小数点への変換でも丸め処理が変更され
     、元の数に一番近い浮動小数点値が返されるようになりました。これは浮
     動小数点へ完全に変換できる小さい整数では問題になりませんが、桁数に
     対して精度がどうしても足りない場合に関係します。Python 2.7 はより正
     確に近似するようになりました。例えば、Python 2.6 では次のように計算
     されていました:

          >>> n = 295147905179352891391
          >>> float(n)
          2.9514790517935283e+20
          >>> n - long(float(n))
          65535L

     Python 2.7 の浮動小数点への変換結果は元の数値より大きくなりますが、
     元の値により近くなっています:

          >>> n = 295147905179352891391
          >>> float(n)
          2.9514790517935289e+20
          >>> n - long(float(n))
          -1L

     (Implemented by Mark Dickinson; bpo-3166(4).)

     この丸めの動作により、整数同士の true division (‘from __future__
     import division’) の結果もより正確になりました。 (Also implemented
     by Mark Dickinson; bpo-1811(5).)

   * Implicit coercion for complex numbers has been removed; the
     interpreter will no longer ever attempt to call a ‘__coerce__()’
     method on complex objects.  (Removed by Meador Inge and Mark
     Dickinson; bpo-5211(6).)

   * *note str.format(): 5ed. メソッドは置換フィールドに対する自動ナンバ
     リングをサポートするようになりました。これにより *note
     str.format(): 5ed. をより ‘%s’ と同じように使えるようになりました。

          >>> '{}:{}:{}'.format(2009, 04, 'Sunday')
          '2009:4:Sunday'
          >>> '{}:{}:{day}'.format(2009, 4, day='Sunday')
          '2009:4:Sunday'

     自動ナンバリングは左のフィールドから右のフィールドへと行われるので
     、最初の ‘{...}’ 指定は *note str.format(): 5ed. メソッドの最初の引
     数を利用し、次の指定は次の引数を利用します。自動ナンバリングと明示
     的なナンバリングを混ぜて使うことはできず、全ての置換指定に手動でナ
     ンバリングするか、全てを自動ナンバリングに任せなければなりません。
     ただし、上の例の2つめのように、自動ナンバリングと名前フィールドを混
     ぜて使うことは可能です。 (Contributed by Eric Smith; bpo-5237(7).)

     複素数が *note format(): 5eb. をサポートするようになりました。デフ
     ォルトでは右寄せになります。精度やカンマ区切りの指定は、実部と虚部
     のそれぞれに対して適用されます。アラインの指定は ‘1.5+3j’ のような
     複素数全体に対して適用されます。 (Contributed by Eric Smith;
     bpo-1588(8) and bpo-7988(9).)

     'F' 書式符号は常に大文字を使って出力するようになり、 'INF' や 'NAN'
     が出力されるようになりました。 (Contributed by Eric Smith;
     bpo-3382(10).)

     A low-level change: the *note object.__format__(): 5ea. method now
     triggers a *note PendingDeprecationWarning: 895. if it's passed a
     format string, because the ‘__format__()’ method for *note object:
     a5a. converts the object to a string representation and formats
     that.  Previously the method silently applied the format string to
     the string representation, but that could hide mistakes in Python
     code.  If you're supplying formatting information such as an
     alignment or precision, presumably you're expecting the formatting
     to be applied in some object-specific way.  (Fixed by Eric Smith;
     bpo-7994(11).)

   * The *note int(): 238. and ‘long()’ types gained a ‘bit_length’
     method that returns the number of bits necessary to represent its
     argument in binary:

          >>> n = 37
          >>> bin(n)
          '0b100101'
          >>> n.bit_length()
          6
          >>> n = 2**123-1
          >>> n.bit_length()
          123
          >>> (n+1).bit_length()
          124

     (Contributed by Fredrik Johansson and Victor Stinner;
     bpo-3439(12).)

   * *note import: 5ac. 文が、絶対インポート (例: ‘from .os import
     sep’)が失敗したときに相対インポートを試さなくなりました。これはバグ
     修正ですが、いままでたまたま動いていただけの ‘import’ 文を動かなく
     してしまう可能性があります。(Fixed by Meador Inge; bpo-7902(13).)

   * It's now possible for a subclass of the built-in ‘unicode’ type to
     override the ‘__unicode__()’ method.  (Implemented by Victor
     Stinner; bpo-1583863(14).)

   * *note bytearray: 508. 型の *note translate(): 12c9. メソッドが第一
     引数に ‘None’ を受け入れるようになりました。 (Fixed by Georg
     Brandl; bpo-4759(15).)

   * When using *note @classmethod: 14c. and *note @staticmethod: 3ef.
     to wrap methods as class or static methods, the wrapper object now
     exposes the wrapped function as their *note __func__: 12ca.
     attribute.  (Contributed by Amaury Forgeot d'Arc, after a
     suggestion by George Sakkis; bpo-5982(16).)

   * ‘__slots__’ を利用して属性を制限した場合に、設定されていない属性を
     del したときに *note AttributeError: 326. にならなかったのを修正し
     ました。 (Fixed by Benjamin Peterson; bpo-7604(17).)

   * 2つの新しいエンコーディングが追加されました: "cp720" は主にアラビア
     文字に使われます。 "cp858" は cp850 の一種ですが、ユーロ記号を追加
     しています。 (CP720 contributed by Alexander Belchenko and Amaury
     Forgeot d'Arc in bpo-1616979(18); CP858 contributed by Tim Hatch in
     bpo-8016(19).)

   * The ‘file’ object will now set the ‘filename’ attribute on the
     *note IOError: 1026. exception when trying to open a directory on
     POSIX platforms (noted by Jan Kaliszewski; bpo-4764(20)), and now
     explicitly checks for and forbids writing to read-only file objects
     instead of trusting the C library to catch and report the error
     (fixed by Stefan Krah; bpo-5677(21)).

   * Python の字句解析機は改行をそれ自身に変換するようになりました。それ
     により、組み込みの *note compile(): 177. 関数がどの改行コードを利用
     したコードでも受け付けるようになりました。また、コードの終端の改行
     も不要になりました。

   * 関数宣言中の余分な丸括弧は Python 3.x では不正になりました。つまり
     、 ‘def f((x)): pass’ はsyntax errorになります。 Python3 警告モード
     では、 Python 2.7 はこの利用方法について警告を出すようになりました
     。 (Noted by James Lingard; bpo-7362(22).)

   * 古いスタイルのクラスのオブジェクトに対して弱参照を作れるようになり
     ました。新スタイルクラスには以前から弱参照を利用できます。(Fixed by
     Antoine Pitrou; bpo-8268(23).)

   * モジュールオブジェクトがGCされたとき、モジュールの辞書は、他にその
     辞書への参照を持っているものがない場合にのみクリアされるようになり
     ました。(bpo-7140(24)).

* Menu:

* インタプリタの変更::
* 最適化: 最適化<11>.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2335

   (2) https://bugs.python.org/issue?@action=redirect&bpo=2333

   (3) https://bugs.python.org/issue?@action=redirect&bpo=7117

   (4) https://bugs.python.org/issue?@action=redirect&bpo=3166

   (5) https://bugs.python.org/issue?@action=redirect&bpo=1811

   (6) https://bugs.python.org/issue?@action=redirect&bpo=5211

   (7) https://bugs.python.org/issue?@action=redirect&bpo=5237

   (8) https://bugs.python.org/issue?@action=redirect&bpo=1588

   (9) https://bugs.python.org/issue?@action=redirect&bpo=7988

   (10) https://bugs.python.org/issue?@action=redirect&bpo=3382

   (11) https://bugs.python.org/issue?@action=redirect&bpo=7994

   (12) https://bugs.python.org/issue?@action=redirect&bpo=3439

   (13) https://bugs.python.org/issue?@action=redirect&bpo=7902

   (14) https://bugs.python.org/issue?@action=redirect&bpo=1583863

   (15) https://bugs.python.org/issue?@action=redirect&bpo=4759

   (16) https://bugs.python.org/issue?@action=redirect&bpo=5982

   (17) https://bugs.python.org/issue?@action=redirect&bpo=7604

   (18) https://bugs.python.org/issue?@action=redirect&bpo=1616979

   (19) https://bugs.python.org/issue?@action=redirect&bpo=8016

   (20) https://bugs.python.org/issue?@action=redirect&bpo=4764

   (21) https://bugs.python.org/issue?@action=redirect&bpo=5677

   (22) https://bugs.python.org/issue?@action=redirect&bpo=7362

   (23) https://bugs.python.org/issue?@action=redirect&bpo=8268

   (24) https://bugs.python.org/issue?@action=redirect&bpo=7140


File: python.info,  Node: インタプリタの変更,  Next: 最適化<11>,  Up: その他の言語変更<12>

1.15.10.1 インタプリタの変更
............................

新しい環境変数 *note PYTHONWARNINGS: b78. を使って警告を制御できるように
なりました。この環境変数には、 *note -W: 896. スイッチに使われる警告の設
定を、カンマ区切りの文字列として指定します。 (Contributed by Brian
Curtin; bpo-7301(1).)

For example, the following setting will print warnings every time they
occur, but turn warnings from the *note Cookie: 67. module into an
error.  (The exact syntax for setting an environment variable varies
across operating systems and shells.)

     export PYTHONWARNINGS=all,error:::Cookie:0

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=7301


File: python.info,  Node: 最適化<11>,  Prev: インタプリタの変更,  Up: その他の言語変更<12>

1.15.10.2 最適化
................

いくつかの場面でパフォーマンスが向上しています。

   * A new opcode was added to perform the initial setup for *note with:
     59c. statements, looking up the *note __enter__(): 592. and *note
     __exit__(): 12ce. methods.  (Contributed by Benjamin Peterson.)

   * たくさんのオブジェクトを開放せずに確保していくという、よくある使い
     方の 1つにおいて、GCのパフォーマンスが向上しました。以前はこの場合
     にGCにかかる時間はオブジェクトの数の2乗に比例していました。現在はフ
     ルGCの数は増えたヒープ上のオブジェクトの数に比例しています。新しい
     方式では、3世代中2世代目に対するGCが10回実行されたうえで、 2世代目
     から3世代目に移ったオブジェクトの数が3世代目のオブジェクトの数の
     10%を超えたときにフルGCが発生します。(Suggested by Martin von Löwis
     and implemented by Antoine Pitrou; bpo-4074(1).)

   * GCが循環参照になりえないシンプルなコンテナ型の追跡を避けるようにな
     りました。 Python 2.7 では、アトミックな型(整数、文字列など)のみを
     含むタプルと辞書は追跡されません。推移的に、アトミックな型のみを含
     むタプルを含む辞書も、同じく追跡されません。これにより、GCによって
     巡回されチェックされるオブジェクトの数が減るので、 GCのコストを減ら
     すことができます。 (Contributed by Antoine Pitrou; bpo-4688(2).)

   * Long integers are now stored internally either in base ‘2**15’ or
     in base ‘2**30’, the base being determined at build time.
     Previously, they were always stored in base ‘2**15’.  Using base
     ‘2**30’ gives significant performance improvements on 64-bit
     machines, but benchmark results on 32-bit machines have been mixed.
     Therefore, the default is to use base ‘2**30’ on 64-bit machines
     and base ‘2**15’ on 32-bit machines; on Unix, there's a new
     configure option ‘--enable-big-digits’ that can be used to override
     this default.

     Apart from the performance improvements this change should be
     invisible to end users, with one exception: for testing and
     debugging purposes there's a new structseq ‘sys.long_info’ that
     provides information about the internal format, giving the number
     of bits per digit and the size in bytes of the C type used to store
     each digit:

          >>> import sys
          >>> sys.long_info
          sys.long_info(bits_per_digit=30, sizeof_digit=4)

     (Contributed by Mark Dickinson; bpo-4258(3).)

     その他の変更により、多倍長整数オブジェクトのサイズは数バイト小さく
     なりました。 32bit システムでは 2byte, 64bit システムでは 6byte 小
     さくなりました。 (Contributed by Mark Dickinson; bpo-5260(4).)

   * 多倍長整数の除算アルゴリズムが、内部のループの軽量化や乗算からシフ
     ト演算への置き換え、不要なイテレーションの削除により高速化されまし
     た。いくつかのベンチマークによると、多倍長整数の剰余演算は 50% から
     150% 高速化されています。 (Contributed by Mark Dickinson;
     bpo-5512(5).)  ビット演算も高速化されています。(initial patch by
     Gregory Smith; bpo-1087418(6))

   * ‘%’ の実装が、左側のオペランドが文字列型かどうかをチェックしてその
     場合の処理を特殊化しました。これにより文字列に対して ‘%’ を頻繁に使
     う、テンプレートライブラリなどのアプリケーションのパフォーマンスが
     1-3%向上します。 (Implemented by Collin Winter; bpo-5176(7).)

   * ‘if’ 条件付きのリスト内包表記がより高速なバイトコードにコンパイルさ
     れるようになりました。(Patch by Antoine Pitrou, back-ported to 2.7
     by Jeffrey Yasskin; bpo-4715(8).)

   * 整数や多倍長整数から10進文字列への変換を、任意の基数をサポートした
     汎用の変換関数を使う代わりに10進数に特殊化した処理を行うことで高速
     化しました。 (Patch by Gawain Bolton; bpo-6713(9).)

   * The ‘split()’, ‘replace()’, ‘rindex()’, ‘rpartition()’, and
     ‘rsplit()’ methods of string-like types (strings, Unicode strings,
     and *note bytearray: 508. objects) now use a fast reverse-search
     algorithm instead of a character-by-character scan.  This is
     sometimes faster by a factor of 10.  (Added by Florent Xicluna;
     bpo-7462(10) and bpo-7622(11).)

   * The *note pickle: 95. and ‘cPickle’ modules now automatically
     intern the strings used for attribute names, reducing memory usage
     of the objects resulting from unpickling.  (Contributed by Jake
     McGuire; bpo-5084(12).)

   * The ‘cPickle’ module now special-cases dictionaries, nearly halving
     the time required to pickle them.  (Contributed by Collin Winter;
     bpo-5670(13).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4074

   (2) https://bugs.python.org/issue?@action=redirect&bpo=4688

   (3) https://bugs.python.org/issue?@action=redirect&bpo=4258

   (4) https://bugs.python.org/issue?@action=redirect&bpo=5260

   (5) https://bugs.python.org/issue?@action=redirect&bpo=5512

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1087418

   (7) https://bugs.python.org/issue?@action=redirect&bpo=5176

   (8) https://bugs.python.org/issue?@action=redirect&bpo=4715

   (9) https://bugs.python.org/issue?@action=redirect&bpo=6713

   (10) https://bugs.python.org/issue?@action=redirect&bpo=7462

   (11) https://bugs.python.org/issue?@action=redirect&bpo=7622

   (12) https://bugs.python.org/issue?@action=redirect&bpo=5084

   (13) https://bugs.python.org/issue?@action=redirect&bpo=5670


File: python.info,  Node: 新しいモジュールと改良されたモジュール,  Next: ビルドならびに C API の変更<8>,  Prev: その他の言語変更<12>,  Up: What's New in Python 2 7

1.15.11 新しいモジュールと改良されたモジュール
----------------------------------------------

全てのリリースに置いて、 Python の標準ライブラリはたくさんの改良とバグ修
正がされてきました。ここでは一部の注目に値する変更を、モジュール名で辞書
順ソートしてリストアップしています。もっと完全な変更リストが見たければ、
ソースツリー内の ‘Misc/NEWS’ ファイルか、全ての完全な詳細が入っている
Subversion のログを参照してください。

   * *note bdb: b. モジュールの基底デバッガクラス *note Bdb: 12d0. に、
     モジュールをスキップする機能が追加されました。コンストラクタは
     ‘django.*’ のような glob スタイルのパターンをもった iterable を引数
     として受け取ります。デバッガはパターンのどれかにマッチするスタック
     フレームにステップインしません。 (Contributed by Maru Newby after a
     suggestion by Senthil Kumaran; bpo-5142(1).)

   * *note binascii: c. モジュールが buffer API をサポートするようになり
     、 *note memoryview: 435. インスタンスやその他のバッファオブジェク
     トともに利用できるようになりました。 (Backported from 3.x by
     Florent Xicluna; bpo-7703(2).)

   * Updated module: the ‘bsddb’ module has been updated from
     4.7.2devel9 to version 4.8.4 of the pybsddb package(3).  The new
     version features better Python 3.x compatibility, various bug
     fixes, and adds several new BerkeleyDB flags and methods.  (Updated
     by Jesús Cea Avión; bpo-8156(4).  The pybsddb changelog can be read
     at ‘https://hg.jcea.es/pybsddb/file/tip/ChangeLog’.)

   * *note bz2: f. モジュールの *note BZ2File: 832. がコンテキストマネー
     ジャープロトコルをサポートするようになりました。これにより、 ‘with
     bz2.BZ2File(...) as f:’ といった書き方ができます。 (Contributed by
     Hagen Fürstenau; bpo-3860(5).)

   * *note collections: 16. モジュールの新しい *note Counter: 1067. クラ
     スは、データの数え上げをするときに便利です。 *note Counter: 1067. イ
     ンスタンスは辞書のように振る舞いますが、キーが存在しなかったときに
     *note KeyError: 31d. 例外を発生させる代わりに 0 を返します。

          >>> from collections import Counter
          >>> c = Counter()
          >>> for letter in 'here is a sample of english text':
          ...   c[letter] += 1
          ...
          >>> c
          Counter({' ': 6, 'e': 5, 's': 3, 'a': 2, 'i': 2, 'h': 2,
          'l': 2, 't': 2, 'g': 1, 'f': 1, 'm': 1, 'o': 1, 'n': 1,
          'p': 1, 'r': 1, 'x': 1})
          >>> c['e']
          5
          >>> c['z']
          0

     *note Counter: 1067. には追加の3つのメソッドがあります。 *note
     most_common(): 12d1. はカウントが最も多い N 要素とそのカウントを返
     します。 *note elements(): 12d2. はカウントしている要素を、そのカウ
     ント数だけ繰り返すイテレータを返します。 *note subtract(): 11af. は
     イテレート可能型を受け取り、その各要素を足すのではなく引いて行きま
     す。引数が辞書か他の ‘Counter’ だった場合は、そのカウントが引かれま
     す。

          >>> c.most_common(5)
          [(' ', 6), ('e', 5), ('s', 3), ('a', 2), ('i', 2)]
          >>> c.elements() ->
             'a', 'a', ' ', ' ', ' ', ' ', ' ', ' ',
             'e', 'e', 'e', 'e', 'e', 'g', 'f', 'i', 'i',
             'h', 'h', 'm', 'l', 'l', 'o', 'n', 'p', 's',
             's', 's', 'r', 't', 't', 'x'
          >>> c['e']
          5
          >>> c.subtract('very heavy on the letter e')
          >>> c['e']    # Count is now lower
          -1

     Contributed by Raymond Hettinger; bpo-1696199(6).

     新しいクラス *note OrderedDict: 5a5. はすでに *note PEP 372;
     collections に順序付き辞書を追加: 12b7. で紹介しました。

     メソッドが追加されました。*note deque: 5a6. データ型の *note
     count(): 11b1. メソッドは、引数で指定された 'x' と等しい要素が何個
     入っているかを返します。 *note reverse(): 11b2. メソッドは deque 内
     の要素をインプレースで逆順にします。 *note deque: 5a6. はまた、最大
     長を返す読み出し専用の属性 *note maxlen: 12d3. を持ちます。 (Both
     features added by Raymond Hettinger.)

     *note namedtuple: 1ac. クラスにオプションの 'rename' 引数が追加され
     ました。 'rename' が真のとき、複数回現れたり Python の識別子として
     許可されないために無効なフィールド名があったとき、フィールドのリス
     ト内での場所に基づく有効なフィールド名に置き換えられます。

          >>> from collections import namedtuple
          >>> T = namedtuple('T', ['field1', '$illegal', 'for', 'field2'], rename=True)
          >>> T._fields
          ('field1', '_1', '_2', 'field2')

     (Added by Raymond Hettinger; bpo-1818(7).)

     Finally, the *note Mapping: 898. abstract base class now returns
     *note NotImplemented: 79d. if a mapping is compared to another type
     that isn't a ‘Mapping’.  (Fixed by Daniel Stutzbach; bpo-8729(8).)

   * Constructors for the parsing classes in the *note ConfigParser: 1b.
     module now take an 'allow_no_value' parameter, defaulting to false;
     if true, options without values will be allowed.  For example:

          >>> import ConfigParser, StringIO
          >>> sample_config = """
          ... [mysqld]
          ... user = mysql
          ... pid-file = /var/run/mysqld/mysqld.pid
          ... skip-bdb
          ... """
          >>> config = ConfigParser.RawConfigParser(allow_no_value=True)
          >>> config.readfp(StringIO.StringIO(sample_config))
          >>> config.get('mysqld', 'user')
          'mysql'
          >>> print config.get('mysqld', 'skip-bdb')
          None
          >>> print config.get('mysqld', 'unknown')
          Traceback (most recent call last):
            ...
          NoOptionError: No option 'unknown' in section: 'mysqld'

     (Contributed by Mats Kindahl; bpo-7005(9).)

   * Deprecated function: ‘contextlib.nested()’, which allows handling
     more than one context manager with a single *note with: 59c.
     statement, has been deprecated, because the ‘with’ statement now
     supports multiple context managers.

   * The *note cookielib: 66. module now ignores cookies that have an
     invalid version field, one that doesn't contain an integer value.
     (Fixed by John J. Lee; bpo-3924(10).)

   * *note copy: 1e. モジュールの *note deepcopy(): b3c. 関数が、束縛ず
     みインスタンスメソッドを正しくコピーするようになりました。
     (Implemented by Robert Collins; bpo-1515(11).)

   * *note ctypes: 22. モジュールが、ポインタとして宣言された引数に対し
     て ‘None’ が渡された場合常に C の ‘NULL’ ポインタに変換するようにな
     りました。(Changed by Thomas Heller; bpo-4606(12).)  根底の、
     libffi ライブラリ(13) がバージョン 3.0.9 にアップデートされ、いくつ
     かのプラットフォームにおけるいろいろな問題が修正されました。
     (Updated by Matthias Klose; bpo-8142(14).)

   * 新しいメソッド: *note datetime: 28. モジュールの *note timedelta:
     99d. クラスに *note total_seconds(): 12d4. メソッドが追加されました
     。これはその期間の秒数を返します。(Contributed by Brian Quinlan;
     bpo-5788(15).)

   * New method: the *note Decimal: 27d. class gained a *note
     from_float(): 11d5. class method that performs an exact conversion
     of a floating-point number to a ‘Decimal’.  This exact conversion
     strives for the closest decimal approximation to the floating-point
     representation's value; the resulting decimal value will therefore
     still include the inaccuracy, if any.  For example,
     ‘Decimal.from_float(0.1)’ returns
     ‘Decimal('0.1000000000000000055511151231257827021181583404541015625')’.
     (Implemented by Raymond Hettinger; bpo-4796(16).)

     Comparing instances of *note Decimal: 27d. with floating-point
     numbers now produces sensible results based on the numeric values
     of the operands.  Previously such comparisons would fall back to
     Python's default rules for comparing objects, which produced
     arbitrary results based on their type.  Note that you still cannot
     combine ‘Decimal’ and floating point in other operations such as
     addition, since you should be explicitly choosing how to convert
     between float and ‘Decimal’.  (Fixed by Mark Dickinson;
     bpo-2531(17).)

     *note Decimal: 27d. のコンストラクタが浮動小数点数を受け入れるよう
     になりました。 (added by Raymond Hettinger; bpo-8257(18)) また、ア
     ラビア・インド数字などの、ヨーロッパ以外の Unicode 文字も受け入れる
     ようになりました。 (contributed by Mark Dickinson; bpo-6595(19)).

     *note Context: 107f. クラスのほとんどのメソッドが *note Decimal:
     27d. インスタンスと同じく整数を受け入れるようになりました。例外は
     *note canonical(): 12d5. と *note is_canonical(): 12d6. メソッドだ
     けです。 (Patch by Juan José Conti; bpo-7633(20).)

     *note Decimal: 27d. インスタンスを文字列の *note format(): 5ed. メ
     ソッドで利用した場合、デフォルトのアライメントが左揃えから、数値型
     に適した右揃えに変更されました。 (Changed by Mark Dickinson;
     bpo-6857(21).)

     signaling NaN (あるいは ‘sNAN’) との比較は、暗黙に比較演算に応じて
     真偽値を返すのではなく、 *note InvalidOperation: 107a. 例外を発生さ
     せるようになりました。 Quiet NaN (あるいは ‘NAN’) はハッシュ可能に
     なりました。 (Fixed by Mark Dickinson; bpo-7279(22).)

   * *note difflib: 2f. モジュールの出力が、ファイル名を含むヘッダのセパ
     レータにスペースではなくタブ文字を使うようになり、最近の
     ‘diff’/‘patch’ ツールとの互換性が高くなりました。(Fixed by Anatoly
     Techtonik; bpo-7585(23).)

   * Distutils ‘sdist’ コマンドが、 ‘MANIFEST.in’ や ‘setup.py’ ファイル
     が変更されていなくても、ユーザーが作成したかもしれない新しいファイ
     ルが含まれるようにするために、毎回 ‘MANIFEST’ ファイルを再生成する
     ようになりました。 (Fixed by Tarek Ziadé; bpo-8688(24).)

   * The *note doctest: 31. module's *note IGNORE_EXCEPTION_DETAIL:
     12d7. flag will now ignore the name of the module containing the
     exception being tested.  (Patch by Lennart Regebro; bpo-7490(25).)

   * The *note email: 32. module's *note Message: 25d. class will now
     accept a Unicode-valued payload, automatically converting the
     payload to the encoding specified by ‘output_charset’.  (Added by
     R.  David Murray; bpo-1368247(26).)

   * *note Fraction: 1c8. クラスが、コンストラクタの引数として、 1つの
     float 値、 *note Decimal: 27d. インスタンス、 2つの有理数を受け入れ
     るようになりました。(Implemented by Mark Dickinson; rationals added
     in bpo-5812(27), and float/decimal in bpo-8294(28).)

     fraction と complex 数の間の順序比較演算 (‘<’, ‘<=’, ‘>’, ‘>=’)が
     *note TypeError: 502. 例外を発生させるようになりました。これは過失
     を修正し、 *note Fraction: 1c8. を他の数値型とマッチさせます。

   * 新しいクラス: *note FTP_TLS: 8c9. が *note ftplib: 54. に追加されま
     した。認証とその後の制御・データ転送をTLSカプセル化することでセキュ
     アなFTP接続を提供します。 (Contributed by Giampaolo Rodola;
     bpo-2054(29).)

     バイナリデータのアップロードを行う *note storbinary(): 12d8. に
     'rest' 引数が追加され、アップロードのリスタートができるようになりま
     した。 (patch by Pablo Mouzo; bpo-6845(30).)

   * New class decorator: *note total_ordering(): f0f. in the *note
     functools: 55. module takes a class that defines an *note __eq__():
     ac8. method and one of *note __lt__(): 12d9, *note __le__(): 12da,
     *note __gt__(): 12db, or *note __ge__(): 12dc, and generates the
     missing comparison methods.  Since the ‘__cmp__()’ method is being
     deprecated in Python 3.x, this decorator makes it easier to define
     ordered classes.  (Added by Raymond Hettinger; bpo-5479(31).)

     新しい関数: *note cmp_to_key(): 11aa. 関数は、古いスタイルの2引数を
     受け取る比較関数を受け取り、 *note sorted(): b9c, *note min(): ed3,
     *note max(): ed4. などの 'key' 引数に利用できる呼び出し可能オブジェ
     クトを返します。この関数の主な目的は、古いコードを Python 3.x へ対
     応させるのを手助けすることです。(Added by Raymond Hettinger.)

   * 新しい関数: *note gc: 56. モジュールに *note is_tracked(): 12dd. 関
     数が追加されました。渡されたオブジェクトがGCに追跡されている場合に
     True を、そうでない場合に False を返します。 (Contributed by
     Antoine Pitrou; bpo-4688(32).)

   * *note gzip: 5d. モジュールの *note GzipFile: 3f3. がコンテキストマ
     ネージャープロトコルをサポートしました。 ‘with gzip.GzipFile(...)
     as f:’ と書くことができます。(contributed by Hagen Fürstenau;
     bpo-3860(33) また、 *note io.BufferedIOBase: 660. ABC を実装してい
     ます。なので、より高速な処理のために *note io.BufferedReader: 11df.
     でラップすることができます。 (contributed by Nir Aides;
     bpo-7471(34)).  さらに、コンストラクタにオプションのタイムスタンプ
     を指定することで、 gzip ファイル内の変更時間レコードをオーバーライ
     ドすることができるようになりました。 (Contributed by Jacques
     Frechet; bpo-4272(35).)

     gzip ファイルフォーマットのファイルは最後にゼロバイトによるパディン
     グができるようになりました。 *note gzip: 5d. モジュールは末尾のゼロ
     バイトを消費します。(Fixed by Tadek Pietraszek and Brian Curtin;
     bpo-2846(36).)

   * New attribute: the *note hashlib: 5e. module now has an
     ‘algorithms’ attribute containing a tuple naming the supported
     algorithms.  In Python 2.7, ‘hashlib.algorithms’ contains ‘('md5',
     'sha1', 'sha224', 'sha256', 'sha384', 'sha512')’.  (Contributed by
     Carl Chenet; bpo-7418(37).)

   * The default *note HTTPResponse: 10a1. class used by the *note
     httplib: 64. module now supports buffering, resulting in much
     faster reading of HTTP responses.  (Contributed by Kristján Valur
     Jónsson; bpo-4879(38).)

     The *note HTTPConnection: b0e. and *note HTTPSConnection: b0f.
     classes now support a 'source_address' parameter, a ‘(host, port)’
     2-tuple giving the source address that will be used for the
     connection.  (Contributed by Eldon Ziegler; bpo-3972(39).)

   * The ‘ihooks’ module now supports relative imports.  Note that
     ‘ihooks’ is an older module for customizing imports, superseded by
     the ‘imputil’ module added in Python 2.0.  (Relative import support
     added by Neil Schemenauer.)

   * *note imaplib: 6a. モジュールが IPv6 アドレスをサポートするようにな
     りました。 (Contributed by Derek Morr; bpo-1655(40).)

   * *note inspect: 72. モジュールに *note getcallargs(): e86. 関数が追
     加されました。 callable とその位置引数、キーワード引数を受け取り、
     callable のどの仮引数がどの実引数を受け取るかを計算し、引数名から値
     へマップする辞書を返します。例えば:

          >>> from inspect import getcallargs
          >>> def f(a, b=1, *pos, **named):
          ...     pass
          ...
          >>> getcallargs(f, 1, 2, 3)
          {'a': 1, 'b': 2, 'pos': (3,), 'named': {}}
          >>> getcallargs(f, a=2, x=4)
          {'a': 2, 'b': 1, 'pos': (), 'named': {'x': 4}}
          >>> getcallargs(f)
          Traceback (most recent call last):
          ...
          TypeError: f() takes at least 1 argument (0 given)

     Contributed by George Sakkis; bpo-3135(41).

   * Updated module: The *note io: 73. library has been upgraded to the
     version shipped with Python 3.1.  For 3.1, the I/O library was
     entirely rewritten in C and is 2 to 20 times faster depending on
     the task being performed.  The original Python version was renamed
     to the ‘_pyio’ module.

     One minor resulting change: the *note io.TextIOBase: 661. class now
     has an *note errors: 12de. attribute giving the error setting used
     for encoding and decoding errors (one of ‘'strict'’, ‘'replace'’,
     ‘'ignore'’).

     *note io.FileIO: 12df. クラスは、無効なファイルディスクリプタを渡さ
     れたときに *note OSError: 3f0. を送出するようになりました。
     (Implemented by Benjamin Peterson; bpo-4991(42).)  *note
     truncate(): 12e0. メソッドは、ファイル位置を保存するようになりまし
     た。以前は、ファイル位置を新しいファイルの末尾に変更しました。
     (Fixed by Pascal Chambon; bpo-6939(43).)

   * 新しい関数: ‘itertools.compress(data, selectors)’ は、2 つのイテレ
     ータを取ります。'data' の要素は、'selectors' の対応する値が真であれ
     ば返されます:

          itertools.compress('ABCDEF', [1,0,1,0,1,1]) =>
            A, C, E, F

     新しい関数: ‘itertools.combinations_with_replacement(iter, r)’ は、
     'iter' から、すべての可能な長さ 'r' の要素の組合せを返します。
     *note combinations(): 12e1. とは異なり、生成された組合せに個別の要
     素が繰り返し出現できます:

          itertools.combinations_with_replacement('abc', 2) =>
            ('a', 'a'), ('a', 'b'), ('a', 'c'),
            ('b', 'b'), ('b', 'c'), ('c', 'c')

     なお要素は、実際の値ではなく、その入力内での位置に依って一意である
     とみなされます。

     *note itertools.count(): 1254. 関数は、1 以外の値を増分できるように
     、 'step' 引数を追加しました。 *note count(): 1254. はまた、キーワ
     ード引数に対応し、さらに浮動小数点数や *note Decimal: 27d. インスタ
     ンスのような、非整数の値を使えるようになりました。(Implemented by
     Raymond Hettinger; bpo-5032(44).)

     *note itertools.combinations(): 12e1. および *note
     itertools.product(): 12e2. は、以前は入力のイテレート可能オブジェク
     トより大きい 'r' に *note ValueError: 1e3. を返していました。これは
     仕様エラーと認められ、空のイテレータを返すようになりました。(Fixed
     by Raymond Hettinger; bpo-4816(45).)

   * 更新されたモジュール: *note json: 76. モジュールが、エンコーディン
     グやデコーディングを高速化する C 拡張を含んだ、 simplejson パッケー
     ジのバージョン 2.0.9 にアップグレードされました。 (Contributed by
     Bob Ippolito; bpo-4136(46).)

     新しい *note collections.OrderedDict: 5a5. 型をサポートするために、
     *note json.load(): c82. はオプションとして、任意のオブジェクトリテ
     ラルに対して呼び出され、ペアのリストにデコードする
     'object_pairs_hook' パラメタを追加しました。(Contributed by Raymond
     Hettinger; bpo-5381(47).)

   * *note mailbox: 7f. モジュールの *note Maildir: 3f5. クラスは、読み
     込むディレクトリのタイムスタンプを記録し、その後に更新時刻が変わっ
     た場合にのみ再読み込みするようになりました。これは不必要なディレク
     トリ走査を避けることでパフォーマンスを向上させます。(Fixed by A.M.
     Kuchling and Antoine Pitrou; bpo-1607951(48), bpo-6896(49).)

   * 新しい関数: *note math: 81. モジュールは、誤差関数と相補誤差関数
     *note erf(): ba6. および *note erfc(): ba7. 、 ‘e**x - 1’ を *note
     exp(): 12e3. から 1 を引くのよりも高い精度で計算する *note expm1():
     11bd. 、ガンマ関数 *note gamma(): 11be. 、そしてガンマ関数の自然対
     数 *note lgamma(): 11bf. を追加しました。 (Contributed by Mark
     Dickinson and nirinA raseliarison; bpo-3366(50).)

   * The *note multiprocessing: 86. module's ‘Manager*’ classes can now
     be passed a callable that will be called whenever a subprocess is
     started, along with a set of arguments that will be passed to the
     callable.  (Contributed by lekma; bpo-5585(51).)

     The *note Pool: f38. class, which controls a pool of worker
     processes, now has an optional 'maxtasksperchild' parameter.
     Worker processes will perform the specified number of tasks and
     then exit, causing the ‘Pool’ to start a new worker.  This is
     useful if tasks may leak memory or other resources, or if some
     tasks will cause the worker to become very large.  (Contributed by
     Charles Cazabon; bpo-6963(52).)

   * The ‘nntplib’ module now supports IPv6 addresses.  (Contributed by
     Derek Morr; bpo-1664(53).)

   * 新しい関数: *note os: 91. モジュールは、以下の POSIX システムコール
     をラップします: real, effective, および saved GID と UID を返す、
     *note getresgid(): 12e4. と *note getresuid(): 12e5. 、 real,
     effective, および saved GID と UID を新しく設定する、 *note
     setresgid(): 12e6. と *note setresuid(): 12e7. 、現在のプロセスにグ
     ループアクセスリストを初期化する *note initgroups(): 12e8. 。
     (GID/UID functions contributed by Travis H.; bpo-6508(54).  Support
     for initgroups added by Jean-Paul Calderone; bpo-7333(55).)

     *note os.fork(): 17c. 関数は、子プロセス中で import ロックを再初期
     化するようになりました。これは、Solaris における *note fork(): 17c.
     がスレッドから呼び出された時の問題を修正します。(Fixed by Zsolt
     Cserna; bpo-7242(56).)

   * *note os.path: 92. モジュールの、 *note normpath(): 12e9. および
     *note abspath(): 12ea. 関数は、Unicode を保存するようになりました。
     入力パスが Unicode なら、戻り値も Unicode 文字列になります。 (*note
     normpath(): 12e9. fixed by Matt Giuca in bpo-5827(57); *note
     abspath(): 12ea. fixed by Ezio Melotti in bpo-3426(58).)

   * *note pydoc: a3. モジュールは、Python が使う様々なシンボルのヘルプ
     を追加しました。例えば、 ‘help('<<')’ や ‘help('@')’ とできるように
     なりました。(Contributed by David Laban; bpo-4739(59).)

   * *note re: a7. モジュールの *note split(): 282, *note sub(): 283, お
     よび *note subn(): 284. は、モジュールの他の関数との一貫性のため、
     オプションの 'flags' 引数を受け付けるようになりました。 (Added by
     Gregory P. Smith.)

   * 新しい関数: *note runpy: ac. モジュールの *note run_path(): 166. は
     、与えられた 'path' 引数のコードを実行します。 'path' は Python ソ
     ースファイルのパス (‘example.py’)、コンパイル済みバイトコードファイ
     ル (‘example.pyc’)、ディレクトリ (‘./package/’)、または zip アーカ
     イブ (‘example.zip’) にできます。ディレクトリか zip パスが与えられ
     ると、それが ‘sys.path’ の最初に加えられ、モジュール *note
     __main__: 1. が import されます。これは、ディレクトリや zip が
     ‘__main__.py’ を含むことを期待します。なければ、他の ‘__main__.py’
     が ‘sys.path’ の後の部分から import されることがあります。これによ
     り、Python のコマンドラインが明示的なパス名を処理する方法を真似たい
     ようなスクリプトに、 *note runpy: ac. のより多くの機構が利用できる
     ようになります。 (Added by Nick Coghlan; bpo-6816(60).)

   * 新しい関数: *note shutil: b3. モジュールの *note make_archive():
     47f. は、ファイル名、アーカイブ型 (zip または tar-format)、およびデ
     ィレクトリパスを取って、そのディレクトリの内容を含むアーカイブを生
     成します。(Added by Tarek Ziadé.)

     *note shutil: b3. の *note copyfile(): a27. および *note
     copytree(): 9f7. 関数は、名前付きパイプのコピーを求められたときに
     ‘SpecialFileError’ 例外を送出する様になりました。以前は、コードは、
     名前付きパイプを、通常のファイルのように読み込み用に開いて扱い、い
     つまでもブロックしていました。 (Fixed by Antoine Pitrou;
     bpo-3002(61).)

   * *note signal: b4. モジュールは、シグナルハンドラを本当に必要でない
     限り再インストールしなくなりました。これで、EINTR シグナルを確実に
     捕えられないバグが修正されました。(Fixed by Charles-Francois
     Natali; bpo-8354(62).)

   * 新しい関数: *note site: b5. モジュールの、新しい関数群は様々なサイ
     トおよびユーザに特有のパスを返します。 *note getsitepackages():
     120f. は、全てのグローバル site-packages ディレクトリを含むリストを
     返します。 *note getusersitepackages(): 1211. は、ユーザの
     site-packages ディレクトリのパスを返します。そして、 *note
     getuserbase(): 1210. は、データの保存に使えるディレクトリへのパスを
     与える、 *note USER_BASE: 12eb. 環境変数の値を返します。
     (Contributed by Tarek Ziadé; bpo-6693(63).)

     *note site: b5. モジュールは *note sitecustomize: b6. モジュールが
     import されたときに例外を報告するようになり、 *note
     KeyboardInterrupt: 99f. 例外が捕捉されて飲み込まれることはなくなり
     ました。 (Fixed by Victor Stinner; bpo-3137(64).)

   * *note create_connection(): 63e. 関数は、接続に使われるソースアドレ
     スを与える ‘(host, port)’ の 2-タプル、 'source_address' パラメタを
     追加しました。 (Contributed by Eldon Ziegler; bpo-3972(65).)

     *note recv_into(): 12ec. および *note recvfrom_into(): 12ed. メソッ
     ドは、バッファ API をサポートするオブジェクト、最も便利なのは *note
     bytearray: 508. や *note memoryview: 435. 、に書きこむようになりま
     した。 (Implemented by Antoine Pitrou; bpo-8104(66).)

   * The *note SocketServer: b9. module's *note TCPServer: 12ee. class
     now supports socket timeouts and disabling the Nagle algorithm.
     The ‘disable_nagle_algorithm’ class attribute defaults to ‘False’;
     if overridden to be true, new request connections will have the
     TCP_NODELAY option set to prevent buffering many small sends into a
     single TCP packet.  The *note timeout: 12ef. class attribute can
     hold a timeout in seconds that will be applied to the request
     socket; if no request is received within that time, *note
     handle_timeout(): 12f0. will be called and *note handle_request():
     12f1. will return.  (Contributed by Kristján Valur Jónsson;
     bpo-6192(67) and bpo-6267(68).)

   * 更新されたモジュール: *note sqlite3: ba. モジュールが pysqlite パッ
     ケージ(69) のバージョン 2.6.0 にアップデートされました。バージョン
     2.6.0 はいくつかのバグ修正を含み、共有ライブラリから SQLite 拡張を
     ロードできるようになりました。拡張を有効にするには
     ‘enable_load_extension(True)’ メソッドを呼び出し、そして特定の共有
     ライブラリをロードするには *note load_extension(): 484. を呼び出し
     てください。 (Updated by Gerhard Häring.)

   * The *note ssl: bb. module's *note SSLSocket: 8b8. objects now
     support the buffer API, which fixed a test suite failure (fix by
     Antoine Pitrou; bpo-7133(70)) and automatically set OpenSSL's
     ‘SSL_MODE_AUTO_RETRY’, which will prevent an error code being
     returned from ‘recv()’ operations that trigger an SSL renegotiation
     (fix by Antoine Pitrou; bpo-8222(71)).

     The *note wrap_socket(): 4ee. constructor function now takes a
     'ciphers' argument that's a string listing the encryption
     algorithms to be allowed; the format of the string is described in
     the OpenSSL documentation(72).  (Added by Antoine Pitrou;
     bpo-8322(73).)

     その他の変更により、拡張はOpenSSL の全ての暗号とメッセージダイジェ
     ストアルゴリズムをロードし、それらすべてが利用できるようにします。
     SSL 証明書の中には検証できないものもあり、"unknown algorithm" エラ
     ーを報告します。 (Reported by Beda Kosata, and fixed by Antoine
     Pitrou; bpo-8484(74).)

     The version of OpenSSL being used is now available as the module
     attributes *note ssl.OPENSSL_VERSION: 11f0. (a string), *note
     ssl.OPENSSL_VERSION_INFO: 11f1. (a 5-tuple), and *note
     ssl.OPENSSL_VERSION_NUMBER: 11f2. (an integer).  (Added by Antoine
     Pitrou; bpo-8321(75).)

   * The *note struct: c0. module will no longer silently ignore
     overflow errors when a value is too large for a particular integer
     format code (one of ‘bBhHiIlLqQ’); it now always raises a *note
     struct.error: 12f2. exception.  (Changed by Mark Dickinson;
     bpo-1523(76).)  The *note pack(): 1248. function will also attempt
     to use *note __index__(): 6e8. to convert and pack non-integers
     before trying the *note __int__(): 6e7. method or reporting an
     error.  (Changed by Mark Dickinson; bpo-8300(77).)

   * 新しい関数: *note subprocess: c1. モジュールの *note
     check_output(): f8e. は、指定された引数群でコマンドを実行し、コマン
     ドがエラーを起こさずに実行したらコマンドの出力を文字列として返し、
     そうでなければ *note CalledProcessError: 12f3. 例外を送出します。

          >>> subprocess.check_output(['df', '-h', '.'])
          'Filesystem     Size   Used  Avail Capacity  Mounted on\n
          /dev/disk0s2    52G    49G   3.0G    94%    /\n'

          >>> subprocess.check_output(['df', '-h', '/bogus'])
            ...
          subprocess.CalledProcessError: Command '['df', '-h', '/bogus']' returned non-zero exit status 1

     (Contributed by Gregory P. Smith.)

     The *note subprocess: c1. module will now retry its internal system
     calls on receiving an *note EINTR: d54. signal.  (Reported by
     several people; final patch by Gregory P. Smith in
     bpo-1068268(78).)

   * 新しい関数: *note symtable: c2. モジュールの *note
     is_declared_global(): 12f4. は、明示的に global と宣言された引数に
     は真、暗示的に global である引数には偽を返します。(Contributed by
     Jeremy Hylton.)

   * *note syslog: c6. モジュールは、識別子として、以前デフォルトであっ
     た ‘'python'’ の値ではなく、 ‘sys.argv[0]’ の値を使うようになりまし
     た。 (Changed by Sean Reifschneider; bpo-8451(79).)

   * The *note sys.version_info: 66c. value is now a named tuple, with
     attributes named ‘major’, ‘minor’, ‘micro’, ‘releaselevel’, and
     ‘serial’.  (Contributed by Ross Light; bpo-4285(80).)

     *note sys.getwindowsversion(): cb5. also returns a named tuple,
     with attributes named ‘major’, ‘minor’, ‘build’, ‘platform’,
     ‘service_pack’, ‘service_pack_major’, ‘service_pack_minor’,
     ‘suite_mask’, and ‘product_type’.  (Contributed by Brian Curtin;
     bpo-7766(81).)

   * *note tarfile: c8. モジュールのデフォルトエラー処理が変更され、致命
     的なエラーを抑制しないようになりました。デフォルトのエラーレベルは
     以前は 0 で、エラーはメッセージとしてデバッグログに書き込まれるだけ
     でしたが、デバッグログはデフォルトでは活性化されていないため、エラ
     ーは顧みられませんでした。デフォルトのエラーレベルは 1 になり、エラ
     ーがあれば例外が送出されます。 (Changed by Lars Gustäbel;
     bpo-7357(82).)

     *note tarfile: c8. は、tar ファイルに追加される *note TarInfo:
     11e2. オブジェクトのフィルタリングをサポートするようになりました。
     *note add(): bc1. を呼び出したとき、オプションの呼び出し可能オブジ
     ェクトである 'filter' 引数を与えることができます。 'filter' オブジ
     ェクトには、ファイルが追加される度に *note TarInfo: 11e2. を渡され
     、これを変形して返せます。このオブジェクトが ‘None’ を返したら、そ
     のファイルは結果のアーカイブから除かれます。これは既存の 'exclude'
     引数より強力で、それゆえこれは非推奨となります。(Added by Lars
     Gustäbel; bpo-6856(83).)  *note TarFile: 11e1. クラスはまた、コンテ
     キストマネージャプロトコルもサポートするようになりました。(Added by
     Lars Gustäbel; bpo-7232(84).)

   * *note threading.Event: 112b. クラスの *note wait(): 12f5. メソッド
     は、終了時に内部フラグを返すようになりました。 *note wait(): 12f5.
     は内部フラグが真になるまでブロックすることを想定されているため、こ
     の関数は通常真を返すことになります。この戻り値は、タイムアウトが与
     えられ、オペレーションがタイムアウトした時のみ偽になります。
     (Contributed by Tim Lesher; bpo-1674032(85).)

   * *note unicodedata: ee. モジュールに提供される Unicode データベース
     は、どの文字が数字や空白文字か、または改行を表すかを決定するために
     、内部で使われるようになりました。このデータベースはまた、
     ‘Unihan.txt’ データファイルからの情報も含みます (patch by Anders
     Chrigström and Amaury Forgeot d'Arc; bpo-1571184(86))。また、バージ
     ョン 5.2.0 にアップデートされました (updated by Florent Xicluna;
     bpo-8024(87))。

   * The *note urlparse: f3. module's *note urlsplit(): d0d. now handles
     unknown URL schemes in a fashion compliant with RFC 3986(88): if
     the URL is of the form ‘"<something>://..."’, the text before the
     ‘://’ is treated as the scheme, even if it's a made-up scheme that
     the module doesn't know about.  This change may break code that
     worked around the old behaviour.  For example, Python 2.6.4 or 2.5
     will return the following:

          >>> import urlparse
          >>> urlparse.urlsplit('invented://host/filename?query')
          ('invented', '', '//host/filename?query', '', '')

     Python 2.7 (や Python 2.6.5) は以下を返します:

          >>> import urlparse
          >>> urlparse.urlsplit('invented://host/filename?query')
          ('invented', 'host', '/filename?query', '', '')

     (Python 2.7 では、これは普通のタプルではなく名前付きタプルを返すの
     で、実際は微妙に異なる出力をします。)

     The *note urlparse: f3. module also supports IPv6 literal addresses
     as defined by RFC 2732(89) (contributed by Senthil Kumaran;
     bpo-2987(90)).

          >>> urlparse.urlparse('http://[1080::8:800:200C:417A]/foo')
          ParseResult(scheme='http', netloc='[1080::8:800:200C:417A]',
                      path='/foo', params='', query='', fragment='')

   * 新しいクラス: *note weakref: fc. モジュールの *note WeakSet: 5a7. ク
     ラスは、その要素の弱参照だけを保持する集合です。要素は、それを指す
     参照がなくなり次第除去されます。 (Originally implemented in Python
     3.x by Raymond Hettinger, and backported to 2.7 by Michael Foord.)

   * The *note xml.etree.ElementTree: 10c. library, no longer escapes
     ampersands and angle brackets when outputting an XML processing
     instruction (which looks like ‘<?xml-stylesheet href="#style1"?>’)
     or comment (which looks like ‘<!-- comment -->’).  (Patch by Neil
     Muller; bpo-2746(91).)

   * The XML-RPC client and server, provided by the *note xmlrpclib:
     114. and *note SimpleXMLRPCServer: 115. modules, have improved
     performance by supporting HTTP/1.1 keep-alive and by optionally
     using gzip encoding to compress the XML being exchanged.  The gzip
     compression is controlled by the ‘encode_threshold’ attribute of
     *note SimpleXMLRPCRequestHandler: 12f6, which contains a size in
     bytes; responses larger than this will be compressed.  (Contributed
     by Kristján Valur Jónsson; bpo-6267(92).)

   * *note zipfile: 117. モジュールの *note ZipFile: 690. は、コンテキス
     トマネジメントプロトコルをサポートし、 ‘with zipfile.ZipFile(...)
     as f:’ と書けるようになりました。 (Contributed by Brian Curtin;
     bpo-5511(93).)

     *note zipfile: 117. now also supports archiving empty directories
     and extracts them correctly.  (Fixed by Kuba Wieczorek;
     bpo-4710(94).)  Reading files out of an archive is faster, and
     interleaving *note read(): 12f7. and *note readline(): 12f8. now
     works correctly.  (Contributed by Nir Aides; bpo-7610(95).)

     *note is_zipfile(): 12f9. 関数は、以前受け付けられていたパス名に加
     え、ファイルオブジェクトも受け付けるようになりました。 (Contributed
     by Gabriel Genellina; bpo-4756(96).)

     *note writestr(): 12fa. メソッドは、 *note ZipFile: 690. コンストラ
     クタで指定されたデフォルトの圧縮メソッドをオーバライドする、オプシ
     ョンの 'compress_type' パラメタを追加しました。 (Contributed by
     Ronald Oussoren; bpo-6003(97).)

* Menu:

* 新しいモジュール; importlib: 新しいモジュール importlib.
* 新しいモジュール; sysconfig: 新しいモジュール sysconfig.
* ttk; Tk のテーマ付きウィジェット: ttk Tk のテーマ付きウィジェット.
* 更新されたモジュール; unittest: 更新されたモジュール unittest.
* 更新されたモジュール; ElementTree 1.3: 更新されたモジュール ElementTree 1 3.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5142

   (2) https://bugs.python.org/issue?@action=redirect&bpo=7703

   (3) https://www.jcea.es/programacion/pybsddb.htm

   (4) https://bugs.python.org/issue?@action=redirect&bpo=8156

   (5) https://bugs.python.org/issue?@action=redirect&bpo=3860

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1696199

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1818

   (8) https://bugs.python.org/issue?@action=redirect&bpo=8729

   (9) https://bugs.python.org/issue?@action=redirect&bpo=7005

   (10) https://bugs.python.org/issue?@action=redirect&bpo=3924

   (11) https://bugs.python.org/issue?@action=redirect&bpo=1515

   (12) https://bugs.python.org/issue?@action=redirect&bpo=4606

   (13) https://sourceware.org/libffi/

   (14) https://bugs.python.org/issue?@action=redirect&bpo=8142

   (15) https://bugs.python.org/issue?@action=redirect&bpo=5788

   (16) https://bugs.python.org/issue?@action=redirect&bpo=4796

   (17) https://bugs.python.org/issue?@action=redirect&bpo=2531

   (18) https://bugs.python.org/issue?@action=redirect&bpo=8257

   (19) https://bugs.python.org/issue?@action=redirect&bpo=6595

   (20) https://bugs.python.org/issue?@action=redirect&bpo=7633

   (21) https://bugs.python.org/issue?@action=redirect&bpo=6857

   (22) https://bugs.python.org/issue?@action=redirect&bpo=7279

   (23) https://bugs.python.org/issue?@action=redirect&bpo=7585

   (24) https://bugs.python.org/issue?@action=redirect&bpo=8688

   (25) https://bugs.python.org/issue?@action=redirect&bpo=7490

   (26) https://bugs.python.org/issue?@action=redirect&bpo=1368247

   (27) https://bugs.python.org/issue?@action=redirect&bpo=5812

   (28) https://bugs.python.org/issue?@action=redirect&bpo=8294

   (29) https://bugs.python.org/issue?@action=redirect&bpo=2054

   (30) https://bugs.python.org/issue?@action=redirect&bpo=6845

   (31) https://bugs.python.org/issue?@action=redirect&bpo=5479

   (32) https://bugs.python.org/issue?@action=redirect&bpo=4688

   (33) https://bugs.python.org/issue?@action=redirect&bpo=3860

   (34) https://bugs.python.org/issue?@action=redirect&bpo=7471

   (35) https://bugs.python.org/issue?@action=redirect&bpo=4272

   (36) https://bugs.python.org/issue?@action=redirect&bpo=2846

   (37) https://bugs.python.org/issue?@action=redirect&bpo=7418

   (38) https://bugs.python.org/issue?@action=redirect&bpo=4879

   (39) https://bugs.python.org/issue?@action=redirect&bpo=3972

   (40) https://bugs.python.org/issue?@action=redirect&bpo=1655

   (41) https://bugs.python.org/issue?@action=redirect&bpo=3135

   (42) https://bugs.python.org/issue?@action=redirect&bpo=4991

   (43) https://bugs.python.org/issue?@action=redirect&bpo=6939

   (44) https://bugs.python.org/issue?@action=redirect&bpo=5032

   (45) https://bugs.python.org/issue?@action=redirect&bpo=4816

   (46) https://bugs.python.org/issue?@action=redirect&bpo=4136

   (47) https://bugs.python.org/issue?@action=redirect&bpo=5381

   (48) https://bugs.python.org/issue?@action=redirect&bpo=1607951

   (49) https://bugs.python.org/issue?@action=redirect&bpo=6896

   (50) https://bugs.python.org/issue?@action=redirect&bpo=3366

   (51) https://bugs.python.org/issue?@action=redirect&bpo=5585

   (52) https://bugs.python.org/issue?@action=redirect&bpo=6963

   (53) https://bugs.python.org/issue?@action=redirect&bpo=1664

   (54) https://bugs.python.org/issue?@action=redirect&bpo=6508

   (55) https://bugs.python.org/issue?@action=redirect&bpo=7333

   (56) https://bugs.python.org/issue?@action=redirect&bpo=7242

   (57) https://bugs.python.org/issue?@action=redirect&bpo=5827

   (58) https://bugs.python.org/issue?@action=redirect&bpo=3426

   (59) https://bugs.python.org/issue?@action=redirect&bpo=4739

   (60) https://bugs.python.org/issue?@action=redirect&bpo=6816

   (61) https://bugs.python.org/issue?@action=redirect&bpo=3002

   (62) https://bugs.python.org/issue?@action=redirect&bpo=8354

   (63) https://bugs.python.org/issue?@action=redirect&bpo=6693

   (64) https://bugs.python.org/issue?@action=redirect&bpo=3137

   (65) https://bugs.python.org/issue?@action=redirect&bpo=3972

   (66) https://bugs.python.org/issue?@action=redirect&bpo=8104

   (67) https://bugs.python.org/issue?@action=redirect&bpo=6192

   (68) https://bugs.python.org/issue?@action=redirect&bpo=6267

   (69) https://github.com/ghaering/pysqlite

   (70) https://bugs.python.org/issue?@action=redirect&bpo=7133

   (71) https://bugs.python.org/issue?@action=redirect&bpo=8222

   (72) https://docs.openssl.org/1.0.2/man1/ciphers/

   (73) https://bugs.python.org/issue?@action=redirect&bpo=8322

   (74) https://bugs.python.org/issue?@action=redirect&bpo=8484

   (75) https://bugs.python.org/issue?@action=redirect&bpo=8321

   (76) https://bugs.python.org/issue?@action=redirect&bpo=1523

   (77) https://bugs.python.org/issue?@action=redirect&bpo=8300

   (78) https://bugs.python.org/issue?@action=redirect&bpo=1068268

   (79) https://bugs.python.org/issue?@action=redirect&bpo=8451

   (80) https://bugs.python.org/issue?@action=redirect&bpo=4285

   (81) https://bugs.python.org/issue?@action=redirect&bpo=7766

   (82) https://bugs.python.org/issue?@action=redirect&bpo=7357

   (83) https://bugs.python.org/issue?@action=redirect&bpo=6856

   (84) https://bugs.python.org/issue?@action=redirect&bpo=7232

   (85) https://bugs.python.org/issue?@action=redirect&bpo=1674032

   (86) https://bugs.python.org/issue?@action=redirect&bpo=1571184

   (87) https://bugs.python.org/issue?@action=redirect&bpo=8024

   (88) https://datatracker.ietf.org/doc/html/rfc3986.html

   (89) https://datatracker.ietf.org/doc/html/rfc2732.html

   (90) https://bugs.python.org/issue?@action=redirect&bpo=2987

   (91) https://bugs.python.org/issue?@action=redirect&bpo=2746

   (92) https://bugs.python.org/issue?@action=redirect&bpo=6267

   (93) https://bugs.python.org/issue?@action=redirect&bpo=5511

   (94) https://bugs.python.org/issue?@action=redirect&bpo=4710

   (95) https://bugs.python.org/issue?@action=redirect&bpo=7610

   (96) https://bugs.python.org/issue?@action=redirect&bpo=4756

   (97) https://bugs.python.org/issue?@action=redirect&bpo=6003


File: python.info,  Node: 新しいモジュール importlib,  Next: 新しいモジュール sysconfig,  Up: 新しいモジュールと改良されたモジュール

1.15.11.1 新しいモジュール: importlib
.....................................

Python 3.1 includes the *note importlib: 6b. package, a
re-implementation of the logic underlying Python's *note import: 5ac.
statement.  *note importlib: 6b. is useful for implementers of Python
interpreters and to users who wish to write new importers that can
participate in the import process.  Python 2.7 doesn't contain the
complete *note importlib: 6b. package, but instead has a tiny subset
that contains a single function, *note import_module(): 4e1.

‘import_module(name, package=None)’ はモジュールを import します。
'name' はモジュールまたはパッケージの名前を含む文字列です。
‘..utils.errors’ のように ‘.’ 文字で始まる文字列を与えることで、相対
import も可能です。相対 import では、 'package' 引数は必ず与えられなけれ
ばならず、相対 import のアンカーとして使われるパッケージの名前でなければ
なりません。 *note import_module(): 4e1. は、 import されたモジュールを
‘sys.modules’ に挿入し、モジュールオブジェクトを返すこともします。

ここに例があります:

     >>> from importlib import import_module
     >>> anydbm = import_module('anydbm')  # Standard absolute import
     >>> anydbm
     <module 'anydbm' from '/p/python/Lib/anydbm.py'>
     >>> # Relative import
     >>> file_util = import_module('..file_util', 'distutils.command')
     >>> file_util
     <module 'distutils.file_util' from '/python/Lib/distutils/file_util.pyc'>

*note importlib: 6b. は、Brett Cannon によって実装され、 Python 3.1 に導
入されました。


File: python.info,  Node: 新しいモジュール sysconfig,  Next: ttk Tk のテーマ付きウィジェット,  Prev: 新しいモジュール importlib,  Up: 新しいモジュールと改良されたモジュール

1.15.11.2 新しいモジュール: sysconfig
.....................................

*note sysconfig: c5. モジュールが Distutils パッケージから引き抜かれ、新
しいトップレベルモジュールになりました。 *note sysconfig: c5. は、Python
のビルドプロセスについての以下の情報を得るための関数群を提供しています。
コンパイラスイッチ、インストレーションパス、プラットフォーム名、そして
Python がソースディレクトリから実行されているかどうかです。

モジュールの関数のいくつかを紹介すると:

   * *note get_config_var(): ff5. は、Python の Makefile と ‘pyconfig.h’
     ファイルから変数を返します。

   * *note get_config_vars(): ff6. は、すべての環境設定変数を含む辞書を
     返します。

   * *note get_path(): 12fd. は、特定のタイプのモジュール、つまり標準ラ
     イブラリ、サイト特有のモジュール、プラットフォーム特有のライブフラ
     リなど、への設定されたパスを返します。

   * *note is_python_build(): 2da. は、Python ソースツリーからバイナリを
     起動していれば真を、そうでなければ偽を返します。

詳細と関数の完全な一覧は *note sysconfig: c5. ドキュメントを参照してくだ
さい。

Distutils パッケージと *note sysconfig: c5. は Tarek Ziadé によってメン
テナンスされていて、彼は Distutils の新世代版を開発するために Distutils2
パッケージ (source repository at ‘https://hg.python.org/distutils2/’) も
開始しました。


File: python.info,  Node: ttk Tk のテーマ付きウィジェット,  Next: 更新されたモジュール unittest,  Prev: 新しいモジュール sysconfig,  Up: 新しいモジュールと改良されたモジュール

1.15.11.3 ttk: Tk のテーマ付きウィジェット
..........................................

Tcl/Tk 8.5 は、基本的な Tk ウィジェットを最実装しながらより自由な外観の
カスタマイズが広がり、よりネイティブなプラットフォームのウィジェットに似
たテーマ付きウィジェット群を含みます。このウィジェット群は、元は Tile と
呼ばれていましたが、Tcl/Tck リリース 8.5 への追加の際に ("themed Tk" を
略して) Ttk に改名されました。

To learn more, read the *note ttk: e2. module documentation.  You may
also wish to read the Tcl/Tk manual page describing the Ttk theme
engine, available at
‘https://www.tcl.tk/man/tcl8.5/TkCmd/ttk_intro.html’.  Some screenshots
of the Python/Ttk code in use are at
‘https://code.google.com/archive/p/python-ttk/wikis/Screenshots.wiki’.

The *note tkinter.ttk: e2. module was written by Guilherme Polo and
added in bpo-2983(1).  An alternate version called ‘Tile.py’, written by
Martin Franklin and maintained by Kevin Walzer, was proposed for
inclusion in bpo-2618(2), but the authors argued that Guilherme Polo's
work was more comprehensive.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2983

   (2) https://bugs.python.org/issue?@action=redirect&bpo=2618


File: python.info,  Node: 更新されたモジュール unittest,  Next: 更新されたモジュール ElementTree 1 3,  Prev: ttk Tk のテーマ付きウィジェット,  Up: 新しいモジュールと改良されたモジュール

1.15.11.4 更新されたモジュール: unittest
........................................

The *note unittest: ef. module was greatly enhanced; many new features
were added.  Most of these features were implemented by Michael Foord,
unless otherwise noted.  The enhanced version of the module is
downloadable separately for use with Python versions 2.4 to 2.6,
packaged as the ‘unittest2’ package, from unittest2(1).

When used from the command line, the module can automatically discover
tests.  It's not as fancy as py.test(2) or nose(3), but provides a
simple way to run tests kept within a set of package directories.  For
example, the following command will search the ‘test/’ subdirectory for
any importable test files named ‘test*.py’:

     python -m unittest discover -s test

詳細は、 *note unittest: ef. モジュールのドキュメントを参照してください
。 (Developed in bpo-6001(4).)

*note main(): fb0. 関数は、その他幾つかの新しいオプションを提供します:

   * *note -b: 1301. や ‘--buffer’ は、標準出力や標準エラーストリームを
     それぞれのテストの間バッファに入れます。テストが通れば、結果の出力
     は全て捨てられます。失敗したら、バッファに入れられた出力が表示され
     ます。

   * *note -c: 1302. や ‘--catch’ は、control-C による中断をより上品にし
     ます。テストプロセスを即座に中断するのではなく、現在実行中のテスト
     は完了させ、中断までの部分的な結果は報告されます。待ちきれなければ
     、control-C をもう一度押せば、即座に中断されます。

     この control-C ハンドラは、コードがテストされているときや、実行され
     ているテストが独自のシグナルハンドラを定義したとき、シグナルハンド
     ラがすでに設定されていてそして呼び出されたということを知らせること
     で、問題を起こさないようにします。これがまずいなら、 *note
     removeHandler(): 1303. デコレータを使って、テストが control-C ハン
     ドリングを無効にするべきであると示せます。

   * *note -f: 1304. や ‘--failfast’ は、テストが失敗したとき、他のテス
     トを続けるのではなく、テストの実行を即座に停止します。 (Suggested
     by Cliff Dyer and implemented by Michael Foord; bpo-8074(5).)

進捗メッセージは、verbose モードで実行したとき、期待された失敗に 'x' を
、期待されない成功に 'u' を表示するようになりました。(Contributed by
Benjamin Peterson.)

テストケースは、テストをスキップするために *note SkipTest: fb1. 例外を送
出します。(bpo-1034053(6)).

*note assertEqual(): 4f2, *note assertTrue(): 4f0, および *note
assertFalse(): 4f1. 失敗のメッセージは、提供する情報量が増えました。
*note TestCase: 41a. クラスの *note longMessage: 1305. 属性を真に設定す
ると、失敗時に、標準のエラーメッセージと追加して提供したメッセージの両方
が表示されます。(Added by Michael Foord; bpo-5663(7).)

*note assertRaises(): 4f6. メソッドは、実行する呼び出し可能オブジェクト
を与えずに呼び出されたとき、コンテキストハンドラを返すようになりました。
例えば、こう書くことができます:

     with self.assertRaises(KeyError):
         {}['foo']

(Implemented by Antoine Pitrou; bpo-4444(8).)

モジュールレベルおよびクラスレベルの設定と、ティアダウンフィクスチャがサ
ポートされました。モジュールは、 ‘setUpModule()’ および
‘tearDownModule()’ 関数を含むことができます。クラスは *note
setUpClass(): a1d. および *note tearDownClass(): 1306. メソッドを含むこ
とができ、これらは (‘@classmethod’ や透過なものを使って) クラスメソッド
として定義しなければなりません。これらの関数とメソッドは、テストランナー
が別のモジュールやクラスのテストケースに切り替えるときに呼び出されます。

メソッド *note addCleanup(): a4f. および *note doCleanups(): 1307. が追
加されました。 *note addCleanup(): a4f. で、無条件に呼び出されるクリーン
アップ関数を (*note setUp(): 1308. が失敗したら *note setUp(): 1308. の
後に、そうでなければ *note tearDown(): 1309. の後に) 追加できるようにし
ます。これにより、テスト中のリソースの配置と解放が簡潔になります。
(bpo-5679(9)).

より特化したテストを提供するメソッドがいくつか追加されました。これらのメ
ソッドの多くは、Google のエンジニアたちによってそのテストスイートのため
に書かれました。Gregory P. Smith, Michael Foord, and GvR が、これを
*note unittest: ef. の Python 版にマージしました。

   * *note assertIsNone(): 125b. および *note assertIsNotNone(): 125c. は
     ひとつの式を取り、その結果が ‘None’ であるか、またはないかを確かめ
     ます。

   * *note assertIs(): 130a. および *note assertIsNot(): 130b. は、2 つ
     の値を取り、その評価が同一のオブジェクトであるか、またはないかを確
     かめます。 (Added by Michael Foord; bpo-2578(10).)

   * *note assertIsInstance(): 130c. および *note assertNotIsInstance():
     130d. は、結果のオブジェクトが特定のクラス、またはタプルにあるクラ
     スのいずれかのインスタンスであるかを調べます。(Added by Georg
     Brandl; bpo-7031(11).)

   * *note assertGreater(): 130e, *note assertGreaterEqual(): 130f,
     *note assertLess(): 1310, および *note assertLessEqual(): 1311. は
     、二つの量を比較します。

   * *note assertMultiLineEqual(): 1312. は 2 つの文字列を比較し、等しく
     なければ、2 文字列の差分をハイライトする有益な比較を表示します。こ
     の比較は、Unicode 文字列が *note assertEqual(): 4f2. で比較されると
     きのデフォルトに使われるようになりました。

   * *note assertRegexpMatches(): 4f7. and *note
     assertNotRegexpMatches(): 4f9. checks whether the first argument is
     a string matching or not matching the regular expression provided
     as the second argument (bpo-8038(12)).

   * *note assertRaisesRegexp(): 4f8. checks whether a particular
     exception is raised, and then also checks that the string
     representation of the exception matches the provided regular
     expression.

   * *note assertIn(): 1313. および *note assertNotIn(): 1314. は、
     'first' が 'second' に属するか、または属さないかを調べます。

   * *note assertItemsEqual(): 11fb. tests whether two provided
     sequences contain the same elements.

   * *note assertSetEqual(): 1256. は、2 つの集合が等しいか比較し、エラ
     ーの場合のみ、集合間の差分を報告します。

   * 同様に、 *note assertListEqual(): 1258. および *note
     assertTupleEqual(): 1259. は、指定された型を比較し、差分を説明しま
     すが、完全な値を表示するとはかぎりません。これらのメソッドは、リス
     トやタプルを *note assertEqual(): 4f2. で比較するときにデフォルトで
     使われるようになりました。より一般的には、 *note
     assertSequenceEqual(): 125a. は 2 つのシーケンスを比較し、必要なら
     両方のシーケンスが特定の型であるかを調べます。

   * *note assertDictEqual(): 1257. compares two dictionaries and
     reports the differences; it's now used by default when you compare
     two dictionaries using *note assertEqual(): 4f2.
     ‘assertDictContainsSubset()’ checks whether all of the key/value
     pairs in 'first' are found in 'second'.

   * *note assertAlmostEqual(): 4f4. and *note assertNotAlmostEqual():
     4f5. test whether 'first' and 'second' are approximately equal.
     This method can either round their difference to an optionally
     specified number of 'places' (the default is 7) and compare it to
     zero, or require the difference to be smaller than a supplied
     'delta' value.

   * *note loadTestsFromName(): 1315. は、 *note TestLoader: 26e. の
     *note suiteClass: 1316. 属性を適切に受け入れます。(Fixed by Mark
     Roddy; bpo-6866(13).)

   * 新しいフックにより、 *note assertEqual(): 4f2. メソッドを拡張して新
     しいデータ型を扱わせられます。 *note addTypeEqualityFunc(): 1317. メ
     ソッドは型オブジェクトと関数を取ります。この関数は、比較される両方
     のオブジェクトが特定の型であるときに使われます。この関数は、2 つの
     オブジェクトを比較し、マッチしなければ例外を送出するべきです。この
     関数が、新しいシーケンス比較メソッドがするように、2 つのオブジェク
     トがなぜマッチしないのかについて追加の情報を提供するのがいいアイデ
     アです。

*note unittest.main(): fb0. はオプションの ‘exit’ 引数を取るようになりま
した。偽の場合、 *note main(): fb0. は *note sys.exit(): 1318. を呼び出
さず、これにより対話型インタプリタから *note main(): fb0. が使えるように
なります。(Contributed by J. Pablo Fernández; bpo-3379(14).)

*note TestResult: 113a. に、テストランの直前と直後に呼び出される *note
startTestRun(): 1319. および *note stopTestRun(): 131a. が追加されました
。 (Contributed by Robert Collins; bpo-5728(15).)

これら一連の変更により、 ‘unittest.py’ は無様に大きくなったので、モジュ
ールはパッケージとなり、コードは複数のファイルに分割されました (by
Benjamin Peterson)。これは、モジュールをインポートして使う方法には影響し
ません。

参考
....

‘https://web.archive.org/web/20210619163128/http://www.voidspace.org.uk/python/articles/unittest2.shtml’

     Describes the new features, how to use them, and the rationale for
     various design decisions.  (By Michael Foord.)

   ---------- Footnotes ----------

   (1) https://pypi.org/project/unittest2/

   (2) https://pytest.org

   (3) https://nose.readthedocs.io/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=6001

   (5) https://bugs.python.org/issue?@action=redirect&bpo=8074

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1034053

   (7) https://bugs.python.org/issue?@action=redirect&bpo=5663

   (8) https://bugs.python.org/issue?@action=redirect&bpo=4444

   (9) https://bugs.python.org/issue?@action=redirect&bpo=5679

   (10) https://bugs.python.org/issue?@action=redirect&bpo=2578

   (11) https://bugs.python.org/issue?@action=redirect&bpo=7031

   (12) https://bugs.python.org/issue?@action=redirect&bpo=8038

   (13) https://bugs.python.org/issue?@action=redirect&bpo=6866

   (14) https://bugs.python.org/issue?@action=redirect&bpo=3379

   (15) https://bugs.python.org/issue?@action=redirect&bpo=5728


File: python.info,  Node: 更新されたモジュール ElementTree 1 3,  Prev: 更新されたモジュール unittest,  Up: 新しいモジュールと改良されたモジュール

1.15.11.5 更新されたモジュール: ElementTree 1.3
...............................................

Python に同梱される ElementTree ライブラリのバージョンが、バージョン 1.3
にアップデートされました。新機能の一部は:

   * 様々な解析関数が、使われる *note XMLParser: a22. インスタンスを与え
     る 'parser' キーワード引数を取るようになりました。これにより、ファ
     イルの内部エンコーディングをオーバーライドできるようになりました:

          p = ET.XMLParser(encoding='utf-8')
          t = ET.XML("""<root/>""", parser=p)

     Errors in parsing XML now raise a *note ParseError: 1249.
     exception, whose instances have a ‘position’ attribute containing a
     ('line', 'column') tuple giving the location of the problem.

   * ElementTree's code for converting trees to a string has been
     significantly reworked, making it roughly twice as fast in many
     cases.  The *note ElementTree.write(): fc2. and ‘Element.write()’
     methods now have a 'method' parameter that can be "xml" (the
     default), "html", or "text".  HTML mode will output empty elements
     as ‘<empty></empty>’ instead of ‘<empty/>’, and text mode will skip
     over elements and only output the text chunks.  If you set the
     *note tag: 131d. attribute of an element to ‘None’ but leave its
     children in place, the element will be omitted when the tree is
     written out, so you don't need to do more extensive rearrangement
     to remove a single element.

     名前空間の操作も改善されました。すべての ‘xmlns:<whatever>’ 宣言は
     、結果の XML に散らばるのではなく、ルート要素に出力されます。
     ‘default_namespace’ 属性を設定することでデフォルトの名前空間を設定
     でき、 *note register_namespace(): 11a2. で新しい接頭辞を登録できま
     す。XML モードでは、XML 宣言を抑制するために真/偽の
     'xml_declaration' パラメタを使えます。

   * 新しい *note Element: 2e8. メソッド: *note extend(): 11a3. はシーケ
     ンスから項目の子に要素を追加します。要素それ自体はシーケンスのよう
     に振る舞うので、子をある要素から別の要素に移すのが簡単です:

          from xml.etree import ElementTree as ET

          t = ET.XML("""<list>
            <item>1</item> <item>2</item>  <item>3</item>
          </list>""")
          new = ET.XML('<root/>')
          new.extend(t)

          # Outputs <root><item>1</item>...</root>
          print ET.tostring(new)

   * New *note Element: 2e8. method: *note iter(): 131e. yields the
     children of the element as a generator.  It's also possible to
     write ‘for child in elem:’ to loop over an element's children.  The
     existing method ‘getiterator()’ is now deprecated, as is
     ‘getchildren()’ which constructs and returns a list of children.

   * New *note Element: 2e8. method: *note itertext(): 11a5. yields all
     chunks of text that are descendants of the element.  For example:

          t = ET.XML("""<list>
            <item>1</item> <item>2</item>  <item>3</item>
          </list>""")

          # Outputs ['\n  ', '1', ' ', '2', '  ', '3', '\n']
          print list(t.itertext())

   * 非推奨: 要素をブール値として使う (すなわち、 ‘if elem:’) と、要素が
     子を持てば真を、子を持たなければ偽を返します。この振る舞いは紛らわ
     しいです - ‘None’ は偽、では子を持たない要素は?  - ですから、 *note
     FutureWarning: 3ee. を引き起こすようになりました。コードでは、明示
     するべきです。子の数に興味があるなら ‘len(elem) != 0’ と、または
     ‘elem is not None’ と書いてください。

Fredrik Lundh develops ElementTree and produced the 1.3 version; you can
read his article describing 1.3 at
‘https://web.archive.org/web/20200703234532/http://effbot.org/zone/elementtree-13-intro.htm’.
Florent Xicluna updated the version included with Python, after
discussions on python-dev and in bpo-6472(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=6472


File: python.info,  Node: ビルドならびに C API の変更<8>,  Next: その他の変更と修正,  Prev: 新しいモジュールと改良されたモジュール,  Up: What's New in Python 2 7

1.15.12 ビルドならびに C API の変更
-----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * The latest release of the GNU Debugger, GDB 7, can be scripted
     using Python(1).  When you begin debugging an executable program P,
     GDB will look for a file named ‘P-gdb.py’ and automatically read
     it.  Dave Malcolm contributed a ‘python-gdb.py’ that adds a number
     of commands useful when debugging Python itself.  For example,
     ‘py-up’ and ‘py-down’ go up or down one Python stack frame, which
     usually corresponds to several C stack frames.  ‘py-print’ prints
     the value of a Python variable, and ‘py-bt’ prints the Python stack
     trace.  (Added as a result of bpo-8032(2).)

   * Python に備え付けの ‘.gdbinit’ ファイルを使うと、デバッグされている
     スレッドが GIL をほじしていないとき、2.7 バージョンの "pyo" マクロ
     が正常に動くようになりました。このマクロは、表示の前にこれを取得す
     るようになりました。 (Contributed by Victor Stinner; bpo-3632(3).)

   * *note Py_AddPendingCall(): 94f. はスレッドセーフになり、ワーカスレ
     ッドがメイン Python スレッドに通知を投入することができるようになり
     ました。これは特に、非同時性の IO 処理に便利です。(Contributed by
     Kristján Valur Jónsson; bpo-4293(4).)

   * New function: *note PyCode_NewEmpty(): 1320. creates an empty code
     object; only the filename, function name, and first line number are
     required.  This is useful for extension modules that are attempting
     to construct a more useful traceback stack.  Previously such
     extensions needed to call ‘PyCode_New()’, which had many more
     arguments.  (Added by Jeffrey Yasskin.)

   * 新しい関数: *note PyErr_NewExceptionWithDoc(): 123a. は、既存の
     *note PyErr_NewException(): 123b. と同じように新しい例外クラスを生
     成しますが、新しい例外クラスの docstring を含む、追加の ‘char *’ 引
     数を取ります。(Added by 'lekma' on the Python bug tracker;
     bpo-7033(5).)

   * 新しい関数: *note PyFrame_GetLineNumber(): 756. はフレームオブジェ
     クトを取り、そのフレームが現在実行している行番号を返します。以前は
     、コードは現在実行しているバイトコード命令のインデクスを得て、それ
     からそのアドレスに対応する行番号を探索する必要がありました。(Added
     by Jeffrey Yasskin.)

   * New functions: *note PyLong_AsLongAndOverflow(): 1237. and *note
     PyLong_AsLongLongAndOverflow(): 1238. approximates a Python long
     integer as a C long or long long.  If the number is too large to
     fit into the output type, an 'overflow' flag is set and returned to
     the caller.  (Contributed by Case Van Horsen; bpo-7528(6) and
     bpo-7767(7).)

   * New function: stemming from the rewrite of string-to-float
     conversion, a new *note PyOS_string_to_double(): 1266. function was
     added.  The old ‘PyOS_ascii_strtod()’ and ‘PyOS_ascii_atof()’
     functions are now deprecated.

   * New function: ‘PySys_SetArgvEx()’ sets the value of ‘sys.argv’ and
     can optionally update ‘sys.path’ to include the directory
     containing the script named by ‘sys.argv[0]’ depending on the value
     of an 'updatepath' parameter.

     This function was added to close a security hole for applications
     that embed Python.  The old function, ‘PySys_SetArgv()’, would
     always update ‘sys.path’, and sometimes it would add the current
     directory.  This meant that, if you ran an application embedding
     Python in a directory controlled by someone else, attackers could
     put a Trojan-horse module in the directory (say, a file named
     ‘os.py’) that your application would then import and run.

     If you maintain a C/C++ application that embeds Python, check
     whether you're calling ‘PySys_SetArgv()’ and carefully consider
     whether the application should be using ‘PySys_SetArgvEx()’ with
     'updatepath' set to false.

     Security issue reported as CVE 2008-5983(8); discussed in
     bpo-5753(9), and fixed by Antoine Pitrou.

   * 新しいマクロ: Python ヘッダファイルは、以下のマクロを定義しました:
     ‘Py_ISALNUM’, ‘Py_ISALPHA’, ‘Py_ISDIGIT’, ‘Py_ISLOWER’,
     ‘Py_ISSPACE’, ‘Py_ISUPPER’, ‘Py_ISXDIGIT’, ‘Py_TOLOWER’, および
     ‘Py_TOUPPER’ 。これらすべての関数は、文字を分類する C の標準マクロ
     と類似ですが、Python は文字をロケールに依らず文字を分析したいときが
     あるため、現在のロケール設定を無視します。(Added by Eric Smith;
     bpo-5793(10).)

   * Removed function: ‘PyEval_CallObject()’ is now only available as a
     macro.  A function version was being kept around to preserve ABI
     linking compatibility, but that was in 1997; it can certainly be
     deleted by now.  (Removed by Antoine Pitrou; bpo-8276(11).)

   * New format codes: the ‘PyString_FromFormat()’,
     ‘PyString_FromFormatV()’, and *note PyErr_Format(): e7a. functions
     now accept ‘%lld’ and ‘%llu’ format codes for displaying C's long
     long types.  (Contributed by Mark Dickinson; bpo-7228(12).)

   * スレッドとプロセスのフォークの間の複雑な相互関係が変更されました。
     以前は、 *note os.fork(): 17c. によって生成された子プロセスは失敗し
     ていました。これは、子は動作しているスレッド 1 つだけで生成され、そ
     のスレッドが *note os.fork(): 17c. を処理するからです。他のスレッド
     が、Python のインポートロックのような、ロックを保持していたら、フォ
     ークが実行されたとき、ロックは新しいプロセスでも "held" としてマー
     クされたままです。しかし、子プロセスでは、他のスレッドは複製されな
     いため、ロックを解放するものは何もないので、子プロセスは import の
     実行を続けることができません。

     Python 2.7 は、 *note os.fork(): 17c. を実行する前に import ロック
     を取得し、また *note threading: d6. モジュールを使って生成された全
     てのロックをクリーンアップします。内部ロックを持っていたり、自身で
     ‘fork()’ を呼び出したりするような C 拡張モジュールは、このクリーン
     アップの恩恵を受けません。

     (Fixed by Thomas Wouters; bpo-1590864(13).)

   * The *note Py_Finalize(): 1321. function now calls the internal
     ‘threading._shutdown()’ function; this prevents some exceptions
     from being raised when an interpreter shuts down.  (Patch by Adam
     Olsen; bpo-1722344(14).)

   * When using the *note PyMemberDef: 51a. structure to define
     attributes of a type, Python will no longer let you try to delete
     or set a ‘T_STRING_INPLACE’ attribute.

   * *note ctypes: 22. によって定義されたグローバルシンボルには、 ‘Py’ ま
     たは ‘_ctypes’ が接頭されるようになりました。(Implemented by Thomas
     Heller; bpo-3102(15).)

   * New configure option: the ‘--with-system-expat’ switch allows
     building the *note pyexpat: 10d. module to use the system Expat
     library.  (Contributed by Arfrever Frehtes Taifersar Arahesis;
     bpo-7609(16).)

   * 新しい設定オプション: ‘--with-valgrind’ オプションは、 Valgrind メ
     モリエラー検出器が正しく分析するのが難しい pymalloc アロケータを無
     効にするようになりました。ですから Valgrind は、メモリリークやオー
     バーランをより検出できます。 (Contributed by James Henstridge;
     bpo-2422(17).)

   * 新しい設定オプション: ‘--with-dbmliborder=’ に空の文字列を与えて様
     々な DBM モジュールを全て無効にできます。 (Added by Arfrever
     Frehtes Taifersar Arahesis; bpo-6491(18).)

   * ‘configure’ スクリプトは、ある種の 32-bit Intel チップ上の浮動小数
     点丸めバグを調べ、 ‘X87_DOUBLE_ROUNDING’ プリプロセッサ定義を定義し
     ます。現在この定義を使うコードはありませんが、使うことを望む人がい
     たら使えます。(Added by Mark Dickinson; bpo-2937(19).)

     ‘configure’ はまた、C++ リンクをサポートする ‘LDCXXSHARED’ Makefile
     を設定するようになりました。 (Contributed by Arfrever Frehtes
     Taifersar Arahesis; bpo-1222585(20).)

   * ビルドプロセスは、pkg-config サポートに必要なファイルを生成するよう
     になりました。(Contributed by Clinton Roy; bpo-3585(21).)

   * ビルドプロセスは、Subversion 1.7 をサポートするようになりました。
     (Contributed by Arfrever Frehtes Taifersar Arahesis; bpo-6094(22).)

* Menu:

* カプセル::
* ポート特有の変更; Windows: ポート特有の変更 Windows.
* ポート特有の変更; Mac OS X: ポート特有の変更 Mac OS X.
* ポート特有の変更; FreeBSD: ポート特有の変更 FreeBSD.

   ---------- Footnotes ----------

   (1) 
https://web.archive.org/web/20110715084810/http://sourceware.org/gdb/current/onlinedocs/gdb/Python.html

   (2) https://bugs.python.org/issue?@action=redirect&bpo=8032

   (3) https://bugs.python.org/issue?@action=redirect&bpo=3632

   (4) https://bugs.python.org/issue?@action=redirect&bpo=4293

   (5) https://bugs.python.org/issue?@action=redirect&bpo=7033

   (6) https://bugs.python.org/issue?@action=redirect&bpo=7528

   (7) https://bugs.python.org/issue?@action=redirect&bpo=7767

   (8) https://www.cve.org/CVERecord?id=CVE-2008-5983

   (9) https://bugs.python.org/issue?@action=redirect&bpo=5753

   (10) https://bugs.python.org/issue?@action=redirect&bpo=5793

   (11) https://bugs.python.org/issue?@action=redirect&bpo=8276

   (12) https://bugs.python.org/issue?@action=redirect&bpo=7228

   (13) https://bugs.python.org/issue?@action=redirect&bpo=1590864

   (14) https://bugs.python.org/issue?@action=redirect&bpo=1722344

   (15) https://bugs.python.org/issue?@action=redirect&bpo=3102

   (16) https://bugs.python.org/issue?@action=redirect&bpo=7609

   (17) https://bugs.python.org/issue?@action=redirect&bpo=2422

   (18) https://bugs.python.org/issue?@action=redirect&bpo=6491

   (19) https://bugs.python.org/issue?@action=redirect&bpo=2937

   (20) https://bugs.python.org/issue?@action=redirect&bpo=1222585

   (21) https://bugs.python.org/issue?@action=redirect&bpo=3585

   (22) https://bugs.python.org/issue?@action=redirect&bpo=6094


File: python.info,  Node: カプセル,  Next: ポート特有の変更 Windows,  Up: ビルドならびに C API の変更<8>

1.15.12.1 カプセル
..................

Python 3.1 は、拡張モジュールに C API を提供する新しい C データ型 *note
PyCapsule: 1244. を追加しました。カプセルは、本質的には C の ‘void *’ ポ
インタのホルダであり、モジュール属性として利用できるようになります。例え
ば、 *note socket: b8. モジュールの API は ‘socket.CAPI’ として公開され
ていて、 *note unicodedata: ee. は ‘ucnhash_CAPI’ を公開しています。その
他の拡張はモジュールを import し、辞書にアクセスしてカプセルオブジェクト
を取得し、そしてモジュールの様々な API 関数へのポインタの配列を指す
‘void *’ ポインタを取得できます。

There is an existing data type already used for this, ‘PyCObject’, but
it doesn't provide type safety.  Evil code written in pure Python could
cause a segmentation fault by taking a ‘PyCObject’ from module A and
somehow substituting it for the ‘PyCObject’ in module B. Capsules know
their own name, and getting the pointer requires providing the name:

     void *vtable;

     if (!PyCapsule_IsValid(capsule, "mymodule.CAPI") {
             PyErr_SetString(PyExc_ValueError, "argument type invalid");
             return NULL;
     }

     vtable = PyCapsule_GetPointer(capsule, "mymodule.CAPI");

‘vtable’ が期待どおりのものを指すことが保証されます。異なるカプセルが渡
されたら、 *note PyCapsule_IsValid(): 1324. は不適合な名前を検知し、偽を
返します。これらのオブジェクトの使用について、より詳しい情報は、 *note
拡張モジュールに C API を提供する: 1325. を参照してください。

Python 2.7 now uses capsules internally to provide various
extension-module APIs, but the ‘PyCObject_AsVoidPtr()’ was modified to
handle capsules, preserving compile-time compatibility with the
‘PyCObject’ interface.  Use of ‘PyCObject_AsVoidPtr()’ will signal a
*note PendingDeprecationWarning: 895, which is silent by default.

Implemented in Python 3.1 and backported to 2.7 by Larry Hastings;
discussed in bpo-5630(1).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5630


File: python.info,  Node: ポート特有の変更 Windows,  Next: ポート特有の変更 Mac OS X,  Prev: カプセル,  Up: ビルドならびに C API の変更<8>

1.15.12.2 ポート特有の変更: Windows
...................................

   * The *note msvcrt: 85. module now contains some constants from the
     ‘crtassem.h’ header file: *note CRT_ASSEMBLY_VERSION: 1327, *note
     VC_ASSEMBLY_PUBLICKEYTOKEN: 1328, and *note
     LIBRARIES_ASSEMBLY_NAME_PREFIX: 1329.  (Contributed by David
     Cournapeau; bpo-4365(1).)

   * The *note _winreg: fe. module for accessing the registry now
     implements the *note CreateKeyEx(): 132a. and *note DeleteKeyEx():
     132b. functions, extended versions of previously supported
     functions that take several extra arguments.  The *note
     DisableReflectionKey(): 132c, *note EnableReflectionKey(): 132d,
     and *note QueryReflectionKey(): 132e. were also tested and
     documented.  (Implemented by Brian Curtin: bpo-7347(2).)

   * The new ‘_beginthreadex()’ API is used to start threads, and the
     native thread-local storage functions are now used.  (Contributed
     by Kristján Valur Jónsson; bpo-3582(3).)

   * The *note os.kill(): 132f. function now works on Windows.  The
     signal value can be the constants *note CTRL_C_EVENT: 1330, *note
     CTRL_BREAK_EVENT: 1331, or any integer.  The first two constants
     will send ‘Control-C’ and ‘Control-Break’ keystroke events to
     subprocesses; any other value will use the ‘TerminateProcess()’
     API.  (Contributed by Miki Tebeka; bpo-1220212(4).)

   * *note os.listdir(): 10cd. 関数は、空のパスに対してちゃんと失敗する
     ようになりました。 (Fixed by Hirokazu Yamamoto; bpo-5913(5).)

   * The *note mimetypes: 82. module will now read the MIME database
     from the Windows registry when initializing.  (Patch by Gabriel
     Genellina; bpo-4969(6).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4365

   (2) https://bugs.python.org/issue?@action=redirect&bpo=7347

   (3) https://bugs.python.org/issue?@action=redirect&bpo=3582

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1220212

   (5) https://bugs.python.org/issue?@action=redirect&bpo=5913

   (6) https://bugs.python.org/issue?@action=redirect&bpo=4969


File: python.info,  Node: ポート特有の変更 Mac OS X,  Next: ポート特有の変更 FreeBSD,  Prev: ポート特有の変更 Windows,  Up: ビルドならびに C API の変更<8>

1.15.12.3 ポート特有の変更: Mac OS X
....................................

   * 追加されたパッケージを、システムインストレーションとユーザがインス
     トールした同じバージョンのコピーで共有するために、 ‘sys.path’ に
     ‘/Library/Python/2.7/site-packages’ が追加されました。 (Changed by
     Ronald Oussoren; bpo-4865(1).)

     バージョン 2.7.13 で変更: As of 2.7.13, this change was removed.
     ‘/Library/Python/2.7/site-packages’, the site-packages directory
     used by the Apple-supplied system Python 2.7 is no longer appended
     to ‘sys.path’ for user-installed Pythons such as from the
     python.org installers.  As of macOS 10.12, Apple changed how the
     system site-packages directory is configured, which could cause
     installation of pip components, like setuptools, to fail.  Packages
     installed for the system Python will no longer be shared with
     user-installed Pythons.  (bpo-28440(2))

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=4865

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28440


File: python.info,  Node: ポート特有の変更 FreeBSD,  Prev: ポート特有の変更 Mac OS X,  Up: ビルドならびに C API の変更<8>

1.15.12.4 ポート特有の変更: FreeBSD
...................................

   * FreeBSD 7.1's ‘SO_SETFIB’ constant, used with the *note socket():
     d6e. methods *note getsockopt(): ca3./*note setsockopt(): ca4. to
     select an alternate routing table, is now available in the *note
     socket: b8. module.  (Added by Kyle VanderBeek; bpo-8235(1).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=8235


File: python.info,  Node: その他の変更と修正,  Next: Python 2 7 への移植,  Prev: ビルドならびに C API の変更<8>,  Up: What's New in Python 2 7

1.15.13 その他の変更と修正
--------------------------

   * ベンチマークスクリプトの 2 つ、 ‘iobench’ および ‘ccbench’, が
     ‘Tools’ ディレクトリに追加されました。 ‘iobench’ は、様々な演算を実
     行している間 *note open(): 4e5. によって返された組み込みファイル
     I/O オブジェクトの速度を計測し、 ‘ccbench’ は、変化する数のスレッド
     を使っていくつかのタスクを処理するときの計算スループット、スレッド
     切り替えレイテンシ、IO 処理バンド幅の計測を試みる同時実行ベンチマー
     クです。

   * ‘Tools/i18n/msgfmt.py’ スクリプトは、複数の形式の ‘.po’ ファイルを
     理解できるようになりました。(Fixed by Martin von Löwis;
     bpo-5464(1).)

   * When importing a module from a ‘.pyc’ or ‘.pyo’ file with an
     existing ‘.py’ counterpart, the *note co_filename: 1335. attributes
     of the resulting code objects are overwritten when the original
     filename is obsolete.  This can happen if the file has been
     renamed, moved, or is accessed through different paths.  (Patch by
     Ziga Seilnacht and Jean-Paul Calderone; bpo-1180193(2).)

   * ‘regrtest.py’ スクリプトは、テストを乱順に実行する ‘-r’ オプション
     の、ランダムシードに使われる整数を取る ‘--randseed=’ スイッチを取る
     ようになりました。 ‘-r’ オプションは、使われたシードも報告します。
     (Added by Collin Winter.)

   * もう一つの ‘regrtest.py’ スイッチは ‘-j’ で、いくつのテストを並行し
     て実行するかを指定する整数です。これにより、マルチコア機での合計実
     行時間を短縮できます。このオプションは、実行時間を長くすることで知
     られている ‘-R’ スイッチなど、いくつかの他のオプションと互換です。
     (Added by Antoine Pitrou, bpo-6152(3).)  これはまた、選ばれたテスト
     を失敗するまでループして実行する ‘-F’ スイッチとも同時に使えます。
     (Added by Antoine Pitrou; bpo-7312(4).)

   * スクリプトとして実行されるとき、 ‘py_compile.py’ モジュールは標準入
     力を読み込んでコンパイルするファイル名のリストとする ‘'-'’ を引数と
     して受け付けるようになりました。(Contributed by Piotr Ożarowski;
     bpo-8233(5).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5464

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1180193

   (3) https://bugs.python.org/issue?@action=redirect&bpo=6152

   (4) https://bugs.python.org/issue?@action=redirect&bpo=7312

   (5) https://bugs.python.org/issue?@action=redirect&bpo=8233


File: python.info,  Node: Python 2 7 への移植,  Next: Python 2 7 メンテナンスリリースで追加された新機能,  Prev: その他の変更と修正,  Up: What's New in Python 2 7

1.15.14 Python 2.7 への移植
---------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

   * The *note range(): 911. function processes its arguments more
     consistently; it will now call *note __int__(): 6e7. on non-float,
     non-integer arguments that are supplied to it.  (Fixed by Alexander
     Belopolsky; bpo-1533(1).)

   * 文字列 *note format(): 5eb. メソッドは浮動小数点数および複素数に使
     われるデフォルトの精度を、 *note str(): 418. で使われる精度に合わせ
     、小数第 6 位から 12 位に変更しました。 (Changed by Eric Smith;
     bpo-5920(2).)

   * Because of an optimization for the *note with: 59c. statement, the
     special methods *note __enter__(): 592. and *note __exit__(): 12ce.
     must belong to the object's type, and cannot be directly attached
     to the object's instance.  This affects new-style classes (derived
     from *note object: a5a.) and C extension types.  (bpo-6101(3).)

   * Due to a bug in Python 2.6, the 'exc_value' parameter to *note
     __exit__(): 12ce. methods was often the string representation of
     the exception, not an instance.  This was fixed in 2.7, so
     'exc_value' will be an instance as expected.  (Fixed by Florent
     Xicluna; bpo-7853(4).)

   * ‘__slots__’ を利用して属性を制限した場合に、設定されていない属性を
     del したときに *note AttributeError: 326. にならなかったのを修正し
     ました。 (Fixed by Benjamin Peterson; bpo-7604(5).)

標準ライブラリでは:

   * 年がサポートされている範囲外にはみ出るような *note datetime: 1ae. イ
     ンスタンスの演算が、 *note OverflowError: 84e. を送出しないことがあ
     りました。このようなエラーはより注意深く調べられ、例外を送出するよ
     うになりました。(Reported by Mark Leander, patch by Anand B. Pillai
     and Alexander Belopolsky; bpo-7150(6).)

   * *note Decimal: 27d. インスタンスを文字列の *note format(): 5eb. メ
     ソッドに使うとき、デフォルトの揃えは以前は左揃えでした。これは右揃
     えに変更され、プログラムの出力が変わるかもしれません。(Changed by
     Mark Dickinson; bpo-6857(7).)

     signaling NaN (あるいは ‘sNAN’) との比較は、暗黙に比較演算に応じて
     真偽値を返すのではなく、 *note InvalidOperation: 107a. 例外を発生さ
     せるようになりました。 Quiet NaN (あるいは ‘NAN’) はハッシュ可能に
     なりました。 (Fixed by Mark Dickinson; bpo-7279(8).)

   * The *note xml.etree.ElementTree: 10c. library no longer escapes
     ampersands and angle brackets when outputting an XML processing
     instruction (which looks like ‘<?xml-stylesheet href="#style1"?>’)
     or comment (which looks like ‘<!-- comment -->’).  (Patch by Neil
     Muller; bpo-2746(9).)

   * The ‘readline()’ method of *note StringIO: ef3. objects now does
     nothing when a negative length is requested, as other file-like
     objects do.  (bpo-7348(10)).

   * *note syslog: c6. モジュールは、識別子として、以前デフォルトであっ
     た ‘'python'’ の値ではなく、 ‘sys.argv[0]’ の値を使うようになりまし
     た。 (Changed by Sean Reifschneider; bpo-8451(11).)

   * *note tarfile: c8. モジュールのデフォルトエラー処理が変更され、致命
     的なエラーを抑制しないようになりました。デフォルトのエラーレベルは
     以前は 0 で、エラーはメッセージとしてデバッグログに書き込まれるだけ
     でしたが、デバッグログはデフォルトでは活性化されていないため、エラ
     ーは顧みられませんでした。デフォルトのエラーレベルは 1 になり、エラ
     ーがあれば例外が送出されます。 (Changed by Lars Gustäbel;
     bpo-7357(12).)

   * The *note urlparse: f3. module's *note urlsplit(): d0d. now handles
     unknown URL schemes in a fashion compliant with RFC 3986(13): if
     the URL is of the form ‘"<something>://..."’, the text before the
     ‘://’ is treated as the scheme, even if it's a made-up scheme that
     the module doesn't know about.  This change may break code that
     worked around the old behaviour.  For example, Python 2.6.4 or 2.5
     will return the following:

          >>> import urlparse
          >>> urlparse.urlsplit('invented://host/filename?query')
          ('invented', '', '//host/filename?query', '', '')

     Python 2.7 (や Python 2.6.5) は以下を返します:

          >>> import urlparse
          >>> urlparse.urlsplit('invented://host/filename?query')
          ('invented', 'host', '/filename?query', '', '')

     (Python 2.7 では、これは普通のタプルではなく名前付きタプルを返すの
     で、実際は微妙に異なる出力をします。)

C 拡張では:

   * ‘PyArg_Parse*’ 系統の関数で整数フォーマットコードを使う C 拡張は、
     *note DeprecationWarning: 18a. を引き起こすのではなく、 *note
     TypeError: 502. 例外を送出するようになりました。(bpo-5080(14))

   * Use the new *note PyOS_string_to_double(): 1266. function instead
     of the old ‘PyOS_ascii_strtod()’ and ‘PyOS_ascii_atof()’ functions,
     which are now deprecated.

Python を埋め込んだアプリケーションでは:

   * The ‘PySys_SetArgvEx()’ function was added, letting applications
     close a security hole when the existing ‘PySys_SetArgv()’ function
     was used.  Check whether you're calling ‘PySys_SetArgv()’ and
     carefully consider whether the application should be using
     ‘PySys_SetArgvEx()’ with 'updatepath' set to false.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1533

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5920

   (3) https://bugs.python.org/issue?@action=redirect&bpo=6101

   (4) https://bugs.python.org/issue?@action=redirect&bpo=7853

   (5) https://bugs.python.org/issue?@action=redirect&bpo=7604

   (6) https://bugs.python.org/issue?@action=redirect&bpo=7150

   (7) https://bugs.python.org/issue?@action=redirect&bpo=6857

   (8) https://bugs.python.org/issue?@action=redirect&bpo=7279

   (9) https://bugs.python.org/issue?@action=redirect&bpo=2746

   (10) https://bugs.python.org/issue?@action=redirect&bpo=7348

   (11) https://bugs.python.org/issue?@action=redirect&bpo=8451

   (12) https://bugs.python.org/issue?@action=redirect&bpo=7357

   (13) https://datatracker.ietf.org/doc/html/rfc3986.html

   (14) https://bugs.python.org/issue?@action=redirect&bpo=5080


File: python.info,  Node: Python 2 7 メンテナンスリリースで追加された新機能,  Next: 謝辞,  Prev: Python 2 7 への移植,  Up: What's New in Python 2 7

1.15.15 Python 2.7 メンテナンスリリースで追加された新機能
---------------------------------------------------------

Python 2.7 メンテナンスリリースでは、正真正銘それが求められる状況では、
新しい機能が追加される場合があります。そのような追加のどんなものでも
Python Enhancement Proposal プロセスを通過しなければなりません。Python 3
だけに新しい機能を追加することによっても Python Package Index に公開する
ことによってもいずれでも十分ではないと言えるだけのやむにやまれない理由付
けが必要です。

個別の提案は以下にリストしますが、全ての Python 2.7 メンテナンスリリース
に追加される新しい ‘-3’ 警告は除いています。

* Menu:

* デバッグモード用の2つの新しい環境変数::
* PEP 434; IDLE 拡張についての全てのブランチにおける例外的な扱い: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い.
* PEP 466; Python 2.7 のためのネットワークセキュリティ拡張: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張.
* PEP 477; Python 2.7 への ensurepip (PEP 453) バックポート: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート.
* PEP 476; stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>.
* PEP 493; HTTPS verification migration tools for Python 2.7: PEP 493 HTTPS verification migration tools for Python 2 7.
* New make regen-all build target: New make regen-all build target<3>.
* Removal of make touch build target: Removal of make touch build target<3>.


File: python.info,  Node: デバッグモード用の2つの新しい環境変数,  Next: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.1 デバッグモード用の2つの新しい環境変数
...............................................

In debug mode, the ‘[xxx refs]’ statistic is not written by default, the
‘PYTHONSHOWREFCOUNT’ environment variable now must also be set.
(Contributed by Victor Stinner; bpo-31733(1).)

When Python is compiled with ‘COUNT_ALLOC’ defined, allocation counts
are no longer dumped by default anymore: the ‘PYTHONSHOWALLOCCOUNT’
environment variable must now also be set.  Moreover, allocation counts
are now dumped into stderr, rather than stdout.  (Contributed by Victor
Stinner; bpo-31692(2).)

Added in version 2.7.15.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31733

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31692


File: python.info,  Node: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い,  Next: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張,  Prev: デバッグモード用の2つの新しい環境変数,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.2 PEP 434: IDLE 拡張についての全てのブランチにおける例外的な扱い
........................................................................

PEP 434(1) は、Pythonと一緒に出荷されるIDLE開発環境に変更を加えるための
一般的な免除事項を説明します。これは、IDLE の開発者 が Python 2 と 3 の
すべてのサポートされているバージョン間でより一貫したユーザーエクスペリエ
ンスを提供するためのものです。

全ての IDLE の変更についての詳細は、個別のリリースについてのNEWS ファイ
ルを参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0434/


File: python.info,  Node: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張,  Next: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート,  Prev: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.3 PEP 466: Python 2.7 のためのネットワークセキュリティ拡張
..................................................................

PEP 466(1) は、 Python 2.7 メンテナンスリリースに含めることを認められた
数多くのネットワークセキュリティ強化についての提案を記述しています。それ
ら変更の最初のものは Python 2.7.7 に初めて登場しました。

Python 2.7.7 に PEP 466(2) 関連で追加された機能:

   * *note hmac.compare_digest(): 109c. が Python 3 からバックポートされ
     ました。これにより Python 2 アプリケーションで timing attack
     resistant comparison operation が利用可能になります (Contributed by
     Alex Gaynor; bpo-21306(3).)

   * python.org で公開される公式 Windows インストーラのビルドに使う
     OpenSSL が 1.0.1g にアップグレードされました .  (Contributed by
     Zachary Ware; bpo-21462(4).)

Python 2.7.8 に PEP 466(5) 関連で追加された機能:

   * *note hashlib.pbkdf2_hmac(): 4d9. が Python 3 からバックポートされ
     ました。これにより Python 2 アプリケーションでも、安全なパスワード
     格納に広範に使うのに相応しいハッシュアルゴリズムが利用できます
     (Contributed by Alex Gaynor; bpo-21304(6).)

   * OpenSSL 1.0.1h was upgraded for the official Windows installers
     published on python.org.  (Contributed by Zachary Ware in
     bpo-21671(7) for CVE 2014-0224(8).)

Python 2.7.9 に PEP 466(9) 関連で追加された機能:

   * Python 3.4 の *note ssl: bb. モジュールのほとんどがバックポートされ
     ました。つまり *note ssl: bb. は今や、Server Name Indication,
     TLS1.x 設定, platform certificate store へのアクセス, *note
     SSLContext: 274. クラス, その他機能が使えます (Contributed by Alex
     Gaynor and David Reid; bpo-21308(10).)

     個別の詳細については、モジュールのドキュメンテーション内の "バージ
     ョン 2.7.9 で追加" の注釈を参照してください。

   * *note os.urandom(): 4ec. は、呼び出しのたびに ‘/dev/urandom’ を開き
     なおす代わりに ‘/dev/urandom’ のファイル記述子をキャッシュするよう
     に変更されました。(Contributed by Alex Gaynor; bpo-21305(11).)

   * *note hashlib.algorithms_guaranteed: 133b. と *note
     hashlib.algorithms_available: 133c. が Python 3 からバックポートさ
     れました。これにより Python 2 アプリケーションが可能な限り最強のハ
     ッシュアルゴリズムを選択するのが容易になります (Contributed by Alex
     Gaynor in bpo-21307(12))

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0466/

   (2) https://peps.python.org/pep-0466/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21306

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21462

   (5) https://peps.python.org/pep-0466/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21304

   (7) https://bugs.python.org/issue?@action=redirect&bpo=21671

   (8) https://www.cve.org/CVERecord?id=CVE-2014-0224

   (9) https://peps.python.org/pep-0466/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21308

   (11) https://bugs.python.org/issue?@action=redirect&bpo=21305

   (12) https://bugs.python.org/issue?@action=redirect&bpo=21307


File: python.info,  Node: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート,  Next: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>,  Prev: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.4 PEP 477: Python 2.7 への ensurepip (PEP 453) バックポート
...................................................................

PEP 477(1) が Python 2.7 メンテナンスリリースに PEP 453(2) ensurepip モ
ジュール, それによって可能になるドキュメンテーションの改善を含めることを
認め、Python 2.7.9 リリースではじめてお披露目されました。

* Menu:

* デフォルトでの pip のブートストラッピング: デフォルトでの pip のブートストラッピング<2>.
* ドキュメントの変更: ドキュメントの変更<2>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0477/

   (2) https://peps.python.org/pep-0453/


File: python.info,  Node: デフォルトでの pip のブートストラッピング<2>,  Next: ドキュメントの変更<2>,  Up: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート

1.15.15.5 デフォルトでの pip のブートストラッピング
...................................................

新しい *note ensurepip: 4b. モジュール( PEP 453(1) で定義されています)は
標準のクロスプラットフォームのメカニズムで、Python インストールに pip イ
ンストーラをブートストラップします。Python 2.7.9 に含まれる ‘pip’ のバー
ジョンは ‘pip’ 1.5.6 で、将来の 2.7.x メンテナンスリリースでは Python の
リリース候補の作成時点で入手出来る最新バージョンの ‘pip’ がバンドルされ
る予定です。

デフォルトでは ‘pip’ , ‘pipX’ , ‘pipX.Y’ コマンドが全てのプラットフォー
ムに、Python パッケージ ‘pip’ とその依存物とともにインストールされます
(X.  Y はインストールされる Python のバージョン)。

CPython の *note source builds on POSIX systems: ebe. では ‘make
install’, ‘make altinstall’ コマンドはデフォルトでは ‘pip’ ブートストラ
ップを行いません。この振る舞いは configure のオプションを変更して
Makefile を作ることで変更できます。

Windows と Mac OS X では CPython インストーラはそれ自身と一緒に ‘pip’ を
デフォルトでインストールするようになっています(ユーザはインストールプロ
セスで除外するかもしれませんが)。Windows ユーザは ‘pip’ がコマンドライン
からデフォルトで利用可能なように ‘PATH’ の自動修正するかの選択を求められ
ます。そうしない場合でも Windows のための Python ランチャで ‘py -m pip’
のようにすれば良いです。

As discussed in the PEP(2), platform packagers may choose not to install
these commands by default, as long as, when invoked, they provide clear
and simple directions on how to install them on that platform (usually
using the system package manager).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0453/

   (2) 
https://peps.python.org/pep-0477/#disabling-ensurepip-by-downstream-distributors


File: python.info,  Node: ドキュメントの変更<2>,  Prev: デフォルトでの pip のブートストラッピング<2>,  Up: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート

1.15.15.6 ドキュメントの変更
............................

この変更の一部は、 *note Python モジュールのインストール: ec0. と
distributing-index セクションがより手短な始め方として完全にデザインし直
されたことと、FAQ ドキュメントです。ほとんどのパッケージングについてのド
キュメンテーションは Python Packaging User Guide(1) が保守している
Python Packaging Authority に移動されて、独立したプロジェクトのドキュメ
ンテーションになっています。

However, as this migration is currently still incomplete, the legacy
versions of those guides remaining available as *note setuptools による
C および C++ 拡張のビルド: ec1. and *note setuptools による C および C++
拡張のビルド: ec2.

参考
....

PEP 453(2) - Python インストールの際の明示的なpipのブートストラッピング

     PEP は Donald Stufft と Nick Coghlan によって書かれ、Donald Stufft,
     Nick Coghlan, Martin von Löwis, Ned Deily により実装されました。

   ---------- Footnotes ----------

   (1) https://packaging.python.org

   (2) https://peps.python.org/pep-0453/


File: python.info,  Node: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>,  Next: PEP 493 HTTPS verification migration tools for Python 2 7,  Prev: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.7 PEP 476: stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化
.....................................................................................

PEP 476(1) updated *note httplib: 64. and modules which use it, such as
*note urllib2: f4. and *note xmlrpclib: 114, to now verify that the
server presents a certificate which is signed by a Certificate Authority
in the platform trust store and whose hostname matches the hostname
being requested by default, significantly improving security for many
applications.  This change was made in the Python 2.7.9 release.

以前の古い振る舞いが必要なアプリケーションでは、代わりとなるコンテキスト
を渡せます:

     import urllib2
     import ssl

     # This disables all verification
     context = ssl._create_unverified_context()

     # This allows using a specific certificate for the host, which doesn't need
     # to be in the trust store
     context = ssl.create_default_context(cafile="/path/to/file.crt")

     urllib2.urlopen("https://invalid-cert", context=context)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0476/


File: python.info,  Node: PEP 493 HTTPS verification migration tools for Python 2 7,  Next: New make regen-all build target<3>,  Prev: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.8 PEP 493: HTTPS verification migration tools for Python 2.7
....................................................................

PEP 493(1) provides additional migration tools to support a more
incremental infrastructure upgrade process for environments containing
applications and services relying on the historically permissive
processing of server certificates when establishing client HTTPS
connections.  These additions were made in the Python 2.7.12 release.

These tools are intended for use in cases where affected applications
and services can't be modified to explicitly pass a more permissive SSL
context when establishing the connection.

For applications and services which can't be modified at all, the new
‘PYTHONHTTPSVERIFY’ environment variable may be set to ‘0’ to revert an
entire Python process back to the default permissive behaviour of Python
2.7.8 and earlier.

For cases where the connection establishment code can't be modified, but
the overall application can be, the new
‘ssl._https_verify_certificates()’ function can be used to adjust the
default behaviour at runtime.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0493/


File: python.info,  Node: New make regen-all build target<3>,  Next: Removal of make touch build target<3>,  Prev: PEP 493 HTTPS verification migration tools for Python 2 7,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.9 New ‘make regen-all’ build target
...........................................

To simplify cross-compilation, and to ensure that CPython can reliably
be compiled without requiring an existing version of Python to already
be available, the autotools-based build system no longer attempts to
implicitly recompile generated files based on file modification times.

Instead, a new ‘make regen-all’ command has been added to force
regeneration of these files when desired (e.g.  after an initial version
of Python has already been built based on the pregenerated versions).

More selective regeneration targets are also defined - see
Makefile.pre.in(1) for details.

(Victor Stinner の貢献による bpo-23404(2))

Added in version 2.7.14.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Makefile.pre.in

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23404


File: python.info,  Node: Removal of make touch build target<3>,  Prev: New make regen-all build target<3>,  Up: Python 2 7 メンテナンスリリースで追加された新機能

1.15.15.10 Removal of ‘make touch’ build target
...............................................

The ‘make touch’ build target previously used to request implicit
regeneration of generated files by updating their modification times has
been removed.

It has been replaced by the new ‘make regen-all’ target.

(Victor Stinner の貢献による bpo-23404(1))

バージョン 2.7.14 で変更.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23404


File: python.info,  Node: 謝辞,  Prev: Python 2 7 メンテナンスリリースで追加された新機能,  Up: What's New in Python 2 7

1.15.16 謝辞
------------

著者は、以下の方々がこの記事の多くの草稿に提案、修正、そして助力を差し伸
べてくださったことに感謝の意を表したいと思います: Nick Coghlan, Philip
Jenvey, Ryan Lovett, R. David Murray, Hugh Secker-Walker.


File: python.info,  Node: What's New in Python 2 6,  Next: What's New in Python 2 5,  Prev: What's New in Python 2 7,  Up: What's New in Python

1.16 What's New in Python 2.6
=============================


著者: A.M. Kuchling (amk at amk.ca)

This article explains the new features in Python 2.6, released on
October 1, 2008.  The release schedule is described in PEP 361(1).

Python 2.6 の主要なテーマは、大幅な言語の再設計となる Python 3.0 移行へ
の道筋を準備することです。可能な場合にはいつでも、Python 2.6 は、古い機
能や文法を削除することなく既存のコードの互換性を保てるようにしながら、
3.0 より新機能と新文法を組み込んでいます。そうすることが出来ない場合には
、Python 2.6 は、出来ることを出来るだけ試みました。それには
‘future_builtins’ モジュールに互換関数を、また、Python 3 でサポートされ
なくなる用法についての警告を出すための ‘-3’ スイッチ を追加しています。

*note multiprocessing: 86. や *note json: 76. といった、いくつか重要な新
しいパッケージが標準ライブラリに追加されましたが、Python 3.0 に何らかも
関係しない新機能はあまり多くはありません。

Python 2.6 ではさらに、たくさんの改善とバグフィックスがソースコードのあ
りとあらゆる場所に見られます。Python 2.5 から 2.6 の変更ログを手繰ってみ
ると、低く見積もっても、適用されたパッチは 259、フィックスされたバグは
612 にのぼります。

このドキュメントは新機能の完全な詳細を提供するのではなくて、簡易な概要を
提供することを目的にしています。完全な詳細が知りたければ、 Python 2.6 の
ドキュメントを参照してください。設計と実装の根拠を理解したい場合は、新機
能に関する PEP を参照してください。可能な限り、 "What’s New in Python" は
各変更の bug や patch に対してリンクしています。

* Menu:

* Python 3.0: Python 3 0.
* 開発プロセスに関する変更::
* PEP 343; "with" ステートメント: PEP 343 "with" ステートメント.
* PEP 366; メインモジュールからの明示的相対インポート: PEP 366 メインモジュールからの明示的相対インポート.
* PEP 370; ユーザごとの site-packages ディレクトリ: PEP 370 ユーザごとの site-packages ディレクトリ.
* PEP 371; multiprocessing パッケージ: PEP 371 multiprocessing パッケージ.
* PEP 3101; 進化版文字列フォーマッティング: PEP 3101 進化版文字列フォーマッティング.
* PEP 3105; print を関数にする: PEP 3105 print を関数にする.
* PEP 3110; 例外処理の変更: PEP 3110 例外処理の変更.
* PEP 3112; バイトリテラル: PEP 3112 バイトリテラル.
* PEP 3116; 新しい I/O ライブラリ: PEP 3116 新しい I/O ライブラリ.
* PEP 3118; 改訂版バッファプロトコル: PEP 3118 改訂版バッファプロトコル.
* PEP 3119; 抽象基底クラス: PEP 3119 抽象基底クラス.
* PEP 3127; 整数リテラルのサポートと文法: PEP 3127 整数リテラルのサポートと文法.
* PEP 3129; クラスデコレータ: PEP 3129 クラスデコレータ.
* PEP 3141; 数値の型階層: PEP 3141 数値の型階層.
* その他の言語変更: その他の言語変更<13>.
* 新しいモジュールと改良されたモジュール: 新しいモジュールと改良されたモジュール<2>.
* 非推奨と削除::
* ビルドならびに C API の変更: ビルドならびに C API の変更<9>.
* Python 2.6 への移植: Python 2 6 への移植.
* 謝辞: 謝辞<2>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0361/


File: python.info,  Node: Python 3 0,  Next: 開発プロセスに関する変更,  Up: What's New in Python 2 6

1.16.1 Python 3.0
-----------------

Python 2.6 と 3.0 の開発サイクルは同期していました。両バージョンのアルフ
ァ、ベータリリースは同じ日にリリースされています。3.0 の開発は 2.6 の多
くの機能に影響を与えました。

Python 3.0 は、2.x シリーズとの互換性を破壊する、広範囲な再設計です。こ
れは、Python 3.0 で動作させるためには既存のコードに何らかの変換が必要な
ことを意味しています。しかしながら、必ずしも全ての 3.0 での変更が互換性
を破壊するわけではありません。新機能が既存のコードの破壊を引き起こさない
ケースにおいては、それらは 2.6 にバックポートされました。これらについて
はこのドキュメントの適切な場所に記載しています。3.0 由来の機能の一部とし
ては以下があります:

   * オブジェクトを複素数(虚数)に変換する ‘__complex__()’ メソッド。

   * 例外の捕捉の、これまでとは別の文法の追加: ‘except TypeError as exc’
     。

   * 組み込み関数 ‘reduce()’ への別名としての *note functools.reduce():
     12aa. の追加。

Python 3.0 はいくつかの新しい組み込み関数を追加し、また、いくつかの既存
の組み込み関数では意味を変更しています。Python 3.0 での新しい組み込み関
数、例えば *note bin(): 127a. などは単純に 2.6 に追加されましたが、既存
のものはそうせずに、代わりに ‘future_builtins’ モジュールに 3.0 版のもの
を追加しています。3.0 と互換性を持ちたいコードでは、必要に応じて ‘from
future_builtins import hex, map’ などとすることが出来ます。

A new command-line switch, ‘-3’, enables warnings about features that
will be removed in Python 3.0.  You can run code with this switch to see
how much work will be necessary to port code to 3.0.  The value of this
switch is available to Python code as the boolean variable
‘sys.py3kwarning’, and to C extension code as ‘Py_Py3kWarningFlag’.

参考
....

The 3'xxx' series of PEPs, which contains proposals for Python 3.0.  PEP
3000(1) describes the development process for Python 3.0.  Start with
PEP 3100(2) that describes the general goals for Python 3.0, and then
explore the higher-numbered PEPs that propose specific features.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3000/

   (2) https://peps.python.org/pep-3100/


File: python.info,  Node: 開発プロセスに関する変更,  Next: PEP 343 "with" ステートメント,  Prev: Python 3 0,  Up: What's New in Python 2 6

1.16.2 開発プロセスに関する変更
-------------------------------

2.6 の開発の間で、Python 開発プロセスは 2 つの重要な変更を経験しました:
SourceForge の課題トラッカーから、カスタイマイズした Roundup インストレ
ーションに乗り換えました。また、ドキュメントは LaTeX から
reStructuredText に変換しました。

* Menu:

* 新しい課題トラッカー; Roundup: 新しい課題トラッカー Roundup.
* 新しいドキュメンテーションフォーマット; Sphinx を使っての reStructuredText: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText.


File: python.info,  Node: 新しい課題トラッカー Roundup,  Next: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText,  Up: 開発プロセスに関する変更

1.16.2.1 新しい課題トラッカー: Roundup
......................................

もう随分長いこと Python 開発者たちは、SourceForge のバグトラッカーにイラ
イラを高め続けてきました。SourceForge がホストするソリューションには全く
カスタマイズの余地がなく、たとえば課題のライフサイクルをカスタマイズ出来
ませんでした。

The infrastructure committee of the Python Software Foundation therefore
posted a call for issue trackers, asking volunteers to set up different
products and import some of the bugs and patches from SourceForge.  Four
different trackers were examined: Jira(1), Launchpad(2), Roundup(3), and
Trac(4).  The committee eventually settled on Jira and Roundup as the
two candidates.  Jira is a commercial product that offers no-cost hosted
instances to free-software projects; Roundup is an open-source project
that requires volunteers to administer it and a server to host it.

ボランティアへの呼び掛けののち、新しい Roundup インストレーションが
‘https://bugs.python.org’ にセットアップされました。Roundup の一つのイン
ストレーションは複数のトラッカーをホスト出来るため、このサーバは今では
Jython と Python ウェブサイトのための課題トラッカーもホストしています。
間違いなく将来はほかのものもホストするでしょう。可能な場所では、"What's
New in Python" のこのエディションでは、それぞれの変更についてのバグ/パッ
チの Roundup アイテムにリンクします。

Hosting of the Python bug tracker is kindly provided by Upfront
Systems(5) of Stellenbosch, South Africa.  Martin von Löwis put a lot of
effort into importing existing bugs and patches from SourceForge; his
scripts for this import operation are at
‘https://svn.python.org/view/tracker/importer/’ and may be useful to
other projects wishing to move from SourceForge to Roundup.

参考
....

‘https://bugs.python.org’

     Python のバグトラッカー。

‘https://bugs.jython.org’:

     Jython のバグトラッカー。

‘https://roundup.sourceforge.io/’

     Roundup のダウンロードとドキュメント。

‘https://svn.python.org/view/tracker/importer/’

     Martin von Löwis の変換スクリプト。

   ---------- Footnotes ----------

   (1) https://www.atlassian.com/software/jira/

   (2) https://launchpad.net/

   (3) https://roundup.sourceforge.io/

   (4) https://trac.edgewall.org/

   (5) https://upfrontsoftware.co.za


File: python.info,  Node: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText,  Prev: 新しい課題トラッカー Roundup,  Up: 開発プロセスに関する変更

1.16.2.2 新しいドキュメンテーションフォーマット: Sphinx を使っての reStructuredText
...................................................................................

Python のドキュメンテーションは、そのプロジェクトの開始した 1989 年頃よ
り LaTeX を使って書かれてきました。1980 年代と 1990 年代初期は、ほとんど
のドキュメンテーションはあとで学習するために印刷されるもので、オンライン
で見るものではありませんでした。LaTeX はとても魅惑的な印刷をしてくれるも
のですから、非常に大変広く広く使われていましたが、一方では、学んだマーク
アップの基礎的なルールで直裁的に、書いたらそれっきり、というものでもあり
ました。

こんにちにおいてもなお、印刷を命題とする出版において LaTeX は健在といえ
ど、プログラミングの道具立ての風景は変わりました。わたしたちはもはやドキ
ュメンテーションの紙束をプリントアウトはしません。代わりにオンラインでブ
ラウズします。ですから HTML は、サポートすべき最も重要なフォーマットにな
りました。悲しいかな、 LaTeX から HTML への変換は気が狂うほどに複雑で、
Fred L. Drake Jr.、彼は長らく Python ドキュメンテーションのエディターを
務めていますが、彼はその変換処理の保守に多大な時間を浪費していたのです。
ときおり人々はドキュメンテーションを SGML に変換して、それから XML にす
ればいいでしょ、と持ちかけるのですが、良い変換を達成することにとらわれて
、誰一人として仕事を完遂させようと時間を捧げることはしませんでした。

During the 2.6 development cycle, Georg Brandl put a lot of effort into
building a new toolchain for processing the documentation.  The
resulting package is called Sphinx, and is available from
‘https://www.sphinx-doc.org/’.

Sphinx は HTML 出力に集中し、人を惹きつけるスタイルでモダンな HTML を生
成します。印刷出力は LaTeX への変換を経由することで健在です。入力のフォ
ーマットは reStructuredText です。これはカスタムな拡張とディレクティブを
サポートしているマークアップ文法で、Python コミュニティでは広く使われて
います。

Sphinx は執筆に使えるスタンドアロンのパッケージです。そして 2 ダースに届
かんばかりのプロジェクト (Sphinx ウェブサイトのリスト(1)) が Sphinx をド
キュメンテーションツールとして採用しました。

参考
....

Documenting Python(2)

     Python ドキュメントの書き方について書いています。

Sphinx(3)

     Sphinx ツールチェインのドキュメントとコードです。

Docutils(4)

     縁の下の力持ちになっている reStructuredText のパーサとツールセット
     です。

   ---------- Footnotes ----------

   (1) https://www.sphinx-doc.org/en/master/examples.html

   (2) https://devguide.python.org/documenting/

   (3) https://www.sphinx-doc.org/

   (4) https://docutils.sourceforge.io


File: python.info,  Node: PEP 343 "with" ステートメント,  Next: PEP 366 メインモジュールからの明示的相対インポート,  Prev: 開発プロセスに関する変更,  Up: What's New in Python 2 6

1.16.3 PEP 343: "with" ステートメント
-------------------------------------

Python 2.5 では、 '*note with: 59c.' 文が ‘from __future__ import
with_statement’ ディレクティブで有効に出来るオプションの機能として追加さ
れました。2.6 では '‘with’' 文は特別に有効化する必要なく、もういつでもそ
こにあります。このセクションの残りの部分は "What's New in Python 2.5" の
対応するセクションからの丸々コピーですので、2.5 で '‘with’' 文に馴染んで
いるなら読み飛ばしてもらって結構です。

'*note with: 59c.' ステートメントは、以前なら後片付けが実行されるのを確
実にするために ‘try...finally’ ブロックを使ったであろうようなコードを、
より単純明快にします。このセクションでは、このステートメントの普通の使い
方を説明します。続くセクションでは実装の詳細を調べ、このステートメントと
ともに使うためにオブジェクトをどうやって書けば良いかをお見せします。

'*note with: 59c.' ステートメントは基本構造が以下となる制御フロー構造で
す:

     with expression [as variable]:
         with-block

The expression is evaluated, and it should result in an object that
supports the context management protocol (that is, has *note
__enter__(): 592. and *note __exit__(): 12ce. methods).

The object's *note __enter__(): 592. is called before 'with-block' is
executed and therefore can run set-up code.  It also may return a value
that is bound to the name 'variable', if given.  (Note carefully that
'variable' is 'not' assigned the result of 'expression'.)

After execution of the 'with-block' is finished, the object's *note
__exit__(): 12ce. method is called, even if the block raised an
exception, and can therefore run clean-up code.

いくつかの Python 標準オブジェクトが既にコンテキスト管理プロトコルをサポ
ートしていて、 '*note with: 59c.' とともに使えます。ファイルオブジェクト
がその一例です:

     with open('/etc/passwd', 'r') as f:
         for line in f:
             print line
             ... more processing code ...

このステートメントが実行し終わったあかつきには、 'f' のファイルオブジェ
クトは、たとえ *note for: 2c9. ループが道半ばにして例外と成り果てても、
自動的にクローズされます。

     注釈: In this case, 'f' is the same object created by *note open():
     4e5, because *note __enter__(): 592. returns 'self'.

*note threading: d6. モジュールのロック・条件変数でも '*note with: 59c.'
ステートメントの恩恵にあずかれます:

     lock = threading.Lock()
     with lock:
         # Critical section of code
         ...

ブロックが実行される前にロックが獲得されて、ブロックが完了するやいなや必
ず解放されます。

*note decimal: 2e. モジュール内の ‘localcontext()’ 関数は現在の decimal
のコンテキスト (計算の望みの精度と丸め特性をカプセル化しています) を保存
しておいてあとで元に戻すのを簡単にしてくれます:

     from decimal import Decimal, Context, localcontext

     # Displays with default precision of 28 digits
     v = Decimal('578')
     print v.sqrt()

     with localcontext(Context(prec=16)):
         # All code in this block uses a precision of 16 digits.
         # The original context is restored on exiting the block.
         print v.sqrt()

* Menu:

* コンテキストマネージャを書く::
* contextlib モジュール::


File: python.info,  Node: コンテキストマネージャを書く,  Next: contextlib モジュール,  Up: PEP 343 "with" ステートメント

1.16.3.1 コンテキストマネージャを書く
.....................................

中身を紐解いてみれば、 '*note with: 59c.' ステートメントはけっこう入り組
んでいます。ほとんどの人にとっては、既存のオブジェクトを '‘with’' ととも
に使うだけのことでその詳細を知る必要は無いので、それで良いならこのセクシ
ョンの残りの部分は読み飛ばして結構です。新しいオブジェクトの作者は基礎と
なる実装の詳細について知る必要があるので、このまま読み進めるべきです。

コンテキスト管理プロトコルの高度な説明はこんなです:

   * The expression is evaluated and should result in an object called a
     "context manager".  The context manager must have *note
     __enter__(): 592. and *note __exit__(): 12ce. methods.

   * The context manager's *note __enter__(): 592. method is called.
     The value returned is assigned to 'VAR'. If no ‘as VAR’ clause is
     present, the value is simply discarded.

   * 'BLOCK' 内のコードが実行されます。

   * If 'BLOCK' raises an exception, the context manager's *note
     __exit__(): 12ce. method is called with three arguments, the
     exception details (‘type, value, traceback’, the same values
     returned by *note sys.exc_info(): 656, which can also be ‘None’ if
     no exception occurred).  The method's return value controls whether
     an exception is re-raised: any false value re-raises the exception,
     and ‘True’ will result in suppressing it.  You'll only rarely want
     to suppress the exception, because if you do the author of the code
     containing the '*note with: 59c.' statement will never realize
     anything went wrong.

   * If 'BLOCK' didn't raise an exception, the *note __exit__(): 12ce.
     method is still called, but 'type', 'value', and 'traceback' are
     all ‘None’.

例を通じて考えましょう。枝葉末節を含んだ完璧なコードを提示しようとは思い
ませんが、データベースのためにトランザクションをサポートするのに必要とな
るメソッドの書き方についてスケッチしてみようと思います。

(データベース用語に不慣れな方へ:データベースへの変更のセットは、トランザ
クションという単位でグループ化されています。トランザクションは「コミット
」される、その意味は、全ての変更がデータベースに書き込まれることです、も
しくは「ロールバック」される、この場合全ての変更が捨てられてデータベース
が変更されません、この 2 つのいずれかになりえます。詳しくはなにかデータ
ベースの著述を読んで下さい。)

データベース接続を表現するオブジェクトがあると仮定しましょう。私たちの目
標は、そのオブジェクトのユーザがこのように書けるようになることです:

     db_connection = DatabaseConnection()
     with db_connection as cursor:
         cursor.execute('insert into ...')
         cursor.execute('delete from ...')
         # ... more operations ...

トランザクションはブロック内のコードがつつがなく終了すればコミットし、例
外が発生すればロールバックすべきです。私が思い描いている
‘DatabaseConnection’ の基本的なインターフェイスはこんなです:

     class DatabaseConnection:
         # Database interface
         def cursor(self):
             "Returns a cursor object and starts a new transaction"
         def commit(self):
             "Commits current transaction"
         def rollback(self):
             "Rolls back current transaction"

The *note __enter__(): 592. method is pretty easy, having only to start
a new transaction.  For this application the resulting cursor object
would be a useful result, so the method will return it.  The user can
then add ‘as cursor’ to their '*note with: 59c.' statement to bind the
cursor to a variable name.

     class DatabaseConnection:
         ...
         def __enter__(self):
             # Code to start a new transaction
             cursor = self.cursor()
             return cursor

The *note __exit__(): 12ce. method is the most complicated because it's
where most of the work has to be done.  The method has to check if an
exception occurred.  If there was no exception, the transaction is
committed.  The transaction is rolled back if there was an exception.

下記のコード内では実行がメソッドの末尾まで落ちていって、なのでデフォルト
の ‘None’ 返却になります。 ‘None’ は偽なので、例外は自動的に再送出されま
す。望むならもっと明示的に、コメントでマークした部分で *note return:
99c. 文を書いてもよろしいです:

     class DatabaseConnection:
         ...
         def __exit__(self, type, value, tb):
             if tb is None:
                 # No exception, so commit
                 self.commit()
             else:
                 # Exception occurred, so rollback.
                 self.rollback()
                 # return False


File: python.info,  Node: contextlib モジュール,  Prev: コンテキストマネージャを書く,  Up: PEP 343 "with" ステートメント

1.16.3.2 contextlib モジュール
..............................

*note contextlib: 1c. モジュールは、 '*note with: 59c.' ステートメントで
使えるオブジェクトを書く際に便利ないくつかの関数とデコレータを提供してい
ます。

The decorator is called ‘contextmanager()’, and lets you write a single
generator function instead of defining a new class.  The generator
should yield exactly one value.  The code up to the *note yield: 99b.
will be executed as the *note __enter__(): 592. method, and the value
yielded will be the method's return value that will get bound to the
variable in the '*note with: 59c.' statement's ‘as’ clause, if any.  The
code after the ‘yield’ will be executed in the *note __exit__(): 12ce.
method.  Any exception raised in the block will be raised by the ‘yield’
statement.

このデコレータを使って、前セクションの私たちのデータベースの例はこのよう
に書けます:

     from contextlib import contextmanager

     @contextmanager
     def db_transaction(connection):
         cursor = connection.cursor()
         try:
             yield cursor
         except:
             connection.rollback()
             raise
         else:
             connection.commit()

     db = DatabaseConnection()
     with db_transaction(db) as cursor:
         ...

*note contextlib: 1c. モジュールには ‘nested(mgr1, mgr2, ...)’ 関数もあ
り、この関数はたくさんのコンテキストマネージャを組み合わせることができて
、入れ子の '*note with: 59c.' を書く必要性をなくしてくれます。この例では
、単一の '‘with’' でデータベーストランザクション開始とスレッドのロック獲
得の両方をやってのけています:

     lock = threading.Lock()
     with nested (db_transaction(db), lock) as (cursor, locked):
         ...

最後になりますが、 ‘closing()’ 関数はその与えた引数をそのまま返して変数
に束縛出来るようにし、かつブロックの終了で、与えた引数が持つ ‘.close()’
を呼び出します:

     import urllib, sys
     from contextlib import closing

     with closing(urllib.urlopen('http://www.yahoo.com')) as f:
         for line in f:
             sys.stdout.write(line)

参考
....

PEP 343(1) - "with" ステートメント

     PEP は Guido van Rossum と Nick Coghlan によって書かれ、Mike Bland、
     Guido van Rossum、Neal Norwitz により実装されました。この PEP は
     '*note with: 59c.' ステートメントによって生成されるコードを見せてく
     れるので、このステートメントがどうやって動作するのかを知るのに役立
     ちます。

*note contextlib: 1c. モジュールについてのドキュメント。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0343/


File: python.info,  Node: PEP 366 メインモジュールからの明示的相対インポート,  Next: PEP 370 ユーザごとの site-packages ディレクトリ,  Prev: PEP 343 "with" ステートメント,  Up: What's New in Python 2 6

1.16.4 PEP 366: メインモジュールからの明示的相対インポート
----------------------------------------------------------

Python のオプション *note -m: 5ab. で、モジュールをスクリプトとして実行
出来ます。パッケージ内のモジュールを実行する際に、相対インポートが正しく
動作していませんでした。

The fix for Python 2.6 adds a *note module.__package__: 2b9. attribute.
When this attribute is present, relative imports will be relative to the
value of this attribute instead of the *note __name__: 1350. attribute.

PEP 302-style importers can then set *note __package__: 2b9. as
necessary.  The *note runpy: ac. module that implements the *note -m:
5ab. switch now does this, so relative imports will now work correctly
in scripts running from inside a package.


File: python.info,  Node: PEP 370 ユーザごとの site-packages ディレクトリ,  Next: PEP 371 multiprocessing パッケージ,  Prev: PEP 366 メインモジュールからの明示的相対インポート,  Up: What's New in Python 2 6

1.16.5 PEP 370: ユーザごとの ‘site-packages’ ディレクトリ
---------------------------------------------------------

When you run Python, the module search path ‘sys.path’ usually includes
a directory whose path ends in ‘"site-packages"’.  This directory is
intended to hold locally installed packages available to all users using
a machine or a particular site installation.

Python 2.6 ではユーザ固有のサイトディレクトリのための決まりを導入しまし
た。ディレクトリはプラットフォームに依存して変わります。

   * Unix と Mac OS X: ‘~/.local/’

   * Windows: ‘%APPDATA%/Python’

このディレクトリ内にはバージョン固有のサブディレクトリが入ります。
Unix/Mac OS では ‘lib/python2.6/site-packages’ のように、Windows では
‘Python26/site-packages’ のように。

このデフォルトディレクトリが好きでないなら、この機能をサポートする全ての
Python バージョンが使う環境変数 *note PYTHONUSERBASE: 1352. にルートディ
レクトリを指定することで上書き出来ます。Windows ではアプリケーション固有
データの場所を環境変数 ‘APPDATA’ で変更出来ます。また、あなたの Python イ
ンストレーションについての ‘site.py’ ファイルを修正することでも出来ます
。

この機能は Python 起動時に *note -s: 1353. オプションを付けるか、環境変
数 *note PYTHONNOUSERSITE: 1354. をセットすることで完全に無効に出来ます
。

参考
....

PEP 370(1) - ユーザごとの ‘site-packages’ ディレクトリ

     PEP 著と実装 Christian Heimes.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0370/


File: python.info,  Node: PEP 371 multiprocessing パッケージ,  Next: PEP 3101 進化版文字列フォーマッティング,  Prev: PEP 370 ユーザごとの site-packages ディレクトリ,  Up: What's New in Python 2 6

1.16.6 PEP 371: ‘multiprocessing’ パッケージ
--------------------------------------------

新しい *note multiprocessing: 86. により、Python プログラムが新たなプロ
セスを作成して何か計算を実行させて結果を返させることが出来ます。親と子の
プロセスはキューとパイプを使って通信し、ロックとセマフォを使って同期し、
単純なデータの配列を共有出来ます。

*note multiprocessing: 86. モジュールは、 *note threading: d6. モジュー
ルがスレッドの代わりにプロセスを使ようになるだけのような、完全な模倣とな
るよう開始されました。その目標は Python 2.6 へ向かう道のりを経て捨て去ら
れはしましたが、モジュールの一般的なアプローチはそれでも似ています。基礎
的なクラスは ‘Process’ です。これには呼び出し可能オブジェクトと引数のコ
レクションを渡します。その ‘start()’ メソッドが渡された呼び出し可能オブ
ジェクトをサブプロセスで実行するので、 ‘is_alive()’ メソッドを呼び出せば
サブプロセスが実行中かを知ることが出来、 ‘join()’ メソッドでそのプロセス
が終了するのを待つことが出来ます。

ここに、サブプロセスが階乗を計算する例を示します。その計算をする関数はヘ
ンテコリンに書かれていて、入力が 4 の倍数だととっても時間がかかるように
仕組んであります。

     import time
     from multiprocessing import Process, Queue


     def factorial(queue, N):
         "Compute a factorial."
         # If N is a multiple of 4, this function will take much longer.
         if (N % 4) == 0:
             time.sleep(.05 * N/4)

         # Calculate the result
         fact = 1L
         for i in range(1, N+1):
             fact = fact * i

         # Put the result on the queue
         queue.put(fact)

     if __name__ == '__main__':
         queue = Queue()

         N = 5

         p = Process(target=factorial, args=(queue, N))
         p.start()
         p.join()

         result = queue.get()
         print 'Factorial', N, '=', result

*note Queue: 1356. が factorial の結果を通信して返すのに使われています。
*note Queue: 1356. オブジェクトはグローバル変数に格納されています。子プ
ロセスは、子プロセスが作成された時点のその変数の値を使うことになります;
*note Queue: 1356. なので、親子はそのオブジェクトを通信のために使うこと
が出来ます。(プロセス作成後に親がグローバル変数 queue を差し替えても、子
の値は左右されませんし、逆もしかりです。)

2 つのほかのクラス ‘Pool’ と ‘Manager’ はハイレベルインターフェイスです
。 ‘Pool’ では固定数のワーカープロセスを作ってワーカープロセスにリクエス
トを配ることが出来ます。 ‘apply()’ または ‘apply_async()’ メソッドで単体
のリクエストを追加出来、 *note map(): 82f. または ‘map_async()’ メソッド
でたくさんのリクエストを追加出来ます。以下のコードでは ‘Pool’ を使って 5
つのワーカープロセスにリクエストをばら撒き、結果のリストを回収します:

     from multiprocessing import Pool

     def factorial(N, dictionary):
         "Compute a factorial."
         ...
     p = Pool(5)
     result = p.map(factorial, range(1, 1000, 10))
     for v in result:
         print v

これは以下のような出力をします:

     1
     39916800
     51090942171709440000
     8222838654177922817725562880000000
     33452526613163807108170062053440751665152000000000
     ...

もう一方の方のハイレベルインターフェイス ‘Manager’ クラスは、Python デー
タ構造のマスターコピーを保持出来る、独立したひとつのサーバプロセスを作り
ます。ほかのプロセスたちは、これらデータ構造の読み書きと修正をプロキシオ
ブジェクトを使って行えます。続く例では、 *note dict(): 237. メソッドを呼
ぶことにより共有辞書を作ります; ワーカープロセスはその辞書へ挿入します。
(ロックは自動的には行われませんがこの例では問題ではありません。
‘Manager’ のメソッドには ‘Lock()’, ‘RLock()’, ‘Semaphore()’ メソッドも含
まれていて、共有ロックを作るのに使えます。)

     import time
     from multiprocessing import Pool, Manager

     def factorial(N, dictionary):
         "Compute a factorial."
         # Calculate the result
         fact = 1L
         for i in range(1, N+1):
             fact = fact * i

         # Store result in dictionary
         dictionary[N] = fact

     if __name__ == '__main__':
         p = Pool(5)
         mgr = Manager()
         d = mgr.dict()         # Create shared dictionary

         # Run tasks using the pool
         for N in range(1, 1000, 10):
             p.apply_async(factorial, (N, d))

         # Mark pool as closed -- no more tasks can be added.
         p.close()

         # Wait for tasks to exit
         p.join()

         # Output results
         for k, v in sorted(d.items()):
             print k, v

これはこんな出力をするでしょう:

     1 1
     11 39916800
     21 51090942171709440000
     31 8222838654177922817725562880000000
     41 33452526613163807108170062053440751665152000000000
     51 15511187532873822802242430164693032110632597200169861120000...

参考
....

*note multiprocessing: 86. モジュールについてのドキュメント。

PEP 371(1) - multiprocessing パッケージの追加

     PEP 著 Jesse Noller と Richard Oudkerk; 実装 Richard Oudkerk と
     Jesse Noller.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0371/


File: python.info,  Node: PEP 3101 進化版文字列フォーマッティング,  Next: PEP 3105 print を関数にする,  Prev: PEP 371 multiprocessing パッケージ,  Up: What's New in Python 2 6

'PEP 3101': 進化版文字列フォーマッティング

In Python 3.0, the ‘%’ operator is supplemented by a more powerful
string formatting method, *note format(): 5eb.  Support for the *note
str.format(): 5ed. method has been backported to Python 2.6.

In 2.6, both 8-bit and Unicode strings have a ‘.format()’ method that
treats the string as a template and takes the arguments to be formatted.
The formatting template uses curly brackets (‘{’, ‘}’) as special
characters:

     >>> # Substitute positional argument 0 into the string.
     >>> "User ID: {0}".format("root")
     'User ID: root'
     >>> # Use the named keyword arguments
     >>> "User ID: {uid}   Last seen: {last_login}".format(
     ...    uid="root",
     ...    last_login = "5 Mar 2008 07:20")
     'User ID: root   Last seen: 5 Mar 2008 07:20'

波括弧自身は二重に書くことでエスケープ出来ます:

     >>> "Empty dict: {{}}".format()
     "Empty dict: {}"

フィールド名は、位置引数に対応する整数による ‘{0}’, ‘{1}’, …、またはキー
ワード引数に対応する名前です。属性を読み出したり辞書のキーにアクセスする
ような合成フィールド名(compound field names)も与えることが出来ます:

     >>> import sys
     >>> print 'Platform: {0.platform}\nPython version: {0.version}'.format(sys)
     Platform: darwin
     Python version: 2.6a1+ (trunk:61261M, Mar  5 2008, 20:29:41)
     [GCC 4.0.1 (Apple Computer, Inc. build 5367)]'

     >>> import mimetypes
     >>> 'Content-type: {0[.mp4]}'.format(mimetypes.types_map)
     'Content-type: video/mp4'

‘[.mp4]’ のように辞書スタイルの記法を使う際は文字列の周りを引用符で囲む
必要はありません; ‘.mp4’ をキーに値のルックアップされます。数値で始まる
文字列は整数に変換されます。フォーマット文字列内でこれ以上複雑な表現は書
けません。

ここまでは、結果文字列に置き換えられるフィールドを指定する方法について見
てきました。フォーマッティングではさらに、コロンに続けて書式指定子を追加
することでコントロール可能です。例えば:

     >>> # Field 0: left justify, pad to 15 characters
     >>> # Field 1: right justify, pad to 6 characters
     >>> fmt = '{0:15} ${1:>6}'
     >>> fmt.format('Registration', 35)
     'Registration    $    35'
     >>> fmt.format('Tutorial', 50)
     'Tutorial        $    50'
     >>> fmt.format('Banquet', 125)
     'Banquet         $   125'

書式指定子として、ネストによる他フィールド参照が使えます:

     >>> fmt = '{0:{1}}'
     >>> width = 15
     >>> fmt.format('Invoice #1234', width)
     'Invoice #1234  '
     >>> width = 35
     >>> fmt.format('Invoice #1234', width)
     'Invoice #1234                      '

望みの幅内でのフィールドの整列を指定可能です:

文字                 効果
                     
----------------------------------------------------------------------
                     
< (デフォルト)       左寄せ
                     
                     
>                    右寄せ
                     
                     
^                    中央寄せ
                     
                     
=                    (数値型についてのみ) 符号のあとにパディング
                     

書式指定子には体裁のタイプも含めることが出来ます。値をどのようにフォーマ
ットするかです。たとえば浮動小数点数は普通の数値に、あるいは指数形式でフ
ォーマット出来ます:

     >>> '{0:g}'.format(3.75)
     '3.75'
     >>> '{0:e}'.format(3.75)
     '3.750000e+00'

たくさんの体裁のタイプを利用出来ます。2.6 ドキュメントの *note complete
list: 1358. を調べてみてください。以下はその一部です:

‘b’       2進数。出力される数値は2を基数とします。
          
          
‘c’       文字。数値を対応するユニコード文字に変換します。
          
          
‘d’       10進数。出力される数値は10を基数とします。
          
          
‘o’       8進数。出力される数値は8を基数とします。
          
          
‘x’       16進数。出力される数値は16を基数とします。 10進で9を超える数字には小文字が
          使われます。
          
          
‘e’       指数表現です。指数を示す 'e' を使った科学的記数法で表示します。
          
          
‘g’       汎用フォーマット。数値が大き過ぎない限りは固定小数点表現をしますが、大きい
          値では 'e' 指数表現に切り替えます。
          
          
‘n’       数値です。現在のロケールに合わせて、数値分割文字が挿入されることを除き、
          ‘'g'’ (浮動小数点数の場合) または 'd' (整数の場合) と同じです。
          
          
‘%’       パーセンテージです。数値は 100 倍され、固定小数点数フォーマット (‘'f'’) で
          パーセント記号付きで表示されます。
          

クラスと型は、自身がどのように書式化されるかをコントロールするために
‘__format__()’ メソッドを定義出来ます。単一の引数として書式指定子を受け
取ります:

     def __format__(self, format_spec):
         if isinstance(format_spec, unicode):
             return unicode(str(self))
         else:
             return str(self)

ビルトインの *note format(): 5eb. もあって、単一の値をフォーマット出来ま
す。これは型の ‘__format__()’ メソッドを与えられた指定子とともに呼び出し
ます:

     >>> format(75.6564, '.2f')
     '75.66'

参考
....

*note 書式指定文字列の文法: 1358.

     リファレンスドキュメント。

PEP 3101(1): 進化版文字列フォーマッティング

     PEP 著 Talin; 実装 Eric Smith。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3101/


File: python.info,  Node: PEP 3105 print を関数にする,  Next: PEP 3110 例外処理の変更,  Prev: PEP 3101 進化版文字列フォーマッティング,  Up: What's New in Python 2 6

1.16.8 PEP 3105: ‘print’ を関数にする
-------------------------------------

‘print’ 文は Python 3.0 では *note print(): f42. 関数になります。 *note
print(): f42. が関数になることで、 ‘def print(...)’ やなにかほかの場所か
らの新しい関数をインポートするなどの方法で置き換え可能になります。

Python 2.6 では ‘__future__’ インポートで 言語構文としての ‘print’ を取
り除き、関数形式のものを代わりに使えるように出来ます。たとえば:

     >>> from __future__ import print_function
     >>> print('# of entries', len(dictionary), file=sys.stderr)

この新しい関数のシグネチャは以下の通りです:

     def print(*args, sep=' ', end='\n', file=None)

パラメータは以下のとおりです:

   * 'args': 出力される値を指定する位置引数リスト。

   * 'sep': 引数リスト 'args' を出力するのに使われる区切り文字。

   * 'end': 引数リスト 'args' を全て出力したあとに出力するテキスト。

   * 'file': 出力が送られるファイルオブジェクト。

参考
....

PEP 3105(1) - print を関数にする

     Georg Brandl 著の PEP。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3105/


File: python.info,  Node: PEP 3110 例外処理の変更,  Next: PEP 3112 バイトリテラル,  Prev: PEP 3105 print を関数にする,  Up: What's New in Python 2 6

1.16.9 PEP 3110: 例外処理の変更
-------------------------------

Python プログラマが時折やらかしてしまう誤りの一つにこんなのがあります:

     try:
         ...
     except TypeError, ValueError:  # Wrong!
         ...

このコードの作者はきっと *note TypeError: 502. 例外と *note ValueError:
1e3. 例外の両方とっつかまえてやろうと思ったのでしょうが、このコードは実
際にはちょっと違ったことをします: *note TypeError: 502. を捕捉したらこれ
を ‘"ValueError"’ というローカル名の例外オブジェクトに束縛します…。
*note ValueError: 1e3. 例外は決して捕捉されません。正しくは、例外のタプ
ルで指定します:

     try:
         ...
     except (TypeError, ValueError):
         ...

こんなことが起こってしまうのは、ここではカンマの使用が曖昧だからです: そ
れ、解析木内で 2 つのノードを示すのかな、タプルな単一ノードかしら?

Python 3.0 はカンマからワード "as" に置き換えてこの曖昧さをなくします。
例外を捕捉して例外オブジェクトを ‘exc’ に記憶するには、こう書かなければ
なりません:

     try:
         ...
     except TypeError as exc:
         ...

Python 3.0 は "as" の使用のみをサポートするようになるので、最初の例は 2
つの異なる例外を捕捉するものとして翻訳されます。Python 2.6 ではカンマも
"as" もサポートするので、既存のコードはそのまま動作します。新たに 2.6 で
実行される Python コードを書くならば、 "as" の使用を勧めます。

参考
....

PEP 3110(1) - Python 3000 での例外の捕捉

     PEP 著と実装 Collin Winter.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3110/


File: python.info,  Node: PEP 3112 バイトリテラル,  Next: PEP 3116 新しい I/O ライブラリ,  Prev: PEP 3110 例外処理の変更,  Up: What's New in Python 2 6

1.16.10 PEP 3112: バイトリテラル
--------------------------------

Python 3.0 は Unicode を言語の基本文字列型として採用し、8 ビットリテラル
は異なった記法で指示します。それには ‘b'string'’ とするか、 *note bytes:
1a4. のコンストラクタを用います。前方互換のために、Python 2.6 は *note
str: 418. 型に対する別名として *note bytes: 1a4. を追加のうえで、 ‘b''’
記法もサポートします。

2.6 の *note str: 418. 型は 3.0 の *note bytes: 1a4. 型とは色んな意味で
違います; 一番顕著なのは、コンストラクタがまったく異なることです。3.0 で
の ‘bytes([65, 66, 67])’ は 3 つのバイトで ‘ABC’ を構築しますが、2.6 で
の ‘bytes([65, 66, 67])’ は引数のリストを *note str(): 418. で文字列化し
た 12 バイト文字列を返します。

2.6 での *note bytes: 1a4. の主な使いみちはオブジェクトの型のテストに
‘isinstance(x, bytes)’ とすることでしょう。またこれは、 2.x コードが文字
列として ASCII 文字と 8 ビットバイトのどちらを意図しているのか知ることが
出来ない 2to3 コンバータの助けになります; あなたは今や *note bytes: 1a4.
と *note str: 418. の区別を、あなたの意図を正確に表現するのに使えます。
そして結果のコードは Python 3.0 で正しいものに修正されるでしょう。

全ての文字列リテラルを Unicode 文字列としてしまう ‘__future__’ インポー
トもあります。これは Unicode 文字を含むのに ‘\u’ エスケープシーケンスを
使えることを意味します。

     from __future__ import unicode_literals

     s = ('\u751f\u3080\u304e\u3000\u751f\u3054'
          '\u3081\u3000\u751f\u305f\u307e\u3054')

     print len(s)               # 12 Unicode characters

At the C level, Python 3.0 will rename the existing 8-bit string type,
called ‘PyStringObject’ in Python 2.x, to *note PyBytesObject: 75d.
Python 2.6 uses ‘#define’ to support using the names *note
PyBytesObject(): 75d, *note PyBytes_Check(): 135c, *note
PyBytes_FromStringAndSize(): 135d, and all the other functions and
macros used with strings.

*note bytes: 1a4. 型のインスタンスは単に文字列と同じで *note immutable:
1272. です。 *note bytearray: 508. 型が、バイト列を *note mutable: 1273.
シーケンスとして格納するものとして新しく追加されました:

     >>> bytearray([65, 66, 67])
     bytearray(b'ABC')
     >>> b = bytearray(u'\u21ef\u3244', 'utf-8')
     >>> b
     bytearray(b'\xe2\x87\xaf\xe3\x89\x84')
     >>> b[0] = '\xe3'
     >>> b
     bytearray(b'\xe3\x87\xaf\xe3\x89\x84')
     >>> unicode(str(b), 'utf-8')
     u'\u31ef \u3244'

*note bytearray: 508. は ‘startswith()’/‘endswith()’, ‘find()’/‘rfind()’
のような文字列型のほとんどのメソッド、 ‘append()’, ‘pop()’, ‘reverse()’
のようなリストのいくつかのメソッドをサポートします。

     >>> b = bytearray('ABC')
     >>> b.append('d')
     >>> b.append(ord('e'))
     >>> b
     bytearray(b'ABCde')

対応する C API もあります。 *note PyByteArray_FromObject(): 135e, *note
PyByteArray_FromStringAndSize(): 135f. や色々その他関数です。

参考
....

PEP 3112(1) - Python 3000 でのバイトリテラル

     PEP 著 Jason Orendorff; 2.6 へのバックポート Christian Heimes.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3112/


File: python.info,  Node: PEP 3116 新しい I/O ライブラリ,  Next: PEP 3118 改訂版バッファプロトコル,  Prev: PEP 3112 バイトリテラル,  Up: What's New in Python 2 6

1.16.11 PEP 3116: 新しい I/O ライブラリ
---------------------------------------

Python ビルトインのファイルオブジェクトはたくさんのメソッドをサポートし
ていますが、ファイルライクなオブジェクトは必ずしもそのすべてをサポートす
る必要はありません。ファイルのまねごとをするオブジェクトは大抵 ‘read()’
と ‘write()’ をサポートしますが、 *note readline(): a8. はサポートしない
かもしれません、例えば。Python 3.0 は *note io: 73. モジュールに、階層化
された I/O ライブラリを導入しています。それは基礎的な読み書き操作からバ
ッファリング機能とテキスト処理を分離しています。

*note io: 73. モジュールによって提供される抽象基底クラスには 3 つのレベ
ルがあります:

   * ‘RawIOBase’ は剥き身の I/O 操作を定義します: ‘read()’,
     ‘readinto()’, ‘write()’, ‘seek()’, ‘tell()’, ‘truncate()’,
     ‘close()’ 。このクラスのほとんどのメソッドが多くの場合単一のシステ
     ムコールに対応するでしょう。 ‘readable()’, ‘writable()’,
     ‘seekable()’ メソッドも利用可能で、オブジェクトでどの操作が許される
     のかを知るのに使えます。

     Python 3.0 はこのクラスのファイルとソケットに対する具象実装を持って
     いますが、Python 2.6 はファイル、ソケットオブジェクトのこの方法での
     再構築はしていません。

   * ‘BufferedIOBase’ はデータをメモリにバッファすることでシステムコール
     使用回数を減らし、I/O 処理をより効率的に行うための抽象基底クラスで
     す。 ‘RawIOBase’ の全てのメソッドをサポートし、追加で基底の剥き身の
     オブジェクトを保持する ‘raw’ 属性を持ちます。

     5 つの具象クラスがこの ABC を実装しています。 ‘BufferedWriter’ と
     ‘BufferedReader’ はランダムアクセスのための ‘seek()’ を持ち、書き込
     み専用または読み出し専用の用途をサポートするオブジェクトのためのも
     のです。 ‘BufferedRandom’ オブジェクトはこれらと同じ前提のストリー
     ムでの読み書きアクセスをサポートし、 ‘BufferedRWPair’ は、TTY のよ
     うな、連続していないデータのストリームの上で読み書き操作両方を演じ
     るオブジェクトのためのものです。 ‘BytesIO’ クラスはインメモリのバッ
     ファ上での読み、書き、シークをサポートします。

   * ‘TextIOBase’: 文字列 (忘れないで、Python 3.0 では文字列は Unicode に
     なります) の読み書き関数を提供し、 *note universal newlines: d08. を
     サポートします。 ‘TextIOBase’ は *note readline(): a8. メソッドをサ
     ポートし、また、オブジェクトを渡るイテレーションをサポートします。

     2 つの具象実装があります。 ‘TextIOWrapper’ はバッファ化 I/O オブジ
     ェクトをラップし、テキスト I/O の全てのメソッドをサポートし、追加で
     元となるオブジェクトへのアクセスのための ‘buffer’ 属性を持ちます。
     ‘StringIO’ はディスクへの一切の書き込みをせずに単純にメモリ内に全て
     をバッファします。

     (In Python 2.6, *note io.StringIO: ef3. is implemented in pure
     Python, so it's pretty slow.  You should therefore stick with the
     existing ‘StringIO’ module or ‘cStringIO’ for now.  At some point
     Python 3.0's *note io: 73. module will be rewritten into C for
     speed, and perhaps the C implementation will be backported to the
     2.x releases.)

Python 2.6 では根底にある実装が *note io: 73. モジュールのクラスの上に組
み立てられるようには再構築されていません (訳注: Python HowTo の移植ガイ
ドにも触れられている通り、2.7 も同じです)。このモジュールは 3.0 への前方
互換のコードを書くのを容易にするために、また、開発者たちがバッファリング
I/O とテキスト I/O を自身で書く労力を省くために提供されています。

参考
....

PEP 3116(1) - 新しい I/O

     PEP 著: Daniel Stutzbach, Mike Verdone, Guido van Rossum.  実装:
     Guido van Rossum, Georg Brandl, Walter Doerwald, Jeremy Hylton,
     Martin von Loewis, Tony Löwis, ほか.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3116/


File: python.info,  Node: PEP 3118 改訂版バッファプロトコル,  Next: PEP 3119 抽象基底クラス,  Prev: PEP 3116 新しい I/O ライブラリ,  Up: What's New in Python 2 6

1.16.12 PEP 3118: 改訂版バッファプロトコル
------------------------------------------

バッファプロトコルは Python 型にその内部表現へのポインタをやりとりさせる
、C レベル API です。例えば、メモリマップドファイルは文字のバッファとし
て見ることが出来ます。そしてこれは *note re: a7. のようなほかのモジュー
ルが、それを文字列として扱って検索するようなことを許します。

バッファプロトコルの主なユーザは NumPy のような数値演算パッケージで、そ
れらは呼び出し元がより遅い API を経由することなく直接的に行列にデータを
書き込むことが出来るように、行列の内部表現を曝しています。この PEP は
NumPy 開発の経験を踏まえてバッファプロトコルを更新するもので、行列の形状
を表明したり、メモリ領域をロックしたりするような多数の新機能を追加します
。

最重要の新規 C API 関数は ‘PyObject_GetBuffer(PyObject *obj, Py_buffer
*view, int flags)’ で、これはオブジェクトを受け取って、フラグをセットし
、 ‘Py_buffer’ 構造体にオブジェクトのメモリ表現についての情報を埋めます
。オブジェクトはこの操作を、外部の呼び出し元がその内容を修正している間所
定のメモリをロックするのに使えます。ですので対応する操作
‘PyBuffer_Release(Py_buffer *view)’ があり、これで外部呼出し元が処理を終
えたことを表明します。

*note PyObject_GetBuffer(): 373. への 'flags' 引数は返されるメモリについ
ての制約条件を指定します。いくつかの例として:

   * *note PyBUF_WRITABLE: 1362. indicates that the memory must be
     writable.

   * ‘PyBUF_LOCK’ requests a read-only or exclusive lock on the memory.

   * *note PyBUF_C_CONTIGUOUS: 1363. and *note PyBUF_F_CONTIGUOUS: 1364.
     requests a C-contiguous (last dimension varies the fastest) or
     Fortran-contiguous (first dimension varies the fastest) array
     layout.

*note PyArg_ParseTuple(): 53d. のための 2 つの新しい書式化コード ‘s*’ と
‘z*’ は、パラメータとしてロックされたバッファオブジェクトを返します。

参考
....

PEP 3118(1) - 改訂版バッファプロトコル

     PEP 著: Travis Oliphant, Carl Banks; 実装: Travis Oliphant.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3118/


File: python.info,  Node: PEP 3119 抽象基底クラス,  Next: PEP 3127 整数リテラルのサポートと文法,  Prev: PEP 3118 改訂版バッファプロトコル,  Up: What's New in Python 2 6

1.16.13 PEP 3119: 抽象基底クラス
--------------------------------

ある種のオブジェクト指向言語、たとえば Java などは、クラスが持つメソッド
の集合やサポートするアクセスプロトコルを宣言するための「インターフェイス
」をサポートしています。抽象基底クラス (ABCs=Abstract Base Classes)は
Python でのこれと等価な機能です。ABC サポートは、 ‘ABCMeta’ と呼ばれるメ
タクラスを含む *note abc: 4. モジュール、ビルトイン *note isinstance():
40e. と *note issubclass(): 78c. のそのメタクラスについての特殊処理、そ
れに Python 開発者が広範囲にわたって使えると考えた基礎的な ABCs のコレク
ションから成ります。たぶん将来のバージョンの Python ではもっとたくさんの
ABCs が追加されると思います。

あなたがなにか特別なクラスを持っていて、辞書スタイルのアクセスをサポート
するのか知りたいとしましょう。「辞書スタイル」ってなんでしょうね、それに
しても。たぶんアイテムにアクセスするのに ‘obj[1]’ が使えるでしょう。それ
は ‘obj[2] = value’ のように値をセットするのも含まれるでしょうね?  ある
いは ‘keys()’, ‘values()’, ‘items()’ メソッドを持ちますかね?
‘iterkeys()’ みたいな列挙系はいかがでしょう?  *note copy(): 1e. と
‘update()’ は?  オブジェクトを巡回するのに *note iter(): 7a2. で出来ます
?

Python 2.6 の *note collections: 16. モジュールには、この手の区別を表現
出来るたくさんの ABCs が含まれています。 ‘Iterable’ は ‘__iter__()’ を定
義したクラスを示し、 ‘Container’ は ‘__contains__()’ メソッドを定義して
いて、なので ‘x in y’ 式をサポートしていることを意味します。アイテム取得
、アイテムセット、 ‘keys()’, ‘values()’, ‘items()’ という品揃えの基礎的
な辞書インターフェイスは ‘MutableMapping’ ABC で定義されています。

あなた自身のクラスを特定の ABC から派生して、ABC のインターフェイスをサ
ポートすることを示せます:

     import collections

     class Storage(collections.MutableMapping):
         ...

別の方法としては、望みの ABC から派生するのではなく、その ABC の
‘register()’ メソッドを呼び出して登録することでも出来ます:

     import collections

     class Storage:
         ...

     collections.MutableMapping.register(Storage)

あなたが書くクラスでは ABC から派生するのが、たぶん綺麗で良いと思います
。既存の型やクラスを記述出来る新しい ABC が書けた場合や、なにかサードパ
ーティのクラスが実装する ABC を宣言したい場合などには ‘register()’ メソ
ッドが有用です。例えば、 ‘PrintableType’ ABC を定義したのなら、今がその
とき、です:

     # Register Python's types
     PrintableType.register(int)
     PrintableType.register(float)
     PrintableType.register(str)

クラスは ABC が規定するセマンティクスに従うべきですが、Python はそれをチ
ェックは出来ません；その ABC の要求を理解してコードを適切に実装するのは
クラスの作者任せです。

オブジェクトが特定のインターフェイスをサポートするかどうかをチェックする
のには、今やこう書けます:

     def func(d):
         if not isinstance(d, collections.MutableMapping):
             raise ValueError("Mapping object expected, not %r" % d)

これからはたくさんのこのようなチェックをしなければならないのだ、この例の
ように、などとは思わないように。Python は至極ダックタイピングな流儀なの
であって明示的な型チェックは決してされませんし、コードは単純にオブジェク
トのメソッドを、それらメソッドがそこにあるはずで、なければ例外になるのを
信じて呼ぶだけです。ABC についてのチェックには分別を持ち、それが絶対的に
必要な場合にだけそうするようにしましょう。

あなた自身の ABCs を書くには、クラス定義内のメタクラスとして
‘abc.ABCMeta’ を使います:

     from abc import ABCMeta, abstractmethod

     class Drawable():
         __metaclass__ = ABCMeta

         @abstractmethod
         def draw(self, x, y, scale=1.0):
             pass

         def draw_doubled(self, x, y):
             self.draw(x, y, scale=2.0)


     class Square(Drawable):
         def draw(self, x, y, scale):
             ...

上の ‘Drawable’ ABC では、 ‘draw_doubled()’ メソッドがオブジェクトをその
2 倍のサイズで描画しますが、 ‘Drawable’ で示されたほかのメソッドのやり方
で実現されるのでしょう。この ABC を実装するクラスは ‘draw_doubled()’ の
それ自身の実装を提供する必要はないわけですが、実装しても良いです。一方
‘draw()’ の実装は必要です。その ABC が役に立つ汎用的な実装が提供出来てい
ないので。

‘draw()’ のような、実装が必須のメソッドに対して ‘@abstractmethod’ デコレ
ータを適用することが出来ます; Python はそのメソッドを実装しないクラスに
例外を喰らわせます。サブクラスにそのメソッドが欠けていたとしても、インス
タンスを実際に作ろうと試みてはじめて例外となることに注意しましょう:

     >>> class Circle(Drawable):
     ...     pass
     ...
     >>> c = Circle()
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: Can't instantiate abstract class Circle with abstract methods draw
     >>>

抽象データ属性を ‘@abstractproperty’ を使って宣言出来ます:

     from abc import abstractproperty
     ...

     @abstractproperty
     def readonly(self):
        return self._x

この場合サブクラスは ‘readonly()’ プロパティを定義することが必須です。

参考
....

PEP 3119(1) - 抽象基底クラスの導入

     PEP は Guido van Rossum と Talin によって著され、Guido van Rossum に
     より実装されています。Python 2.6 へのバックポートは Benjamin
     Aranguren と Alex Martelli により行われました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3119/


File: python.info,  Node: PEP 3127 整数リテラルのサポートと文法,  Next: PEP 3129 クラスデコレータ,  Prev: PEP 3119 抽象基底クラス,  Up: What's New in Python 2 6

1.16.14 PEP 3127: 整数リテラルのサポートと文法
----------------------------------------------

Python 3.0 は octal (基数 8: 8 進数) 整数リテラルの構文を変更し、先行す
るゼロの代わりに "0o" または "0O" (「ゼロオー」)としています。また、
binary (基数 2: 2 進数) 整数リテラルのサポートを追加し、これは "0b" また
は "0B" で指示します。

Python 2.6 は先行するゼロの形式での 8 進数サポートをやめませんが、 "0o"
と "0b" は追加サポートします:

     >>> 0o21, 2*8 + 1
     (17, 17)
     >>> 0b101111
     47

ビルトイン関数 *note oct(): 129c. はまだ先行ゼロ形式での表現を返します。
新しいビルトイン関数 *note bin(): 127a. は数値の 2 進数表現を返します:

     >>> oct(42)
     '052'
     >>> future_builtins.oct(42)
     '0o52'
     >>> bin(173)
     '0b10101101'

ビルトイン *note int(): 238, ‘long()’ が、基数 8 か 0 を要求された場合の
"0o" プレフィクス、基数 2 か 0 を要求された場合の "0b" プレフィクスをそ
れぞれ許容するようになりました(基数 'base' = 0 は文字列から基数を決める
べきであることを指示します):

     >>> int ('0o52', 0)
     42
     >>> int('1101', 2)
     13
     >>> int('0b1101', 2)
     13
     >>> int('0b1101', 0)
     13

参考
....

PEP 3127(1) - 整数リテラルのサポートと文法

     PEP 著 Patrick Maupin、2.6 へのバックポートは Eric Smith による。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3127/


File: python.info,  Node: PEP 3129 クラスデコレータ,  Next: PEP 3141 数値の型階層,  Prev: PEP 3127 整数リテラルのサポートと文法,  Up: What's New in Python 2 6

1.16.15 PEP 3129: クラスデコレータ
----------------------------------

デコレータが拡張されて関数だけでなクラスにも使えるようになりました。今や
このように書くのは合法です:

     @foo
     @bar
     class A:
       pass

これは次と等価です:

     class A:
       pass

     A = foo(bar(A))

参考
....

PEP 3129(1) - クラスデコレータ

     PEP 著 Collin Winter.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3129/


File: python.info,  Node: PEP 3141 数値の型階層,  Next: その他の言語変更<13>,  Prev: PEP 3129 クラスデコレータ,  Up: What's New in Python 2 6

1.16.16 PEP 3141: 数値の型階層
------------------------------

Python 3.0 では Scheme の numeric tower に触発された、いくつかの数値型の
ための抽象基底クラスを追加しています。これらのクラスは *note numbers:
8e. モジュール として 2.6 にバックポートされています。

一番てっぺんの汎用 ABC が ‘Number’ です。これには何の演算も含まれず、オ
ブジェクトがなんらか数値であることをチェックするためだけにあります。
‘isinstance(obj, Number)’ として使えます。

‘Complex’ は ‘Number’ のサブクラスです。複素数は基礎的な追加の演算の加算
、減算、積算、除算、累乗に耐えるとともに、実数部と虚数部の抽出と共役数の
取得が出来ます。Python のビルトインの complex 型は ‘Complex’ を実装して
います。

‘Real’ は ‘Complex’ から更に派生し、実数のみで動作する演算を追加していま
す: ‘floor()’, ‘trunc()’, 丸め, divmod, floor division, 比較、です。

‘Rational’ 数は ‘Real’ からの派生で、プロパティ ‘numerator’,
‘denominator’ を持ち、浮動小数点数への変換が出来ます。Python 2.6 は単純
な有理数クラス ‘Fraction’ を *note fractions: 53. モジュールに追加してい
ます。(‘Rational’ ではなく ‘Fraction’ なのは、 *note numbers.Rational:
1290. と名前が衝突するのを避けるためです。)

‘Integral’ 数は ‘Rational’ からの派生で、シフト演算 ‘<<’, ‘>>’ が出来て
、 ‘&’ や ‘|’ のようなビット演算で混ぜ合わせることができて、また、配列の
インデクスとスライスの境界として使えます。

Python 3.0 では、その PEP は少し既存のビルトイン *note round(): 12a8,
*note math.floor(): 1369, *note math.ceil(): 136a. を再定義していて、ま
た、Python 2.6 にバックポートされている新しい *note math.trunc(): 136b.
を追加しています。 *note math.trunc(): 136b. はゼロに向かう方向の丸めで
、引数とゼロの間で一番近い ‘Integral’ を返します。

参考
....

PEP 3141(1) - 数値の型階層

     PEP 著: Jeffrey Yasskin.

Guile マニュアルの Scheme's numerical tower(2) 。

Scheme's number datatypes(3) from the R5RS Scheme specification.

* Menu:

* fractions モジュール::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3141/

   (2) 
https://www.gnu.org/software/guile/manual/html_node/Numerical-Tower.html#Numerical-Tower

   (3) 
https://conservatory.scheme.org/schemers/Documents/Standards/R5RS/HTML/r5rs-Z-H-9.html#%_sec_6.2


File: python.info,  Node: fractions モジュール,  Up: PEP 3141 数値の型階層

1.16.16.1 ‘fractions’ モジュール
................................

数値型階層を埋めるべく、 *note fractions: 53. モジュールが有理数クラスを
提供しています。有理数は分子(numerator)と分母(denominator)で構成される分
数としてその値を格納し、浮動小数点数では近似しか出来ない ‘2/3’ のような
数を正確に表現出来ます。

‘Fraction’ のコンストラクタは 2 つの ‘Integral’ 値を取り、それらはそれぞ
れ結果の分数の分子と分母になります。:

     >>> from fractions import Fraction
     >>> a = Fraction(2, 3)
     >>> b = Fraction(2, 5)
     >>> float(a), float(b)
     (0.66666666666666663, 0.40000000000000002)
     >>> a+b
     Fraction(16, 15)
     >>> a/b
     Fraction(5, 3)

For converting floating-point numbers to rationals, the float type now
has an ‘as_integer_ratio()’ method that returns the numerator and
denominator for a fraction that evaluates to the same floating-point
value:

     >>> (2.5) .as_integer_ratio()
     (5, 2)
     >>> (3.1415) .as_integer_ratio()
     (7074029114692207L, 2251799813685248L)
     >>> (1./3) .as_integer_ratio()
     (6004799503160661L, 18014398509481984L)

1./3 のような浮動小数点数で近似にしかならない値は、近似して単純化された
りはしないことに注意してください; その分数は浮動小数点数に '正確に' 合う
ように試みられます。

*note fractions: 53. モジュールは、ずっと長い間 Python の
‘Demo/classes/’ ディレクトリにいた Sjoerd Mullender による実装に基いてい
ます。この実装が Jeffrey Yasskin によって大幅に更新されました。


File: python.info,  Node: その他の言語変更<13>,  Next: 新しいモジュールと改良されたモジュール<2>,  Prev: PEP 3141 数値の型階層,  Up: What's New in Python 2 6

1.16.17 その他の言語変更
------------------------

Python 言語コアに小さな変更がいくつか行われました:

   * ‘__main__.py’ を含んだディレクトリ名と zip アーカイブ名をインタプリ
     タに渡して直接実行出来るようになりました。そのディレクトリと zip ア
     ーカイブは自動的に sys.path エントリの先頭に追加されます。
     (Suggestion and initial patch by Andy Chu, subsequently revised by
     Phillip J. Eby and Nick Coghlan; bpo-1739468(1).)

   * *note hasattr(): 49e. 関数は ‘__getattr__()’ メソッドが例外を起こす
     と何か失敗したのだと仮定して、全て捕捉して無視して ‘False’ を返して
     いました。ですがそのロジックは *note KeyboardInterrupt: 99f. と
     *note SystemExit: d0e. まで捕まえるべきではなかったのです。Python
     2.6 では *note hasattr(): 49e. はもはやそれら例外に出会ってもそれを
     捨てません。 (Fixed by Benjamin Peterson; bpo-2196(2).)

   * ‘**’ 構文を使ってキーワード引数を許容する関数を呼び出すのに、もう
     Python 辞書を使う必要はありません; 任意のマッピングプロトコルをサポ
     ートするオブジェクトで今では動作します:

          >>> def f(**kw):
          ...    print sorted(kw)
          ...
          >>> ud=UserDict.UserDict()
          >>> ud['a'] = 1
          >>> ud['b'] = 'string'
          >>> f(**ud)
          ['a', 'b']

     (Contributed by Alexander Belopolsky; bpo-1686487(3).)

     同時に、 ‘*args’ 引数のあとでキーワード引数を与える関数呼び出しも今
     では合法です。:

          >>> def f(*args, **kw):
          ...     print args, kw
          ...
          >>> f(1,2,3, *(4,5,6), keyword=13)
          (1, 2, 3, 4, 5, 6) {'keyword': 13}

     以前はこれは構文エラーになっていました。 (Contributed by Amaury
     Forgeot d'Arc; bpo-3473(4).)

   * 新しいビルトイン ‘next(iterator, [default])’ は指定したイテレータよ
     り次のアイテムを返します。 'iterator' が使い果たされている場合、
     'default' 引数が与えられていれがこれを、そうでなければ *note
     StopIteration: bc8. 例外を起こします。 (Backported in bpo-2719(5).)

   * タプルがリストと同じく ‘index()’ と ‘count()’ メソッドを持つように
     なっています:

          >>> t = (0,1,2,3,4,0,1,2)
          >>> t.index(3)
          3
          >>> t.count(0)
          2

     (Contributed by Raymond Hettinger)

   * ビルトイン型が拡張スライス構文をサポートするために改善されています
     。色々な ‘(start, stop, step)’ 組み合わせを受け付けます。以前はこれ
     のサポートは限定的で、ものによっては動作しませんでした。
     (Implemented by Thomas Wouters.)

   * property に ‘getter’, ‘setter’, ‘deleter’ が追加されています。取得
     関数(getter)、設定関数(setter)、削除関数(deleter)を既存のプロパティ
     に追加するための便利なショートカットとして使えるデコレータです。こ
     れらはこのように使えます:

          class C(object):
              @property
              def x(self):
                  return self._x

              @x.setter
              def x(self, value):
                  self._x = value

              @x.deleter
              def x(self):
                  del self._x

          class D(C):
              @C.x.getter
              def x(self):
                  return self._x * 2

              @x.setter
              def x(self, value):
                  self._x = value / 2

   * ビルトインの set 型のいくつかのメソッドが複数イテラブルを受け付ける
     ようになっています: ‘intersection()’, ‘intersection_update()’,
     ‘union()’, ‘update()’, ‘difference()’, ‘difference_update()’ です。

          >>> s=set('1234567890')
          >>> s.intersection('abc123', 'cdf246')  # Intersection between all inputs
          set(['2'])
          >>> s.difference('246', '789')
          set(['1', '0', '3', '5'])

     (Contributed by Raymond Hettinger.)

   * たくさんの浮動小数点数機能が追加されました。 *note float(): 2ce. 関
     数は文字列 ‘nan’ を IEEE 754 非数 (Not A Number) 値に変換し、
     ‘+inf’ と ‘-inf’ は正あるいは負の無限大に変換します。これは IEEE
     754 セマンティクスのあらゆるプラットフォームで動作します。
     (Contributed by Christian Heimes; bpo-1635(6).)

     ほか *note math: 81. モジュールに ‘isinf()’ と ‘isnan()’ が追加され
     ています; 浮動小数点数が、前者は無限大ならば、後者は非数ならばそれ
     ぞれ真を返します。 (bpo-1640(7))

     浮動小数点数を 16 進表記文字列に変換する変換関数が追加されています
     (bpo-3008(8))。これら関数は 10 進と 2 進との間の変換で起こる丸め誤
     差を持ち込まずに浮動小数点数と文字列表現の相互変換をします。浮動小
     数点数は文字列表現を返す *note hex(): 129d. メソッドを持ち、また、
     ‘float.fromhex()’ メソッドが文字列から浮動小数点数に戻します:

          >>> a = 3.75
          >>> a.hex()
          '0x1.e000000000000p+1'
          >>> float.fromhex('0x1.e000000000000p+1')
          3.75
          >>> b=1./3
          >>> b.hex()
          '0x1.5555555555555p-2'

   * 数に関する繊細さ: 符号付ゼロ (-0 と +0) をサポートするシステムで 2
     つの浮動小数点数から複素数を作る際に、 *note complex(): 2cf. コンス
     トラクタがゼロの符号を維持するようになりました。 (Fixed by Mark T.
     Dickinson; bpo-1507(9).)

   * ‘__hash__()’ メソッドを親クラスから継承するクラスは、ハッシュ出来な
     いことを示すのに ‘__hash__ = None’ をセット出来ます。これにより
     ‘hash(obj)’ は *note TypeError: 502. を起こし、そのクラスは
     ‘Hashable’ ABC を実装していないことを示します。

     ‘__cmp__()’ か ‘__eq__()’ を定義するのにその比較にオブジェクトの身
     元ではなくその値を使ったならば、あなたはこれをすべきです。全てのオ
     ブジェクトはその値として ‘id(obj)’ を使うデフォルトのハッシュ化メソ
     ッドを持っています。親クラスから継承した ‘__hash__()’ を削除する整
     理された方法はありません。ですのでオーバライドとしての ‘None’ の代
     入が実装されました。 C API のレベルでは、拡張は ‘tp_hash’ に *note
     PyObject_HashNotImplemented(): 136e. をセット出来ます。 (Fixed by
     Nick Coghlan and Amaury Forgeot d'Arc; bpo-2235(10).)

   * *note GeneratorExit: 136f. 例外が *note Exception: 9a7. ではなく
     *note BaseException: 584. のサブクラスになっています。 ‘except
     Exception:’ をする例外ハンドラが意図せず *note GeneratorExit: 136f.
     捕捉してしまうことがなくなります。 (Contributed by Chad Austin;
     bpo-1537(11).)

   * ジェネレータオブジェクトが、そのジェネレータを返すオリジナルのコー
     ドオブジェクトを参照する ‘gi_code’ 属性を持つようになりました。
     (Contributed by Collin Winter; bpo-1473257(12).)

   * ビルトイン関数 *note compile(): 177. が位置引数だけでなくキーワード
     引数も受け付けるようになりました。 (Contributed by Thomas Wouters;
     bpo-1444529(13).)

   * *note complex(): 2cf. コンストラクタが括弧で囲まれた複素数表現文字
     列を受け付けるようになっています。 ‘complex(repr(cplx))’ で元に戻せ
     るということです。例えば ‘complex('(3+4j)')’ は今では値 ‘(3+4j)’ を
     返します。 (bpo-1491866(14))

   * 文字列の ‘translate()’ メソッドが変形テーブルパラメータとして
     ‘None’ を受け付けるようになりました。そのまま同じものを返す変形とし
     て扱われます。これにより文字を削除する操作を実行するのが簡単になり
     ます。 (Contributed by Bengt Richter and implemented by Raymond
     Hettinger; bpo-1193128(15).)

   * ビルトインの *note dir(): 5fe. 関数が、受け取ったオブジェクトの
     ‘__dir__()’ メソッドをチェックするようになりました。このメソッドは
     そのオブジェクトで妥当な属性名を含む文字列のリストを返さなければな
     りません。これにより *note dir(): 5fe. が生成する値を制御出来ます。
     ‘__getattr__()’ や ‘__getattribute__()’ メソッドを使うオブジェクト
     はこれを使うことで、約束するつもりの擬似属性を公表出来ます。
     (bpo-1591665(16))

   * Instance method objects have new attributes for the object and
     function comprising the method; the new synonym for ‘im_self’ is
     *note __self__: 1370, and ‘im_func’ is also available as *note
     __func__: 12ca.  The old names are still supported in Python 2.6,
     but are gone in 3.0.

   * 目立たない変更: *note locals(): 127. 関数を *note class: 12a5. ステ
     ートメント内で使う際、結果の辞書はもはや自由変数を返しません。(この
     場合、自由変数は ‘class’ ステートメント内で参照される変数で、クラス
     の属性ではありません。)

* Menu:

* 最適化: 最適化<12>.
* インタプリタの変更: インタプリタの変更<2>.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1739468

   (2) https://bugs.python.org/issue?@action=redirect&bpo=2196

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1686487

   (4) https://bugs.python.org/issue?@action=redirect&bpo=3473

   (5) https://bugs.python.org/issue?@action=redirect&bpo=2719

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1635

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1640

   (8) https://bugs.python.org/issue?@action=redirect&bpo=3008

   (9) https://bugs.python.org/issue?@action=redirect&bpo=1507

   (10) https://bugs.python.org/issue?@action=redirect&bpo=2235

   (11) https://bugs.python.org/issue?@action=redirect&bpo=1537

   (12) https://bugs.python.org/issue?@action=redirect&bpo=1473257

   (13) https://bugs.python.org/issue?@action=redirect&bpo=1444529

   (14) https://bugs.python.org/issue?@action=redirect&bpo=1491866

   (15) https://bugs.python.org/issue?@action=redirect&bpo=1193128

   (16) https://bugs.python.org/issue?@action=redirect&bpo=1591665


File: python.info,  Node: 最適化<12>,  Next: インタプリタの変更<2>,  Up: その他の言語変更<13>

1.16.17.1 最適化
................

   * *note warnings: fa. モジュールが C で書き直されました。これにより警
     告をパーサから発行出来、また、インタプリタの起動が高速化しています
     。 (Contributed by Neal Norwitz and Brett Cannon; bpo-1631171(1).)

   * 型オブジェクトがメソッドのキャッシュを持つようになっています。これ
     は個別のクラスについての正しいメソッド実装を見つけるのに必要な仕事
     を減らします。いったんキャッシュされれば、インタプリタは呼び出さな
     ければならない正しいメソッドを知るために基底クラス群を横断しなくて
     もよくなります。基底クラスやクラス自身が修正されれば、Python の動的
     な振る舞いの面においても正しくあり続けなければならないので、キャッ
     シュはクリアされます。 (Original optimization implemented by Armin
     Rigo, updated for Python 2.6 by Kevin Jacobs; bpo-1700288(2).)

     デフォルトではこの変更は、Python コアに含まれる型のみに適用されます
     。拡張モジュールは必ずしもこのキャッシュに互換ではなく、拡張モジュ
     ールはメソッドキャッシュを有効にするために、モジュールの ‘tp_flags’
     フィールドに明示的に ‘Py_TPFLAGS_HAVE_VERSION_TAG’ を追加しなければ
     なりません。(このメソッドキャッシュに対して互換であるためには、拡張
     モジュールのコードは、それが実装するどんな型についても ‘tp_dict’ メ
     ンバに直接アクセスしたり修正したりしてはなりません。ほとんどのモジ
     ュールはこれをしていませんが、Python インタプリタがそれを検知するこ
     とは出来ません。 bpo-1878(3) にいくらかの議論がありますので参照して
     ください。)

   * キーワード引数を使う関数呼び出しが、素早くポインタで比較することで
     顕著に高速化しています。これは常に文字列丸ごとを比較する時間を省き
     ます。 (Contributed by Raymond Hettinger, after an initial
     implementation by Antoine Pitrou; bpo-1819(4).)

   * *note struct: c0. モジュールの全ての関数が C で書き換えられました。
     「Need For Speed スプリント」での作業の成果です。 (Contributed by
     Raymond Hettinger.)

   * いくつかの標準ビルトイン型が、その型オブジェクトにビットをセットす
     るようになりました。これは、オブジェクトがそれら型のサブクラスの一
     つであるかどうかのチェックするのを高速化します。 (Contributed by
     Neal Norwitz.)

   * Unicode 文字列が、空白文字と改行を検出するためのコードにより高速な
     実装を使うようになりました; ‘split()’ メソッドでおよそ 25% の速度向
     上、 ‘splitlines()’ メソッドでは 35% です。(Contributed by Antoine
     Pitrou.)  Unicode 文字列データのために pymalloc を使うことでメモリ
     使用が減りました。

   * The ‘with’ statement now stores the *note __exit__(): 12ce. method
     on the stack, producing a small speedup.  (Implemented by Jeffrey
     Yasskin.)

   * メモリ使用を減らすために、一番作られたオブジェクトをガーベージコレ
     クトする際に、ガーベージコレクタが内部のフリーリストをクリアするよ
     うになりました。これはオペレーティングシステムにすぐに返されます。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1631171

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1700288

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1878

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1819


File: python.info,  Node: インタプリタの変更<2>,  Prev: 最適化<12>,  Up: その他の言語変更<13>

1.16.17.2 インタプリタの変更
............................

Python のほかの実装で使うために、2 つのコマンドラインオプションが予約さ
れました。 *note -J: 1374. スイッチは Jython 固有のオプションのために予
約されました。前提となる JVM に渡すスイッチなどに使います。 *note -X:
15c. スイッチは個別の Python 実装、たとえば CPython、Jython や
IronPython のために予約されました。Python 2.6 でどちらかのオプションが使
われると、インタプリタはそのオプションは現在使われていないことを報告しま
す。

Python インタプリタに *note -B: 1375. スイッチを渡すか、インタプリタ実行
前に環境変数 *note PYTHONDONTWRITEBYTECODE: 1376. をセットするかのどちら
かで、 ‘.pyc’ や ‘.pyo’ が作られないようにすることが出来るようになりまし
た。この設定は Python プログラムから ‘sys.dont_write_bytecode’ 変数とし
て利用可能で、Python コードはこの変数を変更してインタプリタの振る舞いを
変えることが出来ます。 (Contributed by Neal Norwitz and Georg Brandl.)

標準入力、標準出力、標準エラー出力に使うエンコーディングを、インタプリタ
起動前に環境変数 *note PYTHONIOENCODING: fd5. を設定することで指定出来る
ようになりました。値は ‘<encoding>’ または ‘<encoding>:<errorhandler>’ 形
式の文字列でなければなりません。 'encoding' 部分はエンコーディングの名前
で、例えば ‘utf-8’ や ‘latin-1’ です; 省略可能な 'errorhandler' 部分はエ
ンコーディングによって処理出来ない文字に対して何をするのかを指定するもの
で、 "error", "ignore", "replace" のどれかです。 (Contributed by Martin
von Löwis.)


File: python.info,  Node: 新しいモジュールと改良されたモジュール<2>,  Next: 非推奨と削除,  Prev: その他の言語変更<13>,  Up: What's New in Python 2 6

1.16.18 新しいモジュールと改良されたモジュール
----------------------------------------------

全てのリリースに置いて、 Python の標準ライブラリはたくさんの改良とバグ修
正がされてきました。ここでは一部の注目に値する変更を、モジュール名で辞書
順ソートしてリストアップしています。もっと完全な変更リストが見たければ、
ソースツリー内の ‘Misc/NEWS’ ファイルか、全ての完全な詳細が入っている
Subversion のログを参照してください。

   * The ‘asyncore’ and ‘asynchat’ modules are being actively maintained
     again, and a number of patches and bugfixes were applied.
     (Maintained by Josiah Carlson; see bpo-1736190(1) for one patch.)

   * ‘bsddb’ モジュールは新しいメンテナ Jesús Cea Avión を得て、パッケー
     ジは今ではスタンドアロンのパッケージとして入手可能です。パッケージ
     のウェブページは www.jcea.es/programacion/pybsddb.htm(2) です。この
     モジュールは Python 3.0 では標準ライブラリからは削除される予定です
     。というのも、これの更新ペースは Python のそれよりも遥かに頻繁だか
     らです。

     ‘bsddb.dbshelve’ モジュールは pickle 化で、プロトコル 1 に制限する
     のではなく利用出来る一番高いプロトコルバージョンを使うようになりま
     した。(Contributed by W. Barnes.)

   * The ‘cgi’ module will now read variables from the query string of
     an HTTP POST request.  This makes it possible to use form actions
     with URLs that include query strings such as
     "/cgi-bin/add.py?category=1".  (Contributed by Alexandre Fiori and
     Nubis; bpo-1817(3).)

     The ‘parse_qs()’ and ‘parse_qsl()’ functions have been relocated
     from the ‘cgi’ module to the *note urlparse: f3. module.  The
     versions still available in the ‘cgi’ module will trigger *note
     PendingDeprecationWarning: 895. messages in 2.6 (bpo-600362(4)).

   * *note cmath: 11. モジュールに大掛かりな改訂が行われました。Mark
     Dickinson と Christian Heimes による貢献です。5 つの新しい関数が追
     加されました:

        * ‘polar()’ は複素数を極形式 (polar form) に変換し、複素数の絶対
          値 (modulus) と偏角 (argument) を返します。

        * ‘rect()’ はその逆で、絶対値と偏角から対応する複素数に戻します
          。

        * ‘phase()’ は複素数の偏角 (angle とも呼ばれています) を返します
          。

        * ‘isnan()’ はその引数の実数部か虚数部のどちらかが NaN であれば
          真を返します。

        * ‘isinf()’ はその引数の実数部か虚数部のどちらかが無限大であれば
          真を返します。

     その改訂では、 *note cmath: 11. モジュールの数値的安定性も改善され
     ました。全ての関数で、結果の実数部、虚数部は最小精度単位で少しの範
     囲内で、可能な限り正確です。詳細は bpo-1381(5) を見てください。
     ‘asinh()’, ‘atanh()’:, ‘atan()’ に対する分岐截線 (branch cut) も修
     正されています。(-- 訳注: units of least precision に対する枯れた訳
     語はないようなので最小精度単位としていますが仮数部の最下位ビットの
     ことです。ので、within a few ulps は下位数ビットという意味。分岐截
     線 (branch cut) は一般的な訳語かどうかはわかりませんが、wikipedia か
     ら採りました。--)

     そのモジュールのテストは大変拡大しました; およそ 2000 の新たなテス
     トケースが数学関数群を鍛え上げます。

     IEEE 754 プラットフォームでは *note cmath: 11. モジュールは、IEEE
     754 の特殊値と浮動小数点例外を、C99 標準の付録 'G' での一貫性のある
     方法で処理するようになりました。

   * A new data type in the *note collections: 16. module:
     ‘namedtuple(typename, fieldnames)’ is a factory function that
     creates subclasses of the standard tuple whose fields are
     accessible by name as well as index.  For example:

          >>> var_type = collections.namedtuple('variable',
          ...             'id name type size')
          >>> # Names are separated by spaces or commas.
          >>> # 'id, name, type, size' would also work.
          >>> var_type._fields
          ('id', 'name', 'type', 'size')

          >>> var = var_type(1, 'frequency', 'int', 4)
          >>> print var[0], var.id    # Equivalent
          1 1
          >>> print var[2], var.type  # Equivalent
          int int
          >>> var._asdict()
          {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'}
          >>> v2 = var._replace(name='amplitude')
          >>> v2
          variable(id=1, name='amplitude', type='int', size=4)

     Several places in the standard library that returned tuples have
     been modified to return ‘namedtuple()’ instances.  For example, the
     ‘Decimal.as_tuple()’ method now returns a named tuple with ‘sign’,
     ‘digits’, and ‘exponent’ fields.

     (Contributed by Raymond Hettinger.)

   * *note collections: 16. モジュールのもう一つの変更は、 ‘deque’ 型が
     省略可能な 'maxlen' パラメータをサポートするようになったことです; 与
     えられると、 deque のサイズが要素数 'maxlen' を超えないように制限さ
     れます。お腹いっぱいの deque にさらに要素を追加すると、古いものから
     捨てられます。

          >>> from collections import deque
          >>> dq=deque(maxlen=3)
          >>> dq
          deque([], maxlen=3)
          >>> dq.append(1); dq.append(2); dq.append(3)
          >>> dq
          deque([1, 2, 3], maxlen=3)
          >>> dq.append(4)
          >>> dq
          deque([2, 3, 4], maxlen=3)

     (Contributed by Raymond Hettinger.)

   * The *note Cookie: 67. module's *note Morsel: bd2. objects now
     support an *note httponly: 1378. attribute.  In some browsers.
     cookies with this attribute set cannot be accessed or manipulated
     by JavaScript code.  (Contributed by Arvin Schnell;
     bpo-1638033(6).)

   * *note curses: 23. モジュールの新しい window メソッド ‘chgat()’ は、
     一行での指定数ぶん文字の表示属性を変更します。 (Contributed by
     Fabian Kreutz.)

          # Boldface text starting at y=0,x=21
          # and affecting the rest of the line.
          stdscr.chgat(0, 21, curses.A_BOLD)

     *note curses.textpad: 26. モジュールの ‘Textbox’ クラスが上書きモー
     ドのほかに挿入モード編集をサポートするようになりました。挿入モード
     は ‘Textbox’ インスタンス構築時に 'insert_mode' パラメータを真にす
     ることで有効になります。

   * *note datetime: 28. モジュールの ‘strftime()’ メソッドが ‘%f’ 書式
     化コードをサポートするようになりました。これはオブジェクトのマイク
     ロ秒をミリ秒としてゼロ埋めで 6 桁で展開します。 (--訳注: 言葉だけだ
     とどうしても伝わりにくいですが、フィールドとしてミリ秒を持たずにマ
     イクロ秒を持っている datetime で「秒.ミリ秒」という表記をするのにマ
     イクロ秒精度まで表示するのが目的です。ですので 654 ミリ秒が「
     654000」と書式化されますし、32 ミリ秒は「032000」です。--)
     (Contributed by Skip Montanaro; bpo-1158(7).)

   * The *note decimal: 2e. module was updated to version 1.66 of the
     General Decimal Specification(8).  New features include some
     methods for some basic mathematical functions such as ‘exp()’ and
     ‘log10()’:

          >>> Decimal(1).exp()
          Decimal("2.718281828459045235360287471")
          >>> Decimal("2.7182818").ln()
          Decimal("0.9999999895305022877376682436")
          >>> Decimal(1000).log10()
          Decimal("3")

     ‘Decimal’ クラスの ‘as_tuple()’ メソッドが ‘sign’, ‘digits’,
     ‘exponent’ フィールドを持った名前付きタプルを返すようになりました。

     (Implemented by Facundo Batista and Mark Dickinson.  Named tuple
     support added by Raymond Hettinger.)

   * *note difflib: 2f. モジュールの ‘SequenceMatcher’ クラスが、マッチ
     を ‘a’, ‘b’, ‘size’ 属性を持つ名前付きタプルで返すようになりました
     。 (Contributed by Raymond Hettinger.)

   * *note ftplib.FTP: 8c8. クラスのコンストラクタと ‘connect()’ メソッ
     ドに省略可能 ‘timeout’ パラメータが追加されました。タイムアウトを秒
     で指定します。(Added by Facundo Batista.)  また、 ‘FTP’ クラスの
     ‘storbinary()’ と ‘storlines()’ メソッドが 'callback' パラメータを
     新たに受け取ります。これはデータが送信されたあとでデータの各ブロッ
     クごとに呼び出されます。 (Contributed by Phil Schwartz;
     bpo-1221598(9).)

   * ビルトイン関数の ‘reduce()’ が *note functools: 55. モジュールでも
     利用可能です。Python 3.0 ではビルトイン関数は削除されて *note
     functools: 55. のものだけが使えます; 現在のところ 2.x シリーズでビ
     ルトイン版を削除する計画はありません。 (Patched by Christian
     Heimes; bpo-1739906(10).)  (--訳注: 2.7 でも削除されていません。使
     用を検出するには ‘-3’ オプションなどで警告をチェックしてください。
     --)

   * 可能な場合には、 *note getpass: 58. モジュールはプロンプトメッセー
     ジ出力とパスワードの読み取りに ‘/dev/tty’ を使うようになりました。
     利用出来ない場合は標準エラー出力と標準入力が使われます。端末に入力
     パスワードがエコーされるかもしれない場合、プロンプト表示の前に警告
     が出力されます。 (Contributed by Gregory P. Smith.)

   * *note glob.glob(): 27f. 関数が、Unicode パスが使われるかディレクト
     リ内に Unicode ファイル名がマッチすると Unicode ファイル名を返すよ
     うになりました。 (bpo-1001604(11))

   * *note heapq: 5f. モジュールの新しい関数 ‘merge(iter1, iter2, ...)’
     は、任意の数のソートされたデータを返すイテラブルを取り、全てのイテ
     ラブルの内容をソートされた順に返す新しいジェネレータを返します (--訳
     注: 誤解を招く表現なので補足しておきますが、入力のイテレータはソー
     ト済みであることを「仮定」し、出力のジェネレータは「入力が主張して
     いる」順序に従うだけです。入力がソートされていなくても並べ替えられ
     るわけではありません。リファレンスにはここはきちんと書かれています
     。--)。例えば:

          >>> list(heapq.merge([1, 3, 5, 9], [2, 8, 16]))
          [1, 2, 3, 5, 8, 9, 16]

     もう一つの新たな関数 ‘heappushpop(heap, item)’ は、 'item' を
     'heap' に push した後、pop を行って 'heap' から最初の要素を返します
     。この一続きの動作を ‘heappush()’ に引き続いて ‘heappop()’ を別々に
     呼び出すよりも効率的に実行します。

     *note heapq: 5f. は以前使っていた「以下(‘<=’)」比較ではなく「より小
     さい(‘<’)」比較だけを使って実装されています。これにより *note
     heapq: 5f. に格納する型の要件が *note list.sort(): b9d. メソッドに
     合致します。 (Contributed by Raymond Hettinger.)

   * An optional ‘timeout’ parameter, specifying a timeout measured in
     seconds, was added to the *note httplib.HTTPConnection: b0e. and
     *note HTTPSConnection: b0f. class constructors.  (Added by Facundo
     Batista.)

   * ‘getmoduleinfo()’ や ‘getargs()’ のようなほとんどの *note inspect:
     72. モジュール関数が、名前付きタプルを返すようになりました。タプル
     のように振る舞うだけでなく、属性でアクセスすることも出来ます。
     (Contributed by Raymond Hettinger.)

     モジュールには ‘isgenerator()’, ‘isgeneratorfunction()’,
     ‘isabstract()’ を含むいくつかの新しい関数が追加されています。

   * *note itertools: 75. モジュールにいくつかの関数が追加されています。

     ‘izip_longest(iter1, iter2, ...[, fillvalue])’ はそれぞれの要素群か
     らタプルを生成します; イテラブルの要素数がほかのものより短ければ欠
     落値として 'fillvalue' が埋められます。例えば:

          >>> tuple(itertools.izip_longest([1,2,3], [1,2,3,4,5]))
          ((1, 1), (2, 2), (3, 3), (None, 4), (None, 5))

     ‘product(iter1, iter2, ..., [repeat=N])’ は与えたイテラブルの直積
     (Cartesian product)、つまりそれぞれのイテラブルから返るその要素たち
     の全てのありうる組み合わせを含むタプルの集合を返します。:

          >>> list(itertools.product([1,2,3], [4,5,6]))
          [(1, 4), (1, 5), (1, 6),
           (2, 4), (2, 5), (2, 6),
           (3, 4), (3, 5), (3, 6)]

     省略可能 'repeat' キーワード引数が与えられると、イテラブルが一つで
     あればこれが 'N' 個、複数あればそのセットが 'N' 回与えられたとみな
     します。単一のイテラブルに対しては 'N' 要素タプルのリストで返ります
     :

          >>> list(itertools.product([1,2], repeat=3))
          [(1, 1, 1), (1, 1, 2), (1, 2, 1), (1, 2, 2),
           (2, 1, 1), (2, 1, 2), (2, 2, 1), (2, 2, 2)]

     2 つのイテラブルであれば '2N' 要素タプルのリストで返ります:

          >>> list(itertools.product([1,2], [3,4], repeat=2))
          [(1, 3, 1, 3), (1, 3, 1, 4), (1, 3, 2, 3), (1, 3, 2, 4),
           (1, 4, 1, 3), (1, 4, 1, 4), (1, 4, 2, 3), (1, 4, 2, 4),
           (2, 3, 1, 3), (2, 3, 1, 4), (2, 3, 2, 3), (2, 3, 2, 4),
           (2, 4, 1, 3), (2, 4, 1, 4), (2, 4, 2, 3), (2, 4, 2, 4)]

     ‘combinations(iterable, r)’ は、入力 'iterable' の要素からなる長さ
     'r' の部分列を返します (--訳注: 数学の初等組み合わせ論の「組合せ
     (combination)」 --):

          >>> list(itertools.combinations('123', 2))
          [('1', '2'), ('1', '3'), ('2', '3')]
          >>> list(itertools.combinations('123', 3))
          [('1', '2', '3')]
          >>> list(itertools.combinations('1234', 3))
          [('1', '2', '3'), ('1', '2', '4'),
           ('1', '3', '4'), ('2', '3', '4')]

     ‘permutations(iter[, r])’ は入力 'iterable' の長さ 'r' の順列を返し
     ます。 'r' が指定されなければ、イテラブルが生成する全要素数がデフォ
     ルトで使われます (--訳注: 数学の初等組み合わせ論の「順列 (sequence
     without repetition)」または群論や組合せ論の「置換 (permutation)」。
     リファレンスでは訳出で置換も順列も両方出てきていますが、高校教育で
     習う用語で「順列」が伝わりやすいのでここでは「順列」としています。
     --):

          >>> list(itertools.permutations([1,2,3,4], 2))
          [(1, 2), (1, 3), (1, 4),
           (2, 1), (2, 3), (2, 4),
           (3, 1), (3, 2), (3, 4),
           (4, 1), (4, 2), (4, 3)]

     ‘itertools.chain(*iterables)’ は *note itertools: 75. に元々いたも
     のですが、新しい構築方法が出来ました。Python 2.6 では、
     ‘itertools.chain.from_iterable(iterable)’ でほかのイテラブルを返す
     単一のイテラブルを取り、 ‘chain()’ は、最初のイテラブルからの全要素
     、次のイテラブルからの全要素、…、のように返します:

          >>> list(itertools.chain.from_iterable([[1,2,3], [4,5,6]]))
          [1, 2, 3, 4, 5, 6]

     (All contributed by Raymond Hettinger.)

   * *note logging: 7b. モジュールの ‘FileHandler’ クラスとそのサブクラ
     スの ‘WatchedFileHandler’, ‘RotatingFileHandler’,
     ‘TimedRotatingFileHandler’ がそのコンストラクタで省略可能 'delay' パ
     ラメータを受け取るようになりました。 'delay' が真の場合、ログファイ
     ルのオープンは最初の ‘emit()’ が呼び出されるまで延期されます。
     (Contributed by Vinay Sajip.)

     ‘TimedRotatingFileHandler’ ではコンストラクタに 'utc' パラメータも
     取るようになっています。これが真の場合、 ‘when='midnight'’ などの切
     り替え時刻判定とその生成ファイル名に UTC が使われます。

   * いくつかの新しい関数が *note math: 81. モジュールに追加されました:

        * *note isinf(): 1379. と *note isnan(): 137a. は与えられた浮動
          小数点数が、順に、(正または負の) 無限大であるかどうか、非数
          (NaN=Not a Number) であるかどうかを返します。

        * *note copysign(): 137b. は IEEE 754 数の符号ビットをコピーしま
          す。 'x' の絶対値と 'y' の符号ビットを組み合わせたものを返しま
          す。例えば ‘math.copysign(1, -0.0)’ は -1.0 を返します。
          (Contributed by Christian Heimes.)

        * *note factorial(): 915. は階乗を計算します。 (Contributed by
          Raymond Hettinger; bpo-2138(12).)

        * *note fsum(): 137c. はイテラブルからの数列を、部分和の計算を通
          じて精度の損失を避けながら積み上げた合計の計算をします。
          (Contributed by Jean Brouwers, Raymond Hettinger, and Mark
          Dickinson; bpo-2819(13).)

        * *note acosh(): 137d, *note asinh(): 137e, *note atanh(): 137f.
          は逆双曲線関数を計算します。

        * *note log1p(): 1380. は '1+x' の自然対数 (底 'e' の対数) を返
          します。

        * ‘trunc()’ はゼロに向かう方向に丸めを行い、与えられた引数とゼロ
          に最も近い ‘Integral’ を返します。これは *note PEP 3141;
          数値の型階層: 128f. のバックポートの一部として追加されました。

   * *note math: 81. モジュールは、特に浮動小数点例外と IEEE 754 の特殊
     値の処理において、プラットフォーム間に渡る振る舞いの一貫性をさらに
     高めるように改善されました。

     可能な場合にはいつでもこのモジュールは 754 の特殊値について、C99 標
     準の勧告に従います。例えば、 ‘sqrt(-1.)’ は今ではほとんど全てのプラ
     ットフォームで *note ValueError: 1e3. となるはずで、
     ‘sqrt(float('NaN'))’ は全ての IEEE 754 プラットフォームで NaN を返
     すはずです。C99 標準の付録 'F' で 'divide-by-zero' または 'invalid'
     を伝えることを勧告している箇所では Python は *note ValueError: 1e3.
     を投げます。C99 標準の付録 'F' で 'overflow' を伝えることを勧告して
     いる箇所では Python は *note OverflowError: 84e. を投げます。 (See
     bpo-711019(14) and bpo-1640(15).)

     (Contributed by Christian Heimes and Mark Dickinson.)

   * *note mmap: 1ec. オブジェクトに ‘rfind()’ メソッドが追加されていま
     す。部分文字列の検索を、末尾から後ろ向きに検索します。 ‘find()’ に
     は新しい引数 'end' パラメータが追加されていて、検索対象の終了位置を
     指定することが出来ます。 (Contributed by John Lenton.)

   * *note operator: 8f. モジュールに ‘methodcaller()’ 関数が追加されて
     います。名前と省略可能な引数を与えると、渡したその任意の引数でその
     名前の関数を呼び出す呼び出し可能オブジェクトを返します。例えば:

          >>> # Equivalent to lambda s: s.replace('old', 'new')
          >>> replacer = operator.methodcaller('replace', 'old', 'new')
          >>> replacer('old wine in old bottles')
          'new wine in new bottles'

     (Contributed by Georg Brandl, after a suggestion by Gregory
     Petrosyan.)

     ‘attrgetter()’ 関数がドット付きの名前を受け付け、対応する属性ルック
     アップをするようになりました:

          >>> inst_name = operator.attrgetter(
          ...        '__class__.__name__')
          >>> inst_name('')
          'str'
          >>> inst_name(help)
          '_Helper'

     (Contributed by Georg Brandl, after a suggestion by Barry Warsaw.)

   * *note os: 91. モジュールがいくつか新しくシステムコールをラップして
     います。開いたファイルについて、 ‘fchmod(fd, mode)’ はモードを変更
     し、 ‘fchown(fd, uid, gid)’ は所有権を変更し、 ‘lchmod(path, mode)’
     はシンボリックリンクのモードを変更します。 (Contributed by Georg
     Brandl and Christian Heimes.)

     ‘chflags()’ と ‘lchflags()’ は対応するシステムコール (利用可能であ
     れば) へのラッパーで、ファイルのフラグを変更します。そのフラグ値に
     ついての定数が *note stat: bc. モジュールに定義されています; いくつ
     かの取りうる値には、ファイルが変更されるべきではないことを伝える
     ‘UF_IMMUTABLE’ 、ファイルにはデータの追記のみが可能であることを伝え
     る ‘UF_APPEND’ 、があります。 (Contributed by M. Levinson.)

     ‘os.closerange(low, high)’ は効率よく全ての 'low' から 'high' のフ
     ァイルデスクリプタをクローズします。全てのエラーは無視されます。そ
     れと 'high' はクローズ対象ではないです。この関数は既に *note
     subprocess: c1. モジュールがプロセスを開始するのを高速化するために
     使われています。 (Contributed by Georg Brandl; bpo-1663329(16).)

   * ‘os.environ’ オブジェクトの ‘clear()’ メソッドが、オブジェクトのキ
     ーから取り除くだけでなく *note os.unsetenv(): 8e9. を使って環境変数
     を未設定にするようになりました。 (Contributed by Martin Horcicka;
     bpo-1181(17).)

   * *note os.walk(): 476. 関数に ‘followlinks’ パラメータが追加されてい
     ます。これを真にすると、シンボリックリンクが指す相手のディレクトリ
     を渡り歩くようになります。後方互換のためにこのパラメータのデフォル
     トは偽です。なお、親ディレクトリを指すシンボリックリンクなど参照が
     循環していると、無限再帰に陥りますので注意してください。
     (bpo-1273829(18))

   * *note os.path: 92. モジュールの ‘splitext()’ 関数が、先行するピリオ
     ドで分割しないように変更されています。これにより Unix のドットファ
     イルの処理結果がよくなります。例えば ‘os.path.splitext('.ipython')’
     は ‘('', '.ipython')’ ではなく ‘('.ipython', '')’ を返すようになっ
     ています。 (bpo-1115886(19))

     新規関数 ‘os.path.relpath(path, start='.')’ は、与えられれば
     ‘start’ からの、与えられなければカレントディレクトリからの、目的地
     ‘path’ への相対パスを返します。 (Contributed by Richard Barran;
     bpo-1339796(20).)

     Windows において、 *note os.path.expandvars(): 1381. が "%var%" 形
     式の記述に環境変数を展開し、 "~user" にユーザのホームディレクトリの
     パスを展開するようになりました。 (Contributed by Josiah Carlson;
     bpo-957650(21).)  (--訳注: "~user" は実在した仕様かわかりません。
     2.7 に該当する実装もコメントも docstring もリファレンスもありません
     し、当然この振る舞いは現在実在していません。--)

   * *note pdb: 94. モジュールで提供される Python デバッガに新たなコマン
     ドが追加されました: "run" はデバッグ対象の Python プログラムを再起
     動します。またオプションとして、対象プログラムに与えるコマンドライ
     ン引数を渡せます。 (Contributed by Rocky Bernstein;
     bpo-1393667(22).)

   * トレースバックのデバッグを開始するのに使われる *note
     pdb.post_mortem(): 1382. が、トレースバックが与えられない場合に
     *note sys.exc_info(): 656. からの戻り値のトレースバックを使うように
     なりました。 (Contributed by Facundo Batista; bpo-1106316(23).)

   * *note pickletools: 96. モジュールに ‘optimize()’ 関数が追加されまし
     た。これは pickle を含んだ文字列を受け取って、未使用 opcode を削除
     の上で同じデータ構造を含んだより小さい pickle を返します。
     (Contributed by Raymond Hettinger.)

   * *note pkgutil: 97. モジュールに ‘get_data()’ 関数が追加されました。
     これはインストールされている Python パッケージに含まれるリソースフ
     ァイルの内容を返します。例えば:

          >>> import pkgutil
          >>> print pkgutil.get_data('test', 'exception_hierarchy.txt')
          BaseException
           +-- SystemExit
           +-- KeyboardInterrupt
           +-- GeneratorExit
           +-- Exception
                +-- StopIteration
                +-- StandardError
           ...

     (Contributed by Paul Moore; bpo-2439(24).)

   * ‘pyexpat’ モジュールの ‘Parser’ オブジェクトで、 ‘buffer_size’ 属性
     の設定により文字データの保持に使うバッファのサイズを変更出来るよう
     になりました。 (Contributed by Achim Gaedke; bpo-1137(25).)

   * ‘Queue’ モジュールが、エントリを違った順序で取り出すような queue の
     変種をサポートするようになっています。 ‘PriorityQueue’ クラスはキュ
     ーアイテムをヒープで格納し、それを優先順で取り出します。
     ‘LifoQueue’ クラスは、最後にエントリに追加されたものを最初に取り出
     します。つまり stack のように振舞うということです。 (Contributed by
     Raymond Hettinger.)

   * *note random: a6. モジュールの ‘Random’ が、今では 32 ビットシステ
     ムで pickle 出来、64 ビットシステムで unpickle 出来、逆も出来ます。
     残念ながらこの変更は Python 2.6 の ‘Random’ オブジェクトを以前の
     Python で正しく unpickle 出来ないことを意味します。 (Contributed by
     Shawn Ligocki; bpo-1727780(26).)

     新たな ‘triangular(low, high, mode)’ は、三角分布 (triangular
     distribution) に従う乱数を生成します。 'mode' は分布内の最頻値で、
     返却値は 'high' を含まない 'low' と 'high' の間です。 (Contributed
     by Wladmir van der Laan and Raymond Hettinger; bpo-1681432(27).)

   * *note re: a7. モジュールによって実行される長い正規表現検索が届けら
     れるシグナルをチェックするようになり、これにより多大な時間を要する
     検索を中断出来るようになります。 (Contributed by Josh Hoyt and Ralf
     Schmitt; bpo-846388(28).)  (--訳注: 原文を忠実に訳すとわかりにくい
     ですが、単に C のレベルでシグナルハンドラを仕掛けたので Python が割
     り込める、というのがここで言っていることです。本質的には「長い」や
     「時間のかかる」はあまり関係ないです。--)

     正規表現モジュールは、小さな正規表現固有仮想マシン用のバイトコード
     をコンパイルすることで実装されています。信頼出来ないコードにより、
     悪意あるバイトコード文字列を直接作って破滅させることが出来ます。で
     すので、2.6 では正規表現バイトコードの検証をするようにしてあります
     。(Contributed by Guido van Rossum from work for Google App Engine;
     bpo-3487(29).)

   * The *note rlcompleter: ab. module's ‘Completer.complete()’ method
     will now ignore exceptions triggered while evaluating a name.
     (Fixed by Lorenz Quack; bpo-2250(30).)

   * *note sched: ad. モジュールの ‘scheduler’ インスタンスが読み出し専
     用の *note queue: a4. 属性を持つようになりました。これはスケジュー
     ラのキュー内容を名前付きタプル ‘(time, priority, action, argument)’
     で返します。 (Contributed by Raymond Hettinger; bpo-1861(31).)

   * The *note select: af. module now has wrapper functions for the
     Linux ‘epoll()’ and BSD ‘kqueue()’ system calls.  ‘modify()’ method
     was added to the existing ‘poll’ objects; ‘pollobj.modify(fd,
     eventmask)’ takes a file descriptor or file object and an event
     mask, modifying the recorded event mask for that file.
     (Contributed by Christian Heimes; bpo-1657(32).)

   * *note shutil.copytree(): 9f7. が省略可能引数 'ignore' を取るように
     なっています。呼び出し可能オブジェクトを渡します。この呼び出し可能
     オブジェクトはそれぞれのディレクトリパスとその内容リストを受け取っ
     て、コピーせずに無視したい名前のリストを返します。

     *note shutil: b3. モジュールでは同時に、この新たなパラメータのため
     に使える ‘ignore_patterns()’ も提供しています。 ‘ignore_patterns()’
     は任意の数の glob スタイルのパターンを取り、これらパターンに合致す
     る任意のファイルとディレクトリを無視する呼び出し可能オブジェクトを
     返します。以下は、 ‘.svn’ ディレクトリと '~' で終わるファイル名を持
     つ Emacs のバックアップファイルをスキップしてディレクトリコピーをす
     る例です:

          shutil.copytree('Doc/library', '/tmp/library',
                          ignore=shutil.ignore_patterns('*~', '.svn'))

     (Contributed by Tarek Ziadé; bpo-2663(33).)

   * Tkinter や GTK+ などのような場所で、シグナルハンドリングと GUI 処理
     のイベントループを組み合わせることは、長い間悩みの種でした; ほとん
     どのソフトウェアはポーリングを行って、わずかばかりの時間で起き上が
     っては GUI イベントが起きていないかチェックするハメになっています。
     *note signal: b4. モジュールが、これをより効率的に行えるようにしま
     した。 ‘signal.set_wakeup_fd(fd)’ でファイルデスクリプタをセットす
     ると、イベント受信時にファイルデスクリプタにバイトが書き込まれます
     。 C レベルの関数 *note PySignal_SetWakeupFd(): 1383. もあります。
     同じくファイルデスクリプタを渡します。

     Event loops will use this by opening a pipe to create two
     descriptors, one for reading and one for writing.  The writable
     descriptor will be passed to ‘set_wakeup_fd()’, and the readable
     descriptor will be added to the list of descriptors monitored by
     the event loop via ‘select()’ or ‘poll()’.  On receiving a signal,
     a byte will be written and the main event loop will be woken up,
     avoiding the need to poll.

     (Contributed by Adam Olsen; bpo-1583(34).)

     ‘siginterrupt()’ 関数が Python コードから利用可能になりました。対象
     シグナルがシステムコールを中断出来るかどうかを変更出来ます。
     (Contributed by Ralf Schmitt.)

     ‘setitimer()’, ‘getitimer()’ 関数も追加されています (利用可能であれ
     ば)。 ‘setitimer()’ は、指定時間経過後に処理にシグナルを届けます。
     時間は「壁時計時間 (wall-clock time)」(訳注: リファレンスでは「実時
     間」と表現している)、「プロセスの実行時間 (consumed process time)」
     、またはプロセス + システム時間の組合せで指定します。(Contributed
     by Guilherme Polo; bpo-2240(35).)

   * *note smtplib: b7. モジュールが、 ‘SMTP_SSL’ クラスの追加によって
     SMTP over SSL をサポートするようになっています。このクラスは既存の
     ‘SMTP’ と同じインターフェイスです。(Contributed by Monty Taylor.)  両
     方のクラスのコンストラクタでは新たに省略可能な ‘timeout’ パラメータ
     を取ります。最初に接続を試みる際のタイムアウト値を秒で指定します。
     (Contributed by Facundo Batista.)

     LMTP プロトコル ( RFC 2033(36)) 実装もモジュールに追加されています
     。LMTP はメールキューを管理しないエージェント間で e-mail を転送する
     際に、SMTP の代わりに使われます。(LMTP implemented by Leif
     Hedstrom; bpo-957003(37).)

     ‘SMTP.starttls()’ は今や RFC 3207(38) 遵守であり、TLS ネゴシエーシ
     ョン自身で得たのでないサーバから得られるいかなる知識も記憶しません
     。(Patch contributed by Bill Fenner; bpo-829951(39).)

   * The *note socket: b8. module now supports TIPC
     (‘https://tipc.sourceforge.net/’), a high-performance non-IP-based
     protocol designed for use in clustered environments.  TIPC
     addresses are 4- or 5-tuples.  (Contributed by Alberto Bertogli;
     bpo-1646(40).)

     新規の ‘create_connection()’ 関数はアドレスを取り、省略可能なタイム
     アウト値を使って接続を行い、接続されたソケットオブジェクトを返しま
     す。この関数は同時に、アドレスのタイプを調べて IPv4 と IPv6 の相応
     しい方を使って接続します。あなたのコードが ‘socket(socket.AF_INET,
     ...)’ を使う代わりに ‘create_connection()’ に乗り換えることは、それ
     が IPv6 対応で必要なこと全て、となるでしょう。

   * The base classes in the *note SocketServer: b9. module now support
     calling a *note handle_timeout(): 12f0. method after a span of
     inactivity specified by the server's *note timeout: 12ef.
     attribute.  (Contributed by Michael Pomraning.)  The *note
     serve_forever(): 1112. method now takes an optional poll interval
     measured in seconds, controlling how often the server will check
     for a shutdown request.  (Contributed by Pedro Werneck and Jeffrey
     Yasskin; bpo-742598(41), bpo-1193577(42).)

   * Gerhard Häring により保守されている *note sqlite3: ba. モジュールが
     、Python 2.5 時のバージョン 2.3.2 からバージョン 2.4.1 に更新されま
     した。

   * The *note struct: c0. module now supports the C99 _Bool type, using
     the format character ‘'?'’.  (Contributed by David Remahl.)

   * The *note Popen: 17e. objects provided by the *note subprocess: c1.
     module now have *note terminate(): 1384, *note kill(): 1385, and
     *note send_signal(): 1386. methods.  On Windows, ‘send_signal()’
     only supports the *note SIGTERM: 1387. signal, and all these
     methods are aliases for the Win32 API function
     ‘TerminateProcess()’.  (Contributed by Christian Heimes.)

   * *note sys: c3. モジュールに新たに追加された変数 ‘float_info’ は、
     ‘float.h’ に由来するプラットフォームの浮動小数点数サポートについて
     の情報を含んだオブジェクトです。このオブジェクトの属性としては、
     ‘mant_dig’ (仮数部の桁数)、 ‘epsilon’ (1.0 と、それより大きい表現可
     能な最小値との差)などがあります。 (Contributed by Christian Heimes;
     bpo-1534(43).)

     もう一つの新たな変数 ‘dont_write_bytecode’ は Python がモジュールイ
     ンポート時に ‘.pyc’ や ‘.pyo’ を作るかどうかを制御します。この変数
     が真ならば、コンパイル済みファイルは作られません。この変数は Python
     インタプリタを *note -B: 1375. スイッチ付きで起動するか環境変数
     *note PYTHONDONTWRITEBYTECODE: 1376. をセットすることで初期設定され
     ます。Python コードはこのあとでこの変数の値を変更することで、バイト
     コードファイルを作るかどうかを制御出来ます。 (Contributed by Neal
     Norwitz and Georg Brandl.)

     Python インタプリタに与えられたコマンドライン引数についての情報を、
     ‘sys.flags’ として利用可能な名前付きタプルで知ることが出来ます。例
     えば Python が冗長モードで起動された場合は ‘verbose’ 属性は真となり
     、デバッグモードでは ‘debug’ 属性が真、などです。これら属性は全て読
     み出し専用です。 (Contributed by Christian Heimes.)

     新しい関数 ‘getsizeof()’ が追加されました。 Python オブジェクトを受
     け取り、そのオブジェクトが利用しているメモリサイズをバイト単位で返
     します。 ビルトインオブジェクトは正確な結果を返しますが、サードパー
     ティの拡張は正確な値を返さないかもしれません。 その場合
     ‘__sizeof__()’ メソッドを定義してオブジェクトのサイズを返すことがで
     きます。 (Robert Schuppenies による貢献.  bpo-2898(44))

     現在動作中のプロファイラとトレーサーを、 *note sys.getprofile():
     1388. と *note sys.gettrace(): 1389. で知ることが出来るようになりま
     した。 (Contributed by Georg Brandl; bpo-1648(45).)

   * *note tarfile: c8. モジュールが、既にサポートされている
     POSIX.1-1988 (ustar) と GNU tar フォーマットに加えて、POSIX.1-2001
     (pax) をサポートするようになりました。デフォルトは GNU tar です; こ
     れと違うフォーマットでファイルを開くには ‘format’ パラメータで指定
     します:

          tar = tarfile.open("output.tar", "w",
                             format=tarfile.PAX_FORMAT)

     新しい ‘encoding’ と ‘errors’ パラメータはエンコーディングと文字変
     換のエラー処理方法を指定します。 ‘'strict'’, ‘'ignore'’,
     ‘'replace'’ は Python の 3 つの標準エラー処理です; ‘'utf-8'’ は特殊
     で、不正な文字を、それの UTF-8 表現に置き換えます。(文字変換は、PAX
     フォーマットが Unicode ファイル名をサポートするために現れ、デフォル
     トは UTF-8 エンコーディングです。)

     The ‘TarFile.add()’ method now accepts an ‘exclude’ argument that's
     a function that can be used to exclude certain filenames from an
     archive.  The function must take a filename and return true if the
     file should be excluded or false if it should be archived.  The
     function is applied to both the name initially passed to ‘add()’
     and to the names of files in recursively added directories.

     (All changes contributed by Lars Gustäbel).

   * An optional ‘timeout’ parameter was added to the ‘telnetlib.Telnet’
     class constructor, specifying a timeout measured in seconds.
     (Added by Facundo Batista.)

   * *note tempfile.NamedTemporaryFile: 492. クラスは普通はこれが作った
     一時ファイルを、ファイルクローズ時に削除します。この振る舞いを、コ
     ンストラクタのパラメータに ‘delete=False’ を渡すことで変更出来るよ
     うになりました。 (Contributed by Damien Miller; bpo-1537850(46).)

     新しいクラス ‘SpooledTemporaryFile’ は一時ファイルのように振舞いま
     すが、そのデータは最大サイズを超えるまではメモリ内に格納されます。
     その制限を超えると、その内容がディスク上の一時ファイルに書き込まれ
     ます。 (Contributed by Dustin J. Mitchell.)

     ‘NamedTemporaryFile’ と ‘SpooledTemporaryFile’ のともにコンテキスト
     マネージャとして動作しますので、 ‘with
     tempfile.NamedTemporaryFile() as tmp: ...’ のように書くことが出来ま
     す。 (Contributed by Alexander Belopolsky; bpo-2021(47).)

   * The *note test.test_support: cd. module gained a number of context
     managers useful for writing tests.  *note EnvironmentVarGuard():
     138a. is a context manager that temporarily changes environment
     variables and automatically restores them to their old values.

     もう一つのコンテキストマネージャ ‘TransientResource’ は、利用出来る
     かもしれないし出来ないかもしれないリソースの呼び出しを包むことが出
     来ます; 指定した例外リストを捕捉して無視します(--訳注: この紹介、良
     くないと思うのと、多分著者が誤解してます。確かに属性名/属性値を特定
     してこれに一致する場合にだけ例外を受け取るためのものなので、一致し
     ないものは無視、という事実には反しませんが、「狙った例外は受け取る
     (ResourceDenied)」でもあるはずです。「期待した例外が発生する」こと
     をテストしたいでしょう、「期待しない例外はテストには関係ない」であ
     るとともに。それとリファレンスと docstring によれば「指定した例外と
     属性に合致する場合に ResourceDenied」と言っているので、やはり事実と
     は反しています。--)。例えば、ネットワークのテストでは外部のウェブサ
     イトとの接続時の特定の失敗を無視するでしょう:

          with test_support.TransientResource(IOError,
                                          errno=errno.ETIMEDOUT):
              f = urllib.urlopen('https://sf.net')
              ...

     最後に、 ‘check_warnings()’ は ‘warning’ モジュールの警告フィルタを
     リセットして、全ての引き起こされる警告メッセージを記録するオブジェ
     クトを返します (bpo-3781(48)):

          with test_support.check_warnings() as wrec:
              warnings.simplefilter("always")
              # ... code that triggers a warning ...
              assert str(wrec.message) == "function is outdated"
              assert len(wrec.warnings) == 1, "Multiple warnings raised"

     (Contributed by Brett Cannon.)

   * The *note textwrap: d5. module can now preserve existing whitespace
     at the beginnings and ends of the newly created lines by specifying
     ‘drop_whitespace=False’ as an argument:

          >>> S = """This  sentence  has a bunch   of
          ...   extra   whitespace."""
          >>> print textwrap.fill(S, width=15)
          This  sentence
          has a bunch
          of    extra
          whitespace.
          >>> print textwrap.fill(S, drop_whitespace=False, width=15)
          This  sentence
            has a bunch
             of    extra
             whitespace.
          >>>

     (Contributed by Dwayne Bailey; bpo-1581073(49).)

   * *note threading: d6. モジュールの API が、 ‘setDaemon()’,
     ‘isDaemon()’ メソッドではなく ‘daemon’ のようにプロパティを使うよう
     に変更中です。また、いくつかのメソッドはキャメルケースではなくアン
     ダースコアスタイルに名前変更されています; 例えば ‘activeCount()’ メ
     ソッドは ‘active_count()’ にリネームされます。2.6 と 3.0 の両バージ
     ョンのモジュールは同じプロパティとリネームされたメソッドをサポート
     しますが、古いメソッドは削除されません。古い API が Python 3.x で撤
     廃するのがいつになるのかは未定です; 2.x バージョンでは削除されない
     でしょう。 (Carried out by several people, most notably Benjamin
     Peterson.)  (-- 訳注: 3.5 でもこの状態は続いたままです。今でもキャ
     メルケーススタイルのメソッドが使えます。ですが、もちろん新しい名前
     を使うべきです。--)

     *note threading: d6. モジュールの ‘Thread’ オブジェクトに ‘ident’ プ
     ロパティが追加されています。スレッドの識別子を非ゼロの整数で返しま
     す。 (Contributed by Gregory P. Smith; bpo-2871(50).)

   * *note timeit: d8. モジュールが、計測されるステートメントとセットア
     ップコードとして、文字列だけでなく呼び出し可能オブジェクトを渡せる
     ようになりました。 ‘Timer’ インスタンスを作成する 2 つの便利関数が
     追加されています: ‘repeat(stmt, setup, time, repeat, number)’ と
     ‘timeit(stmt, setup, time, number)’ で、インスタンスを作成して対応
     するメソッドを呼びます。 (Contributed by Erik Demaine;
     bpo-1533909(51).)

   * ‘Tkinter’ モジュールが、オプションとしてリストとタプルを受け付ける
     ようになっています。Tcl/Tk へは空白区切りの文字列にして渡されます。
     (Contributed by Guilherme Polo; bpo-2906(52).)

   * タートルグラフィックスのための *note turtle: ea. モジュールが
     Gregor Lingl により大幅に拡張されました。 モジュールの新しい機能は
     次の通りです:

        * 亀の移動と回転のアニメーションの改善。

        * 新しい ‘delay()’ メソッド、 ‘tracer()’ メソッド、 ‘speed()’ メ
          ソッドを使って亀の動きをコントロールできるようになりました。

        * 亀に新しい姿を設定できたり、新しい座標系を定義できるようになり
          ました。

        * Turtles now have an ‘undo()’ method that can roll back
          actions.

        * マウスやキーボードからの入力イベントに反応するための簡易なサポ
          ートが入り、簡単なゲームを書けるようになりました。

        * ‘turtle.cfg’ を使って、turtle の画面の起動時の見た目をカスタマ
          イズできるようになりました。

        * モジュールの docstring が、他の言語に翻訳された docstring に置
          き換えられるようになりました。

     (bpo-1513695(53))

   * An optional ‘timeout’ parameter was added to the *note
     urllib.urlopen: 273. function and the ‘urllib.ftpwrapper’ class
     constructor, as well as the *note urllib2.urlopen: 273. function.
     The parameter specifies a timeout measured in seconds.  For
     example:

          >>> u = urllib2.urlopen("http://slow.example.com",
                                  timeout=3)
          Traceback (most recent call last):
            ...
          urllib2.URLError: <urlopen error timed out>
          >>>

     (Added by Facundo Batista.)

   * *note unicodedata: ee. モジュールで提供される Unicode データベース
     が、バージョン 5.1.0 に更新されました。 (Updated by Martin von
     Löwis; bpo-3811(54).)

   * *note warnings: fa. モジュールの ‘formatwarning()’ と
     ‘showwarning()’ に省略可能な 'line' 引数が追加されました。ソースコ
     ードの行番号を与えることが出来ます。 (Added as part of
     bpo-1631171(55), which re-implemented part of the *note warnings:
     fa. module in C code.)

     新しい関数 ‘catch_warnings()’ はコンテキストマネージャで、テスト目
     的で警告フィルタを一時的に変更して元に戻すのに使えます。
     (bpo-3781(56)).

   * The XML-RPC *note SimpleXMLRPCServer: 115. and *note
     DocXMLRPCServer: 115. classes can now be prevented from immediately
     opening and binding to their socket by passing ‘False’ as the
     'bind_and_activate' constructor parameter.  This can be used to
     modify the instance's ‘allow_reuse_address’ attribute before
     calling the ‘server_bind()’ and ‘server_activate()’ methods to open
     the socket and begin listening for connections.  (Contributed by
     Peter Parente; bpo-1599845(57).)

     ‘SimpleXMLRPCServer’ はさらに ‘_send_traceback_header’ 属性を持つよ
     うになりました。真の場合、例外とフォーマットされたトレースバックが
     HTTP ヘッダ "X-Exception" と "X-Traceback" として返ります。この機能
     はデバッグのみに使い、製品のサーバには使ってはなりません。トレース
     バックには剥き出しのパスワードが含まれるかもしれず、あるいはほかの
     何か企業秘密だったり国家秘密だったりするような繊細な情報満載かもし
     れないのです。 (Contributed by Alan McIntyre as part of his project
     for Google's Summer of Code 2007.)

   * The *note xmlrpclib: 114. module no longer automatically converts
     *note datetime.date: 1af. and *note datetime.time: 1b0. to the
     *note xmlrpclib.DateTime: 138b. type; the conversion semantics were
     not necessarily correct for all applications.  Code using
     ‘xmlrpclib’ should convert ‘date’ and *note time: 1b0. instances.
     (bpo-1330538(58)) The code can also handle dates before 1900
     (contributed by Ralf Schmitt; bpo-2014(59)) and 64-bit integers
     represented by using ‘<i8>’ in XML-RPC responses (contributed by
     Riku Lindblad; bpo-2985(60)).

   * *note zipfile: 117. モジュールの ‘ZipFile’ クラスに ‘extract()’ メ
     ソッドと ‘extractall()’ メソッドが追加されました。アーカイブ内の、
     それぞれ単一ファイル、全てのファイルを、カレントディレクトリか指定
     のディレクトリに展開します:

          z = zipfile.ZipFile('python-251.zip')

          # Unpack a single file, writing it relative
          # to the /tmp directory.
          z.extract('Python/sysmodule.c', '/tmp')

          # Unpack all the files in the archive.
          z.extractall()

     (Contributed by Alan McIntyre; bpo-467924(61).)

     *note open(): 4e5, ‘read()’, ‘extract()’ メソッドはファイル名か
     ‘ZipInfo’ オブジェクトのどちらかを受け取れるようになっています。こ
     れは誤って重複したファイル名を含んでいるアーカイブで有用でしょう。
     (Contributed by Graham Horler; bpo-1775025(62).)

     最後に、 *note zipfile: 117. がアーカイブするファイルのファイル名と
     して Unicode の使用をサポートするようになりました。 (Contributed by
     Alexey Borzenkov; bpo-1734346(63).)  (--訳注: リファレンスに注意事
     項として書かれていますが、zip ファイルのファイル名標準は存在しない
     のでこれは問題を起こすことがあります。--)

* Menu:

* ast モジュール::
* future_builtins モジュール::
* json モジュール; JavaScript オブジェクト記法: json モジュール JavaScript オブジェクト記法.
* plistlib モジュール; プロパティリストパーサ: plistlib モジュール プロパティリストパーサ.
* ctypes の強化::
* SSL サポートの改善::

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1736190

   (2) https://www.jcea.es/programacion/pybsddb.htm

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1817

   (4) https://bugs.python.org/issue?@action=redirect&bpo=600362

   (5) https://bugs.python.org/issue?@action=redirect&bpo=1381

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1638033

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1158

   (8) https://speleotrove.com/decimal/decarith.html

   (9) https://bugs.python.org/issue?@action=redirect&bpo=1221598

   (10) https://bugs.python.org/issue?@action=redirect&bpo=1739906

   (11) https://bugs.python.org/issue?@action=redirect&bpo=1001604

   (12) https://bugs.python.org/issue?@action=redirect&bpo=2138

   (13) https://bugs.python.org/issue?@action=redirect&bpo=2819

   (14) https://bugs.python.org/issue?@action=redirect&bpo=711019

   (15) https://bugs.python.org/issue?@action=redirect&bpo=1640

   (16) https://bugs.python.org/issue?@action=redirect&bpo=1663329

   (17) https://bugs.python.org/issue?@action=redirect&bpo=1181

   (18) https://bugs.python.org/issue?@action=redirect&bpo=1273829

   (19) https://bugs.python.org/issue?@action=redirect&bpo=1115886

   (20) https://bugs.python.org/issue?@action=redirect&bpo=1339796

   (21) https://bugs.python.org/issue?@action=redirect&bpo=957650

   (22) https://bugs.python.org/issue?@action=redirect&bpo=1393667

   (23) https://bugs.python.org/issue?@action=redirect&bpo=1106316

   (24) https://bugs.python.org/issue?@action=redirect&bpo=2439

   (25) https://bugs.python.org/issue?@action=redirect&bpo=1137

   (26) https://bugs.python.org/issue?@action=redirect&bpo=1727780

   (27) https://bugs.python.org/issue?@action=redirect&bpo=1681432

   (28) https://bugs.python.org/issue?@action=redirect&bpo=846388

   (29) https://bugs.python.org/issue?@action=redirect&bpo=3487

   (30) https://bugs.python.org/issue?@action=redirect&bpo=2250

   (31) https://bugs.python.org/issue?@action=redirect&bpo=1861

   (32) https://bugs.python.org/issue?@action=redirect&bpo=1657

   (33) https://bugs.python.org/issue?@action=redirect&bpo=2663

   (34) https://bugs.python.org/issue?@action=redirect&bpo=1583

   (35) https://bugs.python.org/issue?@action=redirect&bpo=2240

   (36) https://datatracker.ietf.org/doc/html/rfc2033.html

   (37) https://bugs.python.org/issue?@action=redirect&bpo=957003

   (38) https://datatracker.ietf.org/doc/html/rfc3207.html

   (39) https://bugs.python.org/issue?@action=redirect&bpo=829951

   (40) https://bugs.python.org/issue?@action=redirect&bpo=1646

   (41) https://bugs.python.org/issue?@action=redirect&bpo=742598

   (42) https://bugs.python.org/issue?@action=redirect&bpo=1193577

   (43) https://bugs.python.org/issue?@action=redirect&bpo=1534

   (44) https://bugs.python.org/issue?@action=redirect&bpo=2898

   (45) https://bugs.python.org/issue?@action=redirect&bpo=1648

   (46) https://bugs.python.org/issue?@action=redirect&bpo=1537850

   (47) https://bugs.python.org/issue?@action=redirect&bpo=2021

   (48) https://bugs.python.org/issue?@action=redirect&bpo=3781

   (49) https://bugs.python.org/issue?@action=redirect&bpo=1581073

   (50) https://bugs.python.org/issue?@action=redirect&bpo=2871

   (51) https://bugs.python.org/issue?@action=redirect&bpo=1533909

   (52) https://bugs.python.org/issue?@action=redirect&bpo=2906

   (53) https://bugs.python.org/issue?@action=redirect&bpo=1513695

   (54) https://bugs.python.org/issue?@action=redirect&bpo=3811

   (55) https://bugs.python.org/issue?@action=redirect&bpo=1631171

   (56) https://bugs.python.org/issue?@action=redirect&bpo=3781

   (57) https://bugs.python.org/issue?@action=redirect&bpo=1599845

   (58) https://bugs.python.org/issue?@action=redirect&bpo=1330538

   (59) https://bugs.python.org/issue?@action=redirect&bpo=2014

   (60) https://bugs.python.org/issue?@action=redirect&bpo=2985

   (61) https://bugs.python.org/issue?@action=redirect&bpo=467924

   (62) https://bugs.python.org/issue?@action=redirect&bpo=1775025

   (63) https://bugs.python.org/issue?@action=redirect&bpo=1734346


File: python.info,  Node: ast モジュール,  Next: future_builtins モジュール,  Up: 新しいモジュールと改良されたモジュール<2>

1.16.18.1 ‘ast’ モジュール
..........................

*note ast: 7. モジュールは Python コードの抽象構文木 (Abstract Syntax
Tree) 表現を提供します。また、Armin Ronacher は共通タスクを実行するさま
ざまなヘルパー関数を寄稿しました。これらは HTML テンプレートパッケージで
あるとか、コードアナライザ、などなどの、Python コードを処理するツールで
有用となるでしょう。

‘parse()’ 関数は式を受け取り AST を返します。 ‘dump()’ 関数はツリー表現
をデバッギングに相応しい出力をします:

     import ast

     t = ast.parse("""
     d = {}
     for i in 'abcdefghijklm':
         d[i + i] = ord(i) - ord('a') + 1
     print d
     """)
     print ast.dump(t)

これの出力は深くネストされたツリーです:

     Module(body=[
       Assign(targets=[
         Name(id='d', ctx=Store())
        ], value=Dict(keys=[], values=[]))
       For(target=Name(id='i', ctx=Store()),
           iter=Str(s='abcdefghijklm'), body=[
         Assign(targets=[
           Subscript(value=
             Name(id='d', ctx=Load()),
               slice=
               Index(value=
                 BinOp(left=Name(id='i', ctx=Load()), op=Add(),
                  right=Name(id='i', ctx=Load()))), ctx=Store())
          ], value=
          BinOp(left=
           BinOp(left=
            Call(func=
             Name(id='ord', ctx=Load()), args=[
               Name(id='i', ctx=Load())
              ], keywords=[], starargs=None, kwargs=None),
            op=Sub(), right=Call(func=
             Name(id='ord', ctx=Load()), args=[
               Str(s='a')
              ], keywords=[], starargs=None, kwargs=None)),
            op=Add(), right=Num(n=1)))
         ], orelse=[])
        Print(dest=None, values=[
          Name(id='d', ctx=Load())
        ], nl=True)
      ])

‘literal_eval()’ メソッドは、文字列またはリテラル式を表現する AST を受け
取り解析と評価を行い、結果の値を返します。リテラル式は、文字列、数値、辞
書などのみを含む Python 式で、文や関数呼び出しを含みません。もしもあなた
に式を評価する必要があって、だけれども *note eval(): 165. を呼び出すこと
によるセキュリティリスクを許容出来ないということであれば、
‘literal_eval()’ がそれを安全に処理してくれます:

     >>> literal = '("a", "b", {2:4, 3:8, 1:2})'
     >>> print ast.literal_eval(literal)
     ('a', 'b', {1: 2, 2: 4, 3: 8})
     >>> print ast.literal_eval('"a" + "b"')
     Traceback (most recent call last):
       ...
     ValueError: malformed string

モジュールには、AST を横断し、修正するための ‘NodeVisitor’ と
‘NodeTransformer’ クラス、例えば行番号の変更などの共通的な変形を行う関数
群が含まれています。


File: python.info,  Node: future_builtins モジュール,  Next: json モジュール JavaScript オブジェクト記法,  Prev: ast モジュール,  Up: 新しいモジュールと改良されたモジュール<2>

1.16.18.2 ‘future_builtins’ モジュール
......................................

Python 3.0 はビルトイン関数のレポジトリにたくさんの変更を加えていて、そ
のほとんどが互換性を破壊するため Python 2.x シリーズには導入出来ません。
‘future_builtins’ モジュールは 3.0 互換コードを書くのにインポート出来る
3.0 互換関数セットです。

このモジュールに今のところ含まれるのは:

   * ‘ascii(obj)’: 2.x の *note repr(): 7c8. と同じことをします。Python
     3.0 では *note repr(): 7c8. は Unicode 文字列を返すようになっていて
     、一方 *note ascii(): 138e. は純粋な ASCII バイト文字列を返します。

   * ‘filter(predicate, iterable)’, ‘map(func, iterable1, ...)’: 3.0 と
     同じようにイテレータを返し、これは 2.x のビルトインがリストで返すの
     とは違っています。

   * ‘hex(value)’, ‘oct(value)’: ‘__hex__()’ と ‘__oct__()’ メソッドを呼
     び出すのではなく、 ‘__index__()’ メソッドを呼び出した結果を
     hexadecimal または octal に変換します。こちらのバージョンの *note
     oct(): 129c. は新しい ‘0o’ 記法で返却します。


File: python.info,  Node: json モジュール JavaScript オブジェクト記法,  Next: plistlib モジュール プロパティリストパーサ,  Prev: future_builtins モジュール,  Up: 新しいモジュールと改良されたモジュール<2>

1.16.18.3 ‘json’ モジュール: JavaScript オブジェクト記法
........................................................

新しい *note json: 76. モジュールは、JSON (Javascript Object Notation) と
Python 型のエンコーディング、デコーディングをサポートします。JSON は軽量
なデータ交換フォーマットで、頻繁にウェブアプリケーションで使われます。
JSON の詳細情報は ‘http://www.json.org’ にあります。

*note json: 76. モジュールはほとんどのビルトイン型のデコーディングとエン
コーディングサポートを備えています。以下の例は辞書のエンコードとデコード
をしています:

     >>> import json
     >>> data = {"spam": "foo", "parrot": 42}
     >>> in_json = json.dumps(data) # Encode the data
     >>> in_json
     '{"parrot": 42, "spam": "foo"}'
     >>> json.loads(in_json) # Decode into a Python object
     {"spam": "foo", "parrot": 42}

ほかの何か型をサポートするのに独自のエンコーダ、デコーダを書くことも出来
ます。JSON 文字列の pretty-printing もサポートされています。

*note json: 76. (もともと simplejson と呼ばれていました) は Bob Ippolito
によって書かれました。


File: python.info,  Node: plistlib モジュール プロパティリストパーサ,  Next: ctypes の強化,  Prev: json モジュール JavaScript オブジェクト記法,  Up: 新しいモジュールと改良されたモジュール<2>

1.16.18.4 ‘plistlib’ モジュール: プロパティリストパーサ
.......................................................

‘.plist’ フォーマットは Mac OS X で一般的に使われ、基本的なデータ型(数値
、文字列、リスト、辞書)を XML ベースのフォーマットにシリアライズして格納
します。データ型の XML-RPC シリアライズに似ています。

Mac OS X で主に使われるとはいえ、そのフォーマットはまったく Mac 固有では
なくその Python 実装は Python がサポートするあらゆるプラットフォームで動
作するので、*note plistlib: 99. は標準ライブラリに昇格しました。

モジュールを使うのは単純です:

     import sys
     import plistlib
     import datetime

     # Create data structure
     data_struct = dict(lastAccessed=datetime.datetime.now(),
                        version=1,
                        categories=('Personal','Shared','Private'))

     # Create string containing XML.
     plist_str = plistlib.writePlistToString(data_struct)
     new_struct = plistlib.readPlistFromString(plist_str)
     print data_struct
     print new_struct

     # Write data structure to a file and read it back.
     plistlib.writePlist(data_struct, '/tmp/customizations.plist')
     new_struct = plistlib.readPlist('/tmp/customizations.plist')

     # read/writePlist accepts file-like objects as well as paths.
     plistlib.writePlist(data_struct, sys.stdout)


File: python.info,  Node: ctypes の強化,  Next: SSL サポートの改善,  Prev: plistlib モジュール プロパティリストパーサ,  Up: 新しいモジュールと改良されたモジュール<2>

1.16.18.5 ctypes の強化
.......................

Thomas Heller は *note ctypes: 22. モジュールの保守と拡張を続けました。

*note ctypes: 22. は今では C99 ‘bool’ 型を表す ‘c_bool’ データ型をサポー
トします。 (Contributed by David Remahl; bpo-1649190(1).)

*note ctypes: 22. の string, buffer, array 型が拡張スライスインデクス構
文をサポートするように改善され、 ‘(start, stop, step)’ の色々な組み合わ
せが使えます。 (Implemented by Thomas Wouters.)

全ての *note ctypes: 22. データ型が ‘from_buffer()’,
‘from_buffer_copy()’ メソッドをサポートするようになりました。これは与え
られた buffer オブジェクトに基く ctypes インスタンスを作ります。
‘from_buffer_copy()’ はそのオブジェクトの内容をコピーし、
‘from_buffer()’ はその同じメモリ領域を共有します。

新しい呼び出しの慣例は、 *note ctypes: 22. にそれぞれのラップされた呼び
出しの発生時に ‘errno’ あるいは Win32 LastError 変数をクリアすることを伝
えることです。 (Implemented by Thomas Heller; bpo-1798(2).)

Unix ‘errno’ 変数を関数呼び出し後に抽出できるようになっています。ラップ
された関数を作る際、 ‘use_errno=True’ を ‘DLL()’ 関数へのキーワード引数
として渡すことが出来、それによりモジュールレベル関数の ‘set_errno()’ と
‘get_errno()’ を、 errno 値を設定・取得するのに呼び出せます。

Win32 LastError は ‘DLL()’, ‘OleDLL()’, ‘WinDLL()’ 関数で同じようにサポ
ートされています。同じように ‘use_last_error=True’ を与え、モジュールレ
ベル関数 ‘set_last_error()’ と ‘get_last_error()’ を使います。

ctypes インスタンスへのポインタを抽出にするのに使われる ‘byref()’ 関数が
、省略可能な 'offset' パラメータを受け取るようになりました。これは返され
るポインタに追加されるバイト数です。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1649190

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1798


File: python.info,  Node: SSL サポートの改善,  Prev: ctypes の強化,  Up: 新しいモジュールと改良されたモジュール<2>

1.16.18.6 SSL サポートの改善
............................

Bill Janssen は Python 2.6 の Secure Sockets Layer サポートを大掛かりに
改善しました。行われたのは新モジュール *note ssl: bb. の追加です。これは
OpenSSL(1) ライブラリの上に構築されています。この新しいモジュールはプロ
トコルのネゴシエイトのさらなる制御、X.509 証明書の使用、そして SSL サー
バ (クライアントの対語としての) を Python で書くためのより良いサポートを
提供しています。既存の *note socket: b8. モジュールにある SSL サポートは
削除されずにそのまま使えますが、Python 3.0 では削除されます。

この新たなモジュールを使うには、まず最初にいつものやり方で TCP コネクシ
ョンを作らなければなりません。そしてその上でそれを ‘ssl.wrap_socket()’ 関
数に渡します (--訳注: 2.7.9 ではさらに進化した ‘SSLContext.wrap_socket’
が使えます --)。証明書が必要かどうかを指定することが出来、証明書の情報を
‘getpeercert()’ メソッドで取得することも出来ます。

参考
....

*note ssl: bb. モジュールについてのドキュメント。

   ---------- Footnotes ----------

   (1) https://www.openssl.org/


File: python.info,  Node: 非推奨と削除,  Next: ビルドならびに C API の変更<9>,  Prev: 新しいモジュールと改良されたモジュール<2>,  Up: What's New in Python 2 6

1.16.19 非推奨と削除
--------------------

   * 文字列を例外として送出することは出来なくなりました。これをすると
     *note TypeError: 502. を起こします。

   * Changes to the *note Exception: 9a7. interface as dictated by PEP
     352(1) continue to be made.  For 2.6, the ‘message’ attribute is
     being deprecated in favor of the *note args: 538. attribute.

   * (3.0 警告モード) Python 3.0 はたくさんの時代遅れのモジュールを削除
     し、ほかのものも名前変更するような標準ライブラリの再編成が特色とな
     ります。Python 2.6 を 3.0 警告モードで動かすと、それらがインポート
     される際に警告が励起されます。

     The list of deprecated modules is: ‘audiodev’, ‘bgenlocations’,
     ‘buildtools’, ‘bundlebuilder’, ‘Canvas’, ‘compiler’, ‘dircache’,
     ‘dl’, ‘fpformat’, ‘gensuitemodule’, ‘ihooks’, ‘imageop’, ‘imgfile’,
     ‘linuxaudiodev’, ‘mhlib’, ‘mimetools’, ‘multifile’, ‘new’, ‘pure’,
     ‘statvfs’, ‘sunaudiodev’, ‘test.testall’, and ‘toaiff’.

   * The ‘gopherlib’ module has been removed.

   * The ‘MimeWriter’ module and ‘mimify’ module have been deprecated;
     use the *note email: 32. package instead.

   * The ‘md5’ module has been deprecated; use the *note hashlib: 5e.
     module instead.

   * The ‘posixfile’ module has been deprecated; *note fcntl.lockf():
     1394. provides better locking.

   * The ‘popen2’ module has been deprecated; use the *note subprocess:
     c1. module.

   * The ‘rgbimg’ module has been removed.

   * The ‘sets’ module has been deprecated; it's better to use the
     built-in *note set: 5a3. and *note frozenset: 5a4. types.

   * The ‘sha’ module has been deprecated; use the *note hashlib: 5e.
     module instead.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0352/


File: python.info,  Node: ビルドならびに C API の変更<9>,  Next: Python 2 6 への移植,  Prev: 非推奨と削除,  Up: What's New in Python 2 6

1.16.20 ビルドならびに C API の変更
-----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * Python now must be compiled with C89 compilers (after 19 years!).
     This means that the Python source tree has dropped its own
     implementations of ‘memmove()’ and ‘strerror()’, which are in the
     C89 standard library.

   * Python 2.6 は Microsoft Visual Studio 2008 (version 9.0) でビルド出
     来ます。そしてこれが新しいデフォルトコンパイラです。 ‘PCbuild’ ディ
     レクトリのビルドファイルを参照して下さい。 (Implemented by
     Christian Heimes.)

   * Mac OS X では、Python 2.6 は 4 種類のユニバーサルビルドでコンパイル
     出来ます。 ‘configure’ スクリプトは
     ‘--with-universal-archs=[32-bit|64-bit|all]’ スイッチを取って、
     32-bit アーキテクチャ (x86, PowerPC), 64-bit (x86-64 and PPC-64), あ
     るいは両方のバイナリをビルド出来ます。 (Contributed by Ronald
     Oussoren.)

   * A new function added in Python 2.6.6, ‘PySys_SetArgvEx()’, sets the
     value of ‘sys.argv’ and can optionally update ‘sys.path’ to include
     the directory containing the script named by ‘sys.argv[0]’
     depending on the value of an 'updatepath' parameter.

     This function was added to close a security hole for applications
     that embed Python.  The old function, ‘PySys_SetArgv()’, would
     always update ‘sys.path’, and sometimes it would add the current
     directory.  This meant that, if you ran an application embedding
     Python in a directory controlled by someone else, attackers could
     put a Trojan-horse module in the directory (say, a file named
     ‘os.py’) that your application would then import and run.

     If you maintain a C/C++ application that embeds Python, check
     whether you're calling ‘PySys_SetArgv()’ and carefully consider
     whether the application should be using ‘PySys_SetArgvEx()’ with
     'updatepath' set to false.  Note that using this function will
     break compatibility with Python versions 2.6.5 and earlier; if you
     have to continue working with earlier versions, you can leave the
     call to ‘PySys_SetArgv()’ alone and call
     ‘PyRun_SimpleString("sys.path.pop(0)\n")’ afterwards to discard the
     first ‘sys.path’ component.

     Security issue reported as CVE 2008-5983(1); discussed in
     gh-50003(2), and fixed by Antoine Pitrou.

   * BerkeleyDB モジュールが C API オブジェクトを公開しています。
     ‘bsddb.db.api’ として利用可能です。このモジュールは ‘bsddb’ モジュ
     ールを自身の独自の目的で使いたいほかの C 拡張で使えます。
     (Contributed by Duncan Grisby.)

   * *note PEP 3118 改訂版バッファプロトコル: 1361. で前述の新しいバッフ
     ァインターフェイスのために、 *note PyObject_GetBuffer(): 373. と
     *note PyBuffer_Release(): 374. とほか少しの関数が追加されました。

   * Python's use of the C stdio library is now thread-safe, or at least
     as thread-safe as the underlying library is.  A long-standing
     potential bug occurred if one thread closed a file object while
     another thread was reading from or writing to the object.  In 2.6
     file objects have a reference count, manipulated by the
     ‘PyFile_IncUseCount()’ and ‘PyFile_DecUseCount()’ functions.  File
     objects can't be closed unless the reference count is zero.
     ‘PyFile_IncUseCount()’ should be called while the GIL is still
     held, before carrying out an I/O operation using the ‘FILE *’
     pointer, and ‘PyFile_DecUseCount()’ should be called immediately
     after the GIL is re-acquired.  (Contributed by Antoine Pitrou and
     Gregory P. Smith.)

   * 異なるスレッドから同時にモジュールをインポートすることでデッドロッ
     クが発生することはなくなりました; 今では *note ImportError: 3f2. に
     なります。新たな API 関数 *note PyImport_ImportModuleNoBlock():
     397. は最初に ‘sys.modules’ を探し、インポートロック獲得後にインポ
     ートしようと試みます。インポートロックが他のスレッドにより獲得され
     ていれば *note ImportError: 3f2. が発生します。(Contributed by
     Christian Heimes.)

   * Several functions return information about the platform's
     floating-point support.  *note PyFloat_GetMax(): 1396. returns the
     maximum representable floating-point value, and *note
     PyFloat_GetMin(): 1397. returns the minimum positive value.  *note
     PyFloat_GetInfo(): 1398. returns an object containing more
     information from the ‘float.h’ file, such as ‘"mant_dig"’ (number
     of digits in the mantissa), ‘"epsilon"’ (smallest difference
     between 1.0 and the next largest value representable), and several
     others.  (Contributed by Christian Heimes; bpo-1534(3).)

   * *note PyComplex_AsCComplex(): 1399. を使う C 関数とメソッドが
     ‘__complex__()’ メソッドを持つ引数を受け付けるようになっています。
     特に、 *note cmath: 11. モジュールにある関数は、このメソッドを持つ
     オブジェクトを受け付けます。これは Python 3.0 での変更のバックポー
     トです。 (Contributed by Mark Dickinson; bpo-1675423(4).)

   * Python C API に 2 つの大文字小文字を区別しない文字列比較関数
     ‘PyOS_stricmp(char*, char*)’ と ‘PyOS_strnicmp(char*, char*,
     Py_ssize_t)’ が追加されました。 (Contributed by Christian Heimes;
     bpo-1635(5).)

   * 多くの C 拡張が、 ‘init*’ 関数内でモジュール辞書に整数と文字列定数
     を追加するために独自の小さなマクロを定義しています。 Python 2.6 で
     はついにモジュールに値を追加する標準マクロを定義しました。 *note
     PyModule_AddStringMacro: 139a. と *note PyModule_AddIntMacro():
     139b. です。 (Contributed by Christian Heimes.)

   * Some macros were renamed in both 3.0 and 2.6 to make it clearer
     that they are macros, not functions.  ‘Py_Size()’ became *note
     Py_SIZE(): 74d, ‘Py_Type()’ became *note Py_TYPE(): 74b, and
     ‘Py_Refcnt()’ became *note Py_REFCNT(): 877.  The mixed-case macros
     are still available in Python 2.6 for backward compatibility.
     (bpo-1629(6))

   * Distutils は C 拡張を、デバッグバージョンの Python 実行時に別のディ
     レクトリにビルドするようになりました。 (Contributed by Collin
     Winter; bpo-1530959(7).)

   * いくつかの基本データ型、例えば数値や文字列型は、あとで再利用される
     オブジェクトのフリーリスト(--訳注: メモリ管理での alloc/free の
     free。--)を内部的に管理しています。それらデータ構造はこのフリーリス
     トに関して、命名規約に従うようにしました; その変数名は常に
     ‘free_list’ 、カウンタは常に ‘numfree’ 、そしてマクロ
     ‘Py<typename>_MAXFREELIST’ が必ず定義されます。

   * 新たに追加された Makefile のターゲット "make patchcheck" は、Python
     ソースツリーに対してパッチを作る準備をします: 修正された ‘.py’ ファ
     イル全てに含まれる末尾の余分な空白を取り除き、ドキュメンテーション
     が変更されているかをチェックし、そして ‘Misc/ACKS’ と ‘Misc/NEWS’ が
     更新されているかどうかを報告します。 (Contributed by Brett Cannon.)

     もう一つの新しいターゲット "make profile-opt" は、GCC の
     profile-guided 最適化を使った Python バイナリをビルドします。これは
     Python をプロファイリングを有効にしてビルドし、プロファイル結果のセ
     ットを得るためのテストスイートを実施し、そして最適化のためにそれら
     結果を使ってビルドします。 (Contributed by Gregory P. Smith.)

* Menu:

* ポート特有の変更; Windows: ポート特有の変更 Windows<2>.
* ポート特有の変更; Mac OS X: ポート特有の変更 Mac OS X<2>.
* ポート特有の変更; IRIX: ポート特有の変更 IRIX.

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2008-5983

   (2) https://github.com/python/cpython/issues/50003

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1534

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1675423

   (5) https://bugs.python.org/issue?@action=redirect&bpo=1635

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1629

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1530959


File: python.info,  Node: ポート特有の変更 Windows<2>,  Next: ポート特有の変更 Mac OS X<2>,  Up: ビルドならびに C API の変更<9>

1.16.20.1 ポート特有の変更: Windows
...................................

   * Windows 95, 98, ME, NT4 のサポートはとりやめられました。 Python 2.6
     は最低でも Windows 2000 SP4 が必要です。

   * Windows での新しいデフォルトコンパイラが Visual Studio 2008
     (version 9.0) になっています。Visual Studio 2003 (version 7.1) と
     2005 (version 8.0) のビルドディレクトリは PC/ に移動しました。新し
     い ‘PCbuild’ ディレクトリは X64, デバッグビルド、Profile Guided
     Optimization (PGO) をサポートしています。PGO ビルドは通常ビルドに較
     べておよそ 10% 高速化になります。 (Contributed by Christian Heimes
     with help from Amaury Forgeot d'Arc and Martin von Löwis.)

   * The *note msvcrt: 85. module now supports both the normal and wide
     char variants of the console I/O API. The *note getwch(): 139d.
     function reads a keypress and returns a Unicode value, as does the
     *note getwche(): 139e. function.  The *note putwch(): 139f.
     function takes a Unicode character and writes it to the console.
     (Contributed by Christian Heimes.)

   * *note os.path.expandvars(): 1381. は "%var%" 形式を環境変数で置換し
     、 "~user" をユーザのホームディレクトリパスに置換します(--訳注: 上
     のほうの訳注参照。--)。 (Contributed by Josiah Carlson;
     bpo-957650(1).)

   * The *note socket: b8. module's socket objects now have an *note
     ioctl(): ca1. method that provides a limited interface to the
     ‘WSAIoctl()’ system interface.

   * The *note _winreg: fe. module now has a function, *note
     ExpandEnvironmentStrings(): 13a0, that expands environment variable
     references such as ‘%NAME%’ in an input string.  The handle objects
     provided by this module now support the context protocol, so they
     can be used in *note with: 59c. statements.  (Contributed by
     Christian Heimes.)

     *note _winreg: fe. also has better support for x64 systems,
     exposing the *note DisableReflectionKey(): 132c, *note
     EnableReflectionKey(): 132d, and *note QueryReflectionKey(): 132e.
     functions, which enable and disable registry reflection for 32-bit
     processes running on 64-bit systems.  (bpo-1753245(2))

   * The ‘msilib’ module's ‘Record’ object gained ‘GetInteger()’ and
     ‘GetString()’ methods that return field values as an integer or a
     string.  (Contributed by Floris Bruynooghe; bpo-2125(3).)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=957650

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1753245

   (3) https://bugs.python.org/issue?@action=redirect&bpo=2125


File: python.info,  Node: ポート特有の変更 Mac OS X<2>,  Next: ポート特有の変更 IRIX,  Prev: ポート特有の変更 Windows<2>,  Up: ビルドならびに C API の変更<9>

1.16.20.2 ポート特有の変更: Mac OS X
....................................

   * Python をフレームワークビルドでコンパイルする際に、 ‘configure’ ス
     クリプトに ‘--with-framework-name’ オプションでフレームワーク名を指
     定出来るようになりました。

   * The ‘macfs’ module has been removed.  This in turn required the
     ‘macostools.touched()’ function to be removed because it depended
     on the ‘macfs’ module.  (bpo-1490190(1))

   * Many other Mac OS modules have been deprecated and will be removed
     in Python 3.0: ‘_builtinSuites’, ‘aepack’, ‘aetools’, ‘aetypes’,
     ‘applesingle’, ‘appletrawmain’, ‘appletrunner’, ‘argvemulator’,
     ‘Audio_mac’, ‘autoGIL’, ‘Carbon’, ‘cfmfile’, ‘CodeWarrior’,
     ‘ColorPicker’, ‘EasyDialogs’, ‘Explorer’, ‘Finder’, ‘FrameWork’,
     ‘findertools’, ‘ic’, ‘icglue’, ‘icopen’, ‘macerrors’, ‘MacOS’,
     ‘macfs’, ‘macostools’, ‘macresource’, ‘MiniAEFrame’, ‘Nav’,
     ‘Netscape’, ‘OSATerminology’, ‘pimp’, ‘PixMapWrapper’, ‘StdSuites’,
     ‘SystemEvents’, ‘Terminal’, and ‘terminalcommand’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1490190


File: python.info,  Node: ポート特有の変更 IRIX,  Prev: ポート特有の変更 Mac OS X<2>,  Up: ビルドならびに C API の変更<9>

1.16.20.3 ポート特有の変更: IRIX
................................

A number of old IRIX-specific modules were deprecated and will be
removed in Python 3.0: ‘al’ and ‘AL’, ‘cd’, ‘cddb’, ‘cdplayer’, ‘CL’ and
‘cl’, ‘DEVICE’, ‘ERRNO’, ‘FILE’, ‘FL’ and ‘fl’, ‘flp’, ‘fm’, ‘GET’,
‘GLWS’, ‘GL’ and ‘gl’, ‘IN’, ‘IOCTL’, ‘jpeg’, ‘panelparser’, ‘readcd’,
‘SV’ and ‘sv’, ‘torgb’, ‘videoreader’, and ‘WAIT’.


File: python.info,  Node: Python 2 6 への移植,  Next: 謝辞<2>,  Prev: ビルドならびに C API の変更<9>,  Up: What's New in Python 2 6

1.16.21 Python 2.6 への移植
---------------------------

このセクションでは前述の変更とバグフィックスにより必要となるかもしれない
コードの変更を列挙します:

   * ハッシュ化をサポートしないクラスはその定義内でその事実を示すために
     、 ‘__hash__ = None’ をセットすべきです。

   * 文字列を例外として送出することは出来なくなりました。これをすると
     *note TypeError: 502. を起こします。

   * *note collections.deque: 5a6. の ‘__init__()’ メソッドが、イテラブ
     ルから要素を追加する前に全ての deque の既存の内容をクリアするように
     なっています。この変更は ‘list.__init__()’ の振る舞いと一致します
     (--訳注: 当たり前のことにしか思えないのですが詳細がわかりません。こ
     れ以前のバージョンでは deque はシングルトンのように振舞っていたので
     しょうか。--)。

   * *note object.__init__(): 67c. は以前は任意の引数とキーワード引数を
     受け取り、そして無視していました。Python 2.6 ではもうこれは許されま
     せん。 *note TypeError: 502. を起こします。これは結果的に *note
     object: a5a. の対応するメソッドを呼ぶ(おそらく *note super(): 4a8.
     を介して) ‘__init__()’ メソッドに影響します。 bpo-1683368(1) の議論
     を参照して下さい。

   * ‘Decimal’ のコンストラクタは今では先頭と末尾の空白が含まれる文字列
     を許容します。以前は ‘InvalidOperation’ となっていました。他方で、
     ‘Context’ オブジェクトの ‘create_decimal()’ メソッドは余分な空白を
     明示的に拒絶するようになり、 ‘ConversionSyntax’ を投げます。

   * 実装上の誤り(事故)で、ビルトインの *note __import__(): 8a2. 関数に
     ファイルパスを渡すと指定したファイルをインポート出来ていました。し
     かしながらこれは決して意図した振る舞いではありませんでした。実装は
     今ではこのケースを明示的にチェックし、 *note ImportError: 3f2. を起
     こします。

   * C API: *note PyImport_Import(): 13a4. と *note
     PyImport_ImportModule(): 398. 関数がデフォルトで、相対インポートで
     はなく絶対インポートをするようになっています。これはほかのモジュー
     ルをインポートする C 拡張に影響します。

   * C API: ハッシュされるべきではない拡張データ型は、 ‘tp_hash’ スロッ
     トを *note PyObject_HashNotImplemented(): 136e. と定義すべきです。

   * *note socket: b8. モジュールの例外 *note socket.error: 1029. が
     *note IOError: 1026. 派生になっています。以前は ‘StandardError’ の
     サブクラスではありませんでしたが今は *note IOError: 1026. を通じて
     それのサブクラスです。 (Implemented by Gregory P. Smith;
     bpo-1706815(2).)

   * The *note xmlrpclib: 114. module no longer automatically converts
     *note datetime.date: 1af. and *note datetime.time: 1b0. to the
     *note xmlrpclib.DateTime: 138b. type; the conversion semantics were
     not necessarily correct for all applications.  Code using
     ‘xmlrpclib’ should convert ‘date’ and *note time: 1b0. instances.
     (bpo-1330538(3))

   * (3.0 警告モード) *note Exception: 9a7. クラスはスライスやインデクス
     アクセスで警告を出します; *note Exception: 9a7. のタプルのような振
     る舞いはのちに取り除かれます。

   * (3.0 警告モード) 2 つの辞書や 2 つの比較メソッドを実装しないオブジ
     ェクトの不等号比較は警告されます。 ‘dict1 == dict2’ はまだ動作しま
     すが、 ‘dict1 < dict2’ はのちに取り除かれます。

     Python のスコープルールの実装の詳細であるセル間の比較も、警告を引き
     起こします。なぜならこれは、3.0 ではそのような比較は完全に禁止され
     ているからです。

Python を埋め込んだアプリケーションでは:

   * The ‘PySys_SetArgvEx()’ function was added in Python 2.6.6, letting
     applications close a security hole when the existing
     ‘PySys_SetArgv()’ function was used.  Check whether you're calling
     ‘PySys_SetArgv()’ and carefully consider whether the application
     should be using ‘PySys_SetArgvEx()’ with 'updatepath' set to false.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1683368

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1706815

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1330538


File: python.info,  Node: 謝辞<2>,  Prev: Python 2 6 への移植,  Up: What's New in Python 2 6

1.16.22 謝辞
------------

著者は提案の申し出や修正、様々なこの記事の草稿の助けをしてくれた以下の人
々に感謝します: Georg Brandl, Steve Brown, Nick Coghlan, Ralph Corderoy,
Jim Jewett, Kent Johnson, Chris Lambacher, Martin Michlmayr, Antoine
Pitrou, Brian Warner.


File: python.info,  Node: What's New in Python 2 5,  Next: What's New in Python 2 4,  Prev: What's New in Python 2 6,  Up: What's New in Python

1.17 What's New in Python 2.5
=============================


著者: A.M. Kuchling

This article explains the new features in Python 2.5.  The final release
of Python 2.5 is scheduled for August 2006; PEP 356(1) describes the
planned release schedule.  Python 2.5 was released on September 19,
2006.

The changes in Python 2.5 are an interesting mix of language and library
improvements.  The library enhancements will be more important to
Python's user community, I think, because several widely useful packages
were added.  New modules include ElementTree for XML processing
(‘xml.etree’), the SQLite database module (‘sqlite’), and the *note
ctypes: 22. module for calling C functions.

言語の変更の意義は、中程度のものです。いくつかの心地よい機能が入りました
が、そのほとんどの機能は毎日使うというものでもありません。条件式
(conditional expressions)がついに言語に追加されました。ちょっと変わった
文法です。 *note PEP 308; 条件式 (Conditional Expressions): 13a9. のセク
ションを参照してください。新しい '*note with: 59c.' 文は後始末のコードを
書くのを簡単にします(*note PEP 343; "with" ステートメント: 13aa. セクシ
ョン)。ジェネレータに値を返すことが出来るようになりました(*note PEP 342;
ジェネレータの新機能: 13ab. セクション)。インポートが、絶対パス、相対パ
スのどちらかで可視に出来るようになりました(*note PEP 328;
絶対インポート、相対インポート: 13ac. セクション)。例外ハンドリングのい
くつかの境界のケースで、より良いハンドリングを行えるようになりました
(*note PEP 341; try/except/finally の一体化: 13ad. セクション)。これらの
どの改善も価値が高いですが、それらは言語機能を限定的に改善するものであっ
て、いずれも Python のセマンティクスを広範に修正するものではありません。

言語とライブラリの追加と同様に、ほかの改善とバグフィックスもソースツリー
全体に渡っています。SVN 変更ログを検索すると、Python 2.4 から 2.5 の間で
適用されたパッチは 353、フィックスされたバグは 458 ありました(ともに少な
く見積もってです)。

このドキュメントは新機能の完全な詳細を提供するのではなくて、変更について
、役に立つ実例を使った簡易な概要を提供することを目的にしています。完全な
詳細が知りたければ常に、 ‘https://docs.python.org’ の Python 2.6 のドキ
ュメントを参照すべきです。設計と実装の根拠を理解したい場合は、新機能に関
する PEP を参照してください。可能な限り、 "What’s New in Python" は各変
更の bug や patch に対してリンクしています。

このドキュメントについてのコメント、提案と誤りの報告は歓迎です。著者に電
子メールを送るか、または Python バグトラッカーにバグをあげてください。

* Menu:

* PEP 308; 条件式 (Conditional Expressions): PEP 308 条件式 Conditional Expressions.
* PEP 309; 関数の部分適用: PEP 309 関数の部分適用.
* PEP 314; Metadata for Python Software Packages v1.1: PEP 314 Metadata for Python Software Packages v1 1.
* PEP 328; 絶対インポート、相対インポート: PEP 328 絶対インポート、相対インポート.
* PEP 338 - モジュールをスクリプトとして実行する::
* PEP 341; try/except/finally の一体化: PEP 341 try/except/finally の一体化.
* PEP 342; ジェネレータの新機能: PEP 342 ジェネレータの新機能.
* PEP 343; "with" ステートメント: PEP 343 "with" ステートメント<2>.
* PEP 352; 例外の新スタイルクラス化: PEP 352 例外の新スタイルクラス化.
* PEP 353; 添え字型に ssize_t を使う: PEP 353 添え字型に ssize_t を使う.
* PEP 357; '__index__' メソッド: PEP 357 '__index__' メソッド.
* その他の言語変更: その他の言語変更<14>.
* 新たなモジュール、改良されたモジュール、削除されたモジュール::
* ビルドならびに C API の変更: ビルドならびに C API の変更<10>.
* Python 2.5 への移植: Python 2 5 への移植.
* 謝辞: 謝辞<3>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0356/


File: python.info,  Node: PEP 308 条件式 Conditional Expressions,  Next: PEP 309 関数の部分適用,  Up: What's New in Python 2 5

1.17.1 PEP 308: 条件式 (Conditional Expressions)
------------------------------------------------

もう長いことずっと、人々は条件式を書くための手段を要望し続けてきました。
それは Boolean 値が真か偽かによって値 A または B を返す式です。条件式に
より以下と同じ効果を持つ単一行代入式を書くことが出来ます:

     if condition:
         x = true_value
     else:
         x = false_value

構文についての退屈で終わりのない議論が python-dev と comp.lang.python の
両方で続いてきました。投票では、大半は何らかの形で条件式を望んでいること
を示していましたが、明らかな過半数によって支持される構文はありませんでし
た。候補には C の ‘cond ? true_v : false_v’ や ‘if cond then true_v else
false_v’ を含む、ほか 16 のバリエーションがありました。

Guido van Rossum は結果として意外な構文を選択しました:

     x = true_value if condition else false_value

評価はこれでも既存の Boolean 式のように遅延的であり、評価順は少々前後し
ます。真ん中の 'condition' はまさに最初に評価されるのであって、
'true_value' 式はその 'condition' が真の場合にのみ評価されます。同じよう
に 'false_value' は 'condition' が偽の場合にのみ評価されるのです。

この構文は奇妙で退行しているようにも思えます; どうして condition が '真
ん中' にあって C の ‘c ? x : y’ のように前にないのでしょう?  この決定は
、標準ライブラリ内のモジュールにその新構文を適用し、結果のコードをどう読
むかを見ることでチェックされました。条件式が使われる多くの場合で、一つの
値はどうやら「一般の場合」で一つの値は「例外的な場合」のようで、条件を満
たさないことが稀な場合にのみ使われていました。条件の構文はこのパターンで
少しばかり明快さを増します:

     contents = ((doc + '\n') if doc else '')

私には上記ステートメントはこう読めます。「 'contents' は普通は
‘doc+'\n'’ の値に代入される。ただし時々 'doc' が空になる。その特別な場合
には空の値が代入されるのだ」。私は普通と普通でないのが明らかでない場合に
頻繁に条件式を使うとは思いません。

言語が条件式に括弧を必要とすべきかどうかに関していくつか議論がありました
。決定は Python 言語文法として括弧は '必要ない' とされましたが、スタイル
の問題としては私は常に括弧を付けるべきと思います。以下 2 つの例を考えて
みてください:

     # First version -- no parens
     level = 1 if logging else 0

     # Second version -- with parens
     level = (1 if logging else 0)

最初の版の場合、私は読者の目はおそらくステートメントを「level = 1」「if
logging」「else 0」にグループ化すると思います。そして condition は
'level' への代入が行われるのかどうかを決めるのだ、と考えるであろうと。後
者の版は読みやすいです、少なくとも私の意見では。代入はいつでも行われるこ
とも、選択が 2 つの値の間で起こることもはっきりしますから。

括弧を含めるもう一つの理由があります: 少し奇妙なリスト内包とラムダの組合
せが、不完全な条件式になることがあります。 PEP 308(1) にいくつかの例があ
るので見てください。条件式の周りをいつでも括弧で囲むなら、このケースにぶ
ち当たることもありません。

参考
....

PEP 308(2) - 条件式 (Conditional Expressions)

     PEP 著 Guido van Rossum と Raymond D. Hettinger; 実装 Thomas
     Wouters.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0308/

   (2) https://peps.python.org/pep-0308/


File: python.info,  Node: PEP 309 関数の部分適用,  Next: PEP 314 Metadata for Python Software Packages v1 1,  Prev: PEP 308 条件式 Conditional Expressions,  Up: What's New in Python 2 5

1.17.2 PEP 309: 関数の部分適用
------------------------------

*note functools: 55. モジュールは、関数型スタイルのプログラミングのため
のツールを含むことを意図したものです。

このモジュールには一つの有用なツールとして、 ‘partial()’ 関数があります
。関数型スタイルでプログラムを書くのに、あなたはときおり、いくつかのパラ
メータを持つ関数に一部パラメータを埋めたものを作りたくなります。Python 関
数 ‘f(a, b, c)’ を考えてみましょう; ‘f(1, b, c)’ と等価な ‘g(b, c)’ を作
れたら、と思うわけです。これは「関数の部分適用」と呼ばれています。

‘partial()’ は ‘(function, arg1, arg2, ... kwarg1=value1,
kwarg2=value2)’ という引数を取ります。できあがったオブジェクトは呼び出し
可能オブジェクトですので、それを呼べば、引数の埋まった 'function' を実行
したのと同じことになります。

以下にあるのは、小さいけれども現実的な一つの例です:

     import functools

     def log (message, subsystem):
         "Write the contents of 'message' to the specified subsystem."
         print '%s: %s' % (subsystem, message)
         ...

     server_log = functools.partial(log, subsystem='server')
     server_log('Unable to open socket')

もうひとつ、PyGTK を使うプログラムからの例をみてみましょう。いま、「コン
テキスト依存」のポップアップメニューを動的に構築しようとしています。その
メニューオプションから提供されるコールバックは、 ‘open_item()’ メソッド
の部分適用版で、その最初の引数が適用済みです:

     ...
     class Application:
         def open_item(self, path):
            ...
         def init (self):
             open_func = functools.partial(self.open_item, item_path)
             popup_menu.append( ("Open", open_func, 1) )

*note functools: 55. モジュールのもう一つの関数は
‘update_wrapper(wrapper, wrapped)’ で、より良く振舞うデコレータを書くの
に役立ちます。 ‘update_wrapper()’ は包まれるほうの名前、モジュール、ドキ
ュメンテーション文字列属性をラッパー関数にコピーすることで、トレースバッ
クを理解しやすくします。たとえばこう書けます:

     def my_decorator(f):
         def wrapper(*args, **kwds):
             print 'Calling decorated function'
             return f(*args, **kwds)
         functools.update_wrapper(wrapper, f)
         return wrapper

‘wraps()’ は、ラップされる関数についての情報をコピーするために、あなた自
身のデコレータ内で使えるデコレータです。先の例はこのようにも書けます:

     def my_decorator(f):
         @functools.wraps(f)
         def wrapper(*args, **kwds):
             print 'Calling decorated function'
             return f(*args, **kwds)
         return wrapper

参考
....

PEP 309(1) - 関数の部分適用

     PEP の提案と著: Peter Harris; 実装: Hye-Shik Chang と Nick Coghlan,
     また、適応物が Raymond Hettinger により。 (--訳注: この PEP のタイ
     トルに違和感を憶える人は多いと思います。functools のテリトリが「関
     数型スタイルのサポート」にあるのに。部分引数サポートのためのパッチ
     が最終的に関数型スタイルに行き着いた (正確には、「partial のような
     高階関数を置く場所として functools という場所を使いましょう、
     partial から始めましょう」というのが提案の趣旨)、という経緯がこのタ
     イトルに反映しています。--)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0309/


File: python.info,  Node: PEP 314 Metadata for Python Software Packages v1 1,  Next: PEP 328 絶対インポート、相対インポート,  Prev: PEP 309 関数の部分適用,  Up: What's New in Python 2 5

1.17.3 PEP 314: Metadata for Python Software Packages v1.1
----------------------------------------------------------

Distutils にいくつかの単純な依存性解決サポートが追加されました。
‘setup()’ 関数に ‘requires’, ‘provides’, ‘obsoletes’ キーワードパラメー
タが追加されています。 ‘sdist’ コマンドでソース配布物をビルドする際に、
依存性についての情報が ‘PKG-INFO’ ファイルに記録されます。

もう一つ追加されたキーワードパラメータ ‘download_url’ は、パッケージのソ
ースコードの URL をセットします。これによりパッケージインデクス内のエン
トリを探し出すことが出来、パッケージの依存性を決めることが出来、必要パッ
ケージをダウンロード出来ます:

     VERSION = '1.0'
     setup(name='PyPackage',
           version=VERSION,
           requires=['numarray', 'zlib (>=1.1.4)'],
           obsoletes=['OldPackage']
           download_url=('http://www.example.com/pypackage/dist/pkg-%s.tar.gz'
                         % VERSION),
          )

Python Package Index (‘https://pypi.org’) へのもう一つの新たな拡張は、パ
ッケージについてのソースコードとバイナリアーカイブの保存についてです。新
たな Distutils コマンド ‘upload’ は、レポジトリへパッケージをアップロー
ドします。

パッケージがアップロードされる前には、Distutils ‘sdist’ コマンドを使って
配布物をビルド可能でなければなりません。それさえ出来ていれば、 ‘python
setup.py upload’ がパッケージを PyPI アーカイブに追加してくれます。追加
で、パッケージに GPG 署名出来ます。これには ‘--sign’ オプションと
‘--identity’ オプションを使います。

パッケージのアップロードは Martin von Löwis と Richard Jones により実装
されました。

参考
....

PEP 314(1) - Metadata for Python Software Packages v1.1

     PEP 提案と著 A.M. Kuchling、 Richard Jones、 Fred Drake; 実装
     Richard Jones と Fred Drake.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0314/


File: python.info,  Node: PEP 328 絶対インポート、相対インポート,  Next: PEP 338 - モジュールをスクリプトとして実行する,  Prev: PEP 314 Metadata for Python Software Packages v1 1,  Up: What's New in Python 2 5

1.17.4 PEP 328: 絶対インポート、相対インポート
----------------------------------------------

The simpler part of PEP 328(1) was implemented in Python 2.4:
parentheses could now be used to enclose the names imported from a
module using the ‘from ... import ...’ statement, making it easier to
import many different names.

より複雑なほうは Python 2.5 で実装されました: モジュールのインポートにお
いて、それが絶対インポートなのかパッケージ相対のインポートなのかを指定出
来るようにする、というものです。将来のバージョンの Python では絶対インポ
ートをデフォルトにする方向に向かう予定です。

いま、あなたは以下のようなパッケージディレクトリを持っているとします:

     pkg/
     pkg/__init__.py
     pkg/main.py
     pkg/string.py

‘pkg’ パッケージがモジュール ‘pkg.main’ とサブモジュール ‘pkg.string’ を
持っています。

‘main.py’ のなかの人、になってみましょう。 ‘import string’ 文を実行する
と、何が起こるでしょうか?  Python 2.4 とそれ以前のバージョンでは、相対イ
ンポートとして実行するためにパッケージのディレクトリ内のものを最初に探し
、 ‘pkg/string.py’ を発見してそのファイル内容を ‘pkg.string’ モジュール
であるとしてインポートし、そのモジュールは ‘pkg.main’ モジュール内の名前
空間で、名前 ‘string’ に束縛されます。

よろしいでしょう。欲しいものが ‘pkg.string’ であるならば。ですが欲しいの
は Python 標準ライブラリモジュールの *note string: be. なのだとしたら?
‘pkg.string’ を無視して標準モジュールを探す綺麗な方法はありません; 一般
的に、 ‘sys.modules’ の中身から探す必要がありました。これはちょっとばか
り美しくありません。Holger Krekel の ‘py.std’ パッケージは標準ライブラリ
からモジュールをインポートするのに ‘import py; py.std.string.join()’ と
、よりこぎれいな方法を与えてくれますが、そのパッケージは全ての Python イ
ンストレーションでの利用が可能にはなっていません。

相対インポートに頼ったコードを読むことは、より不明瞭でもあります。読者は
*note string: be. と ‘pkg.string’ のどちらを使おうとしているのかについて
、混乱するだろうからです。Python ユーザはすぐに、彼らのパッケージのサブ
モジュール名が標準ライブラリモジュールの名前と被らないようにすることを学
びますが、あなたのサブモジュール名が将来のバージョンの Python に追加され
る新しいモジュールで使われる名前にならないようにすることは出来ません。

Python 2.5 では *note import: 5ac. の振る舞いを、 ‘from __future__
import absolute_import’ ディレクティブを使うことによって絶対インポートに
切り替えられます。この絶対インポートの振る舞いは将来バージョンの Python
でデフォルトになります(おそらく Python 2.7 で)。(訳注: ご承知のとおり
Python 2.7 でもこれはデフォルトとはなっていません。Python 3.x への移行の
ためにも 2.5 - 2.7 では ‘from __future__ import absolute_import’ を使う
べきです。) 絶対インポートをデフォルトにしてしまえば、 ‘import string’ は
いつでも標準ライブラリ版を見つけます。ユーザは可能な限り絶対インポートを
使い始めるべきで、あなたのコードでは ‘from pkg import string’ と書き始め
ることが望まれます。

相対インポートは、 ‘from ... import’ 形式を使う際にモジュール名の前にピ
リオドを付ければまだ可能です:

     # Import names from pkg.string
     from .string import name1, name2
     # Import pkg.string
     from . import string

これは現在のパッケージからの相対で *note string: be. モジュールをインポ
ートしますので、 ‘pkg.main’ 内ではこれは、 'name1' と 'name2' を
‘pkg.string’ からインポートするでしょう。加えて、先行する複数ピリオドは
、現在のパッケージの親からの相対インポートを実行します。例えば、 ‘A.B.C’
モジュール内のコードはこのように出来ます:

     from . import D                 # Imports A.B.D
     from .. import E                # Imports A.E
     from ..F import G               # Imports A.F.G

このピリオドによる書き方は ‘import modname’ 形式のインポート文では使えず
、 ‘from ... import’ 形式でのみ使えます。

参考
....

PEP 328(2) - マルチラインインポートと、絶対/相対インポート

     PEP 著 Aahz; 実装 Thomas Wouters。

‘https://pylib.readthedocs.io/’

     Holger Krekel による py ライブラリで、 ‘py.std’ パッケージを含みま
     す。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0328/

   (2) https://peps.python.org/pep-0328/


File: python.info,  Node: PEP 338 - モジュールをスクリプトとして実行する,  Next: PEP 341 try/except/finally の一体化,  Prev: PEP 328 絶対インポート、相対インポート,  Up: What's New in Python 2 5

1.17.5 PEP 338 - モジュールをスクリプトとして実行する
-----------------------------------------------------

Python 2.4 で追加されたモジュールをスクリプトとして実行するための *note
-m: 5ab. スイッチが、少し能力を高めました。Python インタプリタ内での C 実
装に代わり、これの実現には新しいモジュール *note runpy: ac. を使うように
なっています。

*note runpy: ac. モジュールはインポートのメカニズムをより洗練された方法
で実装しているので、今では ‘pychecker.checker’ のようにパッケージ内のモ
ジュールも実行出来ます。このモジュールは異なるインポートメカニズム、例え
ば *note zipimport: 118. モジュールもサポートします。このことにより、
‘sys.path’ に .zip アーカイブのパスを追加して、 *note -m: 5ab. スイッチ
でアーカイブ内のコードを実行する、といったことも出来ます。

参考
....

PEP 338(1) - モジュールをスクリプトとして実行する

     PEP 著と実装 Nick Coghlan.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0338/


File: python.info,  Node: PEP 341 try/except/finally の一体化,  Next: PEP 342 ジェネレータの新機能,  Prev: PEP 338 - モジュールをスクリプトとして実行する,  Up: What's New in Python 2 5

1.17.6 PEP 341: try/except/finally の一体化
-------------------------------------------

Until Python 2.5, the *note try: 6b4. statement came in two flavours.
You could use a *note finally: 997. block to ensure that code is always
executed, or one or more *note except: 170. blocks to catch specific
exceptions.  You couldn't combine both ‘except’ blocks and a ‘finally’
block, because generating the right bytecode for the combined version
was complicated and it wasn't clear what the semantics of the combined
statement should be.

Guido van Rossum はいくらかの時間 Java での作業に時間を割きました。それ
は *note except: 170. ブロックと *note finally: 997. ブロックを組み合わ
せるのと等価なものをサポートしています。そしてこの作業が、このステートメ
ントがどういう意味であるべきかを明らかにしたのです。Python 2.5 では、あ
なたは今ではこう書くことが出来ます:

     try:
         block-1 ...
     except Exception1:
         handler-1 ...
     except Exception2:
         handler-2 ...
     else:
         else-block
     finally:
         final-block

'block-1' 内のコードが実行されます。そのコードが例外を投げた場合、個々の
*note except: 170. ブロックがテストされます: その例外が ‘Exception1’ ク
ラスであれば、 'handler-1' が実行されます; そうでない場合で ‘Exception2’
クラスであれば、 'handler-2' が実行されます、以下同文。例外が起こらなけ
れば、 'else-block' が実行されます。

以前に何が起こったのかに拠らず、コードブロック完了時やどれかの例外が処理
されれば 'final-block' が実行されます。例外ハンドラ内や 'else-block' で
エラーが起こったり、 新しく例外を投げる場合でさえ、 'final-block' 内のコ
ードはそれでも実行されます。

参考
....

PEP 341(1) - try-except と try-finally を一体化する

     PEP 著 Georg Brandl; 実装 Thomas Lee。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0341/


File: python.info,  Node: PEP 342 ジェネレータの新機能,  Next: PEP 343 "with" ステートメント<2>,  Prev: PEP 341 try/except/finally の一体化,  Up: What's New in Python 2 5

1.17.7 PEP 342: ジェネレータの新機能
------------------------------------

Python 2.5 は、ジェネレータ 'に向けて' 値を渡すための単純な手段を追加し
ました。Python 2.3 でジェネレータが導入された時点ではジェネレータが出来
たのは出力だけでした。いったんジェネレータのコードが呼び出されてイテレー
タが作られたあとは、新しい情報をそのジェネレータ関数の再開位置に渡す手段
はありませんでした。ヤクザな解決法としては、ジェネレータがグローバル変数
を見るようにしたり、ミュータブルなオブジェクトを渡しておいて呼び出し元で
あとからそれを変更したり、といったものがありました。

基本的なジェネレータについて思い出してもらいましょう、単純な例はこんなで
す:

     def counter (maximum):
         i = 0
         while i < maximum:
             yield i
             i += 1

When you call ‘counter(10)’, the result is an iterator that returns the
values from 0 up to 9.  On encountering the *note yield: 99b. statement,
the iterator returns the provided value and suspends the function's
execution, preserving the local variables.  Execution resumes on the
following call to the iterator's *note next(): 7a3. method, picking up
after the ‘yield’ statement.

In Python 2.3, *note yield: 99b. was a statement; it didn't return any
value.  In 2.5, ‘yield’ is now an expression, returning a value that can
be assigned to a variable or otherwise operated on:

     val = (yield i)

戻り値に何かする際は、 *note yield: 99b. 式の周りには括弧は付けておいた
ほうがいいと思います、この例でのように。括弧はべつに必要はないのですが、
どんな場合に必要かを憶えるよりは、いつでも付けるのが簡単でしょう。

( PEP 342(1) がその規則を正確に説明していますが、それによると *note
yield: 99b. 式は、代入式で右辺のトップレベルにあるとき以外はいつも括弧を
付ける必要があります。つまり ‘val = yield i’ とは書けますが、 ‘val =
(yield i) + 12’ のように演算子があるときは括弧を使わなくてはいけません。
)

Values are sent into a generator by calling its ‘send(value)’ method.
The generator's code is then resumed and the *note yield: 99b.
expression returns the specified 'value'.  If the regular *note next():
7a3. method is called, the ‘yield’ returns *note None: 641.

以下は前のと同じ例ですが、内部カウンタの値の変更を許す修正をしました:

     def counter (maximum):
         i = 0
         while i < maximum:
             val = (yield i)
             # If value provided, change counter
             if val is not None:
                 i = val
             else:
                 i += 1

そしてカウンタ変更の例がこちらです:

     >>> it = counter(10)
     >>> print it.next()
     0
     >>> print it.next()
     1
     >>> print it.send(8)
     8
     >>> print it.next()
     9
     >>> print it.next()
     Traceback (most recent call last):
       File "t.py", line 15, in ?
         print it.next()
     StopIteration

*note yield: 99b. が *note None: 641. を返すことはよくあるのですから、そ
うなっていないかどうか必ずチェックしておくべきです。ジェネレータ関数を再
開するために使うメソッドが ‘send()’ しかないのだと確信してるのでない限り
、式の値をそのまま使ってはいけません。

ジェネレータには、 ‘send()’ のほかにも新しいメソッドが二つあります

   * ‘throw(type, value=None, traceback=None)’ はジェネレータ内で例外を
     投げるために使います; その例外はジェネレータの実行が停止したところ
     の *note yield: 99b. 式によって投げられます。

   * ‘close()’ はジェネレータ内で *note GeneratorExit: 136f. 例外を投げ
     てイテレートを終了させます。この例外を受け取ったジェネレータのコー
     ドは *note GeneratorExit: 136f. か *note StopIteration: bc8. を投げ
     なくてはいけません; この例外を捕捉して何かほかのことをしようとする
     のは規則違反であり、 *note RuntimeError: 17a. を引き起こします; 関
     数が何かほかの例外を投げると、その例外は呼び出し元に伝播します。
     ‘close()’ はジェネレータのガーベージコレクトによっても呼ばれます。

     *note GeneratorExit: 136f. が起こったときにクリーンアップ作業をする
     必要があるなら、 *note GeneratorExit: 136f. を捕捉するのではなく
     ‘try: ... finaly:’ するようお勧めします。

これらの変更の合わせ技で、ジェネレータは情報の一方的な生産者から、生産者
かつ消費者という存在に変貌を遂げたのです。

ジェネレータは 'コルーチン' という、より一般化された形式のサブルーチンに
もなります。サブルーチンは一カ所 (関数の冒頭) から入って別の一カ所
(*note return: 99c. 文) から出るだけですが、コルーチンはいろいろな場所
(*note yield: 99b. 文) から入ったり出たり再開したりできるのです。わたし
たちは Python でコルーチンを効果的に使うためのパターンを理解する必要があ
ります。

The addition of the ‘close()’ method has one side effect that isn't
obvious.  ‘close()’ is called when a generator is garbage-collected, so
this means the generator's code gets one last chance to run before the
generator is destroyed.  This last chance means that ‘try...finally’
statements in generators can now be guaranteed to work; the *note
finally: 997. clause will now always get a chance to run.  The syntactic
restriction that you couldn't mix *note yield: 99b. statements with a
‘try...finally’ suite has therefore been removed.  This seems like a
minor bit of language trivia, but using generators and ‘try...finally’
is actually necessary in order to implement the *note with: 59c.
statement described by PEP 343(2).  I'll look at this new statement in
the following section.

もう一つさらに深遠なこの変更の効果: 以前はジェネレータの ‘gi_frame’ 属性
は常にフレームオブジェクトでした。今では ‘gi_frame’ は、ジェネレータが使
い果たされた場合に ‘None’ になります。

参考
....

PEP 342(3) - 拡張されたジェネレータを用いたコルーチン

     PEP は Guido van Rossum と Phillip J. Eby によって書かれ、Phillip
     J.  Eby によって実装されました。コルーチンとしてのジェネレータの用
     法のいくつかの手が込んだ例が含まれています。

     この機能の初期バージョンは Raymond Hettinger による PEP 288(4) と
     Samuele Pedroni による PEP 325(5) で提案されました。

‘https://en.wikipedia.org/wiki/Coroutine’

     コルーチンに関する WikiPedia エントリ。

‘https://web.archive.org/web/20160321211320/http://www.sidhe.org/~dan/blog/archives/000178.html’

     Dan Sugalski による、Perl の視点からみたコルーチンの説明です。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0342/

   (2) https://peps.python.org/pep-0343/

   (3) https://peps.python.org/pep-0342/

   (4) https://peps.python.org/pep-0288/

   (5) https://peps.python.org/pep-0325/


File: python.info,  Node: PEP 343 "with" ステートメント<2>,  Next: PEP 352 例外の新スタイルクラス化,  Prev: PEP 342 ジェネレータの新機能,  Up: What's New in Python 2 5

1.17.8 PEP 343: "with" ステートメント
-------------------------------------

'*note with: 59c.' ステートメントは、以前なら後片付けが実行されるのを確
実にするために ‘try...finally’ ブロックを使ったであろうようなコードを、
より単純明快にします。このセクションでは、このステートメントの普通の使い
方を説明します。続くセクションでは実装の詳細を調べ、このステートメントと
ともに使うためにオブジェクトをどうやって書けば良いかをお見せします。

'*note with: 59c.' ステートメントは基本構造が以下となる新しい制御フロー
構造です:

     with expression [as variable]:
         with-block

The expression is evaluated, and it should result in an object that
supports the context management protocol (that is, has *note
__enter__(): 592. and *note __exit__(): 12ce. methods.

The object's *note __enter__(): 592. is called before 'with-block' is
executed and therefore can run set-up code.  It also may return a value
that is bound to the name 'variable', if given.  (Note carefully that
'variable' is 'not' assigned the result of 'expression'.)

After execution of the 'with-block' is finished, the object's *note
__exit__(): 12ce. method is called, even if the block raised an
exception, and can therefore run clean-up code.

Python 2.5 でこのステートメントを有効にするには、以下のディレクティブを
あなたのモジュールに追加する必要があります:

     from __future__ import with_statement

Python 2.6 ではこれは常に有効になります。

いくつかの Python 標準オブジェクトが既にコンテキスト管理プロトコルをサポ
ートしていて、 '*note with: 59c.' とともに使えます。ファイルオブジェクト
がその一例です:

     with open('/etc/passwd', 'r') as f:
         for line in f:
             print line
             ... more processing code ...

このステートメントが実行し終わったあかつきには、 'f' のファイルオブジェ
クトは、たとえ *note for: 2c9. ループが道半ばにして例外と成り果てても、
自動的にクローズされます。

     注釈: In this case, 'f' is the same object created by *note open():
     4e5, because *note __enter__(): 592. returns 'self'.

*note threading: d6. モジュールのロック・条件変数でも '*note with: 59c.'
ステートメントの恩恵にあずかれます:

     lock = threading.Lock()
     with lock:
         # Critical section of code
         ...

ブロックが実行される前にロックが獲得されて、ブロックが完了するやいなや必
ず解放されます。

*note decimal: 2e. モジュール内の新しい ‘localcontext()’ 関数は現在の
decimal のコンテキスト (計算の望みの精度と丸め特性をカプセル化しています
) を保存しておいてあとで元に戻すのを簡単にしてくれます:

     from decimal import Decimal, Context, localcontext

     # Displays with default precision of 28 digits
     v = Decimal('578')
     print v.sqrt()

     with localcontext(Context(prec=16)):
         # All code in this block uses a precision of 16 digits.
         # The original context is restored on exiting the block.
         print v.sqrt()

* Menu:

* コンテキストマネージャを書く: コンテキストマネージャを書く<2>.
* contextlib モジュール: contextlib モジュール<2>.


File: python.info,  Node: コンテキストマネージャを書く<2>,  Next: contextlib モジュール<2>,  Up: PEP 343 "with" ステートメント<2>

1.17.8.1 コンテキストマネージャを書く
.....................................

中身を紐解いてみれば、 '*note with: 59c.' ステートメントはけっこう入り組
んでいます。ほとんどの人にとっては、既存のオブジェクトを '‘with’' ととも
に使うだけのことでその詳細を知る必要は無いので、それで良いならこのセクシ
ョンの残りの部分は読み飛ばして結構です。新しいオブジェクトの作者は基礎と
なる実装の詳細について知る必要があるので、このまま読み進めるべきです。

コンテキスト管理プロトコルの高度な説明はこんなです:

   * The expression is evaluated and should result in an object called a
     "context manager".  The context manager must have *note
     __enter__(): 592. and *note __exit__(): 12ce. methods.

   * The context manager's *note __enter__(): 592. method is called.
     The value returned is assigned to 'VAR'. If no ‘'as VAR'’ clause is
     present, the value is simply discarded.

   * 'BLOCK' 内のコードが実行されます。

   * 'BLOCK' が例外を起こした場合、コンテキストマネージャの ‘__exit__’ メ
     ソッドが 3 つの引数とともに呼び出されます。これは例外の詳細です
     (‘type, value, traceback’, これは *note sys.exc_info(): 656. が返す
     値と同じで、例外が起こらなければ ‘None’ です)。そのメソッドの戻り値
     は例外を再送出するかどうかを制御します: 全ての偽の値ではその例外が
     再送出され、 ‘True’ では揉み消します。例外を揉み消すなど滅多なこと
     では欲しいと思わないでしょう。もしそうしてしまったら、 '*note with:
     59c.' ステートメントを含んだコードの作者は何か間違ったことが起こっ
     たことに決して気付かないですから。

   * If 'BLOCK' didn't raise an exception, the *note __exit__(): 12ce.
     method is still called, but 'type', 'value', and 'traceback' are
     all ‘None’.

例を通じて考えましょう。枝葉末節を含んだ完璧なコードを提示しようとは思い
ませんが、データベースのためにトランザクションをサポートするのに必要とな
るメソッドの書き方についてスケッチしてみようと思います。

(データベース用語に不慣れな方へ:データベースへの変更のセットは、トランザ
クションという単位でグループ化されています。トランザクションは「コミット
」される、その意味は、全ての変更がデータベースに書き込まれることです、も
しくは「ロールバック」される、この場合全ての変更が捨てられてデータベース
が変更されません、この 2 つのいずれかになりえます。詳しくはなにかデータ
ベースの著述を読んで下さい。)

データベース接続を表現するオブジェクトがあると仮定しましょう。私たちの目
標は、そのオブジェクトのユーザがこのように書けるようになることです:

     db_connection = DatabaseConnection()
     with db_connection as cursor:
         cursor.execute('insert into ...')
         cursor.execute('delete from ...')
         # ... more operations ...

トランザクションはブロック内のコードがつつがなく終了すればコミットし、例
外が発生すればロールバックすべきです。私が思い描いている
‘DatabaseConnection’ の基本的なインターフェイスはこんなです:

     class DatabaseConnection:
         # Database interface
         def cursor (self):
             "Returns a cursor object and starts a new transaction"
         def commit (self):
             "Commits current transaction"
         def rollback (self):
             "Rolls back current transaction"

The *note __enter__(): 592. method is pretty easy, having only to start
a new transaction.  For this application the resulting cursor object
would be a useful result, so the method will return it.  The user can
then add ‘as cursor’ to their '*note with: 59c.' statement to bind the
cursor to a variable name.

     class DatabaseConnection:
         ...
         def __enter__ (self):
             # Code to start a new transaction
             cursor = self.cursor()
             return cursor

The *note __exit__(): 12ce. method is the most complicated because it's
where most of the work has to be done.  The method has to check if an
exception occurred.  If there was no exception, the transaction is
committed.  The transaction is rolled back if there was an exception.

下記のコード内では実行がメソッドの末尾まで落ちていって、なのでデフォルト
の ‘None’ 返却になります。 ‘None’ は偽なので、例外は自動的に再送出されま
す。望むならもっと明示的に、コメントでマークした部分で *note return:
99c. 文を書いてもよろしいです:

     class DatabaseConnection:
         ...
         def __exit__ (self, type, value, tb):
             if tb is None:
                 # No exception, so commit
                 self.commit()
             else:
                 # Exception occurred, so rollback.
                 self.rollback()
                 # return False


File: python.info,  Node: contextlib モジュール<2>,  Prev: コンテキストマネージャを書く<2>,  Up: PEP 343 "with" ステートメント<2>

1.17.8.2 contextlib モジュール
..............................

新しい *note contextlib: 1c. モジュールは、 '*note with: 59c.' ステート
メントで使えるオブジェクトを書く際に便利ないくつかの関数とデコレータを提
供しています。

The decorator is called ‘contextmanager()’, and lets you write a single
generator function instead of defining a new class.  The generator
should yield exactly one value.  The code up to the *note yield: 99b.
will be executed as the *note __enter__(): 592. method, and the value
yielded will be the method's return value that will get bound to the
variable in the '*note with: 59c.' statement's ‘as’ clause, if any.  The
code after the *note yield: 99b. will be executed in the *note
__exit__(): 12ce. method.  Any exception raised in the block will be
raised by the ‘yield’ statement.

このデコレータを使って、前セクションの私たちのデータベースの例はこのよう
に書けます:

     from contextlib import contextmanager

     @contextmanager
     def db_transaction (connection):
         cursor = connection.cursor()
         try:
             yield cursor
         except:
             connection.rollback()
             raise
         else:
             connection.commit()

     db = DatabaseConnection()
     with db_transaction(db) as cursor:
         ...

*note contextlib: 1c. モジュールには ‘nested(mgr1, mgr2, ...)’ 関数もあ
り、この関数はたくさんのコンテキストマネージャを組み合わせることができて
、入れ子の '*note with: 59c.' を書く必要性をなくしてくれます。この例では
、単一の '‘with’' でデータベーストランザクション開始とスレッドのロック獲
得の両方をやってのけています:

     lock = threading.Lock()
     with nested (db_transaction(db), lock) as (cursor, locked):
         ...

最後になりますが、 ‘closing(object)’ 関数は 'object' をそのまま返して変
数に束縛出来るようにし、かつブロックの終了で、与えた引数が持つ
‘object.close’ を呼び出します:

     import urllib, sys
     from contextlib import closing

     with closing(urllib.urlopen('http://www.yahoo.com')) as f:
         for line in f:
             sys.stdout.write(line)

参考
....

PEP 343(1) - "with" ステートメント

     PEP は Guido van Rossum と Nick Coghlan によって書かれ、Mike Bland、
     Guido van Rossum、Neal Norwitz により実装されました。この PEP は
     '*note with: 59c.' ステートメントによって生成されるコードを見せてく
     れるので、このステートメントがどうやって動作するのかを知るのに役立
     ちます。

*note contextlib: 1c. モジュールについてのドキュメント。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0343/


File: python.info,  Node: PEP 352 例外の新スタイルクラス化,  Next: PEP 353 添え字型に ssize_t を使う,  Prev: PEP 343 "with" ステートメント<2>,  Up: What's New in Python 2 5

1.17.9 PEP 352: 例外の新スタイルクラス化
----------------------------------------

例外クラスは、今では旧スタイルクラスだけではなく新スタイルクラスになれま
す。組み込みの *note Exception: 9a7. クラスと全ての標準組み込み例外
(*note NameError: 40b, *note ValueError: 1e3, など) が今では新スタイルク
ラスです。

例外の継承階層が少し再編成されました。2.5 では継承関係はこのようになって
います (--訳注: 2.6 ではさらに GeneratorExit が Exception ではなく
BaseExceotion の直接の子になり、これは 3.x でも引き継がれています。--):

     BaseException       # New in Python 2.5
     |- KeyboardInterrupt
     |- SystemExit
     |- Exception
        |- (all other current built-in exceptions)

この再編成が行われたのは、人々がしばしばプログラムのエラーを示す例外すべ
てを捕捉したがるからです。 *note KeyboardInterrupt: 99f. と *note
SystemExit: d0e. はエラーではありませんが、普通は ‘Control-C’ をユーザが
叩いたか、コードが *note sys.exit(): 1318. を呼び出したかのような明示的
なアクションを表します。剥き出しの ‘except:’ はまさに全ての例外を捕捉し
ますから、一般に、再送出のために *note KeyboardInterrupt: 99f. と *note
SystemExit: d0e. はリストする必要があります。お決まりのパターンはこんな
です:

     try:
         ...
     except (KeyboardInterrupt, SystemExit):
         raise
     except:
         # Log error...
         # Continue running program...

Python 2.5 では同じ結果を得るのにもう ‘except Exception’ と書いても良い
です。これは普通はエラーを示す例外全てを捕捉しつつも *note
KeyboardInterrupt: 99f. と *note SystemExit: d0e. は置き去りにします。無
論かつてまでのバージョン同様、剥き身の ‘except:’ は全例外を捕捉します。

Python 3.0 での目標は、例外として raise される全てのクラスが *note
BaseException: 584. からの、もしくは *note BaseException: 584. のある子
孫であることを要求することであり、Python 2.x シリーズの将来のリリースに
おいてはこの制約の強制を始めるかもしれません。ですからあなたの全ての例外
は、今からすぐに *note Exception: 9a7. 派生にするのが肝要です。捕捉例外
を特定しない ‘except:’ は Python 3.0 から取り除かれるべきであることが提
案されていますが、Guido van Rossum はこれをどうするかまだ決めていません
。 (--訳注: 2.7 では raise は「新スタイルクラスであれば」 *note
BaseException: 584. 派生であることを要求されますが、旧スタイルクラスであ
ればなんでも許されてしまう点ではあまり変わっていません。これについての警
告は ‘-3’ などで受けることが出来ます。Python 3.0 でようやく全ての例外が
*note BaseException: 584. 派生であることが強制されるようになりました。 ま
た、 ‘except:’ は 3.4 でも残っています。--)

例外として文字列を ‘raise "Error occurred"’ として raise することは
Python 2.5 では非推奨であり警告を引き起こします。その目的は、あと少しの
リリースで文字列例外を削除することです。 (--訳注: 2.6 以降の What's New
では明示的に書かれてはいませんが、2.7 では警告ではなくエラーです。--)

参考
....

PEP 352(1) - 例外のためのスーパークラス

     PEP 著: Brett Cannon と Guido van Rossum; 実装: Brett Cannon.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0352/


File: python.info,  Node: PEP 353 添え字型に ssize_t を使う,  Next: PEP 357 '__index__' メソッド,  Prev: PEP 352 例外の新スタイルクラス化,  Up: What's New in Python 2 5

1.17.10 PEP 353: 添え字型に ssize_t を使う
------------------------------------------

A wide-ranging change to Python's C API, using a new *note Py_ssize_t:
a2e. type definition instead of int, will permit the interpreter to
handle more data on 64-bit platforms.  This change doesn't affect
Python's capacity on 32-bit platforms.

Various pieces of the Python interpreter used C's int type to store
sizes or counts; for example, the number of items in a list or tuple
were stored in an int.  The C compilers for most 64-bit platforms still
define int as a 32-bit type, so that meant that lists could only hold up
to ‘2**31 - 1’ = 2147483647 items.  (There are actually a few different
programming models that 64-bit C compilers can use - see
‘https://unix.org/version2/whatsnew/lp64_wp.html’ for a discussion - but
the most commonly available model leaves int as 32 bits.)

2147483647 に要素数が制限されることは 32 ビットプラットフォームではあま
り重大でもありません。その長さ制限を喰らう前にメモリを使い果たすでしょう
から。それぞれのリストアイテムは、ポインタのための領域 (4 バイト) をアイ
テムを表現する *note PyObject: 312. に余分に必要とします。2147483647*4 は
既に 32 ビットのアドレス空間が含められるバイト数を超えています。(--訳注:
意味不明。何か誤解があるような…?  4 バイトは 2147483647 (符号付きとして
2^31 - 1) でしょう。4 を掛ける説明なんかここでまったくされていない。なぜ
掛ける?  それと要素のインデクシングとアイテムの必要領域は議論には無関係
なのでは?--)

It's possible to address that much memory on a 64-bit platform, however.
The pointers for a list that size would only require 16 GiB of space, so
it's not unreasonable that Python programmers might construct lists that
large.  Therefore, the Python interpreter had to be changed to use some
type other than int, and this will be a 64-bit type on 64-bit platforms.
The change will cause incompatibilities on 64-bit machines, so it was
deemed worth making the transition now, while the number of 64-bit users
is still relatively small.  (In 5 or 10 years, we may 'all' be on 64-bit
machines, and the transition would be more painful then.)

この変更は C 拡張モジュールの著者に大変大きく影響します。Python 文字列と
リストやタプルのようなコンテナ型は、そのサイズを表すのに *note
Py_ssize_t: a2e. を使うようになっています。 *note PyList_Size(): 13c1. の
ような関数は *note Py_ssize_t: a2e. を返します。拡張モジュール内のコード
では、ですので、ある程度の変数の *note Py_ssize_t: a2e. への変更が必要で
しょう。

The *note PyArg_ParseTuple(): 53d. and *note Py_BuildValue(): 875.
functions have a new conversion code, ‘n’, for *note Py_ssize_t: a2e.
*note PyArg_ParseTuple(): 53d.'s ‘s#’ and ‘t#’ still output int by
default, but you can define the macro ‘PY_SSIZE_T_CLEAN’ before
including ‘Python.h’ to make them return *note Py_ssize_t: a2e.

PEP 353(1) には、拡張の著者が読んで学ぶべき 64 ビットプラットフォームサ
ポートについてのセクションがあります。

参考
....

PEP 353(2) - 添え字型に ssize_t を使う

     PEP 著と実装 Martin von Löwis.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0353/

   (2) https://peps.python.org/pep-0353/


File: python.info,  Node: PEP 357 '__index__' メソッド,  Next: その他の言語変更<14>,  Prev: PEP 353 添え字型に ssize_t を使う,  Up: What's New in Python 2 5

1.17.11 PEP 357: '__index__' メソッド
-------------------------------------

NumPy 開発者たちは、新しい特殊メソッド、 ‘__index__()’ を追加することに
よってしか解決できない問題を抱えていました。スライスの表現
‘[start:stop:step]’ を使う際、 'start', 'stop', 'step' は全て整数か長整
数でなければなりません。NumPy は様々な特殊化された整数型を持っていて、符
号なし、符号付きの 8、16、32、64 ビットに対応していますが、それらをスラ
イスの添え字に使う手段はありませんでした。

スライシングに既存の ‘__int__()’ メソッドをそのまま使うことは出来ません
。それらは整数への型変換を実装するのにも使われるからです。スライシングが
‘__int__()’ を使ったとすれば、浮動小数点数でさえスライスの添え字として使
うことが合法になりますが、それは明らかに望む振る舞いではありません。

その代わりに新しい特殊メソッド ‘__index__()’ が追加されました。これは引
数を取らずに、スライスの添え字として使われる整数を返します。例えば:

     class C:
         def __index__ (self):
             return self.value

戻り値は Python 整数または長整数でなければなりません。インタプリタは戻り
値が正しいかどうかをチェックし、要求に合わない場合に *note TypeError:
502. を送出します。

A corresponding *note nb_index: 13c4. slot was added to the C-level
*note PyNumberMethods: 13c5. structure to let C extensions implement
this protocol.  ‘PyNumber_Index(obj)’ can be used in extension code to
call the ‘__index__()’ function and retrieve its result.

参考
....

PEP 357(1) - スライシングのために任意のオブジェクトを使えるようにする

     PEP 著と実装 Travis Oliphant.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0357/


File: python.info,  Node: その他の言語変更<14>,  Next: 新たなモジュール、改良されたモジュール、削除されたモジュール,  Prev: PEP 357 '__index__' メソッド,  Up: What's New in Python 2 5

1.17.12 その他の言語変更
------------------------

以下が、Python 2.5 言語コアに加えられた全ての変更点です。

   * *note dict: 237. 型に新たなフックが追加されています。サブクラスが、
     辞書に含まれないキーに対してデフォルトを提供出来るようにするもので
     す。キーが見つからない場合、辞書の ‘__missing__(key)’ メソッドが呼
     ばれます。このフックは *note collections: 16. モジュール内の新しい
     クラス ‘defaultdict’ で使われています。続く例は存在しないキーに対し
     てゼロを返す辞書を定義しています:

          class zerodict (dict):
              def __missing__ (self, key):
                  return 0

          d = zerodict({1:1, 2:2})
          print d[1], d[2]   # Prints 1, 2
          print d[3], d[4]   # Prints 0, 0

   * 8 ビット文字列、Unicode ともに、ありがちなユースケースを単純化する
     ‘partition(sep)’ と ‘rpartition(sep)’ が追加されました。

     文字列のスライスに使うために ‘find(S)’ メソッドを使ってインデクスを
     得るのだけれども、やりたいのはそのセパレータ(S)の前後の部分文字列を
     得ることだ、といったことはしょっちゅう必要になります。
     ‘partition(sep)’ はこのパターンのコードを、一撃、に圧縮してくれます
     。これはセパレータ前の部分文字列、セパレータ自身、セパレータ後の部
     分文字列の 3 要素タプルを返します。セパレータが含まれない場合は、返
     却値の最初の要素に文字列全体が、残り2つは空文字列で返ります。
     ‘rpartition(sep)’ もほぼ同じことをしますがセパレータの検索をお尻か
     ら始めます。 ‘r’ は逆順('reverse')を表します。

     いくつかの例です:

          >>> ('http://www.python.org').partition('://')
          ('http', '://', 'www.python.org')
          >>> ('file:/usr/share/doc/index.html').partition('://')
          ('file:/usr/share/doc/index.html', '', '')
          >>> (u'Subject: a quick question').partition(':')
          (u'Subject', u':', u' a quick question')
          >>> 'www.python.org'.rpartition('.')
          ('www.python', '.', 'org')
          >>> 'www.python.org'.rpartition(':')
          ('', '', 'www.python.org')

     (Implemented by Fredrik Lundh following a suggestion by Raymond
     Hettinger.)

   * 文字列型の ‘startswith()’ と ‘endswith()’ メソッドが、チェックされ
     る文字列のタプルを受け容れるようになりました:

          def is_image_file (filename):
              return filename.endswith(('.gif', '.jpg', '.tiff'))

     (Implemented by Georg Brandl following a suggestion by Tom Lynn.)

   * ビルトイン関数 *note min(): ed3. と *note max(): ed4. に、 ‘sort()’
     における ‘key’ に似たキーワード引数 ‘key’ が追加されました。このパ
     ラメータには関数を与えます。これは一つの引数を取り、リスト内の全て
     の値に対して呼び出されます; *note min(): ed3./*note max(): ed4. は
     この関数を全要素に適用したもののなかでの最小値/最大値を返します。例
     えば、リスト中の最長の文字列を探すにはこのように出来ます:

          L = ['medium', 'longest', 'short']
          # Prints 'longest'
          print max(L, key=len)
          # Prints 'short', because lexicographically 'short' has the largest value
          print max(L)

     (Contributed by Steven Bethard and Raymond Hettinger.)

   * 2 つの新たなビルトイン関数 *note any(): 13c8. と *note all(): 13c9.
     は、イテレータがいくつか真を含むかどうかを評価します。 *note any():
     13c8. はイテレータのいずれかが返す値が真と評価される場合に *note
     True: bdb. を返し、そうでなければ *note False: b05. を返します。
     *note all(): 13c9. はイテレータが返す値の評価が真のみの場合に *note
     True: bdb. を返します。 (Suggested by Guido van Rossum, and
     implemented by Raymond Hettinger.)

   * クラスの ‘__hash__()’ メソッドが返す値として、長整数と整数のどちら
     でも良くなりました。長整数が返されれば、その値のハッシュから取られ
     ます。以前のバージョンではこれは普通の整数であることが要求されてい
     ましたが、2.5 ではビルトイン関数 *note id(): 13ca. が変更されて常に
     非負数が返り、ユーザはしばしば ‘__hash__()’ 内で ‘id(self)’ を使う
     ようです (これはお奨めしませんが)。 (--訳注: 不思議な論法で意味がわ
     かりません。id が非負を返すとなぜユーザは __hash__ の実装に使おうと
     するのか?  ユーザがそれをしてしまうのは単にデフォルト実装がそうだか
     ら、というだけではないかと思います。__cmp__, __eq__ が「身元」以外
     の意味を使って比較を行うならば、 __cmp__ で id を使うのはシンプルに
     「ダメ」でしょう。-)

   * モジュールのデフォルトエンコーディングが ASCII になりました(訳注:
     Python 3 からはデフォルトは utf-8 (PEP 3120))。8 ビット文字を含んで
     いるのにエンコーディング宣言がないモジュールが構文エラーになるよう
     になりました。Python 2.4 では構文エラーとはならず警告でした。モジュ
     ールのエンコーディングをする方法については PEP 263(1) を参照してく
     ださい; 例えば、ソースコードの先頭付近にこのような行を追加すること
     で出来ます:

          # -*- coding: latin1 -*-

   * Unicode 文字列とデフォルトの ASCII エンコーディングで Unicode に変
     換出来ない 8 ビット文字列との比較を試みると、新しい警告 *note
     UnicodeWarning: 13cb. が引き起こされるようになっています。比較結果
     は偽です:

          >>> chr(128) == unichr(128)   # Can't convert chr(128) to Unicode
          __main__:1: UnicodeWarning: Unicode equal comparison failed
            to convert both arguments to Unicode - interpreting them
            as being unequal
          False
          >>> chr(127) == unichr(127)   # chr(127) can be converted
          True

     以前はこれは *note UnicodeDecodeError: 9e1. を起こしていましたので
     、2.5 でのこれは辞書のアクセス時に悩ましい問題をもたらしました。キ
     ーとして使われている ‘unichr(128)’ や ‘chr(128)’ を探そうとすると
     *note UnicodeDecodeError: 9e1. 例外が起こっていたでしょう。2.5 での
     、 辞書を実装している ‘dictobject.c’ のほかの変更により、これは揉み
     消すのではなく、引き続き例外を起こします(訳注: 原文では this
     exception といっているので *note UnicodeDecodeError: 9e1. が起こる
     ように読めるのですが、2.5 時点での振る舞いは確認出来ていませんが
     2.7 では *note UnicodeWarning: 13cb. とともに *note KeyError: 31d.
     が発生する、のようになるはずです。2.6 以降の What's New でのこれに
     関する言及はありませんが変更があったのかもしれません)。

     この種の比較で例外を起こすのは完全に正しいことではあるものの、その
     変更はコードを破壊するかもしれないので、必要に応じて警告に出来るよ
     う導入されたのが *note UnicodeWarning: 13cb. です。

     (Implemented by Marc-André Lemburg.)

   * Python プログラマがよくしでかす間違いとして、パッケージディレクトリ
     に ‘__init__.py’ を入れ忘れる、というものがあります。この間違いのデ
     バッグはややこしく、大抵 Python を *note -v: 13cc. スイッチ付きで起
     動して、パス検索全てをログ出力するハメになります。Python 2.5 ではパ
     ッケージディレクトリに ‘__init__.py’ がないことが検出されると新たに
     *note ImportWarning: 4c7. 警告を出すようになりました。デフォルトで
     はこの警告は黙って無視されます; これを出したければ、 *note -Wd:
     896. スイッチをつけて Python を起動してください。(Implemented by
     Thomas Wouters.)

   * クラス定義において、基底クラスのリストを空リストに出来るようになっ
     ています(訳注: object を派生しないので結果として旧スタイルクラスに
     なります)。例えば以下は今や合法です:

          class C():
              pass

     (Implemented by Brett Cannon.)

* Menu:

* 対話的なインタプリタの変更::
* 最適化: 最適化<13>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0263/


File: python.info,  Node: 対話的なインタプリタの変更,  Next: 最適化<13>,  Up: その他の言語変更<14>

1.17.12.1 対話的なインタプリタの変更
....................................

対話的なインタプリタ内では、 ‘quit’ と ‘exit’ はずっと、立ち去ろうと
(quit しようと)試みてそうタイプしてしまうユーザにとってある種有用な文字
列になっていました:

     >>> quit
     'Use Ctrl-D (i.e. EOF) to exit.'

Python 2.5 でも ‘quit’ と ‘exit’ はそれ自身そのような文字列を生成はしま
すが、同時に「呼び出す」ことが出来るオブジェクトになっています。初心者が
思わず ‘quit()’ や ‘exit()’ してしまった場合、今では彼らが期待する通りに
インタプリタが終了します。 (Implemented by Georg Brandl.)

Python 実行形式ファイルが標準的な長い形式の *note -help: 5ba. と *note
-version: ce9. を受け付けるようになりました。Windows の場合はヘルプメッ
セージを出力するのに *note /?: 13cf. オプションも受け付けます。
(Implemented by Georg Brandl.)


File: python.info,  Node: 最適化<13>,  Prev: 対話的なインタプリタの変更,  Up: その他の言語変更<14>

1.17.12.2 最適化
................

この最適化のいくつかは、2006年5月21日から28日にかけてアイスランドのレイ
キャビクで開催されたイベント、NeedForSpeed sprintで開発されました。この
スプリントはCPythonの実装のスピードアップに焦点を当て、EWT LLCが資金を提
供し、CCP Gamesが現地でサポートしました。 このスプリントで追加された最適
化については、以下のリストで特別にマークしています。

   * Python 2.4 が導入されたとき、組み込みの *note set: 5a3. と *note
     frozenset: 5a4. 型は Python の辞書型の上に構築されたものでした。
     Python 2.5 では、内部データ構造がセットを実装するためにカスタマイズ
     され、その結果、セットのメモリ使用量は3分の1になり、多少高速化され
     ました。(Raymond Hettinger による実装。)

   * 部分文字列の検索、文字列の分割、文字マップのエンコードとデコードな
     ど、いくつかの Unicode 操作の速度が改善されました。 (部分文字列の検
     索と分割は、NeedForSpeed スプリントで Fredrik Lundh と Andrew Dalke
     が追加しました。部分文字列の検索と分割の改良は、NeedForSpeed
     sprintでFredrik LundhとAndrew Dalkeによって追加されました。文字マッ
     プは Walter Dörwald と Martin von Löwis によって改善されました。)

   * The ‘long(str, base)’ function is now faster on long digit strings
     because fewer intermediate results are calculated.  The peak is for
     strings of around 800-1000 digits where the function is 6 times
     faster.  (Contributed by Alan McIntyre and committed at the
     NeedForSpeed sprint.)

   * It's now illegal to mix iterating over a file with ‘for line in
     file’ and calling the file object's ‘read()’/*note readline():
     a8./‘readlines()’ methods.  Iteration uses an internal buffer and
     the ‘read*()’ methods don't use that buffer.  Instead they would
     return the data following the buffer, causing the data to appear
     out of order.  Mixing iteration and these methods will now trigger
     a *note ValueError: 1e3. from the ‘read*()’ method.  (Implemented
     by Thomas Wouters.)

   * The *note struct: c0. module now compiles structure format strings
     into an internal representation and caches this representation,
     yielding a 20% speedup.  (Contributed by Bob Ippolito at the
     NeedForSpeed sprint.)

   * *note re: a7. モジュールは、システムの ‘malloc()’ と ‘free()’ の代
     わりに Python のアロケータ関数に切り替えることで、1～2%のスピードア
     ップを達成しました。(NeedForSpeed sprintにてJack Diederichによるコ
     ントリビュート)

   * コードジェネレータの peephole オプティマイザは式の中で簡単な定数の
     折りたたみを実行するようになりました。 ‘a = 2+3’ のように書くと、コ
     ードジェネレータは算術演算を行い、 ‘a = 5’ に対応するコードを生成し
     ます。 (Raymond Hettinger による提案と実装。)

   * Function calls are now faster because code objects now keep the
     most recently finished frame (a "zombie frame") in an internal
     field of the code object, reusing it the next time the code object
     is invoked.  (Original patch by Michael Hudson, modified by Armin
     Rigo and Richard Jones; committed at the NeedForSpeed sprint.)
     Frame objects are also slightly smaller, which may improve cache
     locality and reduce memory usage a bit.  (Contributed by Neal
     Norwitz.)

   * Python's built-in exceptions are now new-style classes, a change
     that speeds up instantiation considerably.  Exception handling in
     Python 2.5 is therefore about 30% faster than in 2.4.  (Contributed
     by Richard Jones, Georg Brandl and Sean Reifschneider at the
     NeedForSpeed sprint.)

   * Importing now caches the paths tried, recording whether they exist
     or not so that the interpreter makes fewer ‘open()’ and ‘stat()’
     calls on startup.  (Contributed by Martin von Löwis and Georg
     Brandl.)


File: python.info,  Node: 新たなモジュール、改良されたモジュール、削除されたモジュール,  Next: ビルドならびに C API の変更<10>,  Prev: その他の言語変更<14>,  Up: What's New in Python 2 5

1.17.13 新たなモジュール、改良されたモジュール、削除されたモジュール
--------------------------------------------------------------------

標準ライブラリは Python 2.5 で数多くの拡張とバグフィックスを行っています
。ここでは注目に値する変更をモジュール名の辞書順で列挙します。変更につい
てのもっと完全なリストが見たければソースツリーの ‘Misc/NEWS’ を調べるか
、全ての詳細について SVN ログに目を通してみてください。

   * The ‘audioop’ module now supports the a-LAW encoding, and the code
     for u-LAW encoding has been improved.  (Contributed by Lars
     Immisch.)

   * *note codecs: 14. モジュールに漸増的コーデックのサポートが追加され
     ています。 ‘codec.lookup()’ 関数がタプルではなく ‘CodecInfo’ を返す
     ようになっています。 ‘CodecInfo’ のインスタンスは後方互換性を維持す
     るために 4 要素タプルのように振舞うだけでなく、属性 ‘encode’,
     ‘decode’, ‘incrementalencoder’, ‘incrementaldecoder’,
     ‘streamwriter’, ‘streamreader’ を持ちます。漸増的コーデックは入力を
     受け取って出力するのを複数チャンクに分けて行えます; 出力は非漸増的
     コーデックに一回で入力全体を渡したものと同じになります。詳細は
     *note codecs: 14. モジュールのドキュメントを参照して下さい。
     (Designed and implemented by Walter Dörwald.)

   * *note collections: 16. モジュールに新たに追加された ‘defaultdict’ 型
     は、標準 *note dict: 237. のサブクラスです。この新しい型はほとんど
     辞書と同じに振る舞い、ただし、キーを要求された際にそのキーが存在し
     ていなかった場合に、自動的に辞書にデフォルト値を追加します。

     ‘defaultdict’ のコンストラクタの最初の引数は、キーが要求されて存在
     しない場合に呼び出されるファクトリ関数です。ファクトリ関数は引数を
     取りません。つまりこれに該当する *note list(): 5dc. や *note int():
     238. のようなビルトイン型のコンストラクタも使えます。例えば、その頭
     文字を基準に語の索引をこのように作ることが出来ます:

          words = """Nel mezzo del cammin di nostra vita
          mi ritrovai per una selva oscura
          che la diritta via era smarrita""".lower().split()

          index = defaultdict(list)

          for w in words:
              init_letter = w[0]
              index[init_letter].append(w)

     ‘index’ を出力するとこんな具合です:

          defaultdict(<type 'list'>, {'c': ['cammin', 'che'], 'e': ['era'],
                  'd': ['del', 'di', 'diritta'], 'm': ['mezzo', 'mi'],
                  'l': ['la'], 'o': ['oscura'], 'n': ['nel', 'nostra'],
                  'p': ['per'], 's': ['selva', 'smarrita'],
                  'r': ['ritrovai'], 'u': ['una'], 'v': ['vita', 'via']}

     (Contributed by Guido van Rossum.)

   * *note collections: 16. モジュールで提供されている両端キュー
     (double-ended queue) 型 ‘deque’ に、キュー内で最初に現れる 'value'
     を削除するメソッド ‘remove(value)’ メソッドが追加されています。
     'value' が見つからなければ *note ValueError: 1e3. が送出されます。
     (Contributed by Raymond Hettinger.)

   * 新規モジュール: *note contextlib: 1c. モジュールには '*note with:
     59c.' ステートメントで使えるヘルパ関数が含まれています。詳細は
     *note contextlib モジュール: 13bb. をみてください。

   * 新規モジュール: *note cProfile: 20. モジュールは既存の *note
     profile: 9d. モジュールの C 実装で、遥かに小さなオーバヘッドで実行
     出来ます。モジュールのインターフェイスは *note profile: 9d. と同じ
     です: 関数をプロファイルするのには ‘cProfile.run('main()')’ と実行
     し、プロファイル結果をファイルに書き出すなど出来ます。これは
     Hotshot プロファイラとして知られるものではないですが (これも C で書
     かれてますが *note profile: 9d. モジュールのインターフェイスとは別
     物です)、将来バージョンの Python で保守が続けられる予定です。
     (Contributed by Armin Rigo.)

     また、プロファイラによる計測データの解析のための *note pstats: 9e.
     モジュールが、 ‘Stats’ コンストラクタの 'stream' 引数による直接ファ
     イル出力に対応しました。 (Contributed by Skip Montanaro.)

   * The *note csv: 21. module, which parses files in comma-separated
     value format, received several enhancements and a number of
     bugfixes.  You can now set the maximum size in bytes of a field by
     calling the ‘csv.field_size_limit(new_limit)’ function; omitting
     the 'new_limit' argument will return the currently set limit.  The
     ‘reader’ class now has a ‘line_num’ attribute that counts the
     number of physical lines read from the source; records can span
     multiple physical lines, so ‘line_num’ is not the same as the
     number of records read.

     CSV パーサは引用符内のマルチラインをより厳密に扱うようになっていま
     す。以前は、引用符で囲まれたフィールドが改行文字(newline)で終了する
     ことなく終端すると、改行文字が返却フィールドに追加されていました。
     この振る舞いはフィールドに復帰文字(carriage return)を含んだファイル
     を読み込む際に問題だったため、改行文字を挿入することなくフィールド
     を返すように変更されました。このことにより、フィールド内に埋め込ま
     れた改行文字が重要な場合、入力は改行文字が保存される方法で行分割さ
     れるはずです。(--訳注: リファレンスも含めこの説明の表現がわかりにく
     いです。行指向で読み込む場合改行コードのモード(NL, CR NL, CR)依存で
     「物理行が終了した」とみなされるわけですが、このモード依存(CR 時)の
     振る舞いがなくなった、ということです。--)

     (Contributed by Skip Montanaro and Andrew McNamara.)

   * The *note datetime: 1ae. class in the *note datetime: 28. module
     now has a ‘strptime(string, format)’ method for parsing date
     strings, contributed by Josh Spoerri.  It uses the same format
     characters as *note time.strptime(): 13d4. and *note
     time.strftime(): 11ba.:

          from datetime import datetime

          ts = datetime.strptime('10:13:15 2006-03-07',
                                 '%H:%M:%S %Y-%m-%d')

   * *note difflib: 2f. モジュールのメソッド
     ‘SequenceMatcher.get_matching_blocks()’ が、合致するサブシーケンス
     を記述するブロックについて、最小範囲リストを返すよう保障するように
     なりました。以前は時折 2 つのリストエントリに合致要素ブロックが分割
     されることがありました。(Enhancement by Tim Peters.)

   * *note doctest: 31. モジュールに、実行されるべきものから例を守る
     ‘SKIP’ オプションが追加されています。これは、読者のための使用例とし
     て意図しているけれども実際のテストケースとして意図していないような
     コードスニペットのために用意されました。

     ‘testfile()’ 関数と ‘DocFileSuite’ にファイルのエンコーディングを指
     定するための 'encoding' パラメータが追加されました。これにより
     docstring 内に非 ASCII 文字列を含むテストが簡単になります。
     (Contributed by Bjorn Tillenius.)

   * *note email: 32. パッケージがバージョン 4.0 にアップデートされまし
     た (Contributed by Barry Warsaw.)

   * The *note fileinput: 51. module was made more flexible.  Unicode
     filenames are now supported, and a 'mode' parameter that defaults
     to ‘"r"’ was added to the *note input(): 12a6. function to allow
     opening files in binary or *note universal newlines: d08. mode.
     Another new parameter, 'openhook', lets you use a function other
     than *note open(): 4e5. to open the input files.  Once you're
     iterating over the set of files, the ‘FileInput’ object's new *note
     fileno(): 13d5. returns the file descriptor for the currently
     opened file.  (Contributed by Georg Brandl.)

   * *note gc: 56. モジュールに、新しい関数 ‘get_count()’ が追加されてい
     ます。これは GC 3 世代についての現在の検出を含む 3 要素タプルを返し
     ます。これはガーベージコレクタの決算情報です; これらの数が指定され
     た閾値に到達すると、ガーベージコレクトのスイープが起こります。既存
     の *note gc.collect(): a08. 関数は省略可能な 'generation' 引数を取
     るようになっていて、これはどの世代を検出するかを指定する 0、1、2 で
     す。 (Contributed by Barry Warsaw.)

   * *note heapq: 5f. モジュールの ‘nsmallest()’ 関数と ‘nlargest()’ 関
     数がキーワードパラメータ ‘key’ をサポートするようになっています。こ
     れは *note min(): ed3./*note max(): ed4. 関数と ‘sort()’ メソッドで
     提供されているものと似たものです。例えば:

          >>> import heapq
          >>> L = ["short", 'medium', 'longest', 'longer still']
          >>> heapq.nsmallest(2, L)  # Return two lowest elements, lexicographically
          ['longer still', 'longest']
          >>> heapq.nsmallest(2, L, key=len)   # Return two shortest elements
          ['short', 'medium']

     (Contributed by Raymond Hettinger.)

   * *note itertools.islice(): b1a. 関数が start と step として ‘None’ を
     受け付けるようになっています。これは slice オブジェクトとの互換性を
     高めるもので、つまり以下のように書くことが出来ます:

          s = slice(5)     # Create slice object
          itertools.islice(iterable, s.start, s.stop, s.step)

     (Contributed by Raymond Hettinger.)

   * *note locale: 7a. モジュールの *note format(): 5eb. 関数が更新され
     、2 つの関数 ‘format_string()’ と ‘currency()’ が追加されました。

     *note format(): 5eb. 関数の 'val' パラメータは以前は一つ以上の %文
     字指定子が現れる文字列が許されていました; 今はこのパラメータは正確
     に一つの %文字指定子を含む、周りに囲むテキストのない文字列でなけれ
     ばなりません。省略可能な 'monetary' パラメータも追加されています。
     これが ‘True’ の場合、通貨の書式化の 3 桁ごとに区切るセパレータに、
     ロケールのルールを使います。

     複数 %文字指定子を含む文字列をフォーマットするには、 *note
     format(): 5eb. のように働き、任意のテキストと %文字指定子を混ぜた文
     字列をサポートする新しい ‘format_string()’ 関数を使ってください。

     現在ロケール設定に関連した数字を書式化する ‘currency()’ 関数も追加
     されています。

     (Contributed by Georg Brandl.)

   * *note mailbox: 7f. モジュールでは、メールボックスについてそれを読む
     ことに加えて修正出来る能力を追加するための、大々的な書き換えが行わ
     れています。 ‘mbox’, ‘MH’, ‘Maildir’ を含む新しいクラス群はメールボ
     ックス読み込みに使われますが、メッセージ追加のための ‘add(message)’
     、削除の ‘remove(key)’ 、ロック/アンロックのための
     ‘lock()’/‘unlock()’ も持っています。続く例は maildir 形式から mbox
     形式に変換する例です:

          import mailbox

          # 'factory=None' uses email.Message.Message as the class representing
          # individual messages.
          src = mailbox.Maildir('maildir', factory=None)
          dest = mailbox.mbox('/tmp/mbox')

          for msg in src:
              dest.add(msg)

     (Contributed by Gregory K. Johnson.  Funding was provided by
     Google's 2005 Summer of Code.)

   * New module: the ‘msilib’ module allows creating Microsoft Installer
     ‘.msi’ files and CAB files.  Some support for reading the ‘.msi’
     database is also included.  (Contributed by Martin von Löwis.)

   * The ‘nis’ module now supports accessing domains other than the
     system default domain by supplying a 'domain' argument to the
     ‘nis.match()’ and ‘nis.maps()’ functions.  (Contributed by Ben
     Bell.)

   * *note operator: 8f. モジュールの ‘itemgetter()’ 関数と
     ‘attrgetter()’ 関数が複数フィールドをサポートするようになりました。
     ‘operator.attrgetter('a', 'b')’ のように呼び出すと、 ‘a’ と ‘b’ 属
     性を取り出す関数を返します。この新機能と ‘sort()’ メソッドの ‘key’
     パラメータを組み合わせると、複数フィールドでのリストのソートが簡単
     になります。

   * *note optparse: 90. モジュールが Optik ライブラリのバージョン 1.5.1
     に更新されました。 ‘OptionParser’ クラスに ‘epilog’ 属性と
     ‘destroy()’ メソッドが追加されています。前者はヘルプメッセージのあ
     とに出力される文字列です。後者はオブジェクトによって作られた循環参
     照を破棄します。 (Contributed by Greg Ward.)

   * *note os: 91. モジュールに多数の変更がありました。
     ‘stat_float_times’ 値のデフォルトが真となっていて、これはつまり
     *note os.stat(): 46d. が時刻の値を浮動小数点数で返すということです
     。(ただし必ずしも *note os.stat(): 46d. が秒の端数が正確な値を返す
     という意味ではありません; 全てのシステムがそのような精度をサポート
     してはいません。)

     Constants named *note os.SEEK_SET: 125e, *note os.SEEK_CUR: 125f,
     and *note os.SEEK_END: 1260. have been added; these are the
     parameters to the *note os.lseek(): 10ea. function.  Two new
     constants for locking are *note os.O_SHLOCK: 13d6. and *note
     os.O_EXLOCK: 13d7.

     2 つの新しい関数 ‘wait3()’ と ‘wait4()’ が追加されています。これら
     は ‘waitpid()’ 関数に似ています。これは子プロセスが終了するのを待っ
     てプロセス ID とその終了コードを返しますが、 ‘wait3()’ と ‘wait4()’
     は追加の情報を返します。 ‘wait3()’ はプロセス ID を入力に取りません
     ので任意の子プロセス終了を待ち、 *note resource.getrusage(): 13d8.
     関数から返る 'process-id', 'exit-status', 'resource-usage' の 3 要
     素タプルを返します。 ‘wait4(pid)’ はプロセス ID を取ります。
     (Contributed by Chad J. Schroeder.)

     FreeBSD では、 *note os.stat(): 46d. 関数がナノ秒精度の時刻を返し、
     また、返却オブジェクトが ‘st_gen’ と ‘st_birthtime’ を持つようにな
     っています。 ‘st_flags’ 属性も、プラットフォームがサポートされてい
     る場合には利用可能です。 (Contributed by Antti Louko and Diego
     Pettenò.)

   * *note pdb: 94. モジュールで提供される Python デバッガが、ブレイクポ
     イントに到達して実行が停止する際に実行するコマンドのリストを記憶す
     るようになりました。ブレイクポイント #1 を作ったら、 ‘commands 1’ を
     入力し、実行するコマンド群を入力し、 ‘end’ でリストを終えます。コマ
     ンドリストには ‘continue’ や ‘next’ のような実行再開コマンドを含め
     ることが出来ます。 (Contributed by Grégoire Dooms.)

   * The *note pickle: 95. and ‘cPickle’ modules no longer accept a
     return value of ‘None’ from the *note __reduce__(): 9a1. method;
     the method must return a tuple of arguments instead.  The ability
     to return ‘None’ was deprecated in Python 2.4, so this completes
     the removal of the feature.

   * The *note pkgutil: 97. module, containing various utility functions
     for finding packages, was enhanced to support PEP 302(1)'s import
     hooks and now also works for packages stored in ZIP-format
     archives.  (Contributed by Phillip J. Eby.)

   * Marc-André Lemburg による pybench ベンチマークスイートが
     ‘Tools/pybench’ ディレクトリに含まれるようになりました。pybench ス
     イートは、広く使われている ‘pystone.py’ プログラムの改善版で、イン
     タプリタの速度についてのより詳しい計測を行います。 ‘pystone.py’ の
     ように多くの異なる演算を実行したり単独の数字に縮退する代わりに、こ
     れは関数コール、タプルのスライス、メソッドの検索、数値演算のような
     特定の演算を計測します。 (--訳注: Tools についての言及すべてに共通
     することですが、原則として Tools は「全て」を入手する手段はソースコ
     ード配布を利用することだけです。インストールされるものはプラットフ
     ォーム依存や linux であればディストリビュータによっても変わります。
     顕著なのは Windows で、Tools 配下のものはごく限られたものだけがイン
     ストールされます。pybench もソースコード配布物にのみ含まれ、Windows
     公式インストーラではインストールされません。なお、 ‘pystone.py’ は
     Lib/test 内にあります。--)

   * ‘pyexpat’ モジュールが使う Expat パーサをバージョン 2.0 にしました
     。 (Contributed by Trent Mick.)

   * The *note Queue: 1356. class provided by the ‘Queue’ module gained
     two new methods.  ‘join()’ blocks until all items in the queue have
     been retrieved and all processing work on the items have been
     completed.  Worker threads call the other new method,
     ‘task_done()’, to signal that processing for an item has been
     completed.  (Contributed by Raymond Hettinger.)

   * 古い ‘regex’, ‘regsub’ モジュール、これは Python 2.0 からずっと非推
     奨になっていましたが、ついに削除されました。ほかにも、 ‘statcache’,
     ‘tzparse’, ‘whrandom’ が削除されています。

   * ‘dircmp’ や ‘ni’ といった石器時代のモジュールを大事にしまっていた
     ‘lib-old’ ディレクトリも削除されました。 ‘lib-old’ がデフォルトで
     ‘sys.path’ に含まれることはなかったので、あなたが明示的にそれを
     ‘sys.path’ に入れてこなかった限り、この削除はあなたには関係ないでし
     ょう。

   * *note rlcompleter: ab. モジュールが *note readline: a8. モジュール
     のインポートに依存しないようになりました。これにより非 Unix プラッ
     トフォームで動作するようになりました。 (Patch from Robert Kiendl.)

   * The *note SimpleXMLRPCServer: 115. and *note DocXMLRPCServer: 115.
     classes now have a ‘rpc_paths’ attribute that constrains XML-RPC
     operations to a limited set of URL paths; the default is to allow
     only ‘'/'’ and ‘'/RPC2'’.  Setting ‘rpc_paths’ to ‘None’ or an
     empty tuple disables this path checking.

   * The *note socket: b8. module now supports ‘AF_NETLINK’ sockets on
     Linux, thanks to a patch from Philippe Biondi.  Netlink sockets are
     a Linux-specific mechanism for communications between a user-space
     process and kernel code; an introductory article about them is at
     ‘https://www.linuxjournal.com/article/7356’.  In Python code,
     netlink addresses are represented as a tuple of 2 integers, ‘(pid,
     group_mask)’.

     ソケットオブジェクトの 2 つの新たなメソッド、 ‘recv_into(buffer)’,
     ‘recvfrom_into(buffer)’ は、受信データを、文字列データとして返す代
     わりにバッファプロトコルをサポートするオブジェクトに書き込みます。
     このことにより、受信データを直接 array やメモリマップドファイルに置
     けます。

     ソケットオブジェクトには ‘getfamily()’, ‘gettype()’, ‘getproto()’ ア
     クセッサメソッドも追加されています。それぞれソケットについてのアド
     レスファミリ、タイプ、プロトコルを取得します。

   * New module: the ‘spwd’ module provides functions for accessing the
     shadow password database on systems that support shadow passwords.

   * ‘pack()’, ‘unpack()’ メソッドでフォーマット文字列を ‘Struct’ オブジ
     ェクトにコンパイルすることで、 *note struct: c0. がより高速になって
     います。これは *note re: a7. モジュールでコンパイル済み正規表現オブ
     ジェクトを作れるのに似ています。モジュールレベルの ‘pack()’,
     ‘unpack()’ 関数もそのまま使えます; それらは ‘Struct’ オブジェクトを
     作ってキャッシュします。あるいは ‘Struct’ インスタンスを直接使えま
     す:

          s = struct.Struct('ih3s')

          data = s.pack(1972, 187, 'abc')
          year, number, name = s.unpack(data)

     You can also pack and unpack data to and from buffer objects
     directly using the ‘pack_into(buffer, offset, v1, v2, ...)’ and
     ‘unpack_from(buffer, offset)’ methods.  This lets you store data
     directly into an array or a memory-mapped file.

     (‘Struct’ objects were implemented by Bob Ippolito at the
     NeedForSpeed sprint.  Support for buffer objects was added by
     Martin Blais, also at the NeedForSpeed sprint.)

   * Python デベロッパは 2.5 開発プロセスの間で CVS から Subversion に移
     行しました。ビルドバージョンについての正確な情報は ‘sys.subversion’
     により取得可能で、これは 3 要素タプル ‘(interpreter-name,
     branch-name, revision-range)’ です。例えば執筆時点では 2.5 で
     ‘('CPython', 'trunk', '45313:45315')’ を返します。 (--訳注: Python
     3.2 から 3.3 にかけて、開発が Mercurial に移行していて、これは 2.7
     メンテナンスリリースの間にあたります。今(3.6 dev 時点)では全て
     Mercurial に移行しており、 ‘sys.subversion’ は今では意味のある値は
     返しません。3.3 からは既に ‘sys.subversion’ は削除されています。--)

     この情報は C 拡張から *note Py_GetBuildInfo(): 13d9. 関数を使っても
     得ることが出来ます。これはビルド情報についての文字列を返し、例えば
     ‘"trunk:45355:45356M, Apr 13 2006, 07:42:19"’ のような値です。
     (Contributed by Barry Warsaw.)

   * もう一つの新規関数 *note sys._current_frames(): 13da. は、実行スレ
     ッドについての現在スタックフレームを、各スレッドの識別子がキーの辞
     書として返します。辞書の値は、関数が呼ばれた時点のそのスレッドで現
     在アクティブになっているスタックフレームの一番上です。(Contributed
     by Tim Peters.)

   * *note tarfile: c8. モジュールの ‘TarFile’ クラスに ‘extractall()’ メ
     ソッドが追加されました。アーカイブから全てのメンバをカレントディレ
     クトリに抽出します。抽出ターゲットとして別のディレクトリも指定でき
     ますし、アーカイブメンバのサブセットのみ解凍することも出来ます。

     ストリームモードで開く tarfile に使われる圧縮を、モード ‘'r|*'’ を
     使って自動で検出出来るようになっています。 (Contributed by Lars
     Gustäbel.)

   * *note threading: d6. モジュールで、新しいスレッドを作る際に使われる
     スタックサイズを設定出来るようになりました。 ‘stack_size([*size*])’
     関数は現在構成されているスタックサイズを返し、省略可能引数 'size' パ
     ラメータを与えると新しい値を設定します。全てのプラットフォームがス
     タックサイズ変更をサポートしているわけではなく、Windows、POSIX スレ
     ッド、OS/2 で可能です。 (Contributed by Andrew MacIntyre.)

   * The *note unicodedata: ee. module has been updated to use version
     4.1.0 of the Unicode character database.  Version 3.2.0 is required
     by some specifications, so it's still available as *note
     unicodedata.ucd_3_2_0: 13db.

   * 新モジュール: *note uuid: f8. モジュールは RFC 4122(2) による UUID
     (universally unique identifiers) を生成します。その RFC ではいくつ
     かの異なる UUID のバージョンを定義しており、文字列から生成するもの
     、システム特性から生成するもの、純粋に乱数から生成するものがありま
     す。このモジュールでは ‘UUID’ クラスと ‘uuid1()’, ‘uuid3()’,
     ‘uuid4()’, ‘uuid5()’ 関数を持っていて、それら異なったバージョンの
     UUID を生成します。(UUID バージョン 2 は RFC 4122(3) にありませんの
     でこのモジュールにもないです)

          >>> import uuid
          >>> # make a UUID based on the host ID and current time
          >>> uuid.uuid1()
          UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')

          >>> # make a UUID using an MD5 hash of a namespace UUID and a name
          >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
          UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')

          >>> # make a random UUID
          >>> uuid.uuid4()
          UUID('16fd2706-8baf-433b-82eb-8c7fada847da')

          >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
          >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
          UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')

     (Contributed by Ka-Ping Yee.)

   * *note weakref: fc. モジュールの ‘WeakKeyDictionary’ 型と
     ‘WeakValueDictionary’ 型に、辞書内に含まれる弱参照を巡回する新たな
     メソッドが追加されています。 ‘iterkeyrefs()’ と ‘keyrefs()’ が
     ‘WeakKeyDictionary’ に追加され、 ‘itervaluerefs()’ と ‘valuerefs()’
     が ‘WeakValueDictionary’ に追加されました。(Contributed by Fred L.
     Drake, Jr.)

   * The *note webbrowser: fd. module received a number of enhancements.
     It's now usable as a script with ‘python -m webbrowser’, taking a
     URL as the argument; there are a number of switches to control the
     behaviour (‘-n’ for a new browser window, ‘-t’ for a new tab).  New
     module-level functions, ‘open_new()’ and ‘open_new_tab()’, were
     added to support this.  The module's *note open(): 4e5. function
     supports an additional feature, an 'autoraise' parameter that
     signals whether to raise the open window when possible.  A number
     of additional browsers were added to the supported list such as
     Firefox, Opera, Konqueror, and elinks.  (Contributed by Oleg
     Broytmann and Georg Brandl.)

   * The *note xmlrpclib: 114. module now supports returning *note
     datetime: 1ae. objects for the XML-RPC date type.  Supply
     ‘use_datetime=True’ to the *note loads(): 13dc. function or the
     ‘Unmarshaller’ class to enable this feature.  (Contributed by Skip
     Montanaro.)

   * *note zipfile: 117. モジュールが ZIP64 バージョンのフォーマットをサ
     ポートしました。これで 4GiB を超える zip 書庫を作れ、4GiB を超える
     ファイルを書庫に含めることが出来ます。 (Contributed by Ronald
     Oussoren.)

   * *note zlib: 119. モジュールの ‘Compress’ , ‘Decompress’ オブジェク
     トが *note copy(): 1e. メソッドをサポートするようになりました。オブ
     ジェクトの内部状態を複製して新しい ‘Compress’ あるいは ‘Decompress’
     オブジェクトを返します。 (Contributed by Chris AtLee.)

* Menu:

* ctypes パッケージ::
* ElementTree パッケージ::
* hashlib パッケージ::
* sqlite3 パッケージ::
* wsgiref パッケージ::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0302/

   (2) https://datatracker.ietf.org/doc/html/rfc4122.html

   (3) https://datatracker.ietf.org/doc/html/rfc4122.html


File: python.info,  Node: ctypes パッケージ,  Next: ElementTree パッケージ,  Up: 新たなモジュール、改良されたモジュール、削除されたモジュール

1.17.13.1 ctypes パッケージ
...........................

The *note ctypes: 22. package, written by Thomas Heller, has been added
to the standard library.  *note ctypes: 22. lets you call arbitrary
functions in shared libraries or DLLs.  Long-time users may remember the
‘dl’ module, which provides functions for loading shared libraries and
calling functions in them.  The *note ctypes: 22. package is much
fancier.

シェアドライブラリや DLL をロードするには、 ‘CDLL’ クラスのインスタンス
を、その名前かパスを渡して構築します。構築したら、 ‘CDLL’ オブジェクトの
属性にアクセスすることで任意の関数呼び出しが出来ます:

     import ctypes

     libc = ctypes.CDLL('libc.so.6')
     result = libc.printf("Line of output\n")

Type constructors for the various C types are provided: ‘c_int()’,
‘c_float()’, ‘c_double()’, ‘c_char_p()’ (equivalent to char*), and so
forth.  Unlike Python's types, the C versions are all mutable; you can
assign to their ‘value’ attribute to change the wrapped value.  Python
integers and strings will be automatically converted to the
corresponding C types, but for other types you must call the correct
type constructor.  (And I mean 'must'; getting it wrong will often
result in the interpreter crashing with a segmentation fault.)

C 関数がメモリ領域を更新するものである場合、Python 文字列に ‘c_char_p()’
を使うべきではありません。 Python 文字列は *note immutable: 1272. である
ことを前提としているからです; この規則を犯すことは頭を掻き毟るバグを引き
起こすでしょう。更新可能なメモリ領域が必要な場合は
‘create_string_buffer()’ を使います:

     s = "this is a string"
     buf = ctypes.create_string_buffer(s)
     libc.strfry(buf)

C 関数はデフォルトでは整数を返すと仮定されますが、関数オブジェクトの
‘restype’ 属性をセットすることでこれを変更出来ます:

     >>> libc.atof('2.71828')
     -1783957616
     >>> libc.atof.restype = ctypes.c_double
     >>> libc.atof('2.71828')
     2.71828

*note ctypes: 22. also provides a wrapper for Python's C API as the
‘ctypes.pythonapi’ object.  This object does 'not' release the global
interpreter lock before calling a function, because the lock must be
held when calling into the interpreter's code.  There's a *note
py_object: 13df. type constructor that will create a *note PyObject:
312.* pointer.  A simple usage:

     import ctypes

     d = {}
     ctypes.pythonapi.PyObject_SetItem(ctypes.py_object(d),
               ctypes.py_object("abc"),  ctypes.py_object(1))
     # d is now {'abc', 1}.

Don't forget to use *note py_object(): 13df.; if it's omitted you end up
with a segmentation fault.

*note ctypes: 22. が周辺ライブラリとして登場してしばらく経ちますが、
*note ctypes: 22. が存在していることに依存できないとなれば人々はまだハー
ドコードされた拡張モジュールを書いて配布します。 *note ctypes: 22. が
Python 中核に含められた今、おそらく開発者たちは、拡張モジュールの代わり
に *note ctypes: 22. を介してアクセスするライブラリの上に Python ラッパ
ーを書き始めるでしょう,

参考
....

‘https://web.archive.org/web/20180410025338/http://starship.python.net/crew/theller/ctypes/’

     The pre-stdlib ctypes web page, with a tutorial, reference, and
     FAQ.

*note ctypes: 22. モジュールについてのドキュメント。


File: python.info,  Node: ElementTree パッケージ,  Next: hashlib パッケージ,  Prev: ctypes パッケージ,  Up: 新たなモジュール、改良されたモジュール、削除されたモジュール

1.17.13.2 ElementTree パッケージ
................................

XML 処理のための、Fredrik Lundh の ElementTree ライブラリのサブセットが
、標準ライブラリに ‘xml.etree’ として追加されました。利用可能なモジュー
ルは ElementTree 1.2.6 よりの ‘ElementTree’, ‘ElementPath’,
‘ElementInclude’ です。 C 実装 ‘cElementTree’ モジュールも含まれています
。

The rest of this section will provide a brief overview of using
ElementTree.  Full documentation for ElementTree is available at
‘https://web.archive.org/web/20201124024954/http://effbot.org/zone/element-index.htm’.

ElementTree は XML ドキュメントを、要素ノードのツリーとして表現します。
ドキュメントのテキストコンテントは ‘text’ 属性と ‘tail’ 属性に格納されま
す (これが ElementTree と Document Object Model (DOM) との一番大きな違い
です; DOM 内ではノードの数多くの型があります。 ‘TextNode’ はその一つです
。)

最も一般的に使う解析関数は ‘parse()’ です。これは (ファイル名が含まれる
とみなされる) 文字列またはファイルのようなオブジェクトを受け取って、
‘ElementTree’ インスタンスを返します:

     from xml.etree import ElementTree as ET

     tree = ET.parse('ex-1.xml')

     feed = urllib.urlopen(
               'http://planet.python.org/rss10.xml')
     tree = ET.parse(feed)

‘ElementTree’ インスタンスを手にしてしまえば、あとはルートの ‘Element’ ノ
ードを得るために ‘getroot()’ を呼び出せます。

文字列リテラルを受け取って (‘ElementTree’ ではなく) ‘Element’ ノードを返
す ‘XML()’ 関数 もあります。この関数を使えば、簡単に XML リテラルを使っ
て XML 断片からツリーを組み上げることが綺麗に出来ます:

     svg = ET.XML("""<svg width="10px" version="1.0">
                  </svg>""")
     svg.set('height', '320px')
     svg.append(elem1)

個々の XML 要素はいくつかの辞書のような、いくつかのリストのようなメソッ
ドをサポートしています。辞書的な操作は属性値のアクセスに使い、リスト的な
操作は子ノードのアクセスに使います。

演算                                結果
                                    
-------------------------------------------------------------------------------------
                                    
‘elem[n]’                           n 番目の子要素を返す。
                                    
                                    
‘elem[m:n]’                         m 番目から n 番目までの子要素を返す(--訳注: n
                                    は含まない--)。
                                    
                                    
‘len(elem)’                         子要素数を返す。
                                    
                                    
‘list(elem)’                        子要素のリストを返す。
                                    
                                    
‘elem.append(elem2)’                'elem2' を子として追加する。
                                    
                                    
‘elem.insert(index, elem2)’         指定された位置に 'elem2' を挿入する。
                                    
                                    
‘del elem[n]’                       n 番目の子要素を削除する。
                                    
                                    
‘elem.keys()’                       属性名のリストを返す。
                                    
                                    
‘elem.get(name)’                    属性 'name' の値を返す。
                                    
                                    
‘elem.set(name, value)’             属性 'name' に新しい値をセットする。
                                    
                                    
‘elem.attrib’                       属性を含んだ辞書を取り出す。
                                    
                                    
‘del elem.attrib[name]’             属性 'name' を削除する。
                                    

コメントと処理命令 (processing instruction=PI) も、 ‘Element’ ノードで表
現されます。ノードがコメントあるいは処理命令であるかをチェックするにはこ
のようにします:

     if elem.tag is ET.Comment:
         ...
     elif elem.tag is ET.ProcessingInstruction:
         ...

XML 出力を生成するには ‘ElementTree.write()’ メソッドを呼び出す必要があ
ります。 ‘parse()’ のように、文字列もしくはファイルのようなオブジェクト
を渡せます:

     # Encoding is US-ASCII
     tree.write('output.xml')

     # Encoding is UTF-8
     f = open('output.xml', 'w')
     tree.write(f, encoding='utf-8')

(警告: 出力に使われるデフォルトエンコーディングは ASCII です。一般的な
XML での作業では要素名に任意の Unicode 文字を含められるので、ASCII エン
コーディングはあまり役に立ちません。要素名に 127 より大きなどんな文字が
含まれても例外となりますので。ですから任意の Unicode 文字を扱うために
UTF-8 のようなエンコーディングを指定するのが吉です。)

このセクションでは ElementTree インターフェイスのほんの一部しか記載して
いません。さらに詳しい情報については、パッケージの公式ドキュメントを参照
して下さい。

参考
....

‘https://web.archive.org/web/20201124024954/http://effbot.org/zone/element-index.htm’

     ElementTree の公式ドキュメント


File: python.info,  Node: hashlib パッケージ,  Next: sqlite3 パッケージ,  Prev: ElementTree パッケージ,  Up: 新たなモジュール、改良されたモジュール、削除されたモジュール

1.17.13.3 hashlib パッケージ
............................

A new *note hashlib: 5e. module, written by Gregory P. Smith, has been
added to replace the ‘md5’ and ‘sha’ modules.  *note hashlib: 5e. adds
support for additional secure hashes (SHA-224, SHA-256, SHA-384, and
SHA-512).  When available, the module uses OpenSSL for fast platform
optimized implementations of algorithms.

The old ‘md5’ and ‘sha’ modules still exist as wrappers around hashlib
to preserve backwards compatibility.  The new module's interface is very
close to that of the old modules, but not identical.  The most
significant difference is that the constructor functions for creating
new hashing objects are named differently.

     # Old versions
     h = md5.md5()
     h = md5.new()

     # New version
     h = hashlib.md5()

     # Old versions
     h = sha.sha()
     h = sha.new()

     # New version
     h = hashlib.sha1()

     # Hash that weren't previously available
     h = hashlib.sha224()
     h = hashlib.sha256()
     h = hashlib.sha384()
     h = hashlib.sha512()

     # Alternative form
     h = hashlib.new('md5')          # Provide algorithm as a string

ハッシュオブジェクトを作ってしまえばあとはそのメソッドは以前と同じです:
‘update(string)’ は指定された文字列を現在のダイジェスト状態にハッシュ更
新し、 ‘digest()’ と ‘hexdigest()’ は結果のダイジェスト値をバイナリ文字
列・16進数表記文字列として返し、 *note copy(): 1e. はダイジェスト状態を
複製して新たなハッシュオブジェクトを作ります。

参考
....

*note hashlib: 5e. モジュールについてのドキュメント。


File: python.info,  Node: sqlite3 パッケージ,  Next: wsgiref パッケージ,  Prev: hashlib パッケージ,  Up: 新たなモジュール、改良されたモジュール、削除されたモジュール

1.17.13.4 sqlite3 パッケージ
............................

The pysqlite module (‘https://www.pysqlite.org’), a wrapper for the
SQLite embedded database, has been added to the standard library under
the package name *note sqlite3: ba.

SQLite は、軽量なディスク上のデータベースを提供する C ライブラリです。別
のサーバプロセスを用意する必要なく、 SQL クエリー言語の非標準的な一種を
使用してデータベースにアクセスできます。一部のアプリケーションは内部デー
タ保存に SQLite を使えます。また、SQLite を使ってアプリケーションのプロ
トタイプを作り、その後そのコードを PostgreSQL や Oracle のような大規模デ
ータベースに移植するということも可能です。

pysqlite は Gerhard Häring によって書かれ、 PEP 249(1) に記述された
DB-API 2.0 仕様に準拠した SQL インターフェースを提供するものです。

ソースコードから Python をビルドする場合は注意してください。Python ソー
スツリーは SQLite コードを含まずラッパーモジュールのみを含んでいます。
Python ビルド前に SQLite ライブラリとヘッダをインストールする必要があり
ます。必要ヘッダが利用可能となっていればモジュールはビルドされます。

このモジュールを使うには、最初にデータベースを表す ‘Connection’ オブジェ
クトを作ります。ここではデータはファイル ‘/tmp/example’ に格納されている
ものとします。

     conn = sqlite3.connect('/tmp/example')

特別な名前である ‘:memory:’ を使うと RAM 上にデータベースを作ることもで
きます。

‘Connection’ があれば、 ‘Cursor’ オブジェクトを作りその ‘execute()’ メソ
ッドを呼んで SQL コマンドを実行することができます:

     c = conn.cursor()

     # Create table
     c.execute('''create table stocks
     (date text, trans text, symbol text,
      qty real, price real)''')

     # Insert a row of data
     c.execute("""insert into stocks
               values ('2006-01-05','BUY','RHAT',100,35.14)""")

たいてい、SQL 操作は Python 変数の値を使う必要があります。この時、クエリ
ーを Python の文字列操作を使って構築することは、安全とは言えないので、す
べきではありません。そのようなことをするとプログラムが SQL インジェクシ
ョン攻撃に対し脆弱になりかねません。

代わりに、DB-API のパラメータ割り当てを使います。 ‘?’ を変数の値を使いた
いところに埋めておきます。その上で、値のタプルをカーソルの ‘execute()’ メ
ソッドの第2引数として引き渡します。(他のデータベースモジュールでは変数の
場所を示すのに ‘%s’ や ‘:1’ などの異なった表記を用いることがあります。)
例を示します:

     # Never do this -- insecure!
     symbol = 'IBM'
     c.execute("... where symbol = '%s'" % symbol)

     # Do this instead
     t = (symbol,)
     c.execute('select * from stocks where symbol=?', t)

     # Larger example
     for t in (('2006-03-28', 'BUY', 'IBM', 1000, 45.00),
               ('2006-04-05', 'BUY', 'MSOFT', 1000, 72.00),
               ('2006-04-06', 'SELL', 'IBM', 500, 53.00),
              ):
         c.execute('insert into stocks values (?,?,?,?,?)', t)

SELECT 文を実行した後データを取得する方法は3つありどれを使っても構いませ
ん。一つはカーソルをイテレータ (*note iterator: 191.) として扱う、一つは
カーソルの ‘fetchone()’ メソッドを呼んで一致した内の一行を取得する、もう
一つは ‘fetchall()’ メソッドを呼んで一致した全ての行のリストとして受け取
る、という3つです。

以下の例ではイテレータの形を使います:

     >>> c = conn.cursor()
     >>> c.execute('select * from stocks order by price')
     >>> for row in c:
     ...    print row
     ...
     (u'2006-01-05', u'BUY', u'RHAT', 100, 35.140000000000001)
     (u'2006-03-28', u'BUY', u'IBM', 1000, 45.0)
     (u'2006-04-06', u'SELL', u'IBM', 500, 53.0)
     (u'2006-04-05', u'BUY', u'MSOFT', 1000, 72.0)
     >>>

SQLite でサポートされる SQL 方言についてもっと詳しく知りたければ、
‘http://www.sqlite.org’ を参照して下さい。

参考
....

‘https://www.pysqlite.org’

     pysqlite のウェブページ。

‘https://www.sqlite.org’

     SQLite のウェブページ。ここの文書ではサポートされる SQL 方言の文法
     と使えるデータ型を説明しています。

*note sqlite3: ba. モジュールについてのドキュメント。

PEP 249(2) - Database API Specification 2.0

     Marc-Andre Lemburg により書かれた PEP。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0249/

   (2) https://peps.python.org/pep-0249/


File: python.info,  Node: wsgiref パッケージ,  Prev: sqlite3 パッケージ,  Up: 新たなモジュール、改良されたモジュール、削除されたモジュール

1.17.13.5 wsgiref パッケージ
............................

Web Server Gateway Interface (WSGI) v1.0 は、 Web サーバと Python で記述
された Web アプリケーションとの標準インターフェースであり、 PEP 333(1) で
定義されています。 *note wsgiref: 100. パッケージは WSGI 仕様のリファレ
ンス実装です。

パッケージには WSGI アプリケーションとして動作する基礎的な HTTP サーバが
含まれています; このサーバは製品ユースではないデバッグ目的に有用です。サ
ーバをセットアップするには僅か数行で済みます:

     from wsgiref import simple_server

     wsgi_app = ...

     host = ''
     port = 8000
     httpd = simple_server.make_server(host, port, wsgi_app)
     httpd.serve_forever()

参考
....

‘https://web.archive.org/web/20160331090247/http://wsgi.readthedocs.org/en/latest/’

     WSGI 関連のリソースについて集約しているウェブサイト。

PEP 333(2) - Python Web Server Gateway Interface v1.0

     PEP 著 Phillip J. Eby.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0333/

   (2) https://peps.python.org/pep-0333/


File: python.info,  Node: ビルドならびに C API の変更<10>,  Next: Python 2 5 への移植,  Prev: 新たなモジュール、改良されたモジュール、削除されたモジュール,  Up: What's New in Python 2 5

1.17.14 ビルドならびに C API の変更
-----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * Python ソースツリーは CVS から Subversion に変換されました。この複
     雑な移行手続きは Martin von Löwis によって指揮されつつがなく遂行さ
     れました。この手続きは PEP 347(1) にて開発されました。

   * Coverity, a company that markets a source code analysis tool called
     Prevent, provided the results of their examination of the Python
     source code.  The analysis found about 60 bugs that were quickly
     fixed.  Many of the bugs were refcounting problems, often occurring
     in error-handling code.  See ‘https://scan.coverity.com’ for the
     statistics.

   * The largest change to the C API came from PEP 353(2), which
     modifies the interpreter to use a *note Py_ssize_t: a2e. type
     definition instead of int.  See the earlier section *note PEP 353;
     添え字型に ssize_t を使う: 13bf. for a discussion of this change.

   * The design of the bytecode compiler has changed a great deal, no
     longer generating bytecode by traversing the parse tree.  Instead
     the parse tree is converted to an abstract syntax tree (or AST),
     and it is the abstract syntax tree that's traversed to produce the
     bytecode.

     It's possible for Python code to obtain AST objects by using the
     *note compile(): 177. built-in and specifying ‘_ast.PyCF_ONLY_AST’
     as the value of the 'flags' parameter:

          from _ast import PyCF_ONLY_AST
          ast = compile("""a=0
          for i in range(10):
              a += i
          """, "<string>", 'exec', PyCF_ONLY_AST)

          assignment = ast.body[0]
          for_loop = ast.body[1]

     No official documentation has been written for the AST code yet,
     but PEP 339(3) discusses the design.  To start learning about the
     code, read the definition of the various AST nodes in
     ‘Parser/Python.asdl’.  A Python script reads this file and
     generates a set of C structure definitions in
     ‘Include/Python-ast.h’.  The ‘PyParser_ASTFromString()’ and
     ‘PyParser_ASTFromFile()’, defined in ‘Include/pythonrun.h’, take
     Python source as input and return the root of an AST representing
     the contents.  This AST can then be turned into a code object by
     ‘PyAST_Compile()’.  For more information, read the source code, and
     then ask questions on python-dev.

     The AST code was developed under Jeremy Hylton's management, and
     implemented by (in alphabetical order) Brett Cannon, Nick Coghlan,
     Grant Edwards, John Ehresman, Kurt Kaiser, Neal Norwitz, Tim
     Peters, Armin Rigo, and Neil Schemenauer, plus the participants in
     a number of AST sprints at conferences such as PyCon.

   * Evan Jones's patch to obmalloc, first described in a talk at PyCon
     DC 2005, was applied.  Python 2.4 allocated small objects in
     256K-sized arenas, but never freed arenas.  With this patch, Python
     will free arenas when they're empty.  The net effect is that on
     some platforms, when you allocate many objects, Python's memory
     usage may actually drop when you delete them and the memory may be
     returned to the operating system.  (Implemented by Evan Jones, and
     reworked by Tim Peters.)

     Note that this change means extension modules must be more careful
     when allocating memory.  Python's API has many different functions
     for allocating memory that are grouped into families.  For example,
     *note PyMem_Malloc(): c33, *note PyMem_Realloc(): ffc, and *note
     PyMem_Free(): 13ea. are one family that allocates raw memory, while
     *note PyObject_Malloc(): c36, *note PyObject_Realloc(): 13eb, and
     *note PyObject_Free(): c34. are another family that's supposed to
     be used for creating Python objects.

     Previously these different families all reduced to the platform's
     ‘malloc()’ and ‘free()’ functions.  This meant it didn't matter if
     you got things wrong and allocated memory with the ‘PyMem’ function
     but freed it with the ‘PyObject’ function.  With 2.5's changes to
     obmalloc, these families now do different things and mismatches
     will probably result in a segfault.  You should carefully test your
     C extension modules with Python 2.5.

   * ビルトインの集合型のために公式の C API が作られました。新しく作るの
     には *note PySet_New(): 13ec. か *note PyFrozenSet_New(): 13ed. を
     、要素の追加には *note PySet_Add(): 13ee. 、削除には *note
     PySet_Discard(): 13ef. 、 *note PySet_Contains(): 13f0. と *note
     PySet_Size(): 13f1. で集合オブジェクトの状態を調べます。
     (Contributed by Raymond Hettinger.)

   * C コードから Python インタプリタの正確なリビジョンについての情報を
     取得出来るようになりました。 *note Py_GetBuildInfo(): 13d9. 関数を
     呼び出すことでビルド情報についての文字列が ‘"trunk:45355:45356M,
     Apr 13 2006, 07:42:19"’ のように返ります。 (Contributed by Barry
     Warsaw.)

   * Two new macros can be used to indicate C functions that are local
     to the current file so that a faster calling convention can be
     used.  ‘Py_LOCAL(type)’ declares the function as returning a value
     of the specified 'type' and uses a fast-calling qualifier.
     ‘Py_LOCAL_INLINE(type)’ does the same thing and also requests the
     function be inlined.  If macro ‘PY_LOCAL_AGGRESSIVE’ is defined
     before ‘python.h’ is included, a set of more aggressive
     optimizations are enabled for the module; you should benchmark the
     results to find out if these optimizations actually make the code
     faster.  (Contributed by Fredrik Lundh at the NeedForSpeed sprint.)

   * ‘PyErr_NewException(name, base, dict)’ が 'base' 引数としてベースク
     ラスのタプルを受け付けるようになりました。 (Contributed by Georg
     Brandl.)

   * The ‘PyErr_Warn()’ function for issuing warnings is now deprecated
     in favour of ‘PyErr_WarnEx(category, message, stacklevel)’ which
     lets you specify the number of stack frames separating this
     function and the caller.  A 'stacklevel' of 1 is the function
     calling *note PyErr_WarnEx(): 13f2, 2 is the function above that,
     and so forth.  (Added by Neal Norwitz.)

   * CPython は今でも C で書かれていますが、コードは C++ コンパイラでも
     エラーなしでコンパイル出来るようになりました。 (Implemented by
     Anthony Baxter, Martin von Löwis, Skip Montanaro.)

   * The ‘PyRange_New()’ function was removed.  It was never documented,
     never used in the core code, and had dangerously lax error
     checking.  In the unlikely case that your extensions were using it,
     you can replace it by something like the following:

          range = PyObject_CallFunction((PyObject*) &PyRange_Type, "lll",
                                        start, stop, step);

* Menu:

* ポート特有の変更::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0347/

   (2) https://peps.python.org/pep-0353/

   (3) https://peps.python.org/pep-0339/


File: python.info,  Node: ポート特有の変更,  Up: ビルドならびに C API の変更<10>

1.17.14.1 ポート特有の変更
..........................

   * MacOS X (10.3 以上): モジュールの動的ロードに、MacOS 固有の関数では
     なく ‘dlopen()’ 関数を使うようになりました。

   * MacOS X: an ‘--enable-universalsdk’ switch was added to the
     ‘configure’ script that compiles the interpreter as a universal
     binary able to run on both PowerPC and Intel processors.
     (Contributed by Ronald Oussoren; bpo-2573(1).)

   * Windows: ‘.dll’ はもはや拡張モジュールのファイル拡張子としてはサポ
     ートされません。これからは ‘.pyd’ だけが拡張モジュールとして検索さ
     れるファイル拡張子です。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=2573


File: python.info,  Node: Python 2 5 への移植,  Next: 謝辞<3>,  Prev: ビルドならびに C API の変更<10>,  Up: What's New in Python 2 5

1.17.15 Python 2.5 への移植
---------------------------

このセクションでは前述の変更により必要となるかもしれないコードの変更を列
挙します:

   * ASCII がモジュールのデフォルトエンコーディングになっています(訳注:
     Python 3 からはデフォルトは utf-8 (PEP 3120))。8 ビット文字を含んで
     いるのにエンコーディング宣言がないモジュールが構文エラーになるよう
     になりました。Python 2.4 では構文エラーとはならず警告でした。

   * 以前はジェネレータの ‘gi_frame’ 属性は常にフレームオブジェクトでし
     たが、 *note PEP 342; ジェネレータの新機能: 13ab. で説明した PEP
     342(1) での変更により、 ‘gi_frame’ は ‘None’ になりえます。

   * Unicode 文字列とデフォルトの ASCII エンコーディングで Unicode に変
     換出来ない 8 ビット文字列との比較を試みると、新しい警告 *note
     UnicodeWarning: 13cb. が引き起こされるようになっています。以前はそ
     のような比較では *note UnicodeDecodeError: 9e1. 例外を起こしていま
     した。

   * ライブラリ: *note csv: 21. モジュールは引用符内のマルチラインをより
     厳密に扱うようになっています。フィールド内に改行を埋め込んでいるフ
     ァイルがある場合は、その入力は改行文字を残すやり方で行分解されるは
     ずです。

   * ライブラリ: *note locale: 7a. モジュールの *note format(): 5eb. 関
     数は、以前は %文字指定子が一つを超えてさえいなければ任意の文字列を
     受け付けていたかもしれませんが、Python 2.5 からは正確に一つの、ほか
     に周りをテキストで囲まれていない %文字指定子でなければなりません。

   * Library: The *note pickle: 95. and ‘cPickle’ modules no longer
     accept a return value of ‘None’ from the *note __reduce__(): 9a1.
     method; the method must return a tuple of arguments instead.  The
     modules also no longer accept the deprecated 'bin' keyword
     parameter.

   * Library: The *note SimpleXMLRPCServer: 115. and *note
     DocXMLRPCServer: 115. classes now have a ‘rpc_paths’ attribute that
     constrains XML-RPC operations to a limited set of URL paths; the
     default is to allow only ‘'/'’ and ‘'/RPC2'’.  Setting ‘rpc_paths’
     to ‘None’ or an empty tuple disables this path checking.

   * C API: Many functions now use *note Py_ssize_t: a2e. instead of int
     to allow processing more data on 64-bit machines.  Extension code
     may need to make the same change to avoid warnings and to support
     64-bit machines.  See the earlier section *note PEP 353; 添え字型に
     ssize_t を使う: 13bf. for a discussion of this change.

   * C API: The obmalloc changes mean that you must be careful to not
     mix usage of the ‘PyMem_*’ and ‘PyObject_*’ families of functions.
     Memory allocated with one family's ‘*_Malloc’ must be freed with
     the corresponding family's ‘*_Free’ function.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0342/


File: python.info,  Node: 謝辞<3>,  Prev: Python 2 5 への移植,  Up: What's New in Python 2 5

1.17.16 謝辞
------------

The author would like to thank the following people for offering
suggestions, corrections and assistance with various drafts of this
article: Georg Brandl, Nick Coghlan, Phillip J. Eby, Lars Gustäbel,
Raymond Hettinger, Ralf W. Grosse-Kunstleve, Kent Johnson, Iain Lowe,
Martin von Löwis, Fredrik Lundh, Andrew McNamara, Skip Montanaro,
Gustavo Niemeyer, Paul Prescod, James Pryor, Mike Rovner, Scott Weikart,
Barry Warsaw, Thomas Wouters.


File: python.info,  Node: What's New in Python 2 4,  Next: What's New in Python 2 3,  Prev: What's New in Python 2 5,  Up: What's New in Python

1.18 What's New in Python 2.4
=============================


著者: A.M. Kuchling

この文書は 2005 年 3 月 30 日にリリースされた Python 2.4.1 の新機能につ
いて解説します。

Python 2.4 は、真ん中サイズ、のリリースです。急進的だった Python 2.2 ほ
どには多くの変更をしていませんが、保守的だった 2.3 よりは多くの機能を導
入しています。新しい言語機能で最も重要なのが、関数デコレータとジェネレー
タ式です。ほかのほとんどの変更は標準ライブラリに対するものです。

Python 2.3 から 2.4 の CVS 変更ログによれば、適用されたパッチは 481、フ
ィックスされたバグは 502 ありました。ともに、少なく見積もって、です。

このドキュメントは個々の新機能の完全な詳細を提供するのではなくて、簡易な
概要を提供することを目的にしています。完全な詳細が知りたければ、 Python
ライブラリリファレンス、Python リファレンスマニュアルのような Python 2.4
のドキュメントを参照してください。多くの場合個別の新機能についての実装の
説明やデザインの根拠については PEP に託されています。

* Menu:

* PEP 218; ビルトインの集合オブジェクト: PEP 218 ビルトインの集合オブジェクト.
* PEP 237; 長整数と整数を一体化していく: PEP 237 長整数と整数を一体化していく.
* PEP 289; ジェネレータ式: PEP 289 ジェネレータ式.
* PEP 292; より単純な文字列置換 (string substitution): PEP 292 より単純な文字列置換 string substitution.
* PEP 318; 関数とメソッドのためのデコレータ: PEP 318 関数とメソッドのためのデコレータ.
* PEP 322; 逆順のイテレーション: PEP 322 逆順のイテレーション.
* PEP 324; 新しい subprocess モジュール: PEP 324 新しい subprocess モジュール.
* PEP 327; Decimal データ型: PEP 327 Decimal データ型.
* PEP 328; マルチラインインポート: PEP 328 マルチラインインポート.
* PEP 331; Locale に依存しない Float/String 変換: PEP 331 Locale に依存しない Float/String 変換.
* その他の言語変更: その他の言語変更<15>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>.
* ビルドならびに C API の変更: ビルドならびに C API の変更<11>.
* Python 2.4 への移植: Python 2 4 への移植.
* 謝辞: 謝辞<4>.


File: python.info,  Node: PEP 218 ビルトインの集合オブジェクト,  Next: PEP 237 長整数と整数を一体化していく,  Up: What's New in Python 2 4

1.18.1 PEP 218: ビルトインの集合オブジェクト
--------------------------------------------

Python 2.3 では ‘sets’ モジュールを導入しました。集合データ型の C 実装が
Python コアに新たに、2 つの新しいビルトイン型 ‘set(iterable)’ と
‘frozenset(iterable)’ として追加されています。これらは要素が集合に属して
いるかのメンバシップテスト、シーケンスからの重複の削除、それに和集合
(union)、共通集合 (intersection)、 差 (difference)、対称差 (symmetric
difference) といった数学演算を高速に行います:

     >>> a = set('abracadabra')              # form a set from a string
     >>> 'z' in a                            # fast membership testing
     False
     >>> a                                   # unique letters in a
     set(['a', 'r', 'b', 'c', 'd'])
     >>> ''.join(a)                          # convert back into a string
     'arbcd'

     >>> b = set('alacazam')                 # form a second set
     >>> a - b                               # letters in a but not in b
     set(['r', 'd', 'b'])
     >>> a | b                               # letters in either a or b
     set(['a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'])
     >>> a & b                               # letters in both a and b
     set(['a', 'c'])
     >>> a ^ b                               # letters in a or b but not both
     set(['r', 'd', 'b', 'm', 'z', 'l'])

     >>> a.add('z')                          # add a new element
     >>> a.update('wxy')                     # add multiple new elements
     >>> a
     set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'x', 'z'])
     >>> a.remove('x')                       # take one element out
     >>> a
     set(['a', 'c', 'b', 'd', 'r', 'w', 'y', 'z'])

*note frozenset(): 5a4. 型は *note set(): 5a3. の *note immutable: 1272.
版です。 immutable かつハッシュ可能なので、辞書のキーやほかの set のメン
バとして使えるでしょう。

2.3 で追加された ‘sets’ モジュールは標準ライブラリに残されていて、 ‘Set’
や ‘ImmutableSet’ をサブクラス化したければ便利かもしれません。今のところ
これを撤廃する予定はありません。(--訳注: ‘sets’ モジュールは 2.6 で非推
奨となっています。--)

参考
....

PEP 218(1) - 集合オブジェクト型をビルトインに追加する

     元々は Greg Wilson によって提案され、完全な実装は Raymond Hettinger
     によってなされました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0218/


File: python.info,  Node: PEP 237 長整数と整数を一体化していく,  Next: PEP 289 ジェネレータ式,  Prev: PEP 218 ビルトインの集合オブジェクト,  Up: What's New in Python 2 4

1.18.2 PEP 237: 長整数と整数を一体化していく
--------------------------------------------

この PEP の非常に長期に渡る移行は Python 2.2 に始まり、Python 2.4 でさら
にもう一歩前進しています。2.3 では int/long の一体化後に異なる振る舞いを
する整数演算をすると *note FutureWarning: 3ee. 警告を出して、結果の値は
(プラットフォーム依存で) 32 ビットまたは 64 ビットに制限していました。
2.4 ではこれらの式はもう警告は出さず、代わりにいつでも(2.3 とは違った)長
整数となる結果をはじき出します。

問題を起こしうる式は主として左シフトで、そして長い 16 進リテラルと 8 進
リテラルです。例えば ‘2 << 32’ は 2.3 では警告とともに 32 ビットプラット
フォームでは結果は 0 になります。Python 2.4 ではこの式は正しい答えの
8589934592 になります。

参考
....

PEP 237(1) - 長整数と整数を一体化していく

     オリジナルの PEP は Moshe Zadka と GvR (Guido van Rossum) によって
     書かれました。.2.4 での変更については Kalle Svensson によって実装さ
     れました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0237/


File: python.info,  Node: PEP 289 ジェネレータ式,  Next: PEP 292 より単純な文字列置換 string substitution,  Prev: PEP 237 長整数と整数を一体化していく,  Up: What's New in Python 2 4

1.18.3 PEP 289: ジェネレータ式
------------------------------

The iterator feature introduced in Python 2.2 and the *note itertools:
75. module make it easier to write programs that loop through large data
sets without having the entire data set in memory at one time.  List
comprehensions don't fit into this picture very well because they
produce a Python list object containing all of the items.  This
unavoidably pulls all of the objects into memory, which can be a problem
if your data set is very large.  When trying to write a functionally
styled program, it would be natural to write something like:

     links = [link for link in get_all_links() if not link.followed]
     for link in links:
         ...

こうではなく

     for link in get_all_links():
         if link.followed:
             continue
         ...

最初の形の方が簡潔でおそらく読みやすいですが、扱っているのがとても多くの
リンクオブジェクトであるならば、全てのリンクオブジェクトが一気にメモリに
載らないように二つ目の形で書く必要がありました。

ジェネレータ式はリスト内包と似た動作をしますが、リスト全体を実体化しませ
ん; 代わりにそれは、要素を一つずつ返すジェネレータを返します。上述の例は
こう書けます:

     links = (link for link in get_all_links() if not link.followed)
     for link in links:
         ...

上の例でのように、ジェネレータ式は常に括弧の中に書かなければなりません。
関数呼び出しを囲む括弧もそれに含まれるので、関数にそのまま渡すイテレータ
を作りたければこれで良いです:

     print sum(obj.count for obj in list_all_objects())

ジェネレータ式はリスト内包とは色々小さい点で違います。最も顕著なのはルー
プ変数 (上の例での 'obj') がジェネレータ式の外からアクセス不能なことです
。リスト内包はループの制御変数が最後に代入された値で残ります; 将来のバー
ジョンの Python では、この振る舞いはリスト内包がこの点でジェネレータ式と
同じになるように変更されます。 (--訳注: Python 2.7 でもリスト内包のこの
振る舞いは変わっておらず、警告ともなりません。制御変数が内包のスコープ外
で可視でなくなったのは Python 3.0 からです。--)

参考
....

PEP 289(1) - ジェネレータ式

     Raymond Hettinger によって提案され、Hye-Shik Chang に導かれた早期の
     尽力によって Jiwon Seo により実装されました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0289/


File: python.info,  Node: PEP 292 より単純な文字列置換 string substitution,  Next: PEP 318 関数とメソッドのためのデコレータ,  Prev: PEP 289 ジェネレータ式,  Up: What's New in Python 2 4

1.18.4 PEP 292: より単純な文字列置換 (string substitution)
----------------------------------------------------------

標準ライブラリに、文字列を変数で置換するための代替メカニズムをもたらす新
しいくつかのクラスが追加されました; この置換のスタイルは、訓練されていな
いユーザがテンプレートを編集する必要があるようなアプリケーションにとって
、より良いものでしょう。

変数置換を名前で行うためのいつもの方法は ‘%’ 演算子です:

     >>> '%(page)i: %(title)s' % {'page':2, 'title': 'The Best of Times'}
     '2: The Best of Times'

テンプレート文字列を書くのに、閉じ括弧のあとの ‘i’ や ‘s’ を忘れやすいで
す。これはそのテンプレートが Python モジュール内にあるなら大問題でもあり
ません。コードを実行し、「サポートされないフォーマット文字 (unsupported
format character)」な *note ValueError: 1e3. を喰らい、問題を直すだけの
ことです。ですが、例えば Mailman のようなアプリケーションを考えてみてく
ださい。テンプレート文字列や翻訳は、Python 言語について承知していないユ
ーザが編集するのです。フォーマット文字列の構文はそのようなユーザに説明す
るには複雑で、彼らが間違いをやらかした場合には、親切なフィードバックを彼
らに与えるのは難しいのです。

PEP 292 は *note string: be. モジュールに ‘Template’ クラスを追加します
。これは置換を指示するのに ‘$’ を使います:

     >>> import string
     >>> t = string.Template('$page: $title')
     >>> t.substitute({'page':2, 'title': 'The Best of Times'})
     '2: The Best of Times'

辞書にキーが見つからない場合、 ‘substitute()’ メソッドは *note KeyError:
31d. を送出します。 ‘safe_substitute()’ メソッドもあり、これはキー不在を
無視します:

     >>> t = string.Template('$page: $title')
     >>> t.safe_substitute({'page':3})
     '3: $title'

参考
....

PEP 292(1) - より単純な文字列置換 (string substitution)

     Barry Warsaw 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0292/


File: python.info,  Node: PEP 318 関数とメソッドのためのデコレータ,  Next: PEP 322 逆順のイテレーション,  Prev: PEP 292 より単純な文字列置換 string substitution,  Up: What's New in Python 2 4

1.18.5 PEP 318: 関数とメソッドのためのデコレータ
------------------------------------------------

Python 2.2 は Python オブジェクトモデルを静的メソッド、クラスメソッドを
追加することで拡張はしましたが、それらを定義する新たな手段を提供するよう
な Python 構文の拡張はしませんでした。このため、 *note def: 13ff. でメソ
ッドは普通に書いたのち、新型メソッドとしての関数へ仕立て上げる *note
staticmethod(): 3ef. または *note classmethod(): 14c. にその結果のメソッ
ドを渡す、という手順を取る必要がありました。このような具合でした:

     class C:
        def meth (cls):
            ...

        meth = classmethod(meth)   # Rebind name to wrapped-up class method

メソッドがとても長かったりすると、関数のボディの後ろの *note
classmethod(): 14c. 呼び出しは見失ったり忘れたりしやすいものでした。

そのような定義をもっと読みやすくするために何か構文を追加する、という意図
は常にありましたが、2.2 のリリース時点では良い構文は明らかではありません
でした。本日時点でさえ 'いまだ' 明らかとは言えませんが、ユーザは静的メソ
ッドとクラスメソッドを簡単に手にする手段を注文し続けています; 新たな構文
的機能はこの要求に合うように追加されました。

この新たな機能は「関数デコレータ (function decorators)」と呼ばれます。こ
の名前は *note classmethod(): 14c, *note staticmethod(): 3ef, とその仲間
たちが関数オブジェクトに追加的な情報を保存することから着想を得たものです
; それらは関数をより多くの詳細で 'デコレート (修飾) している' というわけ
です。

記法は Java より拝借して ‘'@'’ 文字を指示子として使います。この新たな構
文を使うと、上記の例はこのように書けます:

     class C:

        @classmethod
        def meth (cls):
            ...

‘@classmethod’ は ‘meth=classmethod(meth)’ 代入の速記法です。より一般的
には、このように書けば…:

     @A
     @B
     @C
     def f ():
         ...

これはデコレータ前史の以下コードと等価です:

     def f(): ...
     f = A(B(C(f)))

デコレータは関数定義の前になければなりません。一行ごとに一つのデコレータ
です。 def ステートメントと同じ行にあってはダメです。つまり ‘@A def f():
...’ は不正です。モジュールレベルかクラス内の関数定義のみをデコレート出
来ます; クラス定義はデコレート出来ません。(-- 訳注: クラス定義のデコレー
タは Python 2.6 で追加されました (PEP 3129) 。--)

デコレータはただの関数です。引数としてデコレートされる関数を取り、同じ関
数か何か新しいオブジェクトを返すだけの。結果がほかのデコレータ適用される
の出ない限りは、デコレータの戻り値は呼び出し可能である必要はありません
(普通はそうですが)。あなた自身のデコレータを書くのは簡単です。続く単純な
例は、関数オブジェクトに単に属性をセットするだけのものです:

     >>> def deco(func):
     ...    func.attr = 'decorated'
     ...    return func
     ...
     >>> @deco
     ... def f(): pass
     ...
     >>> f
     <function f at 0x402ef0d4>
     >>> f.attr
     'decorated'
     >>>

もう少しだけ現実的な例として、続く例ではデコレータに、与えられた引数が整
数かどうかチェックさせてみます:

     def require_int (func):
         def wrapper (arg):
             assert isinstance(arg, int)
             return func(arg)

         return wrapper

     @require_int
     def p1 (arg):
         print arg

     @require_int
     def p2(arg):
         print arg*2

PEP 318(1) にある例はこのアイディアのもっと凝った版が含まれていて、それ
は要求型の指定と戻り値のチェックの両方が出来ます。

デコレータ関数は引数を取ることが出来ます。引数が与えられた場合、あなたの
デコレータ関数はそれら引数のみで呼び出され、そして新しいデコレータを返さ
なければなりません; この関数は単一の関数を取らなければならず、前述のよう
に関数を返さなければなりません。言い換えると、 ‘@A @B @C(args)’ はこうな
ります:

     def f(): ...
     _deco = C(args)
     f = A(B(_deco(f)))

これが正しいと理解するには少しばかり頭をひねる必要がありますが、難しすぎ
ることはありません。

A small related change makes the *note func_name: 12a2. attribute of
functions writable.  This attribute is used to display function names in
tracebacks, so decorators should change the name of any new function
that's constructed and returned.

参考
....

PEP 318(2) - 関数、メソッド、クラスのためのデコレータ

     Kevin D. Smith, Jim Jewett, Skip Montanaro により著されました。数多
     くの人々が関数デコレータ実装のパッチを書きましたが、実際にチェック
     インされたものは Mark Russell が書いた #979728 でした。

‘https://wiki.python.org/moin/PythonDecoratorLibrary’

     数多くのデコレータ例を含む Wiki ページ。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0318/

   (2) https://peps.python.org/pep-0318/


File: python.info,  Node: PEP 322 逆順のイテレーション,  Next: PEP 324 新しい subprocess モジュール,  Prev: PEP 318 関数とメソッドのためのデコレータ,  Up: What's New in Python 2 4

1.18.6 PEP 322: 逆順のイテレーション
------------------------------------

新しいビルトイン関数 ‘reversed(seq)’ は、シーケンスを受け取って、シーケ
ンスの要素を逆順にループするイテレータを返します:

     >>> for i in reversed(xrange(1,4)):
     ...    print i
     ...
     3
     2
     1

‘range(1,4)[::-1]’ のようにする拡張スライスでのやり方に比較して *note
reversed(): 831. は読みやすく、実行が高速で、大体の場合はメモリ使用が少
なく済みます。

*note reversed(): 831. は任意のイテレータは受け付けず、シーケンスのみ受
け付けることに注意してください。イテレータを逆順にしたければ、最初に
*note list(): 5dc. でリストに変換してください:

     >>> input = open('/etc/passwd', 'r')
     >>> for line in reversed(list(input)):
     ...   print line
     ...
     root:*:0:0:System Administrator:/var/root:/bin/tcsh
       ...

参考
....

PEP 322(1) - 逆順のイテレーション

     Raymond Hettinger 著、実装.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0322/


File: python.info,  Node: PEP 324 新しい subprocess モジュール,  Next: PEP 327 Decimal データ型,  Prev: PEP 322 逆順のイテレーション,  Up: What's New in Python 2 4

1.18.7 PEP 324: 新しい subprocess モジュール
--------------------------------------------

The standard library provides a number of ways to execute a subprocess,
offering different features and different levels of complexity.
‘os.system(command)’ is easy to use, but slow (it runs a shell process
which executes the command) and dangerous (you have to be careful about
escaping the shell's metacharacters).  The ‘popen2’ module offers
classes that can capture standard output and standard error from the
subprocess, but the naming is confusing.  The *note subprocess: c1.
module cleans this up, providing a unified interface that offers all the
features you might need.

Instead of ‘popen2’'s collection of classes, *note subprocess: c1.
contains a single class called *note subprocess.Popen: 17e. whose
constructor supports a number of different keyword arguments.

     class Popen(args, bufsize=0, executable=None,
                 stdin=None, stdout=None, stderr=None,
                 preexec_fn=None, close_fds=False, shell=False,
                 cwd=None, env=None, universal_newlines=False,
                 startupinfo=None, creationflags=0):

'args' は普通は文字列のシーケンスで、サブプロセスとして実行するプログラ
ムへの引数群となります。 ('shell' 引数が真の場合は 'args' はシェルに解釈
を任せるために渡す文字列に出来、つまりこの場合 *note os.system(): 1402.
と同じことをします。)

'stdin', 'stdout', 'stderr' はサブプロセスの入力・出力・エラーのストリー
ムを指定します。ファイルオブジェクトかファイル記述子を渡すことが出来ます
。あるいは定数 ‘subprocess.PIPE’ を渡してサブプロセスと親とのパイプを作
成することが出来ます。

コンストラクタには多くの便利なオプションがあります:

   * 'close_fds' はサブプロセス実行前に全てのファイル記述子をクローズす
     ることを要求します。

   * 'cwd' はサブプロセスを実行する作業ディレクトリを指定します (デフォ
     ルトは親の作業ディレクトリです)。

   * 'env' は環境変数を指定する辞書です。

   * 'preexec_fn' は子が開始する前に呼び出される関数です。

   * 'universal_newlines' で、子の入出力を、Python の *note universal
     newlines: d08. 機能で開きます。

‘Popen’ インスタンスを作ってしまえば、あとはサブプロセスが終了するまで停
止するために ‘wait()’ メソッド呼び出すことが出来、停止することなく終了を
チェックするのに ‘poll()’ メソッドを呼び出すことが出来、あるいは
‘communicate(data)’ を呼び出して、子の標準入力に 'data' を送信することが
出来ます。 ‘communicate(data)’ はサブプロセスが送信する標準出力と標準エ
ラー出力を読み込み、タプル ‘(stdout_data, stderr_data)’ を返します。

‘call()’ は ‘Popen’ コンストラクタにその引数を流し込むショートカットで、
コマンドが終了するまで待ち、サブプロセスの終了コードを返します。これは
*note os.system(): 1402. に対する安全な置き換えとなりえます:

     sts = subprocess.call(['dpkg', '-i', '/tmp/new-package.deb'])
     if sts == 0:
         # Success
         ...
     else:
         # dpkg returned an error
         ...

コマンドはシェルを使うことなく呼び出されます。もしシェルを本当に使いたい
のであればキーワード引数として ‘shell=True’ を与えた上でシーケンスの代わ
りに文字列を与えることが出来ます:

     sts = subprocess.call('dpkg -i /tmp/new-package.deb', shell=True)

PEP にはシェルと Python コードの様々な例が採られていて、シェルスクリプト
をいかにして *note subprocess: c1. を用いて Python コードに変換するかを
示しています。PEP のこのセクションを読むことを強くお勧めします。

参考
....

PEP 324(1) - subprocess - プロセスのための新たなモジュール

     Fredrik Lundh 他によるサポートによって、Peter Åstrand により PEP 著
     と実装が行われました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0324/


File: python.info,  Node: PEP 327 Decimal データ型,  Next: PEP 328 マルチラインインポート,  Prev: PEP 324 新しい subprocess モジュール,  Up: What's New in Python 2 4

1.18.8 PEP 327: Decimal データ型
--------------------------------

Python has always supported floating-point (FP) numbers, based on the
underlying C double type, as a data type.  However, while most
programming languages provide a floating-point type, many people (even
programmers) are unaware that floating-point numbers don't represent
certain decimal fractions accurately.  The new ‘Decimal’ type can
represent these fractions accurately, up to a user-specified precision
limit.

* Menu:

* なぜ Decimal が必要なのか?::
* Decimal 型::
* Context 型::


File: python.info,  Node: なぜ Decimal が必要なのか?,  Next: Decimal 型,  Up: PEP 327 Decimal データ型

1.18.8.1 なぜ Decimal が必要なのか?
...................................

浮動小数点数が使う表現方法に起因する制約があります。浮動小数点数は 3 つ
の構成要素から成ります:

   * 符号(sign)。正または負。

   * 仮数部(mantissa)。一桁の 2 進値に端数部が続きます。例えば 2 進数で
     ‘1.01’ は ‘1 + 0/2 + 1/4’ で 10 進表記で 1.25 です。

   * 指数部(exponent)。小数点がその数値のどこに位置するかを表します。

例えば 1.25 は、正の符号を持ち、仮数部の値は (2 進数で) 1.01 で、指数部
は 0 です (小数点は移動の必要がありません)。5 は同じ符号と仮数部を持ち、
指数部は、仮数部が 4 倍なので 2 (2 を底とする 2 の 冪乗) です; 1.25 * 4
は 5 です。

Modern systems usually provide floating-point support that conforms to a
standard called IEEE 754.  C's double type is usually implemented as a
64-bit IEEE 754 number, which uses 52 bits of space for the mantissa.
This means that numbers can only be specified to 52 bits of precision.
If you're trying to represent numbers whose expansion repeats endlessly,
the expansion is cut off after 52 bits.  Unfortunately, most software
needs to produce output in base 10, and common fractions in base 10 are
often repeating decimals in binary.  For example, 1.1 decimal is binary
‘1.0001100110011 ...’; .1 = 1/16 + 1/32 + 1/256 plus an infinite number
of additional terms.  IEEE 754 has to chop off that infinitely repeated
decimal after 52 digits, so the representation is slightly inaccurate.

ときどきあなたはこの不正確さを、数値を表示する際に目にするでしょう:

     >>> 1.1
     1.1000000000000001

この不正確さは数値を表示する際にいつでも目に見えるわけではありません。浮
動小数点数から文字列への変換が C ライブラリによって提供されていて、C ラ
イブラリのほとんどが賢明な出力を生成しようと頑張っているからです。それが
表示されないにしても、不正確さはそれでも存在していて、後続の計算への誤差
が大きくなりえます。

多くのアプリケーションではこれは重要ではありません。モニタにプロットして
表示するのに 1.1 と 1.1000000000000001 の差は小さすぎて見えません。大抵
は出力を一定の桁位置までに制限して出力するものですし、2 やら 3 やら 8 桁
などの位置で丸めたりすれば誤差は決して露わにはなりません。ですがそれが重
要なアプリケーションにとっては、あなた自身のカスタム数学ルーチンのための
実装作業は膨大になります。

こうして ‘Decimal’ 型が作られました。


File: python.info,  Node: Decimal 型,  Next: Context 型,  Prev: なぜ Decimal が必要なのか?,  Up: PEP 327 Decimal データ型

1.18.8.2 ‘Decimal’ 型
.....................

新しいモジュール *note decimal: 2e. が Python 標準ライブラリに追加されま
した。これには 2 つのクラス ‘Decimal’, ‘Context’ を含みます。 ‘Decimal’
インスタンスは数値を表現し、 ‘Context’ インスタンスは、精度やデフォルト
の丸めモードなどのさまざまな設定をまとめるのに使われます。

‘Decimal’ のインスタンスは普通の Python 整数や浮動小数点数のように *note
immutable: 1272. です。 ‘Decimal’ のインスタンスは整数や文字列から構築出
来ます:

     >>> import decimal
     >>> decimal.Decimal(1972)
     Decimal("1972")
     >>> decimal.Decimal("1.1")
     Decimal("1.1")

符号(sign)、10進数値のタプルで表した仮数部(mantissa)、指数部(exponent)を
含んだタプルを渡すことも出来ます:

     >>> decimal.Decimal((1, (1, 4, 7, 5), -2))
     Decimal("-14.75")

注意: 符号ビットは負符号の有無なので、 0 が正、1 が負です。

浮動小数点数からの変換は少々問題です: 1.1 を表現する浮動小数点数は 10 進
数値の正確な 1.1 に変換すべきでしょうか、それとも 1.1 が持つどんな不正確
さもそのまま持ち込むべきでしょうか?  決定は、問題をはぐらかして、その種
の変換を API の範疇外とする、というものでした。代わりにあなたは浮動小数
点数を望みの精度で文字列に変換して、その文字列を ‘Decimal’ コンストラク
タに渡す必要があります:

     >>> f = 1.1
     >>> decimal.Decimal(str(f))
     Decimal("1.1")
     >>> decimal.Decimal('%.12f' % f)
     Decimal("1.100000000000")

いったん ‘Decimal’ を手にしてしまえばあとは普通の数学演算が使えます。制
約の一つ: べき乗には整数の指数しか使えません:

     >>> a = decimal.Decimal('35.72')
     >>> b = decimal.Decimal('1.73')
     >>> a+b
     Decimal("37.45")
     >>> a-b
     Decimal("33.99")
     >>> a*b
     Decimal("61.7956")
     >>> a/b
     Decimal("20.64739884393063583815028902")
     >>> a ** 2
     Decimal("1275.9184")
     >>> a**b
     Traceback (most recent call last):
       ...
     decimal.InvalidOperation: x ** (non-integer)

‘Decimal’ インスタンスと整数は混ぜて使えますが、浮動小数点数とは出来ませ
ん:

     >>> a + 4
     Decimal("39.72")
     >>> a + 4.5
     Traceback (most recent call last):
       ...
     TypeError: You can interact Decimal only with int, long or Decimal data types.
     >>>

‘Decimal’ 数を *note math: 81, *note cmath: 11. モジュールで使うことは出
来ますが、演算実行前にその場で浮動小数点数に変換されて、結果精度と正確性
を失う可能性があります。戻り値は普通の浮動小数点数であって ‘Decimal’ で
はありません:

     >>> import math, cmath
     >>> d = decimal.Decimal('123456789012.345')
     >>> math.sqrt(d)
     351364.18288201344
     >>> cmath.sqrt(-d)
     351364.18288201344j

‘Decimal’ インスタンスは ‘Decimal’ インスタンスを返す ‘sqrt()’ メソッド
を持っていますが、三角関数のようななにかほかのことが必要な場合は、それら
を実装する必要があるでしょう。:

     >>> d.sqrt()
     Decimal("351364.1828820134592177245001")


File: python.info,  Node: Context 型,  Prev: Decimal 型,  Up: PEP 327 Decimal データ型

1.18.8.3 ‘Context’ 型
.....................

‘Context’ クラスのインスタンスは decimal 演算についてのいくつかの設定を
カプセル化しています:

   * ‘prec’ は精度で、小数桁数です。

   * ‘rounding’ は丸めのモードを指定します。 *note decimal: 2e. にはこの
     値に渡せる定数が定義されています: ‘ROUND_DOWN’, ‘ROUND_CEILING’,
     ‘ROUND_HALF_EVEN’, それに色々。

   * ‘traps’ は特定のエラー状態に出会った場合に何が起こるべきかを指定す
     る辞書です: 例外を発生させるか値を返すかどちらかです。いくつかのエ
     ラー状態の例としては、ゼロ除算、精度損失、オーバーフローがあります
     。

スレッドローカルなデフォルトのコンテキストを、 ‘getcontext()’ を呼び出す
ことで利用出来ます; デフォルトの精度、丸めモード、トラップ処理に代えてこ
のコンテキストのプロパティを変更出来ます。続く例はデフォルトコンテキスト
の精度を変更する効果についてお見せします:

     >>> decimal.getcontext().prec
     28
     >>> decimal.Decimal(1) / decimal.Decimal(7)
     Decimal("0.1428571428571428571428571429")
     >>> decimal.getcontext().prec = 9
     >>> decimal.Decimal(1) / decimal.Decimal(7)
     Decimal("0.142857143")

エラー状態の場合のデフォルトアクションを選択出来ます; モジュールは無限大
(infinity)あるいは非数(not-a-number: NaN)を返すか、例外を投げるかです:

     >>> decimal.Decimal(1) / decimal.Decimal(0)
     Traceback (most recent call last):
       ...
     decimal.DivisionByZero: x / 0
     >>> decimal.getcontext().traps[decimal.DivisionByZero] = False
     >>> decimal.Decimal(1) / decimal.Decimal(0)
     Decimal("Infinity")
     >>>

‘Context’ インスタンスは ‘to_eng_string()’, ‘to_sci_string()’ のような、
数値の書式化のための色々なメソッドも持っています。

さらに詳しく知りたければ *note decimal: 2e. モジュールのドキュメントを読
んで下さい。これには簡単に始められるチュートリアルとリファレンスが入って
います。

参考
....

PEP 327(1) - Decimal データ型

     Facundo Batista によって著され、Facundo Batista, Eric Price,
     Raymond Hettinger, Aahz, Tim Peters らによって実装されました。

http://www.lahey.com/float.htm(2)

     この記事は浮動小数点数の不正確さが起こりうるたくさんの問題について
     、Fortran コードを使って解説しています。

‘https://speleotrove.com/decimal/’

     10 進数ベースの表現についての記述です(訳注: decimal-based は小数ベ
     ースとも 10 進数ベースとも取れるのですが、後者にしておきました)。こ
     の表現方法は標準として提案されていて、この Python の decimal 型の基
     礎になっています。この題材の多くが Rexx 言語設計者である Mike
     Cowlishaw によって著されました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0327/

   (2) 
https://web.archive.org/web/20230604072523/http://www.lahey.com/float.htm


File: python.info,  Node: PEP 328 マルチラインインポート,  Next: PEP 331 Locale に依存しない Float/String 変換,  Prev: PEP 327 Decimal データ型,  Up: What's New in Python 2 4

1.18.9 PEP 328: マルチラインインポート
--------------------------------------

言語の変更の一つは小さな文法的な微調整で、モジュールからたくさんの名前を
インポートするのを簡単にするためのものです。 ‘from module import names’
文において、 'names' はカンマ区切りのシーケンスです。シーケンスがとても
長くなった場合、同じモジュールからのインポート文を何度も書くか、行末をバ
ックスラッシュでエスケープするかするでしょう、このように:

     from SimpleXMLRPCServer import SimpleXMLRPCServer,\
                 SimpleXMLRPCRequestHandler,\
                 CGIXMLRPCRequestHandler,\
                 resolve_dotted_attribute

Python 2.4 での文法的な変更は、単純に names を丸括弧で囲んでも良い、とす
るだけのものです。Python は丸括弧内の改行を無視しますので、バックスラッ
シュはもう必要ありません:

     from SimpleXMLRPCServer import (SimpleXMLRPCServer,
                                     SimpleXMLRPCRequestHandler,
                                     CGIXMLRPCRequestHandler,
                                     resolve_dotted_attribute)

その PEP は、全ての *note import: 5ac. 文が絶対インポートであること、相
対インポートであることを示すには ‘.’ 文字で開始すること、の提案もしてい
ます。PEP のこの部分は Python 2.4 では実装されていませんが、 Python 2.5
向けには完了しています。

参考
....

PEP 328(1) - マルチラインインポートと、絶対/相対インポート

     Aahz 著.  Multi-line imports は Dima Dorfman により実装。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0328/


File: python.info,  Node: PEP 331 Locale に依存しない Float/String 変換,  Next: その他の言語変更<15>,  Prev: PEP 328 マルチラインインポート,  Up: What's New in Python 2 4

1.18.10 PEP 331: Locale に依存しない Float/String 変換
------------------------------------------------------

*note locale: 7a. モジュールにより、Python ソフトウェアは特定の国や言語
の地域化をする色々な変換や表示の変換を選択出来ます。ところがこのモジュー
ルは、数値ロケールを変更しないように気を配らなければなりませんでした。と
いうのも Python 内の色んな関数実装が、数値ロケールが ‘'C'’ ロケールにセ
ットされたままであることを必要としていたからです。しばしばこれは、コード
が C ライブラリの ‘atof()’ 関数を使っていることに原因がありました。

Not setting the numeric locale caused trouble for extensions that used
third-party C libraries, however, because they wouldn't have the correct
locale set.  The motivating example was GTK+, whose user interface
widgets weren't displaying numbers in the current locale.

この PEP に記述された解法は、ロケール設定を無視して ASCII のみの変換を実
施する 3 つの新しい Python API 関数を追加することです:

   * ‘PyOS_ascii_strtod(str, ptr)’ and ‘PyOS_ascii_atof(str, ptr)’ both
     convert a string to a C double.

   * ‘PyOS_ascii_formatd(buffer, buf_len, format, d)’ converts a double
     to an ASCII string.

The code for these functions came from the GLib library
(https://developer-old.gnome.org/glib/2.26/(1)), whose developers kindly
relicensed the relevant functions and donated them to the Python
Software Foundation.  The *note locale: 7a. module can now change the
numeric locale, letting extensions such as GTK+ produce the correct
results.

参考
....

PEP 331(2) - Locale に依存しない Float/String 変換

     Christian R. Reis 著, 実装 Gustavo Carneiro.

   ---------- Footnotes ----------

   (1) 
http://web.archive.org/web/20210306104320/https://developer.gnome.org/glib/2.26/

   (2) https://peps.python.org/pep-0331/


File: python.info,  Node: その他の言語変更<15>,  Next: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>,  Prev: PEP 331 Locale に依存しない Float/String 変換,  Up: What's New in Python 2 4

1.18.11 その他の言語変更
------------------------

以下が、Python 2.4 言語コアに加えられた全ての変更点です。

   * 関数とメソッドのためのデコレータが追加されました。 ( PEP 318(1)).

   * ビルトインの *note set(): 5a3. 型と *note frozenset(): 5a4. 型が追
     加されました ( PEP 218(2))。ほか新たなビルトイン関数
     ‘reversed(seq)’ 関数が追加されました ( PEP 322(3))。

   * ジェネレータ式が追加されました ( PEP 289(4)).

   * いくらかの数値式は、もう 32 ビットや 64 ビットに制限されません (
     PEP 237(5)).

   * ‘from module import names’ ステートメントにおいて、 'names' を括弧
     で囲むことが出来るようになりました ( PEP 328(6)).

   * *note dict.update(): 140a. メソッドが *note dict: 237. コンストラク
     タと同じ形式の引数を取れるようになりました。これには任意のマッピン
     グ、キー/値ペアのイテラブルとキーワード引数を含みます。
     (Contributed by Raymond Hettinger.)

   * 文字列の ‘ljust()’, ‘rjust()’, ‘center()’ メソッドで空白以外の埋め
     文字を省略可能引数で指定出来るようになりました。 (Contributed by
     Raymond Hettinger.)

   * ほかに、文字列には ‘rsplit()’ メソッドも追加されています。これは
     ‘split()’ メソッドと似た動きをしますが、後ろから順に分割します
     (Contributed by Sean Reifschneider.)

          >>> 'www.python.org'.split('.', 1)
          ['www', 'python.org']
          'www.python.org'.rsplit('.', 1)
          ['www.python', 'org']

   * リストの ‘sort()’ メソッドに 3 つのキーワード引数 'cmp', 'key',
     'reverse' が追加されています。これらパラメータは ‘sort()’ のある種
     の用法を単純にします。これらは全て省略可能です。

     'cmp' パラメータには比較関数を渡します。これは 2 つのパラメータを取
     り、パラメータの比較結果に応じて -1, 0, +1 のいずれかを返します。こ
     の関数はリストのソートに使われます。これまでの ‘sort()’ に唯一許さ
     れていたのがこの 'cmp' パラメータでした。

     'key' には単一パラメータ関数を渡します。これはリスト要素を受け取り
     、要素の比較キーを返す関数です。リストはその比較キーを使ってソート
     されます。続く例はリストを大文字小文字区別なく並び替えます:

          >>> L = ['A', 'b', 'c', 'D']
          >>> L.sort()                 # Case-sensitive sort
          >>> L
          ['A', 'D', 'b', 'c']
          >>> # Using 'key' parameter to sort list
          >>> L.sort(key=lambda x: x.lower())
          >>> L
          ['A', 'b', 'c', 'D']
          >>> # Old-fashioned way
          >>> L.sort(cmp=lambda x,y: cmp(x.lower(), y.lower()))
          >>> L
          ['A', 'b', 'c', 'D']

     例の最後のものは 'cmp' パラメータを使っています。これが大文字小文字
     区別のない並び替えの昔ながらの方法です。むろん動きます。が、 'key'
     パラメータでのやり方より遅いです。 'cmp' では ‘lower()’ メソッド呼
     び出しが比較ごとなので要素ごとに 2 回呼び出すことになりますが、
     'key' だと呼び出しはそれぞれの要素ごとに ‘lower()’ 呼び出しを一回だ
     けで済ませられます。

     単純なキー関数や比較関数には、しばしば *note lambda: 126d. 関数を避
     けて非束縛メソッドを使えます。例えば上記の大文字小文字によらない並
     べ替えはこのように書くのが最善です:

          >>> L.sort(key=str.lower)
          >>> L
          ['A', 'b', 'c', 'D']

     最後の 'reverse' パラメータはブーリアン値を取ります。真ならばリスト
     は逆順にソートされます。 ‘L.sort(); L.reverse()’ と書く代わりにこれ
     からは ‘L.sort(reverse=True)’ と書けます。

     ソートの結果がステーブル(安定)であることが保障されるようになりまし
     た。つまり 2 つの要素が同列である場合、入力と同じ順序が保たれます。
     例えば人物リストを名前でソートしたのちに年齢でソートすると結果は、
     年齢でソートされていますが同年齢の人物は名前順です。

     (All changes to ‘sort()’ contributed by Raymond Hettinger.)

   * 新たに追加されたビルトイン関数 ‘sorted(iterable)’ はインプレイスな
     メソッド *note list.sort(): b9d. と似た振る舞いをしますが、式内で使
     えます。違いは:

   * 入力には任意のイテラブルを取れます;

   * 新しく構築されたコピーをソートし、オリジナルは無傷のままにします; そ
     して

   * 式として新しいソート済みコピーを返します。

          >>> L = [9,7,8,3,2,4,1,6,5]
          >>> [10+i for i in sorted(L)]       # usable in a list comprehension
          [11, 12, 13, 14, 15, 16, 17, 18, 19]
          >>> L                               # original is left unchanged
          [9,7,8,3,2,4,1,6,5]
          >>> sorted('Monty Python')          # any iterable may be an input
          [' ', 'M', 'P', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y', 'y']

          >>> # List the contents of a dict sorted by key values
          >>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5)
          >>> for k, v in sorted(colormap.iteritems()):
          ...     print k, v
          ...
          black 4
          blue 2
          green 3
          red 1
          yellow 5

     (Contributed by Raymond Hettinger.)

   * 整数演算はもはや ‘OverflowWarning’ は引き起こしません。
     ‘OverflowWarning’ 警告は Python 2.5 で撤廃されます。

   * インタプリタに新たに *note -m: 5ab. スイッチが加わりました。これは
     名前を取り、 ‘sys.path’ にある対応するモジュールを検索し、そしてそ
     のモジュールをスクリプトとして実行します。たとえば Python プロファ
     イラを ‘python -m profile’ で起動することが出来るようになりました。
     (Contributed by Nick Coghlan.)

   * ‘eval(expr, globals, locals)’ 関数と ‘execfile(filename, globals,
     locals)’ 関数、 ‘exec’ 文が 'locals' パラメータに任意のマッピング型
     を受け取れるようになりました。以前は正規の Python 辞書である必要が
     ありました。 (Contributed by Raymond Hettinger.)

   * ビルトイン関数の *note zip(): 79b. と ‘itertools.izip()’ が引数なし
     で呼ばれた場合に空リストを返すようになりました。以前は *note
     TypeError: 502. 例外でした。これにより可変引数リストをこなしやすく
     なります:

          >>> def transpose(array):
          ...    return zip(*array)
          ...
          >>> transpose([(1,2,3), (4,5,6)])
          [(1, 4), (2, 5), (3, 6)]
          >>> transpose([])
          []

     (Contributed by Raymond Hettinger.)

   * Encountering a failure while importing a module no longer leaves a
     partially initialized module object in ‘sys.modules’.  The
     incomplete module object left behind would fool further imports of
     the same module into succeeding, leading to confusing errors.
     (Fixed by Tim Peters.)

   * *note None: 641. が定数になっています。 ‘None’ という名前に新しい値
     を割り当てようとするコードは、今では構文エラーになります。
     (Contributed by Raymond Hettinger.)

* Menu:

* 最適化: 最適化<14>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0318/

   (2) https://peps.python.org/pep-0218/

   (3) https://peps.python.org/pep-0322/

   (4) https://peps.python.org/pep-0289/

   (5) https://peps.python.org/pep-0237/

   (6) https://peps.python.org/pep-0328/


File: python.info,  Node: 最適化<14>,  Up: その他の言語変更<15>

1.18.11.1 最適化
................

   * The inner loops for list and tuple slicing were optimized and now
     run about one-third faster.  The inner loops for dictionaries were
     also optimized, resulting in performance boosts for ‘keys()’,
     ‘values()’, ‘items()’, ‘iterkeys()’, ‘itervalues()’, and
     ‘iteritems()’.  (Contributed by Raymond Hettinger.)

   * The machinery for growing and shrinking lists was optimized for
     speed and for space efficiency.  Appending and popping from lists
     now runs faster due to more efficient code paths and less frequent
     use of the underlying system ‘realloc()’.  List comprehensions also
     benefit.  ‘list.extend()’ was also optimized and no longer converts
     its argument into a temporary list before extending the base list.
     (Contributed by Raymond Hettinger.)

   * *note list(): 5dc, *note tuple(): 349, *note map(): 82f, *note
     filter(): 830, and *note zip(): 79b. now run several times faster
     with non-sequence arguments that supply a ‘__len__()’ method.
     (Contributed by Raymond Hettinger.)

   * The methods ‘list.__getitem__()’, ‘dict.__getitem__()’, and
     ‘dict.__contains__()’ are now implemented as ‘method_descriptor’
     objects rather than ‘wrapper_descriptor’ objects.  This form of
     access doubles their performance and makes them more suitable for
     use as arguments to functionals: ‘map(mydict.__getitem__,
     keylist)’.  (Contributed by Raymond Hettinger.)

   * Added a new opcode, ‘LIST_APPEND’, that simplifies the generated
     bytecode for list comprehensions and speeds them up by about a
     third.  (Contributed by Raymond Hettinger.)

   * The peephole bytecode optimizer has been improved to produce
     shorter, faster bytecode; remarkably, the resulting bytecode is
     more readable.  (Enhanced by Raymond Hettinger.)

   * String concatenations in statements of the form ‘s = s + "abc"’ and
     ‘s += "abc"’ are now performed more efficiently in certain
     circumstances.  This optimization won't be present in other Python
     implementations such as Jython, so you shouldn't rely on it; using
     the ‘join()’ method of strings is still recommended when you want
     to efficiently glue a large number of strings together.
     (Contributed by Armin Rigo.)

The net result of the 2.4 optimizations is that Python 2.4 runs the
pystone benchmark around 5% faster than Python 2.3 and 35% faster than
Python 2.2.  (pystone is not a particularly good benchmark, but it's the
most commonly used measurement of Python's performance.  Your own
applications may show greater or smaller benefits from Python 2.4.)


File: python.info,  Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>,  Next: ビルドならびに C API の変更<11>,  Prev: その他の言語変更<15>,  Up: What's New in Python 2 4

1.18.12 新たなモジュール、改良されたモジュール、非推奨のモジュール
------------------------------------------------------------------

いつものように、Python の標準ライブラリには数多くの拡張とバグ修正があり
ました。ここでは最も注目に値する変更について、モジュールの辞書順に列挙し
ます。変更の完全なリストについてはソースツリーの ‘Misc/NEWS’ を調べるか
、あるいは全ての詳細について CVS ログに目を通してみてください。

   * The ‘asyncore’ module's ‘loop()’ function now has a 'count'
     parameter that lets you perform a limited number of passes through
     the polling loop.  The default is still to loop forever.

   * The *note base64: a. module now has more complete RFC 3548(1)
     support for Base64, Base32, and Base16 encoding and decoding,
     including optional case folding and optional alternative alphabets.
     (Contributed by Barry Warsaw.)

   * *note bisect: d. モジュールが性能改善のために C 実装を使うようにな
     りました。 (Contributed by Dmitry Vasiliev.)

   * Hye-Shik Chang によって保守されている東アジアのコーデックの
     CJKCodecs コレクションが Python 2.4 に統合されました。新たなエンコ
     ーディングは:

   * Chinese (PRC): gb2312, gbk, gb18030, big5hkscs, hz

   * Chinese (ROC): big5, cp950

   * 
     Japanese: cp932, euc-jis-2004, euc-jp, euc-jisx0213, iso-2022-jp,

          iso-2022-jp-1, iso-2022-jp-2, iso-2022-jp-3, iso-2022-jp-ext,
          iso-2022-jp-2004, shift-jis, shift-jisx0213, shift-jis-2004

   * Korean: cp949, euc-kr, johab, iso-2022-kr

   * ほか、新たなエンコーディングが追加されています: HP Roman8,
     ISO_8859-11, ISO_8859-16, PCTP-154, TIS-620.

   * UTF-8, UTF-16 コーデックが部分的な入力を受け取った場合により上手に
     処理するようになりました。以前は ‘StreamReader’ クラスは不足データ
     を読み出そうと試みるために、それがストリームからデコード処理を再開
     することを不可能にしていました。 ‘read()’ メソッドは今ではそのとき
     読めているデータを返し、次の呼び出しで以前の読み残しのデコード処理
     から再開します。(Implemented by Walter Dörwald.)

   * There is a new *note collections: 16. module for various
     specialized collection datatypes.  Currently it contains just one
     type, ‘deque’, a double-ended queue that supports efficiently
     adding and removing elements from either end:

          >>> from collections import deque
          >>> d = deque('ghi')        # make a new deque with three items
          >>> d.append('j')           # add a new entry to the right side
          >>> d.appendleft('f')       # add a new entry to the left side
          >>> d                       # show the representation of the deque
          deque(['f', 'g', 'h', 'i', 'j'])
          >>> d.pop()                 # return and remove the rightmost item
          'j'
          >>> d.popleft()             # return and remove the leftmost item
          'f'
          >>> list(d)                 # list the contents of the deque
          ['g', 'h', 'i']
          >>> 'h' in d                # search the deque
          True

     ‘Queue’ や *note threading: d6. のようないくつかのモジュールで、
     *note collections.deque: 5a6. を生かして性能改善を成し遂げています
     。 (Contributed by Raymond Hettinger.)

   * The *note ConfigParser: 1b. classes have been enhanced slightly.
     The *note read(): 140d. method now returns a list of the files that
     were successfully parsed, and the *note set(): 123e. method raises
     *note TypeError: 502. if passed a 'value' argument that isn't a
     string.  (Contributed by John Belmonte and David Goodger.)

   * *note curses: 23. モジュールが ncurses 拡張の
     ‘use_default_colors()’ をサポートするようになりました。透明性をサポ
     ートするターミナルを持つプラットフォームならば、このことで透明背景
     に出来ます。 (Contributed by Jörg Lehmann.)

   * *note difflib: 2f. モジュールに ‘HtmlDiff’ クラスが追加されています
     。これは対象テキストをサイドバイサイドで視覚化する HTML テーブルを
     作ります。 (Contributed by Dan Gass.)

   * *note email: 32. パッケージがバージョン 3.0 に更新されています。多
     くの非推奨だった API が削除され、Python 2.3 以前のバージョンへのサ
     ポートが削除されています。パッケージのバージョン 3.0 は MIME メッセ
     ージについての漸増的な新パーサを使います。これは ‘email.FeedParser’
     モジュールで利用可能です。この新パーサはメモリ内に全てのメッセージ
     を読み込んでおく必要がなく、メッセージが不正であっても例外は投げま
     せん; 代わりにメッセージの全ての問題についてを ‘defect’ 属性に記録
     します。 (Developed by Anthony Baxter, Barry Warsaw, Thomas
     Wouters, and others.)

   * *note heapq: 5f. モジュールは C に変換されました。性能改善は 10 倍
     となり、モジュールはより大きなデータを扱うのに相応しいものになりま
     した。加えて、モジュールには新しく 2 つの関数が追加されました。それ
     は ‘nlargest()’ と ‘nsmallest()’ で、データセット内の大きいものから
     N 番目まで、小さいものから N 番目までを、高価な完全なソートを要する
     ことなく取り出すのに使います。(Contributed by Raymond Hettinger.)

   * The *note httplib: 64. module now contains constants for HTTP
     status codes defined in various HTTP-related RFC documents.
     Constants have names such as ‘OK’, ‘CREATED’, ‘CONTINUE’, and
     ‘MOVED_PERMANENTLY’; use pydoc to get a full list.  (Contributed by
     Andrew Eland.)

   * *note imaplib: 6a. モジュールが IMAP の THREAD コマンドをサポートす
     るようになりました。 (contributed by Yves Dionne) また、
     ‘deleteacl()’ メソッドと ‘myrights()’ メソッドが追加されました。
     (contributed by Arnaud Mazin).

   * *note itertools: 75. モジュールに ‘groupby(iterable[, *func*])’ 関
     数が追加されました。 'iterable' は何か要素のストリームを返すものを
     イテレート出来るもので、省略可能な 'func' パラメータは要素を取って
     キー値を返す関数です。省略されればキーは要素自身です。 ‘groupby()’
     は要素群をキー値の合致ごとサブシーケンスにグループ化して、キー値と
     サブシーケンスに対するイテレータを組とする 2 要素タプルのシリーズを
     返します。

     例をお見せするのが早いでしょう。ここでは 'key' 関数は単に数値が偶数
     か奇数かを返すだけです。 ‘groupby()’ の結果は偶数または奇数の一連の
     流れを返します:

          >>> import itertools
          >>> L = [2, 4, 6, 7, 8, 9, 11, 12, 14]
          >>> for key_val, it in itertools.groupby(L, lambda x: x % 2):
          ...    print key_val, list(it)
          ...
          0 [2, 4, 6]
          1 [7]
          0 [8]
          1 [9, 11]
          0 [12, 14]
          >>>

     ‘groupby()’ は典型的にはソート済み入力に使います。 ‘groupby()’ のロ
     ジックは除外、数え上げ、重複要素の特定を手軽に行う Unix の ‘uniq’ フ
     ィルタに似ています:

          >>> word = 'abracadabra'
          >>> letters = sorted(word)   # Turn string into a sorted list of letters
          >>> letters
          ['a', 'a', 'a', 'a', 'a', 'b', 'b', 'c', 'd', 'r', 'r']
          >>> for k, g in itertools.groupby(letters):
          ...    print k, list(g)
          ...
          a ['a', 'a', 'a', 'a', 'a']
          b ['b', 'b']
          c ['c']
          d ['d']
          r ['r', 'r']
          >>> # List unique letters
          >>> [k for k, g in groupby(letters)]
          ['a', 'b', 'c', 'd', 'r']
          >>> # Count letter occurrences
          >>> [(k, len(list(g))) for k, g in groupby(letters)]
          [('a', 5), ('b', 2), ('c', 1), ('d', 1), ('r', 2)]

     (Contributed by Hye-Shik Chang.)

   * *note itertools: 75. には ‘tee(iterator, N)’ という新たな関数も追加
     されています。これは 'iterator' の、独立した 'N' 個の複製イテレータ
     を返します。 'N' は省略されればデフォルトは 2 です。:

          >>> L = [1,2,3]
          >>> i1, i2 = itertools.tee(L)
          >>> i1,i2
          (<itertools.tee object at 0x402c2080>, <itertools.tee object at 0x402c2090>)
          >>> list(i1)               # Run the first iterator to exhaustion
          [1, 2, 3]
          >>> list(i2)               # Run the second iterator to exhaustion
          [1, 2, 3]

     ‘tee()’ がイテレータから返される値のコピーを維持する必要があること
     に注意してください。最悪の場合はそれら全てを維持する必要があるかも
     しれません。ですのでこれは長丁場の入力に対して、先行するイテレータ
     が後続のイテレータの遥か先を突っ走れる場合には注意深く使わなければ
     なりません。その分断が大きいようであれば、 *note list(): 5dc. を代
     わりに使うほうが良いかもしれません。イテレータたちが相互に近い場所
     を追跡する場合は ‘tee()’ は理想的です。ブックマーク、ウィンドウ処理
     、あるいは先読みイテレータといったものに適用出来るのではないでしょ
     うか。 (Contributed by Raymond Hettinger.)

   * A number of functions were added to the *note locale: 7a. module,
     such as ‘bind_textdomain_codeset()’ to specify a particular
     encoding and a family of ‘l*gettext()’ functions that return
     messages in the chosen encoding.  (Contributed by Gustavo
     Niemeyer.)

   * *note logging: 7b. パッケージの ‘basicConfig()’ 関数に、ログ設定を
     簡単にするいくつかのキーワード引数が追加されました。デフォルトの振
     る舞いはログメッセージを標準エラー出力に出力することですが、様々な
     キーワード引数でログを特定のファイルに書いたり、ログのフォーマット
     を変えたり、ロギングのレベルを変えたり出来ます。例えば:

          import logging
          logging.basicConfig(filename='/var/log/application.log',
              level=0,  # Log all messages
              format='%(levelname):%(process):%(thread):%(message)')

     ほかの *note logging: 7b. パッケージへの追加としては、 便利メソッド
     ‘log(level, msg)’ や、ログファイルを時間間隔でローテートするクラス
     ‘TimedRotatingFileHandler’ などがあります。モジュールには元々
     ‘RotatingFileHandler’ が含まれており、こちらはファイルが特定のサイ
     ズを超過した場合にローテートするものです。両クラスとも新しく導出さ
     れた ‘BaseRotatingHandler’ 基底クラスから派生していて、これはまた別
     のローテートするハンドラを実装するのに使えます。

     (Changes implemented by Vinay Sajip.)

   * *note marshal: 80. モジュールが、データ構造のアンパックで内部化した
     文字列を共有するようになりました。これはある種の pickle 文字列のサ
     イズを切り詰めるでしょうが、主要な効能は ‘.pyc’ ファイルが顕著に小
     さくなることです。(Contributed by Martin von Löwis.)

   * The ‘nntplib’ module's ‘NNTP’ class gained ‘description()’ and
     ‘descriptions()’ methods to retrieve newsgroup descriptions for a
     single group or for a range of groups.  (Contributed by Jürgen A.
     Erhard.)

   * *note operator: 8f. モジュールに 2 つの関数 ‘attrgetter(attr)’ と
     ‘itemgetter(index)’ が追加されています。両関数ともに、単一引数を取
     ってそれに対応する属性かアイテムを返す呼び出し可能オブジェクトを返
     します。これら呼び出し可能オブジェクトは *note map(): 82f. や *note
     sorted(): b9c. とともに使う際の優れたデータ抽出器になります。例えば
     :

          >>> L = [('c', 2), ('d', 1), ('a', 4), ('b', 3)]
          >>> map(operator.itemgetter(0), L)
          ['c', 'd', 'a', 'b']
          >>> map(operator.itemgetter(1), L)
          [2, 1, 4, 3]
          >>> sorted(L, key=operator.itemgetter(1)) # Sort list by second tuple item
          [('d', 1), ('c', 2), ('b', 3), ('a', 4)]

     (Contributed by Raymond Hettinger.)

   * *note optparse: 90. モジュールが色々更新されました。モジュールはメ
     ッセージを *note gettext.gettext(): 140e. を通して Optik のヘルプと
     エラーメッセージを国際化するのを可能にしています。オプションのヘル
     プメッセージは文字列 ‘'%default'’ を含めることが出来るようになって
     おり、これはオプションのデフォルト値に置換されます。(Contributed by
     Greg Ward.)

   * The long-term plan is to deprecate the ‘rfc822’ module in some
     future Python release in favor of the *note email: 32. package.  To
     this end, the *note email.Utils.formatdate: 140f. function has been
     changed to make it usable as a replacement for
     ‘rfc822.formatdate()’.  You may want to write new e-mail processing
     code with this in mind.  (Change implemented by Anthony Baxter.)

   * *note os: 91. モジュールに ‘urandom(n)’ が追加されました。これは
     'n' バイトの乱数データを含む文字列を返します。この関数はプラットフ
     ォーム固有の乱数発生源にアクセスします。例えば Linux での
     ‘/dev/urandom’ や Windows での CryptoAPI です。 (Contributed by
     Trevor Perrin.)

   * もう一つの新規関数 ‘os.path.lexists(path)’ は 'path' によって指定さ
     れたファイルがそれがシンボリックリンクかどうかによらず、存在してい
     る場合に真を返します。これは、既存の ‘os.path.exists(path)’ 関数が
     'path' がシンボリックリンクでその指し先が存在しない場合に偽を返すの
     とは異なります。 (Contributed by Beni Cherniavsky.)

   * *note os: 91. モジュールの下層にある *note posix: 9b. モジュールに
     ‘getsid()’ 関数が追加されました。 (Contributed by J. Raynor.)

   * *note poplib: 9a. モジュールが POP over SSL をサポートするようにな
     りました.  (Contributed by Hector Urtubia.)

   * *note profile: 9d. モジュールが C 拡張の関数をプロファイル出来るよ
     うになりました。 (Contributed by Nick Bastin.)

   * *note random: a6. モジュールに、 ‘getrandbits(N)’ 関数が追加されま
     した。 'N' ビット長の長整数を返します。既存の ‘randrange()’ メソッ
     ドは ‘getrandbits()’ を適切な場所で使うようになり、任意の大きな乱数
     値生成をより効果的にしています。 (Contributed by Raymond
     Hettinger.)

   * *note re: a7. モジュールの正規表現言語が拡張されて、単純な条件式
     ‘(?(group)A|B)’ を書けるようになっています。 'group' は数値グループ
     ID か正規表現内で ‘(?P<group>...)’ で定義したグループ名のどちらかで
     す。指定したグループが合致した場合は、正規表現パターン 'A' が文字列
     に対してテストされ、そうでなければパターン 'B' が代わりに試されます
     。(Contributed by Gustavo Niemeyer.)

   * *note re: a7. モジュールはもう再帰をすることはありません。Gustavo
     Niemeyer による膨大な量の仕事のおかげです。再帰する正規表現エンジン
     では、ある種のパターンでは大量の C スタック空間を消費し、スタックの
     オーバーフローを起こすことがありました。例えば表現 ‘(a|b)+’ が文字
     ‘a’ から成る 3 万バイトの文字列に対してマッチすると、一文字ごとに一
     つのスタックフレームを消費していました。Python 2.3 ではスタックオー
     バーフローのチェックを試みて *note RuntimeError: 17a. を投げようと
     しましたが、ある種のパターンではチェックをすり抜けてしまって、運が
     悪いとセグメンテーション違反を起こしていました。Python 2.4 の正規表
     現エンジンではこのパターンと問題を起こすことなくマッチ出来ます。

   * *note signal: b4. モジュールで、 *note signal.signal(): 1107. への
     パラメータのエラーチェックを厳しくしています。例えば ‘SIGKILL’ シグ
     ナルへのハンドラはセット出来ません。以前のバージョンの Python では
     これを黙って受け容れていましたが、2.4 では *note RuntimeError: 17a.
     を投げます。

   * *note socket: b8. モジュールに 2 つ新しい関数が追加されています。
     ‘socketpair()’ 関数は接続したソケットのペアを返し、
     ‘getservbyport(port)’ は与えたポート番号からサービス名を探して返し
     ます。(Contributed by Dave Cole and Barry Warsaw.)

   * ‘sys.exitfunc()’ 関数は非推奨となりました。コードは既存の *note
     atexit: 9. モジュールを使うべきです。これは複数の終了関数呼び出しを
     正しく処理出来ます。結果的には ‘sys.exitfunc()’ は純粋に *note
     atexit: 9. のみから使われる内部インターフェイスとなるでしょう。

   * *note tarfile: c8. モジュールがデフォルトで GNU フォーマットを生成
     するようになっています。 (Contributed by Lars Gustäbel.)

   * *note threading: d6. モジュールで、スレッドローカルなデータのサポー
     トについて、品の良い単純な方法でサポート出来ました。モジュールは
     ‘local’ クラスを持っており、その属性値は異なるスレッドごとにローカ
     ルになります:

          import threading

          data = threading.local()
          data.number = 42
          data.url = ('www.python.org', 80)

     この場合他のスレッドは ‘number’ 属性、 ‘url’ 属性に自身の値を代入、
     抽出出来ます。 ‘local’ クラスは属性初期化であるとかメソッドの追加の
     ためにサブクラス化することも出来ます。 (Contributed by Jim Fulton.)

   * *note timeit: d8. モジュールはループを計測中は周期的なガーベージコ
     レクションを自動で無効化するようになりました。この変更により、繰り
     返しの計測の比較がやりやすくなります。 (Contributed by Raymond
     Hettinger.)

   * *note weakref: fc. モジュールがサポートするオブジェクトが非常に幅広
     くなりました。これには Python 関数、クラスインスタンス, set,
     frozenset, deque, array と正規表現パターンオブジェクトが含まれます
     。(Contributed by Raymond Hettinger.)

   * The *note xmlrpclib: 114. module now supports a multi-call
     extension for transmitting multiple XML-RPC calls in a single HTTP
     operation.  (Contributed by Brian Quinlan.)

   * ‘mpz’, ‘rotor’, ‘xreadlines’ モジュールは削除されました。

* Menu:

* cookielib::
* doctest: doctest<5>.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3548.html


File: python.info,  Node: cookielib,  Next: doctest<5>,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>

1.18.12.1 cookielib
...................

The *note cookielib: 66. library supports client-side handling for HTTP
cookies, mirroring the *note Cookie: 67. module's server-side cookie
support.  Cookies are stored in cookie jars; the library transparently
stores cookies offered by the web server in the cookie jar, and fetches
the cookie from the jar when connecting to the server.  As in web
browsers, policy objects control whether cookies are accepted or not.

セッションを跨いでクッキーを記憶するために、2 つのクッキー瓶実装が提供さ
れています。一つは Netscape フォーマットでクッキーを記憶するのでアプリケ
ーションは Mozilla か Lynx のクッキーファイルを使え、もう一つは Perl の
libwww ライブラリと同じフォーマットでクッキーを記憶します。

*note urllib2: f4. has been changed to interact with *note cookielib:
66.: ‘HTTPCookieProcessor’ manages a cookie jar that is used when
accessing URLs.

このモジュールは John J. Lee により寄稿されました。


File: python.info,  Node: doctest<5>,  Prev: cookielib,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>

1.18.12.2 doctest
.................

Edward Loper と Tim Peters のおかげにより、 *note doctest: 31. モジュー
ルに注目に値するリファクタリングが入りました。テストはこれまで通り単純に
*note doctest.testmod(): 1412. を実行するすることで行えますが、リファク
タリングはモジュールの操作をカスタマイズする色々な手段を提供してくれます
。

新規クラス ‘DocTestFinder’ は指定したオブジェクトの docstring からテスト
を抽出します:

     def f (x, y):
         """>>> f(2,2)
     4
     >>> f(3,2)
     6
         """
         return x*y

     finder = doctest.DocTestFinder()

     # Get list of DocTest instances
     tests = finder.find(f)

新規クラス ‘DocTestRunner’ はテストを個々に実行し、結果の要約を生成出来
ます:

     runner = doctest.DocTestRunner()
     for t in tests:
         tried, failed = runner.run(t)

     runner.summarize(verbose=1)

上の例はこのような出力を生成します:

     1 items passed all tests:
        2 tests in f
     2 tests in 1 items.
     2 passed and 0 failed.
     Test passed.

‘DocTestRunner’ は実際の出力と結果の期待値の比較に、 ‘OutputChecker’ の
インスタンスを使います。このクラスはその振る舞いをカスタマイズする色々な
フラグを取ります。意欲的なユーザであれば ‘OutputChecker’ の完全な新しい
サブクラスも書けます。

デフォルトの出力チェッカーは多くのお手軽機能を持っています。例えば *note
doctest.ELLIPSIS: 1413. オプションフラグは、出力の期待値内での省略記号
(‘...’) と任意文字列を一致するとみなし、瑣末な部分が変化するような出力に
簡単に適合するように出来ます:

     def o (n):
         """>>> o(1)
     <__main__.C instance at 0x...>
     >>>
     """

もう一つの特殊文字列 ‘<BLANKLINE>’ は空行に合致します:

     def p (n):
         """>>> p(1)
     <BLANKLINE>
     >>>
     """

もう一つの新機能は出力の diff スタイル出力で、オプションフラグに *note
doctest.REPORT_UDIFF: 1414. (unified diffs), *note doctest.REPORT_CDIFF:
1415. (context diffs), *note doctest.REPORT_NDIFF: 1416. (delta-style) を
指定することで利用出来ます。例えば以下があるとして:

     def g (n):
         """>>> g(4)
     here
     is
     a
     lengthy
     >>>"""
         L = 'here is a rather lengthy list of words'.split()
         for word in L[:n]:
             print word

Running the above function's tests with *note doctest.REPORT_UDIFF:
1414. specified, you get the following output:

     **********************************************************************
     File "t.py", line 15, in g
     Failed example:
         g(4)
     Differences (unified diff with -expected +actual):
         @@ -2,3 +2,3 @@
          is
          a
         -lengthy
         +rather
     **********************************************************************


File: python.info,  Node: ビルドならびに C API の変更<11>,  Next: Python 2 4 への移植,  Prev: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>,  Up: What's New in Python 2 4

1.18.13 ビルドならびに C API の変更
-----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * 拡張関数からの戻り値として一般的に使うための 3 つの便利なマクロが追
     加されています: *note Py_RETURN_NONE: 1418, *note Py_RETURN_TRUE:
     1419, *note Py_RETURN_FALSE: 141a. (Contributed by Brett Cannon.)

   * Another new macro, *note Py_CLEAR: 544, decreases the reference
     count of 'obj' and sets 'obj' to the null pointer.  (Contributed by
     Jim Fulton.)

   * 新規関数 ‘PyTuple_Pack(N, obj1, obj2, ..., objN)’ は Python オブジ
     ェクトの可変長引数リストからタプルを構築します。 (Contributed by
     Raymond Hettinger.)

   * 新規関数 ‘PyDict_Contains(d, k)’ は、処理内で起こる例外のマスキング
     なしでの高速なルックアップを実装しています。 (Contributed by
     Raymond Hettinger.)

   * The Py_IS_NAN(X) macro returns 1 if its float or double argument
     'X' is a NaN. (Contributed by Tim Peters.)

   * C code can avoid unnecessary locking by using the new
     ‘PyEval_ThreadsInitialized()’ function to tell if any thread
     operations have been performed.  If this function returns false, no
     lock operations are needed.  (Contributed by Nick Coghlan.)

   * 新規関数 *note PyArg_VaParseTupleAndKeywords(): 35d. は *note
     PyArg_ParseTupleAndKeywords(): 35c. と同じですが、たくさんの引数の
     代わりに ‘va_list’ を取ることだけが違います。(Contributed by Greg
     Chapman.)

   * A new method flag, *note METH_COEXIST: 141b, allows a function
     defined in slots to co-exist with a *note PyCFunction: 141c. having
     the same name.  This can halve the access time for a method such as
     ‘set.__contains__()’.  (Contributed by Raymond Hettinger.)

   * Python can now be built with additional profiling for the
     interpreter itself, intended as an aid to people developing the
     Python core.  Providing ‘--enable-profiling’ to the ‘configure’
     script will let you profile the interpreter with ‘gprof’, and
     providing the ‘--with-tsc’ switch enables profiling using the
     Pentium's Time-Stamp-Counter register.  Note that the ‘--with-tsc’
     switch is slightly misnamed, because the profiling feature also
     works on the PowerPC platform, though that processor architecture
     doesn't call that register "the TSC register".  (Contributed by
     Jeremy Hylton.)

   * The ‘tracebackobject’ type has been renamed to ‘PyTracebackObject’.

* Menu:

* ポート特有の変更: ポート特有の変更<2>.


File: python.info,  Node: ポート特有の変更<2>,  Up: ビルドならびに C API の変更<11>

1.18.13.1 ポート特有の変更
..........................

   * Windows ポートは MSVC++ 6 と 7.1 でビルド出来ます。 (Contributed by
     Martin von Löwis.)


File: python.info,  Node: Python 2 4 への移植,  Next: 謝辞<4>,  Prev: ビルドならびに C API の変更<11>,  Up: What's New in Python 2 4

1.18.14 Python 2.4 への移植
---------------------------

このセクションでは前述の変更により必要となるかもしれないコードの変更を列
挙します:

   * 大き過ぎる値を持つ左シフトと 16 進/ 8 進定数が *note FutureWarning:
     3ee. を引き起こした上で 32 ビットまたは 64 ビットに制限される、とい
     う振る舞いはもうしません。代わりに長整数を返します。

   * 整数演算はもはや ‘OverflowWarning’ は引き起こしません。
     ‘OverflowWarning’ 警告は Python 2.5 で撤廃されます。

   * ビルトイン関数の *note zip(): 79b. と ‘itertools.izip()’ が引数なし
     で呼ばれた場合に、 *note TypeError: 502. 例外を起こすのではなく空リ
     ストを返すようになりました。

   * You can no longer compare the ‘date’ and *note datetime: 1ae.
     instances provided by the *note datetime: 28. module.  Two
     instances of different classes will now always be unequal, and
     relative comparisons (‘<’, ‘>’) will raise a *note TypeError: 502.

   * ‘dircache.listdir()’ now passes exceptions to the caller instead of
     returning empty lists.

   * ‘LexicalHandler.startDTD()’ はパブリックでシステムの ID を間違った
     順序で受け取っていました。これは修正されました; この間違った順序に
     依存したアプリケーションは修正しなければなりません。

   * *note fcntl.ioctl(): 141f. は 'mutate_flag' 引数が省略されて問題に
     関係がある場合は警告を出します。

   * *note tarfile: c8. モジュールがデフォルトで GNU フォーマットを生成
     するようになっています。

   * Encountering a failure while importing a module no longer leaves a
     partially initialized module object in ‘sys.modules’.

   * *note None: 641. が定数になっています。 ‘None’ という名前に新しい値
     を割り当てようとするコードは、今では構文エラーになります。

   * ‘signals.signal()’ 関数は、ある種の不正な値では *note RuntimeError:
     17a. を投げるようになっています。以前はこれらエラーは黙って通してい
     ました。例えばもう ‘SIGKILL’ へはハンドラは渡せません。


File: python.info,  Node: 謝辞<4>,  Prev: Python 2 4 への移植,  Up: What's New in Python 2 4

1.18.15 謝辞
------------

著者は提案の申し出や修正、様々なこの記事の草稿の助けをしてくれた以下の人
々に感謝します: Koray Can, Hye-Shik Chang, Michael Dyck, Raymond
Hettinger, Brian Hurt, Hamish Lawson, Fredrik Lundh, Sean Reifschneider,
Sadruddin Rejeb.


File: python.info,  Node: What's New in Python 2 3,  Next: What's New in Python 2 2,  Prev: What's New in Python 2 4,  Up: What's New in Python

1.19 What's New in Python 2.3
=============================


著者: A.M. Kuchling

この文書は Python 2.3 の新機能について解説します。Python 2.3 は 2003 年
7 月 29 日にリリースされました。

Python 2.3 の主要なテーマは、2.2 で追加されたいくつかの機能を磨くこと、
言語中核に小さいながらも有用な種々の拡張をすること、そして標準ライブラリ
の拡充です。ひとつ前のバージョンで導入された新しいオブジェクトモデルは、
18 ヶ月に渡るバグフィックスと新スタイルクラスの性能改善をもたらした最適
化の努力の恩恵を受けました。 *note sum(): 437, *note enumerate(): 1424.
のような、新たなビルトイン関数が少し追加されました。 *note in: 2cb. 演算
子がサブストリングの検索に使えるようになりました (例えば ‘"ab" in "abc"’
は *note True: bdb. を返します)。

たくさんのライブラリ新機能…、Boolean、 set、 heap、 日付/時刻データ型、
ZIP 形式アーカイブからのモジュールインポート、待ち望まれていた Python カ
タログのためのメタデータサポート、更新されたバージョンの IDLE、ロギング
メッセージのためのモジュール、テキストの折り返し、CSV ファイルの解析、コ
マンドラインオプションの処理、BerkeleyDB データベースの使用…、新機能、強
化機能のリストは長大になります。

このドキュメントは個々の新機能の完全な詳細を提供するのではなくて、簡易な
概要を提供することを目的にしています。完全な詳細が知りたければ、 Python
ライブラリリファレンス、Python リファレンスマニュアルのような Python 2.4
のドキュメントを参照してください。設計と実装の根拠を理解したい場合は、新
機能に関する PEP を参照してください。

* Menu:

* PEP 218; 標準の集合データ型: PEP 218 標準の集合データ型.
* PEP 255; 単純なジェネレータ: PEP 255 単純なジェネレータ.
* PEP 263; ソースコードのエンコーディング: PEP 263 ソースコードのエンコーディング.
* PEP 273; Zip アーカイブからモジュールをインポートする: PEP 273 Zip アーカイブからモジュールをインポートする.
* PEP 277; Windows NT での Unicode ファイル名サポート: PEP 277 Windows NT での Unicode ファイル名サポート.
* PEP 278; Universal Newline サポート: PEP 278 Universal Newline サポート.
* PEP 279; enumerate(): PEP 279 enumerate.
* PEP 282; ロギングパッケージ: PEP 282 ロギングパッケージ.
* PEP 285; Boolean 型: PEP 285 Boolean 型.
* PEP 293; コーデックエラーを処理するコールバック: PEP 293 コーデックエラーを処理するコールバック.
* PEP 301; パッケージインデクスと、 Distutils のためのメタデータ: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ.
* PEP 302; 新たなインポートフック: PEP 302 新たなインポートフック.
* PEP 305; カンマ区切り形式ファイル: PEP 305 カンマ区切り形式ファイル.
* PEP 307; Pickle の機能拡張: PEP 307 Pickle の機能拡張.
* 拡張スライス::
* その他の言語変更: その他の言語変更<16>.
* 新たなモジュール、改良されたモジュール、非推奨のモジュール: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
* Pymalloc; 特殊化されたオブジェクトアロケータ: Pymalloc 特殊化されたオブジェクトアロケータ.
* ビルドならびに C API の変更: ビルドならびに C API の変更<12>.
* その他の変更と修正: その他の変更と修正<2>.
* Python 2.3 への移植: Python 2 3 への移植.
* 謝辞: 謝辞<5>.


File: python.info,  Node: PEP 218 標準の集合データ型,  Next: PEP 255 単純なジェネレータ,  Up: What's New in Python 2 3

1.19.1 PEP 218: 標準の集合データ型
----------------------------------

(--訳注: イキナリですが、あなたが今これを「Python の歴史を知る」もしくは
「初登場時の熱量高い紹介」を読みたくて読んでいるのでない限りは、もしくは
本当に今 2.3 を使う必要があれば別ですが、このモジュールは 2.4 で既にビル
トインで置き換えられ、2.6 では非推奨となり、3.0 では削除されています。の
で、集合型について知りたければここよりも 2.4 のビルトインの方から読んだ
方が良いです。--) -- 新しいモジュール ‘sets’ には、集合データ型の実装が
含まれています。 ‘Set’ クラスは *note mutable: 1273. の集合のためのクラ
スで、メンバの追加と削除が出来ます。 ‘ImmutableSet’ は変更できない集合の
ためのクラスなので、‘ImmutableSet’ のインスタンスを辞書のキーとして利用
出来ます。集合型は辞書の上に構築されているので、集合内の要素はハッシュ可
能でなければなりません。

単純な使用例です:

     >>> import sets
     >>> S = sets.Set([1,2,3])
     >>> S
     Set([1, 2, 3])
     >>> 1 in S
     True
     >>> 0 in S
     False
     >>> S.add(5)
     >>> S.remove(3)
     >>> S
     Set([1, 2, 5])
     >>>

和集合 (union) と共通集合 (intersection) は *note union(): 1426. と
*note intersection(): 1427. メソッドで計算出来ます; 別の記法として、ビッ
ト演算子 ‘&’ と ‘|’ も使えます。変更可能な集合ではこれらのインプレイス版
‘union_update()’ と *note intersection_update(): 1428. も使えます:

     >>> S1 = sets.Set([1,2,3])
     >>> S2 = sets.Set([4,5,6])
     >>> S1.union(S2)
     Set([1, 2, 3, 4, 5, 6])
     >>> S1 | S2                  # Alternative notation
     Set([1, 2, 3, 4, 5, 6])
     >>> S1.intersection(S2)
     Set([])
     >>> S1 & S2                  # Alternative notation
     Set([])
     >>> S1.union_update(S2)
     >>> S1
     Set([1, 2, 3, 4, 5, 6])
     >>>

2 つの集合の対称差 (symmetric difference) を取ることも出来ます。これは、
union から intersection を除いた全要素を取ります。別の言い方をすれば、対
称差とは、正確に一つの集合だけに含まれる全要素、ということです。ほかと同
じくビット演算子の記法 (‘^’) が使え、インプレイスバージョンは見苦しい名
前の *note symmetric_difference_update(): 1429. です:

     >>> S1 = sets.Set([1,2,3,4])
     >>> S2 = sets.Set([3,4,5,6])
     >>> S1.symmetric_difference(S2)
     Set([1, 2, 5, 6])
     >>> S1 ^ S2
     Set([1, 2, 5, 6])
     >>>

‘issubset()’ と ‘issuperset()’ メソッドも使えます。これはある集合が部分
集合、上位集合であるかとうかをチェックします:

     >>> S1 = sets.Set([1,2,3])
     >>> S2 = sets.Set([2,3])
     >>> S2.issubset(S1)
     True
     >>> S1.issubset(S2)
     False
     >>> S1.issuperset(S2)
     True
     >>>

参考
....

PEP 218(1) - 集合オブジェクト型をビルトインに追加する

     PEP 著 Greg V. Wilson.  実装: Greg V. Wilson, Alex Martelli, GvR.
     (--訳注: PEPそのものは 2.4 のビルトイン型 set, frozenset の追加と同
     じものですが、2.3 ではモジュールとして追加され、2.4 でビルトイン版
     が追加され、2.6 でモジュール版が非推奨となった、という流れです。--)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0218/


File: python.info,  Node: PEP 255 単純なジェネレータ,  Next: PEP 263 ソースコードのエンコーディング,  Prev: PEP 218 標準の集合データ型,  Up: What's New in Python 2 3

1.19.2 PEP 255: 単純なジェネレータ
----------------------------------

Python 2.2 では、ジェネレータが ‘from __future__ import generators’ ディ
レクティブで有効に出来るオプションの機能として追加されました。2.3 ではジ
ェネレータは特別に有効化する必要なく、もうキーワード *note yield: 99b. と
して、いつでもそこにあります。このセクションの残りの部分は "What's New
in Python 2.2" のジェネレータの記述からの丸々コピーですので、2.2 のとき
に読んだなら読み飛ばしてもらって結構です。

Python や C の標準的な関数コールについては、よくご存じに違いありません。
関数を呼ぶと、ローカル変数を作るプライベートな名前空間ができますね。その
関数が *note return: 99c. 文まで来ると、ローカル変数が破壊されてから、返
り値が呼び出し元に返ります。次に同じ関数をもう一度呼ぶと、新しいプライベ
ート名前空間に新規のローカル変数が作られるのです。しかし、関数を出るとき
にローカル変数を捨てなければどうなるでしょうか。その出ていったところから
関数を続行できたとしたら、どうでしょう。これこそジェネレータが提供する機
能です; すなわち、ジェネレータは続行できる関数と考えることができます。

ジェネレータ関数の最も単純な例です:

     def generate_ints(N):
         for i in range(N):
             yield i

新しいキーワード *note yield: 99b. がジェネレータのために導入されました
。 ‘yield’ ステートメントを含むどんな関数もジェネレータ関数です; Python
バイトコードコンパイラはこれを検知し、関数が特別に扱われるように翻訳しま
す。 (--訳注: Python 2.5 の PEP 342 も参照して下さい。この 2.2 で導入時
点の ‘yield’ はステートメントではなく式に変更されています。--)

ジェネレータ関数を呼び出すと、単一の値の代わりにイテレータプロトコルに対
応したオブジェクトを返します。上の例で ‘yield’ を実行したとき、ジェネレ
ータは ‘return’ 文のようにして ‘i’ の値を生成します。 ‘yield’ と
‘return’ 文の大きな違いは、 ‘yield’ に到達した段階でジェネレータの実行状
態が一時停止になって、ローカル変数が保存される点です。次回そのジェネレー
タの ‘.next()’ メソッドを呼ぶと、 ‘yield’ の直後から関数が実行を再開しま
す。(複雑な理由により、 ‘yield’ は ‘try’...*note finally: 997. の ‘try’
ブロック内に含めることは許されていません; PEP 255(1) に ‘yield’ と例外の
相互作用についての詳細説明がありますので参照して下さい。) -- (--訳注:
Python 2.5 の PEP 342 で *note try: 6b4...*note finally: 997. 内に置けな
いという制約はなくなりました。また、 *note try: 6b4...*note finally:
997. の *note try: 6b4. 、とここであえて特定しているのは、同じく 2.5 の
PEP 341 によって try/except/finally の一体化されるまでは、 ‘finally’ の
‘try’ と ‘except’ の ‘try’ が別物だったからです。--)

上記の ‘generate_ints()’ ジェネレータはこんな具合に使います:

     >>> gen = generate_ints(3)
     >>> gen
     <generator object at 0x8117f90>
     >>> gen.next()
     0
     >>> gen.next()
     1
     >>> gen.next()
     2
     >>> gen.next()
     Traceback (most recent call last):
       File "stdin", line 1, in ?
       File "stdin", line 2, in generate_ints
     StopIteration

同じく ‘for i in generate_ints(5)’ や ‘a,b,c = generate_ints(3)’ といっ
た書き方もできます。

ジェネレータ関数内で *note return: 99c. 文は、引数を付けずに、処理の終わ
りを知らせるためにだけ使うことができます; ‘return’ を実行したあとは、も
うそのジェネレータが値を返すことはできません。ジェネレータ関数の中では、
‘return 5’ などと値を付けた ‘return’ は構文エラーです。ジェネレータの出
力が終わったことを示すには、ほかにも、手動で *note StopIteration: bc8. を
投げてもいいですし、関数の最後まで実行するだけでも同じことになります。
(--訳注: Python 2.7 まではジェネレータ内での戻り値のある ‘return 5’ は構
文エラーになりますが、少なくとも Python 3.4 で構文エラーとはなりません。
単に無視されます。リファレンスに言及されていない振舞いなので、何かの事故
かもしれません。いずれにせよジェネレータ内では Python 3 でも ‘return’ で
値は戻せません。--)

自分でクラスを書いて、ジェネレータで言うところのローカル変数をインスタン
ス変数として全部保管しておけば、同じ効果を得ることは可能です。たとえば整
数のリストを返すのは、 ‘self.count’ を 0 にして、 *note next(): 7a3. メ
ソッドが ‘self.count’ をインクリメントして返すようにすればできます。しか
しながら、ある程度複雑なジェネレータになってくると、同じことをするクラス
を書くのは格段にややこしいことになります。 ‘Lib/test/test_generators.py’
にはもっと面白い例がたくさん含まれています。一番単純な一つは、ジェネレー
タを再帰的に使ってツリーを順繰りに横断する実装をするこれです (--訳注: ジ
ェネレータは現在の最新 3.5 までの間に 2 度大きな機能強化が行われているの
ですが、一つが 2.5 での PEP 342 でこれは yield 「に」値を戻せるようにす
るものです。もう一つが 3.3 での PEP 380 で、これはサブジェネレータへの委
譲 ‘yield from <subgen>’ の追加でした。ですのでこの 3.3 からの ‘yield
from’ を使うと下記例はもっとスッキリ書けます。--):

     # A recursive generator that generates Tree leaves in in-order.
     def inorder(t):
         if t:
             for x in inorder(t.left):
                 yield x
             yield t.label
             for x in inorder(t.right):
                 yield x

ほかにも ‘Lib/test/test_generators.py’ には、N-Queens 問題 (N×N コマのチ
ェス盤に、互いに攻撃できないような配置で N 個のクイーンを置く) やナイト
・ツアー (N×N 盤の全コマをナイトが一度ずつ通るような経路を探す) の解を出
す例が入っています。

ジェネレータの発想はほかのプログラミング言語、特に Icon
(‘https://www2.cs.arizona.edu/icon/’) から着想しています。Icon ではジェ
ネレータが言語の中枢になっています。Icon では、あらゆる式と関数がジェネ
レータのように振舞います。
‘https://www2.cs.arizona.edu/icon/docs/ipd266.htm’ の "Icon プログラミン
グ言語の概要" の一つの例が、これがどのようなものであるのかを教えてくれま
す:

     sentence := "Store it in the neighboring harbor"
     if (i := find("or", sentence)) > 5 then write(i)

Icon では ‘find()’ 関数は部分文字列 "or" が見つかる位置 3, 23, 33 を返し
ます。 *note if: 2ca. 文内では ‘i’ には最初 3 が代入されますが、これは 3
より小さいので比較は失敗し、Icon は次の値 23 を取り出します。 23 は 5 よ
り大きいので比較は成功し、コードは 23 をスクリーンに表示します。

Python では Icon がそうするほどにはジェネレータを中心的概念に置きません
。ジェネレータは Python 言語中核の新たな一面ではありますが、それらを学ぶ
のも使うのも誰しも行うべきだというものでもなく、そしてこれで解決できない
何か問題があれば、忘れてしまっても良いものです。Icon と比較した特筆すべ
き Python インターフェイスの機能はジェネレータの状態が具象オブジェクト
(イテレータ) で表現されることであり、それは他の関数に渡せますし、データ
構造に記憶しておくことも出来ます。(--訳注: ジェネレータについてかなり控
えめなのは、この時点で著者は将来の拡張を既に見据えていたから?  かもしれ
ませんね。PEP 342 と PEP 380 により今やジェネレータはこの頃より遥かに高
機能になっており、今ではきっと「こんなものなくても困らない」なんて
Python 使いはいないでしょう。--)

参考
....

PEP 255(2) - 単純なジェネレータ

     Neil Schemenauer, Tim Peters, Magnus Lie Hetland により著されました
     。実装のほとんどは Neil Schemenauer と Tim Peters により行われ、
     Python Labs クルーにより他の修正が行われました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0255/

   (2) https://peps.python.org/pep-0255/


File: python.info,  Node: PEP 263 ソースコードのエンコーディング,  Next: PEP 273 Zip アーカイブからモジュールをインポートする,  Prev: PEP 255 単純なジェネレータ,  Up: What's New in Python 2 3

1.19.3 PEP 263: ソースコードのエンコーディング
----------------------------------------------

Python ソースファイルで、異なる文字セットエンコーディングを宣言出来るよ
うになりました。エンコーディングはソースコードの 1 行目か 2 行目に特殊形
式のコメントを含めることで宣言出来ます。 UTF-8 ファイルであればこのよう
に宣言出来ます:

     #!/usr/bin/env python
     # -*- coding: UTF-8 -*-

このエンコーディング宣言がなければ、デフォルトの 7 ビット ASCII エンコー
ディングが使われます(訳注: Python 3 からはデフォルトは utf-8 (PEP
3120))。8 ビット文字を含んでいるのにエンコーディング宣言がないモジュール
の実行やインポートを行うと、 Python 2.3 では *note DeprecationWarning:
18a. を引き起こします; 2.4 ではこれは構文エラーになる予定です(訳注: 実際
には 2.4 ではこれは実現せず、2.5 から)。

エンコーディング宣言は Unicode 文字列リテラルにのみ影響します。それらは
指定したエンコーディングで Unicode 文字列に変換されます。Python 識別子は
今でも ASCII 文字列に制限されていることに注意してください。ですから普通
の英数字範囲外の文字を変数名に使うことは出来ません。

参考
....

PEP 263(1) - Python ソースコードのエンコーディングを定義する

     Marc-André Lemburg、 Martin von Löwis 著; Suzuki Hisao、 Martin von
     Löwis 実装.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0263/


File: python.info,  Node: PEP 273 Zip アーカイブからモジュールをインポートする,  Next: PEP 277 Windows NT での Unicode ファイル名サポート,  Prev: PEP 263 ソースコードのエンコーディング,  Up: What's New in Python 2 3

1.19.4 PEP 273: Zip アーカイブからモジュールをインポートする
------------------------------------------------------------

新たなモジュール *note zipimport: 118. が、ZIP フォーマットの書庫からモ
ジュールのインポートをサポートします。 *note zipimport: 118. を明示的に
インポートする必要はありません; ‘sys.path’ に ZIP 形式書庫が追加されると
それは自動的にインポートされます。例えば:

     amk@nyman:~/src/python$ unzip -l /tmp/example.zip
     Archive:  /tmp/example.zip
       Length     Date   Time    Name
      --------    ----   ----    ----
          8467  11-26-02 22:30   jwzthreading.py
      --------                   -------
          8467                   1 file
     amk@nyman:~/src/python$ ./python
     Python 2.3 (#1, Aug 1 2003, 19:54:32)
     >>> import sys
     >>> sys.path.insert(0, '/tmp/example.zip')  # Add .zip file to front of path
     >>> import jwzthreading
     >>> jwzthreading.__file__
     '/tmp/example.zip/jwzthreading.py'
     >>>

‘sys.path’ には今や ZIP 書庫のファイル名も入れることが出来ます。ZIP アー
カイブ内にはどんなファイルを置いてもかまいませんが、import できるのは
‘*.py’, ‘*.pyc’, ‘*.pyo’ だけです。書庫に ‘*.py’ だけが含まれる場合には
、Python は書庫を修正して対応する ‘*.pyc’ を作るなどということはしないの
で、 ‘*.pyc’ ファイルを含まない ZIP 書庫からのインポートはやや遅いかもし
れません。

書庫内のパスをサブディレクトリ以下のみインポートするように指定出来ます;
例えば、パス ‘/tmp/example.zip/lib/’ はその書庫内の ‘lib/’ サブディレク
トリだけからインポートします。

参考
....

PEP 273(1) - Zip アーカイブからモジュールをインポートする

     このモジュールの実装も行った、James C. Ahlstrom による PEP です。
     Python 2.3 は PEP 273(2) の仕様に従っていますが、 Just van Rossum の
     書いた、 PEP 302(3) に記述されているインポートフックによる実装を使
     っています。その新しいインポートフックについては *note PEP 302;
     新たなインポートフック: 142f. をみてください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0273/

   (2) https://peps.python.org/pep-0273/

   (3) https://peps.python.org/pep-0302/


File: python.info,  Node: PEP 277 Windows NT での Unicode ファイル名サポート,  Next: PEP 278 Universal Newline サポート,  Prev: PEP 273 Zip アーカイブからモジュールをインポートする,  Up: What's New in Python 2 3

1.19.5 PEP 277: Windows NT での Unicode ファイル名サポート
----------------------------------------------------------

Windows NT, 2000, XP では、ファイルシステムはファイル名として Unicode 文
字列を使います。伝統的に Python はファイル名をバイト文字列として表現して
きましたが、それはアクセス出来ないファイル名を表してしまう場合があって、
不十分でした。

Python はいまや (ファイルシステムの制約の範囲内での) 任意の Unicode 文字
列を *note open(): 4e5. 組み込み関数をはじめとするファイル名が期待される
全ての関数で許容します。 *note os.listdir(): 10cd. に Unicode 文字列が渡
されれば、Python は今では Unicode 文字列のリストを返します。新しい関数
‘os.getcwdu()’ は Unicode 文字列でカレントディレクトリを返します(訳注: ち
なみに Python 3 での Unicode 周りの大改造に伴いこの関数はなくなり、代わ
りに「あえてバイト列のほうを返す」 が追加されています(‘os.getcwdu()’ が
もはや Unicode を返すので)。)。

ファイル名のバイト文字列はいまでも動きます。Windows 版 Python は透過的に
それらを Unicode に ‘mbcs’ エンコーディングを使って変換します。

ほかのシステムでもファイル名の Unicode は許容されますが、システムに渡す
前にバイト文字列に変換され、 *note UnicodeError: 1275. 例外を引き起こす
かもしれません。アプリケーションは任意の Unicode 文字列がファイル名に許
されるかどうかを、ブーリアン値 *note os.path.supports_unicode_filenames:
1431. をチェックすることでテスト出来ます。

MacOS では、 *note os.listdir(): 10cd. は Unicode ファイル名を返すように
なっているでしょう。

参考
....

PEP 277(1) - Windows NT での Unicode ファイル名サポート

     Neil Hodgson 著; 実装 Neil Hodgson, Martin von Löwis, Mark Hammond。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0277/


File: python.info,  Node: PEP 278 Universal Newline サポート,  Next: PEP 279 enumerate,  Prev: PEP 277 Windows NT での Unicode ファイル名サポート,  Up: What's New in Python 2 3

1.19.6 PEP 278: Universal Newline サポート
------------------------------------------

今日では 3 つの主要なオペレーティングシステムが使われています。
Microsoft Windows, Apple の Macintosh OS, さまざまな Unix 派生系です。テ
キストファイルの行終端マークに使う文字がこれら 3 つ全てでそれぞれ違って
いることが、クロスプラットフォームのための仕事における小さな苛立ちです。
Unix が使うのはラインフィード (ASCII 文字 10), MacOS が使うのはキャリッ
ジリターン (ASCII 文字 13), Windows に至ってはキャリッジリターンとライン
フィード 2 文字のシーケンスを使います。

Python のファイルオブジェクトが、動作しているプラットフォームに従わない
行終端変換をサポートするようになりました。ファイルのオープンにモード
‘'U'’ や ‘'rU'’ を使うと、 *note universal newlines: d08. モードを使った
読み込みとしてファイルを開きます。これで ‘read()’, ‘readline()’ などのフ
ァイルメソッドが、 3 つどの行終端でも ‘'\n'’ という文字列に翻訳して返す
ようになります。

universal newline サポートはモジュールのインポートと ‘execfile()’ 関数で
のファイル実行にも使われます。これで 3 つ全てのオペレーティングシステム
間で行終端変換の必要なく Python モジュールを共有出来ます。

この機能は Python をソースからビルドする際に ‘configure’ スクリプトに
‘--without-universal-newlines’ スイッチ を付けることで無効に出来ます。

参考
....

PEP 278(1) : Universal Newline サポート

     Jack Jansen 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0278/


File: python.info,  Node: PEP 279 enumerate,  Next: PEP 282 ロギングパッケージ,  Prev: PEP 278 Universal Newline サポート,  Up: What's New in Python 2 3

1.19.7 PEP 279: enumerate()
---------------------------

新たな組み込み関数 *note enumerate(): 1424. はある種のループ処理を少し簡
潔にするものです。 'thing' がイテレータかシーケンスだとして、
‘enumerate(thing)’ は ‘(0, thing[0])’, ‘(1, thing[1])’, ‘(2, thing[2])’,
… を生成するイテレータを返します。

リストの全てを変更するためのよくあるイディオムはこのようなものでしょう:

     for i in range(len(L)):
         item = L[i]
         # ... compute some result based on item ...
         L[i] = result

これは *note enumerate(): 1424. を使ってこのように書き換えることが出来ま
す:

     for i, item in enumerate(L):
         # ... compute some result based on item ...
         L[i] = result

参考
....

PEP 279(1) - 組み込み関数 enumerate()

     Raymond D. Hettinger 著、実装.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0279/


File: python.info,  Node: PEP 282 ロギングパッケージ,  Next: PEP 285 Boolean 型,  Prev: PEP 279 enumerate,  Up: What's New in Python 2 3

1.19.8 PEP 282: ロギングパッケージ
----------------------------------

ログ記録のための標準パッケージ *note logging: 7b. が Python 2.3 に追加さ
れています。それはログ出力生成の強力で柔軟なメカニズムを提供し、フィルタ
と加工を色々な方法で行えます。標準フォーマットで書く設定ファイルで、プロ
グラムのロギングの振る舞いを制御出来ます。ログレコードを標準エラー出力や
ファイルやソケット、システムログへの送信、あるいは e-mail 送信するような
ハンドラが Python に含まれています。もちろん、あなた自身のハンドラクラス
を書くことも出来ます。

*note Logger: b1d. が最も重要なクラスです。ほとんどのアプリケーションコ
ードは一つかそれ以上の *note Logger: b1d. オブジェクトを扱い、それぞれ一
つはそのアプリケーションの特定のサブシステムで使われるでしょう。それぞれ
の *note Logger: b1d. は名前で識別され、名前は ‘.’ をコンポーネントのセ
パレータとして使う階層で体系化されます。例えば、 ‘server’,
‘server.auth’, ‘server.network’ といった名前の *note Logger: b1d. インス
タンスを持つといった具合です。この例の後ろ 2 つは階層で ‘server’ の下に
あります。 ‘server’ への冗長性を見つけた場合や ‘server’ メッセージを直接
異なるハンドラに向けた場合、変更は ‘server.auth’ と ‘server.network’ へ
のログ記録にも適用されるということです。全てのほかのロガーの親となる、ル
ート *note Logger: b1d. もあります。

単純な用法のために、 *note logging: 7b. パッケージはいくつかの便利関数を
含んでいて、これは常にルートログを使います:

     import logging

     logging.debug('Debugging information')
     logging.info('Informational message')
     logging.warning('Warning:config file %s not found', 'server.conf')
     logging.error('Error occurred')
     logging.critical('Critical error -- shutting down')

これは以下のような出力をします:

     WARNING:root:Warning:config file server.conf not found
     ERROR:root:Error occurred
     CRITICAL:root:Critical error -- shutting down

In the default configuration, informational and debugging messages are
suppressed and the output is sent to standard error.  You can enable the
display of informational and debugging messages by calling the *note
setLevel(): 1436. method on the root logger.

Notice the *note warning(): 2d6. call's use of string formatting
operators; all of the functions for logging messages take the arguments
‘(msg, arg1, arg2, ...)’ and log the string resulting from ‘msg % (arg1,
arg2, ...)’.

There's also an *note exception(): 1437. function that records the most
recent traceback.  Any of the other functions will also record the
traceback if you specify a true value for the keyword argument
'exc_info'.

     def f():
         try:    1/0
         except: logging.exception('Problem recorded')

     f()

これは以下のような出力をします:

     ERROR:root:Problem recorded
     Traceback (most recent call last):
       File "t.py", line 6, in f
         1/0
     ZeroDivisionError: integer division or modulo by zero

多少なりとも高度なプログラムでは、ルートロガー以上のロガーを使うでしょう
。 ‘getLogger(name)’ 関数は特定のロガーを取得するのに使います。その時点
で存在していなければ、作成されます。 ‘getLogger(None)’ はルートロガーを
返します。:

     log = logging.getLogger('server')
      ...
     log.info('Listening on port %i', port)
      ...
     log.critical('Disk full')
      ...

Log records are usually propagated up the hierarchy, so a message logged
to ‘server.auth’ is also seen by ‘server’ and ‘root’, but a *note
Logger: b1d. can prevent this by setting its *note propagate: 1438.
attribute to *note False: b05.

There are more classes provided by the *note logging: 7b. package that
can be customized.  When a *note Logger: b1d. instance is told to log a
message, it creates a *note LogRecord: fb3. instance that is sent to any
number of different *note Handler: 1439. instances.  Loggers and
handlers can also have an attached list of filters, and each filter can
cause the *note LogRecord: fb3. to be ignored or can modify the record
before passing it along.  When they're finally output, *note LogRecord:
fb3. instances are converted to text by a *note Formatter: 143a. class.
All of these classes can be replaced by your own specially written
classes.

これら全ての機能で *note logging: 7b. パッケージは最も複雑なアプリケーシ
ョンでさえ、十分な柔軟性を提供しているはずです。ここではそれら機能の不完
全な概要しか示しませんでしたので、全ての詳細はパッケージのドキュメントを
参照してください。 PEP 282(1) を読むことも助けになるでしょう。(--訳注: 今
ではクックブックもあるのでそちらもどうぞ。--)

参考
....

PEP 282(2) - ログシステム

     PEP 著: Vinay Sajip と Trent Mick; 実装: Vinay Sajip.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0282/

   (2) https://peps.python.org/pep-0282/


File: python.info,  Node: PEP 285 Boolean 型,  Next: PEP 293 コーデックエラーを処理するコールバック,  Prev: PEP 282 ロギングパッケージ,  Up: What's New in Python 2 3

1.19.9 PEP 285: Boolean 型
--------------------------

A Boolean type was added to Python 2.3.  Two new constants were added to
the ‘__builtin__’ module, *note True: bdb. and *note False: b05.  (*note
True: bdb. and *note False: b05. constants were added to the built-ins
in Python 2.2.1, but the 2.2.1 versions are simply set to integer values
of 1 and 0 and aren't a different type.)

この新しい型の型オブジェクトの名前は *note bool: 434. です; これのコンス
トラクタは任意の Python 値を取り、 *note True: bdb. または *note False:
b05. に変換します:

     >>> bool(1)
     True
     >>> bool(0)
     False
     >>> bool([])
     False
     >>> bool( (1,) )
     True

標準ライブラリモジュールとビルトイン関数のほとんどが、そうすべきときには
Boolean を返すように変更されました:

     >>> obj = []
     >>> hasattr(obj, 'append')
     True
     >>> isinstance(obj, list)
     True
     >>> isinstance(obj, tuple)
     False

Python の Boolean はコードを明快にすることを主たる目標として追加されまし
た。例えばあなたがコードを読んでいて ‘return 1’ に出くわした場合、あなた
は考えるはずです。この ‘1’ は、真偽としての真値なのであろうか、それとも
インデクスだろうか、はたまた何かほかの数量に掛ける係数だろうか、と。
‘return True’ であればその意味するところはかなり明らかです。

Python の Boolean は、厳格な型チェックを目的として追加された 'のではあり
ません' 。Pascal のようなとても厳格な言語では、Boolean の数学演算も阻む
でしょうし、 *note if: 2ca. ステートメントの式が必ず Boolean の結果に評
価されなければならないことを要求するでしょう。 Python はこの厳しさを今持
ちませんし、 PEP 285(1) が名言するように、未来永劫持つことはありません。
このことは、 ‘if’ ステートメントにこれからも任意の式を書けることを意味し
ますし、リストやらタプルやら何かほかのデタラメなオブジェクトに評価される
ものでも良いことを意味します。Boolean 型は *note int: 238. クラスのサブ
クラスであって、Boolean の算術演算はこれからも動作します:

     >>> True + 1
     2
     >>> False + 1
     1
     >>> False * 75
     0
     >>> True * 75
     75

*note True: bdb. と *note False: b05. はぶっちゃけて言えば…: これらは整
数値 1 と 0 の別名だけれども唯一異なるのは *note str(): 418. と *note
repr(): 7c8. が ‘'1'’ と ‘'0'’ ではなく ‘'True'’ と ‘'False'’ を返すこと
だけである。

参考
....

PEP 285(2) - 真偽値型の追加

     Guido van Rossum 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0285/

   (2) https://peps.python.org/pep-0285/


File: python.info,  Node: PEP 293 コーデックエラーを処理するコールバック,  Next: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ,  Prev: PEP 285 Boolean 型,  Up: What's New in Python 2 3

1.19.10 PEP 293: コーデックエラーを処理するコールバック
-------------------------------------------------------

Unicode 文字列をバイト文字列にエンコードする際には、エンコード出来ない文
字に出会うことがあります。いまのところ Python は、そのエラー処理として
"strict" (*note UnicodeError: 1275. を発生させる)、 "ignore" (その文字を
スキップする)、 "replace" (出力文字列ではクエッションマークに置換する)、
のいずれか一つを指定出来て、 "strict" がデフォルトの振る舞いになっていま
す。その種のエラーのために、ほかの代わりとなる処理が望ましいかもしれませ
ん。例えば XML や HTML の実体参照に置き換えるなどの。

Python は今や、異なる処理戦略を追加する柔軟なフレームワークを手にしまし
た。新しいエラーハンドラを *note codecs.register_error(): 143e. で追加出
来、コーデックは *note codecs.lookup_error(): 143f. を使ってそのエラーハ
ンドラにアクセス出来ます。等価な C API も C で書かれたコーデックのために
追加されています。エラーハンドラは、変換すべき文字列、そのエラーが検出さ
れたその文字列内での位置、ターゲットエンコーディングのような必要な状態情
報を受け取ります。ハンドラは例外を投げるか、置換文字列を返せます。

このフレームワークを使って 2 つのエラーハンドラが実装されました:
"backslashreplace" はエンコード出来ない文字をバックスラッシュで引用し、
"xmlcharrefreplace" は XML 文字参照を発行します。

参考
....

PEP 293(1) - コーデックエラーを処理するコールバック

     Walter Dörwald 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0293/


File: python.info,  Node: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ,  Next: PEP 302 新たなインポートフック,  Prev: PEP 293 コーデックエラーを処理するコールバック,  Up: What's New in Python 2 3

1.19.11 PEP 301: パッケージインデクスと、 Distutils のためのメタデータ
----------------------------------------------------------------------

長い間要望されてきた Python カタログのサポートが 2.3 で初登場です。

カタログの心臓部は Distutils の新コマンド ‘register’ です。 ‘python
setup.py register’ を実行すると、名前、バージョン、メンテナ、説明、ライ
センスのようなパッケージ記述のメタデータを収集して、中央カタログサーバに
送信します。結果のカタログは ‘https://pypi.org’ で利用可能です。

To make the catalog a bit more useful, a new optional 'classifiers'
keyword argument has been added to the Distutils ‘setup()’ function.  A
list of Trove(1)-style strings can be supplied to help classify the
software.

以下は ‘setup.py’ に分類指定子 (classifier) を記述する例です。 Distutils
の古いバージョンと互換になるように書いています。:

     from distutils import core
     kw = {'name': "Quixote",
           'version': "0.5.1",
           'description': "A highly Pythonic Web application framework",
           # ...
           }

     if (hasattr(core, 'setup_keywords') and
         'classifiers' in core.setup_keywords):
         kw['classifiers'] = \
             ['Topic :: Internet :: WWW/HTTP :: Dynamic Content',
              'Environment :: No Input/Output (Daemon)',
              'Intended Audience :: Developers'],

     core.setup(**kw)

classifier の完全なリストは ‘python setup.py register
--list-classifiers’ と実行することで得ることが出来ます。

参考
....

PEP 301(2) - パッケージインデクスと、 Distutils のためのメタデータ

     Richard Jones 著、実装

   ---------- Footnotes ----------

   (1) http://catb.org/~esr/trove/

   (2) https://peps.python.org/pep-0301/


File: python.info,  Node: PEP 302 新たなインポートフック,  Next: PEP 305 カンマ区切り形式ファイル,  Prev: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ,  Up: What's New in Python 2 3

1.19.12 PEP 302: 新たなインポートフック
---------------------------------------

カスタムなインポートフックを書くことは、Python 1.3 で ‘ihooks’ モジュー
ルが導入されたその日からずっと可能でした。それでも本当のところそれで幸せ
になった人は誰一人いません。それで新しいインポートフックを書くのが難しく
てとっ散らかっていたからです。 ‘imputil’ と ‘iu’ モジュール のような代わ
りとなる色々な提案がありましたが、そのいずれも多くの賛同を得ることが出来
たものはありませんし、そのいずれもが簡単に C コードから使うことが出来ま
せんでした。

PEP 302(1) はその先駆者、特に Gordon McMillan の ‘iu’ モジュールからアイ
ディアを借りています。3 つの新たなアイテムが *note sys: c3. モジュールに
追加されています:

   * ‘sys.path_hooks’ は呼び出し可能オブジェクトのリストです。ほとんどの
     場合クラスになるでしょう。それぞれの呼び出し可能オブジェクトは、パ
     スを含む文字列を受け取って、このパスからインポートを処理するインポ
     ーターオブジェクトを返すか、このパスを処理出来なければ *note
     ImportError: 3f2. を送出します。

   * ‘sys.path_importer_cache’ はそれぞれのパスごとのインポーターオブジ
     ェクトをキャッシュしますので、 ‘sys.path_hooks’ は個々のパスを一回
     だけ横断すれば良いことになります。

   * ‘sys.meta_path’ は ‘sys.path’ がチェックされる前に横断させるインポ
     ーターオブジェクトのリストです(訳注: ここだけ読むとわかりにくいです
     がライブラリリファレンスを読めばわかります)。このリストは初期状態で
     空ですが、ユーザコードがオブジェクトをそれに追加出来ます。追加のビ
     ルトインと凍結モジュールを、このリストにオブジェクトを追加すること
     によってインポートさせることが出来ます。

インポーターオブジェクトは一つのメソッド ‘find_module(fullname,
path=None)’ を持たなければなりません。 'fullname' はモジュールかパッケー
ジの名前です。例えば ‘string’ や ‘distutils.core’ です。 ‘find_module()’
メソッドは一つのメソッド ‘load_module(fullname)’ を持つローダーオブジェ
クトを返さなければなりません。 ‘load_module(fullname)’ では対応するモジ
ュールオブジェクトを生成して返します。

Python の新しいインポートのロジックは、なので、擬似コードで示すとだいた
いこんな感じです (少し単純化しています; 完全な詳細は PEP 302(2) 参照):

     for mp in sys.meta_path:
         loader = mp(fullname)
         if loader is not None:
             <module> = loader.load_module(fullname)

     for path in sys.path:
         for hook in sys.path_hooks:
             try:
                 importer = hook(path)
             except ImportError:
                 # ImportError, so try the other path hooks
                 pass
             else:
                 loader = importer.find_module(fullname)
                 <module> = loader.load_module(fullname)

     # Not found!
     raise ImportError

参考
....

PEP 302(3) - 新たなインポートフック

     Just van Rossum、Paul Moore 著、実装 Just van Rossum。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0302/

   (2) https://peps.python.org/pep-0302/

   (3) https://peps.python.org/pep-0302/


File: python.info,  Node: PEP 305 カンマ区切り形式ファイル,  Next: PEP 307 Pickle の機能拡張,  Prev: PEP 302 新たなインポートフック,  Up: What's New in Python 2 3

1.19.13 PEP 305: カンマ区切り形式ファイル
-----------------------------------------

カンマ区切りファイルは、データベースやスプレッドシートからのエキスポート
のために頻繁に使われるフォーマットです。Python 2.3 はカンマ区切りファイ
ルのパーサを追加しました。

カンマ区切りフォーマットは、ぱっと見で、簡単そうに見えます:

     Costs,150,200,3.95

行を読んで ‘line.split(',')’: これほどに簡単なものはあるだろうか、って?
ですが、文字列データ内にカンマを含んだりすると、コトは複雑になります:

     "Costs",150,200,3.95,"Includes taxes, shipping, and sundry items"

デカくて醜い正規表現でこれをパース出来るでしょうが、新登場の *note csv:
21. を使えば遥かに単純になります:

     import csv

     input = open('datafile', 'rb')
     reader = csv.reader(input)
     for line in reader:
         print line

The *note reader(): 453. function takes a number of different options.
The field separator isn't limited to the comma and can be changed to any
character, and so can the quoting and line-ending characters.

カンマ区切りファイルの異なった方言を定義して登録出来ます。今のところ 2 つ
の方言があって、両者とも Microsoft Excel で使われるものです。独立してい
る *note csv.writer: 454. はタプルやリストの連続から、デリミタを含む文字
列は引用符で囲みつつカンマ区切りファイルを生成します。

参考
....

PEP 305(1) - CSV File API

     PEP 著と実装: Kevin Altis, Dave Cole, Andrew McNamara, Skip
     Montanaro, Cliff Wells.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0305/


File: python.info,  Node: PEP 307 Pickle の機能拡張,  Next: 拡張スライス,  Prev: PEP 305 カンマ区切り形式ファイル,  Up: What's New in Python 2 3

1.19.14 PEP 307: Pickle の機能拡張
----------------------------------

The *note pickle: 95. and ‘cPickle’ modules received some attention
during the 2.3 development cycle.  In 2.2, new-style classes could be
pickled without difficulty, but they weren't pickled very compactly; PEP
307(1) quotes a trivial example where a new-style class results in a
pickled string three times longer than that for a classic class.

解決方法として、新しい pickle プロトコルが発明されました。 *note
pickle.dumps(): 1447. 関数はずっと長い間、テキストとするのかバイナリとす
るのかについてはサポートしていました。2.3 ではこのフラグは Boolean から
整数に再定義されました: 0 は旧式のテキストモード pickle フォーマット、1
が同じく旧式のバイナリフォーマット、そして 2 が今回の 2.3 から特有のフォ
ーマットです。新しく追加された定数 *note pickle.HIGHEST_PROTOCOL: 1448.
を指定すると、最も望ましいものが選択されます。

Unpickling is no longer considered a safe operation.  2.2's *note
pickle: 95. provided hooks for trying to prevent unsafe classes from
being unpickled (specifically, a ‘__safe_for_unpickling__’ attribute),
but none of this code was ever audited and therefore it's all been
ripped out in 2.3.  You should not unpickle untrusted data in any
version of Python.

To reduce the pickling overhead for new-style classes, a new interface
for customizing pickling was added using three special methods: *note
__getstate__(): 5a2, *note __setstate__(): 1449, and *note
__getnewargs__(): 144a.  Consult PEP 307(2) for the full semantics of
these methods.

pickle をもっとさらに圧縮する方法として、pickle されるクラスの身元特定の
ために長い文字列を使う代わりに整数コードを使えるようになっています。
Python Software Foundation は標準コードのリストを保守しています; プライ
ベート使用のためのコード範囲もあります。現在のところ指定されているコード
はありません。

参考
....

PEP 307(3) - pickle プロトコルの拡張

     著、実装: Guido van Rossum と Tim Peters

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0307/

   (2) https://peps.python.org/pep-0307/

   (3) https://peps.python.org/pep-0307/


File: python.info,  Node: 拡張スライス,  Next: その他の言語変更<16>,  Prev: PEP 307 Pickle の機能拡張,  Up: What's New in Python 2 3

1.19.15 拡張スライス
--------------------

Python 1.4 以来ずっと、スライシングの構文は省略可能な 3 つ目の引数
"step" またの名を "stride" 、をサポートしていたのです。例えばこれらは全
て合法な Python 構文です: ‘L[1:10:2]’, ‘L[:-1:1]’, ‘L[::-1]’ 。これはこ
の 3 つ目の引数を大々的に使う Numerical Python 開発者によって要望された
ことで Python に追加されたものですが、Python ビルトインのリスト、タプル
、文字列といったシーケンス型がこの機能をサポートすることはなく、これを試
みると *note TypeError: 502. を起こしていました。Michael Hudson がこの不
徹底を修正するパッチを寄稿しました。

例えば、今やリストの偶数番目要素を簡単に取り出せます:

     >>> L = range(10)
     >>> L[::2]
     [0, 2, 4, 6, 8]

負の値では、同じリストの逆順コピーを作るように動作します:

     >>> L[::-1]
     [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

これはタプル、配列、文字列に対しても使えます:

     >>> s='abcd'
     >>> s[::2]
     'ac'
     >>> s[::-1]
     'dcba'

リストや配列のような *note mutable: 1273. なシーケンスに対して、拡張スラ
イスを代入や削除に使えますが、拡張スライスと普通のスライスではいくつかの
違いがあります。普通のスライスで代入を行えば、シーケンスの長さを変更出来
ます (--訳注: 念のため。Python 3 の range は list を直接返す関数ではなく
ジェネレータなので、以下例は ‘a = list(range(3))’ などとしないと動作しま
せん。続く例でも同じです。--):

     >>> a = range(3)
     >>> a
     [0, 1, 2]
     >>> a[1:3] = [4, 5, 6]
     >>> a
     [0, 4, 5, 6]

拡張スライスにはこの柔軟性はありません。拡張スライスを代入に使う際は、ス
テートメントの右辺のリストは、置換されるスライスとしての要素数と同数でな
ければなりません:

     >>> a = range(4)
     >>> a
     [0, 1, 2, 3]
     >>> a[::2]
     [0, 2]
     >>> a[::2] = [0, -1]
     >>> a
     [0, 1, -1, 3]
     >>> a[::2] = [0,1,2]
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     ValueError: attempt to assign sequence of size 3 to extended slice of size 2

削除はもっと素直です:

     >>> a = range(4)
     >>> a
     [0, 1, 2, 3]
     >>> a[::2]
     [0, 2]
     >>> del a[::2]
     >>> a
     [1, 3]

One can also now pass slice objects to the *note __getitem__(): 264.
methods of the built-in sequences:

     >>> range(10).__getitem__(slice(0, 5, 2))
     [0, 2, 4]

あるいは直接 slice オブジェクトを添え字に使えます:

     >>> range(10)[slice(0, 5, 2)]
     [0, 2, 4]

To simplify implementing sequences that support extended slicing, slice
objects now have a method ‘indices(length)’ which, given the length of a
sequence, returns a ‘(start, stop, step)’ tuple that can be passed
directly to *note range(): 911.  ‘indices()’ handles omitted and
out-of-bounds indices in a manner consistent with regular slices (and
this innocuous phrase hides a welter of confusing details!).  The method
is intended to be used like this:

     class FakeSeq:
         ...
         def calc_item(self, i):
             ...
         def __getitem__(self, item):
             if isinstance(item, slice):
                 indices = item.indices(len(self))
                 return FakeSeq([self.calc_item(i) for i in range(*indices)])
             else:
                 return self.calc_item(i)

ところでこの例からは、ビルトインの *note slice: 436. オブジェクトが今で
は slice 型という型オブジェクトで、もう関数ではないことがわかるでしょう
。これは、Python 2.2 で *note int: 238, *note str: 418. などに対して行わ
れた同じ目的の修正と一貫しています。


File: python.info,  Node: その他の言語変更<16>,  Next: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>,  Prev: 拡張スライス,  Up: What's New in Python 2 3

1.19.16 その他の言語変更
------------------------

以下が、Python 2.3 言語コアに加えられた全ての変更点です。

   * *note yield: 99b. 文がこのドキュメントの *note PEP 255;
     単純なジェネレータ: 142b. で述べた通り、キーワードになっています。

   * 新たな組み込み関数 *note enumerate(): 1424. が追加されました。この
     ドキュメントの *note PEP 279; enumerate(): 1434. で述べた通りです。

   * 新たな定数 *note True: bdb, *note False: b05. がビルトイン *note
     bool: 434. 型の追加に伴い追加されました。このドキュメントの *note
     PEP 285; Boolean 型: 143c. で述べた通りです。

   * *note int(): 238. 型コンストラクタは、文字列や浮動小数点数を整数に
     収める際、それがとても大き場合に *note OverflowError: 84e. を投げる
     のではなく長整数を返すようになっています。これは
     ‘isinstance(int(expression), int)’ が偽を返すかもしれないという逆説
     的な結果をもたらし得ますが、これが実際に問題を起こすとはあまり思え
     ません。

   * ビルトイン型が拡張スライス構文をサポートするようになりました。この
     ドキュメントの *note 拡張スライス: 144c. で述べた通りです。

   * 新規組み込み関数 ‘sum(iterable, start=0)’ はイテラブル オブジェクト
     内の数値アイテムを足し込んで総和を返します。 *note sum(): 437. は数
     値しか受け付けませんので、文字列群を連結するのには使えません。
     (Contributed by Alex Martelli.)

   * ‘list.insert(pos, value)’ で 'value' を先頭に追加するのに 'pos' に
     負数が使われてきました。この振る舞いはスライスのインデクシングとの
     一貫性のために変更されました。つまり 'pos' が -1 の場合は最終要素の
     前への追加、などとなります。

   * ‘list.index(value)’ はリスト内から 'value' を探してそのインデクスを
     返しますが、オプショナルな 'start' と 'stop' 引数を取って、リストの
     部分列からの検索が可能になりました。

   * 辞書の新たなメソッド ‘pop(key[, *default*])’ は、 'key' に対応する
     値を返して辞書からそのキー/値ペアを取り除きます。辞書内にそのキーが
     不在であれば、 'default' が指定されていればそれを、そうでなければ
     *note KeyError: 31d. を投げます。:

          >>> d = {1:2}
          >>> d
          {1: 2}
          >>> d.pop(4)
          Traceback (most recent call last):
            File "stdin", line 1, in ?
          KeyError: 4
          >>> d.pop(1)
          2
          >>> d.pop(1)
          Traceback (most recent call last):
            File "stdin", line 1, in ?
          KeyError: 'pop(): dictionary is empty'
          >>> d
          {}
          >>>

     また、新しいメソッド ‘dict.fromkeys(iterable, value)’ は、与えられ
     たイテレータ 'iterable' からキーを取り出しつつ全ての値を 'value' に
     セットすることで構築します。 'value' のデフォルトは ‘None’ です。

     (Patches contributed by Raymond Hettinger.)

     また、 *note dict(): 237. コンストラクタは小さな辞書を簡単に構築出
     来るよう、キーワード引数を受け付けるようになりました:

          >>> dict(red=1, blue=2, green=3, black=4)
          {'blue': 2, 'black': 4, 'green': 3, 'red': 1}

     (Contributed by Just van Rossum.)

   * *note assert: 936. ステートメントが ‘__debug__’ フラグをチェックす
     ることはもうありません。このため、 ‘__debug__’ に代入することによっ
     てアサーションを無効にすることは出来ません。Python を *note -O:
     d82. スイッチで起動により全てのアサーションが実行されない点は、以前
     と変わりません。

   * ほとんどの型オブジェクトが今では呼び出し可能であり、なので関数、ク
     ラス、モジュールのようなオブジェクトを新たに構築するのにそれを使え
     ます。 (‘new’ モジュールはこれにより将来のバージョンの Python で撤
     廃される可能性があります。 *note types: ec. モジュール内の型オブジ
     ェクトが使えるからです。 --訳注: 2.6 で実際に撤廃されています。--)
     例えば、新規モジュールオブジェクトは以下コードで構築出来ます:

          >>> import types
          >>> m = types.ModuleType('abc','docstring')
          >>> m
          <module 'abc' (built-in)>
          >>> m.__doc__
          'docstring'

   * 新たな警告 *note PendingDeprecationWarning: 895. が、将来廃止される
     予定のある機能であることを示すために追加されました。この警告はデフ
     ォルトで '出力されません' 。将来において廃止される予定の機能の使用
     をチェックするにはコマンドラインから *note
     -Walways;;PendingDeprecationWarning;;: 896. を与えるか、 *note
     warnings.filterwarnings(): 144e. を使います。

   * 文字列ベースの例外、例えば ‘raise "Error occurred"’ のようなもの、
     これは廃止のための過程を開始しています。文字列を例外として投げると
     *note PendingDeprecationWarning: 895. が発行されます。

   * ‘None’ を変数名に使うと *note SyntaxWarning: 432. 警告を出すように
     なっています。将来バージョンの Python では ‘None’ はキーワードにな
     ります。

   * The ‘xreadlines()’ method of file objects, introduced in Python
     2.1, is no longer necessary because files now behave as their own
     iterator.  ‘xreadlines()’ was originally introduced as a faster way
     to loop over all the lines in a file, but now you can simply write
     ‘for line in file_obj’.  File objects also have a new read-only
     ‘encoding’ attribute that gives the encoding used by the file;
     Unicode strings written to the file will be automatically converted
     to bytes using the given encoding.

   * The method resolution order used by new-style classes has changed,
     though you'll only notice the difference if you have a really
     complicated inheritance hierarchy.  Classic classes are unaffected
     by this change.  Python 2.2 originally used a topological sort of a
     class's ancestors, but 2.3 now uses the C3 algorithm as described
     in the paper "A Monotonic Superclass Linearization for Dylan"(1).
     To understand the motivation for this change, read Michele
     Simionato's article *note The Python 2.3 Method Resolution Order:
     144f, or read the thread on python-dev starting with the message at
     ‘https://mail.python.org/pipermail/python-dev/2002-October/029035.html’.
     Samuele Pedroni first pointed out the problem and also implemented
     the fix by coding the C3 algorithm.

   * Python runs multithreaded programs by switching between threads
     after executing N bytecodes.  The default value for N has been
     increased from 10 to 100 bytecodes, speeding up single-threaded
     applications by reducing the switching overhead.  Some
     multithreaded applications may suffer slower response time, but
     that's easily fixed by setting the limit back to a lower number
     using ‘sys.setcheckinterval(N)’.  The limit can be retrieved with
     the new ‘sys.getcheckinterval()’ function.

   * マイナーですが広範囲に渡る変更として、拡張型の名前の変更があります
     。Python と一緒に含まれるモジュールで定義される拡張型の名前が、モジ
     ュール名と ‘'.'’ が型名に前置されるようになりました。例えば、Python
     2.2 ではソケットオブジェクトを作って ‘__class__’ を出力すると、この
     ような出力だったでしょう:

          >>> s = socket.socket()
          >>> s.__class__
          <type 'socket'>

     2.3 ではこうなります:

          >>> s.__class__
          <type '_socket.socket'>

   * One of the noted incompatibilities between old- and new-style
     classes has been removed: you can now assign to the *note __name__:
     1450. and *note __bases__: 1451. attributes of new-style classes.
     There are some restrictions on what can be assigned to ‘__bases__’
     along the lines of those relating to assigning to an instance's
     *note __class__: 1452. attribute.

* Menu:

* 文字列に関する変更::
* 最適化: 最適化<15>.

   ---------- Footnotes ----------

   (1) https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.19.3910


File: python.info,  Node: 文字列に関する変更,  Next: 最適化<15>,  Up: その他の言語変更<16>

1.19.16.1 文字列に関する変更
............................

   * *note in: 2cb. 演算子が文字列に対して違った振る舞いをするようになり
     ました。以前は 'X' と 'Y' が文字列の場合の ‘X in Y’ は、 'X' は単一
     文字でなければなりませんでした。これが 'X' はどんな長さでも良くなり
     、 ‘X in Y’ は 'X' が 'Y' のサブストリングであれば *note True: bdb.
     を返すように変更されました。 'X' が空文字列の場合は結果は常に *note
     True: bdb. になります。

          >>> 'ab' in 'abcd'
          True
          >>> 'ad' in 'abcd'
          False
          >>> '' in 'abcd'
          True

     これはサブストリングの開始位置を教えてくれるわけではないので、その
     情報が必要であれば *note find(): e71. 文字列メソッドを使ってくださ
     い。

   * *note strip(): 1454, *note lstrip(): 1455, *note rstrip(): 1456. に
     、剥ぎ取る文字を指定する省略可能な引数が追加されています。デフォル
     トは従来通り全ての空白文字を削除します。:

          >>> '   abc '.strip()
          'abc'
          >>> '><><abc<><><>'.strip('<>')
          'abc'
          >>> '><><abc<><><>\n'.strip('<>')
          'abc<><><>\n'
          >>> u'\u4000\u4001abc\u4000'.strip(u'\u4000')
          u'\u4001abc'
          >>>

     (Suggested by Simon Brunning and implemented by Walter Dörwald.)

   * The *note startswith(): e94. and *note endswith(): e95. string
     methods now accept negative numbers for the 'start' and 'end'
     parameters.

   * Another new string method is *note zfill(): 1457, originally a
     function in the *note string: be. module.  *note zfill(): 1457.
     pads a numeric string with zeros on the left until it's the
     specified width.  Note that the ‘%’ operator is still more flexible
     and powerful than *note zfill(): 1457.

          >>> '45'.zfill(4)
          '0045'
          >>> '12345'.zfill(4)
          '12345'
          >>> 'goofy'.zfill(6)
          '0goofy'

     (Contributed by Walter Dörwald.)

   * A new type object, ‘basestring’, has been added.  Both 8-bit
     strings and Unicode strings inherit from this type, so
     ‘isinstance(obj, basestring)’ will return *note True: bdb. for
     either kind of string.  It's a completely abstract type, so you
     can't create ‘basestring’ instances.

   * 内部化した文字列はもう不死身ではないので、内部辞書からの参照が、参
     照している唯一のものとなれば、普通にガーベージコレクト対象となりま
     す。 (Implemented by Oren Tirosh.)


File: python.info,  Node: 最適化<15>,  Prev: 文字列に関する変更,  Up: その他の言語変更<16>

1.19.16.2 最適化
................

   * The creation of new-style class instances has been made much
     faster; they're now faster than classic classes!

   * The *note sort(): b9d. method of list objects has been extensively
     rewritten by Tim Peters, and the implementation is significantly
     faster.

   * Multiplication of large long integers is now much faster thanks to
     an implementation of Karatsuba multiplication, an algorithm that
     scales better than the 'O'('n'^2) required for the grade-school
     multiplication algorithm.  (Original patch by Christopher A. Craig,
     and significantly reworked by Tim Peters.)

   * The ‘SET_LINENO’ opcode is now gone.  This may provide a small
     speed increase, depending on your compiler's idiosyncrasies.  See
     section *note その他の変更と修正: 1459. for a longer explanation.
     (Removed by Michael Hudson.)

   * ‘xrange()’ objects now have their own iterator, making ‘for i in
     xrange(n)’ slightly faster than ‘for i in range(n)’.  (Patch by
     Raymond Hettinger.)

   * A number of small rearrangements have been made in various hotspots
     to improve performance, such as inlining a function or removing
     some code.  (Implemented mostly by GvR, but lots of people have
     contributed single changes.)

The net result of the 2.3 optimizations is that Python 2.3 runs the
pystone benchmark around 25% faster than Python 2.2.


File: python.info,  Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>,  Next: Pymalloc 特殊化されたオブジェクトアロケータ,  Prev: その他の言語変更<16>,  Up: What's New in Python 2 3

1.19.17 新たなモジュール、改良されたモジュール、非推奨のモジュール
------------------------------------------------------------------

いつものように、Python の標準ライブラリには数多くの拡張とバグ修正があり
ました。ここでは最も注目に値する変更について、モジュールの辞書順に列挙し
ます。変更の完全なリストについてはソースツリーの ‘Misc/NEWS’ を調べるか
、あるいは全ての詳細について CVS ログに目を通してみてください。

   * *note array: 6. モジュールが ‘'u'’ フォーマット文字を使った Unicode
     文字の配列をサポートするようになっています。配列はまた、 ‘+=’ 代入
     演算子を使ってほかの配列内容を加算すること、 ‘*=’ 演算子を使って配
     列を繰り返すことが可能になっています。(Contributed by Jason
     Orendorff.)

   * ‘bsddb’ モジュールが PyBSDDB(1) バージョン 4.1.6 によって置き換えら
     れています。これは BerkeleyDB のトランザクションの機能へのより完全
     なインターフェースを提供します。

     古いバージョンのモジュールは ‘bsddb185’ にリネームされて、自動的に
     はビルドされません。有効にするには ‘Modules/Setup’ を編集する必要が
     あります。新しい ‘bsddb’ パッケージは古いモジュールと互換となるよう
     に意図されていますので、何か非互換を見つけたらファイルのバグを確認
     してください。Python 2.3 へのアップグレードの際、前提となる
     BerkeleyDB ライブラリの新バージョンでインタープリタがコンパイルされ
     るならば、ほぼ確実にあなたのデータベースは新バージョンに変換しなけ
     ればならないでしょう。ソース配布物の ‘Tools/scripts’ ディレクトリの
     ‘db2pickle.py’ と ‘pickle2db.py’ スクリプトを使って、これをかなり簡
     単に行うことが出来ます。もし既に PyBSDDB パッケージを使っていて
     ‘bsddb3’ としてインポートしているならば、 ‘bsddb’ をインポートする
     ように ‘import’ 文を変更する必要があります。

   * 新規の *note bz2: f. モジュールは bz2 データ圧縮ライブラリへのイン
     ターフェイスです。bz2 圧縮データは普通 *note zlib: 119. 圧縮データ
     よりも小さくなります。 (Contributed by Gustavo Niemeyer.)

   * 標準の日付時刻型が *note datetime: 28. モジュールとして追加されてい
     ます。詳細はこのドキュメントの下の方に記述してありますのでそちらを
     参照して下さい。

   * The Distutils ‘Extension’ class now supports an extra constructor
     argument named 'depends' for listing additional source files that
     an extension depends on.  This lets Distutils recompile the module
     if any of the dependency files are modified.  For example, if
     ‘sampmodule.c’ includes the header file ‘sample.h’, you would
     create the ‘Extension’ object like this:

          ext = Extension("samp",
                          sources=["sampmodule.c"],
                          depends=["sample.h"])

     ‘sample.h’ を修正するとモジュールは再コンパイルされます。
     (Contributed by Jeremy Hylton.)

   * Other minor changes to Distutils: it now checks for the *note CC:
     145b, *note CFLAGS: 145c, ‘CPP’, *note LDFLAGS: 145d, and *note
     CPPFLAGS: 145e. environment variables, using them to override the
     settings in Python's configuration (contributed by Robert Weber).

   * Previously the *note doctest: 31. module would only search the
     docstrings of public methods and functions for test cases, but it
     now also examines private ones as well.  The *note DocTestSuite():
     dc0. function creates a *note unittest.TestSuite: dc1. object from
     a set of *note doctest: 31. tests.

   * 新しい関数 ‘gc.get_referents(object)’ は 'object' により参照されて
     いる全てのオブジェクトのリストを返します。

   * The *note getopt: 57. module gained a new function, *note
     gnu_getopt(): 145f, that supports the same arguments as the
     existing *note getopt(): 1460. function but uses GNU-style scanning
     mode.  The existing *note getopt(): 1460. stops processing options
     as soon as a non-option argument is encountered, but in GNU-style
     mode processing continues, meaning that options and arguments can
     be mixed.  For example:

          >>> getopt.getopt(['-f', 'filename', 'output', '-v'], 'f:v')
          ([('-f', 'filename')], ['output', '-v'])
          >>> getopt.gnu_getopt(['-f', 'filename', 'output', '-v'], 'f:v')
          ([('-f', 'filename'), ('-v', '')], ['output'])

     (Contributed by Peter Åstrand.)

   * モジュール *note grp: 5c, *note pwd: a0, *note resource: aa. では拡
     張されたタプルを返すようになりました:

          >>> import grp
          >>> g = grp.getgrnam('amk')
          >>> g.gr_name, g.gr_gid
          ('amk', 500)

   * *note gzip: 5d. モジュールが 2 GiB を超えるファイルを扱えるようにな
     っています。

   * The new *note heapq: 5f. module contains an implementation of a
     heap queue algorithm.  A heap is an array-like data structure that
     keeps items in a partially sorted order such that, for every index
     'k', ‘heap[k] <= heap[2*k+1]’ and ‘heap[k] <= heap[2*k+2]’.  This
     makes it quick to remove the smallest item, and inserting a new
     item while maintaining the heap property is 'O'(log 'n').  (See
     ‘https://xlinux.nist.gov/dads//HTML/priorityque.html’ for more
     information about the priority queue data structure.)

     The *note heapq: 5f. module provides *note heappush(): 1461. and
     *note heappop(): 1462. functions for adding and removing items
     while maintaining the heap property on top of some other mutable
     Python sequence type.  Here's an example that uses a Python list:

          >>> import heapq
          >>> heap = []
          >>> for item in [3, 7, 5, 11, 1]:
          ...    heapq.heappush(heap, item)
          ...
          >>> heap
          [1, 3, 5, 11, 7]
          >>> heapq.heappop(heap)
          1
          >>> heapq.heappop(heap)
          3
          >>> heap
          [5, 7, 11]

     (Contributed by Kevin O'Connor.)

   * The IDLE integrated development environment has been updated using
     the code from the IDLEfork project
     (‘https://idlefork.sourceforge.net’).  The most notable feature is
     that the code being developed is now executed in a subprocess,
     meaning that there's no longer any need for manual ‘reload()’
     operations.  IDLE's core code has been incorporated into the
     standard library as the *note idlelib: 69. package.

   * *note imaplib: 6a. モジュールが IMAP over SSL をサポートするように
     なりました.  (Contributed by Piers Lauder and Tino Lange.)

   * The *note itertools: 75. contains a number of useful functions for
     use with iterators, inspired by various functions provided by the
     ML and Haskell languages.  For example,
     ‘itertools.ifilter(predicate, iterator)’ returns all elements in
     the iterator for which the function ‘predicate()’ returns *note
     True: bdb, and ‘itertools.repeat(obj, N)’ returns ‘obj’ 'N' times.
     There are a number of other functions in the module; see the
     package's reference documentation for details.  (Contributed by
     Raymond Hettinger.)

   * *note math: 81. module の 2 つの新規関数 ‘degrees(rads)’ と
     ‘radians(degs)’ は、ラジアンと度の間の変換を行います。 *note math:
     81. モジュールの *note math.sin(): 1463. や *note math.cos(): 1464.
     などは常にラジアンでの入力が必要です。 *note math.log(): 1465. 関数
     には底を指定するオプショナルの 'base' 引数が追加されていて、 ‘e’ と
     ‘10’ でない底の対数を計算するのが簡単になりました。 (Contributed by
     Raymond Hettinger.)

   * Several new POSIX functions (‘getpgid()’, ‘killpg()’, ‘lchown()’,
     ‘loadavg()’, ‘major()’, ‘makedev()’, ‘minor()’, and ‘mknod()’) were
     added to the *note posix: 9b. module that underlies the *note os:
     91. module.  (Contributed by Gustavo Niemeyer, Geert Jansen, and
     Denis S. Otkidach.)

   * In the *note os: 91. module, the ‘*stat()’ family of functions can
     now report fractions of a second in a timestamp.  Such time stamps
     are represented as floats, similar to the value returned by *note
     time.time(): 235.

     During testing, it was found that some applications will break if
     time stamps are floats.  For compatibility, when using the tuple
     interface of the *note stat_result: 1466. time stamps will be
     represented as integers.  When using named fields (a feature first
     introduced in Python 2.2), time stamps are still represented as
     integers, unless ‘os.stat_float_times()’ is invoked to enable float
     return values:

          >>> os.stat("/tmp").st_mtime
          1034791200
          >>> os.stat_float_times(True)
          >>> os.stat("/tmp").st_mtime
          1034791200.6335014

     Python 2.4 では、浮動小数点数を返すのがデフォルトとなります。

     Application developers should enable this feature only if all their
     libraries work properly when confronted with floating-point time
     stamps, or if they use the tuple API. If used, the feature should
     be activated on an application level instead of trying to enable it
     on a per-use basis.

   * *note optparse: 90. モジュールに新たなコマンドライン引数パーサが追
     加されました。これはオプション値を特定の Python 型に変換することが
     出来、また、自動的に使用例メッセージを生成します。詳細はこのドキュ
     メントの続くセクションを参照して下さい。

   * The old and never-documented ‘linuxaudiodev’ module has been
     deprecated, and a new version named ‘ossaudiodev’ has been added.
     The module was renamed because the OSS sound drivers can be used on
     platforms other than Linux, and the interface has also been tidied
     and brought up to date in various ways.  (Contributed by Greg Ward
     and Nicholas FitzRoy-Dale.)

   * 実行中のプラットフォームについての色々な特性を決定する数多くの関数
     を含む、新規 *note platform: 98. モジュールが追加されました。アーキ
     テクチャ、CPU タイプ、Windows の OS バージョンや Linux ディストリビ
     ューションのバージョンなどを取得できます。(Contributed by
     Marc-André Lemburg.)

   * The parser objects provided by the *note pyexpat: 10d. module can
     now optionally buffer character data, resulting in fewer calls to
     your character data handler and therefore faster performance.
     Setting the parser object's *note buffer_text: 1467. attribute to
     *note True: bdb. will enable buffering.

   * The ‘sample(population, k)’ function was added to the *note random:
     a6. module.  'population' is a sequence or ‘xrange’ object
     containing the elements of a population, and *note sample(): 711.
     chooses 'k' elements from the population without replacing chosen
     elements.  'k' can be any value up to ‘len(population)’.  For
     example:

          >>> days = ['Mo', 'Tu', 'We', 'Th', 'Fr', 'St', 'Sn']
          >>> random.sample(days, 3)      # Choose 3 elements
          ['St', 'Sn', 'Th']
          >>> random.sample(days, 7)      # Choose 7 elements
          ['Tu', 'Th', 'Mo', 'We', 'St', 'Fr', 'Sn']
          >>> random.sample(days, 7)      # Choose 7 again
          ['We', 'Mo', 'Sn', 'Fr', 'Tu', 'St', 'Th']
          >>> random.sample(days, 8)      # Can't choose eight
          Traceback (most recent call last):
            File "<stdin>", line 1, in ?
            File "random.py", line 414, in sample
                raise ValueError, "sample larger than population"
          ValueError: sample larger than population
          >>> random.sample(xrange(1,10000,2), 10)   # Choose ten odd nos. under 10000
          [3407, 3805, 1505, 7023, 2401, 2267, 9733, 3151, 8083, 9195]

     *note random: a6. が C で実装された新しいアルゴリズムのメルセンヌ・
     ツイスタを使うようになりました。これは以前のアルゴリズムよりも高速
     で、より広く研究されています。

     (All changes contributed by Raymond Hettinger.)

   * The *note readline: a8. module also gained a number of new
     functions: *note get_history_item(): 1468, *note
     get_current_history_length(): 1469, and *note redisplay(): 146a.

   * The ‘rexec’ and ‘Bastion’ modules have been declared dead, and
     attempts to import them will fail with a *note RuntimeError: 17a.
     New-style classes provide new ways to break out of the restricted
     execution environment provided by ‘rexec’, and no one has interest
     in fixing them or time to do so.  If you have applications using
     ‘rexec’, rewrite them to use something else.

     (Sticking with Python 2.2 or 2.1 will not make your applications
     any safer because there are known bugs in the ‘rexec’ module in
     those versions.  To repeat: if you're using ‘rexec’, stop using it
     immediately.)

   * The ‘rotor’ module has been deprecated because the algorithm it
     uses for encryption is not believed to be secure.  If you need
     encryption, use one of the several AES Python modules that are
     available separately.

   * *note shutil: b3. モジュールに ‘move(src, dest)’ が追加されており、
     これはファイルまたはディレクトリを新しい場所へ再帰的に移動します。

   * Support for more advanced POSIX signal handling was added to the
     *note signal: b4. but then removed again as it proved impossible to
     make it work reliably across platforms.

   * *note socket: b8. モジュールがタイムアウトをサポートするようになり
     ました。ソケットオブジェクトの ‘settimeout(t)’ メソッドに 't' 秒を
     与えることで行えます。これに続くソケット操作が 't' 秒を超えて完了し
     ない場合には操作は中断し、 *note socket.timeout: 7ff. 例外を投げま
     す。

     オリジナルのタイムアウト実装は Tim O'Malley によりなされました。
     Michael Gilfix がこれを Python *note socket: b8. モジュールに統合し
     、長い長いレビューに導きました。コードがチェックインされたのち、
     Guido van Rossum はそれを部分的に書き換えました。(これは協調的開発
     プロセスの好例です。)

   * Windows での *note socket: b8. モジュールの Secure Sockets Layer
     (SSL) サポートが始まりました。

   * The value of the C ‘PYTHON_API_VERSION’ macro is now exposed at the
     Python level as ‘sys.api_version’.  The current exception can be
     cleared by calling the new ‘sys.exc_clear()’ function.

   * 新モジュール *note tarfile: c8. で ‘tar’ 形式のアーカイブファイルの
     読み書きが出来ます。 (Contributed by Lars Gustäbel.)

   * The new *note textwrap: d5. module contains functions for wrapping
     strings containing paragraphs of text.  The ‘wrap(text, width)’
     function takes a string and returns a list containing the text
     split into lines of no more than the chosen width.  The ‘fill(text,
     width)’ function returns a single string, reformatted to fit into
     lines no longer than the chosen width.  (As you can guess, *note
     fill(): 146b. is built on top of *note wrap(): 146c.  For example:

          >>> import textwrap
          >>> paragraph = "Not a whit, we defy augury: ... more text ..."
          >>> textwrap.wrap(paragraph, 60)
          ["Not a whit, we defy augury: there's a special providence in",
           "the fall of a sparrow. If it be now, 'tis not to come; if it",
           ...]
          >>> print textwrap.fill(paragraph, 35)
          Not a whit, we defy augury: there's
          a special providence in the fall of
          a sparrow. If it be now, 'tis not
          to come; if it be not to come, it
          will be now; if it be not now, yet
          it will come: the readiness is all.
          >>>

     The module also contains a *note TextWrapper: f9a. class that
     actually implements the text wrapping strategy.  Both the *note
     TextWrapper: f9a. class and the *note wrap(): 146c. and *note
     fill(): 146b. functions support a number of additional keyword
     arguments for fine-tuning the formatting; consult the module's
     documentation for details.  (Contributed by Greg Ward.)

   * The ‘thread’ and *note threading: d6. modules now have companion
     modules, ‘dummy_thread’ and ‘dummy_threading’, that provide a
     do-nothing implementation of the ‘thread’ module's interface for
     platforms where threads are not supported.  The intention is to
     simplify thread-aware modules (ones that 'don't' rely on threads to
     run) by putting the following code at the top:

          try:
              import threading as _threading
          except ImportError:
              import dummy_threading as _threading

     In this example, ‘_threading’ is used as the module name to make it
     clear that the module being used is not necessarily the actual
     *note threading: d6. module.  Code can call functions and use
     classes in ‘_threading’ whether or not threads are supported,
     avoiding an *note if: 2ca. statement and making the code slightly
     clearer.  This module will not magically make multithreaded code
     run without threads; code that waits for another thread to return
     or to do something will simply hang forever.

   * *note time: d7. モジュールの *note strptime(): 13d4. 関数は長いこと
     混乱の元でした。それがプラットフォームの C 関数 *note strptime():
     13d4. を使い、異なったプラットフォームごとに時折おかしなバグを持っ
     ていたからです。Brett Cannon は pure Python で、全てのプラットフォ
     ームで全く同じに振舞うように書き直した実装を寄稿しました。

   * 新規モジュール *note timeit: d8. は、Python コードの断片 (スニペッ
     ト) を実行するのにかかる時間を計測します。ファイル ‘timeit.py’ は直
     接コマンドラインから実行出来ますし、モジュールの *note Timer: 146d.
     クラスをインポートして直接使うことも出来ます。以下に、空の Unicode
     文字列を追加することによって 8 ビット文字列を Unicode に変換するの
     と ‘unicode()’ 関数を使うのとでいずれが高速なのかを把握するための短
     い例をお見せします:

          import timeit

          timer1 = timeit.Timer('unicode("abc")')
          timer2 = timeit.Timer('"abc" + u""')

          # Run three trials
          print timer1.repeat(repeat=3, number=100000)
          print timer2.repeat(repeat=3, number=100000)

          # On my laptop this outputs:
          # [0.36831796169281006, 0.37441694736480713, 0.35304892063140869]
          # [0.17574405670166016, 0.18193507194519043, 0.17565798759460449]

   * ‘Tix’ モジュールに色々バグ修正がなされ、Tix パッケージの現在バージ
     ョンに更新されました。

   * ‘Tkinter’ モジュールがスレッドを有効化した Tcl で動作するようになり
     ました。Tcl のスレッドモデルは、ウィジットはそれが作られたスレッド
     からのみアクセスされることを必要とします。ほかのスレッドからのアク
     セスは Tcl を混乱させます。ある特定の Tcl インターフェイスでは、
     ‘Tkinter’ はウィジットがコマンドの纏め上げによって異なるスレッドか
     らアクセスされる際に、正しいスレッドに向けて結果を待つことで自動的
     にこれを避けるようになりました。それ以外のインターフェイスでは自動
     で処理は出来ませんが、 ‘Tkinter’ はそのようなアクセス時に最低でもそ
     れが問題とわかるよう例外を送出するようになっています。この変更につ
     いての詳細な説明は
     ‘https://mail.python.org/pipermail/python-dev/2002-December/031107.html’
     をみてください。(Implemented by Martin von Löwis.)

   * ‘_tkinter’ を介した Tcl メソッド呼び出しは今では文字列だけを返すの
     ではありません。代わりに Tcl は対応する Python の等価なオブジェクト
     に変換されたオブジェクトを返します。Python に等価なものがなければ
     ‘_tkinter.Tcl_Obj’ で包んで返します。この振る舞いは ‘tkapp’ オブジ
     ェクトの ‘wantobjects()’ メソッドで制御出来ます。

     (ほとんどの Tkinter アプリケーションがそうするように) ‘Tkinter’ モ
     ジュールを通して ‘_tkinter’ を使う際、この機能は常に有効になります
     。これは互換性の問題を引き起こさないはずです。 Tkinter は可能な場合
     には文字列を Python 型に常に変換していたからです。

     何か非互換性を見つけたら古い振る舞いに戻せます。最初の ‘tkapp’ オブ
     ジェクトを生成する前に ‘Tkinter’ モジュールの ‘wantobjects’ 変数に
     偽をセットしてください:

          import Tkinter
          Tkinter.wantobjects = 0

     ここで説明した変更によって何かアプリケーションの破壊があれば、バグ
     として報告してください。

   * ‘UserDict’ モジュールに新しく ‘DictMixin’ クラスが追加されました。
     既に最小限のマッピングインターフェースを持っているクラスのために、
     全ての辞書メソッドを定義します。これは、 *note shelve: b1. モジュー
     ル内のクラスのような、辞書に置換可能である必要があるクラスの記述を
     大幅に単純化します。

     クラスがメソッド *note __getitem__(): 264, *note __setitem__():
     146e, *note __delitem__(): 146f, ‘keys()’ を定義している場合にはい
     つでも、スーパークラスとして mix-in を追加すると完全な辞書インター
     フェースになります。例えば:

          >>> import UserDict
          >>> class SeqDict(UserDict.DictMixin):
          ...     """Dictionary lookalike implemented with lists."""
          ...     def __init__(self):
          ...         self.keylist = []
          ...         self.valuelist = []
          ...     def __getitem__(self, key):
          ...         try:
          ...             i = self.keylist.index(key)
          ...         except ValueError:
          ...             raise KeyError
          ...         return self.valuelist[i]
          ...     def __setitem__(self, key, value):
          ...         try:
          ...             i = self.keylist.index(key)
          ...             self.valuelist[i] = value
          ...         except ValueError:
          ...             self.keylist.append(key)
          ...             self.valuelist.append(value)
          ...     def __delitem__(self, key):
          ...         try:
          ...             i = self.keylist.index(key)
          ...         except ValueError:
          ...             raise KeyError
          ...         self.keylist.pop(i)
          ...         self.valuelist.pop(i)
          ...     def keys(self):
          ...         return list(self.keylist)
          ...
          >>> s = SeqDict()
          >>> dir(s)      # See that other dictionary methods are implemented
          ['__cmp__', '__contains__', '__delitem__', '__doc__', '__getitem__',
           '__init__', '__iter__', '__len__', '__module__', '__repr__',
           '__setitem__', 'clear', 'get', 'has_key', 'items', 'iteritems',
           'iterkeys', 'itervalues', 'keylist', 'keys', 'pop', 'popitem',
           'setdefault', 'update', 'valuelist', 'values']

     (Contributed by Raymond Hettinger.)

   * The DOM implementation in *note xml.dom.minidom: 109. can now
     generate XML output in a particular encoding by providing an
     optional encoding argument to the *note toxml(): 1470. and *note
     toprettyxml(): 1471. methods of DOM nodes.

   * ‘xmlrpclib’ モジュールが、 Python の ‘None’ のような nil データを処
     理するための XML-RPC 拡張をサポートするようになりました。 nil 値は
     XML-RPC 応答のアンマーシャルでいつでもサポートされます。 ‘None’ を
     含んだリクエストを生成するためには、 ‘Marshaller’ のインスタンスを
     生成する際に 'allow_none' パラメータに真を与えなければなりません。

   * 新規モジュール ‘DocXMLRPCServer’ は、セルフ-ドキュメンティング
     XML-RPC サーバを書くのに使えます。実際のところをみるためにはデモモ
     ード (つまりプログラムとして) 実行してみてください。ウェブブラウザ
     を RPC サーバに向ければ pydoc スタイルのドキュメントを生成します。
     xmlrpclib をサーバに向ければ実際のメソッドを呼び出せます。
     (Contributed by Brian Quinlan.)

   * internationalized domain names (RFC 3454, 3490, 3491, 3492) のサポ
     ートが追加されました。Unicode ドメイン名とその名前の ASCII 互換エン
     コーディング (ACE=ASCII-compatible encoding) の間の変換をするのに
     "idna" エンコーディングを使用出来ます:

          >{}>{}> u"www.Alliancefrançaise.nu".encode("idna")
          'www.xn--alliancefranaise-npb.nu'

     *note socket: b8. モジュールも、C ライブラリに渡す前に Unicode ホス
     ト名を ACE バージョンに透過的に変換するように拡張されています。
     ‘httplib’ や *note ftplib: 54. のようなホスト名を扱うモジュールも
     Unicode ホスト名をサポートしています; ‘httplib’ は HTTP ‘Host’ ヘッ
     ダをドメイン名の ACE 版を使って送信します。 *note urllib: f1. は
     URL の ‘path’ 部分が ASCII のみである限り、非 ASCII ホスト名を持つ
     Unicode URL をサポートします

     この変更の実装のために、 *note stringprep: bf. モジュール、
     ‘mkstringprep’ ツール、 ‘punycode’ エンコーディングが追加されました
     。

* Menu:

* 日付時刻型::
* optparse モジュール::

   ---------- Footnotes ----------

   (1) https://pybsddb.sourceforge.net


File: python.info,  Node: 日付時刻型,  Next: optparse モジュール,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>

1.19.17.1 日付時刻型
....................

タイムスタンプとして使うのに相応しい日付と時刻の型が *note datetime: 28.
モジュールとして追加されました。これら型は異なるカレンダであるとか多くの
洒落た機能をサポートはせずに、時刻表現の基礎だけに集中するものです。

3 つの基礎となるクラスがあり、 *note date: 1af. は年・月・日を表現し、
*note time: 1b0. は時・分・秒を、 *note datetime: 1ae. が *note date:
1af. と *note time: 1b0. の両方の属性すべてを持ちます。また、 *note
timedelta: 99d. は 2 つの時刻の差を表現し、タイムゾーンのロジックは抽象
クラス *note tzinfo: 5a8. から派生したクラスにより実装されます。

You can create instances of *note date: 1af. and *note time: 1b0. by
either supplying keyword arguments to the appropriate constructor, e.g.
‘datetime.date(year=1972, month=10, day=15)’, or by using one of a
number of class methods.  For example, the *note today(): 1473. class
method returns the current local date.

構築後の日付時刻クラスのインスタンスは全て *note immutable: 1272. です。
オブジェクトから書式文字列を生成する数多くのメソッドがあります:

     >>> import datetime
     >>> now = datetime.datetime.now()
     >>> now.isoformat()
     '2002-12-30T21:27:03.994956'
     >>> now.ctime()  # Only available on date, datetime
     'Mon Dec 30 21:27:03 2002'
     >>> now.strftime('%Y %d %b')
     '2002 30 Dec'

The *note replace(): 1474. method allows modifying one or more fields of
a *note date: 1af. or *note datetime: 1ae. instance, returning a new
instance:

     >>> d = datetime.datetime.now()
     >>> d
     datetime.datetime(2002, 12, 30, 22, 15, 38, 827738)
     >>> d.replace(year=2001, hour = 12)
     datetime.datetime(2001, 12, 30, 12, 15, 38, 827738)
     >>>

インスタンスは比較可能で、ハッシュ出来、文字列に変換出来ます (結果は
*note isoformat(): afe. メソッドのものと同じです)。 と *note datetime:
1ae. はお互いに減算演算が可能で、 *note timedelta: 99d. インスタンスを加
算することも出来ます。最も大きな不足機能としては、文字列を解析して *note
date: 1af. や *note datetime: 1ae. へ戻すための標準ライブラリサポートは
ありません。(--訳注: 2 点。「比較可能」の意味は 2.3 から 2.4 で意味が変
わっています。2.4 で *note date: 1af. と *note datetime: 1ae. の比較は出
来なくなりました。2.3 では出来ていました。文字列からの *note datetime:
1ae. 構築は 2.5 で ‘strptime()’ が追加されています。--)

さらに詳しい情報については、モジュールのリファレンスドキュメントを参照し
てください。 (Contributed by Tim Peters.)


File: python.info,  Node: optparse モジュール,  Prev: 日付時刻型,  Up: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>

1.19.17.2 optparse モジュール
.............................

*note getopt: 57. モジュールはコマンドライン引数の単純な解析を提供してい
ます。新規に追加された *note optparse: 90. モジュール (元々 Optik と呼ば
れていたものです) は Unix の慣習に従ったもっと念入りなコマンドライン解析
を行い、自動的に ‘--help’ のための出力をし、異なったオプションに対して異
なったアクションを実行出来ます。 (--訳注: 2.7 以降は *note optparse: 90.
よりも新しい *note argparse: 5. を使ってください。--)

*note OptionParser: 1476. インスタンスを作ることから始め、プログラムのオ
プションがどんなであるかそれに対して教えてやります:

     import sys
     from optparse import OptionParser

     op = OptionParser()
     op.add_option('-i', '--input',
                   action='store', type='string', dest='input',
                   help='set input filename')
     op.add_option('-l', '--length',
                   action='store', type='int', dest='length',
                   help='set maximum length of output')

コマンドラインの解析は *note parse_args(): 1477. メソッドを呼び出すこと
で行います

     options, args = op.parse_args(sys.argv[1:])
     print options
     print args

これは、全てのオプションの値を含んだオブジェクトと残った引数を含む文字列
リストを返します。

色々な引数でこのスクリプトを実行すれば、あなたの期待するように動きます。
この例での 'length' 引数が自動的に整数に変換されることに注目してください
。

     $ ./python opt.py -i data arg1
     <Values at 0x400cad4c: {'input': 'data', 'length': None}>
     ['arg1']
     $ ./python opt.py --input=data --length=4
     <Values at 0x400cad2c: {'input': 'data', 'length': 4}>
     []
     $

ヘルプメッセージはあなたのために自動生成されます:

     $ ./python opt.py --help
     usage: opt.py [options]

     options:
       -h, --help            show this help message and exit
       -iINPUT, --input=INPUT
                             set input filename
       -lLENGTH, --length=LENGTH
                             set maximum length of output
     $

さらに詳しいことはモジュールのドキュメントを参照して下さい。

Optik は Getopt SIG の読者からの示唆を受けてGreg Ward により書かれました
。


File: python.info,  Node: Pymalloc 特殊化されたオブジェクトアロケータ,  Next: ビルドならびに C API の変更<12>,  Prev: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>,  Up: What's New in Python 2 3

1.19.18 Pymalloc: 特殊化されたオブジェクトアロケータ
----------------------------------------------------

Pymalloc は Vladimir Marangozov により書かれ Python 2.1 で追加された、特
殊化されたオブジェクトアロケータです。Pymalloc は典型的な Python プログ
ラムでのアロケーションのパターンにおいて、システムの ‘malloc()’ よりも高
速で省メモリであることを意図したものです。このアロケータは C の
‘malloc()’ 関数を大きなメモリプールを得るのに使い、それより小さなメモリ
要求はこれらプールで実現しています。

2.1 と 2.2 ではこの機能は実験的な位置付けでありデフォルトでは有効ではあ
りませんでした。これを有効にするには Python コンパイル時に ‘configure’ ス
クリプトに ‘--with-pymalloc’ オプションを明示的に与える必要がありました
。2.3 では pymalloc はさらに拡張され、また、デフォルトで有効になりました
。逆にこれを無効にするのに ‘--without-pymalloc’ を与える必要があります。

この変更は Python で書いたコードからは見えませんが、 pymalloc は C 拡張
内のバグを露にするかもしれません。C 拡張の著者は pymalloc を有効にしてテ
ストすべきです。というのも、ある種の正しくないコードが実行時にコアダンプ
しうるからです。

問題を起こすとりわけ一般的な誤りが一つあります。Python の C API 内には数
多くのメモリアロケーション関数がありますが、これは以前は単に C ライブラ
リの ‘malloc()’ と ‘free()’ への別名であり、何かの間違いでミスマッチな関
数呼び出しをしても、誤りは気付かれないものでした。今回のこのオブジェクト
アロケータを有効化すると、これら関数は ‘malloc()’ と ‘free()’ への別名で
はまったくなくて、メモリ解放に誤った関数を呼び出すとコアダンプし得ます。
例えば *note PyObject_Malloc(): c36. を使って獲得したメモリは ‘free()’ で
はなく *note PyObject_Free(): c34. を使って解放する必要があります。
Python に含まれるいくつかのモジュールがまさにこれに抵触し、修正の必要が
ありました。間違いなく多くのサードパーティモジュールが同じ問題を抱えてい
るでしょう。

この変更の一環として、メモリアロケーションのためのこんがらかった複数イン
ターフェイスが統合されて 2 つの API ファミリになりました。一方のファミリ
で獲得されたメモリは他方の関数で操作されることは許されません。一方のファ
ミリはメモリの塊を獲得するためのもので、もう一方は Python オブジェクトの
獲得に特殊化されたものです。

   * 何某かの区別のないメモリの塊を獲得・解放するのには「生メモリ」ファ
     ミリを使います: *note PyMem_Malloc(): c33, *note PyMem_Realloc():
     ffc, *note PyMem_Free(): 13ea.

   * 「オブジェクトメモリ」ファミリは上述の pymalloc 機構へのインターフ
     ェイスであり、多数の「小さな」獲得をするための特化がされています:
     *note PyObject_Malloc(): c36, *note PyObject_Realloc(): 13eb, *note
     PyObject_Free(): c34.

   * Python オブジェクトの獲得と解放には「オブジェクト」ファミリ *note
     PyObject_New: 953, *note PyObject_NewVar: 954, *note
     PyObject_Del(): 147a. を使います。

Tim Peters による多大な仕事のおかげで、 2.3 の pymalloc はデバッグ機能も
提供しています。これはメモリの上書き、二重解放に関して、拡張モジュールと
インタプリタ自身について検出出来ます。このサポートを有効にするには
‘configure’ スクリプトにオプション ‘--with-pydebug’ を与えて Python イン
タプリタをデバッグバージョンとしてコンパイルしてください。

拡張の著者のために、Python 2.3 のソースとともにヘッダファイル
‘Misc/pymemcompat.h’ が配布されています。これは Python 拡張に 2.3 インタ
ーフェイスでのメモリ獲得を使えるようにするもので、1.5.2 以降の全てのバー
ジョンに対してコンパイル可能です。Python のソース配布物からファイルをコ
ピーして、あなたの拡張ソースにバンドル出来ます。

参考
....

‘https://hg.python.org/cpython/file/default/Objects/obmalloc.c’

     pymalloc 実装に関する完全な詳細については Python ソースコード内の
     ‘Objects/obmalloc.c’ ファイルの先頭のコメントを参照してください。上
     のファイルへのリンクは python.org の SVN ブラウザを指しています。


File: python.info,  Node: ビルドならびに C API の変更<12>,  Next: その他の変更と修正<2>,  Prev: Pymalloc 特殊化されたオブジェクトアロケータ,  Up: What's New in Python 2 3

1.19.19 ビルドならびに C API の変更
-----------------------------------

Python のビルド過程と C API の変更は以下の通りです:

   * ガーベージコレクションで使われている循環の検出実装が安定であること
     がわかったため、必須とすることになりました。Python をこれなしでコン
     パイルすることはもう出来ません。 ‘configure’ スクリプトの
     ‘--with-cycle-gc’ スイッチは削除されました。

   * Python がオプショナルでシェアドライブラリ (‘libpython2.3.so’) とし
     てビルド可能になりました。Python の ‘configure’ スクリプトに
     ‘--enable-shared’ オプションを与えることで可能です。 (Contributed
     by Ondrej Palkovsky.)

   * マクロ ‘DL_EXPORT’ と ‘DL_IMPORT’ が非推奨となっています。Python コ
     アが一般的にマクロ ‘PyAPI_FUNC’ と ‘PyAPI_DATA’ を使うのに対し、
     Python 拡張モジュールの初期化関数が新規マクロ *note PyMODINIT_FUNC:
     147c. を使って宣言されなければならなくなりました。

   * ‘configure’ スクリプトに ‘--without-doc-strings’ オプションを与える
     ことで、ビルトイン関数とモジュールが docstring を持たないインタプリ
     タとしてコンパイル出来るようになりました。これは Python の実行形式
     ファイルを 10% 小さくしますが、もちろん Python ビルトインのヘルプが
     取得できないことにもなります。 (Contributed by Gustavo Niemeyer.)

   * ‘PyArg_NoArgs()’ マクロが非推奨となったので、これを使っているコード
     は修正しなければなりません。Python 2.2 以降ではメソッド定義テーブル
     では引数を持たず、引数チェックを省けることを示すのに *note
     METH_NOARGS: 147d. フラグが使えます。2.2 以前の Python バージョンと
     の互換性が重要な場合には ‘PyArg_ParseTuple(args, "")’ を代わりに使
     えますが、 *note METH_NOARGS: 147d. を使うより遅いです。

   * *note PyArg_ParseTuple(): 53d. に符号なし整数の色々なサイズのための
     フォーマット文字が追加されました: unsigned char のための ‘B’,
     unsigned short int のための ‘H’, unsigned int のための ‘I’,
     unsigned long long のための ‘K’。

   * 新規関数 ‘PyObject_DelItemString(mapping, char *key)’ が
     ‘PyObject_DelItem(mapping, PyString_New(key))’ の速記法として追加さ
     れました。

   * ファイルオブジェクトの内部文字列バッファの管理が変更されて、必要な
     場合には指数関数的に増やすようになりました。
     ‘Lib/test/test_bufio.py’ 内のベンチマークテストの結果での速度向上は
     大幅なものです (ある一つの計測では 57 秒から 1.7 秒になりました)。

   * It's now possible to define class and static methods for a C
     extension type by setting either the *note METH_CLASS: 147e. or
     *note METH_STATIC: 147f. flags in a method's *note PyMethodDef:
     1480. structure.

   * Python は Expat XML パーサのソースコードのコピーを丸抱えするように
     なり、これにより Expat のシステムのバージョンやローカルにインストー
     ルされたものへの依存がなくなっています。

   * If you dynamically allocate type objects in your extension, you
     should be aware of a change in the rules relating to the *note
     __module__: 34d. and *note __name__: 1450. attributes.  In summary,
     you will want to ensure the type's dictionary contains a
     ‘'__module__'’ key; making the module name the part of the type
     name leading up to the final period will no longer have the desired
     effect.  For more detail, read the API reference documentation or
     the source.

* Menu:

* ポート特有の変更: ポート特有の変更<3>.


File: python.info,  Node: ポート特有の変更<3>,  Up: ビルドならびに C API の変更<12>

1.19.19.1 ポート特有の変更
..........................

Support for a port to IBM's OS/2 using the EMX runtime environment was
merged into the main Python source tree.  EMX is a POSIX emulation layer
over the OS/2 system APIs.  The Python port for EMX tries to support all
the POSIX-like capability exposed by the EMX runtime, and mostly
succeeds; ‘fork()’ and *note fcntl(): 4f. are restricted by the
limitations of the underlying emulation layer.  The standard OS/2 port,
which uses IBM's Visual Age compiler, also gained support for
case-sensitive import semantics as part of the integration of the EMX
port into CVS. (Contributed by Andrew MacIntyre.)

On MacOS, most toolbox modules have been weaklinked to improve backward
compatibility.  This means that modules will no longer fail to load if a
single routine is missing on the current OS version.  Instead calling
the missing routine will raise an exception.  (Contributed by Jack
Jansen.)

The RPM spec files, found in the ‘Misc/RPM/’ directory in the Python
source distribution, were updated for 2.3.  (Contributed by Sean
Reifschneider.)

Other new platforms now supported by Python include AtheOS
(‘http://www.atheos.cx/’), GNU/Hurd, and OpenVMS.


File: python.info,  Node: その他の変更と修正<2>,  Next: Python 2 3 への移植,  Prev: ビルドならびに C API の変更<12>,  Up: What's New in Python 2 3

1.19.20 その他の変更と修正
--------------------------

いつものように、たくさんのほかの改善とバグフィックスがソースツリー全体に
渡って散らばっています。CVS 変更ログを検索すると、Python 2.2 から 2.3 に
かけて適用されたパッチは 523、バグ修正は 514 ありました。いずれも少なく
見積もって、です。

ほかの、さらに特筆すべき変更のいくつかを挙げます:

   * 環境変数 *note PYTHONINSPECT: 1483. をセットしておくと、Python イン
     タプリタが Python プログラム実行後に対話モードに入ります。これは
     Python を *note -i: 1484. で起動するのと同じです。環境変数は Python
     インタプリタ実行前にセットするか、Python プログラムのその実行の一部
     としてセットすることが出来ます。

   * ‘regrtest.py’ スクリプトで「'foo' を除く全てのリソース」とする手段
     が出来ました。 ‘-u’ オプションにリソース名を渡すのにハイフン
     (‘'-'’) を前置すると「このリソースを除く」ことを意味します。例えば
     '‘-uall,-bsddb’' は ‘bsddb’ を除く全てのリソースを有効にするのに使
     えます。

   * ドキュメントのビルドに使われるツールは今では Unix 同様に Cygwin で
     も動作します。

   * ‘SET_LINENO’ 命令コード (opcode) は削除されました。彼方の昔に戻れば
     、この命令コードはトレースバック内で行番号を生成し、トレース関数を
     サポートするのに必要でした (例えば *note pdb: 94. のために)。Python
     1.5 より、トレースバック内の行番号は "python -O" で働くための異なっ
     たメカニズムを用いて計算で求められてきました。2.3 のためには
     Michael Hudson がトレース関数を呼ぶのに決定する似た方法を実装しまし
     たので、 ‘SET_LINENO’ の必要性は完全になくなりました。

     Python コードから何か異なる結果を見つけるのは、 *note -O: d82. なし
     で Python を実行する際のわずかなスピードアップを別とすれば、困難か
     もしれません。

     フレームオブジェクトの *note f_lineno: 777. フィールドにアクセスし
     ている C 拡張は、代わりに ‘PyCode_Addr2Line(f->f_code, f->f_lasti)’
     を呼び出すべきです。これは以前の Python バージョンでも "python -O"
     のもとでコードが動作するのにも望ましい効果を持つでしょう。

     気の利いた新機能としては、トレース関数は、今ではフレームオブジェク
     トの *note f_lineno: 777. 属性を、次に実行される行に変更してセット
     します。 *note pdb: 94. デバッガにはこの新機能の恩恵を受けて ‘jump’
     コマンドが追加されています。 (Implemented by Richie Hindle.)


File: python.info,  Node: Python 2 3 への移植,  Next: 謝辞<5>,  Prev: その他の変更と修正<2>,  Up: What's New in Python 2 3

1.19.21 Python 2.3 への移植
---------------------------

このセクションでは前述の変更により必要となるかもしれないコードの変更を列
挙します:

   * *note yield: 99b. は今では常にキーワードです。変数名として使ってい
     たならば、別の名前を選ぶ必要があります。

   * 文字列 'X' と 'Y' について、 ‘X in Y’ は 'X' が一文字以上の場合でも
     動作するようになりました。

   * *note int(): 238. 型コンストラクタは、文字列や浮動小数点数を整数に
     収める際、それがとても大き場合に *note OverflowError: 84e. を投げる
     のではなく長整数を返すようになっています。

   * 8 ビット文字を含んだ Unicode 文字列をソースコードに埋め込む場合、フ
     ァイルのエンコーディング (UTF-8, Latin-1, あるいはほか何か) を、フ
     ァイルの先頭のコメントに宣言しなければなりません。 *note PEP 263;
     ソースコードのエンコーディング: 142d. を参照してください。

   * ‘_tkinter’ を介した Tcl メソッド呼び出しは今では文字列だけを返すの
     ではありません。代わりに Tcl は対応する Python の等価なオブジェクト
     に変換されたオブジェクトを返します。Python に等価なものがなければ
     ‘_tkinter.Tcl_Obj’ で包んで返します。

   * ‘0xffffffff’ のような大きな値の 8 進、16 進リテラルで *note
     FutureWarning: 3ee. が発行されます。2.3 ではこれは 32 ビットの値に
     格納されて結果は負の値になりますが、Python 2.4 ではこれは正の長整数
     になります。

     この警告の修正をする方法が少しだけあります。本当に正の値が欲しいの
     であれば ‘L’ をリテラルの最後に付けて下さい。32 ビット分だけの下位
     ビットセットで 32 ビット整数を取り出したいのであれば、また、 ‘~(1
     << 31)’ のような式を使ってきたのであれば、おそらく全ビットをセット
     することから始めて上位ビットをクリアするのが最も簡明です。例えば最
     上位ビット (ビット 31) を単にクリアするには ‘0xffffffffL
     &~(1L<<31)’ と書けます。(--訳注: 2 点。Python 3 サポートを検討する
     ならば ‘L’ は付けないように。2.4 以降は警告もなしに長整数になります
     し。もう一点はこのパラグラフ全体について。根本的に警告への対処の話
     をしてるようで後半はほとんど本質でない話をしているので意味不明な文
     章になっています。本当に 2.3 を使わなければならないのでない限り、こ
     の文章を真面目に理解しようとしなくとも良いと思います(本質的な措置は
     ‘L’ を付けることしかない、2.3 では)。--)

   * ‘__debug__’ に代入することでアサーションを無効にすることは出来なく
     なりました。

   * Distutils の ‘setup()’ 関数に 'depends' のような色々な新しいキーワ
     ード引数が追加されています。Distutils の古いバージョンでは未知のキ
     ーワードを渡すと処理を中断してしまいます。新旧で動作させなければな
     らないのであれば、 ‘setup.py’ 内で ‘get_distutil_options()’ 関数の
     有無をチェックし、それらをサポートするバージョンの Distutils でのみ
     新しいキーワード引数を使うようにしてください:

          from distutils import core

          kw = {'sources': 'foo.c', ...}
          if hasattr(core, 'get_distutil_options'):
              kw['depends'] = ['foo.h']
          ext = Extension(**kw)

   * ‘None’ を変数名に使うと *note SyntaxWarning: 432. 警告を出すように
     なっています。

   * Python と一緒に含まれるモジュールで定義される拡張型の名前にモジュー
     ル名と ‘'.'’ が型名の頭に付くようになっています。


File: python.info,  Node: 謝辞<5>,  Prev: Python 2 3 への移植,  Up: What's New in Python 2 3

1.19.22 謝辞
------------

著者は提案の申し出や修正、様々なこの記事の草稿の助けをしてくれた以下の人
々に感謝します: Jeff Bauer, Simon Brunning, Brett Cannon, Michael
Chermside, Andrew Dalke, Scott David Daniels, Fred L. Drake, Jr., David
Fraser, Kelly Gerber, Raymond Hettinger, Michael Hudson, Chris Lambert,
Detlef Lannert, Martin von Löwis, Andrew MacIntyre, Lalo Martins, Chad
Netzer, Gustavo Niemeyer, Neal Norwitz, Hans Nowak, Chris Reedy,
Francesco Ricciardi, Vinay Sajip, Neil Schemenauer, Roman Suzi, Jason
Tishler, Just van Rossum.


File: python.info,  Node: What's New in Python 2 2,  Next: What's New in Python 2 1,  Prev: What's New in Python 2 3,  Up: What's New in Python

1.20 What's New in Python 2.2
=============================


著者: A.M. Kuchling

* Menu:

* はじめに::
* PEP 252 と PEP 253; 型とクラスについての変更: PEP 252 と PEP 253 型とクラスについての変更.
* PEP 234; イテレータ: PEP 234 イテレータ.
* PEP 255; 単純なジェネレータ: PEP 255 単純なジェネレータ<2>.
* PEP 237; 長整数と整数を一体化していく: PEP 237 長整数と整数を一体化していく<2>.
* PEP 238; 除算演算子を変更していく: PEP 238 除算演算子を変更していく.
* Unicode の変更::
* PEP 227; 入れ子状のスコープ: PEP 227 入れ子状のスコープ.
* 新しいモジュールと改良されたモジュール: 新しいモジュールと改良されたモジュール<3>.
* インタプリタの変更と修正::
* その他の変更と修正: その他の変更と修正<3>.
* 謝辞: 謝辞<6>.


File: python.info,  Node: はじめに,  Next: PEP 252 と PEP 253 型とクラスについての変更,  Up: What's New in Python 2 2

1.20.1 はじめに
---------------

この文書は 2002 年 10 月 14 日にリリースされた Python 2.2.2 の新機能につ
いて解説します。Python 2.2.2 は 2001 年 12 月 21 日にリリースされた
Python 2.2 のバグフィックスリリースです。

Python 2.2 は「クリーンアップリリース」と考えることが出来ます。ジェネレ
ータやイテレータのように、完全に書き直されたいくつかの機能があります。ほ
とんどのその変更は著しくて以前とはかけ離れたものとなりましたが、これは言
語設計の不品行と暗黒面を綺麗に掃除することを目的としています。

このドキュメントは個々の新機能の完全な詳細を提供するのではなくて、簡易な
概要を提供することを目的にしています。完全な詳細が知りたければ、Python ラ
イブラリリファレンス(1) 、Python リファレンスマニュアル(2) のような
Python 2.2 のドキュメントを参照すべきです。設計と実装の根拠を理解したい
場合は、新機能に関する PEP を参照してください。

   ---------- Footnotes ----------

   (1) https://docs.python.org/2.2/lib/lib.html

   (2) https://docs.python.org/2.2/ref/ref.html


File: python.info,  Node: PEP 252 と PEP 253 型とクラスについての変更,  Next: PEP 234 イテレータ,  Prev: はじめに,  Up: What's New in Python 2 2

1.20.2 PEP 252 と PEP 253: 型とクラスについての変更
---------------------------------------------------

最大にして広範に影響が及ぶ Python 2.2 の変更は、 オブジェクトとクラスの
Python モデルについてのものです。変更は後方互換であるはずなので、あなた
のコードは変更なしで動きそうです。ですがその変更は、いくつかの素晴らしい
能力を発揮させます。この、本記事中において最も長くて複雑なセクションにつ
いて始める前に、変更の概要を提供し、いくつかの所感を提示しておこうと思い
ます。

A long time ago I wrote a web page listing flaws in Python's design.
One of the most significant flaws was that it's impossible to subclass
Python types implemented in C. In particular, it's not possible to
subclass built-in types, so you can't just subclass, say, lists in order
to add a single useful method to them.  The ‘UserList’ module provides a
class that supports all of the methods of lists and that can be
subclassed further, but there's lots of C code that expects a regular
Python list and won't accept a *note UserList: 148c. instance.

Python 2.2 はこれを修正し、また、その過程においていくつかの心躍る新機能
を追加しました。簡単に要約します:

   * あなたはリストのような組み込み型をサブクラス化出来ます。整数でさえ
     出来ます。そしてあなたのサブクラスは、元の型を要求している全ての場
     所で動作します。

   * 以前より使えたインスタンスメソッド加え、静的メソッド、クラスメソッ
     ドを今や定義出来ます。

   * It's also possible to automatically call methods on accessing or
     setting an instance attribute by using a new mechanism called
     'properties'.  Many uses of *note __getattr__(): 49f. can be
     rewritten to use properties instead, making the resulting code
     simpler and faster.  As a small side benefit, attributes can now
     have docstrings, too.

   * 'slots' を使って、インスタンスの適正な属性を特定の集合に制限できま
     す。これはタイプミスに対する安全装置にも出来ますし、将来のバージョ
     ンの Python では今よりも最適化される可能性があります。

一部のユーザはこれら全ての変更に懸念を表明しました。そうだね、彼らは言い
ます、新しい機能はかっこいいし昔の Python では出来なかった全ての芸当の役
に立つさ、だけどさ、それって言語をより複雑にするよなぁ。一部の人々はずっ
と常に、Python が単純さを保つことを提言してきました。そして彼らはその単
純さが失われると感じたのです。

個人的に私は、それらは心配には及ばない、と思っています。多くのそれら新機
能は随分と秘伝的で、あなたはそれらに気付く必要もないままたくさんの
Python コードを書けます。単純なクラスを書くことはかつてよりも難しいとい
うことはなく、実際にそれを必要としない限りは、秘伝をわざわざ学習すること
も教育することも必要ありません。以前ならば C 言語からでしか可能でなかっ
たようなある種の複雑なタスクは、いまやピュアな python から出来て、私には
何もかもが良い方向に思えます。

この記事では全てのショーケースの品を陳列しようとはしませんし、将来の拡張
のために必要な小さな変更は説明しません。代わりにこのセクションではおおま
かなアウトラインを描きます。Python 2.2 の新しいオブジェクトモデルの追加
的な情報源については、 *note 関連リンク: 148d. を参照してください。

* Menu:

* 旧と新クラス::
* デスクリプタ::
* 多重継承; ダイヤモンドルール: 多重継承 ダイヤモンドルール.
* 属性アクセス::
* 関連リンク::


File: python.info,  Node: 旧と新クラス,  Next: デスクリプタ,  Up: PEP 252 と PEP 253 型とクラスについての変更

1.20.2.1 旧と新クラス
.....................

まず、 Python 2.2 は本当に 2 種類のクラスを持っているのだ、ということを
知る必要があります: クラシック、あるいは旧スタイルクラス、と、新スタイル
クラスです。旧スタイルクラスのモデルは、以前のバージョンのクラスモデルと
完全に同じものです。このセクションに記述する全ての新機能は、全て新スタイ
ルクラスだけに適用されるものです。この逸脱が未来永劫続くことは望まれてい
ません; 最終的には旧スタイルクラスは撤廃されます。たぶん Python 3.0 で。

では、新スタイルクラスは、どうやって定義すればいいのでしょう?  答えは、
既存の新スタイルクラスをサブクラス化することです。たとえば整数、リスト、
辞書やファイルでさえも、ほとんどの Python 組み込み型は今では新スタイルク
ラスです。 *note object: a5a. という名の新スタイルクラスは全ての組み込み
型の基底クラスとして既に追加されていて、相応しい組み込み型がなければ単に
*note object: a5a. をサブクラス化すれば良いです:

     class C(object):
         def __init__ (self):
             ...
         ...

This means that *note class: 12a5. statements that don't have any base
classes are always classic classes in Python 2.2.  (Actually you can
also change this by setting a module-level variable named
‘__metaclass__’ -- see PEP 253(1) for the details -- but it's easier to
just subclass *note object: a5a.)

組み込み型(ビルトイン型)のための型オブジェクトは、クレバーなトリックを使
って名付けられた組み込み(ビルトイン)として利用可能です。Python は既に組
み込み関数 *note int(): 238, *note float(): 2ce, *note str(): 418. を持
っていました。2.2 にはその関数はなくなり、型オブジェクトは呼び出されると
ファクトリとして振舞います:

     >>> int
     <type 'int'>
     >>> int('123')
     123

To make the set of types complete, new type objects such as *note
dict(): 237. and ‘file()’ have been added.  Here's a more interesting
example, adding a ‘lock()’ method to file objects:

     class LockableFile(file):
         def lock (self, operation, length=0, start=0, whence=0):
             import fcntl
             return fcntl.lockf(self.fileno(), operation,
                                length, start, whence)

The now-obsolete ‘posixfile’ module contained a class that emulated all
of a file object's methods and also added a ‘lock()’ method, but this
class couldn't be passed to internal functions that expected a built-in
file, something which is possible with our new ‘LockableFile’.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0253/


File: python.info,  Node: デスクリプタ,  Next: 多重継承 ダイヤモンドルール,  Prev: 旧と新クラス,  Up: PEP 252 と PEP 253 型とクラスについての変更

1.20.2.2 デスクリプタ
.....................

In previous versions of Python, there was no consistent way to discover
what attributes and methods were supported by an object.  There were
some informal conventions, such as defining ‘__members__’ and
‘__methods__’ attributes that were lists of names, but often the author
of an extension type or a class wouldn't bother to define them.  You
could fall back on inspecting the *note __dict__: 526. of an object, but
when class inheritance or an arbitrary ‘__getattr__()’ hook were in use
this could still be inaccurate.

その新しいクラスモデルの根底にあったひとつの大きな着想は、 'descriptors'
を使ったオブジェクトの属性を記述する API を正式なものにしてしまうことで
す。デスクリプタは属性の値を記述し、それがメソッドなのかフィールドなのか
を伝えます。デスククリプタ API によって、静的メソッドとクラスメソッドが
、より風変わりなコンストラクタとともに可能となりました。

属性デスクリプタはクラスオブジェクト内部に棲息するオブジェクトで、それ自
身のいくつかの属性を持っています:

   * *note __name__: 103b. は属性の名前です。

   * *note __doc__: 8f6. is the attribute's docstring.

   * ‘__get__(object)’ は 'object' から属性値を取り出すメソッドです。

   * ‘__set__(object, value)’ は 'object' の属性に 'value' をセットする
     メソッドです。

   * ‘__delete__(object, value)’ は 'object' の 'value' 属性を削除します
     。

例えば、あなたが ‘obj.x’ と書いたときに Python が実際に行うことは以下で
す:

     descriptor = obj.__class__.x
     descriptor.__get__(obj)

For methods, *note descriptor.__get__: 1490. returns a temporary object
that's callable, and wraps up the instance and the method to be called
on it.  This is also why static methods and class methods are now
possible; they have descriptors that wrap up just the method, or the
method and the class.  As a brief explanation of these new kinds of
methods, static methods aren't passed the instance, and therefore
resemble regular functions.  Class methods are passed the class of the
object, but not the object itself.  Static and class methods are defined
like this:

     class C(object):
         def f(arg1, arg2):
             ...
         f = staticmethod(f)

         def g(cls, arg1, arg2):
             ...
         g = classmethod(g)

The *note staticmethod(): 3ef. function takes the function ‘f()’, and
returns it wrapped up in a descriptor so it can be stored in the class
object.  You might expect there to be special syntax for creating such
methods (‘def static f’, ‘defstatic f()’, or something like that) but no
such syntax has been defined yet; that's been left for future versions
of Python.

スロットとプロパティのような新機能がさらに新種のデスクリプタとして実装さ
れ、また、何か奇抜なデスクリプタクラスを書くことは難しくはありません。例
えば、Eiffel 言語スタイルのメソッドに対する事前条件・事後条件を書くこと
を可能とするデスクリプタクラスを書けるかもしれません。それを使ったクラス
はきっとこう定義出来るでしょう:

     from eiffel import eiffelmethod

     class C(object):
         def f(self, arg1, arg2):
             # The actual function
             ...
         def pre_f(self):
             # Check preconditions
             ...
         def post_f(self):
             # Check postconditions
             ...

         f = eiffelmethod(f, pre_f, post_f)

Note that a person using the new ‘eiffelmethod()’ doesn't have to
understand anything about descriptors.  This is why I think the new
features don't increase the basic complexity of the language.  There
will be a few wizards who need to know about it in order to write
‘eiffelmethod()’ or the ZODB or whatever, but most users will just write
code on top of the resulting libraries and ignore the implementation
details.


File: python.info,  Node: 多重継承 ダイヤモンドルール,  Next: 属性アクセス,  Prev: デスクリプタ,  Up: PEP 252 と PEP 253 型とクラスについての変更

1.20.2.3 多重継承: ダイヤモンドルール
.....................................

多重継承は名前解決のルールの変更を経てより有用なものになっています。クラ
スのこのようなセットを考えてみましょう (ダイアグラムは Guido van Rossum
による PEP 253(1) より):

           class A:
             ^ ^  def save(self): ...
            /   \
           /     \
          /       \
         /         \
     class B     class C:
         ^         ^  def save(self): ...
          \       /
           \     /
            \   /
             \ /
           class D

The lookup rule for classic classes is simple but not very smart; the
base classes are searched depth-first, going from left to right.  A
reference to ‘D.save()’ will search the classes ‘D’, ‘B’, and then ‘A’,
where ‘save()’ would be found and returned.  ‘C.save()’ would never be
found at all.  This is bad, because if ‘C’'s ‘save()’ method is saving
some internal state specific to ‘C’, not calling it will result in that
state never getting saved.

新スタイルクラスはちょっと説明するのに複雑な違ったアルゴリズムを使い、こ
の状況では正しいことをします(Python 2.3 ではこのアルゴリズムはさらに変更
されて、ほとんどのケースで同じ結果となり、本当に複雑な継承グラフの場合に
もっと有用な結果となりました)。

  1. List all the base classes, following the classic lookup rule and
     include a class multiple times if it's visited repeatedly.  In the
     above example, the list of visited classes is [‘D’, ‘B’, ‘A’, ‘C’,
     ‘A’].

  2. Scan the list for duplicated classes.  If any are found, remove all
     but one occurrence, leaving the 'last' one in the list.  In the
     above example, the list becomes [‘D’, ‘B’, ‘C’, ‘A’] after dropping
     duplicates.

Following this rule, referring to ‘D.save()’ will return ‘C.save()’,
which is the behaviour we're after.  This lookup rule is the same as the
one followed by Common Lisp.  A new built-in function, *note super():
4a8, provides a way to get at a class's superclasses without having to
reimplement Python's algorithm.  The most commonly used form will be
‘super(class, obj)’, which returns a bound superclass object (not the
actual class object).  This form will be used in methods to call a
method in the superclass; for example, ‘D’'s ‘save()’ method would look
like this:

     class D (B,C):
         def save (self):
             # Call superclass .save()
             super(D, self).save()
             # Save D's private information here
             ...

*note super(): 4a8. は ‘super(class)’ や ‘super(class1, class2)’ のよう
に呼ばれれば非束縛のスーパークラスオブジェクトも返せますが、これはあまり
役には立たないでしょう。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0253/


File: python.info,  Node: 属性アクセス,  Next: 関連リンク,  Prev: 多重継承 ダイヤモンドルール,  Up: PEP 252 と PEP 253 型とクラスについての変更

1.20.2.4 属性アクセス
.....................

A fair number of sophisticated Python classes define hooks for attribute
access using *note __getattr__(): 49f.; most commonly this is done for
convenience, to make code more readable by automatically mapping an
attribute access such as ‘obj.parent’ into a method call such as
‘obj.get_parent’.  Python 2.2 adds some new ways of controlling
attribute access.

まず、 ‘__getattr__(attr_name)’ は新スタイルクラスにおいてもなおサポート
され、変更はありません。これまで同様に、 ‘obj.foo’ アクセスが試みられて
、インスタンスの辞書に ‘foo’ 名の属性が見つからなければ呼び出されます。

New-style classes also support a new method,
‘__getattribute__(attr_name)’.  The difference between the two methods
is that *note __getattribute__(): ba0. is 'always' called whenever any
attribute is accessed, while the old *note __getattr__(): 49f. is only
called if ‘foo’ isn't found in the instance's dictionary.

However, Python 2.2's support for 'properties' will often be a simpler
way to trap attribute references.  Writing a ‘__getattr__()’ method is
complicated because to avoid recursion you can't use regular attribute
accesses inside them, and instead have to mess around with the contents
of *note __dict__: 526.  *note __getattr__(): 49f. methods also end up
being called by Python when it checks for other methods such as *note
__repr__(): 5e8. or ‘__coerce__()’, and so have to be written with this
in mind.  Finally, calling a function on every attribute access results
in a sizable performance loss.

*note property: 179. is a new built-in type that packages up three
functions that get, set, or delete an attribute, and a docstring.  For
example, if you want to define a ‘size’ attribute that's computed, but
also settable, you could write:

     class C(object):
         def get_size (self):
             result = ... computation ...
             return result
         def set_size (self, size):
             ... compute something based on the size
             and set internal state appropriately ...

         # Define a property.  The 'delete this attribute'
         # method is defined as None, so the attribute
         # can't be deleted.
         size = property(get_size, set_size,
                         None,
                         "Storage size of this instance")

That is certainly clearer and easier to write than a pair of
‘__getattr__()’/‘__setattr__()’ methods that check for the ‘size’
attribute and handle it specially while retrieving all other attributes
from the instance's *note __dict__: 526.  Accesses to ‘size’ are also
the only ones which have to perform the work of calling a function, so
references to other attributes run at their usual speed.

もう一つ最後、新しいクラス属性 *note __slots__: 1493. を使うと、オブジェ
クトで参照出来る属性リストを制約することが出来ます。Python オブジェクト
は普通非常に動的で、どんなときにもインスタンスに対して単に
‘obj.new_attr=1’ とするだけで新しい属性を定義出来ます。新スタイルクラス
は *note __slots__: 1493. という名前のクラス属性を定義出来、これにより適
正な属性名集合を特定の集合に制限出来ます。実例をみるのが早いです:

     >>> class C(object):
     ...     __slots__ = ('template', 'name')
     ...
     >>> obj = C()
     >>> print obj.template
     None
     >>> obj.template = 'Test'
     >>> print obj.template
     Test
     >>> obj.newattr = None
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     AttributeError: 'C' object has no attribute 'newattr'

*note __slots__: 1493. リストに含めなかった属性への代入を試みて *note
AttributeError: 326. になっていることに注目してください。


File: python.info,  Node: 関連リンク,  Prev: 属性アクセス,  Up: PEP 252 と PEP 253 型とクラスについての変更

1.20.2.5 関連リンク
...................

このセクションは新機能について、あなたがプログラミングを始める説明として
は十分な簡単な概要だけ示しました。ですが、多くの詳細は、単純化したり無視
しています。もっと完全な光景を眺めたければ、どこに行けば良いでしょうか?

The *note デスクリプタ ガイド: 1495. is a lengthy tutorial introduction
to the descriptor features, written by Guido van Rossum.  If my
description has whetted your appetite, go read this tutorial next,
because it goes into much more detail about the new features while still
remaining quite easy to read.

次です。2 つの関連する PEP、 PEP 252(1), PEP 253(2) があります。 PEP
252(3) は "型をもっとクラスに似せる(Making Types Look More Like
Classes)" というタイトルで、デスクリプタ API についてカバーしています。
PEP 253(4) は "組み込み型のサブタイプ化(Subtyping Built-in Types)" とい
うタイトルで、組み込み型のサブタイプを可能とするための型オブジェクトの変
更について記述しています。 PEP 253(5) は 252 よりも複雑な PEP で、型とメ
タ型で必要な説明のいくつかのポイントでは、あなたの脳味噌は爆発するかもし
れないです。どちらの PEP も、著・実装ともに、Zope Corp.  チームの残りの
メンバーからのかなりの支援を受けて、Guido van Rossum によって書かれまし
た。

最後ですが、究極の権威があります: ソースコードです。型ハンドリングのほと
んどの機構は ‘Objects/typeobject.c’ 内にあります。ただしこれに頼るのは、
python-list や python-dev へ質問を投稿することを含むほかの全ての手段を使
い果たしたのちの最後の手段にしてください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0252/

   (2) https://peps.python.org/pep-0253/

   (3) https://peps.python.org/pep-0252/

   (4) https://peps.python.org/pep-0253/

   (5) https://peps.python.org/pep-0253/


File: python.info,  Node: PEP 234 イテレータ,  Next: PEP 255 単純なジェネレータ<2>,  Prev: PEP 252 と PEP 253 型とクラスについての変更,  Up: What's New in Python 2 2

1.20.3 PEP 234: イテレータ
--------------------------

2.2 でのもう一つの重要な追加は、C と Python レベル両方に対するイテレーシ
ョンインターフェイスです。オブジェクトが呼び出し元からどのように反復され
るのか定義出来ます。

In Python versions up to 2.1, the usual way to make ‘for item in obj’
work is to define a *note __getitem__(): 264. method that looks
something like this:

     def __getitem__(self, index):
         return <next item>

*note __getitem__(): 264. is more properly used to define an indexing
operation on an object so that you can write ‘obj[5]’ to retrieve the
sixth element.  It's a bit misleading when you're using this only to
support *note for: 2c9. loops.  Consider some file-like object that
wants to be looped over; the 'index' parameter is essentially
meaningless, as the class probably assumes that a series of *note
__getitem__(): 264. calls will be made with 'index' incrementing by one
each time.  In other words, the presence of the *note __getitem__():
264. method doesn't mean that using ‘file[5]’ to randomly access the
sixth element will work, though it really should.

In Python 2.2, iteration can be implemented separately, and *note
__getitem__(): 264. methods can be limited to classes that really do
support random access.  The basic idea of iterators is simple.  A new
built-in function, ‘iter(obj)’ or ‘iter(C, sentinel)’, is used to get an
iterator.  ‘iter(obj)’ returns an iterator for the object 'obj', while
‘iter(C, sentinel)’ returns an iterator that will invoke the callable
object 'C' until it returns 'sentinel' to signal that the iterator is
done.

Python classes can define an ‘__iter__()’ method, which should create
and return a new iterator for the object; if the object is its own
iterator, this method can just return ‘self’.  In particular, iterators
will usually be their own iterators.  Extension types implemented in C
can implement a *note tp_iter: 1497. function in order to return an
iterator, and extension types that want to behave as iterators can
define a *note tp_iternext: 1498. function.

それでは、結局のところイテレータは実際どんなでしょうか?  これに必要なメ
ソッドは一つ、 *note next(): 7a3. です (--訳注: Python 3 で ‘__next__’ に
変更されています--)。これは引数を取らず、次の値を返します。返すべき値が
なくなったら、 *note next(): 7a3. 呼び出しは *note StopIteration: bc8. 例
外を送出しなければなりません:

     >>> L = [1,2,3]
     >>> i = iter(L)
     >>> print i
     <iterator object at 0x8116870>
     >>> i.next()
     1
     >>> i.next()
     2
     >>> i.next()
     3
     >>> i.next()
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     StopIteration
     >>>

In 2.2, Python's *note for: 2c9. statement no longer expects a sequence;
it expects something for which *note iter(): 7a2. will return an
iterator.  For backward compatibility and convenience, an iterator is
automatically constructed for sequences that don't implement
‘__iter__()’ or a *note tp_iter: 1497. slot, so ‘for i in [1,2,3]’ will
still work.  Wherever the Python interpreter loops over a sequence, it's
been changed to use the iterator protocol.  This means you can do things
like this:

     >>> L = [1,2,3]
     >>> i = iter(L)
     >>> a,b,c = i
     >>> a,b,c
     (1, 2, 3)

いくつかの Python の基礎型には既にイテレータのサポートが追加されています
。辞書に対して *note iter(): 7a2. を呼び出すと、キーの反復をするイテレー
タが返ります:

     >>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
     ...      'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
     >>> for key in m: print key, m[key]
     ...
     Mar 3
     Feb 2
     Aug 8
     Sep 9
     May 5
     Jun 6
     Jul 7
     Jan 1
     Apr 4
     Nov 11
     Dec 12
     Oct 10

That's just the default behaviour.  If you want to iterate over keys,
values, or key/value pairs, you can explicitly call the ‘iterkeys()’,
‘itervalues()’, or ‘iteritems()’ methods to get an appropriate iterator.
In a minor related change, the *note in: 2cb. operator now works on
dictionaries, so ‘key in dict’ is now equivalent to ‘dict.has_key(key)’.

ファイルもイテレータを提供しています。これはファイルに読むべき行がなくな
るまで *note readline(): a8. を呼び出すもので、つまりファイルを行ごとに
読み出すのにこのように書けるわけです:

     for line in file:
         # do something for each line
         ...

イテレータは前進しか出来ないことに注意してください; 前の要素を取り出す手
段もなければ、イテレータをリセットしたりコピーしたりといったことも出来ま
せん。イテレータオブジェクトにそのような追加の能力を持たせることは出来ま
すが、イテレータプロトコルが規定するのは *note next(): 7a3. メソッドのみ
です。

参考
....

PEP 234(1): イテレータ

     著: Ka-Ping Yee と GvR (Guido van Rossum); 実装: Python Labs クルー
     , 主に GvR と Tim Peters.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0234/


File: python.info,  Node: PEP 255 単純なジェネレータ<2>,  Next: PEP 237 長整数と整数を一体化していく<2>,  Prev: PEP 234 イテレータ,  Up: What's New in Python 2 2

1.20.4 PEP 255: 単純なジェネレータ
----------------------------------

ジェネレータはもう一つの新機能で、これはイテレータの導入と連携するもので
す。

Python や C の標準的な関数コールについては、よくご存じに違いありません。
関数を呼ぶと、ローカル変数を作るプライベートな名前空間ができますね。その
関数が *note return: 99c. 文まで来ると、ローカル変数が破壊されてから、返
り値が呼び出し元に返ります。次に同じ関数をもう一度呼ぶと、新しいプライベ
ート名前空間に新規のローカル変数が作られるのです。しかし、関数を出るとき
にローカル変数を捨てなければどうなるでしょうか。その出ていったところから
関数を続行できたとしたら、どうでしょう。これこそジェネレータが提供する機
能です; すなわち、ジェネレータは続行できる関数と考えることができます。

ジェネレータ関数の最も単純な例です:

     def generate_ints(N):
         for i in range(N):
             yield i

新しいキーワード *note yield: 99b. がジェネレータのために導入されました
。 ‘yield’ ステートメントを含むどんな関数もジェネレータ関数です; Python
バイトコードコンパイラはこれを検知し、関数が特別に扱われるように翻訳しま
す。新たなキーワードの導入なので、ジェネレータを使えるようにするには
‘from __future__ import generators’ ステートメントをモジュールソースコー
ドの先頭付近に含めなければなりません。Python 2.3 ではこのステートメント
は不要になります。(--訳注: Python 2.5 の PEP 342 も参照して下さい。この
2.2 で導入時点の ‘yield’ はステートメントではなく式に変更されています。
--)

ジェネレータ関数を呼び出すと、単一の値の代わりにイテレータプロトコルに対
応したオブジェクトを返します。上の例で ‘yield’ を実行したとき、ジェネレ
ータは ‘return’ 文のようにして ‘i’ の値を生成します。 ‘yield’ と
‘return’ 文の大きな違いは、 ‘yield’ に到達した段階でジェネレータの実行状
態が一時停止になって、ローカル変数が保存される点です。次回そのジェネレー
タの ‘.next()’ メソッドを呼ぶと、 ‘yield’ の直後から関数が実行を再開しま
す。(複雑な理由により、 ‘yield’ は ‘try’...*note finally: 997. の ‘try’
ブロック内に含めることは許されていません; PEP 255(1) に ‘yield’ と例外の
相互作用についての詳細説明がありますので参照して下さい。) -- (--訳注:
Python 2.5 の PEP 342 で *note try: 6b4...*note finally: 997. 内に置けな
いという制約はなくなりました。また、 *note try: 6b4...*note finally:
997. の *note try: 6b4. 、とここであえて特定しているのは、同じく 2.5 の
PEP 341 によって try/except/finally の一体化されるまでは、 ‘finally’ の
‘try’ と ‘except’ の ‘try’ が別物だったからです。--)

上記の ‘generate_ints()’ ジェネレータはこんな具合に使います:

     >>> gen = generate_ints(3)
     >>> gen
     <generator object at 0x8117f90>
     >>> gen.next()
     0
     >>> gen.next()
     1
     >>> gen.next()
     2
     >>> gen.next()
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
       File "<stdin>", line 2, in generate_ints
     StopIteration

同じく ‘for i in generate_ints(5)’ や ‘a,b,c = generate_ints(3)’ といっ
た書き方もできます。

ジェネレータ関数内で *note return: 99c. 文は、引数を付けずに、処理の終わ
りを知らせるためにだけ使うことができます; ‘return’ を実行したあとは、も
うそのジェネレータが値を返すことはできません。ジェネレータ関数の中では、
‘return 5’ などと値を付けた ‘return’ は構文エラーです。ジェネレータの出
力が終わったことを示すには、ほかにも、手動で *note StopIteration: bc8. を
投げてもいいですし、関数の最後まで実行するだけでも同じことになります。
(--訳注: Python 2.7 まではジェネレータ内での戻り値のある ‘return 5’ は構
文エラーになりますが、少なくとも Python 3.4 で構文エラーとはなりません。
単に無視されます。リファレンスに言及されていない振舞いなので、何かの事故
かもしれません。いずれにせよジェネレータ内では Python 3 でも ‘return’ で
値は戻せません。--)

自分でクラスを書いて、ジェネレータで言うところのローカル変数をインスタン
ス変数として全部保管しておけば、同じ効果を得ることは可能です。たとえば整
数のリストを返すのは、 ‘self.count’ を 0 にして、 *note next(): 7a3. メ
ソッドが ‘self.count’ をインクリメントして返すようにすればできます。しか
しながら、ある程度複雑なジェネレータになってくると、同じことをするクラス
を書くのは格段にややこしいことになります。 ‘Lib/test/test_generators.py’
にはもっと面白い例がたくさん含まれています。一番単純な一つは、ジェネレー
タを再帰的に使ってツリーを順繰りに横断する実装をするこれです (--訳注: ジ
ェネレータは現在の最新 3.5 までの間に 2 度大きな機能強化が行われているの
ですが、一つが 2.5 での PEP 342 でこれは yield 「に」値を戻せるようにす
るものです。もう一つが 3.3 での PEP 380 で、これはサブジェネレータへの委
譲 ‘yield from <subgen>’ の追加でした。ですのでこの 3.3 からの ‘yield
from’ を使うと下記例はもっとスッキリ書けます。--):

     # A recursive generator that generates Tree leaves in in-order.
     def inorder(t):
         if t:
             for x in inorder(t.left):
                 yield x
             yield t.label
             for x in inorder(t.right):
                 yield x

ほかにも ‘Lib/test/test_generators.py’ には、N-Queens 問題 (N×N コマのチ
ェス盤に、互いに攻撃できないような配置で N 個のクイーンを置く) やナイト
・ツアー (N×N 盤の全コマをナイトが一度ずつ通るような経路を探す) の解を出
す例が入っています。

ジェネレータの発想はほかのプログラミング言語、特に Icon
(‘https://www2.cs.arizona.edu/icon/’) から着想しています。Icon ではジェ
ネレータが言語の中枢になっています。Icon では、あらゆる式と関数がジェネ
レータのように振舞います。
‘https://www2.cs.arizona.edu/icon/docs/ipd266.htm’ の "Icon プログラミン
グ言語の概要" の一つの例が、これがどのようなものであるのかを教えてくれま
す:

     sentence := "Store it in the neighboring harbor"
     if (i := find("or", sentence)) > 5 then write(i)

Icon では ‘find()’ 関数は部分文字列 "or" が見つかる位置 3, 23, 33 を返し
ます。 *note if: 2ca. 文内では ‘i’ には最初 3 が代入されますが、これは 3
より小さいので比較は失敗し、Icon は次の値 23 を取り出します。 23 は 5 よ
り大きいので比較は成功し、コードは 23 をスクリーンに表示します。

Python では Icon がそうするほどにはジェネレータを中心的概念に置きません
。ジェネレータは Python 言語中核の新たな一面ではありますが、それらを学ぶ
のも使うのも誰しも行うべきだというものでもなく、そしてこれで解決できない
何か問題があれば、忘れてしまっても良いものです。Icon と比較した特筆すべ
き Python インターフェイスの機能はジェネレータの状態が具象オブジェクト
(イテレータ) で表現されることであり、それは他の関数に渡せますし、データ
構造に記憶しておくことも出来ます。(--訳注: ジェネレータについてかなり控
えめなのは、この時点で著者は将来の拡張を既に見据えていたから?  かもしれ
ませんね。PEP 342 と PEP 380 により今やジェネレータはこの頃より遥かに高
機能になっており、今ではきっと「こんなものなくても困らない」なんて
Python 使いはいないでしょう。--)

参考
....

PEP 255(2) - 単純なジェネレータ

     Neil Schemenauer, Tim Peters, Magnus Lie Hetland により著されました
     。実装のほとんどは Neil Schemenauer と Tim Peters により行われ、
     Python Labs クルーにより他の修正が行われました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0255/

   (2) https://peps.python.org/pep-0255/


File: python.info,  Node: PEP 237 長整数と整数を一体化していく<2>,  Next: PEP 238 除算演算子を変更していく,  Prev: PEP 255 単純なジェネレータ<2>,  Up: What's New in Python 2 2

1.20.5 PEP 237: 長整数と整数を一体化していく
--------------------------------------------

In recent versions, the distinction between regular integers, which are
32-bit values on most machines, and long integers, which can be of
arbitrary size, was becoming an annoyance.  For example, on platforms
that support files larger than ‘2**32’ bytes, the ‘tell()’ method of
file objects has to return a long integer.  However, there were various
bits of Python that expected plain integers and would raise an error if
a long integer was provided instead.  For example, in Python 1.5, only
regular integers could be used as a slice index, and ‘'abc'[1L:]’ would
raise a *note TypeError: 502. exception with the message 'slice index
must be int'.

Python 2.2 は必要に応じて short 整数を長整数に値をシフトします。 'L' サ
フィックスは長整数リテラルを示すのにはもはや不要です。今ではコンパイラは
相応しい型を選べます。('L' サフィックスは将来の Python 2.x では非推奨と
なり、Python 2.4 では警告となり、おそらく Python 3.0 では削除されます。
-- 訳注: Python 3 で 'L' が廃止されて、付けると構文エラーになるようにな
ったのは事実です。ですが少なくとも Python 2.7 では ‘-3’ でも ‘-Qwarnall’
でも警告とならないので注意してください。Python 2 系を使っていて Python 3
との互換性を持ちたいならば、 2.2 以降では 'L' は付けるべきではありません
。 -- ) かつて *note OverflowError: 84e. となっていたような多くの演算が
、今ではその結果として長整数を返します。例えば:

     >>> 1234567890123
     1234567890123L
     >>> 2 ** 64
     18446744073709551616L

ほとんどのケースで、今や整数と長整数は同じものとして扱われるでしょう。
*note type(): d16. ビルトインで今でも区別出来ますが、ほとんど必要ないで
しょう (-- 訳注: Python 3 では本当にこの2つの区別がなくなったので、当然
区別出来ません。Python 3 系への移行を考えている Python 2 コードは、両者
の区別に頼らないようにするべきです。 --)。

参考
....

PEP 237(1) - 長整数と整数を一体化していく

     Moshe Zadka と Guido van Rossum 著、実装 (ほぼ) Guido van Rossum.。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0237/


File: python.info,  Node: PEP 238 除算演算子を変更していく,  Next: Unicode の変更,  Prev: PEP 237 長整数と整数を一体化していく<2>,  Up: What's New in Python 2 2

1.20.6 PEP 238: 除算演算子を変更していく
----------------------------------------

Python 2.2 の変更で最も物議を醸すものが、Python 誕生時からずっとそうであ
り続けた古い設計の欠陥、これを修正するための取り組み開始の予兆です。現在
の Python の除算演算子 ‘/’ は 2 つの整数引数に対して C 言語の除算演算子
のように振舞います: 端数部があれば切り捨てて整数を結果として返します。例
えば ‘3/2’ は 1.5 ではなく 1 で、 ‘(-1)/2’ は -0.5 ではなく -1 です。
Python の動的型付けにより演算対象の型がなんなのかを容易には決定できない
くせに 2 つの演算対象の型に依存するので、除算の結果は予想に反したものと
なりうるのです。

(議論の的となるのはこれが '本当の' 設計の欠陥なのかどうかと、果たしてこ
れを修正することで既存のコードを破壊する価値はあるのかどうかです。それは
python-dev での終わりのない議論を巻き起こし、2001 年 7 月には
‘comp.lang.python’ への辛辣な投稿の嵐に突入しました。私はここではどちら
かの側に立って説きつけるつもりはなく、Python 2.2 で何が実現したのかを記
述することだけに専念します。 PEP 238(1) にはその主張と反対意見の要約が書
かれていますので、そちらをお読みください。)

この変更がコードを破壊しうるために、導入は大変ゆっくり少しずつ進められて
いきます。Python 2.2 が移行を始めますが、切り替えは Python 3.0 になるま
で達成させられることはありません。

まず最初に、いくつか PEP 238(2) から用語を借りることにします。 "真の除算
(True division)" とは、プログラマでない人々が一番馴染みのある除算です。
3/2 は 1.5、1/4 は 0.25、などなど。 "切り捨て除算 (Floor division)" は、
整数の被演算子が与えられたときの Python の ‘/’ 演算子が現在やっているこ
とで、結果は真の除算の結果の値の小数点以下を小さくなる方向へ丸めたもので
す。 "クラシック除算 (Classic division)" は現在の ‘/’ の混合した振る舞い
を指します。演算対象が整数同士であれば切り捨て除算の結果となり、一方が浮
動小数点数であれば真の除算の結果となる振る舞いです。

以下が 2.2 で導入される変更です:

   * 新しい演算子 ‘//’ が floor division の演算子です。(いえーい、これっ
     て C++ コメントのシンボルに似てるね、なんてことは私たちは知っていま
     す。) ‘//’ は演算対象の型がなんであれ 'いつでも' floor division を
     実行しますので、 ‘1 // 2’ は 0、 ‘1.0 // 2.0’ も 0.0 です。

     ‘//’ は Python 2.2 でいつでも使えます; ‘__future__’ を使って有効化
     するなんてことは必要ないです。

   * ‘from __future__ import division’ をモジュールに import することで
     、 ‘/’ 演算子が真の除算 (true division) の結果を返すように変更され
     るので、 ‘1/2’ は 0.5 になります。 ‘__future__’ 文なしでは ‘/’ はク
     ラシック除算 (classic division) のままです。 ‘/’ が持つデフォルトの
     意味は Python 3.0 になるまで変更されません。

   * Classes can define methods called *note __truediv__(): 149c. and
     *note __floordiv__(): 149d. to overload the two division operators.
     At the C level, there are also slots in the *note PyNumberMethods:
     13c5. structure so extension types can define the two operators.

   * Python 2.2 は、コードが変更後の除算セマンティクスで動作するかどうか
     をテストするコマンドライン引数をサポートします。 ‘-Q warn’ で
     python を実行すると、除算が二つの整数に適用されている箇所全てで警告
     します。除算の意味変更の影響を受ける箇所の特定と修正に使えるでしょ
     う。デフォルトでは、Python 2.2 は警告なしで単純に classic division
     を実行します; その警告がデフォルトになるのは Python 2.3 からです。

参考
....

PEP 238(3) - 除算演算子を変更していく

     Moshe Zadka と Guido van Rossum 著、実装 Guido van Rossum.。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0238/

   (2) https://peps.python.org/pep-0238/

   (3) https://peps.python.org/pep-0238/


File: python.info,  Node: Unicode の変更,  Next: PEP 227 入れ子状のスコープ,  Prev: PEP 238 除算演算子を変更していく,  Up: What's New in Python 2 2

1.20.7 Unicode の変更
---------------------

Python の Unicode サポートが 2.2 で少し拡張されています。Unicode 文字列
は普通は 16 ビット符号なし整数としての UCS-2 で格納されます。Python 2.2
は内部エンコーディングとして 32 ビット符号なし整数の UCS-4 を使うように
もコンパイル出来ます。これは ‘configure’ スクリプトに
‘--enable-unicode=ucs4’ オプションを与えることで行います。
(‘--disable-unicode’ を与えることで完全に Unicode サポートを無効にするこ
とも出来ます。)

When built to use UCS-4 (a "wide Python"), the interpreter can natively
handle Unicode characters from U+000000 to U+110000, so the range of
legal values for the ‘unichr()’ function is expanded accordingly.  Using
an interpreter compiled to use UCS-2 (a "narrow Python"), values greater
than 65535 will still cause ‘unichr()’ to raise a *note ValueError: 1e3.
exception.  This is all described in PEP 261(1), "Support for 'wide'
Unicode characters"; consult it for further details.

Another change is simpler to explain.  Since their introduction, Unicode
strings have supported an ‘encode()’ method to convert the string to a
selected encoding such as UTF-8 or Latin-1.  A symmetric
‘decode([*encoding*])’ method has been added to 8-bit strings (though
not to Unicode strings) in 2.2.  ‘decode()’ assumes that the string is
in the specified encoding and decodes it, returning whatever is returned
by the codec.

この新たなインターフェイスに相乗りする形で、 Unicode には無関係のタスク
のためのコーデックが追加されました。例えば uu エンコーディング、 MIME の
base64 エンコーディング、 *note zlib: 119. モジュールでの圧縮のためのエ
ンコーディングが追加されています:

     >>> s = """Here is a lengthy piece of redundant, overly verbose,
     ... and repetitive text.
     ... """
     >>> data = s.encode('zlib')
     >>> data
     'x\x9c\r\xc9\xc1\r\x80 \x10\x04\xc0?Ul...'
     >>> data.decode('zlib')
     'Here is a lengthy piece of redundant, overly verbose,\nand repetitive text.\n'
     >>> print s.encode('uu')
     begin 666 <data>
     M2&5R92!I<R!A(&QE;F=T:'D@<&EE8V4@;V8@<F5D=6YD86YT+"!O=F5R;'D@
     >=F5R8F]S92P*86YD(')E<&5T:71I=F4@=&5X="X*

     end
     >>> "sheesh".encode('rot-13')
     'furrfu'

To convert a class instance to Unicode, a ‘__unicode__()’ method can be
defined by a class, analogous to ‘__str__()’.

‘encode()’, ‘decode()’, and ‘__unicode__()’ were implemented by
Marc-André Lemburg.  The changes to support using UCS-4 internally were
implemented by Fredrik Lundh and Martin von Löwis.

参考
....

PEP 261(2) - 'wide' Unicode 文字のサポート

     Paul Prescod 著。 (--訳注: この What's New セクションと PEP 内容は
     2.x ではずっと有効ですが、3.x で大幅に変わっていて逐一補足出来ない
     ほど大きく違っています。変更の概要についてはクックブックの「Python
     2 から Python 3 への移植」がわかりやすいと思います。--)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0261/

   (2) https://peps.python.org/pep-0261/


File: python.info,  Node: PEP 227 入れ子状のスコープ,  Next: 新しいモジュールと改良されたモジュール<3>,  Prev: Unicode の変更,  Up: What's New in Python 2 2

1.20.8 PEP 227: 入れ子状のスコープ
----------------------------------

Python 2.1 では、静的にネストされたスコープが ‘from __future__ import
nested_scopes’ ディレクティブで有効に出来るオプションの機能として追加さ
れました。2.2 では入れ子のスコープには特別に有効化する必要なく、もういつ
でもそこにあります。このセクションの残りの部分は "What's New in Python
2.1" の入れ子のスコープの記述からの丸々コピーですので、2.1 のときに読ん
だなら読み飛ばしてもらって結構です。

Python2.1 で導入され、2.2 で完成した最も大きな変更点は Python のスコープ
ルールです。Python2.0では、ある指定された時点である変数の名前を検索する
ために多くても3つの名前空間、つまりローカル、モジュールレベル、ビルトイ
ン名前空間しか使われませんでした。このことは直感的な期待と一致せずしばし
ば人々を驚かせました。例えば、入れ子になった再帰関数の定義は動きません:

     def f():
         ...
         def g(value):
             ...
             return g(value-1) + 1
         ...

The function ‘g()’ will always raise a *note NameError: 40b. exception,
because the binding of the name ‘g’ isn't in either its local namespace
or in the module-level namespace.  This isn't much of a problem in
practice (how often do you recursively define interior functions like
this?), but this also made using the *note lambda: 126d. expression
clumsier, and this was a problem in practice.  In code which uses
‘lambda’ you can often find local variables being copied by passing them
as the default values of arguments.

     def find(self, name):
         "Return list of any entries equal to 'name'"
         L = filter(lambda x, name=name: x == name,
                    self.list_attribute)
         return L

過度な関数型スタイルで書かれた Python コードの可読性は、結果的にはひどく
苦痛を感じるものですね。

Python 2.2 の最も重要な変更点は、この問題を解決するために静的なスコープ
が追加されたことです。最初の効果として、 ‘name=name’ という例ではデフォ
ルトの引数は必要ありません。簡単に言えば、指定された引数名が関数内の値に
割り当てられない場合(*note def: 13ff. 、 *note class: 12a5. または *note
import: 5ac. ステートメントの割り当てによって)、変数の参照は外側のスコー
プのローカル名前空間で検索されます。ルールや実装の詳細は PEP で参照でき
ます。

この変更は、同じ変数名がモジュールレベルと関数の定義が含まれている関数内
のローカルの両方で変数名として使用されているコードで、互換性の問題を引き
起こす可能性があります。ですがむしろ気にしなくてよいでしょう。そのような
コードはそもそも最初から相当こんがらかっているので。

この変更の副作用の一つは、 ‘from module import *’ と ‘exec’ の両ステート
メントが特定の条件下の関数スコープ内で不正となることです。 Python のリフ
ァレンスマニュアルははじめからずっと ‘from module import *’ はトップレベ
ルモジュールでのみ合法であると言ってきましたが、以前の CPython インタプ
リタはこれを一度も強制していませんでした。入れ子になったスコープ実装の一
環として、Python のソースをバイトコードに変換するコンパイラは、内包され
たスコープ内の変数にアクセスするために別のコードを生成する必要があります
。 ‘from module import *’, ‘exec’ はコンパイラにこれを理解することを不可
能にしてしまいます。なぜならそれらはコンパイル時にはわからないローカル名
前空間に名前を追加するからです。それゆえ、もし関数が関数定義を含んだり自
由な変数に *note lambda: 126d. の語句を含んだりする場合、コンパイラは
*note SyntaxError: 172. 例外を上げて知らせます。

前述した説明を少し明確にするため、例を挙げます:

     x = 1
     def f():
         # The next line is a syntax error
         exec 'x=2'
         def g():
             return x

Line 4 containing the ‘exec’ statement is a syntax error, since ‘exec’
would define a new local variable named ‘x’ whose value should be
accessed by ‘g()’.

これは実際には大した制約でもないはずです。 ‘exec’ が Python コードで使わ
れるのは稀です(使われているとしたら大抵どこか貧弱な設計であることの証)。

参考
....

PEP 227(1) - 静的に入れ子になったスコープ

     Jeremy Hylton著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0227/


File: python.info,  Node: 新しいモジュールと改良されたモジュール<3>,  Next: インタプリタの変更と修正,  Prev: PEP 227 入れ子状のスコープ,  Up: What's New in Python 2 2

1.20.9 新しいモジュールと改良されたモジュール
---------------------------------------------

   * The *note xmlrpclib: 114. module was contributed to the standard
     library by Fredrik Lundh, providing support for writing XML-RPC
     clients.  XML-RPC is a simple remote procedure call protocol built
     on top of HTTP and XML. For example, the following snippet
     retrieves a list of RSS channels from the O'Reilly Network, and
     then lists the recent headlines for one channel:

          import xmlrpclib
          s = xmlrpclib.Server(
                'http://www.oreillynet.com/meerkat/xml-rpc/server.php')
          channels = s.meerkat.getChannels()
          # channels is a list of dictionaries, like this:
          # [{'id': 4, 'title': 'Freshmeat Daily News'}
          #  {'id': 190, 'title': '32Bits Online'},
          #  {'id': 4549, 'title': '3DGamers'}, ... ]

          # Get the items for one channel
          items = s.meerkat.getItems( {'channel': 4} )

          # 'items' is another list of dictionaries, like this:
          # [{'link': 'http://freshmeat.net/releases/52719/',
          #   'description': 'A utility which converts HTML to XSL FO.',
          #   'title': 'html2fo 0.3 (Default)'}, ... ]

     The *note SimpleXMLRPCServer: 115. module makes it easy to create
     straightforward XML-RPC servers.  See
     ‘http://xmlrpc.scripting.com/’ for more information about XML-RPC.

   * 新しい *note hmac: 60. モジュールは、 RFC 2104(1) で記述される HMAC
     アルゴリズムを実装します 。 (Contributed by Gerhard Häring.)

   * Several functions that originally returned lengthy tuples now
     return pseudo-sequences that still behave like tuples but also have
     mnemonic attributes such as ‘memberst_mtime’ or *note tm_year:
     14a1.  The enhanced functions include *note stat(): 46d, *note
     fstat(): d59, *note statvfs(): 10cf, and *note fstatvfs(): d5a. in
     the *note os: 91. module, and *note localtime(): 14a2, *note
     gmtime(): 1190, and *note strptime(): 13d4. in the *note time: d7.
     module.

     例えば旧式のタプルでファイルサイズを得るには ‘file_size =
     os.stat(filename)[stat.ST_SIZE]’ のように書くしかありませんでしたが
     、今ではもっとわかりやすい ‘file_size = os.stat(filename).st_size’
     のように書くことが出来ます。

     この機能のオリジナルのパッチは Nick Mathewson により寄稿されました
     。

   * Python プロファイラが大幅に改造されて、出力の色々な間違いが修正され
     ました。 (Contributed by Fred L. Drake, Jr.  and Tim Peters.)

   * *note socket: b8. モジュールを IPv6 サポート付きでコンパイル可能に
     なりました。Python の ‘configure’ スクリプトに ‘--enable-ipv6’ オプ
     ションを与えてください。(Contributed by Jun-ichiro "itojun"
     Hagino.)

   * Two new format characters were added to the *note struct: c0.
     module for 64-bit integers on platforms that support the C long
     long type.  ‘q’ is for a signed 64-bit integer, and ‘Q’ is for an
     unsigned one.  The value is returned in Python's long integer type.
     (Contributed by Tim Peters.)

   * インタプリタの対話モードに新たに *note help(): 8a5. ビルトインが追
     加されています。これは Python 2.1 で導入された *note pydoc: a3. モ
     ジュールを用いて対話的なヘルプを提供します。 ‘help(object)’ で
     'object' について手に入る任意のヘルプを表示します。 *note help():
     8a5. を引数なしで起動するとオンラインのヘルプユーティリティに入りま
     す。ここから関数名やクラス名、モジュール名をタイプすることで、それ
     らのヘルプテキストを読むことが出来ます。 (Contributed by Guido van
     Rossum, using Ka-Ping Yee's *note pydoc: a3. module.)

   * Various bugfixes and performance improvements have been made to the
     SRE engine underlying the *note re: a7. module.  For example, the
     *note re.sub(): 283. and *note re.split(): 282. functions have been
     rewritten in C. Another contributed patch speeds up certain Unicode
     character ranges by a factor of two, and a new *note finditer():
     14a3. method that returns an iterator over all the non-overlapping
     matches in a given string.  (SRE is maintained by Fredrik Lundh.
     The BIGCHARSET patch was contributed by Martin von Löwis.)

   * *note smtplib: b7. モジュールに RFC 2487(2) 「Secure SMTP over TLS」
     のサポートが追加されました。これにより Python プログラムとメール転
     送エージェント間でのメッセージの暗号化された SMTP トラフィックが可
     能になりました。 *note smtplib: b7. は SMTP 認証もサポートしていま
     す。 (Contributed by Gerhard Häring.)

   * Piers Lauder によって保守されている *note imaplib: 6a. モジュールに
     新たに多くの拡張のサポートが追加されました: RFC 2342(3) で定義され
     ている NAMESPACE 拡張、 SORT、 GETACL、 SETACL。(Contributed by
     Anthony Baxter and Michel Pelletier.)

   * The ‘rfc822’ module's parsing of email addresses is now compliant
     with RFC 2822(4), an update to RFC 822(5).  (The module's name is
     'not' going to be changed to ‘rfc2822’.)  A new package, *note
     email: 32, has also been added for parsing and generating e-mail
     messages.  (Contributed by Barry Warsaw, and arising out of his
     work on Mailman.)

   * The *note difflib: 2f. module now contains a new ‘Differ’ class for
     producing human-readable lists of changes (a "delta") between two
     sequences of lines of text.  There are also two generator
     functions, ‘ndiff()’ and ‘restore()’, which respectively return a
     delta from two sequences, or one of the original sequences from a
     delta.  (Grunt work contributed by David Goodger, from ndiff.py
     code by Tim Peters who then did the generatorization.)

   * New constants ‘ascii_letters’, ‘ascii_lowercase’, and
     ‘ascii_uppercase’ were added to the *note string: be. module.
     There were several modules in the standard library that used
     ‘string.letters’ to mean the ranges A-Za-z, but that assumption is
     incorrect when locales are in use, because ‘string.letters’ varies
     depending on the set of legal characters defined by the current
     locale.  The buggy modules have all been fixed to use
     ‘ascii_letters’ instead.  (Reported by an unknown person; fixed by
     Fred L. Drake, Jr.)

   * The *note mimetypes: 82. module now makes it easier to use
     alternative MIME-type databases by the addition of a *note
     MimeTypes: 14a4. class, which takes a list of filenames to be
     parsed.  (Contributed by Fred L. Drake, Jr.)

   * A *note Timer: 112c. class was added to the *note threading: d6.
     module that allows scheduling an activity to happen at some future
     time.  (Contributed by Itamar Shtull-Trauring.)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2104.html

   (2) https://datatracker.ietf.org/doc/html/rfc2487.html

   (3) https://datatracker.ietf.org/doc/html/rfc2342.html

   (4) https://datatracker.ietf.org/doc/html/rfc2822.html

   (5) https://datatracker.ietf.org/doc/html/rfc822.html


File: python.info,  Node: インタプリタの変更と修正,  Next: その他の変更と修正<3>,  Prev: 新しいモジュールと改良されたモジュール<3>,  Up: What's New in Python 2 2

1.20.10 インタプリタの変更と修正
--------------------------------

Python 拡張モジュールを書いたり、インタプリタの埋め込みをしたり、あるい
は単にインタプリタそのものをハックしたりするために C レベルでインタプリ
タを扱う人々以外には影響しないいくつかの変更があります。Python コードを
書くだけであればここに記述する変更は、あなたに関係するものは全くありませ
ん。

   * プロファイルとトレースの関数が C で実装されました。Python ベースの
     ものと比較して圧倒的に高速に操作出来、プロファイルとトレースのオー
     バヘッドを削減するはずです。これは Python の開発環境の著者に朗報で
     しょう。2 つの C 関数、 *note PyEval_SetProfile(): 14a6. と *note
     PyEval_SetTrace(): 14a7. が Python API に追加されました。既存の
     *note sys.setprofile(): 14a8. 関数、 *note sys.settrace(): 14a9. 関
     数はそのまま存在し、単純に新規 C レベル関数を使うように修正されまし
     た。 (Contributed by Fred L. Drake, Jr.)

   * Another low-level API, primarily of interest to implementers of
     Python debuggers and development tools, was added.  *note
     PyInterpreterState_Head(): 14aa. and *note
     PyInterpreterState_Next(): 14ab. let a caller walk through all the
     existing interpreter objects; *note
     PyInterpreterState_ThreadHead(): 14ac. and *note
     PyThreadState_Next(): 14ad. allow looping over all the thread
     states for a given interpreter.  (Contributed by David Beazley.)

   * ガーベージコレクタの C レベルインターフェイスが変更されています。こ
     れはガーベージコレクションをサポートする拡張型を書いたり、関数の利
     用誤りのデバッグをするのを簡単にします。多数の関数が少々これまでと
     は異なったセマンティクスを持つので、関数群がリネームされました。旧
     API を使う拡張はこれまで通りコンパイルは出来ますが、ガーベージコレ
     クションには参加 '出来ません' 。このため 2.2 のためにはかなり高優先
     度で更新を検討すべきです。

     拡張モジュールを新 API でアップグレードするには、以下のステップを実
     施してください:

   * Rename ‘Py_TPFLAGS_GC’ to *note Py_TPFLAGS_HAVE_GC: 748.

   * 
     オブジェクトのアロケートには *note PyObject_GC_New(): a70. または *note PyObject_GC_NewVar(): a71. を使ってください。

          そしてオブジェクトのデアロケートには *note PyObject_GC_Del():
          14ae. を使ってください。

   * Rename ‘PyObject_GC_Init()’ to *note PyObject_GC_Track(): 14af. and
     ‘PyObject_GC_Fini()’ to *note PyObject_GC_UnTrack(): 14b0.

   * Remove ‘PyGC_HEAD_SIZE’ from object size calculations.

   * Remove calls to ‘PyObject_AS_GC()’ and ‘PyObject_FROM_GC()’.

   * *note PyArg_ParseTuple(): 53d. に新たな書式化シーケンス ‘et’ が追加
     されました。 ‘et’ はパラメータとエンコーディング名の両方を取りパラ
     メータを与えられたエンコーディングで変換しますが、パラメータが
     Unicode である場合には変換し、8 ビット文字列である場合にはこれが既
     に望みのものであることと仮定してそのままにします。このことは ‘es’ 書
     式化文字が 8 ビット文字列は Python デフォルトの ASCII エンコーディ
     ングであると仮定して新たに与えられたエンコーディングで変換するのと
     は違っています。 (Contributed by M.-A. Lemburg, and used for the
     MBCS support on Windows described in the following section.)

   * A different argument parsing function, *note PyArg_UnpackTuple():
     14b1, has been added that's simpler and presumably faster.  Instead
     of specifying a format string, the caller simply gives the minimum
     and maximum number of arguments expected, and a set of pointers to
     *note PyObject: 312.* variables that will be filled in with
     argument values.

   * Two new flags *note METH_NOARGS: 147d. and *note METH_O: 14b2. are
     available in method definition tables to simplify implementation of
     methods with no arguments or a single untyped argument.  Calling
     such methods is more efficient than calling a corresponding method
     that uses *note METH_VARARGS: 14b3.  Also, the old ‘METH_OLDARGS’
     style of writing C methods is now officially deprecated.

   * Two new wrapper functions, *note PyOS_snprintf(): 14b4. and *note
     PyOS_vsnprintf(): 14b5. were added to provide cross-platform
     implementations for the relatively new ‘snprintf()’ and
     ‘vsnprintf()’ C lib APIs.  In contrast to the standard ‘sprintf()’
     and ‘vsprintf()’ functions, the Python versions check the bounds of
     the buffer used to protect against buffer overruns.  (Contributed
     by M.-A. Lemburg.)

   * *note _PyTuple_Resize(): 14b6. 関数の未使用パラメータを取り除いたの
     で、今後は 3 つではなく 2 つのパラメータを取ります。3 つ目の引数は
     一度も使われることはなかったため、Python 2.2 以前のコードからの移植
     時には単純に捨てることが出来ます。


File: python.info,  Node: その他の変更と修正<3>,  Next: 謝辞<6>,  Prev: インタプリタの変更と修正,  Up: What's New in Python 2 2

1.20.11 その他の変更と修正
--------------------------

いつものように、たくさんのほかの改善とバグフィックスがソースツリー全体に
渡って散らばっています。CVS 変更ログを検索すると、Python 2.1 から 2.2 に
かけて適用されたパッチは 527、バグ修正は 683、2.2.1 で適用されたパッチは
139、バグ修正は 143、2.2.2 で適用されたパッチは 106、バグ修正は 82。いず
れも少なく見積もって、です。

ほかの、さらに特筆すべき変更のいくつかを挙げます:

   * The code for the MacOS port for Python, maintained by Jack Jansen,
     is now kept in the main Python CVS tree, and many changes have been
     made to support MacOS X.

     The most significant change is the ability to build Python as a
     framework, enabled by supplying the ‘--enable-framework’ option to
     the configure script when compiling Python.  According to Jack
     Jansen, "This installs a self-contained Python installation plus
     the OS X framework "glue" into
     ‘/Library/Frameworks/Python.framework’ (or another location of
     choice).  For now there is little immediate added benefit to this
     (actually, there is the disadvantage that you have to change your
     PATH to be able to find Python), but it is the basis for creating a
     full-blown Python application, porting the MacPython IDE, possibly
     using Python as a standard OSA scripting language and much more."

     Most of the MacPython toolbox modules, which interface to MacOS
     APIs such as windowing, QuickTime, scripting, etc.  have been
     ported to OS X, but they've been left commented out in ‘setup.py’.
     People who want to experiment with these modules can uncomment them
     manually.

   * キーワード引数を取らないビルトイン関数にそれを渡すと、メッセージ
     "'function' takes no keyword arguments" を伴う *note TypeError:
     502. 例外を励起するようになりました。

   * Python 2.1 で拡張モジュールとして追加された弱参照は、今では Python
     中核の一部です。これは新スタイルクラスの実装のために使われるからで
     す。このため *note weakref: fc. モジュールにいた *note
     ReferenceError: 14b8. 例外をビルトイン例外に移動しました。

   * Tim Peters による新しいスクリプト ‘Tools/scripts/cleanfuture.py’ は
     、Python ソースコードから自動的に廃止された ‘__future__’ 文を削除し
     ます。

   * ビルトイン関数 *note compile(): 177. に 'flags' 引数が追加され、こ
     れにより ‘__future__’ ステートメントの振る舞いが、IDLE 内やほかの開
     発環境内にある模擬的なシェル内で正しく準拠するようになりました。こ
     の変更は PEP 264(1) に記述されています。 (Contributed by Michael
     Hudson.)

   * Python 1.6 で導入された新ライセンスは GPL 互換ではありませんでした
     。2.2 ライセンスのためにいくつか小さな字句的修正によりこれをフィッ
     クスし、GPL プログラム内に Python を埋め込むことが再び合法になりま
     した。Python そのものは GPL ではなく、かつても今後も BSD ライセンス
     に本質的に等価なものであることに注意してください。このライセンスの
     変更は Python 2.0.1 リリース、2.1.1 リリースにも適用されました。

   * Windows において Unicode ファイル名がある場合に、Python はそれを
     Microsoft ファイル API を使うことで MBCS 文字列に変換するようになり
     ました。MBCS はそのファイル API によって明示的に使われるので、デフ
     ォルトのエンコーディングとして Python が ASCII を選択するのは苛立た
     しいことがわかりました。Unix においては
     ‘locale.nl_langinfo(CODESET)’ が利用可能であればロケールの文字セッ
     トが使われます。 (Windows support was contributed by Mark Hammond
     with assistance from Marc-André Lemburg.  Unix support was added by
     Martin von Löwis.)

   * Windows でのラージファイルのサポートが有効になりました。
     (Contributed by Tim Peters.)

   * ‘Tools/scripts/ftpmirror.py’ スクリプトが、もしあれば、 ‘.netrc’ フ
     ァイルを読むようになりました。 (Contributed by Mike Romberg.)

   * Some features of the object returned by the ‘xrange()’ function are
     now deprecated, and trigger warnings when they're accessed; they'll
     disappear in Python 2.3.  ‘xrange’ objects tried to pretend they
     were full sequence types by supporting slicing, sequence
     multiplication, and the *note in: 2cb. operator, but these features
     were rarely used and therefore buggy.  The ‘tolist()’ method and
     the ‘start’, ‘stop’, and ‘step’ attributes are also being
     deprecated.  At the C level, the fourth argument to the
     ‘PyRange_New()’ function, ‘repeat’, has also been deprecated.

   * 辞書実装に対するパッチの束がありました。ほとんどが、辞書にこっそり
     とそのハッシュ値を変更するオブジェクトを含んでいたり、それが含まれ
     る辞書を変更する場合に潜在的にコアダンプしていたことに対する修正で
     す。Michael Hudson がコアダンプするケースを見つけて python-dev に穏
     やかなリズムで報告している間に Tim Peters がバグをフィックスし、
     Michael がまた別のケースを見つけ、ということを繰り返しました。

   * On Windows, Python can now be compiled with Borland C thanks to a
     number of patches contributed by Stephen Hansen, though the result
     isn't fully functional yet.  (But this 'is' progress...)

   * Another Windows enhancement: Wise Solutions generously offered
     PythonLabs use of their InstallerMaster 8.1 system.  Earlier
     PythonLabs Windows installers used Wise 5.0a, which was beginning
     to show its age.  (Packaged up by Tim Peters.)

   * ファイル名が ‘.pyw’ で終わるものが Windows でインポート出来るように
     なりました。 ‘.pyw’ は Windows のみのものであり、スクリプトが
     PYTHON.EXE ではなく PYTHONW.EXE を使って実行されることを示すのに使
     われます。これは出力のために DOS コンソールがポップアップしてしまう
     のを避けるのに使われます。このパッチはそのようなスクリプトを、それ
     がモジュールとしても利用可能であるケースでインポート出来るようにし
     ます。 (Implemented by David Bolen.)

   * Python が C の ‘dlopen()’ 関数を拡張モジュールのロードに用いるプラ
     ットフォームにおいて、 ‘dlopen()’ で使われるフラグを *note
     sys.getdlopenflags(): 14b9. 関数と *note sys.setdlopenflags():
     10f2. 関数でセット出来るようになりました。 (Contributed by Bram
     Stolk.)

   * The *note pow(): 9a0. built-in function no longer supports 3
     arguments when floating-point numbers are supplied.  ‘pow(x, y, z)’
     returns ‘(x**y) % z’, but this is never useful for floating-point
     numbers, and the final result varies unpredictably depending on the
     platform.  A call such as ‘pow(2.0, 8.0, 7.0)’ will now raise a
     *note TypeError: 502. exception.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0264/


File: python.info,  Node: 謝辞<6>,  Prev: その他の変更と修正<3>,  Up: What's New in Python 2 2

1.20.12 謝辞
------------

著者は提案の申し出や修正、様々なこの記事の草稿の助けをしてくれた以下の人
々に感謝します: Fred Bremmer, Keith Briggs, Andrew Dalke, Fred L. Drake,
Jr., Carel Fellinger, David Goodger, Mark Hammond, Stephen Hansen,
Michael Hudson, Jack Jansen, Marc-André Lemburg, Martin von Löwis,
Fredrik Lundh, Michael McLay, Nick Mathewson, Paul Moore, Gustavo
Niemeyer, Don O'Donnell, Joonas Paalasma, Tim Peters, Jens Quade, Tom
Reinhardt, Neil Schemenauer, Guido van Rossum, Greg Ward, Edward
Welbourne.


File: python.info,  Node: What's New in Python 2 1,  Next: What's New in Python 2 0,  Prev: What's New in Python 2 2,  Up: What's New in Python

1.21 What's New in Python 2.1
=============================


著者: A.M. Kuchling

* Menu:

* はじめに: はじめに<2>.
* PEP 227; 入れ子状のスコープ: PEP 227 入れ子状のスコープ<2>.
* PEP 236; __future__ 指示文: PEP 236 __future__ 指示文.
* PEP 207; 拡張比較: PEP 207 拡張比較.
* PEP 230; 警告フレームワーク: PEP 230 警告フレームワーク.
* PEP 229; 新しいビルドシステム: PEP 229 新しいビルドシステム.
* PEP 205; 弱参照: PEP 205 弱参照.
* PEP 232; 関数の属性: PEP 232 関数の属性.
* PEP 235; 大文字小文字を区別しないプラットフォームでのモジュールの読み込み: PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み.
* PEP 217; 対話モード用 Display Hook: PEP 217 対話モード用 Display Hook.
* PEP 208; 新しい型強制モデル: PEP 208 新しい型強制モデル.
* PEP 241; Pythonソフトウェアパッケージのためのメタデータ: PEP 241 Pythonソフトウェアパッケージのためのメタデータ.
* 新しいモジュールと改良されたモジュール: 新しいモジュールと改良されたモジュール<4>.
* その他の変更と修正: その他の変更と修正<4>.
* 謝辞: 謝辞<7>.


File: python.info,  Node: はじめに<2>,  Next: PEP 227 入れ子状のスコープ<2>,  Up: What's New in Python 2 1

1.21.1 はじめに
---------------

この記事はPython 2.1の新機能について説明します。Python 2.1には Python
2.0ほど多くの変更点はありませんが、楽しい驚きがあります。2.1はPythonの拡
張計画（PEP）を使い動かす最初のリリースであり、大きい変更点のほとんどは
、より詳細なドキュメントや変更のための設計原理を提供するPEPに付随してい
ます。この記事は新機能について網羅していませんが、Pythonプログラマのため
の新機能について概要を示します。特に興味のある任意の新機能の詳細について
は、Python 2.1ドキュメントか特定のPEPを参照してください。

Python開発チームの最近の目標の一つとして新しいリリースのペースを上げてお
り、一つのリリースにつき6～9ヶ月ごとにリリースしています。2.1はこの速い
ペースになって出てきた最初のリリースで、初のアルファ版は、2.0の最終版が
リリースされた3ヶ月後の1月に登場しました。

Python 2.1の最終版は2001年4月17日に作成されました。


File: python.info,  Node: PEP 227 入れ子状のスコープ<2>,  Next: PEP 236 __future__ 指示文,  Prev: はじめに<2>,  Up: What's New in Python 2 1

1.21.2 PEP 227: 入れ子状のスコープ
----------------------------------

Python2.1における最も大きな変更点はPythonのスコープルールです。
Python2.0では、ある指定された時点である変数の名前を検索するために多くて
も3つの名前空間、つまりローカル、モジュールレベル、ビルトイン名前空間し
か使われませんでした。このことは直感的な期待と一致せずしばしば人々を驚か
せました。例えば、入れ子になった再帰関数の定義は動きません:

     def f():
         ...
         def g(value):
             ...
             return g(value-1) + 1
         ...

The function ‘g()’ will always raise a *note NameError: 40b. exception,
because the binding of the name ‘g’ isn't in either its local namespace
or in the module-level namespace.  This isn't much of a problem in
practice (how often do you recursively define interior functions like
this?), but this also made using the *note lambda: 126d. expression
clumsier, and this was a problem in practice.  In code which uses *note
lambda: 126d. you can often find local variables being copied by passing
them as the default values of arguments.

     def find(self, name):
         "Return list of any entries equal to 'name'"
         L = filter(lambda x, name=name: x == name,
                    self.list_attribute)
         return L

過度な関数型スタイルで書かれた Python コードの可読性は、結果的にはひどく
苦痛を感じるものですね。

Python 2.1の最も重要な変更点は、この問題を解決するために静的なスコープが
追加されたことです。最初の効果として、‘name=name’ という例ではデフォルト
の引数は必要ありません。簡単に言えば、指定された引数名が関数内の値に割り
当てられない場合(*note def: 13ff.、*note class: 12a5. または *note
import: 5ac. ステートメントの割り当てによって)、変数の参照は外側のスコー
プのローカル名前空間で検索されます。ルールや実装の詳細はPEPで参照できま
す。

この変更は、同じ変数名がモジュールレベルと関数の定義が含まれている関数内
のローカルの両方で変数名として使用されているコードで、互換性の問題を引き
起こす可能性があります。ですがむしろ気にしなくてよいでしょう。そのような
コードはそもそも最初から相当こんがらかっているので。

この変更の副作用の一つは、 ‘from module import *’ と ‘exec’ の両ステート
メントが特定の条件下の関数スコープ内で不正となることです。 Python のリフ
ァレンスマニュアルははじめからずっと ‘from module import *’ はトップレベ
ルモジュールでのみ合法であると言ってきましたが、以前の CPython インタプ
リタはこれを一度も強制していませんでした。入れ子になったスコープ実装の一
環として、Python のソースをバイトコードに変換するコンパイラは、内包され
たスコープ内の変数にアクセスするために別のコードを生成する必要があります
。 ‘from module import *’, ‘exec’ はコンパイラにこれを理解することを不可
能にしてしまいます。なぜならそれらはコンパイル時にはわからないローカル名
前空間に名前を追加するからです。それゆえ、もし関数が関数定義を含んだり自
由な変数に *note lambda: 126d. の語句を含んだりする場合、コンパイラは
*note SyntaxError: 172. 例外を上げて知らせます。

前述した説明を少し明確にするため、例を挙げます:

     x = 1
     def f():
         # The next line is a syntax error
         exec 'x=2'
         def g():
             return x

Line 4 containing the ‘exec’ statement is a syntax error, since ‘exec’
would define a new local variable named ‘x’ whose value should be
accessed by ‘g()’.

これは実際には大した制約でもないはずです。 ‘exec’ が Python コードで使わ
れるのは稀です(使われているとしたら大抵どこか貧弱な設計であることの証)。

互換性の問題が考慮されて、入れ子のスコープは段階的導入につながりました;
Python 2.1 ではそれらはデフォルトで有効になっていませんが、 PEP 236(1) に
記載されているように、future 文を使用してモジュール内でオンにすることが
できます。( PEP 236(2) の更なる議論について、続くセクションを参照してく
ださい。) Python 2.2では入れ子になったスコープがデフォルトになり、それを
オフにする方法はありませんが、ユーザは 2.1 の全ライフタイムを通して、導
入の結果起きるあらゆる破損を修正し続けるでしょう。

参考
....

PEP 227(3) - 静的に入れ子になったスコープ

     Jeremy Hylton著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0236/

   (2) https://peps.python.org/pep-0236/

   (3) https://peps.python.org/pep-0227/


File: python.info,  Node: PEP 236 __future__ 指示文,  Next: PEP 207 拡張比較,  Prev: PEP 227 入れ子状のスコープ<2>,  Up: What's New in Python 2 1

1.21.3 PEP 236: __future__ 指示文
---------------------------------

ネストされたスコープへのこの対応は、リリース 2.1 ではコードを壊すことの
危険性について広く懸念されており、 Pythoneer 達に保守的なアプローチを選
ばせるには十分でした。このアプローチは、必須とするリリース N+1 に対する
、 リリース N でのオプション機能として有効化という序奏、というものです。

この構文は *note __future__: 0. という名の予約モジュールを使う
‘from...import’ ステートメントを使用します。ネストしたスコープは以下のス
テートメントで有効にできます。

     from __future__ import nested_scopes

普通 の *note import: 5ac. ステートメントに見えますが、実は違います; こ
のような未来のステートメントが置かれる場所には厳格なルールがあります。こ
れらはモジュールの冒頭にしか置けませんし、必ず何らかのPythonコードや正規
の ‘import’ ステートメントの前になければなりません。それと言うのもこのよ
うなステートメントは、Pythonのバイトコードコンパイラがコードを解析し、バ
イトコードを生成する方法に影響しますので、生成されるバイトコードとなるス
テートメントの前になくてはならないのです。

参考
....

PEP 236(1) - バック・トゥ・ザ・ *note __future__: 0.

     Tim Peter著、Jeremy Hylton主実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0236/


File: python.info,  Node: PEP 207 拡張比較,  Next: PEP 230 警告フレームワーク,  Prev: PEP 236 __future__ 指示文,  Up: What's New in Python 2 1

1.21.4 PEP 207: 拡張比較
------------------------

In earlier versions, Python's support for implementing comparisons on
user-defined classes and extension types was quite simple.  Classes
could implement a ‘__cmp__()’ method that was given two instances of a
class, and could only return 0 if they were equal or +1 or -1 if they
weren't; the method couldn't raise an exception or return anything other
than a Boolean value.  Users of Numeric Python often found this model
too weak and restrictive, because in the number-crunching programs that
numeric Python is used for, it would be more useful to be able to
perform elementwise comparisons of two matrices, returning a matrix
containing the results of a given comparison for each element.  If the
two matrices are of different sizes, then the compare has to be able to
raise an exception to signal the error.

Python2.1で、このニーズを満たすために拡張比較が追加されました。Pythonの
クラスは、‘<’、‘<=’、‘>’、‘>=’、‘==’、‘!=’ の各演算を個別にオーバーロー
ドできます。この新しい特殊メソッドの名前は:

演算            メソッド名
                
---------------------------------------------
                
‘<’             *note __lt__(): 12d9.
                
                
‘<=’            *note __le__(): 12da.
                
                
‘>’             *note __gt__(): 12db.
                
                
‘>=’            *note __ge__(): 12dc.
                
                
‘==’            *note __eq__(): ac8.
                
                
‘!=’            *note __ne__(): 14c1.
                

(特殊メソッドはFortranの ‘.LT.’ や ‘.LE.’ 等々の演算子にちなんで命名され
ています。プログラマはほぼ確実にこれらの名前を熟知していますので、覚えや
すいでしょう。)

これらの特殊メソッドは ‘method(self, other)’ の形式になっており、‘self’
が演算子の左辺、‘other’ が右辺のオブジェクトになります。例えば、式 ‘A <
B’ は ‘A.__lt__(B)’ を呼び出します。

これらの特殊メソッドは何でも、つまり真偽値や行列、リストや他のPython オ
ブジェクトを返せます。もし比較が不可能であったり、矛盾していたり、意味が
ない場合は、代わりに例外を上げることができます。

The built-in ‘cmp(A,B)’ function can use the rich comparison machinery,
and now accepts an optional argument specifying which comparison
operation to use; this is given as one of the strings ‘"<"’, ‘"<="’,
‘">"’, ‘">="’, ‘"=="’, or ‘"!="’.  If called without the optional third
argument, ‘cmp()’ will only return -1, 0, or +1 as in previous versions
of Python; otherwise it will call the appropriate method and can return
any Python object.

C プログラマにとって興味深い関連する変更があります。型オブジェクトに新し
い ‘tp_richcmp’ スロットと、この拡張された比較を行うAPIが追加されました
。ここではC APIについて言及しませんが、あながた関連する関数のリストを見
たければ、 PEP 207(1) かバージョン2.1のC APIドキュメントを参照してくださ
い。

参考
....

PEP 207(2): 拡張比較

     David Ascher によるかつての仕事に大きく拠りますが Guido van Rossum
     によって著され、実装されました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0207/

   (2) https://peps.python.org/pep-0207/


File: python.info,  Node: PEP 230 警告フレームワーク,  Next: PEP 229 新しいビルドシステム,  Prev: PEP 207 拡張比較,  Up: What's New in Python 2 1

1.21.5 PEP 230: 警告フレームワーク
----------------------------------

10 年の間に、Python は途中で廃止されたモジュールと機能の特定の番号を蓄積
してきました。どれだけのコードが活用されているか知る術はないので、機能を
削除して問題ないか把握することは困難です。その機能に依存するプログラムは
一つもないかもしれませんし、たくさんあるかもしれません。より構造化された
方法で古い機能を削除できるようにするために、警告のフレームワークが追加さ
れました。Python の開発者がある機能を取り除きたいときは、まずは Python の
次のバージョンで警告を引き起こします。続く Python バージョンで開発者はそ
の機能を削除出来、ユーザは古い機能の使用を取り除くために Python リリース
サイクル一つ丸々使えます。

Python 2.1 はこのスキームで使われる警告フレームワークを追加します。また
、警告の表示機能や表示させたくない警告を除外する機能を提供する、 *note
warnings: fa. モジュールを追加します。サードパーティーのモジュールはまた
、彼らがサポート対象外にしたい古い機能を非推奨と知らしめるのにこのフレー
ムワークを利用できます。

For example, in Python 2.1 the ‘regex’ module is deprecated, so
importing it causes a warning to be printed:

     >>> import regex
     __main__:1: DeprecationWarning: the regex module
              is deprecated; please use the re module
     >>>

警告は *note warnings.warn(): 14c3. 関数を呼び出すことで発行できます:

     warnings.warn("feature X no longer supported")

最初のパラメータは警告メッセージです。任意追加のパラメータは、特定の警告
カテゴリを指定するために利用することができます。

Filters can be added to disable certain warnings; a regular expression
pattern can be applied to the message or to the module name in order to
suppress a warning.  For example, you may have a program that uses the
‘regex’ module and not want to spare the time to convert it to use the
*note re: a7. module right now.  The warning can be suppressed by
calling

     import warnings
     warnings.filterwarnings(action = 'ignore',
                             message='.*regex module is deprecated',
                             category=DeprecationWarning,
                             module = '__main__')

This adds a filter that will apply only to warnings of the class *note
DeprecationWarning: 18a. triggered in the *note __main__: 1. module, and
applies a regular expression to only match the message about the ‘regex’
module being deprecated, and will cause such warnings to be ignored.
Warnings can also be printed only once, printed every time the offending
code is executed, or turned into exceptions that will cause the program
to stop (unless the exceptions are caught in the usual way, of course).

関数は、警告を発行するための Python の C API にも追加されました。詳細に
ついては PEP 230 または Python の API ドキュメントを参照してください。

参考
....

PEP 5(1) - 言語の進化のためのガイドライン

     Python から古い機能を削除する時に従うべき手順を示すため、 Paul
     Prescod により書かれました。当 PEP に記載された方針は正式に採用され
     ていませんが、最終的な方針も Prescod の提案とおそらくさほど違いはな
     いでしょう。

PEP 230(2) - 警告フレームワーク

     Guido van Rossum 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0005/

   (2) https://peps.python.org/pep-0230/


File: python.info,  Node: PEP 229 新しいビルドシステム,  Next: PEP 205 弱参照,  Prev: PEP 230 警告フレームワーク,  Up: What's New in Python 2 1

1.21.6 PEP 229: 新しいビルドシステム
------------------------------------

Python のコンパイル時、ユーザはソースツリーの中に入って、様々な追加モジ
ュールを有効にするために ‘Modules/Setup’ ファイルを編集しなければなりま
せんでした; デフォルトのセットは比較的小さくて、ほとんどの Unix プラット
フォームで、コンパイルするモジュールを制限しています。これは、特に Linux
に顕著ですが、たくさんの追加機能を持った Unix プラットフォームでは、
Python インストレーションはしばしば、そう出来るのに有用なモジュールを全
く含まない、といったことが起こることを意味しています。

Python 2.0 は、配布と拡張のインストールをするためのモジュールのセットで
ある Distutils を追加しました。Python 2.1 では Distutils を、たくさんの
拡張モジュールの標準ライブラリを、サポートする機器かどうかを自動検出して
コンパイルするのに使っています。これが Python インストレーションをより簡
単に、より機能的とするものであることが期待されています。

モジュールを有効化するために ‘Modules/Setup’ を編集する必要性の代わりに
、Python ソースツリーのトップレベルディレクトリにある ‘setup.py’ スクリ
プトがビルド時に実行され、システムのモジュールとヘッダファイルを調べるこ
とによって、どのモジュールが有効に出来るのかを検出しようと試みます。モジ
ュールが ‘Modules/Setup’ 内でそう構成されていれば、 ‘setup.py’ スクリプ
トはそのモジュールをコンパイルしようとはせずに ‘Modules/Setup’ ファイル
内容に従います。これは特定のプラットフォームで必要となるヘンチクリンなコ
マンドラインフラグやライブラリフラグを特定する手段も与えてくれます。

もう一つの大きなビルド機構の変更点は Neil Schemenauer による再構成で、今
や Python は、トップディレクトリと ‘Python/’, ‘Parser/’, ‘Objects/’,
‘Modules/’ サブディレクトリにあった別々の Makefile が再帰的にビルドする
代わりに、再帰をしないトップレベルの単一 makefile を使うようになっていま
す。このことで Python のビルドは速くなり、 Makefile をもてあそぶのが単純
明快になっています。

参考
....

PEP 229(1) - Distutils を使った Python のビルド

     A.M. Kuchling 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0229/


File: python.info,  Node: PEP 205 弱参照,  Next: PEP 232 関数の属性,  Prev: PEP 229 新しいビルドシステム,  Up: What's New in Python 2 1

1.21.7 PEP 205: 弱参照
----------------------

*note weakref: fc. モジュールを通して利用出来る弱参照(weak references)は
、ささやかですが有用な、Python プログラマの道具箱に新たに加わったデータ
型です。

オブジェクトへの参照(辞書内やリスト内を思い浮かべてください)を記憶してお
くということは、オブジェクトを生き永らえさせるという副作用を持っています
。少しばかりの、この振る舞いが望ましくない特殊なケースがあります。オブジ
ェクトのキャッシュがその最もありがちな一つで、もう一つはツリーのようなデ
ータ構造での循環参照です。

例えば、他の関数 ‘f(x)’ の結果を、その関数の引数と結果を辞書に格納するこ
とでキャッシュするメモライジング関数を考えてみましょう。

     _cache = {}
     def memoize(x):
         if _cache.has_key(x):
             return _cache[x]

         retval = f(x)

         # Cache the returned object
         _cache[x] = retval

         return retval

This version works for simple things such as integers, but it has a side
effect; the ‘_cache’ dictionary holds a reference to the return values,
so they'll never be deallocated until the Python process exits and
cleans up.  This isn't very noticeable for integers, but if ‘f()’
returns an object, or a data structure that takes up a lot of memory,
this can be a problem.

弱参照は、オブジェクトをその時間を超えて生き永らえさせたくないキャッシュ
の実装のための手段を提供します。オブジェクトがアクセス出来るのが弱参照か
らのみである場合、そのオブジェクトは解放されて、その弱参照は参照している
そのオブジェクトがもはや存在しないことを表明します。オブジェクト 'obj' へ
の弱参照を作るには、 ‘wr = weakref.ref(obj)’ とします。参照されているオ
ブジェクトは、それがあたかも関数であったかのように弱参照を「コール」する
ことで得ます: ‘wr()’ 。それは参照されたオブジェクトを返すか、もう存在し
ていないのであれば ‘None’ を返します。

This makes it possible to write a ‘memoize()’ function whose cache
doesn't keep objects alive, by storing weak references in the cache.

     _cache = {}
     def memoize(x):
         if _cache.has_key(x):
             obj = _cache[x]()
             # If weak reference object still exists,
             # return it
             if obj is not None: return obj

         retval = f(x)

         # Cache a weak reference
         _cache[x] = weakref.ref(retval)

         return retval

The *note weakref: fc. module also allows creating proxy objects which
behave like weak references -- an object referenced only by proxy
objects is deallocated - but instead of requiring an explicit call to
retrieve the object, the proxy transparently forwards all operations to
the object as long as the object still exists.  If the object is
deallocated, attempting to use a proxy will cause a
‘weakref.ReferenceError’ exception to be raised.

     proxy = weakref.proxy(obj)
     proxy.attr   # Equivalent to obj.attr
     proxy.meth() # Equivalent to obj.meth()
     del obj
     proxy.attr   # raises weakref.ReferenceError

参考
....

PEP 205(1) - 弱参照

     Fred L. Drake, Jr.  著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0205/


File: python.info,  Node: PEP 232 関数の属性,  Next: PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み,  Prev: PEP 205 弱参照,  Up: What's New in Python 2 1

1.21.8 PEP 232: 関数の属性
--------------------------

In Python 2.1, functions can now have arbitrary information attached to
them.  People were often using docstrings to hold information about
functions and methods, because the *note __doc__: 11a9. attribute was
the only way of attaching any information to a function.  For example,
in the Zope web application server, functions are marked as safe for
public access by having a docstring, and in John Aycock's SPARK parsing
framework, docstrings hold parts of the BNF grammar to be parsed.  This
overloading is unfortunate, since docstrings are really intended to hold
a function's documentation; for example, it means you can't properly
document functions intended for private use in Zope.

ついに関数に、任意の属性をセットし、取り出すことが出来るようになりました
。普通の Python 構文で出来ます:

     def f(): pass

     f.publish = 1
     f.secure = 1
     f.grammar = "A ::= B (C D)*"

The dictionary containing attributes can be accessed as the function's
*note __dict__: 12a0.  Unlike the *note __dict__: c2b. attribute of
class instances, in functions you can actually assign a new dictionary
to *note __dict__: 12a0, though the new value is restricted to a regular
Python dictionary; you 'can't' be tricky and set it to a ‘UserDict’
instance, or any other random object that behaves like a mapping.

参考
....

PEP 232(1) - 関数の属性

     Barry Warsaw 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0232/


File: python.info,  Node: PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み,  Next: PEP 217 対話モード用 Display Hook,  Prev: PEP 232 関数の属性,  Up: What's New in Python 2 1

1.21.9 PEP 235: 大文字小文字を区別しないプラットフォームでのモジュールの読み込み
--------------------------------------------------------------------------------

いくつかのオペレーティングシステムは、大小文字区別に無関心なファイルシス
テムを持っています。MacOS と Windows がその代表例です。それらシステムに
おいてはファイル名 ‘FILE.PY’ と ‘file.py’ の区別が出来ません。たとえそれ
が元のファイル名を尊重して格納出来たとしてもです(それらは大小文字維持、
でもあります)。

Python 2.1 では *note import: 5ac. 文が、case-insensitive (大小文字に無
関心)なプラットフォームで case-sensitivity (大小文字への繊細さ)をシミュ
レートして動作します。Python は今や、まずはデフォルトで case-sensitive な
マッチによる検索をし、それで見つからなければ *note ImportError: 3f2. を
投げます。ですから ‘import file’ は ‘FILE.PY’ をインポートしません。
case-insensitive マッチングは Python インタプリタ開始前に環境変数 *note
PYTHONCASEOK: 92a. をセットすることで要求出来ます。


File: python.info,  Node: PEP 217 対話モード用 Display Hook,  Next: PEP 208 新しい型強制モデル,  Prev: PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み,  Up: What's New in Python 2 1

1.21.10 PEP 217: 対話モード用 Display Hook
------------------------------------------

Python インタプリタを対話的に使う際には、コマンドの出力結果表示にはビル
トインの *note repr(): 7c8. 関数が使われます。Python 2.1 ではこの *note
repr(): 7c8. の代わりに呼び出される呼び出し可能オブジェクトを、 *note
sys.displayhook(): 14c9. 変数にセット出来ます。たとえば特別な pretty-
printing 関数をセット出来ます:

     >>> # Create a recursive data structure
     ... L = [1,2,3]
     >>> L.append(L)
     >>> L # Show Python's default output
     [1, 2, 3, [...]]
     >>> # Use pprint.pprint() as the display function
     ... import sys, pprint
     >>> sys.displayhook = pprint.pprint
     >>> L
     [1, 2, 3,  <Recursion on list with id=135143996>]
     >>>

参考
....

PEP 217(1) - Display Hook の対話的な使用

     Moshe Zadka 著、実装

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0217/


File: python.info,  Node: PEP 208 新しい型強制モデル,  Next: PEP 241 Pythonソフトウェアパッケージのためのメタデータ,  Prev: PEP 217 対話モード用 Display Hook,  Up: What's New in Python 2 1

1.21.11 PEP 208: 新しい型強制モデル
-----------------------------------

数値強制が C レベルでどのようになされるかについての修正は、とても大きな
ものでした。これは Python の C 拡張の著者にのみ影響し、数値操作をサポー
トする拡張型を書くのをより柔軟にするものです。

拡張型はその ‘PyTypeObject’ 構造体に、新しい型強制モデルをサポートするこ
とを示すために ‘Py_TPFLAGS_CHECKTYPES’ フラグをセット出来るようになりま
した。そのような拡張型内では、数値的スロット関数は 2 つの引数が同じ型で
あることを仮定しなくなります。代わりに、2 つの引数が異なる型を渡せて、内
部的に型変換を実行出来ます。スロット関数にそれが処理出来ない型が渡された
場合は、それが失敗であることを表すために ‘Py_NotImplemented’ シングルト
ン値への参照を返せます。この場合他の数値関数が試されて、おそらく操作を実
行出来ます。それでも ‘Py_NotImplemented’ を返すなら *note TypeError:
502. が送出されます。Python で書かれた数値メソッドも ‘Py_NotImplemented’
を返せます。この場合インタプリタはメソッドが存在しないものとして振舞いま
す。 (おそらく *note TypeError: 502. が投げられたり、オブジェクトのほか
の数値メソッドが試されます。)

参考
....

PEP 208(1) - 型強制モデルの手直し

     Neil Schemenauer により著され、実装されましたが、大変多くを
     Marc-André Lemburg による以前の仕事に拠っています。C レベルで今では
     数値操作がどのように処理されるようになったかの細かい点を理解したけ
     れば、これを読んで下さい。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0208/


File: python.info,  Node: PEP 241 Pythonソフトウェアパッケージのためのメタデータ,  Next: 新しいモジュールと改良されたモジュール<4>,  Prev: PEP 208 新しい型強制モデル,  Up: What's New in Python 2 1

1.21.12 PEP 241: Pythonソフトウェアパッケージのためのメタデータ
---------------------------------------------------------------

Python ユーザーからのよくある苦情としては、存在するすべての Python モジ
ュールの一覧がないということです。T. Middleton's の
‘www.vex.net/parnassus/’ にあった Vaults of Parnassus (2009年2月に停止、
Internet Archive Wayback Machine
<‘https://web.archive.org/web/20090130140102/http://www.vex.net/parnassus/’>'_
で閲覧可) が最大のものでしたが、ソフトウェアの登録は任意だったため、多く
の人は登録しませんでした。

この問題をどうにかするための最初の小さな一歩として、Distutils の ‘sdist’
コマンドを使ってパッケージ化する Python ソフトウェアに ‘PKG-INFO’ と名付
けられたファイルを含むようにしました。これには名前、バージョン、著者 (カ
タログ化の用語ではメタデータ) のような情報を含んでいます。 PEP 241(1) が
‘PKG-INFO’ ファイルに持てるフィールドの完全なリストを記述しています。
Python 2.1 を使ったソフトウェアをパッケージ化し始めた人々によってパッケ
ージがどんどんメタデータを含み、自動的なカタログ化システムを構築し、それ
を実験することが出来るようになります。その結果の経験により、おそらく本当
に良いカタログを設計出来、Python 2.2 でそのサポートを構築出来るでしょう
。例えば Distutils の ‘sdist’ コマンドと ‘bdist_*’ コマンド群はあなたの
パッケージをカタログサーバに自動的にアップロードする ‘upload’ オプション
をサポート出来るでしょう。

‘PKG-INFO’ を含んだパッケージの作成は Python 2.1 を使っていなくても開始
することが出来ます。Distutils の新しいリリースが以前のバージョンの
Python ユーザ向けにも作られているからです。Distutils のバージョン 1.0.2
が、多数のバグフィックスや拡張とともに、 PEP 241(2) の変更を含んでいます
。これは ‘https://www.python.org/community/sigs/current/distutils-sig/’
にある Distutils SIG から入手可能です。

参考
....

PEP 241(3) - Pythonソフトウェアパッケージのためのメタデータ

     A.M. Kuchling 著、実装

PEP 243(4) - レポジトリアップロードモジュールのメカニズム

     Sean Reifschneider により著されました。このドラフト PEP は中央サー
     バに Python パッケージをアップロードする機構について提案しています
     。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0241/

   (2) https://peps.python.org/pep-0241/

   (3) https://peps.python.org/pep-0241/

   (4) https://peps.python.org/pep-0243/


File: python.info,  Node: 新しいモジュールと改良されたモジュール<4>,  Next: その他の変更と修正<4>,  Prev: PEP 241 Pythonソフトウェアパッケージのためのメタデータ,  Up: What's New in Python 2 1

1.21.13 新しいモジュールと改良されたモジュール
----------------------------------------------

   * Ka-Ping Yee contributed two new modules: ‘inspect.py’, a module for
     getting information about live Python code, and ‘pydoc.py’, a
     module for interactively converting docstrings to HTML or text.  As
     a bonus, ‘Tools/scripts/pydoc’, which is now automatically
     installed, uses ‘pydoc.py’ to display documentation given a Python
     module, package, or class name.  For example, ‘pydoc xml.dom’
     displays the following:

          Python Library Documentation: package xml.dom in xml

          NAME
              xml.dom - W3C Document Object Model implementation for Python.

          FILE
              /usr/local/lib/python2.1/xml/dom/__init__.pyc

          DESCRIPTION
              The Python mapping of the Document Object Model is documented in the
              Python Library Reference in the section on the xml.dom package.

              This package contains the following modules:
                ...

     ‘pydoc’ には TK ベースの対話的ヘルプブラウザも含まれています。
     ‘pydoc’ はすぐに病みつきになります。お試しあれ。

   * Two different modules for unit testing were added to the standard
     library.  The *note doctest: 31. module, contributed by Tim Peters,
     provides a testing framework based on running embedded examples in
     docstrings and comparing the results against the expected output.
     PyUnit, contributed by Steve Purcell, is a unit testing framework
     inspired by JUnit, which was in turn an adaptation of Kent Beck's
     Smalltalk testing framework.  See ‘https://pyunit.sourceforge.net/’
     for more information about PyUnit.

   * The *note difflib: 2f. module contains a class, *note
     SequenceMatcher: fe4, which compares two sequences and computes the
     changes required to transform one sequence into the other.  For
     example, this module can be used to write a tool similar to the
     Unix ‘diff’ program, and in fact the sample program
     ‘Tools/scripts/ndiff.py’ demonstrates how to write such a script.

   * *note curses.panel: 25. はパネルライブラリへのラッパーであり、
     ncurses と SYSV curses の一部であり、 Thomas Gellekum により寄稿さ
     れました。パネルライブラリは深さ(depth)の追加機能を持つウィンドウを
     提供しています。ウィンドウは深さ順での高い方、低い方に移動出来、パ
     ネルライブラリはパネルがどこで重なるか、区域のどちらが可視かを理解
     します。

   * The PyXML package has gone through a few releases since Python 2.0,
     and Python 2.1 includes an updated version of the *note xml: 107.
     package.  Some of the noteworthy changes include support for Expat
     1.2 and later versions, the ability for Expat parsers to handle
     files in any encoding supported by Python, and various bugfixes for
     SAX, DOM, and the ‘minidom’ module.

   * Ka-Ping Yee は未捕捉の例外を処理するもうひとつのフックも寄稿しまし
     た。 *note sys.excepthook(): 7d6. には呼び出し可能オブジェクトをセ
     ット出来ます。例外がどの *note try: 6b4...*note except: 170. にも捕
     捉されない場合に、例外は *note sys.excepthook(): 7d6. に通されて、
     そこで好きなことを何でも出来ます。9 回目の Python カンファレンスに
     おいて、Ping はこのフックを使ったアプリケーションのデモを行いました
     。そこでは、スタックフレームを列挙するだけでなくそれぞれのフレーム
     での関数の引数とローカル変数の列挙も行う拡張トレースバックの表示を
     していました。

   * Various functions in the *note time: d7. module, such as *note
     asctime(): 11b8. and *note localtime(): 14a2, require a
     floating-point argument containing the time in seconds since the
     epoch.  The most common use of these functions is to work with the
     current time, so the floating-point argument has been made
     optional; when a value isn't provided, the current time will be
     used.  For example, log file entries usually need a string
     containing the current time; in Python 2.1, ‘time.asctime()’ can be
     used, instead of the lengthier
     ‘time.asctime(time.localtime(time.time()))’ that was previously
     required.

     この変更は Thomas Wouters により提案され、実装されました。

   * *note ftplib: 54. モジュールがデフォルトでパッシブモードでファイル
     を取得するようになりました。これはパッシブモードがファイアウォール
     配下ではより良く動作するようだからです。この要望は Debian のバグト
     ラッキングシステムから起こりました。ほかの Debian パッケージがファ
     イル取得に *note ftplib: 54. を使い、ファイアウォールの元で動作しな
     かったのです。このことが誰かの問題になるとは思えません。Netscape の
     デフォルトがパッシブモードですし、苦情を言う人々も稀でした。ですが
     もしもパッシブモードがあなたのアプリケーションやネットワーク構成に
     とって不適切である場合には、FTP オブジェクトの ‘set_pasv(0)’ を呼び
     出して、パッシブモードを無効にしてください。

   * *note socket: b8. モジュールに、Grant Edwards により寄稿された、生
     のソケットへのアクセスのサポートが追加されました。

   * *note pstats: 9e. モジュールに、Python プログラムの時間計測プロファ
     イルを表示する単純な対話的統計ブラウザが含まれるようになり、これは
     モジュールがスクリプトとして実行された場合に呼び出されます。Eric S.
     Raymond によって寄稿されました。

   * 実装依存の関数ですが ‘sys._getframe([depth])’ が、現在の呼び出しス
     タックより、指定したフレームオブジェクトを返すものとして追加されま
     した。 *note sys._getframe(): 6ac. は呼び出しスタックの一番上のフレ
     ームを返します。オプショナルな整数引数 'depth' を与えると、関数はス
     タックの一番上から下 'depth' ぶんの呼び出しのフレームを返します。例
     えば ‘sys._getframe(1)’ は呼び出し元のフレームオブジェクトを返しま
     す。

     この関数は CPython のみに含まれ、 Jython や .NET 実装にはありません
     。デバッグのためだけに用い、製品コード内にこれを書いてしまう誘惑に
     打ち克ってください。


File: python.info,  Node: その他の変更と修正<4>,  Next: 謝辞<7>,  Prev: 新しいモジュールと改良されたモジュール<4>,  Up: What's New in Python 2 1

1.21.14 その他の変更と修正
--------------------------

短めのリリースサイクルだったため Python 2.1 では比較的少ない変更でした。
CVS 変更ログの検索では 117 のパッチ適用と 136 のバグフィックスが見つかり
ます。ともに少なく見積もっています。いくつかの注目に値する変更を紹介しま
す:

   * A specialized object allocator is now optionally available, that
     should be faster than the system ‘malloc()’ and have less memory
     overhead.  The allocator uses C's ‘malloc()’ function to get large
     pools of memory, and then fulfills smaller memory requests from
     these pools.  It can be enabled by providing the ‘--with-pymalloc’
     option to the ‘configure’ script; see ‘Objects/obmalloc.c’ for the
     implementation details.

     Authors of C extension modules should test their code with the
     object allocator enabled, because some incorrect code may break,
     causing core dumps at runtime.  There are a bunch of memory
     allocation functions in Python's C API that have previously been
     just aliases for the C library's ‘malloc()’ and ‘free()’, meaning
     that if you accidentally called mismatched functions, the error
     wouldn't be noticeable.  When the object allocator is enabled,
     these functions aren't aliases of ‘malloc()’ and ‘free()’ any more,
     and calling the wrong function to free memory will get you a core
     dump.  For example, if memory was allocated using *note PyMem_New:
     14ce, it has to be freed using *note PyMem_Del(): 14cf, not
     ‘free()’.  A few modules included with Python fell afoul of this
     and had to be fixed; doubtless there are more third-party modules
     that will have the same problem.

     オブジェクトアロケータは Vladimir Marangozov により寄稿されました。

   * The speed of line-oriented file I/O has been improved because
     people often complain about its lack of speed, and because it's
     often been used as a naïve benchmark.  The *note readline(): a8.
     method of file objects has therefore been rewritten to be much
     faster.  The exact amount of the speedup will vary from platform to
     platform depending on how slow the C library's ‘getc()’ was, but is
     around 66%, and potentially much faster on some particular
     operating systems.  Tim Peters did much of the benchmarking and
     coding for this change, motivated by a discussion in
     comp.lang.python.

     A new module and method for file objects was also added,
     contributed by Jeff Epler.  The new method, ‘xreadlines()’, is
     similar to the existing ‘xrange()’ built-in.  ‘xreadlines()’
     returns an opaque sequence object that only supports being iterated
     over, reading a line on every iteration but not reading the entire
     file into memory as the existing ‘readlines()’ method does.  You'd
     use it like this:

          for line in sys.stdin.xreadlines():
              # ... do something for each line ...
              ...

     ライン I/O の変更についての詳しい説明は、
     ‘https://mail.python.org/pipermail/python-dev/2001-January/’ にある
     2001 年 1 月 1-15 日の python-dev のまとめをご覧ください。

   * A new method, *note popitem(): 14d0, was added to dictionaries to
     enable destructively iterating through the contents of a
     dictionary; this can be faster for large dictionaries because
     there's no need to construct a list containing all the keys or
     values.  ‘D.popitem()’ removes a random ‘(key, value)’ pair from
     the dictionary ‘D’ and returns it as a 2-tuple.  This was
     implemented mostly by Tim Peters and Guido van Rossum, after a
     suggestion and preliminary patch by Moshe Zadka.

   * ‘from module import *’ を使ってインポートする際にインポートされる名
     前を制御出来るようになりました。インポートされるべき名前のリストを
     含む ‘__all__’ 属性を定義することでこれを行えます。一つのよくある不
     平が、 *note sys: c3. や *note string: be. のように、ほかのモジュー
     ルをモジュールがインポートする場合に、 ‘from module import *’ がイ
     ンポートしているモジュールの名前空間内にそれらを追加することです。
     これをフィックスするには、 ‘__all__’ に公開名を単に列挙します:

          # List public names
          __all__ = ['Database', 'open']

     このパッチのより厳密な版が最初に示唆されて Ben Wolfson により実装さ
     れましたが、python-dev でのいくつかの議論を経てからより弱い最終版が
     チェックインされました。

   * 文字列に *note repr(): 7c8. を適用するとこれまでは表示出来ない文字
     について、8 進エスケープが使われていました。例えば改行コードは
     ‘'\012'’ でした。これは Python の起源である C に追従した名残ですが
     、こんにちでは普段使いで 8 進エスケープが使われることは非常に少なく
     なりました。Ka-Ping Yee が 8 進の代わりに 16 進を使いつつ相応の文字
     には ‘\n’, ‘\t’, ‘\r’ などのエスケープを使うよう示唆し、この新しい
     書式化を実装しました。

   * コンパイル時点で検出される構文エラーがエラーとなったファイル名と行
     番号を含む例外を送出できるようになり、またこれによりコンパイラの再
     編成という喜ばしい副作用がありました。Jeremy Hylton により達成され
     ました。

   * C extensions which import other modules have been changed to use
     *note PyImport_ImportModule(): 398, which means that they will use
     any import hooks that have been installed.  This is also encouraged
     for third-party extensions that need to import some other module
     from C code.

   * Unicode 文字データベースのサイズが Fredrik Lundh のおかげでさらに
     340K だけ小さくなりました。

   * いくつかの新たなポートの寄与: MacOS X (by Steven Majewski), Cygwin
     (by Jason Tishler); RISCOS (by Dietmar Schwertberger); Unixware 7
     (by Billy G. Allie).

そしてよくあるマイナーなバグフィックス、マイナーなメモリリーク、ドキュメ
ンテーション文字列の編集やほかの微調整があり、全てを列挙するには長過ぎま
す。もし見たいのであれば、CVS ログで完全な詳細を読んで下さい。


File: python.info,  Node: 謝辞<7>,  Prev: その他の変更と修正<4>,  Up: What's New in Python 2 1

1.21.15 謝辞
------------

著者は提案の申し出や修正、様々なこの記事の草稿の助けをしてくれた以下の人
々に感謝します: Graeme Cross, David Goodger, Jay Graves, Michael Hudson,
Marc-André Lemburg, Fredrik Lundh, Neil Schemenauer, Thomas Wouters.


File: python.info,  Node: What's New in Python 2 0,  Next: 変更履歴,  Prev: What's New in Python 2 1,  Up: What's New in Python

1.22 What's New in Python 2.0
=============================


著者: A.M. Kuchling and Moshe Zadka

* Menu:

* はじめに: はじめに<3>.
* Python 1.6 はいかがですか?: Python 1 6 はいかがですか?.
* 新しい開発プロセス::
* Unicode 文字列型: Unicode 文字列型<2>.
* リストの内包表記::
* 累算代入 (Augmented Assignment): 累算代入 Augmented Assignment.
* 文字列メソッド::
* 循環参照のガベージコレクション::
* その他の言語コアの変更::
* Python 2.0 への移植: Python 2 0 への移植.
* 拡張と埋め込みについての変更::
* Distutils; モジュールの簡単インストール: Distutils モジュールの簡単インストール.
* XML モジュール::
* 更新されたモジュール::
* 新しいモジュール::
* IDLE の改善::
* 削除されたモジュール、非推奨となったモジュール::
* 謝辞: 謝辞<8>.


File: python.info,  Node: はじめに<3>,  Next: Python 1 6 はいかがですか?,  Up: What's New in Python 2 0

1.22.1 はじめに
---------------

新 Python リリース、バージョン 2.0 は、2000 年 10 月 16 日にリリースされ
ました。この記事では 2.0 のエキサイティングな新機能をカバーし、いくつか
の有用な変更点をハイライトし、少しの、コードの書き換えを要する互換性のな
い変更点について指摘します。

Python の開発は、リリースとリリースの間で止まることはなく、バグフィック
スと改善はとめどなく、日夜提出されます。多くのマイナーフィックス、少しの
最適化、ドキュメンテーション文字列の追加、より良いエラーメッセージが 2.0
に仲間入りしました。これら全てを列挙するのは不可能ですが、それは確かに大
事でしょう、全てのリストを見たければ、公に入手可能な CVS ログを調べてく
ださい。この前進は、今やバグ修正に日々を費やすことで報酬を受け取って
PythonLabs のために働く 5 人の開発者、それと SourceForge に移行した結果
改善されたコミュニケーションのおかげです。


File: python.info,  Node: Python 1 6 はいかがですか?,  Next: 新しい開発プロセス,  Prev: はじめに<3>,  Up: What's New in Python 2 0

1.22.2 Python 1.6 はいかがですか?
---------------------------------

Python 1.6 は「推定的義務」の Python リリースと考えることが出来ます。
2000 年 5 月にコア開発チームが CNRI を離れたあと、CNRI は Python にかか
る作業全てが CNRI で実施されることを含む 1.6 リリースが作成されることを
リクエストしました。それゆえ Python 1.6 は、最も重要な新機能としての
Unicode サポートを含む、2000 年 5 月の CVS ツリーの状態と同等です。開発
はもちろん 5 月以降も継続されましたので、1.6 ツリーは Python 2.0 との前
方互換を保障するために少しの修正を受け取りました。1.6 はですから、Python
の進化の一部であり、側枝ではありません。

では、あなたは Python 1.6 に興味を示すべきでしょうか?  おそらく答えはノ
ーです。1.6final と 2.0beta1 のリリースは同じ日に行われ (2000 年 9 月 5
日)、Python 2.0 のファイナライズはその一ヶ月かそこらで行われるよう計画さ
れました。もしあなたが保守すべきアプリケーションを持っているならば、1.6
への移行には少しばかりコードの破壊を伴うようです。つまりその修正を行い、
一ヶ月の間に 2.0 への移行による別の破壊ラウンドがやってきます。直接 2.0
に移行したほうが良いでしょう。このドキュメントに記載する、ほとんどの面白
い機能は 2.0 のみのものであり、なぜならほとんどの作業は、5 月から 9 月の
間に行われたからなのです。


File: python.info,  Node: 新しい開発プロセス,  Next: Unicode 文字列型<2>,  Prev: Python 1 6 はいかがですか?,  Up: What's New in Python 2 0

1.22.3 新しい開発プロセス
-------------------------

Python 2.0 における最も重要な変化はコードに対するものではまったくなくて
、Python がどのように開発されるのかについてでしょう: 2000 年 5 月に
Python 開発者たちは、ソースコード格納、バグ報告の追跡、パッチ提出の待ち
行列管理のための SourceForge によって利用出来るようになったツールの使用
を始めました。Python 2.0 ではバグ報告やパッチの提出には、Python プロジェ
クトページで利用可能なバグトラッキングとパッチ管理ツールを使ってください
。 ‘https://sourceforge.net/projects/python/’ にあります(訳注: 2015 年現
在の状況は What's New in Python 2.6 参照)。

SourceForge で現在ホストされているサービスの中で最も重要なのは Python
CVS ツリーで、Python のソースコードを含む、バージョンコントロールされた
レポジトリです。以前までは、CVS ツリーへの書き込み許可を持つ人々が 7 人
ほどいて、全てのパッチはその中の一人が精査とチェックをする必要がありまし
た。明らかにこれはスケーラブルではありませんでした。CVS ツリーを
SourceForge に移動することで、より多くの人々に書き込み許可を与えることが
可能になりました; 2000 年 9 月時点で、27 人の人々が変更をチェックイン出
来るようになっていました。これは 4 倍の増加です。これは大規模な変更、こ
れまでであれば小さなコア開発グループによるフィルタを経由しなければならな
いために試みられなかったような、大規模な変更を可能にしています。例えばあ
る日 Peter Schneider-Kamp は K&R C 互換を落としてしまうことを思い立ち、
Python の C ソースを ANSI C に変換しました。python-dev メーリングリスト
での承認を得たのち、彼は立て続けにチェックインを開始しておよそ一週間ほど
で終わらせ、ほかの開発者たちも手助けに参加し、そして作業は完了しました。
書き込み許可が 5 人だけだったならば、おそらくそのタスクはこう見做された
でしょう:「素晴らしい。けれども時間と労力に見合わない」。そして決して実
現することはなかったことでしょう。

SourceForge のサービスを使うことへのシフトは、開発の目覚しいスピードアッ
プをもたらしました。パッチはいまや、提出され、コメントされ、提出者以外の
別人によって改定されて戻ってきて、などなどが、パッチがチェックインの価値
があると判断されるまで行われています。バグは唯一つの中央保管庫で追跡され
、修正には特定の誰かを割り当てることが出来、そして私たちはオープンバグを
進捗の指標として考えることが出来ます。これは代償なしでは達成しませんでし
た; 開発者には今や以前よりもたくさんの処理すべき電子メールがあり、より多
くメーリングリストに追従しなければならず、そして新しい環境のための特別な
ツールを要しました。例えば、SourceForge はデフォルトでパッチ提出とバグ報
告を電子メールで通知しますが、これは全く助けにならないもので、Ka-Ping
Yee はもっと有用なメッセージを送信するための HTML スクリーンスクレイパを
書きました。

簡単にコードを追加出来るようになったことは、当初少し苦痛を大きくしました
。例えばコードが不十分なままだったり、開発グループからのはっきりとした承
諾のないままチェックインされたりするといったことです。浮上してきた承認プ
ロセスは、Apache グループが使っているようなものにいくらか似たものです。
開発者たちは +1, +0, -0, -1 というふうにパッチに投票できます; +1 と -1 は
承諾、却下を表し、+0 と -0 は、開発者は変更にほとんど興味がないけれども
やや肯定、否定の傾向であることを意味します。Apache モデルからの最も大き
な違いは、投票行為は本質的に助言であって、優しい終身独裁者 Guido van
Rossum 侯に大衆の民意を伝えるものであることです。彼は投票結果をそれでも
無視出来ますし、コミュニティが異論を唱えようが変更を承認したり却下したり
出来ます。

実際のパッチの作成は新機能の追加での最後のステップであり、通常、良いデザ
インを工面する前のタスクと容易に比較出来ます。一方で新機能についての議論
はしばしばメーリングリストでの長大なスレッドを巻き起こし、議論に追いつく
のが大変になり、そして誰も python-dev の投稿全てを読めません。それゆえに
、Python 拡張提案 (Python Enhancement Proposals: PEPs)を書く、相対的に形
式ばったプロセスが、始動しました。インターネットの RFC をモデルにしたも
のです。PEPs は新機能提案を記述した草案文書であり、コミュニティの合意と
して提案が承認されるか却下されるまで継続的に改定されます。 PEP 1(1) の導
入部、"PEP の目的とガイドライン" から引用します:

     PEP は Python Enhancement Proposal を意味します。PEP は、Python コ
     ミュニティに対して情報を提供する、あるいは Python の新機能について
     記述する設計文書です。PEP は、機能についての技術的な仕様とその機能
     の論拠(理論)を簡潔に伝えるべきです。

     私たちは PEP が新機能提案にかかる、コミュニティによる問題提起の集積
     と Python になされる設計決断の文書化のための最上位の機構となること
     を意図しています。PEP の著者にはコミュニティ内の合意形成を行うこと
     、反対意見を文書化することの責務があります。

PEP の編集に関するプロセス、様式、体裁についての詳細が PEP 1(2) の残りの
部分に書かれています。PEPs は SourceForge 上の Python CVS ツリーで営まれ
ますが Python 2.0 配布物の一部ではなく、 ‘https://peps.python.org/’ で
HTML 形式で利用可能です。2000 年 9 月時点で PEP 201(3) の "Lockstep
Iteration" から PEP 225 の "Elementwise/Objectwise Operators" までの 25
の PEP があります。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0001/

   (2) https://peps.python.org/pep-0001/

   (3) https://peps.python.org/pep-0201/


File: python.info,  Node: Unicode 文字列型<2>,  Next: リストの内包表記,  Prev: 新しい開発プロセス,  Up: What's New in Python 2 0

1.22.4 Unicode 文字列型
-----------------------

Python 2.0 での最大の新機能は新しい基礎データ型、Unicode 文字列です。
Unicode は文字を表現するのに ASCII で使用される 8 ビット数の代わりに 16
ビットを使います。これによって 65,536 の個別の文字がサポート出来ます。
(--訳注: Unicode の扱いはまず Python 2.2 で UCS4 が使えるように拡張され
(つまり 32 ビットに拡張)、Python 3 では Unicode が唯一の文字列型に変更さ
れています。後者の変更点は非常に大きいですが、クックブックの「Python 2 か
ら Python 3 への移植」に比較的よくまとめられています。--)

最終的な Unicode サポートに関するインターフェイスは、python-dev メーリン
グリストにおける数え切れない、時として嵐のような議論を経て、Fredrik
Lundh によって実装された Unicode 文字列型に基づいて、ほとんどが
Marc-André Lemburg によって実装されました。インターフェイスについての詳
細な説明は PEP 100(1) 「Python Unicode の統合」に記述されました。今ここ
では、Unicode インターフェイスについて、一番重要な点を単純にカバーするだ
けにしましょう。

Python ソースコード内では Unicode 文字列は ‘u"string"’ のように書きます
。任意の Unicode 文字は新しく追加されたエスケープシーケンスで書きます。
‘\uHHHH’ のように書き、 'HHHH' は 0000 から FFFF までの 4 桁の 16 進表記
数です。以前からあるエスケープシーケンス ‘\xHH’ も使えますし、8 進表記も
、 ‘\777’ で表現される U+01FF までの文字に使えます。

Unicode 文字列は普通の文字列と全く似ていて、 *note immutable: 1272. なシ
ーケンス型です。添え字でアクセス出来、スライス出来ますが、インプレイスに
変更することは出来ません。Unicode 文字列は ‘encode( [encoding] )’ メソッ
ドを持っていて、これは望みのエンコーディングでエンコードした 8 ビット文
字列を返します。エンコーディングは文字列で名前付けられていて、例えば
‘'ascii'’, ‘'utf-8'’, ‘'iso-8859-1'’ のようなものです。コーデック API は
、新しいエンコーディングを実装し、Python プログラム全体を通して利用可能
となるよう登録するために定義されています。エンコーディングが指定されない
場合はデフォルトのエンコーディングは普通 7 ビット ASCII ですが、Python イ
ンストレーションにおいて、 ‘site.py’ のカスタマイズ版内で
‘sys.setdefaultencoding(encoding)’ を呼び出すことで変更出来ます。

8 ビット文字列と Unicode 文字列を結合すると常に、デフォルトの ASCII エン
コーディングを使って Unicode に型変換されます。 ‘'a' + u'bc'’ の結果は
‘u'abc'’ になります。

新たなビルトイン関数が追加され、既存のビルトイン関数も Unicode サポート
のために修正されました:

   * ‘unichr(ch)’ は Unicode におけるコードが整数 'ch' になるような文字
     1 文字からなる Unicode 文字列を返します。

   * 'u' が 1 文字の通常文字あるいは Unicode 文字として、 ‘ord(u)’ はコ
     ードを整数で返します。

   * ‘unicode(string [, encoding] [, errors] )’ は、8 ビット文字列から
     Unicode 文字列を作ります。 ‘encoding’ は使用するエンコーディング名
     の文字列です。 ‘errors’ パラメータは、現在エンコーディングにおいて
     不正な文字の扱いを指示します; これに値として ‘'strict'’ を渡すと全
     てのエンコーディングエラーに対し、例外を引き起こします。 ‘'ignore'’
     を渡すとエラーは黙って無視されます。 ‘'replace'’ を渡すと、全ての問
     題ケースで、公式な置き換え文字である U+FFFD に置き換えます。

   * ‘exec’ 文や　‘eval()’, ‘getattr()’, ‘setattr()’ のような色々なビル
     トインも、普通の文字列同様に Unicode 文字列を受け付けるようになりま
     した。(この修正をするプロセスをいくつかのビルトインで忘れている可能
     性もあります。文字列を受け取るものが Unicode を全く受け取らないビル
     トインを見つけたら、バグとして報告してください。)

新規モジュール *note unicodedata: ee. は、Unicode 文字の特性へのインター
フェイスを提供します。例えば ‘unicodedata.category(u'A')’ は 2 文字の文
字列 'Lu' を返しますが、これは、 'L' が letter を、 'u' が uppercase を
表します。 ‘unicodedata.bidirectional(u'\u0660')’ は 'AN' を返し、これは
U+0660 が Arabic Number であることを表します。

*note codecs: 14. モジュールには、既存のエンコーディングをルックアップす
る関数、新しいエンコーディングを登録する関数が含まれます。新しいエンコー
ディングを実装したいと思うのでない限りは、一番使うことになるのは
‘codecs.lookup(encoding)’ でしょう。これは 4 要素のタプルを返します:
‘(encode_func, decode_func, stream_reader, stream_writer)’ 。

   * 'encode_func' は、Unicode 文字列を受け取って 2 要素タプル ‘(string,
     length)’ を返す関数です。 'string' は、与えられたエンコーディングで
     Unicode 文字列を変換した部分 (おそらく全体) を含む 8 ビット文字列で
     、 'length' は何文字の Unicode 文字列が変換されたかを伝えます。

   * 'decode_func' は 'encode_func' の対となる関数で、8 ビット文字列を受
     け取って、2 要素のタプル ‘(ustring, length)’ を返します。 'ustring'
     が結果の Unicode 文字列で、整数 'length' が、8 ビット文字列何文字が
     消費されたかを表します。

   * 'stream_reader' is a class that supports decoding input from a
     stream.  'stream_reader(file_obj)' returns an object that supports
     the ‘read()’, ‘readline()’, and ‘readlines()’ methods.  These
     methods will all translate from the given encoding and return
     Unicode strings.

   * 'stream_writer', similarly, is a class that supports encoding
     output to a stream.  'stream_writer(file_obj)' returns an object
     that supports the ‘write()’ and ‘writelines()’ methods.  These
     methods expect Unicode strings, translating them to the given
     encoding on output.

例えば以下のコードは Unicode 文字列を UTF-8 でエンコーディングしてファイ
ルに書きます:

     import codecs

     unistr = u'\u0660\u2000ab ...'

     (UTF8_encode, UTF8_decode,
      UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8')

     output = UTF8_streamwriter( open( '/tmp/output', 'wb') )
     output.write( unistr )
     output.close()

そして以下コードではファイルから UTF-8 で読めます:

     input = UTF8_streamreader( open( '/tmp/output', 'rb') )
     print repr(input.read())
     input.close()

*note re: a7. モジュールでは Unicode 対応した正規表現が利用可能で、これ
は新しい根底となる SRE なる実装から成り、Secret Labs AB の Fredrik Lundh
によって書かれました。

Python コンパイラに全ての文字列リテラルを Unicode 文字列として解釈させる
ための ‘-U’ コマンドラインオプションが追加されました。これはあなたの
Python コードのテストと将来の保障を意図しています。というのも、将来の
Python バージョンでは 8 ビット文字列のサポートがなくなって、Unicode 文字
列だけとなる予定だからです。 (--訳注: ここで言っている将来バージョンとは
、結果的には Python 3 になりました。What's New での明記はないのですが
‘-U’ オプションは Python 2.7 時点では存在していません。ですが同じことは
2.6 以降では ‘from __future__ import unicode_literals’ で出来ます。 --)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0100/


File: python.info,  Node: リストの内包表記,  Next: 累算代入 Augmented Assignment,  Prev: Unicode 文字列型<2>,  Up: What's New in Python 2 0

1.22.5 リストの内包表記
-----------------------

リストというのは Python の主要なデータ型で、多くのプログラムがリストをい
つかは操るものです。リストの操作での 2 つのよくある操作は、それらについ
てループし、あるいは特定の基準に合致したものを取り出すか個々の要素にある
関数を適用するかする、といったものです。例えば文字列のリストが与えられた
場合、特定の部分文字列を含む全ての文字列を引き抜いたり、あるいは各行から
末尾の空白を取り除いたりしたいでしょう。

既にあった *note map(): 82f. 関数、 *note filter(): 830. 関数がこの目的
のためには使えますが、それらにはその引数の一つに関数が必要です。何か既存
のビルトイン関数で直接渡せるものがあればよいのですが、これがない場合その
必要とされる仕事をする小さな関数を作る必要があって、また、Python のスコ
ープ規則によって、その小さな関数が何かほかの情報を必要とする場合に醜いも
のになります。前パラグラフでの最初の例を考えましょう。指定の部分文字列を
含む文字列リストから全てを探す例です。このように書けるでしょう:

     # Given the list L, make a list of all strings
     # containing the substring S.
     sublist = filter( lambda s, substring=S:
                          string.find(s, substring) != -1,
                       L)

Python のスコープ規則のために、 *note lambda: 126d. 式で作っている匿名関
数にデフォルト引数を使い、これに検索対象の部分文字列を渡しています。リス
ト内包表記はこれを明快にします:

     sublist = [ s for s in L if string.find(s, S) != -1 ]

リスト内包表記は以下の形式を持ちます:

     [ expression for expr in sequence1
                  for expr2 in sequence2 ...
                  for exprN in sequenceN
                  if condition ]

‘for’...‘in’ 節はイテレートするシーケンスを含みます。シーケンス群は同じ
長さである必要はありません。それらは並列でイテレートされる 'のではなく'
左から右の順で周ります。続くパラグラフでもっとわかりやすく説明します。生
成されるリストの要素は一連の 'expression' の値となります。最後の *note
if: 2ca. 節はオプショナルです。これがあれば 'expression' は 'condition'
が真の場合にのみ評価・追加されます。

セマンティクスについてとてもわかりやすく説明しておきましょう。リスト内包
は以下の Python コードと等価です:

     for expr1 in sequence1:
         for expr2 in sequence2:
         ...
             for exprN in sequenceN:
                  if (condition):
                       # Append the value of
                       # the expression to the
                       # resulting list.

つまり、複数の ‘for’...‘in’ 節があって ‘if’ がないときの最終出力は、長さ
が各シーケンス長の積に等しくなるということです。長さ 3 のリスト二つなら
、出力リストの長さは 9 要素です:

     seq1 = 'abc'
     seq2 = (1,2,3)
     >>> [ (x,y) for x in seq1 for y in seq2]
     [('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2), ('b', 3), ('c', 1),
     ('c', 2), ('c', 3)]

Python の文法に曖昧さを紛れ込ませないように、'expression' でタプルを作る
なら括弧で囲わなくてはなりません。下にあるリスト内包表記で、最初のは構文
エラーですが、二番目は有効です:

     # Syntax error
     [ x,y for x in seq1 for y in seq2]
     # Correct
     [ (x,y) for x in seq1 for y in seq2]

リスト内包表記のアイディアは、もともとは関数型プログラミング言語 Haskell
(‘https://www.haskell.org’) に由来しています。Greg Ewing が Python にこ
れを追加することを最も実際的に主張し、彼が最初のリスト内包のパッチを書き
ました。それは傍目には終わりのない議論が python-dev メーリングリストにて
続き、Skip Montanaro によって最新に保たれました。


File: python.info,  Node: 累算代入 Augmented Assignment,  Next: 文字列メソッド,  Prev: リストの内包表記,  Up: What's New in Python 2 0

1.22.6 累算代入 (Augmented Assignment)
--------------------------------------

累算代入はもう一つの長らく待ち望まれた機能であり、Python 2.0 に追加され
ました。累算代入演算子には ‘+=’, ‘-=’, ‘*=’ などがあります。例えばステー
トメント ‘a += 2’ は変数 ‘a’ に 2 を加算し、これはちょっとだけ長い記述
‘a = a + 2’ と同じです。

The full list of supported assignment operators is ‘+=’, ‘-=’, ‘*=’,
‘/=’, ‘%=’, ‘**=’, ‘&=’, ‘|=’, ‘^=’, ‘>>=’, and ‘<<=’.  Python classes
can override the augmented assignment operators by defining methods
named ‘__iadd__()’, ‘__isub__()’, etc.  For example, the following
‘Number’ class stores a number and supports using += to create a new
instance with an incremented value.

     class Number:
         def __init__(self, value):
             self.value = value
         def __iadd__(self, increment):
             return Number( self.value + increment)

     n = Number(5)
     n += 3
     print n.value

The ‘__iadd__()’ special method is called with the value of the
increment, and should return a new instance with an appropriately
modified value; this return value is bound as the new value of the
variable on the left-hand side.

累算代入演算子は最初に C 言語で導入されて、 ‘awk’, C++, Java, Perl, PHP
といった C から派生した言語のほとんどでサポートされています。累算代入の
パッチは Thomas Wouters により実装されました。


File: python.info,  Node: 文字列メソッド,  Next: 循環参照のガベージコレクション,  Prev: 累算代入 Augmented Assignment,  Up: What's New in Python 2 0

1.22.7 文字列メソッド
---------------------

Until now string-manipulation functionality was in the *note string: be.
module, which was usually a front-end for the ‘strop’ module written in
C. The addition of Unicode posed a difficulty for the ‘strop’ module,
because the functions would all need to be rewritten in order to accept
either 8-bit or Unicode strings.  For functions such as
‘string.replace()’, which takes 3 string arguments, that means eight
possible permutations, and correspondingly complicated code.

代わりに、Python 2.0 は問題を文字列型に押し込み、文字列操作機能が 8 ビッ
ト文字列と Unicode 文字列の両方のメソッドを通じて利用可能としました。

     >>> 'andrew'.capitalize()
     'Andrew'
     >>> 'hostname'.replace('os', 'linux')
     'hlinuxtname'
     >>> 'moshe'.find('sh')
     2

変わらない一つのこと、華やかなエイプリルフールのジョークではありませんが
、それは Python 文字列が *note immutable: 1272. だということです。ですの
で文字列メソッドは新しい文字列を返し、それが操作する文字列を変更しません
。

古い *note string: be. モジュールはまだ後方互換性のために残されますが、
それはほとんど新たな文字列メソッドへのフロントエンドとして振舞います。

Two methods which have no parallel in pre-2.0 versions, although they
did exist in JPython for quite some time, are ‘startswith()’ and
‘endswith()’.  ‘s.startswith(t)’ is equivalent to ‘s[:len(t)] == t’,
while ‘s.endswith(t)’ is equivalent to ‘s[-len(t):] == t’.

One other method which deserves special mention is ‘join()’.  The
‘join()’ method of a string receives one parameter, a sequence of
strings, and is equivalent to the ‘string.join()’ function from the old
*note string: be. module, with the arguments reversed.  In other words,
‘s.join(seq)’ is equivalent to the old ‘string.join(seq, s)’.


File: python.info,  Node: 循環参照のガベージコレクション,  Next: その他の言語コアの変更,  Prev: 文字列メソッド,  Up: What's New in Python 2 0

1.22.8 循環参照のガベージコレクション
-------------------------------------

Python の C 実装は、ガーベージコレクションの実装に参照カウントを使ってい
ます。全ての Python オブジェクトは自身を参照している数を維持していて、参
照が作成されたり破壊されたりするカウントを調整しています。参照カウントが
ゼロになればそのオブジェクトにはもはや到達可能ではありません。あなたはそ
れにアクセスするためのオブジェクトへの参照を持つ必要がありますが、カウン
トがゼロならば参照はもはや存在しないということです。

参照カウントはある種望ましい特徴を持っています。それは理解しやすく、実装
しやすく、結果としての実装の移植性は高く、かなり高速であり、そして、独自
のメモリ処理方式を実装しているようなほかのライブラリと共にでも良く振舞い
ます。参照カウントの主要な問題点は、それが時々、オブジェクトにはもう到達
不能であることに気付かないので、結果としてメモリリークを引き起こすことで
す。これは参照の循環がある場合に発生します。

最も単純な循環について考えてみます。クラスインスタンスが自身への参照を持
つ場合です:

     instance = SomeClass()
     instance.myself = instance

上の例の 2 行のコードが実行された後では、 ‘instance’ の参照カウントは 2
です。参照の一つ目は ‘'instance'’ と名付けられた変数からのもので、もう一
つの参照は、インスタンスの ‘myself’ 属性から来るものです。

このあとに続くコードが ‘del instance’ だとしたら、何が起こるでしょうか?
‘instance’ の参照カウントは 1 減るので参照カウントは 1 になります。
‘myself’ 属性内の参照はいまだ存在します。けれどもインスタンスはもう
Python コードからは到達不能ですから、本来削除出来るはずです。お互いを参
照しあうならばいくつものオブジェクトが循環に参加しえるので、結果それら全
てのオブジェクトはリークしてしまいます。

Python 2.0 はこの問題を、循環検出アルゴリズムを周期的に実行することによ
りフィックスします。そのアルゴリズムは、到達不能な循環を探して関係するオ
ブジェクトを削除します。新しく追加された *note gc: 56. モジュールは、ガ
ーベージコレクションを実行する関数、デバッグのための統計情報を取得する関
数、コレクタのパラメータを調整する関数を提供します。

循環検出アルゴリズムの実行はいくらかの時間がかかるので、結果として多少の
追加的なオーバヘッドがかかるでしょう。2.0 を使って循環のコレクションの経
験を積んだのちに、 Python 2.1 では注意深い調整によりオーバヘッドを最小に
出来ることが望まれています。今のところパフォーマンスの損失がいかほどなの
かは明らかではありません。これはこれのベンチマークがトリッキーであり、プ
ログラムがどれだけの頻度でオブジェクトを構築・破棄するのかに大きく依存す
るからです。循環の検出は Python コンパイル時に無効に出来ます。もしもあな
たが小さな速度のペナルティでさえも許容出来ないであるとか、あるいは循環の
コレクションがバギーであることを疑うのであれば、 ‘configure’ スクリプト
実行時に ‘--without-cycle-gc’ スイッチを与えることでそうすることが出来ま
す。 (--訳注: Python 2.3 でこの循環参照の GC は必須となり、
‘--without-cycle-gc’ 、 ‘--with-cycle-gc’ での有無効化は撤廃されました。
--)

何人かの人々がこの問題に体当たりで取り組み、解決に対する貢献をしました。
循環検出アプローチの初期の実装は、Toby Kelsey により書かれました。現在の
アルゴリズムは CNRI を訪れている間に Eric Tiedemann によって提案されて、
Guido van Rossum と Neil Schemenauer が別々の 2 つの実装を書いて、あとで
Neil によって統合されたものです。そこに至るまでにもほかの数多くの人々に
よって提案がなされました。python-dev メーリングリストの 2000 年 3 月のア
ーカイブに、これに関するほとんどの議論が含まれています。特にタイトルが
"Reference cycle collection for Python" と "Finalization again" のスレッ
ドです。


File: python.info,  Node: その他の言語コアの変更,  Next: Python 2 0 への移植,  Prev: 循環参照のガベージコレクション,  Up: What's New in Python 2 0

1.22.9 その他の言語コアの変更
-----------------------------

Python 文法とビルトイン関数について、色々マイナーな変更がなされました。
影響が広範囲に及ぶものは一つもありませんが、手軽で便利なものです。

* Menu:

* 言語のマイナー変更::
* ビルトイン関数の変更::


File: python.info,  Node: 言語のマイナー変更,  Next: ビルトイン関数の変更,  Up: その他の言語コアの変更

1.22.9.1 言語のマイナー変更
...........................

A new syntax makes it more convenient to call a given function with a
tuple of arguments and/or a dictionary of keyword arguments.  In Python
1.5 and earlier, you'd use the ‘apply()’ built-in function: ‘apply(f,
args, kw)’ calls the function ‘f()’ with the argument tuple 'args' and
the keyword arguments in the dictionary 'kw'.  ‘apply()’ is the same in
2.0, but thanks to a patch from Greg Ewing, ‘f(*args, **kw)’ is a
shorter and clearer way to achieve the same effect.  This syntax is
symmetrical with the syntax for defining functions:

     def f(*args, **kw):
         # args is a tuple of positional args,
         # kw is a dictionary of keyword args
         ...

The ‘print’ statement can now have its output directed to a file-like
object by following the ‘print’ with ‘>> file’, similar to the
redirection operator in Unix shells.  Previously you'd either have to
use the ‘write()’ method of the file-like object, which lacks the
convenience and simplicity of ‘print’, or you could assign a new value
to ‘sys.stdout’ and then restore the old value.  For sending output to
standard error, it's much easier to write this:

     print >> sys.stderr, "Warning: action field not supplied"

‘import module as name’ または ‘from module import name as othername’ と
いう構文を使って、インポートするモジュールの名前をリネーム出来るようにな
りました。パッチは Thomas Wouters が投稿しました。

‘%’ 演算子を使う際に新しい書式化スタイルが利用可能です; '%r' はその引数
の *note repr(): 7c8. を挿入します。これは対称性の検討からも考えられまし
た。今の場合は既存の '%s' が引数の *note str(): 418. を挿入することに呼
応するものです。例えば ‘'%r %s' % ('abc', 'abc')’ は文字列 ‘'abc' abc’ を
返します。

Previously there was no way to implement a class that overrode Python's
built-in *note in: 2cb. operator and implemented a custom version.  ‘obj
in seq’ returns true if 'obj' is present in the sequence 'seq'; Python
computes this by simply trying every index of the sequence until either
'obj' is found or an *note IndexError: 14de. is encountered.  Moshe
Zadka contributed a patch which adds a ‘__contains__()’ magic method for
providing a custom implementation for ‘in’.  Additionally, new built-in
objects written in C can define what ‘in’ means for them via a new slot
in the sequence protocol.

以前のバージョンの Python では、オブジェクトの削除に再帰するアルゴリズム
を使っていました。データ構造が深くネストしている場合、インタプリタが C の
スタックを使い果たしてクラッシュしていました。Christian Tismer はこの問
題をフィックスする削除ロジックに書き直しました。これに関係する注目すべき
ものとしては、再帰するオブジェクトの比較が無限再帰してクラッシュしていた
のを、Jeremy Hylton が書き直してクラッシュしないようにして、有用な結果を
生成するようにしたことです。例えば以下コード:

     a = []
     b = []
     a.append(a)
     b.append(b)

The comparison ‘a==b’ returns true, because the two recursive data
structures are isomorphic.  See the thread "trashcan and PR#7" in the
April 2000 archives of the python-dev mailing list for the discussion
leading up to this implementation, and some useful relevant links.  Note
that comparisons can now also raise exceptions.  In earlier versions of
Python, a comparison operation such as ‘cmp(a,b)’ would always produce
an answer, even if a user-defined ‘__cmp__()’ method encountered an
error, since the resulting exception would simply be silently swallowed.

Work has been done on porting Python to 64-bit Windows on the Itanium
processor, mostly by Trent Mick of ActiveState.  (Confusingly,
‘sys.platform’ is still ‘'win32'’ on Win64 because it seems that for
ease of porting, MS Visual C++ treats code as 32 bit on Itanium.)
PythonWin also supports Windows CE; see the Python CE page at
‘https://pythonce.sourceforge.net/’ for more information.

Another new platform is Darwin/MacOS X; initial support for it is in
Python 2.0.  Dynamic loading works, if you specify "configure -with-dyld
-with-suffix=.x".  Consult the README in the Python source distribution
for more instructions.

変数に値が割り当てられる前にローカル変数を参照するコードにおいて、 *note
NameError: 40b. 例外はよく混乱するものであり、この欠点を軽減する試みがな
されました。例えば下に挙げるコードは ‘print’ 文で 1.5.2 と 2.0 の両方で
例外が発生しますが、1.5.2 は *note NameError: 40b. 例外が、2.0 では新規
の例外 *note UnboundLocalError: 14df. が投げられます。 *note
UnboundLocalError: 14df. は *note NameError: 40b. のサブクラスですので
*note NameError: 40b. が投げられることを想定する既存のコードはそのまま動
作するはずです。:

     def f():
         print "i=",i
         i = i + 1
     f()

2 つの新規例外 *note TabError: 50e. と *note IndentationError: 773. が導
入されました。これらはともに *note SyntaxError: 172. のサブクラスで、
Python コードに不適切なインデントが見つかると送出されます。


File: python.info,  Node: ビルトイン関数の変更,  Prev: 言語のマイナー変更,  Up: その他の言語コアの変更

1.22.9.2 ビルトイン関数の変更
.............................

新しいビルトイン関数 ‘zip(seq1, seq2, ...)’ が追加されました。 *note
zip(): 79b. はタプルのリストを返します。それぞれは、引数のシーケンスのそ
れぞれの i 番目要素たちを含むタプルです。 *note zip(): 79b. と
‘map(None, seq1, seq2)’ の違いは、 *note map(): 82f. はシーケンスが同じ
長さを持たない場合に ‘None’ が埋められるのに対し、 *note zip(): 79b. は
返すリストの長さを、引数のシーケンスの最も短い長さに切り詰めます。

The *note int(): 238. and ‘long()’ functions now accept an optional
"base" parameter when the first argument is a string.  ‘int('123', 10)’
returns 123, while ‘int('123', 16)’ returns 291.  ‘int(123, 16)’ raises
a *note TypeError: 502. exception with the message "can't convert
non-string with explicit base".

*note sys: c3. モジュールに、これまでより詳細なバージョン情報を持つ変数
が追加されました。 ‘sys.version_info’ はタプル ‘(major, minor, micro,
level, serial)’ です。例えば仮に 2.0.1beta1 というバージョンだったとすれ
ば、 ‘sys.version_info’ は ‘(2, 0, 1, 'beta', 1)’ となるでしょう。
'level' は ‘"alpha"’ や ‘"beta"’ といった文字列で、最終リリースでは
‘"final"’ です。(--訳注: Python 2.7 で名前付きタプルになっています。また
、その属性名では level ではなく releaselevel です。--)

Dictionaries have an odd new method, ‘setdefault(key, default)’, which
behaves similarly to the existing ‘get()’ method.  However, if the key
is missing, ‘setdefault()’ both returns the value of 'default' as
‘get()’ would do, and also inserts it into the dictionary as the value
for 'key'.  Thus, the following lines of code:

     if dict.has_key( key ): return dict[key]
     else:
         dict[key] = []
         return dict[key]

は、単一の ‘return dict.setdefault(key, [])’ ステートメントだけで書けま
す。

再帰の暴走を C のスタックが埋め尽くされてコアダンプしたり GPF (訳注:
General Protection Fault) する前に捕捉するために、インタプリタは最大の再
帰の深さをセットします。以前まではこの制限は Python コンパイル時点で決め
てしまっていましたが、2.0 では最大の再帰の深さは *note
sys.getrecursionlimit(): 490. と *note sys.setrecursionlimit(): 48f. を
使って読み取れ、修正出来ます。このデフォルトは 1000 です。また、当該プラ
ットフォームでのおよその最大値は、新たに追加されたスクリプト
‘Misc/find_recursionlimit.py’ を実行することで知ることが出来ます。


File: python.info,  Node: Python 2 0 への移植,  Next: 拡張と埋め込みについての変更,  Prev: その他の言語コアの変更,  Up: What's New in Python 2 0

1.22.10 Python 2.0 への移植
---------------------------

新しい Python リリースは以前のリリースとの互換性を保つために苦心していま
すし、その記録はかなり良くなされてきました。ですがいくつかの変更に関して
は、大抵は大きな誤りであると判明した初期デザインを修正するという理由で、
後方互換性を破壊することを必ずしも回避せずに有用性が検討されています。こ
のセクションでは Python 2.0 において、古い Python コードを破壊するかもし
れない変更点について列挙します。

The change which will probably break the most code is tightening up the
arguments accepted by some methods.  Some methods would take multiple
arguments and treat them as a tuple, particularly various list methods
such as ‘append()’ and ‘insert()’.  In earlier versions of Python, if
‘L’ is a list, ‘L.append( 1,2 )’ appends the tuple ‘(1,2)’ to the list.
In Python 2.0 this causes a *note TypeError: 502. exception to be
raised, with the message: 'append requires exactly 1 argument; 2 given'.
The fix is to simply add an extra set of parentheses to pass both values
as a tuple: ‘L.append( (1,2) )’.

The earlier versions of these methods were more forgiving because they
used an old function in Python's C interface to parse their arguments;
2.0 modernizes them to use *note PyArg_ParseTuple(): 53d, the current
argument parsing function, which provides more helpful error messages
and treats multi-argument calls as errors.  If you absolutely must use
2.0 but can't fix your code, you can edit ‘Objects/listobject.c’ and
define the preprocessor symbol ‘NO_STRICT_LIST_APPEND’ to preserve the
old behaviour; this isn't recommended.

*note socket: b8. モジュールのいくつかの関数についてはまだこの方法が許さ
れています。例えば、 ‘socket.connect( ('hostname', 25) )’ が正しい形式な
のですが、 ‘socket.connect('hostname', 25)’ も動作します。*note
socket.connect_ex: 14e2. と *note socket.bind: 1093. も同じようにおおら
かです。2.0alpha1 がそれら関数を厳しくしたのですが、ドキュメントが実際に
は複数引数を取る形式で誤って書かれたために、多くの人々がその厳しくなった
チェックに違反してしまうコードを書いてしまいました。GvR はその変更を、市
民たちの反応を受けて元に戻し、 *note socket: b8. モジュールについてはド
キュメントは修正されて、複数引数形式は非推奨としてマークするに留められま
した。将来バージョンの Python においてこれはもう一度厳しく 'なります' 。
(--訳注: What's New からは読み取れませんが少なくとも 2.7 では単一引数で
しか渡せません。つまり明示的にタプルにして渡す必要があります。--)

文字列リテラル内の ‘\x’ エスケープは、正確に 2 桁の 16 進表記文字になり
ました。以前は 'x' に続く 16 進表記文字全てを消費して最後の 8 ビットを使
っていたため、 ‘\x123456’ は ‘\x56’ と同じでした。

例外 *note AttributeError: 326. と *note NameError: 40b. がよりフレンド
リなエラーメッセージを持つようになっています。それらのテキストは ‘'Spam'
instance has no attribute 'eggs'’ や ‘name 'eggs' is not defined’ のよう
なものになります。以前まではエラーメッセージは存在しない属性名 ‘eggs’ だ
けでしたので、この事実に便乗して書かれたコードは 2.0 では壊れます。

Some work has been done to make integers and long integers a bit more
interchangeable.  In 1.5.2, large-file support was added for Solaris, to
allow reading files larger than 2 GiB; this made the ‘tell()’ method of
file objects return a long integer instead of a regular integer.  Some
code would subtract two file offsets and attempt to use the result to
multiply a sequence or slice a string, but this raised a *note
TypeError: 502.  In 2.0, long integers can be used to multiply or slice
a sequence, and it'll behave as you'd intuitively expect it to; ‘3L *
'abc'’ produces 'abcabcabc', and ‘(0,1,2,3)[2L:4L]’ produces (2,3).
Long integers can also be used in various contexts where previously only
integers were accepted, such as in the ‘seek()’ method of file objects,
and in the formats supported by the ‘%’ operator (‘%d’, ‘%i’, ‘%x’,
etc.).  For example, ‘"%d" % 2L**64’ will produce the string
‘18446744073709551616’.

一番微妙な長整数についての変更は、長整数を *note str(): 418. してももは
や末尾の 'L' 文字が付かないことです。 *note repr(): 7c8. では今でも付く
のにも関わらずです。 'L' は長整数を普通の整数と全く同じように印字したい
多くの人々を悩ませてきました。それを各々自分なりの手段で取り除く必要があ
ったからです。これはもう 2.0 では問題でなくなりましたが、 'L' が付くこと
をあてにして ‘str(longval)[:-1]’ とするコードが今度は数値の最後の桁を失
ってしまいます。

Taking the *note repr(): 7c8. of a float now uses a different formatting
precision than *note str(): 418.  *note repr(): 7c8. uses ‘%.17g’ format
string for C's ‘sprintf()’, while *note str(): 418. uses ‘%.12g’ as
before.  The effect is that *note repr(): 7c8. may occasionally show
more decimal places than *note str(): 418, for certain numbers.  For
example, the number 8.1 can't be represented exactly in binary, so
‘repr(8.1)’ is ‘'8.0999999999999996'’, while str(8.1) is ‘'8.1'’.

The ‘-X’ command-line option, which turned all standard exceptions into
strings instead of classes, has been removed; the standard exceptions
will now always be classes.  The ‘exceptions’ module containing the
standard exceptions was translated from Python to a built-in C module,
written by Barry Warsaw and Fredrik Lundh.


File: python.info,  Node: 拡張と埋め込みについての変更,  Next: Distutils モジュールの簡単インストール,  Prev: Python 2 0 への移植,  Up: What's New in Python 2 0

1.22.11 拡張と埋め込みについての変更
------------------------------------

いくつかの変更点については覆いが被されていて、C 拡張モジュールや大きなア
プリケーションでの Python インタプリタの埋め込みを書く人々からしか見えな
いものです。Python C API を扱う必要がないのであれば、このセクションは読
み飛ばして差し支えありません。

Python C API のバージョン番号がインクリメントされたので、1.5.2 でコンパ
イルされた C 拡張は 2.0 で動作させるために再コンパイルしなければなりませ
ん。Windows では Python 1.5.x でビルドされたサードパーティ拡張を Python
2.0 でインポートすることは、Windows の DLL の仕組みのために、出来ません
。その場合 Python は例外を投げ、インポートは失敗します。(--訳注: この文
章、おかしなことを言っているので一応…。おそらく「Windows の一般市民は C
コンパイラを持っていない」ことが著者の頭にあって、手が滑っているのだと思
います。DLL の動作の仕組みが問題となるのは事実ですが、本質的には Windows
云々はあまり関係ないです。API が変わるか ABI が変わるならプラットフォー
ムに関係なくリコンパイルは常に必要です。 --)

Users of Jim Fulton's ExtensionClass module will be pleased to find out
that hooks have been added so that ExtensionClasses are now supported by
*note isinstance(): 40e. and *note issubclass(): 78c.  This means you no
longer have to remember to write code such as ‘if type(obj) ==
myExtensionClass’, but can use the more natural ‘if isinstance(obj,
myExtensionClass)’.

‘Python/importdl.c’ ファイルが多くの異なるプラットフォームの動的ロードを
サポートするのに大量の #ifdef だらけになっていたのを、Greg Stein が掃除
して再編成しました。 ‘importdl.c’ は今ではとても小さくなり、プラットフォ
ーム依存のコードは ‘Python/dynload_*.c’ ファイル群の束にそれぞれ移動しま
した。もう一つの掃除。include/ ディレクトリ内で色々な移植性のためのハッ
クを施すためのたくさんの ‘my*.h’ ファイルたちが、単一の
‘Include/pyport.h’ にマージされました。

Vladimir Marangozov の手による、待ち望まれた malloc の再編成が完了しまし
た。これは Python インタプリタが C 標準の ‘malloc()’ の代わりにカスタム
アロケータを使うことを容易にするものです。ドキュメントについては
‘Include/pymem.h’ と ‘Include/objimpl.h’ のコメントを読んで下さい。イン
ターフェイスが決着するまでの間の長い長い議論については python.org の
'patches' と 'python-dev' リストのウェブアーカイブをみてください。(--訳
注: この件についての続きの話が What's New in Python 2.3 に Pymalloc とし
て少しわかりやすく記述されています。--)

MacOS の GUSI 開発環境の最近のバージョンは POSIX スレッドをサポートして
います。ですので Python の POSIX スレッディングのサポートは今では
Macintosh で動作します。ユーザ空間での GNU ‘pth’ ライブラリを使ったスレ
ッディングサポートも寄稿されました。

Windows でのスレッディングサポートも拡張されました。Windows は、競合があ
るケースでのみカーネルオブジェクトを使うスレッドロックをサポートしていま
す。競合がない普通のケースではそれらはより単純な関数を使い、これは段違い
に高速です。NT での Python 1.5.2 版でスレッド化すると、非スレッド版の 2
倍遅くなりますが、2.0 に変えるとその差はたった 10% です。これらの改善は
Yakov Markovitch の貢献によるものです。

Python 2.0 のソースが ANSI C プロトタイプだけを使うようになったので、
Python のコンパイルには ANSI C コンパイラが必須になりました。K&R C しか
サポートしないコンパイラではもうコンパイル出来ません。

Previously the Python virtual machine used 16-bit numbers in its
bytecode, limiting the size of source files.  In particular, this
affected the maximum size of literal lists and dictionaries in Python
source; occasionally people who are generating Python code would run
into this limit.  A patch by Charles G. Waldman raises the limit from
‘2**16’ to ‘2**32’.

Three new convenience functions intended for adding constants to a
module's dictionary at module initialization time were added: *note
PyModule_AddObject(): 33f, *note PyModule_AddIntConstant(): 14e4, and
*note PyModule_AddStringConstant(): 14e5.  Each of these functions takes
a module object, a null-terminated C string containing the name to be
added, and a third argument for the value to be assigned to the name.
This third argument is, respectively, a Python object, a C long, or a C
string.

Unix スタイルのシグナルハンドラへのラッパーAPIが追加されました。 *note
PyOS_getsig(): 14e6. でシグナルハンドラを取得し、 *note PyOS_setsig():
14e7. で新しいハンドラをセットします。


File: python.info,  Node: Distutils モジュールの簡単インストール,  Next: XML モジュール,  Prev: 拡張と埋め込みについての変更,  Up: What's New in Python 2 0

1.22.12 Distutils: モジュールの簡単インストール
-----------------------------------------------

Python 2.0 以前は、モジュールのインストールは退屈な作業でした - Python が
どこにインストールされているかや拡張モジュールのコンパイルに必要なオプシ
ョンを自動的に知る方法はありませんでした。ソフトウェアの作者は Makefile
と設定ファイル群の編集という大変な労力を要する儀式を通過しなければならな
いのに、それは実際には Unix だけのためであって Windows と MacOS のサポー
トを置き去りにするものでした。Python ユーザは全く異なったインストール命
令に直面していました。それは拡張パッケージごとに異なり、Python インスト
ールをある種つまらない作業としていました。

The SIG for distribution utilities, shepherded by Greg Ward, has created
the Distutils, a system to make package installation much easier.  They
form the ‘distutils’ package, a new part of Python's standard library.
In the best case, installing a Python module from source will require
the same steps: first you simply mean unpack the tarball or zip archive,
and the run "‘python setup.py install’".  The platform will be
automatically detected, the compiler will be recognized, C extension
modules will be compiled, and the distribution installed into the proper
directory.  Optional command-line arguments provide more control over
the installation process, the distutils package offers many places to
override defaults - separating the build from the install, building or
installing in non-default directories, and more.

Distutils を使うには ‘setup.py’ スクリプトを書く必要があります。単純なケ
ースでは、ソフトウェアが .py ファイルだけを含む場合、最小限の ‘setup.py’
は数行足らずで書けます:

     from distutils.core import setup
     setup (name = "foo", version = "1.0",
            py_modules = ["module1", "module2"])

‘setup.py’ ファイルは、ソフトウェアが少しのパッケージで構成される場合は
これより大きく複雑になることはありません:

     from distutils.core import setup
     setup (name = "foo", version = "1.0",
            packages = ["package", "package.subpackage"])

C 拡張が最も複雑なケースになりえます。以下は PyXML パッケージからもって
きた例です:

     from distutils.core import setup, Extension

     expat_extension = Extension('xml.parsers.pyexpat',
          define_macros = [('XML_NS', None)],
          include_dirs = [ 'extensions/expat/xmltok',
                           'extensions/expat/xmlparse' ],
          sources = [ 'extensions/pyexpat.c',
                      'extensions/expat/xmltok/xmltok.c',
                      'extensions/expat/xmltok/xmlrole.c', ]
            )
     setup (name = "PyXML", version = "0.5.4",
            ext_modules =[ expat_extension ] )

Distutils ではソース配布物、バイナリ配布物の作成の面倒もみてくれます。
"sdist" コマンドは "‘python setup.py sdist’" を実行することで起動し、こ
れは ‘foo-1.0.tar.gz’ のようなソース配布物を作ります。新しいコマンドを作
るのは難しくありません。コマンド "bdist_rpm" と "bdist_wininst" が既に寄
稿されていて、各々 RPM 配布物の作成、Windows インストーラの作成を行いま
す。Debian パッケージや Solaris の ‘.pkg’ のようなほかの配布フォーマット
を作成するコマンドについての開発ステージは様々です。

これら全ては、 Python ドキュメントの基本的なセットとして追加されたマニュ
アル 'Python モジュールの配布' にドキュメントされています。


File: python.info,  Node: XML モジュール,  Next: 更新されたモジュール,  Prev: Distutils モジュールの簡単インストール,  Up: What's New in Python 2 0

1.22.13 XML モジュール
----------------------

Python 1.5.2 included a simple XML parser in the form of the ‘xmllib’
module, contributed by Sjoerd Mullender.  Since 1.5.2's release, two
different interfaces for processing XML have become common: SAX2
(version 2 of the Simple API for XML) provides an event-driven interface
with some similarities to ‘xmllib’, and the DOM (Document Object Model)
provides a tree-based interface, transforming an XML document into a
tree of nodes that can be traversed and modified.  Python 2.0 includes a
SAX2 interface and a stripped-down DOM interface as part of the *note
xml: 107. package.  Here we will give a brief overview of these new
interfaces; consult the Python documentation or the source code for
complete details.  The Python XML SIG is also working on improved
documentation.

* Menu:

* SAX2 サポート::
* DOM サポート::
* PyXML との関係::


File: python.info,  Node: SAX2 サポート,  Next: DOM サポート,  Up: XML モジュール

1.22.13.1 SAX2 サポート
.......................

SAX defines an event-driven interface for parsing XML. To use SAX, you
must write a SAX handler class.  Handler classes inherit from various
classes provided by SAX, and override various methods that will then be
called by the XML parser.  For example, the *note startElement(): 14eb.
and *note endElement(): 14ec. methods are called for every starting and
end tag encountered by the parser, the *note characters(): 14ed. method
is called for every chunk of character data, and so forth.

イベントドリブンのアプローチはドキュメント全体をいっときにメモリに持たな
くて良い点で有利であり、ドキュメントが本当に巨大であるものを処理する際に
はこれは重要です。ですが SAX ハンドラクラスを記述することは、ドキュメン
ト構造を変更しようとする場合にはある種入り組んだものとなって、とても複雑
になりえます。

以下の小さな実例プログラムでは、全ての開始・終了タグでメッセージを印字す
るハンドラを定義して、ファイル ‘hamlet.xml’ をそのハンドラを使ってパース
しています:

     from xml import sax

     class SimpleHandler(sax.ContentHandler):
         def startElement(self, name, attrs):
             print 'Start of element:', name, attrs.keys()

         def endElement(self, name):
             print 'End of element:', name

     # Create a parser object
     parser = sax.make_parser()

     # Tell it what handler to use
     handler = SimpleHandler()
     parser.setContentHandler( handler )

     # Parse a file!
     parser.parse( 'hamlet.xml' )

For more information, consult the Python documentation, or the XML HOWTO
at ‘https://pyxml.sourceforge.net/topics/howto/xml-howto.html’.


File: python.info,  Node: DOM サポート,  Next: PyXML との関係,  Prev: SAX2 サポート,  Up: XML モジュール

1.22.13.2 DOM サポート
......................

The Document Object Model is a tree-based representation for an XML
document.  A top-level ‘Document’ instance is the root of the tree, and
has a single child which is the top-level ‘Element’ instance.  This
‘Element’ has children nodes representing character data and any
sub-elements, which may have further children of their own, and so
forth.  Using the DOM you can traverse the resulting tree any way you
like, access element and attribute values, insert and delete nodes, and
convert the tree back into XML.

DOM は XML ドキュメントを修正するのに有用です。というのも DOM ツリーは作
成出来、新規ノードを追加したりサブツリーを再編成したりすることで修正出来
、出力として新たな XML ドキュメントを生成出来るからです。DOM ツリーを手
動で構築して XML に変換することも出来ます。これにより単純に
‘<tag1>’...‘</tag1>’ をファイルに書くよりも柔軟性の高い方法で XML 出力を
生成出来ます。

The DOM implementation included with Python lives in the *note
xml.dom.minidom: 109. module.  It's a lightweight implementation of the
Level 1 DOM with support for XML namespaces.  The ‘parse()’ and
‘parseString()’ convenience functions are provided for generating a DOM
tree:

     from xml.dom import minidom
     doc = minidom.parse('hamlet.xml')

‘doc’ is a ‘Document’ instance.  ‘Document’, like all the other DOM
classes such as ‘Element’ and ‘Text’, is a subclass of the ‘Node’ base
class.  All the nodes in a DOM tree therefore support certain common
methods, such as ‘toxml()’ which returns a string containing the XML
representation of the node and its children.  Each class also has
special methods of its own; for example, ‘Element’ and ‘Document’
instances have a method to find all child elements with a given tag
name.  Continuing from the previous 2-line example:

     perslist = doc.getElementsByTagName( 'PERSONA' )
     print perslist[0].toxml()
     print perslist[1].toxml()

'Hamlet' XML ファイルに対して上の例は以下のような出力をします:

     <PERSONA>CLAUDIUS, king of Denmark. </PERSONA>
     <PERSONA>HAMLET, son to the late, and nephew to the present king.</PERSONA>

ドキュメントのルートエレメントは ‘doc.documentElement’ として取得出来、
その子は簡単に、ノードを削除したり追加したりすることで修正出来ます:

     root = doc.documentElement

     # Remove the first child
     root.removeChild( root.childNodes[0] )

     # Move the new first child to the end
     root.appendChild( root.childNodes[0] )

     # Insert the new first child (originally,
     # the third child) before the 20th child.
     root.insertBefore( root.childNodes[0], root.childNodes[20] )

Again, I will refer you to the Python documentation for a complete
listing of the different ‘Node’ classes and their various methods.


File: python.info,  Node: PyXML との関係,  Prev: DOM サポート,  Up: XML モジュール

1.22.13.3 PyXML との関係
........................

The XML Special Interest Group has been working on XML-related Python
code for a while.  Its code distribution, called PyXML, is available
from the SIG's web pages at
‘https://www.python.org/community/sigs/current/xml-sig’.  The PyXML
distribution also used the package name ‘xml’.  If you've written
programs that used PyXML, you're probably wondering about its
compatibility with the 2.0 *note xml: 107. package.

結論として、Python 2.0 の *note xml: 107. パッケージは PyXML と互換性が
ありません。ですが、直近バージョンの PyXML をインストールすることで互換
性を持たせることができます。 多くのアプリケーションは Python 2.0 に含ま
れる XML サポートで十分ですが、より複雑なアプリケーションは完全なPyXML パ
ッケージをインストールする必要があります。 インストールされた PyXML バー
ジョン 0.6.0 以上は、Python に同梱されている *note xml: 107. パッケージ
を置き換え、標準パッケージの厳密なスーパーセットとなり、多くの追加機能が
追加されます。 PyXML の追加機能には次のようなものがあります。

   * 4DOM, a full DOM implementation from FourThought, Inc.

   * The xmlproc validating parser, written by Lars Marius Garshol.

   * The ‘sgmlop’ parser accelerator module, written by Fredrik Lundh.


File: python.info,  Node: 更新されたモジュール,  Next: 新しいモジュール,  Prev: XML モジュール,  Up: What's New in Python 2 0

1.22.14 更新されたモジュール
----------------------------

Lots of improvements and bugfixes were made to Python's extensive
standard library; some of the affected modules include *note readline:
a8, *note ConfigParser: 1b, ‘cgi’, *note calendar: 10, *note posix: 9b,
*note readline: a8, ‘xmllib’, ‘aifc’, ‘chunk’, *note wave: fb, *note
random: a6, *note shelve: b1, and ‘nntplib’.  Consult the CVS logs for
the exact patch-by-patch details.

Brian Gallew contributed OpenSSL support for the *note socket: b8.
module.  OpenSSL is an implementation of the Secure Socket Layer, which
encrypts the data being sent over a socket.  When compiling Python, you
can edit ‘Modules/Setup’ to include SSL support, which adds an
additional function to the *note socket: b8. module: ‘socket.ssl(socket,
keyfile, certfile)’, which takes a socket object and returns an SSL
socket.  The *note httplib: 64. and *note urllib: f1. modules were also
changed to support ‘https://’ URLs, though no one has implemented FTP or
SMTP over SSL.

The *note httplib: 64. module has been rewritten by Greg Stein to
support HTTP/1.1.

Backward compatibility with the 1.5 version of ‘httplib’ is provided,
though using HTTP/1.1 features such as pipelining will require rewriting
code to use a different set of interfaces.

The ‘Tkinter’ module now supports Tcl/Tk version 8.1, 8.2, or 8.3, and
support for the older 7.x versions has been dropped.  The Tkinter module
now supports displaying Unicode strings in Tk widgets.  Also, Fredrik
Lundh contributed an optimization which makes operations like
‘create_line’ and ‘create_polygon’ much faster, especially when using
lots of coordinates.

*note curses: 23. モジュールが、Oliver Andrich による拡張版をもとに大規
模に拡張され、ncurses と SYSV curses からの多くの追加機能、例えば色付き
の表示、別の文字集合サポート、パッド、マウスサポートなどをサポートするよ
うになりました。このことは、モジュールが BSD curses だけしか持っていない
OS とは互換性が無いことを意味しますが、現在メンテナンスされている OS で
そういう類のものは無さそうです。

2.0 の Unicode サポートについて前述したように、 *note re: a7. モジュール
で提供される正規表現の根底となる実装が変更されました。SRE は新しい正規表
現エンジンで、Fredrik Lundh によって書かれ、部分的に Hewlett Packard 社
により寄贈されました。これは 8 ビット文字列と Unicode 文字列両方に合致す
るようサポートされています。


File: python.info,  Node: 新しいモジュール,  Next: IDLE の改善,  Prev: 更新されたモジュール,  Up: What's New in Python 2 0

1.22.15 新しいモジュール
------------------------

数多くのモジュールが新しく追加されました。ここではそれらを短い説明ととも
に列挙するだけにします。特定のモジュールの詳細は 2.0 のドキュメントを調
べてください。

   * *note atexit: 9.: Python インタプリタが終了する前に呼び出す関数を登
     録します。これまで ‘sys.exitfunc’ に直接セットしてきたコードは
     *note atexit: 9. モジュールを代わりに用いるように修正してください。
     *note atexit: 9. をインポートし、 *note atexit.register(): 84a. で
     終了時に呼び出す関数を登録します。(Contributed by Skip Montanaro.)

   * *note codecs: 14, ‘encodings’, *note unicodedata: ee.: Added as
     part of the new Unicode support.

   * *note filecmp: 50.: Supersedes the old ‘cmp’, ‘cmpcache’ and
     ‘dircmp’ modules, which have now become deprecated.  (Contributed
     by Gordon MacMillan and Moshe Zadka.)

   * *note gettext: 59.: このモジュールは Python プログラムに、GNU
     gettext メッセージカタログライブラリへのインターフェイスを提供する
     ことで国際化 (I18N=internationalization) と地域化
     (L10N=localization) サポートをもたらします。 (Integrated by Barry
     Warsaw, from separate contributions by Martin von Löwis, Peter
     Funk, and James Henstridge.)

   * ‘linuxaudiodev’: Support for the ‘/dev/audio’ device on Linux, a
     twin to the existing ‘sunaudiodev’ module.  (Contributed by Peter
     Bosch, with fixes by Jeremy Hylton.)

   * *note mmap: 83.: Windows、Unix 両方でのメモリマップドファイルへのイ
     ンターフェイスです。ファイル内容をメモリに直接マッピング出来、それ
     は *note mutable: 1273. な文字列であるかのように振る舞い、これによ
     り読み書き出来ます。それらは例えば *note re: a7. モジュールのような
     普通は文字列を期待するような関数にさえも渡せます。(Contributed by
     Sam Rushing, with some extensions by A.M. Kuchling.)

   * ‘pyexpat’: An interface to the Expat XML parser.  (Contributed by
     Paul Prescod.)

   * *note robotparser: f6.: Parse a ‘robots.txt’ file, which is used
     for writing web spiders that politely avoid certain areas of a web
     site.  The parser accepts the contents of a ‘robots.txt’ file,
     builds a set of rules from it, and can then answer questions about
     the fetchability of a given URL. (Contributed by Skip Montanaro.)

   * *note tabnanny: c7.: Python ソースコードが曖昧なインデントになって
     いないかをチェックするモジュール/スクリプトです。 (Contributed by
     Tim Peters.)

   * ‘UserString’: A base class useful for deriving objects that behave
     like strings.

   * *note webbrowser: fd.: 指定した URL で、プラットフォームに依存しな
     い方法でウェブブラウザを起動するモジュールです。個々のプラットフォ
     ームにおいて様々なブラウザが特定の順序で試されます。ユーザはどのブ
     ラウザを起動するかを環境変数 'BROWSER' をセットすることで変更出来ま
     す。(元々は Eric S. Raymond による *note urllib: f1. への、同じ機能
     追加をするパッチに触発されましたが、最終的なモジュールは Fred Drake
     が元々 ‘Tools/idle/BrowserControl.py’ として実装したものに由来し、
     Fred が標準ライブラリに適合させました。)

   * *note _winreg: fe.: An interface to the Windows registry.
     ‘_winreg’ is an adaptation of functions that have been part of
     PythonWin since 1995, but has now been added to the core
     distribution, and enhanced to support Unicode.  ‘_winreg’ was
     written by Bill Tutt and Mark Hammond.

   * *note zipfile: 117.: ZIP 形式アーカイブの読み書きのためのモジュール
     です。DOS/Windows での ‘PKZIP’ や Unix での ‘zip’ により生成される
     アーカイブで、 ‘gzip’ 形式とは混同しないで下さい (こちらは *note
     gzip: 5d. モジュールによってサポートされています)。(Contributed by
     James C. Ahlstrom.)

   * ‘imputil’: A module that provides a simpler way for writing
     customized import hooks, in comparison to the existing ‘ihooks’
     module.  (Implemented by Greg Stein, with much discussion on
     python-dev along the way.)


File: python.info,  Node: IDLE の改善,  Next: 削除されたモジュール、非推奨となったモジュール,  Prev: 新しいモジュール,  Up: What's New in Python 2 0

1.22.16 IDLE の改善
-------------------

IDLE は公式の Python のクロスプラットフォームな IDE で、 Tkinter を使っ
て書かれています。Python 2.0 では IDLE 0.6 を含めました。これは多くの新
機能追加と改善がなされています。以下はその一部です:

   * UI の、特にシンタックスハイライトと自動インデントの領域において、改
     善と最適化がなされました。

   * クラスブラウザで、例えばモジュール内のトップレベル関数のような、よ
     り多くの情報をみることが出来るようになりました。

   * タブ幅をユーザ制御出来るようになりました。既存の Python ファイルを
     操作する際には、IDLE は自動的にインデントの慣習を検知してそれに合わ
     せます。

   * 色々なプラットフォームでブラウザの呼び出しがサポートされています。
     これを使って、ブラウザで Python ドキュメントを開きます。

   * IDLE がコマンドラインを持つようになりました。これは普通の Python イ
     ンタプリタに大きく似せてあります。

   * 色々な場所でコンテキストヘルプが出るようになっています。

   * IDLE は今ではパッケージとしてインストール出来ます。

   * エディタウィンドウ内では、下部に行/桁を表示するようになっています。

   * 新たな 3 つのキーストロークコマンド: モジュールのチェック
     (‘Alt-F5’)、モジュールのインポート (‘F5’)、スクリプト実行
     (‘Ctrl-F5’).


File: python.info,  Node: 削除されたモジュール、非推奨となったモジュール,  Next: 謝辞<8>,  Prev: IDLE の改善,  Up: What's New in Python 2 0

1.22.17 削除されたモジュール、非推奨となったモジュール
------------------------------------------------------

A few modules have been dropped because they're obsolete, or because
there are now better ways to do the same thing.  The ‘stdwin’ module is
gone; it was for a platform-independent windowing toolkit that's no
longer developed.

A number of modules have been moved to the ‘lib-old’ subdirectory:
‘cmp’, ‘cmpcache’, ‘dircmp’, ‘dump’, ‘find’, ‘grep’, ‘packmail’, ‘poly’,
‘util’, ‘whatsound’, ‘zmod’.  If you have code which relies on a module
that's been moved to ‘lib-old’, you can simply add that directory to
‘sys.path’ to get them back, but you're encouraged to update any code
that uses these modules.


File: python.info,  Node: 謝辞<8>,  Prev: 削除されたモジュール、非推奨となったモジュール,  Up: What's New in Python 2 0

1.22.18 謝辞
------------

著者は提案の申し出や修正、様々なこの記事の草稿の助けをしてくれた以下の人
々に感謝します: David Bolen, Mark Hammond, Gregg Hauser, Jeremy Hylton,
Fredrik Lundh, Detlef Lannert, Aahz Maruch, Skip Montanaro, Vladimir
Marangozov, Tobias Polzin, Guido van Rossum, Neil Schemenauer, and Russ
Schmidt.

"変更履歴" は、 Misc/NEWS.d(1) ディレクトリ以下の内容から ビルドされたフ
ァイル(2) の HTML 版で、現在のバージョンの Python への 'すべての' 重要な
変更が載っています。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Misc/NEWS.d

   (2) https://pypi.org/project/blurb/


File: python.info,  Node: 変更履歴,  Prev: What's New in Python 2 0,  Up: What's New in Python

1.23 変更履歴
=============

* Menu:

* Python next::
* Python 3.13.0 final: Python 3 13 0 final.
* Python 3.13.0 release candidate 3: Python 3 13 0 release candidate 3.
* Python 3.13.0 release candidate 2: Python 3 13 0 release candidate 2.
* Python 3.13.0 release candidate 1: Python 3 13 0 release candidate 1.
* Python 3.13.0 beta 4: Python 3 13 0 beta 4.
* Python 3.13.0 beta 3: Python 3 13 0 beta 3.
* Python 3.13.0 beta 2: Python 3 13 0 beta 2.
* Python 3.13.0 beta 1: Python 3 13 0 beta 1.
* Python 3.13.0 alpha 6: Python 3 13 0 alpha 6.
* Python 3.13.0 alpha 5: Python 3 13 0 alpha 5.
* Python 3.13.0 alpha 4: Python 3 13 0 alpha 4.
* Python 3.13.0 alpha 3: Python 3 13 0 alpha 3.
* Python 3.13.0 alpha 2: Python 3 13 0 alpha 2.
* Python 3.13.0 alpha 1: Python 3 13 0 alpha 1.
* Python 3.12.0 beta 1: Python 3 12 0 beta 1.
* Python 3.12.0 alpha 7: Python 3 12 0 alpha 7.
* Python 3.12.0 alpha 6: Python 3 12 0 alpha 6.
* Python 3.12.0 alpha 5: Python 3 12 0 alpha 5.
* Python 3.12.0 alpha 4: Python 3 12 0 alpha 4.
* Python 3.12.0 alpha 3: Python 3 12 0 alpha 3.
* Python 3.12.0 alpha 2: Python 3 12 0 alpha 2.
* Python 3.12.0 alpha 1: Python 3 12 0 alpha 1.
* Python 3.11.0 beta 1: Python 3 11 0 beta 1.
* Python 3.11.0 alpha 7: Python 3 11 0 alpha 7.
* Python 3.11.0 alpha 6: Python 3 11 0 alpha 6.
* Python 3.11.0 alpha 5: Python 3 11 0 alpha 5.
* Python 3.11.0 alpha 4: Python 3 11 0 alpha 4.
* Python 3.11.0 alpha 3: Python 3 11 0 alpha 3.
* Python 3.11.0 alpha 2: Python 3 11 0 alpha 2.
* Python 3.11.0 alpha 1: Python 3 11 0 alpha 1.
* Python 3.10.0 beta 1: Python 3 10 0 beta 1.
* Python 3.10.0 alpha 7: Python 3 10 0 alpha 7.
* Python 3.10.0 alpha 6: Python 3 10 0 alpha 6.
* Python 3.10.0 alpha 5: Python 3 10 0 alpha 5.
* Python 3.10.0 alpha 4: Python 3 10 0 alpha 4.
* Python 3.10.0 alpha 3: Python 3 10 0 alpha 3.
* Python 3.10.0 alpha 2: Python 3 10 0 alpha 2.
* Python 3.10.0 alpha 1: Python 3 10 0 alpha 1.
* Python 3.9.0 beta 1: Python 3 9 0 beta 1.
* Python 3.9.0 alpha 6: Python 3 9 0 alpha 6.
* Python 3.9.0 alpha 5: Python 3 9 0 alpha 5.
* Python 3.9.0 alpha 4: Python 3 9 0 alpha 4.
* Python 3.9.0 alpha 3: Python 3 9 0 alpha 3.
* Python 3.9.0 alpha 2: Python 3 9 0 alpha 2.
* Python 3.9.0 alpha 1: Python 3 9 0 alpha 1.
* Python 3.8.0 beta 1: Python 3 8 0 beta 1.
* Python 3.8.0 alpha 4: Python 3 8 0 alpha 4.
* Python 3.8.0 alpha 3: Python 3 8 0 alpha 3.
* Python 3.8.0 alpha 2: Python 3 8 0 alpha 2.
* Python 3.8.0 alpha 1: Python 3 8 0 alpha 1.
* Python 3.7.0 final: Python 3 7 0 final.
* Python 3.7.0 release candidate 1: Python 3 7 0 release candidate 1.
* Python 3.7.0 beta 5: Python 3 7 0 beta 5.
* Python 3.7.0 beta 4: Python 3 7 0 beta 4.
* Python 3.7.0 beta 3: Python 3 7 0 beta 3.
* Python 3.7.0 beta 2: Python 3 7 0 beta 2.
* Python 3.7.0 beta 1: Python 3 7 0 beta 1.
* Python 3.7.0 alpha 4: Python 3 7 0 alpha 4.
* Python 3.7.0 alpha 3: Python 3 7 0 alpha 3.
* Python 3.7.0 alpha 2: Python 3 7 0 alpha 2.
* Python 3.7.0 alpha 1: Python 3 7 0 alpha 1.
* Python 3.6.6 final: Python 3 6 6 final.
* Python 3.6.6 release candidate 1: Python 3 6 6 release candidate 1.
* Python 3.6.5 final: Python 3 6 5 final.
* Python 3.6.5 release candidate 1: Python 3 6 5 release candidate 1.
* Python 3.6.4 final: Python 3 6 4 final.
* Python 3.6.4 release candidate 1: Python 3 6 4 release candidate 1.
* Python 3.6.3 final: Python 3 6 3 final.
* Python 3.6.3 release candidate 1: Python 3 6 3 release candidate 1.
* Python 3.6.2 final: Python 3 6 2 final.
* Python 3.6.2 release candidate 2: Python 3 6 2 release candidate 2.
* Python 3.6.2 release candidate 1: Python 3 6 2 release candidate 1.
* Python 3.6.1 final: Python 3 6 1 final.
* Python 3.6.1 release candidate 1: Python 3 6 1 release candidate 1.
* Python 3.6.0 final: Python 3 6 0 final.
* Python 3.6.0 release candidate 2: Python 3 6 0 release candidate 2.
* Python 3.6.0 release candidate 1: Python 3 6 0 release candidate 1.
* Python 3.6.0 beta 4: Python 3 6 0 beta 4.
* Python 3.6.0 beta 3: Python 3 6 0 beta 3.
* Python 3.6.0 beta 2: Python 3 6 0 beta 2.
* Python 3.6.0 beta 1: Python 3 6 0 beta 1.
* Python 3.6.0 alpha 4: Python 3 6 0 alpha 4.
* Python 3.6.0 alpha 3: Python 3 6 0 alpha 3.
* Python 3.6.0 alpha 2: Python 3 6 0 alpha 2.
* Python 3.6.0 alpha 1: Python 3 6 0 alpha 1.
* Python 3.5.5 final: Python 3 5 5 final.
* Python 3.5.5 release candidate 1: Python 3 5 5 release candidate 1.
* Python 3.5.4 final: Python 3 5 4 final.
* Python 3.5.4 release candidate 1: Python 3 5 4 release candidate 1.
* Python 3.5.3 final: Python 3 5 3 final.
* Python 3.5.3 release candidate 1: Python 3 5 3 release candidate 1.
* Python 3.5.2 final: Python 3 5 2 final.
* Python 3.5.2 release candidate 1: Python 3 5 2 release candidate 1.
* Python 3.5.1 final: Python 3 5 1 final.
* Python 3.5.1 release candidate 1: Python 3 5 1 release candidate 1.
* Python 3.5.0 final: Python 3 5 0 final.
* Python 3.5.0 release candidate 4: Python 3 5 0 release candidate 4.
* Python 3.5.0 release candidate 3: Python 3 5 0 release candidate 3.
* Python 3.5.0 release candidate 2: Python 3 5 0 release candidate 2.
* Python 3.5.0 release candidate 1: Python 3 5 0 release candidate 1.
* Python 3.5.0 beta 4: Python 3 5 0 beta 4.
* Python 3.5.0 beta 3: Python 3 5 0 beta 3.
* Python 3.5.0 beta 2: Python 3 5 0 beta 2.
* Python 3.5.0 beta 1: Python 3 5 0 beta 1.
* Python 3.5.0 alpha 4: Python 3 5 0 alpha 4.
* Python 3.5.0 alpha 3: Python 3 5 0 alpha 3.
* Python 3.5.0 alpha 2: Python 3 5 0 alpha 2.
* Python 3.5.0 alpha 1: Python 3 5 0 alpha 1.


File: python.info,  Node: Python next,  Next: Python 3 13 0 final,  Up: 変更履歴

1.23.1 Python next
------------------

'Release date: XXXX-XX-XX'

* Menu:

* macOS::
* Windows::
* Tools/Demos::
* Tests::
* Security::
* Library::
* IDLE: IDLE<3>.
* Documentation::
* Core and Builtins::
* C API::
* Build::


File: python.info,  Node: macOS,  Next: Windows,  Up: Python next

1.23.1.1 macOS
..............

   - gh-124448(1): Update bundled Tcl/Tk in macOS installer to 8.6.15.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124448


File: python.info,  Node: Windows,  Next: Tools/Demos,  Prev: macOS,  Up: Python next

1.23.1.2 Windows
................

   - gh-118973(1): Ensures the experimental free-threaded install
     includes the ‘_tkinter’ module.  The optional Tcl/Tk component must
     also be installed in order for the module to work.

   - gh-126497(2): Fixes venv failure due to missing redirector
     executables in experimental free-threaded installs.

   - gh-126074(3): Removed unnecessary DLLs from Windows embeddable
     package

   - gh-125315(4): Avoid crashing in *note platform: 98. due to slow WMI
     calls on some Windows machines.

   - gh-126084(5): Fix venvwlauncher to launch pythonw instead of python
     so no extra console window is created.

   - gh-125842(6): Fix a *note SystemError: 541. when *note sys.exit():
     1318. is called with ‘0xffffffff’ on Windows.

   - gh-125550(7): Enable the *note Windows の Python ランチャ: 588. to
     detect Python 3.14 installs from the Windows Store.

   - gh-124448(8): Updated bundled Tcl/Tk to 8.6.15.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118973

   (2) https://github.com/python/cpython/issues/126497

   (3) https://github.com/python/cpython/issues/126074

   (4) https://github.com/python/cpython/issues/125315

   (5) https://github.com/python/cpython/issues/126084

   (6) https://github.com/python/cpython/issues/125842

   (7) https://github.com/python/cpython/issues/125550

   (8) https://github.com/python/cpython/issues/124448


File: python.info,  Node: Tools/Demos,  Next: Tests,  Prev: Windows,  Up: Python next

1.23.1.3 Tools/Demos
....................

   - gh-126807(1): Fix extraction warnings in ‘pygettext.py’ caused by
     mistaking function definitions for function calls.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/126807


File: python.info,  Node: Tests,  Next: Security,  Prev: Tools/Demos,  Up: Python next

1.23.1.4 Tests
..............

   - gh-125041(1): Re-enable skipped tests for *note zlib: 119. on the
     s390x architecture: only skip checks of the compressed bytes, which
     can be different between zlib's software implementation and the
     hardware-accelerated implementation.

   - gh-124295(2): Add translation tests to the *note argparse: 5.
     module.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/125041

   (2) https://github.com/python/cpython/issues/124295


File: python.info,  Node: Security,  Next: Library,  Prev: Tests,  Up: Python next

1.23.1.5 Security
.................

   - gh-126623(1): Upgrade libexpat to 2.6.4

   - gh-125140(2): Remove the current directory from ‘sys.path’ when
     using PyREPL.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/126623

   (2) https://github.com/python/cpython/issues/125140


File: python.info,  Node: Library,  Next: IDLE<3>,  Prev: Security,  Up: Python next

1.23.1.6 Library
................

   - gh-126188(1): Update bundled pip to 24.3.1

   - gh-126766(2): Fix issue where *note urllib.request.url2pathname():
     14fe. failed to discard two leading slashes introducing an empty
     authority section.

   - gh-126654(3): Fix crash when non-dict was passed to several
     functions in ‘_interpreters’ module.

   - gh-104745(4): Limit starting a patcher (from *note
     unittest.mock.patch(): e5b. or *note unittest.mock.patch.object():
     14ff.) more than once without stopping it

   - gh-126595(5): Fix a crash when instantiating *note itertools.count:
     1254. with an initial count of *note sys.maxsize: 1195. on debug
     builds.  Patch by Bénédikt Tran.

   - gh-120423(6): Fix issue where *note urllib.request.pathname2url():
     1500. mishandled Windows paths with embedded forward slashes.

   - gh-126565(7): Improve performances of *note zipfile.Path.open():
     1501. for non-reading modes.

   - gh-126505(8): Fix bugs in compiling case-insensitive *note regular
     expressions: a7. with character classes containing non-BMP
     characters: upper-case non-BMP character did was ignored and the
     ASCII flag was ignored when matching a character range whose upper
     bound is beyond the BMP region.

   - gh-117378(9): Fixed the *note multiprocessing: 86. ‘"forkserver"’
     start method forkserver process to correctly inherit the parent's
     *note sys.path: 38e. during the importing of *note
     multiprocessing.set_forkserver_preload(): 1502. modules in the same
     manner as *note sys.path: 38e. is configured in workers before
     executing work items.

     This bug caused some forkserver module preloading to silently fail
     to preload.  This manifested as a performance degration in child
     processes when the ‘sys.path’ was required due to additional
     repeated work in every worker.

     It could also have a side effect of ‘""’ remaining in *note
     sys.path: 38e. during forkserver preload imports instead of the
     absolute path from *note os.getcwd(): 1503. at multiprocessing
     import time used in the worker ‘sys.path’.

     The ‘sys.path’ differences between phases in the child process
     could potentially have caused preload to import incorrect things
     from the wrong location.  We are unaware of that actually having
     happened in practice.

   - gh-125679(10): The *note multiprocessing.Lock: 1504. and *note
     multiprocessing.RLock: 1505. ‘repr’ values no longer say "unknown"
     on macOS.

   - gh-126489(11): The Python implementation of *note pickle: 95. no
     longer calls *note pickle.Pickler.persistent_id(): 1506. for the
     result of ‘persistent_id()’.

   - gh-126313(12): Fix an issue in *note curses.napms(): 1507. when
     *note curses.initscr(): 1508. has not yet been called.  Patch by
     Bénédikt Tran.

   - gh-126303(13): Fix pickling and copying of *note os.sched_param:
     1509. objects.

   - gh-126138(14): Fix a use-after-free crash on *note asyncio.Task:
     4a5. objects whose underlying coroutine yields an object that
     implements an evil *note __getattribute__(): ba0.  Patch by Nico
     Posada.

   - gh-126220(15): Fix crash in ‘cProfile.Profile’ and
     ‘_lsprof.Profiler’ when their callbacks were directly called with 0
     arguments.

   - gh-126212(16): Fix issue where *note urllib.request.pathname2url():
     1500. and *note url2pathname(): 14fe. removed slashes from Windows
     DOS drive paths and URLs.

   - gh-126223(17): Raise a *note UnicodeEncodeError: 643. instead of a
     *note SystemError: 541. upon calling ‘_interpreters.create()’ with
     an invalid Unicode character.

   - gh-126205(18): Fix issue where *note urllib.request.pathname2url():
     1500. generated URLs beginning with four slashes (rather than two)
     when given a Windows UNC path.

   - gh-126105(19): Fix a crash in *note ast: 7. when the *note
     ast.AST._fields: 150a. attribute is deleted.

   - gh-126106(20): Fixes a possible ‘NULL’ pointer dereference in *note
     ssl: bb.

   - gh-126080(21): Fix a use-after-free crash on *note asyncio.Task:
     4a5. objects for which the underlying event loop implements an evil
     *note __getattribute__(): ba0.  Reported by Nico-Posada.  Patch by
     Bénédikt Tran.

   - gh-126083(22): Fixed a reference leak in *note asyncio.Task: 4a5.
     objects when reinitializing the same object with a non-‘None’
     context.  Patch by Nico Posada.

   - gh-125984(23): Fix use-after-free crashes on *note asyncio.Future:
     b9b. objects for which the underlying event loop implements an evil
     *note __getattribute__(): ba0.  Reported by Nico-Posada.  Patch by
     Bénédikt Tran.

   - gh-125969(24): Fix an out-of-bounds crash when an evil *note
     asyncio.loop.call_soon(): ad2. mutates the length of the internal
     callbacks list.  Patch by Bénédikt Tran.

   - gh-125966(25): Fix a use-after-free crash in *note
     asyncio.Future.remove_done_callback(): 150b.  Patch by Bénédikt
     Tran.

   - gh-125789(26): Fix possible crash when mutating list of callbacks
     returned by ‘asyncio.Future._callbacks’.  It now always returns a
     new copy in C implementation ‘_asyncio’.  Patch by Kumar Aditya.

   - gh-125884(27): Fixed the bug for *note pdb: 94. where it can't set
     breakpoints on functions with certain annotations.

   - gh-125355(28): Fix several bugs in *note
     argparse.ArgumentParser.parse_intermixed_args(): ace.

        * The parser no longer changes temporarily during parsing.

        * Default values are not processed twice.

        * Required mutually exclusive groups containing positional
          arguments are now supported.

        * The missing arguments report now includes the names of all
          required optional and positional arguments.

        * Unknown options can be intermixed with positional arguments in
          parse_known_intermixed_args().

   - gh-125710(29): [Enum] fix hashable<->nonhashable comparisons for
     member values

   - gh-125631(30): Restore ability to set *note persistent_id: 1506.
     and *note persistent_load: 150c. attributes of instances of the
     ‘Pickler’ and ‘Unpickler’ classes in the *note pickle: 95. module.

   - gh-125378(31): Fixed the bug in *note pdb: 94. where after a
     multi-line command, an empty line repeats the first line of the
     multi-line command, instead of the full command.

   - gh-125682(32): Reject non-ASCII digits in the Python implementation
     of *note json.loads(): 923. conforming to the JSON specification.

   - gh-125660(33): Reject invalid unicode escapes for Python
     implementation of *note json.loads(): 923.

   - gh-125259(34): Fix the notes removal logic for errors thrown in
     enum initialization.

   - gh-125590(35): Allow ‘FrameLocalsProxy’ to delete and pop if the
     key is not a fast variable.

   - gh-125519(36): Improve traceback if *note importlib.reload(): 4e2.
     is called with an object that is not a module.  Patch by Alex
     Waygood.

   - gh-125451(37): Fix deadlock when *note
     concurrent.futures.ProcessPoolExecutor: 8bc. shuts down
     concurrently with an error when feeding a job to a worker process.

   - gh-125422(38): Fixed the bug where *note pdb: 94. and *note bdb: b.
     can step into the bottom caller frame.

   - gh-100141(39): Fixed the bug where *note pdb: 94. will be stuck in
     an infinite loop when debugging an empty file.

   - gh-125115(40): Fixed a bug in *note pdb: 94. where arguments
     starting with ‘-’ can't be passed to the debugged script.

   - gh-53203(41): Fix *note time.strptime(): 13d4. for ‘%c’, ‘%x’ and
     ‘%X’ formats in many locales that use non-ASCII digits, like
     Persian, Burmese, Odia and Shan.

   - gh-125398(42): Fix the conversion of the ‘VIRTUAL_ENV’ path in the
     activate script in *note venv: f9. when running in Git Bash for
     Windows.

   - gh-125316(43): Fix using *note functools.partial(): 3ed. as *note
     enum.Enum: 5fc. member.  A FutureWarning with suggestion to use
     *note enum.member(): 5f3. is now emitted when the ‘partial’
     instance is used as an enum member.

   - gh-125245(44): Fix race condition when importing *note
     collections.abc: 17, which could incorrectly return an empty
     module.

   - gh-125243(45): Fix data race when creating *note zoneinfo.ZoneInfo:
     8ad. objects in the free threading build.

   - gh-125254(46): Fix a bug where ArgumentError includes the incorrect
     ambiguous option in *note argparse: 5.

   - gh-125235(47): Keep *note tkinter: d9. TCL paths in venv pointing
     to base installation on Windows.

   - gh-61011(48): Fix inheritance of nested mutually exclusive groups
     from parent parser in *note argparse.ArgumentParser: 503.
     Previously, all nested mutually exclusive groups lost their
     connection to the group containing them and were displayed as
     belonging directly to the parser.

   - gh-52551(49): Fix encoding issues in *note time.strftime(): 11ba,
     the *note strftime(): c5e. method of the *note datetime: 28.
     classes *note datetime: 1ae, *note date: 1af. and *note time: 1b0.
     and formatting of these classes.  Characters not encodable in the
     current locale are now acceptable in the format string.  Surrogate
     pairs and sequence of surrogatescape-encoded bytes are no longer
     recombinated.  Embedded null character no longer terminates the
     format string.

   - gh-125118(50): Don't copy arbitrary values to _Bool in the *note
     struct: c0. module.

   - gh-125069(51): Fix an issue where providing a *note
     pathlib.PurePath: 473. object as an initializer argument to a
     second *note PurePath: 473. object with a different *note parser:
     20d. resulted in arguments to the former object's initializer being
     joined by the latter object's parser.

   - gh-125096(52): If the *note PYTHON_BASIC_REPL: 154. environment
     variable is set, the *note site: b5. module no longer imports the
     ‘_pyrepl’ module.  Moreover, the *note site: b5. module now
     respects *note -E: 92b. and *note -I: 92c. command line options:
     ignore *note PYTHON_BASIC_REPL: 154. in this case.  Patch by Victor
     Stinner.

   - gh-124969(53): Fix ‘locale.nl_langinfo(locale.ALT_DIGITS)’ on
     platforms with glibc.  Now it returns a string consisting of up to
     100 semicolon-separated symbols (an empty string in most locales)
     on all Posix platforms.  Previously it only returned the first
     symbol or an empty string.

   - gh-124960(54): Fix support for the ‘barry_as_FLUFL’ future flag in
     the new REPL.

   - gh-124958(55): Fix refcycles in exceptions raised from *note
     asyncio.TaskGroup: 19a. and the python implementation of *note
     asyncio.Future: b9b.

   - gh-53203(56): Fix *note time.strptime(): 13d4. for ‘%c’ and ‘%x’
     formats in many locales: Arabic, Bislama, Breton, Bodo, Kashubian,
     Chuvash, Estonian, French, Irish, Ge'ez, Gurajati, Manx Gaelic,
     Hebrew, Hindi, Chhattisgarhi, Haitian Kreyol, Japanese, Kannada,
     Korean, Marathi, Malay, Norwegian, Nynorsk, Punjabi, Rajasthani,
     Tok Pisin, Yoruba, Yue Chinese, Yau/Nungon and Chinese.

   - gh-124917(57): Allow calling *note os.path.exists(): 9dc. and *note
     os.path.lexists(): 9dd. with keyword arguments on Windows.  Fixes a
     regression in 3.13.0.

   - gh-124653(58): Fix detection of the minimal Queue API needed by the
     *note logging: 7b. module.  Patch by Bénédikt Tran.

   - gh-124858(59): Fix reference cycles left in tracebacks in *note
     asyncio.open_connection(): ae6. when used with
     ‘happy_eyeballs_delay’

   - gh-124390(60): Fixed *note AssertionError: 675. when using
     ‘asyncio.staggered.staggered_race()’ with *note
     asyncio.eager_task_factory: 444.

   - gh-124651(61): Properly quote template strings in *note venv: f9.
     activation scripts.

   - gh-116850(62): Fix *note argparse: 5. for namespaces with not
     directly writable dict (e.g.  classes).

   - gh-58573(63): Fix conflicts between abbreviated long options in the
     parent parser and subparsers in *note argparse: 5.

   - gh-124594(64): All *note asyncio: 8. REPL prompts run in the same
     *note context: 150d.  Contributed by Bartosz Sławecki.

   - gh-61181(65): Fix support of *note choices: 150e. with string value
     in *note argparse: 5.  Substrings of the specified string no longer
     considered valid values.

   - gh-80259(66): Fix *note argparse: 5. support of positional
     arguments with ‘nargs='?'’, ‘default=argparse.SUPPRESS’ and
     specified ‘type’.

   - gh-120378(67): Fix a crash related to an integer overflow in *note
     curses.resizeterm(): 150f. and *note curses.resize_term(): 1510.

   - gh-123884(68): Fixed bug in itertools.tee() handling of other tee
     inputs (a tee in a tee).  The output now has the promised 'n'
     independent new iterators.  Formerly, the first iterator was
     identical (not independent) to the input iterator.  This would
     sometimes give surprising results.

   - gh-58956(69): Fixed a bug in *note pdb: 94. where sometimes the
     breakpoint won't trigger if it was set on a function which is
     already in the call stack.

   - gh-124345(70): *note argparse: 5. vim supports abbreviated
     single-dash long options separated by ‘=’ from its value.

   - gh-104860(71): Fix disallowing abbreviation of single-dash long
     options in *note argparse: 5. with ‘allow_abbrev=False’.

   - gh-63143(72): Fix parsing mutually exclusive arguments in *note
     argparse: 5.  Arguments with the value identical to the default
     value (e.g.  booleans, small integers, empty or 1-character
     strings) are no longer considered "not present".

   - gh-72795(73): Positional arguments with *note nargs: 1511. equal to
     ‘'*'’ or ‘argparse.REMAINDER’ are no longer required.  This allows
     to use positional argument with ‘nargs='*'’ and without ‘default’
     in mutually exclusive group and improves error message about
     required arguments.

   - gh-59317(74): Fix parsing positional argument with *note nargs:
     1511. equal to ‘'?'’ or ‘'*'’ if it is preceded by an option and
     another positional argument.

   - gh-53780(75): *note argparse: 5. now ignores the first ‘"--"’
     (double dash) between an option and command.

   - gh-124217(76): Add RFC 9637 reserved IPv6 block ‘3fff::/20’ in
     *note ipaddress: 74. module.

   - gh-81691(77): Fix handling of multiple ‘"--"’ (double dashes) in
     *note argparse: 5.  Only the first one has now been removed, all
     subsequent ones are now taken literally.

   - gh-123978(78): Remove broken *note time.thread_time(): 904. and
     *note time.thread_time_ns(): b5f. on NetBSD.

   - gh-122765(79): Fix unbalanced quote errors occurring when
     activate.csh in *note venv: f9. was sourced with a custom prompt
     containing unpaired quotes or newlines.

   - gh-123370(80): Fix the canvas not clearing after running turtledemo
     clock.

   - gh-116810(81): Resolve a memory leak introduced in CPython 3.10's
     *note ssl: bb. when the *note ssl.SSLSocket.session: 1512. property
     was accessed.  Speeds up read and write access to said property by
     no longer unnecessarily cloning session objects via serialization.

   - gh-120754(82): Update unbounded ‘read’ calls in *note zipfile: 117.
     to specify an explicit ‘size’ putting a limit on how much data they
     may read.  This also updates handling around ZIP max comment size
     to match the standard instead of reading comments that are one byte
     too long.

   - gh-70764(83): Fixed an issue where *note inspect.getclosurevars():
     10a8. would incorrectly classify an attribute name as a global
     variable when the name exists both as an attribute name and a
     global variable.

   - gh-118289(84): ‘posixpath.realpath()’ now raises *note
     NotADirectoryError: 102e. when 'strict' mode is enabled and a
     non-directory path with a trailing slash is supplied.

   - gh-117766(85): Always use *note str(): 418. to print ‘choices’ in
     *note argparse: 5.

   - gh-71936(86): Fix a race condition in *note
     multiprocessing.pool.Pool: f38.

   - bpo-46128(87): Strip *note unittest.IsolatedAsyncioTestCase: 2e4.
     stack frames from reported stacktraces.

   - bpo-14074(88): Fix *note argparse: 5. metavar processing to allow
     positional arguments to have a tuple metavar.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/126188

   (2) https://github.com/python/cpython/issues/126766

   (3) https://github.com/python/cpython/issues/126654

   (4) https://github.com/python/cpython/issues/104745

   (5) https://github.com/python/cpython/issues/126595

   (6) https://github.com/python/cpython/issues/120423

   (7) https://github.com/python/cpython/issues/126565

   (8) https://github.com/python/cpython/issues/126505

   (9) https://github.com/python/cpython/issues/117378

   (10) https://github.com/python/cpython/issues/125679

   (11) https://github.com/python/cpython/issues/126489

   (12) https://github.com/python/cpython/issues/126313

   (13) https://github.com/python/cpython/issues/126303

   (14) https://github.com/python/cpython/issues/126138

   (15) https://github.com/python/cpython/issues/126220

   (16) https://github.com/python/cpython/issues/126212

   (17) https://github.com/python/cpython/issues/126223

   (18) https://github.com/python/cpython/issues/126205

   (19) https://github.com/python/cpython/issues/126105

   (20) https://github.com/python/cpython/issues/126106

   (21) https://github.com/python/cpython/issues/126080

   (22) https://github.com/python/cpython/issues/126083

   (23) https://github.com/python/cpython/issues/125984

   (24) https://github.com/python/cpython/issues/125969

   (25) https://github.com/python/cpython/issues/125966

   (26) https://github.com/python/cpython/issues/125789

   (27) https://github.com/python/cpython/issues/125884

   (28) https://github.com/python/cpython/issues/125355

   (29) https://github.com/python/cpython/issues/125710

   (30) https://github.com/python/cpython/issues/125631

   (31) https://github.com/python/cpython/issues/125378

   (32) https://github.com/python/cpython/issues/125682

   (33) https://github.com/python/cpython/issues/125660

   (34) https://github.com/python/cpython/issues/125259

   (35) https://github.com/python/cpython/issues/125590

   (36) https://github.com/python/cpython/issues/125519

   (37) https://github.com/python/cpython/issues/125451

   (38) https://github.com/python/cpython/issues/125422

   (39) https://github.com/python/cpython/issues/100141

   (40) https://github.com/python/cpython/issues/125115

   (41) https://github.com/python/cpython/issues/53203

   (42) https://github.com/python/cpython/issues/125398

   (43) https://github.com/python/cpython/issues/125316

   (44) https://github.com/python/cpython/issues/125245

   (45) https://github.com/python/cpython/issues/125243

   (46) https://github.com/python/cpython/issues/125254

   (47) https://github.com/python/cpython/issues/125235

   (48) https://github.com/python/cpython/issues/61011

   (49) https://github.com/python/cpython/issues/52551

   (50) https://github.com/python/cpython/issues/125118

   (51) https://github.com/python/cpython/issues/125069

   (52) https://github.com/python/cpython/issues/125096

   (53) https://github.com/python/cpython/issues/124969

   (54) https://github.com/python/cpython/issues/124960

   (55) https://github.com/python/cpython/issues/124958

   (56) https://github.com/python/cpython/issues/53203

   (57) https://github.com/python/cpython/issues/124917

   (58) https://github.com/python/cpython/issues/124653

   (59) https://github.com/python/cpython/issues/124858

   (60) https://github.com/python/cpython/issues/124390

   (61) https://github.com/python/cpython/issues/124651

   (62) https://github.com/python/cpython/issues/116850

   (63) https://github.com/python/cpython/issues/58573

   (64) https://github.com/python/cpython/issues/124594

   (65) https://github.com/python/cpython/issues/61181

   (66) https://github.com/python/cpython/issues/80259

   (67) https://github.com/python/cpython/issues/120378

   (68) https://github.com/python/cpython/issues/123884

   (69) https://github.com/python/cpython/issues/58956

   (70) https://github.com/python/cpython/issues/124345

   (71) https://github.com/python/cpython/issues/104860

   (72) https://github.com/python/cpython/issues/63143

   (73) https://github.com/python/cpython/issues/72795

   (74) https://github.com/python/cpython/issues/59317

   (75) https://github.com/python/cpython/issues/53780

   (76) https://github.com/python/cpython/issues/124217

   (77) https://github.com/python/cpython/issues/81691

   (78) https://github.com/python/cpython/issues/123978

   (79) https://github.com/python/cpython/issues/122765

   (80) https://github.com/python/cpython/issues/123370

   (81) https://github.com/python/cpython/issues/116810

   (82) https://github.com/python/cpython/issues/120754

   (83) https://github.com/python/cpython/issues/70764

   (84) https://github.com/python/cpython/issues/118289

   (85) https://github.com/python/cpython/issues/117766

   (86) https://github.com/python/cpython/issues/71936

   (87) https://bugs.python.org/issue?@action=redirect&bpo=46128

   (88) https://bugs.python.org/issue?@action=redirect&bpo=14074


File: python.info,  Node: IDLE<3>,  Next: Documentation,  Prev: Library,  Up: Python next

1.23.1.7 IDLE
.............

   - gh-122392(1): Increase currently inadequate vertical spacing for
     the IDLE browsers (path, module, and stack) on high-resolution
     monitors.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122392


File: python.info,  Node: Documentation,  Next: Core and Builtins,  Prev: IDLE<3>,  Up: Python next

1.23.1.8 Documentation
......................

   - gh-125277(1): Require Sphinx 7.2.6 or later to build the Python
     documentation.  Patch by Adam Turner.

   - gh-124872(2): Added definitions for *note context: 1515, *note
     current context: 1516, and *note context management protocol: 1517,
     updated related definitions to be consistent, and expanded the
     documentation for *note contextvars.Context: 150d.

   - gh-125018(3): The *note importlib.metadata: 6e. documentation now
     includes semantic cross-reference targets for the significant
     documented APIs.  This means intersphinx references like *note
     importlib.metadata.version(): 1518. will now work as expected.

   - gh-70870(4): Clarified the dual usage of the term "free variable"
     (both the formal meaning of any reference to names defined outside
     the local scope, and the narrower pragmatic meaning of nonlocal
     variables named in ‘co_freevars’).

   - gh-121277(5): Writers of CPython's documentation can now use ‘next’
     as the version for the ‘versionchanged’, ‘versionadded’,
     ‘deprecated’ directives.

   - gh-60712(6): Include the *note object: a5a. type in the lists of
     documented types.  Change by Furkan Onder and Martin Panter.

   - bpo-34008(7): The *note Py_Main(): bf3. documentation moved from
     the "Very High Level API" section to the "Initialization and
     Finalization" section.

     Also make it explicit that we expect ‘Py_Main’ to typically be
     called instead of ‘Py_Initialize’ rather than after it (since
     ‘Py_Main’ makes its own call to ‘Py_Initialize’).  Document that
     calling both is supported but is version dependent on which
     settings will be applied correctly.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/125277

   (2) https://github.com/python/cpython/issues/124872

   (3) https://github.com/python/cpython/issues/125018

   (4) https://github.com/python/cpython/issues/70870

   (5) https://github.com/python/cpython/issues/121277

   (6) https://github.com/python/cpython/issues/60712

   (7) https://bugs.python.org/issue?@action=redirect&bpo=34008


File: python.info,  Node: Core and Builtins,  Next: C API,  Prev: Documentation,  Up: Python next

1.23.1.9 Core and Builtins
..........................

   - gh-126341(1): Now *note ValueError: 1e3. is raised instead of *note
     SystemError: 541. when trying to iterate over a released *note
     memoryview: 435. object.

   - gh-126688(2): Fix a crash when calling *note os.fork(): 17c. on
     some operating systems, including SerenityOS.

   - gh-126066(3): Fix *note importlib: 6b. to not write an incomplete
     .pyc files when a ulimit or some other operating system mechanism
     is preventing the write to go through fully.

   - gh-126312(4): Fix crash during garbage collection on an object
     frozen by *note gc.freeze(): b08. on the free-threaded build.

   - gh-126139(5): Provide better error location when attempting to use
     a *note future statement: d7a. with an unknown future feature.

   - gh-126018(6): Fix a crash in *note sys.audit(): 151a. when passing
     a non-string as first argument and Python was compiled in debug
     mode.

   - gh-125942(7): On Android, the ‘errors’ setting of *note sys.stdout:
     aa4. was changed from ‘surrogateescape’ to ‘backslashreplace’.

   - gh-125859(8): Fix a crash in the free threading build when *note
     gc.get_objects(): 7ce. or *note gc.get_referrers(): 7cf. is called
     during an in-progress garbage collection.

   - gh-125593(9): Use color to highlight error locations in traceback
     from exception group

   - gh-125444(10): Fix illegal instruction for older Arm architectures.
     Patch by Diego Russo, testing by Ross Burton.

   - gh-124375(11): Fix a crash in the free threading build when the GC
     runs concurrently with a new thread starting.

   - gh-125221(12): Fix possible race condition when calling *note
     __reduce_ex__(): 151b. for the first time in the free threading
     build.

   - gh-125038(13): Fix crash when iterating over a generator expression
     after direct changes on ‘gi_frame.f_locals’.  Patch by Mikhail
     Efimov.

   - gh-123378(14): Fix a crash in the *note __str__(): 5e9. method of
     *note UnicodeError: 1275. objects when the *note
     UnicodeError.start: 151c. and *note UnicodeError.end: 151d. values
     are invalid or out-of-range.  Patch by Bénédikt Tran.

   - gh-116510(15): Fix a crash caused by immortal interned strings
     being shared between sub-interpreters that use basic single-phase
     init.  In that case, the string can be used by an interpreter that
     outlives the interpreter that created and interned it.  For
     interpreters that share obmalloc state, also share the interned
     dict with the main interpreter.

   - gh-122878(16): Use the ‘pager’ binary, if available (e.g.  on
     Debian and derivatives), to display REPL ‘help()’.

   - gh-124188(17): Fix reading and decoding a line from the source file
     witn non-UTF-8 encoding for syntax errors raised in the compiler.

   - gh-123930(18): Improve the error message when a script shadowing a
     module from the standard library causes *note ImportError: 3f2. to
     be raised during a "from" import.  Similarly, improve the error
     message when a script shadowing a third party module attempts to
     "from" import an attribute from that third party module while still
     initialising.

   - gh-118950(19): Fix bug where SSLProtocol.connection_lost wasn't
     getting called when OSError was thrown on writing to socket.

   - gh-113570(20): Fixed a bug in ‘reprlib.repr’ where it incorrectly
     called the repr method on shadowed Python built-in types.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/126341

   (2) https://github.com/python/cpython/issues/126688

   (3) https://github.com/python/cpython/issues/126066

   (4) https://github.com/python/cpython/issues/126312

   (5) https://github.com/python/cpython/issues/126139

   (6) https://github.com/python/cpython/issues/126018

   (7) https://github.com/python/cpython/issues/125942

   (8) https://github.com/python/cpython/issues/125859

   (9) https://github.com/python/cpython/issues/125593

   (10) https://github.com/python/cpython/issues/125444

   (11) https://github.com/python/cpython/issues/124375

   (12) https://github.com/python/cpython/issues/125221

   (13) https://github.com/python/cpython/issues/125038

   (14) https://github.com/python/cpython/issues/123378

   (15) https://github.com/python/cpython/issues/116510

   (16) https://github.com/python/cpython/issues/122878

   (17) https://github.com/python/cpython/issues/124188

   (18) https://github.com/python/cpython/issues/123930

   (19) https://github.com/python/cpython/issues/118950

   (20) https://github.com/python/cpython/issues/113570


File: python.info,  Node: C API,  Next: Build,  Prev: Core and Builtins,  Up: Python next

1.23.1.10 C API
...............

   - gh-125608(1): Fix a bug where dictionary watchers (e.g., *note
     PyDict_Watch(): 52f.) on an object's attribute dictionary (*note
     __dict__: 526.) were not triggered when the object's attributes
     were modified.

   - bpo-34008(2): Added ‘Py_IsInitialized’ to the list of APIs that are
     safe to call before the interpreter is initialized, and updated the
     embedding tests to cover it.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/125608

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34008


File: python.info,  Node: Build,  Prev: C API,  Up: Python next

1.23.1.11 Build
...............

   - gh-123877(1): Set ‘wasm32-wasip1’ as the WASI target.  The old
     ‘wasm32-wasi’ target is deprecated so it can be used for an
     eventual WASI 1.0.

   - gh-89640(2): Hard-code float word ordering as little endian on
     WASM.

   - gh-125940(3): The Android build now supports 16 KB page sizes(4).

   - gh-89640(5): Improve detection of float word ordering on Linux when
     link-time optimizations are enabled.

   - gh-125269(6): Fix detection of whether ‘-latomic’ is needed when
     cross-compiling CPython using the configure script.

   - gh-121634(7): Allow for specifying the target compile triple for
     WASI.

   - gh-122578(8): Use WASI SDK 24 for testing.

   - gh-115382(9): Fix cross compile failures when the host and target
     SOABIs match.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123877

   (2) https://github.com/python/cpython/issues/89640

   (3) https://github.com/python/cpython/issues/125940

   (4) https://developer.android.com/guide/practices/page-sizes

   (5) https://github.com/python/cpython/issues/89640

   (6) https://github.com/python/cpython/issues/125269

   (7) https://github.com/python/cpython/issues/121634

   (8) https://github.com/python/cpython/issues/122578

   (9) https://github.com/python/cpython/issues/115382


File: python.info,  Node: Python 3 13 0 final,  Next: Python 3 13 0 release candidate 3,  Prev: Python next,  Up: 変更履歴

1.23.2 Python 3.13.0 final
--------------------------

'Release date: 2024-10-07'

* Menu:

* Core and Builtins: Core and Builtins<2>.


File: python.info,  Node: Core and Builtins<2>,  Up: Python 3 13 0 final

1.23.2.1 Core and Builtins
..........................

   - gh-125008(1): Fix *note tokenize.untokenize(): 1522. producing
     invalid syntax for double braces preceded by certain escape
     characters.

   - gh-124871(2): Fix compiler bug (in some versions of 3.13) where an
     assertion fails during reachability analysis.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/125008

   (2) https://github.com/python/cpython/issues/124871


File: python.info,  Node: Python 3 13 0 release candidate 3,  Next: Python 3 13 0 release candidate 2,  Prev: Python 3 13 0 final,  Up: 変更履歴

1.23.3 Python 3.13.0 release candidate 3
----------------------------------------

'Release date: 2024-10-01'

* Menu:

* macOS: macOS<2>.
* Windows: Windows<2>.
* Tests: Tests<2>.
* Library: Library<2>.
* IDLE: IDLE<4>.
* Documentation: Documentation<2>.
* Core and Builtins: Core and Builtins<3>.
* C API: C API<2>.
* Build: Build<2>.


File: python.info,  Node: macOS<2>,  Next: Windows<2>,  Up: Python 3 13 0 release candidate 3

1.23.3.1 macOS
..............

   - gh-123797(1): Check for runtime availability of ‘ptsname_r’
     function on macos.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123797


File: python.info,  Node: Windows<2>,  Next: Tests<2>,  Prev: macOS<2>,  Up: Python 3 13 0 release candidate 3

1.23.3.2 Windows
................

   - gh-124609(1): Fix ‘_Py_ThreadId’ for Windows builds using MinGW.
     Patch by Tony Roberts.

   - gh-124254(2): Ensures experimental free-threaded binaries remain
     installed when updating.

   - gh-123915(3): Ensure that ‘Tools\msi\buildrelease.bat’ uses
     different directories for AMD64 and ARM64 builds.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124609

   (2) https://github.com/python/cpython/issues/124254

   (3) https://github.com/python/cpython/issues/123915


File: python.info,  Node: Tests<2>,  Next: Library<2>,  Prev: Windows<2>,  Up: Python 3 13 0 release candidate 3

1.23.3.3 Tests
..............

   - gh-124378(1): Updated ‘test_ttk’ to pass with Tcl/Tk 8.6.15.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124378


File: python.info,  Node: Library<2>,  Next: IDLE<4>,  Prev: Tests<2>,  Up: Python 3 13 0 release candidate 3

1.23.3.4 Library
................

   - gh-124538(1): Fixed crash when using *note gc.get_referents(): 7d0.
     on a capsule object.

   - gh-124498(2): Fix *note typing.TypeAliasType: 421. not to be
     generic, when ‘type_params’ is an empty tuple.

   - gh-123017(3): Due to unreliable results on some devices, *note
     time.strftime(): 11ba. no longer accepts negative years on Android.

   - gh-123014(4): *note os.pidfd_open(): 447. and *note
     signal.pidfd_send_signal(): 8f9. are now unavailable when building
     against Android API levels older than 31, since the underlying
     system calls may cause a crash.

   - gh-124248(5): Fixed potential crash when using *note struct: c0. to
     process zero-width 'Pascal string' fields (‘0p’).

   - gh-87041(6): Fix a bug in *note argparse: 5. where lengthy
     subparser argument help is incorrectly indented.

   - gh-124212(7): Fix invalid variable in *note venv: f9. handling of
     failed symlink on Windows

   - gh-124171(8): Add workaround for broken ‘fmod()’ implementations on
     Windows, that loose zero sign (e.g.  ‘fmod(-10, 1)’ returns ‘0.0’).
     Patch by Sergey B Kirpichev.

   - gh-123934(9): Fix *note unittest.mock.MagicMock: e5a. reseting
     magic methods return values after ‘.reset_mock(return_value=True)’
     was called.

   - gh-123968(10): Fix the command-line interface for the *note random:
     a6. module to select floats between 0 and N, not 1 and N.

   - gh-123892(11): Add ‘"_wmi"’ to *note sys.stdlib_module_names: 80c.
     Patch by Victor Stinner.

   - gh-123339(12): Fix *note inspect.getsource(): 1528. for classes in
     *note collections.abc: 17. and *note decimal: 2e. (for pure Python
     implementation) modules.  *note inspect.getcomments(): 1529. now
     raises OSError instead of IndexError if the ‘__firstlineno__’ value
     for a class is out of bound.

   - gh-121735(13): When working with zip archives, importlib.resources
     now properly honors module-adjacent references (e.g.
     ‘files(pkg.mod)’ and not just ‘files(pkg)’).

   - gh-122145(14): Fix an issue when reporting tracebacks corresponding
     to Python code emitting an empty AST body.  Patch by Nikita Sobolev
     and Bénédikt Tran.

   - gh-119004(15): Fix a crash in *note OrderedDict.__eq__: 152a. when
     operands are mutated during the check.  Patch by Bénédikt Tran.

   - bpo-44864(16): Do not translate user-provided strings in *note
     argparse.ArgumentParser: 503.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124538

   (2) https://github.com/python/cpython/issues/124498

   (3) https://github.com/python/cpython/issues/123017

   (4) https://github.com/python/cpython/issues/123014

   (5) https://github.com/python/cpython/issues/124248

   (6) https://github.com/python/cpython/issues/87041

   (7) https://github.com/python/cpython/issues/124212

   (8) https://github.com/python/cpython/issues/124171

   (9) https://github.com/python/cpython/issues/123934

   (10) https://github.com/python/cpython/issues/123968

   (11) https://github.com/python/cpython/issues/123892

   (12) https://github.com/python/cpython/issues/123339

   (13) https://github.com/python/cpython/issues/121735

   (14) https://github.com/python/cpython/issues/122145

   (15) https://github.com/python/cpython/issues/119004

   (16) https://bugs.python.org/issue?@action=redirect&bpo=44864


File: python.info,  Node: IDLE<4>,  Next: Documentation<2>,  Prev: Library<2>,  Up: Python 3 13 0 release candidate 3

1.23.3.5 IDLE
.............

   - gh-112938(1): Fix uninteruptable hang when Shell gets rapid
     continuous output.

   - gh-120104(2): Fix padding in config and search dialog windows in
     IDLE.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/112938

   (2) https://github.com/python/cpython/issues/120104


File: python.info,  Node: Documentation<2>,  Next: Core and Builtins<3>,  Prev: IDLE<4>,  Up: Python 3 13 0 release candidate 3

1.23.3.6 Documentation
......................

   - gh-124720(1): Update "Using Python on a Mac" section of the "Python
     Setup and Usage" document and include information on installing
     free-threading support.

   - gh-116622(2): Add an Android platform guide, and flag modules not
     available on Android.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124720

   (2) https://github.com/python/cpython/issues/116622


File: python.info,  Node: Core and Builtins<3>,  Next: C API<2>,  Prev: Documentation<2>,  Up: Python 3 13 0 release candidate 3

1.23.3.7 Core and Builtins
..........................

   - gh-124567(1): Revert the incremental GC (in 3.13), since it's not
     clear the benefits outweigh the costs at this point.

   - gh-124642(2): Fixed scalability issue in free-threaded builds for
     lock-free reads from dictionaries in multi-threaded scenarios

   - gh-116510(3): Fix a bug that can cause a crash when
     sub-interpreters use "basic" single-phase extension modules.
     Shared objects could refer to PyGC_Head nodes that had been freed
     as part of interpreter cleanup.

   - gh-124547(4): When deallocating an object with inline values whose
     ‘__dict__’ is still live: if memory allocation for the inline
     values fails, clear the dictionary.  Prevents an interpreter crash.

   - gh-124513(5): Fix a crash in FrameLocalsProxy constructor: check
     the number of arguments.  Patch by Victor Stinner.

   - gh-124442(6): Fix nondeterminism in compilation by sorting the
     value of *note __static_attributes__: 131.  Patch by kp2pml30.

   - gh-123856(7): Fix PyREPL failure when a keyboard interrupt is
     triggered after using a history search

   - gh-65961(8): Document the deprecation of setting and using
     ‘__package__’ and ‘__cached__’.

   - gh-124027(9): Support ‘<page up>’, ‘<page down>’, and ‘<delete>’
     keys in the Python REPL when ‘$TERM’ is set to ‘vt100’.

   - gh-77894(10): Fix possible crash in the garbage collector when it
     tries to break a reference loop containing a *note memoryview: 435.
     object.  Now a ‘memoryview’ object can only be cleared if there are
     no buffers that refer it.

   - gh-123339(11): Setting the ‘__module__’ attribute for a class now
     removes the ‘__firstlineno__’ item from the type's dict, so they
     will no longer be inconsistent.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124567

   (2) https://github.com/python/cpython/issues/124642

   (3) https://github.com/python/cpython/issues/116510

   (4) https://github.com/python/cpython/issues/124547

   (5) https://github.com/python/cpython/issues/124513

   (6) https://github.com/python/cpython/issues/124442

   (7) https://github.com/python/cpython/issues/123856

   (8) https://github.com/python/cpython/issues/65961

   (9) https://github.com/python/cpython/issues/124027

   (10) https://github.com/python/cpython/issues/77894

   (11) https://github.com/python/cpython/issues/123339


File: python.info,  Node: C API<2>,  Next: Build<2>,  Prev: Core and Builtins<3>,  Up: Python 3 13 0 release candidate 3

1.23.3.8 C API
..............

   - gh-124160(1): Fix crash when importing modules containing state and
     single-phase initialization in a subinterpreter.

   - gh-123880(2): Fixed a bug that prevented circular imports of
     extension modules that use single-phase initialization.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124160

   (2) https://github.com/python/cpython/issues/123880


File: python.info,  Node: Build<2>,  Prev: C API<2>,  Up: Python 3 13 0 release candidate 3

1.23.3.9 Build
..............

   - gh-124487(1): Windows builds now use Windows 8.1 as their API
     baseline (installation already required Windows 8.1).

   - gh-124043(2): Building using *note -with-trace-refs: 36e. is
     (temporarily) disallowed when the GIL is disabled.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/124487

   (2) https://github.com/python/cpython/issues/124043


File: python.info,  Node: Python 3 13 0 release candidate 2,  Next: Python 3 13 0 release candidate 1,  Prev: Python 3 13 0 release candidate 3,  Up: 変更履歴

1.23.4 Python 3.13.0 release candidate 2
----------------------------------------

'Release date: 2024-09-06'

* Menu:

* macOS: macOS<3>.
* Windows: Windows<3>.
* Tools/Demos: Tools/Demos<2>.
* Tests: Tests<3>.
* Security: Security<2>.
* Library: Library<3>.
* IDLE: IDLE<5>.
* Core and Builtins: Core and Builtins<4>.
* C API: C API<3>.
* Build: Build<3>.


File: python.info,  Node: macOS<3>,  Next: Windows<3>,  Up: Python 3 13 0 release candidate 2

1.23.4.1 macOS
..............

   - gh-123418(1): Updated macOS installer build to use OpenSSL 3.0.15.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123418


File: python.info,  Node: Windows<3>,  Next: Tools/Demos<2>,  Prev: macOS<3>,  Up: Python 3 13 0 release candidate 2

1.23.4.2 Windows
................

   - gh-123418(1): Updated Windows build to use OpenSSL 3.0.15.

   - gh-122573(2): The Windows build of CPython now requires 3.10 or
     newer.

   - gh-100256(3): *note mimetypes: 82. no longer fails when it
     encounters an inaccessible registry key.

   - gh-79846(4): Makes ‘ssl.create_default_context()’ ignore invalid
     certificates in the Windows certificate store

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123418

   (2) https://github.com/python/cpython/issues/122573

   (3) https://github.com/python/cpython/issues/100256

   (4) https://github.com/python/cpython/issues/79846


File: python.info,  Node: Tools/Demos<2>,  Next: Tests<3>,  Prev: Windows<3>,  Up: Python 3 13 0 release candidate 2

1.23.4.3 Tools/Demos
....................

   - gh-123418(1): Update GitHub CI workflows to use OpenSSL 3.0.15 and
     multissltests to use 3.0.15, 3.1.7, and 3.2.3.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123418


File: python.info,  Node: Tests<3>,  Next: Security<2>,  Prev: Tools/Demos<2>,  Up: Python 3 13 0 release candidate 2

1.23.4.4 Tests
..............

   - gh-119727(1): Add ‘--single-process’ command line option to Python
     test runner (regrtest).  Patch by Victor Stinner.

   - gh-101525(2): Skip ‘test_gdb’ if the binary is relocated by BOLT.
     Patch by Donghee Na.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/119727

   (2) https://github.com/python/cpython/issues/101525


File: python.info,  Node: Security<2>,  Next: Library<3>,  Prev: Tests<3>,  Up: Python 3 13 0 release candidate 2

1.23.4.5 Security
.................

   - gh-123678(1): Upgrade libexpat to 2.6.3

   - gh-121285(2): Remove backtracking from tarfile header parsing for
     ‘hdrcharset’, PAX, and GNU sparse headers.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123678

   (2) https://github.com/python/cpython/issues/121285


File: python.info,  Node: Library<3>,  Next: IDLE<5>,  Prev: Security<2>,  Up: Python 3 13 0 release candidate 2

1.23.4.6 Library
................

   - gh-123657(1): Fix crash and memory leak in *note
     decimal.getcontext(): 1537.  It crashed when using a thread-local
     context by ‘--with-decimal-contextvar=no’.

   - gh-123448(2): Fixed memory leak of *note typing.NoDefault: 243. by
     moving it to the static types array.

   - gh-123409(3): Fix *note ipaddress.IPv6Address.reverse_pointer:
     1538. output according to RFC 3596, §2.5(4).  Patch by Bénédikt
     Tran.

   - gh-123270(5): Applied a more surgical fix for malformed payloads in
     *note zipfile.Path: 695. causing infinite loops (gh-122905(6))
     without breaking contents using legitimate characters.

   - gh-123228(7): Fix return type for
     ‘_pyrepl.readline._ReadlineWrapper.get_line_buffer()’ to be *note
     str(): 418.  Patch by Sergey B Kirpichev.

   - gh-123240(8): Raise audit events for the *note input(): 12a6. in
     the new REPL.

   - gh-123243(9): Fix memory leak in ‘_decimal’.

   - gh-122546(10): Consistently use same file name for different
     exceptions in the new repl.  Patch by Sergey B Kirpichev.

   - gh-123213(11): *note xml.etree.ElementTree.Element.extend(): 11a3.
     and *note Element: 2e8. assignment no longer hide the internal
     exception if an erronous generator is passed.  Patch by Bar Harel.

   - gh-85110(12): Preserve relative path in URL without netloc in *note
     urllib.parse.urlunsplit(): 1539. and *note
     urllib.parse.urlunparse(): 153a.

   - gh-123067(13): Fix quadratic complexity in parsing ‘"’-quoted
     cookie values with backslashes by *note http.cookies: 67.

   - gh-122981(14): Fix *note inspect.getsource(): 1528. for generated
     classes with Python base classes (e.g.  enums).

   - gh-122903(15): ‘zipfile.Path.glob’ now correctly matches
     directories instead of silently omitting them.

   - gh-122905(16): *note zipfile.Path: 695. objects now sanitize names
     from the zipfile.

   - gh-122695(17): Fixed double-free when using *note
     gc.get_referents(): 7d0. with a freed *note asyncio.Future: b9b.
     iterator.

   - gh-116263(18): *note logging.handlers.RotatingFileHandler: 153b. no
     longer rolls over empty log files.

   - gh-105376(19): Restore the deprecated *note logging: 7b. ‘warn()’
     method.  It was removed in Python 3.13 alpha 1.  Keep the
     deprecated ‘warn()’ method in Python 3.13.  Patch by Victor
     Stinner.

   - gh-122744(20): Bump the version of pip bundled in ensurepip to
     version 24.2.

   - gh-118814(21): Fix the *note typing.TypeVar: 143. constructor when
     name is passed by keyword.

   - gh-122478(22): Remove internal frames from tracebacks shown in
     *note code.InteractiveInterpreter: 153c. with non-default *note
     sys.excepthook(): 7d6.  Save correct tracebacks in *note
     sys.last_traceback: 48d. and update ‘__traceback__’ attribute of
     *note sys.last_value: 48c. and *note sys.last_exc: 48a.

   - gh-116622(23): On Android, the ‘FICLONE’ and ‘FICLONERANGE’
     constants are no longer exposed by *note fcntl: 4f, as these ioctls
     are blocked by SELinux.

   - gh-82378(24): Make sure that the new *note REPL: 150. interprets
     *note sys.tracebacklimit: 153d. in the same way that the classic
     REPL did.

   - gh-122334(25): Fix crash when importing *note ssl: bb. after the
     main interpreter restarts.

   - gh-87320(26): In *note code.InteractiveInterpreter: 153c, handle
     exceptions caused by calling a non-default *note sys.excepthook():
     7d6.  Before, the exception bubbled up to the caller, ending the
     *note REPL: 150.

   - gh-121650(27): *note email: 32. headers with embedded newlines are
     now quoted on output.  The *note generator: 37. will now refuse to
     serialize (write) headers that are unsafely folded or delimited;
     see *note verify_generated_headers: 1c4.  (Contributed by Bas
     Bloemsaat and Petr Viktorin in gh-121650(28).)

   - gh-121723(29): Make *note logging.config.dictConfig(): 1180. accept
     any object implementing the Queue public API. See the *note queue
     configuration: 153e. section for details.  Patch by Bénédikt Tran.

   - gh-122081(30): Fix a crash in the ‘decimal.IEEEContext()’ optional
     function available via the ‘EXTRA_FUNCTIONALITY’ configuration
     flag.

   - gh-121804(31): Correctly show error locations, when *note
     SyntaxError: 172. raised in new repl.  Patch by Sergey B Kirpichev.

   - gh-121151(32): Fix wrapping of long usage text of arguments inside
     a mutually exclusive group in *note argparse: 5.

   - gh-108172(33): ‘webbrowser’ honors OS preferred browser on Linux
     when its desktop entry name contains the text of a known browser
     name.

   - gh-109109(34): You can now get the raw TLS certificate chains from
     TLS connections via *note ssl.SSLSocket.get_verified_chain(): 153f.
     and *note ssl.SSLSocket.get_unverified_chain(): 1540. methods.

     Contributed by Mateusz Nowak.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123657

   (2) https://github.com/python/cpython/issues/123448

   (3) https://github.com/python/cpython/issues/123409

   (4) https://datatracker.ietf.org/doc/html/rfc3596.html#section-2.5

   (5) https://github.com/python/cpython/issues/123270

   (6) https://github.com/python/cpython/issues/122905

   (7) https://github.com/python/cpython/issues/123228

   (8) https://github.com/python/cpython/issues/123240

   (9) https://github.com/python/cpython/issues/123243

   (10) https://github.com/python/cpython/issues/122546

   (11) https://github.com/python/cpython/issues/123213

   (12) https://github.com/python/cpython/issues/85110

   (13) https://github.com/python/cpython/issues/123067

   (14) https://github.com/python/cpython/issues/122981

   (15) https://github.com/python/cpython/issues/122903

   (16) https://github.com/python/cpython/issues/122905

   (17) https://github.com/python/cpython/issues/122695

   (18) https://github.com/python/cpython/issues/116263

   (19) https://github.com/python/cpython/issues/105376

   (20) https://github.com/python/cpython/issues/122744

   (21) https://github.com/python/cpython/issues/118814

   (22) https://github.com/python/cpython/issues/122478

   (23) https://github.com/python/cpython/issues/116622

   (24) https://github.com/python/cpython/issues/82378

   (25) https://github.com/python/cpython/issues/122334

   (26) https://github.com/python/cpython/issues/87320

   (27) https://github.com/python/cpython/issues/121650

   (28) https://github.com/python/cpython/issues/121650

   (29) https://github.com/python/cpython/issues/121723

   (30) https://github.com/python/cpython/issues/122081

   (31) https://github.com/python/cpython/issues/121804

   (32) https://github.com/python/cpython/issues/121151

   (33) https://github.com/python/cpython/issues/108172

   (34) https://github.com/python/cpython/issues/109109


File: python.info,  Node: IDLE<5>,  Next: Core and Builtins<4>,  Prev: Library<3>,  Up: Python 3 13 0 release candidate 2

1.23.4.7 IDLE
.............

   - gh-120083(1): Add explicit black IDLE Hovertip foreground color
     needed for recent macOS. Fixes Sonoma showing unreadable white on
     pale yellow.  Patch by John Riggles.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/120083


File: python.info,  Node: Core and Builtins<4>,  Next: C API<3>,  Prev: IDLE<5>,  Up: Python 3 13 0 release candidate 2

1.23.4.8 Core and Builtins
..........................

   - gh-120221(1): asyncio REPL is now again properly recognizing
     KeyboardInterrupts.  Display of exceptions raised in secondary
     threads is fixed.

   - gh-119310(2): Allow the new interactive shell to read history files
     written with the editline library that use unicode-escaped entries.
     Patch by aorcajo and Łukasz Langa.

   - gh-123572(3): Fix key mappings for various F-keys in Windows for
     the new REPL. Patch by devdanzin

   - gh-119034(4): Change ‘<page up>’ and ‘<page down>’ keys of the
     Python REPL to history search forward/backward.  Patch by Victor
     Stinner.

   - gh-123545(5): Fix a double decref in rare cases on experimental JIT
     builds.

   - gh-123484(6): Fix ‘_Py_DebugOffsets’ for long objects to be
     relative to the start of the object rather than the start of a
     subobject.

   - gh-123344(7): Add AST optimizations for type parameter defaults.

   - gh-123321(8): Prevent Parser/myreadline race condition from
     segfaulting on multi-threaded use.  Patch by Bar Harel and Amit
     Wienner.

   - gh-123177(9): Fix a bug causing stray prompts to appear in the
     middle of wrapped lines in the new REPL.

   - gh-122982(10): Extend the deprecation period for bool inversion
     (‘~’) by two years.

   - gh-123275(11): Support *note -X gil=1: 15c. and *note PYTHON_GIL=1:
     15b. on non-free-threaded builds.

   - gh-123177(12): Deactivate line wrap in the Apple Terminal via a
     ANSI escape code.  Patch by Pablo Galindo

   - gh-123229(13): Fix valgrind warning by initializing the f-string
     buffers to 0 in the tokenizer.  Patch by Pablo Galindo

   - gh-122298(14): Restore printout of GC stats when
     ‘gc.set_debug(gc.DEBUG_STATS)’ is called.  This featue was
     accidentally removed when implementing incremental GC.

   - gh-121804(15): Correctly show error locations when a *note
     SyntaxError: 172. is raised in the basic REPL. Patch by Sergey B
     Kirpichev.

   - gh-123142(16): Fix too-wide source location in exception tracebacks
     coming from broken iterables in comprehensions.

   - gh-123048(17): Fix a bug where pattern matching code could emit a
     *note JUMP_FORWARD: 1543. with no source location.

   - gh-123123(18): Fix displaying *note SyntaxError: 172. exceptions
     covering multiple lines.  Patch by Pablo Galindo

   - gh-123083(19): Fix a potential use-after-free in
     ‘STORE_ATTR_WITH_HINT’.

   - gh-123022(20): Fix crash in free-threaded build when calling *note
     Py_Initialize(): 87a. from a non-main thread.

   - gh-122888(21): Fix crash on certain calls to ‘str()’ with
     positional arguments of the wrong type.  Patch by Jelle Zijlstra.

   - gh-116622(22): Fix Android stdout and stderr messages being
     truncated or lost.

   - gh-122527(23): Fix a crash that occurred when a ‘PyStructSequence’
     was deallocated after its type's dictionary was cleared by the GC.
     The type's *note tp_basicsize: 955. now accounts for non-sequence
     fields that aren't included in the *note Py_SIZE: 74d. of the
     sequence.

   - gh-122445(24): Add only fields which are modified via self.* to
     *note __static_attributes__: 131.

   - gh-98442(25): Fix too wide source locations of the cleanup
     instructions of a with statement.

   - gh-93691(26): Fix source locations of instructions generated for
     with statements.

   - gh-120097(27): ‘FrameLocalsProxy’ now subclasses
     ‘collections.abc.Mapping’ and can be matched as a mapping in
     ‘match’ statements

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/120221

   (2) https://github.com/python/cpython/issues/119310

   (3) https://github.com/python/cpython/issues/123572

   (4) https://github.com/python/cpython/issues/119034

   (5) https://github.com/python/cpython/issues/123545

   (6) https://github.com/python/cpython/issues/123484

   (7) https://github.com/python/cpython/issues/123344

   (8) https://github.com/python/cpython/issues/123321

   (9) https://github.com/python/cpython/issues/123177

   (10) https://github.com/python/cpython/issues/122982

   (11) https://github.com/python/cpython/issues/123275

   (12) https://github.com/python/cpython/issues/123177

   (13) https://github.com/python/cpython/issues/123229

   (14) https://github.com/python/cpython/issues/122298

   (15) https://github.com/python/cpython/issues/121804

   (16) https://github.com/python/cpython/issues/123142

   (17) https://github.com/python/cpython/issues/123048

   (18) https://github.com/python/cpython/issues/123123

   (19) https://github.com/python/cpython/issues/123083

   (20) https://github.com/python/cpython/issues/123022

   (21) https://github.com/python/cpython/issues/122888

   (22) https://github.com/python/cpython/issues/116622

   (23) https://github.com/python/cpython/issues/122527

   (24) https://github.com/python/cpython/issues/122445

   (25) https://github.com/python/cpython/issues/98442

   (26) https://github.com/python/cpython/issues/93691

   (27) https://github.com/python/cpython/issues/120097


File: python.info,  Node: C API<3>,  Next: Build<3>,  Prev: Core and Builtins<4>,  Up: Python 3 13 0 release candidate 2

1.23.4.9 C API
..............

   - gh-122728(1): Fix *note PyEval_GetLocals(): 32e. to avoid *note
     SystemError: 541. ("bad argument to internal function").  Patch by
     Victor Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122728


File: python.info,  Node: Build<3>,  Prev: C API<3>,  Up: Python 3 13 0 release candidate 2

1.23.4.10 Build
...............

   - gh-123418(1): Updated Android build to use OpenSSL 3.0.15.

   - gh-123297(2): Propagate the value of ‘LDFLAGS’ to ‘LDCXXSHARED’ in
     *note sysconfig: c5.  Patch by Pablo Galindo

   - gh-116622(3): Rename build variable ‘MODULE_LDFLAGS’ back to
     ‘LIBPYTHON’, as it's used by package build systems (e.g.  Meson).

   - gh-118943(4): Fix an issue where the experimental JIT could be
     built several times by the ‘make regen-all’ target, leading to
     possible race conditions on heavily parallelized builds.

   - gh-118943(5): Fix a possible race condition affecting parallel
     builds configured with ‘--enable-experimental-jit’, in which *note
     FileNotFoundError: e8f. could be caused by another process already
     moving ‘jit_stencils.h.new’ to ‘jit_stencils.h’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/123418

   (2) https://github.com/python/cpython/issues/123297

   (3) https://github.com/python/cpython/issues/116622

   (4) https://github.com/python/cpython/issues/118943

   (5) https://github.com/python/cpython/issues/118943


File: python.info,  Node: Python 3 13 0 release candidate 1,  Next: Python 3 13 0 beta 4,  Prev: Python 3 13 0 release candidate 2,  Up: 変更履歴

1.23.5 Python 3.13.0 release candidate 1
----------------------------------------

'Release date: 2024-07-31'

* Menu:

* Tests: Tests<4>.
* Security: Security<3>.
* Library: Library<4>.
* IDLE: IDLE<6>.
* Core and Builtins: Core and Builtins<5>.
* C API: C API<4>.
* Build: Build<4>.


File: python.info,  Node: Tests<4>,  Next: Security<3>,  Up: Python 3 13 0 release candidate 1

1.23.5.1 Tests
..............

   - gh-59022(1): Add tests for *note pkgutil.extend_path(): 1548.
     Patch by Andreas Stocker.

   - gh-99242(2): *note os.getloadavg(): 1549. may throw *note OSError:
     3f0. when running regression tests under certain conditions (e.g.
     chroot).  This error is now caught and ignored, since reporting
     load average is optional.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/59022

   (2) https://github.com/python/cpython/issues/99242


File: python.info,  Node: Security<3>,  Next: Library<4>,  Prev: Tests<4>,  Up: Python 3 13 0 release candidate 1

1.23.5.2 Security
.................

   - gh-122133(1): Authenticate the socket connection for the
     ‘socket.socketpair()’ fallback on platforms where ‘AF_UNIX’ is not
     available like Windows.

     Patch by Gregory P. Smith <<greg@krypto.org>> and Seth Larson
     <<seth@python.org>>.  Reported by Ellie <<el@horse64.org>>

   - gh-121957(2): Fixed missing audit events around interactive use of
     Python, now also properly firing for ‘python -i’, as well as for
     ‘python -m asyncio’.  The events in question are
     ‘cpython.run_stdin’ and ‘cpython.run_startup’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122133

   (2) https://github.com/python/cpython/issues/121957


File: python.info,  Node: Library<4>,  Next: IDLE<6>,  Prev: Security<3>,  Up: Python 3 13 0 release candidate 1

1.23.5.3 Library
................

   - gh-122400(1): Handle *note ValueError: 1e3.s raised by *note
     os.stat(): 46d. in *note filecmp.dircmp: f0d. and *note
     filecmp.cmpfiles(): 154c.  Patch by Bénédikt Tran.

   - gh-122311(2): Fix some error messages in *note pickle: 95.

   - gh-122332(3): Fixed segfault with *note asyncio.Task.get_coro():
     9a9. when using an eager task factory.

   - gh-105733(4): *note ctypes.ARRAY(): 27c. is now *note soft
     deprecated: 1ea.: it no longer emits deprecation warnings and is
     not scheduled for removal.

   - gh-122087(5): Restore *note inspect.ismethoddescriptor(): 154d. and
     *note inspect.isroutine(): 154e. returning ‘False’ for *note
     functools.partial: 3ed. objects.

   - gh-122170(6): Handle *note ValueError: 1e3.s raised by *note
     os.stat(): 46d. in *note linecache: 79.  Patch by Bénédikt Tran.

   - gh-82951(7): Serializing objects with complex ‘__qualname__’ (such
     as unbound methods and nested classes) by name no longer involves
     serializing parent objects by value in pickle protocols < 4.

   - gh-113785(8): *note csv: 21. now correctly parses numeric fields
     (when used with *note csv.QUOTE_NONNUMERIC: 154f. or *note
     csv.QUOTE_STRINGS: 452.) which start with an escape character.

   - gh-122088(9): *note @warnings.deprecated: 146. now copies the
     coroutine status of functions and methods so that *note
     inspect.iscoroutinefunction(): 2c5. returns the correct result.

   - gh-120930(10): Fixed a bug introduced by gh-92081(11) that added an
     incorrect extra blank to encoded words occurring in wrapped
     headers.

   - gh-121474(12): Fix missing sanity check for ‘parties’ arg in *note
     threading.Barrier: 11b4. constructor.  Patch by Clinton Christian
     (pygeek).

   - gh-120289(13): Fixed the use-after-free issue in *note cProfile:
     20. by disallowing ‘disable()’ and ‘clear()’ in external timers.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122400

   (2) https://github.com/python/cpython/issues/122311

   (3) https://github.com/python/cpython/issues/122332

   (4) https://github.com/python/cpython/issues/105733

   (5) https://github.com/python/cpython/issues/122087

   (6) https://github.com/python/cpython/issues/122170

   (7) https://github.com/python/cpython/issues/82951

   (8) https://github.com/python/cpython/issues/113785

   (9) https://github.com/python/cpython/issues/122088

   (10) https://github.com/python/cpython/issues/120930

   (11) https://github.com/python/cpython/issues/92081

   (12) https://github.com/python/cpython/issues/121474

   (13) https://github.com/python/cpython/issues/120289


File: python.info,  Node: IDLE<6>,  Next: Core and Builtins<5>,  Prev: Library<4>,  Up: Python 3 13 0 release candidate 1

1.23.5.4 IDLE
.............

   - gh-122482(1): Change About IDLE to direct users to
     discuss.python.org instead of the now unused idle-dev email and
     mailing list.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122482


File: python.info,  Node: Core and Builtins<5>,  Next: C API<4>,  Prev: IDLE<6>,  Up: Python 3 13 0 release candidate 1

1.23.5.5 Core and Builtins
..........................

   - gh-116090(1): Fix an issue in JIT builds that prevented some *note
     for: 2c9. loops from correctly firing *note RAISE: 1552. monitoring
     events.

   - gh-122208(2): Dictionary watchers now only deliver the
     PyDict_EVENT_ADDED event when the insertion is in a known good
     state to succeed.

   - gh-122300(3): Preserve AST nodes for f-string with single-element
     format specifiers.  Patch by Pablo Galindo

   - gh-120906(4): *note frame.f_locals: 167. now supports arbitrary
     hashable objects as keys.

   - gh-122029(5): Emit ‘c_call’ events in *note sys.setprofile(): 14a8.
     when a ‘PyMethodObject’ pointing to a ‘PyCFunction’ is called.

   - gh-122026(6): Fix a bug that caused the tokenizer to not correctly
     identify mismatched parentheses inside f-strings in some
     situations.  Patch by Pablo Galindo

   - gh-118934(7): Make ‘PyEval_GetLocals’ return borrowed reference

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116090

   (2) https://github.com/python/cpython/issues/122208

   (3) https://github.com/python/cpython/issues/122300

   (4) https://github.com/python/cpython/issues/120906

   (5) https://github.com/python/cpython/issues/122029

   (6) https://github.com/python/cpython/issues/122026

   (7) https://github.com/python/cpython/issues/118934


File: python.info,  Node: C API<4>,  Next: Build<4>,  Prev: Core and Builtins<5>,  Up: Python 3 13 0 release candidate 1

1.23.5.6 C API
..............

   - gh-116622(1): Make *note PyObject_Print: 1554. work around a bug in
     Android and OpenBSD which prevented it from throwing an exception
     when trying to write to a read-only stream.

   - gh-121489(2): Export private ‘_PyBytes_Join()’ again.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116622

   (2) https://github.com/python/cpython/issues/121489


File: python.info,  Node: Build<4>,  Prev: C API<4>,  Up: Python 3 13 0 release candidate 1

1.23.5.7 Build
..............

   - gh-120522(1): Added a *note -with-app-store-compliance: 1556.
     option to patch out known issues with macOS/iOS App Store review
     processes.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/120522


File: python.info,  Node: Python 3 13 0 beta 4,  Next: Python 3 13 0 beta 3,  Prev: Python 3 13 0 release candidate 1,  Up: 変更履歴

1.23.6 Python 3.13.0 beta 4
---------------------------

'Release date: 2024-07-18'

* Menu:

* Tests: Tests<5>.
* Library: Library<5>.
* IDLE: IDLE<7>.
* Documentation: Documentation<3>.
* Core and Builtins: Core and Builtins<6>.
* C API: C API<5>.
* Build: Build<5>.


File: python.info,  Node: Tests<5>,  Next: Library<5>,  Up: Python 3 13 0 beta 4

1.23.6.1 Tests
..............

   - gh-121084(1): Fix test_typing random leaks.  Clear typing ABC
     caches when running tests for refleaks (‘-R’ option): call
     ‘_abc_caches_clear()’ on typing abstract classes and their
     subclasses.  Patch by Victor Stinner.

   - gh-121160(2): Add a test for *note readline.set_history_length():
     1559.  Note that this test may fail on readline libraries.

   - gh-121200(3): Fix ‘test_expanduser_pwd2()’ of ‘test_posixpath’.
     Call ‘getpwnam()’ to get ‘pw_dir’, since it can be different than
     ‘getpwall()’ ‘pw_dir’.  Patch by Victor Stinner.

   - gh-121188(4): When creating the JUnit XML file, regrtest now
     escapes characters which are invalid in XML, such as the chr(27)
     control character used in ANSI escape sequences.  Patch by Victor
     Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/121084

   (2) https://github.com/python/cpython/issues/121160

   (3) https://github.com/python/cpython/issues/121200

   (4) https://github.com/python/cpython/issues/121188


File: python.info,  Node: Library<5>,  Next: IDLE<7>,  Prev: Tests<5>,  Up: Python 3 13 0 beta 4

1.23.6.2 Library
................

   - gh-57141(1): The 'shallow' argument to *note filecmp.dircmp: f0d.
     (new in Python 3.13) is now keyword-only.

   - gh-121245(2): Simplify handling of the history file in
     ‘site.register_readline()’ helper.  The ‘CAN_USE_PYREPL’ variable
     now will be initialized, when imported.  Patch by Sergey B
     Kirpichev.

   - gh-121332(3): Fix constructor of *note ast: 7. nodes with custom
     ‘_attributes’.  Previously, passing custom attributes would raise a
     *note DeprecationWarning: 18a.  Passing arguments to the
     constructor that are not in ‘_fields’ or ‘_attributes’ remains
     deprecated.  Patch by Jelle Zijlstra.

   - gh-121279(4): Avoid *note NameError: 40b. for the *note warnings:
     fa. module when accessing the depracated atributes of the *note
     importlib.abc: 6c. module.

   - gh-121245(5): Fix a bug in the handling of the command history of
     the new *note REPL: 150. that caused the history file to be wiped
     at REPL exit.

   - gh-87744(6): Fix waitpid race while calling *note send_signal():
     155b. in asyncio.  Patch by Kumar Aditya.

   - gh-121018(7): Fixed other issues where *note
     argparse.ArgumentParser: 503. did not honor ‘exit_on_error=False’.

   - gh-120678(8): Fix regression in the new REPL that meant that
     globals from files passed using the ‘-i’ argument would not be
     included in the REPL's global namespace.  Patch by Alex Waygood.

   - gh-120782(9): Fix wrong references of the *note datetime: 28. types
     after reloading the module.

   - gh-120713(10): *note datetime.datetime.strftime(): c5e. now 0-pads
     years with less than four digits for the format specifiers ‘%Y’ and
     ‘%G’ on Linux.  Patch by Ben Hsing

   - gh-117983(11): Defer the ‘threading’ import in ‘importlib.util’
     until lazy loading is used.

   - gh-119189(12): When using the ‘**’ operator or *note pow(): 9a0.
     with *note Fraction: 1c8. as the base and an exponent that is not
     rational, a float, or a complex, the fraction is no longer
     converted to a float.

   - gh-118714(13): Allow ‘restart’ in post-mortem debugging of *note
     pdb: 94.  Removed restart message when the user quits pdb from
     post-mortem mode.

   - gh-105623(14): Fix performance degradation in *note
     logging.handlers.RotatingFileHandler: 153b.  Patch by Craig Robson.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/57141

   (2) https://github.com/python/cpython/issues/121245

   (3) https://github.com/python/cpython/issues/121332

   (4) https://github.com/python/cpython/issues/121279

   (5) https://github.com/python/cpython/issues/121245

   (6) https://github.com/python/cpython/issues/87744

   (7) https://github.com/python/cpython/issues/121018

   (8) https://github.com/python/cpython/issues/120678

   (9) https://github.com/python/cpython/issues/120782

   (10) https://github.com/python/cpython/issues/120713

   (11) https://github.com/python/cpython/issues/117983

   (12) https://github.com/python/cpython/issues/119189

   (13) https://github.com/python/cpython/issues/118714

   (14) https://github.com/python/cpython/issues/105623


File: python.info,  Node: IDLE<7>,  Next: Documentation<3>,  Prev: Library<5>,  Up: Python 3 13 0 beta 4

1.23.6.3 IDLE
.............

   - gh-78889(1): Stop Shell freezes by blocking user access to
     non-method sys.stdout.shell attributes, which are all private.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/78889


File: python.info,  Node: Documentation<3>,  Next: Core and Builtins<6>,  Prev: IDLE<7>,  Up: Python 3 13 0 beta 4

1.23.6.4 Documentation
......................

   - gh-121749(1): Fix documentation for *note PyModule_AddObjectRef():
     33e.

   - gh-120012(2): Clarify the behaviours of *note
     multiprocessing.Queue.empty(): 155e. and *note
     multiprocessing.SimpleQueue.empty(): 155f. on closed queues.  Patch
     by Bénédikt Tran.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/121749

   (2) https://github.com/python/cpython/issues/120012


File: python.info,  Node: Core and Builtins<6>,  Next: C API<5>,  Prev: Documentation<3>,  Up: Python 3 13 0 beta 4

1.23.6.5 Core and Builtins
..........................

   - gh-121860(1): Fix crash when rematerializing a managed dictionary
     after it was deleted.

   - gh-121814(2): Fixed the SegFault when *note PyEval_SetTrace():
     14a7. is used with no Python frame on stack.

   - gh-121295(3): Fix PyREPL console getting into a blocked state after
     interrupting a long paste

   - gh-121794(4): Fix bug in free-threaded Python where a resurrected
     object could lead to a negative ref count assertion failure.

   - gh-121657(5): Improve the *note SyntaxError: 172. message if the
     user tries to use *note yield from: 99b. outside a function.

   - gh-121609(6): Fix pasting of characters containing unicode
     character joiners in the new REPL. Patch by Marta Gomez Macias

   - gh-117482(7): Unexpected slot wrappers are no longer created for
     builtin static types in subinterpreters.

   - gh-121499(8): Fix a bug affecting how multi-line history was being
     rendered in the new REPL after interacting with the new screen
     cache.  Patch by Pablo Galindo

   - gh-121497(9): Fix a bug that was preventing the REPL to correctly
     respect the history when an input hook was set.  Patch by Pablo
     Galindo

   - gh-121012(10): Tier 2 execution now ensures that list iterators
     remain exhausted, once they become exhausted.

   - gh-121439(11): Allow tuples of length 20 in the freelist to be
     reused.

   - gh-121368(12): Fix race condition in ‘_PyType_Lookup’ in the
     free-threaded build due to a missing memory fence.  This could lead
     to ‘_PyType_Lookup’ returning incorrect results on arm64.

   - gh-121130(13): Fix f-strings with debug expressions in format
     specifiers.  Patch by Pablo Galindo

   - gh-121115(14): *note PyLong_AsNativeBytes(): 33a. no longer uses
     *note __index__(): 6e8. methods by default.  The
     ‘Py_ASNATIVEBYTES_ALLOW_INDEX’ flag has been added to allow it.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/121860

   (2) https://github.com/python/cpython/issues/121814

   (3) https://github.com/python/cpython/issues/121295

   (4) https://github.com/python/cpython/issues/121794

   (5) https://github.com/python/cpython/issues/121657

   (6) https://github.com/python/cpython/issues/121609

   (7) https://github.com/python/cpython/issues/117482

   (8) https://github.com/python/cpython/issues/121499

   (9) https://github.com/python/cpython/issues/121497

   (10) https://github.com/python/cpython/issues/121012

   (11) https://github.com/python/cpython/issues/121439

   (12) https://github.com/python/cpython/issues/121368

   (13) https://github.com/python/cpython/issues/121130

   (14) https://github.com/python/cpython/issues/121115


File: python.info,  Node: C API<5>,  Next: Build<5>,  Prev: Core and Builtins<6>,  Up: Python 3 13 0 beta 4

1.23.6.6 C API
..............

   - gh-89364(1): Export the *note PySignal_SetWakeupFd(): 1383.
     function.  Previously, the function was documented but it couldn't
     be used in 3rd party code.  Patch by Victor Stinner.

   - gh-113993(2): *note PyUnicode_InternInPlace(): 87f. no longer
     prevents its argument from being garbage collected.

     Several functions that take ‘char *’ are now documented as possibly
     preventing string objects from being garbage collected; refer to
     their documentation for details: *note
     PyUnicode_InternFromString(): 1562, *note PyDict_SetItemString():
     1563, *note PyObject_SetAttrString(): 1564, *note
     PyObject_DelAttrString(): 1565, *note PyUnicode_InternFromString():
     1562, and ‘PyModule_Add*’ convenience functions.

   - gh-113601(3): Removed debug build assertions related to interning
     strings, which were falsely triggered by stable ABI extensions.

   - gh-112136(4): Restore the private ‘_PyArg_Parser’ structure and the
     private ‘_PyArg_ParseTupleAndKeywordsFast()’ function, previously
     removed in Python 3.13 alpha 1.  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89364

   (2) https://github.com/python/cpython/issues/113993

   (3) https://github.com/python/cpython/issues/113601

   (4) https://github.com/python/cpython/issues/112136


File: python.info,  Node: Build<5>,  Prev: C API<5>,  Up: Python 3 13 0 beta 4

1.23.6.7 Build
..............

   - gh-120371(1): Support WASI SDK 22 by explicitly skipping functions
     that are just stubs in wasi-libc.

   - gh-121731(2): Fix mimalloc compile error on GNU/Hurd

   - gh-121487(3): Fix deprecation warning for ATOMIC_VAR_INIT in
     mimalloc.

   - gh-121467(4): Fix a Makefile bug that prevented mimalloc header
     files from being installed.

   - gh-121103(5): On POSIX systems, excluding macOS framework installs,
     the lib directory for the free-threaded build now includes a "t"
     suffix to avoid conflicts with a co-located default build
     installation.

   - gh-120831(6): The default minimum iOS version was increased to
     13.0.

   - gh-113565(7): Improve *note curses: 23. and *note curses.panel: 25.
     dependency checks in ‘configure’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/120371

   (2) https://github.com/python/cpython/issues/121731

   (3) https://github.com/python/cpython/issues/121487

   (4) https://github.com/python/cpython/issues/121467

   (5) https://github.com/python/cpython/issues/121103

   (6) https://github.com/python/cpython/issues/120831

   (7) https://github.com/python/cpython/issues/113565


File: python.info,  Node: Python 3 13 0 beta 3,  Next: Python 3 13 0 beta 2,  Prev: Python 3 13 0 beta 4,  Up: 変更履歴

1.23.7 Python 3.13.0 beta 3
---------------------------

'Release date: 2024-06-27'

* Menu:

* Core and Builtins: Core and Builtins<7>.
* Library: Library<6>.
* Build: Build<6>.
* C API: C API<6>.


File: python.info,  Node: Core and Builtins<7>,  Next: Library<6>,  Up: Python 3 13 0 beta 3

1.23.7.1 Core and Builtins
..........................

   - gh-120838(1): *note Py_Finalize(): 1321. and *note Py_FinalizeEx():
     ce3. now always run with the main interpreter active.

   - gh-113433(2): Subinterpreters now get cleaned up automatically
     during runtime finalization.

   - gh-119462(3): Make sure that invariants of type versioning are
     maintained: * Superclasses always have their version number
     assigned before subclasses * The version tag is always zero if the
     tag is not valid.  * The version tag is always non-zero if the tag
     is valid.

   - gh-120437(4): Fix ‘_CHECK_STACK_SPACE’ optimization problems
     introduced in gh-118322(5).

   - gh-120722(6): Correctly set the bytecode position on return
     instructions within lambdas.  Patch by Jelle Zijlstra.

   - gh-120367(7): Fix bug where compiler creates a redundant jump
     during pseudo-op replacement.  Can only happen with a synthetic AST
     that has a try on the same line as the instruction following the
     exception handler.

   - gh-113993(8): Strings interned with *note sys.intern(): 12a9. are
     again garbage-collected when no longer used, as per the
     documentation.  Strings interned with the C function *note
     PyUnicode_InternInPlace(): 87f. are still immortal.  Internals of
     the string interning mechanism have been changed.  This may affect
     performance and identities of *note str: 418. objects.

   - gh-120384(9): Fix an array out of bounds crash in
     ‘list_ass_subscript’, which could be invoked via some specificly
     tailored input: including concurrent modification of a list object,
     where one thread assigns a slice and another clears it.

   - gh-120367(10): Fix crash in compiler on code with redundant NOPs
     and JUMPs which show up after exception handlers are moved to the
     end of the code.

   - gh-120380(11): Fix Python implementation of *note pickle.Pickler:
     9ec. for *note bytes: 1a4. and *note bytearray: 508. objects when
     using protocol version 5.  Patch by Bénédikt Tran.

   - gh-120400(12): Support Linux perf profiler to see Python calls on
     RISC-V architecture.

   - gh-120221(13): Deliver real signals on Ctrl-C and Ctrl-Z in the new
     REPL. Patch by Pablo Galindo

   - gh-120346(14): Respect *note PYTHON_BASIC_REPL: 154. when running
     in interative inspect mode (‘python -i’).  Patch by Pablo Galindo

   - gh-93691(15): Fix source locations of instructions generated for
     the iterator of a for statement.

   - gh-120198(16): Fix a crash when multiple threads read and write to
     the same ‘__class__’ of an object concurrently.

   - gh-120298(17): Fix use-after free in ‘list_richcompare_impl’ which
     can be invoked via some specificly tailored evil input.

   - gh-119666(18): Fix a compiler crash in the case where two
     comprehensions in class scope both reference ‘__class__’.

   - gh-120225(19): Fix crash in compiler on empty block at end of
     exception handler.

   - gh-119933(20): Improve *note SyntaxError: 172. messages for invalid
     expressions in a type parameters bound, a type parameter constraint
     tuple or a default type parameter.  Patch by Bénédikt Tran.

   - bpo-24766(21): Fix handling of ‘doc’ argument to subclasses of
     ‘property’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/120838

   (2) https://github.com/python/cpython/issues/113433

   (3) https://github.com/python/cpython/issues/119462

   (4) https://github.com/python/cpython/issues/120437

   (5) https://github.com/python/cpython/issues/118322

   (6) https://github.com/python/cpython/issues/120722

   (7) https://github.com/python/cpython/issues/120367

   (8) https://github.com/python/cpython/issues/113993

   (9) https://github.com/python/cpython/issues/120384

   (10) https://github.com/python/cpython/issues/120367

   (11) https://github.com/python/cpython/issues/120380

   (12) https://github.com/python/cpython/issues/120400

   (13) https://github.com/python/cpython/issues/120221

   (14) https://github.com/python/cpython/issues/120346

   (15) https://github.com/python/cpython/issues/93691

   (16) https://github.com/python/cpython/issues/120198

   (17) https://github.com/python/cpython/issues/120298

   (18) https://github.com/python/cpython/issues/119666

   (19) https://github.com/python/cpython/issues/120225

   (20) https://github.com/python/cpython/issues/119933

   (21) https://bugs.python.org/issue?@action=redirect&bpo=24766


File: python.info,  Node: Library<6>,  Next: Build<6>,  Prev: Core and Builtins<7>,  Up: Python 3 13 0 beta 3

1.23.7.2 Library
................

   - gh-121027(1): Add a future warning in
     ‘functools.partial.__get__()’.  In future Python versions *note
     functools.partial: 3ed. will be a method descriptor.

   - gh-121025(2): Improve the *note __repr__(): 5e8. of *note
     functools.partialmethod: a49.  Patch by Bénédikt Tran.

   - gh-121018(3): Fixed an issue where
     ‘argparse.ArgumentParser.parses_args()’ did not honor
     ‘exit_on_error=False’ when given unrecognized arguments.  Patch by
     Ben Hsing.

   - gh-119614(4): Fix truncation of strings with embedded null
     characters in some internal operations in *note tkinter: d9.

   - gh-120910(5): When reading installed files from an egg, use
     ‘relative_to(walk_up=True)’ to honor files installed outside of the
     installation root.

   - gh-120888(6): Upgrade pip wheel bundled with ensurepip (pip 24.1.1)

   - gh-101830(7): Accessing the *note tkinter: d9. object's string
     representation no longer converts the underlying Tcl object to a
     string on Windows.

   - gh-120811(8): Fix possible memory leak in *note
     contextvars.Context.run(): 156a.

   - gh-120769(9): Make empty line in *note pdb: 94. repeats the last
     command even when the command is from ‘cmdqueue’.

   - gh-120732(10): Fix ‘name’ passing to *note unittest.mock.Mock: a1a.
     object when using *note unittest.mock.create_autospec(): 156b.

   - gh-120683(11): Fix an error in *note logging.LogRecord: fb3, when
     the integer part of the timestamp is rounded up, while the
     millisecond calculation truncates, causing the log timestamp to be
     wrong by up to 999 ms (affected roughly 1 in 8 million timestamps).

   - gh-120633(12): Move scrollbar and remove tear-off menus in
     turtledemo.

   - gh-120541(13): Improve the prompt in the "less" pager when *note
     help(): 8a5. is called with non-string argument.

   - gh-120495(14): Fix incorrect exception handling in Tab Nanny.
     Patch by Wulian233.

   - gh-120381(15): Correct *note inspect.ismethoddescriptor(): 154d. to
     check also for the lack of *note __delete__(): 156c.  Patch by Jan
     Kaliszewski.

   - gh-90425(16): The OS byte in gzip headers is now always set to 255
     when using *note gzip.compress(): 60a.

   - gh-120343(17): Fix column offset reporting for tokens that come
     after multiline f-strings in the *note tokenize: e4. module.

   - gh-119600(18): Fix *note unittest.mock.patch(): e5b. to not read
     attributes of the target when ‘new_callable’ is set.  Patch by
     Robert Collins.

   - gh-114053(19): Fix edge-case bug where *note
     typing.get_type_hints(): 67d. would produce incorrect results if
     type parameters in a class scope were overridden by assignments in
     a class scope and ‘from __future__ import annotations’ semantics
     were enabled.  Patch by Alex Waygood.

   - gh-114053(20): Fix erroneous *note NameError: 40b. when calling
     *note inspect.get_annotations(): 7de. with ‘eval_str=True`’ on a
     class that made use of PEP 695(21) type parameters in a module that
     had ‘from __future__ import annotations’ at the top of the file.
     Patch by Alex Waygood.

   - gh-120268(22): Prohibit passing ‘None’ to pure-Python *note
     datetime.date.fromtimestamp(): 156d. to achieve consistency with
     C-extension implementation.

   - gh-120244(23): Fix memory leak in *note re.sub(): 283. when the
     replacement string contains backreferences.

   - gh-120211(24): Fix *note tkinter.ttk: e2. with Tcl/Tk 9.0.

   - gh-71587(25): Fix crash in C version of *note
     datetime.datetime.strptime(): 156e. when called again on the
     restarted interpreter.

   - gh-120161(26): *note datetime: 28. no longer crashes in certain
     complex reference cycle situations.

   - gh-119698(27): Fix *note symtable.Class.get_methods(): 2c6. and
     document its behaviour.  Patch by Bénédikt Tran.

   - gh-120121(28): Add *note concurrent.futures.InvalidStateError:
     156f. to module's ‘__all__’.

   - gh-119933(29): Add the *note symtable.SymbolTableType: 1570.
     enumeration to represent the possible outputs of the *note
     symtable.SymbolTable.get_type: 1571. method.  Patch by Bénédikt
     Tran.

   - gh-120108(30): Fix calling *note copy.deepcopy(): b3c. on *note
     ast: 7. trees that have been modified to have references to parent
     nodes.  Patch by Jelle Zijlstra.

   - gh-112672(31): Support building *note tkinter: d9. with Tcl 9.0.

   - gh-65454(32): *note unittest.mock.Mock.attach_mock(): 1572. no
     longer triggers a call to a ‘PropertyMock’ being attached.

   - gh-81936(33): ‘help()’ and ‘showtopic()’ methods now respect a
     configured 'output' argument to ‘pydoc.Helper’ and not use the
     pager in such cases.  Patch by Enrico Tröger.

   - gh-119577(34): The *note DeprecationWarning: 18a. emitted when
     testing the truth value of an *note xml.etree.ElementTree.Element:
     2e8. now describes unconditionally returning ‘True’ in a future
     version rather than raising an exception in Python 3.14.

   - gh-118908(35): Limit exposed globals from internal imports and
     definitions on new REPL startup.  Patch by Eugene Triguba and Pablo
     Galindo.

   - gh-119506(36): Fix ‘io.TextIOWrapper.write()’ method breaks
     internal buffer when the method is called again during flushing
     internal buffer.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/121027

   (2) https://github.com/python/cpython/issues/121025

   (3) https://github.com/python/cpython/issues/121018

   (4) https://github.com/python/cpython/issues/119614

   (5) https://github.com/python/cpython/issues/120910

   (6) https://github.com/python/cpython/issues/120888

   (7) https://github.com/python/cpython/issues/101830

   (8) https://github.com/python/cpython/issues/120811

   (9) https://github.com/python/cpython/issues/120769

   (10) https://github.com/python/cpython/issues/120732

   (11) https://github.com/python/cpython/issues/120683

   (12) https://github.com/python/cpython/issues/120633

   (13) https://github.com/python/cpython/issues/120541

   (14) https://github.com/python/cpython/issues/120495

   (15) https://github.com/python/cpython/issues/120381

   (16) https://github.com/python/cpython/issues/90425

   (17) https://github.com/python/cpython/issues/120343

   (18) https://github.com/python/cpython/issues/119600

   (19) https://github.com/python/cpython/issues/114053

   (20) https://github.com/python/cpython/issues/114053

   (21) https://peps.python.org/pep-0695/

   (22) https://github.com/python/cpython/issues/120268

   (23) https://github.com/python/cpython/issues/120244

   (24) https://github.com/python/cpython/issues/120211

   (25) https://github.com/python/cpython/issues/71587

   (26) https://github.com/python/cpython/issues/120161

   (27) https://github.com/python/cpython/issues/119698

   (28) https://github.com/python/cpython/issues/120121

   (29) https://github.com/python/cpython/issues/119933

   (30) https://github.com/python/cpython/issues/120108

   (31) https://github.com/python/cpython/issues/112672

   (32) https://github.com/python/cpython/issues/65454

   (33) https://github.com/python/cpython/issues/81936

   (34) https://github.com/python/cpython/issues/119577

   (35) https://github.com/python/cpython/issues/118908

   (36) https://github.com/python/cpython/issues/119506


File: python.info,  Node: Build<6>,  Next: C API<6>,  Prev: Library<6>,  Up: Python 3 13 0 beta 3

1.23.7.3 Build
..............

   - gh-120671(1): Fix failing configure tests due to a missing space
     when appending to CFLAGS.

   - gh-120602(2): Correctly handle LLVM installs with
     ‘LLVM_VERSION_SUFFIX’ when building with
     ‘--enable-experimental-jit’.

   - gh-120326(3): On Windows, fix build error when ‘--disable-gil’ and
     ‘--experimental-jit’ options are combined.

   - gh-120291(4): Make the ‘python-config’ shell script compatible with
     non-bash shells.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/120671

   (2) https://github.com/python/cpython/issues/120602

   (3) https://github.com/python/cpython/issues/120326

   (4) https://github.com/python/cpython/issues/120291


File: python.info,  Node: C API<6>,  Prev: Build<6>,  Up: Python 3 13 0 beta 3

1.23.7.4 C API
..............

   - gh-120642(1): Remove the private ‘_Py_CODEUNIT’ type from the
     public C API. The internal ‘pycore_code.h’ header should now be
     used to get this internal type.  Patch by Victor Stinner.

   - gh-120858(2): *note PyDict_Next(): 1575. no longer locks the
     dictionary in the free-threaded build.  The locking needs to be
     done by the caller around the entire iteration loop.

   - gh-120642(3): Remove the following unstable functions:

        * ‘PyUnstable_Replace_Executor()’

        * ‘PyUnstable_SetOptimizer()’

        * ‘PyUnstable_GetOptimizer()’

        * ‘PyUnstable_GetExecutor()’

        * ‘PyUnstable_Optimizer_NewCounter()’

        * ‘PyUnstable_Optimizer_NewUOpOptimizer()’

     Patch by Victor Stinner.

   - gh-119344(4): The critical section API is now public as part of the
     non-limited C API.

   - gh-118789(5): Add *note
     PyUnstable_Object_ClearWeakRefsNoCallbacks(): 1576, which clears
     weakrefs without calling their callbacks.

   - gh-117511(6): Make the *note PyMutex: 141. public in the
     non-limited C API.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/120642

   (2) https://github.com/python/cpython/issues/120858

   (3) https://github.com/python/cpython/issues/120642

   (4) https://github.com/python/cpython/issues/119344

   (5) https://github.com/python/cpython/issues/118789

   (6) https://github.com/python/cpython/issues/117511


File: python.info,  Node: Python 3 13 0 beta 2,  Next: Python 3 13 0 beta 1,  Prev: Python 3 13 0 beta 3,  Up: 変更履歴

1.23.8 Python 3.13.0 beta 2
---------------------------

'Release date: 2024-06-05'

* Menu:

* Security: Security<4>.
* Core and Builtins: Core and Builtins<8>.
* Library: Library<7>.
* Tests: Tests<6>.
* Build: Build<7>.
* Windows: Windows<4>.
* C API: C API<7>.


File: python.info,  Node: Security<4>,  Next: Core and Builtins<8>,  Up: Python 3 13 0 beta 2

1.23.8.1 Security
.................

   - gh-118773(1): Fixes creation of ACLs in *note os.mkdir(): 1fe. on
     Windows to work correctly on non-English machines.

   - gh-118486(2): *note os.mkdir(): 1fe. on Windows now accepts 'mode'
     of ‘0o700’ to restrict the new directory to the current user.  This
     fixes CVE 2024-4030(3) affecting *note tempfile.mkdtemp(): 200. in
     scenarios where the base temporary directory is more permissive
     than the default.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118773

   (2) https://github.com/python/cpython/issues/118486

   (3) https://www.cve.org/CVERecord?id=CVE-2024-4030


File: python.info,  Node: Core and Builtins<8>,  Next: Library<7>,  Prev: Security<4>,  Up: Python 3 13 0 beta 2

1.23.8.2 Core and Builtins
..........................

   - gh-119724(1): Reverted improvements to error messages for
     ‘elif’/‘else’ statements not matching any valid statements, which
     made in hard to locate the syntax errors inside those ‘elif’/‘else’
     blocks.

   - gh-119842(2): Honor *note PyOS_InputHook(): 551. in the new REPL.
     Patch by Pablo Galindo

   - gh-119821(3): Fix execution of *note annotation scopes: 16d. within
     classes when ‘globals’ is set to a non-dict.  Patch by Jelle
     Zijlstra.

   - gh-119548(4): Add a ‘clear’ command to the REPL. Patch by Pablo
     Galindo

   - gh-111999(5): Fix the signature of *note str.format_map(): da4.

   - gh-119560(6): An invalid assert in beta 1 has been removed.  The
     assert would fail if ‘PyState_FindModule()’ was used in an
     extension module's init function before the module def had been
     initialized.

   - gh-119369(7): Fix deadlock during thread deletion in free-threaded
     build, which could occur when the GIL was enabled at runtime.

   - gh-119525(8): Fix deadlock involving ‘_PyType_Lookup()’ cache in
     the free-threaded build when the GIL is dynamically enabled at
     runtime.

   - gh-119311(9): Fix bug where names are unexpectedly mangled in the
     bases of generic classes.

   - gh-119395(10): Fix bug where names appearing after a generic class
     are mangled as if they are in the generic class.

   - gh-119213(11): Non-builtin modules built with argument clinic were
     crashing if used in a subinterpreter before the main interpreter.
     The objects that were causing the problem by leaking between
     interpreters carelessly have been fixed.

   - gh-119011(12): Fixes ‘type.__type_params__’ to return an empty
     tuple instead of a descriptor.

   - gh-118692(13): Avoid creating unnecessary *note StopIteration: bc8.
     instances for monitoring.

   - gh-119049(14): Fix displaying the source line for warnings created
     by the C API if the *note warnings: fa. module had not yet been
     imported.

   - gh-118844(15): Fix build failures when configuring with both
     ‘--disable-gil’ and ‘--enable-experimental-jit’.

   - gh-118921(16): Add ‘copy()’ method for ‘FrameLocalsProxy’ which
     returns a snapshot ‘dict’ for local variables.

   - gh-117657(17): Fix data races on the field that stores a pointer to
     the interpreter's main thread that occur in free-threaded builds.

   - gh-118561(18): Fix race condition in free-threaded build where
     ‘list.extend()’ could expose uninitialised memory to concurrent
     readers.

   - gh-117195(19): Avoid assertion failure for debug builds when
     calling ‘object.__sizeof__(1)’

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/119724

   (2) https://github.com/python/cpython/issues/119842

   (3) https://github.com/python/cpython/issues/119821

   (4) https://github.com/python/cpython/issues/119548

   (5) https://github.com/python/cpython/issues/111999

   (6) https://github.com/python/cpython/issues/119560

   (7) https://github.com/python/cpython/issues/119369

   (8) https://github.com/python/cpython/issues/119525

   (9) https://github.com/python/cpython/issues/119311

   (10) https://github.com/python/cpython/issues/119395

   (11) https://github.com/python/cpython/issues/119213

   (12) https://github.com/python/cpython/issues/119011

   (13) https://github.com/python/cpython/issues/118692

   (14) https://github.com/python/cpython/issues/119049

   (15) https://github.com/python/cpython/issues/118844

   (16) https://github.com/python/cpython/issues/118921

   (17) https://github.com/python/cpython/issues/117657

   (18) https://github.com/python/cpython/issues/118561

   (19) https://github.com/python/cpython/issues/117195


File: python.info,  Node: Library<7>,  Next: Tests<6>,  Prev: Core and Builtins<8>,  Up: Python 3 13 0 beta 2

1.23.8.3 Library
................

   - gh-119819(1): Fix regression to allow logging configuration with
     multiprocessing queue types.

   - gh-117142(2): The *note ctypes: 22. module may now be imported in
     all subinterpreters, including those that have their own GIL.

   - gh-118835(3): Fix _pyrepl crash when using custom prompt with ANSI
     escape codes.

   - gh-117398(4): The ‘_datetime’ module (C implementation for *note
     datetime: 28.) now supports being imported in multiple
     interpreters.

   - gh-89727(5): Fix issue with *note shutil.rmtree(): 2d8. where a
     *note RecursionError: d39. is raised on deep directory trees.

   - gh-89727(6): Partially fix issue with *note shutil.rmtree(): 2d8.
     where a *note RecursionError: d39. is raised on deep directory
     trees.  A recursion error is no longer raised when
     ‘rmtree.avoids_symlink_attacks’ is false.

   - gh-119118(7): Fix performance regression in the *note tokenize: e4.
     module by caching the ‘line’ token attribute and calculating the
     column offset more efficiently.

   - gh-89727(8): Fix issue with *note os.fwalk(): b29. where a *note
     RecursionError: d39. was raised on deep directory trees by
     adjusting the implementation to be iterative instead of recursive.

   - gh-119588(9): ‘zipfile.Path.is_symlink’ now assesses if the given
     path is a symlink.

   - gh-119555(10): Catch *note SyntaxError: 172. from *note compile():
     177. in the runsource() method of the InteractiveColoredConsole.
     Patch by Sergey B Kirpichev.

   - gh-113892(11): Now, the method ‘sock_connect’ of *note
     asyncio.ProactorEventLoop: 5d4. raises a *note ValueError: 1e3. if
     given socket is not in non-blocking mode, as well as in other loop
     implementations.

   - gh-119443(12): The interactive REPL no longer runs with ‘from
     __future__ import annotations’ enabled.  Patch by Jelle Zijlstra.

   - gh-117398(13): Objects in the datetime C-API are now all statically
     allocated, which means better memory safety, especially when the
     module is reloaded.  This should be transparent to users.

   - gh-118894(14): *note asyncio: 8. REPL now has the same capabilities
     as PyREPL.

   - gh-118911(15): In PyREPL, updated ‘maybe-accept’'s logic so that if
     the user hits ‘Enter’ twice, they are able to terminate the block
     even if there's trailing whitespace.  Also, now when the user hits
     arrow up, the cursor is on the last functional line.  This matches
     IPython's behavior.  Patch by Aya Elsayed.

   - gh-111201(16): Remove dependency to *note readline: a8. from the
     new Python REPL.

   - gh-119174(17): Fix high DPI causes turtledemo(turtle-graphics
     examples) windows blurry Patch by Wulian233 and Terry Jan Reedy

   - gh-119121(18): Fix a NameError happening in
     ‘asyncio.staggered.staggered_race’.  This function is now tested.

   - gh-119113(19): Fix issue where *note
     pathlib.PurePath.with_suffix(): 157b. didn't raise *note TypeError:
     502. when given ‘None’ as a suffix.

   - gh-118643(20): Fix an AttributeError in the *note email: 32. module
     when re-fold a long address list.  Also fix more cases of incorrect
     encoding of the address separator in the address list.

   - gh-58933(21): Make *note pdb: 94. return to caller frame correctly
     when ‘f_trace’ of the caller frame is not set

   - gh-118895(22): Setting attributes on *note typing.NoDefault: 243.
     now raises *note AttributeError: 326. instead of *note TypeError:
     502.

   - gh-118868(23): Fixed issue where kwargs were no longer passed to
     the logging handler QueueHandler

   - gh-118851(24): ‘ctx’ arguments to the constructors of *note ast: 7.
     node classes now default to *note ast.Load(): 189.  Patch by Jelle
     Zijlstra.

   - gh-118760(25): Restore the default value of ‘tkiter.wantobjects’ to
     ‘1’.

   - gh-118760(26): Fix errors in calling Tkinter bindings on Windows.

   - gh-118507(27): Fix *note os.path.isfile(): 9df. on Windows for
     pipes.  Speedup *note os.path.isjunction(): 470. and *note
     os.path.lexists(): 9dd. on Windows with a native implementation.

   - gh-118772(28): Allow *note typing.TypeVar: 143. instances without a
     default to follow instances without a default in some cases.  Patch
     by Jelle Zijlstra.

   - gh-110863(29): *note os.path.realpath(): 206. now suppresses any
     *note OSError: 3f0. from *note os.readlink(): 8ee. when 'strict'
     mode is disabled (the default).

   - gh-118263(30): Speed up *note os.path.splitroot(): 471. & *note
     os.path.normpath(): 12e9. with a direct C call.

   - gh-118033(31): Fix *note dataclasses.dataclass(): 1ad. not creating
     a ‘__weakref__’ slot when subclassing *note typing.Generic: 157c.

   - gh-106531(32): In *note importlib.resources: 6f, sync with
     importlib_resources 6.3.2(33), including: ‘MultiplexedPath’ now
     expects ‘Traversable’ paths, deprecating string arguments to
     ‘MultiplexedPath’; Enabled support for resources in namespace
     packages in zip files; Fixed ‘NotADirectoryError’ when calling
     files on a subdirectory of a namespace package.

   - gh-113978(34): Ignore warnings on text completion inside REPL.

   - gh-103956(35): Fix lack of newline characters in *note trace: e6.
     module output when line tracing is enabled but source code line for
     current frame is not available.

   - gh-92081(36): Fix missing spaces in email headers when the spaces
     are mixed with encoded 8-bit characters.

   - gh-103194(37): Prepare Tkinter for C API changes in Tcl 8.7/9.0 to
     avoid ‘_tkinter.Tcl_Obj’ being unexpectedly returned instead of
     *note bool: 434, *note str: 418, *note bytearray: 508, or *note
     int: 238.

   - gh-87106(38): Fixed handling in *note inspect.Signature.bind():
     157d. of keyword arguments having the same name as positional-only
     arguments when a variadic keyword argument (e.g.  ‘**kwargs’) is
     present.

   - bpo-45767(39): Fix integer conversion in *note os.major(): 157e,
     *note os.minor(): 157f, and *note os.makedev(): 1580.  Support
     device numbers larger than ‘2**63-1’.  Support non-existent device
     number (‘NODEV’).

   - gh-67693(40): Fix *note urllib.parse.urlunparse(): 153a. and *note
     urllib.parse.urlunsplit(): 1539. for URIs with path starting with
     multiple slashes and no authority.  Based on patch by Ashwin
     Ramaswami.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/119819

   (2) https://github.com/python/cpython/issues/117142

   (3) https://github.com/python/cpython/issues/118835

   (4) https://github.com/python/cpython/issues/117398

   (5) https://github.com/python/cpython/issues/89727

   (6) https://github.com/python/cpython/issues/89727

   (7) https://github.com/python/cpython/issues/119118

   (8) https://github.com/python/cpython/issues/89727

   (9) https://github.com/python/cpython/issues/119588

   (10) https://github.com/python/cpython/issues/119555

   (11) https://github.com/python/cpython/issues/113892

   (12) https://github.com/python/cpython/issues/119443

   (13) https://github.com/python/cpython/issues/117398

   (14) https://github.com/python/cpython/issues/118894

   (15) https://github.com/python/cpython/issues/118911

   (16) https://github.com/python/cpython/issues/111201

   (17) https://github.com/python/cpython/issues/119174

   (18) https://github.com/python/cpython/issues/119121

   (19) https://github.com/python/cpython/issues/119113

   (20) https://github.com/python/cpython/issues/118643

   (21) https://github.com/python/cpython/issues/58933

   (22) https://github.com/python/cpython/issues/118895

   (23) https://github.com/python/cpython/issues/118868

   (24) https://github.com/python/cpython/issues/118851

   (25) https://github.com/python/cpython/issues/118760

   (26) https://github.com/python/cpython/issues/118760

   (27) https://github.com/python/cpython/issues/118507

   (28) https://github.com/python/cpython/issues/118772

   (29) https://github.com/python/cpython/issues/110863

   (30) https://github.com/python/cpython/issues/118263

   (31) https://github.com/python/cpython/issues/118033

   (32) https://github.com/python/cpython/issues/106531

   (33) 
https://importlib-resources.readthedocs.io/en/latest/history.html#v6-3-2

   (34) https://github.com/python/cpython/issues/113978

   (35) https://github.com/python/cpython/issues/103956

   (36) https://github.com/python/cpython/issues/92081

   (37) https://github.com/python/cpython/issues/103194

   (38) https://github.com/python/cpython/issues/87106

   (39) https://bugs.python.org/issue?@action=redirect&bpo=45767

   (40) https://github.com/python/cpython/issues/67693


File: python.info,  Node: Tests<6>,  Next: Build<7>,  Prev: Library<7>,  Up: Python 3 13 0 beta 2

1.23.8.4 Tests
..............

   - gh-119050(1): regrtest test runner: Add XML support to the refleak
     checker (-R option).  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/119050


File: python.info,  Node: Build<7>,  Next: Windows<4>,  Prev: Tests<6>,  Up: Python 3 13 0 beta 2

1.23.8.5 Build
..............

   - gh-119729(1): On POSIX systems, the pkg-config (‘.pc’) filenames
     now include the ABI flags, which may include debug ("d") and
     free-threaded ("t").  For example: * ‘python-3.14.pc’ (default,
     non-debug build) * ‘python-3.14d.pc’ (default, debug build) *
     ‘python-3.14t.pc’ (free-threaded build)

   - gh-115119(2): Fall back to the bundled libmpdec if a system version
     cannot be found.

   - gh-119132(3): Update *note sys.version: 15e. to identify whether
     the build is default build or free-threading build.  Patch By
     Donghee Na.

   - gh-118836(4): Fix an ‘AssertionError’ when building with
     ‘--enable-experimental-jit’ and the compiler emits a ‘SHT_NOTE’
     section.

   - gh-118943(5): Fix a possible race condition affecting parallel
     builds configured with ‘--enable-experimental-jit’, in which
     compilation errors could be caused by an incompletely-generated
     header file.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/119729

   (2) https://github.com/python/cpython/issues/115119

   (3) https://github.com/python/cpython/issues/119132

   (4) https://github.com/python/cpython/issues/118836

   (5) https://github.com/python/cpython/issues/118943


File: python.info,  Node: Windows<4>,  Next: C API<7>,  Prev: Build<7>,  Up: Python 3 13 0 beta 2

1.23.8.6 Windows
................

   - gh-119679(1): Ensures correct import libraries are included in
     Windows installs.

   - gh-119690(2): Adds Unicode support and fixes audit events for
     ‘_winapi.CreateNamedPipe’.

   - gh-111201(3): Add support for new pyrepl on Windows

   - gh-119070(4): Fixes ‘py.exe’ handling of shebangs like
     ‘/usr/bin/env python3.12’, which were previously interpreted as
     ‘python3.exe’ instead of ‘python3.12.exe’.

   - gh-117505(5): Fixes an issue with the Windows installer not running
     ensurepip in a fully isolated environment.  This could cause
     unexpected interactions with the user site-packages.

   - gh-118209(6): Avoid crashing in *note mmap: 83. on Windows when the
     mapped memory is inaccessible due to file system errors or access
     violations.

   - gh-116145(7): Updated bundled Tcl/Tk to 8.6.14.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/119679

   (2) https://github.com/python/cpython/issues/119690

   (3) https://github.com/python/cpython/issues/111201

   (4) https://github.com/python/cpython/issues/119070

   (5) https://github.com/python/cpython/issues/117505

   (6) https://github.com/python/cpython/issues/118209

   (7) https://github.com/python/cpython/issues/116145


File: python.info,  Node: C API<7>,  Prev: Windows<4>,  Up: Python 3 13 0 beta 2

1.23.8.7 C API
..............

   - gh-119585(1): Fix crash when a thread state that was created by
     *note PyGILState_Ensure(): 385. calls a destructor that during
     *note PyThreadState_Clear(): 1585. that calls back into *note
     PyGILState_Ensure(): 385. and *note PyGILState_Release(): 386.
     This might occur when in the free-threaded build or when using
     thread-local variables whose destructors call *note
     PyGILState_Ensure(): 385.

   - gh-119336(2): Restore the removed ‘_PyLong_NumBits()’ function.  It
     is used by the pywin32 project.  Patch by Ethan Smith

   - gh-119247(3): Added ‘Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST’ and
     ‘Py_END_CRITICAL_SECTION_SEQUENCE_FAST’ macros to make it possible
     to use PySequence_Fast APIs safely when free-threaded, and update
     str.join to work without the GIL using them.

   - gh-111389(4): Add *note PyHASH_MULTIPLIER: 1586. constant: prime
     multiplier used in string and various other hashes.  Patch by
     Victor Stinner.

   - gh-116984(5): Make mimalloc includes relative to the current file
     to avoid embedders or extensions needing to include
     ‘Internal/mimalloc’ if they are already including internal CPython
     headers.

   - gh-118789(6): Restore ‘_PyWeakref_ClearRef’ that was previously
     removed in Python 3.13 alpha 1.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/119585

   (2) https://github.com/python/cpython/issues/119336

   (3) https://github.com/python/cpython/issues/119247

   (4) https://github.com/python/cpython/issues/111389

   (5) https://github.com/python/cpython/issues/116984

   (6) https://github.com/python/cpython/issues/118789


File: python.info,  Node: Python 3 13 0 beta 1,  Next: Python 3 13 0 alpha 6,  Prev: Python 3 13 0 beta 2,  Up: 変更履歴

1.23.9 Python 3.13.0 beta 1
---------------------------

'Release date: 2024-05-08'

* Menu:

* Security: Security<5>.
* Core and Builtins: Core and Builtins<9>.
* Library: Library<8>.
* Documentation: Documentation<4>.
* Build: Build<8>.
* Windows: Windows<5>.
* macOS: macOS<4>.
* IDLE: IDLE<8>.
* C API: C API<8>.


File: python.info,  Node: Security<5>,  Next: Core and Builtins<9>,  Up: Python 3 13 0 beta 1

1.23.9.1 Security
.................

   - gh-116741(1): Update bundled libexpat to 2.6.2

   - gh-117233(2): Detect BLAKE2, SHA3, Shake, & truncated SHA512
     support in the OpenSSL-ish libcrypto library at build time.  This
     allows *note hashlib: 5e. to be used with libraries that do not to
     support every algorithm that upstream OpenSSL does.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116741

   (2) https://github.com/python/cpython/issues/117233


File: python.info,  Node: Core and Builtins<9>,  Next: Library<8>,  Prev: Security<5>,  Up: Python 3 13 0 beta 1

1.23.9.2 Core and Builtins
..........................

   - gh-118414(1): Add instrumented opcodes to YIELD_VALUE assertion for
     tracing cases.

   - gh-117953(2): When a builtin or extension module is imported for
     the first time, while a subinterpreter is active, the module's init
     function is now run by the main interpreter first before import
     continues in the subinterpreter.  Consequently, single-phase init
     modules now fail in an isolated subinterpreter without the init
     function running under that interpreter, whereas before it would
     run under the subinterpreter 'before' failing, potentially leaving
     behind global state and callbacks and otherwise leaving the module
     in an inconsistent state.

   - gh-117549(3): Don't use designated initializer syntax in inline
     functions in internal headers.  They cause problems for C++ or MSVC
     users who aren't yet using the latest C++ standard (C++20).  While
     internal, pycore_backoff.h, is included (indirectly, via
     pycore_code.h) by some key 3rd party software that does so for
     speed.

   - gh-95382(4): Improve performance of *note json.dumps(): d13. and
     *note json.dump(): d12. when using the argument 'indent'.
     Depending on the data the encoding using *note json.dumps(): d13.
     with 'indent' can be up to 2 to 3 times faster.

   - gh-116322(5): In ‘--disable-gil’ builds, the GIL will be enabled
     while loading C extension modules.  If the module indicates that it
     supports running without the GIL, the GIL will be disabled once
     loading is complete.  Otherwise, the GIL will remain enabled for
     the remainder of the interpreter's lifetime.  This behavior does
     not apply if the GIL has been explicitly enabled or disabled with
     ‘PYTHON_GIL’ or ‘-Xgil’.

   - gh-118513(6): Fix incorrect *note UnboundLocalError: 14df. when two
     comprehensions in the same function both reference the same name,
     and in one comprehension the name is bound while in the other it's
     an implicit global.

   - gh-118518(7): Allow the Linux perf support to work without frame
     pointers using perf's advanced JIT support.  The feature is
     activated when using the ‘PYTHON_PERF_JIT_SUPPORT’ environment
     variable or when running Python with ‘-Xperf_jit’.  Patch by Pablo
     Galindo.

   - gh-117514(8): Add ‘sys._is_gil_enabled()’ function that returns
     whether the GIL is currently enabled.  In the default build it
     always returns ‘True’ because the GIL is always enabled.  In the
     free-threaded build, it may return ‘True’ or ‘False’.

   - gh-118164(9): Break a loop between the Python implementation of the
     *note decimal: 2e. module and the Python code for integer to string
     conversion.  Also optimize integer to string conversion for values
     in the range from 9_000 to 135_000 decimal digits.

   - gh-118473(10): Fix *note sys.set_asyncgen_hooks(): 158a. not to be
     partially set when raising *note TypeError: 502.

   - gh-118465(11): Compiler populates the new ‘__firstlineno__’ field
     on a class with the line number of the first line of the class
     definition.

   - gh-118492(12): Fix an issue where the type cache can expose a
     previously accessed attribute when a finalizer is run.

   - gh-117714(13): update ‘async_generator.athrow().close()’ and
     ‘async_generator.asend().close()’ to close their section of the
     underlying async generator

   - gh-111201(14): The *note interactive: 14f. interpreter is now
     implemented in Python, which allows for a number of new features
     like colors, multiline input, history viewing, and paste mode.
     Contributed by Pablo Galindo, Łukasz Langa and Lysandros Nikolaou
     based on code from the PyPy project.

   - gh-74929(15): Implement PEP 667: converted *note
     FrameType.f_locals: 167. and *note PyFrame_GetLocals(): 3f8. to
     return a write-through proxy object when the frame refers to a
     function or comprehension.

   - gh-116767(16): Fix crash in compiler on 'async with' that has many
     context managers.

   - gh-118335(17): Change how to use the tier 2 interpreter.  Instead
     of running Python with ‘-X uops’ or setting the environment
     variable ‘PYTHON_UOPS=1’, this choice is now made at build time by
     configuring with ‘--enable-experimental-jit=interpreter’.

     'Beware!'  This changes the environment variable to enable or
     disable micro-ops to ‘PYTHON_JIT’.  The old ‘PYTHON_UOPS’ is no
     longer used.

   - gh-118306(18): Update JIT compilation to use LLVM 18

   - gh-118160(19): *note Annotation scopes: 16d. within classes can now
     contain comprehensions.  However, such comprehensions are not
     inlined into their parent scope at runtime.  Patch by Jelle
     Zijlstra.

   - gh-118272(20): Fix bug where ‘generator.close’ does not free the
     generator frame's locals.

   - gh-118216(21): Don't consider *note __future__: 0. imports with
     dots before the module name.

   - gh-118074(22): Make sure that the Executor objects in the
     COLD_EXITS array aren't assumed to be GC-able (which would access
     bytes outside the object).

   - gh-107674(23): Lazy load frame line number to improve performance
     of tracing

   - gh-118082(24): Improve *note SyntaxError: 172. message for imports
     without names, like in ‘from x import’ and ‘import’ cases.  It now
     points out to users that *note import: 5ac. expects at least one
     name after it.

   - gh-118090(25): Improve *note SyntaxError: 172. message for empty
     type param brackets.

   - gh-117958(26): Added a ‘get_jit_code()’ method to access JIT
     compiled machine code from the UOp Executor when the experimental
     JIT is enabled.  Patch by Anthony Shaw.

   - gh-117901(27): Add option for compiler's codegen to save nested
     instruction sequences for introspection.

   - gh-116622(28): Redirect stdout and stderr to system log when
     embedded in an Android app.

   - gh-109118(29): *note annotation scope: 16d. within class scopes can
     now contain lambdas.

   - gh-117894(30): Prevent ‘agen.aclose()’ objects being re-used after
     ‘.throw()’.

   - gh-117881(31): prevent concurrent access to an async generator via
     athrow().throw() or asend().throw()

   - gh-117536(32): Fix a *note RuntimeWarning: 1a2. when calling
     ‘agen.aclose().throw(Exception)’.

   - gh-117755(33): Fix mimalloc allocator for huge memory allocation
     (around 8,589,934,592 GiB) on s390x.  Patch by Victor Stinner.

   - gh-117750(34): Fix issue where an object's dict would get out of
     sync with the object's internal values when being cleared.
     ‘obj.__dict__.clear()’ now clears the internal values, but leaves
     the dict attached to the object.

   - gh-117431(35): Improve the performance of the following *note
     bytes: 1a4. and *note bytearray: 508. methods by adapting them to
     the *note METH_FASTCALL: 158b. calling convention:

        * ‘count()’

        * ‘find()’

        * ‘index()’

        * ‘rfind()’

        * ‘rindex()’

   - gh-117709(36): Speed up calls to *note str(): 418. with
     positional-only argument, by using the PEP 590(37) ‘vectorcall’
     calling convention.  Patch by Erlend Aasland.

   - gh-117680(38): Give ‘_PyInstructionSequence’ a Python interface and
     use it in tests.

   - gh-115776(39): Statically allocated objects are, by definition,
     immortal so must be marked as such regardless of whether they are
     in extension modules or not.

   - gh-117385(40): Remove unhandled ‘PY_MONITORING_EVENT_BRANCH’ and
     ‘PY_MONITORING_EVENT_EXCEPTION_HANDLED’ events from *note
     sys.settrace(): 14a9.

   - gh-116322(41): Extension modules may indicate to the runtime that
     they can run without the GIL. Multi-phase init modules do so by
     calling providing ‘Py_MOD_GIL_NOT_USED’ for the ‘Py_mod_gil’ slot,
     while single-phase init modules call ‘PyUnstable_Module_SetGIL(mod,
     Py_MOD_GIL_NOT_USED)’ from their init function.

   - gh-116129(42): Implement PEP 696(43), adding support for defaults
     on type parameters.  Patch by Jelle Zijlstra.

   - gh-93502(44): Add two new functions to the C-API, *note
     PyRefTracer_SetTracer(): 345. and *note PyRefTracer_GetTracer():
     346, that allows to track object creation and destruction the same
     way the *note tracemalloc: e8. module does.  Patch by Pablo Galindo

   - gh-107674(45): Improved the performance of *note sys.settrace():
     14a9. significantly

   - gh-95754(46): Improve the error message when a script shadowing a
     module from the standard library causes *note AttributeError: 326.
     to be raised.  Similarly, improve the error message when a script
     shadowing a third party module attempts to access an attribute from
     that third party module while still initialising.

   - gh-99180(47): Elide uninformative traceback indicators in ‘return’
     and simple ‘assignment’ statements.  Patch by Pablo Galindo.

   - gh-105879(48): Allow the 'globals' and 'locals' arguments to *note
     exec(): 164. and *note eval(): 165. to be passed as keywords.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118414

   (2) https://github.com/python/cpython/issues/117953

   (3) https://github.com/python/cpython/issues/117549

   (4) https://github.com/python/cpython/issues/95382

   (5) https://github.com/python/cpython/issues/116322

   (6) https://github.com/python/cpython/issues/118513

   (7) https://github.com/python/cpython/issues/118518

   (8) https://github.com/python/cpython/issues/117514

   (9) https://github.com/python/cpython/issues/118164

   (10) https://github.com/python/cpython/issues/118473

   (11) https://github.com/python/cpython/issues/118465

   (12) https://github.com/python/cpython/issues/118492

   (13) https://github.com/python/cpython/issues/117714

   (14) https://github.com/python/cpython/issues/111201

   (15) https://github.com/python/cpython/issues/74929

   (16) https://github.com/python/cpython/issues/116767

   (17) https://github.com/python/cpython/issues/118335

   (18) https://github.com/python/cpython/issues/118306

   (19) https://github.com/python/cpython/issues/118160

   (20) https://github.com/python/cpython/issues/118272

   (21) https://github.com/python/cpython/issues/118216

   (22) https://github.com/python/cpython/issues/118074

   (23) https://github.com/python/cpython/issues/107674

   (24) https://github.com/python/cpython/issues/118082

   (25) https://github.com/python/cpython/issues/118090

   (26) https://github.com/python/cpython/issues/117958

   (27) https://github.com/python/cpython/issues/117901

   (28) https://github.com/python/cpython/issues/116622

   (29) https://github.com/python/cpython/issues/109118

   (30) https://github.com/python/cpython/issues/117894

   (31) https://github.com/python/cpython/issues/117881

   (32) https://github.com/python/cpython/issues/117536

   (33) https://github.com/python/cpython/issues/117755

   (34) https://github.com/python/cpython/issues/117750

   (35) https://github.com/python/cpython/issues/117431

   (36) https://github.com/python/cpython/issues/117709

   (37) https://peps.python.org/pep-0590/

   (38) https://github.com/python/cpython/issues/117680

   (39) https://github.com/python/cpython/issues/115776

   (40) https://github.com/python/cpython/issues/117385

   (41) https://github.com/python/cpython/issues/116322

   (42) https://github.com/python/cpython/issues/116129

   (43) https://peps.python.org/pep-0696/

   (44) https://github.com/python/cpython/issues/93502

   (45) https://github.com/python/cpython/issues/107674

   (46) https://github.com/python/cpython/issues/95754

   (47) https://github.com/python/cpython/issues/99180

   (48) https://github.com/python/cpython/issues/105879


File: python.info,  Node: Library<8>,  Next: Documentation<4>,  Prev: Core and Builtins<9>,  Up: Python 3 13 0 beta 1

1.23.9.3 Library
................

   - gh-118418(1): A *note DeprecationWarning: 18a. is now emitted if
     you fail to pass a value to the new 'type_params' parameter of
     ‘typing._eval_type()’ or ‘typing.ForwardRef._evaluate()’.  (Using
     either of these private and undocumented functions is discouraged
     to begin with, but failing to pass a value to the ‘type_params’
     parameter may lead to incorrect behaviour on Python 3.12 or newer.)

   - gh-118660(2): Add an optional second type parameter to *note
     typing.ContextManager: c5c. and *note typing.AsyncContextManager:
     158d, representing the return types of *note __exit__(): 12ce. and
     *note __aexit__(): 158e. respectively.  This parameter defaults to
     ‘bool | None’.

   - gh-118650(3): The ‘enum’ module allows method named ‘_repr_*’ to be
     defined on ‘Enum’ types.

   - gh-118648(4): Add type parameter defaults to *note
     typing.Generator: 158f. and *note typing.AsyncGenerator: 1590.

   - gh-101137(5): Mime type ‘text/x-rst’ is now supported by *note
     mimetypes: 82.

   - gh-118164(6): The Python implementation of the ‘decimal’ module
     could appear to hang in relatively small power cases (like
     ‘2**117’) if context precision was set to a very high value.  A
     different method to check for exactly representable results is used
     now that doesn't rely on computing ‘10**precision’ (which could be
     effectively too large to compute).

   - gh-111744(7): ‘breakpoint()’ and ‘pdb.set_trace()’ now enter the
     debugger immediately after the call rather than before the next
     line is executed.

   - gh-118500(8): Add *note pdb: 94. support for zipapps

   - gh-118406(9): Add signature for *note sqlite3.Connection: 226.
     objects.

   - gh-101732(10): Use a Y2038 compatible openssl time function when
     available.

   - gh-118404(11): Fix *note inspect.signature(): 703. for
     non-comparable callables.

   - gh-118402(12): Fix *note inspect.signature(): 703. for the result
     of the *note functools.cmp_to_key(): 11aa. call.

   - gh-116622(13): On Android, *note sysconfig.get_platform: 1213. now
     returns the format specified by PEP 738(14).

   - gh-118285(15): Allow to specify the signature of custom callable
     instances of extension type by the ‘__text_signature__’ attribute.
     Specify signatures of *note operator.attrgetter: e00, *note
     operator.itemgetter: a30, and *note operator.methodcaller: e01.
     instances.

   - gh-118314(16): Fix an edge case in *note binascii.a2b_base64():
     1591. strict mode, where excessive padding is not detected when no
     padding is necessary.

   - gh-118271(17): Add the ‘PhotoImage’ methods ‘read()’ to read an
     image from a file and ‘data()’ to get the image data.  Add
     'background' and 'grayscale' parameters to ‘PhotoImage’ method
     ‘write()’.

   - gh-118225(18): Add the ‘PhotoImage’ method ‘copy_replace()’ to copy
     a region from one image to other image, possibly with pixel zooming
     and/or subsampling.  Add 'from_coords' parameter to ‘PhotoImage’
     methods ‘copy()’, ‘zoom()’ and ‘subsample()’.  Add 'zoom' and
     'subsample' parameters to ‘PhotoImage’ method ‘copy()’.

   - gh-118221(19): Fix a bug where *note sqlite3.Connection.iterdump():
     228. could fail if a custom *note row factory: 1592. was used.
     Patch by Erlend Aasland.

   - gh-118013(20): Fix regression introduced in gh-103193(21) that
     meant that calling *note inspect.getattr_static(): 461. on an
     instance would cause a strong reference to that instance's class to
     persist in an internal cache in the *note inspect: 72. module.
     This caused unexpected memory consumption if the class was
     dynamically created, the class held strong references to other
     objects which took up a significant amount of memory, and the cache
     contained the sole strong reference to the class.  The fix for the
     regression leads to a slowdown in ‘getattr_static()’, but the
     function should still be significantly faster than it was in Python
     3.11.  Patch by Alex Waygood.

   - gh-118218(22): Speed up *note itertools.pairwise(): 7e0. in the
     common case by up to 1.8x.

   - gh-117486(23): Improve the behavior of user-defined subclasses of
     *note ast.AST: 18b.  Such classes will now require no changes in
     the usual case to conform with the behavior changes of the *note
     ast: 7. module in Python 3.13.  Patch by Jelle Zijlstra.

   - gh-90848(24): Fixed *note unittest.mock.create_autospec(): 156b. to
     configure parent mock with keyword arguments.

   - gh-118168(25): Fix incorrect argument substitution when *note
     typing.Unpack: 1593. is used with the builtin *note tuple: 349.
     ‘typing.Unpack’ now raises *note TypeError: 502. when used with
     certain invalid types.  Patch by Jelle Zijlstra.

   - gh-118131(26): Add command-line interface for the *note random: a6.
     module.  Patch by Hugo van Kemenade.

   - gh-118107(27): Fix *note zipimport: 118. reading of ZIP64 files
     with file entries that are too big or offset too far.

   - gh-102511(28): Fix *note os.path.normpath(): 12e9. for UNC paths on
     Windows.  Speed up *note os.path.splitroot(): 471. with a native
     implementation.

   - gh-117535(29): Change the unknown filename of *note warnings: fa.
     from ‘sys’ to ‘<sys>’ to clarify that it's not a real filename.

   - gh-114053(30): Fix erroneous *note NameError: 40b. when calling
     *note typing.get_type_hints(): 67d. on a class that made use of PEP
     695(31) type parameters in a module that had ‘from __future__
     import annotations’ at the top of the file.  Patch by Alex Waygood.

   - gh-116931(32): Add parameter 'fileobj' check for *note
     tarfile.TarFile.addfile(): 1594.

   - gh-117995(33): Don't raise *note DeprecationWarning: 18a. when a
     *note sequence: 4be. of parameters is used to bind indexed,
     nameless placeholders.  See also gh-100668(34).

   - gh-80361(35): Fix TypeError in *note
     email.message.Message.get_payload(): 119d. when the charset is RFC
     2231(36) encoded.

   - gh-86650(37): Fix IndexError when parse some emails with invalid
     Message-ID (including one-off addresses generated by Microsoft
     Outlook).

   - gh-117691(38): Improve the error messages emitted by *note tarfile:
     c8. deprecation warnings relating to PEP 706.  If a ‘filter’
     argument is not provided to ‘extract()’ or ‘extractall’, the
     deprecation warning now points to the line in the user's code where
     the relevant function was called.  Patch by Alex Waygood.

   - gh-115874(39): Fixed a possible segfault during garbage collection
     of ‘_asyncio.FutureIter’ objects.  Patch by Savannah Ostrowski.

   - gh-115060(40): Speed up *note pathlib.Path.glob(): 20e. by omitting
     an initial *note is_dir(): 211. call.  As a result of this change,
     *note glob(): 20e. can no longer raise *note OSError: 3f0.

   - gh-77102(41): *note site: b5. module now parses ‘.pth’ file with
     UTF-8 first, and *note locale encoding: 223. if
     ‘UnicodeDecodeError’ happened.  It supported only locale encoding
     before.

   - gh-76785(42): We've exposed the low-level ‘_interpreters’ module
     for the sake of the PyPI implementation of PEP 734(43).  It was
     sometimes available as the ‘_xxsubinterpreters’ module and was
     formerly used only for testing.  For the most part, it should be
     considered an internal module, like ‘_thread’ and ‘_imp’.  See
     ‘https://discuss.python.org/t/pep-734-multiple-interpreters-in-the-stdlib/41147/26’.

   - gh-115060(44): Speed up *note pathlib.Path.glob(): 20e. by not
     scanning directories for non-wildcard pattern segments.

   - gh-117727(45): Speed up *note pathlib.Path.iterdir(): 1595. by
     using *note os.scandir(): a2d. internally.

   - gh-117586(46): Speed up *note pathlib.Path.walk(): 475. by working
     with strings internally.

   - gh-117722(47): Change the new multi-separator support in *note
     asyncio.StreamReader.readuntil(): 199. to only accept tuples of
     separators rather than arbitrary iterables.

   - gh-117692(48): Fixes a bug when *note doctest.DocTestFinder: 1596.
     was failing on wrapped ‘builtin_function_or_method’.

   - gh-117348(49): Largely restored import time performance of
     configparser by avoiding dataclasses.

   - gh-117641(50): Speedup *note os.path.commonpath(): e0a. on Unix.

   - gh-117663(51): Fix ‘_simple_enum’ to detect aliases when multiple
     arguments are present but only one is the member value.

   - gh-117636(52): Speedup *note os.path.join(): 1597.

   - gh-117618(53): Support ‘package.module’ as ‘filename’ for ‘break’
     command of *note pdb: 94.

   - gh-102247(54): the status codes enum with constants in
     http.HTTPStatus are updated to include the names from RFC9110.
     This RFC includes some HTTP statuses previously only used for
     WEBDAV and assigns more generic names to them.

     The old constants are preserved for backwards compatibility.

   - gh-117607(55): Speedup *note os.path.relpath(): 477.

   - gh-117586(56): Speed up *note pathlib.Path.glob(): 20e. by working
     with strings internally.

   - gh-117225(57): Add colour to doctest output.  Patch by Hugo van
     Kemenade.

   - gh-117566(58): *note ipaddress.IPv6Address.is_loopback(): 1598.
     will now return ‘True’ for IPv4-mapped loopback addresses, i.e.
     addresses in the ‘::ffff:127.0.0.0/104’ address space.

   - gh-117546(59): Fix issue where *note os.path.realpath(): 206.
     stopped resolving symlinks after encountering a symlink loop on
     POSIX.

   - gh-116720(60): Improved behavior of *note asyncio.TaskGroup: 19a.
     when an external cancellation collides with an internal
     cancellation.  For example, when two task groups are nested and
     both experience an exception in a child task simultaneously, it was
     possible that the outer task group would misbehave, because its
     internal cancellation was swallowed by the inner task group.

     In the case where a task group is cancelled externally and also
     must raise an *note ExceptionGroup: 19b, it will now call the
     parent task's *note cancel(): 19c. method.  This ensures that a
     *note asyncio.CancelledError: 19d. will be raised at the next *note
     await: 19e, so the cancellation is not lost.

     An added benefit of these changes is that task groups now preserve
     the cancellation count (*note asyncio.Task.cancelling(): 19f.).

     In order to handle some corner cases, *note
     asyncio.Task.uncancel(): 1a0. may now reset the undocumented
     ‘_must_cancel’ flag when the cancellation count reaches zero.

   - gh-117516(61): Add *note typing.TypeIs: 149, implementing PEP
     742(62).  Patch by Jelle Zijlstra.

   - gh-117503(63): Fix support of non-ASCII user names in bytes paths
     in *note os.path.expanduser(): 9e2. on Posix.

   - gh-117394(64): *note os.path.ismount(): 9e0. is now 2-3 times
     faster if the user has permissions.

   - gh-117313(65): Only treat ‘'\n'’, ‘'\r'’ and ‘'\r\n'’ as line
     separators in re-folding the *note email: 32. messages.  Preserve
     control characters ‘'\v'’, ‘'\f'’, ‘'\x1c'’, ‘'\x1d'’ and ‘'\x1e'’
     and Unicode line separators ‘'\x85'’, ‘'\u2028'’ and ‘'\u2029'’ as
     is.

   - gh-117142(66): Convert ‘_ctypes’ to multi-phase initialisation (
     PEP 489(67)).

   - gh-66543(68): Add the *note mimetypes.guess_file_type(): 1e8.
     function which works with file path.  Passing file path instead of
     URL in *note guess_type(): 1e9. is *note soft deprecated: 1ea.

   - gh-68583(69): webbrowser CLI: replace getopt with argparse, add
     long options.  Patch by Hugo van Kemenade.

   - gh-116871(70): Name suggestions for *note AttributeError: 326. and
     *note ImportError: 3f2. now only include underscored names if the
     original name was underscored.

   - gh-116023(71): Don't show empty fields (value ‘None’ or ‘[]’) in
     *note ast.dump(): 8b2. by default.  Add ‘show_empty=False’
     parameter to optionally show them.

   - gh-115961(72): Added ‘name’ and ‘mode’ attributes for compressed
     and archived file-like objects in modules *note bz2: f, *note lzma:
     7e, *note tarfile: c8. and *note zipfile: 117.  The value of the
     ‘mode’ attribute of *note gzip.GzipFile: 3f3. was changed from
     integer (‘1’ or ‘2’) to string (‘'rb'’ or ‘'wb'’).  The value of
     the ‘mode’ attribute of the readable file-like object returned by
     *note zipfile.ZipFile.open(): 3f4. was changed from ‘'r'’ to
     ‘'rb'’.

   - gh-82062(73): Fix *note inspect.signature(): 703. to correctly
     handle parameter defaults on methods in extension modules that use
     names defined in the module namespace.

   - gh-83856(74): Honor *note atexit: 9. for all *note multiprocessing:
     86. start methods

   - gh-113081(75): Print colorized exception just like built-in
     traceback in *note pdb: 94.

   - gh-112855(76): Speed up pickling of *note pathlib.PurePath: 473.
     objects.  Patch by Barney Gale.

   - gh-111744(77): Support opcode events in *note bdb: b.

   - gh-109617(78): ‘ncurses’: fixed a crash that could occur on macOS
     13 or earlier when Python was built with Apple Xcode 15's SDK.

   - gh-83151(79): Enabled arbitrary statements and evaluations in *note
     pdb: 94. shell to access the local variables of the current frame,
     which made it possible for multi-scope code like generators or
     nested function to work.

   - gh-110209(80): Add *note __class_getitem__(): 706. to *note
     types.GeneratorType: 1599. and *note types.CoroutineType: e54. for
     type hinting purposes.  Patch by James Hilton-Balfe.

   - gh-108191(81): The *note types.SimpleNamespace: 1b3. now accepts an
     optional positional argument which specifies initial values of
     attributes as a dict or an iterable of key-value pairs.

   - gh-62090(82): Fix assertion errors caused by whitespace in metavars
     or ‘SUPPRESS’-ed groups in *note argparse: 5. by simplifying usage
     formatting.  Patch by Ali Hamdan.

   - gh-102402(83): Adjust ‘logging.LogRecord’ to use ‘time.time_ns()’
     and fix minor bug related to floating-point math.

   - gh-100242(84): Bring pure Python implementation
     ‘functools.partial.__new__’ more in line with the C-implementation
     by not just always checking for the presence of the attribute
     ‘'func'’ on the first argument of ‘partial’.  Instead, both the
     Python version and the C version perform an ‘isinstance(func,
     partial)’ check on the first argument of ‘partial’.

   - gh-99730(85): HEAD requests are no longer upgraded to GET request
     during redirects in urllib.

   - gh-66410(86): Setting the ‘tkinter’ module global ‘wantobjects’ to
     ‘2’ before creating the *note Tk: 159a. object or call the
     ‘wantobjects()’ method of the ‘Tk’ object with argument ‘2’ makes
     now arguments to callbacks registered in the *note tkinter: d9.
     module to be passed as various Python objects (‘int’, ‘float’,
     ‘bytes’, ‘tuple’), depending on their internal representation in
     Tcl, instead of always ‘str’.  ‘tkinter.wantobjects’ is now set to
     ‘2’ by default.

   - bpo-40943(87): Fix several IndexError when parse emails with
     truncated Message-ID, address, routes, etc, e.g.  ‘example@’.

   - bpo-39324(88): Add mime type mapping for .md <-> text/markdown

   - bpo-18108(89): *note shutil.chown(): 221. now supports 'dir_fd' and
     'follow_symlinks' keyword arguments.

   - bpo-30988(90): Fix parsing of emails with invalid address headers
     having a leading or trailing dot.  Patch by tsufeki.

   - bpo-32839(91): Add the ‘after_info()’ method for Tkinter widgets.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118418

   (2) https://github.com/python/cpython/issues/118660

   (3) https://github.com/python/cpython/issues/118650

   (4) https://github.com/python/cpython/issues/118648

   (5) https://github.com/python/cpython/issues/101137

   (6) https://github.com/python/cpython/issues/118164

   (7) https://github.com/python/cpython/issues/111744

   (8) https://github.com/python/cpython/issues/118500

   (9) https://github.com/python/cpython/issues/118406

   (10) https://github.com/python/cpython/issues/101732

   (11) https://github.com/python/cpython/issues/118404

   (12) https://github.com/python/cpython/issues/118402

   (13) https://github.com/python/cpython/issues/116622

   (14) https://peps.python.org/pep-0738/

   (15) https://github.com/python/cpython/issues/118285

   (16) https://github.com/python/cpython/issues/118314

   (17) https://github.com/python/cpython/issues/118271

   (18) https://github.com/python/cpython/issues/118225

   (19) https://github.com/python/cpython/issues/118221

   (20) https://github.com/python/cpython/issues/118013

   (21) https://github.com/python/cpython/issues/103193

   (22) https://github.com/python/cpython/issues/118218

   (23) https://github.com/python/cpython/issues/117486

   (24) https://github.com/python/cpython/issues/90848

   (25) https://github.com/python/cpython/issues/118168

   (26) https://github.com/python/cpython/issues/118131

   (27) https://github.com/python/cpython/issues/118107

   (28) https://github.com/python/cpython/issues/102511

   (29) https://github.com/python/cpython/issues/117535

   (30) https://github.com/python/cpython/issues/114053

   (31) https://peps.python.org/pep-0695/

   (32) https://github.com/python/cpython/issues/116931

   (33) https://github.com/python/cpython/issues/117995

   (34) https://github.com/python/cpython/issues/100668

   (35) https://github.com/python/cpython/issues/80361

   (36) https://datatracker.ietf.org/doc/html/rfc2231.html

   (37) https://github.com/python/cpython/issues/86650

   (38) https://github.com/python/cpython/issues/117691

   (39) https://github.com/python/cpython/issues/115874

   (40) https://github.com/python/cpython/issues/115060

   (41) https://github.com/python/cpython/issues/77102

   (42) https://github.com/python/cpython/issues/76785

   (43) https://peps.python.org/pep-0734/

   (44) https://github.com/python/cpython/issues/115060

   (45) https://github.com/python/cpython/issues/117727

   (46) https://github.com/python/cpython/issues/117586

   (47) https://github.com/python/cpython/issues/117722

   (48) https://github.com/python/cpython/issues/117692

   (49) https://github.com/python/cpython/issues/117348

   (50) https://github.com/python/cpython/issues/117641

   (51) https://github.com/python/cpython/issues/117663

   (52) https://github.com/python/cpython/issues/117636

   (53) https://github.com/python/cpython/issues/117618

   (54) https://github.com/python/cpython/issues/102247

   (55) https://github.com/python/cpython/issues/117607

   (56) https://github.com/python/cpython/issues/117586

   (57) https://github.com/python/cpython/issues/117225

   (58) https://github.com/python/cpython/issues/117566

   (59) https://github.com/python/cpython/issues/117546

   (60) https://github.com/python/cpython/issues/116720

   (61) https://github.com/python/cpython/issues/117516

   (62) https://peps.python.org/pep-0742/

   (63) https://github.com/python/cpython/issues/117503

   (64) https://github.com/python/cpython/issues/117394

   (65) https://github.com/python/cpython/issues/117313

   (66) https://github.com/python/cpython/issues/117142

   (67) https://peps.python.org/pep-0489/

   (68) https://github.com/python/cpython/issues/66543

   (69) https://github.com/python/cpython/issues/68583

   (70) https://github.com/python/cpython/issues/116871

   (71) https://github.com/python/cpython/issues/116023

   (72) https://github.com/python/cpython/issues/115961

   (73) https://github.com/python/cpython/issues/82062

   (74) https://github.com/python/cpython/issues/83856

   (75) https://github.com/python/cpython/issues/113081

   (76) https://github.com/python/cpython/issues/112855

   (77) https://github.com/python/cpython/issues/111744

   (78) https://github.com/python/cpython/issues/109617

   (79) https://github.com/python/cpython/issues/83151

   (80) https://github.com/python/cpython/issues/110209

   (81) https://github.com/python/cpython/issues/108191

   (82) https://github.com/python/cpython/issues/62090

   (83) https://github.com/python/cpython/issues/102402

   (84) https://github.com/python/cpython/issues/100242

   (85) https://github.com/python/cpython/issues/99730

   (86) https://github.com/python/cpython/issues/66410

   (87) https://bugs.python.org/issue?@action=redirect&bpo=40943

   (88) https://bugs.python.org/issue?@action=redirect&bpo=39324

   (89) https://bugs.python.org/issue?@action=redirect&bpo=18108

   (90) https://bugs.python.org/issue?@action=redirect&bpo=30988

   (91) https://bugs.python.org/issue?@action=redirect&bpo=32839


File: python.info,  Node: Documentation<4>,  Next: Build<8>,  Prev: Library<8>,  Up: Python 3 13 0 beta 1

1.23.9.4 Documentation
......................

   - gh-117928(1): The minimum Sphinx version required for the
     documentation is now 6.2.1.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/117928


File: python.info,  Node: Build<8>,  Next: Windows<5>,  Prev: Documentation<4>,  Up: Python 3 13 0 beta 1

1.23.9.5 Build
..............

   - gh-118734(1): Fixes Windows build when invoked directly (not
     through the ‘build.bat’ script) without specifying a value for
     ‘UseTIER2’.

   - gh-115119(2): The ‘configure’ option *note -with-system-libmpdec:
     3eb. now defaults to ‘yes’.  The bundled copy of ‘libmpdecimal’
     will be removed in Python 3.15.

   - gh-117845(3): Fix building against recent libedit versions by
     detecting readline hook signatures in ‘configure’.

   - gh-116622(4): A testbed project was added to run the test suite on
     Android.

   - gh-117645(5): Increase WASI stack size from 512 KiB to 8 MiB and
     the initial memory from 10 MiB to 20 MiB. Patch by Victor Stinner.

   - gh-115119(6): ‘configure’ now uses ‘pkg-config’ to detect *note
     decimal: 2e. dependencies if the *note -with-system-libmpdec: 3eb.
     option is given.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118734

   (2) https://github.com/python/cpython/issues/115119

   (3) https://github.com/python/cpython/issues/117845

   (4) https://github.com/python/cpython/issues/116622

   (5) https://github.com/python/cpython/issues/117645

   (6) https://github.com/python/cpython/issues/115119


File: python.info,  Node: Windows<5>,  Next: macOS<4>,  Prev: Build<8>,  Up: Python 3 13 0 beta 1

1.23.9.6 Windows
................

   - gh-115119(1): Update Windows installer to use libmpdecimal 4.0.0.

   - gh-118486(2): *note os.mkdir(): 1fe. now accepts 'mode' of ‘0o700’
     to restrict the new directory to the current user.

   - gh-118347(3): Fixes launcher updates not being installed.

   - gh-118293(4): The ‘multiprocessing’ module now passes the
     ‘STARTF_FORCEOFFFEEDBACK’ flag when spawning processes to tell
     Windows not to change the mouse cursor.

   - gh-115009(5): Update Windows installer to use SQLite 3.45.3.

   - gh-90329(6): Suppress the warning displayed on virtual environment
     creation when the requested and created paths differ only by a
     short (8.3 style) name.  Warnings will continue to be shown if a
     junction or symlink in the path caused the venv to be created in a
     different location than originally requested.

   - gh-117786(7): Fixes virtual environments not correctly launching
     when created from a Store install.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115119

   (2) https://github.com/python/cpython/issues/118486

   (3) https://github.com/python/cpython/issues/118347

   (4) https://github.com/python/cpython/issues/118293

   (5) https://github.com/python/cpython/issues/115009

   (6) https://github.com/python/cpython/issues/90329

   (7) https://github.com/python/cpython/issues/117786


File: python.info,  Node: macOS<4>,  Next: IDLE<8>,  Prev: Windows<5>,  Up: Python 3 13 0 beta 1

1.23.9.7 macOS
..............

   - gh-115119(1): Update macOS installer to use libmpdecimal 4.0.0.

   - gh-114099(2): iOS preprocessor symbol usage was made compatible
     with older macOS SDKs.

   - gh-115009(3): Update macOS installer to use SQLite 3.45.3.

   - gh-91629(4): Use ‘~/.config/fish/conf.d’ configs and
     ‘fish_add_path’ to set ‘PATH’ when installing for the Fish shell.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115119

   (2) https://github.com/python/cpython/issues/114099

   (3) https://github.com/python/cpython/issues/115009

   (4) https://github.com/python/cpython/issues/91629


File: python.info,  Node: IDLE<8>,  Next: C API<8>,  Prev: macOS<4>,  Up: Python 3 13 0 beta 1

1.23.9.8 IDLE
.............

   - bpo-34774(1): Use user-selected color theme for Help => IDLE Doc.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34774


File: python.info,  Node: C API<8>,  Prev: IDLE<8>,  Up: Python 3 13 0 beta 1

1.23.9.9 C API
..............

   - gh-118124(1): Fix ‘Py_BUILD_ASSERT’ and ‘Py_BUILD_ASSERT_EXPR’ for
     non-constant expressions: use ‘static_assert()’ on C11 and newer.
     Patch by Victor Stinner.

   - gh-110850(2): Add "Raw" variant of PyTime functions

        * *note PyTime_MonotonicRaw(): 30b.

        * *note PyTime_PerfCounterRaw(): 30d.

        * *note PyTime_TimeRaw(): 30f.

     Patch by Victor Stinner.

   - gh-117987(3): Restore functions removed in Python 3.13 alpha 1:

        * *note Py_SetPythonHome(): 15a1.

        * *note Py_SetProgramName(): 15a2.

        * *note PySys_SetArgvEx(): 15a3.

        * *note PySys_SetArgv(): 15a4.

     Patch by Victor Stinner.

   - gh-117929(4): Restore removed *note PyEval_InitThreads(): 15a5.
     function.  Patch by Victor Stinner.

   - gh-117534(5): Improve validation logic in the C implementation of
     *note datetime.datetime.fromisoformat(): 5e2. to better handle
     invalid years.  Patch by Vlad Efanov.

   - gh-68114(6): Fixed skipitem()'s handling of the old 'w' and 'w#'
     formatters.  These are no longer supported and now raise an
     exception if used.

   - gh-111997(7): Add a C-API for firing monitoring events.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/118124

   (2) https://github.com/python/cpython/issues/110850

   (3) https://github.com/python/cpython/issues/117987

   (4) https://github.com/python/cpython/issues/117929

   (5) https://github.com/python/cpython/issues/117534

   (6) https://github.com/python/cpython/issues/68114

   (7) https://github.com/python/cpython/issues/111997


File: python.info,  Node: Python 3 13 0 alpha 6,  Next: Python 3 13 0 alpha 5,  Prev: Python 3 13 0 beta 1,  Up: 変更履歴

1.23.10 Python 3.13.0 alpha 6
-----------------------------

'Release date: 2024-04-09'

* Menu:

* Core and Builtins: Core and Builtins<10>.
* Library: Library<9>.
* Documentation: Documentation<5>.
* Tests: Tests<7>.
* Build: Build<9>.
* Windows: Windows<6>.
* C API: C API<9>.


File: python.info,  Node: Core and Builtins<10>,  Next: Library<9>,  Up: Python 3 13 0 alpha 6

1.23.10.1 Core and Builtins
...........................

   - gh-117494(1): Refactored the instruction sequence data structure
     out of compile.c into instruction_sequence.c.

   - gh-116968(2): Introduce a unified 16-bit backoff counter type
     (‘_Py_BackoffCounter’), shared between the Tier 1 adaptive
     specializer and the Tier 2 optimizer.  The API used for adaptive
     specialization counters is changed but the behavior is (supposed to
     be) identical.

     The behavior of the Tier 2 counters is changed:

        * There are no longer dynamic thresholds (we never varied
          these).

        * All counters now use the same exponential backoff.

        * The counter for ‘JUMP_BACKWARD’ starts counting down from 16.

        * The ‘temperature’ in side exits starts counting down from 64.

   - gh-117431(3): Improve the performance of the following *note bytes:
     1a4. and *note bytearray: 508. methods by adapting them to the
     *note METH_FASTCALL: 158b. calling convention:

        * ‘endswith()’

        * ‘startswith()’

   - gh-117431(4): Improve the performance of the following *note str:
     418. methods by adapting them to the *note METH_FASTCALL: 158b.
     calling convention:

        * *note count(): 15a8.

        * *note endswith(): e95.

        * *note find(): e71.

        * *note index(): 15a9.

        * *note rfind(): e72.

        * *note rindex(): 1229.

        * *note startswith(): e94.

   - gh-117411(5): Move ‘PyFutureFeatures’ to an internal header and
     make it private.

   - gh-109120(6): Added handle of incorrect star expressions, e.g ‘f(3,
     *)’.  Patch by Grigoryev Semyon

   - gh-117266(7): Fix crashes for certain user-created subclasses of
     *note ast.AST: 18b.  Such classes are now expected to set the
     ‘_field_types’ attribute.

   - gh-99108(8): Updated the *note hashlib: 5e. built-in HACL*
     project(9) C code from upstream that we use for many
     implementations when they are not present via OpenSSL in a given
     build.  This also avoids the rare potential for a C symbol name one
     definition rule linking issue.

   - gh-117108(10): Change the old space bit of objects in the young
     generation from 0 to gcstate->visited, so that any objects created
     during GC will have the old bit set correctly if they get moved
     into the old generation.

   - gh-117108(11): The cycle GC now chooses the size of increments
     based on the total heap size, instead of the rate of object
     creation.  This ensures that it can keep up with growing heaps.

   - gh-116735(12): For ‘INSTRUMENTED_CALL_FUNCTION_EX’, set ‘arg0’ to
     ‘sys.monitoring.MISSING’ instead of ‘None’ for *note CALL: 15aa.
     event.

   - gh-113964(13): Starting new threads and process creation through
     *note os.fork(): 17c. are now only prevented once all non-daemon
     threads exit.

   - gh-116626(14): Ensure ‘INSTRUMENTED_CALL_FUNCTION_EX’ always emits
     *note CALL: 15aa.

   - gh-116554(15): ‘list.sort()’ now exploits more cases of partial
     ordering, particularly those with long descending runs with
     sub-runs of equal values.  Those are recognized as single runs now
     (previously, each block of repeated values caused a new run to be
     created).

   - gh-114099(16): Added a Loader that can discover extension modules
     in an iOS-style Frameworks folder.

   - gh-115775(17): Compiler populates the new ‘__static_attributes__’
     field on a class with the names of attributes of this class which
     are accessed through self.X from any function in its body.

   - gh-115776(18): The array of values, the ‘PyDictValues’ struct is
     now embedded in the object during allocation.  This provides better
     performance in the common case, and does not degrade as much when
     the object's ‘__dict__’ is materialized.

   - gh-108362(19): Implement an incremental cyclic garbage collector.
     By collecting the old generation in increments, there is no need
     for a full heap scan.  This can hugely reduce maximum pause time
     for programs with large heaps.

     Reduce the number of generations from three to two.  The old
     generation is split into two spaces, "visited" and "pending".

     Collection happens in two steps:: * An increment is formed from the
     young generation and a small part of the pending space.  * This
     increment is scanned and the survivors moved to the end of the
     visited space.

     When the collecting space becomes empty, the two spaces are
     swapped.

   - gh-109870(20): Dataclasses now calls *note exec(): 164. once per
     dataclass, instead of once per method being added.  This can speed
     up dataclass creation by up to 20%.

   - gh-97901(21): Mime type ‘text/rtf’ is now supported by *note
     mimetypes: 82.

   - bpo-24612(22): Improve the *note SyntaxError: 172. that happens
     when 'not' appears after an operator.  Patch by Pablo Galindo

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/117494

   (2) https://github.com/python/cpython/issues/116968

   (3) https://github.com/python/cpython/issues/117431

   (4) https://github.com/python/cpython/issues/117431

   (5) https://github.com/python/cpython/issues/117411

   (6) https://github.com/python/cpython/issues/109120

   (7) https://github.com/python/cpython/issues/117266

   (8) https://github.com/python/cpython/issues/99108

   (9) https://github.com/hacl-star/hacl-star

   (10) https://github.com/python/cpython/issues/117108

   (11) https://github.com/python/cpython/issues/117108

   (12) https://github.com/python/cpython/issues/116735

   (13) https://github.com/python/cpython/issues/113964

   (14) https://github.com/python/cpython/issues/116626

   (15) https://github.com/python/cpython/issues/116554

   (16) https://github.com/python/cpython/issues/114099

   (17) https://github.com/python/cpython/issues/115775

   (18) https://github.com/python/cpython/issues/115776

   (19) https://github.com/python/cpython/issues/108362

   (20) https://github.com/python/cpython/issues/109870

   (21) https://github.com/python/cpython/issues/97901

   (22) https://bugs.python.org/issue?@action=redirect&bpo=24612


File: python.info,  Node: Library<9>,  Next: Documentation<5>,  Prev: Core and Builtins<10>,  Up: Python 3 13 0 alpha 6

1.23.10.2 Library
.................

   - gh-117648(1): Improve performance of *note os.path.join(): 1597.
     and *note os.path.expanduser(): 9e2.

   - gh-117584(2): Raise *note TypeError: 502. for non-paths in
     ‘posixpath.relpath()’.

   - gh-117467(3): Preserve mailbox ownership when rewriting in
     ‘mailbox.mbox.flush()’.  Patch by Tony Mountifield.

   - gh-114848(4): Raise *note FileNotFoundError: e8f. when ‘getcwd()’
     returns '(unreachable)', which can happen on Linux >= 2.6.36 with
     glibc < 2.27.

   - gh-117459(5): ‘asyncio.asyncio.run_coroutine_threadsafe()’ now
     keeps the traceback of ‘CancelledError’, *note TimeoutError: 800.
     and ‘InvalidStateError’ which are raised in the coroutine.

   - gh-117381(6): Fix error message for ‘ntpath.commonpath()’.

   - gh-117337(7): Deprecate undocumented ‘glob.glob0()’ and
     ‘glob.glob1()’ functions.  Use *note glob.glob(): 27f. and pass a
     directory to its 'root_dir' argument instead.

   - gh-117349(8): Optimise several functions in *note os.path: 92.

   - gh-117348(9): Refactored ‘configparser.RawConfigParser._read()’ to
     reduce cyclometric complexity and improve comprehensibility.

   - gh-117335(10): Raise TypeError for non-sequences for
     ‘ntpath.commonpath()’.

   - gh-66449(11): *note configparser.ConfigParser: 1aa. now accepts
     unnamed sections before named ones, if configured to do so.

   - gh-88014(12): In documentation of *note gzip.GzipFile: 3f3. in
     module gzip, explain data type of optional constructor argument
     'mtime', and recommend ‘mtime = 0’ for generating deterministic
     streams.

   - gh-117310(13): Fixed an unlikely early & extra ‘Py_DECREF’
     triggered crash in *note ssl: bb. when creating a new
     ‘_ssl._SSLContext’ if CPython was built implausibly such that the
     default cipher list is empty 'or' the SSL library it was linked
     against reports a failure from its C ‘SSL_CTX_set_cipher_list()’
     API.

   - gh-117294(14): A ‘DocTestCase’ now reports as skipped if all
     examples in the doctest are skipped.

   - gh-98966(15): In *note subprocess: c1, raise a more informative
     message when ‘stdout=STDOUT’.

   - gh-117225(16): doctest: only print "and X failed" when non-zero,
     don't pluralise "1 items".  Patch by Hugo van Kemenade.

   - gh-117205(17): Speed up *note compileall.compile_dir(): af4. by 20%
     when using multiprocessing by increasing ‘chunksize’.

   - gh-117178(18): Fix regression in lazy loading of self-referential
     modules, introduced in gh-114781(19).

   - gh-112383(20): Fix *note dis: 30. module's handling of
     ‘ENTER_EXECUTOR’ instructions.

   - gh-117182(21): Lazy-loading of modules that modify their own
     ‘__class__’ no longer reverts the ‘__class__’ to *note
     types.ModuleType: de0.

   - gh-117084(22): Fix *note zipfile: 117. extraction for directory
     entries with the name containing backslashes on Windows.

   - gh-117114(23): Make *note os.path.isdevdrive(): 15ac. available on
     all platforms.  For those that do not offer Dev Drives, it will
     always return ‘False’.

   - gh-117110(24): Fix a bug that prevents subclasses of *note
     typing.Any: 678. to be instantiated with arguments.  Patch by Chris
     Fu.

   - gh-109653(25): Deferred select imports in importlib.metadata and
     importlib.resources for a 14% speedup.

   - gh-70647(26): Start the deprecation period for the current behavior
     of *note datetime.datetime.strptime(): 156e. and *note
     time.strptime(): 13d4. which always fails to parse a date string
     with a *note ValueError: 1e3. involving a day of month such as
     ‘strptime("02-29", "%m-%d")’ when a year is 'not' specified and the
     date happen to be February 29th.  This should help avoid users
     finding new bugs every four years due to a natural mistaken
     assumption about the API when parsing partial date values.

   - gh-116987(27): Fixed ‘inspect.findsource()’ for class code objects.

   - gh-114099(28): Modify standard library to allow for iOS platform
     differences.

   - gh-90872(29): On Windows, *note subprocess.Popen.wait(): cb2. no
     longer calls ‘WaitForSingleObject()’ with a negative timeout: pass
     ‘0’ ms if the timeout is negative.  Patch by Victor Stinner.

   - gh-116957(30): configparser: Don't leave ConfigParser values in an
     invalid state (stored as a list instead of a str) after an earlier
     read raised DuplicateSectionError or DuplicateOptionError.

   - gh-115538(31): ‘_io.WindowsConsoleIO’ now emit a warning if a
     boolean value is passed as a filedescriptor argument.

   - gh-90095(32): Ignore empty lines and comments in ‘.pdbrc’

   - gh-106531(33): Refreshed zipfile._path from zipp 3.18(34),
     providing better compatibility for PyPy, better glob performance
     for deeply nested zipfiles, and providing internal access to
     ‘CompleteDirs.inject’ for use in other tests (like
     importlib.resources).

   - gh-63207(35): On Windows, *note time.time(): 235. now uses the
     ‘GetSystemTimePreciseAsFileTime()’ clock to have a resolution
     better than 1 us, instead of the ‘GetSystemTimeAsFileTime()’ clock
     which has a resolution of 15.6 ms.  Patch by Victor Stinner.

   - gh-116764(36): Restore support of ‘None’ and other false values in
     *note urllib.parse: f3. functions *note parse_qs(): 25b. and *note
     parse_qsl(): 25a.  Also, they now raise a TypeError for non-zero
     integers and non-empty sequences.

   - gh-116811(37): In ‘PathFinder.invalidate_caches’, delegate to
     ‘MetadataPathFinder.invalidate_caches’.

   - gh-116647(38): Fix recursive child in dataclasses

   - gh-113171(39): Fixed various false positives and false negatives in

        * *note ipaddress.IPv4Address.is_private: 15ad. (see these docs
          for details)

        * *note ipaddress.IPv4Address.is_global: f2c.

        * *note ipaddress.IPv6Address.is_private: 15ae.

        * *note ipaddress.IPv6Address.is_global: 15af.

     Also in the corresponding *note ipaddress.IPv4Network: 1df. and
     *note ipaddress.IPv6Network: 1e0. attributes.

   - gh-63283(40): In *note encodings.idna: 48, any capitalization of
     the the ACE prefix (‘xn--’) is now acceptable.  Patch by Pepijn de
     Vos and Zackery Spytz.

   - gh-71042(41): Add *note platform.android_ver(): 15b0, which
     provides device and OS information on Android.

   - gh-73468(42): Added new *note math.fma(): 1e6. function, wrapping
     C99's ‘fma()’ operation: fused multiply-add function.  Patch by
     Mark Dickinson and Victor Stinner.

   - gh-116608(43): The *note importlib.resources: 6f. functions *note
     is_resource(): 1cd, *note open_binary(): 1ce, *note open_text():
     1cf, *note path(): 1d0, *note read_binary(): 1d1, and *note
     read_text(): 1d2. are un-deprecated, and support subdirectories via
     multiple positional arguments.  The *note contents(): 1d3. function
     also allows subdirectories, but remains deprecated.

   - gh-116484(44): Change automatically generated ‘tkinter.Checkbutton’
     widget names to avoid collisions with automatically generated
     ‘tkinter.ttk.Checkbutton’ widget names within the same parent
     widget.

   - gh-114314(45): In *note ctypes: 22, ctype data is now stored in
     type objects directly rather than in a dict subclass.  This is an
     internal change that should not affect usage.

   - gh-116401(46): Fix blocking *note os.fwalk(): b29. and *note
     shutil.rmtree(): 2d8. on opening named pipe.

   - gh-71052(47): Implement *note ctypes.util.find_library(): d17. on
     Android.

   - gh-90535(48): Fix support of 'interval' values > 1 in
     ‘logging.TimedRotatingFileHandler’ for ‘when='MIDNIGHT'’ and
     ‘when='Wx'’.

   - gh-113308(49): Remove some internal protected parts from *note
     uuid: f8.: ‘_has_uuid_generate_time_safe’, ‘_netbios_getnode’,
     ‘_ipconfig_getnode’, and ‘_load_system_functions’.  They were
     unused.

   - gh-115627(50): Fix the *note ssl: bb. module error handling of
     connection terminate by peer.  It now throws an OSError with the
     appropriate error code instead of an EOFError.

   - gh-114847(51): Speed up *note os.path.realpath(): 206. on
     non-Windows platforms.

   - gh-114271(52): Fix a race in ‘threading.Thread.join()’.

     ‘threading._MainThread’ now always represents the main thread of
     the main interpreter.

     ‘PyThreadState.on_delete’ and ‘PyThreadState.on_delete_data’ have
     been removed.

   - gh-113538(53): Add *note asyncio.Server.close_clients(): 197. and
     *note asyncio.Server.abort_clients(): 198. methods which allow to
     more forcefully close an asyncio server.

   - gh-85287(54): Changes Unicode codecs to return UnicodeEncodeError
     or UnicodeDecodeError, rather than just UnicodeError.

   - gh-113548(55): *note pdb: 94. now allows CLI arguments to ‘pdb -m’.

   - gh-112948(56): Make completion of *note pdb: 94. similar to Python
     REPL

   - gh-105866(57): Fixed ‘_get_slots’ bug which caused error when
     defining dataclasses with slots and a weakref_slot.

   - gh-96471(58): Add *note asyncio.Queue: a44. termination with *note
     shutdown(): 195. method.

   - gh-89739(59): The *note zipimport: 118. module can now read ZIP64
     files.

   - bpo-33533(60): *note asyncio.as_completed(): 18f. now returns an
     object that is both an asynchronous iterator and plain iterator.
     The new asynchronous iteration pattern allows for easier
     correlation between prior tasks and their completed results.  This
     is a closer match to *note concurrent.futures.as_completed():
     15b1.'s iteration pattern.  Patch by Justin Arthur.

   - bpo-27578(61): *note inspect.getsource(): 1528. (and related
     functions) work with empty module files, returning ‘'\n'’ (or
     reasonable equivalent) instead of raising ‘OSError’.  Patch by
     Kernc.

   - bpo-37141(62): Accept an iterable of separators in *note
     asyncio.StreamReader.readuntil(): 199, stopping when one of them is
     encountered.

   - gh-66543(63): Make *note mimetypes.guess_type(): 1e9. properly
     parsing of URLs with only a host name, URLs containing fragment or
     query, and filenames with only a UNC sharepoint on Windows.  Based
     on patch by Dong-hee Na.

   - bpo-15010(64): *note unittest.TestLoader.discover(): fb2. now saves
     the original value of ‘unittest.TestLoader._top_level_dir’ and
     restores it at the end of the call.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/117648

   (2) https://github.com/python/cpython/issues/117584

   (3) https://github.com/python/cpython/issues/117467

   (4) https://github.com/python/cpython/issues/114848

   (5) https://github.com/python/cpython/issues/117459

   (6) https://github.com/python/cpython/issues/117381

   (7) https://github.com/python/cpython/issues/117337

   (8) https://github.com/python/cpython/issues/117349

   (9) https://github.com/python/cpython/issues/117348

   (10) https://github.com/python/cpython/issues/117335

   (11) https://github.com/python/cpython/issues/66449

   (12) https://github.com/python/cpython/issues/88014

   (13) https://github.com/python/cpython/issues/117310

   (14) https://github.com/python/cpython/issues/117294

   (15) https://github.com/python/cpython/issues/98966

   (16) https://github.com/python/cpython/issues/117225

   (17) https://github.com/python/cpython/issues/117205

   (18) https://github.com/python/cpython/issues/117178

   (19) https://github.com/python/cpython/issues/114781

   (20) https://github.com/python/cpython/issues/112383

   (21) https://github.com/python/cpython/issues/117182

   (22) https://github.com/python/cpython/issues/117084

   (23) https://github.com/python/cpython/issues/117114

   (24) https://github.com/python/cpython/issues/117110

   (25) https://github.com/python/cpython/issues/109653

   (26) https://github.com/python/cpython/issues/70647

   (27) https://github.com/python/cpython/issues/116987

   (28) https://github.com/python/cpython/issues/114099

   (29) https://github.com/python/cpython/issues/90872

   (30) https://github.com/python/cpython/issues/116957

   (31) https://github.com/python/cpython/issues/115538

   (32) https://github.com/python/cpython/issues/90095

   (33) https://github.com/python/cpython/issues/106531

   (34) https://zipp.readthedocs.io/en/latest/history.html#v3-18-0

   (35) https://github.com/python/cpython/issues/63207

   (36) https://github.com/python/cpython/issues/116764

   (37) https://github.com/python/cpython/issues/116811

   (38) https://github.com/python/cpython/issues/116647

   (39) https://github.com/python/cpython/issues/113171

   (40) https://github.com/python/cpython/issues/63283

   (41) https://github.com/python/cpython/issues/71042

   (42) https://github.com/python/cpython/issues/73468

   (43) https://github.com/python/cpython/issues/116608

   (44) https://github.com/python/cpython/issues/116484

   (45) https://github.com/python/cpython/issues/114314

   (46) https://github.com/python/cpython/issues/116401

   (47) https://github.com/python/cpython/issues/71052

   (48) https://github.com/python/cpython/issues/90535

   (49) https://github.com/python/cpython/issues/113308

   (50) https://github.com/python/cpython/issues/115627

   (51) https://github.com/python/cpython/issues/114847

   (52) https://github.com/python/cpython/issues/114271

   (53) https://github.com/python/cpython/issues/113538

   (54) https://github.com/python/cpython/issues/85287

   (55) https://github.com/python/cpython/issues/113548

   (56) https://github.com/python/cpython/issues/112948

   (57) https://github.com/python/cpython/issues/105866

   (58) https://github.com/python/cpython/issues/96471

   (59) https://github.com/python/cpython/issues/89739

   (60) https://bugs.python.org/issue?@action=redirect&bpo=33533

   (61) https://bugs.python.org/issue?@action=redirect&bpo=27578

   (62) https://bugs.python.org/issue?@action=redirect&bpo=37141

   (63) https://github.com/python/cpython/issues/66543

   (64) https://bugs.python.org/issue?@action=redirect&bpo=15010


File: python.info,  Node: Documentation<5>,  Next: Tests<7>,  Prev: Library<9>,  Up: Python 3 13 0 alpha 6

1.23.10.3 Documentation
.......................

   - gh-115977(1): Remove compatibility references to Emscripten.

   - gh-114099(2): Add an iOS platform guide, and flag modules not
     available on iOS.

   - gh-91565(3): Changes to documentation files and config outputs to
     reflect the new location for reporting bugs - i.e.  GitHub rather
     than bugs.python.org.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115977

   (2) https://github.com/python/cpython/issues/114099

   (3) https://github.com/python/cpython/issues/91565


File: python.info,  Node: Tests<7>,  Next: Build<9>,  Prev: Documentation<5>,  Up: Python 3 13 0 alpha 6

1.23.10.4 Tests
...............

   - gh-83434(1): Disable JUnit XML output (‘--junit-xml=FILE’ command
     line option) in regrtest when hunting for reference leaks (‘-R’
     option).  Patch by Victor Stinner.

   - gh-117187(2): Fix XML tests for vanilla Expat <2.6.0.

   - gh-116333(3): Tests of TLS related things (error codes, etc) were
     updated to be more lenient about specific error message strings and
     behaviors as seen in the BoringSSL and AWS-LC forks of OpenSSL.

   - gh-117089(4): Consolidated tests for importlib.metadata in their
     own ‘metadata’ package.

   - gh-115979(5): Update test_importlib so that it passes under WASI
     SDK 21.

   - gh-112536(6): Add -tsan to test.regrtest for running TSAN tests in
     reasonable execution times.  Patch by Donghee Na.

   - gh-116307(7): Added import helper ‘isolated_modules’ as
     ‘CleanImport’ does not remove modules imported during the context.
     Use it in importlib.resources tests to avoid leaving ‘mod’ around
     to impede importlib.metadata tests.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/83434

   (2) https://github.com/python/cpython/issues/117187

   (3) https://github.com/python/cpython/issues/116333

   (4) https://github.com/python/cpython/issues/117089

   (5) https://github.com/python/cpython/issues/115979

   (6) https://github.com/python/cpython/issues/112536

   (7) https://github.com/python/cpython/issues/116307


File: python.info,  Node: Build<9>,  Next: Windows<6>,  Prev: Tests<7>,  Up: Python 3 13 0 alpha 6

1.23.10.5 Build
...............

   - gh-114736(1): Have WASI builds use WASI SDK 21.

   - gh-115983(2): Skip building test modules that must be built as
     shared under WASI.

   - gh-71052(3): Add Android build script and instructions.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/114736

   (2) https://github.com/python/cpython/issues/115983

   (3) https://github.com/python/cpython/issues/71052


File: python.info,  Node: Windows<6>,  Next: C API<9>,  Prev: Build<9>,  Up: Python 3 13 0 alpha 6

1.23.10.6 Windows
.................

   - gh-117267(1): Ensure ‘DirEntry.stat().st_ctime’ behaves
     consistently with *note os.stat(): 46d. during the deprecation
     period of ‘st_ctime’ by containing the same value as
     ‘st_birthtime’.  After the deprecation period, ‘st_ctime’ will be
     the metadata change time (or unavailable through ‘DirEntry’), and
     only ‘st_birthtime’ will contain the creation time.

   - gh-116195(2): Improves performance of *note os.getppid(): 15b6. by
     using an alternate system API when available.  Contributed by
     vxiiduu.

   - gh-88494(3): On Windows, *note time.monotonic(): 234. now uses the
     ‘QueryPerformanceCounter()’ clock to have a resolution better than
     1 us, instead of the ‘GetTickCount64()’ clock which has a
     resolution of 15.6 ms.  Patch by Victor Stinner.

   - gh-116773(4): Fix instances of ‘<_overlapped.Overlapped object at
     0xXXX> still has pending operation at deallocation, the process may
     crash’.

   - gh-91227(5): Fix the asyncio ProactorEventLoop implementation so
     that sending a datagram to an address that is not listening does
     not prevent receiving any more datagrams.

   - gh-115119(6): Switched from vendored ‘libmpdecimal’ code to a
     separately-hosted external package in the ‘cpython-source-deps’
     repository when building the ‘_decimal’ module.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/117267

   (2) https://github.com/python/cpython/issues/116195

   (3) https://github.com/python/cpython/issues/88494

   (4) https://github.com/python/cpython/issues/116773

   (5) https://github.com/python/cpython/issues/91227

   (6) https://github.com/python/cpython/issues/115119


File: python.info,  Node: C API<9>,  Prev: Windows<6>,  Up: Python 3 13 0 alpha 6

1.23.10.7 C API
...............

   - gh-117642(1): Fix PEP 737(2) implementation for ‘%#T’ and ‘%#N’.

   - gh-87193(3): *note _PyBytes_Resize(): 15b8. can now be called for
     bytes objects with reference count > 1, including 1-byte bytes
     objects.  It creates a new bytes object and destroys the old one if
     it has reference count > 1.

   - gh-117021(4): Fix integer overflow in ‘PyLong_AsPid()’ on
     non-Windows 64-bit platforms.

   - gh-115756(5): ‘PyCode_GetFirstFree()’ is an ustable API now and has
     been renamed to *note PyUnstable_Code_GetFirstFree(): 35f.
     (Contributed by Bogdan Romanyuk in gh-115781(6))

   - gh-116869(7): Add ‘test_cext’ test: build a C extension to check if
     the Python C API emits C compiler warnings.  Patch by Victor
     Stinner.

   - gh-116869(8): Make the C API compatible with
     ‘-Werror=declaration-after-statement’ compiler flag again.  Patch
     by Victor Stinner.

   - gh-116936(9): Add *note PyType_GetModuleByDef(): 36d. to the
     limited C API. Patch by Victor Stinner.

   - gh-116809(10): Restore removed private ‘_PyErr_ChainExceptions1()’
     function.  Patch by Victor Stinner.

   - gh-115754(11): In the limited C API version 3.13, getting
     ‘Py_None’, ‘Py_False’, ‘Py_True’, ‘Py_Ellipsis’ and
     ‘Py_NotImplemented’ singletons is now implemented as function calls
     at the stable ABI level to hide implementation details.  Getting
     these constants still return borrowed references.  Patch by Victor
     Stinner.

   - gh-115754(12): Add *note Py_GetConstant(): 32f. and *note
     Py_GetConstantBorrowed(): 330. functions to get constants.  For
     example, ‘Py_GetConstant(Py_CONSTANT_ZERO)’ returns a *note strong
     reference: 316. to the constant zero.  Patch by Victor Stinner.

   - gh-111696(13): Add support for ‘%T’, ‘%T#’, ‘%N’ and ‘%N#’ formats
     to *note PyUnicode_FromFormat(): 363.: format the fully qualified
     name of an object type and of a type: call *note
     PyType_GetModuleName(): 34e.  See PEP 737(14) for more information.
     Patch by Victor Stinner.

   - gh-111696(15): Add *note PyType_GetModuleName(): 34e. function to
     get the type's module name.  Equivalent to getting the
     ‘type.__module__’ attribute.  Patch by Eric Snow and Victor
     Stinner.

   - gh-111696(16): Add *note PyType_GetFullyQualifiedName(): 34c.
     function to get the type's fully qualified name.  Equivalent to
     ‘f"{type.__module__}.{type.__qualname__}"’, or ‘type.__qualname__’
     if ‘type.__module__’ is not a string or is equal to ‘"builtins"’.
     Patch by Victor Stinner.

   - gh-85283(17): The ‘fcntl’, ‘grp’, ‘pwd’, ‘termios’, ‘_statistics’
     and ‘_testconsole’ C extensions are now built with the *note
     limited C API: 36f.  Patch by Victor Stinner.

   - gh-111140(18): Add additional flags to *note
     PyLong_AsNativeBytes(): 33a. and *note PyLong_FromNativeBytes():
     33b. to allow the caller to determine how to handle edge cases
     around values that fill the entire buffer.

   - gh-113024(19): Add *note PyObject_GenericHash(): 340. function.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/117642

   (2) https://peps.python.org/pep-0737/

   (3) https://github.com/python/cpython/issues/87193

   (4) https://github.com/python/cpython/issues/117021

   (5) https://github.com/python/cpython/issues/115756

   (6) https://github.com/python/cpython/issues/115781

   (7) https://github.com/python/cpython/issues/116869

   (8) https://github.com/python/cpython/issues/116869

   (9) https://github.com/python/cpython/issues/116936

   (10) https://github.com/python/cpython/issues/116809

   (11) https://github.com/python/cpython/issues/115754

   (12) https://github.com/python/cpython/issues/115754

   (13) https://github.com/python/cpython/issues/111696

   (14) https://peps.python.org/pep-0737/

   (15) https://github.com/python/cpython/issues/111696

   (16) https://github.com/python/cpython/issues/111696

   (17) https://github.com/python/cpython/issues/85283

   (18) https://github.com/python/cpython/issues/111140

   (19) https://github.com/python/cpython/issues/113024


File: python.info,  Node: Python 3 13 0 alpha 5,  Next: Python 3 13 0 alpha 4,  Prev: Python 3 13 0 alpha 6,  Up: 変更履歴

1.23.11 Python 3.13.0 alpha 5
-----------------------------

'Release date: 2024-03-12'

* Menu:

* Security: Security<6>.
* Core and Builtins: Core and Builtins<11>.
* Library: Library<10>.
* Documentation: Documentation<6>.
* Tests: Tests<8>.
* Build: Build<10>.
* Windows: Windows<7>.
* macOS: macOS<5>.
* IDLE: IDLE<9>.
* Tools/Demos: Tools/Demos<3>.
* C API: C API<10>.


File: python.info,  Node: Security<6>,  Next: Core and Builtins<11>,  Up: Python 3 13 0 alpha 5

1.23.11.1 Security
..................

   - gh-115398(1): Allow controlling Expat >=2.6.0 reparse deferral (
     CVE 2023-52425(2)) by adding five new methods:

        * *note xml.etree.ElementTree.XMLParser.flush(): 250.

        * *note xml.etree.ElementTree.XMLPullParser.flush(): 251.

        * *note xml.parsers.expat.xmlparser.GetReparseDeferralEnabled():
          252.

        * *note xml.parsers.expat.xmlparser.SetReparseDeferralEnabled():
          253.

        * ‘xml.sax.expatreader.ExpatParser.flush()’

   - gh-114572(3): *note ssl.SSLContext.cert_store_stats(): f78. and
     *note ssl.SSLContext.get_ca_certs(): f79. now correctly lock access
     to the certificate store, when the *note ssl.SSLContext: 274. is
     shared across multiple threads.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115398

   (2) https://www.cve.org/CVERecord?id=CVE-2023-52425

   (3) https://github.com/python/cpython/issues/114572


File: python.info,  Node: Core and Builtins<11>,  Next: Library<10>,  Prev: Security<6>,  Up: Python 3 13 0 alpha 5

1.23.11.2 Core and Builtins
...........................

   - gh-116604(1): Respect the status of the garbage collector when
     indirect calls are made via *note PyErr_CheckSignals(): 433. and
     the evaluation breaker.  Patch by Pablo Galindo

   - gh-112087(2): *note list: 5dc. is now compatible with the
     implementation of PEP 703(3).

   - gh-116381(4): Add specialization for ‘CONTAINS_OP’.

   - gh-116296(5): Fix possible refleak in ‘object.__reduce__()’
     internal error handling.

   - gh-115823(6): Properly calculate error ranges in the parser when
     raising *note SyntaxError: 172. exceptions caused by invalid byte
     sequences.  Patch by Pablo Galindo

   - gh-115778(7): Add ‘tierN’ annotation for instruction definition in
     interpreter DSL.

   - gh-115733(8): Fix crash when calling ‘next()’ on exhausted list
     iterators.

   - gh-115700(9): The regen-cases build stage now works on Windows.

   - gh-115347(10): Fix bug where docstring was replaced by a redundant
     NOP when Python is run with ‘-OO’.

   - gh-115323(11): Make error message more meaningful for when
     ‘bytearray.extend()’ is called with a *note str: 418. object.

   - gh-112175(12): Every ‘PyThreadState’ now has its own
     ‘eval_breaker’, allowing specific threads to be interrupted.

   - gh-115154(13): Fix a bug that was causing the *note
     tokenize.untokenize(): 1522. function to handle unicode named
     literals incorrectly.  Patch by Pablo Galindo

   - gh-112433(14): Add ability to force alignment of *note
     ctypes.Structure: 1b6. by way of the new ‘_align_’ attribute on the
     class.

   - gh-104090(15): The multiprocessing resource tracker now exits with
     non-zero status code if a resource leak was detected.  It still
     exits with status code 0 otherwise.

   - gh-105858(16): Improve the constructors for *note ast: 7. nodes.
     Arguments of list types now default to an empty list if omitted,
     and optional fields default to ‘None’.  AST nodes now have an
     ‘__annotations__’ attribute with the expected types of their
     attributes.  Passing unrecognized extra arguments to AST nodes is
     deprecated and will become an error in Python 3.15.  Omitting a
     required argument to an AST node is deprecated and will become an
     error in Python 3.15.  Patch by Jelle Zijlstra.

   - gh-101860(17): Expose ‘__name__’ attribute on property.

   - gh-96497(18): Fix incorrect resolution of mangled class variables
     used in assignment expressions in comprehensions.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116604

   (2) https://github.com/python/cpython/issues/112087

   (3) https://peps.python.org/pep-0703/

   (4) https://github.com/python/cpython/issues/116381

   (5) https://github.com/python/cpython/issues/116296

   (6) https://github.com/python/cpython/issues/115823

   (7) https://github.com/python/cpython/issues/115778

   (8) https://github.com/python/cpython/issues/115733

   (9) https://github.com/python/cpython/issues/115700

   (10) https://github.com/python/cpython/issues/115347

   (11) https://github.com/python/cpython/issues/115323

   (12) https://github.com/python/cpython/issues/112175

   (13) https://github.com/python/cpython/issues/115154

   (14) https://github.com/python/cpython/issues/112433

   (15) https://github.com/python/cpython/issues/104090

   (16) https://github.com/python/cpython/issues/105858

   (17) https://github.com/python/cpython/issues/101860

   (18) https://github.com/python/cpython/issues/96497


File: python.info,  Node: Library<10>,  Next: Documentation<6>,  Prev: Core and Builtins<11>,  Up: Python 3 13 0 alpha 5

1.23.11.3 Library
.................

   - gh-116600(1): Fix *note repr(): 7c8. for global *note Flag: 5ef.
     members.

   - gh-116349(2): *note platform.java_ver(): 287. is deprecated and
     will be removed in 3.15.  It was largely untested, had a confusing
     API, and was only useful for Jython support.

   - gh-116143(3): Fix a race in pydoc ‘_start_server’, eliminating a
     window in which ‘_start_server’ can return a thread that is
     "serving" but without a ‘docserver’ set.

   - gh-116127(4): *note typing: ed.: implement PEP 705(5) which adds
     *note typing.ReadOnly: 147. support to *note typing.TypedDict: 148.

   - gh-116325(6): *note typing: ed.: raise *note SyntaxError: 172.
     instead of *note AttributeError: 326. on forward references as
     empty strings.

   - gh-115957(7): When ‘asyncio.TaskGroup.create_task’ is called on an
     inactive ‘asyncio.TaskGroup’, the given coroutine will be closed
     (which prevents a ‘RuntimeWarning’).

   - gh-115978(8): Disable preadv(), readv(), pwritev(), and writev() on
     WASI.

     Under wasmtime for WASI 0.2, these functions don't pass test_posix
     (‘https://github.com/bytecodealliance/wasmtime/issues/7830’).

   - gh-88352(9): Fix the computation of the next rollover time in the
     ‘logging.TimedRotatingFileHandler’ handler.  ‘computeRollover()’
     now always returns a timestamp larger than the specified time and
     works correctly during the DST change.  ‘doRollover()’ no longer
     overwrite the already rolled over file, saving from data loss when
     run at midnight or during repeated time at the DST change.

   - gh-87115(10): Set ‘__main__.__spec__’ to ‘None’ when running a
     script with *note pdb: 94.

   - gh-76511(11): Fix UnicodeEncodeError in ‘email.Message.as_string()’
     that results when a message that claims to be in the ascii
     character set actually has non-ascii characters.  Non-ascii
     characters are now replaced with the U+FFFD replacement character,
     like in the ‘replace’ error handler.

   - gh-89547(12): Add support for nested typing special forms like
     Final[ClassVar[int]].

   - gh-65824(13): Improve the ‘less’ prompt in *note pydoc: a3.

   - gh-116040(14): [Enum] fix by-value calls when second value is
     falsey; e.g.  Cardinal(1, 0)

   - gh-115821(15): [Enum] Improve error message when calling
     super().__new__() in custom __new__.

   - gh-85644(16): Use the ‘XDG_CURRENT_DESKTOP’ environment variable in
     *note webbrowser: fd. to check desktop.  Prefer it to the
     deprecated ‘GNOME_DESKTOP_SESSION_ID’ for GNOME detection.

   - gh-75988(17): Fixed *note unittest.mock.create_autospec(): 156b. to
     pass the call through to the wrapped object to return the real
     result.

   - gh-115881(18): Fix issue where *note ast.parse(): 18d. would
     incorrectly flag conditional context managers (such as ‘with (x()
     if y else z()): ...’) as invalid syntax if ‘feature_version=(3, 8)’
     was passed.  This reverts changes to the grammar made as part of
     gh-94949(19).

   - gh-115886(20): Fix silent truncation of the name with an embedded
     null character in *note multiprocessing.shared_memory.SharedMemory:
     15bd.

   - gh-115532(21): Add kernel density estimation to the statistics
     module.

   - gh-115714(22): On WASI, the *note time: d7. module no longer get
     process time using ‘times()’ or ‘CLOCK_PROCESS_CPUTIME_ID’, system
     API is that is unreliable and is likely to be removed from WASI.
     The affected clock functions fall back to calling ‘clock()’.

   - gh-115809(23): Improve algorithm for computing which rolled-over
     log files to delete in ‘logging.TimedRotatingFileHandler’.  It is
     now reliable for handlers without ‘namer’ and with arbitrary
     deterministic ‘namer’ that leaves the datetime part in the file
     name unmodified.

   - gh-74668(24): *note urllib.parse: f3. functions *note parse_qs():
     25b. and *note parse_qsl(): 25a. now support bytes arguments
     containing raw and percent-encoded non-ASCII data.

   - gh-67044(25): *note csv.writer(): 454. now always quotes or escapes
     ‘'\r'’ and ‘'\n'’, regardless of 'lineterminator' value.

   - gh-115712(26): Restore support of space delimiter with
     ‘skipinitialspace=True’ in *note csv: 21.  *note csv.writer(): 454.
     now quotes empty fields if delimiter is a space and
     skipinitialspace is true and raises exception if quoting is not
     possible.

   - gh-112364(27): Fixed *note ast.unparse(): 8b3. to handle
     format_spec with ‘"’, ‘'’ or ‘\\’.  Patched by Frank Hoffmann.

   - gh-112997(28): Stop logging potentially sensitive callback
     arguments in *note asyncio: 8. unless debug mode is active.

   - gh-114914(29): Fix an issue where an abandoned ‘StreamWriter’ would
     not be garbage collected.

   - gh-111358(30): Fix a bug in
     ‘asyncio.BaseEventLoop.shutdown_default_executor()’ to ensure the
     timeout passed to the coroutine behaves as expected.

   - gh-115618(31): Fix improper decreasing the reference count for
     ‘None’ argument in *note property: 179. methods *note getter():
     15be, *note setter(): 15bf. and *note deleter(): 15c0.

   - gh-112720(32): Refactor ‘dis.ArgResolver’ to make it possible to
     subclass and change the way jump args are interpreted.

   - gh-112006(33): Fix *note inspect.unwrap(): f29. for types with the
     ‘__wrapper__’ data descriptor.  Fix *note
     inspect.Signature.from_callable(): 705. for builtins *note
     classmethod(): 14c. and *note staticmethod(): 3ef.

   - gh-101293(34): Support callables with the ‘__call__()’ method and
     types with ‘__new__()’ and ‘__init__()’ methods set to class
     methods, static methods, bound methods, partial functions, and
     other types of methods and descriptors in *note
     inspect.Signature.from_callable(): 705.

   - gh-103092(35): Isolate ‘_lsprof’ (apply PEP 687(36)).

   - gh-113942(37): *note pydoc: a3. no longer skips global functions
     implemented as builtin methods, such as ‘MethodDescriptorType’ and
     ‘WrapperDescriptorType’.

   - gh-115256(38): Added DeprecationWarning when accessing the tarfile
     attribute of TarInfo objects.  The attribute is never used
     internally and is only attached to TarInfos when the tarfile is
     opened in write-mode, not read-mode.  The attribute creates an
     unnecessary reference cycle which may cause corruption when not
     closing the handle after writing a tarfile.

   - gh-115197(39): ‘urllib.request’ no longer resolves the hostname
     before checking it against the system's proxy bypass list on macOS
     and Windows.

   - gh-113812(40): ‘DatagramTransport.sendto()’ will now send
     zero-length datagrams if called with an empty bytes object.  The
     transport flow control also now accounts for the datagram header
     when calculating the buffer size.

   - gh-114763(41): Protect modules loaded with *note
     importlib.util.LazyLoader: c7b. from race conditions when multiple
     threads try to access attributes before the loading is complete.

   - gh-114709(42): ‘posixpath.commonpath()’ now raises a *note
     ValueError: 1e3. exception when passed an empty iterable.
     Previously, *note IndexError: 14de. was raised.

     ‘posixpath.commonpath()’ now raises a *note TypeError: 502.
     exception when passed ‘None’.  Previously, *note ValueError: 1e3.
     was raised.

   - gh-114610(43): Fix bug where *note pathlib.PurePath.with_stem():
     15c1. converted a non-empty path suffix to a stem when given an
     empty 'stem' argument.  It now raises *note ValueError: 1e3, just
     like *note pathlib.PurePath.with_suffix(): 157b. does when called
     on a path with an empty stem, given a non-empty 'suffix' argument.

   - gh-107361(44): Add *note ssl.VERIFY_X509_PARTIAL_CHAIN: 13c. and
     ‘VERIFY_X509_STRICT’ to the default SSL context created with *note
     ssl.create_default_context(): 13b.

   - gh-112281(45): Allow creating *note union of types: 78d. for *note
     typing.Annotated: 90b. with unhashable metadata.

   - gh-111775(46): Fix
     ‘importlib.resources.simple.ResourceHandle.open()’ for text mode,
     added missed ‘stream’ argument.

   - gh-90095(47): Make .pdbrc and -c work with any valid pdb commands.

   - gh-107625(48): Raise *note configparser.ParsingError: 4d0. from
     *note read(): 140d. and *note read_file(): 4d1. methods of *note
     configparser.ConfigParser: 1aa. if a key without a corresponding
     value is continued (that is, followed by an indented line).

   - gh-107155(49): Fix incorrect output of ‘help(x)’ where ‘x’ is a
     *note lambda: 126d. function, which has an ‘__annotations__’
     dictionary attribute with a ‘"return"’ key.

   - gh-57141(50): Add option for 'non-shallow' comparisons to *note
     filecmp.dircmp: f0d. like *note filecmp.cmp(): 15c2.  Original
     patch by Steven Ward.  Enhanced by Tobias Rautenkranz

   - gh-69990(51): ‘Profile.print_stats()’ has been improved to accept
     multiple sort arguments.  Patched by Chiu-Hsiang Hsu and Furkan
     Onder.

   - gh-104061(52): Add ‘socket.SO_BINDTOIFINDEX’ constant.

   - gh-60346(53): Fix ArgumentParser inconsistent with
     parse_known_args.

   - gh-102389(54): Add ‘windows_31j’ to aliases for ‘cp932’ codec

   - gh-72249(55): ‘functools.partial`s of :func:`repr()’ has been
     improved to include the *note module: 15c3. name.  Patched by
     Furkan Onder and Anilyka Barry.

   - gh-100985(56): Update HTTPSConnection to consistently wrap IPv6
     Addresses when using a proxy.

   - gh-100884(57): email: fix misfolding of comma in address-lists over
     multiple lines in combination with unicode encoding.

   - gh-95782(58): Fix ‘io.BufferedReader.tell()’,
     ‘io.BufferedReader.seek()’, ‘_pyio.BufferedReader.tell()’,
     ‘io.BufferedRandom.tell()’, ‘io.BufferedRandom.seek()’ and
     ‘_pyio.BufferedRandom.tell()’ being able to return negative
     offsets.

   - gh-96310(59): Fix a traceback in *note argparse: 5. when all
     options in a mutually exclusive group are suppressed.

   - gh-93205(60): Fixed a bug in *note
     logging.handlers.TimedRotatingFileHandler: f2e. where multiple
     rotating handler instances pointing to files with the same name but
     different extensions would conflict and not delete the correct
     files.

   - bpo-31116(61): Add Z85 encoding to ‘base64’.

   - bpo-44865(62): Add missing call to localization function in *note
     argparse: 5.

   - bpo-43952(63): Fix *note
     multiprocessing.connection.Listener.accept(): 15c4. to accept empty
     bytes as authkey.  Not accepting empty bytes as key causes it to
     hang indefinitely.

   - bpo-42125(64): linecache: get module name from ‘__spec__’ if
     available.  This allows getting source code for the ‘__main__’
     module when a custom loader is used.

   - bpo-41122(65): Failing to pass arguments properly to *note
     functools.singledispatchmethod(): 9c0. now throws a TypeError
     instead of hitting an index out of bounds internally.

   - bpo-40818(66): The asyncio REPL now runs *note
     sys.__interactivehook__: f94. on startup.  The default
     implementation of *note sys.__interactivehook__: f94. provides
     auto-completion to the asyncio REPL. Patch contributed by Rémi
     Lapeyre.

   - bpo-33775(67): Add 'default' and 'version' help text for
     localization in argparse.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116600

   (2) https://github.com/python/cpython/issues/116349

   (3) https://github.com/python/cpython/issues/116143

   (4) https://github.com/python/cpython/issues/116127

   (5) https://peps.python.org/pep-0705/

   (6) https://github.com/python/cpython/issues/116325

   (7) https://github.com/python/cpython/issues/115957

   (8) https://github.com/python/cpython/issues/115978

   (9) https://github.com/python/cpython/issues/88352

   (10) https://github.com/python/cpython/issues/87115

   (11) https://github.com/python/cpython/issues/76511

   (12) https://github.com/python/cpython/issues/89547

   (13) https://github.com/python/cpython/issues/65824

   (14) https://github.com/python/cpython/issues/116040

   (15) https://github.com/python/cpython/issues/115821

   (16) https://github.com/python/cpython/issues/85644

   (17) https://github.com/python/cpython/issues/75988

   (18) https://github.com/python/cpython/issues/115881

   (19) https://github.com/python/cpython/issues/94949

   (20) https://github.com/python/cpython/issues/115886

   (21) https://github.com/python/cpython/issues/115532

   (22) https://github.com/python/cpython/issues/115714

   (23) https://github.com/python/cpython/issues/115809

   (24) https://github.com/python/cpython/issues/74668

   (25) https://github.com/python/cpython/issues/67044

   (26) https://github.com/python/cpython/issues/115712

   (27) https://github.com/python/cpython/issues/112364

   (28) https://github.com/python/cpython/issues/112997

   (29) https://github.com/python/cpython/issues/114914

   (30) https://github.com/python/cpython/issues/111358

   (31) https://github.com/python/cpython/issues/115618

   (32) https://github.com/python/cpython/issues/112720

   (33) https://github.com/python/cpython/issues/112006

   (34) https://github.com/python/cpython/issues/101293

   (35) https://github.com/python/cpython/issues/103092

   (36) https://peps.python.org/pep-0687/

   (37) https://github.com/python/cpython/issues/113942

   (38) https://github.com/python/cpython/issues/115256

   (39) https://github.com/python/cpython/issues/115197

   (40) https://github.com/python/cpython/issues/113812

   (41) https://github.com/python/cpython/issues/114763

   (42) https://github.com/python/cpython/issues/114709

   (43) https://github.com/python/cpython/issues/114610

   (44) https://github.com/python/cpython/issues/107361

   (45) https://github.com/python/cpython/issues/112281

   (46) https://github.com/python/cpython/issues/111775

   (47) https://github.com/python/cpython/issues/90095

   (48) https://github.com/python/cpython/issues/107625

   (49) https://github.com/python/cpython/issues/107155

   (50) https://github.com/python/cpython/issues/57141

   (51) https://github.com/python/cpython/issues/69990

   (52) https://github.com/python/cpython/issues/104061

   (53) https://github.com/python/cpython/issues/60346

   (54) https://github.com/python/cpython/issues/102389

   (55) https://github.com/python/cpython/issues/72249

   (56) https://github.com/python/cpython/issues/100985

   (57) https://github.com/python/cpython/issues/100884

   (58) https://github.com/python/cpython/issues/95782

   (59) https://github.com/python/cpython/issues/96310

   (60) https://github.com/python/cpython/issues/93205

   (61) https://bugs.python.org/issue?@action=redirect&bpo=31116

   (62) https://bugs.python.org/issue?@action=redirect&bpo=44865

   (63) https://bugs.python.org/issue?@action=redirect&bpo=43952

   (64) https://bugs.python.org/issue?@action=redirect&bpo=42125

   (65) https://bugs.python.org/issue?@action=redirect&bpo=41122

   (66) https://bugs.python.org/issue?@action=redirect&bpo=40818

   (67) https://bugs.python.org/issue?@action=redirect&bpo=33775


File: python.info,  Node: Documentation<6>,  Next: Tests<8>,  Prev: Library<10>,  Up: Python 3 13 0 alpha 5

1.23.11.4 Documentation
.......................

   - gh-115399(1): Document CVE 2023-52425(2) of Expat <2.6.0 under "XML
     vulnerabilities".

   - gh-109653(3): Improve import time of *note uuid: f8. on Linux.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115399

   (2) https://www.cve.org/CVERecord?id=CVE-2023-52425

   (3) https://github.com/python/cpython/issues/109653


File: python.info,  Node: Tests<8>,  Next: Build<10>,  Prev: Documentation<6>,  Up: Python 3 13 0 alpha 5

1.23.11.5 Tests
...............

   - gh-71052(1): Add test exclusions to support running the test suite
     on Android.

   - gh-71052(2): Enable ‘test_concurrent_futures’ on platforms that
     support threading but not multiprocessing.

   - gh-115796(3): Make '_testinternalcapi.assemble_code_object'
     construct the exception table for the code object.

   - gh-115720(4): Leak tests (‘-R’, ‘--huntrleaks’) now show a summary
     of the number of leaks found in each iteration.

   - gh-115122(5): Add ‘--bisect’ option to regrtest test runner: run
     failed tests with ‘test.bisect_cmd’ to identify failing tests.
     Patch by Victor Stinner.

   - gh-115596(6): Fix ‘ProgramPriorityTests’ in ‘test_os’ permanently
     changing the process priority.

   - gh-115556(7): On Windows, commas passed in arguments to
     ‘Tools\buildbot\test.bat’ and ‘PCbuild\\rt.bat’ are now properly
     handled.

   - gh-115420(8): Fix translation of exception handler targets by
     ‘_testinternalcapi.optimize_cfg’.

   - gh-115376(9): Fix segfault in ‘_testinternalcapi.compiler_codegen’
     on bad input.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/71052

   (2) https://github.com/python/cpython/issues/71052

   (3) https://github.com/python/cpython/issues/115796

   (4) https://github.com/python/cpython/issues/115720

   (5) https://github.com/python/cpython/issues/115122

   (6) https://github.com/python/cpython/issues/115596

   (7) https://github.com/python/cpython/issues/115556

   (8) https://github.com/python/cpython/issues/115420

   (9) https://github.com/python/cpython/issues/115376


File: python.info,  Node: Build<10>,  Next: Windows<7>,  Prev: Tests<8>,  Up: Python 3 13 0 alpha 5

1.23.11.6 Build
...............

   - gh-116313(1): Get WASI builds to work under wasmtime 18 w/ WASI
     0.2/preview2 primitives.

   - gh-71052(2): Change Android's *note sys.platform: a5b. from
     ‘"linux"’ to ‘"android"’.

   - gh-116117(3): Backport ‘libb2’'s PR #42 to fix compiling CPython on
     32-bit Windows with ‘clang-cl’.

   - gh-71052(4): Fix several Android build issues

   - gh-114099(5): A testbed project was added to run the test suite on
     iOS.

   - gh-115350(6): Fix building ctypes module with -DWIN32_LEAN_AND_MEAN
     defined

   - gh-111225(7): Link extension modules against libpython on Android.

   - gh-115737(8): The install name for libPython is now correctly set
     for non-framework macOS builds.

   - gh-114099(9): Makefile targets were added to support compiling an
     iOS-compatible framework build.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116313

   (2) https://github.com/python/cpython/issues/71052

   (3) https://github.com/python/cpython/issues/116117

   (4) https://github.com/python/cpython/issues/71052

   (5) https://github.com/python/cpython/issues/114099

   (6) https://github.com/python/cpython/issues/115350

   (7) https://github.com/python/cpython/issues/111225

   (8) https://github.com/python/cpython/issues/115737

   (9) https://github.com/python/cpython/issues/114099


File: python.info,  Node: Windows<7>,  Next: macOS<5>,  Prev: Build<10>,  Up: Python 3 13 0 alpha 5

1.23.11.7 Windows
.................

   - gh-116012(1): Ensure the value of ‘GetLastError()’ is preserved
     across GIL operations.

   - gh-115582(2): Building extensions intended for free-threaded builds
     of CPython now require compiling with ‘/DPy_GIL_DISABLED’ manually
     when using a regular install.  This is expected to change in future
     releases.

   - gh-115554(3): The installer now has more strict rules about
     updating the *note Windows の Python ランチャ: 588.  In general,
     most users only have a single launcher installed and will see no
     difference.  When multiple launchers have been installed, the
     option to install the launcher is disabled until all but one have
     been removed.  Downgrading the launcher (which was never allowed)
     is now more obviously blocked.

   - gh-115543(4): *note Windows の Python ランチャ: 588. can now detect
     Python 3.13 when installed from the Microsoft Store, and will
     install Python 3.12 by default when ‘PYLAUNCHER_ALLOW_INSTALL’ is
     set.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116012

   (2) https://github.com/python/cpython/issues/115582

   (3) https://github.com/python/cpython/issues/115554

   (4) https://github.com/python/cpython/issues/115543


File: python.info,  Node: macOS<5>,  Next: IDLE<9>,  Prev: Windows<7>,  Up: Python 3 13 0 alpha 5

1.23.11.8 macOS
...............

   - gh-116145(1): Update macOS installer to Tcl/Tk 8.6.14.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/116145


File: python.info,  Node: IDLE<9>,  Next: Tools/Demos<3>,  Prev: macOS<5>,  Up: Python 3 13 0 alpha 5

1.23.11.9 IDLE
..............

   - gh-88516(1): On macOS show a proxy icon in the title bar of editor
     windows to match platform behaviour.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/88516


File: python.info,  Node: Tools/Demos<3>,  Next: C API<10>,  Prev: IDLE<9>,  Up: Python 3 13 0 alpha 5

1.23.11.10 Tools/Demos
......................

   - gh-100176(1): Remove outdated Tools/{io,cc,string}bench

   - bpo-45101(2): Add consistency in usage message IO between 2
     versions of python-config.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100176

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45101


File: python.info,  Node: C API<10>,  Prev: Tools/Demos<3>,  Up: Python 3 13 0 alpha 5

1.23.11.11 C API
................

   - gh-114626(1): Add again ‘_PyCFunctionFastWithKeywords’ name,
     removed in Python 3.13 alpha 4 by mistake.  Keep the old private
     ‘_PyCFunctionFastWithKeywords’ name (Python 3.7) as an alias to the
     new public name ‘PyCFunctionFastWithKeywords’ (Python 3.13a4).
     Patch by Victor Stinner.

   - gh-111418(2): Add *note PyHASH_MODULUS: 15cd, *note PyHASH_BITS:
     15ce, *note PyHASH_INF: 15cf. and *note PyHASH_IMAG: 15d0. C
     macros.  Patch by Sergey B Kirpichev.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/114626

   (2) https://github.com/python/cpython/issues/111418


File: python.info,  Node: Python 3 13 0 alpha 4,  Next: Python 3 13 0 alpha 3,  Prev: Python 3 13 0 alpha 5,  Up: 変更履歴

1.23.12 Python 3.13.0 alpha 4
-----------------------------

'Release date: 2024-02-15'

* Menu:

* Security: Security<7>.
* Core and Builtins: Core and Builtins<12>.
* Library: Library<11>.
* Documentation: Documentation<7>.
* Tests: Tests<9>.
* Build: Build<11>.
* Windows: Windows<8>.
* macOS: macOS<6>.
* IDLE: IDLE<10>.
* Tools/Demos: Tools/Demos<4>.
* C API: C API<11>.


File: python.info,  Node: Security<7>,  Next: Core and Builtins<12>,  Up: Python 3 13 0 alpha 4

1.23.12.1 Security
..................

   - gh-115399(1): Update bundled libexpat to 2.6.0

   - gh-115243(2): Fix possible crashes in *note
     collections.deque.index(): d9f. when the deque is concurrently
     modified.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115399

   (2) https://github.com/python/cpython/issues/115243


File: python.info,  Node: Core and Builtins<12>,  Next: Library<11>,  Prev: Security<7>,  Up: Python 3 13 0 alpha 4

1.23.12.2 Core and Builtins
...........................

   - gh-112087(1): For an empty reverse iterator for list will be
     reduced to *note reversed(): 831.  Patch by Donghee Na

   - gh-114570(2): Add *note PythonFinalizationError: 133. exception.
     This exception derived from *note RuntimeError: 17a. is raised when
     an operation is blocked during the *note Python finalization: 134.
     Patch by Victor Stinner.

   - gh-114695(3): Add *note sys._clear_internal_caches(): 15d4, which
     clears all internal performance-related caches (and deprecate the
     less-general *note sys._clear_type_cache(): 15d5. function).

   - gh-114828(4): Fix compilation crashes in uncommon code examples
     using *note super(): 4a8. inside a comprehension in a class body.

   - gh-112069(5): Adapt *note set: 5a3. and *note frozenset: 5a4.
     methods to Argument Clinic.

   - gh-115011(6): Setters for members with an unsigned integer type now
     support the same range of valid values for objects that has a *note
     __index__(): 6e8. method as for *note int: 238.

   - gh-114887(7): Changed socket type validation in *note
     create_datagram_endpoint(): 6fe. to accept all non-stream sockets.
     This fixes a regression in compatibility with raw sockets.

   - gh-114944(8): Fixes a race between ‘PyParkingLot_Park’ and
     ‘_PyParkingLot_UnparkAll’.

   - gh-113462(9): Limit the number of versions that a single class can
     use.  Prevents a few wayward classes using up all the version
     numbers.

   - gh-76763(10): The *note chr(): 15d6. builtin function now always
     raises *note ValueError: 1e3. for values outside the valid range.
     Previously it raised *note OverflowError: 84e. for very large or
     small values.

   - gh-114806(11): No longer specialize calls to classes, if those
     classes have metaclasses.  Fixes bug where the ‘__call__’ method of
     the metaclass was not being called.

   - gh-107944(12): Improve error message for function calls with bad
     keyword arguments via getargs

   - gh-112529(13): The free-threaded build no longer allocates space
     for the ‘PyGC_Head’ structure in objects that support cyclic
     garbage collection.  A number of other fields and data structures
     are used as replacements, including ‘ob_gc_bits’, ‘ob_tid’, and
     mimalloc internal data structures.

   - gh-114456(14): Lower the recursion limit under a debug build of
     WASI.

   - gh-114083(15): Compiler applies folding of LOAD_CONST with
     following instruction in a separate pass before other
     optimisations.  This enables jump threading in certain
     circumstances.

   - gh-114388(16): Fix a *note RuntimeWarning: 1a2. emitted when assign
     an integer-like value that is not an instance of *note int: 238. to
     an attribute that corresponds to a C struct member of *note type:
     15d7. T_UINT and T_ULONG. Fix a double *note RuntimeWarning: 1a2.
     emitted when assign a negative integer value to an attribute that
     corresponds to a C struct member of type T_UINT.

   - gh-114265(17): Compiler propagates line numbers before
     optimization, leading to more optimization opportunities and
     removing the need for the ‘guarantee_lineno_for_exits’ hack.

   - gh-112529(18): The free-threaded build now has its own thread-safe
     GC implementation that uses mimalloc to find GC tracked objects.
     It is non-generational, unlike the existing GC implementation.

   - gh-114050(19): Fix segmentation fault caused by an incorrect format
     string in ‘TypeError’ exception when more than two arguments are
     passed to ‘int’.

   - gh-112354(20): The ‘END_FOR’ instruction now pops only one value.
     This is to better support side exits in loops.

   - gh-113884(21): Make *note queue.SimpleQueue: b38. thread safe when
     the GIL is disabled.

   - gh-114058(22): Implement the foundations of the Tier 2 redundancy
     eliminator.

   - gh-113939(23): frame.clear(): Clear frame.f_locals as well, and not
     only the fast locals.  This is relevant once frame.f_locals was
     accessed, which would contain also references to all the locals.

   - gh-112050(24): Convert *note collections.deque: 5a6. to use
     Argument Clinic.

   - gh-112050(25): Make methods on *note collections.deque: 5a6.
     thread-safe when the GIL is disabled.

   - gh-113464(26): Add an option (‘--enable-experimental-jit’ for
     ‘configure’-based builds or ‘--experimental-jit’ for
     ‘PCbuild’-based ones) to build an 'experimental' just-in-time
     compiler, based on copy-and-patch(27)

   - gh-113055(28): Make interp->obmalloc a pointer.  For interpreters
     that share state with the main interpreter, this points to the same
     static memory structure.  For interpreters with their own obmalloc
     state, it is heap allocated.  Add free_obmalloc_arenas() which will
     free the obmalloc arenas and radix tree structures for interpreters
     with their own obmalloc state.

   - gh-55664(29): Add warning when creating *note type: d16. using a
     namespace dictionary with non-string keys.  Patched by Daniel Urban
     and Furkan Onder.

   - gh-104530(30): Use native Win32 condition variables.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/112087

   (2) https://github.com/python/cpython/issues/114570

   (3) https://github.com/python/cpython/issues/114695

   (4) https://github.com/python/cpython/issues/114828

   (5) https://github.com/python/cpython/issues/112069

   (6) https://github.com/python/cpython/issues/115011

   (7) https://github.com/python/cpython/issues/114887

   (8) https://github.com/python/cpython/issues/114944

   (9) https://github.com/python/cpython/issues/113462

   (10) https://github.com/python/cpython/issues/76763

   (11) https://github.com/python/cpython/issues/114806

   (12) https://github.com/python/cpython/issues/107944

   (13) https://github.com/python/cpython/issues/112529

   (14) https://github.com/python/cpython/issues/114456

   (15) https://github.com/python/cpython/issues/114083

   (16) https://github.com/python/cpython/issues/114388

   (17) https://github.com/python/cpython/issues/114265

   (18) https://github.com/python/cpython/issues/112529

   (19) https://github.com/python/cpython/issues/114050

   (20) https://github.com/python/cpython/issues/112354

   (21) https://github.com/python/cpython/issues/113884

   (22) https://github.com/python/cpython/issues/114058

   (23) https://github.com/python/cpython/issues/113939

   (24) https://github.com/python/cpython/issues/112050

   (25) https://github.com/python/cpython/issues/112050

   (26) https://github.com/python/cpython/issues/113464

   (27) https://fredrikbk.com/publications/copy-and-patch.pdf

   (28) https://github.com/python/cpython/issues/113055

   (29) https://github.com/python/cpython/issues/55664

   (30) https://github.com/python/cpython/issues/104530


File: python.info,  Node: Library<11>,  Next: Documentation<7>,  Prev: Core and Builtins<12>,  Up: Python 3 13 0 alpha 4

1.23.12.3 Library
.................

   - gh-115392(1): Fix a bug in *note doctest: 31. where incorrect line
     numbers would be reported for decorated functions.

   - gh-114563(2): Fix several *note format(): 5eb. bugs when using the
     C implementation of *note Decimal: 27d.: * memory leak in some rare
     cases when using the ‘z’ format option (coerce negative 0) *
     incorrect output when applying the ‘z’ format option to type ‘F’
     (fixed-point with capital ‘NAN’ / ‘INF’) * incorrect output when
     applying the ‘#’ format option (alternate form)

   - gh-102840(3): Fix confused traceback when floordiv, mod, or divmod
     operations happens between instances of *note fractions.Fraction:
     1c8. and *note complex: 2cf.

   - gh-115165(4): Most exceptions are now ignored when attempting to
     set the ‘__orig_class__’ attribute on objects returned when calling
     *note typing: ed. generic aliases (including generic aliases
     created using *note typing.Annotated: 90b.).  Previously only *note
     AttributeError: 326. was ignored.  Patch by Dave Shawley.

   - gh-112903(5): Fix "issubclass() arg 1 must be a class" errors in
     certain cases of multiple inheritance with generic aliases
     (regression in early 3.13 alpha releases).

   - gh-115133(6): Fix tests for *note XMLPullParser: fbe. with Expat
     2.6.0.

   - gh-115059(7): ‘io.BufferedRandom.read1()’ now flushes the
     underlying write buffer.

   - gh-79382(8): Trailing ‘**’ no longer allows to match files and
     non-existing paths in recursive *note glob(): 27f.

   - gh-67837(9): Avoid race conditions in the creation of directories
     during concurrent extraction in *note tarfile: c8. and *note
     zipfile: 117.

   - gh-115060(10): Speed up *note pathlib.Path.glob(): 20e. by removing
     redundant regex matching.

   - gh-97928(11): Partially revert the behavior of
     ‘tkinter.Text.count()’.  By default it preserves the behavior of
     older Python versions, except that setting ‘wantobjects’ to 0 no
     longer has effect.  Add a new parameter 'return_ints': specifying
     ‘return_ints=True’ makes ‘Text.count()’ always returning the single
     count as an integer instead of a 1-tuple or ‘None’.

   - gh-114628(12): When csv.Error is raised when handling TypeError, do
     not print the TypeError traceback.

   - gh-85984(13): Added ‘_POSIX_VDISABLE’ from C's ‘<unistd.h>’ to
     *note termios: ca.

   - gh-114965(14): Update bundled pip to 24.0

   - gh-114959(15): *note tarfile: c8. no longer ignores errors when
     trying to extract a directory on top of a file.

   - gh-114894(16): Add *note array.array.clear(): 187.

   - gh-114071(17): Support tuple subclasses using auto() for enum
     member value.

   - gh-109475(18): Fix support of explicit option value "-" in *note
     argparse: 5. (e.g.  ‘--option=--’).

   - gh-49766(19): Fix *note date: 1af.-*note datetime: 1ae. comparison.
     Now the special comparison methods like ‘__eq__’ and ‘__lt__’
     return *note NotImplemented: 79d. if one of comparands is ‘date’
     and other is ‘datetime’ instead of ignoring the time part and the
     time zone or forcefully return "not equal" or raise *note
     TypeError: 502.  It makes comparison of ‘date’ and ‘datetime’
     subclasses more symmetric and allows to change the default behavior
     by overriding the special comparison methods in subclasses.

   - gh-110190(20): Fix ctypes structs with array on Windows ARM64
     platform by setting ‘MAX_STRUCT_SIZE’ to 32 in stgdict.  Patch by
     Diego Russo

   - gh-114678(21): Ensure that deprecation warning for 'N' specifier in
     *note Decimal: 27d. format is not raised for cases where 'N'
     appears in other places in the format specifier.  Based on patch by
     Stefan Krah.

   - gh-70303(22): Return both files and directories from *note
     pathlib.Path.glob(): 20e. if a pattern ends with "‘**’".
     Previously only directories were returned.

   - gh-109653(23): Improve import time of *note importlib.metadata: 6e.
     and *note email.utils: 47.

   - gh-113280(24): Fix a leak of open socket in rare cases when error
     occurred in *note ssl.SSLSocket: 8b8. creation.

   - gh-77749(25): *note email.policy.EmailPolicy.fold(): 15d9. now
     always encodes non-ASCII characters in headers if *note utf8: dc5.
     is false.

   - gh-83383(26): Synchronization of the *note dbm.dumb: 2a. database
     is now no-op if there was no modification since opening or last
     synchronization.  The directory file for a newly created empty
     *note dbm.dumb: 2a. database is now created immediately after
     opening instead of deferring this until synchronizing or closing.

   - gh-91602(27): Add 'filter' keyword-only parameter to *note
     sqlite3.Connection.iterdump(): 228. for filtering database objects
     to dump.  Patch by Mariusz Felisiak.

   - gh-112451(28): Prohibit subclassing pure-Python *note
     datetime.timezone: 1091.  This is consistent with C-extension
     implementation.  Patch by Mariusz Felisiak.

   - gh-69893(29): Add the ‘close()’ method for the iterator returned by
     *note xml.etree.ElementTree.iterparse(): 254.

   - gh-109653(30): Reduce the import time of *note threading: d6.
     module by ~50%.  Patch by Daniel Hollas.

   - gh-114492(31): Make the result of *note termios.tcgetattr(): 15da.
     reproducible on Alpine Linux.  Previously it could leave a random
     garbage in some fields.

   - gh-114315(32): Make *note threading.Lock: 15db. a real class, not a
     factory function.  Add ‘__new__’ to ‘_thread.lock’ type.

   - gh-100414(33): Add *note dbm.sqlite3: 2d. as a backend to *note
     dbm: 29, and make it the new default ‘dbm’ backend.  Patch by
     Raymond Hettinger and Erlend E. Aasland.

   - gh-113267(34): Revert changes in gh-106584(35) which made calls of
     ‘TestResult’ methods ‘startTest()’ and ‘stopTest()’ unbalanced.

   - gh-75128(36): Ignore an *note OSError: 3f0. in
     ‘asyncio.BaseEventLoop.create_server()’ when IPv6 is available but
     the interface cannot actually support it.

   - gh-114423(37): ‘_DummyThread’ entries in ‘threading._active’ are
     now automatically removed when the related thread dies.

   - gh-114257(38): Dismiss the ‘FileNotFound’ error in *note
     ctypes.util.find_library(): d17. and just return ‘None’ on Linux.

   - gh-114321(39): Expose more platform specific constants in the *note
     fcntl: 4f. module on Linux, macOS, FreeBSD and NetBSD.

   - gh-114328(40): The *note tty.setcbreak(): 15dc. and new *note
     tty.cfmakecbreak(): 15dd. no longer clears the terminal input ICRLF
     flag.  This fixes a regression introduced in 3.12 that no longer
     matched how OSes define cbreak mode in their ‘stty(1)’ manual
     pages.

   - gh-114281(41): Remove type hints from ‘Lib/asyncio/staggered.py’.
     The annotations in the typeshed(42) project should be used instead.

   - gh-101438(43): Avoid reference cycle in ElementTree.iterparse.  The
     iterator returned by ‘ElementTree.iterparse’ may hold on to a file
     descriptor.  The reference cycle prevented prompt clean-up of the
     file descriptor if the returned iterator was not exhausted.

   - gh-114198(44): The signature for the ‘__replace__’ method on *note
     dataclasses: 27. now has the first argument named ‘self’, rather
     than ‘obj’.

   - gh-104522(45): *note OSError: 3f0. raised when run a subprocess now
     only has 'filename' attribute set to 'cwd' if the error was caused
     by a failed attempt to change the current directory.

   - gh-114149(46): Enum: correctly handle tuple subclasses in custom
     ‘__new__’.

   - gh-83648(47): Support deprecation of options, positional arguments
     and subcommands in *note argparse: 5.

   - gh-114087(48): Speed up ‘dataclasses.asdict’ up to 1.35x.

   - gh-109534(49): Fix a reference leak in
     ‘asyncio.selector_events.BaseSelectorEventLoop’ when SSL handshakes
     fail.  Patch contributed by Jamie Phan.

   - gh-79634(50): Accept *note path-like objects: 280. as patterns in
     *note pathlib.Path.glob(): 20e. and *note rglob(): 20f.

   - gh-112202(51): Ensure that a *note asyncio.Condition.notify():
     15de. call does not get lost if the awakened ‘Task’ is
     simultaneously cancelled or encounters any other error.

   - gh-113951(52): Fix the behavior of ‘tag_unbind()’ methods of
     ‘tkinter.Text’ and ‘tkinter.Canvas’ classes with three arguments.
     Previously, ‘widget.tag_unbind(tag, sequence, funcid)’ destroyed
     the current binding for 'sequence', leaving 'sequence' unbound, and
     deleted the 'funcid' command.  Now it removes only 'funcid' from
     the binding for 'sequence', keeping other commands, and deletes the
     'funcid' command.  It leaves 'sequence' unbound only if 'funcid'
     was the last bound command.

   - gh-97959(53): Fix rendering class methods, bound methods, method
     and function aliases in *note pydoc: a3.  Class methods no longer
     have "method of builtins.type instance" note.  Corresponding notes
     are now added for class and unbound methods.  Method and function
     aliases now have references to the module or the class where the
     origin was defined if it differs from the current.  Bound methods
     are now listed in the static methods section.  Methods of builtin
     classes are now supported as well as methods of Python classes.

   - gh-113796(54): Add more validation checks in the *note csv.Dialect:
     15df. constructor.  *note ValueError: 1e3. is now raised if the
     same character is used in different roles.

   - gh-113732(55): Fix support of *note QUOTE_NOTNULL: 451. and *note
     QUOTE_STRINGS: 452. in *note csv.reader(): 453.

   - gh-113225(56): Speed up *note pathlib.Path.walk(): 475. by using
     *note os.DirEntry.path: 15e0. where possible.

   - gh-89039(57): When replace() method is called on a subclass of
     datetime, date or time, properly call derived constructor.
     Previously, only the base class's constructor was called.

     Also, make sure to pass non-zero fold values when creating
     subclasses in various methods.  Previously, fold was silently
     ignored.

   - gh-112919(58): Speed-up *note datetime.datetime.replace(): 1474,
     *note datetime.date.replace(): 15e1. and *note
     datetime.time.replace(): 15e2.

   - gh-59013(59): Set breakpoint on the first executable line of the
     function, instead of the line of function definition when the user
     do ‘break func’ using *note pdb: 94.

   - gh-112343(60): Improve handling of pdb convenience variables to
     avoid replacing string contents.

   - gh-112240(61): Add option to calendar module CLI to specify the
     weekday to start each week.  Patch by Steven Ward.

   - gh-111741(62): Recognise ‘image/webp’ as a standard format in the
     *note mimetypes: 82. module.

   - gh-43457(63): Fix the *note tkinter: d9. widget method
     ‘wm_attributes()’.  It now accepts the attribute name without the
     minus prefix to get window attributes and allows to specify
     attributes and values to set as keyword arguments.  Add new
     optional keyword argument 'return_python_dict': calling
     ‘w.wm_attributes(return_python_dict=True)’ returns the attributes
     as a dict instead of a tuple.  Calling ‘w.wm_attributes()’ now
     returns a tuple instead of string if 'wantobjects' was set to 0.

   - gh-82626(64): Many functions now emit a warning if a boolean value
     is passed as a file descriptor argument.

   - gh-111051(65): Added check for file modification during debugging
     with *note pdb: 94.

   - gh-110345(66): Show the Tcl/Tk patchlevel (rather than version) in
     ‘tkinter._test()’.

   - gh-38807(67): Fix race condition in *note trace: e6.  Instead of
     checking if a directory exists and creating it, directly call *note
     os.makedirs(): 1ff. with the kwarg ‘exist_ok=True’.

   - gh-75705(68): Set unixfrom envelope in *note mailbox.mbox: 15e3.
     and *note mailbox.MMDF: 15e4.

   - gh-106233(69): Fix stacklevel in ‘InvalidTZPathWarning’ during
     *note zoneinfo: 11a. module import.

   - gh-105102(70): Allow *note ctypes.Union: 15e5. to be nested in
     *note ctypes.Structure: 1b6. when the system endianness is the
     opposite of the classes.

   - gh-104282(71): Fix null pointer dereference in
     ‘lzma._decode_filter_properties()’ due to improper handling of BCJ
     filters with properties of zero length.  Patch by Radislav
     Chugunov.

   - gh-96471(72): Add *note queue.Queue: 1356. termination with *note
     shutdown(): 21b.

   - gh-101599(73): Changed argparse flag options formatting to remove
     redundancy.

   - gh-85984(74): Add POSIX pseudo-terminal functions *note
     os.posix_openpt(): 15e6, *note os.grantpt(): 15e7, *note
     os.unlockpt(): 15e8, and *note os.ptsname(): 15e9.

   - gh-102512(75): When *note os.fork(): 17c. is called from a foreign
     thread (aka ‘_DummyThread’), the type of the thread in a child
     process is changed to ‘_MainThread’.  Also changed its name and
     daemonic status, it can be now joined.

   - gh-88569(76): Add *note os.path.isreserved(): 204, which identifies
     reserved pathnames such as "NUL", "AUX" and "CON". This function is
     only available on Windows.

     Deprecate *note pathlib.PurePath.is_reserved(): 286.

   - bpo-38364(77): The ‘inspect’ functions ‘isgeneratorfunction’,
     ‘iscoroutinefunction’, ‘isasyncgenfunction’ now support
     ‘functools.partialmethod’ wrapped functions the same way they
     support ‘functools.partial’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115392

   (2) https://github.com/python/cpython/issues/114563

   (3) https://github.com/python/cpython/issues/102840

   (4) https://github.com/python/cpython/issues/115165

   (5) https://github.com/python/cpython/issues/112903

   (6) https://github.com/python/cpython/issues/115133

   (7) https://github.com/python/cpython/issues/115059

   (8) https://github.com/python/cpython/issues/79382

   (9) https://github.com/python/cpython/issues/67837

   (10) https://github.com/python/cpython/issues/115060

   (11) https://github.com/python/cpython/issues/97928

   (12) https://github.com/python/cpython/issues/114628

   (13) https://github.com/python/cpython/issues/85984

   (14) https://github.com/python/cpython/issues/114965

   (15) https://github.com/python/cpython/issues/114959

   (16) https://github.com/python/cpython/issues/114894

   (17) https://github.com/python/cpython/issues/114071

   (18) https://github.com/python/cpython/issues/109475

   (19) https://github.com/python/cpython/issues/49766

   (20) https://github.com/python/cpython/issues/110190

   (21) https://github.com/python/cpython/issues/114678

   (22) https://github.com/python/cpython/issues/70303

   (23) https://github.com/python/cpython/issues/109653

   (24) https://github.com/python/cpython/issues/113280

   (25) https://github.com/python/cpython/issues/77749

   (26) https://github.com/python/cpython/issues/83383

   (27) https://github.com/python/cpython/issues/91602

   (28) https://github.com/python/cpython/issues/112451

   (29) https://github.com/python/cpython/issues/69893

   (30) https://github.com/python/cpython/issues/109653

   (31) https://github.com/python/cpython/issues/114492

   (32) https://github.com/python/cpython/issues/114315

   (33) https://github.com/python/cpython/issues/100414

   (34) https://github.com/python/cpython/issues/113267

   (35) https://github.com/python/cpython/issues/106584

   (36) https://github.com/python/cpython/issues/75128

   (37) https://github.com/python/cpython/issues/114423

   (38) https://github.com/python/cpython/issues/114257

   (39) https://github.com/python/cpython/issues/114321

   (40) https://github.com/python/cpython/issues/114328

   (41) https://github.com/python/cpython/issues/114281

   (42) https://github.com/python/typeshed

   (43) https://github.com/python/cpython/issues/101438

   (44) https://github.com/python/cpython/issues/114198

   (45) https://github.com/python/cpython/issues/104522

   (46) https://github.com/python/cpython/issues/114149

   (47) https://github.com/python/cpython/issues/83648

   (48) https://github.com/python/cpython/issues/114087

   (49) https://github.com/python/cpython/issues/109534

   (50) https://github.com/python/cpython/issues/79634

   (51) https://github.com/python/cpython/issues/112202

   (52) https://github.com/python/cpython/issues/113951

   (53) https://github.com/python/cpython/issues/97959

   (54) https://github.com/python/cpython/issues/113796

   (55) https://github.com/python/cpython/issues/113732

   (56) https://github.com/python/cpython/issues/113225

   (57) https://github.com/python/cpython/issues/89039

   (58) https://github.com/python/cpython/issues/112919

   (59) https://github.com/python/cpython/issues/59013

   (60) https://github.com/python/cpython/issues/112343

   (61) https://github.com/python/cpython/issues/112240

   (62) https://github.com/python/cpython/issues/111741

   (63) https://github.com/python/cpython/issues/43457

   (64) https://github.com/python/cpython/issues/82626

   (65) https://github.com/python/cpython/issues/111051

   (66) https://github.com/python/cpython/issues/110345

   (67) https://github.com/python/cpython/issues/38807

   (68) https://github.com/python/cpython/issues/75705

   (69) https://github.com/python/cpython/issues/106233

   (70) https://github.com/python/cpython/issues/105102

   (71) https://github.com/python/cpython/issues/104282

   (72) https://github.com/python/cpython/issues/96471

   (73) https://github.com/python/cpython/issues/101599

   (74) https://github.com/python/cpython/issues/85984

   (75) https://github.com/python/cpython/issues/102512

   (76) https://github.com/python/cpython/issues/88569

   (77) https://bugs.python.org/issue?@action=redirect&bpo=38364


File: python.info,  Node: Documentation<7>,  Next: Tests<9>,  Prev: Library<11>,  Up: Python 3 13 0 alpha 4

1.23.12.4 Documentation
.......................

   - gh-115233(1): Fix an example for *note LoggerAdapter: 12c3. in the
     Logging Cookbook.

   - gh-114123(2): Move the *note csv: 21. module docstring to the ‘csv’
     module instead of reexporting it from the internal ‘_csv’ module,
     and remove ‘__doc__’ from ‘csv.__all__’.

     Move ‘csv.__version__’ to the ‘csv’ module instead of reexporting
     it from the internal ‘_csv’ module, and remove ‘__version__’ from
     ‘csv.__all__’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115233

   (2) https://github.com/python/cpython/issues/114123


File: python.info,  Node: Tests<9>,  Next: Build<11>,  Prev: Documentation<7>,  Up: Python 3 13 0 alpha 4

1.23.12.5 Tests
...............

   - gh-114099(1): Added test exclusions required to run the test suite
     on iOS.

   - gh-105089(2): Fix
     ‘test.test_zipfile.test_core.TestWithDirectory.test_create_directory_with_write’
     test in AIX by doing a bitwise AND of 0xFFFF on mode , so that it
     will be in sync with ‘zinfo.external_attr’

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/114099

   (2) https://github.com/python/cpython/issues/105089


File: python.info,  Node: Build<11>,  Next: Windows<8>,  Prev: Tests<9>,  Up: Python 3 13 0 alpha 4

1.23.12.6 Build
...............

   - gh-115167(1): Avoid vendoring ‘vcruntime140_threads.dll’ when
     building with Visual Studio 2022 version 17.8.

   - gh-113632(2): Promote WASI to a tier 2 platform and drop Emscripten
     from tier 3 in configure.ac.

   - gh-114099(3): configure and Makefile were refactored to accommodate
     framework builds on Apple platforms other than macOS.

   - gh-114875(4): Add ‘getgrent()’ as a prerequisite for building the
     *note grp: 5c. module.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115167

   (2) https://github.com/python/cpython/issues/113632

   (3) https://github.com/python/cpython/issues/114099

   (4) https://github.com/python/cpython/issues/114875


File: python.info,  Node: Windows<8>,  Next: macOS<6>,  Prev: Build<11>,  Up: Python 3 13 0 alpha 4

1.23.12.7 Windows
.................

   - gh-115049(1): Fixes ‘py.exe’ launcher failing when run as users
     without user profiles.

   - gh-115009(2): Update Windows installer to use SQLite 3.45.1.

   - gh-109991(3): Update Windows build to use OpenSSL 3.0.13.

   - gh-111239(4): Update Windows builds to use zlib v1.3.1.

   - gh-100107(5): The ‘py.exe’ launcher will no longer attempt to run
     the Microsoft Store redirector when launching a script containing a
     ‘/usr/bin/env’ shebang

   - gh-112984(6): Adds free-threaded binaries to Windows installer as
     an optional component.

   - gh-89240(7): Allows *note multiprocessing: 86. to create pools of
     greater than 62 processes.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115049

   (2) https://github.com/python/cpython/issues/115009

   (3) https://github.com/python/cpython/issues/109991

   (4) https://github.com/python/cpython/issues/111239

   (5) https://github.com/python/cpython/issues/100107

   (6) https://github.com/python/cpython/issues/112984

   (7) https://github.com/python/cpython/issues/89240


File: python.info,  Node: macOS<6>,  Next: IDLE<10>,  Prev: Windows<8>,  Up: Python 3 13 0 alpha 4

1.23.12.8 macOS
...............

   - gh-115009(1): Update macOS installer to use SQLite 3.45.1.

   - gh-109991(2): Update macOS installer to use OpenSSL 3.0.13.

   - gh-114490(3): Add Mach-O linkage support for *note
     platform.architecture(): 15ef.

   - gh-87804(4): On macOS the result of ‘os.statvfs’ and ‘os.fstatvfs’
     now correctly report the size of very large disks, in previous
     versions the reported number of blocks was wrong for disks with at
     least 2**32 blocks.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/115009

   (2) https://github.com/python/cpython/issues/109991

   (3) https://github.com/python/cpython/issues/114490

   (4) https://github.com/python/cpython/issues/87804


File: python.info,  Node: IDLE<10>,  Next: Tools/Demos<4>,  Prev: macOS<6>,  Up: Python 3 13 0 alpha 4

1.23.12.9 IDLE
..............

   - gh-96905(1): In idlelib code, stop redefining built-ins 'dict' and
     'object'.

   - gh-103820(2): Revise IDLE bindings so that events from mouse button
     4/5 on non-X11 windowing systems (i.e.  Win32 and Aqua) are not
     mistaken for scrolling.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/96905

   (2) https://github.com/python/cpython/issues/103820


File: python.info,  Node: Tools/Demos<4>,  Next: C API<11>,  Prev: IDLE<10>,  Up: Python 3 13 0 alpha 4

1.23.12.10 Tools/Demos
......................

   - gh-113516(1): Don't set ‘LDSHARED’ when building for WASI.

   - gh-109991(2): Update GitHub CI workflows to use OpenSSL 3.0.13 and
     multissltests to use 1.1.1w, 3.0.13, 3.1.5, and 3.2.1.

   - gh-115015(3): Fix a bug in Argument Clinic that generated incorrect
     code for methods with no parameters that use the *note METH_METHOD
     | METH_FASTCALL | METH_KEYWORDS: 15f2. calling convention.  Only
     the positional parameter count was checked; any keyword argument
     passed would be silently accepted.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/113516

   (2) https://github.com/python/cpython/issues/109991

   (3) https://github.com/python/cpython/issues/115015


File: python.info,  Node: C API<11>,  Prev: Tools/Demos<4>,  Up: Python 3 13 0 alpha 4

1.23.12.11 C API
................

   - gh-111140(1): Adds *note PyLong_AsNativeBytes(): 33a, *note
     PyLong_FromNativeBytes(): 33b. and *note
     PyLong_FromUnsignedNativeBytes(): 33c. functions.

   - gh-114685(2): *note PyBuffer_FillInfo(): 72b. now raises a *note
     SystemError: 541. if called with *note PyBUF_READ: 15f4. or *note
     PyBUF_WRITE: 15f5. as flags.  These flags should only be used with
     the ‘PyMemoryView_*’ C API.

   - gh-114685(3): *note PyObject_GetBuffer(): 373. now raises a *note
     SystemError: 541. if called with *note PyBUF_READ: 15f4. or *note
     PyBUF_WRITE: 15f5. as flags.  These flags should only be used with
     the ‘PyMemoryView_*’ C API.

   - gh-114626(4): Add ‘PyCFunctionFast’ and
     ‘PyCFunctionFastWithKeywords’ typedefs (identical to the existing
     ‘_PyCFunctionFast’ and ‘_PyCFunctionFastWithKeywords’ typedefs,
     just without a leading ‘_’ prefix).

   - gh-114329(5): Add *note PyList_GetItemRef(): 334, which is similar
     to *note PyList_GetItem(): 335. but returns a *note strong
     reference: 316. instead of a *note borrowed reference: 317.

   - gh-110850(6): Add PyTime C API:

        * *note PyTime_t: 306. type.

        * *note PyTime_MIN: 307. and *note PyTime_MAX: 308. constants.

        * *note PyTime_AsSecondsDouble(): 309, *note PyTime_Monotonic():
          30a, *note PyTime_PerfCounter(): 30c, and *note PyTime_Time():
          30e. functions.

     Patch by Victor Stinner.

   - gh-112066(7): Add *note PyDict_SetDefaultRef(): 318.: insert a key
     and value into a dictionary if the key is not already present.
     This is similar to *note dict.setdefault(): 104e, but returns an
     integer value indicating if the key was already present.  It is
     also similar to *note PyDict_SetDefault(): 319, but returns a
     strong reference instead of a borrowed reference.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111140

   (2) https://github.com/python/cpython/issues/114685

   (3) https://github.com/python/cpython/issues/114685

   (4) https://github.com/python/cpython/issues/114626

   (5) https://github.com/python/cpython/issues/114329

   (6) https://github.com/python/cpython/issues/110850

   (7) https://github.com/python/cpython/issues/112066


File: python.info,  Node: Python 3 13 0 alpha 3,  Next: Python 3 13 0 alpha 2,  Prev: Python 3 13 0 alpha 4,  Up: 変更履歴

1.23.13 Python 3.13.0 alpha 3
-----------------------------

'Release date: 2024-01-17'

* Menu:

* Security: Security<8>.
* Core and Builtins: Core and Builtins<13>.
* Library: Library<12>.
* Documentation: Documentation<8>.
* Tests: Tests<10>.
* Build: Build<12>.
* Windows: Windows<9>.
* macOS: macOS<7>.
* IDLE: IDLE<11>.
* C API: C API<12>.


File: python.info,  Node: Security<8>,  Next: Core and Builtins<13>,  Up: Python 3 13 0 alpha 3

1.23.13.1 Security
..................

   - gh-113659(1): Skip ‘.pth’ files with names starting with a dot or
     hidden file attribute.

   - gh-112302(2): Created a Software Bill-of-Materials document and
     tooling for tracking dependencies.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/113659

   (2) https://github.com/python/cpython/issues/112302


File: python.info,  Node: Core and Builtins<13>,  Next: Library<12>,  Prev: Security<8>,  Up: Python 3 13 0 alpha 3

1.23.13.2 Core and Builtins
...........................

   - gh-107901(1): Compiler duplicates basic blocks that have an eval
     breaker check, no line number, and multiple predecessors.

   - gh-107901(2): A jump leaving an exception handler back to normal
     code no longer checks the eval breaker.

   - gh-113655(3): Set the C recursion limit to 4000 on Windows, and
     10000 on Linux/OSX. This seems to be near the sweet spot to
     maintain safety, but not compromise backwards compatibility.

   - gh-113710(4): Add typed stack effects to the interpreter DSL, along
     with various instruction annotations.

   - gh-77046(5): On Windows, file descriptors wrapping Windows handles
     are now created non inheritable by default ( PEP 446(6)).  Patch by
     Zackery Spytz and Victor Stinner.

   - gh-113853(7): Guarantee that all executors make progress.  This
     then guarantees that tier 2 execution always makes progress.

   - gh-113753(8): Fix an issue where the finalizer of ‘PyAsyncGenASend’
     objects might not be called if they were allocated from a free
     list.

   - gh-107901(9): Compiler changed so that synthetic jumps which are
     not at loop end no longer check the eval breaker.

   - gh-113703(10): Fix a regression in the *note codeop: 15. module
     that was causing it to incorrectly identify incomplete f-strings.
     Patch by Pablo Galindo

   - gh-89811(11): Check for a valid ‘tp_version_tag’ before performing
     bytecode specializations that rely on this value being usable.

   - gh-111488(12): Changed error message in case of no 'in' keyword
     after 'for' in list comprehensions

   - gh-113657(13): Fix an issue that caused important instruction
     pointer updates to be optimized out of tier two traces.

   - gh-113603(14): Fixed bug where a redundant NOP is not removed,
     causing an assertion to fail in the compiler in debug mode.

   - gh-113602(15): Fix an error that was causing the parser to try to
     overwrite existing errors and crashing in the process.  Patch by
     Pablo Galindo

   - gh-113486(16): No longer issue spurious ‘PY_UNWIND’ events for
     optimized calls to classes.

   - gh-113297(17): Fix segfault in the compiler on with statement with
     19 context managers.

   - gh-113212(18): Improve *note super: 4a8. error messages.

   - gh-111375(19): Only use ‘NULL’ in the exception stack to indicate
     an exception was handled.  Patch by Carey Metcalfe.

   - gh-112215(20): Increase the C recursion limit by a factor of 3 for
     non-debug builds, except for webassembly and s390 platforms which
     are unchanged.  This mitigates some regressions in 3.12 with deep
     recursion mixing builtin (C) and Python code.

   - gh-113054(21): Fixed bug where a redundant NOP is not removed,
     causing an assertion to fail in the compiler in debug mode.

   - gh-106905(22): Use per AST-parser state rather than global state to
     track recursion depth within the AST parser to prevent potential
     race condition due to simultaneous parsing.

     The issue primarily showed up in 3.11 by multithreaded users of
     *note ast.parse(): 18d.  In 3.12 a change to when garbage
     collection can be triggered prevented the race condition from
     occurring.

   - gh-108866(23): Change the API and contract of ‘_PyExecutorObject’
     to return the next_instr pointer, instead of the frame, and to
     always execute at least one instruction.

   - gh-90350(24): Optimize builtin functions *note min(): ed3. and
     *note max(): ed4.

   - gh-112943(25): Correctly compute end column offsets for multiline
     tokens in the *note tokenize: e4. module.  Patch by Pablo Galindo

   - gh-112125(26): Fix ‘None.__ne__(None)’ returning ‘NotImplemented’
     instead of ‘False’.

   - gh-74616(27): *note input(): 12a6. now raises a ValueError when
     output on the terminal if the prompt contains embedded null
     characters instead of silently truncating it.

   - gh-112716(28): Fix SystemError in the ‘import’ statement and in
     ‘__reduce__()’ methods of builtin types when ‘__builtins__’ is not
     a dict.

   - gh-112730(29): Use color to highlight error locations in
     tracebacks.  Patch by Pablo Galindo

   - gh-112625(30): Fixes a bug where a bytearray object could be
     cleared while iterating over an argument in the ‘bytearray.join()’
     method that could result in reading memory after it was freed.

   - gh-112660(31): Do not clear unexpected errors during formatting
     error messages for ImportError and AttributeError for modules.

   - gh-105967(32): Workaround a bug in Apple's macOS platform zlib
     library where *note zlib.crc32(): 15f9. and *note binascii.crc32():
     15fa. could produce incorrect results on multi-gigabyte inputs.
     Including when using *note zipfile: 117. on zips containing large
     data.

   - gh-95754(33): Provide a better error message when accessing invalid
     attributes on partially initialized modules.  The origin of the
     module being accessed is now included in the message to help with
     the common issue of shadowing other modules.

   - gh-112217(34): Add check for the type of ‘__cause__’ returned from
     calling the type ‘T’ in ‘raise from T’.

   - gh-111058(35): Change coro.cr_frame/gen.gi_frame to return ‘None’
     after the coroutine/generator has been closed.  This fixes a bug
     where *note getcoroutinestate(): de6. and *note
     getgeneratorstate(): 1207. return the wrong state for a closed
     coroutine/generator.

   - gh-112388(36): Fix an error that was causing the parser to try to
     overwrite tokenizer errors.  Patch by pablo Galindo

   - gh-112387(37): Fix error positions for decoded strings with
     backwards tokenize errors.  Patch by Pablo Galindo

   - gh-99606(38): Make code generated for an empty f-string identical
     to the code of an empty normal string.

   - gh-112367(39): Avoid undefined behaviour when using the perf
     trampolines by not freeing the code arenas until shutdown.  Patch
     by Pablo Galindo

   - gh-112320(40): The Tier 2 translator now tracks the confidence
     level for staying "on trace" (i.e.  not exiting back to the Tier 1
     interpreter) for branch instructions based on the number of bits
     set in the branch "counter".  Trace translation ends when the
     confidence drops below 1/3rd.

   - gh-109598(41): *note PyComplex_RealAsDouble(): 15fb./*note
     PyComplex_ImagAsDouble(): 15fc. now tries to convert an object to a
     *note complex: 2cf. instance using its ‘__complex__()’ method
     before falling back to the ‘__float__()’ method.  Patch by Sergey B
     Kirpichev.

   - gh-94606(42): Fix UnicodeEncodeError when
     ‘email.message.get_payload()’ reads a message with a Unicode
     surrogate character and the message content is not well-formed for
     surrogateescape encoding.  Patch by Sidney Markowitz.

   - bpo-21861(43): Use the object's actual class name in
     ‘_io.FileIO.__repr__()’, ‘_io._WindowsConsoleIO()’ and
     ‘_io.TextIOWrapper.__repr__()’, to make these methods subclass
     friendly.

   - bpo-45369(44): Remove LibreSSL workarounds as per PEP 644(45).

   - bpo-34392(46): Added *note sys._is_interned(): 231.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/107901

   (2) https://github.com/python/cpython/issues/107901

   (3) https://github.com/python/cpython/issues/113655

   (4) https://github.com/python/cpython/issues/113710

   (5) https://github.com/python/cpython/issues/77046

   (6) https://peps.python.org/pep-0446/

   (7) https://github.com/python/cpython/issues/113853

   (8) https://github.com/python/cpython/issues/113753

   (9) https://github.com/python/cpython/issues/107901

   (10) https://github.com/python/cpython/issues/113703

   (11) https://github.com/python/cpython/issues/89811

   (12) https://github.com/python/cpython/issues/111488

   (13) https://github.com/python/cpython/issues/113657

   (14) https://github.com/python/cpython/issues/113603

   (15) https://github.com/python/cpython/issues/113602

   (16) https://github.com/python/cpython/issues/113486

   (17) https://github.com/python/cpython/issues/113297

   (18) https://github.com/python/cpython/issues/113212

   (19) https://github.com/python/cpython/issues/111375

   (20) https://github.com/python/cpython/issues/112215

   (21) https://github.com/python/cpython/issues/113054

   (22) https://github.com/python/cpython/issues/106905

   (23) https://github.com/python/cpython/issues/108866

   (24) https://github.com/python/cpython/issues/90350

   (25) https://github.com/python/cpython/issues/112943

   (26) https://github.com/python/cpython/issues/112125

   (27) https://github.com/python/cpython/issues/74616

   (28) https://github.com/python/cpython/issues/112716

   (29) https://github.com/python/cpython/issues/112730

   (30) https://github.com/python/cpython/issues/112625

   (31) https://github.com/python/cpython/issues/112660

   (32) https://github.com/python/cpython/issues/105967

   (33) https://github.com/python/cpython/issues/95754

   (34) https://github.com/python/cpython/issues/112217

   (35) https://github.com/python/cpython/issues/111058

   (36) https://github.com/python/cpython/issues/112388

   (37) https://github.com/python/cpython/issues/112387

   (38) https://github.com/python/cpython/issues/99606

   (39) https://github.com/python/cpython/issues/112367

   (40) https://github.com/python/cpython/issues/112320

   (41) https://github.com/python/cpython/issues/109598

   (42) https://github.com/python/cpython/issues/94606

   (43) https://bugs.python.org/issue?@action=redirect&bpo=21861

   (44) https://bugs.python.org/issue?@action=redirect&bpo=45369

   (45) https://peps.python.org/pep-0644/

   (46) https://bugs.python.org/issue?@action=redirect&bpo=34392


File: python.info,  Node: Library<12>,  Next: Documentation<8>,  Prev: Core and Builtins<13>,  Up: Python 3 13 0 alpha 3

1.23.13.3 Library
.................

   - gh-114077(1): Fix possible *note OverflowError: 84e. in *note
     socket.socket.sendfile(): e26. when pass 'count' larger than 2 GiB
     on 32-bit platform.

   - gh-111803(2): *note plistlib: 99. now supports loading more deeply
     nested lists in binary format.

   - gh-114014(3): Fixed a bug in *note fractions.Fraction: 1c8. where
     an invalid string using ‘d’ in the decimals part creates a
     different error compared to other invalid letters/characters.
     Patch by Jeremiah Gabriel Pascual.

   - gh-108364(4): *note sqlite3.Connection.iterdump(): 228. now ensures
     that foreign key support is disabled before dumping the database
     schema, if there is any foreign key violation.  Patch by Erlend E.
     Aasland and Mariusz Felisiak.

   - gh-113971(5): The *note zipfile.ZipInfo: cd8. previously protected
     ‘._compresslevel’ attribute has been made public as
     ‘.compress_level’ with the old ‘_compresslevel’ name remaining
     available as a property to retain compatibility.

   - gh-113877(6): Fix *note tkinter: d9. method ‘winfo_pathname()’ on
     64-bit Windows.

   - gh-113868(7): Added *note mmap.MAP_NORESERVE: 15fe, *note
     mmap.MAP_NOEXTEND: 15ff, *note mmap.MAP_HASSEMAPHORE: 1600, *note
     mmap.MAP_NOCACHE: 1601, *note mmap.MAP_JIT: 1602, *note
     mmap.MAP_RESILIENT_CODESIGN: 1603, *note mmap.MAP_RESILIENT_MEDIA:
     1604, *note mmap.MAP_32BIT: 1605, *note
     mmap.MAP_TRANSLATED_ALLOW_EXECUTE: 1606, *note mmap.MAP_UNIX03:
     1607. and *note mmap.MAP_TPRO: 1608.  All of them are ‘mmap(2)’
     flags on macOS.

   - gh-113848(8): *note asyncio.TaskGroup(): 19a. and *note
     asyncio.timeout(): 5c9. context managers now handle *note
     CancelledError: 19d. subclasses as well as exact ‘CancelledError’.

   - gh-113661(9): unittest runner: Don't exit 5 if tests were skipped.
     The intention of exiting 5 was to detect issues where the test
     suite wasn't discovered at all.  If we skipped tests, it was
     correctly discovered.

   - gh-96037(10): Insert *note TimeoutError: 800. in the context of the
     exception that was raised during exiting an expired *note
     asyncio.timeout(): 5c9. block.

   - gh-113781(11): Silence unraisable AttributeError when warnings are
     emitted during Python finalization.

   - gh-113238(12): Add ‘Anchor’ to ‘importlib.resources’ (in order for
     the code to comply with the documentation)

   - gh-111693(13): *note asyncio.Condition.wait(): 1609. now re-raises
     the same ‘CancelledError’ instance that may have caused it to be
     interrupted.  Fixed race condition in *note
     asyncio.Semaphore.acquire(): 160a. when interrupted with a
     ‘CancelledError’.

   - gh-113791(14): Add ‘CLOCK_MONOTONIC_RAW_APPROX’ and
     ‘CLOCK_UPTIME_RAW_APPROX’ to *note time: d7. on macOS. These are
     clocks available on macOS 10.12 or later.

   - gh-112932(15): Restore the ability for *note zipfile: 117. to
     ‘extractall’ from zip files with a "/" directory entry in them as
     is commonly added to zips by some wiki or bug tracker data
     exporters.

   - gh-113568(16): Raise deprecation warnings from *note
     pathlib.PurePath: 473. and not its private base class
     ‘PurePathBase’.

   - gh-113594(17): Fix *note UnicodeEncodeError: 643. in *note email:
     32. when re-fold lines that contain unknown-8bit encoded part
     followed by non-unknown-8bit encoded part.

   - gh-113538(18): In ‘asyncio.StreamReaderProtocol.connection_made()’,
     there is callback that logs an error if the task wrapping the
     "connected callback" fails.  This callback would itself fail if the
     task was cancelled.  Prevent this by checking whether the task was
     cancelled first.  If so, close the transport but don't log an
     error.

   - gh-113626(19): Add support for the 'allow_code' argument in the
     *note marshal: 80. module.  Passing ‘allow_code=False’ prevents
     serialization and de-serialization of code objects which is
     incompatible between Python versions.

   - gh-85567(20): Fix resource warnings for unclosed files in *note
     pickle: 95. and *note pickletools: 96. command line interfaces.

   - gh-113537(21): Support loads ‘str’ in *note plistlib.loads(): 91e.

   - gh-89850(22): Add default implementations of *note
     pickle.Pickler.persistent_id(): 1506. and *note
     pickle.Unpickler.persistent_load(): 150c. methods in the C
     implementation.  Calling ‘super().persistent_id()’ and
     ‘super().persistent_load()’ in subclasses of the C implementation
     of *note pickle.Pickler: 9ec. and *note pickle.Unpickler: 160b.
     classes no longer causes infinite recursion.

   - gh-113569(23): Indicate if there were no actual calls in unittest
     *note assert_has_calls(): 160c. failure.

   - gh-101225(24): Increase the backlog for *note
     multiprocessing.connection.Listener: 160d. objects created by
     ‘multiprocessing.manager’ and ‘multiprocessing.resource_sharer’ to
     significantly reduce the risk of getting a connection refused error
     when creating a *note multiprocessing.connection.Connection: 160e.
     to them.

   - gh-113568(25): Raise audit events from *note pathlib.Path: 20a. and
     not its private base class ‘PathBase’.

   - gh-113543(26): Make sure that ‘webbrowser.MacOSXOSAScript’ sends
     ‘webbrowser.open’ audit event.

   - gh-113028(27): When a second reference to a string appears in the
     input to *note pickle: 95, and the Python implementation is in use,
     we are guaranteed that a single copy gets pickled and a single
     object is shared when reloaded.  Previously, in protocol 0, when a
     string contained certain characters (e.g.  newline) it resulted in
     duplicate objects.

   - gh-113421(28): Fix multiprocessing logger for ‘%(filename)s’.

   - gh-111784(29): Fix segfaults in the ‘_elementtree’ module.  Fix
     first segfault during deallocation of ‘_elementtree.XMLParser’
     instances by keeping strong reference to ‘pyexpat’ module in module
     state for capsule lifetime.  Fix second segfault which happens in
     the same deallocation process by keeping strong reference to
     ‘_elementtree’ module in ‘XMLParser’ structure for ‘_elementtree’
     module lifetime.

   - gh-113407(30): Fix import of *note unittest.mock: f0. when CPython
     is built without docstrings.

   - gh-113320(31): Fix regression in Python 3.12 where *note Protocol:
     245. classes that were not marked as *note runtime-checkable: 40f.
     would be unnecessarily introspected, potentially causing exceptions
     to be raised if the protocol had problematic members.  Patch by
     Alex Waygood.

   - gh-53502(32): Add a new option ‘aware_datetime’ in *note plistlib:
     99. to loads or dumps aware datetime.

   - gh-113358(33): Fix rendering tracebacks with exceptions with a
     broken __getattr__

   - gh-113214(34): Fix an ‘AttributeError’ during asyncio SSL protocol
     aborts in SSL-over-SSL scenarios.

   - gh-113246(35): Update bundled pip to 23.3.2.

   - gh-87264(36): Fixed tarfile list() method to show file type.

   - gh-112182(37): ‘asyncio.futures.Future.set_exception()’ now
     transforms *note StopIteration: bc8. into *note RuntimeError: 17a.
     instead of hanging or other misbehavior.  Patch contributed by
     Jamie Phan.

   - gh-113225(38): Speed up *note pathlib.Path.glob(): 20e. by using
     *note os.DirEntry.path: 15e0. where possible.

   - gh-113149(39): Improve error message when a JSON array or object
     contains a trailing comma.  Patch by Carson Radtke.

   - gh-113117(40): The *note subprocess: c1. module can now use the
     *note os.posix_spawn(): 201. function with ‘close_fds=True’ on
     platforms where ‘posix_spawn_file_actions_addclosefrom_np’ is
     available.  Patch by Jakub Kulik.

   - gh-113199(41): Make ‘http.client.HTTPResponse.read1’ and
     ‘http.client.HTTPResponse.readline’ close IO after reading all data
     when content length is known.  Patch by Illia Volochii.

   - gh-113191(42): Add support of *note os.fchmod(): 1fd. and a file
     descriptor in *note os.chmod(): 1fc. on Windows.

   - gh-113188(43): Fix *note shutil.copymode(): 160f. and *note
     shutil.copystat(): 1101. on Windows.  Previously they worked
     differently if 'dst' is a symbolic link: they modified the
     permission bits of 'dst' itself rather than the file it points to
     if 'follow_symlinks' is true or 'src' is not a symbolic link, and
     did not modify the permission bits if 'follow_symlinks' is false
     and 'src' is a symbolic link.

   - gh-113119(44): *note os.posix_spawn(): 201. now accepts ‘env=None’,
     which makes the newly spawned process use the current process
     environment.  Patch by Jakub Kulik.

   - gh-113202(45): Add a ‘strict’ option to ‘batched()’ in the
     ‘itertools’ module.

   - gh-61648(46): Detect line numbers of properties in doctests.

   - gh-113175(47): Sync with importlib_metadata 7.0, including improved
     type annotations, fixed issue with symlinked packages in
     ‘package_distributions’, added ‘EntryPoints.__repr__’, introduced
     the ‘diagnose’ script, added ‘Distribution.origin’ property, and
     removed deprecated ‘EntryPoint’ access by numeric index (tuple
     behavior).

   - gh-59616(48): Add support of *note os.lchmod(): 1fb. and the
     'follow_symlinks' argument in *note os.chmod(): 1fc. on Windows.
     Note that the default value of 'follow_symlinks' in ‘os.lchmod()’
     is ‘False’ on Windows.

   - gh-112559(49): *note signal.signal(): 1107. and *note
     signal.getsignal(): 1610. no longer call ‘repr’ on callable
     handlers.  *note asyncio.run(): 449. and *note
     asyncio.Runner.run(): 1611. no longer call ‘repr’ on the task
     results.  Patch by Yilei Yang.

   - gh-112962(50): *note dis: 30. module functions add cache
     information to the *note Instruction: 1be. instance rather than
     creating fake *note Instruction: 1be. instances to represent the
     cache entries.

   - gh-112989(51): Reduce overhead to connect sockets with *note
     asyncio: 8. SelectorEventLoop.

   - gh-112970(52): Use ‘closefrom()’ on Linux where available (e.g.
     glibc-2.34), rather than only FreeBSD.

   - gh-110190(53): Fix ctypes structs with array on PPC64LE platform by
     setting ‘MAX_STRUCT_SIZE’ to 64 in stgdict.  Patch by Diego Russo.

   - gh-112540(54): The statistics.geometric_mean() function now returns
     zero for datasets containing a zero.  Formerly, it would raise an
     exception.

   - gh-87286(55): Added ‘LOG_FTP’, ‘LOG_NETINFO’, ‘LOG_REMOTEAUTH’,
     ‘LOG_INSTALL’, ‘LOG_RAS’, and ‘LOG_LAUNCHD’ tot the *note syslog:
     c6. module, all of them constants on used on macOS.

   - gh-112800(56): Fix *note asyncio: 8. ‘SubprocessTransport.close()’
     not to throw ‘PermissionError’ when used with setuid executables.

   - gh-51944(57): Add the following constants to the *note termios: ca.
     module.  These values are present in macOS system headers:
     ‘ALTWERASE’, ‘B14400’, ‘B28800’, ‘B7200’, ‘B76800’, ‘CCAR_OFLOW’,
     ‘CCTS_OFLOW’, ‘CDSR_OFLOW’, ‘CDTR_IFLOW’, ‘CIGNORE’, ‘CRTS_IFLOW’,
     ‘EXTPROC’, ‘IUTF8’, ‘MDMBUF’, ‘NL2’, ‘NL3’, ‘NOKERNINFO’, ‘ONOEOT’,
     ‘OXTABS’, ‘VDSUSP’, ‘VSTATUS’.

   - gh-79325(58): Fix an infinite recursion error in *note
     tempfile.TemporaryDirectory(): 1205. cleanup on Windows.

   - gh-94692(59): *note shutil.rmtree(): 2d8. now only catches OSError
     exceptions.  Previously a symlink attack resistant version of
     ‘shutil.rmtree()’ could ignore or pass to the error handler
     arbitrary exception when invalid arguments were provided.

   - gh-112736(60): The use of del-safe symbols in ‘subprocess’ was
     refactored to allow for use in cross-platform build environments.

   - gh-112727(61): Speed up *note pathlib.Path.absolute(): 1612.  Patch
     by Barney Gale.

   - gh-74690(62): Speedup *note issubclass(): 78c. checks against
     simple *note runtime-checkable protocols: 40f. by around 6%.  Patch
     by Alex Waygood.

   - gh-74690(63): Speedup *note isinstance(): 40e. checks by roughly
     20% for *note runtime-checkable protocols: 40f. that only have one
     callable member.  Speedup *note issubclass(): 78c. checks for these
     protocols by roughly 10%.  Patch by Alex Waygood.

   - gh-112645(64): Remove deprecation error on passing ‘onerror’ to
     *note shutil.rmtree(): 2d8.

   - gh-112640(65): Add ‘kwdefaults’ parameter to *note
     types.FunctionType: 850. to set default keyword argument values.

   - gh-112622(66): Ensure ‘name’ parameter is passed to event loop in
     *note asyncio.create_task(): 5c7.

   - gh-112618(67): Fix a caching bug relating to *note
     typing.Annotated: 90b.  ‘Annotated[str, True]’ is no longer
     identical to ‘Annotated[str, 1]’.

   - gh-112334(68): Fixed a performance regression in 3.12's *note
     subprocess: c1. on Linux where it would no longer use the fast-path
     ‘vfork()’ system call when it could have due to a logic bug,
     instead falling back to the safe but slower ‘fork()’.

     Also fixed a second 3.12.0 potential security bug.  If a value of
     ‘extra_groups=[]’ was passed to *note subprocess.Popen: 17e. or
     related APIs, the underlying ‘setgroups(0, NULL)’ system call to
     clear the groups list would not be made in the child process prior
     to ‘exec()’.

     This was identified via code inspection in the process of fixing
     the first bug.

   - gh-110190(69): Fix ctypes structs with array on Arm platform by
     setting ‘MAX_STRUCT_SIZE’ to 32 in stgdict.  Patch by Diego Russo.

   - gh-81194(70): Fix a crash in *note socket.if_indextoname(): 9fd.
     with specific value (UINT_MAX). Fix an integer overflow in *note
     socket.if_indextoname(): 9fd. on 64-bit non-Windows platforms.

   - gh-112578(71): Fix a spurious *note RuntimeWarning: 1a2. when
     executing the *note zipfile: 117. module.

   - gh-112516(72): Update the bundled copy of pip to version 23.3.1.

   - gh-112510(73): Add *note readline.backend: 1613. for the backend
     readline uses (‘editline’ or ‘readline’)

   - gh-112328(74): [Enum] Make ‘EnumDict’, ‘EnumDict.member_names’,
     ‘EnumType._add_alias_’ and ‘EnumType._add_value_alias_’ public.

   - gh-112509(75): Fix edge cases that could cause a key to be present
     in both the ‘__required_keys__’ and ‘__optional_keys__’ attributes
     of a *note typing.TypedDict: 148.  Patch by Jelle Zijlstra.

   - gh-101336(76): Add ‘keep_alive’ keyword parameter for
     ‘AbstractEventLoop.create_server()’ and
     ‘BaseEventLoop.create_server()’.

   - gh-63284(77): Added support for TLS-PSK (pre-shared key) mode to
     the *note ssl: bb. module.

   - gh-112414(78): Fix regression in Python 3.12 where calling *note
     repr(): 7c8. on a module that had been imported using a custom
     *note loader: 1614. could fail with *note AttributeError: 326.
     Patch by Alex Waygood.

   - gh-112358(79): Revert change to *note struct.Struct: 1615.
     initialization that broke some cases of subclassing.

   - gh-112405(80): Optimize *note pathlib.PurePath.relative_to(): 2ab.
     Patch by Alex Waygood.

   - gh-94722(81): Fix bug where comparison between instances of *note
     DocTest: 1616. fails if one of them has ‘None’ as its lineno.

   - gh-112361(82): Speed up a small handful of *note pathlib: 93.
     methods by removing some temporary objects.

   - gh-112345(83): Improve error message when trying to call *note
     issubclass(): 78c. against a *note typing.Protocol: 245. that has
     non-method members.  Patch by Randolf Scholz.

   - gh-112137(84): Change *note dis: 30. output to display no-lineno as
     "-" instead of "None".

   - gh-112332(85): Deprecate the ‘exc_type’ field of *note
     traceback.TracebackException: 23d.  Add ‘exc_type_str’ to replace
     it.

   - gh-81620(86): Add extra tests for *note random.binomialvariate():
     47c.

   - gh-112292(87): Fix a crash in *note readline: a8. when imported
     from a sub interpreter.  Patch by Anthony Shaw

   - gh-77621(88): Slightly improve the import time of the *note
     pathlib: 93. module by deferring some imports.  Patch by Barney
     Gale.

   - gh-112137(89): Change *note dis: 30. output to display logical
     labels for jump targets instead of offsets.

   - gh-112139(90): Add ‘Signature.format()’ to format signatures to
     string with extra options.  And use it in *note pydoc: a3. to
     render more readable signatures that have new lines between
     parameters.

   - gh-112105(91): Make *note readline.set_completer_delims(): 1617.
     work with libedit

   - gh-106922(92): Display multiple lines with ‘traceback’ when errors
     span multiple lines.

   - gh-111874(93): When creating a *note typing.NamedTuple: 290. class,
     ensure *note __set_name__(): c1c. is called on all objects that
     define ‘__set_name__’ and exist in the values of the ‘NamedTuple’
     class's class dictionary.  Patch by Alex Waygood.

   - gh-68166(94): Add support of the "vsapi" element type in *note
     tkinter.ttk.Style.element_create(): 239.

   - gh-110275(95): Named tuple's methods ‘_replace()’ and
     ‘__replace__()’ now raise TypeError instead of ValueError for
     invalid keyword arguments.

   - gh-99367(96): Do not mangle ‘sys.path[0]’ in *note pdb: 94. if
     safe_path is set

   - gh-111615(97): Fix a regression caused by a fix to gh-93162(98)
     whereby you couldn't configure a ‘QueueHandler’ without specifying
     handlers.

   - gh-75666(99): Fix the behavior of *note tkinter: d9. widget's
     ‘unbind()’ method with two arguments.  Previously,
     ‘widget.unbind(sequence, funcid)’ destroyed the current binding for
     'sequence', leaving 'sequence' unbound, and deleted the 'funcid'
     command.  Now it removes only 'funcid' from the binding for
     'sequence', keeping other commands, and deletes the 'funcid'
     command.  It leaves 'sequence' unbound only if 'funcid' was the
     last bound command.

   - gh-67790(100): Implement basic formatting support (minimum width,
     alignment, fill) for *note fractions.Fraction: 1c8.

   - gh-111049(101): Fix crash during garbage collection of the *note
     io.BytesIO: e6d. buffer object.

   - gh-102980(102): Redirect the output of ‘interact’ command of *note
     pdb: 94. to the same channel as the debugger.  Add tests and
     improve docs.

   - gh-102988(103): *note email.utils.getaddresses(): 1c5. and *note
     email.utils.parseaddr(): 1c6. now return ‘('', '')’ 2-tuples in
     more situations where invalid email addresses are encountered
     instead of potentially inaccurate values.  Add optional 'strict'
     parameter to these two functions: use ‘strict=False’ to get the old
     behavior, accept malformed inputs.  ‘getattr(email.utils,
     'supports_strict_parsing', False)’ can be use to check if the
     'strict' parameter is available.  Patch by Thomas Dwyer and Victor
     Stinner to improve the CVE 2023-27043(104) fix.

   - gh-52161(105): *note cmd.Cmd.do_help(): 1618. now cleans docstrings
     with *note inspect.cleandoc(): 1619. before writing them.  Patch by
     Filip Łapkiewicz.

   - gh-82300(106): Add ‘track’ parameter to *note
     multiprocessing.shared_memory.SharedMemory: 15bd. that allows using
     shared memory blocks without having to register with the POSIX
     resource tracker that automatically releases them upon process
     exit.

   - gh-110109(107): Add private ‘pathlib._PurePathBase’ class: a base
     class for *note pathlib.PurePath: 473. that omits certain magic
     methods.  It may be made public (along with ‘_PathBase’) in future.

   - gh-109858(108): Protect *note zipfile: 117. from "quoted-overlap"
     zipbomb.  It now raises BadZipFile when try to read an entry that
     overlaps with other entry or central directory.

   - gh-109786(109): Fix possible reference leaks and crash when
     re-enter the ‘__next__()’ method of *note itertools.pairwise: 7e0.

   - gh-91539(110): Small (10 - 20%) and trivial performance improvement
     of ‘urllib.request.getproxies_environment()’, typically useful when
     there are many environment variables to go over.

   - gh-103363(111): Add 'follow_symlinks' keyword-only argument to
     *note pathlib.Path.owner(): 212. and *note group(): 213, defaulting
     to ‘True’.

   - gh-102130(112): Support tab completion in *note cmd: 12. for
     ‘editline’.

   - gh-99437(113): *note runpy.run_path(): 166. now decodes path-like
     objects, making sure __file__ and sys.argv[0] of the module being
     run are always strings.

   - gh-104003(114): Add *note warnings.deprecated(): 146, a decorator
     to mark deprecated functions to static type checkers and to warn on
     usage of deprecated classes and functions.  See PEP 702(115).
     Patch by Jelle Zijlstra.

   - gh-103708(116): Make hardcoded python name, a configurable
     parameter so that different implementations of python can override
     it instead of making huge diffs in sysconfig.py

   - gh-66515(117): *note mailbox.MH: 161a. now supports folders that do
     not contain a ‘.mh_sequences’ file (e.g.  Claws Mail IMAP-cache
     folders).  Patch by Serhiy Storchaka.

   - gh-83162(118): Renamed ‘re.error’ to ‘PatternError’ for clarity,
     and kept ‘re.error’ for backward compatibility.  Patch by Matthias
     Bussonnier and Adam Chhina.

   - gh-91133(119): Fix a bug in *note tempfile.TemporaryDirectory:
     1205. cleanup, which now no longer dereferences symlinks when
     working around file system permission errors.

   - bpo-43153(120): On Windows, ‘tempfile.TemporaryDirectory’
     previously masked a ‘PermissionError’ with ‘NotADirectoryError’
     during directory cleanup.  It now correctly raises
     ‘PermissionError’ if errors are not ignored.  Patch by Andrei
     Kulakov and Ken Jin.

   - bpo-32731(121): *note getpass.getuser(): 3f1. now raises *note
     OSError: 3f0. for all failures rather than *note ImportError: 3f2.
     on systems lacking the *note pwd: a0. module or *note KeyError:
     31d. if the password database is empty.

   - bpo-34321(122): *note mmap.mmap: 1ec. now has a 'trackfd' parameter
     on Unix; if it is ‘False’, the file descriptor specified by
     'fileno' will not be duplicated.

   - bpo-35332(123): The *note shutil.rmtree(): 2d8. function now
     ignores errors when calling *note os.close(): b42. when
     'ignore_errors' is ‘True’, and *note os.close(): b42. no longer
     retried after error.

   - bpo-35928(124): *note io.TextIOWrapper: 786. now correctly handles
     the decoding buffer after ‘read()’ and ‘write()’.

   - bpo-26791(125): *note shutil.move(): a2a. now moves a symlink into
     a directory when that directory is the target of the symlink.  This
     provides the same behavior as the mv shell command.  The previous
     behavior raised an exception.  Patch by Jeffrey Kintscher.

   - bpo-41422(126): Fixed memory leaks of *note pickle.Pickler: 9ec.
     and *note pickle.Unpickler: 160b. involving cyclic references via
     the internal memo mapping.

   - bpo-19821(127): The ‘pydoc.ispackage()’ function has been
     deprecated.

   - bpo-40262(128): The ‘ssl.SSLSocket.recv_into()’ method no longer
     requires the 'buffer' argument to implement ‘__len__’ and supports
     buffers with arbitrary item size.

   - bpo-39912(129): *note warnings.filterwarnings(): 144e. and *note
     warnings.simplefilter(): 68d. now raise appropriate exceptions
     instead of ‘AssertionError’.  Patch contributed by Rémi Lapeyre.

   - bpo-37260(130): Fixed a race condition in *note shutil.rmtree():
     2d8. in which directory entries removed by another process or
     thread while ‘shutil.rmtree()’ is running can cause it to raise
     FileNotFoundError.  Patch by Jeffrey Kintscher.

   - bpo-36959(131): Fix some error messages for invalid ISO format
     string combinations in ‘strptime()’ that referred to directives not
     contained in the format string.  Patch by Gordon P. Hemsley.

   - bpo-18060(132): Fixed a class inheritance issue that can cause
     segfaults when deriving two or more levels of subclasses from a
     base class of Structure or Union.

   - bpo-29779(133): Add a new *note PYTHON_HISTORY: 176. environment
     variable to set the location of a ‘.python_history’ file.

   - bpo-21360(134): *note mailbox.Maildir: 3f5. now ignores files with
     a leading dot.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/114077

   (2) https://github.com/python/cpython/issues/111803

   (3) https://github.com/python/cpython/issues/114014

   (4) https://github.com/python/cpython/issues/108364

   (5) https://github.com/python/cpython/issues/113971

   (6) https://github.com/python/cpython/issues/113877

   (7) https://github.com/python/cpython/issues/113868

   (8) https://github.com/python/cpython/issues/113848

   (9) https://github.com/python/cpython/issues/113661

   (10) https://github.com/python/cpython/issues/96037

   (11) https://github.com/python/cpython/issues/113781

   (12) https://github.com/python/cpython/issues/113238

   (13) https://github.com/python/cpython/issues/111693

   (14) https://github.com/python/cpython/issues/113791

   (15) https://github.com/python/cpython/issues/112932

   (16) https://github.com/python/cpython/issues/113568

   (17) https://github.com/python/cpython/issues/113594

   (18) https://github.com/python/cpython/issues/113538

   (19) https://github.com/python/cpython/issues/113626

   (20) https://github.com/python/cpython/issues/85567

   (21) https://github.com/python/cpython/issues/113537

   (22) https://github.com/python/cpython/issues/89850

   (23) https://github.com/python/cpython/issues/113569

   (24) https://github.com/python/cpython/issues/101225

   (25) https://github.com/python/cpython/issues/113568

   (26) https://github.com/python/cpython/issues/113543

   (27) https://github.com/python/cpython/issues/113028

   (28) https://github.com/python/cpython/issues/113421

   (29) https://github.com/python/cpython/issues/111784

   (30) https://github.com/python/cpython/issues/113407

   (31) https://github.com/python/cpython/issues/113320

   (32) https://github.com/python/cpython/issues/53502

   (33) https://github.com/python/cpython/issues/113358

   (34) https://github.com/python/cpython/issues/113214

   (35) https://github.com/python/cpython/issues/113246

   (36) https://github.com/python/cpython/issues/87264

   (37) https://github.com/python/cpython/issues/112182

   (38) https://github.com/python/cpython/issues/113225

   (39) https://github.com/python/cpython/issues/113149

   (40) https://github.com/python/cpython/issues/113117

   (41) https://github.com/python/cpython/issues/113199

   (42) https://github.com/python/cpython/issues/113191

   (43) https://github.com/python/cpython/issues/113188

   (44) https://github.com/python/cpython/issues/113119

   (45) https://github.com/python/cpython/issues/113202

   (46) https://github.com/python/cpython/issues/61648

   (47) https://github.com/python/cpython/issues/113175

   (48) https://github.com/python/cpython/issues/59616

   (49) https://github.com/python/cpython/issues/112559

   (50) https://github.com/python/cpython/issues/112962

   (51) https://github.com/python/cpython/issues/112989

   (52) https://github.com/python/cpython/issues/112970

   (53) https://github.com/python/cpython/issues/110190

   (54) https://github.com/python/cpython/issues/112540

   (55) https://github.com/python/cpython/issues/87286

   (56) https://github.com/python/cpython/issues/112800

   (57) https://github.com/python/cpython/issues/51944

   (58) https://github.com/python/cpython/issues/79325

   (59) https://github.com/python/cpython/issues/94692

   (60) https://github.com/python/cpython/issues/112736

   (61) https://github.com/python/cpython/issues/112727

   (62) https://github.com/python/cpython/issues/74690

   (63) https://github.com/python/cpython/issues/74690

   (64) https://github.com/python/cpython/issues/112645

   (65) https://github.com/python/cpython/issues/112640

   (66) https://github.com/python/cpython/issues/112622

   (67) https://github.com/python/cpython/issues/112618

   (68) https://github.com/python/cpython/issues/112334

   (69) https://github.com/python/cpython/issues/110190

   (70) https://github.com/python/cpython/issues/81194

   (71) https://github.com/python/cpython/issues/112578

   (72) https://github.com/python/cpython/issues/112516

   (73) https://github.com/python/cpython/issues/112510

   (74) https://github.com/python/cpython/issues/112328

   (75) https://github.com/python/cpython/issues/112509

   (76) https://github.com/python/cpython/issues/101336

   (77) https://github.com/python/cpython/issues/63284

   (78) https://github.com/python/cpython/issues/112414

   (79) https://github.com/python/cpython/issues/112358

   (80) https://github.com/python/cpython/issues/112405

   (81) https://github.com/python/cpython/issues/94722

   (82) https://github.com/python/cpython/issues/112361

   (83) https://github.com/python/cpython/issues/112345

   (84) https://github.com/python/cpython/issues/112137

   (85) https://github.com/python/cpython/issues/112332

   (86) https://github.com/python/cpython/issues/81620

   (87) https://github.com/python/cpython/issues/112292

   (88) https://github.com/python/cpython/issues/77621

   (89) https://github.com/python/cpython/issues/112137

   (90) https://github.com/python/cpython/issues/112139

   (91) https://github.com/python/cpython/issues/112105

   (92) https://github.com/python/cpython/issues/106922

   (93) https://github.com/python/cpython/issues/111874

   (94) https://github.com/python/cpython/issues/68166

   (95) https://github.com/python/cpython/issues/110275

   (96) https://github.com/python/cpython/issues/99367

   (97) https://github.com/python/cpython/issues/111615

   (98) https://github.com/python/cpython/issues/93162

   (99) https://github.com/python/cpython/issues/75666

   (100) https://github.com/python/cpython/issues/67790

   (101) https://github.com/python/cpython/issues/111049

   (102) https://github.com/python/cpython/issues/102980

   (103) https://github.com/python/cpython/issues/102988

   (104) https://www.cve.org/CVERecord?id=CVE-2023-27043

   (105) https://github.com/python/cpython/issues/52161

   (106) https://github.com/python/cpython/issues/82300

   (107) https://github.com/python/cpython/issues/110109

   (108) https://github.com/python/cpython/issues/109858

   (109) https://github.com/python/cpython/issues/109786

   (110) https://github.com/python/cpython/issues/91539

   (111) https://github.com/python/cpython/issues/103363

   (112) https://github.com/python/cpython/issues/102130

   (113) https://github.com/python/cpython/issues/99437

   (114) https://github.com/python/cpython/issues/104003

   (115) https://peps.python.org/pep-0702/

   (116) https://github.com/python/cpython/issues/103708

   (117) https://github.com/python/cpython/issues/66515

   (118) https://github.com/python/cpython/issues/83162

   (119) https://github.com/python/cpython/issues/91133

   (120) https://bugs.python.org/issue?@action=redirect&bpo=43153

   (121) https://bugs.python.org/issue?@action=redirect&bpo=32731

   (122) https://bugs.python.org/issue?@action=redirect&bpo=34321

   (123) https://bugs.python.org/issue?@action=redirect&bpo=35332

   (124) https://bugs.python.org/issue?@action=redirect&bpo=35928

   (125) https://bugs.python.org/issue?@action=redirect&bpo=26791

   (126) https://bugs.python.org/issue?@action=redirect&bpo=41422

   (127) https://bugs.python.org/issue?@action=redirect&bpo=19821

   (128) https://bugs.python.org/issue?@action=redirect&bpo=40262

   (129) https://bugs.python.org/issue?@action=redirect&bpo=39912

   (130) https://bugs.python.org/issue?@action=redirect&bpo=37260

   (131) https://bugs.python.org/issue?@action=redirect&bpo=36959

   (132) https://bugs.python.org/issue?@action=redirect&bpo=18060

   (133) https://bugs.python.org/issue?@action=redirect&bpo=29779

   (134) https://bugs.python.org/issue?@action=redirect&bpo=21360


File: python.info,  Node: Documentation<8>,  Next: Tests<10>,  Prev: Library<12>,  Up: Python 3 13 0 alpha 3

1.23.13.4 Documentation
.......................

   - gh-111699(1): Relocate ‘smtpd’ deprecation notice to its own
     section rather than under ‘locale’ in What's New in Python 3.12
     document

   - gh-110746(2): Improved markup for valid options/values for methods
     ttk.treeview.column and ttk.treeview.heading, and for Layouts.

   - gh-95649(3): Document that the *note asyncio: 8. module contains
     code taken from v0.16.0 of the uvloop project(4), as well as the
     required MIT licensing information.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111699

   (2) https://github.com/python/cpython/issues/110746

   (3) https://github.com/python/cpython/issues/95649

   (4) https://github.com/MagicStack/uvloop/tree/v0.16.0


File: python.info,  Node: Tests<10>,  Next: Build<12>,  Prev: Documentation<8>,  Up: Python 3 13 0 alpha 3

1.23.13.5 Tests
...............

   - gh-111798(1): Disable ‘test_super_deep()’ from ‘test_call’ under
     pydebug builds on WASI; the stack depth is too small to make the
     test useful.

   - gh-111801(2): Lower the recursion limit in ‘test_isinstance’ for
     ‘test_infinitely_many_bases()’.  This prevents a stack overflow on
     a pydebug build of WASI.

   - gh-111802(3): Specify a low recursion depth for
     ‘test_bad_getattr()’ in ‘test.pickletester’ to avoid exhausting the
     stack under a pydebug build for WASI.

   - gh-44626(4): Fix *note os.path.isabs(): 205. incorrectly returning
     ‘True’ when given a path that starts with exactly one (back)slash
     on Windows.

     Fix ‘pathlib.PureWindowsPath.is_absolute()’ incorrectly returning
     ‘False’ for some paths beginning with two (back)slashes.

   - gh-113633(5): Use module state for the _testcapi extension module.

   - gh-109980(6): Fix ‘test_tarfile_vs_tar’ in ‘test_shutil’ for macOS,
     where system tar can include more information in the archive than
     *note shutil.make_archive: 47f.

   - gh-112769(7): The tests now correctly compare zlib version when
     *note zlib.ZLIB_RUNTIME_VERSION: 1141. contains non-integer
     suffixes.  For example zlib-ng defines the version as
     ‘1.3.0.zlib-ng’.

   - gh-112334(8): Adds a regression test to verify that ‘vfork()’ is
     used when expected by *note subprocess: c1. on vfork enabled POSIX
     systems (Linux).

   - gh-108927(9): Fixed order dependence in running tests in the same
     process when a test that has submodules (e.g.  test_importlib)
     follows a test that imports its submodule (e.g.
     test_importlib.util) and precedes a test (e.g.  test_unittest or
     test_compileall) that uses that submodule.

   - bpo-40648(10): Test modes that file can get with chmod() on
     Windows.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111798

   (2) https://github.com/python/cpython/issues/111801

   (3) https://github.com/python/cpython/issues/111802

   (4) https://github.com/python/cpython/issues/44626

   (5) https://github.com/python/cpython/issues/113633

   (6) https://github.com/python/cpython/issues/109980

   (7) https://github.com/python/cpython/issues/112769

   (8) https://github.com/python/cpython/issues/112334

   (9) https://github.com/python/cpython/issues/108927

   (10) https://bugs.python.org/issue?@action=redirect&bpo=40648


File: python.info,  Node: Build<12>,  Next: Windows<9>,  Prev: Tests<10>,  Up: Python 3 13 0 alpha 3

1.23.13.6 Build
...............

   - gh-114013(1): Fix ‘Tools/wasm/wasi.py’ to not include the path to
     ‘python.wasm’ as part of ‘HOSTRUNNER’.  The environment variable is
     meant to specify how to run the WASI host only, having
     ‘python.wasm’ and relevant flags appended to the ‘HOSTRUNNER’.
     This fixes ‘make test’ work.

   - gh-113258(2): Changed the Windows build to write out generated
     frozen modules into the build tree instead of the source tree.

   - gh-112305(3): Fixed the ‘check-clean-src’ step performed on out of
     tree builds to detect errant ‘$(srcdir)/Python/frozen_modules/*.h’
     files and recommend appropriate source tree cleanup steps to get a
     working build again.

   - gh-112536(4): Add support for thread sanitizer (TSAN)

   - gh-112867(5): Fix the build for the case that
     WITH_PYMALLOC_RADIX_TREE=0 set.

   - gh-103065(6): Introduce ‘Tools/wasm/wasi.py’ to simplify doing a
     WASI build.

   - bpo-11102(7): The *note os.major(): 157e, *note os.makedev(): 1580,
     and *note os.minor(): 157f. functions are now available on HP-UX
     v3.

   - bpo-36351(8): Do not set ipv6type when cross-compiling.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/114013

   (2) https://github.com/python/cpython/issues/113258

   (3) https://github.com/python/cpython/issues/112305

   (4) https://github.com/python/cpython/issues/112536

   (5) https://github.com/python/cpython/issues/112867

   (6) https://github.com/python/cpython/issues/103065

   (7) https://bugs.python.org/issue?@action=redirect&bpo=11102

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36351


File: python.info,  Node: Windows<9>,  Next: macOS<7>,  Prev: Build<12>,  Up: Python 3 13 0 alpha 3

1.23.13.7 Windows
.................

   - gh-114096(1): Process privileges that are activated for creating
     directory junctions are now restored afterwards, avoiding behaviour
     changes in other parts of the program.

   - gh-111877(2): *note os.stat(): 46d. calls were returning incorrect
     time values for files that could not be accessed directly.

   - gh-111973(3): Update Windows installer to use SQLite 3.44.2.

   - gh-113009(4): *note multiprocessing: 86.: On Windows, fix a race
     condition in ‘Process.terminate()’: no longer set the ‘returncode’
     attribute to always call ‘WaitForSingleObject()’ in
     ‘Process.wait()’.  Previously, sometimes the process was still
     running after ‘TerminateProcess()’ even if ‘GetExitCodeProcess()’
     is not ‘STILL_ACTIVE’.  Patch by Victor Stinner.

   - gh-86179(5): Fixes path calculations when launching Python on
     Windows through a symlink.

   - gh-71383(6): Update Tcl/Tk in Windows installer to 8.6.13 with a
     patch to suppress incorrect ThemeChanged warnings.

   - gh-111650(7): Ensures the ‘Py_GIL_DISABLED’ preprocessor variable
     is defined in ‘pyconfig.h’ so that extension modules written in C
     are able to use it.

   - gh-112278(8): Reduce the time cost for some functions in *note
     platform: 98. on Windows if current user has no permission to the
     WMI.

   - gh-73427(9): Deprecate *note sys._enablelegacywindowsfsencoding():
     28e.  Use *note PYTHONLEGACYWINDOWSFSENCODING: 28f. instead.  Patch
     by Inada Naoki.

   - gh-87868(10): Correctly sort and remove duplicate environment
     variables in ‘_winapi.CreateProcess()’.

   - bpo-37308(11): Fix mojibake in *note mmap.mmap: 1ec. when using a
     non-ASCII 'tagname' argument on Windows.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/114096

   (2) https://github.com/python/cpython/issues/111877

   (3) https://github.com/python/cpython/issues/111973

   (4) https://github.com/python/cpython/issues/113009

   (5) https://github.com/python/cpython/issues/86179

   (6) https://github.com/python/cpython/issues/71383

   (7) https://github.com/python/cpython/issues/111650

   (8) https://github.com/python/cpython/issues/112278

   (9) https://github.com/python/cpython/issues/73427

   (10) https://github.com/python/cpython/issues/87868

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37308


File: python.info,  Node: macOS<7>,  Next: IDLE<11>,  Prev: Windows<9>,  Up: Python 3 13 0 alpha 3

1.23.13.8 macOS
...............

   - gh-113666(1): Add the following constants to module *note stat:
     bc.: ‘UF_SETTABLE’, ‘UF_TRACKED’, ‘UF_DATAVAULT’, ‘SF_SUPPORTED’,
     ‘SF_SETTABLE’, ‘SF_SYNTHETIC’, ‘SF_RESTRICTED’, ‘SF_FIRMLINK’ and
     ‘SF_DATALESS’.  The values ‘UF_SETTABLE’, ‘SF_SUPPORTED’,
     ‘SF_SETTABLE’ and ‘SF_SYNTHETIC’ are only available on macOS.

   - gh-113536(2): *note os.waitid(): d66. is now available on macOS

   - gh-110459(3): Running ‘configure ... --with-openssl-rpath=X/Y/Z’ no
     longer fails to detect OpenSSL on macOS.

   - gh-74573(4): Document that *note dbm.ndbm: 2c. can silently corrupt
     DBM files on updates when exceeding undocumented platform limits,
     and can crash (segmentation fault) when reading such a corrupted
     file.  (FB8919203)

   - gh-65701(5): The ‘freeze’ tool doesn't work with framework builds
     of Python.  Document this and bail out early when running the tool
     with such a build.

   - gh-87277(6): webbrowser: Don't look for X11 browsers on macOS.
     Those are generally not used and probing for them can result in
     starting XQuartz even if it isn't used otherwise.

   - gh-111973(7): Update macOS installer to use SQLite 3.44.2.

   - gh-108269(8): Set ‘CFBundleAllowMixedLocalizations’ to true in the
     Info.plist for the framework, embedded Python.app and IDLE.app with
     framework installs on macOS. This allows applications to pick up
     the user's preferred locale when that's different from english.

   - gh-102362(9): Make sure the result of ‘sysconfig.get_plaform()’
     includes at least a major and minor versions, even if
     ‘MACOSX_DEPLOYMENT_TARGET’ is set to only a major version during
     build to match the format expected by pip.

   - gh-110017(10): Disable a signal handling stress test on macOS due
     to a bug in macOS (FB13453490).

   - gh-110820(11): Make sure the preprocessor definitions for
     ‘ALIGNOF_MAX_ALIGN_T’, ‘SIZEOF_LONG_DOUBLE’ and
     ‘HAVE_GCC_ASM_FOR_X64’ are correct for Universal 2 builds on macOS.

   - gh-109981(12): Use ‘/dev/fd’ on macOS to determine the number of
     open files in ‘test.support.os_helper.fd_count’ to avoid a crash
     with "guarded" file descriptors when probing for open files.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/113666

   (2) https://github.com/python/cpython/issues/113536

   (3) https://github.com/python/cpython/issues/110459

   (4) https://github.com/python/cpython/issues/74573

   (5) https://github.com/python/cpython/issues/65701

   (6) https://github.com/python/cpython/issues/87277

   (7) https://github.com/python/cpython/issues/111973

   (8) https://github.com/python/cpython/issues/108269

   (9) https://github.com/python/cpython/issues/102362

   (10) https://github.com/python/cpython/issues/110017

   (11) https://github.com/python/cpython/issues/110820

   (12) https://github.com/python/cpython/issues/109981


File: python.info,  Node: IDLE<11>,  Next: C API<12>,  Prev: macOS<7>,  Up: Python 3 13 0 alpha 3

1.23.13.9 IDLE
..............

   - gh-72284(1): Improve the lists of features, editor key bindings,
     and shell key bingings in the IDLE doc.

   - gh-113903(2): Fix rare failure of test.test_idle, in
     test_configdialog.

   - gh-113729(3): Fix the "Help -> IDLE Doc" menu bug in 3.11.7 and
     3.12.1.

   - gh-113269(4): Fix test_editor hang on macOS Catalina.

   - gh-112898(5): Fix processing unsaved files when quitting IDLE on
     macOS.

   - bpo-13586(6): Enter the selected text when opening the "Replace"
     dialog.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/72284

   (2) https://github.com/python/cpython/issues/113903

   (3) https://github.com/python/cpython/issues/113729

   (4) https://github.com/python/cpython/issues/113269

   (5) https://github.com/python/cpython/issues/112898

   (6) https://bugs.python.org/issue?@action=redirect&bpo=13586


File: python.info,  Node: C API<12>,  Prev: IDLE<11>,  Up: Python 3 13 0 alpha 3

1.23.13.10 C API
................

   - gh-106560(1): Fix redundant declarations in the public C API.
     Declare PyBool_Type, PyLong_Type and PySys_Audit() only once.
     Patch by Victor Stinner.

   - gh-112438(2): Fix support of format units "es", "et", "es#", and
     "et#" in nested tuples in *note PyArg_ParseTuple(): 53d.-like
     functions.

   - gh-111545(3): Add *note Py_HashPointer(): 341. function to hash a
     pointer.  Patch by Victor Stinner.

   - gh-65210(4): Change the declaration of the 'keywords' parameter of
     *note PyArg_ParseTupleAndKeywords(): 35c. and *note
     PyArg_VaParseTupleAndKeywords(): 35d. for better compatibility with
     C++.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/106560

   (2) https://github.com/python/cpython/issues/112438

   (3) https://github.com/python/cpython/issues/111545

   (4) https://github.com/python/cpython/issues/65210


File: python.info,  Node: Python 3 13 0 alpha 2,  Next: Python 3 13 0 alpha 1,  Prev: Python 3 13 0 alpha 3,  Up: 変更履歴

1.23.14 Python 3.13.0 alpha 2
-----------------------------

'Release date: 2023-11-22'

* Menu:

* Core and Builtins: Core and Builtins<14>.
* Library: Library<13>.
* Tests: Tests<11>.
* Build: Build<13>.
* Windows: Windows<10>.
* macOS: macOS<8>.
* IDLE: IDLE<12>.
* Tools/Demos: Tools/Demos<5>.
* C API: C API<13>.


File: python.info,  Node: Core and Builtins<14>,  Next: Library<13>,  Up: Python 3 13 0 alpha 2

1.23.14.1 Core and Builtins
...........................

   - gh-112243(1): Don't include comments in f-string debug expressions.
     Patch by Pablo Galindo

   - gh-112287(2): Slightly optimize the Tier 2 (uop) interpreter by
     only loading ‘oparg’ and ‘operand’ when needed.  Also double the
     trace size limit again, to 512 this time.

   - gh-112266(3): Change docstrings of *note __dict__: 526. and
     ‘__weakref__’.

   - gh-111807(4): Lower the max parser stack depth to 1000 under WASI
     debug builds.

   - gh-111798(5): When Python is built in debug mode, set the C
     recursion limit to 500 instead of 1500.  A debug build is likely
     built with low optimization level which implies higher stack memory
     usage than a release build.  Patch by Victor Stinner.

   - gh-106529(6): Enable translating unspecialized ‘FOR_ITER’ to Tier
     2.

   - gh-111916(7): Make hashlib related modules thread-safe without the
     GIL

   - gh-81137(8): Deprecate assignment to a function's ‘__code__’ field
     when the new code object is of a mismatched type (e.g., from a
     generator to a plain function).

   - gh-79932(9): Raise exception if *note frame.clear(): 261. is called
     on a suspended frame.

   - gh-81925(10): Implement native thread ids for GNU KFreeBSD.

   - gh-111843(11): Use exponential backoff to reduce the number of
     failed tier 2 optimization attempts by over 99%.

   - gh-110829(12): Joining a thread now ensures the underlying OS
     thread has exited.  This is required for safer fork() in
     multi-threaded processes.

   - gh-109369(13): Make sure that tier 2 traces are de-optimized if the
     code is instrumented

   - gh-111772(14): Specialize slot loads and stores for _Py_T_OBJECT as
     well as Py_T_OBJECT_EX

   - gh-111666(15): Speed up *note BaseExceptionGroup.derive(): 1624,
     *note BaseExceptionGroup.subgroup(): 1625, and *note
     BaseExceptionGroup.split(): 1626. by changing how they parse passed
     arguments.

   - gh-111654(16): Fix runtime crash when some error happens in opcode
     ‘LOAD_FROM_DICT_OR_DEREF’.

   - gh-111623(17): Add support for sharing tuples between interpreters
     using the cross-interpreter API. Patch by Anthony Shaw.

   - gh-111354(18): The oparg of *note YIELD_VALUE: 2ec. is now ‘1’ if
     the instruction is part of a yield-from or await, and ‘0’
     otherwise.

     The SUSPENDED frame state is now split into ‘SUSPENDED’ and
     ‘SUSPENDED_YIELD_FROM’.  This simplifies the code in ‘_PyGen_yf’.

   - gh-111520(19): Merge the Tier 1 (bytecode) and Tier 2 (micro-ops)
     interpreters together, moving the Tier 2 interpreter loop and
     switch into ‘_PyEval_EvalFrameDefault()’ in ‘Python/ceval.c’.  The
     ‘Python/executor.c’ file is gone.  Also the ‘TIER_ONE’ and
     ‘TIER_TWO’ macros are now handled by the code generator.

     'Beware!'  This changes the environment variables to enable
     micro-ops and their debugging to ‘PYTHON_UOPS’ and
     ‘PYTHON_LLTRACE’.

   - gh-109181(20): Speed up ‘Traceback’ object creation by lazily
     compute the line number.  Patch by Pablo Galindo

   - gh-111420(21): Allow type comments in parenthesized ‘with’
     statements

   - gh-111438(22): Add support for sharing floats between interpreters
     using the cross-interpreter API. Patch by Anthony Shaw.

   - gh-111435(23): Add support for sharing of ‘True’ and ‘False’
     between interpreters using the cross-interpreter API. Patch by
     Anthony Shaw.

   - gh-102388(24): Fix a bug where ‘iso2022_jp_3’ and ‘iso2022_jp_2004’
     codecs read out of bounds

   - gh-111366(25): Fix an issue in the *note codeop: 15. that was
     causing *note SyntaxError: 172. exceptions raised in the presence
     of invalid syntax to not contain precise error messages.  Patch by
     Pablo Galindo

   - gh-111380(26): Fix a bug that was causing *note SyntaxWarning: 432.
     to appear twice when parsing if invalid syntax is encountered
     later.  Patch by Pablo galindo

   - gh-111374(27): Added a new environment variable *note
     PYTHON_FROZEN_MODULES: 173.  It determines whether or not frozen
     modules are ignored by the import machinery, equivalent of the
     *note -X frozen_modules: 15c. command-line option.

   - gh-111354(28): Remove ‘oparg’ from *note YIELD_VALUE: 2ec.  Change
     ‘oparg’ of *note RESUME: 2ed. to include information about the
     except-depth.  These changes make it possible to simplify the code
     in generator close.

   - gh-94438(29): Fix a regression that prevented jumping across ‘is
     None’ and ‘is not None’ when debugging.  Patch by Savannah
     Ostrowski.

   - gh-67224(30): Show source lines in tracebacks when using the ‘-c’
     option when running Python.  Patch by Pablo Galindo

   - gh-111123(31): Fix a bug where a *note global: 16f. declaration in
     an *note except: 170. block is rejected when the global is used in
     the *note else: 171. block.

   - gh-110938(32): Fix error messages for indented blocks with
     functions and classes with generic type parameters.  Patch by Pablo
     Galindo

   - gh-109214(33): Remove unnecessary instruction pointer updates
     before returning from frames.

   - gh-110912(34): Correctly display the traceback for *note
     MemoryError: 1627. exceptions using the *note traceback: e7.
     module.  Patch by Pablo Galindo

   - gh-109894(35): Fixed crash due to improperly initialized static
     *note MemoryError: 1627. in subinterpreter.

   - gh-110892(36): Return ‘NULL’ for ‘PyTrace_RETURN’ events caused by
     an exception

   - gh-110864(37): Fix argument parsing by
     ‘_PyArg_UnpackKeywordsWithVararg’ for functions defining
     pos-or-keyword, vararg, and kw-only parameters.

   - gh-109094(38): Replace ‘prev_instr’ on the interpreter frame by
     ‘instr_ptr’ which points to the beginning of the instruction that
     is currently executing (or will execute once the frame resumes).

   - gh-110805(39): Allow the repl to show source code and complete
     tracebacks.  Patch by Pablo Galindo

   - gh-110722(40): Add ‘PYTHON_PRESITE=package.module’ to import a
     module early in the interpreter lifecycle before ‘site.py’ is
     executed.  Python needs to be *note built in debug mode: 1da. for
     this option to exist.

   - gh-110481(41): Implement biased reference counting in
     ‘--disable-gil’ builds.

   - gh-110543(42): Fix regression in Python 3.12 where
     ‘types.CodeType.replace()’ would produce a broken code object if
     called on a module or class code object that contains a
     comprehension.  Patch by Jelle Zijlstra.

   - gh-89519(43): Removed chained *note classmethod: 14c. descriptors
     (introduced in bpo-19072(44)).  This can no longer be used to wrap
     other descriptors such as *note property: 179.  The core design of
     this feature was flawed and caused a number of downstream problems.
     To "pass-through" a *note classmethod: 14c, consider using the
     ‘__wrapped__’ attribute that was added in Python 3.10.

   - gh-103615(45): Use local events for opcode tracing

   - bpo-46657(46): Add mimalloc memory allocator support.

   - gh-106718(47): When PyConfig.stdlib_dir is explicitly set, it's now
     respected and won't be overridden by PyConfig.home.

   - gh-106905(48): Fix incorrect SystemError about AST constructor
     recursion depth mismatch.

   - gh-100445(49): Improve error message for unterminated strings with
     escapes.

   - bpo-45759(50): Improved error messages for ‘elif’/‘else’ statements
     not matching any valid statements.  Patch by Jeremiah Vivian.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/112243

   (2) https://github.com/python/cpython/issues/112287

   (3) https://github.com/python/cpython/issues/112266

   (4) https://github.com/python/cpython/issues/111807

   (5) https://github.com/python/cpython/issues/111798

   (6) https://github.com/python/cpython/issues/106529

   (7) https://github.com/python/cpython/issues/111916

   (8) https://github.com/python/cpython/issues/81137

   (9) https://github.com/python/cpython/issues/79932

   (10) https://github.com/python/cpython/issues/81925

   (11) https://github.com/python/cpython/issues/111843

   (12) https://github.com/python/cpython/issues/110829

   (13) https://github.com/python/cpython/issues/109369

   (14) https://github.com/python/cpython/issues/111772

   (15) https://github.com/python/cpython/issues/111666

   (16) https://github.com/python/cpython/issues/111654

   (17) https://github.com/python/cpython/issues/111623

   (18) https://github.com/python/cpython/issues/111354

   (19) https://github.com/python/cpython/issues/111520

   (20) https://github.com/python/cpython/issues/109181

   (21) https://github.com/python/cpython/issues/111420

   (22) https://github.com/python/cpython/issues/111438

   (23) https://github.com/python/cpython/issues/111435

   (24) https://github.com/python/cpython/issues/102388

   (25) https://github.com/python/cpython/issues/111366

   (26) https://github.com/python/cpython/issues/111380

   (27) https://github.com/python/cpython/issues/111374

   (28) https://github.com/python/cpython/issues/111354

   (29) https://github.com/python/cpython/issues/94438

   (30) https://github.com/python/cpython/issues/67224

   (31) https://github.com/python/cpython/issues/111123

   (32) https://github.com/python/cpython/issues/110938

   (33) https://github.com/python/cpython/issues/109214

   (34) https://github.com/python/cpython/issues/110912

   (35) https://github.com/python/cpython/issues/109894

   (36) https://github.com/python/cpython/issues/110892

   (37) https://github.com/python/cpython/issues/110864

   (38) https://github.com/python/cpython/issues/109094

   (39) https://github.com/python/cpython/issues/110805

   (40) https://github.com/python/cpython/issues/110722

   (41) https://github.com/python/cpython/issues/110481

   (42) https://github.com/python/cpython/issues/110543

   (43) https://github.com/python/cpython/issues/89519

   (44) https://bugs.python.org/issue?@action=redirect&bpo=19072

   (45) https://github.com/python/cpython/issues/103615

   (46) https://bugs.python.org/issue?@action=redirect&bpo=46657

   (47) https://github.com/python/cpython/issues/106718

   (48) https://github.com/python/cpython/issues/106905

   (49) https://github.com/python/cpython/issues/100445

   (50) https://bugs.python.org/issue?@action=redirect&bpo=45759


File: python.info,  Node: Library<13>,  Next: Tests<11>,  Prev: Core and Builtins<14>,  Up: Python 3 13 0 alpha 2

1.23.14.2 Library
.................

   - gh-111942(1): Fix SystemError in the TextIOWrapper constructor with
     non-encodable "errors" argument in non-debug mode.

   - gh-111995(2): Added the ‘NI_IDN’ constant to the *note socket: b8.
     module when present in C at build time for use with *note
     socket.getnameinfo(): 1629.

   - gh-109538(3): Issue warning message instead of having *note
     RuntimeError: 17a. be displayed when event loop has already been
     closed at ‘StreamWriter.__del__()’.

   - gh-111942(4): Fix crashes in *note io.TextIOWrapper.reconfigure():
     b17. when pass invalid arguments, e.g.  non-string encoding.

   - gh-111460(5): *note curses: 23.: restore wide character support
     (including *note curses.unget_wch(): 106d. and *note get_wch():
     106c.) on macOS, which was unavailable due to a regression in
     Python 3.12.

   - gh-103791(6): *note contextlib.suppress: ef2. now supports
     suppressing exceptions raised as part of a *note
     BaseExceptionGroup: 240, in addition to the recent support for
     *note ExceptionGroup: 19b.

   - gh-111835(7): The *note mmap.mmap: 1ec. class now has an *note
     seekable(): 1ed. method that can be used when a seekable file-like
     object is required.  The *note seek(): 1ee. method now returns the
     new absolute position.  Patch by Donghee Na.

   - gh-111804(8): Remove posix.fallocate() under WASI as the underlying
     posix_fallocate() is not available in WASI preview2.

   - gh-111841(9): Fix truncating arguments on an embedded null
     character in *note os.putenv(): 8ea. and *note os.unsetenv(): 8e9.
     on Windows.

   - gh-111768(10): *note wsgiref.util.is_hop_by_hop(): 162a. is now
     exposed correctly in ‘__all__’.

   - gh-80731(11): Avoid executing the default function in *note
     cmd.Cmd: 162b. in an except block

   - gh-111541(12): Fix *note doctest: 31. for *note SyntaxError: 172.
     not-builtin subclasses.

   - gh-111719(13): Add extra argument validation for ‘alias’ command in
     *note pdb: 94.

   - gh-111482(14): *note time: d7.: Make *note time.clock_gettime():
     1131. and *note time.clock_gettime_ns(): ab0. functions up to 2x
     faster by faster calling convention.  Patch by Victor Stinner.

   - gh-110894(15): Call loop exception handler for exceptions in
     ‘client_connected_cb’ of *note asyncio.start_server(): ae7. so that
     applications can handle it.  Patch by Kumar Aditya.

   - gh-111531(16): Fix reference leaks in ‘bind_class()’ and
     ‘bind_all()’ methods of *note tkinter: d9. widgets.

   - gh-111246(17): *note asyncio.loop.create_unix_server(): 193. will
     now automatically remove the Unix socket when the server is closed.

   - gh-111356(18): Added *note io.text_encoding(): 162c, *note
     io.DEFAULT_BUFFER_SIZE: 162d, and *note
     io.IncrementalNewlineDecoder: 162e. to ‘io.__all__’.

   - gh-66425(19): Remove the code to set the REMOTE_HOST header from
     wsgiref module, as it is unreachable.  This header is used for
     performance reasons, which is not necessary in the wsgiref module.

   - gh-111429(20): Speed up *note pathlib.PurePath.relative_to(): 2ab.
     and *note is_relative_to(): 2aa.

   - gh-111342(21): Fixed typo in *note math.sumprod(): 464.

   - gh-68166(22): Remove mention of not supported "vsapi" element type
     in *note tkinter.ttk.Style.element_create(): 239.  Add tests for
     ‘element_create()’ and other ‘ttk.Style’ methods.  Add examples for
     ‘element_create()’ in the documentation.

   - gh-111388(23): Add ‘show_group’ parameter to *note
     traceback.format_exception_only(): 819, which allows to format
     *note ExceptionGroup: 19b. instances.

   - gh-79033(24): Another attempt at fixing *note
     asyncio.Server.wait_closed(): 162f.  It now blocks until both
     conditions are true: the server is closed, 'and' there are no more
     active connections.  (This means that in some cases where in 3.12.0
     this function would 'incorrectly' have returned immediately, it
     will now block; in particular, when there are no active connections
     but the server hasn't been closed yet.)

   - gh-111259(25): Optimize recursive wildcards in *note pathlib: 93.

   - gh-111295(26): Fix *note time: d7. not checking for errors when
     initializing.

   - gh-111253(27): Add error checking during ‘_socket’ module init.

   - gh-111251(28): Fix ‘_blake2’ not checking for errors when
     initializing.

   - gh-111233(29): Fix *note select: af. not checking for errors when
     initializing.

   - gh-111230(30): Fix *note ssl: bb. not checking for errors when
     initializing.

   - gh-111174(31): Fix crash in *note io.BytesIO.getbuffer(): 11c2.
     called repeatedly for empty BytesIO.

   - gh-111187(32): Postpone removal version for
     locale.getdefaultlocale() to Python 3.15.

   - gh-111159(33): Fix *note doctest: 31. output comparison for
     exceptions with notes.

   - gh-110910(34): Fix invalid state handling in *note
     asyncio.TaskGroup: 19a. and *note asyncio.Timeout: 1630.  They now
     raise proper RuntimeError if they are improperly used and are left
     in consistent state after this.

   - gh-111092(35): Make turtledemo run without default root enabled.

   - gh-110944(36): Support alias and convenience vars for *note pdb:
     94. completion

   - gh-110745(37): Added 'newline' parameter to *note
     pathlib.Path.read_text(): e12.  Patch by Junya Okabe.

   - gh-84583(38): Make *note pdb: 94. enter post-mortem mode even for
     *note SyntaxError: 172.

   - gh-80675(39): Set ‘f_trace_lines = True’ on all frames upon *note
     pdb.set_trace(): 216.

   - gh-110771(40): Expose the setup and cleanup portions of
     ‘asyncio.run_forever()’ as the standalone methods
     ‘asyncio.run_forever_setup()’ and ‘asyncio.run_forever_cleanup()’.
     This allows for tighter integration with GUI event loops.

   - gh-110774(41): Support setting the *note asyncio.Runner: 5cb.
     loop_factory kwarg in *note unittest.IsolatedAsyncioTestCase: 2e4.

   - gh-110392(42): Fix *note tty.setraw(): 1631. and *note
     tty.setcbreak(): 15dc.: previously they returned partially modified
     list of the original tty attributes.  *note tty.cfmakeraw(): 1632.
     and *note tty.cfmakecbreak(): 15dd. now make a copy of the list of
     special characters before modifying it.

   - gh-59013(43): Make line number of function breakpoint more precise
     in *note pdb: 94.

   - gh-88434(44): Emit deprecation warning for non-integer numbers in
     *note gettext: 59. functions and methods that consider plural forms
     even if the translation was not found.

   - gh-110395(45): Ensure that *note select.kqueue(): 1633. objects
     correctly appear as closed in forked children, to prevent
     operations on an invalid file descriptor.

   - gh-110196(46): Add ‘__reduce__’ method to ‘IPv6Address’ in order to
     keep ‘scope_id’

   - gh-109747(47): Improve errors for unsupported look-behind patterns.
     Now re.error is raised instead of OverflowError or RuntimeError for
     too large width of look-behind pattern.

   - gh-109466(48): Add the *note ipaddress.IPv4Address.ipv6_mapped:
     1dc. property, which returns the IPv4-mapped IPv6 address.

   - gh-85098(49): Implement the CLI of the *note symtable: c2. module
     and improve the repr of *note Symbol: 1634.

   - gh-108791(50): Improved error handling in *note pdb: 94. command
     line interface, making it produce more concise error messages.

   - gh-105931(51): Change *note compileall: 19. to only strip the
     stripdir prefix from the full path recorded in the compiled ‘.pyc’
     file, when the prefix matches the start of the full path in its
     entirety.  When the prefix does not match, no stripping is
     performed and a warning to this effect is displayed.

     Previously all path components of the stripdir prefix that matched
     the full path were removed, while those that did not match were
     left alone (including ones interspersed between matching
     components).

   - gh-107431(52): Make the ‘DictProxy’ and ‘ListProxy’ types in *note
     multiprocessing.managers: 89. *note Generic Alias Types: 67e. for
     ‘[]’ use in typing contexts.

   - gh-72904(53): Add *note glob.translate(): 1cb.  This function
     converts a pathname with shell-style wildcards to a regular
     expression.

   - gh-90026(54): Define ‘USE_XATTRS’ on Cygwin so that XATTR-related
     functions in the *note os: 91. module become available.

   - gh-90890(55): New methods *note mailbox.Maildir.get_info(): 1635,
     *note mailbox.Maildir.set_info(): 1636, *note
     mailbox.Maildir.get_flags(): 1637, *note
     mailbox.Maildir.set_flags(): 1638, *note
     mailbox.Maildir.add_flag(): 1639, *note
     mailbox.Maildir.remove_flag(): 163a.  These methods speed up
     accessing a message's info and/or flags and are useful when it is
     not necessary to access the message's contents, as when iterating
     over a Maildir to find messages with specific flags.

   - gh-102956(56): Fix returning of empty byte strings after seek in
     zipfile module

   - gh-102895(57): Added a parameter ‘local_exit’ for *note
     code.interact(): 163b. to prevent ‘exit()’ and ‘quit’ from closing
     ‘sys.stdin’ and raise ‘SystemExit’.

   - gh-97928(58): Change the behavior of ‘tkinter.Text.count()’.  It
     now always returns an integer if one or less counting options are
     specified.  Previously it could return a single count as a 1-tuple,
     an integer (only if option ‘"update"’ was specified) or ‘None’ if
     no items found.  The result is now the same if ‘wantobjects’ is set
     to ‘0’.

   - gh-96954(59): Switch the storage of the unicode codepoint names to
     use a different data-structure, a directed acyclic word graph(60).
     This makes the unicodedata shared library about 440 KiB smaller.
     Contributed by Carl Friedrich Bolz-Tereick using code from the PyPy
     project.

   - gh-73561(61): Omit the interface scope from an IPv6 address when
     used as Host header by *note http.client: 65.

   - gh-86826(62): ‘zipinfo’ now supports the full range of values in
     the TZ string determined by RFC 8536 and detects all invalid
     formats.  Both Python and C implementations now raise exceptions of
     the same type on invalid data.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111942

   (2) https://github.com/python/cpython/issues/111995

   (3) https://github.com/python/cpython/issues/109538

   (4) https://github.com/python/cpython/issues/111942

   (5) https://github.com/python/cpython/issues/111460

   (6) https://github.com/python/cpython/issues/103791

   (7) https://github.com/python/cpython/issues/111835

   (8) https://github.com/python/cpython/issues/111804

   (9) https://github.com/python/cpython/issues/111841

   (10) https://github.com/python/cpython/issues/111768

   (11) https://github.com/python/cpython/issues/80731

   (12) https://github.com/python/cpython/issues/111541

   (13) https://github.com/python/cpython/issues/111719

   (14) https://github.com/python/cpython/issues/111482

   (15) https://github.com/python/cpython/issues/110894

   (16) https://github.com/python/cpython/issues/111531

   (17) https://github.com/python/cpython/issues/111246

   (18) https://github.com/python/cpython/issues/111356

   (19) https://github.com/python/cpython/issues/66425

   (20) https://github.com/python/cpython/issues/111429

   (21) https://github.com/python/cpython/issues/111342

   (22) https://github.com/python/cpython/issues/68166

   (23) https://github.com/python/cpython/issues/111388

   (24) https://github.com/python/cpython/issues/79033

   (25) https://github.com/python/cpython/issues/111259

   (26) https://github.com/python/cpython/issues/111295

   (27) https://github.com/python/cpython/issues/111253

   (28) https://github.com/python/cpython/issues/111251

   (29) https://github.com/python/cpython/issues/111233

   (30) https://github.com/python/cpython/issues/111230

   (31) https://github.com/python/cpython/issues/111174

   (32) https://github.com/python/cpython/issues/111187

   (33) https://github.com/python/cpython/issues/111159

   (34) https://github.com/python/cpython/issues/110910

   (35) https://github.com/python/cpython/issues/111092

   (36) https://github.com/python/cpython/issues/110944

   (37) https://github.com/python/cpython/issues/110745

   (38) https://github.com/python/cpython/issues/84583

   (39) https://github.com/python/cpython/issues/80675

   (40) https://github.com/python/cpython/issues/110771

   (41) https://github.com/python/cpython/issues/110774

   (42) https://github.com/python/cpython/issues/110392

   (43) https://github.com/python/cpython/issues/59013

   (44) https://github.com/python/cpython/issues/88434

   (45) https://github.com/python/cpython/issues/110395

   (46) https://github.com/python/cpython/issues/110196

   (47) https://github.com/python/cpython/issues/109747

   (48) https://github.com/python/cpython/issues/109466

   (49) https://github.com/python/cpython/issues/85098

   (50) https://github.com/python/cpython/issues/108791

   (51) https://github.com/python/cpython/issues/105931

   (52) https://github.com/python/cpython/issues/107431

   (53) https://github.com/python/cpython/issues/72904

   (54) https://github.com/python/cpython/issues/90026

   (55) https://github.com/python/cpython/issues/90890

   (56) https://github.com/python/cpython/issues/102956

   (57) https://github.com/python/cpython/issues/102895

   (58) https://github.com/python/cpython/issues/97928

   (59) https://github.com/python/cpython/issues/96954

   (60) 
https://en.wikipedia.org/wiki/Deterministic_acyclic_finite_state_automaton

   (61) https://github.com/python/cpython/issues/73561

   (62) https://github.com/python/cpython/issues/86826


File: python.info,  Node: Tests<11>,  Next: Build<13>,  Prev: Library<13>,  Up: Python 3 13 0 alpha 2

1.23.14.3 Tests
...............

   - gh-111808(1): Make the default value of
     ‘test.support.infinite_recursion()’ to be conditional based on
     whether optimizations were used when compiling the interpreter.
     This helps with platforms like WASI whose stack size is greatly
     restricted in debug builds.

   - gh-110722(2): Gathering line coverage of standard libraries within
     the regression test suite is now precise, as well as much faster.
     Patch by Łukasz Langa.

   - gh-110367(3): Make regrtest ‘--verbose3’ option compatible with
     ‘--huntrleaks -jN’ options.  The ‘./python -m test -j1 -R 3:3
     --verbose3’ command now works as expected.  Patch by Victor
     Stinner.

   - gh-111165(4): Remove no longer used functions ‘run_unittest()’ and
     ‘run_doctest()’ from the *note test.support: cd. module.

   - gh-110932(5): Fix regrtest if the ‘SOURCE_DATE_EPOCH’ environment
     variable is defined: use the variable value as the random seed.
     Patch by Victor Stinner.

   - gh-110995(6): test_gdb: Fix detection of gdb built without Python
     scripting support.  Patch by Victor Stinner.

   - gh-110918(7): Test case matching patterns specified by options
     ‘--match’, ‘--ignore’, ‘--matchfile’ and ‘--ignorefile’ are now
     tested in the order of specification, and the last match determines
     whether the test case be run or ignored.

   - gh-108747(8): Add unit test for ‘usercustomize’ and ‘sitecustomize’
     hooks from *note site: b5.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111808

   (2) https://github.com/python/cpython/issues/110722

   (3) https://github.com/python/cpython/issues/110367

   (4) https://github.com/python/cpython/issues/111165

   (5) https://github.com/python/cpython/issues/110932

   (6) https://github.com/python/cpython/issues/110995

   (7) https://github.com/python/cpython/issues/110918

   (8) https://github.com/python/cpython/issues/108747


File: python.info,  Node: Build<13>,  Next: Windows<10>,  Prev: Tests<11>,  Up: Python 3 13 0 alpha 2

1.23.14.4 Build
...............

   - gh-96954(1): Make ‘make regen-unicodedata’ work for out-of-tree
     builds of CPython.

   - gh-112088(2): Add ‘Tools/build/regen-configure.sh’ script to
     regenerate the ‘configure’ with an Ubuntu container image.  The
     ‘quay.io/tiran/cpython_autoconf:271’ container image
     (tiran/cpython_autoconf(3)) is no longer used.  Patch by Victor
     Stinner.

   - gh-111046(4): For wasi-threads, memory is now exported to fix
     compatibility issues with some wasm runtimes.

   - gh-110828(5): AIX 32bit needs ‘-latomic’ to build the ‘_testcapi’
     extension module.

   - gh-85283(6): The ‘errno’, ‘md5’, ‘resource’, ‘winsound’,
     ‘_ctypes_test’, ‘_multiprocessing.posixshmem’, ‘_scproxy’, ‘_stat’,
     ‘_testimportmultiple’ and ‘_uuid’ C extensions are now built with
     the *note limited C API: 36f.  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/96954

   (2) https://github.com/python/cpython/issues/112088

   (3) https://github.com/tiran/cpython_autoconf

   (4) https://github.com/python/cpython/issues/111046

   (5) https://github.com/python/cpython/issues/110828

   (6) https://github.com/python/cpython/issues/85283


File: python.info,  Node: Windows<10>,  Next: macOS<8>,  Prev: Build<13>,  Up: Python 3 13 0 alpha 2

1.23.14.5 Windows
.................

   - gh-111856(1): Fixes *note fstat(): d59. on file systems that do not
     support file ID requests.  This includes FAT32 and exFAT.

   - gh-111293(2): Fix *note os.DirEntry.inode: 163f. dropping higher 64
     bits of a file id on some filesystems on Windows.

   - gh-110913(3): WindowsConsoleIO now correctly chunks large buffers
     without splitting up UTF-8 sequences.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111856

   (2) https://github.com/python/cpython/issues/111293

   (3) https://github.com/python/cpython/issues/110913


File: python.info,  Node: macOS<8>,  Next: IDLE<12>,  Prev: Windows<10>,  Up: Python 3 13 0 alpha 2

1.23.14.6 macOS
...............

   - gh-59703(1): For macOS framework builds, in ‘getpath.c’ use the
     system ‘dladdr’ function to find the path to the shared library
     rather than depending on deprecated macOS APIs.

   - gh-110950(2): Update macOS installer to include an upstream Tcl/Tk
     fix for the ‘Secure coding is not enabled for restorable state!’
     warning encountered in Tkinter on macOS 14 Sonoma.

   - gh-111015(3): Ensure that IDLE.app and Python Launcher.app are
     installed with appropriate permissions on macOS builds.

   - gh-71383(4): Update macOS installer to include an upstream Tcl/Tk
     fix for the ‘ttk::ThemeChanged’ error encountered in Tkinter.

   - gh-92603(5): Update macOS installer to include a fix accepted by
     upstream Tcl/Tk for a crash encountered after the first *note
     tkinter.Tk(): 159a. instance is destroyed.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/59703

   (2) https://github.com/python/cpython/issues/110950

   (3) https://github.com/python/cpython/issues/111015

   (4) https://github.com/python/cpython/issues/71383

   (5) https://github.com/python/cpython/issues/92603


File: python.info,  Node: IDLE<12>,  Next: Tools/Demos<5>,  Prev: macOS<8>,  Up: Python 3 13 0 alpha 2

1.23.14.7 IDLE
..............

   - bpo-35668(1): Add docstrings to the IDLE debugger module.  Fix two
     bugs: initialize ‘Idb.botframe’ (should be in Bdb); in
     ‘Idb.in_rpc_code’, check whether ‘prev_frame’ is ‘None’ before
     trying to use it.  Greatly expand test_debugger.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35668


File: python.info,  Node: Tools/Demos<5>,  Next: C API<13>,  Prev: IDLE<12>,  Up: Python 3 13 0 alpha 2

1.23.14.8 Tools/Demos
.....................

   - gh-111903(1): Argument Clinic now supports the ‘@critical_section’
     directive that instructs Argument Clinic to generate a critical
     section around the function call, which locks the ‘self’ object in
     ‘--disable-gil’ builds.  Patch by Sam Gross.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/111903


File: python.info,  Node: C API<13>,  Prev: Tools/Demos<5>,  Up: Python 3 13 0 alpha 2

1.23.14.9 C API
...............

   - gh-112026(1): Add again the private ‘_PyThreadState_UncheckedGet()’
     function as an alias to the new public *note
     PyThreadState_GetUnchecked(): 34a. function.  Patch by Victor
     Stinner.

   - gh-112026(2): Restore the removed
     ‘_PyDict_GetItemStringWithError()’ function.  It is used by numpy.
     Patch by Victor Stinner.

   - gh-112026(3): Restore removed private C API functions, macros and
     structures which have no simple replacement for now:

        * _PyDict_GetItem_KnownHash()

        * _PyDict_NewPresized()

        * _PyHASH_BITS

        * _PyHASH_IMAG

        * _PyHASH_INF

        * _PyHASH_MODULUS

        * _PyHASH_MULTIPLIER

        * _PyLong_Copy()

        * _PyLong_FromDigits()

        * _PyLong_New()

        * _PyLong_Sign()

        * _PyObject_CallMethodId()

        * _PyObject_CallMethodNoArgs()

        * _PyObject_CallMethodOneArg()

        * _PyObject_CallOneArg()

        * _PyObject_EXTRA_INIT

        * _PyObject_FastCallDict()

        * _PyObject_GetAttrId()

        * _PyObject_Vectorcall()

        * _PyObject_VectorcallMethod()

        * _PyStack_AsDict()

        * _PyThread_CurrentFrames()

        * _PyUnicodeWriter structure

        * _PyUnicodeWriter_Dealloc()

        * _PyUnicodeWriter_Finish()

        * _PyUnicodeWriter_Init()

        * _PyUnicodeWriter_Prepare()

        * _PyUnicodeWriter_PrepareKind()

        * _PyUnicodeWriter_WriteASCIIString()

        * _PyUnicodeWriter_WriteChar()

        * _PyUnicodeWriter_WriteLatin1String()

        * _PyUnicodeWriter_WriteStr()

        * _PyUnicodeWriter_WriteSubstring()

        * _PyUnicode_AsString()

        * _PyUnicode_FromId()

        * _PyVectorcall_Function()

        * _Py_IDENTIFIER()

        * _Py_c_abs()

        * _Py_c_diff()

        * _Py_c_neg()

        * _Py_c_pow()

        * _Py_c_prod()

        * _Py_c_quot()

        * _Py_c_sum()

        * _Py_static_string()

        * _Py_static_string_init()

     Patch by Victor Stinner.

   - gh-112026(4): Add again ‘<ctype.h>’ and ‘<unistd.h>’ includes in
     ‘Python.h’, but don't include them in the limited C API version
     3.13 and newer.  Patch by Victor Stinner.

   - gh-111956(5): Add internal-only one-time initialization API:
     ‘_PyOnceFlag’ and ‘_PyOnceFlag_CallOnce’.

   - gh-111262(6): Add *note PyDict_Pop(): 31a. and *note
     PyDict_PopString(): 31b. functions: remove a key from a dictionary
     and optionally return the removed value.  This is similar to *note
     dict.pop(): 31c, but without the default value and not raising
     *note KeyError: 31d. if the key missing.  Patch by Stefan Behnel
     and Victor Stinner.

   - gh-111863(7): Rename ‘Py_NOGIL’ to ‘Py_GIL_DISABLED’.  Patch by
     Hugo van Kemenade.

   - gh-111138(8): Add *note PyList_Extend(): 336. and *note
     PyList_Clear(): 337. functions: similar to Python ‘list.extend()’
     and ‘list.clear()’ methods.  Patch by Victor Stinner.

   - gh-108765(9): On Windows, ‘Python.h’ no longer includes the
     ‘<stddef.h>’ standard header file.  If needed, it should now be
     included explicitly.  Patch by Victor Stinner.

   - gh-111569(10): Implement "Python Critical Sections" from PEP
     703(11).  These are macros to help replace the GIL with per-object
     locks in the ‘--disable-gil’ build of CPython.  The macros are
     no-ops in the default build.

   - gh-111506(12): In the limited C API version 3.13, *note
     Py_SET_REFCNT(): 878. function is now implemented as an opaque
     function call.  Patch by Victor Stinner.

   - gh-108082(13): Add *note PyErr_FormatUnraisable(): 327. function.

   - gh-110964(14): Move the undocumented private _PyArg functions and
     _PyArg_Parser structure to internal C API (‘pycore_modsupport.h’).
     Patch by Victor Stinner.

   - gh-110815(15): Support non-ASCII keyword names in *note
     PyArg_ParseTupleAndKeywords(): 35c.

   - gh-109587(16): Introduced
     ‘PyUnstable_PerfTrampoline_CompileCode()’,
     ‘PyUnstable_PerfTrampoline_SetPersistAfterFork()’ and
     ‘PyUnstable_CopyPerfMapFile()’.  These functions allow extension
     modules to initialize trampolines eagerly, after the application is
     "warmed up".  This makes it possible to have perf-trampolines
     running in an always-enabled fashion.

   - gh-85283(17): Add the *note PySys_Audit(): 348. function to the
     limited C API. Patch by Victor Stinner.

   - gh-85283(18): Add *note PyMem_RawMalloc(): 369, *note
     PyMem_RawCalloc(): 36a, *note PyMem_RawRealloc(): 36b. and *note
     PyMem_RawFree(): 36c. to the limited C API. Patch by Victor
     Stinner.

   - gh-106672(19): Functions *note PyDict_GetItem(): 360, *note
     PyDict_GetItemString(): 361, *note PyMapping_HasKey(): 358, *note
     PyMapping_HasKeyString(): 35a, *note PyObject_HasAttr(): 354, *note
     PyObject_HasAttrString(): 356, and *note PySys_GetObject(): 362,
     which clear all errors occurred during calling the function, report
     now them using *note sys.unraisablehook(): 1d8.

   - gh-67565(20): Remove redundant C-contiguity check in ‘getargs.c’,
     *note binascii: c, *note ssl: bb. and Argument Clinic.  Patched by
     Stefan Krah and Furkan Onder

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/112026

   (2) https://github.com/python/cpython/issues/112026

   (3) https://github.com/python/cpython/issues/112026

   (4) https://github.com/python/cpython/issues/112026

   (5) https://github.com/python/cpython/issues/111956

   (6) https://github.com/python/cpython/issues/111262

   (7) https://github.com/python/cpython/issues/111863

   (8) https://github.com/python/cpython/issues/111138

   (9) https://github.com/python/cpython/issues/108765

   (10) https://github.com/python/cpython/issues/111569

   (11) https://peps.python.org/pep-0703/

   (12) https://github.com/python/cpython/issues/111506

   (13) https://github.com/python/cpython/issues/108082

   (14) https://github.com/python/cpython/issues/110964

   (15) https://github.com/python/cpython/issues/110815

   (16) https://github.com/python/cpython/issues/109587

   (17) https://github.com/python/cpython/issues/85283

   (18) https://github.com/python/cpython/issues/85283

   (19) https://github.com/python/cpython/issues/106672

   (20) https://github.com/python/cpython/issues/67565


File: python.info,  Node: Python 3 13 0 alpha 1,  Next: Python 3 12 0 beta 1,  Prev: Python 3 13 0 alpha 2,  Up: 変更履歴

1.23.15 Python 3.13.0 alpha 1
-----------------------------

'Release date: 2023-10-13'

* Menu:

* Security: Security<9>.
* Core and Builtins: Core and Builtins<15>.
* Library: Library<14>.
* Documentation: Documentation<9>.
* Tests: Tests<12>.
* Build: Build<14>.
* Windows: Windows<11>.
* macOS: macOS<9>.
* IDLE: IDLE<13>.
* Tools/Demos: Tools/Demos<6>.
* C API: C API<14>.


File: python.info,  Node: Security<9>,  Next: Core and Builtins<15>,  Up: Python 3 13 0 alpha 1

1.23.15.1 Security
..................

   - gh-108310(1): Fixed an issue where instances of *note
     ssl.SSLSocket: 8b8. were vulnerable to a bypass of the TLS
     handshake and included protections (like certificate verification)
     and treating sent unencrypted data as if it were post-handshake TLS
     encrypted data.  Security issue reported as CVE 2023-40217(2) by
     Aapo Oksman.  Patch by Gregory P. Smith.

   - gh-107774(3): PEP 669 specifies that
     ‘sys.monitoring.register_callback’ will generate an audit event.
     Pre-releases of Python 3.12 did not generate the audit event.  This
     is now fixed.

   - gh-102988(4): Reverted the *note email.utils: 47. security
     improvement change released in 3.12beta4 that unintentionally
     caused *note email.utils.getaddresses: 1c5. to fail to parse email
     addresses with a comma in the quoted name field.  See gh-106669(5).

   - gh-99108(6): Refresh our new HACL* built-in *note hashlib: 5e. code
     from upstream.  Built-in SHA2 should be faster and an issue with
     SHA3 on 32-bit platforms is fixed.

   - gh-102509(7): Start initializing ‘ob_digit’ during creation of
     *note PyLongObject: 554. objects.  Patch by Illia Volochii.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/108310

   (2) https://www.cve.org/CVERecord?id=CVE-2023-40217

   (3) https://github.com/python/cpython/issues/107774

   (4) https://github.com/python/cpython/issues/102988

   (5) https://github.com/python/cpython/issues/106669

   (6) https://github.com/python/cpython/issues/99108

   (7) https://github.com/python/cpython/issues/102509


File: python.info,  Node: Core and Builtins<15>,  Next: Library<14>,  Prev: Security<9>,  Up: Python 3 13 0 alpha 1

1.23.15.2 Core and Builtins
...........................

   - gh-110782(1): Fix crash when *note typing.TypeVar: 143. is
     constructed with a keyword argument.  Patch by Jelle Zijlstra.

   - gh-110752(2): Reset ‘ceval.eval_breaker’ in ‘interpreter_clear()’

   - gh-110721(3): Use the *note traceback: e7. implementation for the
     default ‘PyErr_Display()’ functionality.  Patch by Pablo Galindo

   - gh-110696(4): Fix incorrect error message for invalid argument
     unpacking.  Patch by Pablo Galindo

   - gh-104169(5): Split the tokenizer into two separate directories: -
     One part includes the actual lexeme producing logic and lives in
     ‘Parser/lexer’.  - The second part wraps the lexer according to the
     different tokenization modes we have (string, utf-8, file,
     interactive, readline) and lives in ‘Parser/tokenizer’.

   - gh-110688(6): Remove undocumented ‘test_c_api’ method from *note
     set: 5a3, which was only defined for testing purposes under
     ‘Py_DEBUG’.  Now we have proper CAPI tests.

   - gh-104584(7): Fix a reference leak when running with ‘PYTHONUOPS’
     or *note -X uops: 15c. enabled.

   - gh-110514(8): Add ‘PY_THROW’ to *note sys.setprofile(): 14a8.
     events

   - gh-110489(9): Optimise *note math.ceil(): 136a. when the input is
     exactly a float, resulting in about a 10% improvement.

   - gh-110455(10): Guard ‘assert(tstate->thread_id > 0)’ with ‘#ifndef
     HAVE_PTHREAD_STUBS’.  This allows for for pydebug builds to work
     under WASI which (currently) lacks thread support.

   - gh-110309(11): Remove unnecessary empty constant nodes in the ast
     of f-string specs.

   - gh-110259(12): Correctly identify the format spec in f-strings
     (with single or triple quotes) that have multiple lines in the
     expression part and include a formatting spec.  Patch by Pablo
     Galindo

   - gh-110237(13): Fix missing error checks for calls to
     ‘PyList_Append’ in ‘_PyEval_MatchClass’.

   - gh-110164(14): regrtest: If the ‘SOURCE_DATE_EPOCH’ environment
     variable is defined, regrtest now disables tests randomization.
     Patch by Victor Stinner.

   - gh-109889(15): Fix the compiler's redundant NOP detection algorithm
     to skip over NOPs with no line number when looking for the next
     instruction's lineno.

   - gh-109853(16): ‘sys.path[0]’ is now set correctly for
     subinterpreters.

   - gh-109923(17): Set line number on the ‘POP_TOP’ that follows a
     ‘RETURN_GENERATOR’.

   - gh-105716(18): Subinterpreters now correctly handle the case where
     they have threads running in the background.  Before, such threads
     would interfere with cleaning up and destroying them, as well as
     prevent running another script.

   - gh-109369(19): The internal eval_breaker and supporting flags, plus
     the monitoring version have been merged into a single atomic
     integer to speed up checks.

   - gh-109823(20): Fix bug where compiler does not adjust labels when
     removing an empty basic block which is a jump target.

   - gh-109793(21): The main thread no longer exits prematurely when a
     subinterpreter is cleaned up during runtime finalization.  The bug
     was a problem particularly because, when triggered, the Python
     process would always return with a 0 exitcode, even if it failed.

   - gh-109719(22): Fix missing jump target labels when compiler
     reorders cold/warm blocks.

   - gh-109595(23): Add *note -X cpu_count: 15c. command line option to
     override return results of *note os.cpu_count(): 1a7. and *note
     os.process_cpu_count(): 1a6.  This option is useful for users who
     need to limit CPU resources of a container system without having to
     modify the container (application code).  Patch by Donghee Na.

   - gh-109627(24): Fix bug where the compiler does not assign a new
     jump target label to a duplicated small exit block.

   - gh-109596(25): Fix some tokens in the grammar that were incorrectly
     marked as soft keywords.  Also fix some repeated rule names and
     ensure that repeated rules are not allowed.  Patch by Pablo Galindo

   - gh-109496(26): On a Python built in debug mode, *note Py_DECREF():
     53b. now calls ‘_Py_NegativeRefcount()’ if the object is a dangling
     pointer to deallocated memory: memory filled with ‘0xDD’ "dead
     byte" by the debug hook on memory allocators.  The fix is to check
     the reference count 'before' checking for ‘_Py_IsImmortal()’.
     Patch by Victor Stinner.

   - gh-107265(27): Deopt opcodes hidden by the executor when base
     opcode is needed

   - gh-109371(28): Deopted instructions correctly for tool
     initialization and modified the incorrect assertion in
     instrumentation, when a previous tool already sets INSTRUCTION
     events

   - gh-105658(29): Fix bug where the line trace of an except block
     ending with a conditional includes an excess event with the line of
     the conditional expression.

   - gh-109219(30): Fix compiling type param scopes that use a name
     which is also free in an inner scope.

   - gh-109351(31): Fix crash when compiling an invalid AST involving a
     named (walrus) expression.

   - gh-109341(32): Fix crash when compiling an invalid AST involving a
     *note ast.TypeAlias: 1647.

   - gh-109195(33): Fix source location for the ‘LOAD_*’ instruction
     preceding a ‘LOAD_SUPER_ATTR’ to load the ‘super’ global (or
     shadowing variable) so that it encompasses only the name ‘super’
     and not the following parentheses.

   - gh-109256(34): Opcode IDs for specialized opcodes are allocated in
     their own range to improve stability of the IDs for the 'real'
     opcodes.

   - gh-109216(35): Fix possible memory leak in *note BUILD_MAP: 1648.

   - gh-109207(36): Fix a SystemError in ‘__repr__’ of symtable entry
     object.

   - gh-109179(37): Fix bug where the C traceback display drops notes
     from *note SyntaxError: 172.

   - gh-109118(38): Disallow nested scopes (lambdas, generator
     expressions, and comprehensions) within PEP 695 annotation scopes
     that are nested within classes.

   - gh-109156(39): Add tests for de-instrumenting instructions while
     keeping the instrumentation for lines

   - gh-109114(40): Relax the detection of the error message for invalid
     lambdas inside f-strings to not search for arbitrary replacement
     fields to avoid false positives.  Patch by Pablo Galindo

   - gh-105848(41): Add a new *note CALL_KW: 1649. opcode, used for
     calls containing keyword arguments.  Also, fix a possible crash
     when jumping over method calls in a debugger.

   - gh-109052(42): Use the base opcode when comparing code objects to
     avoid interference from instrumentation

   - gh-109118(43): Fix interpreter crash when a NameError is raised
     inside the type parameters of a generic class.

   - gh-88943(44): Improve syntax error for non-ASCII character that
     follows a numerical literal.  It now points on the invalid
     non-ASCII character, not on the valid numerical literal.

   - gh-108976(45): Fix crash that occurs after de-instrumenting a code
     object in a monitoring callback.

   - gh-108732(46): Make iteration variables of module- and class-scoped
     comprehensions visible to pdb and other tools that use
     ‘frame.f_locals’ again.

   - gh-108959(47): Fix caret placement for error locations for
     subscript and binary operations that involve non-semantic
     parentheses and spaces.  Patch by Pablo Galindo

   - gh-104584(48): Fix a crash when running with ‘PYTHONUOPS’ or *note
     -X uops: 15c. enabled and an error occurs during optimization.

   - gh-108727(49): Define ‘tp_dealloc’ for ‘CounterOptimizer_Type’.
     This fixes a segfault on deallocation.

   - gh-108520(50): Fix
     ‘multiprocessing.synchronize.SemLock.__setstate__()’ to properly
     initialize ‘multiprocessing.synchronize.SemLock._is_fork_ctx’.
     This fixes a regression when passing a SemLock across nested
     processes.

     Rename ‘multiprocessing.synchronize.SemLock.is_fork_ctx’ to
     ‘multiprocessing.synchronize.SemLock._is_fork_ctx’ to avoid
     exposing it as public API.

   - gh-108654(51): Restore locals shadowed by an inlined comprehension
     if the comprehension raises an exception.

   - gh-108488(52): Change the initialization of inline cache entries so
     that the cache entry for ‘JUMP_BACKWARD’ is initialized to zero,
     instead of the ‘adaptive_counter_warmup()’ value used for all other
     instructions.  This counter, unique among instructions, counts up
     from zero.

   - gh-108716(53): Turn off deep-freezing of code objects.  Modules are
     still frozen, so that a file system search is not needed for common
     modules.

   - gh-108614(54): Add RESUME_CHECK instruction, to avoid having to
     handle instrumentation, signals, and contexts switches in the tier
     2 execution engine.

   - gh-108487(55): Move an assert that would cause a spurious crash in
     a devious case that should only trigger deoptimization.

   - gh-106176(56): Use a ‘WeakValueDictionary’ to track the lists
     containing the modules each thread is currently importing.  This
     helps avoid a reference leak from keeping the list around longer
     than necessary.  Weakrefs are used as GC can't interrupt the
     cleanup.

   - gh-105481(57): The regen-opcode build stage was removed and its
     work is now done in regen-cases.

   - gh-107901(58): Fix missing line number on *note JUMP_BACKWARD: 6d7.
     at the end of a for loop.

   - gh-108113(59): The *note compile(): 177. built-in can now accept a
     new flag, ‘ast.PyCF_OPTIMIZED_AST’, which is similar to
     ‘ast.PyCF_ONLY_AST’ except that the returned ‘AST’ is optimized
     according to the value of the ‘optimize’ argument.

     *note ast.parse(): 18d. now accepts an optional argument ‘optimize’
     which is passed on to the *note compile(): 177. built-in.  This
     makes it possible to obtain an optimized ‘AST’.

   - gh-107971(60): Opcode IDs are generated from bytecodes.c instead of
     being hard coded in opcode.py.

   - gh-107944(61): Improve error message for function calls with bad
     keyword arguments.  Patch by Pablo Galindo

   - gh-108390(62): Raise an exception when setting a non-local event
     (‘RAISE’, ‘EXCEPTION_HANDLED’, etc.)  in
     ‘sys.monitoring.set_local_events’.

     Fixes crash when tracing in recursive calls to Python classes.

   - gh-108035(63): Remove the ‘_PyCFrame’ struct, moving the pointer to
     the current interpreter frame back to the threadstate, as it was
     for 3.10 and earlier.  The ‘_PyCFrame’ existed as a performance
     optimization for tracing.  Since PEP 669 has been implemented, this
     optimization no longer applies.

   - gh-91051(64): Fix abort / segfault when using all eight type
     watcher slots, on platforms where ‘char’ is signed by default.

   - gh-106581(65): Fix possible assertion failures and missing
     instrumentation events when ‘PYTHONUOPS’ or *note -X uops: 15c. is
     enabled.

   - gh-107526(66): Revert converting ‘vars’, ‘dir’, ‘next’, ‘getattr’,
     and ‘iter’ to argument clinic.

   - gh-84805(67): Autogenerate signature for *note METH_NOARGS: 147d.
     and *note METH_O: 14b2. extension functions.

   - gh-107758(68): Make the ‘dump_stack()’ routine used by the
     ‘lltrace’ feature (low-level interpreter debugging) robust against
     recursion by ensuring that it never calls a ‘__repr__’ method
     implemented in Python.  Also make the similar output for Tier-2
     uops appear on ‘stdout’ (instead of ‘stderr’), to match the
     ‘lltrace’ code in ceval.c.

   - gh-107659(69): Add docstrings for *note ctypes.pointer(): 164a. and
     *note ctypes.POINTER(): 164b.

   - gh-105848(70): Modify the bytecode so that the actual callable for
     a *note CALL: 6d2. is at a consistent position on the stack
     (regardless of whether or not bound-method-calling optimizations
     are active).

   - gh-107674(71): Fixed performance regression in ‘sys.settrace’.

   - gh-107724(72): In pre-release versions of 3.12, up to rc1, the
     sys.monitoring callback function for the ‘PY_THROW’ event was
     missing the third, exception argument.  That is now fixed.

   - gh-84436(73): Skip reference count modifications for many known
     immortal objects.

   - gh-107596(74): Specialize subscripting *note str: 418. objects by
     *note int: 238. indexes.

   - gh-107080(75): Trace refs builds (‘--with-trace-refs’) were
     crashing when used with isolated subinterpreters.  The problematic
     global state has been isolated to each interpreter.  Other fixing
     the crashes, this change does not affect users.

   - gh-107557(76): Generate the cases needed for the barebones tier 2
     abstract interpreter for optimization passes in CPython.

   - gh-106608(77): Make ‘_PyUOpExecutorObject’ variable length.

   - gh-100964(78): Clear generators' exception state after ‘return’ to
     break reference cycles.

   - gh-107455(79): Improve error messages when converting an
     incompatible type to *note ctypes.c_char_p: 164c, *note
     ctypes.c_wchar_p: 164d. and *note ctypes.c_void_p: 164e.

   - gh-107263(80): Increase C recursion limit for functions other than
     the main interpreter from 800 to 1500.  This should allow functions
     like ‘list.__repr__’ and ‘json.dumps’ to handle all the inputs that
     they could prior to 3.12

   - gh-104584(81): Fix an issue which caused incorrect inline caches to
     be read when running with ‘PYTHONUOPS’ or *note -X uops: 15c.
     enabled.

   - gh-104432(82): Fix potential unaligned memory access on C APIs
     involving returned sequences of ‘char *’ pointers within the *note
     grp: 5c. and *note socket: b8. modules.  These were revealed using
     a ‘-fsaniziter=alignment’ build on ARM macOS. Patch by Christopher
     Chavez.

   - gh-106078(83): Isolate ‘_decimal’ (apply PEP 687(84)).  Patch by
     Charlie Zhao.

   - gh-106898(85): Add the exception as the third argument to
     ‘PY_UNIND’ callbacks in ‘sys.monitoring’.  This makes the
     ‘PY_UNWIND’ callback consistent with the other exception handling
     callbacks.

   - gh-106895(86): Raise a ‘ValueError’ when a monitoring callback
     function returns ‘DISABLE’ for events that cannot be disabled
     locally.

   - gh-106897(87): Add a ‘RERAISE’ event to ‘sys.monitoring’, which
     occurs when an exception is reraise, either explicitly by a plain
     ‘raise’ statement, or implicitly in an ‘except’ or ‘finally’ block.

   - gh-77377(88): Ensure that multiprocessing synchronization objects
     created in a fork context are not sent to a different process
     created in a spawn context.  This changes a segfault into an
     actionable RuntimeError in the parent process.

   - gh-106931(89): Statically allocated string objects are now interned
     globally instead of per-interpreter.  This fixes a situation where
     such a string would only be interned in a single interpreter.
     Normal string objects are unaffected.

   - gh-104621(90): Unsupported modules now always fail to be imported.

   - gh-107122(91): Add *note dbm.ndbm.ndbm.clear(): 1ba. to *note
     dbm.ndbm: 2c.  Patch By Donghee Na.

   - gh-107122(92): Add *note dbm.gnu.gdbm.clear(): 1b9. to *note
     dbm.gnu: 2b.  Patch By Donghee Na.

   - gh-107015(93): The ASYNC and AWAIT tokens are removed from the
     Grammar, which removes the possibility of making ‘async’ and
     ‘await’ soft keywords when using ‘feature_version<7’ in *note
     ast.parse(): 18d.

   - gh-106917(94): Fix classmethod-style *note super(): 4a8. method
     calls (i.e., where the second argument to *note super(): 4a8, or
     the implied second argument drawn from ‘self/cls’ in the case of
     zero-arg super, is a type) when the target of the call is not a
     classmethod.

   - gh-105699(95): Python no longer crashes due an infrequent race when
     initializing per-interpreter interned strings.  The crash would
     manifest when the interpreter was finalized.

   - gh-105699(96): Python no longer crashes due to an infrequent race
     in setting ‘Py_FileSystemDefaultEncoding’ and
     ‘Py_FileSystemDefaultEncodeErrors’ (both deprecated), when
     simultaneously initializing two isolated subinterpreters.  Now they
     are only set during runtime initialization.

   - gh-106908(97): Fix various hangs, reference leaks, test failures,
     and tracing/introspection bugs when running with ‘PYTHONUOPS’ or
     *note -X uops: 15c. enabled.

   - gh-106092(98): Fix a segmentation fault caused by a use-after-free
     bug in ‘frame_dealloc’ when the trashcan delays the deallocation of
     a ‘PyFrameObject’.

   - gh-106485(99): Reduce the number of materialized instances
     dictionaries by dematerializing them when possible.

   - gh-106719(100): No longer suppress arbitrary errors in the
     ‘__annotations__’ getter and setter in the type and module types.

   - gh-106723(101): Propagate ‘frozen_modules’ to multiprocessing
     spawned process interpreters.

   - gh-104909(102): Split ‘LOAD_ATTR_INSTANCE_VALUE’ into micro-ops.

   - gh-104909(103): Split *note LOAD_GLOBAL: 164f. specializations into
     micro-ops.

   - gh-106597(104): A new debug structure of offsets has been added to
     the ‘_PyRuntimeState’ that will help out-of-process debuggers and
     profilers to obtain the offsets to relevant interpreter structures
     in a way that is agnostic of how Python was compiled and that
     doesn't require copying the headers.  Patch by Pablo Galindo

   - gh-106487(105): Allow the 'count' argument of *note str.replace():
     17f. to be a keyword.  Patch by Hugo van Kemenade.

   - gh-96844(106): Improve error message of ‘list.remove()’.  Patch by
     Donghee Na.

   - gh-81283(107): Compiler now strips indents from docstrings.  It
     reduces ‘pyc’ file size 5% when the module is heavily documented.
     This change affects to ‘__doc__’ so tools like doctest will be
     affected.

   - gh-106396(108): When the format specification of an f-string
     expression is empty, the parser now generates an empty *note
     ast.JoinedStr: 1650. node for it instead of an one-element *note
     ast.JoinedStr: 1650. with an empty string *note ast.Constant: 299.

   - gh-100288(109): Specialize *note LOAD_ATTR: 4ab. for
     non-descriptors on the class.  Adds
     ‘LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES’ and
     ‘LOAD_ATTR_NONDESCRIPTOR_NO_DICT’.

   - gh-106008(110): Fix possible reference leaks when failing to
     optimize comparisons with *note None: 641. in the bytecode
     compiler.

   - gh-106145(111): Make ‘end_lineno’ and ‘end_col_offset’ required on
     ‘type_param’ ast nodes.

   - gh-106213(112): Changed the way that Emscripten call trampolines
     work for compatibility with Wasm/JS Promise integration.

   - gh-106182(113): *note sys.getfilesystemencoding(): c27. and *note
     sys.getfilesystemencodeerrors: cb4. now return interned Unicode
     object.

   - gh-106210(114): Removed Emscripten import trampoline as it was no
     longer necessary for Pyodide.

   - gh-104584(115): Added a new, experimental, tracing optimizer and
     interpreter (a.k.a.  "tier 2").  This currently pessimizes, so
     don't use yet - this is infrastructure so we can experiment with
     optimizing passes.  To enable it, pass ‘-Xuops’ or set
     ‘PYTHONUOPS=1’.  To get debug output, set ‘PYTHONUOPSDEBUG=N’ where
     ‘N’ is a debug level (0-4, where 0 is no debug output and 4 is
     excessively verbose).

   - gh-105775(116): *note LOAD_CLOSURE: 1651. is now a pseudo-op.

   - gh-105730(117): Allow any callable other than type objects as the
     condition predicate in *note BaseExceptionGroup.split(): 1626. and
     *note BaseExceptionGroup.subgroup(): 1625.

   - gh-105979(118): Fix crash in ‘_imp.get_frozen_object()’ due to
     improper exception handling.

   - gh-106003(119): Add a new *note TO_BOOL: 1652. instruction, which
     performs boolean conversions for *note POP_JUMP_IF_TRUE: 1653,
     *note POP_JUMP_IF_FALSE: 1654, and *note UNARY_NOT: 1655. (which
     all expect exact *note bool: 434. values now).  Also, modify the
     oparg of *note COMPARE_OP: 937. to include an optional "boolean
     conversion" flag.

   - gh-98931(120): Ensure custom *note SyntaxError: 172. error messages
     are raised for invalid imports with multiple targets.  Patch by
     Pablo Galindo

   - gh-105724(121): Improve ‘assert’ error messages by providing exact
     error range.

   - gh-105908(122): Fixed bug where gh-99111(123) breaks future import
     ‘barry_as_FLUFL’ in the Python REPL.

   - gh-105840(124): Fix possible crashes when specializing function
     calls with too many ‘__defaults__’.

   - gh-105831(125): Fix an f-string bug, where using a debug expression
     (the ‘=’ sign) that appears in the last line of a file results to
     the debug buffer that holds the expression text being one character
     too small.

   - gh-105800(126): Correctly issue *note SyntaxWarning: 432. in
     f-strings if invalid sequences are used.  Patch by Pablo Galindo

   - gh-105340(127): Include the comprehension iteration variable in
     ‘locals()’ inside a module- or class-scope comprehension.

   - gh-105331(128): Raise *note ValueError: 1e3. if the ‘delay’
     argument to *note asyncio.sleep(): a3d. is a NaN (matching *note
     time.sleep(): 669.).

   - gh-105587(129): The runtime can't guarantee that immortal objects
     will not be mutated by Extensions.  Thus, this modifies
     _PyStaticObject_CheckRefcnt to warn instead of asserting.

   - gh-105564(130): Don't include artificil newlines in the ‘line’
     attribute of tokens in the APIs of the *note tokenize: e4. module.
     Patch by Pablo Galindo

   - gh-105549(131): Tokenize separately ‘NUMBER’ and ‘NAME’ tokens that
     are not ambiguous.  Patch by Pablo Galindo.

   - gh-105588(132): Fix an issue that could result in crashes when
     compiling malformed *note ast: 7. nodes.

   - gh-100987(133): Allow objects other than code objects as the
     "executable" in internal frames.  In the long term, this can help
     tools like Cython and PySpy interact more efficiently.  In the
     shorter term, it allows us to perform some optimizations more
     simply.

   - gh-105375(134): Fix bugs in the *note builtins: e. module where
     exceptions could end up being overwritten.

   - gh-105375(135): Fix bug in the compiler where an exception could
     end up being overwritten.

   - gh-105375(136): Improve error handling in
     ‘PyUnicode_BuildEncodingMap()’ where an exception could end up
     being overwritten.

   - gh-105486(137): Change the repr of ‘ParamSpec’ list of args in
     ‘types.GenericAlias’.

   - gh-105678(138): Break the ‘MAKE_FUNCTION’ instruction into two
     parts, ‘MAKE_FUNCTION’ which makes the function and
     ‘SET_FUNCTION_ATTRIBUTE’ which sets the attributes on the function.
     This makes the stack effect of ‘MAKE_FUNCTION’ regular to ease
     optimization and code generation.

   - gh-105435(139): Fix spurious newline character if file ends on a
     comment without a newline.  Patch by Pablo Galindo

   - gh-105390(140): Correctly raise *note tokenize.TokenError: 50d.
     exceptions instead of *note SyntaxError: 172. for tokenize errors
     such as incomplete input.  Patch by Pablo Galindo

   - gh-105259(141): Don't include newline character for trailing
     ‘NEWLINE’ tokens emitted in the *note tokenize: e4. module.  Patch
     by Pablo Galindo

   - gh-104635(142): Eliminate redundant *note STORE_FAST: 1656.
     instructions in the compiler.  Patch by Donghee Na and Carl Meyer.

   - gh-105324(143): Fix the main function of the *note tokenize: e4.
     module when reading from ‘sys.stdin’.  Patch by Pablo Galindo

   - gh-33092(144): Simplify and speed up interpreter for f-strings.
     Removes ‘FORMAT_VALUE’ opcode.  Add ‘CONVERT_VALUE’,
     ‘FORMAT_SIMPLE’ and ‘FORMAT_WITH_SPEC’ opcode.  Compiler emits more
     efficient sequence for each format expression.

   - gh-105229(145): Remove remaining two-codeunit superinstructions.
     All remaining superinstructions only take a single codeunit,
     simplifying instrumentation and quickening.

   - gh-105235(146): Prevent out-of-bounds memory access during
     ‘mmap.find()’ calls.

   - gh-98963(147): Restore the ability for a subclass of *note
     property: 179. to define ‘__slots__’ or otherwise be dict-less by
     ignoring failures to set a docstring on such a class.  This
     behavior had regressed in 3.12beta1.  An *note AttributeError: 326.
     where there had not previously been one was disruptive to existing
     code.

   - gh-104812(148): The "pending call" machinery now works for all
     interpreters, not just the main interpreter, and runs in all
     threads, not just the main thread.  Some calls are still only done
     in the main thread, ergo in the main interpreter.  This change does
     not affect signal handling nor the existing public C-API
     (‘Py_AddPendingCall()’), which both still only target the main
     thread.  The new functionality is meant strictly for internal use
     for now, since consequences of its use are not well understood yet
     outside some very restricted cases.  This change brings the
     capability in line with the intention when the state was made
     per-interpreter several years ago.

   - gh-105194(149): Do not escape with backslashes f-string format
     specifiers.  Patch by Pablo Galindo

   - gh-105229(150): Replace some dynamic superinstructions with single
     instruction equivalents.

   - gh-105162(151): Fixed bug in generator.close()/throw() where an
     inner iterator would be ignored when the outer iterator was
     instrumented.

   - gh-105164(152): Ensure annotations are set up correctly if the only
     annotation in a block is within a *note match: 7d8. block.  Patch
     by Jelle Zijlstra.

   - gh-105148(153): Make ‘_PyASTOptimizeState’ internal to ast_opt.c.
     Make ‘_PyAST_Optimize’ take two integers instead of a pointer to
     this struct.  This avoids the need to include pycore_compile.h in
     ast_opt.c.

   - gh-104799(154): Attributes of *note ast: 7. nodes that are lists
     now default to the empty list if omitted.  This means that some
     code that previously raised *note TypeError: 502. when the AST node
     was used will now proceed with the empty list instead.  Patch by
     Jelle Zijlstra.

   - gh-105111(155): Remove the old trashcan macros
     ‘Py_TRASHCAN_SAFE_BEGIN’ and ‘Py_TRASHCAN_SAFE_END’.  They should
     be replaced by the new macros ‘Py_TRASHCAN_BEGIN’ and
     ‘Py_TRASHCAN_END’.

   - gh-105035(156): Fix *note super(): 4a8. calls on types with custom
     *note tp_getattro: 1657. implementation (e.g.  meta-types.)

   - gh-105017(157): Show CRLF lines in the tokenize string attribute in
     both NL and NEWLINE tokens.  Patch by Marta Gómez.

   - gh-105013(158): Fix handling of multiline parenthesized lambdas in
     *note inspect.getsource(): 1528.  Patch by Pablo Galindo

   - gh-105017(159): Do not include an additional final ‘NL’ token when
     parsing files having CRLF lines.  Patch by Marta Gómez.

   - gh-104976(160): Ensure that trailing ‘DEDENT’ ‘tokenize.TokenInfo’
     objects emitted by the *note tokenize: e4. module are reported as
     in Python 3.11.  Patch by Pablo Galindo

   - gh-104972(161): Ensure that the ‘line’ attribute in
     ‘tokenize.TokenInfo’ objects in the *note tokenize: e4. module are
     always correct.  Patch by Pablo Galindo

   - gh-104955(162): Fix signature for the new *note
     __release_buffer__(): 1658. slot.  Patch by Jelle Zijlstra.

   - gh-104690(163): Starting new threads and process creation through
     *note os.fork(): 17c. during interpreter shutdown (such as from
     *note atexit: 9. handlers) is no longer supported.  It can lead to
     race condition between the main Python runtime thread freeing
     thread states while internal *note threading: d6. routines are
     trying to allocate and use the state of just created threads.  Or
     forked children trying to use the mid-shutdown runtime and thread
     state in the child process.

   - gh-104879(164): Fix crash when accessing the ‘__module__’ attribute
     of type aliases defined outside a module.  Patch by Jelle Zijlstra.

   - gh-104825(165): Tokens emitted by the *note tokenize: e4. module do
     not include an implicit ‘\n’ character in the ‘line’ attribute
     anymore.  Patch by Pablo Galindo

   - gh-104770(166): If a generator returns a value upon being closed,
     the value is now returned by *note generator.close(): 1659.

   - gh-89091(167): Raise *note RuntimeWarning: 1a2. for unawaited async
     generator methods like *note asend(): 8a7, *note athrow(): 4c6. and
     *note aclose(): 8a6.  Patch by Kumar Aditya.

   - gh-96663(168): Add a better, more introspect-able error message
     when setting attributes on classes without a ‘__dict__’ and no slot
     member for the attribute.

   - gh-93627(169): Update the Python pickle module implementation to
     match the C implementation of the pickle module.  For objects
     setting reduction methods like *note __reduce_ex__(): 151b. or
     *note __reduce__(): 9a1. to ‘None’, pickling will result in a *note
     TypeError: 502.

   - gh-101006(170): Improve error handling when read *note marshal: 80.
     data.

   - gh-91095(171): Specializes calls to most Python classes.
     Specifically, any class that inherits from ‘object’, or another
     Python class, and does not override ‘__new__’.

     The specialized instruction does the following:

       1. Creates the object (by calling ‘object.__new__’)

       2. Pushes a shim frame to the frame stack (to cleanup after
          ‘__init__’)

       3. Pushes the frame for ‘__init__’ to the frame stack

     Speeds up the instantiation of most Python classes.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/110782

   (2) https://github.com/python/cpython/issues/110752

   (3) https://github.com/python/cpython/issues/110721

   (4) https://github.com/python/cpython/issues/110696

   (5) https://github.com/python/cpython/issues/104169

   (6) https://github.com/python/cpython/issues/110688

   (7) https://github.com/python/cpython/issues/104584

   (8) https://github.com/python/cpython/issues/110514

   (9) https://github.com/python/cpython/issues/110489

   (10) https://github.com/python/cpython/issues/110455

   (11) https://github.com/python/cpython/issues/110309

   (12) https://github.com/python/cpython/issues/110259

   (13) https://github.com/python/cpython/issues/110237

   (14) https://github.com/python/cpython/issues/110164

   (15) https://github.com/python/cpython/issues/109889

   (16) https://github.com/python/cpython/issues/109853

   (17) https://github.com/python/cpython/issues/109923

   (18) https://github.com/python/cpython/issues/105716

   (19) https://github.com/python/cpython/issues/109369

   (20) https://github.com/python/cpython/issues/109823

   (21) https://github.com/python/cpython/issues/109793

   (22) https://github.com/python/cpython/issues/109719

   (23) https://github.com/python/cpython/issues/109595

   (24) https://github.com/python/cpython/issues/109627

   (25) https://github.com/python/cpython/issues/109596

   (26) https://github.com/python/cpython/issues/109496

   (27) https://github.com/python/cpython/issues/107265

   (28) https://github.com/python/cpython/issues/109371

   (29) https://github.com/python/cpython/issues/105658

   (30) https://github.com/python/cpython/issues/109219

   (31) https://github.com/python/cpython/issues/109351

   (32) https://github.com/python/cpython/issues/109341

   (33) https://github.com/python/cpython/issues/109195

   (34) https://github.com/python/cpython/issues/109256

   (35) https://github.com/python/cpython/issues/109216

   (36) https://github.com/python/cpython/issues/109207

   (37) https://github.com/python/cpython/issues/109179

   (38) https://github.com/python/cpython/issues/109118

   (39) https://github.com/python/cpython/issues/109156

   (40) https://github.com/python/cpython/issues/109114

   (41) https://github.com/python/cpython/issues/105848

   (42) https://github.com/python/cpython/issues/109052

   (43) https://github.com/python/cpython/issues/109118

   (44) https://github.com/python/cpython/issues/88943

   (45) https://github.com/python/cpython/issues/108976

   (46) https://github.com/python/cpython/issues/108732

   (47) https://github.com/python/cpython/issues/108959

   (48) https://github.com/python/cpython/issues/104584

   (49) https://github.com/python/cpython/issues/108727

   (50) https://github.com/python/cpython/issues/108520

   (51) https://github.com/python/cpython/issues/108654

   (52) https://github.com/python/cpython/issues/108488

   (53) https://github.com/python/cpython/issues/108716

   (54) https://github.com/python/cpython/issues/108614

   (55) https://github.com/python/cpython/issues/108487

   (56) https://github.com/python/cpython/issues/106176

   (57) https://github.com/python/cpython/issues/105481

   (58) https://github.com/python/cpython/issues/107901

   (59) https://github.com/python/cpython/issues/108113

   (60) https://github.com/python/cpython/issues/107971

   (61) https://github.com/python/cpython/issues/107944

   (62) https://github.com/python/cpython/issues/108390

   (63) https://github.com/python/cpython/issues/108035

   (64) https://github.com/python/cpython/issues/91051

   (65) https://github.com/python/cpython/issues/106581

   (66) https://github.com/python/cpython/issues/107526

   (67) https://github.com/python/cpython/issues/84805

   (68) https://github.com/python/cpython/issues/107758

   (69) https://github.com/python/cpython/issues/107659

   (70) https://github.com/python/cpython/issues/105848

   (71) https://github.com/python/cpython/issues/107674

   (72) https://github.com/python/cpython/issues/107724

   (73) https://github.com/python/cpython/issues/84436

   (74) https://github.com/python/cpython/issues/107596

   (75) https://github.com/python/cpython/issues/107080

   (76) https://github.com/python/cpython/issues/107557

   (77) https://github.com/python/cpython/issues/106608

   (78) https://github.com/python/cpython/issues/100964

   (79) https://github.com/python/cpython/issues/107455

   (80) https://github.com/python/cpython/issues/107263

   (81) https://github.com/python/cpython/issues/104584

   (82) https://github.com/python/cpython/issues/104432

   (83) https://github.com/python/cpython/issues/106078

   (84) https://peps.python.org/pep-0687/

   (85) https://github.com/python/cpython/issues/106898

   (86) https://github.com/python/cpython/issues/106895

   (87) https://github.com/python/cpython/issues/106897

   (88) https://github.com/python/cpython/issues/77377

   (89) https://github.com/python/cpython/issues/106931

   (90) https://github.com/python/cpython/issues/104621

   (91) https://github.com/python/cpython/issues/107122

   (92) https://github.com/python/cpython/issues/107122

   (93) https://github.com/python/cpython/issues/107015

   (94) https://github.com/python/cpython/issues/106917

   (95) https://github.com/python/cpython/issues/105699

   (96) https://github.com/python/cpython/issues/105699

   (97) https://github.com/python/cpython/issues/106908

   (98) https://github.com/python/cpython/issues/106092

   (99) https://github.com/python/cpython/issues/106485

   (100) https://github.com/python/cpython/issues/106719

   (101) https://github.com/python/cpython/issues/106723

   (102) https://github.com/python/cpython/issues/104909

   (103) https://github.com/python/cpython/issues/104909

   (104) https://github.com/python/cpython/issues/106597

   (105) https://github.com/python/cpython/issues/106487

   (106) https://github.com/python/cpython/issues/96844

   (107) https://github.com/python/cpython/issues/81283

   (108) https://github.com/python/cpython/issues/106396

   (109) https://github.com/python/cpython/issues/100288

   (110) https://github.com/python/cpython/issues/106008

   (111) https://github.com/python/cpython/issues/106145

   (112) https://github.com/python/cpython/issues/106213

   (113) https://github.com/python/cpython/issues/106182

   (114) https://github.com/python/cpython/issues/106210

   (115) https://github.com/python/cpython/issues/104584

   (116) https://github.com/python/cpython/issues/105775

   (117) https://github.com/python/cpython/issues/105730

   (118) https://github.com/python/cpython/issues/105979

   (119) https://github.com/python/cpython/issues/106003

   (120) https://github.com/python/cpython/issues/98931

   (121) https://github.com/python/cpython/issues/105724

   (122) https://github.com/python/cpython/issues/105908

   (123) https://github.com/python/cpython/issues/99111

   (124) https://github.com/python/cpython/issues/105840

   (125) https://github.com/python/cpython/issues/105831

   (126) https://github.com/python/cpython/issues/105800

   (127) https://github.com/python/cpython/issues/105340

   (128) https://github.com/python/cpython/issues/105331

   (129) https://github.com/python/cpython/issues/105587

   (130) https://github.com/python/cpython/issues/105564

   (131) https://github.com/python/cpython/issues/105549

   (132) https://github.com/python/cpython/issues/105588

   (133) https://github.com/python/cpython/issues/100987

   (134) https://github.com/python/cpython/issues/105375

   (135) https://github.com/python/cpython/issues/105375

   (136) https://github.com/python/cpython/issues/105375

   (137) https://github.com/python/cpython/issues/105486

   (138) https://github.com/python/cpython/issues/105678

   (139) https://github.com/python/cpython/issues/105435

   (140) https://github.com/python/cpython/issues/105390

   (141) https://github.com/python/cpython/issues/105259

   (142) https://github.com/python/cpython/issues/104635

   (143) https://github.com/python/cpython/issues/105324

   (144) https://github.com/python/cpython/issues/33092

   (145) https://github.com/python/cpython/issues/105229

   (146) https://github.com/python/cpython/issues/105235

   (147) https://github.com/python/cpython/issues/98963

   (148) https://github.com/python/cpython/issues/104812

   (149) https://github.com/python/cpython/issues/105194

   (150) https://github.com/python/cpython/issues/105229

   (151) https://github.com/python/cpython/issues/105162

   (152) https://github.com/python/cpython/issues/105164

   (153) https://github.com/python/cpython/issues/105148

   (154) https://github.com/python/cpython/issues/104799

   (155) https://github.com/python/cpython/issues/105111

   (156) https://github.com/python/cpython/issues/105035

   (157) https://github.com/python/cpython/issues/105017

   (158) https://github.com/python/cpython/issues/105013

   (159) https://github.com/python/cpython/issues/105017

   (160) https://github.com/python/cpython/issues/104976

   (161) https://github.com/python/cpython/issues/104972

   (162) https://github.com/python/cpython/issues/104955

   (163) https://github.com/python/cpython/issues/104690

   (164) https://github.com/python/cpython/issues/104879

   (165) https://github.com/python/cpython/issues/104825

   (166) https://github.com/python/cpython/issues/104770

   (167) https://github.com/python/cpython/issues/89091

   (168) https://github.com/python/cpython/issues/96663

   (169) https://github.com/python/cpython/issues/93627

   (170) https://github.com/python/cpython/issues/101006

   (171) https://github.com/python/cpython/issues/91095


File: python.info,  Node: Library<14>,  Next: Documentation<9>,  Prev: Core and Builtins<15>,  Up: Python 3 13 0 alpha 1

1.23.15.3 Library
.................

   - gh-110786(1): *note sysconfig: c5.'s CLI now ignores *note
     BrokenPipeError: 1030, making it exit normally if its output is
     being piped and the pipe closes.

   - gh-103480(2): The *note sysconfig: c5. module is now a package,
     instead of a single-file module.

   - gh-110733(3): Micro-optimization: Avoid calling ‘min()’, ‘max()’ in
     ‘BaseEventLoop._run_once()’.

   - gh-94597(4): Added *note asyncio.EventLoop: 165b. for use with the
     *note asyncio.run(): 449. 'loop_factory' kwarg to avoid calling the
     asyncio policy system.

   - gh-110682(5): *note runtime-checkable protocols: 40f. used to
     consider ‘__match_args__’ a protocol member in ‘__instancecheck__’
     if it was present on the protocol.  Now, this attribute is ignored
     if it is present.

   - gh-110488(6): Fix a couple of issues in *note
     pathlib.PurePath.with_name(): 165c.: a single dot was incorrectly
     considered a valid name, and in ‘PureWindowsPath’, a name with an
     NTFS alternate data stream, like ‘a:b’, was incorrectly considered
     invalid.

   - gh-110590(7): Fix a bug in ‘_sre.compile()’ where *note TypeError:
     502. would be overwritten by *note OverflowError: 84e. when the
     'code' argument was a list of non-ints.

   - gh-65052(8): Prevent *note pdb: 94. from crashing when trying to
     display undisplayable objects

   - gh-110519(9): Deprecation warning about non-integer number in *note
     gettext: 59. now always refers to the line in the user code where
     gettext function or method is used.  Previously it could refer to a
     line in ‘gettext’ code.

   - gh-89902(10): Deprecate non-standard format specifier "N" for *note
     decimal.Decimal: 27d.  It was not documented and only supported in
     the C implementation.

   - gh-110378(11): *note contextmanager(): 11d3. and *note
     asynccontextmanager(): af8. context managers now close an invalid
     underlying generator object that yields more then one value.

   - gh-106670(12): In *note pdb: 94, set convenience variable
     ‘$_exception’ for post mortem debugging.

   - gh-110365(13): Fix *note termios.tcsetattr(): 165d. bug that was
     overwriting existing errors during parsing integers from ‘term’
     list.

   - gh-109653(14): Slightly improve the import time of several
     standard-library modules by deferring imports of *note warnings:
     fa. within those modules.  Patch by Alex Waygood.

   - gh-110273(15): *note dataclasses.replace(): 165e. now raises
     TypeError instead of ValueError if specify keyword argument for a
     field declared with init=False or miss keyword argument for
     required InitVar field.

   - gh-110249(16): Add ‘--inline-caches’ flag to ‘dis’ command line.

   - gh-109653(17): Fix a Python 3.12 regression in the import time of
     *note random: a6.  Patch by Alex Waygood.

   - gh-110222(18): Add support of struct sequence objects in *note
     copy.replace(): 137.  Patched by Xuehai Pan.

   - gh-109649(19): *note multiprocessing: 86, *note concurrent.futures:
     1a, *note compileall: 19.: Replace *note os.cpu_count(): 1a7. with
     *note os.process_cpu_count(): 1a6. to select the default number of
     worker threads and processes.  Get the CPU affinity if supported.
     Patch by Victor Stinner.

   - gh-110150(20): Fix base case handling in statistics.quantiles.  Now
     allows a single data point.

   - gh-110036(21): On Windows, multiprocessing ‘Popen.terminate()’ now
     catches *note PermissionError: d10. and get the process exit code.
     If the process is still running, raise again the *note
     PermissionError: d10.  Otherwise, the process terminated as
     expected: store its exit code.  Patch by Victor Stinner.

   - gh-110038(22): Fixed an issue that caused ‘KqueueSelector.select()’
     to not return all the ready events in some cases when a file
     descriptor is registered for both read and write.

   - gh-110045(23): Update the *note symtable: c2. module to support the
     new scopes introduced by PEP 695(24).

   - gh-88402(25): Add new variables to *note
     sysconfig.get_config_vars(): ff6. on Windows: ‘LIBRARY’,
     ‘LDLIBRARY’, ‘LIBDIR’, ‘SOABI’, and ‘Py_NOGIL’.

   - gh-109631(26): *note re: a7. functions such as *note re.findall():
     ff4, *note re.split(): 282, *note re.search(): 11fd. and *note
     re.sub(): 283. which perform short repeated matches can now be
     interrupted by user.

   - gh-109653(27): Reduce the import time of *note email.utils: 47. by
     around 43%.  This results in the import time of *note
     email.message: 3b. falling by around 18%, which in turn reduces the
     import time of *note importlib.metadata: 6e. by around 6%.  Patch
     by Alex Waygood.

   - gh-109818(28): Fix *note reprlib.recursive_repr(): 11c4. not
     copying ‘__type_params__’ from decorated function.

   - gh-109047(29): *note concurrent.futures: 1a.: The 'executor manager
     thread' now catches exceptions when adding an item to the 'call
     queue'.  During Python finalization, creating a new thread can now
     raise *note RuntimeError: 17a.  Catch the exception and call
     ‘terminate_broken()’ in this case.  Patch by Victor Stinner.

   - gh-109782(30): Ensure the signature of *note os.path.isdir(): 9de.
     is identical on all platforms.  Patch by Amin Alaee.

   - gh-109653(31): Improve import time of *note functools: 55. by
     around 13%.  Patch by Alex Waygood.

   - gh-109590(32): *note shutil.which(): 480. will prefer files with an
     extension in ‘PATHEXT’ if the given mode includes ‘os.X_OK’ on
     win32.  If no ‘PATHEXT’ match is found, a file without an extension
     in ‘PATHEXT’ can be returned.  This change will have *note
     shutil.which(): 480. act more similarly to previous behavior in
     Python 3.11.

   - gh-109653(33): Reduce the import time of *note enum: 4c. by over
     50%.  Patch by Alex Waygood.

   - gh-109593(34): Avoid deadlocking on a reentrant call to the
     multiprocessing resource tracker.  Such a reentrant call, though
     unlikely, can happen if a GC pass invokes the finalizer for a
     multiprocessing object such as SemLock.

   - gh-109653(35): Reduce the import time of *note typing: ed. by
     around a third.  Patch by Alex Waygood.

   - gh-109649(36): Add *note os.process_cpu_count(): 1a6. function to
     get the number of logical CPUs usable by the calling thread of the
     current process.  Patch by Victor Stinner.

   - gh-74481(37): Add ‘set_error_mode’ related constants in ‘msvcrt’
     module in Python debug build.

   - gh-109613(38): Fix *note os.stat(): 46d. and *note
     os.DirEntry.stat(): 165f.: check for exceptions.  Previously, on
     Python built in debug mode, these functions could trigger a fatal
     Python error (and abort the process) when a function succeeded with
     an exception set.  Patch by Victor Stinner.

   - gh-109599(39): Expose the type of PyCapsule objects as
     ‘types.CapsuleType’.

   - gh-109109(40): You can now get the raw TLS certificate chains from
     TLS connections via *note ssl.SSLSocket.get_verified_chain(): 153f.
     and *note ssl.SSLSocket.get_unverified_chain(): 1540. methods.

     Contributed by Mateusz Nowak.

   - gh-109559(41): Update *note unicodedata: ee. database to Unicode
     15.1.0.

   - gh-109543(42): Remove unnecessary *note hasattr(): 49e. check
     during *note typing.TypedDict: 148. creation.

   - gh-109495(43): Remove unnecessary extra ‘__slots__’ in *note
     datetime: 1ae.'s pure python implementation to reduce memory size,
     as they are defined in the superclass.  Patch by James Hilton-Balfe

   - gh-109461(44): *note logging: 7b.: Use a context manager for lock
     acquisition.

   - gh-109096(45): *note http.server.CGIHTTPRequestHandler: 281. has
     been deprecated for removal in 3.15.  Its design is old and the web
     world has long since moved beyond CGI.

   - gh-109409(46): Fix error when it was possible to inherit a frozen
     dataclass from multiple parents some of which were possibly not
     frozen.

   - gh-109375(47): The *note pdb: 94. ‘alias’ command now prevents
     registering aliases without arguments.

   - gh-109319(48): Deprecate the ‘dis.HAVE_ARGUMENT’ field in favour of
     ‘dis.hasarg’.

   - gh-107219(49): Fix a race condition in ‘concurrent.futures’.  When
     a process in the process pool was terminated abruptly (while the
     future was running or pending), close the connection write end.  If
     the call queue is blocked on sending bytes to a worker process,
     closing the connection write end interrupts the send, so the queue
     can be closed.  Patch by Victor Stinner.

   - gh-66143(50): The *note codecs.CodecInfo: 1660. object has been
     made copyable and pickleable.  Patched by Robert Lehmann and Furkan
     Onder.

   - gh-109187(51): *note pathlib.Path.resolve(): 1661. now treats
     symlink loops like other errors: in strict mode, *note OSError:
     3f0. is raised, and in non-strict mode, no exception is raised.

   - gh-50644(52): Attempts to pickle or create a shallow or deep copy
     of *note codecs: 14. streams now raise a TypeError.  Previously,
     copying failed with a RecursionError, while pickling produced wrong
     results that eventually caused unpickling to fail with a
     RecursionError.

   - gh-109174(53): Add support of *note types.SimpleNamespace: 1b3. in
     *note copy.replace(): 137.

   - gh-109164(54): *note pdb: 94.: Replace *note getopt: 57. with *note
     argparse: 5. for parsing command line arguments.

   - gh-109151(55): Enable ‘readline’ editing features in the *note
     sqlite3 command-line interface: 40d. (‘python -m sqlite3’).

   - gh-108987(56): Fix *note _thread.start_new_thread(): 17b. race
     condition.  If a thread is created during Python finalization, the
     newly spawned thread now exits immediately instead of trying to
     access freed memory and lead to a crash.  Patch by Victor Stinner.

   - gh-108682(57): Enum: require ‘names=()’ or ‘type=...’ to create an
     empty enum using the functional syntax.

   - gh-109033(58): Exceptions raised by os.utime builtin function now
     include the related filename

   - gh-108843(59): Fix an issue in *note ast.unparse(): 8b3. when
     unparsing f-strings containing many quote types.

   - gh-108469(60): *note ast.unparse(): 8b3. now supports new *note
     f-string: 402. syntax introduced in Python 3.12.  Note that the
     *note f-string: 402. quotes are reselected for simplicity under the
     new syntax.  (Patch by Steven Sun)

   - gh-108751(61): Add *note copy.replace(): 137. function which allows
     to create a modified copy of an object.  It supports named tuples,
     dataclasses, and many other objects.

   - gh-108682(62): Enum: raise *note TypeError: 502. if
     ‘super().__new__()’ is called from a custom ‘__new__’.

   - gh-108278(63): Deprecate passing the callback callable by keyword
     for the following *note sqlite3.Connection: 226. APIs:

        * *note set_authorizer(): 28b.

        * *note set_progress_handler(): 28c.

        * *note set_trace_callback(): 28d.

     The affected parameters will become positional-only in Python 3.15.

     Patch by Erlend E. Aasland.

   - gh-105829(64): Fix concurrent.futures.ProcessPoolExecutor deadlock

   - gh-108295(65): Fix crashes related to use of weakrefs on *note
     typing.TypeVar: 143.

   - gh-108463(66): Make expressions/statements work as expected in pdb

   - gh-108277(67): Add *note os.timerfd_create(): 1f2, *note
     os.timerfd_settime(): 1f3, *note os.timerfd_gettime(): 1f5, *note
     os.timerfd_settime_ns(): 1f4, and *note os.timerfd_gettime_ns():
     1f6. to provide a low level interface for Linux's timer
     notification file descriptor.

   - gh-107811(68): *note tarfile: c8.: extraction of members with
     overly large UID or GID (e.g.  on an OS with 32-bit ‘id_t’) now
     fails in the same way as failing to set the ID.

   - gh-64662(69): Fix support for virtual tables in *note
     sqlite3.Connection.iterdump(): 228.  Patch by Aviv Palivoda.

   - gh-108111(70): Fix a regression introduced in gh-101251(71) for
     3.12, resulting in an incorrect offset calculation in
     ‘gzip.GzipFile.seek()’.

   - gh-108294(72): *note time.sleep(): 669. now raises an auditing
     event.

   - gh-108278(73): Deprecate passing name, number of arguments, and the
     callable as keyword arguments, for the following *note
     sqlite3.Connection: 226. APIs:

        * *note create_function(): 289.

        * *note create_aggregate(): 28a.

     The affected parameters will become positional-only in Python 3.15.

     Patch by Erlend E. Aasland.

   - gh-108322(74): Speed-up NormalDist.samples() by using the inverse
     CDF method instead of calling random.gauss().

   - gh-83417(75): Add the ability for venv to create a ‘.gitignore’
     file which causes the created environment to be ignored by Git.  It
     is on by default when venv is called via its CLI.

   - gh-105736(76): Harmonized the pure Python version of *note
     OrderedDict: 5a5. with the C version.  Now, both versions set up
     their internal state in ‘__new__’.  Formerly, the pure Python
     version did the set up in ‘__init__’.

   - gh-108083(77): Fix bugs in the constructor of *note
     sqlite3.Connection: 226. and *note sqlite3.Connection.close(): 227.
     where exceptions could be leaked.  Patch by Erlend E. Aasland.

   - gh-107932(78): Fix ‘dis’ module to properly report and display
     bytecode that do not have source lines.

   - gh-105539(79): *note sqlite3: ba. now emits an *note
     ResourceWarning: 225. if a *note sqlite3.Connection: 226. object is
     not ‘closed’ explicitly.  Patch by Erlend E. Aasland.

   - gh-107995(80): The ‘__module__’ attribute on instances of *note
     functools.cached_property: 50c. is now set to the name of the
     module in which the cached_property is defined, rather than
     "functools".  This means that doctests in ‘cached_property’
     docstrings are now properly collected by the *note doctest: 31.
     module.  Patch by Tyler Smart.

   - gh-107963(81): Fix *note multiprocessing.set_forkserver_preload():
     1502. to check the given list of modules names.  Patch by Donghee
     Na.

   - gh-106242(82): Fixes *note os.path.normpath(): 12e9. to handle
     embedded null characters without truncating the path.

   - gh-81555(83): *note xml.dom.minidom: 109. now only quotes ‘"’ in
     attributes.

   - gh-50002(84): *note xml.dom.minidom: 109. now preserves whitespaces
     in attributes.

   - gh-93057(85): Passing more than one positional argument to *note
     sqlite3.connect(): 288. and the *note sqlite3.Connection: 226.
     constructor is deprecated.  The remaining parameters will become
     keyword-only in Python 3.15.  Patch by Erlend E. Aasland.

   - gh-76913(86): Add 'merge_extra' parameter/feature to *note
     logging.LoggerAdapter: 12c3.

   - gh-107913(87): Fix possible losses of ‘errno’ and ‘winerror’ values
     in *note OSError: 3f0. exceptions if they were cleared or modified
     by the cleanup code before creating the exception object.

   - gh-107845(88): *note tarfile.data_filter(): 1662. now takes the
     location of symlinks into account when determining their target, so
     it will no longer reject some valid tarballs with
     ‘LinkOutsideDestinationError’.

   - gh-107812(89): Extend socket's netlink support to the FreeBSD
     platform.

   - gh-107805(90): Fix signatures of module-level generated functions
     in *note turtle: ea.

   - gh-107782(91): *note pydoc: a3. is now able to show signatures
     which are not representable in Python, e.g.  for ‘getattr’ and
     ‘dict.pop’.

   - gh-56166(92): Deprecate passing optional arguments 'maxsplit',
     'count' and 'flags' in module-level functions *note re.split():
     282, *note re.sub(): 283. and *note re.subn(): 284. as positional.
     They should only be passed by keyword.

   - gh-107710(93): Speed up *note logging.getHandlerNames(): 1663.

   - gh-107715(94): Fix *note doctest.DocTestFinder.find(): 1664. in
     presence of class names with special characters.  Patch by Gertjan
     van Zwieten.

   - gh-100814(95): Passing a callable object as an option value to a
     Tkinter image now raises the expected TclError instead of an
     AttributeError.

   - gh-72684(96): Add *note tkinter: d9. widget methods:
     ‘tk_busy_hold()’, ‘tk_busy_configure()’, ‘tk_busy_cget()’,
     ‘tk_busy_forget()’, ‘tk_busy_current()’, and ‘tk_busy_status()’.

   - gh-106684(97): Raise *note ResourceWarning: 225. when *note
     asyncio.StreamWriter: 1665. is not closed leading to memory leaks.
     Patch by Kumar Aditya.

   - gh-107465(98): Add *note pathlib.Path.from_uri(): 20b. classmethod.

   - gh-107077(99): Seems that in some conditions, OpenSSL will return
     ‘SSL_ERROR_SYSCALL’ instead of ‘SSL_ERROR_SSL’ when a certification
     verification has failed, but the error parameters will still
     contain ‘ERR_LIB_SSL’ and ‘SSL_R_CERTIFICATE_VERIFY_FAILED’.  We
     are now detecting this situation and raising the appropriate
     ‘ssl.SSLCertVerificationError’.  Patch by Pablo Galindo

   - gh-107576(100): Fix *note types.get_original_bases(): 49a. to only
     return ‘__orig_bases__’ if it is present on ‘cls’ directly.  Patch
     by James Hilton-Balfe.

   - gh-105481(101): Remove ‘opcode.is_pseudo’,
     ‘opcode.MIN_PSEUDO_OPCODE’ and ‘opcode.MAX_PSEUDO_OPCODE’, which
     were added in 3.12, were never documented and were not intended to
     be used externally.

   - gh-105481(102): ‘opcode.ENABLE_SPECIALIZATION’ (which was added in
     3.12 but never documented or intended for external usage) is moved
     to ‘_opcode.ENABLE_SPECIALIZATION’ where tests can access it.

   - gh-107396(103): tarfiles; Fixed use before assignment of
     self.exception for gzip decompression

   - gh-107409(104): Set ‘__wrapped__’ attribute in *note
     reprlib.recursive_repr(): 11c4.

   - gh-107406(105): Implement new ‘__repr__()’ method for *note
     struct.Struct: 1615.  Now it returns ‘Struct(<format repr>)’.

   - gh-107369(106): Optimize *note textwrap.indent(): 257.  It is ~30%
     faster for large input.  Patch by Inada Naoki.

   - gh-78722(107): Fix issue where *note pathlib.Path.iterdir(): 1595.
     did not raise *note OSError: 3f0. until iterated.

   - gh-105578(108): Deprecate *note typing.AnyStr: 292. in favor of the
     new Type Parameter syntax.  See PEP 695.

   - gh-62519(109): Make *note gettext.pgettext(): 9c3. search plural
     definitions when translation is not found.

   - gh-107089(110): Shelves opened with *note shelve.open(): 1666. have
     a much faster ‘clear()’ method.  Patch by James Cave.

   - gh-82500(111): Fix overflow on 32-bit systems with *note asyncio:
     8. *note os.sendfile(): add. implementation.

   - gh-83006(112): Document behavior of *note shutil.disk_usage():
     1100. for non-mounted filesystems on Unix.

   - gh-65495(113): Use lowercase ‘mail from’ and ‘rcpt to’ in
     ‘smptlib.SMTP’.

   - gh-106186(114): Do not report ‘MultipartInvariantViolationDefect’
     defect when the *note email.parser.Parser: 116f. class is used to
     parse emails with ‘headersonly=True’.

   - gh-105002(115): Fix invalid result from ‘PurePath.relative_to()’
     method when attempting to walk a "‘..’" segment in 'other' with
     'walk_up' enabled.  A *note ValueError: 1e3. exception is now
     raised in this case.

   - gh-106739(116): Add the ‘rtype_cache’ to the warning message (as an
     addition to the type of leaked objects and the number of leaked
     objects already included in the message) to make debugging leaked
     objects easier when the multiprocessing resource tracker process
     finds leaked objects at shutdown.  This helps more quickly identify
     what was leaked and/or why the leaked object was not properly
     cleaned up.

   - gh-106751(117): Optimize ‘SelectSelector.select()’ for many
     iteration case.  Patch By Donghee Na.

   - gh-106751(118): Optimize ‘_PollLikeSelector.select()’ for many
     iteration case.

   - gh-106751(119): Optimize ‘KqueueSelector.select()’ for many
     iteration case.  Patch By Donghee Na.

   - gh-106831(120): Fix potential missing ‘NULL’ check of
     ‘d2i_SSL_SESSION’ result in ‘_ssl.c’.

   - gh-105481(121): The various opcode lists in the *note dis: 30.
     module are now generated from bytecodes.c instead of explicitly
     constructed in opcode.py.

   - gh-106727(122): Make *note inspect.getsource(): 1528. smarter for
     class for same name definitions

   - gh-106789(123): Remove import of *note pprint: 9c. from *note
     sysconfig: c5.

   - gh-105726(124): Added ‘__slots__’ to *note
     contextlib.AbstractContextManager: c5b. and *note
     contextlib.AbstractAsyncContextManager: af9. so that child classes
     can use ‘__slots__’.

   - gh-106774(125): Update the bundled copy of pip to version 23.2.1.

   - gh-106751(126): *note selectors: b0.: Optimize
     ‘EpollSelector.select()’ code by moving some code outside of the
     loop.

   - gh-106752(127): Fixed several bugs in zipfile.Path, including: in
     ‘zipfile.Path.match()’, Windows separators are no longer honored
     (and never were meant to be); Fixed
     ‘name’/‘suffix’/‘suffixes’/‘stem’ operations when no filename is
     present and the Path is not at the root of the zipfile; Reworked
     glob for performance and more correct matching behavior.

   - gh-105293(128): Remove call to ‘SSL_CTX_set_session_id_context’
     during client side context creation in the *note ssl: bb. module.

   - gh-106734(129): Disable tab completion in multiline mode of *note
     pdb: 94.

   - gh-105481(130): Expose opcode metadata through ‘_opcode’.

   - gh-106670(131): Add the new ‘exceptions’ command to the Pdb
     debugger.  It makes it possible to move between chained exceptions
     when using post mortem debugging.

   - gh-106602(132): Add __copy__ and __deepcopy__ in *note enum: 4c.

   - gh-106664(133): *note selectors: b0.: Add ‘_SelectorMapping.get()’
     method and optimize ‘_SelectorMapping.__getitem__()’.

   - gh-106628(134): Speed up parsing of emails by about 20% by not
     compiling a new regular expression for every single email.

   - gh-89427(135): Set the environment variable ‘VIRTUAL_ENV_PROMPT’ at
     *note venv: f9. activation, even when ‘VIRTUAL_ENV_DISABLE_PROMPT’
     is set.

   - gh-106530(136): Revert a change to *note colorsys.rgb_to_hls():
     1667. that caused division by zero for certain almost-white inputs.
     Patch by Terry Jan Reedy.

   - gh-106584(137): Fix exit code for ‘unittest’ if all tests are
     skipped.  Patch by Egor Eliseev.

   - gh-106566(138): Optimize ‘(?!)’ (pattern which always fails) in
     regular expressions.

   - gh-106554(139): *note selectors: b0.: Reduce Selector overhead by
     using a ‘dict.get()’ to lookup file descriptors.

   - gh-106558(140): Remove ref cycle in callers of ‘convert_to_error()’
     by deleting ‘result’ from scope in a ‘finally’ block.

   - gh-100502(141): Add ‘pathlib.PurePath.pathmod’ class attribute that
     stores the implementation of *note os.path: 92. used for low-level
     path operations: either ‘posixpath’ or ‘ntpath’.

   - gh-106527(142): Reduce overhead to add and remove *note asyncio: 8.
     readers and writers.

   - gh-106524(143): Fix crash in ‘_sre.template()’ with templates
     containing invalid group indices.

   - gh-106531(144): Removed ‘_legacy’ and the names it provided from
     ‘importlib.resources’: ‘Resource’, ‘contents’, ‘is_resource’,
     ‘open_binary’, ‘open_text’, ‘path’, ‘read_binary’, and ‘read_text’.

   - gh-106052(145): *note re: a7. module: fix the matching of
     possessive quantifiers in the case of a subpattern containing
     backtracking.

   - gh-106510(146): Improve debug output for atomic groups in regular
     expressions.

   - gh-106503(147): Fix ref cycle in ‘asyncio._SelectorSocketTransport’
     by removing ‘_write_ready’ in ‘close’.

   - gh-105497(148): Fix flag mask inversion when unnamed flags exist.

   - gh-90876(149): Prevent ‘multiprocessing.spawn’ from failing to
     'import' in environments where ‘sys.executable’ is ‘None’.  This
     regressed in 3.11 with the addition of support for path-like
     objects in multiprocessing.

   - gh-106403(150): Instances of *note typing.TypeVar: 143, *note
     typing.ParamSpec: 144, *note typing.ParamSpecArgs: 791, *note
     typing.ParamSpecKwargs: 792, and *note typing.TypeVarTuple: 145.
     once again support weak references, fixing a regression introduced
     in Python 3.12.0 beta 1.  Patch by Jelle Zijlstra.

   - gh-89812(151): Add private ‘pathlib._PathBase’ class, which
     provides experimental support for virtual filesystems, and may be
     made public in a future version of Python.

   - gh-106292(152): Check for an instance-dict cached value in the
     ‘__get__()’ method of *note functools.cached_property(): 50c.  This
     better matches the pre-3.12 behavior and improves compatibility for
     users subclassing *note functools.cached_property(): 50c. and
     adding a ‘__set__()’ method.

   - gh-106350(153): Detect possible memory allocation failure in the
     libtommath function ‘mp_init()’ used by the ‘_tkinter’ module.

   - gh-106330(154): Fix incorrect matching of empty paths in *note
     pathlib.PurePath.match(): 479.  This bug was introduced in Python
     3.12.0 beta 1.

   - gh-106309(155): Deprecate *note typing.no_type_check_decorator():
     291.  No major type checker ever added support for this decorator.
     Patch by Alex Waygood.

   - gh-102541(156): Make ‘pydoc.doc()’ catch bad module *note
     ImportError: 3f2. when output stream is not ‘None’.

   - gh-106263(157): Fix crash when calling ‘repr’ with a manually
     constructed SignalDict object.  Patch by Charlie Zhao.

   - gh-106236(158): Replace ‘assert’ statements with ‘raise
     RuntimeError’ in *note threading: d6, so that ‘_DummyThread’ cannot
     be joined even with ‘-OO’.

   - gh-106238(159): Fix rare concurrency bug in lock acquisition by the
     logging package.

   - gh-106152(160): Added PY_THROW event hook for *note cProfile: 20.
     for generators

   - gh-106075(161): Added ‘asyncio.taskgroups.__all__’ to
     ‘asyncio.__all__’ for export in star imports.

   - gh-104527(162): Zipapp will now skip over appending an archive to
     itself.

   - gh-106046(163): Improve the error message from *note os.fspath():
     c21. if called on an object where ‘__fspath__’ is set to ‘None’.
     Patch by Alex Waygood.

   - gh-105987(164): Fix crash due to improper reference counting in
     *note asyncio: 8. eager task factory internal routines.

   - gh-105974(165): Fix bug where a *note typing.Protocol: 245. class
     that had one or more non-callable members would raise *note
     TypeError: 502. when *note issubclass(): 78c. was called against
     it, even if it defined a custom ‘__subclasshook__’ method.  The
     behaviour in Python 3.11 and lower - which has now been restored -
     was not to raise *note TypeError: 502. in these situations if a
     custom ‘__subclasshook__’ method was defined.  Patch by Alex
     Waygood.

   - gh-96145(166): Reverted addition of ‘json.AttrDict’.

   - gh-89812(167): Add *note pathlib.UnsupportedOperation: 208, which
     is raised instead of *note NotImplementedError: 209. when a path
     operation isn't supported.

   - gh-105808(168): Fix a regression introduced in gh-101251(169) for
     3.12, causing ‘gzip.GzipFile.flush()’ to not flush the compressor
     (nor pass along the ‘zip_mode’ argument).

   - gh-105481(170): *note stack_effect(): efd. no longer raises an
     exception if an ‘oparg’ is provided for an ‘opcode’ that doesn't
     use its arg, or when it is not provided for an ‘opcode’ that does
     use it.  In the latter case, the stack effect is returned for
     ‘oparg=0’.

   - gh-104799(171): Enable *note ast.unparse(): 8b3. to unparse
     function and class definitions created without the new
     ‘type_params’ field from PEP 695(172).  Patch by Jelle Zijlstra.

   - gh-105793(173): Add 'follow_symlinks' keyword-only argument to
     *note pathlib.Path.is_dir(): 211. and *note is_file(): 210,
     defaulting to ‘True’.

   - gh-105570(174): Deprecate two methods of creating *note
     typing.TypedDict: 148. classes with 0 fields using the functional
     syntax: ‘TD = TypedDict("TD")’ and ‘TD = TypedDict("TD", None)’.
     Both will be disallowed in Python 3.15.  To create a ‘TypedDict’
     class with 0 fields, either use ‘class TD(TypedDict): pass’ or ‘TD
     = TypedDict("TD", {})’.

   - gh-105745(175): Fix ‘webbrowser.Konqueror.open’ method.

   - gh-105733(176): *note ctypes: 22.: Deprecate undocumented
     ‘ctypes.SetPointerType()’ and ‘ctypes.ARRAY()’ functions.  Patch by
     Victor Stinner.

   - gh-105687(177): Remove deprecated ‘re.template’, ‘re.T’,
     ‘re.TEMPLATE’, ‘sre_constans.SRE_FLAG_TEMPLATE’.

   - gh-105684(178): Supporting *note asyncio.Task.set_name(): 9ab. is
     now mandatory for third party task implementations.  The
     undocumented ‘_set_task_name()’ function (deprecated since 3.8) has
     been removed.  Patch by Kumar Aditya.

   - gh-105375(179): Fix a bug in ‘_Unpickler_SetInputStream()’ where an
     exception could end up being overwritten in case of failure.

   - gh-105626(180): Change the default return value of *note
     http.client.HTTPConnection.get_proxy_response_headers(): 1668. to
     be ‘None’ and not ‘{}’.

   - gh-105375(181): Fix bugs in *note sys: c3. where exceptions could
     end up being overwritten because of deferred error handling.

   - gh-105605(182): Harden ‘pyexpat’ error handling during module
     initialisation to prevent exceptions from possibly being
     overwritten, and objects from being dereferenced twice.

   - gh-105375(183): Fix bug in *note decimal: 2e. where an exception
     could end up being overwritten.

   - gh-105375(184): Fix bugs in ‘_datetime’ where exceptions could be
     overwritten in case of module initialisation failure.

   - gh-105375(185): Fix bugs in ‘_ssl’ initialisation which could lead
     to leaked references and overwritten exceptions.

   - gh-105375(186): Fix a bug in *note array.array: 185. where an
     exception could end up being overwritten.

   - gh-105375(187): Fix bugs in ‘_ctypes’ where exceptions could end up
     being overwritten.

   - gh-105375(188): Fix a bug in the *note posix: 9b. module where an
     exception could be overwritten.

   - gh-105375(189): Fix bugs in ‘_elementtree’ where exceptions could
     be overwritten.

   - gh-105375(190): Fix bugs in *note zoneinfo: 11a. where exceptions
     could be overwritten.

   - gh-105375(191): Fix bugs in *note errno: 4d. where exceptions could
     be overwritten.

   - gh-105566(192): Deprecate creating a *note typing.NamedTuple: 290.
     class using keyword arguments to denote the fields (‘NT =
     NamedTuple("NT", x=int, y=str)’).  This will be disallowed in
     Python 3.15.  Use the class-based syntax or the functional syntax
     instead.

     Two methods of creating ‘NamedTuple’ classes with 0 fields using
     the functional syntax are also deprecated, and will be disallowed
     in Python 3.15: ‘NT = NamedTuple("NT")’ and ‘NT = NamedTuple("NT",
     None)’.  To create a ‘NamedTuple’ class with 0 fields, either use
     ‘class NT(NamedTuple): pass’ or ‘NT = NamedTuple("NT", [])’.

   - gh-105545(193): Remove deprecated in 3.11
     ‘webbrowser.MacOSXOSAScript._name’ attribute.

   - gh-105497(194): Fix flag inversion when alias/mask members exist.

   - gh-105509(195): *note typing.Annotated: 90b. is now implemented as
     an instance of ‘typing._SpecialForm’ rather than a class.  This
     should have no user-facing impact for users of the *note typing:
     ed. module public API.

   - gh-105375(196): Fix bugs in *note pickle: 95. where exceptions
     could be overwritten.

   - gh-70303(197): Emit *note FutureWarning: 3ee. from *note
     pathlib.Path.glob(): 20e. and *note rglob(): 20f. if the given
     pattern ends with "‘**’".  In a future Python release, patterns
     with this ending will match both files and directories.  Add a
     trailing slash to only match directories.

   - gh-105375(198): Fix a bug in *note sqlite3: ba. where an exception
     could be overwritten in the *note collation: 642. callback.

   - gh-105382(199): Remove 'cafile', 'capath' and 'cadefault'
     parameters of the *note urllib.request.urlopen(): 273. function,
     deprecated in Python 3.6.  Patch by Victor Stinner.

   - gh-105376(200): *note logging: 7b.: Remove undocumented and
     untested ‘Logger.warn()’ and ‘LoggerAdapter.warn()’ methods and
     ‘logging.warn()’ function.  Deprecated since Python 3.3, they were
     aliases to the *note logging.Logger.warning(): 1669. method,
     ‘logging.LoggerAdapter.warning()’ method and *note
     logging.warning(): 2d6. function.  Patch by Victor Stinner.

   - gh-105332(201): Revert pickling method from by-name back to
     by-value.

   - gh-104554(202): Add RTSPS scheme support in urllib.parse

   - gh-105292(203): Add option to *note
     traceback.format_exception_only(): 819. to recurse into the nested
     exception of a *note BaseExceptionGroup: 240.

   - gh-105280(204): Fix bug where ‘isinstance([],
     collections.abc.Mapping)’ could evaluate to ‘True’ if garbage
     collection happened at the wrong time.  The bug was caused by
     changes to the implementation of *note typing.Protocol: 245. in
     Python 3.12.

   - gh-80480(205): *note array: 6.: Add ‘'w'’ typecode that represents
     ‘Py_UCS4’.

   - gh-105239(206): Fix longstanding bug where ‘issubclass(object,
     typing.Protocol)’ would evaluate to ‘True’ in some edge cases.
     Patch by Alex Waygood.

   - gh-104310(207): In the beta 1 release we added a utility function
     for extension module authors, to use when testing their module for
     support in multiple interpreters or under a per-interpreter GIL.
     The name of that function has changed from
     ‘allowing_all_extensions’ to
     ‘_incompatible_extension_module_restrictions’.  The default for the
     "disable_check" argument has change from ‘True’ to ‘False’, to
     better match the new function name.

   - gh-105080(208): Fixed inconsistent signature on derived classes for
     *note inspect.signature(): 703.

   - gh-105144(209): Fix a recent regression in the *note typing: ed.
     module.  The regression meant that doing ‘class Foo(X,
     typing.Protocol)’, where ‘X’ was a class that had *note
     abc.ABCMeta: ee4. as its metaclass, would then cause subsequent
     ‘isinstance(1, X)’ calls to erroneously raise *note TypeError: 502.
     Patch by Alex Waygood.

   - gh-62948(210): The *note io.IOBase: 1d6. finalizer now logs the
     ‘close()’ method errors with *note sys.unraisablehook: 1d8.
     Previously, errors were ignored silently by default, and only
     logged in *note Python Development Mode: 1d9. or on *note Python
     built on debug mode: 1da.  Patch by Victor Stinner.

   - gh-105096(211): *note wave: fb.: Deprecate the ‘getmark()’,
     ‘setmark()’ and ‘getmarkers()’ methods of the *note wave.Wave_read:
     296. and *note wave.Wave_write: 297. classes.  They will be removed
     in Python 3.15.  Patch by Victor Stinner.

   - gh-104992(212): Remove the untested and undocumented
     ‘unittest.TestProgram.usageExit()’ method, deprecated in Python
     3.11.  Patch by Hugo van Kemenade.

   - gh-104996(213): Improve performance of *note pathlib.PurePath: 473.
     initialisation by deferring joining of paths when multiple
     arguments are given.

   - gh-101588(214): Deprecate undocumented copy/deepcopy/pickle support
     for itertools.

   - gh-103631(215): Fix
     ‘pathlib.PurePosixPath(pathlib.PureWindowsPath(...))’ not
     converting path separators to restore 3.11 compatible behavior.

   - gh-104947(216): Make comparisons between *note
     pathlib.PureWindowsPath: 166a. objects consistent across Windows
     and Posix to match 3.11 behavior.

   - gh-104773(217): PEP 594(218): Remove the ‘audioop’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(219): PEP 594(220): Remove the ‘aifc’ module, deprecated
     in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(221): PEP 594(222): Remove the ‘uu’ module, deprecated in
     Python 3.11.  Patch by Victor Stinner.

   - gh-104935(223): Fix bugs with the interaction between *note
     typing.runtime_checkable(): 40f. and *note typing.Generic: 157c.
     that were introduced by the PEP 695(224) implementation.  Patch by
     Jelle Zijlstra.

   - gh-104773(225): PEP 594(226): Remove the ‘crypt’ module and its
     private ‘_crypt’ extension, deprecated in Python 3.11.  Patch by
     Victor Stinner.

   - gh-104773(227): PEP 594(228): Remove the ‘nis’ module, deprecated
     in Python 3.11.  Patch by Victor Stinner.

   - gh-104898(229): Add missing *note __slots__: 1493. to *note
     os.PathLike: c1f.

   - gh-104773(230): PEP 594(231): Remove the ‘xdrlib’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(232): PEP 594(233): Remove the ‘nntplib’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104886(234): Remove the undocumented
     ‘configparser.LegacyInterpolation’ class, deprecated in the
     docstring since Python 3.2, and with a deprecation warning since
     Python 3.11.  Patch by Hugo van Kemenade.

   - gh-104786(235): Remove kwargs-based *note typing.TypedDict: 148.
     creation

   - gh-104876(236): Remove the ‘turtle.RawTurtle.settiltangle()’
     method, deprecated in docs since Python 3.1 and with a deprecation
     warning since Python 3.11.  Patch by Hugo van Kemenade.

   - gh-104773(237): PEP 594(238): Removed the ‘msilib’ package,
     deprecated in Python 3.11.

   - gh-104773(239): PEP 594(240): Remove the ‘spwd’ module, deprecated
     in Python 3.11: the python-pam(241) project can be used instead.
     Patch by Victor Stinner.

   - gh-75552(242): Removed the ‘tkinter.tix’ module, deprecated since
     Python 3.6.

   - gh-104773(243): PEP 594(244): Remove the ‘chunk’ module, deprecated
     in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(245): PEP 594(246): Remove the ‘mailcap’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(247): PEP 594(248): Remove the ‘sunau’ module, deprecated
     in Python 3.11.  Patch by Victor Stinner.

   - gh-104780(249): PEP 594(250): Remove the ‘ossaudiodev’ module,
     deprecated in Python 3.11.  Patch Victor Stinner.

   - gh-104773(251): PEP 594(252): Remove the ‘pipes’ module, deprecated
     in Python 3.11.  Patch by Victor Stinner.

   - gh-104873(253): Add *note typing.get_protocol_members(): 244. to
     return the set of members defining a *note typing.Protocol: 245.
     Add *note typing.is_protocol(): 246. to check whether a class is a
     *note typing.Protocol: 245.  Patch by Jelle Zijlstra.

   - gh-104874(254): Document the ‘__name__’ and ‘__supertype__’
     attributes of *note typing.NewType: cc3.  Patch by Jelle Zijlstra.

   - gh-104835(255): Removed the following *note unittest: ef.
     functions, deprecated in Python 3.11:

        * ‘unittest.findTestCases()’

        * ‘unittest.makeSuite()’

        * ‘unittest.getTestCaseNames()’

     Use *note TestLoader: 26e. methods instead:

        * *note unittest.TestLoader.loadTestsFromModule(): 26f.

        * *note unittest.TestLoader.loadTestsFromTestCase(): 270.

        * *note unittest.TestLoader.getTestCaseNames(): 271.

     Patch by Hugo van Kemenade.

   - gh-104804(256): Remove the untested and undocumented *note
     webbrowser: fd. ‘MacOSX’ class, deprecated in Python 3.11.  Patch
     by Hugo van Kemenade.

   - gh-83863(257): Support for using *note pathlib.Path: 20a. objects
     as context managers has been removed.  Before Python 3.9, exiting
     the context manager marked a path as "closed", which caused some
     (but not all!)  methods to raise when called.  Since Python 3.9,
     using a path as a context manager does nothing.

   - gh-104799(258): Adjust the location of the (see PEP 695(259))
     ‘type_params’ field on *note ast.ClassDef: 166b, *note
     ast.AsyncFunctionDef: 166c, and *note ast.FunctionDef: 166d. to
     better preserve backward compatibility.  Patch by Jelle Zijlstra

   - gh-104797(260): Allow *note typing.Protocol: 245. classes to
     inherit from *note collections.abc.Buffer: 2a4.  Patch by Jelle
     Zijlstra.

   - gh-104783(261): Remove ‘locale.resetlocale()’ function deprecated
     in Python 3.11.  Patch by Victor Stinner.

   - gh-104780(262): Remove the ‘2to3’ program and the ‘lib2to3’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(263): PEP 594(264): Remove the ‘telnetlib’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(265): PEP 594(266): Remove the ‘imghdr’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(267): PEP 594(268): Remove the ‘cgi’ and ‘cgitb’ modules,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104773(269): PEP 594(270): Remove the ‘sndhdr’ module,
     deprecated in Python 3.11.  Patch by Victor Stinner.

   - gh-104372(271): On Linux where *note subprocess: c1. can use the
     ‘vfork()’ syscall for faster spawning, prevent the parent process
     from blocking other threads by dropping the GIL while it waits for
     the vfork'ed child process ‘exec()’ outcome.  This prevents
     spawning a binary from a slow filesystem from blocking the rest of
     the application.

   - gh-99108(272): We now release the GIL around built-in *note
     hashlib: 5e. computations of reasonable size for the SHA families
     and MD5 hash functions, matching what our OpenSSL backed hash
     computations already does.

   - gh-102613(273): Improve performance of *note pathlib.Path.glob():
     20e. when expanding a pattern with a non-terminal "‘**’" component
     by filtering walked paths through a regular expression, rather than
     calling *note os.scandir(): a2d. more than once on each directory.

   - gh-104399(274): Prepare the ‘_tkinter’ module for building with Tcl
     9.0 and future libtommath by replacing usage of deprecated
     functions ‘mp_to_unsigned_bin_n()’ and ‘mp_unsigned_bin_size()’
     when necessary.

   - gh-102676(275): Add fields ‘start_offset’, ‘cache_offset’,
     ‘end_offset’, ‘baseopname’, ‘baseopcode’, ‘jump_target’ and ‘oparg’
     to *note dis.Instruction: 1be.

   - gh-103558(276): Fixed ‘parent’ argument validation mechanism of
     *note argparse: 5.  Improved test coverage.

   - gh-103464(277): Provide helpful usage messages when parsing
     incorrect *note pdb: 94. commands.

   - gh-103384(278): Generalize the regex pattern
     ‘BaseConfigurator.INDEX_PATTERN’ to allow spaces and
     non-alphanumeric characters in keys.

   - gh-103124(279): Added multiline statement support for *note pdb:
     94.

   - gh-101162(280): Forbid using ‘builtins.issubclass()’ with *note
     types.GenericAlias: 7b6. as the first argument.

   - gh-103200(281): Fix cache repopulation semantics of
     zipimport.invalidate_caches().  The cache is now repopulated upon
     retrieving files with an invalid cache, not when the cache is
     invalidated.

   - gh-100061(282): Fix a bug that causes wrong matches for regular
     expressions with possessive qualifier.

   - gh-77609(283): Add 'follow_symlinks' argument to *note
     pathlib.Path.glob(): 20e. and *note rglob(): 20f, defaulting to
     false.

   - gh-102541(284): Hide traceback in *note help(): 8a5. prompt, when
     import failed.

   - gh-102120(285): Added a stream mode to ‘tarfile’ that allows for
     reading archives without caching info about the inner files.

   - gh-102029(286): Deprecate passing any arguments to *note
     threading.RLock(): 2bf.

   - gh-88233(287): Refactored ‘zipfile._strip_extra’ to use higher
     level abstractions for extras instead of a heavy-state loop.

   - gh-102024(288): Reduce calls of ‘_idle_semaphore.release()’ in
     ‘concurrent.futures.thread._worker()’.

   - gh-73435(289): Add support for recursive wildcards in *note
     pathlib.PurePath.match(): 479.

   - gh-84867(290): *note unittest.TestLoader: 26e. no longer loads test
     cases from exact *note unittest.TestCase: 41a. and *note
     unittest.FunctionTestCase: 166e. classes.

   - gh-99203(291): Restore following CPython <= 3.10.5 behavior of
     *note shutil.make_archive(): 47f.: do not create an empty archive
     if ‘root_dir’ is not a directory, and, in that case, raise *note
     FileNotFoundError: e8f. or *note NotADirectoryError: 102e.
     regardless of ‘format’ choice.  Beyond the brought-back behavior,
     the function may now also raise these exceptions in ‘dry_run’ mode.

   - gh-80480(292): Emit *note DeprecationWarning: 18a. for *note array:
     6.'s ‘'u'’ type code, deprecated in docs since Python 3.3.

   - gh-94924(293): *note unittest.mock.create_autospec(): 156b. now
     properly returns coroutine functions compatible with *note
     inspect.iscoroutinefunction(): 2c5.

   - gh-94777(294): Fix hanging *note multiprocessing: 86.
     ‘ProcessPoolExecutor’ when a child process crashes while data is
     being written in the call queue.

   - gh-92871(295): Remove the ‘typing.io’ and ‘typing.re’ namespaces,
     deprecated since Python 3.8.  All items are still available from
     the main *note typing: ed. module.

   - bpo-43633(296): Improve the textual representation of IPv4-mapped
     IPv6 addresses ( RFC 4291(297) Sections 2.2, 2.5.5.2) in *note
     ipaddress: 74.  Patch by Oleksandr Pavliuk.

   - bpo-44850(298): Improve performance of *note
     operator.methodcaller(): e01. using the PEP 590(299) ‘vectorcall’
     convention.  Patch by Anthony Lee and Pieter Eendebak.

   - bpo-44185(300): *note unittest.mock.mock_open(): 166f. will call
     the ‘close()’ method of the file handle mock when it is exiting
     from the context manager.  Patch by Samet Yaslan.

   - bpo-40988(301): Improve performance of *note
     functools.singledispatchmethod: 9c0. by caching the generated
     dispatch wrapper.  Optimization suggested by frederico.  Patch by
     @mental32, Alex Waygood and Pieter Eendebak.

   - bpo-41768(302): *note unittest.mock: f0. speccing no longer calls
     class properties.  Patch by Melanie Witt.

   - bpo-18319(303): Ensure ‘gettext(msg)’ retrieve translations even if
     a plural form exists.  In other words: ‘gettext(msg) ==
     ngettext(msg, '', 1)’.

   - bpo-17013(304): Add ‘ThreadingMock’ to *note unittest.mock: f0.
     that can be used to create Mock objects that can wait until they
     are called.  Patch by Karthikeyan Singaravelan and Mario Corchero.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/110786

   (2) https://github.com/python/cpython/issues/103480

   (3) https://github.com/python/cpython/issues/110733

   (4) https://github.com/python/cpython/issues/94597

   (5) https://github.com/python/cpython/issues/110682

   (6) https://github.com/python/cpython/issues/110488

   (7) https://github.com/python/cpython/issues/110590

   (8) https://github.com/python/cpython/issues/65052

   (9) https://github.com/python/cpython/issues/110519

   (10) https://github.com/python/cpython/issues/89902

   (11) https://github.com/python/cpython/issues/110378

   (12) https://github.com/python/cpython/issues/106670

   (13) https://github.com/python/cpython/issues/110365

   (14) https://github.com/python/cpython/issues/109653

   (15) https://github.com/python/cpython/issues/110273

   (16) https://github.com/python/cpython/issues/110249

   (17) https://github.com/python/cpython/issues/109653

   (18) https://github.com/python/cpython/issues/110222

   (19) https://github.com/python/cpython/issues/109649

   (20) https://github.com/python/cpython/issues/110150

   (21) https://github.com/python/cpython/issues/110036

   (22) https://github.com/python/cpython/issues/110038

   (23) https://github.com/python/cpython/issues/110045

   (24) https://peps.python.org/pep-0695/

   (25) https://github.com/python/cpython/issues/88402

   (26) https://github.com/python/cpython/issues/109631

   (27) https://github.com/python/cpython/issues/109653

   (28) https://github.com/python/cpython/issues/109818

   (29) https://github.com/python/cpython/issues/109047

   (30) https://github.com/python/cpython/issues/109782

   (31) https://github.com/python/cpython/issues/109653

   (32) https://github.com/python/cpython/issues/109590

   (33) https://github.com/python/cpython/issues/109653

   (34) https://github.com/python/cpython/issues/109593

   (35) https://github.com/python/cpython/issues/109653

   (36) https://github.com/python/cpython/issues/109649

   (37) https://github.com/python/cpython/issues/74481

   (38) https://github.com/python/cpython/issues/109613

   (39) https://github.com/python/cpython/issues/109599

   (40) https://github.com/python/cpython/issues/109109

   (41) https://github.com/python/cpython/issues/109559

   (42) https://github.com/python/cpython/issues/109543

   (43) https://github.com/python/cpython/issues/109495

   (44) https://github.com/python/cpython/issues/109461

   (45) https://github.com/python/cpython/issues/109096

   (46) https://github.com/python/cpython/issues/109409

   (47) https://github.com/python/cpython/issues/109375

   (48) https://github.com/python/cpython/issues/109319

   (49) https://github.com/python/cpython/issues/107219

   (50) https://github.com/python/cpython/issues/66143

   (51) https://github.com/python/cpython/issues/109187

   (52) https://github.com/python/cpython/issues/50644

   (53) https://github.com/python/cpython/issues/109174

   (54) https://github.com/python/cpython/issues/109164

   (55) https://github.com/python/cpython/issues/109151

   (56) https://github.com/python/cpython/issues/108987

   (57) https://github.com/python/cpython/issues/108682

   (58) https://github.com/python/cpython/issues/109033

   (59) https://github.com/python/cpython/issues/108843

   (60) https://github.com/python/cpython/issues/108469

   (61) https://github.com/python/cpython/issues/108751

   (62) https://github.com/python/cpython/issues/108682

   (63) https://github.com/python/cpython/issues/108278

   (64) https://github.com/python/cpython/issues/105829

   (65) https://github.com/python/cpython/issues/108295

   (66) https://github.com/python/cpython/issues/108463

   (67) https://github.com/python/cpython/issues/108277

   (68) https://github.com/python/cpython/issues/107811

   (69) https://github.com/python/cpython/issues/64662

   (70) https://github.com/python/cpython/issues/108111

   (71) https://github.com/python/cpython/issues/101251

   (72) https://github.com/python/cpython/issues/108294

   (73) https://github.com/python/cpython/issues/108278

   (74) https://github.com/python/cpython/issues/108322

   (75) https://github.com/python/cpython/issues/83417

   (76) https://github.com/python/cpython/issues/105736

   (77) https://github.com/python/cpython/issues/108083

   (78) https://github.com/python/cpython/issues/107932

   (79) https://github.com/python/cpython/issues/105539

   (80) https://github.com/python/cpython/issues/107995

   (81) https://github.com/python/cpython/issues/107963

   (82) https://github.com/python/cpython/issues/106242

   (83) https://github.com/python/cpython/issues/81555

   (84) https://github.com/python/cpython/issues/50002

   (85) https://github.com/python/cpython/issues/93057

   (86) https://github.com/python/cpython/issues/76913

   (87) https://github.com/python/cpython/issues/107913

   (88) https://github.com/python/cpython/issues/107845

   (89) https://github.com/python/cpython/issues/107812

   (90) https://github.com/python/cpython/issues/107805

   (91) https://github.com/python/cpython/issues/107782

   (92) https://github.com/python/cpython/issues/56166

   (93) https://github.com/python/cpython/issues/107710

   (94) https://github.com/python/cpython/issues/107715

   (95) https://github.com/python/cpython/issues/100814

   (96) https://github.com/python/cpython/issues/72684

   (97) https://github.com/python/cpython/issues/106684

   (98) https://github.com/python/cpython/issues/107465

   (99) https://github.com/python/cpython/issues/107077

   (100) https://github.com/python/cpython/issues/107576

   (101) https://github.com/python/cpython/issues/105481

   (102) https://github.com/python/cpython/issues/105481

   (103) https://github.com/python/cpython/issues/107396

   (104) https://github.com/python/cpython/issues/107409

   (105) https://github.com/python/cpython/issues/107406

   (106) https://github.com/python/cpython/issues/107369

   (107) https://github.com/python/cpython/issues/78722

   (108) https://github.com/python/cpython/issues/105578

   (109) https://github.com/python/cpython/issues/62519

   (110) https://github.com/python/cpython/issues/107089

   (111) https://github.com/python/cpython/issues/82500

   (112) https://github.com/python/cpython/issues/83006

   (113) https://github.com/python/cpython/issues/65495

   (114) https://github.com/python/cpython/issues/106186

   (115) https://github.com/python/cpython/issues/105002

   (116) https://github.com/python/cpython/issues/106739

   (117) https://github.com/python/cpython/issues/106751

   (118) https://github.com/python/cpython/issues/106751

   (119) https://github.com/python/cpython/issues/106751

   (120) https://github.com/python/cpython/issues/106831

   (121) https://github.com/python/cpython/issues/105481

   (122) https://github.com/python/cpython/issues/106727

   (123) https://github.com/python/cpython/issues/106789

   (124) https://github.com/python/cpython/issues/105726

   (125) https://github.com/python/cpython/issues/106774

   (126) https://github.com/python/cpython/issues/106751

   (127) https://github.com/python/cpython/issues/106752

   (128) https://github.com/python/cpython/issues/105293

   (129) https://github.com/python/cpython/issues/106734

   (130) https://github.com/python/cpython/issues/105481

   (131) https://github.com/python/cpython/issues/106670

   (132) https://github.com/python/cpython/issues/106602

   (133) https://github.com/python/cpython/issues/106664

   (134) https://github.com/python/cpython/issues/106628

   (135) https://github.com/python/cpython/issues/89427

   (136) https://github.com/python/cpython/issues/106530

   (137) https://github.com/python/cpython/issues/106584

   (138) https://github.com/python/cpython/issues/106566

   (139) https://github.com/python/cpython/issues/106554

   (140) https://github.com/python/cpython/issues/106558

   (141) https://github.com/python/cpython/issues/100502

   (142) https://github.com/python/cpython/issues/106527

   (143) https://github.com/python/cpython/issues/106524

   (144) https://github.com/python/cpython/issues/106531

   (145) https://github.com/python/cpython/issues/106052

   (146) https://github.com/python/cpython/issues/106510

   (147) https://github.com/python/cpython/issues/106503

   (148) https://github.com/python/cpython/issues/105497

   (149) https://github.com/python/cpython/issues/90876

   (150) https://github.com/python/cpython/issues/106403

   (151) https://github.com/python/cpython/issues/89812

   (152) https://github.com/python/cpython/issues/106292

   (153) https://github.com/python/cpython/issues/106350

   (154) https://github.com/python/cpython/issues/106330

   (155) https://github.com/python/cpython/issues/106309

   (156) https://github.com/python/cpython/issues/102541

   (157) https://github.com/python/cpython/issues/106263

   (158) https://github.com/python/cpython/issues/106236

   (159) https://github.com/python/cpython/issues/106238

   (160) https://github.com/python/cpython/issues/106152

   (161) https://github.com/python/cpython/issues/106075

   (162) https://github.com/python/cpython/issues/104527

   (163) https://github.com/python/cpython/issues/106046

   (164) https://github.com/python/cpython/issues/105987

   (165) https://github.com/python/cpython/issues/105974

   (166) https://github.com/python/cpython/issues/96145

   (167) https://github.com/python/cpython/issues/89812

   (168) https://github.com/python/cpython/issues/105808

   (169) https://github.com/python/cpython/issues/101251

   (170) https://github.com/python/cpython/issues/105481

   (171) https://github.com/python/cpython/issues/104799

   (172) https://peps.python.org/pep-0695/

   (173) https://github.com/python/cpython/issues/105793

   (174) https://github.com/python/cpython/issues/105570

   (175) https://github.com/python/cpython/issues/105745

   (176) https://github.com/python/cpython/issues/105733

   (177) https://github.com/python/cpython/issues/105687

   (178) https://github.com/python/cpython/issues/105684

   (179) https://github.com/python/cpython/issues/105375

   (180) https://github.com/python/cpython/issues/105626

   (181) https://github.com/python/cpython/issues/105375

   (182) https://github.com/python/cpython/issues/105605

   (183) https://github.com/python/cpython/issues/105375

   (184) https://github.com/python/cpython/issues/105375

   (185) https://github.com/python/cpython/issues/105375

   (186) https://github.com/python/cpython/issues/105375

   (187) https://github.com/python/cpython/issues/105375

   (188) https://github.com/python/cpython/issues/105375

   (189) https://github.com/python/cpython/issues/105375

   (190) https://github.com/python/cpython/issues/105375

   (191) https://github.com/python/cpython/issues/105375

   (192) https://github.com/python/cpython/issues/105566

   (193) https://github.com/python/cpython/issues/105545

   (194) https://github.com/python/cpython/issues/105497

   (195) https://github.com/python/cpython/issues/105509

   (196) https://github.com/python/cpython/issues/105375

   (197) https://github.com/python/cpython/issues/70303

   (198) https://github.com/python/cpython/issues/105375

   (199) https://github.com/python/cpython/issues/105382

   (200) https://github.com/python/cpython/issues/105376

   (201) https://github.com/python/cpython/issues/105332

   (202) https://github.com/python/cpython/issues/104554

   (203) https://github.com/python/cpython/issues/105292

   (204) https://github.com/python/cpython/issues/105280

   (205) https://github.com/python/cpython/issues/80480

   (206) https://github.com/python/cpython/issues/105239

   (207) https://github.com/python/cpython/issues/104310

   (208) https://github.com/python/cpython/issues/105080

   (209) https://github.com/python/cpython/issues/105144

   (210) https://github.com/python/cpython/issues/62948

   (211) https://github.com/python/cpython/issues/105096

   (212) https://github.com/python/cpython/issues/104992

   (213) https://github.com/python/cpython/issues/104996

   (214) https://github.com/python/cpython/issues/101588

   (215) https://github.com/python/cpython/issues/103631

   (216) https://github.com/python/cpython/issues/104947

   (217) https://github.com/python/cpython/issues/104773

   (218) https://peps.python.org/pep-0594/

   (219) https://github.com/python/cpython/issues/104773

   (220) https://peps.python.org/pep-0594/

   (221) https://github.com/python/cpython/issues/104773

   (222) https://peps.python.org/pep-0594/

   (223) https://github.com/python/cpython/issues/104935

   (224) https://peps.python.org/pep-0695/

   (225) https://github.com/python/cpython/issues/104773

   (226) https://peps.python.org/pep-0594/

   (227) https://github.com/python/cpython/issues/104773

   (228) https://peps.python.org/pep-0594/

   (229) https://github.com/python/cpython/issues/104898

   (230) https://github.com/python/cpython/issues/104773

   (231) https://peps.python.org/pep-0594/

   (232) https://github.com/python/cpython/issues/104773

   (233) https://peps.python.org/pep-0594/

   (234) https://github.com/python/cpython/issues/104886

   (235) https://github.com/python/cpython/issues/104786

   (236) https://github.com/python/cpython/issues/104876

   (237) https://github.com/python/cpython/issues/104773

   (238) https://peps.python.org/pep-0594/

   (239) https://github.com/python/cpython/issues/104773

   (240) https://peps.python.org/pep-0594/

   (241) https://pypi.org/project/python-pam/

   (242) https://github.com/python/cpython/issues/75552

   (243) https://github.com/python/cpython/issues/104773

   (244) https://peps.python.org/pep-0594/

   (245) https://github.com/python/cpython/issues/104773

   (246) https://peps.python.org/pep-0594/

   (247) https://github.com/python/cpython/issues/104773

   (248) https://peps.python.org/pep-0594/

   (249) https://github.com/python/cpython/issues/104780

   (250) https://peps.python.org/pep-0594/

   (251) https://github.com/python/cpython/issues/104773

   (252) https://peps.python.org/pep-0594/

   (253) https://github.com/python/cpython/issues/104873

   (254) https://github.com/python/cpython/issues/104874

   (255) https://github.com/python/cpython/issues/104835

   (256) https://github.com/python/cpython/issues/104804

   (257) https://github.com/python/cpython/issues/83863

   (258) https://github.com/python/cpython/issues/104799

   (259) https://peps.python.org/pep-0695/

   (260) https://github.com/python/cpython/issues/104797

   (261) https://github.com/python/cpython/issues/104783

   (262) https://github.com/python/cpython/issues/104780

   (263) https://github.com/python/cpython/issues/104773

   (264) https://peps.python.org/pep-0594/

   (265) https://github.com/python/cpython/issues/104773

   (266) https://peps.python.org/pep-0594/

   (267) https://github.com/python/cpython/issues/104773

   (268) https://peps.python.org/pep-0594/

   (269) https://github.com/python/cpython/issues/104773

   (270) https://peps.python.org/pep-0594/

   (271) https://github.com/python/cpython/issues/104372

   (272) https://github.com/python/cpython/issues/99108

   (273) https://github.com/python/cpython/issues/102613

   (274) https://github.com/python/cpython/issues/104399

   (275) https://github.com/python/cpython/issues/102676

   (276) https://github.com/python/cpython/issues/103558

   (277) https://github.com/python/cpython/issues/103464

   (278) https://github.com/python/cpython/issues/103384

   (279) https://github.com/python/cpython/issues/103124

   (280) https://github.com/python/cpython/issues/101162

   (281) https://github.com/python/cpython/issues/103200

   (282) https://github.com/python/cpython/issues/100061

   (283) https://github.com/python/cpython/issues/77609

   (284) https://github.com/python/cpython/issues/102541

   (285) https://github.com/python/cpython/issues/102120

   (286) https://github.com/python/cpython/issues/102029

   (287) https://github.com/python/cpython/issues/88233

   (288) https://github.com/python/cpython/issues/102024

   (289) https://github.com/python/cpython/issues/73435

   (290) https://github.com/python/cpython/issues/84867

   (291) https://github.com/python/cpython/issues/99203

   (292) https://github.com/python/cpython/issues/80480

   (293) https://github.com/python/cpython/issues/94924

   (294) https://github.com/python/cpython/issues/94777

   (295) https://github.com/python/cpython/issues/92871

   (296) https://bugs.python.org/issue?@action=redirect&bpo=43633

   (297) https://datatracker.ietf.org/doc/html/rfc4291.html

   (298) https://bugs.python.org/issue?@action=redirect&bpo=44850

   (299) https://peps.python.org/pep-0590/

   (300) https://bugs.python.org/issue?@action=redirect&bpo=44185

   (301) https://bugs.python.org/issue?@action=redirect&bpo=40988

   (302) https://bugs.python.org/issue?@action=redirect&bpo=41768

   (303) https://bugs.python.org/issue?@action=redirect&bpo=18319

   (304) https://bugs.python.org/issue?@action=redirect&bpo=17013


File: python.info,  Node: Documentation<9>,  Next: Tests<12>,  Prev: Library<14>,  Up: Python 3 13 0 alpha 1

1.23.15.4 Documentation
.......................

   - gh-109209(1): The minimum Sphinx version required for the
     documentation is now 4.2.

   - gh-108826(2): *note dis: 30. module command-line interface is now
     mentioned in documentation.

   - gh-107305(3): Add documentation for *note PyInterpreterConfig: 539.
     and *note Py_NewInterpreterFromConfig(): 428.  Also clarify some of
     the nearby docs relative to per-interpreter GIL.

   - gh-107008(4): Document the *note curses: 23. module variables *note
     LINES: 1671. and *note COLS: 1672.

   - gh-106948(5): Add a number of standard external names to
     ‘nitpick_ignore’.

   - gh-106232(6): Make timeit doc command lines compatible with Windows
     by using double quotes for arguments.  This works on linux and
     macOS also.

   - gh-105172(7): Fixed *note functools.lru_cache(): 9bd. docstring
     accounting for ‘typed’ argument's different handling of str and
     int.  Patch by Bar Harel.

   - gh-105052(8): Update ‘timeit’ doc to specify that time in seconds
     is just the default.

   - gh-89455(9): Add missing documentation for the ‘max_group_depth’
     and ‘max_group_width’ parameters and the ‘exceptions’ attribute of
     the *note traceback.TracebackException: 23d. class.

   - gh-89412(10): Add missing documentation for the ‘end_lineno’ and
     ‘end_offset’ attributes of the *note traceback.TracebackException:
     23d. class.

   - gh-104943(11): Remove mentions of old Python versions in *note
     typing.NamedTuple: 290.

   - gh-54738(12): Add documentation on how to localize the *note
     argparse: 5. module.

   - gh-102823(13): Document the return type of ‘x // y’ when ‘x’ and
     ‘y’ have type *note float: 2ce.

   - gh-102759(14): Align function signature for ‘functools.reduce’ in
     documentation and docstring with the C implementation.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109209

   (2) https://github.com/python/cpython/issues/108826

   (3) https://github.com/python/cpython/issues/107305

   (4) https://github.com/python/cpython/issues/107008

   (5) https://github.com/python/cpython/issues/106948

   (6) https://github.com/python/cpython/issues/106232

   (7) https://github.com/python/cpython/issues/105172

   (8) https://github.com/python/cpython/issues/105052

   (9) https://github.com/python/cpython/issues/89455

   (10) https://github.com/python/cpython/issues/89412

   (11) https://github.com/python/cpython/issues/104943

   (12) https://github.com/python/cpython/issues/54738

   (13) https://github.com/python/cpython/issues/102823

   (14) https://github.com/python/cpython/issues/102759


File: python.info,  Node: Tests<12>,  Next: Build<14>,  Prev: Documentation<9>,  Up: Python 3 13 0 alpha 1

1.23.15.5 Tests
...............

   - gh-110647(1): Fix test_stress_modifying_handlers() of test_signal.
     Patch by Victor Stinner.

   - gh-103053(2): Fix test_tools.test_freeze on FreeBSD: run "make
     distclean" instead of "make clean" in the copied source directory
     to remove also the "python" program.  Patch by Victor Stinner.

   - gh-110167(3): Fix a deadlock in test_socket when server fails with
     a timeout but the client is still running in its thread.  Don't
     hold a lock to call cleanup functions in doCleanups().  One of the
     cleanup function waits until the client completes, whereas the
     client could deadlock if it called addCleanup() in such situation.
     Patch by Victor Stinner.

   - gh-110388(4): Add tests for *note tty: e9.

   - gh-81002(5): Add tests for *note termios: ca.

   - gh-110367(6): regrtest: When using worker processes (-jN) with
     -verbose3 option, regrtest can now display the worker output even
     if a worker process does crash.  Previously, sys.stdout and
     sys.stderr were replaced and so the worker output was lost on a
     crash.  Patch by Victor Stinner.

   - gh-110267(7): Add tests for pickling and copying PyStructSequence
     objects.  Patched by Xuehai Pan.

   - gh-110171(8): ‘libregrtest’ now always sets and shows
     ‘random.seed’, so tests are more reproducible.  Use ‘--randseed’
     flag to pass the explicit random seed for tests.

   - gh-110152(9): Remove ‘Tools/scripts/run_tests.py’ and ‘make
     hostrunnertest’.  Just run ‘./python -m test --slow-ci’, ‘make
     buildbottest’ or ‘make test’ instead.  Python test runner
     (regrtest) now handles cross-compilation and HOSTRUNNER. It also
     adds options to Python such fast ‘-u -E -W default -bb’ when
     ‘--fast-ci’ or ‘--slow-ci’ option is used.  Patch by Victor
     Stinner.

   - gh-110031(10): Skip test_threading tests using thread+fork if
     Python is built with Address Sanitizer (ASAN). Patch by Victor
     Stinner.

   - gh-110088(11): Fix test_asyncio timeouts: don't measure the maximum
     duration, a test should not measure a CI performance.  Only measure
     the minimum duration when a task has a timeout or delay.  Add
     ‘CLOCK_RES’ to ‘test_asyncio.utils’.  Patch by Victor Stinner.

   - gh-109974(12): Fix race conditions in test_threading lock tests.
     Wait until a condition is met rather than using *note time.sleep():
     669. with a hardcoded number of seconds.  Patch by Victor Stinner.

   - gh-110033(13): Fix ‘test_interprocess_signal()’ of ‘test_signal’.
     Make sure that the ‘subprocess.Popen’ object is deleted before the
     test raising an exception in a signal handler.  Otherwise,
     ‘Popen.__del__()’ can get the exception which is logged as
     ‘Exception ignored in: ...’ and the test fails.  Patch by Victor
     Stinner.

   - gh-109594(14): Fix test_timeout() of
     test_concurrent_futures.test_wait.  Remove the future which may or
     may not complete depending if it takes longer than the timeout or
     not.  Keep the second future which does not complete before wait()
     timeout.  Patch by Victor Stinner.

   - gh-109972(15): Split test_gdb.py file into a test_gdb package made
     of multiple tests, so tests can now be run in parallel.  Patch by
     Victor Stinner.

   - gh-109566(16): regrtest: When ‘--fast-ci’ or ‘--slow-ci’ option is
     used, regrtest now replaces the current process with a new process
     to add ‘-u -W default -bb -E’ options to Python.  Patch by Victor
     Stinner.

   - gh-109748(17): Fix ‘test_zippath_from_non_installed_posix()’ of
     test_venv: don't copy ‘__pycache__/’ sub-directories, because they
     can be modified by other Python tests running in parallel.  Patch
     by Victor Stinner.

   - gh-109739(18): regrtest: Fix reference leak check on Windows.
     Disable the load tracker on Windows in the reference leak check
     mode (-R option).  Patch by Victor Stinner.

   - gh-109276(19): regrtest: When a test fails with "env changed" and
     the -rerun option is used, the test is now re-run in verbose mode
     in a fresh process.  Patch by Victor Stinner.

   - gh-103053(20): Skip test_freeze_simple_script() of
     test_tools.test_freeze if Python is built with ‘./configure
     --enable-optimizations’, which means with Profile Guided
     Optimization (PGO): it just makes the test too slow.  The freeze
     tool is tested by many other CIs with other (faster) compiler
     flags.  Patch by Victor Stinner.

   - gh-109580(21): Skip ‘test_perf_profiler’ if Python is built with
     ASAN, MSAN or UBSAN sanitizer.  Python does crash randomly in this
     test on such build.  Patch by Victor Stinner.

   - gh-109566(22): regrtest: Add ‘--fast-ci’ and ‘--slow-ci’ options.
     ‘--fast-ci’ uses a default timeout of 10 minutes and ‘-u all,-cpu’
     (skip slowest tests).  ‘--slow-ci’ uses a default timeout of 20
     minutes and ‘-u all’ (run all tests).  Patch by Victor Stinner.

   - gh-109425(23): libregrtest now decodes stdout of test worker
     processes with the "backslashreplace" error handler to log
     corrupted stdout, instead of failing with an error and not logging
     the stdout.  Patch by Victor Stinner.

   - gh-109396(24): Fix ‘test_socket.test_hmac_sha1()’ in FIPS mode.
     Use a longer key: FIPS mode requires at least of at least 112 bits.
     The previous key was only 32 bits.  Patch by Victor Stinner.

   - gh-104736(25): Fix test_gdb on Python built with LLVM clang 16 on
     Linux ppc64le (ex: Fedora 38).  Search patterns in gdb "bt" command
     output to detect when gdb fails to retrieve the traceback.  For
     example, skip a test if ‘Backtrace stopped: frame did not save the
     PC’ is found.  Patch by Victor Stinner.

   - gh-109276(26): libregrtest now calls *note random.seed(): 1245.
     before running each test file when ‘-r/--randomize’ command line
     option is used.  Moreover, it's also called in worker processes.
     It should help to make tests more deterministic.  Previously, it
     was only called once in the main process before running all test
     files and it was not called in worker processes.  Patch by Victor
     Stinner.

   - gh-109276(27): libregrtest now uses a separated file descriptor to
     write test result as JSON. Previously, if a test wrote debug
     messages late around the JSON, the main test process failed to
     parse JSON. Patch by Victor Stinner.

   - gh-108996(28): Fix and enable ‘test_msvcrt’.

   - gh-109237(29): Fix ‘test_site.test_underpth_basic()’ when the
     working directory contains at least one non-ASCII character: encode
     the ‘._pth’ file to UTF-8 and enable the UTF-8 Mode to use UTF-8
     for the child process stdout.  Patch by Victor Stinner.

   - gh-109230(30): Fix ‘test_pyexpat.test_exception()’: it can now be
     run from a directory different than Python source code directory.
     Before, the test failed in this case.  Skip the test if
     Modules/pyexpat.c source is not available.  Skip also the test on
     Python implementations other than CPython.  Patch by Victor
     Stinner.

   - gh-108996(31): Add tests for ‘msvcrt’.

   - gh-109015(32): Fix test_asyncio, test_imaplib and test_socket tests
     on FreeBSD if the TCP blackhole is enabled (‘sysctl
     net.inet.tcp.blackhole’).  Skip the few tests which failed with
     ‘ETIMEDOUT’ which such non standard configuration.  Currently, the
     FreeBSD GCP image enables TCP and UDP blackhole(33) (‘sysctl
     net.inet.tcp.blackhole=2’ and ‘sysctl net.inet.udp.blackhole=1’).
     Patch by Victor Stinner.

   - gh-91960(34): Skip ‘test_gdb’ if gdb is unable to retrieve Python
     frame objects: if a frame is ‘<optimized out>’.  When Python is
     built with "clang -Og", gdb can fail to retrieve the 'frame'
     parameter of ‘_PyEval_EvalFrameDefault()’.  In this case, tests
     like ‘py_bt()’ are likely to fail.  Without getting access to
     Python frames, ‘python-gdb.py’ is mostly clueless on retrieving the
     Python traceback.  Moreover, ‘test_gdb’ is no longer skipped on
     macOS if Python is built with Clang.  Patch by Victor Stinner.

   - gh-108962(35): Skip ‘test_tempfile.test_flags()’ if ‘chflags()’
     fails with "OSError: [Errno 45] Operation not supported" (ex: on
     FreeBSD 13).  Patch by Victor Stinner.

   - gh-91960(36): FreeBSD 13.2 CI coverage for pull requests is now
     provided by Cirrus-CI (a hosted CI service that supports Linux,
     macOS, Windows, and FreeBSD).

   - gh-89392(37): Removed support of ‘test_main()’ function in tests.
     They now always use normal unittest test runner.

   - gh-108851(38): Fix ‘test_tomllib’ recursion tests for WASI
     buildbots: reduce the recursion limit and compute the maximum
     nested array/dict depending on the current available recursion
     limit.  Patch by Victor Stinner.

   - gh-108851(39): Add ‘get_recursion_available()’ and
     ‘get_recursion_depth()’ functions to the *note test.support: cd.
     module.  Patch by Victor Stinner.

   - gh-108834(40): Add ‘--fail-rerun option’ option to regrtest: if a
     test failed when then passed when rerun in verbose mode, exit the
     process with exit code 2 (error), instead of exit code 0 (success).
     Patch by Victor Stinner.

   - gh-108834(41): Rename regrtest ‘--verbose2’ option (‘-w’) to
     ‘--rerun’.  Keep ‘--verbose2’ as a deprecated alias.  Patch by
     Victor Stinner.

   - gh-108834(42): When regrtest reruns failed tests in verbose mode
     (‘./python -m test --rerun’), tests are now rerun in fresh worker
     processes rather than being executed in the main process.  If a
     test does crash or is killed by a timeout, the main process can
     detect and handle the killed worker process.  Tests are rerun in
     parallel if the ‘-jN’ option is used to run tests in parallel.
     Patch by Victor Stinner.

   - gh-108822(43): ‘regrtest’ now computes statistics on all tests:
     successes, failures and skipped.  ‘test_netrc’,
     ‘test_pep646_syntax’ and ‘test_xml_etree’ now return results in
     their ‘test_main()’ function.  Patch by Victor Stinner and Alex
     Waygood.

   - gh-108794(44): The *note doctest.DocTestRunner.run(): 1c0. method
     now counts the number of skipped tests.  Add *note
     doctest.DocTestRunner.skips: 1c1. and *note
     doctest.TestResults.skipped: 1c2. attributes.  Patch by Victor
     Stinner.

   - gh-108388(45): Convert test_concurrent_futures to a package of 7
     sub-tests.  Patch by Victor Stinner.

   - gh-108388(46): Split test_multiprocessing_fork,
     test_multiprocessing_forkserver and test_multiprocessing_spawn into
     test packages.  Each package is made of 4 sub-tests: processes,
     threads, manager and misc.  It allows running more tests in
     parallel and so reduce the total test duration.  Patch by Victor
     Stinner.

   - gh-105776(47): Fix test_cppext when the C compiler command
     ‘-std=c11’ option: remove ‘-std=’ options from the compiler
     command.  Patch by Victor Stinner.

   - gh-107652(48): Set up CIFuzz to run fuzz targets in GitHub Actions.
     Patch by Illia Volochii.

   - gh-107237(49): ‘test_logging’: Fix ‘test_udp_reconnection()’ by
     increasing the timeout from 100 ms to 5 minutes (LONG_TIMEOUT).
     Patch by Victor Stinner.

   - gh-107178(50): Add the C API test for functions in the Mapping
     Protocol, the Sequence Protocol and some functions in the Object
     Protocol.

   - gh-106714(51): test_capi: Fix test_no_FatalError_infinite_loop() to
     no longer write a coredump, by using
     test.support.SuppressCrashReport.  Patch by Victor Stinner.

   - gh-104090(52): Avoid creating a reference to the test object in
     *note collectedDurations(): 1674.

   - gh-106752(53): Moved tests for ‘zipfile.Path’ into
     ‘Lib/test/test_zipfile/_path’.  Made ‘zipfile._path’ a package.

   - gh-106690(54): Add .coveragerc to cpython repository for use with
     coverage package.

   - gh-101634(55): When running the Python test suite with ‘-jN’
     option, if a worker stdout cannot be decoded from the locale
     encoding report a failed testn so the exitcode is non-zero.  Patch
     by Victor Stinner.

   - gh-105084(56): When the Python build is configured
     ‘--with-wheel-pkg-dir’, tests requiring the ‘setuptools’ and
     ‘wheel’ wheels will search for the wheels in ‘WHEEL_PKG_DIR’.

   - gh-81005(57): String tests are modified to reflect that ‘str’ and
     ‘unicode’ are merged in Python 3.  Patch by Daniel Fortunov.

   - gh-103186(58): Suppress and assert expected RuntimeWarnings in
     test_sys_settrace.py

   - gh-69714(59): Add additional tests to *note calendar: 10. to
     achieve full test coverage.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/110647

   (2) https://github.com/python/cpython/issues/103053

   (3) https://github.com/python/cpython/issues/110167

   (4) https://github.com/python/cpython/issues/110388

   (5) https://github.com/python/cpython/issues/81002

   (6) https://github.com/python/cpython/issues/110367

   (7) https://github.com/python/cpython/issues/110267

   (8) https://github.com/python/cpython/issues/110171

   (9) https://github.com/python/cpython/issues/110152

   (10) https://github.com/python/cpython/issues/110031

   (11) https://github.com/python/cpython/issues/110088

   (12) https://github.com/python/cpython/issues/109974

   (13) https://github.com/python/cpython/issues/110033

   (14) https://github.com/python/cpython/issues/109594

   (15) https://github.com/python/cpython/issues/109972

   (16) https://github.com/python/cpython/issues/109566

   (17) https://github.com/python/cpython/issues/109748

   (18) https://github.com/python/cpython/issues/109739

   (19) https://github.com/python/cpython/issues/109276

   (20) https://github.com/python/cpython/issues/103053

   (21) https://github.com/python/cpython/issues/109580

   (22) https://github.com/python/cpython/issues/109566

   (23) https://github.com/python/cpython/issues/109425

   (24) https://github.com/python/cpython/issues/109396

   (25) https://github.com/python/cpython/issues/104736

   (26) https://github.com/python/cpython/issues/109276

   (27) https://github.com/python/cpython/issues/109276

   (28) https://github.com/python/cpython/issues/108996

   (29) https://github.com/python/cpython/issues/109237

   (30) https://github.com/python/cpython/issues/109230

   (31) https://github.com/python/cpython/issues/108996

   (32) https://github.com/python/cpython/issues/109015

   (33) https://reviews.freebsd.org/D41751

   (34) https://github.com/python/cpython/issues/91960

   (35) https://github.com/python/cpython/issues/108962

   (36) https://github.com/python/cpython/issues/91960

   (37) https://github.com/python/cpython/issues/89392

   (38) https://github.com/python/cpython/issues/108851

   (39) https://github.com/python/cpython/issues/108851

   (40) https://github.com/python/cpython/issues/108834

   (41) https://github.com/python/cpython/issues/108834

   (42) https://github.com/python/cpython/issues/108834

   (43) https://github.com/python/cpython/issues/108822

   (44) https://github.com/python/cpython/issues/108794

   (45) https://github.com/python/cpython/issues/108388

   (46) https://github.com/python/cpython/issues/108388

   (47) https://github.com/python/cpython/issues/105776

   (48) https://github.com/python/cpython/issues/107652

   (49) https://github.com/python/cpython/issues/107237

   (50) https://github.com/python/cpython/issues/107178

   (51) https://github.com/python/cpython/issues/106714

   (52) https://github.com/python/cpython/issues/104090

   (53) https://github.com/python/cpython/issues/106752

   (54) https://github.com/python/cpython/issues/106690

   (55) https://github.com/python/cpython/issues/101634

   (56) https://github.com/python/cpython/issues/105084

   (57) https://github.com/python/cpython/issues/81005

   (58) https://github.com/python/cpython/issues/103186

   (59) https://github.com/python/cpython/issues/69714


File: python.info,  Node: Build<14>,  Next: Windows<11>,  Prev: Tests<12>,  Up: Python 3 13 0 alpha 1

1.23.15.6 Build
...............

   - gh-103053(1): "make check-clean-src" now also checks if the
     "python" program is found in the source directory: fail with an
     error if it does exist.  Patch by Victor Stinner.

   - gh-109191(2): Fix compile error when building with recent versions
     of libedit.

   - gh-110276(3): No longer ignore *note PROFILE_TASK: 1676. failure
     silently: command used by Profile Guided Optimization (PGO). Patch
     by Victor Stinner.

   - gh-109566(4): Remove ‘make testall’ target: use ‘make buildbottest’
     instead.  Patch by Victor Stinner.

   - gh-109740(5): The experimental ‘--disable-gil’ configure flag now
     includes "t" (for "threaded") in extension ABI tags.

   - gh-109054(6): Fix building the ‘_testcapi’ extension on Linux
     AArch64 which requires linking to libatomic when
     ‘<cpython/pyatomic.h>’ is used: the ‘_Py_atomic_or_uint64()’
     function requires libatomic ‘__atomic_fetch_or_8()’ on this
     platform.  The configure script now checks if linking to libatomic
     is needed and generates a new LIBATOMIC variable used to build the
     _testcapi extension.  Patch by Victor Stinner.

   - gh-63760(7): Fix Solaris build: no longer redefine the
     ‘gethostname()’ function.  Solaris defines the function since 2005.
     Patch by Victor Stinner, original patch by Jakub Kulík.

   - gh-108740(8): Fix a race condition in ‘make regen-all’.  The
     ‘deepfreeze.c’ source and files generated by Argument Clinic are
     now generated or updated before generating "global objects".
     Previously, some identifiers may miss depending on the order in
     which these files were generated.  Patch by Victor Stinner.

   - gh-108634(9): Python built with ‘configure’ *note -with-trace-refs:
     36e. (tracing references) is now ABI compatible with Python release
     build and *note debug build: 1da.  Patch by Victor Stinner.

   - gh-85283(10): The ‘_stat’ C extension is now built with the *note
     limited C API: 36f.  Patch by Victor Stinner.

   - gh-108447(11): Fix x86_64 GNU/Hurd build

   - gh-107814(12): When calling ‘find_python.bat’ with ‘-q’ it did not
     properly silence the output of nuget.  That is now fixed.

   - gh-105481(13): Remove the make target ‘regen-opcode-targets’, merge
     its work into ‘regen-opcode’ which repeats most of the calculation.
     This simplifies the code for the build and reduces code
     duplication.

   - gh-106881(14): Check for ‘linux/limits.h’ before including it in
     ‘Modules/posixmodule.c’.

   - gh-95855(15): Refactor platform triplet detection code and add
     detection for MIPS soft float and musl libc.

   - gh-106962(16): Detect MPI compilers in ‘configure’.

   - gh-106118(17): Fix compilation for platforms without ‘O_CLOEXEC’.
     The issue was introduced with Python 3.12b1 in gh-103295(18).
     Patch by Erlend Aasland.

   - gh-105875(19): SQLite 3.15.2 or newer is required to build the
     *note sqlite3: ba. extension module.  Patch by Erlend Aasland.

   - gh-90005(20): Fix a regression in ‘configure’ where we could end up
     unintentionally linking with ‘libbsd’.

   - gh-102404(21): Document how to perform a WASI build on Linux.  Also
     add Tools/wasm/build_wasi.sh as a reference implementation of the
     docs.

   - gh-89886(22): Autoconf 2.71 and aclocal 1.16.4 is now required to
     regenerate ‘!configure’.

   - gh-104692(23): Include ‘commoninstall’ as a prerequisite for
     ‘bininstall’

     This ensures that ‘commoninstall’ is completed before ‘bininstall’
     is started when parallel builds are used (‘make -j install’), and
     so the ‘python3’ symlink is only installed after all standard
     library modules are installed.

   - gh-101538(24): Add experimental wasi-threads support.  Patch by
     Takashi Yamamoto.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/103053

   (2) https://github.com/python/cpython/issues/109191

   (3) https://github.com/python/cpython/issues/110276

   (4) https://github.com/python/cpython/issues/109566

   (5) https://github.com/python/cpython/issues/109740

   (6) https://github.com/python/cpython/issues/109054

   (7) https://github.com/python/cpython/issues/63760

   (8) https://github.com/python/cpython/issues/108740

   (9) https://github.com/python/cpython/issues/108634

   (10) https://github.com/python/cpython/issues/85283

   (11) https://github.com/python/cpython/issues/108447

   (12) https://github.com/python/cpython/issues/107814

   (13) https://github.com/python/cpython/issues/105481

   (14) https://github.com/python/cpython/issues/106881

   (15) https://github.com/python/cpython/issues/95855

   (16) https://github.com/python/cpython/issues/106962

   (17) https://github.com/python/cpython/issues/106118

   (18) https://github.com/python/cpython/issues/103295

   (19) https://github.com/python/cpython/issues/105875

   (20) https://github.com/python/cpython/issues/90005

   (21) https://github.com/python/cpython/issues/102404

   (22) https://github.com/python/cpython/issues/89886

   (23) https://github.com/python/cpython/issues/104692

   (24) https://github.com/python/cpython/issues/101538


File: python.info,  Node: Windows<11>,  Next: macOS<9>,  Prev: Build<14>,  Up: Python 3 13 0 alpha 1

1.23.15.7 Windows
.................

   - gh-110437(1): Allows overriding the source of VC redistributables
     so that releases can be guaranteed to never downgrade between
     updates.

   - gh-109286(2): Update Windows installer to use SQLite 3.43.1.

   - gh-82367(3): *note os.path.realpath(): 206. now resolves MS-DOS
     style file names even if the file is not accessible.  Patch by
     Moonsik Park.

   - gh-109991(4): Update Windows build to use OpenSSL 3.0.11.

   - gh-106242(5): Fixes *note realpath(): 206. to behave consistently
     when passed a path containing an embedded null character on
     Windows.  In strict mode, it now raises *note OSError: 3f0. instead
     of the unexpected *note ValueError: 1e3, and in non-strict mode
     will make the path absolute.

   - gh-83180(6): Changes the *note Windows の Python ランチャ: 588. to
     prefer an active virtual environment when the launched script has a
     shebang line using a Unix-like virtual command, even if the command
     requests a specific version of Python.

   - gh-106844(7): Fix integer overflow and truncating by the null
     character in ‘_winapi.LCMapStringEx()’ which affects
     ‘ntpath.normcase()’.

   - gh-105436(8): Ensure that an empty environment block is terminated
     by two null characters, as is required by Windows.

   - gh-105146(9): Updated the links at the end of the installer to
     point to Discourse rather than the mailing lists.

   - gh-103646(10): When installed from the Microsoft Store, ‘pip’ no
     longer defaults to per-user installs.  However, as the install
     directory is unwritable, it should automatically decide to do a
     per-user install anyway.  This should resolve issues when ‘pip’ is
     passed an option that conflicts with ‘--user’.

   - gh-88745(11): Improve performance of *note shutil.copy2(): a29. by
     using the operating system's ‘CopyFile2’ function.  This may result
     in subtle changes to metadata copied along with some files,
     bringing them in line with normal OS behavior.

   - gh-104820(12): Fixes *note stat(): 46d. and related functions on
     file systems that do not support file ID requests.  This includes
     FAT32 and exFAT.

   - gh-104803(13): Add *note os.path.isdevdrive(): 15ac. to detect
     whether a path is on a Windows Dev Drive.  Returns ‘False’ on
     platforms that do not support Dev Drive, and is absent on
     non-Windows platforms.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/110437

   (2) https://github.com/python/cpython/issues/109286

   (3) https://github.com/python/cpython/issues/82367

   (4) https://github.com/python/cpython/issues/109991

   (5) https://github.com/python/cpython/issues/106242

   (6) https://github.com/python/cpython/issues/83180

   (7) https://github.com/python/cpython/issues/106844

   (8) https://github.com/python/cpython/issues/105436

   (9) https://github.com/python/cpython/issues/105146

   (10) https://github.com/python/cpython/issues/103646

   (11) https://github.com/python/cpython/issues/88745

   (12) https://github.com/python/cpython/issues/104820

   (13) https://github.com/python/cpython/issues/104803


File: python.info,  Node: macOS<9>,  Next: IDLE<13>,  Prev: Windows<11>,  Up: Python 3 13 0 alpha 1

1.23.15.8 macOS
...............

   - gh-109286(1): Update macOS installer to use SQLite 3.43.1.

   - gh-109991(2): Update macOS installer to use OpenSSL 3.0.11.

   - gh-99079(3): Update macOS installer to use OpenSSL 3.0.9.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109286

   (2) https://github.com/python/cpython/issues/109991

   (3) https://github.com/python/cpython/issues/99079


File: python.info,  Node: IDLE<13>,  Next: Tools/Demos<6>,  Prev: macOS<9>,  Up: Python 3 13 0 alpha 1

1.23.15.9 IDLE
..............

   - gh-104719(1): Remove IDLE's modification of tokenize.tabsize and
     test other uses of tokenize data and methods.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104719


File: python.info,  Node: Tools/Demos<6>,  Next: C API<14>,  Prev: IDLE<13>,  Up: Python 3 13 0 alpha 1

1.23.15.10 Tools/Demos
......................

   - gh-109991(1): Update GitHub CI workflows to use OpenSSL 3.0.11 and
     multissltests to use 1.1.1w, 3.0.11, and 3.1.3.

   - gh-108494(2): Argument Clinic(3) now has a partial support of the
     *note Limited API: 36f.: see documentation in the Python
     Developer's Guide(4) Patch by Victor Stinner.

   - gh-107704(5): It is now possible to deprecate passing keyword
     arguments for keyword-or-positional parameters with Argument
     Clinic, using the new ‘/ [from X.Y]’ syntax.  (To be read as
     '"positional-only from Python version X.Y"'.) See documentation in
     the Python Developer's Guide(6) for more information.

   - gh-107880(7): Argument Clinic can now clone ‘__init__()’ and
     ‘__new__()’ methods.

   - gh-104683(8): Add ‘--exclude’ option to Argument Clinic CLI.

   - gh-95065(9): Argument Clinic now supports overriding automatically
     generated signature by using directive ‘@text_signature’.  See
     documentation in the Python Developer's Guide(10)

   - gh-107609(11): Fix duplicate module check in Argument Clinic.
     Previously, a duplicate definition would incorrectly be silently
     accepted.  Patch by Erlend E. Aasland.

   - gh-107467(12): The Argument Clinic command-line tool now prints to
     stderr instead of stdout on failure.

   - gh-106970(13): Fix bugs in the Argument Clinic ‘destination <name>
     clear’ command; the destination buffers would never be cleared, and
     the ‘destination’ directive parser would simply continue to the
     fault handler after processing the command.  Patch by Erlend E.
     Aasland.

   - gh-106706(14): Change bytecode syntax for families to remove
     redundant name matching pseudo syntax.

   - gh-106359(15): Argument Clinic now explicitly forbids "kwarg
     splats" in function calls used as annotations.

   - gh-103186(16): ‘freeze’ now fetches ‘CONFIG_ARGS’ from the original
     CPython instance the Makefile uses to call utility scripts.  Patch
     by Ijtaba Hussain.

   - gh-95065(17): It is now possible to deprecate passing parameters
     positionally with Argument Clinic, using the new ‘* [from X.Y]’
     syntax.  (To be read as '"keyword-only from Python version X.Y"'.)
     See documentation in the Python Developer's Guide(18) for more
     information.  Patch by Erlend E. Aasland with help from Alex
     Waygood, Nikita Sobolev, and Serhiy Storchaka.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/109991

   (2) https://github.com/python/cpython/issues/108494

   (3) https://devguide.python.org/development-tools/clinic/

   (4) 
https://devguide.python.org/development-tools/clinic/#clinic-howto-limited-capi

   (5) https://github.com/python/cpython/issues/107704

   (6) 
https://devguide.python.org/development-tools/clinic/#clinic-howto-deprecate-keyword

   (7) https://github.com/python/cpython/issues/107880

   (8) https://github.com/python/cpython/issues/104683

   (9) https://github.com/python/cpython/issues/95065

   (10) 
https://devguide.python.org/development-tools/clinic/#clinic-howto-override-signature

   (11) https://github.com/python/cpython/issues/107609

   (12) https://github.com/python/cpython/issues/107467

   (13) https://github.com/python/cpython/issues/106970

   (14) https://github.com/python/cpython/issues/106706

   (15) https://github.com/python/cpython/issues/106359

   (16) https://github.com/python/cpython/issues/103186

   (17) https://github.com/python/cpython/issues/95065

   (18) 
https://devguide.python.org/development-tools/clinic/#clinic-howto-deprecate-positional


File: python.info,  Node: C API<14>,  Prev: Tools/Demos<6>,  Up: Python 3 13 0 alpha 1

1.23.15.11 C API
................

   - gh-85283(1): If the *note Py_LIMITED_API: 3f7. macro is defined,
     ‘Py_BUILD_CORE’, ‘Py_BUILD_CORE_BUILTIN’ and ‘Py_BUILD_CORE_MODULE’
     macros are now undefined by ‘<Python.h>’.  Patch by Victor Stinner.

   - gh-110289(2): Add *note PyUnicode_EqualToUTF8AndSize(): 34f. and
     *note PyUnicode_EqualToUTF8(): 350. functions.

   - gh-110235(3): Raise *note TypeError: 502. for duplicate/unknown
     fields in ‘PyStructSequence’ constructor.  Patched by Xuehai Pan.

   - gh-110014(4): Remove undocumented ‘PY_TIMEOUT_MAX’ constant from
     the limited C API. Patch by Victor Stinner.

   - gh-109521(5): *note PyImport_GetImporter(): 167c. now sets
     RuntimeError if it fails to get *note sys.path_hooks: fee. or *note
     sys.path_importer_cache: 5ae. or they are not list and dict
     correspondingly.  Previously it could return NULL without setting
     error in obscure cases, crash or raise SystemError if these
     attributes have wrong type.

   - gh-108724(6): Add *note PyMutex: 141. internal-only lightweight
     locking API.

   - gh-85283(7): Add *note PySys_AuditTuple(): 347. function: similar
     to *note PySys_Audit(): 348, but pass event arguments as a Python
     *note tuple: 349. object.  Patch by Victor Stinner.

   - gh-108867(8): Add *note PyThreadState_GetUnchecked(): 34a.
     function: similar to *note PyThreadState_Get(): 34b, 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. Previously, the
     function was private and known as ‘_PyThreadState_UncheckedGet()’.
     Patch by Victor Stinner.

   - gh-108765(9): ‘Python.h’ no longer includes the ‘<ctype.h>’
     standard header file.  If needed, it should now be included
     explicitly.  For example, it provides ‘isalpha()’ and ‘tolower()’
     functions which are locale dependent.  Python provides locale
     independent functions, like ‘Py_ISALPHA()’ and ‘Py_TOLOWER()’.
     Patch by Victor Stinner.

   - gh-108765(10): ‘Python.h’ no longer includes the ‘<unistd.h>’
     standard header file.  If needed, it should now be included
     explicitly.  For example, it provides the functions: ‘close()’,
     ‘getpagesize()’, ‘getpid()’ and ‘sysconf()’.  Patch by Victor
     Stinner.

   - gh-108765(11): ‘Python.h’ no longer includes the ‘<ieeefp.h>’
     standard header.  It was included for the ‘finite()’ function which
     is now provided by the ‘<math.h>’ header.  It should now be
     included explicitly if needed.  Remove also the ‘HAVE_IEEEFP_H’
     macro.  Patch by Victor Stinner.

   - gh-108765(12): ‘Python.h’ no longer includes these standard header
     files: ‘<time.h>’, ‘<sys/select.h>’ and ‘<sys/time.h>’.  If needed,
     they should now be included explicitly.  For example, ‘<time.h>’
     provides the ‘clock()’ and ‘gmtime()’ functions, ‘<sys/select.h>’
     provides the ‘select()’ function, and ‘<sys/time.h>’ provides the
     ‘futimes()’, ‘gettimeofday()’ and ‘setitimer()’ functions.  Patch
     by Victor Stinner.

   - gh-108511(13): Add functions *note PyObject_HasAttrWithError():
     353, *note PyObject_HasAttrStringWithError(): 355, *note
     PyMapping_HasKeyWithError(): 357. and *note
     PyMapping_HasKeyStringWithError(): 359.

   - gh-107073(14): Add *note PyObject_VisitManagedDict(): 342. and
     *note PyObject_ClearManagedDict(): 343. functions which must be
     called by the traverse and clear functions of a type using *note
     Py_TPFLAGS_MANAGED_DICT: 344. flag.  Patch by Victor Stinner.

   - gh-108634(15): Python built with ‘configure’ *note
     -with-trace-refs: 36e. (tracing references) now supports the *note
     Limited API: 36f.  Patch by Victor Stinner.

   - gh-108014(16): Add *note PyLong_AsInt(): 338. function: similar to
     *note PyLong_AsLong(): 339, but store the result in a C int instead
     of a C long.  Previously, it was known as the private function
     ‘_PyLong_AsInt()’ (with an underscore prefix).  Patch by Victor
     Stinner.

   - gh-108314(17): Add *note PyDict_ContainsString(): 310. function:
     same as *note PyDict_Contains(): 311, but 'key' is specified as a
     const char* UTF-8 encoded bytes string, rather than a *note
     PyObject: 312.*.  Patch by Victor Stinner.

   - gh-108337(18): Add atomic operations on additional data types in
     pyatomic.h.

   - gh-108014(19): Add *note Py_IsFinalizing(): 333. function: check if
     the main Python interpreter is *note shutting down: 134.  Patch by
     Victor Stinner.

   - gh-107916(20): C API functions *note
     PyErr_SetFromErrnoWithFilename(): 167d, *note
     PyErr_SetExcFromWindowsErrWithFilename(): 167e. and *note
     PyErr_SetFromWindowsErrWithFilename(): 167f. save now the error
     code before calling *note PyUnicode_DecodeFSDefault(): 1680.

   - gh-107915(21): Such C API functions as ‘PyErr_SetString()’,
     ‘PyErr_Format()’, ‘PyErr_SetFromErrnoWithFilename()’ and many
     others no longer crash or ignore errors if it failed to format the
     error message or decode the filename.  Instead, they keep a
     corresponding error.

   - gh-107810(22): Improve *note DeprecationWarning: 18a. for uses of
     *note PyType_Spec: 1681. with metaclasses that have custom
     ‘tp_new’.

   - gh-107249(23): Implement the *note Py_UNUSED: 1682. macro for
     Windows MSVC compiler.  Patch by Victor Stinner.

   - gh-107226(24): *note PyModule_AddObjectRef(): 33e. is now only
     available in the limited API version 3.10 or later.

   - gh-106320(25): Remove private ‘_PyUnicode_AsString()’ alias to
     *note PyUnicode_AsUTF8(): b89.  It was kept for backward
     compatibility with Python 3.0 - 3.2.  The *note PyUnicode_AsUTF8():
     b89. is available since Python 3.3.  The *note
     PyUnicode_AsUTF8String(): 1161. function can be used to keep
     compatibility with Python 3.2 and older.  Patch by Victor Stinner.

   - gh-106572(26): Convert *note PyObject_DelAttr(): 1683. and *note
     PyObject_DelAttrString(): 1565. macros to functions.  Patch by
     Victor Stinner.

   - gh-106307(27): Add *note PyMapping_GetOptionalItem(): 31e.
     function.

   - gh-106521(28): Add *note PyObject_GetOptionalAttr(): 322. and *note
     PyObject_GetOptionalAttrString(): 323. functions.

   - gh-106320(29): Remove ‘_PyInterpreterState_Get()’ alias to *note
     PyInterpreterState_Get(): 387. which was kept for backward
     compatibility with Python 3.8.  Patch by Victor Stinner.

   - gh-106316(30): Remove ‘cpython/pytime.h’ header file: it only
     contained private functions.  Patch by Victor Stinner.

   - gh-106023(31): Remove private ‘_PyObject_FastCall()’ function: use
     ‘PyObject_Vectorcall()’ which is available since Python 3.8 ( PEP
     590(32)).  Patch by Victor Stinner.

   - gh-106168(33): If Python is built in *note debug mode: 1da. or
     *note with assertions: 365, *note PyTuple_SET_ITEM(): 366. and
     *note PyList_SET_ITEM(): 367. now check the index argument with an
     assertion.  If the assertion fails, make sure that the size is set
     before.  Patch by Victor Stinner.

   - gh-106084(34): Remove the old aliases to functions calling
     functions which were kept for backward compatibility with Python
     3.8 provisional API:

        * ‘_PyObject_CallMethodNoArgs()’: use
          ‘PyObject_CallMethodNoArgs()’

        * ‘_PyObject_CallMethodOneArg()’: use
          ‘PyObject_CallMethodOneArg()’

        * ‘_PyObject_CallOneArg()’: use ‘PyObject_CallOneArg()’

        * ‘_PyObject_FastCallDict()’: use ‘PyObject_VectorcallDict()’

        * ‘_PyObject_Vectorcall()’: use ‘PyObject_Vectorcall()’

        * ‘_PyObject_VectorcallMethod()’: use
          ‘PyObject_VectorcallMethod()’

        * ‘_PyVectorcall_Function()’: use ‘PyVectorcall_Function()’

     Just remove the underscore prefix to update your code.  Patch by
     Victor Stinner.

   - gh-106004(35): Adds *note PyDict_GetItemRef(): 313. and *note
     PyDict_GetItemStringRef(): 314. functions: similar to *note
     PyDict_GetItemWithError(): 315. but returning a *note strong
     reference: 316. instead of a *note borrowed reference: 317.  Patch
     by Victor Stinner.

   - gh-105927(36): Deprecate the *note PyWeakref_GetObject(): 352. and
     *note PyWeakref_GET_OBJECT(): 399. functions: use the new *note
     PyWeakref_GetRef(): 351. function instead.  Patch by Victor
     Stinner.

   - gh-105927(37): Add *note PyWeakref_GetRef(): 351. function: similar
     to *note PyWeakref_GetObject(): 352. but returns a *note strong
     reference: 316, or ‘NULL’ if the referent is no longer live.  Patch
     by Victor Stinner.

   - gh-105922(38): Add *note PyImport_AddModuleRef(): 331.: similar to
     *note PyImport_AddModule(): 332, but return a *note strong
     reference: 316. instead of a *note borrowed reference: 317.  Patch
     by Victor Stinner.

   - gh-105227(39): The new *note PyType_GetDict(): 1684. provides the
     dictionary for the given type object that is normally exposed by
     ‘cls.__dict__’.  Normally it's sufficient to use *note tp_dict:
     1685, but for the static builtin types ‘tp_dict’ is now always
     ‘NULL’.  ‘PyType_GetDict()’ provides the correct dict object
     instead.

   - gh-105375(40): Fix a bug in *note PyErr_WarnExplicit(): 1686. where
     an exception could end up being overwritten if the API failed
     internally.

   - gh-105603(41): We've renamed the new (in 3.12)
     ‘PyInterpreterConfig.own_gil’ to ‘PyInterpreterConfig.gil’ and
     changed the meaning of the value from "bool" to an integer with
     supported values of ‘PyInterpreterConfig_DEFAULT_GIL’,
     ‘PyInterpreterConfig_SHARED_GIL’, and
     ‘PyInterpreterConfig_OWN_GIL’.  The default is "shared".

   - gh-105387(42): In the limited C API version 3.12, *note
     Py_INCREF(): 53a. and *note Py_DECREF(): 53b. functions are now
     implemented as opaque function calls to hide implementation
     details.  Patch by Victor Stinner.

   - gh-105396(43): Deprecate the *note PyImport_ImportModuleNoBlock():
     397. function which is just an alias to *note
     PyImport_ImportModule(): 398. since Python 3.3.  Patch by Victor
     Stinner.

   - gh-103968(44): *note PyType_FromMetaclass(): 51b. now allows
     metaclasses with ‘tp_new’ set to ‘NULL’.

   - gh-105268(45): Remove the old private, undocumented and untested
     ‘_PyGC_FINALIZED()’ macro which was kept for backward compatibility
     with Python 3.8 and older.  Patch by Victor Stinner.

   - gh-105182(46): Remove ‘PyEval_AcquireLock()’ and
     ‘PyEval_ReleaseLock()’ functions, deprecated in Python 3.2.  Patch
     by Victor Stinner.

   - gh-105182(47): Remove ‘PyEval_InitThreads()’ and
     ‘PyEval_ThreadsInitialized()’ functions, deprecated in Python 3.9.
     Patch by Victor Stinner.

   - gh-105145(48): Deprecate old Python initialization functions:

        * *note PySys_ResetWarnOptions(): 389.

        * *note Py_GetExecPrefix(): 38b.

        * *note Py_GetPath(): 38d.

        * *note Py_GetPrefix(): 38f.

        * *note Py_GetProgramFullPath(): 391.

        * *note Py_GetProgramName(): 393.

        * *note Py_GetPythonHome(): 394.

     Patch by Victor Stinner.

   - gh-85275(49): ‘PyObject_AsCharBuffer()’, ‘PyObject_AsReadBuffer()’,
     ‘PyObject_CheckReadBuffer()’, and ‘PyObject_AsWriteBuffer()’ are
     removed.  Please migrate to new buffer protocol; *note
     PyObject_GetBuffer(): 373. and *note PyBuffer_Release(): 374.

   - gh-105156(50): Deprecate the old ‘Py_UNICODE’ and ‘PY_UNICODE_TYPE’
     types: use directly the ‘wchar_t’ type instead.  Since Python 3.3,
     ‘Py_UNICODE’ and ‘PY_UNICODE_TYPE’ are just aliases to ‘wchar_t’.
     Patch by Victor Stinner.

   - gh-105145(51): Remove the following old functions to configure the
     Python initialization, deprecated in Python 3.11:

        * ‘PySys_AddWarnOptionUnicode()’

        * ‘PySys_AddWarnOption()’

        * ‘PySys_AddXOption()’

        * ‘PySys_HasWarnOptions()’

        * ‘PySys_SetArgvEx()’

        * ‘PySys_SetArgv()’

        * ‘PySys_SetPath()’

        * ‘Py_SetPath()’

        * ‘Py_SetProgramName()’

        * ‘Py_SetPythonHome()’

        * ‘Py_SetStandardStreamEncoding()’

        * ‘_Py_SetProgramFullPath()’

     Patch by Victor Stinner.

   - gh-105107(52): Remove functions deprecated in Python 3.9.

        * ‘PyEval_CallObject()’, ‘PyEval_CallObjectWithKeywords()’: use
          *note PyObject_CallNoArgs(): 375. and *note PyObject_Call():
          376. (positional arguments must not be 'NULL') instead.

        * ‘PyEval_CallFunction()’: use *note PyObject_CallFunction():
          378. instead.

        * ‘PyEval_CallMethod()’: use *note PyObject_CallMethod(): 379.
          instead.

        * ‘PyCFunction_Call()’: use *note PyObject_Call(): 376. instead.

     Patch by Victor Stinner.

   - gh-105115(53): ‘PyTypeObject.tp_bases’ (and ‘tp_mro’) for builtin
     static types are now shared by all interpreters, whereas in
     3.12-beta1 they were stored on ‘PyInterpreterState’.  Also note
     that now the tuples are immortal objects.

   - gh-105071(54): Add ‘PyUnstable_Exc_PrepReraiseStar’ to the unstable
     C api to expose the implementation of *note except*: 582.

   - gh-104922(55): ‘PY_SSIZE_T_CLEAN’ is no longer required to use
     ‘'#'’ formats in APIs like *note PyArg_ParseTuple(): 53d. and *note
     Py_BuildValue(): 875.  They uses ‘Py_ssize_t’ for ‘'#'’ regardless
     ‘PY_SSIZE_T_CLEAN’.

   - gh-104584(56): Add an unstable C API for hooking in an optimizer.
     This is mainly internal, but marked "unstable" to allow third-party
     experimentation.

   - gh-104668(57): Don't call *note PyOS_InputHook: 551. or *note
     PyOS_ReadlineFunctionPointer: 552. in subinterpreters, since it's
     generally difficult to avoid using global state in their registered
     callbacks.  This also avoids situations where extensions may find
     themselves running in a subinterpreter they don't support (or
     haven't yet been loaded in).

   - bpo-42327(58): Add *note PyModule_Add(): 33d. function: similar to
     *note PyModule_AddObjectRef(): 33e. and *note PyModule_AddObject():
     33f, but always steals a reference to the value.

   - bpo-40309(59): Properly handle trailing spaces before closing
     parenthesis in *note Py_BuildValue(): 875. format strings.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/85283

   (2) https://github.com/python/cpython/issues/110289

   (3) https://github.com/python/cpython/issues/110235

   (4) https://github.com/python/cpython/issues/110014

   (5) https://github.com/python/cpython/issues/109521

   (6) https://github.com/python/cpython/issues/108724

   (7) https://github.com/python/cpython/issues/85283

   (8) https://github.com/python/cpython/issues/108867

   (9) https://github.com/python/cpython/issues/108765

   (10) https://github.com/python/cpython/issues/108765

   (11) https://github.com/python/cpython/issues/108765

   (12) https://github.com/python/cpython/issues/108765

   (13) https://github.com/python/cpython/issues/108511

   (14) https://github.com/python/cpython/issues/107073

   (15) https://github.com/python/cpython/issues/108634

   (16) https://github.com/python/cpython/issues/108014

   (17) https://github.com/python/cpython/issues/108314

   (18) https://github.com/python/cpython/issues/108337

   (19) https://github.com/python/cpython/issues/108014

   (20) https://github.com/python/cpython/issues/107916

   (21) https://github.com/python/cpython/issues/107915

   (22) https://github.com/python/cpython/issues/107810

   (23) https://github.com/python/cpython/issues/107249

   (24) https://github.com/python/cpython/issues/107226

   (25) https://github.com/python/cpython/issues/106320

   (26) https://github.com/python/cpython/issues/106572

   (27) https://github.com/python/cpython/issues/106307

   (28) https://github.com/python/cpython/issues/106521

   (29) https://github.com/python/cpython/issues/106320

   (30) https://github.com/python/cpython/issues/106316

   (31) https://github.com/python/cpython/issues/106023

   (32) https://peps.python.org/pep-0590/

   (33) https://github.com/python/cpython/issues/106168

   (34) https://github.com/python/cpython/issues/106084

   (35) https://github.com/python/cpython/issues/106004

   (36) https://github.com/python/cpython/issues/105927

   (37) https://github.com/python/cpython/issues/105927

   (38) https://github.com/python/cpython/issues/105922

   (39) https://github.com/python/cpython/issues/105227

   (40) https://github.com/python/cpython/issues/105375

   (41) https://github.com/python/cpython/issues/105603

   (42) https://github.com/python/cpython/issues/105387

   (43) https://github.com/python/cpython/issues/105396

   (44) https://github.com/python/cpython/issues/103968

   (45) https://github.com/python/cpython/issues/105268

   (46) https://github.com/python/cpython/issues/105182

   (47) https://github.com/python/cpython/issues/105182

   (48) https://github.com/python/cpython/issues/105145

   (49) https://github.com/python/cpython/issues/85275

   (50) https://github.com/python/cpython/issues/105156

   (51) https://github.com/python/cpython/issues/105145

   (52) https://github.com/python/cpython/issues/105107

   (53) https://github.com/python/cpython/issues/105115

   (54) https://github.com/python/cpython/issues/105071

   (55) https://github.com/python/cpython/issues/104922

   (56) https://github.com/python/cpython/issues/104584

   (57) https://github.com/python/cpython/issues/104668

   (58) https://bugs.python.org/issue?@action=redirect&bpo=42327

   (59) https://bugs.python.org/issue?@action=redirect&bpo=40309


File: python.info,  Node: Python 3 12 0 beta 1,  Next: Python 3 12 0 alpha 7,  Prev: Python 3 13 0 alpha 1,  Up: 変更履歴

1.23.16 Python 3.12.0 beta 1
----------------------------

'Release date: 2023-05-22'

* Menu:

* Security: Security<10>.
* Core and Builtins: Core and Builtins<16>.
* Library: Library<15>.
* Documentation: Documentation<10>.
* Tests: Tests<13>.
* Build: Build<15>.
* Windows: Windows<12>.
* macOS: macOS<10>.
* IDLE: IDLE<14>.
* Tools/Demos: Tools/Demos<7>.
* C API: C API<15>.


File: python.info,  Node: Security<10>,  Next: Core and Builtins<16>,  Up: Python 3 12 0 beta 1

1.23.16.1 Security
..................

   - gh-99889(1): Fixed a security in flaw in ‘uu.decode()’ that could
     allow for directory traversal based on the input if no ‘out_file’
     was specified.

   - gh-104049(2): Do not expose the local on-disk location in directory
     indexes produced by ‘http.client.SimpleHTTPRequestHandler’.

   - gh-99108(3): Upgrade built-in *note hashlib: 5e. SHA3
     implementation to a verified implementation from the ‘HACL*’
     project.  Used when OpenSSL is not present or lacks SHA3.

   - gh-102153(4): *note urllib.parse.urlsplit(): d0d. now strips
     leading C0 control and space characters following the specification
     for URLs defined by WHATWG in response to CVE 2023-24329(5).  Patch
     by Illia Volochii.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99889

   (2) https://github.com/python/cpython/issues/104049

   (3) https://github.com/python/cpython/issues/99108

   (4) https://github.com/python/cpython/issues/102153

   (5) https://www.cve.org/CVERecord?id=CVE-2023-24329


File: python.info,  Node: Core and Builtins<16>,  Next: Library<15>,  Prev: Security<10>,  Up: Python 3 12 0 beta 1

1.23.16.2 Core and Builtins
...........................

   - gh-102856(1): Implement PEP 701 changes in the *note tokenize: e4.
     module.  Patch by Marta Gómez Macías and Pablo Galindo Salgado

   - gh-104615(2): Fix wrong ordering of assignments in code like ‘a, a
     = x, y’.  Contributed by Carl Meyer.

   - gh-104572(3): Improve syntax error message for invalid constructs
     in PEP 695(4) contexts and in annotations when ‘from __future__
     import annotations’ is active.

   - gh-104482(5): Fix three error handling bugs in ast.c's validation
     of pattern matching statements.

   - gh-102818(6): Do not add a frame to the traceback in the
     ‘sys.setprofile’ and ‘sys.settrace’ trampoline functions.  This
     ensures that frames are not duplicated if an exception is raised in
     the callback function, and ensures that frames are not omitted if a
     C callback is used and that does not add the frame.

   - gh-104405(7): Fix an issue where some *note bytecode: 16c.
     instructions could ignore PEP 523(8) when "inlining" calls.

   - gh-103082(9): Change behavior of ‘sys.monitoring.events.LINE’
     events in ‘sys.monitoring’: Line events now occur when a new line
     is reached dynamically, instead of using a static approximation, as
     before.  This makes the behavior very similar to that of "line"
     events in ‘sys.settrace’.  This should ease porting of tools from
     3.11 to 3.12.

   - gh-104263(10): Fix ‘float("nan")’ to produce a quiet NaN on
     platforms (like MIPS) where the meaning of the signalling / quiet
     bit is inverted from its usual meaning.  Also introduce a new macro
     ‘Py_INFINITY’ matching C99's ‘INFINITY’, and refactor internals to
     rely on C99's ‘NAN’ and ‘INFINITY’ macros instead of hard-coding
     bit patterns for infinities and NaNs.  Thanks Sebastian Berg.

   - gh-99113(11): Multi-phase init extension modules may now indicate
     that they support running in subinterpreters that have their own
     GIL. This is done by using ‘Py_MOD_PER_INTERPRETER_GIL_SUPPORTED’
     as the value for the ‘Py_mod_multiple_interpreters’ module def
     slot.  Otherwise the module, by default, cannot be imported in such
     subinterpreters.  (This does not affect the main interpreter or
     subinterpreters that do not have their own GIL.) In addition to the
     isolation that multi-phase init already normally requires, support
     for per-interpreter GIL involves one additional constraint:
     thread-safety.  If the module has external (linked) dependencies
     and those libraries have any state that isn't thread-safe then the
     module must do the additional work to add thread-safety.  This
     should be an uncommon case.

   - gh-99113(12): The GIL is now (optionally) per-interpreter.  This is
     the fundamental change for PEP 684.  This is all made possible by
     virtue of the isolated state of each interpreter in the process.
     The behavior of the main interpreter remains unchanged.  Likewise,
     interpreters created using ‘Py_NewInterpreter()’ are not affected.
     To get an interpreter with its own GIL, call
     ‘Py_NewInterpreterFromConfig()’.

   - gh-104108(13): Multi-phase init extension modules may now indicate
     whether or not they actually support multiple interpreters.  By
     default such modules are expected to support use in multiple
     interpreters.  In the uncommon case that one does not, it may use
     the new ‘Py_mod_multiple_interpreters’ module def slot.  A value of
     ‘0’ means the module does not support them.  ‘1’ means it does.
     The default is ‘1’.

   - gh-104142(14): Fix an issue where *note list: 5dc. or *note tuple:
     349. repetition could fail to respect PEP 683(15).

   - gh-104078(16): Improve the performance of *note
     PyObject_HasAttrString(): 356.

   - gh-104066(17): Improve the performance of *note hasattr(): 49e. for
     module objects with a missing attribute.

   - gh-104028(18): Reduce object creation while calling callback
     function from gc.  Patch by Donghee Na.

   - gh-104018(19): Disallow the "z" format specifier in %-format of
     bytes objects.

   - gh-102213(20): Fix performance loss when accessing an object's
     attributes with ‘__getattr__’ defined.

   - gh-103895(21): Improve handling of edge cases in showing
     ‘Exception.__notes__’.  Ensures that the messages always end with a
     newline and that string/bytes are not exploded over multiple lines.
     Patch by Carey Metcalfe.

   - gh-103907(22): Don't modify the refcounts of known immortal objects
     (*note True: bdb, *note False: b05, and *note None: 641.) in the
     main interpreter loop.

   - gh-103899(23): Provide a helpful hint in the *note TypeError: 502.
     message when accidentally calling a *note module: 15c3. object that
     has a callable attribute of the same name (such as *note dis.dis():
     b02. or *note datetime.datetime: 1ae.).

   - gh-103845(24): Remove both line and instruction instrumentation
     before adding new ones for monitoring, to avoid newly added
     instrumentation being removed immediately.

   - gh-103763(25): Implement PEP 695(26), adding syntactic support for
     generic classes, generic functions, and type aliases.

     A new ‘type X = ...’ syntax is added for type aliases, which
     resolves at runtime to an instance of the new class
     ‘typing.TypeAliasType’.  The value is lazily evaluated and is
     accessible through the ‘.__value__’ attribute.  This is implemented
     as a new AST node ‘ast.TypeAlias’.

     New syntax (‘class X[T]: ...’, ‘def func[T](): ...’) is added for
     defining generic functions and classes.  This is implemented as a
     new ‘type_params’ attribute on the AST nodes for classes and
     functions.  This node holds instances of the new AST classes
     ‘ast.TypeVar’, ‘ast.ParamSpec’, and ‘ast.TypeVarTuple’.

     ‘typing.TypeVar’, ‘typing.ParamSpec’, ‘typing.ParamSpecArgs’,
     ‘typing.ParamSpecKwargs’, ‘typing.TypeVarTuple’, and
     ‘typing.Generic’ are now implemented in C rather than Python.

     There are new bytecode instructions ‘LOAD_LOCALS’,
     ‘LOAD_CLASSDICT_OR_GLOBAL’, and ‘LOAD_CLASSDICT_OR_DEREF’ to
     support correct resolution of names in class namespaces.

     Patch by Eric Traut, Larry Hastings, and Jelle Zijlstra.

   - gh-103801(27): Adds three minor linting fixes to the wasm module
     caught that were caught by ruff.

   - gh-103793(28): Optimized asyncio Task creation by deferring
     expensive string formatting (task name generation) from Task
     creation to the first time ‘get_name’ is called.  This makes
     asyncio benchmarks up to 5% faster.

   - gh-102310(29): Change the error range for invalid bytes literals.

   - gh-103590(30): Do not wrap a single exception raised from a
     ‘try-except*’ construct in an *note ExceptionGroup: 19b.

   - gh-103650(31): Change the perf map format to remove the '0x' prefix
     from the addresses

   - gh-102856(32): Implement the required C tokenizer changes for PEP
     701.  Patch by Pablo Galindo Salgado, Lysandros Nikolaou, Batuhan
     Taskaya, Marta Gómez Macías and sunmy2019.

   - gh-100530(33): Clarify the error message raised when the called
     part of a class pattern isn't actually a class.

   - gh-101517(34): Fix bug in line numbers of instructions emitted for
     *note except*: 582.

   - gh-103492(35): Clarify *note SyntaxWarning: 432. with literal ‘is’
     comparison by specifying which literal is problematic, since
     comparisons using ‘is’ with e.g.  ‘None’ and bool literals are
     idiomatic.

   - gh-87729(36): Add *note LOAD_SUPER_ATTR: 4a9. (and a specialization
     for ‘super().method()’) to speed up ‘super().method()’ and
     ‘super().attr’.  This makes ‘super().method()’ roughly 2.3x faster
     and brings it within 20% of the performance of a simple method
     call.  Patch by Vladimir Matveev and Carl Meyer.

   - gh-103488(37): Change the internal offset distinguishing yield and
     return target addresses, so that the instruction pointer is correct
     for exception handling and other stack unwinding.

   - gh-82012(38): The bitwise inversion operator (‘~’) on bool is
     deprecated.  It returns the bitwise inversion of the underlying
     ‘int’ representation such that ‘bool(~True) == True’, which can be
     confusing.  Use ‘not’ for logical negation of bools.  In the rare
     case that you really need the bitwise inversion of the underlying
     ‘int’, convert to int explicitly ‘~int(x)’.

   - gh-77757(39): Exceptions raised in a typeobject's ‘__set_name__’
     method are no longer wrapped by a *note RuntimeError: 17a.  Context
     information is added to the exception as a PEP 678(40) note.

   - gh-103333(41): *note AttributeError: 326. now retains the ‘name’
     attribute when pickled and unpickled.

   - gh-103242(42): Migrate *note set_ecdh_curve(): 1116. method not to
     use deprecated OpenSSL APIs.  Patch by Donghee Na.

   - gh-103323(43): We've replaced our use of
     ‘_PyRuntime.tstate_current’ with a thread-local variable.  This is
     a fairly low-level implementation detail, and there should be no
     change in behavior.

   - gh-84436(44): The implementation of PEP-683 which adds Immortal
     Objects by using a fixed reference count that skips reference
     counting to make objects truly immutable.

   - gh-102700(45): Allow built-in modules to be submodules.  This
     allows submodules to be statically linked into a CPython binary.

   - gh-103082(46): Implement PEP 669(47) Low Impact Monitoring for
     CPython.

   - gh-88691(48): Reduce the number of inline *note CACHE: 6c4. entries
     for *note CALL: 6d2.

   - gh-102500(49): Make the buffer protocol accessible in Python code
     using the new ‘__buffer__’ and ‘__release_buffer__’ magic methods.
     See PEP 688(50) for details.  Patch by Jelle Zijlstra.

   - gh-97933(51): PEP 709(52): inline list, dict and set comprehensions
     to improve performance and reduce bytecode size.

   - gh-99184(53): Bypass instance attribute access of ‘__name__’ in
     ‘repr’ of *note weakref.ref: fbb.

   - gh-98003(54): Complex function calls are now faster and consume no
     C stack space.

   - bpo-39610(55): ‘len()’ for 0-dimensional *note memoryview: 435.
     objects (such as ‘memoryview(ctypes.c_uint8(42))’) now raises a
     *note TypeError: 502.  Previously this returned ‘1’, which was not
     consistent with ‘mem_0d[0]’ raising an *note IndexError: 14de.

   - bpo-31821(56): Fix ‘pause_reading()’ to work when called from
     ‘connection_made()’ in *note asyncio: 8.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102856

   (2) https://github.com/python/cpython/issues/104615

   (3) https://github.com/python/cpython/issues/104572

   (4) https://peps.python.org/pep-0695/

   (5) https://github.com/python/cpython/issues/104482

   (6) https://github.com/python/cpython/issues/102818

   (7) https://github.com/python/cpython/issues/104405

   (8) https://peps.python.org/pep-0523/

   (9) https://github.com/python/cpython/issues/103082

   (10) https://github.com/python/cpython/issues/104263

   (11) https://github.com/python/cpython/issues/99113

   (12) https://github.com/python/cpython/issues/99113

   (13) https://github.com/python/cpython/issues/104108

   (14) https://github.com/python/cpython/issues/104142

   (15) https://peps.python.org/pep-0683/

   (16) https://github.com/python/cpython/issues/104078

   (17) https://github.com/python/cpython/issues/104066

   (18) https://github.com/python/cpython/issues/104028

   (19) https://github.com/python/cpython/issues/104018

   (20) https://github.com/python/cpython/issues/102213

   (21) https://github.com/python/cpython/issues/103895

   (22) https://github.com/python/cpython/issues/103907

   (23) https://github.com/python/cpython/issues/103899

   (24) https://github.com/python/cpython/issues/103845

   (25) https://github.com/python/cpython/issues/103763

   (26) https://peps.python.org/pep-0695/

   (27) https://github.com/python/cpython/issues/103801

   (28) https://github.com/python/cpython/issues/103793

   (29) https://github.com/python/cpython/issues/102310

   (30) https://github.com/python/cpython/issues/103590

   (31) https://github.com/python/cpython/issues/103650

   (32) https://github.com/python/cpython/issues/102856

   (33) https://github.com/python/cpython/issues/100530

   (34) https://github.com/python/cpython/issues/101517

   (35) https://github.com/python/cpython/issues/103492

   (36) https://github.com/python/cpython/issues/87729

   (37) https://github.com/python/cpython/issues/103488

   (38) https://github.com/python/cpython/issues/82012

   (39) https://github.com/python/cpython/issues/77757

   (40) https://peps.python.org/pep-0678/

   (41) https://github.com/python/cpython/issues/103333

   (42) https://github.com/python/cpython/issues/103242

   (43) https://github.com/python/cpython/issues/103323

   (44) https://github.com/python/cpython/issues/84436

   (45) https://github.com/python/cpython/issues/102700

   (46) https://github.com/python/cpython/issues/103082

   (47) https://peps.python.org/pep-0669/

   (48) https://github.com/python/cpython/issues/88691

   (49) https://github.com/python/cpython/issues/102500

   (50) https://peps.python.org/pep-0688/

   (51) https://github.com/python/cpython/issues/97933

   (52) https://peps.python.org/pep-0709/

   (53) https://github.com/python/cpython/issues/99184

   (54) https://github.com/python/cpython/issues/98003

   (55) https://bugs.python.org/issue?@action=redirect&bpo=39610

   (56) https://bugs.python.org/issue?@action=redirect&bpo=31821


File: python.info,  Node: Library<15>,  Next: Documentation<10>,  Prev: Core and Builtins<16>,  Up: Python 3 12 0 beta 1

1.23.16.3 Library
.................

   - gh-104600(1): *note functools.update_wrapper(): fec. now sets the
     ‘__type_params__’ attribute (added by PEP 695(2)).

   - gh-104340(3): When an ‘asyncio’ pipe protocol loses its connection
     due to an error, and the caller doesn't await ‘wait_closed()’ on
     the corresponding ‘StreamWriter’, don't log a warning about an
     exception that was never retrieved.  After all, according to the
     ‘StreamWriter.close()’ docs, the ‘wait_closed()’ call is optional
     ("not mandatory").

   - gh-104555(4): Fix issue where an *note issubclass(): 78c. check
     comparing a class ‘X’ against a *note runtime-checkable protocol:
     40f. ‘Y’ with non-callable members would not cause *note TypeError:
     502. to be raised if an *note isinstance(): 40e. call had
     previously been made comparing an instance of ‘X’ to ‘Y’.  This
     issue was present in edge cases on Python 3.11, but became more
     prominent in 3.12 due to some unrelated changes that were made to
     runtime-checkable protocols.  Patch by Alex Waygood.

   - gh-104372(5): Refactored the ‘_posixsubprocess’ internals to avoid
     Python C API usage between fork and exec when marking ‘pass_fds=’
     file descriptors inheritable.

   - gh-104484(6): Added 'case_sensitive' argument to *note
     pathlib.PurePath.match(): 479.

   - gh-75367(7): Fix data descriptor detection in *note
     inspect.getattr_static(): 461.

   - gh-104536(8): Fix a race condition in the internal
     ‘multiprocessing.process’ cleanup logic that could manifest as an
     unintended ‘AttributeError’ when calling ‘process.close()’.

   - gh-103857(9): Update datetime deprecations' stracktrace to point to
     the calling line

   - gh-101520(10): Move the core functionality of the ‘tracemalloc’
     module in the ‘Python/’ folder, leaving just the module wrapper in
     ‘Modules/’.

   - gh-104392(11): Remove undocumented and unused ‘_paramspec_tvars’
     attribute from some classes in *note typing: ed.

   - gh-102613(12): Fix issue where *note pathlib.Path.glob(): 20e.
     raised *note RecursionError: d39. when walking deep directory
     trees.

   - gh-103000(13): Improve performance of *note dataclasses.asdict():
     168b. for the common case where 'dict_factory' is ‘dict’.  Patch by
     David C Ellis.

   - gh-104301(14): Allow leading whitespace in disambiguated statements
     in *note pdb: 94.

   - gh-104139(15): Teach ‘urllib.parse.unsplit()’ to retain the ‘"//"’
     when assembling ‘itms-services://?action=generate-bugs’ style Apple
     Platform Deployment(16) URLs.

   - gh-104307(17): *note socket.getnameinfo(): 1629. now releases the
     GIL while contacting the DNS server

   - gh-104310(18): Users may now use
     ‘importlib.util.allowing_all_extensions()’ (a context manager) to
     temporarily disable the strict compatibility checks for importing
     extension modules in subinterpreters.

   - gh-87695(19): Fix issue where *note pathlib.Path.glob(): 20e.
     raised *note OSError: 3f0. when it encountered a symlink to an
     overly long path.

   - gh-104265(20): Prevent possible crash by disallowing instantiation
     of the ‘_csv.Reader’ and ‘_csv.Writer’ types.  The regression was
     introduced in 3.10.0a4 with PR 23224 (bpo-14935(21)).  Patch by
     Radislav Chugunov.

   - gh-102613(22): Improve performance of *note pathlib.Path.glob():
     20e. when expanding recursive wildcards ("‘**’") by merging
     adjacent wildcards and de-duplicating results only when necessary.

   - gh-65772(23): Remove unneeded comments and code in turtle.py.

   - gh-90208(24): Fixed issue where *note pathlib.Path.glob(): 20e.
     returned incomplete results when it encountered a *note
     PermissionError: d10.  This method now suppresses all *note
     OSError: 3f0. exceptions, except those raised from calling *note
     is_dir(): 211. on the top-level path.

   - gh-104144(25): Optimize *note asyncio.TaskGroup: 19a. when using
     *note asyncio.eager_task_factory(): 444.  Skip scheduling a done
     callback if a TaskGroup task completes eagerly.

   - gh-104144(26): Optimize *note asyncio.gather(): 5c8. when using
     *note asyncio.eager_task_factory(): 444. to complete eagerly if all
     fututres completed eagerly.  Avoid scheduling done callbacks for
     futures that complete eagerly.

   - gh-104114(27): Fix issue where *note pathlib.Path.glob(): 20e.
     returns paths using the case of non-wildcard segments for
     corresponding path segments, rather than the real filesystem case.

   - gh-104104(28): Improve performance of *note pathlib.Path.glob():
     20e. by using *note re.IGNORECASE: 168c. to implement
     case-insensitive matching.

   - gh-104102(29): Improve performance of *note pathlib.Path.glob():
     20e. when evaluating patterns that contain ‘'../'’ segments.

   - gh-103822(30): Update the return type of ‘weekday’ to the newly
     added Day attribute

   - gh-103629(31): Update the ‘repr’ of *note typing.Unpack: 1593.
     according to PEP 692(32).

   - gh-103963(33): Make *note dis: 30. display the names of the args
     for ‘CALL_INTRINSIC_*’.

   - gh-104035(34): Do not ignore user-defined ‘__getstate__’ and
     ‘__setstate__’ methods for slotted frozen dataclasses.

   - gh-103987(35): In *note mmap: 83, fix several bugs that could lead
     to access to memory-mapped files after they have been invalidated.

   - gh-103977(36): Improve import time of *note platform: 98. module.

   - gh-88773(37): Added *note turtle.teleport(): 168d. to the *note
     turtle: ea. module to move a turtle to a new point without tracing
     a line, visible or invisible.  Patch by Liam Gersten.

   - gh-103935(38): Use *note io.open_code(): 168e. for files to be
     executed instead of raw *note open(): 4e5.

   - gh-68968(39): Fixed garbled output of *note assertEqual(): 4f2.
     when an input lacks final newline.

   - gh-100370(40): Fix potential *note OverflowError: 84e. in *note
     sqlite3.Connection.blobopen(): 64d. for 32-bit builds.  Patch by
     Erlend E. Aasland.

   - gh-102628(41): Substitute CTRL-D with CTRL-Z in *note sqlite3: ba.
     CLI banner when running on Windows.

   - gh-103636(42): Module-level attributes ‘January’ and ‘February’ are
     deprecated from *note calendar: 10.

   - gh-103583(43): Isolate ‘_multibytecodec’ and codecs extension
     modules.  Patches by Erlend E. Aasland.

   - gh-103848(44): Add checks to ensure that ‘[’ bracketed ‘]’ hosts
     found by *note urllib.parse.urlsplit(): d0d. are of IPv6 or
     IPvFuture format.

   - gh-103872(45): Update the bundled copy of pip to version 23.1.2.

   - gh-99944(46): Make *note dis: 30. display the value of oparg of
     ‘KW_NAMES’.

   - gh-74940(47): The C.UTF-8 locale is no longer converted to
     en_US.UTF-8, enabling the use of UTF-8 encoding on systems which
     have no locales installed.

   - gh-103861(48): Fix ‘zipfile.Zipfile’ creating invalid zip files
     when ‘force_zip64’ was used to add files to them.  Patch by Carey
     Metcalfe.

   - gh-103857(49): Deprecated *note datetime.datetime.utcnow(): 2d3.
     and *note datetime.datetime.utcfromtimestamp(): 2d4.  (Patch by
     Paul Ganssle)

   - gh-103839(50): Avoid compilation error due to tommath.h not being
     found when building Tkinter against Tcl 8.7 built with bundled
     libtommath.

   - gh-103791(51): *note contextlib.suppress: ef2. now supports
     suppressing exceptions raised as part of an *note ExceptionGroup:
     19b.  If other exceptions exist on the group, they are re-raised in
     a group that does not contain the suppressed exceptions.

   - gh-90750(52): Use *note datetime.datetime.fromisocalendar(): 9bb.
     in the implementation of *note datetime.datetime.strptime(): 156e,
     which should now accept only valid ISO dates.  (Patch by Paul
     Ganssle)

   - gh-103685(53): Prepare ‘tkinter.Menu.index()’ for Tk 8.7 so that it
     does not raise ‘TclError: expected integer but got ""’ when it
     should return ‘None’.

   - gh-81403(54): *note urllib.request.CacheFTPHandler: 168f. no longer
     raises ‘URLError’ if a cached FTP instance is reused.  ftplib's
     endtransfer method calls voidresp to drain the connection to handle
     FTP instance reuse properly.

   - gh-103699(55): Add ‘__orig_bases__’ to non-generic TypedDicts,
     call-based TypedDicts, and call-based NamedTuples.  Other
     TypedDicts and NamedTuples already had the attribute.

   - gh-103693(56): Add convenience variable feature to *note pdb: 94.

   - gh-92248(57): Deprecate ‘type’, ‘choices’, and ‘metavar’ parameters
     of ‘argparse.BooleanOptionalAction’.

   - gh-89415(58): Add *note socket: b8. constants for source-specific
     multicast.  Patch by Reese Hyde.

   - gh-103673(59): *note socketserver: b9. gains
     ‘ForkingUnixStreamServer’ and ‘ForkingUnixDatagramServer’ classes.
     Patch by Jay Berry.

   - gh-103636(60): Added Enum for months and days in the calendar
     module.

   - gh-84976(61): Create a new ‘Lib/_pydatetime.py’ file that defines
     the Python version of the ‘datetime’ module, and make ‘datetime’
     import the contents of the new library only if the C implementation
     is missing.  Currently, the full Python implementation is defined
     and then deleted if the C implementation is not available, slowing
     down ‘import datetime’ unnecessarily.

   - gh-103596(62): Attributes/methods are no longer shadowed by
     same-named enum members, although they may be shadowed by
     enum.property's.

   - gh-103584(63): Updated ‘importlib.metadata’ with changes from
     ‘importlib_metadata’ 5.2 through 6.5.0, including: Support
     ‘installed-files.txt’ for ‘Distribution.files’ when present.
     ‘PackageMetadata’ now stipulates an additional ‘get’ method
     allowing for easy querying of metadata keys that may not be
     present.  ‘packages_distributions’ now honors packages and modules
     with Python modules that not ‘.py’ sources (e.g.  ‘.pyc’, ‘.so’).
     Expand protocol for ‘PackageMetadata.get_all’ to match the upstream
     implementation of ‘email.message.Message.get_all’ in
     python/typeshed#9620.  Deprecated use of ‘Distribution’ without
     defining abstract methods.  Deprecated expectation that
     ‘PackageMetadata.__getitem__’ will return ‘None’ for missing keys.
     In the future, it will raise a ‘KeyError’.

   - gh-103578(64): Fixed a bug where *note pdb: 94. crashes when
     reading source file with different encoding by replacing *note
     io.open(): 4e6. with *note io.open_code(): 168e.  The new method
     would also call into the hook set by *note
     PyFile_SetOpenCodeHook(): 1690.

   - gh-103556(65): Now creating *note inspect.Signature: 1b1. objects
     with positional-only parameter with a default followed by a
     positional-or-keyword parameter without one is impossible.

   - gh-103559(66): Update the bundled copy of pip to version 23.1.1.

   - gh-103548(67): Improve performance of *note
     pathlib.Path.absolute(): 1612. and *note cwd(): 1691. by joining
     paths only when necessary.  Also improve performance of *note
     pathlib.PurePath.is_absolute(): 1692. on Posix by skipping path
     parsing and normalization.

   - gh-103538(68): Remove ‘_tkinter’ module code guarded by definition
     of the ‘TK_AQUA’ macro which was only needed for Tk 8.4.7 or
     earlier and was never actually defined by any build system or
     documented for manual use.

   - gh-103533(69): Update *note cProfile: 20. to use PEP 669 API

   - gh-103525(70): Fix misleading exception message when mixed ‘str’
     and ‘bytes’ arguments are supplied to *note pathlib.PurePath: 473.
     and *note Path: 20a.

   - gh-103489(71): Add *note getconfig(): 485. and *note setconfig():
     486. to *note Connection: 226. to make configuration changes to a
     database connection.  Patch by Erlend E. Aasland.

   - gh-103365(72): Set default Flag boundary to ‘STRICT’ and fix
     bitwise operations.

   - gh-103472(73): Avoid a potential *note ResourceWarning: 225. in
     *note http.client.HTTPConnection: b0e. by closing the proxy /
     tunnel's CONNECT response explicitly.

   - gh-103462(74): Fixed an issue with using *note writelines(): 1693.
     in *note asyncio: 8. to send very large payloads that exceed the
     amount of data that can be written in one call to *note
     socket.socket.send(): d74. or *note socket.socket.sendmsg(): 443,
     resulting in the remaining buffer being left unwritten.

   - gh-103449(75): Fix a bug in doc string generation in *note
     dataclasses.dataclass(): 1ad.

   - gh-103092(76): Isolate ‘_collections’ (apply PEP 687(77)).  Patch
     by Erlend E. Aasland.

   - gh-103357(78): Added support for *note logging.Formatter: 143a.
     ‘defaults’ parameter to *note logging.config.dictConfig(): 1180.
     and *note logging.config.fileConfig(): b1f.  Patch by Bar Harel.

   - gh-103092(79): Adapt the *note winreg: fe. extension module to PEP
     687(80).

   - gh-74690(81): The performance of *note isinstance(): 40e. checks
     against *note runtime-checkable protocols: 40f. has been
     considerably improved for protocols that only have a few members.
     To achieve this improvement, several internal implementation
     details of the *note typing: ed. module have been refactored,
     including ‘typing._ProtocolMeta.__instancecheck__’,
     ‘typing._is_callable_members_only’, and
     ‘typing._get_protocol_attrs’.  Patches by Alex Waygood.

   - gh-74690(82): The members of a runtime-checkable protocol are now
     considered "frozen" at runtime as soon as the class has been
     created.  See *note "What's new in Python 3.12": 49d. for more
     details.

   - gh-103256(83): Fixed a bug that caused *note hmac: 60. to raise an
     exception when the requested hash algorithm was not available in
     OpenSSL despite being available separately as part of ‘hashlib’
     itself.  It now falls back properly to the built-in.  This could
     happen when, for example, your OpenSSL does not include SHA3
     support and you want to compute ‘hmac.digest(b'K', b'M',
     'sha3_256')’.

   - gh-102778(84): Support ‘sys.last_exc’ in *note idlelib: 69.

   - gh-103285(85): Improve performance of *note
     ast.get_source_segment(): 9a5.

   - gh-103225(86): Fix a bug in *note pdb: 94. when displaying line
     numbers of module-level source code.

   - gh-103092(87): Adapt the *note msvcrt: 85. extension module to PEP
     687(88).

   - gh-103092(89): Adapt the *note winsound: ff. extension module to
     PEP 687(90).

   - gh-93910(91): Remove deprecation of enum ‘member.member’ access.

   - gh-102978(92): Fixes *note unittest.mock.patch(): e5b. not
     enforcing function signatures for methods decorated with
     ‘@classmethod’ or ‘@staticmethod’ when patch is called with
     ‘autospec=True’.

   - gh-103092(93): Isolate ‘_socket’ (apply PEP 687(94)).  Patch by
     Erlend E. Aasland.

   - gh-100479(95): Add *note pathlib.PurePath.with_segments(): 474,
     which creates a path object from arguments.  This method is called
     whenever a derivative path is created, such as from *note
     pathlib.PurePath.parent: 1694.  Subclasses may override this method
     to share information between path objects.

   - gh-103220(96): Fix issue where *note os.path.join(): 1597. added a
     slash when joining onto an incomplete UNC drive with a trailing
     slash on Windows.

   - gh-103204(97): Fixes *note http.server: 68. accepting HTTP requests
     with HTTP version numbers preceded by '+', or '-', or with
     digit-separating '_' characters.  The length of the version numbers
     is also constrained.

   - gh-75586(98): Fix various Windows-specific issues with
     ‘shutil.which’.

   - gh-103193(99): Improve performance of *note
     inspect.getattr_static(): 461.  Patch by Alex Waygood.

   - gh-103176(100): *note sys._current_exceptions(): 48e. now returns a
     mapping from thread-id to an exception instance, rather than to a
     ‘(typ, exc, tb)’ tuple.

   - gh-103143(101): Polish the help messages and docstrings of *note
     pdb: 94.

   - gh-103015(102): Add 'entrypoint' keyword-only parameter to *note
     sqlite3.Connection.load_extension(): 484, for overriding the SQLite
     extension entry point.  Patch by Erlend E. Aasland.

   - gh-103000(103): Improve performance of *note dataclasses.astuple():
     1695. and *note dataclasses.asdict(): 168b. in cases where the
     contents are common Python types.

   - gh-102953(104): The extraction methods in *note tarfile: c8, and
     *note shutil.unpack_archive(): 438, have a new a 'filter' argument
     that allows limiting tar features than may be surprising or
     dangerous, such as creating files outside the destination
     directory.  See *note Extraction filters: 439. for details.

   - gh-97696(105): Implemented an eager task factory in asyncio.  When
     used as a task factory on an event loop, it performs eager
     execution of coroutines.  Coroutines that are able to complete
     synchronously (e.g.  return or raise without blocking) are returned
     immediately as a finished task, and the task is never scheduled to
     the event loop.  If the coroutine blocks, the (pending) task is
     scheduled and returned.

   - gh-81079(106): Add 'case_sensitive' keyword-only argument to *note
     pathlib.Path.glob(): 20e. and *note rglob(): 20f.

   - gh-101819(107): Isolate the *note io: 73. extension module by
     applying PEP 687(108).  Patch by Kumar Aditya, Victor Stinner, and
     Erlend E. Aasland.

   - gh-91896(109): Deprecate *note collections.abc.ByteString: 2a3.

   - gh-101362(110): Speed up *note pathlib.Path: 20a. construction by
     omitting the path anchor from the internal list of path parts.

   - gh-102114(111): Functions in the *note dis: 30. module that accept
     a source code string as argument now print a more concise traceback
     when the string contains a syntax or indentation error.

   - gh-62432(112): The *note unittest: ef. runner will now exit with
     status code 5 if no tests were run.  It is common for test runner
     misconfiguration to fail to find any tests, this should be an
     error.

   - gh-78079(113): Fix incorrect normalization of UNC device path
     roots, and partial UNC share path roots, in *note pathlib.PurePath:
     473.  Pathlib no longer appends a trailing slash to such paths.

   - gh-85984(114): Add *note tty.cfmakeraw(): 1632. and *note
     tty.cfmakecbreak(): 15dd. to *note tty: e9. and modernize, the
     behavior of *note tty.setraw(): 1631. and *note tty.setcbreak():
     15dc. to use POSIX.1-2017 Chapter 11 "General Terminal Interface"
     flag masks by default.

   - gh-101688(115): Implement *note types.get_original_bases(): 49a. to
     provide further introspection for types.

   - gh-101640(116): *note argparse.ArgumentParser: 503. now catches
     errors when writing messages, such as when *note sys.stderr: 907.
     is ‘None’.  Patch by Oleg Iarygin.

   - gh-83861(117): Fix datetime.astimezone method return value when
     invoked on a naive datetime instance that represents local time
     falling in a timezone transition gap.  PEP 495 requires that
     instances with fold=1 produce earlier times than those with fold=0
     in this case.

   - gh-89550(118): Decrease execution time of some *note gzip: 5d. file
     writes by 15% by adding more appropriate buffering.

   - gh-95299(119): Remove the bundled setuptools wheel from
     ‘ensurepip’, and stop installing setuptools in environments created
     by ‘venv’.

   - gh-99353(120): Respect the *note http.client.HTTPConnection: b0e.
     ‘.debuglevel’ flag in ‘urllib.request.AbstractHTTPHandler’ when its
     constructor parameter ‘debuglevel’ is not set.  And do the same for
     ‘*HTTPS*’.

   - gh-98040(121): Remove the long-deprecated ‘imp’ module.

   - gh-97850(122): Deprecate *note pkgutil.find_loader(): 2ac. and
     *note pkgutil.get_loader(): 2ad. in favor of *note
     importlib.util.find_spec(): 2ae.

   - gh-94473(123): Flatten arguments in ‘tkinter.Canvas.coords()’.  It
     now accepts not only ‘x1, y1, x2, y2, ...’ and ‘[x1, y1, x2, y2,
     ...]’, but also ‘(x1, y1), (x2, y2), ...’ and ‘[(x1, y1), (x2, y2),
     ...]’.

   - gh-98040(124): Remove more deprecated importlib APIs:
     ‘find_loader()’, ‘find_module()’, ‘importlib.abc.Finder’,
     ‘pkgutil.ImpImporter’, ‘pkgutil.ImpLoader’.

   - gh-96522(125): Fix potential deadlock in pty.spawn()

   - gh-96534(126): Support divert(4) added in FreeBSD 14.

   - gh-87474(127): Fix potential file descriptor leaks in *note
     subprocess.Popen: 17e.

   - gh-94906(128): Support multiple steps in *note math.nextafter():
     465.  Patch by Shantanu Jain and Matthias Gorgens.

   - gh-51574(129): Make *note tempfile.mkdtemp(): 200. return absolute
     paths when its 'dir' parameter is relative.

   - gh-94518(130): Convert private ‘_posixsubprocess.fork_exec()’ to
     use Argument Clinic.

   - gh-92184(131): When creating zip files using *note zipfile: 117,
     ‘os.altsep’, if not ‘None’, will always be treated as a path
     separator even when it is not ‘/’.  Patch by Carey Metcalfe.

   - bpo-46797(132): Deprecation warnings are now emitted for ‘ast.Num’,
     ‘ast.Bytes’, ‘ast.Str’, ‘ast.NameConstant’ and ‘ast.Ellipsis’.
     These have been documented as deprecated since Python 3.8, and will
     be removed in Python 3.14.

   - bpo-44844(133): Enables *note webbrowser: fd. to detect and launch
     Microsoft Edge browser.

   - bpo-45606(134): Fixed the bug in *note pathlib.Path.glob(): 20e. -
     previously a dangling symlink would not be found by this method
     when the pattern is an exact match, but would be found when the
     pattern contains a wildcard or the recursive wildcard (‘**’).  With
     this change, a dangling symlink will be found in both cases.

   - bpo-23041(135): Add *note QUOTE_STRINGS: 452. and *note
     QUOTE_NOTNULL: 451. to the suite of *note csv: 21. module quoting
     styles.

   - bpo-24964(136): Added *note
     http.client.HTTPConnection.get_proxy_response_headers(): 1668. that
     provides access to the HTTP headers on a proxy server response to
     the ‘CONNECT’ request.

   - bpo-17258(137): *note multiprocessing: 86. now supports stronger
     HMAC algorithms for inter-process connection authentication rather
     than only HMAC-MD5.

   - bpo-39744(138): Make *note
     asyncio.subprocess.Process.communicate(): 1696. close the
     subprocess's stdin even when called with ‘input=None’.

   - bpo-22708(139): http.client CONNECT method tunnel improvements: Use
     HTTP 1.1 protocol; send a matching Host: header with CONNECT, if
     one is not provided; convert IDN domain names to Punycode.  Patch
     by Michael Handler.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104600

   (2) https://peps.python.org/pep-0695/

   (3) https://github.com/python/cpython/issues/104340

   (4) https://github.com/python/cpython/issues/104555

   (5) https://github.com/python/cpython/issues/104372

   (6) https://github.com/python/cpython/issues/104484

   (7) https://github.com/python/cpython/issues/75367

   (8) https://github.com/python/cpython/issues/104536

   (9) https://github.com/python/cpython/issues/103857

   (10) https://github.com/python/cpython/issues/101520

   (11) https://github.com/python/cpython/issues/104392

   (12) https://github.com/python/cpython/issues/102613

   (13) https://github.com/python/cpython/issues/103000

   (14) https://github.com/python/cpython/issues/104301

   (15) https://github.com/python/cpython/issues/104139

   (16) 
https://support.apple.com/en-gb/guide/deployment/depce7cefc4d/web

   (17) https://github.com/python/cpython/issues/104307

   (18) https://github.com/python/cpython/issues/104310

   (19) https://github.com/python/cpython/issues/87695

   (20) https://github.com/python/cpython/issues/104265

   (21) https://bugs.python.org/issue?@action=redirect&bpo=14935

   (22) https://github.com/python/cpython/issues/102613

   (23) https://github.com/python/cpython/issues/65772

   (24) https://github.com/python/cpython/issues/90208

   (25) https://github.com/python/cpython/issues/104144

   (26) https://github.com/python/cpython/issues/104144

   (27) https://github.com/python/cpython/issues/104114

   (28) https://github.com/python/cpython/issues/104104

   (29) https://github.com/python/cpython/issues/104102

   (30) https://github.com/python/cpython/issues/103822

   (31) https://github.com/python/cpython/issues/103629

   (32) https://peps.python.org/pep-0692/

   (33) https://github.com/python/cpython/issues/103963

   (34) https://github.com/python/cpython/issues/104035

   (35) https://github.com/python/cpython/issues/103987

   (36) https://github.com/python/cpython/issues/103977

   (37) https://github.com/python/cpython/issues/88773

   (38) https://github.com/python/cpython/issues/103935

   (39) https://github.com/python/cpython/issues/68968

   (40) https://github.com/python/cpython/issues/100370

   (41) https://github.com/python/cpython/issues/102628

   (42) https://github.com/python/cpython/issues/103636

   (43) https://github.com/python/cpython/issues/103583

   (44) https://github.com/python/cpython/issues/103848

   (45) https://github.com/python/cpython/issues/103872

   (46) https://github.com/python/cpython/issues/99944

   (47) https://github.com/python/cpython/issues/74940

   (48) https://github.com/python/cpython/issues/103861

   (49) https://github.com/python/cpython/issues/103857

   (50) https://github.com/python/cpython/issues/103839

   (51) https://github.com/python/cpython/issues/103791

   (52) https://github.com/python/cpython/issues/90750

   (53) https://github.com/python/cpython/issues/103685

   (54) https://github.com/python/cpython/issues/81403

   (55) https://github.com/python/cpython/issues/103699

   (56) https://github.com/python/cpython/issues/103693

   (57) https://github.com/python/cpython/issues/92248

   (58) https://github.com/python/cpython/issues/89415

   (59) https://github.com/python/cpython/issues/103673

   (60) https://github.com/python/cpython/issues/103636

   (61) https://github.com/python/cpython/issues/84976

   (62) https://github.com/python/cpython/issues/103596

   (63) https://github.com/python/cpython/issues/103584

   (64) https://github.com/python/cpython/issues/103578

   (65) https://github.com/python/cpython/issues/103556

   (66) https://github.com/python/cpython/issues/103559

   (67) https://github.com/python/cpython/issues/103548

   (68) https://github.com/python/cpython/issues/103538

   (69) https://github.com/python/cpython/issues/103533

   (70) https://github.com/python/cpython/issues/103525

   (71) https://github.com/python/cpython/issues/103489

   (72) https://github.com/python/cpython/issues/103365

   (73) https://github.com/python/cpython/issues/103472

   (74) https://github.com/python/cpython/issues/103462

   (75) https://github.com/python/cpython/issues/103449

   (76) https://github.com/python/cpython/issues/103092

   (77) https://peps.python.org/pep-0687/

   (78) https://github.com/python/cpython/issues/103357

   (79) https://github.com/python/cpython/issues/103092

   (80) https://peps.python.org/pep-0687/

   (81) https://github.com/python/cpython/issues/74690

   (82) https://github.com/python/cpython/issues/74690

   (83) https://github.com/python/cpython/issues/103256

   (84) https://github.com/python/cpython/issues/102778

   (85) https://github.com/python/cpython/issues/103285

   (86) https://github.com/python/cpython/issues/103225

   (87) https://github.com/python/cpython/issues/103092

   (88) https://peps.python.org/pep-0687/

   (89) https://github.com/python/cpython/issues/103092

   (90) https://peps.python.org/pep-0687/

   (91) https://github.com/python/cpython/issues/93910

   (92) https://github.com/python/cpython/issues/102978

   (93) https://github.com/python/cpython/issues/103092

   (94) https://peps.python.org/pep-0687/

   (95) https://github.com/python/cpython/issues/100479

   (96) https://github.com/python/cpython/issues/103220

   (97) https://github.com/python/cpython/issues/103204

   (98) https://github.com/python/cpython/issues/75586

   (99) https://github.com/python/cpython/issues/103193

   (100) https://github.com/python/cpython/issues/103176

   (101) https://github.com/python/cpython/issues/103143

   (102) https://github.com/python/cpython/issues/103015

   (103) https://github.com/python/cpython/issues/103000

   (104) https://github.com/python/cpython/issues/102953

   (105) https://github.com/python/cpython/issues/97696

   (106) https://github.com/python/cpython/issues/81079

   (107) https://github.com/python/cpython/issues/101819

   (108) https://peps.python.org/pep-0687/

   (109) https://github.com/python/cpython/issues/91896

   (110) https://github.com/python/cpython/issues/101362

   (111) https://github.com/python/cpython/issues/102114

   (112) https://github.com/python/cpython/issues/62432

   (113) https://github.com/python/cpython/issues/78079

   (114) https://github.com/python/cpython/issues/85984

   (115) https://github.com/python/cpython/issues/101688

   (116) https://github.com/python/cpython/issues/101640

   (117) https://github.com/python/cpython/issues/83861

   (118) https://github.com/python/cpython/issues/89550

   (119) https://github.com/python/cpython/issues/95299

   (120) https://github.com/python/cpython/issues/99353

   (121) https://github.com/python/cpython/issues/98040

   (122) https://github.com/python/cpython/issues/97850

   (123) https://github.com/python/cpython/issues/94473

   (124) https://github.com/python/cpython/issues/98040

   (125) https://github.com/python/cpython/issues/96522

   (126) https://github.com/python/cpython/issues/96534

   (127) https://github.com/python/cpython/issues/87474

   (128) https://github.com/python/cpython/issues/94906

   (129) https://github.com/python/cpython/issues/51574

   (130) https://github.com/python/cpython/issues/94518

   (131) https://github.com/python/cpython/issues/92184

   (132) https://bugs.python.org/issue?@action=redirect&bpo=46797

   (133) https://bugs.python.org/issue?@action=redirect&bpo=44844

   (134) https://bugs.python.org/issue?@action=redirect&bpo=45606

   (135) https://bugs.python.org/issue?@action=redirect&bpo=23041

   (136) https://bugs.python.org/issue?@action=redirect&bpo=24964

   (137) https://bugs.python.org/issue?@action=redirect&bpo=17258

   (138) https://bugs.python.org/issue?@action=redirect&bpo=39744

   (139) https://bugs.python.org/issue?@action=redirect&bpo=22708


File: python.info,  Node: Documentation<10>,  Next: Tests<13>,  Prev: Library<15>,  Up: Python 3 12 0 beta 1

1.23.16.4 Documentation
.......................

   - gh-67056(1): Document that the effect of registering or
     unregistering an *note atexit: 9. cleanup function from within a
     registered cleanup function is undefined.

   - gh-103629(2): Mention the new way of typing ‘**kwargs’ with
     ‘Unpack’ and ‘TypedDict’ introduced in PEP 692(3).

   - gh-48241(4): Clarifying documentation about the url parameter to
     urllib.request.urlopen and urllib.request.Request needing to be
     encoded properly.

   - gh-86094(5): Add support for Unicode Path Extra Field in ZipFile.
     Patch by Yeojin Kim and Andrea Giudiceandrea

   - gh-99202(6): Fix extension type from documentation for compiling in
     C++20 mode

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/67056

   (2) https://github.com/python/cpython/issues/103629

   (3) https://peps.python.org/pep-0692/

   (4) https://github.com/python/cpython/issues/48241

   (5) https://github.com/python/cpython/issues/86094

   (6) https://github.com/python/cpython/issues/99202


File: python.info,  Node: Tests<13>,  Next: Build<15>,  Prev: Documentation<10>,  Up: Python 3 12 0 beta 1

1.23.16.5 Tests
...............

   - gh-104494(1): Update ‘test_pack_configure_in’ and
     ‘test_place_configure_in’ for changes to error message formatting
     in Tk 8.7.

   - gh-104461(2): Run test_configure_screen on X11 only, since the
     ‘DISPLAY’ environment variable and ‘-screen’ option for toplevels
     are not useful on Tk for Win32 or Aqua.

   - gh-86275(3): Added property-based tests to the *note zoneinfo: 11a.
     tests, along with stubs for the ‘hypothesis’ interface.  (Patch by
     Paul Ganssle)

   - gh-103329(4): Regression tests for the behaviour of
     ‘unittest.mock.PropertyMock’ were added.

   - gh-102795(5): fix use of poll in test_epoll's test_control_and_wait

   - gh-75729(6): Fix the *note os.spawn*: 1699. tests failing on
     Windows when the working directory or interpreter path contains
     spaces.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104494

   (2) https://github.com/python/cpython/issues/104461

   (3) https://github.com/python/cpython/issues/86275

   (4) https://github.com/python/cpython/issues/103329

   (5) https://github.com/python/cpython/issues/102795

   (6) https://github.com/python/cpython/issues/75729


File: python.info,  Node: Build<15>,  Next: Windows<12>,  Prev: Tests<13>,  Up: Python 3 12 0 beta 1

1.23.16.6 Build
...............

   - gh-101282(1): BOLT optimization is now applied to the libpython
     shared library if building a shared library.  BOLT instrumentation
     and application settings can now be influenced via the
     ‘BOLT_INSTRUMENT_FLAGS’ and ‘BOLT_APPLY_FLAGS’ configure variables.

   - gh-99017(2): ‘PYTHON_FOR_REGEN’ now require Python 3.10 or newer.

   - gh-104490(3): Define ‘.PHONY’ / virtual make targets consistently
     and properly.

   - gh-104106(4): Add gcc fallback of mkfifoat/mknodat for macOS. Patch
     by Donghee Na.

   - gh-103532(5): The ‘TKINTER_PROTECT_LOADTK’ macro is no longer
     defined or used in the ‘_tkinter’ module.  It was previously only
     defined when building against Tk 8.4.13 and older, but Tk older
     than 8.5.12 has been unsupported since gh-91152(6).

   - gh-99069(7): Extended workaround defining ‘static_assert’ when
     missing from the libc headers to all clang and gcc builds.  In
     particular, this fixes building on macOS <= 10.10.

   - gh-100220(8): Changed the default value of the ‘SHELL’ Makefile
     variable from ‘/bin/sh’ to ‘/bin/sh -e’ to ensure that complex
     recipes correctly fail after an error.  Previously, ‘make install’
     could fail to install some files and yet return a successful
     result.

   - gh-90656(9): Add platform triplets for 64-bit LoongArch:

        * loongarch64-linux-gnusf

        * loongarch64-linux-gnuf32

        * loongarch64-linux-gnu

     Patch by Zhang Na.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101282

   (2) https://github.com/python/cpython/issues/99017

   (3) https://github.com/python/cpython/issues/104490

   (4) https://github.com/python/cpython/issues/104106

   (5) https://github.com/python/cpython/issues/103532

   (6) https://github.com/python/cpython/issues/91152

   (7) https://github.com/python/cpython/issues/99069

   (8) https://github.com/python/cpython/issues/100220

   (9) https://github.com/python/cpython/issues/90656


File: python.info,  Node: Windows<12>,  Next: macOS<10>,  Prev: Build<15>,  Up: Python 3 12 0 beta 1

1.23.16.7 Windows
.................

   - gh-104623(1): Update Windows installer to use SQLite 3.42.0.

   - gh-82814(2): Fix a potential ‘[Errno 13] Permission denied’ when
     using *note shutil.copystat(): 1101. within Windows Subsystem for
     Linux (WSL) on a mounted filesystem by adding ‘errno.EACCES’ to the
     list of ignored errors within the internal implementation.

   - gh-103088(3): Fix virtual environment ‘activate’ script having
     incorrect line endings for Cygwin.

   - gh-103088(4): Fixes venvs not working in bash on Windows across
     different disks

   - gh-102997(5): Update Windows installer to use SQLite 3.41.2.

   - gh-88013(6): Fixed a bug where *note TypeError: 502. was raised
     when calling ‘ntpath.realpath()’ with a bytes parameter in some
     cases.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104623

   (2) https://github.com/python/cpython/issues/82814

   (3) https://github.com/python/cpython/issues/103088

   (4) https://github.com/python/cpython/issues/103088

   (5) https://github.com/python/cpython/issues/102997

   (6) https://github.com/python/cpython/issues/88013


File: python.info,  Node: macOS<10>,  Next: IDLE<14>,  Prev: Windows<12>,  Up: Python 3 12 0 beta 1

1.23.16.8 macOS
...............

   - gh-99834(1): Update macOS installer to Tcl/Tk 8.6.13.

   - gh-104623(2): Update macOS installer to SQLite 3.42.0.

   - gh-103545(3): Add ‘os.PRIO_DARWIN_THREAD’,
     ‘os.PRIO_DARWIN_PROCESS’, ‘os.PRIO_DARWIN_BG’ and
     ‘os.PRIO_DARWIN_NONUI’.  These can be used with ‘os.setpriority’ to
     run the process at a lower priority and make use of the efficiency
     cores on Apple Silicon systems.

   - gh-104180(4): Support reading SOCKS proxy configuration from macOS
     System Configuration.  Patch by Sam Schott.

   - gh-60436(5): update curses textbox to additionally handle backspace
     using the ‘curses.ascii.DEL’ key press.

   - gh-102997(6): Update macOS installer to SQLite 3.41.2.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99834

   (2) https://github.com/python/cpython/issues/104623

   (3) https://github.com/python/cpython/issues/103545

   (4) https://github.com/python/cpython/issues/104180

   (5) https://github.com/python/cpython/issues/60436

   (6) https://github.com/python/cpython/issues/102997


File: python.info,  Node: IDLE<14>,  Next: Tools/Demos<7>,  Prev: macOS<10>,  Up: Python 3 12 0 beta 1

1.23.16.9 IDLE
..............

   - gh-104499(1): Fix completions for Tk Aqua 8.7 (currently blank).

   - gh-104496(2): About prints both tcl and tk versions if different
     (expected someday).

   - gh-88496(3): Fix IDLE test hang on macOS.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104499

   (2) https://github.com/python/cpython/issues/104496

   (3) https://github.com/python/cpython/issues/88496


File: python.info,  Node: Tools/Demos<7>,  Next: C API<15>,  Prev: IDLE<14>,  Up: Python 3 12 0 beta 1

1.23.16.10 Tools/Demos
......................

   - gh-104389(1): Argument Clinic C converters now accept the ‘unused’
     keyword, for wrapping a parameter with *note Py_UNUSED: 1682.
     Patch by Erlend E. Aasland.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/104389


File: python.info,  Node: C API<15>,  Prev: Tools/Demos<7>,  Up: Python 3 12 0 beta 1

1.23.16.11 C API
................

   - gh-101291(1): Added unstable C API for extracting the value of
     "compact" integers: *note PyUnstable_Long_IsCompact(): 555. and
     *note PyUnstable_Long_CompactValue(): 556.

   - gh-104109(2): We've added ‘Py_NewInterpreterFromConfig()’ and
     ‘PyInterpreterConfig’ to the public C-API (but not the stable ABI;
     not yet at least).  The new function may be used to create a new
     interpreter with various features configured.  The function was
     added to support PEP 684 (per-interpreter GIL).

   - gh-103968(3): *note PyType_FromSpec(): 549. and its variants now
     allow creating classes whose metaclass overrides *note tp_new: 54b.
     The ‘tp_new’ is ignored.  This behavior is deprecated and will be
     disallowed in 3.14+.  The new *note PyType_FromMetaclass(): 51b.
     already disallows it.

   - gh-103743(4): Add *note PyUnstable_Object_GC_NewWithExtraData():
     16a0. function that can be used to allocate additional memory after
     an object for data not managed by Python.

   - gh-103295(5): Introduced *note PyUnstable_WritePerfMapEntry():
     16a1, *note PyUnstable_PerfMapState_Init(): 16a2. and *note
     PyUnstable_PerfMapState_Fini(): 16a3.  These allow extension
     modules (JIT compilers in particular) to write to perf-map files in
     a thread safe manner.  The *note Python support for the Linux perf
     profiler: 16a4. also uses these APIs to write entries in the
     perf-map file.

   - gh-103509(6): Added C API for extending types whose instance memory
     layout is opaque: *note PyType_Spec.basicsize: 513. can now be zero
     or negative, *note PyObject_GetTypeData(): 514. can be used to get
     subclass-specific data, and *note Py_TPFLAGS_ITEMS_AT_END: 516. can
     be used to safely extend variable-size objects.  See PEP 697(7) for
     details.

   - gh-103091(8): Add a new C-API function to eagerly assign a version
     tag to a PyTypeObject: ‘PyUnstable_Type_AssignVersionTag()’.

   - gh-101408(9): *note PyObject_GC_Resize: 16a5. should calculate
     preheader size if needed.  Patch by Donghee Na.

   - gh-98836(10): Add support of more formatting options (left
     aligning, octals, uppercase hexadecimals, ‘intmax_t’, ‘ptrdiff_t’,
     ‘wchar_t’ C strings, variable width and precision) in *note
     PyUnicode_FromFormat(): 363. and *note PyUnicode_FromFormatV():
     540.

   - gh-96803(11): Add unstable C-API functions to get the code object,
     lasti and line number from the internal ‘_PyInterpreterFrame’ in
     the limited API. The functions are:

        * ‘PyCodeObject * PyUnstable_InterpreterFrame_GetCode(struct
          _PyInterpreterFrame *frame)’

        * ‘int PyUnstable_InterpreterFrame_GetLasti(struct
          _PyInterpreterFrame *frame)’

        * ‘int PyUnstable_InterpreterFrame_GetLine(struct
          _PyInterpreterFrame *frame)’

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101291

   (2) https://github.com/python/cpython/issues/104109

   (3) https://github.com/python/cpython/issues/103968

   (4) https://github.com/python/cpython/issues/103743

   (5) https://github.com/python/cpython/issues/103295

   (6) https://github.com/python/cpython/issues/103509

   (7) https://peps.python.org/pep-0697/

   (8) https://github.com/python/cpython/issues/103091

   (9) https://github.com/python/cpython/issues/101408

   (10) https://github.com/python/cpython/issues/98836

   (11) https://github.com/python/cpython/issues/96803


File: python.info,  Node: Python 3 12 0 alpha 7,  Next: Python 3 12 0 alpha 6,  Prev: Python 3 12 0 beta 1,  Up: 変更履歴

1.23.17 Python 3.12.0 alpha 7
-----------------------------

'Release date: 2023-04-04'

* Menu:

* Core and Builtins: Core and Builtins<17>.
* Library: Library<16>.
* Documentation: Documentation<11>.
* Tests: Tests<14>.
* Build: Build<16>.
* Windows: Windows<13>.
* Tools/Demos: Tools/Demos<8>.
* C API: C API<16>.


File: python.info,  Node: Core and Builtins<17>,  Next: Library<16>,  Up: Python 3 12 0 alpha 7

1.23.17.1 Core and Builtins
...........................

   - gh-102192(1): Deprecated ‘_PyErr_ChainExceptions’ in favour of
     ‘_PyErr_ChainExceptions1’.

   - gh-89987(2): Reduce the number of inline *note CACHE: 6c4. entries
     for *note BINARY_SUBSCR: 16a8.

   - gh-102859(3): Removed ‘JUMP_IF_FALSE_OR_POP’ and
     ‘JUMP_IF_TRUE_OR_POP’ instructions.

   - gh-101975(4): Fixed ‘stacktop’ value on tracing entries to avoid
     corruption on garbage collection.

   - gh-102778(5): Add *note sys.last_exc: 48a. and deprecate *note
     sys.last_type: 48b, *note sys.last_value: 48c. and *note
     sys.last_traceback: 48d, which hold the same information in its
     legacy form.

   - gh-100982(6): Replace all occurrences of ‘COMPARE_AND_BRANCH’ with
     *note COMPARE_OP: 937.

   - gh-102701(7): Fix overflow when creating very large dict.

   - gh-102755(8): Add *note PyErr_DisplayException(): 3db. which takes
     just an exception instance, to replace the legacy ‘PyErr_Display()’
     which takes the ‘(typ, exc, tb)’ triplet.

   - gh-102594(9): Add note to exception raised in ‘PyErr_SetObject’
     when normalization fails.

   - gh-90997(10): Shrink the number of inline *note CACHE: 6c4. entries
     used by *note LOAD_GLOBAL: 164f.

   - gh-102491(11): Improve import time of ‘platform’ by removing
     IronPython version parsing.  The IronPython version parsing was not
     functional (see
     ‘https://github.com/IronLanguages/ironpython3/issues/1667’).

   - gh-101291(12): Rearrage bits in first field (after header) of
     PyLongObject.  * Bits 0 and 1: 1 - sign.  I.e.  0 for positive
     numbers, 1 for zero and 2 for negative numbers.  * Bit 2 reserved
     (probably for the immortal bit) * Bits 3+ the unsigned size.

     This makes a few operations slightly more efficient, and will
     enable a more compact and faster 2s-complement representation of
     most ints in future.

   - gh-102397(13): Fix segfault from race condition in signal handling
     during garbage collection.  Patch by Kumar Aditya.

   - gh-102406(14): *note codecs: 14. encoding/decoding errors now get
     the context information (which operation and which codecs) attached
     as PEP 678(15) notes instead of through chaining a new instance of
     the exception.

   - gh-102281(16): Fix potential nullptr dereference and use of
     uninitialized memory in fileutils.  Patch by Max Bachmann.

   - gh-102300(17): Reuse operands with refcount of 1 in float
     specializations of BINARY_OP.

   - gh-102213(18): Fix performance loss when accessing an object's
     attributes with ‘__getattr__’ defined.

   - gh-102255(19): Improve build support for the Xbox.  Patch by Max
     Bachmann.

   - gh-102027(20): Fix SSE2 and SSE3 detection in ‘_blake2’ internal
     module.  Patch by Max Bachmann.

   - gh-101865(21): Deprecate ‘co_lnotab’ in code objects, schedule it
     for removal in Python 3.14

   - bpo-1635741(22): Adapt ‘_pickle’ to PEP 687(23).  Patch by Mohamed
     Koubaa and Erlend Aasland.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102192

   (2) https://github.com/python/cpython/issues/89987

   (3) https://github.com/python/cpython/issues/102859

   (4) https://github.com/python/cpython/issues/101975

   (5) https://github.com/python/cpython/issues/102778

   (6) https://github.com/python/cpython/issues/100982

   (7) https://github.com/python/cpython/issues/102701

   (8) https://github.com/python/cpython/issues/102755

   (9) https://github.com/python/cpython/issues/102594

   (10) https://github.com/python/cpython/issues/90997

   (11) https://github.com/python/cpython/issues/102491

   (12) https://github.com/python/cpython/issues/101291

   (13) https://github.com/python/cpython/issues/102397

   (14) https://github.com/python/cpython/issues/102406

   (15) https://peps.python.org/pep-0678/

   (16) https://github.com/python/cpython/issues/102281

   (17) https://github.com/python/cpython/issues/102300

   (18) https://github.com/python/cpython/issues/102213

   (19) https://github.com/python/cpython/issues/102255

   (20) https://github.com/python/cpython/issues/102027

   (21) https://github.com/python/cpython/issues/101865

   (22) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (23) https://peps.python.org/pep-0687/


File: python.info,  Node: Library<16>,  Next: Documentation<11>,  Prev: Core and Builtins<17>,  Up: Python 3 12 0 alpha 7

1.23.17.2 Library
.................

   - gh-103085(1): Pure python *note locale.getencoding(): 2be. will not
     warn deprecation.

   - gh-103068(2): It's no longer possible to register conditional
     breakpoints in *note Pdb: 8f0. that raise *note SyntaxError: 172.
     Patch by Tian Gao.

   - gh-102549(3): Don't ignore exceptions in member type creation.

   - gh-103056(4): Ensure final ‘_generate_next_value_’ is a
     ‘staticmethod’.

   - gh-103046(5): Display current line label correctly in *note dis:
     30. when ‘show_caches’ is False and ‘lasti’ points to a CACHE
     entry.

   - gh-102433(6): *note isinstance(): 40e. checks against *note
     runtime-checkable protocols: 40f. now use *note
     inspect.getattr_static(): 461. rather than *note hasattr(): 49e. to
     lookup whether attributes exist.  This means that descriptors and
     *note __getattr__(): 49f. methods are no longer unexpectedly
     evaluated during ‘isinstance()’ checks against runtime-checkable
     protocols.  However, it may also mean that some objects which used
     to be considered instances of a runtime-checkable protocol may no
     longer be considered instances of that protocol on Python 3.12+,
     and vice versa.  Most users are unlikely to be affected by this
     change.  Patch by Alex Waygood.

   - gh-103023(7): It's no longer possible to register expressions to
     display in *note Pdb: 8f0. that raise *note SyntaxError: 172.
     Patch by Tian Gao.

   - gh-102947(8): Improve traceback when *note dataclasses.fields():
     16aa. is called on a non-dataclass.  Patch by Alex Waygood

   - gh-102780(9): The *note asyncio.Timeout: 1630. context manager now
     works reliably even when performing cleanup due to task
     cancellation.  Previously it could raise a *note CancelledError:
     19d. instead of an *note TimeoutError: 16ab. in such cases.

   - gh-102871(10): Remove support for obsolete browsers from *note
     webbrowser: fd.  Removed browsers include Grail, Mosaic, Netscape,
     Galeon, Skipstone, Iceape, Firebird, and Firefox versions 35 and
     below.

   - gh-102839(11): Improve performance of *note math.log(): 1465.
     arguments handling by removing the argument clinic.

   - gh-102828(12): Add the ‘onexc’ arg to *note shutil.rmtree(): 2d8,
     which is like ‘onerror’ but expects an exception instance rather
     than an exc_info tuple.  Deprecate ‘onerror’.

   - gh-88965(13): typing: Fix a bug relating to substitution in custom
     classes generic over a *note ParamSpec: 144.  Previously, if the
     ‘ParamSpec’ was substituted with a parameters list that itself
     contained a *note TypeVar: 143, the ‘TypeVar’ in the parameters
     list could not be subsequently substituted.  This is now fixed.

     Patch by Nikita Sobolev.

   - gh-76846(14): Fix issue where ‘__new__()’ and ‘__init__()’ methods
     of *note pathlib.PurePath: 473. and *note Path: 20a. subclasses
     were not called in some circumstances.

   - gh-78530(15): *note asyncio.wait(): 44c. now accepts generators
     yielding tasks.  Patch by Kumar Aditya.

   - gh-102748(16): *note asyncio.iscoroutine(): 44b. now returns
     ‘False’ for generators as *note asyncio: 8. does not support legacy
     generator-based coroutines.  Patch by Kumar Aditya.

   - gh-102670(17): Optimized fmean(), correlation(), covariance(), and
     linear_regression() using the new math.sumprod() function.

   - gh-102615(18): Typing: Improve the ‘repr’ of generic aliases for
     classes generic over a *note ParamSpec: 144.  (Use square brackets
     to represent a parameter list.)

   - gh-100112(19): *note asyncio.Task.get_coro(): 9a9. now always
     returns a coroutine when wrapping an awaitable object.  Patch by
     Kumar Aditya.

   - gh-102578(20): Speed up setting or deleting mutable attributes on
     non-dataclass subclasses of frozen dataclasses.  Due to the
     implementation of ‘__setattr__’ and ‘__delattr__’ for frozen
     dataclasses, this previously had a time complexity of 'O'('n').  It
     now has a time complexity of 'O'(1).

   - gh-102519(21): Add *note os.listdrives(): 46a, *note
     os.listvolumes(): 46b. and *note os.listmounts(): 46c. functions on
     Windows for enumerating drives, volumes and mount points

   - gh-74468(22): Attribute name of the extracted *note tarfile: c8.
     file object now holds filename of itself rather than of the archive
     it is contained in.  Patch by Oleg Iarygin.

   - gh-102378(23): Private helper method
     ‘inspect._signature_strip_non_python_syntax’ will no longer strip
     ‘/’ from the input string.

   - gh-79940(24): Add *note inspect.getasyncgenstate(): 45f. and *note
     inspect.getasyncgenlocals(): 460.  Patch by Thomas Krennwallner.

   - gh-102103(25): Add ‘module’ argument to *note
     dataclasses.make_dataclass(): 16ac. and make classes produced by it
     pickleable.

   - gh-102069(26): Fix ‘__weakref__’ descriptor generation for custom
     dataclasses.

   - gh-102038(27): Skip a ‘stat’ in *note site: b5. if we have already
     found a ‘pyvenv.cfg’

   - gh-98886(28): Fix issues when defining dataclasses that have fields
     with specific underscore names that aren't clearly reserved by
     *note dataclasses: 27.

   - gh-101673(29): Fix a *note pdb: 94. bug where ‘ll’ clears the
     changes to local variables.

   - gh-101313(30): Added -h and -help arguments to the webbrowser CLI

   - gh-100372(31): *note ssl.SSLContext.load_verify_locations(): eb6.
     no longer incorrectly accepts some cases of trailing data when
     parsing DER.

   - gh-89727(32): Fix pathlib.Path.walk RecursionError on deep
     directory trees by rewriting it using iteration instead of
     recursion.

   - gh-100131(33): Added an optional ‘delete’ keyword argument to *note
     tempfile.TemporaryDirectory: 1205.

   - gh-48330(34): Added ‘--durations’ command line option, showing the
     N slowest test cases.  *note unittest.TextTestRunner: 16ad. and
     *note unittest.TextTestResult: 4fa. constructors accept a new
     'durations' keyword argument.  Subclasses should take this into
     account or accept ‘**kwargs’.  Added *note
     unittest.TestResult.addDuration(): 16ae. method and *note
     unittest.TestResult.collectedDurations: 1674. attribute.

     (Contributed by Giampaolo Rodola)

   - gh-98169(35): Fix *note dataclasses.astuple(): 1695. crash when
     *note collections.defaultdict: 118d. is present in the attributes.

   - gh-96931(36): Fix incorrect results from *note
     ssl.SSLSocket.shared_ciphers(): e35.

   - gh-95495(37): When built against OpenSSL 3.0, the *note ssl: bb.
     module had a bug where it reported unauthenticated EOFs (i.e.
     without close_notify) as a clean TLS-level EOF. It now raises *note
     SSLEOFError: 16af, matching the behavior in previous versions of
     OpenSSL. The *note options: 803. attribute on *note SSLContext:
     274. also no longer includes *note OP_IGNORE_UNEXPECTED_EOF: 802.
     by default.  This option may be set to specify the previous OpenSSL
     3.0 behavior.

   - gh-94684(38): Now *note uuid.uuid3(): 16b0. and *note uuid.uuid5():
     16b1. functions support *note bytes: 1a4. objects as their 'name'
     argument.

   - gh-94440(39): Fix a ‘concurrent.futures.process’ bug where
     ‘ProcessPoolExecutor’ shutdown could hang after a future has been
     quickly submitted and canceled.

   - gh-72346(40): Added deprecation warning to 'isdst' parameter of
     *note email.utils.localtime(): 2a5.

   - bpo-36305(41): Fix handling of Windows filenames that resemble
     drives, such as ‘./a:b’, in *note pathlib: 93.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/103085

   (2) https://github.com/python/cpython/issues/103068

   (3) https://github.com/python/cpython/issues/102549

   (4) https://github.com/python/cpython/issues/103056

   (5) https://github.com/python/cpython/issues/103046

   (6) https://github.com/python/cpython/issues/102433

   (7) https://github.com/python/cpython/issues/103023

   (8) https://github.com/python/cpython/issues/102947

   (9) https://github.com/python/cpython/issues/102780

   (10) https://github.com/python/cpython/issues/102871

   (11) https://github.com/python/cpython/issues/102839

   (12) https://github.com/python/cpython/issues/102828

   (13) https://github.com/python/cpython/issues/88965

   (14) https://github.com/python/cpython/issues/76846

   (15) https://github.com/python/cpython/issues/78530

   (16) https://github.com/python/cpython/issues/102748

   (17) https://github.com/python/cpython/issues/102670

   (18) https://github.com/python/cpython/issues/102615

   (19) https://github.com/python/cpython/issues/100112

   (20) https://github.com/python/cpython/issues/102578

   (21) https://github.com/python/cpython/issues/102519

   (22) https://github.com/python/cpython/issues/74468

   (23) https://github.com/python/cpython/issues/102378

   (24) https://github.com/python/cpython/issues/79940

   (25) https://github.com/python/cpython/issues/102103

   (26) https://github.com/python/cpython/issues/102069

   (27) https://github.com/python/cpython/issues/102038

   (28) https://github.com/python/cpython/issues/98886

   (29) https://github.com/python/cpython/issues/101673

   (30) https://github.com/python/cpython/issues/101313

   (31) https://github.com/python/cpython/issues/100372

   (32) https://github.com/python/cpython/issues/89727

   (33) https://github.com/python/cpython/issues/100131

   (34) https://github.com/python/cpython/issues/48330

   (35) https://github.com/python/cpython/issues/98169

   (36) https://github.com/python/cpython/issues/96931

   (37) https://github.com/python/cpython/issues/95495

   (38) https://github.com/python/cpython/issues/94684

   (39) https://github.com/python/cpython/issues/94440

   (40) https://github.com/python/cpython/issues/72346

   (41) https://bugs.python.org/issue?@action=redirect&bpo=36305


File: python.info,  Node: Documentation<11>,  Next: Tests<14>,  Prev: Library<16>,  Up: Python 3 12 0 alpha 7

1.23.17.3 Documentation
.......................

   - gh-103112(1): Add docstring to *note
     http.client.HTTPResponse.read(): 16b3. to fix ‘pydoc’ output.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/103112


File: python.info,  Node: Tests<14>,  Next: Build<16>,  Prev: Documentation<11>,  Up: Python 3 12 0 alpha 7

1.23.17.4 Tests
...............

   - gh-102980(1): Improve test coverage on *note pdb: 94.

   - gh-102537(2): Adjust the error handling strategy in
     ‘test_zoneinfo.TzPathTest.python_tzpath_context’.  Patch by Paul
     Ganssle.

   - gh-101377(3): Improved test_locale_calendar_formatweekday of
     calendar.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102980

   (2) https://github.com/python/cpython/issues/102537

   (3) https://github.com/python/cpython/issues/101377


File: python.info,  Node: Build<16>,  Next: Windows<13>,  Prev: Tests<14>,  Up: Python 3 12 0 alpha 7

1.23.17.5 Build
...............

   - gh-102973(1): Add a dev container (along with accompanying
     Dockerfile) for development purposes.

   - gh-102711(2): Fix ‘-Wstrict-prototypes’ compiler warnings.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102973

   (2) https://github.com/python/cpython/issues/102711


File: python.info,  Node: Windows<13>,  Next: Tools/Demos<8>,  Prev: Build<16>,  Up: Python 3 12 0 alpha 7

1.23.17.6 Windows
.................

   - gh-102690(1): Update *note webbrowser: fd. to fall back to
     Microsoft Edge instead of Internet Explorer.

   - gh-99726(2): Improves correctness of stat results for Windows, and
     uses faster API when available

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102690

   (2) https://github.com/python/cpython/issues/99726


File: python.info,  Node: Tools/Demos<8>,  Next: C API<16>,  Prev: Windows<13>,  Up: Python 3 12 0 alpha 7

1.23.17.7 Tools/Demos
.....................

   - gh-102809(1): ‘Misc/gdbinit’ was removed.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102809


File: python.info,  Node: C API<16>,  Prev: Tools/Demos<8>,  Up: Python 3 12 0 alpha 7

1.23.17.8 C API
...............

   - gh-102013(1): Add a new (unstable) C-API function for iterating
     over GC'able objects using a callback: ‘PyUnstable_VisitObjects’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102013


File: python.info,  Node: Python 3 12 0 alpha 6,  Next: Python 3 12 0 alpha 5,  Prev: Python 3 12 0 alpha 7,  Up: 変更履歴

1.23.18 Python 3.12.0 alpha 6
-----------------------------

'Release date: 2023-03-07'

* Menu:

* Security: Security<11>.
* Core and Builtins: Core and Builtins<18>.
* Library: Library<17>.
* Documentation: Documentation<12>.
* Tests: Tests<15>.
* Build: Build<17>.
* Windows: Windows<14>.
* macOS: macOS<11>.
* C API: C API<17>.


File: python.info,  Node: Security<11>,  Next: Core and Builtins<18>,  Up: Python 3 12 0 alpha 6

1.23.18.1 Security
..................

   - gh-99108(1): Replace builtin hashlib implementations of MD5 and
     SHA1 with verified ones from the HACL* project.

   - gh-101727(2): Updated the OpenSSL version used in Windows and macOS
     binary release builds to 1.1.1t to address CVE 2023-0286(3), CVE
     2022-4303(4), and CVE 2022-4303(5) per the OpenSSL 2023-02-07
     security advisory(6).

   - gh-99108(7): Replace the builtin *note hashlib: 5e. implementations
     of SHA2-384 and SHA2-512 originally from LibTomCrypt with formally
     verified, side-channel resistant code from the HACL*(8) project.
     The builtins remain a fallback only used when OpenSSL does not
     provide them.

   - gh-101283(9): *note subprocess.Popen: 17e. now uses a safer
     approach to find ‘cmd.exe’ when launching with ‘shell=True’.  Patch
     by Eryk Sun, based on a patch by Oleg Iarygin.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99108

   (2) https://github.com/python/cpython/issues/101727

   (3) https://www.cve.org/CVERecord?id=CVE-2023-0286

   (4) https://www.cve.org/CVERecord?id=CVE-2022-4303

   (5) https://www.cve.org/CVERecord?id=CVE-2022-4303

   (6) https://openssl-library.org/news/secadv/20230207.txt

   (7) https://github.com/python/cpython/issues/99108

   (8) https://github.com/hacl-star/hacl-star/

   (9) https://github.com/python/cpython/issues/101283


File: python.info,  Node: Core and Builtins<18>,  Next: Library<17>,  Prev: Security<11>,  Up: Python 3 12 0 alpha 6

1.23.18.2 Core and Builtins
...........................

   - gh-102493(1): Fix regression in semantics of normalisation in
     ‘PyErr_SetObject’.

   - gh-102416(2): Do not memoize incorrectly automatically generated
     loop rules in the parser.  Patch by Pablo Galindo.

   - gh-102356(3): Fix a bug that caused a crash when deallocating
     deeply nested filter objects.  Patch by Marta Gómez Macías.

   - gh-102336(4): Cleanup Windows 7 specific special handling.  Patch
     by Max Bachmann.

   - gh-102250(5): Fixed a segfault occurring when the interpreter calls
     a ‘__bool__’ method that raises.

   - gh-102126(6): Fix deadlock at shutdown when clearing thread states
     if any finalizer tries to acquire the runtime head lock.  Patch by
     Kumar Aditya.

   - gh-102027(7): Use ‘GetCurrentProcessId’ on Windows when ‘getpid’ is
     unavailable.  Patch by Max Bachmann.

   - gh-102056(8): Fix error handling bugs in interpreter's exception
     printing code, which could cause a crash on infinite recursion.

   - gh-100982(9): Restrict the scope of the ‘FOR_ITER_RANGE’
     instruction to the scope of the original *note FOR_ITER: 16bc.
     instruction, to allow instrumentation.

   - gh-101967(10): Fix possible segfault in
     ‘positional_only_passed_as_keyword’ function, when new list
     created.

   - gh-101952(11): Fix possible segfault in ‘BUILD_SET’ opcode, when
     new set created.

   - gh-74895(12): *note socket.getaddrinfo: 16bd. no longer raises
     *note OverflowError: 84e. for *note int: 238. 'port' values outside
     of the C long range.  Out of range values are left up to the
     underlying string based C library API to report.  A *note
     socket.gaierror: 16be. ‘SAI_SERVICE’ may occur instead, or no error
     at all as not all platform C libraries generate an error.

   - gh-101799(13): Add *note CALL_INTRINSIC_2: 4af. and use it instead
     of ‘PREP_RERAISE_STAR’.

   - gh-101857(14): Fix xattr support detection on Linux systems by
     widening the check to linux, not just glibc.  This fixes support
     for musl.

   - gh-84783(15): Make the slice object hashable.  Patch by Will
     Bradshaw and Furkan Onder.

   - gh-87849(16): Change the ‘SEND’ instruction to leave the receiver
     on the stack.  This allows the specialized form of ‘SEND’ to skip
     the chain of C calls and jump directly to the ‘RESUME’ in the
     generator or coroutine.

   - gh-101765(17): Fix SystemError / segmentation fault in iter
     ‘__reduce__’ when internal access of ‘builtins.__dict__’ keys
     mutates the iter object.

   - gh-101430(18): Update *note tracemalloc: e8. to handle presize of
     object properly.  Patch by Donghee Na.

   - gh-101696(19): Invalidate type version tag in
     ‘_PyStaticType_Dealloc’ for static types, avoiding bug where a
     false cache hit could crash the interpreter.  Patch by Kumar
     Aditya.

   - gh-101632(20): Adds a new *note RETURN_CONST: 4b6. instruction.

   - gh-100719(21): Remove gi_code field from generator (and coroutine
     and async generator) objects as it is redundant.  The frame already
     includes a reference to the code object.

   - gh-98627(22): When an interpreter is configured to check (and only
     then), importing an extension module will now fail when the
     extension does not support multiple interpreters (i.e.  doesn't
     implement PEP 489 multi-phase init).  This does not apply to the
     main interpreter, nor to subinterpreters created with
     ‘Py_NewInterpreter()’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102493

   (2) https://github.com/python/cpython/issues/102416

   (3) https://github.com/python/cpython/issues/102356

   (4) https://github.com/python/cpython/issues/102336

   (5) https://github.com/python/cpython/issues/102250

   (6) https://github.com/python/cpython/issues/102126

   (7) https://github.com/python/cpython/issues/102027

   (8) https://github.com/python/cpython/issues/102056

   (9) https://github.com/python/cpython/issues/100982

   (10) https://github.com/python/cpython/issues/101967

   (11) https://github.com/python/cpython/issues/101952

   (12) https://github.com/python/cpython/issues/74895

   (13) https://github.com/python/cpython/issues/101799

   (14) https://github.com/python/cpython/issues/101857

   (15) https://github.com/python/cpython/issues/84783

   (16) https://github.com/python/cpython/issues/87849

   (17) https://github.com/python/cpython/issues/101765

   (18) https://github.com/python/cpython/issues/101430

   (19) https://github.com/python/cpython/issues/101696

   (20) https://github.com/python/cpython/issues/101632

   (21) https://github.com/python/cpython/issues/100719

   (22) https://github.com/python/cpython/issues/98627


File: python.info,  Node: Library<17>,  Next: Documentation<12>,  Prev: Core and Builtins<18>,  Up: Python 3 12 0 alpha 6

1.23.18.3 Library
.................

   - gh-102302(1): Micro-optimise hashing of *note inspect.Parameter:
     1b2, reducing the time it takes to hash an instance by around 40%.

   - gh-101979(2): Fix a bug where parentheses in the ‘metavar’ argument
     to *note argparse.ArgumentParser.add_argument(): 183. were dropped.
     Patch by Yeojin Kim.

   - gh-91038(3): *note platform.platform(): 16c0. now has boolean
     default arguments.

   - gh-81652(4): Add *note mmap.MAP_ALIGNED_SUPER: 16c1. FreeBSD and
     *note mmap.MAP_CONCEAL: 16c2. OpenBSD constants to *note mmap: 83.
     Patch by Yeojin Kim.

   - gh-102179(5): Fix *note os.dup2(): b31. error message for negative
     fds.

   - gh-101961(6): For the binary mode, ‘fileinput.hookcompressed()’
     doesn't set the ‘encoding’ value even if the value is ‘None’.
     Patch by Gihwan Kim.

   - gh-101936(7): The default value of ‘fp’ becomes *note io.BytesIO:
     e6d. if *note HTTPError: fab. is initialized without a designated
     ‘fp’ parameter.  Patch by Long Vo.

   - gh-101566(8): In zipfile, sync Path with zipp 3.14(9), including
     fix for extractall on the underlying zipfile after being wrapped in
     ‘Path’.

   - gh-97930(10): Apply changes from importlib_resources 5.12(11),
     including fix for ‘MultiplexedPath’ to support directories in
     multiple namespaces (python/importlib_resources#265).

   - gh-101997(12): Upgrade pip wheel bundled with ensurepip (pip
     23.0.1)

   - gh-99108(13): The built-in extension modules for *note hashlib: 5e.
     SHA2 algorithms, used when OpenSSL does not provide them, now live
     in a single internal ‘_sha2’ module instead of separate ‘_sha256’
     and ‘_sha512’ modules.

   - gh-101892(14): Callable iterators no longer raise *note
     SystemError: 541. when the callable object exhausts the iterator
     but forgets to either return a sentinel value or raise *note
     StopIteration: bc8.

   - gh-87634(15): Remove locking behavior from *note
     functools.cached_property(): 50c.

   - gh-97786(16): Fix potential undefined behaviour in corner cases of
     floating-point-to-time conversions.

   - gh-101517(17): Fixed bug where *note bdb: b. looks up the source
     line with *note linecache: 79. with a ‘lineno=None’, which causes
     it to fail with an unhandled exception.

   - gh-101773(18): Optimize *note fractions.Fraction: 1c8. for small
     components.  The private argument ‘_normalize’ of the *note
     fractions.Fraction: 1c8. constructor has been removed.

   - gh-101693(19): In *note sqlite3.Cursor.execute(): 2b2, *note
     DeprecationWarning: 18a. is now emitted when *note named
     placeholders: 2b4. are used together with parameters supplied as a
     *note sequence: 4be. instead of as a *note dict: 237.  Starting
     from Python 3.14, using named placeholders with parameters supplied
     as a sequence will raise a *note ProgrammingError: 4bf.  Patch by
     Erlend E. Aasland.

   - gh-101446(20): Change repr of *note collections.OrderedDict: 5a5.
     to use regular dictionary formatting instead of pairs of keys and
     values.

   - gh-101362(21): Speed up *note pathlib.PurePath: 473. construction
     by handling arguments more uniformly.  When a *note pathlib.Path:
     20a. argument is supplied, we use its string representation rather
     than joining its parts with *note os.path.join(): 1597.

   - gh-101362(22): Speed up *note pathlib.PurePath: 473. construction
     by calling *note os.path.join(): 1597. only when two or more
     arguments are given.

   - gh-101362(23): Speed up *note pathlib.Path: 20a. construction by
     running the path flavour compatibility check only when pathlib is
     imported.

   - gh-85984(24): Refactored the implementation of *note pty.fork():
     16c3. to use *note os.login_tty(): 16c4.

     A *note DeprecationWarning: 18a. is now raised by
     ‘pty.master_open()’ and ‘pty.slave_open()’.  They were undocumented
     and deprecated long long ago in the docstring in favor of *note
     pty.openpty(): 2af.

   - gh-101561(25): Add a new decorator *note typing.override(): 417.
     See PEP 698(26) for details.  Patch by Steven Troxler.

   - gh-63301(27): Set exit code when *note tabnanny: c7. CLI exits on
     error.

   - gh-101360(28): Fix anchor matching in
     ‘pathlib.PureWindowsPath.match()’.  Path and pattern anchors are
     now matched with *note fnmatch: 52, just like other path parts.
     This allows patterns such as ‘"*:/Users/*"’ to be matched.

   - gh-101277(29): Remove global state from *note itertools: 75. module
     ( PEP 687(30)).  Patches by Erlend E. Aasland.

   - gh-100809(31): Fix handling of drive-relative paths (like 'C:' and
     'C:foo') in *note pathlib.Path.absolute(): 1612.  This method now
     uses the OS API to retrieve the correct current working directory
     for the drive.

   - gh-99138(32): Apply PEP 687(33) to *note zoneinfo: 11a.  Patch by
     Erlend E. Aasland.

   - gh-96764(34): *note asyncio.wait_for(): 5ca. now uses *note
     asyncio.timeout(): 5c9. as its underlying implementation.  Patch by
     Kumar Aditya.

   - gh-88233(35): Correctly preserve "extra" fields in ‘zipfile’
     regardless of their ordering relative to a zip64 "extra."

   - bpo-23224(36): Fix segfaults when creating *note
     lzma.LZMADecompressor: 16c5. and *note bz2.BZ2Decompressor: 16c6.
     objects without calling ‘__init__()’, and fix leakage of locks and
     internal buffers when calling the ‘__init__()’ methods of *note
     lzma.LZMADecompressor: 16c5, *note lzma.LZMACompressor: 16c7, *note
     bz2.BZ2Compressor: 16c8, and *note bz2.BZ2Decompressor: 16c6.
     objects multiple times.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102302

   (2) https://github.com/python/cpython/issues/101979

   (3) https://github.com/python/cpython/issues/91038

   (4) https://github.com/python/cpython/issues/81652

   (5) https://github.com/python/cpython/issues/102179

   (6) https://github.com/python/cpython/issues/101961

   (7) https://github.com/python/cpython/issues/101936

   (8) https://github.com/python/cpython/issues/101566

   (9) https://zipp.readthedocs.io/en/latest/history.html#v3-14-0

   (10) https://github.com/python/cpython/issues/97930

   (11) 
https://importlib-resources.readthedocs.io/en/latest/history.html#v5-12-0

   (12) https://github.com/python/cpython/issues/101997

   (13) https://github.com/python/cpython/issues/99108

   (14) https://github.com/python/cpython/issues/101892

   (15) https://github.com/python/cpython/issues/87634

   (16) https://github.com/python/cpython/issues/97786

   (17) https://github.com/python/cpython/issues/101517

   (18) https://github.com/python/cpython/issues/101773

   (19) https://github.com/python/cpython/issues/101693

   (20) https://github.com/python/cpython/issues/101446

   (21) https://github.com/python/cpython/issues/101362

   (22) https://github.com/python/cpython/issues/101362

   (23) https://github.com/python/cpython/issues/101362

   (24) https://github.com/python/cpython/issues/85984

   (25) https://github.com/python/cpython/issues/101561

   (26) https://peps.python.org/pep-0698/

   (27) https://github.com/python/cpython/issues/63301

   (28) https://github.com/python/cpython/issues/101360

   (29) https://github.com/python/cpython/issues/101277

   (30) https://peps.python.org/pep-0687/

   (31) https://github.com/python/cpython/issues/100809

   (32) https://github.com/python/cpython/issues/99138

   (33) https://peps.python.org/pep-0687/

   (34) https://github.com/python/cpython/issues/96764

   (35) https://github.com/python/cpython/issues/88233

   (36) https://bugs.python.org/issue?@action=redirect&bpo=23224


File: python.info,  Node: Documentation<12>,  Next: Tests<15>,  Prev: Library<17>,  Up: Python 3 12 0 alpha 6

1.23.18.4 Documentation
.......................

   - gh-85417(1): Update *note cmath: 11. documentation to clarify
     behaviour on branch cuts.

   - gh-97725(2): Fix *note asyncio.Task.print_stack(): 16ca.
     description for ‘file=None’.  Patch by Oleg Iarygin.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/85417

   (2) https://github.com/python/cpython/issues/97725


File: python.info,  Node: Tests<15>,  Next: Build<17>,  Prev: Documentation<12>,  Up: Python 3 12 0 alpha 6

1.23.18.5 Tests
...............

   - gh-102019(1): Fix deadlock on shutdown if
     ‘test_current_{exception,frames}’ fails.  Patch by Jacob Bower.

   - gh-85984(2): Utilize new "winsize" functions from termios in pty
     tests.

   - gh-89792(3): ‘test_tools’ now copies up to 10x less source data to
     a temporary directory during the ‘freeze’ test by ignoring git
     metadata and other artifacts.  It also limits its python build
     parallelism based on os.cpu_count instead of hard coding it as 8
     cores.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102019

   (2) https://github.com/python/cpython/issues/85984

   (3) https://github.com/python/cpython/issues/89792


File: python.info,  Node: Build<17>,  Next: Windows<14>,  Prev: Tests<15>,  Up: Python 3 12 0 alpha 6

1.23.18.6 Build
...............

   - gh-99942(1): On Android, in a static build, python-config in embed
     mode no longer incorrectly reports a library to link to.

   - gh-99942(2): On Android, python.pc now correctly reports the
     library to link to, the same as python-config.sh.

   - gh-100221(3): Fix creating install directories in ‘make
     sharedinstall’ if they exist outside ‘DESTDIR’ already.

   - gh-96821(4): Explicitly mark C extension modules that need defined
     signed integer overflow, and add a configure option *note
     -with-strict-overflow: 16cd.  Patch by Matthias Görgens and
     Shantanu Jain.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99942

   (2) https://github.com/python/cpython/issues/99942

   (3) https://github.com/python/cpython/issues/100221

   (4) https://github.com/python/cpython/issues/96821


File: python.info,  Node: Windows<14>,  Next: macOS<11>,  Prev: Build<17>,  Up: Python 3 12 0 alpha 6

1.23.18.7 Windows
.................

   - gh-102344(1): Implement ‘winreg.QueryValue’ using ‘QueryValueEx’
     and ‘winreg.SetValue’ using ‘SetValueEx’.  Patch by Max Bachmann.

   - gh-101881(2): Handle read and write operations on non-blocking
     pipes properly on Windows.

   - gh-101881(3): Add support for the os.get_blocking() and
     os.set_blocking() functions on Windows.

   - gh-101849(4): Ensures installer will correctly upgrade existing
     ‘py.exe’ launcher installs.

   - gh-101763(5): Updates copy of libffi bundled with Windows installs
     to 3.4.4.

   - gh-101759(6): Update Windows installer to SQLite 3.40.1.

   - gh-101614(7): Correctly handle extensions built against debug
     binaries that reference ‘python3_d.dll’.

   - gh-101196(8): The functions ‘os.path.isdir’, ‘os.path.isfile’,
     ‘os.path.islink’ and ‘os.path.exists’ are now 13% to 28% faster on
     Windows, by making fewer Win32 API calls.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/102344

   (2) https://github.com/python/cpython/issues/101881

   (3) https://github.com/python/cpython/issues/101881

   (4) https://github.com/python/cpython/issues/101849

   (5) https://github.com/python/cpython/issues/101763

   (6) https://github.com/python/cpython/issues/101759

   (7) https://github.com/python/cpython/issues/101614

   (8) https://github.com/python/cpython/issues/101196


File: python.info,  Node: macOS<11>,  Next: C API<17>,  Prev: Windows<14>,  Up: Python 3 12 0 alpha 6

1.23.18.8 macOS
...............

   - gh-101759(1): Update macOS installer to SQLite 3.40.1.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101759


File: python.info,  Node: C API<17>,  Prev: macOS<11>,  Up: Python 3 12 0 alpha 6

1.23.18.9 C API
...............

   - gh-101907(1): Removes use of non-standard C++ extension in public
     header files.

   - gh-99293(2): Document that the Py_TPFLAGS_VALID_VERSION_TAG is an
     internal feature, should not be used, and will be removed.

   - gh-101578(3): Add *note PyErr_GetRaisedException(): 3cd. and *note
     PyErr_SetRaisedException(): 3d0. for saving and restoring the
     current exception.  These functions return and accept a single
     exception object, rather than the triple arguments of the
     now-deprecated *note PyErr_Fetch(): 3cc. and *note PyErr_Restore():
     3cf.  This is less error prone and a bit more efficient.

     Add *note PyException_GetArgs(): 536. and *note
     PyException_SetArgs(): 537. as convenience functions for retrieving
     and modifying the *note args: 538. passed to the exception's
     constructor.

   - gh-91744(4): Introduced the 'Unstable C API tier', marking APi that
     is allowed to change in minor releases without a deprecation
     period.  See PEP 689(5) for details.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101907

   (2) https://github.com/python/cpython/issues/99293

   (3) https://github.com/python/cpython/issues/101578

   (4) https://github.com/python/cpython/issues/91744

   (5) https://peps.python.org/pep-0689/


File: python.info,  Node: Python 3 12 0 alpha 5,  Next: Python 3 12 0 alpha 4,  Prev: Python 3 12 0 alpha 6,  Up: 変更履歴

1.23.19 Python 3.12.0 alpha 5
-----------------------------

'Release date: 2023-02-07'

* Menu:

* Security: Security<12>.
* Core and Builtins: Core and Builtins<19>.
* Library: Library<18>.
* Documentation: Documentation<13>.
* Tests: Tests<16>.
* Build: Build<18>.
* Windows: Windows<15>.


File: python.info,  Node: Security<12>,  Next: Core and Builtins<19>,  Up: Python 3 12 0 alpha 5

1.23.19.1 Security
..................

   - gh-99108(1): Replace the builtin *note hashlib: 5e. implementations
     of SHA2-224 and SHA2-256 originally from LibTomCrypt with formally
     verified, side-channel resistant code from the HACL*(2) project.
     The builtins remain a fallback only used when OpenSSL does not
     provide them.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99108

   (2) https://github.com/hacl-star/hacl-star/


File: python.info,  Node: Core and Builtins<19>,  Next: Library<18>,  Prev: Security<12>,  Up: Python 3 12 0 alpha 5

1.23.19.2 Core and Builtins
...........................

   - gh-92173(1): Fix the ‘defs’ and ‘kwdefs’ arguments to *note
     PyEval_EvalCodeEx(): 16d4. and a reference leak in that function.

   - gh-59956(2): The GILState API is now partially compatible with
     subinterpreters.  Previously, ‘PyThreadState_GET()’ and
     ‘PyGILState_GetThisThreadState()’ would get out of sync, causing
     inconsistent behavior and crashes.

   - gh-101400(3): Fix wrong lineno in exception message on *note
     continue: 998. or *note break: a77. which are not in a loop.  Patch
     by Donghee Na.

   - gh-101372(4): Fix *note is_normalized(): a17. to properly handle
     the UCD 3.2.0 cases.  Patch by Donghee Na.

   - gh-101266(5): Fix *note sys.getsizeof(): 16d5. reporting for *note
     int: 238. subclasses.

   - gh-101291(6): Refactor the ‘PyLongObject’ struct into a normal
     Python object header and a ‘PyLongValue’ struct.

   - gh-101046(7): Fix a possible memory leak in the parser when raising
     *note MemoryError: 1627.  Patch by Pablo Galindo

   - gh-101037(8): Fix potential memory underallocation issue for
     instances of *note int: 238. subclasses with value zero.

   - gh-100762(9): Record the (virtual) exception block depth in the
     oparg of *note YIELD_VALUE: 2ec.  Use this to avoid the expensive
     ‘throw()’ when closing generators (and coroutines) that can be
     closed trivially.

   - gh-100982(10): Adds a new ‘COMPARE_AND_BRANCH’ instruction.  This
     is a bit more efficient when performing a comparison immediately
     followed by a branch, and restores the design intent of PEP 659
     that specializations are local to a single instruction.

   - gh-100942(11): Fixed segfault in property.getter/setter/deleter
     that occurred when a property subclass overrode the ‘__new__’
     method to return a non-property instance.

   - gh-100923(12): Remove the ‘mask’ cache entry for the *note
     COMPARE_OP: 937. instruction and embed the mask into the oparg.

   - gh-100892(13): Fix race while iterating over thread states in
     clearing *note threading.local: 16d6.  Patch by Kumar Aditya.

   - gh-91351(14): Fix a case where re-entrant imports could corrupt the
     import deadlock detection code and cause a *note KeyError: 31d. to
     be raised out of ‘importlib/_bootstrap’.  In addition to the
     straightforward cases, this could also happen when garbage
     collection leads to a warning being emitted - as happens when it
     collects an open socket or file)

   - gh-100726(15): Optimize construction of ‘range’ object for medium
     size integers.

   - gh-100712(16): Added option to build cpython with specialization
     disabled, by setting ‘ENABLE_SPECIALIZATION=False’ in ‘opcode’,
     followed by ‘make regen-all’.

   - bpo-32780(17): Inter-field padding is now inserted into the PEP3118
     format strings obtained from *note ctypes.Structure: 1b6. objects,
     reflecting their true representation in memory.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92173

   (2) https://github.com/python/cpython/issues/59956

   (3) https://github.com/python/cpython/issues/101400

   (4) https://github.com/python/cpython/issues/101372

   (5) https://github.com/python/cpython/issues/101266

   (6) https://github.com/python/cpython/issues/101291

   (7) https://github.com/python/cpython/issues/101046

   (8) https://github.com/python/cpython/issues/101037

   (9) https://github.com/python/cpython/issues/100762

   (10) https://github.com/python/cpython/issues/100982

   (11) https://github.com/python/cpython/issues/100942

   (12) https://github.com/python/cpython/issues/100923

   (13) https://github.com/python/cpython/issues/100892

   (14) https://github.com/python/cpython/issues/91351

   (15) https://github.com/python/cpython/issues/100726

   (16) https://github.com/python/cpython/issues/100712

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32780


File: python.info,  Node: Library<18>,  Next: Documentation<13>,  Prev: Core and Builtins<19>,  Up: Python 3 12 0 alpha 5

1.23.19.3 Library
.................

   - gh-101541(1): [Enum] - fix psuedo-flag creation

   - gh-101570(2): Upgrade pip wheel bundled with ensurepip (pip 23.0)

   - gh-101323(3): Fix a bug where errors where not thrown by
     zlib._ZlibDecompressor if encountered during decompressing.

   - gh-101317(4): Add 'ssl_shutdown_timeout' parameter for *note
     asyncio.StreamWriter.start_tls(): 5cf.

   - gh-101326(5): Fix regression when passing ‘None’ as second or third
     argument to ‘FutureIter.throw’.

   - gh-92123(6): Adapt the ‘_elementtree’ extension module to
     multi-phase init ( PEP 489(7)).  Patches by Erlend E. Aasland.

   - gh-100795(8): Avoid potential unexpected ‘freeaddrinfo’ call
     (double free) in *note socket: b8. when when a libc ‘getaddrinfo()’
     implementation leaves garbage in an output pointer when returning
     an error.  Original patch by Sergey G. Brester.

   - gh-101143(9): Remove unused references to *note TimerHandle: 16d8.
     in ‘asyncio.base_events.BaseEventLoop._add_callback’.

   - gh-101144(10): Make *note zipfile.Path.open(): 1501. and *note
     zipfile.Path.read_text(): 16d9. also accept ‘encoding’ as a
     positional argument.  This was the behavior in Python 3.9 and
     earlier.  3.10 introduced a regression where supplying it as a
     positional argument would lead to a *note TypeError: 502.

   - gh-94518(11): Group-related variables of ‘_posixsubprocess’ module
     are renamed to stress that supplementary group affinity is added to
     a fork, not replace the inherited ones.  Patch by Oleg Iarygin.

   - gh-101015(12): Fix *note typing.get_type_hints(): 67d. on
     ‘'*tuple[...]'’ and ‘*tuple[...]’.  It must not drop the ‘Unpack’
     part.

   - gh-101000(13): Add *note os.path.splitroot(): 471, which splits a
     path into a 3-item tuple ‘(drive, root, tail)’.  This new function
     is used by *note pathlib: 93. to improve the performance of path
     construction by up to a third.

   - gh-100573(14): Fix a Windows *note asyncio: 8. bug with named pipes
     where a client doing ‘os.stat()’ on the pipe would cause an error
     in the server that disabled serving future requests.

   - gh-39615(15): *note warnings.warn(): 14c3. now has the ability to
     skip stack frames based on code filename prefix rather than only a
     numeric ‘stacklevel’ via the new ‘skip_file_prefixes’ keyword
     argument.

   - gh-100750(16): pass encoding kwarg to subprocess in platform

   - gh-100160(17): Emit a deprecation warning in
     ‘asyncio.DefaultEventLoopPolicy.get_event_loop()’ if there is no
     current event loop set and it decides to create one.

   - gh-96290(18): Fix handling of partial and invalid UNC drives in
     ‘ntpath.splitdrive()’, and in ‘ntpath.normpath()’ on non-Windows
     systems.  Paths such as '\server' and '\' are now considered by
     ‘splitdrive()’ to contain only a drive, and consequently are not
     modified by ‘normpath()’ on non-Windows systems.  The behaviour of
     ‘normpath()’ on Windows systems is unaffected, as native OS APIs
     are used.  Patch by Eryk Sun, with contributions by Barney Gale.

   - gh-99952(19): Fix a reference undercounting issue in *note
     ctypes.Structure: 1b6. with ‘from_param()’ results larger than a C
     pointer.

   - gh-67790(20): Add float-style formatting support for *note
     fractions.Fraction: 1c8. instances.

   - gh-99266(21): Preserve more detailed error messages in *note
     ctypes: 22.

   - gh-86682(22): Ensure runtime-created collections have the correct
     module name using the newly added (internal) *note
     sys._getframemodulename(): 16da.

   - gh-88597(23): *note uuid: f8. now has a command line interface.
     Try ‘python -m uuid -h’.

   - gh-60580(24): ‘ctypes.wintypes.BYTE’ definition changed from *note
     c_byte: 16db. to *note c_ubyte: 16dc. to match Windows SDK. Patch
     by Anatoly Techtonik and Oleg Iarygin.

   - gh-94518(25): ‘_posixsubprocess’ now initializes all UID and GID
     variables using a reserved ‘-1’ value instead of a separate flag.
     Patch by Oleg Iarygin.

   - bpo-38941(26): The *note xml.etree.ElementTree: 10c. module now
     emits *note DeprecationWarning: 18a. when testing the truth value
     of an *note xml.etree.ElementTree.Element: 2e8.  Before, the Python
     implementation emitted *note FutureWarning: 3ee, and the C
     implementation emitted nothing.

   - bpo-40077(27): Convert ‘elementtree’ types to heap types.  Patch by
     Erlend E. Aasland.

   - bpo-29847(28): Fix a bug where *note pathlib.Path: 20a. accepted
     and ignored keyword arguments.  Patch provided by Yurii Karabas.

   - gh-77772(29): *note ctypes.CDLL: 9b7, *note ctypes.OleDLL: 16dd,
     *note ctypes.WinDLL: 16de, and *note ctypes.PyDLL: 16df. now accept
     *note path-like objects: 280. as their ‘name’ argument.  Patch by
     Robert Hoelzl.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101541

   (2) https://github.com/python/cpython/issues/101570

   (3) https://github.com/python/cpython/issues/101323

   (4) https://github.com/python/cpython/issues/101317

   (5) https://github.com/python/cpython/issues/101326

   (6) https://github.com/python/cpython/issues/92123

   (7) https://peps.python.org/pep-0489/

   (8) https://github.com/python/cpython/issues/100795

   (9) https://github.com/python/cpython/issues/101143

   (10) https://github.com/python/cpython/issues/101144

   (11) https://github.com/python/cpython/issues/94518

   (12) https://github.com/python/cpython/issues/101015

   (13) https://github.com/python/cpython/issues/101000

   (14) https://github.com/python/cpython/issues/100573

   (15) https://github.com/python/cpython/issues/39615

   (16) https://github.com/python/cpython/issues/100750

   (17) https://github.com/python/cpython/issues/100160

   (18) https://github.com/python/cpython/issues/96290

   (19) https://github.com/python/cpython/issues/99952

   (20) https://github.com/python/cpython/issues/67790

   (21) https://github.com/python/cpython/issues/99266

   (22) https://github.com/python/cpython/issues/86682

   (23) https://github.com/python/cpython/issues/88597

   (24) https://github.com/python/cpython/issues/60580

   (25) https://github.com/python/cpython/issues/94518

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38941

   (27) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (28) https://bugs.python.org/issue?@action=redirect&bpo=29847

   (29) https://github.com/python/cpython/issues/77772


File: python.info,  Node: Documentation<13>,  Next: Tests<16>,  Prev: Library<18>,  Up: Python 3 12 0 alpha 5

1.23.19.4 Documentation
.......................

   - gh-88324(1): Reword *note subprocess: c1. to emphasize default
     behavior of 'stdin', 'stdout', and 'stderr' arguments.  Remove
     inaccurate statement about child file handle inheritance.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/88324


File: python.info,  Node: Tests<16>,  Next: Build<18>,  Prev: Documentation<13>,  Up: Python 3 12 0 alpha 5

1.23.19.5 Tests
...............

   - gh-101334(1): ‘test_tarfile’ has been updated to pass when run as a
     high UID.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101334


File: python.info,  Node: Build<18>,  Next: Windows<15>,  Prev: Tests<16>,  Up: Python 3 12 0 alpha 5

1.23.19.6 Build
...............

   - gh-101282(1): Update BOLT configuration not to use deprecated usage
     of ‘--split functions’.  Patch by Donghee Na.

   - gh-101522(2): Allow overriding Windows dependencies versions and
     paths using MSBuild properties.

   - gh-77532(3): Minor fixes to allow building with
     ‘PlatformToolset=ClangCL’ on Windows.

   - gh-101152(4): In accordance with PEP 699(5), the ‘ma_version_tag’
     field in *note PyDictObject: 39b. is deprecated for extension
     modules.  Accessing this field will generate a compiler warning at
     compile time.  This field will be removed in Python 3.14.

   - gh-100340(6): Allows -Wno-int-conversion for wasm-sdk 17 and
     onwards, thus enables building WASI builds once against the latest
     sdk.

   - gh-101060(7): Conditionally add ‘-fno-reorder-blocks-and-partition’
     in configure.  Effectively fixes ‘--enable-bolt’ when using Clang,
     as this appears to be a GCC-only flag.

   - gh-98705(8): ‘__bool__’ is defined in AIX system header files which
     breaks the build in AIX, so undefine it.

   - gh-98636(9): Fix a regression in detecting ‘gdbm_compat’ library
     for the ‘_gdbm’ module build.

   - gh-96305(10): ‘_aix_support’ now uses a simple code to get platform
     details rather than the now non-existent ‘_bootsubprocess’ during
     bootstrap.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101282

   (2) https://github.com/python/cpython/issues/101522

   (3) https://github.com/python/cpython/issues/77532

   (4) https://github.com/python/cpython/issues/101152

   (5) https://peps.python.org/pep-0699/

   (6) https://github.com/python/cpython/issues/100340

   (7) https://github.com/python/cpython/issues/101060

   (8) https://github.com/python/cpython/issues/98705

   (9) https://github.com/python/cpython/issues/98636

   (10) https://github.com/python/cpython/issues/96305


File: python.info,  Node: Windows<15>,  Prev: Build<18>,  Up: Python 3 12 0 alpha 5

1.23.19.7 Windows
.................

   - gh-101543(1): Ensure the install path in the registry is only used
     when the standard library hasn't been located in any other way.

   - gh-101467(2): The ‘py.exe’ launcher now correctly filters when only
     a single runtime is installed.  It also correctly handles prefix
     matches on tags so that ‘-3.1’ does not match ‘3.11’, but would
     still match ‘3.1-32’.

   - gh-99834(3): Updates bundled copy of Tcl/Tk to 8.6.13.0

   - gh-101135(4): Restore ability to launch older 32-bit versions from
     the ‘py.exe’ launcher when both 32-bit and 64-bit installs of the
     same version are available.

   - gh-82052(5): Fixed an issue where writing more than 32K of Unicode
     output to the console screen in one go can result in mojibake.

   - gh-100320(6): Ensures the ‘PythonPath’ registry key from an install
     is used when launching from a different copy of Python that relies
     on an existing install to provide a copy of its modules and
     standard library.

   - gh-100247(7): Restores support for the ‘py.exe’ launcher finding
     shebang commands in its configuration file using the full command
     name.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/101543

   (2) https://github.com/python/cpython/issues/101467

   (3) https://github.com/python/cpython/issues/99834

   (4) https://github.com/python/cpython/issues/101135

   (5) https://github.com/python/cpython/issues/82052

   (6) https://github.com/python/cpython/issues/100320

   (7) https://github.com/python/cpython/issues/100247


File: python.info,  Node: Python 3 12 0 alpha 4,  Next: Python 3 12 0 alpha 3,  Prev: Python 3 12 0 alpha 5,  Up: 変更履歴

1.23.20 Python 3.12.0 alpha 4
-----------------------------

'Release date: 2023-01-10'

* Menu:

* Core and Builtins: Core and Builtins<20>.
* Library: Library<19>.
* Documentation: Documentation<14>.
* Tests: Tests<17>.
* Build: Build<19>.
* Windows: Windows<16>.
* macOS: macOS<12>.
* Tools/Demos: Tools/Demos<9>.
* C API: C API<18>.


File: python.info,  Node: Core and Builtins<20>,  Next: Library<19>,  Up: Python 3 12 0 alpha 4

1.23.20.1 Core and Builtins
...........................

   - gh-100776(1): Fix misleading default value in *note input():
     12a6.'s ‘__text_signature__’.

   - gh-99005(2): Remove ‘UNARY_POSITIVE’, ‘ASYNC_GEN_WRAP’ and
     ‘LIST_TO_TUPLE’, replacing them with intrinsics.

   - gh-99005(3): Add new *note CALL_INTRINSIC_1: 4ae. instruction.
     Remove ‘IMPORT_STAR’, ‘PRINT_EXPR’ and ‘STOPITERATION_ERROR’,
     replacing them with the *note CALL_INTRINSIC_1: 4ae. instruction.

   - gh-100288(4): Remove the LOAD_ATTR_METHOD_WITH_DICT specialized
     instruction.  Stats show it is not useful.

   - gh-100720(5): Added ‘_PyFrame_NumSlotsForCodeObject’, which returns
     the number of slots needed in a frame for a given code object.

   - gh-100719(6): Removed the co_nplaincellvars field from the code
     object, as it is redundant.

   - gh-100637(7): Fix ‘int.__sizeof__()’ calculation to include the
     1-element ‘ob_digit’ array for ‘0’ and ‘False’.

   - gh-100649(8): Update the native_thread_id field of PyThreadState
     after fork.

   - gh-100126(9): Fix an issue where "incomplete" frames could be
     briefly visible to C code while other frames are being torn down,
     possibly resulting in corruption or hard crashes of the interpreter
     while running finalizers.

   - gh-87447(10): Fix *note SyntaxError: 172. on comprehension rebind
     checking with names that are not actually redefined.

     Now reassigning ‘b’ in ‘[(b := 1) for a, b.prop in some_iter]’ is
     allowed.  Reassigning ‘a’ is still disallowed as per PEP 572(11).

   - gh-100268(12): Add *note int.is_integer(): 16e6. to improve duck
     type compatibility between *note int: 238. and *note float: 2ce.

   - gh-100425(13): Improve the accuracy of ‘sum()’ with compensated
     summation.

   - gh-100374(14): Fix incorrect result and delay in *note
     socket.getfqdn(): 16e7.  Patch by Dominic Socular.

   - gh-100357(15): Convert ‘vars’, ‘dir’, ‘next’, ‘getattr’, and ‘iter’
     to argument clinic.

   - gh-100117(16): Improve the output of *note codeobject.co_lines():
     2d2. by emitting only one entry for each line range.

   - gh-90043(17): Handle NaNs when specializing *note COMPARE_OP: 937.
     for *note float: 2ce. values.

   - gh-100222(18): Redefine the ‘_Py_CODEUNIT’ typedef as a union to
     describe its layout to the C compiler, avoiding type punning and
     improving clarity.

   - gh-99955(19): Internal compiler functions (in compile.c) now
     consistently return -1 on error and 0 on success.

   - gh-100188(20): The ‘BINARY_SUBSCR_LIST_INT’ and
     ‘BINARY_SUBSCR_TUPLE_INT’ instructions are no longer used for
     negative integers because those instructions always miss when
     encountering negative integers.

   - gh-99110(21): Initialize frame->previous in frameobject.c to fix a
     segmentation fault when accessing frames created by
     ‘PyFrame_New()’.

   - gh-94155(22): Improved the hashing algorithm for code objects,
     mitigating some hash collisions.

   - gh-99540(23): ‘None’ now hashes to a constant value.  This is not a
     requirements change.

   - gh-100143(24): When built with ‘--enable-pystats’, stats collection
     is now off by default.  To enable it early at startup, pass the
     ‘-Xpystats’ flag.  Stats are now always dumped, even if switched
     off.

   - gh-100146(25): Improve ‘BUILD_LIST’ opcode so that it works
     similarly to the ‘BUILD_TUPLE’ opcode, by stealing references from
     the stack rather than repeatedly using stack operations to set list
     elements.  Implementation details are in a new private API
     ‘_PyList_FromArraySteal()’.

   - gh-100110(26): Specialize ‘FOR_ITER’ for tuples.

   - gh-100050(27): Honor existing errors obtained when searching for
     mismatching parentheses in the tokenizer.  Patch by Pablo Galindo

   - gh-92216(28): Improve the performance of *note hasattr(): 49e. for
     type objects with a missing attribute.

   - gh-99582(29): Freeze *note zipimport: 118. module into
     ‘_bootstrap_python’.

   - gh-99554(30): Pack debugging location tables more efficiently
     during bytecode compilation.

   - gh-98522(31): Add an internal version number to code objects, to
     give better versioning of inner functions and comprehensions, and
     thus better specialization of those functions.  This change is
     invisible to both Python and C extensions.

   - gh-94603(32): Improve performance of ‘list.pop’ for small lists.

   - gh-89051(33): Add *note ssl.OP_LEGACY_SERVER_CONNECT: 16e8.

   - bpo-32782(34): ‘ctypes’ arrays of length 0 now report a correct
     itemsize when a ‘memoryview’ is constructed from them, rather than
     always giving a value of 0.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100776

   (2) https://github.com/python/cpython/issues/99005

   (3) https://github.com/python/cpython/issues/99005

   (4) https://github.com/python/cpython/issues/100288

   (5) https://github.com/python/cpython/issues/100720

   (6) https://github.com/python/cpython/issues/100719

   (7) https://github.com/python/cpython/issues/100637

   (8) https://github.com/python/cpython/issues/100649

   (9) https://github.com/python/cpython/issues/100126

   (10) https://github.com/python/cpython/issues/87447

   (11) https://peps.python.org/pep-0572/

   (12) https://github.com/python/cpython/issues/100268

   (13) https://github.com/python/cpython/issues/100425

   (14) https://github.com/python/cpython/issues/100374

   (15) https://github.com/python/cpython/issues/100357

   (16) https://github.com/python/cpython/issues/100117

   (17) https://github.com/python/cpython/issues/90043

   (18) https://github.com/python/cpython/issues/100222

   (19) https://github.com/python/cpython/issues/99955

   (20) https://github.com/python/cpython/issues/100188

   (21) https://github.com/python/cpython/issues/99110

   (22) https://github.com/python/cpython/issues/94155

   (23) https://github.com/python/cpython/issues/99540

   (24) https://github.com/python/cpython/issues/100143

   (25) https://github.com/python/cpython/issues/100146

   (26) https://github.com/python/cpython/issues/100110

   (27) https://github.com/python/cpython/issues/100050

   (28) https://github.com/python/cpython/issues/92216

   (29) https://github.com/python/cpython/issues/99582

   (30) https://github.com/python/cpython/issues/99554

   (31) https://github.com/python/cpython/issues/98522

   (32) https://github.com/python/cpython/issues/94603

   (33) https://github.com/python/cpython/issues/89051

   (34) https://bugs.python.org/issue?@action=redirect&bpo=32782


File: python.info,  Node: Library<19>,  Next: Documentation<14>,  Prev: Core and Builtins<20>,  Up: Python 3 12 0 alpha 4

1.23.20.2 Library
.................

   - gh-100833(1): Speed up *note math.fsum(): 137c. by removing
     defensive ‘volatile’ qualifiers.

   - gh-100805(2): Modify *note random.choice(): 1201. implementation to
     once again work with NumPy arrays.

   - gh-100813(3): Add ‘socket.IP_PKTINFO’ constant.

   - gh-100792(4): Make *note email.message.Message.__contains__():
     16ea. twice as fast.

   - gh-91851(5): Microoptimizations for *note
     fractions.Fraction.__round__(): 16eb, *note
     fractions.Fraction.__ceil__(): 16ec. and *note
     fractions.Fraction.__floor__(): 16ed.

   - gh-90104(6): Avoid RecursionError on ‘repr’ if a dataclass field
     definition has a cyclic reference.

   - gh-100689(7): Fix crash in ‘pyexpat’ by statically allocating
     ‘PyExpat_CAPI’ capsule.

   - gh-100740(8): Fix ‘unittest.mock.Mock’ not respecting the spec for
     attribute names prefixed with ‘assert’.

   - gh-91219(9): Change ‘SimpleHTTPRequestHandler’ to support
     subclassing to provide a different set of index file names instead
     of using ‘__init__’ parameters.

   - gh-100690(10): ‘Mock’ objects which are not unsafe will now raise
     an ‘AttributeError’ when accessing an attribute that matches the
     name of an assertion but without the prefix ‘assert_’, e.g.
     accessing ‘called_once’ instead of ‘assert_called_once’.  This is
     in addition to this already happening for accessing attributes with
     prefixes ‘assert’, ‘assret’, ‘asert’, ‘aseert’, and ‘assrt’.

   - gh-89727(11): Simplify and optimize *note os.walk(): 476. by using
     *note isinstance(): 40e. checks to check the top of the stack.

   - gh-100485(12): Add math.sumprod() to compute the sum of products.

   - gh-86508(13): Fix *note asyncio.open_connection(): ae6. to skip
     binding to local addresses of different family.  Patch by Kumar
     Aditya.

   - gh-97930(14): ‘importlib.resources.files’ now accepts a module as
     an anchor instead of only accepting packages.  If a module is
     passed, resources are resolved adjacent to that module (in the same
     package or at the package root).  The parameter was renamed from
     ‘package’ to ‘anchor’ with a compatibility shim for those passing
     by keyword.  Additionally, the new ‘anchor’ parameter is now
     optional and will default to the caller's module.

   - gh-100585(15): Fixed a bug where importlib.resources.as_file was
     leaving file pointers open

   - gh-100562(16): Improve performance of *note
     pathlib.Path.absolute(): 1612. by nearly 2x.  This comes at the
     cost of a performance regression in *note pathlib.Path.cwd(): 1691,
     which is generally used less frequently in user code.

   - gh-100519(17): Small simplification of
     ‘http.cookiejar.eff_request_host()’ that improves readability and
     better matches the RFC wording.

   - gh-100287(18): Fix the interaction of *note unittest.mock.seal():
     b6f. with *note unittest.mock.AsyncMock: a19.

   - gh-100488(19): Add ‘Fraction.is_integer()’ to check whether a *note
     fractions.Fraction: 1c8. is an integer.  This improves duck type
     compatibility with *note float: 2ce. and *note int: 238.

   - gh-100474(20): *note http.server: 68. now checks that an index page
     is actually a regular file before trying to serve it.  This avoids
     issues with directories named ‘index.html’.

   - gh-100363(21): Speed up *note asyncio.get_running_loop(): ad9. by
     removing redundant ‘getpid’ checks.  Patch by Kumar Aditya.

   - gh-78878(22): Fix crash when creating an instance of
     ‘_ctypes.CField’.

   - gh-100348(23): Fix ref cycle in ‘asyncio._SelectorSocketTransport’
     by removing ‘_read_ready_cb’ in ‘close’.

   - gh-100344(24): Provide C implementation for *note
     asyncio.current_task(): 44a. for a 4x-6x speedup.

   - gh-100272(25): Fix JSON serialization of OrderedDict.  It now
     preserves the order of keys.

   - gh-83076(26): Instantiation of ‘Mock()’ and ‘AsyncMock()’ is now
     3.8x faster.

   - gh-100234(27): Set a default value of 1.0 for the ‘lambd’ parameter
     in random.expovariate().

   - gh-100228(28): A *note DeprecationWarning: 18a. may be raised when
     *note os.fork(): 17c. or *note os.forkpty(): 17d. is called from
     multi-threaded processes.  Forking with threads is unsafe and can
     cause deadlocks, crashes and subtle problems.  Lack of a warning
     does not indicate that the fork call was actually safe, as Python
     may not be aware of all threads.

   - gh-100039(29): Improve signatures for enums and flags.

   - gh-100133(30): Fix regression in *note asyncio: 8. where a
     subprocess would sometimes lose data received from pipe.

   - bpo-44592(31): Fixes inconsistent handling of case sensitivity of
     'extrasaction' arg in *note csv.DictWriter: 11cf.

   - gh-100098(32): Fix ‘tuple’ subclasses being cast to ‘tuple’ when
     used as enum values.

   - gh-85432(33): Rename the 'fmt' parameter of the pure-Python
     implementation of *note datetime.time.strftime(): 16ee. to
     'format'.  Rename the 't' parameter of *note
     datetime.datetime.fromtimestamp(): 4ba. to 'timestamp'.  These
     changes mean the parameter names in the pure-Python implementation
     now match the parameter names in the C implementation.  Patch by
     Alex Waygood.

   - gh-98778(34): Update *note HTTPError: fab. to be initialized
     properly, even if the ‘fp’ is ‘None’.  Patch by Donghee Na.

   - gh-99925(35): Unify error messages in JSON serialization between
     ‘json.dumps(float('nan'), allow_nan=False)’ and
     ‘json.dumps(float('nan'), allow_nan=False, indent=<SOMETHING>)’.
     Now both include the representation of the value that could not be
     serialized.

   - gh-89727(36): Fix issue with *note os.walk(): 476. where a *note
     RecursionError: d39. would occur on deep directory structures by
     adjusting the implementation of *note os.walk(): 476. to be
     iterative instead of recursive.

   - gh-94943(37): Add *note データクラスのサポート: 16ef. to the *note
     Enum: 5fc. *note __repr__(): 16f0.  When inheriting from a *note
     dataclass: 1ad, only show the field names in the value section of
     the member *note repr(): 7c8, and not the dataclass' class name.

   - gh-83035(38): Fix *note inspect.getsource(): 1528. handling of
     decorator calls with nested parentheses.

   - gh-99576(39): Fix ‘.save()’ method for ‘LWPCookieJar’ and
     ‘MozillaCookieJar’: saved file was not truncated on repeated save.

   - gh-94912(40): Add *note inspect.markcoroutinefunction(): 45d.
     decorator which manually marks a function as a coroutine for the
     benefit of ‘iscoroutinefunction()’.

   - gh-99509(41): Add PEP 585(42) support for
     ‘multiprocessing.queues.Queue’.

   - gh-99482(43): Remove ‘Jython’ partial compatibility code from
     several stdlib modules.

   - gh-99433(44): Fix *note doctest: 31. failure on *note
     types.MethodWrapperType: 617. in modules.

   - gh-85267(45): Several improvements to *note inspect.signature():
     703.'s handling of ‘__text_signature’.  - Fixes a case where *note
     inspect.signature(): 703. dropped parameters - Fixes a case where
     *note inspect.signature(): 703. raised *note tokenize.TokenError:
     50d. - Allows *note inspect.signature(): 703. to understand
     defaults involving binary operations of constants - *note
     inspect.signature(): 703. is documented as only raising *note
     TypeError: 502. or *note ValueError: 1e3, but sometimes raised
     *note RuntimeError: 17a.  These cases now raise *note ValueError:
     1e3. - Removed a dead code path

   - gh-91166(46): *note asyncio: 8. is optimized to avoid excessive
     copying when writing to socket and use *note sendmsg(): 443. if the
     platform supports it.  Patch by Kumar Aditya.

   - gh-98030(47): Add missing TCP socket options from Linux:
     ‘TCP_MD5SIG’, ‘TCP_THIN_LINEAR_TIMEOUTS’, ‘TCP_THIN_DUPACK’,
     ‘TCP_REPAIR’, ‘TCP_REPAIR_QUEUE’, ‘TCP_QUEUE_SEQ’,
     ‘TCP_REPAIR_OPTIONS’, ‘TCP_TIMESTAMP’, ‘TCP_CC_INFO’,
     ‘TCP_SAVE_SYN’, ‘TCP_SAVED_SYN’, ‘TCP_REPAIR_WINDOW’,
     ‘TCP_FASTOPEN_CONNECT’, ‘TCP_ULP’, ‘TCP_MD5SIG_EXT’,
     ‘TCP_FASTOPEN_KEY’, ‘TCP_FASTOPEN_NO_COOKIE’,
     ‘TCP_ZEROCOPY_RECEIVE’, ‘TCP_INQ’, ‘TCP_TX_DELAY’.

   - gh-88500(48): Reduced the memory usage of *note
     urllib.parse.unquote(): 16f1. and *note
     urllib.parse.unquote_to_bytes(): 16f2. on large values.

   - gh-96127(49): ‘inspect.signature’ was raising ‘TypeError’ on call
     with mock objects.  Now it correctly returns ‘(*args, **kwargs)’ as
     inferred signature.

   - gh-95882(50): Fix a 3.11 regression in *note asynccontextmanager():
     af8, which caused it to propagate exceptions with incorrect
     tracebacks and fix a 3.11 regression in *note contextmanager():
     11d3, which caused it to propagate exceptions with incorrect
     tracebacks for *note StopIteration: bc8.

   - gh-78707(51): Deprecate passing more than one positional argument
     to *note pathlib.PurePath.relative_to(): 2ab. and *note
     is_relative_to(): 2aa.

   - gh-92122(52): Fix reStructuredText syntax errors in docstrings in
     the *note enum: 4c. module.

   - gh-91851(53): Optimize the *note Fraction: 1c8. arithmetics for
     small components.

   - bpo-24132(54): Make *note pathlib.PurePath: 473. and *note Path:
     20a. subclassable (private to start).  Previously, attempting to
     instantiate a subclass resulted in an *note AttributeError: 326.
     being raised.  Patch by Barney Gale.

   - bpo-40447(55): Accept *note os.PathLike: c1f. (such as *note
     pathlib.Path: 20a.) in the ‘stripdir’ arguments of *note
     compileall.compile_file(): dae. and *note compileall.compile_dir():
     af4.

   - bpo-36880(56): Fix a reference counting issue when a *note ctypes:
     22. callback with return type *note py_object: 13df. returns
     ‘None’, which could cause crashes.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100833

   (2) https://github.com/python/cpython/issues/100805

   (3) https://github.com/python/cpython/issues/100813

   (4) https://github.com/python/cpython/issues/100792

   (5) https://github.com/python/cpython/issues/91851

   (6) https://github.com/python/cpython/issues/90104

   (7) https://github.com/python/cpython/issues/100689

   (8) https://github.com/python/cpython/issues/100740

   (9) https://github.com/python/cpython/issues/91219

   (10) https://github.com/python/cpython/issues/100690

   (11) https://github.com/python/cpython/issues/89727

   (12) https://github.com/python/cpython/issues/100485

   (13) https://github.com/python/cpython/issues/86508

   (14) https://github.com/python/cpython/issues/97930

   (15) https://github.com/python/cpython/issues/100585

   (16) https://github.com/python/cpython/issues/100562

   (17) https://github.com/python/cpython/issues/100519

   (18) https://github.com/python/cpython/issues/100287

   (19) https://github.com/python/cpython/issues/100488

   (20) https://github.com/python/cpython/issues/100474

   (21) https://github.com/python/cpython/issues/100363

   (22) https://github.com/python/cpython/issues/78878

   (23) https://github.com/python/cpython/issues/100348

   (24) https://github.com/python/cpython/issues/100344

   (25) https://github.com/python/cpython/issues/100272

   (26) https://github.com/python/cpython/issues/83076

   (27) https://github.com/python/cpython/issues/100234

   (28) https://github.com/python/cpython/issues/100228

   (29) https://github.com/python/cpython/issues/100039

   (30) https://github.com/python/cpython/issues/100133

   (31) https://bugs.python.org/issue?@action=redirect&bpo=44592

   (32) https://github.com/python/cpython/issues/100098

   (33) https://github.com/python/cpython/issues/85432

   (34) https://github.com/python/cpython/issues/98778

   (35) https://github.com/python/cpython/issues/99925

   (36) https://github.com/python/cpython/issues/89727

   (37) https://github.com/python/cpython/issues/94943

   (38) https://github.com/python/cpython/issues/83035

   (39) https://github.com/python/cpython/issues/99576

   (40) https://github.com/python/cpython/issues/94912

   (41) https://github.com/python/cpython/issues/99509

   (42) https://peps.python.org/pep-0585/

   (43) https://github.com/python/cpython/issues/99482

   (44) https://github.com/python/cpython/issues/99433

   (45) https://github.com/python/cpython/issues/85267

   (46) https://github.com/python/cpython/issues/91166

   (47) https://github.com/python/cpython/issues/98030

   (48) https://github.com/python/cpython/issues/88500

   (49) https://github.com/python/cpython/issues/96127

   (50) https://github.com/python/cpython/issues/95882

   (51) https://github.com/python/cpython/issues/78707

   (52) https://github.com/python/cpython/issues/92122

   (53) https://github.com/python/cpython/issues/91851

   (54) https://bugs.python.org/issue?@action=redirect&bpo=24132

   (55) https://bugs.python.org/issue?@action=redirect&bpo=40447

   (56) https://bugs.python.org/issue?@action=redirect&bpo=36880


File: python.info,  Node: Documentation<14>,  Next: Tests<17>,  Prev: Library<19>,  Up: Python 3 12 0 alpha 4

1.23.20.3 Documentation
.......................

   - gh-100616(1): Document existing ‘attr’ parameter to *note
     curses.window.vline(): 16f4. function in *note curses: 23.

   - gh-100472(2): Remove claim in documentation that the ‘stripdir’,
     ‘prependdir’ and ‘limit_sl_dest’ parameters of *note
     compileall.compile_dir(): af4. and *note compileall.compile_file():
     dae. could be *note bytes: 1a4.

   - bpo-25377(3): Clarify use of octal format of mode argument in
     help(os.chmod) as well as help(os.fchmod)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100616

   (2) https://github.com/python/cpython/issues/100472

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25377


File: python.info,  Node: Tests<17>,  Next: Build<19>,  Prev: Documentation<14>,  Up: Python 3 12 0 alpha 4

1.23.20.4 Tests
...............

   - gh-100454(1): Start running SSL tests with OpenSSL 3.1.0-beta1.

   - gh-100086(2): The Python test runner (libregrtest) now logs Python
     build information like "debug" vs "release" build, or LTO and PGO
     optimizations.  Patch by Victor Stinner.

   - gh-93018(3): Make two tests forgiving towards host system libexpat
     with backported security fixes applied.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100454

   (2) https://github.com/python/cpython/issues/100086

   (3) https://github.com/python/cpython/issues/93018


File: python.info,  Node: Build<19>,  Next: Windows<16>,  Prev: Tests<17>,  Up: Python 3 12 0 alpha 4

1.23.20.5 Build
...............

   - gh-100540(1): Removed the ‘--with-system-ffi’ ‘configure’ option;
     ‘libffi’ must now always be supplied by the system on all
     non-Windows platforms.  The option has had no effect on non-Darwin
     platforms for several releases, and in 3.11 only had the
     non-obvious effect of invoking ‘pkg-config’ to find ‘libffi’ and
     never setting ‘-DUSING_APPLE_OS_LIBFFI’.  Now on Darwin platforms
     ‘configure’ will first check for the OS ‘libffi’ and then fall back
     to the same processing as other platforms if it is not found.

   - gh-88267(2): Avoid exporting Python symbols in linked Windows
     applications when the core is built as static.

   - bpo-41916(3): Allow override of ac_cv_cxx_thread so that cross
     compiled python can set -pthread for CXX.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100540

   (2) https://github.com/python/cpython/issues/88267

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41916


File: python.info,  Node: Windows<16>,  Next: macOS<12>,  Prev: Build<19>,  Up: Python 3 12 0 alpha 4

1.23.20.6 Windows
.................

   - gh-100180(1): Update Windows installer to OpenSSL 1.1.1s

   - gh-99191(2): Use ‘_MSVC_LANG >= 202002L’ instead of less-precise
     ‘_MSC_VER >=1929’ to more accurately test for C++20 support in
     ‘PC/_wmimodule.cpp’.

   - gh-79218(3): Define ‘MS_WIN64’ for Mingw-w64 64bit, fix cython
     compilation failure.

   - gh-99941(4): Ensure that *note asyncio.Protocol.data_received():
     16f8. receives an immutable *note bytes: 1a4. object (as
     documented), instead of *note bytearray: 508.

   - bpo-43984(5): *note winreg.SetValueEx(): 16f9. now leaves the
     target value untouched in the case of conversion errors.
     Previously, ‘-1’ would be written in case of such errors.

   - bpo-34816(6): ‘hasattr(ctypes.windll, 'nonexistant')’ now returns
     ‘False’ instead of raising *note OSError: 3f0.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100180

   (2) https://github.com/python/cpython/issues/99191

   (3) https://github.com/python/cpython/issues/79218

   (4) https://github.com/python/cpython/issues/99941

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43984

   (6) https://bugs.python.org/issue?@action=redirect&bpo=34816


File: python.info,  Node: macOS<12>,  Next: Tools/Demos<9>,  Prev: Windows<16>,  Up: Python 3 12 0 alpha 4

1.23.20.7 macOS
...............

   - gh-100180(1): Update macOS installer to OpenSSL 1.1.1s

   - gh-100540(2): Removed obsolete ‘dlfcn.h’ shim from the ‘_ctypes’
     extension module, which has not been necessary since Mac OS X 10.2.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100180

   (2) https://github.com/python/cpython/issues/100540


File: python.info,  Node: Tools/Demos<9>,  Next: C API<18>,  Prev: macOS<12>,  Up: Python 3 12 0 alpha 4

1.23.20.8 Tools/Demos
.....................

   - bpo-45256(1): Fix a bug that caused an *note AttributeError: 326.
     to be raised in ‘python-gdb.py’ when ‘py-locals’ is used without a
     frame.

   - gh-100342(2): Add missing ‘NULL’ check for possible allocation
     failure in ‘*args’ parsing in Argument Clinic.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45256

   (2) https://github.com/python/cpython/issues/100342


File: python.info,  Node: C API<18>,  Prev: Tools/Demos<9>,  Up: Python 3 12 0 alpha 4

1.23.20.9 C API
...............

   - gh-99947(1): Raising SystemError on import will now have its cause
     be set to the original unexpected exception.

   - gh-99240(2): In argument parsing, after deallocating newly
     allocated memory, reset its pointer to NULL.

   - gh-98724(3): The *note Py_CLEAR: 544, *note Py_SETREF: 545. and
     *note Py_XSETREF: 546. macros now only evaluate their arguments
     once.  If an argument has side effects, these side effects are no
     longer duplicated.  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99947

   (2) https://github.com/python/cpython/issues/99240

   (3) https://github.com/python/cpython/issues/98724


File: python.info,  Node: Python 3 12 0 alpha 3,  Next: Python 3 12 0 alpha 2,  Prev: Python 3 12 0 alpha 4,  Up: 変更履歴

1.23.21 Python 3.12.0 alpha 3
-----------------------------

'Release date: 2022-12-06'

* Menu:

* Security: Security<13>.
* Core and Builtins: Core and Builtins<21>.
* Library: Library<20>.
* Documentation: Documentation<15>.
* Tests: Tests<18>.
* Build: Build<20>.
* Windows: Windows<17>.
* macOS: macOS<13>.
* Tools/Demos: Tools/Demos<10>.
* C API: C API<19>.


File: python.info,  Node: Security<13>,  Next: Core and Builtins<21>,  Up: Python 3 12 0 alpha 3

1.23.21.1 Security
..................

   - gh-100001(1): ‘python -m http.server’ no longer allows terminal
     control characters sent within a garbage request to be printed to
     the stderr server log.

     This is done by changing the *note http.server: 68.
     ‘BaseHTTPRequestHandler’ ‘.log_message’ method to replace control
     characters with a ‘\xHH’ hex escape before printing.

   - gh-87604(2): Avoid publishing list of active per-interpreter audit
     hooks via the *note gc: 56. module

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100001

   (2) https://github.com/python/cpython/issues/87604


File: python.info,  Node: Core and Builtins<21>,  Next: Library<20>,  Prev: Security<13>,  Up: Python 3 12 0 alpha 3

1.23.21.2 Core and Builtins
...........................

   - gh-99891(1): Fix a bug in the tokenizer that could cause infinite
     recursion when showing syntax warnings that happen in the first
     line of the source.  Patch by Pablo Galindo

   - gh-91054(2): Add *note PyCode_AddWatcher(): 532. and *note
     PyCode_ClearWatcher(): 533. APIs to register callbacks to receive
     notification on creation and destruction of code objects.

   - gh-99729(3): Fix an issue that could cause frames to be visible to
     Python code as they are being torn down, possibly leading to memory
     corruption or hard crashes of the interpreter.

   - gh-99708(4): Fix bug where compiler crashes on an if expression
     with an empty body block.

   - gh-99578(5): Fix a reference bug in ‘_imp.create_builtin()’ after
     the creation of the first sub-interpreter for modules ‘builtins’
     and ‘sys’.  Patch by Victor Stinner.

   - gh-99581(6): Fixed a bug that was causing a buffer overflow if the
     tokenizer copies a line missing the newline character from a file
     that is as long as the available tokenizer buffer.  Patch by Pablo
     galindo

   - gh-99553(7): Fix bug where an *note ExceptionGroup: 19b. subclass
     can wrap a *note BaseException: 584.

   - gh-99547(8): Add a function to os.path to check if a path is a
     junction: isjunction.  Add similar functionality to pathlib.Path as
     is_junction.

   - gh-99370(9): Fix zip path for venv created from a non-installed
     python on POSIX platforms.

   - gh-99377(10): Add audit events for thread creation and clear
     operations.

   - gh-98686(11): Remove the ‘BINARY_OP_GENERIC’ and
     ‘COMPARE_OP_GENERIC’ "specializations".

   - gh-99298(12): Remove the remaining error paths for attribute
     specializations, and refuse to specialize attribute accesses on
     types that haven't had *note PyType_Ready(): 747. called on them
     yet.

   - gh-99127(13): Allow some features of *note syslog: c6. to the main
     interpreter only.  Patch by Donghee Na.

   - gh-91053(14): Optimizing interpreters and JIT compilers may need to
     invalidate internal metadata when functions are modified.  This
     change adds the ability to provide a callback that will be invoked
     each time a function is created, modified, or destroyed.

   - gh-90994(15): Improve error messages when there's a syntax error
     with call arguments.  The following three cases are covered: - No
     value is assigned to a named argument, eg ‘foo(a=)’.  - A value is
     assigned to a star argument, eg ‘foo(*args=[0])’.  - A value is
     assigned to a double-star keyword argument, eg ‘foo(**kwarg={'a':
     0})’.

   - bpo-45026(16): Optimize the *note range: 911. object iterator.  It
     is now smaller, faster iteration of ranges containing large
     numbers.  Smaller pickles, faster unpickling.

   - bpo-31718(17): Raise *note ValueError: 1e3. instead of *note
     SystemError: 541. when methods of uninitialized *note
     io.IncrementalNewlineDecoder: 162e. objects are called.  Patch by
     Oren Milman.

   - bpo-38031(18): Fix a possible assertion failure in *note io.FileIO:
     12df. when the opener returns an invalid file descriptor.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99891

   (2) https://github.com/python/cpython/issues/91054

   (3) https://github.com/python/cpython/issues/99729

   (4) https://github.com/python/cpython/issues/99708

   (5) https://github.com/python/cpython/issues/99578

   (6) https://github.com/python/cpython/issues/99581

   (7) https://github.com/python/cpython/issues/99553

   (8) https://github.com/python/cpython/issues/99547

   (9) https://github.com/python/cpython/issues/99370

   (10) https://github.com/python/cpython/issues/99377

   (11) https://github.com/python/cpython/issues/98686

   (12) https://github.com/python/cpython/issues/99298

   (13) https://github.com/python/cpython/issues/99127

   (14) https://github.com/python/cpython/issues/91053

   (15) https://github.com/python/cpython/issues/90994

   (16) https://bugs.python.org/issue?@action=redirect&bpo=45026

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31718

   (18) https://bugs.python.org/issue?@action=redirect&bpo=38031


File: python.info,  Node: Library<20>,  Next: Documentation<15>,  Prev: Core and Builtins<21>,  Up: Python 3 12 0 alpha 3

1.23.21.3 Library
.................

   - gh-100001(1): Also escape s in the http.server
     BaseHTTPRequestHandler.log_message so that it is technically
     possible to parse the line and reconstruct what the original data
     was.  Without this a xHH is ambiguous as to if it is a hex
     replacement we put in or the characters r"x" came through in the
     original request line.

   - gh-99957(2): Add ‘frozen_default’ parameter to *note
     typing.dataclass_transform(): 4a0.

   - gh-79033(3): Fix *note asyncio.Server.wait_closed(): 162f. to
     actually do what the docs promise - wait for all existing
     connections to complete, after closing the server.

   - gh-51524(4): Fix bug when calling trace.CoverageResults with valid
     infile.

   - gh-99645(5): Fix a bug in handling class cleanups in *note
     unittest.TestCase: 41a.  Now ‘addClassCleanup()’ uses separate
     lists for different ‘TestCase’ subclasses, and ‘doClassCleanups()’
     only cleans up the particular class.

   - gh-99508(6): Fix ‘TypeError’ in
     ‘Lib/importlib/_bootstrap_external.py’ while calling
     ‘_imp.source_hash()’.

   - gh-66285(7): Fix *note asyncio: 8. to not share event loop and
     signal wakeupfd in forked processes.  Patch by Kumar Aditya.

   - gh-97001(8): Release the GIL when calling termios APIs to avoid
     blocking threads.

   - gh-92647(9): Use final status of an enum to determine lookup or
     creation branch of functional API.

   - gh-99388(10): Add 'loop_factory' parameter to *note asyncio.run():
     449. to allow specifying a custom event loop factory.  Patch by
     Kumar Aditya.

   - gh-99341(11): Fix *note ast.increment_lineno(): 1701. to also cover
     ‘ast.TypeIgnore’ when changing line numbers.

   - gh-99382(12): Check the number of arguments in substitution in user
     generics containing a *note TypeVarTuple: 145. and one or more
     *note TypeVar: 143.

   - gh-99379(13): Fix substitution of *note ParamSpec: 144. followed by
     *note TypeVarTuple: 145. in generic aliases.

   - gh-99344(14): Fix substitution of *note TypeVarTuple: 145. and
     *note ParamSpec: 144. together in user generics.

   - gh-99284(15): Remove ‘_use_broken_old_ctypes_structure_semantics_’
     old untested and undocumented hack from *note ctypes: 22.

   - gh-99201(16): Fix *note IndexError: 14de. when initializing the
     config variables on Windows if ‘HAVE_DYNAMIC_LOADING’ is not set.

   - gh-99240(17): Fix double-free bug in Argument Clinic
     ‘str_converter’ by extracting memory clean up to a new
     ‘post_parsing’ section.

   - gh-64490(18): Fix refcount error when arguments are packed to tuple
     in Argument Clinic.

   - gh-99029(19): *note pathlib.PurePath.relative_to(): 2ab. now treats
     naked Windows drive paths as relative.  This brings its behaviour
     in line with other parts of pathlib.

   - gh-98253(20): The implementation of the typing module is now more
     resilient to reference leaks in binary extension modules.

     Previously, a reference leak in a typed C API-based extension
     module could leak internals of the typing module, which could in
     turn introduce leaks in essentially any other package with typed
     function signatures.  Although the typing package is not the
     original source of the problem, such non-local dependences
     exacerbate debugging of large-scale projects, and the
     implementation was therefore changed to reduce harm by providing
     better isolation.

   - gh-98458(21): Fix infinite loop in unittest when a self-referencing
     chained exception is raised

   - gh-93453(22): *note asyncio.get_event_loop(): 2a2. and many other
     *note asyncio: 8. functions like *note asyncio.ensure_future():
     c44, *note asyncio.shield(): a3e. or *note asyncio.gather(): 5c8,
     and also the ‘get_event_loop()’ method of
     ‘asyncio.BaseDefaultEventLoopPolicy’ now raise a *note
     RuntimeError: 17a. if called when there is no running event loop
     and the current event loop was not set.  Previously they implicitly
     created and set a new current event loop.  *note
     DeprecationWarning: 18a. is no longer emitted if there is no
     running event loop but the current event loop was set.

   - gh-97966(23): On ‘uname_result’, restored expectation that
     ‘_fields’ and ‘_asdict’ would include all six properties including
     ‘processor’.

   - gh-98248(24): Provide informative error messages in *note
     struct.pack(): 1248. when its integral arguments are not in range.

   - gh-98108(25): ‘zipfile.Path’ is now pickleable if its
     initialization parameters were pickleable (e.g.  for file system
     paths).

   - gh-98098(26): Created packages from zipfile and test_zipfile
     modules, separating ‘zipfile.Path’ functionality.

   - gh-82836(27): Fix *note is_private: 15ad. properties in the *note
     ipaddress: 74. module.  Previously non-private networks (0.0.0.0/0)
     would return ‘True’ from this method; now they correctly return
     ‘False’.

   - gh-96828(28): Add an *note OP_ENABLE_KTLS: 1702. option for
     enabling the use of the kernel TLS (kTLS). Patch by Illia Volochii.

   - gh-88863(29): To avoid apparent memory leaks when *note
     asyncio.open_connection(): ae6. raises, break reference cycles
     generated by local exception and future instances (which has
     exception instance as its member var).  Patch by Dong Uk, Kang.

   - gh-91078(30): ‘TarFile.next()’ now returns ‘None’ when called on an
     empty tarfile.

   - bpo-47220(31): Document the optional 'callback' parameter of
     ‘WeakMethod’.  Patch by Géry Ogam.

   - bpo-44817(32): Ignore WinError 53 (ERROR_BAD_NETPATH), 65
     (ERROR_NETWORK_ACCESS_DENIED) and 161 (ERROR_BAD_PATHNAME) when
     using ntpath.realpath().

   - bpo-41260(33): Rename the 'fmt' parameter of the pure Python
     implementation of *note datetime.date.strftime(): c5f. to 'format'.

   - bpo-15999(34): All built-in functions now accept arguments of any
     type instead of just ‘bool’ and ‘int’ for boolean parameters.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/100001

   (2) https://github.com/python/cpython/issues/99957

   (3) https://github.com/python/cpython/issues/79033

   (4) https://github.com/python/cpython/issues/51524

   (5) https://github.com/python/cpython/issues/99645

   (6) https://github.com/python/cpython/issues/99508

   (7) https://github.com/python/cpython/issues/66285

   (8) https://github.com/python/cpython/issues/97001

   (9) https://github.com/python/cpython/issues/92647

   (10) https://github.com/python/cpython/issues/99388

   (11) https://github.com/python/cpython/issues/99341

   (12) https://github.com/python/cpython/issues/99382

   (13) https://github.com/python/cpython/issues/99379

   (14) https://github.com/python/cpython/issues/99344

   (15) https://github.com/python/cpython/issues/99284

   (16) https://github.com/python/cpython/issues/99201

   (17) https://github.com/python/cpython/issues/99240

   (18) https://github.com/python/cpython/issues/64490

   (19) https://github.com/python/cpython/issues/99029

   (20) https://github.com/python/cpython/issues/98253

   (21) https://github.com/python/cpython/issues/98458

   (22) https://github.com/python/cpython/issues/93453

   (23) https://github.com/python/cpython/issues/97966

   (24) https://github.com/python/cpython/issues/98248

   (25) https://github.com/python/cpython/issues/98108

   (26) https://github.com/python/cpython/issues/98098

   (27) https://github.com/python/cpython/issues/82836

   (28) https://github.com/python/cpython/issues/96828

   (29) https://github.com/python/cpython/issues/88863

   (30) https://github.com/python/cpython/issues/91078

   (31) https://bugs.python.org/issue?@action=redirect&bpo=47220

   (32) https://bugs.python.org/issue?@action=redirect&bpo=44817

   (33) https://bugs.python.org/issue?@action=redirect&bpo=41260

   (34) https://bugs.python.org/issue?@action=redirect&bpo=15999


File: python.info,  Node: Documentation<15>,  Next: Tests<18>,  Prev: Library<20>,  Up: Python 3 12 0 alpha 3

1.23.21.4 Documentation
.......................

   - gh-99931(1): Use sphinxext-opengraph(2) to generate OpenGraph
     metadata(3).

   - gh-89682(4): Reworded docstring of the default ‘__contains__’ to
     clarify that it returns a *note bool: 434.

   - gh-88330(5): Improved the description of what a resource is in
     importlib.resources docs.

   - gh-92892(6): Document that calling variadic functions with ctypes
     requires special care on macOS/arm64 (and possibly other
     platforms).

   - bpo-41825(7): Restructured the documentation for the *note
     os.wait*: d65. family of functions, and improved the docs for *note
     os.waitid(): d66. with more explanation of the possible argument
     constants.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99931

   (2) https://sphinxext-opengraph.readthedocs.io/

   (3) https://ogp.me/

   (4) https://github.com/python/cpython/issues/89682

   (5) https://github.com/python/cpython/issues/88330

   (6) https://github.com/python/cpython/issues/92892

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41825


File: python.info,  Node: Tests<18>,  Next: Build<20>,  Prev: Documentation<15>,  Up: Python 3 12 0 alpha 3

1.23.21.5 Tests
...............

   - gh-99892(1): Skip test_normalization() of test_unicodedata if it
     fails to download NormalizationTest.txt file from pythontest.net.
     Patch by Victor Stinner.

   - gh-99934(2): Correct test_marsh on (32 bit) x86: test_deterministic
     sets was failing.

   - gh-99741(3): We've implemented multi-phase init (PEP 489/630/687)
     for the internal (for testing) _xxsubinterpreters module.

   - gh-99659(4): Optional big memory tests in ‘test_sqlite3’ now catch
     the correct ‘sqlite.DataError’ exception type in case of too large
     strings and/or blobs passed.

   - gh-99593(5): Cover the Unicode C API with tests.

   - gh-96002(6): Add functional test for Argument Clinic.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99892

   (2) https://github.com/python/cpython/issues/99934

   (3) https://github.com/python/cpython/issues/99741

   (4) https://github.com/python/cpython/issues/99659

   (5) https://github.com/python/cpython/issues/99593

   (6) https://github.com/python/cpython/issues/96002


File: python.info,  Node: Build<20>,  Next: Windows<17>,  Prev: Tests<18>,  Up: Python 3 12 0 alpha 3

1.23.21.6 Build
...............

   - gh-99086(1): Fix ‘-Wimplicit-int’, ‘-Wstrict-prototypes’, and
     ‘-Wimplicit-function-declaration’ compiler warnings in ‘configure’
     checks.

   - gh-99337(2): Fix a compilation issue with GCC 12 on macOS.

   - gh-99289(3): Add a ‘COMPILEALL_OPTS’ variable in Makefile to
     override *note compileall: 19. options (default: ‘-j0’) in ‘make
     install’.  Also merged the ‘compileall’ commands into a single
     command building .pyc files for the all optimization levels (0, 1,
     2) at once.  Patch by Victor Stinner.

   - gh-98872(4): Fix a possible fd leak in ‘Programs/_freeze_module.c’
     introduced in Python 3.11.

   - gh-88226(5): Always define ‘TARGET_*’ labels in ‘Python/ceval.c’,
     even if ‘USE_COMPUTED_GOTOS’ is disabled.  This allows breakpoints
     to be set at those labels in (for instance) ‘gdb’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99086

   (2) https://github.com/python/cpython/issues/99337

   (3) https://github.com/python/cpython/issues/99289

   (4) https://github.com/python/cpython/issues/98872

   (5) https://github.com/python/cpython/issues/88226


File: python.info,  Node: Windows<17>,  Next: macOS<13>,  Prev: Build<20>,  Up: Python 3 12 0 alpha 3

1.23.21.7 Windows
.................

   - gh-99345(1): Use faster initialization functions to detect install
     location for Windows Store package

   - gh-98629(2): Fix initialization of *note sys.version: 15e. and
     ‘sys._git’ on Windows

   - gh-99442(3): Fix handling in *note Windows の Python ランチャ: 588.
     when ‘argv[0]’ does not include a file extension.

   - bpo-40882(4): Fix a memory leak in *note
     multiprocessing.shared_memory.SharedMemory: 15bd. on Windows.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99345

   (2) https://github.com/python/cpython/issues/98629

   (3) https://github.com/python/cpython/issues/99442

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40882


File: python.info,  Node: macOS<13>,  Next: Tools/Demos<10>,  Prev: Windows<17>,  Up: Python 3 12 0 alpha 3

1.23.21.8 macOS
...............

   - gh-87235(1): On macOS ‘python3 /dev/fd/9 9</path/to/script.py’
     failed for any script longer than a couple of bytes.

   - gh-98940(2): Fix ‘Mac/Extras.install.py’ file filter bug.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/87235

   (2) https://github.com/python/cpython/issues/98940


File: python.info,  Node: Tools/Demos<10>,  Next: C API<19>,  Prev: macOS<13>,  Up: Python 3 12 0 alpha 3

1.23.21.9 Tools/Demos
.....................

   - gh-64490(1): Argument Clinic varargs bugfixes

        * Fix out-of-bounds error in
          ‘_PyArg_UnpackKeywordsWithVararg()’.

        * Fix incorrect check which allowed more than one varargs in
          clinic.py.

        * Fix miscalculation of ‘noptargs’ in generated code.

        * Do not generate ‘noptargs’ when there is a vararg argument and
          no optional argument.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/64490


File: python.info,  Node: C API<19>,  Prev: Tools/Demos<10>,  Up: Python 3 12 0 alpha 3

1.23.21.10 C API
................

   - gh-98680(1): ‘PyBUF_*’ constants were marked as part of Limited API
     of Python 3.11+.  These were available in 3.11.0 with *note
     Py_LIMITED_API: 3f7. defined for 3.11, and are necessary to use the
     buffer API.

   - gh-99612(2): Fix *note PyUnicode_DecodeUTF8Stateful(): 170a. for
     ASCII-only data: ‘*consumed’ was not set.

   - gh-47146(3): The ‘structmember.h’ header is deprecated.  Its
     non-deprecated contents are now available just by including
     ‘Python.h’, with a ‘Py_’ prefix added if it was missing.
     (Deprecated contents are *note T_OBJECT: 55f, *note T_NONE: 561,
     and no-op flags.)  Patch by Petr Viktorin, based on earlier work by
     Alexander Belopolsky and Matthias Braun.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98680

   (2) https://github.com/python/cpython/issues/99612

   (3) https://github.com/python/cpython/issues/47146


File: python.info,  Node: Python 3 12 0 alpha 2,  Next: Python 3 12 0 alpha 1,  Prev: Python 3 12 0 alpha 3,  Up: 変更履歴

1.23.22 Python 3.12.0 alpha 2
-----------------------------

'Release date: 2022-11-14'

* Menu:

* Security: Security<14>.
* Core and Builtins: Core and Builtins<22>.
* Library: Library<21>.
* Documentation: Documentation<16>.
* Tests: Tests<19>.
* Build: Build<21>.
* Windows: Windows<18>.
* macOS: macOS<14>.
* C API: C API<20>.


File: python.info,  Node: Security<14>,  Next: Core and Builtins<22>,  Up: Python 3 12 0 alpha 2

1.23.22.1 Security
..................

   - gh-98433(1): The IDNA codec decoder used on DNS hostnames by *note
     socket: b8. or *note asyncio: 8. related name resolution functions
     no longer involves a quadratic algorithm.  This prevents a
     potential CPU denial of service if an out-of-spec excessive length
     hostname involving bidirectional characters were decoded.  Some
     protocols such as *note urllib: f1. http ‘3XX’ redirects
     potentially allow for an attacker to supply such a name.

     Individual labels within an IDNA encoded DNS name will now raise an
     error early during IDNA decoding if they are longer than 1024
     unicode characters given that each decoded DNS label must be 63 or
     fewer characters and the entire decoded DNS name is limited to 255.
     Only an application presenting a hostname or label consisting
     primarily of RFC 3454(2) section 3.1 "Nothing" characters to be
     removed would run into of this new limit.  See also RFC 5894(3)
     section 6 and RFC 3491(4).

   - gh-98739(5): Update bundled libexpat to 2.5.0

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98433

   (2) https://datatracker.ietf.org/doc/html/rfc3454.html

   (3) https://datatracker.ietf.org/doc/html/rfc5894.html

   (4) https://datatracker.ietf.org/doc/html/rfc3491.html

   (5) https://github.com/python/cpython/issues/98739


File: python.info,  Node: Core and Builtins<22>,  Next: Library<21>,  Prev: Security<14>,  Up: Python 3 12 0 alpha 2

1.23.22.2 Core and Builtins
...........................

   - gh-81057(1): The docs clearly say that ‘PyImport_Inittab’, *note
     PyImport_AppendInittab(): 170e, and *note PyImport_ExtendInittab():
     170f. should not be used after *note Py_Initialize(): 87a. has been
     called.  We now enforce this for the two functions.  Additionally,
     the runtime now uses an internal copy of ‘PyImport_Inittab’, to
     guard against modification.

   - gh-99298(2): Fix an issue that could potentially cause incorrect
     error handling for some bytecode instructions.

   - gh-99254(3): The compiler now removes all unused constants from
     code objects (except the first one, which may be a docstring).

   - gh-99205(4): Fix an issue that prevented *note PyThreadState: 758.
     and *note PyInterpreterState: 88b. memory from being freed
     properly.

   - gh-81057(5): The 18 global C variables holding the state of the
     allocators have been moved to ‘_PyRuntimeState’.  This is a
     strictly internal change with no change in behavior.

   - gh-99181(6): Fix failure in *note except*: 582. with unhashable
     exceptions.

   - gh-99204(7): Fix calculation of ‘sys._base_executable’ when inside
     a POSIX virtual environment using copies of the python binary when
     the base installation does not provide the executable name used by
     the venv.  Calculation will fall back to alternative names
     ("python<MAJOR>", "python<MAJOR>.<MINOR>").

   - gh-96055(8): Update *note faulthandler: 4e. to emit an error
     message with the proper unexpected signal number.  Patch by Donghee
     Na.

   - gh-99153(9): Fix location of *note SyntaxError: 172. for a *note
     try: 6b4. block with both *note except: 170. and *note except*:
     582.

   - gh-98686(10): Merge the adaptive opcode logic into each
     instruction's unquickened variant, and merge the logic in
     ‘EXTENDED_ARG_QUICK’ into *note EXTENDED_ARG: 1710.  With these
     changes, the quickening that happens at code object creation is now
     only responsible for initializing warmup counters and inserting
     superinstructions.

   - gh-99103(11): Fix the error reporting positions of specialized
     traceback anchors when the source line contains Unicode characters.

   - gh-99139(12): Improve the error suggestion for *note NameError:
     40b. exceptions for instances.  Now if a *note NameError: 40b. is
     raised in a method and the instance has an attribute that's exactly
     equal to the name in the exception, the suggestion will include
     ‘self.<NAME>’ instead of the closest match in the method scope.
     Patch by Pablo Galindo

   - gh-98401(13): Octal escapes with value larger than ‘0o377’ (ex:
     ‘"\477"’), deprecated in Python 3.11, now produce a *note
     SyntaxWarning: 432, instead of *note DeprecationWarning: 18a.  In a
     future Python version they will be eventually a *note SyntaxError:
     172.  Patch by Victor Stinner.

   - gh-98401(14): A backslash-character pair that is not a valid escape
     sequence now generates a *note SyntaxWarning: 432, instead of *note
     DeprecationWarning: 18a.  For example, ‘re.compile("\d+\.\d+")’ now
     emits a *note SyntaxWarning: 432. (‘"\d"’ is an invalid escape
     sequence), use raw strings for regular expression:
     ‘re.compile(r"\d+\.\d+")’.  In a future Python version, *note
     SyntaxError: 172. will eventually be raised, instead of *note
     SyntaxWarning: 432.  Patch by Victor Stinner.

   - gh-96793(15): Handle StopIteration and StopAsyncIteration raised in
     generator or coroutines in the bytecode, rather than in wrapping C
     code.

   - gh-98931(16): Improve the *note SyntaxError: 172. error message
     when the user types ‘import x from y’ instead of ‘from y import x’.
     Patch by Pablo Galindo

   - gh-98852(17): Fix subscription of type aliases containing bare
     generic types or types like *note TypeVar: 143.: for example
     ‘tuple[A, T][int]’ and ‘tuple[TypeVar, T][int]’, where ‘A’ is a
     generic type, and ‘T’ is a type variable.

   - gh-98925(18): Lower the recursion depth for marshal on WASI to
     support (in-development) wasmtime 2.0.

   - gh-98783(19): Fix multiple crashes in debug mode when ‘str’
     subclasses are used instead of ‘str’ itself.

   - gh-98811(20): Use complete source locations to simplify detection
     of ‘__future__’ imports which are not at the beginning of the file.
     Also corrects the offset in the exception raised in one case, which
     was off by one and impeded highlighting.

   - gh-96793(21): Add specialization of *note FOR_ITER: 16bc. for
     generators.  Saves multiple layers of dispatch and checking to get
     from the *note FOR_ITER: 16bc. instruction in the caller to the
     *note RESUME: 2ed. in the generator.

   - gh-98762(22): Fix source locations of *note match: 7d8.
     sub-patterns.

   - gh-98586(23): Added the methods *note PyObject_Vectorcall(): 527.
     and *note PyObject_VectorcallMethod(): 528. to the *note Limited
     API: 51e. along with the auxiliary macro constant *note
     PY_VECTORCALL_ARGUMENTS_OFFSET: 529.

     The availability of these functions enables more efficient PEP
     590(24) vector calls from binary extension modules that avoid
     argument boxing/unboxing overheads.

   - gh-99257(25): Fix an issue where member descriptors (such as those
     for *note __slots__: 1493.) could behave incorrectly or crash
     instead of raising a *note TypeError: 502. when accessed via an
     instance of an invalid type.

   - gh-93143(26): Rather than changing ‘co_code’, the interpreter will
     now display a *note RuntimeWarning: 1a2. and assign *note None:
     641. to any fast locals that are left unbound after jumps or *note
     del: 1711. statements executed while tracing.

   - gh-96421(27): When calling into Python code from C code, through
     *note PyEval_EvalFrameEx(): ff8. or a related C-API function, a
     shim frame in inserted into the call stack.  This occurs in the
     ‘_PyEval_EvalFrameDefault()’ function.  The extra frame should be
     invisible to all Python and most C extensions, but out-of-process
     profilers and debuggers need to be aware of it.  These shim frames
     can be detected by checking ‘frame->owner ==
     FRAME_OWNED_BY_CSTACK’.

     Extensions implementing their own interpreters using PEP 523 need
     to be aware of this shim frame and the changes to the semantics of
     *note RETURN_VALUE: 1712, *note YIELD_VALUE: 2ec, and *note
     RETURN_GENERATOR: 6c7, which now clear the frame.

   - gh-98415(28): Fix detection of MAC addresses for *note uuid: f8. on
     certain OSs.  Patch by Chaim Sanders

   - gh-98686(29): Quicken all code objects, and specialize adaptive
     bytecode instructions more aggressively.

   - gh-92119(30): Print exception class name instead of its string
     representation when raising errors from *note ctypes: 22. calls.

   - gh-91058(31): *note ImportError: 3f2. raised from failed ‘from
     <module> import <name>’ now include suggestions for the value of
     ‘<name>’ based on the available names in ‘<module>’.  Patch by
     Pablo Galindo

   - gh-96793(32): The *note FOR_ITER: 16bc. now leaves the iterator on
     the stack on termination of the loop.  This is to assist
     specialization of loops for generators.

   - gh-90716(33): Add _pylong.py module.  It includes asymptotically
     faster algorithms that can be used for operations on integers with
     many digits.  It is used by longobject.c to speed up some
     operations.

   - gh-95389(34): Expose *note ETH_P_ALL: 1713. and some of the *note
     ETHERTYPE_* constants: 1714. in *note socket: b8.  Patch by Noam
     Cohen.

   - gh-93696(35): Allow *note pdb: 94. to locate source for frozen
     modules in the standard library.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/81057

   (2) https://github.com/python/cpython/issues/99298

   (3) https://github.com/python/cpython/issues/99254

   (4) https://github.com/python/cpython/issues/99205

   (5) https://github.com/python/cpython/issues/81057

   (6) https://github.com/python/cpython/issues/99181

   (7) https://github.com/python/cpython/issues/99204

   (8) https://github.com/python/cpython/issues/96055

   (9) https://github.com/python/cpython/issues/99153

   (10) https://github.com/python/cpython/issues/98686

   (11) https://github.com/python/cpython/issues/99103

   (12) https://github.com/python/cpython/issues/99139

   (13) https://github.com/python/cpython/issues/98401

   (14) https://github.com/python/cpython/issues/98401

   (15) https://github.com/python/cpython/issues/96793

   (16) https://github.com/python/cpython/issues/98931

   (17) https://github.com/python/cpython/issues/98852

   (18) https://github.com/python/cpython/issues/98925

   (19) https://github.com/python/cpython/issues/98783

   (20) https://github.com/python/cpython/issues/98811

   (21) https://github.com/python/cpython/issues/96793

   (22) https://github.com/python/cpython/issues/98762

   (23) https://github.com/python/cpython/issues/98586

   (24) https://peps.python.org/pep-0590/

   (25) https://github.com/python/cpython/issues/99257

   (26) https://github.com/python/cpython/issues/93143

   (27) https://github.com/python/cpython/issues/96421

   (28) https://github.com/python/cpython/issues/98415

   (29) https://github.com/python/cpython/issues/98686

   (30) https://github.com/python/cpython/issues/92119

   (31) https://github.com/python/cpython/issues/91058

   (32) https://github.com/python/cpython/issues/96793

   (33) https://github.com/python/cpython/issues/90716

   (34) https://github.com/python/cpython/issues/95389

   (35) https://github.com/python/cpython/issues/93696


File: python.info,  Node: Library<21>,  Next: Documentation<16>,  Prev: Core and Builtins<22>,  Up: Python 3 12 0 alpha 2

1.23.22.3 Library
.................

   - gh-99418(1): Fix bug in *note urllib.parse.urlparse(): 2e5. that
     causes URL schemes that begin with a digit, a plus sign, or a minus
     sign to be parsed incorrectly.

   - gh-94597(2): Deprecate *note asyncio.AbstractChildWatcher: 29c. to
     be removed in Python 3.14.  Patch by Kumar Aditya.

   - gh-99305(3): Improve performance of *note secrets.token_hex():
     1716.

   - gh-74044(4): Fixed bug where *note inspect.signature(): 703.
     reported incorrect arguments for decorated methods.

   - gh-99275(5): Fix ‘SystemError’ in *note ctypes: 22. when exception
     was not set during ‘__initsubclass__’.

   - gh-99277(6): Remove older version of
     ‘_SSLProtocolTransport.get_write_buffer_limits’ in
     ‘asyncio.sslproto’

   - gh-99248(7): fix negative numbers failing in verify()

   - gh-99155(8): Fix *note statistics.NormalDist: a06. pickle with ‘0’
     and ‘1’ protocols.

   - gh-93464(9): ‘enum.auto()’ is now correctly activated when combined
     with other assignment values.  E.g.  ‘ONE = auto(), 'some text'’
     will now evaluate as ‘(1, 'some text')’.

   - gh-99134(10): Update the bundled copy of pip to version 22.3.1.

   - gh-92584(11): Remove the ‘distutils’ package.  It was deprecated in
     Python 3.10 by PEP 632(12) "Deprecate distutils module".  For
     projects still using ‘distutils’ and cannot be updated to something
     else, the ‘setuptools’ project can be installed: it still provides
     ‘distutils’.  Patch by Victor Stinner.

   - gh-98999(13): Now ‘_pyio’ is consistent with ‘_io’ in raising
     ‘ValueError’ when executing methods over closed buffers.

   - gh-83004(14): Clean up refleak on failed module initialisation in
     ‘_zoneinfo’

   - gh-83004(15): Clean up refleaks on failed module initialisation in
     ‘_pickle’

   - gh-83004(16): Clean up refleak on failed module initialisation in
     ‘_io’.

   - gh-98897(17): Fix memory leak in *note math.dist(): 9d0. when both
     points don't have the same dimension.  Patch by Kumar Aditya.

   - gh-98878(18): Use the frame bound builtins when offering a name
     suggestion in *note traceback: e7. to prevent crashing when
     ‘__builtins__’ is not a dict.

   - gh-98139(19): In ‘importlib._bootstrap’, enhance namespace package
     repr to ‘<module 'x' (namespace) from ['path']>’.

   - gh-90352(20): Fix ‘_SelectorDatagramTransport’ to inherit from
     *note DatagramTransport: 1717. in *note asyncio: 8.  Patch by Kumar
     Aditya.

   - gh-98793(21): Fix argument typechecks in ‘_overlapped.WSAConnect()’
     and ‘_overlapped.Overlapped.WSASendTo()’ functions.

   - gh-98744(22): Prevent crashing in *note traceback: e7. when
     retrieving the byte-offset for some source files that contain
     certain unicode characters.

   - gh-98740(23): Fix internal error in the *note re: a7. module which
     in very rare circumstances prevented compilation of a regular
     expression containing a *note conditional expression: 1718. without
     the "else" branch.

   - gh-98703(24): Fix *note asyncio.StreamWriter.drain(): 1719. to call
     ‘protocol.connection_lost’ callback only once on Windows.

   - gh-98624(25): Add a mutex to unittest.mock.NonCallableMock to
     protect concurrent access to mock attributes.

   - gh-98658(26): The *note array.array: 185. class now supports
     subscripting, making it a *note generic type: 405.

   - gh-98284(27): Improved *note TypeError: 502. message for undefined
     abstract methods of a *note abc.ABC: ee3. instance.  The names of
     the missing methods are surrounded by single-quotes to highlight
     them.

   - gh-96151(28): Allow ‘BUILTINS’ to be a valid field name for frozen
     dataclasses.

   - gh-98086(29): Make sure ‘patch.dict()’ can be applied on async
     functions.

   - gh-72719(30): Remove modules ‘asyncore’ and ‘asynchat’, which were
     deprecated by PEP 594(31).

   - gh-96192(32): Fix handling of ‘bytes’ *note path-like objects: 280.
     in ‘os.ismount()’.

   - gh-94172(33): *note ftplib: 54.: Remove the ‘FTP_TLS.ssl_version’
     class attribute: use the 'context' parameter instead.  Patch by
     Victor Stinner

   - gh-94172(34): Remove the 'keyfile' and 'certfile' parameters from
     the *note ftplib: 54, *note imaplib: 6a, *note poplib: 9a. and
     *note smtplib: b7. modules, and the 'key_file', 'cert_file' and
     'check_hostname' parameters from the *note http.client: 65. module,
     all deprecated since Python 3.6.  Use the 'context' parameter
     ('ssl_context' in *note imaplib: 6a.) instead.  Patch by Victor
     Stinner.

   - gh-83638(35): Add the *note autocommit: 482. attribute to *note
     sqlite3.Connection: 226. and the 'autocommit' parameter to *note
     sqlite3.connect(): 288. to control PEP 249(36)-compliant *note
     transaction handling: 483.  Patch by Erlend E. Aasland.

   - gh-92452(37): Fixed a race condition that could cause *note
     sysconfig.get_config_var(): ff5. to incorrectly return *note None:
     641. in multi-threaded programs.

   - gh-91803(38): Fix an error when using a method of objects mocked
     with *note unittest.mock.create_autospec(): 156b. after it was
     sealed with *note unittest.mock.seal(): b6f. function.

   - bpo-38523(39): *note shutil.copytree(): 9f7. now applies the
     'ignore_dangling_symlinks' argument recursively.

   - bpo-40358(40): Add walk_up argument in *note
     pathlib.PurePath.relative_to(): 2ab.

   - bpo-36267(41): Fix IndexError in *note argparse.ArgumentParser:
     503. when a ‘store_true’ action is given an explicit argument.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99418

   (2) https://github.com/python/cpython/issues/94597

   (3) https://github.com/python/cpython/issues/99305

   (4) https://github.com/python/cpython/issues/74044

   (5) https://github.com/python/cpython/issues/99275

   (6) https://github.com/python/cpython/issues/99277

   (7) https://github.com/python/cpython/issues/99248

   (8) https://github.com/python/cpython/issues/99155

   (9) https://github.com/python/cpython/issues/93464

   (10) https://github.com/python/cpython/issues/99134

   (11) https://github.com/python/cpython/issues/92584

   (12) https://peps.python.org/pep-0632/

   (13) https://github.com/python/cpython/issues/98999

   (14) https://github.com/python/cpython/issues/83004

   (15) https://github.com/python/cpython/issues/83004

   (16) https://github.com/python/cpython/issues/83004

   (17) https://github.com/python/cpython/issues/98897

   (18) https://github.com/python/cpython/issues/98878

   (19) https://github.com/python/cpython/issues/98139

   (20) https://github.com/python/cpython/issues/90352

   (21) https://github.com/python/cpython/issues/98793

   (22) https://github.com/python/cpython/issues/98744

   (23) https://github.com/python/cpython/issues/98740

   (24) https://github.com/python/cpython/issues/98703

   (25) https://github.com/python/cpython/issues/98624

   (26) https://github.com/python/cpython/issues/98658

   (27) https://github.com/python/cpython/issues/98284

   (28) https://github.com/python/cpython/issues/96151

   (29) https://github.com/python/cpython/issues/98086

   (30) https://github.com/python/cpython/issues/72719

   (31) https://peps.python.org/pep-0594/

   (32) https://github.com/python/cpython/issues/96192

   (33) https://github.com/python/cpython/issues/94172

   (34) https://github.com/python/cpython/issues/94172

   (35) https://github.com/python/cpython/issues/83638

   (36) https://peps.python.org/pep-0249/

   (37) https://github.com/python/cpython/issues/92452

   (38) https://github.com/python/cpython/issues/91803

   (39) https://bugs.python.org/issue?@action=redirect&bpo=38523

   (40) https://bugs.python.org/issue?@action=redirect&bpo=40358

   (41) https://bugs.python.org/issue?@action=redirect&bpo=36267


File: python.info,  Node: Documentation<16>,  Next: Tests<19>,  Prev: Library<21>,  Up: Python 3 12 0 alpha 2

1.23.22.4 Documentation
.......................

   - gh-98832(1): Changes wording of docstring for *note
     pathlib.Path.iterdir(): 1595.

   - gh-97966(2): Update uname docs to clarify the special nature of the
     platform attribute and to indicate when it became late-bound.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98832

   (2) https://github.com/python/cpython/issues/97966


File: python.info,  Node: Tests<19>,  Next: Build<21>,  Prev: Documentation<16>,  Up: Python 3 12 0 alpha 2

1.23.22.5 Tests
...............

   - gh-98903(1): The Python test suite now fails with exit code 4 if no
     tests ran.  It should help detecting typos in test names and test
     methods.

   - gh-98713(2): Fix a bug in the *note typing: ed. tests where a test
     relying on CPython-specific implementation details was not
     decorated with ‘@cpython_only’ and was not skipped on other
     implementations.

   - gh-87390(3): Add tests for star-unpacking with PEP 646, and some
     other miscellaneous PEP 646 tests.

   - gh-96853(4): Added explicit coverage of ‘Py_Initialize’ (and hence
     ‘Py_InitializeEx’) back to the embedding tests (all other embedding
     tests migrated to ‘Py_InitializeFromConfig’ in Python 3.11)

   - bpo-34272(5): Some C API tests were moved into the new
     Lib/test/test_capi/ directory.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98903

   (2) https://github.com/python/cpython/issues/98713

   (3) https://github.com/python/cpython/issues/87390

   (4) https://github.com/python/cpython/issues/96853

   (5) https://bugs.python.org/issue?@action=redirect&bpo=34272


File: python.info,  Node: Build<21>,  Next: Windows<18>,  Prev: Tests<19>,  Up: Python 3 12 0 alpha 2

1.23.22.6 Build
...............

   - gh-99086(1): Fix ‘-Wimplicit-int’ compiler warning in ‘configure’
     check for ‘PTHREAD_SCOPE_SYSTEM’.

   - gh-99016(2): Fix build with ‘PYTHON_FOR_REGEN=python3.8’.

   - gh-97731(3): Specify the full path to the source location for ‘make
     docclean’ (needed for cross-builds).

   - gh-98949(4): Drop unused build dependency on ‘readelf’.

   - gh-98989(5): Use ‘python3.11’, if available, for regeneration and
     freezing.

   - gh-98831(6): Add new tooling, in ‘Tools/cases_generator’, to
     generate the interpreter switch statement from a list of opcode
     definitions.  This only affects adding, modifying or removing
     instruction definitions.  The instruction definitions now live in
     ‘Python/bytecodes.c’, in the form of a custom DSL (under
     development)(7).  The tooling reads this file and writes
     ‘Python/generated_cases.c.h’, which is then included by
     ‘Python/ceval.c’ to provide most of the cases of the main
     interpreter switch.

   - gh-98817(8): Remove PCbuild/lib.pyproj: it's not used for anything,
     is only a minor convenience for Visual Studio users (who probably
     mostly don't even know about it), and it takes a lot of maintenance
     effort to keep updated.

   - gh-98776(9): Fix ‘make regen-test-levenshtein’ for out-of-tree
     builds.

   - gh-98707(10): Don't use vendored ‘libmpdec’ headers if *note
     -with-system-libmpdec: 3eb. is passed to ‘configure’.  Don't use
     vendored ‘libexpat’ headers if *note -with-system-expat: 171d. is
     passed to ‘configure’.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/99086

   (2) https://github.com/python/cpython/issues/99016

   (3) https://github.com/python/cpython/issues/97731

   (4) https://github.com/python/cpython/issues/98949

   (5) https://github.com/python/cpython/issues/98989

   (6) https://github.com/python/cpython/issues/98831

   (7) 
https://github.com/faster-cpython/ideas/blob/main/3.12/interpreter_definition.md

   (8) https://github.com/python/cpython/issues/98817

   (9) https://github.com/python/cpython/issues/98776

   (10) https://github.com/python/cpython/issues/98707


File: python.info,  Node: Windows<18>,  Next: macOS<14>,  Prev: Build<21>,  Up: Python 3 12 0 alpha 2

1.23.22.7 Windows
.................

   - gh-98689(1): Update Windows builds to zlib v1.2.13.  v1.2.12 has
     CVE 2022-37434(2), but the vulnerable ‘inflateGetHeader’ API is not
     used by Python.

   - gh-98790(3): Assumes that a missing ‘DLLs’ directory means that
     standard extension modules are in the executable's directory.

   - gh-98745(4): Update ‘py.exe’ launcher to install 3.11 by default
     and 3.12 on request.

   - gh-98692(5): Fix the *note Windows の Python ランチャ: 588.
     ignoring unrecognized shebang lines instead of treating them as
     local paths

   - gh-94328(6): Update Windows installer to use SQLite 3.39.4.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98689

   (2) https://www.cve.org/CVERecord?id=CVE-2022-37434

   (3) https://github.com/python/cpython/issues/98790

   (4) https://github.com/python/cpython/issues/98745

   (5) https://github.com/python/cpython/issues/98692

   (6) https://github.com/python/cpython/issues/94328


File: python.info,  Node: macOS<14>,  Next: C API<20>,  Prev: Windows<18>,  Up: Python 3 12 0 alpha 2

1.23.22.8 macOS
...............

   - gh-94328(1): Update macOS installer to SQLite 3.39.4.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/94328


File: python.info,  Node: C API<20>,  Prev: macOS<14>,  Up: Python 3 12 0 alpha 2

1.23.22.9 C API
...............

   - gh-98724(1): The *note Py_CLEAR: 544, *note Py_SETREF: 545. and
     *note Py_XSETREF: 546. macros now only evaluate their argument
     once.  If the argument has side effects, these side effects are no
     longer duplicated.  Patch by Victor Stinner.

   - gh-98978(2): Fix use-after-free in ‘Py_SetPythonHome(NULL)’,
     ‘Py_SetProgramName(NULL)’ and ‘_Py_SetProgramFullPath(NULL)’
     function calls.  Issue reported by Benedikt Reinartz.  Patch by
     Victor Stinner.

   - gh-98410(3): Add ‘getbufferproc’ and ‘releasebufferproc’ to the
     stable API.

   - gh-98610(4): Some configurable capabilities of sub-interpreters
     have changed.  They always allow subprocesses (*note subprocess:
     c1.) now, whereas before subprocesses could be optionally
     disallowed for a sub-interpreter.  Instead ‘os.exec()’ can now be
     disallowed.  Disallowing daemon threads is now supported.
     Disallowing all threads is still allowed, but is never done by
     default.  Note that the optional restrictions are only available
     through ‘_Py_NewInterpreterFromConfig()’, which isn't a public API.
     They do not affect the main interpreter, nor *note
     Py_NewInterpreter(): 1721.

   - gh-98608(5): A ‘_PyInterpreterConfig’ has been added and
     ‘_Py_NewInterpreter()’ has been renamed to
     ‘_Py_NewInterpreterFromConfig()’.  The "isolated_subinterpreters"
     argument is now a granular config that captures the previous
     behavior.  Note that this is all "private" API.

   - gh-96853(6): ‘Py_InitializeEx’ now correctly calls ‘PyConfig_Clear’
     after initializing the interpreter (the omission didn't cause a
     memory leak only because none of the dynamically allocated config
     fields are populated by the wrapper function)

   - gh-91248(7): Add *note PyFrame_GetVar(): 534. and *note
     PyFrame_GetVarString(): 535. functions to get a frame variable by
     its name.  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98724

   (2) https://github.com/python/cpython/issues/98978

   (3) https://github.com/python/cpython/issues/98410

   (4) https://github.com/python/cpython/issues/98610

   (5) https://github.com/python/cpython/issues/98608

   (6) https://github.com/python/cpython/issues/96853

   (7) https://github.com/python/cpython/issues/91248


File: python.info,  Node: Python 3 12 0 alpha 1,  Next: Python 3 11 0 beta 1,  Prev: Python 3 12 0 alpha 2,  Up: 変更履歴

1.23.23 Python 3.12.0 alpha 1
-----------------------------

'Release date: 2022-10-25'

* Menu:

* Security: Security<15>.
* Core and Builtins: Core and Builtins<23>.
* Library: Library<22>.
* Documentation: Documentation<17>.
* Tests: Tests<20>.
* Build: Build<22>.
* Windows: Windows<19>.
* macOS: macOS<15>.
* IDLE: IDLE<15>.
* Tools/Demos: Tools/Demos<11>.
* C API: C API<21>.


File: python.info,  Node: Security<15>,  Next: Core and Builtins<23>,  Up: Python 3 12 0 alpha 1

1.23.23.1 Security
..................

   - gh-97616(1): Fix multiplying a list by an integer (‘list *= int’):
     detect the integer overflow when the new allocated length is close
     to the maximum size.  Issue reported by Jordan Limor.  Patch by
     Victor Stinner.

   - gh-97514(2): On Linux the *note multiprocessing: 86. module returns
     to using filesystem backed unix domain sockets for communication
     with the 'forkserver' process instead of the Linux abstract socket
     namespace.  Only code that chooses to use the *note "forkserver"
     start method: 2a9. is affected.

     Abstract sockets have no permissions and could allow any user on
     the system in the same network namespace(3) (often the whole
     system) to inject code into the multiprocessing 'forkserver'
     process.  This was a potential privilege escalation.  Filesystem
     based socket permissions restrict this to the 'forkserver' process
     user as was the default in Python 3.8 and earlier.

     This prevents Linux CVE 2022-42919(4).

   - gh-87389(5): *note http.server: 68.: Fix an open redirection
     vulnerability in the HTTP server when an URI path starts with ‘//’.
     Vulnerability discovered, and initial fix proposed, by Hamza Avvan.

   - gh-79096(6): LWPCookieJar and MozillaCookieJar create files with
     file mode 600 instead of 644 (Microsoft Windows is not affected)

   - gh-92888(7): Fix ‘memoryview’ use after free when accessing the
     backing buffer in certain cases.

   - gh-68966(8): The deprecated mailcap module now refuses to inject
     unsafe text (filenames, MIME types, parameters) into shell
     commands.  Instead of using such text, it will warn and act as if a
     match was not found (or for test commands, as if the test failed).

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97616

   (2) https://github.com/python/cpython/issues/97514

   (3) https://man7.org/linux/man-pages/man7/network_namespaces.7.html

   (4) https://www.cve.org/CVERecord?id=CVE-2022-42919

   (5) https://github.com/python/cpython/issues/87389

   (6) https://github.com/python/cpython/issues/79096

   (7) https://github.com/python/cpython/issues/92888

   (8) https://github.com/python/cpython/issues/68966


File: python.info,  Node: Core and Builtins<23>,  Next: Library<22>,  Prev: Security<15>,  Up: Python 3 12 0 alpha 1

1.23.23.2 Core and Builtins
...........................

   - gh-98374(1): Suppress ImportError for invalid query for help()
     command.  Patch by Donghee Na.

   - gh-98461(2): Fix source location in bytecode for list, set and dict
     comprehensions as well as generator expressions.

   - gh-98354(3): Added unicode check for ‘name’ attribute of ‘spec’
     argument passed in ‘_imp.create_builtin()’ function.

   - gh-98398(4): Fix source location of 'assert' bytecodes.

   - gh-98390(5): Fix location of sub-expressions of boolean
     expressions, by reducing their scope to that of the sub-expression.

   - gh-98254(6): Modules from the standard library are now potentially
     suggested as part of the error messages displayed by the
     interpreter when an *note NameError: 40b. is raised to the top
     level.  Patch by Pablo Galindo

   - gh-97997(7): Add running column offset to the tokenizer state to
     avoid calculating AST column information with pointer arithmetic.

   - gh-97973(8): Modify the tokenizer to return all necessary
     information the parser needs to set location information in the AST
     nodes, so that the parser does not have to calculate those doing
     pointer arithmetic.

   - gh-96078(9): *note os.sched_yield(): 10e4. now release the GIL
     while calling sched_yield(2).  Patch by Donghee Na.

   - gh-97955(10): Migrate *note zoneinfo: 11a. to Argument Clinic.

   - gh-97912(11): The compiler now avoids quadratic behavior when
     finding which instructions should use the *note LOAD_FAST_CHECK:
     4b2. opcode.

   - gh-97002(12): Fix an issue where several frame objects could be
     backed by the same interpreter frame, possibly leading to corrupted
     memory and hard crashes of the interpreter.

   - gh-97943(13): Bugfix: *note PyFunction_GetAnnotations(): 1725.
     should return a borrowed reference.  It was returning a new
     reference.

   - gh-97922(14): The Garbage Collector now runs only on the eval
     breaker mechanism of the Python bytecode evaluation loop instead on
     object allocations.  The GC can also run when *note
     PyErr_CheckSignals(): 433. is called so C extensions that need to
     run for a long time without executing any Python code also have a
     chance to execute the GC periodically.

   - gh-65961(15): When ‘__package__’ is different than
     ‘__spec__.parent’, raise a ‘DeprecationWarning’ instead of
     ‘ImportWarning’.

     Also remove ‘importlib.util.set_package()’ which was scheduled for
     removal.

   - gh-97850(16): Long deprecated, ‘module_repr()’ should now be
     completely eradicated.

   - gh-86298(17): In cases where ‘warnings.warn_explicit()’ consults
     the module's loader, an ‘DeprecationWarning’ is issued when
     ‘m.__loader__’ differs from ‘m.__spec__.loader’.

   - gh-97779(18): Ensure that all Python frame objects are backed by
     "complete" frames.

   - gh-91052(19): Add API for subscribing to modification events on
     selected dictionaries.

   - gh-97752(20): Fix possible data corruption or crashes when
     accessing the ‘f_back’ member of newly-created generator or
     coroutine frames.

   - gh-97591(21): Fixed a missing incref/decref pair in
     ‘Exception.__setstate__()’.  Patch by Ofey Chan.

   - gh-97670(22): Remove the ‘sys.getdxp()’ function and the
     ‘Tools/scripts/analyze_dxp.py’ script.  DXP stands for "dynamic
     execution pairs".  They were related to ‘DYNAMIC_EXECUTION_PROFILE’
     and ‘DXPAIRS’ macros which have been removed in Python 3.11.
     Python can now be built with *note ./configure -enable-pystats:
     1726. to gather statistics on Python opcodes.  Patch by Victor
     Stinner.

   - gh-94526(23): Fix the Python path configuration used to initialized
     *note sys.path: 38e. at Python startup.  Paths are no longer
     encoded to UTF-8/strict to avoid encoding errors if it contains
     surrogate characters (bytes paths are decoded with the
     surrogateescape error handler).  Patch by Victor Stinner.

   - gh-96670(24): The parser now raises *note SyntaxError: 172. when
     parsing source code containing null bytes.  Patch by Pablo Galindo

   - gh-96975(25): Fix a crash occurring when *note PyEval_GetFrame():
     1727. is called while the topmost Python frame is in a
     partially-initialized state.

   - gh-96848(26): Fix command line parsing: reject *note -X
     int_max_str_digits: 15c. option with no value (invalid) when the
     *note PYTHONINTMAXSTRDIGITS: 1728. environment variable is set to a
     valid limit.  Patch by Victor Stinner.

   - gh-95921(27): Fix overly-broad source position information for
     chained comparisons used as branching conditions.

   - gh-96821(28): Fix undefined behaviour in ‘audioop.c’.

   - gh-96821(29): Fix undefined behaviour in ‘_testcapimodule.c’.

   - gh-95778(30): When *note ValueError: 1e3. is raised if an integer
     is larger than the limit, mention the *note
     sys.set_int_max_str_digits(): 1729. function in the error message.
     Patch by Victor Stinner.

   - gh-96387(31): At Python exit, sometimes a thread holding the GIL
     can wait forever for a thread (usually a daemon thread) which
     requested to drop the GIL, whereas the thread already exited.  To
     fix the race condition, the thread which requested the GIL drop now
     resets its request before exiting.  Issue discovered and analyzed
     by Mingliang ZHAO. Patch by Victor Stinner.

   - gh-96864(32): Fix a possible assertion failure, fatal error, or
     *note SystemError: 541. if a line tracing event raises an exception
     while opcode tracing is enabled.

   - gh-95778(33): The ‘PyLong_FromString’ function was refactored to
     make it more maintainable and extensible.

   - gh-96678(34): Fix undefined behaviour in C code of null pointer
     arithmetic.

   - gh-96754(35): Make sure that all frame objects created are created
     from valid interpreter frames.  Prevents the possibility of invalid
     frames in backtraces and signal handlers.

   - gh-90997(36): Improve the performance of reading and writing inline
     bytecode caches on some platforms.

   - gh-96751(37): Remove dead code from ‘CALL_FUNCTION_EX’ opcode.

   - gh-90751(38): *note memoryview: 435. now supports half-floats.
     Patch by Donghee Na and Antoine Pitrou.

   - gh-96678(39): Fix case of undefined behavior in ceval.c

   - gh-64373(40): Convert ‘_functools’ to argument clinic.

   - gh-96641(41): Do not expose ‘KeyWrapper’ in ‘_functools’.

   - gh-96636(42): Ensure that tracing, ‘sys.setrace()’, is turned on
     immediately.  In pre-release versions of 3.11, some tracing events
     might have been lost when turning on tracing in a ‘__del__’ method
     or interrupt.

   - gh-96572(43): Fix use after free in trace refs build mode.  Patch
     by Kumar Aditya.

   - gh-96611(44): When loading a file with invalid UTF-8 inside a
     multi-line string, a correct SyntaxError is emitted.

   - gh-96612(45): Make sure that incomplete frames do not show up in
     tracemalloc traces.

   - gh-90230(46): Fix compiler warnings and test failures when building
     with ‘--enable-pystats’.

   - gh-96587(47): Correctly raise ‘SyntaxError’ on exception groups (
     PEP 654(48)) on python versions prior to 3.11

   - gh-96569(49): Remove two cases of undefined behavior, by adding
     NULL checks.

   - gh-96582(50): Fix possible ‘NULL’ pointer dereference in
     ‘_PyThread_CurrentFrames’.  Patch by Kumar Aditya.

   - gh-91079(51): Separate Python recursion checking from C recursion
     checking which reduces the chance of C stack overflow and allows
     the recursion limit to be increased safely.

   - gh-93911(52): Fix an issue that could prevent *note LOAD_ATTR: 4ab.
     from specializing properly when accessing properties.

   - gh-96348(53): Emit a DeprecationWarning when *note throw(): 4c5,
     *note throw(): 4c4. or *note athrow(): 4c6. are called with more
     than one argument.

   - gh-95196(54): Disable incorrect pickling of the C implemented
     classmethod descriptors.

   - gh-96364(55): Fix text signatures of ‘list.__getitem__’ and
     ‘dict.__getitem__’.

   - gh-96352(56): Fix *note AttributeError: 326. missing ‘name’ and
     ‘obj’ attributes in *note object.__getattribute__(): ba0.  Patch by
     Philip Georgi.

   - gh-93554(57): Change the jump opcodes so that all conditional jumps
     are forward jumps.  Backward jumps are converted by the assembler
     into a conditional forward jump whose target is the fallthrough
     block (and with a reversed condition), followed by an unconditional
     backward jump.  For example:

     ‘POP_JUMP_IF_TRUE BACKWARD_TARGET’ becomes ‘POP_JUMP_IF_FALSE
     NEXT_BLOCK; JUMP BACKWARD_TARGET’.

     All the directed conditional jump opcodes were removed:
     ‘POP_JUMP_FORWARD_IF_TRUE’, ‘POP_JUMP_BACKWARD_IF_TRUE’,
     ‘POP_JUMP_FORWARD_IF_FALSE’, ‘POP_JUMP_BACKWARD_IF_FALSE’,
     ‘POP_JUMP_FORWARD_IF_NONE’, ‘POP_JUMP_BACKWARD_IF_NONE’,
     ‘POP_JUMP_FORWARD_IF_NOT_NONE’, ‘POP_JUMP_BACKWARD_IF_NOT_NONE’.

     The corresponding opcodes without direction are no longer
     pseudo-instructions, and they implement the forward conditional
     jumps.

   - gh-96268(58): Loading a file with invalid UTF-8 will now report the
     broken character at the correct location.

   - gh-96237(59): The internal field ‘_PyInterpreterFrame.f_func’ is
     renamed to ‘_PyInterpreterFrame.f_funcobj’ and may be any object.
     The ‘f_globals’ and ‘f_builtin’ fields may hold junk values.

     It is safest to treat the ‘_PyInterpreterFrame’ struct as opaque.

   - gh-96187(60): Fixed a bug that caused ‘_PyCode_GetExtra’ to return
     garbage for negative indexes.  Patch by Pablo Galindo

   - gh-96143(61): Add a new ‘-X perf’ Python command line option as
     well as *note sys.activate_stack_trampoline(): 43c. and *note
     sys.deactivate_stack_trampoline(): 43d. function in the *note sys:
     c3. module that allows to set/unset the interpreter in a way that
     the Linux ‘perf’ profiler can detect Python calls.  The new *note
     sys.is_stack_trampoline_active(): 43e. function allows to query the
     state of the perf trampoline.  Design by Pablo Galindo.  Patch by
     Pablo Galindo and Christian Heimes with contributions from Gregory
     P. Smith [Google] and Mark Shannon.

   - gh-96071(62): Fix a deadlock in *note PyGILState_Ensure(): 385.
     when allocating new thread state.  Patch by Kumar Aditya.

   - gh-96046(63): *note PyType_Ready(): 747. now initializes
     ‘ht_cached_keys’ and performs additional checks to ensure that type
     objects are properly configured.  This avoids crashes in 3rd party
     packages that don't use regular API to create new types.

   - gh-96005(64): On WASI *note ENOTCAPABLE: 172a. is now mapped to
     *note PermissionError: d10.  The *note errno: 4d. modules exposes
     the new error number.  ‘getpath.py’ now ignores *note
     PermissionError: d10. when it cannot open landmark files
     ‘pybuilddir.txt’ and ‘pyenv.cfg’.

   - gh-93678(65): Added test a harness for direct unit tests of the
     compiler's optimization stage.  The
     ‘_testinternalcapi.optimize_cfg()’ function runs the optimiser on a
     sequence of instructions.  The ‘CfgOptimizationTestCase’ class in
     ‘test.support’ has utilities for invoking the optimizer and
     checking the output.

   - gh-95245(66): Reduces the size of a "simple" Python object from 8
     to 6 words by moving the weakreflist pointer into the pre-header
     directly before the object's dict/values pointer.

   - gh-90997(67): Compile virtual *note try: 6b4./*note except: 170.
     blocks to handle exceptions raised during *note close(): 1659. or
     *note throw(): 4c5. calls through a suspended frame.

   - gh-95977(68): Optimized calling *note __get__(): 1490. with
     vectorcall.  Patch by Kumar Aditya.

   - gh-91210(69): Improve error message when a parameter without a
     default value follows one with a default value, and show the same
     message, even when the non-default/default sequence is preceded by
     positional-only parameters.

   - gh-95922(70): Fixed bug where the compiler's
     ‘eliminate_empty_basic_blocks’ function ignores the last block of
     the code unit.

   - gh-95818(71): Skip over incomplete frames in *note
     PyThreadState_GetFrame(): 759.

   - gh-95876(72): Fix format string in
     ‘_PyPegen_raise_error_known_location’ that can lead to memory
     corruption on some 64bit systems.  The function was building a
     tuple with ‘i’ (int) instead of ‘n’ (Py_ssize_t) for Py_ssize_t
     arguments.

   - gh-95605(73): Fix misleading contents of error message when
     converting an all-whitespace string to *note float: 2ce.

   - gh-95150(74): Update code object hashing and equality to consider
     all debugging and exception handling tables.  This fixes an issue
     where certain non-identical code objects could be "deduplicated"
     during compilation.

   - gh-91146(75): Reduce allocation size of *note list: 5dc. from *note
     str.split(): e73. and *note str.rsplit(): 1227.  Patch by Donghee
     Na and Inada Naoki.

   - gh-87092(76): Create a 'jump target label' abstraction in the
     compiler so that the compiler's codegen stage does not work
     directly with basic blocks.  This prepares the code for changes to
     the underlying CFG generation mechanism.

   - gh-95355(77): ‘_PyPegen_Parser_New’ now properly detects token
     memory allocation errors.  Patch by Honglin Zhu.

   - gh-90081(78): Run Python code in tracer/profiler function at full
     speed.  Fixes slowdown in earlier versions of 3.11.

   - gh-95324(79): Emit a warning in debug mode if an object does not
     call *note PyObject_GC_UnTrack(): 14b0. before deallocation.  Patch
     by Pablo Galindo.

   - gh-95245(80): Merge managed dict and values pointer into a single
     tagged pointer to save one word in the pre-header.

   - gh-93678(81): Add cfg_builder struct and refactor the relevant code
     so that a cfg can be constructed without an instance of the
     compiler struct.

   - gh-95185(82): Prevented crashes in the AST constructor when
     compiling some absurdly long expressions like ‘"+0"*1000000’.
     *note RecursionError: d39. is now raised instead.  Patch by Pablo
     Galindo

   - gh-93351(83): *note ast.AST: 18b. node positions are now validated
     when provided to *note compile(): 177. and other related functions.
     If invalid positions are detected, a *note ValueError: 1e3. will be
     raised.

   - gh-94438(84): Fix an issue that caused extended opcode arguments
     and some conditional pops to be ignored when calculating valid jump
     targets for assignments to the ‘f_lineno’ attribute of frame
     objects.  In some cases, this could cause inconsistent internal
     state, resulting in a hard crash of the interpreter.

   - gh-95060(85): Undocumented ‘PyCode_Addr2Location’ function now
     properly returns when ‘addrq’ argument is less than zero.

   - gh-95113(86): Replace all ‘EXTENDED_ARG_QUICK’ instructions with
     basic *note EXTENDED_ARG: 1710. instructions in unquickened code.
     Consumers of non-adaptive bytecode should be able to handle
     extended arguments the same way they were handled in CPython 3.10
     and older.

   - gh-91409(87): Fix incorrect source location info caused by certain
     optimizations in the bytecode compiler.

   - gh-95023(88): Implement *note os.setns(): 172b. and *note
     os.unshare(): 172c. for Linux.  Patch by Noam Cohen.

   - gh-94036(89): Fix incorrect source location info for some
     multi-line attribute accesses and method calls.

   - gh-94938(90): Fix error detection in some builtin functions when
     keyword argument name is an instance of a str subclass with
     overloaded ‘__eq__’ and ‘__hash__’.  Previously it could cause
     SystemError or other undesired behavior.

   - gh-94996(91): *note ast.parse(): 18d. will no longer parse function
     definitions with positional-only params when passed
     ‘feature_version’ less than ‘(3, 8)’.  Patch by Shantanu Jain.

   - gh-94739(92): Allow jumping within, out of, and across exception
     handlers in the debugger.

   - gh-94949(93): *note ast.parse(): 18d. will no longer parse
     parenthesized context managers when passed ‘feature_version’ less
     than ‘(3, 9)’.  Patch by Shantanu Jain.

   - gh-94947(94): *note ast.parse(): 18d. will no longer parse
     assignment expressions when passed ‘feature_version’ less than ‘(3,
     8)’.  Patch by Shantanu Jain.

   - gh-91256(95): Ensures the program name is known for help text
     during interpreter startup.

   - gh-94869(96): Fix the column offsets for some expressions in
     multi-line f-strings *note ast: 7. nodes.  Patch by Pablo Galindo.

   - gh-94893(97): Fix an issue where frame object manipulations could
     corrupt inline bytecode caches.

   - gh-94822(98): Fix an issue where lookups of metaclass descriptors
     may be ignored when an identically-named attribute also exists on
     the class itself.

   - gh-91153(99): Fix an issue where a *note bytearray: 508. item
     assignment could crash if it's resized by the new value's
     ‘__index__()’ method.

   - gh-90699(100): Fix reference counting bug in ‘bool.__repr__()’.
     Patch by Kumar Aditya.

   - gh-94694(101): Fix an issue that could cause code with multi-line
     method lookups to have misleading or incorrect column offset
     information.  In some cases (when compiling a hand-built AST) this
     could have resulted in a hard crash of the interpreter.

   - gh-93252(102): Fix an issue that caused internal frames to outlive
     failed Python function calls, possibly resulting in memory leaks or
     hard interpreter crashes.

   - gh-94215(103): Fix an issue where exceptions raised by line-tracing
     events would cause frames to be left in an invalid state, possibly
     resulting in a hard crash of the interpreter.

   - gh-92228(104): Disable the compiler's inline-small-exit-blocks
     optimization for exit blocks that are associated with source code
     lines.  This fixes a bug where the debugger cannot tell where an
     exception handler ends and the following code block begins.

   - gh-94485(105): Line number of a module's ‘RESUME’ instruction is
     set to 0 as specified in PEP 626(106).

   - gh-94438(107): Account for instructions that can push NULL to the
     stack when setting line number in a frame.  Prevents some
     (unlikely) crashes.

   - gh-91719(108): Reload ‘opcode’ when raising ‘unknown opcode error’
     in the interpreter main loop, for C compilers to generate
     dispatching code independently.

   - gh-94329(109): Compile and run code with unpacking of extremely
     large sequences (1000s of elements).  Such code failed to compile.
     It now compiles and runs correctly.

   - gh-94360(110): Fixed a tokenizer crash when reading encoded files
     with syntax errors from ‘stdin’ with non utf-8 encoded text.  Patch
     by Pablo Galindo

   - gh-88116(111): Fix an issue when reading line numbers from code
     objects if the encoded line numbers are close to ‘INT_MIN’.  Patch
     by Pablo Galindo

   - gh-94262(112): Don't create frame objects for incomplete frames.
     Prevents the creation of generators and closures from being
     observable to Python and C extensions, restoring the behavior of
     3.10 and earlier.

   - gh-94192(113): Fix error for dictionary literals with invalid
     expression as value.

   - gh-87995(114): *note types.MappingProxyType: 43a. instances are now
     hashable if the underlying mapping is hashable.

   - gh-93883(115): Revise the display strategy of traceback enhanced
     error locations.  The indicators are only shown when the location
     doesn't span the whole line.

   - gh-94163(116): Add *note BINARY_SLICE: 4ac. and *note STORE_SLICE:
     4ad. instructions for more efficient handling and better
     specialization of slicing operations, where the slice is explicit
     in the source code.

   - gh-94021(117): Fix unreachable code warning in
     ‘Python/specialize.c’.

   - gh-93911(118): Specialize ‘LOAD_ATTR’ for objects with custom
     ‘__getattribute__’.

   - gh-93955(119): Improve performance of attribute lookups on objects
     with custom ‘__getattribute__’ and ‘__getattr__’.  Patch by Ken
     Jin.

   - gh-93911(120): Specialize ‘LOAD_ATTR’ for ‘property()’ attributes.

   - gh-93678(121): Refactor compiler optimisation code so that it no
     longer needs the ‘struct assembler’ and ‘struct compiler’ passed
     around.  Instead, each function takes the CFG and other data that
     it actually needs.  This will make it possible to test this code
     directly.

   - gh-93841(122): When built with ‘-enable-pystats’,
     ‘sys._stats_on()’, ‘sys._stats_off()’, ‘sys._stats_clear()’ and
     ‘sys._stats_dump()’ functions have been added to enable gathering
     stats for parts of programs.

   - gh-93516(123): Store offset of first traceable instruction in code
     object to avoid having to recompute it for each instruction when
     tracing.

   - gh-93516(124): Lazily create a table mapping bytecode offsets to
     line numbers to speed up calculation of line numbers when tracing.

   - gh-89828(125): *note types.GenericAlias: 7b6. no longer relays the
     ‘__class__’ attribute.  For example, ‘isinstance(list[int], type)’
     no longer returns ‘True’.

   - gh-93678(126): Refactor the compiler to reduce boilerplate and
     repetition.

   - gh-93671(127): Fix some exponential backtrace case happening with
     deeply nested sequence patterns in match statements.  Patch by
     Pablo Galindo

   - gh-93662(128): Make sure that the end column offsets are correct in
     multi-line method calls.  Previously, the end column could precede
     the column offset.

   - gh-93461(129): *note importlib.invalidate_caches(): bde. now drops
     entries from *note sys.path_importer_cache: 5ae. with a relative
     path as name.  This solves a caching issue when a process changes
     its current working directory.

     ‘FileFinder’ no longer inserts a dot in the path, e.g.
     ‘/egg/./spam’ is now ‘/egg/spam’.

   - gh-93621(130): Change order of bytecode instructions emitted for
     *note with: 59c. and *note async with: 59f. to reduce the number of
     entries in the exception table.

   - gh-93533(131): Reduce the size of the inline cache for
     ‘LOAD_METHOD’ by 2 bytes.

   - gh-93444(132): Removed redundant fields from the compiler's
     basicblock struct: ‘b_nofallthrough’, ‘b_exit’, ‘b_return’.  They
     can be easily calculated from the opcode of the last instruction of
     the block.

   - gh-93429(133): ‘LOAD_METHOD’ instruction has been removed.  It was
     merged back into ‘LOAD_ATTR’.

   - gh-93418(134): Fixed an assert where an f-string has an equal sign
     '=' following an expression, but there's no trailing brace.  For
     example, f"{i=".

   - gh-93382(135): Cache the result of *note PyCode_GetCode(): 743.
     function to restore the 'O'(1) lookup of the ‘co_code’ attribute.

   - gh-93359(136): Ensure that custom *note ast: 7. nodes without
     explicit end positions can be compiled.  Patch by Pablo Galindo.

   - gh-93356(137): Code for exception handlers is emitted at the end of
     the code unit's bytecode.  This avoids one jump when no exception
     is raised.

   - gh-93354(138): Use exponential backoff for specialization counters
     in the interpreter.  Can reduce the number of failed
     specializations significantly and avoid slowdown for those parts of
     a program that are not suitable for specialization.

   - gh-93283(139): Improve error message for invalid syntax of
     conversion character in f-string expressions.

   - gh-93345(140): Fix a crash in substitution of a ‘TypeVar’ in nested
     generic alias after ‘TypeVarTuple’.

   - gh-93223(141): When a bytecode instruction jumps to an
     unconditional jump instruction, the first instruction can often be
     optimized to target the unconditional jump's target directly.  For
     tracing reasons, this would previously only occur if both
     instructions have the same line number.  This also now occurs if
     the unconditional jump is artificial, i.e., if it has no associated
     line number.

   - gh-84694(142): The ‘--experimental-isolated-subinterpreters’
     configure option and ‘EXPERIMENTAL_ISOLATED_SUBINTERPRETERS’ macro
     have been removed.

   - gh-91924(143): Fix ‘__lltrace__’ debug feature if the stdout
     encoding is not UTF-8.  Patch by Victor Stinner.

   - gh-93040(144): Wraps unused parameters in ‘Objects/obmalloc.c’ with
     ‘Py_UNUSED’.

   - gh-93143(145): Avoid ‘NULL’ checks for uninitialized local
     variables by determining at compile time which variables must be
     initialized.

   - gh-93061(146): Backward jumps after ‘async for’ loops are no longer
     given dubious line numbers.

   - gh-93065(147): Fix contextvars HAMT implementation to handle
     iteration over deep trees.

     The bug was discovered and fixed by Eli Libman.  See
     MagicStack/immutables#84(148) for more details.

   - gh-93012(149): Added the new function *note PyType_FromMetaclass():
     51b, which generalizes the existing *note
     PyType_FromModuleAndSpec(): 51c. using an additional metaclass
     argument.  This is useful for language binding tools, where it can
     be used to intercept type-related operations like subclassing or
     static attribute access by specifying a metaclass with custom
     slots.

     Importantly, *note PyType_FromMetaclass(): 51b. is available in the
     Limited API, which provides a path towards migrating more binding
     tools onto the Stable ABI.

   - gh-93021(150): Fix the ‘__text_signature__’ for ‘__get__()’ methods
     implemented in C. Patch by Jelle Zijlstra.

   - gh-89914(151): The operand of the ‘YIELD_VALUE’ instruction is set
     to the stack depth.  This is done to help frame handling on ‘yield’
     and may assist debuggers.

   - gh-92955(152): Fix memory leak in code object's lines and positions
     iterators as they were not finalized at exit.  Patch by Kumar
     Aditya.

   - gh-92930(153): Fixed a crash in ‘_pickle.c’ from mutating
     collections during ‘__reduce__’ or ‘persistent_id’.

   - gh-90690(154): The PRECALL instruction has been removed.  It
     offered only a small advantage for specialization and is not needed
     in the vast majority of cases.

   - gh-92914(155): Always round the allocated size for lists up to the
     nearest even number.

   - gh-92858(156): Improve error message for some suites with syntax
     error before ':'

   - gh-90473(157): Decrease default recursion limit on WASI to address
     limited call stack size.

   - gh-92804(158): Fix memory leak in ‘memoryview’ iterator as it was
     not finalized at exit.  Patch by Kumar Aditya.

   - gh-92777(159): Specialize ‘LOAD_METHOD’ for objects with lazy
     dictionaries.  Patch by Ken Jin.

   - gh-92658(160): Add support for connecting and binding to Hyper-V
     sockets on Windows Hyper-V hosts and guests.

   - gh-92236(161): Remove spurious "LINE" event when starting a
     generator or coroutine, visible tracing functions implemented in C.

   - gh-91102(162): ‘_warnings.warn_explicit()’ is ported to Argument
     Clinic.

   - gh-92619(163): Make the compiler duplicate an exit block only if
     none of its instructions have a lineno (previously only the first
     instruction in the block was checked, leading to unnecessarily
     duplicated blocks).

   - gh-88750(164): The deprecated debug build only ‘PYTHONTHREADDEBUG’
     environment variable no longer does anything.

   - gh-92261(165): Fix hang when trying to iterate over a
     ‘typing.Union’.

   - gh-91432(166): Specialized the *note FOR_ITER: 16bc. opcode using
     the PEP 659 machinery

   - gh-91399(167): Removed duplicate '{0, 0, 0, 0, 0, 0}' entry in
     'Objects/unicodetype_db.h'.

   - gh-91578(168): Updates the error message for abstract class.

   - bpo-47091(169): Improve performance of repetition of *note list:
     5dc. and *note tuple: 349. by using ‘memcpy’ to copy data and
     performing the reference increments in one step.

   - bpo-46142(170): Make ‘--help’ output shorter by moving some info to
     the new ‘--help-env’ and ‘--help-xoptions’ command-line options.
     Also add ‘--help-all’ option to print complete usage.

   - bpo-42316(171): Document some places where an assignment expression
     needs parentheses.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98374

   (2) https://github.com/python/cpython/issues/98461

   (3) https://github.com/python/cpython/issues/98354

   (4) https://github.com/python/cpython/issues/98398

   (5) https://github.com/python/cpython/issues/98390

   (6) https://github.com/python/cpython/issues/98254

   (7) https://github.com/python/cpython/issues/97997

   (8) https://github.com/python/cpython/issues/97973

   (9) https://github.com/python/cpython/issues/96078

   (10) https://github.com/python/cpython/issues/97955

   (11) https://github.com/python/cpython/issues/97912

   (12) https://github.com/python/cpython/issues/97002

   (13) https://github.com/python/cpython/issues/97943

   (14) https://github.com/python/cpython/issues/97922

   (15) https://github.com/python/cpython/issues/65961

   (16) https://github.com/python/cpython/issues/97850

   (17) https://github.com/python/cpython/issues/86298

   (18) https://github.com/python/cpython/issues/97779

   (19) https://github.com/python/cpython/issues/91052

   (20) https://github.com/python/cpython/issues/97752

   (21) https://github.com/python/cpython/issues/97591

   (22) https://github.com/python/cpython/issues/97670

   (23) https://github.com/python/cpython/issues/94526

   (24) https://github.com/python/cpython/issues/96670

   (25) https://github.com/python/cpython/issues/96975

   (26) https://github.com/python/cpython/issues/96848

   (27) https://github.com/python/cpython/issues/95921

   (28) https://github.com/python/cpython/issues/96821

   (29) https://github.com/python/cpython/issues/96821

   (30) https://github.com/python/cpython/issues/95778

   (31) https://github.com/python/cpython/issues/96387

   (32) https://github.com/python/cpython/issues/96864

   (33) https://github.com/python/cpython/issues/95778

   (34) https://github.com/python/cpython/issues/96678

   (35) https://github.com/python/cpython/issues/96754

   (36) https://github.com/python/cpython/issues/90997

   (37) https://github.com/python/cpython/issues/96751

   (38) https://github.com/python/cpython/issues/90751

   (39) https://github.com/python/cpython/issues/96678

   (40) https://github.com/python/cpython/issues/64373

   (41) https://github.com/python/cpython/issues/96641

   (42) https://github.com/python/cpython/issues/96636

   (43) https://github.com/python/cpython/issues/96572

   (44) https://github.com/python/cpython/issues/96611

   (45) https://github.com/python/cpython/issues/96612

   (46) https://github.com/python/cpython/issues/90230

   (47) https://github.com/python/cpython/issues/96587

   (48) https://peps.python.org/pep-0654/

   (49) https://github.com/python/cpython/issues/96569

   (50) https://github.com/python/cpython/issues/96582

   (51) https://github.com/python/cpython/issues/91079

   (52) https://github.com/python/cpython/issues/93911

   (53) https://github.com/python/cpython/issues/96348

   (54) https://github.com/python/cpython/issues/95196

   (55) https://github.com/python/cpython/issues/96364

   (56) https://github.com/python/cpython/issues/96352

   (57) https://github.com/python/cpython/issues/93554

   (58) https://github.com/python/cpython/issues/96268

   (59) https://github.com/python/cpython/issues/96237

   (60) https://github.com/python/cpython/issues/96187

   (61) https://github.com/python/cpython/issues/96143

   (62) https://github.com/python/cpython/issues/96071

   (63) https://github.com/python/cpython/issues/96046

   (64) https://github.com/python/cpython/issues/96005

   (65) https://github.com/python/cpython/issues/93678

   (66) https://github.com/python/cpython/issues/95245

   (67) https://github.com/python/cpython/issues/90997

   (68) https://github.com/python/cpython/issues/95977

   (69) https://github.com/python/cpython/issues/91210

   (70) https://github.com/python/cpython/issues/95922

   (71) https://github.com/python/cpython/issues/95818

   (72) https://github.com/python/cpython/issues/95876

   (73) https://github.com/python/cpython/issues/95605

   (74) https://github.com/python/cpython/issues/95150

   (75) https://github.com/python/cpython/issues/91146

   (76) https://github.com/python/cpython/issues/87092

   (77) https://github.com/python/cpython/issues/95355

   (78) https://github.com/python/cpython/issues/90081

   (79) https://github.com/python/cpython/issues/95324

   (80) https://github.com/python/cpython/issues/95245

   (81) https://github.com/python/cpython/issues/93678

   (82) https://github.com/python/cpython/issues/95185

   (83) https://github.com/python/cpython/issues/93351

   (84) https://github.com/python/cpython/issues/94438

   (85) https://github.com/python/cpython/issues/95060

   (86) https://github.com/python/cpython/issues/95113

   (87) https://github.com/python/cpython/issues/91409

   (88) https://github.com/python/cpython/issues/95023

   (89) https://github.com/python/cpython/issues/94036

   (90) https://github.com/python/cpython/issues/94938

   (91) https://github.com/python/cpython/issues/94996

   (92) https://github.com/python/cpython/issues/94739

   (93) https://github.com/python/cpython/issues/94949

   (94) https://github.com/python/cpython/issues/94947

   (95) https://github.com/python/cpython/issues/91256

   (96) https://github.com/python/cpython/issues/94869

   (97) https://github.com/python/cpython/issues/94893

   (98) https://github.com/python/cpython/issues/94822

   (99) https://github.com/python/cpython/issues/91153

   (100) https://github.com/python/cpython/issues/90699

   (101) https://github.com/python/cpython/issues/94694

   (102) https://github.com/python/cpython/issues/93252

   (103) https://github.com/python/cpython/issues/94215

   (104) https://github.com/python/cpython/issues/92228

   (105) https://github.com/python/cpython/issues/94485

   (106) https://peps.python.org/pep-0626/

   (107) https://github.com/python/cpython/issues/94438

   (108) https://github.com/python/cpython/issues/91719

   (109) https://github.com/python/cpython/issues/94329

   (110) https://github.com/python/cpython/issues/94360

   (111) https://github.com/python/cpython/issues/88116

   (112) https://github.com/python/cpython/issues/94262

   (113) https://github.com/python/cpython/issues/94192

   (114) https://github.com/python/cpython/issues/87995

   (115) https://github.com/python/cpython/issues/93883

   (116) https://github.com/python/cpython/issues/94163

   (117) https://github.com/python/cpython/issues/94021

   (118) https://github.com/python/cpython/issues/93911

   (119) https://github.com/python/cpython/issues/93955

   (120) https://github.com/python/cpython/issues/93911

   (121) https://github.com/python/cpython/issues/93678

   (122) https://github.com/python/cpython/issues/93841

   (123) https://github.com/python/cpython/issues/93516

   (124) https://github.com/python/cpython/issues/93516

   (125) https://github.com/python/cpython/issues/89828

   (126) https://github.com/python/cpython/issues/93678

   (127) https://github.com/python/cpython/issues/93671

   (128) https://github.com/python/cpython/issues/93662

   (129) https://github.com/python/cpython/issues/93461

   (130) https://github.com/python/cpython/issues/93621

   (131) https://github.com/python/cpython/issues/93533

   (132) https://github.com/python/cpython/issues/93444

   (133) https://github.com/python/cpython/issues/93429

   (134) https://github.com/python/cpython/issues/93418

   (135) https://github.com/python/cpython/issues/93382

   (136) https://github.com/python/cpython/issues/93359

   (137) https://github.com/python/cpython/issues/93356

   (138) https://github.com/python/cpython/issues/93354

   (139) https://github.com/python/cpython/issues/93283

   (140) https://github.com/python/cpython/issues/93345

   (141) https://github.com/python/cpython/issues/93223

   (142) https://github.com/python/cpython/issues/84694

   (143) https://github.com/python/cpython/issues/91924

   (144) https://github.com/python/cpython/issues/93040

   (145) https://github.com/python/cpython/issues/93143

   (146) https://github.com/python/cpython/issues/93061

   (147) https://github.com/python/cpython/issues/93065

   (148) https://github.com/MagicStack/immutables/issues/84

   (149) https://github.com/python/cpython/issues/93012

   (150) https://github.com/python/cpython/issues/93021

   (151) https://github.com/python/cpython/issues/89914

   (152) https://github.com/python/cpython/issues/92955

   (153) https://github.com/python/cpython/issues/92930

   (154) https://github.com/python/cpython/issues/90690

   (155) https://github.com/python/cpython/issues/92914

   (156) https://github.com/python/cpython/issues/92858

   (157) https://github.com/python/cpython/issues/90473

   (158) https://github.com/python/cpython/issues/92804

   (159) https://github.com/python/cpython/issues/92777

   (160) https://github.com/python/cpython/issues/92658

   (161) https://github.com/python/cpython/issues/92236

   (162) https://github.com/python/cpython/issues/91102

   (163) https://github.com/python/cpython/issues/92619

   (164) https://github.com/python/cpython/issues/88750

   (165) https://github.com/python/cpython/issues/92261

   (166) https://github.com/python/cpython/issues/91432

   (167) https://github.com/python/cpython/issues/91399

   (168) https://github.com/python/cpython/issues/91578

   (169) https://bugs.python.org/issue?@action=redirect&bpo=47091

   (170) https://bugs.python.org/issue?@action=redirect&bpo=46142

   (171) https://bugs.python.org/issue?@action=redirect&bpo=42316


File: python.info,  Node: Library<22>,  Next: Documentation<17>,  Prev: Core and Builtins<23>,  Up: Python 3 12 0 alpha 1

1.23.23.3 Library
.................

   - gh-89237(1): Fix hang on Windows in ‘subprocess.wait_closed()’ in
     *note asyncio: 8. with *note ProactorEventLoop: 5d4.  Patch by
     Kumar Aditya.

   - gh-97928(2): ‘tkinter.Text.count()’ raises now an exception for
     options starting with "-" instead of silently ignoring them.

   - gh-98393(3): The *note os: 91. module no longer accepts bytes-like
     paths, like *note bytearray: 508. and *note memoryview: 435. types:
     only the exact *note bytes: 1a4. type is accepted for bytes
     strings.  Patch by Victor Stinner.

   - gh-98363(4): Added itertools.batched() to batch data into lists of
     a given length with the last list possibly being shorter than the
     others.

   - gh-98331(5): Update the bundled copies of pip and setuptools to
     versions 22.3 and 65.5.0 respectively.

   - gh-98307(6): A *note createSocket(): 627. method was added to *note
     SysLogHandler: 628.

   - gh-96035(7): Fix bug in *note urllib.parse.urlparse(): 2e5. that
     causes certain port numbers containing whitespace, underscores,
     plus and minus signs, or non-ASCII digits to be incorrectly
     accepted.

   - gh-98257(8): Make *note sys.setprofile(): 14a8. and *note
     sys.settrace(): 14a9. functions reentrant.  They can no long fail
     with: ‘RuntimeError("Cannot install a trace function while another
     trace function is being installed")’.  Patch by Victor Stinner.

   - gh-98251(9): Allow *note venv: f9. to pass along ‘PYTHON*’
     variables to ‘ensurepip’ and ‘pip’ when they do not impact path
     resolution

   - gh-94597(10): Deprecated *note
     asyncio.AbstractEventLoopPolicy.get_child_watcher(): 2a1. and *note
     asyncio.AbstractEventLoopPolicy.set_child_watcher(): 2a0. methods
     to be removed in Python 3.14.  Patch by Kumar Aditya.

   - gh-98178(11): On macOS, fix a crash in *note syslog.syslog(): 50b.
     in multi-threaded applications.  On macOS, the libc ‘syslog()’
     function is not thread-safe, so *note syslog.syslog(): 50b. no
     longer releases the GIL to call it.  Patch by Victor Stinner.

   - gh-44098(12): Release the GIL when creating *note mmap.mmap: 1ec.
     objects on Unix.

   - gh-87730(13): Wrap network errors consistently in urllib FTP
     support, so the test suite doesn't fail when a network is available
     but the public internet is not reachable.

   - gh-94597(14): The child watcher classes *note
     MultiLoopChildWatcher: 29a, *note FastChildWatcher: 29b. and *note
     SafeChildWatcher: 29d. are deprecated and will be removed in Python
     3.14.  Patch by Kumar Aditya.

   - gh-98023(15): Change default child watcher to *note
     PidfdChildWatcher: 446. on Linux systems which supports it.  Patch
     by Kumar Aditya.

   - gh-90985(16): Earlier in 3.11 we deprecated
     ‘asyncio.Task.cancel("message")’.  We realized we were too harsh,
     and have undeprecated it.

   - gh-65961(17): Do not rely solely on ‘__cached__’ on modules; code
     will also support ‘__spec__.cached’.

   - gh-97646(18): Replace deprecated ‘application/javascript’ with
     ‘text/javascript’ in *note mimetypes: 82.  See RFC 9239(19).  Patch
     by Noam Cohen.

   - gh-97930(20): Apply changes from importlib_resources 5.8 and 5.9:
     ‘Traversable.joinpath’ provides a concrete implementation.
     ‘as_file’ now supports directories of resources.

   - gh-97850(21): Remove deprecated ‘importlib.util.set_loader()’ and
     ‘importlib.util.module_for_loader()’ from *note importlib.util: 71.

   - gh-97837(22): Change deprecate warning message in *note unittest:
     ef. from

     ‘It is deprecated to return a value!=None’

     to

     ‘It is deprecated to return a value that is not None from a test
     case’

   - gh-97825(23): Fixes *note AttributeError: 326. when *note
     subprocess.check_output(): f8e. is used with argument ‘input=None’
     and either of the arguments 'encoding' or 'errors' are used.

   - gh-97008(24): *note NameError: 40b. and *note AttributeError: 326.
     spelling suggestions provided since gh-82711(25) are now also
     emitted by the pure Python *note traceback: e7. module.  Tests for
     those suggestions now exercise both implementations to ensure they
     are equivalent.  Patch by Carl Friedrich Bolz-Tereick and Łukasz
     Langa.

   - gh-97799(26): ‘dataclass’ now uses *note inspect.get_annotations():
     7de. to examine the annotations on class objects.

   - gh-97781(27): Removed deprecated interfaces in ‘importlib.metadata’
     (entry points accessed as dictionary, implicit dictionary
     construction of sequence of ‘EntryPoint’ objects, mutablility of
     ‘EntryPoints’ result, access of entry point by index).
     ‘entry_points’ now has a simpler, more straightforward API
     (returning ‘EntryPoints’).

   - gh-96827(28): Avoid spurious tracebacks from *note asyncio: 8. when
     default executor cleanup is delayed until after the event loop is
     closed (e.g.  as the result of a keyboard interrupt).

   - gh-95534(29): ‘gzip.GzipFile.read()’ reads 10% faster.

   - gh-97592(30): Avoid a crash in the C version of *note
     asyncio.Future.remove_done_callback(): 150b. when an evil argument
     is passed.

   - gh-97639(31): Remove ‘tokenize.NL’ check from *note tabnanny: c7.

   - gh-97545(32): Make Semaphore run faster.

   - gh-73588(33): Fix generation of the default name of
     ‘tkinter.Checkbutton’.  Previously, checkbuttons in different
     parent widgets could have the same short name and share the same
     state if arguments "name" and "variable" are not specified.  Now
     they are globally unique.

   - gh-96865(34): fix Flag to use boundary CONFORM

     This restores previous Flag behavior of allowing flags with
     non-sequential values to be combined; e.g.

     class Skip(Flag): TWO = 2 EIGHT = 8

     Skip.TWO | Skip.EIGHT -> <Skip.TWO|EIGHT: 10>

   - gh-97005(35): Update bundled libexpat to 2.4.9

   - gh-85760(36): Fix race condition in *note asyncio: 8. where *note
     process_exited(): 172e. called before the *note
     pipe_data_received(): 172f. leading to inconsistent output.  Patch
     by Kumar Aditya.

   - gh-96704(37): Pass the correct ‘contextvars.Context’ when a
     ‘asyncio’ exception handler is called on behalf of a task or
     callback handle.  This adds a new ‘Task’ method, ‘get_context’, and
     also a new ‘Handle’ method with the same name.  If this method is
     not found on a task object (perhaps because it is a third-party
     library that does not yet provide this method), the context
     prevailing at the time the exception handler is called is used.

   - gh-96819(38): Fixed check in ‘multiprocessing.resource_tracker’
     that guarantees that the length of a write to a pipe is not greater
     than ‘PIPE_BUF’.

   - gh-95865(39): Reduce *note urllib.parse.quote_from_bytes(): 1730.
     memory use on large values.

     Contributed by Dennis Sweeney.

   - gh-96741(40): Corrected type annotation for dataclass attribute
     ‘pstats.FunctionProfile.ncalls’ to be ‘str’.

   - gh-96734(41): Update *note unicodedata: ee. database to Unicode
     15.0.0.

   - gh-96735(42): Fix undefined behaviour in *note struct.unpack():
     1731.

   - gh-46412(43): Improve performance of ‘bool(db)’ for large ndb/gdb
     databases.  Previously this would call ‘len(db)’ which would
     iterate over all keys - the answer (empty or not) is known after
     the first key.

   - gh-96652(44): Fix the faulthandler implementation of
     ‘faulthandler.register(signal, chain=True)’ if the ‘sigaction()’
     function is not available: don't call the previous signal handler
     if it's NULL. Patch by Victor Stinner.

   - gh-68163(45): Correct conversion of *note numbers.Rational: 1290.'s
     to *note float: 2ce.

   - gh-96538(46): Speed up ‘bisect.bisect()’ functions by taking
     advantage of type-stability.

   - gh-96465(47): Fraction hashes are now cached.

   - gh-96079(48): In *note typing: ed, fix missing field ‘name’ and
     incorrect ‘__module__’ in _AnnotatedAlias.

   - gh-96415(49): Remove ‘types._cell_factory’ from module namespace.

   - gh-95987(50): Fix ‘repr’ of ‘Any’ subclasses.

   - gh-96388(51): Work around missing socket functions in *note socket:
     d6e.'s ‘__repr__’.

   - gh-96385(52): Fix ‘TypeVarTuple.__typing_prepare_subst__’.
     ‘TypeError’ was not raised when using more than one ‘TypeVarTuple’,
     like ‘[*T, *V]’ in type alias substitutions.

   - gh-96142(53): Add ‘match_args’, ‘kw_only’, ‘slots’, and
     ‘weakref_slot’ to ‘_DataclassParams’.

   - gh-96073(54): In *note inspect: 72, fix overeager replacement of
     "‘typing.’" in formatting annotations.

   - gh-89258(55): Added a *note getChildren(): 1732. method to *note
     logging.Logger: b1d, to get the immediate child loggers of a
     logger.

   - gh-96346(56): Use double caching for compiled RE patterns.

   - gh-96349(57): Fixed a minor performance regression in
     ‘threading.Event.__init__()’

   - gh-90467(58): Fix ‘asyncio.streams.StreamReaderProtocol’ to keep a
     strong reference to the created task, so that it's not garbage
     collected

   - gh-96172(59): Fix a bug in ‘unicodedata’: ‘east_asian_width’ used
     to return the wrong value for unassigned characters; and for yet
     unassigned, but reserved characters.

   - gh-96159(60): Fix a performance regression in logging
     TimedRotatingFileHandler.  Only check for special files when the
     rollover time has passed.

   - gh-96175(61): Fix unused ‘localName’ parameter in the ‘Attr’ class
     in *note xml.dom.minidom: 109.

   - gh-96145(62): Add AttrDict to JSON module for use with object_hook.

   - gh-96052(63): Fix handling compiler warnings (SyntaxWarning and
     DeprecationWarning) in *note codeop.compile_command(): 1733. when
     checking for incomplete input.  Previously it emitted warnings and
     raised a SyntaxError.  Now it always returns ‘None’ for incomplete
     input without emitting any warnings.

   - gh-96125(64): Fix incorrect condition that causes
     ‘sys.thread_info.name’ to be wrong on pthread platforms.

   - gh-96019(65): Fix a bug in the ‘makeunicodedata.py’ script leading
     to about 13 KiB of space saving in the ‘unicodedata’ module,
     specifically the character decomposition data.

   - gh-95463(66): Remove an incompatible change from bpo-28080(67) that
     caused a regression that ignored the utf8 in ‘ZipInfo.flag_bits’.
     Patch by Pablo Galindo.

   - gh-69142(68): Add ‘%:z’ strftime format code (generates tzoffset
     with colons as separator), see *note strftime() と strptime()
     の振る舞い: 1734.

   - gh-95899(69): Fix *note asyncio.Runner: 5cb. to call *note
     asyncio.set_event_loop(): 1735. only once to avoid calling *note
     attach_loop(): 1736. multiple times on child watchers.  Patch by
     Kumar Aditya.

   - gh-95736(70): Fix *note unittest.IsolatedAsyncioTestCase: 2e4. to
     set event loop before calling setup functions.  Patch by Kumar
     Aditya.

   - gh-95865(71): Speed up *note urllib.parse.quote_from_bytes(): 1730.
     by replacing a list comprehension with ‘map()’.

   - gh-95861(72): Add support for computing Spearman's correlation
     coefficient to the existing statistics.correlation() function.

   - gh-95804(73): Fix ‘logging’ shutdown handler so it respects
     ‘MemoryHandler.flushOnClose’.

   - gh-95704(74): When a task catches *note asyncio.CancelledError:
     19d. and raises some other error, the other error should generally
     not silently be suppressed.

   - gh-95149(75): The *note HTTPStatus: 8ce. enum offers a couple of
     properties to indicate the HTTP status category e.g.
     ‘HTTPStatus.OK.is_success’.

   - gh-95609(76): Update bundled pip to 22.2.2.

   - gh-95289(77): Fix *note asyncio.TaskGroup: 19a. to propagate
     exception when *note asyncio.CancelledError: 19d. was replaced with
     another exception by a context manager.  Patch by Kumar Aditya and
     Guido van Rossum.

   - gh-94909(78): Fix incorrect joining of relative Windows paths with
     drives in *note pathlib.PurePath: 473. initializer.

   - gh-95385(79): Faster ‘json.dumps()’ when sorting of keys is not
     requested (default).

   - gh-83901(80): Improve *note Signature.bind: 157d. error message for
     missing keyword-only arguments.

   - gh-95339(81): Update bundled pip to 22.2.1.

   - gh-95045(82): Fix GC crash when deallocating ‘_lsprof.Profiler’ by
     untracking it before calling any callbacks.  Patch by Kumar Aditya.

   - gh-95231(83): Fail gracefully if *note EPERM: 1737. or *note
     ENOSYS: 1738. is raised when loading ‘crypt’ methods.  This may
     happen when trying to load ‘MD5’ on a Linux kernel with FIPS
     (Federal Information Processing Standard) enabled.

   - gh-95097(84): Fix *note asyncio.run(): 449. for *note asyncio.Task:
     4a5. implementations without *note uncancel(): 1a0. method.  Patch
     by Kumar Aditya.

   - gh-95087(85): Fix IndexError in parsing invalid date in the *note
     email: 32. module.

   - gh-95199(86): Upgrade bundled setuptools to 63.2.0.

   - gh-95194(87): Upgrade bundled pip to 22.2.

   - gh-93899(88): Fix check for existence of *note os.EFD_CLOEXEC:
     1739, *note os.EFD_NONBLOCK: 173a. and *note os.EFD_SEMAPHORE:
     173b. flags on older kernel versions where these flags are not
     present.  Patch by Kumar Aditya.

   - gh-95166(89): Fix *note concurrent.futures.Executor.map(): db1. to
     cancel the currently waiting on future on an error - e.g.
     TimeoutError or KeyboardInterrupt.

   - gh-95132(90): Fix a *note sqlite3: ba. regression where ‘*args’ and
     ‘**kwds’ were incorrectly relayed from *note connect(): 288. to the
     *note Connection: 226. factory.  The regression was introduced in
     3.11a1 with PR 24421 (gh-85128(91)).  Patch by Erlend E. Aasland.

   - gh-93157(92): Fix *note fileinput: 51. module didn't support
     ‘errors’ option when ‘inplace’ is true.

   - gh-91212(93): Fixed flickering of the turtle window when the tracer
     is turned off.  Patch by Shin-myoung-serp.

   - gh-95077(94): Add deprecation warning for enum ‘member.member’
     access (e.g.  ‘Color.RED.BLUE’).  Remove ‘EnumMeta.__getattr__’.

   - gh-95109(95): Ensure that timeouts scheduled with *note
     asyncio.Timeout: 1630. that have already expired are delivered
     promptly.

   - gh-95105(96): ‘wsgiref.types.InputStream.__iter__()’ should return
     ‘Iterator[bytes]’, not ‘Iterable[bytes]’.  Patch by Shantanu Jain.

   - gh-95066(97): Replaced assert with exception in *note ast.parse():
     18d, when ‘feature_version’ has an invalid major version.  Patch by
     Shantanu Jain.

   - gh-77617(98): Add *note sqlite3: ba. *note command-line interface:
     40d.  Patch by Erlend Aasland.

   - gh-95005(99): Replace _PyAccu with _PyUnicodeWriter in JSON encoder
     and StringIO and remove the _PyAccu implementation.

   - gh-90085(100): Remove ‘-c/--clock’ and ‘-t/--time’ CLI options of
     *note timeit: d8.  The options had been deprecated since Python 3.3
     and the functionality was removed in Python 3.7.  Patch by Shantanu
     Jain.

   - gh-94857(101): Fix refleak in ‘_io.TextIOWrapper.reconfigure’.
     Patch by Kumar Aditya.

   - gh-94821(102): Fix binding of unix socket to empty address on Linux
     to use an available address from the abstract namespace, instead of
     "0".

   - gh-94736(103): Fix crash when deallocating an instance of a
     subclass of ‘_multiprocessing.SemLock’.  Patch by Kumar Aditya.

   - gh-81620(104): Add random.binomialvariate().

   - gh-74116(105): Allow *note asyncio.StreamWriter.drain(): 1719. to
     be awaited concurrently by multiple tasks.  Patch by Kumar Aditya.

   - gh-87822(106): When called with ‘capture_locals=True’, the *note
     traceback: e7. module functions swallow exceptions raised from
     calls to ‘repr()’ on local variables of frames.  This is in order
     to prioritize the original exception over rendering errors.  An
     indication of the failure is printed in place of the missing value.
     (Patch by Simon-Martin Schroeder).

   - gh-88050(107): Fix *note asyncio: 8. subprocess transport to kill
     process cleanly when process is blocked and avoid ‘RuntimeError’
     when loop is closed.  Patch by Kumar Aditya.

   - gh-94637(108): ‘SSLContext.set_default_verify_paths()’ now releases
     the GIL around ‘SSL_CTX_set_default_verify_paths’ call.  The
     function call performs I/O and CPU intensive work.

   - gh-94309(109): Deprecate aliases *note typing.Hashable: 4c0. and
     *note typing.Sized: 4c1.

   - gh-92546(110): An undocumented ‘python -m pprint’ benchmark is
     moved into ‘pprint’ suite of pyperformance.  Patch by Oleg Iarygin.

   - gh-94607(111): Fix subclassing complex generics with type variables
     in *note typing: ed.  Previously an error message saying ‘Some type
     variables ... are not listed in Generic[...]’ was shown.  *note
     typing: ed. no longer populates ‘__parameters__’ with the
     ‘__parameters__’ of a Python class.

   - gh-94619(112): Remove the long-deprecated ‘module_repr()’ from
     *note importlib: 6b.

   - gh-93910(113): The ability to access the other values of an enum on
     an enum (e.g.  ‘Color.RED.BLUE’) has been restored in order to fix
     a performance regression.

   - gh-93896(114): Fix *note asyncio.run(): 449. and *note
     unittest.IsolatedAsyncioTestCase: 2e4. to always the set event loop
     as it was done in Python 3.10 and earlier.  Patch by Kumar Aditya.

   - gh-94343(115): Allow setting the attributes of ‘reprlib.Repr’
     during object initialization

   - gh-94382(116): Port static types of ‘_multiprocessing’ module to
     heap types.  Patch by Kumar Aditya.

   - gh-78724(117): Fix crash in *note struct.Struct: 1615. when it was
     not completely initialized by initializing it in *note __new__():
     54c.  Patch by Kumar Aditya.

   - gh-94510(118): Re-entrant calls to *note sys.setprofile(): 14a8.
     and *note sys.settrace(): 14a9. now raise *note RuntimeError: 17a.
     Patch by Pablo Galindo.

   - gh-92336(119): Fix bug where *note linecache.getline(): df0. fails
     on bad files with *note UnicodeDecodeError: 9e1. or *note
     SyntaxError: 172.  It now returns an empty string as per the
     documentation.

   - gh-94398(120): Once a *note asyncio.TaskGroup: 19a. has started
     shutting down (i.e., at least one task has failed and the task
     group has started cancelling the remaining tasks), it should not be
     possible to add new tasks to the task group.

   - gh-94383(121): ‘xml.etree’: Remove the ‘ElementTree.Element.copy()’
     method of the pure Python implementation, deprecated in Python
     3.10, use the *note copy.copy(): 4fd. function instead.  The C
     implementation of ‘xml.etree’ has no ‘copy()’ method, only a
     ‘__copy__()’ method.  Patch by Victor Stinner.

   - gh-94379(122): *note zipimport: 118.: Remove ‘find_loader()’ and
     ‘find_module()’ methods, deprecated in Python 3.10: use the
     ‘find_spec()’ method instead.  See PEP 451(123) for the rationale.
     Patch by Victor Stinner.

   - gh-94352(124): *note shlex.split(): 506.: Passing ‘None’ for 's'
     argument now raises an exception, rather than reading *note
     sys.stdin: 507.  The feature was deprecated in Python 3.9.  Patch
     by Victor Stinner.

   - gh-94318(125): Strip trailing spaces in *note pydoc: a3. text
     output.

   - gh-89988(126): Fix memory leak in *note pickle.Pickler: 9ec. when
     looking up ‘dispatch_table’.  Patch by Kumar Aditya.

   - gh-90016(127): Deprecate *note sqlite3: ba. *note default adapters
     and converters: 4bc.  Patch by Erlend E. Aasland.

   - gh-94254(128): Fixed types of *note struct: c0. module to be
     immutable.  Patch by Kumar Aditya.

   - gh-93259(129): Now raise ‘ValueError’ when ‘None’ or an empty
     string are passed to ‘Distribution.from_name’ (and other callers).

   - gh-74696(130): *note shutil.make_archive(): 47f. now passes the
     'root_dir' argument to custom archivers which support it.

   - gh-94216(131): The *note dis: 30. module now has the opcodes for
     pseudo instructions (those which are used by the compiler during
     code generation but then removed or replaced by real opcodes before
     the final bytecode is emitted).

   - gh-93096(132): Removed undocumented ‘python -m codecs’.  Use
     ‘python -m unittest test.test_codecs.EncodedFileTest’ instead.

   - gh-94207(133): Made ‘_struct.Struct’ GC-tracked in order to fix a
     reference leak in the ‘_struct’ module.

   - gh-93096(134): Removed undocumented ‘-t’ argument of ‘python -m
     base64’.  Use ‘python -m unittest
     test.test_base64.LegacyBase64TestCase.test_encodebytes’ instead.

   - gh-94226(135): Remove the ‘locale.format()’ function, deprecated in
     Python 3.7: use *note locale.format_string(): 4e8. instead.  Patch
     by Victor Stinner.

   - gh-94199(136): Remove the ‘ssl.match_hostname()’ function.  The
     ‘ssl.match_hostname()’ was deprecated in Python 3.7.  OpenSSL
     performs hostname matching since Python 3.7, Python no longer uses
     the ‘ssl.match_hostname()’ function.  Patch by Victor Stinner.

   - gh-94214(137): Document the ‘context’ object used in the
     ‘venv.EnvBuilder’ class, and add the new environment's library path
     to it.

   - gh-94199(138): Remove the ‘ssl.wrap_socket()’ function, deprecated
     in Python 3.7: instead, create a *note ssl.SSLContext: 274. object
     and call its *note ssl.SSLContext.wrap_socket: 4ee. method.  Any
     package that still uses ‘ssl.wrap_socket()’ is broken and insecure.
     The function neither sends a SNI TLS extension nor validates server
     hostname.  Code is subject to CWE 295(139) Improper Certificate
     Validation.  Patch by Victor Stinner.

   - gh-94199(140): Remove the ‘ssl.RAND_pseudo_bytes()’ function,
     deprecated in Python 3.6: use *note os.urandom(): 4ec. or *note
     ssl.RAND_bytes(): 4ed. instead.  Patch by Victor Stinner.

   - gh-94199(141): *note hashlib: 5e.: Remove the pure Python
     implementation of *note hashlib.pbkdf2_hmac(): 4d9, deprecated in
     Python 3.10.  Python 3.10 and newer requires OpenSSL 1.1.1 ( PEP
     644(142)): this OpenSSL version provides a C implementation of
     *note pbkdf2_hmac(): 4d9. which is faster.  Patch by Victor
     Stinner.

   - gh-94196(143): *note gzip: 5d.: Remove the ‘filename’ attribute of
     *note gzip.GzipFile: 3f3, deprecated since Python 2.6, use the
     *note name: 4d7. attribute instead.  In write mode, the ‘filename’
     attribute added ‘'.gz'’ file extension if it was not present.
     Patch by Victor Stinner.

   - gh-94182(144): run the *note asyncio.PidfdChildWatcher: 446. on the
     running loop, this allows event loops to run subprocesses when
     there is no default event loop running on the main thread

   - gh-94169(145): Remove ‘io.OpenWrapper’ and ‘_pyio.OpenWrapper’,
     deprecated in Python 3.10: just use *note open(): 4e5. instead.
     The *note open(): 4e5. (*note io.open(): 4e6.) function is a
     built-in function.  Since Python 3.10, ‘_pyio.open()’ is also a
     static method.  Patch by Victor Stinner.

   - gh-91742(146): Fix *note pdb: 94. crash after jump caused by a null
     pointer dereference.  Patch by Kumar Aditya.

   - gh-94101(147): Manual instantiation of *note ssl.SSLSession: cab.
     objects is no longer allowed as it lead to misconfigured instances
     that crashed the interpreter when attributes where accessed on
     them.

   - gh-84753(148): *note inspect.iscoroutinefunction(): 2c5, *note
     inspect.isgeneratorfunction(): 173c, and *note
     inspect.isasyncgenfunction(): 173d. now properly return ‘True’ for
     duck-typed function-like objects like instances of *note
     unittest.mock.AsyncMock: a19.

     This makes *note inspect.iscoroutinefunction(): 2c5. consistent
     with the behavior of ‘asyncio.iscoroutinefunction()’.  Patch by
     Mehdi ABAAKOUK.

   - gh-94028(149): Fix a regression in the *note sqlite3: ba. where
     statement objects were not properly cleared and reset after use in
     cursor iters.  The regression was introduced by PR 27884 in Python
     3.11a1.  Patch by Erlend E. Aasland.

   - gh-93973(150): Add keyword argument ‘all_errors’ to
     ‘asyncio.create_connection’ so that multiple connection errors can
     be raised as an ‘ExceptionGroup’.

   - gh-93963(151): Officially deprecate from ‘importlib.abc’ classes
     moved to ‘importlib.resources.abc’.

   - gh-93858(152): Prevent error when activating venv in nested fish
     instances.

   - gh-93820(153): Pickle *note enum.Flag: 5ef. by name.

   - gh-93847(154): Fix repr of enum of generic aliases.

   - gh-91404(155): Revert the *note re: a7. memory leak when a match is
     terminated by a signal or memory allocation failure as the
     implemented fix caused a major performance regression.

   - gh-83499(156): Fix double closing of file description in *note
     tempfile: c9.

   - gh-93820(157): Fixed a regression when *note copy.copy(): 4fd.-ing
     *note enum.Flag: 5ef. with multiple flag members.

   - gh-79512(158): Fixed names and ‘__module__’ value of *note weakref:
     fc. classes *note ReferenceType: 173e, *note ProxyType: 173f, *note
     CallableProxyType: 1740.  It makes them pickleable.

   - gh-91389(159): Fix an issue where *note dis: 30. utilities could
     report missing or incorrect position information in the presence of
     ‘CACHE’ entries.

   - gh-93626(160): Set ‘__future__.annotations’ to have a ‘None’
     mandatoryRelease to indicate that it is currently 'TBD'.

   - gh-90473(161): Emscripten and WASI have no home directory and
     cannot provide PEP 370(162) user site directory.

   - gh-90494(163): *note copy.copy(): 4fd. and *note copy.deepcopy():
     b3c. now always raise a TypeError if ‘__reduce__()’ returns a tuple
     with length 6 instead of silently ignore the 6th item or produce
     incorrect result.

   - gh-90549(164): Fix a multiprocessing bug where a global named
     resource (such as a semaphore) could leak when a child process is
     spawned (as opposed to forked).

   - gh-93521(165): Fixed a case where dataclasses would try to add
     ‘__weakref__’ into the ‘__slots__’ for a dataclass that specified
     ‘weakref_slot=True’ when it was already defined in one of its
     bases.  This resulted in a ‘TypeError’ upon the new class being
     created.

   - gh-79579(166): *note sqlite3: ba. now correctly detects DML queries
     with leading comments.  Patch by Erlend E. Aasland.

   - gh-93421(167): Update *note sqlite3.Cursor.rowcount: 1741. when a
     DML statement has run to completion.  This fixes the row count for
     SQL queries like ‘UPDATE ... RETURNING’.  Patch by Erlend E.
     Aasland.

   - gh-93475(168): Expose ‘FICLONE’ and ‘FICLONERANGE’ constants in
     *note fcntl: 4f.  Patch by Illia Volochii.

   - gh-93370(169): Deprecate *note sqlite3.version: 2b0. and *note
     sqlite3.version_info: 2b1.

   - gh-91810(170): Suppress writing an XML declaration in open files in
     ‘ElementTree.write()’ with ‘encoding='unicode'’ and
     ‘xml_declaration=None’.

   - gh-91162(171): Support splitting of unpacked arbitrary-length tuple
     over ‘TypeVar’ and ‘TypeVarTuple’ parameters.  For example:

        * ‘A[T, *Ts][*tuple[int, ...]]’ -> ‘A[int, *tuple[int, ...]]’

        * ‘A[*Ts, T][*tuple[int, ...]]’ -> ‘A[*tuple[int, ...], int]’

   - gh-93353(172): Fix the *note importlib.resources.as_file(): 45a.
     context manager to remove the temporary file if destroyed late
     during Python finalization: keep a local reference to the *note
     os.remove(): 10c1. function.  Patch by Victor Stinner.

   - gh-83658(173): Make ‘multiprocessing.Pool’ raise an exception if
     ‘maxtasksperchild’ is not ‘None’ or a positive int.

   - gh-93312(174): Add *note os.PIDFD_NONBLOCK: 467. flag to open a
     file descriptor for a process with *note os.pidfd_open(): 447. in
     non-blocking mode.  Patch by Kumar Aditya.

   - gh-88123(175): Implement ‘Enum.__contains__’ that returns ‘True’ or
     ‘False’ to replace the deprecated behaviour that would sometimes
     raise a *note TypeError: 502.

   - gh-93297(176): Make asyncio task groups prevent child tasks from
     being GCed

   - gh-85308(177): Changed *note argparse.ArgumentParser: 503. to use
     *note filesystem encoding and error handler: 505. instead of
     default text encoding to read arguments from file (e.g.
     ‘fromfile_prefix_chars’ option).  This change affects Windows;
     argument file should be encoded with UTF-8 instead of ANSI
     Codepage.

   - gh-93156(178): Accessing the *note pathlib.PurePath.parents: 7eb.
     sequence of an absolute path using negative index values produced
     incorrect results.

   - gh-93162(179): Add the ability for *note
     logging.config.dictConfig(): 1180. to usefully configure *note
     QueueHandler: 1742. and *note QueueListener: df9. as a pair, and
     add *note logging.getHandlerByName(): 1743. and *note
     logging.getHandlerNames(): 1663. APIs to allow access to handlers
     by name.

   - gh-93243(180): The ‘smtpd’ module was removed per the schedule in
     PEP 594(181).

   - gh-92886(182): Replace ‘assert’ statements with ‘raise
     AssertionError()’ in ‘BaseHandler’ so that the tested behaviour is
     maintained running with optimizations ‘(-O)’.

   - gh-90155(183): Fix broken *note asyncio.Semaphore: a42. when
     acquire is cancelled.

   - gh-90817(184): The ‘locale.resetlocale()’ function is deprecated
     and will be removed in Python 3.13.  Use
     ‘locale.setlocale(locale.LC_ALL, "")’ instead.  Patch by Victor
     Stinner.

   - gh-91513(185): Added ‘taskName’ attribute to *note logging: 7b.
     module for use with *note asyncio: 8. tasks.

   - gh-74696(186): *note shutil.make_archive(): 47f. no longer
     temporarily changes the current working directory during creation
     of standard ‘.zip’ or tar archives.

   - gh-92728(187): The ‘re.template()’ function and the corresponding
     ‘re.TEMPLATE’ and ‘re.T’ flags are restored after they were removed
     in 3.11.0b1, but they are now deprecated, so they might be removed
     from Python 3.13.

   - gh-93033(188): Search in some strings (platform dependent i.e
     [U+0xFFFF, U+0x0100] on Windows or [U+0xFFFFFFFF, U+0x00010000] on
     Linux 64-bit) are now up to 10 times faster.

   - gh-89973(189): Fix ‘re.error’ raised in *note fnmatch: 52. if the
     pattern contains a character range with upper bound lower than
     lower bound (e.g.  ‘[c-a]’).  Now such ranges are interpreted as
     empty ranges.

   - gh-93044(190): No longer convert the database argument of *note
     sqlite3.connect(): 288. to bytes before passing it to the factory.

   - gh-93010(191): In a very special case, the email package tried to
     append the nonexistent ‘InvalidHeaderError’ to the defect list.  It
     should have been ‘InvalidHeaderDefect’.

   - gh-92986(192): Fix *note ast.unparse(): 8b3. when
     ‘ImportFrom.level’ is ‘None’

   - gh-92932(193): Now *note dis(): b02. and *note get_instructions():
     1bd. handle operand values for instructions prefixed by
     ‘EXTENDED_ARG_QUICK’.  Patch by Sam Gross and Donghee Na.

   - gh-92675(194): Fix ‘venv.ensure_directories()’ to accept *note
     pathlib.Path: 20a. arguments in addition to *note str: 418. paths.
     Patch by David Foster.

   - gh-87901(195): Removed the ‘encoding’ argument from *note
     os.popen(): a55. that was added in 3.11b1.

   - gh-91922(196): Fix function ‘sqlite.connect()’ and the
     ‘sqlite.Connection’ constructor on non-UTF-8 locales.  Also, they
     now support bytes paths non-decodable with the current FS encoding.

   - gh-92869(197): Added *note c_time_t: 1744. to *note ctypes: 22,
     which has the same size as the ‘time_t’ type in C.

   - gh-92839(198): Fixed crash resulting from calling bisect.insort()
     or bisect.insort_left() with the key argument not equal to ‘None’.

   - gh-90473(199): *note subprocess: c1. now fails early on Emscripten
     and WASI platforms to work around missing *note os.pipe(): 1745. on
     WASI.

   - gh-89325(200): Removed many old deprecated *note unittest: ef.
     features: *note TestCase: 41a. method aliases, undocumented and
     broken *note TestCase: 41a. method ‘assertDictContainsSubset’,
     undocumented *note TestLoader.loadTestsFromModule: 26f. parameter
     'use_load_tests', and an underscored alias of the *note
     TextTestResult: 4fa. class.

   - gh-92734(201): Allow multi-element reprs emitted by *note reprlib:
     a9. to be pretty-printed using configurable indentation.

   - gh-92671(202): Fixed *note ast.unparse(): 8b3. for empty tuples in
     the assignment target context.

   - gh-91581(203): *note utcfromtimestamp(): 2d4. no longer attempts to
     resolve ‘fold’ in the pure Python implementation, since the fold is
     never 1 in UTC. In addition to being slightly faster in the common
     case, this also prevents some errors when the timestamp is close to
     *note datetime.min: 1746.  Patch by Paul Ganssle.

   - gh-86388(204): Removed randrange() functionality deprecated since
     Python 3.10.  Formerly, randrange(10.0) losslessly converted to
     randrange(10).  Now, it raises a TypeError.  Also, the exception
     raised for non-integral values such as randrange(10.5) or
     randrange('10') has been changed from ValueError to TypeError.

   - gh-90385(205): Add *note pathlib.Path.walk(): 475. as an
     alternative to *note os.walk(): 476.

   - gh-92550(206): Fix *note pathlib.Path.rglob(): 20f. for empty
     pattern.

   - gh-92591(207): Allow *note logging: 7b. filters to return a *note
     logging.LogRecord: fb3. instance so that filters attached to *note
     logging.Handler: 1439.s can enrich records without side effects on
     other handlers.

   - gh-92445(208): Fix a bug in *note argparse: 5. where ‘nargs="*"’
     would raise an error instead of returning an empty list when 0
     arguments were supplied if choice was also defined in
     ‘parser.add_argument’.

   - gh-92547(209): Remove undocumented *note sqlite3: ba. features
     deprecated in Python 3.10:

        * ‘sqlite3.enable_shared_cache()’

        * ‘sqlite3.OptimizedUnicode’

     Patch by Erlend E. Aasland.

   - gh-92530(210): Fix an issue that occurred after interrupting *note
     threading.Condition.notify(): 1747.

   - gh-92531(211): The statistics.median_grouped() function now always
     return a float.  Formerly, it did not convert the input type when
     for sequences of length one.

   - gh-84131(212): The *note pathlib.Path: 20a. deprecated method
     ‘link_to’ has been removed.  Use 3.10's *note hardlink_to(): 7ec.
     method instead as its semantics are consistent with that of *note
     symlink_to(): 7ed.

   - gh-89336(213): Removed *note configparser: 1b. module APIs: the
     ‘SafeConfigParser’ class alias, the ‘ParsingError.filename’
     property and parameter, and the ‘ConfigParser.readfp’ method, all
     of which were deprecated since Python 3.2.

   - gh-92391(214): Add *note __class_getitem__(): 706. to *note
     csv.DictReader: 9b3. and *note csv.DictWriter: 11cf, allowing them
     to be parameterized at runtime.  Patch by Marc Mueller.

   - gh-91968(215): Add ‘SO_RTABLE’ and ‘SO_USER_COOKIE’ constants to
     *note socket: b8.

   - gh-91810(216): *note ElementTree: 91c. method *note write(): fc2.
     and function *note tostring(): fc0. now use the text file's
     encoding ("UTF-8" if not available) instead of locale encoding in
     XML declaration when ‘encoding="unicode"’ is specified.

   - gh-81790(217): *note os.path.splitdrive(): bc2. now understands DOS
     device paths with UNC links (beginning ‘\\?\UNC\’).  Contributed by
     Barney Gale.

   - gh-91760(218): Apply more strict rules for numerical group
     references and group names in regular expressions.  Only sequence
     of ASCII digits is now accepted as a numerical reference.  The
     group name in bytes patterns and replacement strings can now only
     contain ASCII letters and digits and underscore.

   - gh-90622(219): Worker processes for *note
     concurrent.futures.ProcessPoolExecutor: 8bc. are no longer spawned
     on demand (a feature added in 3.9) when the multiprocessing context
     start method is ‘"fork"’ as that can lead to deadlocks in the child
     processes due to a fork happening while threads are running.

   - gh-91577(220): Move imports in ‘SharedMemory’ methods to module
     level so that they can be executed late in python finalization.

   - gh-91581(221): Remove an unhandled error case in the C
     implementation of calls to *note datetime.fromtimestamp: 4ba. with
     no time zone (i.e.  getting a local time from an epoch timestamp).
     This should have no user-facing effect other than giving a possibly
     more accurate error message when called with timestamps that fall
     on 10000-01-01 in the local time.  Patch by Paul Ganssle.

   - gh-91539(222): Improve performance of
     ‘urllib.request.getproxies_environment’ when there are many
     environment variables

   - gh-91524(223): Speed up the regular expression substitution
     (functions *note re.sub(): 283. and *note re.subn(): 284. and
     corresponding *note re.Pattern: 1748. methods) for replacement
     strings containing group references by 2-3 times.

   - gh-91447(224): Fix findtext in the xml module to only give an empty
     string when the text attribute is set to ‘None’.

   - gh-91456(225): Deprecate current default auto() behavior: In 3.13
     the default will be for for auto() to always return the largest
     member value incremented by 1, and to raise if incompatible value
     types are used.

   - bpo-47231(226): Fixed an issue with inconsistent trailing slashes
     in tarfile longname directories.

   - bpo-39064(227): *note zipfile.ZipFile: 690. now raises *note
     zipfile.BadZipFile: 1749. instead of ‘ValueError’ when reading a
     corrupt zip file in which the central directory offset is negative.

   - bpo-41287(228): Fix handling of the ‘doc’ argument in subclasses of
     *note property(): 179.

   - gh-90005(229): *note ctypes: 22. dependency ‘libffi’ is now
     detected with ‘pkg-config’.

   - bpo-32547(230): The constructors for *note DictWriter: 11cf. and
     *note DictReader: 9b3. now coerce the ‘fieldnames’ argument to a
     *note list: 5dc. if it is an iterator.

   - bpo-35540(231): Fix *note dataclasses.asdict(): 168b. crash when
     *note collections.defaultdict: 118d. is present in the attributes.

   - bpo-47063(232): Add an index_pages parameter to support using
     non-default index page names.

   - bpo-47025(233): Drop support for *note bytes: 1a4. on *note
     sys.path: 38e.

   - bpo-46951(234): Order the contents of zipapp archives, to make
     builds more reproducible.

   - bpo-42777(235): Implement *note pathlib.Path.is_mount(): 9e5. for
     Windows paths.

   - bpo-46755(236): In ‘QueueHandler’, clear ‘stack_info’ from
     ‘LogRecord’ to prevent stack trace from being written twice.

   - bpo-45393(237): Fix the formatting for ‘await x’ and ‘not x’ in the
     operator precedence table when using the *note help(): 8a5. system.

   - bpo-46642(238): Improve error message when trying to subclass an
     instance of *note typing.TypeVar: 143, *note typing.ParamSpec: 144,
     *note typing.TypeVarTuple: 145, etc.  Based on patch by Gregory
     Beauregard.

   - bpo-46364(239): Restrict use of sockets instead of pipes for stdin
     of subprocesses created by *note asyncio: 8. to AIX platform only.

   - bpo-28249(240): Set *note doctest.DocTest.lineno: 174a. to ‘None’
     when an object does not have *note __doc__: 8f6.

   - bpo-46197(241): Fix *note ensurepip: 4b. environment isolation for
     subprocess running ‘pip’.

   - bpo-45924(242): Fix *note asyncio: 8. incorrect traceback when
     future's exception is raised multiple times.  Patch by Kumar
     Aditya.

   - bpo-45046(243): Add support of context managers in *note unittest:
     ef.: methods *note enterContext(): 685. and *note
     enterClassContext(): 686. of class *note TestCase: 41a, method
     *note enterAsyncContext(): 687. of class *note
     IsolatedAsyncioTestCase: 2e4. and function *note
     unittest.enterModuleContext(): 688.

   - bpo-44173(244): Enable fast seeking of uncompressed unencrypted
     ‘zipfile.ZipExtFile’

   - bpo-42627(245): Fix incorrect parsing of Windows registry proxy
     settings

   - bpo-42047(246): Add *note threading.get_native_id(): a0c. support
     for DragonFly BSD. Patch by David Carlier.

   - bpo-14243(247): The *note tempfile.NamedTemporaryFile: 492.
     function has a new optional parameter 'delete_on_close'

   - bpo-41246(248): Give the same callback function for when the
     overlapped operation is done to the functions ‘recv’, ‘recv_into’,
     ‘recvfrom’, ‘sendto’, ‘send’ and ‘sendfile’ inside ‘IocpProactor’.

   - bpo-39264(249): Fixed ‘collections.UserDict.get()’ to not call
     ‘__missing__()’ when a value is not found.  This matches the
     behavior of *note dict: 237.  Patch by Bar Harel.

   - bpo-38693(250): *note importlib: 6b. now uses f-strings internally
     instead of ‘str.format’.

   - bpo-38267(251): Add 'timeout' parameter to *note
     asyncio.loop.shutdown_default_executor(): 8b5.  The default value
     is ‘None’, which means the executor will be given an unlimited
     amount of time.  When called from *note asyncio.Runner: 5cb. or
     *note asyncio.run(): 449, the default timeout is 5 minutes.

   - bpo-34828(252): *note sqlite3.Connection.iterdump(): 228. now
     handles databases that use ‘AUTOINCREMENT’ in one or more tables.

   - bpo-32990(253): Support reading wave files with the
     ‘WAVE_FORMAT_EXTENSIBLE’ format in the *note wave: fb. module.

   - bpo-26253(254): Allow adjustable compression level for tarfile
     streams in *note tarfile.open(): e40.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89237

   (2) https://github.com/python/cpython/issues/97928

   (3) https://github.com/python/cpython/issues/98393

   (4) https://github.com/python/cpython/issues/98363

   (5) https://github.com/python/cpython/issues/98331

   (6) https://github.com/python/cpython/issues/98307

   (7) https://github.com/python/cpython/issues/96035

   (8) https://github.com/python/cpython/issues/98257

   (9) https://github.com/python/cpython/issues/98251

   (10) https://github.com/python/cpython/issues/94597

   (11) https://github.com/python/cpython/issues/98178

   (12) https://github.com/python/cpython/issues/44098

   (13) https://github.com/python/cpython/issues/87730

   (14) https://github.com/python/cpython/issues/94597

   (15) https://github.com/python/cpython/issues/98023

   (16) https://github.com/python/cpython/issues/90985

   (17) https://github.com/python/cpython/issues/65961

   (18) https://github.com/python/cpython/issues/97646

   (19) https://datatracker.ietf.org/doc/html/rfc9239.html

   (20) https://github.com/python/cpython/issues/97930

   (21) https://github.com/python/cpython/issues/97850

   (22) https://github.com/python/cpython/issues/97837

   (23) https://github.com/python/cpython/issues/97825

   (24) https://github.com/python/cpython/issues/97008

   (25) https://github.com/python/cpython/issues/82711

   (26) https://github.com/python/cpython/issues/97799

   (27) https://github.com/python/cpython/issues/97781

   (28) https://github.com/python/cpython/issues/96827

   (29) https://github.com/python/cpython/issues/95534

   (30) https://github.com/python/cpython/issues/97592

   (31) https://github.com/python/cpython/issues/97639

   (32) https://github.com/python/cpython/issues/97545

   (33) https://github.com/python/cpython/issues/73588

   (34) https://github.com/python/cpython/issues/96865

   (35) https://github.com/python/cpython/issues/97005

   (36) https://github.com/python/cpython/issues/85760

   (37) https://github.com/python/cpython/issues/96704

   (38) https://github.com/python/cpython/issues/96819

   (39) https://github.com/python/cpython/issues/95865

   (40) https://github.com/python/cpython/issues/96741

   (41) https://github.com/python/cpython/issues/96734

   (42) https://github.com/python/cpython/issues/96735

   (43) https://github.com/python/cpython/issues/46412

   (44) https://github.com/python/cpython/issues/96652

   (45) https://github.com/python/cpython/issues/68163

   (46) https://github.com/python/cpython/issues/96538

   (47) https://github.com/python/cpython/issues/96465

   (48) https://github.com/python/cpython/issues/96079

   (49) https://github.com/python/cpython/issues/96415

   (50) https://github.com/python/cpython/issues/95987

   (51) https://github.com/python/cpython/issues/96388

   (52) https://github.com/python/cpython/issues/96385

   (53) https://github.com/python/cpython/issues/96142

   (54) https://github.com/python/cpython/issues/96073

   (55) https://github.com/python/cpython/issues/89258

   (56) https://github.com/python/cpython/issues/96346

   (57) https://github.com/python/cpython/issues/96349

   (58) https://github.com/python/cpython/issues/90467

   (59) https://github.com/python/cpython/issues/96172

   (60) https://github.com/python/cpython/issues/96159

   (61) https://github.com/python/cpython/issues/96175

   (62) https://github.com/python/cpython/issues/96145

   (63) https://github.com/python/cpython/issues/96052

   (64) https://github.com/python/cpython/issues/96125

   (65) https://github.com/python/cpython/issues/96019

   (66) https://github.com/python/cpython/issues/95463

   (67) https://bugs.python.org/issue?@action=redirect&bpo=28080

   (68) https://github.com/python/cpython/issues/69142

   (69) https://github.com/python/cpython/issues/95899

   (70) https://github.com/python/cpython/issues/95736

   (71) https://github.com/python/cpython/issues/95865

   (72) https://github.com/python/cpython/issues/95861

   (73) https://github.com/python/cpython/issues/95804

   (74) https://github.com/python/cpython/issues/95704

   (75) https://github.com/python/cpython/issues/95149

   (76) https://github.com/python/cpython/issues/95609

   (77) https://github.com/python/cpython/issues/95289

   (78) https://github.com/python/cpython/issues/94909

   (79) https://github.com/python/cpython/issues/95385

   (80) https://github.com/python/cpython/issues/83901

   (81) https://github.com/python/cpython/issues/95339

   (82) https://github.com/python/cpython/issues/95045

   (83) https://github.com/python/cpython/issues/95231

   (84) https://github.com/python/cpython/issues/95097

   (85) https://github.com/python/cpython/issues/95087

   (86) https://github.com/python/cpython/issues/95199

   (87) https://github.com/python/cpython/issues/95194

   (88) https://github.com/python/cpython/issues/93899

   (89) https://github.com/python/cpython/issues/95166

   (90) https://github.com/python/cpython/issues/95132

   (91) https://github.com/python/cpython/issues/85128

   (92) https://github.com/python/cpython/issues/93157

   (93) https://github.com/python/cpython/issues/91212

   (94) https://github.com/python/cpython/issues/95077

   (95) https://github.com/python/cpython/issues/95109

   (96) https://github.com/python/cpython/issues/95105

   (97) https://github.com/python/cpython/issues/95066

   (98) https://github.com/python/cpython/issues/77617

   (99) https://github.com/python/cpython/issues/95005

   (100) https://github.com/python/cpython/issues/90085

   (101) https://github.com/python/cpython/issues/94857

   (102) https://github.com/python/cpython/issues/94821

   (103) https://github.com/python/cpython/issues/94736

   (104) https://github.com/python/cpython/issues/81620

   (105) https://github.com/python/cpython/issues/74116

   (106) https://github.com/python/cpython/issues/87822

   (107) https://github.com/python/cpython/issues/88050

   (108) https://github.com/python/cpython/issues/94637

   (109) https://github.com/python/cpython/issues/94309

   (110) https://github.com/python/cpython/issues/92546

   (111) https://github.com/python/cpython/issues/94607

   (112) https://github.com/python/cpython/issues/94619

   (113) https://github.com/python/cpython/issues/93910

   (114) https://github.com/python/cpython/issues/93896

   (115) https://github.com/python/cpython/issues/94343

   (116) https://github.com/python/cpython/issues/94382

   (117) https://github.com/python/cpython/issues/78724

   (118) https://github.com/python/cpython/issues/94510

   (119) https://github.com/python/cpython/issues/92336

   (120) https://github.com/python/cpython/issues/94398

   (121) https://github.com/python/cpython/issues/94383

   (122) https://github.com/python/cpython/issues/94379

   (123) https://peps.python.org/pep-0451/

   (124) https://github.com/python/cpython/issues/94352

   (125) https://github.com/python/cpython/issues/94318

   (126) https://github.com/python/cpython/issues/89988

   (127) https://github.com/python/cpython/issues/90016

   (128) https://github.com/python/cpython/issues/94254

   (129) https://github.com/python/cpython/issues/93259

   (130) https://github.com/python/cpython/issues/74696

   (131) https://github.com/python/cpython/issues/94216

   (132) https://github.com/python/cpython/issues/93096

   (133) https://github.com/python/cpython/issues/94207

   (134) https://github.com/python/cpython/issues/93096

   (135) https://github.com/python/cpython/issues/94226

   (136) https://github.com/python/cpython/issues/94199

   (137) https://github.com/python/cpython/issues/94214

   (138) https://github.com/python/cpython/issues/94199

   (139) https://cwe.mitre.org/data/definitions/295.html

   (140) https://github.com/python/cpython/issues/94199

   (141) https://github.com/python/cpython/issues/94199

   (142) https://peps.python.org/pep-0644/

   (143) https://github.com/python/cpython/issues/94196

   (144) https://github.com/python/cpython/issues/94182

   (145) https://github.com/python/cpython/issues/94169

   (146) https://github.com/python/cpython/issues/91742

   (147) https://github.com/python/cpython/issues/94101

   (148) https://github.com/python/cpython/issues/84753

   (149) https://github.com/python/cpython/issues/94028

   (150) https://github.com/python/cpython/issues/93973

   (151) https://github.com/python/cpython/issues/93963

   (152) https://github.com/python/cpython/issues/93858

   (153) https://github.com/python/cpython/issues/93820

   (154) https://github.com/python/cpython/issues/93847

   (155) https://github.com/python/cpython/issues/91404

   (156) https://github.com/python/cpython/issues/83499

   (157) https://github.com/python/cpython/issues/93820

   (158) https://github.com/python/cpython/issues/79512

   (159) https://github.com/python/cpython/issues/91389

   (160) https://github.com/python/cpython/issues/93626

   (161) https://github.com/python/cpython/issues/90473

   (162) https://peps.python.org/pep-0370/

   (163) https://github.com/python/cpython/issues/90494

   (164) https://github.com/python/cpython/issues/90549

   (165) https://github.com/python/cpython/issues/93521

   (166) https://github.com/python/cpython/issues/79579

   (167) https://github.com/python/cpython/issues/93421

   (168) https://github.com/python/cpython/issues/93475

   (169) https://github.com/python/cpython/issues/93370

   (170) https://github.com/python/cpython/issues/91810

   (171) https://github.com/python/cpython/issues/91162

   (172) https://github.com/python/cpython/issues/93353

   (173) https://github.com/python/cpython/issues/83658

   (174) https://github.com/python/cpython/issues/93312

   (175) https://github.com/python/cpython/issues/88123

   (176) https://github.com/python/cpython/issues/93297

   (177) https://github.com/python/cpython/issues/85308

   (178) https://github.com/python/cpython/issues/93156

   (179) https://github.com/python/cpython/issues/93162

   (180) https://github.com/python/cpython/issues/93243

   (181) https://peps.python.org/pep-0594/

   (182) https://github.com/python/cpython/issues/92886

   (183) https://github.com/python/cpython/issues/90155

   (184) https://github.com/python/cpython/issues/90817

   (185) https://github.com/python/cpython/issues/91513

   (186) https://github.com/python/cpython/issues/74696

   (187) https://github.com/python/cpython/issues/92728

   (188) https://github.com/python/cpython/issues/93033

   (189) https://github.com/python/cpython/issues/89973

   (190) https://github.com/python/cpython/issues/93044

   (191) https://github.com/python/cpython/issues/93010

   (192) https://github.com/python/cpython/issues/92986

   (193) https://github.com/python/cpython/issues/92932

   (194) https://github.com/python/cpython/issues/92675

   (195) https://github.com/python/cpython/issues/87901

   (196) https://github.com/python/cpython/issues/91922

   (197) https://github.com/python/cpython/issues/92869

   (198) https://github.com/python/cpython/issues/92839

   (199) https://github.com/python/cpython/issues/90473

   (200) https://github.com/python/cpython/issues/89325

   (201) https://github.com/python/cpython/issues/92734

   (202) https://github.com/python/cpython/issues/92671

   (203) https://github.com/python/cpython/issues/91581

   (204) https://github.com/python/cpython/issues/86388

   (205) https://github.com/python/cpython/issues/90385

   (206) https://github.com/python/cpython/issues/92550

   (207) https://github.com/python/cpython/issues/92591

   (208) https://github.com/python/cpython/issues/92445

   (209) https://github.com/python/cpython/issues/92547

   (210) https://github.com/python/cpython/issues/92530

   (211) https://github.com/python/cpython/issues/92531

   (212) https://github.com/python/cpython/issues/84131

   (213) https://github.com/python/cpython/issues/89336

   (214) https://github.com/python/cpython/issues/92391

   (215) https://github.com/python/cpython/issues/91968

   (216) https://github.com/python/cpython/issues/91810

   (217) https://github.com/python/cpython/issues/81790

   (218) https://github.com/python/cpython/issues/91760

   (219) https://github.com/python/cpython/issues/90622

   (220) https://github.com/python/cpython/issues/91577

   (221) https://github.com/python/cpython/issues/91581

   (222) https://github.com/python/cpython/issues/91539

   (223) https://github.com/python/cpython/issues/91524

   (224) https://github.com/python/cpython/issues/91447

   (225) https://github.com/python/cpython/issues/91456

   (226) https://bugs.python.org/issue?@action=redirect&bpo=47231

   (227) https://bugs.python.org/issue?@action=redirect&bpo=39064

   (228) https://bugs.python.org/issue?@action=redirect&bpo=41287

   (229) https://github.com/python/cpython/issues/90005

   (230) https://bugs.python.org/issue?@action=redirect&bpo=32547

   (231) https://bugs.python.org/issue?@action=redirect&bpo=35540

   (232) https://bugs.python.org/issue?@action=redirect&bpo=47063

   (233) https://bugs.python.org/issue?@action=redirect&bpo=47025

   (234) https://bugs.python.org/issue?@action=redirect&bpo=46951

   (235) https://bugs.python.org/issue?@action=redirect&bpo=42777

   (236) https://bugs.python.org/issue?@action=redirect&bpo=46755

   (237) https://bugs.python.org/issue?@action=redirect&bpo=45393

   (238) https://bugs.python.org/issue?@action=redirect&bpo=46642

   (239) https://bugs.python.org/issue?@action=redirect&bpo=46364

   (240) https://bugs.python.org/issue?@action=redirect&bpo=28249

   (241) https://bugs.python.org/issue?@action=redirect&bpo=46197

   (242) https://bugs.python.org/issue?@action=redirect&bpo=45924

   (243) https://bugs.python.org/issue?@action=redirect&bpo=45046

   (244) https://bugs.python.org/issue?@action=redirect&bpo=44173

   (245) https://bugs.python.org/issue?@action=redirect&bpo=42627

   (246) https://bugs.python.org/issue?@action=redirect&bpo=42047

   (247) https://bugs.python.org/issue?@action=redirect&bpo=14243

   (248) https://bugs.python.org/issue?@action=redirect&bpo=41246

   (249) https://bugs.python.org/issue?@action=redirect&bpo=39264

   (250) https://bugs.python.org/issue?@action=redirect&bpo=38693

   (251) https://bugs.python.org/issue?@action=redirect&bpo=38267

   (252) https://bugs.python.org/issue?@action=redirect&bpo=34828

   (253) https://bugs.python.org/issue?@action=redirect&bpo=32990

   (254) https://bugs.python.org/issue?@action=redirect&bpo=26253


File: python.info,  Node: Documentation<17>,  Next: Tests<20>,  Prev: Library<22>,  Up: Python 3 12 0 alpha 1

1.23.23.4 Documentation
.......................

   - gh-85525(1): Remove extra row

   - gh-86404(2): Deprecated tools ‘make suspicious’ and ‘rstlint.py’
     are now removed.  They have been replaced by sphinx-lint(3).

   - gh-97741(4): Fix ‘!’ in c domain ref target syntax via a ‘conf.py’
     patch, so it works as intended to disable ref target resolution.

   - gh-96432(5): Fraction literals now support whitespace around the
     forward slash, ‘Fraction('2 / 3')’.

   - gh-96098(6): Improve discoverability of the higher level
     concurrent.futures module by providing clearer links from the lower
     level threading and multiprocessing modules.

   - gh-95957(7): What's New 3.11 now has instructions for how to
     provide compiler and linker flags for Tcl/Tk and OpenSSL on RHEL 7
     and CentOS 7.

   - gh-95588(8): Clarified the conflicting advice given in the *note
     ast: 7. documentation about *note ast.literal_eval(): be6. being
     "safe" for use on untrusted input while at the same time warning
     that it can crash the process.  The latter statement is true and is
     deemed unfixable without a large amount of work unsuitable for a
     bugfix.  So we keep the warning and no longer claim that
     ‘literal_eval’ is safe.

   - gh-91207(9): Fix stylesheet not working in Windows CHM htmlhelp
     docs and add warning that they are deprecated.  Contributed by
     C.A.M. Gerlach.

   - gh-95454(10): Replaced incorrectly written true/false values in
     documentation.  Patch by Robert O'Shea

   - gh-95451(11): Update library documentation with *note availability
     information: 174c. on WebAssembly platforms ‘wasm32-emscripten’ and
     ‘wasm32-wasi’.

   - gh-95415(12): Use consistent syntax for platform availability.  The
     directive now supports a content body and emits a warning when it
     encounters an unknown platform.

   - gh-94321(13): Document the PEP 246(14) style protocol type *note
     sqlite3.PrepareProtocol: 174d.

   - gh-86128(15): Document a limitation in ThreadPoolExecutor where its
     exit handler is executed before any handlers in atexit.

   - gh-61162(16): Clarify *note sqlite3: ba. behavior when *note
     接続(connection)コンテキストマネージャの使い方: 174e.

   - gh-87260(17): Align *note sqlite3: ba. argument specs with the
     actual implementation.

   - gh-86986(18): The minimum Sphinx version required to build the
     documentation is now 3.2.

   - gh-88831(19): Augmented documentation of asyncio.create_task().
     Clarified the need to keep strong references to tasks and added a
     code snippet detailing how to do this.

   - gh-86438(20): Clarify that *note -W: 896. and *note PYTHONWARNINGS:
     b78. are matched literally and case-insensitively, rather than as
     regular expressions, in *note warnings: fa.

   - gh-93031(21): Update tutorial introduction output to use 3.10+
     SyntaxError invalid range.

   - gh-92240(22): Added release dates for "What's New in Python 3.X"
     for 3.0, 3.1, 3.2, 3.8 and 3.10

   - bpo-47161(23): Document that *note pathlib.PurePath: 473. does not
     collapse initial double slashes because they denote UNC paths.

   - bpo-40838(24): Document that *note inspect.getdoc(): 9c8, *note
     inspect.getmodule(): 174f, and *note inspect.getsourcefile(): 1750.
     might return ‘None’.

   - bpo-43689(25): The ‘Differ’ documentation now also mentions other
     whitespace characters, which make it harder to understand the diff
     output.

   - bpo-38056(26): Overhaul the *note エラーハンドラ: 1751.
     documentation in *note codecs: 14.

   - bpo-13553(27): Document tkinter.Tk args.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/85525

   (2) https://github.com/python/cpython/issues/86404

   (3) https://pypi.org/project/sphinx-lint/

   (4) https://github.com/python/cpython/issues/97741

   (5) https://github.com/python/cpython/issues/96432

   (6) https://github.com/python/cpython/issues/96098

   (7) https://github.com/python/cpython/issues/95957

   (8) https://github.com/python/cpython/issues/95588

   (9) https://github.com/python/cpython/issues/91207

   (10) https://github.com/python/cpython/issues/95454

   (11) https://github.com/python/cpython/issues/95451

   (12) https://github.com/python/cpython/issues/95415

   (13) https://github.com/python/cpython/issues/94321

   (14) https://peps.python.org/pep-0246/

   (15) https://github.com/python/cpython/issues/86128

   (16) https://github.com/python/cpython/issues/61162

   (17) https://github.com/python/cpython/issues/87260

   (18) https://github.com/python/cpython/issues/86986

   (19) https://github.com/python/cpython/issues/88831

   (20) https://github.com/python/cpython/issues/86438

   (21) https://github.com/python/cpython/issues/93031

   (22) https://github.com/python/cpython/issues/92240

   (23) https://bugs.python.org/issue?@action=redirect&bpo=47161

   (24) https://bugs.python.org/issue?@action=redirect&bpo=40838

   (25) https://bugs.python.org/issue?@action=redirect&bpo=43689

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38056

   (27) https://bugs.python.org/issue?@action=redirect&bpo=13553


File: python.info,  Node: Tests<20>,  Next: Build<22>,  Prev: Documentation<17>,  Up: Python 3 12 0 alpha 1

1.23.23.5 Tests
...............

   - gh-95027(1): On Windows, when the Python test suite is run with the
     ‘-jN’ option, the ANSI code page is now used as the encoding for
     the stdout temporary file, rather than using UTF-8 which can lead
     to decoding errors.  Patch by Victor Stinner.

   - gh-96624(2): Fixed the failure of repeated runs of
     ‘test.test_unittest’ caused by side effects in
     ‘test_dotted_but_module_not_loaded’.

   - gh-95243(3): Mitigate the inherent race condition from using
     find_unused_port() in testSockName() by trying to find an unused
     port a few times before failing.  Patch by Ross Burton.

   - gh-95573(4): Lib/test/test_asyncio/test_ssl.py(5) exposed a bug in
     the macOS kernel where intense concurrent load on non-blocking
     sockets occasionally causes *note errno.ENOBUFS: 1753. ("No buffer
     space available") to be emitted.  FB11063974 filed with Apple, in
     the mean time as a workaround buffer size used in tests on macOS is
     decreased to avoid intermittent failures.  Patch by Fantix King.

   - gh-95280(6): Fix problem with ‘test_ssl’ ‘test_get_ciphers’ on
     systems that require perfect forward secrecy (PFS) ciphers.

   - gh-95212(7): Make multiprocessing test case
     ‘test_shared_memory_recreate’ parallel-safe.

   - gh-95218(8): Move tests for importlib.resources into
     test_importlib.resources.

   - gh-93963(9): Updated tests to use preferred location for
     ‘importlib.resources’ ABCs.

   - gh-94675(10): Add a regression test for *note re: a7. exponentional
     slowdown when using rjsmin.

   - gh-91330(11): Added more tests for *note dataclasses: 27. to cover
     behavior with data descriptor-based fields.

   - gh-94208(12): ‘test_ssl’ is now checking for supported TLS version
     and protocols in more tests.

   - gh-94315(13): Tests now check for DAC override capability instead
     of relying on *note os.geteuid(): 1754.

   - gh-54781(14): Rename test_tk to test_tkinter, and rename
     test_ttk_guionly to test_ttk.  Patch by Victor Stinner.

   - gh-93839(15): Move ‘Lib/ctypes/test/’ to ‘Lib/test/test_ctypes/’.
     Patch by Victor Stinner.

   - gh-93951(16): In test_bdb.StateTestCase.test_skip, avoid including
     auxiliary importers.

   - gh-93957(17): Provide nicer error reporting from subprocesses in
     test_venv.EnsurePipTest.test_with_pip.

   - gh-93884(18): Add test cases for *note PyNumber_ToBase(): 1755.
     that take a large number or a non-int object as parameter.

   - gh-93852(19): test_asyncio, test_logging, test_socket and
     test_socketserver now create AF_UNIX domains in the current
     directory to no longer fail with ‘OSError("AF_UNIX path too long")’
     if the temporary directory (the ‘TMPDIR’ environment variable) is
     too long.  Patch by Victor Stinner.

   - gh-93353(20): regrtest now checks if a test leaks temporary files
     or directories if run with -jN option.  Patch by Victor Stinner.

   - gh-84461(21): ‘run_tests.py’ now handles cross compiling env vars
     correctly and pass ‘HOSTRUNNER’ to regression tests.

   - gh-93616(22): ‘test_modulefinder’ now creates a temporary directory
     in ‘ModuleFinderTest.setUp()’ instead of module scope.

   - gh-93575(23): Fix issue with test_unicode test_raiseMemError.  The
     test case now use ‘test.support.calcobjsize’ to calculate size of
     PyUnicode structs.  *note sys.getsizeof(): 16d5. may return
     different size when string has UTF-8 memory.

   - gh-90473(24): WASI does not have a ‘chmod(2)’ syscall.  *note
     os.chmod(): 1fc. is now a dummy function on WASI. Skip all tests
     that depend on working *note os.chmod(): 1fc.

   - gh-90473(25): Skip tests on WASI that require symlinks with
     absolute paths.

   - gh-57539(26): Increase calendar test coverage for
     ‘calendar.LocaleTextCalendar.formatweekday()’.

   - gh-90473(27): Skip symlink tests on WASI. wasmtime uses
     ‘openat2(2)’ with ‘RESOLVE_BENEATH’ flag, which prevents symlinks
     with absolute paths.

   - gh-89858(28): Fix ‘test_embed’ for out-of-tree builds.  Patch by
     Kumar Aditya.

   - gh-92886(29): Fixing tests that fail when running with
     optimizations (‘-O’) in ‘test_imaplib.py’.

   - gh-92886(30): Fixing tests that fail when running with
     optimizations (‘-O’) in ‘test_zipimport.py’

   - gh-92886(31): Fixing tests that fail when running with
     optimizations (‘-O’) in ‘test_py_compile.py’

   - gh-92886(32): Fixing tests that fail when running with
     optimizations (‘-O’) in ‘test_sys_settrace.py’.

   - gh-92886(33): Fixing tests that fail when running with
     optimizations (‘-O’) in ‘_test_multiprocessing.py’

   - gh-92670(34): Skip
     ‘test_shutil.TestCopy.test_copyfile_nonexistent_dir’ test on AIX as
     the test uses a trailing slash to force the OS consider the path as
     a directory, but on AIX the trailing slash has no effect and is
     considered as a file.

   - gh-92514(35): Remove unused ‘test.support.BasicTestRunner’.  Patch
     by Jelle Zijlstra.

   - bpo-47016(36): Create a GitHub Actions workflow for verifying
     bundled pip and setuptools.  Patch by Illia Volochii and Adam
     Turner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/95027

   (2) https://github.com/python/cpython/issues/96624

   (3) https://github.com/python/cpython/issues/95243

   (4) https://github.com/python/cpython/issues/95573

   (5) 
https://github.com/python/cpython/tree/3.13/Lib/test/test_asyncio/test_ssl.py

   (6) https://github.com/python/cpython/issues/95280

   (7) https://github.com/python/cpython/issues/95212

   (8) https://github.com/python/cpython/issues/95218

   (9) https://github.com/python/cpython/issues/93963

   (10) https://github.com/python/cpython/issues/94675

   (11) https://github.com/python/cpython/issues/91330

   (12) https://github.com/python/cpython/issues/94208

   (13) https://github.com/python/cpython/issues/94315

   (14) https://github.com/python/cpython/issues/54781

   (15) https://github.com/python/cpython/issues/93839

   (16) https://github.com/python/cpython/issues/93951

   (17) https://github.com/python/cpython/issues/93957

   (18) https://github.com/python/cpython/issues/93884

   (19) https://github.com/python/cpython/issues/93852

   (20) https://github.com/python/cpython/issues/93353

   (21) https://github.com/python/cpython/issues/84461

   (22) https://github.com/python/cpython/issues/93616

   (23) https://github.com/python/cpython/issues/93575

   (24) https://github.com/python/cpython/issues/90473

   (25) https://github.com/python/cpython/issues/90473

   (26) https://github.com/python/cpython/issues/57539

   (27) https://github.com/python/cpython/issues/90473

   (28) https://github.com/python/cpython/issues/89858

   (29) https://github.com/python/cpython/issues/92886

   (30) https://github.com/python/cpython/issues/92886

   (31) https://github.com/python/cpython/issues/92886

   (32) https://github.com/python/cpython/issues/92886

   (33) https://github.com/python/cpython/issues/92886

   (34) https://github.com/python/cpython/issues/92670

   (35) https://github.com/python/cpython/issues/92514

   (36) https://bugs.python.org/issue?@action=redirect&bpo=47016


File: python.info,  Node: Build<22>,  Next: Windows<19>,  Prev: Tests<20>,  Up: Python 3 12 0 alpha 1

1.23.23.6 Build
...............

   - gh-96761(1): Fix the build process of clang compiler for
     ‘_bootstrap_python’ if LTO optimization is applied.  Patch by
     Matthias Görgens and Donghee Na.

   - gh-96883(2): ‘wasm32-emscripten’ builds for browsers now include
     *note concurrent.futures: 1a. for *note asyncio: 8. and *note
     unittest.mock: f0.

   - gh-85936(3): CPython now uses the ThinLTO option as the default
     policy if the Clang compiler accepts the flag.  Patch by Donghee
     Na.

   - gh-96729(4): Ensure that Windows releases built with
     ‘Tools\msi\buildrelease.bat’ are upgradable to and from official
     Python releases.

   - gh-96269(5): Shared module targets now depend on new ‘MODULE_DEPS’
     variable, which includes ‘EXPORTSYMS’.  This fixes a build order
     issue on unsupported AIX platform.

   - gh-84461(6): ‘wasm32-emscripten’ platform no longer builds *note
     resource: aa. module, *note getresuid(): 12e5, *note getresgid():
     12e4, and their setters.  The APIs are stubs and not functional.

   - gh-95973(7): Add a new ‘--with-dsymutil’ configure option to link
     debug information in macOS. Patch by Pablo Galindo.

   - gh-90536(8): Use the BOLT post-link optimizer to improve
     performance, particularly on medium-to-large applications.

   - gh-93744(9): Remove the ‘configure --with-cxx-main’ build option:
     it didn't work for many years.  Remove the ‘MAINCC’ variable from
     ‘configure’ and ‘Makefile’.  Patch by Victor Stinner.

   - gh-94801(10): Fix a regression in ‘configure’ script that caused
     some header checks to ignore custom ‘CPPFLAGS’.  The regression was
     introduced in gh-94802(11).

   - gh-95145(12): wasm32-wasi builds no longer depend on WASIX's
     pthread stubs.  Python now has its own stubbed pthread API.

   - gh-95174(13): Python now detects missing ‘dup’ function in WASI and
     works around some missing *note errno: 4d, *note select: af, and
     *note socket: b8. constants.

   - gh-95174(14): Python now skips missing *note socket: b8. functions
     and methods on WASI. WASI can only create sockets from existing fd
     / accept and has no netdb.

   - gh-95085(15): Platforms ‘wasm32-unknown-emscripten’ and
     ‘wasm32-unknown-wasi’ have been promoted to PEP 11(16) tier 3
     platform support.

   - gh-94847(17): Fixed ‘_decimal’ module build issue on GCC when
     compiling with LTO and pydebug.  Debug builds no longer force
     inlining of functions.

   - gh-94841(18): Fix the possible performance regression of *note
     PyObject_Free(): c34. compiled with MSVC version 1932.

   - gh-94801(19): ‘configure’ now uses custom flags like ‘ZLIB_CFLAGS’
     and ‘ZLIB_LIBS’ when searching for headers and libraries.

   - gh-94773(20): ‘deepfreeze.py’ now supports code object with
     frozensets that contain incompatible, unsortable types.

   - gh-94682(21): Build and test with OpenSSL 1.1.1q

   - gh-90005(22): Dependencies of *note readline: a8. and *note curses:
     23. module are now detected in ‘configure’ script with
     ‘pkg-config’.  Only ‘ncurses’ / ‘ncursesw’ are detected
     automatically.  The old ‘curses’ library is not configured
     automatically.  Workaround for missing ‘termcap’ or ‘tinfo’ library
     has been removed.

   - gh-90005(23): Fix building ‘_ctypes’ extension without
     ‘pkg-config’.

   - gh-90005(24): ‘_dbm’ module dependencies are now detected by
     configure.

   - gh-94404(25): ‘makesetup’ now works around an issue with sed on
     macOS and uses correct CFLAGS for object files that end up in a
     shared extension.  Module CFLAGS are used before
     PY_STDMODULE_CFLAGS to avoid clashes with system headers.

   - gh-93939(26): C extension modules are now built by ‘configure’ and
     ‘make’ instead of ‘distutils’ and ‘setup.py’.

   - gh-93939(27): The ‘2to3’, ‘idle’, and ‘pydoc’ scripts are now
     generated and installed by ‘Makefile’ instead of ‘setup.py’.

   - gh-94280(28): Updated pegen regeneration script on Windows to find
     and use Python 3.9 or higher.  Prior to this, pegen regeneration
     already required 3.9 or higher, but the script may have used lower
     versions of Python.

   - gh-93584(29): Address race condition in ‘Makefile’ when installing
     a PGO build.  All ‘test’ and ‘install’ targets now depend on ‘all’
     target.

   - gh-93491(30): ‘configure’ now detects and reports PEP 11(31)
     support tiers.

   - gh-69093(32): Fix ‘Modules/Setup.stdlib.in’ rule for ‘_sqlite3’
     extension.

   - gh-93207(33): ‘va_start()’ with two parameters, like
     ‘va_start(args, format),’ is now required to build Python.
     ‘va_start()’ is no longer called with a single parameter.  Patch by
     Kumar Aditya.

   - gh-93202(34): Python now always use the ‘%zu’ and ‘%zd’ printf
     formats to format a ‘size_t’ or ‘Py_ssize_t’ number.  Building
     Python 3.12 requires a C11 compiler, so these printf formats are
     now always supported.  Patch by Victor Stinner.

   - gh-90473(35): Disable pymalloc and increase stack size on
     ‘wasm32-wasi’.

   - bpo-34449(36): Drop invalid compiler switch ‘-fPIC’ for HP aCC on
     HP-UX. Patch by Michael Osipov.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/96761

   (2) https://github.com/python/cpython/issues/96883

   (3) https://github.com/python/cpython/issues/85936

   (4) https://github.com/python/cpython/issues/96729

   (5) https://github.com/python/cpython/issues/96269

   (6) https://github.com/python/cpython/issues/84461

   (7) https://github.com/python/cpython/issues/95973

   (8) https://github.com/python/cpython/issues/90536

   (9) https://github.com/python/cpython/issues/93744

   (10) https://github.com/python/cpython/issues/94801

   (11) https://github.com/python/cpython/issues/94802

   (12) https://github.com/python/cpython/issues/95145

   (13) https://github.com/python/cpython/issues/95174

   (14) https://github.com/python/cpython/issues/95174

   (15) https://github.com/python/cpython/issues/95085

   (16) https://peps.python.org/pep-0011/

   (17) https://github.com/python/cpython/issues/94847

   (18) https://github.com/python/cpython/issues/94841

   (19) https://github.com/python/cpython/issues/94801

   (20) https://github.com/python/cpython/issues/94773

   (21) https://github.com/python/cpython/issues/94682

   (22) https://github.com/python/cpython/issues/90005

   (23) https://github.com/python/cpython/issues/90005

   (24) https://github.com/python/cpython/issues/90005

   (25) https://github.com/python/cpython/issues/94404

   (26) https://github.com/python/cpython/issues/93939

   (27) https://github.com/python/cpython/issues/93939

   (28) https://github.com/python/cpython/issues/94280

   (29) https://github.com/python/cpython/issues/93584

   (30) https://github.com/python/cpython/issues/93491

   (31) https://peps.python.org/pep-0011/

   (32) https://github.com/python/cpython/issues/69093

   (33) https://github.com/python/cpython/issues/93207

   (34) https://github.com/python/cpython/issues/93202

   (35) https://github.com/python/cpython/issues/90473

   (36) https://bugs.python.org/issue?@action=redirect&bpo=34449


File: python.info,  Node: Windows<19>,  Next: macOS<15>,  Prev: Build<22>,  Up: Python 3 12 0 alpha 1

1.23.23.7 Windows
.................

   - gh-98360(1): Fixes *note multiprocessing: 86. spawning child
     processes on Windows from a virtual environment to ensure that
     child processes that also use *note multiprocessing: 86. to spawn
     more children will recognize that they are in a virtual
     environment.

   - gh-98414(2): Fix ‘py.exe’ launcher handling of ‘-V:<COMPANY>/’
     option when default preferences have been set in environment
     variables or configuration files.

   - gh-97728(3): Fix possible crashes caused by the use of
     uninitialized variables when pass invalid arguments in *note
     os.system(): 1402. on Windows and in Windows-specific modules (like
     ‘winreg’).

   - gh-90989(4): Made *note Windows の Python ランチャ: 588. install
     per-user by default (unless an all users install already exists),
     and clarify some text in the installer.

   - gh-97649(5): The ‘Tools’ directory is no longer installed on
     Windows

   - gh-96965(6): Update libffi to 3.4.3

   - gh-96577(7): Fixes a potential buffer overrun in ‘msilib’.

   - gh-96559(8): Fixes the Windows launcher not using the compatible
     interpretation of default tags found in configuration files when no
     tag was passed to the command.

   - gh-94781(9): Fix ‘pcbuild.proj’ to clean previous instances of
     output files in ‘Python\deepfreeze’ and ‘Python\frozen_modules’
     directories on Windows.  Patch by Charlie Zhao.

   - gh-89545(10): Updates *note platform: 98. code getting the Windows
     version to use native Windows Management Instrumentation (WMI)
     queries to determine OS version, type, and architecture.

   - gh-95733(11): Make certain requirements of the Windows Store
     package optional to allow installing on earlier updates of Windows.

   - gh-95656(12): Enable the *note enable_load_extension(): 809. *note
     sqlite3: ba. API.

   - gh-95587(13): Fixes some issues where the Windows installer would
     incorrectly detect certain features of an existing install when
     upgrading.

   - gh-94399(14): Restores the behaviour of *note Windows の Python
     ランチャ: 588. for ‘/usr/bin/env’ shebang lines, which will now
     search ‘PATH’ for an executable matching the given command.  If
     none is found, the usual search process is used.

   - gh-95445(15): Fixes the unsuccessful removal of the HTML document
     directory when uninstalling with Windows msi.

   - gh-95359(16): Fix *note Windows の Python ランチャ: 588. handling
     of ‘py.ini’ commands (it was incorrectly expecting a ‘py_’ prefix
     on keys) and crashes when reading per-user configuration file.

   - gh-95285(17): Fix *note Windows の Python ランチャ: 588. handling
     of command lines where it is only passed a short executable name.

   - gh-90844(18): Allow virtual environments to correctly launch when
     they have spaces in the path.

   - gh-94772(19): Fix incorrect handling of shebang lines in py.exe
     launcher

   - gh-94018(20): *note zipfile: 117. will now remove trailing spaces
     from path components when extracting files on Windows.

   - gh-93824(21): Drag and drop of files onto Python files in Windows
     Explorer has been enabled for Windows ARM64.

   - gh-43414(22): *note os.get_terminal_size(): 10d5. now attempts to
     read the size from any provided handle, rather than only supporting
     file descriptors 0, 1 and 2.

   - gh-92817(23): Ensures that ‘py.exe’ will prefer an active virtual
     environment over default tags specified with environment variables
     or through a ‘py.ini’ file.

   - gh-92984(24): Explicitly disable incremental linking for non-Debug
     builds

   - gh-92841(25): *note asyncio: 8. no longer throws ‘RuntimeError:
     Event loop is closed’ on interpreter exit after asynchronous socket
     activity.  Patch by Oleg Iarygin.

   - bpo-46907(26): Update Windows installer to use SQLite 3.38.4.

   - gh-91061(27): Accept os.PathLike for the argument to
     winsound.PlaySound

   - bpo-42658(28): Support native Windows case-insensitive path
     comparisons by using ‘LCMapStringEx’ instead of *note str.lower():
     1758. in ‘ntpath.normcase()’.  Add ‘LCMapStringEx’ to the ‘_winapi’
     module.

   - bpo-38704(29): Prevent installation on unsupported Windows
     versions.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98360

   (2) https://github.com/python/cpython/issues/98414

   (3) https://github.com/python/cpython/issues/97728

   (4) https://github.com/python/cpython/issues/90989

   (5) https://github.com/python/cpython/issues/97649

   (6) https://github.com/python/cpython/issues/96965

   (7) https://github.com/python/cpython/issues/96577

   (8) https://github.com/python/cpython/issues/96559

   (9) https://github.com/python/cpython/issues/94781

   (10) https://github.com/python/cpython/issues/89545

   (11) https://github.com/python/cpython/issues/95733

   (12) https://github.com/python/cpython/issues/95656

   (13) https://github.com/python/cpython/issues/95587

   (14) https://github.com/python/cpython/issues/94399

   (15) https://github.com/python/cpython/issues/95445

   (16) https://github.com/python/cpython/issues/95359

   (17) https://github.com/python/cpython/issues/95285

   (18) https://github.com/python/cpython/issues/90844

   (19) https://github.com/python/cpython/issues/94772

   (20) https://github.com/python/cpython/issues/94018

   (21) https://github.com/python/cpython/issues/93824

   (22) https://github.com/python/cpython/issues/43414

   (23) https://github.com/python/cpython/issues/92817

   (24) https://github.com/python/cpython/issues/92984

   (25) https://github.com/python/cpython/issues/92841

   (26) https://bugs.python.org/issue?@action=redirect&bpo=46907

   (27) https://github.com/python/cpython/issues/91061

   (28) https://bugs.python.org/issue?@action=redirect&bpo=42658

   (29) https://bugs.python.org/issue?@action=redirect&bpo=38704


File: python.info,  Node: macOS<15>,  Next: IDLE<15>,  Prev: Windows<19>,  Up: Python 3 12 0 alpha 1

1.23.23.8 macOS
...............

   - gh-97897(1): The macOS 13 SDK includes support for the ‘mkfifoat’
     and ‘mknodat’ system calls.  Using the ‘dir_fd’ option with either
     *note os.mkfifo(): d5d. or *note os.mknod(): d5e. could result in a
     segfault if cpython is built with the macOS 13 SDK but run on an
     earlier version of macOS. Prevent this by adding runtime support
     for detection of these system calls ("weaklinking") as is done for
     other newer syscalls on macOS.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97897


File: python.info,  Node: IDLE<15>,  Next: Tools/Demos<11>,  Prev: macOS<15>,  Up: Python 3 12 0 alpha 1

1.23.23.9 IDLE
..............

   - gh-97527(1): Fix a bug in the previous bugfix that caused IDLE to
     not start when run with 3.10.8, 3.12.0a1, and at least Microsoft
     Python 3.10.2288.0 installed without the Lib/test package.  3.11.0
     was never affected.

   - gh-65802(2): Document handling of extensions in Save As dialogs.

   - gh-95191(3): Include prompts when saving Shell (interactive input
     and output).

   - gh-95511(4): Fix the Shell context menu copy-with-prompts bug of
     copying an extra line when one selects whole lines.

   - gh-95471(5): In the Edit menu, move ‘Select All’ and add a new
     separator.

   - gh-95411(6): Enable using IDLE's module browser with .pyw files.

   - gh-89610(7): Add .pyi as a recognized extension for IDLE on macOS.
     This allows opening stub files by double clicking on them in the
     Finder.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97527

   (2) https://github.com/python/cpython/issues/65802

   (3) https://github.com/python/cpython/issues/95191

   (4) https://github.com/python/cpython/issues/95511

   (5) https://github.com/python/cpython/issues/95471

   (6) https://github.com/python/cpython/issues/95411

   (7) https://github.com/python/cpython/issues/89610


File: python.info,  Node: Tools/Demos<11>,  Next: C API<21>,  Prev: IDLE<15>,  Up: Python 3 12 0 alpha 1

1.23.23.10 Tools/Demos
......................

   - gh-68686(1): Remove ptags and eptags scripts.

   - gh-97681(2): Remove the ‘Tools/demo/’ directory which contained old
     demo scripts.  A copy can be found in the old-demos project(3).
     Patch by Victor Stinner.

   - gh-97669(4): Remove outdated example scripts of the
     ‘Tools/scripts/’ directory.  A copy can be found in the old-demos
     project(5).  Patch by Victor Stinner.

   - gh-95853(6): The ‘wasm_build.py’ script now pre-builds Emscripten
     ports, checks for broken EMSDK versions, and warns about pkg-config
     env vars.

   - gh-95853(7): The new tool ‘Tools/wasm/wasm_builder.py’ automates
     configure, compile, and test steps for building CPython on
     WebAssembly platforms.

   - gh-95731(8): Fix handling of module docstrings in
     ‘Tools/i18n/pygettext.py’.

   - gh-93939(9): Add script ‘Tools/scripts/check_modules.py’ to check
     and validate builtin and shared extension modules.  The script also
     handles ‘Modules/Setup’ and will eventually replace ‘setup.py’.

   - gh-94538(10): Fix Argument Clinic output to custom file
     destinations.  Patch by Erlend E. Aasland.

   - gh-94430(11): Allow parameters named ‘module’ and ‘self’ with
     custom C names in Argument Clinic.  Patch by Erlend E. Aasland

   - gh-86087(12): The ‘Tools/scripts/parseentities.py’ script used to
     parse HTML4 entities has been removed.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/68686

   (2) https://github.com/python/cpython/issues/97681

   (3) https://github.com/gvanrossum/old-demos

   (4) https://github.com/python/cpython/issues/97669

   (5) https://github.com/gvanrossum/old-demos

   (6) https://github.com/python/cpython/issues/95853

   (7) https://github.com/python/cpython/issues/95853

   (8) https://github.com/python/cpython/issues/95731

   (9) https://github.com/python/cpython/issues/93939

   (10) https://github.com/python/cpython/issues/94538

   (11) https://github.com/python/cpython/issues/94430

   (12) https://github.com/python/cpython/issues/86087


File: python.info,  Node: C API<21>,  Prev: Tools/Demos<11>,  Up: Python 3 12 0 alpha 1

1.23.23.11 C API
................

   - gh-98393(1): The *note PyUnicode_FSDecoder(): 543. function no
     longer accepts bytes-like paths, like *note bytearray: 508. and
     *note memoryview: 435. types: only the exact *note bytes: 1a4. type
     is accepted for bytes strings.  Patch by Victor Stinner.

   - gh-91051(2): Add *note PyType_Watch(): 531. and related APIs to
     allow callbacks on *note PyType_Modified(): 175d.

   - gh-95756(3): Lazily create and cache ‘co_’ attributes for better
     performance for code getters.

   - gh-96512(4): Configuration for the *note integer string conversion
     length limitation: 5bf. now lives in the PyConfig C API struct.

   - gh-95589(5): Extensions classes that set ‘tp_dictoffset’ and
     ‘tp_weaklistoffset’ lose the support for multiple inheritance, but
     are now safe.  Extension classes should use *note
     Py_TPFLAGS_MANAGED_DICT: 344. and *note Py_TPFLAGS_MANAGED_WEAKREF:
     525. instead.

   - gh-95781(6): An unrecognized format character in *note
     PyUnicode_FromFormat(): 363. and *note PyUnicode_FromFormatV():
     540. now sets a *note SystemError: 541.  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.

   - gh-92678(7): Restore the 3.10 behavior for multiple inheritance of
     C extension classes that store their dictionary at the end of the
     struct.

   - gh-92678(8): Support C extensions using managed dictionaries by
     setting the ‘Py_TPFLAGS_MANAGED_DICT’ flag.

   - gh-93274(9): API for implementing vectorcall (*note
     Py_TPFLAGS_HAVE_VECTORCALL: 51f, *note PyVectorcall_NARGS(): 520.
     and *note PyVectorcall_Call(): 521.) was added to the limited API
     and stable ABI.

   - gh-95504(10): Fix sign placement when specifying width or precision
     in *note PyUnicode_FromFormat(): 363. and *note
     PyUnicode_FromFormatV(): 540.  Patch by Philip Georgi.

   - gh-93012(11): The *note Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag is
     now removed from a class when the class's *note __call__(): 523.
     method is reassigned.  This makes vectorcall safe to use with
     mutable types (i.e.  heap types without the ‘immutable’ flag).
     Mutable types that do not override *note tp_call: 524. now inherit
     the *note Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag.

   - gh-95388(12): Creating *note immutable types: 39c. with mutable
     bases is deprecated and is planned to be disabled in Python 3.14.

   - gh-92678(13): Adds unstable C-API functions
     ‘_PyObject_VisitManagedDict’ and ‘_PyObject_ClearManagedDict’ to
     allow C extensions to allow the VM to manage their object's
     dictionaries.

   - gh-94936(14): Added *note PyCode_GetVarnames(): 744, *note
     PyCode_GetCellvars(): 745. and *note PyCode_GetFreevars(): 746. for
     accessing ‘co_varnames’, ‘co_cellvars’ and ‘co_freevars’
     respectively via the C API.

   - gh-94930(15): Fix ‘SystemError’ raised when *note
     PyArg_ParseTupleAndKeywords(): 35c. is used with ‘#’ in ‘(...)’ but
     without ‘PY_SSIZE_T_CLEAN’ defined.

   - gh-94731(16): Python again uses C-style casts for most casting
     operations when compiled with C++.  This may trigger compiler
     warnings, if they are enabled with e.g.  ‘-Wold-style-cast’ or
     ‘-Wzero-as-null-pointer-constant’ options for ‘g++’.

   - gh-93937(17): The following frame functions and type are now
     directly available with ‘#include <Python.h>’, it's no longer
     needed to add ‘#include <frameobject.h>’:

        * *note PyFrame_Check(): 750.

        * *note PyFrame_GetBack(): 751.

        * *note PyFrame_GetBuiltins(): 736.

        * *note PyFrame_GetGenerator(): 737.

        * *note PyFrame_GetGlobals(): 738.

        * *note PyFrame_GetLasti(): 739.

        * *note PyFrame_GetLocals(): 3f8.

        * *note PyFrame_Type: 752.

     Patch by Victor Stinner.

   - gh-91321(18): Fix the compatibility of the Python C API with C++
     older than C++11.  Patch by Victor Stinner.

   - gh-91731(19): Avoid defining the ‘static_assert’ when compiling
     with C++ 11, where this is a keyword and redefining it can lead to
     undefined behavior.  Patch by Pablo Galindo

   - gh-89546(20): *note PyType_FromMetaclass(): 51b. (and other
     ‘PyType_From*’ functions) now check that offsets and the base
     class's *note tp_basicsize: 955. fit in the new class's
     ‘tp_basicsize’.

   - gh-93503(21): Add two new public functions to the public C-API,
     *note PyEval_SetProfileAllThreads(): 52a. and *note
     PyEval_SetTraceAllThreads(): 52b, that allow to set tracing and
     profiling functions in all running threads in addition to the
     calling one.  Also, two analogous functions to the *note threading:
     d6. module (*note threading.setprofile_all_threads(): 495. and
     *note threading.settrace_all_threads(): 494.) that allow to do the
     same from Python.  Patch by Pablo Galindo

   - gh-93442(22): Add C++ overloads for _Py_CAST_impl() to handle
     0/NULL. This will allow C++ extensions that pass 0 or NULL to
     macros using _Py_CAST() to continue to compile.

   - gh-93466(23): Slot IDs in PyType_Spec may not be repeated.  The
     documentation was updated to mention this.  For some cases of
     repeated slots, PyType_FromSpec and related functions will now
     raise an exception.

   - gh-92898(24): Fix C++ compiler warnings when casting function
     arguments to ‘PyObject*’.  Patch by Serge Guelton.

   - gh-93103(25): Deprecate global configuration variables, like *note
     Py_IgnoreEnvironmentFlag: 3b2, in the documentation: the *note
     Py_InitializeFromConfig(): 39f. API should be instead.  Patch by
     Victor Stinner.

   - gh-77782(26): Deprecate global configuration variable like *note
     Py_IgnoreEnvironmentFlag: 3b2.: the *note
     Py_InitializeFromConfig(): 39f. API should be instead.  Patch by
     Victor Stinner.

   - gh-92913(27): Ensures changes to *note
     PyConfig.module_search_paths: 37c. are ignored unless *note
     PyConfig.module_search_paths_set: 5b9. is set

   - gh-92781(28): Avoid mixing declarations and code in the C API to
     fix the compiler warning: "ISO C90 forbids mixed declarations and
     code" [-Werror=declaration-after-statement].  Patch by Victor
     Stinner.

   - gh-92651(29): Remove the ‘token.h’ header file.  There was never
     any public tokenizer C API. The ‘token.h’ header file was only
     designed to be used by Python internals.  Patch by Victor Stinner.

   - gh-92536(30): Remove legacy Unicode APIs based on ‘Py_UNICODE*’.

   - gh-85858(31): Remove the ‘PyUnicode_InternImmortal()’ function and
     the ‘SSTATE_INTERNED_IMMORTAL’ macro.  Patch by Victor Stinner.

   - gh-92193(32): Add new function *note PyFunction_SetVectorcall():
     52c. to the C API which sets the vectorcall field of a given *note
     PyFunctionObject: 52d.

     Warning: extensions using this API must preserve the behavior of
     the unaltered function!

   - gh-59121(33): Fixed an assert that prevented ‘PyRun_InteractiveOne’
     from providing tracebacks when parsing from the provided FD.

   - bpo-45383(34): The *note PyType_FromSpec(): 549. API will now find
     and use a metaclass based on the provided bases.  An error will be
     raised if there is a metaclass conflict.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/98393

   (2) https://github.com/python/cpython/issues/91051

   (3) https://github.com/python/cpython/issues/95756

   (4) https://github.com/python/cpython/issues/96512

   (5) https://github.com/python/cpython/issues/95589

   (6) https://github.com/python/cpython/issues/95781

   (7) https://github.com/python/cpython/issues/92678

   (8) https://github.com/python/cpython/issues/92678

   (9) https://github.com/python/cpython/issues/93274

   (10) https://github.com/python/cpython/issues/95504

   (11) https://github.com/python/cpython/issues/93012

   (12) https://github.com/python/cpython/issues/95388

   (13) https://github.com/python/cpython/issues/92678

   (14) https://github.com/python/cpython/issues/94936

   (15) https://github.com/python/cpython/issues/94930

   (16) https://github.com/python/cpython/issues/94731

   (17) https://github.com/python/cpython/issues/93937

   (18) https://github.com/python/cpython/issues/91321

   (19) https://github.com/python/cpython/issues/91731

   (20) https://github.com/python/cpython/issues/89546

   (21) https://github.com/python/cpython/issues/93503

   (22) https://github.com/python/cpython/issues/93442

   (23) https://github.com/python/cpython/issues/93466

   (24) https://github.com/python/cpython/issues/92898

   (25) https://github.com/python/cpython/issues/93103

   (26) https://github.com/python/cpython/issues/77782

   (27) https://github.com/python/cpython/issues/92913

   (28) https://github.com/python/cpython/issues/92781

   (29) https://github.com/python/cpython/issues/92651

   (30) https://github.com/python/cpython/issues/92536

   (31) https://github.com/python/cpython/issues/85858

   (32) https://github.com/python/cpython/issues/92193

   (33) https://github.com/python/cpython/issues/59121

   (34) https://bugs.python.org/issue?@action=redirect&bpo=45383


File: python.info,  Node: Python 3 11 0 beta 1,  Next: Python 3 11 0 alpha 7,  Prev: Python 3 12 0 alpha 1,  Up: 変更履歴

1.23.24 Python 3.11.0 beta 1
----------------------------

'Release date: 2022-05-06'

* Menu:

* Security: Security<16>.
* Core and Builtins: Core and Builtins<24>.
* Library: Library<23>.
* Documentation: Documentation<18>.
* Tests: Tests<21>.
* Build: Build<23>.
* Windows: Windows<20>.
* macOS: macOS<16>.
* Tools/Demos: Tools/Demos<12>.
* C API: C API<22>.


File: python.info,  Node: Security<16>,  Next: Core and Builtins<24>,  Up: Python 3 11 0 beta 1

1.23.24.1 Security
..................

   - gh-57684(1): Add the *note -P: 56e. command line option and the
     *note PYTHONSAFEPATH: 56f. environment variable to not prepend a
     potentially unsafe path to *note sys.path: 38e.  Patch by Victor
     Stinner.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/57684


File: python.info,  Node: Core and Builtins<24>,  Next: Library<23>,  Prev: Security<16>,  Up: Python 3 11 0 beta 1

1.23.24.2 Core and Builtins
...........................

   - gh-89519(1): Chaining classmethod descriptors (introduced in
     bpo-19072(2)) is deprecated.  It can no longer be used to wrap
     other descriptors such as property().  The core design of this
     feature was flawed, and it caused a number of downstream problems.

   - gh-92345(3): ‘pymain_run_python()’ now imports ‘readline’ and
     ‘rlcompleter’ before sys.path is extended to include the current
     working directory of an interactive interpreter.  Non-interactive
     interpreters are not affected.

   - bpo-43857(4): Improve the *note AttributeError: 326. message when
     deleting a missing attribute.  Patch by Géry Ogam.

   - gh-92245(5): Make sure that PEP 523 is respected in all cases.  In
     3.11a7, specialization may have prevented Python-to-Python calls
     respecting PEP 523.

   - gh-92203(6): Add a closure keyword-only parameter to *note exec():
     164.  It can only be specified when exec-ing a code object that
     uses free variables.  When specified, it must be a tuple, with
     exactly the number of cell variables referenced by the code object.
     closure has a default value of ‘None’, and it must be ‘None’ if the
     code object doesn't refer to any free variables.

   - gh-91173(7): Disable frozen modules in debug builds.  Patch by
     Kumar Aditya.

   - gh-92114(8): Improve error message when subscript a type with
     ‘__class_getitem__’ set to ‘None’.

   - gh-92112(9): Fix crash triggered by an evil custom ‘mro()’ on a
     metaclass.

   - gh-92063(10): The ‘PRECALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS’
     instruction now ensures methods are called only on objects of the
     correct type.

   - gh-92031(11): Deoptimize statically allocated code objects during
     ‘Py_FINALIZE()’ so that future ‘_PyCode_Quicken’ calls always start
     with unquickened code.

   - gh-92036(12): Fix a crash in subinterpreters related to the garbage
     collector.  When a subinterpreter is deleted, untrack all objects
     tracked by its GC. To prevent a crash in deallocator functions
     expecting objects to be tracked by the GC, leak a strong reference
     to these objects on purpose, so they are never deleted and their
     deallocator functions are not called.  Patch by Victor Stinner.

   - gh-92032(13): The interpreter can now autocomplete soft keywords,
     as of now ‘match’, ‘case’, and ‘_’ (wildcard pattern) from PEP
     634(14).

   - gh-87999(15): The warning emitted by the Python parser for a
     numeric literal immediately followed by keyword has been changed
     from deprecation warning to syntax warning.

   - gh-91869(16): Fix an issue where specialized opcodes with extended
     arguments could produce incorrect tracing output or lead to
     assertion failures.

   - gh-91603(17): Speed up *note types.UnionType: 606. instantiation.
     Based on patch provided by Yurii Karabas.

   - gh-89373(18): If Python is built in debug mode, Python now ensures
     that deallocator functions leave the current exception unchanged.
     Patch by Victor Stinner.

   - gh-91632(19): Fix a minor memory leak at exit: release the memory
     of the ‘generic_alias_iterator’ type.  Patch by Donghee Na.

   - gh-81548(20): Octal escapes with value larger than ‘0o377’ now
     produce a *note DeprecationWarning: 18a.  In a future Python
     version they will be a *note SyntaxWarning: 432. and eventually a
     *note SyntaxError: 172.

   - bpo-43950(21): Use a single compact table for line starts, ends and
     column offsets.  Reduces memory consumption for location info by
     half

   - gh-91102(22): Use Argument Clinic for ‘EncodingMap’.  Patch by Oleg
     Iarygin.

   - gh-91636(23): Fixed a crash in a garbage-collection edge-case, in
     which a ‘PyFunction_Type.tp_clear’ function could leave a python
     function object in an inconsistent state.

   - gh-91603(24): Speed up *note isinstance(): 40e. and *note
     issubclass(): 78c. checks for *note types.UnionType: 606.  Patch by
     Yurii Karabas.

   - gh-91625(25): Fixed a bug in which adaptive opcodes ignored any
     preceding ‘EXTENDED_ARG’s on specialization failure.

   - gh-78607(26): The LLTRACE special build now looks for the name
     ‘__lltrace__’ defined in module globals, rather than the name
     ‘__ltrace__’, which had been introduced as a typo.

   - gh-91576(27): Speed up iteration of ascii strings by 50%.  Patch by
     Kumar Aditya.

   - gh-89279(28): Improve interpreter performance on Windows by
     inlining a few specific macros.

   - gh-91502(29): Add a new ‘_PyFrame_IsEntryFrame()’ API function, to
     check if a *note PyFrameObject: 754. is an entry frame.  Patch by
     Pablo Galindo.

   - gh-91266(30): Refactor the ‘bytearray’ strip methods ‘strip’,
     ‘lstrip’ and ‘rstrip’ to use a common implementation.

   - gh-91479(31): Replaced the ‘__note__’ field of *note BaseException:
     584. (added in an earlier version of 3.11) with the final design of
     PEP 678(32).  Namely, *note BaseException: 584. gets an
     ‘add_note()’ method, and its ‘__notes__’ field is created when
     necessary.

   - gh-46055(33): Speed up right shift of negative integers, by
     removing unnecessary creation of temporaries.  Original patch by
     Xinhang Xu, reworked by Mark Dickinson.

   - gh-91462(34): Make the interpreter's low-level tracing (lltrace)
     feature output more readable by displaying opcode names (rather
     than just numbers), and by displaying stack contents before each
     opcode.

   - gh-89455(35): Fixed an uninitialized bool value in the traceback
     printing code path that was introduced by the initial bpo-45292(36)
     exception groups work.

   - gh-91421(37): Fix a potential integer overflow in _Py_DecodeUTF8Ex.

   - gh-91428(38): Add ‘static const char *const _PyOpcode_OpName[256] =
     {...};’ to ‘opcode.h’ for debug builds to assist in debugging the
     Python interpreter.  It is now more convenient to make various
     forms of debugging output more human-readable by including opcode
     names rather than just the corresponding decimal digits.

   - bpo-47120(39): Make *note POP_JUMP_IF_TRUE: 1653, *note
     POP_JUMP_IF_FALSE: 1654, *note POP_JUMP_IF_NONE: 1761. and *note
     POP_JUMP_IF_NOT_NONE: 1762. virtual, mapping to new relative jump
     opcodes.

   - bpo-45317(40): Add internal documentation explaining design of new
     (for 3.11) frame stack.

   - bpo-47197(41): ctypes used to mishandle ‘void’ return types, so
     that for instance a function declared like ‘ctypes.CFUNCTYPE(None,
     ctypes.c_int)’ would be called with signature ‘int f(int)’ instead
     of ‘void f(int)’.  Wasm targets require function pointers to be
     called with the correct signatures so this led to crashes.  The
     problem is now fixed.

   - bpo-47120(42): Make opcodes ‘JUMP_IF_TRUE_OR_POP’ and
     ‘JUMP_IF_FALSE_OR_POP’ relative rather than absolute.

   - bpo-47177(43): Replace the ‘f_lasti’ member of the internal
     ‘_PyInterpreterFrame’ structure with a ‘prev_instr’ pointer, which
     reduces overhead in the main interpreter loop.  The ‘f_lasti’
     attribute of Python-layer frame objects is preserved for
     backward-compatibility.

   - bpo-46961(44): Integer mod/remainder operations, including the
     three-argument form of *note pow(): 9a0, now consistently return
     ints from the global small integer cache when applicable.

   - bpo-46962(45): Classes and functions that unconditionally declared
     their docstrings ignoring the ‘--without-doc-strings’ compilation
     flag no longer do so.

     The classes affected are ‘ctypes.UnionType’, *note
     pickle.PickleBuffer: 1763, ‘testcapi.RecursingInfinitelyError’, and
     *note types.GenericAlias: 7b6.

     The functions affected are 24 methods in *note ctypes: 22.

     Patch by Oleg Iarygin.

   - bpo-46942(46): Use Argument Clinic for the *note types.MethodType:
     1764. constructor.  Patch by Oleg Iarygin.

   - bpo-46764(47): Fix wrapping bound methods with @classmethod

   - bpo-43464(48): Optimize ‘set.intersection()’ for non-set arguments.

   - bpo-46721(49): Optimize ‘set.issuperset()’ for non-set argument.

   - bpo-46509(50): Add type-specialized versions of the ‘Py_DECREF()’,
     and use them for ‘float’, ‘int’, ‘str’, ‘bool’, and ‘None’ to avoid
     pointer-chasing at runtime where types are known at C compile time.

   - bpo-46045(51): Do not use POSIX semaphores on NetBSD

   - bpo-36819(52): Fix crashes in built-in encoders with error handlers
     that return position less or equal than the starting position of
     non-encodable characters.

   - bpo-34093(53): ‘marshal.dumps()’ uses ‘FLAG_REF’ for all interned
     strings.  This makes output more deterministic and helps
     reproducible build.

   - bpo-26579(54): Added ‘object.__getstate__’ which provides the
     default implementation of the ‘__getstate__()’ method.

     Copying and pickling instances of subclasses of builtin types
     bytearray, set, frozenset, collections.OrderedDict,
     collections.deque, weakref.WeakSet, and datetime.tzinfo now copies
     and pickles instance attributes implemented as slots.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89519

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19072

   (3) https://github.com/python/cpython/issues/92345

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43857

   (5) https://github.com/python/cpython/issues/92245

   (6) https://github.com/python/cpython/issues/92203

   (7) https://github.com/python/cpython/issues/91173

   (8) https://github.com/python/cpython/issues/92114

   (9) https://github.com/python/cpython/issues/92112

   (10) https://github.com/python/cpython/issues/92063

   (11) https://github.com/python/cpython/issues/92031

   (12) https://github.com/python/cpython/issues/92036

   (13) https://github.com/python/cpython/issues/92032

   (14) https://peps.python.org/pep-0634/

   (15) https://github.com/python/cpython/issues/87999

   (16) https://github.com/python/cpython/issues/91869

   (17) https://github.com/python/cpython/issues/91603

   (18) https://github.com/python/cpython/issues/89373

   (19) https://github.com/python/cpython/issues/91632

   (20) https://github.com/python/cpython/issues/81548

   (21) https://bugs.python.org/issue?@action=redirect&bpo=43950

   (22) https://github.com/python/cpython/issues/91102

   (23) https://github.com/python/cpython/issues/91636

   (24) https://github.com/python/cpython/issues/91603

   (25) https://github.com/python/cpython/issues/91625

   (26) https://github.com/python/cpython/issues/78607

   (27) https://github.com/python/cpython/issues/91576

   (28) https://github.com/python/cpython/issues/89279

   (29) https://github.com/python/cpython/issues/91502

   (30) https://github.com/python/cpython/issues/91266

   (31) https://github.com/python/cpython/issues/91479

   (32) https://peps.python.org/pep-0678/

   (33) https://github.com/python/cpython/issues/46055

   (34) https://github.com/python/cpython/issues/91462

   (35) https://github.com/python/cpython/issues/89455

   (36) https://bugs.python.org/issue?@action=redirect&bpo=45292

   (37) https://github.com/python/cpython/issues/91421

   (38) https://github.com/python/cpython/issues/91428

   (39) https://bugs.python.org/issue?@action=redirect&bpo=47120

   (40) https://bugs.python.org/issue?@action=redirect&bpo=45317

   (41) https://bugs.python.org/issue?@action=redirect&bpo=47197

   (42) https://bugs.python.org/issue?@action=redirect&bpo=47120

   (43) https://bugs.python.org/issue?@action=redirect&bpo=47177

   (44) https://bugs.python.org/issue?@action=redirect&bpo=46961

   (45) https://bugs.python.org/issue?@action=redirect&bpo=46962

   (46) https://bugs.python.org/issue?@action=redirect&bpo=46942

   (47) https://bugs.python.org/issue?@action=redirect&bpo=46764

   (48) https://bugs.python.org/issue?@action=redirect&bpo=43464

   (49) https://bugs.python.org/issue?@action=redirect&bpo=46721

   (50) https://bugs.python.org/issue?@action=redirect&bpo=46509

   (51) https://bugs.python.org/issue?@action=redirect&bpo=46045

   (52) https://bugs.python.org/issue?@action=redirect&bpo=36819

   (53) https://bugs.python.org/issue?@action=redirect&bpo=34093

   (54) https://bugs.python.org/issue?@action=redirect&bpo=26579


File: python.info,  Node: Library<23>,  Next: Documentation<18>,  Prev: Core and Builtins<24>,  Up: Python 3 11 0 beta 1

1.23.24.3 Library
.................

   - gh-87901(1): Add the 'encoding' parameter to *note os.popen(): a55.

   - gh-90997(2): Fix an issue where *note dis: 30. utilities may
     interpret populated inline cache entries as valid instructions.

   - gh-92332(3): Deprecate *note typing.Text: 2e3. (removal of the
     class is currently not planned).  Patch by Alex Waygood.

   - Deprecate nested classes in enum definitions becoming members - in
     3.13 they will be normal classes; add ‘member’ and ‘nonmember’
     functions to allow control over results now.

   - gh-92356(4): Fixed a performance regression in ctypes function
     calls.

   - gh-90997(5): Show the actual named values stored in inline caches
     when ‘show_caches=True’ is passed to *note dis: 30. utilities.

   - gh-92301(6): Prefer ‘close_range()’ to iterating over procfs for
     file descriptor closing in *note subprocess: c1. for better
     performance.

   - gh-67248(7): Sort the miscellaneous topics in Cmd.do_help()

   - gh-92210(8): Port ‘socket.__init__’ to Argument Clinic.  Patch by
     Cinder.

   - gh-80010(9): Add support for generalized ISO 8601 parsing to *note
     datetime.datetime.fromisoformat(): 5e2, *note
     datetime.date.fromisoformat(): 5e0. and *note
     datetime.time.fromisoformat(): 5e1.  Patch by Paul Ganssle.

   - gh-92118(10): Fix a 3.11 regression in *note contextmanager():
     11d3, which caused it to propagate exceptions with incorrect
     tracebacks.

   - gh-90887(11): Adding ‘COPYFILE_STAT’, ‘COPYFILE_ACL’ and
     ‘COPYFILE_XATTR’ constants for ‘os.fcopyfile()’ available in macOs.

   - gh-91215(12): For *note @dataclass: 1ad, add 'weakref_slot'.  The
     new parameter defaults to ‘False’.  If true, and if ‘slots=True’,
     add a slot named ‘"__weakref__"’, which will allow instances to be
     weakref'd.  Contributed by Eric V. Smith

   - gh-85984(13): New function os.login_tty() for Unix.

   - gh-92128(14): Add *note __class_getitem__(): 706. to *note
     logging.LoggerAdapter: 12c3. and *note logging.StreamHandler: 11c9,
     allowing them to be parameterized at runtime.  Patch by Alex
     Waygood.

   - gh-92049(15): Forbid pickling constants ‘re._constants.SUCCESS’
     etc.  Previously, pickling did not fail, but the result could not
     be unpickled.

   - gh-92062(16): *note inspect.Parameter: 1b2. now raises *note
     ValueError: 1e3. if ‘name’ is a keyword, in addition to the
     existing check that it is an identifier.

   - gh-87390(17): Add an ‘__unpacked__’ attribute to *note
     types.GenericAlias: 7b6.  Patch by Jelle Zijlstra.

   - gh-88089(18): Add support for generic *note typing.NamedTuple: 290.

   - gh-91996(19): New http.HTTPMethod enum to represent all the
     available HTTP request methods in a convenient way

   - gh-91984(20): Modified test strings in test_argparse.py to not
     contain trailing spaces before end of line.

   - gh-91952(21): Add ‘encoding="locale"’ support to
     ‘TextIOWrapper.reconfigure()’.

   - gh-91954(22): Add 'encoding' and 'errors' arguments to *note
     subprocess.getoutput(): 1766. and *note
     subprocess.getstatusoutput(): f8f.

   - bpo-47029(23): Always close the read end of the pipe used by *note
     multiprocessing.Queue: 1767. 'after' the last write of buffered
     data to the write end of the pipe to avoid *note BrokenPipeError:
     1030. at garbage collection and at *note
     multiprocessing.Queue.close(): 1768. calls.  Patch by Géry Ogam.

   - gh-91928(24): Add ‘datetime.UTC’ alias for ‘datetime.timezone.utc’.

     Patch by Kabir Kwatra.

   - gh-68966(25): The ‘mailcap’ module is now deprecated and will be
     removed in Python 3.13.  See PEP 594(26) for the rationale and the
     *note mimetypes: 82. module for an alternative.  Patch by Victor
     Stinner.

   - gh-91401(27): Provide a way to disable *note subprocess: c1. use of
     ‘vfork()’ just in case it is ever needed and document the existing
     mechanism for ‘posix_spawn()’.

   - gh-64783(28): Fix *note signal.NSIG: 1769. value on FreeBSD to
     accept signal numbers greater than 32, like ‘signal.SIGRTMIN’ and
     ‘signal.SIGRTMAX’.  Patch by Victor Stinner.

   - gh-91910(29): Add missing f prefix to f-strings in error messages
     from the *note multiprocessing: 86. and *note asyncio: 8. modules.

   - gh-91860(30): Add *note typing.dataclass_transform(): 4a0,
     implementing PEP 681(31).  Patch by Jelle Zijlstra.

   - gh-91832(32): Add ‘required’ attribute to *note argparse.Action:
     176a. repr output.

   - gh-91827(33): In the *note tkinter: d9. module add method
     ‘info_patchlevel()’ which returns the exact version of the Tcl
     library as a named tuple similar to *note sys.version_info: 66c.

   - gh-84461(34): Add *note -enable-wasm-pthreads: 176b. to enable
     pthreads support for WASM builds.  ‘Emscripten/node’ no longer has
     threading enabled by default.  Include additional file systems.

   - gh-91821(35): Fix unstable ‘test_from_tuple’ test in
     ‘test_decimal.py’.

   - gh-91217(36): Deprecate the xdrlib module.

   - gh-91217(37): Deprecate the uu module.

   - gh-91760(38): More strict rules will be applied for numerical group
     references and group names in regular expressions.  For now, a
     deprecation warning is emitted for group references and group names
     which will be errors in future Python versions.

   - gh-84461(39): Add provisional *note sys._emscripten_info: 176c.
     named tuple with build-time and run-time information about
     Emscripten platform.

   - gh-90623(40): *note signal.raise_signal(): 176d. and *note
     os.kill(): 132f. now check immediately for pending signals.  Patch
     by Victor Stinner.

   - gh-91734(41): Fix OSS audio support on Solaris.

   - gh-90633(42): Include the passed value in the exception thrown by
     *note typing.assert_never(): 673.  Patch by Jelle Zijlstra.

   - gh-91700(43): Compilation of regular expression containing a
     conditional expression ‘(?(group)...)’ now raises an appropriate
     ‘re.error’ if the group number refers to not defined group.
     Previously an internal RuntimeError was raised.

   - gh-91231(44): Add an optional keyword 'shutdown_timeout' parameter
     to the ‘multiprocessing.BaseManager’ constructor.  Kill the process
     if terminate() takes longer than the timeout.  Patch by Victor
     Stinner.

   - gh-91621(45): Fix *note typing.get_type_hints(): 67d. for *note
     collections.abc.Callable: 7b5.  Patch by Shantanu Jain.

   - gh-90568(46): Parsing ‘\N’ escapes of Unicode Named Character
     Sequences in a *note regular expression: a7. raises now ‘re.error’
     instead of ‘TypeError’.

   - gh-91670(47): Remove deprecated ‘SO’ config variable in *note
     sysconfig: c5.

   - gh-91217(48): Deprecate the telnetlib module.

   - gh-91217(49): Deprecate the sunau module.

   - gh-91217(50): Deprecate the spwd module.

   - gh-91217(51): Deprecate the sndhdr module, as well as inline needed
     functionality for ‘email.mime.MIMEAudio’.

   - gh-91616(52): *note re: a7. module, fix *note fullmatch(): 176e.
     mismatch when using Atomic Grouping or Possessive Quantifiers.

   - gh-91217(53): Deprecate the 'pipes' module.

   - gh-91217(54): Deprecate the ossaudiodev module.

   - bpo-47256(55): *note re: a7. module, limit the maximum capturing
     group to 1,073,741,823 in 64-bit build, this increases the depth of
     backtracking.

   - gh-91217(56): Deprecate the nis module.

   - gh-91595(57): Fix the comparison of character and integer inside
     ‘Tools.gdb.libpython.write_repr()’.  Patch by Yu Liu.

   - gh-74166(58): Add option to raise all errors from *note
     create_connection(): 63e. in an *note ExceptionGroup: 19b. when it
     fails to create a connection.  The default remains to raise only
     the last error that had occurred when multiple addresses were
     tried.

   - gh-91487(59): Optimize asyncio UDP speed, over 100 times faster
     when transferring a large file.

   - gh-91575(60): Update case-insensitive matching in the *note re: a7.
     module to the latest Unicode version.

   - gh-90622(61): In ‘concurrent.futures.process.ProcessPoolExecutor’
     disallow the "fork" multiprocessing start method when the new
     ‘max_tasks_per_child’ feature is used as the mix of threads+fork
     can hang the child processes.  Default to using the safe "spawn"
     start method in that circumstance if no ‘mp_context’ was supplied.

   - gh-89022(62): In *note sqlite3: ba, ‘SQLITE_MISUSE’ result codes
     are now mapped to *note InterfaceError: 649. instead of *note
     ProgrammingError: 4bf.  Also, more accurate exceptions are raised
     when binding parameters fail.  Patch by Erlend E. Aasland.

   - gh-91526(63): Stop calling ‘os.device_encoding(file.fileno())’ in
     ‘TextIOWrapper’.  It was complex, never documented, and didn't work
     for most cases.  (Patch by Inada Naoki.)

   - gh-88116(64): Change the frame-related functions in the *note
     inspect: 72. module to return a regular object (that is backwards
     compatible with the old tuple-like interface) that include the
     extended PEP 657(65) position information (end line number, column
     and end column).  The affected functions are: *note
     inspect.getframeinfo(): 61b, *note inspect.getouterframes(): 61c,
     *note inspect.getinnerframes(): 61d, *note inspect.stack(): 61e.
     and *note inspect.trace(): 61f.  Patch by Pablo Galindo.

   - gh-69093(66): Add indexing and slicing support to *note
     sqlite3.Blob: 64e.  Patch by Aviv Palivoda and Erlend E. Aasland.

   - gh-69093(67): Add *note context manager: 59e. support to *note
     sqlite3.Blob: 64e.  Patch by Aviv Palivoda and Erlend E. Aasland.

   - gh-91217(68): Deprecate nntplib.

   - gh-91217(69): Deprecate msilib.

   - gh-91404(70): Improve the performance of *note re: a7. matching by
     using computed gotos (or "threaded code") on supported platforms
     and removing expensive pointer indirections.

   - gh-91217(71): Deprecate the imghdr module.

   - gh-91217(72): Deprecate the crypt module.

   - gh-91276(73): Make space for longer opcodes in *note dis: 30.
     output.

   - bpo-47000(74): Make ‘TextIOWrapper’ uses locale encoding when
     ‘encoding="locale"’ is specified even in UTF-8 mode.

   - gh-91230(75): *note warnings.catch_warnings(): 550. now accepts
     arguments for *note warnings.simplefilter(): 68d, providing a more
     concise way to locally ignore warnings or convert them to errors.

   - gh-91217(76): Deprecate the chunk module.

   - Add the ‘TCP_CONNECTION_INFO’ option (available on macOS) to *note
     socket: b8.

   - bpo-47260(77): Fix ‘os.closerange()’ potentially being a no-op in a
     Linux seccomp sandbox.

   - bpo-47087(78): Implement ‘typing.Required’ and ‘typing.NotRequired’
     ( PEP 655(79)).  Patch by David Foster and Jelle Zijlstra.

   - bpo-47061(80): Deprecate cgi and cgitb.

   - bpo-47061(81): Deprecate audioop.

   - bpo-47000(82): Add *note locale.getencoding(): 2be. to get the
     current locale encoding.  It is similar to
     ‘locale.getpreferredencoding(False)’ but ignores the *note Python
     UTF-8 Mode: 622.

   - bpo-42012(83): Add *note wsgiref.types: 104, containing
     WSGI-specific types for static type checking.

   - bpo-47227(84): Suppress expression chaining for more *note re: a7.
     parsing errors.

   - bpo-47211(85): Remove undocumented and never working function
     ‘re.template()’ and flag ‘re.TEMPLATE’.  This was later reverted in
     3.11.0b2 and deprecated instead.

   - bpo-47135(86): *note decimal.localcontext(): 176f. now accepts
     context attributes via keyword arguments

   - bpo-43323(87): Fix errors in the *note email: 32. module if the
     charset itself contains undecodable/unencodable characters.

   - bpo-46841(88): Disassembly of quickened code.

   - bpo-46681(89): Forward gzip.compress() compresslevel to zlib.

   - bpo-45100(90): Add *note typing.get_overloads(): 67a. and *note
     typing.clear_overloads(): 67b.  Patch by Jelle Zijlstra.

   - bpo-44807(91): *note typing.Protocol: 245. no longer silently
     replaces ‘__init__()’ methods defined on subclasses.  Patch by
     Adrian Garcia Badaracco.

   - bpo-46787(92): Fix *note concurrent.futures.ProcessPoolExecutor:
     8bc. exception memory leak

   - bpo-46720(93): Add support for path-like objects to *note
     multiprocessing.set_executable(): 1770. for Windows to be on a par
     with Unix-like systems.  Patch by Géry Ogam.

   - bpo-46696(94): Add ‘SO_INCOMING_CPU’ constant to *note socket: b8.

   - bpo-46053(95): Fix OSS audio support on NetBSD.

   - bpo-45639(96): ‘image/avif’ and ‘image/webp’ were added to *note
     mimetypes: 82.

   - bpo-46285(97): Add command-line option ‘-p’/‘--protocol’ to module
     *note http.server: 68. which specifies the HTTP version to which
     the server is conformant (HTTP/1.1 conformant servers can now be
     run from the command-line interface of module *note http.server:
     68.).  Patch by Géry Ogam.

   - bpo-44791(98): Accept ellipsis as the last argument of *note
     typing.Concatenate: 78f.

   - bpo-46547(99): Remove variables leaking into ‘pydoc.Helper’ class
     namespace.

   - bpo-46415(100): Fix ipaddress.ip_{address,interface,network}
     raising TypeError instead of ValueError if given invalid tuple as
     address parameter.

   - bpo-46075(101): ‘CookieJar’ with ‘DefaultCookiePolicy’ now can
     process cookies from localhost with domain=localhost explicitly
     specified in Set-Cookie header.

   - bpo-45995(102): Add a "z" option to the string formatting
     specification that coerces negative zero floating-point values to
     positive zero after rounding to the format precision.  Contributed
     by John Belmonte.

   - bpo-26175(103): Fully implement the *note io.BufferedIOBase: 660.
     or *note io.TextIOBase: 661. interface for *note
     tempfile.SpooledTemporaryFile: 65f. objects.  This lets them work
     correctly with higher-level layers (like compression modules).
     Patch by Carey Metcalfe.

   - bpo-45138(104): Fix a regression in the *note sqlite3: ba. trace
     callback where bound parameters were not expanded in the passed
     statement string.  The regression was introduced in Python 3.10 by
     bpo-40318(105).  Patch by Erlend E. Aasland.

   - bpo-44863(106): Allow *note TypedDict: 148. subclasses to also
     include *note Generic: 157c. as a base class in class based syntax.
     Thereby allowing the user to define a generic ‘TypedDict’, just
     like a user-defined generic but with ‘TypedDict’ semantics.

   - bpo-44587(107): Fix BooleanOptionalAction to not automatically add
     a default string.  If a default string is desired, use a formatter
     to add it.

   - bpo-43827(108): All positional-or-keyword parameters to
     ‘ABCMeta.__new__’ are now positional-only to avoid conflicts with
     keyword arguments to be passed to ‘__init_subclass__()’.

   - bpo-43218(109): Prevent creation of a venv whose path contains the
     PATH separator.  This could affect the usage of the activate
     script.  Patch by Dustin Rodrigues.

   - bpo-38435(110): Add a ‘process_group’ parameter to *note
     subprocess.Popen: 17e. to help move more things off of the unsafe
     ‘preexec_fn’ parameter.

   - bpo-42066(111): Fix cookies getting sorted in
     ‘CookieJar.__iter__()’ which is an extra behavior and not mentioned
     in RFC 2965 or Netscape cookie protocol.  Now the cookies in
     ‘CookieJar’ follows the order of the ‘Set-Cookie’ header.  Patch by
     Iman Kermani.

   - bpo-40617(112): Add *note create_window_function(): 64c. to *note
     sqlite3.Connection: 226. for creating aggregate window functions.
     Patch by Erlend E. Aasland.

   - bpo-40676(113): Convert *note csv: 21. to use Argument Clinic for
     *note csv.field_size_limit(): 1771, *note csv.get_dialect(): 1772,
     *note csv.unregister_dialect(): 1773. and *note
     csv.list_dialects(): 1774.

   - bpo-39716(114): Raise an ‘ArgumentError’ when the same subparser
     name is added twice to an ‘argparse.ArgumentParser’.  This is
     consistent with the (default) behavior when the same option string
     is added twice to an ‘ArgumentParser’.

   - bpo-36073(115): Raise *note ProgrammingError: 4bf. instead of
     segfaulting on recursive usage of cursors in *note sqlite3: ba.
     converters.  Patch by Sergey Fedoseev.

   - bpo-34975(116): Adds a ‘start_tls()’ method to ‘StreamWriter’,
     which upgrades the connection with TLS using the given *note
     SSLContext: 274.

   - bpo-22276(117): *note Path: 20a. methods *note glob(): 20e. and
     *note rglob(): 20f. return only directories if 'pattern' ends with
     a pathname components separator (‘/’ or *note sep: 636.).  Patch by
     Eisuke Kawashima.

   - bpo-24905(118): Add *note blobopen(): 64d. to *note
     sqlite3.Connection: 226.  *note sqlite3.Blob: 64e. allows
     incremental I/O operations on blobs.  Patch by Aviv Palivoda and
     Erlend E. Aasland.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/87901

   (2) https://github.com/python/cpython/issues/90997

   (3) https://github.com/python/cpython/issues/92332

   (4) https://github.com/python/cpython/issues/92356

   (5) https://github.com/python/cpython/issues/90997

   (6) https://github.com/python/cpython/issues/92301

   (7) https://github.com/python/cpython/issues/67248

   (8) https://github.com/python/cpython/issues/92210

   (9) https://github.com/python/cpython/issues/80010

   (10) https://github.com/python/cpython/issues/92118

   (11) https://github.com/python/cpython/issues/90887

   (12) https://github.com/python/cpython/issues/91215

   (13) https://github.com/python/cpython/issues/85984

   (14) https://github.com/python/cpython/issues/92128

   (15) https://github.com/python/cpython/issues/92049

   (16) https://github.com/python/cpython/issues/92062

   (17) https://github.com/python/cpython/issues/87390

   (18) https://github.com/python/cpython/issues/88089

   (19) https://github.com/python/cpython/issues/91996

   (20) https://github.com/python/cpython/issues/91984

   (21) https://github.com/python/cpython/issues/91952

   (22) https://github.com/python/cpython/issues/91954

   (23) https://bugs.python.org/issue?@action=redirect&bpo=47029

   (24) https://github.com/python/cpython/issues/91928

   (25) https://github.com/python/cpython/issues/68966

   (26) https://peps.python.org/pep-0594/

   (27) https://github.com/python/cpython/issues/91401

   (28) https://github.com/python/cpython/issues/64783

   (29) https://github.com/python/cpython/issues/91910

   (30) https://github.com/python/cpython/issues/91860

   (31) https://peps.python.org/pep-0681/

   (32) https://github.com/python/cpython/issues/91832

   (33) https://github.com/python/cpython/issues/91827

   (34) https://github.com/python/cpython/issues/84461

   (35) https://github.com/python/cpython/issues/91821

   (36) https://github.com/python/cpython/issues/91217

   (37) https://github.com/python/cpython/issues/91217

   (38) https://github.com/python/cpython/issues/91760

   (39) https://github.com/python/cpython/issues/84461

   (40) https://github.com/python/cpython/issues/90623

   (41) https://github.com/python/cpython/issues/91734

   (42) https://github.com/python/cpython/issues/90633

   (43) https://github.com/python/cpython/issues/91700

   (44) https://github.com/python/cpython/issues/91231

   (45) https://github.com/python/cpython/issues/91621

   (46) https://github.com/python/cpython/issues/90568

   (47) https://github.com/python/cpython/issues/91670

   (48) https://github.com/python/cpython/issues/91217

   (49) https://github.com/python/cpython/issues/91217

   (50) https://github.com/python/cpython/issues/91217

   (51) https://github.com/python/cpython/issues/91217

   (52) https://github.com/python/cpython/issues/91616

   (53) https://github.com/python/cpython/issues/91217

   (54) https://github.com/python/cpython/issues/91217

   (55) https://bugs.python.org/issue?@action=redirect&bpo=47256

   (56) https://github.com/python/cpython/issues/91217

   (57) https://github.com/python/cpython/issues/91595

   (58) https://github.com/python/cpython/issues/74166

   (59) https://github.com/python/cpython/issues/91487

   (60) https://github.com/python/cpython/issues/91575

   (61) https://github.com/python/cpython/issues/90622

   (62) https://github.com/python/cpython/issues/89022

   (63) https://github.com/python/cpython/issues/91526

   (64) https://github.com/python/cpython/issues/88116

   (65) https://peps.python.org/pep-0657/

   (66) https://github.com/python/cpython/issues/69093

   (67) https://github.com/python/cpython/issues/69093

   (68) https://github.com/python/cpython/issues/91217

   (69) https://github.com/python/cpython/issues/91217

   (70) https://github.com/python/cpython/issues/91404

   (71) https://github.com/python/cpython/issues/91217

   (72) https://github.com/python/cpython/issues/91217

   (73) https://github.com/python/cpython/issues/91276

   (74) https://bugs.python.org/issue?@action=redirect&bpo=47000

   (75) https://github.com/python/cpython/issues/91230

   (76) https://github.com/python/cpython/issues/91217

   (77) https://bugs.python.org/issue?@action=redirect&bpo=47260

   (78) https://bugs.python.org/issue?@action=redirect&bpo=47087

   (79) https://peps.python.org/pep-0655/

   (80) https://bugs.python.org/issue?@action=redirect&bpo=47061

   (81) https://bugs.python.org/issue?@action=redirect&bpo=47061

   (82) https://bugs.python.org/issue?@action=redirect&bpo=47000

   (83) https://bugs.python.org/issue?@action=redirect&bpo=42012

   (84) https://bugs.python.org/issue?@action=redirect&bpo=47227

   (85) https://bugs.python.org/issue?@action=redirect&bpo=47211

   (86) https://bugs.python.org/issue?@action=redirect&bpo=47135

   (87) https://bugs.python.org/issue?@action=redirect&bpo=43323

   (88) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (89) https://bugs.python.org/issue?@action=redirect&bpo=46681

   (90) https://bugs.python.org/issue?@action=redirect&bpo=45100

   (91) https://bugs.python.org/issue?@action=redirect&bpo=44807

   (92) https://bugs.python.org/issue?@action=redirect&bpo=46787

   (93) https://bugs.python.org/issue?@action=redirect&bpo=46720

   (94) https://bugs.python.org/issue?@action=redirect&bpo=46696

   (95) https://bugs.python.org/issue?@action=redirect&bpo=46053

   (96) https://bugs.python.org/issue?@action=redirect&bpo=45639

   (97) https://bugs.python.org/issue?@action=redirect&bpo=46285

   (98) https://bugs.python.org/issue?@action=redirect&bpo=44791

   (99) https://bugs.python.org/issue?@action=redirect&bpo=46547

   (100) https://bugs.python.org/issue?@action=redirect&bpo=46415

   (101) https://bugs.python.org/issue?@action=redirect&bpo=46075

   (102) https://bugs.python.org/issue?@action=redirect&bpo=45995

   (103) https://bugs.python.org/issue?@action=redirect&bpo=26175

   (104) https://bugs.python.org/issue?@action=redirect&bpo=45138

   (105) https://bugs.python.org/issue?@action=redirect&bpo=40318

   (106) https://bugs.python.org/issue?@action=redirect&bpo=44863

   (107) https://bugs.python.org/issue?@action=redirect&bpo=44587

   (108) https://bugs.python.org/issue?@action=redirect&bpo=43827

   (109) https://bugs.python.org/issue?@action=redirect&bpo=43218

   (110) https://bugs.python.org/issue?@action=redirect&bpo=38435

   (111) https://bugs.python.org/issue?@action=redirect&bpo=42066

   (112) https://bugs.python.org/issue?@action=redirect&bpo=40617

   (113) https://bugs.python.org/issue?@action=redirect&bpo=40676

   (114) https://bugs.python.org/issue?@action=redirect&bpo=39716

   (115) https://bugs.python.org/issue?@action=redirect&bpo=36073

   (116) https://bugs.python.org/issue?@action=redirect&bpo=34975

   (117) https://bugs.python.org/issue?@action=redirect&bpo=22276

   (118) https://bugs.python.org/issue?@action=redirect&bpo=24905


File: python.info,  Node: Documentation<18>,  Next: Tests<21>,  Prev: Library<23>,  Up: Python 3 11 0 beta 1

1.23.24.4 Documentation
.......................

   - gh-91888(1): Add a new ‘gh’ role to the documentation to link to
     GitHub issues.

   - gh-91783(2): Document security issues concerning the use of the
     function *note shutil.unpack_archive(): 438.

   - gh-91547(3): Remove "Undocumented modules" page.

   - gh-91298(4): In ‘importlib.resources.abc’, refined the
     documentation of the Traversable Protocol, applying changes from
     importlib_resources 5.7.1.

   - bpo-44347(5): Clarify the meaning of 'dirs_exist_ok', a kwarg of
     *note shutil.copytree(): 9f7.

   - bpo-36329(6): Remove 'make -C Doc serve' in favour of 'make -C Doc
     htmlview'

   - bpo-47189(7): Add a What's New in Python 3.11 entry for the Faster
     CPython project.  Documentation by Ken Jin and Kumar Aditya.

   - bpo-38668(8): Update the introduction to documentation for *note
     os.path: 92. to remove warnings that became irrelevant after the
     implementations of PEP 383(9) and PEP 529(10).

   - bpo-47115(11): The documentation now lists which members of C
     structs are part of the *note Limited API/Stable ABI: 51e.

   - bpo-46962(12): All docstrings in code snippets are now wrapped into
     *note PyDoc_STR: 1776. to follow the guideline of PEP 7's
     Documentation Strings paragraph(13).  Patch by Oleg Iarygin.

   - bpo-26792(14): Improve the docstrings of *note runpy.run_module():
     1777. and *note runpy.run_path(): 166.  Original patch by Andrew
     Brezovsky.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/91888

   (2) https://github.com/python/cpython/issues/91783

   (3) https://github.com/python/cpython/issues/91547

   (4) https://github.com/python/cpython/issues/91298

   (5) https://bugs.python.org/issue?@action=redirect&bpo=44347

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36329

   (7) https://bugs.python.org/issue?@action=redirect&bpo=47189

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38668

   (9) https://peps.python.org/pep-0383/

   (10) https://peps.python.org/pep-0529/

   (11) https://bugs.python.org/issue?@action=redirect&bpo=47115

   (12) https://bugs.python.org/issue?@action=redirect&bpo=46962

   (13) https://peps.python.org/pep-0007/#documentation-strings

   (14) https://bugs.python.org/issue?@action=redirect&bpo=26792


File: python.info,  Node: Tests<21>,  Next: Build<23>,  Prev: Documentation<18>,  Up: Python 3 11 0 beta 1

1.23.24.5 Tests
...............

   - gh-92169(1): Use ‘warnings_helper.import_deprecated()’ to import
     deprecated modules uniformly in tests.  Patch by Hugo van Kemenade.

   - gh-84461(2): When multiprocessing is enabled, libregrtest can now
     use a Python executable other than ‘sys.executable’ via the
     ‘--python’ flag.

   - gh-91904(3): Fix initialization of ‘PYTHONREGRTEST_UNICODE_GUARD’
     which prevented running regression tests on non-UTF-8 locale.

   - gh-91752(4): Added @requires_zlib to
     test.test_tools.test_freeze.TestFreeze.

   - gh-91607(5): Fix ‘test_concurrent_futures’ to test the correct
     multiprocessing start method context in several cases where the
     test logic mixed this up.

   - bpo-40280(6): Threading tests are now skipped on WASM targets
     without pthread support.

   - bpo-47109(7): Test for ‘ctypes.macholib.dyld’,
     ‘ctypes.macholib.dylib’, and ‘ctypes.macholib.framework’ are
     brought from manual pre-*note unittest: ef. times to ‘ctypes.test’
     location and structure.  Patch by Oleg Iarygin.

   - bpo-29890(8): Add tests for *note ipaddress.IPv4Interface: 1779.
     and *note ipaddress.IPv6Interface: 177a. construction with tuple
     arguments.  Original patch and tests by louisom.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92169

   (2) https://github.com/python/cpython/issues/84461

   (3) https://github.com/python/cpython/issues/91904

   (4) https://github.com/python/cpython/issues/91752

   (5) https://github.com/python/cpython/issues/91607

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (7) https://bugs.python.org/issue?@action=redirect&bpo=47109

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29890


File: python.info,  Node: Build<23>,  Next: Windows<20>,  Prev: Tests<21>,  Up: Python 3 11 0 beta 1

1.23.24.6 Build
...............

   - gh-89452(1): gdbm-compat is now preferred over ndbm if both are
     available on the system.  This allows avoiding the problematic
     ndbm.h on macOS.

   - gh-91731(2): Python is now built with ‘-std=c11’ compiler option,
     rather than ‘-std=c99’.  Patch by Victor Stinner.

   - bpo-47152(3): Add script and make target for generating
     ‘sre_constants.h’.

   - bpo-47103(4): Windows ‘PGInstrument’ builds now copy a required DLL
     into the output directory, making it easier to run the profile
     stage of a PGO build.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/89452

   (2) https://github.com/python/cpython/issues/91731

   (3) https://bugs.python.org/issue?@action=redirect&bpo=47152

   (4) https://bugs.python.org/issue?@action=redirect&bpo=47103


File: python.info,  Node: Windows<20>,  Next: macOS<16>,  Prev: Build<23>,  Up: Python 3 11 0 beta 1

1.23.24.7 Windows
.................

   - bpo-46907(1): Update Windows installer to use SQLite 3.38.3.

   - bpo-47239(2): Fixed -list and -list-paths output for *note Windows
     の Python ランチャ: 588. when used in an active virtual
     environment.

   - bpo-46907(3): Update Windows installer to use SQLite 3.38.2.

   - bpo-46785(4): Fix race condition between *note os.stat(): 46d. and
     unlinking a file on Windows, by using errors codes returned by
     ‘FindFirstFileW()’ when appropriate in ‘win32_xstat_impl’.

   - bpo-40859(5): Update Windows build to use xz-5.2.5

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46907

   (2) https://bugs.python.org/issue?@action=redirect&bpo=47239

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46907

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46785

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40859


File: python.info,  Node: macOS<16>,  Next: Tools/Demos<12>,  Prev: Windows<20>,  Up: Python 3 11 0 beta 1

1.23.24.8 macOS
...............

   - bpo-46907(1): Update macOS installer to SQLite 3.38.4.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46907


File: python.info,  Node: Tools/Demos<12>,  Next: C API<22>,  Prev: macOS<16>,  Up: Python 3 11 0 beta 1

1.23.24.9 Tools/Demos
.....................

   - gh-91583(1): Fix regression in the code generated by Argument
     Clinic for functions with the ‘defining_class’ parameter.

   - gh-91575(2): Add script ‘Tools/scripts/generate_re_casefix.py’ and
     the make target ‘regen-re’ for generating additional data for
     case-insensitive matching according to the current Unicode version.

   - gh-91551(3): Remove the ancient Pynche color editor.  It has moved
     to ‘https://gitlab.com/warsaw/pynche’

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/91583

   (2) https://github.com/python/cpython/issues/91575

   (3) https://github.com/python/cpython/issues/91551


File: python.info,  Node: C API<22>,  Prev: Tools/Demos<12>,  Up: Python 3 11 0 beta 1

1.23.24.10 C API
................

   - gh-88279(1): Deprecate the C functions: ‘PySys_SetArgv()’,
     ‘PySys_SetArgvEx()’, ‘PySys_SetPath()’.  Patch by Victor Stinner.

   - gh-92154(2): Added the *note PyCode_GetCode(): 743. function.  This
     function does the equivalent of the Python code
     ‘getattr(code_object, 'co_code')’.

   - gh-92173(3): Fix the ‘closure’ argument to *note
     PyEval_EvalCodeEx(): 16d4.

   - gh-91320(4): Fix C++ compiler warnings about "old-style cast" (‘g++
     -Wold-style-cast’) in the Python C API. Use C++
     ‘reinterpret_cast<>’ and ‘static_cast<>’ casts when the Python C
     API is used in C++.  Patch by Victor Stinner.

   - gh-80527(5): Mark functions as deprecated by PEP 623(6):
     ‘PyUnicode_AS_DATA()’, ‘PyUnicode_AS_UNICODE()’,
     ‘PyUnicode_GET_DATA_SIZE()’, ‘PyUnicode_GET_SIZE()’.  Patch by
     Victor Stinner.

   - gh-91768(7): *note Py_REFCNT(): 877, *note Py_TYPE(): 74b, *note
     Py_SIZE(): 74d. and *note Py_IS_TYPE(): 1780. functions argument
     type is now ‘PyObject*’, rather than ‘const PyObject*’.  Patch by
     Victor Stinner.

   - gh-91020(8): Add ‘PyBytes_Type.tp_alloc’ to initialize
     ‘PyBytesObject.ob_shash’ for bytes subclasses.

   - bpo-40421(9): Add ‘PyFrame_GetLasti’ C-API function to access frame
     object's ‘f_lasti’ attribute safely from C code.

   - bpo-35134(10): Remove the ‘Include/code.h’ header file.  C
     extensions should only include the main ‘<Python.h>’ header file.
     Patch by Victor Stinner.

   - bpo-47169(11): *note PyOS_CheckStack(): 1781. is now exported in
     the Stable ABI on Windows.

   - bpo-47169(12): ‘PyThread_get_thread_native_id()’ is excluded from
     the stable ABI on platforms where it doesn't exist (like Solaris).

   - bpo-46343(13): Added *note PyErr_GetHandledException(): 73a. and
     *note PyErr_SetHandledException(): 73b. as simpler alternatives to
     *note PyErr_GetExcInfo(): 73d. and *note PyErr_SetExcInfo(): 73c.

     They are included in the stable ABI.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/88279

   (2) https://github.com/python/cpython/issues/92154

   (3) https://github.com/python/cpython/issues/92173

   (4) https://github.com/python/cpython/issues/91320

   (5) https://github.com/python/cpython/issues/80527

   (6) https://peps.python.org/pep-0623/

   (7) https://github.com/python/cpython/issues/91768

   (8) https://github.com/python/cpython/issues/91020

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40421

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (11) https://bugs.python.org/issue?@action=redirect&bpo=47169

   (12) https://bugs.python.org/issue?@action=redirect&bpo=47169

   (13) https://bugs.python.org/issue?@action=redirect&bpo=46343


File: python.info,  Node: Python 3 11 0 alpha 7,  Next: Python 3 11 0 alpha 6,  Prev: Python 3 11 0 beta 1,  Up: 変更履歴

1.23.25 Python 3.11.0 alpha 7
-----------------------------

'Release date: 2022-04-05'

* Menu:

* Core and Builtins: Core and Builtins<25>.
* Library: Library<24>.
* Documentation: Documentation<19>.
* Tests: Tests<22>.
* Build: Build<24>.
* Windows: Windows<21>.
* macOS: macOS<17>.
* Tools/Demos: Tools/Demos<13>.
* C API: C API<23>.


File: python.info,  Node: Core and Builtins<25>,  Next: Library<24>,  Up: Python 3 11 0 alpha 7

1.23.25.1 Core and Builtins
...........................

   - bpo-47212(1): Raise *note IndentationError: 773. instead of *note
     SyntaxError: 172. for a bare ‘except’ with no following indent.
     Improve *note SyntaxError: 172. locations for an un-parenthesized
     generator used as arguments.  Patch by Matthieu Dartiailh.

   - bpo-47186(2): Replace ‘JUMP_IF_NOT_EG_MATCH’ by *note
     CHECK_EG_MATCH: 6cd. + jump.

   - bpo-47176(3): Emscripten builds cannot handle signals in the usual
     way due to platform limitations.  Python can now handle signals.
     To use, set Module.Py_EmscriptenSignalBuffer to be a single byte
     SharedArrayBuffer and set Py_EMSCRIPTEN_SIGNAL_HANDLING to 1.
     Writing a number into the SharedArrayBuffer will cause the
     corresponding signal to be raised into the Python thread.

   - bpo-47186(4): Replace ‘JUMP_IF_NOT_EXC_MATCH’ by *note
     CHECK_EXC_MATCH: 6d6. + jump.

   - bpo-47120(5): Replace the absolute jump opcode *note
     JUMP_NO_INTERRUPT: 1784. by the relative *note
     JUMP_BACKWARD_NO_INTERRUPT: 6ca.

   - bpo-46841(6): Avoid unnecessary allocations when comparing code
     objects.

   - bpo-47182(7): Fix a crash when using a named unicode character like
     ‘"\N{digit nine}"’ after the main interpreter has been initialized
     a second time.

   - bpo-47162(8): WebAssembly cannot deal with bad function pointer
     casts (different count or types of arguments).  Python can now use
     call trampolines to mitigate the problem.  Define
     ‘PY_CALL_TRAMPOLINE’ to enable call trampolines.

   - bpo-46775(9): Some Windows system error codes(>= 10000) are now
     mapped into the correct errno and may now raise a subclass of *note
     OSError: 3f0.  Patch by Donghee Na.

   - bpo-47129(10): Improve error messages in f-string syntax errors
     concerning empty expressions.

   - bpo-47117(11): Fix a crash if we fail to decode characters in
     interactive mode if the tokenizer buffers are uninitialized.  Patch
     by Pablo Galindo.

   - bpo-47127(12): Speed up calls to c functions with keyword arguments
     by 25% with specialization.  Patch by Kumar Aditya.

   - bpo-47120(13): Replaced ‘JUMP_ABSOLUTE’ by the relative jump *note
     JUMP_BACKWARD: 6d7.

   - bpo-42197(14): ‘PyFrame_FastToLocalsWithError()’ and
     ‘PyFrame_LocalsToFast()’ are no longer called during profiling nor
     tracing.  C code can access the ‘f_locals’ attribute of *note
     PyFrameObject: 754. by calling *note PyFrame_GetLocals(): 3f8.

   - bpo-47070(15): Improve performance of ‘array_inplace_repeat’ by
     reducing the number of invocations of ‘memcpy’.  Refactor the
     ‘repeat’ and inplace ‘repeat’ methods of ‘array’, ‘bytes’,
     ‘bytearray’ and ‘unicodeobject’ to use the common
     ‘_PyBytes_Repeat’.

   - bpo-47053(16): Reduce de-optimization in the specialized
     ‘BINARY_OP_INPLACE_ADD_UNICODE’ opcode.

   - bpo-47045(17): Remove the ‘f_state’ field from the
     _PyInterpreterFrame struct.  Add the ‘owner’ field to the
     _PyInterpreterFrame struct to make ownership explicit to simplify
     clearing and deallocing frames and generators.

   - bpo-46968(18): Check for the existence of the "sys/auxv.h" header
     in *note faulthandler: 4e. to avoid compilation problems in systems
     where this header doesn't exist.  Patch by Pablo Galindo

   - bpo-46329(19): Use low bit of ‘LOAD_GLOBAL’ to indicate whether to
     push a ‘NULL’ before the global.  Helps streamline the call
     sequence a bit.

   - bpo-46841(20): Quicken bytecode in-place by storing it as part of
     the corresponding ‘PyCodeObject’.

   - bpo-47012(21): Speed up iteration of *note bytes: 1a4. and *note
     bytearray: 508. by 30%.  Patch by Kumar Aditya.

   - bpo-47009(22): Improved the performance of ‘list.append()’ and list
     comprehensions by optimizing for the common case, where no resize
     is needed.  Patch by Dennis Sweeney.

   - bpo-47005(23): Improve performance of ‘bytearray_repeat’ and
     ‘bytearray_irepeat’ by reducing the number of invocations of
     ‘memcpy’.

   - bpo-46829(24): Deprecate passing a message into *note
     asyncio.Future.cancel(): 1785. and *note asyncio.Task.cancel():
     19c.

   - bpo-46993(25): Speed up *note bytearray: 508. creation from *note
     list: 5dc. and *note tuple: 349. by 40%.  Patch by Kumar Aditya.

   - bpo-39829(26): Removed the ‘__len__()’ call when initializing a
     list and moved initializing to ‘list_extend’.  Patch by Jeremiah
     Pascual.

   - bpo-46944(27): Speed up throwing exception in generator with *note
     METH_FASTCALL: 158b. calling convention.  Patch by Kumar Aditya.

   - bpo-46841(28): Modify *note STORE_SUBSCR: 1786. to use an inline
     cache entry (rather than its oparg) as an adaptive counter.

   - bpo-46841(29): Use inline caching for ‘PRECALL’ and *note CALL:
     6d2, and remove the internal machinery for managing the (now
     unused) non-inline caches.

   - bpo-46881(30): Statically allocate and initialize the latin1
     characters.

   - bpo-46838(31): Improve syntax errors for incorrect function
     definitions.  Patch by Pablo Galindo

   - bpo-43721(32): Fix docstrings of *note getter: 15be, *note setter:
     15bf, and *note deleter: 15c0. to clarify that they create a new
     copy of the property.

   - bpo-43224(33): Make grammar changes required for PEP 646.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=47212

   (2) https://bugs.python.org/issue?@action=redirect&bpo=47186

   (3) https://bugs.python.org/issue?@action=redirect&bpo=47176

   (4) https://bugs.python.org/issue?@action=redirect&bpo=47186

   (5) https://bugs.python.org/issue?@action=redirect&bpo=47120

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (7) https://bugs.python.org/issue?@action=redirect&bpo=47182

   (8) https://bugs.python.org/issue?@action=redirect&bpo=47162

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46775

   (10) https://bugs.python.org/issue?@action=redirect&bpo=47129

   (11) https://bugs.python.org/issue?@action=redirect&bpo=47117

   (12) https://bugs.python.org/issue?@action=redirect&bpo=47127

   (13) https://bugs.python.org/issue?@action=redirect&bpo=47120

   (14) https://bugs.python.org/issue?@action=redirect&bpo=42197

   (15) https://bugs.python.org/issue?@action=redirect&bpo=47070

   (16) https://bugs.python.org/issue?@action=redirect&bpo=47053

   (17) https://bugs.python.org/issue?@action=redirect&bpo=47045

   (18) https://bugs.python.org/issue?@action=redirect&bpo=46968

   (19) https://bugs.python.org/issue?@action=redirect&bpo=46329

   (20) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (21) https://bugs.python.org/issue?@action=redirect&bpo=47012

   (22) https://bugs.python.org/issue?@action=redirect&bpo=47009

   (23) https://bugs.python.org/issue?@action=redirect&bpo=47005

   (24) https://bugs.python.org/issue?@action=redirect&bpo=46829

   (25) https://bugs.python.org/issue?@action=redirect&bpo=46993

   (26) https://bugs.python.org/issue?@action=redirect&bpo=39829

   (27) https://bugs.python.org/issue?@action=redirect&bpo=46944

   (28) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (29) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (30) https://bugs.python.org/issue?@action=redirect&bpo=46881

   (31) https://bugs.python.org/issue?@action=redirect&bpo=46838

   (32) https://bugs.python.org/issue?@action=redirect&bpo=43721

   (33) https://bugs.python.org/issue?@action=redirect&bpo=43224


File: python.info,  Node: Library<24>,  Next: Documentation<19>,  Prev: Core and Builtins<25>,  Up: Python 3 11 0 alpha 7

1.23.25.2 Library
.................

   - bpo-47208(1): Allow vendors to override ‘CTYPES_MAX_ARGCOUNT’.

   - bpo-23689(2): *note re: a7. module: fix memory leak when a match is
     terminated by a signal or memory allocation failure.  Patch by Ma
     Lin.

   - bpo-47167(3): Allow overriding a future compliance check in *note
     asyncio.Task: 4a5.

   - bpo-47151(4): When subprocess tries to use vfork, it now falls back
     to fork if vfork returns an error.  This allows use in situations
     where vfork isn't allowed by the OS kernel.

   - bpo-47152(5): Convert the *note re: a7. module into a package.
     Deprecate modules ‘sre_compile’, ‘sre_constants’ and ‘sre_parse’.

   - bpo-4833(6): Add ‘ZipFile.mkdir()’

   - bpo-27929(7): Fix *note asyncio.loop.sock_connect(): d97. to only
     resolve names for *note socket.AF_INET: 1788. or *note
     socket.AF_INET6: 1789. families.  Resolution may not make sense for
     other families, like ‘socket.AF_BLUETOOTH’ and *note
     socket.AF_UNIX: 178a.

   - bpo-14265(8): Adds the fully qualified test name to unittest output

   - bpo-47061(9): Deprecate the aifc module.

   - bpo-39622(10): Handle Ctrl+C in asyncio programs to interrupt the
     main task.

   - bpo-47101(11): *note hashlib.algorithms_available: 133c. now lists
     only algorithms that are provided by activated crypto providers on
     OpenSSL 3.0.  Legacy algorithms are not listed unless the legacy
     provider has been loaded into the default OSSL context.

   - bpo-47099(12): All ‘URLError’ exception messages raised in *note
     urllib.request.URLopener: 2e6. now contain a colon between ‘ftp
     error’ and the rest of the message.  Previously, ‘open_ftp()’
     missed the colon.  Patch by Oleg Iarygin.

   - bpo-47099(13): Exception chaining is changed from
     ‘Exception.with_traceback()’/*note sys.exc_info(): 656. to PEP
     3134(14).  Patch by Oleg Iarygin.

   - bpo-47095(15): *note hashlib: 5e.'s internal ‘_blake2’ module now
     prefers ‘libb2’ from ‘https://www.blake2.net/’ over Python's
     vendored copy of blake2.

   - bpo-47098(16): The Keccak Code Package for *note hashlib: 5e.'s
     internal ‘_sha3’ module has been replaced with tiny_sha3.  The
     module is used as fallback when Python is built without OpenSSL.

   - bpo-47088(17): Implement *note typing.LiteralString: 594, part of
     PEP 675(18).  Patch by Jelle Zijlstra.

   - bpo-42885(19): Optimize *note re.search(): 11fd, *note re.split():
     282, *note re.findall(): ff4, *note re.finditer(): 14a3. and *note
     re.sub(): 283. for regular expressions starting with ‘\A’ or ‘^’.

   - bpo-23691(20): Protect the *note re.finditer(): 14a3. iterator from
     re-entering.

   - bpo-47067(21): Optimize calling ‘GenericAlias’ objects by using PEP
     590(22) ‘vectorcall’ and by replacing ‘PyObject_SetAttrString’ with
     ‘PyObject_SetAttr’.

   - bpo-28080(23): Add the 'metadata_encoding' parameter in the *note
     zipfile.ZipFile: 690. constructor and the ‘--metadata-encoding’
     option in the *note zipfile: 117. CLI to allow reading zipfiles
     using non-standard codecs to encode the filenames within the
     archive.

   - bpo-47000(24): Make *note io.text_encoding(): 162c. returns "utf-8"
     when UTF-8 mode is enabled.

   - bpo-42369(25): Fix thread safety of ‘zipfile._SharedFile.tell()’ to
     avoid a "zipfile.BadZipFile: Bad CRC-32 for file" exception when
     reading a ‘ZipFile’ from multiple threads.

   - bpo-38256(26): Fix *note binascii.crc32(): 15fa. when it is
     compiled to use zlib'c crc32 to work properly on inputs 4+GiB in
     length instead of returning the wrong result.  The workaround prior
     to this was to always feed the function data in increments smaller
     than 4GiB or to just call the zlib module function.

     We also have *note binascii.crc32(): 15fa. release the GIL when
     computing on larger inputs as *note zlib.crc32(): 15f9. and *note
     hashlib: 5e. do.

     This also boosts performance on Windows as it now uses the zlib
     crc32 implementation for *note binascii.crc32(): 15fa. for a 2-3x
     speedup.

     That the stdlib has a crc32 API in two modules is a known
     historical oddity.  This moves us closer to a single implementation
     behind them.

   - bpo-47066(27): Global inline flags (e.g.  ‘(?i)’) can now only be
     used at the start of the regular expressions.  Using them not at
     the start of expression was deprecated since Python 3.6.

   - bpo-39394(28): A warning about inline flags not at the start of the
     regular expression now contains the position of the flag.

   - bpo-433030(29): Add support of atomic grouping (‘(?>...)’) and
     possessive quantifiers (‘*+’, ‘++’, ‘?+’, ‘{m,n}+’) in *note
     regular expressions: a7.

   - bpo-47062(30): Implement *note asyncio.Runner: 5cb. context
     manager.

   - bpo-46382(31): *note dataclass(): 1ad. ‘slots=True’ now correctly
     omits slots already defined in base classes.  Patch by Arie
     Bovenberg.

   - bpo-47057(32): Use FASTCALL convention for ‘FutureIter.throw()’

   - bpo-47061(33): Deprecate the various modules listed by PEP 594(34):

     aifc, asynchat, asyncore, audioop, cgi, cgitb, chunk, crypt,
     imghdr, msilib, nntplib, nis, ossaudiodev, pipes, smtpd, sndhdr,
     spwd, sunau, telnetlib, uu, xdrlib

   - bpo-34790(35): Remove passing coroutine objects to *note
     asyncio.wait(): 44c.

   - bpo-47039(36): Normalize ‘repr()’ of asyncio future and task
     objects.

   - bpo-2604(37): Fix bug where doctests using globals would fail when
     run multiple times.

   - bpo-45150(38): Add *note hashlib.file_digest(): 610. helper for
     efficient hashing of file object.

   - bpo-34861(39): Made cumtime the default sorting key for cProfile

   - bpo-45997(40): Fix *note asyncio.Semaphore: a42. re-aquiring FIFO
     order.

   - bpo-47022(41): The ‘asynchat’, ‘asyncore’ and ‘smtpd’ modules have
     been deprecated since at least Python 3.6.  Their documentation and
     deprecation warnings and have now been updated to note they will
     removed in Python 3.12 ( PEP 594(42)).

   - bpo-43253(43): Fix a crash when closing transports where the
     underlying socket handle is already invalid on the Proactor event
     loop.

   - bpo-40280(44): *note select.select(): d6d. now passes ‘NULL’ to
     ‘select’ for each empty fdset.

   - bpo-47004(45): Apply bugfixes from importlib_metadata 4.11.3,
     including bugfix for EntryPoint.extras, which was returning match
     objects and not the extras strings.

   - bpo-46998(46): Allow subclassing of *note typing.Any: 678.  Patch
     by Shantanu Jain.

   - bpo-46995(47): Deprecate missing *note asyncio.Task.set_name():
     9ab. for third-party task implementations, schedule making it
     mandatory in Python 3.13.

   - bpo-46994(48): Accept explicit contextvars.Context in *note
     asyncio.create_task(): 5c7. and *note asyncio.loop.create_task():
     9aa.

   - bpo-46981(49): ‘typing.get_args(typing.Tuple[()])’ now returns ‘()’
     instead of ‘((),)’.

   - bpo-46968(50): Add ‘os.sysconf_names['SC_MINSIGSTKSZ']’.

   - bpo-46985(51): Upgrade pip wheel bundled with ensurepip (pip
     22.0.4)

   - bpo-46968(52): *note faulthandler: 4e.: On Linux 5.14 and newer,
     dynamically determine size of signal handler stack size CPython
     allocates using ‘getauxval(AT_MINSIGSTKSZ)’.  This changes allows
     for Python extension's request to Linux kernel to use AMX_TILE
     instruction set on Sapphire Rapids Xeon processor to succeed,
     unblocking use of the ISA in frameworks.

   - bpo-46917(53): The *note math.nan: 62f. value is now always
     available.  Patch by Victor Stinner.

   - bpo-46955(54): Expose ‘asyncio.base_events.Server’ as *note
     asyncio.Server: ae0.  Patch by Stefan Zabka.

   - bpo-23325(55): The *note signal: b4. module no longer assumes that
     *note SIG_IGN: 178b. and *note SIG_DFL: 178c. are small int
     singletons.

   - bpo-46932(56): Update bundled libexpat to 2.4.7

   - bpo-46933(57): The *note pwd: a0. module is now optional.  *note
     os.path.expanduser(): 9e2. returns the path when the *note pwd: a0.
     module is not available.

   - bpo-40059(58): PEP 680(59), the *note tomllib: e5. module.  Adds
     support for parsing TOML.

   - bpo-464471(60): *note asyncio.timeout(): 5c9. and *note
     asyncio.timeout_at(): 178d. context managers added.  Patch by Tin
     Tvrtković and Andrew Svetlov.

   - bpo-46805(61): Added raw datagram socket functions for asyncio:
     ‘sock_sendto()’, ‘sock_recvfrom()’ and ‘sock_recvfrom_into()’.

   - bpo-46644(62): No longer require valid typeforms to be callable.
     This allows *note typing.Annotated: 90b. to wrap *note
     typing.ParamSpecArgs: 791. and ‘dataclasses.InitVar’.  Patch by
     Gregory Beauregard.

   - bpo-46581(63): Brings ‘ParamSpec’ propagation for ‘GenericAlias’ in
     line with ‘Concatenate’ (and others).

   - bpo-45413(64): Define 'posix_venv' and 'nt_venv' *note sysconfig
     installation schemes: 65b. to be used for bootstrapping new virtual
     environments.  Add 'venv' sysconfig installation scheme to get the
     appropriate one of the above.  The schemes are identical to the
     pre-existing 'posix_prefix' and 'nt' install schemes.  The *note
     venv: f9. module now uses the 'venv' scheme to create new virtual
     environments instead of hardcoding the paths depending only on the
     platform.  Downstream Python distributors customizing the
     'posix_prefix' or 'nt' install scheme in a way that is not
     compatible with the install scheme used in virtual environments are
     encouraged not to customize the 'venv' schemes.  When Python itself
     runs in a virtual environment, *note
     sysconfig.get_default_scheme(): 178e. and *note
     sysconfig.get_preferred_scheme(): 65c. with ‘key="prefix"’ returns
     'venv'.

   - bpo-43224(65): Implement support for PEP 646 in typing.py.

   - bpo-43224(66): Allow unpacking types.GenericAlias objects, e.g.
     ‘*tuple[int, str]’.

   - bpo-46557(67): Warnings captured by the logging module are now
     logged without a format string to prevent systems that group logs
     by the msg argument from grouping captured warnings together.

   - bpo-41370(68): *note typing.get_type_hints(): 67d. now supports
     evaluating strings as forward references in *note PEP 585 generic
     aliases: 67e.

   - bpo-46607(69): Add *note DeprecationWarning: 18a. to
     ‘LegacyInterpolation’, deprecated in the docstring since Python
     3.2.  Will be removed in Python 3.13.  Use ‘BasicInterpolation’ or
     ‘ExtendedInterpolation’ instead.

   - bpo-26120(70): *note pydoc: a3. now excludes __future__ imports
     from the module's data items.

   - bpo-46480(71): Add *note typing.assert_type(): 677.  Patch by Jelle
     Zijlstra.

   - bpo-46421(72): Fix a unittest issue where if the command was
     invoked as ‘python -m unittest’ and the filename(s) began with a
     dot (.), a ‘ValueError’ is returned.

   - bpo-46245(73): Add optional parameter 'dir_fd' in *note
     shutil.rmtree(): 2d8.

   - bpo-22859(74): ‘unittest.TestProgram.usageExit()’ is marked as
     deprecated, to be removed in Python 3.13.

   - bpo-46170(75): Improve the error message when you try to subclass
     an instance of *note typing.NewType: cc3.

   - bpo-40296(76): Fix supporting generic aliases in *note pydoc: a3.

   - bpo-20392(77): Fix inconsistency with uppercase file extensions in
     ‘MimeTypes.guess_type()’.  Patch by Kumar Aditya.

   - bpo-46030(78): Add ‘LOCAL_CREDS’, ‘LOCAL_CREDS_PERSISTENT’ and
     ‘SCM_CREDS2’ FreeBSD constants to the socket module.

   - bpo-44439(79): Fix ‘.write()’ method of a member file in ‘ZipFile’,
     when the input data is an object that supports the buffer protocol,
     the file length may be wrong.

   - bpo-45171(80): Fix handling of the ‘stacklevel’ argument to logging
     functions in the *note logging: 7b. module so that it is consistent
     across all logging functions and, as advertised, similar to the
     ‘stacklevel’ argument used in *note warn(): 14c3.

   - bpo-24959(81): Fix bug where *note unittest: ef. sometimes drops
     frames from tracebacks of exceptions raised in tests.

   - bpo-44859(82): Raise more accurate and PEP 249(83) compatible
     exceptions in *note sqlite3: ba.

        * Raise *note InterfaceError: 649. instead of *note
          ProgrammingError: 4bf. for ‘SQLITE_MISUSE’ errors.

        * Don't overwrite *note BufferError: 178f. with *note
          ValueError: 1e3. when conversion to BLOB fails.

        * Raise *note ProgrammingError: 4bf. instead of *note Warning:
          1790. if user tries to *note execute(): 2b2. more than one SQL
          statement.

        * Raise *note ProgrammingError: 4bf. instead of *note
          ValueError: 1e3. if an SQL query contains null characters.

   - bpo-44493(84): Add missing terminated NUL in sockaddr_un's length

     This was potentially observable when using non-abstract AF_UNIX
     datagram sockets to processes written in another programming
     language.

   - bpo-41930(85): Add *note serialize(): 64a. and *note deserialize():
     64b. support to *note sqlite3: ba.  Patch by Erlend E. Aasland.

   - bpo-33178(86): Added *note ctypes.BigEndianUnion: 1791. and *note
     ctypes.LittleEndianUnion: 1792. classes, as originally documented
     in the library docs but not yet implemented.

   - bpo-43352(87): Add an Barrier object in synchronization primitives
     of 'asyncio' Lib in order to be consistent with Barrier from
     'threading' and 'multiprocessing' libs*

   - bpo-35859(88): *note re: a7. module, fix a few bugs about capturing
     group.  In rare cases, capturing group gets an incorrect string.
     Patch by Ma Lin.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=47208

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23689

   (3) https://bugs.python.org/issue?@action=redirect&bpo=47167

   (4) https://bugs.python.org/issue?@action=redirect&bpo=47151

   (5) https://bugs.python.org/issue?@action=redirect&bpo=47152

   (6) https://bugs.python.org/issue?@action=redirect&bpo=4833

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27929

   (8) https://bugs.python.org/issue?@action=redirect&bpo=14265

   (9) https://bugs.python.org/issue?@action=redirect&bpo=47061

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39622

   (11) https://bugs.python.org/issue?@action=redirect&bpo=47101

   (12) https://bugs.python.org/issue?@action=redirect&bpo=47099

   (13) https://bugs.python.org/issue?@action=redirect&bpo=47099

   (14) https://peps.python.org/pep-3134/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=47095

   (16) https://bugs.python.org/issue?@action=redirect&bpo=47098

   (17) https://bugs.python.org/issue?@action=redirect&bpo=47088

   (18) https://peps.python.org/pep-0675/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=42885

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23691

   (21) https://bugs.python.org/issue?@action=redirect&bpo=47067

   (22) https://peps.python.org/pep-0590/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=28080

   (24) https://bugs.python.org/issue?@action=redirect&bpo=47000

   (25) https://bugs.python.org/issue?@action=redirect&bpo=42369

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38256

   (27) https://bugs.python.org/issue?@action=redirect&bpo=47066

   (28) https://bugs.python.org/issue?@action=redirect&bpo=39394

   (29) https://bugs.python.org/issue?@action=redirect&bpo=433030

   (30) https://bugs.python.org/issue?@action=redirect&bpo=47062

   (31) https://bugs.python.org/issue?@action=redirect&bpo=46382

   (32) https://bugs.python.org/issue?@action=redirect&bpo=47057

   (33) https://bugs.python.org/issue?@action=redirect&bpo=47061

   (34) https://peps.python.org/pep-0594/

   (35) https://bugs.python.org/issue?@action=redirect&bpo=34790

   (36) https://bugs.python.org/issue?@action=redirect&bpo=47039

   (37) https://bugs.python.org/issue?@action=redirect&bpo=2604

   (38) https://bugs.python.org/issue?@action=redirect&bpo=45150

   (39) https://bugs.python.org/issue?@action=redirect&bpo=34861

   (40) https://bugs.python.org/issue?@action=redirect&bpo=45997

   (41) https://bugs.python.org/issue?@action=redirect&bpo=47022

   (42) https://peps.python.org/pep-0594/

   (43) https://bugs.python.org/issue?@action=redirect&bpo=43253

   (44) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (45) https://bugs.python.org/issue?@action=redirect&bpo=47004

   (46) https://bugs.python.org/issue?@action=redirect&bpo=46998

   (47) https://bugs.python.org/issue?@action=redirect&bpo=46995

   (48) https://bugs.python.org/issue?@action=redirect&bpo=46994

   (49) https://bugs.python.org/issue?@action=redirect&bpo=46981

   (50) https://bugs.python.org/issue?@action=redirect&bpo=46968

   (51) https://bugs.python.org/issue?@action=redirect&bpo=46985

   (52) https://bugs.python.org/issue?@action=redirect&bpo=46968

   (53) https://bugs.python.org/issue?@action=redirect&bpo=46917

   (54) https://bugs.python.org/issue?@action=redirect&bpo=46955

   (55) https://bugs.python.org/issue?@action=redirect&bpo=23325

   (56) https://bugs.python.org/issue?@action=redirect&bpo=46932

   (57) https://bugs.python.org/issue?@action=redirect&bpo=46933

   (58) https://bugs.python.org/issue?@action=redirect&bpo=40059

   (59) https://peps.python.org/pep-0680/

   (60) https://bugs.python.org/issue?@action=redirect&bpo=464471

   (61) https://bugs.python.org/issue?@action=redirect&bpo=46805

   (62) https://bugs.python.org/issue?@action=redirect&bpo=46644

   (63) https://bugs.python.org/issue?@action=redirect&bpo=46581

   (64) https://bugs.python.org/issue?@action=redirect&bpo=45413

   (65) https://bugs.python.org/issue?@action=redirect&bpo=43224

   (66) https://bugs.python.org/issue?@action=redirect&bpo=43224

   (67) https://bugs.python.org/issue?@action=redirect&bpo=46557

   (68) https://bugs.python.org/issue?@action=redirect&bpo=41370

   (69) https://bugs.python.org/issue?@action=redirect&bpo=46607

   (70) https://bugs.python.org/issue?@action=redirect&bpo=26120

   (71) https://bugs.python.org/issue?@action=redirect&bpo=46480

   (72) https://bugs.python.org/issue?@action=redirect&bpo=46421

   (73) https://bugs.python.org/issue?@action=redirect&bpo=46245

   (74) https://bugs.python.org/issue?@action=redirect&bpo=22859

   (75) https://bugs.python.org/issue?@action=redirect&bpo=46170

   (76) https://bugs.python.org/issue?@action=redirect&bpo=40296

   (77) https://bugs.python.org/issue?@action=redirect&bpo=20392

   (78) https://bugs.python.org/issue?@action=redirect&bpo=46030

   (79) https://bugs.python.org/issue?@action=redirect&bpo=44439

   (80) https://bugs.python.org/issue?@action=redirect&bpo=45171

   (81) https://bugs.python.org/issue?@action=redirect&bpo=24959

   (82) https://bugs.python.org/issue?@action=redirect&bpo=44859

   (83) https://peps.python.org/pep-0249/

   (84) https://bugs.python.org/issue?@action=redirect&bpo=44493

   (85) https://bugs.python.org/issue?@action=redirect&bpo=41930

   (86) https://bugs.python.org/issue?@action=redirect&bpo=33178

   (87) https://bugs.python.org/issue?@action=redirect&bpo=43352

   (88) https://bugs.python.org/issue?@action=redirect&bpo=35859


File: python.info,  Node: Documentation<19>,  Next: Tests<22>,  Prev: Library<24>,  Up: Python 3 11 0 alpha 7

1.23.25.3 Documentation
.......................

   - bpo-45099(1): Document internal *note asyncio: 8. API.

   - bpo-47126(2): Update PEP URLs to PEP 676(3)'s new canonical form.

   - bpo-47040(4): Clarified the old Python versions compatibility note
     of *note binascii.crc32(): 15fa. / *note zlib.adler32(): 1794. /
     *note zlib.crc32(): 15f9. functions.

   - bpo-46033(5): Clarify ‘for’ statement execution in its doc.

   - bpo-45790(6): Adjust inaccurate phrasing in *note 拡張の型の定義;
     チュートリアル: 1795. about the ‘ob_base’ field and the macros used
     to access its contents.

   - bpo-42340(7): Document that in some circumstances *note
     KeyboardInterrupt: 99f. may cause the code to enter an inconsistent
     state.  Provided a sample workaround to avoid it if needed.

   - bpo-41233(8): Link the errnos referenced in
     ‘Doc/library/exceptions.rst’ to their respective section in
     ‘Doc/library/errno.rst’, and vice versa.  Previously this was only
     done for EINTR and InterruptedError.  Patch by Yan "yyyyyyyan"
     Orestes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45099

   (2) https://bugs.python.org/issue?@action=redirect&bpo=47126

   (3) https://peps.python.org/pep-0676/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=47040

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46033

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45790

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42340

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41233


File: python.info,  Node: Tests<22>,  Next: Build<24>,  Prev: Documentation<19>,  Up: Python 3 11 0 alpha 7

1.23.25.4 Tests
...............

   - bpo-47205(1): Skip test for *note sched_getaffinity(): 10dd. and
     *note sched_setaffinity(): 10e1. error case on FreeBSD.

   - bpo-46126(2): Restore 'descriptions' when running tests internally.

   - bpo-47104(3): Rewrite *note asyncio.to_thread(): 8b6. tests to use
     *note unittest.IsolatedAsyncioTestCase: 2e4.

   - bpo-40280(4): The test suite is now passing on the Emscripten
     platform.  All fork, socket, and subprocess-based tests are
     skipped.

   - bpo-47037(5): Skip ‘strftime("%4Y")’ feature test on Windows.  It
     can cause an assertion error in debug builds.

   - bpo-46587(6): Skip tests if platform's ‘strftime’ does not support
     non-portable glibc extensions.

   - bpo-47015(7): A test case for *note os.sendfile(): add. is
     converted from deprecated ‘asyncore’ (see PEP 594(8)) to *note
     asyncio: 8.  Patch by Oleg Iarygin.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=47205

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46126

   (3) https://bugs.python.org/issue?@action=redirect&bpo=47104

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (5) https://bugs.python.org/issue?@action=redirect&bpo=47037

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46587

   (7) https://bugs.python.org/issue?@action=redirect&bpo=47015

   (8) https://peps.python.org/pep-0594/


File: python.info,  Node: Build<24>,  Next: Windows<21>,  Prev: Tests<22>,  Up: Python 3 11 0 alpha 7

1.23.25.5 Build
...............

   - bpo-40280(1): Add configure option *note
     -enable-wasm-dynamic-linking: 1798. to enable ‘dlopen’ and
     MAIN_MODULE / SIDE_MODULE on ‘wasm32-emscripten’.

   - bpo-46023(2): ‘makesetup’ now detects and skips all duplicated
     module definitions.  The first entry wins.

   - bpo-40280(3): Add SOABI ‘wasm32-emscripten’ for Emscripten and
     ‘wasm32-wasi’ for WASI on 32bit WASM as well as ‘wasm64’ counter
     parts.

   - bpo-47032(4): Ensure Windows install builds fail correctly with a
     non-zero exit code when part of the build fails.

   - bpo-47024(5): Update OpenSSL to 1.1.1n for macOS installers and all
     Windows builds.

   - bpo-46996(6): The *note tkinter: d9. package now requires Tcl/Tk
     version 8.5.12 or newer.

   - bpo-46973(7): Add ‘regen-configure’ make target to regenerate
     configure script with Christian's container image
     ‘quay.io/tiran/cpython_autoconf:269’.

   - bpo-46917(8): Building Python now requires support of IEEE 754
     floating-point numbers.  Patch by Victor Stinner.

   - bpo-45774(9): ‘configure’ now verifies that all SQLite C APIs
     needed for the *note sqlite3: ba. extension module are found.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46023

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (4) https://bugs.python.org/issue?@action=redirect&bpo=47032

   (5) https://bugs.python.org/issue?@action=redirect&bpo=47024

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46996

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46973

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46917

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45774


File: python.info,  Node: Windows<21>,  Next: macOS<17>,  Prev: Build<24>,  Up: Python 3 11 0 alpha 7

1.23.25.6 Windows
.................

   - bpo-47194(1): Update ‘zlib’ to v1.2.12 to resolve CVE
     2018-25032(2).

   - bpo-47171(3): Enables installing the ‘py.exe’ launcher on Windows
     ARM64.

   - bpo-46566(4): Upgraded *note Windows の Python ランチャ: 588. to
     support a new ‘-V:company/tag’ argument for full PEP 514(5) support
     and to detect ARM64 installs.  The ‘-64’ suffix on arguments is
     deprecated, but still selects any non-32-bit install.  Setting
     ‘PYLAUNCHER_ALLOW_INSTALL’ and specifying a version that is not
     installed will attempt to install the requested version from the
     Microsoft Store.

   - bpo-47086(6): The installer for Windows now includes documentation
     as loose HTML files rather than a single compiled ‘.chm’ file.

   - bpo-46907(7): Update Windows installer to use SQLite 3.38.1.

   - bpo-44549(8): Update bzip2 to 1.0.8 in Windows builds to mitigate
     CVE 2016-3189(9) and CVE 2019-12900(10).

   - bpo-46948(11): Prevent CVE 2022-26488(12) by ensuring the Add to
     PATH option in the Windows installer uses the correct path when
     being repaired.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=47194

   (2) https://www.cve.org/CVERecord?id=CVE-2018-25032

   (3) https://bugs.python.org/issue?@action=redirect&bpo=47171

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46566

   (5) https://peps.python.org/pep-0514/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=47086

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46907

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44549

   (9) https://www.cve.org/CVERecord?id=CVE-2016-3189

   (10) https://www.cve.org/CVERecord?id=CVE-2019-12900

   (11) https://bugs.python.org/issue?@action=redirect&bpo=46948

   (12) https://www.cve.org/CVERecord?id=CVE-2022-26488


File: python.info,  Node: macOS<17>,  Next: Tools/Demos<13>,  Prev: Windows<21>,  Up: Python 3 11 0 alpha 7

1.23.25.7 macOS
...............

   - bpo-46890(1): Fix a regression in the setting of
     ‘sys._base_executable’ in framework builds, and thereby fix a
     regression in *note venv: f9. virtual environments with such
     builds.

   - bpo-46907(2): Update macOS installer to SQLite 3.38.1.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46890

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46907


File: python.info,  Node: Tools/Demos<13>,  Next: C API<23>,  Prev: macOS<17>,  Up: Python 3 11 0 alpha 7

1.23.25.8 Tools/Demos
.....................

   - bpo-40280(1): Replace Emscripten's limited shell with Katie Bell's
     browser-ui REPL from python-wasm project.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40280


File: python.info,  Node: C API<23>,  Prev: Tools/Demos<13>,  Up: Python 3 11 0 alpha 7

1.23.25.9 C API
...............

   - bpo-40421(1): Add ‘PyFrame_GetBuiltins’, ‘PyFrame_GetGenerator’ and
     ‘PyFrame_GetGlobals’ C-API functions to access frame object
     attributes safely from C code.

   - bpo-46850(2): Move the private ‘_PyFrameEvalFunction’ type, and
     private ‘_PyInterpreterState_GetEvalFrameFunc()’ and
     ‘_PyInterpreterState_SetEvalFrameFunc()’ functions to the internal
     C API. The ‘_PyFrameEvalFunction’ callback function type now uses
     the ‘_PyInterpreterFrame’ type which is part of the internal C API.
     Patch by Victor Stinner.

   - bpo-46850(3): Move the private undocumented
     ‘_PyEval_EvalFrameDefault()’ function to the internal C API. The
     function now uses the ‘_PyInterpreterFrame’ type which is part of
     the internal C API. Patch by Victor Stinner.

   - bpo-46850(4): Remove the private undocumented function
     ‘_PyEval_CallTracing()’ from the C API. Call the public *note
     sys.call_tracing(): 179d. function instead.  Patch by Victor
     Stinner.

   - bpo-46850(5): Remove the private undocumented function
     ‘_PyEval_GetCoroutineOriginTrackingDepth()’ from the C API. Call
     the public *note sys.get_coroutine_origin_tracking_depth(): b59.
     function instead.  Patch by Victor Stinner.

   - bpo-46850(6): Remove the following private undocumented functions
     from the C API:

        * ‘_PyEval_GetAsyncGenFirstiter()’

        * ‘_PyEval_GetAsyncGenFinalizer()’

        * ‘_PyEval_SetAsyncGenFirstiter()’

        * ‘_PyEval_SetAsyncGenFinalizer()’

     Call the public *note sys.get_asyncgen_hooks(): 179e. and *note
     sys.set_asyncgen_hooks(): 158a. functions instead.  Patch by Victor
     Stinner.

   - bpo-46987(7): Remove private functions ‘_PySys_GetObjectId()’ and
     ‘_PySys_SetObjectId()’.  Patch by Donghee Na.

   - bpo-46906(8): Add new functions to pack and unpack C double
     (serialize and deserialize): *note PyFloat_Pack2(): 730, *note
     PyFloat_Pack4(): 731, *note PyFloat_Pack8(): 732, *note
     PyFloat_Unpack2(): 733, *note PyFloat_Unpack4(): 734. and *note
     PyFloat_Unpack8(): 735.  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40421

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46850

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46850

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46850

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46850

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46850

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46987

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46906


File: python.info,  Node: Python 3 11 0 alpha 6,  Next: Python 3 11 0 alpha 5,  Prev: Python 3 11 0 alpha 7,  Up: 変更履歴

1.23.26 Python 3.11.0 alpha 6
-----------------------------

'Release date: 2022-03-07'

* Menu:

* Core and Builtins: Core and Builtins<26>.
* Library: Library<25>.
* Documentation: Documentation<20>.
* Tests: Tests<23>.
* Build: Build<25>.
* Windows: Windows<22>.
* IDLE: IDLE<16>.
* C API: C API<24>.


File: python.info,  Node: Core and Builtins<26>,  Next: Library<25>,  Up: Python 3 11 0 alpha 6

1.23.26.1 Core and Builtins
...........................

   - bpo-46940(1): Avoid overriding *note AttributeError: 326. metadata
     information for nested attribute access calls.  Patch by Pablo
     Galindo.

   - bpo-46927(2): Include the type's name in the error message for
     subscripting non-generic types.

   - bpo-46921(3): Support vectorcall for ‘super()’.  Patch by Ken Jin.

   - bpo-46841(4): Fix incorrect handling of inline cache entries when
     specializing *note BINARY_OP: 6d1.

   - bpo-46841(5): Use an oparg to simplify the construction of helpful
     error messages in *note GET_AWAITABLE: 17a1.

   - bpo-46903(6): Make sure that str subclasses can be used as
     attribute names for instances with virtual dictionaries.  Fixes
     regression in 3.11alpha

   - bpo-46841(7): Add more detailed specialization failure stats for
     *note COMPARE_OP: 937. followed by *note EXTENDED_ARG: 1710.

   - bpo-46891(8): Fix bug introduced during 3.11alpha where subclasses
     of ‘types.ModuleType’ with ‘__slots__’ were not initialized
     correctly, resulting in an interpreter crash.

   - bpo-46841(9): Use inline caching for *note LOAD_ATTR: 4ab, *note
     LOAD_METHOD: bed, and *note STORE_ATTR: 17a2.

   - bpo-46841(10): Use inline cache for *note BINARY_SUBSCR: 16a8.

   - bpo-46841(11): Use inline caching for *note COMPARE_OP: 937.

   - bpo-46864(12): Deprecate ‘PyBytesObject.ob_shash’.  It will be
     removed in Python 3.13.

   - bpo-46841(13): Use inline caching for *note UNPACK_SEQUENCE: 17a3.

   - bpo-46845(14): Reduces dict size by removing hash value from hash
     table when all inserted keys are Unicode.  For example,
     ‘sys.getsizeof(dict.fromkeys("abcdefg"))’ becomes 272 bytes from
     352 bytes on 64bit platform.

   - bpo-46841(15): Use inline cache for *note LOAD_GLOBAL: 164f.

   - bpo-46852(16): Rename the private undocumented
     ‘float.__set_format__()’ method to ‘float.__setformat__()’ to fix a
     typo introduced in Python 3.7.  The method is only used by
     test_float.  Patch by Victor Stinner.

   - bpo-46852(17): Remove the undocumented private
     ‘float.__set_format__()’ method, previously known as
     ‘float.__setformat__()’ in Python 3.7.  Its docstring said: "You
     probably don't want to use this function.  It exists mainly to be
     used in Python's test suite."  Patch by Victor Stinner.

   - bpo-40116(18): Fix regression that dict.update(other) may don't
     respect iterate order of other when other is key sharing dict.

   - bpo-46712(19): Share global string identifiers in deep-frozen
     modules.

   - bpo-46430(20): Fix memory leak in interned strings of deep-frozen
     modules.

   - bpo-46841(21): Store *note BINARY_OP: 6d1. caches inline using a
     new *note CACHE: 6c4. instruction.

   - bpo-45107(22): Specialize ‘LOAD_METHOD’ for instances with a dict.

   - bpo-44337(23): Reduce the memory usage of specialized *note
     LOAD_ATTR: 4ab. and *note STORE_ATTR: 17a2. instructions.

   - bpo-46729(24): Add number of sub-exceptions to
     ‘BaseException.__str__()’.

   - bpo-45885(25): Don't un-adapt *note COMPARE_OP: 937. when
     collecting specialization stats.

   - bpo-46329(26): Fix specialization stats gathering for ‘PRECALL’
     instructions.

   - bpo-46794(27): Bump up the libexpat version into 2.4.6

   - bpo-46823(28): Implement a specialized combined opcode
     ‘LOAD_FAST__LOAD_ATTR_INSTANCE_VALUE’.  Patch by Dennis Sweeney.

   - bpo-46820(29): Fix parsing a numeric literal immediately (without
     spaces) followed by "not in" keywords, like in ‘1not in x’.  Now
     the parser only emits a warning, not a syntax error.

   - bpo-46329(30): Move ‘KW_NAMES’ before ‘PRECALL’ instruction in call
     sequence.  Change ‘operand’ of ‘CALL’ to match ‘PRECALL’ for easier
     specialization.

   - bpo-46808(31): Remove the ‘NEXT_BLOCK’ macro from compile.c, and
     make the compiler automatically generate implicit blocks when they
     are needed.

   - bpo-46329(32): Add ‘PUSH_NULL’ instruction.  This is used as a
     prefix when evaluating a callable, so that the stack has the same
     shape for methods and other calls.  ‘PRECALL_FUNCTION’ and
     ‘PRECALL_METHOD’ are merged into a single ‘PRECALL’ instruction.

     There is no change in semantics.

   - bpo-46762(33): Fix an assert failure in debug builds when a '<',
     '>', or '=' is the last character in an f-string that's missing a
     closing right brace.

   - bpo-46730(34): Message of AttributeError caused by getting, setting
     or deleting a property without the corresponding function now
     mentions that the attribute is in fact a property and also
     specifies type of the class that it belongs to.

   - bpo-46724(35): Make sure that all backwards jumps use the
     ‘JUMP_ABSOLUTE’ instruction, rather than ‘JUMP_FORWARD’ with an
     argument of ‘(2**32)+offset’.

   - bpo-46732(36): Correct the docstring for the *note __bool__():
     12a3. method.  Patch by Jelle Zijlstra.

   - bpo-46072(37): Add more detailed specialization failure statistics
     for *note BINARY_OP: 6d1.

   - bpo-46707(38): Avoid potential exponential backtracking when
     producing some syntax errors involving lots of brackets.  Patch by
     Pablo Galindo.

   - bpo-46323(39): *note ctypes: 22. now allocates memory on the stack
     instead of on the heap to pass arguments while calling a Python
     callback function.  Patch by Donghee Na.

   - bpo-45923(40): Add a quickened form of *note RESUME: 2ed. that
     skips quickening checks.

   - bpo-46702(41): Specialize *note UNPACK_SEQUENCE: 17a3. for *note
     tuple: 349. and *note list: 5dc. unpackings.

   - bpo-46072(42): Opcode pair stats are now gathered with
     ‘--enable-pystats’.  Defining ‘DYNAMIC_EXECUTION_PROFILE’ or
     ‘DXPAIRS’ no longer has any effect.

   - bpo-46675(43): Allow more than 16 items in a split dict before it
     is combined.  The limit is now 254.

   - bpo-40479(44): Add a missing call to ‘va_end()’ in
     ‘Modules/_hashopenssl.c’.

   - bpo-46323(45): Use *note PyObject_Vectorcall(): 527. while calling
     ctypes callback function.  Patch by Donghee Na.

   - bpo-46615(46): When iterating over sets internally in
     ‘setobject.c’, acquire strong references to the resulting items
     from the set.  This prevents crashes in corner-cases of various set
     operations where the set gets mutated.

   - bpo-45828(47): The bytecode compiler now attempts to apply runtime
     stack manipulations at compile-time (whenever it is feasible to do
     so).

   - bpo-30496(48): Fixed a minor portability issue in the
     implementation of *note PyLong_FromLong(): 17a4, and added a fast
     path for single-digit integers to *note PyLong_FromLongLong():
     17a5.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46940

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46927

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46921

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46903

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46891

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (10) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (11) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (12) https://bugs.python.org/issue?@action=redirect&bpo=46864

   (13) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (14) https://bugs.python.org/issue?@action=redirect&bpo=46845

   (15) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (16) https://bugs.python.org/issue?@action=redirect&bpo=46852

   (17) https://bugs.python.org/issue?@action=redirect&bpo=46852

   (18) https://bugs.python.org/issue?@action=redirect&bpo=40116

   (19) https://bugs.python.org/issue?@action=redirect&bpo=46712

   (20) https://bugs.python.org/issue?@action=redirect&bpo=46430

   (21) https://bugs.python.org/issue?@action=redirect&bpo=46841

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45107

   (23) https://bugs.python.org/issue?@action=redirect&bpo=44337

   (24) https://bugs.python.org/issue?@action=redirect&bpo=46729

   (25) https://bugs.python.org/issue?@action=redirect&bpo=45885

   (26) https://bugs.python.org/issue?@action=redirect&bpo=46329

   (27) https://bugs.python.org/issue?@action=redirect&bpo=46794

   (28) https://bugs.python.org/issue?@action=redirect&bpo=46823

   (29) https://bugs.python.org/issue?@action=redirect&bpo=46820

   (30) https://bugs.python.org/issue?@action=redirect&bpo=46329

   (31) https://bugs.python.org/issue?@action=redirect&bpo=46808

   (32) https://bugs.python.org/issue?@action=redirect&bpo=46329

   (33) https://bugs.python.org/issue?@action=redirect&bpo=46762

   (34) https://bugs.python.org/issue?@action=redirect&bpo=46730

   (35) https://bugs.python.org/issue?@action=redirect&bpo=46724

   (36) https://bugs.python.org/issue?@action=redirect&bpo=46732

   (37) https://bugs.python.org/issue?@action=redirect&bpo=46072

   (38) https://bugs.python.org/issue?@action=redirect&bpo=46707

   (39) https://bugs.python.org/issue?@action=redirect&bpo=46323

   (40) https://bugs.python.org/issue?@action=redirect&bpo=45923

   (41) https://bugs.python.org/issue?@action=redirect&bpo=46702

   (42) https://bugs.python.org/issue?@action=redirect&bpo=46072

   (43) https://bugs.python.org/issue?@action=redirect&bpo=46675

   (44) https://bugs.python.org/issue?@action=redirect&bpo=40479

   (45) https://bugs.python.org/issue?@action=redirect&bpo=46323

   (46) https://bugs.python.org/issue?@action=redirect&bpo=46615

   (47) https://bugs.python.org/issue?@action=redirect&bpo=45828

   (48) https://bugs.python.org/issue?@action=redirect&bpo=30496


File: python.info,  Node: Library<25>,  Next: Documentation<20>,  Prev: Core and Builtins<26>,  Up: Python 3 11 0 alpha 6

1.23.26.2 Library
.................

   - bpo-25707(1): Fixed a file leak in *note
     xml.etree.ElementTree.iterparse(): 254. when the iterator is not
     exhausted.  Patch by Jacob Walls.

   - bpo-46877(2): Export *note unittest.doModuleCleanups(): 17a7. in
     *note unittest: ef.  Patch by Kumar Aditya.

   - bpo-46848(3): For performance, use the optimized string-searching
     implementations from *note find(): 17a8. and *note rfind(): 17a9.
     for ‘find()’ and ‘rfind()’.

   - bpo-46736(4): *note SimpleHTTPRequestHandler: b11. now uses HTML5
     grammar.  Patch by Donghee Na.

   - bpo-44886(5): Inherit asyncio proactor datagram transport from
     *note asyncio.DatagramTransport: 1717.

   - bpo-46827(6): Support UDP sockets in *note
     asyncio.loop.sock_connect(): d97. for selector-based event loops.
     Patch by Thomas Grainger.

   - bpo-46811(7): Make test suite support Expat >=2.4.5

   - bpo-46252(8): Raise *note TypeError: 502. if *note ssl.SSLSocket:
     8b8. is passed to transport-based APIs.

   - bpo-46784(9): Fix libexpat symbols collisions with user dynamically
     loaded or statically linked libexpat in embedded Python.

   - bpo-46786(10): The HTML serialisation in xml.etree.ElementTree now
     writes ‘embed’, ‘source’, ‘track’ and ‘wbr’ as empty tags, as
     defined in HTML 5.

   - bpo-39327(11): *note shutil.rmtree(): 2d8. can now work with
     VirtualBox shared folders when running from the guest
     operating-system.

   - bpo-45390(12): Propagate *note asyncio.CancelledError: 19d. message
     from inner task to outer awaiter.

   - bpo-46756(13): Fix a bug in *note
     urllib.request.HTTPPasswordMgr.find_user_password(): 17aa. and
     *note
     urllib.request.HTTPPasswordMgrWithPriorAuth.is_authenticated():
     17ab. which allowed to bypass authorization.  For example, access
     to URI ‘example.org/foobar’ was allowed if the user was authorized
     for URI ‘example.org/foo’.

   - bpo-46737(14): *note random.gauss(): 17ac. and *note
     random.normalvariate(): 17ad. now have default arguments.

   - bpo-46752(15): Add task groups to asyncio (structured concurrency,
     inspired by Trio's nurseries).  This also introduces a change to
     task cancellation, where a cancelled task can't be cancelled again
     until it calls .uncancel().

   - bpo-46724(16): Fix *note dis: 30. behavior on negative jump
     offsets.

   - bpo-46333(17): The ‘__repr__()’ method of *note typing.ForwardRef:
     17ae. now includes the ‘module’ parameter of *note
     typing.ForwardRef: 17ae. when it is set.

   - bpo-46643(18): In *note typing.get_type_hints(): 67d, support
     evaluating stringified ‘ParamSpecArgs’ and ‘ParamSpecKwargs’
     annotations.  Patch by Gregory Beauregard.

   - bpo-45863(19): When the *note tarfile: c8. module creates a pax
     format archive, it will put an integer representation of timestamps
     in the ustar header (if possible) for the benefit of older
     unarchivers, in addition to the existing full-precision timestamps
     in the pax extended header.

   - bpo-46066(20): Deprecate kwargs-based syntax for *note
     typing.TypedDict: 148. definitions.  It had confusing semantics
     when specifying totality, and was largely unused.  Patch by
     Jingchen Ye.

   - bpo-46676(21): Make *note typing.ParamSpec: 144. args and kwargs
     equal to themselves.  Patch by Gregory Beauregard.

   - bpo-46323(22): ‘ctypes.CFUNCTYPE()’ and ‘ctypes.WINFUNCTYPE()’ now
     fail to create the type if its ‘_argtypes_’ member contains too
     many arguments.  Previously, the error was only raised when calling
     a function.  Patch by Victor Stinner.

   - bpo-46672(23): Fix ‘NameError’ in *note asyncio.gather(): 5c8. when
     initial type check fails.

   - bpo-46659(24): The *note calendar.LocaleTextCalendar: 70f. and
     *note calendar.LocaleHTMLCalendar: 710. classes now use *note
     locale.getlocale(): 2bc, instead of using *note
     locale.getdefaultlocale(): 2bb, if no locale is specified.  Patch
     by Victor Stinner.

   - bpo-46659(25): The *note locale.getdefaultlocale(): 2bb. function
     is deprecated and will be removed in Python 3.13.  Use *note
     locale.setlocale(): 2bd, *note locale.getpreferredencoding(False):
     504. and *note locale.getlocale(): 2bc. functions instead.  Patch
     by Victor Stinner.

   - bpo-46655(26): In *note typing.get_type_hints(): 67d, support
     evaluating bare stringified ‘TypeAlias’ annotations.  Patch by
     Gregory Beauregard.

   - bpo-45948(27): Fixed a discrepancy in the C implementation of the
     *note xml.etree.ElementTree: 10c. module.  Now, instantiating an
     *note xml.etree.ElementTree.XMLParser: a22. with a ‘target=None’
     keyword provides a default *note xml.etree.ElementTree.TreeBuilder:
     a23. target as the Python implementation does.

   - bpo-46626(28): Expose Linux's ‘IP_BIND_ADDRESS_NO_PORT’ option in
     *note socket: b8.

   - bpo-46521(29): Fix a bug in the *note codeop: 15. module that was
     incorrectly identifying invalid code involving string quotes as
     valid code.

   - bpo-46571(30): Improve *note typing.no_type_check(): 680.

     Now it does not modify external classes and functions.  We also now
     correctly mark classmethods as not to be type checked.

   - bpo-46400(31): expat: Update libexpat from 2.4.1 to 2.4.4

   - bpo-46556(32): Deprecate undocumented support for using a *note
     pathlib.Path: 20a. object as a context manager.

   - bpo-46534(33): Implement PEP 673(34) *note typing.Self: 591.  Patch
     by James Hilton-Balfe.

   - bpo-46522(35): Make various module ‘__getattr__’ AttributeErrors
     more closely match a typical AttributeError

   - bpo-46475(36): Add *note typing.Never: 674. and *note
     typing.assert_never(): 673.  Patch by Jelle Zijlstra.

   - bpo-46333(37): The ‘__eq__()’ and ‘__hash__()’ methods of *note
     typing.ForwardRef: 17ae. now honor the ‘module’ parameter of *note
     typing.ForwardRef: 17ae.  Forward references from different modules
     are now differentiated.

   - bpo-46246(38): Add missing ‘__slots__’ to
     ‘importlib.metadata.DeprecatedList’.  Patch by Arie Bovenberg.

   - bpo-46232(39): The *note ssl: bb. module now handles certificates
     with bit strings in DN correctly.

   - bpo-46195(40): *note typing.get_type_hints(): 67d. no longer adds
     ‘Optional’ to parameters with ‘None’ as a default.  This aligns to
     changes to PEP 484 in ‘https://github.com/python/peps/pull/689’

   - bpo-31369(41): Add *note RegexFlag: 5f9. to ‘re.__all__’ and
     documented it.  Add ‘NOFLAG’ to indicate no flags being set.

   - bpo-45898(42): *note ctypes: 22. no longer defines ‘ffi_type_*’
     symbols in ‘cfield.c’.  The symbols have been provided by libffi
     for over a decade.

   - bpo-44953(43): Calling ‘operator.itemgetter’ objects and
     ‘operator.attrgetter’ objects is now faster due to use of the
     vectorcall calling convention.

   - bpo-44289(44): Fix an issue with *note is_tarfile(): 17af. method
     when using 'fileobj' argument: position in the 'fileobj' was
     advanced forward which made it unreadable with *note
     tarfile.TarFile.open(): 17b0.

   - bpo-44011(45): Reimplement SSL/TLS support in asyncio, borrow the
     implementation from uvloop library.

   - bpo-41086(46): Make the *note configparser.ConfigParser: 1aa.
     constructor raise *note TypeError: 502. if the ‘interpolation’
     parameter is not of type ‘configparser.Interpolation’

   - bpo-29418(47): Implement *note inspect.ismethodwrapper(): 616. and
     fix *note inspect.isroutine(): 154e. for cases where methodwrapper
     is given.  Patch by Hakan Çelik.

   - bpo-14156(48): argparse.FileType now supports an argument of '-' in
     binary mode, returning the .buffer attribute of
     sys.stdin/sys.stdout as appropriate.  Modes including 'x' and 'a'
     are treated equivalently to 'w' when argument is '-'.  Patch
     contributed by Josh Rosenberg

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25707

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46877

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46848

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46736

   (5) https://bugs.python.org/issue?@action=redirect&bpo=44886

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46827

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46811

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46252

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46784

   (10) https://bugs.python.org/issue?@action=redirect&bpo=46786

   (11) https://bugs.python.org/issue?@action=redirect&bpo=39327

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45390

   (13) https://bugs.python.org/issue?@action=redirect&bpo=46756

   (14) https://bugs.python.org/issue?@action=redirect&bpo=46737

   (15) https://bugs.python.org/issue?@action=redirect&bpo=46752

   (16) https://bugs.python.org/issue?@action=redirect&bpo=46724

   (17) https://bugs.python.org/issue?@action=redirect&bpo=46333

   (18) https://bugs.python.org/issue?@action=redirect&bpo=46643

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45863

   (20) https://bugs.python.org/issue?@action=redirect&bpo=46066

   (21) https://bugs.python.org/issue?@action=redirect&bpo=46676

   (22) https://bugs.python.org/issue?@action=redirect&bpo=46323

   (23) https://bugs.python.org/issue?@action=redirect&bpo=46672

   (24) https://bugs.python.org/issue?@action=redirect&bpo=46659

   (25) https://bugs.python.org/issue?@action=redirect&bpo=46659

   (26) https://bugs.python.org/issue?@action=redirect&bpo=46655

   (27) https://bugs.python.org/issue?@action=redirect&bpo=45948

   (28) https://bugs.python.org/issue?@action=redirect&bpo=46626

   (29) https://bugs.python.org/issue?@action=redirect&bpo=46521

   (30) https://bugs.python.org/issue?@action=redirect&bpo=46571

   (31) https://bugs.python.org/issue?@action=redirect&bpo=46400

   (32) https://bugs.python.org/issue?@action=redirect&bpo=46556

   (33) https://bugs.python.org/issue?@action=redirect&bpo=46534

   (34) https://peps.python.org/pep-0673/

   (35) https://bugs.python.org/issue?@action=redirect&bpo=46522

   (36) https://bugs.python.org/issue?@action=redirect&bpo=46475

   (37) https://bugs.python.org/issue?@action=redirect&bpo=46333

   (38) https://bugs.python.org/issue?@action=redirect&bpo=46246

   (39) https://bugs.python.org/issue?@action=redirect&bpo=46232

   (40) https://bugs.python.org/issue?@action=redirect&bpo=46195

   (41) https://bugs.python.org/issue?@action=redirect&bpo=31369

   (42) https://bugs.python.org/issue?@action=redirect&bpo=45898

   (43) https://bugs.python.org/issue?@action=redirect&bpo=44953

   (44) https://bugs.python.org/issue?@action=redirect&bpo=44289

   (45) https://bugs.python.org/issue?@action=redirect&bpo=44011

   (46) https://bugs.python.org/issue?@action=redirect&bpo=41086

   (47) https://bugs.python.org/issue?@action=redirect&bpo=29418

   (48) https://bugs.python.org/issue?@action=redirect&bpo=14156


File: python.info,  Node: Documentation<20>,  Next: Tests<23>,  Prev: Library<25>,  Up: Python 3 11 0 alpha 6

1.23.26.3 Documentation
.......................

   - bpo-42238(1): ‘Doc/tools/rstlint.py’ has moved to its own
     repository and is now packaged on PyPI as ‘sphinx-lint’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42238


File: python.info,  Node: Tests<23>,  Next: Build<25>,  Prev: Documentation<20>,  Up: Python 3 11 0 alpha 6

1.23.26.4 Tests
...............

   - bpo-46913(1): Fix test_faulthandler.test_sigfpe() if Python is
     built with undefined behavior sanitizer (UBSAN): disable UBSAN on
     the faulthandler_sigfpe() function.  Patch by Victor Stinner.

   - bpo-46760(2): Remove bytecode offsets from expected values in
     test.test_dis module.  Reduces the obstacles to modifying the VM or
     compiler.

   - bpo-46708(3): Prevent default asyncio event loop policy
     modification warning after ‘test_asyncio’ execution.

   - bpo-46678(4): The function ‘make_legacy_pyc’ in
     ‘Lib/test/support/import_helper.py’ no longer fails when
     ‘PYTHONPYCACHEPREFIX’ is set to a directory on a different device
     from where tempfiles are stored.

   - bpo-46623(5): Skip test_pair() and test_speech128() of test_zlib on
     s390x since they fail if zlib uses the s390x hardware accelerator.
     Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46913

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46760

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46708

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46678

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46623


File: python.info,  Node: Build<25>,  Next: Windows<22>,  Prev: Tests<23>,  Up: Python 3 11 0 alpha 6

1.23.26.5 Build
...............

   - bpo-46860(1): Respect ‘--with-suffix’ when building on
     case-insensitive file systems.

   - bpo-46656(2): Building Python now requires a C11 compiler.
     Optional C11 features are not required.  Patch by Victor Stinner.

   - bpo-46656(3): Building Python now requires support for
     floating-point Not-a-Number (NaN): remove the ‘Py_NO_NAN’ macro.
     Patch by Victor Stinner.

   - bpo-46640(4): Building Python now requires a C99 ‘<math.h>’ header
     file providing a ‘NAN’ constant, or the ‘__builtin_nan()’ built-in
     function.  Patch by Victor Stinner.

   - bpo-46608(5): Exclude marshalled-frozen data if deep-freezing to
     save 300 KB disk space.  This includes adding a new ‘is_package’
     field to *note _frozen: 740.  Patch by Kumar Aditya.

   - bpo-40280(6): Fix wasm32-emscripten test failures and platform
     issues.  - Disable syscalls that are not supported or don't work,
     e.g.  wait, getrusage, prlimit, mkfifo, mknod, setres[gu]id,
     setgroups.  - Use fd_count to count open fds.  - Add more checks
     for subprocess and fork.  - Add workarounds for missing
     _multiprocessing and failing socket.accept().  - Enable bzip2.  -
     Disable large file support.  - Disable signal.alarm.

   - bpo-46430(7): Intern strings in deep-frozen modules.  Patch by
     Kumar Aditya.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46860

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46656

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46656

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46640

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46608

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46430


File: python.info,  Node: Windows<22>,  Next: IDLE<16>,  Prev: Build<25>,  Up: Python 3 11 0 alpha 6

1.23.26.6 Windows
.................

   - bpo-46744(1): The default all users install directory for ARM64 is
     now under the native ‘Program Files’ folder, rather than ‘Program
     Files (Arm)’ which is intended for ARM (32-bit) files.

   - bpo-46567(2): Adds Tcl and Tk support for Windows ARM64.  This also
     adds IDLE to the installation.

   - bpo-46638(3): Ensures registry virtualization is consistently
     disabled.  For 3.10 and earlier, it remains enabled (some registry
     writes are protected), while for 3.11 and later it is disabled
     (registry modifications affect all applications).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46744

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46567

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46638


File: python.info,  Node: IDLE<16>,  Next: C API<24>,  Prev: Windows<22>,  Up: Python 3 11 0 alpha 6

1.23.26.7 IDLE
..............

   - bpo-46630(1): Make query dialogs on Windows start with a cursor in
     the entry box.

   - bpo-45447(2): Apply IDLE syntax highlighting to ‘.pyi’ files.
     Patch by Alex Waygood and Terry Jan Reedy.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46630

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45447


File: python.info,  Node: C API<24>,  Prev: IDLE<16>,  Up: Python 3 11 0 alpha 6

1.23.26.8 C API
...............

   - bpo-46748(1): Python's public headers no longer import
     ‘<stdbool.h>’, leaving code that embeds/extends Python free to
     define ‘bool’, ‘true’ and ‘false’.

   - bpo-46836(2): Move the *note PyFrameObject: 754. type definition
     (‘struct _frame’) to the internal C API ‘pycore_frame.h’ header
     file.  Patch by Victor Stinner.

   - bpo-45459(3): Rename ‘Include/buffer.h’ header file to
     ‘Include/pybuffer.h’ to avoid conflicts with projects having an
     existing ‘buffer.h’ header file.  Patch by Victor Stinner.

   - bpo-45412(4): Remove the ‘HAVE_PY_SET_53BIT_PRECISION’ macro (moved
     to the internal C API). Patch by Victor Stinner.

   - bpo-46613(5): Added function *note PyType_GetModuleByDef(): 36d,
     which allows access to module state when a method's defining class
     is not available.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46748

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46836

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45459

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45412

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46613


File: python.info,  Node: Python 3 11 0 alpha 5,  Next: Python 3 11 0 alpha 4,  Prev: Python 3 11 0 alpha 6,  Up: 変更履歴

1.23.27 Python 3.11.0 alpha 5
-----------------------------

'Release date: 2022-02-03'

* Menu:

* Core and Builtins: Core and Builtins<27>.
* Library: Library<26>.
* Documentation: Documentation<21>.
* Tests: Tests<24>.
* Build: Build<26>.
* Windows: Windows<23>.
* macOS: macOS<18>.
* IDLE: IDLE<17>.
* C API: C API<25>.


File: python.info,  Node: Core and Builtins<27>,  Next: Library<26>,  Up: Python 3 11 0 alpha 5

1.23.27.1 Core and Builtins
...........................

   - bpo-45773(1): Remove two invalid "peephole" optimizations from the
     bytecode compiler.

   - bpo-46564(2): Do not create frame objects when creating *note
     super: 4a8. object.  Patch by Kumar Aditya.

   - bpo-45885(3): Added more fined-grained specialization failure stats
     regarding the ‘COMPARE_OP’ bytecode.

   - bpo-44977(4): The delegation of *note int(): 238. to ‘__trunc__()’
     is now deprecated.  Calling ‘int(a)’ when ‘type(a)’ implements
     ‘__trunc__()’ but not ‘__int__()’ or ‘__index__()’ now raises a
     *note DeprecationWarning: 18a.

   - bpo-46458(5): Reorder code emitted by the compiler for a *note try:
     6b4.-*note except: 170. block so that the *note else: 171. block's
     code immediately follows the *note try: 6b4. body (without a jump).
     This is more optimal for the happy path.

   - bpo-46527(6): Allow passing ‘iterable’ as a keyword argument to
     *note enumerate(): 1424. again.  Patch by Jelle Zijlstra.

   - bpo-46528(7): Replace several stack manipulation instructions
     (‘DUP_TOP’, ‘DUP_TOP_TWO’, ‘ROT_TWO’, ‘ROT_THREE’, ‘ROT_FOUR’, and
     ‘ROT_N’) with new *note COPY: 6d4. and *note SWAP: 6d5.
     instructions.

   - bpo-46329(8): Use two or three bytecodes to implement most calls.

     Calls without named arguments are implemented as a sequence of two
     instructions: ‘PRECALL; CALL’.  Calls with named arguments are
     implemented as a sequence of three instructions: ‘PRECALL;
     KW_NAMES; CALL’.  There are two different ‘PRECALL’ instructions:
     ‘PRECALL_FUNTION’ and ‘PRECALL_METHOD’.  The latter pairs with
     ‘LOAD_METHOD’.

     This partition into pre-call and call allows better specialization,
     and thus better performance ultimately.

     There is no change in semantics.

   - bpo-46503(9): Fix an assert when parsing some invalid N escape
     sequences in f-strings.

   - bpo-46431(10): Improve error message on invalid calls to
     ‘BaseExceptionGroup.__new__()’.

   - bpo-46476(11): Fix memory leak in code objects generated by
     deepfreeze.  Patch by Kumar Aditya.

   - bpo-46481(12): Speed up calls to ‘weakref.ref.__call__()’ by using
     the PEP 590(13) ‘vectorcall’ calling convention.  Patch by Donghee
     Na.

   - bpo-46417(14): Fix a race condition on setting a type ‘__bases__’
     attribute: the internal function ‘add_subclass()’ now gets the
     ‘PyTypeObject.tp_subclasses’ member after calling *note
     PyWeakref_NewRef(): 17b9. which can trigger a garbage collection
     which can indirectly modify ‘PyTypeObject.tp_subclasses’.  Patch by
     Victor Stinner.

   - bpo-46417(15): ‘python -X showrefcount’ now shows the total
     reference count after clearing and destroyed the main Python
     interpreter.  Previously, it was shown before.  Patch by Victor
     Stinner.

   - bpo-43683(16): Add ASYNC_GEN_WRAP opcode to wrap the value to be
     yielded in async generators.  Removes the need to special case
     async generators in the ‘YIELD_VALUE’ instruction.

   - bpo-46407(17): Optimize some modulo operations in
     ‘Objects/longobject.c’.  Patch by Jeremiah Vivian.

   - bpo-46409(18): Add new ‘RETURN_GENERATOR’ bytecode to make
     generators.  Simplifies calling Python functions in the VM, as they
     no longer any need to special case generator functions.

     Also add ‘JUMP_NO_INTERRUPT’ bytecode that acts like
     ‘JUMP_ABSOLUTE’, but does not check for interrupts.

   - bpo-46406(19): The integer division ‘//’ implementation has been
     optimized to better let the compiler understand its constraints.
     It can be 20% faster on the amd64 platform when dividing an int by
     a value smaller than ‘2**30’.

   - bpo-46383(20): Fix invalid signature of ‘_zoneinfo’'s ‘module_free’
     function to resolve a crash on wasm32-emscripten platform.

   - bpo-46361(21): Ensure that "small" integers created by *note
     int.from_bytes(): 17ba. and *note decimal.Decimal: 27d. are
     properly cached.

   - bpo-46161(22): Fix the class building error when the arguments are
     constants and CALL_FUNCTION_EX is used.

   - bpo-46028(23): Fixes calculation of ‘sys._base_executable’ when
     inside a virtual environment that uses symlinks with different
     binary names than the base environment provides.

   - bpo-46091(24): Correctly calculate indentation levels for lines
     with whitespace character that are ended by line continuation
     characters.  Patch by Pablo Galindo

   - bpo-30512(25): Add CAN Socket support for NetBSD.

   - bpo-46045(26): Do not use POSIX semaphores on NetBSD

   - bpo-44024(27): Improve the *note TypeError: 502. message for
     non-string second arguments passed to the built-in functions *note
     getattr(): b9f. and *note hasattr(): 49e.  Patch by Géry Ogam.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45773

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46564

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45885

   (4) https://bugs.python.org/issue?@action=redirect&bpo=44977

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46458

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46527

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46528

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46329

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46503

   (10) https://bugs.python.org/issue?@action=redirect&bpo=46431

   (11) https://bugs.python.org/issue?@action=redirect&bpo=46476

   (12) https://bugs.python.org/issue?@action=redirect&bpo=46481

   (13) https://peps.python.org/pep-0590/

   (14) https://bugs.python.org/issue?@action=redirect&bpo=46417

   (15) https://bugs.python.org/issue?@action=redirect&bpo=46417

   (16) https://bugs.python.org/issue?@action=redirect&bpo=43683

   (17) https://bugs.python.org/issue?@action=redirect&bpo=46407

   (18) https://bugs.python.org/issue?@action=redirect&bpo=46409

   (19) https://bugs.python.org/issue?@action=redirect&bpo=46406

   (20) https://bugs.python.org/issue?@action=redirect&bpo=46383

   (21) https://bugs.python.org/issue?@action=redirect&bpo=46361

   (22) https://bugs.python.org/issue?@action=redirect&bpo=46161

   (23) https://bugs.python.org/issue?@action=redirect&bpo=46028

   (24) https://bugs.python.org/issue?@action=redirect&bpo=46091

   (25) https://bugs.python.org/issue?@action=redirect&bpo=30512

   (26) https://bugs.python.org/issue?@action=redirect&bpo=46045

   (27) https://bugs.python.org/issue?@action=redirect&bpo=44024


File: python.info,  Node: Library<26>,  Next: Documentation<21>,  Prev: Core and Builtins<27>,  Up: Python 3 11 0 alpha 5

1.23.27.2 Library
.................

   - bpo-46624(1): Restore support for non-integer arguments of *note
     random.randrange(): 837. and *note random.randint(): 1200.

   - bpo-46591(2): Make the IDLE doc URL on the About IDLE dialog
     clickable.

   - bpo-46565(3): Remove loop variables that are leaking into modules'
     namespaces.

   - bpo-46553(4): In *note typing.get_type_hints(): 67d, support
     evaluating bare stringified ‘ClassVar’ annotations.  Patch by
     Gregory Beauregard.

   - bpo-46544(5): Don't leak ‘x’ & ‘uspace’ intermediate vars in *note
     textwrap.TextWrapper: f9a.

   - bpo-46487(6): Add the ‘get_write_buffer_limits’ method to
     ‘asyncio.transports.WriteTransport’ and to the SSL transport.

   - bpo-45173(7): Note the configparser deprecations will be removed in
     Python 3.12.

   - bpo-45162(8): The deprecated *note unittest: ef. APIs removed in
     3.11a1 have been temporarily restored to be removed in 3.12 while
     cleanups in external projects go in.

   - bpo-46539(9): In *note typing.get_type_hints(): 67d, support
     evaluating stringified ‘ClassVar’ and ‘Final’ annotations inside
     ‘Annotated’.  Patch by Gregory Beauregard.

   - bpo-46510(10): Add missing test for *note types.TracebackType: ac0.
     and *note types.FrameType: 17bc.  Calculate them directly from the
     caught exception without calling *note sys.exc_info(): 656.

   - bpo-46491(11): Allow *note typing.Annotated: 90b. to wrap *note
     typing.Final: 248. and *note typing.ClassVar: 247.  Patch by
     Gregory Beauregard.

   - bpo-46483(12): Remove *note __class_getitem__(): 706. from *note
     pathlib.PurePath: 473. as this class was not supposed to be
     generic.

   - bpo-46436(13): Fix command-line option ‘-d’/‘--directory’ in module
     *note http.server: 68. which is ignored when combined with
     command-line option ‘--cgi’.  Patch by Géry Ogam.

   - bpo-41403(14): Make ‘mock.patch()’ raise a *note TypeError: 502.
     with a relevant error message on invalid arg.  Previously it
     allowed a cryptic *note AttributeError: 326. to escape.

   - bpo-46474(15): In ‘importlib.metadata.EntryPoint.pattern’, avoid
     potential REDoS by limiting ambiguity in consecutive whitespace.

   - bpo-46474(16): Removed private method from
     ‘importlib.metadata.Path’.  Sync with importlib_metadata 4.10.0.

   - bpo-46470(17): Remove unused branch from
     ‘typing._remove_dups_flatten’

   - bpo-46469(18): *note asyncio: 8. generic classes now return *note
     types.GenericAlias: 7b6. in ‘__class_getitem__’ instead of the same
     class.

   - bpo-41906(19): Support passing filter instances in the ‘filters’
     values of ‘handlers’ and ‘loggers’ in the dictionary passed to
     *note logging.config.dictConfig(): 1180.

   - bpo-46422(20): Use ‘dis.Positions’ in ‘dis.Instruction’ instead of
     a regular ‘tuple’.

   - bpo-46434(21): *note pdb: 94. now gracefully handles ‘help’ when
     *note __doc__: 17bd. is missing, for example when run with
     pregenerated optimized ‘.pyc’ files.

   - bpo-43869(22): Python uses the same time Epoch on all platforms.
     Add an explicit unit test to ensure that it's the case.  Patch by
     Victor Stinner.

   - bpo-46414(23): Add *note typing.reveal_type(): 676.  Patch by Jelle
     Zijlstra.

   - bpo-40280(24): *note subprocess: c1. now imports Windows-specific
     imports when ‘msvcrt’ module is available, and POSIX-specific
     imports on all other platforms.  This gives a clean exception when
     ‘_posixsubprocess’ is not available (e.g.  Emscripten browser
     target).

   - bpo-40066(25): ‘IntEnum’, ‘IntFlag’, and ‘StrEnum’ use the mixed-in
     type for their ‘str()’ and ‘format()’ output.

   - bpo-46316(26): Optimize *note pathlib.Path.iterdir(): 1595. by
     removing an unnecessary check for special entries.

   - bpo-29688(27): Document *note pathlib.Path.absolute(): 1612. (which
     has always existed).

   - bpo-43012(28): The pathlib module's obsolete and internal
     ‘_Accessor’ class has been removed to prepare the terrain for
     upcoming enhancements to the module.

   - bpo-46258(29): Speed up *note math.isqrt(): 9d3. for small positive
     integers by replacing two division steps with a lookup table.

   - bpo-46242(30): Improve error message when creating a new *note
     enum.Enum: 5fc. type subclassing an existing ‘Enum’ with
     ‘_member_names_’ using ‘enum.Enum.__call__()’.

   - bpo-43118(31): Fix a bug in *note inspect.signature(): 703. that
     was causing it to fail on some subclasses of classes with a
     ‘__text_signature__’ referencing module globals.  Patch by Weipeng
     Hong.

   - bpo-26552(32): Fixed case where failing *note
     asyncio.ensure_future(): c44. did not close the coroutine.  Patch
     by Kumar Aditya.

   - bpo-21987(33): Fix an issue with *note tarfile.TarFile.getmember():
     17be. getting a directory name with a trailing slash.

   - bpo-46124(34): Update *note zoneinfo: 11a. to rely on
     importlib.resources traversable API.

   - bpo-46103(35): Now *note inspect.getmembers(): 17bf. only gets
     ‘__bases__’ attribute from class type.  Patch by Weipeng Hong.

   - bpo-46080(36): Fix exception in argparse help text generation if a
     *note argparse.BooleanOptionalAction: 17c0. argument's default is
     ‘argparse.SUPPRESS’ and it has ‘help’ specified.  Patch by Felix
     Fontein.

   - bpo-44791(37): Fix substitution of *note ParamSpec: 144. in *note
     Concatenate: 78f. with different parameter expressions.
     Substitution with a list of types returns now a tuple of types.
     Substitution with ‘Concatenate’ returns now a ‘Concatenate’ with
     concatenated lists of arguments.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46624

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46591

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46565

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46553

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46544

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46487

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45173

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45162

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46539

   (10) https://bugs.python.org/issue?@action=redirect&bpo=46510

   (11) https://bugs.python.org/issue?@action=redirect&bpo=46491

   (12) https://bugs.python.org/issue?@action=redirect&bpo=46483

   (13) https://bugs.python.org/issue?@action=redirect&bpo=46436

   (14) https://bugs.python.org/issue?@action=redirect&bpo=41403

   (15) https://bugs.python.org/issue?@action=redirect&bpo=46474

   (16) https://bugs.python.org/issue?@action=redirect&bpo=46474

   (17) https://bugs.python.org/issue?@action=redirect&bpo=46470

   (18) https://bugs.python.org/issue?@action=redirect&bpo=46469

   (19) https://bugs.python.org/issue?@action=redirect&bpo=41906

   (20) https://bugs.python.org/issue?@action=redirect&bpo=46422

   (21) https://bugs.python.org/issue?@action=redirect&bpo=46434

   (22) https://bugs.python.org/issue?@action=redirect&bpo=43869

   (23) https://bugs.python.org/issue?@action=redirect&bpo=46414

   (24) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (25) https://bugs.python.org/issue?@action=redirect&bpo=40066

   (26) https://bugs.python.org/issue?@action=redirect&bpo=46316

   (27) https://bugs.python.org/issue?@action=redirect&bpo=29688

   (28) https://bugs.python.org/issue?@action=redirect&bpo=43012

   (29) https://bugs.python.org/issue?@action=redirect&bpo=46258

   (30) https://bugs.python.org/issue?@action=redirect&bpo=46242

   (31) https://bugs.python.org/issue?@action=redirect&bpo=43118

   (32) https://bugs.python.org/issue?@action=redirect&bpo=26552

   (33) https://bugs.python.org/issue?@action=redirect&bpo=21987

   (34) https://bugs.python.org/issue?@action=redirect&bpo=46124

   (35) https://bugs.python.org/issue?@action=redirect&bpo=46103

   (36) https://bugs.python.org/issue?@action=redirect&bpo=46080

   (37) https://bugs.python.org/issue?@action=redirect&bpo=44791


File: python.info,  Node: Documentation<21>,  Next: Tests<24>,  Prev: Library<26>,  Up: Python 3 11 0 alpha 5

1.23.27.3 Documentation
.......................

   - bpo-46463(1): Fixes ‘escape4chm.py’ script used when building the
     CHM documentation file

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46463


File: python.info,  Node: Tests<24>,  Next: Build<26>,  Prev: Documentation<21>,  Up: Python 3 11 0 alpha 5

1.23.27.4 Tests
...............

   - bpo-43478(1): Mocks can no longer be provided as the specs for
     other Mocks.  As a result, an already-mocked object cannot be
     passed to ‘mock.Mock()’.  This can uncover bugs in tests since
     these Mock-derived Mocks will always pass certain tests (e.g.
     isinstance) and builtin assert functions (e.g.
     assert_called_once_with) will unconditionally pass.

   - bpo-46616(2): Ensures ‘test_importlib.test_windows’ cleans up
     registry keys after completion.

   - bpo-44359(3): test_ftplib now silently ignores socket errors to
     prevent logging unhandled threading exceptions.  Patch by Victor
     Stinner.

   - bpo-46600(4): Fix test_gdb.test_pycfunction() for Python built with
     ‘clang -Og’.  Tolerate inlined functions in the gdb traceback.
     Patch by Victor Stinner.

   - bpo-46542(5): Fix a Python crash in test_lib2to3 when using Python
     built in debug mode: limit the recursion limit.  Patch by Victor
     Stinner.

   - bpo-46576(6): test_peg_generator now disables compiler optimization
     when testing compilation of its own C extensions to significantly
     speed up the testing on non-debug builds of CPython.

   - bpo-46542(7): Fix ‘test_json’ tests checking for *note
     RecursionError: d39.: modify these tests to use
     ‘support.infinite_recursion()’.  Patch by Victor Stinner.

   - bpo-13886(8): Skip test_builtin PTY tests on non-ASCII characters
     if the readline module is loaded.  The readline module changes
     input() behavior, but test_builtin is not intended to test the
     readline module.  Patch by Victor Stinner.

   - bpo-40280(9): Add ‘test.support.requires_fork()’ decorators to mark
     tests that require a working *note os.fork(): 17c.

   - bpo-40280(10): Add ‘test.support.requires_subprocess()’ decorator
     to mark tests which require working *note subprocess: c1. module or
     ‘os.spawn*’.  The wasm32-emscripten platform has no support for
     processes.

   - bpo-46126(11): Disable 'descriptions' when running tests
     internally.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43478

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46616

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44359

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46600

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46542

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46576

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46542

   (8) https://bugs.python.org/issue?@action=redirect&bpo=13886

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (10) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (11) https://bugs.python.org/issue?@action=redirect&bpo=46126


File: python.info,  Node: Build<26>,  Next: Windows<23>,  Prev: Tests<24>,  Up: Python 3 11 0 alpha 5

1.23.27.5 Build
...............

   - bpo-46602(1): Tidied up configure.ac so that conftest.c is
     truncated rather than appended.  This assists in the case where the
     'rm' of conftest.c fails to happen between tests.  Downstream
     issues such as a clobbered SOABI can result.

   - bpo-46600(2): Fix the test checking if the C compiler supports
     ‘-Og’ option in the ‘./configure’ script to also use ‘-Og’ on clang
     which supports it.  Patch by Victor Stinner.

   - bpo-38472(3): Fix GCC detection in setup.py when cross-compiling.
     The C compiler is now run with LC_ALL=C. Previously, the detection
     failed with a German locale.

   - bpo-46513(4): ‘configure’ no longer uses ‘AC_C_CHAR_UNSIGNED’ macro
     and ‘pyconfig.h’ no longer defines reserved symbol
     ‘__CHAR_UNSIGNED__’.

   - bpo-46471(5): Use global singletons for single byte bytes objects
     in deepfreeze.

   - bpo-46443(6): Deepfreeze now uses cached small integers as it saves
     some space for common small integers.

   - bpo-46429(7): Merge all deep-frozen files into one for space
     savings.  Patch by Kumar Aditya.

   - bpo-45569(8): The build now defaults to using 30-bit digits for
     Python integers.  Previously either 15-bit or 30-bit digits would
     be selected, depending on the platform.  15-bit digits may still be
     selected using the ‘--enable-big-digits=15’ option to the
     ‘configure’ script, or by defining ‘PYLONG_BITS_IN_DIGIT’ in
     ‘pyconfig.h’.

   - bpo-45925(9): Update Windows installer to use SQLite 3.37.2.

   - bpo-43112(10): Detect musl libc as a separate SOABI (tagged as
     ‘linux-musl’).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46602

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46600

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38472

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46513

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46471

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46443

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46429

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45569

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45925

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43112


File: python.info,  Node: Windows<23>,  Next: macOS<18>,  Prev: Build<26>,  Up: Python 3 11 0 alpha 5

1.23.27.6 Windows
.................

   - bpo-33125(1): The traditional EXE/MSI based installer for Windows
     is now available for ARM64

   - bpo-46362(2): os.path.abspath("C:CON") is now fixed to return
     "\.CON", not the same path.  The regression was true of all legacy
     DOS devices such as COM1, LPT1, or NUL.

   - bpo-44934(3): The installer now offers a command-line only option
     to add the installation directory to the end of ‘PATH’ instead of
     at the start.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33125

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46362

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44934


File: python.info,  Node: macOS<18>,  Next: IDLE<17>,  Prev: Windows<23>,  Up: Python 3 11 0 alpha 5

1.23.27.7 macOS
...............

   - bpo-45925(1): Update macOS installer to SQLite 3.37.2.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45925


File: python.info,  Node: IDLE<17>,  Next: C API<25>,  Prev: macOS<18>,  Up: Python 3 11 0 alpha 5

1.23.27.8 IDLE
..............

   - bpo-45296(1): Clarify close, quit, and exit in IDLE. In the File
     menu, 'Close' and 'Exit' are now 'Close Window' (the current one)
     and 'Exit' is now 'Exit IDLE' (by closing all windows).  In Shell,
     'quit()' and 'exit()' mean 'close Shell'.  If there are no other
     windows, this also exits IDLE.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45296


File: python.info,  Node: C API<25>,  Prev: IDLE<17>,  Up: Python 3 11 0 alpha 5

1.23.27.9 C API
...............

   - bpo-40170(1): Remove the ‘PyHeapType_GET_MEMBERS()’ macro.  It was
     exposed in the public C API by mistake, it must only be used by
     Python internally.  Use the ‘PyTypeObject.tp_members’ member
     instead.  Patch by Victor Stinner.

   - bpo-40170(2): Move _Py_GetAllocatedBlocks() and
     _PyObject_DebugMallocStats() private functions to the internal C
     API. Patch by Victor Stinner.

   - bpo-46433(3): The internal function _PyType_GetModuleByDef now
     correctly handles inheritance patterns involving static types.

   - bpo-45459(4): *note Py_buffer: 723. and various ‘Py_buffer’ related
     functions are now part of the limited API and stable ABI.

   - bpo-14916(5): Fixed bug in the tokenizer that prevented
     ‘PyRun_InteractiveOne’ from parsing from the provided FD.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46433

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45459

   (5) https://bugs.python.org/issue?@action=redirect&bpo=14916


File: python.info,  Node: Python 3 11 0 alpha 4,  Next: Python 3 11 0 alpha 3,  Prev: Python 3 11 0 alpha 5,  Up: 変更履歴

1.23.28 Python 3.11.0 alpha 4
-----------------------------

'Release date: 2022-01-13'

* Menu:

* Core and Builtins: Core and Builtins<28>.
* Library: Library<27>.
* Documentation: Documentation<22>.
* Tests: Tests<25>.
* Build: Build<27>.
* Windows: Windows<24>.
* macOS: macOS<19>.
* C API: C API<26>.


File: python.info,  Node: Core and Builtins<28>,  Next: Library<27>,  Up: Python 3 11 0 alpha 4

1.23.28.1 Core and Builtins
...........................

   - bpo-46070(1): *note Py_EndInterpreter(): 17ca. now explicitly
     untracks all objects currently tracked by the GC. Previously, if an
     object was used later by another interpreter, calling *note
     PyObject_GC_UnTrack(): 14b0. on the object crashed if the previous
     or the next object of the ‘PyGC_Head’ structure became a dangling
     pointer.  Patch by Victor Stinner.

   - bpo-46347(2): Fix memory leak in PyEval_EvalCodeEx.

   - bpo-46339(3): Fix a crash in the parser when retrieving the error
     text for multi-line f-strings expressions that do not start in the
     first line of the string.  Patch by Pablo Galindo

   - bpo-46331(4): Do not set line number of instruction storing
     doc-string.  Fixes regression introduced in 3.11 alpha.

   - bpo-46314(5): Remove spurious "call" event when creating a lambda
     function that was accidentally introduced in 3.11a4.

   - bpo-46289(6): ASDL declaration of ‘FormattedValue’ has changed to
     reflect ‘conversion’ field is not optional.

   - bpo-46297(7): Fixed an interpreter crash on bootup with multiple
     PythonPaths set in the Windows registry.  Patch by Derzsi Dániel.

   - bpo-46237(8): Fix the line number of tokenizer errors inside
     f-strings.  Patch by Pablo Galindo.

   - bpo-46263(9): We always expect the "use_frozen_modules" config to
     be set, now that getpath.c was rewritten in pure Python and the
     logic improved.

   - bpo-46006(10): Fix a regression when a type method like
     ‘__init__()’ is modified in a subinterpreter.  Fix a regression in
     ‘_PyUnicode_EqualToASCIIId()’ and type ‘update_slot()’.  Revert the
     change which made the Unicode dictionary of interned strings
     compatible with subinterpreters: the internal interned dictionary
     is shared again by all interpreters.  Patch by Victor Stinner.

   - bpo-45923(11): Add RESUME opcode.  This is a logical no-op.  It is
     emitted by the compiler anywhere a Python function can be entered.
     It is used by the interpreter to perform tracing and optimizer
     checks.

   - bpo-46208(12): Fix the regression of os.path.normpath("A/../../B")
     not returning expected "../B" but "B".

   - bpo-46240(13): Correct the error message for unclosed parentheses
     when the tokenizer doesn't reach the end of the source when the
     error is reported.  Patch by Pablo Galindo

   - bpo-46009(14): Remove the ‘GEN_START’ opcode.

   - bpo-46235(15): Certain sequence multiplication operations like ‘[0]
     * 1_000’ are now faster due to reference-counting optimizations.
     Patch by Dennis Sweeney.

   - bpo-46221(16): ‘PREP_RERAISE_STAR’ no longer pushes ‘lasti’ to the
     stack.

   - bpo-46202(17): Remove ‘POP_EXCEPT_AND_RERAISE’ and replace it by an
     equivalent sequence of other opcodes.

   - bpo-46085(18): Fix iterator cache mechanism of ‘OrderedDict’.

   - bpo-46055(19): Speed up shifting operation involving integers less
     than ‘PyLong_BASE’.  Patch by Xinhang Xu.

   - bpo-46110(20): Add a maximum recursion check to the PEG parser to
     avoid stack overflow.  Patch by Pablo Galindo

   - bpo-46107(21): Fix bug where ‘ExceptionGroup.split()’ and
     ‘ExceptionGroup.subgroup()’ did not copy the exception group's
     ‘__note__’ field to the parts.

   - bpo-45711(22): The interpreter state's representation of handled
     exceptions (a.k.a exc_info, or _PyErr_StackItem) now has only the
     ‘exc_value’ field, ‘exc_type’ and ‘exc_traceback’ have been removed
     as their values can be derived from ‘exc_value’.

   - bpo-44525(23): Replace the four call bytecode instructions which
     one pre-call instruction and two call instructions.

     Removes ‘CALL_FUNCTION’, ‘CALL_FUNCTION_KW’, ‘CALL_METHOD’ and
     ‘CALL_METHOD_KW’.

     Adds ‘CALL_NO_KW’ and ‘CALL_KW’ call instructions, and
     ‘PRECALL_METHOD’ prefix for pairing with ‘LOAD_METHOD’.

   - bpo-46039(24): Remove the ‘YIELD_FROM’ instruction and replace it
     with the ‘SEND’ instruction which performs the same operation, but
     without the loop.

   - bpo-45635(25): The code called from ‘_PyErr_Display()’ was
     refactored to improve error handling.  It now exits immediately
     upon an unrecoverable error.

   - bpo-46054(26): Fix parser error when parsing non-utf8 characters in
     source files.  Patch by Pablo Galindo.

   - bpo-46042(27): Improve the location of the caret in *note
     SyntaxError: 172. exceptions emitted by the symbol table.  Patch by
     Pablo Galindo.

   - bpo-46049(28): Ensure ‘._pth’ files work as intended on platforms
     other than Windows.

   - bpo-46048(29): Fixes parsing of ‘._pth’ files on startup so that
     single-character paths are correctly read.

   - bpo-37971(30): Fix a bug where the line numbers given in a
     traceback when a decorator application raised an exception were
     wrong.

   - bpo-46031(31): Add *note POP_JUMP_IF_NOT_NONE: 1762. and *note
     POP_JUMP_IF_NONE: 1761. opcodes to speed up conditional jumps.

   - bpo-45654(32): Deepfreeze *note runpy: ac, patch by Kumar Aditya.

   - bpo-46025(33): Fix a crash in the *note atexit: 9. module involving
     functions that unregister themselves before raising exceptions.
     Patch by Pablo Galindo.

   - bpo-46000(34): Improve compatibility of the *note curses: 23.
     module with NetBSD curses.

   - bpo-44525(35): Specialize the CALL_FUNCTION instruction for calls
     to builtin types with a single argument.  Speeds up ‘range(x)’,
     ‘list(x)’, and specifically ‘type(obj)’.

   - bpo-42918(36): Fix bug where the built-in *note compile(): 177.
     function did not always raise a *note SyntaxError: 172. when passed
     multiple statements in 'single' mode.  Patch by Weipeng Hong.

   - bpo-45953(37): The main interpreter in _PyRuntimeState.interpreters
     is now statically allocated (as part of _PyRuntime).  Likewise for
     the initial thread state of each interpreter.  This means less
     allocation during runtime init, as well as better memory locality
     for these key state objects.

   - bpo-45292(38): Complete the PEP 654(39) implementation: add
     ‘except*’.

   - bpo-43413(40): Revert changes in ‘set.__init__’.  Subclass of *note
     set: 5a3. needs to define a ‘__init__()’ method if it defines a
     ‘__new__()’ method with additional keyword parameters.

   - bpo-43931(41): Added the *note Py_Version: 721. constant which
     bears the same value as *note PY_VERSION_HEX: 722.  Patch by
     Gabriele N. Tornetta.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46070

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46347

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46339

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46331

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46314

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46289

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46297

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46237

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46263

   (10) https://bugs.python.org/issue?@action=redirect&bpo=46006

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45923

   (12) https://bugs.python.org/issue?@action=redirect&bpo=46208

   (13) https://bugs.python.org/issue?@action=redirect&bpo=46240

   (14) https://bugs.python.org/issue?@action=redirect&bpo=46009

   (15) https://bugs.python.org/issue?@action=redirect&bpo=46235

   (16) https://bugs.python.org/issue?@action=redirect&bpo=46221

   (17) https://bugs.python.org/issue?@action=redirect&bpo=46202

   (18) https://bugs.python.org/issue?@action=redirect&bpo=46085

   (19) https://bugs.python.org/issue?@action=redirect&bpo=46055

   (20) https://bugs.python.org/issue?@action=redirect&bpo=46110

   (21) https://bugs.python.org/issue?@action=redirect&bpo=46107

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (23) https://bugs.python.org/issue?@action=redirect&bpo=44525

   (24) https://bugs.python.org/issue?@action=redirect&bpo=46039

   (25) https://bugs.python.org/issue?@action=redirect&bpo=45635

   (26) https://bugs.python.org/issue?@action=redirect&bpo=46054

   (27) https://bugs.python.org/issue?@action=redirect&bpo=46042

   (28) https://bugs.python.org/issue?@action=redirect&bpo=46049

   (29) https://bugs.python.org/issue?@action=redirect&bpo=46048

   (30) https://bugs.python.org/issue?@action=redirect&bpo=37971

   (31) https://bugs.python.org/issue?@action=redirect&bpo=46031

   (32) https://bugs.python.org/issue?@action=redirect&bpo=45654

   (33) https://bugs.python.org/issue?@action=redirect&bpo=46025

   (34) https://bugs.python.org/issue?@action=redirect&bpo=46000

   (35) https://bugs.python.org/issue?@action=redirect&bpo=44525

   (36) https://bugs.python.org/issue?@action=redirect&bpo=42918

   (37) https://bugs.python.org/issue?@action=redirect&bpo=45953

   (38) https://bugs.python.org/issue?@action=redirect&bpo=45292

   (39) https://peps.python.org/pep-0654/

   (40) https://bugs.python.org/issue?@action=redirect&bpo=43413

   (41) https://bugs.python.org/issue?@action=redirect&bpo=43931


File: python.info,  Node: Library<27>,  Next: Documentation<22>,  Prev: Core and Builtins<28>,  Up: Python 3 11 0 alpha 4

1.23.28.2 Library
.................

   - bpo-46342(1): The ‘@typing.final’ decorator now sets the
     ‘__final__’ attribute on the decorated object to allow runtime
     introspection.  Patch by Jelle Zijlstra.

   - bpo-46328(2): Added the *note sys.exception(): 657. method which
     returns the active exception instance.

   - bpo-46307(3): Add *note string.Template.is_valid(): 652. and *note
     string.Template.get_identifiers(): 651. methods.

   - bpo-46306(4): Assume that *note types.CodeType: 2c0. always has
     ‘types.CodeType.co_firstlineno’ in *note doctest: 31.

   - bpo-40479(5): Fix *note hashlib: 5e. 'usedforsecurity' option to
     work correctly with OpenSSL 3.0.0 in FIPS mode.

   - bpo-46070(6): Fix possible segfault when importing the *note
     asyncio: 8. module from different sub-interpreters in parallel.
     Patch by Erlend E. Aasland.

   - bpo-46244(7): Removed ‘__slots__’ from *note typing.ParamSpec: 144.
     and *note typing.TypeVar: 143.  They served no purpose.  Patch by
     Arie Bovenberg.

   - bpo-46278(8): Reflect ‘context’ argument in
     ‘AbstractEventLoop.call_*()’ methods.  Loop implementations already
     support it.

   - bpo-46269(9): Remove special-casing of ‘__new__’ in *note
     enum.Enum.__dir__(): 17cc.

   - bpo-46266(10): Improve day constants in *note calendar: 10.

     Now all constants (‘MONDAY’ ...  ‘SUNDAY’) are documented, tested,
     and added to ‘__all__’.

   - bpo-46257(11): Optimized the mean, variance, and stdev functions in
     the statistics module.  If the input is an iterator, it is consumed
     in a single pass rather than eating memory by conversion to a list.
     The single pass algorithm is about twice as fast as the previous
     two pass code.

   - bpo-41011(12): Added two new variables to 'pyvenv.cfg' which is
     generated by *note venv: f9. module: 'executable' for the
     executable and 'command' for the command line used to create the
     environment.

   - bpo-46239(13): Improve error message when importing
     ‘asyncio.windows_events’ on non-Windows.

   - bpo-46238(14): Reuse ‘_winapi’ constants in
     ‘asyncio.windows_events’.

   - bpo-46222(15): Adding ‘SF_NOCACHE’ sendfile constant for FreeBSD
     for the posixmodule.

   - bpo-37295(16): Add fast path for ‘0 <= k <= n <= 67’ for *note
     math.comb(): 69b.

   - bpo-46176(17): Adding the ‘MAP_STACK’ constant for the mmap module.

   - bpo-43424(18): Deprecate ‘webbrowser.MacOSXOSAScript._name’ and use
     ‘name’ instead.

   - bpo-45321(19): Added missing error codes to module
     ‘xml.parsers.expat.errors’.

   - bpo-46125(20): Refactor tests to test traversable API directly.
     Includes changes from importlib 5.4.0.

   - bpo-46118(21): Moved importlib.resources and its related
     functionality to a package.

   - bpo-37578(22): Add 'include_hidden' parameter to *note glob(): 27f.
     and *note iglob(): 7d2. to match hidden files and directories when
     using special characters like ‘*’, ‘**’, ‘?’ and ‘[]’.

   - bpo-20369(23): *note concurrent.futures.wait(): 17cd. no longer
     blocks forever when given duplicate Futures.  Patch by Kumar
     Aditya.

   - bpo-46105(24): Honor spec when generating requirement specs with
     urls and extras (importlib_metadata 4.8.3).

   - bpo-44893(25): EntryPoint objects are no longer tuples.
     Recommended means to access is by attribute ('.name', '.group') or
     accessor ('.load()').  Access by index is deprecated and will raise
     deprecation warning.

   - bpo-22815(26): Print unexpected successes together with failures
     and errors in summary in *note unittest.TextTestResult: 4fa.

   - bpo-22047(27): Calling ‘add_argument_group()’ on an argument group
     is deprecated.  Calling ‘add_argument_group()’ or
     ‘add_mutually_exclusive_group()’ on a mutually exclusive group is
     deprecated.

     These features were never supported and do not always work
     correctly.  The functions exist on the API by accident through
     inheritance and will be removed in the future.

   - bpo-26952(28): *note argparse: 5. raises *note ValueError: 1e3.
     with clear message when trying to render usage for an empty
     mutually exclusive group.  Previously it raised a cryptic *note
     IndexError: 14de.

   - bpo-45615(29): Functions in the *note traceback: e7. module raise
     *note TypeError: 502. rather than *note AttributeError: 326. when
     an exception argument is not of type *note BaseException: 584.

   - bpo-16594(30): Add allow allow_reuse_port flag in socketserver.

   - bpo-27718(31): Fix help for the *note signal: b4. module.  Some
     functions (e.g.  ‘signal()’ and ‘getsignal()’) were omitted.

   - bpo-46032(32): The ‘registry()’ method of *note
     functools.singledispatch(): 605. functions checks now the first
     argument or the first parameter annotation and raises a TypeError
     if it is not supported.  Previously unsupported "types" were
     ignored (e.g.  ‘typing.List[int]’) or caused an error at calling
     time (e.g.  ‘list[int]’).

   - bpo-46014(33): Add ability to use ‘typing.Union’ and
     ‘types.UnionType’ as dispatch argument to
     ‘functools.singledispatch’.  Patch provided by Yurii Karabas.

   - bpo-27062(34): Add ‘__all__’ to *note inspect: 72, patch by Kumar
     Aditya.

   - bpo-46018(35): Ensure that *note math.expm1(): 11bd. does not raise
     on underflow.

   - bpo-46016(36): Adding ‘F_DUP2FD’ and ‘F_DUP2FD_CLOEXEC’ constants
     from FreeBSD into the fcntl module.

   - bpo-45755(37): *note typing: ed. generic aliases now reveal the
     class attributes of the original generic class when passed to
     ‘dir()’.  This was the behavior up to Python 3.6, but was changed
     in 3.7-3.9.

   - bpo-45874(38): The empty query string, consisting of no query
     arguments, is now handled correctly in ‘urllib.parse.parse_qsl’.
     This caused problems before when strict parsing was enabled.

   - bpo-44674(39): Change how dataclasses disallows mutable default
     values.  It used to use a list of known types (list, dict, set).
     Now it disallows unhashable objects to be defaults.  It's using
     unhashability as a proxy for mutability.  Patch by Eric V. Smith,
     idea by Raymond Hettinger.

   - bpo-23882(40): Remove namespace package (PEP 420) support from
     unittest discovery.  It was introduced in Python 3.4 but has been
     broken since Python 3.7.

   - bpo-25066(41): Added a ‘__repr__()’ method to *note
     multiprocessing.Event: 17ce. objects, patch by Kumar Aditya.

   - bpo-45643(42): Added *note signal.SIGSTKFLT: 17cf. on platforms
     where this signal is defined.

   - bpo-44092(43): Fetch across rollback no longer raises *note
     InterfaceError: 649.  Instead we leave it to the SQLite library to
     handle these cases.  Patch by Erlend E. Aasland.

   - bpo-42413(44): Replace ‘concurrent.futures.TimeoutError’ and
     ‘asyncio.TimeoutError’ with builtin *note TimeoutError: 800, keep
     these names as deprecated aliases.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46342

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46328

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46307

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46306

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40479

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46070

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46244

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46278

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46269

   (10) https://bugs.python.org/issue?@action=redirect&bpo=46266

   (11) https://bugs.python.org/issue?@action=redirect&bpo=46257

   (12) https://bugs.python.org/issue?@action=redirect&bpo=41011

   (13) https://bugs.python.org/issue?@action=redirect&bpo=46239

   (14) https://bugs.python.org/issue?@action=redirect&bpo=46238

   (15) https://bugs.python.org/issue?@action=redirect&bpo=46222

   (16) https://bugs.python.org/issue?@action=redirect&bpo=37295

   (17) https://bugs.python.org/issue?@action=redirect&bpo=46176

   (18) https://bugs.python.org/issue?@action=redirect&bpo=43424

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45321

   (20) https://bugs.python.org/issue?@action=redirect&bpo=46125

   (21) https://bugs.python.org/issue?@action=redirect&bpo=46118

   (22) https://bugs.python.org/issue?@action=redirect&bpo=37578

   (23) https://bugs.python.org/issue?@action=redirect&bpo=20369

   (24) https://bugs.python.org/issue?@action=redirect&bpo=46105

   (25) https://bugs.python.org/issue?@action=redirect&bpo=44893

   (26) https://bugs.python.org/issue?@action=redirect&bpo=22815

   (27) https://bugs.python.org/issue?@action=redirect&bpo=22047

   (28) https://bugs.python.org/issue?@action=redirect&bpo=26952

   (29) https://bugs.python.org/issue?@action=redirect&bpo=45615

   (30) https://bugs.python.org/issue?@action=redirect&bpo=16594

   (31) https://bugs.python.org/issue?@action=redirect&bpo=27718

   (32) https://bugs.python.org/issue?@action=redirect&bpo=46032

   (33) https://bugs.python.org/issue?@action=redirect&bpo=46014

   (34) https://bugs.python.org/issue?@action=redirect&bpo=27062

   (35) https://bugs.python.org/issue?@action=redirect&bpo=46018

   (36) https://bugs.python.org/issue?@action=redirect&bpo=46016

   (37) https://bugs.python.org/issue?@action=redirect&bpo=45755

   (38) https://bugs.python.org/issue?@action=redirect&bpo=45874

   (39) https://bugs.python.org/issue?@action=redirect&bpo=44674

   (40) https://bugs.python.org/issue?@action=redirect&bpo=23882

   (41) https://bugs.python.org/issue?@action=redirect&bpo=25066

   (42) https://bugs.python.org/issue?@action=redirect&bpo=45643

   (43) https://bugs.python.org/issue?@action=redirect&bpo=44092

   (44) https://bugs.python.org/issue?@action=redirect&bpo=42413


File: python.info,  Node: Documentation<22>,  Next: Tests<25>,  Prev: Library<27>,  Up: Python 3 11 0 alpha 4

1.23.28.3 Documentation
.......................

   - bpo-46196(1): Document method *note cmd.Cmd.columnize(): 17d1.

   - bpo-46120(2): State that ‘|’ is preferred for readability over
     ‘Union’ in the *note typing: ed. docs.

   - bpo-46109(3): Extracted ‘importlib.resources’ and
     ‘importlib.resources.abc’ documentation into separate files.

   - bpo-19737(4): Update the documentation for the *note globals():
     17d2. function.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46196

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46120

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46109

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19737


File: python.info,  Node: Tests<25>,  Next: Build<27>,  Prev: Documentation<22>,  Up: Python 3 11 0 alpha 4

1.23.28.4 Tests
...............

   - bpo-46296(1): Add a test case for *note enum: 4c. with ‘_use_args_
     == True’ and ‘_member_type_ == object’.

   - bpo-46205(2): Fix hang in runtest_mp due to race condition

   - bpo-46263(3): Fix test_capi on FreeBSD 14-dev: instruct jemalloc to
     not fill freed memory with junk byte.

   - bpo-46262(4): Cover ‘ValueError’ path in tests for
     ‘enum.Flag._missing_()’.

   - bpo-46150(5): Now ‘fakename’ in
     ‘test_pathlib.PosixPathTest.test_expanduser’ is checked to be
     non-existent.

   - bpo-46129(6): Rewrite ‘asyncio.locks’ tests with *note
     unittest.IsolatedAsyncioTestCase: 2e4. usage.

   - bpo-23819(7): Fixed *note asyncio: 8. tests in python optimized
     mode.  Patch by Kumar Aditya.

   - bpo-46114(8): Fix test case for OpenSSL 3.0.1 version.  OpenSSL 3.0
     uses ‘0xMNN00PP0L’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46296

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46205

   (3) https://bugs.python.org/issue?@action=redirect&bpo=46263

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46262

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46150

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46129

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23819

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46114


File: python.info,  Node: Build<27>,  Next: Windows<24>,  Prev: Tests<25>,  Up: Python 3 11 0 alpha 4

1.23.28.5 Build
...............

   - bpo-44133(1): When Python is configured with *note
     -without-static-libpython: 85b, the Python static library
     (libpython.a) is no longer built.  Patch by Victor Stinner.

   - bpo-44133(2): When Python is built without *note -enable-shared:
     82e, the ‘python’ program is now linked to object files, rather
     than being linked to the Python static library (libpython.a), to
     make sure that all symbols are exported.  Previously, the linker
     omitted some symbols like the ‘Py_FrozenMain()’ function.  Patch by
     Victor Stinner.

   - bpo-40280(3): The ‘configure’ script has a new option
     ‘--with-emscripten-target’ to select browser or node as Emscripten
     build target.

   - bpo-46315(4): Added and fixed ‘#ifdef HAVE_FEATURE’ checks for
     functionality that is not available on WASI platform.

   - bpo-45723(5): Fixed a regression in ‘configure’ check for *note
     select.epoll(): f60.

   - bpo-46263(6): ‘configure’ no longer sets ‘MULTIARCH’ on FreeBSD
     platforms.

   - bpo-46106(7): Updated OpenSSL to 1.1.1m in Windows builds, macOS
     installer builds, and CI. Patch by Kumar Aditya.

   - bpo-46088(8): Automatically detect or install bootstrap Python
     runtime when building from Visual Studio.

   - bpo-46072(9): Add a -with-pystats configure option to turn on
     internal statistics gathering.

   - bpo-40280(10): A new directory ‘Tools/wasm’ contains
     WebAssembly-related helpers like ‘config.site’ override for
     wasm32-emscripten, wasm assets generator to bundle the stdlib, and
     a README.

   - bpo-46023(11): ‘makesetup’ no longer builds extensions that have
     been marked as 'disabled'.  This allows users to disable modules in
     ‘Modules/Setup.local’.

   - bpo-45949(12): Use pure Python ‘freeze_module’ for all but
     importlib bootstrap files.  ‘--with-freeze-module’ ‘configure’
     option is no longer needed for cross builds.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44133

   (2) https://bugs.python.org/issue?@action=redirect&bpo=44133

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (4) https://bugs.python.org/issue?@action=redirect&bpo=46315

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45723

   (6) https://bugs.python.org/issue?@action=redirect&bpo=46263

   (7) https://bugs.python.org/issue?@action=redirect&bpo=46106

   (8) https://bugs.python.org/issue?@action=redirect&bpo=46088

   (9) https://bugs.python.org/issue?@action=redirect&bpo=46072

   (10) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (11) https://bugs.python.org/issue?@action=redirect&bpo=46023

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45949


File: python.info,  Node: Windows<24>,  Next: macOS<19>,  Prev: Build<27>,  Up: Python 3 11 0 alpha 4

1.23.28.6 Windows
.................

   - bpo-46217(1): Removed parameter that is unsupported on Windows 8.1
     and early Windows 10 and may have caused build or runtime failures.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46217


File: python.info,  Node: macOS<19>,  Next: C API<26>,  Prev: Windows<24>,  Up: Python 3 11 0 alpha 4

1.23.28.7 macOS
...............

   - bpo-40477(1): The Python Launcher app for macOS now properly
     launches scripts and, if necessary, the Terminal app when running
     on recent macOS releases.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40477


File: python.info,  Node: C API<26>,  Prev: macOS<19>,  Up: Python 3 11 0 alpha 4

1.23.28.8 C API
...............

   - bpo-46236(1): Fix a bug in *note PyFunction_GetAnnotations(): 1725.
     that caused it to return a ‘tuple’ instead of a ‘dict’.

   - bpo-46140(2): *note PyBuffer_GetPointer(): 724, *note
     PyBuffer_FromContiguous(): 727, *note PyBuffer_ToContiguous(): 726.
     and *note PyMemoryView_FromBuffer(): 72c. now take buffer info by
     ‘const Py_buffer *’ instead of ‘Py_buffer *’, as they do not need
     mutability.  *note PyBuffer_FromContiguous(): 727. also now takes
     the source buffer as ‘const void *’, and similarly *note
     PyBuffer_GetPointer(): 724. takes the strides as ‘const Py_ssize_t
     *’.

   - bpo-45855(3): Document that the 'no_block' argument to *note
     PyCapsule_Import(): 17d8. is a no-op now.

   - bpo-45855(4): Replaced deprecated usage of *note
     PyImport_ImportModuleNoBlock(): 397. with *note
     PyImport_ImportModule(): 398. in stdlib modules.  Patch by Kumar
     Aditya.

   - bpo-46007(5): The ‘PyUnicode_CHECK_INTERNED()’ macro has been
     excluded from the limited C API. It was never usable there, because
     it used internal structures which are not available in the limited
     C API. Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46236

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46140

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45855

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45855

   (5) https://bugs.python.org/issue?@action=redirect&bpo=46007


File: python.info,  Node: Python 3 11 0 alpha 3,  Next: Python 3 11 0 alpha 2,  Prev: Python 3 11 0 alpha 4,  Up: 変更履歴

1.23.29 Python 3.11.0 alpha 3
-----------------------------

'Release date: 2021-12-08'

* Menu:

* Core and Builtins: Core and Builtins<29>.
* Library: Library<28>.
* Documentation: Documentation<23>.
* Tests: Tests<26>.
* Build: Build<28>.
* Windows: Windows<25>.
* macOS: macOS<20>.
* C API: C API<27>.


File: python.info,  Node: Core and Builtins<29>,  Next: Library<28>,  Up: Python 3 11 0 alpha 3

1.23.29.1 Core and Builtins
...........................

   - bpo-46009(1): Restore behavior from 3.9 and earlier when sending
     non-None to newly started generator.  In 3.9 this did not affect
     the state of the generator.  In 3.10.0 and 3.10.1
     ‘gen_func().send(0)’ is equivalent to
     ‘gen_func().throw(TypeError(...)’ which exhausts the generator.  In
     3.10.2 onward, the behavior has been reverted to that of 3.9.

   - bpo-46004(2): Fix the *note SyntaxError: 172. location for errors
     involving for loops with invalid targets.  Patch by Pablo Galindo

   - bpo-45711(3): ‘_PyErr_ChainStackItem()’ no longer normalizes
     ‘exc_info’ (including setting the traceback on the exception
     instance) because ‘exc_info’ is always normalized.

   - bpo-45607(4): The ‘__note__’ field was added to *note
     BaseException: 584.  It is ‘None’ by default but can be set to a
     string which is added to the exception's traceback.

   - bpo-45947(5): Place pointers to dict and values immediately before
     GC header.  This reduces number of dependent memory loads to access
     either dict or values from 3 to 1.

   - bpo-45915(6): ‘is_valid_fd’ now uses faster ‘fcntl(fd, F_GETFD)’ on
     Linux, macOS, and Windows.

   - bpo-44530(7): Reverts a change to the ‘code.__new__’ *note audit
     event: 17db. from an earlier prerelease.

   - bpo-42268(8): Fail the configure step if the selected compiler
     doesn't support memory sanitizer.  Patch by Pablo Galindo

   - bpo-45711(9): The three values of ‘exc_info’ are now always
     consistent with each other.  In particular, the ‘type’ and
     ‘traceback’ fields are now derived from the exception instance.
     This impacts the return values of *note sys.exc_info(): 656. and
     *note PyErr_GetExcInfo(): 73d. if the exception instance is
     modified while the exception is handled, as well as *note
     PyErr_SetExcInfo(): 73c, which now ignores the ‘type’ and
     ‘traceback’ arguments provided to it.

   - bpo-45727(10): Refine the custom syntax error that suggests that a
     comma may be missing to trigger only when the expressions are
     detected between parentheses or brackets.  Patch by Pablo Galindo

   - bpo-45885(11): Specialized the ‘COMPARE_OP’ opcode using the PEP
     659 machinery.

   - bpo-45786(12): Allocate space for the interpreter frame in the
     frame object, to avoid an additional allocation when the frame
     object outlives the frame activation.

   - bpo-45614(13): Fix *note traceback: e7. display for exceptions with
     invalid module name.

   - bpo-45813(14): Fix crash when calling coro.cr_frame.clear() after
     coroutine has been freed.

   - bpo-45811(15): Improve the tokenizer errors when encountering
     invisible control characters in the parser.  Patch by Pablo Galindo

   - bpo-45848(16): Allow the parser to obtain error lines directly from
     encoded files.  Patch by Pablo Galindo

   - bpo-45709(17): Restore behavior from 3.10 when tracing an exception
     raised within a with statement.

   - bpo-44525(18): Adds new *note COPY_FREE_VARS: 6c9. opcode, to make
     copying of free variables from function to frame explicit.  Helps
     optimization of calls to Python function.

   - bpo-45829(19): Specialize *note BINARY_SUBSCR: 16a8. for classes
     with a ‘__getitem__’ method implemented in Python

   - bpo-45826(20): Fixed a crash when calling ‘.with_traceback(None)’
     on ‘NameError’.  This occurs internally in
     ‘unittest.TestCase.assertRaises()’.

   - bpo-45822(21): Fixed a bug in the parser that was causing it to not
     respect PEP 263(22) coding cookies when no flags are provided.
     Patch by Pablo Galindo

   - bpo-45820(23): Fix a segfault when the parser fails without reading
     any input.  Patch by Pablo Galindo

   - bpo-45636(24): Simplify the implementation of *note BINARY_OP: 6d1.
     by indexing into an array of function pointers (rather than
     switching on the oparg).

   - bpo-42540(25): Fix crash when *note os.fork(): 17c. is called with
     an active non-default memory allocator.

   - bpo-45738(26): Fix computation of error location for invalid
     continuation characters in the parser.  Patch by Pablo Galindo.

   - bpo-45636(27): Remove an existing "fast path" for old-style string
     formatting, since it no longer appears to have any measurable
     impact.

   - bpo-45753(28): Make recursion checks a bit more efficient by
     tracking amount of calls left before overflow.

   - bpo-45773(29): Fix a compiler hang when attempting to optimize
     certain jump patterns.

   - bpo-45764(30): The parser now gives a better error message when
     leaving out the opening parenthesis ‘(’ after a ‘def’-statement:

          >>> def f:
            File "<stdin>", line 1
              def f:
                   ^
          SyntaxError: expected '('

   - bpo-45609(31): Specialized the ‘STORE_SUBSCR’ opcode using the PEP
     659 machinery.

   - bpo-45636(32): Replace all numeric ‘BINARY_*’ and ‘INPLACE_*’
     instructions with a single *note BINARY_OP: 6d1. implementation.

   - bpo-45582(33): Path calculation (known as ‘getpath’) has been
     reimplemented as a frozen Python module.  This should have no
     visible impact, but may affect calculation of all paths referenced
     in *note sys: c3. and *note sysconfig: c5.

   - bpo-45450(34): Improve the syntax error message for parenthesized
     arguments.  Patch by Pablo Galindo.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46009

   (2) https://bugs.python.org/issue?@action=redirect&bpo=46004

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45607

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45947

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45915

   (7) https://bugs.python.org/issue?@action=redirect&bpo=44530

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42268

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45727

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45885

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45786

   (13) https://bugs.python.org/issue?@action=redirect&bpo=45614

   (14) https://bugs.python.org/issue?@action=redirect&bpo=45813

   (15) https://bugs.python.org/issue?@action=redirect&bpo=45811

   (16) https://bugs.python.org/issue?@action=redirect&bpo=45848

   (17) https://bugs.python.org/issue?@action=redirect&bpo=45709

   (18) https://bugs.python.org/issue?@action=redirect&bpo=44525

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45829

   (20) https://bugs.python.org/issue?@action=redirect&bpo=45826

   (21) https://bugs.python.org/issue?@action=redirect&bpo=45822

   (22) https://peps.python.org/pep-0263/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=45820

   (24) https://bugs.python.org/issue?@action=redirect&bpo=45636

   (25) https://bugs.python.org/issue?@action=redirect&bpo=42540

   (26) https://bugs.python.org/issue?@action=redirect&bpo=45738

   (27) https://bugs.python.org/issue?@action=redirect&bpo=45636

   (28) https://bugs.python.org/issue?@action=redirect&bpo=45753

   (29) https://bugs.python.org/issue?@action=redirect&bpo=45773

   (30) https://bugs.python.org/issue?@action=redirect&bpo=45764

   (31) https://bugs.python.org/issue?@action=redirect&bpo=45609

   (32) https://bugs.python.org/issue?@action=redirect&bpo=45636

   (33) https://bugs.python.org/issue?@action=redirect&bpo=45582

   (34) https://bugs.python.org/issue?@action=redirect&bpo=45450


File: python.info,  Node: Library<28>,  Next: Documentation<23>,  Prev: Core and Builtins<29>,  Up: Python 3 11 0 alpha 3

1.23.29.2 Library
.................

   - bpo-27946(1): Fix possible crash when getting an attribute of *note
     xml.etree.ElementTree.Element: 2e8. simultaneously with replacing
     the ‘attrib’ dict.

   - bpo-45711(2): Make *note asyncio: 8. normalize exceptions as soon
     as they are captured with *note PyErr_Fetch(): 3cc, and before they
     are stored as an exc_info triplet.  This brings *note asyncio: 8.
     in line with the rest of the codebase, where an exc_info triplet is
     always normalized.

   - bpo-23819(3): Replaced asserts with exceptions in asyncio, patch by
     Kumar Aditya.

   - bpo-13236(4): *note unittest.TextTestResult: 4fa. and *note
     unittest.TextTestRunner: 16ad. flush now the output stream more
     often.

   - bpo-45917(5): Added *note math.exp2(): 62c.:, which returns 2
     raised to the power of x.

   - bpo-37658(6): Fix issue when on certain conditions
     ‘asyncio.wait_for()’ may allow a coroutine to complete
     successfully, but fail to return the result, potentially causing
     memory leaks or other issues.

   - bpo-45876(7): Improve the accuracy of stdev() and pstdev() in the
     statistics module.  When the inputs are floats or fractions, the
     output is a correctly rounded float

   - bpo-44649(8): Handle dataclass(slots=True) with a field that has
     default a default value, but for which init=False.

   - bpo-45803(9): Added missing kw_only parameter to
     dataclasses.make_dataclass().

   - bpo-45837(10): The ‘turtle.RawTurtle.settiltangle()’ is deprecated
     since Python 3.1, it now emits a deprecation warning and will be
     removed in Python 3.13.

     Use ‘turtle.RawTurtle.tiltangle()’ instead.

     ‘turtle.RawTurtle.tiltangle()’ was earlier incorrectly marked as
     deprecated, its docstring has been corrected.

     Patch by Hugo van Kemenade.

   - bpo-45831(11): *note faulthandler: 4e. can now write ASCII-only
     strings (like filenames and function names) with a single write()
     syscall when dumping a traceback.  It reduces the risk of getting
     an unreadable dump when two threads or two processes dump a
     traceback to the same file (like stderr) at the same time.  Patch
     by Victor Stinner.

   - bpo-45828(12): ‘sqlite’ C callbacks now use unraisable exceptions
     if callback tracebacks are enabled.  Patch by Erlend E. Aasland.

   - bpo-41735(13): Fix thread lock in ‘zlib.Decompress.flush()’ method
     before ‘PyObject_GetBuffer’.

   - bpo-45235(14): Reverted an argparse bugfix that caused regression
     in the handling of default arguments for subparsers.  This
     prevented leaf level arguments from taking precedence over root
     level arguments.

   - bpo-45754(15): Fix a regression in Python 3.11a1 and 3.11a2 where
     *note sqlite3: ba. incorrectly would use ‘SQLITE_LIMIT_LENGTH’ when
     checking SQL statement lengths.  Now, ‘SQLITE_LIMIT_SQL_LENGTH’ is
     used.  Patch by Erlend E. Aasland.

   - bpo-45766(16): Added 'proportional' option to *note
     statistics.linear_regression(): 7fc.

   - bpo-45765(17): In importlib.metadata, fix distribution discovery
     for an empty path.

   - bpo-45757(18): Fix bug where *note dis: 30. produced an incorrect
     oparg when *note EXTENDED_ARG: 1710. is followed by an opcode that
     does not use its argument.

   - bpo-45644(19): In-place JSON file formatting using ‘python3 -m
     json.tool infile infile’ now works correctly, previously it left
     the file empty.  Patch by Chris Wesseling.

   - bpo-45703(20): When a namespace package is imported before another
     module from the same namespace is created/installed in a different
     *note sys.path: 38e. location while the program is running, calling
     the *note importlib.invalidate_caches(): bde. function will now
     also guarantee the new module is noticed.

   - bpo-45535(21): Improve output of ‘dir()’ with Enums.

   - bpo-45664(22): Fix *note types.resolve_bases(): b6a. and *note
     types.new_class(): 1134. for *note types.GenericAlias: 7b6.
     instance as a base.

   - bpo-45663(23): Fix *note dataclasses.is_dataclass(): 17dd. for
     dataclasses which are subclasses of *note types.GenericAlias: 7b6.

   - bpo-45662(24): Fix the repr of ‘dataclasses.InitVar’ with a type
     alias to the built-in class, e.g.  ‘InitVar[list[int]]’.

   - bpo-43137(25): Launch GNOME web browsers via gio tool instead of
     obsolete gvfs-open

   - bpo-45429(26): On Windows, *note time.sleep(): 669. now uses a
     waitable timer which supports high-resolution timers.  Patch by
     Donghee Na and Eryk Sun.

   - bpo-37295(27): Optimize *note math.comb(): 69b. and *note
     math.perm(): 69c.

   - bpo-45514(28): Deprecated legacy functions in *note
     importlib.resources: 6f.

   - bpo-45507(29): Add tests for truncated/missing trailers in
     gzip.decompress implementation.

   - bpo-45359(30): Implement PEP 585(31) for *note
     graphlib.TopologicalSorter: 8af.

   - bpo-44733(32): Add ‘max_tasks_per_child’ to *note
     concurrent.futures.ProcessPoolExecutor: 8bc.  This allows users to
     specify the maximum number of tasks a single process should execute
     before the process needs to be restarted.

   - bpo-28806(33): Improve netrc library.  netrc file no longer needs
     to contain all tokens.  And if the login name is anonymous,
     security check is no longer need.

   - bpo-43498(34): Avoid a possible '"RuntimeError: dictionary changed
     size during iteration"' when adjusting the process count of
     ‘ProcessPoolExecutor’.

   - bpo-42158(35): Add MIME types for N-quads, N-triples, Notation3 and
     TriG to ‘mimetypes’.

   - bpo-30533(36): Add *note inspect.getmembers_static(): 615. , it
     return all members without triggering dynamic lookup via the
     descriptor protocol.  Patch by Weipeng Hong.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27946

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45711

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23819

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13236

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45917

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37658

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45876

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44649

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45803

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45837

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45831

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45828

   (13) https://bugs.python.org/issue?@action=redirect&bpo=41735

   (14) https://bugs.python.org/issue?@action=redirect&bpo=45235

   (15) https://bugs.python.org/issue?@action=redirect&bpo=45754

   (16) https://bugs.python.org/issue?@action=redirect&bpo=45766

   (17) https://bugs.python.org/issue?@action=redirect&bpo=45765

   (18) https://bugs.python.org/issue?@action=redirect&bpo=45757

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45644

   (20) https://bugs.python.org/issue?@action=redirect&bpo=45703

   (21) https://bugs.python.org/issue?@action=redirect&bpo=45535

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45664

   (23) https://bugs.python.org/issue?@action=redirect&bpo=45663

   (24) https://bugs.python.org/issue?@action=redirect&bpo=45662

   (25) https://bugs.python.org/issue?@action=redirect&bpo=43137

   (26) https://bugs.python.org/issue?@action=redirect&bpo=45429

   (27) https://bugs.python.org/issue?@action=redirect&bpo=37295

   (28) https://bugs.python.org/issue?@action=redirect&bpo=45514

   (29) https://bugs.python.org/issue?@action=redirect&bpo=45507

   (30) https://bugs.python.org/issue?@action=redirect&bpo=45359

   (31) https://peps.python.org/pep-0585/

   (32) https://bugs.python.org/issue?@action=redirect&bpo=44733

   (33) https://bugs.python.org/issue?@action=redirect&bpo=28806

   (34) https://bugs.python.org/issue?@action=redirect&bpo=43498

   (35) https://bugs.python.org/issue?@action=redirect&bpo=42158

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30533


File: python.info,  Node: Documentation<23>,  Next: Tests<26>,  Prev: Library<28>,  Up: Python 3 11 0 alpha 3

1.23.29.3 Documentation
.......................

   - bpo-42238(1): ‘make -C Doc suspicious’ will be removed soon in
     favor of ‘make -C Doc check’, mark it as deprecated.

   - bpo-45840(2): Improve cross-references in the documentation for the
     data model.

   - bpo-45640(3): Properly marked-up grammar tokens in the
     documentation are now clickable and take you to the definition of a
     given piece of grammar.  Patch by Arthur Milchior.

   - bpo-45788(4): Link doc for sys.prefix to sysconfig doc on
     installation paths.

   - bpo-45772(5): ‘socket.socket’ documentation is corrected to a class
     from a function.

   - bpo-45392(6): Update the docstring of the *note type: d16. built-in
     to remove a redundant line and to mention keyword arguments for the
     constructor.

   - bpo-45250(7): Update the documentation to note that CPython does
     not consistently require iterators to define ‘__iter__’.

   - bpo-25381(8): In the extending chapter of the extending doc, update
     a paragraph about the global variables containing exception
     information.

   - bpo-43905(9): Expanded *note astuple(): 1695. and *note asdict():
     168b. docs, warning about deepcopy being applied and providing a
     workaround.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42238

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45840

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45640

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45788

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45772

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45392

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45250

   (8) https://bugs.python.org/issue?@action=redirect&bpo=25381

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43905


File: python.info,  Node: Tests<26>,  Next: Build<28>,  Prev: Documentation<23>,  Up: Python 3 11 0 alpha 3

1.23.29.4 Tests
...............

   - bpo-45695(1): Out-of-tree builds with a read-only source directory
     are now tested by CI.

   - bpo-19460(2): Add new Test for
     ‘Lib/email/mime/nonmultipart.py::MIMENonMultipart’.

   - bpo-45835(3): Fix race condition in test_queue tests with multiple
     "feeder" threads.

   - bpo-45783(4): The test for the freeze tool now handles file moves
     and deletions.

   - bpo-45745(5): Remove the ‘--findleaks’ command line option of
     regrtest: use the ‘--fail-env-changed’ option instead.  Since
     Python 3.7, it was a deprecated alias to the ‘--fail-env-changed’
     option.

   - bpo-45701(6): Add tests with ‘tuple’ type with *note
     functools.lru_cache(): 9bd. to ‘test_functools’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45695

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19460

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45835

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45783

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45745

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45701


File: python.info,  Node: Build<28>,  Next: Windows<25>,  Prev: Tests<26>,  Up: Python 3 11 0 alpha 3

1.23.29.5 Build
...............

   - bpo-44035(1): CI now verifies that autoconf files have been
     regenerated with a current and unpatched autoconf package.

   - bpo-45950(2): The build system now uses a ‘_bootstrap_python’
     interpreter for freezing and deepfreezing again.  To speed up build
     process the build tools ‘_bootstrap_python’ and ‘_freeze_module’
     are no longer build with LTO.

   - bpo-45881(3): The ‘configure’ script now accepts
     ‘--with-build-python’ and ‘--with-freeze-module’ options to make
     cross compiling easier.

   - bpo-40280(4): Emscripten platform now uses ‘.wasm’ suffix by
     default.

   - bpo-40280(5): Disable unusable core extension modules on
     WASM/Emscripten targets.

   - bpo-40280(6): ‘configure’ now checks for socket ‘shutdown’
     function.  The check makes it possible to disable ‘SYS_shutdown’
     with ‘ac_cv_func_shutdown=no’ in CONFIG_SITE.

   - bpo-40280(7): ‘configure’ now checks for functions ‘fork1, getegid,
     geteuid, getgid, getppid, getuid, opendir, pipe, system, wait,
     ttyname’.

   - bpo-33393(8): Update ‘config.guess’ to 2021-06-03 and ‘config.sub’
     to 2021-08-14.  ‘Makefile’ now has an ‘update-config’ target to
     make updating more convenient.

   - bpo-45866(9): ‘make regen-all’ now produces the same output when
     run from a directory other than the source tree: when building
     Python out of the source tree.  pegen now strips directory of the
     "generated by pygen from <FILENAME>" header Patch by Victor
     Stinner.

   - bpo-40280(10): ‘configure’ now accepts machine ‘wasm32’ or ‘wasm64’
     and OS ‘wasi’ or ‘emscripten’ for cross building, e.g.
     ‘wasm32-unknown-emscripten’, ‘wasm32-wasi’, or
     ‘wasm32-unknown-wasi’.

   - bpo-41498(11): Python now compiles on platforms without ‘sigset_t’.
     Several functions in *note signal: b4. are not available when
     ‘sigset_t’ is missing.

     Based on patch by Roman Yurchak for pyodide.

   - bpo-45881(12): ‘setup.py’ now uses ‘CC’ from environment first to
     discover multiarch and cross compile paths.

   - bpo-45886(13): The ‘_freeze_module’ program path can now be
     overridden on the command line, e.g.  ‘make
     FREEZE_MODULE=../x86_64/Program/_freeze_module’.

   - bpo-45873(14): Get rid of the ‘_bootstrap_python’ build step.  The
     deepfreeze.py script is now run using ‘$(PYTHON_FOR_REGEN)’ which
     can be Python 3.7 or newer (on Windows, 3.8 or newer).

   - bpo-45847(15): Port builtin hashlib extensions to ‘PY_STDLIB_MOD’
     macro and ‘addext()’.

   - bpo-45723(16): Add ‘autoconf’ helpers for saving and restoring
     environment variables:

        * ‘SAVE_ENV’: Save ‘$CFLAGS’, ‘$LDFLAGS’, ‘$LIBS’, and
          ‘$CPPFLAGS’.

        * ‘RESTORE_ENV’: Restore ‘$CFLAGS’, ‘$LDFLAGS’, ‘$LIBS’, and
          ‘$CPPFLAGS’.

        * ‘WITH_SAVE_ENV([SCRIPT])’: Run ‘SCRIPT’ wrapped with
          ‘SAVE_ENV’ and ‘RESTORE_ENV’.

     Patch by Erlend E. Aasland.

   - bpo-45573(17): Mandatory core modules, that are required to
     bootstrap Python, are now in ‘Modules/Setup.bootstrap’.

   - bpo-45573(18): ‘configure’ now creates ‘Modules/Setup.stdlib’ with
     conditionally enabled/disabled extension module lines.  The file is
     not used, yet.

   - bpo-45573(19): ‘configure’ now uses a unified format to set state,
     compiler flags, and linker flags in Makefile.  The new macro
     ‘PY_STDLIB_MOD’ sets three variables that are consumed by
     ‘Modules/Setup’ and ‘setup.py’.

   - bpo-45816(20): Python now supports building with Visual Studio 2022
     (MSVC v143, VS Version 17.0).  Patch by Jeremiah Vivian.

   - bpo-45800(21): Settings for ‘pyexpat’ C extension are now detected
     by ‘configure’.  The bundled ‘expat’ library is built in
     ‘Makefile’.

   - bpo-45798(22): Settings for *note decimal: 2e. internal C extension
     are now detected by ‘configure’.  The bundled ‘libmpdec’ library is
     built in ‘Makefile’.

   - bpo-45723(23): ‘configure’ has a new option ‘--with-pkg-config’ to
     disable or require pkg-config.

   - bpo-45774(24): The build dependencies for *note sqlite3: ba. are
     now detected by ‘configure’ and ‘pkg-config’.  Patch by Erlend E.
     Aasland.

   - bpo-45763(25): The build dependencies for *note zlib: 119, *note
     bz2: f, and *note lzma: 7e. are now detected by ‘configure’.

   - bpo-45747(26): gdbm and dbm build dependencies are now detected by
     ‘configure’.

   - bpo-45743(27): On macOS, the build system no longer passes
     ‘search_paths_first’ to the linker.  The flag has been the default
     since Xcode 4 / macOS 10.6.

   - bpo-45723(28): ‘configure.ac’ is now compatible with autoconf 2.71.
     Deprecated checks ‘STDC_HEADERS’ and ‘AC_HEADER_TIME’ have been
     removed.

   - bpo-45723(29): ‘configure’ now prints a warning when pkg-config is
     missing.

   - bpo-45731(30): ‘configure --enable-loadable-sqlite-extensions’ is
     now handled by new ‘PY_SQLITE_ENABLE_LOAD_EXTENSION’ macro instead
     of logic in setup.py.

   - bpo-45723(31): configure.ac now uses custom helper macros and
     ‘AC_CACHE_CHECK’ to simplify and speed up configure runs.

   - bpo-45696(32): Skip the marshal step for frozen modules by
     generating C code that produces a set of ready-to-use code objects.
     This speeds up startup time by another 10% or more.

   - bpo-45561(33): Run smelly.py tool from $(srcdir).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44035

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45950

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45881

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33393

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45866

   (10) https://bugs.python.org/issue?@action=redirect&bpo=40280

   (11) https://bugs.python.org/issue?@action=redirect&bpo=41498

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45881

   (13) https://bugs.python.org/issue?@action=redirect&bpo=45886

   (14) https://bugs.python.org/issue?@action=redirect&bpo=45873

   (15) https://bugs.python.org/issue?@action=redirect&bpo=45847

   (16) https://bugs.python.org/issue?@action=redirect&bpo=45723

   (17) https://bugs.python.org/issue?@action=redirect&bpo=45573

   (18) https://bugs.python.org/issue?@action=redirect&bpo=45573

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45573

   (20) https://bugs.python.org/issue?@action=redirect&bpo=45816

   (21) https://bugs.python.org/issue?@action=redirect&bpo=45800

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45798

   (23) https://bugs.python.org/issue?@action=redirect&bpo=45723

   (24) https://bugs.python.org/issue?@action=redirect&bpo=45774

   (25) https://bugs.python.org/issue?@action=redirect&bpo=45763

   (26) https://bugs.python.org/issue?@action=redirect&bpo=45747

   (27) https://bugs.python.org/issue?@action=redirect&bpo=45743

   (28) https://bugs.python.org/issue?@action=redirect&bpo=45723

   (29) https://bugs.python.org/issue?@action=redirect&bpo=45723

   (30) https://bugs.python.org/issue?@action=redirect&bpo=45731

   (31) https://bugs.python.org/issue?@action=redirect&bpo=45723

   (32) https://bugs.python.org/issue?@action=redirect&bpo=45696

   (33) https://bugs.python.org/issue?@action=redirect&bpo=45561


File: python.info,  Node: Windows<25>,  Next: macOS<20>,  Prev: Build<28>,  Up: Python 3 11 0 alpha 3

1.23.29.6 Windows
.................

   - bpo-46105(1): Fixed calculation of *note sys.path: 38e. in a venv
     on Windows.

   - bpo-45901(2): When installed through the Microsoft Store and set as
     the default app for ‘*.py’ files, command line arguments will now
     be passed to Python when invoking a script without explicitly
     launching Python (that is, ‘script.py args’ rather than ‘python
     script.py args’).

   - bpo-45616(3): Fix Python Launcher's ability to distinguish between
     versions 3.1 and 3.10 when either one is explicitly requested.
     Previously, 3.1 would be used if 3.10 was requested but not
     installed, and 3.10 would be used if 3.1 was requested but 3.10 was
     installed.

   - bpo-45850(4): Implement changes to build with deep-frozen modules
     on Windows.  Note that we now require Python 3.10 as the
     "bootstrap" or "host" Python.

   - bpo-45732(5): Updates bundled Tcl/Tk to 8.6.12.

   - bpo-45720(6): Internal reference to ‘shlwapi.dll’ was dropped to
     help improve startup time.  This DLL will no longer be loaded at
     the start of every Python process.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=46105

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45901

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45616

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45850

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45732

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45720


File: python.info,  Node: macOS<20>,  Next: C API<27>,  Prev: Windows<25>,  Up: Python 3 11 0 alpha 3

1.23.29.7 macOS
...............

   - bpo-45732(1): Update python.org macOS installer to use Tcl/Tk
     8.6.12.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45732


File: python.info,  Node: C API<27>,  Prev: macOS<20>,  Up: Python 3 11 0 alpha 3

1.23.29.8 C API
...............

   - bpo-39026(1): Fix Python.h to build C extensions with Xcode: remove
     a relative include from ‘Include/cpython/pystate.h’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39026


File: python.info,  Node: Python 3 11 0 alpha 2,  Next: Python 3 11 0 alpha 1,  Prev: Python 3 11 0 alpha 3,  Up: 変更履歴

1.23.30 Python 3.11.0 alpha 2
-----------------------------

'Release date: 2021-11-05'

* Menu:

* Core and Builtins: Core and Builtins<30>.
* Library: Library<29>.
* Documentation: Documentation<24>.
* Tests: Tests<27>.
* Build: Build<29>.
* Windows: Windows<26>.
* macOS: macOS<21>.
* IDLE: IDLE<18>.
* C API: C API<28>.


File: python.info,  Node: Core and Builtins<30>,  Next: Library<29>,  Up: Python 3 11 0 alpha 2

1.23.30.1 Core and Builtins
...........................

   - bpo-45716(1): Improve the *note SyntaxError: 172. message when
     using ‘True’, ‘None’ or ‘False’ as keywords in a function call.
     Patch by Pablo Galindo.

   - bpo-45688(2): *note sys.stdlib_module_names: 80c. now contains the
     macOS-specific module ‘_scproxy’.

   - bpo-45379(3): Clarify *note ImportError: 3f2. message when we try
     to explicitly import a frozen module but frozen modules are
     disabled.

   - bpo-44525(4): Specialize simple calls to Python functions (no
     starargs, keyword dict, or closure)

   - bpo-45530(5): Cases of sorting using tuples as keys may now be
     significantly faster in some cases.  Patch by Tim Peters.

     The order of the result may differ from earlier releases if the
     tuple elements don't define a total ordering (see *note 値の比較:
     17e6. for information on total ordering).  It's generally true that
     the result of sorting simply isn't well-defined in the absence of a
     total ordering on list elements.

   - bpo-45526(6): In obmalloc, set ADDRESS_BITS to not ignore any bits
     (ignored 16 before).  That is safer in the case that the kernel
     gives user-space virtual addresses that span a range greater than
     48 bits.

   - bpo-30570(7): Fixed a crash in ‘issubclass()’ from infinite
     recursion when searching pathological ‘__bases__’ tuples.

   - bpo-45521(8): Fix a bug in the obmalloc radix tree code.  On 64-bit
     machines, the bug causes the tree to hold 46-bits of virtual
     addresses, rather than the intended 48-bits.

   - bpo-45494(9): Fix parser crash when reporting errors involving
     invalid continuation characters.  Patch by Pablo Galindo.

   - bpo-45445(10): Python now fails to initialize if it finds an
     invalid *note -X: 15c. option in the command line.  Patch by Pablo
     Galindo.

   - bpo-45340(11): Object attributes are held in an array instead of a
     dictionary.  An object's dictionary are created lazily, only when
     needed.  Reduces the memory consumption of a typical Python object
     by about 30%.  Patch by Mark Shannon.

   - bpo-45408(12): Fix a crash in the parser when reporting tokenizer
     errors that occur at the same time unclosed parentheses are
     detected.  Patch by Pablo Galindo.

   - bpo-29410(13): Add SipHash13 for string hash algorithm and use it
     by default.

   - bpo-45385(14): Fix reference leak from descr_check.  Patch by
     Donghee Na.

   - bpo-45367(15): Specialized the ‘BINARY_MULTIPLY’ opcode to
     ‘BINARY_MULTIPLY_INT’ and ‘BINARY_MULTIPLY_FLOAT’ using the PEP 659
     machinery.

   - bpo-21736(16): Frozen stdlib modules now have ‘__file__’ to the .py
     file they would otherwise be loaded from, if possible.  For
     packages, ‘__path__’ now has the correct entry instead of being an
     empty list, which allows unfrozen submodules to be imported.  These
     are set only if the stdlib directory is known when the runtime is
     initialized.  Note that the file at ‘__file__’ is not guaranteed to
     exist.  None of this affects non-stdlib frozen modules nor, for
     now, frozen modules imported using ‘PyImport_ImportFrozenModule()’.
     Also, at the moment ‘co_filename’ is not updated for the module.

   - bpo-45020(17): For frozen stdlib modules, record the original
     module name as ‘module.__spec__.loader_state.origname’.  If the
     value is different than ‘module.__spec__.name’ then the module was
     defined as an alias in Tools/scripts/freeze_modules.py.  If it is
     ‘None’ then the module comes from a source file outside the stdlib.

   - bpo-45324(18): In FrozenImporter.find_spec(), we now preserve the
     information needed in exec_module() to load the module.  This
     change mostly impacts internal details, rather than changing the
     importer's behavior.

   - bpo-45292(19): Implement PEP 654(20).  Add *note ExceptionGroup:
     19b. and *note BaseExceptionGroup: 240.  Update traceback display
     code.

   - bpo-40116(21): Change to the implementation of split dictionaries.
     Classes where the instances differ either in the exact set of
     attributes, or in the order in which those attributes are set, can
     still share keys.  This should have no observable effect on users
     of Python or the C-API. Patch by Mark Shannon.

   - bpo-44050(22): Extensions that indicate they use global state (by
     setting ‘m_size’ to -1) can again be used in multiple interpreters.
     This reverts to behavior of Python 3.8.

   - bpo-44525(23): Setup initial specialization infrastructure for the
     ‘CALL_FUNCTION’ opcode.  Implemented initial specializations for C
     function calls:

        * ‘CALL_FUNCTION_BUILTIN_O’ for ‘METH_O’ flag.

        * ‘CALL_FUNCTION_BUILTIN_FAST’ for ‘METH_FASTCALL’ flag without
          keywords.

        * ‘CALL_FUNCTION_LEN’ for ‘len(o)’.

        * ‘CALL_FUNCTION_ISINSTANCE’ for ‘isinstance(o, t)’.

   - bpo-44511(24): Improve the generated bytecode for class and mapping
     patterns.

   - bpo-43706(25): Speed up calls to ‘enumerate()’ by using the PEP
     590(26) ‘vectorcall’ calling convention.  Patch by Donghee Na.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45716

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45688

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45379

   (4) https://bugs.python.org/issue?@action=redirect&bpo=44525

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45530

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45526

   (7) https://bugs.python.org/issue?@action=redirect&bpo=30570

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45521

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45494

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45445

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45340

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45408

   (13) https://bugs.python.org/issue?@action=redirect&bpo=29410

   (14) https://bugs.python.org/issue?@action=redirect&bpo=45385

   (15) https://bugs.python.org/issue?@action=redirect&bpo=45367

   (16) https://bugs.python.org/issue?@action=redirect&bpo=21736

   (17) https://bugs.python.org/issue?@action=redirect&bpo=45020

   (18) https://bugs.python.org/issue?@action=redirect&bpo=45324

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45292

   (20) https://peps.python.org/pep-0654/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=40116

   (22) https://bugs.python.org/issue?@action=redirect&bpo=44050

   (23) https://bugs.python.org/issue?@action=redirect&bpo=44525

   (24) https://bugs.python.org/issue?@action=redirect&bpo=44511

   (25) https://bugs.python.org/issue?@action=redirect&bpo=43706

   (26) https://peps.python.org/pep-0590/


File: python.info,  Node: Library<29>,  Next: Documentation<24>,  Prev: Core and Builtins<30>,  Up: Python 3 11 0 alpha 2

1.23.30.2 Library
.................

   - bpo-45679(1): Fix caching of multi-value *note typing.Literal: 820.
     ‘Literal[True, 2]’ is no longer equal to ‘Literal[1, 2]’.

   - bpo-42064(2): Convert *note sqlite3: ba. to multi-phase
     initialisation (PEP 489).  Patches by Erlend E. Aasland.

   - bpo-45438(3): Fix typing.Signature string representation for
     generic builtin types.

   - bpo-45613(4): *note sqlite3: ba. now sets *note
     sqlite3.threadsafety: 648. based on the default threading mode the
     underlying SQLite library has been compiled with.  Patch by Erlend
     E. Aasland.

   - bpo-45574(5): Fix warning about ‘print_escape’ being unused.

   - bpo-45581(6): *note sqlite3.connect(): 288. now correctly raises
     *note MemoryError: 1627. if the underlying SQLite API signals
     memory error.  Patch by Erlend E. Aasland.

   - bpo-45557(7): *note pprint.pprint(): 7f3. now handles
     'underscore_numbers' correctly.  Previously it was always setting
     it to ‘False’.

   - bpo-44019(8): Add *note operator.call(): 17e8. to
     ‘operator.__all__’.  Patch by Kreusada.

   - bpo-42174(9): *note shutil.get_terminal_size(): 10d6. now falls
     back to sane values if the column or line count are 0.

   - bpo-35673(10): Improve the introspectability of the ‘__loader__’
     attribute for namespace packages.  *note
     importlib.machinery.NamespaceLoader: f23. is now public, and
     implements the *note importlib.abc.InspectLoader: f21. interface.
     ‘_NamespaceLoader’ is kept for backward compatibility.

   - bpo-45515(11): Add references to *note zoneinfo: 11a. in the *note
     datetime: 28. documentation, mostly replacing outdated references
     to ‘dateutil.tz’.  Change by Paul Ganssle.

   - bpo-45475(12): Reverted optimization of iterating *note
     gzip.GzipFile: 3f3, *note bz2.BZ2File: 832, and *note
     lzma.LZMAFile: fd7. (see bpo-43787(13)) because it caused
     regression when user iterate them without having reference of them.
     Patch by Inada Naoki.

   - bpo-45489(14): Update *note ForwardRef: 17ae. to support ‘|’
     operator.  Patch by Donghee Na.

   - bpo-42222(15): Removed deprecated support for float arguments in
     'randrange()'.

   - bpo-45428(16): Fix a regression in py_compile when reading
     filenames from standard input.

   - bpo-45467(17): Fix incremental decoder and stream reader in the
     "raw-unicode-escape" codec.  Previously they failed if the escape
     sequence was split.

   - bpo-45461(18): Fix incremental decoder and stream reader in the
     "unicode-escape" codec.  Previously they failed if the escape
     sequence was split.

   - bpo-45239(19): Fixed *note email.utils.parsedate_tz(): 17e9.
     crashing with *note UnboundLocalError: 14df. on certain invalid
     input instead of returning ‘None’.  Patch by Ben Hoyt.

   - bpo-45417(20): Fix quadratic behaviour in the enum module: Creation
     of enum classes with a lot of entries was quadratic.

   - bpo-45249(21): Fix the behaviour of *note traceback.print_exc():
     17ea. when displaying the caret when the ‘end_offset’ in the
     exception is set to 0.  Patch by Pablo Galindo

   - bpo-45416(22): Fix use of *note asyncio.Condition: a41. with
     explicit *note asyncio.Lock: a3f. objects, which was a regression
     due to removal of explicit loop arguments.  Patch by Joongi Kim.

   - bpo-20028(23): Empty escapechar/quotechar is not allowed when
     initializing *note csv.Dialect: 15df.  Patch by Vajrasky Kok and
     Donghee Na.

   - bpo-44904(24): Fix bug in the *note doctest: 31. module that caused
     it to fail if a docstring included an example with a ‘classmethod’
     ‘property’.  Patch by Alex Waygood.

   - bpo-45406(25): Make *note inspect.getmodule(): 174f. catch
     ‘FileNotFoundError’ raised by ‘inspect.getabsfile()’, and return
     ‘None’ to indicate that the module could not be determined.

   - bpo-45411(26): Add extensions for files containing subtitles - .srt
     & .vtt - to the mimetypes.py module.

   - bpo-10716(27): Migrated pydoc to HTML5 (without changing the look
     of it).  Side effect is to update xmlrpc's ‘ServerHTMLDoc’ which
     now uses the CSS too.  cgitb now relies less on pydoc (as it can't
     use the CSS file).

   - bpo-27580(28): Add support of null characters in *note csv: 21.

   - bpo-45262(29): Prevent use-after-free in asyncio.  Make sure the
     cached running loop holder gets cleared on dealloc to prevent
     use-after-free in get_running_loop

   - bpo-45386(30): Make *note xmlrpc.client: 114. more robust to C
     runtimes where the underlying C ‘strftime’ function results in a
     ‘ValueError’ when testing for year formatting options.

   - bpo-20028(31): Improve error message of *note csv.Dialect: 15df.
     when initializing.  Patch by Vajrasky Kok and Donghee Na.

   - bpo-45343(32): Update bundled pip to 21.2.4 and setuptools to
     58.1.0

   - bpo-45328(33): Fixed *note http.client.HTTPConnection: b0e. to work
     properly in OSs that don't support the ‘TCP_NODELAY’ socket option.

   - bpo-45243(34): Add *note setlimit(): 646. and *note getlimit():
     647. to *note sqlite3.Connection: 226. for setting and getting
     SQLite limits by connection basis.  Patch by Erlend E. Aasland.

   - bpo-45320(35): Removed from the *note inspect: 72. module:

        * 
          the ‘getargspec’ function, deprecated since Python 3.0;

               use *note inspect.signature(): 703. or *note
               inspect.getfullargspec(): 704. instead.

        * the ‘formatargspec’ function, deprecated since Python 3.5; use
          the *note inspect.signature(): 703. function and ‘Signature’
          object directly.

        * the undocumented ‘Signature.from_builtin’ and
          ‘Signature.from_function’ functions, deprecated since Python
          3.5; use the *note Signature.from_callable(): 705. method
          instead.

     Patch by Hugo van Kemenade.

   - bpo-45192(36): Fix the ‘tempfile._infer_return_type’ function so
     that the ‘dir’ argument of the *note tempfile: c9. functions
     accepts an object implementing the ‘os.PathLike’ protocol.

     Patch by Kyungmin Lee.

   - bpo-45160(37): When tracing a tkinter variable used by a ttk
     OptionMenu, callbacks are no longer made twice.

   - bpo-25625(38): Added non parallel-safe *note chdir(): 5d7. context
     manager to change the current working directory and then restore it
     on exit.  Simple wrapper around *note chdir(): 5d8.

   - bpo-24139(39): Add support for SQLite extended result codes in
     *note sqlite3.Error: 17eb.  Patch by Erlend E. Aasland.

   - bpo-24444(40): Fixed an error raised in *note argparse: 5. help
     display when help for an option is set to 1+ blank spaces or when
     'choices' arg is an empty container.

   - bpo-44547(41): Implement ‘Fraction.__int__’, so that a *note
     fractions.Fraction: 1c8. instance ‘f’ passes an ‘isinstance(f,
     typing.SupportsInt)’ check.

   - bpo-40321(42): Adds support for HTTP 308 redirects to *note urllib:
     f1.  See RFC 7538(43) for details.  Patch by Jochem Schulenklopper.

   - bpo-41374(44): Ensure that ‘socket.TCP_*’ constants are exposed on
     Cygwin 3.1.6 and greater.

   - bpo-35970(45): Add help flag to the base64 module's command line
     interface.  Patch contributed by Robert Kuska.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45679

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42064

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45438

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45613

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45574

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45581

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45557

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44019

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42174

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35673

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45515

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45475

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43787

   (14) https://bugs.python.org/issue?@action=redirect&bpo=45489

   (15) https://bugs.python.org/issue?@action=redirect&bpo=42222

   (16) https://bugs.python.org/issue?@action=redirect&bpo=45428

   (17) https://bugs.python.org/issue?@action=redirect&bpo=45467

   (18) https://bugs.python.org/issue?@action=redirect&bpo=45461

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45239

   (20) https://bugs.python.org/issue?@action=redirect&bpo=45417

   (21) https://bugs.python.org/issue?@action=redirect&bpo=45249

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45416

   (23) https://bugs.python.org/issue?@action=redirect&bpo=20028

   (24) https://bugs.python.org/issue?@action=redirect&bpo=44904

   (25) https://bugs.python.org/issue?@action=redirect&bpo=45406

   (26) https://bugs.python.org/issue?@action=redirect&bpo=45411

   (27) https://bugs.python.org/issue?@action=redirect&bpo=10716

   (28) https://bugs.python.org/issue?@action=redirect&bpo=27580

   (29) https://bugs.python.org/issue?@action=redirect&bpo=45262

   (30) https://bugs.python.org/issue?@action=redirect&bpo=45386

   (31) https://bugs.python.org/issue?@action=redirect&bpo=20028

   (32) https://bugs.python.org/issue?@action=redirect&bpo=45343

   (33) https://bugs.python.org/issue?@action=redirect&bpo=45328

   (34) https://bugs.python.org/issue?@action=redirect&bpo=45243

   (35) https://bugs.python.org/issue?@action=redirect&bpo=45320

   (36) https://bugs.python.org/issue?@action=redirect&bpo=45192

   (37) https://bugs.python.org/issue?@action=redirect&bpo=45160

   (38) https://bugs.python.org/issue?@action=redirect&bpo=25625

   (39) https://bugs.python.org/issue?@action=redirect&bpo=24139

   (40) https://bugs.python.org/issue?@action=redirect&bpo=24444

   (41) https://bugs.python.org/issue?@action=redirect&bpo=44547

   (42) https://bugs.python.org/issue?@action=redirect&bpo=40321

   (43) https://datatracker.ietf.org/doc/html/rfc7538.html

   (44) https://bugs.python.org/issue?@action=redirect&bpo=41374

   (45) https://bugs.python.org/issue?@action=redirect&bpo=35970


File: python.info,  Node: Documentation<24>,  Next: Tests<27>,  Prev: Library<29>,  Up: Python 3 11 0 alpha 2

1.23.30.3 Documentation
.......................

   - bpo-45726(1): Improve documentation for *note
     functools.singledispatch(): 605. and *note
     functools.singledispatchmethod: 9c0.

   - bpo-45680(2): Amend the docs on ‘GenericAlias’ objects to clarify
     that non-container classes can also implement ‘__class_getitem__’.
     Patch contributed by Alex Waygood.

   - bpo-45618(3): Update Sphinx version used to build the documentation
     to 4.2.0.  Patch by Maciej Olko.

   - bpo-45655(4): Add a new "relevant PEPs" section to the top of the
     documentation for the ‘typing’ module.  Patch by Alex Waygood.

   - bpo-45604(5): Add ‘level’ argument to
     ‘multiprocessing.log_to_stderr’ function docs.

   - bpo-45516(6): Add protocol description to the *note
     importlib.abc.TraversableResources: 17ed. documentation.

   - bpo-45464(7): Mention in the documentation of *note Built-in
     Exceptions: 17ee. that inheriting from multiple exception types in
     a single subclass is not recommended due to possible memory layout
     incompatibility.

   - bpo-45449(8): Add note about PEP 585(9) in *note collections.abc:
     17.

   - bpo-45516(10): Add protocol description to the *note
     importlib.abc.Traversable: 17ef. documentation.

   - bpo-20692(11): Add Programming FAQ entry explaining that int
     literal attribute access requires either a space after or
     parentheses around the literal.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45726

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45680

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45618

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45655

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45604

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45516

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45464

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45449

   (9) https://peps.python.org/pep-0585/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45516

   (11) https://bugs.python.org/issue?@action=redirect&bpo=20692


File: python.info,  Node: Tests<27>,  Next: Build<29>,  Prev: Documentation<24>,  Up: Python 3 11 0 alpha 2

1.23.30.4 Tests
...............

   - bpo-45678(1): Add tests for scenarios in which *note
     functools.singledispatchmethod: 9c0. is stacked on top of a method
     that has already been wrapped by two other decorators.  Patch by
     Alex Waygood.

   - bpo-45578(2): Add tests for ‘dis.distb()’

   - bpo-45678(3): Add tests to ensure that
     ‘functools.singledispatchmethod’ correctly wraps the attributes of
     the target function.

   - bpo-45668(4): PGO tests now pass when Python is built without test
     extension modules.

   - bpo-45577(5): Add subtests for all ‘pickle’ protocols in
     ‘test_zoneinfo’.

   - bpo-45566(6): Fix ‘test_frozen_pickle’ in ‘test_dataclasses’ to
     check all ‘pickle’ versions.

   - bpo-43592(7): ‘test.libregrtest’ now raises the soft resource limit
     for the maximum number of file descriptors when the default is too
     low for our test suite as was often the case on macOS.

   - bpo-39679(8): Add more test cases for
     ‘@functools.singledispatchmethod’ when combined with ‘@classmethod’
     or ‘@staticmethod’.

   - bpo-45410(9): When libregrtest spawns a worker process, stderr is
     now written into stdout to keep messages order.  Use a single pipe
     for stdout and stderr, rather than two pipes.  Previously, messages
     were out of order which made analysis of buildbot logs harder Patch
     by Victor Stinner.

   - bpo-45402(10): Fix test_tools.test_sundry() when Python is built
     out of tree: fix how the freeze_modules.py tool locates the
     _freeze_module program.  Patch by Victor Stinner.

   - bpo-45403(11): Fix test_sys.test_stdlib_dir() when Python is built
     outside the source tree: compare normalized paths.  Patch by Victor
     Stinner.

   - bpo-45400(12): Fix
     test_name_error_suggestions_do_not_trigger_for_too_many_locals() of
     test_exceptions if a directory name contains "a1" (like
     "Python-3.11.0a1"): use a stricter regular expression.  Patch by
     Victor Stinner.

   - bpo-10572(13): Rename *note sqlite3: ba. tests from ‘test_sqlite’
     to ‘test_sqlite3’, and relocate them to ‘Lib/test/test_sqlite3’.
     Patch by Erlend E. Aasland.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45678

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45578

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45678

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45668

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45577

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45566

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43592

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39679

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45410

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45402

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45403

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45400

   (13) https://bugs.python.org/issue?@action=redirect&bpo=10572


File: python.info,  Node: Build<29>,  Next: Windows<26>,  Prev: Tests<27>,  Up: Python 3 11 0 alpha 2

1.23.30.5 Build
...............

   - bpo-43158(1): ‘setup.py’ now uses values from configure script to
     build the ‘_uuid’ extension module.  Configure now detects
     util-linux's ‘libuuid’, too.

   - bpo-45666(2): Fix warning of ‘swprintf’ and ‘%s’ usage in
     ‘_testembed.c’

   - bpo-45548(3): ‘Modules/Setup’ and ‘Modules/makesetup’ have been
     improved.  The ‘Setup’ file now contains working rules for all
     extensions.  Outdated comments have been removed.  Rules defined by
     ‘makesetup’ track dependencies correctly.

   - bpo-45548(4): The *note math: 81. and *note cmath: 11.
     implementation now require a C99 compatible ‘libm’ and no longer
     ship with workarounds for missing acosh, asinh, atanh, expm1, and
     log1p functions.

   - bpo-45595(5): ‘setup.py’ and ‘makesetup’ now track build
     dependencies on all Python header files and module specific header
     files.

   - bpo-45571(6): ‘Modules/Setup’ now use ‘PY_CFLAGS_NODIST’ instead of
     ‘PY_CFLAGS’ to compile shared modules.

   - bpo-45570(7): ‘pyexpat’ and ‘_elementtree’ no longer define
     obsolete macros ‘HAVE_EXPAT_CONFIG_H’ and ‘USE_PYEXPAT_CAPI’.
     ‘XML_POOR_ENTROPY’ is now defined in ‘expat_config.h’.

   - bpo-43974(8): ‘setup.py’ no longer defines ‘Py_BUILD_CORE_MODULE’.
     Instead every module, that uses the internal API, defines the
     macro.

   - bpo-45548(9): Fill in missing entries in Modules/Setup.

   - bpo-45532(10): Update *note sys.version: 15e. to use ‘main’ as
     fallback information.  Patch by Jeong YunWon.

   - bpo-45536(11): The ‘configure’ script now checks whether OpenSSL
     headers and libraries provide required APIs.  Most common APIs are
     verified.  The check detects outdated or missing OpenSSL. Failures
     do not stop configure.

   - bpo-45221(12): Fixed regression in handling of ‘LDFLAGS’ and
     ‘CPPFLAGS’ options where ‘argparse.parse_known_args()’ could
     interpret an option as one of the built-in command line argument,
     for example ‘-h’ for help.

   - bpo-45440(13): Building Python now requires a C99 ‘<math.h>’ header
     file providing the following functions: ‘copysign()’, ‘hypot()’,
     ‘isfinite()’, ‘isinf()’, ‘isnan()’, ‘round()’.  Patch by Victor
     Stinner.

   - bpo-45405(14): Prevent ‘internal configure error’ when running
     ‘configure’ with recent versions of non-Apple clang.  Patch by
     David Bohman.

   - bpo-45433(15): Avoid linking libpython with libcrypt.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43158

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45666

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45548

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45548

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45595

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45571

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45570

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43974

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45548

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45532

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45536

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45221

   (13) https://bugs.python.org/issue?@action=redirect&bpo=45440

   (14) https://bugs.python.org/issue?@action=redirect&bpo=45405

   (15) https://bugs.python.org/issue?@action=redirect&bpo=45433


File: python.info,  Node: Windows<26>,  Next: macOS<21>,  Prev: Build<29>,  Up: Python 3 11 0 alpha 2

1.23.30.6 Windows
.................

   - bpo-43652(1): Update Tcl/Tk to 8.6.11, actually this time.  The
     previous update incorrectly included 8.6.10.

   - bpo-45337(2): venv now warns when the created environment may need
     to be accessed at a different path, due to redirections, links or
     junctions.  It also now correctly installs or upgrades components
     when the alternate path is required.

   - bpo-43851(3): Build SQLite ‘SQLITE_OMIT_AUTOINIT’ on Windows.
     Patch by Erlend E. Aasland.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43652

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45337

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43851


File: python.info,  Node: macOS<21>,  Next: IDLE<18>,  Prev: Windows<26>,  Up: Python 3 11 0 alpha 2

1.23.30.7 macOS
...............

   - bpo-44828(1): Avoid tkinter file dialog failure on macOS 12
     Monterey when using the Tk 8.6.11 provided by python.org macOS
     installers.  Patch by Marc Culler of the Tk project.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44828


File: python.info,  Node: IDLE<18>,  Next: C API<28>,  Prev: macOS<21>,  Up: Python 3 11 0 alpha 2

1.23.30.8 IDLE
..............

   - bpo-45495(1): Add context keywords 'case' and 'match' to
     completions list.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45495


File: python.info,  Node: C API<28>,  Prev: IDLE<18>,  Up: Python 3 11 0 alpha 2

1.23.30.9 C API
...............

   - bpo-29103(1): *note PyType_FromSpec*: 51c. now copies the class
     name from the spec to a buffer owned by the class, so the original
     can be safely deallocated.  Patch by Petr Viktorin.

   - bpo-45522(2): The internal freelists for frame, float, list, dict,
     async generators, and context objects can now be disabled.

   - bpo-35134(3): Exclude *note PyWeakref_GET_OBJECT(): 399. from the
     limited C API. It never worked since the ‘PyWeakReference’
     structure is opaque in the limited C API.

   - bpo-35081(4): Move the ‘interpreteridobject.h’ header file from
     ‘Include/’ to ‘Include/internal/’.  It only provides private
     functions.  Patch by Victor Stinner.

   - bpo-35134(5): The non-limited API files ‘cellobject.h’,
     ‘classobject.h’, ‘context.h’, ‘funcobject.h’, ‘genobject.h’ and
     ‘longintrepr.h’ have been moved to the ‘Include/cpython’ directory.
     Moreover, the ‘eval.h’ header file was removed.  These files must
     not be included directly, as they are already included in
     ‘Python.h’: *note Include Files: 74f.  If they have been included
     directly, consider including ‘Python.h’ instead.  Patch by Victor
     Stinner.

   - bpo-45474(6): The following items are no longer available when
     ‘Py_LIMITED_API’ is defined:

        * *note PyMarshal_WriteLongToFile(): 761.

        * *note PyMarshal_WriteObjectToFile(): 762.

        * *note PyMarshal_ReadObjectFromString(): 763.

        * *note PyMarshal_WriteObjectToString(): 764.

        * the ‘Py_MARSHAL_VERSION’ macro

     These are not part of the *note limited API: 765.

     Patch by Victor Stinner.

   - bpo-45434(7): Remove the ‘pystrhex.h’ header file.  It only
     contains private functions.  C extensions should only include the
     main ‘<Python.h>’ header file.  Patch by Victor Stinner.

   - bpo-45440(8): Remove the ‘Py_FORCE_DOUBLE()’ macro.  It was used by
     the ‘Py_IS_INFINITY()’ macro.  Patch by Victor Stinner.

   - bpo-45434(9): ‘<Python.h>’ no longer includes the header files
     ‘<stdlib.h>’, ‘<stdio.h>’, ‘<errno.h>’ and ‘<string.h>’ when the
     ‘Py_LIMITED_API’ macro is set to ‘0x030b0000’ (Python 3.11) or
     higher.  C extensions should explicitly include the header files
     after ‘#include <Python.h>’.  Patch by Victor Stinner.

   - bpo-41123(10): Remove ‘Py_UNICODE_COPY()’ and ‘Py_UNICODE_FILL()’
     macros, deprecated since Python 3.3.  Use
     ‘PyUnicode_CopyCharacters()’ or ‘memcpy()’ (‘wchar_t*’ string), and
     ‘PyUnicode_Fill()’ functions instead.  Patch by Victor Stinner.

   - bpo-45412(11): Remove the following math macros using the ‘errno’
     variable:

        * ‘Py_ADJUST_ERANGE1()’

        * ‘Py_ADJUST_ERANGE2()’

        * ‘Py_OVERFLOWED()’

        * ‘Py_SET_ERANGE_IF_OVERFLOW()’

        * ‘Py_SET_ERRNO_ON_MATH_ERROR()’

     Patch by Victor Stinner.

   - bpo-45395(12): Custom frozen modules (the array set to
     ‘PyImport_FrozenModules’) are now treated as additions, rather than
     replacing all the default frozen modules.  Frozen stdlib modules
     can still be disabled by setting the "code" field of the custom
     array entry to NULL.

   - bpo-43760(13): Add new *note PyThreadState_EnterTracing(): 71f, and
     *note PyThreadState_LeaveTracing(): 720. functions to the limited C
     API to suspend and resume tracing and profiling.  Patch by Victor
     Stinner.

   - bpo-44220(14): *note PyStructSequence_UnnamedField: 950. is added
     to the Stable ABI.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29103

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45522

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35081

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45474

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45434

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45440

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45434

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41123

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45412

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45395

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43760

   (14) https://bugs.python.org/issue?@action=redirect&bpo=44220


File: python.info,  Node: Python 3 11 0 alpha 1,  Next: Python 3 10 0 beta 1,  Prev: Python 3 11 0 alpha 2,  Up: 変更履歴

1.23.31 Python 3.11.0 alpha 1
-----------------------------

'Release date: 2021-10-05'

* Menu:

* Security: Security<17>.
* Core and Builtins: Core and Builtins<31>.
* Library: Library<30>.
* Documentation: Documentation<25>.
* Tests: Tests<28>.
* Build: Build<30>.
* Windows: Windows<27>.
* macOS: macOS<22>.
* IDLE: IDLE<19>.
* Tools/Demos: Tools/Demos<14>.
* C API: C API<29>.


File: python.info,  Node: Security<17>,  Next: Core and Builtins<31>,  Up: Python 3 11 0 alpha 1

1.23.31.1 Security
..................

   - bpo-42278(1): Replaced usage of *note tempfile.mktemp(): 17f8. with
     *note TemporaryDirectory: 1205. to avoid a potential race
     condition.

   - bpo-44600(2): Fix incorrect line numbers while tracing some failed
     patterns in *note match: 7d8. statements.  Patch by Charles
     Burkland.

   - bpo-41180(3): Add auditing events to the *note marshal: 80. module,
     and stop raising ‘code.__init__’ events for every unmarshalled code
     object.  Directly instantiated code objects will continue to raise
     an event, and audit event handlers should inspect or collect the
     raw marshal data.  This reduces a significant performance overhead
     when loading from ‘.pyc’ files.

   - bpo-44394(4): Update the vendored copy of libexpat to 2.4.1 (from
     2.2.8) to get the fix for the CVE 2013-0340(5) "Billion Laughs"
     vulnerability.  This copy is most used on Windows and macOS.

   - bpo-43124(6): Made the internal ‘putcmd’ function in *note smtplib:
     b7. sanitize input for presence of ‘\r’ and ‘\n’ characters to
     avoid (unlikely) command injection.

   - bpo-44022(7): *note http.client: 65. now avoids infinitely reading
     potential HTTP headers after a ‘100 Continue’ status response from
     the server.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42278

   (2) https://bugs.python.org/issue?@action=redirect&bpo=44600

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41180

   (4) https://bugs.python.org/issue?@action=redirect&bpo=44394

   (5) https://www.cve.org/CVERecord?id=CVE-2013-0340

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43124

   (7) https://bugs.python.org/issue?@action=redirect&bpo=44022


File: python.info,  Node: Core and Builtins<31>,  Next: Library<30>,  Prev: Security<17>,  Up: Python 3 11 0 alpha 1

1.23.31.2 Core and Builtins
...........................

   - bpo-43760(1): The number of hardware branches per instruction
     dispatch is reduced from two to one by adding a special instruction
     for tracing.  Patch by Mark Shannon.

   - bpo-45061(2): Add a deallocator to the bool type to detect refcount
     bugs in C extensions which call Py_DECREF(Py_True) or
     Py_DECREF(Py_False) by mistake.  Detect also refcount bugs when the
     empty tuple singleton or the Unicode empty string singleton is
     destroyed by mistake.  Patch by Victor Stinner.

   - bpo-24076(3): sum() was further optimised for summing up single
     digit integers.

   - bpo-45190(4): Update Unicode databases to Unicode 14.0.0.

   - bpo-45167(5): Fix deepcopying of *note types.GenericAlias: 7b6.
     objects.

   - bpo-45155(6): *note int.to_bytes(): 17fa. and *note
     int.from_bytes(): 17ba. now take a default value of ‘"big"’ for the
     ‘byteorder’ argument.  *note int.to_bytes(): 17fa. also takes a
     default value of ‘1’ for the ‘length’ argument.

   - bpo-44219(7): Release the GIL while performing ‘isatty’ system
     calls on arbitrary file descriptors.  In particular, this affects
     *note os.isatty(): 17fb, *note os.device_encoding(): 17fc. and
     *note io.TextIOWrapper: 786.  By extension, *note io.open(): 4e6.
     in text mode is also affected.  This change solves a deadlock in
     *note os.isatty(): 17fb.  Patch by Vincent Michel in bpo-44219(8).

   - bpo-44959(9): Added fallback to extension modules with '.sl' suffix
     on HP-UX

   - bpo-45121(10): Fix issue where ‘Protocol.__init__’ raises
     ‘RecursionError’ when it's called directly or via ‘super()’.  Patch
     provided by Yurii Karabas.

   - bpo-44348(11): The deallocator function of the *note BaseException:
     584. type now uses the trashcan mechanism to prevent stack
     overflow.  For example, when a *note RecursionError: d39. instance
     is raised, it can be linked to another RecursionError through the
     ‘__context__’ attribute or the ‘__traceback__’ attribute, and then
     a chain of exceptions is created.  When the chain is destroyed,
     nested deallocator function calls can crash with a stack overflow
     if the chain is too long compared to the available stack memory.
     Patch by Victor Stinner.

   - bpo-45123(12): Fix PyAiter_Check to only check for the __anext__
     presence (not for __aiter__).  Rename PyAiter_Check to
     PyAIter_Check, PyObject_GetAiter -> PyObject_GetAIter.

   - bpo-1514420(13): Interpreter no longer attempts to open files with
     names in angle brackets (like "<string>" or "<stdin>") when
     formatting an exception.

   - bpo-41031(14): Match C and Python code formatting of unprintable
     exceptions and exceptions in the *note __main__: 1. module.

   - bpo-37330(15): *note open(): 4e5, *note io.open(): 4e6, *note
     codecs.open(): 70b. and *note fileinput.FileInput: 702. no longer
     accept ‘'U'’ ("universal newline") in the file mode.  This flag was
     deprecated since Python 3.3.  Patch by Victor Stinner.

   - bpo-45083(16): When the interpreter renders an exception, its name
     now has a complete qualname.  Previously only the class name was
     concatenated to the module name, which sometimes resulted in an
     incorrect full name being displayed.

     (This issue impacted only the C code exception rendering, the *note
     traceback: e7. module was using qualname already).

   - bpo-34561(17): List sorting now uses the merge-ordering strategy
     from Munro and Wild's ‘powersort()’.  Unlike the former strategy,
     this is provably near-optimal in the entropy of the distribution of
     run lengths.  Most uses of ‘list.sort()’ probably won't see a
     significant time difference, but may see significant improvements
     in cases where the former strategy was exceptionally poor.
     However, as these are all fast linear-time approximations to a
     problem that's inherently at best quadratic-time to solve truly
     optimally, it's also possible to contrive cases where the former
     strategy did better.

   - bpo-45056(18): Compiler now removes trailing unused constants from
     co_consts.

   - bpo-45020(19): Add a new command line option, "-X
     frozen_modules=[on|off]" to opt out of (or into) using optional
     frozen modules.  This defaults to "on" (or "off" if it's running
     out of the source tree).

   - bpo-45012(20): In *note posix: 9b, release GIL during ‘stat()’,
     ‘lstat()’, and ‘fstatat()’ syscalls made by *note
     os.DirEntry.stat(): 165f.  Patch by Stanisław Skonieczny.

   - bpo-45018(21): Fixed pickling of range iterators that iterated for
     over ‘2**32’ times.

   - bpo-45000(22): A *note SyntaxError: 172. is now raised when trying
     to delete *note __debug__: 7a5.  Patch by Donghee Na.

   - bpo-44963(23): Implement ‘send()’ and ‘throw()’ methods for
     ‘anext_awaitable’ objects.  Patch by Pablo Galindo.

   - bpo-44962(24): Fix a race in WeakKeyDictionary, WeakValueDictionary
     and WeakSet when two threads attempt to commit the last pending
     removal.  This fixes asyncio.create_task and fixes a data loss in
     asyncio.run where shutdown_asyncgens is not run

   - bpo-24234(25): Implement the ‘__bytes__()’ special method on the
     *note bytes: 1a4. type, so a bytes object ‘b’ passes an
     ‘isinstance(b, typing.SupportsBytes)’ check.

   - bpo-24234(26): Implement the ‘__complex__()’ special method on the
     *note complex: 2cf. type, so a complex number ‘z’ passes an
     ‘isinstance(z, typing.SupportsComplex)’ check.

   - bpo-44954(27): Fixed a corner case bug where the result of
     ‘float.fromhex('0x.8p-1074')’ was rounded the wrong way.

   - bpo-44947(28): Refine the syntax error for trailing commas in
     import statements.  Patch by Pablo Galindo.

   - bpo-44945(29): Specialize the BINARY_ADD instruction using the PEP
     659 machinery.  Adds five new instructions:

        * BINARY_ADD_ADAPTIVE

        * BINARY_ADD_FLOAT

        * BINARY_ADD_INT

        * BINARY_ADD_UNICODE

        * BINARY_ADD_UNICODE_INPLACE_FAST

   - bpo-44929(30): Fix some edge cases of ‘enum.Flag’ string
     representation in the REPL. Patch by Pablo Galindo.

   - bpo-44914(31): Class version tags are no longer recycled.

     This means that a version tag serves as a unique identifier for the
     state of a class.  We rely on this for effective specialization of
     the LOAD_ATTR and other instructions.

   - bpo-44698(32): Restore behaviour of complex exponentiation with
     integer-valued exponent of type *note float: 2ce. or *note complex:
     2cf.

   - bpo-44895(33): A debug variable *note PYTHONDUMPREFSFILE: 17fd. is
     added for creating a dump file which is generated by *note
     -with-trace-refs: 36e.  Patch by Donghee Na.

   - bpo-44900(34): Add five superinstructions for PEP 659 quickening:

        * LOAD_FAST LOAD_FAST

        * STORE_FAST LOAD_FAST

        * LOAD_FAST LOAD_CONST

        * LOAD_CONST LOAD_FAST

        * STORE_FAST STORE_FAST

   - bpo-44889(35): Initial implementation of adaptive specialization of
     ‘LOAD_METHOD’.  The following specialized forms were added:

        * ‘LOAD_METHOD_CACHED’

        * ‘LOAD_METHOD_MODULE’

        * ‘LOAD_METHOD_CLASS’

   - bpo-44890(36): Specialization stats are always collected in debug
     builds.

   - bpo-44885(37): Correct the ast locations of f-strings with format
     specs and repeated expressions.  Patch by Pablo Galindo

   - bpo-44878(38): Remove the loop from the bytecode interpreter.  All
     instructions end with a DISPATCH macro, so the loop is now
     redundant.

   - bpo-44878(39): Remove switch statement for interpreter loop when
     using computed gotos.  This makes sure that we only have one
     dispatch table in the interpreter.

   - bpo-44874(40): Deprecate the old trashcan macros
     (‘Py_TRASHCAN_SAFE_BEGIN’/‘Py_TRASHCAN_SAFE_END’).  They should be
     replaced by the new macros ‘Py_TRASHCAN_BEGIN’ and
     ‘Py_TRASHCAN_END’.

   - bpo-44872(41): Use new trashcan macros (Py_TRASHCAN_BEGIN/END) in
     frameobject.c instead of the old ones (Py_TRASHCAN_SAFE_BEGIN/END).

   - bpo-33930(42): Fix segmentation fault with deep recursion when
     cleaning method objects.  Patch by Augusto Goulart and Pablo
     Galindo.

   - bpo-25782(43): Fix bug where ‘PyErr_SetObject’ hangs when the
     current exception has a cycle in its context chain.

   - bpo-44856(44): Fix reference leaks in the error paths of
     ‘update_bases()’ and ‘__build_class__’.  Patch by Pablo Galindo.

   - bpo-44826(45): Initial implementation of adaptive specialization of
     STORE_ATTR

     Three specialized forms of STORE_ATTR are added:

        * STORE_ATTR_SLOT

        * STORE_ATTR_SPLIT_KEYS

        * STORE_ATTR_WITH_HINT

   - bpo-44838(46): Fixed a bug that was causing the parser to raise an
     incorrect custom *note SyntaxError: 172. for invalid 'if'
     expressions.  Patch by Pablo Galindo.

   - bpo-44821(47): Create instance dictionaries (__dict__) eagerly, to
     improve regularity of object layout and assist specialization.

   - bpo-44792(48): Improve syntax errors for if expressions.  Patch by
     Miguel Brito

   - bpo-34013(49): Generalize the invalid legacy statement custom error
     message (like the one generated when "print" is called without
     parentheses) to include more generic expressions.  Patch by Pablo
     Galindo

   - bpo-44732(50): Rename ‘types.Union’ to ‘types.UnionType’.

   - bpo-44725(51): Expose specialization stats in python via
     ‘_opcode.get_specialization_stats()’.

   - bpo-44717(52): Improve AttributeError on circular imports of
     submodules.

   - bpo-44698(53): Fix undefined behaviour in complex object
     exponentiation.

   - bpo-44653(54): Support *note typing: ed. types in parameter
     substitution in the union type.

   - bpo-44676(55): Add ability to serialise ‘types.Union’ objects.
     Patch provided by Yurii Karabas.

   - bpo-44633(56): Parameter substitution of the union type with wrong
     types now raises ‘TypeError’ instead of returning *note
     NotImplemented: 79d.

   - bpo-44661(57): Update ‘property_descr_set’ to use vectorcall if
     possible.  Patch by Donghee Na.

   - bpo-44662(58): Add ‘__module__’ to ‘types.Union’.  This also fixes
     ‘types.Union’ issues with ‘typing.Annotated’.  Patch provided by
     Yurii Karabas.

   - bpo-44655(59): Include the name of the type in unset __slots__
     attribute errors.  Patch by Pablo Galindo

   - bpo-44655(60): Don't include a missing attribute with the same name
     as the failing one when offering suggestions for missing
     attributes.  Patch by Pablo Galindo

   - bpo-44646(61): Fix the hash of the union type: it no longer depends
     on the order of arguments.

   - bpo-44636(62): Collapse union of equal types.  E.g.  the result of
     ‘int | int’ is now ‘int’.  Fix comparison of the union type with
     non-hashable objects.  E.g.  ‘int | str == {}’ no longer raises a
     TypeError.

   - bpo-44611(63): On Windows, *note os.urandom(): 4ec.: uses
     BCryptGenRandom API instead of CryptGenRandom API which is
     deprecated from Microsoft Windows API. Patch by Donghee Na.

   - bpo-44635(64): Convert ‘None’ to ‘type(None)’ in the union type
     constructor.

   - bpo-26280(65): Implement adaptive specialization for BINARY_SUBSCR

     Three specialized forms of BINARY_SUBSCR are added:

        * BINARY_SUBSCR_LIST_INT

        * BINARY_SUBSCR_TUPLE_INT

        * BINARY_SUBSCR_DICT

   - bpo-44589(66): Mapping patterns in ‘match’ statements with two or
     more equal literal keys will now raise a *note SyntaxError: 172. at
     compile-time.

   - bpo-44606(67): Fix ‘__instancecheck__’ and ‘__subclasscheck__’ for
     the union type.

   - bpo-42073(68): The ‘@classmethod’ decorator can now wrap other
     classmethod-like descriptors.

   - bpo-41972(69): Tuned the string-searching algorithm of fastsearch.h
     to have a shorter inner loop for most cases.

   - bpo-44590(70): All necessary data for executing a Python function
     (local variables, stack, etc) is now kept in a per-thread stack.
     Frame objects are lazily allocated on demand.  This increases
     performance by about 7% on the standard benchmark suite.
     Introspection and debugging are unaffected as frame objects are
     always available when needed.  Patch by Mark Shannon.

   - bpo-44584(71): The threading debug (‘PYTHONTHREADDEBUG’ environment
     variable) is deprecated in Python 3.10 and will be removed in
     Python 3.12.  This feature requires a debug build of Python.  Patch
     by Victor Stinner.

   - bpo-43895(72): An obsolete internal cache of shared object file
     handles added in 1995 that attempted, but did not guarantee, that a
     .so would not be dlopen'ed twice to work around flaws in mid-1990s
     posix-ish operating systems has been removed from dynload_shlib.c.

   - bpo-44490(73): *note typing: ed. now searches for type parameters
     in ‘types.Union’ objects.  ‘get_type_hints’ will also properly
     resolve annotations with nested ‘types.Union’ objects.  Patch
     provided by Yurii Karabas.

   - bpo-43950(74): Code objects can now provide the column information
     for instructions when available.  This is levaraged during
     traceback printing to show the expressions responsible for errors.

     Contributed by Pablo Galindo, Batuhan Taskaya and Ammar Askar as
     part of PEP 657(75).

   - bpo-44562(76): Remove uses of *note PyObject_GC_Del(): 14ae. in
     error path when initializing *note types.GenericAlias: 7b6.

   - bpo-41486(77): Fix a memory consumption and copying performance
     regression in earlier 3.10 beta releases if someone used an output
     buffer larger than 4GiB with zlib.decompress on input data that
     expands that large.

   - bpo-43908(78): Heap types with the *note Py_TPFLAGS_IMMUTABLETYPE:
     39c. flag can now inherit the PEP 590(79) vectorcall protocol.
     Previously, this was only possible for *note static types: 74a.
     Patch by Erlend E. Aasland.

   - bpo-44553(80): Implement GC methods for ‘types.Union’ to break
     reference cycles and prevent memory leaks.

   - bpo-44490(81): Add ‘__parameters__’ attribute and ‘__getitem__’
     operator to ‘types.Union’.  Patch provided by Yurii Karabas.

   - bpo-44523(82): Remove the pass-through for *note hash(): 5b5. of
     *note weakref.proxy: a20. objects to prevent unintended
     consequences when the original referred object dies while the proxy
     is part of a hashable object.  Patch by Pablo Galindo.

   - bpo-44483(83): Fix a crash in ‘types.Union’ objects when creating a
     union of an object with bad ‘__module__’ field.

   - bpo-44486(84): Modules will always have a dictionary, even when
     created by ‘types.ModuleType.__new__()’

   - bpo-44472(85): Fix ltrace functionality when exceptions are raised.
     Patch by Pablo Galindo

   - bpo-12022(86): A *note TypeError: 502. is now raised instead of an
     *note AttributeError: 326. in *note with: 59c. and *note async
     with: 59f. statements for objects which do not support the *note
     context manager: 59e. or *note asynchronous context manager: 5a1.
     protocols correspondingly.

   - bpo-44297(87): Make sure that the line number is set when entering
     a comprehension scope.  This ensures that backtraces including
     generator expressions show the correct line number.

   - bpo-44456(88): Improve the syntax error when mixing positional and
     keyword patterns.  Patch by Pablo Galindo.

   - bpo-44409(89): Fix error location information for tokenizer errors
     raised on initialization of the tokenizer.  Patch by Pablo Galindo.

   - bpo-44396(90): Fix a possible crash in the tokenizer when raising
     syntax errors for unclosed strings.  Patch by Pablo Galindo.

   - bpo-44376(91): Exact integer exponentiation (like ‘i**2’ or ‘pow(i,
     2)’) with a small exponent is much faster, due to reducing overhead
     in such cases.

   - bpo-44313(92): Directly imported objects and modules (through
     import and from import statements) don't generate
     ‘LOAD_METHOD’/‘CALL_METHOD’ for directly accessed objects on their
     namespace.  They now use the regular ‘LOAD_ATTR’/‘CALL_FUNCTION’.

   - bpo-44338(93): Implement adaptive specialization for LOAD_GLOBAL

     Two specialized forms of LOAD_GLOBAL are added:

        * LOAD_GLOBAL_MODULE

        * LOAD_GLOBAL_BUILTIN

   - bpo-44368(94): Improve syntax errors for invalid "as" targets.
     Patch by Pablo Galindo

   - bpo-44349(95): Fix an edge case when displaying text from files
     with encoding in syntax errors.  Patch by Pablo Galindo.

   - bpo-44337(96): Initial implementation of adaptive specialization of
     LOAD_ATTR

     Four specialized forms of LOAD_ATTR are added:

        * LOAD_ATTR_SLOT

        * LOAD_ATTR_SPLIT_KEYS

        * LOAD_ATTR_WITH_HINT

        * LOAD_ATTR_MODULE

   - bpo-44335(97): Fix a regression when identifying incorrect
     characters in syntax errors.  Patch by Pablo Galindo

   - bpo-43693(98): Computation of the offsets of cell variables is done
     in the compiler instead of at runtime.  This reduces the overhead
     of handling cell and free variables, especially in the case where a
     variable is both an argument and cell variable.

   - bpo-44317(99): Improve tokenizer error with improved locations.
     Patch by Pablo Galindo.

   - bpo-44304(100): Fix a crash in the *note sqlite3: ba. module that
     happened when the garbage collector clears ‘sqlite.Statement’
     objects.  Patch by Pablo Galindo

   - bpo-44305(101): Improve error message for ‘try’ blocks without
     ‘except’ or ‘finally’ blocks.  Patch by Pablo Galindo.

   - bpo-43413(102): Constructors of subclasses of some builtin classes
     (e.g.  *note tuple: 349, *note list: 5dc, *note frozenset: 5a4.) no
     longer accept arbitrary keyword arguments.  [reverted in 3.11a4]
     Subclass of *note set: 5a3. can now define a ‘__new__()’ method
     with additional keyword parameters without overriding also
     ‘__init__()’.

   - bpo-43667(103): Improve Unicode support in non-UTF locales on
     Oracle Solaris.  This issue does not affect other Solaris systems.

   - bpo-43693(104): A new opcode MAKE_CELL has been added that
     effectively moves some of the work done on function entry into the
     compiler and into the eval loop.  In addition to creating the
     required cell objects, the new opcode converts relevant arguments
     (and other locals) to cell variables on function entry.

   - bpo-44232(105): Fix a regression in *note type(): d16. when a
     metaclass raises an exception.  The C function ‘type_new()’ must
     properly report the exception when a metaclass constructor raises
     an exception and the winner class is not the metaclass.  Patch by
     Victor Stinner.

   - bpo-44201(106): Avoid side effects of checking for specialized
     syntax errors in the REPL that was causing it to ask for extra
     tokens after a syntax error had been detected.  Patch by Pablo
     Galindo

   - bpo-43693(107): ‘PyCodeObject’ gained ‘co_fastlocalnames’ and
     ‘co_fastlocalkinds’ as the authoritative source of fast locals
     info.  Marshaled code objects have changed accordingly.

   - bpo-44184(108): Fix a crash at Python exit when a deallocator
     function removes the last strong reference to a heap type.  Patch
     by Victor Stinner.

   - bpo-44187(109): Implement quickening in the interpreter.  This
     offers no advantages as yet, but is an enabler of future
     optimizations.  See PEP 659 for full explanation.

   - bpo-44180(110): The parser doesn't report generic syntax errors
     that happen in a position further away that the one it reached in
     the first pass.  Patch by Pablo Galindo

   - bpo-44168(111): Fix error message in the parser involving keyword
     arguments with invalid expressions.  Patch by Pablo Galindo

   - bpo-44156(112): String caches in ‘compile.c’ are now subinterpreter
     compatible.

   - bpo-44143(113): Fixed a crash in the parser that manifest when
     raising tokenizer errors when an existing exception was present.
     Patch by Pablo Galindo.

   - bpo-44032(114): Move 'fast' locals and other variables from the
     frame object to a per-thread datastack.

   - bpo-44114(115): Fix incorrect dictkeys_reversed and
     dictitems_reversed function signatures in C code, which broke
     webassembly builds.

   - bpo-44110(116): Improve ‘str.__getitem__()’ error message

   - bpo-26110(117): Add ‘CALL_METHOD_KW’ opcode to speed up method
     calls with keyword arguments.  Idea originated from PyPy.  A side
     effect is executing ‘CALL_METHOD’ is now branchless in the
     evaluation loop.

   - bpo-28307(118): Compiler now optimizes simple C-style formatting
     with literal format containing only format codes %s, %r and %a by
     converting them to f-string expressions.

   - bpo-43149(119): Correct the syntax error message regarding multiple
     exception types to not refer to "exception groups".  Patch by Pablo
     Galindo

   - bpo-43822(120): The parser will prioritize tokenizer errors over
     custom syntax errors when raising exceptions.  Patch by Pablo
     Galindo.

   - bpo-40222(121): "Zero cost" exception handling.

        * Uses a lookup table to determine how to handle exceptions.

        * Removes SETUP_FINALLY and POP_TOP block instructions,
          eliminating the runtime overhead of try statements.

        * Reduces the size of the frame object by about 60%.

     Patch by Mark Shannon

   - bpo-43918(122): Document the signature and ‘default’ argument in
     the docstring of the new ‘anext’ builtin.

   - bpo-43833(123): Emit a deprecation warning if the numeric literal
     is immediately followed by one of keywords: and, else, for, if, in,
     is, or.  Raise a syntax error with more informative message if it
     is immediately followed by other keyword or identifier.

   - bpo-43879(124): Add native_thread_id to PyThreadState.  Patch by
     Gabriele N. Tornetta.

   - bpo-43693(125): Compute cell offsets relative to locals in
     compiler.  Allows the interpreter to treats locals and cells a
     single array, which is slightly more efficient.  Also make the
     LOAD_CLOSURE opcode an alias for LOAD_FAST. Preserving LOAD_CLOSURE
     helps keep bytecode a bit more readable.

   - bpo-17792(126): More accurate error messages for access of unbound
     locals or free vars.

   - bpo-28146(127): Fix a confusing error message in *note
     str.format(): 5ed.

   - bpo-11105(128): When compiling *note ast.AST: 18b. objects with
     recursive references through *note compile(): 177, the interpreter
     doesn't crash anymore instead it raises a *note RecursionError:
     d39.

   - bpo-39091(129): Fix crash when using passing a non-exception to a
     generator's ‘throw()’ method.  Patch by Noah Oxer

   - bpo-33346(130): Asynchronous comprehensions are now allowed inside
     comprehensions in asynchronous functions.  Outer comprehensions
     implicitly become asynchronous.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43760

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45061

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24076

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45190

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45167

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45155

   (7) https://bugs.python.org/issue?@action=redirect&bpo=44219

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44219

   (9) https://bugs.python.org/issue?@action=redirect&bpo=44959

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45121

   (11) https://bugs.python.org/issue?@action=redirect&bpo=44348

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45123

   (13) https://bugs.python.org/issue?@action=redirect&bpo=1514420

   (14) https://bugs.python.org/issue?@action=redirect&bpo=41031

   (15) https://bugs.python.org/issue?@action=redirect&bpo=37330

   (16) https://bugs.python.org/issue?@action=redirect&bpo=45083

   (17) https://bugs.python.org/issue?@action=redirect&bpo=34561

   (18) https://bugs.python.org/issue?@action=redirect&bpo=45056

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45020

   (20) https://bugs.python.org/issue?@action=redirect&bpo=45012

   (21) https://bugs.python.org/issue?@action=redirect&bpo=45018

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45000

   (23) https://bugs.python.org/issue?@action=redirect&bpo=44963

   (24) https://bugs.python.org/issue?@action=redirect&bpo=44962

   (25) https://bugs.python.org/issue?@action=redirect&bpo=24234

   (26) https://bugs.python.org/issue?@action=redirect&bpo=24234

   (27) https://bugs.python.org/issue?@action=redirect&bpo=44954

   (28) https://bugs.python.org/issue?@action=redirect&bpo=44947

   (29) https://bugs.python.org/issue?@action=redirect&bpo=44945

   (30) https://bugs.python.org/issue?@action=redirect&bpo=44929

   (31) https://bugs.python.org/issue?@action=redirect&bpo=44914

   (32) https://bugs.python.org/issue?@action=redirect&bpo=44698

   (33) https://bugs.python.org/issue?@action=redirect&bpo=44895

   (34) https://bugs.python.org/issue?@action=redirect&bpo=44900

   (35) https://bugs.python.org/issue?@action=redirect&bpo=44889

   (36) https://bugs.python.org/issue?@action=redirect&bpo=44890

   (37) https://bugs.python.org/issue?@action=redirect&bpo=44885

   (38) https://bugs.python.org/issue?@action=redirect&bpo=44878

   (39) https://bugs.python.org/issue?@action=redirect&bpo=44878

   (40) https://bugs.python.org/issue?@action=redirect&bpo=44874

   (41) https://bugs.python.org/issue?@action=redirect&bpo=44872

   (42) https://bugs.python.org/issue?@action=redirect&bpo=33930

   (43) https://bugs.python.org/issue?@action=redirect&bpo=25782

   (44) https://bugs.python.org/issue?@action=redirect&bpo=44856

   (45) https://bugs.python.org/issue?@action=redirect&bpo=44826

   (46) https://bugs.python.org/issue?@action=redirect&bpo=44838

   (47) https://bugs.python.org/issue?@action=redirect&bpo=44821

   (48) https://bugs.python.org/issue?@action=redirect&bpo=44792

   (49) https://bugs.python.org/issue?@action=redirect&bpo=34013

   (50) https://bugs.python.org/issue?@action=redirect&bpo=44732

   (51) https://bugs.python.org/issue?@action=redirect&bpo=44725

   (52) https://bugs.python.org/issue?@action=redirect&bpo=44717

   (53) https://bugs.python.org/issue?@action=redirect&bpo=44698

   (54) https://bugs.python.org/issue?@action=redirect&bpo=44653

   (55) https://bugs.python.org/issue?@action=redirect&bpo=44676

   (56) https://bugs.python.org/issue?@action=redirect&bpo=44633

   (57) https://bugs.python.org/issue?@action=redirect&bpo=44661

   (58) https://bugs.python.org/issue?@action=redirect&bpo=44662

   (59) https://bugs.python.org/issue?@action=redirect&bpo=44655

   (60) https://bugs.python.org/issue?@action=redirect&bpo=44655

   (61) https://bugs.python.org/issue?@action=redirect&bpo=44646

   (62) https://bugs.python.org/issue?@action=redirect&bpo=44636

   (63) https://bugs.python.org/issue?@action=redirect&bpo=44611

   (64) https://bugs.python.org/issue?@action=redirect&bpo=44635

   (65) https://bugs.python.org/issue?@action=redirect&bpo=26280

   (66) https://bugs.python.org/issue?@action=redirect&bpo=44589

   (67) https://bugs.python.org/issue?@action=redirect&bpo=44606

   (68) https://bugs.python.org/issue?@action=redirect&bpo=42073

   (69) https://bugs.python.org/issue?@action=redirect&bpo=41972

   (70) https://bugs.python.org/issue?@action=redirect&bpo=44590

   (71) https://bugs.python.org/issue?@action=redirect&bpo=44584

   (72) https://bugs.python.org/issue?@action=redirect&bpo=43895

   (73) https://bugs.python.org/issue?@action=redirect&bpo=44490

   (74) https://bugs.python.org/issue?@action=redirect&bpo=43950

   (75) https://peps.python.org/pep-0657/

   (76) https://bugs.python.org/issue?@action=redirect&bpo=44562

   (77) https://bugs.python.org/issue?@action=redirect&bpo=41486

   (78) https://bugs.python.org/issue?@action=redirect&bpo=43908

   (79) https://peps.python.org/pep-0590/

   (80) https://bugs.python.org/issue?@action=redirect&bpo=44553

   (81) https://bugs.python.org/issue?@action=redirect&bpo=44490

   (82) https://bugs.python.org/issue?@action=redirect&bpo=44523

   (83) https://bugs.python.org/issue?@action=redirect&bpo=44483

   (84) https://bugs.python.org/issue?@action=redirect&bpo=44486

   (85) https://bugs.python.org/issue?@action=redirect&bpo=44472

   (86) https://bugs.python.org/issue?@action=redirect&bpo=12022

   (87) https://bugs.python.org/issue?@action=redirect&bpo=44297

   (88) https://bugs.python.org/issue?@action=redirect&bpo=44456

   (89) https://bugs.python.org/issue?@action=redirect&bpo=44409

   (90) https://bugs.python.org/issue?@action=redirect&bpo=44396

   (91) https://bugs.python.org/issue?@action=redirect&bpo=44376

   (92) https://bugs.python.org/issue?@action=redirect&bpo=44313

   (93) https://bugs.python.org/issue?@action=redirect&bpo=44338

   (94) https://bugs.python.org/issue?@action=redirect&bpo=44368

   (95) https://bugs.python.org/issue?@action=redirect&bpo=44349

   (96) https://bugs.python.org/issue?@action=redirect&bpo=44337

   (97) https://bugs.python.org/issue?@action=redirect&bpo=44335

   (98) https://bugs.python.org/issue?@action=redirect&bpo=43693

   (99) https://bugs.python.org/issue?@action=redirect&bpo=44317

   (100) https://bugs.python.org/issue?@action=redirect&bpo=44304

   (101) https://bugs.python.org/issue?@action=redirect&bpo=44305

   (102) https://bugs.python.org/issue?@action=redirect&bpo=43413

   (103) https://bugs.python.org/issue?@action=redirect&bpo=43667

   (104) https://bugs.python.org/issue?@action=redirect&bpo=43693

   (105) https://bugs.python.org/issue?@action=redirect&bpo=44232

   (106) https://bugs.python.org/issue?@action=redirect&bpo=44201

   (107) https://bugs.python.org/issue?@action=redirect&bpo=43693

   (108) https://bugs.python.org/issue?@action=redirect&bpo=44184

   (109) https://bugs.python.org/issue?@action=redirect&bpo=44187

   (110) https://bugs.python.org/issue?@action=redirect&bpo=44180

   (111) https://bugs.python.org/issue?@action=redirect&bpo=44168

   (112) https://bugs.python.org/issue?@action=redirect&bpo=44156

   (113) https://bugs.python.org/issue?@action=redirect&bpo=44143

   (114) https://bugs.python.org/issue?@action=redirect&bpo=44032

   (115) https://bugs.python.org/issue?@action=redirect&bpo=44114

   (116) https://bugs.python.org/issue?@action=redirect&bpo=44110

   (117) https://bugs.python.org/issue?@action=redirect&bpo=26110

   (118) https://bugs.python.org/issue?@action=redirect&bpo=28307

   (119) https://bugs.python.org/issue?@action=redirect&bpo=43149

   (120) https://bugs.python.org/issue?@action=redirect&bpo=43822

   (121) https://bugs.python.org/issue?@action=redirect&bpo=40222

   (122) https://bugs.python.org/issue?@action=redirect&bpo=43918

   (123) https://bugs.python.org/issue?@action=redirect&bpo=43833

   (124) https://bugs.python.org/issue?@action=redirect&bpo=43879

   (125) https://bugs.python.org/issue?@action=redirect&bpo=43693

   (126) https://bugs.python.org/issue?@action=redirect&bpo=17792

   (127) https://bugs.python.org/issue?@action=redirect&bpo=28146

   (128) https://bugs.python.org/issue?@action=redirect&bpo=11105

   (129) https://bugs.python.org/issue?@action=redirect&bpo=39091

   (130) https://bugs.python.org/issue?@action=redirect&bpo=33346


File: python.info,  Node: Library<30>,  Next: Documentation<25>,  Prev: Core and Builtins<31>,  Up: Python 3 11 0 alpha 1

1.23.31.3 Library
.................

   - bpo-45371(1): Fix clang rpath issue in ‘distutils’.  The
     UnixCCompiler now uses correct clang option to add a runtime
     library directory (rpath) to a shared library.

   - bpo-45329(2): Fix freed memory access in ‘pyexpat.xmlparser’ when
     building it with an installed expat library <= 2.2.0.

   - bpo-41710(3): On Unix, if the ‘sem_clockwait()’ function is
     available in the C library (glibc 2.30 and newer), the *note
     threading.Lock.acquire(): 664. method now uses the monotonic clock
     (*note time.CLOCK_MONOTONIC: 665.) for the timeout, rather than
     using the system clock (*note time.CLOCK_REALTIME: 666.), to not be
     affected by system clock changes.  Patch by Victor Stinner.

   - bpo-1596321(4): Fix the ‘threading._shutdown()’ function when the
     *note threading: d6. module was imported first from a thread
     different than the main thread: no longer log an error at Python
     exit.

   - bpo-45274(5): Fix a race condition in the *note Thread.join():
     11b5. method of the *note threading: d6. module.  If the function
     is interrupted by a signal and the signal handler raises an
     exception, make sure that the thread remains in a consistent state
     to prevent a deadlock.  Patch by Victor Stinner.

   - bpo-21302(6): In Unix operating systems, *note time.sleep(): 669.
     now uses the ‘nanosleep()’ function, if ‘clock_nanosleep()’ is not
     available but ‘nanosleep()’ is available.  ‘nanosleep()’ allows to
     sleep with nanosecond precision.

   - bpo-21302(7): On Windows, *note time.sleep(): 669. now uses a
     waitable timer which has a resolution of 100 nanoseconds (10^-7
     seconds).  Previously, it had a resolution of 1 millisecond (10^-3
     seconds).  Patch by Benjamin Szőke and Victor Stinner.

   - bpo-45238(8): Fix ‘unittest.IsolatedAsyncioTestCase.debug()’: it
     runs now asynchronous methods and callbacks.

   - bpo-36674(9): *note unittest.TestCase.debug(): 17ff. raises now a
     *note unittest.SkipTest: fb1. if the class or the test method are
     decorated with the skipping decorator.

   - bpo-45235(10): Fix an issue where argparse would not preserve
     values in a provided namespace when using a subparser with
     defaults.

   - bpo-45183(11): Have zipimport.zipimporter.find_spec() not raise an
     exception when the underlying zip file has been deleted and the
     internal cache has been reset via invalidate_cache().

   - bpo-45234(12): Fixed a regression in *note copyfile(): a27, *note
     copy(): a28, *note copy2(): a29. raising *note FileNotFoundError:
     e8f. when source is a directory, which should raise *note
     IsADirectoryError: 102d.

   - bpo-45228(13): Fix stack buffer overflow in parsing J1939 network
     address.

   - bpo-45225(14): use map function instead of genexpr in capwords.

   - bpo-42135(15): Fix typo: ‘importlib.find_loader’ is really slated
     for removal in Python 3.12 not 3.10, like the others in PR 25169.

     Patch by Hugo van Kemenade.

   - bpo-20524(16): Improves error messages on ‘.format()’ operation for
     ‘str’, ‘float’, ‘int’, and ‘complex’.  New format now shows the
     problematic pattern and the object type.

   - bpo-45168(17): Change *note dis.dis(): b02. output to omit op arg
     values that cannot be resolved due to ‘co_consts’, ‘co_names’ etc
     not being provided.  Previously the oparg itself was repeated in
     the value field, which is not useful and can be confusing.

   - bpo-21302(18): In Unix operating systems, *note time.sleep(): 669.
     now uses the ‘clock_nanosleep()’ function, if available, which
     allows to sleep for an interval specified with nanosecond
     precision.

   - bpo-45173(19): Remove from the *note configparser: 1b. module: the
     ‘SafeConfigParser’ class, the ‘filename’ property of the *note
     ParsingError: 4d0. class, the ‘readfp()’ method of the *note
     ConfigParser: 1aa. class, deprecated since Python 3.2.

     Patch by Hugo van Kemenade.

   - bpo-44987(20): Pure ASCII strings are now normalized in constant
     time by *note unicodedata.normalize(): 6a0.  Patch by Donghee Na.

   - bpo-35474(21): Calling *note mimetypes.guess_all_extensions():
     1800. with ‘strict=False’ no longer affects the result of the
     following call with ‘strict=True’.  Also, mutating the returned
     list no longer affects the global state.

   - bpo-45166(22): *note typing.get_type_hints(): 67d. now works with
     *note Final: 248. wrapped in *note ForwardRef: 17ae.

   - bpo-45162(23): Remove many old deprecated *note unittest: ef.
     features:

        * "‘fail*’" and "‘assert*’" aliases of *note TestCase: 41a.
          methods.

        * Broken from start *note TestCase: 41a. method
          ‘assertDictContainsSubset()’.

        * Ignored ‘<unittest.TestLoader.loadTestsFromModule>
          TestLoader.loadTestsFromModule()’ parameter 'use_load_tests'.

        * Old alias ‘_TextTestResult’ of *note TextTestResult: 4fa.

   - bpo-38371(24): Remove the deprecated ‘split()’ method of
     ‘_tkinter.TkappType’.  Patch by Erlend E. Aasland.

   - bpo-20499(25): Improve the speed and accuracy of
     statistics.pvariance().

   - bpo-45132(26): Remove *note __getitem__(): 264. methods of *note
     xml.dom.pulldom.DOMEventStream: 700, *note
     wsgiref.util.FileWrapper: 701. and *note fileinput.FileInput: 702,
     deprecated since Python 3.9.

     Patch by Hugo van Kemenade.

   - bpo-45129(27): Due to significant security concerns, the
     'reuse_address' parameter of *note
     asyncio.loop.create_datagram_endpoint(): 6fe, disabled in Python
     3.9, is now entirely removed.  This is because of the behavior of
     the socket option ‘SO_REUSEADDR’ in UDP.

     Patch by Hugo van Kemenade.

   - bpo-45124(28): The ‘bdist_msi’ command, deprecated in Python 3.9,
     is now removed.

     Use ‘bdist_wheel’ (wheel packages) instead.

     Patch by Hugo van Kemenade.

   - bpo-30856(29): *note unittest.TestResult: 113a. methods *note
     addFailure(): 1801, *note addError(): 1802, *note addSkip(): 1803.
     and *note addSubTest(): 1804. are now called immediately after
     raising an exception in test or finishing a subtest.  Previously
     they were called only after finishing the test clean up.

   - bpo-45034(30): Changes how error is formatted for ‘struct.pack’
     with ‘'H'’ and ‘'h'’ modes and too large / small numbers.  Now it
     shows the actual numeric limits, while previously it was showing
     arithmetic expressions.

   - bpo-25894(31): *note unittest: ef. now always reports skipped and
     failed subtests separately: separate characters in default mode and
     separate lines in verbose mode.  Also the test description is now
     output for errors in test method, class and module cleanups.

   - bpo-45081(32): Fix issue when dataclasses that inherit from
     ‘typing.Protocol’ subclasses have wrong ‘__init__’.  Patch provided
     by Yurii Karabas.

   - bpo-45085(33): The ‘binhex’ module, deprecated in Python 3.9, is
     now removed.  The following *note binascii: c. functions,
     deprecated in Python 3.9, are now also removed:

        * ‘a2b_hqx()’, ‘b2a_hqx()’;

        * ‘rlecode_hqx()’, ‘rledecode_hqx()’.

     The *note binascii.crc_hqx(): 6ff. function remains available.

     Patch by Victor Stinner.

   - bpo-40360(34): The ‘lib2to3’ package is now deprecated and may not
     be able to parse Python 3.10 or newer.  See the PEP 617(35) (New
     PEG parser for CPython).  Patch by Victor Stinner.

   - bpo-45075(36): Rename ‘traceback.StackSummary.format_frame()’ to
     *note traceback.StackSummary.format_frame_summary(): 66f.  This
     method was added for 3.11 so it was not released yet.

     Updated code and docs to better distinguish frame and FrameSummary.

   - bpo-31299(37): Add option to completely drop frames from a
     traceback by returning ‘None’ from a ‘format_frame()’ override.

   - bpo-41620(38): *note run(): 1139. now always return a *note
     TestResult: 113a. instance.  Previously it returned ‘None’ if the
     test class or method was decorated with a skipping decorator.

   - bpo-45021(39): Fix a potential deadlock at shutdown of forked
     children when using *note concurrent.futures: 1a. module

   - bpo-43913(40): Fix bugs in cleaning up classes and modules in *note
     unittest: ef.:

        * Functions registered with *note addModuleCleanup(): a1b. were
          not called unless the user defines ‘tearDownModule()’ in their
          test module.

        * Functions registered with *note addClassCleanup(): a1c. were
          not called if ‘tearDownClass’ is set to ‘None’.

        * Buffering in *note TestResult: 113a. did not work with
          functions registered with ‘addClassCleanup()’ and
          ‘addModuleCleanup()’.

        * Errors in functions registered with ‘addClassCleanup()’ and
          ‘addModuleCleanup()’ were not handled correctly in buffered
          and debug modes.

        * Errors in ‘setUpModule()’ and functions registered with
          ‘addModuleCleanup()’ were reported in wrong order.

        * And several lesser bugs.

   - bpo-45030(41): Fix integer overflow in pickling and copying the
     range iterator.

   - bpo-45001(42): Made email date parsing more robust against
     malformed input, namely a whitespace-only ‘Date:’ header.  Patch by
     Wouter Bolsterlee.

   - bpo-45010(43): Remove support of special method ‘__div__’ in *note
     unittest.mock: f0.  It is not used in Python 3.

   - bpo-39218(44): Improve accuracy of variance calculations by using
     ‘x*x’ instead of ‘x**2’.

   - bpo-43613(45): Improve the speed of *note gzip.compress(): 60a. and
     *note gzip.decompress(): 11de. by compressing and decompressing at
     once in memory instead of in a streamed fashion.

   - bpo-37596(46): Ensure that *note set: 5a3. and *note frozenset:
     5a4. objects are always *note marshalled: 80. reproducibly.

   - bpo-44019(47): A new function ‘operator.call’ has been added, such
     that ‘operator.call(obj, *args, **kwargs) == obj(*args, **kwargs)’.

   - bpo-42255(48): ‘webbrowser.MacOSX’ is deprecated and will be
     removed in Python 3.13.  It is untested and undocumented and also
     not used by *note webbrowser: fd. itself.  Patch by Donghee Na.

   - bpo-44955(49): Method *note stopTestRun(): 131a. is now always
     called in pair with method *note startTestRun(): 1319. for *note
     TestResult: 113a. objects implicitly created in *note run(): 1139.
     Previously it was not called for test methods and classes decorated
     with a skipping decorator.

   - bpo-39039(50): tarfile.open raises *note ReadError: 1805. when a
     zlib error occurs during file extraction.

   - bpo-44935(51): *note subprocess: c1. on Solaris now also uses *note
     os.posix_spawn(): 201. for better performance.

   - bpo-44911(52): *note IsolatedAsyncioTestCase: 2e4. will no longer
     throw an exception while cancelling leaked tasks.  Patch by Bar
     Harel.

   - bpo-41322(53): Added ‘DeprecationWarning’ for tests and async tests
     that return a value!=None (as this may indicate an improperly
     written test, for example a test written as a generator function).

   - bpo-44524(54): Make exception message more useful when subclass
     from typing special form alias.  Patch provided by Yurii Karabas.

   - bpo-38956(55): *note argparse.BooleanOptionalAction: 17c0.'s
     default value is no longer printed twice when used with *note
     argparse.ArgumentDefaultsHelpFormatter: 1806.

   - bpo-44860(56): Fix the ‘posix_user’ scheme in *note sysconfig: c5.
     to not depend on *note sys.platlibdir: 906.

   - bpo-44859(57): Improve error handling in *note sqlite3: ba. and
     raise more accurate exceptions.

        * *note MemoryError: 1627. is now raised instead of *note
          sqlite3.Warning: 1790. when memory is not enough for encoding
          a statement to UTF-8 in ‘Connection.__call__()’ and
          ‘Cursor.execute()’.

        * ‘UnicodEncodeError’ is now raised instead of *note
          sqlite3.Warning: 1790. when the statement contains surrogate
          characters in ‘Connection.__call__()’ and ‘Cursor.execute()’.

        * *note TypeError: 502. is now raised instead of *note
          ValueError: 1e3. for non-string script argument in
          ‘Cursor.executescript()’.

        * *note ValueError: 1e3. is now raised for script containing the
          null character instead of truncating it in
          ‘Cursor.executescript()’.

        * Correctly handle exceptions raised when getting boolean value
          of the result of the progress handler.

        * Add many tests covering different corner cases.

   - bpo-44581(58): Upgrade bundled pip to 21.2.3 and setuptools to
     57.4.0

   - bpo-44849(59): Fix the *note os.set_inheritable(): ec6. function on
     FreeBSD 14 for file descriptor opened with the *note O_PATH: f3f.
     flag: ignore the *note EBADF: 929. error on ‘ioctl()’, fallback on
     the ‘fcntl()’ implementation.  Patch by Victor Stinner.

   - bpo-44605(60): The @functools.total_ordering() decorator now works
     with metaclasses.

   - bpo-44524(61): Fixed an issue wherein the ‘__name__’ and
     ‘__qualname__’ attributes of subscribed specialforms could be
     ‘None’.

   - bpo-44839(62): *note MemoryError: 1627. raised in user-defined
     functions will now produce a ‘MemoryError’ in *note sqlite3: ba.
     *note OverflowError: 84e. will now be converted to *note DataError:
     1807.  Previously *note OperationalError: 1808. was produced in
     these cases.

   - bpo-44822(63): *note sqlite3: ba. user-defined functions and
     aggregators returning *note strings: 418. with embedded NUL
     characters are no longer truncated.  Patch by Erlend E. Aasland.

   - bpo-44801(64): Ensure that the *note ParamSpec: 144. variable in
     Callable can only be substituted with a parameters expression (a
     list of types, an ellipsis, ParamSpec or Concatenate).

   - bpo-44806(65): Non-protocol subclasses of *note typing.Protocol:
     245. ignore now the ‘__init__’ method inherited from protocol base
     classes.

   - bpo-27275(66): *note collections.OrderedDict.popitem(): 12bb. and
     ‘collections.OrderedDict.pop()’ no longer call ‘__getitem__’ and
     ‘__delitem__’ methods of the OrderedDict subclasses.

   - bpo-44793(67): Fix checking the number of arguments when subscribe
     a generic type with ‘ParamSpec’ parameter.

   - bpo-44784(68): In importlib.metadata tests, override warnings
     behavior under expected DeprecationWarnings (importlib_metadata
     4.6.3).

   - bpo-44667(69): The *note tokenize.tokenize(): 4a6. doesn't
     incorrectly generate a ‘NEWLINE’ token if the source doesn't end
     with a new line character but the last line is a comment, as the
     function is already generating a ‘NL’ token.  Patch by Pablo
     Galindo

   - bpo-44771(70): Added ‘importlib.simple’ module implementing
     adapters from a low-level resources reader interface to a
     ‘TraversableResources’ interface.  Legacy API (‘path’, ‘contents’,
     ...)  is now supported entirely by the ‘.files()’ API with a
     compatibility shim supplied for resource loaders without that
     functionality.  Feature parity with ‘importlib_resources’ 5.2.

   - bpo-44752(71): ‘rcompleter’ does not call *note getattr(): b9f. on
     *note property: 179. objects to avoid the side-effect of evaluating
     the corresponding method.

   - bpo-44747(72): Refactor usage of ‘sys._getframe’ in ‘typing’
     module.  Patch provided by Yurii Karabas.

   - bpo-42378(73): Fixes the issue with log file being overwritten when
     *note logging.FileHandler: 1809. is used in *note atexit: 9. with
     'filemode' set to ‘'w'’.  Note this will cause the message in
     'atexit' not being logged if the log stream is already closed due
     to shutdown of logging.

   - bpo-44720(74): ‘weakref.proxy’ objects referencing non-iterators
     now raise ‘TypeError’ rather than dereferencing the null
     ‘tp_iternext’ slot and crashing.

   - bpo-44704(75): The implementation of ‘collections.abc.Set._hash()’
     now matches that of ‘frozenset.__hash__()’.

   - bpo-44666(76): Fixed issue in *note compileall.compile_file(): dae.
     when ‘sys.stdout’ is redirected.  Patch by Stefan Hölzl.

   - bpo-44688(77): *note sqlite3.Connection.create_collation(): 642.
     now accepts non-ASCII collation names.  Patch by Erlend E. Aasland.

   - bpo-44690(78): Adopt 'binacii.a2b_base64"s strict mode in
     'base64.b64decode'.

   - bpo-42854(79): Fixed a bug in the ‘_ssl’ module that was throwing
     *note OverflowError: 84e. when using ‘_ssl._SSLSocket.write()’ and
     ‘_ssl._SSLSocket.read()’ for a big value of the ‘len’ parameter.
     Patch by Pablo Galindo.

   - bpo-44686(80): Replace ‘unittest.mock._importer’ with
     ‘pkgutil.resolve_name’.

   - bpo-44353(81): Make ‘NewType.__call__’ faster by implementing it in
     C. Patch provided by Yurii Karabas.

   - bpo-44682(82): Change the *note pdb: 94. 'commands' directive to
     disallow setting commands for an invalid breakpoint and to display
     an appropriate error.

   - bpo-44353(83): Refactor ‘typing.NewType’ from function into
     callable class.  Patch provided by Yurii Karabas.

   - bpo-44678(84): Added a separate error message for discontinuous
     padding in 'binascii.a2b_base64' strict mode.

   - bpo-44524(85): Add missing ‘__name__’ and ‘__qualname__’ attributes
     to ‘typing’ module classes.  Patch provided by Yurii Karabas.

   - bpo-40897(86): Give priority to using the current class constructor
     in *note inspect.signature(): 703.  Patch by Weipeng Hong.

   - bpo-44638(87): Add a reference to the zipp project and hint as to
     how to use it.

   - bpo-44648(88): Fixed wrong error being thrown by *note
     inspect.getsource(): 1528. when examining a class in the
     interactive session.  Instead of *note TypeError: 502, it should be
     *note OSError: 3f0. with appropriate error message.

   - bpo-44608(89): Fix memory leak in ‘_tkinter._flatten()’ if it is
     called with a sequence or set, but not list or tuple.

   - bpo-44594(90): Fix an edge case of ‘ExitStack’ and ‘AsyncExitStack’
     exception chaining.  They will now match ‘with’ block behavior when
     ‘__context__’ is explicitly set to ‘None’ when the exception is in
     flight.

   - bpo-42799(91): In *note fnmatch: 52, the cache size for compiled
     regex patterns (*note functools.lru_cache(): 9bd.) was bumped up
     from 256 to 32768, affecting functions: *note fnmatch.fnmatch():
     180a, *note fnmatch.fnmatchcase(): 180b, *note fnmatch.filter():
     180c.

   - bpo-41928(92): Update *note shutil.copyfile(): a27. to raise *note
     FileNotFoundError: e8f. instead of confusing *note
     IsADirectoryError: 102d. when a path ending with a ‘os.path.sep’
     does not exist; *note shutil.copy(): a28. and *note shutil.copy2():
     a29. are also affected.

   - bpo-44569(93): Added the ‘StackSummary.format_frame()’ function in
     *note traceback: e7.  This allows users to customize the way
     individual lines are formatted in tracebacks without
     re-implementing logic to handle recursive tracebacks.

   - bpo-44566(94): handle StopIteration subclass raised from
     @contextlib.contextmanager generator

   - bpo-44558(95): Make the implementation consistency of *note
     indexOf(): 8a9. between C and Python versions.  Patch by Donghee
     Na.

   - bpo-41249(96): Fixes ‘TypedDict’ to work with
     ‘typing.get_type_hints()’ and postponed evaluation of annotations
     across modules.

   - bpo-44554(97): Refactor argument processing in ‘pdb.main()’ to
     simplify detection of errors in input loading and clarify behavior
     around module or script invocation.

   - bpo-34798(98): Break up paragraph about *note pprint.PrettyPrinter:
     f4c. construction parameters to make it easier to read.

   - bpo-44539(99): Added support for recognizing JPEG files without
     JFIF or Exif markers.

   - bpo-44461(100): Fix bug with *note pdb: 94.'s handling of import
     error due to a package which does not have a ‘__main__’ module

   - bpo-43625(101): Fix a bug in the detection of CSV file headers by
     *note csv.Sniffer.has_header(): 180d. and improve documentation of
     same.

   - bpo-44516(102): Update vendored pip to 21.1.3

   - bpo-42892(103): Fixed an exception thrown while parsing a malformed
     multipart email by *note email.message.EmailMessage: 25c.

   - bpo-44468(104): *note typing.get_type_hints(): 67d. now finds
     annotations in classes and base classes with unexpected
     ‘__module__’.  Previously, it skipped those MRO elements.

   - bpo-44491(105): Allow clearing the *note sqlite3: ba. authorizer
     callback by passing *note None: 641. to *note set_authorizer():
     28b.  Patch by Erlend E. Aasland.

   - bpo-43977(106): Set the proper *note Py_TPFLAGS_MAPPING: 180e. and
     *note Py_TPFLAGS_SEQUENCE: 180f. flags for subclasses created
     before a parent has been registered as a *note
     collections.abc.Mapping: 898. or *note collections.abc.Sequence:
     1194.

   - bpo-44482(107): Fix very unlikely resource leak in *note glob: 5a.
     in alternate Python implementations.

   - bpo-44466(108): The *note faulthandler: 4e. module now detects if a
     fatal error occurs during a garbage collector collection.  Patch by
     Victor Stinner.

   - bpo-44471(109): A *note TypeError: 502. is now raised instead of an
     *note AttributeError: 326. in *note
     contextlib.ExitStack.enter_context(): 59d. and *note
     contextlib.AsyncExitStack.enter_async_context(): 5a0. for objects
     which do not support the *note context manager: 59e. or *note
     asynchronous context manager: 5a1. protocols correspondingly.

   - bpo-44404(110): *note tkinter: d9.'s ‘after()’ method now supports
     callables without the ‘__name__’ attribute.

   - bpo-41546(111): Make *note pprint: 9c. (like the builtin ‘print’)
     not attempt to write to ‘stdout’ when it is ‘None’.

   - bpo-44458(112): ‘BUFFER_BLOCK_SIZE’ is now declared static, to
     avoid linking collisions when bz2, lmza or zlib are statically
     linked.

   - bpo-44464(113): Remove exception for flake8 in deprecated
     importlib.metadata interfaces.  Sync with importlib_metadata 4.6.

   - bpo-44446(114): Take into account that ‘lineno’ might be ‘None’ in
     *note traceback.FrameSummary: e4f.

   - bpo-44439(115): Fix in ‘bz2.BZ2File.write()’ /
     ‘lzma.LZMAFile.write()’ methods, when the input data is an object
     that supports the buffer protocol, the file length may be wrong.

   - bpo-44434(116): _thread.start_new_thread() no longer calls
     PyThread_exit_thread() explicitly at the thread exit, the call was
     redundant.  On Linux with the glibc, pthread_exit() aborts the
     whole process if dlopen() fails to open libgcc_s.so file (ex:
     EMFILE error).  Patch by Victor Stinner.

   - bpo-42972(117): The _thread.RLock type now fully implement the GC
     protocol: add a traverse function and the *note Py_TPFLAGS_HAVE_GC:
     748. flag.  Patch by Victor Stinner.

   - bpo-44422(118): The *note threading.enumerate(): 1810. function now
     uses a reentrant lock to prevent a hang on reentrant call.  Patch
     by Victor Stinner.

   - bpo-38291(119): Importing typing.io or typing.re now prints a
     ‘DeprecationWarning’.

   - bpo-37880(120): argparse actions store_const and append_const each
     receive a default value of ‘None’ when the ‘const’ kwarg is not
     provided.  Previously, this raised a *note TypeError: 502.

   - bpo-44389(121): Fix deprecation of *note ssl.OP_NO_TLSv1_3: 1811.

   - bpo-27827(122): ‘pathlib.PureWindowsPath.is_reserved()’ now
     identifies a greater range of reserved filenames, including those
     with trailing spaces or colons.

   - bpo-44395(123): Fix ‘as_string()’ to pass unixfrom properly.  Patch
     by Donghee Na.

   - bpo-34266(124): Handle exceptions from parsing the arg of *note
     pdb: 94.'s run/restart command.

   - bpo-44362(125): Improve *note ssl: bb. module's deprecation
     messages, error reporting, and documentation for deprecations.

   - bpo-44342(126): [Enum] Change pickling from by-value to by-name.

   - bpo-44356(127): [Enum] Allow multiple data-type mixins if they are
     all the same.

   - bpo-44351(128): Restore back ‘parse_makefile()’ in
     ‘distutils.sysconfig’ because it behaves differently than the
     similar implementation in *note sysconfig: c5.

   - bpo-35800(129): ‘smtpd.MailmanProxy’ is now removed as it is
     unusable without an external module, ‘mailman’.  Patch by Donghee
     Na.

   - bpo-44357(130): Added a function that returns cube root of the
     given number *note math.cbrt(): 62d.

   - bpo-44339(131): Change ‘math.pow(±0.0, -math.inf)’ to return ‘inf’
     instead of raising ‘ValueError’.  This brings the special-case
     handling of ‘math.pow’ into compliance with the IEEE 754 standard.

   - bpo-44242(132): Remove missing flag check from Enum creation and
     move into a ‘verify’ decorator.

   - bpo-44246(133): In ‘importlib.metadata’, restore compatibility in
     the result from ‘Distribution.entry_points’ (‘EntryPoints’) to
     honor expectations in older implementations and issuing deprecation
     warnings for these cases: A. ‘EntryPoints’ objects are once again
     mutable, allowing for ‘sort()’ and other list-based mutation
     operations.  Avoid deprecation warnings by casting to a mutable
     sequence (e.g.  ‘list(dist.entry_points).sort()’).  B.
     ‘EntryPoints’ results once again allow for access by index.  To
     avoid deprecation warnings, cast the result to a Sequence first
     (e.g.  ‘tuple(dist.entry_points)[0]’).

   - bpo-44246(134): In importlib.metadata.entry_points, de-duplication
     of distributions no longer requires loading the full metadata for
     PathDistribution objects, improving entry point loading performance
     by ~10x.

   - bpo-43858(135): Added a function that returns a copy of a dict of
     logging levels: *note logging.getLevelNamesMapping(): 625.

   - bpo-44260(136): The *note random.Random: 1812. constructor no
     longer reads system entropy without need.

   - bpo-44254(137): On Mac, give turtledemo button text a color that
     works on both light or dark background.  Programmers cannot control
     the latter.

   - bpo-44258(138): Support PEP 515 for Fraction's initialization from
     string.

   - bpo-44235(139): Remove deprecated functions in the *note gettext:
     59.  Patch by Donghee Na.

   - bpo-38693(140): Prefer f-strings to ‘.format’ in
     importlib.resources.

   - bpo-33693(141): Importlib.metadata now prefers f-strings to
     .format.

   - bpo-44241(142): Incorporate minor tweaks from importlib_metadata
     4.1: SimplePath protocol, support for Metadata 2.2.

   - bpo-43216(143): Remove the ‘@asyncio.coroutine’ *note decorator:
     6fc. enabling legacy generator-based coroutines to be compatible
     with async/await code; remove ‘asyncio.coroutines.CoroWrapper’ used
     for wrapping legacy coroutine objects in the debug mode.  The
     decorator has been deprecated since Python 3.8 and the removal was
     initially scheduled for Python 3.10.  Patch by Illia Volochii.

   - bpo-44210(144): Make importlib.metadata._meta.PackageMetadata
     public.

   - bpo-43643(145): Declare readers.MultiplexedPath.name as a property
     per the spec.

   - bpo-27334(146): The *note sqlite3: ba. context manager now performs
     a rollback (thus releasing the database lock) if commit failed.
     Patch by Luca Citi and Erlend E. Aasland.

   - bpo-4928(147): Documented existing behavior on POSIX:
     NamedTemporaryFiles are not deleted when creating process is killed
     with SIGKILL

   - bpo-44154(148): Optimize *note fractions.Fraction: 1c8. pickling
     for large components.

   - bpo-33433(149): For IPv4 mapped IPv6 addresses ( RFC 4291(150)
     Section 2.5.5.2), the *note ipaddress.IPv6Address.is_private: 15ae.
     check is deferred to the mapped IPv4 address.  This solves a bug
     where public mapped IPv4 addresses were considered private by the
     IPv6 check.

   - bpo-44150(151): Add optional 'weights' argument to
     statistics.fmean().

   - bpo-44142(152): *note ast.unparse(): 8b3. will now drop the
     redundant parentheses when tuples used as assignment targets (e.g
     in for loops).

   - bpo-44145(153): *note hmac: 60. computations were not releasing the
     GIL while calling the OpenSSL ‘HMAC_Update’ C API (a new feature in
     3.9).  This unintentionally prevented parallel computation as other
     *note hashlib: 5e. algorithms support.

   - bpo-44095(154): *note zipfile.Path: 695. now supports *note
     zipfile.Path.stem: 692, *note zipfile.Path.suffixes: 694, and *note
     zipfile.Path.suffix: 693. attributes.

   - bpo-44077(155): It's now possible to receive the type of service
     (ToS), a.k.a.  differentiated services (DS), a.k.a.  differentiated
     services code point (DSCP) and explicit congestion notification
     (ECN) IP header fields with ‘socket.IP_RECVTOS’.

   - bpo-37788(156): Fix a reference leak when a Thread object is never
     joined.

   - bpo-38908(157): Subclasses of ‘typing.Protocol’ which only have
     data variables declared will now raise a ‘TypeError’ when checked
     with ‘isinstance’ unless they are decorated with
     ‘runtime_checkable()’.  Previously, these checks passed silently.
     Patch provided by Yurii Karabas.

   - bpo-44098(158): ‘typing.ParamSpec’ will no longer be found in the
     ‘__parameters__’ of most *note typing: ed. generics except in valid
     use locations specified by PEP 612(159).  This prevents incorrect
     usage like ‘typing.List[P][int]’.  This change means incorrect
     usage which may have passed silently in 3.10 beta 1 and earlier
     will now error.

   - bpo-44089(160): Allow subclassing ‘csv.Error’ in 3.10 (it was
     allowed in 3.9 and earlier but was disallowed in early versions of
     3.10).

   - bpo-44081(161): *note ast.unparse(): 8b3. now doesn't use redundant
     spaces to separate ‘lambda’ and the ‘:’ if there are no parameters.

   - bpo-44061(162): Fix regression in previous release when calling
     *note pkgutil.iter_modules(): d18. with a list of *note
     pathlib.Path: 20a. objects

   - bpo-44059(163): Register the SerenityOS Browser in the *note
     webbrowser: fd. module.

   - bpo-36515(164): The *note hashlib: 5e. module no longer does
     unaligned memory accesses when compiled for ARM platforms.

   - bpo-40465(165): Remove random module features deprecated in Python
     3.9.

   - bpo-44018(166): random.seed() no longer mutates bytearray inputs.

   - bpo-38352(167): Add ‘IO’, ‘BinaryIO’, ‘TextIO’, ‘Match’, and
     ‘Pattern’ to ‘typing.__all__’.  Patch by Jelle Zijlstra.

   - bpo-44002(168): *note urllib.parse: f3. now uses
     ‘functool.lru_cache()’ for its internal URL splitting and quoting
     caches instead of rolling its own like its the '90s.

     The undocumented internal *note urllib.parse: f3. ‘Quoted’ class
     API is now deprecated, for removal in 3.14.

   - bpo-43972(169): When *note http.server.SimpleHTTPRequestHandler:
     b11. sends a ‘301 (Moved Permanently)’ for a directory path not
     ending with ‘/’, add a ‘Content-Length: 0’ header.  This improves
     the behavior for certain clients.

   - bpo-28528(170): Fix a bug in *note pdb: 94. where ‘checkline()’
     raises *note AttributeError: 326. if it is called after ‘reset()’.

   - bpo-43853(171): Improved string handling for *note sqlite3: ba.
     user-defined functions and aggregates:

        * It is now possible to pass strings with embedded null
          characters to UDFs

        * Conversion failures now correctly raise *note MemoryError:
          1627.

     Patch by Erlend E. Aasland.

   - bpo-43666(172): AIX: ‘Lib/_aix_support.get_platform()’ may fail in
     an AIX WPAR. The fileset bos.rte appears to have a builddate in
     both LPAR and WPAR so this fileset is queried rather than bos.mp64.
     To prevent a similar situation (no builddate in ODM) a value (9988)
     sufficient for completing a build is provided.  Patch by M Felt.

   - bpo-43650(173): Fix *note MemoryError: 1627. in *note
     shutil.unpack_archive(): 438. which fails inside
     ‘shutil._unpack_zipfile()’ on large files.  Patch by Igor
     Bolshakov.

   - bpo-43612(174): *note zlib.compress(): 60b. now accepts a wbits
     parameter which allows users to compress data as a raw deflate
     block without zlib headers and trailers in one go.  Previously this
     required instantiating a ‘zlib.compressobj’.  It also provides a
     faster alternative to ‘gzip.compress’ when wbits=31 is used.

   - bpo-43392(175): ‘importlib._bootstrap._find_and_load()’ now
     implements a two-step check to avoid locking when modules have been
     already imported and are ready.  This improves performance of
     repeated calls to *note importlib.import_module(): 4e1. and *note
     importlib.__import__(): 1042.

   - bpo-43318(176): Fix a bug where *note pdb: 94. does not always echo
     cleared breakpoints.

   - bpo-43234(177): Prohibit passing non-*note
     concurrent.futures.ThreadPoolExecutor: 70d. executors to
     ‘loop.set_default_executor()’ following a deprecation in Python
     3.8.  Patch by Illia Volochii.

   - bpo-43232(178): Prohibit previously deprecated potentially
     disruptive operations on ‘asyncio.trsock.TransportSocket’.  Patch
     by Illia Volochii.

   - bpo-30077(179): Added support for Apple's aifc/sowt
     pseudo-compression

   - bpo-42971(180): Add definition of ‘errno.EQFULL’ for platforms that
     define this constant (such as macOS).

   - bpo-43086(181): Added a new optional ‘strict_mode’ parameter to
     'binascii.a2b_base64'.  When ‘scrict_mode’ is set to ‘True’, the
     'a2b_base64' function will accept only valid base64 content.  More
     details about what "valid base64 content" is, can be found in the
     function's documentation.

   - bpo-43024(182): Improve the help signature of *note
     traceback.print_exception(): 81a, *note
     traceback.format_exception(): 818. and *note
     traceback.format_exception_only(): 819.

   - bpo-33809(183): Add the *note traceback.TracebackException.print():
     670. method which prints the formatted exception information.

   - bpo-42862(184): *note sqlite3: ba. now utilizes *note
     functools.lru_cache(): 9bd. to implement the connection statement
     cache.  As a small optimisation, the default statement cache size
     has been increased from 100 to 128.  Patch by Erlend E. Aasland.

   - bpo-41818(185): Soumendra Ganguly: add termios.tcgetwinsize(),
     termios.tcsetwinsize().

   - bpo-40497(186): *note subprocess.check_output(): f8e. now raises
     *note ValueError: 1e3. when the invalid keyword argument 'check' is
     passed by user code.  Previously such use would fail later with a
     *note TypeError: 502.  Patch by Rémi Lapeyre.

   - bpo-37449(187): ‘ensurepip’ now uses ‘importlib.resources.files()’
     traversable APIs

   - bpo-40956(188): Use Argument Clinic in *note sqlite3: ba.  Patches
     by Erlend E. Aasland.

   - bpo-41730(189): ‘DeprecationWarning’ is now raised when importing
     ‘tkinter.tix’, which has been deprecated in documentation since
     Python 3.6.

   - bpo-20684(190): Remove unused ‘_signature_get_bound_param’ function
     from *note inspect: 72. - by Anthony Sottile.

   - bpo-41402(191): Fix *note email.message.EmailMessage.set_content():
     1813. when called with binary data and ‘7bit’ content transfer
     encoding.

   - bpo-32695(192): The 'compresslevel' and 'preset' keyword arguments
     of *note tarfile.open(): e40. are now both documented and tested.

   - bpo-41137(193): Use utf-8 encoding while reading .pdbrc files.
     Patch by Srinivas Reddy Thatiparthy

   - bpo-24391(194): Improved reprs of *note threading: d6.
     synchronization objects: *note Semaphore: 1129, *note
     BoundedSemaphore: 112a, *note Event: 112b. and *note Barrier: 11b4.

   - bpo-5846(195): Deprecated the following *note unittest: ef.
     functions, scheduled for removal in Python 3.13:

        * ‘findTestCases()’

        * ‘makeSuite()’

        * ‘getTestCaseNames()’

     Use *note TestLoader: 26e. methods instead:

        * *note unittest.TestLoader.loadTestsFromModule(): 26f.

        * *note unittest.TestLoader.loadTestsFromTestCase(): 270.

        * *note unittest.TestLoader.getTestCaseNames(): 271.

     Patch by Erlend E. Aasland.

   - bpo-40563(196): Support pathlike objects on dbm/shelve.  Patch by
     Hakan Çelik and Henry-Joseph Audéoud.

   - bpo-34990(197): Fixed a Y2k38 bug in the compileall module where it
     would fail to compile files with a modification time after the year
     2038.

   - bpo-39549(198): Whereas the code for reprlib.Repr had previously
     used a hardcoded string value of '...', this PR updates it to use
     of a “fillvalue” attribute, whose value defaults to '...'  and can
     be reset in either individual reprlib.Repr instances or in
     subclasses thereof.

   - bpo-37022(199): *note pdb: 94. now displays exceptions from
     ‘repr()’ with its ‘p’ and ‘pp’ commands.

   - bpo-38840(200): Fix ‘test___all__’ on platforms lacking a shared
     memory implementation.

   - bpo-39359(201): Add one missing check that the password is a bytes
     object for an encrypted zipfile.

   - bpo-38741(202): *note configparser: 1b.: using ']' inside a section
     header will no longer cut the section name short at the ']'

   - bpo-38415(203): Added missing behavior to *note
     contextlib.asynccontextmanager(): af8. to match *note
     contextlib.contextmanager(): 11d3. so decorated functions can
     themselves be decorators.

   - bpo-30256(204): Pass multiprocessing BaseProxy argument
     ‘manager_owned’ through AutoProxy.

   - bpo-27513(205): *note email.utils.getaddresses(): 1c5. now accepts
     *note email.header.Header: 1814. objects along with string values.
     Patch by Zackery Spytz.

   - bpo-16379(206): Add SQLite error code and name to *note sqlite3:
     ba. exceptions.  Patch by Aviv Palivoda, Daniel Shahaf, and Erlend
     E. Aasland.

   - bpo-26228(207): pty.spawn no longer hangs on FreeBSD, macOS, and
     Solaris.

   - bpo-33349(208): lib2to3 now recognizes async generators everywhere.

   - bpo-29298(209): Fix ‘TypeError’ when required subparsers without
     ‘dest’ do not receive arguments.  Patch by Anthony Sottile.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45371

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45329

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41710

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1596321

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45274

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21302

   (7) https://bugs.python.org/issue?@action=redirect&bpo=21302

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45238

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36674

   (10) https://bugs.python.org/issue?@action=redirect&bpo=45235

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45183

   (12) https://bugs.python.org/issue?@action=redirect&bpo=45234

   (13) https://bugs.python.org/issue?@action=redirect&bpo=45228

   (14) https://bugs.python.org/issue?@action=redirect&bpo=45225

   (15) https://bugs.python.org/issue?@action=redirect&bpo=42135

   (16) https://bugs.python.org/issue?@action=redirect&bpo=20524

   (17) https://bugs.python.org/issue?@action=redirect&bpo=45168

   (18) https://bugs.python.org/issue?@action=redirect&bpo=21302

   (19) https://bugs.python.org/issue?@action=redirect&bpo=45173

   (20) https://bugs.python.org/issue?@action=redirect&bpo=44987

   (21) https://bugs.python.org/issue?@action=redirect&bpo=35474

   (22) https://bugs.python.org/issue?@action=redirect&bpo=45166

   (23) https://bugs.python.org/issue?@action=redirect&bpo=45162

   (24) https://bugs.python.org/issue?@action=redirect&bpo=38371

   (25) https://bugs.python.org/issue?@action=redirect&bpo=20499

   (26) https://bugs.python.org/issue?@action=redirect&bpo=45132

   (27) https://bugs.python.org/issue?@action=redirect&bpo=45129

   (28) https://bugs.python.org/issue?@action=redirect&bpo=45124

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30856

   (30) https://bugs.python.org/issue?@action=redirect&bpo=45034

   (31) https://bugs.python.org/issue?@action=redirect&bpo=25894

   (32) https://bugs.python.org/issue?@action=redirect&bpo=45081

   (33) https://bugs.python.org/issue?@action=redirect&bpo=45085

   (34) https://bugs.python.org/issue?@action=redirect&bpo=40360

   (35) https://peps.python.org/pep-0617/

   (36) https://bugs.python.org/issue?@action=redirect&bpo=45075

   (37) https://bugs.python.org/issue?@action=redirect&bpo=31299

   (38) https://bugs.python.org/issue?@action=redirect&bpo=41620

   (39) https://bugs.python.org/issue?@action=redirect&bpo=45021

   (40) https://bugs.python.org/issue?@action=redirect&bpo=43913

   (41) https://bugs.python.org/issue?@action=redirect&bpo=45030

   (42) https://bugs.python.org/issue?@action=redirect&bpo=45001

   (43) https://bugs.python.org/issue?@action=redirect&bpo=45010

   (44) https://bugs.python.org/issue?@action=redirect&bpo=39218

   (45) https://bugs.python.org/issue?@action=redirect&bpo=43613

   (46) https://bugs.python.org/issue?@action=redirect&bpo=37596

   (47) https://bugs.python.org/issue?@action=redirect&bpo=44019

   (48) https://bugs.python.org/issue?@action=redirect&bpo=42255

   (49) https://bugs.python.org/issue?@action=redirect&bpo=44955

   (50) https://bugs.python.org/issue?@action=redirect&bpo=39039

   (51) https://bugs.python.org/issue?@action=redirect&bpo=44935

   (52) https://bugs.python.org/issue?@action=redirect&bpo=44911

   (53) https://bugs.python.org/issue?@action=redirect&bpo=41322

   (54) https://bugs.python.org/issue?@action=redirect&bpo=44524

   (55) https://bugs.python.org/issue?@action=redirect&bpo=38956

   (56) https://bugs.python.org/issue?@action=redirect&bpo=44860

   (57) https://bugs.python.org/issue?@action=redirect&bpo=44859

   (58) https://bugs.python.org/issue?@action=redirect&bpo=44581

   (59) https://bugs.python.org/issue?@action=redirect&bpo=44849

   (60) https://bugs.python.org/issue?@action=redirect&bpo=44605

   (61) https://bugs.python.org/issue?@action=redirect&bpo=44524

   (62) https://bugs.python.org/issue?@action=redirect&bpo=44839

   (63) https://bugs.python.org/issue?@action=redirect&bpo=44822

   (64) https://bugs.python.org/issue?@action=redirect&bpo=44801

   (65) https://bugs.python.org/issue?@action=redirect&bpo=44806

   (66) https://bugs.python.org/issue?@action=redirect&bpo=27275

   (67) https://bugs.python.org/issue?@action=redirect&bpo=44793

   (68) https://bugs.python.org/issue?@action=redirect&bpo=44784

   (69) https://bugs.python.org/issue?@action=redirect&bpo=44667

   (70) https://bugs.python.org/issue?@action=redirect&bpo=44771

   (71) https://bugs.python.org/issue?@action=redirect&bpo=44752

   (72) https://bugs.python.org/issue?@action=redirect&bpo=44747

   (73) https://bugs.python.org/issue?@action=redirect&bpo=42378

   (74) https://bugs.python.org/issue?@action=redirect&bpo=44720

   (75) https://bugs.python.org/issue?@action=redirect&bpo=44704

   (76) https://bugs.python.org/issue?@action=redirect&bpo=44666

   (77) https://bugs.python.org/issue?@action=redirect&bpo=44688

   (78) https://bugs.python.org/issue?@action=redirect&bpo=44690

   (79) https://bugs.python.org/issue?@action=redirect&bpo=42854

   (80) https://bugs.python.org/issue?@action=redirect&bpo=44686

   (81) https://bugs.python.org/issue?@action=redirect&bpo=44353

   (82) https://bugs.python.org/issue?@action=redirect&bpo=44682

   (83) https://bugs.python.org/issue?@action=redirect&bpo=44353

   (84) https://bugs.python.org/issue?@action=redirect&bpo=44678

   (85) https://bugs.python.org/issue?@action=redirect&bpo=44524

   (86) https://bugs.python.org/issue?@action=redirect&bpo=40897

   (87) https://bugs.python.org/issue?@action=redirect&bpo=44638

   (88) https://bugs.python.org/issue?@action=redirect&bpo=44648

   (89) https://bugs.python.org/issue?@action=redirect&bpo=44608

   (90) https://bugs.python.org/issue?@action=redirect&bpo=44594

   (91) https://bugs.python.org/issue?@action=redirect&bpo=42799

   (92) https://bugs.python.org/issue?@action=redirect&bpo=41928

   (93) https://bugs.python.org/issue?@action=redirect&bpo=44569

   (94) https://bugs.python.org/issue?@action=redirect&bpo=44566

   (95) https://bugs.python.org/issue?@action=redirect&bpo=44558

   (96) https://bugs.python.org/issue?@action=redirect&bpo=41249

   (97) https://bugs.python.org/issue?@action=redirect&bpo=44554

   (98) https://bugs.python.org/issue?@action=redirect&bpo=34798

   (99) https://bugs.python.org/issue?@action=redirect&bpo=44539

   (100) https://bugs.python.org/issue?@action=redirect&bpo=44461

   (101) https://bugs.python.org/issue?@action=redirect&bpo=43625

   (102) https://bugs.python.org/issue?@action=redirect&bpo=44516

   (103) https://bugs.python.org/issue?@action=redirect&bpo=42892

   (104) https://bugs.python.org/issue?@action=redirect&bpo=44468

   (105) https://bugs.python.org/issue?@action=redirect&bpo=44491

   (106) https://bugs.python.org/issue?@action=redirect&bpo=43977

   (107) https://bugs.python.org/issue?@action=redirect&bpo=44482

   (108) https://bugs.python.org/issue?@action=redirect&bpo=44466

   (109) https://bugs.python.org/issue?@action=redirect&bpo=44471

   (110) https://bugs.python.org/issue?@action=redirect&bpo=44404

   (111) https://bugs.python.org/issue?@action=redirect&bpo=41546

   (112) https://bugs.python.org/issue?@action=redirect&bpo=44458

   (113) https://bugs.python.org/issue?@action=redirect&bpo=44464

   (114) https://bugs.python.org/issue?@action=redirect&bpo=44446

   (115) https://bugs.python.org/issue?@action=redirect&bpo=44439

   (116) https://bugs.python.org/issue?@action=redirect&bpo=44434

   (117) https://bugs.python.org/issue?@action=redirect&bpo=42972

   (118) https://bugs.python.org/issue?@action=redirect&bpo=44422

   (119) https://bugs.python.org/issue?@action=redirect&bpo=38291

   (120) https://bugs.python.org/issue?@action=redirect&bpo=37880

   (121) https://bugs.python.org/issue?@action=redirect&bpo=44389

   (122) https://bugs.python.org/issue?@action=redirect&bpo=27827

   (123) https://bugs.python.org/issue?@action=redirect&bpo=44395

   (124) https://bugs.python.org/issue?@action=redirect&bpo=34266

   (125) https://bugs.python.org/issue?@action=redirect&bpo=44362

   (126) https://bugs.python.org/issue?@action=redirect&bpo=44342

   (127) https://bugs.python.org/issue?@action=redirect&bpo=44356

   (128) https://bugs.python.org/issue?@action=redirect&bpo=44351

   (129) https://bugs.python.org/issue?@action=redirect&bpo=35800

   (130) https://bugs.python.org/issue?@action=redirect&bpo=44357

   (131) https://bugs.python.org/issue?@action=redirect&bpo=44339

   (132) https://bugs.python.org/issue?@action=redirect&bpo=44242

   (133) https://bugs.python.org/issue?@action=redirect&bpo=44246

   (134) https://bugs.python.org/issue?@action=redirect&bpo=44246

   (135) https://bugs.python.org/issue?@action=redirect&bpo=43858

   (136) https://bugs.python.org/issue?@action=redirect&bpo=44260

   (137) https://bugs.python.org/issue?@action=redirect&bpo=44254

   (138) https://bugs.python.org/issue?@action=redirect&bpo=44258

   (139) https://bugs.python.org/issue?@action=redirect&bpo=44235

   (140) https://bugs.python.org/issue?@action=redirect&bpo=38693

   (141) https://bugs.python.org/issue?@action=redirect&bpo=33693

   (142) https://bugs.python.org/issue?@action=redirect&bpo=44241

   (143) https://bugs.python.org/issue?@action=redirect&bpo=43216

   (144) https://bugs.python.org/issue?@action=redirect&bpo=44210

   (145) https://bugs.python.org/issue?@action=redirect&bpo=43643

   (146) https://bugs.python.org/issue?@action=redirect&bpo=27334

   (147) https://bugs.python.org/issue?@action=redirect&bpo=4928

   (148) https://bugs.python.org/issue?@action=redirect&bpo=44154

   (149) https://bugs.python.org/issue?@action=redirect&bpo=33433

   (150) https://datatracker.ietf.org/doc/html/rfc4291.html

   (151) https://bugs.python.org/issue?@action=redirect&bpo=44150

   (152) https://bugs.python.org/issue?@action=redirect&bpo=44142

   (153) https://bugs.python.org/issue?@action=redirect&bpo=44145

   (154) https://bugs.python.org/issue?@action=redirect&bpo=44095

   (155) https://bugs.python.org/issue?@action=redirect&bpo=44077

   (156) https://bugs.python.org/issue?@action=redirect&bpo=37788

   (157) https://bugs.python.org/issue?@action=redirect&bpo=38908

   (158) https://bugs.python.org/issue?@action=redirect&bpo=44098

   (159) https://peps.python.org/pep-0612/

   (160) https://bugs.python.org/issue?@action=redirect&bpo=44089

   (161) https://bugs.python.org/issue?@action=redirect&bpo=44081

   (162) https://bugs.python.org/issue?@action=redirect&bpo=44061

   (163) https://bugs.python.org/issue?@action=redirect&bpo=44059

   (164) https://bugs.python.org/issue?@action=redirect&bpo=36515

   (165) https://bugs.python.org/issue?@action=redirect&bpo=40465

   (166) https://bugs.python.org/issue?@action=redirect&bpo=44018

   (167) https://bugs.python.org/issue?@action=redirect&bpo=38352

   (168) https://bugs.python.org/issue?@action=redirect&bpo=44002

   (169) https://bugs.python.org/issue?@action=redirect&bpo=43972

   (170) https://bugs.python.org/issue?@action=redirect&bpo=28528

   (171) https://bugs.python.org/issue?@action=redirect&bpo=43853

   (172) https://bugs.python.org/issue?@action=redirect&bpo=43666

   (173) https://bugs.python.org/issue?@action=redirect&bpo=43650

   (174) https://bugs.python.org/issue?@action=redirect&bpo=43612

   (175) https://bugs.python.org/issue?@action=redirect&bpo=43392

   (176) https://bugs.python.org/issue?@action=redirect&bpo=43318

   (177) https://bugs.python.org/issue?@action=redirect&bpo=43234

   (178) https://bugs.python.org/issue?@action=redirect&bpo=43232

   (179) https://bugs.python.org/issue?@action=redirect&bpo=30077

   (180) https://bugs.python.org/issue?@action=redirect&bpo=42971

   (181) https://bugs.python.org/issue?@action=redirect&bpo=43086

   (182) https://bugs.python.org/issue?@action=redirect&bpo=43024

   (183) https://bugs.python.org/issue?@action=redirect&bpo=33809

   (184) https://bugs.python.org/issue?@action=redirect&bpo=42862

   (185) https://bugs.python.org/issue?@action=redirect&bpo=41818

   (186) https://bugs.python.org/issue?@action=redirect&bpo=40497

   (187) https://bugs.python.org/issue?@action=redirect&bpo=37449

   (188) https://bugs.python.org/issue?@action=redirect&bpo=40956

   (189) https://bugs.python.org/issue?@action=redirect&bpo=41730

   (190) https://bugs.python.org/issue?@action=redirect&bpo=20684

   (191) https://bugs.python.org/issue?@action=redirect&bpo=41402

   (192) https://bugs.python.org/issue?@action=redirect&bpo=32695

   (193) https://bugs.python.org/issue?@action=redirect&bpo=41137

   (194) https://bugs.python.org/issue?@action=redirect&bpo=24391

   (195) https://bugs.python.org/issue?@action=redirect&bpo=5846

   (196) https://bugs.python.org/issue?@action=redirect&bpo=40563

   (197) https://bugs.python.org/issue?@action=redirect&bpo=34990

   (198) https://bugs.python.org/issue?@action=redirect&bpo=39549

   (199) https://bugs.python.org/issue?@action=redirect&bpo=37022

   (200) https://bugs.python.org/issue?@action=redirect&bpo=38840

   (201) https://bugs.python.org/issue?@action=redirect&bpo=39359

   (202) https://bugs.python.org/issue?@action=redirect&bpo=38741

   (203) https://bugs.python.org/issue?@action=redirect&bpo=38415

   (204) https://bugs.python.org/issue?@action=redirect&bpo=30256

   (205) https://bugs.python.org/issue?@action=redirect&bpo=27513

   (206) https://bugs.python.org/issue?@action=redirect&bpo=16379

   (207) https://bugs.python.org/issue?@action=redirect&bpo=26228

   (208) https://bugs.python.org/issue?@action=redirect&bpo=33349

   (209) https://bugs.python.org/issue?@action=redirect&bpo=29298


File: python.info,  Node: Documentation<25>,  Next: Tests<28>,  Prev: Library<30>,  Up: Python 3 11 0 alpha 1

1.23.31.4 Documentation
.......................

   - bpo-45216(1): Remove extra documentation listing methods in
     ‘difflib’.  It was rendering twice in pydoc and was outdated in
     some places.

   - bpo-45024(2): *note collections.abc: 17. documentation has been
     expanded to explicitly cover how instance and subclass checks work,
     with additional doctest examples and an exhaustive list of ABCs
     which test membership purely by presence of the right *note special
     method: 1816.s.  Patch by Raymond Hettinger.

   - bpo-44957(3): Promote PEP 604 union syntax by using it where
     possible.  Also, mention ‘X | Y’ more prominently in section about
     ‘Union’ and mention ‘X | None’ at all in section about ‘Optional’.

   - bpo-16580(4): Added code equivalents for the *note int.to_bytes():
     17fa. and *note int.from_bytes(): 17ba. methods, as well as tests
     ensuring that these code equivalents are valid.

   - bpo-44903(5): Removed the ‘othergui.rst’ file, any references to
     it, and the list of GUI frameworks in the FAQ. In their place I've
     added links to the Python Wiki page on GUI frameworks(6).

   - bpo-33479(7): Tkinter documentation has been greatly expanded with
     new "Architecture" and "Threading model" sections.

   - bpo-36700(8): *note base64: a. RFC references were updated to point
     to RFC 4648(9); a section was added to point users to the new
     "security considerations" section of the RFC.

   - bpo-44740(10): Replaced occurrences of uppercase "Web" and
     "Internet" with lowercase versions per the 2016 revised Associated
     Press Style Book.

   - bpo-44693(11): Update the definition of __future__ in the glossary
     by replacing the confusing word "pseudo-module" with a more
     accurate description.

   - bpo-35183(12): Add typical examples to os.path.splitext docs

   - bpo-30511(13): Clarify that *note shutil.make_archive(): 47f. is
     not thread-safe due to reliance on changing the current working
     directory.

   - bpo-44561(14): Update of three expired hyperlinks in
     Doc/distributing/index.rst: "Project structure", "Building and
     packaging the project", and "Uploading the project to the Python
     Packaging Index".

   - bpo-44651(15): Delete entry "coercion" in Doc/glossary.rst for its
     outdated definition.

   - bpo-42958(16): Updated the docstring and docs of *note
     filecmp.cmp(): 15c2. to be more accurate and less confusing
     especially in respect to 'shallow' arg.

   - bpo-44631(17): Refactored the ‘repr()’ code of the ‘_Environ’ (os
     module).

   - bpo-44613(18): importlib.metadata is no longer provisional.

   - bpo-44558(19): Match the docstring and python implementation of
     *note countOf(): 8aa. to the behavior of its c implementation.

   - bpo-44544(20): List all kwargs for *note textwrap.wrap(): 146c,
     *note textwrap.fill(): 146b, and *note textwrap.shorten(): f9d.
     Now, there are nav links to attributes of ‘TextWrap’, which makes
     navigation much easier while minimizing duplication in the
     documentation.

   - bpo-38062(21): Clarify that atexit uses equality comparisons
     internally.

   - bpo-40620(22): Convert examples in tutorial controlflow.rst section
     4.3 to be interpreter-demo style.

   - bpo-43066(23): Added a warning to *note zipfile: 117. docs:
     filename arg with a leading slash may cause archive to be
     un-openable on Windows systems.

   - bpo-39452(24): Rewrote ‘Doc/library/__main__.rst’.  Broadened scope
     of the document to explicitly discuss and differentiate between
     ‘__main__.py’ in packages versus the ‘__name__ == '__main__'’
     expression (and the idioms that surround it).

   - bpo-13814(25): In the Design FAQ, answer "Why don't generators
     support the with statement?"

   - bpo-27752(26): Documentation of csv.Dialect is more descriptive.

   - bpo-44453(27): Fix documentation for the return type of *note
     sysconfig.get_path(): 12fd.

   - bpo-44392(28): Added a new section in the C API documentation for
     types used in type hinting.  Documented ‘Py_GenericAlias’ and
     ‘Py_GenericAliasType’.

   - bpo-38291(29): Mark ‘typing.io’ and ‘typing.re’ as deprecated since
     Python 3.8 in the documentation.  They were never properly
     supported by type checkers.

   - bpo-44322(30): Document that SyntaxError args have a details tuple
     and that details are adjusted for errors in f-string field
     replacement expressions.

   - bpo-42392(31): Document the deprecation and removal of the ‘loop’
     parameter for many functions and classes in *note asyncio: 8.

   - bpo-44195(32): Corrected references to ‘TraversableResources’ in
     docs.  There is no ‘TraversableReader’.

   - bpo-41963(33): Document that ‘ConfigParser’ strips off comments
     when reading configuration files.

   - bpo-44072(34): Correct where in the numeric ABC hierarchy ‘**’
     support is added, i.e., in numbers.Complex, not numbers.Integral.

   - bpo-43558(35): Add the remark to *note dataclasses: 27.
     documentation that the ‘__init__()’ of any base class has to be
     called in ‘__post_init__()’, along with a code example.

   - bpo-44025(36): Clarify when '_' in match statements is a keyword,
     and when not.

   - bpo-41706(37): Fix docs about how methods like ‘__add__’ are
     invoked when evaluating operator expressions.

   - bpo-41621(38): Document that *note collections.defaultdict: 118d.
     parameter ‘default_factory’ defaults to ‘None’ and is
     positional-only.

   - bpo-41576(39): document BaseException in favor of bare except

   - bpo-21760(40): The description for __file__ fixed.  Patch by Furkan
     Onder

   - bpo-39498(41): Add a "Security Considerations" index which links to
     standard library modules that have explicitly documented security
     considerations.

   - bpo-33479(42): Remove the unqualified claim that tkinter is
     threadsafe.  It has not been true for several years and likely
     never was.  An explanation of what is true may be added later,
     after more discussion, and possibly after patching _tkinter.c,

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45216

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45024

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44957

   (4) https://bugs.python.org/issue?@action=redirect&bpo=16580

   (5) https://bugs.python.org/issue?@action=redirect&bpo=44903

   (6) https://wiki.python.org/moin/GuiProgramming

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33479

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36700

   (9) https://datatracker.ietf.org/doc/html/rfc4648.html

   (10) https://bugs.python.org/issue?@action=redirect&bpo=44740

   (11) https://bugs.python.org/issue?@action=redirect&bpo=44693

   (12) https://bugs.python.org/issue?@action=redirect&bpo=35183

   (13) https://bugs.python.org/issue?@action=redirect&bpo=30511

   (14) https://bugs.python.org/issue?@action=redirect&bpo=44561

   (15) https://bugs.python.org/issue?@action=redirect&bpo=44651

   (16) https://bugs.python.org/issue?@action=redirect&bpo=42958

   (17) https://bugs.python.org/issue?@action=redirect&bpo=44631

   (18) https://bugs.python.org/issue?@action=redirect&bpo=44613

   (19) https://bugs.python.org/issue?@action=redirect&bpo=44558

   (20) https://bugs.python.org/issue?@action=redirect&bpo=44544

   (21) https://bugs.python.org/issue?@action=redirect&bpo=38062

   (22) https://bugs.python.org/issue?@action=redirect&bpo=40620

   (23) https://bugs.python.org/issue?@action=redirect&bpo=43066

   (24) https://bugs.python.org/issue?@action=redirect&bpo=39452

   (25) https://bugs.python.org/issue?@action=redirect&bpo=13814

   (26) https://bugs.python.org/issue?@action=redirect&bpo=27752

   (27) https://bugs.python.org/issue?@action=redirect&bpo=44453

   (28) https://bugs.python.org/issue?@action=redirect&bpo=44392

   (29) https://bugs.python.org/issue?@action=redirect&bpo=38291

   (30) https://bugs.python.org/issue?@action=redirect&bpo=44322

   (31) https://bugs.python.org/issue?@action=redirect&bpo=42392

   (32) https://bugs.python.org/issue?@action=redirect&bpo=44195

   (33) https://bugs.python.org/issue?@action=redirect&bpo=41963

   (34) https://bugs.python.org/issue?@action=redirect&bpo=44072

   (35) https://bugs.python.org/issue?@action=redirect&bpo=43558

   (36) https://bugs.python.org/issue?@action=redirect&bpo=44025

   (37) https://bugs.python.org/issue?@action=redirect&bpo=41706

   (38) https://bugs.python.org/issue?@action=redirect&bpo=41621

   (39) https://bugs.python.org/issue?@action=redirect&bpo=41576

   (40) https://bugs.python.org/issue?@action=redirect&bpo=21760

   (41) https://bugs.python.org/issue?@action=redirect&bpo=39498

   (42) https://bugs.python.org/issue?@action=redirect&bpo=33479


File: python.info,  Node: Tests<28>,  Next: Build<30>,  Prev: Documentation<25>,  Up: Python 3 11 0 alpha 1

1.23.31.5 Tests
...............

   - bpo-40173(1): Fix *note
     test.support.import_helper.import_fresh_module(): 1818.

   - bpo-45280(2): Add a test case for empty *note typing.NamedTuple:
     290.

   - bpo-45269(3): Cover case when invalid ‘markers’ type is supplied to
     ‘c_make_encoder’.

   - bpo-45128(4): Fix ‘test_multiprocessing_fork’ failure due to
     ‘test_logging’ and ‘sys.modules’ manipulation.

   - bpo-45209(5): Fix ‘UserWarning: resource_tracker’ warning in
     ‘_test_multiprocessing._TestSharedMemory.test_shared_memory_cleaned_after_process_termination’

   - bpo-45185(6): Enables ‘TestEnumerations’ test cases in ‘test_ssl’
     suite.

   - bpo-45195(7): Fix test_readline.test_nonascii(): sometimes, the
     newline character is not written at the end, so don't expect it in
     the output.  Patch by Victor Stinner.

   - bpo-45156(8): Fixes infinite loop on *note unittest.mock.seal():
     b6f. of mocks created by ‘create_autospec()’.

   - bpo-45125(9): Improves pickling tests and docs of ‘SharedMemory’
     and ‘SharableList’ objects.

   - bpo-44860(10): Update ‘test_sysconfig.test_user_similar()’ for the
     posix_user scheme: ‘platlib’ doesn't use *note sys.platlibdir: 906.
     Patch by Victor Stinner.

   - bpo-45052(11):
     ‘WithProcessesTestSharedMemory.test_shared_memory_basics’ test was
     ignored, because ‘self.assertEqual(sms.size, sms2.size)’ line was
     failing.  It is now removed and test is unskipped.

     The main motivation for this line to be removed from the test is
     that the ‘size’ of ‘SharedMemory’ is not ever guaranteed to be the
     same.  It is decided by the platform.

   - bpo-44895(12): libregrtest now clears the type cache later to
     reduce the risk of false alarm when checking for reference leaks.
     Previously, the type cache was cleared too early and libregrtest
     raised a false alarm about reference leaks under very specific
     conditions.  Patch by Irit Katriel and Victor Stinner.

   - bpo-45042(13): Fixes that test classes decorated with
     ‘@hashlib_helper.requires_hashdigest’ were skipped all the time.

   - bpo-25130(14): Add calls of *note gc.collect(): a08. in tests to
     support PyPy.

   - bpo-45011(15): Made tests relying on the ‘_asyncio’ C extension
     module optional to allow running on alternative Python
     implementations.  Patch by Serhiy Storchaka.

   - bpo-44949(16): Fix auto history tests of test_readline: sometimes,
     the newline character is not written at the end, so don't expect it
     in the output.

   - bpo-44891(17): Tests were added to clarify *note id(): 13ca. is
     preserved when ‘obj * 1’ is used on *note str: 418. and *note
     bytes: 1a4. objects.  Patch by Nikita Sobolev.

   - bpo-44852(18): Add ability to wholesale silence DeprecationWarnings
     while running the regression test suite.

   - bpo-40928(19): Notify users running test_decimal regression tests
     on macOS of potential harmless "malloc can't allocate region"
     messages spewed by test_decimal.

   - bpo-44734(20): Fixed floating-point precision issue in turtle
     tests.

   - bpo-44708(21): Regression tests, when run with -w, are now
     re-running only the affected test methods instead of re-running the
     entire test file.

   - bpo-42095(22): Added interop tests for Apple plists: generate plist
     files with Python plistlib and parse with Apple plutil; and the
     other way round.

   - bpo-44647(23): Added a permanent Unicode-valued environment
     variable to regression tests to ensure they handle this use case in
     the future.  If your test environment breaks because of that,
     report a bug to us, and temporarily set
     PYTHONREGRTEST_UNICODE_GUARD=0 in your test environment.

   - bpo-44515(24): Adjust recently added contextlib tests to avoid
     assuming the use of a refcounted GC

   - bpo-44287(25): Fix asyncio test_popen() of test_windows_utils by
     using a longer timeout.  Use military grade battle-tested *note
     test.support.SHORT_TIMEOUT: 1819. timeout rather than a hardcoded
     timeout of 10 seconds: it's 30 seconds by default, but it is made
     longer on slow buildbots.  Patch by Victor Stinner.

   - bpo-44451(26): Reset ‘DeprecationWarning’ filters in
     ‘test.test_importlib.test_metadata_api.APITests.test_entry_points_by_index’
     to avoid ‘StopIteration’ error if ‘DeprecationWarnings’ are
     ignored.

   - bpo-44363(27): Account for address sanitizer in test_capi.
     test_capi now passes when run GCC address sanitizer.

   - bpo-44364(28): Add non integral tests for *note math.sqrt(): 9d4.
     function.

   - bpo-43921(29): Fix test_ssl.test_wrong_cert_tls13(): use
     ‘suppress_ragged_eofs=False’, since ‘read()’ can raise *note
     ssl.SSLEOFError: 16af. on Windows.  Patch by Victor Stinner.

   - bpo-43921(30): Fix test_pha_required_nocert() of test_ssl: catch
     two more EOF cases (when the ‘recv()’ method returns an empty
     string).  Patch by Victor Stinner.

   - bpo-44131(31): Add test_frozenmain to test_embed to test the
     ‘Py_FrozenMain()’ C function.  Patch by Victor Stinner.

   - bpo-31904(32): Ignore error string case in test_file_not_exists().

   - bpo-42083(33): Add test to check that ‘PyStructSequence_NewType’
     accepts a ‘PyStructSequence_Desc’ with ‘doc’ field set to ‘NULL’.

   - bpo-35753(34): Fix crash in doctest when doctest parses modules
     that include unwrappable functions by skipping those functions.

   - bpo-30256(35): Add test for nested queues when using
     ‘multiprocessing’ shared objects ‘AutoProxy[Queue]’ inside
     ‘ListProxy’ and ‘DictProxy’

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40173

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45280

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45269

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45128

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45209

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45185

   (7) https://bugs.python.org/issue?@action=redirect&bpo=45195

   (8) https://bugs.python.org/issue?@action=redirect&bpo=45156

   (9) https://bugs.python.org/issue?@action=redirect&bpo=45125

   (10) https://bugs.python.org/issue?@action=redirect&bpo=44860

   (11) https://bugs.python.org/issue?@action=redirect&bpo=45052

   (12) https://bugs.python.org/issue?@action=redirect&bpo=44895

   (13) https://bugs.python.org/issue?@action=redirect&bpo=45042

   (14) https://bugs.python.org/issue?@action=redirect&bpo=25130

   (15) https://bugs.python.org/issue?@action=redirect&bpo=45011

   (16) https://bugs.python.org/issue?@action=redirect&bpo=44949

   (17) https://bugs.python.org/issue?@action=redirect&bpo=44891

   (18) https://bugs.python.org/issue?@action=redirect&bpo=44852

   (19) https://bugs.python.org/issue?@action=redirect&bpo=40928

   (20) https://bugs.python.org/issue?@action=redirect&bpo=44734

   (21) https://bugs.python.org/issue?@action=redirect&bpo=44708

   (22) https://bugs.python.org/issue?@action=redirect&bpo=42095

   (23) https://bugs.python.org/issue?@action=redirect&bpo=44647

   (24) https://bugs.python.org/issue?@action=redirect&bpo=44515

   (25) https://bugs.python.org/issue?@action=redirect&bpo=44287

   (26) https://bugs.python.org/issue?@action=redirect&bpo=44451

   (27) https://bugs.python.org/issue?@action=redirect&bpo=44363

   (28) https://bugs.python.org/issue?@action=redirect&bpo=44364

   (29) https://bugs.python.org/issue?@action=redirect&bpo=43921

   (30) https://bugs.python.org/issue?@action=redirect&bpo=43921

   (31) https://bugs.python.org/issue?@action=redirect&bpo=44131

   (32) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (33) https://bugs.python.org/issue?@action=redirect&bpo=42083

   (34) https://bugs.python.org/issue?@action=redirect&bpo=35753

   (35) https://bugs.python.org/issue?@action=redirect&bpo=30256


File: python.info,  Node: Build<30>,  Next: Windows<27>,  Prev: Tests<28>,  Up: Python 3 11 0 alpha 1

1.23.31.6 Build
...............

   - bpo-45220(1): Avoid building with the Windows 11 SDK previews
     automatically.  This may be overridden by setting the
     ‘DefaultWindowsSDKVersion’ environment variable before building.

   - bpo-45020(2): Freeze stdlib modules that are imported during
     startup.  This provides significant performance improvements to
     startup.  If necessary, use the previously added "-X
     frozen_modules=off" commandline option to force importing the
     source modules.

   - bpo-45188(3): Windows builds now regenerate frozen modules as the
     first part of the build.  Previously the regeneration was later in
     the build, which would require it to be restarted if any modules
     had changed.

   - bpo-45163(4): Fixes Haiku platform build.

   - bpo-45067(5): The ncurses function extended_color_content was
     introduced in 2017

     (‘https://invisible-island.net/ncurses/NEWS.html#index-t20170401’).
     The

     ncurses-devel package in CentOS 7 had a older version ncurses
     resulted in compilation error.  For compiling ncurses with extended
     color support, we verify the version of the ncurses library >=
     20170401.

   - bpo-45019(6): Generate lines in relevant files for frozen modules.
     Up until now each of the files had to be edited manually.  This
     change makes it easier to add to and modify the frozen modules.

   - bpo-44340(7): Add support for building with clang thin lto via
     -with-lto=thin/full.  Patch by Donghee Na and Brett Holman.

   - bpo-44535(8): Enable building using a Visual Studio 2022 install on
     Windows.

   - bpo-43298(9): Improved error message when building without a
     Windows SDK installed.

   - bpo-44381(10): The Windows build now accepts
     ‘EnableControlFlowGuard’ set to ‘guard’ to enable CFG.

   - bpo-41282(11): Fix broken ‘make install’ that caused standard
     library extension modules to be unnecessarily and incorrectly
     rebuilt during the install phase of cpython.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45220

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45020

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45188

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45163

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45067

   (6) https://bugs.python.org/issue?@action=redirect&bpo=45019

   (7) https://bugs.python.org/issue?@action=redirect&bpo=44340

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44535

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43298

   (10) https://bugs.python.org/issue?@action=redirect&bpo=44381

   (11) https://bugs.python.org/issue?@action=redirect&bpo=41282


File: python.info,  Node: Windows<27>,  Next: macOS<22>,  Prev: Build<30>,  Up: Python 3 11 0 alpha 1

1.23.31.7 Windows
.................

   - bpo-45375(1): Fixes an assertion failure due to searching for the
     standard library in unnormalised paths.

   - bpo-45022(2): Update Windows release to include libffi 3.4.2

   - bpo-45007(3): Update to OpenSSL 1.1.1l in Windows build

   - bpo-44848(4): Upgrade Windows installer to use SQLite 3.36.0.

   - bpo-44572(5): Avoid consuming standard input in the *note platform:
     98. module

   - bpo-44582(6): Accelerate speed of *note mimetypes: 82.
     initialization using a native implementation of the registry scan.

   - bpo-41299(7): Fix 16 milliseconds jitter when using timeouts in
     *note threading: d6, such as with *note threading.Lock.acquire():
     664. or *note threading.Condition.wait(): 181c.

   - bpo-42686(8): Build *note sqlite3: ba. with math functions enabled.
     Patch by Erlend E. Aasland.

   - bpo-40263(9): This is a follow-on bug from
     ‘https://bugs.python.org/issue26903’.  Once that is applied we run
     into an off-by-one assertion problem.  The assert was not correct.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45375

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45022

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45007

   (4) https://bugs.python.org/issue?@action=redirect&bpo=44848

   (5) https://bugs.python.org/issue?@action=redirect&bpo=44572

   (6) https://bugs.python.org/issue?@action=redirect&bpo=44582

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41299

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42686

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40263


File: python.info,  Node: macOS<22>,  Next: IDLE<19>,  Prev: Windows<27>,  Up: Python 3 11 0 alpha 1

1.23.31.8 macOS
...............

   - bpo-45007(1): Update macOS installer builds to use OpenSSL 1.1.1l.

   - bpo-34602(2): When building CPython on macOS with ‘./configure
     --with-undefined-behavior-sanitizer --with-pydebug’, the stack size
     is now quadrupled to allow for the entire test suite to pass.

   - bpo-44848(3): Update macOS installer to use SQLite 3.36.0.

   - bpo-44689(4): *note ctypes.util.find_library(): d17. now works
     correctly on macOS 11 Big Sur even if Python is built on an older
     version of macOS. Previously, when built on older macOS systems,
     ‘find_library’ was not able to find macOS system libraries when
     running on Big Sur due to changes in how system libraries are
     stored.

   - bpo-41972(5): The framework build's user header path in sysconfig
     is changed to add a 'pythonX.Y' component to match distutils's
     behavior.

   - bpo-43109(6): Allow -with-lto configure option to work with
     Apple-supplied Xcode or Command Line Tools.

   - bpo-34932(7): Add socket.TCP_KEEPALIVE support for macOS. Patch by
     Shane Harvey.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45007

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34602

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44848

   (4) https://bugs.python.org/issue?@action=redirect&bpo=44689

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41972

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43109

   (7) https://bugs.python.org/issue?@action=redirect&bpo=34932


File: python.info,  Node: IDLE<19>,  Next: Tools/Demos<14>,  Prev: macOS<22>,  Up: Python 3 11 0 alpha 1

1.23.31.9 IDLE
..............

   - bpo-45296(1): On Windows, change exit/quit message to suggest
     Ctrl-D, which works, instead of <Ctrl-Z Return>, which does not
     work in IDLE.

   - bpo-45193(2): Make completion boxes appear on Ubuntu again.

   - bpo-40128(3): Mostly fix completions on macOS when not using tcl/tk
     8.6.11 (as with 3.9).  The added update_idletask call should be
     harmless and possibly helpful otherwise.

   - bpo-33962(4): Move the indent space setting from the Font tab to
     the new Windows tab.  Patch by Mark Roseman and Terry Jan Reedy.

   - bpo-40468(5): Split the settings dialog General tab into Windows
     and Shell/ED tabs.  Move help sources, which extend the Help menu,
     to the Extensions tab.  Make space for new options and shorten the
     dialog.  The latter makes the dialog better fit small screens.

   - bpo-41611(6): Avoid uncaught exceptions in
     ‘AutoCompleteWindow.winconfig_event()’.

   - bpo-41611(7): Fix IDLE sometimes freezing upon tab-completion on
     macOS.

   - bpo-44010(8): Highlight the new *note match: 7d8. statement's *note
     soft keywords: 7d7.: *note match: 7d8, *note case: 7d8, and *note
     _: 7d9.  However, this highlighting is not perfect and will be
     incorrect in some rare cases, including some ‘_’-s in ‘case’
     patterns.

   - bpo-44026(9): Include interpreter's typo fix suggestions in message
     line for NameErrors and AttributeErrors.  Patch by E. Paine.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=45296

   (2) https://bugs.python.org/issue?@action=redirect&bpo=45193

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40128

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33962

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40468

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41611

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41611

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44010

   (9) https://bugs.python.org/issue?@action=redirect&bpo=44026


File: python.info,  Node: Tools/Demos<14>,  Next: C API<29>,  Prev: IDLE<19>,  Up: Python 3 11 0 alpha 1

1.23.31.10 Tools/Demos
......................

   - bpo-44786(1): Fix a warning in regular expression in the c-analyzer
     script.

   - bpo-44967(2): pydoc now returns a non-zero status code when a
     module cannot be found.

   - bpo-44978(3): Allow the Argument Clinic tool to handle
     ‘__complex__’ special methods.

   - bpo-43425(4): Removed the 'test2to3' demo project that demonstrated
     using lib2to3 to support Python 2.x and Python 3.x from a single
     source in a distutils package.  Patch by Donghee Na

   - bpo-44074(5): Make patchcheck automatically detect the correct base
     branch name (previously it was hardcoded to 'master')

   - bpo-20291(6): Added support for variadic positional parameters in
     Argument Clinic.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44786

   (2) https://bugs.python.org/issue?@action=redirect&bpo=44967

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44978

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43425

   (5) https://bugs.python.org/issue?@action=redirect&bpo=44074

   (6) https://bugs.python.org/issue?@action=redirect&bpo=20291


File: python.info,  Node: C API<29>,  Prev: Tools/Demos<14>,  Up: Python 3 11 0 alpha 1

1.23.31.11 C API
................

   - bpo-41710(1): The PyThread_acquire_lock_timed() function now clamps
     the timeout if it is too large, rather than aborting the process.
     Patch by Victor Stinner.

   - bpo-44687(2): ‘BufferedReader.peek()’ no longer raises *note
     ValueError: 1e3. when the entire file has already been buffered.

   - bpo-45116(3): Add the *note Py_ALWAYS_INLINE: 1821. macro to ask
     the compiler to always inline a static inline function.  The
     compiler can ignore it and decides to not inline the function.
     Patch by Victor Stinner.

   - bpo-45094(4): Add the *note Py_NO_INLINE: 1822. macro to disable
     inlining on a function.  Patch by Victor Stinner.

   - bpo-45061(5): Add a deallocator to the *note bool: 434. type to
     detect refcount bugs in C extensions which call
     ‘Py_DECREF(Py_True);’ or ‘Py_DECREF(Py_False);’ by mistake.  Patch
     by Victor Stinner.

   - bpo-42035(6): Add a new *note PyType_GetQualName(): 71e. function
     to get type's qualified name.

   - bpo-41103(7): Reverts removal of the old buffer protocol because
     they are part of stable ABI.

   - bpo-44751(8): Remove ‘crypt.h’ include from the public ‘Python.h’
     header.

   - bpo-42747(9): The ‘Py_TPFLAGS_HAVE_VERSION_TAG’ type flag now does
     nothing.  The ‘Py_TPFLAGS_HAVE_AM_SEND’ flag (which was added in
     3.10) is removed.  Both were unnecessary because it is not possible
     to have type objects with the relevant fields missing.

   - bpo-44530(10): Added the ‘co_qualname’ to the ‘PyCodeObject’
     structure to propagate the qualified name from the compiler to code
     objects.

     Patch by Gabriele N. Tornetta

   - bpo-44441(11): *note Py_RunMain(): 993. now resets
     ‘PyImport_Inittab’ to its initial value at exit.  It must be
     possible to call *note PyImport_AppendInittab(): 170e. or *note
     PyImport_ExtendInittab(): 170f. at each Python initialization.
     Patch by Victor Stinner.

   - bpo-39947(12): Remove 4 private trashcan C API functions which were
     only kept for the backward compatibility of the stable ABI with
     Python 3.8 and older, since the trashcan API was not usable with
     the limited C API on Python 3.8 and older.  The trashcan API was
     excluded from the limited C API in Python 3.9.

     Removed functions:

        * _PyTrash_deposit_object()

        * _PyTrash_destroy_chain()

        * _PyTrash_thread_deposit_object()

        * _PyTrash_thread_destroy_chain()

     The trashcan C API was never usable with the limited C API, since
     old trashcan macros accessed directly *note PyThreadState: 758.
     members like ‘_tstate->trash_delete_nesting’, whereas the *note
     PyThreadState: 758. structure is opaque in the limited C API.

     Exclude also the ‘PyTrash_UNWIND_LEVEL’ constant from the C API.

     Patch by Victor Stinner.

   - bpo-40939(13): Removed documentation for the removed ‘PyParser_*’ C
     API.

   - bpo-43795(14): The list in *note 限定版APIの内容: 765. now shows
     the public name *note PyFrameObject: 754. rather than ‘_frame’.
     The non-existing entry ‘_node’ no longer appears in the list.

   - bpo-44378(15): *note Py_IS_TYPE(): 1780. no longer uses *note
     Py_TYPE(): 74b. to avoid a compiler warning: no longer cast ‘const
     PyObject*’ to ‘PyObject*’.  Patch by Victor Stinner.

   - bpo-39573(16): Convert the *note Py_TYPE(): 74b. and *note
     Py_SIZE(): 74d. macros to static inline functions.  The *note
     Py_SET_TYPE(): 74c. and *note Py_SET_SIZE(): 74e. functions must
     now be used to set an object type and size.  Patch by Victor
     Stinner.

   - bpo-44263(17): The *note PyType_Ready(): 747. function now raises
     an error if a type is defined with the *note Py_TPFLAGS_HAVE_GC:
     748. flag set but has no traverse function (*note
     PyTypeObject.tp_traverse: 749.).  Patch by Victor Stinner.

   - bpo-43795(18): The undocumented function ‘Py_FrozenMain()’ is
     removed from the Limited API.

   - bpo-44113(19): Deprecate the following functions to configure the
     Python initialization:

        * ‘PySys_AddWarnOptionUnicode()’

        * ‘PySys_AddWarnOption()’

        * ‘PySys_AddXOption()’

        * ‘PySys_HasWarnOptions()’

        * ‘Py_SetPath()’

        * ‘Py_SetProgramName()’

        * ‘Py_SetPythonHome()’

        * ‘Py_SetStandardStreamEncoding()’

        * ‘_Py_SetProgramFullPath()’

     Use the new *note PyConfig: 380. API of the *note Python
     Initialization Configuration: 381. instead ( PEP 587(20)).

   - bpo-44094(21): Remove ‘PyErr_SetFromErrnoWithUnicodeFilename()’,
     ‘PyErr_SetFromWindowsErrWithUnicodeFilename()’, and
     ‘PyErr_SetExcFromWindowsErrWithUnicodeFilename()’.  They are not
     documented and have been deprecated since Python 3.3.

   - bpo-43795(22): *note PyCodec_Unregister(): 864. is now properly
     exported as a function in the Windows Stable ABI DLL.

   - bpo-44029(23): Remove deprecated ‘Py_UNICODE’ APIs:
     ‘PyUnicode_Encode’, ‘PyUnicode_EncodeUTF7’, ‘PyUnicode_EncodeUTF8’,
     ‘PyUnicode_EncodeUTF16’, ‘PyUnicode_EncodeUTF32’,
     ‘PyUnicode_EncodeLatin1’, ‘PyUnicode_EncodeMBCS’,
     ‘PyUnicode_EncodeDecimal’, ‘PyUnicode_EncodeRawUnicodeEscape’,
     ‘PyUnicode_EncodeCharmap’, ‘PyUnicode_EncodeUnicodeEscape’,
     ‘PyUnicode_TransformDecimalToASCII’, ‘PyUnicode_TranslateCharmap’,
     ‘PyUnicodeEncodeError_Create’, ‘PyUnicodeTranslateError_Create’.
     See PEP 393(24) and PEP 624(25) for reference.

   - bpo-42035(26): Add a new *note PyType_GetName(): 71d. function to
     get type's short name.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41710

   (2) https://bugs.python.org/issue?@action=redirect&bpo=44687

   (3) https://bugs.python.org/issue?@action=redirect&bpo=45116

   (4) https://bugs.python.org/issue?@action=redirect&bpo=45094

   (5) https://bugs.python.org/issue?@action=redirect&bpo=45061

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42035

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41103

   (8) https://bugs.python.org/issue?@action=redirect&bpo=44751

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42747

   (10) https://bugs.python.org/issue?@action=redirect&bpo=44530

   (11) https://bugs.python.org/issue?@action=redirect&bpo=44441

   (12) https://bugs.python.org/issue?@action=redirect&bpo=39947

   (13) https://bugs.python.org/issue?@action=redirect&bpo=40939

   (14) https://bugs.python.org/issue?@action=redirect&bpo=43795

   (15) https://bugs.python.org/issue?@action=redirect&bpo=44378

   (16) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (17) https://bugs.python.org/issue?@action=redirect&bpo=44263

   (18) https://bugs.python.org/issue?@action=redirect&bpo=43795

   (19) https://bugs.python.org/issue?@action=redirect&bpo=44113

   (20) https://peps.python.org/pep-0587/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=44094

   (22) https://bugs.python.org/issue?@action=redirect&bpo=43795

   (23) https://bugs.python.org/issue?@action=redirect&bpo=44029

   (24) https://peps.python.org/pep-0393/

   (25) https://peps.python.org/pep-0624/

   (26) https://bugs.python.org/issue?@action=redirect&bpo=42035


File: python.info,  Node: Python 3 10 0 beta 1,  Next: Python 3 10 0 alpha 7,  Prev: Python 3 11 0 alpha 1,  Up: 変更履歴

1.23.32 Python 3.10.0 beta 1
----------------------------

'Release date: 2021-05-03'

* Menu:

* Security: Security<18>.
* Core and Builtins: Core and Builtins<32>.
* Library: Library<31>.
* Documentation: Documentation<26>.
* Tests: Tests<29>.
* Build: Build<31>.
* Windows: Windows<28>.
* macOS: macOS<23>.
* IDLE: IDLE<20>.
* C API: C API<30>.


File: python.info,  Node: Security<18>,  Next: Core and Builtins<32>,  Up: Python 3 10 0 beta 1

1.23.32.1 Security
..................

   - bpo-43434(1): Creating *note sqlite3.Connection: 226. objects now
     also produces ‘sqlite3.connect’ and ‘sqlite3.connect/handle’ *note
     auditing events: 1825.  Previously these events were only produced
     by *note sqlite3.connect(): 288. calls.  Patch by Erlend E.
     Aasland.

   - bpo-43998(2): The *note ssl: bb. module sets more secure cipher
     suites defaults.  Ciphers without forward secrecy and with SHA-1
     MAC are disabled by default.  Security level 2 prohibits weak RSA,
     DH, and ECC keys with less than 112 bits of security.  *note
     SSLContext: 274. defaults to minimum protocol version TLS 1.2.
     Settings are based on Hynek Schlawack's research.

   - bpo-43882(3): The presence of newline or tab characters in parts of
     a URL could allow some forms of attacks.

     Following the controlling specification for URLs defined by WHATWG
     *note urllib.parse(): f3. now removes ASCII newlines and tabs from
     URLs, preventing such attacks.

   - bpo-43472(4): Ensures interpreter-level audit hooks receive the
     ‘cpython.PyInterpreterState_New’ event when called through the
     ‘_xxsubinterpreters’ module.

   - bpo-43362(5): Fix invalid free in _sha3 module.  The issue was
     introduced in 3.10.0a1.  Python 3.9 and earlier are not affected.

   - bpo-43762(6): Add audit events for ‘sqlite3.connect/handle()’,
     *note sqlite3.Connection.enable_load_extension(): 809, and *note
     sqlite3.Connection.load_extension(): 484.  Patch by Erlend E.
     Aasland.

   - bpo-43756(7): Add new audit event ‘glob.glob/2’ to incorporate the
     new 'root_dir' and 'dir_fd' arguments added to *note glob.glob():
     27f. and *note glob.iglob(): 7d2.

   - bpo-36384(8): *note ipaddress: 74. module no longer accepts any
     leading zeros in IPv4 address strings.  Leading zeros are ambiguous
     and interpreted as octal notation by some libraries.  For example
     the legacy function *note socket.inet_aton(): 92f. treats leading
     zeros as octal notation.  glibc implementation of modern *note
     inet_pton(): 930. does not accept any leading zeros.  For a while
     the *note ipaddress: 74. module used to accept ambiguous leading
     zeros.

   - bpo-43075(9): Fix Regular Expression Denial of Service (ReDoS)
     vulnerability in *note urllib.request.AbstractBasicAuthHandler:
     1826.  The ReDoS-vulnerable regex has quadratic worst-case
     complexity and it allows cause a denial of service when identifying
     crafted invalid RFCs.  This ReDoS issue is on the client side and
     needs remote attackers to control the HTTP server.

   - bpo-42800(10): Audit hooks are now fired for frame.f_code,
     traceback.tb_frame, and generator code/frame attribute access.

   - bpo-37363(11): Add audit events to the *note http.client: 65.
     module.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43434

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43998

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43882

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43472

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43362

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43762

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43756

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36384

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43075

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42800

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37363


File: python.info,  Node: Core and Builtins<32>,  Next: Library<31>,  Prev: Security<18>,  Up: Python 3 10 0 beta 1

1.23.32.2 Core and Builtins
...........................

   - bpo-43977(1): Prevent classes being both a sequence and a mapping
     when pattern matching.

   - bpo-43977(2): Use *note tp_flags: 1828. on the class object to
     determine if the subject is a sequence or mapping when pattern
     matching.  Avoids the need to import *note collections.abc: 17.
     when pattern matching.

   - bpo-43892(3): Restore proper validation of complex literal value
     patterns when parsing ‘match’ blocks.

   - bpo-43933(4): Set frame.f_lineno to the line number of the 'with'
     kweyword when executing the call to ‘__exit__’.

   - bpo-43933(5): If the current position in a frame has no line number
     then set the f_lineno attribute to None, instead of -1, to conform
     to PEP 626.  This should not normally be possible, but might occur
     in some unusual circumstances.

   - bpo-43963(6): Importing the ‘_signal’ module in a subinterpreter
     has no longer side effects.

   - bpo-42739(7): The internal representation of line number tables is
     changed to not use sentinels, and an explicit length parameter is
     added to the out of process API function
     ‘PyLineTable_InitAddressRange’.  This makes the handling of line
     number tables more robust in some circumstances.

   - bpo-43908(8): Make *note re: a7. types immutable.  Patch by Erlend
     E. Aasland.

   - bpo-43908(9): Make the *note array.array: 185. type immutable.
     Patch by Erlend E. Aasland.

   - bpo-43901(10): Change class and module objects to lazy-create empty
     annotations dicts on demand.  The annotations dicts are stored in
     the object's __dict__ for backwards compatibility.

   - bpo-43892(11): Match patterns now use new dedicated AST nodes
     (‘MatchValue’, ‘MatchSingleton’, ‘MatchSequence’, ‘MatchStar’,
     ‘MatchMapping’, ‘MatchClass’) rather than reusing expression AST
     nodes.  ‘MatchAs’ and ‘MatchOr’ are now defined as pattern nodes
     rather than as expression nodes.  Patch by Nick Coghlan.

   - bpo-42725(12): Usage of ‘await’/‘yield’/‘yield from’ and named
     expressions within an annotation is now forbidden when PEP 563 is
     activated.

   - bpo-43754(13): When performing structural pattern matching ( PEP
     634(14)), captured names are now left unbound until the 'entire'
     pattern has matched successfully.

   - bpo-42737(15): Annotations for complex targets (everything beside
     simple names) no longer cause any runtime effects with ‘from
     __future__ import annotations’.

   - bpo-43914(16): *note SyntaxError: 172. exceptions raised by the
     interpreter will highlight the full error range of the expression
     that constitutes the syntax error itself, instead of just where the
     problem is detected.  Patch by Pablo Galindo.

   - bpo-38605(17): Revert making ‘from __future__ import annotations’
     the default.  This follows the Steering Council decision to
     postpone PEP 563 changes to at least Python 3.11.  See the original
     email for more information regarding the decision:
     ‘https://mail.python.org/archives/list/python-dev@python.org/thread/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/’.
     Patch by Pablo Galindo.

   - bpo-43475(18): Hashes of NaN values now depend on object identity.
     Formerly, they always hashed to 0 even though NaN values are not
     equal to one another.  Having the same hash for unequal values
     caused pile-ups in hash tables.

   - bpo-43859(19): Improve the error message for *note
     IndentationError: 773. exceptions.  Patch by Pablo Galindo

   - bpo-41323(20): Constant tuple folding in bytecode optimizer now
     reuses tuple in constant table.

   - bpo-43846(21): Data stack usage is much reduced for large literal
     and call expressions.

   - bpo-38530(22): When printing *note NameError: 40b. raised by the
     interpreter, ‘PyErr_Display()’ will offer suggestions of similar
     variable names in the function that the exception was raised from.
     Patch by Pablo Galindo

   - bpo-43823(23): Improve syntax errors for invalid dictionary
     literals.  Patch by Pablo Galindo.

   - bpo-43822(24): Improve syntax errors in the parser for missing
     commas between expressions.  Patch by Pablo Galindo.

   - bpo-43798(25): *note ast.alias: 1829. nodes now include source
     location metadata attributes e.g.  lineno, col_offset.

   - bpo-43797(26): Improve ‘SyntaxError’ error messages for invalid
     comparisons.  Patch by Pablo Galindo.

   - bpo-43760(27): Move the flag for checking whether tracing is
     enabled to the C stack, from the heap.  Should speed up dispatch in
     the interpreter.

   - bpo-43682(28): Static methods (*note @staticmethod: 3ef.) and class
     methods (*note @classmethod: 14c.) now inherit the method
     attributes (‘__module__’, ‘__name__’, ‘__qualname__’, ‘__doc__’,
     ‘__annotations__’) and have a new ‘__wrapped__’ attribute.  Patch
     by Victor Stinner.

   - bpo-43751(29): Fixed a bug where ‘anext(ait, default)’ would
     erroneously return None.

   - bpo-42128(30): *note __match_args__: 182a. is no longer allowed to
     be a list.

   - bpo-43683(31): Add GEN_START opcode.  Marks start of generator,
     including async, or coroutine and handles sending values to a newly
     created generator or coroutine.

   - bpo-43105(32): Importlib now resolves relative paths when creating
     module spec objects from file locations.

   - bpo-43682(33): Static methods (*note @staticmethod: 3ef.) are now
     callable as regular functions.  Patch by Victor Stinner.

   - bpo-42609(34): Prevented crashes in the AST validator and optimizer
     when compiling some absurdly long expressions like ‘"+0"*1000000’.
     *note RecursionError: d39. is now raised instead.

   - bpo-38530(35): When printing *note AttributeError: 326,
     ‘PyErr_Display()’ will offer suggestions of similar attribute names
     in the object that the exception was raised from.  Patch by Pablo
     Galindo

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43977

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43977

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43892

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43933

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43933

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43963

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42739

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43908

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43908

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43901

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43892

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42725

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43754

   (14) https://peps.python.org/pep-0634/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=42737

   (16) https://bugs.python.org/issue?@action=redirect&bpo=43914

   (17) https://bugs.python.org/issue?@action=redirect&bpo=38605

   (18) https://bugs.python.org/issue?@action=redirect&bpo=43475

   (19) https://bugs.python.org/issue?@action=redirect&bpo=43859

   (20) https://bugs.python.org/issue?@action=redirect&bpo=41323

   (21) https://bugs.python.org/issue?@action=redirect&bpo=43846

   (22) https://bugs.python.org/issue?@action=redirect&bpo=38530

   (23) https://bugs.python.org/issue?@action=redirect&bpo=43823

   (24) https://bugs.python.org/issue?@action=redirect&bpo=43822

   (25) https://bugs.python.org/issue?@action=redirect&bpo=43798

   (26) https://bugs.python.org/issue?@action=redirect&bpo=43797

   (27) https://bugs.python.org/issue?@action=redirect&bpo=43760

   (28) https://bugs.python.org/issue?@action=redirect&bpo=43682

   (29) https://bugs.python.org/issue?@action=redirect&bpo=43751

   (30) https://bugs.python.org/issue?@action=redirect&bpo=42128

   (31) https://bugs.python.org/issue?@action=redirect&bpo=43683

   (32) https://bugs.python.org/issue?@action=redirect&bpo=43105

   (33) https://bugs.python.org/issue?@action=redirect&bpo=43682

   (34) https://bugs.python.org/issue?@action=redirect&bpo=42609

   (35) https://bugs.python.org/issue?@action=redirect&bpo=38530


File: python.info,  Node: Library<31>,  Next: Documentation<26>,  Prev: Core and Builtins<32>,  Up: Python 3 10 0 beta 1

1.23.32.3 Library
.................

   - bpo-44015(1): In @dataclass(), raise a TypeError if KW_ONLY is
     specified more than once.

   - bpo-25478(2): Added a 'total()' method to collections.Counter() to
     compute the sum of the counts.

   - bpo-43733(3): Change *note netrc.netrc: 182c. to use UTF-8 encoding
     before using locale encoding.

   - bpo-43979(4): Removed an unnecessary list comprehension before
     looping from *note urllib.parse.parse_qsl(): 25a.  Patch by
     Christoph Zwerschke and Donghee Na.

   - bpo-43993(5): Update bundled pip to 21.1.1.

   - bpo-43957(6): [Enum] Deprecate ‘TypeError’ when non-member is used
     in a containment check; In 3.12 ‘True’ or ‘False’ will be returned
     instead, and containment will return ‘True’ if the value is either
     a member of that enum or one of its members' value.

   - bpo-42904(7): For backwards compatibility with previous minor
     versions of Python, if *note typing.get_type_hints(): 67d. receives
     no namespace dictionary arguments, *note typing.get_type_hints():
     67d. will search through the global then local namespaces during
     evaluation of stringized type annotations (string forward
     references) inside a class.

   - bpo-43945(8): [Enum] Deprecate non-standard mixin format()
     behavior: in 3.12 the enum member, not the member's value, will be
     used for format() calls.

   - bpo-41139(9): Deprecate undocumented ‘cgi.log()’ API.

   - bpo-43937(10): Fixed the *note turtle: ea. module working with
     non-default root window.

   - bpo-43930(11): Update bundled pip to 21.1 and setuptools to 56.0.0

   - bpo-43907(12): Fix a bug in the pure-Python pickle implementation
     when using protocol 5, where bytearray instances that occur several
     time in the pickled object graph would incorrectly unpickle into
     repeated copies of the bytearray object.

   - bpo-43926(13): In ‘importlib.metadata’, provide a uniform interface
     to ‘Description’, allow for any field to be encoded with multiline
     values, remove continuation lines from multiline values, and add a
     ‘.json’ property for easy access to the PEP 566 JSON-compatible
     form.  Sync with ‘importlib_metadata 4.0’.

   - bpo-43920(14): OpenSSL 3.0.0: *note load_verify_locations(): eb6.
     now returns a consistent error message when cadata contains no
     valid certificate.

   - bpo-43607(15): *note urllib: f1. can now convert Windows paths with
     ‘\\?\’ prefixes into URL paths.

   - bpo-43817(16): Add *note inspect.get_annotations(): 7de, which
     safely computes the annotations defined on an object.  It works
     around the quirks of accessing the annotations from various types
     of objects, and makes very few assumptions about the object passed
     in.  *note inspect.get_annotations(): 7de. can also correctly
     un-stringize stringized annotations.

     *note inspect.signature(): 703, ‘inspect.from_callable()’, and
     ‘inspect.from_function()’ now call *note inspect.get_annotations():
     7de. to retrieve annotations.  This means *note
     inspect.signature(): 703. and ‘inspect.from_callable()’ can now
     un-stringize stringized annotations, too.

   - bpo-43284(17): platform.win32_ver derives the windows version from
     sys.getwindowsversion().platform_version which in turn derives the
     version from kernel32.dll (which can be of a different version than
     Windows itself).  Therefore change the platform.win32_ver to
     determine the version using the platform module's _syscmd_ver
     private function to return an accurate version.

   - bpo-42854(18): The *note ssl: bb. module now uses ‘SSL_read_ex’ and
     ‘SSL_write_ex’ internally.  The functions support reading and
     writing of data larger than 2 GB. Writing zero-length data no
     longer fails with a protocol violation error.

   - bpo-42333(19): Port ‘_ssl’ extension module to multiphase
     initialization.

   - bpo-43880(20): *note ssl: bb. now raises DeprecationWarning for
     OP_NO_SSL/TLS* options, old TLS versions, old protocols, and other
     features that have been deprecated since Python 3.6, 3.7, or
     OpenSSL 1.1.0.

   - bpo-41559(21): PEP 612(22) is now implemented purely in Python;
     builtin ‘types.GenericAlias’ objects no longer include
     ‘typing.ParamSpec’ in ‘__parameters__’ (with the exception of
     ‘collections.abc.Callable’'s ‘GenericAlias’).  This means
     previously invalid uses of ‘ParamSpec’ (such as ‘list[P]’) which
     worked in earlier versions of Python 3.10 alpha, will now raise
     ‘TypeError’ during substitution.

   - bpo-43867(23): The *note multiprocessing: 86. ‘Server’ class now
     explicitly catches *note SystemExit: d0e. and closes the client
     connection in this case.  It happens when the
     ‘Server.serve_client()’ method reaches the end of file (EOF).

   - bpo-40443(24): Remove unused imports: pyclbr no longer uses copy,
     and typing no longer uses ast.  Patch by Victor Stinner.

   - bpo-43820(25): Remove an unneeded copy of the namespace passed to
     dataclasses.make_dataclass().

   - bpo-43787(26): Add ‘__iter__()’ method to *note bz2.BZ2File: 832,
     *note gzip.GzipFile: 3f3, and *note lzma.LZMAFile: fd7.  It makes
     iterating them about 2x faster.  Patch by Inada Naoki.

   - bpo-43680(27): Deprecate io.OpenWrapper and _pyio.OpenWrapper: use
     io.open and _pyio.open instead.  Until Python 3.9, _pyio.open was
     not a static method and builtins.open was set to OpenWrapper to not
     become a bound method when set to a class variable.  _io.open is a
     built-in function whereas _pyio.open is a Python function.  In
     Python 3.10, _pyio.open() is now a static method, and
     builtins.open() is now io.open().

   - bpo-43680(28): The Python ‘_pyio.open()’ function becomes a static
     method to behave as *note io.open(): 4e6. built-in function: don't
     become a bound method when stored as a class variable.  It becomes
     possible since static methods are now callable in Python 3.10.
     Moreover, ‘_pyio.OpenWrapper()’ becomes a simple alias to
     ‘_pyio.open()’.  Patch by Victor Stinner.

   - bpo-41515(29): Fix *note KeyError: 31d. raised in *note
     typing.get_type_hints(): 67d. due to synthetic modules that don't
     appear in ‘sys.modules’.

   - bpo-43776(30): When *note subprocess.Popen: 17e. args are provided
     as a string or as *note pathlib.Path: 20a, the Popen instance repr
     now shows the right thing.

   - bpo-42248(31): [Enum] ensure exceptions raised in ‘_missing__’ are
     released

   - bpo-43744(32): fix issue with enum member name matching the start
     of a private variable name

   - bpo-43772(33): Fixed the return value of ‘TypeVar.__ror__’.  Patch
     by Jelle Zijlstra.

   - bpo-43764(34): Add match_args parameter to @dataclass decorator to
     allow suppression of __match_args__ generation.

   - bpo-43799(35): OpenSSL 3.0.0: define ‘OPENSSL_API_COMPAT’ 1.1.1 to
     suppress deprecation warnings.  Python requires OpenSSL 1.1.1 APIs.

   - bpo-43478(36): Mocks can no longer be used as the specs for other
     Mocks.  As a result, an already-mocked object cannot have an
     attribute mocked using ‘autospec=True’ or be the subject of a
     ‘create_autospec(...)’ call.  This can uncover bugs in tests since
     these Mock-derived Mocks will always pass certain tests (e.g.
     *note isinstance(): 40e.) and builtin assert functions (e.g.
     assert_called_once_with) will unconditionally pass.

   - bpo-43794(37): Add *note ssl.OP_IGNORE_UNEXPECTED_EOF: 802.
     constants (OpenSSL 3.0.0)

   - bpo-43785(38): Improve ‘bz2.BZ2File’ performance by removing the
     RLock from BZ2File.  This makes BZ2File thread unsafe in the face
     of multiple simultaneous readers or writers, just like its
     equivalent classes in *note gzip: 5d. and *note lzma: 7e. have
     always been.  Patch by Inada Naoki.

   - bpo-43789(39): OpenSSL 3.0.0: Don't call the password callback
     function a second time when first call has signaled an error
     condition.

   - bpo-43788(40): The header files for *note ssl: bb. error codes are
     now OpenSSL version-specific.  Exceptions will now show correct
     reason and library codes.  The ‘make_ssl_data.py’ script has been
     rewritten to use OpenSSL's text file with error codes.

   - bpo-43766(41): Implement PEP 647(42) in the *note typing: ed.
     module by adding ‘TypeGuard’.

   - bpo-25264(43): *note os.path.realpath(): 206. now accepts a
     'strict' keyword-only argument.  When set to ‘True’, *note OSError:
     3f0. is raised if a path doesn't exist or a symlink loop is
     encountered.

   - bpo-43780(44): In ‘importlib.metadata’, incorporate changes from
     importlib_metadata 3.10: Add mtime-based caching during
     distribution discovery.  Flagged use of dict result from
     ‘entry_points()’ as deprecated.

   - The ‘P.args’ and ‘P.kwargs’ attributes of *note typing.ParamSpec:
     144. are now instances of the new classes *note
     typing.ParamSpecArgs: 791. and *note typing.ParamSpecKwargs: 792,
     which enables a more useful ‘repr()’.  Patch by Jelle Zijlstra.

   - bpo-43731(45): Add an ‘encoding’ parameter ‘logging.fileConfig()’.

   - bpo-43712(46): Add ‘encoding’ and ‘errors’ parameters to *note
     fileinput.input(): 7ca. and *note fileinput.FileInput: 702.

   - bpo-38659(47): A ‘simple_enum’ decorator is added to the ‘enum’
     module to convert a normal class into an Enum.  ‘test_simple_enum’
     added to test simple enums against a corresponding normal Enum.
     Standard library modules updated to use ‘simple_enum’.

   - bpo-43764(48): Fix an issue where *note __match_args__: 182a.
     generation could fail for some *note dataclasses: 27.

   - bpo-43752(49): Fix *note sqlite3: ba. regression for zero-sized
     blobs with converters, where ‘b""’ was returned instead of ‘None’.
     The regression was introduced by PR 24723.  Patch by Erlend E.
     Aasland.

   - bpo-43655(50): *note tkinter: d9. dialog windows are now recognized
     as dialogs by window managers on macOS and X Window.

   - bpo-43723(51): The following ‘threading’ methods are now deprecated
     and should be replaced:

        - ‘currentThread’ => *note threading.current_thread(): 2e1.

        - ‘activeCount’ => *note threading.active_count(): 2e2.

        - ‘Condition.notifyAll’ => *note
          threading.Condition.notify_all(): 2db.

        - ‘Event.isSet’ => *note threading.Event.is_set(): 2dc.

        - ‘Thread.setName’ => *note threading.Thread.name: 2e0.

        - ‘thread.getName’ => *note threading.Thread.name: 2e0.

        - ‘Thread.isDaemon’ => *note threading.Thread.daemon: 2de.

        - ‘Thread.setDaemon’ => *note threading.Thread.daemon: 2de.

     Patch by Jelle Zijlstra.

   - bpo-2135(52): Deprecate find_module() and find_loader()
     implementations in importlib and zipimport.

   - bpo-43534(53): *note turtle.textinput(): 182d. and *note
     turtle.numinput(): 182e. create now a transient window working on
     behalf of the canvas window.

   - bpo-43532(54): Add the ability to specify keyword-only fields to
     dataclasses.  These fields will become keyword-only arguments to
     the generated __init__.

   - bpo-43522(55): Fix problem with *note hostname_checks_common_name:
     b4b.  OpenSSL does not copy hostflags from 'struct SSL_CTX' to
     'struct SSL'.

   - bpo-8978(56): Improve error message for *note tarfile.open(): e40.
     when *note lzma: 7e. / *note bz2: f. are unavailable.  Patch by
     Anthony Sottile.

   - bpo-42967(57): Allow *note bytes: 1a4. ‘separator’ argument in
     ‘urllib.parse.parse_qs’ and ‘urllib.parse.parse_qsl’ when parsing
     *note str: 418. query strings.  Previously, this raised a
     ‘TypeError’.

   - bpo-43296(58): Improve *note sqlite3: ba. error handling:
     ‘sqlite3_value_blob()’ errors that set ‘SQLITE_NOMEM’ now raise
     *note MemoryError: 1627.  Patch by Erlend E. Aasland.

   - bpo-43312(59): New functions *note
     sysconfig.get_preferred_scheme(): 65c. and *note
     sysconfig.get_default_scheme(): 178e. are added to query a platform
     for its preferred "user", "home", and "prefix" (default) scheme
     names.

   - bpo-43265(60): Improve *note sqlite3.Connection.backup(): b48.
     error handling.  The error message for non-existent target database
     names is now ‘unknown database <database name>’ instead of ‘SQL
     logic error’.  Patch by Erlend E. Aasland.

   - bpo-41282(61): Install schemes in ‘distutils.command.install’ are
     now loaded from *note sysconfig: c5.

   - bpo-41282(62): ‘distutils.sysconfig’ has been merged to *note
     sysconfig: c5.

   - bpo-43176(63): Fixed processing of a dataclass that inherits from a
     frozen dataclass with no fields.  It is now correctly detected as
     an error.

   - bpo-43080(64): *note pprint: 9c. now has support for *note
     dataclasses.dataclass: 1ad.  Patch by Lewis Gaul.

   - bpo-39950(65): Add ‘pathlib.Path.hardlink_to()’ method that
     supersedes ‘link_to()’.  The new method has the same argument order
     as ‘symlink_to()’.

   - bpo-42904(66): *note typing.get_type_hints(): 67d. now checks the
     local namespace of a class when evaluating PEP 563(67) annotations
     inside said class.

   - bpo-42269(68): Add ‘slots’ parameter to ‘dataclasses.dataclass’
     decorator to automatically generate ‘__slots__’ for class.  Patch
     provided by Yurii Karabas.

   - bpo-39529(69): Deprecated use of *note asyncio.get_event_loop():
     2a2. without running event loop.  Emit deprecation warning for
     *note asyncio: 8. functions which implicitly create a *note Future:
     b9b. or *note Task: 4a5. objects if there is no running event loop
     and no explicit 'loop' argument is passed: *note ensure_future():
     c44, *note wrap_future(): 182f, *note gather(): 5c8, *note
     shield(): a3e, *note as_completed(): 18f. and constructors of *note
     Future: b9b, *note Task: 4a5, *note StreamReader: 1830,
     ‘StreamReaderProtocol’.

   - bpo-18369(70): Certificate and PrivateKey classes were added to the
     ssl module.  Certificates and keys can now be loaded from memory
     buffer, too.

   - bpo-41486(71): Use a new output buffer management code for *note
     bz2: f. / *note lzma: 7e. / *note zlib: 119. modules, and add
     ‘.readall()’ function to ‘_compression.DecompressReader’ class.
     These bring some performance improvements.  Patch by Ma Lin.

   - bpo-31870(72): The *note ssl.get_server_certificate(): 807.
     function now has a 'timeout' parameter.

   - bpo-41735(73): Fix thread locks in zlib module may go wrong in rare
     case.  Patch by Ma Lin.

   - bpo-36470(74): Fix dataclasses with ‘InitVar’s and *note replace():
     165e.  Patch by Claudiu Popa.

   - bpo-40849(75): Expose X509_V_FLAG_PARTIAL_CHAIN ssl flag

   - bpo-35114(76): *note ssl.RAND_status(): 1831. now returns a boolean
     value (as documented) instead of ‘1’ or ‘0’.

   - bpo-39906(77): *note pathlib.Path.stat(): 7ee. and *note chmod():
     7ef. now accept a 'follow_symlinks' keyword-only argument for
     consistency with corresponding functions in the *note os: 91.
     module.

   - bpo-39899(78): *note os.path.expanduser(): 9e2. now refuses to
     guess Windows home directories if the basename of current user's
     home directory does not match their username.

     *note pathlib.Path.expanduser(): e0f. and *note home(): e10. now
     consistently raise *note RuntimeError: 17a. exception when a home
     directory cannot be resolved.  Previously a *note KeyError: 31d.
     exception could be raised on Windows when the ‘"USERNAME"’
     environment variable was unset.

   - bpo-36076(79): Added SNI support to *note
     ssl.get_server_certificate(): 807.

   - bpo-38490(80): Covariance, Pearson's correlation, and simple linear
     regression functionality was added to statistics module.  Patch by
     Tymoteusz Wołodźko.

   - bpo-33731(81): Provide a locale.localize() function, which converts
     a normalized number string into a locale format.

   - bpo-32745(82): Fix a regression in the handling of ctypes' *note
     ctypes.c_wchar_p: 164d. type: embedded null characters would cause
     a *note ValueError: 1e3. to be raised.  Patch by Zackery Spytz.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=44015

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25478

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43733

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43979

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43993

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43957

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42904

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43945

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41139

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43937

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43930

   (12) https://bugs.python.org/issue?@action=redirect&bpo=43907

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43926

   (14) https://bugs.python.org/issue?@action=redirect&bpo=43920

   (15) https://bugs.python.org/issue?@action=redirect&bpo=43607

   (16) https://bugs.python.org/issue?@action=redirect&bpo=43817

   (17) https://bugs.python.org/issue?@action=redirect&bpo=43284

   (18) https://bugs.python.org/issue?@action=redirect&bpo=42854

   (19) https://bugs.python.org/issue?@action=redirect&bpo=42333

   (20) https://bugs.python.org/issue?@action=redirect&bpo=43880

   (21) https://bugs.python.org/issue?@action=redirect&bpo=41559

   (22) https://peps.python.org/pep-0612/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=43867

   (24) https://bugs.python.org/issue?@action=redirect&bpo=40443

   (25) https://bugs.python.org/issue?@action=redirect&bpo=43820

   (26) https://bugs.python.org/issue?@action=redirect&bpo=43787

   (27) https://bugs.python.org/issue?@action=redirect&bpo=43680

   (28) https://bugs.python.org/issue?@action=redirect&bpo=43680

   (29) https://bugs.python.org/issue?@action=redirect&bpo=41515

   (30) https://bugs.python.org/issue?@action=redirect&bpo=43776

   (31) https://bugs.python.org/issue?@action=redirect&bpo=42248

   (32) https://bugs.python.org/issue?@action=redirect&bpo=43744

   (33) https://bugs.python.org/issue?@action=redirect&bpo=43772

   (34) https://bugs.python.org/issue?@action=redirect&bpo=43764

   (35) https://bugs.python.org/issue?@action=redirect&bpo=43799

   (36) https://bugs.python.org/issue?@action=redirect&bpo=43478

   (37) https://bugs.python.org/issue?@action=redirect&bpo=43794

   (38) https://bugs.python.org/issue?@action=redirect&bpo=43785

   (39) https://bugs.python.org/issue?@action=redirect&bpo=43789

   (40) https://bugs.python.org/issue?@action=redirect&bpo=43788

   (41) https://bugs.python.org/issue?@action=redirect&bpo=43766

   (42) https://peps.python.org/pep-0647/

   (43) https://bugs.python.org/issue?@action=redirect&bpo=25264

   (44) https://bugs.python.org/issue?@action=redirect&bpo=43780

   (45) https://bugs.python.org/issue?@action=redirect&bpo=43731

   (46) https://bugs.python.org/issue?@action=redirect&bpo=43712

   (47) https://bugs.python.org/issue?@action=redirect&bpo=38659

   (48) https://bugs.python.org/issue?@action=redirect&bpo=43764

   (49) https://bugs.python.org/issue?@action=redirect&bpo=43752

   (50) https://bugs.python.org/issue?@action=redirect&bpo=43655

   (51) https://bugs.python.org/issue?@action=redirect&bpo=43723

   (52) https://bugs.python.org/issue?@action=redirect&bpo=2135

   (53) https://bugs.python.org/issue?@action=redirect&bpo=43534

   (54) https://bugs.python.org/issue?@action=redirect&bpo=43532

   (55) https://bugs.python.org/issue?@action=redirect&bpo=43522

   (56) https://bugs.python.org/issue?@action=redirect&bpo=8978

   (57) https://bugs.python.org/issue?@action=redirect&bpo=42967

   (58) https://bugs.python.org/issue?@action=redirect&bpo=43296

   (59) https://bugs.python.org/issue?@action=redirect&bpo=43312

   (60) https://bugs.python.org/issue?@action=redirect&bpo=43265

   (61) https://bugs.python.org/issue?@action=redirect&bpo=41282

   (62) https://bugs.python.org/issue?@action=redirect&bpo=41282

   (63) https://bugs.python.org/issue?@action=redirect&bpo=43176

   (64) https://bugs.python.org/issue?@action=redirect&bpo=43080

   (65) https://bugs.python.org/issue?@action=redirect&bpo=39950

   (66) https://bugs.python.org/issue?@action=redirect&bpo=42904

   (67) https://peps.python.org/pep-0563/

   (68) https://bugs.python.org/issue?@action=redirect&bpo=42269

   (69) https://bugs.python.org/issue?@action=redirect&bpo=39529

   (70) https://bugs.python.org/issue?@action=redirect&bpo=18369

   (71) https://bugs.python.org/issue?@action=redirect&bpo=41486

   (72) https://bugs.python.org/issue?@action=redirect&bpo=31870

   (73) https://bugs.python.org/issue?@action=redirect&bpo=41735

   (74) https://bugs.python.org/issue?@action=redirect&bpo=36470

   (75) https://bugs.python.org/issue?@action=redirect&bpo=40849

   (76) https://bugs.python.org/issue?@action=redirect&bpo=35114

   (77) https://bugs.python.org/issue?@action=redirect&bpo=39906

   (78) https://bugs.python.org/issue?@action=redirect&bpo=39899

   (79) https://bugs.python.org/issue?@action=redirect&bpo=36076

   (80) https://bugs.python.org/issue?@action=redirect&bpo=38490

   (81) https://bugs.python.org/issue?@action=redirect&bpo=33731

   (82) https://bugs.python.org/issue?@action=redirect&bpo=32745


File: python.info,  Node: Documentation<26>,  Next: Tests<29>,  Prev: Library<31>,  Up: Python 3 10 0 beta 1

1.23.32.4 Documentation
.......................

   - bpo-43987(1): Add "Annotations Best Practices" document as a new
     HOWTO.

   - bpo-43977(2): Document the new *note Py_TPFLAGS_MAPPING: 180e. and
     *note Py_TPFLAGS_SEQUENCE: 180f. type flags.

   - bpo-43959(3): The documentation on the PyContextVar C-API was
     clarified.

   - bpo-43938(4): Update dataclasses documentation to express that
     FrozenInstanceError is derived from AttributeError.

   - bpo-43778(5): Fix the Sphinx glossary_search extension: create the
     _static/ sub-directory if it doesn't exist.

   - bpo-43755(6): Update documentation to reflect that unparenthesized
     lambda expressions can no longer be the expression part in an ‘if’
     clause in comprehensions and generator expressions since Python
     3.9.

   - bpo-43739(7): Fixing the example code in
     Doc/extending/extending.rst to declare and initialize the pmodule
     variable to be of the right type.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43987

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43977

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43959

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43938

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43778

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43755

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43739


File: python.info,  Node: Tests<29>,  Next: Build<31>,  Prev: Documentation<26>,  Up: Python 3 10 0 beta 1

1.23.32.5 Tests
...............

   - bpo-43961(1): Fix test_logging.test_namer_rotator_inheritance() on
     Windows: use *note os.replace(): 10c3. rather than *note
     os.rename(): 10c2.  Patch by Victor Stinner.

   - bpo-43842(2): Fix a race condition in the SMTP test of
     test_logging.  Don't close a file descriptor (socket) from a
     different thread while asyncore.loop() is polling the file
     descriptor.  Patch by Victor Stinner.

   - bpo-43843(3): ‘test.libregrtest’ now marks a test as ENV_CHANGED
     (altered the execution environment) if a thread raises an exception
     but does not catch it.  It sets a hook on *note
     threading.excepthook(): 816.  Use ‘--fail-env-changed’ option to
     mark the test as failed.  Patch by Victor Stinner.

   - bpo-43811(4): Tests multiple OpenSSL versions on GitHub Actions.
     Use ccache to speed up testing.

   - bpo-43791(5): OpenSSL 3.0.0: Disable testing of legacy protocols
     TLS 1.0 and 1.1.  Tests are failing with
     TLSV1_ALERT_INTERNAL_ERROR.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43961

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43842

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43843

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43811

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43791


File: python.info,  Node: Build<31>,  Next: Windows<28>,  Prev: Tests<29>,  Up: Python 3 10 0 beta 1

1.23.32.6 Build
...............

   - bpo-43567(1): Improved generated code refresh
     (AST/tokens/opcodes/keywords) on Windows.

   - bpo-43669(2): Implement PEP 644(3).  Python now requires OpenSSL
     1.1.1 or newer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43567

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43669

   (3) https://peps.python.org/pep-0644/


File: python.info,  Node: Windows<28>,  Next: macOS<23>,  Prev: Build<31>,  Up: Python 3 10 0 beta 1

1.23.32.7 Windows
.................

   - bpo-35306(1): Adds additional arguments to *note os.startfile():
     1836. function.

   - bpo-43538(2): Avoid raising errors from *note
     pathlib.Path.exists(): 9e4. when passed an invalid filename.

   - bpo-38822(3): Fixed *note os.stat(): 46d. failing on inaccessible
     directories with a trailing slash, rather than falling back to the
     parent directory's metadata.  This implicitly affected *note
     os.path.exists(): 9dc. and *note os.path.isdir(): 9de.

   - bpo-26227(4): Fixed decoding of host names in *note
     socket.gethostbyaddr(): 1837. and *note socket.gethostbyname_ex():
     1838.

   - bpo-40432(5): Updated pegen regeneration script on Windows to find
     and use Python 3.8 or higher.  Prior to this, pegen regeneration
     already required 3.8 or higher, but the script may have used lower
     versions of Python.

   - bpo-43745(6): Actually updates Windows release to OpenSSL 1.1.1k.
     Earlier releases were mislabelled and actually included 1.1.1i
     again.

   - bpo-43652(7): Update Tcl and Tk to 8.6.11 in Windows installer.

   - bpo-43492(8): Upgrade Windows installer to use SQLite 3.35.5.

   - bpo-30555(9): Fix ‘WindowsConsoleIO’ errors in the presence of fd
     redirection.  Patch by Segev Finer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35306

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43538

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38822

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26227

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40432

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43745

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43652

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43492

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30555


File: python.info,  Node: macOS<23>,  Next: IDLE<20>,  Prev: Windows<28>,  Up: Python 3 10 0 beta 1

1.23.32.8 macOS
...............

   - bpo-42119(1): Fix check for macOS SDK paths when building Python.
     Narrow search to match contents of SDKs, namely only files in
     ‘/System/Library’, ‘/System/IOSSupport’, and ‘/usr’ other than
     ‘/usr/local’.  Previously, anything under ‘/System’ was assumed to
     be in an SDK which causes problems with the new file system layout
     in 10.15+ where user file systems may appear to be mounted under
     ‘/System’.  Paths in ‘/Library’ were also incorrectly treated as
     SDK locations.

   - bpo-43568(2): Drop support for MACOSX_DEPLOYMENT_TARGET < 10.3

   - bpo-44009(3): Provide "python3.x-intel64" executable to allow
     reliably forcing macOS universal2 framework builds to run under
     Rosetta 2 Intel-64 emulation on Apple Silicon Macs.  This can be
     useful for testing or when universal2 wheels are not yet available.

   - bpo-43851(4): Build SQLite with ‘SQLITE_OMIT_AUTOINIT’ on macOS.
     Patch by Erlend E. Aasland.

   - bpo-43492(5): Update macOS installer to use SQLite 3.35.4.

   - bpo-42235(6): ‘Mac/BuildScript/build-installer.py’ will now use
     "-enable-optimizations" and ‘--with-lto’ when building on macOS
     10.15 or later.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42119

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43568

   (3) https://bugs.python.org/issue?@action=redirect&bpo=44009

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43851

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43492

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42235


File: python.info,  Node: IDLE<20>,  Next: C API<30>,  Prev: macOS<23>,  Up: Python 3 10 0 beta 1

1.23.32.9 IDLE
..............

   - bpo-37903(1): Add mouse actions to the shell sidebar.  Left click
     and optional drag selects one or more lines, as with the editor
     line number sidebar.  Right click after selecting raises a context
     menu with 'copy with prompts'.  This zips together prompts from the
     sidebar with lines from the selected text.

   - bpo-43981(2): Fix reference leak in test_sidebar and test_squeezer.
     Patches by Terry Jan Reedy and Pablo Galindo

   - bpo-37892(3): Indent IDLE Shell input with spaces instead of tabs

   - bpo-43655(4): IDLE dialog windows are now recognized as dialogs by
     window managers on macOS and X Window.

   - bpo-37903(5): IDLE's shell now shows prompts in a separate
     side-bar.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37903

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43981

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37892

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43655

   (5) https://bugs.python.org/issue?@action=redirect&bpo=37903


File: python.info,  Node: C API<30>,  Prev: IDLE<20>,  Up: Python 3 10 0 beta 1

1.23.32.10 C API
................

   - bpo-43916(1): Add a new *note Py_TPFLAGS_DISALLOW_INSTANTIATION:
     54e. type flag to disallow creating type instances.  Patch by
     Victor Stinner.

   - bpo-43774(2): Remove the now unused ‘PYMALLOC_DEBUG’ macro.  Debug
     hooks on memory allocators are now installed by default if Python
     is built in debug mode (if ‘Py_DEBUG’ macro is defined).  Moreover,
     they can now be used on Python build in release mode (ex: using
     ‘PYTHONMALLOC=debug’ environment variable).

   - bpo-43962(3): _PyInterpreterState_IDIncref() now calls
     _PyInterpreterState_IDInitref() and always increments id_refcount.
     Previously, calling _xxsubinterpreters.get_current() could create
     an id_refcount inconsistency when a
     _xxsubinterpreters.InterpreterID object was deallocated.  Patch by
     Victor Stinner.

   - bpo-28254(4): Add new C-API functions to control the state of the
     garbage collector: *note PyGC_Enable(): 871, *note PyGC_Disable():
     872, *note PyGC_IsEnabled(): 873, corresponding to the functions in
     the *note gc: 56. module.

   - bpo-43908(5): Introduce *note Py_TPFLAGS_IMMUTABLETYPE: 39c. flag
     for immutable type objects, and modify *note PyType_Ready(): 747.
     to set it for static types.  Patch by Erlend E. Aasland.

   - bpo-43795(6): *note PyMem_Calloc(): e76. is now available in the
     limited C API (‘Py_LIMITED_API’).

   - bpo-43868(7): *note PyOS_ReadlineFunctionPointer(): 552. is no
     longer exported by limited C API headers and by ‘python3.dll’ on
     Windows.  Like any function that takes ‘FILE*’, it is not part of
     the stable ABI.

   - bpo-43795(8): Stable ABI and limited API definitions are generated
     from a central manifest ( PEP 652(9)).

   - bpo-43753(10): Add the *note Py_Is(x, y): 86d. function to test if
     the 'x' object is the 'y' object, the same as ‘x is y’ in Python.
     Add also the *note Py_IsNone(): 86e, *note Py_IsTrue(): 86f, *note
     Py_IsFalse(): 870. functions to test if an object is, respectively,
     the ‘None’ singleton, the ‘True’ singleton or the ‘False’
     singleton.  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43916

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43774

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43962

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28254

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43908

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43795

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43868

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43795

   (9) https://peps.python.org/pep-0652/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43753


File: python.info,  Node: Python 3 10 0 alpha 7,  Next: Python 3 10 0 alpha 6,  Prev: Python 3 10 0 beta 1,  Up: 変更履歴

1.23.33 Python 3.10.0 alpha 7
-----------------------------

'Release date: 2021-04-05'

* Menu:

* Security: Security<19>.
* Core and Builtins: Core and Builtins<33>.
* Library: Library<32>.
* Documentation: Documentation<27>.
* Tests: Tests<30>.
* Build: Build<32>.
* Windows: Windows<29>.
* IDLE: IDLE<21>.
* C API: C API<31>.


File: python.info,  Node: Security<19>,  Next: Core and Builtins<33>,  Up: Python 3 10 0 alpha 7

1.23.33.1 Security
..................

   - bpo-42988(1): CVE 2021-3426(2): Remove the ‘getfile’ feature of the
     *note pydoc: a3. module which could be abused to read arbitrary
     files on the disk (directory traversal vulnerability).  Moreover,
     even source code of Python modules can contain sensitive data like
     passwords.  Vulnerability reported by David Schwörer.

   - bpo-43285(3): *note ftplib: 54. no longer trusts the IP address
     value returned from the server in response to the PASV command by
     default.  This prevents a malicious FTP server from using the
     response to probe IPv4 address and port combinations on the client
     network.

     Code that requires the former vulnerable behavior may set a
     ‘trust_server_pasv_ipv4_address’ attribute on their *note
     ftplib.FTP: 8c8. instances to ‘True’ to re-enable it.

   - bpo-43439(4): Add audit hooks for *note gc.get_objects(): 7ce,
     *note gc.get_referrers(): 7cf. and *note gc.get_referents(): 7d0.
     Patch by Pablo Galindo.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42988

   (2) https://www.cve.org/CVERecord?id=CVE-2021-3426

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43285

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43439


File: python.info,  Node: Core and Builtins<33>,  Next: Library<32>,  Prev: Security<19>,  Up: Python 3 10 0 alpha 7

1.23.33.2 Core and Builtins
...........................

   - bpo-27129(1): Update CPython bytecode magic number.

   - bpo-43672(2): Raise ImportWarning when calling find_loader().

   - bpo-43660(3): Fix crash that happens when replacing ‘sys.stderr’
     with a callable that can remove the object while an exception is
     being printed.  Patch by Pablo Galindo.

   - bpo-27129(4): The bytecode interpreter uses instruction, rather
     byte, offsets internally.  This reduces the number of EXTENDED_ARG
     instructions needed and streamlines instruction dispatch a bit.

   - bpo-40645(5): Fix reference leak in the ‘_hashopenssl’ extension.
     Patch by Pablo Galindo.

   - bpo-42134(6): Calls to find_module() by the import system now raise
     ImportWarning.

   - bpo-41064(7): Improve the syntax error for invalid usage of double
     starred elements ('**') in f-strings.  Patch by Pablo Galindo.

   - bpo-43575(8): Speed up calls to ‘map()’ by using the PEP 590(9)
     ‘vectorcall’ calling convention.  Patch by Donghee Na.

   - bpo-42137(10): The import system now prefers using ‘__spec__’ for
     ‘ModuleType.__repr__’ over ‘module_repr()’.

   - bpo-43452(11): Added micro-optimizations to ‘_PyType_Lookup()’ to
     improve cache lookup performance in the common case of cache hits.

   - bpo-43555(12): Report the column offset for *note SyntaxError: 172.
     for invalid line continuation characters.  Patch by Pablo Galindo.

   - bpo-43517(13): Fix misdetection of circular imports when using
     ‘from pkg.mod import attr’, which caused false positives in
     non-trivial multi-threaded code.

   - bpo-43497(14): Emit SyntaxWarnings for assertions with tuple
     constants, this is a regression introduced in python3.7

   - bpo-39316(15): Tracing now has correct line numbers for attribute
     accesses when the attribute is on a different line from the object.
     Improves debugging and profiling for multi-line method chains.

   - bpo-35883(16): Python no longer fails at startup with a fatal error
     if a command line argument contains an invalid Unicode character.
     The *note Py_DecodeLocale(): b95. function now escapes byte
     sequences which would be decoded as Unicode characters outside the
     [U+0000; U+10ffff] range.

   - bpo-43410(17): Fix a bug that was causing the parser to crash when
     emitting syntax errors when reading input from stdin.  Patch by
     Pablo Galindo

   - bpo-43406(18): Fix a possible race condition where
     ‘PyErr_CheckSignals’ tries to execute a non-Python signal handler.

   - bpo-42128(19): Add ‘__match_args__’ to *note struct sequence
     objects: 118f.  Patch by Pablo Galindo.

   - bpo-43390(20): CPython now sets the ‘SA_ONSTACK’ flag in
     ‘PyOS_setsig’ for the VM's default signal handlers.  This is
     friendlier to other in-process code that an extension module or
     embedding use could pull in (such as Golang's cgo) where tiny
     thread stacks are the norm and ‘sigaltstack()’ has been used to
     provide for signal handlers.  This is a no-op change for the vast
     majority of processes that don't use sigaltstack.

   - bpo-43287(21): Speed up calls to ‘filter()’ by using the PEP
     590(22) ‘vectorcall’ calling convention.  Patch by Donghee Na.

   - bpo-37448(23): Add a radix tree based memory map to track in-use
     obmalloc arenas.  Use to replace the old implementation of
     address_in_range().  The radix tree approach makes it easy to
     increase pool sizes beyond the OS page size.  Boosting the pool and
     arena size allows obmalloc to handle a significantly higher
     percentage of requests from its ultra-fast paths.

     It also has the advantage of eliminating the memory unsanitary
     behavior of the previous address_in_range().  The old
     address_in_range() was marked with the annotations
     _Py_NO_SANITIZE_ADDRESS, _Py_NO_SANITIZE_THREAD, and
     _Py_NO_SANITIZE_MEMORY. Those annotations are no longer needed.

     To disable the radix tree map, set a preprocessor flag as follows:
     ‘-DWITH_PYMALLOC_RADIX_TREE=0’.

     Co-authored-by: Tim Peters <<tim.peters@gmail.com>>

   - bpo-29988(24): Only handle asynchronous exceptions and requests to
     drop the GIL when returning from a call or on the back edges of
     loops.  Makes sure that *note __exit__(): 12ce. is always called in
     with statements, even for interrupts.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27129

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43672

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43660

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27129

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40645

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42134

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41064

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43575

   (9) https://peps.python.org/pep-0590/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42137

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43452

   (12) https://bugs.python.org/issue?@action=redirect&bpo=43555

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43517

   (14) https://bugs.python.org/issue?@action=redirect&bpo=43497

   (15) https://bugs.python.org/issue?@action=redirect&bpo=39316

   (16) https://bugs.python.org/issue?@action=redirect&bpo=35883

   (17) https://bugs.python.org/issue?@action=redirect&bpo=43410

   (18) https://bugs.python.org/issue?@action=redirect&bpo=43406

   (19) https://bugs.python.org/issue?@action=redirect&bpo=42128

   (20) https://bugs.python.org/issue?@action=redirect&bpo=43390

   (21) https://bugs.python.org/issue?@action=redirect&bpo=43287

   (22) https://peps.python.org/pep-0590/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=37448

   (24) https://bugs.python.org/issue?@action=redirect&bpo=29988


File: python.info,  Node: Library<32>,  Next: Documentation<27>,  Prev: Core and Builtins<33>,  Up: Python 3 10 0 alpha 7

1.23.33.3 Library
.................

   - bpo-43720(1): Document various stdlib deprecations in imp, pkgutil,
     and importlib.util for removal in Python 3.12.

   - bpo-43433(2): *note xmlrpc.client.ServerProxy: a25. no longer
     ignores query and fragment in the URL of the server.

   - bpo-31956(3): The *note index(): 7ab. method of *note array.array:
     185. now has optional 'start' and 'stop' parameters.

   - bpo-40066(4): Enum: adjust ‘repr()’ to show only enum and member
     name (not value, nor angle brackets) and ‘str()’ to show only
     member name.  Update and improve documentation to match.

   - bpo-42136(5): Deprecate all module_repr() methods found in
     importlib as their use is being phased out by Python 3.12.

   - bpo-35930(6): Raising an exception raised in a "future" instance
     will create reference cycles.

   - bpo-41369(7): Finish updating the vendored libmpdec to version
     2.5.1.  Patch by Stefan Krah.

   - bpo-43422(8): Revert the _decimal C API which was added in
     bpo-41324(9).

   - bpo-43577(10): Fix deadlock when using *note ssl.SSLContext: 274.
     debug callback with *note ssl.SSLContext.sni_callback(): 1840.

   - bpo-43571(11): It's now possible to create MPTCP sockets with
     IPPROTO_MPTCP

   - bpo-43542(12): ‘image/heic’ and ‘image/heif’ were added to *note
     mimetypes: 82.

   - bpo-40645(13): The *note hmac: 60. module now uses OpenSSL's HMAC
     implementation when digestmod argument is a hash name or builtin
     hash function.

   - bpo-43510(14): Implement PEP 597(15): Add ‘EncodingWarning’
     warning, ‘-X warn_default_encoding’ option, *note
     PYTHONWARNDEFAULTENCODING: 787. environment variable and
     ‘encoding="locale"’ argument value.

   - bpo-43521(16): ‘ast.unparse’ can now render NaNs and empty sets.

   - bpo-42914(17): *note pprint.pprint(): 7f3. gains a new boolean
     ‘underscore_numbers’ optional argument to emit integers with
     thousands separated by an underscore character for improved
     readability (for example ‘1_000_000’ instead of ‘1000000’).

   - bpo-41361(18): *note rotate(): 1841. calls are now slightly faster
     due to faster argument parsing.

   - bpo-43423(19): ‘subprocess.communicate()’ no longer raises an
     IndexError when there is an empty stdout or stderr IO buffer during
     a timeout on Windows.

   - bpo-27820(20): Fixed long-standing bug of smtplib.SMTP where doing
     AUTH LOGIN with initial_response_ok=False will fail.

     The cause is that SMTP.auth_login _always_ returns a password if
     provided with a challenge string, thus non-compliant with the
     standard for AUTH LOGIN.

     Also fixes bug with the test for smtpd.

   - bpo-43445(21): Add frozen modules to *note sys.stdlib_module_names:
     80c.  For example, add ‘"_frozen_importlib"’ and
     ‘"_frozen_importlib_external"’ names.

   - bpo-43245(22): Add keyword arguments support to
     ‘ChainMap.new_child()’.

   - bpo-29982(23): Add optional parameter 'ignore_cleanup_errors' to
     *note tempfile.TemporaryDirectory(): 1205. and allow multiple
     ‘cleanup()’ attempts.  Contributed by C.A.M. Gerlach.

   - bpo-43428(24): Include changes from importlib_metadata 3.7(25):

     Performance enhancements to distribution discovery.

     ‘entry_points’ only returns unique distributions.

     Introduces new ‘EntryPoints’ object for containing a set of entry
     points with convenience methods for selecting entry points by group
     or name.  ‘entry_points’ now returns this object if selection
     parameters are supplied but continues to return a dict object for
     compatibility.  Users are encouraged to rely on the selection
     interface.  The dict object result is likely to be deprecated in
     the future.

     Added packages_distributions function to return a mapping of
     packages to the distributions that provide them.

   - bpo-43332(26): Improves the networking efficiency of *note
     http.client: 65. when using a proxy via ‘set_tunnel()’.  Fewer
     small send calls are made during connection setup.

   - bpo-43420(27): Improve performance of *note fractions.Fraction:
     1c8. arithmetics for large components.  Contributed by Sergey B.
     Kirpichev.

   - bpo-43356(28): Allow passing a signal number to
     ‘_thread.interrupt_main()’.

   - bpo-43399(29): Fix ‘ElementTree.extend’ not working on iterators
     when using the Python implementation

   - bpo-43369(30): Improve *note sqlite3: ba. error handling: If
     ‘sqlite3_column_text()’ and ‘sqlite3_column_blob()’ set
     ‘SQLITE_NOMEM’, *note MemoryError: 1627. is now raised.  Patch by
     Erlend E. Aasland.

   - bpo-43368(31): Fix a regression introduced in PR 24562, where an
     empty bytestring was fetched as ‘None’ instead of ‘b''’ in *note
     sqlite3: ba.  Patch by Mariusz Felisiak.

   - bpo-41282(32): Fixed stacklevel of ‘DeprecationWarning’ emitted
     from ‘import distutils’.

   - bpo-42129(33): ‘importlib.resources’ now honors namespace packages,
     merging resources from each location in the namespace as introduced
     in ‘importlib_resources’ 3.2 and including incidental changes
     through 5.0.3.

   - bpo-43295(34): *note datetime.datetime.strptime(): 156e. now raises
     ‘ValueError’ instead of ‘IndexError’ when matching ‘'z'’ with the
     ‘%z’ format specifier.

   - bpo-43125(35): Return empty string if base64mime.body_encode
     receive empty bytes

   - bpo-43084(36): *note curses.window.enclose(): 1842. returns now
     ‘True’ or ‘False’ (as was documented) instead of ‘1’ or ‘0’.

   - bpo-42994(37): Add MIME types for opus, AAC, 3gpp and 3gpp2

   - bpo-14678(38): Add an invalidate_caches() method to the
     zipimport.zipimporter class to support
     importlib.invalidate_caches().  Patch by Desmond Cheong.

   - bpo-42782(39): Fail fast in *note shutil.move(): a2a. to avoid
     creating destination directories on failure.

   - bpo-40066(40): Enum's ‘repr()’ and ‘str()’ have changed: ‘repr()’
     is now 'EnumClass.MemberName' and ‘str()’ is 'MemberName'.
     Additionally, stdlib Enum's whose contents are available as module
     attributes, such as ‘RegexFlag.IGNORECASE’, have their ‘repr()’ as
     'module.name', e.g.  ‘re.IGNORECASE’.

   - bpo-26053(41): Fixed bug where the *note pdb: 94. interactive run
     command echoed the args from the shell command line, even if those
     have been overridden at the pdb prompt.

   - bpo-24160(42): Fixed bug where breakpoints did not persist across
     multiple debugger sessions in *note pdb: 94.'s interactive mode.

   - bpo-40701(43): When the *note tempfile.tempdir: 1843. global
     variable is set to a value of type bytes, it is now handled
     consistently.  Previously exceptions could be raised from some
     tempfile APIs when the directory did not already exist in this
     situation.  Also ensures that the *note tempfile.gettempdir():
     1844. and *note tempfile.gettempdirb(): 1845. functions 'always'
     return ‘str’ and ‘bytes’ respectively.

   - bpo-39342(44): Expose ‘X509_V_FLAG_ALLOW_PROXY_CERTS’ as *note
     VERIFY_ALLOW_PROXY_CERTS: 1846. to allow proxy certificate
     validation as explained in
     ‘https://docs.openssl.org/1.1.1/man7/proxy-certificates/’.

   - bpo-31861(45): Add builtins.aiter and builtins.anext.  Patch by
     Joshua Bronson (@jab), Daniel Pope (@lordmauve), and Justin Wang
     (@justin39).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43720

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43433

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31956

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40066

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42136

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35930

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41369

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43422

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41324

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43577

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43571

   (12) https://bugs.python.org/issue?@action=redirect&bpo=43542

   (13) https://bugs.python.org/issue?@action=redirect&bpo=40645

   (14) https://bugs.python.org/issue?@action=redirect&bpo=43510

   (15) https://peps.python.org/pep-0597/

   (16) https://bugs.python.org/issue?@action=redirect&bpo=43521

   (17) https://bugs.python.org/issue?@action=redirect&bpo=42914

   (18) https://bugs.python.org/issue?@action=redirect&bpo=41361

   (19) https://bugs.python.org/issue?@action=redirect&bpo=43423

   (20) https://bugs.python.org/issue?@action=redirect&bpo=27820

   (21) https://bugs.python.org/issue?@action=redirect&bpo=43445

   (22) https://bugs.python.org/issue?@action=redirect&bpo=43245

   (23) https://bugs.python.org/issue?@action=redirect&bpo=29982

   (24) https://bugs.python.org/issue?@action=redirect&bpo=43428

   (25) 
https://importlib-metadata.readthedocs.io/en/latest/history.html#v3-7-0

   (26) https://bugs.python.org/issue?@action=redirect&bpo=43332

   (27) https://bugs.python.org/issue?@action=redirect&bpo=43420

   (28) https://bugs.python.org/issue?@action=redirect&bpo=43356

   (29) https://bugs.python.org/issue?@action=redirect&bpo=43399

   (30) https://bugs.python.org/issue?@action=redirect&bpo=43369

   (31) https://bugs.python.org/issue?@action=redirect&bpo=43368

   (32) https://bugs.python.org/issue?@action=redirect&bpo=41282

   (33) https://bugs.python.org/issue?@action=redirect&bpo=42129

   (34) https://bugs.python.org/issue?@action=redirect&bpo=43295

   (35) https://bugs.python.org/issue?@action=redirect&bpo=43125

   (36) https://bugs.python.org/issue?@action=redirect&bpo=43084

   (37) https://bugs.python.org/issue?@action=redirect&bpo=42994

   (38) https://bugs.python.org/issue?@action=redirect&bpo=14678

   (39) https://bugs.python.org/issue?@action=redirect&bpo=42782

   (40) https://bugs.python.org/issue?@action=redirect&bpo=40066

   (41) https://bugs.python.org/issue?@action=redirect&bpo=26053

   (42) https://bugs.python.org/issue?@action=redirect&bpo=24160

   (43) https://bugs.python.org/issue?@action=redirect&bpo=40701

   (44) https://bugs.python.org/issue?@action=redirect&bpo=39342

   (45) https://bugs.python.org/issue?@action=redirect&bpo=31861


File: python.info,  Node: Documentation<27>,  Next: Tests<30>,  Prev: Library<32>,  Up: Python 3 10 0 alpha 7

1.23.33.4 Documentation
.......................

   - bpo-43199(1): Answer "Why is there no goto?"  in the Design and
     History FAQ.

   - bpo-43407(2): Clarified that a result from *note time.monotonic():
     234, *note time.perf_counter(): a56, *note time.process_time():
     a57, or *note time.thread_time(): 904. can be compared with the
     result from any following call to the same function - not just the
     next immediate call.

   - bpo-43354(3): Fix type documentation for ‘Fault.faultCode’; the
     type has to be ‘int’ instead of ‘str’.

   - bpo-41933(4): Clarified wording of s * n in the Common Sequence
     Operations

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43199

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43407

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43354

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41933


File: python.info,  Node: Tests<30>,  Next: Build<32>,  Prev: Documentation<27>,  Up: Python 3 10 0 alpha 7

1.23.33.5 Tests
...............

   - bpo-37945(1): Fix test_getsetlocale_issue1813() of test_locale:
     skip the test if ‘setlocale()’ fails.  Patch by Victor Stinner.

   - bpo-41561(2): Add workaround for Ubuntu's custom OpenSSL security
     level policy.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37945

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41561


File: python.info,  Node: Build<32>,  Next: Windows<29>,  Prev: Tests<30>,  Up: Python 3 10 0 alpha 7

1.23.33.6 Build
...............

   - bpo-43179(1): Introduce and correctly use ALIGNOF_X in place of
     SIZEOF_X for alignment-related code in optimized string routines.
     Patch by Jessica Clarke.

   - bpo-43631(2): Update macOS, Windows, and CI to OpenSSL 1.1.1k.

   - bpo-43617(3): Improve configure.ac: Check for presence of
     autoconf-archive package and remove our copies of M4 macros.

   - bpo-43466(4): The ‘configure’ script now supports
     ‘--with-openssl-rpath’ option.

   - bpo-43372(5): Use ‘_freeze_importlib’ to generate code for the
     ‘__hello__’ module.  This approach ensures the code matches the
     interpreter version.  Previously, PYTHON_FOR_REGEN was used to
     generate the code, which might be wrong.  The marshal format for
     code objects has changed with bpo-42246(6), commit 877df851.
     Update the code and the expected code sizes in ctypes
     test_frozentable.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43179

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43631

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43617

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43466

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43372

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42246


File: python.info,  Node: Windows<29>,  Next: IDLE<21>,  Prev: Build<32>,  Up: Python 3 10 0 alpha 7

1.23.33.7 Windows
.................

   - bpo-43440(1): Build *note sqlite3: ba. with the ‘R*Tree’ module
     enabled.  Patch by Erlend E. Aasland.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43440


File: python.info,  Node: IDLE<21>,  Next: C API<31>,  Prev: Windows<29>,  Up: Python 3 10 0 alpha 7

1.23.33.8 IDLE
..............

   - bpo-42225(1): Document that IDLE can fail on Unix either from
     misconfigured IP masquerade rules or failure displaying complex
     colored (non-ascii) characters.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42225


File: python.info,  Node: C API<31>,  Prev: IDLE<21>,  Up: Python 3 10 0 alpha 7

1.23.33.9 C API
...............

   - bpo-43688(1): The limited C API is now supported if Python is built
     in debug mode (if the ‘Py_DEBUG’ macro is defined).  In the limited
     C API, the *note Py_INCREF(): 53a. and *note Py_DECREF(): 53b.
     functions are now implemented as opaque function calls, rather than
     accessing directly the *note PyObject.ob_refcnt: 86c. member, if
     Python is built in debug mode and the ‘Py_LIMITED_API’ macro
     targets Python 3.10 or newer.  It became possible to support the
     limited C API in debug mode because the *note PyObject: 312.
     structure is the same in release and debug mode since Python 3.8
     (see bpo-36465(2)).

     The limited C API is still not supported in the ‘--with-trace-refs’
     special build (‘Py_TRACE_REFS’ macro).

     Patch by Victor Stinner.

   - bpo-43244(3): Remove the ‘pyarena.h’ header file with functions:

        * ‘PyArena_New()’

        * ‘PyArena_Free()’

        * ‘PyArena_Malloc()’

        * ‘PyArena_AddPyObject()’

     These functions were undocumented, excluded from the limited C API,
     and were only used internally by the compiler.  Patch by Victor
     Stinner.

   - bpo-43244(4): Remove the compiler and parser functions using
     ‘struct _mod’ type, because the public AST C API was removed:

        * ‘PyAST_Compile()’

        * ‘PyAST_CompileEx()’

        * ‘PyAST_CompileObject()’

        * ‘PyFuture_FromAST()’

        * ‘PyFuture_FromASTObject()’

        * ‘PyParser_ASTFromFile()’

        * ‘PyParser_ASTFromFileObject()’

        * ‘PyParser_ASTFromFilename()’

        * ‘PyParser_ASTFromString()’

        * ‘PyParser_ASTFromStringObject()’

     These functions were undocumented and excluded from the limited C
     API. Patch by Victor Stinner.

   - bpo-43244(5): Remove ‘ast.h’, ‘asdl.h’, and ‘Python-ast.h’ header
     files.  These functions were undocumented and excluded from the
     limited C API. Most names defined by these header files were not
     prefixed by ‘Py’ and so could create names conflicts.  For example,
     ‘Python-ast.h’ defined a ‘Yield’ macro which was conflict with the
     ‘Yield’ name used by the Windows ‘<winbase.h>’ header.  Use the
     Python *note ast: 7. module instead.  Patch by Victor Stinner.

   - bpo-43541(6): Fix a ‘PyEval_EvalCodeEx()’ regression: fix reference
     counting on builtins.  Patch by Victor Stinner.

   - bpo-43244(7): Remove the ‘symtable.h’ header file and the
     undocumented functions:

        * ‘PyST_GetScope()’

        * ‘PySymtable_Build()’

        * ‘PySymtable_BuildObject()’

        * ‘PySymtable_Free()’

        * ‘Py_SymtableString()’

        * ‘Py_SymtableStringObject()’

     The ‘Py_SymtableString()’ function was part the stable ABI by
     mistake but it could not be used, because the ‘symtable.h’ header
     file was excluded from the limited C API.

     The Python *note symtable: c2. module remains available and is
     unchanged.

     Patch by Victor Stinner.

   - bpo-43244(8): Remove the ‘PyAST_Validate()’ function.  It is no
     longer possible to build a AST object (‘mod_ty’ type) with the
     public C API. The function was already excluded from the limited C
     API ( PEP 384(9)).  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43688

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36465

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43541

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43244

   (9) https://peps.python.org/pep-0384/


File: python.info,  Node: Python 3 10 0 alpha 6,  Next: Python 3 10 0 alpha 5,  Prev: Python 3 10 0 alpha 7,  Up: 変更履歴

1.23.34 Python 3.10.0 alpha 6
-----------------------------

'Release date: 2021-03-01'

* Menu:

* Security: Security<20>.
* Core and Builtins: Core and Builtins<34>.
* Library: Library<33>.
* Documentation: Documentation<28>.
* Tests: Tests<31>.
* Build: Build<33>.
* Windows: Windows<30>.
* macOS: macOS<24>.
* IDLE: IDLE<22>.
* C API: C API<32>.


File: python.info,  Node: Security<20>,  Next: Core and Builtins<34>,  Up: Python 3 10 0 alpha 6

1.23.34.1 Security
..................

   - bpo-42967(1): Fix web cache poisoning vulnerability by defaulting
     the query args separator to ‘&’, and allowing the user to choose a
     custom separator.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42967


File: python.info,  Node: Core and Builtins<34>,  Next: Library<33>,  Prev: Security<20>,  Up: Python 3 10 0 alpha 6

1.23.34.2 Core and Builtins
...........................

   - bpo-43321(1): Fix ‘SystemError’ raised when ‘PyArg_Parse*()’ is
     used with ‘#’ but without ‘PY_SSIZE_T_CLEAN’ defined.

   - bpo-36346(2): ‘PyArg_Parse*()’ functions now emits
     ‘DeprecationWarning’ when ‘u’ or ‘Z’ format is used.  See PEP
     623(3) for detail.

   - bpo-43277(4): Add a new *note PySet_CheckExact(): 86a. function to
     the C-API to check if an object is an instance of *note set: 5a3.
     but not an instance of a subtype.  Patch by Pablo Galindo.

   - bpo-42990(5): The *note types.FunctionType: 850. constructor now
     inherits the current builtins if the 'globals' dictionary has no
     ‘"__builtins__"’ key, rather than using ‘{"None": None}’ as
     builtins: same behavior as *note eval(): 165. and *note exec():
     164. functions.  Defining a function with ‘def function(...): ...’
     in Python is not affected, globals cannot be overridden with this
     syntax: it also inherits the current builtins.  Patch by Victor
     Stinner.

   - bpo-42990(6): Functions have a new ‘__builtins__’ attribute which
     is used to look for builtin symbols when a function is executed,
     instead of looking into ‘__globals__['__builtins__']’.  Patch by
     Mark Shannon and Victor Stinner.

   - bpo-43149(7): Improve the error message in the parser for exception
     groups without parentheses.  Patch by Pablo Galindo.

   - bpo-43121(8): Fixed an incorrect *note SyntaxError: 172. message
     for missing comma in literals.  Patch by Pablo Galindo.

   - bpo-42819(9): *note readline: a8.: Explicitly disable bracketed
     paste in the interactive interpreter, even if it's set in the
     inputrc, is enabled by default (eg GNU Readline 8.1), or a user
     calls ‘readline.read_init_file()’.  The Python REPL has not
     implemented bracketed paste support.  Also, bracketed mode writes
     the ‘"\x1b[?2004h"’ escape sequence into stdout which causes test
     failures in applications that don't support it.  It can still be
     explicitly enabled by calling ‘readline.parse_and_bind("set
     enable-bracketed-paste on")’.  Patch by Dustin Rodrigues.

   - bpo-42808(10): Simple calls to ‘type(object)’ are now faster due to
     the ‘vectorcall’ calling convention.  Patch by Dennis Sweeney.

   - bpo-42217(11): Make the compiler merges same co_code and
     co_linetable objects in a module like already did for co_consts.

   - bpo-41972(12): Substring search functions such as ‘str1 in str2’
     and ‘str2.find(str1)’ now sometimes use the "Two-Way" string
     comparison algorithm to avoid quadratic behavior on long strings.

   - bpo-42128(13): Implement PEP 634(14) (structural pattern matching).
     Patch by Brandt Bucher.

   - bpo-40692(15): In the *note concurrent.futures.ProcessPoolExecutor:
     8bc, validate that ‘multiprocess.synchronize()’ is available on a
     given platform and rely on that check in the *note
     concurrent.futures: 1a. test suite so we can run tests that are
     unrelated to ‘ProcessPoolExecutor’ on those platforms.

   - bpo-38302(16): If *note object.__ipow__(): 79c. returns *note
     NotImplemented: 79d, the operator will correctly fall back to *note
     object.__pow__(): 79e. and *note object.__rpow__(): 79f. as
     expected.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43321

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36346

   (3) https://peps.python.org/pep-0623/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43277

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42990

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42990

   (7) https://bugs.python.org/issue?@action=redirect&bpo=43149

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43121

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42819

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42808

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42217

   (12) https://bugs.python.org/issue?@action=redirect&bpo=41972

   (13) https://bugs.python.org/issue?@action=redirect&bpo=42128

   (14) https://peps.python.org/pep-0634/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=40692

   (16) https://bugs.python.org/issue?@action=redirect&bpo=38302


File: python.info,  Node: Library<33>,  Next: Documentation<28>,  Prev: Core and Builtins<34>,  Up: Python 3 10 0 alpha 6

1.23.34.3 Library
.................

   - bpo-43316(1): The ‘python -m gzip’ command line application now
     properly fails when detecting an unsupported extension.  It exits
     with a non-zero exit code and prints an error message to stderr.

   - bpo-43317(2): Set the chunk size for the ‘gzip’ module main
     function to io.DEFAULT_BUFFER_SIZE. This is slightly faster than
     the 1024 bytes constant that was used previously.

   - bpo-43146(3): Handle None in single-arg versions of *note
     print_exception(): 81a. and *note format_exception(): 818.

   - bpo-43260(4): Fix TextIOWrapper can not flush internal buffer
     forever after very large text is written.

   - bpo-43258(5): Prevent needless allocation of *note sqlite3: ba.
     aggregate function context when no rows match an aggregate query.
     Patch by Erlend E. Aasland.

   - bpo-43251(6): Improve *note sqlite3: ba. error handling:
     ‘sqlite3_column_name()’ failures now result in *note MemoryError:
     1627.  Patch by Erlend E. Aasland.

   - bpo-40956(7): Fix segfault in *note sqlite3.Connection.backup():
     b48. if no argument was provided.  The regression was introduced by
     PR 23838.  Patch by Erlend E. Aasland.

   - bpo-43172(8): The readline module now passes its tests when built
     directly against libedit.  Existing irreconcilable API differences
     remain in *note readline.get_begidx(): 1851. and *note
     readline.get_endidx(): 1852. behavior based on libreadline vs
     libedit use.

   - bpo-43163(9): Fix a bug in *note codeop: 15. that was causing it to
     not ask for more input when multi-line snippets have unclosed
     parentheses.  Patch by Pablo Galindo

   - bpo-43162(10): deprecate unsupported ability to access enum members
     as attributes of other enum members

   - bpo-43146(11): Fix recent regression in None argument handling in
     *note traceback: e7. module functions.

   - bpo-43102(12): The namedtuple __new__ method had its __builtins__
     set to None instead of an actual dictionary.  This created problems
     for introspection tools.

   - bpo-43106(13): Added *note O_EVTONLY: 7e5, *note O_FSYNC: 7e6,
     *note O_SYMLINK: 7e7. and *note O_NOFOLLOW_ANY: 7e8. for macOS.
     Patch by Donghee Na.

   - bpo-42960(14): Adds *note resource.RLIMIT_KQUEUES: 1853. constant
     from FreeBSD to the *note resource: aa. module.

   - bpo-42151(15): Make the pure Python implementation of *note
     xml.etree.ElementTree: 10c. behave the same as the C implementation
     (‘_elementree’) regarding default attribute values (by not setting
     ‘specified_attributes=1’).

   - bpo-29753(16): In ctypes, now packed bitfields are calculated
     properly and the first item of packed bitfields is now shrank
     correctly.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43316

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43317

   (3) https://bugs.python.org/issue?@action=redirect&bpo=43146

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43260

   (5) https://bugs.python.org/issue?@action=redirect&bpo=43258

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43251

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40956

   (8) https://bugs.python.org/issue?@action=redirect&bpo=43172

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43163

   (10) https://bugs.python.org/issue?@action=redirect&bpo=43162

   (11) https://bugs.python.org/issue?@action=redirect&bpo=43146

   (12) https://bugs.python.org/issue?@action=redirect&bpo=43102

   (13) https://bugs.python.org/issue?@action=redirect&bpo=43106

   (14) https://bugs.python.org/issue?@action=redirect&bpo=42960

   (15) https://bugs.python.org/issue?@action=redirect&bpo=42151

   (16) https://bugs.python.org/issue?@action=redirect&bpo=29753


File: python.info,  Node: Documentation<28>,  Next: Tests<31>,  Prev: Library<33>,  Up: Python 3 10 0 alpha 6

1.23.34.4 Documentation
.......................

   - bpo-27646(1): Clarify that 'yield from <expr>' works with any
     iterable, not just iterators.

   - bpo-36346(2): Update some deprecated unicode APIs which are
     documented as "will be removed in 4.0" to "3.12".  See PEP 623(3)
     for detail.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27646

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36346

   (3) https://peps.python.org/pep-0623/


File: python.info,  Node: Tests<31>,  Next: Build<33>,  Prev: Documentation<28>,  Up: Python 3 10 0 alpha 6

1.23.34.5 Tests
...............

   - bpo-43288(1): Fix test_importlib to correctly skip Unicode file
     tests if the filesystem does not support them.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43288


File: python.info,  Node: Build<33>,  Next: Windows<30>,  Prev: Tests<31>,  Up: Python 3 10 0 alpha 6

1.23.34.6 Build
...............

   - bpo-43174(1): Windows build now uses ‘/utf-8’ compiler option.

   - bpo-43103(2): Add a new configure ‘--without-static-libpython’
     option to not build the ‘libpythonMAJOR.MINOR.a’ static library and
     not install the ‘python.o’ object file.

   - bpo-13501(3): The configure script can now use 'libedit' instead of
     'readline' with the command line option ‘--with-readline=editline’.

   - bpo-42603(4): Make configure script use pkg-config to detect the
     location of Tcl/Tk headers and libraries, used to build tkinter.

     On macOS, a Tcl/Tk configuration provided by pkg-config will be
     preferred over Tcl/Tk frameworks installed in
     ‘/{System/,}Library/Frameworks’.  If both exist and the latter is
     preferred, the appropriate ‘--with-tcltk-*’ configuration options
     need to be explicitly set.

   - bpo-39448(5): Add the "regen-frozen" makefile target that
     regenerates the code for the frozen ‘__hello__’ module.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43174

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43103

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13501

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42603

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39448


File: python.info,  Node: Windows<30>,  Next: macOS<24>,  Prev: Build<33>,  Up: Python 3 10 0 alpha 6

1.23.34.7 Windows
.................

   - bpo-43155(1): *note PyCMethod_New(): 1858. is now present in
     ‘python3.lib’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43155


File: python.info,  Node: macOS<24>,  Next: IDLE<22>,  Prev: Windows<30>,  Up: Python 3 10 0 alpha 6

1.23.34.8 macOS
...............

   - bpo-41837(1): Update macOS installer build to use OpenSSL 1.1.1j.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41837


File: python.info,  Node: IDLE<22>,  Next: C API<32>,  Prev: macOS<24>,  Up: Python 3 10 0 alpha 6

1.23.34.9 IDLE
..............

   - bpo-43283(1): Document why printing to IDLE's Shell is often slower
     than printing to a system terminal and that it can be made faster
     by pre-formatting a single string before printing.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43283


File: python.info,  Node: C API<32>,  Prev: IDLE<22>,  Up: Python 3 10 0 alpha 6

1.23.34.10 C API
................

   - bpo-43278(1): Always put compiler and system information on the
     first line of the REPL welcome message.

   - bpo-43270(2): Remove the private ‘_PyErr_OCCURRED()’ macro: use the
     public *note PyErr_Occurred(): 185c. function instead.

   - bpo-35134(3): Move odictobject.h, parser_interface.h,
     picklebufobject.h, pydebug.h, and pyfpe.h into the cpython/
     directory.  They must not be included directly, as they are already
     included by Python.h: *note Include Files: 74f.

   - bpo-35134(4): Move pyarena.h, pyctype.h, and pytime.h into the
     cpython/ directory.  They must not be included directly, as they
     are already included by Python.h: *note Include Files: 74f.

   - bpo-40170(5): ‘PyExceptionClass_Name()’ is now always declared as a
     function, in order to hide implementation details.  The macro
     accessed *note PyTypeObject.tp_name: 185d. directly.  Patch by
     Erlend E. Aasland.

   - bpo-43239(6): The *note PyCFunction_New(): 185e. function is now
     exported in the ABI when compiled with ‘-fvisibility=hidden’.

   - bpo-40170(7): *note PyIter_Check(): 185f. is now always declared as
     a function, in order to hide implementation details.  The macro
     accessed *note PyTypeObject.tp_iternext: 1498. directly.  Patch by
     Erlend E. Aasland.

   - bpo-40170(8): Convert *note PyDescr_IsData(): 1860. macro to a
     function to hide implementation details: The macro accessed *note
     PyTypeObject.tp_descr_set: 1861. directly.  Patch by Erlend E.
     Aasland.

   - bpo-43181(9): Convert *note PyObject_TypeCheck(): 1862. macro to a
     static inline function.  Patch by Erlend E. Aasland.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43278

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43270

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (6) https://bugs.python.org/issue?@action=redirect&bpo=43239

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (9) https://bugs.python.org/issue?@action=redirect&bpo=43181


File: python.info,  Node: Python 3 10 0 alpha 5,  Next: Python 3 10 0 alpha 4,  Prev: Python 3 10 0 alpha 6,  Up: 変更履歴

1.23.35 Python 3.10.0 alpha 5
-----------------------------

'Release date: 2021-02-02'

* Menu:

* Security: Security<21>.
* Core and Builtins: Core and Builtins<35>.
* Library: Library<34>.
* Documentation: Documentation<29>.
* Tests: Tests<32>.
* Build: Build<34>.
* Windows: Windows<31>.
* macOS: macOS<25>.
* IDLE: IDLE<23>.
* C API: C API<33>.


File: python.info,  Node: Security<21>,  Next: Core and Builtins<35>,  Up: Python 3 10 0 alpha 5

1.23.35.1 Security
..................

   - bpo-42938(1): Avoid static buffers when computing the repr of *note
     ctypes.c_double: 1865. and *note ctypes.c_longdouble: 1866. values.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42938


File: python.info,  Node: Core and Builtins<35>,  Next: Library<34>,  Prev: Security<21>,  Up: Python 3 10 0 alpha 5

1.23.35.2 Core and Builtins
...........................

   - bpo-42990(1): Refactor the ‘PyEval_’ family of functions.

        * An new function ‘_PyEval_Vector’ is added to simplify calls to
          Python from C.

        * ‘_PyEval_EvalCodeWithName’ is removed

        * ‘PyEval_EvalCodeEx’ is retained as part of the API, but is not
          used internally

   - bpo-38631(2): Replace *note Py_FatalError(): 951. calls in the
     compiler with regular *note SystemError: 541. exceptions.  Patch by
     Victor Stinner.

   - bpo-42997(3): Improve error message for missing ":" before blocks.
     Patch by Pablo Galindo.

   - bpo-43017(4): Improve error message in the parser when using
     un-parenthesised tuples in comprehensions.  Patch by Pablo Galindo.

   - bpo-42986(5): Fix parser crash when reporting syntax errors in
     f-string with newlines.  Patch by Pablo Galindo.

   - bpo-40176(6): Syntax errors for unterminated string literals now
     point to the start of the string instead of reporting EOF/EOL.

   - bpo-42927(7): The inline cache for ‘LOAD_ATTR’ now also optimizes
     access to attributes defined by ‘__slots__’.  This makes reading
     such attribute up to 30% faster.

   - bpo-42864(8): Improve error messages in the parser when parentheses
     are not closed.  Patch by Pablo Galindo.

   - bpo-42924(9): Fix ‘bytearray’ repetition incorrectly copying data
     from the start of the buffer, even if the data is offset within the
     buffer (e.g.  after reassigning a slice at the start of the
     ‘bytearray’ to a shorter byte string).

   - bpo-42882(10): Fix the ‘_PyUnicode_FromId()’ function
     (_Py_IDENTIFIER(var) API) when *note Py_Initialize(): 87a. / *note
     Py_Finalize(): 1321. is called multiple times: preserve
     ‘_PyRuntime.unicode_ids.next_index’ value.

   - bpo-42827(11): Fix a crash when working out the error line of a
     *note SyntaxError: 172. in some multi-line expressions.

   - bpo-42823(12): frame.f_lineno is correct even if frame.f_trace is
     set to True

   - bpo-37324(13): Remove deprecated aliases to *note
     コレクション抽象基底クラス: 844. from the *note collections: 16.
     module.

   - bpo-41994(14): Fixed possible leak in ‘import’ when ‘sys.modules’
     is not a ‘dict’.

   - bpo-27772(15): In string formatting, preceding the 'width' field by
     ‘'0'’ no longer affects the default alignment for strings.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42990

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38631

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42997

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43017

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42986

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40176

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42927

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42864

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42924

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42882

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42827

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42823

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37324

   (14) https://bugs.python.org/issue?@action=redirect&bpo=41994

   (15) https://bugs.python.org/issue?@action=redirect&bpo=27772


File: python.info,  Node: Library<34>,  Next: Documentation<29>,  Prev: Core and Builtins<35>,  Up: Python 3 10 0 alpha 5

1.23.35.3 Library
.................

   - bpo-43108(1): Fixed a reference leak in the *note curses: 23.
     module.  Patch by Pablo Galindo

   - bpo-43077(2): Update the bundled pip to 21.0.1 and setuptools to
     52.0.0.

   - bpo-41282(3): Deprecate ‘distutils’ in documentation and add
     warning on import.

   - bpo-43014(4): Improve performance of *note tokenize: e4. by 20-30%.
     Patch by Anthony Sottile.

   - bpo-42323(5): Fix *note math.nextafter(): 465. for NaN on AIX.

   - bpo-42955(6): Add *note sys.stdlib_module_names: 80c, containing
     the list of the standard library module names.  Patch by Victor
     Stinner.

   - bpo-42944(7): Fix ‘random.Random.sample’ when ‘counts’ argument is
     not ‘None’.

   - bpo-42934(8): Use *note TracebackException: 23d.'s new ‘compact’
     param in *note TestResult: 113a. to reduce time and memory consumed
     by traceback formatting.

   - bpo-42931(9): Add ‘randbytes()’ to ‘random.__all__’.

   - bpo-38250(10): [Enum] Flags consisting of a single bit are now
     considered canonical, and will be the only flags returned from
     listing and iterating over a Flag class or a Flag member.
     Multi-bit flags are considered aliases; they will be returned from
     lookups and operations that result in their value.  Iteration for
     both Flag and Flag members is in definition order.

   - bpo-42877(11): Added the ‘compact’ parameter to the constructor of
     *note traceback.TracebackException: 23d. to reduce time and memory
     for use cases that only need to call ‘TracebackException.format()’
     and ‘TracebackException.format_exception_only()’.

   - bpo-42923(12): The *note Py_FatalError(): 951. function and the
     *note faulthandler: 4e. module now dump the list of extension
     modules on a fatal error.

   - bpo-42848(13): Removed recursion from *note TracebackException:
     23d. to allow it to handle long exception chains.

   - bpo-42901(14): [Enum] move member creation from ‘EnumMeta.__new__’
     to ‘_proto_member.__set_name__’, allowing members to be created and
     visible in ‘__init_subclass__’.

   - bpo-42780(15): Fix os.set_inheritable() for O_PATH file descriptors
     on Linux.

   - bpo-42866(16): Fix a reference leak in the ‘getcodec()’ function of
     CJK codecs.  Patch by Victor Stinner.

   - bpo-42846(17): Convert the 6 CJK codec extension modules
     (_codecs_cn, _codecs_hk, _codecs_iso2022, _codecs_jp, _codecs_kr
     and _codecs_tw) to the multiphase initialization API ( PEP
     489(18)).  Patch by Victor Stinner.

   - bpo-42851(19): remove __init_subclass__ support for Enum members

   - bpo-42834(20): Make internal caches of the ‘_json’ module
     compatible with subinterpreters.

   - bpo-41748(21): Fix HTMLParser parsing rules for element attributes
     containing commas with spaces.  Patch by Karl Dubost.

   - bpo-40810(22): Require SQLite 3.7.15 or newer.  Patch by Erlend E.
     Aasland.

   - bpo-1635741(23): Convert the _multibytecodec extension module (CJK
     codecs) to multi-phase initialization ( PEP 489(24)).  Patch by
     Erlend E. Aasland.

   - bpo-42802(25): The distutils ‘bdist_wininst’ command deprecated in
     Python 3.8 has been removed.  The distutils ‘bdist_wheel’ command
     is now recommended to distribute binary packages on Windows.

   - bpo-24464(26): The undocumented built-in function
     ‘sqlite3.enable_shared_cache’ is now deprecated, scheduled for
     removal in Python 3.12.  Its use is strongly discouraged by the
     SQLite3 documentation.  Patch by Erlend E. Aasland.

   - bpo-42384(27): Make pdb populate sys.path[0] exactly the same as
     regular python execution.

   - bpo-42383(28): Fix pdb: previously pdb would fail to restart the
     debugging target if it was specified using a relative path and the
     current directory changed.

   - bpo-42005(29): Fix CLI of *note cProfile: 20. and *note profile:
     9d. to catch *note BrokenPipeError: 1030.

   - bpo-41604(30): Don't decrement the reference count of the previous
     user_ptr when set_panel_userptr fails.

   - bpo-41149(31): Allow executing callables that have a boolean value
     of ‘False’ when passed to ‘Threading.thread’ as the target.  Patch
     contributed by Barney Stratford.

   - bpo-38307(32): Add an 'end_lineno' attribute to the Class and
     Function objects that appear in the tree returned by pyclbr
     functions.  This and the existing 'lineno' attribute define the
     extent of class and def statements.  Patch by Aviral Srivastava.

   - bpo-39273(33): The ‘BUTTON5_*’ constants are now exposed in the
     *note curses: 23. module if available.

   - bpo-33289(34): Correct call to *note tkinter.colorchooser: da. to
     return RGB triplet of ints instead of floats.  Patch by Cheryl
     Sabella.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43108

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43077

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41282

   (4) https://bugs.python.org/issue?@action=redirect&bpo=43014

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42323

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42955

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42944

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42934

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42931

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38250

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42877

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42923

   (13) https://bugs.python.org/issue?@action=redirect&bpo=42848

   (14) https://bugs.python.org/issue?@action=redirect&bpo=42901

   (15) https://bugs.python.org/issue?@action=redirect&bpo=42780

   (16) https://bugs.python.org/issue?@action=redirect&bpo=42866

   (17) https://bugs.python.org/issue?@action=redirect&bpo=42846

   (18) https://peps.python.org/pep-0489/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=42851

   (20) https://bugs.python.org/issue?@action=redirect&bpo=42834

   (21) https://bugs.python.org/issue?@action=redirect&bpo=41748

   (22) https://bugs.python.org/issue?@action=redirect&bpo=40810

   (23) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (24) https://peps.python.org/pep-0489/

   (25) https://bugs.python.org/issue?@action=redirect&bpo=42802

   (26) https://bugs.python.org/issue?@action=redirect&bpo=24464

   (27) https://bugs.python.org/issue?@action=redirect&bpo=42384

   (28) https://bugs.python.org/issue?@action=redirect&bpo=42383

   (29) https://bugs.python.org/issue?@action=redirect&bpo=42005

   (30) https://bugs.python.org/issue?@action=redirect&bpo=41604

   (31) https://bugs.python.org/issue?@action=redirect&bpo=41149

   (32) https://bugs.python.org/issue?@action=redirect&bpo=38307

   (33) https://bugs.python.org/issue?@action=redirect&bpo=39273

   (34) https://bugs.python.org/issue?@action=redirect&bpo=33289


File: python.info,  Node: Documentation<29>,  Next: Tests<32>,  Prev: Library<34>,  Up: Python 3 10 0 alpha 5

1.23.35.4 Documentation
.......................

   - bpo-40304(1): Fix doc for type(name, bases, dict).  Patch by Boris
     Verkhovskiy and Éric Araujo.

   - bpo-42811(2): Updated importlib.util.resolve_name() doc to use
     __spec__.parent instead of __package__.  (Thanks Yair Frid.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40304

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42811


File: python.info,  Node: Tests<32>,  Next: Build<34>,  Prev: Documentation<29>,  Up: Python 3 10 0 alpha 5

1.23.35.5 Tests
...............

   - bpo-40823(1): Use ‘unittest.TestLoader().loadTestsFromTestCase()’
     instead of ‘unittest.makeSuite()’ in *note sqlite3: ba. tests.
     Patch by Erlend E. Aasland.

   - bpo-40810(2): In *note sqlite3: ba, fix ‘CheckTraceCallbackContent’
     for SQLite pre 3.7.15.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40823

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40810


File: python.info,  Node: Build<34>,  Next: Windows<31>,  Prev: Tests<32>,  Up: Python 3 10 0 alpha 5

1.23.35.6 Build
...............

   - bpo-43031(1): Pass ‘--timeout=$(TESTTIMEOUT)’ option to the default
     profile task ‘./python -m test --pgo’ command.

   - bpo-36143(2): ‘make regen-all’ now also runs ‘regen-keyword’.
     Patch by Victor Stinner.

   - bpo-42874(3): Removed the grep -q and -E flags in the tzpath
     validation section of the configure script to better accommodate
     users of some platforms (specifically Solaris 10).

   - bpo-31904(4): Add library search path by wr-cc in
     add_cross_compiling_paths() for VxWorks.

   - bpo-42856(5): Add ‘--with-wheel-pkg-dir=PATH’ option to the
     ‘./configure’ script.  If specified, the *note ensurepip: 4b.
     module looks for ‘setuptools’ and ‘pip’ wheel packages in this
     directory: if both are present, these wheel packages are used
     instead of ensurepip bundled wheel packages.

     Some Linux distribution packaging policies recommend against
     bundling dependencies.  For example, Fedora installs wheel packages
     in the ‘/usr/share/python-wheels/’ directory and don't install the
     ‘ensurepip._bundled’ package.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43031

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36143

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42874

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42856


File: python.info,  Node: Windows<31>,  Next: macOS<25>,  Prev: Build<34>,  Up: Python 3 10 0 alpha 5

1.23.35.7 Windows
.................

   - bpo-41837(1): Updated Windows installer to include OpenSSL 1.1.1i

   - bpo-42584(2): Upgrade Windows installer to use SQLite 3.34.0.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41837

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42584


File: python.info,  Node: macOS<25>,  Next: IDLE<23>,  Prev: Windows<31>,  Up: Python 3 10 0 alpha 5

1.23.35.8 macOS
...............

   - bpo-42504(1): Ensure that the value of
     sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET') is always a
     string, even in when the value is parsable as an integer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42504


File: python.info,  Node: IDLE<23>,  Next: C API<33>,  Prev: macOS<25>,  Up: Python 3 10 0 alpha 5

1.23.35.9 IDLE
..............

   - bpo-43008(1): Make IDLE invoke *note sys.excepthook(): 7d6. in
     normal, 2-process mode.  Patch by Ken Hilton.

   - bpo-33065(2): Fix problem debugging user classes with __repr__
     method.

   - bpo-23544(3): Disable Debug=>Stack Viewer when user code is running
     or Debugger is active, to prevent hang or crash.  Patch by Zackery
     Spytz.

   - bpo-32631(4): Finish zzdummy example extension module: make menu
     entries work; add docstrings and tests with 100% coverage.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=43008

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33065

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23544

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32631


File: python.info,  Node: C API<33>,  Prev: IDLE<23>,  Up: Python 3 10 0 alpha 5

1.23.35.10 C API
................

   - bpo-42979(1): When Python is built in debug mode (with C
     assertions), calling a type slot like ‘sq_length’ (‘__len__()’ in
     Python) now fails with a fatal error if the slot succeeded with an
     exception set, or failed with no exception set.  The error message
     contains the slot, the type name, and the current exception (if an
     exception is set).  Patch by Victor Stinner.

   - bpo-43030(2): Fixed a compiler warning in *note
     Py_UNICODE_ISSPACE(): 1870. on platforms with signed ‘wchar_t’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42979

   (2) https://bugs.python.org/issue?@action=redirect&bpo=43030


File: python.info,  Node: Python 3 10 0 alpha 4,  Next: Python 3 10 0 alpha 3,  Prev: Python 3 10 0 alpha 5,  Up: 変更履歴

1.23.36 Python 3.10.0 alpha 4
-----------------------------

'Release date: 2021-01-04'

* Menu:

* Core and Builtins: Core and Builtins<36>.
* Library: Library<35>.
* Documentation: Documentation<30>.
* Tests: Tests<33>.
* Build: Build<35>.
* macOS: macOS<26>.
* Tools/Demos: Tools/Demos<15>.
* C API: C API<34>.


File: python.info,  Node: Core and Builtins<36>,  Next: Library<35>,  Up: Python 3 10 0 alpha 4

1.23.36.1 Core and Builtins
...........................

   - bpo-42814(1): Fix undefined behavior in
     ‘Objects/genericaliasobject.c’.

   - bpo-42806(2): Fix the column offsets for f-strings *note ast: 7.
     nodes surrounded by parentheses and for nodes that spawn multiple
     lines.  Patch by Pablo Galindo.

   - bpo-40631(3): Fix regression where a single parenthesized starred
     expression was a valid assignment target.

   - bpo-27794(4): Improve the error message for failed writes/deletes
     to property objects.  When possible, the attribute name is now
     shown.  Patch provided by Yurii Karabas.

   - bpo-42745(5): Make the type attribute lookup cache per-interpreter.
     Patch by Victor Stinner.

   - bpo-42246(6): Jumps to jumps are not eliminated when it would break
     PEP 626.

   - bpo-42246(7): Make sure that the ‘f_lasti’ and ‘f_lineno’
     attributes of a frame are set correctly when an exception is raised
     or re-raised.  Required for PEP 626.

   - bpo-32381(8): The coding cookie (ex: ‘# coding: latin1’) is now
     ignored in the command passed to the *note -c: 5aa. command line
     option.  Patch by Victor Stinner.

   - bpo-30858(9): Improve error location in expressions that contain
     assignments.  Patch by Pablo Galindo and Lysandros Nikolaou.

   - bpo-42615(10): Remove jump commands made redundant by the deletion
     of unreachable bytecode blocks

   - bpo-42639(11): Make the *note atexit: 9. module state
     per-interpreter.  It is now safe have more than one *note atexit:
     9. module instance.  Patch by Donghee Na and Victor Stinner.

   - bpo-32381(12): Fix encoding name when running a ‘.pyc’ file on
     Windows: *note PyRun_SimpleFileExFlags(): 1873. now uses the
     correct encoding to decode the filename.

   - bpo-42195(13): The ‘__args__’ of the parameterized generics for
     *note typing.Callable: 790. and *note collections.abc.Callable:
     7b5. are now consistent.  The ‘__args__’ for *note
     collections.abc.Callable: 7b5. are now flattened while *note
     typing.Callable: 790.'s have not changed.  To allow this change,
     *note types.GenericAlias: 7b6. can now be subclassed and
     ‘collections.abc.Callable’'s ‘__class_getitem__’ will now return a
     subclass of ‘types.GenericAlias’.  Tests for typing were also
     updated to not subclass things like ‘Callable[..., T]’ as that is
     not a valid base class.  Finally, both ‘Callable’s no longer
     validate their ‘argtypes’, in ‘Callable[[argtypes], resulttype]’ to
     prepare for PEP 612(14).  Patch by Ken Jin.

   - bpo-40137(15): Convert functools module to use *note
     PyType_FromModuleAndSpec(): 51c.

   - bpo-40077(16): Convert *note array: 6. to use heap types, and
     establish module state for these.

   - bpo-42008(17): Fix _random.Random() seeding.

   - bpo-1635741(18): Port the ‘pyexpat’ extension module to multi-phase
     initialization ( PEP 489(19)).

   - bpo-40521(20): Make the Unicode dictionary of interned strings
     compatible with subinterpreters.  Patch by Victor Stinner.

   - bpo-39465(21): Make ‘_PyUnicode_FromId()’ function compatible with
     subinterpreters.  Each interpreter now has an array of identifier
     objects (interned strings decoded from UTF-8).  Patch by Victor
     Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42814

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42806

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40631

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27794

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42745

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42246

   (7) https://bugs.python.org/issue?@action=redirect&bpo=42246

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32381

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30858

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42615

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42639

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32381

   (13) https://bugs.python.org/issue?@action=redirect&bpo=42195

   (14) https://peps.python.org/pep-0612/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=40137

   (16) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (17) https://bugs.python.org/issue?@action=redirect&bpo=42008

   (18) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (19) https://peps.python.org/pep-0489/

   (20) https://bugs.python.org/issue?@action=redirect&bpo=40521

   (21) https://bugs.python.org/issue?@action=redirect&bpo=39465


File: python.info,  Node: Library<35>,  Next: Documentation<30>,  Prev: Core and Builtins<36>,  Up: Python 3 10 0 alpha 4

1.23.36.2 Library
.................

   - bpo-42257(1): Handle empty string in variable executable in
     platform.libc_ver()

   - bpo-42772(2): randrange() now raises a TypeError when step is
     specified without a stop argument.  Formerly, it silently ignored
     the step argument.

   - bpo-42759(3): Fixed equality comparison of ‘tkinter.Variable’ and
     *note tkinter.font.Font: 1875.  Objects which belong to different
     Tcl interpreters are now always different, even if they have the
     same name.

   - bpo-42756(4): Configure LMTP Unix-domain socket to use socket
     global default timeout when a timeout is not explicitly provided.

   - bpo-23328(5): Allow / character in username, password fields on
     _PROXY envars.

   - bpo-42740(6): *note typing.get_args(): 84b. and *note
     typing.get_origin(): a15. now support PEP 604(7) union types and
     PEP 612(8) additions to ‘Callable’.

   - bpo-42655(9): *note subprocess: c1. 'extra_groups' is now correctly
     passed into setgroups() system call.

   - bpo-42727(10): ‘EnumMeta.__prepare__’ now accepts ‘**kwds’ to
     properly support ‘__init_subclass__’

   - bpo-38308(11): Add optional 'weights' to
     'statistics.harmonic_mean()'.

   - bpo-42721(12): When simple query dialogs (*note
     tkinter.simpledialog: e1.), message boxes (*note
     tkinter.messagebox: df.) or color choose dialog (*note
     tkinter.colorchooser: da.) are created without arguments 'master'
     and 'parent', and the default root window is not yet created, and
     ‘NoDefaultRoot()’ was not called, a new temporal hidden root window
     will be created automatically.  It will not be set as the default
     root window and will be destroyed right after closing the dialog
     window.  It will help to use these simple dialog windows in
     programs which do not need other GUI.

   - bpo-25246(13): Optimized *note collections.deque.remove(): 1876.

   - bpo-35728(14): Added a root parameter to *note
     tkinter.font.nametofont(): 1877.

   - bpo-15303(15): *note tkinter: d9. supports now widgets with boolean
     value False.

   - bpo-42681(16): Fixed range checks for color and pair numbers in
     *note curses: 23.

   - bpo-42685(17): Improved placing of simple query windows in Tkinter
     (such as *note tkinter.simpledialog.askinteger(): 1878.).  They are
     now centered at the center of the parent window if it is specified
     and shown, otherwise at the center of the screen.

   - bpo-9694(18): Argparse help no longer uses the confusing phrase,
     "optional arguments".  It uses "options" instead.

   - bpo-1635741(19): Port the ‘_thread’ extension module to the
     multiphase initialization API ( PEP 489(20)) and convert its static
     types to heap types.

   - bpo-37961(21): Fix crash in ‘tracemalloc.Traceback.__repr__()’
     (regressed in Python 3.9).

   - bpo-42630(22): *note tkinter: d9. functions and constructors which
     need a default root window raise now *note RuntimeError: 17a. with
     descriptive message instead of obscure *note AttributeError: 326.
     or *note NameError: 40b. if it is not created yet or cannot be
     created automatically.

   - bpo-42639(23): ‘atexit._run_exitfuncs()’ now logs callback
     exceptions using *note sys.unraisablehook: 1d8, rather than logging
     them directly into *note sys.stderr: 907. and raise the last
     exception.

   - bpo-42644(24): ‘logging.disable’ will now validate the types and
     value of its parameter.  It also now accepts strings representing
     the levels (as does ‘logging.setLevel’) instead of only the
     numerical values.

   - bpo-42639(25): At Python exit, if a callback registered with *note
     atexit.register(): 84a. fails, its exception is now logged.
     Previously, only some exceptions were logged, and the last
     exception was always silently ignored.

   - bpo-36541(26): Fixed lib2to3.pgen2 to be able to parse PEP-570
     positional only argument syntax.

   - bpo-42382(27): In ‘importlib.metadata’: - ‘EntryPoint’ objects now
     expose a ‘.dist’ object referencing the ‘Distribution’ when
     constructed from a ‘Distribution’.  - Add support for package
     discovery under package normalization rules.  - The object returned
     by ‘metadata()’ now has a formally defined protocol called
     ‘PackageMetadata’ with declared support for the ‘.get_all()’
     method.  - Synced with importlib_metadata 3.3.

   - bpo-41877(28): A check is added against misspellings of autospect,
     auto_spec and set_spec being passed as arguments to patch,
     patch.object and create_autospec.

   - bpo-39717(29): [tarfile] update nested exception raising to use
     ‘from None’ or ‘from e’

   - bpo-41877(30): AttributeError for suspected misspellings of
     assertions on mocks are now pointing out that the cause are
     misspelled assertions and also what to do if the misspelling is
     actually an intended attribute name.  The unittest.mock document is
     also updated to reflect the current set of recognised misspellings.

   - bpo-41559(31): Implemented PEP 612(32): added ‘ParamSpec’ and
     ‘Concatenate’ to *note typing: ed.  Patch by Ken Jin.

   - bpo-42385(33): StrEnum: fix _generate_next_value_ to return a str

   - bpo-31904(34): Define THREAD_STACK_SIZE for VxWorks.

   - bpo-34750(35): [Enum] ‘_EnumDict.update()’ is now supported.

   - bpo-42517(36): Enum: private names do not become members / do not
     generate errors - they remain normal attributes

   - bpo-42678(37): ‘Enum’: call ‘__init_subclass__’ after members have
     been added

   - bpo-28964(38): *note ast.literal_eval(): be6. adds line number
     information (if available) in error message for malformed nodes.

   - bpo-42470(39): *note random.sample(): 711. no longer warns on a
     sequence which is also a set.

   - bpo-31904(40): ‘posixpath.expanduser()’ returns the input 'path'
     unchanged if user home directory is None on VxWorks.

   - bpo-42388(41): Fix subprocess.check_output(..., input=None)
     behavior when text=True to be consistent with that of the
     documentation and universal_newlines=True.

   - bpo-34463(42): Fixed discrepancy between *note traceback: e7. and
     the interpreter in formatting of SyntaxError with lineno not set
     (*note traceback: e7. was changed to match interpreter).

   - bpo-42393(43): Raise *note OverflowError: 84e. instead of silent
     truncation in *note socket.ntohs(): 84d. and *note socket.htons():
     84c.  Silent truncation was deprecated in Python 3.7.  Patch by
     Erlend E. Aasland

   - bpo-42222(44): Harmonized *note random.randrange(): 837. argument
     handling to match *note range(): 911.

        * The integer test and conversion in ‘randrange()’ now uses
          *note operator.index(): 1879.

        * Non-integer arguments to ‘randrange()’ are deprecated.

        * The ‘ValueError’ is deprecated in favor of a ‘TypeError’.

        * It now runs a little faster than before.

     (Contributed by Raymond Hettinger and Serhiy Storchaka.)

   - bpo-42163(45): Restore compatibility for ‘uname_result’ around
     deepcopy and _replace.

   - bpo-42090(46): ‘zipfile.Path.joinpath’ now accepts arbitrary
     arguments, same as ‘pathlib.Path.joinpath’.

   - bpo-1635741(47): Port the _csv module to the multi-phase
     initialization API ( PEP 489(48)).

   - bpo-42059(49): *note typing.TypedDict: 148. types created using the
     alternative call-style syntax now correctly respect the ‘total’
     keyword argument when setting their ‘__required_keys__’ and
     ‘__optional_keys__’ class attributes.

   - bpo-41960(50): Add ‘globalns’ and ‘localns’ parameters to the *note
     inspect.signature(): 703. and *note
     inspect.Signature.from_callable(): 705.

   - bpo-41907(51): fix ‘format()’ behavior for ‘IntFlag’

   - bpo-41891(52): Ensure asyncio.wait_for waits for task completion

   - bpo-24792(53): Fixed bug where ‘zipimporter’ sometimes reports an
     incorrect cause of import errors.

   - bpo-31904(54): Fix site and sysconfig modules for VxWorks RTOS
     which has no home directories.

   - bpo-41462(55): Add *note os.set_blocking(): e07. support for
     VxWorks RTOS.

   - bpo-40219(56): Lowered ‘tkinter.ttk.LabeledScale’ dummy widget to
     prevent hiding part of the content label.

   - bpo-37193(57): Fixed memory leak in ‘socketserver.ThreadingMixIn’
     introduced in Python 3.7.

   - bpo-39068(58): Fix initialization race condition in ‘a85encode()’
     and ‘b85encode()’ in *note base64: a.  Patch by Brandon Stansbury.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42257

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42772

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42759

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42756

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23328

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42740

   (7) https://peps.python.org/pep-0604/

   (8) https://peps.python.org/pep-0612/

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42655

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42727

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38308

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42721

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25246

   (14) https://bugs.python.org/issue?@action=redirect&bpo=35728

   (15) https://bugs.python.org/issue?@action=redirect&bpo=15303

   (16) https://bugs.python.org/issue?@action=redirect&bpo=42681

   (17) https://bugs.python.org/issue?@action=redirect&bpo=42685

   (18) https://bugs.python.org/issue?@action=redirect&bpo=9694

   (19) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (20) https://peps.python.org/pep-0489/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=37961

   (22) https://bugs.python.org/issue?@action=redirect&bpo=42630

   (23) https://bugs.python.org/issue?@action=redirect&bpo=42639

   (24) https://bugs.python.org/issue?@action=redirect&bpo=42644

   (25) https://bugs.python.org/issue?@action=redirect&bpo=42639

   (26) https://bugs.python.org/issue?@action=redirect&bpo=36541

   (27) https://bugs.python.org/issue?@action=redirect&bpo=42382

   (28) https://bugs.python.org/issue?@action=redirect&bpo=41877

   (29) https://bugs.python.org/issue?@action=redirect&bpo=39717

   (30) https://bugs.python.org/issue?@action=redirect&bpo=41877

   (31) https://bugs.python.org/issue?@action=redirect&bpo=41559

   (32) https://peps.python.org/pep-0612/

   (33) https://bugs.python.org/issue?@action=redirect&bpo=42385

   (34) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (35) https://bugs.python.org/issue?@action=redirect&bpo=34750

   (36) https://bugs.python.org/issue?@action=redirect&bpo=42517

   (37) https://bugs.python.org/issue?@action=redirect&bpo=42678

   (38) https://bugs.python.org/issue?@action=redirect&bpo=28964

   (39) https://bugs.python.org/issue?@action=redirect&bpo=42470

   (40) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (41) https://bugs.python.org/issue?@action=redirect&bpo=42388

   (42) https://bugs.python.org/issue?@action=redirect&bpo=34463

   (43) https://bugs.python.org/issue?@action=redirect&bpo=42393

   (44) https://bugs.python.org/issue?@action=redirect&bpo=42222

   (45) https://bugs.python.org/issue?@action=redirect&bpo=42163

   (46) https://bugs.python.org/issue?@action=redirect&bpo=42090

   (47) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (48) https://peps.python.org/pep-0489/

   (49) https://bugs.python.org/issue?@action=redirect&bpo=42059

   (50) https://bugs.python.org/issue?@action=redirect&bpo=41960

   (51) https://bugs.python.org/issue?@action=redirect&bpo=41907

   (52) https://bugs.python.org/issue?@action=redirect&bpo=41891

   (53) https://bugs.python.org/issue?@action=redirect&bpo=24792

   (54) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (55) https://bugs.python.org/issue?@action=redirect&bpo=41462

   (56) https://bugs.python.org/issue?@action=redirect&bpo=40219

   (57) https://bugs.python.org/issue?@action=redirect&bpo=37193

   (58) https://bugs.python.org/issue?@action=redirect&bpo=39068


File: python.info,  Node: Documentation<30>,  Next: Tests<33>,  Prev: Library<35>,  Up: Python 3 10 0 alpha 4

1.23.36.3 Documentation
.......................

   - bpo-17140(1): Add documentation for the *note
     multiprocessing.pool.ThreadPool: 187b. class.

   - bpo-34398(2): Prominently feature listings from the glossary in
     documentation search results.  Patch by Ammar Askar.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17140

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34398


File: python.info,  Node: Tests<33>,  Next: Build<35>,  Prev: Documentation<30>,  Up: Python 3 10 0 alpha 4

1.23.36.4 Tests
...............

   - bpo-42794(1): Update test_nntplib to use official group name of
     news.aioe.org for testing.  Patch by Donghee Na.

   - bpo-31904(2): Skip some asyncio tests on VxWorks.

   - bpo-42641(3): Enhance ‘test_select.test_select()’: it now takes 500
     milliseconds rather than 10 seconds.  Use Python rather than a
     shell to make the test more portable.

   - bpo-31904(4): Skip some tests in _test_all_chown_common() on
     VxWorks.

   - bpo-42199(5): Fix bytecode helper assertNotInBytecode.

   - bpo-41443(6): Add more attribute checking in test_posix.py

   - bpo-31904(7): Disable os.popen and impacted tests on VxWorks

   - bpo-41439(8): Port test_ssl and test_uuid to VxWorks RTOS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42794

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42641

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42199

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41443

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41439


File: python.info,  Node: Build<35>,  Next: macOS<26>,  Prev: Tests<33>,  Up: Python 3 10 0 alpha 4

1.23.36.5 Build
...............

   - bpo-42692(1): Fix __builtin_available check on older compilers.
     Patch by Joshua Root.

   - bpo-27640(2): Added ‘--disable-test-modules’ option to the
     ‘configure’ script: don't build nor install test modules.  Patch by
     Xavier de Gaye, Thomas Petazzoni and Peixing Xin.

   - bpo-42604(3): Now all platforms use a value for the "EXT_SUFFIX"
     build variable derived from SOABI (for instance in freeBSD,
     "EXT_SUFFIX" is now ".cpython-310d.so" instead of ".so").
     Previously only Linux, Mac and VxWorks were using a value for
     "EXT_SUFFIX" that included "SOABI".

   - bpo-42598(4): Fix implicit function declarations in configure which
     could have resulted in incorrect configuration checks.  Patch
     contributed by Joshua Root.

   - bpo-31904(5): Enable libpython3.so for VxWorks.

   - bpo-29076(6): Add fish shell support to macOS installer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42692

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27640

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42604

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42598

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29076


File: python.info,  Node: macOS<26>,  Next: Tools/Demos<15>,  Prev: Build<35>,  Up: Python 3 10 0 alpha 4

1.23.36.6 macOS
...............

   - bpo-42361(1): Update macOS installer build to use Tcl/Tk 8.6.11
     (rc2, expected to be final release).

   - bpo-41837(2): Update macOS installer build to use OpenSSL 1.1.1i.

   - bpo-42584(3): Update macOS installer to use SQLite 3.34.0.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42361

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41837

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42584


File: python.info,  Node: Tools/Demos<15>,  Next: C API<34>,  Prev: macOS<26>,  Up: Python 3 10 0 alpha 4

1.23.36.7 Tools/Demos
.....................

   - bpo-42726(1): Fixed Python 3 compatibility issue with
     gdb/libpython.py handling of attribute dictionaries.

   - bpo-42613(2): Fix ‘freeze.py’ tool to use the prope config and
     library directories.  Patch by Victor Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42726

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42613


File: python.info,  Node: C API<34>,  Prev: Tools/Demos<15>,  Up: Python 3 10 0 alpha 4

1.23.36.8 C API
...............

   - bpo-42591(1): Export the ‘Py_FrozenMain()’ function: fix a Python
     3.9.0 regression.  Python 3.9 uses ‘-fvisibility=hidden’ and the
     function was not exported explicitly and so not exported.

   - bpo-32381(2): Remove the private ‘_Py_fopen()’ function which is no
     longer needed.  Use ‘_Py_wfopen()’ or ‘_Py_fopen_obj()’ instead.
     Patch by Victor Stinner.

   - bpo-1635741(3): Port *note resource: aa. extension module to module
     state

   - bpo-42111(4): Update the ‘xxlimited’ module to be a better example
     of how to use the limited C API.

   - bpo-40052(5): Fix an alignment build warning/error in function
     ‘PyVectorcall_Function()’.  Patch by Andreas Schneider, Antoine
     Pitrou and Petr Viktorin.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42591

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32381

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42111

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40052


File: python.info,  Node: Python 3 10 0 alpha 3,  Next: Python 3 10 0 alpha 2,  Prev: Python 3 10 0 alpha 4,  Up: 変更履歴

1.23.37 Python 3.10.0 alpha 3
-----------------------------

'Release date: 2020-12-07'

* Menu:

* Security: Security<22>.
* Core and Builtins: Core and Builtins<37>.
* Library: Library<36>.
* Documentation: Documentation<31>.
* Tests: Tests<34>.
* Build: Build<36>.
* Windows: Windows<32>.
* macOS: macOS<27>.
* IDLE: IDLE<24>.
* Tools/Demos: Tools/Demos<16>.
* C API: C API<35>.


File: python.info,  Node: Security<22>,  Next: Core and Builtins<37>,  Up: Python 3 10 0 alpha 3

1.23.37.1 Security
..................

   - bpo-40791(1): Add ‘volatile’ to the accumulator variable in
     ‘hmac.compare_digest’, making constant-time-defeating optimizations
     less likely.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40791


File: python.info,  Node: Core and Builtins<37>,  Next: Library<36>,  Prev: Security<22>,  Up: Python 3 10 0 alpha 3

1.23.37.2 Core and Builtins
...........................

   - bpo-42576(1): ‘types.GenericAlias’ will now raise a ‘TypeError’
     when attempting to initialize with a keyword argument.  Previously,
     this would cause the interpreter to crash if the interpreter was
     compiled with debug symbols.  This does not affect interpreters
     compiled for release.  Patch by Ken Jin.

   - bpo-42536(2): Several built-in and standard library types now
     ensure that their internal result tuples are always tracked by the
     *note garbage collector: 1884.:

        - *note collections.OrderedDict.items(): 5a5.

        - *note dict.items(): 79a.

        - *note enumerate(): 1424.

        - *note functools.reduce(): 12aa.

        - *note itertools.combinations(): 12e1.

        - *note itertools.combinations_with_replacement(): 1252.

        - *note itertools.permutations(): 1885.

        - *note itertools.product(): 12e2.

        - *note itertools.zip_longest(): 126e.

        - *note zip(): 79b.

     Previously, they could have become untracked by a prior garbage
     collection.  Patch by Brandt Bucher.

   - bpo-42500(3): Improve handling of exceptions near recursion limit.
     Converts a number of Fatal Errors in RecursionErrors.

   - bpo-42246(4): PEP 626: After a return, the f_lineno attribute of a
     frame is always the last line executed.

   - bpo-42435(5): Speed up comparison of bytes objects with non-bytes
     objects when option *note -b: 5ad. is specified.  Speed up
     comparison of bytarray objects with non-buffer object.

   - bpo-1635741(6): Port the ‘_warnings’ extension module to the
     multi-phase initialization API ( PEP 489(7)).  Patch by Victor
     Stinner.

   - bpo-41686(8): On Windows, the ‘SIGINT’ event,
     ‘_PyOS_SigintEvent()’, is now created even if Python is configured
     to not install signal handlers (if *note
     PyConfig.install_signal_handlers: 88c. equals to 0, or
     ‘Py_InitializeEx(0)’).

   - bpo-42381(9): Allow assignment expressions in set literals and set
     comprehensions as per PEP 572.  Patch by Pablo Galindo.

   - bpo-42202(10): Change function parameters annotations internal
     representation to tuple of strings.  Patch provided by Yurii
     Karabas.

   - bpo-42374(11): Fix a regression introduced by the new parser, where
     an unparenthesized walrus operator was not allowed within generator
     expressions.

   - bpo-42316(12): Allow an unparenthesized walrus in subscript
     indexes.

   - bpo-42349(13): Make sure that the compiler front-end produces a
     well-formed control flow graph.  Be more aggressive in the compiler
     back-end, as it is now safe to do so.

   - bpo-42296(14): On Windows, fix a regression in signal handling
     which prevented to interrupt a program using CTRL+C. The signal
     handler can be run in a thread different than the Python thread, in
     which case the test deciding if the thread can handle signals is
     wrong.

   - bpo-42332(15): *note types.GenericAlias: 7b6. objects can now be
     the targets of weakrefs.

   - bpo-42282(16): Optimise constant subexpressions that appear as part
     of named expressions (previously the AST optimiser did not descend
     into named expressions).  Patch by Nick Coghlan.

   - bpo-42266(17): Fixed a bug with the LOAD_ATTR opcode cache that was
     not respecting monkey-patching a class-level attribute to make it a
     descriptor.  Patch by Pablo Galindo.

   - bpo-40077(18): Convert *note queue: a4. to use heap types.

   - bpo-42246(19): Improved accuracy of line tracing events and
     f_lineno attribute of Frame objects.  See PEP 626 for details.

   - bpo-40077(20): Convert *note mmap: 83. to use heap types.

   - bpo-42233(21): Allow ‘GenericAlias’ objects to use *note union type
     expressions: 78d.  This allows expressions like ‘list[int] |
     dict[float, str]’ where previously a ‘TypeError’ would have been
     thrown.  This also fixes union type expressions not de-duplicating
     ‘GenericAlias’ objects.  (Contributed by Ken Jin in bpo-42233(22).)

   - bpo-26131(23): The import system triggers a ‘ImportWarning’ when it
     falls back to using ‘load_module()’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42576

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42536

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42500

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42246

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42435

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (7) https://peps.python.org/pep-0489/

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41686

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42381

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42202

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42374

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42316

   (13) https://bugs.python.org/issue?@action=redirect&bpo=42349

   (14) https://bugs.python.org/issue?@action=redirect&bpo=42296

   (15) https://bugs.python.org/issue?@action=redirect&bpo=42332

   (16) https://bugs.python.org/issue?@action=redirect&bpo=42282

   (17) https://bugs.python.org/issue?@action=redirect&bpo=42266

   (18) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (19) https://bugs.python.org/issue?@action=redirect&bpo=42246

   (20) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (21) https://bugs.python.org/issue?@action=redirect&bpo=42233

   (22) https://bugs.python.org/issue?@action=redirect&bpo=42233

   (23) https://bugs.python.org/issue?@action=redirect&bpo=26131


File: python.info,  Node: Library<36>,  Next: Documentation<31>,  Prev: Core and Builtins<37>,  Up: Python 3 10 0 alpha 3

1.23.37.3 Library
.................

   - bpo-5054(1): CGIHTTPRequestHandler.run_cgi() HTTP_ACCEPT improperly
     parsed.  Replace the special purpose getallmatchingheaders with
     generic get_all method and add relevant tests.

     Original Patch by Martin Panter.  Modified by Senthil Kumaran.

   - bpo-42562(2): Fix issue when dis failed to parse function that has
     no line numbers.  Patch provided by Yurii Karabas.

   - bpo-17735(3): ‘inspect.findsource()’ now raises *note OSError: 3f0.
     instead of *note IndexError: 14de. when ‘co_lineno’ of a code
     object is greater than the file length.  This can happen, for
     example, when a file is edited after it was imported.  PR by Irit
     Katriel.

   - bpo-42116(4): Fix handling of trailing comments by *note
     inspect.getsource(): 1528.

   - bpo-42532(5): Remove unexpected call of ‘__bool__’ when passing a
     ‘spec_arg’ argument to a Mock.

   - bpo-38200(6): Added itertools.pairwise()

   - bpo-41818(7): Fix test_master_read() so that it succeeds on all
     platforms that either raise OSError or return b"" upon reading from
     master.

   - bpo-42487(8): ChainMap.__iter__ no longer calls __getitem__ on
     underlying maps

   - bpo-42482(9): *note TracebackException: 23d. no longer holds a
     reference to the exception's traceback object.  Consequently,
     instances of TracebackException for equivalent but non-equal
     exceptions now compare as equal.

   - bpo-41818(10): Make test_openpty() avoid unexpected success due to
     number of rows and/or number of columns being == 0.

   - bpo-42392(11): Remove loop parameter from ‘asyncio.subprocess’ and
     ‘asyncio.tasks’ functions.  Patch provided by Yurii Karabas.

   - bpo-42392(12): Remove loop parameter from ‘asyncio.open_connection’
     and ‘asyncio.start_server’ functions.  Patch provided by Yurii
     Karabas.

   - bpo-28468(13): Add *note platform.freedesktop_os_release(): 7f1.
     function to parse freedesktop.org ‘os-release’ files.

   - bpo-42299(14): Removed the ‘formatter’ module, which was deprecated
     in Python 3.4.  It is somewhat obsolete, little used, and not
     tested.  It was originally scheduled to be removed in Python 3.6,
     but such removals were delayed until after Python 2.7 EOL. Existing
     users should copy whatever classes they use into their code.  Patch
     by Donghee Na and and Terry J. Reedy.

   - bpo-26131(15): Deprecate zipimport.zipimporter.load_module() in
     favour of exec_module().

   - bpo-41818(16): Updated tests for the pty library.  test_basic() has
     been changed to test_openpty(); this additionally checks if slave
     termios and slave winsize are being set properly by pty.openpty().
     In order to add support for FreeBSD, NetBSD, OpenBSD, and Darwin,
     this also adds test_master_read(), which demonstrates that
     pty.spawn() should not depend on an OSError to exit from its copy
     loop.

   - bpo-42392(17): Remove loop parameter from ‘__init__’ in all
     ‘asyncio.locks’ and ‘asyncio.Queue’ classes.  Patch provided by
     Yurii Karabas.

   - bpo-15450(18): Make *note filecmp.dircmp: f0d. respect subclassing.
     Now the *note filecmp.dircmp.subdirs: 1887. behaves as expected
     when subclassing dircmp.

   - bpo-42413(19): The exception *note socket.timeout: 7ff. is now an
     alias of *note TimeoutError: 800.

   - bpo-31904(20): Support signal module on VxWorks.

   - bpo-42406(21): We fixed an issue in ‘pickle.whichmodule’ in which
     importing ‘multiprocessing’ could change the how pickle identifies
     which module an object belongs to, potentially breaking the
     unpickling of those objects.

   - bpo-42403(22): Simplify the *note importlib: 6b. external bootstrap
     code: ‘importlib._bootstrap_external’ now uses regular imports to
     import builtin modules.  When it is imported, the builtin *note
     __import__(): 8a2. function is already fully working and so can be
     used to import builtin modules like *note sys: c3.  Patch by Victor
     Stinner.

   - bpo-1635741(23): Convert _sre module types to heap types (PEP 384).
     Patch by Erlend E. Aasland.

   - bpo-42375(24): subprocess module update for DragonFlyBSD support.

   - bpo-41713(25): Port the ‘_signal’ extension module to the
     multi-phase initialization API ( PEP 489(26)).  Patch by Victor
     Stinner and Mohamed Koubaa.

   - bpo-37205(27): *note time.time(): 235, *note time.perf_counter():
     a56. and *note time.monotonic(): 234. functions can no longer fail
     with a Python fatal error, instead raise a regular Python exception
     on failure.

   - bpo-42328(28): Fixed *note tkinter.ttk.Style.map(): 1888.  The
     function accepts now the representation of the default state as
     empty sequence (as returned by ‘Style.map()’).  The structure of
     the result is now the same on all platform and does not depend on
     the value of ‘wantobjects’.

   - bpo-42345(29): Fix various issues with ‘typing.Literal’ parameter
     handling (flatten, deduplicate, use type to cache key).  Patch
     provided by Yurii Karabas.

   - bpo-37205(30): *note time.perf_counter(): a56. on Windows and *note
     time.monotonic(): 234. on macOS are now system-wide.  Previously,
     they used an offset computed at startup to reduce the precision
     loss caused by the float type.  Use *note time.perf_counter_ns():
     ab3. and *note time.monotonic_ns(): ab2. added in Python 3.7 to
     avoid this precision loss.

   - bpo-42318(31): Fixed support of non-BMP characters in *note
     tkinter: d9. on macOS.

   - bpo-42350(32): Fix the *note threading.Thread: 91a. class at fork:
     do nothing if the thread is already stopped (ex: fork called at
     Python exit).  Previously, an error was logged in the child
     process.

   - bpo-42333(33): Port _ssl extension module to heap types.

   - bpo-42014(34): The ‘onerror’ callback from ‘shutil.rmtree’ now
     receives correct function when ‘os.open’ fails.

   - bpo-42237(35): Fix ‘os.sendfile()’ on illumos.

   - bpo-42308(36): Add *note threading.__excepthook__: 815. to allow
     retrieving the original value of *note threading.excepthook(): 816.
     in case it is set to a broken or a different value.  Patch by Mario
     Corchero.

   - bpo-42131(37): Implement PEP 451/spec methods on
     zipimport.zipimporter: find_spec(), create_module(), and
     exec_module().

     This also allows for the documented deprecation of find_loader(),
     find_module(), and load_module().

   - bpo-41877(38): Mock objects which are not unsafe will now raise an
     AttributeError if an attribute with the prefix asert, aseert, or
     assrt is accessed, in addition to this already happening for the
     prefixes assert or assret.

   - bpo-42264(39): ‘sqlite3.OptimizedUnicode’ has been undocumented and
     obsolete since Python 3.3, when it was made an alias to *note str:
     418.  It is now deprecated, scheduled for removal in Python 3.12.

   - bpo-42251(40): Added *note threading.gettrace(): 811. and *note
     threading.getprofile(): 812. to retrieve the functions set by *note
     threading.settrace(): 813. and *note threading.setprofile(): 814.
     respectively.  Patch by Mario Corchero.

   - bpo-42249(41): Fixed writing binary Plist files larger than 4 GiB.

   - bpo-42236(42): On Unix, the *note os.device_encoding(): 17fc.
     function now returns ‘'UTF-8'’ rather than the device encoding if
     the *note Python UTF-8 Mode: 622. is enabled.

   - bpo-41754(43): webbrowser: Ignore 'NotADirectoryError' when calling
     ‘xdg-settings’.

   - bpo-42183(44): Fix a stack overflow error for asyncio Task or
     Future repr().

     The overflow occurs under some circumstances when a Task or Future
     recursively returns itself.

   - bpo-42140(45): Improve asyncio.wait function to create the futures
     set just one time.

   - bpo-42133(46): Update various modules in the stdlib to fall back on
     ‘__spec__.loader’ when ‘__loader__’ isn't defined on a module.

   - bpo-26131(47): The ‘load_module()’ methods found in ‘importlib’ now
     trigger a ‘DeprecationWarning’.

   - bpo-39825(48): Windows: Change
     ‘sysconfig.get_config_var('EXT_SUFFIX')’ to the expected full
     ‘platform_tag.extension’ format.  Previously it was hard-coded to
     ‘.pyd’, now it is compatible with ‘distutils.sysconfig’ and will
     result in something like ‘.cp38-win_amd64.pyd’.  This brings
     windows into conformance with the other platforms.

   - bpo-26389(49): The *note traceback.format_exception(): 818, *note
     traceback.format_exception_only(): 819, and *note
     traceback.print_exception(): 81a. functions can now take an
     exception object as a positional-only argument.

   - bpo-41889(50): Enum: fix regression involving inheriting a multiply
     inherited enum

   - bpo-41861(51): Convert *note sqlite3: ba. to use heap types (PEP
     384).  Patch by Erlend E. Aasland.

   - bpo-40624(52): Added support for the XPath ‘!=’ operator in
     xml.etree

   - bpo-28850(53): Fix *note pprint.PrettyPrinter.format(): 1889.
     overrides being ignored for contents of small containers.  The
     ‘pprint._safe_repr()’ function was removed.

   - bpo-41625(54): Expose the ‘splice()’ as *note os.splice(): 7e4. in
     the *note os: 91. module.  Patch by Pablo Galindo

   - bpo-34215(55): Clarify the error message for *note
     asyncio.IncompleteReadError: 188a. when ‘expected’ is ‘None’.

   - bpo-41543(56): Add async context manager support for
     contextlib.nullcontext.

   - bpo-21041(57): *note pathlib.PurePath.parents: 7eb. now supports
     negative indexing.  Patch contributed by Yaroslav Pankovych.

   - bpo-41332(58): Added missing connect_accepted_socket() method to
     ‘asyncio.AbstractEventLoop’.

   - bpo-12800(59): Extracting a symlink from a tarball should succeed
     and overwrite the symlink if it already exists.  The fix is to
     remove the existing file or symlink before extraction.  Based on
     patch by Chris AtLee, Jeffrey Kintscher, and Senthil Kumaran.

   - bpo-40968(60): *note urllib.request: f4. and *note http.client: 65.
     now send ‘http/1.1’ ALPN extension during TLS handshake when no
     custom context is supplied.

   - bpo-41001(61): Add *note os.eventfd(): 7e3. to provide a low level
     interface for Linux's event notification file descriptor.

   - bpo-40816(62): Add AsyncContextDecorator to contextlib to support
     async context manager as a decorator.

   - bpo-40550(63): Fix time-of-check/time-of-action issue in
     subprocess.Popen.send_signal.

   - bpo-39411(64): Add an ‘is_async’ identifier to *note pyclbr: a2.'s
     ‘Function’ objects.  Patch by Batuhan Taskaya

   - bpo-35498(65): Add slice support to *note pathlib.PurePath.parents:
     7eb.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5054

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42562

   (3) https://bugs.python.org/issue?@action=redirect&bpo=17735

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42116

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42532

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38200

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41818

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42487

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42482

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41818

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42392

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42392

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28468

   (14) https://bugs.python.org/issue?@action=redirect&bpo=42299

   (15) https://bugs.python.org/issue?@action=redirect&bpo=26131

   (16) https://bugs.python.org/issue?@action=redirect&bpo=41818

   (17) https://bugs.python.org/issue?@action=redirect&bpo=42392

   (18) https://bugs.python.org/issue?@action=redirect&bpo=15450

   (19) https://bugs.python.org/issue?@action=redirect&bpo=42413

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (21) https://bugs.python.org/issue?@action=redirect&bpo=42406

   (22) https://bugs.python.org/issue?@action=redirect&bpo=42403

   (23) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (24) https://bugs.python.org/issue?@action=redirect&bpo=42375

   (25) https://bugs.python.org/issue?@action=redirect&bpo=41713

   (26) https://peps.python.org/pep-0489/

   (27) https://bugs.python.org/issue?@action=redirect&bpo=37205

   (28) https://bugs.python.org/issue?@action=redirect&bpo=42328

   (29) https://bugs.python.org/issue?@action=redirect&bpo=42345

   (30) https://bugs.python.org/issue?@action=redirect&bpo=37205

   (31) https://bugs.python.org/issue?@action=redirect&bpo=42318

   (32) https://bugs.python.org/issue?@action=redirect&bpo=42350

   (33) https://bugs.python.org/issue?@action=redirect&bpo=42333

   (34) https://bugs.python.org/issue?@action=redirect&bpo=42014

   (35) https://bugs.python.org/issue?@action=redirect&bpo=42237

   (36) https://bugs.python.org/issue?@action=redirect&bpo=42308

   (37) https://bugs.python.org/issue?@action=redirect&bpo=42131

   (38) https://bugs.python.org/issue?@action=redirect&bpo=41877

   (39) https://bugs.python.org/issue?@action=redirect&bpo=42264

   (40) https://bugs.python.org/issue?@action=redirect&bpo=42251

   (41) https://bugs.python.org/issue?@action=redirect&bpo=42249

   (42) https://bugs.python.org/issue?@action=redirect&bpo=42236

   (43) https://bugs.python.org/issue?@action=redirect&bpo=41754

   (44) https://bugs.python.org/issue?@action=redirect&bpo=42183

   (45) https://bugs.python.org/issue?@action=redirect&bpo=42140

   (46) https://bugs.python.org/issue?@action=redirect&bpo=42133

   (47) https://bugs.python.org/issue?@action=redirect&bpo=26131

   (48) https://bugs.python.org/issue?@action=redirect&bpo=39825

   (49) https://bugs.python.org/issue?@action=redirect&bpo=26389

   (50) https://bugs.python.org/issue?@action=redirect&bpo=41889

   (51) https://bugs.python.org/issue?@action=redirect&bpo=41861

   (52) https://bugs.python.org/issue?@action=redirect&bpo=40624

   (53) https://bugs.python.org/issue?@action=redirect&bpo=28850

   (54) https://bugs.python.org/issue?@action=redirect&bpo=41625

   (55) https://bugs.python.org/issue?@action=redirect&bpo=34215

   (56) https://bugs.python.org/issue?@action=redirect&bpo=41543

   (57) https://bugs.python.org/issue?@action=redirect&bpo=21041

   (58) https://bugs.python.org/issue?@action=redirect&bpo=41332

   (59) https://bugs.python.org/issue?@action=redirect&bpo=12800

   (60) https://bugs.python.org/issue?@action=redirect&bpo=40968

   (61) https://bugs.python.org/issue?@action=redirect&bpo=41001

   (62) https://bugs.python.org/issue?@action=redirect&bpo=40816

   (63) https://bugs.python.org/issue?@action=redirect&bpo=40550

   (64) https://bugs.python.org/issue?@action=redirect&bpo=39411

   (65) https://bugs.python.org/issue?@action=redirect&bpo=35498


File: python.info,  Node: Documentation<31>,  Next: Tests<34>,  Prev: Library<36>,  Up: Python 3 10 0 alpha 3

1.23.37.4 Documentation
.......................

   - bpo-42238(1): Tentative to deprecate ‘make suspicious’ by first
     removing it from the CI and documentation builds, but keeping it
     around for manual uses.

   - bpo-42153(2): Fix the URL for the IMAP protocol documents.

   - bpo-41028(3): Language and version switchers, previously maintained
     in every cpython branches, are now handled by docsbuild-script.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42238

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42153

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41028


File: python.info,  Node: Tests<34>,  Next: Build<36>,  Prev: Documentation<31>,  Up: Python 3 10 0 alpha 3

1.23.37.5 Tests
...............

   - bpo-41473(1): Re-enable test_gdb on gdb 9.2 and newer:
     ‘https://bugzilla.redhat.com/show_bug.cgi?id=1866884’ bug is fixed
     in gdb 10.1.

   - bpo-42553(2): Fix ‘test_asyncio.test_call_later()’ race condition:
     don't measure asyncio performance in the ‘call_later()’ unit test.
     The test failed randomly on the CI.

   - bpo-31904(3): Fix test_netrc on VxWorks: create temporary
     directories using temp_cwd().

   - bpo-31904(4): skip test_getaddrinfo_ipv6_scopeid_symbolic and
     test_getnameinfo_ipv6_scopeid_symbolic on VxWorks

   - bpo-31904(5): skip test_test of test_mailcap on VxWorks

   - bpo-31904(6): add shell requirement for test_pipes

   - bpo-31904(7): skip some tests related to fifo on VxWorks

   - bpo-31904(8): Fix test_doctest.py failures for VxWorks.

   - bpo-40754(9): Include ‘_testinternalcapi’ module in Windows
     installer for test suite

   - bpo-41561(10): test_ssl: skip test_min_max_version_mismatch when
     TLS 1.0 is not available

   - bpo-31904(11): Fix os module failures for VxWorks RTOS.

   - bpo-31904(12): Fix fifo test cases for VxWorks RTOS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41473

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42553

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40754

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41561

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31904


File: python.info,  Node: Build<36>,  Next: Windows<32>,  Prev: Tests<34>,  Up: Python 3 10 0 alpha 3

1.23.37.6 Build
...............

   - bpo-31904(1): remove libnet dependency from detect_socket() for
     VxWorks

   - bpo-42398(2): Fix a race condition in "make regen-all" when make
     -jN option is used to run jobs in parallel.  The clinic.py script
     now only use atomic write to write files.  Moveover, generated
     files are now left unchanged if the content does not change, to not
     change the file modification time.

   - bpo-41617(3): Fix building ‘pycore_bitutils.h’ internal header on
     old clang version without ‘__builtin_bswap16()’ (ex: Xcode 4.6.3 on
     Mac OS X 10.7).  Patch by Joshua Root and Victor Stinner.

   - bpo-38823(4): It is no longer possible to build the ‘_ctypes’
     extension module without ‘wchar_t’ type: remove ‘CTYPES_UNICODE’
     macro.  Anyway, the ‘wchar_t’ type is required to build Python.
     Patch by Victor Stinner.

   - bpo-42087(5): Support was removed for AIX 5.3 and below.  See
     bpo-40680(6).

   - bpo-40998(7): Addressed three compiler warnings found by undefined
     behavior sanitizer (ubsan).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42398

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41617

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38823

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42087

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40680

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40998


File: python.info,  Node: Windows<32>,  Next: macOS<27>,  Prev: Build<36>,  Up: Python 3 10 0 alpha 3

1.23.37.7 Windows
.................

   - bpo-42120(1): Remove macro definition of ‘copysign’ (to
     ‘_copysign’) in headers.

   - bpo-38506(2): The Windows launcher now properly handles Python 3.10
     when listing installed Python versions.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42120

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38506


File: python.info,  Node: macOS<27>,  Next: IDLE<24>,  Prev: Windows<32>,  Up: Python 3 10 0 alpha 3

1.23.37.8 macOS
...............

   - bpo-42504(1): Fix build on macOS Big Sur when
     MACOSX_DEPLOYMENT_TARGET=11

   - bpo-41116(2): Ensure distutils.unixxcompiler.find_library_file can
     find system provided libraries on macOS 11.

   - bpo-41100(3): Add support for macOS 11 and Apple Silicon systems.

     It is now possible to build "Universal 2" binaries using
     "-enable-universalsdk -with-universal-archs=universal2".

     Binaries build on later macOS versions can be deployed back to
     older versions (tested up to macOS 10.9), when using the correct
     deployment target.  This is tested using Xcode 11 and later.

   - bpo-42232(4): Added Darwin specific madvise options to mmap module.

   - bpo-38443(5): The ‘--enable-universalsdk’ and
     ‘--with-universal-archs’ options for the configure script now check
     that the specified architectures can be used.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42504

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41116

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41100

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42232

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38443


File: python.info,  Node: IDLE<24>,  Next: Tools/Demos<16>,  Prev: macOS<27>,  Up: Python 3 10 0 alpha 3

1.23.37.9 IDLE
..............

   - bpo-42508(1): Keep IDLE running on macOS. Remove obsolete
     workaround that prevented running files with shortcuts when using
     new universal2 installers built on macOS 11.

   - bpo-42426(2): Fix reporting offset of the RE error in searchengine.

   - bpo-42415(3): Get docstrings for IDLE calltips more often by using
     inspect.getdoc.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42508

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42426

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42415


File: python.info,  Node: Tools/Demos<16>,  Next: C API<35>,  Prev: IDLE<24>,  Up: Python 3 10 0 alpha 3

1.23.37.10 Tools/Demos
......................

   - bpo-42212(1): The smelly.py script now also checks the Python
     dynamic library and extension modules, not only the Python static
     library.  Make also the script more verbose: explain what it does.

   - bpo-36310(2): Allow ‘Tools/i18n/pygettext.py’ to detect calls to
     ‘gettext’ in f-strings.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42212

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36310


File: python.info,  Node: C API<35>,  Prev: Tools/Demos<16>,  Up: Python 3 10 0 alpha 3

1.23.37.11 C API
................

   - bpo-42423(1): The *note PyType_FromSpecWithBases(): 54a. and *note
     PyType_FromModuleAndSpec(): 51c. functions now accept a single
     class as the 'bases' argument.

   - bpo-1635741(2): Port *note select: af. extension module to
     multiphase initialization ( PEP 489(3)).

   - bpo-1635741(4): Port _posixsubprocess extension module to
     multiphase initialization ( PEP 489(5)).

   - bpo-1635741(6): Port _posixshmem extension module to multiphase
     initialization ( PEP 489(7))

   - bpo-1635741(8): Port _struct extension module to multiphase
     initialization ( PEP 489(9))

   - bpo-1635741(10): Port ‘spwd’ extension module to multiphase
     initialization ( PEP 489(11))

   - bpo-1635741(12): Port *note gc: 56. extension module to multiphase
     initialization ( PEP 489(13))

   - bpo-1635741(14): Port _queue extension module to multiphase
     initialization ( PEP 489(15))

   - bpo-39573(16): Convert *note Py_TYPE(): 74b. and *note Py_SIZE():
     74d. back to macros to allow using them as an l-value.  Many third
     party C extension modules rely on the ability of using Py_TYPE()
     and Py_SIZE() to set an object type and size: ‘Py_TYPE(obj) =
     type;’ and ‘Py_SIZE(obj) = size;’.

   - bpo-1635741(17): Port *note symtable: c2. extension module to
     multiphase initialization ( PEP 489(18))

   - bpo-1635741(19): Port *note grp: 5c. and *note pwd: a0. extension
     modules to multiphase initialization ( PEP 489(20))

   - bpo-1635741(21): Port _random extension module to multiphase
     initialization ( PEP 489(22))

   - bpo-1635741(23): Port _hashlib extension module to multiphase
     initialization ( PEP 489(24))

   - bpo-41713(25): Removed the undocumented ‘PyOS_InitInterrupts()’
     function.  Initializing Python already implicitly installs signal
     handlers: see *note PyConfig.install_signal_handlers: 88c.  Patch
     by Victor Stinner.

   - bpo-40170(26): The ‘Py_TRASHCAN_BEGIN’ macro no longer accesses
     PyTypeObject attributes, but now can get the condition by calling
     the new private ‘_PyTrash_cond()’ function which hides
     implementation details.

   - bpo-42260(27): *note Py_GetPath(): 38d, *note Py_GetPrefix(): 38f,
     *note Py_GetExecPrefix(): 38b, *note Py_GetProgramFullPath(): 391,
     *note Py_GetPythonHome(): 394. and *note Py_GetProgramName(): 393.
     functions now return ‘NULL’ if called before *note Py_Initialize():
     87a. (before Python is initialized).  Use the new *note Python
     Initialization Configuration API: 381. to get the *note Python Path
     Configuration.: 87b.  Patch by Victor Stinner.

   - bpo-42260(28): The *note PyConfig_Read(): 75b. function now only
     parses *note PyConfig.argv: 39d. arguments once: *note
     PyConfig.parse_argv: 1893. is set to ‘2’ after arguments are
     parsed.  Since Python arguments are strippped from *note
     PyConfig.argv: 39d, parsing arguments twice would parse the
     application options as Python options.

   - bpo-42262(29): Added *note Py_NewRef(): 867. and *note
     Py_XNewRef(): 868. functions to increment the reference count of an
     object and return the object.  Patch by Victor Stinner.

   - bpo-42260(30): When *note Py_Initialize(): 87a. is called twice,
     the second call now updates more *note sys: c3. attributes for the
     configuration, rather than only *note sys.argv: 1236.  Patch by
     Victor Stinner.

   - bpo-41832(31): The *note PyType_FromModuleAndSpec(): 51c. function
     now accepts NULL ‘tp_doc’ slot.

   - bpo-1635741(32): Added *note PyModule_AddObjectRef(): 33e.
     function: similar to *note PyModule_AddObject(): 33f. but don't
     steal a reference to the value on success.  Patch by Victor
     Stinner.

   - bpo-42171(33): The *note METH_FASTCALL: 158b. calling convention is
     added to the limited API. The functions *note PyModule_AddType():
     943, *note PyType_FromModuleAndSpec(): 51c, *note
     PyType_GetModule(): 93c. and *note PyType_GetModuleState(): 93d.
     are added to the limited API on Windows.

   - bpo-42085(34): Add dedicated entry to PyAsyncMethods for sending
     values

   - bpo-41073(35): *note PyType_GetSlot(): 869. can now accept static
     types.

   - bpo-30459(36): *note PyList_SET_ITEM(): 367, *note
     PyTuple_SET_ITEM(): 366. and *note PyCell_SET(): 87c. macros can no
     longer be used as l-value or r-value.  For example, ‘x =
     PyList_SET_ITEM(a, b, c)’ and ‘PyList_SET_ITEM(a, b, c) = x’ now
     fail with a compiler error.  It prevents bugs like ‘if
     (PyList_SET_ITEM (a, b, c) < 0) ...’ test.  Patch by Zackery Spytz
     and Victor Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42423

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (3) https://peps.python.org/pep-0489/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (5) https://peps.python.org/pep-0489/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (7) https://peps.python.org/pep-0489/

   (8) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (9) https://peps.python.org/pep-0489/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (11) https://peps.python.org/pep-0489/

   (12) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (13) https://peps.python.org/pep-0489/

   (14) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (15) https://peps.python.org/pep-0489/

   (16) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (17) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (18) https://peps.python.org/pep-0489/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (20) https://peps.python.org/pep-0489/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (22) https://peps.python.org/pep-0489/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (24) https://peps.python.org/pep-0489/

   (25) https://bugs.python.org/issue?@action=redirect&bpo=41713

   (26) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (27) https://bugs.python.org/issue?@action=redirect&bpo=42260

   (28) https://bugs.python.org/issue?@action=redirect&bpo=42260

   (29) https://bugs.python.org/issue?@action=redirect&bpo=42262

   (30) https://bugs.python.org/issue?@action=redirect&bpo=42260

   (31) https://bugs.python.org/issue?@action=redirect&bpo=41832

   (32) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (33) https://bugs.python.org/issue?@action=redirect&bpo=42171

   (34) https://bugs.python.org/issue?@action=redirect&bpo=42085

   (35) https://bugs.python.org/issue?@action=redirect&bpo=41073

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30459


File: python.info,  Node: Python 3 10 0 alpha 2,  Next: Python 3 10 0 alpha 1,  Prev: Python 3 10 0 alpha 3,  Up: 変更履歴

1.23.38 Python 3.10.0 alpha 2
-----------------------------

'Release date: 2020-11-03'

* Menu:

* Security: Security<23>.
* Core and Builtins: Core and Builtins<38>.
* Library: Library<37>.
* Documentation: Documentation<32>.
* Tests: Tests<35>.
* Build: Build<37>.
* Windows: Windows<33>.
* macOS: macOS<28>.
* IDLE: IDLE<25>.
* C API: C API<36>.


File: python.info,  Node: Security<23>,  Next: Core and Builtins<38>,  Up: Python 3 10 0 alpha 2

1.23.38.1 Security
..................

   - bpo-42103(1): Prevented potential DoS attack via CPU and RAM
     exhaustion when processing malformed Apple Property List files in
     binary format.

   - bpo-42051(2): The *note plistlib: 99. module no longer accepts
     entity declarations in XML plist files to avoid XML
     vulnerabilities.  This should not affect users as entity
     declarations are not used in regular plist files.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42103

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42051


File: python.info,  Node: Core and Builtins<38>,  Next: Library<37>,  Prev: Security<23>,  Up: Python 3 10 0 alpha 2

1.23.38.2 Core and Builtins
...........................

   - bpo-42236(1): If the ‘nl_langinfo(CODESET)’ function returns an
     empty string, Python now uses UTF-8 as the filesystem encoding.
     Patch by Victor Stinner.

   - bpo-42218(2): Fixed a bug in the PEG parser that was causing
     crashes in debug mode.  Now errors are checked in left-recursive
     rules to avoid cases where such errors do not get handled in time
     and appear as long-distance crashes in other places.

   - bpo-42214(3): Fixed a possible crash in the PEG parser when
     checking for the '!=' token in the ‘barry_as_flufl’ rule.  Patch by
     Pablo Galindo.

   - bpo-42206(4): Propagate and raise the errors caused by
     ‘PyAST_Validate()’ in the parser.

   - bpo-41796(5): The *note ast: 7. module internal state is now per
     interpreter.  Patch by Victor Stinner.

   - bpo-42143(6): Fix handling of errors during creation of
     ‘PyFunctionObject’, which resulted in operations on uninitialized
     memory.  Patch by Yonatan Goldschmidt.

   - bpo-41659(7): Fix a bug in the parser, where a curly brace
     following a ‘primary’ didn't fail immediately.  This led to invalid
     expressions like ‘a {b}’ to throw a *note SyntaxError: 172. with a
     wrong offset, or invalid expressions ending with a curly brace like
     ‘a {’ to not fail immediately in the REPL.

   - bpo-42150(8): Fix possible buffer overflow in the new parser when
     checking for continuation lines.  Patch by Pablo Galindo.

   - bpo-42123(9): Run the parser two times.  On the first run, disable
     all the rules that only generate better error messages to gain
     performance.  If there's a parse failure, run the parser a second
     time with those enabled.

   - bpo-42093(10): The ‘LOAD_ATTR’ instruction now uses new "per opcode
     cache" mechanism and it is about 36% faster now.  Patch by Pablo
     Galindo and Yury Selivanov.

   - bpo-42030(11): Support for the legacy AIX-specific shared library
     loading support has been removed.  All versions of AIX since 4.3
     have supported and defaulted to using the common Unix mechanism
     instead.

   - bpo-41984(12): The garbage collector now tracks all user-defined
     classes.  Patch by Brandt Bucher.

   - bpo-41993(13): Fixed potential issues with removing not completely
     initialized module from ‘sys.modules’ when import fails.

   - bpo-41979(14): Star-unpacking is now allowed for with item's
     targets in the PEG parser.

   - bpo-41974(15): Removed special methods ‘__int__’, ‘__float__’,
     ‘__floordiv__’, ‘__mod__’, ‘__divmod__’, ‘__rfloordiv__’,
     ‘__rmod__’ and ‘__rdivmod__’ of the *note complex: 2cf. class.
     They always raised a *note TypeError: 502.

   - bpo-41902(16): Micro optimization when compute *note sq_item: 1897.
     and *note mp_subscript: 1898. of *note range: 911.  Patch by
     Donghee Na.

   - bpo-41894(17): When loading a native module and a load failure
     occurs, prevent a possible UnicodeDecodeError when not running in a
     UTF-8 locale by decoding the load error message using the current
     locale's encoding.

   - bpo-41902(18): Micro optimization for range.index if step is 1.
     Patch by Donghee Na.

   - bpo-41435(19): Add ‘sys._current_exceptions()’ function to retrieve
     a dictionary mapping each thread's identifier to the topmost
     exception currently active in that thread at the time the function
     is called.

   - bpo-38605(20): Enable ‘from __future__ import annotations’ ( PEP
     563(21)) by default.  The values found in ‘__annotations__’ dicts
     are now strings, for example ‘{"x": "int"}’ instead of ‘{"x":
     int}’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42236

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42218

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42214

   (4) https://bugs.python.org/issue?@action=redirect&bpo=42206

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41796

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42143

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41659

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42150

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42123

   (10) https://bugs.python.org/issue?@action=redirect&bpo=42093

   (11) https://bugs.python.org/issue?@action=redirect&bpo=42030

   (12) https://bugs.python.org/issue?@action=redirect&bpo=41984

   (13) https://bugs.python.org/issue?@action=redirect&bpo=41993

   (14) https://bugs.python.org/issue?@action=redirect&bpo=41979

   (15) https://bugs.python.org/issue?@action=redirect&bpo=41974

   (16) https://bugs.python.org/issue?@action=redirect&bpo=41902

   (17) https://bugs.python.org/issue?@action=redirect&bpo=41894

   (18) https://bugs.python.org/issue?@action=redirect&bpo=41902

   (19) https://bugs.python.org/issue?@action=redirect&bpo=41435

   (20) https://bugs.python.org/issue?@action=redirect&bpo=38605

   (21) https://peps.python.org/pep-0563/


File: python.info,  Node: Library<37>,  Next: Documentation<32>,  Prev: Core and Builtins<38>,  Up: Python 3 10 0 alpha 2

1.23.38.3 Library
.................

   - bpo-35455(1): On Solaris, *note thread_time(): 904. is now
     implemented with ‘gethrvtime()’ because
     ‘clock_gettime(CLOCK_THREAD_CPUTIME_ID)’ is not always available.
     Patch by Jakub Kulik.

   - bpo-42233(2): The *note repr(): 7c8. of *note typing: ed. types
     containing *note Generic Alias Types: 67e. previously did not show
     the parameterized types in the ‘GenericAlias’.  They have now been
     changed to do so.

   - bpo-29566(3): ‘binhex.binhex()’ consistently writes macOS 9 line
     endings.

   - bpo-26789(4): The *note logging.FileHandler: 1809. class now keeps
     a reference to the builtin *note open(): 4e5. function to be able
     to open or reopen the file during Python finalization.  Fix errors
     like: ‘NameError: name 'open' is not defined’.  Patch by Victor
     Stinner.

   - bpo-42157(5): Removed the ‘unicodedata.ucnhash_CAPI’ attribute
     which was an internal PyCapsule object.  The related private
     ‘_PyUnicode_Name_CAPI’ structure was moved to the internal C API.
     Patch by Victor Stinner.

   - bpo-42157(6): Convert the *note unicodedata: ee. extension module
     to the multiphase initialization API ( PEP 489(7)) and convert the
     ‘unicodedata.UCD’ static type to a heap type.  Patch by Mohamed
     Koubaa and Victor Stinner.

   - bpo-42146(8): Fix memory leak in *note subprocess.Popen(): 17e. in
     case an uid (gid) specified in ‘user’ (‘group’, ‘extra_groups’)
     overflows ‘uid_t’ (‘gid_t’).

   - bpo-42103(9): ‘InvalidFileException’ and *note RecursionError: d39.
     are now the only errors caused by loading malformed binary Plist
     file (previously ValueError and TypeError could be raised in some
     specific cases).

   - bpo-41490(10): In ‘importlib.resources’, ‘.path’ method is more
     aggressive about releasing handles to zipfile objects early,
     enabling use-cases like certifi to leave the context open but
     delete the underlying zip file.

   - bpo-41052(11): Pickling heap types implemented in C with protocols
     0 and 1 raises now an error instead of producing incorrect data.

   - bpo-42089(12): In ‘importlib.metadata.PackageNotFoundError’, make
     reference to the package metadata being missing to improve the user
     experience.

   - bpo-41491(13): plistlib: fix parsing XML plists with hexadecimal
     integer values

   - bpo-42065(14): Fix an incorrectly formatted error from
     ‘_codecs.charmap_decode()’ when called with a mapped value outside
     the range of valid Unicode code points.  PR by Max Bernstein.

   - bpo-41966(15): Fix pickling pure Python *note datetime.time: 1b0.
     subclasses.  Patch by Dean Inwood.

   - bpo-19270(16): *note sched.scheduler.cancel(): 189a. will now
     cancel the correct event, if two events with same priority are
     scheduled for the same time.  Patch by Bar Harel.

   - bpo-28660(17): *note textwrap.wrap(): 146c. now attempts to break
     long words after hyphens when ‘break_long_words=True’ and
     ‘break_on_hyphens=True’.

   - bpo-35823(18): Use ‘vfork()’ instead of ‘fork()’ for *note
     subprocess.Popen(): 17e. on Linux to improve performance in cases
     where it is deemed safe.

   - bpo-42043(19): Add support for ‘zipfile.Path’ inheritance.
     ‘zipfile.Path.is_file()’ now returns False for non-existent names.
     ‘zipfile.Path’ objects now expose a ‘.filename’ attribute and rely
     on that to resolve ‘.name’ and ‘.parent’ when the ‘Path’ object is
     at the root of the zipfile.

   - bpo-42021(20): Fix possible ref leaks in *note sqlite3: ba. module
     init.

   - bpo-39101(21): Fixed tests using IsolatedAsyncioTestCase from
     hanging on BaseExceptions.

   - bpo-41976(22): Fixed a bug that was causing *note
     ctypes.util.find_library(): d17. to return ‘None’ when triying to
     locate a library in an environment when gcc>=9 is available and
     ‘ldconfig’ is not.  Patch by Pablo Galindo

   - bpo-41943(23): Fix bug where TestCase.assertLogs doesn't correctly
     filter messages by level.

   - bpo-41923(24): Implement PEP 613(25), introducing *note
     typing.TypeAlias: 794. annotation.

   - bpo-41905(26): A new function in abc: 'update_abstractmethods' to
     re-calculate an abstract class's abstract status.  In addition,
     'dataclass' has been changed to call this function.

   - bpo-23706(27): Added 'newline' parameter to
     ‘pathlib.Path.write_text()’.

   - bpo-41876(28): Tkinter font class repr uses font name

   - bpo-41831(29): ‘str()’ for the ‘type’ attribute of the
     ‘tkinter.Event’ object always returns now the numeric code returned
     by Tk instead of the name of the event type.

   - bpo-39337(30): ‘encodings.normalize_encoding()’ now ignores
     non-ASCII characters.

   - bpo-41747(31): Ensure all methods that generated from *note
     dataclasses.dataclass(): 1ad. objects now have the proper
     ‘__qualname__’ attribute referring to the class they belong to.
     Patch by Batuhan Taskaya.

   - bpo-30681(32): Handle exceptions caused by unparsable date headers
     when using email "default" policy.  Patch by Tim Bell, Georges Toth

   - bpo-41586(33): Add F_SETPIPE_SZ and F_GETPIPE_SZ to fcntl module.
     Allow setting pipesize on subprocess.Popen.

   - bpo-41229(34): Add ‘contextlib.aclosing’ for deterministic cleanup
     of async generators which is analogous to ‘contextlib.closing’ for
     non-async generators.  Patch by Joongi Kim and John Belmonte.

   - bpo-16396(35): Allow ‘ctypes.wintypes’ to be imported on
     non-Windows systems.

   - bpo-4356(36): Add a key function to the bisect module.

   - bpo-40592(37): *note shutil.which(): 480. now ignores empty entries
     in ‘PATHEXT’ instead of treating them as a match.

   - bpo-40492(38): Fix ‘--outfile’ for *note cProfile: 20. / *note
     profile: 9d. not writing the output file in the original directory
     when the program being profiled changes the working directory.  PR
     by Anthony Sottile.

   - bpo-34204(39): The *note shelve: b1. module now uses *note
     pickle.DEFAULT_PROTOCOL: 7f9. by default instead of *note pickle:
     95. protocol ‘3’.

   - bpo-27321(40): Fixed KeyError exception when flattening an email to
     a string attempts to replace a non-existent
     Content-Transfer-Encoding header.

   - bpo-38976(41): The *note http.cookiejar: 66. module now supports
     the parsing of cookies in CURL-style cookiejar files through
     MozillaCookieJar on all platforms.  Previously, such cookie entries
     would be silently ignored when loading a cookiejar with such
     entries.

     Additionally, the HTTP Only attribute is persisted in the object,
     and will be correctly written to file if the MozillaCookieJar
     object is subsequently dumped.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35455

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42233

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29566

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26789

   (5) https://bugs.python.org/issue?@action=redirect&bpo=42157

   (6) https://bugs.python.org/issue?@action=redirect&bpo=42157

   (7) https://peps.python.org/pep-0489/

   (8) https://bugs.python.org/issue?@action=redirect&bpo=42146

   (9) https://bugs.python.org/issue?@action=redirect&bpo=42103

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41490

   (11) https://bugs.python.org/issue?@action=redirect&bpo=41052

   (12) https://bugs.python.org/issue?@action=redirect&bpo=42089

   (13) https://bugs.python.org/issue?@action=redirect&bpo=41491

   (14) https://bugs.python.org/issue?@action=redirect&bpo=42065

   (15) https://bugs.python.org/issue?@action=redirect&bpo=41966

   (16) https://bugs.python.org/issue?@action=redirect&bpo=19270

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28660

   (18) https://bugs.python.org/issue?@action=redirect&bpo=35823

   (19) https://bugs.python.org/issue?@action=redirect&bpo=42043

   (20) https://bugs.python.org/issue?@action=redirect&bpo=42021

   (21) https://bugs.python.org/issue?@action=redirect&bpo=39101

   (22) https://bugs.python.org/issue?@action=redirect&bpo=41976

   (23) https://bugs.python.org/issue?@action=redirect&bpo=41943

   (24) https://bugs.python.org/issue?@action=redirect&bpo=41923

   (25) https://peps.python.org/pep-0613/

   (26) https://bugs.python.org/issue?@action=redirect&bpo=41905

   (27) https://bugs.python.org/issue?@action=redirect&bpo=23706

   (28) https://bugs.python.org/issue?@action=redirect&bpo=41876

   (29) https://bugs.python.org/issue?@action=redirect&bpo=41831

   (30) https://bugs.python.org/issue?@action=redirect&bpo=39337

   (31) https://bugs.python.org/issue?@action=redirect&bpo=41747

   (32) https://bugs.python.org/issue?@action=redirect&bpo=30681

   (33) https://bugs.python.org/issue?@action=redirect&bpo=41586

   (34) https://bugs.python.org/issue?@action=redirect&bpo=41229

   (35) https://bugs.python.org/issue?@action=redirect&bpo=16396

   (36) https://bugs.python.org/issue?@action=redirect&bpo=4356

   (37) https://bugs.python.org/issue?@action=redirect&bpo=40592

   (38) https://bugs.python.org/issue?@action=redirect&bpo=40492

   (39) https://bugs.python.org/issue?@action=redirect&bpo=34204

   (40) https://bugs.python.org/issue?@action=redirect&bpo=27321

   (41) https://bugs.python.org/issue?@action=redirect&bpo=38976


File: python.info,  Node: Documentation<32>,  Next: Tests<35>,  Prev: Library<37>,  Up: Python 3 10 0 alpha 2

1.23.38.4 Documentation
.......................

   - bpo-42061(1): Document __format__ functionality for IP addresses.

   - bpo-41910(2): Document the default implementation of
     ‘object.__eq__’.

   - bpo-42010(3): Clarify that subscription expressions are also valid
     for certain *note classes: 189c. and *note types: 189d. in the
     standard library, and for user-defined classes and types if the
     classmethod ‘__class_getitem__()’ is provided.

   - bpo-41805(4): Documented *note generic alias type: 67e. and *note
     types.GenericAlias: 7b6.  Also added an entry in glossary for *note
     generic types: 405.

   - bpo-39693(5): Fix tarfile's extractfile documentation

   - bpo-39416(6): Document some restrictions on the default string
     representations of numeric classes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42061

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41910

   (3) https://bugs.python.org/issue?@action=redirect&bpo=42010

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41805

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39693

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39416


File: python.info,  Node: Tests<35>,  Next: Build<37>,  Prev: Documentation<32>,  Up: Python 3 10 0 alpha 2

1.23.38.5 Tests
...............

   - bpo-41739(1): Fix
     test_logging.test_race_between_set_target_and_flush(): the test now
     waits until all threads complete to avoid leaking running threads.

   - bpo-41970(2): Avoid a test failure in ‘test_lib2to3’ if the module
     has already imported at the time the test executes.  Patch by Pablo
     Galindo.

   - bpo-41944(3): Tests for CJK codecs no longer call ‘eval()’ on
     content received via HTTP.

   - bpo-41306(4): Fixed a failure in ‘test_tk.test_widgets.ScaleTest’
     happening when executing the test with Tk 8.6.10.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41739

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41970

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41944

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41306


File: python.info,  Node: Build<37>,  Next: Windows<33>,  Prev: Tests<35>,  Up: Python 3 10 0 alpha 2

1.23.38.6 Build
...............

   - bpo-38980(1): Add ‘-fno-semantic-interposition’ to both the compile
     and link line when building with ‘--enable-optimizations’.  Patch
     by Victor Stinner and Pablo Galindo.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38980


File: python.info,  Node: Windows<33>,  Next: macOS<28>,  Prev: Build<37>,  Up: Python 3 10 0 alpha 2

1.23.38.7 Windows
.................

   - bpo-38439(1): Updates the icons for IDLE in the Windows Store
     package.

   - bpo-38252(2): Use 8-byte step to detect ASCII sequence in 64-bit
     Windows build.

   - bpo-39107(3): Update Tcl and Tk to 8.6.10 in Windows installer.

   - bpo-41557(4): Update Windows installer to use SQLite 3.33.0.

   - bpo-38324(5): Avoid Unicode errors when accessing certain locale
     data on Windows.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38439

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38252

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39107

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41557

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38324


File: python.info,  Node: macOS<28>,  Next: IDLE<25>,  Prev: Windows<33>,  Up: Python 3 10 0 alpha 2

1.23.38.8 macOS
...............

   - bpo-41471(1): Ignore invalid prefix lengths in system proxy
     excludes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41471


File: python.info,  Node: IDLE<25>,  Next: C API<36>,  Prev: macOS<28>,  Up: Python 3 10 0 alpha 2

1.23.38.9 IDLE
..............

   - bpo-33987(1): Mostly finish using ttk widgets, mainly for editor,
     settings, and searches.  Some patches by Mark Roseman.

   - bpo-40511(2): Typing opening and closing parentheses inside the
     parentheses of a function call will no longer cause unnecessary
     "flashing" off and on of an existing open call-tip, e.g.  when
     typed in a string literal.

   - bpo-38439(3): Add a 256×256 pixel IDLE icon to the Windows .ico
     file.  Created by Andrew Clover.  Remove the low-color gif
     variations from the .ico file.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33987

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40511

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38439


File: python.info,  Node: C API<36>,  Prev: IDLE<25>,  Up: Python 3 10 0 alpha 2

1.23.38.10 C API
................

   - bpo-42157(1): The private ‘_PyUnicode_Name_CAPI’ structure of the
     PyCapsule API ‘unicodedata.ucnhash_CAPI’ has been moved to the
     internal C API. Patch by Victor Stinner.

   - bpo-42015(2): Fix potential crash in deallocating method objects
     when dynamically allocated *note PyMethodDef: 1480.'s lifetime is
     managed through the ‘self’ argument of a *note PyCFunction: 141c.

   - bpo-40423(3): The *note subprocess: c1. module and ‘os.closerange’
     will now use the ‘close_range(low, high, flags)’ syscall when it is
     available for more efficient closing of ranges of descriptors.

   - bpo-41845(4): *note PyObject_GenericGetDict(): 18a4. is available
     again in the limited API when targeting 3.10 or later.

   - bpo-40422(5): Add ‘_Py_closerange’ function to provide performant
     closing of a range of file descriptors.

   - bpo-41986(6): ‘Py_FileSystemDefaultEncodeErrors’ and ‘Py_UTF8Mode’
     are available again in limited API.

   - bpo-41756(7): Add ‘PyIter_Send’ function to allow sending value
     into generator/coroutine/iterator without raising StopIteration
     exception to signal return.

   - bpo-41784(8): Added ‘PyUnicode_AsUTF8AndSize’ to the limited C API.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42157

   (2) https://bugs.python.org/issue?@action=redirect&bpo=42015

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40423

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41845

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40422

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41986

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41756

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41784


File: python.info,  Node: Python 3 10 0 alpha 1,  Next: Python 3 9 0 beta 1,  Prev: Python 3 10 0 alpha 2,  Up: 変更履歴

1.23.39 Python 3.10.0 alpha 1
-----------------------------

'Release date: 2020-10-05'

* Menu:

* Security: Security<24>.
* Core and Builtins: Core and Builtins<39>.
* Library: Library<38>.
* Documentation: Documentation<33>.
* Tests: Tests<36>.
* Build: Build<38>.
* Windows: Windows<34>.
* macOS: macOS<29>.
* IDLE: IDLE<26>.
* C API: C API<37>.


File: python.info,  Node: Security<24>,  Next: Core and Builtins<39>,  Up: Python 3 10 0 alpha 1

1.23.39.1 Security
..................

   - bpo-41304(1): Fixes ‘python3x._pth’ being ignored on Windows,
     caused by the fix for bpo-29778(2) ( CVE 2020-15801(3)).

   - bpo-41162(4): Audit hooks are now cleared later during finalization
     to avoid missing events.

   - bpo-29778(5): Ensure ‘python3.dll’ is loaded from correct locations
     when Python is embedded ( CVE 2020-15523(6)).

   - bpo-41004(7): The __hash__() methods of ipaddress.IPv4Interface and
     ipaddress.IPv6Interface incorrectly generated constant hash values
     of 32 and 128 respectively.  This resulted in always causing hash
     collisions.  The fix uses hash() to generate hash values for the
     tuple of (address, mask length, network address).

   - bpo-39603(8): Prevent http header injection by rejecting control
     characters in http.client.putrequest(...).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41304

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29778

   (3) https://www.cve.org/CVERecord?id=CVE-2020-15801

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41162

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29778

   (6) https://www.cve.org/CVERecord?id=CVE-2020-15523

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41004

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39603


File: python.info,  Node: Core and Builtins<39>,  Next: Library<38>,  Prev: Security<24>,  Up: Python 3 10 0 alpha 1

1.23.39.2 Core and Builtins
...........................

   - bpo-41909(1): Fixed stack overflow in *note issubclass(): 78c. and
     *note isinstance(): 40e. when getting the ‘__bases__’ attribute
     leads to infinite recursion.

   - bpo-41922(2): Speed up calls to ‘reversed()’ by using the PEP
     590(3) ‘vectorcall’ calling convention.  Patch by Donghee Na.

   - bpo-41873(4): Calls to ‘float()’ are now faster due to the
     ‘vectorcall’ calling convention.  Patch by Dennis Sweeney.

   - bpo-41870(5): Speed up calls to ‘bool()’ by using the PEP 590(6)
     ‘vectorcall’ calling convention.  Patch by Donghee Na.

   - bpo-1635741(7): Port the ‘_bisect’ module to the multi-phase
     initialization API ( PEP 489(8)).

   - bpo-39934(9): Correctly count control blocks in 'except' in
     compiler.  Ensures that a syntax error, rather a fatal error,
     occurs for deeply nested, named exception handlers.

   - bpo-41780(10): Fix ‘__dir__()’ of *note types.GenericAlias: 7b6.
     Patch by Batuhan Taskaya.

   - bpo-1635741(11): Port the ‘_lsprof’ extension module to multi-phase
     initialization ( PEP 489(12)).

   - bpo-1635741(13): Port the *note cmath: 11. extension module to
     multi-phase initialization ( PEP 489(14)).

   - bpo-1635741(15): Port the ‘_scproxy’ extension module to
     multi-phase initialization ( PEP 489(16)).

   - bpo-1635741(17): Port the *note termios: ca. extension module to
     multi-phase initialization ( PEP 489(18)).

   - bpo-1635741(19): Convert the ‘_sha256’ extension module types to
     heap types.

   - bpo-41690(20): Fix a possible stack overflow in the parser when
     parsing functions and classes with a huge amount of arguments.
     Patch by Pablo Galindo.

   - bpo-1635741(21): Port the ‘_overlapped’ extension module to
     multi-phase initialization ( PEP 489(22)).

   - bpo-1635741(23): Port the ‘_curses_panel’ extension module to
     multi-phase initialization ( PEP 489(24)).

   - bpo-1635741(25): Port the ‘_opcode’ extension module to multi-phase
     initialization ( PEP 489(26)).

   - bpo-41681(27): Fixes the wrong error description in the error
     raised by using 2 ‘,’ in format string in f-string and *note
     str.format(): 5ed.

   - bpo-41675(28): The implementation of *note signal.siginterrupt():
     1108. now uses ‘sigaction()’ (if it is available in the system)
     instead of the deprecated ‘siginterrupt()’.  Patch by Pablo
     Galindo.

   - bpo-41670(29): Prevent line trace being skipped on platforms not
     compiled with ‘USE_COMPUTED_GOTOS’.  Fixes issue where some lines
     nested within a try-except block were not being traced on Windows.

   - bpo-41654(30): Fix a crash that occurred when destroying subclasses
     of *note MemoryError: 1627.  Patch by Pablo Galindo.

   - bpo-1635741(31): Port the *note zlib: 119. extension module to
     multi-phase initialization ( PEP 489(32)).

   - bpo-41631(33): The ‘_ast’ module uses again a global state.  Using
     a module state per module instance is causing subtle practical
     problems.  For example, the Mercurial project replaces the
     ‘__import__()’ function to implement lazy import, whereas Python
     expected that ‘import _ast’ always return a fully initialized
     ‘_ast’ module.

   - bpo-40077(34): Convert ‘_operator’ to use *note PyType_FromSpec():
     549.

   - bpo-1653741(35): Port ‘_sha3’ to multi-phase init.  Convert static
     types to heap types.

   - bpo-1635741(36): Port the ‘_blake2’ extension module to the
     multi-phase initialization API ( PEP 489(37)).

   - bpo-41533(38): Free the stack allocated in ‘va_build_stack’ if
     ‘do_mkstack’ fails and the stack is not a ‘small_stack’.

   - bpo-41531(39): Fix a bug that was dropping keys when compiling dict
     literals with more than 0xFFFF elements.  Patch by Pablo Galindo.

   - bpo-41525(40): The output of ‘python --help’ contains now only
     ASCII characters.

   - bpo-1635741(41): Port the ‘_sha1’, ‘_sha512’, and ‘_md5’ extension
     modules to multi-phase initialization API ( PEP 489(42)).

   - bpo-41431(43): Optimize ‘dict_merge()’ for copying dict (e.g.
     ‘dict(d)’ and ‘{}.update(d)’).

   - bpo-41428(44): Implement PEP 604.  This supports (int | str) etc.
     in place of Union[str, int].

   - bpo-41340(45): Removed fallback implementation for ‘strdup’.

   - bpo-38156(46): Handle interrupts that come after EOF correctly in
     ‘PyOS_StdioReadline’.

   - bpo-41342(47): *note round(): 12a8. with integer argument is now
     faster (9-60%).

   - bpo-41334(48): Constructors *note str(): 418, *note bytes(): 1a4.
     and *note bytearray(): 508. are now faster (around 30-40% for small
     objects).

   - bpo-41295(49): Resolve a regression in CPython 3.8.4 where defining
     "__setattr__" in a multi-inheritance setup and calling up the
     hierarchy chain could fail if builtins/extension types were
     involved in the base types.

   - bpo-41323(50): Bytecode optimizations are performed directly on the
     control flow graph.  This will result in slightly more compact code
     objects in some circumstances.

   - bpo-41247(51): Always cache the running loop holder when running
     ‘asyncio.set_running_loop’.

   - bpo-41252(52): Fix incorrect refcounting in _ssl.c's
     ‘_servername_callback()’.

   - bpo-1635741(53): Port *note multiprocessing: 86. to multi-phase
     initialization

   - bpo-1635741(54): Port ‘winapi’ to multiphase initialization

   - bpo-41215(55): Use non-NULL default values in the PEG parser
     keyword list to overcome a bug that was preventing Python from
     being properly compiled when using the XLC compiler.  Patch by
     Pablo Galindo.

   - bpo-41218(56): Python 3.8.3 had a regression where compiling with
     ast.PyCF_ALLOW_TOP_LEVEL_AWAIT would aggressively mark list
     comprehension with CO_COROUTINE. Now only list comprehension making
     use of async/await will tagged as so.

   - bpo-1635741(57): Port *note faulthandler: 4e. to multiphase
     initialization.

   - bpo-1635741(58): Port ‘sha256’ to multiphase initialization

   - bpo-41175(59): Guard against a NULL pointer dereference within
     bytearrayobject triggered by the ‘bytearray() + bytearray()’
     operation.

   - bpo-41100(60): add arm64 to the allowable Mac OS arches in
     mpdecimal.h

   - bpo-41094(61): Fix decoding errors with audit when open files with
     non-ASCII names on non-UTF-8 locale.

   - bpo-39960(62): The "hackcheck" that prevents sneaking around a
     type's __setattr__() by calling the superclass method was rewritten
     to allow C implemented heap types.

   - bpo-41084(63): Prefix the error message with 'f-string: ', when
     parsing an f-string expression which throws a *note SyntaxError:
     172.

   - bpo-40521(64): Empty frozensets are no longer singletons.

   - bpo-41076(65): Pre-feed the parser with the location of the
     f-string expression, not the f-string itself, which allows us to
     skip the shifting of the AST node locations after the parsing is
     completed.

   - bpo-41056(66): Fixes a reference to deallocated stack space during
     startup when constructing sys.path involving a relative symlink
     when code was supplied via -c.  (discovered via Coverity)

   - bpo-41061(67): Fix incorrect expressions and asserts in hashtable
     code and tests.

   - bpo-41052(68): Opt out serialization/deserialization for
     _random.Random

   - bpo-40939(69): Rename ‘PyPegen*’ functions to ‘PyParser*’, so that
     we can remove the old set of ‘PyParser*’ functions that were using
     the old parser, but keep everything backwards-compatible.

   - bpo-35975(70): Stefan Behnel reported that cf_feature_version is
     used even when PyCF_ONLY_AST is not set.  This is against the
     intention and against the documented behavior, so it's been fixed.

   - bpo-40939(71): Remove the remaining files from the old parser and
     the ‘symbol’ module.

   - bpo-40077(72): Convert ‘_bz2’ to use *note PyType_FromSpec(): 549.

   - bpo-41006(73): The ‘encodings.latin_1’ module is no longer imported
     at startup.  Now it is only imported when it is the filesystem
     encoding or the stdio encoding.

   - bpo-40636(74): *note zip(): 79b. now supports PEP 618(75)'s
     ‘strict’ parameter, which raises a *note ValueError: 1e3. if the
     arguments are exhausted at different lengths.  Patch by Brandt
     Bucher.

   - bpo-1635741(76): Port ‘_gdbm’ to multiphase initialization.

   - bpo-40985(77): Fix a bug that caused the *note SyntaxError: 172.
     text to be empty when a file ends with a line ending in a line
     continuation character (i.e.  backslash).  The error text should
     contain the text of the last line.

   - bpo-40958(78): Fix a possible buffer overflow in the PEG parser
     when gathering information for emitting syntax errors.  Patch by
     Pablo Galindo.

   - bpo-1635741(79): Port ‘_dbm’ to multiphase initialization.

   - bpo-40957(80): Fix refleak in _Py_fopen_obj() when PySys_Audit()
     fails

   - bpo-40950(81): Add a state to the ‘nis’ module ( PEP 3121(82)) and
     apply the multiphase initialization.  Patch by Donghee Na.

   - bpo-40947(83): The Python *note Path Configuration: 87b. now takes
     *note PyConfig.platlibdir: 18a8. in account.

   - bpo-40939(84): Remove the old parser, the ‘parser’ module and all
     associated support code, command-line options and environment
     variables.  Patch by Pablo Galindo.

   - bpo-40847(85): Fix a bug where a line with only a line continuation
     character is not considered a blank line at tokenizer level.  In
     such cases, more than a single ‘NEWLINE’ token was emitted.  The
     old parser was working around the issue, but the new parser threw a
     *note SyntaxError: 172. for valid input due to this.  For example,
     an empty line following a line continuation character was
     interpreted as a *note SyntaxError: 172.

   - bpo-40890(86): Each dictionary view now has a ‘mapping’ attribute
     that provides a *note types.MappingProxyType: 43a. wrapping the
     original dictionary.  Patch contributed by Dennis Sweeney.

   - bpo-40889(87): Improved the performance of symmetric difference
     operations on dictionary item views.  Patch by Dennis Sweeney.

   - bpo-40904(88): Fix possible segfault in the new PEG parser when
     parsing f-string containing yield statements with no value
     (‘f"{yield}"’).  Patch by Pablo Galindo

   - bpo-40903(89): Fixed a possible segfault in the new PEG parser when
     producing error messages for invalid assignments of the form
     ‘p=p=’.  Patch by Pablo Galindo

   - bpo-40880(90): Fix invalid memory read in the new parser when
     checking newlines in string literals.  Patch by Pablo Galindo.

   - bpo-40883(91): Fix memory leak in when parsing f-strings in the new
     parser.  Patch by Pablo Galindo

   - bpo-40870(92): Raise *note ValueError: 1e3. when validating custom
     AST's where the constants ‘True’, ‘False’ and ‘None’ are used
     within a *note ast.Name: 18a9. node.

   - bpo-40854(93): Allow overriding *note sys.platlibdir: 906. via a
     new *note PYTHONPLATLIBDIR: 18aa. environment variable.

   - bpo-40826(94): Fix GIL usage in ‘PyOS_Readline()’: lock the GIL to
     set an exception and pass the Python thread state when checking if
     there is a pending signal.

   - bpo-1635741(95): Port *note fcntl: 4f. to multiphase
     initialization.

   - bpo-19468(96): Delete unnecessary instance check in
     importlib.reload().  Patch by Furkan Önder.

   - bpo-40824(97): Unexpected errors in calling the ‘__iter__’ method
     are no longer masked by ‘TypeError’ in the *note in: 2cb. operator
     and functions *note contains(): 8a8, *note indexOf(): 8a9. and
     *note countOf(): 8aa. of the *note operator: 8f. module.

   - bpo-40792(98): Attributes ‘start’, ‘stop’ and ‘step’ of the *note
     range: 911. object now always has exact type *note int: 238.
     Previously, they could have been an instance of a subclass of
     ‘int’.

   - bpo-40780(99): Fix a corner case where g-style string formatting of
     a float failed to remove trailing zeros.

   - bpo-38964(100): When there's a *note SyntaxError: 172. in the
     expression part of an fstring, the filename attribute of the *note
     SyntaxError: 172. gets correctly set to the name of the file the
     fstring resides in.

   - bpo-40750(101): Support the "-d" debug flag in the new PEG parser.
     Patch by Pablo Galindo

   - bpo-40217(102): Instances of types created with *note
     PyType_FromSpecWithBases(): 54a. will no longer automatically visit
     their class object when traversing references in the garbage
     collector.  The user is expected to manually visit the object's
     class.  Patch by Pablo Galindo.

   - bpo-39573(103): *note Py_TYPE(): 74b. is changed to the inline
     static function.  Patch by Donghee Na.

   - bpo-40696(104): Fix a hang that can arise after *note
     generator.throw(): 4c5. due to a cycle in the exception context
     chain.

   - bpo-40521(105): Each interpreter now its has own free lists,
     singletons and caches:

        * Free lists: float, tuple, list, dict, frame, context,
          asynchronous generator, MemoryError.

        * Singletons: empty tuple, empty bytes string, empty Unicode
          string, single byte character, single Unicode (latin1)
          character.

        * Slice cache.

     They are no longer shared by all interpreters.

   - bpo-40679(106): Certain *note TypeError: 502. messages about
     missing or extra arguments now include the function's *note
     qualified name: 18ab.  Patch by Dennis Sweeney.

   - bpo-29590(107): Make the stack trace correct after calling *note
     generator.throw(): 4c5. on a generator that has yielded from a
     ‘yield from’.

   - bpo-4022(108): Improve performance of generators by not raising
     internal StopIteration.

   - bpo-1635741(109): Port *note mmap: 83. to multiphase
     initialization.

   - bpo-1635741(110): Port ‘_lzma’ to multiphase initialization.

   - bpo-37999(111): Builtin and extension functions that take integer
     arguments no longer accept *note Decimal: 27d.s, *note Fraction:
     1c8.s and other objects that can be converted to integers only with
     a loss (e.g.  that have the *note __int__(): 6e7. method but do not
     have the *note __index__(): 6e8. method).

   - bpo-29882(112): Add *note int.bit_count(): 797, counting the number
     of ones in the binary representation of an integer.  Patch by
     Niklas Fiekas.

   - bpo-36982(113): Use ncurses extended color functions when available
     to support terminals with 256 colors, and add the new function
     *note curses.has_extended_color_support(): 7c0. to indicate whether
     extended color support is provided by the underlying ncurses
     library.

   - bpo-19569(114): Add the private macros ‘_Py_COMP_DIAG_PUSH’,
     ‘_Py_COMP_DIAG_IGNORE_DEPR_DECLS’, and ‘_Py_COMP_DIAG_POP’.

   - bpo-26680(115): The int type now supports the x.is_integer() method
     for compatibility with float.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41909

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41922

   (3) https://peps.python.org/pep-0590/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41873

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41870

   (6) https://peps.python.org/pep-0590/

   (7) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (8) https://peps.python.org/pep-0489/

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39934

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41780

   (11) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (12) https://peps.python.org/pep-0489/

   (13) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (14) https://peps.python.org/pep-0489/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (16) https://peps.python.org/pep-0489/

   (17) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (18) https://peps.python.org/pep-0489/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (20) https://bugs.python.org/issue?@action=redirect&bpo=41690

   (21) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (22) https://peps.python.org/pep-0489/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (24) https://peps.python.org/pep-0489/

   (25) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (26) https://peps.python.org/pep-0489/

   (27) https://bugs.python.org/issue?@action=redirect&bpo=41681

   (28) https://bugs.python.org/issue?@action=redirect&bpo=41675

   (29) https://bugs.python.org/issue?@action=redirect&bpo=41670

   (30) https://bugs.python.org/issue?@action=redirect&bpo=41654

   (31) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (32) https://peps.python.org/pep-0489/

   (33) https://bugs.python.org/issue?@action=redirect&bpo=41631

   (34) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (35) https://bugs.python.org/issue?@action=redirect&bpo=1653741

   (36) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (37) https://peps.python.org/pep-0489/

   (38) https://bugs.python.org/issue?@action=redirect&bpo=41533

   (39) https://bugs.python.org/issue?@action=redirect&bpo=41531

   (40) https://bugs.python.org/issue?@action=redirect&bpo=41525

   (41) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (42) https://peps.python.org/pep-0489/

   (43) https://bugs.python.org/issue?@action=redirect&bpo=41431

   (44) https://bugs.python.org/issue?@action=redirect&bpo=41428

   (45) https://bugs.python.org/issue?@action=redirect&bpo=41340

   (46) https://bugs.python.org/issue?@action=redirect&bpo=38156

   (47) https://bugs.python.org/issue?@action=redirect&bpo=41342

   (48) https://bugs.python.org/issue?@action=redirect&bpo=41334

   (49) https://bugs.python.org/issue?@action=redirect&bpo=41295

   (50) https://bugs.python.org/issue?@action=redirect&bpo=41323

   (51) https://bugs.python.org/issue?@action=redirect&bpo=41247

   (52) https://bugs.python.org/issue?@action=redirect&bpo=41252

   (53) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (54) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (55) https://bugs.python.org/issue?@action=redirect&bpo=41215

   (56) https://bugs.python.org/issue?@action=redirect&bpo=41218

   (57) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (58) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (59) https://bugs.python.org/issue?@action=redirect&bpo=41175

   (60) https://bugs.python.org/issue?@action=redirect&bpo=41100

   (61) https://bugs.python.org/issue?@action=redirect&bpo=41094

   (62) https://bugs.python.org/issue?@action=redirect&bpo=39960

   (63) https://bugs.python.org/issue?@action=redirect&bpo=41084

   (64) https://bugs.python.org/issue?@action=redirect&bpo=40521

   (65) https://bugs.python.org/issue?@action=redirect&bpo=41076

   (66) https://bugs.python.org/issue?@action=redirect&bpo=41056

   (67) https://bugs.python.org/issue?@action=redirect&bpo=41061

   (68) https://bugs.python.org/issue?@action=redirect&bpo=41052

   (69) https://bugs.python.org/issue?@action=redirect&bpo=40939

   (70) https://bugs.python.org/issue?@action=redirect&bpo=35975

   (71) https://bugs.python.org/issue?@action=redirect&bpo=40939

   (72) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (73) https://bugs.python.org/issue?@action=redirect&bpo=41006

   (74) https://bugs.python.org/issue?@action=redirect&bpo=40636

   (75) https://peps.python.org/pep-0618/

   (76) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (77) https://bugs.python.org/issue?@action=redirect&bpo=40985

   (78) https://bugs.python.org/issue?@action=redirect&bpo=40958

   (79) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (80) https://bugs.python.org/issue?@action=redirect&bpo=40957

   (81) https://bugs.python.org/issue?@action=redirect&bpo=40950

   (82) https://peps.python.org/pep-3121/

   (83) https://bugs.python.org/issue?@action=redirect&bpo=40947

   (84) https://bugs.python.org/issue?@action=redirect&bpo=40939

   (85) https://bugs.python.org/issue?@action=redirect&bpo=40847

   (86) https://bugs.python.org/issue?@action=redirect&bpo=40890

   (87) https://bugs.python.org/issue?@action=redirect&bpo=40889

   (88) https://bugs.python.org/issue?@action=redirect&bpo=40904

   (89) https://bugs.python.org/issue?@action=redirect&bpo=40903

   (90) https://bugs.python.org/issue?@action=redirect&bpo=40880

   (91) https://bugs.python.org/issue?@action=redirect&bpo=40883

   (92) https://bugs.python.org/issue?@action=redirect&bpo=40870

   (93) https://bugs.python.org/issue?@action=redirect&bpo=40854

   (94) https://bugs.python.org/issue?@action=redirect&bpo=40826

   (95) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (96) https://bugs.python.org/issue?@action=redirect&bpo=19468

   (97) https://bugs.python.org/issue?@action=redirect&bpo=40824

   (98) https://bugs.python.org/issue?@action=redirect&bpo=40792

   (99) https://bugs.python.org/issue?@action=redirect&bpo=40780

   (100) https://bugs.python.org/issue?@action=redirect&bpo=38964

   (101) https://bugs.python.org/issue?@action=redirect&bpo=40750

   (102) https://bugs.python.org/issue?@action=redirect&bpo=40217

   (103) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (104) https://bugs.python.org/issue?@action=redirect&bpo=40696

   (105) https://bugs.python.org/issue?@action=redirect&bpo=40521

   (106) https://bugs.python.org/issue?@action=redirect&bpo=40679

   (107) https://bugs.python.org/issue?@action=redirect&bpo=29590

   (108) https://bugs.python.org/issue?@action=redirect&bpo=4022

   (109) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (110) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (111) https://bugs.python.org/issue?@action=redirect&bpo=37999

   (112) https://bugs.python.org/issue?@action=redirect&bpo=29882

   (113) https://bugs.python.org/issue?@action=redirect&bpo=36982

   (114) https://bugs.python.org/issue?@action=redirect&bpo=19569

   (115) https://bugs.python.org/issue?@action=redirect&bpo=26680


File: python.info,  Node: Library<38>,  Next: Documentation<33>,  Prev: Core and Builtins<39>,  Up: Python 3 10 0 alpha 1

1.23.39.3 Library
.................

   - bpo-41900(1): C14N 2.0 serialisation in xml.etree.ElementTree
     failed for unprefixed attributes when a default namespace was
     defined.

   - bpo-41887(2): Strip leading spaces and tabs on *note
     ast.literal_eval(): be6.  Also document stripping of spaces and
     tabs for *note eval(): 165.

   - bpo-41773(3): Note in documentation that *note random.choices():
     c94. doesn't support non-finite weights, raise *note ValueError:
     1e3. when given non-finite weights.

   - bpo-41840(4): Fix a bug in the *note symtable: c2. module that was
     causing module-scope global variables to not be reported as both
     local and global.  Patch by Pablo Galindo.

   - bpo-41842(5): Add *note codecs.unregister(): 7b3. function to
     unregister a codec search function.

   - bpo-40564(6): In ‘zipfile.Path’, mutate the passed ZipFile object
     type instead of making a copy.  Prevents issues when both the local
     copy and the caller’s copy attempt to close the same file handle.

   - bpo-40670(7): More reliable validation of statements in *note
     timeit.Timer: 146d.  It now accepts "empty" statements (only
     whitespaces and comments) and rejects misindentent statements.

   - bpo-41833(8): The *note threading.Thread: 91a. constructor now uses
     the target name if the 'target' argument is specified but the
     'name' argument is omitted.

   - bpo-41817(9): fix ‘tkinter.EventType’ Enum so all members are
     strings, and none are tuples

   - bpo-41810(10): *note types.EllipsisType: 81c, *note
     types.NotImplementedType: 81e. and *note types.NoneType: 81d. have
     been reintroduced, providing a new set of types readily
     interpretable by static type checkers.

   - bpo-41815(11): Fix SQLite3 segfault when backing up closed
     database.  Patch contributed by Peter David McCormick.

   - bpo-41816(12): StrEnum added: it ensures that all members are
     already strings or string candidates

   - bpo-41517(13): fix bug allowing Enums to be extended via multiple
     inheritance

   - bpo-39587(14): use the correct mix-in data type when constructing
     Enums

   - bpo-41792(15): Add is_typeddict function to typing.py to check if a
     type is a TypedDict class

     Previously there was no way to check that without using private
     API.  See the relevant issue in python/typing(16).

   - bpo-41789(17): Honor ‘object’ overrides in ‘Enum’ class creation
     (specifically, ‘__str__’, ‘__repr__’, ‘__format__’, and
     ‘__reduce_ex__’).

   - bpo-32218(18): ‘enum.Flag’ and ‘enum.IntFlag’ members are now
     iterable.

   - bpo-39651(19): Fix a race condition in the ‘call_soon_threadsafe()’
     method of ‘asyncio.ProactorEventLoop’: do nothing if the self-pipe
     socket has been closed.

   - bpo-1635741(20): Port the ‘mashal’ extension module to the
     multi-phase initialization API ( PEP 489(21)).

   - bpo-1635741(22): Port the ‘_string’ extension module to the
     multi-phase initialization API ( PEP 489(23)).

   - bpo-41732(24): Added an *note iterator: 191. to *note memoryview:
     435.

   - bpo-41720(25): Fixed ‘turtle.Vec2D.__rmul__()’ for arguments which
     are not int or float.

   - bpo-41696(26): Fix handling of debug mode in *note asyncio.run():
     449.  This allows setting ‘PYTHONASYNCIODEBUG’ or ‘-X dev’ to
     enable asyncio debug mode when using *note asyncio.run(): 449.

   - bpo-41687(27): Fix implementation of sendfile to be compatible with
     Solaris.

   - bpo-41662(28): No longer override exceptions raised in ‘__len__()’
     of a sequence of parameters in *note sqlite3: ba. with *note
     ProgrammingError: 4bf.

   - bpo-39010(29): Restarting a ‘ProactorEventLoop’ on Windows no
     longer logs spurious ‘ConnectionResetErrors’.

   - bpo-41638(30): *note ProgrammingError: 4bf. message for absent
     parameter in *note sqlite3: ba. contains now the name of the
     parameter instead of its index when parameters are supplied as a
     dict.

   - bpo-41662(31): Fixed crash when mutate list of parameters during
     iteration in *note sqlite3: ba.

   - bpo-41513(32): Improved the accuracy of math.hypot().  Internally,
     each step is computed with extra precision so that the result is
     now almost always correctly rounded.

   - bpo-41609(33): The pdb whatis command correctly reports instance
     methods as 'Method' rather than 'Function'.

   - bpo-39994(34): Fixed pprint's handling of dict subclasses that
     override __repr__.

   - bpo-32751(35): When cancelling the task due to a timeout, *note
     asyncio.wait_for(): 5ca. will now wait until the cancellation is
     complete also in the case when 'timeout' is <= 0, like it does with
     positive timeouts.

   - bpo-37658(36): *note asyncio.wait_for(): 5ca. now properly handles
     races between cancellation of itself and the completion of the
     wrapped awaitable.

   - bpo-40782(37): Change the method
     asyncio.AbstractEventLoop.run_in_executor to not be a coroutine.

   - bpo-41520(38): Fix *note codeop: 15. regression that prevented
     turning compile warnings into errors.

   - bpo-41528(39): turtle uses math module functions to convert degrees
     to radians and vice versa and to calculate vector norm

   - bpo-41513(40): Minor algorithmic improvement to math.hypot() and
     math.dist() giving small gains in speed and accuracy.

   - bpo-41503(41): Fixed a race between setTarget and flush in
     logging.handlers.MemoryHandler.

   - bpo-41497(42): Fix potential UnicodeDecodeError in dis module.

   - bpo-41467(43): On Windows, fix asyncio ‘recv_into()’ return value
     when the socket/pipe is closed (*note BrokenPipeError: 1030.):
     return ‘0’ rather than an empty byte string (‘b''’).

   - bpo-41425(44): Make tkinter doc example runnable.

   - bpo-41421(45): Make an algebraic simplification to
     random.paretovariate().  It now is slightly less subject to
     round-off error and is slightly faster.  Inputs that used to cause
     ZeroDivisionError now cause an OverflowError instead.

   - bpo-41440(46): Add *note os.cpu_count(): 1a7. support for VxWorks
     RTOS.

   - bpo-41316(47): Fix the *note tarfile: c8. module to write only
     basename of TAR file to GZIP compression header.

   - bpo-41384(48): Raise TclError instead of TypeError when an unknown
     option is passed to tkinter.OptionMenu.

   - bpo-41317(49): Use add_done_callback() in
     asyncio.loop.sock_accept() to unsubscribe reader early on
     cancellation.

   - bpo-41364(50): Reduce import overhead of *note uuid: f8.

   - bpo-35328(51): Set the environment variable ‘VIRTUAL_ENV_PROMPT’ at
     *note venv: f9. activation.

   - bpo-41341(52): Recursive evaluation of ‘typing.ForwardRef’ in
     ‘get_type_hints’.

   - bpo-41344(53): Prevent creating ‘shared_memory.SharedMemory’
     objects with ‘size=0’.

   - bpo-41333(54): ‘collections.OrderedDict.pop()’ is now 2 times
     faster.

   - bpo-41288(55): Unpickling invalid NEWOBJ_EX opcode with the C
     implementation raises now UnpicklingError instead of crashing.

   - bpo-39017(56): Avoid infinite loop when reading specially crafted
     TAR files using the tarfile module ( CVE 2019-20907(57)).

   - bpo-41273(58): Speed up any transport using
     ‘_ProactorReadPipeTransport’ by calling ‘recv_into’ instead of
     ‘recv’, thus not creating a new buffer for each ‘recv’ call in the
     transport's read loop.

   - bpo-41235(59): Fix the error handling in *note
     ssl.SSLContext.load_dh_params(): 1115.

   - bpo-41207(60): In distutils.spawn, restore expectation that
     DistutilsExecError is raised when the command is not found.

   - bpo-29727(61): Register *note array.array: 185. as a *note
     MutableSequence: 186.  Patch by Pablo Galindo.

   - bpo-39168(62): Remove the ‘__new__’ method of *note typing.Generic:
     157c.

   - bpo-41194(63): Fix a crash in the ‘_ast’ module: it can no longer
     be loaded more than once.  It now uses a global state rather than a
     module state.

   - bpo-41195(64): Add read-only ssl.SSLContext.security_level
     attribute to retrieve the context's security level.

   - bpo-41193(65): The ‘write_history()’ atexit function of the
     readline completer now ignores any *note OSError: 3f0. to ignore
     error if the filesystem is read-only, instead of only ignoring
     *note FileNotFoundError: e8f. and *note PermissionError: d10.

   - bpo-41182(66): selector: use DefaultSelector based upon
     implementation

   - bpo-41161(67): The decimal module now requires libmpdec-2.5.0.
     Users of -with-system-libmpdec should update their system library.

   - bpo-40874(68): The decimal module now requires libmpdec-2.5.0.

   - bpo-41138(69): Fixed the *note trace: e6. module CLI for Python
     source files with non-UTF-8 encoding.

   - bpo-31082(70): Use the term "iterable" in the docstring for *note
     functools.reduce(): 12aa.

   - bpo-40521(71): Remove freelist from collections.deque().

   - bpo-31938(72): Fix default-value signatures of several functions in
     the *note select: af. module - by Anthony Sottile.

   - bpo-41068(73): Fixed reading files with non-ASCII names from ZIP
     archive directly after writing them.

   - bpo-41058(74): ‘pdb.find_function()’ now correctly determines the
     source file encoding.

   - bpo-41056(75): Invalid file descriptor values are now prevented
     from being passed to os.fpathconf.  (discovered by Coverity)

   - bpo-41056(76): Fix a NULL pointer dereference within the ssl module
     during a MemoryError in the keylog callback.  (discovered by
     Coverity)

   - bpo-41056(77): Fixed an instance where a MemoryError within the
     zoneinfo module might not be reported or not reported at its
     source.  (found by Coverity)

   - bpo-41048(78): *note mimetypes.read_mime_types(): 18ad. function
     reads the rule file using UTF-8 encoding, not the locale encoding.
     Patch by Srinivas Reddy Thatiparthy.

   - bpo-41043(79): Fixed the use of *note glob(): 27f. in the stdlib:
     literal part of the path is now always correctly escaped.

   - bpo-41025(80): Fixed an issue preventing the C implementation of
     *note zoneinfo.ZoneInfo: 8ad. from being subclassed.

   - bpo-35018(81): Add the *note xml.sax.handler.LexicalHandler: 827.
     class that is present in other SAX XML implementations.

   - bpo-41002(82): Improve performance of HTTPResponse.read with a
     given amount.  Patch by Bruce Merry.

   - bpo-40448(83): *note ensurepip: 4b. now disables the use of ‘pip’
     cache when installing the bundled versions of ‘pip’ and
     ‘setuptools’.  Patch by Krzysztof Konopko.

   - bpo-40967(84): Removed ‘asyncio.Task.current_task()’ and
     ‘asyncio.Task.all_tasks()’.  Patch contributed by Rémi Lapeyre.

   - bpo-40924(85): Ensure ‘importlib.resources.path’ returns an extant
     path for the SourceFileLoader's resource reader.  Avoids the
     regression identified in master while a long-term solution is
     devised.

   - bpo-40955(86): Fix a minor memory leak in *note subprocess: c1.
     module when extra_groups was specified.

   - bpo-40855(87): The standard deviation and variance functions in the
     statistics module were ignoring their mu and xbar arguments.

   - bpo-40939(88): Use the new PEG parser when generating the stdlib
     *note keyword: 78. module.

   - bpo-23427(89): Add *note sys.orig_argv: 80b. attribute: the list of
     the original command line arguments passed to the Python
     executable.

   - bpo-33689(90): Ignore empty or whitespace-only lines in .pth files.
     This matches the documentated behavior.  Before, empty lines caused
     the site-packages dir to appear multiple times in sys.path.  By Ido
     Michael, contributors Malcolm Smith and Tal Einat.

   - bpo-40884(91): Added a ‘defaults’ parameter to *note
     logging.Formatter: 143a, to allow specifying default values for
     custom fields.  Patch by Asaf Alon and Bar Harel.

   - bpo-40876(92): Clarify error message in the *note csv: 21. module.

   - bpo-39791(93): Refresh importlib.metadata from importlib_metadata
     1.6.1.

   - bpo-40807(94): Stop codeop._maybe_compile, used by
     code.InteractiveInterpreter (and IDLE). from emitting each warning
     three times.

   - bpo-32604(95): Fix reference leak in the *note select: af. module
     when the module is imported in a subinterpreter.

   - bpo-39791(96): Built-in loaders (SourceFileLoader and ZipImporter)
     now supply ‘TraversableResources’ implementations for
     ‘ResourceReader’, and the fallback function has been removed.

   - bpo-39314(97): *note rlcompleter.Completer: 18ae. and the standard
     Python shell now close the parenthesis for functions that take no
     arguments.  Patch contributed by Rémi Lapeyre.

   - bpo-17005(98): The topological sort functionality that was
     introduced initially in the *note functools: 55. module has been
     moved to a new *note graphlib: 5b. module to better accommodate the
     new tools and keep the original scope of the *note functools: 55.
     module.  Patch by Pablo Galindo

   - bpo-40834(99): Fix truncate when sending str object
     with_xxsubinterpreters.channel_send.

   - bpo-40755(100): Add rich comparisons to collections.Counter().

   - bpo-26407(101): Unexpected errors in calling the ‘__iter__’ method
     are no longer masked by ‘TypeError’ in *note csv.reader(): 453,
     ‘csv.writer.writerow()’ and ‘csv.writer.writerows()’.

   - bpo-39384(102): Fixed email.contentmanager to allow set_content()
     to set a null string.

   - bpo-40744(103): The *note sqlite3: ba. module uses SQLite API
     functions that require SQLite v3.7.3 or higher.  This patch removes
     support for older SQLite versions, and explicitly requires SQLite
     3.7.3 both at build, compile and runtime.  Patch by Sergey Fedoseev
     and Erlend E. Aasland.

   - bpo-40777(104): Initialize PyDateTime_IsoCalendarDateType.tp_base
     at run-time to avoid errors on some compilers.

   - bpo-38488(105): Update ensurepip to install pip 20.1.1 and
     setuptools 47.1.0.

   - bpo-40792(106): The result of *note operator.index(): 1879. now
     always has exact type *note int: 238.  Previously, the result could
     have been an instance of a subclass of ‘int’.

   - bpo-40767(107): *note webbrowser: fd. now properly finds the
     default browser in pure Wayland systems by checking the
     WAYLAND_DISPLAY environment variable.  Patch contributed by Jérémy
     Attali.

   - bpo-40791(108): ‘hashlib.compare_digest()’ uses OpenSSL's
     ‘CRYPTO_memcmp()’ function when OpenSSL is available.

   - bpo-40795(109): *note ctypes: 22. module: If ctypes fails to
     convert the result of a callback or if a ctypes callback function
     raises an exception, sys.unraisablehook is now called with an
     exception set.  Previously, the error was logged into stderr by
     *note PyErr_Print(): 18af.

   - bpo-16995(110): Add *note base64.b32hexencode(): 7ae. and *note
     base64.b32hexdecode(): 7af. to support the Base32 Encoding with
     Extended Hex Alphabet.

   - bpo-30008(111): Fix *note ssl: bb. code to be compatible with
     OpenSSL 1.1.x builds that use ‘no-deprecated’ and ‘--api=1.1.0’.

   - bpo-30064(112): Fix asyncio ‘loop.sock_*’ race condition issue

   - bpo-40759(113): Deprecate the ‘symbol’ module.

   - bpo-40756(114): The second argument (extra) of
     ‘LoggerAdapter.__init__’ now defaults to None.

   - bpo-37129(115): Add a new *note os.RWF_APPEND: 18b0. flag for *note
     os.pwritev(): b2e.

   - bpo-40737(116): Fix possible reference leak for *note sqlite3: ba.
     initialization.

   - bpo-40726(117): Handle cases where the ‘end_lineno’ is ‘None’ on
     *note ast.increment_lineno(): 1701.

   - bpo-40698(118): ‘distutils’ upload creates SHA2-256 and Blake2b-256
     digests.  MD5 digests is skipped if platform blocks MD5.

   - bpo-40695(119): *note hashlib: 5e. no longer falls back to builtin
     hash implementations when OpenSSL provides a hash digest and the
     algorithm is blocked by security policy.

   - bpo-9216(120): *note hashlib.new(): 18b1. passed ‘usedforsecurity’
     to OpenSSL EVP constructor ‘_hashlib.new()’.  test_hashlib and
     test_smtplib handle strict security policy better.

   - bpo-40614(121): *note ast.parse(): 18d. will not parse self
     documenting expressions in f-strings when passed ‘feature_version’
     is less than ‘(3, 8)’.

   - bpo-40626(122): Add h5 file extension as MIME Type
     application/x-hdf5, as per HDF Group recommendation for HDF5
     formatted data files.  Patch contributed by Mark Schwab.

   - bpo-25920(123): On macOS, when building Python for macOS 10.4 and
     older, which wasn't the case for python.org macOS installer, *note
     socket.getaddrinfo(): 16bd. no longer uses an internal lock to
     prevent race conditions when calling ‘getaddrinfo()’ which is
     thread-safe since macOS 10.5.  Python 3.9 requires macOS 10.6 or
     newer.  The internal lock caused random hang on fork when another
     thread was calling *note socket.getaddrinfo(): 16bd.  The lock was
     also used on FreeBSD older than 5.3, OpenBSD older than 201311 and
     NetBSD older than 4.

   - bpo-40671(124): Prepare ‘_hashlib’ for PEP 489(125) and use *note
     PyModule_AddType(): 943.

   - bpo-32309(126): Added a new *note coroutine: 45e. *note
     asyncio.to_thread(): 8b6.  It is mainly used for running IO-bound
     functions in a separate thread to avoid blocking the event loop,
     and essentially works as a high-level version of *note
     run_in_executor(): 8b7. that can directly take keyword arguments.

   - bpo-36543(127): Restored the deprecated ‘xml.etree.cElementTree’
     module.

   - bpo-40611(128): *note MAP_POPULATE: 18b2. constant has now been
     added to the list of exported *note mmap: 83. module flags.

   - bpo-39881(129): PEP 554 for use in the test suite.  (Patch By
     Joannah Nanjekye)

   - bpo-13097(130): ‘ctypes’ now raises an ‘ArgumentError’ when a
     callback is invoked with more than 1024 arguments.

   - bpo-39385(131): A new test assertion context-manager,
     ‘unittest.assertNoLogs()’ will ensure a given block of code emits
     no log messages using the logging module.  Contributed by Kit Yan
     Choi.

   - bpo-23082(132): Updated the error message and docs of
     PurePath.relative_to() to better reflect the function behaviour.

   - bpo-40318(133): Use SQLite3 trace v2 API, if it is available.

   - bpo-40105(134): ZipFile truncates files to avoid corruption when a
     shorter comment is provided in append ("a") mode.  Patch by Jan
     Mazur.

   - bpo-40084(135): Fix ‘Enum.__dir__’: dir(Enum.member) now includes
     attributes as well as methods.

   - bpo-31122(136): ssl.wrap_socket() now raises ssl.SSLEOFError rather
     than OSError when peer closes connection during TLS negotiation

   - bpo-39728(137): fix default ‘_missing_’ so a duplicate ‘ValueError’
     is not set as the ‘__context__’ of the original ‘ValueError’.

   - bpo-39244(138): Fixed
     ‘multiprocessing.context.get_all_start_methods’ to properly return
     the default method first on macOS.

   - bpo-39040(139): Fix parsing of invalid mime headers parameters by
     collapsing whitespace between encoded words in a bare-quote-string.

   - bpo-38731(140): Add ‘--quiet’ option to command-line interface of
     *note py_compile: a1.  Patch by Gregory Schevchenko.

   - bpo-35714(141): *note struct.error: 12f2. is now raised if there is
     a null character in a *note struct: c0. format string.

   - bpo-38144(142): Added the 'root_dir' and 'dir_fd' parameters in
     *note glob.glob(): 27f.

   - bpo-26543(143): Fix ‘IMAP4.noop()’ when debug mode is enabled (ex:
     ‘imaplib.Debug = 3’).

   - bpo-12178(144): *note csv.writer(): 454. now correctly escapes
     'escapechar' when input contains 'escapechar'.  Patch by Catalin
     Iacob, Berker Peksag, and Itay Elbirt.

   - bpo-36290(145): AST nodes are now raising *note TypeError: 502. on
     conflicting keyword arguments.  Patch contributed by Rémi Lapeyre.

   - bpo-33944(146): Added site.py site-packages tracing in verbose
     mode.

   - bpo-35078(147): Refactor formatweekday, formatmonthname methods in
     LocaleHTMLCalendar and LocaleTextCalendar classes in calendar
     module to call the base class methods.This enables customizable CSS
     classes for LocaleHTMLCalendar.  Patch by Srinivas Reddy
     Thatiparthy

   - bpo-29620(148): *note assertWarns(): 1137. no longer raises a
     ‘RuntimeException’ when accessing a module's ‘__warningregistry__’
     causes importation of a new module, or when a new module is
     imported in another thread.  Patch by Kernc.

   - bpo-31844(149): Remove ‘ParserBase.error()’ method from the private
     and undocumented ‘_markupbase’ module.  *note
     html.parser.HTMLParser: 843. is the only subclass of ‘ParserBase’
     and its ‘error()’ implementation was deprecated in Python 3.4 and
     removed in Python 3.5.

   - bpo-34226(150): Fix ‘cgi.parse_multipart’ without content_length.
     Patch by Roger Duran

   - bpo-33660(151): Fix pathlib.PosixPath to resolve a relative path
     located on the root directory properly.

   - bpo-28557(152): Improve the error message for a misbehaving
     ‘rawio.readinto’

   - bpo-26680(153): The d.is_integer() method is added to the Decimal
     type, for compatibility with other number types.

   - bpo-26680(154): The x.is_integer() method is incorporated into the
     abstract types of the numeric tower, Real, Rational and Integral,
     with appropriate default implementations.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41900

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41887

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41773

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41840

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41842

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40564

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40670

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41833

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41817

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41810

   (11) https://bugs.python.org/issue?@action=redirect&bpo=41815

   (12) https://bugs.python.org/issue?@action=redirect&bpo=41816

   (13) https://bugs.python.org/issue?@action=redirect&bpo=41517

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39587

   (15) https://bugs.python.org/issue?@action=redirect&bpo=41792

   (16) https://github.com/python/typing/issues/751

   (17) https://bugs.python.org/issue?@action=redirect&bpo=41789

   (18) https://bugs.python.org/issue?@action=redirect&bpo=32218

   (19) https://bugs.python.org/issue?@action=redirect&bpo=39651

   (20) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (21) https://peps.python.org/pep-0489/

   (22) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (23) https://peps.python.org/pep-0489/

   (24) https://bugs.python.org/issue?@action=redirect&bpo=41732

   (25) https://bugs.python.org/issue?@action=redirect&bpo=41720

   (26) https://bugs.python.org/issue?@action=redirect&bpo=41696

   (27) https://bugs.python.org/issue?@action=redirect&bpo=41687

   (28) https://bugs.python.org/issue?@action=redirect&bpo=41662

   (29) https://bugs.python.org/issue?@action=redirect&bpo=39010

   (30) https://bugs.python.org/issue?@action=redirect&bpo=41638

   (31) https://bugs.python.org/issue?@action=redirect&bpo=41662

   (32) https://bugs.python.org/issue?@action=redirect&bpo=41513

   (33) https://bugs.python.org/issue?@action=redirect&bpo=41609

   (34) https://bugs.python.org/issue?@action=redirect&bpo=39994

   (35) https://bugs.python.org/issue?@action=redirect&bpo=32751

   (36) https://bugs.python.org/issue?@action=redirect&bpo=37658

   (37) https://bugs.python.org/issue?@action=redirect&bpo=40782

   (38) https://bugs.python.org/issue?@action=redirect&bpo=41520

   (39) https://bugs.python.org/issue?@action=redirect&bpo=41528

   (40) https://bugs.python.org/issue?@action=redirect&bpo=41513

   (41) https://bugs.python.org/issue?@action=redirect&bpo=41503

   (42) https://bugs.python.org/issue?@action=redirect&bpo=41497

   (43) https://bugs.python.org/issue?@action=redirect&bpo=41467

   (44) https://bugs.python.org/issue?@action=redirect&bpo=41425

   (45) https://bugs.python.org/issue?@action=redirect&bpo=41421

   (46) https://bugs.python.org/issue?@action=redirect&bpo=41440

   (47) https://bugs.python.org/issue?@action=redirect&bpo=41316

   (48) https://bugs.python.org/issue?@action=redirect&bpo=41384

   (49) https://bugs.python.org/issue?@action=redirect&bpo=41317

   (50) https://bugs.python.org/issue?@action=redirect&bpo=41364

   (51) https://bugs.python.org/issue?@action=redirect&bpo=35328

   (52) https://bugs.python.org/issue?@action=redirect&bpo=41341

   (53) https://bugs.python.org/issue?@action=redirect&bpo=41344

   (54) https://bugs.python.org/issue?@action=redirect&bpo=41333

   (55) https://bugs.python.org/issue?@action=redirect&bpo=41288

   (56) https://bugs.python.org/issue?@action=redirect&bpo=39017

   (57) https://www.cve.org/CVERecord?id=CVE-2019-20907

   (58) https://bugs.python.org/issue?@action=redirect&bpo=41273

   (59) https://bugs.python.org/issue?@action=redirect&bpo=41235

   (60) https://bugs.python.org/issue?@action=redirect&bpo=41207

   (61) https://bugs.python.org/issue?@action=redirect&bpo=29727

   (62) https://bugs.python.org/issue?@action=redirect&bpo=39168

   (63) https://bugs.python.org/issue?@action=redirect&bpo=41194

   (64) https://bugs.python.org/issue?@action=redirect&bpo=41195

   (65) https://bugs.python.org/issue?@action=redirect&bpo=41193

   (66) https://bugs.python.org/issue?@action=redirect&bpo=41182

   (67) https://bugs.python.org/issue?@action=redirect&bpo=41161

   (68) https://bugs.python.org/issue?@action=redirect&bpo=40874

   (69) https://bugs.python.org/issue?@action=redirect&bpo=41138

   (70) https://bugs.python.org/issue?@action=redirect&bpo=31082

   (71) https://bugs.python.org/issue?@action=redirect&bpo=40521

   (72) https://bugs.python.org/issue?@action=redirect&bpo=31938

   (73) https://bugs.python.org/issue?@action=redirect&bpo=41068

   (74) https://bugs.python.org/issue?@action=redirect&bpo=41058

   (75) https://bugs.python.org/issue?@action=redirect&bpo=41056

   (76) https://bugs.python.org/issue?@action=redirect&bpo=41056

   (77) https://bugs.python.org/issue?@action=redirect&bpo=41056

   (78) https://bugs.python.org/issue?@action=redirect&bpo=41048

   (79) https://bugs.python.org/issue?@action=redirect&bpo=41043

   (80) https://bugs.python.org/issue?@action=redirect&bpo=41025

   (81) https://bugs.python.org/issue?@action=redirect&bpo=35018

   (82) https://bugs.python.org/issue?@action=redirect&bpo=41002

   (83) https://bugs.python.org/issue?@action=redirect&bpo=40448

   (84) https://bugs.python.org/issue?@action=redirect&bpo=40967

   (85) https://bugs.python.org/issue?@action=redirect&bpo=40924

   (86) https://bugs.python.org/issue?@action=redirect&bpo=40955

   (87) https://bugs.python.org/issue?@action=redirect&bpo=40855

   (88) https://bugs.python.org/issue?@action=redirect&bpo=40939

   (89) https://bugs.python.org/issue?@action=redirect&bpo=23427

   (90) https://bugs.python.org/issue?@action=redirect&bpo=33689

   (91) https://bugs.python.org/issue?@action=redirect&bpo=40884

   (92) https://bugs.python.org/issue?@action=redirect&bpo=40876

   (93) https://bugs.python.org/issue?@action=redirect&bpo=39791

   (94) https://bugs.python.org/issue?@action=redirect&bpo=40807

   (95) https://bugs.python.org/issue?@action=redirect&bpo=32604

   (96) https://bugs.python.org/issue?@action=redirect&bpo=39791

   (97) https://bugs.python.org/issue?@action=redirect&bpo=39314

   (98) https://bugs.python.org/issue?@action=redirect&bpo=17005

   (99) https://bugs.python.org/issue?@action=redirect&bpo=40834

   (100) https://bugs.python.org/issue?@action=redirect&bpo=40755

   (101) https://bugs.python.org/issue?@action=redirect&bpo=26407

   (102) https://bugs.python.org/issue?@action=redirect&bpo=39384

   (103) https://bugs.python.org/issue?@action=redirect&bpo=40744

   (104) https://bugs.python.org/issue?@action=redirect&bpo=40777

   (105) https://bugs.python.org/issue?@action=redirect&bpo=38488

   (106) https://bugs.python.org/issue?@action=redirect&bpo=40792

   (107) https://bugs.python.org/issue?@action=redirect&bpo=40767

   (108) https://bugs.python.org/issue?@action=redirect&bpo=40791

   (109) https://bugs.python.org/issue?@action=redirect&bpo=40795

   (110) https://bugs.python.org/issue?@action=redirect&bpo=16995

   (111) https://bugs.python.org/issue?@action=redirect&bpo=30008

   (112) https://bugs.python.org/issue?@action=redirect&bpo=30064

   (113) https://bugs.python.org/issue?@action=redirect&bpo=40759

   (114) https://bugs.python.org/issue?@action=redirect&bpo=40756

   (115) https://bugs.python.org/issue?@action=redirect&bpo=37129

   (116) https://bugs.python.org/issue?@action=redirect&bpo=40737

   (117) https://bugs.python.org/issue?@action=redirect&bpo=40726

   (118) https://bugs.python.org/issue?@action=redirect&bpo=40698

   (119) https://bugs.python.org/issue?@action=redirect&bpo=40695

   (120) https://bugs.python.org/issue?@action=redirect&bpo=9216

   (121) https://bugs.python.org/issue?@action=redirect&bpo=40614

   (122) https://bugs.python.org/issue?@action=redirect&bpo=40626

   (123) https://bugs.python.org/issue?@action=redirect&bpo=25920

   (124) https://bugs.python.org/issue?@action=redirect&bpo=40671

   (125) https://peps.python.org/pep-0489/

   (126) https://bugs.python.org/issue?@action=redirect&bpo=32309

   (127) https://bugs.python.org/issue?@action=redirect&bpo=36543

   (128) https://bugs.python.org/issue?@action=redirect&bpo=40611

   (129) https://bugs.python.org/issue?@action=redirect&bpo=39881

   (130) https://bugs.python.org/issue?@action=redirect&bpo=13097

   (131) https://bugs.python.org/issue?@action=redirect&bpo=39385

   (132) https://bugs.python.org/issue?@action=redirect&bpo=23082

   (133) https://bugs.python.org/issue?@action=redirect&bpo=40318

   (134) https://bugs.python.org/issue?@action=redirect&bpo=40105

   (135) https://bugs.python.org/issue?@action=redirect&bpo=40084

   (136) https://bugs.python.org/issue?@action=redirect&bpo=31122

   (137) https://bugs.python.org/issue?@action=redirect&bpo=39728

   (138) https://bugs.python.org/issue?@action=redirect&bpo=39244

   (139) https://bugs.python.org/issue?@action=redirect&bpo=39040

   (140) https://bugs.python.org/issue?@action=redirect&bpo=38731

   (141) https://bugs.python.org/issue?@action=redirect&bpo=35714

   (142) https://bugs.python.org/issue?@action=redirect&bpo=38144

   (143) https://bugs.python.org/issue?@action=redirect&bpo=26543

   (144) https://bugs.python.org/issue?@action=redirect&bpo=12178

   (145) https://bugs.python.org/issue?@action=redirect&bpo=36290

   (146) https://bugs.python.org/issue?@action=redirect&bpo=33944

   (147) https://bugs.python.org/issue?@action=redirect&bpo=35078

   (148) https://bugs.python.org/issue?@action=redirect&bpo=29620

   (149) https://bugs.python.org/issue?@action=redirect&bpo=31844

   (150) https://bugs.python.org/issue?@action=redirect&bpo=34226

   (151) https://bugs.python.org/issue?@action=redirect&bpo=33660

   (152) https://bugs.python.org/issue?@action=redirect&bpo=28557

   (153) https://bugs.python.org/issue?@action=redirect&bpo=26680

   (154) https://bugs.python.org/issue?@action=redirect&bpo=26680


File: python.info,  Node: Documentation<33>,  Next: Tests<36>,  Prev: Library<38>,  Up: Python 3 10 0 alpha 1

1.23.39.4 Documentation
.......................

   - bpo-41428(1): Add documentation for PEP 604(2) (Allow writing union
     types as ‘X | Y’).

   - bpo-41774(3): In Programming FAQ "Sequences (Tuples/Lists)"
     section, add "How do you remove multiple items from a list".

   - bpo-35293(4): Fix RemovedInSphinx40Warning when building the
     documentation.  Patch by Donghee Na.

   - bpo-37149(5): Change Shipman tkinter doc link from archive.org to
     TkDocs.  (The doc has been removed from the NMT server.)  The new
     link responds much faster and includes a short explanatory note.

   - bpo-41726(6): Update the refcounts info of
     ‘PyType_FromModuleAndSpec’.

   - bpo-41624(7): Fix the signature of *note typing.Coroutine: 18b4.

   - bpo-40204(8): Enable Sphinx 3.2 ‘c_allow_pre_v3’ option and disable
     ‘c_warn_on_allowed_pre_v3’ option to make the documentation
     compatible with Sphinx 2 and Sphinx 3.

   - bpo-41045(9): Add documentation for debug feature of f-strings.

   - bpo-41314(10): Changed the release when ‘from __future__ import
     annotations’ becomes the default from ‘4.0’ to ‘3.10’ (following a
     change in PEP 563).

   - bpo-40979(11): Refactored typing.rst, arranging more than 70
     classes, functions, and decorators into new sub-sections.

   - bpo-40552(12): Fix in tutorial section 4.2.  Code snippet is now
     correct.

   - bpo-39883(13): Make code, examples, and recipes in the Python
     documentation be licensed under the more permissive BSD0 license in
     addition to the existing Python 2.0 license.

   - bpo-37703(14): Updated Documentation to comprehensively elaborate
     on the behaviour of gather.cancel()

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41428

   (2) https://peps.python.org/pep-0604/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41774

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35293

   (5) https://bugs.python.org/issue?@action=redirect&bpo=37149

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41726

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41624

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40204

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41045

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41314

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40979

   (12) https://bugs.python.org/issue?@action=redirect&bpo=40552

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39883

   (14) https://bugs.python.org/issue?@action=redirect&bpo=37703


File: python.info,  Node: Tests<36>,  Next: Build<38>,  Prev: Documentation<33>,  Up: Python 3 10 0 alpha 1

1.23.39.5 Tests
...............

   - bpo-41939(1): Fix test_site.test_license_exists_at_url(): call
     ‘urllib.request.urlcleanup()’ to reset the global
     ‘urllib.request._opener’.  Patch by Victor Stinner.

   - bpo-41731(2): Make test_cmd_line_script pass with option '-vv'.

   - bpo-41602(3): Add tests for SIGINT handling in the runpy module.

   - bpo-41521(4): *note test.support: cd.: Rename ‘blacklist’ parameter
     of *note check__all__(): 18b6. to ‘not_exported’.

   - bpo-41477(5): Make ctypes optional in test_genericalias.

   - bpo-41085(6): Fix integer overflow in the *note
     array.array.index(): 7ab. method on 64-bit Windows for index larger
     than ‘2**31’.

   - bpo-41069(7): ‘test.support.TESTFN’ and the current directory for
     tests when run via ‘test.regrtest’ contain now non-ascii characters
     if possible.

   - bpo-38377(8): On Linux, skip tests using multiprocessing if the
     current user cannot create a file in ‘/dev/shm/’ directory.  Add
     the *note skip_if_broken_multiprocessing_synchronize(): 18b7.
     function to the *note test.support: cd. module.

   - bpo-41009(9): Fix use of
     ‘support.require_{linux|mac|freebsd}_version()’ decorators as class
     decorator.

   - bpo-41003(10): Fix ‘test_copyreg’ when ‘numpy’ is installed:
     ‘test.pickletester’ now saves/restores warnings filters when
     importing ‘numpy’, to ignore filters installed by ‘numpy’.

   - bpo-40964(11): Disable remote *note imaplib: 6a. tests, host
     cyrus.andrew.cmu.edu is blocking incoming connections.

   - bpo-40927(12): Fix test_binhex when run twice: it now uses
     import_fresh_module() to ensure that it raises DeprecationWarning
     each time.

   - bpo-17258(13): Skip some *note multiprocessing: 86. tests when MD5
     hash digest is blocked.

   - bpo-31904(14): Increase LOOPBACK_TIMEOUT to 10 for VxWorks RTOS.

   - bpo-38169(15): Increase code coverage for SharedMemory and
     ShareableList

   - bpo-34401(16): Make test_gdb properly run on HP-UX. Patch by
     Michael Osipov.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41939

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41731

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41602

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41521

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41477

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41085

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41069

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38377

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41009

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41003

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40964

   (12) https://bugs.python.org/issue?@action=redirect&bpo=40927

   (13) https://bugs.python.org/issue?@action=redirect&bpo=17258

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (15) https://bugs.python.org/issue?@action=redirect&bpo=38169

   (16) https://bugs.python.org/issue?@action=redirect&bpo=34401


File: python.info,  Node: Build<38>,  Next: Windows<34>,  Prev: Tests<36>,  Up: Python 3 10 0 alpha 1

1.23.39.6 Build
...............

   - bpo-38249(1): Update *note Py_UNREACHABLE: b83. to use
     __builtin_unreachable() if only the compiler is able to use it.
     Patch by Donghee Na.

   - bpo-41617(2): Fix ‘pycore_bitutils.h’ header file to support old
     clang versions: ‘__builtin_bswap16()’ is not available in LLVM
     clang 3.0.

   - bpo-40204(3): Pin Sphinx version to 2.3.1 in ‘Doc/Makefile’.

   - bpo-36020(4): The C99 functions ‘snprintf()’ and ‘vsnprintf()’ are
     now required to build Python.

   - bpo-40684(5): ‘make install’ now uses the ‘PLATLIBDIR’ variable for
     the destination ‘lib-dynload/’ directory when ‘./configure
     --with-platlibdir’ is used.

   - bpo-40683(6): Fixed an issue where the *note zoneinfo: 11a. module
     and its tests were not included when Python is installed with
     ‘make’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38249

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41617

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40204

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36020

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40684

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40683


File: python.info,  Node: Windows<34>,  Next: macOS<29>,  Prev: Build<38>,  Up: Python 3 10 0 alpha 1

1.23.39.7 Windows
.................

   - bpo-41744(1): Fixes automatic import of props file when using the
     Nuget package.

   - bpo-41627(2): The user site directory for 32-bit now includes a
     ‘-32’ suffix to distinguish it from the 64-bit interpreter's
     directory.

   - bpo-41526(3): Fixed layout of final page of the installer by
     removing the special thanks to Mark Hammond (with his permission).

   - bpo-41492(4): Fixes the description that appears in UAC prompts.

   - bpo-40948(5): Improve post-install message to direct people to the
     "py" command.

   - bpo-41412(6): The installer will now fail to install on Windows 7
     and Windows 8.  Further, the UCRT dependency is now always
     downloaded on demand.

   - bpo-40741(7): Update Windows release to include SQLite 3.32.3.

   - bpo-41142(8): ‘msilib’ now supports creating CAB files with
     non-ASCII file path and adding files with non-ASCII file path to
     them.

   - bpo-41074(9): Fixed support of non-ASCII names in functions
     ‘msilib.OpenDatabase()’ and ‘msilib.init_database()’ and non-ASCII
     SQL in method ‘msilib.Database.OpenView()’.

   - bpo-41039(10): Stable ABI redirection DLL (python3.dll) now uses
     ‘#pragma comment(linker)’ for re-exporting.

   - bpo-40164(11): Updates Windows OpenSSL to 1.1.1g

   - bpo-39631(12): Changes the registered MIME type for ‘.py’ files on
     Windows to ‘text/x-python’ instead of ‘text/plain’.

   - bpo-40677(13): Manually define IO_REPARSE_TAG_APPEXECLINK in case
     some old Windows SDK doesn't have it.

   - bpo-37556(14): Extend py.exe help to mention overrides via venv,
     shebang, environmental variables & ini files.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41744

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41627

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41526

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41492

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40948

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41412

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40741

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41142

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41074

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41039

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40164

   (12) https://bugs.python.org/issue?@action=redirect&bpo=39631

   (13) https://bugs.python.org/issue?@action=redirect&bpo=40677

   (14) https://bugs.python.org/issue?@action=redirect&bpo=37556


File: python.info,  Node: macOS<29>,  Next: IDLE<26>,  Prev: Windows<34>,  Up: Python 3 10 0 alpha 1

1.23.39.8 macOS
...............

   - bpo-41557(1): Update macOS installer to use SQLite 3.33.0.

   - bpo-39580(2): Avoid opening Finder window if running installer from
     the command line.  Patch contributed by Rick Heil.

   - bpo-41100(3): Fix configure error when building on macOS 11.  Note
     that the current Python release was released shortly after the
     first developer preview of macOS 11 (Big Sur); there are other
     known issues with building and running on the developer preview.
     Big Sur is expected to be fully supported in a future bugfix
     release of Python 3.8.x and with 3.9.0.

   - bpo-40741(4): Update macOS installer to use SQLite 3.32.3.

   - bpo-41005(5): fixed an XDG settings issue not allowing macos to
     open browser in webbrowser.py

   - bpo-40741(6): Update macOS installer to use SQLite 3.32.2.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41557

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39580

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41100

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40741

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41005

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40741


File: python.info,  Node: IDLE<26>,  Next: C API<37>,  Prev: macOS<29>,  Up: Python 3 10 0 alpha 1

1.23.39.9 IDLE
..............

   - bpo-41775(1): Use 'IDLE Shell' as shell title

   - bpo-35764(2): Rewrite the Calltips doc section.

   - bpo-40181(3): In calltips, stop reminding that '/' marks the end of
     positional-only arguments.

   - bpo-41468(4): Improve IDLE run crash error message (which users
     should never see).

   - bpo-41373(5): Save files loaded with no line ending, as when blank,
     or different line endings, by setting its line ending to the system
     default.  Fix regression in 3.8.4 and 3.9.0b4.

   - bpo-41300(6): Save files with non-ascii chars.  Fix regression
     released in 3.9.0b4 and 3.8.4.

   - bpo-37765(7): Add keywords to module name completion list.  Rewrite
     Completions section of IDLE doc.

   - bpo-41152(8): The encoding of ‘stdin’, ‘stdout’ and ‘stderr’ in
     IDLE is now always UTF-8.

   - bpo-41144(9): Make Open Module open a special module such as
     os.path.

   - bpo-39885(10): Make context menu Cut and Copy work again when
     right-clicking within a selection.

   - bpo-40723(11): Make test_idle pass when run after import.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41775

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35764

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40181

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41468

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41373

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41300

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37765

   (8) https://bugs.python.org/issue?@action=redirect&bpo=41152

   (9) https://bugs.python.org/issue?@action=redirect&bpo=41144

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39885

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40723


File: python.info,  Node: C API<37>,  Prev: IDLE<26>,  Up: Python 3 10 0 alpha 1

1.23.39.10 C API
................

   - bpo-41936(1): Removed undocumented macros ‘Py_ALLOW_RECURSION’ and
     ‘Py_END_ALLOW_RECURSION’ and the ‘recursion_critical’ field of the
     *note PyInterpreterState: 88b. structure.

   - bpo-41692(2): The ‘PyUnicode_InternImmortal()’ function is now
     deprecated and will be removed in Python 3.12: use *note
     PyUnicode_InternInPlace(): 87f. instead.  Patch by Victor Stinner.

   - bpo-41842(3): Add *note PyCodec_Unregister(): 864. function to
     unregister a codec search function.

   - bpo-41834(4): Remove the ‘_Py_CheckRecursionLimit’ variable: it has
     been replaced by ‘ceval.recursion_limit’ of the *note
     PyInterpreterState: 88b. structure.  Patch by Victor Stinner.

   - bpo-41689(5): Types created with *note PyType_FromSpec(): 549. now
     make any signature in their ‘tp_doc’ slot accessible from
     ‘__text_signature__’.

   - bpo-41524(6): Fix bug in PyOS_mystrnicmp and PyOS_mystricmp that
     incremented pointers beyond the end of a string.

   - bpo-41324(7): Add a minimal decimal capsule API. The API supports
     fast conversions between Decimals up to 38 digits and their triple
     representation as a C struct.

   - bpo-30155(8): Add *note PyDateTime_DATE_GET_TZINFO(): 862. and
     *note PyDateTime_TIME_GET_TZINFO(): 863. macros for accessing the
     ‘tzinfo’ attributes of *note datetime.datetime: 1ae. and *note
     datetime.time: 1b0. objects.

   - bpo-40170(9): Revert *note PyType_HasFeature(): 18bd. change: it
     reads again directly the *note PyTypeObject.tp_flags: 1828. member
     when the limited C API is not used, rather than always calling
     *note PyType_GetFlags(): 18be. which hides implementation details.

   - bpo-41123(10): Remove ‘PyUnicode_AsUnicodeCopy’.

   - bpo-41123(11): Removed ‘PyLong_FromUnicode()’.

   - bpo-41123(12): Removed ‘PyUnicode_GetMax()’.

   - bpo-41123(13): Removed ‘Py_UNICODE_str*’ functions manipulating
     ‘Py_UNICODE*’ strings.

   - bpo-41103(14): ‘PyObject_AsCharBuffer()’,
     ‘PyObject_AsReadBuffer()’, ‘PyObject_CheckReadBuffer()’, and
     ‘PyObject_AsWriteBuffer()’ are removed.  Please migrate to new
     buffer protocol; *note PyObject_GetBuffer(): 373. and *note
     PyBuffer_Release(): 374.

   - bpo-36346(15): Raises DeprecationWarning for
     ‘PyUnicode_FromUnicode(NULL, size)’ and
     ‘PyUnicode_FromStringAndSize(NULL, size)’ with ‘size > 0’.

   - bpo-36346(16): Mark ‘Py_UNICODE_COPY’, ‘Py_UNICODE_FILL’,
     ‘PyUnicode_WSTR_LENGTH’, ‘PyUnicode_FromUnicode’,
     ‘PyUnicode_AsUnicode’, and ‘PyUnicode_AsUnicodeAndSize’ as
     deprecated in C. Remove ‘Py_UNICODE_MATCH’ which was deprecated and
     broken since Python 3.3.

   - bpo-40989(17): The ‘PyObject_INIT()’ and ‘PyObject_INIT_VAR()’
     macros become aliases to, respectively, *note PyObject_Init(): a38.
     and *note PyObject_InitVar(): 18bf. functions.

   - bpo-36020(18): On Windows, ‘#include "pyerrors.h"’ no longer
     defines ‘snprintf’ and ‘vsnprintf’ macros.

   - bpo-40943(19): The ‘PY_SSIZE_T_CLEAN’ macro must now be defined to
     use *note PyArg_ParseTuple(): 53d. and *note Py_BuildValue(): 875.
     formats which use ‘#’: ‘es#’, ‘et#’, ‘s#’, ‘u#’, ‘y#’, ‘z#’, ‘U#’
     and ‘Z#’.  See *note Parsing arguments and building values: 876.
     and the PEP 353(20).

   - bpo-40910(21): Export explicitly the *note Py_GetArgcArgv(): 18c0.
     function to the C API and document the function.  Previously, it
     was exported implicitly which no longer works since Python is built
     with ‘-fvisibility=hidden’.

   - bpo-40724(22): Allow defining buffer slots in type specs.

   - bpo-40679(23): Fix a ‘_PyEval_EvalCode()’ crash if 'qualname'
     argument is NULL.

   - bpo-40839(24): Calling *note PyDict_GetItem(): 360. without *note
     GIL: 13f. held had been allowed for historical reason.  It is no
     longer allowed.

   - bpo-40826(25): ‘PyOS_InterruptOccurred()’ now fails with a fatal
     error if it is called with the GIL released.

   - bpo-40792(26): The result of *note PyNumber_Index(): 860. now
     always has exact type *note int: 238.  Previously, the result could
     have been an instance of a subclass of ‘int’.

   - bpo-39573(27): Convert *note Py_REFCNT(): 877. and *note Py_SIZE():
     74d. macros to static inline functions.  They cannot be used as
     l-value anymore: use *note Py_SET_REFCNT(): 878. and *note
     Py_SET_SIZE(): 74e. to set an object reference count and size.
     This change is backward incompatible on purpose, to prepare the C
     API for an opaque *note PyObject: 312. structure.

   - bpo-40703(28): The PyType_FromSpec*() functions no longer overwrite
     the type's "__module__" attribute if it is set via "Py_tp_members"
     or "Py_tp_getset".

   - bpo-39583(29): Remove superfluous "extern C" declarations from
     ‘Include/cpython/*.h’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=41936

   (2) https://bugs.python.org/issue?@action=redirect&bpo=41692

   (3) https://bugs.python.org/issue?@action=redirect&bpo=41842

   (4) https://bugs.python.org/issue?@action=redirect&bpo=41834

   (5) https://bugs.python.org/issue?@action=redirect&bpo=41689

   (6) https://bugs.python.org/issue?@action=redirect&bpo=41524

   (7) https://bugs.python.org/issue?@action=redirect&bpo=41324

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30155

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (10) https://bugs.python.org/issue?@action=redirect&bpo=41123

   (11) https://bugs.python.org/issue?@action=redirect&bpo=41123

   (12) https://bugs.python.org/issue?@action=redirect&bpo=41123

   (13) https://bugs.python.org/issue?@action=redirect&bpo=41123

   (14) https://bugs.python.org/issue?@action=redirect&bpo=41103

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36346

   (16) https://bugs.python.org/issue?@action=redirect&bpo=36346

   (17) https://bugs.python.org/issue?@action=redirect&bpo=40989

   (18) https://bugs.python.org/issue?@action=redirect&bpo=36020

   (19) https://bugs.python.org/issue?@action=redirect&bpo=40943

   (20) https://peps.python.org/pep-0353/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=40910

   (22) https://bugs.python.org/issue?@action=redirect&bpo=40724

   (23) https://bugs.python.org/issue?@action=redirect&bpo=40679

   (24) https://bugs.python.org/issue?@action=redirect&bpo=40839

   (25) https://bugs.python.org/issue?@action=redirect&bpo=40826

   (26) https://bugs.python.org/issue?@action=redirect&bpo=40792

   (27) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (28) https://bugs.python.org/issue?@action=redirect&bpo=40703

   (29) https://bugs.python.org/issue?@action=redirect&bpo=39583


File: python.info,  Node: Python 3 9 0 beta 1,  Next: Python 3 9 0 alpha 6,  Prev: Python 3 10 0 alpha 1,  Up: 変更履歴

1.23.40 Python 3.9.0 beta 1
---------------------------

'Release date: 2020-05-19'

* Menu:

* Security: Security<25>.
* Core and Builtins: Core and Builtins<40>.
* Library: Library<39>.
* Documentation: Documentation<34>.
* Tests: Tests<37>.
* Build: Build<39>.
* Windows: Windows<35>.
* macOS: macOS<30>.
* Tools/Demos: Tools/Demos<17>.
* C API: C API<38>.


File: python.info,  Node: Security<25>,  Next: Core and Builtins<40>,  Up: Python 3 9 0 beta 1

1.23.40.1 Security
..................

   - bpo-40501(1): *note uuid: f8. no longer uses *note ctypes: 22. to
     load ‘libuuid’ or ‘rpcrt4.dll’ at runtime.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40501


File: python.info,  Node: Core and Builtins<40>,  Next: Library<39>,  Prev: Security<25>,  Up: Python 3 9 0 beta 1

1.23.40.2 Core and Builtins
...........................

   - bpo-40663(1): Correctly generate annotations where parentheses are
     omitted but required (e.g: ‘Type[(str, int, *other))]’.

   - bpo-40596(2): Fixed *note str.isidentifier(): 18c4. for
     non-canonicalized strings containing non-BMP characters on Windows.

   - bpo-40593(3): Improved syntax errors for invalid characters in
     source code.

   - bpo-40585(4): Fixed a bug when using *note
     codeop.compile_command(): 1733. that was causing exceptions to be
     swallowed with the new parser.  Patch by Pablo Galindo

   - bpo-40566(5): Apply PEP 573(6) to *note abc: 4.

   - bpo-40502(7): Initialize ‘n->n_col_offset’.  (Patch by Joannah
     Nanjekye)

   - bpo-40527(8): Fix command line argument parsing: no longer write
     errors multiple times into stderr.

   - bpo-1635741(9): Port *note errno: 4d. to multiphase initialization
     ( PEP 489(10)).

   - bpo-40523(11): Add pass-throughs for *note hash(): 5b5. and *note
     reversed(): 831. to *note weakref.proxy: a20. objects.  Patch by
     Pablo Galindo.

   - bpo-1635741(12): Port *note syslog: c6. to multiphase
     initialization ( PEP 489(13)).

   - bpo-40246(14): Reporting a specialised error message for invalid
     string prefixes, which was introduced in bpo-40246(15), is being
     reverted due to backwards compatibility concerns for strings that
     immediately follow a reserved keyword without whitespace between
     them.  Constructs like ‘bg="#d00" if clear else"#fca"’ were failing
     to parse, which is not an acceptable breakage on such short notice.

   - bpo-40417(16): Fix imp module deprecation warning when
     PyImport_ReloadModule is called.  Patch by Robert Rouhani.

   - bpo-40408(17): Fixed support of nested type variables in
     GenericAlias (e.g.  ‘list[list[T]]’).

   - bpo-1635741(18): Port _stat module to multiphase initialization (
     PEP 489(19)).

   - bpo-29587(20): Enable implicit exception chaining when calling
     *note generator.throw(): 4c5.

   - bpo-40328(21): Add tools for generating mappings headers for
     CJKCodecs.

   - bpo-40228(22): Setting frame.f_lineno is now robust w.r.t.  changes
     in the source-to-bytecode compiler

   - bpo-38880(23): Added the ability to list interpreters associated
     with channel ends in the internal subinterpreters module.

   - bpo-37986(24): Improve performance of *note PyLong_FromDouble():
     910. for values that fit into long.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40663

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40596

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40593

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40585

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40566

   (6) https://peps.python.org/pep-0573/

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40502

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40527

   (9) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (10) https://peps.python.org/pep-0489/

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40523

   (12) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (13) https://peps.python.org/pep-0489/

   (14) https://bugs.python.org/issue?@action=redirect&bpo=40246

   (15) https://bugs.python.org/issue?@action=redirect&bpo=40246

   (16) https://bugs.python.org/issue?@action=redirect&bpo=40417

   (17) https://bugs.python.org/issue?@action=redirect&bpo=40408

   (18) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (19) https://peps.python.org/pep-0489/

   (20) https://bugs.python.org/issue?@action=redirect&bpo=29587

   (21) https://bugs.python.org/issue?@action=redirect&bpo=40328

   (22) https://bugs.python.org/issue?@action=redirect&bpo=40228

   (23) https://bugs.python.org/issue?@action=redirect&bpo=38880

   (24) https://bugs.python.org/issue?@action=redirect&bpo=37986


File: python.info,  Node: Library<39>,  Next: Documentation<34>,  Prev: Core and Builtins<40>,  Up: Python 3 9 0 beta 1

1.23.40.3 Library
.................

   - bpo-40662(1): Fixed *note ast.get_source_segment(): 9a5. for ast
     nodes that have incomplete location information.  Patch by Irit
     Katriel.

   - bpo-40665(2): Convert *note bisect: d. to use Argument Clinic.

   - bpo-40536(3): Added the *note available_timezones(): 18c6. function
     to the *note zoneinfo: 11a. module.  Patch by Paul Ganssle.

   - bpo-40645(4): The ‘hmac.HMAC’ exposes internal implementation
     details.  The attributes ‘digest_cons’, ‘inner’, and ‘outer’ are
     deprecated and will be removed in the future.

   - bpo-40645(5): The internal module ‘_hashlib’ wraps and exposes
     OpenSSL's HMAC API. The new code will be used in Python 3.10 after
     the internal implementation details of the pure Python HMAC module
     are no longer part of the public API.

   - bpo-40637(6): Builtin hash modules can now be disabled or
     selectively enabled with ‘configure
     --with-builtin-hashlib-hashes=sha3,blake1’ or
     ‘--without-builtin-hashlib-hashes’.

   - bpo-37630(7): The *note hashlib: 5e. module can now use SHA3 hashes
     and SHAKE XOF from OpenSSL when available.

   - bpo-40479(8): The *note hashlib: 5e. now compiles with OpenSSL
     3.0.0-alpha2.

   - bpo-40257(9): Revert changes to *note inspect.getdoc(): 9c8.

   - bpo-40607(10): When cancelling a task due to timeout, *note
     asyncio.wait_for(): 5ca. will now propagate the exception if an
     error happens during cancellation.  Patch by Roman Skurikhin.

   - bpo-40612(11): Fix edge cases in SyntaxError formatting.  If the
     offset is <= 0, no caret is printed.  If the offset is > line
     length, the caret is printed pointing just after the last
     character.

   - bpo-40597(12): If text content lines are longer than
     policy.max_line_length, always use a content-encoding to make sure
     they are wrapped.

   - bpo-40571(13): Added functools.cache() as a simpler, more
     discoverable way to access the unbounded cache variant of
     lru_cache(maxsize=None).

   - bpo-40503(14): PEP 615(15), the *note zoneinfo: 11a. module.  Adds
     support for the IANA time zone database.

   - bpo-40397(16): Removed attributes ‘__args__’ and ‘__parameters__’
     from special generic aliases like ‘typing.List’ (not subscripted).

   - bpo-40549(17): Convert posixmodule.c ("posix" or "nt" module) to
     the multiphase initialization (PEP 489).

   - bpo-31033(18): Add a ‘msg’ argument to ‘Future.cancel()’ and
     ‘Task.cancel()’.

   - bpo-40541(19): Added an optional 'counts' parameter to
     random.sample().

   - bpo-40515(20): The *note ssl: bb. and *note hashlib: 5e. modules
     now actively check that OpenSSL is build with thread support.
     Python 3.7.0 made thread support mandatory and no longer works
     safely with a no-thread builds.

   - bpo-31033(21): When a *note asyncio.Task: 4a5. is cancelled, the
     exception traceback now chains all the way back to where the task
     was first interrupted.

   - bpo-40504(22): *note functools.lru_cache(): 9bd. objects can now be
     the targets of weakrefs.

   - bpo-40559(23): Fix possible memory leak in the C implementation of
     *note asyncio.Task: 4a5.

   - bpo-40480(24): ‘fnmatch.fnmatch()’ could take exponential time in
     the presence of multiple ‘*’ pattern characters.  This was repaired
     by generating more elaborate regular expressions to avoid futile
     backtracking.

   - bpo-40495(25): *note compileall: 19. is now able to use hardlinks
     to prevent duplicates in a case when ‘.pyc’ files for different
     optimization levels have the same content.

   - bpo-40457(26): The ssl module now support OpenSSL builds without
     TLS 1.0 and 1.1 methods.

   - bpo-40355(27): Improve error reporting in *note ast.literal_eval():
     be6. in the presence of malformed *note ast.Dict: 18c7. nodes
     instead of silently ignoring any non-conforming elements.  Patch by
     Curtis Bucher.

   - bpo-40465(28): Deprecated the optional 'random' argument to
     'random.shuffle()'.

   - bpo-40459(29): *note platform.win32_ver(): 18c8. now produces
     correct 'ptype' strings instead of empty strings.

   - bpo-39435(30): The first argument of *note pickle.loads(): cdf. is
     now positional-only.

   - bpo-39305(31): Update ‘nntplib’ to merge ‘nntplib.NNTP’ and
     ‘nntplib._NNTPBase’.  Patch by Donghee Na.

   - bpo-32494(32): Update *note dbm.gnu: 2b. to use gdbm_count if
     possible when calling *note len(): 5fa.  Patch by Donghee Na.

   - bpo-40453(33): Add ‘isolated=True’ keyword-only parameter to
     ‘_xxsubinterpreters.create()’.  An isolated subinterpreter cannot
     spawn threads, spawn a child process or call ‘os.fork()’.

   - bpo-40286(34): Remove ‘_random.Random.randbytes()’: the C
     implementation of ‘randbytes()’.  Implement the method in Python to
     ease subclassing: ‘randbytes()’ now directly reuses
     ‘getrandbits()’.

   - bpo-40394(35): Added default arguments to *note
     difflib.SequenceMatcher.find_longest_match(): 18c9.

   - bpo-39995(36): Fix a race condition in
     concurrent.futures._ThreadWakeup: access to _ThreadWakeup is now
     protected with the shutdown lock.

   - bpo-30966(37): ‘Process.shutdown(wait=True)’ of *note
     concurrent.futures: 1a. now closes explicitly the result queue.

   - bpo-30966(38): Add a new *note close(): 8e3. method to the *note
     SimpleQueue: 8e2. class to explicitly close the queue.

   - bpo-39966(39): Revert bpo-25597(40).  *note
     unittest.mock.MagicMock: e5a. with wraps' set uses default return
     values for magic methods.

   - bpo-39791(41): Added ‘files()’ function to importlib.resources with
     support for subdirectories in package data, matching backport in
     importlib_resources 1.5.

   - bpo-40375(42): *note imaplib.IMAP4.unselect(): 8d5. is added.
     Patch by Donghee Na.

   - bpo-40389(43): ‘repr()’ now returns ‘typing.Optional[T]’ when
     called for ‘typing.Union’ of two types, one of which is ‘NoneType’.

   - bpo-40291(44): Add support for CAN_J1939 sockets (available on
     Linux 5.4+)

   - bpo-40273(45): *note types.MappingProxyType: 43a. is now
     reversible.

   - bpo-39075(46): The repr for *note types.SimpleNamespace: 1b3. is
     now insertion ordered rather than alphabetical.

   - bpo-40192(47): On AIX, *note thread_time(): 904. is now implemented
     with ‘thread_cputime()’ which has nanosecond resolution, rather
     than ‘clock_gettime(CLOCK_THREAD_CPUTIME_ID)’ which has a
     resolution of 10 milliseconds.  Patch by Batuhan Taskaya.

   - bpo-40025(48): Raise TypeError when _generate_next_value_ is
     defined after members.  Patch by Ethan Onstott.

   - bpo-39058(49): In the argparse module, the repr for Namespace() and
     other argument holders now displayed in the order attributes were
     added.  Formerly, it displayed in alphabetical order even though
     argument order is preserved the user visible parts of the module.

   - bpo-24416(50): The ‘isocalendar()’ methods of *note datetime.date:
     1af. and *note datetime.datetime: 1ae. now return a *note named
     tuple: 61a. instead of a *note tuple: 349.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40662

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40665

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40536

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40645

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40645

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40637

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37630

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40479

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40257

   (10) https://bugs.python.org/issue?@action=redirect&bpo=40607

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40612

   (12) https://bugs.python.org/issue?@action=redirect&bpo=40597

   (13) https://bugs.python.org/issue?@action=redirect&bpo=40571

   (14) https://bugs.python.org/issue?@action=redirect&bpo=40503

   (15) https://peps.python.org/pep-0615/

   (16) https://bugs.python.org/issue?@action=redirect&bpo=40397

   (17) https://bugs.python.org/issue?@action=redirect&bpo=40549

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31033

   (19) https://bugs.python.org/issue?@action=redirect&bpo=40541

   (20) https://bugs.python.org/issue?@action=redirect&bpo=40515

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31033

   (22) https://bugs.python.org/issue?@action=redirect&bpo=40504

   (23) https://bugs.python.org/issue?@action=redirect&bpo=40559

   (24) https://bugs.python.org/issue?@action=redirect&bpo=40480

   (25) https://bugs.python.org/issue?@action=redirect&bpo=40495

   (26) https://bugs.python.org/issue?@action=redirect&bpo=40457

   (27) https://bugs.python.org/issue?@action=redirect&bpo=40355

   (28) https://bugs.python.org/issue?@action=redirect&bpo=40465

   (29) https://bugs.python.org/issue?@action=redirect&bpo=40459

   (30) https://bugs.python.org/issue?@action=redirect&bpo=39435

   (31) https://bugs.python.org/issue?@action=redirect&bpo=39305

   (32) https://bugs.python.org/issue?@action=redirect&bpo=32494

   (33) https://bugs.python.org/issue?@action=redirect&bpo=40453

   (34) https://bugs.python.org/issue?@action=redirect&bpo=40286

   (35) https://bugs.python.org/issue?@action=redirect&bpo=40394

   (36) https://bugs.python.org/issue?@action=redirect&bpo=39995

   (37) https://bugs.python.org/issue?@action=redirect&bpo=30966

   (38) https://bugs.python.org/issue?@action=redirect&bpo=30966

   (39) https://bugs.python.org/issue?@action=redirect&bpo=39966

   (40) https://bugs.python.org/issue?@action=redirect&bpo=25597

   (41) https://bugs.python.org/issue?@action=redirect&bpo=39791

   (42) https://bugs.python.org/issue?@action=redirect&bpo=40375

   (43) https://bugs.python.org/issue?@action=redirect&bpo=40389

   (44) https://bugs.python.org/issue?@action=redirect&bpo=40291

   (45) https://bugs.python.org/issue?@action=redirect&bpo=40273

   (46) https://bugs.python.org/issue?@action=redirect&bpo=39075

   (47) https://bugs.python.org/issue?@action=redirect&bpo=40192

   (48) https://bugs.python.org/issue?@action=redirect&bpo=40025

   (49) https://bugs.python.org/issue?@action=redirect&bpo=39058

   (50) https://bugs.python.org/issue?@action=redirect&bpo=24416


File: python.info,  Node: Documentation<34>,  Next: Tests<37>,  Prev: Library<39>,  Up: Python 3 9 0 beta 1

1.23.40.4 Documentation
.......................

   - bpo-34790(1): Add version of removal for explicit passing of coros
     to ‘asyncio.wait()’'s documentation

   - bpo-40561(2): Provide docstrings for webbrowser open functions.

   - bpo-40499(3): Mention that *note asyncio.wait(): 44c. requires a
     non-empty set of awaitables.

   - bpo-39705(4): Tutorial example for sorted() in the Loop Techniques
     section is given a better explanation.  Also a new example is
     included to explain sorted()'s basic behavior.

   - bpo-39435(5): Fix an incorrect signature for *note pickle.loads():
     cdf. in the docs

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34790

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40561

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40499

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39705

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39435


File: python.info,  Node: Tests<37>,  Next: Build<39>,  Prev: Documentation<34>,  Up: Python 3 9 0 beta 1

1.23.40.5 Tests
...............

   - bpo-40055(1): distutils.tests now saves/restores warnings filters
     to leave them unchanged.  Importing tests imports docutils which
     imports pkg_resources which adds a warnings filter.

   - bpo-40436(2): test_gdb and test.pythoninfo now check gdb command
     exit code.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40055

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40436


File: python.info,  Node: Build<39>,  Next: Windows<35>,  Prev: Tests<37>,  Up: Python 3 9 0 beta 1

1.23.40.6 Build
...............

   - bpo-40653(1): Move _dirnameW out of HAVE_SYMLINK to fix a potential
     compiling issue.

   - bpo-40514(2): Add ‘--with-experimental-isolated-subinterpreters’
     build option to ‘configure’: better isolate subinterpreters,
     experimental build mode.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40653

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40514


File: python.info,  Node: Windows<35>,  Next: macOS<30>,  Prev: Build<39>,  Up: Python 3 9 0 beta 1

1.23.40.7 Windows
.................

   - bpo-40650(1): Include winsock2.h in pytime.c for timeval.

   - bpo-40458(2): Increase reserved stack space to prevent overflow
     crash on Windows.

   - bpo-39148(3): Add IPv6 support to *note asyncio: 8. datagram
     endpoints in ProactorEventLoop.  Change the raised exception for
     unknown address families to ValueError as it's not coming from
     Windows API.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40650

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40458

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39148


File: python.info,  Node: macOS<30>,  Next: Tools/Demos<17>,  Prev: Windows<35>,  Up: Python 3 9 0 beta 1

1.23.40.8 macOS
...............

   - bpo-34956(1): When building Python on macOS from source, ‘_tkinter’
     now links with non-system Tcl and Tk frameworks if they are
     installed in ‘/Library/Frameworks’, as had been the case on older
     releases of macOS. If a macOS SDK is explicitly configured, by
     using ‘--enable-universalsdk=’ or ‘-isysroot’, only the SDK itself
     is searched.  The default behavior can still be overridden with
     ‘--with-tcltk-includes’ and ‘--with-tcltk-libs’.

   - bpo-35569(2): Expose RFC 3542 IPv6 socket options.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34956

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35569


File: python.info,  Node: Tools/Demos<17>,  Next: C API<38>,  Prev: macOS<30>,  Up: Python 3 9 0 beta 1

1.23.40.9 Tools/Demos
.....................

   - bpo-40479(1): Update multissltest helper to test with latest
     OpenSSL 1.0.2, 1.1.0, 1.1.1, and 3.0.0-alpha.

   - bpo-40431(2): Fix a syntax typo in ‘turtledemo’ that now raises a
     ‘SyntaxError’.

   - bpo-40163(3): Fix multissltest tool.  OpenSSL has changed download
     URL for old releases.  The multissltest tool now tries to download
     from current and old download URLs.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40479

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40431

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40163


File: python.info,  Node: C API<38>,  Prev: Tools/Demos<17>,  Up: Python 3 9 0 beta 1

1.23.40.10 C API
................

   - bpo-39465(1): Remove the ‘_PyUnicode_ClearStaticStrings()’ function
     from the C API.

   - bpo-38787(2): Add PyCFunction_CheckExact() macro for exact type
     checks now that we allow subtypes of PyCFunction, as well as
     PyCMethod_CheckExact() and PyCMethod_Check() for the new PyCMethod
     subtype.

   - bpo-40545(3): Declare ‘_PyErr_GetTopmostException()’ with
     ‘PyAPI_FUNC()’ to properly export the function in the C API. The
     function remains private (‘_Py’) prefix.

   - bpo-40412(4): Nullify inittab_copy during finalization, preventing
     future interpreter initializations in an embedded situation from
     crashing.  Patch by Gregory Szorc.

   - bpo-40429(5): The *note PyThreadState_GetFrame(): 759. function now
     returns a strong reference to the frame.

   - bpo-40428(6): Remove the following functions from the C API. Call
     *note PyGC_Collect(): 95c. explicitly to free all free lists.

        * ‘PyAsyncGen_ClearFreeLists()’

        * ‘PyContext_ClearFreeList()’

        * ‘PyDict_ClearFreeList()’

        * ‘PyFloat_ClearFreeList()’

        * ‘PyFrame_ClearFreeList()’

        * ‘PyList_ClearFreeList()’

        * ‘PySet_ClearFreeList()’

        * ‘PyTuple_ClearFreeList()’

   - bpo-40421(7): New *note PyFrame_GetBack(): 751. function: get the
     frame next outer frame.

   - bpo-40421(8): New *note PyFrame_GetCode(): 755. function: return a
     borrowed reference to the frame code.

   - bpo-40217(9): Ensure that instances of types created with *note
     PyType_FromSpecWithBases(): 54a. will visit its class object when
     traversing references in the garbage collector (implemented as an
     extension of the provided *note tp_traverse: 749.).  Patch by Pablo
     Galindo.

   - bpo-38787(10): Module C state is now accessible from C-defined heap
     type methods ( PEP 573(11)).  Patch by Marcel Plch and Petr
     Viktorin.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39465

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38787

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40545

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40412

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40429

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40428

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40421

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40421

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40217

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38787

   (11) https://peps.python.org/pep-0573/


File: python.info,  Node: Python 3 9 0 alpha 6,  Next: Python 3 9 0 alpha 5,  Prev: Python 3 9 0 beta 1,  Up: 変更履歴

1.23.41 Python 3.9.0 alpha 6
----------------------------

'Release date: 2020-04-27'

* Menu:

* Security: Security<26>.
* Core and Builtins: Core and Builtins<41>.
* Library: Library<40>.
* Documentation: Documentation<35>.
* Tests: Tests<38>.
* Build: Build<40>.
* Windows: Windows<36>.
* macOS: macOS<31>.
* IDLE: IDLE<27>.
* Tools/Demos: Tools/Demos<18>.
* C API: C API<39>.


File: python.info,  Node: Security<26>,  Next: Core and Builtins<41>,  Up: Python 3 9 0 alpha 6

1.23.41.1 Security
..................

   - bpo-40121(1): Fixes audit events raised on creating a new socket.

   - bpo-39073(2): Disallow CR or LF in email.headerregistry.Address
     arguments to guard against header injection attacks.

   - bpo-39503(3): CVE 2020-8492(4): The *note AbstractBasicAuthHandler:
     1826. class of the *note urllib.request: f4. module uses an
     inefficient regular expression which can be exploited by an
     attacker to cause a denial of service.  Fix the regex to prevent
     the catastrophic backtracking.  Vulnerability reported by Ben
     Caller and Matt Schwager.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40121

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39073

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39503

   (4) https://www.cve.org/CVERecord?id=CVE-2020-8492


File: python.info,  Node: Core and Builtins<41>,  Next: Library<40>,  Prev: Security<26>,  Up: Python 3 9 0 alpha 6

1.23.41.2 Core and Builtins
...........................

   - bpo-40313(1): Improve the performance of bytes.hex().

   - bpo-40334(2): Switch to a new parser, based on PEG. For more
     details see PEP 617.  To temporarily switch back to the old parser,
     use ‘-X oldparser’ or ‘PYTHONOLDPARSER=1’.  In Python 3.10 we will
     remove the old parser completely, including the ‘parser’ module
     (already deprecated) and anything that depends on it.

   - bpo-40267(3): Fix the tokenizer to display the correct error
     message, when there is a ‘SyntaxError’ on the last input character
     and no newline follows.  It used to be ‘unexpected EOF while
     parsing’, while it should be ‘invalid syntax’.

   - bpo-39522(4): Correctly unparse explicit ‘u’ prefix for strings
     when postponed evaluation for annotations activated.  Patch by
     Batuhan Taskaya.

   - bpo-40246(5): Report a specialized error message, ‘invalid string
     prefix’, when the tokenizer encounters a string with an invalid
     prefix.

   - bpo-40082(6): Fix the signal handler: it now always uses the main
     interpreter, rather than trying to get the current Python thread
     state.

   - bpo-37388(7): str.encode() and str.decode() no longer check the
     encoding and errors in development mode or in debug mode during
     Python finalization.  The codecs machinery can no longer work on
     very late calls to str.encode() and str.decode().

   - bpo-40077(8): Fix possible refleaks in ‘_json’, memo of
     PyScannerObject should be traversed.

   - bpo-37207(9): Speed up calls to ‘dict()’ by using the PEP 590(10)
     ‘vectorcall’ calling convention.

   - bpo-40141(11): Add column and line information to ‘ast.keyword’
     nodes.  Patch by Pablo Galindo.

   - bpo-1635741(12): Port *note resource: aa. to multiphase
     initialization ( PEP 489(13)).

   - bpo-1635741(14): Port *note math: 81. to multiphase initialization
     ( PEP 489(15)).

   - bpo-1635741(16): Port _uuid module to multiphase initialization (
     PEP 489(17)).

   - bpo-40077(18): Convert json module to use *note PyType_FromSpec():
     549.

   - bpo-40067(19): Improve the error message for multiple star
     expressions in an assignment.  Patch by Furkan Onder

   - bpo-1635741(20): Port _functools module to multiphase
     initialization (PEP 489).  Patch by Paulo Henrique Silva.

   - bpo-1635741(21): Port operator module to multiphase initialization
     (PEP 489).  Patch by Paulo Henrique Silva.

   - bpo-20526(22): Fix *note PyThreadState_Clear(): 1585.
     ‘PyThreadState.frame’ is a borrowed reference, not a strong
     reference: ‘PyThreadState_Clear()’ must not call
     ‘Py_CLEAR(tstate->frame)’.

   - bpo-1635741(23): Port time module to multiphase initialization (
     PEP 489(24)).  Patch by Paulo Henrique Silva.

   - bpo-1635741(25): Port _weakref extension module to multiphase
     initialization ( PEP 489(26)).

   - bpo-40020(27): Fix a leak and subsequent crash in parsetok.c caused
     by realloc misuse on a rare codepath.

   - bpo-39939(28): Added str.removeprefix and str.removesuffix methods
     and corresponding bytes, bytearray, and collections.UserString
     methods to remove affixes from a string if present.  See PEP
     616(29) for a full description.  Patch by Dennis Sweeney.

   - bpo-39481(30): Implement PEP 585.  This supports list[int],
     tuple[str, ...]  etc.

   - bpo-32894(31): Support unparsing of infinity numbers in postponed
     annotations.  Patch by Batuhan Taşkaya.

   - bpo-37207(32): Speed up calls to ‘list()’ by using the PEP 590(33)
     ‘vectorcall’ calling convention.  Patch by Mark Shannon.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40313

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40334

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40267

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39522

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40246

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40082

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37388

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (9) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (10) https://peps.python.org/pep-0590/

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40141

   (12) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (13) https://peps.python.org/pep-0489/

   (14) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (15) https://peps.python.org/pep-0489/

   (16) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (17) https://peps.python.org/pep-0489/

   (18) https://bugs.python.org/issue?@action=redirect&bpo=40077

   (19) https://bugs.python.org/issue?@action=redirect&bpo=40067

   (20) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (21) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (22) https://bugs.python.org/issue?@action=redirect&bpo=20526

   (23) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (24) https://peps.python.org/pep-0489/

   (25) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (26) https://peps.python.org/pep-0489/

   (27) https://bugs.python.org/issue?@action=redirect&bpo=40020

   (28) https://bugs.python.org/issue?@action=redirect&bpo=39939

   (29) https://peps.python.org/pep-0616/

   (30) https://bugs.python.org/issue?@action=redirect&bpo=39481

   (31) https://bugs.python.org/issue?@action=redirect&bpo=32894

   (32) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (33) https://peps.python.org/pep-0590/


File: python.info,  Node: Library<40>,  Next: Documentation<35>,  Prev: Core and Builtins<41>,  Up: Python 3 9 0 alpha 6

1.23.41.3 Library
.................

   - bpo-40398(1): *note typing.get_args(): 84b. now always returns an
     empty tuple for special generic aliases.

   - bpo-40396(2): Functions *note typing.get_origin(): a15, *note
     typing.get_args(): 84b. and *note typing.get_type_hints(): 67d.
     support now generic aliases like ‘list[int]’.

   - bpo-38061(3): Optimize the *note subprocess: c1. module on FreeBSD
     using ‘closefrom()’.  A single ‘close(fd)’ syscall is cheap, but
     when ‘sysconf(_SC_OPEN_MAX)’ is high, the loop calling ‘close(fd)’
     on each file descriptor can take several milliseconds.

     The workaround on FreeBSD to improve performance was to load and
     mount the fdescfs kernel module, but this is not enabled by
     default.

     Initial patch by Ed Maste (emaste), Conrad Meyer (cem), Kyle Evans
     (kevans) and Kubilay Kocak (koobs):
     ‘https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242274’

   - bpo-38061(4): On FreeBSD, ‘os.closerange(fd_low, fd_high)’ now
     calls ‘closefrom(fd_low)’ if 'fd_high' is greater than or equal to
     ‘sysconf(_SC_OPEN_MAX)’.

     Initial patch by Ed Maste (emaste), Conrad Meyer (cem), Kyle Evans
     (kevans) and Kubilay Kocak (koobs):
     ‘https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242274’

   - bpo-40360(5): The ‘lib2to3’ module is pending deprecation due to
     PEP 617(6).

   - bpo-40138(7): Fix the Windows implementation of *note os.waitpid():
     d67. for exit code larger than ‘INT_MAX >> 8’.  The exit status is
     now interpreted as an unsigned number.

   - bpo-39942(8): Set "__main__" as the default module name when
     "__name__" is missing in *note typing.TypeVar: 143.  Patch by
     Weipeng Hong.

   - bpo-40275(9): The *note logging: 7b. package is now imported lazily
     in *note unittest: ef. only when the *note assertLogs(): 824.
     assertion is used.

   - bpo-40275(10): The *note asyncio: 8. package is now imported lazily
     in *note unittest: ef. only when the *note IsolatedAsyncioTestCase:
     2e4. class is used.

   - bpo-40330(11): In ‘ShareableList.__setitem__()’, check the size of
     a new string item after encoding it to utf-8, not before.

   - bpo-40148(12): Added ‘pathlib.Path.with_stem()’ to create a new
     Path with the stem replaced.

   - bpo-40325(13): Deprecated support for set objects in
     random.sample().

   - bpo-40257(14): Improved help for the *note typing: ed. module.
     Docstrings are now shown for all special forms and special generic
     aliases (like ‘Union’ and ‘List’).  Using ‘help()’ with generic
     alias like ‘List[int]’ will show the help for the correspondent
     concrete type (‘list’ in this case).

   - bpo-40257(15): *note inspect.getdoc(): 9c8. no longer returns
     docstring inherited from the type of the object or from parent
     class if it is a class if it is not defined in the object itself.
     In *note pydoc: a3. the documentation string is now shown not only
     for class, function, method etc, but for any object that has its
     own ‘__doc__’ attribute.

   - bpo-40287(16): Fixed ‘SpooledTemporaryFile.seek()’ to return the
     position.

   - bpo-40290(17): Added zscore() to statistics.NormalDist().

   - bpo-40282(18): Allow ‘random.getrandbits(0)’ to succeed and to
     return 0.

   - bpo-40286(19): Add *note random.randbytes(): 18d5. function and
     ‘random.Random.randbytes()’ method to generate random bytes.

   - bpo-40277(20): *note collections.namedtuple(): 1ac. now provides a
     human-readable repr for its field accessors.

   - bpo-40270(21): The included copy of sqlite3 on Windows is now
     compiled with the json extension.  This allows the use of functions
     such as ‘json_object’.

   - bpo-29255(22): Wait in ‘KqueueSelector.select’ when no fds are
     registered

   - bpo-40260(23): Ensure *note modulefinder: 84. uses *note
     io.open_code(): 168e. and respects coding comments.

   - bpo-40234(24): Allow again to spawn daemon threads in
     subinterpreters (revert change which denied them).

   - bpo-39207(25): Workers in *note ProcessPoolExecutor: 8bc. are now
     spawned on demand, only when there are no available idle workers to
     reuse.  This optimizes startup overhead and reduces the amount of
     lost CPU time to idle workers.  Patch by Kyle Stanley.

   - bpo-40091(26): Fix a hang at fork in the logging module: the new
     private _at_fork_reinit() method is now used to reinitialize locks
     at fork in the child process.

   - bpo-40149(27): Implement traverse and clear slots in _abc._abc_data
     type.

   - bpo-40208(28): Remove deprecated ‘symtable.SymbolTable.has_exec()’.

   - bpo-40196(29): Fix a bug in the *note symtable: c2. module that was
     causing incorrectly report global variables as local.  Patch by
     Pablo Galindo.

   - bpo-40190(30): Add support for ‘_SC_AIX_REALMEM’ to
     ‘posix.sysconf()’.

   - bpo-40182(31): Removed the ‘_field_types’ attribute of the *note
     typing.NamedTuple: 290. class.

   - bpo-36517(32): Multiple inheritance with *note typing.NamedTuple:
     290. now raises an error instead of silently ignoring other types.

   - bpo-40126(33): Fixed reverting multiple patches in unittest.mock.
     Patcher's ‘__exit__()’ is now never called if its ‘__enter__()’ is
     failed.  Returning true from ‘__exit__()’ silences now the
     exception.

   - bpo-40094(34): CGIHTTPRequestHandler of http.server now logs the
     CGI script exit code, rather than the CGI script exit status of
     os.waitpid().  For example, if the script is killed by signal 11,
     it now logs: "CGI script exit code -11."

   - bpo-40108(35): Improve the error message when triying to import a
     module using *note runpy: ac. and incorrectly using the ".py"
     extension at the end of the module name.  Patch by Pablo Galindo.

   - bpo-40094(36): Add *note os.waitstatus_to_exitcode(): 8eb.
     function: convert a wait status to an exit code.

   - bpo-40089(37): Fix threading._after_fork(): if fork was not called
     by a thread spawned by threading.Thread, threading._after_fork()
     now creates a _MainThread instance for _main_thread, instead of a
     _DummyThread instance.

   - bpo-40089(38): Add a private ‘_at_fork_reinit()’ method to
     ‘_thread.Lock’, ‘_thread.RLock’, *note threading.RLock: 2bf. and
     *note threading.Condition: 1128. classes: reinitialize the lock at
     fork in the child process, reset the lock to the unlocked state.
     Rename also the private ‘_reset_internal_locks()’ method of *note
     threading.Event: 112b. to ‘_at_fork_reinit()’.

   - bpo-25780(39): Expose *note CAN_RAW_JOIN_FILTERS: 8ff. in the *note
     socket: b8. module.

   - bpo-39503(40): *note AbstractBasicAuthHandler: 1826. of *note
     urllib.request: f4. now parses all WWW-Authenticate HTTP headers
     and accepts multiple challenges per header: use the realm of the
     first Basic challenge.

   - bpo-39812(41): Removed daemon threads from *note
     concurrent.futures: 1a. by adding an internal
     ‘threading._register_atexit()’, which calls registered functions
     prior to joining all non-daemon threads.  This allows for
     compatibility with subinterpreters, which don't support daemon
     threads.

   - bpo-40050(42): Fix ‘importlib._bootstrap_external’: avoid creating
     a new ‘winreg’ builtin module if it's already available in *note
     sys.modules: 18d6, and remove redundant imports.

   - bpo-40014(43): Fix ‘os.getgrouplist()’: if ‘getgrouplist()’
     function fails because the group list is too small, retry with a
     larger group list.  On failure, the glibc implementation of
     ‘getgrouplist()’ sets ‘ngroups’ to the total number of groups.  For
     other implementations, double the group list size.

   - bpo-40017(44): Add *note time.CLOCK_TAI: 18d7. constant if the
     operating system support it.

   - bpo-40016(45): In re docstring, clarify the relationship between
     inline and argument compile flags.

   - bpo-39953(46): Update internal table of OpenSSL error codes in the
     ‘ssl’ module.

   - bpo-36144(47): Added PEP 584(48) operators to *note
     weakref.WeakValueDictionary: 18d8.

   - bpo-36144(49): Added PEP 584(50) operators to *note
     weakref.WeakKeyDictionary: 18d9.

   - bpo-38891(51): Fix linear runtime behaviour of the ‘__getitem__’
     and ‘__setitem__’ methods in *note
     multiprocessing.shared_memory.ShareableList: 18da.  This avoids
     quadratic performance when iterating a ‘ShareableList’.  Patch by
     Thomas Krennwallner.

   - bpo-39682(52): Remove undocumented support for 'closing' a
     ‘pathlib.Path’ object via its context manager.  The context manager
     magic methods remain, but they are now a no-op, making ‘Path’
     objects immutable.

   - bpo-36144(53): Added PEP 584(54) operators (‘|’ and ‘|=’) to *note
     collections.ChainMap: bea.

   - bpo-39011(55): Normalization of line endings in ElementTree
     attributes was removed, as line endings which were replaced by
     entity numbers should be preserved in original form.

   - bpo-38410(56): Properly handle *note sys.audit(): 151a. failures in
     *note sys.set_asyncgen_hooks(): 158a.

   - bpo-36541(57): lib2to3 now recognizes named assignment expressions
     (the walrus operator, ‘:=’)

   - bpo-35967(58): In platform, delay the invocation of 'uname -p'
     until the processor attribute is requested.

   - bpo-35113(59): *note inspect.getsource(): 1528. now returns correct
     source code for inner class with same name as module level class.
     Decorators are also returned as part of source of the class.  Patch
     by Karthikeyan Singaravelan.

   - bpo-33262(60): Deprecate passing None as an argument for *note
     shlex.split(): 506.'s ‘s’ parameter.  Patch by Zackery Spytz.

   - bpo-31758(61): Prevent crashes when using an uninitialized
     ‘_elementtree.XMLParser’ object.  Patch by Oren Milman.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40398

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40396

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38061

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38061

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40360

   (6) https://peps.python.org/pep-0617/

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40138

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39942

   (9) https://bugs.python.org/issue?@action=redirect&bpo=40275

   (10) https://bugs.python.org/issue?@action=redirect&bpo=40275

   (11) https://bugs.python.org/issue?@action=redirect&bpo=40330

   (12) https://bugs.python.org/issue?@action=redirect&bpo=40148

   (13) https://bugs.python.org/issue?@action=redirect&bpo=40325

   (14) https://bugs.python.org/issue?@action=redirect&bpo=40257

   (15) https://bugs.python.org/issue?@action=redirect&bpo=40257

   (16) https://bugs.python.org/issue?@action=redirect&bpo=40287

   (17) https://bugs.python.org/issue?@action=redirect&bpo=40290

   (18) https://bugs.python.org/issue?@action=redirect&bpo=40282

   (19) https://bugs.python.org/issue?@action=redirect&bpo=40286

   (20) https://bugs.python.org/issue?@action=redirect&bpo=40277

   (21) https://bugs.python.org/issue?@action=redirect&bpo=40270

   (22) https://bugs.python.org/issue?@action=redirect&bpo=29255

   (23) https://bugs.python.org/issue?@action=redirect&bpo=40260

   (24) https://bugs.python.org/issue?@action=redirect&bpo=40234

   (25) https://bugs.python.org/issue?@action=redirect&bpo=39207

   (26) https://bugs.python.org/issue?@action=redirect&bpo=40091

   (27) https://bugs.python.org/issue?@action=redirect&bpo=40149

   (28) https://bugs.python.org/issue?@action=redirect&bpo=40208

   (29) https://bugs.python.org/issue?@action=redirect&bpo=40196

   (30) https://bugs.python.org/issue?@action=redirect&bpo=40190

   (31) https://bugs.python.org/issue?@action=redirect&bpo=40182

   (32) https://bugs.python.org/issue?@action=redirect&bpo=36517

   (33) https://bugs.python.org/issue?@action=redirect&bpo=40126

   (34) https://bugs.python.org/issue?@action=redirect&bpo=40094

   (35) https://bugs.python.org/issue?@action=redirect&bpo=40108

   (36) https://bugs.python.org/issue?@action=redirect&bpo=40094

   (37) https://bugs.python.org/issue?@action=redirect&bpo=40089

   (38) https://bugs.python.org/issue?@action=redirect&bpo=40089

   (39) https://bugs.python.org/issue?@action=redirect&bpo=25780

   (40) https://bugs.python.org/issue?@action=redirect&bpo=39503

   (41) https://bugs.python.org/issue?@action=redirect&bpo=39812

   (42) https://bugs.python.org/issue?@action=redirect&bpo=40050

   (43) https://bugs.python.org/issue?@action=redirect&bpo=40014

   (44) https://bugs.python.org/issue?@action=redirect&bpo=40017

   (45) https://bugs.python.org/issue?@action=redirect&bpo=40016

   (46) https://bugs.python.org/issue?@action=redirect&bpo=39953

   (47) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (48) https://peps.python.org/pep-0584/

   (49) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (50) https://peps.python.org/pep-0584/

   (51) https://bugs.python.org/issue?@action=redirect&bpo=38891

   (52) https://bugs.python.org/issue?@action=redirect&bpo=39682

   (53) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (54) https://peps.python.org/pep-0584/

   (55) https://bugs.python.org/issue?@action=redirect&bpo=39011

   (56) https://bugs.python.org/issue?@action=redirect&bpo=38410

   (57) https://bugs.python.org/issue?@action=redirect&bpo=36541

   (58) https://bugs.python.org/issue?@action=redirect&bpo=35967

   (59) https://bugs.python.org/issue?@action=redirect&bpo=35113

   (60) https://bugs.python.org/issue?@action=redirect&bpo=33262

   (61) https://bugs.python.org/issue?@action=redirect&bpo=31758


File: python.info,  Node: Documentation<35>,  Next: Tests<38>,  Prev: Library<40>,  Up: Python 3 9 0 alpha 6

1.23.41.4 Documentation
.......................

   - bpo-27635(1): The pickle documentation incorrectly claimed that
     ‘__new__’ isn't called by default when unpickling.

   - bpo-39879(2): Updated *note データモデル: 18dc. docs to include
     *note dict(): 237. insertion order preservation.  Patch by Furkan
     Onder and Samy Lahfa.

   - bpo-38387(3): Document *note PyDoc_STRVAR: 18dd. macro in the C-API
     reference.

   - bpo-13743(4): Some methods within xml.dom.minidom.Element class are
     now better documented.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27635

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39879

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38387

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13743


File: python.info,  Node: Tests<38>,  Next: Build<40>,  Prev: Documentation<35>,  Up: Python 3 9 0 alpha 6

1.23.41.5 Tests
...............

   - bpo-31904(1): Set expected default encoding in
     test_c_locale_coercion.py for VxWorks RTOS.

   - bpo-40162(2): Update Travis CI configuration to OpenSSL 1.1.1f.

   - bpo-40146(3): Update OpenSSL to 1.1.1f in Azure Pipelines.

   - bpo-40094(4): Add *note test.support.wait_process(): 18df.
     function.

   - bpo-40003(5): ‘test.bisect_cmd’ now copies Python command line
     options like ‘-O’ or ‘-W’.  Moreover, emit a warning if
     ‘test.bisect_cmd’ is used with ‘-w’/‘--verbose2’ option.

   - bpo-39380(6): Add the encoding in *note ftplib.FTP: 8c8. and *note
     ftplib.FTP_TLS: 8c9. to the constructor as keyword-only and change
     the default from ‘latin-1’ to ‘utf-8’ to follow RFC 2640(7).

   - bpo-39793(8): Use the same domain when testing ‘make_msgid’.  Patch
     by Batuhan Taskaya.

   - bpo-1812(9): Fix newline handling in doctest.testfile when loading
     from a package whose loader has a get_data method.  Patch by Peter
     Donis.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40162

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40146

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40094

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40003

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39380

   (7) https://datatracker.ietf.org/doc/html/rfc2640.html

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39793

   (9) https://bugs.python.org/issue?@action=redirect&bpo=1812


File: python.info,  Node: Build<40>,  Next: Windows<36>,  Prev: Tests<38>,  Up: Python 3 9 0 alpha 6

1.23.41.6 Build
...............

   - bpo-38360(1): Support single-argument form of macOS -isysroot flag.

   - bpo-40158(2): Fix CPython MSBuild Properties in NuGet Package
     (build/native/python.props)

   - bpo-38527(3): Fix configure check on Solaris for "float word
     ordering": sometimes, the correct "grep" command was not being
     used.  Patch by Arnon Yaari.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38360

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40158

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38527


File: python.info,  Node: Windows<36>,  Next: macOS<31>,  Prev: Build<40>,  Up: Python 3 9 0 alpha 6

1.23.41.7 Windows
.................

   - bpo-40164(1): Updates Windows to OpenSSL 1.1.1f

   - bpo-8901(2): Ignore the Windows registry when the ‘-E’ option is
     used.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40164

   (2) https://bugs.python.org/issue?@action=redirect&bpo=8901


File: python.info,  Node: macOS<31>,  Next: IDLE<27>,  Prev: Windows<36>,  Up: Python 3 9 0 alpha 6

1.23.41.8 macOS
...............

   - bpo-38329(1): python.org macOS installers now update the Current
     version symlink of /Library/Frameworks/Python.framework/Versions
     for 3.9 installs.  Previously, Current was only updated for Python
     2.x installs.  This should make it easier to embed Python 3 into
     other macOS applications.

   - bpo-40164(2): Update macOS installer builds to use OpenSSL 1.1.1g.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38329

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40164


File: python.info,  Node: IDLE<27>,  Next: Tools/Demos<18>,  Prev: macOS<31>,  Up: Python 3 9 0 alpha 6

1.23.41.9 IDLE
..............

   - bpo-38439(1): Add a 256×256 pixel IDLE icon to support more modern
     environments.  Created by Andrew Clover.  Delete the unused macOS
     idle.icns icon file.

   - bpo-38689(2): IDLE will no longer freeze when inspect.signature
     fails when fetching a calltip.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38439

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38689


File: python.info,  Node: Tools/Demos<18>,  Next: C API<39>,  Prev: IDLE<27>,  Up: Python 3 9 0 alpha 6

1.23.41.10 Tools/Demos
......................

   - bpo-40385(1): Removed the checkpyc.py tool.  Please see compileall
     without force mode as a potential alternative.

   - bpo-40179(2): Fixed translation of ‘#elif’ in Argument Clinic.

   - bpo-40094(3): Fix ‘which.py’ script exit code: it now uses *note
     os.waitstatus_to_exitcode(): 8eb. to convert *note os.system():
     1402. exit status into an exit code.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40385

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40179

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40094


File: python.info,  Node: C API<39>,  Prev: Tools/Demos<18>,  Up: Python 3 9 0 alpha 6

1.23.41.11 C API
................

   - bpo-40241(1): Move the ‘PyGC_Head’ structure to the internal C API.

   - bpo-40170(2): Convert *note PyObject_IS_GC(): 952. macro to a
     function to hide implementation details.

   - bpo-40241(3): Add the functions *note PyObject_GC_IsTracked(): 944.
     and *note PyObject_GC_IsFinalized(): 945. to the public API to
     allow to query if Python objects are being currently tracked or
     have been already finalized by the garbage collector respectively.
     Patch by Pablo Galindo.

   - bpo-40170(4): The ‘PyObject_NEW()’ macro becomes an alias to the
     *note PyObject_New(): 953. macro, and the ‘PyObject_NEW_VAR()’
     macro becomes an alias to the *note PyObject_NewVar(): 954. macro,
     to hide implementation details.  They no longer access directly the
     *note PyTypeObject.tp_basicsize: 955. member.

   - bpo-40170(5): *note PyType_HasFeature(): 18bd. now always calls
     *note PyType_GetFlags(): 18be. to hide implementation details.
     Previously, it accessed directly the *note PyTypeObject.tp_flags:
     1828. member when the limited C API was not used.

   - bpo-40170(6): Convert the ‘PyObject_GET_WEAKREFS_LISTPTR()’ macro
     to a function to hide implementation details: the macro accessed
     directly to the *note PyTypeObject.tp_weaklistoffset: 956. member.

   - bpo-40170(7): Convert *note PyObject_CheckBuffer(): 372. macro to a
     function to hide implementation details: the macro accessed
     directly the *note PyTypeObject.tp_as_buffer: 957. member.

   - bpo-40170(8): Always declare *note PyIndex_Check(): 958. as an
     opaque function to hide implementation details: remove
     ‘PyIndex_Check()’ macro.  The macro accessed directly the *note
     PyTypeObject.tp_as_number: 959. member.

   - bpo-39947(9): Add *note PyThreadState_GetID(): 940. function: get
     the unique identifier of a Python thread state.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40241

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (3) https://bugs.python.org/issue?@action=redirect&bpo=40241

   (4) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (5) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (7) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (8) https://bugs.python.org/issue?@action=redirect&bpo=40170

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39947


File: python.info,  Node: Python 3 9 0 alpha 5,  Next: Python 3 9 0 alpha 4,  Prev: Python 3 9 0 alpha 6,  Up: 変更履歴

1.23.42 Python 3.9.0 alpha 5
----------------------------

'Release date: 2020-03-23'

* Menu:

* Security: Security<27>.
* Core and Builtins: Core and Builtins<42>.
* Library: Library<41>.
* Documentation: Documentation<36>.
* Tests: Tests<39>.
* Build: Build<41>.
* Windows: Windows<37>.
* macOS: macOS<32>.
* IDLE: IDLE<28>.
* Tools/Demos: Tools/Demos<19>.
* C API: C API<40>.


File: python.info,  Node: Security<27>,  Next: Core and Builtins<42>,  Up: Python 3 9 0 alpha 5

1.23.42.1 Security
..................

   - bpo-38576(1): Disallow control characters in hostnames in
     http.client, addressing CVE 2019-18348(2).  Such potentially
     malicious header injection URLs now cause a InvalidURL to be
     raised.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38576

   (2) https://www.cve.org/CVERecord?id=CVE-2019-18348


File: python.info,  Node: Core and Builtins<42>,  Next: Library<41>,  Prev: Security<27>,  Up: Python 3 9 0 alpha 5

1.23.42.2 Core and Builtins
...........................

   - bpo-40010(1): Optimize pending calls in multithreaded applications.
     If a thread different than the main thread schedules a pending call
     (*note Py_AddPendingCall(): 94f.), the bytecode evaluation loop is
     no longer interrupted at each bytecode instruction to check for
     pending calls which cannot be executed.  Only the main thread can
     execute pending calls.

     Previously, the bytecode evaluation loop was interrupted at each
     instruction until the main thread executes pending calls.

   - bpo-1635741(2): Port _weakref extension module to multiphase
     initialization ( PEP 489(3)).

   - bpo-1635741(4): Port _collections module to multiphase
     initialization ( PEP 489(5)).

   - bpo-40010(6): Optimize signal handling in multithreaded
     applications.  If a thread different than the main thread gets a
     signal, the bytecode evaluation loop is no longer interrupted at
     each bytecode instruction to check for pending signals which cannot
     be handled.  Only the main thread of the main interpreter can
     handle signals.

     Previously, the bytecode evaluation loop was interrupted at each
     instruction until the main thread handles signals.

   - bpo-39984(7): If *note Py_AddPendingCall(): 94f. is called in a
     subinterpreter, the function 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.

   - bpo-1635741(8): Port _heapq module to multiphase initialization.

   - bpo-1635741(9): Port itertools module to multiphase initialization
     ( PEP 489(10)).

   - bpo-37207(11): Speed up calls to ‘frozenset()’ by using the PEP
     590(12) ‘vectorcall’ calling convention.  Patch by Donghee Na.

   - bpo-39984(13): subinterpreters: Move
     ‘_PyRuntimeState.ceval.tracing_possible’ to
     ‘PyInterpreterState.ceval.tracing_possible’: each interpreter now
     has its own variable.

   - bpo-37207(14): Speed up calls to ‘set()’ by using the PEP 590(15)
     ‘vectorcall’ calling convention.  Patch by Donghee Na.

   - bpo-1635741(16): Port _statistics module to multiphase
     initialization ( PEP 489(17)).

   - bpo-39968(18): Use inline function to replace extension modules'
     get_module_state macros.

   - bpo-39965(19): Correctly raise ‘SyntaxError’ if 'await' is used
     inside non-async functions and ‘PyCF_ALLOW_TOP_LEVEL_AWAIT’ is set
     (like in the asyncio REPL). Patch by Pablo Galindo.

   - bpo-39562(20): Allow executing asynchronous comprehensions on the
     top level when the ‘PyCF_ALLOW_TOP_LEVEL_AWAIT’ flag is given.
     Patch by Batuhan Taskaya.

   - bpo-37207(21): Speed up calls to ‘tuple()’ by using the PEP 590(22)
     ‘vectorcall’ calling convention.  Patch by Donghee Na.

   - bpo-38373(23): Changed list overallocation strategy.  It no longer
     overallocates if the new size is closer to overallocated size than
     to the old size and adds padding.

   - bpo-39926(24): Update Unicode database to Unicode version 13.0.0.

   - bpo-19466(25): Clear the frames of daemon threads earlier during
     the Python shutdown to call objects destructors.  So "unclosed
     file" resource warnings are now emitted for daemon threads in a
     more reliable way.

   - bpo-38894(26): Fix a bug that was causing incomplete results when
     calling ‘pathlib.Path.glob’ in the presence of symlinks that point
     to files where the user does not have read access.  Patch by Pablo
     Galindo and Matt Wozniski.

   - bpo-39877(27): Fix *note PyEval_RestoreThread(): 383. random crash
     at exit with daemon threads.  It now accesses the ‘_PyRuntime’
     variable directly instead of using ‘tstate->interp->runtime’, since
     ‘tstate’ can be a dangling pointer after *note Py_Finalize(): 1321.
     has been called.  Moreover, the daemon thread now exits before
     trying to take the GIL.

   - bpo-39871(28): Fix a possible *note SystemError: 541. in
     ‘math.{atan2,copysign,remainder}()’ when the first argument cannot
     be converted to a *note float: 2ce.  Patch by Zackery Spytz.

   - bpo-39776(29): Fix race condition where threads created by
     PyGILState_Ensure() could get a duplicate id.

     This affects consumers of tstate->id like the contextvar caching
     machinery, which could return invalid cached objects under heavy
     thread load (observed in embedded scenarios).

   - bpo-39778(30): Fixed a crash due to incorrect handling of weak
     references in ‘collections.OrderedDict’ classes.  Patch by Pablo
     Galindo.

   - bpo-1635741(31): Port audioop extension module to multiphase
     initialization ( PEP 489(32)).

   - bpo-39702(33): Relax *note decorator: 6fc. grammar restrictions to
     allow any valid expression ( PEP 614(34)).

   - bpo-38091(35): Tweak import deadlock detection code to not deadlock
     itself.

   - bpo-1635741(36): Port _locale extension module to multiphase
     initialization ( PEP 489(37)).

   - bpo-39087(38): Optimize *note PyUnicode_AsUTF8(): b89. and *note
     PyUnicode_AsUTF8AndSize(): 866. slightly when they need to create
     internal UTF-8 cache.

   - bpo-39520(39): Fix unparsing of ext slices with no items
     (‘foo[:,]’).  Patch by Batuhan Taskaya.

   - bpo-39220(40): Do not optimize annotations if 'from __future__
     import annotations' is used.  Patch by Pablo Galindo.

   - bpo-35712(41): Using *note NotImplemented: 79d. in a boolean
     context has been deprecated.  Patch contributed by Josh Rosenberg.

   - bpo-22490(42): Don't leak environment variable
     ‘__PYVENV_LAUNCHER__’ into the interpreter session on macOS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40010

   (2) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (3) https://peps.python.org/pep-0489/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (5) https://peps.python.org/pep-0489/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=40010

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39984

   (8) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (9) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (10) https://peps.python.org/pep-0489/

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (12) https://peps.python.org/pep-0590/

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39984

   (14) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (15) https://peps.python.org/pep-0590/

   (16) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (17) https://peps.python.org/pep-0489/

   (18) https://bugs.python.org/issue?@action=redirect&bpo=39968

   (19) https://bugs.python.org/issue?@action=redirect&bpo=39965

   (20) https://bugs.python.org/issue?@action=redirect&bpo=39562

   (21) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (22) https://peps.python.org/pep-0590/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=38373

   (24) https://bugs.python.org/issue?@action=redirect&bpo=39926

   (25) https://bugs.python.org/issue?@action=redirect&bpo=19466

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38894

   (27) https://bugs.python.org/issue?@action=redirect&bpo=39877

   (28) https://bugs.python.org/issue?@action=redirect&bpo=39871

   (29) https://bugs.python.org/issue?@action=redirect&bpo=39776

   (30) https://bugs.python.org/issue?@action=redirect&bpo=39778

   (31) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (32) https://peps.python.org/pep-0489/

   (33) https://bugs.python.org/issue?@action=redirect&bpo=39702

   (34) https://peps.python.org/pep-0614/

   (35) https://bugs.python.org/issue?@action=redirect&bpo=38091

   (36) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (37) https://peps.python.org/pep-0489/

   (38) https://bugs.python.org/issue?@action=redirect&bpo=39087

   (39) https://bugs.python.org/issue?@action=redirect&bpo=39520

   (40) https://bugs.python.org/issue?@action=redirect&bpo=39220

   (41) https://bugs.python.org/issue?@action=redirect&bpo=35712

   (42) https://bugs.python.org/issue?@action=redirect&bpo=22490


File: python.info,  Node: Library<41>,  Next: Documentation<36>,  Prev: Core and Builtins<42>,  Up: Python 3 9 0 alpha 5

1.23.42.3 Library
.................

   - bpo-39830(1): Add *note zipfile.Path: 695. to ‘__all__’ in the
     *note zipfile: 117. module.

   - bpo-40000(2): Improved error messages for validation of
     ‘ast.Constant’ nodes.  Patch by Batuhan Taskaya.

   - bpo-39999(3): ‘__module__’ of the AST node classes is now set to
     "ast" instead of "_ast".  Added docstrings for dummy AST node
     classes and deprecated attributes.

   - bpo-39991(4): *note uuid.getnode(): b75. now skips IPv6 addresses
     with the same string length than a MAC address (17 characters):
     only use MAC addresses.

   - bpo-39988(5): Deprecated ‘ast.AugLoad’ and ‘ast.AugStore’ node
     classes because they are no longer used.

   - bpo-39656(6): Ensure ‘bin/python3.#’ is always present in virtual
     environments on POSIX platforms - by Anthony Sottile.

   - bpo-39969(7): Deprecated ‘ast.Param’ node class because it's no
     longer used.  Patch by Batuhan Taskaya.

   - bpo-39360(8): Ensure all workers exit when finalizing a
     ‘multiprocessing.Pool’ implicitly via the module finalization
     handlers of multiprocessing.  This fixes a deadlock situation that
     can be experienced when the Pool is not properly finalized via the
     context manager or a call to ‘multiprocessing.Pool.terminate’.
     Patch by Batuhan Taskaya and Pablo Galindo.

   - bpo-35370(9): sys.settrace(), sys.setprofile() and
     _lsprof.Profiler.enable() now properly report *note PySys_Audit():
     348. error if "sys.setprofile" or "sys.settrace" audit event is
     denied.

   - bpo-39936(10): AIX: Fix _aix_support module when the subprocess is
     not available, when building Python from scratch.  It now uses new
     private _bootsubprocess module, rather than having two
     implementations depending if subprocess is available or not.  So
     _aix_support.aix_platform() result is now the same if subprocess is
     available or not.

   - bpo-36144(11): *note collections.OrderedDict: 5a5. now implements
     ‘|’ and ‘|=’ ( PEP 584(12)).

   - bpo-39652(13): The column name found in
     ‘sqlite3.Cursor.description’ is now truncated on the first '[' only
     if the PARSE_COLNAMES option is set.

   - bpo-39915(14): Ensure *note
     unittest.mock.AsyncMock.await_args_list: 18ea. has call objects in
     the order of awaited arguments instead of using *note
     unittest.mock.Mock.call_args: 18eb. which has the last value of the
     call.  Patch by Karthikeyan Singaravelan.

   - bpo-36144(15): Updated *note os.environ: 118a. and *note
     os.environb: 11e8. to support PEP 584(16)'s merge (‘|’) and update
     (‘|=’) operators.

   - bpo-38662(17): The ‘ensurepip’ module now invokes ‘pip’ via the
     ‘runpy’ module.  Hence it is no longer tightly coupled with the
     internal API of the bundled ‘pip’ version, allowing easier updates
     to a newer ‘pip’ version both internally and for distributors.

   - bpo-38075(18): Fix the *note random.Random.seed(): 18ec. method
     when a *note bool: 434. is passed as the seed.

   - bpo-39916(19): More reliable use of ‘os.scandir()’ in
     ‘Path.glob()’.  It no longer emits a ResourceWarning when
     interrupted.

   - bpo-39850(20): *note multiprocessing: 86. now supports abstract
     socket addresses (if abstract sockets are supported in the running
     platform).  When creating arbitrary addresses (like when
     default-constructing *note multiprocessing.connection.Listener:
     160d. objects) abstract sockets are preferred to avoid the case
     when the temporary-file-generated address is too large for an
     AF_UNIX socket address.  Patch by Pablo Galindo.

   - bpo-36287(21): *note ast.dump(): 8b2. no longer outputs optional
     fields and attributes with default values.  The default values for
     optional fields and attributes of AST nodes are now set as class
     attributes (e.g.  ‘Constant.kind’ is set to ‘None’).

   - bpo-39889(22): Fixed *note ast.unparse(): 8b3. for extended slices
     containing a single element (e.g.  ‘a[i:j,]’).  Remove redundant
     tuples when index with a tuple (e.g.  ‘a[i, j]’).

   - bpo-39828(23): Fix *note json.tool: 77. to catch *note
     BrokenPipeError: 1030.  Patch by Donghee Na.

   - bpo-13487(24): Avoid a possible '"RuntimeError: dictionary changed
     size during iteration"' from *note inspect.getmodule(): 174f. when
     it tried to loop through *note sys.modules: 18d6.

   - bpo-39674(25): Revert "bpo-37330(26): open() no longer accept 'U'
     in file mode".  The "U" mode of open() is kept in Python 3.9 to
     ease transition from Python 2.7, but will be removed in Python
     3.10.

   - bpo-28577(27): The hosts method on 32-bit prefix length
     IPv4Networks and 128-bit prefix IPv6Networks now returns a list
     containing the single Address instead of an empty list.

   - bpo-39826(28): Add getConnection method to logging HTTPHandler to
     enable custom connections.

   - bpo-39763(29): Reimplement ‘distutils.spawn.spawn’ function with
     the *note subprocess: c1. module.

   - bpo-39794(30): Add -without-decimal-contextvar build option.  This
     enables a thread-local rather than a coroutine local context.

   - bpo-36144(31): *note collections.defaultdict: 118d. now implements
     ‘|’ ( PEP 584(32)).

   - bpo-39517(33): Fix runpy.run_path() when using pathlike objects

   - bpo-39775(34): Change ‘inspect.Signature.parameters’ back to
     ‘collections.OrderedDict’.  This was changed to ‘dict’ in Python
     3.9.0a4.

   - bpo-39678(35): Refactor queue_manager in *note
     concurrent.futures.ProcessPoolExecutor: 8bc. to make it easier to
     maintain.

   - bpo-39764(36): Fix AttributeError when calling get_stack on a
     PyAsyncGenObject Task

   - bpo-39769(37): The *note compileall.compile_dir(): af4. function's
     'ddir' parameter and the compileall command line flag ‘-d’ no
     longer write the wrong pathname to the generated pyc file for
     submodules beneath the root of the directory tree being compiled.
     This fixes a regression introduced with Python 3.5.

   - bpo-36144(38): *note types.MappingProxyType: 43a. objects now
     support the merge (‘|’) operator from PEP 584(39).

   - bpo-38691(40): The *note importlib: 6b. module now ignores the
     *note PYTHONCASEOK: 92a. environment variable when the *note -E:
     92b. or *note -I: 92c. command line options are being used.

   - bpo-39719(41): Remove ‘tempfile.SpooledTemporaryFile.softspace()’
     as files no longer have the ‘softspace’ attribute in Python 3.
     Patch by Shantanu.

   - bpo-39667(42): Improve pathlib.Path compatibility on zipfile.Path
     and correct performance degradation as found in zipp 3.0.

   - bpo-39638(43): Keep ASDL signatures in the docstrings for ‘AST’
     nodes.  Patch by Batuhan Taskaya

   - bpo-39639(44): Deprecated ‘ast.Suite’ node class because it's no
     longer used.  Patch by Batuhan Taskaya.

   - bpo-39609(45): Add thread_name_prefix to default asyncio executor

   - bpo-39548(46): Fix handling of header in *note
     urllib.request.AbstractDigestAuthHandler: 18ed. when the optional
     ‘qop’ parameter is not present.

   - bpo-39509(47): HTTP status codes ‘103 EARLY_HINTS’ and ‘425
     TOO_EARLY’ are added to *note http.HTTPStatus: 8ce.  Patch by
     Donghee Na.

   - bpo-39507(48): Adding HTTP status 418 "I'm a Teapot" to HTTPStatus
     in http library.  Patch by Ross Rhodes.

   - bpo-39495(49): Remove default value from 'attrs' parameter of *note
     xml.etree.ElementTree.TreeBuilder.start(): 18ee. for consistency
     between Python and C implementations.

   - bpo-38971(50): Open issue in the BPO indicated a desire to make the
     implementation of codecs.open() at parity with io.open(), which
     implements a try/except to assure file stream gets closed before an
     exception is raised.

   - bpo-38641(51): Added starred expressions support to ‘return’ and
     ‘yield’ statements for ‘lib2to3’.  Patch by Vlad Emelianov.

   - bpo-37534(52): When using minidom module to generate XML documents
     the ability to add Standalone Document Declaration is added.  All
     the changes are made to generate a document in compliance with
     Extensible Markup Language (XML) 1.0 (Fifth Edition) W3C
     Recommendation (available here:
     ‘https://www.w3.org/TR/xml/#sec-prolog-dtd’).

   - bpo-34788(53): Add support for scoped IPv6 addresses to *note
     ipaddress: 74.  Patch by Oleksandr Pavliuk.

   - bpo-34822(54): Simplified AST for subscription.  Simple indices are
     now represented by their value, extended slices are represented as
     tuples.  *note ast: 7. classes ‘Index’ and ‘ExtSlice’ are
     considered deprecated and will be removed in future Python
     versions.  In the meantime, ‘Index(value)’ now returns a ‘value’
     itself, ‘ExtSlice(slices)’ returns ‘Tuple(slices, Load())’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39830

   (2) https://bugs.python.org/issue?@action=redirect&bpo=40000

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39999

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39991

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39988

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39656

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39969

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39360

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35370

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39936

   (11) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (12) https://peps.python.org/pep-0584/

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39652

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39915

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (16) https://peps.python.org/pep-0584/

   (17) https://bugs.python.org/issue?@action=redirect&bpo=38662

   (18) https://bugs.python.org/issue?@action=redirect&bpo=38075

   (19) https://bugs.python.org/issue?@action=redirect&bpo=39916

   (20) https://bugs.python.org/issue?@action=redirect&bpo=39850

   (21) https://bugs.python.org/issue?@action=redirect&bpo=36287

   (22) https://bugs.python.org/issue?@action=redirect&bpo=39889

   (23) https://bugs.python.org/issue?@action=redirect&bpo=39828

   (24) https://bugs.python.org/issue?@action=redirect&bpo=13487

   (25) https://bugs.python.org/issue?@action=redirect&bpo=39674

   (26) https://bugs.python.org/issue?@action=redirect&bpo=37330

   (27) https://bugs.python.org/issue?@action=redirect&bpo=28577

   (28) https://bugs.python.org/issue?@action=redirect&bpo=39826

   (29) https://bugs.python.org/issue?@action=redirect&bpo=39763

   (30) https://bugs.python.org/issue?@action=redirect&bpo=39794

   (31) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (32) https://peps.python.org/pep-0584/

   (33) https://bugs.python.org/issue?@action=redirect&bpo=39517

   (34) https://bugs.python.org/issue?@action=redirect&bpo=39775

   (35) https://bugs.python.org/issue?@action=redirect&bpo=39678

   (36) https://bugs.python.org/issue?@action=redirect&bpo=39764

   (37) https://bugs.python.org/issue?@action=redirect&bpo=39769

   (38) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (39) https://peps.python.org/pep-0584/

   (40) https://bugs.python.org/issue?@action=redirect&bpo=38691

   (41) https://bugs.python.org/issue?@action=redirect&bpo=39719

   (42) https://bugs.python.org/issue?@action=redirect&bpo=39667

   (43) https://bugs.python.org/issue?@action=redirect&bpo=39638

   (44) https://bugs.python.org/issue?@action=redirect&bpo=39639

   (45) https://bugs.python.org/issue?@action=redirect&bpo=39609

   (46) https://bugs.python.org/issue?@action=redirect&bpo=39548

   (47) https://bugs.python.org/issue?@action=redirect&bpo=39509

   (48) https://bugs.python.org/issue?@action=redirect&bpo=39507

   (49) https://bugs.python.org/issue?@action=redirect&bpo=39495

   (50) https://bugs.python.org/issue?@action=redirect&bpo=38971

   (51) https://bugs.python.org/issue?@action=redirect&bpo=38641

   (52) https://bugs.python.org/issue?@action=redirect&bpo=37534

   (53) https://bugs.python.org/issue?@action=redirect&bpo=34788

   (54) https://bugs.python.org/issue?@action=redirect&bpo=34822


File: python.info,  Node: Documentation<36>,  Next: Tests<39>,  Prev: Library<41>,  Up: Python 3 9 0 alpha 5

1.23.42.4 Documentation
.......................

   - bpo-39868(1): Updated the Language Reference for PEP 572(2).

   - bpo-13790(3): Change 'string' to 'specification' in format doc.

   - bpo-17422(4): The language reference no longer restricts default
     class namespaces to dicts only.

   - bpo-39530(5): Fix misleading documentation about mixed-type numeric
     comparisons.

   - bpo-39718(6): Update *note token: e3. documentation to reflect
     additions in Python 3.8

   - bpo-39677(7): Changed operand name of 'MAKE_FUNCTION' from 'argc'
     to 'flags' for module *note dis: 30.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39868

   (2) https://peps.python.org/pep-0572/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13790

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17422

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39530

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39718

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39677


File: python.info,  Node: Tests<39>,  Next: Build<41>,  Prev: Documentation<36>,  Up: Python 3 9 0 alpha 5

1.23.42.5 Tests
...............

   - bpo-40019(1): test_gdb now skips tests if it detects that gdb
     failed to read debug information because the Python binary is
     optimized.

   - bpo-27807(2): ‘test_site.test_startup_imports()’ is now skipped if
     a path of *note sys.path: 38e. contains a ‘.pth’ file.

   - bpo-26067(3): Do not fail test_shutil test_chown test when uid or
     gid of user cannot be resolved to a name.

   - bpo-39855(4): test_subprocess.test_user() now skips the test on an
     user name if the user name doesn't exist.  For example, skip the
     test if the user "nobody" doesn't exist on Linux.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40019

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27807

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26067

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39855


File: python.info,  Node: Build<41>,  Next: Windows<37>,  Prev: Tests<39>,  Up: Python 3 9 0 alpha 5

1.23.42.6 Build
...............

   - bpo-39761(1): Fix build with DTrace but without additional DFLAGS.

   - bpo-39763(2): setup.py now uses a basic implementation of the *note
     subprocess: c1. module if the *note subprocess: c1. module is not
     available: before required C extension modules are built.

   - bpo-1294959(3): Add ‘--with-platlibdir’ option to the configure
     script: name of the platform-specific library directory, stored in
     the new *note sys.platlibdir: 906. attribute.  It is used to build
     the path of platform-specific extension modules and the path of the
     standard library.  It is equal to ‘"lib"’ on most platforms.  On
     Fedora and SuSE, it is equal to ‘"lib64"’ on 64-bit platforms.
     Patch by Jan Matějek, Matěj Cepl, Charalampos Stratakis and Victor
     Stinner.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39761

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39763

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1294959


File: python.info,  Node: Windows<37>,  Next: macOS<32>,  Prev: Build<41>,  Up: Python 3 9 0 alpha 5

1.23.42.7 Windows
.................

   - bpo-39930(1): Ensures the required ‘vcruntime140.dll’ is included
     in install packages.

   - bpo-39847(2): Avoid hang when computer is hibernated whilst waiting
     for a mutex (for lock-related objects from *note threading: d6.)
     around 49-day uptime.

   - bpo-38597(3): ‘distutils’ will no longer statically link
     ‘vcruntime140.dll’ when a redistributable version is unavailable.
     All future releases of CPython will include a copy of this DLL to
     ensure distributed extensions can continue to load.

   - bpo-38380(4): Update Windows builds to use SQLite 3.31.1

   - bpo-39789(5): Update Windows release build machines to Visual
     Studio 2019 (MSVC 14.2).

   - bpo-34803(6): Package for nuget.org now includes repository
     reference and bundled icon image.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39930

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39847

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38597

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38380

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39789

   (6) https://bugs.python.org/issue?@action=redirect&bpo=34803


File: python.info,  Node: macOS<32>,  Next: IDLE<28>,  Prev: Windows<37>,  Up: Python 3 9 0 alpha 5

1.23.42.8 macOS
...............

   - bpo-38380(1): Update macOS builds to use SQLite 3.31.1

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38380


File: python.info,  Node: IDLE<28>,  Next: Tools/Demos<19>,  Prev: macOS<32>,  Up: Python 3 9 0 alpha 5

1.23.42.9 IDLE
..............

   - bpo-27115(1): For 'Go to Line', use a Query box subclass with IDLE
     standard behavior and improved error checking.

   - bpo-39885(2): Since clicking to get an IDLE context menu moves the
     cursor, any text selection should be and now is cleared.

   - bpo-39852(3): Edit "Go to line" now clears any selection,
     preventing accidental deletion.  It also updates Ln and Col on the
     status bar.

   - bpo-39781(4): Selecting code context lines no longer causes a jump.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27115

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39885

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39852

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39781


File: python.info,  Node: Tools/Demos<19>,  Next: C API<40>,  Prev: IDLE<28>,  Up: Python 3 9 0 alpha 5

1.23.42.10 Tools/Demos
......................

   - bpo-36184(1): Port python-gdb.py to FreeBSD. python-gdb.py now
     checks for "take_gil" function name to check if a frame tries to
     acquire the GIL, instead of checking for "pthread_cond_timedwait"
     which is specific to Linux and can be a different condition than
     the GIL.

   - bpo-38080(2): Added support to fix ‘getproxies’ in the
     ‘lib2to3.fixes.fix_urllib’ module.  Patch by José Roberto Meza
     Cabrera.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36184

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38080


File: python.info,  Node: C API<40>,  Prev: Tools/Demos<19>,  Up: Python 3 9 0 alpha 5

1.23.42.11 C API
................

   - bpo-40024(1): Add *note PyModule_AddType(): 943. helper function:
     add a type to a module.  Patch by Donghee Na.

   - bpo-39946(2): Remove ‘_PyRuntime.getframe’ hook and remove
     ‘_PyThreadState_GetFrame’ macro which was an alias to
     ‘_PyRuntime.getframe’.  They were only exposed by the internal C
     API. Remove also ‘PyThreadFrameGetter’ type.

   - bpo-39947(3): Add *note PyThreadState_GetFrame(): 759. function:
     get the current frame of a Python thread state.

   - bpo-37207(4): Add _PyArg_NoKwnames helper function.  Patch by
     Donghee Na.

   - bpo-39947(5): Add *note PyThreadState_GetInterpreter(): 93f.: get
     the interpreter of a Python thread state.

   - bpo-39947(6): Add *note PyInterpreterState_Get(): 387. function to
     the limited C API.

   - bpo-35370(7): If *note PySys_Audit(): 348. fails in *note
     PyEval_SetProfile(): 14a6. or *note PyEval_SetTrace(): 14a7, log
     the error as an unraisable exception.

   - bpo-39947(8): Move the static inline function flavor of
     Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() to the internal
     C API: they access PyThreadState attributes.  The limited C API
     provides regular functions which hide implementation details.

   - bpo-39947(9): Py_TRASHCAN_BEGIN_CONDITION and Py_TRASHCAN_END macro
     no longer access PyThreadState attributes, but call new private
     _PyTrash_begin() and _PyTrash_end() functions which hide
     implementation details.

   - bpo-39884(10): *note PyDescr_NewMethod(): 18f7. and *note
     PyCFunction_NewEx(): 18f8. now include the method name in the
     SystemError "bad call flags" error message to ease debug.

   - bpo-39877(11): Deprecated ‘PyEval_InitThreads()’ and
     ‘PyEval_ThreadsInitialized()’.  Calling ‘PyEval_InitThreads()’ now
     does nothing.

   - bpo-38249(12): *note Py_UNREACHABLE: b83. is now implemented with
     ‘__builtin_unreachable()’ and analogs in release mode.

   - bpo-38643(13): *note PyNumber_ToBase(): 1755. now raises a *note
     SystemError: 541. instead of crashing when called with invalid
     base.

   - bpo-39882(14): The *note Py_FatalError(): 951. function is replaced
     with a macro which logs automatically the name of the current
     function, unless the ‘Py_LIMITED_API’ macro is defined.

   - bpo-39824(15): Extension modules: *note m_traverse: 948, *note
     m_clear: 949. and *note m_free: 94a. functions of *note
     PyModuleDef: 94b. are no longer called if the module state was
     requested but is not allocated yet.  This is the case immediately
     after the module is created and before the module is executed
     (*note Py_mod_exec: 94c. function).  More precisely, these
     functions are not called if *note m_size: 94d. is greater than 0
     and the module state (as returned by *note PyModule_GetState():
     94e.) is ‘NULL’.

     Extension modules without module state (‘m_size <= 0’) are not
     affected.

   - bpo-38913(16): Fixed segfault in ‘Py_BuildValue()’ called with a
     format containing "#" and undefined PY_SSIZE_T_CLEAN whwn an
     exception is set.

   - bpo-38500(17): Add a private API to get and set the frame
     evaluation function: add *note
     _PyInterpreterState_GetEvalFrameFunc(): 18f9. and *note
     _PyInterpreterState_SetEvalFrameFunc(): 18fa. C functions.  The
     *note _PyFrameEvalFunction: 741. function type now takes a 'tstate'
     parameter.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=40024

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39946

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39947

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39947

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39947

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35370

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39947

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39947

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39884

   (11) https://bugs.python.org/issue?@action=redirect&bpo=39877

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38249

   (13) https://bugs.python.org/issue?@action=redirect&bpo=38643

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39882

   (15) https://bugs.python.org/issue?@action=redirect&bpo=39824

   (16) https://bugs.python.org/issue?@action=redirect&bpo=38913

   (17) https://bugs.python.org/issue?@action=redirect&bpo=38500


File: python.info,  Node: Python 3 9 0 alpha 4,  Next: Python 3 9 0 alpha 3,  Prev: Python 3 9 0 alpha 5,  Up: 変更履歴

1.23.43 Python 3.9.0 alpha 4
----------------------------

'Release date: 2020-02-25'

* Menu:

* Security: Security<28>.
* Core and Builtins: Core and Builtins<43>.
* Library: Library<42>.
* Documentation: Documentation<37>.
* Tests: Tests<40>.
* Build: Build<42>.
* Windows: Windows<38>.
* IDLE: IDLE<29>.
* C API: C API<41>.


File: python.info,  Node: Security<28>,  Next: Core and Builtins<43>,  Up: Python 3 9 0 alpha 4

1.23.43.1 Security
..................

   - bpo-39184(1): Add audit events to functions in ‘fcntl’, ‘msvcrt’,
     ‘os’, ‘resource’, ‘shutil’, ‘signal’ and ‘syslog’.

   - bpo-39401(2): Avoid unsafe DLL load at startup on Windows 7 and
     earlier.

   - bpo-39184(3): Add audit events to command execution functions in os
     and pty modules.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39184

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39401

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39184


File: python.info,  Node: Core and Builtins<43>,  Next: Library<42>,  Prev: Security<28>,  Up: Python 3 9 0 alpha 4

1.23.43.2 Core and Builtins
...........................

   - bpo-39382(1): Fix a use-after-free in the single inheritance path
     of ‘issubclass()’, when the ‘__bases__’ of an object has a single
     reference, and so does its first item.  Patch by Yonatan
     Goldschmidt.

   - bpo-39573(2): Update clinic tool to use *note Py_IS_TYPE(): 1780.
     Patch by Donghee Na.

   - bpo-39619(3): Enable use of *note os.chroot(): 18fe. on HP-UX
     systems.

   - bpo-39573(4): Add *note Py_IS_TYPE(): 1780. static inline function
     to check whether the object 'o' type is 'type'.

   - bpo-39606(5): Fix regression caused by fix for bpo-39386(6), that
     prevented calling ‘aclose’ on an async generator that had already
     been closed or exhausted.

   - bpo-39579(7): Change the ending column offset of ‘Attribute’ nodes
     constructed in ‘ast_for_dotted_name’ to point at the end of the
     current node and not at the end of the last ‘NAME’ node.

   - bpo-1635741(8): Port _crypt extension module to multiphase
     initialization ( PEP 489(9)).

   - bpo-1635741(10): Port _contextvars extension module to multiphase
     initialization ( PEP 489(11)).

   - bpo-39510(12): Fix segfault in ‘readinto()’ method on closed
     BufferedReader.

   - bpo-39502(13): Fix *note time.localtime(): 14a2. on 64-bit AIX to
     support years before 1902 and after 2038.  Patch by M Felt.

   - bpo-39492(14): Fix a reference cycle in the C Pickler that was
     preventing the garbage collection of deleted, pickled objects.

   - bpo-39453(15): Fixed a possible crash in ‘list.__contains__()’ when
     a list is changed during comparing items.  Patch by Donghee Na.

   - bpo-39434(16): *note floor division: 912. of float operation now
     has a better performance.  Also the message of *note
     ZeroDivisionError: 913. for this operation is updated.  Patch by
     Donghee Na.

   - bpo-1635741(17): Port _codecs extension module to multiphase
     initialization ( PEP 489(18)).

   - bpo-1635741(19): Port _bz2 extension module to multiphase
     initialization ( PEP 489(20)).

   - bpo-1635741(21): Port _abc extension module to multiphase
     initialization ( PEP 489(22)).

   - bpo-39320(23): Replace two complex bytecodes for building dicts
     with two simpler ones.  The new bytecodes ‘DICT_MERGE’ and
     ‘DICT_UPDATE’ have been added The old bytecodes ‘BUILD_MAP_UNPACK’
     and ‘BUILD_MAP_UNPACK_WITH_CALL’ have been removed.

   - bpo-39219(24): Syntax errors raised in the tokenizer now always set
     correct "text" and "offset" attributes.

   - bpo-36051(25): Drop the GIL during large ‘bytes.join’ operations.
     Patch by Bruce Merry.

   - bpo-38960(26): Fix DTrace build issues on FreeBSD. Patch by David
     Carlier.

   - bpo-37207(27): Speed up calls to ‘range()’ by about 30%, by using
     the PEP 590 ‘vectorcall’ calling convention.  Patch by Mark
     Shannon.

   - bpo-36144(28): *note dict: 237. (and *note collections.UserDict:
     18ff.) objects now support PEP 584's merge (‘|’) and update (‘|=’)
     operators.  Patch by Brandt Bucher.

   - bpo-32856(29): Optimized the idiom for assignment a temporary
     variable in comprehensions.  Now ‘for y in [expr]’ in
     comprehensions is as fast as a simple assignment ‘y = expr’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39382

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39619

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39606

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39386

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39579

   (8) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (9) https://peps.python.org/pep-0489/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (11) https://peps.python.org/pep-0489/

   (12) https://bugs.python.org/issue?@action=redirect&bpo=39510

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39502

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39492

   (15) https://bugs.python.org/issue?@action=redirect&bpo=39453

   (16) https://bugs.python.org/issue?@action=redirect&bpo=39434

   (17) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (18) https://peps.python.org/pep-0489/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (20) https://peps.python.org/pep-0489/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (22) https://peps.python.org/pep-0489/

   (23) https://bugs.python.org/issue?@action=redirect&bpo=39320

   (24) https://bugs.python.org/issue?@action=redirect&bpo=39219

   (25) https://bugs.python.org/issue?@action=redirect&bpo=36051

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38960

   (27) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (28) https://bugs.python.org/issue?@action=redirect&bpo=36144

   (29) https://bugs.python.org/issue?@action=redirect&bpo=32856


File: python.info,  Node: Library<42>,  Next: Documentation<37>,  Prev: Core and Builtins<43>,  Up: Python 3 9 0 alpha 4

1.23.43.3 Library
.................

   - bpo-30566(1): Fix *note IndexError: 14de. when trying to decode an
     invalid string with punycode codec.

   - bpo-39649(2): Remove obsolete check for ‘__args__’ in
     ‘bdb.Bdb.format_stack_entry’.

   - bpo-39648(3): Expanded *note math.gcd(): 8de. and *note math.lcm():
     8df. to handle multiple arguments.

   - bpo-39681(4): Fix a regression where the C pickle module wouldn't
     allow unpickling from a file-like object that doesn't expose a
     readinto() method.

   - bpo-35950(5): Raise *note io.UnsupportedOperation: 1901. in
     ‘io.BufferedReader.truncate()’ when it is called on a read-only
     *note io.BufferedReader: 11df. instance.

   - bpo-39479(6): Add *note math.lcm(): 8df. function: least common
     multiple.

   - bpo-39674(7): Revert "Do not expose abstract collection classes in
     the collections module" change (bpo-25988(8)).  Aliases to ABC like
     collections.Mapping are kept in Python 3.9 to ease transition from
     Python 2.7, but will be removed in Python 3.10.

   - bpo-39104(9): Fix hanging ProcessPoolExcutor on
     ‘shutdown(wait=False)’ when a task has failed pickling.

   - bpo-39627(10): Fixed TypedDict totality check for inherited keys.

   - bpo-39474(11): Fixed starting position of AST for expressions like
     ‘(a)(b)’, ‘(a)[b]’ and ‘(a).b’.

   - bpo-21016(12): The *note pydoc: a3. and *note trace: e6. modules
     now use the *note sysconfig: c5. module to get the path to the
     Python standard library, to support uncommon installation path like
     ‘/usr/lib64/python3.9/’ on Fedora.  Patch by Jan Matějek.

   - bpo-39590(13): Collections.deque now holds strong references during
     deque.__contains__ and deque.count, fixing crashes.

   - bpo-39586(14): The distutils ‘bdist_msi’ command is deprecated in
     Python 3.9, use ‘bdist_wheel’ (wheel packages) instead.

   - bpo-39595(15): Improved performance of zipfile.Path for files with
     a large number of entries.  Also improved performance and fixed
     minor issue as published with importlib_metadata 1.5(16).

   - bpo-39350(17): Fix regression in *note fractions.Fraction: 1c8. if
     the numerator and/or the denominator is an *note int: 238.
     subclass.  The *note math.gcd(): 8de. function is now used to
     normalize the 'numerator' and 'denominator'.  *note math.gcd():
     8de. always return a *note int: 238. type.  Previously, the GCD
     type depended on 'numerator' and 'denominator'.

   - bpo-39567(18): Added audit for *note os.walk(): 476, *note
     os.fwalk(): b29, *note pathlib.Path.glob(): 20e. and *note
     pathlib.Path.rglob(): 20f.

   - bpo-39559(19): Remove unused, undocumented argument ‘getters’ from
     *note uuid.getnode(): b75.

   - bpo-38149(20): *note sys.audit(): 151a. is now called only once per
     call of *note glob.glob(): 27f. and *note glob.iglob(): 7d2.

   - bpo-39546(21): Fix a regression in *note ArgumentParser: 503. where
     ‘allow_abbrev=False’ was ignored for long options that used a
     prefix character other than "-".

   - bpo-39450(22): Striped whitespace from docstring before returning
     it from ‘unittest.case.shortDescription()’.

   - bpo-12915(23): A new function ‘resolve_name’ has been added to the
     ‘pkgutil’ module.  This resolves a string of the form ‘'a.b.c.d'’
     or ‘'a.b:c.d'’ to an object.  In the example, ‘a.b’ is a
     package/module and ‘c.d’ is an object within that package/module
     reached via recursive attribute access.

   - bpo-39353(24): The *note binascii.crc_hqx(): 6ff. function is no
     longer deprecated.

   - bpo-39493(25): Mark ‘typing.IO.closed’ as a property

   - bpo-39491(26): Add *note typing.Annotated: 90b. and
     ‘include_extras’ parameter to *note typing.get_type_hints(): 67d.
     as part of PEP 593(27).  Patch by Till Varoquaux, documentation by
     Till Varoquaux and Konstantin Kashin.

   - bpo-39485(28): Fix a bug in *note unittest.mock.create_autospec():
     156b. that would complain about the wrong number of arguments for
     custom descriptors defined in an extension module returning
     functions.

   - bpo-38932(29): Mock fully resets child objects on reset_mock().
     Patch by Vegard Stikbakke

   - bpo-39082(30): Allow AsyncMock to correctly patch static/class
     methods

   - bpo-39432(31): Implement PEP-489 algorithm for non-ascii
     "PyInit_..."  symbol names in distutils to make it export the
     correct init symbol also on Windows.

   - bpo-18819(32): Omit ‘devmajor’ and ‘devminor’ fields for non-device
     files in *note tarfile: c8. archives, enabling bit-for-bit
     compatibility with GNU ‘tar(1)’.

   - bpo-39349(33): Added a new 'cancel_futures' parameter to *note
     concurrent.futures.Executor.shutdown(): 8bb. that cancels all
     pending futures which have not started running, instead of waiting
     for them to complete before shutting down the executor.

   - bpo-39274(34): ‘bool(fraction.Fraction)’ now returns a boolean even
     if (numerator != 0) does not return a boolean (ex: numpy number).

   - bpo-34793(35): Remove support for ‘with (await asyncio.lock):’ and
     ‘with (yield from asyncio.lock):’.  The same is correct for
     ‘asyncio.Condition’ and ‘asyncio.Semaphore’.

   - bpo-25597(36): Ensure, if ‘wraps’ is supplied to *note
     unittest.mock.MagicMock: e5a, it is used to calculate return values
     for the magic methods instead of using the default return values.
     Patch by Karthikeyan Singaravelan.

   - bpo-36350(37): ‘inspect.Signature.parameters’ and
     ‘inspect.BoundArguments.arguments’ are now dicts instead of
     OrderedDicts.  Patch contributed by Rémi Lapeyre.

   - bpo-35727(38): Fix sys.exit() and sys.exit(None) exit code
     propagation when used in multiprocessing.Process.

   - bpo-32173(39): * Add ‘lazycache’ function to ‘__all__’.  * Use
     ‘dict.clear’ to clear the cache.  * Refactoring ‘getline’ function
     and ‘checkcache’ function.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30566

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39649

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39648

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39681

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35950

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39479

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39674

   (8) https://bugs.python.org/issue?@action=redirect&bpo=25988

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39104

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39627

   (11) https://bugs.python.org/issue?@action=redirect&bpo=39474

   (12) https://bugs.python.org/issue?@action=redirect&bpo=21016

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39590

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39586

   (15) https://bugs.python.org/issue?@action=redirect&bpo=39595

   (16) 
https://importlib-metadata.readthedocs.io/en/latest/history.html#v1-5-0

   (17) https://bugs.python.org/issue?@action=redirect&bpo=39350

   (18) https://bugs.python.org/issue?@action=redirect&bpo=39567

   (19) https://bugs.python.org/issue?@action=redirect&bpo=39559

   (20) https://bugs.python.org/issue?@action=redirect&bpo=38149

   (21) https://bugs.python.org/issue?@action=redirect&bpo=39546

   (22) https://bugs.python.org/issue?@action=redirect&bpo=39450

   (23) https://bugs.python.org/issue?@action=redirect&bpo=12915

   (24) https://bugs.python.org/issue?@action=redirect&bpo=39353

   (25) https://bugs.python.org/issue?@action=redirect&bpo=39493

   (26) https://bugs.python.org/issue?@action=redirect&bpo=39491

   (27) https://peps.python.org/pep-0593/

   (28) https://bugs.python.org/issue?@action=redirect&bpo=39485

   (29) https://bugs.python.org/issue?@action=redirect&bpo=38932

   (30) https://bugs.python.org/issue?@action=redirect&bpo=39082

   (31) https://bugs.python.org/issue?@action=redirect&bpo=39432

   (32) https://bugs.python.org/issue?@action=redirect&bpo=18819

   (33) https://bugs.python.org/issue?@action=redirect&bpo=39349

   (34) https://bugs.python.org/issue?@action=redirect&bpo=39274

   (35) https://bugs.python.org/issue?@action=redirect&bpo=34793

   (36) https://bugs.python.org/issue?@action=redirect&bpo=25597

   (37) https://bugs.python.org/issue?@action=redirect&bpo=36350

   (38) https://bugs.python.org/issue?@action=redirect&bpo=35727

   (39) https://bugs.python.org/issue?@action=redirect&bpo=32173


File: python.info,  Node: Documentation<37>,  Next: Tests<40>,  Prev: Library<42>,  Up: Python 3 9 0 alpha 4

1.23.43.4 Documentation
.......................

   - bpo-17422(1): The language reference now specifies restrictions on
     class namespaces.  Adapted from a patch by Ethan Furman.

   - bpo-39572(2): Updated documentation of ‘total’ flag of ‘TypedDict’.

   - bpo-39654(3): In pyclbr doc, update 'class' to 'module' where
     appropriate and add readmodule comment.  Patch by Hakan Çelik.

   - bpo-39153(4): Clarify refcounting semantics for the following
     functions: - PyObject_SetItem - PyMapping_SetItemString -
     PyDict_SetItem - PyDict_SetItemString

   - bpo-39392(5): Explain that when filling with turtle, overlap
     regions may be left unfilled.

   - bpo-39369(6): Update mmap readline method description.  The fact
     that the readline method does update the file position should not
     be ignored since this might give the impression for the programmer
     that it doesn't update it.

   - bpo-9056(7): Include subsection in TOC for PDF version of docs.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17422

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39572

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39654

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39153

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39392

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39369

   (7) https://bugs.python.org/issue?@action=redirect&bpo=9056


File: python.info,  Node: Tests<40>,  Next: Build<42>,  Prev: Documentation<37>,  Up: Python 3 9 0 alpha 4

1.23.43.5 Tests
...............

   - bpo-38325(1): Skip tests on non-BMP characters of
     test_winconsoleio.

   - bpo-39502(2): Skip test_zipfile.test_add_file_after_2107() if *note
     time.localtime(): 14a2. fails with *note OverflowError: 84e.  It is
     the case on AIX 6.1 for example.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38325

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39502


File: python.info,  Node: Build<42>,  Next: Windows<38>,  Prev: Tests<40>,  Up: Python 3 9 0 alpha 4

1.23.43.6 Build
...............

   - bpo-39489(1): Remove ‘COUNT_ALLOCS’ special build.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39489


File: python.info,  Node: Windows<38>,  Next: IDLE<29>,  Prev: Build<42>,  Up: Python 3 9 0 alpha 4

1.23.43.7 Windows
.................

   - bpo-39553(1): Delete unused code related to SxS manifests.

   - bpo-39439(2): Honor the Python path when a virtualenv is active on
     Windows.

   - bpo-39393(3): Improve the error message when attempting to load a
     DLL with unresolved dependencies.

   - bpo-38883(4): *note home(): e10. and *note expanduser(): e0f. on
     Windows now prefer ‘USERPROFILE’ and no longer use ‘HOME’, which is
     not normally set for regular user accounts.  This makes them again
     behave like *note os.path.expanduser(): 9e2, which was changed to
     ignore ‘HOME’ in 3.8, see bpo-36264(5).

   - bpo-39185(6): The build.bat script has additional options for
     very-quiet output (-q) and very-verbose output (-vv)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39553

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39439

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39393

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38883

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36264

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39185


File: python.info,  Node: IDLE<29>,  Next: C API<41>,  Prev: Windows<38>,  Up: Python 3 9 0 alpha 4

1.23.43.8 IDLE
..............

   - bpo-39663(1): Add tests for pyparse find_good_parse_start().

   - bpo-39600(2): In the font configuration window, remove duplicated
     font names.

   - bpo-30780(3): Add remaining configdialog tests for buttons and
     highlights and keys tabs.

   - bpo-39388(4): IDLE Settings Cancel button now cancels pending
     changes

   - bpo-38792(5): Close an IDLE shell calltip if a *note
     KeyboardInterrupt: 99f. or shell restart occurs.  Patch by Zackery
     Spytz.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39663

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39600

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30780

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39388

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38792


File: python.info,  Node: C API<41>,  Prev: IDLE<29>,  Up: Python 3 9 0 alpha 4

1.23.43.9 C API
...............

   - bpo-35081(1): Move the ‘bytes_methods.h’ header file to the
     internal C API as ‘pycore_bytes_methods.h’: it only contains
     private symbols (prefixed by ‘_Py’), except of the
     ‘PyDoc_STRVAR_shared()’ macro.

   - bpo-35081(2): Move the ‘dtoa.h’ header file to the internal C API
     as ‘pycore_dtoa.h’: it only contains private functions (prefixed by
     ‘_Py’).  The *note math: 81. and *note cmath: 11. modules must now
     be compiled with the ‘Py_BUILD_CORE’ macro defined.

   - bpo-39573(3): Add *note Py_SET_SIZE(): 74e. function to set the
     size of an object.

   - bpo-39500(4): *note PyUnicode_IsIdentifier(): 1908. does not call
     *note Py_FatalError(): 951. anymore if the string is not ready.

   - bpo-39573(5): Add *note Py_SET_TYPE(): 74c. function to set the
     type of an object.

   - bpo-39573(6): Add a *note Py_SET_REFCNT(): 878. function to set the
     reference counter of an object.

   - bpo-39542(7): Convert *note PyType_HasFeature(): 18bd, *note
     PyType_Check(): 1909. and *note PyType_CheckExact(): 190a. macros
     to static inline functions.

   - bpo-39542(8): In the limited C API, ‘PyObject_INIT()’ and
     ‘PyObject_INIT_VAR()’ are now defined as aliases to *note
     PyObject_Init(): a38. and *note PyObject_InitVar(): 18bf. to make
     their implementation opaque.  It avoids to leak implementation
     details in the limited C API. Exclude the following functions from
     the limited C API: ‘_Py_NewReference()’, ‘_Py_ForgetReference()’,
     ‘_PyTraceMalloc_NewReference()’ and ‘_Py_GetRefTotal()’.

   - bpo-39542(9): Exclude trashcan mechanism from the limited C API: it
     requires access to PyTypeObject and PyThreadState structure fields,
     whereas these structures are opaque in the limited C API.

   - bpo-39511(10): The *note PyThreadState_Clear(): 1585. function now
     calls the ‘PyThreadState.on_delete’ callback.  Previously, that
     happened in *note PyThreadState_Delete(): 190b.

   - bpo-38076(11): Fix to clear the interpreter state only after
     clearing module globals to guarantee module state access from C
     Extensions during runtime destruction

   - bpo-39245(12): The Vectorcall API (PEP 590) was made public, adding
     the functions ‘PyObject_Vectorcall’, ‘PyObject_VectorcallMethod’,
     ‘PyVectorcall_Function’, ‘PyObject_CallOneArg’,
     ‘PyObject_CallMethodNoArgs’, ‘PyObject_CallMethodOneArg’,
     ‘PyObject_FastCallDict’, and the flag ‘Py_TPFLAGS_HAVE_VECTORCALL’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35081

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35081

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39500

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39573

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39542

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39542

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39542

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39511

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38076

   (12) https://bugs.python.org/issue?@action=redirect&bpo=39245


File: python.info,  Node: Python 3 9 0 alpha 3,  Next: Python 3 9 0 alpha 2,  Prev: Python 3 9 0 alpha 4,  Up: 変更履歴

1.23.44 Python 3.9.0 alpha 3
----------------------------

'Release date: 2020-01-24'

* Menu:

* Core and Builtins: Core and Builtins<44>.
* Library: Library<43>.
* Documentation: Documentation<38>.
* Build: Build<43>.
* IDLE: IDLE<30>.
* C API: C API<42>.


File: python.info,  Node: Core and Builtins<44>,  Next: Library<43>,  Up: Python 3 9 0 alpha 3

1.23.44.1 Core and Builtins
...........................

   - bpo-39427(1): Document all possibilities for the ‘-X’ options in
     the command line help section.  Patch by Pablo Galindo.

   - bpo-39421(2): Fix possible crashes when operating with the
     functions in the *note heapq: 5f. module and custom comparison
     operators.

   - bpo-39386(3): Prevent double awaiting of async iterator.

   - bpo-17005(4): Add ‘functools.TopologicalSorter’ to the *note
     functools: 55. module to offers functionality to perform
     topological sorting of graphs.  Patch by Pablo Galindo, Tim Peters
     and Larry Hastings.

   - bpo-39320(5): Replace four complex bytecodes for building sequences
     with three simpler ones.

     The following four bytecodes have been removed:

        * BUILD_LIST_UNPACK

        * BUILD_TUPLE_UNPACK

        * BUILD_SET_UNPACK

        * BUILD_TUPLE_UNPACK_WITH_CALL

     The following three bytecodes have been added:

        * LIST_TO_TUPLE

        * LIST_EXTEND

        * SET_UPDATE

   - bpo-39336(6): Import loaders which publish immutable module objects
     can now publish immutable packages in addition to individual
     modules.

   - bpo-39322(7): Added a new function *note gc.is_finalized(): 8cb. to
     check if an object has been finalized by the garbage collector.
     Patch by Pablo Galindo.

   - bpo-39048(8): Improve the displayed error message when incorrect
     types are passed to ‘async with’ statements by looking up the
     ‘__aenter__()’ special method before the ‘__aexit__()’ special
     method when entering an asynchronous context manager.  Patch by
     Géry Ogam.

   - bpo-39235(9): Fix AST end location for lone generator expression in
     function call, e.g.  f(i for i in a).

   - bpo-39209(10): Correctly handle multi-line tokens in interactive
     mode.  Patch by Pablo Galindo.

   - bpo-1635741(11): Port _json extension module to multiphase
     initialization ( PEP 489(12)).

   - bpo-39216(13): Fix constant folding optimization for positional
     only arguments - by Anthony Sottile.

   - bpo-39215(14): Fix ‘SystemError’ when nested function has
     annotation on positional-only argument - by Anthony Sottile.

   - bpo-39200(15): Correct the error message when calling the *note
     min(): ed3. or *note max(): ed4. with no arguments.  Patch by
     Donghee Na.

   - bpo-39200(16): Correct the error message when trying to construct
     *note range: 911. objects with no arguments.  Patch by Pablo
     Galindo.

   - bpo-39166(17): Fix incorrect line execution reporting in trace
     functions when tracing the last iteration of asynchronous for
     loops.  Patch by Pablo Galindo.

   - bpo-39114(18): Fix incorrect line execution reporting in trace
     functions when tracing exception handlers with name binding.  Patch
     by Pablo Galindo.

   - bpo-39156(19): Split the COMPARE_OP bytecode instruction into four
     distinct instructions.

        * COMPARE_OP for rich comparisons

        * IS_OP for 'is' and 'is not' tests

        * CONTAINS_OP for 'in' and 'is not' tests

        * JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except'
          statements.

     This improves the clarity of the interpreter and should provide a
     modest speedup.

   - bpo-38588(20): Fix possible crashes in dict and list when calling
     *note PyObject_RichCompareBool(): 190e.

   - bpo-13601(21): By default, ‘sys.stderr’ is line-buffered now, even
     if ‘stderr’ is redirected to a file.  You can still make
     ‘sys.stderr’ unbuffered by passing the *note -u: 190f. command-line
     option or setting the *note PYTHONUNBUFFERED: 1910. environment
     variable.

     (Contributed by Jendrik Seipp in bpo-13601(22).)

   - bpo-38610(23): Fix possible crashes in several list methods by
     holding strong references to list elements when calling *note
     PyObject_RichCompareBool(): 190e.

   - bpo-32021(24): Include brotli .br encoding in mimetypes
     encodings_map

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39427

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39421

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39386

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17005

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39320

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39336

   (7) https://bugs.python.org/issue?@action=redirect&bpo=39322

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39048

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39235

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39209

   (11) https://bugs.python.org/issue?@action=redirect&bpo=1635741

   (12) https://peps.python.org/pep-0489/

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39216

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39215

   (15) https://bugs.python.org/issue?@action=redirect&bpo=39200

   (16) https://bugs.python.org/issue?@action=redirect&bpo=39200

   (17) https://bugs.python.org/issue?@action=redirect&bpo=39166

   (18) https://bugs.python.org/issue?@action=redirect&bpo=39114

   (19) https://bugs.python.org/issue?@action=redirect&bpo=39156

   (20) https://bugs.python.org/issue?@action=redirect&bpo=38588

   (21) https://bugs.python.org/issue?@action=redirect&bpo=13601

   (22) https://bugs.python.org/issue?@action=redirect&bpo=13601

   (23) https://bugs.python.org/issue?@action=redirect&bpo=38610

   (24) https://bugs.python.org/issue?@action=redirect&bpo=32021


File: python.info,  Node: Library<43>,  Next: Documentation<38>,  Prev: Core and Builtins<44>,  Up: Python 3 9 0 alpha 3

1.23.44.2 Library
.................

   - bpo-39430(1): Fixed race condition in lazy imports in *note
     tarfile: c8.

   - bpo-39413(2): The *note os.unsetenv(): 8e9. function is now also
     available on Windows.

   - bpo-39390(3): Fixed a regression with the ‘ignore’ callback of
     *note shutil.copytree(): 9f7.  The argument types are now ‘str’ and
     ‘List[str]’ again.

   - bpo-39395(4): The *note os.putenv(): 8ea. and *note os.unsetenv():
     8e9. functions are now always available.

   - bpo-39406(5): If ‘setenv()’ C function is available, *note
     os.putenv(): 8ea. is now implemented with ‘setenv()’ instead of
     ‘putenv()’, so Python doesn't have to handle the environment
     variable memory.

   - bpo-39396(6): Fix ‘math.nextafter(-0.0, +0.0)’ on AIX 7.1.

   - bpo-29435(7): Allow *note tarfile.is_tarfile(): 17af. to be used
     with file and file-like objects, like *note zipfile.is_zipfile():
     12f9.  Patch by William Woodruff.

   - bpo-39377(8): Removed ‘encoding’ option from *note json.loads():
     923.  It has been deprecated since Python 3.1.

   - bpo-39389(9): Write accurate compression level metadata in *note
     gzip: 5d. archives, rather than always signaling maximum
     compression.

   - bpo-39366(10): The previously deprecated ‘xpath()’ and ‘xgtitle()’
     methods of ‘nntplib.NNTP’ have been removed.

   - bpo-39357(11): Remove the 'buffering' parameter of *note
     bz2.BZ2File: 832.  Since Python 3.0, it was ignored and using it
     was emitting *note DeprecationWarning: 18a.  Pass an open file
     object, to control how the file is opened.  The 'compresslevel'
     parameter becomes keyword-only.

   - bpo-39353(12): Deprecate binhex4 and hexbin4 standards.  Deprecate
     the ‘binhex’ module and the following *note binascii: c. functions:
     ‘b2a_hqx()’, ‘a2b_hqx()’, ‘rlecode_hqx()’, ‘rledecode_hqx()’, *note
     crc_hqx(): 6ff.

   - bpo-39351(13): Remove ‘base64.encodestring()’ and
     ‘base64.decodestring()’, aliases deprecated since Python 3.1: use
     *note base64.encodebytes(): 921. and *note base64.decodebytes():
     922. instead.

   - bpo-39350(14): Remove ‘fractions.gcd()’ function, deprecated since
     Python 3.5 (bpo-22486(15)): use *note math.gcd(): 8de. instead.

   - bpo-39329(16): *note LMTP: 8fd. constructor now has an optional
     'timeout' parameter.  Patch by Donghee Na.

   - bpo-39313(17): Add a new ‘exec_function’ option ('-exec-function'
     in the CLI) to ‘RefactoringTool’ for making ‘exec’ a function.
     Patch by Batuhan Taskaya.

   - bpo-39259(18): *note FTP_TLS: 8c9. and *note FTP_TLS: 8c9. now
     raise a *note ValueError: 1e3. if the given timeout for their
     constructor is zero to prevent the creation of a non-blocking
     socket.  Patch by Donghee Na.

   - bpo-39259(19): *note SMTP: 8fb. and *note SMTP_SSL: 8fc. now raise
     a *note ValueError: 1e3. if the given timeout for their constructor
     is zero to prevent the creation of a non-blocking socket.  Patch by
     Donghee Na.

   - bpo-39310(20): Add *note math.ulp(): 8e0.: return the value of the
     least significant bit of a float.

   - bpo-39297(21): Improved performance of importlib.metadata
     distribution discovery and resilients to inaccessible sys.path
     entries (importlib_metadata v1.4.0).

   - bpo-39259(22): ‘NNTP’ and ‘NNTP_SSL’ now raise a *note ValueError:
     1e3. if the given timeout for their constructor is zero to prevent
     the creation of a non-blocking socket.  Patch by Donghee Na.

   - bpo-38901(23): When you specify prompt='.'  or equivalently python
     -m venv -prompt .  ...  the basename of the current directory is
     used to set the created venv's prompt when it's activated.

   - bpo-39288(24): Add *note math.nextafter(): 465.: return the next
     floating-point value after 'x' towards 'y'.

   - bpo-39259(25): *note POP3: 8f2. and *note POP3_SSL: 8f3. now raise
     a *note ValueError: 1e3. if the given timeout for their constructor
     is zero to prevent the creation of a non-blocking socket.  Patch by
     Donghee Na.

   - bpo-39242(26): Updated the Gmane domain from news.gmane.org to
     news.gmane.io which is used for examples of ‘NNTP’ news reader
     server and nntplib tests.

   - bpo-35292(27): Proxy the ‘SimpleHTTPRequestHandler.guess_type’ to
     ‘mimetypes.guess_type’ so the ‘mimetypes.init’ is called lazily to
     avoid unnecessary costs when *note http.server: 68. module is
     imported.

   - bpo-39239(28): The *note select.epoll.unregister(): 928. method no
     longer ignores the *note EBADF: 929. error.

   - bpo-38907(29): In http.server script, restore binding to IPv4 on
     Windows.

   - bpo-39152(30): Fix ttk.Scale.configure([name]) to return
     configuration tuple for name or all options.  Giovanni Lombardo
     contributed part of the patch.

   - bpo-39198(31): If an exception were to be thrown in
     ‘Logger.isEnabledFor’ (say, by asyncio timeouts or stopit) , the
     ‘logging’ global lock may not be released appropriately, resulting
     in deadlock.  This change wraps that block of code with
     ‘try...finally’ to ensure the lock is released.

   - bpo-39191(32): Perform a check for running loop before starting a
     new task in ‘loop.run_until_complete()’ to fail fast; it prevents
     the side effect of new task spawning before exception raising.

   - bpo-38871(33): Correctly parenthesize filter-based statements that
     contain lambda expressions in ‘lib2to3’.  Patch by Donghee Na.

   - bpo-39142(34): A change was made to logging.config.dictConfig to
     avoid converting instances of named tuples to ConvertingTuple.
     It's assumed that named tuples are too specialised to be treated
     like ordinary tuples; if a user of named tuples requires
     ConvertingTuple functionality, they will have to implement that
     themselves in their named tuple class.

   - bpo-39158(35): ast.literal_eval() now supports empty sets.

   - bpo-39129(36): Fix import path for ‘asyncio.TimeoutError’

   - bpo-39057(37): ‘urllib.request.proxy_bypass_environment()’ now
     ignores leading dots and no longer ignores a trailing newline.

   - bpo-39056(38): Fixed handling invalid warning category in the -W
     option.  No longer import the re module if it is not needed.

   - bpo-39055(39): *note base64.b64decode(): 1912. with ‘validate=True’
     raises now a binascii.Error if the input ends with a single ‘\n’.

   - bpo-21600(40): Fix ‘mock.patch.stopall()’ to stop active patches
     that were created with ‘mock.patch.dict()’.

   - bpo-39019(41): Implement dummy ‘__class_getitem__’ for *note
     tempfile.SpooledTemporaryFile: 65f.

   - bpo-39019(42): Implement dummy ‘__class_getitem__’ for
     ‘subprocess.Popen’, ‘subprocess.CompletedProcess’

   - bpo-38914(43): Adjusted the wording of the warning issued by
     distutils' ‘check’ command when the ‘author’ and ‘maintainer’
     fields are supplied but no corresponding e-mail field
     (‘author_email’ or ‘maintainer_email’) is found.  The wording now
     reflects the fact that these fields are suggested, but not
     required.  Patch by Juergen Gmach.

   - bpo-38878(44): Fixed __subclasshook__ of *note os.PathLike: c1f. to
     return a correct result upon inheritance.  Patch by Bar Harel.

   - bpo-38615(45): *note IMAP4: 8d1. and *note IMAP4_SSL: 8d2. now have
     an optional 'timeout' parameter for their constructors.  Also, the
     *note open(): 8d3. method now has an optional 'timeout' parameter
     with this change.  The overridden methods of *note IMAP4_SSL: 8d2.
     and *note IMAP4_stream: 8d4. were applied to this change.  Patch by
     Donghee Na.

   - bpo-35182(46): Fixed ‘Popen.communicate()’ subsequent call crash
     when the child process has already closed any piped standard
     stream, but still continues to be running.  Patch by Andriy
     Maletsky.

   - bpo-38630(47): On Unix, *note subprocess.Popen.send_signal(): 1386.
     now polls the process status.  Polling reduces the risk of sending
     a signal to the wrong process if the process completed, the *note
     subprocess.Popen.returncode: 1913. attribute is still ‘None’, and
     the pid has been reassigned (recycled) to a new different process.

   - bpo-38536(48): Removes trailing space in formatted currency with
     ‘international=True’ and a locale with symbol following value.
     E.g.  ‘locale.currency(12.34, international=True)’ returned ‘'12,34
     EUR '’ instead of ‘'12,34 EUR'’.

   - bpo-38473(49): Use signature from inner mock for autospecced
     methods attached with ‘unittest.mock.attach_mock()’.  Patch by
     Karthikeyan Singaravelan.

   - bpo-38361(50): Fixed an issue where ‘ident’ could include a leading
     path separator when *note syslog.openlog(): 509. was called without
     arguments.

   - bpo-38293(51): Add *note copy.copy(): 4fd. and *note
     copy.deepcopy(): b3c. support to *note property(): 179. objects.

   - bpo-37958(52): Added the pstats.Stats.get_profile_dict() method to
     return the profile data as a StatsProfile instance.

   - bpo-28367(53): Termios magic constants for the following baud
     rates: - B500000 - B576000 - B921600 - B1000000 - B1152000 -
     B1500000 - B2000000 - B2500000 - B3000000 - B3500000 - B4000000
     Patch by Andrey Smirnov

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39430

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39413

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39390

   (4) https://bugs.python.org/issue?@action=redirect&bpo=39395

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39406

   (6) https://bugs.python.org/issue?@action=redirect&bpo=39396

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29435

   (8) https://bugs.python.org/issue?@action=redirect&bpo=39377

   (9) https://bugs.python.org/issue?@action=redirect&bpo=39389

   (10) https://bugs.python.org/issue?@action=redirect&bpo=39366

   (11) https://bugs.python.org/issue?@action=redirect&bpo=39357

   (12) https://bugs.python.org/issue?@action=redirect&bpo=39353

   (13) https://bugs.python.org/issue?@action=redirect&bpo=39351

   (14) https://bugs.python.org/issue?@action=redirect&bpo=39350

   (15) https://bugs.python.org/issue?@action=redirect&bpo=22486

   (16) https://bugs.python.org/issue?@action=redirect&bpo=39329

   (17) https://bugs.python.org/issue?@action=redirect&bpo=39313

   (18) https://bugs.python.org/issue?@action=redirect&bpo=39259

   (19) https://bugs.python.org/issue?@action=redirect&bpo=39259

   (20) https://bugs.python.org/issue?@action=redirect&bpo=39310

   (21) https://bugs.python.org/issue?@action=redirect&bpo=39297

   (22) https://bugs.python.org/issue?@action=redirect&bpo=39259

   (23) https://bugs.python.org/issue?@action=redirect&bpo=38901

   (24) https://bugs.python.org/issue?@action=redirect&bpo=39288

   (25) https://bugs.python.org/issue?@action=redirect&bpo=39259

   (26) https://bugs.python.org/issue?@action=redirect&bpo=39242

   (27) https://bugs.python.org/issue?@action=redirect&bpo=35292

   (28) https://bugs.python.org/issue?@action=redirect&bpo=39239

   (29) https://bugs.python.org/issue?@action=redirect&bpo=38907

   (30) https://bugs.python.org/issue?@action=redirect&bpo=39152

   (31) https://bugs.python.org/issue?@action=redirect&bpo=39198

   (32) https://bugs.python.org/issue?@action=redirect&bpo=39191

   (33) https://bugs.python.org/issue?@action=redirect&bpo=38871

   (34) https://bugs.python.org/issue?@action=redirect&bpo=39142

   (35) https://bugs.python.org/issue?@action=redirect&bpo=39158

   (36) https://bugs.python.org/issue?@action=redirect&bpo=39129

   (37) https://bugs.python.org/issue?@action=redirect&bpo=39057

   (38) https://bugs.python.org/issue?@action=redirect&bpo=39056

   (39) https://bugs.python.org/issue?@action=redirect&bpo=39055

   (40) https://bugs.python.org/issue?@action=redirect&bpo=21600

   (41) https://bugs.python.org/issue?@action=redirect&bpo=39019

   (42) https://bugs.python.org/issue?@action=redirect&bpo=39019

   (43) https://bugs.python.org/issue?@action=redirect&bpo=38914

   (44) https://bugs.python.org/issue?@action=redirect&bpo=38878

   (45) https://bugs.python.org/issue?@action=redirect&bpo=38615

   (46) https://bugs.python.org/issue?@action=redirect&bpo=35182

   (47) https://bugs.python.org/issue?@action=redirect&bpo=38630

   (48) https://bugs.python.org/issue?@action=redirect&bpo=38536

   (49) https://bugs.python.org/issue?@action=redirect&bpo=38473

   (50) https://bugs.python.org/issue?@action=redirect&bpo=38361

   (51) https://bugs.python.org/issue?@action=redirect&bpo=38293

   (52) https://bugs.python.org/issue?@action=redirect&bpo=37958

   (53) https://bugs.python.org/issue?@action=redirect&bpo=28367


File: python.info,  Node: Documentation<38>,  Next: Build<43>,  Prev: Library<43>,  Up: Python 3 9 0 alpha 3

1.23.44.3 Documentation
.......................

   - bpo-39381(1): Mention in docs that *note asyncio.get_event_loop():
     2a2. implicitly creates new event loop only if called from the main
     thread.

   - bpo-38918(2): Add an entry for ‘__module__’ in the "function" &
     "method" sections of the *note inspect: 72. docs' *note
     型とメンバー: 1915. table.

   - bpo-3530(3): In the *note ast: 7. module documentation, fix a
     misleading ‘NodeTransformer’ example and add advice on when to use
     the ‘fix_missing_locations’ function.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39381

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38918

   (3) https://bugs.python.org/issue?@action=redirect&bpo=3530


File: python.info,  Node: Build<43>,  Next: IDLE<30>,  Prev: Documentation<38>,  Up: Python 3 9 0 alpha 3

1.23.44.4 Build
...............

   - bpo-39395(1): On non-Windows platforms, the ‘setenv()’ and
     ‘unsetenv()’ functions are now required to build Python.

   - bpo-39160(2): Updated the documentation in ‘./configure --help’ to
     show default values, reference documentation where required and add
     additional explanation where needed.

   - bpo-39144(3): The ctags and etags build targets both include
     Modules/_ctypes and Python standard library source files.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39395

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39160

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39144


File: python.info,  Node: IDLE<30>,  Next: C API<42>,  Prev: Build<43>,  Up: Python 3 9 0 alpha 3

1.23.44.5 IDLE
..............

   - bpo-39050(1): Make IDLE Settings dialog Help button work again.

   - bpo-34118(2): Tag memoryview, range, and tuple as classes, the same
     as list, etcetera, in the library manual built-in functions list.

   - bpo-32989(3): Add tests for editor newline_and_indent_event method.
     Remove dead code from pyparse find_good_parse_start method.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39050

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34118

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32989


File: python.info,  Node: C API<42>,  Prev: IDLE<30>,  Up: Python 3 9 0 alpha 3

1.23.44.6 C API
...............

   - bpo-39372(1): Clean header files of interfaces defined but with no
     implementation.  The public API symbols being removed are:
     ‘_PyBytes_InsertThousandsGroupingLocale’,
     ‘_PyBytes_InsertThousandsGrouping’, ‘_Py_InitializeFromArgs’,
     ‘_Py_InitializeFromWideArgs’, ‘_PyFloat_Repr’, ‘_PyFloat_Digits’,
     ‘_PyFloat_DigitsInit’, ‘PyFrame_ExtendStack’,
     ‘_PyAIterWrapper_Type’, ‘PyNullImporter_Type’, ‘PyCmpWrapper_Type’,
     ‘PySortWrapper_Type’, ‘PyNoArgsFunction’.

   - bpo-39164(2): Add a private ‘_PyErr_GetExcInfo()’ function to
     retrieve exception information of the specified Python thread
     state.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39372

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39164


File: python.info,  Node: Python 3 9 0 alpha 2,  Next: Python 3 9 0 alpha 1,  Prev: Python 3 9 0 alpha 3,  Up: 変更履歴

1.23.45 Python 3.9.0 alpha 2
----------------------------

'Release date: 2019-12-18'

* Menu:

* Security: Security<29>.
* Core and Builtins: Core and Builtins<45>.
* Library: Library<44>.
* Documentation: Documentation<39>.
* Tests: Tests<41>.
* Build: Build<44>.
* Windows: Windows<39>.
* macOS: macOS<33>.
* IDLE: IDLE<31>.
* C API: C API<43>.


File: python.info,  Node: Security<29>,  Next: Core and Builtins<45>,  Up: Python 3 9 0 alpha 2

1.23.45.1 Security
..................

   - bpo-38945(1): Newline characters have been escaped when performing
     uu encoding to prevent them from overflowing into to content
     section of the encoded file.  This prevents malicious or accidental
     modification of data during the decoding process.

   - bpo-37228(2): Due to significant security concerns, the
     'reuse_address' parameter of *note
     asyncio.loop.create_datagram_endpoint(): 6fe. is no longer
     supported.  This is because of the behavior of ‘SO_REUSEADDR’ in
     UDP. For more details, see the documentation for
     ‘loop.create_datagram_endpoint()’.  (Contributed by Kyle Stanley,
     Antoine Pitrou, and Yury Selivanov in bpo-37228(3).)

   - bpo-38804(4): Fixes a ReDoS vulnerability in *note http.cookiejar:
     66.  Patch by Ben Caller.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38945

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37228

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37228

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38804


File: python.info,  Node: Core and Builtins<45>,  Next: Library<44>,  Prev: Security<29>,  Up: Python 3 9 0 alpha 2

1.23.45.2 Core and Builtins
...........................

   - bpo-39028(1): Slightly improve the speed of keyword argument
     parsing with many kwargs by strengthening the assumption that
     kwargs are interned strings.

   - bpo-39080(2): Fix the value of 'end_col_offset' for Starred
     Expression AST nodes when they are among the elements in the 'args'
     attribute of Call AST nodes.

   - bpo-39031(3): When parsing an "elif" node, lineno and col_offset of
     the node now point to the "elif" keyword and not to its condition,
     making it consistent with the "if" node.  Patch by Lysandros
     Nikolaou.

   - bpo-20443(4): In Python 3.9.0a1, sys.argv[0] was made an absolute
     path if a filename was specified on the command line.  Revert this
     change, since most users expect sys.argv to be unmodified.

   - bpo-39008(5): *note PySys_Audit(): 348. now requires ‘Py_ssize_t’
     to be used for size arguments in the format string, regardless of
     whether ‘PY_SSIZE_T_CLEAN’ was defined at include time.

   - bpo-38673(6): In REPL mode, don't switch to PS2 if the line starts
     with comment or whitespace.  Based on work by Batuhan Taşkaya.

   - bpo-38922(7): Calling ‘replace’ on a code object now raises the
     ‘code.__new__’ audit event.

   - bpo-38920(8): Add audit hooks for when *note sys.excepthook(): 7d6.
     and *note sys.unraisablehook(): 1d8. are invoked.

   - bpo-38892(9): Improve documentation for audit events table and
     functions.

   - bpo-38852(10): Set the thread stack size to 8 Mb for debug builds
     on android platforms.

   - bpo-38858(11): Each Python subinterpreter now has its own "small
     integer singletons": numbers in [-5; 257] range.  It is no longer
     possible to change the number of small integers at build time by
     overriding ‘NSMALLNEGINTS’ and ‘NSMALLPOSINTS’ macros: macros
     should now be modified manually in ‘pycore_pystate.h’ header file.

   - bpo-36854(12): The garbage collector state becomes per interpreter
     (‘PyInterpreterState.gc’), rather than being global
     (‘_PyRuntimeState.gc’).

   - bpo-38835(13): The ‘PyFPE_START_PROTECT()’ and
     ‘PyFPE_END_PROTECT()’ macros are empty: they have been doing
     nothing for the last year, so stop using them.

   - bpo-38328(14): Sped up the creation time of constant *note list:
     5dc. and *note set: 5a3. displays.  Patch by Brandt Bucher.

   - bpo-38707(15): ‘MainThread.native_id’ is now correctly reset in
     child processes spawned using *note multiprocessing.Process: b27,
     instead of retaining the parent's value.

   - bpo-38629(16): Added ‘__floor__’ and ‘__ceil__’ methods to float
     object.  Patch by Batuhan Taşkaya.

   - bpo-27145(17): int + int and int - int operators can now return
     small integer singletons.  Patch by hongweipeng.

   - bpo-38021(18): Provide a platform tag for AIX that is sufficient
     for PEP425 binary distribution identification.  Patch by Michael
     Felt.

   - bpo-35409(19): Ignore GeneratorExit exceptions when throwing an
     exception into the aclose coroutine of an asynchronous generator.

   - bpo-33387(20): Removed WITH_CLEANUP_START, WITH_CLEANUP_FINISH,
     BEGIN_FINALLY, END_FINALLY, CALL_FINALLY and POP_FINALLY bytecodes.
     Replaced with RERAISE and WITH_EXCEPT_START bytecodes.  The
     compiler now generates different code for exceptional and
     non-exceptional branches for 'with' and 'try-except' statements.
     For 'try-finally' statements the 'finally' block is replicated for
     each exit from the 'try' body.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39028

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39080

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39031

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20443

   (5) https://bugs.python.org/issue?@action=redirect&bpo=39008

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38673

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38922

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38920

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38892

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38852

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38858

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36854

   (13) https://bugs.python.org/issue?@action=redirect&bpo=38835

   (14) https://bugs.python.org/issue?@action=redirect&bpo=38328

   (15) https://bugs.python.org/issue?@action=redirect&bpo=38707

   (16) https://bugs.python.org/issue?@action=redirect&bpo=38629

   (17) https://bugs.python.org/issue?@action=redirect&bpo=27145

   (18) https://bugs.python.org/issue?@action=redirect&bpo=38021

   (19) https://bugs.python.org/issue?@action=redirect&bpo=35409

   (20) https://bugs.python.org/issue?@action=redirect&bpo=33387


File: python.info,  Node: Library<44>,  Next: Documentation<39>,  Prev: Core and Builtins<45>,  Up: Python 3 9 0 alpha 2

1.23.45.3 Library
.................

   - bpo-39033(1): Fix *note NameError: 40b. in *note zipimport: 118.
     Patch by Karthikeyan Singaravelan.

   - bpo-39022(2): Update importlib.metadata to include improvements
     from importlib_metadata 1.3 including better serialization of
     EntryPoints and improved documentation for custom finders.

   - bpo-39006(3): Fix asyncio when the ssl module is missing: only
     check for ssl.SSLSocket instance if the ssl module is available.

   - bpo-38708(4): Fix a potential IndexError in email parser when
     parsing an empty msg-id.

   - bpo-38698(5): Add a new ‘InvalidMessageID’ token to email parser to
     represent invalid Message-ID headers.  Also, add defects when there
     is remaining value after parsing the header.

   - bpo-38994(6): Implement ‘__class_getitem__’ for ‘os.PathLike’,
     ‘pathlib.Path’.

   - bpo-38979(7): Return class from ‘ContextVar.__class_getitem__’ to
     simplify subclassing.

   - bpo-38978(8): Implement ‘__class_getitem__’ on asyncio objects
     (Future, Task, Queue).  Patch by Batuhan Taskaya.

   - bpo-38916(9): *note array.array: 185.: Remove ‘tostring()’ and
     ‘fromstring()’ methods.  They were aliases to ‘tobytes()’ and
     ‘frombytes()’, deprecated since Python 3.2.

   - bpo-38986(10): Make repr of C accelerated TaskWakeupMethWrapper the
     same as of pure Python version.

   - bpo-38982(11): Fix asyncio ‘PidfdChildWatcher’: handle ‘waitpid()’
     error.  If ‘waitpid()’ is called elsewhere, ‘waitpid()’ call fails
     with *note ChildProcessError: 102c.: use return code 255 in this
     case, and log a warning.  It ensures that the pidfd file descriptor
     is closed if this error occurs.

   - bpo-38529(12): Drop too noisy asyncio warning about deletion of a
     stream without explicit ‘.close()’ call.

   - bpo-27413(13): Added ability to pass through ‘ensure_ascii’ options
     to json.dumps in the ‘json.tool’ command-line interface.

   - bpo-38634(14): The *note readline: a8. module now detects if Python
     is linked to libedit at runtime on all platforms.  Previously, the
     check was only done on macOS.

   - bpo-33684(15): Fix ‘json.tool’ failed to read a JSON file with
     non-ASCII characters when locale encoding is not UTF-8.

   - bpo-38698(16): Prevent UnboundLocalError to pop up in
     parse_message_id.

     parse_message_id() was improperly using a token defined inside an
     exception handler, which was raising ‘UnboundLocalError’ on parsing
     an invalid value.  Patch by Claudiu Popa.

   - bpo-38927(17): Use ‘python -m pip’ instead of ‘pip’ to upgrade
     dependencies in venv.

   - bpo-26730(18): Fix ‘SpooledTemporaryFile.rollover()’ might corrupt
     the file when it is in text mode.  Patch by Serhiy Storchaka.

   - bpo-38881(19): random.choices() now raises a ValueError when all
     the weights are zero.

   - bpo-38876(20): Raise pickle.UnpicklingError when loading an item
     from memo for invalid input.

     The previous code was raising a ‘KeyError’ for both the Python and
     C implementation.  This was caused by the specified index of an
     invalid input which did not exist in the memo structure, where the
     pickle stores what objects it has seen.  The malformed input would
     have caused either a ‘BINGET’ or ‘LONG_BINGET’ load from the memo,
     leading to a ‘KeyError’ as the determined index was bogus.  Patch
     by Claudiu Popa.

   - bpo-38688(21): Calling func:‘shutil.copytree’ to copy a directory
     tree from one directory to another subdirectory resulted in an
     endless loop and a RecursionError.  A fix was added to consume an
     iterator and create the list of the entries to be copied, avoiding
     the recursion for newly created directories.  Patch by Bruno P.
     Kinoshita.

   - bpo-38863(22): Improve ‘is_cgi()’ function in *note http.server:
     68, which enables processing the case that cgi directory is a child
     of another directory other than root.

   - bpo-37838(23): *note typing.get_type_hints(): 67d. properly handles
     functions decorated with *note functools.wraps(): f2a.

   - bpo-38870(24): Expose *note ast.unparse(): 8b3. as a function of
     the *note ast: 7. module that can be used to unparse an *note
     ast.AST: 18b. object and produce a string with code that would
     produce an equivalent *note ast.AST: 18b. object when parsed.
     Patch by Pablo Galindo and Batuhan Taskaya.

   - bpo-38859(25): AsyncMock now returns StopAsyncIteration on the
     exhaustion of a side_effects iterable.  Since PEP-479 its
     Impossible to raise a StopIteration exception from a coroutine.

   - bpo-38857(26): AsyncMock fix for return values that are awaitable
     types.  This also covers side_effect iterable values that happened
     to be awaitable, and wraps callables that return an awaitable type.
     Before these awaitables were being awaited instead of being
     returned as is.

   - bpo-38834(27): *note typing.TypedDict: 148. subclasses now track
     which keys are optional using the ‘__required_keys__’ and
     ‘__optional_keys__’ attributes, to enable runtime validation by
     downstream projects.  Patch by Zac Hatfield-Dodds.

   - bpo-38821(28): Fix unhandled exceptions in *note argparse: 5. when
     internationalizing error messages for arguments with ‘nargs’ set to
     special (non-integer) values.  Patch by Federico Bond.

   - bpo-38820(29): Make Python compatible with OpenSSL 3.0.0.  *note
     ssl.SSLSocket.getpeercert(): f84. no longer returns IPv6 addresses
     with a trailing new line.

   - bpo-38811(30): Fix an unhandled exception in *note pathlib: 93.
     when *note os.link(): 10c0. is missing.  Patch by Toke
     Høiland-Jørgensen.

   - bpo-38686(31): Added support for multiple ‘qop’ values in *note
     urllib.request.AbstractDigestAuthHandler: 18ed.

   - bpo-38712(32): Add the Linux-specific *note
     signal.pidfd_send_signal(): 8f9. function, which allows sending a
     signal to a process identified by a file descriptor rather than a
     pid.

   - bpo-38348(33): Add ‘-i’ and ‘--indent’ (indentation level), and
     ‘--no-type-comments’ (type comments) command line options to ast
     parsing tool.

   - bpo-37523(34): Change ‘zipfile.ZipExtFile’ to raise ‘ValueError’
     when trying to access the underlying file object after it has been
     closed.  This new behavior is consistent with how accessing closed
     files is handled in other parts of Python.

   - bpo-38045(35): Improve the performance of ‘enum._decompose()’ in
     *note enum: 4c.  Patch by hongweipeng.

   - bpo-36820(36): Break cycle generated when saving an exception in
     socket.py, codeop.py and dyld.py as they keep alive not only the
     exception but user objects through the ‘__traceback__’ attribute.
     Patch by Mario Corchero.

   - bpo-36406(37): Handle namespace packages in *note doctest: 31.
     Patch by Karthikeyan Singaravelan.

   - bpo-34776(38): Fix dataclasses to support forward references in
     type annotations

   - bpo-20928(39): ElementTree supports recursive XInclude processing.
     Patch by Stefan Behnel.

   - bpo-29636(40): Add whitespace options for formatting JSON with the
     ‘json.tool’ CLI. The following mutually exclusive options are now
     supported: ‘--indent’ for setting the indent level in spaces;
     ‘--tab’ for indenting with tabs; ‘--no-indent’ for suppressing
     newlines; and ‘--compact’ for suppressing all whitespace.  The
     default behavior remains the same as ‘--indent=4’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39033

   (2) https://bugs.python.org/issue?@action=redirect&bpo=39022

   (3) https://bugs.python.org/issue?@action=redirect&bpo=39006

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38708

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38698

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38994

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38979

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38978

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38916

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38986

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38982

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38529

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27413

   (14) https://bugs.python.org/issue?@action=redirect&bpo=38634

   (15) https://bugs.python.org/issue?@action=redirect&bpo=33684

   (16) https://bugs.python.org/issue?@action=redirect&bpo=38698

   (17) https://bugs.python.org/issue?@action=redirect&bpo=38927

   (18) https://bugs.python.org/issue?@action=redirect&bpo=26730

   (19) https://bugs.python.org/issue?@action=redirect&bpo=38881

   (20) https://bugs.python.org/issue?@action=redirect&bpo=38876

   (21) https://bugs.python.org/issue?@action=redirect&bpo=38688

   (22) https://bugs.python.org/issue?@action=redirect&bpo=38863

   (23) https://bugs.python.org/issue?@action=redirect&bpo=37838

   (24) https://bugs.python.org/issue?@action=redirect&bpo=38870

   (25) https://bugs.python.org/issue?@action=redirect&bpo=38859

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38857

   (27) https://bugs.python.org/issue?@action=redirect&bpo=38834

   (28) https://bugs.python.org/issue?@action=redirect&bpo=38821

   (29) https://bugs.python.org/issue?@action=redirect&bpo=38820

   (30) https://bugs.python.org/issue?@action=redirect&bpo=38811

   (31) https://bugs.python.org/issue?@action=redirect&bpo=38686

   (32) https://bugs.python.org/issue?@action=redirect&bpo=38712

   (33) https://bugs.python.org/issue?@action=redirect&bpo=38348

   (34) https://bugs.python.org/issue?@action=redirect&bpo=37523

   (35) https://bugs.python.org/issue?@action=redirect&bpo=38045

   (36) https://bugs.python.org/issue?@action=redirect&bpo=36820

   (37) https://bugs.python.org/issue?@action=redirect&bpo=36406

   (38) https://bugs.python.org/issue?@action=redirect&bpo=34776

   (39) https://bugs.python.org/issue?@action=redirect&bpo=20928

   (40) https://bugs.python.org/issue?@action=redirect&bpo=29636


File: python.info,  Node: Documentation<39>,  Next: Tests<41>,  Prev: Library<44>,  Up: Python 3 9 0 alpha 2

1.23.45.4 Documentation
.......................

   - bpo-38928(1): Correct when venv's ‘upgrade_dependencies()’ and
     ‘--upgrade-deps’ are added.

   - bpo-38899(2): Update documentation to state that to activate
     virtual environments under fish one should use ‘source’, not ‘.’ as
     documented at
     ‘https://fishshell.com/docs/current/cmds/source.html’.

   - bpo-22377(3): Improves documentation of the values that *note
     datetime.datetime.strptime(): 156e. accepts for ‘%Z’.  Patch by
     Karl Dubost.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38928

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38899

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22377


File: python.info,  Node: Tests<41>,  Next: Build<44>,  Prev: Documentation<39>,  Up: Python 3 9 0 alpha 2

1.23.45.5 Tests
...............

   - bpo-38546(1): Fix test_ressources_gced_in_workers() of
     test_concurrent_futures: explicitly stop the manager to prevent
     leaking a child process running in the background after the test
     completes.

   - bpo-38546(2): Multiprocessing and concurrent.futures tests now stop
     the resource tracker process when tests complete.

   - bpo-38614(3): Replace hardcoded timeout constants in tests with new
     *note test.support: cd. constants: *note LOOPBACK_TIMEOUT: 191f,
     *note INTERNET_TIMEOUT: 1920, *note SHORT_TIMEOUT: 1819. and *note
     LONG_TIMEOUT: 1921.  It becomes easier to adjust these four timeout
     constants for all tests at once, rather than having to adjust every
     single test file.

   - bpo-38547(4): Fix test_pty: if the process is the session leader,
     closing the master file descriptor raises a SIGHUP signal: simply
     ignore SIGHUP when running the tests.

   - bpo-38992(5): Fix a test for *note math.fsum(): 137c. that was
     failing due to constant folding.

   - bpo-38991(6): *note test.support: cd.: ‘run_python_until_end()’,
     ‘assert_python_ok()’ and ‘assert_python_failure()’ functions no
     longer strip whitespaces from stderr.  Remove
     ‘test.support.strip_python_stderr()’ function.

   - bpo-38965(7): Fix test_faulthandler on GCC 10.  Use the "volatile"
     keyword in ‘faulthandler._stack_overflow()’ to prevent tail call
     optimization on any compiler, rather than relying on compiler
     specific pragma.

   - bpo-38875(8): test_capi: trashcan tests now require the test "cpu"
     resource.

   - bpo-38841(9): Skip asyncio
     test_create_datagram_endpoint_existing_sock_unix on platforms
     lacking a functional bind() for named unix domain sockets.

   - bpo-38692(10): Skip the test_posix.test_pidfd_open() test if
     ‘os.pidfd_open()’ fails with a *note PermissionError: d10.  This
     situation can happen in a Linux sandbox using a syscall whitelist
     which doesn't allow the ‘pidfd_open()’ syscall yet.

   - bpo-38839(11): Fix some unused functions in tests.  Patch by Adam
     Johnson.

   - bpo-38669(12): Raise *note TypeError: 502. when passing target as a
     string with *note unittest.mock.patch.object(): 14ff.

   - bpo-37957(13): test.regrtest now can receive a list of test
     patterns to ignore (using the -i/-ignore argument) or a file with a
     list of patterns to ignore (using the -ignore-file argument).
     Patch by Pablo Galindo.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38546

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38546

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38614

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38547

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38992

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38991

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38965

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38875

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38841

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38692

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38839

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38669

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37957


File: python.info,  Node: Build<44>,  Next: Windows<39>,  Prev: Tests<41>,  Up: Python 3 9 0 alpha 2

1.23.45.6 Build
...............

   - bpo-37404(1): *note asyncio: 8. now raises *note TypeError: 502.
     when calling incompatible methods with an *note ssl.SSLSocket: 8b8.
     socket.  Patch by Ido Michael.

   - bpo-36500(2): Added an optional "regen" project to the Visual
     Studio solution that will regenerate all grammar, tokens, and
     opcodes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37404

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36500


File: python.info,  Node: Windows<39>,  Next: macOS<33>,  Prev: Build<44>,  Up: Python 3 9 0 alpha 2

1.23.45.7 Windows
.................

   - bpo-39007(1): Add auditing events to functions in *note winreg: fe.

   - bpo-33125(2): Add support for building and releasing Windows ARM64
     packages.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=39007

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33125


File: python.info,  Node: macOS<33>,  Next: IDLE<31>,  Prev: Windows<39>,  Up: Python 3 9 0 alpha 2

1.23.45.8 macOS
...............

   - bpo-37931(1): Fixed a crash on OSX dynamic builds that occurred
     when re-initializing the posix module after a Py_Finalize if the
     environment had changed since the previous ‘import posix’.  Patch
     by Benoît Hudson.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37931


File: python.info,  Node: IDLE<31>,  Next: C API<43>,  Prev: macOS<33>,  Up: Python 3 9 0 alpha 2

1.23.45.9 IDLE
..............

   - bpo-38944(1): Escape key now closes IDLE completion windows.  Patch
     by Johnny Najera.

   - bpo-38943(2): Fix IDLE autocomplete windows not always appearing on
     some systems.  Patch by Johnny Najera.

   - bpo-38862(3): 'Strip Trailing Whitespace' on the Format menu
     removes extra newlines at the end of non-shell files.

   - bpo-38636(4): Fix IDLE Format menu tab toggle and file indent
     width.  These functions (default shortcuts Alt-T and Alt-U) were
     mistakenly disabled in 3.7.5 and 3.8.0.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38944

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38943

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38862

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38636


File: python.info,  Node: C API<43>,  Prev: IDLE<31>,  Up: Python 3 9 0 alpha 2

1.23.45.10 C API
................

   - bpo-38896(1): Remove ‘PyUnicode_ClearFreeList()’ function: the
     Unicode free list has been removed in Python 3.3.

   - bpo-37340(2): Remove ‘PyMethod_ClearFreeList()’ and
     ‘PyCFunction_ClearFreeList()’ functions: the free lists of bound
     method objects have been removed.

   - bpo-38835(3): Exclude ‘PyFPE_START_PROTECT()’ and
     ‘PyFPE_END_PROTECT()’ macros of ‘pyfpe.h’ from ‘Py_LIMITED_API’
     (stable API).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38896

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37340

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38835


File: python.info,  Node: Python 3 9 0 alpha 1,  Next: Python 3 8 0 beta 1,  Prev: Python 3 9 0 alpha 2,  Up: 変更履歴

1.23.46 Python 3.9.0 alpha 1
----------------------------

'Release date: 2019-11-19'

* Menu:

* Security: Security<30>.
* Core and Builtins: Core and Builtins<46>.
* Library: Library<45>.
* Documentation: Documentation<40>.
* Tests: Tests<42>.
* Build: Build<45>.
* Windows: Windows<40>.
* macOS: macOS<34>.
* IDLE: IDLE<32>.
* Tools/Demos: Tools/Demos<20>.
* C API: C API<44>.


File: python.info,  Node: Security<30>,  Next: Core and Builtins<46>,  Up: Python 3 9 0 alpha 1

1.23.46.1 Security
..................

   - bpo-38722(1): *note runpy: ac. now uses *note io.open_code(): 168e.
     to open code files.  Patch by Jason Killen.

   - bpo-38622(2): Add additional audit events for the *note ctypes: 22.
     module.

   - bpo-38418(3): Fixes audit event for *note os.system(): 1402. to be
     named ‘os.system’.

   - bpo-38243(4): Escape the server title of *note
     xmlrpc.server.DocXMLRPCServer: 1929. when rendering the document
     page as HTML. (Contributed by Donghee Na in bpo-38243(5).)

   - bpo-38174(6): Update vendorized expat library version to 2.2.8,
     which resolves CVE 2019-15903(7).

   - bpo-37764(8): Fixes email._header_value_parser.get_unstructured
     going into an infinite loop for a specific case in which the email
     header does not have trailing whitespace, and the case in which it
     contains an invalid encoded word.  Patch by Ashwin Ramaswami.

   - bpo-37461(9): Fix an infinite loop when parsing specially crafted
     email headers.  Patch by Abhilash Raj.

   - bpo-37363(10): Adds audit events for the range of supported run
     commands (see *note コマンドラインと環境: 192a.).

   - bpo-37463(11): ssl.match_hostname() no longer accepts IPv4
     addresses with additional text after the address and only
     quad-dotted notation without trailing whitespaces.  Some
     inet_aton() implementations ignore whitespace and all data after
     whitespace, e.g.  '127.0.0.1 whatever'.

   - bpo-37363(12): Adds audit events for *note ensurepip: 4b, *note
     ftplib: 54, *note glob: 5a, *note imaplib: 6a, ‘nntplib’, *note
     pdb: 94, *note poplib: 9a, *note shutil: b3, *note smtplib: b7,
     *note sqlite3: ba, *note subprocess: c1, ‘telnetlib’, *note
     tempfile: c9. and *note webbrowser: fd, as well as *note
     os.listdir(): 10cd, *note os.scandir(): a2d. and *note
     breakpoint(): 215.

   - bpo-37364(13): *note io.open_code(): 168e. is now used when reading
     ‘.pth’ files.

   - bpo-34631(14): Updated OpenSSL to 1.1.1c in Windows installer

   - bpo-34155(15): Fix parsing of invalid email addresses with more
     than one ‘@’ (e.g.  a@b@c.com.)  to not return the part before 2nd
     ‘@’ as valid email address.  Patch by maxking & jpic.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38722

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38622

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38418

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38243

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38243

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38174

   (7) https://www.cve.org/CVERecord?id=CVE-2019-15903

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37764

   (9) https://bugs.python.org/issue?@action=redirect&bpo=37461

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37363

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37463

   (12) https://bugs.python.org/issue?@action=redirect&bpo=37363

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37364

   (14) https://bugs.python.org/issue?@action=redirect&bpo=34631

   (15) https://bugs.python.org/issue?@action=redirect&bpo=34155


File: python.info,  Node: Core and Builtins<46>,  Next: Library<45>,  Prev: Security<30>,  Up: Python 3 9 0 alpha 1

1.23.46.2 Core and Builtins
...........................

   - bpo-38631(1): Replace ‘Py_FatalError()’ call with a regular *note
     RuntimeError: 17a. exception in ‘float.__getformat__()’.

   - bpo-38639(2): Optimized *note math.floor(): 1369, *note
     math.ceil(): 136a. and *note math.trunc(): 136b. for floats.

   - bpo-38640(3): Fixed a bug in the compiler that was causing to raise
     in the presence of break statements and continue statements inside
     always false while loops.  Patch by Pablo Galindo.

   - bpo-38613(4): Optimized some set operations (e.g.  ‘|’, ‘^’, and
     ‘-’) of ‘dict_keys’.  ‘d.keys() | other’ was slower than ‘set(d) |
     other’ but they are almost same performance for now.

   - bpo-28029(5): ‘"".replace("", s, n)’ now returns ‘s’ instead of an
     empty string for all non-zero ‘n’.  There are similar changes for
     *note bytes: 1a4. and *note bytearray: 508. objects.

   - bpo-38535(6): Fixed line numbers and column offsets for AST nodes
     for calls without arguments in decorators.

   - bpo-38525(7): Fix a segmentation fault when using reverse iterators
     of empty ‘dict’ objects.  Patch by Donghee Na and Inada Naoki.

   - bpo-38465(8): *note bytearray: 508, *note array: 185. and *note
     mmap: 1ec. objects allow now to export more than ‘2**31’ buffers at
     a time.

   - bpo-38469(9): Fixed a bug where the scope of named expressions was
     not being resolved correctly in the presence of the 'global'
     keyword.  Patch by Pablo Galindo.

   - bpo-38437(10): Activate the ‘GC_DEBUG’ macro for debug builds of
     the interpreter (when ‘Py_DEBUG’ is set).  Patch by Pablo Galindo.

   - bpo-38379(11): When the garbage collector makes a collection in
     which some objects resurrect (they are reachable from outside the
     isolated cycles after the finalizers have been executed), do not
     block the collection of all objects that are still unreachable.
     Patch by Pablo Galindo and Tim Peters.

   - bpo-38379(12): When cyclic garbage collection (gc) runs finalizers
     that resurrect unreachable objects, the current gc run ends,
     without collecting any cyclic trash.  However, the statistics
     reported by ‘collect()’ and ‘get_stats()’ claimed that all cyclic
     trash found was collected, and that the resurrected objects were
     collected.  Changed the stats to report that none were collected.

   - bpo-38392(13): In debug mode, *note PyObject_GC_Track(): 14af. now
     calls ‘tp_traverse()’ of the object type to ensure that the object
     is valid: test that objects visited by ‘tp_traverse()’ are valid.

   - bpo-38210(14): Remove unnecessary intersection and update set
     operation in dictview with empty set.  (Contributed by Donghee Na
     in bpo-38210(15).)

   - bpo-38402(16): Check the error from the system's underlying ‘crypt’
     or ‘crypt_r’.

   - bpo-37474(17): On FreeBSD, Python no longer calls
     ‘fedisableexcept()’ at startup to control the floating-point
     control mode.  The call became useless since FreeBSD 6: it became
     the default mode.

   - bpo-38006(18): Fix a bug due to the interaction of weakrefs and the
     cyclic garbage collector.  We must clear any weakrefs in garbage in
     order to prevent their callbacks from executing and causing a
     crash.

   - bpo-38317(19): Fix warnings options priority:
     ‘PyConfig.warnoptions’ has the highest priority, as stated in the
     PEP 587(20).

   - bpo-38310(21): Predict ‘BUILD_MAP_UNPACK_WITH_CALL’ ->
     ‘CALL_FUNCTION_EX’ opcode pairs in the main interpreter loop.
     Patch by Brandt Bucher.

   - bpo-36871(22): Improve error handling for the assert_has_calls and
     assert_has_awaits methods of mocks.  Fixed a bug where any errors
     encountered while binding the expected calls to the mock's spec
     were silently swallowed, leading to misleading error output.

   - bpo-11410(23): Better control over symbol visibility is provided
     through use of the visibility attributes available in gcc >= 4.0,
     provided in a uniform way across POSIX and Windows.  The POSIX
     build files have been updated to compile with -fvisibility=hidden,
     minimising exported symbols.

   - bpo-38219(24): Optimized the *note dict: 237. constructor and the
     *note update(): 140a. method for the case when the argument is a
     dict.

   - bpo-38236(25): Python now dumps path configuration if it fails to
     import the Python codecs of the filesystem and stdio encodings.

   - bpo-38013(26): Allow to call ‘async_generator_athrow().throw(...)’
     even for non-started async generator helper.  It fixes annoying
     warning at the end of *note asyncio.run(): 449. call.

   - bpo-38124(27): Fix an off-by-one error in PyState_AddModule that
     could cause out-of-bounds memory access.

   - bpo-38116(28): The select module is now PEP-384 compliant and no
     longer has static state

   - bpo-38113(29): ast module updated to PEP-384 and all statics
     removed

   - bpo-38076(30): The struct module is now PEP-384 compatible

   - bpo-38075(31): The random module is now PEP-384 compatible

   - bpo-38074(32): zlib module made PEP-384 compatible

   - bpo-38073(33): Make pwd extension module PEP-384 compatible

   - bpo-38072(34): grp module made PEP-384 compatible

   - bpo-38069(35): Make _posixsubprocess PEP-384 compatible

   - bpo-38071(36): Make termios extension module PEP-384 compatible

   - bpo-38005(37): Fixed comparing and creating of InterpreterID and
     ChannelID.

   - bpo-36946(38): Fix possible signed integer overflow when handling
     slices.  Patch by hongweipeng.

   - bpo-37994(39): Fixed silencing arbitrary errors if an attribute
     lookup fails in several sites.  Only AttributeError should be
     silenced.

   - bpo-8425(40): Optimize set difference_update for the case when the
     other set is much larger than the base set.  (Suggested by Evgeny
     Kapun with code contributed by Michele Orrù).

   - bpo-37966(41): The implementation of *note is_normalized(): a17.
     has been greatly sped up on strings that aren't normalized, by
     implementing the full normalization-quick-check algorithm from the
     Unicode standard.

   - bpo-37947(42): Adjust correctly the recursion level in the symtable
     generation for named expressions.  Patch by Pablo Galindo.

   - bpo-37812(43): The ‘CHECK_SMALL_INT’ macro used inside
     ‘Object/longobject.c’ has been replaced with an explicit ‘return’
     at each call site.

   - bpo-37751(44): Fix *note codecs.lookup(): 931. to normalize the
     encoding name the same way than ‘encodings.normalize_encoding()’,
     except that *note codecs.lookup(): 931. also converts the name to
     lower case.

   - bpo-37830(45): Fixed compilation of *note break: a77. and *note
     continue: 998. in the *note finally: 997. block when the
     corresponding *note try: 6b4. block contains *note return: 99c.
     with a non-constant value.

   - bpo-20490(46): Improve import error message for partially
     initialized module on circular ‘from’ imports - by Anthony Sottile.

   - bpo-37840(47): Fix handling of negative indices in *note sq_item:
     1897. of *note bytearray: 508.  Patch by Sergey Fedoseev.

   - bpo-37802(48): Slightly improve performance of *note
     PyLong_FromUnsignedLong(): 192c, *note
     PyLong_FromUnsignedLongLong(): 192d. and *note PyLong_FromSize_t():
     192e.  Patch by Sergey Fedoseev.

   - bpo-37409(49): Ensure explicit relative imports from interactive
     sessions and scripts (having no parent package) always raise
     ImportError, rather than treating the current module as the
     package.  Patch by Ben Lewis.

   - bpo-32912(50): Reverted bpo-32912(51): emitting *note
     SyntaxWarning: 432. instead of *note DeprecationWarning: 18a. for
     invalid escape sequences in string and bytes literals.

   - bpo-37757(52): PEP 572(53): As described in the PEP, assignment
     expressions now raise *note SyntaxError: 172. when their
     interaction with comprehension scoping results in an ambiguous
     target scope.

     The ‘TargetScopeError’ subclass originally proposed by the PEP has
     been removed in favour of just raising regular syntax errors for
     the disallowed cases.

   - bpo-36279(54): Fix potential use of uninitialized memory in *note
     os.wait3(): d63.

   - bpo-36311(55): Decoding bytes objects larger than 2GiB is faster
     and no longer fails when a multibyte characters spans a chunk
     boundary.

   - bpo-34880(56): The *note assert: 936. statement now works properly
     if the *note AssertionError: 675. exception is being shadowed.
     Patch by Zackery Spytz.

   - bpo-37340(57): Removed object cache (‘free_list’) for bound method
     objects.  Temporary bound method objects are less used than before
     thanks to the ‘LOAD_METHOD’ opcode and the
     ‘_PyObject_VectorcallMethod’ C API.

   - bpo-37648(58): Fixed minor inconsistency in ‘list.__contains__()’,
     ‘tuple.__contains__()’ and a few other places.  The collection's
     item is now always at the left and the needle is on the right of
     ‘==’.

   - bpo-37444(59): Update differing exception between
     ‘builtins.__import__()’ and *note importlib.__import__(): 1042.

   - bpo-37619(60): When adding a wrapper descriptor from one class to a
     different class (for example, setting ‘__add__ = str.__add__’ on an
     ‘int’ subclass), an exception is correctly raised when the operator
     is called.

   - bpo-37593(61): Swap the positions of the 'posonlyargs' and 'args'
     parameters in the constructor of ‘ast.parameters’ nodes.

   - bpo-37543(62): Optimized pymalloc for non PGO build.

   - bpo-37537(63): Compute allocated pymalloc blocks inside
     _Py_GetAllocatedBlocks().  This slows down _Py_GetAllocatedBlocks()
     but gives a small speedup to _PyObject_Malloc() and
     _PyObject_Free().

   - bpo-37467(64): Fix *note sys.excepthook(): 7d6. and
     ‘PyErr_Display()’ if a filename is a bytes string.  For example,
     for a SyntaxError exception where the filename attribute is a bytes
     string.

   - bpo-37433(65): Fix ‘SyntaxError’ indicator printing too many spaces
     for multi-line strings - by Anthony Sottile.

   - bpo-37417(66): ‘bytearray.extend()’ now correctly handles errors
     that arise during iteration.  Patch by Brandt Bucher.

   - bpo-37414(67): The undocumented ‘sys.callstats()’ function has been
     removed.  Since Python 3.7, it was deprecated and always returned
     ‘None’.  It required a special build option ‘CALL_PROFILE’ which
     was already removed in Python 3.7.

   - bpo-37392(68): Remove ‘sys.getcheckinterval()’ and
     ‘sys.setcheckinterval()’ functions.  They were deprecated since
     Python 3.2.  Use *note sys.getswitchinterval(): 917. and *note
     sys.setswitchinterval(): 918. instead.  Remove also
     ‘check_interval’ field of the ‘PyInterpreterState’ structure.

   - bpo-37388(69): In development mode and in debug build, 'encoding'
     and 'errors' arguments are now checked on string encoding and
     decoding operations.  Examples: *note open(): 4e5, *note
     str.encode(): 8a3. and *note bytes.decode(): 8a4.

     By default, for best performances, the 'errors' argument is only
     checked at the first encoding/decoding error, and the 'encoding'
     argument is sometimes ignored for empty strings.

   - bpo-37348(70): Optimized decoding short ASCII string with UTF-8 and
     ascii codecs.  ‘b"foo".decode()’ is about 15% faster.  Patch by
     Inada Naoki.

   - bpo-24214(71): Improved support of the surrogatepass error handler
     in the UTF-8 and UTF-16 incremental decoders.

   - bpo-37330(72): *note open(): 4e5, *note io.open(): 4e6, *note
     codecs.open(): 70b. and *note fileinput.FileInput: 702. no longer
     accept ‘'U'’ ("universal newline") in the file mode.  This flag was
     deprecated since Python 3.3.

   - bpo-35224(73): Reverse evaluation order of key: value in dict
     comprehensions as proposed in PEP 572.  I.e.  in ‘{k: v for ...}’,
     ‘k’ will be evaluated before ‘v’.

   - bpo-37316(74): Fix the *note PySys_Audit(): 348. call in *note
     mmap.mmap: 1ec.

   - bpo-37300(75): Remove an unnecessary Py_XINCREF in classobject.c.

   - bpo-37269(76): Fix a bug in the peephole optimizer that was not
     treating correctly constant conditions with binary operators.
     Patch by Pablo Galindo.

   - bpo-20443(77): Python now gets the absolute path of the script
     filename specified on the command line (ex: "python3 script.py"):
     the __file__ attribute of the __main__ module and sys.path[0]
     become an absolute path, rather than a relative path.

   - bpo-37257(78): Python's small object allocator (‘obmalloc.c’) now
     allows (no more than) one empty arena to remain available for
     immediate reuse, without returning it to the OS. This prevents
     thrashing in simple loops where an arena could be created and
     destroyed anew on each iteration.

   - bpo-37231(79): The dispatching of type slots to special methods
     (for example calling ‘__mul__’ when doing ‘x * y’) has been made
     faster.

   - bpo-36974(80): Implemented separate vectorcall functions for every
     calling convention of builtin functions and methods.  This improves
     performance for calls.

   - bpo-37213(81): Handle correctly negative line offsets in the
     peephole optimizer.  Patch by Pablo Galindo.

   - bpo-37219(82): Remove erroneous optimization for empty set
     differences.

   - bpo-15913(83): Implement *note PyBuffer_SizeFromFormat(): 725.
     function (previously documented but not implemented): call *note
     struct.calcsize(): 192f.  Patch by Joannah Nanjekye.

   - bpo-36922(84): Slot functions optimize any callable with
     ‘Py_TPFLAGS_METHOD_DESCRIPTOR’ instead of only instances of
     ‘function’.

   - bpo-36974(85): The slot ‘tp_vectorcall_offset’ is inherited
     unconditionally to support ‘super().__call__()’ when the base class
     uses vectorcall.

   - bpo-37160(86): *note threading.get_native_id(): a0c. now also
     supports NetBSD.

   - bpo-37077(87): Add *note threading.get_native_id(): a0c. support
     for AIX. Patch by M. Felt

   - bpo-36781(88): *note sum(): 437. has been optimized for boolean
     values.

   - bpo-34556(89): Add ‘--upgrade-deps’ to venv module.  Patch by
     Cooper Ry Lees

   - bpo-20523(90): ‘pdb.Pdb’ supports ~/.pdbrc in Windows 7.  Patch by
     Tim Hopper and Dan Lidral-Porter.

   - bpo-35551(91): Updated encodings: - Removed the "tis260" encoding,
     which was an alias for the nonexistent "tactis" codec.  - Added
     "mac_centeuro" as an alias for the mac_latin2 encoding.

   - bpo-19072(92): The *note classmethod: 14c. decorator can now wrap
     other descriptors such as property objects.  Adapted from a patch
     written by Graham Dumpleton.

   - bpo-27575(93): Improve speed of dictview intersection by directly
     using set intersection logic.  Patch by David Su.

   - bpo-30773(94): Prohibit parallel running of aclose() / asend() /
     athrow().  Fix ag_running to reflect the actual running status of
     the AG.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38631

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38639

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38640

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38613

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28029

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38535

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38525

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38465

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38469

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38437

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38379

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38379

   (13) https://bugs.python.org/issue?@action=redirect&bpo=38392

   (14) https://bugs.python.org/issue?@action=redirect&bpo=38210

   (15) https://bugs.python.org/issue?@action=redirect&bpo=38210

   (16) https://bugs.python.org/issue?@action=redirect&bpo=38402

   (17) https://bugs.python.org/issue?@action=redirect&bpo=37474

   (18) https://bugs.python.org/issue?@action=redirect&bpo=38006

   (19) https://bugs.python.org/issue?@action=redirect&bpo=38317

   (20) https://peps.python.org/pep-0587/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=38310

   (22) https://bugs.python.org/issue?@action=redirect&bpo=36871

   (23) https://bugs.python.org/issue?@action=redirect&bpo=11410

   (24) https://bugs.python.org/issue?@action=redirect&bpo=38219

   (25) https://bugs.python.org/issue?@action=redirect&bpo=38236

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38013

   (27) https://bugs.python.org/issue?@action=redirect&bpo=38124

   (28) https://bugs.python.org/issue?@action=redirect&bpo=38116

   (29) https://bugs.python.org/issue?@action=redirect&bpo=38113

   (30) https://bugs.python.org/issue?@action=redirect&bpo=38076

   (31) https://bugs.python.org/issue?@action=redirect&bpo=38075

   (32) https://bugs.python.org/issue?@action=redirect&bpo=38074

   (33) https://bugs.python.org/issue?@action=redirect&bpo=38073

   (34) https://bugs.python.org/issue?@action=redirect&bpo=38072

   (35) https://bugs.python.org/issue?@action=redirect&bpo=38069

   (36) https://bugs.python.org/issue?@action=redirect&bpo=38071

   (37) https://bugs.python.org/issue?@action=redirect&bpo=38005

   (38) https://bugs.python.org/issue?@action=redirect&bpo=36946

   (39) https://bugs.python.org/issue?@action=redirect&bpo=37994

   (40) https://bugs.python.org/issue?@action=redirect&bpo=8425

   (41) https://bugs.python.org/issue?@action=redirect&bpo=37966

   (42) https://bugs.python.org/issue?@action=redirect&bpo=37947

   (43) https://bugs.python.org/issue?@action=redirect&bpo=37812

   (44) https://bugs.python.org/issue?@action=redirect&bpo=37751

   (45) https://bugs.python.org/issue?@action=redirect&bpo=37830

   (46) https://bugs.python.org/issue?@action=redirect&bpo=20490

   (47) https://bugs.python.org/issue?@action=redirect&bpo=37840

   (48) https://bugs.python.org/issue?@action=redirect&bpo=37802

   (49) https://bugs.python.org/issue?@action=redirect&bpo=37409

   (50) https://bugs.python.org/issue?@action=redirect&bpo=32912

   (51) https://bugs.python.org/issue?@action=redirect&bpo=32912

   (52) https://bugs.python.org/issue?@action=redirect&bpo=37757

   (53) https://peps.python.org/pep-0572/

   (54) https://bugs.python.org/issue?@action=redirect&bpo=36279

   (55) https://bugs.python.org/issue?@action=redirect&bpo=36311

   (56) https://bugs.python.org/issue?@action=redirect&bpo=34880

   (57) https://bugs.python.org/issue?@action=redirect&bpo=37340

   (58) https://bugs.python.org/issue?@action=redirect&bpo=37648

   (59) https://bugs.python.org/issue?@action=redirect&bpo=37444

   (60) https://bugs.python.org/issue?@action=redirect&bpo=37619

   (61) https://bugs.python.org/issue?@action=redirect&bpo=37593

   (62) https://bugs.python.org/issue?@action=redirect&bpo=37543

   (63) https://bugs.python.org/issue?@action=redirect&bpo=37537

   (64) https://bugs.python.org/issue?@action=redirect&bpo=37467

   (65) https://bugs.python.org/issue?@action=redirect&bpo=37433

   (66) https://bugs.python.org/issue?@action=redirect&bpo=37417

   (67) https://bugs.python.org/issue?@action=redirect&bpo=37414

   (68) https://bugs.python.org/issue?@action=redirect&bpo=37392

   (69) https://bugs.python.org/issue?@action=redirect&bpo=37388

   (70) https://bugs.python.org/issue?@action=redirect&bpo=37348

   (71) https://bugs.python.org/issue?@action=redirect&bpo=24214

   (72) https://bugs.python.org/issue?@action=redirect&bpo=37330

   (73) https://bugs.python.org/issue?@action=redirect&bpo=35224

   (74) https://bugs.python.org/issue?@action=redirect&bpo=37316

   (75) https://bugs.python.org/issue?@action=redirect&bpo=37300

   (76) https://bugs.python.org/issue?@action=redirect&bpo=37269

   (77) https://bugs.python.org/issue?@action=redirect&bpo=20443

   (78) https://bugs.python.org/issue?@action=redirect&bpo=37257

   (79) https://bugs.python.org/issue?@action=redirect&bpo=37231

   (80) https://bugs.python.org/issue?@action=redirect&bpo=36974

   (81) https://bugs.python.org/issue?@action=redirect&bpo=37213

   (82) https://bugs.python.org/issue?@action=redirect&bpo=37219

   (83) https://bugs.python.org/issue?@action=redirect&bpo=15913

   (84) https://bugs.python.org/issue?@action=redirect&bpo=36922

   (85) https://bugs.python.org/issue?@action=redirect&bpo=36974

   (86) https://bugs.python.org/issue?@action=redirect&bpo=37160

   (87) https://bugs.python.org/issue?@action=redirect&bpo=37077

   (88) https://bugs.python.org/issue?@action=redirect&bpo=36781

   (89) https://bugs.python.org/issue?@action=redirect&bpo=34556

   (90) https://bugs.python.org/issue?@action=redirect&bpo=20523

   (91) https://bugs.python.org/issue?@action=redirect&bpo=35551

   (92) https://bugs.python.org/issue?@action=redirect&bpo=19072

   (93) https://bugs.python.org/issue?@action=redirect&bpo=27575

   (94) https://bugs.python.org/issue?@action=redirect&bpo=30773


File: python.info,  Node: Library<45>,  Next: Documentation<40>,  Prev: Core and Builtins<46>,  Up: Python 3 9 0 alpha 1

1.23.46.3 Library
.................

   - bpo-36589(1): The *note curses.update_lines_cols(): db9. function
     now returns ‘None’ instead of ‘1’ on success.

   - bpo-38807(2): Update *note TypeError: 502. messages for *note
     os.path.join(): 1597. to include *note os.PathLike: c1f. objects as
     acceptable input types.

   - bpo-38724(3): Add a repr for ‘subprocess.Popen’ objects.  Patch by
     Andrey Doroschenko.

   - bpo-38786(4): pydoc now recognizes and parses HTTPS URLs.  Patch by
     python273.

   - bpo-38785(5): Prevent asyncio from crashing if parent ‘__init__’ is
     not called from a constructor of object derived from
     ‘asyncio.Future’.

   - bpo-38723(6): *note pdb: 94. now uses *note io.open_code(): 168e.
     to trigger auditing events.

   - bpo-27805(7): Allow opening pipes and other non-seekable files in
     append mode with *note open(): 4e5.

   - bpo-38438(8): Simplify the *note argparse: 5. usage message for
     ‘nargs="*"’.

   - bpo-38761(9): WeakSet is now registered as a
     collections.abc.MutableSet.

   - bpo-38716(10): logging: change RotatingHandler namer and rotator to
     class-level attributes.  This stops __init__ from setting them to
     None in the case where a subclass defines them with eponymous
     methods.

   - bpo-38713(11): Add *note os.P_PIDFD: 8e8. constant, which may be
     passed to *note os.waitid(): d66. to wait on a Linux process file
     descriptor.

   - bpo-38692(12): Add *note asyncio.PidfdChildWatcher: 446, a
     Linux-specific child watcher implementation that polls process file
     descriptors.

   - bpo-38692(13): Expose the Linux ‘pidfd_open’ syscall as *note
     os.pidfd_open(): 447.

   - bpo-38602(14): Added constants ‘F_OFD_GETLK’, ‘F_OFD_SETLK’ and
     ‘F_OFD_SETLKW’ to the *note fcntl: 4f. module.  Patch by Donghee
     Na.

   - bpo-38334(15): Fixed seeking backward on an encrypted
     ‘zipfile.ZipExtFile’.

   - bpo-38312(16): Add *note curses.get_escdelay(): 8be, *note
     curses.set_escdelay(): 8bf, *note curses.get_tabsize(): 8c0, and
     *note curses.set_tabsize(): 8c1. functions - by Anthony Sottile.

   - bpo-38586(17): Now *note fileConfig(): b1f. correctly sets the
     .name of handlers loaded.

   - bpo-38565(18): Add new cache_parameters() method for
     functools.lru_cache() to better support pickling.

   - bpo-34679(19): asynci.ProactorEventLoop.close() now only calls
     signal.set_wakeup_fd() in the main thread.

   - bpo-31202(20): The case the result of ‘pathlib.WindowsPath.glob()’
     matches now the case of the pattern for literal parts.

   - bpo-36321(21): Remove misspelled attribute.  The 3.8 changelog
     noted that this would be removed in 3.9.

   - bpo-38521(22): Fixed erroneous equality comparison in
     statistics.NormalDist().

   - bpo-38493(23): Added *note CLD_KILLED: 8e6. and *note CLD_STOPPED:
     8e7. for ‘si_code’.  Patch by Donghee Na.

   - bpo-38478(24): Fixed a bug in ‘inspect.signature.bind()’ that was
     causing it to fail when handling a keyword argument with same name
     as positional-only parameter.  Patch by Pablo Galindo.

   - bpo-33604(25): Fixed ‘hmac.new’ and ‘hmac.HMAC’ to raise TypeError
     instead of ValueError when the digestmod parameter, now required in
     3.8, is omitted.  Also clarified the hmac module documentation and
     docstrings.

   - bpo-38378(26): Parameters 'out' and 'in' of *note os.sendfile():
     add. was renamed to 'out_fd' and 'in_fd'.

   - bpo-38417(27): Added support for setting the umask in the child
     process to the subprocess module on POSIX systems.

   - bpo-38449(28): Revert PR 15522, which introduces a regression in
     *note mimetypes.guess_type(): 1e9. due to improper handling of
     filenames as urls.

   - bpo-38431(29): Fix ‘__repr__’ method for ‘dataclasses.InitVar’ to
     support typing objects, patch by Samuel Colvin.

   - bpo-38109(30): Add missing *note stat.S_IFDOOR: f87, *note
     stat.S_IFPORT: f88, *note stat.S_IFWHT: f89, *note stat.S_ISDOOR():
     1931, *note stat.S_ISPORT(): 1932, and *note stat.S_ISWHT(): 1933.
     values to the Python implementation of *note stat: bc.

   - bpo-38422(31): Clarify docstrings of pathlib suffix(es)

   - bpo-38405(32): Nested subclasses of *note typing.NamedTuple: 290.
     are now pickleable.

   - bpo-38332(33): Prevent *note KeyError: 31d. thrown by
     ‘_encoded_words.decode()’ when given an encoded-word with invalid
     content-type encoding from propagating all the way to
     ‘email.message.get()’.

   - bpo-38371(34): Deprecated the ‘split()’ method in
     ‘_tkinter.TkappType’ in favour of the ‘splitlist()’ method which
     has more consistent and predictable behavior.

   - bpo-38341(35): Add *note smtplib.SMTPNotSupportedError: 1934. to
     the *note smtplib: b7. exported names.

   - bpo-38319(36): sendfile() used in socket and shutil modules was
     raising OverflowError for files >= 2GiB on 32-bit architectures.
     (patch by Giampaolo Rodola)

   - bpo-38242(37): Revert the new asyncio Streams API

   - bpo-13153(38): OS native encoding is now used for converting
     between Python strings and Tcl objects.  This allows to display,
     copy and paste to clipboard emoji and other non-BMP characters.
     Converting strings from Tcl to Python and back now never fails
     (except MemoryError).

   - bpo-38019(39): Correctly handle pause/resume reading of closed
     asyncio unix pipe.

   - bpo-38163(40): Child mocks will now detect their type as either
     synchronous or asynchronous, asynchronous child mocks will be
     AsyncMocks and synchronous child mocks will be either MagicMock or
     Mock (depending on their parent type).

   - bpo-38161(41): Removes _AwaitEvent from AsyncMock.

   - bpo-38216(42): Allow the rare code that wants to send invalid http
     requests from the ‘http.client’ library a way to do so.  The fixes
     for bpo-30458(43) led to breakage for some projects that were
     relying on this ability to test their own behavior in the face of
     bad requests.

   - bpo-28286(44): Deprecate opening *note GzipFile: 3f3. for writing
     implicitly.  Always specify the 'mode' argument for writing.

   - bpo-38108(45): Any synchronous magic methods on an AsyncMock now
     return a MagicMock.  Any asynchronous magic methods on a MagicMock
     now return an AsyncMock.

   - bpo-38265(46): Update the 'length' parameter of *note os.pread():
     b2d. to accept *note Py_ssize_t: a2e. instead of int.

   - bpo-38112(47): *note compileall: 19. has a higher default recursion
     limit and new command-line arguments for path manipulation,
     symlinks handling, and multiple optimization levels.

   - bpo-38248(48): asyncio: Fix inconsistent immediate Task
     cancellation

   - bpo-38237(49): The arguments for the builtin pow function are more
     descriptive.  They can now also be passed in as keywords.

   - bpo-34002(50): Improve efficiency in parts of email package by
     changing while-pop to a for loop, using isdisjoint instead of set
     intersections.

   - bpo-38191(51): Constructors of *note NamedTuple: 290. and *note
     TypedDict: 148. types now accept arbitrary keyword argument names,
     including "cls", "self", "typename", "_typename", "fields" and
     "_fields".

   - bpo-38155(52): Add ‘__all__’ to *note datetime: 28.  Patch by Tahia
     Khan.

   - bpo-38185(53): Fixed case-insensitive string comparison in *note
     sqlite3.Row: e3a. indexing.

   - bpo-38136(54): Changes AsyncMock call count and await count to be
     two different counters.  Now await count only counts when a
     coroutine has been awaited, not when it has been called, and
     vice-versa.  Update the documentation around this.

   - bpo-37828(55): Fix default mock name in *note
     unittest.mock.Mock.assert_called(): cc6. exceptions.  Patch by
     Abraham Toriz Cruz.

   - bpo-38175(56): Fix a memory leak in comparison of *note
     sqlite3.Row: e3a. objects.

   - bpo-33936(57): _hashlib no longer calls obsolete OpenSSL
     initialization function with OpenSSL 1.1.0+.

   - bpo-34706(58): Preserve subclassing in
     inspect.Signature.from_callable.

   - bpo-38153(59): Names of hashing algorithms from OpenSSL are now
     normalized to follow Python's naming conventions.  For example
     OpenSSL uses sha3-512 instead of sha3_512 or blake2b512 instead of
     blake2b.

   - bpo-38115(60): Fix a bug in dis.findlinestarts() where it would
     return invalid bytecode offsets.  Document that a code object's
     co_lnotab can contain invalid bytecode offsets.

   - bpo-38148(61): Add slots to *note asyncio: 8. transport classes,
     which can reduce memory usage.

   - bpo-38142(62): The _hashlib OpenSSL wrapper extension module is now
     PEP-384 compliant.

   - bpo-9216(63): hashlib constructors now support usedforsecurity flag
     to signal that a hashing algorithm is not used in a security
     context.

   - bpo-36991(64): Fixes a potential incorrect AttributeError exception
     escaping ZipFile.extract() in some unsupported input error
     situations.

   - bpo-38134(65): Remove obsolete copy of PBKDF2_HMAC_fast.  All
     supported OpenSSL versions contain a fast implementation.

   - bpo-38132(66): The OpenSSL hashlib wrapper uses a simpler
     implementation.  Several Macros and pointless caches are gone.  The
     hash name now comes from OpenSSL's EVP. The algorithm name stays
     the same, except it is now always lower case.

   - bpo-38008(67): Fix parent class check in protocols to correctly
     identify the module that provides a builtin protocol, instead of
     assuming they all come from the *note collections.abc: 17. module

   - bpo-34037(68): For *note asyncio: 8, add a new coroutine
     ‘loop.shutdown_default_executor()’.  The new coroutine provides an
     API to schedule an executor shutdown that waits on the threadpool
     to finish closing.  Also, *note asyncio.run(): 449. has been
     updated to utilize the new coroutine.  Patch by Kyle Stanley.

   - bpo-37405(69): Fixed regression bug for socket.getsockname() for
     non-CAN_ISOTP AF_CAN address family sockets by returning a 1-tuple
     instead of string.

   - bpo-38121(70): Update parameter names on functions in
     importlib.metadata matching the changes in the 0.22 release of
     importlib_metadata.

   - bpo-38110(71): The os.closewalk() implementation now uses the libc
     fdwalk() API on platforms where it is available.

   - bpo-38093(72): Fixes AsyncMock so it doesn't crash when used with
     AsyncContextManagers or AsyncIterators.

   - bpo-37488(73): Add warning to ‘datetime.utctimetuple()’,
     ‘datetime.utcnow()’ and ‘datetime.utcfromtimestamp()’ .

   - bpo-35640(74): Allow passing a *note path-like object: 280. as
     ‘directory’ argument to the *note
     http.server.SimpleHTTPRequestHandler: b11. class.  Patch by Géry
     Ogam.

   - bpo-38086(75): Update importlib.metadata with changes from
     importlib_metadata 0.21(76).

   - bpo-37251(77): Remove ‘__code__’ check in AsyncMock that
     incorrectly evaluated function specs as async objects but failed to
     evaluate classes with ‘__await__’ but no ‘__code__’ attribute
     defined as async objects.

   - bpo-38037(78): Fix reference counters in the *note signal: b4.
     module.

   - bpo-38066(79): Hide internal asyncio.Stream methods: feed_eof(),
     feed_data(), set_exception() and set_transport().

   - bpo-38059(80): inspect.py now uses sys.exit() instead of exit()

   - bpo-38049(81): Added command-line interface for the *note ast: 7.
     module.

   - bpo-37953(82): In *note typing: ed, improved the ‘__hash__’ and
     ‘__eq__’ methods for ‘ForwardReferences’.

   - bpo-38026(83): Fixed *note inspect.getattr_static(): 461. used
     ‘isinstance’ while it should avoid dynamic lookup.

   - bpo-35923(84): Update *note importlib.machinery.BuiltinImporter:
     c7d. to use ‘loader._ORIGIN’ instead of a hardcoded value.  Patch
     by Donghee Na.

   - bpo-38010(85): In ‘importlib.metadata’ sync with
     ‘importlib_metadata’ 0.20, clarifying behavior of ‘files()’ and
     fixing issue where only one requirement was returned for
     ‘requires()’ on ‘dist-info’ packages.

   - bpo-38006(86): weakref.WeakValueDictionary defines a local remove()
     function used as callback for weak references.  This function was
     created with a closure.  Modify the implementation to avoid the
     closure.

   - bpo-37995(87): Added the 'indent' option to *note ast.dump(): 8b2.
     which allows it to produce a multiline indented output.

   - bpo-34410(88): Fixed a crash in the ‘tee()’ iterator when re-enter
     it.  RuntimeError is now raised in this case.

   - bpo-37140(89): Fix a ctypes regression of Python 3.8.  When a
     ctypes.Structure is passed by copy to a function, ctypes internals
     created a temporary object which had the side effect of calling the
     structure finalizer (__del__) twice.  The Python semantics requires
     a finalizer to be called exactly once.  Fix ctypes internals to no
     longer call the finalizer twice.

   - bpo-37587(90): ‘_json.scanstring’ is now up to 3x faster when there
     are many backslash escaped characters in the JSON string.

   - bpo-37834(91): Prevent shutil.rmtree exception when built on
     non-Windows system without fd system call support, like older
     versions of macOS.

   - bpo-10978(92): Semaphores and BoundedSemaphores can now release
     more than one waiting thread at a time.

   - bpo-37972(93): Subscripts to the ‘unittest.mock.call’ objects now
     receive the same chaining mechanism as any other custom attributes,
     so that the following usage no longer raises a ‘TypeError’:

     ‘call().foo().__getitem__('bar')’

     Patch by blhsing

   - bpo-37965(94): Fix C compiler warning caused by
     distutils.ccompiler.CCompiler.has_function.

   - bpo-37964(95): Add ‘F_GETPATH’ command to *note fcntl: 4f.

   - bpo-37960(96): ‘repr()’ of buffered and text streams now silences
     only expected exceptions when get the value of "name" and "mode"
     attributes.

   - bpo-37961(97): Add a ‘total_nframe’ field to the traces collected
     by the tracemalloc module.  This field indicates the original
     number of frames before it was truncated.

   - bpo-37951(98): Most features of the subprocess module now work
     again in subinterpreters.  Only 'preexec_fn' is restricted in
     subinterpreters.

   - bpo-36205(99): Fix the rusage implementation of time.process_time()
     to correctly report the sum of the system and user CPU time.

   - bpo-37950(100): Fix *note ast.dump(): 8b2. when call with
     incompletely initialized node.

   - bpo-34679(101): Restores instantiation of Windows IOCP event loops
     from the non-main thread.

   - bpo-36917(102): Add default implementation of the *note
     ast.NodeVisitor.visit_Constant(): a3c. method which emits a
     deprecation warning and calls corresponding methods ‘visit_Num()’,
     ‘visit_Str()’, etc.

   - bpo-37798(103): Update test_statistics.py to verify that the
     statistics module works well for both C and Python implementations.
     Patch by Donghee Na

   - bpo-26589(104): Added a new status code to the http module: 451
     UNAVAILABLE_FOR_LEGAL_REASONS

   - bpo-37915(105): Fix a segmentation fault that appeared when
     comparing instances of ‘datetime.timezone’ and ‘datetime.tzinfo’
     objects.  Patch by Pablo Galindo.

   - bpo-32554(106): Deprecate having random.seed() call hash on
     arbitrary types.

   - bpo-9938(107): Add optional keyword argument ‘exit_on_error’ for
     ‘ArgumentParser’.

   - bpo-37851(108): The *note faulthandler: 4e. module no longer
     allocates its alternative stack at Python startup.  Now the stack
     is only allocated at the first faulthandler usage.

   - bpo-32793(109): Fix a duplicated debug message when *note
     smtplib.SMTP.connect(): 1935. is called.

   - bpo-37885(110): venv: Don't generate unset variable warning on
     deactivate.

   - bpo-37868(111): Fix dataclasses.is_dataclass when given an instance
     that never raises AttributeError in __getattr__.  That is, an
     object that returns something for __dataclass_fields__ even if it's
     not a dataclass.

   - bpo-37811(112): Fix ‘socket’ module's ‘socket.connect(address)’
     function being unable to establish connection in case of
     interrupted system call.  The problem was observed on all OSes
     which ‘poll(2)’ system call can take only non-negative integers and
     -1 as a timeout value.

   - bpo-37863(113): Optimizations for Fraction.__hash__ suggested by
     Tim Peters.

   - bpo-21131(114): Fix ‘faulthandler.register(chain=True)’ stack.
     faulthandler now allocates a dedicated stack of ‘SIGSTKSZ*2’ bytes,
     instead of just ‘SIGSTKSZ’ bytes.  Calling the previous signal
     handler in faulthandler signal handler uses more than ‘SIGSTKSZ’
     bytes of stack memory on some platforms.

   - bpo-37798(115): Add C fastpath for statistics.NormalDist.inv_cdf()
     Patch by Donghee Na

   - bpo-37804(116): Remove the deprecated method
     ‘threading.Thread.isAlive()’.  Patch by Donghee Na.

   - bpo-37819(117): Add Fraction.as_integer_ratio() to match the
     corresponding methods in bool, int, float, and decimal.

   - bpo-14465(118): Add an xml.etree.ElementTree.indent() function for
     pretty-printing XML trees.  Contributed by Stefan Behnel.

   - bpo-37810(119): Fix *note difflib: 2f. ‘?’ hint in diff output when
     dealing with tabs.  Patch by Anthony Sottile.

   - bpo-37772(120): In ‘zipfile.Path’, when adding implicit dirs,
     ensure that ancestral directories are added and that duplicates are
     excluded.

   - bpo-18578(121): Renamed and documented ‘test.bytecode_helper’ as
     ‘test.support.bytecode_helper’.  Patch by Joannah Nanjekye.

   - bpo-37785(122): Fix xgettext warnings in *note argparse: 5.

   - bpo-34488(123): ‘writelines()’ method of *note io.BytesIO: e6d. is
     now slightly faster when many small lines are passed.  Patch by
     Sergey Fedoseev.

   - bpo-37449(124): ‘ensurepip’ now uses
     ‘importlib.resources.read_binary()’ to read data instead of
     ‘pkgutil.get_data()’.  Patch by Joannah Nanjekye.

   - bpo-28292(125): Mark calendar.py helper functions as being private.
     The follows PEP 8 guidance to maintain the style conventions in the
     module and it addresses a known case of user confusion.

   - bpo-18049(126): Add definition of THREAD_STACK_SIZE for AIX in
     Python/thread_pthread.h The default thread stacksize caused crashes
     with the default recursion limit Patch by M Felt

   - bpo-37742(127): The logging.getLogger() API now returns the root
     logger when passed the name 'root', whereas previously it returned
     a non-root logger named 'root'.  This could affect cases where user
     code explicitly wants a non-root logger named 'root', or
     instantiates a logger using logging.getLogger(__name__) in some
     top-level module called 'root.py'.

   - bpo-37738(128): Fix the implementation of curses ‘addch(str,
     color_pair)’: pass the color pair to ‘setcchar()’, instead of
     always passing 0 as the color pair.

   - bpo-37723(129): Fix performance regression on regular expression
     parsing with huge character sets.  Patch by Yann Vaginay.

   - bpo-35943(130): The function *note PyImport_GetModule(): b81. now
     ensures any module it returns is fully initialized.  Patch by
     Joannah Nanjekye.

   - bpo-32178(131): Fix IndexError in *note email: 32. package when
     trying to parse invalid address fields starting with ‘:’.

   - bpo-37268(132): The ‘parser’ module is deprecated and will be
     removed in future versions of Python.

   - bpo-11953(133): Completing WSA* error codes in *note socket: b8.

   - bpo-37685(134): Fixed comparisons of *note datetime.timedelta: 99d.
     and *note datetime.timezone: 1091.

   - bpo-37697(135): Synchronize ‘importlib.metadata’ with
     importlib_metadata 0.19(136), improving handling of EGG-INFO files
     and fixing a crash when entry point names contained colons.

   - bpo-37695(137): Correct *note curses.unget_wch(): 106d. error
     message.  Patch by Anthony Sottile.

   - bpo-37689(138): Add ‘is_relative_to()’ in ‘PurePath’ to determine
     whether or not one path is relative to another.

   - bpo-29553(139): Fixed *note argparse.ArgumentParser.format_usage():
     1936. for mutually exclusive groups.  Patch by Andrew Nester.

   - bpo-37691(140): Let math.dist() accept coordinates as sequences (or
     iterables) rather than just tuples.

   - bpo-37685(141): Fixed ‘__eq__’, ‘__lt__’ etc implementations in
     some classes.  They now return *note NotImplemented: 79d. for
     unsupported type of the other operand.  This allows the other
     operand to play role (for example the equality comparison with
     *note ANY: 1937. will return ‘True’).

   - bpo-37354(142): Make Activate.ps1 Powershell script static to allow
     for signing it.

   - bpo-37664(143): Update wheels bundled with ensurepip (pip 19.2.3
     and setuptools 41.2.0)

   - bpo-37663(144): Bring consistency to venv shell activation scripts
     by always using __VENV_PROMPT__.

   - bpo-37642(145): Allowed the pure Python implementation of *note
     datetime.timezone: 1091. to represent sub-minute offsets close to
     minimum and maximum boundaries, specifically in the ranges (23:59,
     24:00) and (-23:59, 24:00).  Patch by Ngalim Siregar

   - bpo-36161(146): In *note posix: 9b, use ‘ttyname_r’ instead of
     ‘ttyname’ for thread safety.

   - bpo-36324(147): Make internal attributes for
     statistics.NormalDist() private.

   - bpo-37555(148): Fix ‘NonCallableMock._call_matcher’ returning tuple
     instead of ‘_Call’ object when ‘self._spec_signature’ exists.
     Patch by Elizabeth Uselton

   - bpo-29446(149): Make ‘from tkinter import *’ import only the
     expected objects.

   - bpo-16970(150): Adding a value error when an invalid value in
     passed to nargs Patch by Robert Leenders

   - bpo-34443(151): Exceptions from *note enum: 4c. now use the
     ‘__qualname’ of the enum class in the exception message instead of
     the ‘__name__’.

   - bpo-37491(152): Fix ‘IndexError’ when parsing email headers with
     unexpectedly ending bare-quoted string value.  Patch by Abhilash
     Raj.

   - bpo-37587(153): Make json.loads faster for long strings.  (Patch by
     Marco Paolini)

   - bpo-18378(154): Recognize "UTF-8" as a valid value for LC_CTYPE in
     locale._parse_localename.

   - bpo-37579(155): Return *note NotImplemented: 79d. in Python
     implementation of ‘__eq__’ for *note timedelta: 99d. and *note
     time: 1b0. when the other object being compared is not of the same
     type to match C implementation.  Patch by Karthikeyan Singaravelan.

   - bpo-21478(156): Record calls to parent when autospecced object is
     attached to a mock using ‘unittest.mock.attach_mock()’.  Patch by
     Karthikeyan Singaravelan.

   - bpo-37531(157): "python3 -m test -jN -timeout=TIMEOUT" now kills a
     worker process if it runs longer than 'TIMEOUT' seconds.

   - bpo-37482(158): Fix serialization of display name in originator or
     destination address fields with both encoded words and special
     chars.

   - bpo-36993(159): Improve error reporting for corrupt zip files with
     bad zip64 extra data.  Patch by Daniel Hillier.

   - bpo-37502(160): pickle.loads() no longer raises TypeError when the
     buffers argument is set to None

   - bpo-37520(161): Correct behavior for zipfile.Path.parent when the
     path object identifies a subdirectory.

   - bpo-18374(162): Fix the ‘.col_offset’ attribute of nested *note
     ast.BinOp: 1938. instances which had a too large value in some
     situations.

   - bpo-37424(163): Fixes a possible hang when using a timeout on
     ‘subprocess.run()’ while capturing output.  If the child process
     spawned its own children or otherwise connected its stdout or
     stderr handles with another process, we could hang after the
     timeout was reached and our child was killed when attempting to
     read final output from the pipes.

   - bpo-37421(164): Fix ‘multiprocessing.util.get_temp_dir()’
     finalizer: clear also the 'tempdir' configuration of the current
     process, so next call to ‘get_temp_dir()’ will create a new
     temporary directory, rather than reusing the removed temporary
     directory.

   - bpo-37481(165): The distutils ‘bdist_wininst’ command is deprecated
     in Python 3.8, use ‘bdist_wheel’ (wheel packages) instead.

   - bpo-37479(166): When ‘Enum.__str__’ is overridden in a derived
     class, the override will be used by ‘Enum.__format__’ regardless of
     whether mixin classes are present.

   - bpo-37440(167): http.client now enables TLS 1.3 post-handshake
     authentication for default context or if a cert_file is passed to
     HTTPSConnection.

   - bpo-37437(168): Update vendorized expat version to 2.2.7.

   - bpo-37428(169): SSLContext.post_handshake_auth = True no longer
     sets SSL_VERIFY_POST_HANDSHAKE verify flag for client connections.
     Although the option is documented as ignored for clients, OpenSSL
     implicitly enables cert chain validation when the flag is set.

   - bpo-37420(170): *note os.sched_setaffinity(): 10e1. now correctly
     handles errors that arise during iteration over its ‘mask’
     argument.  Patch by Brandt Bucher.

   - bpo-37412(171): The *note os.getcwdb(): a5f. function now uses the
     UTF-8 encoding on Windows, rather than the ANSI code page: see PEP
     529(172) for the rationale.  The function is no longer deprecated
     on Windows.

   - bpo-37406(173): The sqlite3 module now raises TypeError, rather
     than ValueError, if operation argument type is not str: execute(),
     executemany() and calling a connection.

   - bpo-29412(174): Fix IndexError in parsing a header value ending
     unexpectedly.  Patch by Abhilash Raj.

   - bpo-36546(175): The 'dist' argument for statistics.quantiles() is
     now positional only.  The current name doesn't reflect that the
     argument can be either a dataset or a distribution.  Marking the
     parameter as positional avoids confusion and makes it possible to
     change the name later.

   - bpo-37394(176): Fix a bug that was causing the *note queue: a4.
     module to fail if the accelerator module was not available.  Patch
     by Pablo Galindo.

   - bpo-37376(177): *note pprint: 9c. now has support for *note
     types.SimpleNamespace: 1b3.  Patch by Carl Bordum Hansen.

   - bpo-26967(178): An *note ArgumentParser: 503. with
     ‘allow_abbrev=False’ no longer disables grouping of short flags,
     such as ‘-vv’, but only disables abbreviation of long flags as
     documented.  Patch by Zac Hatfield-Dodds.

   - bpo-37212(179): *note unittest.mock.call(): 1939. now preserves the
     order of keyword arguments in repr output.  Patch by Karthikeyan
     Singaravelan.

   - bpo-37372(180): Fix error unpickling datetime.time objects from
     Python 2 with seconds>=24.  Patch by Justin Blanchard.

   - bpo-37345(181): Add formal support for UDPLITE sockets.  Support
     was present before, but it is now easier to detect support with
     ‘hasattr(socket, 'IPPROTO_UDPLITE')’ and there are constants
     defined for each of the values needed: ‘socket.IPPROTO_UDPLITE’,
     ‘UDPLITE_SEND_CSCOV’, and ‘UDPLITE_RECV_CSCOV’.  Patch by Gabe
     Appleton.

   - bpo-37358(182): Optimized ‘functools.partial’ by using vectorcall.

   - bpo-37347(183): *note sqlite3.Connection.create_aggregate(): 28a,
     *note sqlite3.Connection.create_function(): 289, *note
     sqlite3.Connection.set_authorizer(): 28b, *note
     sqlite3.Connection.set_progress_handler(): 28c. *note
     sqlite3.Connection.set_trace_callback(): 28d. methods lead to
     segfaults if some of these methods are called twice with an equal
     object but not the same.  Now callbacks are stored more carefully.
     Patch by Aleksandr Balezin.

   - bpo-37163(184): The 'obj' argument of *note dataclasses.replace():
     165e. is positional-only now.

   - bpo-37085(185): Add the optional Linux SocketCAN Broadcast Manager
     constants, used as flags to configure the BCM behaviour, in the
     socket module.  Patch by Karl Ding.

   - bpo-37328(186): ‘HTMLParser.unescape’ is removed.  It was
     undocumented and deprecated since Python 3.4.

   - bpo-37305(187): Add .webmanifest -> application/manifest+json to
     list of recognized file types and content type headers

   - bpo-37320(188): ‘aifc.openfp()’ alias to ‘aifc.open()’,
     ‘sunau.openfp()’ alias to ‘sunau.open()’, and ‘wave.openfp()’ alias
     to ‘wave.open()’ have been removed.  They were deprecated since
     Python 3.7.

   - bpo-37315(189): Deprecated accepting floats with integral value
     (like ‘5.0’) in *note math.factorial(): 915.

   - bpo-37312(190): ‘_dummy_thread’ and ‘dummy_threading’ modules have
     been removed.  These modules were deprecated since Python 3.7 which
     requires threading support.

   - bpo-33972(191): Email with single part but content-type set to
     ‘multipart/*’ doesn't raise AttributeError anymore.

   - bpo-37280(192): Use threadpool for reading from file for sendfile
     fallback mode.

   - bpo-37279(193): Fix asyncio sendfile support when sendfile sends
     extra data in fallback mode.

   - bpo-19865(194): *note ctypes.create_unicode_buffer(): 193a. now
     also supports non-BMP characters on platforms with 16-bit ‘wchar_t’
     (for example, Windows and AIX).

   - bpo-37266(195): In a subinterpreter, spawning a daemon thread now
     raises an exception.  Daemon threads were never supported in
     subinterpreters.  Previously, the subinterpreter finalization
     crashed with a Python fatal error if a daemon thread was still
     running.

   - bpo-37210(196): Allow pure Python implementation of *note pickle:
     95. to work even when the C ‘_pickle’ module is unavailable.

   - bpo-21872(197): Fix *note lzma: 7e.: module decompresses data
     incompletely.  When decompressing a FORMAT_ALONE format file, and
     it doesn't have the end marker, sometimes the last one to dozens
     bytes can't be output.  Patch by Ma Lin.

   - bpo-35922(198): Fix ‘RobotFileParser.crawl_delay()’ and
     ‘RobotFileParser.request_rate()’ to return ‘None’ rather than raise
     *note AttributeError: 326. when no relevant rule is defined in the
     robots.txt file.  Patch by Rémi Lapeyre.

   - bpo-35766(199): Change the format of feature_version to be a
     (major, minor) tuple.

   - bpo-36607(200): Eliminate *note RuntimeError: 17a. raised by *note
     asyncio.all_tasks(): 924. if internal tasks weak set is changed by
     another thread during iteration.

   - bpo-18748(201): ‘_pyio.IOBase’ destructor now does nothing if
     getting the ‘closed’ attribute fails to better mimic ‘_io.IOBase’
     finalizer.

   - bpo-36402(202): Fix a race condition at Python shutdown when
     waiting for threads.  Wait until the Python thread state of all
     non-daemon threads get deleted (join all non-daemon threads),
     rather than just wait until non-daemon Python threads complete.

   - bpo-37206(203): Default values which cannot be represented as
     Python objects no longer improperly represented as ‘None’ in
     function signatures.

   - bpo-37111(204): Added ‘encoding’ and ‘errors’ keyword parameters to
     ‘logging.basicConfig’.

   - bpo-12144(205): Ensure cookies with ‘expires’ attribute are handled
     in ‘CookieJar.make_cookies()’.

   - bpo-34886(206): Fix an unintended ValueError from *note
     subprocess.run(): b54. when checking for conflicting 'input' and
     'stdin' or 'capture_output' and 'stdout' or 'stderr' args when they
     were explicitly provided but with ‘None’ values within a passed in
     ‘**kwargs’ dict rather than as passed directly by name.  Patch
     contributed by Rémi Lapeyre.

   - bpo-37173(207): The exception message for ‘inspect.getfile()’ now
     correctly reports the passed class rather than the builtins module.

   - bpo-37178(208): Give math.perm() a one argument form that means the
     same as math.factorial().

   - bpo-37178(209): For math.perm(n, k), let k default to n, giving the
     same result as factorial.

   - bpo-37165(210): Converted _collections._count_elements to use the
     Argument Clinic.

   - bpo-34767(211): Do not always create a *note collections.deque:
     5a6. in *note asyncio.Lock: a3f.

   - bpo-37158(212): Speed-up statistics.fmean() by switching from a
     function to a generator.

   - bpo-34282(213): Remove ‘Enum._convert’ method, deprecated in 3.8.

   - bpo-37150(214): ‘argparse._ActionsContainer.add_argument’ now
     throws error, if someone accidentally pass FileType class object
     instead of instance of FileType as ‘type’ argument.

   - bpo-28724(215): The socket module now has the *note
     socket.send_fds(): 901. and ‘socket.recv.fds()’ methods.
     Contributed by Joannah Nanjekye, Shinya Okano and Victor Stinner.

   - bpo-35621(216): Support running asyncio subprocesses when execution
     event loop in a thread on UNIX.

   - bpo-36520(217): Lengthy email headers with UTF-8 characters are now
     properly encoded when they are folded.  Patch by Jeffrey Kintscher.

   - bpo-30835(218): Fixed a bug in email parsing where a message with
     invalid bytes in content-transfer-encoding of a multipart message
     can cause an AttributeError.  Patch by Andrew Donnellan.

   - bpo-31163(219): pathlib.Path instance's rename and replace methods
     now return the new Path instance.

   - bpo-25068(220): *note urllib.request.ProxyHandler: 193b. now
     lowercases the keys of the passed dictionary.

   - bpo-26185(221): Fix *note repr(): 7c8. on empty ‘ZipInfo’ object.
     Patch by Mickaël Schoentgen.

   - bpo-21315(222): Email headers containing RFC2047 encoded words are
     parsed despite the missing whitespace, and a defect registered.
     Also missing trailing whitespace after encoded words is now
     registered as a defect.

   - bpo-31904(223): Port test_datetime to VxWorks: skip zoneinfo tests
     on VxWorks

   - bpo-35805(224): Add parser for Message-ID header and add it to
     default HeaderRegistry.  This should prevent folding of Message-ID
     using RFC 2048 encoded words.

   - bpo-36871(225): Ensure method signature is used instead of
     constructor signature of a class while asserting mock object
     against method calls.  Patch by Karthikeyan Singaravelan.

   - bpo-35070(226): posix.getgrouplist() now works correctly when the
     user belongs to NGROUPS_MAX supplemental groups.  Patch by Jeffrey
     Kintscher.

   - bpo-31783(227): Fix race condition in ThreadPoolExecutor when
     worker threads are created during interpreter shutdown.

   - bpo-36582(228): Fix ‘UserString.encode()’ to correctly return
     ‘bytes’ rather than a ‘UserString’ instance.

   - bpo-32424(229): Deprecate xml.etree.ElementTree.Element.copy() in
     favor of copy.copy().

     Patch by Gordon P. Hemsley

   - bpo-36564(230): Fix infinite loop in email header folding logic
     that would be triggered when an email policy's max_line_length is
     not long enough to include the required markup and any values in
     the message.  Patch by Paul Ganssle

   - bpo-36543(231): Removed methods Element.getchildren(),
     Element.getiterator() and ElementTree.getiterator() and the
     xml.etree.cElementTree module.

   - bpo-36409(232): Remove the old plistlib API deprecated in Python
     3.4

   - bpo-36302(233): distutils sorts source file lists so that Extension
     .so files build more reproducibly by default

   - bpo-36250(234): Ignore ‘ValueError’ from ‘signal’ with
     ‘interaction’ in non-main thread.

   - bpo-36046(235): Added ‘user’, ‘group’ and ‘extra_groups’ parameters
     to the subprocess.Popen constructor.  Patch by Patrick McLean.

   - bpo-32627(236): Fix compile error when ‘_uuid’ headers conflicting
     included.

   - bpo-35800(237): Deprecate ‘smtpd.MailmanProxy’ ready for future
     removal.

   - bpo-35168(238): *note shlex.shlex.punctuation_chars: 193c. is now a
     read-only property.

   - bpo-8538(239): Add support for boolean actions like ‘--foo’ and
     ‘--no-foo’ to argparse.  Patch contributed by Rémi Lapeyre.

   - bpo-20504(240): Fixes a bug in ‘cgi’ module when a
     multipart/form-data request has no ‘Content-Length’ header.

   - bpo-25988(241): The abstract base classes in *note collections.abc:
     17. no longer are exposed in the regular *note collections: 16.
     module.

   - bpo-11122(242): Distutils won't check for rpmbuild in specified
     paths only.

   - bpo-34775(243): Division handling of PurePath now returns
     NotImplemented instead of raising a TypeError when passed something
     other than an instance of str or PurePath.  Patch by Roger Aiudi.

   - bpo-34749(244): *note binascii.a2b_base64(): 1591. is now up to 2
     times faster.  Patch by Sergey Fedoseev.

   - bpo-34519(245): Add additional aliases for HP Roman 8.  Patch by
     Michael Osipov.

   - bpo-28009(246): Fix uuid.getnode() on platforms with '.'  as MAC
     Addr delimiter as well fix for MAC Addr format that omits a leading
     0 in MAC Addr values.  Currently, AIX is the only know platform
     with these settings.  Patch by Michael Felt.

   - bpo-30618(247): Add *note readlink(): 8ed.  Patch by Girts
     Folkmanis.

   - bpo-32498(248): Made *note urllib.parse.unquote(): 16f1. accept
     bytes in addition to strings.  Patch by Stein Karlsen.

   - bpo-33348(249): lib2to3 now recognizes expressions after ‘*’ and
     ‘**’ like in ‘f(*[] or [])’.

   - bpo-32689(250): Update *note shutil.move(): a2a. function to allow
     for Path objects to be used as source argument.  Patch by Emily
     Morehouse and Maxwell "5.13b" McKinnon.

   - bpo-32820(251): Added ‘__format__’ to IPv4 and IPv6 classes.
     Always outputs a fully zero-padded string.  Supports b/x/n
     modifiers (bin/hex/native format).  Native format for IPv4 is bin,
     native format for IPv6 is hex.  Also supports '#' and '_'
     modifiers.

   - bpo-27657(252): Fix urllib.parse.urlparse() with numeric paths.  A
     string like "path:80" is no longer parsed as a path but as a scheme
     ("path") and a path ("80").

   - bpo-4963(253): Fixed non-deterministic behavior related to
     mimetypes extension mapping and module reinitialization.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36589

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38807

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38724

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38786

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38785

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38723

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27805

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38438

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38761

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38716

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38713

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38692

   (13) https://bugs.python.org/issue?@action=redirect&bpo=38692

   (14) https://bugs.python.org/issue?@action=redirect&bpo=38602

   (15) https://bugs.python.org/issue?@action=redirect&bpo=38334

   (16) https://bugs.python.org/issue?@action=redirect&bpo=38312

   (17) https://bugs.python.org/issue?@action=redirect&bpo=38586

   (18) https://bugs.python.org/issue?@action=redirect&bpo=38565

   (19) https://bugs.python.org/issue?@action=redirect&bpo=34679

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31202

   (21) https://bugs.python.org/issue?@action=redirect&bpo=36321

   (22) https://bugs.python.org/issue?@action=redirect&bpo=38521

   (23) https://bugs.python.org/issue?@action=redirect&bpo=38493

   (24) https://bugs.python.org/issue?@action=redirect&bpo=38478

   (25) https://bugs.python.org/issue?@action=redirect&bpo=33604

   (26) https://bugs.python.org/issue?@action=redirect&bpo=38378

   (27) https://bugs.python.org/issue?@action=redirect&bpo=38417

   (28) https://bugs.python.org/issue?@action=redirect&bpo=38449

   (29) https://bugs.python.org/issue?@action=redirect&bpo=38431

   (30) https://bugs.python.org/issue?@action=redirect&bpo=38109

   (31) https://bugs.python.org/issue?@action=redirect&bpo=38422

   (32) https://bugs.python.org/issue?@action=redirect&bpo=38405

   (33) https://bugs.python.org/issue?@action=redirect&bpo=38332

   (34) https://bugs.python.org/issue?@action=redirect&bpo=38371

   (35) https://bugs.python.org/issue?@action=redirect&bpo=38341

   (36) https://bugs.python.org/issue?@action=redirect&bpo=38319

   (37) https://bugs.python.org/issue?@action=redirect&bpo=38242

   (38) https://bugs.python.org/issue?@action=redirect&bpo=13153

   (39) https://bugs.python.org/issue?@action=redirect&bpo=38019

   (40) https://bugs.python.org/issue?@action=redirect&bpo=38163

   (41) https://bugs.python.org/issue?@action=redirect&bpo=38161

   (42) https://bugs.python.org/issue?@action=redirect&bpo=38216

   (43) https://bugs.python.org/issue?@action=redirect&bpo=30458

   (44) https://bugs.python.org/issue?@action=redirect&bpo=28286

   (45) https://bugs.python.org/issue?@action=redirect&bpo=38108

   (46) https://bugs.python.org/issue?@action=redirect&bpo=38265

   (47) https://bugs.python.org/issue?@action=redirect&bpo=38112

   (48) https://bugs.python.org/issue?@action=redirect&bpo=38248

   (49) https://bugs.python.org/issue?@action=redirect&bpo=38237

   (50) https://bugs.python.org/issue?@action=redirect&bpo=34002

   (51) https://bugs.python.org/issue?@action=redirect&bpo=38191

   (52) https://bugs.python.org/issue?@action=redirect&bpo=38155

   (53) https://bugs.python.org/issue?@action=redirect&bpo=38185

   (54) https://bugs.python.org/issue?@action=redirect&bpo=38136

   (55) https://bugs.python.org/issue?@action=redirect&bpo=37828

   (56) https://bugs.python.org/issue?@action=redirect&bpo=38175

   (57) https://bugs.python.org/issue?@action=redirect&bpo=33936

   (58) https://bugs.python.org/issue?@action=redirect&bpo=34706

   (59) https://bugs.python.org/issue?@action=redirect&bpo=38153

   (60) https://bugs.python.org/issue?@action=redirect&bpo=38115

   (61) https://bugs.python.org/issue?@action=redirect&bpo=38148

   (62) https://bugs.python.org/issue?@action=redirect&bpo=38142

   (63) https://bugs.python.org/issue?@action=redirect&bpo=9216

   (64) https://bugs.python.org/issue?@action=redirect&bpo=36991

   (65) https://bugs.python.org/issue?@action=redirect&bpo=38134

   (66) https://bugs.python.org/issue?@action=redirect&bpo=38132

   (67) https://bugs.python.org/issue?@action=redirect&bpo=38008

   (68) https://bugs.python.org/issue?@action=redirect&bpo=34037

   (69) https://bugs.python.org/issue?@action=redirect&bpo=37405

   (70) https://bugs.python.org/issue?@action=redirect&bpo=38121

   (71) https://bugs.python.org/issue?@action=redirect&bpo=38110

   (72) https://bugs.python.org/issue?@action=redirect&bpo=38093

   (73) https://bugs.python.org/issue?@action=redirect&bpo=37488

   (74) https://bugs.python.org/issue?@action=redirect&bpo=35640

   (75) https://bugs.python.org/issue?@action=redirect&bpo=38086

   (76) 
https://gitlab.com/python-devs/importlib_metadata/blob/0.21/importlib_metadata/docs/changelog.rst

   (77) https://bugs.python.org/issue?@action=redirect&bpo=37251

   (78) https://bugs.python.org/issue?@action=redirect&bpo=38037

   (79) https://bugs.python.org/issue?@action=redirect&bpo=38066

   (80) https://bugs.python.org/issue?@action=redirect&bpo=38059

   (81) https://bugs.python.org/issue?@action=redirect&bpo=38049

   (82) https://bugs.python.org/issue?@action=redirect&bpo=37953

   (83) https://bugs.python.org/issue?@action=redirect&bpo=38026

   (84) https://bugs.python.org/issue?@action=redirect&bpo=35923

   (85) https://bugs.python.org/issue?@action=redirect&bpo=38010

   (86) https://bugs.python.org/issue?@action=redirect&bpo=38006

   (87) https://bugs.python.org/issue?@action=redirect&bpo=37995

   (88) https://bugs.python.org/issue?@action=redirect&bpo=34410

   (89) https://bugs.python.org/issue?@action=redirect&bpo=37140

   (90) https://bugs.python.org/issue?@action=redirect&bpo=37587

   (91) https://bugs.python.org/issue?@action=redirect&bpo=37834

   (92) https://bugs.python.org/issue?@action=redirect&bpo=10978

   (93) https://bugs.python.org/issue?@action=redirect&bpo=37972

   (94) https://bugs.python.org/issue?@action=redirect&bpo=37965

   (95) https://bugs.python.org/issue?@action=redirect&bpo=37964

   (96) https://bugs.python.org/issue?@action=redirect&bpo=37960

   (97) https://bugs.python.org/issue?@action=redirect&bpo=37961

   (98) https://bugs.python.org/issue?@action=redirect&bpo=37951

   (99) https://bugs.python.org/issue?@action=redirect&bpo=36205

   (100) https://bugs.python.org/issue?@action=redirect&bpo=37950

   (101) https://bugs.python.org/issue?@action=redirect&bpo=34679

   (102) https://bugs.python.org/issue?@action=redirect&bpo=36917

   (103) https://bugs.python.org/issue?@action=redirect&bpo=37798

   (104) https://bugs.python.org/issue?@action=redirect&bpo=26589

   (105) https://bugs.python.org/issue?@action=redirect&bpo=37915

   (106) https://bugs.python.org/issue?@action=redirect&bpo=32554

   (107) https://bugs.python.org/issue?@action=redirect&bpo=9938

   (108) https://bugs.python.org/issue?@action=redirect&bpo=37851

   (109) https://bugs.python.org/issue?@action=redirect&bpo=32793

   (110) https://bugs.python.org/issue?@action=redirect&bpo=37885

   (111) https://bugs.python.org/issue?@action=redirect&bpo=37868

   (112) https://bugs.python.org/issue?@action=redirect&bpo=37811

   (113) https://bugs.python.org/issue?@action=redirect&bpo=37863

   (114) https://bugs.python.org/issue?@action=redirect&bpo=21131

   (115) https://bugs.python.org/issue?@action=redirect&bpo=37798

   (116) https://bugs.python.org/issue?@action=redirect&bpo=37804

   (117) https://bugs.python.org/issue?@action=redirect&bpo=37819

   (118) https://bugs.python.org/issue?@action=redirect&bpo=14465

   (119) https://bugs.python.org/issue?@action=redirect&bpo=37810

   (120) https://bugs.python.org/issue?@action=redirect&bpo=37772

   (121) https://bugs.python.org/issue?@action=redirect&bpo=18578

   (122) https://bugs.python.org/issue?@action=redirect&bpo=37785

   (123) https://bugs.python.org/issue?@action=redirect&bpo=34488

   (124) https://bugs.python.org/issue?@action=redirect&bpo=37449

   (125) https://bugs.python.org/issue?@action=redirect&bpo=28292

   (126) https://bugs.python.org/issue?@action=redirect&bpo=18049

   (127) https://bugs.python.org/issue?@action=redirect&bpo=37742

   (128) https://bugs.python.org/issue?@action=redirect&bpo=37738

   (129) https://bugs.python.org/issue?@action=redirect&bpo=37723

   (130) https://bugs.python.org/issue?@action=redirect&bpo=35943

   (131) https://bugs.python.org/issue?@action=redirect&bpo=32178

   (132) https://bugs.python.org/issue?@action=redirect&bpo=37268

   (133) https://bugs.python.org/issue?@action=redirect&bpo=11953

   (134) https://bugs.python.org/issue?@action=redirect&bpo=37685

   (135) https://bugs.python.org/issue?@action=redirect&bpo=37697

   (136) 
https://gitlab.com/python-devs/importlib_metadata/-/milestones/20

   (137) https://bugs.python.org/issue?@action=redirect&bpo=37695

   (138) https://bugs.python.org/issue?@action=redirect&bpo=37689

   (139) https://bugs.python.org/issue?@action=redirect&bpo=29553

   (140) https://bugs.python.org/issue?@action=redirect&bpo=37691

   (141) https://bugs.python.org/issue?@action=redirect&bpo=37685

   (142) https://bugs.python.org/issue?@action=redirect&bpo=37354

   (143) https://bugs.python.org/issue?@action=redirect&bpo=37664

   (144) https://bugs.python.org/issue?@action=redirect&bpo=37663

   (145) https://bugs.python.org/issue?@action=redirect&bpo=37642

   (146) https://bugs.python.org/issue?@action=redirect&bpo=36161

   (147) https://bugs.python.org/issue?@action=redirect&bpo=36324

   (148) https://bugs.python.org/issue?@action=redirect&bpo=37555

   (149) https://bugs.python.org/issue?@action=redirect&bpo=29446

   (150) https://bugs.python.org/issue?@action=redirect&bpo=16970

   (151) https://bugs.python.org/issue?@action=redirect&bpo=34443

   (152) https://bugs.python.org/issue?@action=redirect&bpo=37491

   (153) https://bugs.python.org/issue?@action=redirect&bpo=37587

   (154) https://bugs.python.org/issue?@action=redirect&bpo=18378

   (155) https://bugs.python.org/issue?@action=redirect&bpo=37579

   (156) https://bugs.python.org/issue?@action=redirect&bpo=21478

   (157) https://bugs.python.org/issue?@action=redirect&bpo=37531

   (158) https://bugs.python.org/issue?@action=redirect&bpo=37482

   (159) https://bugs.python.org/issue?@action=redirect&bpo=36993

   (160) https://bugs.python.org/issue?@action=redirect&bpo=37502

   (161) https://bugs.python.org/issue?@action=redirect&bpo=37520

   (162) https://bugs.python.org/issue?@action=redirect&bpo=18374

   (163) https://bugs.python.org/issue?@action=redirect&bpo=37424

   (164) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (165) https://bugs.python.org/issue?@action=redirect&bpo=37481

   (166) https://bugs.python.org/issue?@action=redirect&bpo=37479

   (167) https://bugs.python.org/issue?@action=redirect&bpo=37440

   (168) https://bugs.python.org/issue?@action=redirect&bpo=37437

   (169) https://bugs.python.org/issue?@action=redirect&bpo=37428

   (170) https://bugs.python.org/issue?@action=redirect&bpo=37420

   (171) https://bugs.python.org/issue?@action=redirect&bpo=37412

   (172) https://peps.python.org/pep-0529/

   (173) https://bugs.python.org/issue?@action=redirect&bpo=37406

   (174) https://bugs.python.org/issue?@action=redirect&bpo=29412

   (175) https://bugs.python.org/issue?@action=redirect&bpo=36546

   (176) https://bugs.python.org/issue?@action=redirect&bpo=37394

   (177) https://bugs.python.org/issue?@action=redirect&bpo=37376

   (178) https://bugs.python.org/issue?@action=redirect&bpo=26967

   (179) https://bugs.python.org/issue?@action=redirect&bpo=37212

   (180) https://bugs.python.org/issue?@action=redirect&bpo=37372

   (181) https://bugs.python.org/issue?@action=redirect&bpo=37345

   (182) https://bugs.python.org/issue?@action=redirect&bpo=37358

   (183) https://bugs.python.org/issue?@action=redirect&bpo=37347

   (184) https://bugs.python.org/issue?@action=redirect&bpo=37163

   (185) https://bugs.python.org/issue?@action=redirect&bpo=37085

   (186) https://bugs.python.org/issue?@action=redirect&bpo=37328

   (187) https://bugs.python.org/issue?@action=redirect&bpo=37305

   (188) https://bugs.python.org/issue?@action=redirect&bpo=37320

   (189) https://bugs.python.org/issue?@action=redirect&bpo=37315

   (190) https://bugs.python.org/issue?@action=redirect&bpo=37312

   (191) https://bugs.python.org/issue?@action=redirect&bpo=33972

   (192) https://bugs.python.org/issue?@action=redirect&bpo=37280

   (193) https://bugs.python.org/issue?@action=redirect&bpo=37279

   (194) https://bugs.python.org/issue?@action=redirect&bpo=19865

   (195) https://bugs.python.org/issue?@action=redirect&bpo=37266

   (196) https://bugs.python.org/issue?@action=redirect&bpo=37210

   (197) https://bugs.python.org/issue?@action=redirect&bpo=21872

   (198) https://bugs.python.org/issue?@action=redirect&bpo=35922

   (199) https://bugs.python.org/issue?@action=redirect&bpo=35766

   (200) https://bugs.python.org/issue?@action=redirect&bpo=36607

   (201) https://bugs.python.org/issue?@action=redirect&bpo=18748

   (202) https://bugs.python.org/issue?@action=redirect&bpo=36402

   (203) https://bugs.python.org/issue?@action=redirect&bpo=37206

   (204) https://bugs.python.org/issue?@action=redirect&bpo=37111

   (205) https://bugs.python.org/issue?@action=redirect&bpo=12144

   (206) https://bugs.python.org/issue?@action=redirect&bpo=34886

   (207) https://bugs.python.org/issue?@action=redirect&bpo=37173

   (208) https://bugs.python.org/issue?@action=redirect&bpo=37178

   (209) https://bugs.python.org/issue?@action=redirect&bpo=37178

   (210) https://bugs.python.org/issue?@action=redirect&bpo=37165

   (211) https://bugs.python.org/issue?@action=redirect&bpo=34767

   (212) https://bugs.python.org/issue?@action=redirect&bpo=37158

   (213) https://bugs.python.org/issue?@action=redirect&bpo=34282

   (214) https://bugs.python.org/issue?@action=redirect&bpo=37150

   (215) https://bugs.python.org/issue?@action=redirect&bpo=28724

   (216) https://bugs.python.org/issue?@action=redirect&bpo=35621

   (217) https://bugs.python.org/issue?@action=redirect&bpo=36520

   (218) https://bugs.python.org/issue?@action=redirect&bpo=30835

   (219) https://bugs.python.org/issue?@action=redirect&bpo=31163

   (220) https://bugs.python.org/issue?@action=redirect&bpo=25068

   (221) https://bugs.python.org/issue?@action=redirect&bpo=26185

   (222) https://bugs.python.org/issue?@action=redirect&bpo=21315

   (223) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (224) https://bugs.python.org/issue?@action=redirect&bpo=35805

   (225) https://bugs.python.org/issue?@action=redirect&bpo=36871

   (226) https://bugs.python.org/issue?@action=redirect&bpo=35070

   (227) https://bugs.python.org/issue?@action=redirect&bpo=31783

   (228) https://bugs.python.org/issue?@action=redirect&bpo=36582

   (229) https://bugs.python.org/issue?@action=redirect&bpo=32424

   (230) https://bugs.python.org/issue?@action=redirect&bpo=36564

   (231) https://bugs.python.org/issue?@action=redirect&bpo=36543

   (232) https://bugs.python.org/issue?@action=redirect&bpo=36409

   (233) https://bugs.python.org/issue?@action=redirect&bpo=36302

   (234) https://bugs.python.org/issue?@action=redirect&bpo=36250

   (235) https://bugs.python.org/issue?@action=redirect&bpo=36046

   (236) https://bugs.python.org/issue?@action=redirect&bpo=32627

   (237) https://bugs.python.org/issue?@action=redirect&bpo=35800

   (238) https://bugs.python.org/issue?@action=redirect&bpo=35168

   (239) https://bugs.python.org/issue?@action=redirect&bpo=8538

   (240) https://bugs.python.org/issue?@action=redirect&bpo=20504

   (241) https://bugs.python.org/issue?@action=redirect&bpo=25988

   (242) https://bugs.python.org/issue?@action=redirect&bpo=11122

   (243) https://bugs.python.org/issue?@action=redirect&bpo=34775

   (244) https://bugs.python.org/issue?@action=redirect&bpo=34749

   (245) https://bugs.python.org/issue?@action=redirect&bpo=34519

   (246) https://bugs.python.org/issue?@action=redirect&bpo=28009

   (247) https://bugs.python.org/issue?@action=redirect&bpo=30618

   (248) https://bugs.python.org/issue?@action=redirect&bpo=32498

   (249) https://bugs.python.org/issue?@action=redirect&bpo=33348

   (250) https://bugs.python.org/issue?@action=redirect&bpo=32689

   (251) https://bugs.python.org/issue?@action=redirect&bpo=32820

   (252) https://bugs.python.org/issue?@action=redirect&bpo=27657

   (253) https://bugs.python.org/issue?@action=redirect&bpo=4963


File: python.info,  Node: Documentation<40>,  Next: Tests<42>,  Prev: Library<45>,  Up: Python 3 9 0 alpha 1

1.23.46.4 Documentation
.......................

   - bpo-21767(1): Explicitly mention abc support in
     functools.singledispatch

   - bpo-38816(2): Provides more details about the interaction between
     ‘fork()’ and CPython's runtime, focusing just on the C-API. This
     includes cautions about where ‘fork()’ should and shouldn't be
     called.

   - bpo-38351(3): Modernize *note email: 32. examples from %-formatting
     to f-strings.

   - bpo-38778(4): Document the fact that *note RuntimeError: 17a. is
     raised if *note os.fork(): 17c. is called in a subinterpreter.

   - bpo-38592(5): Add Brazilian Portuguese to the language switcher at
     Python Documentation website.

   - bpo-38294(6): Add list of no-longer-escaped chars to re.escape
     documentation

   - bpo-38053(7): Modernized the plistlib documentation

   - bpo-26868(8): Fix example usage of *note PyModule_AddObject(): 33f.
     to properly handle errors.

   - bpo-36797(9): Fix a dead link in the distutils API Reference.

   - bpo-37977(10): Warn more strongly and clearly about pickle
     insecurity

   - bpo-37979(11): Added a link to dateutil.parser.isoparse in the
     datetime.fromisoformat documentation.  Patch by Paul Ganssle

   - bpo-12707(12): Deprecate info(), geturl(), getcode() methods in
     favor of the headers, url, and status properties, respectively, for
     HTTPResponse and addinfourl.  Also deprecate the code attribute of
     addinfourl in favor of the status attribute.  Patch by Ashwin
     Ramaswami

   - bpo-37937(13): Mention ‘frame.f_trace’ in *note sys.settrace():
     14a9. docs.

   - bpo-37878(14): Make *note PyThreadState_DeleteCurrent(): 193e.
     Internal.

   - bpo-37759(15): Beginning edits to Whatsnew 3.8

   - bpo-37726(16): Stop recommending getopt in the tutorial for command
     line argument parsing and promote argparse.

   - bpo-32910(17): Remove implementation-specific behaviour of how
     venv's Deactivate works.

   - bpo-37256(18): Fix wording of arguments for ‘Request’ in *note
     urllib.request: f4.

   - bpo-37284(19): Add a brief note to indicate that any new
     ‘sys.implementation’ required attributes must go through the PEP
     process.

   - bpo-30088(20): Documented that *note mailbox.Maildir: 3f5.
     constructor doesn't attempt to verify the maildir folder layout
     correctness.  Patch by Sviatoslav Sydorenko.

   - bpo-37521(21): Fix ‘importlib’ examples to insert any newly created
     modules via importlib.util.module_from_spec() immediately into
     sys.modules instead of after calling loader.exec_module().

     Thanks to Benjamin Mintz for finding the bug.

   - bpo-37456(22): Slash ('/') is now part of syntax.

   - bpo-37487(23): Fix PyList_GetItem index description to include 0.

   - bpo-37149(24): Replace the dead link to the Tkinter 8.5 reference
     by John Shipman, New Mexico Tech, with a link to the archive.org
     copy.

   - bpo-37478(25): Added possible exceptions to the description of
     os.chdir().

   - bpo-34903(26): Documented that in *note
     datetime.datetime.strptime(): 156e, the leading zero in some
     two-digit formats is optional.  Patch by Mike Gleen.

   - bpo-36260(27): Add decompression pitfalls to zipfile module
     documentation.

   - bpo-37004(28): In the documentation for difflib, a note was added
     explicitly warning that the results of SequenceMatcher's ratio
     method may depend on the order of the input strings.

   - bpo-36960(29): Restructured the *note datetime: 28. docs in the
     interest of making them more user-friendly and improving
     readability.  Patch by Brad Solomon.

   - bpo-36487(30): Make C-API docs clear about what the "main"
     interpreter is.

   - bpo-23460(31): The documentation for decimal string formatting
     using the ‘:g’ specifier has been updated to reflect the correct
     exponential notation cutoff point.  Original patch contributed by
     Tuomas Suutari.

   - bpo-35803(32): Document and test that ‘tempfile’ functions may
     accept a *note path-like object: 280. for the ‘dir’ argument.
     Patch by Anthony Sottile.

   - bpo-33944(33): Added a note about the intended use of code in .pth
     files.

   - bpo-34293(34): Fix the Doc/Makefile regarding PAPER environment
     variable and PDF builds

   - bpo-25237(35): Add documentation for tkinter modules

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21767

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38816

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38351

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38778

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38592

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38294

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38053

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26868

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36797

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37977

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37979

   (12) https://bugs.python.org/issue?@action=redirect&bpo=12707

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37937

   (14) https://bugs.python.org/issue?@action=redirect&bpo=37878

   (15) https://bugs.python.org/issue?@action=redirect&bpo=37759

   (16) https://bugs.python.org/issue?@action=redirect&bpo=37726

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32910

   (18) https://bugs.python.org/issue?@action=redirect&bpo=37256

   (19) https://bugs.python.org/issue?@action=redirect&bpo=37284

   (20) https://bugs.python.org/issue?@action=redirect&bpo=30088

   (21) https://bugs.python.org/issue?@action=redirect&bpo=37521

   (22) https://bugs.python.org/issue?@action=redirect&bpo=37456

   (23) https://bugs.python.org/issue?@action=redirect&bpo=37487

   (24) https://bugs.python.org/issue?@action=redirect&bpo=37149

   (25) https://bugs.python.org/issue?@action=redirect&bpo=37478

   (26) https://bugs.python.org/issue?@action=redirect&bpo=34903

   (27) https://bugs.python.org/issue?@action=redirect&bpo=36260

   (28) https://bugs.python.org/issue?@action=redirect&bpo=37004

   (29) https://bugs.python.org/issue?@action=redirect&bpo=36960

   (30) https://bugs.python.org/issue?@action=redirect&bpo=36487

   (31) https://bugs.python.org/issue?@action=redirect&bpo=23460

   (32) https://bugs.python.org/issue?@action=redirect&bpo=35803

   (33) https://bugs.python.org/issue?@action=redirect&bpo=33944

   (34) https://bugs.python.org/issue?@action=redirect&bpo=34293

   (35) https://bugs.python.org/issue?@action=redirect&bpo=25237


File: python.info,  Node: Tests<42>,  Next: Build<45>,  Prev: Documentation<40>,  Up: Python 3 9 0 alpha 1

1.23.46.5 Tests
...............

   - bpo-38614(1): Fix test_communicate() of
     test_asyncio.test_subprocess: use ‘support.LONG_TIMEOUT’ (5
     minutes), instead of just 1 minute.

   - bpo-38614(2): Add timeout constants to *note test.support: cd.:
     *note LOOPBACK_TIMEOUT: 191f, *note INTERNET_TIMEOUT: 1920, *note
     SHORT_TIMEOUT: 1819. and *note LONG_TIMEOUT: 1921.

   - bpo-38502(3): test.regrtest now uses process groups in the
     multiprocessing mode (-jN command line option) if process groups
     are available: if *note os.setsid(): 1940. and *note os.killpg():
     1941. functions are available.

   - bpo-35998(4): Fix a race condition in
     test_asyncio.test_start_tls_server_1().  Previously, there was a
     race condition between the test main() function which replaces the
     protocol and the test ServerProto protocol which sends ANSWER once
     it gets HELLO. Now, only the test main() function is responsible to
     send data, ServerProto no longer sends data.

   - bpo-38470(5): Fix ‘test_compileall.test_compile_dir_maxlevels()’ on
     Windows without long path support: only create 3 subdirectories
     instead of between 20 and 100 subdirectories.

   - bpo-37531(6): On timeout, regrtest no longer attempts to call
     ‘popen.communicate()’ again: it can hang until all child processes
     using stdout and stderr pipes completes.  Kill the worker process
     and ignores its output.  Change also the faulthandler timeout of
     the main process from 1 minute to 5 minutes, for Python slowest
     buildbots.

   - bpo-38239(7): Fix test_gdb for Link Time Optimization (LTO) builds.

   - bpo-38275(8): test_ssl now handles disabled TLS/SSL versions
     better.  OpenSSL's crypto policy and run-time settings are
     recognized and tests for disabled versions are skipped.  Tests also
     accept more TLS minimum_versions for platforms that override
     OpenSSL's default with strict settings.

   - bpo-38271(9): The private keys for test_ssl were encrypted with
     3DES in traditional PKCS#5 format.  3DES and the digest algorithm
     of PKCS#5 are blocked by some strict crypto policies.  Use PKCS#8
     format with AES256 encryption instead.

   - bpo-38270(10): test.support now has a helper function to check for
     availability of a hash digest function.  Several tests are
     refactored avoid MD5 and use SHA256 instead.  Other tests are
     marked to use MD5 and skipped when MD5 is disabled.

   - bpo-37123(11): Multiprocessing test test_mymanager() now also
     expects -SIGTERM, not only exitcode 0.
     BaseManager._finalize_manager() sends SIGTERM to the manager
     process if it takes longer than 1 second to stop, which happens on
     slow buildbots.

   - bpo-38212(12): Multiprocessing tests: increase
     test_queue_feeder_donot_stop_onexc() timeout from 1 to 60 seconds.

   - bpo-38117(13): Test with OpenSSL 1.1.1d

   - bpo-38018(14): Increase code coverage for
     multiprocessing.shared_memory.

   - bpo-37805(15): Add tests for json.dump(..., skipkeys=True).  Patch
     by Donghee Na.

   - bpo-37531(16): Enhance regrtest multiprocess timeout: write a
     message when killing a worker process, catch popen.kill() and
     popen.wait() exceptions, put a timeout on the second call to
     popen.communicate().

   - bpo-37876(17): Add tests for ROT-13 codec.

   - bpo-36833(18): Added tests for ‘PyDateTime_XXX_GET_XXX()’ macros of
     the C API of the *note datetime: 28. module.  Patch by Joannah
     Nanjekye.

   - bpo-37558(19): Fix
     test_shared_memory_cleaned_after_process_termination name handling

   - bpo-37526(20): Add ‘test.support.catch_threading_exception()’:
     context manager catching *note threading.Thread: 91a. exception
     using *note threading.excepthook(): 816.

   - bpo-37421(21): test_concurrent_futures now explicitly stops the
     ForkServer instance if it's running.

   - bpo-37421(22): multiprocessing tests now stop the ForkServer
     instance if it's running: close the "alive" file descriptor to ask
     the server to stop and then remove its UNIX address.

   - bpo-37421(23): test_distutils.test_build_ext() is now able to
     remove the temporary directory on Windows: don't import the newly
     built C extension ("xx") in the current process, but test it in a
     separated process.

   - bpo-37421(24): test_concurrent_futures now cleans up
     multiprocessing to remove immediately temporary directories created
     by multiprocessing.util.get_temp_dir().

   - bpo-37421(25): test_winconsoleio doesn't leak a temporary file
     anymore: use tempfile.TemporaryFile() to remove it when the test
     completes.

   - bpo-37421(26): multiprocessing tests now explicitly call
     ‘_run_finalizers()’ to immediately remove temporary directories
     created by tests.

   - bpo-37421(27): urllib.request tests now call *note urlcleanup():
     1942. to remove temporary files created by ‘urlretrieve()’ tests
     and to clear the ‘_opener’ global variable set by ‘urlopen()’ and
     functions calling indirectly ‘urlopen()’.

   - bpo-37472(28): Remove ‘Lib/test/outstanding_bugs.py’.

   - bpo-37199(29): Fix test failures when IPv6 is unavailable or
     disabled.

   - bpo-19696(30): Replace deprecated method "random.choose" with
     "random.choice" in "test_pkg_import.py".

   - bpo-37335(31): Remove no longer necessary code from c locale
     coercion tests

   - bpo-37421(32): Fix test_shutil to no longer leak temporary files.

   - bpo-37411(33): Fix test_wsgiref.testEnviron() to no longer depend
     on the environment variables (don't fail if "X" variable is set).

   - bpo-37400(34): Fix test_os.test_chown(): use os.getgroups() rather
     than grp.getgrall() to get groups.  Rename also the test to
     test_chown_gid().

   - bpo-37359(35): Add -cleanup option to python3 -m test to remove
     ‘test_python_*’ directories of previous failed jobs.  Add "make
     cleantest" to run ‘python3 -m test --cleanup’.

   - bpo-37362(36): test_gdb no longer fails if it gets an "unexpected"
     message on stderr: it now ignores stderr.  The purpose of test_gdb
     is to test that python-gdb.py commands work as expected, not to
     test gdb.

   - bpo-35998(37): Avoid TimeoutError in test_asyncio:
     test_start_tls_server_1()

   - bpo-37278(38): Fix test_asyncio ProactorLoopCtrlC: join the thread
     to prevent leaking a running thread and leaking a reference.

   - bpo-37261(39): Fix *note test.support.catch_unraisable_exception():
     1943.: its __exit__() method now ignores unraisable exception
     raised when clearing its ‘unraisable’ attribute.

   - bpo-37069(40): regrtest now uses *note sys.unraisablehook(): 1d8.
     to mark a test as "environment altered" (ENV_CHANGED) if it emits
     an "unraisable exception".  Moreover, regrtest logs a warning in
     this case.

     Use ‘python3 -m test --fail-env-changed’ to catch unraisable
     exceptions in tests.

   - bpo-37252(41): Fix assertions in ‘test_close’ and
     ‘test_events_mask_overflow’ devpoll tests.

   - bpo-37169(42): Rewrite ‘_PyObject_IsFreed()’ unit tests.

   - bpo-37153(43): ‘test_venv.test_multiprocessing()’ now explicitly
     calls ‘pool.terminate()’ to wait until the pool completes.

   - bpo-34001(44): Make test_ssl pass with LibreSSL. LibreSSL handles
     minimum and maximum TLS version differently than OpenSSL.

   - bpo-36919(45): Make ‘test_source_encoding.test_issue2301’
     implementation independent.  The test will work now for both
     CPython and IronPython.

   - bpo-30202(46): Update ‘test.test_importlib.test_abc’ to test
     ‘find_spec()’.

   - bpo-28009(47): Modify the test_uuid logic to test when a program is
     available AND can be used to obtain a MACADDR as basis for an UUID.
     Patch by M. Felt

   - bpo-34596(48): Fallback to a default reason when *note
     unittest.skip(): 1944. is uncalled.  Patch by Naitree Zhu.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38614

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38614

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38502

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35998

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38470

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37531

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38239

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38275

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38271

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38270

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37123

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38212

   (13) https://bugs.python.org/issue?@action=redirect&bpo=38117

   (14) https://bugs.python.org/issue?@action=redirect&bpo=38018

   (15) https://bugs.python.org/issue?@action=redirect&bpo=37805

   (16) https://bugs.python.org/issue?@action=redirect&bpo=37531

   (17) https://bugs.python.org/issue?@action=redirect&bpo=37876

   (18) https://bugs.python.org/issue?@action=redirect&bpo=36833

   (19) https://bugs.python.org/issue?@action=redirect&bpo=37558

   (20) https://bugs.python.org/issue?@action=redirect&bpo=37526

   (21) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (22) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (23) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (24) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (25) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (26) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (27) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (28) https://bugs.python.org/issue?@action=redirect&bpo=37472

   (29) https://bugs.python.org/issue?@action=redirect&bpo=37199

   (30) https://bugs.python.org/issue?@action=redirect&bpo=19696

   (31) https://bugs.python.org/issue?@action=redirect&bpo=37335

   (32) https://bugs.python.org/issue?@action=redirect&bpo=37421

   (33) https://bugs.python.org/issue?@action=redirect&bpo=37411

   (34) https://bugs.python.org/issue?@action=redirect&bpo=37400

   (35) https://bugs.python.org/issue?@action=redirect&bpo=37359

   (36) https://bugs.python.org/issue?@action=redirect&bpo=37362

   (37) https://bugs.python.org/issue?@action=redirect&bpo=35998

   (38) https://bugs.python.org/issue?@action=redirect&bpo=37278

   (39) https://bugs.python.org/issue?@action=redirect&bpo=37261

   (40) https://bugs.python.org/issue?@action=redirect&bpo=37069

   (41) https://bugs.python.org/issue?@action=redirect&bpo=37252

   (42) https://bugs.python.org/issue?@action=redirect&bpo=37169

   (43) https://bugs.python.org/issue?@action=redirect&bpo=37153

   (44) https://bugs.python.org/issue?@action=redirect&bpo=34001

   (45) https://bugs.python.org/issue?@action=redirect&bpo=36919

   (46) https://bugs.python.org/issue?@action=redirect&bpo=30202

   (47) https://bugs.python.org/issue?@action=redirect&bpo=28009

   (48) https://bugs.python.org/issue?@action=redirect&bpo=34596


File: python.info,  Node: Build<45>,  Next: Windows<40>,  Prev: Tests<42>,  Up: Python 3 9 0 alpha 1

1.23.46.6 Build
...............

   - bpo-38809(1): On Windows, build scripts will now recognize and use
     python.exe from an active virtual env.

   - bpo-38684(2): Fix _hashlib build when Blake2 is disabled, but
     OpenSSL supports it.

   - bpo-38468(3): Misc/python-config.in now uses ‘getvar()’ for all
     still existing ‘sysconfig.get_config_var()’ calls.  Patch by
     Joannah Nanjekye.

   - bpo-37415(4): Fix stdatomic.h header check for ICC compiler: the
     ICC implementation lacks atomic_uintptr_t type which is needed by
     Python.

   - bpo-38301(5): In Solaris family, we must be sure to use
     ‘-D_REENTRANT’.  Patch by Jesús Cea Avión.

   - bpo-36002(6): Locate ‘llvm-profdata’ and ‘llvm-ar’ binaries using
     ‘AC_PATH_TOOL’ rather than ‘AC_PATH_TARGET_TOOL’.

   - bpo-37936(7): The ‘.gitignore’ file systematically keeps "rooted",
     with a non-trailing slash, all the rules that are meant to apply to
     files in a specific place in the repo.  Previously, when the
     intended file to ignore happened to be at the root of the repo,
     we'd most often accidentally also ignore files and directories with
     the same name anywhere in the tree.

   - bpo-37760(8): The ‘Tools/unicode/makeunicodedata.py’ script, which
     is used for converting information from the Unicode Character
     Database into generated code and data used by the methods of *note
     str: 418. and by the *note unicodedata: ee. module, now handles
     each character's data as a ‘dataclass’ with named attributes,
     rather than a length-18 list of different fields.

   - bpo-37936(9): The ‘.gitignore’ file no longer applies to any files
     that are in fact tracked in the Git repository.  Patch by Greg
     Price.

   - bpo-37725(10): Change "clean" makefile target to also clean the
     program guided optimization (PGO) data.  Previously you would have
     to use "make clean" and "make profile-removal", or "make clobber".

   - bpo-37707(11): Mark some individual tests to skip when -pgo is
     used.  The tests marked increase the PGO task time significantly
     and likely don't help improve optimization of the final executable.

   - bpo-36044(12): Reduce the number of unit tests run for the PGO
     generation task.  This speeds up the task by a factor of about 15x.
     Running the full unit test suite is slow.  This change may result
     in a slightly less optimized build since not as many code branches
     will be executed.  If you are willing to wait for the much slower
     build, the old behavior can be restored using './configure [..]
     PROFILE_TASK="-m test -pgo-extended"'.  We make no guarantees as to
     which PGO task set produces a faster build.  Users who care should
     run their own relevant benchmarks as results can depend on the
     environment, workload, and compiler tool chain.

   - bpo-37468(13): ‘make install’ no longer installs ‘wininst-*.exe’
     files used by distutils bdist_wininst: bdist_wininst only works on
     Windows.

   - bpo-37189(14): Many ‘PyRun_XXX()’ functions like *note
     PyRun_String(): 1946. were no longer exported in ‘libpython38.dll’
     by mistake.  Export them again to fix the ABI compatibility.

   - bpo-25361(15): Enables use of SSE2 instructions in Windows 32-bit
     build.

   - bpo-36210(16): Update optional extension module detection for AIX.
     ossaudiodev and spwd are not applicable for AIX, and are no longer
     reported as missing.  3rd-party packaging of ncurses (with ASIS
     support) conflicts with officially supported AIX curses library, so
     configure AIX to use libcurses.a.  However, skip trying to build
     _curses_panel.

     patch by M Felt

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38809

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38684

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38468

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37415

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38301

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36002

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37936

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37760

   (9) https://bugs.python.org/issue?@action=redirect&bpo=37936

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37725

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37707

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36044

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37468

   (14) https://bugs.python.org/issue?@action=redirect&bpo=37189

   (15) https://bugs.python.org/issue?@action=redirect&bpo=25361

   (16) https://bugs.python.org/issue?@action=redirect&bpo=36210


File: python.info,  Node: Windows<40>,  Next: macOS<34>,  Prev: Build<45>,  Up: Python 3 9 0 alpha 1

1.23.46.7 Windows
.................

   - bpo-38589(1): Fixes HTML Help shortcut when Windows is not
     installed to C drive

   - bpo-38453(2): Ensure ntpath.realpath() correctly resolves relative
     paths.

   - bpo-38519(3): Restores the internal C headers that were missing
     from the nuget.org and Microsoft Store packages.

   - bpo-38492(4): Remove ‘pythonw.exe’ dependency on the Microsoft C++
     runtime.

   - bpo-38344(5): Fix error message in activate.bat

   - bpo-38359(6): Ensures ‘pyw.exe’ launcher reads correct registry
     key.

   - bpo-38355(7): Fixes ‘ntpath.realpath’ failing on ‘sys.executable’.

   - bpo-38117(8): Update bundled OpenSSL to 1.1.1d

   - bpo-38092(9): Reduce overhead when using multiprocessing in a
     Windows virtual environment.

   - bpo-38133(10): Allow py.exe launcher to locate installations from
     the Microsoft Store and improve display of active virtual
     environments.

   - bpo-38114(11): The ‘pip.ini’ is no longer included in the Nuget
     package.

   - bpo-32592(12): Set Windows 8 as the minimum required version for
     API support

   - bpo-36634(13): *note os.cpu_count(): 1a7. now returns active
     processors rather than maximum processors.

   - bpo-36634(14): venv activate.bat now works when the existing
     variables contain double quote characters.

   - bpo-38081(15): Prevent error calling *note os.path.realpath(): 206.
     on ‘'NUL'’.

   - bpo-38087(16): Fix case sensitivity in test_pathlib and
     test_ntpath.

   - bpo-38088(17): Fixes distutils not finding vcruntime140.dll with
     only the v142 toolset installed.

   - bpo-37283(18): Ensure command-line and unattend.xml setting
     override previously detected states in Windows installer.

   - bpo-38030(19): Fixes *note os.stat(): 46d. failing for block
     devices on Windows

   - bpo-38020(20): Fixes potential crash when calling *note
     os.readlink(): 8ee. (or indirectly through *note realpath(): 206.)
     on a file that is not a supported link.

   - bpo-37705(21): Improve the implementation of ‘winerror_to_errno()’.

   - bpo-37549(22): *note os.dup(): 1948. no longer fails for standard
     streams on Windows 7.

   - bpo-1311(23): The ‘nul’ file on Windows now returns True from *note
     exists(): 9dc. and a valid result from *note os.stat(): 46d. with
     ‘S_IFCHR’ set.

   - bpo-9949(24): Enable support for following symlinks in
     ‘os.realpath()’.

   - bpo-37834(25): Treat all name surrogate reparse points on Windows
     in *note os.lstat(): 46e. and other reparse points as regular files
     in *note os.stat(): 46d.

   - bpo-36266(26): Add the module name in the formatted error message
     when DLL load fail happens during module import in
     ‘_PyImport_FindSharedFuncptrWindows()’.  Patch by Srinivas
     Nyayapati.

   - bpo-25172(27): Trying to import the ‘crypt’ module on Windows will
     result in an *note ImportError: 3f2. with a message explaining that
     the module isn't supported on Windows.  On other platforms, if the
     underlying ‘_crypt’ module is not available, the ImportError will
     include a message explaining the problem.

   - bpo-37778(28): Fixes the icons used for file associations to the
     Microsoft Store package.

   - bpo-37734(29): Fix use of registry values to launch Python from
     Microsoft Store app.

   - bpo-37702(30): Fix memory leak on Windows in creating an SSLContext
     object or running ‘urllib.request.urlopen('https://...')’.

   - bpo-37672(31): Switch Windows Store package's pip to use bundled
     ‘pip.ini’ instead of ‘PIP_USER’ variable.

   - bpo-10945(32): Officially drop support for creating bdist_wininst
     installers on non-Windows systems.

   - bpo-37445(33): Include the ‘FORMAT_MESSAGE_IGNORE_INSERTS’ flag in
     ‘FormatMessageW()’ calls.

   - bpo-37369(34): Fixes path for *note sys.executable: 392. when
     running from the Microsoft Store.

   - bpo-37380(35): Don't collect unfinished processes with
     ‘subprocess._active’ on Windows to cleanup later.  Patch by Ruslan
     Kuprieiev.

   - bpo-37351(36): Removes libpython38.a from standard Windows
     distribution.

   - bpo-35360(37): Update Windows builds to use SQLite 3.28.0.

   - bpo-37267(38): On Windows, *note os.dup(): 1948. no longer creates
     an inheritable fd when handling a character file.

   - bpo-36779(39): Ensure ‘time.tzname’ is correct on Windows when the
     active code page is set to CP_UTF7 or CP_UTF8.

   - bpo-32587(40): Make *note winreg.REG_MULTI_SZ: 1949. support
     zero-length strings.

   - bpo-28269(41): Replace use of ‘strcasecmp()’ for the system
     function ‘_stricmp()’.  Patch by Minmin Gong.

   - bpo-36590(42): Add native Bluetooth RFCOMM support to socket
     module.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38589

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38453

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38519

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38492

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38344

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38359

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38355

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38117

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38092

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38133

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38114

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32592

   (13) https://bugs.python.org/issue?@action=redirect&bpo=36634

   (14) https://bugs.python.org/issue?@action=redirect&bpo=36634

   (15) https://bugs.python.org/issue?@action=redirect&bpo=38081

   (16) https://bugs.python.org/issue?@action=redirect&bpo=38087

   (17) https://bugs.python.org/issue?@action=redirect&bpo=38088

   (18) https://bugs.python.org/issue?@action=redirect&bpo=37283

   (19) https://bugs.python.org/issue?@action=redirect&bpo=38030

   (20) https://bugs.python.org/issue?@action=redirect&bpo=38020

   (21) https://bugs.python.org/issue?@action=redirect&bpo=37705

   (22) https://bugs.python.org/issue?@action=redirect&bpo=37549

   (23) https://bugs.python.org/issue?@action=redirect&bpo=1311

   (24) https://bugs.python.org/issue?@action=redirect&bpo=9949

   (25) https://bugs.python.org/issue?@action=redirect&bpo=37834

   (26) https://bugs.python.org/issue?@action=redirect&bpo=36266

   (27) https://bugs.python.org/issue?@action=redirect&bpo=25172

   (28) https://bugs.python.org/issue?@action=redirect&bpo=37778

   (29) https://bugs.python.org/issue?@action=redirect&bpo=37734

   (30) https://bugs.python.org/issue?@action=redirect&bpo=37702

   (31) https://bugs.python.org/issue?@action=redirect&bpo=37672

   (32) https://bugs.python.org/issue?@action=redirect&bpo=10945

   (33) https://bugs.python.org/issue?@action=redirect&bpo=37445

   (34) https://bugs.python.org/issue?@action=redirect&bpo=37369

   (35) https://bugs.python.org/issue?@action=redirect&bpo=37380

   (36) https://bugs.python.org/issue?@action=redirect&bpo=37351

   (37) https://bugs.python.org/issue?@action=redirect&bpo=35360

   (38) https://bugs.python.org/issue?@action=redirect&bpo=37267

   (39) https://bugs.python.org/issue?@action=redirect&bpo=36779

   (40) https://bugs.python.org/issue?@action=redirect&bpo=32587

   (41) https://bugs.python.org/issue?@action=redirect&bpo=28269

   (42) https://bugs.python.org/issue?@action=redirect&bpo=36590


File: python.info,  Node: macOS<34>,  Next: IDLE<32>,  Prev: Windows<40>,  Up: Python 3 9 0 alpha 1

1.23.46.8 macOS
...............

   - bpo-38117(1): Updated OpenSSL to 1.1.1d in macOS installer.

   - bpo-38089(2): Move Azure Pipelines to latest VM versions and make
     macOS tests optional

   - bpo-18049(3): Increase the default stack size of threads from 5MB
     to 16MB on macOS, to match the stack size of the main thread.  This
     avoids crashes on deep recursion in threads.

   - bpo-34602(4): Avoid test suite failures on macOS by no longer
     calling resource.setrlimit to increase the process stack size limit
     at runtime.  The runtime change is no longer needed since the
     interpreter is being built with a larger default stack size.

   - bpo-35360(5): Update macOS installer to use SQLite 3.28.0.

   - bpo-34631(6): Updated OpenSSL to 1.1.1c in macOS installer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38117

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38089

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18049

   (4) https://bugs.python.org/issue?@action=redirect&bpo=34602

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35360

   (6) https://bugs.python.org/issue?@action=redirect&bpo=34631


File: python.info,  Node: IDLE<32>,  Next: Tools/Demos<20>,  Prev: macOS<34>,  Up: Python 3 9 0 alpha 1

1.23.46.9 IDLE
..............

   - bpo-26353(1): Stop adding newline when saving an IDLE shell window.

   - bpo-4630(2): Add an option to toggle IDLE's cursor blink for shell,
     editor, and output windows.  See Settings, General, Window
     Preferences, Cursor Blink.  Patch by Zackery Spytz.

   - bpo-38598(3): Do not try to compile IDLE shell or output windows

   - bpo-36698(4): IDLE no longer fails when write non-encodable
     characters to stderr.  It now escapes them with a backslash, as the
     regular Python interpreter.  Added the ‘errors’ field to the
     standard streams.

   - bpo-35379(5): When exiting IDLE, catch any AttributeError.  One
     happens when EditorWindow.close is called twice.  Printing a
     traceback, when IDLE is run from a terminal, is useless and
     annoying.

   - bpo-38183(6): To avoid problems, test_idle ignores the user config
     directory.  It no longer tries to create or access .idlerc or any
     files within.  Users must run IDLE to discover problems with saving
     settings.

   - bpo-38077(7): IDLE no longer adds 'argv' to the user namespace when
     initializing it.  This bug only affected 3.7.4 and 3.8.0b2 to
     3.8.0b4.

   - bpo-38041(8): Shell restart lines now fill the window width, always
     start with '=', and avoid wrapping unnecessarily.  The line will
     still wrap if the included file name is long relative to the width.

   - bpo-35771(9): To avoid occasional spurious test_idle failures on
     slower machines, increase the ‘hover_delay’ in test_tooltip.

   - bpo-37824(10): Properly handle user input warnings in IDLE shell.
     Cease turning SyntaxWarnings into SyntaxErrors.

   - bpo-37929(11): IDLE Settings dialog now closes properly when there
     is no shell window.

   - bpo-37902(12): Add mousewheel scrolling for IDLE module, path, and
     stack browsers.  Patch by George Zhang.

   - bpo-37849(13): Fixed completions list appearing too high or low
     when shown above the current line.

   - bpo-36419(14): Refactor IDLE autocomplete and improve testing.

   - bpo-37748(15): Reorder the Run menu.  Put the most common choice,
     Run Module, at the top.

   - bpo-37692(16): Improve highlight config sample with example shell
     interaction and better labels for shell elements.

   - bpo-37628(17): Settings dialog no longer expands with font size.

   - bpo-37627(18): Initialize the Customize Run dialog with the command
     line arguments most recently entered before.  The user can
     optionally edit before submitting them.

   - bpo-33610(19): Fix code context not showing the correct context
     when first toggled on.

   - bpo-37530(20): Optimize code context to reduce unneeded background
     activity.  Font and highlight changes now occur along with text
     changes instead of after a random delay.

   - bpo-27452(21): Cleanup ‘config.py’ by inlining ‘RemoveFile’ and
     simplifying the handling of ‘file’ in ‘CreateConfigHandlers’.

   - bpo-37325(22): Fix tab focus traversal order for help source and
     custom run dialogs.

   - bpo-37321(23): Both subprocess connection error messages now refer
     to the 'Startup failure' section of the IDLE doc.

   - bpo-17535(24): Add optional line numbers for IDLE editor windows.
     Windows open without line numbers unless set otherwise in the
     General tab of the configuration dialog.

   - bpo-26806(25): To compensate for stack frames added by IDLE and
     avoid possible problems with low recursion limits, add 30 to limits
     in the user code execution process.  Subtract 30 when reporting
     recursion limits to make this addition mostly transparent.

   - bpo-37177(26): Properly 'attach' search dialogs to their main
     window so that they behave like other dialogs and do not get hidden
     behind their main window.

   - bpo-37039(27): Adjust "Zoom Height" to individual screens by
     momentarily maximizing the window on first use with a particular
     screen.  Changing screen settings may invalidate the saved height.
     While a window is maximized, "Zoom Height" has no effect.

   - bpo-35763(28): Make calltip reminder about '/' meaning
     positional-only less obtrusive by only adding it when there is room
     on the first line.

   - bpo-5680(29): Add 'Run...  Customized' to the Run menu to run a
     module with customized settings.  Any 'command line arguments'
     entered are added to sys.argv.  One can suppress the normal Shell
     main module restart.

   - bpo-36390(30): Gather Format menu functions into format.py.
     Combine paragraph.py, rstrip.py, and format methods from editor.py.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26353

   (2) https://bugs.python.org/issue?@action=redirect&bpo=4630

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38598

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36698

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35379

   (6) https://bugs.python.org/issue?@action=redirect&bpo=38183

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38077

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38041

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35771

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37824

   (11) https://bugs.python.org/issue?@action=redirect&bpo=37929

   (12) https://bugs.python.org/issue?@action=redirect&bpo=37902

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37849

   (14) https://bugs.python.org/issue?@action=redirect&bpo=36419

   (15) https://bugs.python.org/issue?@action=redirect&bpo=37748

   (16) https://bugs.python.org/issue?@action=redirect&bpo=37692

   (17) https://bugs.python.org/issue?@action=redirect&bpo=37628

   (18) https://bugs.python.org/issue?@action=redirect&bpo=37627

   (19) https://bugs.python.org/issue?@action=redirect&bpo=33610

   (20) https://bugs.python.org/issue?@action=redirect&bpo=37530

   (21) https://bugs.python.org/issue?@action=redirect&bpo=27452

   (22) https://bugs.python.org/issue?@action=redirect&bpo=37325

   (23) https://bugs.python.org/issue?@action=redirect&bpo=37321

   (24) https://bugs.python.org/issue?@action=redirect&bpo=17535

   (25) https://bugs.python.org/issue?@action=redirect&bpo=26806

   (26) https://bugs.python.org/issue?@action=redirect&bpo=37177

   (27) https://bugs.python.org/issue?@action=redirect&bpo=37039

   (28) https://bugs.python.org/issue?@action=redirect&bpo=35763

   (29) https://bugs.python.org/issue?@action=redirect&bpo=5680

   (30) https://bugs.python.org/issue?@action=redirect&bpo=36390


File: python.info,  Node: Tools/Demos<20>,  Next: C API<44>,  Prev: IDLE<32>,  Up: Python 3 9 0 alpha 1

1.23.46.10 Tools/Demos
......................

   - bpo-38118(1): Update Valgrind suppression file to ignore a false
     alarm in *note PyUnicode_Decode(): 194d. when using GCC builtin
     strcmp().

   - bpo-38347(2): pathfix.py: Assume all files that end on '.py' are
     Python scripts when working recursively.

   - bpo-37803(3): pdb's ‘--help’ and ‘--version’ long options now work.

   - bpo-37942(4): Improve ArgumentClinic converter for floats.

   - bpo-37704(5): Remove ‘Tools/scripts/h2py.py’: use cffi to access a
     C API in Python.

   - bpo-37675(6): 2to3 now works when run from a zipped standard
     library.

   - bpo-37034(7): Argument Clinic now uses the argument name on errors
     with keyword-only argument instead of their position.  Patch
     contributed by Rémi Lapeyre.

   - bpo-37064(8): Add option -k to pathscript.py script: preserve
     shebang flags.  Add option -a to pathscript.py script: add flags.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=38118

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38347

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37803

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37942

   (5) https://bugs.python.org/issue?@action=redirect&bpo=37704

   (6) https://bugs.python.org/issue?@action=redirect&bpo=37675

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37034

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37064


File: python.info,  Node: C API<44>,  Prev: Tools/Demos<20>,  Up: Python 3 9 0 alpha 1

1.23.46.11 C API
................

   - bpo-37633(1): Re-export some function compatibility wrappers for
     macros in ‘pythonrun.h’.

   - bpo-38644(2): Provide *note Py_EnterRecursiveCall(): 941. and *note
     Py_LeaveRecursiveCall(): 942. as regular functions for the limited
     API. Previously, there were defined as macros, but these macros
     didn't work with the limited API which cannot access
     ‘PyThreadState.recursion_depth’ field.  Remove
     ‘_Py_CheckRecursionLimit’ from the stable ABI.

   - bpo-38650(3): The global variable *note
     PyStructSequence_UnnamedField: 950. is now a constant and refers to
     a constant string.

   - bpo-38540(4): Fixed possible leak in *note PyArg_Parse(): 194f. and
     similar functions for format units ‘"es#"’ and ‘"et#"’ when the
     macro ‘PY_SSIZE_T_CLEAN’ is not defined.

   - bpo-38395(5): Fix a crash in *note weakref.proxy: a20. objects due
     to incorrect lifetime management when calling some associated
     methods that may delete the last reference to object being
     referenced by the proxy.  Patch by Pablo Galindo.

   - bpo-36389(6): The ‘_PyObject_CheckConsistency()’ function is now
     also available in release mode.  For example, it can be used to
     debug a crash in the ‘visit_decref()’ function of the GC.

   - bpo-38266(7): Revert the removal of PyThreadState_DeleteCurrent()
     with documentation.

   - bpo-38303(8): Update audioop extension module to use the stable ABI
     (PEP-384).  Patch by Tyler Kieft.

   - bpo-38234(9): ‘Py_SetPath()’ now sets *note sys.executable: 392. to
     the program full path (*note Py_GetProgramFullPath(): 391.) rather
     than to the program name (*note Py_GetProgramName(): 393.).

   - bpo-38234(10): Python ignored arguments passed to ‘Py_SetPath()’,
     ‘Py_SetPythonHome()’ and ‘Py_SetProgramName()’: fix Python
     initialization to use specified arguments.

   - bpo-38205(11): The *note Py_UNREACHABLE(): b83. macro now calls
     *note Py_FatalError(): 951.

   - bpo-38140(12): Make dict and weakref offsets opaque for C heap
     types by passing the offsets through PyMemberDef

   - bpo-15088(13): The C function ‘PyGen_NeedsFinalizing’ has been
     removed.  It was not documented, tested or used anywhere within
     CPython after the implementation of PEP 442(14).  Patch by Joannah
     Nanjekye.  (Patch by Joannah Nanjekye)

   - bpo-36763(15): Options added by ‘PySys_AddXOption()’ are now
     handled the same way than ‘PyConfig.xoptions’ and command line ‘-X’
     options.

   - bpo-37926(16): Fix a crash in ‘PySys_SetArgvEx(0, NULL, 0)’.

   - bpo-37879(17): Fix subtype_dealloc to suppress the type decref when
     the base type is a C heap type

   - bpo-37645(18): Add ‘_PyObject_FunctionStr()’ to get a user-friendly
     string representation of a function-like object.  Patch by Jeroen
     Demeyer.

   - bpo-29548(19): The functions ‘PyEval_CallObject’,
     ‘PyEval_CallFunction’, ‘PyEval_CallMethod’ and
     ‘PyEval_CallObjectWithKeywords’ are deprecated.  Use *note
     PyObject_Call(): 376. and its variants instead.

   - bpo-37151(20): ‘PyCFunction_Call’ is now a deprecated alias of
     *note PyObject_Call(): 376.

   - bpo-37540(21): The vectorcall protocol now requires that the caller
     passes only strings as keyword names.

   - bpo-37207(22): The vectorcall protocol is now enabled for ‘type’
     objects: set ‘tp_vectorcall’ to a vectorcall function to be used
     instead of ‘tp_new’ and ‘tp_init’ when calling the class itself.

   - bpo-21120(23): Exclude Python-ast.h, ast.h and asdl.h from the
     limited API.

   - bpo-37483(24): Add new function ‘_PyObject_CallOneArg’ for calling
     an object with one positional argument.

   - bpo-36763(25): Add *note PyConfig_SetWideStringList(): 1950.
     function.

   - bpo-37337(26): Add fast functions for calling methods:
     ‘_PyObject_VectorcallMethod()’, ‘_PyObject_CallMethodNoArgs()’ and
     ‘_PyObject_CallMethodOneArg()’.

   - bpo-28805(27): The *note METH_FASTCALL: 158b. calling convention
     has been documented.

   - bpo-37221(28): The new function ‘PyCode_NewWithPosOnlyArgs()’
     allows to create code objects like ‘PyCode_New()’, but with an
     extra 'posonlyargcount' parameter for indicating the number of
     positonal-only arguments.

   - bpo-37215(29): Fix dtrace issue introduce by bpo-36842(30)

   - bpo-37194(31): Add a new public *note PyObject_CallNoArgs(): 375.
     function to the C API: call a callable Python object without any
     arguments.  It is the most efficient way to call a callback without
     any argument.  On x86-64, for example,
     ‘PyObject_CallFunctionObjArgs(func, NULL)’ allocates 960 bytes on
     the stack per call, whereas ‘PyObject_CallNoArgs(func)’ only
     allocates 624 bytes per call.

   - bpo-37170(32): Fix the cast on error in *note
     PyLong_AsUnsignedLongLongMask(): 1951.

   - bpo-35381(33): Convert posixmodule.c statically allocated types
     ‘DirEntryType’ and ‘ScandirIteratorType’ to heap-allocated types.

   - bpo-34331(34): Use singular/plural noun in error message when
     instantiating an abstract class with non-overridden abstract
     method(s).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37633

   (2) https://bugs.python.org/issue?@action=redirect&bpo=38644

   (3) https://bugs.python.org/issue?@action=redirect&bpo=38650

   (4) https://bugs.python.org/issue?@action=redirect&bpo=38540

   (5) https://bugs.python.org/issue?@action=redirect&bpo=38395

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36389

   (7) https://bugs.python.org/issue?@action=redirect&bpo=38266

   (8) https://bugs.python.org/issue?@action=redirect&bpo=38303

   (9) https://bugs.python.org/issue?@action=redirect&bpo=38234

   (10) https://bugs.python.org/issue?@action=redirect&bpo=38234

   (11) https://bugs.python.org/issue?@action=redirect&bpo=38205

   (12) https://bugs.python.org/issue?@action=redirect&bpo=38140

   (13) https://bugs.python.org/issue?@action=redirect&bpo=15088

   (14) https://peps.python.org/pep-0442/

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36763

   (16) https://bugs.python.org/issue?@action=redirect&bpo=37926

   (17) https://bugs.python.org/issue?@action=redirect&bpo=37879

   (18) https://bugs.python.org/issue?@action=redirect&bpo=37645

   (19) https://bugs.python.org/issue?@action=redirect&bpo=29548

   (20) https://bugs.python.org/issue?@action=redirect&bpo=37151

   (21) https://bugs.python.org/issue?@action=redirect&bpo=37540

   (22) https://bugs.python.org/issue?@action=redirect&bpo=37207

   (23) https://bugs.python.org/issue?@action=redirect&bpo=21120

   (24) https://bugs.python.org/issue?@action=redirect&bpo=37483

   (25) https://bugs.python.org/issue?@action=redirect&bpo=36763

   (26) https://bugs.python.org/issue?@action=redirect&bpo=37337

   (27) https://bugs.python.org/issue?@action=redirect&bpo=28805

   (28) https://bugs.python.org/issue?@action=redirect&bpo=37221

   (29) https://bugs.python.org/issue?@action=redirect&bpo=37215

   (30) https://bugs.python.org/issue?@action=redirect&bpo=36842

   (31) https://bugs.python.org/issue?@action=redirect&bpo=37194

   (32) https://bugs.python.org/issue?@action=redirect&bpo=37170

   (33) https://bugs.python.org/issue?@action=redirect&bpo=35381

   (34) https://bugs.python.org/issue?@action=redirect&bpo=34331


File: python.info,  Node: Python 3 8 0 beta 1,  Next: Python 3 8 0 alpha 4,  Prev: Python 3 9 0 alpha 1,  Up: 変更履歴

1.23.47 Python 3.8.0 beta 1
---------------------------

'Release date: 2019-06-04'

* Menu:

* Security: Security<31>.
* Core and Builtins: Core and Builtins<47>.
* Library: Library<46>.
* Documentation: Documentation<41>.
* Tests: Tests<43>.
* Build: Build<46>.
* Windows: Windows<41>.
* macOS: macOS<35>.
* IDLE: IDLE<33>.
* Tools/Demos: Tools/Demos<21>.
* C API: C API<45>.


File: python.info,  Node: Security<31>,  Next: Core and Builtins<47>,  Up: Python 3 8 0 beta 1

1.23.47.1 Security
..................

   - bpo-35907(1): CVE 2019-9948(2): Avoid file reading by disallowing
     ‘local-file://’ and ‘local_file://’ URL schemes in
     ‘URLopener().open()’ and ‘URLopener().retrieve()’ of *note
     urllib.request: f4.

   - bpo-33529(3): Prevent fold function used in email header encoding
     from entering infinite loop when there are too many non-ASCII
     characters in a header.

   - bpo-33164(4): Updated blake2 implementation which uses secure
     memset implementation provided by platform.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35907

   (2) https://www.cve.org/CVERecord?id=CVE-2019-9948

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33529

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33164


File: python.info,  Node: Core and Builtins<47>,  Next: Library<46>,  Prev: Security<31>,  Up: Python 3 8 0 beta 1

1.23.47.2 Core and Builtins
...........................

   - bpo-35814(1): Allow unpacking in the right hand side of annotated
     assignments.  In particular, ‘t: Tuple[int, ...] = x, y, *z’ is now
     allowed.

   - bpo-37126(2): All structseq objects are now tracked by the garbage
     collector.  Patch by Pablo Galindo.

   - bpo-37122(3): Make the 'co_argcount' attribute of code objects
     represent the total number of positional arguments (including
     positional-only arguments).  The value of 'co_posonlyargcount' can
     be used to distinguish which arguments are positional only, and the
     difference ('co_argcount' - 'co_posonlyargcount') is the number of
     positional-or-keyword arguments.  Patch by Pablo Galindo.

   - bpo-20092(4): Constructors of *note int: 238, *note float: 2ce. and
     *note complex: 2cf. will now use the *note __index__(): 6e8.
     special method, if available and the corresponding method *note
     __int__(): 6e7, *note __float__(): 99a. or *note __complex__():
     5b1. is not available.

   - bpo-37087(5): Add native thread ID (TID) support to OpenBSD.

   - bpo-26219(6): Implemented per opcode cache mechanism and
     ‘LOAD_GLOBAL’ instruction use it.  ‘LOAD_GLOBAL’ is now about 40%
     faster.  Contributed by Yury Selivanov, and Inada Naoki.

   - bpo-37072(7): Fix crash in PyAST_FromNodeObject() when flags is
     NULL.

   - bpo-37029(8): Freeing a great many small objects could take time
     quadratic in the number of arenas, due to using linear search to
     keep ‘obmalloc.c’'s list of usable arenas sorted by order of number
     of free memory pools.  This is accomplished without search now,
     leaving the worst-case time linear in the number of arenas.  For
     programs where this quite visibly matters (typically with more than
     100 thousand small objects alive simultaneously), this can greatly
     reduce the time needed to release their memory.

   - bpo-26423(9): Fix possible overflow in ‘wrap_lenfunc()’ when
     ‘sizeof(long) < sizeof(Py_ssize_t)’ (e.g., 64-bit Windows).

   - bpo-37050(10): Improve the AST for "debug" f-strings, which use '='
     to print out the source of the expression being evaluated.  Delete
     expr_text from the FormattedValue node, and instead use a Constant
     string node (possibly merged with adjacent constant expressions
     inside the f-string).

   - bpo-22385(11): The ‘bytes.hex’, ‘bytearray.hex’, and
     ‘memoryview.hex’ methods as well as the ‘binascii.hexlify’ and
     ‘b2a_hex’ functions now have the ability to include an optional
     separator between hex bytes.  This functionality was inspired by
     MicroPython's hexlify implementation.

   - bpo-26836(12): Add *note os.memfd_create(): 9d9.

   - bpo-37032(13): Added new ‘replace()’ method to the code type (*note
     types.CodeType: 2c0.).

   - bpo-37007(14): Implement *note socket.if_nameindex(): 9fb, *note
     socket.if_nametoindex(): 9fc, and *note socket.if_indextoname():
     9fd. on Windows.

   - bpo-36829(15): *note PyErr_WriteUnraisable(): 328. now creates a
     traceback object if there is no current traceback.  Moreover, call
     *note PyErr_NormalizeException(): 3ce. and *note
     PyException_SetTraceback(): 1955. to normalize the exception value.
     Ignore any error.

   - bpo-36878(16): Only accept text after ‘# type: ignore’ if the first
     character is ASCII. This is to disallow things like ‘# type:
     ignoreé’.

   - bpo-36878(17): Store text appearing after a ‘# type: ignore’
     comment in the AST. For example a type ignore like ‘# type:
     ignore[E1000]’ will have the string ‘"[E1000]"’ stored in its AST
     node.

   - bpo-2180(18): Treat line continuation at EOF as a ‘SyntaxError’ by
     Anthony Sottile.

   - bpo-36907(19): Fix a crash when calling a C function with a keyword
     dict (‘f(**kwargs)’) and changing the dict ‘kwargs’ while that
     function is running.

   - bpo-36946(20): Fix possible signed integer overflow when handling
     slices.

   - bpo-36826(21): Add NamedExpression kind support to ast_unparse.c

   - bpo-1875(22): A *note SyntaxError: 172. is now raised if a code
     blocks that will be optimized away (e.g.  if conditions that are
     always false) contains syntax errors.  Patch by Pablo Galindo.

   - bpo-36027(23): Allow computation of modular inverses via
     three-argument ‘pow’: the second argument is now permitted to be
     negative in the case where the first and third arguments are
     relatively prime.

   - bpo-36861(24): Update the Unicode database to version 12.1.0.

   - bpo-28866(25): Avoid caching attributes of classes which type
     defines mro() to avoid a hard cache invalidation problem.

   - bpo-36851(26): The ‘FrameType’ stack is now correctly cleaned up if
     the execution ends with a return and the stack is not empty.

   - bpo-34616(27): The ‘compile()’ builtin functions now support the
     ‘ast.PyCF_ALLOW_TOP_LEVEL_AWAIT’ flag, which allow to compile
     sources that contains top-level ‘await’, ‘async with’ or ‘async
     for’.  This is useful to evaluate async-code from with an already
     async functions; for example in a custom REPL.

   - bpo-36842(28): Implement PEP 578, adding sys.audit, io.open_code
     and related APIs.

   - bpo-27639(29): Correct return type for UserList slicing operations.
     Patch by Michael Blahay, Erick Cervantes, and vaultah

   - bpo-36737(30): Move PyRuntimeState.warnings into per-interpreter
     state (via "module state").

   - bpo-36793(31): Removed ‘__str__’ implementations from builtin types
     *note bool: 434, *note int: 238, *note float: 2ce, *note complex:
     2cf. and few classes from the standard library.  They now inherit
     ‘__str__()’ from *note object: a5a.

   - bpo-36817(32): Add a ‘=’ feature f-strings for debugging.  This can
     precede ‘!s’, ‘!r’, or ‘!a’.  It produces the text of the
     expression, followed by an equal sign, followed by the repr of the
     value of the expression.  So ‘f'{3*9+15=}'’ would be equal to the
     string ‘'3*9+15=42'’.  If ‘=’ is specified, the default conversion
     is set to ‘!r’, unless a format spec is given, in which case the
     formatting behavior is unchanged, and __format__ will be used.

   - bpo-24048(33): Save the live exception during import.c's
     ‘remove_module()’.

   - bpo-27987(34): pymalloc returns memory blocks aligned by 16 bytes,
     instead of 8 bytes, on 64-bit platforms to conform x86-64 ABI.
     Recent compilers assume this alignment more often.  Patch by Inada
     Naoki.

   - bpo-36601(35): A long-since-meaningless check for ‘getpid() ==
     main_pid’ was removed from Python's internal C signal handler.

   - bpo-36594(36): Fix incorrect use of ‘%p’ in format strings.  Patch
     by Zackery Spytz.

   - bpo-36045(37): ‘builtins.help()’ now prefixes ‘async’ for async
     functions.

   - bpo-36084(38): Add native thread ID (TID) to threading.Thread
     objects (supported platforms: Windows, FreeBSD, Linux, macOS)

   - bpo-36035(39): Added fix for broken symlinks in combination with
     pathlib

   - bpo-35983(40): Added new trashcan macros to deal with a double
     deallocation that could occur when the ‘tp_dealloc’ of a subclass
     calls the ‘tp_dealloc’ of a base class and that base class uses the
     trashcan mechanism.  Patch by Jeroen Demeyer.

   - bpo-20602(41): Do not clear *note sys.flags: 658. and *note
     sys.float_info: 1956. during shutdown.  Patch by Zackery Spytz.

   - bpo-26826(42): Expose ‘copy_file_range()’ as a low level API in the
     *note os: 91. module.

   - bpo-32388(43): Remove cross-version binary compatibility
     requirement in tp_flags.

   - bpo-31862(44): Port binascii to PEP 489 multiphase initialization.
     Patch by Marcel Plch.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35814

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37126

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37122

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20092

   (5) https://bugs.python.org/issue?@action=redirect&bpo=37087

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26219

   (7) https://bugs.python.org/issue?@action=redirect&bpo=37072

   (8) https://bugs.python.org/issue?@action=redirect&bpo=37029

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26423

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37050

   (11) https://bugs.python.org/issue?@action=redirect&bpo=22385

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26836

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37032

   (14) https://bugs.python.org/issue?@action=redirect&bpo=37007

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36829

   (16) https://bugs.python.org/issue?@action=redirect&bpo=36878

   (17) https://bugs.python.org/issue?@action=redirect&bpo=36878

   (18) https://bugs.python.org/issue?@action=redirect&bpo=2180

   (19) https://bugs.python.org/issue?@action=redirect&bpo=36907

   (20) https://bugs.python.org/issue?@action=redirect&bpo=36946

   (21) https://bugs.python.org/issue?@action=redirect&bpo=36826

   (22) https://bugs.python.org/issue?@action=redirect&bpo=1875

   (23) https://bugs.python.org/issue?@action=redirect&bpo=36027

   (24) https://bugs.python.org/issue?@action=redirect&bpo=36861

   (25) https://bugs.python.org/issue?@action=redirect&bpo=28866

   (26) https://bugs.python.org/issue?@action=redirect&bpo=36851

   (27) https://bugs.python.org/issue?@action=redirect&bpo=34616

   (28) https://bugs.python.org/issue?@action=redirect&bpo=36842

   (29) https://bugs.python.org/issue?@action=redirect&bpo=27639

   (30) https://bugs.python.org/issue?@action=redirect&bpo=36737

   (31) https://bugs.python.org/issue?@action=redirect&bpo=36793

   (32) https://bugs.python.org/issue?@action=redirect&bpo=36817

   (33) https://bugs.python.org/issue?@action=redirect&bpo=24048

   (34) https://bugs.python.org/issue?@action=redirect&bpo=27987

   (35) https://bugs.python.org/issue?@action=redirect&bpo=36601

   (36) https://bugs.python.org/issue?@action=redirect&bpo=36594

   (37) https://bugs.python.org/issue?@action=redirect&bpo=36045

   (38) https://bugs.python.org/issue?@action=redirect&bpo=36084

   (39) https://bugs.python.org/issue?@action=redirect&bpo=36035

   (40) https://bugs.python.org/issue?@action=redirect&bpo=35983

   (41) https://bugs.python.org/issue?@action=redirect&bpo=20602

   (42) https://bugs.python.org/issue?@action=redirect&bpo=26826

   (43) https://bugs.python.org/issue?@action=redirect&bpo=32388

   (44) https://bugs.python.org/issue?@action=redirect&bpo=31862


File: python.info,  Node: Library<46>,  Next: Documentation<41>,  Prev: Core and Builtins<47>,  Up: Python 3 8 0 beta 1

1.23.47.3 Library
.................

   - bpo-37128(1): Added *note math.perm(): 69c.

   - bpo-37120(2): Add SSLContext.num_tickets to control the number of
     TLSv1.3 session tickets.

   - bpo-12202(3): Fix the error handling in
     ‘msilib.SummaryInformation.GetProperty()’.  Patch by Zackery Spytz.

   - bpo-26835(4): The fcntl module now contains file sealing constants
     for sealing of memfds.

   - bpo-29262(5): Add ‘get_origin()’ and ‘get_args()’ introspection
     helpers to ‘typing’ module.

   - bpo-12639(6): ‘msilib.Directory.start_component()’ no longer fails
     if 'keyfile' is not ‘None’.

   - bpo-36999(7): Add the ‘asyncio.Task.get_coro()’ method to publicly
     expose the tasks's coroutine object.

   - bpo-35246(8): Make *note asyncio.create_subprocess_exec(): a45.
     accept path-like arguments.

   - bpo-35279(9): Change default 'max_workers' of ‘ThreadPoolExecutor’
     from ‘cpu_count() * 5’ to ‘min(32, cpu_count() + 4)’.  Previous
     value was unreasonably large on many cores machines.

   - bpo-37076(10): *note _thread.start_new_thread(): 17b. now logs
     uncaught exception raised by the function using *note
     sys.unraisablehook(): 1d8, rather than *note sys.excepthook(): 7d6,
     so the hook gets access to the function which raised the exception.

   - bpo-33725(11): On macOS, the *note multiprocessing: 86. module now
     uses 'spawn' start method by default.

   - bpo-37054(12): Fix destructor ‘_pyio.BytesIO’ and
     ‘_pyio.TextIOWrapper’: initialize their ‘_buffer’ attribute as soon
     as possible (in the class body), because it's used by ‘__del__()’
     which calls ‘close()’.

   - bpo-37058(13): PEP 544: Add ‘Protocol’ and ‘@runtime_checkable’ to
     the ‘typing’ module.

   - bpo-36933(14): The functions ‘sys.set_coroutine_wrapper’ and
     ‘sys.get_coroutine_wrapper’ that were deprecated and marked for
     removal in 3.8 have been removed.

   - bpo-37047(15): Handle late binding and attribute access in *note
     unittest.mock.AsyncMock: a19. setup for autospeccing.  Document
     newly implemented async methods in *note unittest.mock.MagicMock:
     e5a.

   - bpo-37049(16): PEP 589: Add ‘TypedDict’ to the ‘typing’ module.

   - bpo-37046(17): PEP 586: Add ‘Literal’ to the ‘typing’ module.

   - bpo-37045(18): PEP 591: Add ‘Final’ qualifier and ‘@final’
     decorator to the ‘typing’ module.

   - bpo-37035(19): Don't log OSError based exceptions if a fatal error
     has occurred in asyncio transport.  Peer can generate almost any
     OSError, user cannot avoid these exceptions by fixing own code.
     Errors are still propagated to user code, it's just logging them is
     pointless and pollute asyncio logs.

   - bpo-37001(20): *note symtable.symtable(): 1958. now accepts the
     same input types for source code as the built-in *note compile():
     177. function.  Patch by Dino Viehland.

   - bpo-37028(21): Implement asyncio REPL

   - bpo-37027(22): Return safe to use proxy socket object from
     transport.get_extra_info('socket')

   - bpo-32528(23): Make asyncio.CancelledError a BaseException.

     This will address the common mistake many asyncio users make: an
     "except Exception" clause breaking Tasks cancellation.

     In addition to this change, we stop inheriting asyncio.TimeoutError
     and asyncio.InvalidStateError from their concurrent.futures.*
     counterparts.  There's no point for these exceptions to share the
     inheritance chain.

   - bpo-1230540(24): Add a new *note threading.excepthook(): 816.
     function which handles uncaught *note threading.Thread.run(): a0b.
     exception.  It can be overridden to control how uncaught *note
     threading.Thread.run(): a0b. exceptions are handled.

   - bpo-36996(25): Handle *note unittest.mock.patch(): e5b. used as a
     decorator on async functions.

   - bpo-37008(26): Add support for calling *note next(): 7a3. with the
     mock resulting from *note unittest.mock.mock_open(): 166f.

   - bpo-27737(27): Allow whitespace only header encoding in
     ‘email.header’ - by Batuhan Taskaya

   - bpo-36969(28): PDB command ‘args’ now display positional only
     arguments.  Patch contributed by Rémi Lapeyre.

   - bpo-36969(29): PDB command ‘args’ now display keyword only
     arguments.  Patch contributed by Rémi Lapeyre.

   - bpo-36983(30): Add missing names to ‘typing.__all__’: ‘ChainMap’,
     ‘ForwardRef’, ‘OrderedDict’ - by Anthony Sottile.

   - bpo-36972(31): Add SupportsIndex protocol to the typing module to
     allow type checking to detect classes that can be passed to
     ‘hex()’, ‘oct()’ and ‘bin()’.

   - bpo-32972(32): Implement ‘unittest.IsolatedAsyncioTestCase’ to help
     testing asyncio-based code.

   - bpo-36952(33): *note fileinput.input(): 7ca. and *note
     fileinput.FileInput: 702. 'bufsize' argument has been removed (was
     deprecated and ignored since Python 3.6), and as a result the
     'mode' and 'openhook' arguments have been made keyword-only.

   - bpo-36952(34): Starting with Python 3.3, importing ABCs from *note
     collections: 16. is deprecated, and import should be done from
     *note collections.abc: 17.  Still being able to import from *note
     collections: 16. was marked for removal in 3.8, but has been
     delayed to 3.9; documentation and ‘DeprecationWarning’ clarified.

   - bpo-36949(35): Implement __repr__ for WeakSet objects.

   - bpo-36948(36): Fix *note NameError: 40b. in *note
     urllib.request.URLopener.retrieve(): 1959.  Patch by Karthikeyan
     Singaravelan.

   - bpo-33524(37): Fix the folding of email header when the
     max_line_length is 0 or None and the header contains non-ascii
     characters.  Contributed by Licht Takeuchi (@Licht-T).

   - bpo-24564(38): *note shutil.copystat(): 1101. now ignores *note
     errno.EINVAL: 195a. on *note os.setxattr(): 10da. which may occur
     when copying files on filesystems without extended attributes
     support.

     Original patch by Giampaolo Rodola, updated by Ying Wang.

   - bpo-36888(39): Python child processes can now access the status of
     their parent process using multiprocessing.process.parent_process

   - bpo-36921(40): Deprecate ‘@coroutine’ for sake of ‘async def’.

   - bpo-25652(41): Fix bug in ‘__rmod__’ of ‘UserString’ - by Batuhan
     Taskaya.

   - bpo-36916(42): Remove a message about an unhandled exception in a
     task when writer.write() is used without await and writer.drain()
     fails with an exception.

   - bpo-36889(43): Introduce ‘asyncio.Stream’ class that merges *note
     asyncio.StreamReader: 1830. and *note asyncio.StreamWriter: 1665.
     functionality.  ‘asyncio.Stream’ can work in readonly, writeonly
     and readwrite modes.  Provide ‘asyncio.connect()’,
     ‘asyncio.connect_unix()’, ‘asyncio.connect_read_pipe()’ and
     ‘asyncio.connect_write_pipe()’ factories to open ‘asyncio.Stream’
     connections.  Provide ‘asyncio.StreamServer’ and ‘UnixStreamServer’
     to serve servers with asyncio.Stream API. Modify *note
     asyncio.create_subprocess_shell(): a46. and *note
     asyncio.create_subprocess_exec(): a45. to use ‘asyncio.Stream’
     instead of deprecated ‘StreamReader’ and ‘StreamWriter’.  Deprecate
     *note asyncio.StreamReader: 1830. and *note asyncio.StreamWriter:
     1665.  Deprecate usage of private classes, e.g.
     ‘asyncio.FlowControlMixing’ and ‘asyncio.StreamReaderProtocol’
     outside of asyncio package.

   - bpo-36845(44): Added validation of integer prefixes to the
     construction of IP networks and interfaces in the ipaddress module.

   - bpo-23378(45): Add an extend action to argparser.

   - bpo-36867(46): Fix a bug making a SharedMemoryManager instance and
     its parent process use two separate resource_tracker processes.

   - bpo-23896(47): Adds a grammar to lib2to3.pygram that contains exec
     as a function not as statement.

   - bpo-36895(48): The function ‘time.clock()’ was deprecated in 3.3 in
     favor of ‘time.perf_counter()’ and marked for removal in 3.8, it
     has removed.

   - bpo-35545(49): Fix asyncio discarding IPv6 scopes when ensuring
     hostname resolutions internally

   - bpo-36887(50): Add new function *note math.isqrt(): 9d3. to compute
     integer square roots.

   - bpo-34632(51): Introduce the ‘importlib.metadata’ module with
     (provisional) support for reading metadata from third-party
     packages.

   - bpo-36878(52): When using ‘type_comments=True’ in ‘ast.parse’,
     treat ‘# type: ignore’ followed by a non-alphanumeric character and
     then arbitrary text as a type ignore, instead of requiring nothing
     but whitespace or another comment.  This is to permit formations
     such as ‘# type: ignore[E1000]’.

   - bpo-36778(53): ‘cp65001’ encoding (Windows code page 65001) becomes
     an alias to ‘utf_8’ encoding.

   - bpo-36867(54): The multiprocessing.resource_tracker replaces the
     multiprocessing.semaphore_tracker module.  Other than semaphores,
     resource_tracker also tracks shared_memory segments.

   - bpo-30262(55): The ‘Cache’ and ‘Statement’ objects of the *note
     sqlite3: ba. module are not exposed to the user.  Patch by Aviv
     Palivoda.

   - bpo-24538(56): In ‘shutil.copystat()’, first copy extended file
     attributes and then file permissions, since extended attributes can
     only be set on the destination while it is still writeable.

   - bpo-36829(57): Add new *note sys.unraisablehook(): 1d8. function
     which can be overridden to control how "unraisable exceptions" are
     handled.  It is 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 (*note
     gc.collect(): a08.).

   - bpo-36832(58): Introducing ‘zipfile.Path’, a pathlib-compatible
     wrapper for traversing zip files.

   - bpo-36814(59): Fix an issue where os.posix_spawnp() would
     incorrectly raise a TypeError when file_actions is None.

   - bpo-33110(60): Handle exceptions raised by functions added by
     concurrent.futures add_done_callback correctly when the Future has
     already completed.

   - bpo-26903(61): Limit ‘max_workers’ in ‘ProcessPoolExecutor’ to 61
     to work around a WaitForMultipleObjects limitation.

   - bpo-36813(62): Fix *note QueueListener: df9. to call
     ‘queue.task_done()’ upon stopping.  Patch by Bar Harel.

   - bpo-36806(63): Forbid creation of asyncio stream objects like
     StreamReader, StreamWriter, Process, and their protocols outside of
     asyncio package.

   - bpo-36802(64): Provide both sync and async calls for
     StreamWriter.write() and StreamWriter.close()

   - bpo-36801(65): Properly handle SSL connection closing in asyncio
     StreamWriter.drain() call.

   - bpo-36785(66): Implement PEP 574 (pickle protocol 5 with
     out-of-band buffers).

   - bpo-36772(67): functools.lru_cache() can now be used as a straight
     decorator in addition to its existing usage as a function that
     returns a decorator.

   - bpo-6584(68): Add a *note BadGzipFile: 9c5. exception to the *note
     gzip: 5d. module.

   - bpo-36748(69): Optimized write buffering in C implementation of
     ‘TextIOWrapper’.  Writing ASCII string to ‘TextIOWrapper’ with
     ascii, latin1, or utf-8 encoding is about 20% faster.  Patch by
     Inada Naoki.

   - bpo-8138(70): Don't mark ‘wsgiref.simple_server.SimpleServer’ as
     multi-threaded since ‘wsgiref.simple_server.WSGIServer’ is
     single-threaded.

   - bpo-22640(71): *note py_compile.compile(): 9f3. now supports silent
     mode.  Patch by Joannah Nanjekye

   - bpo-29183(72): Fix double exceptions in *note
     wsgiref.handlers.BaseHandler: 195b. by calling its ‘close()’ method
     only when no exception is raised.

   - bpo-36548(73): Improved the repr of regular expression flags.

   - bpo-36542(74): The signature of Python functions can now be
     overridden by specifying the ‘__text_signature__’ attribute.

   - bpo-36533(75): Reinitialize logging.Handler locks in forked child
     processes instead of attempting to acquire them all in the parent
     before forking only to be released in the child process.  The
     acquire/release pattern was leading to deadlocks in code that has
     implemented any form of chained logging handlers that depend upon
     one another as the lock acquisition order cannot be guaranteed.

   - bpo-35252(76): Throw a TypeError instead of an AssertionError when
     using an invalid type annotation with singledispatch.

   - bpo-35900(77): Allow reduction methods to return a 6-item tuple
     where the 6th item specifies a custom state-setting method that's
     called instead of the regular ‘__setstate__’ method.

   - bpo-35900(78): enable custom reduction callback registration for
     functions and classes in _pickle.c, using the new Pickler's
     attribute ‘reducer_override’

   - bpo-36368(79): Fix a bug crashing SharedMemoryManager instances in
     interactive sessions after a ctrl-c (KeyboardInterrupt) was sent

   - bpo-31904(80): Fix mmap fail for VxWorks

   - bpo-27497(81): *note csv.DictWriter.writeheader(): 11d0. now
     returns the return value of the underlying ‘csv.Writer.writerow()’
     method.  Patch contributed by Ashish Nitin Patil.

   - bpo-36239(82): Parsing .mo files now ignores comments starting and
     ending with #-#-#-#-#.

   - bpo-26707(83): Enable plistlib to read and write binary plist files
     that were created as a KeyedArchive file.  Specifically, this
     allows the plistlib to process 0x80 tokens as UID objects.

   - bpo-31904(84): Add posix module support for VxWorks.

   - bpo-35125(85): Asyncio: Remove inner callback on outer cancellation
     in shield

   - bpo-35721(86): Fix ‘asyncio.SelectorEventLoop.subprocess_exec()’
     leaks file descriptors if ‘Popen’ fails and called with
     ‘stdin=subprocess.PIPE’.  Patch by Niklas Fiekas.

   - bpo-31855(87): *note unittest.mock.mock_open(): 166f. results now
     respects the argument of read([size]).  Patch contributed by Rémi
     Lapeyre.

   - bpo-35431(88): Implement *note math.comb(): 69b. that returns
     binomial coefficient, that computes the number of ways to choose k
     items from n items without repetition and without order.  Patch by
     Yash Aggarwal and Keller Fuchs.

   - bpo-26660(89): Fixed permission errors in *note TemporaryDirectory:
     1205. clean up.  Previously ‘TemporaryDirectory.cleanup()’ failed
     when non-writeable or non-searchable files or directories were
     created inside a temporary directory.

   - bpo-34271(90): Add debugging helpers to ssl module.  It's now
     possible to dump key material and to trace TLS protocol.  The
     default and stdlib contexts also support SSLKEYLOGFILE env var.

   - bpo-26467(91): Added AsyncMock to support using unittest to mock
     asyncio coroutines.  Patch by Lisa Roach.

   - bpo-33569(92): dataclasses.InitVar: Exposes the type used to create
     the init var.

   - bpo-34424(93): Fix serialization of messages containing encoded
     strings when the policy.linesep is set to a multi-character string.
     Patch by Jens Troeger.

   - bpo-34303(94): Performance of *note functools.reduce(): 12aa. is
     slightly improved.  Patch by Sergey Fedoseev.

   - bpo-33361(95): Fix a bug in *note codecs.StreamRecoder: 195c. where
     seeking might leave old data in a buffer and break subsequent read
     calls.  Patch by Ammar Askar.

   - bpo-22454(96): The *note shlex: b2. module now exposes *note
     shlex.join(): 9f5, the inverse of *note shlex.split(): 506.  Patch
     by Bo Bayles.

   - bpo-31922(97):
     ‘asyncio.AbstractEventLoop.create_datagram_endpoint()’: Do not
     connect UDP socket when broadcast is allowed.  This allows to
     receive replies after a UDP broadcast.

   - bpo-24882(98): Change ThreadPoolExecutor to use existing idle
     threads before spinning up new ones.

   - bpo-31961(99): Added support for bytes and path-like objects in
     *note subprocess.Popen(): 17e. on Windows.  The 'args' parameter
     now accepts a *note path-like object: 280. if 'shell' is ‘False’
     and a sequence containing bytes and path-like objects.  The
     'executable' parameter now accepts a bytes and *note path-like
     object: 280.  The 'cwd' parameter now accepts a bytes object.
     Based on patch by Anders Lorentsen.

   - bpo-33123(100): *note pathlib.Path.unlink: 195d. now accepts a
     'missing_ok' parameter to avoid a *note FileNotFoundError: e8f.
     from being raised.  Patch by Robert Buchholz.

   - bpo-32941(101): Allow *note mmap.mmap: 1ec. objects to access the
     madvise() system call (through *note mmap.mmap.madvise(): 9d6.).

   - bpo-22102(102): Added support for ZIP files with disks set to 0.
     Such files are commonly created by builtin tools on Windows when
     use ZIP64 extension.  Patch by Francisco Facioni.

   - bpo-32515(103): trace.py can now run modules via python3 -m trace
     -t -module module_name

   - bpo-32299(104): Changed *note unittest.mock.patch.dict(): 195e. to
     return the patched dictionary when used as context manager.  Patch
     by Vadim Tsander.

   - bpo-27141(105): Added a ‘__copy__()’ to ‘collections.UserList’ and
     ‘collections.UserDict’ in order to correctly implement shallow
     copying of the objects.  Patch by Bar Harel.

   - bpo-31829(106): ‘\r’, ‘\0’ and ‘\x1a’ (end-of-file on Windows) are
     now escaped in protocol 0 pickles of Unicode strings.  This allows
     to load them without loss from files open in text mode in Python 2.

   - bpo-23395(107): ‘_thread.interrupt_main()’ now avoids setting the
     Python error status if the ‘SIGINT’ signal is ignored or not
     handled by Python.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37128

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37120

   (3) https://bugs.python.org/issue?@action=redirect&bpo=12202

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26835

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29262

   (6) https://bugs.python.org/issue?@action=redirect&bpo=12639

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36999

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35246

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35279

   (10) https://bugs.python.org/issue?@action=redirect&bpo=37076

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33725

   (12) https://bugs.python.org/issue?@action=redirect&bpo=37054

   (13) https://bugs.python.org/issue?@action=redirect&bpo=37058

   (14) https://bugs.python.org/issue?@action=redirect&bpo=36933

   (15) https://bugs.python.org/issue?@action=redirect&bpo=37047

   (16) https://bugs.python.org/issue?@action=redirect&bpo=37049

   (17) https://bugs.python.org/issue?@action=redirect&bpo=37046

   (18) https://bugs.python.org/issue?@action=redirect&bpo=37045

   (19) https://bugs.python.org/issue?@action=redirect&bpo=37035

   (20) https://bugs.python.org/issue?@action=redirect&bpo=37001

   (21) https://bugs.python.org/issue?@action=redirect&bpo=37028

   (22) https://bugs.python.org/issue?@action=redirect&bpo=37027

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32528

   (24) https://bugs.python.org/issue?@action=redirect&bpo=1230540

   (25) https://bugs.python.org/issue?@action=redirect&bpo=36996

   (26) https://bugs.python.org/issue?@action=redirect&bpo=37008

   (27) https://bugs.python.org/issue?@action=redirect&bpo=27737

   (28) https://bugs.python.org/issue?@action=redirect&bpo=36969

   (29) https://bugs.python.org/issue?@action=redirect&bpo=36969

   (30) https://bugs.python.org/issue?@action=redirect&bpo=36983

   (31) https://bugs.python.org/issue?@action=redirect&bpo=36972

   (32) https://bugs.python.org/issue?@action=redirect&bpo=32972

   (33) https://bugs.python.org/issue?@action=redirect&bpo=36952

   (34) https://bugs.python.org/issue?@action=redirect&bpo=36952

   (35) https://bugs.python.org/issue?@action=redirect&bpo=36949

   (36) https://bugs.python.org/issue?@action=redirect&bpo=36948

   (37) https://bugs.python.org/issue?@action=redirect&bpo=33524

   (38) https://bugs.python.org/issue?@action=redirect&bpo=24564

   (39) https://bugs.python.org/issue?@action=redirect&bpo=36888

   (40) https://bugs.python.org/issue?@action=redirect&bpo=36921

   (41) https://bugs.python.org/issue?@action=redirect&bpo=25652

   (42) https://bugs.python.org/issue?@action=redirect&bpo=36916

   (43) https://bugs.python.org/issue?@action=redirect&bpo=36889

   (44) https://bugs.python.org/issue?@action=redirect&bpo=36845

   (45) https://bugs.python.org/issue?@action=redirect&bpo=23378

   (46) https://bugs.python.org/issue?@action=redirect&bpo=36867

   (47) https://bugs.python.org/issue?@action=redirect&bpo=23896

   (48) https://bugs.python.org/issue?@action=redirect&bpo=36895

   (49) https://bugs.python.org/issue?@action=redirect&bpo=35545

   (50) https://bugs.python.org/issue?@action=redirect&bpo=36887

   (51) https://bugs.python.org/issue?@action=redirect&bpo=34632

   (52) https://bugs.python.org/issue?@action=redirect&bpo=36878

   (53) https://bugs.python.org/issue?@action=redirect&bpo=36778

   (54) https://bugs.python.org/issue?@action=redirect&bpo=36867

   (55) https://bugs.python.org/issue?@action=redirect&bpo=30262

   (56) https://bugs.python.org/issue?@action=redirect&bpo=24538

   (57) https://bugs.python.org/issue?@action=redirect&bpo=36829

   (58) https://bugs.python.org/issue?@action=redirect&bpo=36832

   (59) https://bugs.python.org/issue?@action=redirect&bpo=36814

   (60) https://bugs.python.org/issue?@action=redirect&bpo=33110

   (61) https://bugs.python.org/issue?@action=redirect&bpo=26903

   (62) https://bugs.python.org/issue?@action=redirect&bpo=36813

   (63) https://bugs.python.org/issue?@action=redirect&bpo=36806

   (64) https://bugs.python.org/issue?@action=redirect&bpo=36802

   (65) https://bugs.python.org/issue?@action=redirect&bpo=36801

   (66) https://bugs.python.org/issue?@action=redirect&bpo=36785

   (67) https://bugs.python.org/issue?@action=redirect&bpo=36772

   (68) https://bugs.python.org/issue?@action=redirect&bpo=6584

   (69) https://bugs.python.org/issue?@action=redirect&bpo=36748

   (70) https://bugs.python.org/issue?@action=redirect&bpo=8138

   (71) https://bugs.python.org/issue?@action=redirect&bpo=22640

   (72) https://bugs.python.org/issue?@action=redirect&bpo=29183

   (73) https://bugs.python.org/issue?@action=redirect&bpo=36548

   (74) https://bugs.python.org/issue?@action=redirect&bpo=36542

   (75) https://bugs.python.org/issue?@action=redirect&bpo=36533

   (76) https://bugs.python.org/issue?@action=redirect&bpo=35252

   (77) https://bugs.python.org/issue?@action=redirect&bpo=35900

   (78) https://bugs.python.org/issue?@action=redirect&bpo=35900

   (79) https://bugs.python.org/issue?@action=redirect&bpo=36368

   (80) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (81) https://bugs.python.org/issue?@action=redirect&bpo=27497

   (82) https://bugs.python.org/issue?@action=redirect&bpo=36239

   (83) https://bugs.python.org/issue?@action=redirect&bpo=26707

   (84) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (85) https://bugs.python.org/issue?@action=redirect&bpo=35125

   (86) https://bugs.python.org/issue?@action=redirect&bpo=35721

   (87) https://bugs.python.org/issue?@action=redirect&bpo=31855

   (88) https://bugs.python.org/issue?@action=redirect&bpo=35431

   (89) https://bugs.python.org/issue?@action=redirect&bpo=26660

   (90) https://bugs.python.org/issue?@action=redirect&bpo=34271

   (91) https://bugs.python.org/issue?@action=redirect&bpo=26467

   (92) https://bugs.python.org/issue?@action=redirect&bpo=33569

   (93) https://bugs.python.org/issue?@action=redirect&bpo=34424

   (94) https://bugs.python.org/issue?@action=redirect&bpo=34303

   (95) https://bugs.python.org/issue?@action=redirect&bpo=33361

   (96) https://bugs.python.org/issue?@action=redirect&bpo=22454

   (97) https://bugs.python.org/issue?@action=redirect&bpo=31922

   (98) https://bugs.python.org/issue?@action=redirect&bpo=24882

   (99) https://bugs.python.org/issue?@action=redirect&bpo=31961

   (100) https://bugs.python.org/issue?@action=redirect&bpo=33123

   (101) https://bugs.python.org/issue?@action=redirect&bpo=32941

   (102) https://bugs.python.org/issue?@action=redirect&bpo=22102

   (103) https://bugs.python.org/issue?@action=redirect&bpo=32515

   (104) https://bugs.python.org/issue?@action=redirect&bpo=32299

   (105) https://bugs.python.org/issue?@action=redirect&bpo=27141

   (106) https://bugs.python.org/issue?@action=redirect&bpo=31829

   (107) https://bugs.python.org/issue?@action=redirect&bpo=23395


File: python.info,  Node: Documentation<41>,  Next: Tests<43>,  Prev: Library<46>,  Up: Python 3 8 0 beta 1

1.23.47.4 Documentation
.......................

   - bpo-36896(1): Clarify that some types have unstable constructor
     signature between Python versions.

   - bpo-36686(2): Improve documentation of the stdin, stdout, and
     stderr arguments of the ‘asyncio.subprocess_exec’ function to
     specify which values are supported.  Also mention that decoding as
     text is not supported.

     Add a few tests to verify that the various values passed to the
     std* arguments actually work.

   - bpo-36984(3): Improve version added references in ‘typing’ module -
     by Anthony Sottile.

   - bpo-36868(4): What's new now mentions
     SSLContext.hostname_checks_common_name instead of
     SSLContext.host_flags.

   - bpo-35924(5): Add a note to the ‘curses.addstr()’ documentation to
     warn that multiline strings can cause segfaults because of an
     ncurses bug.

   - bpo-36783(6): Added C API Documentation for Time_FromTimeAndFold
     and PyDateTime_FromDateAndTimeAndFold as per PEP 495.  Patch by
     Edison Abahurire.

   - bpo-36797(7): More of the legacy distutils documentation has been
     either pruned, or else more clearly marked as being retained solely
     until the setuptools documentation covers it independently.

   - bpo-22865(8): Add detail to the documentation on the ‘pty.spawn’
     function.

   - bpo-35397(9): Remove deprecation and document
     urllib.parse.unwrap().  Patch contributed by Rémi Lapeyre.

   - bpo-32995(10): Added the context variable in glossary.

   - bpo-33519(11): Clarify that ‘copy()’ is not part of the
     ‘MutableSequence’ ABC.

   - bpo-33482(12): Make ‘codecs.StreamRecoder.writelines’ take a list
     of bytes.

   - bpo-25735(13): Added documentation for func factorial to indicate
     that returns integer values

   - bpo-20285(14): Expand object.__doc__ (docstring) to make it
     clearer.  Modify pydoc.py so that help(object) lists object methods
     (for other classes, help omits methods of the object base class.)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36896

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36686

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36984

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36868

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35924

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36783

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36797

   (8) https://bugs.python.org/issue?@action=redirect&bpo=22865

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35397

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32995

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33519

   (12) https://bugs.python.org/issue?@action=redirect&bpo=33482

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25735

   (14) https://bugs.python.org/issue?@action=redirect&bpo=20285


File: python.info,  Node: Tests<43>,  Next: Build<46>,  Prev: Documentation<41>,  Up: Python 3 8 0 beta 1

1.23.47.5 Tests
...............

   - bpo-37069(1): Modify test_coroutines, test_cprofile,
     test_generators, test_raise, test_ssl and test_yield_from to use
     *note test.support.catch_unraisable_exception(): 1943. rather than
     *note test.support.captured_stderr(): 1961.

   - bpo-37098(2): Fix test_memfd_create on older Linux Kernels.

   - bpo-37081(3): Test with OpenSSL 1.1.1c

   - bpo-36829(4): Add *note test.support.catch_unraisable_exception():
     1943.: context manager catching unraisable exception using *note
     sys.unraisablehook(): 1d8.

   - bpo-36915(5): The main regrtest process now always removes all
     temporary directories of worker processes even if they crash or if
     they are killed on KeyboardInterrupt (CTRL+c).

   - bpo-36719(6): "python3 -m test -jN ..."  now continues the
     execution of next tests when a worker process crash (CHILD_ERROR
     state).  Previously, the test suite stopped immediately.  Use
     -failfast to stop at the first error.

   - bpo-36816(7): Update Lib/test/selfsigned_pythontestdotnet.pem to
     match self-signed.pythontest.net's new TLS certificate.

   - bpo-35925(8): Skip httplib and nntplib networking tests when they
     would otherwise fail due to a modern OS or distro with a default
     OpenSSL policy of rejecting connections to servers with weak
     certificates.

   - bpo-36782(9): Add tests for several C API functions in the *note
     datetime: 28. module.  Patch by Edison Abahurire.

   - bpo-36342(10): Fix test_multiprocessing in test_venv if platform
     lacks functioning sem_open.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37069

   (2) https://bugs.python.org/issue?@action=redirect&bpo=37098

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37081

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36829

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36915

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36719

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36816

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35925

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36782

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36342


File: python.info,  Node: Build<46>,  Next: Windows<41>,  Prev: Tests<43>,  Up: Python 3 8 0 beta 1

1.23.47.6 Build
...............

   - bpo-36721(1): To embed Python into an application, a new ‘--embed’
     option must be passed to ‘python3-config --libs --embed’ to get
     ‘-lpython3.8’ (link the application to libpython).  To support both
     3.8 and older, try ‘python3-config --libs --embed’ first and
     fallback to ‘python3-config --libs’ (without ‘--embed’) if the
     previous command fails.

     Add a pkg-config ‘python-3.8-embed’ module to embed Python into an
     application: ‘pkg-config python-3.8-embed --libs’ includes
     ‘-lpython3.8’.  To support both 3.8 and older, try ‘pkg-config
     python-X.Y-embed --libs’ first and fallback to ‘pkg-config
     python-X.Y --libs’ (without ‘--embed’) if the previous command
     fails (replace ‘X.Y’ with the Python version).

     On the other hand, ‘pkg-config python3.8 --libs’ no longer contains
     ‘-lpython3.8’.  C extensions must not be linked to libpython
     (except on Android, case handled by the script); this change is
     backward incompatible on purpose.

   - bpo-36786(2): "make install" now runs compileall in parallel.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36721

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36786


File: python.info,  Node: Windows<41>,  Next: macOS<35>,  Prev: Build<46>,  Up: Python 3 8 0 beta 1

1.23.47.7 Windows
.................

   - bpo-36965(1): include of STATUS_CONTROL_C_EXIT without depending on
     MSC compiler

   - bpo-35926(2): Update to OpenSSL 1.1.1b for Windows.

   - bpo-29883(3): Add Windows support for UDP transports for the
     Proactor Event Loop.  Patch by Adam Meily.

   - bpo-33407(4): The *note Py_DEPRECATED(): a72. macro has been
     implemented for MSVC.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36965

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35926

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29883

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33407


File: python.info,  Node: macOS<35>,  Next: IDLE<33>,  Prev: Windows<41>,  Up: Python 3 8 0 beta 1

1.23.47.8 macOS
...............

   - bpo-36231(1): Support building Python on macOS without /usr/include
     installed.  As of macOS 10.14, system header files are only
     available within an SDK provided by either the Command Line Tools
     or the Xcode app.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36231


File: python.info,  Node: IDLE<33>,  Next: Tools/Demos<21>,  Prev: macOS<35>,  Up: Python 3 8 0 beta 1

1.23.47.9 IDLE
..............

   - bpo-35610(1): Replace now redundant .context_use_ps1 with
     .prompt_last_line.  This finishes change started in bpo-31858(2).

   - bpo-37038(3): Make idlelib.run runnable; add test clause.

   - bpo-36958(4): Print any argument other than None or int passed to
     SystemExit or sys.exit().

   - bpo-36807(5): When saving a file, call os.fsync() so bits are
     flushed to e.g.  USB drive.

   - bpo-32411(6): In browser.py, remove extraneous sorting by line
     number since dictionary was created in line number order.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35610

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31858

   (3) https://bugs.python.org/issue?@action=redirect&bpo=37038

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36958

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36807

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32411


File: python.info,  Node: Tools/Demos<21>,  Next: C API<45>,  Prev: IDLE<33>,  Up: Python 3 8 0 beta 1

1.23.47.10 Tools/Demos
......................

   - bpo-37053(1): Handle strings like u"bar" correctly in
     Tools/parser/unparse.py.  Patch by Chih-Hsuan Yen.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=37053


File: python.info,  Node: C API<45>,  Prev: Tools/Demos<21>,  Up: Python 3 8 0 beta 1

1.23.47.11 C API
................

   - bpo-36763(1): Implement the PEP 587(2) "Python Initialization
     Configuration".

   - bpo-36379(3): Fix crashes when attempting to use the 'modulo'
     parameter when ‘__ipow__’ is implemented in C.

   - bpo-37107(4): Update *note PyObject_CallMethodObjArgs(): 1968. and
     ‘_PyObject_CallMethodIdObjArgs’ to use ‘_PyObject_GetMethod’ to
     avoid creating a bound method object in many cases.  Patch by
     Michael J. Sullivan.

   - bpo-36974(5): Implement PEP 590(6): Vectorcall: a fast calling
     protocol for CPython.  This is a new protocol to optimize calls of
     custom callable objects.

   - bpo-36763(7): ‘Py_Main()’ now returns the exitcode rather than
     calling ‘Py_Exit(exitcode)’ when calling ‘PyErr_Print()’ if the
     current exception type is ‘SystemExit’.

   - bpo-36922(8): Add new type flag ‘Py_TPFLAGS_METHOD_DESCRIPTOR’ for
     objects behaving like unbound methods.  These are objects
     supporting the optimization given by the
     ‘LOAD_METHOD’/‘CALL_METHOD’ opcodes.  See PEP 590.

   - bpo-36728(9): The ‘PyEval_ReInitThreads()’ function has been
     removed from the C API. It should not be called explicitly: use
     *note PyOS_AfterFork_Child(): 3d4. instead.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36763

   (2) https://peps.python.org/pep-0587/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36379

   (4) https://bugs.python.org/issue?@action=redirect&bpo=37107

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36974

   (6) https://peps.python.org/pep-0590/

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36763

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36922

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36728


File: python.info,  Node: Python 3 8 0 alpha 4,  Next: Python 3 8 0 alpha 3,  Prev: Python 3 8 0 beta 1,  Up: 変更履歴

1.23.48 Python 3.8.0 alpha 4
----------------------------

'Release date: 2019-05-06'

* Menu:

* Security: Security<32>.
* Core and Builtins: Core and Builtins<48>.
* Library: Library<47>.
* Documentation: Documentation<42>.
* Tests: Tests<44>.
* Build: Build<47>.
* Windows: Windows<42>.
* macOS: macOS<36>.
* IDLE: IDLE<34>.
* Tools/Demos: Tools/Demos<22>.
* C API: C API<46>.


File: python.info,  Node: Security<32>,  Next: Core and Builtins<48>,  Up: Python 3 8 0 alpha 4

1.23.48.1 Security
..................

   - bpo-36742(1): Fixes mishandling of pre-normalization characters in
     urlsplit().

   - bpo-30458(2): Address CVE 2019-9740(3) by disallowing URL paths
     with embedded whitespace or control characters through into the
     underlying http client request.  Such potentially malicious header
     injection URLs now cause an http.client.InvalidURL exception to be
     raised.

   - bpo-35755(4): *note shutil.which(): 480. now uses
     ‘os.confstr("CS_PATH")’ if available and if the ‘PATH’ environment
     variable is not set.  Remove also the current directory from
     ‘posixpath.defpath’.  On Unix, *note shutil.which(): 480. and the
     *note subprocess: c1. module no longer search the executable in the
     current directory if the ‘PATH’ environment variable is not set.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36742

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30458

   (3) https://www.cve.org/CVERecord?id=CVE-2019-9740

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35755


File: python.info,  Node: Core and Builtins<48>,  Next: Library<47>,  Prev: Security<32>,  Up: Python 3 8 0 alpha 4

1.23.48.2 Core and Builtins
...........................

   - bpo-36722(1): In debug build, import now also looks for C
     extensions compiled in release mode and for C extensions compiled
     in the stable ABI.

   - bpo-32849(2): Fix Python Initialization code on FreeBSD to detect
     properly when stdin file descriptor (fd 0) is invalid.

   - bpo-36623(3): Remove parser headers and related function
     declarations that lack implementations after the removal of pgen.

   - bpo-20180(4): ‘dict.pop()’ is now up to 33% faster thanks to
     Argument Clinic.  Patch by Inada Naoki.

   - bpo-36611(5): Debug memory allocators: disable serialno field by
     default from debug hooks on Python memory allocators to reduce the
     memory footprint by 5%.  Enable *note tracemalloc: e8. to get the
     traceback where a memory block has been allocated when a fatal
     memory error is logged to decide where to put a breakpoint.
     Compile Python with ‘PYMEM_DEBUG_SERIALNO’ defined to get back the
     field.

   - bpo-36588(6): On AIX, *note sys.platform: a5b. doesn't contain the
     major version anymore.  Always return ‘'aix'’, instead of ‘'aix3'’
     ..  ‘'aix7'’.  Since older Python versions include the version
     number, it is recommended to always use
     ‘sys.platform.startswith('aix')’.  Contributed by M. Felt.

   - bpo-36549(7): Change str.capitalize to use titlecase for the first
     character instead of uppercase.

   - bpo-36540(8): Implement PEP 570(9) (Python positional-only
     parameters).  Patch by Pablo Galindo.

   - bpo-36475(10): ‘PyEval_AcquireLock()’ and ‘PyEval_AcquireThread()’
     now terminate the current thread if called while the interpreter is
     finalizing, making them consistent with *note
     PyEval_RestoreThread(): 383, *note Py_END_ALLOW_THREADS(): a5c, and
     *note PyGILState_Ensure(): 385.

   - bpo-36504(11): Fix signed integer overflow in _ctypes.c's
     ‘PyCArrayType_new()’.

   - bpo-20844(12): Fix running script with encoding cookie and LF line
     ending may fail on Windows.

   - bpo-24214(13): Fixed support of the surrogatepass error handler in
     the UTF-8 incremental decoder.

   - bpo-36452(14): Changing ‘dict’ keys during iteration of the dict
     itself, ‘keys()’, ‘values()’, or ‘items()’ will now be detected in
     certain corner cases where keys are deleted/added so that the
     number of keys isn't changed.  A ‘RuntimeError’ will be raised
     after ‘len(dict)’ iterations.  Contributed by Thomas Perl.

   - bpo-36459(15): Fix a possible double ‘PyMem_FREE()’ due to
     tokenizer.c's ‘tok_nextc()’.

   - bpo-36433(16): Fixed TypeError message in classmethoddescr_call.

   - bpo-36430(17): Fix a possible reference leak in *note
     itertools.count(): 1254.

   - bpo-36440(18): Include node names in ‘ParserError’ messages,
     instead of numeric IDs.  Patch by A. Skrobov.

   - bpo-36143(19): Regenerate *note keyword: 78. from the Grammar and
     Tokens file using pgen.  Patch by Pablo Galindo.

   - bpo-18372(20): Add missing *note PyObject_GC_Track(): 14af. calls
     in the *note pickle: 95. module.  Patch by Zackery Spytz.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36722

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32849

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36623

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20180

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36611

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36588

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36549

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36540

   (9) https://peps.python.org/pep-0570/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36475

   (11) https://bugs.python.org/issue?@action=redirect&bpo=36504

   (12) https://bugs.python.org/issue?@action=redirect&bpo=20844

   (13) https://bugs.python.org/issue?@action=redirect&bpo=24214

   (14) https://bugs.python.org/issue?@action=redirect&bpo=36452

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36459

   (16) https://bugs.python.org/issue?@action=redirect&bpo=36433

   (17) https://bugs.python.org/issue?@action=redirect&bpo=36430

   (18) https://bugs.python.org/issue?@action=redirect&bpo=36440

   (19) https://bugs.python.org/issue?@action=redirect&bpo=36143

   (20) https://bugs.python.org/issue?@action=redirect&bpo=18372


File: python.info,  Node: Library<47>,  Next: Documentation<42>,  Prev: Core and Builtins<48>,  Up: Python 3 8 0 alpha 4

1.23.48.3 Library
.................

   - bpo-35952(1): Fix pythoninfo when the compiler is missing.

   - bpo-28238(2): The ‘.find*()’ methods of xml.etree.ElementTree can
     now search for wildcards like ‘{*}tag’ and ‘{ns}*’ that match a tag
     in any namespace or all tags in a namespace.  Patch by Stefan
     Behnel.

   - bpo-26978(3): ‘pathlib.path.link_to()’ is now implemented.  It
     creates a hard link pointing to a path.

   - bpo-1613500(4): *note fileinput.FileInput: 702. now uses the input
     file mode to correctly set the output file mode (previously it was
     hardcoded to ‘'w'’) when ‘inplace=True’ is passed to its
     constructor.

   - bpo-36734(5): Fix compilation of ‘faulthandler.c’ on HP-UX.
     Initialize ‘stack_t current_stack’ to zero using ‘memset()’.

   - bpo-13611(6): The xml.etree.ElementTree packages gained support for
     C14N 2.0 serialisation.  Patch by Stefan Behnel.

   - bpo-36669(7): Add missing matrix multiplication operator support to
     weakref.proxy.

   - bpo-36676(8): The XMLParser() in xml.etree.ElementTree provides
     namespace prefix context to the parser target if it defines the
     callback methods "start_ns()" and/or "end_ns()".  Patch by Stefan
     Behnel.

   - bpo-36673(9): The TreeBuilder and XMLPullParser in
     xml.etree.ElementTree gained support for parsing comments and
     processing instructions.  Patch by Stefan Behnel.

   - bpo-36650(10): The C version of functools.lru_cache() was treating
     calls with an empty ‘**kwargs’ dictionary as being distinct from
     calls with no keywords at all.  This did not result in an incorrect
     answer, but it did trigger an unexpected cache miss.

   - bpo-28552(11): Fix ‘distutils.sysconfig’ if *note sys.executable:
     392. is ‘None’ or an empty string: use *note os.getcwd(): 1503. to
     initialize ‘project_base’.  Fix also the distutils build command:
     don't use *note sys.executable: 392. if it is ‘None’ or an empty
     string.

   - bpo-35755(12): *note shutil.which(): 480. and
     ‘distutils.spawn.find_executable’ now use ‘os.confstr("CS_PATH")’
     if available instead of *note os.defpath: 196d, if the ‘PATH’
     environment variable is not set.  Moreover, don't use
     ‘os.confstr("CS_PATH")’ nor *note os.defpath: 196d. if the ‘PATH’
     environment variable is set to an empty string.

   - bpo-25430(13): improve performance of ‘IPNetwork.__contains__()’

   - bpo-30485(14): Path expressions in xml.etree.ElementTree can now
     avoid explicit namespace prefixes for tags (or the "{namespace}tag"
     notation) by passing a default namespace with an empty string
     prefix.

   - bpo-36613(15): Fix *note asyncio: 8. wait() not removing callback
     if exception

   - bpo-36598(16): Fix ‘isinstance’ check for Mock objects with spec
     when the code is executed under tracing.  Patch by Karthikeyan
     Singaravelan.

   - bpo-18748(17): In development mode (*note -X: 15c. ‘dev’) and in
     debug build, the *note io.IOBase: 1d6. destructor now logs
     ‘close()’ exceptions.  These exceptions are silent by default in
     release mode.

   - bpo-36575(18): The ‘_lsprof’ module now uses internal timer same to
     ‘time.perf_counter()’ by default.  ‘gettimeofday(2)’ was used on
     Unix.  New timer has better resolution on most Unix platforms and
     timings are no longer impacted by system clock updates since
     ‘perf_counter()’ is monotonic.  Patch by Inada Naoki.

   - bpo-33461(19): ‘json.loads’ now emits ‘DeprecationWarning’ when
     ‘encoding’ option is specified.  Patch by Matthias Bussonnier.

   - bpo-36559(20): The random module now prefers the lean internal
     _sha512 module over hashlib for seed(version=2) to optimize import
     time.

   - bpo-17561(21): Set backlog=None as the default for
     socket.create_server.

   - bpo-34373(22): Fix *note time.mktime(): 11b9. error handling on AIX
     for year before 1970.

   - bpo-36232(23): Improve error message when trying to open existing
     DBM database that actually doesn't exist.  Patch by Marco Rougeth.

   - bpo-36546(24): Add statistics.quantiles()

   - bpo-36050(25): Optimized ‘http.client.HTTPResponse.read()’ for
     large response.  Patch by Inada Naoki.

   - bpo-36522(26): If 'debuglevel' is set to >0 in *note http.client:
     65, print all values for headers with multiple values for the same
     header name.  Patch by Matt Houglum.

   - bpo-36492(27): Deprecated passing required arguments like 'func' as
     keyword arguments in functions which should accept arbitrary
     keyword arguments and pass them to other function.  Arbitrary
     keyword arguments (even with names "self" and "func") can now be
     passed to these functions if the required arguments are passed as
     positional arguments.

   - bpo-27181(28): Add statistics.geometric_mean().

   - bpo-30427(29): ‘os.path.normcase()’ relies on ‘os.fspath()’ to
     check the type of its argument.  Redundant checks have been removed
     from its ‘posixpath.normcase()’ and ‘ntpath.normcase()’
     implementations.  Patch by Wolfgang Maier.

   - bpo-36385(30): Stop rejecting IPv4 octets for being ambiguously
     octal.  Leading zeros are ignored, and no longer are assumed to
     specify octal octets.  Octets are always decimal numbers.  Octets
     must still be no more than three digits, including leading zeroes.

   - bpo-36434(31): Errors during writing to a ZIP file no longer
     prevent to properly close it.

   - bpo-36407(32): Fixed wrong indentation writing for CDATA section in
     xml.dom.minidom.  Patch by Vladimir Surjaninov.

   - bpo-36326(33): inspect.getdoc() can now find docstrings for member
     objects when __slots__ is a dictionary.

   - bpo-36366(34): Calling ‘stop()’ on an unstarted or stopped *note
     unittest.mock.patch(): e5b. object will now return ‘None’ instead
     of raising *note RuntimeError: 17a, making the method idempotent.
     Patch by Karthikeyan Singaravelan.

   - bpo-36348(35): The ‘imap.IMAP4.logout()’ method no longer ignores
     silently arbitrary exceptions.

   - bpo-31904(36): Add time module support and fix test_time failures
     for VxWorks.

   - bpo-36227(37): Added support for keyword arguments
     ‘default_namespace’ and ‘xml_declaration’ in functions
     ‘ElementTree.tostring()’ and ‘ElementTree.tostringlist()’.

   - bpo-36004(38): Added new alternate constructors *note
     datetime.date.fromisocalendar(): 9ba. and *note
     datetime.datetime.fromisocalendar(): 9bb, which construct date
     objects from ISO year, week number and weekday; these are the
     inverse of each class's ‘isocalendar’ method.  Patch by Paul
     Ganssle.

   - bpo-35936(39): *note modulefinder: 84. no longer depends on the
     deprecated ‘imp’ module, and the initializer for *note
     modulefinder.ModuleFinder: 196e. now has immutable default
     arguments.  Patch by Brandt Bucher.

   - bpo-35376(40): *note modulefinder: 84. correctly handles modules
     that have the same name as a bad package.  Patch by Brandt Bucher.

   - bpo-17396(41): *note modulefinder: 84. no longer crashes when
     encountering syntax errors in followed imports.  Patch by Brandt
     Bucher.

   - bpo-35934(42): Added *note create_server(): 9f9. and *note
     has_dualstack_ipv6(): 9fa. convenience functions to automate the
     necessary tasks usually involved when creating a server socket,
     including accepting both IPv4 and IPv6 connections on the same
     socket.  (Contributed by Giampaolo Rodola in bpo-17561(43).)

   - bpo-23078(44): Add support for *note classmethod(): 14c. and *note
     staticmethod(): 3ef. to *note unittest.mock.create_autospec():
     156b.  Initial patch by Felipe Ochoa.

   - bpo-35416(45): Fix potential resource warnings in distutils.  Patch
     by Mickaël Schoentgen.

   - bpo-25451(46): Add transparency methods to ‘tkinter.PhotoImage’.
     Patch by Zackery Spytz.

   - bpo-35082(47): Don't return deleted attributes when calling dir on
     a *note unittest.mock.Mock: a1a.

   - bpo-34547(48): *note wsgiref.handlers.BaseHandler: 195b. now
     handles abrupt client connection terminations gracefully.  Patch by
     Petter Strandmark.

   - bpo-31658(49): *note xml.sax.parse(): 196f. now supports *note
     path-like: 280.  Patch by Mickaël Schoentgen.

   - bpo-34139(50): Remove stale unix datagram socket before binding

   - bpo-33530(51): Implemented Happy Eyeballs in
     ‘asyncio.create_connection()’.  Added two new arguments,
     'happy_eyeballs_delay' and 'interleave', to specify Happy Eyeballs
     behavior.

   - bpo-33291(52): Do not raise AttributeError when calling the inspect
     functions isgeneratorfunction, iscoroutinefunction,
     isasyncgenfunction on a method created from an arbitrary callable.
     Instead, return False.

   - bpo-31310(53): Fix the multiprocessing.semaphore_tracker so it is
     reused by child processes

   - bpo-31292(54): Fix ‘setup.py check --restructuredtext’ for files
     containing ‘include’ directives.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35952

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28238

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26978

   (4) https://bugs.python.org/issue?@action=redirect&bpo=1613500

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36734

   (6) https://bugs.python.org/issue?@action=redirect&bpo=13611

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36669

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36676

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36673

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36650

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28552

   (12) https://bugs.python.org/issue?@action=redirect&bpo=35755

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25430

   (14) https://bugs.python.org/issue?@action=redirect&bpo=30485

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36613

   (16) https://bugs.python.org/issue?@action=redirect&bpo=36598

   (17) https://bugs.python.org/issue?@action=redirect&bpo=18748

   (18) https://bugs.python.org/issue?@action=redirect&bpo=36575

   (19) https://bugs.python.org/issue?@action=redirect&bpo=33461

   (20) https://bugs.python.org/issue?@action=redirect&bpo=36559

   (21) https://bugs.python.org/issue?@action=redirect&bpo=17561

   (22) https://bugs.python.org/issue?@action=redirect&bpo=34373

   (23) https://bugs.python.org/issue?@action=redirect&bpo=36232

   (24) https://bugs.python.org/issue?@action=redirect&bpo=36546

   (25) https://bugs.python.org/issue?@action=redirect&bpo=36050

   (26) https://bugs.python.org/issue?@action=redirect&bpo=36522

   (27) https://bugs.python.org/issue?@action=redirect&bpo=36492

   (28) https://bugs.python.org/issue?@action=redirect&bpo=27181

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30427

   (30) https://bugs.python.org/issue?@action=redirect&bpo=36385

   (31) https://bugs.python.org/issue?@action=redirect&bpo=36434

   (32) https://bugs.python.org/issue?@action=redirect&bpo=36407

   (33) https://bugs.python.org/issue?@action=redirect&bpo=36326

   (34) https://bugs.python.org/issue?@action=redirect&bpo=36366

   (35) https://bugs.python.org/issue?@action=redirect&bpo=36348

   (36) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (37) https://bugs.python.org/issue?@action=redirect&bpo=36227

   (38) https://bugs.python.org/issue?@action=redirect&bpo=36004

   (39) https://bugs.python.org/issue?@action=redirect&bpo=35936

   (40) https://bugs.python.org/issue?@action=redirect&bpo=35376

   (41) https://bugs.python.org/issue?@action=redirect&bpo=17396

   (42) https://bugs.python.org/issue?@action=redirect&bpo=35934

   (43) https://bugs.python.org/issue?@action=redirect&bpo=17561

   (44) https://bugs.python.org/issue?@action=redirect&bpo=23078

   (45) https://bugs.python.org/issue?@action=redirect&bpo=35416

   (46) https://bugs.python.org/issue?@action=redirect&bpo=25451

   (47) https://bugs.python.org/issue?@action=redirect&bpo=35082

   (48) https://bugs.python.org/issue?@action=redirect&bpo=34547

   (49) https://bugs.python.org/issue?@action=redirect&bpo=31658

   (50) https://bugs.python.org/issue?@action=redirect&bpo=34139

   (51) https://bugs.python.org/issue?@action=redirect&bpo=33530

   (52) https://bugs.python.org/issue?@action=redirect&bpo=33291

   (53) https://bugs.python.org/issue?@action=redirect&bpo=31310

   (54) https://bugs.python.org/issue?@action=redirect&bpo=31292


File: python.info,  Node: Documentation<42>,  Next: Tests<44>,  Prev: Library<47>,  Up: Python 3 8 0 alpha 4

1.23.48.4 Documentation
.......................

   - bpo-36625(1): Remove obsolete comments from docstrings in
     fractions.Fraction

   - bpo-30840(2): Document relative imports

   - bpo-36523(3): Add docstring for io.IOBase.writelines().

   - bpo-36425(4): New documentation translation: Simplified Chinese(5).

   - bpo-36345(6): Avoid the duplication of code from
     ‘Tools/scripts/serve.py’ in using the ‘literalinclude’ directive
     for the basic wsgiref-based web server in the documentation of
     *note wsgiref: 100.  Contributed by Stéphane Wirtel.

   - bpo-36345(7): Using the code of the ‘Tools/scripts/serve.py’ script
     as an example in the *note wsgiref: 100. documentation.
     Contributed by Stéphane Wirtel.

   - bpo-36157(8): Added documentation for PyInterpreterState_Main().

   - bpo-33043(9): Updates the docs.python.org page with the addition of
     a 'Contributing to Docs' link at the end of the page (between
     'Reporting Bugs' and 'About Documentation').  Updates the 'Found a
     Bug' page with additional links and information in the
     Documentation Bugs section.

   - bpo-35581(10): @typing.type_check_only now allows type stubs to
     mark functions and classes not available during runtime.

   - bpo-33832(11): Add glossary entry for 'magic method'.

   - bpo-32913(12): Added re.Match.groupdict example to regex HOWTO.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36625

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30840

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36523

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36425

   (5) https://docs.python.org/zh-cn/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36345

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36345

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36157

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33043

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35581

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33832

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32913


File: python.info,  Node: Tests<44>,  Next: Build<47>,  Prev: Documentation<42>,  Up: Python 3 8 0 alpha 4

1.23.48.5 Tests
...............

   - bpo-36719(1): regrtest now always detects uncollectable objects.
     Previously, the check was only enabled by ‘--findleaks’.  The check
     now also works with ‘-jN/--multiprocess N’.  ‘--findleaks’ becomes
     a deprecated alias to ‘--fail-env-changed’.

   - bpo-36725(2): When using multiprocessing mode (-jN), regrtest now
     better reports errors if a worker process fails, and it exits
     immediately on a worker thread failure or when interrupted.

   - bpo-36454(3): Change test_time.test_monotonic() to test only the
     lower bound of elapsed time after a sleep command rather than the
     upper bound.  This prevents unnecessary test failures on slow
     buildbots.  Patch by Victor Stinner.

   - bpo-32424(4): Improve test coverage for xml.etree.ElementTree.
     Patch by Gordon P. Hemsley.

   - bpo-32424(5): Fix typo in test_cyclic_gc() test for
     xml.etree.ElementTree.  Patch by Gordon P. Hemsley.

   - bpo-36635(6): Add a new ‘_testinternalcapi’ module to test the
     internal C API.

   - bpo-36629(7): Fix ‘test_imap4_host_default_value()’ of
     ‘test_imaplib’: catch also *note errno.ENETUNREACH: 1972. error.

   - bpo-36611(8): Fix ‘test_sys.test_getallocatedblocks()’ when *note
     tracemalloc: e8. is enabled.

   - bpo-36560(9): Fix reference leak hunting in regrtest: compute also
     deltas (of reference count, allocated memory blocks, file
     descriptor count) during warmup, to ensure that everything is
     initialized before starting to hunt reference leaks.

   - bpo-36565(10): Fix reference hunting (‘python3 -m test -R 3:3’)
     when Python has no built-in abc module.

   - bpo-31904(11): Port test_resource to VxWorks: skip tests cases
     setting RLIMIT_FSIZE and RLIMIT_CPU.

   - bpo-31904(12): Fix test_tabnanny on VxWorks: adjust ENOENT error
     message.

   - bpo-36436(13): Fix ‘_testcapi.pymem_buffer_overflow()’: handle
     memory allocation failure.

   - bpo-31904(14): Fix test_utf8_mode on VxWorks: Python always use
     UTF-8 on VxWorks.

   - bpo-36341(15): Fix tests that may fail with PermissionError upon
     calling bind() on AF_UNIX sockets.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36719

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36725

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36454

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32424

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32424

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36635

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36629

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36611

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36560

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36565

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (13) https://bugs.python.org/issue?@action=redirect&bpo=36436

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36341


File: python.info,  Node: Build<47>,  Next: Windows<42>,  Prev: Tests<44>,  Up: Python 3 8 0 alpha 4

1.23.48.6 Build
...............

   - bpo-36747(1): Remove the stale scriptsinstall Makefile target.

   - bpo-21536(2): On Unix, C extensions are no longer linked to
     libpython except on Android and Cygwin.

     It is now possible for a statically linked Python to load a C
     extension built using a shared library Python.

     When Python is embedded, ‘libpython’ must not be loaded with
     ‘RTLD_LOCAL’, but ‘RTLD_GLOBAL’ instead.  Previously, using
     ‘RTLD_LOCAL’, it was already not possible to load C extensions
     which were not linked to ‘libpython’, such as C extensions of the
     standard library built by the ‘*shared*’ section of
     ‘Modules/Setup’.

     distutils, python-config and python-config.py have been modified.

   - bpo-36707(3): ‘./configure --with-pymalloc’ no longer adds the ‘m’
     flag to SOABI (sys.implementation.cache_tag).  Enabling or
     disabling pymalloc has no impact on the ABI.

   - bpo-36635(4): Change ‘PyAPI_FUNC(type)’, ‘PyAPI_DATA(type)’ and
     ‘PyMODINIT_FUNC’ macros of ‘pyport.h’ when ‘Py_BUILD_CORE_MODULE’
     is defined.  The ‘Py_BUILD_CORE_MODULE’ define must be now be used
     to build a C extension as a dynamic library accessing Python
     internals: export the ‘PyInit_XXX()’ function in DLL exports on
     Windows.

   - bpo-31904(5): Don't build the ‘_crypt’ extension on VxWorks.

   - bpo-36618(6): Add ‘-fmax-type-align=8’ to CFLAGS when clang
     compiler is detected.  The pymalloc memory allocator aligns memory
     on 8 bytes.  On x86-64, clang expects alignment on 16 bytes by
     default and so uses MOVAPS instruction which can lead to
     segmentation fault.  Instruct clang that Python is limited to
     alignment on 8 bytes to use MOVUPS instruction instead: slower but
     don't trigger a SIGSEGV if the memory is not aligned on 16 bytes.
     Sadly, the flag must be added to ‘CFLAGS’ and not just
     ‘CFLAGS_NODIST’, since third party C extensions can have the same
     issue.

   - bpo-36605(7): ‘make tags’ and ‘make TAGS’ now also parse
     ‘Modules/_io/*.c’ and ‘Modules/_io/*.h’.

   - bpo-36465(8): Release builds and debug builds are now ABI
     compatible: defining the ‘Py_DEBUG’ macro no longer implies the
     ‘Py_TRACE_REFS’ macro, which introduces the only ABI
     incompatibility.  The ‘Py_TRACE_REFS’ macro, which adds the *note
     sys.getobjects(): 3fe. function and the *note PYTHONDUMPREFS: 974.
     environment variable, can be set using the new ‘./configure
     --with-trace-refs’ build option.

   - bpo-36577(9): setup.py now correctly reports missing OpenSSL
     headers and libraries again.

   - bpo-36544(10): Fix regression introduced in bpo-36146(11)
     refactoring setup.py

   - bpo-36508(12): ‘python-config --ldflags’ no longer includes flags
     of the ‘LINKFORSHARED’ variable.  The ‘LINKFORSHARED’ variable must
     only be used to build executables.

   - bpo-36503(13): Remove references to "aix3" and "aix4".  Patch by M.
     Felt.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36747

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21536

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36707

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36635

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36618

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36605

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36465

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36577

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36544

   (11) https://bugs.python.org/issue?@action=redirect&bpo=36146

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36508

   (13) https://bugs.python.org/issue?@action=redirect&bpo=36503


File: python.info,  Node: Windows<42>,  Next: macOS<36>,  Prev: Build<47>,  Up: Python 3 8 0 alpha 4

1.23.48.7 Windows
.................

   - bpo-35920(1): Added platform.win32_edition() and
     platform.win32_is_iot().  Added support for cross-compiling
     packages for Windows ARM32.  Skip tests that are not expected to
     work on Windows IoT Core ARM32.

   - bpo-36649(2): Remove trailing spaces for registry keys when
     installed via the Store.

   - bpo-34144(3): Fixed activate.bat to correctly update codepage when
     chcp.com returns dots in output.  Patch by Lorenz Mende.

   - bpo-36509(4): Added preset-iot layout for Windows IoT ARM
     containers.  This layout doesn't contain UI components like tkinter
     or IDLE. It also doesn't contain files to support on-target builds
     since Windows ARM32 builds must be cross-compiled when using MSVC.

   - bpo-35941(5): enum_certificates function of the ssl module now
     returns certificates from all available certificate stores inside
     windows in a query instead of returning only certificates from the
     system wide certificate store.  This includes certificates from
     these certificate stores: local machine, local machine enterprise,
     local machine group policy, current user, current user group
     policy, services, users.  ssl.enum_crls() function is changed in
     the same way to return all certificate revocation lists inside the
     windows certificate revocation list stores.

   - bpo-36441(6): Fixes creating a venv when debug binaries are
     installed.

   - bpo-36085(7): Enable better DLL resolution on Windows by using safe
     DLL search paths and adding *note os.add_dll_directory(): 9b8.

   - bpo-36010(8): Add the venv standard library module to the nuget
     distribution for Windows.

   - bpo-29515(9): Add the following socket module constants on Windows:
     IPPROTO_AH IPPROTO_CBT IPPROTO_DSTOPTS IPPROTO_EGP IPPROTO_ESP
     IPPROTO_FRAGMENT IPPROTO_GGP IPPROTO_HOPOPTS IPPROTO_ICLFXBM
     IPPROTO_ICMPV6 IPPROTO_IDP IPPROTO_IGMP IPPROTO_IGP IPPROTO_IPV4
     IPPROTO_IPV6 IPPROTO_L2TP IPPROTO_MAX IPPROTO_ND IPPROTO_NONE
     IPPROTO_PGM IPPROTO_PIM IPPROTO_PUP IPPROTO_RDP IPPROTO_ROUTING
     IPPROTO_SCTP IPPROTO_ST

   - bpo-35947(10): Added current version of libffi to
     cpython-source-deps.  Change _ctypes to use current version of
     libffi on Windows.

   - bpo-34060(11): Report system load when running test suite on
     Windows.  Patch by Ammar Askar.  Based on prior work by Jeremy
     Kloth.

   - bpo-31512(12): With the Windows 10 Creators Update, non-elevated
     users can now create symlinks as long as the computer has Developer
     Mode enabled.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35920

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36649

   (3) https://bugs.python.org/issue?@action=redirect&bpo=34144

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36509

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35941

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36441

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36085

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36010

   (9) https://bugs.python.org/issue?@action=redirect&bpo=29515

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35947

   (11) https://bugs.python.org/issue?@action=redirect&bpo=34060

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31512


File: python.info,  Node: macOS<36>,  Next: IDLE<34>,  Prev: Windows<42>,  Up: Python 3 8 0 alpha 4

1.23.48.8 macOS
...............

   - bpo-34602(1): Avoid failures setting macOS stack resource limit
     with resource.setrlimit.  This reverts an earlier fix for
     bpo-18075(2) which forced a non-default stack size when building
     the interpreter executable on macOS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34602

   (2) https://bugs.python.org/issue?@action=redirect&bpo=18075


File: python.info,  Node: IDLE<34>,  Next: Tools/Demos<22>,  Prev: macOS<36>,  Up: Python 3 8 0 alpha 4

1.23.48.9 IDLE
..............

   - bpo-36429(1): Fix starting IDLE with pyshell.  Add idlelib.pyshell
     alias at top; remove pyshell alias at bottom.  Remove obsolete
     __name__=='__main__' command.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36429


File: python.info,  Node: Tools/Demos<22>,  Next: C API<46>,  Prev: IDLE<34>,  Up: Python 3 8 0 alpha 4

1.23.48.10 Tools/Demos
......................

   - bpo-14546(1): Fix the argument handling in Tools/scripts/lll.py.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14546


File: python.info,  Node: C API<46>,  Prev: Tools/Demos<22>,  Up: Python 3 8 0 alpha 4

1.23.48.11 C API
................

   - bpo-36763(1): Fix memory leak in ‘Py_SetStandardStreamEncoding()’:
     release memory if the function is called twice.

   - bpo-36641(2): PyDoc_VAR(name) and *note PyDoc_STRVAR: 18dd.(name,
     str) now create ‘static const char name[]’ instead of ‘static char
     name[]’.  Patch by Inada Naoki.

   - bpo-36389(3): Change the value of ‘CLEANBYTE’, ‘DEADDYTE’ and
     ‘FORBIDDENBYTE’ internal constants used by debug hooks on Python
     memory allocators (*note PyMem_SetupDebugHooks(): c38. function).
     Byte patterns ‘0xCB’, ‘0xDB’ and ‘0xFB’ have been replaced with
     ‘0xCD’, ‘0xDD’ and ‘0xFD’ to use the same values than Windows CRT
     debug ‘malloc()’ and ‘free()’.

   - bpo-36443(4): Since Python 3.7.0, calling *note Py_DecodeLocale():
     b95. before *note Py_Initialize(): 87a. produces mojibake if the
     ‘LC_CTYPE’ locale is coerced and/or if the UTF-8 Mode is enabled by
     the user configuration.  The LC_CTYPE coercion and UTF-8 Mode are
     now disabled by default to fix the mojibake issue.  They must now
     be enabled explicitly (opt-in) using the new ‘_Py_PreInitialize()’
     API with ‘_PyPreConfig’.

   - bpo-36025(5): Fixed an accidental change to the datetime C API
     where the arguments to the *note PyDate_FromTimestamp(): 1979.
     function were incorrectly interpreted as a single timestamp rather
     than an arguments tuple, which causes existing code to start
     raising *note TypeError: 502.  The backwards-incompatible change
     was only present in alpha releases of Python 3.8.  Patch by Paul
     Ganssle.

   - bpo-35810(6): Modify ‘PyObject_Init’ to correctly increase the
     refcount of heap-allocated Type objects.  Also fix the refcounts of
     the heap-allocated types that were either doing this manually or
     not decreasing the type's refcount in tp_dealloc

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36763

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36641

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36389

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36443

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36025

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35810


File: python.info,  Node: Python 3 8 0 alpha 3,  Next: Python 3 8 0 alpha 2,  Prev: Python 3 8 0 alpha 4,  Up: 変更履歴

1.23.49 Python 3.8.0 alpha 3
----------------------------

'Release date: 2019-03-25'

* Menu:

* Security: Security<33>.
* Core and Builtins: Core and Builtins<49>.
* Library: Library<48>.
* Documentation: Documentation<43>.
* Tests: Tests<45>.
* Build: Build<48>.
* Windows: Windows<43>.
* IDLE: IDLE<35>.
* Tools/Demos: Tools/Demos<23>.
* C API: C API<47>.


File: python.info,  Node: Security<33>,  Next: Core and Builtins<49>,  Up: Python 3 8 0 alpha 3

1.23.49.1 Security
..................

   - bpo-36216(1): Changes urlsplit() to raise ValueError when the URL
     contains characters that decompose under IDNA encoding
     (NFKC-normalization) into characters that affect how the URL is
     parsed.

   - bpo-35121(2): Don't send cookies of domain A without Domain
     attribute to domain B when domain A is a suffix match of domain B
     while using a cookiejar with *note
     http.cookiejar.DefaultCookiePolicy: 197c. policy.  Patch by
     Karthikeyan Singaravelan.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36216

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35121


File: python.info,  Node: Core and Builtins<49>,  Next: Library<48>,  Prev: Security<33>,  Up: Python 3 8 0 alpha 3

1.23.49.2 Core and Builtins
...........................

   - bpo-36421(1): Fix a possible double decref in _ctypes.c's
     ‘PyCArrayType_new()’.

   - bpo-36412(2): Fix a possible crash when creating a new dictionary.

   - bpo-36398(3): Fix a possible crash in ‘structseq_repr()’.

   - bpo-36256(4): Fix bug in parsermodule when parsing a state in a DFA
     that has two or more arcs with labels of the same type.  Patch by
     Pablo Galindo.

   - bpo-36365(5): repr(structseq) is no longer limited to 512 bytes.

   - bpo-36374(6): Fix a possible null pointer dereference in
     ‘merge_consts_recursive()’.  Patch by Zackery Spytz.

   - bpo-36236(7): At Python initialization, the current directory is no
     longer prepended to *note sys.path: 38e. if it has been removed.

   - bpo-36352(8): Python initialization now fails with an error, rather
     than silently truncating paths, if a path is too long.

   - bpo-36301(9): Python initialization now fails if decoding
     ‘pybuilddir.txt’ configuration file fails at startup.

   - bpo-36333(10): Fix leak in _PyRuntimeState_Fini.  Contributed by
     Stéphane Wirtel.

   - bpo-36332(11): The builtin *note compile(): 177. can now handle AST
     objects that contain assignment expressions.  Patch by Pablo
     Galindo.

   - bpo-36282(12): Improved error message for too much positional
     arguments in some builtin functions.

   - bpo-30040(13): New empty dict uses fewer memory for now.  It used
     more memory than empty dict created by ‘dict.clear()’.  And empty
     dict creation and deletion is about 2x faster.  Patch by Inada
     Naoki.

   - bpo-36262(14): Fix an unlikely memory leak on conversion from
     string to float in the function ‘_Py_dg_strtod()’ used by
     ‘float(str)’, ‘complex(str)’, *note pickle.load(): cde, *note
     marshal.load(): 197e, etc.

   - bpo-36252(15): Update Unicode databases to version 12.0.0.

   - bpo-36218(16): Fix a segfault occurring when sorting a list of
     heterogeneous values.  Patch contributed by Rémi Lapeyre and Elliot
     Gorokhovsky.

   - bpo-36188(17): Cleaned up left-over vestiges of Python 2 unbound
     method handling in method objects and documentation.  Patch by
     Martijn Pieters

   - bpo-36124(18): Add a new interpreter-specific dict and expose it in
     the C-API via PyInterpreterState_GetDict().  This parallels
     PyThreadState_GetDict().  However, extension modules should
     continue using PyModule_GetState() for their own internal
     per-interpreter state.

   - bpo-35975(19): Add a ‘feature_version’ flag to ‘ast.parse()’
     (documented) and ‘compile()’ (hidden) that allows tweaking the
     parser to support older versions of the grammar.  In particular, if
     ‘feature_version’ is 5 or 6, the hacks for the ‘async’ and ‘await’
     keyword from PEP 492 are reinstated.  (For 7 or higher, these are
     unconditionally treated as keywords, but they are still special
     tokens rather than ‘NAME’ tokens that the parser driver
     recognizes.)

   - bpo-31904(20): Use UTF-8 as the system encoding on VxWorks.

   - bpo-36048(21): The *note __index__(): 6e8. special method will be
     used instead of *note __int__(): 6e7. for implicit conversion of
     Python numbers to C integers.  Using the ‘__int__()’ method in
     implicit conversions has been deprecated.

   - bpo-35808(22): Retire pgen and use a modified version of pgen2 to
     generate the parser.  Patch by Pablo Galindo.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36421

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36412

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36398

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36256

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36365

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36374

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36236

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36352

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36301

   (10) https://bugs.python.org/issue?@action=redirect&bpo=36333

   (11) https://bugs.python.org/issue?@action=redirect&bpo=36332

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36282

   (13) https://bugs.python.org/issue?@action=redirect&bpo=30040

   (14) https://bugs.python.org/issue?@action=redirect&bpo=36262

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36252

   (16) https://bugs.python.org/issue?@action=redirect&bpo=36218

   (17) https://bugs.python.org/issue?@action=redirect&bpo=36188

   (18) https://bugs.python.org/issue?@action=redirect&bpo=36124

   (19) https://bugs.python.org/issue?@action=redirect&bpo=35975

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (21) https://bugs.python.org/issue?@action=redirect&bpo=36048

   (22) https://bugs.python.org/issue?@action=redirect&bpo=35808


File: python.info,  Node: Library<48>,  Next: Documentation<43>,  Prev: Core and Builtins<49>,  Up: Python 3 8 0 alpha 3

1.23.49.3 Library
.................

   - bpo-36401(1): The class documentation created by pydoc now has a
     separate section for readonly properties.

   - bpo-36320(2): The typing.NamedTuple() class has deprecated the
     _field_types attribute in favor of the __annotations__ attribute
     which carried the same information.  Also, both attributes were
     converted from OrderedDict to a regular dict.

   - bpo-34745(3): Fix *note asyncio: 8. ssl memory issues caused by
     circular references

   - bpo-36324(4): Add method to statistics.NormalDist for computing the
     inverse cumulative normal distribution.

   - bpo-36321(5): collections.namedtuple() misspelled the name of an
     attribute.  To be consistent with typing.NamedTuple, the attribute
     name should have been "_field_defaults" instead of
     "_fields_defaults".  For backwards compatibility, both spellings
     are now created.  The misspelled version may be removed in the
     future.

   - bpo-36297(6): "unicode_internal" codec is removed.  It was
     deprecated since Python 3.3.  Patch by Inada Naoki.

   - bpo-36298(7): Raise ModuleNotFoundError in pyclbr when a module
     can't be found.  Thanks to 'mental' for the bug report.

   - bpo-36268(8): Switch the default format used for writing tars with
     *note tarfile: c8. to the modern POSIX.1-2001 pax standard, from
     the vendor-specific GNU. Contributed by C.A.M. Gerlach.

   - bpo-36285(9): Fix integer overflows in the array module.  Patch by
     Stephan Hohe.

   - bpo-31904(10): Add _signal module support for VxWorks.

   - bpo-36272(11): *note logging: 7b. does not silently ignore
     RecursionError anymore.  Patch contributed by Rémi Lapeyre.

   - bpo-36280(12): Add a kind field to ast.Constant.  It is 'u' if the
     literal has a 'u' prefix (i.e.  a Python 2 style unicode literal),
     else None.

   - bpo-35931(13): The *note pdb: 94. ‘debug’ command now gracefully
     handles all exceptions.

   - bpo-36251(14): Fix format strings used for stderrprinter and
     re.Match reprs.  Patch by Stephan Hohe.

   - bpo-36235(15): Fix ‘CFLAGS’ in ‘customize_compiler()’ of
     ‘distutils.sysconfig’: when the ‘CFLAGS’ environment variable is
     defined, don't override ‘CFLAGS’ variable with the ‘OPT’ variable
     anymore.  Initial patch written by David Malcolm.

   - bpo-35807(16): Update ensurepip to install pip 19.0.3 and
     setuptools 40.8.0.

   - bpo-36139(17): Release GIL when closing *note mmap: 1ec. objects.

   - bpo-36179(18): Fix two unlikely reference leaks in _hashopenssl.
     The leaks only occur in out-of-memory cases.

   - bpo-36169(19): Add overlap() method to statistics.NormalDist.
     Computes the overlapping coefficient for two normal distributions.

   - bpo-36103(20): Default buffer size used by ‘shutil.copyfileobj()’
     is changed from 16 KiB to 64 KiB on non-Windows platform to reduce
     system call overhead.  Contributed by Inada Naoki.

   - bpo-36130(21): Fix ‘pdb’ with ‘skip=...’ when stepping into a frame
     without a ‘__name__’ global.  Patch by Anthony Sottile.

   - bpo-35652(22): shutil.copytree(copy_function=...)  erroneously pass
     DirEntry instead of a path string.

   - bpo-35178(23): Ensure custom *note warnings.formatwarning(): 1980.
     function can receive ‘line’ as positional argument.  Based on patch
     by Tashrif Billah.

   - bpo-36106(24): Resolve potential name clash with libm's sinpi().
     Patch by Dmitrii Pasechnik.

   - bpo-36091(25): Clean up reference to async generator in Lib/types.
     Patch by Henry Chen.

   - bpo-36043(26): ‘FileCookieJar’ supports *note path-like object:
     280.  Contributed by Stéphane Wirtel

   - bpo-35899(27): Enum has been fixed to correctly handle empty
     strings and strings with non-Latin characters (ie.  'α', 'א')
     without crashing.  Original patch contributed by Maxwell.  Assisted
     by Stéphane Wirtel.

   - bpo-21269(28): Add ‘args’ and ‘kwargs’ properties to mock call
     objects.  Contributed by Kumar Akshay.

   - bpo-30670(29): ‘pprint.pp’ has been added to pretty-print objects
     with dictionary keys being sorted with their insertion order by
     default.  Parameter 'sort_dicts' has been added to ‘pprint.pprint’,
     ‘pprint.pformat’ and ‘pprint.PrettyPrinter’.  Contributed by Rémi
     Lapeyre.

   - bpo-35843(30): Implement ‘__getitem__’ for ‘_NamespacePath’.  Patch
     by Anthony Sottile.

   - bpo-35802(31): Clean up code which checked presence of ‘os.stat’ /
     ‘os.lstat’ / ‘os.chmod’ which are always present.  Patch by Anthony
     Sottile.

   - bpo-35715(32): Librates the return value of a ProcessPoolExecutor
     _process_worker after it's no longer needed to free memory

   - bpo-35493(33): Use *note multiprocessing.connection.wait(): 10b3.
     instead of polling each 0.2 seconds for worker updates in
     ‘multiprocessing.Pool’.  Patch by Pablo Galindo.

   - bpo-35661(34): Store the venv prompt in pyvenv.cfg.

   - bpo-35121(35): Don't set cookie for a request when the request path
     is a prefix match of the cookie's path attribute but doesn't end
     with "/".  Patch by Karthikeyan Singaravelan.

   - bpo-21478(36): Calls to a child function created with *note
     unittest.mock.create_autospec(): 156b. should propagate to the
     parent.  Patch by Karthikeyan Singaravelan.

   - bpo-35198(37): Fix C++ extension compilation on AIX

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36401

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36320

   (3) https://bugs.python.org/issue?@action=redirect&bpo=34745

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36324

   (5) https://bugs.python.org/issue?@action=redirect&bpo=36321

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36297

   (7) https://bugs.python.org/issue?@action=redirect&bpo=36298

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36268

   (9) https://bugs.python.org/issue?@action=redirect&bpo=36285

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31904

   (11) https://bugs.python.org/issue?@action=redirect&bpo=36272

   (12) https://bugs.python.org/issue?@action=redirect&bpo=36280

   (13) https://bugs.python.org/issue?@action=redirect&bpo=35931

   (14) https://bugs.python.org/issue?@action=redirect&bpo=36251

   (15) https://bugs.python.org/issue?@action=redirect&bpo=36235

   (16) https://bugs.python.org/issue?@action=redirect&bpo=35807

   (17) https://bugs.python.org/issue?@action=redirect&bpo=36139

   (18) https://bugs.python.org/issue?@action=redirect&bpo=36179

   (19) https://bugs.python.org/issue?@action=redirect&bpo=36169

   (20) https://bugs.python.org/issue?@action=redirect&bpo=36103

   (21) https://bugs.python.org/issue?@action=redirect&bpo=36130

   (22) https://bugs.python.org/issue?@action=redirect&bpo=35652

   (23) https://bugs.python.org/issue?@action=redirect&bpo=35178

   (24) https://bugs.python.org/issue?@action=redirect&bpo=36106

   (25) https://bugs.python.org/issue?@action=redirect&bpo=36091

   (26) https://bugs.python.org/issue?@action=redirect&bpo=36043

   (27) https://bugs.python.org/issue?@action=redirect&bpo=35899

   (28) https://bugs.python.org/issue?@action=redirect&bpo=21269

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30670

   (30) https://bugs.python.org/issue?@action=redirect&bpo=35843

   (31) https://bugs.python.org/issue?@action=redirect&bpo=35802

   (32) https://bugs.python.org/issue?@action=redirect&bpo=35715

   (33) https://bugs.python.org/issue?@action=redirect&bpo=35493

   (34) https://bugs.python.org/issue?@action=redirect&bpo=35661

   (35) https://bugs.python.org/issue?@action=redirect&bpo=35121

   (36) https://bugs.python.org/issue?@action=redirect&bpo=21478

   (37) https://bugs.python.org/issue?@action=redirect&bpo=35198


File: python.info,  Node: Documentation<43>,  Next: Tests<45>,  Prev: Library<48>,  Up: Python 3 8 0 alpha 3

1.23.49.4 Documentation
.......................

   - bpo-36329(1): Declare the path of the Python binary for the usage
     of ‘Tools/scripts/serve.py’ when executing ‘make -C Doc/ serve’.
     Contributed by Stéphane Wirtel

   - bpo-36138(2): Improve documentation about converting
     datetime.timedelta to scalars.

   - bpo-21314(3): A new entry was added to the Core Language Section of
     the Programming FAQ, which explaines the usage of slash(/) in the
     signature of a function.  Patch by Lysandros Nikolaou

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36329

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36138

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21314


File: python.info,  Node: Tests<45>,  Next: Build<48>,  Prev: Documentation<43>,  Up: Python 3 8 0 alpha 3

1.23.49.5 Tests
...............

   - bpo-36234(1): test_posix.PosixUidGidTests: add tests for invalid
     uid/gid type (str).  Initial patch written by David Malcolm.

   - bpo-29571(2): Fix ‘test_re.test_locale_flag()’: use
     ‘locale.getpreferredencoding()’ rather than ‘locale.getlocale()’ to
     get the locale encoding.  With some locales, ‘locale.getlocale()’
     returns the wrong encoding.

   - bpo-36123(3): Fix race condition in test_socket.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36234

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29571

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36123


File: python.info,  Node: Build<48>,  Next: Windows<43>,  Prev: Tests<45>,  Up: Python 3 8 0 alpha 3

1.23.49.6 Build
...............

   - bpo-36356(1): Fix leaks that led to build failure when configured
     with address sanitizer.

   - bpo-36146(2): Add ‘TEST_EXTENSIONS’ constant to ‘setup.py’ to allow
     to not build test extensions like ‘_testcapi’.

   - bpo-36146(3): Fix setup.py on macOS: only add ‘/usr/include/ffi’ to
     include directories of _ctypes, not for all extensions.

   - bpo-31904(4): Enable build system to cross-build for VxWorks RTOS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36356

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36146

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36146

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31904


File: python.info,  Node: Windows<43>,  Next: IDLE<35>,  Prev: Build<48>,  Up: Python 3 8 0 alpha 3

1.23.49.7 Windows
.................

   - bpo-36312(1): Fixed decoders for the following code pages: 50220,
     50221, 50222, 50225, 50227, 50229, 57002 through 57011, 65000 and
     42.

   - bpo-36264(2): Don't honor POSIX ‘HOME’ in ‘os.path.expanduser’ on
     windows.  Patch by Anthony Sottile.

   - bpo-24643(3): Fix name collisions due to ‘#define timezone
     _timezone’ in PC/pyconfig.h.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36312

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36264

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24643


File: python.info,  Node: IDLE<35>,  Next: Tools/Demos<23>,  Prev: Windows<43>,  Up: Python 3 8 0 alpha 3

1.23.49.8 IDLE
..............

   - bpo-36405(1): Use dict unpacking in idlelib.

   - bpo-36396(2): Remove fgBg param of idlelib.config.GetHighlight().
     This param was only used twice and changed the return type.

   - bpo-36176(3): Fix IDLE autocomplete & calltip popup colors.
     Prevent conflicts with Linux dark themes (and slightly darken
     calltip background).

   - bpo-23205(4): For the grep module, add tests for findfiles,
     refactor findfiles to be a module-level function, and refactor
     findfiles to use os.walk.

   - bpo-23216(5): Add docstrings to IDLE search modules.

   - bpo-36152(6): Remove colorizer.ColorDelegator.close_when_done and
     the corresponding argument of .close().  In IDLE, both have always
     been None or False since 2007.

   - bpo-32129(7): Avoid blurry IDLE application icon on macOS with Tk
     8.6.  Patch by Kevin Walzer.

   - bpo-36096(8): Refactor class variables to instance variables in
     colorizer.

   - bpo-30348(9): Increase test coverage of idlelib.autocomplete by
     30%.  Patch by Louie Lu

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36405

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36396

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36176

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23205

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23216

   (6) https://bugs.python.org/issue?@action=redirect&bpo=36152

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32129

   (8) https://bugs.python.org/issue?@action=redirect&bpo=36096

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30348


File: python.info,  Node: Tools/Demos<23>,  Next: C API<47>,  Prev: IDLE<35>,  Up: Python 3 8 0 alpha 3

1.23.49.9 Tools/Demos
.....................

   - bpo-35132(1): Fix py-list and py-bt commands of python-gdb.py on
     gdb7.

   - bpo-32217(2): Fix freeze script on Windows.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35132

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32217


File: python.info,  Node: C API<47>,  Prev: Tools/Demos<23>,  Up: Python 3 8 0 alpha 3

1.23.49.10 C API
................

   - bpo-36381(1): Raise ‘DeprecationWarning’ when '#' formats are used
     for building or parsing values without ‘PY_SSIZE_T_CLEAN’.

   - bpo-36142(2): The whole coreconfig.h header is now excluded from
     Py_LIMITED_API. Move functions definitions into a new internal
     pycore_coreconfig.h header.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36381

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36142


File: python.info,  Node: Python 3 8 0 alpha 2,  Next: Python 3 8 0 alpha 1,  Prev: Python 3 8 0 alpha 3,  Up: 変更履歴

1.23.50 Python 3.8.0 alpha 2
----------------------------

'Release date: 2019-02-25'

* Menu:

* Core and Builtins: Core and Builtins<50>.
* Library: Library<49>.
* Documentation: Documentation<44>.
* Tests: Tests<46>.
* Windows: Windows<44>.
* IDLE: IDLE<36>.


File: python.info,  Node: Core and Builtins<50>,  Next: Library<49>,  Up: Python 3 8 0 alpha 2

1.23.50.1 Core and Builtins
...........................

   - bpo-36052(1): Raise a *note SyntaxError: 172. when assigning a
     value to ‘__debug__’ with the Assignment Operator.  Contributed by
     Stéphane Wirtel and Pablo Galindo.

   - bpo-36012(2): Doubled the speed of class variable writes.  When a
     non-dunder attribute was updated, there was an unnecessary call to
     update slots.

   - bpo-35942(3): The error message emitted when returning invalid
     types from ‘__fspath__’ in interfaces that allow passing *note
     PathLike: c1f. objects has been improved and now it does explain
     the origin of the error.

   - bpo-36016(4): ‘gc.get_objects’ can now receive an optional
     parameter indicating a generation to get objects from.  Patch by
     Pablo Galindo.

   - bpo-1054041(5): When the main interpreter exits due to an uncaught
     KeyboardInterrupt, the process now exits in the appropriate manner
     for its parent process to detect that a SIGINT or ^C terminated the
     process.  This allows shells and batch scripts to understand that
     the user has asked them to stop.

   - bpo-35992(6): Fix ‘__class_getitem__()’ not being called on a class
     with a custom non-subscriptable metaclass.

   - bpo-35993(7): Fix a crash on fork when using subinterpreters.
     Contributed by Stéphane Wirtel

   - bpo-35991(8): Fix a potential double free in
     Modules/_randommodule.c.

   - bpo-35961(9): Fix a crash in slice_richcompare(): use strong
     references rather than stolen references for the two temporary
     internal tuples.

   - bpo-35911(10): Enable the creation of cell objects by adding a
     ‘cell.__new__’ method, and expose the type ‘cell’ in ‘Lib/types.py’
     under the name CellType.  Patch by Pierre Glaser.

   - bpo-12822(11): Use monotonic clock for ‘pthread_cond_timedwait’
     when ‘pthread_condattr_setclock’ and ‘CLOCK_MONOTONIC’ are
     available.

   - bpo-15248(12): The compiler emits now syntax warnings in the case
     when a comma is likely missed before tuple or list.

   - bpo-35886(13): The implementation of PyInterpreterState has been
     moved into the internal header files (guarded by Py_BUILD_CORE).

   - bpo-31506(14): Clarify the errors reported when ‘object.__new__’
     and ‘object.__init__’ receive more than one argument.  Contributed
     by Sanyam Khurana.

   - bpo-35724(15): Signal-handling is now guaranteed to happen relative
     to the main interpreter.

   - bpo-33608(16): We added a new internal _Py_AddPendingCall() that
     operates relative to the provided interpreter.  This allows us to
     use the existing implementation to ask another interpreter to do
     work that cannot be done in the current interpreter, like decref an
     object the other interpreter owns.  The existing
     Py_AddPendingCall() only operates relative to the main interpreter.

   - bpo-33989(17): Fix a possible crash in *note list.sort(): b9d. when
     sorting objects with ‘ob_type->tp_richcompare == NULL’.  Patch by
     Zackery Spytz.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36052

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36012

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35942

   (4) https://bugs.python.org/issue?@action=redirect&bpo=36016

   (5) https://bugs.python.org/issue?@action=redirect&bpo=1054041

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35992

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35993

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35991

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35961

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35911

   (11) https://bugs.python.org/issue?@action=redirect&bpo=12822

   (12) https://bugs.python.org/issue?@action=redirect&bpo=15248

   (13) https://bugs.python.org/issue?@action=redirect&bpo=35886

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31506

   (15) https://bugs.python.org/issue?@action=redirect&bpo=35724

   (16) https://bugs.python.org/issue?@action=redirect&bpo=33608

   (17) https://bugs.python.org/issue?@action=redirect&bpo=33989


File: python.info,  Node: Library<49>,  Next: Documentation<44>,  Prev: Core and Builtins<50>,  Up: Python 3 8 0 alpha 2

1.23.50.2 Library
.................

   - bpo-35512(1): *note unittest.mock.patch.dict(): 195e. used as a
     decorator with string target resolves the target during function
     call instead of during decorator construction.  Patch by
     Karthikeyan Singaravelan.

   - bpo-36018(2): Add statistics.NormalDist, a tool for creating and
     manipulating normal distributions of random variable.  Features a
     composite class that treats the mean and standard deviation of
     measurement data as single entity.

   - bpo-35904(3): Added statistics.fmean() as a faster, floating-point
     variant of the existing mean() function.

   - bpo-35918(4): Removed broken ‘has_key’ method from
     multiprocessing.managers.SyncManager.dict.  Contributed by Rémi
     Lapeyre.

   - bpo-18283(5): Add support for bytes to *note shutil.which(): 480.

   - bpo-35960(6): Fix *note dataclasses.field(): 198b. throwing away
     empty mapping objects passed as metadata.

   - bpo-35500(7): Write expected and actual call parameters on separate
     lines in *note unittest.mock.Mock.assert_called_with(): 198c.
     assertion errors.  Contributed by Susan Su.

   - bpo-35931(8): The *note pdb: 94. ‘debug’ command now gracefully
     handles syntax errors.

   - bpo-24209(9): In http.server script, rely on getaddrinfo to bind to
     preferred address based on the bind parameter.  Now default bind or
     binding to a name may bind to IPv6 or dual-stack, depending on the
     environment.

   - bpo-35321(10): Set ‘__spec__.origin’ of ‘_frozen_importlib’ to
     frozen so that it matches the behavior of
     ‘_frozen_importlib_external’.  Patch by Nina Zakharenko.

   - bpo-35378(11): Fix a reference issue inside ‘multiprocessing.Pool’
     that caused the pool to remain alive if it was deleted without
     being closed or terminated explicitly.  A new strong reference is
     added to the pool iterators to link the lifetime of the pool to the
     lifetime of its iterators so the pool does not get destroyed if a
     pool iterator is still alive.

   - bpo-34294(12): re module, fix wrong capturing groups in rare cases.
     *note re.search(): 11fd, *note re.findall(): ff4, *note re.sub():
     283. and other functions that scan through string looking for a
     match, should reset capturing groups between two match attempts.
     Patch by Ma Lin.

   - bpo-35615(13): *note weakref: fc.: Fix a RuntimeError when copying
     a WeakKeyDictionary or a WeakValueDictionary, due to some keys or
     values disappearing while iterating.

   - bpo-35606(14): Implement *note math.prod(): 9d2. as analogous
     function to *note sum(): 437. that returns the product of a 'start'
     value (default: 1) times an iterable of numbers.  Patch by Pablo
     Galindo.

   - bpo-32417(15): Performing arithmetic between *note
     datetime.datetime: 1ae. subclasses and *note datetime.timedelta:
     99d. now returns an object of the same type as the *note
     datetime.datetime: 1ae. subclass.  As a result, *note
     datetime.datetime.astimezone(): 99e. and alternate constructors
     like *note datetime.datetime.now(): 4b9. and
     ‘datetime.fromtimestamp()’ called with a ‘tz’ argument now 'also'
     retain their subclass.

   - bpo-35153(16): Add 'headers' optional keyword-only parameter to
     *note xmlrpc.client.ServerProxy: a25, ‘xmlrpc.client.Transport’ and
     ‘xmlrpc.client.SafeTransport’.  Patch by Cédric Krier.

   - bpo-34572(17): Fix C implementation of pickle.loads to use
     importlib's locking mechanisms, and thereby avoid using partially
     loaded modules.  Patch by Tim Burgess.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35512

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36018

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35904

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35918

   (5) https://bugs.python.org/issue?@action=redirect&bpo=18283

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35960

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35500

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35931

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24209

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35321

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35378

   (12) https://bugs.python.org/issue?@action=redirect&bpo=34294

   (13) https://bugs.python.org/issue?@action=redirect&bpo=35615

   (14) https://bugs.python.org/issue?@action=redirect&bpo=35606

   (15) https://bugs.python.org/issue?@action=redirect&bpo=32417

   (16) https://bugs.python.org/issue?@action=redirect&bpo=35153

   (17) https://bugs.python.org/issue?@action=redirect&bpo=34572


File: python.info,  Node: Documentation<44>,  Next: Tests<46>,  Prev: Library<49>,  Up: Python 3 8 0 alpha 2

1.23.50.3 Documentation
.......................

   - bpo-36083(1): Fix formatting of -check-hash-based-pycs options in
     the manpage Synopsis.

   - bpo-36007(2): Bump minimum sphinx version to 1.8.  Patch by Anthony
     Sottile.

   - bpo-22062(3): Update documentation and docstrings for pathlib.
     Original patch by Mike Short.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=36083

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36007

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22062


File: python.info,  Node: Tests<46>,  Next: Windows<44>,  Prev: Documentation<44>,  Up: Python 3 8 0 alpha 2

1.23.50.4 Tests
...............

   - bpo-27313(1): Avoid test_ttk_guionly ComboboxTest failure with
     macOS Cocoa Tk.

   - bpo-36019(2): Add test.support.TEST_HTTP_URL and replace references
     of ‘http://www.example.com’ by this new constant.  Contributed by
     Stéphane Wirtel.

   - bpo-36037(3): Fix test_ssl for strict OpenSSL configuration like
     RHEL8 strict crypto policy.  Use older TLS version for minimum TLS
     version of the server SSL context if needed, to test TLS version
     older than default minimum TLS version.

   - bpo-35798(4): Added ‘test.support.check_syntax_warning()’.

   - bpo-35505(5): Make test_imap4_host_default_value independent on
     whether the local IMAP server is running.

   - bpo-35917(6): multiprocessing: provide unit tests for SyncManager
     and SharedMemoryManager classes + all the shareable types which are
     supposed to be supported by them.  (patch by Giampaolo Rodola)

   - bpo-35704(7): Skip ‘test_shutil.test_unpack_archive_xztar’ to
     prevent a MemoryError on 32-bit AIX when MAXDATA setting is less
     than 0x20000000.

     Patch by Michael Felt (aixtools)

   - bpo-34720(8): Assert m_state != NULL to mimic GC traversal
     functions that do not correctly handle module creation when the
     module state has not been created.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27313

   (2) https://bugs.python.org/issue?@action=redirect&bpo=36019

   (3) https://bugs.python.org/issue?@action=redirect&bpo=36037

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35798

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35505

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35917

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35704

   (8) https://bugs.python.org/issue?@action=redirect&bpo=34720


File: python.info,  Node: Windows<44>,  Next: IDLE<36>,  Prev: Tests<46>,  Up: Python 3 8 0 alpha 2

1.23.50.5 Windows
.................

   - bpo-35976(1): Added ARM build support to Windows build files in
     PCBuild.

   - bpo-35692(2): ‘pathlib’ no longer raises when checking file and
     directory existence on drives that are not ready

   - bpo-35872(3): Uses the base Python executable when invoking venv in
     a virtual environment

   - bpo-35873(4): Prevents venv paths being inherited by child
     processes

   - bpo-35299(5): Fix sysconfig detection of the source directory and
     distutils handling of pyconfig.h during PGO profiling

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35976

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35692

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35872

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35873

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35299


File: python.info,  Node: IDLE<36>,  Prev: Windows<44>,  Up: Python 3 8 0 alpha 2

1.23.50.6 IDLE
..............

   - bpo-24310(1): IDLE - Document settings dialog font tab sample.

   - bpo-35833(2): Revise IDLE doc for control codes sent to Shell.  Add
     a code example block.

   - bpo-35689(3): Add docstrings and unittests for colorizer.py.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24310

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35833

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35689


File: python.info,  Node: Python 3 8 0 alpha 1,  Next: Python 3 7 0 final,  Prev: Python 3 8 0 alpha 2,  Up: 変更履歴

1.23.51 Python 3.8.0 alpha 1
----------------------------

'Release date: 2019-02-03'

* Menu:

* Security: Security<34>.
* Core and Builtins: Core and Builtins<51>.
* Library: Library<50>.
* Documentation: Documentation<45>.
* Tests: Tests<47>.
* Build: Build<49>.
* Windows: Windows<45>.
* macOS: macOS<37>.
* IDLE: IDLE<37>.
* Tools/Demos: Tools/Demos<24>.
* C API: C API<48>.


File: python.info,  Node: Security<34>,  Next: Core and Builtins<51>,  Up: Python 3 8 0 alpha 1

1.23.51.1 Security
..................

   - bpo-35746(1): CVE 2019-5010(2): Fix a NULL pointer deref in ssl
     module.  The cert parser did not handle CRL distribution points
     with empty DP or URI correctly.  A malicious or buggy certificate
     can result into segfault.  Vulnerability (TALOS-2018-0758) reported
     by Colin Read and Nicolas Edet of Cisco.

   - bpo-34812(3): The *note -I: 92c. command line option (run Python in
     isolated mode) is now also copied by the *note multiprocessing: 86.
     and ‘distutils’ modules when spawning child processes.  Previously,
     only *note -E: 92b. and *note -s: 1353. options (enabled by *note
     -I: 92c.) were copied.

   - bpo-34791(4): The xml.sax and xml.dom.domreg no longer use
     environment variables to override parser implementations when
     sys.flags.ignore_environment is set by -E or -I arguments.

   - bpo-17239(5): The xml.sax and xml.dom.minidom parsers no longer
     processes external entities by default.  External DTD and ENTITY
     declarations no longer load files or create network connections.

   - bpo-34623(6): CVE 2018-14647(7): The C accelerated _elementtree
     module now initializes hash randomization salt from _Py_HashSecret
     instead of libexpat's default CSPRNG.

   - bpo-34405(8): Updated to OpenSSL 1.1.0i for Windows builds.

   - bpo-33871(9): Fixed sending the part of the file in *note
     os.sendfile(): add. on macOS. Using the 'trailers' argument could
     cause sending more bytes from the input file than was specified.

   - bpo-32533(10): Fixed thread-safety of error handling in _ssl.

   - bpo-33136(11): Harden ssl module against LibreSSL CVE
     2018-8970(12).  X509_VERIFY_PARAM_set1_host() is called with an
     explicit namelen.  A new test ensures that NULL bytes are not
     allowed.

   - bpo-33001(13): Minimal fix to prevent buffer overrun in os.symlink
     on Windows

   - bpo-32981(14): Regexes in difflib and poplib were vulnerable to
     catastrophic backtracking.  These regexes formed potential DOS
     vectors (REDOS). They have been refactored.  This resolves CVE
     2018-1060(15) and CVE 2018-1061(16).  Patch by Jamie Davis.

   - bpo-28414(17): The ssl module now allows users to perform their own
     IDN en/decoding when using SNI.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35746

   (2) https://www.cve.org/CVERecord?id=CVE-2019-5010

   (3) https://bugs.python.org/issue?@action=redirect&bpo=34812

   (4) https://bugs.python.org/issue?@action=redirect&bpo=34791

   (5) https://bugs.python.org/issue?@action=redirect&bpo=17239

   (6) https://bugs.python.org/issue?@action=redirect&bpo=34623

   (7) https://www.cve.org/CVERecord?id=CVE-2018-14647

   (8) https://bugs.python.org/issue?@action=redirect&bpo=34405

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33871

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32533

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33136

   (12) https://www.cve.org/CVERecord?id=CVE-2018-8970

   (13) https://bugs.python.org/issue?@action=redirect&bpo=33001

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32981

   (15) https://www.cve.org/CVERecord?id=CVE-2018-1060

   (16) https://www.cve.org/CVERecord?id=CVE-2018-1061

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28414


File: python.info,  Node: Core and Builtins<51>,  Next: Library<50>,  Prev: Security<34>,  Up: Python 3 8 0 alpha 1

1.23.51.2 Core and Builtins
...........................

   - bpo-35877(1): Make parenthesis optional for named expressions in
     while statement.  Patch by Karthikeyan Singaravelan.

   - bpo-35814(2): Allow same right hand side expressions in annotated
     assignments as in normal ones.  In particular, ‘x: Tuple[int, int]
     = 1, 2’ (without parentheses on the right) is now allowed.

   - bpo-35766(3): Add the option to parse PEP 484 type comments in the
     ast module.  (Off by default.)  This is merging the key
     functionality of the third party fork thereof,
     [typed_ast](‘https://github.com/python/typed_ast’).

   - bpo-35713(4): Reorganize Python initialization to get working
     exceptions and sys.stderr earlier.

   - bpo-33416(5): Add end line and end column position information to
     the Python AST nodes.  This is a C-level backwards incompatible
     change.

   - bpo-35720(6): Fixed a minor memory leak in
     pymain_parse_cmdline_impl function in Modules/main.c

   - bpo-35634(7): ‘func(**kwargs)’ will now raise an error when
     ‘kwargs’ is a mapping containing multiple entries with the same
     key.  An error was already raised when other keyword arguments are
     passed before ‘**kwargs’ since Python 3.6.

   - bpo-35623(8): Fix a crash when sorting very long lists.  Patch by
     Stephan Hohe.

   - bpo-35214(9): clang Memory Sanitizer build instrumentation was
     added to work around false positives from posix, socket, time,
     test_io, and test_faulthandler.

   - bpo-35560(10): Fix an assertion error in *note format(): 5eb. in
     debug build for floating-point formatting with "n" format, zero
     padding and small width.  Release build is not impacted.  Patch by
     Karthikeyan Singaravelan.

   - bpo-35552(11): Format characters ‘%s’ and ‘%V’ in *note
     PyUnicode_FromFormat(): 363. and ‘%s’ in *note
     PyBytes_FromFormat(): 1994. no longer read memory past the limit if
     'precision' is specified.

   - bpo-35504(12): Fix segfaults and *note SystemError: 541.s when
     deleting certain attributes.  Patch by Zackery Spytz.

   - bpo-35504(13): Fixed a SystemError when delete the
     characters_written attribute of an OSError.

   - bpo-35494(14): Improved syntax error messages for unbalanced
     parentheses in f-string.

   - bpo-35444(15): Fixed error handling in pickling methods when fail
     to look up builtin "getattr".  Sped up pickling iterators.

   - bpo-35436(16): Fix various issues with memory allocation error
     handling.  Patch by Zackery Spytz.

   - bpo-35423(17): Separate the signal handling trigger in the eval
     loop from the "pending calls" machinery.  There is no semantic
     change and the difference in performance is insignificant.

   - bpo-35357(18): Internal attributes' names of unittest.mock._Call
     and unittest.mock.MagicProxy (name, parent & from_kall) are now
     prefixed with _mock_ in order to prevent clashes with widely used
     object attributes.  Fixed minor typo in test function name.

   - bpo-35372(19): Fixed the code page decoder for input longer than 2
     GiB containing undecodable bytes.

   - bpo-35336(20): Fix PYTHONCOERCECLOCALE=1 environment variable: only
     coerce the C locale if the LC_CTYPE locale is "C".

   - bpo-31241(21): The 'lineno' and 'col_offset' attributes of AST
     nodes for list comprehensions, generator expressions and tuples are
     now point to the opening parenthesis or square brace.  For tuples
     without parenthesis they point to the position of the first item.

   - bpo-33954(22): For *note str.format(): 5ed, ‘float.__format__()’
     and ‘complex.__format__()’ methods for non-ASCII decimal point when
     using the "n" formatter.

   - bpo-35269(23): Fix a possible segfault involving a newly created
     coroutine.  Patch by Zackery Spytz.

   - bpo-35224(24): Implement PEP 572(25) (assignment expressions).
     Patch by Emily Morehouse.

   - bpo-32492(26): Speed up ‘namedtuple()’ attribute access by 1.6x
     using a C fast-path for the name descriptors.  Patch by Pablo
     Galindo.

   - bpo-35214(27): Fixed an out of bounds memory access when parsing a
     truncated unicode escape sequence at the end of a string such as
     ‘'\N'’.  It would read one byte beyond the end of the memory
     allocation.

   - bpo-35214(28): The interpreter and extension modules have had
     annotations added so that they work properly under clang's Memory
     Sanitizer.  A new configure flag -with-memory-sanitizer has been
     added to make test builds of this nature easier to perform.

   - bpo-35193(29): Fix an off by one error in the bytecode peephole
     optimizer where it could read bytes beyond the end of bounds of an
     array when removing unreachable code.  This bug was present in
     every release of Python 3.6 and 3.7 until now.

   - bpo-35169(30): Improved error messages for forbidden assignments.

   - bpo-34022(31): Fix handling of hash-based bytecode files in *note
     zipimport: 118.  Patch by Elvis Pranskevichus.

   - bpo-28401(32): Debug builds will no longer to attempt to import
     extension modules built for the ABI as they were never compatible
     to begin with.  Patch by Stefano Rivera.

   - bpo-29341(33): Clarify in the docstrings of *note os: 91. methods
     that path-like objects are also accepted as input parameters.

   - bpo-35050(34): *note socket: b8.: Fix off-by-one bug in length
     check for ‘AF_ALG’ name and type.

   - bpo-29743(35): Raise *note ValueError: 1e3. instead of *note
     OverflowError: 84e. in case of a negative ‘_length_’ in a *note
     ctypes.Array: 1995. subclass.  Also raise *note TypeError: 502.
     instead of *note AttributeError: 326. for non-integer ‘_length_’.
     Original patch by Oren Milman.

   - bpo-16806(36): Fix ‘lineno’ and ‘col_offset’ for multi-line string
     tokens.

   - bpo-35029(37): *note SyntaxWarning: 432. raised as an exception at
     code generation time will be now replaced with a *note SyntaxError:
     172. for better error reporting.

   - bpo-34983(38): Expose *note symtable.Symbol.is_nonlocal(): 1996. in
     the symtable module.  Patch by Pablo Galindo.

   - bpo-34974(39): *note bytes: 1a4. and *note bytearray: 508.
     constructors no longer convert unexpected exceptions (e.g.  *note
     MemoryError: 1627. and *note KeyboardInterrupt: 99f.) to *note
     TypeError: 502.

   - bpo-34939(40): Allow annotated names in module namespace that are
     declared global before the annotation happens.  Patch by Pablo
     Galindo.

   - bpo-34973(41): Fixed crash in *note bytes(): 1a4. when the *note
     list: 5dc. argument is mutated while it is iterated.

   - bpo-34876(42): The 'lineno' and 'col_offset' attributes of the AST
     for decorated function and class refer now to the position of the
     corresponding ‘def’, ‘async def’ and ‘class’ instead of the
     position of the first decorator.  This leads to more correct line
     reporting in tracing.  This is the only case when the position of
     child AST nodes can precede the position of the parent AST node.

   - bpo-34879(43): Fix a possible null pointer dereference in
     bytesobject.c.  Patch by Zackery Spytz.

   - bpo-34784(44): Fix the implementation of PyStructSequence_NewType
     in order to create heap allocated StructSequences.

   - bpo-32912(45): A *note SyntaxWarning: 432. is now emitted instead
     of a *note DeprecationWarning: 18a. for invalid escape sequences in
     string and bytes literals.

   - bpo-34854(46): Fixed a crash in compiling string annotations
     containing a lambda with a keyword-only argument that doesn't have
     a default value.

   - bpo-34850(47): The compiler now produces a *note SyntaxWarning:
     432. when identity checks (‘is’ and ‘is not’) are used with certain
     types of literals (e.g.  strings, ints).  These can often work by
     accident in CPython, but are not guaranteed by the language spec.
     The warning advises users to use equality tests (‘==’ and ‘!=’)
     instead.

   - bpo-34824(48): Fix a possible null pointer dereference in
     Modules/_ssl.c.  Patch by Zackery Spytz.

   - bpo-30156(49): The C function ‘property_descr_get()’ uses a
     "cached" tuple to optimize function calls.  But this tuple can be
     discovered in debug mode with *note sys.getobjects(): 3fe.  Remove
     the optimization, it's not really worth it and it causes 3
     different crashes last years.

   - bpo-34762(50): Fix contextvars C API to use PyObject* pointer
     types.

   - bpo-34751(51): The hash function for tuples is now based on xxHash
     which gives better collision results on (formerly) pathological
     cases.  Additionally, on 64-bit systems it improves tuple hashes in
     general.  Patch by Jeroen Demeyer with substantial contributions by
     Tim Peters.

   - bpo-34735(52): Fix a memory leak in Modules/timemodule.c.  Patch by
     Zackery Spytz.

   - bpo-34683(53): Fixed a bug where some SyntaxError error pointed to
     locations that were off-by-one.

   - bpo-34651(54): Only allow the main interpreter to fork.  The avoids
     the possibility of affecting the main interpreter, which is
     critical to operation of the runtime.

   - bpo-34653(55): Remove unused function
     PyParser_SimpleParseStringFilename.

   - bpo-32236(56): Warn that line buffering is not supported if *note
     open(): 4e5. is called with binary mode and ‘buffering=1’.

   - bpo-34641(57): Further restrict the syntax of the left-hand side of
     keyword arguments in function calls.  In particular,
     ‘f((keyword)=arg)’ is now disallowed.

   - bpo-34637(58): Make the 'start' argument to 'sum()' visible as a
     keyword argument.

   - bpo-1621(59): Do not assume signed integer overflow behavior (C
     undefined behavior) when performing set hash table resizing.

   - bpo-34588(60): Fix an off-by-one in the recursive call pruning
     feature of traceback formatting.

   - bpo-34485(61): On Windows, the LC_CTYPE is now set to the user
     preferred locale at startup.  Previously, the LC_CTYPE locale was
     "C" at startup, but changed when calling setlocale(LC_CTYPE, "") or
     setlocale(LC_ALL, "").

   - bpo-34485(62): Standard streams like sys.stdout now use the
     "surrogateescape" error handler, instead of "strict", on the POSIX
     locale (when the C locale is not coerced and the UTF-8 Mode is
     disabled).

   - bpo-34485(63): Fix the error handler of standard streams like
     sys.stdout: PYTHONIOENCODING=":" is now ignored instead of setting
     the error handler to "strict".

   - bpo-34485(64): Python now gets the locale encoding with C code to
     initialize the encoding of standard streams like sys.stdout.
     Moreover, the encoding is now initialized to the Python codec name
     to get a normalized encoding name and to ensure that the codec is
     loaded.  The change avoids importing _bootlocale and _locale
     modules at startup by default.

   - bpo-34527(65): On FreeBSD, Py_DecodeLocale() and Py_EncodeLocale()
     now also forces the ASCII encoding if the LC_CTYPE locale is
     "POSIX", not only if the LC_CTYPE locale is "C".

   - bpo-34527(66): The UTF-8 Mode is now also enabled by the "POSIX"
     locale, not only by the "C" locale.

   - bpo-34403(67): On HP-UX with C or POSIX locale,
     sys.getfilesystemencoding() now returns "ascii" instead of "roman8"
     (when the UTF-8 Mode is disabled and the C locale is not coerced).

   - bpo-34523(68): The Python filesystem encoding is now read earlier
     during the Python initialization.

   - bpo-12458(69): Tracebacks show now correct line number for
     subexpressions in multiline expressions.  Tracebacks show now the
     line number of the first line for multiline expressions instead of
     the line number of the last subexpression.

   - bpo-34408(70): Prevent a null pointer dereference and resource
     leakage in ‘PyInterpreterState_New()’.

   - bpo-34400(71): Fix undefined behavior in parsetok.c.  Patch by
     Zackery Spytz.

   - bpo-33073(72): Added as_integer_ratio to ints to make them more
     interoperable with floats.

   - bpo-34377(73): Update valgrind suppression list to use
     ‘_PyObject_Free’/‘_PyObject_Realloc’ instead of
     ‘PyObject_Free’/‘PyObject_Realloc’.

   - bpo-34353(74): Added the "socket" option in the ‘stat.filemode()’
     Python implementation to match the C implementation.

   - bpo-34320(75): Fix ‘dict(od)’ didn't copy iteration order of
     OrderedDict.

   - bpo-34113(76): Fixed crash on debug builds when opcode stack was
     adjusted with negative numbers.  Patch by Constantin Petrisor.

   - bpo-34100(77): Compiler now merges constants in tuples and
     frozensets recursively.  Code attributes like ‘co_names’ are merged
     too.

   - bpo-34151(78): Performance of list concatenation, repetition and
     slicing operations is slightly improved.  Patch by Sergey Fedoseev.

   - bpo-34170(79): -X dev: it is now possible to override the memory
     allocator using PYTHONMALLOC even if the developer mode is enabled.

   - bpo-33237(80): Improved *note AttributeError: 326. message for
     partially initialized module.

   - bpo-34149(81): Fix min and max functions to get default behavior
     when key is None.

   - bpo-34125(82): Profiling of unbound built-in methods now works when
     ‘**kwargs’ is given.

   - bpo-34141(83): Optimized pickling atomic types (None, bool, int,
     float, bytes, str).

   - bpo-34126(84): Fix crashes when profiling certain invalid calls of
     unbound methods.  Patch by Jeroen Demeyer.

   - bpo-24618(85): Fixed reading invalid memory when create the code
     object with too small varnames tuple or too large argument counts.

   - bpo-34068(86): In *note io.IOBase.close(): 1d7, ensure that the
     *note closed: 1997. attribute is not set with a live exception.
     Patch by Zackery Spytz and Serhiy Storchaka.

   - bpo-34087(87): Fix buffer overflow while converting unicode to
     numeric values.

   - bpo-34080(88): Fixed a memory leak in the compiler when it raised
     some uncommon errors during tokenizing.

   - bpo-34066(89): Disabled interruption by Ctrl-C between calling
     ‘open()’ and entering a 'with' block in ‘with open()’.

   - bpo-34042(90): Fix dict.copy() to maintain correct total refcount
     (as reported by sys.gettotalrefcount()).

   - bpo-33418(91): Fix potential memory leak in function object when it
     creates reference cycle.

   - bpo-33985(92): Implement contextvars.ContextVar.name attribute.

   - bpo-33956(93): Update vendored Expat library copy to version 2.2.5.

   - bpo-24596(94): Decref the module object in *note
     PyRun_SimpleFileExFlags(): 1873. before calling *note
     PyErr_Print(): 18af.  Patch by Zackery Spytz.

   - bpo-33451(95): Close directly executed pyc files before calling
     ‘PyEval_EvalCode()’.

   - bpo-1617161(96): The hash of ‘BuiltinMethodType’ instances (methods
     of built-in classes) now depends on the hash of the identity of
     '__self__' instead of its value.  The hash and equality of
     ‘ModuleType’ and ‘MethodWrapperType’ instances (methods of
     user-defined classes and some methods of built-in classes like
     ‘str.__add__’) now depend on the hash and equality of the identity
     of '__self__' instead of its value.  ‘MethodWrapperType’ instances
     no longer support ordering.

   - bpo-33824(97): Fix "LC_ALL=C python3.7 -V": reset properly the
     command line parser when the encoding changes after reading the
     Python configuration.

   - bpo-33803(98): Fix a crash in hamt.c caused by enabling GC tracking
     for an object that hadn't all of its fields set to NULL.

   - bpo-33738(99): Seven macro incompatibilities with the Limited API
     were fixed, and the macros *note PyIter_Check(): 185f, *note
     PyIndex_Check(): 958. and ‘PyExceptionClass_Name()’ were added as
     functions.  A script for automatic macro checks was added.

   - bpo-33786(100): Fix asynchronous generators to handle GeneratorExit
     in athrow() correctly

   - bpo-30167(101): ‘PyRun_SimpleFileExFlags’ removes ‘__cached__’ from
     module in addition to ‘__file__’.

   - bpo-33706(102): Fix a crash in Python initialization when parsing
     the command line options.  Thanks Christoph Gohlke for the bug
     report and the fix!

   - bpo-33597(103): Reduce ‘PyGC_Head’ size from 3 words to 2 words.

   - bpo-30654(104): Fixed reset of the SIGINT handler to SIG_DFL on
     interpreter shutdown even when there was a custom handler set
     previously.  Patch by Philipp Kerling.

   - bpo-33622(105): Fixed a leak when the garbage collector fails to
     add an object with the ‘__del__’ method or referenced by it into
     the *note gc.garbage: 1191. list.  *note PyGC_Collect(): 95c. can
     now be called when an exception is set and preserves it.

   - bpo-33462(106): Make dict and dict views reversible.  Patch by Rémi
     Lapeyre.

   - bpo-23722(107): A *note RuntimeError: 17a. is now raised when the
     custom metaclass doesn't provide the ‘__classcell__’ entry in the
     namespace passed to ‘type.__new__’.  A *note DeprecationWarning:
     18a. was emitted in Python 3.6-3.7.

   - bpo-33499(108): Add *note PYTHONPYCACHEPREFIX: 971. environment
     variable and *note -X: 15c. ‘pycache_prefix’ command-line option to
     set an alternate root directory for writing module bytecode cache
     files.

   - bpo-25711(109): The *note zipimport: 118. module has been rewritten
     in pure Python.

   - bpo-33509(110): Fix module_globals parameter of
     warnings.warn_explicit(): don't crash if module_globals is not a
     dict.

   - bpo-31849(111): Fix signed/unsigned comparison warning in pyhash.c.

   - bpo-33475(112): Fixed miscellaneous bugs in converting annotations
     to strings and optimized parentheses in the string representation.

   - bpo-20104(113): Added support for the ‘setpgroup’, ‘resetids’,
     ‘setsigmask’, ‘setsigdef’ and ‘scheduler’ parameters of
     ‘posix_spawn’.  Patch by Pablo Galindo.

   - bpo-33391(114): Fix a leak in set_symmetric_difference().

   - bpo-33363(115): Raise a SyntaxError for ‘async with’ and ‘async
     for’ statements outside of async functions.

   - bpo-28055(116): Fix unaligned accesses in siphash24().  Patch by
     Rolf Eike Beer.

   - bpo-33128(117): Fix a bug that causes PathFinder to appear twice on
     sys.meta_path.  Patch by Pablo Galindo Salgado.

   - bpo-33331(118): Modules imported last are now cleared first at
     interpreter shutdown.

   - bpo-33312(119): Fixed clang ubsan (undefined behavior sanitizer)
     warnings in dictobject.c by adjusting how the internal struct
     _dictkeysobject shared keys structure is declared.

   - bpo-33305(120): Improved syntax error messages for invalid
     numerical literals.

   - bpo-33306(121): Improved syntax error messages for unbalanced
     parentheses.

   - bpo-33234(122): The list constructor will pre-size and not
     over-allocate when the input length is known.

   - bpo-33270(123): Intern the names for all anonymous code objects.
     Patch by Zackery Spytz.

   - bpo-30455(124): The C and Python code and the documentation related
     to tokens are now generated from a single source file
     ‘Grammar/Tokens’.

   - bpo-33176(125): Add a ‘toreadonly()’ method to memoryviews.

   - bpo-33231(126): Fix potential memory leak in ‘normalizestring()’.

   - bpo-33205(127): Change dict growth function from
     ‘round_up_to_power_2(used*2+hashtable_size/2)’ to
     ‘round_up_to_power_2(used*3)’.  Previously, dict is shrinked only
     when ‘used == 0’.  Now dict has more chance to be shrinked.

   - bpo-29922(128): Improved error messages in 'async with' when
     ‘__aenter__()’ or ‘__aexit__()’ return non-awaitable object.

   - bpo-33199(129): Fix ‘ma_version_tag’ in dict implementation is
     uninitialized when copying from key-sharing dict.

   - bpo-33053(130): When using the -m switch, sys.path[0] is now
     explicitly expanded as the 'starting' working directory, rather
     than being left as the empty path (which allows imports from the
     current working directory at the time of the import)

   - bpo-33138(131): Changed standard error message for non-pickleable
     and non-copyable types.  It now says "cannot pickle" instead of
     "can't pickle" or "cannot serialize".

   - bpo-33018(132): Improve consistency of errors raised by
     ‘issubclass()’ when called with a non-class and an abstract base
     class as the first and second arguments, respectively.  Patch by
     Josh Bronson.

   - bpo-33083(133): ‘math.factorial’ no longer accepts arguments that
     are not int-like.  Patch by Pablo Galindo.

   - bpo-33041(134): Added new opcode *note END_ASYNC_FOR: a78. and
     fixes the following issues:

        * Setting global *note StopAsyncIteration: 1998. no longer
          breaks ‘async for’ loops.

        * Jumping into an ‘async for’ loop is now disabled.

        * Jumping out of an ‘async for’ loop no longer corrupts the
          stack.

   - bpo-25750(135): Fix rare Python crash due to bad refcounting in
     ‘type_getattro()’ if a descriptor deletes itself from the class.
     Patch by Jeroen Demeyer.

   - bpo-33041(136): Fixed bytecode generation for "async for" with a
     complex target.  A StopAsyncIteration raised on assigning or
     unpacking will be now propagated instead of stopping the iteration.

   - bpo-33026(137): Fixed jumping out of "with" block by setting
     f_lineno.

   - bpo-33005(138): Fix a crash on fork when using a custom memory
     allocator (ex: using PYTHONMALLOC env var).  _PyGILState_Reinit()
     and _PyInterpreterState_Enable() now use the default RAW memory
     allocator to allocate a new interpreters mutex on fork.

   - bpo-32911(139): Due to unexpected compatibility issues discovered
     during downstream beta testing, reverted bpo-29463(140).
     ‘docstring’ field is removed from Module, ClassDef, FunctionDef,
     and AsyncFunctionDef ast nodes which was added in 3.7a1.  Docstring
     expression is restored as a first statement in their body.  Based
     on patch by Inada Naoki.

   - bpo-17288(141): Prevent jumps from 'return' and 'exception' trace
     events.

   - bpo-32946(142): Importing names from already imported module with
     "from ...  import ..."  is now 30% faster if the module is not a
     package.

   - bpo-32932(143): Make error message more revealing when there are
     non-str objects in ‘__all__’.

   - bpo-32925(144): Optimized iterating and containing test for literal
     lists consisting of non-constants: ‘x in [a, b]’ and ‘for x in [a,
     b]’.  The case of all constant elements already was optimized.

   - bpo-32889(145): Update Valgrind suppression list to account for the
     rename of ‘Py_ADDRESS_IN_RANG’ to ‘address_in_range’.

   - bpo-32836(146): Don't use temporary variables in cases of
     list/dict/set comprehensions

   - bpo-31356(147): Remove the new API added in bpo-31356(148)
     (gc.ensure_disabled() context manager).

   - bpo-32305(149): For namespace packages, ensure that both ‘__file__’
     and ‘__spec__.origin’ are set to None.

   - bpo-32303(150): Make sure ‘__spec__.loader’ matches ‘__loader__’
     for namespace packages.

   - bpo-32711(151): Fix the warning messages for Python/ast_unparse.c.
     Patch by Stéphane Wirtel

   - bpo-32583(152): Fix possible crashing in builtin Unicode decoders
     caused by write out-of-bound errors when using customized decode
     error handlers.

   - bpo-32489(153): A *note continue: 998. statement is now allowed in
     the *note finally: 997. clause.

   - bpo-17611(154): Simplified the interpreter loop by moving the logic
     of unrolling the stack of blocks into the compiler.  The compiler
     emits now explicit instructions for adjusting the stack of values
     and calling the cleaning up code for *note break: a77, *note
     continue: 998. and *note return: 99c.

     Removed opcodes ‘BREAK_LOOP’, ‘CONTINUE_LOOP’, ‘SETUP_LOOP’ and
     ‘SETUP_EXCEPT’.  Added new opcodes ‘ROT_FOUR’, ‘BEGIN_FINALLY’ and
     ‘CALL_FINALLY’ and ‘POP_FINALLY’.  Changed the behavior of
     ‘END_FINALLY’ and ‘WITH_CLEANUP_START’.

   - bpo-32285(155): New function unicodedata.is_normalized, which can
     check whether a string is in a specific normal form.

   - bpo-10544(156): Yield expressions are now disallowed in
     comprehensions and generator expressions except the expression for
     the outermost iterable.

   - bpo-32117(157): Iterable unpacking is now allowed without
     parentheses in yield and return statements, e.g.  ‘yield 1, 2, 3,
     *rest’.  Thanks to David Cuthbert for the change and Jordan Chapman
     for added tests.

   - bpo-31902(158): Fix the ‘col_offset’ attribute for ast nodes
     ‘ast.AsyncFor’, ‘ast.AsyncFunctionDef’, and ‘ast.AsyncWith’.
     Previously, ‘col_offset’ pointed to the keyword after ‘async’.

   - bpo-25862(159): Fix assertion failures in the ‘tell()’ method of
     ‘io.TextIOWrapper’.  Patch by Zackery Spytz.

   - bpo-21983(160): Fix a crash in ‘ctypes.cast()’ in case the type
     argument is a ctypes structured data type.  Patch by Eryk Sun and
     Oren Milman.

   - bpo-31577(161): Fix a crash in ‘os.utime()’ in case of a bad ns
     argument.  Patch by Oren Milman.

   - bpo-29832(162): Remove references to 'getsockaddrarg' from various
     socket error messages.  Patch by Oren Milman.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35877

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35814

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35766

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35713

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33416

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35720

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35634

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35623

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35214

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35560

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35552

   (12) https://bugs.python.org/issue?@action=redirect&bpo=35504

   (13) https://bugs.python.org/issue?@action=redirect&bpo=35504

   (14) https://bugs.python.org/issue?@action=redirect&bpo=35494

   (15) https://bugs.python.org/issue?@action=redirect&bpo=35444

   (16) https://bugs.python.org/issue?@action=redirect&bpo=35436

   (17) https://bugs.python.org/issue?@action=redirect&bpo=35423

   (18) https://bugs.python.org/issue?@action=redirect&bpo=35357

   (19) https://bugs.python.org/issue?@action=redirect&bpo=35372

   (20) https://bugs.python.org/issue?@action=redirect&bpo=35336

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31241

   (22) https://bugs.python.org/issue?@action=redirect&bpo=33954

   (23) https://bugs.python.org/issue?@action=redirect&bpo=35269

   (24) https://bugs.python.org/issue?@action=redirect&bpo=35224

   (25) https://peps.python.org/pep-0572/

   (26) https://bugs.python.org/issue?@action=redirect&bpo=32492

   (27) https://bugs.python.org/issue?@action=redirect&bpo=35214

   (28) https://bugs.python.org/issue?@action=redirect&bpo=35214

   (29) https://bugs.python.org/issue?@action=redirect&bpo=35193

   (30) https://bugs.python.org/issue?@action=redirect&bpo=35169

   (31) https://bugs.python.org/issue?@action=redirect&bpo=34022

   (32) https://bugs.python.org/issue?@action=redirect&bpo=28401

   (33) https://bugs.python.org/issue?@action=redirect&bpo=29341

   (34) https://bugs.python.org/issue?@action=redirect&bpo=35050

   (35) https://bugs.python.org/issue?@action=redirect&bpo=29743

   (36) https://bugs.python.org/issue?@action=redirect&bpo=16806

   (37) https://bugs.python.org/issue?@action=redirect&bpo=35029

   (38) https://bugs.python.org/issue?@action=redirect&bpo=34983

   (39) https://bugs.python.org/issue?@action=redirect&bpo=34974

   (40) https://bugs.python.org/issue?@action=redirect&bpo=34939

   (41) https://bugs.python.org/issue?@action=redirect&bpo=34973

   (42) https://bugs.python.org/issue?@action=redirect&bpo=34876

   (43) https://bugs.python.org/issue?@action=redirect&bpo=34879

   (44) https://bugs.python.org/issue?@action=redirect&bpo=34784

   (45) https://bugs.python.org/issue?@action=redirect&bpo=32912

   (46) https://bugs.python.org/issue?@action=redirect&bpo=34854

   (47) https://bugs.python.org/issue?@action=redirect&bpo=34850

   (48) https://bugs.python.org/issue?@action=redirect&bpo=34824

   (49) https://bugs.python.org/issue?@action=redirect&bpo=30156

   (50) https://bugs.python.org/issue?@action=redirect&bpo=34762

   (51) https://bugs.python.org/issue?@action=redirect&bpo=34751

   (52) https://bugs.python.org/issue?@action=redirect&bpo=34735

   (53) https://bugs.python.org/issue?@action=redirect&bpo=34683

   (54) https://bugs.python.org/issue?@action=redirect&bpo=34651

   (55) https://bugs.python.org/issue?@action=redirect&bpo=34653

   (56) https://bugs.python.org/issue?@action=redirect&bpo=32236

   (57) https://bugs.python.org/issue?@action=redirect&bpo=34641

   (58) https://bugs.python.org/issue?@action=redirect&bpo=34637

   (59) https://bugs.python.org/issue?@action=redirect&bpo=1621

   (60) https://bugs.python.org/issue?@action=redirect&bpo=34588

   (61) https://bugs.python.org/issue?@action=redirect&bpo=34485

   (62) https://bugs.python.org/issue?@action=redirect&bpo=34485

   (63) https://bugs.python.org/issue?@action=redirect&bpo=34485

   (64) https://bugs.python.org/issue?@action=redirect&bpo=34485

   (65) https://bugs.python.org/issue?@action=redirect&bpo=34527

   (66) https://bugs.python.org/issue?@action=redirect&bpo=34527

   (67) https://bugs.python.org/issue?@action=redirect&bpo=34403

   (68) https://bugs.python.org/issue?@action=redirect&bpo=34523

   (69) https://bugs.python.org/issue?@action=redirect&bpo=12458

   (70) https://bugs.python.org/issue?@action=redirect&bpo=34408

   (71) https://bugs.python.org/issue?@action=redirect&bpo=34400

   (72) https://bugs.python.org/issue?@action=redirect&bpo=33073

   (73) https://bugs.python.org/issue?@action=redirect&bpo=34377

   (74) https://bugs.python.org/issue?@action=redirect&bpo=34353

   (75) https://bugs.python.org/issue?@action=redirect&bpo=34320

   (76) https://bugs.python.org/issue?@action=redirect&bpo=34113

   (77) https://bugs.python.org/issue?@action=redirect&bpo=34100

   (78) https://bugs.python.org/issue?@action=redirect&bpo=34151

   (79) https://bugs.python.org/issue?@action=redirect&bpo=34170

   (80) https://bugs.python.org/issue?@action=redirect&bpo=33237

   (81) https://bugs.python.org/issue?@action=redirect&bpo=34149

   (82) https://bugs.python.org/issue?@action=redirect&bpo=34125

   (83) https://bugs.python.org/issue?@action=redirect&bpo=34141

   (84) https://bugs.python.org/issue?@action=redirect&bpo=34126

   (85) https://bugs.python.org/issue?@action=redirect&bpo=24618

   (86) https://bugs.python.org/issue?@action=redirect&bpo=34068

   (87) https://bugs.python.org/issue?@action=redirect&bpo=34087

   (88) https://bugs.python.org/issue?@action=redirect&bpo=34080

   (89) https://bugs.python.org/issue?@action=redirect&bpo=34066

   (90) https://bugs.python.org/issue?@action=redirect&bpo=34042

   (91) https://bugs.python.org/issue?@action=redirect&bpo=33418

   (92) https://bugs.python.org/issue?@action=redirect&bpo=33985

   (93) https://bugs.python.org/issue?@action=redirect&bpo=33956

   (94) https://bugs.python.org/issue?@action=redirect&bpo=24596

   (95) https://bugs.python.org/issue?@action=redirect&bpo=33451

   (96) https://bugs.python.org/issue?@action=redirect&bpo=1617161

   (97) https://bugs.python.org/issue?@action=redirect&bpo=33824

   (98) https://bugs.python.org/issue?@action=redirect&bpo=33803

   (99) https://bugs.python.org/issue?@action=redirect&bpo=33738

   (100) https://bugs.python.org/issue?@action=redirect&bpo=33786

   (101) https://bugs.python.org/issue?@action=redirect&bpo=30167

   (102) https://bugs.python.org/issue?@action=redirect&bpo=33706

   (103) https://bugs.python.org/issue?@action=redirect&bpo=33597

   (104) https://bugs.python.org/issue?@action=redirect&bpo=30654

   (105) https://bugs.python.org/issue?@action=redirect&bpo=33622

   (106) https://bugs.python.org/issue?@action=redirect&bpo=33462

   (107) https://bugs.python.org/issue?@action=redirect&bpo=23722

   (108) https://bugs.python.org/issue?@action=redirect&bpo=33499

   (109) https://bugs.python.org/issue?@action=redirect&bpo=25711

   (110) https://bugs.python.org/issue?@action=redirect&bpo=33509

   (111) https://bugs.python.org/issue?@action=redirect&bpo=31849

   (112) https://bugs.python.org/issue?@action=redirect&bpo=33475

   (113) https://bugs.python.org/issue?@action=redirect&bpo=20104

   (114) https://bugs.python.org/issue?@action=redirect&bpo=33391

   (115) https://bugs.python.org/issue?@action=redirect&bpo=33363

   (116) https://bugs.python.org/issue?@action=redirect&bpo=28055

   (117) https://bugs.python.org/issue?@action=redirect&bpo=33128

   (118) https://bugs.python.org/issue?@action=redirect&bpo=33331

   (119) https://bugs.python.org/issue?@action=redirect&bpo=33312

   (120) https://bugs.python.org/issue?@action=redirect&bpo=33305

   (121) https://bugs.python.org/issue?@action=redirect&bpo=33306

   (122) https://bugs.python.org/issue?@action=redirect&bpo=33234

   (123) https://bugs.python.org/issue?@action=redirect&bpo=33270

   (124) https://bugs.python.org/issue?@action=redirect&bpo=30455

   (125) https://bugs.python.org/issue?@action=redirect&bpo=33176

   (126) https://bugs.python.org/issue?@action=redirect&bpo=33231

   (127) https://bugs.python.org/issue?@action=redirect&bpo=33205

   (128) https://bugs.python.org/issue?@action=redirect&bpo=29922

   (129) https://bugs.python.org/issue?@action=redirect&bpo=33199

   (130) https://bugs.python.org/issue?@action=redirect&bpo=33053

   (131) https://bugs.python.org/issue?@action=redirect&bpo=33138

   (132) https://bugs.python.org/issue?@action=redirect&bpo=33018

   (133) https://bugs.python.org/issue?@action=redirect&bpo=33083

   (134) https://bugs.python.org/issue?@action=redirect&bpo=33041

   (135) https://bugs.python.org/issue?@action=redirect&bpo=25750

   (136) https://bugs.python.org/issue?@action=redirect&bpo=33041

   (137) https://bugs.python.org/issue?@action=redirect&bpo=33026

   (138) https://bugs.python.org/issue?@action=redirect&bpo=33005

   (139) https://bugs.python.org/issue?@action=redirect&bpo=32911

   (140) https://bugs.python.org/issue?@action=redirect&bpo=29463

   (141) https://bugs.python.org/issue?@action=redirect&bpo=17288

   (142) https://bugs.python.org/issue?@action=redirect&bpo=32946

   (143) https://bugs.python.org/issue?@action=redirect&bpo=32932

   (144) https://bugs.python.org/issue?@action=redirect&bpo=32925

   (145) https://bugs.python.org/issue?@action=redirect&bpo=32889

   (146) https://bugs.python.org/issue?@action=redirect&bpo=32836

   (147) https://bugs.python.org/issue?@action=redirect&bpo=31356

   (148) https://bugs.python.org/issue?@action=redirect&bpo=31356

   (149) https://bugs.python.org/issue?@action=redirect&bpo=32305

   (150) https://bugs.python.org/issue?@action=redirect&bpo=32303

   (151) https://bugs.python.org/issue?@action=redirect&bpo=32711

   (152) https://bugs.python.org/issue?@action=redirect&bpo=32583

   (153) https://bugs.python.org/issue?@action=redirect&bpo=32489

   (154) https://bugs.python.org/issue?@action=redirect&bpo=17611

   (155) https://bugs.python.org/issue?@action=redirect&bpo=32285

   (156) https://bugs.python.org/issue?@action=redirect&bpo=10544

   (157) https://bugs.python.org/issue?@action=redirect&bpo=32117

   (158) https://bugs.python.org/issue?@action=redirect&bpo=31902

   (159) https://bugs.python.org/issue?@action=redirect&bpo=25862

   (160) https://bugs.python.org/issue?@action=redirect&bpo=21983

   (161) https://bugs.python.org/issue?@action=redirect&bpo=31577

   (162) https://bugs.python.org/issue?@action=redirect&bpo=29832


File: python.info,  Node: Library<50>,  Next: Documentation<45>,  Prev: Core and Builtins<51>,  Up: Python 3 8 0 alpha 1

1.23.51.3 Library
.................

   - bpo-35845(1): Add 'order' parameter to memoryview.tobytes().

   - bpo-35864(2): The _asdict() method for collections.namedtuple now
     returns a regular dict instead of an OrderedDict.

   - bpo-35537(3): An ExitStack is now used internally within
     subprocess.Popen to clean up pipe file handles.  No behavior change
     in normal operation.  But if closing one handle were ever to cause
     an exception, the others will now be closed instead of leaked.
     (patch by Giampaolo Rodola)

   - bpo-35847(4): RISC-V needed the CTYPES_PASS_BY_REF_HACK. Fixes
     ctypes Structure test_pass_by_value.

   - bpo-35813(5): Shared memory submodule added to multiprocessing to
     avoid need for serialization between processes

   - bpo-35780(6): Fix lru_cache() errors arising in recursive,
     reentrant, or multi-threaded code.  These errors could result in
     orphan links and in the cache being trapped in a state with fewer
     than the specified maximum number of links.  Fix handling of
     negative maxsize which should have been treated as zero.  Fix
     errors in toggling the "full" status flag.  Fix misordering of
     links when errors are encountered.  Sync-up the C code and pure
     Python code for the space saving path in functions with a single
     positional argument.  In this common case, the space overhead of an
     lru cache entry is reduced by almost half.  Fix counting of cache
     misses.  In error cases, the miss count was out of sync with the
     actual number of times the underlying user function was called.

   - bpo-35537(7): *note os.posix_spawn(): 201. and *note
     os.posix_spawnp(): 199a. now have a 'setsid' parameter.

   - bpo-23846(8): *note asyncio.ProactorEventLoop: 5d4. now catches and
     logs send errors when the self-pipe is full.

   - bpo-34323(9): *note asyncio: 8.: Enhance ‘IocpProactor.close()’
     log: wait 1 second before the first log, then log every second.
     Log also the number of seconds since ‘close()’ was called.

   - bpo-35674(10): Add a new *note os.posix_spawnp(): 199a. function.
     Patch by Joannah Nanjekye.

   - bpo-35733(11): ‘ast.Constant(boolean)’ no longer an instance of
     ‘ast.Num’.  Patch by Anthony Sottile.

   - bpo-35726(12): QueueHandler.prepare() now makes a copy of the
     record before modifying and enqueueing it, to avoid affecting other
     handlers in the chain.

   - bpo-35719(13): Sped up multi-argument *note math: 81. functions
     atan2(), copysign(), remainder() and hypot() by 1.3-2.5 times.

   - bpo-35717(14): Fix KeyError exception raised when using enums and
     compile.  Patch contributed by Rémi Lapeyre.

   - bpo-35699(15): Fixed detection of Visual Studio Build Tools 2017 in
     distutils

   - bpo-32710(16): Fix memory leaks in asyncio ProactorEventLoop on
     overlapped operation failure.

   - bpo-35702(17): The *note time.CLOCK_UPTIME_RAW: a11. constant is
     now available for macOS 10.12.

   - bpo-32710(18): Fix a memory leak in asyncio in the
     ProactorEventLoop when ‘ReadFile()’ or ‘WSASend()’ overlapped
     operation fail immediately: release the internal buffer.

   - bpo-35682(19): Fix ‘asyncio.ProactorEventLoop.sendfile()’: don't
     attempt to set the result of an internal future if it's already
     done.

   - bpo-35283(20): Add a deprecated warning for the
     ‘threading.Thread.isAlive()’ method.  Patch by Donghee Na.

   - bpo-35664(21): Improve operator.itemgetter() performance by 33%
     with optimized argument handling and with adding a fast path for
     the common case of a single non-negative integer index into a tuple
     (which is the typical use case in the standard library).

   - bpo-35643(22): Fixed a SyntaxWarning: invalid escape sequence in
     Modules/_sha3/cleanup.py.  Patch by Mickaël Schoentgen.

   - bpo-35619(23): Improved support of custom data descriptors in *note
     help(): 8a5. and *note pydoc: a3.

   - bpo-28503(24): The ‘crypt’ module now internally uses the
     ‘crypt_r()’ library function instead of ‘crypt()’ when available.

   - bpo-35614(25): Fixed help() on metaclasses.  Patch by Sanyam
     Khurana.

   - bpo-35568(26): Expose ‘raise(signum)’ as ‘raise_signal’

   - bpo-35588(27): The floor division and modulo operations and the
     *note divmod(): 96f. function on *note fractions.Fraction: 1c8.
     types are 2-4x faster.  Patch by Stefan Behnel.

   - bpo-35585(28): Speed-up building enums by value, e.g.
     http.HTTPStatus(200).

   - bpo-30561(29): random.gammavariate(1.0, beta) now computes the same
     result as random.expovariate(1.0 / beta).  This synchronizes the
     two algorithms and eliminates some idiosyncrasies in the old
     implementation.  It does however produce a difference stream of
     random variables than it used to.

   - bpo-35537(30): The *note subprocess: c1. module can now use the
     *note os.posix_spawn(): 201. function in some cases for better
     performance.

   - bpo-35526(31): Delaying the 'joke' of barry_as_FLUFL.mandatory to
     Python version 4.0

   - bpo-35523(32): Remove *note ctypes: 22. callback workaround: no
     longer create a callback at startup.  Avoid SELinux alert on
     ‘import ctypes’ and ‘import uuid’.

   - bpo-31784(33): *note uuid.uuid1(): b76. now calls *note
     time.time_ns(): ab5. rather than ‘int(time.time() * 1e9)’.

   - bpo-35513(34): ‘TextTestRunner’ of ‘unittest.runner’ now uses *note
     time.perf_counter(): a56. rather than *note time.time(): 235. to
     measure the execution time of a test: *note time.time(): 235. can
     go backwards, whereas *note time.perf_counter(): a56. is monotonic.

   - bpo-35502(35): Fixed reference leaks in *note
     xml.etree.ElementTree.TreeBuilder: a23. in case of unfinished
     building of the tree (in particular when an error was raised during
     parsing XML).

   - bpo-35348(36): Make *note platform.architecture(): 15ef. parsing of
     ‘file’ command output more reliable: add the ‘-b’ option to the
     ‘file’ command to omit the filename, force the usage of the C
     locale, and search also the "shared object" pattern.

   - bpo-35491(37): *note multiprocessing: 86.: Add ‘Pool.__repr__()’
     and enhance ‘BaseProcess.__repr__()’ (add pid and parent pid) to
     ease debugging.  Pool state constant values are now strings instead
     of integers, for example ‘RUN’ value becomes ‘'RUN'’ instead of
     ‘0’.

   - bpo-35477(38): ‘multiprocessing.Pool.__enter__()’ now fails if the
     pool is not running: ‘with pool:’ fails if used more than once.

   - bpo-31446(39): Copy command line that was passed to CreateProcessW
     since this function can change the content of the input buffer.

   - bpo-35471(40): Python 2.4 dropped MacOS 9 support.  The macpath
     module was deprecated in Python 3.7.  The module is now removed.

   - bpo-23057(41): Unblock Proactor event loop when keyboard interrupt
     is received on Windows

   - bpo-35052(42): Fix xml.dom.minidom cloneNode() on a document with
     an entity: pass the correct arguments to the user data handler of
     an entity.

   - bpo-20239(43): Allow repeated assignment deletion of *note
     unittest.mock.Mock: a1a. attributes.  Patch by Pablo Galindo.

   - bpo-17185(44): Set ‘__signature__’ on mock for *note inspect: 72.
     to get signature.  Patch by Karthikeyan Singaravelan.

   - bpo-35445(45): Memory errors during creating posix.environ no
     longer ignored.

   - bpo-35415(46): Validate fileno= argument to socket.socket().

   - bpo-35424(47): ‘multiprocessing.Pool’ destructor now emits *note
     ResourceWarning: 225. if the pool is still running.

   - bpo-35330(48): When a ‘Mock’ instance was used to wrap an object,
     if ‘side_effect’ is used in one of the mocks of it methods, don't
     call the original implementation and return the result of using the
     side effect the same way that it is done with return_value.

   - bpo-35346(49): Drop Mac OS 9 and Rhapsody support from the *note
     platform: 98. module.  Rhapsody last release was in 2000.  Mac OS 9
     last release was in 2001.

   - bpo-10496(50): ‘check_environ()’ of ‘distutils.utils’ now catches
     *note KeyError: 31d. on calling *note pwd.getpwuid(): 199b.: don't
     create the ‘HOME’ environment variable in this case.

   - bpo-10496(51): ‘posixpath.expanduser()’ now returns the input
     'path' unchanged if the ‘HOME’ environment variable is not set and
     the current user has no home directory (if the current user
     identifier doesn't exist in the password database).  This change
     fix the *note site: b5. module if the current user doesn't exist in
     the password database (if the user has no home directory).

   - bpo-35389(52): *note platform.libc_ver(): 199c. now uses
     ‘os.confstr('CS_GNU_LIBC_VERSION')’ if available and the
     'executable' parameter is not set.

   - bpo-35394(53): Add empty slots to asyncio abstract protocols.

   - bpo-35310(54): Fix a bug in *note select.select(): d6d. where, in
     some cases, the file descriptor sequences were returned unmodified
     after a signal interruption, even though the file descriptors might
     not be ready yet.  *note select.select(): d6d. will now always
     return empty lists if a timeout has occurred.  Patch by Oran
     Avraham.

   - bpo-35380(55): Enable TCP_NODELAY on Windows for proactor asyncio
     event loop.

   - bpo-35341(56): Add generic version of ‘collections.OrderedDict’ to
     the ‘typing’ module.  Patch by Ismo Toijala.

   - bpo-35371(57): Fixed possible crash in ‘os.utime()’ on Windows when
     pass incorrect arguments.

   - bpo-35346(58): *note platform.uname(): 199d. now redirects ‘stderr’
     to *note os.devnull: 199e. when running external programs like ‘cmd
     /c ver’.

   - bpo-35066(59): Previously, calling the strftime() method on a
     datetime object with a trailing '%' in the format string would
     result in an exception.  However, this only occurred when the
     datetime C module was being used; the python implementation did not
     match this behavior.  Datetime is now PEP-399 compliant, and will
     not throw an exception on a trailing '%'.

   - bpo-35345(60): The function ‘platform.popen’ has been removed, it
     was deprecated since Python 3.3: use *note os.popen(): a55.
     instead.

   - bpo-35344(61): On macOS, *note platform.platform(): 16c0. now uses
     *note platform.mac_ver(): 199f, if it returns a non-empty release
     string, to get the macOS version rather than the darwin version.

   - bpo-35312(62): Make ‘lib2to3.pgen2.parse.ParseError’ round-trip
     pickle-able.  Patch by Anthony Sottile.

   - bpo-35308(63): Fix regression in ‘webbrowser’ where default
     browsers may be preferred over browsers in the ‘BROWSER’
     environment variable.

   - bpo-24746(64): Avoid stripping trailing whitespace in doctest fancy
     diff.  Original patch by R. David Murray & Jairo Trad.  Enhanced by
     Sanyam Khurana.

   - bpo-28604(65): *note locale.localeconv(): bcc. now sets temporarily
     the ‘LC_CTYPE’ locale to the ‘LC_MONETARY’ locale if the two
     locales are different and monetary strings are non-ASCII. This
     temporary change affects other threads.

   - bpo-35277(66): Update ensurepip to install pip 18.1 and setuptools
     40.6.2.

   - bpo-24209(67): Adds IPv6 support when invoking http.server
     directly.

   - bpo-35226(68): Recursively check arguments when testing for
     equality of *note unittest.mock.call: 1939. objects and add note
     that tracking of parameters used to create ancestors of mocks in
     ‘mock_calls’ is not possible.

   - bpo-29564(69): The warnings module now suggests to enable
     tracemalloc if the source is specified, the tracemalloc module is
     available, but tracemalloc is not tracing memory allocations.

   - bpo-35189(70): Modify the following fnctl function to retry if
     interrupted by a signal (EINTR): flock, lockf, fnctl

   - bpo-30064(71): Use add_done_callback() in sock_* asyncio API to
     unsubscribe reader/writer early on calcellation.

   - bpo-35186(72): Removed the "built with" comment added when
     ‘setup.py upload’ is used with either ‘bdist_rpm’ or ‘bdist_dumb’.

   - bpo-35152(73): Allow sending more than 2 GB at once on a
     multiprocessing connection on non-Windows systems.

   - bpo-35062(74): Fix incorrect parsing of *note
     io.IncrementalNewlineDecoder: 162e.'s 'translate' argument.

   - bpo-35065(75): Remove ‘StreamReaderProtocol._untrack_reader’.  The
     call to ‘_untrack_reader’ is currently performed too soon, causing
     the protocol to forget about the reader before ‘connection_lost’
     can run and feed the EOF to the reader.

   - bpo-34160(76): ElementTree and minidom now preserve the attribute
     order specified by the user.

   - bpo-35079(77): Improve difflib.SequenceManager.get_matching_blocks
     doc by adding 'non-overlapping' and changing '!=' to '<'.

   - bpo-33710(78): Deprecated ‘l*gettext()’ functions and methods in
     the *note gettext: 59. module.  They return encoded bytes instead
     of Unicode strings and are artifacts from Python 2 times.  Also
     deprecated functions and methods related to setting the charset for
     ‘l*gettext()’ functions and methods.

   - bpo-35017(79): *note socketserver.BaseServer.serve_forever(): 1112.
     now exits immediately if it's *note shutdown(): 19a0. method is
     called while it is polling for new events.

   - bpo-35024(80): ‘importlib’ no longer logs ‘wrote <bytecode path>’
     redundantly after ‘(created|could not create) <bytecode path>’ is
     already logged.  Patch by Quentin Agren.

   - bpo-35047(81): ‘unittest.mock’ now includes mock calls in exception
     messages if ‘assert_not_called’, ‘assert_called_once’, or
     ‘assert_called_once_with’ fails.  Patch by Petter Strandmark.

   - bpo-31047(82): Fix ‘ntpath.abspath’ regression where it didn't
     remove a trailing separator on Windows.  Patch by Tim Graham.

   - bpo-35053(83): tracemalloc now tries to update the traceback when
     an object is reused from a "free list" (optimization for faster
     object creation, used by the builtin list type for example).

   - bpo-31553(84): Add the -json-lines option to json.tool.  Patch by
     hongweipeng.

   - bpo-34794(85): Fixed a leak in Tkinter when pass the Python wrapper
     around Tcl_Obj back to Tcl/Tk.

   - bpo-34909(86): Enum: fix grandchildren subclassing when parent
     mixed with concrete data types.

   - bpo-35022(87): *note unittest.mock.MagicMock: e5a. now supports the
     ‘__fspath__’ method (from *note os.PathLike: c1f.).

   - bpo-35008(88): Fixed references leaks when call the
     ‘__setstate__()’ method of *note xml.etree.ElementTree.Element:
     2e8. in the C implementation for already initialized element.

   - bpo-23420(89): Verify the value for the parameter '-s' of the
     cProfile CLI. Patch by Robert Kuska

   - bpo-33947(90): dataclasses now handle recursive reprs without
     raising RecursionError.

   - bpo-34890(91): Make *note inspect.iscoroutinefunction(): 2c5, *note
     inspect.isgeneratorfunction(): 173c. and *note
     inspect.isasyncgenfunction(): 173d. work with *note
     functools.partial(): 3ed.  Patch by Pablo Galindo.

   - bpo-34521(92): Use *note socket.CMSG_SPACE(): 19a1. to calculate
     ancillary data size instead of *note socket.CMSG_LEN(): 19a2. in
     ‘multiprocessing.reduction.recvfds()’ as RFC 3542(93) requires the
     use of the former for portable applications.

   - bpo-31522(94): The ‘mailbox.mbox.get_string’ function 'from_'
     parameter can now successfully be set to a non-default value.

   - bpo-34970(95): Protect tasks weak set manipulation in
     ‘asyncio.all_tasks()’

   - bpo-34969(96): gzip: Add -fast, -best on the gzip CLI, these
     parameters will be used for the fast compression method (quick) or
     the best method compress (slower, but smaller file).  Also, change
     the default compression level to 6 (tradeoff).

   - bpo-16965(97): The 2to3 ‘execfile’ fixer now opens the file with
     mode ‘'rb'’.  Patch by Zackery Spytz.

   - bpo-34966(98): *note pydoc: a3. now supports aliases not only to
     methods defined in the end class, but also to inherited methods.
     The docstring is not duplicated for aliases.

   - bpo-34926(99): *note mimetypes.MimeTypes.guess_type(): 19a3. now
     accepts *note path-like object: 280. in addition to url strings.
     Patch by Mayank Asthana.

   - bpo-23831(100): Add ‘moveto()’ method to the ‘tkinter.Canvas’
     widget.  Patch by Juliette Monsel.

   - bpo-34941(101): Methods ‘find()’, ‘findtext()’ and ‘findall()’ of
     the ‘Element’ class in the *note xml.etree.ElementTree: 10c. module
     are now able to find children which are instances of ‘Element’
     subclasses.

   - bpo-32680(102): *note smtplib.SMTP: 8fb. objects now always have a
     ‘sock’ attribute present

   - bpo-34769(103): Fix for async generators not finalizing when event
     loop is in debug mode and garbage collector runs in another thread.

   - bpo-34936(104): Fix ‘TclError’ in
     ‘tkinter.Spinbox.selection_element()’.  Patch by Juliette Monsel.

   - bpo-34829(105): Add methods ‘selection_from’, ‘selection_range’,
     ‘selection_present’ and ‘selection_to’ to the ‘tkinter.Spinbox’ for
     consistency with the ‘tkinter.Entry’ widget.  Patch by Juliette
     Monsel.

   - bpo-34911(106): Added 'secure_protocols' argument to
     'http.cookiejar.DefaultCookiePolicy' to allow for tweaking of
     protocols and also to add support by default for 'wss', the secure
     websocket protocol.

   - bpo-34922(107): Fixed integer overflow in the *note digest(): 19a4.
     and *note hexdigest(): 19a5. methods for the SHAKE algorithm in the
     *note hashlib: 5e. module.

   - bpo-34925(108): 25% speedup in argument parsing for the functions
     in the bisect module.

   - bpo-34900(109): Fixed *note unittest.TestCase.debug(): 17ff. when
     used to call test methods with subtests.  Patch by Bruno Oliveira.

   - bpo-34844(110): logging.Formatter enhancement - Ensure styles and
     fmt matches in logging.Formatter - Added validate method in each
     format style class: StrFormatStyle, PercentStyle,
     StringTemplateStyle.  - This method is called in the constructor of
     logging.Formatter class - Also re-raise the KeyError in the format
     method of each style class, so it would a bit clear that it's an
     error with the invalid format fields.

   - bpo-34897(111): Adjust test.support.missing_compiler_executable
     check so that a nominal command name of "" is ignored.  Patch by
     Michael Felt.

   - bpo-34871(112): Fix inspect module polluted ‘sys.modules’ when
     parsing ‘__text_signature__’ of callable.

   - bpo-34898(113): Add ‘mtime’ argument to ‘gzip.compress’ for
     reproducible output.  Patch by Guo Ci Teo.

   - bpo-28441(114): On Cygwin and MinGW, ensure that ‘sys.executable’
     always includes the full filename in the path, including the ‘.exe’
     suffix (unless it is a symbolic link).

   - bpo-34866(115): Adding ‘max_num_fields’ to ‘cgi.FieldStorage’ to
     make DOS attacks harder by limiting the number of
     ‘MiniFieldStorage’ objects created by ‘FieldStorage’.

   - bpo-34711(116): http.server ensures it reports HTTPStatus.NOT_FOUND
     when the local path ends with "/" and is not a directory, even if
     the underlying OS (e.g.  AIX) accepts such paths as a valid file
     reference.  Patch by Michael Felt.

   - bpo-34872(117): Fix self-cancellation in C implementation of
     asyncio.Task

   - bpo-34849(118): Don't log waiting for ‘selector.select’ in asyncio
     loop iteration.  The waiting is pretty normal for any asyncio
     program, logging its time just adds a noise to logs without any
     useful information provided.

   - bpo-34022(119): The ‘SOURCE_DATE_EPOCH’ environment variable no
     longer overrides the value of the 'invalidation_mode' argument to
     *note py_compile.compile(): 9f3, and determines its default value
     instead.

   - bpo-34819(120): Use a monotonic clock to compute timeouts in
     ‘Executor.map()’ and ‘as_completed()’, in order to prevent timeouts
     from deviating when the system clock is adjusted.

   - bpo-34758(121): Add .wasm -> application/wasm to list of recognized
     file types and content type headers

   - bpo-34789(122): *note xml.sax.make_parser(): 19a6. now accepts any
     iterable as its 'parser_list' argument.  Patch by Andrés Delfino.

   - bpo-34334(123): In ‘QueueHandler’, clear ‘exc_text’ from
     ‘LogRecord’ to prevent traceback from being written twice.

   - bpo-34687(124): On Windows, asyncio now uses ProactorEventLoop,
     instead of SelectorEventLoop, by default.

   - bpo-5950(125): Support reading zip files with archive comments in
     *note zipimport: 118.

   - bpo-32892(126): The parser now represents all constants as *note
     ast.Constant: 299. instead of using specific constant AST types
     (‘Num’, ‘Str’, ‘Bytes’, ‘NameConstant’ and ‘Ellipsis’).  These
     classes are considered deprecated and will be removed in future
     Python versions.

   - bpo-34728(127): Add deprecation warning when ‘loop’ is used in
     methods: ‘asyncio.sleep’, ‘asyncio.wait’ and ‘asyncio.wait_for’.

   - bpo-34738(128): ZIP files created by ‘distutils’ will now include
     entries for directories.

   - bpo-34659(129): Add an optional 'initial' argument to
     itertools.accumulate().

   - bpo-29577(130): Support multiple mixin classes when creating Enums.

   - bpo-34670(131): Add SSLContext.post_handshake_auth and
     SSLSocket.verify_client_post_handshake for TLS 1.3's post handshake
     authentication feature.

   - bpo-32718(132): The Activate.ps1 script from venv works with
     PowerShell Core 6.1 and is now available under all operating
     systems.

   - bpo-31177(133): Fix bug that prevented using *note reset_mock: cc8.
     on mock instances with deleted attributes

   - bpo-34672(134): Add a workaround, so the ‘'Z'’ *note
     time.strftime(): 11ba. specifier on the musl C library can work in
     some cases.

   - bpo-34666(135): Implement ‘asyncio.StreamWriter.awrite’ and
     ‘asyncio.StreamWriter.aclose()’ coroutines.  Methods are needed for
     providing a consistent stream API with control flow switched on by
     default.

   - bpo-6721(136): Acquire the logging module's commonly used internal
     locks while fork()ing to avoid deadlocks in the child process.

   - bpo-34658(137): Fix a rare interpreter unhandled exception state
     SystemError only seen when using subprocess with a preexec_fn while
     an after_parent handler has been registered with
     os.register_at_fork and the fork system call fails.

   - bpo-34652(138): Ensure *note os.lchmod(): 1fb. is never defined on
     Linux.

   - bpo-34638(139): Store a weak reference to stream reader to break
     strong references loop between reader and protocol.  It allows to
     detect and close the socket if the stream is deleted (garbage
     collected) without ‘close()’ call.

   - bpo-34536(140): ‘Enum._missing_’: raise ‘ValueError’ if None
     returned and ‘TypeError’ if non-member is returned.

   - bpo-34636(141): Speed up re scanning of many non-matching
     characters for s w and d within bytes objects.  (microoptimization)

   - bpo-24412(142): Add *note addModuleCleanup(): a1b. and *note
     addClassCleanup(): a1c. to unittest to support cleanups for
     ‘setUpModule()’ and *note setUpClass(): a1d.  Patch by Lisa Roach.

   - bpo-34630(143): Don't log SSL certificate errors in asyncio code
     (connection error logging is skipped already).

   - bpo-32490(144): Prevent filename duplication in *note subprocess:
     c1. exception messages.  Patch by Zackery Spytz.

   - bpo-34363(145): dataclasses.asdict() and .astuple() now handle
     namedtuples correctly.

   - bpo-34625(146): Update vendorized expat library version to 2.2.6.

   - bpo-32270(147): The subprocess module no longer mistakenly closes
     redirected fds even when they were in pass_fds when outside of the
     default {0, 1, 2} set.

   - bpo-34622(148): Create a dedicated ‘asyncio.CancelledError’,
     ‘asyncio.InvalidStateError’ and ‘asyncio.TimeoutError’ exception
     classes.  Inherit them from corresponding exceptions from
     ‘concurrent.futures’ package.  Extract ‘asyncio’ exceptions into a
     separate file.

   - bpo-34610(149): Fixed iterator of
     ‘multiprocessing.managers.DictProxy’.

   - bpo-34421(150): Fix distutils logging for non-ASCII strings.  This
     caused installation issues on Windows.

   - bpo-34604(151): Fix possible mojibake in the error message of
     ‘pwd.getpwnam’ and ‘grp.getgrnam’ using string representation
     because of invisible characters or trailing whitespaces.  Patch by
     William Grzybowski.

   - bpo-30977(152): Make uuid.UUID use ‘__slots__’ to reduce its memory
     footprint.  Based on original patch by Wouter Bolsterlee.

   - bpo-34574(153): OrderedDict iterators are not exhausted during
     pickling anymore.  Patch by Sergey Fedoseev.

   - bpo-8110(154): Refactored *note subprocess: c1. to check for
     Windows-specific modules rather than ‘sys.platform == 'win32'’.

   - bpo-34530(155): ‘distutils.spawn.find_executable()’ now falls back
     on *note os.defpath: 196d. if the ‘PATH’ environment variable is
     not set.

   - bpo-34563(156): On Windows, fix multiprocessing.Connection for very
     large read: fix _winapi.PeekNamedPipe() and _winapi.ReadFile() for
     read larger than INT_MAX (usually ‘2**31-1’).

   - bpo-34558(157): Correct typo in Lib/ctypes/_aix.py

   - bpo-34282(158): Move ‘Enum._convert’ to ‘EnumMeta._convert_’ and
     fix enum members getting shadowed by parent attributes.

   - bpo-22872(159): When the queue is closed, *note ValueError: 1e3. is
     now raised by *note multiprocessing.Queue.put(): 19a7. and *note
     multiprocessing.Queue.get(): 19a8. instead of *note AssertionError:
     675. and *note OSError: 3f0, respectively.  Patch by Zackery Spytz.

   - bpo-34515(160): Fix parsing non-ASCII identifiers in
     ‘lib2to3.pgen2.tokenize’ ( PEP 3131(161)).

   - bpo-13312(162): Avoids a possible integer underflow (undefined
     behavior) in the time module's year handling code when passed a
     very low negative year value.

   - bpo-34472(163): Improved compatibility for streamed files in *note
     zipfile: 117.  Previously an optional signature was not being
     written and certain ZIP applications were not supported.  Patch by
     Silas Sewell.

   - bpo-34454(164): Fix the .fromisoformat() methods of datetime types
     crashing when given unicode with non-UTF-8-encodable code points.
     Specifically, datetime.fromisoformat() now accepts surrogate
     unicode code points used as the separator.  Report and tests by
     Alexey Izbyshev, patch by Paul Ganssle.

   - bpo-6700(165): Fix inspect.getsourcelines for module level
     frames/tracebacks.  Patch by Vladimir Matveev.

   - bpo-34171(166): Running the *note trace: e6. module no longer
     creates the ‘trace.cover’ file.

   - bpo-34441(167): Fix crash when an ‘ABC’-derived class with invalid
     ‘__subclasses__’ is passed as the second argument to *note
     issubclass(): 78c.  Patch by Alexey Izbyshev.

   - bpo-34427(168): Fix infinite loop in ‘a.extend(a)’ for
     ‘MutableSequence’ subclasses.

   - bpo-34412(169): Make *note signal.strsignal(): 19a9. work on HP-UX.
     Patch by Michael Osipov.

   - bpo-20849(170): shutil.copytree now accepts a new ‘dirs_exist_ok’
     keyword argument.  Patch by Josh Bronson.

   - bpo-31715(171): Associate ‘.mjs’ file extension with
     ‘application/javascript’ MIME Type.

   - bpo-34384(172): *note os.readlink(): 8ee. now accepts *note
     path-like: 280. and *note bytes: 1a4. objects on Windows.

   - bpo-22602(173): The UTF-7 decoder now raises *note
     UnicodeDecodeError: 9e1. for ill-formed sequences starting with "+"
     (as specified in RFC 2152).  Patch by Zackery Spytz.

   - bpo-2122(174): The *note mmap.flush(): a66. method now returns
     ‘None’ on success, raises an exception on error under all
     platforms.

   - bpo-34341(175): Appending to the ZIP archive with the ZIP64
     extension no longer grows the size of extra fields of existing
     entries.

   - bpo-34333(176): Fix %-formatting in *note
     pathlib.PurePath.with_suffix(): 157b. when formatting an error
     message.

   - bpo-18540(177): The *note imaplib.IMAP4: 8d1. and *note
     imaplib.IMAP4_SSL: 8d2. classes now resolve to the local host IP
     correctly when the default value of 'host' parameter (‘''’) is
     used.

   - bpo-26502(178): Implement ‘traceback.FrameSummary.__len__()’ method
     to preserve compatibility with the old tuple API.

   - bpo-34318(179): *note assertRaises(): 4f6, *note
     assertRaisesRegex(): 4f8, *note assertWarns(): 1137. and *note
     assertWarnsRegex(): 1138. no longer success if the passed callable
     is None.  They no longer ignore unknown keyword arguments in the
     context manager mode.  A DeprecationWarning was raised in these
     cases since Python 3.5.

   - bpo-9372(180): Deprecate *note __getitem__(): 264. methods of *note
     xml.dom.pulldom.DOMEventStream: 700, *note
     wsgiref.util.FileWrapper: 701. and *note fileinput.FileInput: 702.

   - bpo-33613(181): Fix a race condition in
     ‘multiprocessing.semaphore_tracker’ when the tracker receives
     SIGINT before it can register signal handlers for ignoring it.

   - bpo-34248(182): Report filename in the exception raised when the
     database file cannot be opened by *note dbm.gnu.open(): 19aa. and
     *note dbm.ndbm.open(): 19ab. due to OS-related error.  Patch by
     Zsolt Cserna.

   - bpo-33089(183): Add math.dist() to compute the Euclidean distance
     between two points.

   - bpo-34246(184): *note smtplib.SMTP.send_message(): e23. no longer
     modifies the content of the 'mail_options' argument.  Patch by
     Pablo S. Blum de Aguiar.

   - bpo-31047(185): Fix ‘ntpath.abspath’ for invalid paths on windows.
     Patch by Franz Woellert.

   - bpo-32321(186): Add pure Python fallback for functools.reduce.
     Patch by Robert Wright.

   - bpo-34270(187): The default asyncio task class now always has a
     name which can be get or set using two new methods (*note
     get_name(): 9ac. and *note set_name(): 9ab.) and is visible in the
     *note repr(): 7c8. output.  An initial name can also be set using
     the new ‘name’ keyword argument to *note asyncio.create_task():
     5c7. or the ‘create_task()’ method of the event loop.  If no
     initial name is set, the default Task implementation generates a
     name like ‘Task-1’ using a monotonic counter.

   - bpo-34263(188): asyncio's event loop will not pass timeouts longer
     than one day to epoll/select etc.

   - bpo-34035(189): Fix several AttributeError in zipfile seek()
     methods.  Patch by Mickaël Schoentgen.

   - bpo-32215(190): Fix performance regression in *note sqlite3: ba.
     when a DML statement appeared in a different line than the rest of
     the SQL query.

   - bpo-34075(191): Deprecate passing non-ThreadPoolExecutor instances
     to ‘AbstractEventLoop.set_default_executor()’.

   - bpo-34251(192): Restore ‘msilib.Win64’ to preserve backwards
     compatibility since it's already used by ‘distutils’' ‘bdist_msi’
     command.

   - bpo-19891(193): Ignore errors caused by missing / non-writable
     homedir while writing history during exit of an interactive
     session.  Patch by Anthony Sottile.

   - bpo-33089(194): Enhanced math.hypot() to support more than two
     dimensions.

   - bpo-34228(195): tracemalloc: PYTHONTRACEMALLOC=0 environment
     variable and -X tracemalloc=0 command line option are now allowed
     to disable explicitly tracemalloc at startup.

   - bpo-13041(196): Use *note shutil.get_terminal_size(): 10d6. to
     calculate the terminal width correctly in the
     ‘argparse.HelpFormatter’ class.  Initial patch by Zbyszek
     Jędrzejewski-Szmek.

   - bpo-34213(197): Allow frozen dataclasses to have a field named
     "object".  Previously this conflicted with an internal use of
     "object".

   - bpo-34052(198): *note sqlite3.Connection.create_aggregate(): 28a,
     *note sqlite3.Connection.create_function(): 289, *note
     sqlite3.Connection.set_authorizer(): 28b, *note
     sqlite3.Connection.set_progress_handler(): 28c. methods raises
     TypeError when unhashable objects are passed as callable.  These
     methods now don't pass such objects to SQLite API. Previous
     behavior could lead to segfaults.  Patch by Sergey Fedoseev.

   - bpo-34197(199): Attributes 'skipinitialspace', 'doublequote' and
     'strict' of the 'dialect' attribute of the *note csv: 21. reader
     are now *note bool: 434. instances instead of integers 0 or 1.

   - bpo-32788(200): Errors other than *note TypeError: 502. raised in
     methods ‘__adapt__()’ and ‘__conform__()’ in the *note sqlite3: ba.
     module are now propagated to the user.

   - bpo-21446(201): The ‘reload’ fixer now uses *note
     importlib.reload(): 4e2. instead of deprecated ‘imp.reload()’.

   - bpo-940286(202): pydoc's ‘Helper.showtopic()’ method now prints the
     cross references of a topic correctly.

   - bpo-34164(203): *note base64.b32decode(): fef. could raise
     UnboundLocalError or OverflowError for incorrect padding.  Now it
     always raises ‘base64.Error’ in these cases.

   - bpo-33729(204): Fixed issues with arguments parsing in *note
     hashlib: 5e.

   - bpo-34097(205): ZipFile can zip files older than 1980-01-01 and
     newer than 2107-12-31 using a new ‘strict_timestamps’ parameter at
     the cost of setting the timestamp to the limit.

   - bpo-34108(206): Remove extraneous CR in 2to3 refactor.

   - bpo-34070(207): Make sure to only check if the handle is a tty,
     when opening a file with ‘buffering=-1’.

   - bpo-27494(208): Reverted bpo-27494(209).  2to3 rejects now a
     trailing comma in generator expressions.

   - bpo-33967(210): functools.singledispatch now raises TypeError
     instead of IndexError when no positional arguments are passed.

   - bpo-34041(211): Add the parameter 'deterministic' to the *note
     sqlite3.Connection.create_function(): 289. method.  Patch by Sergey
     Fedoseev.

   - bpo-34056(212): Ensure the loader shim created by ‘imp.load_module’
     always returns bytes from its ‘get_data()’ function.  This fixes
     using ‘imp.load_module’ with PEP 552(213) hash-based pycs.

   - bpo-34054(214): The multiprocessing module now uses the monotonic
     clock *note time.monotonic(): 234. instead of the system clock
     *note time.time(): 235. to implement timeout.

   - bpo-34043(215): Optimize tarfile uncompress performance about 15%
     when gzip is used.

   - bpo-34044(216): ‘subprocess.Popen’ now copies the 'startupinfo'
     argument to leave it unchanged: it will modify the copy, so that
     the same ‘STARTUPINFO’ object can be used multiple times.

   - bpo-34010(217): Fixed a performance regression for reading streams
     with tarfile.  The buffered read should use a list, instead of
     appending to a bytes object.

   - bpo-34019(218): webbrowser: Correct the arguments passed to Opera
     Browser when opening a new URL using the ‘webbrowser’ module.
     Patch by Bumsik Kim.

   - bpo-34003(219): csv.DictReader now creates dicts instead of
     OrderedDicts.  Patch by Michael Selik.

   - bpo-33978(220): Closed existing logging handlers before
     reconfiguration via fileConfig and dictConfig.  Patch by
     Karthikeyan Singaravelan.

   - bpo-14117(221): Make minor tweaks to turtledemo.  The 'wikipedia'
     example is now 'rosette', describing what it draws.  The 'penrose'
     print output is reduced.  The'1024' output of 'tree' is eliminated.

   - bpo-33974(222): Fixed passing lists and tuples of strings
     containing special characters ‘"’, ‘\’, ‘{’, ‘}’ and ‘\n’ as
     options to *note ttk: e2. widgets.

   - bpo-27500(223): Fix getaddrinfo to resolve IPv6 addresses
     correctly.

   - bpo-24567(224): Improve random.choices() to handle subnormal input
     weights that could occasionally trigger an IndexError.

   - bpo-33871(225): Fixed integer overflow in *note os.readv(): b2c,
     *note os.writev(): b2f, *note os.preadv(): b2b. and *note
     os.pwritev(): b2e. and in *note os.sendfile(): add. with 'headers'
     or 'trailers' arguments (on BSD-based OSes and macOS).

   - bpo-25007(226): Add *note copy.copy(): 4fd. and *note
     copy.deepcopy(): b3c. support to zlib compressors and
     decompressors.  Patch by Zackery Spytz.

   - bpo-33929(227): multiprocessing: Fix a race condition in Popen of
     multiprocessing.popen_spawn_win32.  The child process now
     duplicates the read end of pipe instead of "stealing" it.
     Previously, the read end of pipe was "stolen" by the child process,
     but it leaked a handle if the child process had been terminated
     before it could steal the handle from the parent process.

   - bpo-33899(228): Tokenize module now implicitly emits a NEWLINE when
     provided with input that does not have a trailing new line.  This
     behavior now matches what the C tokenizer does internally.
     Contributed by Ammar Askar.

   - bpo-33897(229): Added a 'force' keyword argument to
     logging.basicConfig().

   - bpo-33695(230): *note shutil.copytree(): 9f7. uses *note
     os.scandir(): a2d. function and all copy functions depending from
     it use cached *note os.stat(): 46d. values.  The speedup for
     copying a directory with 8000 files is around +9% on Linux, +20% on
     Windows and + 30% on a Windows SMB share.  Also the number of *note
     os.stat(): 46d. syscalls is reduced by 38% making *note
     shutil.copytree(): 9f7. especially faster on network filesystems.
     (Contributed by Giampaolo Rodola' in bpo-33695(231).)

   - bpo-33916(232): bz2 and lzma: When Decompressor.__init__() is
     called twice, free the old lock to not leak memory.

   - bpo-32568(233): Make select.epoll() and its documentation
     consistent regarding 'sizehint' and 'flags'.

   - bpo-33833(234): Fixed bug in asyncio where ProactorSocketTransport
     logs AssertionError if force closed during write.

   - bpo-33663(235): Convert content length to string before putting to
     header.

   - bpo-33721(236): *note os.path: 92. functions that return a boolean
     result like *note exists(): 9dc, *note lexists(): 9dd, *note
     isdir(): 9de, *note isfile(): 9df, *note islink(): 9da, and *note
     ismount(): 9e0, and *note pathlib.Path: 20a. methods that return a
     boolean result like *note exists(): 9e4, *note is_dir(): 211, *note
     is_file(): 210, *note is_mount(): 9e5, *note is_symlink(): 9e6,
     *note is_block_device(): 9e7, *note is_char_device(): 9e8, *note
     is_fifo(): 9e9, *note is_socket(): 9ea. now return ‘False’ instead
     of raising *note ValueError: 1e3. or its subclasses *note
     UnicodeEncodeError: 643. and *note UnicodeDecodeError: 9e1. for
     paths that contain characters or bytes unrepresentable at the OS
     level.

   - bpo-26544(237): Fixed implementation of *note platform.libc_ver():
     199c.  It almost always returned version '2.9' for glibc.

   - bpo-33843(238): Remove deprecated ‘cgi.escape’, ‘cgi.parse_qs’ and
     ‘cgi.parse_qsl’.

   - bpo-33842(239): Remove ‘tarfile.filemode’ which is deprecated since
     Python 3.3.

   - bpo-30167(240): Prevent site.main() exception if PYTHONSTARTUP is
     set.  Patch by Steve Weber.

   - bpo-33805(241): Improve error message of dataclasses.replace() when
     an InitVar is not specified

   - bpo-33687(242): Fix the call to ‘os.chmod()’ for ‘uu.decode()’ if a
     mode is given or decoded.  Patch by Timo Furrer.

   - bpo-33812(243): Datetime instance d with non-None tzinfo, but with
     d.tzinfo.utcoffset(d) returning None is now treated as naive by the
     astimezone() method.

   - bpo-32108(244): In configparser, don't clear section when it is
     assigned to itself.

   - bpo-27397(245): Make email module properly handle invalid-length
     base64 strings.

   - bpo-33578(246): Implement multibyte encoder/decoder state methods

   - bpo-30805(247): Avoid race condition with debug logging

   - bpo-33476(248): Fix _header_value_parser.py when address group is
     missing final ';'.  Contributed by Enrique Perez-Terron

   - bpo-33694(249): asyncio: Fix a race condition causing data loss on
     pause_reading()/resume_reading() when using the ProactorEventLoop.

   - bpo-32493(250): Correct test for ‘uuid_enc_be’ availability in
     ‘configure.ac’.  Patch by Michael Felt.

   - bpo-33792(251): Add asyncio.WindowsSelectorEventLoopPolicy and
     asyncio.WindowsProactorEventLoopPolicy.

   - bpo-33274(252): W3C DOM Level 1 specifies return value of
     Element.removeAttributeNode() as "The Attr node that was removed."
     xml.dom.minidom now complies with this requirement.

   - bpo-33778(253): Update ‘unicodedata’'s database to Unicode version
     11.0.0.

   - bpo-33165(254): Added a stacklevel parameter to logging calls to
     allow use of wrapper/helper functions for logging APIs.

   - bpo-33770(255): improve base64 exception message for encoded inputs
     of invalid length

   - bpo-33769(256): asyncio/start_tls: Fix error message; cancel
     callbacks in case of an unhandled error; mark SSLTransport as
     closed if it is aborted.

   - bpo-33767(257): The concatenation (‘+’) and repetition (‘*’)
     sequence operations now raise *note TypeError: 502. instead of
     *note SystemError: 541. when performed on *note mmap.mmap: 1ec.
     objects.  Patch by Zackery Spytz.

   - bpo-33734(258): asyncio/ssl: Fix AttributeError, increase default
     handshake timeout

   - bpo-31014(259): Fixed creating a controller for *note webbrowser:
     fd. when a user specifies a path to an entry in the BROWSER
     environment variable.  Based on patch by John Still.

   - bpo-2504(260): Add gettext.pgettext() and variants.

   - bpo-33197(261): Add description property for _ParameterKind

   - bpo-32751(262): When cancelling the task due to a timeout, *note
     asyncio.wait_for(): 5ca. will now wait until the cancellation is
     complete.

   - bpo-32684(263): Fix gather to propagate cancellation of itself even
     with return_exceptions.

   - bpo-33654(264): Support protocol type switching in
     SSLTransport.set_protocol().

   - bpo-33674(265): Pause the transport as early as possible to further
     reduce the risk of data_received() being called before
     connection_made().

   - bpo-33671(266): *note shutil.copyfile(): a27, *note shutil.copy():
     a28, *note shutil.copy2(): a29, *note shutil.copytree(): 9f7. and
     *note shutil.move(): a2a. use platform-specific fast-copy syscalls
     on Linux and macOS in order to copy the file more efficiently.  On
     Windows *note shutil.copyfile(): a27. uses a bigger default buffer
     size (1 MiB instead of 16 KiB) and a *note memoryview(): 435.-based
     variant of *note shutil.copyfileobj(): a2b. is used.  The speedup
     for copying a 512MiB file is about +26% on Linux, +50% on macOS and
     +40% on Windows.  Also, much less CPU cycles are consumed.
     (Contributed by Giampaolo Rodola' in bpo-25427(267).)

   - bpo-33674(268): Fix a race condition in
     SSLProtocol.connection_made() of asyncio.sslproto: start
     immediately the handshake instead of using call_soon().
     Previously, data_received() could be called before the handshake
     started, causing the handshake to hang or fail.

   - bpo-31647(269): Fixed bug where calling write_eof() on a
     _SelectorSocketTransport after it's already closed raises
     AttributeError.

   - bpo-32610(270): Make asyncio.all_tasks() return only pending tasks.

   - bpo-32410(271): Avoid blocking on file IO in sendfile fallback code

   - bpo-33469(272): Fix RuntimeError after closing loop that used
     run_in_executor

   - bpo-33672(273): Fix Task.__repr__ crash with Cython's bogus
     coroutines

   - bpo-33654(274): Fix transport.set_protocol() to support switching
     between asyncio.Protocol and asyncio.BufferedProtocol.  Fix
     loop.start_tls() to work with asyncio.BufferedProtocols.

   - bpo-33652(275): Pickles of type variables and subscripted generics
     are now future-proof and compatible with older Python versions.

   - bpo-32493(276): Fixed *note uuid.uuid1(): b76. on FreeBSD.

   - bpo-33238(277): Add ‘InvalidStateError’ to *note
     concurrent.futures: 1a.  ‘Future.set_result’ and
     ‘Future.set_exception’ now raise ‘InvalidStateError’ if the futures
     are not pending or running.  Patch by Jason Haydaman.

   - bpo-33618(278): Finalize and document preliminary and experimental
     TLS 1.3 support with OpenSSL 1.1.1

   - bpo-33625(279): Release GIL on ‘grp.getgrnam’, ‘grp.getgrgid’,
     ‘pwd.getpwnam’ and ‘pwd.getpwuid’ if reentrant variants of these
     functions are available.  Patch by William Grzybowski.

   - bpo-33623(280): Fix possible SIGSGV when asyncio.Future is created
     in __del__

   - bpo-11874(281): Use a better regex when breaking usage into
     wrappable parts.  Avoids bogus assertion errors from custom metavar
     strings.

   - bpo-30877(282): Fixed a bug in the Python implementation of the
     JSON decoder that prevented the cache of parsed strings from
     clearing after finishing the decoding.  Based on patch by c-fos.

   - bpo-33604(283): Remove HMAC default to md5 marked for removal in
     3.8 (removal originally planned in 3.6, bump to 3.8 in PR 7062).

   - bpo-33582(284): Emit a deprecation warning for
     inspect.formatargspec

   - bpo-21145(285): Add ‘functools.cached_property’ decorator, for
     computed properties cached for the life of the instance.

   - bpo-33570(286): Change TLS 1.3 cipher suite settings for
     compatibility with OpenSSL 1.1.1-pre6 and newer.  OpenSSL 1.1.1
     will have TLS 1.3 ciphers enabled by default.

   - bpo-28556(287): Do not simplify arguments to ‘typing.Union’.  Now
     ‘Union[Manager, Employee]’ is not simplified to ‘Employee’ at
     runtime.  Such simplification previously caused several bugs and
     limited possibilities for introspection.

   - bpo-12486(288): *note tokenize.generate_tokens(): 4a7. is now
     documented as a public API to tokenize unicode strings.  It was
     previously present but undocumented.

   - bpo-33540(289): Add a new ‘block_on_close’ class attribute to
     ‘ForkingMixIn’ and ‘ThreadingMixIn’ classes of *note socketserver:
     b9.

   - bpo-33548(290): tempfile._candidate_tempdir_list should consider
     common TEMP locations

   - bpo-33109(291): argparse subparsers are once again not required by
     default, reverting the change in behavior introduced by
     bpo-26510(292) in 3.7.0a2.

   - bpo-33541(293): Remove unused private method
     ‘_strptime.LocaleTime.__pad’ (a.k.a.  ‘_LocaleTime__pad’).

   - bpo-33536(294): dataclasses.make_dataclass now checks for invalid
     field names and duplicate fields.  Also, added a check for invalid
     field specifications.

   - bpo-33542(295): Prevent ‘uuid.get_node’ from using a DUID instead
     of a MAC on Windows.  Patch by Zvi Effron

   - bpo-26819(296): Fix race condition with
     ‘ReadTransport.resume_reading’ in Windows proactor event loop.

   - Fix failure in ‘typing.get_type_hints()’ when ClassVar was provided
     as a string forward reference.

   - bpo-33516(297): *note unittest.mock.MagicMock: e5a. now supports
     the ‘__round__’ magic method.

   - bpo-28612(298): Added support for Site Maps to urllib's
     ‘RobotFileParser’ as *note RobotFileParser.site_maps(): 19ac.
     Patch by Lady Red, based on patch by Peter Wirtz.

   - bpo-28167(299): Remove platform.linux_distribution, which was
     deprecated since 3.5.

   - bpo-33504(300): Switch the default dictionary implementation for
     *note configparser: 1b. from *note collections.OrderedDict: 5a5. to
     the standard *note dict: 237. type.

   - bpo-33505(301): Optimize asyncio.ensure_future() by reordering if
     checks: 1.17x faster.

   - bpo-33497(302): Add errors param to cgi.parse_multipart and make an
     encoding in FieldStorage use the given errors (needed for Twisted).
     Patch by Amber Brown.

   - bpo-29235(303): The ‘cProfile.Profile’ class can now be used as a
     context manager.  Patch by Scott Sanderson.

   - bpo-33495(304): Change dataclasses.Fields repr to use the repr of
     each of its members, instead of str.  This makes it more clear what
     each field actually represents.  This is especially true for the
     'type' member.

   - bpo-26103(305): Correct ‘inspect.isdatadescriptor’ to look for
     ‘__set__’ or ‘__delete__’.  Patch by Aaron Hall.

   - bpo-29209(306): Removed the ‘doctype()’ method and the 'html'
     parameter of the constructor of *note XMLParser: a22.  The
     ‘doctype()’ method defined in a subclass will no longer be called.
     Deprecated methods ‘getchildren()’ and ‘getiterator()’ in the *note
     ElementTree: 10c. module emit now a *note DeprecationWarning: 18a.
     instead of *note PendingDeprecationWarning: 895.

   - bpo-33453(307): Fix dataclasses to work if using literal string
     type annotations or if using PEP 563 "Postponed Evaluation of
     Annotations".  Only specific string prefixes are detected for both
     ClassVar ("ClassVar" and "typing.ClassVar") and InitVar ("InitVar"
     and "dataclasses.InitVar").

   - bpo-28556(308): Minor fixes in typing module: add annotations to
     ‘NamedTuple.__new__’, pass ‘*args’ and ‘**kwds’ in
     ‘Generic.__new__’.  Original PRs by Paulius Šarka and Chad
     Dombrova.

   - bpo-33365(309): Print the header values besides the header keys
     instead just the header keys if 'debuglevel' is set to >0 in *note
     http.client: 65.  Patch by Marco Strigl.

   - bpo-20087(310): Updated alias mapping with glibc 2.27 supported
     locales.

   - bpo-33422(311): Fix trailing quotation marks getting deleted when
     looking up byte/string literals on pydoc.  Patch by Andrés Delfino.

   - bpo-28167(312): The function ‘platform.linux_distribution’ and
     ‘platform.dist’ now trigger a ‘DeprecationWarning’ and have been
     marked for removal in Python 3.8

   - bpo-33281(313): Fix ctypes.util.find_library regression on macOS.

   - bpo-33311(314): Text and html output generated by cgitb does not
     display parentheses if the current call is done directly in the
     module.  Patch by Stéphane Blondon.

   - bpo-27300(315): The file classes in 'tempfile' now accept an
     'errors' parameter that complements the already existing
     'encoding'.  Patch by Stephan Hohe.

   - bpo-32933(316): *note unittest.mock.mock_open(): 166f. now supports
     iteration over the file contents.  Patch by Tony Flury.

   - bpo-33217(317): Raise *note TypeError: 502. when looking up
     non-Enum objects in Enum classes and Enum members.

   - bpo-33197(318): Update error message when constructing invalid
     inspect.Parameters Patch by Donghee Na.

   - bpo-33383(319): Fixed crash in the get() method of the *note
     dbm.ndbm: 2c. database object when it is called with a single
     argument.

   - bpo-33375(320): The warnings module now finds the Python file
     associated with a warning from the code object, rather than the
     frame's global namespace.  This is consistent with how tracebacks
     and pdb find filenames, and should work better for dynamically
     executed code.

   - bpo-33336(321): ‘imaplib’ now allows ‘MOVE’ command in
     ‘IMAP4.uid()’ (RFC 6851: IMAP MOVE Extension) and potentially as a
     name of supported method of ‘IMAP4’ object.

   - bpo-32455(322): Added 'jump' parameter to *note dis.stack_effect():
     efd.

   - bpo-27485(323): Rename and deprecate undocumented functions in
     *note urllib.parse(): f3.

   - bpo-33332(324): Add ‘signal.valid_signals()’ to expose the POSIX
     sigfillset() functionality.

   - bpo-33251(325): ‘ConfigParser.items()’ was fixed so that key-value
     pairs passed in via *note vars(): 19ad. are not included in the
     resulting output.

   - bpo-33329(326): Fix multiprocessing regression on newer glibcs

   - bpo-33334(327): *note dis.stack_effect(): efd. now supports all
     defined opcodes including NOP and EXTENDED_ARG.

   - bpo-991266(328): Fix quoting of the ‘Comment’ attribute of *note
     http.cookies.SimpleCookie: 19ae.

   - bpo-33131(329): Upgrade bundled version of pip to 10.0.1.

   - bpo-33308(330): Fixed a crash in the ‘parser’ module when
     converting an ST object to a tree of tuples or lists with
     ‘line_info=False’ and ‘col_info=True’.

   - bpo-23403(331): lib2to3 now uses pickle protocol 4 for pre-computed
     grammars.

   - bpo-33266(332): lib2to3 now recognizes ‘rf'...'’ strings.

   - bpo-11594(333): Ensure line-endings are respected when using
     lib2to3.

   - bpo-33254(334): Have *note importlib.resources.contents(): 1d3. and
     *note importlib.abc.ResourceReader.contents(): 19af. return an
     *note iterable: 10ad. instead of an *note iterator: 191.

   - bpo-33265(335): ‘contextlib.ExitStack’ and
     ‘contextlib.AsyncExitStack’ now use a method instead of a wrapper
     function for exit callbacks.

   - bpo-33263(336): Fix FD leak in ‘_SelectorSocketTransport’ Patch by
     Vlad Starostin.

   - bpo-33256(337): Fix display of ‘<module>’ call in the html produced
     by ‘cgitb.html()’.  Patch by Stéphane Blondon.

   - bpo-33144(338): ‘random.Random()’ and its subclassing mechanism got
     optimized to check only once at class/subclass instantiation time
     whether its ‘getrandbits()’ method can be relied on by other
     methods, including ‘randrange()’, for the generation of arbitrarily
     large random integers.  Patch by Wolfgang Maier.

   - bpo-33185(339): Fixed regression when running pydoc with the *note
     -m: 5ab. switch.  (The regression was introduced in 3.7.0b3 by the
     resolution of bpo-33053(340))

     This fix also changed pydoc to add ‘os.getcwd()’ to *note sys.path:
     38e. when necessary, rather than adding ‘"."’.

   - bpo-29613(341): Added support for the ‘SameSite’ cookie flag to the
     ‘http.cookies’ module.

   - bpo-33169(342): Delete entries of ‘None’ in *note
     sys.path_importer_cache: 5ae. when
     ‘importlib.machinery.invalidate_caches()’ is called.

   - bpo-33203(343): ‘random.Random.choice()’ now raises ‘IndexError’
     for empty sequences consistently even when called from subclasses
     without a ‘getrandbits()’ implementation.

   - bpo-33224(344): Update difflib.mdiff() for PEP 479(345).  Convert
     an uncaught StopIteration in a generator into a return-statement.

   - bpo-33209(346): End framing at the end of C implementation of *note
     pickle.Pickler.dump(): 19b0.

   - bpo-32861(347): The urllib.robotparser's ‘__str__’ representation
     now includes wildcard entries and the "Crawl-delay" and
     "Request-rate" fields.  Also removes extra newlines that were being
     appended to the end of the string.  Patch by Michael Lazar.

   - bpo-23403(348): ‘DEFAULT_PROTOCOL’ in *note pickle: 95. was bumped
     to 4.  Protocol 4 is described in PEP 3154(349) and available since
     Python 3.4.  It offers better performance and smaller size compared
     to protocol 3 introduced in Python 3.0.

   - bpo-20104(350): Improved error handling and fixed a reference leak
     in *note os.posix_spawn(): 201.

   - bpo-33106(351): Deleting a key from a read-only dbm database raises
     module specific error instead of KeyError.

   - bpo-33175(352): In dataclasses, Field.__set_name__ now looks up the
     __set_name__ special method on the class, not the instance, of the
     default value.

   - bpo-32380(353): Create functools.singledispatchmethod to support
     generic single dispatch on descriptors and methods.

   - bpo-33141(354): Have Field objects pass through __set_name__ to
     their default values, if they have their own __set_name__.

   - bpo-33096(355): Allow ttk.Treeview.insert to insert iid that has a
     false boolean value.  Note iid=0 and iid=False would be same.
     Patch by Garvit Khatri.

   - bpo-32873(356): Treat type variables and special typing forms as
     immutable by copy and pickle.  This fixes several minor issues and
     inconsistencies, and improves backwards compatibility with Python
     3.6.

   - bpo-33134(357): When computing dataclass's __hash__, use the lookup
     table to contain the function which returns the __hash__ value.
     This is an improvement over looking up a string, and then testing
     that string to see what to do.

   - bpo-33127(358): The ssl module now compiles with LibreSSL 2.7.1.

   - bpo-32505(359): Raise TypeError if a member variable of a dataclass
     is of type Field, but doesn't have a type annotation.

   - bpo-33078(360): Fix the failure on OSX caused by the tests relying
     on sem_getvalue

   - bpo-33116(361): Add 'Field' to dataclasses.__all__.

   - bpo-32896(362): Fix an error where subclassing a dataclass with a
     field that uses a default_factory would generate an incorrect
     class.

   - bpo-33100(363): Dataclasses: If a field has a default value that's
     a MemberDescriptorType, then it's from that field being in
     __slots__, not an actual default value.

   - bpo-32953(364): If a non-dataclass inherits from a frozen
     dataclass, allow attributes to be added to the derived class.  Only
     attributes from the frozen dataclass cannot be assigned to.
     Require all dataclasses in a hierarchy to be either all frozen or
     all non-frozen.

   - bpo-33097(365): Raise RuntimeError when ‘executor.submit’ is called
     during interpreter shutdown.

   - bpo-32968(366): Modulo and floor division involving Fraction and
     float should return float.

   - bpo-33061(367): Add missing ‘NoReturn’ to ‘__all__’ in typing.py

   - bpo-33078(368): Fix the size handling in multiprocessing.Queue when
     a pickling error occurs.

   - bpo-33064(369): lib2to3 now properly supports trailing commas after
     ‘*args’ and ‘**kwargs’ in function signatures.

   - bpo-33056(370): FIX properly close leaking fds in
     concurrent.futures.ProcessPoolExecutor.

   - bpo-33021(371): Release the GIL during fstat() calls, avoiding hang
     of all threads when calling mmap.mmap(), os.urandom(), and
     random.seed().  Patch by Nir Soffer.

   - bpo-31804(372): Avoid failing in multiprocessing.Process if the
     standard streams are closed or None at exit.

   - bpo-33034(373): Providing an explicit error message when casting
     the port property to anything that is not an integer value using
     ‘urlparse()’ and ‘urlsplit()’.  Patch by Matt Eaton.

   - bpo-30249(374): Improve struct.unpack_from() exception messages for
     problems with the buffer size and offset.

   - bpo-33037(375): Skip sending/receiving data after SSL transport
     closing.

   - bpo-27683(376): Fix a regression in *note ipaddress: 74. that
     result of ‘hosts()’ is empty when the network is constructed by a
     tuple containing an integer mask and only 1 bit left for addresses.

   - bpo-22674(377): Add the strsignal() function in the signal module
     that returns the system description of the given signal, as
     returned by strsignal(3).

   - bpo-32999(378): Fix C implementation of ‘ABC.__subclasscheck__(cls,
     subclass)’ crashed when ‘subclass’ is not a type object.

   - bpo-33009(379): Fix inspect.signature() for single-parameter
     partialmethods.

   - bpo-32969(380): Expose several missing constants in zlib and fix
     corresponding documentation.

   - bpo-32056(381): Improved exceptions raised for invalid number of
     channels and sample width when read an audio file in modules
     ‘aifc’, *note wave: fb. and ‘sunau’.

   - bpo-32970(382): Improved disassembly of the MAKE_FUNCTION
     instruction.

   - bpo-32844(383): Fix wrong redirection of a low descriptor (0 or 1)
     to stderr in subprocess if another low descriptor is closed.

   - bpo-32960(384): For dataclasses, disallow inheriting frozen from
     non-frozen classes, and also disallow inheriting non-frozen from
     frozen classes.  This restriction will be relaxed at a future date.

   - bpo-32713(385): Fixed tarfile.itn handling of out-of-bounds float
     values.  Patch by Joffrey Fuhrer.

   - bpo-32257(386): The ssl module now contains OP_NO_RENEGOTIATION
     constant, available with OpenSSL 1.1.0h or 1.1.1.

   - bpo-32951(387): Direct instantiation of SSLSocket and SSLObject
     objects is now prohibited.  The constructors were never documented,
     tested, or designed as public constructors.  Users were suppose to
     use ssl.wrap_socket() or SSLContext.

   - bpo-32929(388): Remove the tri-state parameter "hash", and add the
     boolean "unsafe_hash".  If unsafe_hash is True, add a __hash__
     function, but if a __hash__ exists, raise TypeError.  If
     unsafe_hash is False, add a __hash__ based on the values of eq= and
     frozen=.  The unsafe_hash=False behavior is the same as the old
     hash=None behavior.  unsafe_hash=False is the default, just as
     hash=None used to be.

   - bpo-32947(389): Add OP_ENABLE_MIDDLEBOX_COMPAT and test workaround
     for TLSv1.3 for future compatibility with OpenSSL 1.1.1.

   - bpo-32146(390): Document the interaction between frozen executables
     and the spawn and forkserver start methods in multiprocessing.

   - bpo-30622(391): The ssl module now detects missing NPN support in
     LibreSSL.

   - bpo-32922(392): dbm.open() now encodes filename with the filesystem
     encoding rather than default encoding.

   - bpo-32759(393): Free unused arenas in multiprocessing.heap.

   - bpo-32859(394): In ‘os.dup2’, don't check every call whether the
     ‘dup3’ syscall exists or not.

   - bpo-32556(395): nt._getfinalpathname, nt._getvolumepathname and
     nt._getdiskusage now correctly convert from bytes.

   - bpo-21060(396): Rewrite confusing message from setup.py upload from
     "No dist file created in earlier command" to the more helpful "Must
     create and upload files in one command".

   - bpo-32857(397): In *note tkinter: d9, ‘after_cancel(None)’ now
     raises a *note ValueError: 1e3. instead of canceling the first
     scheduled function.  Patch by Cheryl Sabella.

   - bpo-32852(398): Make sure sys.argv remains as a list when running
     trace.

   - bpo-31333(399): ‘_abc’ module is added.  It is a speedup module
     with C implementations for various functions and methods in ‘abc’.
     Creating an ABC subclass and calling ‘isinstance’ or ‘issubclass’
     with an ABC subclass are up to 1.5x faster.  In addition, this
     makes Python start-up up to 10% faster.

     Note that the new implementation hides internal registry and
     caches, previously accessible via private attributes
     ‘_abc_registry’, ‘_abc_cache’, and ‘_abc_negative_cache’.  There
     are three debugging helper methods that can be used instead
     ‘_dump_registry’, ‘_abc_registry_clear’, and ‘_abc_caches_clear’.

   - bpo-32841(400): Fixed ‘asyncio.Condition’ issue which silently
     ignored cancellation after notifying and cancelling a conditional
     lock.  Patch by Bar Harel.

   - bpo-32819(401): ssl.match_hostname() has been simplified and no
     longer depends on re and ipaddress module for wildcard and IP
     addresses.  Error reporting for invalid wildcards has been
     improved.

   - bpo-19675(402): ‘multiprocessing.Pool’ no longer leaks processes if
     its initialization fails.

   - bpo-32394(403): socket: Remove
     TCP_FASTOPEN,TCP_KEEPCNT,TCP_KEEPIDLE,TCP_KEEPINTVL flags on older
     version Windows during run-time.

   - bpo-31787(404): Fixed refleaks of ‘__init__()’ methods in various
     modules.  (Contributed by Oren Milman)

   - bpo-30157(405): Fixed guessing quote and delimiter in
     csv.Sniffer.sniff() when only the last field is quoted.  Patch by
     Jake Davis.

   - bpo-30688(406): Added support of ‘\N{name}’ escapes in regular
     expressions.  Based on patch by Jonathan Eunice.

   - bpo-32792(407): collections.ChainMap() preserves the order of the
     underlying mappings.

   - bpo-32775(408): *note fnmatch.translate(): 19b1. no longer produces
     patterns which contain set operations.  Sets starting with '[' or
     containing '-', '&&', '~~' or '||' will be interpreted differently
     in regular expressions in future versions.  Currently they emit
     warnings.  fnmatch.translate() now avoids producing patterns
     containing such sets by accident.

   - bpo-32622(409): Implement native fast sendfile for Windows proactor
     event loop.

   - bpo-32777(410): Fix a rare but potential pre-exec child process
     deadlock in subprocess on POSIX systems when marking file
     descriptors inheritable on exec in the child process.  This bug
     appears to have been introduced in 3.4.

   - bpo-32647(411): The ctypes module used to depend on indirect
     linking for dlopen.  The shared extension is now explicitly linked
     against libdl on platforms with dl.

   - bpo-32749(412): A *note dbm.dumb: 2a. database opened with flags
     'r' is now read-only.  *note dbm.dumb.open(): a64. with flags 'r'
     and 'w' no longer creates a database if it does not exist.

   - bpo-32741(413): Implement ‘asyncio.TimerHandle.when()’ method.

   - bpo-32691(414): Use mod_spec.parent when running modules with pdb

   - bpo-32734(415): Fixed ‘asyncio.Lock()’ safety issue which allowed
     acquiring and locking the same lock multiple times, without it
     being free.  Patch by Bar Harel.

   - bpo-32727(416): Do not include name field in SMTP envelope from
     address.  Patch by Stéphane Wirtel

   - bpo-31453(417): Add TLSVersion constants and
     SSLContext.maximum_version / minimum_version attributes.  The new
     API wraps OpenSSL 1.1
     ‘https://web.archive.org/web/20180309043602/https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set_min_proto_version.html’
     feature.

   - bpo-24334(418): Internal implementation details of ssl module were
     cleaned up.  The SSLSocket has one less layer of indirection.
     Owner and session information are now handled by the SSLSocket and
     SSLObject constructor.  Channel binding implementation has been
     simplified.

   - bpo-31848(419): Fix the error handling in Aifc_read.initfp() when
     the SSND chunk is not found.  Patch by Zackery Spytz.

   - bpo-32585(420): Add Ttk spinbox widget to *note tkinter.ttk: e2.
     Patch by Alan D Moore.

   - bpo-32512(421): *note profile: 9d. CLI accepts ‘-m module_name’ as
     an alternative to script path.

   - bpo-8525(422): help() on a type now displays builtin subclasses.
     This is intended primarily to help with notification of more
     specific exception subclasses.

     Patch by Sanyam Khurana.

   - bpo-31639(423): http.server now exposes a ThreadingHTTPServer class
     and uses it when the module is run with ‘-m’ to cope with web
     browsers pre-opening sockets.

   - bpo-29877(424): compileall: import ProcessPoolExecutor only when
     needed, preventing hangs on low resource platforms

   - bpo-32221(425): Various functions returning tuple containing IPv6
     addresses now omit ‘%scope’ part since the same information is
     already encoded in 'scopeid' tuple item.  Especially this speeds up
     ‘socket.recvfrom()’ when it receives multicast packet since useless
     resolving of network interface name is omitted.

   - bpo-32147(426): *note binascii.unhexlify(): 19b2. is now up to 2
     times faster.  Patch by Sergey Fedoseev.

   - bpo-30693(427): The TarFile class now recurses directories in a
     reproducible way.

   - bpo-30693(428): The ZipFile class now recurses directories in a
     reproducible way.

   - bpo-31680(429): Added *note curses.ncurses_version: 9b5.

   - bpo-31908(430): Fix output of cover files for ‘trace’ module
     command-line tool.  Previously emitted cover files only when
     ‘--missing’ option was used.  Patch by Michael Selik.

   - bpo-31608(431): Raise a ‘TypeError’ instead of crashing if a
     ‘collections.deque’ subclass returns a non-deque from ‘__new__’.
     Patch by Oren Milman.

   - bpo-31425(432): Add support for sockets of the AF_QIPCRTR address
     family, supported by the Linux kernel.  This is used to communicate
     with services, such as GPS or radio, running on Qualcomm devices.
     Patch by Bjorn Andersson.

   - bpo-22005(433): Implemented unpickling instances of *note datetime:
     1ae, *note date: 1af. and *note time: 1b0. pickled by Python 2.
     ‘encoding='latin1'’ should be used for successful decoding.

   - bpo-27645(434): *note sqlite3.Connection: 226. now exposes a *note
     backup: b48. method, if the underlying SQLite library is at version
     3.6.11 or higher.  Patch by Lele Gaifax.

   - bpo-16865(435): Support arrays >=2GiB in *note ctypes: 22.  Patch
     by Segev Finer.

   - bpo-31508(436): Removed support of arguments in
     ‘tkinter.ttk.Treeview.selection’.  It was deprecated in 3.6.  Use
     specialized methods like ‘selection_set’ for changing the
     selection.

   - bpo-29456(437): Fix bugs in hangul normalization: u1176, u11a7 and
     u11c3

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35845

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35864

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35537

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35847

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35813

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35780

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35537

   (8) https://bugs.python.org/issue?@action=redirect&bpo=23846

   (9) https://bugs.python.org/issue?@action=redirect&bpo=34323

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35674

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35733

   (12) https://bugs.python.org/issue?@action=redirect&bpo=35726

   (13) https://bugs.python.org/issue?@action=redirect&bpo=35719

   (14) https://bugs.python.org/issue?@action=redirect&bpo=35717

   (15) https://bugs.python.org/issue?@action=redirect&bpo=35699

   (16) https://bugs.python.org/issue?@action=redirect&bpo=32710

   (17) https://bugs.python.org/issue?@action=redirect&bpo=35702

   (18) https://bugs.python.org/issue?@action=redirect&bpo=32710

   (19) https://bugs.python.org/issue?@action=redirect&bpo=35682

   (20) https://bugs.python.org/issue?@action=redirect&bpo=35283

   (21) https://bugs.python.org/issue?@action=redirect&bpo=35664

   (22) https://bugs.python.org/issue?@action=redirect&bpo=35643

   (23) https://bugs.python.org/issue?@action=redirect&bpo=35619

   (24) https://bugs.python.org/issue?@action=redirect&bpo=28503

   (25) https://bugs.python.org/issue?@action=redirect&bpo=35614

   (26) https://bugs.python.org/issue?@action=redirect&bpo=35568

   (27) https://bugs.python.org/issue?@action=redirect&bpo=35588

   (28) https://bugs.python.org/issue?@action=redirect&bpo=35585

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30561

   (30) https://bugs.python.org/issue?@action=redirect&bpo=35537

   (31) https://bugs.python.org/issue?@action=redirect&bpo=35526

   (32) https://bugs.python.org/issue?@action=redirect&bpo=35523

   (33) https://bugs.python.org/issue?@action=redirect&bpo=31784

   (34) https://bugs.python.org/issue?@action=redirect&bpo=35513

   (35) https://bugs.python.org/issue?@action=redirect&bpo=35502

   (36) https://bugs.python.org/issue?@action=redirect&bpo=35348

   (37) https://bugs.python.org/issue?@action=redirect&bpo=35491

   (38) https://bugs.python.org/issue?@action=redirect&bpo=35477

   (39) https://bugs.python.org/issue?@action=redirect&bpo=31446

   (40) https://bugs.python.org/issue?@action=redirect&bpo=35471

   (41) https://bugs.python.org/issue?@action=redirect&bpo=23057

   (42) https://bugs.python.org/issue?@action=redirect&bpo=35052

   (43) https://bugs.python.org/issue?@action=redirect&bpo=20239

   (44) https://bugs.python.org/issue?@action=redirect&bpo=17185

   (45) https://bugs.python.org/issue?@action=redirect&bpo=35445

   (46) https://bugs.python.org/issue?@action=redirect&bpo=35415

   (47) https://bugs.python.org/issue?@action=redirect&bpo=35424

   (48) https://bugs.python.org/issue?@action=redirect&bpo=35330

   (49) https://bugs.python.org/issue?@action=redirect&bpo=35346

   (50) https://bugs.python.org/issue?@action=redirect&bpo=10496

   (51) https://bugs.python.org/issue?@action=redirect&bpo=10496

   (52) https://bugs.python.org/issue?@action=redirect&bpo=35389

   (53) https://bugs.python.org/issue?@action=redirect&bpo=35394

   (54) https://bugs.python.org/issue?@action=redirect&bpo=35310

   (55) https://bugs.python.org/issue?@action=redirect&bpo=35380

   (56) https://bugs.python.org/issue?@action=redirect&bpo=35341

   (57) https://bugs.python.org/issue?@action=redirect&bpo=35371

   (58) https://bugs.python.org/issue?@action=redirect&bpo=35346

   (59) https://bugs.python.org/issue?@action=redirect&bpo=35066

   (60) https://bugs.python.org/issue?@action=redirect&bpo=35345

   (61) https://bugs.python.org/issue?@action=redirect&bpo=35344

   (62) https://bugs.python.org/issue?@action=redirect&bpo=35312

   (63) https://bugs.python.org/issue?@action=redirect&bpo=35308

   (64) https://bugs.python.org/issue?@action=redirect&bpo=24746

   (65) https://bugs.python.org/issue?@action=redirect&bpo=28604

   (66) https://bugs.python.org/issue?@action=redirect&bpo=35277

   (67) https://bugs.python.org/issue?@action=redirect&bpo=24209

   (68) https://bugs.python.org/issue?@action=redirect&bpo=35226

   (69) https://bugs.python.org/issue?@action=redirect&bpo=29564

   (70) https://bugs.python.org/issue?@action=redirect&bpo=35189

   (71) https://bugs.python.org/issue?@action=redirect&bpo=30064

   (72) https://bugs.python.org/issue?@action=redirect&bpo=35186

   (73) https://bugs.python.org/issue?@action=redirect&bpo=35152

   (74) https://bugs.python.org/issue?@action=redirect&bpo=35062

   (75) https://bugs.python.org/issue?@action=redirect&bpo=35065

   (76) https://bugs.python.org/issue?@action=redirect&bpo=34160

   (77) https://bugs.python.org/issue?@action=redirect&bpo=35079

   (78) https://bugs.python.org/issue?@action=redirect&bpo=33710

   (79) https://bugs.python.org/issue?@action=redirect&bpo=35017

   (80) https://bugs.python.org/issue?@action=redirect&bpo=35024

   (81) https://bugs.python.org/issue?@action=redirect&bpo=35047

   (82) https://bugs.python.org/issue?@action=redirect&bpo=31047

   (83) https://bugs.python.org/issue?@action=redirect&bpo=35053

   (84) https://bugs.python.org/issue?@action=redirect&bpo=31553

   (85) https://bugs.python.org/issue?@action=redirect&bpo=34794

   (86) https://bugs.python.org/issue?@action=redirect&bpo=34909

   (87) https://bugs.python.org/issue?@action=redirect&bpo=35022

   (88) https://bugs.python.org/issue?@action=redirect&bpo=35008

   (89) https://bugs.python.org/issue?@action=redirect&bpo=23420

   (90) https://bugs.python.org/issue?@action=redirect&bpo=33947

   (91) https://bugs.python.org/issue?@action=redirect&bpo=34890

   (92) https://bugs.python.org/issue?@action=redirect&bpo=34521

   (93) https://datatracker.ietf.org/doc/html/rfc3542.html

   (94) https://bugs.python.org/issue?@action=redirect&bpo=31522

   (95) https://bugs.python.org/issue?@action=redirect&bpo=34970

   (96) https://bugs.python.org/issue?@action=redirect&bpo=34969

   (97) https://bugs.python.org/issue?@action=redirect&bpo=16965

   (98) https://bugs.python.org/issue?@action=redirect&bpo=34966

   (99) https://bugs.python.org/issue?@action=redirect&bpo=34926

   (100) https://bugs.python.org/issue?@action=redirect&bpo=23831

   (101) https://bugs.python.org/issue?@action=redirect&bpo=34941

   (102) https://bugs.python.org/issue?@action=redirect&bpo=32680

   (103) https://bugs.python.org/issue?@action=redirect&bpo=34769

   (104) https://bugs.python.org/issue?@action=redirect&bpo=34936

   (105) https://bugs.python.org/issue?@action=redirect&bpo=34829

   (106) https://bugs.python.org/issue?@action=redirect&bpo=34911

   (107) https://bugs.python.org/issue?@action=redirect&bpo=34922

   (108) https://bugs.python.org/issue?@action=redirect&bpo=34925

   (109) https://bugs.python.org/issue?@action=redirect&bpo=34900

   (110) https://bugs.python.org/issue?@action=redirect&bpo=34844

   (111) https://bugs.python.org/issue?@action=redirect&bpo=34897

   (112) https://bugs.python.org/issue?@action=redirect&bpo=34871

   (113) https://bugs.python.org/issue?@action=redirect&bpo=34898

   (114) https://bugs.python.org/issue?@action=redirect&bpo=28441

   (115) https://bugs.python.org/issue?@action=redirect&bpo=34866

   (116) https://bugs.python.org/issue?@action=redirect&bpo=34711

   (117) https://bugs.python.org/issue?@action=redirect&bpo=34872

   (118) https://bugs.python.org/issue?@action=redirect&bpo=34849

   (119) https://bugs.python.org/issue?@action=redirect&bpo=34022

   (120) https://bugs.python.org/issue?@action=redirect&bpo=34819

   (121) https://bugs.python.org/issue?@action=redirect&bpo=34758

   (122) https://bugs.python.org/issue?@action=redirect&bpo=34789

   (123) https://bugs.python.org/issue?@action=redirect&bpo=34334

   (124) https://bugs.python.org/issue?@action=redirect&bpo=34687

   (125) https://bugs.python.org/issue?@action=redirect&bpo=5950

   (126) https://bugs.python.org/issue?@action=redirect&bpo=32892

   (127) https://bugs.python.org/issue?@action=redirect&bpo=34728

   (128) https://bugs.python.org/issue?@action=redirect&bpo=34738

   (129) https://bugs.python.org/issue?@action=redirect&bpo=34659

   (130) https://bugs.python.org/issue?@action=redirect&bpo=29577

   (131) https://bugs.python.org/issue?@action=redirect&bpo=34670

   (132) https://bugs.python.org/issue?@action=redirect&bpo=32718

   (133) https://bugs.python.org/issue?@action=redirect&bpo=31177

   (134) https://bugs.python.org/issue?@action=redirect&bpo=34672

   (135) https://bugs.python.org/issue?@action=redirect&bpo=34666

   (136) https://bugs.python.org/issue?@action=redirect&bpo=6721

   (137) https://bugs.python.org/issue?@action=redirect&bpo=34658

   (138) https://bugs.python.org/issue?@action=redirect&bpo=34652

   (139) https://bugs.python.org/issue?@action=redirect&bpo=34638

   (140) https://bugs.python.org/issue?@action=redirect&bpo=34536

   (141) https://bugs.python.org/issue?@action=redirect&bpo=34636

   (142) https://bugs.python.org/issue?@action=redirect&bpo=24412

   (143) https://bugs.python.org/issue?@action=redirect&bpo=34630

   (144) https://bugs.python.org/issue?@action=redirect&bpo=32490

   (145) https://bugs.python.org/issue?@action=redirect&bpo=34363

   (146) https://bugs.python.org/issue?@action=redirect&bpo=34625

   (147) https://bugs.python.org/issue?@action=redirect&bpo=32270

   (148) https://bugs.python.org/issue?@action=redirect&bpo=34622

   (149) https://bugs.python.org/issue?@action=redirect&bpo=34610

   (150) https://bugs.python.org/issue?@action=redirect&bpo=34421

   (151) https://bugs.python.org/issue?@action=redirect&bpo=34604

   (152) https://bugs.python.org/issue?@action=redirect&bpo=30977

   (153) https://bugs.python.org/issue?@action=redirect&bpo=34574

   (154) https://bugs.python.org/issue?@action=redirect&bpo=8110

   (155) https://bugs.python.org/issue?@action=redirect&bpo=34530

   (156) https://bugs.python.org/issue?@action=redirect&bpo=34563

   (157) https://bugs.python.org/issue?@action=redirect&bpo=34558

   (158) https://bugs.python.org/issue?@action=redirect&bpo=34282

   (159) https://bugs.python.org/issue?@action=redirect&bpo=22872

   (160) https://bugs.python.org/issue?@action=redirect&bpo=34515

   (161) https://peps.python.org/pep-3131/

   (162) https://bugs.python.org/issue?@action=redirect&bpo=13312

   (163) https://bugs.python.org/issue?@action=redirect&bpo=34472

   (164) https://bugs.python.org/issue?@action=redirect&bpo=34454

   (165) https://bugs.python.org/issue?@action=redirect&bpo=6700

   (166) https://bugs.python.org/issue?@action=redirect&bpo=34171

   (167) https://bugs.python.org/issue?@action=redirect&bpo=34441

   (168) https://bugs.python.org/issue?@action=redirect&bpo=34427

   (169) https://bugs.python.org/issue?@action=redirect&bpo=34412

   (170) https://bugs.python.org/issue?@action=redirect&bpo=20849

   (171) https://bugs.python.org/issue?@action=redirect&bpo=31715

   (172) https://bugs.python.org/issue?@action=redirect&bpo=34384

   (173) https://bugs.python.org/issue?@action=redirect&bpo=22602

   (174) https://bugs.python.org/issue?@action=redirect&bpo=2122

   (175) https://bugs.python.org/issue?@action=redirect&bpo=34341

   (176) https://bugs.python.org/issue?@action=redirect&bpo=34333

   (177) https://bugs.python.org/issue?@action=redirect&bpo=18540

   (178) https://bugs.python.org/issue?@action=redirect&bpo=26502

   (179) https://bugs.python.org/issue?@action=redirect&bpo=34318

   (180) https://bugs.python.org/issue?@action=redirect&bpo=9372

   (181) https://bugs.python.org/issue?@action=redirect&bpo=33613

   (182) https://bugs.python.org/issue?@action=redirect&bpo=34248

   (183) https://bugs.python.org/issue?@action=redirect&bpo=33089

   (184) https://bugs.python.org/issue?@action=redirect&bpo=34246

   (185) https://bugs.python.org/issue?@action=redirect&bpo=31047

   (186) https://bugs.python.org/issue?@action=redirect&bpo=32321

   (187) https://bugs.python.org/issue?@action=redirect&bpo=34270

   (188) https://bugs.python.org/issue?@action=redirect&bpo=34263

   (189) https://bugs.python.org/issue?@action=redirect&bpo=34035

   (190) https://bugs.python.org/issue?@action=redirect&bpo=32215

   (191) https://bugs.python.org/issue?@action=redirect&bpo=34075

   (192) https://bugs.python.org/issue?@action=redirect&bpo=34251

   (193) https://bugs.python.org/issue?@action=redirect&bpo=19891

   (194) https://bugs.python.org/issue?@action=redirect&bpo=33089

   (195) https://bugs.python.org/issue?@action=redirect&bpo=34228

   (196) https://bugs.python.org/issue?@action=redirect&bpo=13041

   (197) https://bugs.python.org/issue?@action=redirect&bpo=34213

   (198) https://bugs.python.org/issue?@action=redirect&bpo=34052

   (199) https://bugs.python.org/issue?@action=redirect&bpo=34197

   (200) https://bugs.python.org/issue?@action=redirect&bpo=32788

   (201) https://bugs.python.org/issue?@action=redirect&bpo=21446

   (202) https://bugs.python.org/issue?@action=redirect&bpo=940286

   (203) https://bugs.python.org/issue?@action=redirect&bpo=34164

   (204) https://bugs.python.org/issue?@action=redirect&bpo=33729

   (205) https://bugs.python.org/issue?@action=redirect&bpo=34097

   (206) https://bugs.python.org/issue?@action=redirect&bpo=34108

   (207) https://bugs.python.org/issue?@action=redirect&bpo=34070

   (208) https://bugs.python.org/issue?@action=redirect&bpo=27494

   (209) https://bugs.python.org/issue?@action=redirect&bpo=27494

   (210) https://bugs.python.org/issue?@action=redirect&bpo=33967

   (211) https://bugs.python.org/issue?@action=redirect&bpo=34041

   (212) https://bugs.python.org/issue?@action=redirect&bpo=34056

   (213) https://peps.python.org/pep-0552/

   (214) https://bugs.python.org/issue?@action=redirect&bpo=34054

   (215) https://bugs.python.org/issue?@action=redirect&bpo=34043

   (216) https://bugs.python.org/issue?@action=redirect&bpo=34044

   (217) https://bugs.python.org/issue?@action=redirect&bpo=34010

   (218) https://bugs.python.org/issue?@action=redirect&bpo=34019

   (219) https://bugs.python.org/issue?@action=redirect&bpo=34003

   (220) https://bugs.python.org/issue?@action=redirect&bpo=33978

   (221) https://bugs.python.org/issue?@action=redirect&bpo=14117

   (222) https://bugs.python.org/issue?@action=redirect&bpo=33974

   (223) https://bugs.python.org/issue?@action=redirect&bpo=27500

   (224) https://bugs.python.org/issue?@action=redirect&bpo=24567

   (225) https://bugs.python.org/issue?@action=redirect&bpo=33871

   (226) https://bugs.python.org/issue?@action=redirect&bpo=25007

   (227) https://bugs.python.org/issue?@action=redirect&bpo=33929

   (228) https://bugs.python.org/issue?@action=redirect&bpo=33899

   (229) https://bugs.python.org/issue?@action=redirect&bpo=33897

   (230) https://bugs.python.org/issue?@action=redirect&bpo=33695

   (231) https://bugs.python.org/issue?@action=redirect&bpo=33695

   (232) https://bugs.python.org/issue?@action=redirect&bpo=33916

   (233) https://bugs.python.org/issue?@action=redirect&bpo=32568

   (234) https://bugs.python.org/issue?@action=redirect&bpo=33833

   (235) https://bugs.python.org/issue?@action=redirect&bpo=33663

   (236) https://bugs.python.org/issue?@action=redirect&bpo=33721

   (237) https://bugs.python.org/issue?@action=redirect&bpo=26544

   (238) https://bugs.python.org/issue?@action=redirect&bpo=33843

   (239) https://bugs.python.org/issue?@action=redirect&bpo=33842

   (240) https://bugs.python.org/issue?@action=redirect&bpo=30167

   (241) https://bugs.python.org/issue?@action=redirect&bpo=33805

   (242) https://bugs.python.org/issue?@action=redirect&bpo=33687

   (243) https://bugs.python.org/issue?@action=redirect&bpo=33812

   (244) https://bugs.python.org/issue?@action=redirect&bpo=32108

   (245) https://bugs.python.org/issue?@action=redirect&bpo=27397

   (246) https://bugs.python.org/issue?@action=redirect&bpo=33578

   (247) https://bugs.python.org/issue?@action=redirect&bpo=30805

   (248) https://bugs.python.org/issue?@action=redirect&bpo=33476

   (249) https://bugs.python.org/issue?@action=redirect&bpo=33694

   (250) https://bugs.python.org/issue?@action=redirect&bpo=32493

   (251) https://bugs.python.org/issue?@action=redirect&bpo=33792

   (252) https://bugs.python.org/issue?@action=redirect&bpo=33274

   (253) https://bugs.python.org/issue?@action=redirect&bpo=33778

   (254) https://bugs.python.org/issue?@action=redirect&bpo=33165

   (255) https://bugs.python.org/issue?@action=redirect&bpo=33770

   (256) https://bugs.python.org/issue?@action=redirect&bpo=33769

   (257) https://bugs.python.org/issue?@action=redirect&bpo=33767

   (258) https://bugs.python.org/issue?@action=redirect&bpo=33734

   (259) https://bugs.python.org/issue?@action=redirect&bpo=31014

   (260) https://bugs.python.org/issue?@action=redirect&bpo=2504

   (261) https://bugs.python.org/issue?@action=redirect&bpo=33197

   (262) https://bugs.python.org/issue?@action=redirect&bpo=32751

   (263) https://bugs.python.org/issue?@action=redirect&bpo=32684

   (264) https://bugs.python.org/issue?@action=redirect&bpo=33654

   (265) https://bugs.python.org/issue?@action=redirect&bpo=33674

   (266) https://bugs.python.org/issue?@action=redirect&bpo=33671

   (267) https://bugs.python.org/issue?@action=redirect&bpo=25427

   (268) https://bugs.python.org/issue?@action=redirect&bpo=33674

   (269) https://bugs.python.org/issue?@action=redirect&bpo=31647

   (270) https://bugs.python.org/issue?@action=redirect&bpo=32610

   (271) https://bugs.python.org/issue?@action=redirect&bpo=32410

   (272) https://bugs.python.org/issue?@action=redirect&bpo=33469

   (273) https://bugs.python.org/issue?@action=redirect&bpo=33672

   (274) https://bugs.python.org/issue?@action=redirect&bpo=33654

   (275) https://bugs.python.org/issue?@action=redirect&bpo=33652

   (276) https://bugs.python.org/issue?@action=redirect&bpo=32493

   (277) https://bugs.python.org/issue?@action=redirect&bpo=33238

   (278) https://bugs.python.org/issue?@action=redirect&bpo=33618

   (279) https://bugs.python.org/issue?@action=redirect&bpo=33625

   (280) https://bugs.python.org/issue?@action=redirect&bpo=33623

   (281) https://bugs.python.org/issue?@action=redirect&bpo=11874

   (282) https://bugs.python.org/issue?@action=redirect&bpo=30877

   (283) https://bugs.python.org/issue?@action=redirect&bpo=33604

   (284) https://bugs.python.org/issue?@action=redirect&bpo=33582

   (285) https://bugs.python.org/issue?@action=redirect&bpo=21145

   (286) https://bugs.python.org/issue?@action=redirect&bpo=33570

   (287) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (288) https://bugs.python.org/issue?@action=redirect&bpo=12486

   (289) https://bugs.python.org/issue?@action=redirect&bpo=33540

   (290) https://bugs.python.org/issue?@action=redirect&bpo=33548

   (291) https://bugs.python.org/issue?@action=redirect&bpo=33109

   (292) https://bugs.python.org/issue?@action=redirect&bpo=26510

   (293) https://bugs.python.org/issue?@action=redirect&bpo=33541

   (294) https://bugs.python.org/issue?@action=redirect&bpo=33536

   (295) https://bugs.python.org/issue?@action=redirect&bpo=33542

   (296) https://bugs.python.org/issue?@action=redirect&bpo=26819

   (297) https://bugs.python.org/issue?@action=redirect&bpo=33516

   (298) https://bugs.python.org/issue?@action=redirect&bpo=28612

   (299) https://bugs.python.org/issue?@action=redirect&bpo=28167

   (300) https://bugs.python.org/issue?@action=redirect&bpo=33504

   (301) https://bugs.python.org/issue?@action=redirect&bpo=33505

   (302) https://bugs.python.org/issue?@action=redirect&bpo=33497

   (303) https://bugs.python.org/issue?@action=redirect&bpo=29235

   (304) https://bugs.python.org/issue?@action=redirect&bpo=33495

   (305) https://bugs.python.org/issue?@action=redirect&bpo=26103

   (306) https://bugs.python.org/issue?@action=redirect&bpo=29209

   (307) https://bugs.python.org/issue?@action=redirect&bpo=33453

   (308) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (309) https://bugs.python.org/issue?@action=redirect&bpo=33365

   (310) https://bugs.python.org/issue?@action=redirect&bpo=20087

   (311) https://bugs.python.org/issue?@action=redirect&bpo=33422

   (312) https://bugs.python.org/issue?@action=redirect&bpo=28167

   (313) https://bugs.python.org/issue?@action=redirect&bpo=33281

   (314) https://bugs.python.org/issue?@action=redirect&bpo=33311

   (315) https://bugs.python.org/issue?@action=redirect&bpo=27300

   (316) https://bugs.python.org/issue?@action=redirect&bpo=32933

   (317) https://bugs.python.org/issue?@action=redirect&bpo=33217

   (318) https://bugs.python.org/issue?@action=redirect&bpo=33197

   (319) https://bugs.python.org/issue?@action=redirect&bpo=33383

   (320) https://bugs.python.org/issue?@action=redirect&bpo=33375

   (321) https://bugs.python.org/issue?@action=redirect&bpo=33336

   (322) https://bugs.python.org/issue?@action=redirect&bpo=32455

   (323) https://bugs.python.org/issue?@action=redirect&bpo=27485

   (324) https://bugs.python.org/issue?@action=redirect&bpo=33332

   (325) https://bugs.python.org/issue?@action=redirect&bpo=33251

   (326) https://bugs.python.org/issue?@action=redirect&bpo=33329

   (327) https://bugs.python.org/issue?@action=redirect&bpo=33334

   (328) https://bugs.python.org/issue?@action=redirect&bpo=991266

   (329) https://bugs.python.org/issue?@action=redirect&bpo=33131

   (330) https://bugs.python.org/issue?@action=redirect&bpo=33308

   (331) https://bugs.python.org/issue?@action=redirect&bpo=23403

   (332) https://bugs.python.org/issue?@action=redirect&bpo=33266

   (333) https://bugs.python.org/issue?@action=redirect&bpo=11594

   (334) https://bugs.python.org/issue?@action=redirect&bpo=33254

   (335) https://bugs.python.org/issue?@action=redirect&bpo=33265

   (336) https://bugs.python.org/issue?@action=redirect&bpo=33263

   (337) https://bugs.python.org/issue?@action=redirect&bpo=33256

   (338) https://bugs.python.org/issue?@action=redirect&bpo=33144

   (339) https://bugs.python.org/issue?@action=redirect&bpo=33185

   (340) https://bugs.python.org/issue?@action=redirect&bpo=33053

   (341) https://bugs.python.org/issue?@action=redirect&bpo=29613

   (342) https://bugs.python.org/issue?@action=redirect&bpo=33169

   (343) https://bugs.python.org/issue?@action=redirect&bpo=33203

   (344) https://bugs.python.org/issue?@action=redirect&bpo=33224

   (345) https://peps.python.org/pep-0479/

   (346) https://bugs.python.org/issue?@action=redirect&bpo=33209

   (347) https://bugs.python.org/issue?@action=redirect&bpo=32861

   (348) https://bugs.python.org/issue?@action=redirect&bpo=23403

   (349) https://peps.python.org/pep-3154/

   (350) https://bugs.python.org/issue?@action=redirect&bpo=20104

   (351) https://bugs.python.org/issue?@action=redirect&bpo=33106

   (352) https://bugs.python.org/issue?@action=redirect&bpo=33175

   (353) https://bugs.python.org/issue?@action=redirect&bpo=32380

   (354) https://bugs.python.org/issue?@action=redirect&bpo=33141

   (355) https://bugs.python.org/issue?@action=redirect&bpo=33096

   (356) https://bugs.python.org/issue?@action=redirect&bpo=32873

   (357) https://bugs.python.org/issue?@action=redirect&bpo=33134

   (358) https://bugs.python.org/issue?@action=redirect&bpo=33127

   (359) https://bugs.python.org/issue?@action=redirect&bpo=32505

   (360) https://bugs.python.org/issue?@action=redirect&bpo=33078

   (361) https://bugs.python.org/issue?@action=redirect&bpo=33116

   (362) https://bugs.python.org/issue?@action=redirect&bpo=32896

   (363) https://bugs.python.org/issue?@action=redirect&bpo=33100

   (364) https://bugs.python.org/issue?@action=redirect&bpo=32953

   (365) https://bugs.python.org/issue?@action=redirect&bpo=33097

   (366) https://bugs.python.org/issue?@action=redirect&bpo=32968

   (367) https://bugs.python.org/issue?@action=redirect&bpo=33061

   (368) https://bugs.python.org/issue?@action=redirect&bpo=33078

   (369) https://bugs.python.org/issue?@action=redirect&bpo=33064

   (370) https://bugs.python.org/issue?@action=redirect&bpo=33056

   (371) https://bugs.python.org/issue?@action=redirect&bpo=33021

   (372) https://bugs.python.org/issue?@action=redirect&bpo=31804

   (373) https://bugs.python.org/issue?@action=redirect&bpo=33034

   (374) https://bugs.python.org/issue?@action=redirect&bpo=30249

   (375) https://bugs.python.org/issue?@action=redirect&bpo=33037

   (376) https://bugs.python.org/issue?@action=redirect&bpo=27683

   (377) https://bugs.python.org/issue?@action=redirect&bpo=22674

   (378) https://bugs.python.org/issue?@action=redirect&bpo=32999

   (379) https://bugs.python.org/issue?@action=redirect&bpo=33009

   (380) https://bugs.python.org/issue?@action=redirect&bpo=32969

   (381) https://bugs.python.org/issue?@action=redirect&bpo=32056

   (382) https://bugs.python.org/issue?@action=redirect&bpo=32970

   (383) https://bugs.python.org/issue?@action=redirect&bpo=32844

   (384) https://bugs.python.org/issue?@action=redirect&bpo=32960

   (385) https://bugs.python.org/issue?@action=redirect&bpo=32713

   (386) https://bugs.python.org/issue?@action=redirect&bpo=32257

   (387) https://bugs.python.org/issue?@action=redirect&bpo=32951

   (388) https://bugs.python.org/issue?@action=redirect&bpo=32929

   (389) https://bugs.python.org/issue?@action=redirect&bpo=32947

   (390) https://bugs.python.org/issue?@action=redirect&bpo=32146

   (391) https://bugs.python.org/issue?@action=redirect&bpo=30622

   (392) https://bugs.python.org/issue?@action=redirect&bpo=32922

   (393) https://bugs.python.org/issue?@action=redirect&bpo=32759

   (394) https://bugs.python.org/issue?@action=redirect&bpo=32859

   (395) https://bugs.python.org/issue?@action=redirect&bpo=32556

   (396) https://bugs.python.org/issue?@action=redirect&bpo=21060

   (397) https://bugs.python.org/issue?@action=redirect&bpo=32857

   (398) https://bugs.python.org/issue?@action=redirect&bpo=32852

   (399) https://bugs.python.org/issue?@action=redirect&bpo=31333

   (400) https://bugs.python.org/issue?@action=redirect&bpo=32841

   (401) https://bugs.python.org/issue?@action=redirect&bpo=32819

   (402) https://bugs.python.org/issue?@action=redirect&bpo=19675

   (403) https://bugs.python.org/issue?@action=redirect&bpo=32394

   (404) https://bugs.python.org/issue?@action=redirect&bpo=31787

   (405) https://bugs.python.org/issue?@action=redirect&bpo=30157

   (406) https://bugs.python.org/issue?@action=redirect&bpo=30688

   (407) https://bugs.python.org/issue?@action=redirect&bpo=32792

   (408) https://bugs.python.org/issue?@action=redirect&bpo=32775

   (409) https://bugs.python.org/issue?@action=redirect&bpo=32622

   (410) https://bugs.python.org/issue?@action=redirect&bpo=32777

   (411) https://bugs.python.org/issue?@action=redirect&bpo=32647

   (412) https://bugs.python.org/issue?@action=redirect&bpo=32749

   (413) https://bugs.python.org/issue?@action=redirect&bpo=32741

   (414) https://bugs.python.org/issue?@action=redirect&bpo=32691

   (415) https://bugs.python.org/issue?@action=redirect&bpo=32734

   (416) https://bugs.python.org/issue?@action=redirect&bpo=32727

   (417) https://bugs.python.org/issue?@action=redirect&bpo=31453

   (418) https://bugs.python.org/issue?@action=redirect&bpo=24334

   (419) https://bugs.python.org/issue?@action=redirect&bpo=31848

   (420) https://bugs.python.org/issue?@action=redirect&bpo=32585

   (421) https://bugs.python.org/issue?@action=redirect&bpo=32512

   (422) https://bugs.python.org/issue?@action=redirect&bpo=8525

   (423) https://bugs.python.org/issue?@action=redirect&bpo=31639

   (424) https://bugs.python.org/issue?@action=redirect&bpo=29877

   (425) https://bugs.python.org/issue?@action=redirect&bpo=32221

   (426) https://bugs.python.org/issue?@action=redirect&bpo=32147

   (427) https://bugs.python.org/issue?@action=redirect&bpo=30693

   (428) https://bugs.python.org/issue?@action=redirect&bpo=30693

   (429) https://bugs.python.org/issue?@action=redirect&bpo=31680

   (430) https://bugs.python.org/issue?@action=redirect&bpo=31908

   (431) https://bugs.python.org/issue?@action=redirect&bpo=31608

   (432) https://bugs.python.org/issue?@action=redirect&bpo=31425

   (433) https://bugs.python.org/issue?@action=redirect&bpo=22005

   (434) https://bugs.python.org/issue?@action=redirect&bpo=27645

   (435) https://bugs.python.org/issue?@action=redirect&bpo=16865

   (436) https://bugs.python.org/issue?@action=redirect&bpo=31508

   (437) https://bugs.python.org/issue?@action=redirect&bpo=29456


File: python.info,  Node: Documentation<45>,  Next: Tests<47>,  Prev: Library<50>,  Up: Python 3 8 0 alpha 1

1.23.51.4 Documentation
.......................

   - bpo-21257(1): Document *note http.client.parse_headers(): 19b4.

   - bpo-34764(2): Improve example of iter() with 2nd sentinel argument.

   - bpo-35564(3): Explicitly set master_doc variable in conf.py for
     compliance with Sphinx 2.0

   - bpo-35511(4): Specified that profile.Profile class doesn't not
     support enable or disable methods.  Also, elaborated that Profile
     object as a context manager is only supported in cProfile module.

   - bpo-10536(5): Enhance the gettext docs.  Patch by Éric Araujo

   - bpo-35089(6): Remove mention of ‘typing.io’ and ‘typing.re’.  Their
     types should be imported from ‘typing’ directly.

   - bpo-35038(7): Fix the documentation about an unexisting
     ‘f_restricted’ attribute in the frame object.  Patch by Stéphane
     Wirtel

   - bpo-35042(8): Replace PEP XYZ by the pep role and allow to use the
     direct links to the PEPs.

   - bpo-35044(9): Fix the documentation with the role ‘exc’ for the
     appropriated exception.  Patch by Stéphane Wirtel

   - bpo-35035(10): Rename documentation for *note email.utils: 47. to
     ‘email.utils.rst’.

   - bpo-34967(11): Use app.add_object_type() instead of the deprecated
     Sphinx function app.description_unit()

   - bpo-34913(12): Add documentation about the new command line
     interface of the gzip module.

   - bpo-32174(13): chm document displays non-ASCII characters properly
     on some MBCS Windows systems.

   - bpo-11233(14): Create availability directive for documentation.
     Original patch by Georg Brandl.

   - bpo-34790(15): Document how passing coroutines to asyncio.wait()
     can be confusing.

   - bpo-34552(16): Make clear that ‘==’ operator sometimes is
     equivalent to ‘is’.  The ‘<’, ‘<=’, ‘>’ and ‘>=’ operators are only
     defined where they make sense.

   - bpo-28617(17): Fixed info in the stdtypes docs concerning the types
     that support membership tests.

   - bpo-20177(18): Migrate datetime.date.fromtimestamp to Argument
     Clinic.  Patch by Tim Hoffmann.

   - bpo-34065(19): Fix wrongly written basicConfig documentation markup
     syntax

   - bpo-33460(20): replaced ellipsis with correct error codes in
     tutorial chapter 3.

   - bpo-33847(21): Add '@' operator entry to index.

   - bpo-33409(22): Clarified the relationship between PEP 538(23)'s
     PYTHONCOERCECLOCALE and PEP 540's PYTHONUTF8 mode.

   - bpo-33197(24): Add versionadded tag to the documentation of
     ParameterKind.description

   - bpo-17045(25): Improve the C-API doc for PyTypeObject.  This
     includes adding several quick-reference tables and a lot of missing
     slot/typedef entries.  The existing entries were also cleaned up
     with a slightly more consistent format.

   - bpo-33736(26): Improve the documentation of *note
     asyncio.open_connection(): ae6, *note asyncio.start_server(): ae7.
     and their UNIX socket counterparts.

   - bpo-23859(27): Document that ‘asyncio.wait()’ does not cancel its
     futures on timeout.

   - bpo-32436(28): Document PEP 567(29) changes to asyncio.

   - bpo-33604(30): Update HMAC md5 default to a DeprecationWarning,
     bump removal to 3.8.

   - bpo-33594(31): Document ‘getargspec’, ‘from_function’ and
     ‘from_builtin’ as deprecated in their respective docstring, and
     include version since deprecation in DeprecationWarning message.

   - bpo-33503(32): Fix broken pypi link

   - bpo-33421(33): Add missing documentation for
     ‘typing.AsyncContextManager’.

   - bpo-33487(34): BZ2file now emit a DeprecationWarning when
     buffering=None is passed, the deprecation message and documentation
     also now explicitly state it is deprecated since 3.0.

   - bpo-33378(35): Add Korean language switcher for
     ‘https://docs.python.org/3/’

   - bpo-33276(36): Clarify that the ‘__path__’ attribute on modules
     cannot be just any value.

   - bpo-33201(37): Modernize documentation for writing C extension
     types.

   - bpo-33195(38): Deprecate ‘Py_UNICODE’ usage in ‘c-api/arg’
     document.  ‘Py_UNICODE’ related APIs are deprecated since Python
     3.3, but it is missed in the document.

   - bpo-33126(39): Document PyBuffer_ToContiguous().

   - bpo-27212(40): Modify documentation for the ‘islice()’ recipe to
     consume initial values up to the start index.

   - bpo-28247(41): Update *note zipapp: 116. documentation to describe
     how to make standalone applications.

   - bpo-18802(42): Documentation changes for ipaddress.  Patch by Jon
     Foster and Berker Peksag.

   - bpo-27428(43): Update documentation to clarify that
     ‘WindowsRegistryFinder’ implements ‘MetaPathFinder’.  (Patch by
     Himanshu Lakhara)

   - bpo-28124(44): The ssl module function ssl.wrap_socket() has been
     de-emphasized and deprecated in favor of the more secure and
     efficient SSLContext.wrap_socket() method.

   - bpo-17232(45): Clarify docs for -O and -OO. Patch by Terry Reedy.

   - bpo-32436(46): Add documentation for the contextvars module (PEP
     567).

   - bpo-32800(47): Update link to w3c doc for xml default namespaces.

   - bpo-11015(48): Update *note test.support: cd. documentation.

   - bpo-32613(49): Update the faq/windows.html to use the py command
     from PEP 397 instead of python.

   - bpo-8722(50): Document ‘__getattr__()’ behavior when property
     ‘get()’ method raises *note AttributeError: 326.

   - bpo-32614(51): Modify RE examples in documentation to use raw
     strings to prevent *note DeprecationWarning: 18a. and add text to
     REGEX HOWTO to highlight the deprecation.

   - bpo-20709(52): Remove the paragraph where we explain that
     os.utime() does not support a directory as path under Windows.
     Patch by Jan-Philip Gehrcke

   - bpo-32722(53): Remove the bad example in the tutorial of the
     Generator Expression.  Patch by Stéphane Wirtel

   - bpo-31972(54): Improve docstrings for ‘pathlib.PurePath’
     subclasses.

   - bpo-30607(55): Use the externalized ‘python-docs-theme’ package
     when building the documentation.

   - bpo-8243(56): Add a note about curses.addch and curses.addstr
     exception behavior when writing outside a window, or pad.

   - bpo-32337(57): Update documentation related with ‘dict’ order.

   - bpo-25041(58): Document ‘AF_PACKET’ in the *note socket: b8.
     module.

   - bpo-31432(59): Clarify meaning of CERT_NONE, CERT_OPTIONAL, and
     CERT_REQUIRED flags for ssl.SSLContext.verify_mode.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21257

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34764

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35564

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35511

   (5) https://bugs.python.org/issue?@action=redirect&bpo=10536

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35089

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35038

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35042

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35044

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35035

   (11) https://bugs.python.org/issue?@action=redirect&bpo=34967

   (12) https://bugs.python.org/issue?@action=redirect&bpo=34913

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32174

   (14) https://bugs.python.org/issue?@action=redirect&bpo=11233

   (15) https://bugs.python.org/issue?@action=redirect&bpo=34790

   (16) https://bugs.python.org/issue?@action=redirect&bpo=34552

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28617

   (18) https://bugs.python.org/issue?@action=redirect&bpo=20177

   (19) https://bugs.python.org/issue?@action=redirect&bpo=34065

   (20) https://bugs.python.org/issue?@action=redirect&bpo=33460

   (21) https://bugs.python.org/issue?@action=redirect&bpo=33847

   (22) https://bugs.python.org/issue?@action=redirect&bpo=33409

   (23) https://peps.python.org/pep-0538/

   (24) https://bugs.python.org/issue?@action=redirect&bpo=33197

   (25) https://bugs.python.org/issue?@action=redirect&bpo=17045

   (26) https://bugs.python.org/issue?@action=redirect&bpo=33736

   (27) https://bugs.python.org/issue?@action=redirect&bpo=23859

   (28) https://bugs.python.org/issue?@action=redirect&bpo=32436

   (29) https://peps.python.org/pep-0567/

   (30) https://bugs.python.org/issue?@action=redirect&bpo=33604

   (31) https://bugs.python.org/issue?@action=redirect&bpo=33594

   (32) https://bugs.python.org/issue?@action=redirect&bpo=33503

   (33) https://bugs.python.org/issue?@action=redirect&bpo=33421

   (34) https://bugs.python.org/issue?@action=redirect&bpo=33487

   (35) https://bugs.python.org/issue?@action=redirect&bpo=33378

   (36) https://bugs.python.org/issue?@action=redirect&bpo=33276

   (37) https://bugs.python.org/issue?@action=redirect&bpo=33201

   (38) https://bugs.python.org/issue?@action=redirect&bpo=33195

   (39) https://bugs.python.org/issue?@action=redirect&bpo=33126

   (40) https://bugs.python.org/issue?@action=redirect&bpo=27212

   (41) https://bugs.python.org/issue?@action=redirect&bpo=28247

   (42) https://bugs.python.org/issue?@action=redirect&bpo=18802

   (43) https://bugs.python.org/issue?@action=redirect&bpo=27428

   (44) https://bugs.python.org/issue?@action=redirect&bpo=28124

   (45) https://bugs.python.org/issue?@action=redirect&bpo=17232

   (46) https://bugs.python.org/issue?@action=redirect&bpo=32436

   (47) https://bugs.python.org/issue?@action=redirect&bpo=32800

   (48) https://bugs.python.org/issue?@action=redirect&bpo=11015

   (49) https://bugs.python.org/issue?@action=redirect&bpo=32613

   (50) https://bugs.python.org/issue?@action=redirect&bpo=8722

   (51) https://bugs.python.org/issue?@action=redirect&bpo=32614

   (52) https://bugs.python.org/issue?@action=redirect&bpo=20709

   (53) https://bugs.python.org/issue?@action=redirect&bpo=32722

   (54) https://bugs.python.org/issue?@action=redirect&bpo=31972

   (55) https://bugs.python.org/issue?@action=redirect&bpo=30607

   (56) https://bugs.python.org/issue?@action=redirect&bpo=8243

   (57) https://bugs.python.org/issue?@action=redirect&bpo=32337

   (58) https://bugs.python.org/issue?@action=redirect&bpo=25041

   (59) https://bugs.python.org/issue?@action=redirect&bpo=31432


File: python.info,  Node: Tests<47>,  Next: Build<49>,  Prev: Documentation<45>,  Up: Python 3 8 0 alpha 1

1.23.51.5 Tests
...............

   - bpo-35772(1): Fix sparse file tests of test_tarfile on ppc64 with
     the tmpfs filesystem.  Fix the function testing if the filesystem
     supports sparse files: create a file which contains data and
     "holes", instead of creating a file which contains no data.  tmpfs
     effective block size is a page size (tmpfs lives in the page
     cache).  RHEL uses 64 KiB pages on aarch64, ppc64, ppc64le, only
     s390x and x86_64 use 4 KiB pages, whereas the test punch holes of 4
     KiB.

   - bpo-35045(2): Make ssl tests less strict and also accept TLSv1 as
     system default.  The changes unbreaks test_min_max_version on
     Fedora 29.

   - bpo-32710(3): ‘test_asyncio/test_sendfile.py’ now resets the event
     loop policy using ‘tearDownModule()’ as done in other tests, to
     prevent a warning when running tests on Windows.

   - bpo-33717(4): test.pythoninfo now logs information of all clocks,
     not only time.time() and time.perf_counter().

   - bpo-35488(5): Add a test to pathlib's Path.match() to verify it
     does not support glob-style ** recursive pattern matching.

   - bpo-31731(6): Fix a race condition in ‘check_interrupted_write()’
     of test_io: create directly the thread with SIGALRM signal blocked,
     rather than blocking the signal later from the thread.  Previously,
     it was possible that the thread gets the signal before the signal
     is blocked.

   - bpo-35424(7): Fix test_multiprocessing_main_handling: use
     ‘multiprocessing.Pool’ with a context manager and then explicitly
     join the pool.

   - bpo-35519(8): Rename ‘test.bisect’ module to ‘test.bisect_cmd’ to
     avoid conflict with *note bisect: d. module when running directly a
     test like ‘./python Lib/test/test_xmlrpc.py’.

   - bpo-35513(9): Replace *note time.time(): 235. with *note
     time.monotonic(): 234. in tests to measure time delta.

   - bpo-34279(10): ‘test.support.run_unittest()’ no longer raise
     ‘TestDidNotRun’ if the test result contains skipped tests.  The
     exception is now only raised if no test have been run and no test
     have been skipped.

   - bpo-35412(11): Add testcase to ‘test_future4’: check unicode
     literal.

   - bpo-26704(12): Added test demonstrating double-patching of an
     instance method.  Patch by Anthony Sottile.

   - bpo-33725(13): test_multiprocessing_fork may crash on recent
     versions of macOS. Until the issue is resolved, skip the test on
     macOS.

   - bpo-35352(14): Modify test_asyncio to use the certificate set from
     the test directory.

   - bpo-35317(15): Fix ‘mktime()’ overflow error in ‘test_email’: run
     ‘test_localtime_daylight_true_dst_true()’ and
     ‘test_localtime_daylight_false_dst_true()’ with a specific
     timezone.

   - bpo-21263(16): After several reports that test_gdb does not work
     properly on macOS and since gdb is not shipped by default anymore,
     test_gdb is now skipped on macOS when LLVM Clang has been used to
     compile Python.  Patch by Lysandros Nikolaou

   - bpo-34279(17): regrtest issue a warning when no tests have been
     executed in a particular test file.  Also, a new final result state
     is issued if no test have been executed across all test files.
     Patch by Pablo Galindo.

   - bpo-34962(18): make docstest in Doc now passes., and is enforced in
     CI

   - bpo-23596(19): Use argparse for the command line of the gzip
     module.  Patch by Antony Lee

   - bpo-34537(20): Fix ‘test_gdb.test_strings()’ when ‘LC_ALL=C’ and
     GDB was compiled with Python 3.6 or earlier.

   - bpo-34587(21): test_socket: Remove RDSTest.testCongestion().  The
     test tries to fill the receiver's socket buffer and expects an
     error.  But the RDS protocol doesn't require that.  Moreover, the
     Linux implementation of RDS expects that the producer of the
     messages reduces its rate, it's not the role of the receiver to
     trigger an error.  The test fails on Fedora 28 by design, so just
     remove it.

   - bpo-34661(22): Fix test_shutil if unzip doesn't support -t.

   - bpo-34200(23): Fixed non-deterministic flakiness of test_pkg by not
     using the scary test.support.module_cleanup() logic to save and
     restore sys.modules contents between test cases.

   - bpo-34569(24): The experimental PEP 554 data channels now correctly
     pass negative PyLong objects between subinterpreters on 32-bit
     systems.  Patch by Michael Felt.

   - bpo-34594(25): Fix usage of hardcoded ‘errno’ values in the tests.

   - bpo-34579(26): Fix test_embed for AIX Patch by Michael Felt

   - bpo-34542(27): Use 3072 RSA keys and SHA-256 signature for test
     certs and keys.

   - bpo-11193(28): Remove special condition for AIX in
     ‘test_subprocess.test_undecodable_env’

   - bpo-34347(29): Fix ‘test_utf8_mode.test_cmd_line’ for AIX

   - bpo-34490(30): On AIX with AF_UNIX family sockets getsockname()
     does not provide 'sockname', so skip calls to
     transport.get_extra_info('sockname')

   - bpo-34391(31): Fix ftplib test for TLS 1.3 by reading from data
     socket.

   - bpo-11192(32): Fix ‘test_socket’ on AIX 6.1 and later IPv6 zone id
     supports only supported by ‘inet_pton6_zone()’.  Switch to
     runtime-based ‘platform.system()’ to establish current platform
     rather than build-time based ‘sys.platform()’

   - bpo-34399(33): Update all RSA keys and DH params to use at least
     2048 bits.

   - bpo-34373(34): Fix ‘test_mktime’ and ‘test_pthread_getcpuclickid’
     tests for AIX Add range checking for ‘_PyTime_localtime’ for AIX
     Patch by Michael Felt

   - bpo-11191(35): Skip the distutils test 'test_search_cpp' when using
     XLC as compiler patch by aixtools (Michael Felt)

   - Improved an error message when mock assert_has_calls fails.

   - bpo-33746(36): Fix test_unittest when run in verbose mode.

   - bpo-33901(37): Fix test_dbm_gnu on macOS with gdbm 1.15: add a
     larger value to make sure that the file size changes.

   - bpo-33873(38): Fix a bug in ‘regrtest’ that caused an extra test to
     run if -huntrleaks/-R was used.  Exit with error in case that
     invalid parameters are specified to -huntrleaks/-R (at least one
     warmup run and one repetition must be used).

   - bpo-33562(39): Check that a global asyncio event loop policy is not
     left behind by any tests.

   - bpo-33655(40): Ignore test_posix_fallocate failures on BSD
     platforms that might be due to running on ZFS.

   - bpo-32962(41): Fixed test_gdb when Python is compiled with flags
     -mcet -fcf-protection -O0.

   - bpo-33358(42): Fix
     ‘test_embed.test_pre_initialization_sys_options()’ when the
     interpreter is built with ‘--enable-shared’.

   - bpo-32872(43): Avoid regrtest compatibility issue with namespace
     packages.

   - bpo-32517(44): Fix failing ‘test_asyncio’ on macOS 10.12.2+ due to
     transport of ‘KqueueSelector’ loop was not being closed.

   - bpo-32663(45): Making sure the ‘SMTPUTF8SimTests’ class of tests
     gets run in ‘test_smtplib.py’.

   - bpo-27643(46): Test_C test case needs "signed short" bitfields, but
     the IBM XLC compiler (on AIX) does not support this Skip the code
     and test when AIX and XLC are used

     Applicable to Python2-2.7 and later

   - bpo-19417(47): Add test_bdb.py.

   - bpo-31809(48): Add tests to verify connection with secp ECDH
     curves.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35772

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35045

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32710

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33717

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35488

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31731

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35424

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35519

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35513

   (10) https://bugs.python.org/issue?@action=redirect&bpo=34279

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35412

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26704

   (13) https://bugs.python.org/issue?@action=redirect&bpo=33725

   (14) https://bugs.python.org/issue?@action=redirect&bpo=35352

   (15) https://bugs.python.org/issue?@action=redirect&bpo=35317

   (16) https://bugs.python.org/issue?@action=redirect&bpo=21263

   (17) https://bugs.python.org/issue?@action=redirect&bpo=34279

   (18) https://bugs.python.org/issue?@action=redirect&bpo=34962

   (19) https://bugs.python.org/issue?@action=redirect&bpo=23596

   (20) https://bugs.python.org/issue?@action=redirect&bpo=34537

   (21) https://bugs.python.org/issue?@action=redirect&bpo=34587

   (22) https://bugs.python.org/issue?@action=redirect&bpo=34661

   (23) https://bugs.python.org/issue?@action=redirect&bpo=34200

   (24) https://bugs.python.org/issue?@action=redirect&bpo=34569

   (25) https://bugs.python.org/issue?@action=redirect&bpo=34594

   (26) https://bugs.python.org/issue?@action=redirect&bpo=34579

   (27) https://bugs.python.org/issue?@action=redirect&bpo=34542

   (28) https://bugs.python.org/issue?@action=redirect&bpo=11193

   (29) https://bugs.python.org/issue?@action=redirect&bpo=34347

   (30) https://bugs.python.org/issue?@action=redirect&bpo=34490

   (31) https://bugs.python.org/issue?@action=redirect&bpo=34391

   (32) https://bugs.python.org/issue?@action=redirect&bpo=11192

   (33) https://bugs.python.org/issue?@action=redirect&bpo=34399

   (34) https://bugs.python.org/issue?@action=redirect&bpo=34373

   (35) https://bugs.python.org/issue?@action=redirect&bpo=11191

   (36) https://bugs.python.org/issue?@action=redirect&bpo=33746

   (37) https://bugs.python.org/issue?@action=redirect&bpo=33901

   (38) https://bugs.python.org/issue?@action=redirect&bpo=33873

   (39) https://bugs.python.org/issue?@action=redirect&bpo=33562

   (40) https://bugs.python.org/issue?@action=redirect&bpo=33655

   (41) https://bugs.python.org/issue?@action=redirect&bpo=32962

   (42) https://bugs.python.org/issue?@action=redirect&bpo=33358

   (43) https://bugs.python.org/issue?@action=redirect&bpo=32872

   (44) https://bugs.python.org/issue?@action=redirect&bpo=32517

   (45) https://bugs.python.org/issue?@action=redirect&bpo=32663

   (46) https://bugs.python.org/issue?@action=redirect&bpo=27643

   (47) https://bugs.python.org/issue?@action=redirect&bpo=19417

   (48) https://bugs.python.org/issue?@action=redirect&bpo=31809


File: python.info,  Node: Build<49>,  Next: Windows<45>,  Prev: Tests<47>,  Up: Python 3 8 0 alpha 1

1.23.51.6 Build
...............

   - bpo-34691(1): The _contextvars module is now built into the core
     Python library on Windows.

   - bpo-35683(2): Improved Azure Pipelines build steps and now
     verifying layouts correctly

   - bpo-35642(3): Remove asynciomodule.c from pythoncore.vcxproj

   - bpo-35550(4): Fix incorrect Solaris #ifdef checks to look for __sun
     && __SVR4 instead of sun when compiling.

   - bpo-35499(5): ‘make profile-opt’ no longer replaces ‘CFLAGS_NODIST’
     with ‘CFLAGS’.  It now adds profile-guided optimization (PGO) flags
     to ‘CFLAGS_NODIST’: existing ‘CFLAGS_NODIST’ flags are kept.

   - bpo-35257(6): Avoid leaking the linker flags from Link Time
     Optimizations (LTO) into distutils when compiling C extensions.

   - bpo-35351(7): When building Python with clang and LTO, LTO flags
     are no longer passed into CFLAGS to build third-party C extensions
     through distutils.

   - bpo-35139(8): Fix a compiler error when statically linking
     ‘pyexpat’ in ‘Modules/Setup’.

   - bpo-35059(9): PCbuild: Set InlineFunctionExpansion to
     OnlyExplicitInline ("/Ob1" option) in pyproject.props in Debug mode
     to expand functions marked as inline.  This change should make
     Python compiled in Debug mode a little bit faster on Windows.

   - bpo-35011(10): Restores the use of pyexpatns.h to isolate our
     embedded copy of the expat C library so that its symbols do not
     conflict at link or dynamic loading time with an embedding
     application or other extension modules with their own version of
     libexpat.

   - bpo-28015(11): Have -with-lto works correctly with clang.

   - bpo-34765(12): Update the outdated install-sh file to the latest
     revision from automake v1.16.1

   - bpo-34585(13): Check for floating-point byte order in configure.ac
     using compilation tests instead of executing code, so that these
     checks work in cross-compiled builds.

   - bpo-34710(14): Fixed SSL module build with OpenSSL & pedantic
     CFLAGS.

   - bpo-34582(15): Add JUnit XML output for regression tests and update
     Azure DevOps builds.

   - bpo-34081(16): Make Sphinx warnings as errors in the Docs Makefile.

   - bpo-34555(17): Fix for case where it was not possible to have both
     ‘HAVE_LINUX_VM_SOCKETS_H’ and ‘HAVE_SOCKADDR_ALG’ be undefined.

   - bpo-33015(18): Fix an undefined behaviour in the pthread
     implementation of ‘PyThread_start_new_thread()’: add a function
     wrapper to always return ‘NULL’.

   - bpo-34245(19): The Python shared library is now installed with
     write permission (mode 0755), which is the standard way of
     installing such libraries.

   - bpo-34121(20): Fix detection of C11 atomic support on clang.

   - bpo-32430(21): Rename Modules/Setup.dist to Modules/Setup, and
     remove the necessity to copy the former manually to the latter when
     updating the local source tree.

   - bpo-30345(22): Add -g to LDFLAGS when compiling with LTO to get
     debug symbols.

   - bpo-5755(23): Move ‘-Wstrict-prototypes’ option to ‘CFLAGS_NODIST’
     from ‘OPT’.  This option emitted annoying warnings when building
     extension modules written in C++.

   - bpo-33614(24): Ensures module definition files for the stable ABI
     on Windows are correctly regenerated.

   - bpo-33648(25): The -with-c-locale-warning configuration flag has
     been removed.  It has had no effect for about a year.

   - bpo-33522(26): Enable CI builds on Visual Studio Team Services at
     ‘https://python.visualstudio.com/cpython’

   - bpo-33512(27): configure's check for "long double" has been
     simplified

   - bpo-33483(28): C compiler is now correctly detected from the
     standard environment variables.  -without-gcc and -with-icc options
     have been removed.

   - bpo-33394(29): Enable the verbose build for extension modules, when
     GNU make is passed macros on the command line.

   - bpo-33393(30): Update config.guess and config.sub files.

   - bpo-33377(31): Add new triplets for mips r6 and riscv variants
     (used in extension suffixes).

   - bpo-32232(32): By default, modules configured in ‘Modules/Setup’
     are no longer built with ‘-DPy_BUILD_CORE’.  Instead, modules that
     specifically need that preprocessor definition include it in their
     individual entries.

   - bpo-33182(33): The embedding tests can once again be built with
     clang 6.0

   - bpo-33163(34): Upgrade pip to 9.0.3 and setuptools to v39.0.1.

   - bpo-33012(35): gcc 8 has added a new warning heuristic to detect
     invalid function casts and a stock python build seems to hit that
     warning quite often.  The most common is the cast of a METH_NOARGS
     function (that uses just one argument) to a PyCFunction.  Fix this
     by adding a dummy argument to all functions that implement
     METH_NOARGS.

   - bpo-32898(36): Fix the python debug build when using COUNT_ALLOCS.

   - bpo-29442(37): Replace optparse with argparse in setup.py

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34691

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35683

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35642

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35550

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35499

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35257

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35351

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35139

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35059

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35011

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28015

   (12) https://bugs.python.org/issue?@action=redirect&bpo=34765

   (13) https://bugs.python.org/issue?@action=redirect&bpo=34585

   (14) https://bugs.python.org/issue?@action=redirect&bpo=34710

   (15) https://bugs.python.org/issue?@action=redirect&bpo=34582

   (16) https://bugs.python.org/issue?@action=redirect&bpo=34081

   (17) https://bugs.python.org/issue?@action=redirect&bpo=34555

   (18) https://bugs.python.org/issue?@action=redirect&bpo=33015

   (19) https://bugs.python.org/issue?@action=redirect&bpo=34245

   (20) https://bugs.python.org/issue?@action=redirect&bpo=34121

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32430

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30345

   (23) https://bugs.python.org/issue?@action=redirect&bpo=5755

   (24) https://bugs.python.org/issue?@action=redirect&bpo=33614

   (25) https://bugs.python.org/issue?@action=redirect&bpo=33648

   (26) https://bugs.python.org/issue?@action=redirect&bpo=33522

   (27) https://bugs.python.org/issue?@action=redirect&bpo=33512

   (28) https://bugs.python.org/issue?@action=redirect&bpo=33483

   (29) https://bugs.python.org/issue?@action=redirect&bpo=33394

   (30) https://bugs.python.org/issue?@action=redirect&bpo=33393

   (31) https://bugs.python.org/issue?@action=redirect&bpo=33377

   (32) https://bugs.python.org/issue?@action=redirect&bpo=32232

   (33) https://bugs.python.org/issue?@action=redirect&bpo=33182

   (34) https://bugs.python.org/issue?@action=redirect&bpo=33163

   (35) https://bugs.python.org/issue?@action=redirect&bpo=33012

   (36) https://bugs.python.org/issue?@action=redirect&bpo=32898

   (37) https://bugs.python.org/issue?@action=redirect&bpo=29442


File: python.info,  Node: Windows<45>,  Next: macOS<37>,  Prev: Build<49>,  Up: Python 3 8 0 alpha 1

1.23.51.7 Windows
.................

   - bpo-35890(1): Fix API calling consistency of GetVersionEx and
     wcstok.

   - bpo-32560(2): The ‘py’ launcher now forwards its ‘STARTUPINFO’
     structure to child processes.

   - bpo-35854(3): Fix EnvBuilder and -symlinks in venv on Windows

   - bpo-35811(4): Avoid propagating venv settings when launching via
     py.exe

   - bpo-35797(5): Fix default executable used by the multiprocessing
     module

   - bpo-35758(6): Allow building on ARM with MSVC.

   - bpo-29734(7): Fix handle leaks in os.stat on Windows.

   - bpo-35596(8): Use unchecked PYCs for the embeddable distro to avoid
     zipimport restrictions.

   - bpo-35596(9): Fix vcruntime140.dll being added to embeddable distro
     multiple times.

   - bpo-35402(10): Update Windows build to use Tcl and Tk 8.6.9

   - bpo-35401(11): Updates Windows build to OpenSSL 1.1.0j

   - bpo-34977(12): venv on Windows will now use a python.exe redirector
     rather than copying the actual binaries from the base environment.

   - bpo-34977(13): Adds support for building a Windows App Store
     package

   - bpo-35067(14): Remove _distutils_findvs module and use vswhere.exe
     instead.

   - bpo-32557(15): Allow shutil.disk_usage to take a file path on
     Windows

   - bpo-34770(16): Fix a possible null pointer dereference in
     pyshellext.cpp.

   - bpo-34603(17): Fix returning structs from functions produced by
     MSVC

   - bpo-34581(18): Guard MSVC-specific code in socketmodule.c with
     ‘#ifdef _MSC_VER’.

   - bpo-34532(19): Fixes exit code of list version arguments for
     py.exe.

   - bpo-34062(20): Fixed the '-list' and '-list-paths' arguments for
     the py.exe launcher

   - bpo-34225(21): Ensure INCLUDE and LIB directories do not end with a
     backslash.

   - bpo-34011(22): A suite of code has been changed which copied across
     DLLs and init.tcl from the running Python location into a venv
     being created.  These copies are needed only when running from a
     Python source build, and the copying code is now only run when that
     is the case, rather than whenever a venv is created.

   - bpo-34006(23): Revert line length limit for Windows help docs.  The
     line-length limit is not needed because the pages appear in a
     separate app rather than on a browser tab.  It can also interact
     badly with the DPI setting.

   - bpo-31546(24): Restore running PyOS_InputHook while waiting for
     user input at the prompt.  The restores integration of interactive
     GUI windows (such as Matplotlib figures) with the prompt on
     Windows.

   - bpo-30237(25): Output error when ReadConsole is canceled by
     CancelSynchronousIo instead of crashing.

   - bpo-33895(26): GIL is released while calling functions that acquire
     Windows loader lock.

   - bpo-33720(27): Reduces maximum marshal recursion depth on release
     builds.

   - bpo-29097(28): Fix bug where ‘datetime.fromtimestamp()’ erroneously
     throws an *note OSError: 3f0. on Windows for values between 0 and
     86400.  Patch by Ammar Askar.

   - bpo-33316(29): PyThread_release_lock always fails

   - bpo-33184(30): Update Windows installer to use OpenSSL 1.1.0h.

   - bpo-32890(31): Fix usage of GetLastError() instead of errno in
     os.execve() and os.truncate().

   - bpo-33016(32): Fix potential use of uninitialized memory in
     nt._getfinalpathname

   - bpo-32903(33): Fix a memory leak in os.chdir() on Windows if the
     current directory is set to a UNC path.

   - bpo-32901(34): Update Tcl and Tk versions to 8.6.8

   - bpo-31966(35): Fixed WindowsConsoleIO.write() for writing empty
     data.

   - bpo-32409(36): Ensures activate.bat can handle Unicode contents.

   - bpo-32457(37): Improves handling of denormalized executable path
     when launching Python.

   - bpo-32370(38): Use the correct encoding for ipconfig output in the
     uuid module.  Patch by Segev Finer.

   - bpo-29248(39): Fix *note os.readlink(): 8ee. on Windows, which was
     mistakenly treating the ‘PrintNameOffset’ field of the reparse data
     buffer as a number of characters instead of bytes.  Patch by Craig
     Holmquist and SSE4.

   - bpo-1104(40): Correctly handle string length in
     ‘msilib.SummaryInfo.GetProperty()’ to prevent it from truncating
     the last character.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35890

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32560

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35854

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35811

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35797

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35758

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29734

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35596

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35596

   (10) https://bugs.python.org/issue?@action=redirect&bpo=35402

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35401

   (12) https://bugs.python.org/issue?@action=redirect&bpo=34977

   (13) https://bugs.python.org/issue?@action=redirect&bpo=34977

   (14) https://bugs.python.org/issue?@action=redirect&bpo=35067

   (15) https://bugs.python.org/issue?@action=redirect&bpo=32557

   (16) https://bugs.python.org/issue?@action=redirect&bpo=34770

   (17) https://bugs.python.org/issue?@action=redirect&bpo=34603

   (18) https://bugs.python.org/issue?@action=redirect&bpo=34581

   (19) https://bugs.python.org/issue?@action=redirect&bpo=34532

   (20) https://bugs.python.org/issue?@action=redirect&bpo=34062

   (21) https://bugs.python.org/issue?@action=redirect&bpo=34225

   (22) https://bugs.python.org/issue?@action=redirect&bpo=34011

   (23) https://bugs.python.org/issue?@action=redirect&bpo=34006

   (24) https://bugs.python.org/issue?@action=redirect&bpo=31546

   (25) https://bugs.python.org/issue?@action=redirect&bpo=30237

   (26) https://bugs.python.org/issue?@action=redirect&bpo=33895

   (27) https://bugs.python.org/issue?@action=redirect&bpo=33720

   (28) https://bugs.python.org/issue?@action=redirect&bpo=29097

   (29) https://bugs.python.org/issue?@action=redirect&bpo=33316

   (30) https://bugs.python.org/issue?@action=redirect&bpo=33184

   (31) https://bugs.python.org/issue?@action=redirect&bpo=32890

   (32) https://bugs.python.org/issue?@action=redirect&bpo=33016

   (33) https://bugs.python.org/issue?@action=redirect&bpo=32903

   (34) https://bugs.python.org/issue?@action=redirect&bpo=32901

   (35) https://bugs.python.org/issue?@action=redirect&bpo=31966

   (36) https://bugs.python.org/issue?@action=redirect&bpo=32409

   (37) https://bugs.python.org/issue?@action=redirect&bpo=32457

   (38) https://bugs.python.org/issue?@action=redirect&bpo=32370

   (39) https://bugs.python.org/issue?@action=redirect&bpo=29248

   (40) https://bugs.python.org/issue?@action=redirect&bpo=1104


File: python.info,  Node: macOS<37>,  Next: IDLE<37>,  Prev: Windows<45>,  Up: Python 3 8 0 alpha 1

1.23.51.8 macOS
...............

   - bpo-35401(1): Update macOS installer to use OpenSSL 1.1.0j.

   - bpo-35025(2): Properly guard the use of the ‘CLOCK_GETTIME’ et al.
     macros in ‘timemodule’ on macOS.

   - bpo-24658(3): On macOS, fix reading from and writing into a file
     with a size larger than 2 GiB.

   - bpo-34405(4): Update to OpenSSL 1.1.0i for macOS installer builds.

   - bpo-33635(5): In macOS stat on some file descriptors (/dev/fd/3
     f.e) will result in bad file descriptor OSError.  Guard against
     this exception was added in is_dir, is_file and similar methods.
     DirEntry.is_dir can also throw this exception so
     _RecursiveWildcardSelector._iterate_directories was also extended
     with the same error ignoring pattern.

   - bpo-13631(6): The .editrc file in user's home directory is now
     processed correctly during the readline initialization through
     editline emulation on macOS.

   - bpo-33184(7): Update macOS installer build to use OpenSSL 1.1.0h.

   - bpo-32726(8): Build and link with private copy of Tcl/Tk 8.6 for
     the macOS 10.6+ installer.  The 10.9+ installer variant already
     does this.  This means that the Python 3.7 provided by the
     python.org macOS installers no longer need or use any external
     versions of Tcl/Tk, either system-provided or user-installed, such
     as ActiveTcl.

   - bpo-32901(9): Update macOS 10.9+ installer to Tcl/Tk 8.6.8.

   - bpo-31903(10): In ‘_scproxy’, drop the GIL when calling into
     ‘SystemConfiguration’ to avoid deadlocks.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35401

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35025

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24658

   (4) https://bugs.python.org/issue?@action=redirect&bpo=34405

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33635

   (6) https://bugs.python.org/issue?@action=redirect&bpo=13631

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33184

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32726

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32901

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31903


File: python.info,  Node: IDLE<37>,  Next: Tools/Demos<24>,  Prev: macOS<37>,  Up: Python 3 8 0 alpha 1

1.23.51.9 IDLE
..............

   - bpo-35770(1): IDLE macosx deletes Options => Configure IDLE. It
     previously deleted Window => Zoom Height by mistake.  (Zoom Height
     is now on the Options menu).  On Mac, the settings dialog is
     accessed via Preferences on the IDLE menu.

   - bpo-35769(2): Change IDLE's new file name from 'Untitled' to
     'untitled'

   - bpo-35660(3): Fix imports in idlelib.window.

   - bpo-35641(4): Proper format ‘calltip’ when the function has no
     docstring.

   - bpo-33987(5): Use ttk Frame for ttk widgets.

   - bpo-34055(6): Fix erroneous 'smart' indents and newlines in IDLE
     Shell.

   - bpo-35591(7): Find Selection now works when selection not found.

   - bpo-35196(8): Speed up squeezer line counting.

   - bpo-35598(9): Update config_key: use PEP 8 names and ttk widgets,
     make some objects global, and add tests.

   - bpo-28097(10): Add Previous/Next History entries to Shell menu.

   - bpo-35208(11): Squeezer now properly counts wrapped lines before
     newlines.

   - bpo-35555(12): Gray out Code Context menu entry when it's not
     applicable.

   - bpo-35521(13): Document the IDLE editor code context feature.  Add
     some internal references within the IDLE doc.

   - bpo-22703(14): The Code Context menu label now toggles between
     Show/Hide Code Context.  The Zoom Height menu now toggles between
     Zoom/Restore Height.  Zoom Height has moved from the Window menu to
     the Options menu.

   - bpo-35213(15): Where appropriate, use 'macOS' in idlelib.

   - bpo-34864(16): On macOS, warn if the system preference "Prefer tabs
     when opening documents" is set to "Always".

   - bpo-34864(17): Document two IDLE on MacOS issues.  The System
     Preferences Dock "prefer tabs always" setting disables some IDLE
     features.  Menus are a bit different than as described for Windows
     and Linux.

   - bpo-35202(18): Remove unused imports from lib/idlelib

   - bpo-33000(19): Document that IDLE's shell has no line limit.  A
     program that runs indefinitely can overfill memory.

   - bpo-23220(20): Explain how IDLE's Shell displays output.

   - bpo-35099(21): Improve the doc about IDLE running user code.  The
     section is renamed from "IDLE - console differences" is renamed
     "Running user code".  It mostly covers the implications of using
     custom ‘sys.stdXXX’ objects.

   - bpo-35097(22): Add IDLE doc subsection explaining editor windows.
     Topics include opening, title and status bar, .py* extension, and
     running.

   - bpo-35093(23): Document the IDLE document viewer in the IDLE doc.
     Add a paragraph in "Help and preferences", "Help sources"
     subsection.

   - bpo-35088(24): Update idlelib.help.copy_string docstring.  We now
     use git and backporting instead of hg and forward merging.

   - bpo-35087(25): Update idlelib help files for the current doc build.
     The main change is the elimination of chapter-section numbers.

   - bpo-34548(26): Use configured color theme for read-only text views.

   - bpo-1529353(27): Enable "squeezing" of long outputs in the shell,
     to avoid performance degradation and to clean up the history
     without losing it.  Squeezed outputs may be copied, viewed in a
     separate window, and "unsqueezed".

   - bpo-34047(28): Fixed mousewheel scrolling direction on macOS.

   - bpo-34275(29): Make IDLE calltips always visible on Mac.  Some
     MacOS-tk combinations need .update_idletasks().  Patch by Kevin
     Walzer.

   - bpo-34120(30): Fix unresponsiveness after closing certain windows
     and dialogs.

   - bpo-33975(31): Avoid small type when running htests.  Since part of
     the purpose of human-viewed tests is to determine that widgets look
     right, it is important that they look the same for testing as when
     running IDLE.

   - bpo-33905(32): Add test for idlelib.stackview.StackBrowser.

   - bpo-33924(33): Change mainmenu.menudefs key 'windows' to 'window'.
     Every other menudef key is lowercase version of main menu entry.

   - bpo-33906(34): Rename idlelib.windows as window Match Window on the
     main menu and remove last plural module name.

   - bpo-33917(35): Fix and document idlelib/idle_test/template.py.  The
     revised file compiles, runs, and tests OK. idle_test/README.txt
     explains how to use it to create new IDLE test files.

   - bpo-33904(36): IDLE: In rstrip, rename class RstripExtension as
     Rstrip

   - bpo-33907(37): For consistency and clarity, rename an IDLE module
     and classes.  Module calltips and its class CallTips are now
     calltip and Calltip.  In module calltip_w, class CallTip is now
     CalltipWindow.

   - bpo-33856(38): Add "help" in the welcome message of IDLE

   - bpo-33839(39): IDLE: refactor ToolTip and CallTip and add
     documentation and tests

   - bpo-33855(40): Minimally test all IDLE modules.  Add missing files,
     import module, instantiate classes, and check coverage.  Check
     existing files.

   - bpo-33656(41): On Windows, add API call saying that tk scales for
     DPI. On Windows 8.1+ or 10, with DPI compatibility properties of
     the Python binary unchanged, and a monitor resolution greater than
     96 DPI, this should make text and lines sharper.  It should
     otherwise have no effect.

   - bpo-33768(42): Clicking on a context line moves that line to the
     top of the editor window.

   - bpo-33763(43): IDLE: Use read-only text widget for code context
     instead of label widget.

   - bpo-33664(44): Scroll IDLE editor text by lines.  Previously, the
     mouse wheel and scrollbar slider moved text by a fixed number of
     pixels, resulting in partial lines at the top of the editor box.
     The change also applies to the shell and grep output windows, but
     not to read-only text views.

   - bpo-33679(45): Enable theme-specific color configuration for Code
     Context.  Use the Highlights tab to see the setting for built-in
     themes or add settings to custom themes.

   - bpo-33642(46): Display up to maxlines non-blank lines for Code
     Context.  If there is no current context, show a single blank line.

   - bpo-33628(47): IDLE: Cleanup codecontext.py and its test.

   - bpo-33564(48): IDLE's code context now recognizes async as a block
     opener.

   - bpo-21474(49): Update word/identifier definition from ascii to
     unicode.  In text and entry boxes, this affects selection by
     double-click, movement left/right by control-left/right, and
     deletion left/right by control-BACKSPACE/DEL.

   - bpo-33204(50): IDLE: consistently color invalid string prefixes.  A
     'u' string prefix cannot be paired with either 'r' or 'f'.
     Consistently color as much of the prefix, starting at the right, as
     is valid.  Revise and extend colorizer test.

   - bpo-32984(51): Set ‘__file__’ while running a startup file.  Like
     Python, IDLE optionally runs one startup file in the Shell window
     before presenting the first interactive input prompt.  For IDLE,
     ‘-s’ runs a file named in environmental variable ‘IDLESTARTUP’ or
     *note PYTHONSTARTUP: f95.; ‘-r file’ runs ‘file’.  Python sets
     ‘__file__’ to the startup file name before running the file and
     unsets it before the first prompt.  IDLE now does the same when run
     normally, without the ‘-n’ option.

   - bpo-32940(52): Simplify and rename StringTranslatePseudoMapping in
     pyparse.

   - bpo-32916(53): Change ‘str’ to ‘code’ in pyparse.

   - bpo-32905(54): Remove unused code in pyparse module.

   - bpo-32874(55): Add tests for pyparse.

   - bpo-32837(56): Using the system and place-dependent default
     encoding for open() is a bad idea for IDLE's system and
     location-independent files.

   - bpo-32826(57): Add "encoding=utf-8" to open() in IDLE's
     test_help_about.  GUI test test_file_buttons() only looks at
     initial ascii-only lines, but failed on systems where open()
     defaults to 'ascii' because readline() internally reads and decodes
     far enough ahead to encounter a non-ascii character in CREDITS.txt.

   - bpo-32831(58): Add docstrings and tests for codecontext.

   - bpo-32765(59): Update configdialog General tab docstring to add new
     widgets to the widget list.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35770

   (2) https://bugs.python.org/issue?@action=redirect&bpo=35769

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35660

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35641

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33987

   (6) https://bugs.python.org/issue?@action=redirect&bpo=34055

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35591

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35196

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35598

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28097

   (11) https://bugs.python.org/issue?@action=redirect&bpo=35208

   (12) https://bugs.python.org/issue?@action=redirect&bpo=35555

   (13) https://bugs.python.org/issue?@action=redirect&bpo=35521

   (14) https://bugs.python.org/issue?@action=redirect&bpo=22703

   (15) https://bugs.python.org/issue?@action=redirect&bpo=35213

   (16) https://bugs.python.org/issue?@action=redirect&bpo=34864

   (17) https://bugs.python.org/issue?@action=redirect&bpo=34864

   (18) https://bugs.python.org/issue?@action=redirect&bpo=35202

   (19) https://bugs.python.org/issue?@action=redirect&bpo=33000

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23220

   (21) https://bugs.python.org/issue?@action=redirect&bpo=35099

   (22) https://bugs.python.org/issue?@action=redirect&bpo=35097

   (23) https://bugs.python.org/issue?@action=redirect&bpo=35093

   (24) https://bugs.python.org/issue?@action=redirect&bpo=35088

   (25) https://bugs.python.org/issue?@action=redirect&bpo=35087

   (26) https://bugs.python.org/issue?@action=redirect&bpo=34548

   (27) https://bugs.python.org/issue?@action=redirect&bpo=1529353

   (28) https://bugs.python.org/issue?@action=redirect&bpo=34047

   (29) https://bugs.python.org/issue?@action=redirect&bpo=34275

   (30) https://bugs.python.org/issue?@action=redirect&bpo=34120

   (31) https://bugs.python.org/issue?@action=redirect&bpo=33975

   (32) https://bugs.python.org/issue?@action=redirect&bpo=33905

   (33) https://bugs.python.org/issue?@action=redirect&bpo=33924

   (34) https://bugs.python.org/issue?@action=redirect&bpo=33906

   (35) https://bugs.python.org/issue?@action=redirect&bpo=33917

   (36) https://bugs.python.org/issue?@action=redirect&bpo=33904

   (37) https://bugs.python.org/issue?@action=redirect&bpo=33907

   (38) https://bugs.python.org/issue?@action=redirect&bpo=33856

   (39) https://bugs.python.org/issue?@action=redirect&bpo=33839

   (40) https://bugs.python.org/issue?@action=redirect&bpo=33855

   (41) https://bugs.python.org/issue?@action=redirect&bpo=33656

   (42) https://bugs.python.org/issue?@action=redirect&bpo=33768

   (43) https://bugs.python.org/issue?@action=redirect&bpo=33763

   (44) https://bugs.python.org/issue?@action=redirect&bpo=33664

   (45) https://bugs.python.org/issue?@action=redirect&bpo=33679

   (46) https://bugs.python.org/issue?@action=redirect&bpo=33642

   (47) https://bugs.python.org/issue?@action=redirect&bpo=33628

   (48) https://bugs.python.org/issue?@action=redirect&bpo=33564

   (49) https://bugs.python.org/issue?@action=redirect&bpo=21474

   (50) https://bugs.python.org/issue?@action=redirect&bpo=33204

   (51) https://bugs.python.org/issue?@action=redirect&bpo=32984

   (52) https://bugs.python.org/issue?@action=redirect&bpo=32940

   (53) https://bugs.python.org/issue?@action=redirect&bpo=32916

   (54) https://bugs.python.org/issue?@action=redirect&bpo=32905

   (55) https://bugs.python.org/issue?@action=redirect&bpo=32874

   (56) https://bugs.python.org/issue?@action=redirect&bpo=32837

   (57) https://bugs.python.org/issue?@action=redirect&bpo=32826

   (58) https://bugs.python.org/issue?@action=redirect&bpo=32831

   (59) https://bugs.python.org/issue?@action=redirect&bpo=32765


File: python.info,  Node: Tools/Demos<24>,  Next: C API<48>,  Prev: IDLE<37>,  Up: Python 3 8 0 alpha 1

1.23.51.10 Tools/Demos
......................

   - bpo-35884(1): Add a benchmark script for timing various ways to
     access variables: ‘Tools/scripts/var_access_benchmark.py’.

   - bpo-34989(2): python-gdb.py now handles errors on computing the
     line number of a Python frame.

   - bpo-20260(3): Argument Clinic now has non-bitwise unsigned int
     converters.

   - bpo-32962(4): python-gdb now catches ‘UnicodeDecodeError’
     exceptions when calling ‘string()’.

   - bpo-32962(5): python-gdb now catches ValueError on read_var(): when
     Python has no debug symbols for example.

   - bpo-33189(6): ‘pygettext.py’ now recognizes only literal strings as
     docstrings and translatable strings, and rejects bytes literals and
     f-string expressions.

   - bpo-31920(7): Fixed handling directories as arguments in the
     ‘pygettext’ script.  Based on patch by Oleg Krasnikov.

   - bpo-29673(8): Fix pystackv and pystack gdbinit macros.

   - bpo-25427(9): Remove the pyvenv script in favor of ‘python3 -m
     venv’ in order to lower confusion as to what Python interpreter a
     virtual environment will be created for.

   - bpo-32885(10): Add an ‘-n’ flag for ‘Tools/scripts/pathfix.py’ to
     disable automatic backup creation (files with ‘~’ suffix).

   - bpo-32222(11): Fix pygettext not extracting docstrings for
     functions with type annotated arguments.  Patch by Toby Harradine.

   - bpo-31583(12): Fix 2to3 for using with -add-suffix option but
     without -output-dir option for relative path to files in current
     directory.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35884

   (2) https://bugs.python.org/issue?@action=redirect&bpo=34989

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20260

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32962

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32962

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33189

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31920

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29673

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25427

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32885

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32222

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31583


File: python.info,  Node: C API<48>,  Prev: Tools/Demos<24>,  Up: Python 3 8 0 alpha 1

1.23.51.11 C API
................

   - bpo-35713(1): The ‘PyByteArray_Init()’ and ‘PyByteArray_Fini()’
     functions have been removed.  They did nothing since Python 2.7.4
     and Python 3.2.0, were excluded from the limited API (stable ABI),
     and were not documented.

   - bpo-33817(2): Fixed *note _PyBytes_Resize(): 15b8. for empty bytes
     objects.

   - bpo-35322(3): Fix memory leak in *note PyUnicode_EncodeLocale():
     b98. and *note PyUnicode_EncodeFSDefault(): 19bc. on error
     handling.

   - bpo-35059(4): The following C macros have been converted to static
     inline functions: *note Py_INCREF(): 53a, *note Py_DECREF(): 53b,
     *note Py_XINCREF(): a33, *note Py_XDECREF(): 75a,
     ‘PyObject_INIT()’, ‘PyObject_INIT_VAR()’.

   - bpo-35296(5): ‘make install’ now also installs the internal API:
     ‘Include/internal/*.h’ header files.

   - bpo-35081(6): Internal APIs surrounded by ‘#ifdef Py_BUILD_CORE’
     have been moved from ‘Include/*.h’ headers to new header files
     ‘Include/internal/pycore_*.h’.

   - bpo-35259(7): Conditionally declare *note Py_FinalizeEx(): ce3.
     (new in 3.6) based on Py_LIMITED_API. Patch by Arthur Neufeld.

   - bpo-35081(8): The ‘_PyObject_GC_TRACK()’ and
     ‘_PyObject_GC_UNTRACK()’ macros have been removed from the public C
     API.

   - bpo-35134(9): Creation of a new ‘Include/cpython/’ subdirectory.

   - bpo-34725(10): Adds _Py_SetProgramFullPath so embedders may
     override sys.executable

   - bpo-34910(11): Ensure that *note PyObject_Print(): 1554. always
     returns ‘-1’ on error.  Patch by Zackery Spytz.

   - bpo-34523(12): Py_DecodeLocale() and Py_EncodeLocale() now use the
     UTF-8 encoding on Windows if Py_LegacyWindowsFSEncodingFlag is
     zero.

   - bpo-34193(13): Fix pluralization in TypeError messages in getargs.c
     and typeobject.c: '1 argument' instead of '1 arguments' and '1
     element' instead of '1 elements'.

   - bpo-34127(14): Return grammatically correct error message based on
     argument count.  Patch by Karthikeyan Singaravelan.

   - bpo-23927(15): Fixed *note SystemError: 541. in *note
     PyArg_ParseTupleAndKeywords(): 35c. when the ‘w*’ format unit is
     used for optional parameter.

   - bpo-32455(16): Added ‘PyCompile_OpcodeStackEffectWithJump()’.

   - bpo-34008(17): Py_Main() can again be called after Py_Initialize(),
     as in Python 3.6.

   - bpo-32500(18): Fixed error messages for *note PySequence_Size():
     19bd, *note PySequence_GetItem(): 19be, *note PySequence_SetItem():
     19bf. and *note PySequence_DelItem(): 19c0. called with a mapping
     and *note PyMapping_Size(): 19c1. called with a sequence.

   - bpo-33818(19): ‘PyExceptionClass_Name()’ will now return ‘const
     char *’ instead of ‘char *’.

   - bpo-33042(20): Embedding applications may once again call
     PySys_ResetWarnOptions, PySys_AddWarnOption, and PySys_AddXOption
     prior to calling Py_Initialize.

   - bpo-32374(21): Document that m_traverse for multi-phase initialized
     modules can be called with m_state=NULL, and add a sanity check

   - bpo-30863(22): *note PyUnicode_AsWideChar(): 19c2. and *note
     PyUnicode_AsWideCharString(): 88a. no longer cache the ‘wchar_t*’
     representation of string objects.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=35713

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33817

   (3) https://bugs.python.org/issue?@action=redirect&bpo=35322

   (4) https://bugs.python.org/issue?@action=redirect&bpo=35059

   (5) https://bugs.python.org/issue?@action=redirect&bpo=35296

   (6) https://bugs.python.org/issue?@action=redirect&bpo=35081

   (7) https://bugs.python.org/issue?@action=redirect&bpo=35259

   (8) https://bugs.python.org/issue?@action=redirect&bpo=35081

   (9) https://bugs.python.org/issue?@action=redirect&bpo=35134

   (10) https://bugs.python.org/issue?@action=redirect&bpo=34725

   (11) https://bugs.python.org/issue?@action=redirect&bpo=34910

   (12) https://bugs.python.org/issue?@action=redirect&bpo=34523

   (13) https://bugs.python.org/issue?@action=redirect&bpo=34193

   (14) https://bugs.python.org/issue?@action=redirect&bpo=34127

   (15) https://bugs.python.org/issue?@action=redirect&bpo=23927

   (16) https://bugs.python.org/issue?@action=redirect&bpo=32455

   (17) https://bugs.python.org/issue?@action=redirect&bpo=34008

   (18) https://bugs.python.org/issue?@action=redirect&bpo=32500

   (19) https://bugs.python.org/issue?@action=redirect&bpo=33818

   (20) https://bugs.python.org/issue?@action=redirect&bpo=33042

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32374

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30863


File: python.info,  Node: Python 3 7 0 final,  Next: Python 3 7 0 release candidate 1,  Prev: Python 3 8 0 alpha 1,  Up: 変更履歴

1.23.52 Python 3.7.0 final
--------------------------

'Release date: 2018-06-27'

* Menu:

* Library: Library<51>.
* C API: C API<49>.


File: python.info,  Node: Library<51>,  Next: C API<49>,  Up: Python 3 7 0 final

1.23.52.1 Library
.................

   - bpo-33851(1): Fix *note ast.get_docstring(): 19c5. for a node that
     lacks a docstring.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33851


File: python.info,  Node: C API<49>,  Prev: Library<51>,  Up: Python 3 7 0 final

1.23.52.2 C API
...............

   - bpo-33932(1): Calling Py_Initialize() twice does nothing, instead
     of failing with a fatal error: restore the Python 3.6 behaviour.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33932


File: python.info,  Node: Python 3 7 0 release candidate 1,  Next: Python 3 7 0 beta 5,  Prev: Python 3 7 0 final,  Up: 変更履歴

1.23.53 Python 3.7.0 release candidate 1
----------------------------------------

'Release date: 2018-06-12'

* Menu:

* Core and Builtins: Core and Builtins<52>.
* Library: Library<52>.
* Documentation: Documentation<46>.
* Build: Build<50>.
* Windows: Windows<46>.
* IDLE: IDLE<38>.


File: python.info,  Node: Core and Builtins<52>,  Next: Library<52>,  Up: Python 3 7 0 release candidate 1

1.23.53.1 Core and Builtins
...........................

   - bpo-33803(1): Fix a crash in hamt.c caused by enabling GC tracking
     for an object that hadn't all of its fields set to NULL.

   - bpo-33706(2): Fix a crash in Python initialization when parsing the
     command line options.  Thanks Christoph Gohlke for the bug report
     and the fix!

   - bpo-30654(3): Fixed reset of the SIGINT handler to SIG_DFL on
     interpreter shutdown even when there was a custom handler set
     previously.  Patch by Philipp Kerling.

   - bpo-31849(4): Fix signed/unsigned comparison warning in pyhash.c.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33803

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33706

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30654

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31849


File: python.info,  Node: Library<52>,  Next: Documentation<46>,  Prev: Core and Builtins<52>,  Up: Python 3 7 0 release candidate 1

1.23.53.2 Library
.................

   - bpo-30167(1): Prevent site.main() exception if PYTHONSTARTUP is
     set.  Patch by Steve Weber.

   - bpo-33812(2): Datetime instance d with non-None tzinfo, but with
     d.tzinfo.utcoffset(d) returning None is now treated as naive by the
     astimezone() method.

   - bpo-30805(3): Avoid race condition with debug logging

   - bpo-33694(4): asyncio: Fix a race condition causing data loss on
     pause_reading()/resume_reading() when using the ProactorEventLoop.

   - bpo-32493(5): Correct test for ‘uuid_enc_be’ availability in
     ‘configure.ac’.  Patch by Michael Felt.

   - bpo-33792(6): Add asyncio.WindowsSelectorEventLoopPolicy and
     asyncio.WindowsProactorEventLoopPolicy.

   - bpo-33778(7): Update ‘unicodedata’'s database to Unicode version
     11.0.0.

   - bpo-33770(8): improve base64 exception message for encoded inputs
     of invalid length

   - bpo-33769(9): asyncio/start_tls: Fix error message; cancel
     callbacks in case of an unhandled error; mark SSLTransport as
     closed if it is aborted.

   - bpo-33767(10): The concatenation (‘+’) and repetition (‘*’)
     sequence operations now raise *note TypeError: 502. instead of
     *note SystemError: 541. when performed on *note mmap.mmap: 1ec.
     objects.  Patch by Zackery Spytz.

   - bpo-33734(11): asyncio/ssl: Fix AttributeError, increase default
     handshake timeout

   - bpo-11874(12): Use a better regex when breaking usage into
     wrappable parts.  Avoids bogus assertion errors from custom metavar
     strings.

   - bpo-33582(13): Emit a deprecation warning for inspect.formatargspec

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30167

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33812

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30805

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33694

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32493

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33792

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33778

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33770

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33769

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33767

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33734

   (12) https://bugs.python.org/issue?@action=redirect&bpo=11874

   (13) https://bugs.python.org/issue?@action=redirect&bpo=33582


File: python.info,  Node: Documentation<46>,  Next: Build<50>,  Prev: Library<52>,  Up: Python 3 7 0 release candidate 1

1.23.53.3 Documentation
.......................

   - bpo-33409(1): Clarified the relationship between PEP 538(2)'s
     PYTHONCOERCECLOCALE and PEP 540's PYTHONUTF8 mode.

   - bpo-33736(3): Improve the documentation of *note
     asyncio.open_connection(): ae6, *note asyncio.start_server(): ae7.
     and their UNIX socket counterparts.

   - bpo-31432(4): Clarify meaning of CERT_NONE, CERT_OPTIONAL, and
     CERT_REQUIRED flags for ssl.SSLContext.verify_mode.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33409

   (2) https://peps.python.org/pep-0538/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33736

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31432


File: python.info,  Node: Build<50>,  Next: Windows<46>,  Prev: Documentation<46>,  Up: Python 3 7 0 release candidate 1

1.23.53.4 Build
...............

   - bpo-5755(1): Move ‘-Wstrict-prototypes’ option to ‘CFLAGS_NODIST’
     from ‘OPT’.  This option emitted annoying warnings when building
     extension modules written in C++.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5755


File: python.info,  Node: Windows<46>,  Next: IDLE<38>,  Prev: Build<50>,  Up: Python 3 7 0 release candidate 1

1.23.53.5 Windows
.................

   - bpo-33720(1): Reduces maximum marshal recursion depth on release
     builds.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33720


File: python.info,  Node: IDLE<38>,  Prev: Windows<46>,  Up: Python 3 7 0 release candidate 1

1.23.53.6 IDLE
..............

   - bpo-33656(1): On Windows, add API call saying that tk scales for
     DPI. On Windows 8.1+ or 10, with DPI compatibility properties of
     the Python binary unchanged, and a monitor resolution greater than
     96 DPI, this should make text and lines sharper.  It should
     otherwise have no effect.

   - bpo-33768(2): Clicking on a context line moves that line to the top
     of the editor window.

   - bpo-33763(3): IDLE: Use read-only text widget for code context
     instead of label widget.

   - bpo-33664(4): Scroll IDLE editor text by lines.  Previously, the
     mouse wheel and scrollbar slider moved text by a fixed number of
     pixels, resulting in partial lines at the top of the editor box.
     The change also applies to the shell and grep output windows, but
     not to read-only text views.

   - bpo-33679(5): Enable theme-specific color configuration for Code
     Context.  Use the Highlights tab to see the setting for built-in
     themes or add settings to custom themes.

   - bpo-33642(6): Display up to maxlines non-blank lines for Code
     Context.  If there is no current context, show a single blank line.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33656

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33768

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33763

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33664

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33679

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33642


File: python.info,  Node: Python 3 7 0 beta 5,  Next: Python 3 7 0 beta 4,  Prev: Python 3 7 0 release candidate 1,  Up: 変更履歴

1.23.54 Python 3.7.0 beta 5
---------------------------

'Release date: 2018-05-30'

* Menu:

* Core and Builtins: Core and Builtins<53>.
* Library: Library<53>.
* Documentation: Documentation<47>.
* Tests: Tests<48>.
* Build: Build<51>.
* macOS: macOS<38>.
* IDLE: IDLE<39>.


File: python.info,  Node: Core and Builtins<53>,  Next: Library<53>,  Up: Python 3 7 0 beta 5

1.23.54.1 Core and Builtins
...........................

   - bpo-33622(1): Fixed a leak when the garbage collector fails to add
     an object with the ‘__del__’ method or referenced by it into the
     *note gc.garbage: 1191. list.  *note PyGC_Collect(): 95c. can now
     be called when an exception is set and preserves it.

   - bpo-33509(2): Fix module_globals parameter of
     warnings.warn_explicit(): don't crash if module_globals is not a
     dict.

   - bpo-20104(3): The new ‘os.posix_spawn’ added in 3.7.0b1 was removed
     as we are still working on what the API should look like.  Expect
     this in 3.8 instead.

   - bpo-33475(4): Fixed miscellaneous bugs in converting annotations to
     strings and optimized parentheses in the string representation.

   - bpo-33391(5): Fix a leak in set_symmetric_difference().

   - bpo-28055(6): Fix unaligned accesses in siphash24().  Patch by Rolf
     Eike Beer.

   - bpo-32911(7): Due to unexpected compatibility issues discovered
     during downstream beta testing, reverted bpo-29463(8).  ‘docstring’
     field is removed from Module, ClassDef, FunctionDef, and
     AsyncFunctionDef ast nodes which was added in 3.7a1.  Docstring
     expression is restored as a first statement in their body.  Based
     on patch by Inada Naoki.

   - bpo-21983(9): Fix a crash in ‘ctypes.cast()’ in case the type
     argument is a ctypes structured data type.  Patch by Eryk Sun and
     Oren Milman.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33622

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33509

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20104

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33475

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33391

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28055

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32911

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29463

   (9) https://bugs.python.org/issue?@action=redirect&bpo=21983


File: python.info,  Node: Library<53>,  Next: Documentation<47>,  Prev: Core and Builtins<53>,  Up: Python 3 7 0 beta 5

1.23.54.2 Library
.................

   - bpo-32751(1): When cancelling the task due to a timeout, *note
     asyncio.wait_for(): 5ca. will now wait until the cancellation is
     complete.

   - bpo-32684(2): Fix gather to propagate cancellation of itself even
     with return_exceptions.

   - bpo-33654(3): Support protocol type switching in
     SSLTransport.set_protocol().

   - bpo-33674(4): Pause the transport as early as possible to further
     reduce the risk of data_received() being called before
     connection_made().

   - bpo-33674(5): Fix a race condition in SSLProtocol.connection_made()
     of asyncio.sslproto: start immediately the handshake instead of
     using call_soon().  Previously, data_received() could be called
     before the handshake started, causing the handshake to hang or
     fail.

   - bpo-31647(6): Fixed bug where calling write_eof() on a
     _SelectorSocketTransport after it's already closed raises
     AttributeError.

   - bpo-32610(7): Make asyncio.all_tasks() return only pending tasks.

   - bpo-32410(8): Avoid blocking on file IO in sendfile fallback code

   - bpo-33469(9): Fix RuntimeError after closing loop that used
     run_in_executor

   - bpo-33672(10): Fix Task.__repr__ crash with Cython's bogus
     coroutines

   - bpo-33654(11): Fix transport.set_protocol() to support switching
     between asyncio.Protocol and asyncio.BufferedProtocol.  Fix
     loop.start_tls() to work with asyncio.BufferedProtocols.

   - bpo-33652(12): Pickles of type variables and subscripted generics
     are now future-proof and compatible with older Python versions.

   - bpo-32493(13): Fixed *note uuid.uuid1(): b76. on FreeBSD.

   - bpo-33618(14): Finalize and document preliminary and experimental
     TLS 1.3 support with OpenSSL 1.1.1

   - bpo-33623(15): Fix possible SIGSGV when asyncio.Future is created
     in __del__

   - bpo-30877(16): Fixed a bug in the Python implementation of the JSON
     decoder that prevented the cache of parsed strings from clearing
     after finishing the decoding.  Based on patch by c-fos.

   - bpo-33570(17): Change TLS 1.3 cipher suite settings for
     compatibility with OpenSSL 1.1.1-pre6 and newer.  OpenSSL 1.1.1
     will have TLS 1.3 ciphers enabled by default.

   - bpo-28556(18): Do not simplify arguments to ‘typing.Union’.  Now
     ‘Union[Manager, Employee]’ is not simplified to ‘Employee’ at
     runtime.  Such simplification previously caused several bugs and
     limited possibilities for introspection.

   - bpo-33540(19): Add a new ‘block_on_close’ class attribute to
     ‘ForkingMixIn’ and ‘ThreadingMixIn’ classes of *note socketserver:
     b9.

   - bpo-33548(20): tempfile._candidate_tempdir_list should consider
     common TEMP locations

   - bpo-33109(21): argparse subparsers are once again not required by
     default, reverting the change in behavior introduced by
     bpo-26510(22) in 3.7.0a2.

   - bpo-33536(23): dataclasses.make_dataclass now checks for invalid
     field names and duplicate fields.  Also, added a check for invalid
     field specifications.

   - bpo-33542(24): Prevent ‘uuid.get_node’ from using a DUID instead of
     a MAC on Windows.  Patch by Zvi Effron

   - bpo-26819(25): Fix race condition with
     ‘ReadTransport.resume_reading’ in Windows proactor event loop.

   - Fix failure in ‘typing.get_type_hints()’ when ClassVar was provided
     as a string forward reference.

   - bpo-33505(26): Optimize asyncio.ensure_future() by reordering if
     checks: 1.17x faster.

   - bpo-33497(27): Add errors param to cgi.parse_multipart and make an
     encoding in FieldStorage use the given errors (needed for Twisted).
     Patch by Amber Brown.

   - bpo-33495(28): Change dataclasses.Fields repr to use the repr of
     each of its members, instead of str.  This makes it more clear what
     each field actually represents.  This is especially true for the
     'type' member.

   - bpo-33453(29): Fix dataclasses to work if using literal string type
     annotations or if using PEP 563 "Postponed Evaluation of
     Annotations".  Only specific string prefixes are detected for both
     ClassVar ("ClassVar" and "typing.ClassVar") and InitVar ("InitVar"
     and "dataclasses.InitVar").

   - bpo-28556(30): Minor fixes in typing module: add annotations to
     ‘NamedTuple.__new__’, pass ‘*args’ and ‘**kwds’ in
     ‘Generic.__new__’.  Original PRs by Paulius Šarka and Chad
     Dombrova.

   - bpo-20087(31): Updated alias mapping with glibc 2.27 supported
     locales.

   - bpo-33422(32): Fix trailing quotation marks getting deleted when
     looking up byte/string literals on pydoc.  Patch by Andrés Delfino.

   - bpo-28167(33): The function ‘platform.linux_distribution’ and
     ‘platform.dist’ now trigger a ‘DeprecationWarning’ and have been
     marked for removal in Python 3.8

   - bpo-33197(34): Update error message when constructing invalid
     inspect.Parameters Patch by Donghee Na.

   - bpo-33263(35): Fix FD leak in ‘_SelectorSocketTransport’ Patch by
     Vlad Starostin.

   - bpo-32861(36): The urllib.robotparser's ‘__str__’ representation
     now includes wildcard entries and the "Crawl-delay" and
     "Request-rate" fields.  Patch by Michael Lazar.

   - bpo-32257(37): The ssl module now contains OP_NO_RENEGOTIATION
     constant, available with OpenSSL 1.1.0h or 1.1.1.

   - bpo-16865(38): Support arrays >=2GiB in *note ctypes: 22.  Patch by
     Segev Finer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32751

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32684

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33654

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33674

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33674

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31647

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32610

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32410

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33469

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33672

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33654

   (12) https://bugs.python.org/issue?@action=redirect&bpo=33652

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32493

   (14) https://bugs.python.org/issue?@action=redirect&bpo=33618

   (15) https://bugs.python.org/issue?@action=redirect&bpo=33623

   (16) https://bugs.python.org/issue?@action=redirect&bpo=30877

   (17) https://bugs.python.org/issue?@action=redirect&bpo=33570

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (19) https://bugs.python.org/issue?@action=redirect&bpo=33540

   (20) https://bugs.python.org/issue?@action=redirect&bpo=33548

   (21) https://bugs.python.org/issue?@action=redirect&bpo=33109

   (22) https://bugs.python.org/issue?@action=redirect&bpo=26510

   (23) https://bugs.python.org/issue?@action=redirect&bpo=33536

   (24) https://bugs.python.org/issue?@action=redirect&bpo=33542

   (25) https://bugs.python.org/issue?@action=redirect&bpo=26819

   (26) https://bugs.python.org/issue?@action=redirect&bpo=33505

   (27) https://bugs.python.org/issue?@action=redirect&bpo=33497

   (28) https://bugs.python.org/issue?@action=redirect&bpo=33495

   (29) https://bugs.python.org/issue?@action=redirect&bpo=33453

   (30) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (31) https://bugs.python.org/issue?@action=redirect&bpo=20087

   (32) https://bugs.python.org/issue?@action=redirect&bpo=33422

   (33) https://bugs.python.org/issue?@action=redirect&bpo=28167

   (34) https://bugs.python.org/issue?@action=redirect&bpo=33197

   (35) https://bugs.python.org/issue?@action=redirect&bpo=33263

   (36) https://bugs.python.org/issue?@action=redirect&bpo=32861

   (37) https://bugs.python.org/issue?@action=redirect&bpo=32257

   (38) https://bugs.python.org/issue?@action=redirect&bpo=16865


File: python.info,  Node: Documentation<47>,  Next: Tests<48>,  Prev: Library<53>,  Up: Python 3 7 0 beta 5

1.23.54.3 Documentation
.......................

   - bpo-23859(1): Document that ‘asyncio.wait()’ does not cancel its
     futures on timeout.

   - bpo-32436(2): Document PEP 567(3) changes to asyncio.

   - bpo-33604(4): Update HMAC md5 default to a DeprecationWarning, bump
     removal to 3.8.

   - bpo-33503(5): Fix broken pypi link

   - bpo-33421(6): Add missing documentation for
     ‘typing.AsyncContextManager’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23859

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32436

   (3) https://peps.python.org/pep-0567/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33604

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33503

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33421


File: python.info,  Node: Tests<48>,  Next: Build<51>,  Prev: Documentation<47>,  Up: Python 3 7 0 beta 5

1.23.54.4 Tests
...............

   - bpo-33655(1): Ignore test_posix_fallocate failures on BSD platforms
     that might be due to running on ZFS.

   - bpo-32604(2): Remove the _xxsubinterpreters module (meant for
     testing) and associated helpers.  This module was originally added
     recently in 3.7b1.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33655

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32604


File: python.info,  Node: Build<51>,  Next: macOS<38>,  Prev: Tests<48>,  Up: Python 3 7 0 beta 5

1.23.54.5 Build
...............

   - bpo-33614(1): Ensures module definition files for the stable ABI on
     Windows are correctly regenerated.

   - bpo-33522(2): Enable CI builds on Visual Studio Team Services at
     ‘https://python.visualstudio.com/cpython’

   - bpo-33012(3): Add ‘-Wno-cast-function-type’ for gcc 8 for silencing
     warnings about function casts like casting to PyCFunction in method
     definition lists.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33614

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33522

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33012


File: python.info,  Node: macOS<38>,  Next: IDLE<39>,  Prev: Build<51>,  Up: Python 3 7 0 beta 5

1.23.54.6 macOS
...............

   - bpo-13631(1): The .editrc file in user's home directory is now
     processed correctly during the readline initialization through
     editline emulation on macOS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13631


File: python.info,  Node: IDLE<39>,  Prev: macOS<38>,  Up: Python 3 7 0 beta 5

1.23.54.7 IDLE
..............

   - bpo-33628(1): IDLE: Cleanup codecontext.py and its test.

   - bpo-33564(2): IDLE's code context now recognizes async as a block
     opener.

   - bpo-32831(3): Add docstrings and tests for codecontext.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33628

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33564

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32831


File: python.info,  Node: Python 3 7 0 beta 4,  Next: Python 3 7 0 beta 3,  Prev: Python 3 7 0 beta 5,  Up: 変更履歴

1.23.55 Python 3.7.0 beta 4
---------------------------

'Release date: 2018-05-02'

* Menu:

* Core and Builtins: Core and Builtins<54>.
* Library: Library<54>.
* Documentation: Documentation<48>.
* Tests: Tests<49>.
* Build: Build<52>.
* Windows: Windows<47>.
* macOS: macOS<39>.
* IDLE: IDLE<40>.
* Tools/Demos: Tools/Demos<25>.


File: python.info,  Node: Core and Builtins<54>,  Next: Library<54>,  Up: Python 3 7 0 beta 4

1.23.55.1 Core and Builtins
...........................

   - bpo-33363(1): Raise a SyntaxError for ‘async with’ and ‘async for’
     statements outside of async functions.

   - bpo-33128(2): Fix a bug that causes PathFinder to appear twice on
     sys.meta_path.  Patch by Pablo Galindo Salgado.

   - bpo-33312(3): Fixed clang ubsan (undefined behavior sanitizer)
     warnings in dictobject.c by adjusting how the internal struct
     _dictkeysobject shared keys structure is declared.

   - bpo-33231(4): Fix potential memory leak in ‘normalizestring()’.

   - bpo-33205(5): Change dict growth function from
     ‘round_up_to_power_2(used*2+hashtable_size/2)’ to
     ‘round_up_to_power_2(used*3)’.  Previously, dict is shrinked only
     when ‘used == 0’.  Now dict has more chance to be shrinked.

   - bpo-29922(6): Improved error messages in 'async with' when
     ‘__aenter__()’ or ‘__aexit__()’ return non-awaitable object.

   - bpo-33199(7): Fix ‘ma_version_tag’ in dict implementation is
     uninitialized when copying from key-sharing dict.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33363

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33128

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33312

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33231

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33205

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29922

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33199


File: python.info,  Node: Library<54>,  Next: Documentation<48>,  Prev: Core and Builtins<54>,  Up: Python 3 7 0 beta 4

1.23.55.2 Library
.................

   - bpo-33281(1): Fix ctypes.util.find_library regression on macOS.

   - bpo-33383(2): Fixed crash in the get() method of the *note
     dbm.ndbm: 2c. database object when it is called with a single
     argument.

   - bpo-33329(3): Fix multiprocessing regression on newer glibcs

   - bpo-991266(4): Fix quoting of the ‘Comment’ attribute of *note
     http.cookies.SimpleCookie: 19ae.

   - bpo-33131(5): Upgrade bundled version of pip to 10.0.1.

   - bpo-33308(6): Fixed a crash in the ‘parser’ module when converting
     an ST object to a tree of tuples or lists with ‘line_info=False’
     and ‘col_info=True’.

   - bpo-33266(7): lib2to3 now recognizes ‘rf'...'’ strings.

   - bpo-11594(8): Ensure line-endings are respected when using lib2to3.

   - bpo-33254(9): Have *note importlib.resources.contents(): 1d3. and
     *note importlib.abc.ResourceReader.contents(): 19af. return an
     *note iterable: 10ad. instead of an *note iterator: 191.

   - bpo-33256(10): Fix display of ‘<module>’ call in the html produced
     by ‘cgitb.html()’.  Patch by Stéphane Blondon.

   - bpo-33185(11): Fixed regression when running pydoc with the *note
     -m: 5ab. switch.  (The regression was introduced in 3.7.0b3 by the
     resolution of bpo-33053(12)) This fix also changed pydoc to add
     ‘os.getcwd()’ to *note sys.path: 38e. when necessary, rather than
     adding ‘"."’.

   - bpo-33169(13): Delete entries of ‘None’ in *note
     sys.path_importer_cache: 5ae. when
     ‘importlib.machinery.invalidate_caches()’ is called.

   - bpo-33217(14): Deprecate looking up non-Enum objects in Enum
     classes and Enum members (will raise *note TypeError: 502. in
     3.8+).

   - bpo-33203(15): ‘random.Random.choice()’ now raises ‘IndexError’ for
     empty sequences consistently even when called from subclasses
     without a ‘getrandbits()’ implementation.

   - bpo-33224(16): Update difflib.mdiff() for PEP 479(17).  Convert an
     uncaught StopIteration in a generator into a return-statement.

   - bpo-33209(18): End framing at the end of C implementation of *note
     pickle.Pickler.dump(): 19b0.

   - bpo-20104(19): Improved error handling and fixed a reference leak
     in *note os.posix_spawn(): 201.

   - bpo-33175(20): In dataclasses, Field.__set_name__ now looks up the
     __set_name__ special method on the class, not the instance, of the
     default value.

   - bpo-33097(21): Raise RuntimeError when ‘executor.submit’ is called
     during interpreter shutdown.

   - bpo-31908(22): Fix output of cover files for ‘trace’ module
     command-line tool.  Previously emitted cover files only when
     ‘--missing’ option was used.  Patch by Michael Selik.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33281

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33383

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33329

   (4) https://bugs.python.org/issue?@action=redirect&bpo=991266

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33131

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33308

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33266

   (8) https://bugs.python.org/issue?@action=redirect&bpo=11594

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33254

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33256

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33185

   (12) https://bugs.python.org/issue?@action=redirect&bpo=33053

   (13) https://bugs.python.org/issue?@action=redirect&bpo=33169

   (14) https://bugs.python.org/issue?@action=redirect&bpo=33217

   (15) https://bugs.python.org/issue?@action=redirect&bpo=33203

   (16) https://bugs.python.org/issue?@action=redirect&bpo=33224

   (17) https://peps.python.org/pep-0479/

   (18) https://bugs.python.org/issue?@action=redirect&bpo=33209

   (19) https://bugs.python.org/issue?@action=redirect&bpo=20104

   (20) https://bugs.python.org/issue?@action=redirect&bpo=33175

   (21) https://bugs.python.org/issue?@action=redirect&bpo=33097

   (22) https://bugs.python.org/issue?@action=redirect&bpo=31908


File: python.info,  Node: Documentation<48>,  Next: Tests<49>,  Prev: Library<54>,  Up: Python 3 7 0 beta 4

1.23.55.3 Documentation
.......................

   - bpo-33378(1): Add Korean language switcher for
     ‘https://docs.python.org/3/’

   - bpo-33276(2): Clarify that the ‘__path__’ attribute on modules
     cannot be just any value.

   - bpo-33201(3): Modernize documentation for writing C extension
     types.

   - bpo-33195(4): Deprecate ‘Py_UNICODE’ usage in ‘c-api/arg’ document.
     ‘Py_UNICODE’ related APIs are deprecated since Python 3.3, but it
     is missed in the document.

   - bpo-8243(5): Add a note about curses.addch and curses.addstr
     exception behavior when writing outside a window, or pad.

   - bpo-32337(6): Update documentation related with ‘dict’ order.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33378

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33276

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33201

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33195

   (5) https://bugs.python.org/issue?@action=redirect&bpo=8243

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32337


File: python.info,  Node: Tests<49>,  Next: Build<52>,  Prev: Documentation<48>,  Up: Python 3 7 0 beta 4

1.23.55.4 Tests
...............

   - bpo-33358(1): Fix
     ‘test_embed.test_pre_initialization_sys_options()’ when the
     interpreter is built with ‘--enable-shared’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33358


File: python.info,  Node: Build<52>,  Next: Windows<47>,  Prev: Tests<49>,  Up: Python 3 7 0 beta 4

1.23.55.5 Build
...............

   - bpo-33394(1): Enable the verbose build for extension modules, when
     GNU make is passed macros on the command line.

   - bpo-33393(2): Update config.guess and config.sub files.

   - bpo-33377(3): Add new triplets for mips r6 and riscv variants (used
     in extension suffixes).

   - bpo-32232(4): By default, modules configured in ‘Modules/Setup’ are
     no longer built with ‘-DPy_BUILD_CORE’.  Instead, modules that
     specifically need that preprocessor definition include it in their
     individual entries.

   - bpo-33182(5): The embedding tests can once again be built with
     clang 6.0

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33394

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33393

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33377

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32232

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33182


File: python.info,  Node: Windows<47>,  Next: macOS<39>,  Prev: Build<52>,  Up: Python 3 7 0 beta 4

1.23.55.6 Windows
.................

   - bpo-33184(1): Update Windows installer to use OpenSSL 1.1.0h.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33184


File: python.info,  Node: macOS<39>,  Next: IDLE<40>,  Prev: Windows<47>,  Up: Python 3 7 0 beta 4

1.23.55.7 macOS
...............

   - bpo-33184(1): Update macOS installer build to use OpenSSL 1.1.0h.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33184


File: python.info,  Node: IDLE<40>,  Next: Tools/Demos<25>,  Prev: macOS<39>,  Up: Python 3 7 0 beta 4

1.23.55.8 IDLE
..............

   - bpo-21474(1): Update word/identifier definition from ascii to
     unicode.  In text and entry boxes, this affects selection by
     double-click, movement left/right by control-left/right, and
     deletion left/right by control-BACKSPACE/DEL.

   - bpo-33204(2): IDLE: consistently color invalid string prefixes.  A
     'u' string prefix cannot be paired with either 'r' or 'f'.
     Consistently color as much of the prefix, starting at the right, as
     is valid.  Revise and extend colorizer test.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21474

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33204


File: python.info,  Node: Tools/Demos<25>,  Prev: IDLE<40>,  Up: Python 3 7 0 beta 4

1.23.55.9 Tools/Demos
.....................

   - bpo-33189(1): ‘pygettext.py’ now recognizes only literal strings as
     docstrings and translatable strings, and rejects bytes literals and
     f-string expressions.

   - bpo-31920(2): Fixed handling directories as arguments in the
     ‘pygettext’ script.  Based on patch by Oleg Krasnikov.

   - bpo-29673(3): Fix pystackv and pystack gdbinit macros.

   - bpo-31583(4): Fix 2to3 for using with -add-suffix option but
     without -output-dir option for relative path to files in current
     directory.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33189

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31920

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29673

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31583


File: python.info,  Node: Python 3 7 0 beta 3,  Next: Python 3 7 0 beta 2,  Prev: Python 3 7 0 beta 4,  Up: 変更履歴

1.23.56 Python 3.7.0 beta 3
---------------------------

'Release date: 2018-03-29'

* Menu:

* Security: Security<35>.
* Core and Builtins: Core and Builtins<55>.
* Library: Library<55>.
* Documentation: Documentation<49>.
* Tests: Tests<50>.
* Build: Build<53>.
* Windows: Windows<48>.
* macOS: macOS<40>.
* IDLE: IDLE<41>.
* Tools/Demos: Tools/Demos<26>.
* C API: C API<50>.


File: python.info,  Node: Security<35>,  Next: Core and Builtins<55>,  Up: Python 3 7 0 beta 3

1.23.56.1 Security
..................

   - bpo-33136(1): Harden ssl module against LibreSSL CVE 2018-8970(2).
     X509_VERIFY_PARAM_set1_host() is called with an explicit namelen.
     A new test ensures that NULL bytes are not allowed.

   - bpo-33001(3): Minimal fix to prevent buffer overrun in os.symlink
     on Windows

   - bpo-32981(4): Regexes in difflib and poplib were vulnerable to
     catastrophic backtracking.  These regexes formed potential DOS
     vectors (REDOS). They have been refactored.  This resolves CVE
     2018-1060(5) and CVE 2018-1061(6).  Patch by Jamie Davis.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33136

   (2) https://www.cve.org/CVERecord?id=CVE-2018-8970

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33001

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32981

   (5) https://www.cve.org/CVERecord?id=CVE-2018-1060

   (6) https://www.cve.org/CVERecord?id=CVE-2018-1061


File: python.info,  Node: Core and Builtins<55>,  Next: Library<55>,  Prev: Security<35>,  Up: Python 3 7 0 beta 3

1.23.56.2 Core and Builtins
...........................

   - bpo-33053(1): When using the -m switch, sys.path[0] is now
     explicitly expanded as the 'starting' working directory, rather
     than being left as the empty path (which allows imports from the
     current working directory at the time of the import)

   - bpo-33018(2): Improve consistency of errors raised by
     ‘issubclass()’ when called with a non-class and an abstract base
     class as the first and second arguments, respectively.  Patch by
     Josh Bronson.

   - bpo-33041(3): Fixed jumping when the function contains an ‘async
     for’ loop.

   - bpo-33026(4): Fixed jumping out of "with" block by setting
     f_lineno.

   - bpo-33005(5): Fix a crash on fork when using a custom memory
     allocator (ex: using PYTHONMALLOC env var).  _PyGILState_Reinit()
     and _PyInterpreterState_Enable() now use the default RAW memory
     allocator to allocate a new interpreters mutex on fork.

   - bpo-17288(6): Prevent jumps from 'return' and 'exception' trace
     events.

   - bpo-32836(7): Don't use temporary variables in cases of
     list/dict/set comprehensions

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33053

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33018

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33041

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33026

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33005

   (6) https://bugs.python.org/issue?@action=redirect&bpo=17288

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32836


File: python.info,  Node: Library<55>,  Next: Documentation<49>,  Prev: Core and Builtins<55>,  Up: Python 3 7 0 beta 3

1.23.56.3 Library
.................

   - bpo-33141(1): Have Field objects pass through __set_name__ to their
     default values, if they have their own __set_name__.

   - bpo-33096(2): Allow ttk.Treeview.insert to insert iid that has a
     false boolean value.  Note iid=0 and iid=False would be same.
     Patch by Garvit Khatri.

   - bpo-32873(3): Treat type variables and special typing forms as
     immutable by copy and pickle.  This fixes several minor issues and
     inconsistencies, and improves backwards compatibility with Python
     3.6.

   - bpo-33134(4): When computing dataclass's __hash__, use the lookup
     table to contain the function which returns the __hash__ value.
     This is an improvement over looking up a string, and then testing
     that string to see what to do.

   - bpo-33127(5): The ssl module now compiles with LibreSSL 2.7.1.

   - bpo-32505(6): Raise TypeError if a member variable of a dataclass
     is of type Field, but doesn't have a type annotation.

   - bpo-33078(7): Fix the failure on OSX caused by the tests relying on
     sem_getvalue

   - bpo-33116(8): Add 'Field' to dataclasses.__all__.

   - bpo-32896(9): Fix an error where subclassing a dataclass with a
     field that uses a default_factory would generate an incorrect
     class.

   - bpo-33100(10): Dataclasses: If a field has a default value that's a
     MemberDescriptorType, then it's from that field being in __slots__,
     not an actual default value.

   - bpo-32953(11): If a non-dataclass inherits from a frozen dataclass,
     allow attributes to be added to the derived class.  Only attributes
     from the frozen dataclass cannot be assigned to.  Require all
     dataclasses in a hierarchy to be either all frozen or all
     non-frozen.

   - bpo-33061(12): Add missing ‘NoReturn’ to ‘__all__’ in typing.py

   - bpo-33078(13): Fix the size handling in multiprocessing.Queue when
     a pickling error occurs.

   - bpo-33064(14): lib2to3 now properly supports trailing commas after
     ‘*args’ and ‘**kwargs’ in function signatures.

   - bpo-33056(15): FIX properly close leaking fds in
     concurrent.futures.ProcessPoolExecutor.

   - bpo-33021(16): Release the GIL during fstat() calls, avoiding hang
     of all threads when calling mmap.mmap(), os.urandom(), and
     random.seed().  Patch by Nir Soffer.

   - bpo-31804(17): Avoid failing in multiprocessing.Process if the
     standard streams are closed or None at exit.

   - bpo-33037(18): Skip sending/receiving data after SSL transport
     closing.

   - bpo-27683(19): Fix a regression in *note ipaddress: 74. that result
     of ‘hosts()’ is empty when the network is constructed by a tuple
     containing an integer mask and only 1 bit left for addresses.

   - bpo-32999(20): Fix C implementation of ‘ABC.__subclasscheck__(cls,
     subclass)’ crashed when ‘subclass’ is not a type object.

   - bpo-33009(21): Fix inspect.signature() for single-parameter
     partialmethods.

   - bpo-32969(22): Expose several missing constants in zlib and fix
     corresponding documentation.

   - bpo-32056(23): Improved exceptions raised for invalid number of
     channels and sample width when read an audio file in modules
     ‘aifc’, *note wave: fb. and ‘sunau’.

   - bpo-32844(24): Fix wrong redirection of a low descriptor (0 or 1)
     to stderr in subprocess if another low descriptor is closed.

   - bpo-32857(25): In *note tkinter: d9, ‘after_cancel(None)’ now
     raises a *note ValueError: 1e3. instead of canceling the first
     scheduled function.  Patch by Cheryl Sabella.

   - bpo-31639(26): http.server now exposes a ThreadedHTTPServer class
     and uses it when the module is run with ‘-m’ to cope with web
     browsers pre-opening sockets.

   - bpo-27645(27): *note sqlite3.Connection: 226. now exposes a *note
     backup: b48. method, if the underlying SQLite library is at version
     3.6.11 or higher.  Patch by Lele Gaifax.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33141

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33096

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32873

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33134

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33127

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32505

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33078

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33116

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32896

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33100

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32953

   (12) https://bugs.python.org/issue?@action=redirect&bpo=33061

   (13) https://bugs.python.org/issue?@action=redirect&bpo=33078

   (14) https://bugs.python.org/issue?@action=redirect&bpo=33064

   (15) https://bugs.python.org/issue?@action=redirect&bpo=33056

   (16) https://bugs.python.org/issue?@action=redirect&bpo=33021

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31804

   (18) https://bugs.python.org/issue?@action=redirect&bpo=33037

   (19) https://bugs.python.org/issue?@action=redirect&bpo=27683

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32999

   (21) https://bugs.python.org/issue?@action=redirect&bpo=33009

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32969

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32056

   (24) https://bugs.python.org/issue?@action=redirect&bpo=32844

   (25) https://bugs.python.org/issue?@action=redirect&bpo=32857

   (26) https://bugs.python.org/issue?@action=redirect&bpo=31639

   (27) https://bugs.python.org/issue?@action=redirect&bpo=27645


File: python.info,  Node: Documentation<49>,  Next: Tests<50>,  Prev: Library<55>,  Up: Python 3 7 0 beta 3

1.23.56.4 Documentation
.......................

   - bpo-33126(1): Document PyBuffer_ToContiguous().

   - bpo-27212(2): Modify documentation for the ‘islice()’ recipe to
     consume initial values up to the start index.

   - bpo-28247(3): Update *note zipapp: 116. documentation to describe
     how to make standalone applications.

   - bpo-18802(4): Documentation changes for ipaddress.  Patch by Jon
     Foster and Berker Peksag.

   - bpo-27428(5): Update documentation to clarify that
     ‘WindowsRegistryFinder’ implements ‘MetaPathFinder’.  (Patch by
     Himanshu Lakhara)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33126

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27212

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28247

   (4) https://bugs.python.org/issue?@action=redirect&bpo=18802

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27428


File: python.info,  Node: Tests<50>,  Next: Build<53>,  Prev: Documentation<49>,  Up: Python 3 7 0 beta 3

1.23.56.5 Tests
...............

   - bpo-32872(1): Avoid regrtest compatibility issue with namespace
     packages.

   - bpo-32517(2): Fix failing ‘test_asyncio’ on macOS 10.12.2+ due to
     transport of ‘KqueueSelector’ loop was not being closed.

   - bpo-19417(3): Add test_bdb.py.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32872

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32517

   (3) https://bugs.python.org/issue?@action=redirect&bpo=19417


File: python.info,  Node: Build<53>,  Next: Windows<48>,  Prev: Tests<50>,  Up: Python 3 7 0 beta 3

1.23.56.6 Build
...............

   - bpo-33163(1): Upgrade pip to 9.0.3 and setuptools to v39.0.1.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33163


File: python.info,  Node: Windows<48>,  Next: macOS<40>,  Prev: Build<53>,  Up: Python 3 7 0 beta 3

1.23.56.7 Windows
.................

   - bpo-33016(1): Fix potential use of uninitialized memory in
     nt._getfinalpathname

   - bpo-32903(2): Fix a memory leak in os.chdir() on Windows if the
     current directory is set to a UNC path.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33016

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32903


File: python.info,  Node: macOS<40>,  Next: IDLE<41>,  Prev: Windows<48>,  Up: Python 3 7 0 beta 3

1.23.56.8 macOS
...............

   - bpo-32726(1): Build and link with private copy of Tcl/Tk 8.6 for
     the macOS 10.6+ installer.  The 10.9+ installer variant already
     does this.  This means that the Python 3.7 provided by the
     python.org macOS installers no longer need or use any external
     versions of Tcl/Tk, either system-provided or user-installed, such
     as ActiveTcl.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32726


File: python.info,  Node: IDLE<41>,  Next: Tools/Demos<26>,  Prev: macOS<40>,  Up: Python 3 7 0 beta 3

1.23.56.9 IDLE
..............

   - bpo-32984(1): Set ‘__file__’ while running a startup file.  Like
     Python, IDLE optionally runs one startup file in the Shell window
     before presenting the first interactive input prompt.  For IDLE,
     ‘-s’ runs a file named in environmental variable ‘IDLESTARTUP’ or
     *note PYTHONSTARTUP: f95.; ‘-r file’ runs ‘file’.  Python sets
     ‘__file__’ to the startup file name before running the file and
     unsets it before the first prompt.  IDLE now does the same when run
     normally, without the ‘-n’ option.

   - bpo-32940(2): Simplify and rename StringTranslatePseudoMapping in
     pyparse.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32984

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32940


File: python.info,  Node: Tools/Demos<26>,  Next: C API<50>,  Prev: IDLE<41>,  Up: Python 3 7 0 beta 3

1.23.56.10 Tools/Demos
......................

   - bpo-32885(1): Add an ‘-n’ flag for ‘Tools/scripts/pathfix.py’ to
     disable automatic backup creation (files with ‘~’ suffix).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32885


File: python.info,  Node: C API<50>,  Prev: Tools/Demos<26>,  Up: Python 3 7 0 beta 3

1.23.56.11 C API
................

   - bpo-33042(1): Embedding applications may once again call
     PySys_ResetWarnOptions, PySys_AddWarnOption, and PySys_AddXOption
     prior to calling Py_Initialize.

   - bpo-32374(2): Document that m_traverse for multi-phase initialized
     modules can be called with m_state=NULL, and add a sanity check

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33042

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32374


File: python.info,  Node: Python 3 7 0 beta 2,  Next: Python 3 7 0 beta 1,  Prev: Python 3 7 0 beta 3,  Up: 変更履歴

1.23.57 Python 3.7.0 beta 2
---------------------------

'Release date: 2018-02-27'

* Menu:

* Security: Security<36>.
* Core and Builtins: Core and Builtins<56>.
* Library: Library<56>.
* Documentation: Documentation<50>.
* Tests: Tests<51>.
* Build: Build<54>.
* Windows: Windows<49>.
* macOS: macOS<41>.
* IDLE: IDLE<42>.
* Tools/Demos: Tools/Demos<27>.


File: python.info,  Node: Security<36>,  Next: Core and Builtins<56>,  Up: Python 3 7 0 beta 2

1.23.57.1 Security
..................

   - bpo-28414(1): The ssl module now allows users to perform their own
     IDN en/decoding when using SNI.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28414


File: python.info,  Node: Core and Builtins<56>,  Next: Library<56>,  Prev: Security<36>,  Up: Python 3 7 0 beta 2

1.23.57.2 Core and Builtins
...........................

   - bpo-32889(1): Update Valgrind suppression list to account for the
     rename of ‘Py_ADDRESS_IN_RANG’ to ‘address_in_range’.

   - bpo-31356(2): Remove the new API added in bpo-31356(3)
     (gc.ensure_disabled() context manager).

   - bpo-32305(4): For namespace packages, ensure that both ‘__file__’
     and ‘__spec__.origin’ are set to None.

   - bpo-32303(5): Make sure ‘__spec__.loader’ matches ‘__loader__’ for
     namespace packages.

   - bpo-32711(6): Fix the warning messages for Python/ast_unparse.c.
     Patch by Stéphane Wirtel

   - bpo-32583(7): Fix possible crashing in builtin Unicode decoders
     caused by write out-of-bound errors when using customized decode
     error handlers.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32889

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31356

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31356

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32305

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32303

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32711

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32583


File: python.info,  Node: Library<56>,  Next: Documentation<50>,  Prev: Core and Builtins<56>,  Up: Python 3 7 0 beta 2

1.23.57.3 Library
.................

   - bpo-32960(1): For dataclasses, disallow inheriting frozen from
     non-frozen classes, and also disallow inheriting non-frozen from
     frozen classes.  This restriction will be relaxed at a future date.

   - bpo-32713(2): Fixed tarfile.itn handling of out-of-bounds float
     values.  Patch by Joffrey Fuhrer.

   - bpo-32951(3): Direct instantiation of SSLSocket and SSLObject
     objects is now prohibited.  The constructors were never documented,
     tested, or designed as public constructors.  Users were suppose to
     use ssl.wrap_socket() or SSLContext.

   - bpo-32929(4): Remove the tri-state parameter "hash", and add the
     boolean "unsafe_hash".  If unsafe_hash is True, add a __hash__
     function, but if a __hash__ exists, raise TypeError.  If
     unsafe_hash is False, add a __hash__ based on the values of eq= and
     frozen=.  The unsafe_hash=False behavior is the same as the old
     hash=None behavior.  unsafe_hash=False is the default, just as
     hash=None used to be.

   - bpo-32947(5): Add OP_ENABLE_MIDDLEBOX_COMPAT and test workaround
     for TLSv1.3 for future compatibility with OpenSSL 1.1.1.

   - bpo-30622(6): The ssl module now detects missing NPN support in
     LibreSSL.

   - bpo-32922(7): dbm.open() now encodes filename with the filesystem
     encoding rather than default encoding.

   - bpo-32859(8): In ‘os.dup2’, don't check every call whether the
     ‘dup3’ syscall exists or not.

   - bpo-32556(9): nt._getfinalpathname, nt._getvolumepathname and
     nt._getdiskusage now correctly convert from bytes.

   - bpo-25988(10): Emit a *note DeprecationWarning: 18a. when using or
     importing an ABC directly from *note collections: 16. rather than
     from *note collections.abc: 17.

   - bpo-21060(11): Rewrite confusing message from setup.py upload from
     "No dist file created in earlier command" to the more helpful "Must
     create and upload files in one command".

   - bpo-32852(12): Make sure sys.argv remains as a list when running
     trace.

   - bpo-31333(13): ‘_abc’ module is added.  It is a speedup module with
     C implementations for various functions and methods in ‘abc’.
     Creating an ABC subclass and calling ‘isinstance’ or ‘issubclass’
     with an ABC subclass are up to 1.5x faster.  In addition, this
     makes Python start-up up to 10% faster.  Note that the new
     implementation hides internal registry and caches, previously
     accessible via private attributes ‘_abc_registry’, ‘_abc_cache’,
     and ‘_abc_negative_cache’.  There are three debugging helper
     methods that can be used instead ‘_dump_registry’,
     ‘_abc_registry_clear’, and ‘_abc_caches_clear’.

   - bpo-32841(14): Fixed ‘asyncio.Condition’ issue which silently
     ignored cancellation after notifying and cancelling a conditional
     lock.  Patch by Bar Harel.

   - bpo-32819(15): ssl.match_hostname() has been simplified and no
     longer depends on re and ipaddress module for wildcard and IP
     addresses.  Error reporting for invalid wildcards has been
     improved.

   - bpo-32394(16): socket: Remove
     TCP_FASTOPEN,TCP_KEEPCNT,TCP_KEEPIDLE,TCP_KEEPINTVL flags on older
     version Windows during run-time.

   - bpo-31787(17): Fixed refleaks of ‘__init__()’ methods in various
     modules.  (Contributed by Oren Milman)

   - bpo-30157(18): Fixed guessing quote and delimiter in
     csv.Sniffer.sniff() when only the last field is quoted.  Patch by
     Jake Davis.

   - bpo-32792(19): collections.ChainMap() preserves the order of the
     underlying mappings.

   - bpo-32775(20): *note fnmatch.translate(): 19b1. no longer produces
     patterns which contain set operations.  Sets starting with '[' or
     containing '-', '&&', '~~' or '||' will be interpreted differently
     in regular expressions in future versions.  Currently they emit
     warnings.  fnmatch.translate() now avoids producing patterns
     containing such sets by accident.

   - bpo-32622(21): Implement native fast sendfile for Windows proactor
     event loop.

   - bpo-32777(22): Fix a rare but potential pre-exec child process
     deadlock in subprocess on POSIX systems when marking file
     descriptors inheritable on exec in the child process.  This bug
     appears to have been introduced in 3.4.

   - bpo-32647(23): The ctypes module used to depend on indirect linking
     for dlopen.  The shared extension is now explicitly linked against
     libdl on platforms with dl.

   - bpo-32741(24): Implement ‘asyncio.TimerHandle.when()’ method.

   - bpo-32691(25): Use mod_spec.parent when running modules with pdb

   - bpo-32734(26): Fixed ‘asyncio.Lock()’ safety issue which allowed
     acquiring and locking the same lock multiple times, without it
     being free.  Patch by Bar Harel.

   - bpo-32727(27): Do not include name field in SMTP envelope from
     address.  Patch by Stéphane Wirtel

   - bpo-31453(28): Add TLSVersion constants and
     SSLContext.maximum_version / minimum_version attributes.  The new
     API wraps OpenSSL 1.1
     ‘https://web.archive.org/web/20180309043602/https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set_min_proto_version.html’
     feature.

   - bpo-24334(29): Internal implementation details of ssl module were
     cleaned up.  The SSLSocket has one less layer of indirection.
     Owner and session information are now handled by the SSLSocket and
     SSLObject constructor.  Channel binding implementation has been
     simplified.

   - bpo-31848(30): Fix the error handling in Aifc_read.initfp() when
     the SSND chunk is not found.  Patch by Zackery Spytz.

   - bpo-32585(31): Add Ttk spinbox widget to *note tkinter.ttk: e2.
     Patch by Alan D Moore.

   - bpo-32221(32): Various functions returning tuple containing IPv6
     addresses now omit ‘%scope’ part since the same information is
     already encoded in 'scopeid' tuple item.  Especially this speeds up
     ‘socket.recvfrom()’ when it receives multicast packet since useless
     resolving of network interface name is omitted.

   - bpo-30693(33): The TarFile class now recurses directories in a
     reproducible way.

   - bpo-30693(34): The ZipFile class now recurses directories in a
     reproducible way.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32960

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32713

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32951

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32929

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32947

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30622

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32922

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32859

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32556

   (10) https://bugs.python.org/issue?@action=redirect&bpo=25988

   (11) https://bugs.python.org/issue?@action=redirect&bpo=21060

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32852

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31333

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32841

   (15) https://bugs.python.org/issue?@action=redirect&bpo=32819

   (16) https://bugs.python.org/issue?@action=redirect&bpo=32394

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31787

   (18) https://bugs.python.org/issue?@action=redirect&bpo=30157

   (19) https://bugs.python.org/issue?@action=redirect&bpo=32792

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32775

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32622

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32777

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32647

   (24) https://bugs.python.org/issue?@action=redirect&bpo=32741

   (25) https://bugs.python.org/issue?@action=redirect&bpo=32691

   (26) https://bugs.python.org/issue?@action=redirect&bpo=32734

   (27) https://bugs.python.org/issue?@action=redirect&bpo=32727

   (28) https://bugs.python.org/issue?@action=redirect&bpo=31453

   (29) https://bugs.python.org/issue?@action=redirect&bpo=24334

   (30) https://bugs.python.org/issue?@action=redirect&bpo=31848

   (31) https://bugs.python.org/issue?@action=redirect&bpo=32585

   (32) https://bugs.python.org/issue?@action=redirect&bpo=32221

   (33) https://bugs.python.org/issue?@action=redirect&bpo=30693

   (34) https://bugs.python.org/issue?@action=redirect&bpo=30693


File: python.info,  Node: Documentation<50>,  Next: Tests<51>,  Prev: Library<56>,  Up: Python 3 7 0 beta 2

1.23.57.4 Documentation
.......................

   - bpo-28124(1): The ssl module function ssl.wrap_socket() has been
     de-emphasized and deprecated in favor of the more secure and
     efficient SSLContext.wrap_socket() method.

   - bpo-17232(2): Clarify docs for -O and -OO. Patch by Terry Reedy.

   - bpo-32436(3): Add documentation for the contextvars module (PEP
     567).

   - bpo-32800(4): Update link to w3c doc for xml default namespaces.

   - bpo-11015(5): Update *note test.support: cd. documentation.

   - bpo-8722(6): Document ‘__getattr__()’ behavior when property
     ‘get()’ method raises *note AttributeError: 326.

   - bpo-32614(7): Modify RE examples in documentation to use raw
     strings to prevent *note DeprecationWarning: 18a. and add text to
     REGEX HOWTO to highlight the deprecation.

   - bpo-31972(8): Improve docstrings for ‘pathlib.PurePath’ subclasses.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28124

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17232

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32436

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32800

   (5) https://bugs.python.org/issue?@action=redirect&bpo=11015

   (6) https://bugs.python.org/issue?@action=redirect&bpo=8722

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32614

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31972


File: python.info,  Node: Tests<51>,  Next: Build<54>,  Prev: Documentation<50>,  Up: Python 3 7 0 beta 2

1.23.57.5 Tests
...............

   - bpo-31809(1): Add tests to verify connection with secp ECDH curves.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31809


File: python.info,  Node: Build<54>,  Next: Windows<49>,  Prev: Tests<51>,  Up: Python 3 7 0 beta 2

1.23.57.6 Build
...............

   - bpo-32898(1): Fix the python debug build when using COUNT_ALLOCS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32898


File: python.info,  Node: Windows<49>,  Next: macOS<41>,  Prev: Build<54>,  Up: Python 3 7 0 beta 2

1.23.57.7 Windows
.................

   - bpo-32901(1): Update Tcl and Tk versions to 8.6.8

   - bpo-31966(2): Fixed WindowsConsoleIO.write() for writing empty
     data.

   - bpo-32409(3): Ensures activate.bat can handle Unicode contents.

   - bpo-32457(4): Improves handling of denormalized executable path
     when launching Python.

   - bpo-32370(5): Use the correct encoding for ipconfig output in the
     uuid module.  Patch by Segev Finer.

   - bpo-29248(6): Fix *note os.readlink(): 8ee. on Windows, which was
     mistakenly treating the ‘PrintNameOffset’ field of the reparse data
     buffer as a number of characters instead of bytes.  Patch by Craig
     Holmquist and SSE4.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32901

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31966

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32409

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32457

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32370

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29248


File: python.info,  Node: macOS<41>,  Next: IDLE<42>,  Prev: Windows<49>,  Up: Python 3 7 0 beta 2

1.23.57.8 macOS
...............

   - bpo-32901(1): Update macOS 10.9+ installer to Tcl/Tk 8.6.8.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32901


File: python.info,  Node: IDLE<42>,  Next: Tools/Demos<27>,  Prev: macOS<41>,  Up: Python 3 7 0 beta 2

1.23.57.9 IDLE
..............

   - bpo-32916(1): Change ‘str’ to ‘code’ in pyparse.

   - bpo-32905(2): Remove unused code in pyparse module.

   - bpo-32874(3): Add tests for pyparse.

   - bpo-32837(4): Using the system and place-dependent default encoding
     for open() is a bad idea for IDLE's system and location-independent
     files.

   - bpo-32826(5): Add "encoding=utf-8" to open() in IDLE's
     test_help_about.  GUI test test_file_buttons() only looks at
     initial ascii-only lines, but failed on systems where open()
     defaults to 'ascii' because readline() internally reads and decodes
     far enough ahead to encounter a non-ascii character in CREDITS.txt.

   - bpo-32765(6): Update configdialog General tab docstring to add new
     widgets to the widget list.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32916

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32905

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32874

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32837

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32826

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32765


File: python.info,  Node: Tools/Demos<27>,  Prev: IDLE<42>,  Up: Python 3 7 0 beta 2

1.23.57.10 Tools/Demos
......................

   - bpo-32222(1): Fix pygettext not extracting docstrings for functions
     with type annotated arguments.  Patch by Toby Harradine.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32222


File: python.info,  Node: Python 3 7 0 beta 1,  Next: Python 3 7 0 alpha 4,  Prev: Python 3 7 0 beta 2,  Up: 変更履歴

1.23.58 Python 3.7.0 beta 1
---------------------------

'Release date: 2018-01-30'

* Menu:

* Core and Builtins: Core and Builtins<57>.
* Library: Library<57>.
* Documentation: Documentation<51>.
* Tests: Tests<52>.
* Build: Build<55>.
* Windows: Windows<50>.
* macOS: macOS<42>.
* C API: C API<51>.


File: python.info,  Node: Core and Builtins<57>,  Next: Library<57>,  Up: Python 3 7 0 beta 1

1.23.58.1 Core and Builtins
...........................

   - bpo-32703(1): Fix coroutine's ResourceWarning when there's an
     active error set when it's being finalized.

   - bpo-32650(2): Pdb and other debuggers dependent on bdb.py will
     correctly step over (next command) native coroutines.  Patch by
     Pablo Galindo.

   - bpo-28685(3): Optimize list.sort() and sorted() by using type
     specialized comparisons when possible.

   - bpo-32685(4): Improve suggestion when the Python 2 form of print
     statement is either present on the same line as the header of a
     compound statement or else terminated by a semi-colon instead of a
     newline.  Patch by Nitish Chandra.

   - bpo-32697(5): Python now explicitly preserves the definition order
     of keyword-only parameters.  It's always preserved their order, but
     this behavior was never guaranteed before; this behavior is now
     guaranteed and tested.

   - bpo-32690(6): The locals() dictionary now displays in the lexical
     order that variables were defined.  Previously, the order was
     reversed.

   - bpo-32677(7): Add ‘.isascii()’ method to ‘str’, ‘bytes’ and
     ‘bytearray’.  It can be used to test that string contains only
     ASCII characters.

   - bpo-32670(8): Enforce PEP 479(9) for all code.  This means that
     manually raising a StopIteration exception from a generator is
     prohibited for all code, regardless of whether 'from __future__
     import generator_stop' was used or not.

   - bpo-32591(10): Added built-in support for tracking the origin of
     coroutine objects; see sys.set_coroutine_origin_tracking_depth and
     CoroutineType.cr_origin.  This replaces the asyncio debug mode's
     use of coroutine wrapping for native coroutine objects.

   - bpo-31368(11): Expose preadv and pwritev system calls in the os
     module.  Patch by Pablo Galindo

   - bpo-32544(12): ‘hasattr(obj, name)’ and ‘getattr(obj, name,
     default)’ are about 4 times faster than before when ‘name’ is not
     found and ‘obj’ doesn't override ‘__getattr__’ or
     ‘__getattribute__’.

   - bpo-26163(13): Improved frozenset() hash to create more distinct
     hash values when faced with datasets containing many similar
     values.

   - bpo-32550(14): Remove the STORE_ANNOTATION bytecode.

   - bpo-20104(15): Expose posix_spawn as a low level API in the os
     module.  (removed before 3.7.0rc1)

   - bpo-24340(16): Fixed estimation of the code stack size.

   - bpo-32436(17): Implement PEP 567(18) Context Variables.

   - bpo-18533(19): ‘repr()’ on a dict containing its own ‘values()’ or
     ‘items()’ no longer raises ‘RecursionError’; OrderedDict similarly.
     Instead, use ‘...’, as for other recursive structures.  Patch by
     Ben North.

   - bpo-20891(20): Py_Initialize() now creates the GIL. The GIL is no
     longer created "on demand" to fix a race condition when
     PyGILState_Ensure() is called in a non-Python thread.

   - bpo-32028(21): Leading whitespace is now correctly ignored when
     generating suggestions for converting Py2 print statements to Py3
     builtin print function calls.  Patch by Sanyam Khurana.

   - bpo-31179(22): Make dict.copy() up to 5.5 times faster.

   - bpo-31113(23): Get rid of recursion in the compiler for normal
     control flow.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32703

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32650

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28685

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32685

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32697

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32690

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32677

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32670

   (9) https://peps.python.org/pep-0479/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32591

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31368

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32544

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26163

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32550

   (15) https://bugs.python.org/issue?@action=redirect&bpo=20104

   (16) https://bugs.python.org/issue?@action=redirect&bpo=24340

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32436

   (18) https://peps.python.org/pep-0567/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=18533

   (20) https://bugs.python.org/issue?@action=redirect&bpo=20891

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32028

   (22) https://bugs.python.org/issue?@action=redirect&bpo=31179

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31113


File: python.info,  Node: Library<57>,  Next: Documentation<51>,  Prev: Core and Builtins<57>,  Up: Python 3 7 0 beta 1

1.23.58.2 Library
.................

   - bpo-25988(1): Deprecate exposing the contents of collections.abc in
     the regular collections module.

   - bpo-31429(2): The default cipher suite selection of the ssl module
     now uses a blacklist approach rather than a hard-coded whitelist.
     Python no longer re-enables ciphers that have been blocked by
     OpenSSL security update.  Default cipher suite selection can be
     configured on compile time.

   - bpo-30306(3): contextlib.contextmanager now releases the arguments
     passed to the underlying generator as soon as the context manager
     is entered.  Previously it would keep them alive for as long as the
     context manager was alive, even when not being used as a function
     decorator.  Patch by Martin Teichmann.

   - bpo-21417(4): Added support for setting the compression level for
     zipfile.ZipFile.

   - bpo-32251(5): Implement asyncio.BufferedProtocol (provisional API).

   - bpo-32513(6): In dataclasses, allow easier overriding of dunder
     methods without specifying decorator parameters.

   - bpo-32660(7): *note termios: ca. makes available ‘FIONREAD’,
     ‘FIONCLEX’, ‘FIOCLEX’, ‘FIOASYNC’ and ‘FIONBIO’ also under
     Solaris/derivatives.

   - bpo-27931(8): Fix email address header parsing error when the
     username is an empty quoted string.  Patch by Xiang Zhang.

   - bpo-32659(9): Under Solaris and derivatives, *note os.stat_result:
     1466. provides a st_fstype attribute.

   - bpo-32662(10): Implement Server.start_serving(),
     Server.serve_forever(), and Server.is_serving() methods.  Add
     'start_serving' keyword parameter to loop.create_server() and
     loop.create_unix_server().

   - bpo-32391(11): Implement *note asyncio.StreamWriter.wait_closed():
     ada. and *note asyncio.StreamWriter.is_closing(): adb. methods

   - bpo-32643(12): Make Task._step, Task._wakeup and
     Future._schedule_callbacks methods private.

   - bpo-32630(13): Refactor decimal module to use contextvars to store
     decimal context.

   - bpo-32622(14): Add ‘asyncio.AbstractEventLoop.sendfile()’ method.

   - bpo-32304(15): distutils' upload command no longer corrupts tar
     files ending with a CR byte, and no longer tries to convert CR to
     CRLF in any of the upload text fields.

   - bpo-32502(16): uuid.uuid1 no longer raises an exception if a 64-bit
     hardware address is encountered.

   - bpo-32596(17): ‘concurrent.futures’ imports ‘ThreadPoolExecutor’
     and ‘ProcessPoolExecutor’ lazily (using PEP 562(18)).  It makes
     ‘import asyncio’ about 15% faster because asyncio uses only
     ‘ThreadPoolExecutor’ by default.

   - bpo-31801(19): Add ‘_ignore_’ to ‘Enum’ so temporary variables can
     be used during class construction without being turned into
     members.

   - bpo-32576(20): Use queue.SimpleQueue() in places where it can be
     invoked from a weakref callback.

   - bpo-32574(21): Fix memory leak in asyncio.Queue, when the queue has
     limited size and it is full, the cancelation of queue.put() can
     cause a memory leak.  Patch by: José Melero.

   - bpo-32521(22): The nis module is now compatible with new libnsl and
     headers location.

   - bpo-32467(23): collections.abc.ValuesView now inherits from
     collections.abc.Collection.

   - bpo-32473(24): Improve ABCMeta._dump_registry() output readability

   - bpo-32102(25): New argument ‘capture_output’ for subprocess.run

   - bpo-32521(26): glibc has removed Sun RPC. Use replacement libtirpc
     headers and library in nis module.

   - bpo-32493(27): UUID module fixes build for FreeBSD/OpenBSD

   - bpo-32503(28): Pickling with protocol 4 no longer creates too small
     frames.

   - bpo-29237(29): Create enum for pstats sorting options

   - bpo-32454(30): Add close(fd) function to the socket module.

   - bpo-25942(31): The subprocess module is now more graceful when
     handling a Ctrl-C KeyboardInterrupt during subprocess.call,
     subprocess.run, or a Popen context manager.  It now waits a short
     amount of time for the child (presumed to have also gotten the
     SIGINT) to exit, before continuing the KeyboardInterrupt exception
     handling.  This still includes a SIGKILL in the call() and run()
     APIs, but at least the child had a chance first.

   - bpo-32433(32): The hmac module now has hmac.digest(), which
     provides an optimized HMAC digest.

   - bpo-28134(33): Sockets now auto-detect family, type and protocol
     from file descriptor by default.

   - bpo-32404(34): Fix bug where *note
     datetime.datetime.fromtimestamp(): 4ba. did not call __new__ in
     *note datetime.datetime: 1ae. subclasses.

   - bpo-32403(35): Improved speed of *note datetime.date: 1af. and
     *note datetime.datetime: 1ae. alternate constructors.

   - bpo-32228(36): Ensure that ‘truncate()’ preserves the file position
     (as reported by ‘tell()’) after writes longer than the buffer size.

   - bpo-32410(37): Implement ‘loop.sock_sendfile’ for asyncio event
     loop.

   - bpo-22908(38): Added seek and tell to the ZipExtFile class.  This
     only works if the file object used to open the zipfile is seekable.

   - bpo-32373(39): Add socket.getblocking() method.

   - bpo-32248(40): Add *note importlib.resources: 6f. and *note
     importlib.abc.ResourceReader: acb. as the unified API for reading
     resources contained within packages.  Loaders wishing to support
     resource reading must implement the ‘get_resource_reader()’ method.
     File-based and zipimport-based loaders both implement these APIs.
     *note importlib.abc.ResourceLoader: bb5. is deprecated in favor of
     these new APIs.

   - bpo-32320(41): collections.namedtuple() now supports default
     values.

   - bpo-29302(42): Add contextlib.AsyncExitStack.  Patch by Alexander
     Mohr and Ilya Kulakov.

   - bpo-31961(43): 'Removed in Python 3.7.0b2.'  The 'args' argument of
     subprocess.Popen can now be a *note path-like object: 280.  If
     'args' is given as a sequence, it's first element can now be a
     *note path-like object: 280. as well.

   - bpo-31900(44): The *note locale.localeconv(): bcc. function now
     sets temporarily the ‘LC_CTYPE’ locale to the ‘LC_NUMERIC’ locale
     to decode ‘decimal_point’ and ‘thousands_sep’ byte strings if they
     are non-ASCII or longer than 1 byte, and the ‘LC_NUMERIC’ locale is
     different than the ‘LC_CTYPE’ locale.  This temporary change
     affects other threads.  Same change for the *note str.format():
     5ed. method when formatting a number (*note int: 238, *note float:
     2ce, *note float: 2ce. and subclasses) with the ‘n’ type (ex:
     ‘'{:n}'.format(1234)’).

   - bpo-31853(45): Use super().method instead of socket.method in
     SSLSocket.  They were there most likely for legacy reasons.

   - bpo-31399(46): The ssl module now uses OpenSSL's
     X509_VERIFY_PARAM_set1_host() and X509_VERIFY_PARAM_set1_ip() API
     to verify hostname and IP addresses.  Subject common name fallback
     can be disabled with SSLContext.hostname_checks_common_name.

   - bpo-14976(47): Add a queue.SimpleQueue class, an unbounded FIFO
     queue with a reentrant C implementation of put().

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25988

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31429

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30306

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21417

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32251

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32513

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32660

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27931

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32659

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32662

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32391

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32643

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32630

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32622

   (15) https://bugs.python.org/issue?@action=redirect&bpo=32304

   (16) https://bugs.python.org/issue?@action=redirect&bpo=32502

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32596

   (18) https://peps.python.org/pep-0562/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31801

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32576

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32574

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32521

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32467

   (24) https://bugs.python.org/issue?@action=redirect&bpo=32473

   (25) https://bugs.python.org/issue?@action=redirect&bpo=32102

   (26) https://bugs.python.org/issue?@action=redirect&bpo=32521

   (27) https://bugs.python.org/issue?@action=redirect&bpo=32493

   (28) https://bugs.python.org/issue?@action=redirect&bpo=32503

   (29) https://bugs.python.org/issue?@action=redirect&bpo=29237

   (30) https://bugs.python.org/issue?@action=redirect&bpo=32454

   (31) https://bugs.python.org/issue?@action=redirect&bpo=25942

   (32) https://bugs.python.org/issue?@action=redirect&bpo=32433

   (33) https://bugs.python.org/issue?@action=redirect&bpo=28134

   (34) https://bugs.python.org/issue?@action=redirect&bpo=32404

   (35) https://bugs.python.org/issue?@action=redirect&bpo=32403

   (36) https://bugs.python.org/issue?@action=redirect&bpo=32228

   (37) https://bugs.python.org/issue?@action=redirect&bpo=32410

   (38) https://bugs.python.org/issue?@action=redirect&bpo=22908

   (39) https://bugs.python.org/issue?@action=redirect&bpo=32373

   (40) https://bugs.python.org/issue?@action=redirect&bpo=32248

   (41) https://bugs.python.org/issue?@action=redirect&bpo=32320

   (42) https://bugs.python.org/issue?@action=redirect&bpo=29302

   (43) https://bugs.python.org/issue?@action=redirect&bpo=31961

   (44) https://bugs.python.org/issue?@action=redirect&bpo=31900

   (45) https://bugs.python.org/issue?@action=redirect&bpo=31853

   (46) https://bugs.python.org/issue?@action=redirect&bpo=31399

   (47) https://bugs.python.org/issue?@action=redirect&bpo=14976


File: python.info,  Node: Documentation<51>,  Next: Tests<52>,  Prev: Library<57>,  Up: Python 3 7 0 beta 1

1.23.58.3 Documentation
.......................

   - bpo-32724(1): Add references to some commands in the documentation
     of Pdb.  Patch by Stéphane Wirtel

   - bpo-32649(2): Complete the C API documentation, profiling and
     tracing part with the newly added per-opcode events.

   - bpo-17799(3): Explain real behaviour of sys.settrace and
     sys.setprofile and their C-API counterparts regarding which type of
     events are received in each function.  Patch by Pablo Galindo
     Salgado.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32724

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32649

   (3) https://bugs.python.org/issue?@action=redirect&bpo=17799


File: python.info,  Node: Tests<52>,  Next: Build<55>,  Prev: Documentation<51>,  Up: Python 3 7 0 beta 1

1.23.58.4 Tests
...............

   - bpo-32721(1): Fix test_hashlib to not fail if the _md5 module is
     not built.

   - bpo-28414(2): Add test cases for IDNA 2003 and 2008 host names.
     IDNA 2003 internationalized host names are working since
     bpo-31399(3) has landed.  IDNA 2008 are still broken.

   - bpo-32604(4): Add a new "_xxsubinterpreters" extension module that
     exposes the existing subinterpreter C-API and a new
     cross-interpreter data sharing mechanism.  The module is primarily
     intended for more thorough testing of the existing subinterpreter
     support.  Note that the _xxsubinterpreters module has been removed
     in 3.7.0rc1.

   - bpo-32602(5): Add test certs and test for ECDSA cert and EC/RSA
     dual mode.

   - bpo-32549(6): On Travis CI, Python now Compiles and uses a local
     copy of OpenSSL 1.1.0g for testing.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32721

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28414

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31399

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32604

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32602

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32549


File: python.info,  Node: Build<55>,  Next: Windows<50>,  Prev: Tests<52>,  Up: Python 3 7 0 beta 1

1.23.58.5 Build
...............

   - bpo-32635(1): Fix segfault of the crypt module when libxcrypt is
     provided instead of libcrypt at the system.

   - bpo-32598(2): Use autoconf to detect OpenSSL libs, headers and
     supported features.  The ax_check_openssl M4 macro uses pkg-config
     to locate OpenSSL and falls back to manual search.

   - bpo-32593(3): Drop support of FreeBSD 9 and older.

   - bpo-29708(4): If the ‘SOURCE_DATE_EPOCH’ environment variable is
     set, *note py_compile: a1. will always create hash-based ‘.pyc’
     files.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32635

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32598

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32593

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29708


File: python.info,  Node: Windows<50>,  Next: macOS<42>,  Prev: Build<55>,  Up: Python 3 7 0 beta 1

1.23.58.6 Windows
.................

   - bpo-32588(1): Create standalone _distutils_findvs module and add
     missing _queue module to installer.

   - bpo-29911(2): Ensure separate Modify and Uninstall buttons are
     displayed.

   - bpo-32507(3): Use app-local UCRT install rather than the proper
     update for old versions of Windows.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32588

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29911

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32507


File: python.info,  Node: macOS<42>,  Next: C API<51>,  Prev: Windows<50>,  Up: Python 3 7 0 beta 1

1.23.58.7 macOS
...............

   - bpo-32726(1): Provide an additional, more modern macOS installer
     variant that supports macOS 10.9+ systems in 64-bit mode only.
     Upgrade the supplied third-party libraries to OpenSSL 1.1.0g and to
     SQLite 3.22.0.  The 10.9+ installer now links with and supplies its
     own copy of Tcl/Tk 8.6.

   - bpo-28440(2): No longer add /Library/Python/3.x/site-packages to
     sys.path for macOS framework builds to avoid future conflicts.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32726

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28440


File: python.info,  Node: C API<51>,  Prev: macOS<42>,  Up: Python 3 7 0 beta 1

1.23.58.8 C API
...............

   - bpo-32681(1): Fix uninitialized variable 'res' in the C
     implementation of os.dup2.  Patch by Stéphane Wirtel

   - bpo-10381(2): Add C API access to the ‘datetime.timezone’
     constructor and ‘datetime.timzone.UTC’ singleton.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32681

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10381


File: python.info,  Node: Python 3 7 0 alpha 4,  Next: Python 3 7 0 alpha 3,  Prev: Python 3 7 0 beta 1,  Up: 変更履歴

1.23.59 Python 3.7.0 alpha 4
----------------------------

'Release date: 2018-01-08'

* Menu:

* Core and Builtins: Core and Builtins<58>.
* Library: Library<58>.
* Documentation: Documentation<52>.
* Tests: Tests<53>.
* Windows: Windows<51>.
* Tools/Demos: Tools/Demos<28>.
* C API: C API<52>.


File: python.info,  Node: Core and Builtins<58>,  Next: Library<58>,  Up: Python 3 7 0 alpha 4

1.23.59.1 Core and Builtins
...........................

   - bpo-31975(1): The default warning filter list now starts with a
     "default::DeprecationWarning:__main__" entry, so deprecation
     warnings are once again shown by default in single-file scripts and
     at the interactive prompt.

   - bpo-32226(2): ‘__class_getitem__’ is now an automatic class method.

   - bpo-32399(3): Add AIX uuid library support for RFC4122 using
     uuid_create() in libc.a

   - bpo-32390(4): Fix the compilation failure on AIX after the f_fsid
     field has been added to the object returned by os.statvfs()
     (bpo-32143(5)).  Original patch by Michael Felt.

   - bpo-32379(6): Make MRO computation faster when a class inherits
     from a single base.

   - bpo-32259(7): The error message of a TypeError raised when unpack
     non-iterable is now more specific.

   - bpo-27169(8): The ‘__debug__’ constant is now optimized out at
     compile time.  This fixes also bpo-22091(9).

   - bpo-32329(10): The *note -R: 1a02. option now turns on hash
     randomization when the *note PYTHONHASHSEED: 1052. environment
     variable is set to ‘0’.  Previously, the option was ignored.
     Moreover, ‘sys.flags.hash_randomization’ is now properly set to 0
     when hash randomization is turned off by ‘PYTHONHASHSEED=0’.

   - bpo-30416(11): The optimizer is now protected from spending much
     time doing complex calculations and consuming much memory for
     creating large constants in constant folding.  Increased limits for
     constants that can be produced in constant folding.

   - bpo-32282(12): Fix an unnecessary ifdef in the include of
     VersionHelpers.h in socketmodule on Windows.

   - bpo-30579(13): Implement TracebackType.__new__ to allow
     Python-level creation of traceback objects, and make
     TracebackType.tb_next mutable.

   - bpo-32260(14): Don't byte swap the input keys to the SipHash
     algorithm on big-endian platforms.  This should ensure siphash
     gives consistent results across platforms.

   - bpo-31506(15): Improve the error message logic for object.__new__
     and object.__init__.  Patch by Sanyam Khurana.

   - bpo-20361(16): ‘-b’ and ‘-bb’ now inject ‘'default::BytesWarning'’
     and ‘error::BytesWarning’ entries into ‘sys.warnoptions’, ensuring
     that they take precedence over any other warning filters configured
     via the ‘-W’ option or the ‘PYTHONWARNINGS’ environment variable.

   - bpo-32230(17): ‘-X dev’ now injects a ‘'default'’ entry into
     sys.warnoptions, ensuring that it behaves identically to actually
     passing ‘-Wdefault’ at the command line.

   - bpo-29240(18): Add a new UTF-8 mode: implementation of the PEP
     540(19).

   - bpo-32226(20): PEP 560(21): Add support for ‘__mro_entries__’ and
     ‘__class_getitem__’.  Implemented by Ivan Levkivskyi.

   - bpo-32225(22): PEP 562(23): Add support for module ‘__getattr__’
     and ‘__dir__’.  Implemented by Ivan Levkivskyi.

   - bpo-31901(24): The ‘atexit’ module now has its callback stored per
     interpreter.

   - bpo-31650(25): Implement PEP 552(26) (Deterministic pycs).  Python
     now supports invalidating bytecode cache files bashed on a source
     content hash rather than source last-modified time.

   - bpo-29469(27): Move constant folding from bytecode layer to AST
     layer.  Original patch by Eugene Toder.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31975

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32226

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32399

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32390

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32143

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32379

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32259

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27169

   (9) https://bugs.python.org/issue?@action=redirect&bpo=22091

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32329

   (11) https://bugs.python.org/issue?@action=redirect&bpo=30416

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32282

   (13) https://bugs.python.org/issue?@action=redirect&bpo=30579

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32260

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31506

   (16) https://bugs.python.org/issue?@action=redirect&bpo=20361

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32230

   (18) https://bugs.python.org/issue?@action=redirect&bpo=29240

   (19) https://peps.python.org/pep-0540/

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32226

   (21) https://peps.python.org/pep-0560/

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32225

   (23) https://peps.python.org/pep-0562/

   (24) https://bugs.python.org/issue?@action=redirect&bpo=31901

   (25) https://bugs.python.org/issue?@action=redirect&bpo=31650

   (26) https://peps.python.org/pep-0552/

   (27) https://bugs.python.org/issue?@action=redirect&bpo=29469


File: python.info,  Node: Library<58>,  Next: Documentation<52>,  Prev: Core and Builtins<58>,  Up: Python 3 7 0 alpha 4

1.23.59.2 Library
.................

   - bpo-32506(1): Now that dict is defined as keeping insertion order,
     drop OrderedDict and just use plain dict.

   - bpo-32279(2): Add params to dataclasses.make_dataclasses(): init,
     repr, eq, order, hash, and frozen.  Pass them through to
     dataclass().

   - bpo-32278(3): Make type information optional on
     dataclasses.make_dataclass().  If omitted, the string 'typing.Any'
     is used.

   - bpo-32499(4): Add dataclasses.is_dataclass(obj), which returns True
     if obj is a dataclass or an instance of one.

   - bpo-32468(5): Improve frame repr() to mention filename, code name
     and current line number.

   - bpo-23749(6): asyncio: Implement loop.start_tls()

   - bpo-32441(7): Return the new file descriptor (i.e., the second
     argument) from ‘os.dup2’.  Previously, ‘None’ was always returned.

   - bpo-32422(8): ‘functools.lru_cache’ uses less memory (3 words for
     each cached key) and takes about 1/3 time for cyclic GC.

   - bpo-31721(9): Prevent Python crash from happening when
     Future._log_traceback is set to True manually.  Now it can only be
     set to False, or a ValueError is raised.

   - bpo-32415(10): asyncio: Add Task.get_loop() and Future.get_loop()

   - bpo-26133(11): Don't unsubscribe signals in asyncio UNIX event loop
     on interpreter shutdown.

   - bpo-32363(12): Make asyncio.Task.set_exception() and set_result()
     raise NotImplementedError.  Task._step() and Future.__await__()
     raise proper exceptions when they are in an invalid state, instead
     of raising an AssertionError.

   - bpo-32357(13): Optimize asyncio.iscoroutine() and
     loop.create_task() for non-native coroutines (e.g.  async/await
     compiled with Cython).  'loop.create_task(python_coroutine)' used
     to be 20% faster than 'loop.create_task(cython_coroutine)'.  Now,
     the latter is as fast.

   - bpo-32356(14): asyncio.transport.resume_reading() and
     pause_reading() are now idempotent.  New transport.is_reading()
     method is added.

   - bpo-32355(15): Optimize asyncio.gather(); now up to 15% faster.

   - bpo-32351(16): Use fastpath in asyncio.sleep if delay<0 (2x boost)

   - bpo-32348(17): Optimize asyncio.Future schedule/add/remove
     callback.  The optimization shows 3-6% performance improvements of
     async/await code.

   - bpo-32331(18): Fix socket.settimeout() and socket.setblocking() to
     keep socket.type as is.  Fix socket.socket() constructor to reset
     any bit flags applied to socket's type.  This change only affects
     OSes that have SOCK_NONBLOCK and/or SOCK_CLOEXEC.

   - bpo-32248(19): Add *note importlib.abc.ResourceReader: acb. as an
     ABC for loaders to provide a unified API for reading resources
     contained within packages.  Also add *note importlib.resources: 6f.
     as the port of ‘importlib_resources’.

   - bpo-32311(20): Implement asyncio.create_task(coro) shortcut

   - bpo-32327(21): Convert asyncio functions that were documented as
     coroutines to coroutines.  Affected functions: loop.sock_sendall,
     loop.sock_recv, loop.sock_accept, loop.getaddrinfo,
     loop.getnameinfo.

   - bpo-32323(22): *note urllib.parse.urlsplit(): d0d. does not convert
     zone-id (scope) to lower case for scoped IPv6 addresses in
     hostnames now.

   - bpo-32302(23): Fix bdist_wininst of distutils for CRT v142: it
     binary compatible with CRT v140.

   - bpo-29711(24): Fix ‘stop_serving’ in asyncio proactor loop kill all
     listening servers

   - bpo-32308(25): *note re.sub(): 283. now replaces empty matches
     adjacent to a previous non-empty match.

   - bpo-29970(26): Abort asyncio SSLProtocol connection if handshake
     not complete within 10 seconds.

   - bpo-32314(27): Implement asyncio.run().

   - bpo-17852(28): Revert incorrect fix based on misunderstanding of
     _Py_PyAtExit() semantics.

   - bpo-32296(29): Implement asyncio._get_running_loop() and
     get_event_loop() in C. This makes them 4x faster.

   - bpo-32250(30): Implement ‘asyncio.current_task()’ and
     ‘asyncio.all_tasks()’.  Add helpers intended to be used by
     alternative task implementations: ‘asyncio._register_task’,
     ‘asyncio._enter_task’, ‘asyncio._leave_task’ and
     ‘asyncio._unregister_task’.  Deprecate
     ‘asyncio.Task.current_task()’ and ‘asyncio.Task.all_tasks()’.

   - bpo-32255(31): A single empty field is now always quoted when
     written into a CSV file.  This allows to distinguish an empty row
     from a row consisting of a single empty field.  Patch by Licht
     Takeuchi.

   - bpo-32277(32): Raise ‘NotImplementedError’ instead of ‘SystemError’
     on platforms where ‘chmod(..., follow_symlinks=False)’ is not
     supported.  Patch by Anthony Sottile.

   - bpo-30050(33): New argument warn_on_full_buffer to
     signal.set_wakeup_fd lets you control whether Python prints a
     warning on stderr when the wakeup fd buffer overflows.

   - bpo-29137(34): The ‘fpectl’ library has been removed.  It was never
     enabled by default, never worked correctly on x86-64, and it
     changed the Python ABI in ways that caused unexpected breakage of C
     extensions.

   - bpo-32273(35): Move asyncio.test_utils to test.test_asyncio.

   - bpo-32272(36): Remove asyncio.async() function.

   - bpo-32269(37): Add asyncio.get_running_loop() function.

   - bpo-32265(38): All class and static methods of builtin types now
     are correctly classified by inspect.classify_class_attrs() and
     grouped in pydoc ouput.  Added types.ClassMethodDescriptorType for
     unbound class methods of builtin types.

   - bpo-32253(39): Deprecate ‘yield from lock’, ‘await lock’, ‘with
     (yield from lock)’ and ‘with await lock’ for asyncio
     synchronization primitives.

   - bpo-22589(40): Changed MIME type of .bmp from 'image/x-ms-bmp' to
     'image/bmp'

   - bpo-32193(41): Convert asyncio to use 'async/await' syntax.  Old
     styled ‘yield from’ is still supported too.

   - bpo-32206(42): Add support to run modules with pdb

   - bpo-32227(43): ‘functools.singledispatch’ now supports registering
     implementations using type annotations.

   - bpo-15873(44): Added new alternate constructors *note
     datetime.datetime.fromisoformat(): 5e2, *note
     datetime.time.fromisoformat(): 5e1. and *note
     datetime.date.fromisoformat(): 5e0. as the inverse operation of
     each classes's respective ‘isoformat’ methods.

   - bpo-32199(45): The getnode() ip getter now uses 'ip link' instead
     of 'ip link list'.

   - bpo-32143(46): os.statvfs() includes the f_fsid field from
     statvfs(2)

   - bpo-26439(47): Fix ctypes.util.find_library() for AIX by
     implementing ctypes._aix.find_library() Patch by: Michael Felt

   - bpo-31993(48): The pickler now uses less memory when serializing
     large bytes and str objects into a file.  Pickles created with
     protocol 4 will require less memory for unpickling large bytes and
     str objects.

   - bpo-27456(49): Ensure TCP_NODELAY is set on Linux.  Tests by Victor
     Stinner.

   - bpo-31778(50): ast.literal_eval() is now more strict.  Addition and
     subtraction of arbitrary numbers no longer allowed.

   - bpo-31802(51): Importing native path module (‘posixpath’, ‘ntpath’)
     now works even if the ‘os’ module still is not imported.

   - bpo-30241(52): Add contextlib.AbstractAsyncContextManager.  Patch
     by Jelle Zijlstra.

   - bpo-31699(53): Fix deadlocks in *note
     concurrent.futures.ProcessPoolExecutor: 8bc. when task arguments or
     results cause pickling or unpickling errors.  This should make sure
     that calls to the ‘ProcessPoolExecutor’ API always eventually
     return.

   - bpo-15216(54): ‘TextIOWrapper.reconfigure()’ supports changing
     'encoding', 'errors', and 'newline'.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32506

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32279

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32278

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32499

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32468

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23749

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32441

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32422

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31721

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32415

   (11) https://bugs.python.org/issue?@action=redirect&bpo=26133

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32363

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32357

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32356

   (15) https://bugs.python.org/issue?@action=redirect&bpo=32355

   (16) https://bugs.python.org/issue?@action=redirect&bpo=32351

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32348

   (18) https://bugs.python.org/issue?@action=redirect&bpo=32331

   (19) https://bugs.python.org/issue?@action=redirect&bpo=32248

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32311

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32327

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32323

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32302

   (24) https://bugs.python.org/issue?@action=redirect&bpo=29711

   (25) https://bugs.python.org/issue?@action=redirect&bpo=32308

   (26) https://bugs.python.org/issue?@action=redirect&bpo=29970

   (27) https://bugs.python.org/issue?@action=redirect&bpo=32314

   (28) https://bugs.python.org/issue?@action=redirect&bpo=17852

   (29) https://bugs.python.org/issue?@action=redirect&bpo=32296

   (30) https://bugs.python.org/issue?@action=redirect&bpo=32250

   (31) https://bugs.python.org/issue?@action=redirect&bpo=32255

   (32) https://bugs.python.org/issue?@action=redirect&bpo=32277

   (33) https://bugs.python.org/issue?@action=redirect&bpo=30050

   (34) https://bugs.python.org/issue?@action=redirect&bpo=29137

   (35) https://bugs.python.org/issue?@action=redirect&bpo=32273

   (36) https://bugs.python.org/issue?@action=redirect&bpo=32272

   (37) https://bugs.python.org/issue?@action=redirect&bpo=32269

   (38) https://bugs.python.org/issue?@action=redirect&bpo=32265

   (39) https://bugs.python.org/issue?@action=redirect&bpo=32253

   (40) https://bugs.python.org/issue?@action=redirect&bpo=22589

   (41) https://bugs.python.org/issue?@action=redirect&bpo=32193

   (42) https://bugs.python.org/issue?@action=redirect&bpo=32206

   (43) https://bugs.python.org/issue?@action=redirect&bpo=32227

   (44) https://bugs.python.org/issue?@action=redirect&bpo=15873

   (45) https://bugs.python.org/issue?@action=redirect&bpo=32199

   (46) https://bugs.python.org/issue?@action=redirect&bpo=32143

   (47) https://bugs.python.org/issue?@action=redirect&bpo=26439

   (48) https://bugs.python.org/issue?@action=redirect&bpo=31993

   (49) https://bugs.python.org/issue?@action=redirect&bpo=27456

   (50) https://bugs.python.org/issue?@action=redirect&bpo=31778

   (51) https://bugs.python.org/issue?@action=redirect&bpo=31802

   (52) https://bugs.python.org/issue?@action=redirect&bpo=30241

   (53) https://bugs.python.org/issue?@action=redirect&bpo=31699

   (54) https://bugs.python.org/issue?@action=redirect&bpo=15216


File: python.info,  Node: Documentation<52>,  Next: Tests<53>,  Prev: Library<58>,  Up: Python 3 7 0 alpha 4

1.23.59.3 Documentation
.......................

   - bpo-32418(1): Add get_loop() method to Server and AbstractServer
     classes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32418


File: python.info,  Node: Tests<53>,  Next: Windows<51>,  Prev: Documentation<52>,  Up: Python 3 7 0 alpha 4

1.23.59.4 Tests
...............

   - bpo-32252(1): Fix faulthandler_suppress_crash_report() used to
     prevent core dump files when testing crashes.  getrlimit() returns
     zero on success.

   - bpo-32002(2): Adjust C locale coercion testing for the empty locale
     and POSIX locale cases to more readily adjust to platform dependent
     behaviour.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32252

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32002


File: python.info,  Node: Windows<51>,  Next: Tools/Demos<28>,  Prev: Tests<53>,  Up: Python 3 7 0 alpha 4

1.23.59.5 Windows
.................

   - bpo-19764(1): Implement support for
     ‘subprocess.Popen(close_fds=True)’ on Windows.  Patch by Segev
     Finer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19764


File: python.info,  Node: Tools/Demos<28>,  Next: C API<52>,  Prev: Windows<51>,  Up: Python 3 7 0 alpha 4

1.23.59.6 Tools/Demos
.....................

   - bpo-24960(1): 2to3 and lib2to3 can now read pickled grammar files
     using pkgutil.get_data() rather than probing the filesystem.  This
     lets 2to3 and lib2to3 work when run from a zipfile.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24960


File: python.info,  Node: C API<52>,  Prev: Tools/Demos<28>,  Up: Python 3 7 0 alpha 4

1.23.59.7 C API
...............

   - bpo-32030(1): Py_Initialize() doesn't reset the memory allocators
     to default if the ‘PYTHONMALLOC’ environment variable is not set.

   - bpo-29084(2): Undocumented C API for OrderedDict has been excluded
     from the limited C API. It was added by mistake and actually never
     worked in the limited C API.

   - bpo-32264(3): Moved the pygetopt.h header into internal/, since it
     has no public APIs.

   - bpo-32241(4): ‘Py_SetProgramName()’ and ‘Py_SetPythonHome()’ now
     take the ‘const wchar *’ arguments instead of ‘wchar *’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32030

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29084

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32264

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32241


File: python.info,  Node: Python 3 7 0 alpha 3,  Next: Python 3 7 0 alpha 2,  Prev: Python 3 7 0 alpha 4,  Up: 変更履歴

1.23.60 Python 3.7.0 alpha 3
----------------------------

'Release date: 2017-12-05'

* Menu:

* Core and Builtins: Core and Builtins<59>.
* Library: Library<59>.
* Documentation: Documentation<53>.
* Tests: Tests<54>.
* Build: Build<56>.
* Windows: Windows<52>.
* macOS: macOS<43>.
* IDLE: IDLE<43>.
* Tools/Demos: Tools/Demos<29>.
* C API: C API<53>.


File: python.info,  Node: Core and Builtins<59>,  Next: Library<59>,  Up: Python 3 7 0 alpha 3

1.23.60.1 Core and Builtins
...........................

   - bpo-32176(1): co_flags.CO_NOFREE is now always set correctly by the
     code object constructor based on freevars and cellvars, rather than
     needing to be set correctly by the caller.  This ensures it will be
     cleared automatically when additional cell references are injected
     into a modified code object and function.

   - bpo-10544(2): Yield expressions are now deprecated in
     comprehensions and generator expressions.  They are still permitted
     in the definition of the outermost iterable, as that is evaluated
     directly in the enclosing scope.

   - bpo-32137(3): The repr of deeply nested dict now raises a
     RecursionError instead of crashing due to a stack overflow.

   - bpo-32096(4): Revert memory allocator changes in the C API: move
     structures back from _PyRuntime to Objects/obmalloc.c.  The memory
     allocators are once again initialized statically, and so
     PyMem_RawMalloc() and Py_DecodeLocale() can be called before
     _PyRuntime_Initialize().

   - bpo-32043(5): Add a new "developer mode": new "-X dev" command line
     option to enable debug checks at runtime.

   - bpo-32023(6): SyntaxError is now correctly raised when a generator
     expression without parenthesis is used instead of an inheritance
     list in a class definition.  The duplication of the parentheses can
     be omitted only on calls.

   - bpo-32012(7): SyntaxError is now correctly raised when a generator
     expression without parenthesis is passed as an argument, but
     followed by a trailing comma.  A generator expression always needs
     to be directly inside a set of parentheses and cannot have a comma
     on either side.

   - bpo-28180(8): A new internal ‘_Py_SetLocaleFromEnv(category)’
     helper function has been added in order to improve the consistency
     of behaviour across different ‘libc’ implementations (e.g.  Android
     doesn't support setting the locale from the environment by
     default).

   - bpo-31949(9): Fixed several issues in printing tracebacks
     (PyTraceBack_Print()).  Setting sys.tracebacklimit to 0 or less now
     suppresses printing tracebacks.  Setting sys.tracebacklimit to None
     now causes using the default limit.  Setting sys.tracebacklimit to
     an integer larger than LONG_MAX now means using the limit LONG_MAX
     rather than the default limit.  Fixed integer overflows in the case
     of more than ‘2**31’ traceback items on Windows.  Fixed output
     errors handling.

   - bpo-30696(10): Fix the interactive interpreter looping endlessly
     when no memory.

   - bpo-20047(11): Bytearray methods partition() and rpartition() now
     accept only bytes-like objects as separator, as documented.  In
     particular they now raise TypeError rather of returning a bogus
     result when an integer is passed as a separator.

   - bpo-21720(12): BytesWarning no longer emitted when the 'fromlist'
     argument of ‘__import__()’ or the ‘__all__’ attribute of the module
     contain bytes instances.

   - bpo-31845(13): Environment variables are once more read correctly
     at interpreter startup.

   - bpo-28936(14): Ensure that lexically first syntax error involving a
     parameter and ‘global’ or ‘nonlocal’ is detected first at a given
     scope.  Patch by Ivan Levkivskyi.

   - bpo-31825(15): Fixed OverflowError in the 'unicode-escape' codec
     and in codecs.escape_decode() when decode an escaped non-ascii
     byte.

   - bpo-31618(16): The per-frame tracing logic added in 3.7a1 has been
     altered so that ‘frame->f_lineno’ is updated before either ‘"line"’
     or ‘"opcode"’ events are emitted.  Previously, opcode events were
     emitted first, and therefore would occasionally see stale line
     numbers on the frame.  The behavior of this feature has changed
     slightly as a result: when both ‘f_trace_lines’ and
     ‘f_trace_opcodes’ are enabled, line events now occur first.

   - bpo-28603(17): Print the full context/cause chain of exceptions on
     interpreter exit, even if an exception in the chain is unhashable
     or compares equal to later ones.  Patch by Zane Bitter.

   - bpo-31786(18): Fix timeout rounding in the select module to round
     correctly negative timeouts between -1.0 and 0.0.  The functions
     now block waiting for events as expected.  Previously, the call was
     incorrectly non-blocking.  Patch by Pablo Galindo.

   - bpo-31781(19): Prevent crashes when calling methods of an
     uninitialized ‘zipimport.zipimporter’ object.  Patch by Oren
     Milman.

   - bpo-30399(20): Standard repr() of BaseException with a single
     argument no longer contains redundant trailing comma.

   - bpo-31626(21): Fixed a bug in debug memory allocator.  There was a
     write to freed memory after shrinking a memory block.

   - bpo-30817(22): ‘PyErr_PrintEx()’ clears now the ignored exception
     that may be raised by ‘_PySys_SetObjectId()’, for example when no
     memory.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32176

   (2) https://bugs.python.org/issue?@action=redirect&bpo=10544

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32137

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32096

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32043

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32023

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32012

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28180

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31949

   (10) https://bugs.python.org/issue?@action=redirect&bpo=30696

   (11) https://bugs.python.org/issue?@action=redirect&bpo=20047

   (12) https://bugs.python.org/issue?@action=redirect&bpo=21720

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31845

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28936

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31825

   (16) https://bugs.python.org/issue?@action=redirect&bpo=31618

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28603

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31786

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31781

   (20) https://bugs.python.org/issue?@action=redirect&bpo=30399

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31626

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30817


File: python.info,  Node: Library<59>,  Next: Documentation<53>,  Prev: Core and Builtins<59>,  Up: Python 3 7 0 alpha 3

1.23.60.2 Library
.................

   - bpo-28556(1): Two minor fixes for ‘typing’ module: allow shallow
     copying instances of generic classes, improve interaction of
     ‘__init_subclass__’ with generics.  Original PRs by Ivan
     Levkivskyi.

   - bpo-32214(2): PEP 557, Data Classes.  Provides a decorator which
     adds boilerplate methods to classes which use type annotations so
     specify fields.

   - bpo-27240(3): The header folding algorithm for the new email
     policies has been rewritten, which also fixes bpo-30788(4),
     bpo-31831(5), and bpo-32182(6).  In particular, RFC2231 folding is
     now done correctly.

   - bpo-32186(7): io.FileIO.readall() and io.FileIO.read() now release
     the GIL when getting the file size.  Fixed hang of all threads with
     inaccessible NFS server.  Patch by Nir Soffer.

   - bpo-32101(8): Add *note sys.flags.dev_mode: 1a0c. flag

   - bpo-32154(9): The ‘asyncio.windows_utils.socketpair()’ function has
     been removed: use directly *note socket.socketpair(): bc3. which is
     available on all platforms since Python 3.5 (before, it wasn't
     available on Windows).  ‘asyncio.windows_utils.socketpair()’ was
     just an alias to ‘socket.socketpair’ on Python 3.5 and newer.

   - bpo-32089(10): warnings: In development (-X dev) and debug mode
     (pydebug build), use the "default" action for ResourceWarning,
     rather than the "always" action, in the default warnings filters.

   - bpo-32107(11): ‘uuid.getnode()’ now preferentially returns
     universally administered MAC addresses if available, over locally
     administered MAC addresses.  This makes a better guarantee for
     global uniqueness of UUIDs returned from ‘uuid.uuid1()’.  If only
     locally administered MAC addresses are available, the first such
     one found is returned.

   - bpo-23033(12): Wildcard is now supported in hostname when it is one
     and only character in the left most segment of hostname in second
     argument of ‘ssl.match_hostname()’.  Patch by Mandeep Singh.

   - bpo-12239(13): Make ‘msilib.SummaryInformation.GetProperty()’
     return ‘None’ when the value of property is ‘VT_EMPTY’.  Initial
     patch by Mark Mc Mahon.

   - bpo-28334(14): Use *note os.path.expanduser(): 9e2. to find the
     ‘~/.netrc’ file in *note netrc.netrc: 182c.  If it does not exist,
     *note FileNotFoundError: e8f. is raised.  Patch by Dimitri
     Merejkowsky.

   - bpo-32121(15): Made ‘tracemalloc.Traceback’ behave more like the
     traceback module, sorting the frames from oldest to most recent.
     ‘Traceback.format()’ now accepts negative 'limit', truncating the
     result to the ‘abs(limit)’ oldest frames.  To get the old
     behaviour, one can use the new 'most_recent_first' argument to
     ‘Traceback.format()’.  (Patch by Jesse Bakker.)

   - bpo-31325(16): Fix wrong usage of *note collections.namedtuple():
     1ac. in the *note RobotFileParser.parse(): 1a0d. method.  Initial
     patch by Robin Wellner.

   - bpo-12382(17): ‘msilib.OpenDatabase()’ now raises a better
     exception message when it couldn't open or create an MSI file.
     Initial patch by William Tisäter.

   - bpo-19610(18): ‘setup()’ now warns about invalid types for some
     fields.  The ‘distutils.dist.Distribution’ class now warns when
     ‘classifiers’, ‘keywords’ and ‘platforms’ fields are not specified
     as a list or a string.

   - bpo-32071(19): Added the ‘-k’ command-line option to ‘python -m
     unittest’ to run only tests that match the given pattern(s).

   - bpo-10049(20): Added 'nullcontext' no-op context manager to
     contextlib.  This provides a simpler and faster alternative to
     ExitStack() when handling optional context managers.

   - bpo-28684(21): The new test.support.skip_unless_bind_unix_socket()
     decorator is used here to skip asyncio tests that fail because the
     platform lacks a functional bind() function for unix domain sockets
     (as it is the case for non root users on the recent Android
     versions that run now SELinux in enforcing mode).

   - bpo-32110(22): ‘codecs.StreamReader.read(n)’ now returns not more
     than 'n' characters/bytes for non-negative 'n'.  This makes it
     compatible with ‘read()’ methods of other file-like objects.

   - bpo-27535(23): The warnings module doesn't leak memory anymore in
     the hidden warnings registry for the "ignore" action of warnings
     filters.  warn_explicit() function doesn't add the warning key to
     the registry anymore for the "ignore" action.

   - bpo-32088(24): warnings: When Python is build is debug mode
     (‘Py_DEBUG’), *note DeprecationWarning: 18a, *note
     PendingDeprecationWarning: 895. and *note ImportWarning: 4c7.
     warnings are now displayed by default.

   - bpo-1647489(25): Fixed searching regular expression patterns that
     could match an empty string.  Non-empty string can now be correctly
     found after matching an empty string.

   - bpo-25054(26): Added support of splitting on a pattern that could
     match an empty string.

   - bpo-32072(27): Fixed issues with binary plists: Fixed saving
     bytearrays.  Identical objects will be saved only once.  Equal
     references will be load as identical objects.  Added support for
     saving and loading recursive data structures.

   - bpo-32069(28): Drop legacy SSL transport from asyncio,
     ssl.MemoryBIO is always used anyway.

   - bpo-32066(29): asyncio: Support pathlib.Path in
     create_unix_connection; sock arg should be optional

   - bpo-32046(30): Updates 2to3 to convert from
     operator.isCallable(obj) to callable(obj).  Patch by Donghee Na.

   - bpo-32018(31): inspect.signature should follow PEP 8(32), if the
     parameter has an annotation and a default value.  Patch by Donghee
     Na.

   - bpo-32025(33): Add time.thread_time() and time.thread_time_ns()

   - bpo-32037(34): Integers that fit in a signed 32-bit integer will be
     now pickled with protocol 0 using the INT opcode.  This will
     decrease the size of a pickle, speed up pickling and unpickling,
     and make these integers be unpickled as int instances in Python 2.

   - bpo-32034(35): Make asyncio.IncompleteReadError and
     LimitOverrunError pickleable.

   - bpo-32015(36): Fixed the looping of asyncio in the case of
     reconnection the socket during waiting async read/write from/to the
     socket.

   - bpo-32011(37): Restored support of loading marshal files with the
     TYPE_INT64 code.  These files can be produced in Python 2.7.

   - bpo-28369(38): Enhance add_reader/writer check that socket is not
     used by some transport.  Before, only cases when add_reader/writer
     were called with an int FD were supported.  Now the check is
     implemented correctly for all file-like objects.

   - bpo-31976(39): Fix race condition when flushing a file is slow,
     which can cause a segfault if closing the file from another thread.

   - bpo-31985(40): Formally deprecated aifc.openfp, sunau.openfp, and
     wave.openfp.  Since change 7bc817d5ba917528e8bd07ec461c635291e7b06a
     in 1993, openfp in each of the three modules had been pointing to
     that module's open function as a matter of backwards compatibility,
     though it had been both untested and undocumented.

   - bpo-21862(41): cProfile command line now accepts ‘-m module_name’
     as an alternative to script path.  Patch by Sanyam Khurana.

   - bpo-31970(42): Reduce performance overhead of asyncio debug mode.

   - bpo-31843(43): 'database' argument of sqlite3.connect() now accepts
     a *note path-like object: 280, instead of just a string.

   - bpo-31945(44): Add Configurable 'blocksize' to ‘HTTPConnection’ and
     ‘HTTPSConnection’ for improved upload throughput.  Patch by Nir
     Soffer.

   - bpo-31943(45): Add a ‘cancelled()’ method to *note asyncio.Handle:
     1a0e.  Patch by Marat Sharafutdinov.

   - bpo-9678(46): Fixed determining the MAC address in the uuid module:
     Using ifconfig on NetBSD and OpenBSD. Using arp on Linux, FreeBSD,
     NetBSD and OpenBSD. Based on patch by Takayuki Shimizukawa.

   - bpo-30057(47): Fix potential missed signal in signal.signal().

   - bpo-31933(48): Fix Blake2 params leaf_size and node_offset on big
     endian platforms.  Patch by Jack O'Connor.

   - bpo-21423(49): Add an initializer argument to
     {Process,Thread}PoolExecutor

   - bpo-31927(50): Fixed compilation of the socket module on NetBSD 8.
     Fixed assertion failure or reading arbitrary data when parse a
     AF_BLUETOOTH address on NetBSD and DragonFly BSD.

   - bpo-27666(51): Fixed stack corruption in curses.box() and
     curses.ungetmouse() when the size of types chtype or mmask_t is
     less than the size of C long.  curses.box() now accepts characters
     as arguments.  Based on patch by Steve Fink.

   - bpo-31917(52): Add 3 new clock identifiers: *note
     time.CLOCK_BOOTTIME: b5c, *note time.CLOCK_PROF: b5d. and *note
     time.CLOCK_UPTIME: b5e.

   - bpo-31897(53): plistlib now catches more errors when read binary
     plists and raises InvalidFileException instead of unexpected
     exceptions.

   - bpo-25720(54): Fix the method for checking pad state of curses
     WINDOW. Patch by Masayuki Yamamoto.

   - bpo-31893(55): Fixed the layout of the kqueue_event structure on
     OpenBSD and NetBSD. Fixed the comparison of the kqueue_event
     objects.

   - bpo-31891(56): Fixed building the curses module on NetBSD.

   - bpo-31884(57): added required constants to subprocess module for
     setting priority on windows

   - bpo-28281(58): Remove year (1-9999) limits on the
     Calendar.weekday() function.  Patch by Mark Gollahon.

   - bpo-31702(59): crypt.mksalt() now allows to specify the number of
     rounds for SHA-256 and SHA-512 hashing.

   - bpo-30639(60): *note inspect.getfile(): 1a0f. no longer computes
     the repr of unknown objects to display in an error message, to
     protect against badly behaved custom reprs.

   - bpo-30768(61): Fix the pthread+semaphore implementation of
     PyThread_acquire_lock_timed() when called with timeout > 0 and
     intr_flag=0: recompute the timeout if sem_timedwait() is
     interrupted by a signal (EINTR). See also the PEP 475(62).

   - bpo-31854(63): Add ‘mmap.ACCESS_DEFAULT’ constant.

   - bpo-31834(64): Use optimized code for BLAKE2 only with SSSE3+.  The
     pure SSE2 implementation is slower than the pure C reference
     implementation.

   - bpo-28292(65): Calendar.itermonthdates() will now consistently
     raise an exception when a date falls outside of the 0001-01-01
     through 9999-12-31 range.  To support applications that cannot
     tolerate such exceptions, the new methods itermonthdays3() and
     itermonthdays4() are added.  The new methods return tuples and are
     not restricted by the range supported by datetime.date.

   - bpo-28564(66): The shutil.rmtree() function has been sped up to
     20-40%.  This was done using the os.scandir() function.

   - bpo-28416(67): Instances of pickle.Pickler subclass with the
     persistent_id() method and pickle.Unpickler subclass with the
     persistent_load() method no longer create reference cycles.

   - bpo-31653(68): Don't release the GIL if we can acquire a
     multiprocessing semaphore immediately.

   - bpo-28326(69): Fix multiprocessing.Process when stdout and/or
     stderr is closed or None.

   - bpo-20825(70): Add ‘subnet_of’ and ‘superset_of’ containment tests
     to *note ipaddress.IPv6Network: 1e0. and *note
     ipaddress.IPv4Network: 1df.  Patch by Michel Albert and Cheryl
     Sabella.

   - bpo-31827(71): Remove the os.stat_float_times() function.  It was
     introduced in Python 2.3 for backward compatibility with Python
     2.2, and was deprecated since Python 3.1.

   - bpo-31756(72): Add a ‘subprocess.Popen(text=False)’ keyword
     argument to ‘subprocess’ functions to be more explicit about when
     the library should attempt to decode outputs into text.  Patch by
     Andrew Clegg.

   - bpo-31819(73): Add AbstractEventLoop.sock_recv_into().

   - bpo-31457(74): If nested log adapters are used, the inner
     ‘process()’ methods are no longer omitted.

   - bpo-31457(75): The ‘manager’ property on LoggerAdapter objects is
     now properly settable.

   - bpo-31806(76): Fix timeout rounding in time.sleep(),
     threading.Lock.acquire() and socket.socket.settimeout() to round
     correctly negative timeouts between -1.0 and 0.0.  The functions
     now block waiting for events as expected.  Previously, the call was
     incorrectly non-blocking.  Patch by Pablo Galindo.

   - bpo-31803(77): time.clock() and time.get_clock_info('clock') now
     emit a DeprecationWarning warning.

   - bpo-31800(78): Extended support for parsing UTC offsets.  strptime
     '%z' can now parse the output generated by datetime.isoformat,
     including seconds and microseconds.

   - bpo-28603(79): traceback: Fix a TypeError that occurred during
     printing of exception tracebacks when either the current exception
     or an exception in its context/cause chain is unhashable.  Patch by
     Zane Bitter.

   - bpo-30541(80): Add new function to seal a mock and prevent the
     automatically creation of child mocks.  Patch by Mario Corchero.

   - bpo-31784(81): Implement the PEP 564(82), add new 6 new functions
     with nanosecond resolution to the *note time: d7. module: *note
     clock_gettime_ns(): ab0, *note clock_settime_ns(): ab1, *note
     monotonic_ns(): ab2, *note perf_counter_ns(): ab3, *note
     process_time_ns(): ab4, *note time_ns(): ab5.

   - bpo-30143(83): 2to3 now generates a code that uses abstract
     collection classes from collections.abc rather than collections.

   - bpo-31770(84): Prevent a crash when calling the ‘__init__()’ method
     of a ‘sqlite3.Cursor’ object more than once.  Patch by Oren Milman.

   - bpo-31764(85): Prevent a crash in ‘sqlite3.Cursor.close()’ in case
     the ‘Cursor’ object is uninitialized.  Patch by Oren Milman.

   - bpo-31752(86): Fix possible crash in timedelta constructor called
     with custom integers.

   - bpo-31620(87): an empty asyncio.Queue now doesn't leak memory when
     queue.get pollers timeout

   - bpo-31690(88): Allow the flags re.ASCII, re.LOCALE, and re.UNICODE
     to be used as group flags for regular expressions.

   - bpo-30349(89): FutureWarning is now emitted if a regular expression
     contains character set constructs that will change semantically in
     the future (nested sets and set operations).

   - bpo-31664(90): Added support for the Blowfish hashing in the crypt
     module.

   - bpo-31632(91): Fix method set_protocol() of class
     _SSLProtocolTransport in asyncio module.  This method was
     previously modifying a wrong reference to the protocol.

   - bpo-15037(92): Added a workaround for getkey() in curses for
     ncurses 5.7 and earlier.

   - bpo-31307(93): Allow use of bytes objects for arguments to *note
     configparser.ConfigParser.read(): 140d.  Patch by Vincent Michel.

   - bpo-31334(94): Fix ‘poll.poll([timeout])’ in the ‘select’ module
     for arbitrary negative timeouts on all OSes where it can only be a
     non-negative integer or -1.  Patch by Riccardo Coccioli.

   - bpo-31310(95): multiprocessing's semaphore tracker should be
     launched again if crashed.

   - bpo-31308(96): Make multiprocessing's forkserver process immune to
     Ctrl-C and other user interruptions.  If it crashes, restart it
     when necessary.

   - bpo-31245(97): Added support for AF_UNIX socket in asyncio
     ‘create_datagram_endpoint’.

   - bpo-30553(98): Add HTTP/2 status code 421 (Misdirected Request) to
     *note http.HTTPStatus: 8ce.  Patch by Vitor Pereira.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32214

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27240

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30788

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31831

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32182

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32186

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32101

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32154

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32089

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32107

   (12) https://bugs.python.org/issue?@action=redirect&bpo=23033

   (13) https://bugs.python.org/issue?@action=redirect&bpo=12239

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28334

   (15) https://bugs.python.org/issue?@action=redirect&bpo=32121

   (16) https://bugs.python.org/issue?@action=redirect&bpo=31325

   (17) https://bugs.python.org/issue?@action=redirect&bpo=12382

   (18) https://bugs.python.org/issue?@action=redirect&bpo=19610

   (19) https://bugs.python.org/issue?@action=redirect&bpo=32071

   (20) https://bugs.python.org/issue?@action=redirect&bpo=10049

   (21) https://bugs.python.org/issue?@action=redirect&bpo=28684

   (22) https://bugs.python.org/issue?@action=redirect&bpo=32110

   (23) https://bugs.python.org/issue?@action=redirect&bpo=27535

   (24) https://bugs.python.org/issue?@action=redirect&bpo=32088

   (25) https://bugs.python.org/issue?@action=redirect&bpo=1647489

   (26) https://bugs.python.org/issue?@action=redirect&bpo=25054

   (27) https://bugs.python.org/issue?@action=redirect&bpo=32072

   (28) https://bugs.python.org/issue?@action=redirect&bpo=32069

   (29) https://bugs.python.org/issue?@action=redirect&bpo=32066

   (30) https://bugs.python.org/issue?@action=redirect&bpo=32046

   (31) https://bugs.python.org/issue?@action=redirect&bpo=32018

   (32) https://peps.python.org/pep-0008/

   (33) https://bugs.python.org/issue?@action=redirect&bpo=32025

   (34) https://bugs.python.org/issue?@action=redirect&bpo=32037

   (35) https://bugs.python.org/issue?@action=redirect&bpo=32034

   (36) https://bugs.python.org/issue?@action=redirect&bpo=32015

   (37) https://bugs.python.org/issue?@action=redirect&bpo=32011

   (38) https://bugs.python.org/issue?@action=redirect&bpo=28369

   (39) https://bugs.python.org/issue?@action=redirect&bpo=31976

   (40) https://bugs.python.org/issue?@action=redirect&bpo=31985

   (41) https://bugs.python.org/issue?@action=redirect&bpo=21862

   (42) https://bugs.python.org/issue?@action=redirect&bpo=31970

   (43) https://bugs.python.org/issue?@action=redirect&bpo=31843

   (44) https://bugs.python.org/issue?@action=redirect&bpo=31945

   (45) https://bugs.python.org/issue?@action=redirect&bpo=31943

   (46) https://bugs.python.org/issue?@action=redirect&bpo=9678

   (47) https://bugs.python.org/issue?@action=redirect&bpo=30057

   (48) https://bugs.python.org/issue?@action=redirect&bpo=31933

   (49) https://bugs.python.org/issue?@action=redirect&bpo=21423

   (50) https://bugs.python.org/issue?@action=redirect&bpo=31927

   (51) https://bugs.python.org/issue?@action=redirect&bpo=27666

   (52) https://bugs.python.org/issue?@action=redirect&bpo=31917

   (53) https://bugs.python.org/issue?@action=redirect&bpo=31897

   (54) https://bugs.python.org/issue?@action=redirect&bpo=25720

   (55) https://bugs.python.org/issue?@action=redirect&bpo=31893

   (56) https://bugs.python.org/issue?@action=redirect&bpo=31891

   (57) https://bugs.python.org/issue?@action=redirect&bpo=31884

   (58) https://bugs.python.org/issue?@action=redirect&bpo=28281

   (59) https://bugs.python.org/issue?@action=redirect&bpo=31702

   (60) https://bugs.python.org/issue?@action=redirect&bpo=30639

   (61) https://bugs.python.org/issue?@action=redirect&bpo=30768

   (62) https://peps.python.org/pep-0475/

   (63) https://bugs.python.org/issue?@action=redirect&bpo=31854

   (64) https://bugs.python.org/issue?@action=redirect&bpo=31834

   (65) https://bugs.python.org/issue?@action=redirect&bpo=28292

   (66) https://bugs.python.org/issue?@action=redirect&bpo=28564

   (67) https://bugs.python.org/issue?@action=redirect&bpo=28416

   (68) https://bugs.python.org/issue?@action=redirect&bpo=31653

   (69) https://bugs.python.org/issue?@action=redirect&bpo=28326

   (70) https://bugs.python.org/issue?@action=redirect&bpo=20825

   (71) https://bugs.python.org/issue?@action=redirect&bpo=31827

   (72) https://bugs.python.org/issue?@action=redirect&bpo=31756

   (73) https://bugs.python.org/issue?@action=redirect&bpo=31819

   (74) https://bugs.python.org/issue?@action=redirect&bpo=31457

   (75) https://bugs.python.org/issue?@action=redirect&bpo=31457

   (76) https://bugs.python.org/issue?@action=redirect&bpo=31806

   (77) https://bugs.python.org/issue?@action=redirect&bpo=31803

   (78) https://bugs.python.org/issue?@action=redirect&bpo=31800

   (79) https://bugs.python.org/issue?@action=redirect&bpo=28603

   (80) https://bugs.python.org/issue?@action=redirect&bpo=30541

   (81) https://bugs.python.org/issue?@action=redirect&bpo=31784

   (82) https://peps.python.org/pep-0564/

   (83) https://bugs.python.org/issue?@action=redirect&bpo=30143

   (84) https://bugs.python.org/issue?@action=redirect&bpo=31770

   (85) https://bugs.python.org/issue?@action=redirect&bpo=31764

   (86) https://bugs.python.org/issue?@action=redirect&bpo=31752

   (87) https://bugs.python.org/issue?@action=redirect&bpo=31620

   (88) https://bugs.python.org/issue?@action=redirect&bpo=31690

   (89) https://bugs.python.org/issue?@action=redirect&bpo=30349

   (90) https://bugs.python.org/issue?@action=redirect&bpo=31664

   (91) https://bugs.python.org/issue?@action=redirect&bpo=31632

   (92) https://bugs.python.org/issue?@action=redirect&bpo=15037

   (93) https://bugs.python.org/issue?@action=redirect&bpo=31307

   (94) https://bugs.python.org/issue?@action=redirect&bpo=31334

   (95) https://bugs.python.org/issue?@action=redirect&bpo=31310

   (96) https://bugs.python.org/issue?@action=redirect&bpo=31308

   (97) https://bugs.python.org/issue?@action=redirect&bpo=31245

   (98) https://bugs.python.org/issue?@action=redirect&bpo=30553


File: python.info,  Node: Documentation<53>,  Next: Tests<54>,  Prev: Library<59>,  Up: Python 3 7 0 alpha 3

1.23.60.3 Documentation
.......................

   - bpo-32105(1): Added asyncio.BaseEventLoop.connect_accepted_socket
     versionadded marker.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32105


File: python.info,  Node: Tests<54>,  Next: Build<56>,  Prev: Documentation<53>,  Up: Python 3 7 0 alpha 3

1.23.60.4 Tests
...............

   - bpo-31380(1): Skip test_httpservers test_undecodable_file on macOS:
     fails on APFS.

   - bpo-31705(2): Skip test_socket.test_sha256() on Linux kernel older
     than 4.5.  The test fails with ENOKEY on kernel 3.10 (on ppc64le).
     A fix was merged into the kernel 4.5.

   - bpo-32138(3): Skip on Android test_faulthandler tests that raise
     SIGSEGV and remove the test.support.requires_android_level
     decorator.

   - bpo-32136(4): The runtime embedding tests have been split out from
     ‘Lib/test/test_capi.py’ into a new ‘Lib/test/test_embed.py’ file.

   - bpo-28668(5): test.support.requires_multiprocessing_queue is
     removed.  Skip tests with
     test.support.import_module('multiprocessing.synchronize') instead
     when the semaphore implementation is broken or missing.

   - bpo-32126(6): Skip test_get_event_loop_new_process in
     test.test_asyncio.test_events when sem_open() is not functional.

   - bpo-31174(7): Fix test_tools.test_unparse: DirectoryTestCase now
     stores the names sample to always test the same files.  It prevents
     false alarms when hunting reference leaks.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31380

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31705

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32138

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32136

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28668

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32126

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31174


File: python.info,  Node: Build<56>,  Next: Windows<52>,  Prev: Tests<54>,  Up: Python 3 7 0 alpha 3

1.23.60.5 Build
...............

   - bpo-28538(1): Revert the previous changes, the if_nameindex
     structure is defined by Unified Headers.

   - bpo-28762(2): Revert the last commit, the F_LOCK macro is defined
     by Android Unified Headers.

   - bpo-29040(3): Support building Android with Unified Headers.  The
     first NDK release to support Unified Headers is android-ndk-r14.

   - bpo-32059(4): ‘detect_modules()’ in ‘setup.py’ now also searches
     the sysroot paths when cross-compiling.

   - bpo-31957(5): Fixes Windows SDK version detection when building for
     Windows.

   - bpo-31609(6): Fixes quotes in PCbuild/clean.bat

   - bpo-31934(7): Abort the build when building out of a not clean
     source tree.

   - bpo-31926(8): Fixed Argument Clinic sometimes causing compilation
     errors when there was more than one function and/or method in a .c
     file with the same name.

   - bpo-28791(9): Update Windows builds to use SQLite 3.21.0.

   - bpo-28791(10): Update OS X installer to use SQLite 3.21.0.

   - bpo-28643(11): Record profile-opt build progress with stamp files.

   - bpo-31866(12): Finish removing support for AtheOS.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28538

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28762

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29040

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32059

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31957

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31609

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31934

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31926

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28791

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28791

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28643

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31866


File: python.info,  Node: Windows<52>,  Next: macOS<43>,  Prev: Build<56>,  Up: Python 3 7 0 alpha 3

1.23.60.6 Windows
.................

   - bpo-1102(1): Return ‘None’ when ‘View.Fetch()’ returns
     ‘ERROR_NO_MORE_ITEMS’ instead of raising ‘MSIError’.  Initial patch
     by Anthony Tuininga.

   - bpo-31944(2): Fixes Modify button in Apps and Features dialog.

   - bpo-20486(3): Implement the ‘Database.Close()’ method to help
     closing MSI database objects.

   - bpo-31857(4): Make the behavior of USE_STACKCHECK deterministic in
     a multi-threaded environment.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1102

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31944

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20486

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31857


File: python.info,  Node: macOS<43>,  Next: IDLE<43>,  Prev: Windows<52>,  Up: Python 3 7 0 alpha 3

1.23.60.7 macOS
...............

   - bpo-31392(1): Update macOS installer to use OpenSSL 1.0.2m

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31392


File: python.info,  Node: IDLE<43>,  Next: Tools/Demos<29>,  Prev: macOS<43>,  Up: Python 3 7 0 alpha 3

1.23.60.8 IDLE
..............

   - bpo-32207(1): Improve tk event exception tracebacks in IDLE. When
     tk event handling is driven by IDLE's run loop, a confusing and
     distracting queue.EMPTY traceback context is no longer added to tk
     event exception tracebacks.  The traceback is now the same as when
     event handling is driven by user code.  Patch based on a suggestion
     by Serhiy Storchaka.

   - bpo-32164(2): Delete unused file idlelib/tabbedpages.py.  Use of
     TabbedPageSet in configdialog was replaced by ttk.Notebook.

   - bpo-32100(3): IDLE: Fix old and new bugs in pathbrowser; improve
     tests.  Patch mostly by Cheryl Sabella.

   - bpo-31858(4): IDLE - Restrict shell prompt manipulation to the
     shell.  Editor and output windows only see an empty last prompt
     line.  This simplifies the code and fixes a minor bug when newline
     is inserted.  Sys.ps1, if present, is read on Shell start-up, but
     is not set or changed.

   - bpo-31860(5): The font sample in the IDLE configuration dialog is
     now editable.  Changes persist while IDLE remains open

   - bpo-31836(6): Test_code_module now passes if run after test_idle,
     which sets ps1.  The code module uses sys.ps1 if present or sets it
     to '>>> ' if not.  Test_code_module now properly tests both
     behaviors.  Ditto for ps2.

   - bpo-28603(7): Fix a TypeError that caused a shell restart when
     printing a traceback that includes an exception that is unhashable.
     Patch by Zane Bitter.

   - bpo-13802(8): Use non-Latin characters in the IDLE's Font settings
     sample.  Even if one selects a font that defines a limited subset
     of the unicode Basic Multilingual Plane, tcl/tk will use other
     fonts that define a character.  The expanded example give users of
     non-Latin characters a better idea of what they might see in IDLE's
     shell and editors.  To make room for the expanded sample, frames on
     the Font tab are re-arranged.  The Font/Tabs help explains a bit
     about the additions.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32207

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32164

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32100

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31858

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31860

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31836

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28603

   (8) https://bugs.python.org/issue?@action=redirect&bpo=13802


File: python.info,  Node: Tools/Demos<29>,  Next: C API<53>,  Prev: IDLE<43>,  Up: Python 3 7 0 alpha 3

1.23.60.9 Tools/Demos
.....................

   - bpo-32159(1): Remove CVS and Subversion tools: remove svneol.py and
     treesync.py scripts.  CPython migrated from CVS to Subversion, to
     Mercurial, and then to Git.  CVS and Subversion are no longer used
     to develop CPython.

   - bpo-30722(2): Make redemo work with Python 3.6 and newer versions.
     Also, remove the ‘LOCALE’ option since it doesn't work with string
     patterns in Python 3.  Patch by Christoph Sarnowski.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32159

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30722


File: python.info,  Node: C API<53>,  Prev: Tools/Demos<29>,  Up: Python 3 7 0 alpha 3

1.23.60.10 C API
................

   - bpo-20891(1): Fix PyGILState_Ensure().  When PyGILState_Ensure() is
     called in a non-Python thread before PyEval_InitThreads(), only
     call PyEval_InitThreads() after calling PyThreadState_New() to fix
     a crash.

   - bpo-32125(2): The ‘Py_UseClassExceptionsFlag’ flag has been
     removed.  It was deprecated and wasn't used anymore since Python
     2.0.

   - bpo-25612(3): Move the current exception state from the frame
     object to the co-routine.  This simplifies the interpreter and
     fixes a couple of obscure bugs caused by having swap exception
     state when entering or exiting a generator.

   - bpo-23699(4): Add Py_RETURN_RICHCOMPARE macro to reduce boilerplate
     code in rich comparison functions.

   - bpo-30697(5): The ‘PyExc_RecursionErrorInst’ singleton is removed
     and ‘PyErr_NormalizeException()’ does not use it anymore.  This
     singleton is persistent and its members being never cleared may
     cause a segfault during finalization of the interpreter.  See also
     bpo-22898(6).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20891

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32125

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25612

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23699

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30697

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22898


File: python.info,  Node: Python 3 7 0 alpha 2,  Next: Python 3 7 0 alpha 1,  Prev: Python 3 7 0 alpha 3,  Up: 変更履歴

1.23.61 Python 3.7.0 alpha 2
----------------------------

'Release date: 2017-10-16'

* Menu:

* Core and Builtins: Core and Builtins<60>.
* Library: Library<60>.
* Documentation: Documentation<54>.
* Build: Build<57>.
* IDLE: IDLE<44>.
* C API: C API<54>.


File: python.info,  Node: Core and Builtins<60>,  Next: Library<60>,  Up: Python 3 7 0 alpha 2

1.23.61.1 Core and Builtins
...........................

   - bpo-31558(1): ‘gc.freeze()’ is a new API that allows for moving all
     objects currently tracked by the garbage collector to a permanent
     generation, effectively removing them from future collection
     events.  This can be used to protect those objects from having
     their PyGC_Head mutated.  In effect, this enables great
     copy-on-write stability at fork().

   - bpo-31642(2): Restored blocking "from package import module" by
     setting sys.modules["package.module"] to None.

   - bpo-31708(3): Allow use of asynchronous generator expressions in
     synchronous functions.

   - bpo-31709(4): Drop support of asynchronous __aiter__.

   - bpo-30404(5): The -u option now makes the stdout and stderr streams
     unbuffered rather than line-buffered.

   - bpo-31619(6): Fixed a ValueError when convert a string with large
     number of underscores to integer with binary base.

   - bpo-31602(7): Fix an assertion failure in
     ‘zipimporter.get_source()’ in case of a bad ‘zlib.decompress()’.
     Patch by Oren Milman.

   - bpo-31592(8): Fixed an assertion failure in Python parser in case
     of a bad ‘unicodedata.normalize()’.  Patch by Oren Milman.

   - bpo-31588(9): Raise a ‘TypeError’ with a helpful error message when
     class creation fails due to a metaclass with a bad ‘__prepare__()’
     method.  Patch by Oren Milman.

   - bpo-31574(10): Importlib was instrumented with two dtrace probes to
     profile import timing.

   - bpo-31566(11): Fix an assertion failure in ‘_warnings.warn()’ in
     case of a bad ‘__name__’ global.  Patch by Oren Milman.

   - bpo-31506(12): Improved the error message logic for
     ‘object.__new__’ and ‘object.__init__’.

   - bpo-31505(13): Fix an assertion failure in ‘json’, in case
     ‘_json.make_encoder()’ received a bad ‘encoder()’ argument.  Patch
     by Oren Milman.

   - bpo-31492(14): Fix assertion failures in case of failing to import
     from a module with a bad ‘__name__’ attribute, and in case of
     failing to access an attribute of such a module.  Patch by Oren
     Milman.

   - bpo-31478(15): Fix an assertion failure in ‘_random.Random.seed()’
     in case the argument has a bad ‘__abs__()’ method.  Patch by Oren
     Milman.

   - bpo-31336(16): Speed up class creation by 10-20% by reducing the
     overhead in the necessary special method lookups.  Patch by Stefan
     Behnel.

   - bpo-31415(17): Add ‘-X importtime’ option to show how long each
     import takes.  It can be used to optimize application's startup
     time.  Support the *note PYTHONPROFILEIMPORTTIME: ac3. as an
     equivalent way to enable this.

   - bpo-31410(18): Optimized calling wrapper and classmethod
     descriptors.

   - bpo-31353(19): PEP 553(20) - Add a new built-in called
     ‘breakpoint()’ which calls ‘sys.breakpointhook()’.  By default this
     imports ‘pdb’ and calls ‘pdb.set_trace()’, but users may override
     ‘sys.breakpointhook()’ to call whatever debugger they want.  The
     original value of the hook is saved in ‘sys.__breakpointhook__’.

   - bpo-17852(21): Maintain a list of open buffered files, flush them
     before exiting the interpreter.  Based on a patch from Armin Rigo.

   - bpo-31315(22): Fix an assertion failure in imp.create_dynamic(),
     when spec.name is not a string.  Patch by Oren Milman.

   - bpo-31311(23): Fix a crash in the ‘__setstate__()’ method of
     ‘ctypes._CData’, in case of a bad ‘__dict__’.  Patch by Oren
     Milman.

   - bpo-31293(24): Fix crashes in true division and multiplication of a
     timedelta object by a float with a bad as_integer_ratio() method.
     Patch by Oren Milman.

   - bpo-31285(25): Fix an assertion failure in
     ‘warnings.warn_explicit’, when the return value of the received
     loader's ‘get_source()’ has a bad ‘splitlines()’ method.  Patch by
     Oren Milman.

   - bpo-30406(26): Make ‘async’ and ‘await’ proper keywords, as
     specified in PEP 492(27).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31558

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31642

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31708

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31709

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30404

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31619

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31602

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31592

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31588

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31574

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31566

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31506

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31505

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31492

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31478

   (16) https://bugs.python.org/issue?@action=redirect&bpo=31336

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31415

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31410

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31353

   (20) https://peps.python.org/pep-0553/

   (21) https://bugs.python.org/issue?@action=redirect&bpo=17852

   (22) https://bugs.python.org/issue?@action=redirect&bpo=31315

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31311

   (24) https://bugs.python.org/issue?@action=redirect&bpo=31293

   (25) https://bugs.python.org/issue?@action=redirect&bpo=31285

   (26) https://bugs.python.org/issue?@action=redirect&bpo=30406

   (27) https://peps.python.org/pep-0492/


File: python.info,  Node: Library<60>,  Next: Documentation<54>,  Prev: Core and Builtins<60>,  Up: Python 3 7 0 alpha 2

1.23.61.2 Library
.................

   - bpo-30058(1): Fixed buffer overflow in select.kqueue.control().

   - bpo-31672(2): ‘idpattern’ in ‘string.Template’ matched some
     non-ASCII characters.  Now it uses ‘-i’ regular expression local
     flag to avoid non-ASCII characters.

   - bpo-31701(3): On Windows, faulthandler.enable() now ignores MSC and
     COM exceptions.

   - bpo-31728(4): Prevent crashes in ‘_elementtree’ due to unsafe
     cleanup of ‘Element.text’ and ‘Element.tail’.  Patch by Oren
     Milman.

   - bpo-31671(5): Now ‘re.compile()’ converts passed RegexFlag to
     normal int object before compiling.  bm_regex_compile benchmark
     shows 14% performance improvements.

   - bpo-30397(6): The types of compiled regular objects and match
     objects are now exposed as ‘re.Pattern’ and ‘re.Match’.  This adds
     information in pydoc output for the ‘re’ module.

   - bpo-31675(7): Fixed memory leaks in Tkinter's methods splitlist()
     and split() when pass a string larger than 2 GiB.

   - bpo-31673(8): Fixed typo in the name of Tkinter's method
     adderrorinfo().

   - bpo-31648(9): Improvements to path predicates in ElementTree: Allow
     whitespace around predicate parts, i.e.  "[a = 'text']" instead of
     requiring the less readable "[a='text']".  Add support for text
     comparison of the current node, like "[.='text']".  Patch by Stefan
     Behnel.

   - bpo-30806(10): Fix the string representation of a netrc object.

   - bpo-31638(11): Add optional argument ‘compressed’ to
     ‘zipapp.create_archive’, and add option ‘--compress’ to the command
     line interface of ‘zipapp’.

   - bpo-25351(12): Avoid venv activate failures with undefined
     variables

   - bpo-20519(13): Avoid ctypes use (if possible) and improve import
     time for uuid.

   - bpo-28293(14): The regular expression cache is no longer completely
     dumped when it is full.

   - bpo-31596(15): Added pthread_getcpuclockid() to the time module

   - bpo-27494(16): Make 2to3 accept a trailing comma in generator
     expressions.  For example, ‘set(x for x in [],)’ is now allowed.

   - bpo-30347(17): Stop crashes when concurrently iterate over
     itertools.groupby() iterators.

   - bpo-30346(18): An iterator produced by itertools.groupby() iterator
     now becomes exhausted after advancing the groupby iterator.

   - bpo-31556(19): Cancel asyncio.wait_for future faster if timeout <=
     0

   - bpo-31540(20): Allow passing a context object in *note
     concurrent.futures.ProcessPoolExecutor: 8bc. constructor.  Also,
     free job resources in *note concurrent.futures.ProcessPoolExecutor:
     8bc. earlier to improve memory usage when a worker waits for new
     jobs.

   - bpo-31516(21): ‘threading.current_thread()’ should not return a
     dummy thread at shutdown.

   - bpo-31525(22): In the sqlite module, require the sqlite3_prepare_v2
     API. Thus, the sqlite module now requires sqlite version at least
     3.3.9.

   - bpo-26510(23): argparse subparsers are now required by default.
     This matches behaviour in Python 2.  For optional subparsers, use
     the new parameter ‘add_subparsers(required=False)’.  Patch by
     Anthony Sottile.  (As of 3.7.0rc1, the default was changed to not
     required as had been the case since Python 3.3.)

   - bpo-27541(24): Reprs of subclasses of some collection and iterator
     classes (‘bytearray’, ‘array.array’, ‘collections.deque’,
     ‘collections.defaultdict’, ‘itertools.count’, ‘itertools.repeat’)
     now contain actual type name instead of hardcoded names of the base
     class.

   - bpo-31351(25): python -m ensurepip now exits with non-zero exit
     code if pip bootstrapping has failed.

   - bpo-31389(26): ‘pdb.set_trace()’ now takes an optional keyword-only
     argument ‘header’.  If given, this is printed to the console just
     before debugging begins.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30058

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31672

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31701

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31728

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31671

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30397

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31675

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31673

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31648

   (10) https://bugs.python.org/issue?@action=redirect&bpo=30806

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31638

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25351

   (13) https://bugs.python.org/issue?@action=redirect&bpo=20519

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28293

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31596

   (16) https://bugs.python.org/issue?@action=redirect&bpo=27494

   (17) https://bugs.python.org/issue?@action=redirect&bpo=30347

   (18) https://bugs.python.org/issue?@action=redirect&bpo=30346

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31556

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31540

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31516

   (22) https://bugs.python.org/issue?@action=redirect&bpo=31525

   (23) https://bugs.python.org/issue?@action=redirect&bpo=26510

   (24) https://bugs.python.org/issue?@action=redirect&bpo=27541

   (25) https://bugs.python.org/issue?@action=redirect&bpo=31351

   (26) https://bugs.python.org/issue?@action=redirect&bpo=31389


File: python.info,  Node: Documentation<54>,  Next: Build<57>,  Prev: Library<60>,  Up: Python 3 7 0 alpha 2

1.23.61.3 Documentation
.......................

   - bpo-31537(1): Fix incorrect usage of ‘get_history_length’ in
     readline documentation example code.  Patch by Brad Smith.

   - bpo-30085(2): The operator functions without double underscores are
     preferred for clarity.  The one with underscores are only kept for
     back-compatibility.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31537

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30085


File: python.info,  Node: Build<57>,  Next: IDLE<44>,  Prev: Documentation<54>,  Up: Python 3 7 0 alpha 2

1.23.61.4 Build
...............

   - bpo-31696(1): Improve compiler version information in *note
     sys.version: 15e. when Python is built with Clang.

   - bpo-31625(2): Stop using ranlib on static libraries.  Instead, we
     assume ar supports the 's' flag.

   - bpo-31624(3): Remove support for BSD/OS.

   - bpo-22140(4): Prevent double substitution of prefix in
     python-config.sh.

   - bpo-31569(5): Correct PCBuild/ case to PCbuild/ in build scripts
     and documentation.

   - bpo-31536(6): Avoid wholesale rebuild after ‘make regen-all’ if
     nothing changed.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31696

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31625

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31624

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22140

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31569

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31536


File: python.info,  Node: IDLE<44>,  Next: C API<54>,  Prev: Build<57>,  Up: Python 3 7 0 alpha 2

1.23.61.5 IDLE
..............

   - bpo-31460(1): Simplify the API of IDLE's Module Browser.  Passing a
     widget instead of an flist with a root widget opens the option of
     creating a browser frame that is only part of a window.  Passing a
     full file name instead of pieces assumed to come from a .py file
     opens the possibility of browsing python files that do not end in
     .py.

   - bpo-31649(2): IDLE - Make _htest, _utest parameters keyword only.

   - bpo-31559(3): Remove test order dependence in
     idle_test.test_browser.

   - bpo-31459(4): Rename IDLE's module browser from Class Browser to
     Module Browser.  The original module-level class and method browser
     became a module browser, with the addition of module-level
     functions, years ago.  Nested classes and functions were added
     yesterday.  For back-compatibility, the virtual event
     <<open-class-browser>>, which appears on the Keys tab of the
     Settings dialog, is not changed.  Patch by Cheryl Sabella.

   - bpo-31500(5): Default fonts now are scaled on HiDPI displays.

   - bpo-1612262(6): IDLE module browser now shows nested classes and
     functions.  Original patches for code and tests by Guilherme Polo
     and Cheryl Sabella, respectively.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31460

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31649

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31559

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31459

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31500

   (6) https://bugs.python.org/issue?@action=redirect&bpo=1612262


File: python.info,  Node: C API<54>,  Prev: IDLE<44>,  Up: Python 3 7 0 alpha 2

1.23.61.6 C API
...............

   - bpo-28280(1): Make ‘PyMapping_Keys()’, ‘PyMapping_Values()’ and
     ‘PyMapping_Items()’ always return a ‘list’ (rather than a ‘list’ or
     a ‘tuple’).  Patch by Oren Milman.

   - bpo-31532(2): Fix memory corruption due to allocator mix in
     getpath.c between Py_GetPath() and Py_SetPath()

   - bpo-25658(3): Implement PEP 539(4) for Thread Specific Storage
     (TSS) API: it is a new Thread Local Storage (TLS) API to CPython
     which would supersede use of the existing TLS API within the
     CPython interpreter, while deprecating the existing API. PEP
     written by Erik M. Bray, patch by Masayuki Yamamoto.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28280

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31532

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25658

   (4) https://peps.python.org/pep-0539/


File: python.info,  Node: Python 3 7 0 alpha 1,  Next: Python 3 6 6 final,  Prev: Python 3 7 0 alpha 2,  Up: 変更履歴

1.23.62 Python 3.7.0 alpha 1
----------------------------

'Release date: 2017-09-19'

* Menu:

* Security: Security<37>.
* Core and Builtins: Core and Builtins<61>.
* Library: Library<61>.
* Documentation: Documentation<55>.
* Tests: Tests<55>.
* Build: Build<58>.
* Windows: Windows<53>.
* IDLE: IDLE<45>.
* Tools/Demos: Tools/Demos<30>.
* C API: C API<55>.


File: python.info,  Node: Security<37>,  Next: Core and Builtins<61>,  Up: Python 3 7 0 alpha 1

1.23.62.1 Security
..................

   - bpo-29781(1): SSLObject.version() now correctly returns None when
     handshake over BIO has not been performed yet.

   - bpo-29505(2): Add fuzz tests for float(str), int(str),
     unicode(str); for oss-fuzz.

   - bpo-30947(3): Upgrade libexpat embedded copy from version 2.2.1 to
     2.2.3 to get security fixes.

   - bpo-30730(4): Prevent environment variables injection in subprocess
     on Windows.  Prevent passing other environment variables and
     command arguments.

   - bpo-30694(5): Upgrade expat copy from 2.2.0 to 2.2.1 to get fixes
     of multiple security vulnerabilities including: CVE 2017-9233(6)
     (External entity infinite loop DoS), CVE 2016-9063(7) (Integer
     overflow, re-fix), CVE 2016-0718(8) (Fix regression bugs from
     2.2.0's fix to CVE 2016-0718(9)) and CVE 2012-0876(10) (Counter
     hash flooding with SipHash).  Note: the CVE 2016-5300(11) (Use
     os-specific entropy sources like getrandom) doesn't impact Python,
     since Python already gets entropy from the OS to set the expat
     secret using ‘XML_SetHashSalt()’.

   - bpo-30500(12): Fix urllib.parse.splithost() to correctly parse
     fragments.  For example, ‘splithost('//127.0.0.1#@evil.com/')’ now
     correctly returns the ‘127.0.0.1’ host, instead of treating
     ‘@evil.com’ as the host in an authentication (‘login@host’).

   - bpo-29591(13): Update expat copy from 2.1.1 to 2.2.0 to get fixes
     of CVE 2016-0718(14) and CVE 2016-4472(15).  See
     ‘https://sourceforge.net/p/expat/bugs/537/’ for more information.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29781

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29505

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30947

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30730

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30694

   (6) https://www.cve.org/CVERecord?id=CVE-2017-9233

   (7) https://www.cve.org/CVERecord?id=CVE-2016-9063

   (8) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (9) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (10) https://www.cve.org/CVERecord?id=CVE-2012-0876

   (11) https://www.cve.org/CVERecord?id=CVE-2016-5300

   (12) https://bugs.python.org/issue?@action=redirect&bpo=30500

   (13) https://bugs.python.org/issue?@action=redirect&bpo=29591

   (14) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (15) https://www.cve.org/CVERecord?id=CVE-2016-4472


File: python.info,  Node: Core and Builtins<61>,  Next: Library<61>,  Prev: Security<37>,  Up: Python 3 7 0 alpha 1

1.23.62.2 Core and Builtins
...........................

   - bpo-31490(1): Fix an assertion failure in ‘ctypes’ class
     definition, in case the class has an attribute whose name is
     specified in ‘_anonymous_’ but not in ‘_fields_’.  Patch by Oren
     Milman.

   - bpo-31471(2): Fix an assertion failure in ‘subprocess.Popen()’ on
     Windows, in case the env argument has a bad ‘keys()’ method.  Patch
     by Oren Milman.

   - bpo-31418(3): Fix an assertion failure in ‘PyErr_WriteUnraisable()’
     in case of an exception with a bad ‘__module__’ attribute.  Patch
     by Oren Milman.

   - bpo-31416(4): Fix assertion failures in case of a bad
     warnings.filters or warnings.defaultaction.  Patch by Oren Milman.

   - bpo-28411(5): Change direct usage of PyInterpreterState.modules to
     PyImport_GetModuleDict().  Also introduce more uniformity in other
     code that deals with sys.modules.  This helps reduce complications
     when working on sys.modules.

   - bpo-28411(6): Switch to the abstract API when dealing with
     ‘PyInterpreterState.modules’.  This allows later support for all
     dict subclasses and other Mapping implementations.  Also add a
     ‘PyImport_GetModule()’ function to reduce a bunch of duplicated
     code.

   - bpo-31411(7): Raise a TypeError instead of SystemError in case
     warnings.onceregistry is not a dictionary.  Patch by Oren Milman.

   - bpo-31344(8): For finer control of tracing behaviour when testing
     the interpreter, two new frame attributes have been added to
     control the emission of particular trace events: ‘f_trace_lines’
     (‘True’ by default) to turn off per-line trace events; and
     ‘f_trace_opcodes’ (‘False’ by default) to turn on per-opcode trace
     events.

   - bpo-31373(9): Fix several possible instances of undefined behavior
     due to floating-point demotions.

   - bpo-30465(10): Location information (‘lineno’ and ‘col_offset’) in
     f-strings is now (mostly) correct.  This fixes tools like flake8
     from showing warnings on the wrong line (typically the first line
     of the file).

   - bpo-30860(11): Consolidate CPython's global runtime state under a
     single struct.  This improves discoverability of the runtime state.

   - bpo-31347(12): Fix possible undefined behavior in
     _PyObject_FastCall_Prepend.

   - bpo-31343(13): Include sys/sysmacros.h for major(), minor(), and
     makedev().  GNU C libray plans to remove the functions from
     sys/types.h.

   - bpo-31291(14): Fix an assertion failure in
     ‘zipimport.zipimporter.get_data’ on Windows, when the return value
     of ‘pathname.replace('/','\\')’ isn't a string.  Patch by Oren
     Milman.

   - bpo-31271(15): Fix an assertion failure in the ‘write()’ method of
     ‘io.TextIOWrapper’, when the encoder doesn't return a bytes object.
     Patch by Oren Milman.

   - bpo-31243(16): Fix a crash in some methods of ‘io.TextIOWrapper’,
     when the decoder's state is invalid.  Patch by Oren Milman.

   - bpo-30721(17): ‘print’ now shows correct usage hint for using
     Python 2 redirection syntax.  Patch by Sanyam Khurana.

   - bpo-31070(18): Fix a race condition in importlib
     _get_module_lock().

   - bpo-30747(19): Add a non-dummy implementation of _Py_atomic_store
     and _Py_atomic_load on MSVC.

   - bpo-31095(20): Fix potential crash during GC caused by ‘tp_dealloc’
     which doesn't call ‘PyObject_GC_UnTrack()’.

   - bpo-31071(21): Avoid masking original TypeError in call with *
     unpacking when other arguments are passed.

   - bpo-30978(22): str.format_map() now passes key lookup exceptions
     through.  Previously any exception was replaced with a KeyError
     exception.

   - bpo-30808(23): Use _Py_atomic API for concurrency-sensitive signal
     state.

   - bpo-30876(24): Relative import from unloaded package now reimports
     the package instead of failing with SystemError.  Relative import
     from non-package now fails with ImportError rather than
     SystemError.

   - bpo-30703(25): Improve signal delivery.  Avoid using
     Py_AddPendingCall from signal handler, to avoid calling
     signal-unsafe functions.  The tests I'm adding here fail without
     the rest of the patch, on Linux and OS X. This means our signal
     delivery logic had defects (some signals could be lost).

   - bpo-30765(26): Avoid blocking in pthread_mutex_lock() when
     PyThread_acquire_lock() is asked not to block.

   - bpo-31161(27): Make sure the 'Missing parentheses' syntax error
     message is only applied to SyntaxError, not to subclasses.  Patch
     by Martijn Pieters.

   - bpo-30814(28): Fixed a race condition when import a submodule from
     a package.

   - bpo-30736(29): The internal unicodedata database has been upgraded
     to Unicode 10.0.

   - bpo-30604(30): Move co_extra_freefuncs from per-thread to
     per-interpreter to avoid crashes.

   - bpo-30597(31): ‘print’ now shows expected input in custom error
     message when used as a Python 2 statement.  Patch by Sanyam
     Khurana.

   - bpo-30682(32): Removed a too-strict assertion that failed for
     certain f-strings, such as eval("f'\n'") and eval("f'\r'").

   - bpo-30501(33): The compiler now produces more optimal code for
     complex condition expressions in the "if", "while" and "assert"
     statement, the "if" expression, and generator expressions and
     comprehensions.

   - bpo-28180(34): Implement PEP 538(35) (legacy C locale coercion).
     This means that when a suitable coercion target locale is
     available, both the core interpreter and locale-aware C extensions
     will assume the use of UTF-8 as the default text encoding, rather
     than ASCII.

   - bpo-30486(36): Allows setting cell values for __closure__.  Patch
     by Lisa Roach.

   - bpo-30537(37): itertools.islice now accepts integer-like objects
     (having an __index__ method) as start, stop, and slice arguments

   - bpo-25324(38): Tokens needed for parsing in Python moved to C.
     ‘COMMENT’, ‘NL’ and ‘ENCODING’.  This way the tokens and tok_names
     in the token module don't get changed when you import the tokenize
     module.

   - bpo-29104(39): Fixed parsing backslashes in f-strings.

   - bpo-27945(40): Fixed various segfaults with dict when input
     collections are mutated during searching, inserting or comparing.
     Based on patches by Duane Griffin and Tim Mitchell.

   - bpo-25794(41): Fixed type.__setattr__() and type.__delattr__() for
     non-interned attribute names.  Based on patch by Eryk Sun.

   - bpo-30039(42): If a KeyboardInterrupt happens when the interpreter
     is in the middle of resuming a chain of nested 'yield from' or
     'await' calls, it's now correctly delivered to the innermost frame.

   - bpo-28974(43): ‘object.__format__(x, '')’ is now equivalent to
     ‘str(x)’ rather than ‘format(str(self), '')’.

   - bpo-30024(44): Circular imports involving absolute imports with
     binding a submodule to a name are now supported.

   - bpo-12414(45): sys.getsizeof() on a code object now returns the
     sizes which includes the code struct and sizes of objects which it
     references.  Patch by Donghee Na.

   - bpo-29839(46): len() now raises ValueError rather than
     OverflowError if __len__() returned a large negative integer.

   - bpo-11913(47): README.rst is now included in the list of distutils
     standard READMEs and therefore included in source distributions.

   - bpo-29914(48): Fixed default implementations of __reduce__ and
     __reduce_ex__().  object.__reduce__() no longer takes arguments,
     object.__reduce_ex__() now requires one argument.

   - bpo-29949(49): Fix memory usage regression of set and frozenset
     object.

   - bpo-29935(50): Fixed error messages in the index() method of tuple,
     list and deque when pass indices of wrong type.

   - bpo-29816(51): Shift operation now has less opportunity to raise
     OverflowError.  ValueError always is raised rather than
     OverflowError for negative counts.  Shifting zero with non-negative
     count always returns zero.

   - bpo-24821(52): Fixed the slowing down to 25 times in the searching
     of some unlucky Unicode characters.

   - bpo-29102(53): Add a unique ID to PyInterpreterState.  This makes
     it easier to identify each subinterpreter.

   - bpo-29894(54): The deprecation warning is emitted if __complex__
     returns an instance of a strict subclass of complex.  In a future
     versions of Python this can be an error.

   - bpo-29859(55): Show correct error messages when any of the
     pthread_* calls in thread_pthread.h fails.

   - bpo-29849(56): Fix a memory leak when an ImportError is raised
     during from import.

   - bpo-28856(57): Fix an oversight that %b format for bytes should
     support objects follow the buffer protocol.

   - bpo-29723(58): The ‘sys.path[0]’ initialization change for
     bpo-29139(59) caused a regression by revealing an inconsistency in
     how sys.path is initialized when executing ‘__main__’ from a
     zipfile, directory, or other import location.  The interpreter now
     consistently avoids ever adding the import location's parent
     directory to ‘sys.path’, and ensures no other ‘sys.path’ entries
     are inadvertently modified when inserting the import location named
     on the command line.

   - bpo-29568(60): Escaped percent "%%" in the format string for
     classic string formatting no longer allows any characters between
     two percents.

   - bpo-29714(61): Fix a regression that bytes format may fail when
     containing zero bytes inside.

   - bpo-29695(62): bool(), float(), list() and tuple() no longer take
     keyword arguments.  The first argument of int() can now be passes
     only as positional argument.

   - bpo-28893(63): Set correct __cause__ for errors about invalid
     awaitables returned from __aiter__ and __anext__.

   - bpo-28876(64): ‘bool(range)’ works even if ‘len(range)’ raises
     *note OverflowError: 84e.

   - bpo-29683(65): Fixes to memory allocation in _PyCode_SetExtra.
     Patch by Brian Coleman.

   - bpo-29684(66): Fix minor regression of
     PyEval_CallObjectWithKeywords.  It should raise TypeError when
     kwargs is not a dict.  But it might cause segv when args=NULL and
     kwargs is not a dict.

   - bpo-28598(67): Support __rmod__ for subclasses of str being called
     before str.__mod__.  Patch by Martijn Pieters.

   - bpo-29607(68): Fix stack_effect computation for CALL_FUNCTION_EX.
     Patch by Matthieu Dartiailh.

   - bpo-29602(69): Fix incorrect handling of signed zeros in complex
     constructor for complex subclasses and for inputs having a
     __complex__ method.  Patch by Serhiy Storchaka.

   - bpo-29347(70): Fixed possibly dereferencing undefined pointers when
     creating weakref objects.

   - bpo-29463(71): Add ‘docstring’ field to Module, ClassDef,
     FunctionDef, and AsyncFunctionDef ast nodes.  docstring is not
     first stmt in their body anymore.  It affects ‘co_firstlineno’ and
     ‘co_lnotab’ of code object for module and class.  (Reverted in
     bpo-32911(72).)

   - bpo-29438(73): Fixed use-after-free problem in key sharing dict.

   - bpo-29546(74): Set the 'path' and 'name' attribute on ImportError
     for ‘from ... import ...’.

   - bpo-29546(75): Improve from-import error message with location

   - bpo-29478(76): If max_line_length=None is specified while using the
     Compat32 policy, it is no longer ignored.  Patch by Mircea Cosbuc.

   - bpo-29319(77): Prevent RunMainFromImporter overwriting sys.path[0].

   - bpo-29337(78): Fixed possible BytesWarning when compare the code
     objects.  Warnings could be emitted at compile time.

   - bpo-29327(79): Fixed a crash when pass the iterable keyword
     argument to sorted().

   - bpo-29034(80): Fix memory leak and use-after-free in os module
     (path_converter).

   - bpo-29159(81): Fix regression in bytes(x) when x.__index__() raises
     Exception.

   - bpo-29049(82): Call _PyObject_GC_TRACK() lazily when calling Python
     function.  Calling function is up to 5% faster.

   - bpo-28927(83): bytes.fromhex() and bytearray.fromhex() now ignore
     all ASCII whitespace, not only spaces.  Patch by Robert Xiao.

   - bpo-28932(84): Do not include <sys/random.h> if it does not exist.

   - bpo-25677(85): Correct the positioning of the syntax error caret
     for indented blocks.  Based on patch by Michael Layzell.

   - bpo-29000(86): Fixed bytes formatting of octals with zero padding
     in alternate form.

   - bpo-18896(87): Python function can now have more than 255
     parameters.  collections.namedtuple() now supports tuples with more
     than 255 elements.

   - bpo-28596(88): The preferred encoding is UTF-8 on Android.  Patch
     written by Chi Hsuan Yen.

   - bpo-22257(89): Clean up interpreter startup (see PEP 432(90)).

   - bpo-26919(91): On Android, operating system data is now always
     encoded/decoded to/from UTF-8, instead of the locale encoding to
     avoid inconsistencies with os.fsencode() and os.fsdecode() which
     are already using UTF-8.

   - bpo-28991(92): functools.lru_cache() was susceptible to an obscure
     reentrancy bug triggerable by a monkey-patched len() function.

   - bpo-28147(93): Fix a memory leak in split-table dictionaries:
     setattr() must not convert combined table into split table.  Patch
     written by INADA Naoki.

   - bpo-28739(94): f-string expressions are no longer accepted as
     docstrings and by ast.literal_eval() even if they do not include
     expressions.

   - bpo-28512(95): Fixed setting the offset attribute of SyntaxError by
     PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().

   - bpo-28918(96): Fix the cross compilation of xxlimited when Python
     has been built with Py_DEBUG defined.

   - bpo-23722(97): Rather than silently producing a class that doesn't
     support zero-argument ‘super()’ in methods, failing to pass the new
     ‘__classcell__’ namespace entry up to ‘type.__new__’ now results in
     a ‘DeprecationWarning’ and a class that supports zero-argument
     ‘super()’.

   - bpo-28797(98): Modifying the class __dict__ inside the __set_name__
     method of a descriptor that is used inside that class no longer
     prevents calling the __set_name__ method of other descriptors.

   - bpo-28799(99): Remove the ‘PyEval_GetCallStats()’ function and
     deprecate the untested and undocumented ‘sys.callstats()’ function.
     Remove the ‘CALL_PROFILE’ special build: use the *note
     sys.setprofile(): 14a8. function, *note cProfile: 20. or *note
     profile: 9d. to profile function calls.

   - bpo-12844(100): More than 255 arguments can now be passed to a
     function.

   - bpo-28782(101): Fix a bug in the implementation ‘yield from’ when
     checking if the next instruction is YIELD_FROM. Regression
     introduced by WORDCODE (bpo-26647(102)).

   - bpo-28774(103): Fix error position of the unicode error in ASCII
     and Latin1 encoders when a string returned by the error handler
     contains multiple non-encodable characters (non-ASCII for the ASCII
     codec, characters out of the U+0000-U+00FF range for Latin1).

   - bpo-28731(104): Optimize _PyDict_NewPresized() to create correct
     size dict.  Improve speed of dict literal with constant keys up to
     30%.

   - bpo-28532(105): Show sys.version when -V option is supplied twice.

   - bpo-27100(106): The with-statement now checks for __enter__ before
     it checks for __exit__.  This gives less confusing error messages
     when both methods are missing.  Patch by Jonathan Ellington.

   - bpo-28746(107): Fix the set_inheritable() file descriptor method on
     platforms that do not have the ioctl FIOCLEX and FIONCLEX commands.

   - bpo-26920(108): Fix not getting the locale's charset upon
     initializing the interpreter, on platforms that do not have
     langinfo.

   - bpo-28648(109): Fixed crash in Py_DecodeLocale() in debug build on
     Mac OS X when decode astral characters.  Patch by Xiang Zhang.

   - bpo-28665(110): Improve speed of the STORE_DEREF opcode by 40%.

   - bpo-19398(111): Extra slash no longer added to sys.path components
     in case of empty compile-time PYTHONPATH components.

   - bpo-28621(112): Sped up converting int to float by reusing faster
     bits counting implementation.  Patch by Adrian Wielgosik.

   - bpo-28580(113): Optimize iterating split table values.  Patch by
     Xiang Zhang.

   - bpo-28583(114): PyDict_SetDefault didn't combine split table when
     needed.  Patch by Xiang Zhang.

   - bpo-28128(115): Deprecation warning for invalid str and byte escape
     sequences now prints better information about where the error
     occurs.  Patch by Serhiy Storchaka and Eric Smith.

   - bpo-28509(116): dict.update() no longer allocate unnecessary large
     memory.

   - bpo-28426(117): Fixed potential crash in
     PyUnicode_AsDecodedObject() in debug build.

   - bpo-28517(118): Fixed of-by-one error in the peephole optimizer
     that caused keeping unreachable code.

   - bpo-28214(119): Improved exception reporting for problematic
     __set_name__ attributes.

   - bpo-23782(120): Fixed possible memory leak in _PyTraceback_Add()
     and exception loss in PyTraceBack_Here().

   - bpo-28183(121): Optimize and cleanup dict iteration.

   - bpo-26081(122): Added C implementation of asyncio.Future.  Original
     patch by Yury Selivanov.

   - bpo-28379(123): Added sanity checks and tests for
     PyUnicode_CopyCharacters().  Patch by Xiang Zhang.

   - bpo-28376(124): The type of long range iterator is now registered
     as Iterator.  Patch by Oren Milman.

   - bpo-28376(125): Creating instances of range_iterator by calling
     range_iterator type now is disallowed.  Calling iter() on range
     instance is the only way.  Patch by Oren Milman.

   - bpo-26906(126): Resolving special methods of uninitialized type now
     causes implicit initialization of the type instead of a fail.

   - bpo-18287(127): PyType_Ready() now checks that tp_name is not NULL.
     Original patch by Niklas Koep.

   - bpo-24098(128): Fixed possible crash when AST is changed in process
     of compiling it.

   - bpo-28201(129): Dict reduces possibility of 2nd conflict in hash
     table when hashes have same lower bits.

   - bpo-28350(130): String constants with null character no longer
     interned.

   - bpo-26617(131): Fix crash when GC runs during weakref callbacks.

   - bpo-27942(132): String constants now interned recursively in tuples
     and frozensets.

   - bpo-28289(133): ImportError.__init__ now resets not specified
     attributes.

   - bpo-21578(134): Fixed misleading error message when ImportError
     called with invalid keyword args.

   - bpo-28203(135): Fix incorrect type in complex(1.0, {2:3}) error
     message.  Patch by Soumya Sharma.

   - bpo-28086(136): Single var-positional argument of tuple subtype was
     passed unscathed to the C-defined function.  Now it is converted to
     exact tuple.

   - bpo-28214(137): Now __set_name__ is looked up on the class instead
     of the instance.

   - bpo-27955(138): Fallback on reading /dev/urandom device when the
     getrandom() syscall fails with EPERM, for example when blocked by
     SECCOMP.

   - bpo-28192(139): Don't import readline in isolated mode.

   - bpo-27441(140): Remove some redundant assignments to ob_size in
     longobject.c.  Thanks Oren Milman.

   - bpo-27222(141): Clean up redundant code in long_rshift function.
     Thanks Oren Milman.

   - Upgrade internal unicode databases to Unicode version 9.0.0.

   - bpo-28131(142): Fix a regression in zipimport's compile_source().
     zipimport should use the same optimization level as the
     interpreter.

   - bpo-28126(143): Replace Py_MEMCPY with memcpy().  Visual Studio can
     properly optimize memcpy().

   - bpo-28120(144): Fix dict.pop() for splitted dictionary when trying
     to remove a "pending key" (Not yet inserted in split-table).  Patch
     by Xiang Zhang.

   - bpo-26182(145): Raise DeprecationWarning when async and await
     keywords are used as variable/attribute/class/function name.

   - bpo-26182(146): Fix a refleak in code that raises
     DeprecationWarning.

   - bpo-28721(147): Fix asynchronous generators aclose() and athrow()
     to handle StopAsyncIteration propagation properly.

   - bpo-26110(148): Speed-up method calls: add LOAD_METHOD and
     CALL_METHOD opcodes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31490

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31471

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31418

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31416

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28411

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28411

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31411

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31344

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31373

   (10) https://bugs.python.org/issue?@action=redirect&bpo=30465

   (11) https://bugs.python.org/issue?@action=redirect&bpo=30860

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31347

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31343

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31291

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31271

   (16) https://bugs.python.org/issue?@action=redirect&bpo=31243

   (17) https://bugs.python.org/issue?@action=redirect&bpo=30721

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31070

   (19) https://bugs.python.org/issue?@action=redirect&bpo=30747

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31095

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31071

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30978

   (23) https://bugs.python.org/issue?@action=redirect&bpo=30808

   (24) https://bugs.python.org/issue?@action=redirect&bpo=30876

   (25) https://bugs.python.org/issue?@action=redirect&bpo=30703

   (26) https://bugs.python.org/issue?@action=redirect&bpo=30765

   (27) https://bugs.python.org/issue?@action=redirect&bpo=31161

   (28) https://bugs.python.org/issue?@action=redirect&bpo=30814

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30736

   (30) https://bugs.python.org/issue?@action=redirect&bpo=30604

   (31) https://bugs.python.org/issue?@action=redirect&bpo=30597

   (32) https://bugs.python.org/issue?@action=redirect&bpo=30682

   (33) https://bugs.python.org/issue?@action=redirect&bpo=30501

   (34) https://bugs.python.org/issue?@action=redirect&bpo=28180

   (35) https://peps.python.org/pep-0538/

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30486

   (37) https://bugs.python.org/issue?@action=redirect&bpo=30537

   (38) https://bugs.python.org/issue?@action=redirect&bpo=25324

   (39) https://bugs.python.org/issue?@action=redirect&bpo=29104

   (40) https://bugs.python.org/issue?@action=redirect&bpo=27945

   (41) https://bugs.python.org/issue?@action=redirect&bpo=25794

   (42) https://bugs.python.org/issue?@action=redirect&bpo=30039

   (43) https://bugs.python.org/issue?@action=redirect&bpo=28974

   (44) https://bugs.python.org/issue?@action=redirect&bpo=30024

   (45) https://bugs.python.org/issue?@action=redirect&bpo=12414

   (46) https://bugs.python.org/issue?@action=redirect&bpo=29839

   (47) https://bugs.python.org/issue?@action=redirect&bpo=11913

   (48) https://bugs.python.org/issue?@action=redirect&bpo=29914

   (49) https://bugs.python.org/issue?@action=redirect&bpo=29949

   (50) https://bugs.python.org/issue?@action=redirect&bpo=29935

   (51) https://bugs.python.org/issue?@action=redirect&bpo=29816

   (52) https://bugs.python.org/issue?@action=redirect&bpo=24821

   (53) https://bugs.python.org/issue?@action=redirect&bpo=29102

   (54) https://bugs.python.org/issue?@action=redirect&bpo=29894

   (55) https://bugs.python.org/issue?@action=redirect&bpo=29859

   (56) https://bugs.python.org/issue?@action=redirect&bpo=29849

   (57) https://bugs.python.org/issue?@action=redirect&bpo=28856

   (58) https://bugs.python.org/issue?@action=redirect&bpo=29723

   (59) https://bugs.python.org/issue?@action=redirect&bpo=29139

   (60) https://bugs.python.org/issue?@action=redirect&bpo=29568

   (61) https://bugs.python.org/issue?@action=redirect&bpo=29714

   (62) https://bugs.python.org/issue?@action=redirect&bpo=29695

   (63) https://bugs.python.org/issue?@action=redirect&bpo=28893

   (64) https://bugs.python.org/issue?@action=redirect&bpo=28876

   (65) https://bugs.python.org/issue?@action=redirect&bpo=29683

   (66) https://bugs.python.org/issue?@action=redirect&bpo=29684

   (67) https://bugs.python.org/issue?@action=redirect&bpo=28598

   (68) https://bugs.python.org/issue?@action=redirect&bpo=29607

   (69) https://bugs.python.org/issue?@action=redirect&bpo=29602

   (70) https://bugs.python.org/issue?@action=redirect&bpo=29347

   (71) https://bugs.python.org/issue?@action=redirect&bpo=29463

   (72) https://bugs.python.org/issue?@action=redirect&bpo=32911

   (73) https://bugs.python.org/issue?@action=redirect&bpo=29438

   (74) https://bugs.python.org/issue?@action=redirect&bpo=29546

   (75) https://bugs.python.org/issue?@action=redirect&bpo=29546

   (76) https://bugs.python.org/issue?@action=redirect&bpo=29478

   (77) https://bugs.python.org/issue?@action=redirect&bpo=29319

   (78) https://bugs.python.org/issue?@action=redirect&bpo=29337

   (79) https://bugs.python.org/issue?@action=redirect&bpo=29327

   (80) https://bugs.python.org/issue?@action=redirect&bpo=29034

   (81) https://bugs.python.org/issue?@action=redirect&bpo=29159

   (82) https://bugs.python.org/issue?@action=redirect&bpo=29049

   (83) https://bugs.python.org/issue?@action=redirect&bpo=28927

   (84) https://bugs.python.org/issue?@action=redirect&bpo=28932

   (85) https://bugs.python.org/issue?@action=redirect&bpo=25677

   (86) https://bugs.python.org/issue?@action=redirect&bpo=29000

   (87) https://bugs.python.org/issue?@action=redirect&bpo=18896

   (88) https://bugs.python.org/issue?@action=redirect&bpo=28596

   (89) https://bugs.python.org/issue?@action=redirect&bpo=22257

   (90) https://peps.python.org/pep-0432/

   (91) https://bugs.python.org/issue?@action=redirect&bpo=26919

   (92) https://bugs.python.org/issue?@action=redirect&bpo=28991

   (93) https://bugs.python.org/issue?@action=redirect&bpo=28147

   (94) https://bugs.python.org/issue?@action=redirect&bpo=28739

   (95) https://bugs.python.org/issue?@action=redirect&bpo=28512

   (96) https://bugs.python.org/issue?@action=redirect&bpo=28918

   (97) https://bugs.python.org/issue?@action=redirect&bpo=23722

   (98) https://bugs.python.org/issue?@action=redirect&bpo=28797

   (99) https://bugs.python.org/issue?@action=redirect&bpo=28799

   (100) https://bugs.python.org/issue?@action=redirect&bpo=12844

   (101) https://bugs.python.org/issue?@action=redirect&bpo=28782

   (102) https://bugs.python.org/issue?@action=redirect&bpo=26647

   (103) https://bugs.python.org/issue?@action=redirect&bpo=28774

   (104) https://bugs.python.org/issue?@action=redirect&bpo=28731

   (105) https://bugs.python.org/issue?@action=redirect&bpo=28532

   (106) https://bugs.python.org/issue?@action=redirect&bpo=27100

   (107) https://bugs.python.org/issue?@action=redirect&bpo=28746

   (108) https://bugs.python.org/issue?@action=redirect&bpo=26920

   (109) https://bugs.python.org/issue?@action=redirect&bpo=28648

   (110) https://bugs.python.org/issue?@action=redirect&bpo=28665

   (111) https://bugs.python.org/issue?@action=redirect&bpo=19398

   (112) https://bugs.python.org/issue?@action=redirect&bpo=28621

   (113) https://bugs.python.org/issue?@action=redirect&bpo=28580

   (114) https://bugs.python.org/issue?@action=redirect&bpo=28583

   (115) https://bugs.python.org/issue?@action=redirect&bpo=28128

   (116) https://bugs.python.org/issue?@action=redirect&bpo=28509

   (117) https://bugs.python.org/issue?@action=redirect&bpo=28426

   (118) https://bugs.python.org/issue?@action=redirect&bpo=28517

   (119) https://bugs.python.org/issue?@action=redirect&bpo=28214

   (120) https://bugs.python.org/issue?@action=redirect&bpo=23782

   (121) https://bugs.python.org/issue?@action=redirect&bpo=28183

   (122) https://bugs.python.org/issue?@action=redirect&bpo=26081

   (123) https://bugs.python.org/issue?@action=redirect&bpo=28379

   (124) https://bugs.python.org/issue?@action=redirect&bpo=28376

   (125) https://bugs.python.org/issue?@action=redirect&bpo=28376

   (126) https://bugs.python.org/issue?@action=redirect&bpo=26906

   (127) https://bugs.python.org/issue?@action=redirect&bpo=18287

   (128) https://bugs.python.org/issue?@action=redirect&bpo=24098

   (129) https://bugs.python.org/issue?@action=redirect&bpo=28201

   (130) https://bugs.python.org/issue?@action=redirect&bpo=28350

   (131) https://bugs.python.org/issue?@action=redirect&bpo=26617

   (132) https://bugs.python.org/issue?@action=redirect&bpo=27942

   (133) https://bugs.python.org/issue?@action=redirect&bpo=28289

   (134) https://bugs.python.org/issue?@action=redirect&bpo=21578

   (135) https://bugs.python.org/issue?@action=redirect&bpo=28203

   (136) https://bugs.python.org/issue?@action=redirect&bpo=28086

   (137) https://bugs.python.org/issue?@action=redirect&bpo=28214

   (138) https://bugs.python.org/issue?@action=redirect&bpo=27955

   (139) https://bugs.python.org/issue?@action=redirect&bpo=28192

   (140) https://bugs.python.org/issue?@action=redirect&bpo=27441

   (141) https://bugs.python.org/issue?@action=redirect&bpo=27222

   (142) https://bugs.python.org/issue?@action=redirect&bpo=28131

   (143) https://bugs.python.org/issue?@action=redirect&bpo=28126

   (144) https://bugs.python.org/issue?@action=redirect&bpo=28120

   (145) https://bugs.python.org/issue?@action=redirect&bpo=26182

   (146) https://bugs.python.org/issue?@action=redirect&bpo=26182

   (147) https://bugs.python.org/issue?@action=redirect&bpo=28721

   (148) https://bugs.python.org/issue?@action=redirect&bpo=26110


File: python.info,  Node: Library<61>,  Next: Documentation<55>,  Prev: Core and Builtins<61>,  Up: Python 3 7 0 alpha 1

1.23.62.3 Library
.................

   - bpo-31499(1): xml.etree: Fix a crash when a parser is part of a
     reference cycle.

   - bpo-31482(2): ‘random.seed()’ now works with bytes in version=1

   - bpo-28556(3): typing.get_type_hints now finds the right globalns
     for classes and modules by default (when no ‘globalns’ was
     specified by the caller).

   - bpo-28556(4): Speed improvements to the ‘typing’ module.  Original
     PRs by Ivan Levkivskyi and Mitar.

   - bpo-31544(5): The C accelerator module of ElementTree ignored
     exceptions raised when looking up TreeBuilder target methods in
     XMLParser().

   - bpo-31234(6): socket.create_connection() now fixes manually a
     reference cycle: clear the variable storing the last exception on
     success.

   - bpo-31457(7): LoggerAdapter objects can now be nested.

   - bpo-31431(8): SSLContext.check_hostname now automatically sets
     SSLContext.verify_mode to ssl.CERT_REQUIRED instead of failing with
     a ValueError.

   - bpo-31233(9): socketserver.ThreadingMixIn now keeps a list of
     non-daemonic threads to wait until all these threads complete in
     server_close().

   - bpo-28638(10): Changed the implementation strategy for
     collections.namedtuple() to substantially reduce the use of exec()
     in favor of precomputed methods.  As a result, the 'verbose'
     parameter and '_source' attribute are no longer supported.  The
     benefits include 1) having a smaller memory footprint for
     applications using multiple named tuples, 2) faster creation of the
     named tuple class (approx 4x to 6x depending on how it is
     measured), and 3) minor speed-ups for instance creation using
     __new__, _make, and _replace.  (The primary patch contributor is
     Jelle Zijlstra with further improvements by INADA Naoki, Serhiy
     Storchaka, and Raymond Hettinger.)

   - bpo-31400(11): Improves SSL error handling to avoid losing error
     numbers.

   - bpo-27629(12): Make return types of SSLContext.wrap_bio() and
     SSLContext.wrap_socket() customizable.

   - bpo-28958(13): ssl.SSLContext() now uses OpenSSL error information
     when a context cannot be instantiated.

   - bpo-28182(14): The SSL module now raises SSLCertVerificationError
     when OpenSSL fails to verify the peer's certificate.  The exception
     contains more information about the error.

   - bpo-27340(15): SSLSocket.sendall() now uses memoryview to create
     slices of data.  This fixes support for all bytes-like object.  It
     is also more efficient and avoids costly copies.

   - bpo-14191(16): A new function
     ‘argparse.ArgumentParser.parse_intermixed_args’ provides the
     ability to parse command lines where there user intermixes options
     and positional arguments.

   - bpo-31178(17): Fix string concatenation bug in rare error path in
     the subprocess module

   - bpo-31350(18): Micro-optimize ‘asyncio._get_running_loop()’ to
     become up to 10% faster.

   - bpo-31170(19): expat: Update libexpat from 2.2.3 to 2.2.4.  Fix
     copying of partial characters for UTF-8 input (libexpat bug 115):
     ‘https://github.com/libexpat/libexpat/issues/115’

   - bpo-29136(20): Add TLS 1.3 cipher suites and OP_NO_TLSv1_3.

   - bpo-1198569(21): ‘string.Template’ subclasses can optionally define
     ‘braceidpattern’ if they want to specify different placeholder
     patterns inside and outside the braces.  If None (the default) it
     falls back to ‘idpattern’.

   - bpo-31326(22): concurrent.futures.ProcessPoolExecutor.shutdown()
     now explicitly closes the call queue.  Moreover,
     shutdown(wait=True) now also join the call queue thread, to prevent
     leaking a dangling thread.

   - bpo-27144(23): The ‘map()’ and ‘as_completed()’ iterators in
     ‘concurrent.futures’ now avoid keeping a reference to yielded
     objects.

   - bpo-31281(24): Fix ‘fileinput.FileInput(files, inplace=True)’ when
     ‘files’ contain ‘pathlib.Path’ objects.

   - bpo-10746(25): Fix ctypes producing wrong PEP 3118(26) type codes
     for integer types.

   - bpo-27584(27): ‘AF_VSOCK’ has been added to the socket interface
     which allows communication between virtual machines and their host.

   - bpo-22536(28): The subprocess module now sets the filename when
     FileNotFoundError is raised on POSIX systems due to the executable
     or cwd not being found.

   - bpo-29741(29): Update some methods in the _pyio module to also
     accept integer types.  Patch by Oren Milman.

   - bpo-31249(30): concurrent.futures: WorkItem.run() used by
     ThreadPoolExecutor now breaks a reference cycle between an
     exception object and the WorkItem object.

   - bpo-31247(31): xmlrpc.server now explicitly breaks reference cycles
     when using sys.exc_info() in code handling exceptions.

   - bpo-23835(32): configparser: reading defaults in the
     ‘ConfigParser()’ constructor is now using ‘read_dict()’, making its
     behavior consistent with the rest of the parser.  Non-string keys
     and values in the defaults dictionary are now being implicitly
     converted to strings.  Patch by James Tocknell.

   - bpo-31238(33): pydoc: the stop() method of the private ServerThread
     class now waits until DocServer.serve_until_quit() completes and
     then explicitly sets its docserver attribute to None to break a
     reference cycle.

   - bpo-5001(34): Many asserts in ‘multiprocessing’ are now more
     informative, and some error types have been changed to more
     specific ones.

   - bpo-31109(35): Convert zipimport to use Argument Clinic.

   - bpo-30102(36): The ssl and hashlib modules now call
     OPENSSL_add_all_algorithms_noconf() on OpenSSL < 1.1.0.  The
     function detects CPU features and enables optimizations on some CPU
     architectures such as POWER8.  Patch is based on research from
     Gustavo Serra Scalet.

   - bpo-18966(37): Non-daemonic threads created by a
     multiprocessing.Process are now joined on child exit.

   - bpo-31183(38): ‘dis’ now works with asynchronous generator and
     coroutine objects.  Patch by George Collins based on diagnosis by
     Luciano Ramalho.

   - bpo-5001(39): There are a number of uninformative asserts in the
     ‘multiprocessing’ module, as noted in issue 5001.  This change
     fixes two of the most potentially problematic ones, since they are
     in error-reporting code, in the
     ‘multiprocessing.managers.convert_to_error’ function.  (It also
     makes more informative a ValueError message.)  The only potentially
     problematic change is that the AssertionError is now a TypeError;
     however, this should also help distinguish it from an
     AssertionError being 'reported' by the function/its caller (such as
     in issue 31169).  - Patch by Allen W. Smith (drallensmith on
     github).

   - bpo-31185(40): Fixed miscellaneous errors in asyncio speedup
     module.

   - bpo-31151(41): socketserver.ForkingMixIn.server_close() now waits
     until all child processes completed to prevent leaking zombie
     processes.

   - bpo-31072(42): Add an ‘include_file’ parameter to
     ‘zipapp.create_archive()’

   - bpo-24700(43): Optimize array.array comparison.  It is now from 10x
     up to 70x faster when comparing arrays holding values of the same
     integer type.

   - bpo-31135(44): ttk: fix the destroy() method of LabeledScale and
     OptionMenu classes.  Call the parent destroy() method even if the
     used attribute doesn't exist.  The LabeledScale.destroy() method
     now also explicitly clears label and scale attributes to help the
     garbage collector to destroy all widgets.

   - bpo-31107(45): Fix ‘copyreg._slotnames()’ mangled attribute
     calculation for classes whose name begins with an underscore.
     Patch by Shane Harvey.

   - bpo-31080(46): Allow ‘logging.config.fileConfig’ to accept kwargs
     and/or args.

   - bpo-30897(47): ‘pathlib.Path’ objects now include an ‘is_mount()’
     method (only implemented on POSIX). This is similar to
     ‘os.path.ismount(p)’.  Patch by Cooper Ry Lees.

   - bpo-31061(48): Fixed a crash when using asyncio and threads.

   - bpo-30987(49): Added support for CAN ISO-TP protocol in the socket
     module.

   - bpo-30522(50): Added a ‘setStream’ method to
     ‘logging.StreamHandler’ to allow the stream to be set after
     creation.

   - bpo-30502(51): Fix handling of long oids in ssl.  Based on patch by
     Christian Heimes.

   - bpo-5288(52): Support tzinfo objects with sub-minute offsets.

   - bpo-30919(53): Fix shared memory performance regression in
     multiprocessing in 3.x.  Shared memory used anonymous memory
     mappings in 2.x, while 3.x mmaps actual files.  Try to be careful
     to do as little disk I/O as possible.

   - bpo-26732(54): Fix too many fds in processes started with the
     "forkserver" method.  A child process would inherit as many fds as
     the number of still-running children.

   - bpo-29403(55): Fix ‘unittest.mock’'s autospec to not fail on
     method-bound builtin functions.  Patch by Aaron Gallagher.

   - bpo-30961(56): Fix decrementing a borrowed reference in
     tracemalloc.

   - bpo-19896(57): Fix multiprocessing.sharedctypes to recognize
     typecodes ‘'q'’ and ‘'Q'’.

   - bpo-30946(58): Remove obsolete code in readline module for
     platforms where GNU readline is older than 2.1 or where select() is
     not available.

   - bpo-25684(59): Change ‘ttk.OptionMenu’ radiobuttons to be unique
     across instances of ‘OptionMenu’.

   - bpo-30886(60): Fix multiprocessing.Queue.join_thread(): it now
     waits until the thread completes, even if the thread was started by
     the same process which created the queue.

   - bpo-29854(61): Fix segfault in readline when using readline's
     history-size option.  Patch by Nir Soffer.

   - bpo-30794(62): Added multiprocessing.Process.kill method to
     terminate using the SIGKILL signal on Unix.

   - bpo-30319(63): socket.close() now ignores ECONNRESET error.

   - bpo-30828(64): Fix out of bounds write in
     ‘asyncio.CFuture.remove_done_callback()’.

   - bpo-30302(65): Use keywords in the ‘repr’ of ‘datetime.timedelta’.

   - bpo-30807(66): signal.setitimer() may disable the timer when passed
     a tiny value.  Tiny values (such as 1e-6) are valid non-zero values
     for setitimer(), which is specified as taking
     microsecond-resolution intervals.  However, on some platform, our
     conversion routine could convert 1e-6 into a zero interval,
     therefore disabling the timer instead of (re-)scheduling it.

   - bpo-30441(67): Fix bug when modifying os.environ while iterating
     over it

   - bpo-29585(68): Avoid importing ‘sysconfig’ from ‘site’ to improve
     startup speed.  Python startup is about 5% faster on Linux and 30%
     faster on macOS.

   - bpo-29293(69): Add missing parameter "n" on
     multiprocessing.Condition.notify().  The doc claims
     multiprocessing.Condition behaves like threading.Condition, but its
     notify() method lacked the optional "n" argument (to specify the
     number of sleepers to wake up) that threading.Condition.notify()
     accepts.

   - bpo-30532(70): Fix email header value parser dropping folding white
     space in certain cases.

   - bpo-30596(71): Add a ‘close()’ method to ‘multiprocessing.Process’.

   - bpo-9146(72): Fix a segmentation fault in _hashopenssl when
     standard hash functions such as md5 are not available in the linked
     OpenSSL library.  As in some special FIPS-140 build environments.

   - bpo-29169(73): Update zlib to 1.2.11.

   - bpo-30119(74): ftplib.FTP.putline() now throws ValueError on
     commands that contains CR or LF. Patch by Donghee Na.

   - bpo-30879(75): os.listdir() and os.scandir() now emit bytes names
     when called with bytes-like argument.

   - bpo-30746(76): Prohibited the '=' character in environment variable
     names in ‘os.putenv()’ and ‘os.spawn*()’.

   - bpo-30664(77): The description of a unittest subtest now preserves
     the order of keyword arguments of TestCase.subTest().

   - bpo-21071(78): struct.Struct.format type is now *note str: 418.
     instead of *note bytes: 1a4.

   - bpo-29212(79): Fix concurrent.futures.thread.ThreadPoolExecutor
     threads to have a non repr() based thread name by default when no
     thread_name_prefix is supplied.  They will now identify themselves
     as "ThreadPoolExecutor-y_n".

   - bpo-29755(80): Fixed the lgettext() family of functions in the
     gettext module.  They now always return bytes.

   - bpo-30616(81): Functional API of enum allows to create empty enums.
     Patched by Donghee Na

   - bpo-30038(82): Fix race condition between signal delivery and
     wakeup file descriptor.  Patch by Nathaniel Smith.

   - bpo-23894(83): lib2to3 now recognizes ‘rb'...'’ and ‘f'...'’
     strings.

   - bpo-24744(84): pkgutil.walk_packages function now raises ValueError
     if 'path' is a string.  Patch by Sanyam Khurana.

   - bpo-24484(85): Avoid race condition in multiprocessing cleanup.

   - bpo-30589(86): Fix multiprocessing.Process.exitcode to return the
     opposite of the signal number when the process is killed by a
     signal (instead of 255) when using the "forkserver" method.

   - bpo-28994(87): The traceback no longer displayed for SystemExit
     raised in a callback registered by atexit.

   - bpo-30508(88): Don't log exceptions if Task/Future "cancel()"
     method was called.

   - bpo-30645(89): Fix path calculation in ‘imp.load_package()’, fixing
     it for cases when a package is only shipped with bytecodes.  Patch
     by Alexandru Ardelean.

   - bpo-11822(90): The dis.dis() function now is able to disassemble
     nested code objects.

   - bpo-30624(91): selectors does not take KeyboardInterrupt and
     SystemExit into account, leaving a fd in a bad state in case of
     error.  Patch by Giampaolo Rodola'.

   - bpo-30595(92): multiprocessing.Queue.get() with a timeout now polls
     its reader in non-blocking mode if it succeeded to acquire the lock
     but the acquire took longer than the timeout.

   - bpo-28556(93): Updates to typing module: Add generic
     AsyncContextManager, add support for ContextManager on all
     versions.  Original PRs by Jelle Zijlstra and Ivan Levkivskyi

   - bpo-30605(94): re.compile() no longer raises a BytesWarning when
     compiling a bytes instance with misplaced inline modifier.  Patch
     by Roy Williams.

   - bpo-29870(95): Fix ssl sockets leaks when connection is aborted in
     asyncio/ssl implementation.  Patch by Michaël Sghaïer.

   - bpo-29743(96): Closing transport during handshake process leaks
     open socket.  Patch by Nikolay Kim

   - bpo-27585(97): Fix waiter cancellation in asyncio.Lock.  Patch by
     Mathieu Sornay.

   - bpo-30014(98): modify() method of poll(), epoll() and devpoll()
     based classes of selectors module is around 10% faster.  Patch by
     Giampaolo Rodola'.

   - bpo-30418(99): On Windows, subprocess.Popen.communicate() now also
     ignore EINVAL on stdin.write() if the child process is still
     running but closed the pipe.

   - bpo-30463(100): Addded empty __slots__ to abc.ABC. This allows
     subclassers to deny __dict__ and __weakref__ creation.  Patch by
     Aaron Hall.

   - bpo-30520(101): Loggers are now pickleable.

   - bpo-30557(102): faulthandler now correctly filters and displays
     exception codes on Windows

   - bpo-30526(103): Add TextIOWrapper.reconfigure() and a
     TextIOWrapper.write_through attribute.

   - bpo-30245(104): Fix possible overflow when organize
     struct.pack_into error message.  Patch by Yuan Liu.

   - bpo-30378(105): Fix the problem that logging.handlers.SysLogHandler
     cannot handle IPv6 addresses.

   - bpo-16500(106): Allow registering at-fork handlers.

   - bpo-30470(107): Deprecate invalid ctypes call protection on
     Windows.  Patch by Mariatta Wijaya.

   - bpo-30414(108): multiprocessing.Queue._feed background running
     thread do not break from main loop on exception.

   - bpo-30003(109): Fix handling escape characters in HZ codec.  Based
     on patch by Ma Lin.

   - bpo-30149(110): inspect.signature() now supports callables with
     variable-argument parameters wrapped with partialmethod.  Patch by
     Donghee Na.

   - bpo-30436(111): importlib.find_spec() raises ModuleNotFoundError
     instead of AttributeError if the specified parent module is not a
     package (i.e.  lacks a __path__ attribute).

   - bpo-30301(112): Fix AttributeError when using SimpleQueue.empty()
     under 'spawn' and 'forkserver' start methods.

   - bpo-30375(113): Warnings emitted when compile a regular expression
     now always point to the line in the user code.  Previously they
     could point into inners of the re module if emitted from inside of
     groups or conditionals.

   - bpo-30329(114): imaplib and poplib now catch the Windows socket
     WSAEINVAL error (code 10022) on shutdown(SHUT_RDWR): An invalid
     operation was attempted.  This error occurs sometimes on SSL
     connections.

   - bpo-29196(115): Removed previously deprecated in Python 2.4 classes
     Plist, Dict and _InternalDict in the plistlib module.  Dict values
     in the result of functions readPlist() and readPlistFromBytes() are
     now normal dicts.  You no longer can use attribute access to access
     items of these dictionaries.

   - bpo-9850(116): The ‘macpath’ is now deprecated and will be removed
     in Python 3.8.

   - bpo-30299(117): Compiling regular expression in debug mode on
     CPython now displays the compiled bytecode in human readable form.

   - bpo-30048(118): Fixed ‘Task.cancel()’ can be ignored when the task
     is running coroutine and the coroutine returned without any more
     ‘await’.

   - bpo-30266(119): contextlib.AbstractContextManager now supports
     anti-registration by setting __enter__ = None or __exit__ = None,
     following the pattern introduced in bpo-25958(120).  Patch by Jelle
     Zijlstra.

   - bpo-30340(121): Enhanced regular expressions optimization.  This
     increased the performance of matching some patterns up to 25 times.

   - bpo-30298(122): Weaken the condition of deprecation warnings for
     inline modifiers.  Now allowed several subsequential inline
     modifiers at the start of the pattern (e.g.  ‘'(?i)(?s)...'’).  In
     verbose mode whitespaces and comments now are allowed before and
     between inline modifiers (e.g.  ‘'(?x) (?i) (?s)...'’).

   - bpo-30285(123): Optimized case-insensitive matching and searching
     of regular expressions.

   - bpo-29990(124): Fix range checking in GB18030 decoder.  Original
     patch by Ma Lin.

   - bpo-29979(125): rewrite cgi.parse_multipart, reusing the
     FieldStorage class and making its results consistent with those of
     FieldStorage for multipart/form-data requests.  Patch by Pierre
     Quentel.

   - bpo-30243(126): Removed the __init__ methods of _json's scanner and
     encoder.  Misusing them could cause memory leaks or crashes.  Now
     scanner and encoder objects are completely initialized in the
     __new__ methods.

   - bpo-30215(127): Compiled regular expression objects with the
     re.LOCALE flag no longer depend on the locale at compile time.
     Only the locale at matching time affects the result of matching.

   - bpo-30185(128): Avoid KeyboardInterrupt tracebacks in forkserver
     helper process when Ctrl-C is received.

   - bpo-30103(129): binascii.b2a_uu() and uu.encode() now support using
     ‘'`'’ as zero instead of space.

   - bpo-28556(130): Various updates to typing module: add
     typing.NoReturn type, use WrapperDescriptorType, minor bug-fixes.
     Original PRs by Jim Fasarakis-Hilliard and Ivan Levkivskyi.

   - bpo-30205(131): Fix getsockname() for unbound AF_UNIX sockets on
     Linux.

   - bpo-30228(132): The seek() and tell() methods of io.FileIO now set
     the internal seekable attribute to avoid one syscall on open() (in
     buffered or text mode).

   - bpo-30190(133): unittest's assertAlmostEqual and
     assertNotAlmostEqual provide a better message in case of failure
     which includes the difference between left and right arguments.
     (patch by Giampaolo Rodola')

   - bpo-30101(134): Add support for curses.A_ITALIC.

   - bpo-29822(135): inspect.isabstract() now works during
     __init_subclass__.  Patch by Nate Soares.

   - bpo-29960(136): Preserve generator state when
     _random.Random.setstate() raises an exception.  Patch by Bryan
     Olson.

   - bpo-30070(137): Fixed leaks and crashes in errors handling in the
     parser module.

   - bpo-22352(138): Column widths in the output of dis.dis() are now
     adjusted for large line numbers and instruction offsets.

   - bpo-30061(139): Fixed crashes in IOBase methods __next__() and
     readlines() when readline() or __next__() respectively return
     non-sizeable object.  Fixed possible other errors caused by not
     checking results of PyObject_Size(), PySequence_Size(), or
     PyMapping_Size().

   - bpo-30218(140): Fix PathLike support for shutil.unpack_archive.
     Patch by Jelle Zijlstra.

   - bpo-10076(141): Compiled regular expression and match objects in
     the re module now support copy.copy() and copy.deepcopy() (they are
     considered atomic).

   - bpo-30068(142): _io._IOBase.readlines will check if it's closed
     first when hint is present.

   - bpo-29694(143): Fixed race condition in pathlib mkdir with flags
     parents=True.  Patch by Armin Rigo.

   - bpo-29692(144): Fixed arbitrary unchaining of RuntimeError
     exceptions in contextlib.contextmanager.  Patch by Siddharth
     Velankar.

   - bpo-26187(145): Test that sqlite3 trace callback is not called
     multiple times when schema is changing.  Indirectly fixed by
     switching to use sqlite3_prepare_v2() in bpo-9303(146).  Patch by
     Aviv Palivoda.

   - bpo-30017(147): Allowed calling the close() method of the zip entry
     writer object multiple times.  Writing to a closed writer now
     always produces a ValueError.

   - bpo-29998(148): Pickling and copying ImportError now preserves name
     and path attributes.

   - bpo-29995(149): re.escape() now escapes only regex special
     characters.

   - bpo-29962(150): Add math.remainder operation, implementing
     remainder as specified in IEEE 754.

   - bpo-29649(151): Improve struct.pack_into() exception messages for
     problems with the buffer size and offset.  Patch by Andrew Nester.

   - bpo-29654(152): Support If-Modified-Since HTTP header (browser
     cache).  Patch by Pierre Quentel.

   - bpo-29931(153): Fixed comparison check for ipaddress.ip_interface
     objects.  Patch by Sanjay Sundaresan.

   - bpo-29953(154): Fixed memory leaks in the replace() method of
     datetime and time objects when pass out of bound fold argument.

   - bpo-29942(155): Fix a crash in itertools.chain.from_iterable when
     encountering long runs of empty iterables.

   - bpo-10030(156): Sped up reading encrypted ZIP files by 2 times.

   - bpo-29204(157): Element.getiterator() and the html parameter of
     XMLParser() were deprecated only in the documentation (since Python
     3.2 and 3.4 correspondingly).  Now using them emits a deprecation
     warning.

   - bpo-27863(158): Fixed multiple crashes in ElementTree caused by
     race conditions and wrong types.

   - bpo-25996(159): Added support of file descriptors in os.scandir()
     on Unix.  os.fwalk() is sped up by 2 times by using os.scandir().

   - bpo-28699(160): Fixed a bug in pools in multiprocessing.pool that
     raising an exception at the very first of an iterable may swallow
     the exception or make the program hang.  Patch by Davin Potts and
     Xiang Zhang.

   - bpo-23890(161): unittest.TestCase.assertRaises() now manually
     breaks a reference cycle to not keep objects alive longer than
     expected.

   - bpo-29901(162): The zipapp module now supports general path-like
     objects, not just pathlib.Path.

   - bpo-25803(163): Avoid incorrect errors raised by
     Path.mkdir(exist_ok=True) when the OS gives priority to errors such
     as EACCES over EEXIST.

   - bpo-29861(164): Release references to tasks, their arguments and
     their results as soon as they are finished in multiprocessing.Pool.

   - bpo-19930(165): The mode argument of os.makedirs() no longer
     affects the file permission bits of newly created
     intermediate-level directories.

   - bpo-29884(166): faulthandler: Restore the old sigaltstack during
     teardown.  Patch by Christophe Zeitouny.

   - bpo-25455(167): Fixed crashes in repr of recursive buffered
     file-like objects.

   - bpo-29800(168): Fix crashes in partial.__repr__ if the keys of
     partial.keywords are not strings.  Patch by Michael Seifert.

   - bpo-8256(169): Fixed possible failing or crashing input() if
     attributes "encoding" or "errors" of sys.stdin or sys.stdout are
     not set or are not strings.

   - bpo-28692(170): Using non-integer value for selecting a plural form
     in gettext is now deprecated.

   - bpo-26121(171): Use C library implementation for math functions
     erf() and erfc().

   - bpo-29619(172): os.stat() and os.DirEntry.inode() now convert inode
     (st_ino) using unsigned integers.

   - bpo-28298(173): Fix a bug that prevented array 'Q', 'L' and 'I'
     from accepting big intables (objects that have __int__) as
     elements.

   - bpo-29645(174): Speed up importing the webbrowser module.
     webbrowser.register() is now thread-safe.

   - bpo-28231(175): The zipfile module now accepts path-like objects
     for external paths.

   - bpo-26915(176): index() and count() methods of
     collections.abc.Sequence now check identity before checking
     equality when do comparisons.

   - bpo-28682(177): Added support for bytes paths in os.fwalk().

   - bpo-29728(178): Add new ‘socket.TCP_NOTSENT_LOWAT’ (Linux 3.12)
     constant.  Patch by Nathaniel J. Smith.

   - bpo-29623(179): Allow use of path-like object as a single argument
     in ConfigParser.read().  Patch by David Ellis.

   - bpo-9303(180): Migrate sqlite3 module to _v2 API. Patch by Aviv
     Palivoda.

   - bpo-28963(181): Fix out of bound iteration in
     asyncio.Future.remove_done_callback implemented in C.

   - bpo-29704(182): asyncio.subprocess.SubprocessStreamProtocol no
     longer closes before all pipes are closed.

   - bpo-29271(183): Fix Task.current_task and Task.all_tasks
     implemented in C to accept None argument as their pure Python
     implementation.

   - bpo-29703(184): Fix asyncio to support instantiation of new event
     loops in child processes.

   - bpo-29615(185): SimpleXMLRPCDispatcher no longer chains KeyError
     (or any other exception) to exception(s) raised in the dispatched
     methods.  Patch by Petr Motejlek.

   - bpo-7769(186): Method register_function() of
     xmlrpc.server.SimpleXMLRPCDispatcher and its subclasses can now be
     used as a decorator.

   - bpo-29376(187): Fix assertion error in
     threading._DummyThread.is_alive().

   - bpo-28624(188): Add a test that checks that cwd parameter of
     Popen() accepts PathLike objects.  Patch by Sayan Chowdhury.

   - bpo-28518(189): Start a transaction implicitly before a DML
     statement.  Patch by Aviv Palivoda.

   - bpo-29742(190): get_extra_info() raises exception if get called on
     closed ssl transport.  Patch by Nikolay Kim.

   - bpo-16285(191): urllib.parse.quote is now based on RFC 3986 and
     hence includes '~' in the set of characters that is not quoted by
     default.  Patch by Christian Theune and Ratnadeep Debnath.

   - bpo-29532(192): Altering a kwarg dictionary passed to
     functools.partial() no longer affects a partial object after
     creation.

   - bpo-29110(193): Fix file object leak in aifc.open() when file is
     given as a filesystem path and is not in valid AIFF format.  Patch
     by Anthony Zhang.

   - bpo-22807(194): Add uuid.SafeUUID and uuid.UUID.is_safe to relay
     information from the platform about whether generated UUIDs are
     generated with a multiprocessing safe method.

   - bpo-29576(195): Improve some deprecations in importlib.  Some
     deprecated methods now emit DeprecationWarnings and have better
     descriptive messages.

   - bpo-29534(196): Fixed different behaviour of Decimal.from_float()
     for _decimal and _pydecimal.  Thanks Andrew Nester.

   - bpo-10379(197): locale.format_string now supports the 'monetary'
     keyword argument, and locale.format is deprecated.

   - bpo-29851(198): importlib.reload() now raises ModuleNotFoundError
     if the module lacks a spec.

   - bpo-28556(199): Various updates to typing module: typing.Counter,
     typing.ChainMap, improved ABC caching, etc.  Original PRs by Jelle
     Zijlstra, Ivan Levkivskyi, Manuel Krebber, and Łukasz Langa.

   - bpo-29100(200): Fix datetime.fromtimestamp() regression introduced
     in Python 3.6.0: check minimum and maximum years.

   - bpo-29416(201): Prevent infinite loop in pathlib.Path.mkdir

   - bpo-29444(202): Fixed out-of-bounds buffer access in the group()
     method of the match object.  Based on patch by WGH.

   - bpo-29377(203): Add WrapperDescriptorType, MethodWrapperType, and
     MethodDescriptorType built-in types to types module.  Original
     patch by Manuel Krebber.

   - bpo-29218(204): Unused install_misc command is now removed.  It has
     been documented as unused since 2000.  Patch by Eric N. Vander
     Weele.

   - bpo-29368(205): The extend() method is now called instead of the
     append() method when unpickle collections.deque and other list-like
     objects.  This can speed up unpickling to 2 times.

   - bpo-29338(206): The help of a builtin or extension class now
     includes the constructor signature if __text_signature__ is
     provided for the class.

   - bpo-29335(207): Fix subprocess.Popen.wait() when the child process
     has exited to a stopped instead of terminated state (ex: when under
     ptrace).

   - bpo-29290(208): Fix a regression in argparse that help messages
     would wrap at non-breaking spaces.

   - bpo-28735(209): Fixed the comparison of mock.MagickMock with
     mock.ANY.

   - bpo-29197(210): Removed deprecated function ntpath.splitunc().

   - bpo-29210(211): Removed support of deprecated argument "exclude" in
     tarfile.TarFile.add().

   - bpo-29219(212): Fixed infinite recursion in the repr of
     uninitialized ctypes.CDLL instances.

   - bpo-29192(213): Removed deprecated features in the http.cookies
     module.

   - bpo-29193(214): A format string argument for
     string.Formatter.format() is now positional-only.

   - bpo-29195(215): Removed support of deprecated undocumented keyword
     arguments in methods of regular expression objects.

   - bpo-28969(216): Fixed race condition in C implementation of
     functools.lru_cache.  KeyError could be raised when cached function
     with full cache was simultaneously called from different threads
     with the same uncached arguments.

   - bpo-20804(217): The unittest.mock.sentinel attributes now preserve
     their identity when they are copied or pickled.

   - bpo-29142(218): In urllib.request, suffixes in no_proxy environment
     variable with leading dots could match related hostnames again
     (e.g.  .b.c matches a.b.c).  Patch by Milan Oberkirch.

   - bpo-28961(219): Fix unittest.mock._Call helper: don't ignore the
     name parameter anymore.  Patch written by Jiajun Huang.

   - bpo-15812(220): inspect.getframeinfo() now correctly shows the
     first line of a context.  Patch by Sam Breese.

   - bpo-28985(221): Update authorizer constants in sqlite3 module.
     Patch by Dingyuan Wang.

   - bpo-29079(222): Prevent infinite loop in pathlib.resolve() on
     Windows

   - bpo-13051(223): Fixed recursion errors in large or resized
     curses.textpad.Textbox.  Based on patch by Tycho Andersen.

   - bpo-9770(224): curses.ascii predicates now work correctly with
     negative integers.

   - bpo-28427(225): old keys should not remove new values from
     WeakValueDictionary when collecting from another thread.

   - bpo-28923(226): Remove editor artifacts from Tix.py.

   - bpo-28871(227): Fixed a crash when deallocate deep ElementTree.

   - bpo-19542(228): Fix bugs in WeakValueDictionary.setdefault() and
     WeakValueDictionary.pop() when a GC collection happens in another
     thread.

   - bpo-20191(229): Fixed a crash in resource.prlimit() when passing a
     sequence that doesn't own its elements as limits.

   - bpo-16255(230): subprocess.Popen uses /system/bin/sh on Android as
     the shell, instead of /bin/sh.

   - bpo-28779(231): multiprocessing.set_forkserver_preload() would
     crash the forkserver process if a preloaded module instantiated
     some multiprocessing objects such as locks.

   - bpo-26937(232): The chown() method of the tarfile.TarFile class
     does not fail now when the grp module cannot be imported, as for
     example on Android platforms.

   - bpo-28847(233): dbm.dumb now supports reading read-only files and
     no longer writes the index file when it is not changed.  A
     deprecation warning is now emitted if the index file is missed and
     recreated in the 'r' and 'w' modes (will be an error in future
     Python releases).

   - bpo-27030(234): Unknown escapes consisting of ‘'\'’ and an ASCII
     letter in re.sub() replacement templates regular expressions now
     are errors.

   - bpo-28835(235): Fix a regression introduced in
     warnings.catch_warnings(): call warnings.showwarning() if it was
     overridden inside the context manager.

   - bpo-27172(236): To assist with upgrades from 2.7, the previously
     documented deprecation of ‘inspect.getfullargspec()’ has been
     reversed.  This decision may be revisited again after the Python
     2.7 branch is no longer officially supported.

   - bpo-28740(237): Add sys.getandroidapilevel(): return the build time
     API version of Android as an integer.  Function only available on
     Android.

   - bpo-26273(238): Add new ‘socket.TCP_CONGESTION’ (Linux 2.6.13) and
     ‘socket.TCP_USER_TIMEOUT’ (Linux 2.6.37) constants.  Patch written
     by Omar Sandoval.

   - bpo-28752(239): Restored the __reduce__() methods of datetime
     objects.

   - bpo-28727(240): Regular expression patterns, _sre.SRE_Pattern
     objects created by re.compile(), become comparable (only x==y and
     x!=y operators).  This change should fix the bpo-18383(241): don't
     duplicate warning filters when the warnings module is reloaded
     (thing usually only done in unit tests).

   - bpo-20572(242): Remove the subprocess.Popen.wait endtime parameter.
     It was deprecated in 3.4 and undocumented prior to that.

   - bpo-25659(243): In ctypes, prevent a crash calling the
     from_buffer() and from_buffer_copy() methods on abstract classes
     like Array.

   - bpo-28548(244): In the "http.server" module, parse the protocol
     version if possible, to avoid using HTTP 0.9 in some error
     responses.

   - bpo-19717(245): Makes Path.resolve() succeed on paths that do not
     exist.  Patch by Vajrasky Kok

   - bpo-28563(246): Fixed possible DoS and arbitrary code execution
     when handle plural form selections in the gettext module.  The
     expression parser now supports exact syntax supported by GNU
     gettext.

   - bpo-28387(247): Fixed possible crash in _io.TextIOWrapper
     deallocator when the garbage collector is invoked in other thread.
     Based on patch by Sebastian Cufre.

   - bpo-27517(248): LZMA compressor and decompressor no longer raise
     exceptions if given empty data twice.  Patch by Benjamin Fogle.

   - bpo-28549(249): Fixed segfault in curses's addch() with ncurses6.

   - bpo-28449(250): tarfile.open() with mode "r" or "r:" now tries to
     open a tar file with compression before trying to open it without
     compression.  Otherwise it had 50% chance failed with
     ignore_zeros=True.

   - bpo-23262(251): The webbrowser module now supports Firefox 36+ and
     derived browsers.  Based on patch by Oleg Broytman.

   - bpo-24241(252): The webbrowser in an X environment now prefers
     using the default browser directly.  Also, the webbrowser
     register() function now has a documented 'preferred' argument, to
     specify browsers to be returned by get() with no arguments.  Patch
     by David Steele

   - bpo-27939(253): Fixed bugs in tkinter.ttk.LabeledScale and
     tkinter.Scale caused by representing the scale as float value
     internally in Tk.  tkinter.IntVar now works if float value is set
     to underlying Tk variable.

   - bpo-28255(254): calendar.TextCalendar.prweek() no longer prints a
     space after a weeks's calendar.  calendar.TextCalendar.pryear() no
     longer prints redundant newline after a year's calendar.  Based on
     patch by Xiang Zhang.

   - bpo-28255(255): calendar.TextCalendar.prmonth() no longer prints a
     space at the start of new line after printing a month's calendar.
     Patch by Xiang Zhang.

   - bpo-20491(256): The textwrap.TextWrapper class now honors
     non-breaking spaces.  Based on patch by Kaarle Ritvanen.

   - bpo-28353(257): os.fwalk() no longer fails on broken links.

   - bpo-28430(258): Fix iterator of C implemented asyncio.Future
     doesn't accept non-None value is passed to it.send(val).

   - bpo-27025(259): Generated names for Tkinter widgets now start by
     the "!"  prefix for readability.

   - bpo-25464(260): Fixed HList.header_exists() in tkinter.tix module
     by addin a workaround to Tix library bug.

   - bpo-28488(261): shutil.make_archive() no longer adds entry "./" to
     ZIP archive.

   - bpo-25953(262): re.sub() now raises an error for invalid numerical
     group reference in replacement template even if the pattern is not
     found in the string.  Error message for invalid group reference now
     includes the group index and the position of the reference.  Based
     on patch by SilentGhost.

   - bpo-28469(263): timeit now uses the sequence 1, 2, 5, 10, 20,
     50,...  instead of 1, 10, 100,...  for autoranging.

   - bpo-28115(264): Command-line interface of the zipfile module now
     uses argparse.  Added support of long options.

   - bpo-18219(265): Optimize csv.DictWriter for large number of
     columns.  Patch by Mariatta Wijaya.

   - bpo-28448(266): Fix C implemented asyncio.Future didn't work on
     Windows.

   - bpo-23214(267): In the "io" module, the argument to BufferedReader
     and BytesIO's read1() methods is now optional and can be -1,
     matching the BufferedIOBase specification.

   - bpo-28480(268): Fix error building socket module when
     multithreading is disabled.

   - bpo-28240(269): timeit: remove ‘-c/--clock’ and ‘-t/--time’ command
     line options which were deprecated since Python 3.3.

   - bpo-28240(270): timeit now repeats the benchmarks 5 times instead
     of only 3 to make benchmarks more reliable.

   - bpo-28240(271): timeit autorange now uses a single loop iteration
     if the benchmark takes less than 10 seconds, instead of 10
     iterations.  "python3 -m timeit -s 'import time' 'time.sleep(1)'"
     now takes 4 seconds instead of 40 seconds.

   - Distutils.sdist now looks for README and setup.py files with case
     sensitivity.  This behavior matches that found in Setuptools 6.0
     and later.  See setuptools 100(272) for rationale.

   - bpo-24452(273): Make webbrowser support Chrome on Mac OS X. Patch
     by Ned Batchelder.

   - bpo-20766(274): Fix references leaked by pdb in the handling of
     SIGINT handlers.

   - bpo-27998(275): Fixed bytes path support in os.scandir() on
     Windows.  Patch by Eryk Sun.

   - bpo-28317(276): The disassembler now decodes FORMAT_VALUE argument.

   - bpo-28380(277): unittest.mock Mock autospec functions now properly
     support assert_called, assert_not_called, and assert_called_once.

   - bpo-28229(278): lzma module now supports pathlib.

   - bpo-28321(279): Fixed writing non-BMP characters with binary format
     in plistlib.

   - bpo-28225(280): bz2 module now supports pathlib.  Initial patch by
     Ethan Furman.

   - bpo-28227(281): gzip now supports pathlib.  Patch by Ethan Furman.

   - bpo-28332(282): Deprecated silent truncations in socket.htons and
     socket.ntohs.  Original patch by Oren Milman.

   - bpo-27358(283): Optimized merging var-keyword arguments and
     improved error message when passing a non-mapping as a var-keyword
     argument.

   - bpo-28257(284): Improved error message when passing a non-iterable
     as a var-positional argument.  Added opcode
     BUILD_TUPLE_UNPACK_WITH_CALL.

   - bpo-28322(285): Fixed possible crashes when unpickle itertools
     objects from incorrect pickle data.  Based on patch by John Leitch.

   - bpo-28228(286): imghdr now supports pathlib.

   - bpo-28226(287): compileall now supports pathlib.

   - bpo-28314(288): Fix function declaration (C flags) for the
     getiterator() method of xml.etree.ElementTree.Element.

   - bpo-28148(289): Stop using localtime() and gmtime() in the time
     module.  Introduced platform independent _PyTime_localtime API that
     is similar to POSIX localtime_r, but available on all platforms.
     Patch by Ed Schouten.

   - bpo-28253(290): Fixed calendar functions for extreme months:
     0001-01 and 9999-12.  Methods itermonthdays() and itermonthdays2()
     are reimplemented so that they don't call itermonthdates() which
     can cause datetime.date under/overflow.

   - bpo-28275(291): Fixed possible use after free in the decompress()
     methods of the LZMADecompressor and BZ2Decompressor classes.
     Original patch by John Leitch.

   - bpo-27897(292): Fixed possible crash in
     sqlite3.Connection.create_collation() if pass invalid string-like
     object as a name.  Patch by Xiang Zhang.

   - bpo-18844(293): random.choices() now has k as a keyword-only
     argument to improve the readability of common cases and come into
     line with the signature used in other languages.

   - bpo-18893(294): Fix invalid exception handling in
     Lib/ctypes/macholib/dyld.py.  Patch by Madison May.

   - bpo-27611(295): Fixed support of default root window in the
     tkinter.tix module.  Added the master parameter in the DisplayStyle
     constructor.

   - bpo-27348(296): In the traceback module, restore the formatting of
     exception messages like "Exception: None".  This fixes a regression
     introduced in 3.5a2.

   - bpo-25651(297): Allow false values to be used for msg parameter of
     subTest().

   - bpo-27778(298): Fix a memory leak in os.getrandom() when the
     getrandom() is interrupted by a signal and a signal handler raises
     a Python exception.

   - bpo-28200(299): Fix memory leak on Windows in the os module (fix
     path_converter() function).

   - bpo-25400(300): RobotFileParser now correctly returns default
     values for crawl_delay and request_rate.  Initial patch by Peter
     Wirtz.

   - bpo-27932(301): Prevent memory leak in win32_ver().

   - Fix UnboundLocalError in socket._sendfile_use_sendfile.

   - bpo-28075(302): Check for ERROR_ACCESS_DENIED in Windows
     implementation of os.stat().  Patch by Eryk Sun.

   - bpo-22493(303): Warning message emitted by using inline flags in
     the middle of regular expression now contains a (truncated) regex
     pattern.  Patch by Tim Graham.

   - bpo-25270(304): Prevent codecs.escape_encode() from raising
     SystemError when an empty bytestring is passed.

   - bpo-28181(305): Get antigravity over HTTPS. Patch by Kaartic
     Sivaraam.

   - bpo-25895(306): Enable WebSocket URL schemes in
     urllib.parse.urljoin.  Patch by Gergely Imreh and Markus
     Holtermann.

   - bpo-28114(307): Fix a crash in parse_envlist() when env contains
     byte strings.  Patch by Eryk Sun.

   - bpo-27599(308): Fixed buffer overrun in binascii.b2a_qp() and
     binascii.a2b_qp().

   - bpo-27906(309): Fix socket accept exhaustion during high TCP
     traffic.  Patch by Kevin Conway.

   - bpo-28174(310): Handle when SO_REUSEPORT isn't properly supported.
     Patch by Seth Michael Larson.

   - bpo-26654(311): Inspect functools.partial in
     asyncio.Handle.__repr__.  Patch by iceboy.

   - bpo-26909(312): Fix slow pipes IO in asyncio.  Patch by INADA
     Naoki.

   - bpo-28176(313): Fix callbacks race in
     asyncio.SelectorLoop.sock_connect.

   - bpo-27759(314): Fix selectors incorrectly retain invalid file
     descriptors.  Patch by Mark Williams.

   - bpo-28325(315): Remove vestigial MacOS 9 macurl2path module and its
     tests.

   - bpo-28368(316): Refuse monitoring processes if the child watcher
     has no loop attached.  Patch by Vincent Michel.

   - bpo-28369(317): Raise RuntimeError when transport's FD is used with
     add_reader, add_writer, etc.

   - bpo-28370(318): Speedup asyncio.StreamReader.readexactly.  Patch by
     Коренберг Марк.

   - bpo-28371(319): Deprecate passing asyncio.Handles to
     run_in_executor.

   - bpo-28372(320): Fix asyncio to support formatting of non-python
     coroutines.

   - bpo-28399(321): Remove UNIX socket from FS before binding.  Patch
     by Коренберг Марк.

   - bpo-27972(322): Prohibit Tasks to await on themselves.

   - bpo-24142(323): Reading a corrupt config file left configparser in
     an invalid state.  Original patch by Florian Höch.

   - bpo-29581(324): ABCMeta.__new__ now accepts ‘**kwargs’, allowing
     abstract base classes to use keyword parameters in
     __init_subclass__.  Patch by Nate Soares.

   - bpo-25532(325): inspect.unwrap() will now only try to unwrap an
     object sys.getrecursionlimit() times, to protect against objects
     which create a new object on every attribute access.

   - bpo-30177(326): path.resolve(strict=False) no longer cuts the path
     after the first element not present in the filesystem.  Patch by
     Antoine Pietri.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31499

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31482

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31544

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31234

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31457

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31431

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31233

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28638

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31400

   (12) https://bugs.python.org/issue?@action=redirect&bpo=27629

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28958

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28182

   (15) https://bugs.python.org/issue?@action=redirect&bpo=27340

   (16) https://bugs.python.org/issue?@action=redirect&bpo=14191

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31178

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31350

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31170

   (20) https://bugs.python.org/issue?@action=redirect&bpo=29136

   (21) https://bugs.python.org/issue?@action=redirect&bpo=1198569

   (22) https://bugs.python.org/issue?@action=redirect&bpo=31326

   (23) https://bugs.python.org/issue?@action=redirect&bpo=27144

   (24) https://bugs.python.org/issue?@action=redirect&bpo=31281

   (25) https://bugs.python.org/issue?@action=redirect&bpo=10746

   (26) https://peps.python.org/pep-3118/

   (27) https://bugs.python.org/issue?@action=redirect&bpo=27584

   (28) https://bugs.python.org/issue?@action=redirect&bpo=22536

   (29) https://bugs.python.org/issue?@action=redirect&bpo=29741

   (30) https://bugs.python.org/issue?@action=redirect&bpo=31249

   (31) https://bugs.python.org/issue?@action=redirect&bpo=31247

   (32) https://bugs.python.org/issue?@action=redirect&bpo=23835

   (33) https://bugs.python.org/issue?@action=redirect&bpo=31238

   (34) https://bugs.python.org/issue?@action=redirect&bpo=5001

   (35) https://bugs.python.org/issue?@action=redirect&bpo=31109

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30102

   (37) https://bugs.python.org/issue?@action=redirect&bpo=18966

   (38) https://bugs.python.org/issue?@action=redirect&bpo=31183

   (39) https://bugs.python.org/issue?@action=redirect&bpo=5001

   (40) https://bugs.python.org/issue?@action=redirect&bpo=31185

   (41) https://bugs.python.org/issue?@action=redirect&bpo=31151

   (42) https://bugs.python.org/issue?@action=redirect&bpo=31072

   (43) https://bugs.python.org/issue?@action=redirect&bpo=24700

   (44) https://bugs.python.org/issue?@action=redirect&bpo=31135

   (45) https://bugs.python.org/issue?@action=redirect&bpo=31107

   (46) https://bugs.python.org/issue?@action=redirect&bpo=31080

   (47) https://bugs.python.org/issue?@action=redirect&bpo=30897

   (48) https://bugs.python.org/issue?@action=redirect&bpo=31061

   (49) https://bugs.python.org/issue?@action=redirect&bpo=30987

   (50) https://bugs.python.org/issue?@action=redirect&bpo=30522

   (51) https://bugs.python.org/issue?@action=redirect&bpo=30502

   (52) https://bugs.python.org/issue?@action=redirect&bpo=5288

   (53) https://bugs.python.org/issue?@action=redirect&bpo=30919

   (54) https://bugs.python.org/issue?@action=redirect&bpo=26732

   (55) https://bugs.python.org/issue?@action=redirect&bpo=29403

   (56) https://bugs.python.org/issue?@action=redirect&bpo=30961

   (57) https://bugs.python.org/issue?@action=redirect&bpo=19896

   (58) https://bugs.python.org/issue?@action=redirect&bpo=30946

   (59) https://bugs.python.org/issue?@action=redirect&bpo=25684

   (60) https://bugs.python.org/issue?@action=redirect&bpo=30886

   (61) https://bugs.python.org/issue?@action=redirect&bpo=29854

   (62) https://bugs.python.org/issue?@action=redirect&bpo=30794

   (63) https://bugs.python.org/issue?@action=redirect&bpo=30319

   (64) https://bugs.python.org/issue?@action=redirect&bpo=30828

   (65) https://bugs.python.org/issue?@action=redirect&bpo=30302

   (66) https://bugs.python.org/issue?@action=redirect&bpo=30807

   (67) https://bugs.python.org/issue?@action=redirect&bpo=30441

   (68) https://bugs.python.org/issue?@action=redirect&bpo=29585

   (69) https://bugs.python.org/issue?@action=redirect&bpo=29293

   (70) https://bugs.python.org/issue?@action=redirect&bpo=30532

   (71) https://bugs.python.org/issue?@action=redirect&bpo=30596

   (72) https://bugs.python.org/issue?@action=redirect&bpo=9146

   (73) https://bugs.python.org/issue?@action=redirect&bpo=29169

   (74) https://bugs.python.org/issue?@action=redirect&bpo=30119

   (75) https://bugs.python.org/issue?@action=redirect&bpo=30879

   (76) https://bugs.python.org/issue?@action=redirect&bpo=30746

   (77) https://bugs.python.org/issue?@action=redirect&bpo=30664

   (78) https://bugs.python.org/issue?@action=redirect&bpo=21071

   (79) https://bugs.python.org/issue?@action=redirect&bpo=29212

   (80) https://bugs.python.org/issue?@action=redirect&bpo=29755

   (81) https://bugs.python.org/issue?@action=redirect&bpo=30616

   (82) https://bugs.python.org/issue?@action=redirect&bpo=30038

   (83) https://bugs.python.org/issue?@action=redirect&bpo=23894

   (84) https://bugs.python.org/issue?@action=redirect&bpo=24744

   (85) https://bugs.python.org/issue?@action=redirect&bpo=24484

   (86) https://bugs.python.org/issue?@action=redirect&bpo=30589

   (87) https://bugs.python.org/issue?@action=redirect&bpo=28994

   (88) https://bugs.python.org/issue?@action=redirect&bpo=30508

   (89) https://bugs.python.org/issue?@action=redirect&bpo=30645

   (90) https://bugs.python.org/issue?@action=redirect&bpo=11822

   (91) https://bugs.python.org/issue?@action=redirect&bpo=30624

   (92) https://bugs.python.org/issue?@action=redirect&bpo=30595

   (93) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (94) https://bugs.python.org/issue?@action=redirect&bpo=30605

   (95) https://bugs.python.org/issue?@action=redirect&bpo=29870

   (96) https://bugs.python.org/issue?@action=redirect&bpo=29743

   (97) https://bugs.python.org/issue?@action=redirect&bpo=27585

   (98) https://bugs.python.org/issue?@action=redirect&bpo=30014

   (99) https://bugs.python.org/issue?@action=redirect&bpo=30418

   (100) https://bugs.python.org/issue?@action=redirect&bpo=30463

   (101) https://bugs.python.org/issue?@action=redirect&bpo=30520

   (102) https://bugs.python.org/issue?@action=redirect&bpo=30557

   (103) https://bugs.python.org/issue?@action=redirect&bpo=30526

   (104) https://bugs.python.org/issue?@action=redirect&bpo=30245

   (105) https://bugs.python.org/issue?@action=redirect&bpo=30378

   (106) https://bugs.python.org/issue?@action=redirect&bpo=16500

   (107) https://bugs.python.org/issue?@action=redirect&bpo=30470

   (108) https://bugs.python.org/issue?@action=redirect&bpo=30414

   (109) https://bugs.python.org/issue?@action=redirect&bpo=30003

   (110) https://bugs.python.org/issue?@action=redirect&bpo=30149

   (111) https://bugs.python.org/issue?@action=redirect&bpo=30436

   (112) https://bugs.python.org/issue?@action=redirect&bpo=30301

   (113) https://bugs.python.org/issue?@action=redirect&bpo=30375

   (114) https://bugs.python.org/issue?@action=redirect&bpo=30329

   (115) https://bugs.python.org/issue?@action=redirect&bpo=29196

   (116) https://bugs.python.org/issue?@action=redirect&bpo=9850

   (117) https://bugs.python.org/issue?@action=redirect&bpo=30299

   (118) https://bugs.python.org/issue?@action=redirect&bpo=30048

   (119) https://bugs.python.org/issue?@action=redirect&bpo=30266

   (120) https://bugs.python.org/issue?@action=redirect&bpo=25958

   (121) https://bugs.python.org/issue?@action=redirect&bpo=30340

   (122) https://bugs.python.org/issue?@action=redirect&bpo=30298

   (123) https://bugs.python.org/issue?@action=redirect&bpo=30285

   (124) https://bugs.python.org/issue?@action=redirect&bpo=29990

   (125) https://bugs.python.org/issue?@action=redirect&bpo=29979

   (126) https://bugs.python.org/issue?@action=redirect&bpo=30243

   (127) https://bugs.python.org/issue?@action=redirect&bpo=30215

   (128) https://bugs.python.org/issue?@action=redirect&bpo=30185

   (129) https://bugs.python.org/issue?@action=redirect&bpo=30103

   (130) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (131) https://bugs.python.org/issue?@action=redirect&bpo=30205

   (132) https://bugs.python.org/issue?@action=redirect&bpo=30228

   (133) https://bugs.python.org/issue?@action=redirect&bpo=30190

   (134) https://bugs.python.org/issue?@action=redirect&bpo=30101

   (135) https://bugs.python.org/issue?@action=redirect&bpo=29822

   (136) https://bugs.python.org/issue?@action=redirect&bpo=29960

   (137) https://bugs.python.org/issue?@action=redirect&bpo=30070

   (138) https://bugs.python.org/issue?@action=redirect&bpo=22352

   (139) https://bugs.python.org/issue?@action=redirect&bpo=30061

   (140) https://bugs.python.org/issue?@action=redirect&bpo=30218

   (141) https://bugs.python.org/issue?@action=redirect&bpo=10076

   (142) https://bugs.python.org/issue?@action=redirect&bpo=30068

   (143) https://bugs.python.org/issue?@action=redirect&bpo=29694

   (144) https://bugs.python.org/issue?@action=redirect&bpo=29692

   (145) https://bugs.python.org/issue?@action=redirect&bpo=26187

   (146) https://bugs.python.org/issue?@action=redirect&bpo=9303

   (147) https://bugs.python.org/issue?@action=redirect&bpo=30017

   (148) https://bugs.python.org/issue?@action=redirect&bpo=29998

   (149) https://bugs.python.org/issue?@action=redirect&bpo=29995

   (150) https://bugs.python.org/issue?@action=redirect&bpo=29962

   (151) https://bugs.python.org/issue?@action=redirect&bpo=29649

   (152) https://bugs.python.org/issue?@action=redirect&bpo=29654

   (153) https://bugs.python.org/issue?@action=redirect&bpo=29931

   (154) https://bugs.python.org/issue?@action=redirect&bpo=29953

   (155) https://bugs.python.org/issue?@action=redirect&bpo=29942

   (156) https://bugs.python.org/issue?@action=redirect&bpo=10030

   (157) https://bugs.python.org/issue?@action=redirect&bpo=29204

   (158) https://bugs.python.org/issue?@action=redirect&bpo=27863

   (159) https://bugs.python.org/issue?@action=redirect&bpo=25996

   (160) https://bugs.python.org/issue?@action=redirect&bpo=28699

   (161) https://bugs.python.org/issue?@action=redirect&bpo=23890

   (162) https://bugs.python.org/issue?@action=redirect&bpo=29901

   (163) https://bugs.python.org/issue?@action=redirect&bpo=25803

   (164) https://bugs.python.org/issue?@action=redirect&bpo=29861

   (165) https://bugs.python.org/issue?@action=redirect&bpo=19930

   (166) https://bugs.python.org/issue?@action=redirect&bpo=29884

   (167) https://bugs.python.org/issue?@action=redirect&bpo=25455

   (168) https://bugs.python.org/issue?@action=redirect&bpo=29800

   (169) https://bugs.python.org/issue?@action=redirect&bpo=8256

   (170) https://bugs.python.org/issue?@action=redirect&bpo=28692

   (171) https://bugs.python.org/issue?@action=redirect&bpo=26121

   (172) https://bugs.python.org/issue?@action=redirect&bpo=29619

   (173) https://bugs.python.org/issue?@action=redirect&bpo=28298

   (174) https://bugs.python.org/issue?@action=redirect&bpo=29645

   (175) https://bugs.python.org/issue?@action=redirect&bpo=28231

   (176) https://bugs.python.org/issue?@action=redirect&bpo=26915

   (177) https://bugs.python.org/issue?@action=redirect&bpo=28682

   (178) https://bugs.python.org/issue?@action=redirect&bpo=29728

   (179) https://bugs.python.org/issue?@action=redirect&bpo=29623

   (180) https://bugs.python.org/issue?@action=redirect&bpo=9303

   (181) https://bugs.python.org/issue?@action=redirect&bpo=28963

   (182) https://bugs.python.org/issue?@action=redirect&bpo=29704

   (183) https://bugs.python.org/issue?@action=redirect&bpo=29271

   (184) https://bugs.python.org/issue?@action=redirect&bpo=29703

   (185) https://bugs.python.org/issue?@action=redirect&bpo=29615

   (186) https://bugs.python.org/issue?@action=redirect&bpo=7769

   (187) https://bugs.python.org/issue?@action=redirect&bpo=29376

   (188) https://bugs.python.org/issue?@action=redirect&bpo=28624

   (189) https://bugs.python.org/issue?@action=redirect&bpo=28518

   (190) https://bugs.python.org/issue?@action=redirect&bpo=29742

   (191) https://bugs.python.org/issue?@action=redirect&bpo=16285

   (192) https://bugs.python.org/issue?@action=redirect&bpo=29532

   (193) https://bugs.python.org/issue?@action=redirect&bpo=29110

   (194) https://bugs.python.org/issue?@action=redirect&bpo=22807

   (195) https://bugs.python.org/issue?@action=redirect&bpo=29576

   (196) https://bugs.python.org/issue?@action=redirect&bpo=29534

   (197) https://bugs.python.org/issue?@action=redirect&bpo=10379

   (198) https://bugs.python.org/issue?@action=redirect&bpo=29851

   (199) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (200) https://bugs.python.org/issue?@action=redirect&bpo=29100

   (201) https://bugs.python.org/issue?@action=redirect&bpo=29416

   (202) https://bugs.python.org/issue?@action=redirect&bpo=29444

   (203) https://bugs.python.org/issue?@action=redirect&bpo=29377

   (204) https://bugs.python.org/issue?@action=redirect&bpo=29218

   (205) https://bugs.python.org/issue?@action=redirect&bpo=29368

   (206) https://bugs.python.org/issue?@action=redirect&bpo=29338

   (207) https://bugs.python.org/issue?@action=redirect&bpo=29335

   (208) https://bugs.python.org/issue?@action=redirect&bpo=29290

   (209) https://bugs.python.org/issue?@action=redirect&bpo=28735

   (210) https://bugs.python.org/issue?@action=redirect&bpo=29197

   (211) https://bugs.python.org/issue?@action=redirect&bpo=29210

   (212) https://bugs.python.org/issue?@action=redirect&bpo=29219

   (213) https://bugs.python.org/issue?@action=redirect&bpo=29192

   (214) https://bugs.python.org/issue?@action=redirect&bpo=29193

   (215) https://bugs.python.org/issue?@action=redirect&bpo=29195

   (216) https://bugs.python.org/issue?@action=redirect&bpo=28969

   (217) https://bugs.python.org/issue?@action=redirect&bpo=20804

   (218) https://bugs.python.org/issue?@action=redirect&bpo=29142

   (219) https://bugs.python.org/issue?@action=redirect&bpo=28961

   (220) https://bugs.python.org/issue?@action=redirect&bpo=15812

   (221) https://bugs.python.org/issue?@action=redirect&bpo=28985

   (222) https://bugs.python.org/issue?@action=redirect&bpo=29079

   (223) https://bugs.python.org/issue?@action=redirect&bpo=13051

   (224) https://bugs.python.org/issue?@action=redirect&bpo=9770

   (225) https://bugs.python.org/issue?@action=redirect&bpo=28427

   (226) https://bugs.python.org/issue?@action=redirect&bpo=28923

   (227) https://bugs.python.org/issue?@action=redirect&bpo=28871

   (228) https://bugs.python.org/issue?@action=redirect&bpo=19542

   (229) https://bugs.python.org/issue?@action=redirect&bpo=20191

   (230) https://bugs.python.org/issue?@action=redirect&bpo=16255

   (231) https://bugs.python.org/issue?@action=redirect&bpo=28779

   (232) https://bugs.python.org/issue?@action=redirect&bpo=26937

   (233) https://bugs.python.org/issue?@action=redirect&bpo=28847

   (234) https://bugs.python.org/issue?@action=redirect&bpo=27030

   (235) https://bugs.python.org/issue?@action=redirect&bpo=28835

   (236) https://bugs.python.org/issue?@action=redirect&bpo=27172

   (237) https://bugs.python.org/issue?@action=redirect&bpo=28740

   (238) https://bugs.python.org/issue?@action=redirect&bpo=26273

   (239) https://bugs.python.org/issue?@action=redirect&bpo=28752

   (240) https://bugs.python.org/issue?@action=redirect&bpo=28727

   (241) https://bugs.python.org/issue?@action=redirect&bpo=18383

   (242) https://bugs.python.org/issue?@action=redirect&bpo=20572

   (243) https://bugs.python.org/issue?@action=redirect&bpo=25659

   (244) https://bugs.python.org/issue?@action=redirect&bpo=28548

   (245) https://bugs.python.org/issue?@action=redirect&bpo=19717

   (246) https://bugs.python.org/issue?@action=redirect&bpo=28563

   (247) https://bugs.python.org/issue?@action=redirect&bpo=28387

   (248) https://bugs.python.org/issue?@action=redirect&bpo=27517

   (249) https://bugs.python.org/issue?@action=redirect&bpo=28549

   (250) https://bugs.python.org/issue?@action=redirect&bpo=28449

   (251) https://bugs.python.org/issue?@action=redirect&bpo=23262

   (252) https://bugs.python.org/issue?@action=redirect&bpo=24241

   (253) https://bugs.python.org/issue?@action=redirect&bpo=27939

   (254) https://bugs.python.org/issue?@action=redirect&bpo=28255

   (255) https://bugs.python.org/issue?@action=redirect&bpo=28255

   (256) https://bugs.python.org/issue?@action=redirect&bpo=20491

   (257) https://bugs.python.org/issue?@action=redirect&bpo=28353

   (258) https://bugs.python.org/issue?@action=redirect&bpo=28430

   (259) https://bugs.python.org/issue?@action=redirect&bpo=27025

   (260) https://bugs.python.org/issue?@action=redirect&bpo=25464

   (261) https://bugs.python.org/issue?@action=redirect&bpo=28488

   (262) https://bugs.python.org/issue?@action=redirect&bpo=25953

   (263) https://bugs.python.org/issue?@action=redirect&bpo=28469

   (264) https://bugs.python.org/issue?@action=redirect&bpo=28115

   (265) https://bugs.python.org/issue?@action=redirect&bpo=18219

   (266) https://bugs.python.org/issue?@action=redirect&bpo=28448

   (267) https://bugs.python.org/issue?@action=redirect&bpo=23214

   (268) https://bugs.python.org/issue?@action=redirect&bpo=28480

   (269) https://bugs.python.org/issue?@action=redirect&bpo=28240

   (270) https://bugs.python.org/issue?@action=redirect&bpo=28240

   (271) https://bugs.python.org/issue?@action=redirect&bpo=28240

   (272) https://github.com/pypa/setuptools/issues/100

   (273) https://bugs.python.org/issue?@action=redirect&bpo=24452

   (274) https://bugs.python.org/issue?@action=redirect&bpo=20766

   (275) https://bugs.python.org/issue?@action=redirect&bpo=27998

   (276) https://bugs.python.org/issue?@action=redirect&bpo=28317

   (277) https://bugs.python.org/issue?@action=redirect&bpo=28380

   (278) https://bugs.python.org/issue?@action=redirect&bpo=28229

   (279) https://bugs.python.org/issue?@action=redirect&bpo=28321

   (280) https://bugs.python.org/issue?@action=redirect&bpo=28225

   (281) https://bugs.python.org/issue?@action=redirect&bpo=28227

   (282) https://bugs.python.org/issue?@action=redirect&bpo=28332

   (283) https://bugs.python.org/issue?@action=redirect&bpo=27358

   (284) https://bugs.python.org/issue?@action=redirect&bpo=28257

   (285) https://bugs.python.org/issue?@action=redirect&bpo=28322

   (286) https://bugs.python.org/issue?@action=redirect&bpo=28228

   (287) https://bugs.python.org/issue?@action=redirect&bpo=28226

   (288) https://bugs.python.org/issue?@action=redirect&bpo=28314

   (289) https://bugs.python.org/issue?@action=redirect&bpo=28148

   (290) https://bugs.python.org/issue?@action=redirect&bpo=28253

   (291) https://bugs.python.org/issue?@action=redirect&bpo=28275

   (292) https://bugs.python.org/issue?@action=redirect&bpo=27897

   (293) https://bugs.python.org/issue?@action=redirect&bpo=18844

   (294) https://bugs.python.org/issue?@action=redirect&bpo=18893

   (295) https://bugs.python.org/issue?@action=redirect&bpo=27611

   (296) https://bugs.python.org/issue?@action=redirect&bpo=27348

   (297) https://bugs.python.org/issue?@action=redirect&bpo=25651

   (298) https://bugs.python.org/issue?@action=redirect&bpo=27778

   (299) https://bugs.python.org/issue?@action=redirect&bpo=28200

   (300) https://bugs.python.org/issue?@action=redirect&bpo=25400

   (301) https://bugs.python.org/issue?@action=redirect&bpo=27932

   (302) https://bugs.python.org/issue?@action=redirect&bpo=28075

   (303) https://bugs.python.org/issue?@action=redirect&bpo=22493

   (304) https://bugs.python.org/issue?@action=redirect&bpo=25270

   (305) https://bugs.python.org/issue?@action=redirect&bpo=28181

   (306) https://bugs.python.org/issue?@action=redirect&bpo=25895

   (307) https://bugs.python.org/issue?@action=redirect&bpo=28114

   (308) https://bugs.python.org/issue?@action=redirect&bpo=27599

   (309) https://bugs.python.org/issue?@action=redirect&bpo=27906

   (310) https://bugs.python.org/issue?@action=redirect&bpo=28174

   (311) https://bugs.python.org/issue?@action=redirect&bpo=26654

   (312) https://bugs.python.org/issue?@action=redirect&bpo=26909

   (313) https://bugs.python.org/issue?@action=redirect&bpo=28176

   (314) https://bugs.python.org/issue?@action=redirect&bpo=27759

   (315) https://bugs.python.org/issue?@action=redirect&bpo=28325

   (316) https://bugs.python.org/issue?@action=redirect&bpo=28368

   (317) https://bugs.python.org/issue?@action=redirect&bpo=28369

   (318) https://bugs.python.org/issue?@action=redirect&bpo=28370

   (319) https://bugs.python.org/issue?@action=redirect&bpo=28371

   (320) https://bugs.python.org/issue?@action=redirect&bpo=28372

   (321) https://bugs.python.org/issue?@action=redirect&bpo=28399

   (322) https://bugs.python.org/issue?@action=redirect&bpo=27972

   (323) https://bugs.python.org/issue?@action=redirect&bpo=24142

   (324) https://bugs.python.org/issue?@action=redirect&bpo=29581

   (325) https://bugs.python.org/issue?@action=redirect&bpo=25532

   (326) https://bugs.python.org/issue?@action=redirect&bpo=30177


File: python.info,  Node: Documentation<55>,  Next: Tests<55>,  Prev: Library<61>,  Up: Python 3 7 0 alpha 1

1.23.62.4 Documentation
.......................

   - bpo-31294(1): Fix incomplete code snippet in the
     ZeroMQSocketListener and ZeroMQSocketHandler examples and adapt
     them to Python 3.

   - bpo-21649(2): Add RFC 7525 and Mozilla server side TLS links to SSL
     documentation.

   - bpo-31128(3): Allow the pydoc server to bind to arbitrary
     hostnames.

   - bpo-30803(4): Clarify doc on truth value testing.  Original patch
     by Peter Thomassen.

   - bpo-30176(5): Add missing attribute related constants in curses
     documentation.

   - bpo-30052(6): the link targets for *note bytes(): 1a4. and *note
     bytearray(): 508. are now their respective type definitions, rather
     than the corresponding builtin function entries.  Use *note bytes:
     1a24. and *note bytearray: 1a25. to reference the latter.  In order
     to ensure this and future cross-reference updates are applied
     automatically, the daily documentation builds now disable the
     default output caching features in Sphinx.

   - bpo-26985(7): Add missing info of code object in inspect
     documentation.

   - bpo-19824(8): Improve the documentation for, and links to, template
     strings by emphasizing their utility for internationalization, and
     by clarifying some usage constraints.  (See also: bpo-20314(9),
     bpo-12518(10))

   - bpo-28929(11): Link the documentation to its source file on GitHub.

   - bpo-25008(12): Document smtpd.py as effectively deprecated and add
     a pointer to aiosmtpd, a third-party asyncio-based replacement.

   - bpo-26355(13): Add canonical header link on each page to
     corresponding major version of the documentation.  Patch by
     Matthias Bussonnier.

   - bpo-29349(14): Fix Python 2 syntax in code for building the
     documentation.

   - bpo-23722(15): The data model reference and the porting section in
     the 3.6 What's New guide now cover the additional ‘__classcell__’
     handling needed for custom metaclasses to fully support PEP 487(16)
     and zero-argument ‘super()’.

   - bpo-28513(17): Documented command-line interface of zipfile.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31294

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21649

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31128

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30803

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30176

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30052

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26985

   (8) https://bugs.python.org/issue?@action=redirect&bpo=19824

   (9) https://bugs.python.org/issue?@action=redirect&bpo=20314

   (10) https://bugs.python.org/issue?@action=redirect&bpo=12518

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28929

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25008

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26355

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29349

   (15) https://bugs.python.org/issue?@action=redirect&bpo=23722

   (16) https://peps.python.org/pep-0487/

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28513


File: python.info,  Node: Tests<55>,  Next: Build<58>,  Prev: Documentation<55>,  Up: Python 3 7 0 alpha 1

1.23.62.5 Tests
...............

   - bpo-29639(1): test.support.HOST is now "localhost", a new HOSTv4
     constant has been added for your ‘127.0.0.1’ needs, similar to the
     existing HOSTv6 constant.

   - bpo-31320(2): Silence traceback in test_ssl

   - bpo-31346(3): Prefer PROTOCOL_TLS_CLIENT and PROTOCOL_TLS_SERVER
     protocols for SSLContext.

   - bpo-25674(4): Remove sha256.tbs-internet.com ssl test

   - bpo-30715(5): Address ALPN callback changes for OpenSSL 1.1.0f.
     The latest version behaves like OpenSSL 1.0.2 and no longer aborts
     handshake.

   - bpo-30822(6): regrtest: Exclude tzdata from regrtest -all.  When
     running the test suite using -use=all / -u all, exclude tzdata
     since it makes test_datetime too slow (15-20 min on some buildbots)
     which then times out on some buildbots.  Fix also regrtest command
     line parser to allow passing -u extralargefile to run
     test_zipfile64.

   - bpo-30695(7): Add the ‘set_nomemory(start, stop)’ and
     ‘remove_mem_hooks()’ functions to the ‘_testcapi’ module.

   - bpo-30357(8): test_thread: setUp() now uses
     support.threading_setup() and support.threading_cleanup() to wait
     until threads complete to avoid random side effects on following
     tests.  Initial patch written by Grzegorz Grzywacz.

   - bpo-30197(9): Enhanced functions swap_attr() and swap_item() in the
     test.support module.  They now work when delete replaced attribute
     or item inside the with statement.  The old value of the attribute
     or item (or None if it doesn't exist) now will be assigned to the
     target of the "as" clause, if there is one.

   - bpo-24932(10): Use proper command line parsing in _testembed

   - bpo-28950(11): Disallow -j0 to be combined with -T/-l in regrtest
     command line arguments.

   - bpo-28683(12): Fix the tests that bind() a unix socket and raise
     PermissionError on Android for a non-root user.

   - bpo-26936(13): Fix the test_socket failures on Android -
     getservbyname(), getservbyport() and getaddrinfo() are broken on
     some Android API levels.

   - bpo-28666(14): Now test.support.rmtree is able to remove unwritable
     or unreadable directories.

   - bpo-23839(15): Various caches now are cleared before running every
     test file.

   - bpo-26944(16): Fix test_posix for Android where 'id -G' is entirely
     wrong or missing the effective gid.

   - bpo-28409(17): regrtest: fix the parser of command line arguments.

   - bpo-28217(18): Adds _testconsole module to test console input.

   - bpo-26939(19): Add the support.setswitchinterval() function to fix
     test_functools hanging on the Android armv7 qemu emulator.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29639

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31320

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31346

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25674

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30715

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30822

   (7) https://bugs.python.org/issue?@action=redirect&bpo=30695

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30357

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30197

   (10) https://bugs.python.org/issue?@action=redirect&bpo=24932

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28950

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28683

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26936

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28666

   (15) https://bugs.python.org/issue?@action=redirect&bpo=23839

   (16) https://bugs.python.org/issue?@action=redirect&bpo=26944

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28409

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28217

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26939


File: python.info,  Node: Build<58>,  Next: Windows<53>,  Prev: Tests<55>,  Up: Python 3 7 0 alpha 1

1.23.62.6 Build
...............

   - bpo-31354(1): Allow ‘--with-lto’ to be used on all builds, not just
     ‘make profile-opt’.

   - bpo-31370(2): Remove support for building -without-threads.  This
     option is not really useful anymore in the 21st century.  Removing
     lots of conditional paths allows us to simplify the code base,
     including in difficult to maintain low-level internal code.

   - bpo-31341(3): Per PEP 11(4), support for the IRIX operating system
     was removed.

   - bpo-30854(5): Fix compile error when compiling -without-threads.
     Patch by Masayuki Yamamoto.

   - bpo-30687(6): Locate msbuild.exe on Windows when building rather
     than vcvarsall.bat

   - bpo-20210(7): Support the 'disabled' marker in Setup files.
     Extension modules listed after this marker are not built at all,
     neither by the Makefile nor by setup.py.

   - bpo-29941(8): Add ‘--with-assertions’ configure flag to explicitly
     enable C ‘assert()’ checks.  Defaults to off.  ‘--with-pydebug’
     implies ‘--with-assertions’.

   - bpo-28787(9): Fix out-of-tree builds of Python when configured with
     ‘--with--dtrace’.

   - bpo-29243(10): Prevent unnecessary rebuilding of Python during
     ‘make test’, ‘make install’ and some other make targets when
     configured with ‘--enable-optimizations’.

   - bpo-23404(11): Don't regenerate generated files based on file
     modification time anymore: the action is now explicit.  Replace
     ‘make touch’ with ‘make regen-all’.

   - bpo-29643(12): Fix ‘--enable-optimization’ didn't work.

   - bpo-27593(13): sys.version and the platform module python_build(),
     python_branch(), and python_revision() functions now use git
     information rather than hg when building from a repo.

   - bpo-29572(14): Update Windows build and OS X installers to use
     OpenSSL 1.0.2k.

   - bpo-27659(15): Prohibit implicit C function declarations: use
     ‘-Werror=implicit-function-declaration’ when possible (GCC and
     Clang, but it depends on the compiler version).  Patch written by
     Chi Hsuan Yen.

   - bpo-29384(16): Remove old Be OS helper scripts.

   - bpo-26851(17): Set Android compilation and link flags.

   - bpo-28768(18): Fix implicit declaration of function _setmode.
     Patch by Masayuki Yamamoto

   - bpo-29080(19): Removes hard dependency on hg.exe from
     PCBuild/build.bat

   - bpo-23903(20): Added missed names to PC/python3.def.

   - bpo-28762(21): lockf() is available on Android API level 24, but
     the F_LOCK macro is not defined in android-ndk-r13.

   - bpo-28538(22): Fix the compilation error that occurs because
     if_nameindex() is available on Android API level 24, but the
     if_nameindex structure is not defined.

   - bpo-20211(23): Do not add the directory for installing C header
     files and the directory for installing object code libraries to the
     cross compilation search paths.  Original patch by Thomas
     Petazzoni.

   - bpo-28849(24): Do not define sys.implementation._multiarch on
     Android.

   - bpo-10656(25): Fix out-of-tree building on AIX. Patch by Tristan
     Carel and Michael Haubenwallner.

   - bpo-26359(26): Rename -with-optimiations to -enable-optimizations.

   - bpo-28444(27): Fix missing extensions modules when cross compiling.

   - bpo-28208(28): Update Windows build and OS X installers to use
     SQLite 3.14.2.

   - bpo-28248(29): Update Windows build and OS X installers to use
     OpenSSL 1.0.2j.

   - bpo-21124(30): Fix building the _struct module on Cygwin by passing
     ‘NULL’ instead of ‘&PyType_Type’ to PyVarObject_HEAD_INIT. Patch by
     Masayuki Yamamoto.

   - bpo-13756(31): Fix building extensions modules on Cygwin.  Patch by
     Roumen Petrov, based on original patch by Jason Tishler.

   - bpo-21085(32): Add configure check for siginfo_t.si_band, which
     Cygwin does not provide.  Patch by Masayuki Yamamoto with review
     and rebase by Erik Bray.

   - bpo-28258(33): Fixed build with Estonian locale (python-config and
     distclean targets in Makefile).  Patch by Arfrever Frehtes
     Taifersar Arahesis.

   - bpo-26661(34): setup.py now detects system libffi with multiarch
     wrapper.

   - bpo-27979(35): A full copy of libffi is no longer bundled for use
     when building _ctypes on non-OSX UNIX platforms.  An installed copy
     of libffi is now required when building _ctypes on such platforms.

   - bpo-15819(36): Remove redundant include search directory option for
     building outside the source tree.

   - bpo-28676(37): Prevent missing 'getentropy' declaration warning on
     macOS. Patch by Gareth Rees.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31354

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31370

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31341

   (4) https://peps.python.org/pep-0011/

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30854

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30687

   (7) https://bugs.python.org/issue?@action=redirect&bpo=20210

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29941

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28787

   (10) https://bugs.python.org/issue?@action=redirect&bpo=29243

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23404

   (12) https://bugs.python.org/issue?@action=redirect&bpo=29643

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27593

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29572

   (15) https://bugs.python.org/issue?@action=redirect&bpo=27659

   (16) https://bugs.python.org/issue?@action=redirect&bpo=29384

   (17) https://bugs.python.org/issue?@action=redirect&bpo=26851

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28768

   (19) https://bugs.python.org/issue?@action=redirect&bpo=29080

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23903

   (21) https://bugs.python.org/issue?@action=redirect&bpo=28762

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28538

   (23) https://bugs.python.org/issue?@action=redirect&bpo=20211

   (24) https://bugs.python.org/issue?@action=redirect&bpo=28849

   (25) https://bugs.python.org/issue?@action=redirect&bpo=10656

   (26) https://bugs.python.org/issue?@action=redirect&bpo=26359

   (27) https://bugs.python.org/issue?@action=redirect&bpo=28444

   (28) https://bugs.python.org/issue?@action=redirect&bpo=28208

   (29) https://bugs.python.org/issue?@action=redirect&bpo=28248

   (30) https://bugs.python.org/issue?@action=redirect&bpo=21124

   (31) https://bugs.python.org/issue?@action=redirect&bpo=13756

   (32) https://bugs.python.org/issue?@action=redirect&bpo=21085

   (33) https://bugs.python.org/issue?@action=redirect&bpo=28258

   (34) https://bugs.python.org/issue?@action=redirect&bpo=26661

   (35) https://bugs.python.org/issue?@action=redirect&bpo=27979

   (36) https://bugs.python.org/issue?@action=redirect&bpo=15819

   (37) https://bugs.python.org/issue?@action=redirect&bpo=28676


File: python.info,  Node: Windows<53>,  Next: IDLE<45>,  Prev: Build<58>,  Up: Python 3 7 0 alpha 1

1.23.62.7 Windows
.................

   - bpo-31392(1): Update Windows build to use OpenSSL 1.1.0f

   - bpo-30389(2): Adds detection of Visual Studio 2017 to distutils on
     Windows.

   - bpo-31358(3): zlib is no longer bundled in the CPython source,
     instead it is downloaded on demand just like bz2, lzma, OpenSSL,
     Tcl/Tk, and SQLite.

   - bpo-31340(4): Change to building with MSVC v141 (included with
     Visual Studio 2017)

   - bpo-30581(5): os.cpu_count() now returns the correct number of
     processors on Windows when the number of logical processors is
     greater than 64.

   - bpo-30916(6): Pre-build OpenSSL, Tcl and Tk and include the
     binaries in the build.

   - bpo-30731(7): Add a missing xmlns to python.manifest so that it
     matches the schema.

   - bpo-30291(8): Allow requiring 64-bit interpreters from py.exe using
     -64 suffix.  Contributed by Steve (Gadget) Barnes.

   - bpo-30362(9): Adds list options (-0, -0p) to py.exe launcher.
     Contributed by Steve Barnes.

   - bpo-23451(10): Fix socket deprecation warnings in socketmodule.c.
     Patch by Segev Finer.

   - bpo-30450(11): The build process on Windows no longer depends on
     Subversion, instead pulling external code from GitHub via a Python
     script.  If Python 3.6 is not found on the system (via ‘py -3.6’),
     NuGet is used to download a copy of 32-bit Python.

   - bpo-29579(12): Removes readme.txt from the installer.

   - bpo-25778(13): winreg does not truncate string correctly (Patch by
     Eryk Sun)

   - bpo-28896(14): Deprecate WindowsRegistryFinder and disable it by
     default

   - bpo-28522(15): Fixes mishandled buffer reallocation in getpathp.c

   - bpo-28402(16): Adds signed catalog files for stdlib on Windows.

   - bpo-28333(17): Enables Unicode for ps1/ps2 and input() prompts.
     (Patch by Eryk Sun)

   - bpo-28251(18): Improvements to help manuals on Windows.

   - bpo-28110(19): launcher.msi has different product codes between
     32-bit and 64-bit

   - bpo-28161(20): Opening CON for write access fails

   - bpo-28162(21): WindowsConsoleIO readall() fails if first line
     starts with Ctrl+Z

   - bpo-28163(22): WindowsConsoleIO fileno() passes wrong flags to
     _open_osfhandle

   - bpo-28164(23): _PyIO_get_console_type fails for various paths

   - bpo-28137(24): Renames Windows path file to ._pth

   - bpo-28138(25): Windows ._pth file should allow import site

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31392

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30389

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31358

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31340

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30581

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30916

   (7) https://bugs.python.org/issue?@action=redirect&bpo=30731

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30291

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30362

   (10) https://bugs.python.org/issue?@action=redirect&bpo=23451

   (11) https://bugs.python.org/issue?@action=redirect&bpo=30450

   (12) https://bugs.python.org/issue?@action=redirect&bpo=29579

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25778

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28896

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28522

   (16) https://bugs.python.org/issue?@action=redirect&bpo=28402

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28333

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28251

   (19) https://bugs.python.org/issue?@action=redirect&bpo=28110

   (20) https://bugs.python.org/issue?@action=redirect&bpo=28161

   (21) https://bugs.python.org/issue?@action=redirect&bpo=28162

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28163

   (23) https://bugs.python.org/issue?@action=redirect&bpo=28164

   (24) https://bugs.python.org/issue?@action=redirect&bpo=28137

   (25) https://bugs.python.org/issue?@action=redirect&bpo=28138


File: python.info,  Node: IDLE<45>,  Next: Tools/Demos<30>,  Prev: Windows<53>,  Up: Python 3 7 0 alpha 1

1.23.62.8 IDLE
..............

   - bpo-31493(1): IDLE code context - fix code update and font update
     timers.  Canceling timers prevents a warning message when test_idle
     completes.

   - bpo-31488(2): IDLE - Update non-key options in former extension
     classes.  When applying configdialog changes, call .reload for each
     feature class.  Change ParenMatch so updated options affect
     existing instances attached to existing editor windows.

   - bpo-31477(3): IDLE - Improve rstrip entry in doc.  Strip trailing
     whitespace strips more than blank spaces.  Multiline string
     literals are not skipped.

   - bpo-31480(4): IDLE - make tests pass with zzdummy extension
     disabled by default.

   - bpo-31421(5): Document how IDLE runs tkinter programs.  IDLE calls
     tcl/tk update in the background in order to make live interaction
     and experimentation with tkinter applications much easier.

   - bpo-31414(6): IDLE - fix tk entry box tests by deleting first.
     Adding to an int entry is not the same as deleting and inserting
     because int('') will fail.

   - bpo-31051(7): Rearrange IDLE configdialog GenPage into Window,
     Editor, and Help sections.

   - bpo-30617(8): IDLE - Add docstrings and tests for outwin subclass
     of editor.  Move some data and functions from the class to module
     level.  Patch by Cheryl Sabella.

   - bpo-31287(9): IDLE - Do not modify tkinter.message in
     test_configdialog.

   - bpo-27099(10): Convert IDLE's built-in 'extensions' to regular
     features.  About 10 IDLE features were implemented as supposedly
     optional extensions.  Their different behavior could be confusing
     or worse for users and not good for maintenance.  Hence the
     conversion.  The main difference for users is that user
     configurable key bindings for builtin features are now handled
     uniformly.  Now, editing a binding in a keyset only affects its
     value in the keyset.  All bindings are defined together in the
     system-specific default keysets in config-extensions.def.  All
     custom keysets are saved as a whole in config-extension.cfg.  All
     take effect as soon as one clicks Apply or Ok.  The affected events
     are '<<force-open-completions>>', '<<expand-word>>',
     '<<force-open-calltip>>', '<<flash-paren>>',
     '<<format-paragraph>>', '<<run-module>>', '<<check-module>>', and
     '<<zoom-height>>'.  Any (global) customizations made before 3.6.3
     will not affect their keyset-specific customization after 3.6.3.
     and vice versa.  Initial patch by Charles Wohlganger.

   - bpo-31206(11): IDLE: Factor HighPage(Frame) class from
     ConfigDialog.  Patch by Cheryl Sabella.

   - bpo-31001(12): Add tests for configdialog highlight tab.  Patch by
     Cheryl Sabella.

   - bpo-31205(13): IDLE: Factor KeysPage(Frame) class from
     ConfigDialog.  The slightly modified tests continue to pass.  Patch
     by Cheryl Sabella.

   - bpo-31130(14): IDLE - stop leaks in test_configdialog.  Initial
     patch by Victor Stinner.

   - bpo-31002(15): Add tests for configdialog keys tab.  Patch by
     Cheryl Sabella.

   - bpo-19903(16): IDLE: Calltips use ‘inspect.signature’ instead of
     ‘inspect.getfullargspec’.  This improves calltips for builtins
     converted to use Argument Clinic.  Patch by Louie Lu.

   - bpo-31083(17): IDLE - Add an outline of a TabPage class in
     configdialog.  Update existing classes to match outline.  Initial
     patch by Cheryl Sabella.

   - bpo-31050(18): Factor GenPage(Frame) class from ConfigDialog.  The
     slightly modified tests continue to pass.  Patch by Cheryl Sabella.

   - bpo-31004(19): IDLE - Factor FontPage(Frame) class from
     ConfigDialog.  Slightly modified tests continue to pass.  Fix
     General tests.  Patch mostly by Cheryl Sabella.

   - bpo-30781(20): IDLE - Use ttk widgets in ConfigDialog.  Patches by
     Terry Jan Reedy and Cheryl Sabella.

   - bpo-31060(21): IDLE - Finish rearranging methods of ConfigDialog
     Grouping methods pertaining to each tab and the buttons will aid
     writing tests and improving the tabs and will enable splitting the
     groups into classes.

   - bpo-30853(22): IDLE - Factor a VarTrace class out of ConfigDialog.
     Instance tracers manages pairs consisting of a tk variable and a
     callback function.  When tracing is turned on, setting the variable
     calls the function.  Test coverage for the new class is 100%.

   - bpo-31003(23): IDLE: Add more tests for General tab.

   - bpo-30993(24): IDLE - Improve configdialog font page and tests.  In
     configdialog: Document causal pathways in create_font_tab
     docstring.  Simplify some attribute names.  Move set_samples calls
     to var_changed_font (idea from Cheryl Sabella).  Move related
     functions to positions after the create widgets function.  In
     test_configdialog: Fix test_font_set so not order dependent.  Fix
     renamed test_indent_scale so it tests the widget.  Adjust tests for
     movement of set_samples call.  Add tests for load functions.  Put
     all font tests in one class and tab indent tests in another.
     Except for two lines, these tests completely cover the related
     functions.

   - bpo-30981(25): IDLE - Add more configdialog font page tests.

   - bpo-28523(26): IDLE: replace 'colour' with 'color' in configdialog.

   - bpo-30917(27): Add tests for idlelib.config.IdleConf.  Increase
     coverage from 46% to 96%.  Patch by Louie Lu.

   - bpo-30934(28): Document coverage details for idlelib tests.  Add
     section to idlelib/idle-test/README.txt.  Include check that
     branches are taken both ways.  Exclude IDLE-specific code that does
     not run during unit tests.

   - bpo-30913(29): IDLE: Document ConfigDialog tk Vars, methods, and
     widgets in docstrings This will facilitate improving the dialog and
     splitting up the class.  Original patch by Cheryl Sabella.

   - bpo-30899(30): IDLE: Add tests for ConfigParser subclasses in
     config.  Patch by Louie Lu.

   - bpo-30881(31): IDLE: Add docstrings to browser.py.  Patch by Cheryl
     Sabella.

   - bpo-30851(32): IDLE: Remove unused variables in configdialog.  One
     is a duplicate, one is set but cannot be altered by users.  Patch
     by Cheryl Sabella.

   - bpo-30870(33): IDLE: In Settings dialog, select font with Up, Down
     keys as well as mouse.  Initial patch by Louie Lu.

   - bpo-8231(34): IDLE: call config.IdleConf.GetUserCfgDir only once.

   - bpo-30779(35): IDLE: Factor ConfigChanges class from configdialog,
     put in config; test.  * In config, put dump test code in a
     function; run it and unittest in 'if __name__ == '__main__'.  * Add
     class config.ConfigChanges based on changes_class_v4.py on bpo
     issue.  * Add class test_config.ChangesTest, partly using
     configdialog_tests_v1.py.  * Revise configdialog to use
     ConfigChanges; see tracker msg297804.  * Revise test_configdialog
     to match configdialog changes.  * Remove configdialog functions
     unused or moved to ConfigChanges.  Cheryl Sabella contributed parts
     of the patch.

   - bpo-30777(36): IDLE: configdialog - Add docstrings and fix
     comments.  Patch by Cheryl Sabella.

   - bpo-30495(37): IDLE: Improve textview with docstrings, PEP8 names,
     and more tests.  Patch by Cheryl Sabella.

   - bpo-30723(38): IDLE: Make several improvements to parenmatch.  Add
     'parens' style to highlight both opener and closer.  Make 'default'
     style, which is not default, a synonym for 'opener'.  Make
     time-delay work the same with all styles.  Add help for config
     dialog extensions tab, including help for parenmatch.  Add new
     tests.  Original patch by Charles Wohlganger.

   - bpo-30674(39): IDLE: add docstrings to grep module.  Patch by
     Cheryl Sabella

   - bpo-21519(40): IDLE's basic custom key entry dialog now detects
     duplicates properly.  Original patch by Saimadhav Heblikar.

   - bpo-29910(41): IDLE no longer deletes a character after commenting
     out a region by a key shortcut.  Add ‘return 'break'’ for this and
     other potential conflicts between IDLE and default key bindings.

   - bpo-30728(42): Review and change idlelib.configdialog names.
     Lowercase method and attribute names.  Replace 'colour' with
     'color', expand overly cryptic names, delete unneeded underscores.
     Replace ‘import *’ with specific imports.  Patches by Cheryl
     Sabella.

   - bpo-6739(43): IDLE: Verify user-entered key sequences by trying to
     bind them with tk.  Add tests for all 3 validation functions.
     Original patch by G Polo.  Tests added by Cheryl Sabella.

   - bpo-15786(44): Fix several problems with IDLE's autocompletion box.
     The following should now work: clicking on selection box items;
     using the scrollbar; selecting an item by hitting Return.  Hangs on
     MacOSX should no longer happen.  Patch by Louie Lu.

   - bpo-25514(45): Add doc subsubsection about IDLE failure to start.
     Popup no-connection message directs users to this section.

   - bpo-30642(46): Fix reference leaks in IDLE tests.  Patches by Louie
     Lu and Terry Jan Reedy.

   - bpo-30495(47): Add docstrings for textview.py and use PEP8 names.
     Patches by Cheryl Sabella and Terry Jan Reedy.

   - bpo-30290(48): Help-about: use pep8 names and add tests.  Increase
     coverage to 100%.  Patches by Louie Lu, Cheryl Sabella, and Terry
     Jan Reedy.

   - bpo-30303(49): Add _utest option to textview; add new tests.
     Increase coverage to 100%.  Patches by Louie Lu and Terry Jan
     Reedy.

   - bpo-29071(50): IDLE colors f-string prefixes (but not invalid ur
     prefixes).

   - bpo-28572(51): Add 10% to coverage of IDLE's test_configdialog.
     Update and augment description of the configuration system.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31493

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31488

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31477

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31480

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31421

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31414

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31051

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30617

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31287

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27099

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31206

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31001

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31205

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31130

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31002

   (16) https://bugs.python.org/issue?@action=redirect&bpo=19903

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31083

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31050

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31004

   (20) https://bugs.python.org/issue?@action=redirect&bpo=30781

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31060

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30853

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31003

   (24) https://bugs.python.org/issue?@action=redirect&bpo=30993

   (25) https://bugs.python.org/issue?@action=redirect&bpo=30981

   (26) https://bugs.python.org/issue?@action=redirect&bpo=28523

   (27) https://bugs.python.org/issue?@action=redirect&bpo=30917

   (28) https://bugs.python.org/issue?@action=redirect&bpo=30934

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30913

   (30) https://bugs.python.org/issue?@action=redirect&bpo=30899

   (31) https://bugs.python.org/issue?@action=redirect&bpo=30881

   (32) https://bugs.python.org/issue?@action=redirect&bpo=30851

   (33) https://bugs.python.org/issue?@action=redirect&bpo=30870

   (34) https://bugs.python.org/issue?@action=redirect&bpo=8231

   (35) https://bugs.python.org/issue?@action=redirect&bpo=30779

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30777

   (37) https://bugs.python.org/issue?@action=redirect&bpo=30495

   (38) https://bugs.python.org/issue?@action=redirect&bpo=30723

   (39) https://bugs.python.org/issue?@action=redirect&bpo=30674

   (40) https://bugs.python.org/issue?@action=redirect&bpo=21519

   (41) https://bugs.python.org/issue?@action=redirect&bpo=29910

   (42) https://bugs.python.org/issue?@action=redirect&bpo=30728

   (43) https://bugs.python.org/issue?@action=redirect&bpo=6739

   (44) https://bugs.python.org/issue?@action=redirect&bpo=15786

   (45) https://bugs.python.org/issue?@action=redirect&bpo=25514

   (46) https://bugs.python.org/issue?@action=redirect&bpo=30642

   (47) https://bugs.python.org/issue?@action=redirect&bpo=30495

   (48) https://bugs.python.org/issue?@action=redirect&bpo=30290

   (49) https://bugs.python.org/issue?@action=redirect&bpo=30303

   (50) https://bugs.python.org/issue?@action=redirect&bpo=29071

   (51) https://bugs.python.org/issue?@action=redirect&bpo=28572


File: python.info,  Node: Tools/Demos<30>,  Next: C API<55>,  Prev: IDLE<45>,  Up: Python 3 7 0 alpha 1

1.23.62.9 Tools/Demos
.....................

   - bpo-30983(1): gdb integration commands (py-bt, etc.)  work on
     optimized shared builds now, too.  PEP 523(2) introduced
     _PyEval_EvalFrameDefault which inlines PyEval_EvalFrameEx on
     non-debug shared builds.  This broke the ability to use py-bt,
     py-up, and a few other Python-specific gdb integrations.  The
     problem is fixed by only looking for _PyEval_EvalFrameDefault
     frames in python-gdb.py.  Original patch by Bruno "Polaco"
     Penteado.

   - bpo-29748(3): Added the slice index converter in Argument Clinic.

   - bpo-24037(4): Argument Clinic now uses the converter
     ‘bool(accept={int})’ rather than ‘int’ for semantical booleans.
     This avoids repeating the default value for Python and C and will
     help in converting to ‘bool’ in future.

   - bpo-29367(5): python-gdb.py now supports also ‘method-wrapper’
     (‘wrapperobject’) objects.

   - bpo-28023(6): Fix python-gdb.py didn't support new dict
     implementation.

   - bpo-15369(7): The pybench and pystone microbenchmark have been
     removed from Tools.  Please use the new Python benchmark suite
     ‘https://github.com/python/pyperformance’ which is more reliable
     and includes a portable version of pybench working on Python 2 and
     Python 3.

   - bpo-28102(8): The zipfile module CLI now prints usage to stderr.
     Patch by Stephen J. Turnbull.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30983

   (2) https://peps.python.org/pep-0523/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29748

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24037

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29367

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28023

   (7) https://bugs.python.org/issue?@action=redirect&bpo=15369

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28102


File: python.info,  Node: C API<55>,  Prev: Tools/Demos<30>,  Up: Python 3 7 0 alpha 1

1.23.62.10 C API
................

   - bpo-31338(1): Added the ‘Py_UNREACHABLE()’ macro for code paths
     which are never expected to be reached.  This and a few other
     useful macros are now documented in the C API manual.

   - bpo-30832(2): Remove own implementation for thread-local storage.
     CPython has provided the own implementation for thread-local
     storage (TLS) on Python/thread.c, it's used in the case which a
     platform has not supplied native TLS. However, currently all
     supported platforms (Windows and pthreads) have provided native TLS
     and defined the Py_HAVE_NATIVE_TLS macro with unconditional in any
     case.

   - bpo-30708(3): PyUnicode_AsWideCharString() now raises a ValueError
     if the second argument is NULL and the wchar_t* string contains
     null characters.

   - bpo-16500(4): Deprecate PyOS_AfterFork() and add PyOS_BeforeFork(),
     PyOS_AfterFork_Parent() and PyOS_AfterFork_Child().

   - bpo-6532(5): The type of results of PyThread_start_new_thread() and
     PyThread_get_thread_ident(), and the id parameter of
     PyThreadState_SetAsyncExc() changed from "long" to "unsigned long".

   - bpo-27867(6): Function PySlice_GetIndicesEx() is deprecated and
     replaced with a macro if Py_LIMITED_API is not set or set to the
     value between 0x03050400 and 0x03060000 (not including) or
     0x03060100 or higher.  Added functions PySlice_Unpack() and
     PySlice_AdjustIndices().

   - bpo-29083(7): Fixed the declaration of some public API functions.
     PyArg_VaParse() and PyArg_VaParseTupleAndKeywords() were not
     available in limited API. PyArg_ValidateKeywordArguments(),
     PyArg_UnpackTuple() and Py_BuildValue() were not available in
     limited API of version < 3.3 when PY_SSIZE_T_CLEAN is defined.

   - bpo-28769(8): The result of PyUnicode_AsUTF8AndSize() and
     PyUnicode_AsUTF8() is now of type ‘const char *’ rather of ‘char
     *’.

   - bpo-29058(9): All stable API extensions added after Python 3.2 are
     now available only when Py_LIMITED_API is set to the PY_VERSION_HEX
     value of the minimum Python version supporting this API.

   - bpo-28822(10): The index parameters 'start' and 'end' of
     PyUnicode_FindChar() are now adjusted to behave like
     ‘str[start:end]’.

   - bpo-28808(11): PyUnicode_CompareWithASCIIString() now never raises
     exceptions.

   - bpo-28761(12): The fields name and doc of structures PyMemberDef,
     PyGetSetDef, PyStructSequence_Field, PyStructSequence_Desc, and
     wrapperbase are now of type ‘const char *’ rather of ‘char *’.

   - bpo-28748(13): Private variable _Py_PackageContext is now of type
     ‘const char *’ rather of ‘char *’.

   - bpo-19569(14): Compiler warnings are now emitted if use most of
     deprecated functions.

   - bpo-28426(15): Deprecated undocumented functions
     PyUnicode_AsEncodedObject(), PyUnicode_AsDecodedObject(),
     PyUnicode_AsDecodedUnicode() and PyUnicode_AsEncodedUnicode().

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31338

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30832

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30708

   (4) https://bugs.python.org/issue?@action=redirect&bpo=16500

   (5) https://bugs.python.org/issue?@action=redirect&bpo=6532

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27867

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29083

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28769

   (9) https://bugs.python.org/issue?@action=redirect&bpo=29058

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28822

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28808

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28761

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28748

   (14) https://bugs.python.org/issue?@action=redirect&bpo=19569

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28426


File: python.info,  Node: Python 3 6 6 final,  Next: Python 3 6 6 release candidate 1,  Prev: Python 3 7 0 alpha 1,  Up: 変更履歴

1.23.63 Python 3.6.6 final
--------------------------

'Release date: 2018-06-27'

There were no new changes in version 3.6.6.


File: python.info,  Node: Python 3 6 6 release candidate 1,  Next: Python 3 6 5 final,  Prev: Python 3 6 6 final,  Up: 変更履歴

1.23.64 Python 3.6.6 release candidate 1
----------------------------------------

'Release date: 2018-06-11'

* Menu:

* Core and Builtins: Core and Builtins<62>.
* Library: Library<62>.
* Documentation: Documentation<56>.
* Tests: Tests<56>.
* Build: Build<59>.
* Windows: Windows<54>.
* macOS: macOS<44>.
* IDLE: IDLE<46>.
* Tools/Demos: Tools/Demos<31>.
* C API: C API<56>.


File: python.info,  Node: Core and Builtins<62>,  Next: Library<62>,  Up: Python 3 6 6 release candidate 1

1.23.64.1 Core and Builtins
...........................

   - bpo-33786(1): Fix asynchronous generators to handle GeneratorExit
     in athrow() correctly

   - bpo-30654(2): Fixed reset of the SIGINT handler to SIG_DFL on
     interpreter shutdown even when there was a custom handler set
     previously.  Patch by Philipp Kerling.

   - bpo-33622(3): Fixed a leak when the garbage collector fails to add
     an object with the ‘__del__’ method or referenced by it into the
     *note gc.garbage: 1191. list.  *note PyGC_Collect(): 95c. can now
     be called when an exception is set and preserves it.

   - bpo-31849(4): Fix signed/unsigned comparison warning in pyhash.c.

   - bpo-33391(5): Fix a leak in set_symmetric_difference().

   - bpo-28055(6): Fix unaligned accesses in siphash24().  Patch by Rolf
     Eike Beer.

   - bpo-33231(7): Fix potential memory leak in ‘normalizestring()’.

   - bpo-29922(8): Improved error messages in 'async with' when
     ‘__aenter__()’ or ‘__aexit__()’ return non-awaitable object.

   - bpo-33199(9): Fix ‘ma_version_tag’ in dict implementation is
     uninitialized when copying from key-sharing dict.

   - bpo-33041(10): Fixed jumping when the function contains an ‘async
     for’ loop.

   - bpo-32282(11): Fix an unnecessary ifdef in the include of
     VersionHelpers.h in socketmodule on Windows.

   - bpo-21983(12): Fix a crash in ‘ctypes.cast()’ in case the type
     argument is a ctypes structured data type.  Patch by Eryk Sun and
     Oren Milman.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33786

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30654

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33622

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31849

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33391

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28055

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33231

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29922

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33199

   (10) https://bugs.python.org/issue?@action=redirect&bpo=33041

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32282

   (12) https://bugs.python.org/issue?@action=redirect&bpo=21983


File: python.info,  Node: Library<62>,  Next: Documentation<56>,  Prev: Core and Builtins<62>,  Up: Python 3 6 6 release candidate 1

1.23.64.2 Library
.................

   - bpo-30167(1): Prevent site.main() exception if PYTHONSTARTUP is
     set.  Patch by Steve Weber.

   - bpo-33812(2): Datetime instance d with non-None tzinfo, but with
     d.tzinfo.utcoffset(d) returning None is now treated as naive by the
     astimezone() method.

   - bpo-30805(3): Avoid race condition with debug logging

   - bpo-33767(4): The concatenation (‘+’) and repetition (‘*’) sequence
     operations now raise *note TypeError: 502. instead of *note
     SystemError: 541. when performed on *note mmap.mmap: 1ec. objects.
     Patch by Zackery Spytz.

   - bpo-32684(5): Fix gather to propagate cancellation of itself even
     with return_exceptions.

   - bpo-33674(6): Fix a race condition in SSLProtocol.connection_made()
     of asyncio.sslproto: start immediately the handshake instead of
     using call_soon().  Previously, data_received() could be called
     before the handshake started, causing the handshake to hang or
     fail.

   - bpo-31647(7): Fixed bug where calling write_eof() on a
     _SelectorSocketTransport after it's already closed raises
     AttributeError.

   - bpo-33672(8): Fix Task.__repr__ crash with Cython's bogus
     coroutines

   - bpo-33469(9): Fix RuntimeError after closing loop that used
     run_in_executor

   - bpo-11874(10): Use a better regex when breaking usage into
     wrappable parts.  Avoids bogus assertion errors from custom metavar
     strings.

   - bpo-30877(11): Fixed a bug in the Python implementation of the JSON
     decoder that prevented the cache of parsed strings from clearing
     after finishing the decoding.  Based on patch by c-fos.

   - bpo-33548(12): tempfile._candidate_tempdir_list should consider
     common TEMP locations

   - bpo-33542(13): Prevent ‘uuid.get_node’ from using a DUID instead of
     a MAC on Windows.  Patch by Zvi Effron

   - bpo-26819(14): Fix race condition with
     ‘ReadTransport.resume_reading’ in Windows proactor event loop.

   - bpo-28556(15): Minor fixes in typing module: add annotations to
     ‘NamedTuple.__new__’, pass ‘*args’ and ‘**kwds’ in
     ‘Generic.__new__’.  Original PRs by Paulius Šarka and Chad
     Dombrova.

   - bpo-20087(16): Updated alias mapping with glibc 2.27 supported
     locales.

   - bpo-33422(17): Fix trailing quotation marks getting deleted when
     looking up byte/string literals on pydoc.  Patch by Andrés Delfino.

   - bpo-33197(18): Update error message when constructing invalid
     inspect.Parameters Patch by Donghee Na.

   - bpo-33383(19): Fixed crash in the get() method of the *note
     dbm.ndbm: 2c. database object when it is called with a single
     argument.

   - bpo-33329(20): Fix multiprocessing regression on newer glibcs

   - bpo-991266(21): Fix quoting of the ‘Comment’ attribute of *note
     http.cookies.SimpleCookie: 19ae.

   - bpo-33131(22): Upgrade bundled version of pip to 10.0.1.

   - bpo-33308(23): Fixed a crash in the ‘parser’ module when converting
     an ST object to a tree of tuples or lists with ‘line_info=False’
     and ‘col_info=True’.

   - bpo-33263(24): Fix FD leak in ‘_SelectorSocketTransport’ Patch by
     Vlad Starostin.

   - bpo-33256(25): Fix display of ‘<module>’ call in the html produced
     by ‘cgitb.html()’.  Patch by Stéphane Blondon.

   - bpo-33203(26): ‘random.Random.choice()’ now raises ‘IndexError’ for
     empty sequences consistently even when called from subclasses
     without a ‘getrandbits()’ implementation.

   - bpo-33224(27): Update difflib.mdiff() for PEP 479(28).  Convert an
     uncaught StopIteration in a generator into a return-statement.

   - bpo-33209(29): End framing at the end of C implementation of *note
     pickle.Pickler.dump(): 19b0.

   - bpo-32861(30): The urllib.robotparser's ‘__str__’ representation
     now includes wildcard entries and the "Crawl-delay" and
     "Request-rate" fields.  Patch by Michael Lazar.

   - bpo-33096(31): Allow ttk.Treeview.insert to insert iid that has a
     false boolean value.  Note iid=0 and iid=False would be same.
     Patch by Garvit Khatri.

   - bpo-33127(32): The ssl module now compiles with LibreSSL 2.7.1.

   - bpo-33021(33): Release the GIL during fstat() calls, avoiding hang
     of all threads when calling mmap.mmap(), os.urandom(), and
     random.seed().  Patch by Nir Soffer.

   - bpo-27683(34): Fix a regression in *note ipaddress: 74. that result
     of ‘hosts()’ is empty when the network is constructed by a tuple
     containing an integer mask and only 1 bit left for addresses.

   - bpo-32844(35): Fix wrong redirection of a low descriptor (0 or 1)
     to stderr in subprocess if another low descriptor is closed.

   - bpo-31908(36): Fix output of cover files for ‘trace’ module
     command-line tool.  Previously emitted cover files only when
     ‘--missing’ option was used.  Patch by Michael Selik.

   - bpo-31457(37): If nested log adapters are used, the inner
     ‘process()’ methods are no longer omitted.

   - bpo-16865(38): Support arrays >=2GiB in *note ctypes: 22.  Patch by
     Segev Finer.

   - bpo-31238(39): pydoc: the stop() method of the private ServerThread
     class now waits until DocServer.serve_until_quit() completes and
     then explicitly sets its docserver attribute to None to break a
     reference cycle.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30167

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33812

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30805

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33767

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32684

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33674

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31647

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33672

   (9) https://bugs.python.org/issue?@action=redirect&bpo=33469

   (10) https://bugs.python.org/issue?@action=redirect&bpo=11874

   (11) https://bugs.python.org/issue?@action=redirect&bpo=30877

   (12) https://bugs.python.org/issue?@action=redirect&bpo=33548

   (13) https://bugs.python.org/issue?@action=redirect&bpo=33542

   (14) https://bugs.python.org/issue?@action=redirect&bpo=26819

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (16) https://bugs.python.org/issue?@action=redirect&bpo=20087

   (17) https://bugs.python.org/issue?@action=redirect&bpo=33422

   (18) https://bugs.python.org/issue?@action=redirect&bpo=33197

   (19) https://bugs.python.org/issue?@action=redirect&bpo=33383

   (20) https://bugs.python.org/issue?@action=redirect&bpo=33329

   (21) https://bugs.python.org/issue?@action=redirect&bpo=991266

   (22) https://bugs.python.org/issue?@action=redirect&bpo=33131

   (23) https://bugs.python.org/issue?@action=redirect&bpo=33308

   (24) https://bugs.python.org/issue?@action=redirect&bpo=33263

   (25) https://bugs.python.org/issue?@action=redirect&bpo=33256

   (26) https://bugs.python.org/issue?@action=redirect&bpo=33203

   (27) https://bugs.python.org/issue?@action=redirect&bpo=33224

   (28) https://peps.python.org/pep-0479/

   (29) https://bugs.python.org/issue?@action=redirect&bpo=33209

   (30) https://bugs.python.org/issue?@action=redirect&bpo=32861

   (31) https://bugs.python.org/issue?@action=redirect&bpo=33096

   (32) https://bugs.python.org/issue?@action=redirect&bpo=33127

   (33) https://bugs.python.org/issue?@action=redirect&bpo=33021

   (34) https://bugs.python.org/issue?@action=redirect&bpo=27683

   (35) https://bugs.python.org/issue?@action=redirect&bpo=32844

   (36) https://bugs.python.org/issue?@action=redirect&bpo=31908

   (37) https://bugs.python.org/issue?@action=redirect&bpo=31457

   (38) https://bugs.python.org/issue?@action=redirect&bpo=16865

   (39) https://bugs.python.org/issue?@action=redirect&bpo=31238


File: python.info,  Node: Documentation<56>,  Next: Tests<56>,  Prev: Library<62>,  Up: Python 3 6 6 release candidate 1

1.23.64.3 Documentation
.......................

   - bpo-33503(1): Fix broken pypi link

   - bpo-33421(2): Add missing documentation for
     ‘typing.AsyncContextManager’.

   - bpo-33378(3): Add Korean language switcher for
     ‘https://docs.python.org/3/’

   - bpo-33276(4): Clarify that the ‘__path__’ attribute on modules
     cannot be just any value.

   - bpo-33201(5): Modernize documentation for writing C extension
     types.

   - bpo-33195(6): Deprecate ‘Py_UNICODE’ usage in ‘c-api/arg’ document.
     ‘Py_UNICODE’ related APIs are deprecated since Python 3.3, but it
     is missed in the document.

   - bpo-33126(7): Document PyBuffer_ToContiguous().

   - bpo-27212(8): Modify documentation for the ‘islice()’ recipe to
     consume initial values up to the start index.

   - bpo-28247(9): Update *note zipapp: 116. documentation to describe
     how to make standalone applications.

   - bpo-18802(10): Documentation changes for ipaddress.  Patch by Jon
     Foster and Berker Peksag.

   - bpo-27428(11): Update documentation to clarify that
     ‘WindowsRegistryFinder’ implements ‘MetaPathFinder’.  (Patch by
     Himanshu Lakhara)

   - bpo-8243(12): Add a note about curses.addch and curses.addstr
     exception behavior when writing outside a window, or pad.

   - bpo-31432(13): Clarify meaning of CERT_NONE, CERT_OPTIONAL, and
     CERT_REQUIRED flags for ssl.SSLContext.verify_mode.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33503

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33421

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33378

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33276

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33201

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33195

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33126

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27212

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28247

   (10) https://bugs.python.org/issue?@action=redirect&bpo=18802

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27428

   (12) https://bugs.python.org/issue?@action=redirect&bpo=8243

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31432


File: python.info,  Node: Tests<56>,  Next: Build<59>,  Prev: Documentation<56>,  Up: Python 3 6 6 release candidate 1

1.23.64.4 Tests
...............

   - bpo-33655(1): Ignore test_posix_fallocate failures on BSD platforms
     that might be due to running on ZFS.

   - bpo-19417(2): Add test_bdb.py.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33655

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19417


File: python.info,  Node: Build<59>,  Next: Windows<54>,  Prev: Tests<56>,  Up: Python 3 6 6 release candidate 1

1.23.64.5 Build
...............

   - bpo-5755(1): Move ‘-Wstrict-prototypes’ option to ‘CFLAGS_NODIST’
     from ‘OPT’.  This option emitted annoying warnings when building
     extension modules written in C++.

   - bpo-33614(2): Ensures module definition files for the stable ABI on
     Windows are correctly regenerated.

   - bpo-33522(3): Enable CI builds on Visual Studio Team Services at
     ‘https://python.visualstudio.com/cpython’

   - bpo-33012(4): Add ‘-Wno-cast-function-type’ for gcc 8 for silencing
     warnings about function casts like casting to PyCFunction in method
     definition lists.

   - bpo-33394(5): Enable the verbose build for extension modules, when
     GNU make is passed macros on the command line.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5755

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33614

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33522

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33012

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33394


File: python.info,  Node: Windows<54>,  Next: macOS<44>,  Prev: Build<59>,  Up: Python 3 6 6 release candidate 1

1.23.64.6 Windows
.................

   - bpo-33184(1): Update Windows installer to OpenSSL 1.0.2o.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33184


File: python.info,  Node: macOS<44>,  Next: IDLE<46>,  Prev: Windows<54>,  Up: Python 3 6 6 release candidate 1

1.23.64.7 macOS
...............

   - bpo-33184(1): Update macOS installer build to use OpenSSL 1.0.2o.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33184


File: python.info,  Node: IDLE<46>,  Next: Tools/Demos<31>,  Prev: macOS<44>,  Up: Python 3 6 6 release candidate 1

1.23.64.8 IDLE
..............

   - bpo-33656(1): On Windows, add API call saying that tk scales for
     DPI. On Windows 8.1+ or 10, with DPI compatibility properties of
     the Python binary unchanged, and a monitor resolution greater than
     96 DPI, this should make text and lines sharper.  It should
     otherwise have no effect.

   - bpo-33768(2): Clicking on a context line moves that line to the top
     of the editor window.

   - bpo-33763(3): IDLE: Use read-only text widget for code context
     instead of label widget.

   - bpo-33664(4): Scroll IDLE editor text by lines.  Previously, the
     mouse wheel and scrollbar slider moved text by a fixed number of
     pixels, resulting in partial lines at the top of the editor box.
     The change also applies to the shell and grep output windows, but
     not to read-only text views.

   - bpo-33679(5): Enable theme-specific color configuration for Code
     Context.  Use the Highlights tab to see the setting for built-in
     themes or add settings to custom themes.

   - bpo-33642(6): Display up to maxlines non-blank lines for Code
     Context.  If there is no current context, show a single blank line.

   - bpo-33628(7): IDLE: Cleanup codecontext.py and its test.

   - bpo-33564(8): IDLE's code context now recognizes async as a block
     opener.

   - bpo-29706(9): IDLE now colors async and await as keywords in 3.6.
     They become full keywords in 3.7.

   - bpo-21474(10): Update word/identifier definition from ascii to
     unicode.  In text and entry boxes, this affects selection by
     double-click, movement left/right by control-left/right, and
     deletion left/right by control-BACKSPACE/DEL.

   - bpo-33204(11): IDLE: consistently color invalid string prefixes.  A
     'u' string prefix cannot be paired with either 'r' or 'f'.
     Consistently color as much of the prefix, starting at the right, as
     is valid.  Revise and extend colorizer test.

   - bpo-32831(12): Add docstrings and tests for codecontext.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33656

   (2) https://bugs.python.org/issue?@action=redirect&bpo=33768

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33763

   (4) https://bugs.python.org/issue?@action=redirect&bpo=33664

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33679

   (6) https://bugs.python.org/issue?@action=redirect&bpo=33642

   (7) https://bugs.python.org/issue?@action=redirect&bpo=33628

   (8) https://bugs.python.org/issue?@action=redirect&bpo=33564

   (9) https://bugs.python.org/issue?@action=redirect&bpo=29706

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21474

   (11) https://bugs.python.org/issue?@action=redirect&bpo=33204

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32831


File: python.info,  Node: Tools/Demos<31>,  Next: C API<56>,  Prev: IDLE<46>,  Up: Python 3 6 6 release candidate 1

1.23.64.9 Tools/Demos
.....................

   - bpo-33189(1): ‘pygettext.py’ now recognizes only literal strings as
     docstrings and translatable strings, and rejects bytes literals and
     f-string expressions.

   - bpo-31920(2): Fixed handling directories as arguments in the
     ‘pygettext’ script.  Based on patch by Oleg Krasnikov.

   - bpo-29673(3): Fix pystackv and pystack gdbinit macros.

   - bpo-32885(4): Add an ‘-n’ flag for ‘Tools/scripts/pathfix.py’ to
     disable automatic backup creation (files with ‘~’ suffix).

   - bpo-31583(5): Fix 2to3 for using with -add-suffix option but
     without -output-dir option for relative path to files in current
     directory.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33189

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31920

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29673

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32885

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31583


File: python.info,  Node: C API<56>,  Prev: Tools/Demos<31>,  Up: Python 3 6 6 release candidate 1

1.23.64.10 C API
................

   - bpo-32374(1): Document that m_traverse for multi-phase initialized
     modules can be called with m_state=NULL, and add a sanity check

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32374


File: python.info,  Node: Python 3 6 5 final,  Next: Python 3 6 5 release candidate 1,  Prev: Python 3 6 6 release candidate 1,  Up: 変更履歴

1.23.65 Python 3.6.5 final
--------------------------

'Release date: 2018-03-28'

* Menu:

* Tests: Tests<57>.
* Build: Build<60>.


File: python.info,  Node: Tests<57>,  Next: Build<60>,  Up: Python 3 6 5 final

1.23.65.1 Tests
...............

   - bpo-32872(1): Avoid regrtest compatibility issue with namespace
     packages.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32872


File: python.info,  Node: Build<60>,  Prev: Tests<57>,  Up: Python 3 6 5 final

1.23.65.2 Build
...............

   - bpo-33163(1): Upgrade pip to 9.0.3 and setuptools to v39.0.1.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33163


File: python.info,  Node: Python 3 6 5 release candidate 1,  Next: Python 3 6 4 final,  Prev: Python 3 6 5 final,  Up: 変更履歴

1.23.66 Python 3.6.5 release candidate 1
----------------------------------------

'Release date: 2018-03-13'

* Menu:

* Security: Security<38>.
* Core and Builtins: Core and Builtins<63>.
* Library: Library<63>.
* Documentation: Documentation<57>.
* Tests: Tests<58>.
* Build: Build<61>.
* Windows: Windows<55>.
* macOS: macOS<45>.
* IDLE: IDLE<47>.
* Tools/Demos: Tools/Demos<32>.
* C API: C API<57>.


File: python.info,  Node: Security<38>,  Next: Core and Builtins<63>,  Up: Python 3 6 5 release candidate 1

1.23.66.1 Security
..................

   - bpo-33001(1): Minimal fix to prevent buffer overrun in os.symlink
     on Windows

   - bpo-32981(2): Regexes in difflib and poplib were vulnerable to
     catastrophic backtracking.  These regexes formed potential DOS
     vectors (REDOS). They have been refactored.  This resolves CVE
     2018-1060(3) and CVE 2018-1061(4).  Patch by Jamie Davis.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33001

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32981

   (3) https://www.cve.org/CVERecord?id=CVE-2018-1060

   (4) https://www.cve.org/CVERecord?id=CVE-2018-1061


File: python.info,  Node: Core and Builtins<63>,  Next: Library<63>,  Prev: Security<38>,  Up: Python 3 6 5 release candidate 1

1.23.66.2 Core and Builtins
...........................

   - bpo-33026(1): Fixed jumping out of "with" block by setting
     f_lineno.

   - bpo-17288(2): Prevent jumps from 'return' and 'exception' trace
     events.

   - bpo-32889(3): Update Valgrind suppression list to account for the
     rename of ‘Py_ADDRESS_IN_RANG’ to ‘address_in_range’.

   - bpo-32650(4): Pdb and other debuggers dependent on bdb.py will
     correctly step over (next command) native coroutines.  Patch by
     Pablo Galindo.

   - bpo-32685(5): Improve suggestion when the Python 2 form of print
     statement is either present on the same line as the header of a
     compound statement or else terminated by a semi-colon instead of a
     newline.  Patch by Nitish Chandra.

   - bpo-32583(6): Fix possible crashing in builtin Unicode decoders
     caused by write out-of-bound errors when using customized decode
     error handlers.

   - bpo-26163(7): Improved frozenset() hash to create more distinct
     hash values when faced with datasets containing many similar
     values.

   - bpo-27169(8): The ‘__debug__’ constant is now optimized out at
     compile time.  This fixes also bpo-22091(9).

   - bpo-32329(10): ‘sys.flags.hash_randomization’ is now properly set
     to 0 when hash randomization is turned off by ‘PYTHONHASHSEED=0’.

   - bpo-30416(11): The optimizer is now protected from spending much
     time doing complex calculations and consuming much memory for
     creating large constants in constant folding.

   - bpo-18533(12): ‘repr()’ on a dict containing its own ‘values()’ or
     ‘items()’ no longer raises ‘RecursionError’; OrderedDict similarly.
     Instead, use ‘...’, as for other recursive structures.  Patch by
     Ben North.

   - bpo-32028(13): Leading whitespace is now correctly ignored when
     generating suggestions for converting Py2 print statements to Py3
     builtin print function calls.  Patch by Sanyam Khurana.

   - bpo-32137(14): The repr of deeply nested dict now raises a
     RecursionError instead of crashing due to a stack overflow.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33026

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17288

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32889

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32650

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32685

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32583

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26163

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27169

   (9) https://bugs.python.org/issue?@action=redirect&bpo=22091

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32329

   (11) https://bugs.python.org/issue?@action=redirect&bpo=30416

   (12) https://bugs.python.org/issue?@action=redirect&bpo=18533

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32028

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32137


File: python.info,  Node: Library<63>,  Next: Documentation<57>,  Prev: Core and Builtins<63>,  Up: Python 3 6 5 release candidate 1

1.23.66.3 Library
.................

   - bpo-33064(1): lib2to3 now properly supports trailing commas after
     ‘*args’ and ‘**kwargs’ in function signatures.

   - bpo-31804(2): Avoid failing in multiprocessing.Process if the
     standard streams are closed or None at exit.

   - bpo-33037(3): Skip sending/receiving data after SSL transport
     closing.

   - bpo-30353(4): Fix ctypes pass-by-value for structs on 64-bit
     Cygwin/MinGW.

   - bpo-33009(5): Fix inspect.signature() for single-parameter
     partialmethods.

   - bpo-32969(6): Expose several missing constants in zlib and fix
     corresponding documentation.

   - bpo-32713(7): Fixed tarfile.itn handling of out-of-bounds float
     values.  Patch by Joffrey Fuhrer.

   - bpo-30622(8): The ssl module now detects missing NPN support in
     LibreSSL.

   - bpo-32922(9): dbm.open() now encodes filename with the filesystem
     encoding rather than default encoding.

   - bpo-32859(10): In ‘os.dup2’, don't check every call whether the
     ‘dup3’ syscall exists or not.

   - bpo-21060(11): Rewrite confusing message from setup.py upload from
     "No dist file created in earlier command" to the more helpful "Must
     create and upload files in one command".

   - bpo-32857(12): In *note tkinter: d9, ‘after_cancel(None)’ now
     raises a *note ValueError: 1e3. instead of canceling the first
     scheduled function.  Patch by Cheryl Sabella.

   - bpo-32852(13): Make sure sys.argv remains as a list when running
     trace.

   - bpo-32841(14): Fixed ‘asyncio.Condition’ issue which silently
     ignored cancellation after notifying and cancelling a conditional
     lock.  Patch by Bar Harel.

   - bpo-31787(15): Fixed refleaks of ‘__init__()’ methods in various
     modules.  (Contributed by Oren Milman)

   - bpo-30157(16): Fixed guessing quote and delimiter in
     csv.Sniffer.sniff() when only the last field is quoted.  Patch by
     Jake Davis.

   - bpo-32394(17): socket: Remove TCP_FASTOPEN, TCP_KEEPCNT flags on
     older version Windows during run-time.

   - bpo-32777(18): Fix a rare but potential pre-exec child process
     deadlock in subprocess on POSIX systems when marking file
     descriptors inheritable on exec in the child process.  This bug
     appears to have been introduced in 3.4.

   - bpo-32647(19): The ctypes module used to depend on indirect linking
     for dlopen.  The shared extension is now explicitly linked against
     libdl on platforms with dl.

   - bpo-32734(20): Fixed ‘asyncio.Lock()’ safety issue which allowed
     acquiring and locking the same lock multiple times, without it
     being free.  Patch by Bar Harel.

   - bpo-32727(21): Do not include name field in SMTP envelope from
     address.  Patch by Stéphane Wirtel

   - bpo-27931(22): Fix email address header parsing error when the
     username is an empty quoted string.  Patch by Xiang Zhang.

   - bpo-32304(23): distutils' upload command no longer corrupts tar
     files ending with a CR byte, and no longer tries to convert CR to
     CRLF in any of the upload text fields.

   - bpo-32502(24): uuid.uuid1 no longer raises an exception if a 64-bit
     hardware address is encountered.

   - bpo-31848(25): Fix the error handling in Aifc_read.initfp() when
     the SSND chunk is not found.  Patch by Zackery Spytz.

   - bpo-32555(26): On FreeBSD and Solaris, os.strerror() now always
     decode the byte string from the current locale encoding, rather
     than using ASCII/surrogateescape in some cases.

   - bpo-32521(27): The nis module is now compatible with new libnsl and
     headers location.

   - bpo-32473(28): Improve ABCMeta._dump_registry() output readability

   - bpo-32521(29): glibc has removed Sun RPC. Use replacement libtirpc
     headers and library in nis module.

   - bpo-32228(30): Ensure that ‘truncate()’ preserves the file position
     (as reported by ‘tell()’) after writes longer than the buffer size.

   - bpo-26133(31): Don't unsubscribe signals in asyncio UNIX event loop
     on interpreter shutdown.

   - bpo-32185(32): The SSL module no longer sends IP addresses in SNI
     TLS extension on platforms with OpenSSL 1.0.2+ or inet_pton.

   - bpo-32323(33): *note urllib.parse.urlsplit(): d0d. does not convert
     zone-id (scope) to lower case for scoped IPv6 addresses in
     hostnames now.

   - bpo-32302(34): Fix bdist_wininst of distutils for CRT v142: it
     binary compatible with CRT v140.

   - bpo-32255(35): A single empty field is now always quoted when
     written into a CSV file.  This allows to distinguish an empty row
     from a row consisting of a single empty field.  Patch by Licht
     Takeuchi.

   - bpo-32277(36): Raise ‘NotImplementedError’ instead of ‘SystemError’
     on platforms where ‘chmod(..., follow_symlinks=False)’ is not
     supported.  Patch by Anthony Sottile.

   - bpo-32199(37): The getnode() ip getter now uses 'ip link' instead
     of 'ip link list'.

   - bpo-27456(38): Ensure TCP_NODELAY is set on Linux.  Tests by Victor
     Stinner.

   - bpo-31900(39): The *note locale.localeconv(): bcc. function now
     sets temporarily the ‘LC_CTYPE’ locale to the ‘LC_NUMERIC’ locale
     to decode ‘decimal_point’ and ‘thousands_sep’ byte strings if they
     are non-ASCII or longer than 1 byte, and the ‘LC_NUMERIC’ locale is
     different than the ‘LC_CTYPE’ locale.  This temporary change
     affects other threads.  Same change for the *note str.format():
     5ed. method when formatting a number (*note int: 238, *note float:
     2ce, *note float: 2ce. and subclasses) with the ‘n’ type (ex:
     ‘'{:n}'.format(1234)’).

   - bpo-31802(40): Importing native path module (‘posixpath’, ‘ntpath’)
     now works even if the ‘os’ module still is not imported.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33064

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31804

   (3) https://bugs.python.org/issue?@action=redirect&bpo=33037

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30353

   (5) https://bugs.python.org/issue?@action=redirect&bpo=33009

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32969

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32713

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30622

   (9) https://bugs.python.org/issue?@action=redirect&bpo=32922

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32859

   (11) https://bugs.python.org/issue?@action=redirect&bpo=21060

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32857

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32852

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32841

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31787

   (16) https://bugs.python.org/issue?@action=redirect&bpo=30157

   (17) https://bugs.python.org/issue?@action=redirect&bpo=32394

   (18) https://bugs.python.org/issue?@action=redirect&bpo=32777

   (19) https://bugs.python.org/issue?@action=redirect&bpo=32647

   (20) https://bugs.python.org/issue?@action=redirect&bpo=32734

   (21) https://bugs.python.org/issue?@action=redirect&bpo=32727

   (22) https://bugs.python.org/issue?@action=redirect&bpo=27931

   (23) https://bugs.python.org/issue?@action=redirect&bpo=32304

   (24) https://bugs.python.org/issue?@action=redirect&bpo=32502

   (25) https://bugs.python.org/issue?@action=redirect&bpo=31848

   (26) https://bugs.python.org/issue?@action=redirect&bpo=32555

   (27) https://bugs.python.org/issue?@action=redirect&bpo=32521

   (28) https://bugs.python.org/issue?@action=redirect&bpo=32473

   (29) https://bugs.python.org/issue?@action=redirect&bpo=32521

   (30) https://bugs.python.org/issue?@action=redirect&bpo=32228

   (31) https://bugs.python.org/issue?@action=redirect&bpo=26133

   (32) https://bugs.python.org/issue?@action=redirect&bpo=32185

   (33) https://bugs.python.org/issue?@action=redirect&bpo=32323

   (34) https://bugs.python.org/issue?@action=redirect&bpo=32302

   (35) https://bugs.python.org/issue?@action=redirect&bpo=32255

   (36) https://bugs.python.org/issue?@action=redirect&bpo=32277

   (37) https://bugs.python.org/issue?@action=redirect&bpo=32199

   (38) https://bugs.python.org/issue?@action=redirect&bpo=27456

   (39) https://bugs.python.org/issue?@action=redirect&bpo=31900

   (40) https://bugs.python.org/issue?@action=redirect&bpo=31802


File: python.info,  Node: Documentation<57>,  Next: Tests<58>,  Prev: Library<63>,  Up: Python 3 6 5 release candidate 1

1.23.66.4 Documentation
.......................

   - bpo-17232(1): Clarify docs for -O and -OO. Patch by Terry Reedy.

   - bpo-32800(2): Update link to w3c doc for xml default namespaces.

   - bpo-8722(3): Document ‘__getattr__()’ behavior when property
     ‘get()’ method raises *note AttributeError: 326.

   - bpo-32614(4): Modify RE examples in documentation to use raw
     strings to prevent *note DeprecationWarning: 18a. and add text to
     REGEX HOWTO to highlight the deprecation.

   - bpo-31972(5): Improve docstrings for ‘pathlib.PurePath’ subclasses.

   - bpo-17799(6): Explain real behaviour of sys.settrace and
     sys.setprofile and their C-API counterparts regarding which type of
     events are received in each function.  Patch by Pablo Galindo
     Salgado.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=17232

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32800

   (3) https://bugs.python.org/issue?@action=redirect&bpo=8722

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32614

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31972

   (6) https://bugs.python.org/issue?@action=redirect&bpo=17799


File: python.info,  Node: Tests<58>,  Next: Build<61>,  Prev: Documentation<57>,  Up: Python 3 6 5 release candidate 1

1.23.66.5 Tests
...............

   - bpo-32517(1): Fix failing ‘test_asyncio’ on macOS 10.12.2+ due to
     transport of ‘KqueueSelector’ loop was not being closed.

   - bpo-32721(2): Fix test_hashlib to not fail if the _md5 module is
     not built.

   - bpo-32252(3): Fix faulthandler_suppress_crash_report() used to
     prevent core dump files when testing crashes.  getrlimit() returns
     zero on success.

   - bpo-31518(4): Debian Unstable has disabled TLS 1.0 and 1.1 for
     SSLv23_METHOD().  Change TLS/SSL protocol of some tests to
     PROTOCOL_TLS or PROTOCOL_TLSv1_2 to make them pass on Debian.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32517

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32721

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32252

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31518


File: python.info,  Node: Build<61>,  Next: Windows<55>,  Prev: Tests<58>,  Up: Python 3 6 5 release candidate 1

1.23.66.6 Build
...............

   - bpo-32635(1): Fix segfault of the crypt module when libxcrypt is
     provided instead of libcrypt at the system.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32635


File: python.info,  Node: Windows<55>,  Next: macOS<45>,  Prev: Build<61>,  Up: Python 3 6 5 release candidate 1

1.23.66.7 Windows
.................

   - bpo-33016(1): Fix potential use of uninitialized memory in
     nt._getfinalpathname

   - bpo-32903(2): Fix a memory leak in os.chdir() on Windows if the
     current directory is set to a UNC path.

   - bpo-31966(3): Fixed WindowsConsoleIO.write() for writing empty
     data.

   - bpo-32409(4): Ensures activate.bat can handle Unicode contents.

   - bpo-32457(5): Improves handling of denormalized executable path
     when launching Python.

   - bpo-32370(6): Use the correct encoding for ipconfig output in the
     uuid module.  Patch by Segev Finer.

   - bpo-29248(7): Fix *note os.readlink(): 8ee. on Windows, which was
     mistakenly treating the ‘PrintNameOffset’ field of the reparse data
     buffer as a number of characters instead of bytes.  Patch by Craig
     Holmquist and SSE4.

   - bpo-32588(8): Create standalone _distutils_findvs module.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33016

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32903

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31966

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32409

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32457

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32370

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29248

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32588


File: python.info,  Node: macOS<45>,  Next: IDLE<47>,  Prev: Windows<55>,  Up: Python 3 6 5 release candidate 1

1.23.66.8 macOS
...............

   - bpo-32726(1): Provide an additional, more modern macOS installer
     variant that supports macOS 10.9+ systems in 64-bit mode only.
     Upgrade the supplied third-party libraries to OpenSSL 1.0.2n, XZ
     5.2.3, and SQLite 3.22.0.  The 10.9+ installer now links with and
     supplies its own copy of Tcl/Tk 8.6.8.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32726


File: python.info,  Node: IDLE<47>,  Next: Tools/Demos<32>,  Prev: macOS<45>,  Up: Python 3 6 5 release candidate 1

1.23.66.9 IDLE
..............

   - bpo-32984(1): Set ‘__file__’ while running a startup file.  Like
     Python, IDLE optionally runs one startup file in the Shell window
     before presenting the first interactive input prompt.  For IDLE,
     ‘-s’ runs a file named in environmental variable ‘IDLESTARTUP’ or
     *note PYTHONSTARTUP: f95.; ‘-r file’ runs ‘file’.  Python sets
     ‘__file__’ to the startup file name before running the file and
     unsets it before the first prompt.  IDLE now does the same when run
     normally, without the ‘-n’ option.

   - bpo-32940(2): Simplify and rename StringTranslatePseudoMapping in
     pyparse.

   - bpo-32916(3): Change ‘str’ to ‘code’ in pyparse.

   - bpo-32905(4): Remove unused code in pyparse module.

   - bpo-32874(5): Add tests for pyparse.

   - bpo-32837(6): Using the system and place-dependent default encoding
     for open() is a bad idea for IDLE's system and location-independent
     files.

   - bpo-32826(7): Add "encoding=utf-8" to open() in IDLE's
     test_help_about.  GUI test test_file_buttons() only looks at
     initial ascii-only lines, but failed on systems where open()
     defaults to 'ascii' because readline() internally reads and decodes
     far enough ahead to encounter a non-ascii character in CREDITS.txt.

   - bpo-32765(8): Update configdialog General tab docstring to add new
     widgets to the widget list.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32984

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32940

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32916

   (4) https://bugs.python.org/issue?@action=redirect&bpo=32905

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32874

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32837

   (7) https://bugs.python.org/issue?@action=redirect&bpo=32826

   (8) https://bugs.python.org/issue?@action=redirect&bpo=32765


File: python.info,  Node: Tools/Demos<32>,  Next: C API<57>,  Prev: IDLE<47>,  Up: Python 3 6 5 release candidate 1

1.23.66.10 Tools/Demos
......................

   - bpo-24960(1): 2to3 and lib2to3 can now read pickled grammar files
     using pkgutil.get_data() rather than probing the filesystem.  This
     lets 2to3 and lib2to3 work when run from a zipfile.

   - bpo-32222(2): Fix pygettext not extracting docstrings for functions
     with type annotated arguments.  Patch by Toby Harradine.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24960

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32222


File: python.info,  Node: C API<57>,  Prev: Tools/Demos<32>,  Up: Python 3 6 5 release candidate 1

1.23.66.11 C API
................

   - bpo-29084(1): Undocumented C API for OrderedDict has been excluded
     from the limited C API. It was added by mistake and actually never
     worked in the limited C API.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29084


File: python.info,  Node: Python 3 6 4 final,  Next: Python 3 6 4 release candidate 1,  Prev: Python 3 6 5 release candidate 1,  Up: 変更履歴

1.23.67 Python 3.6.4 final
--------------------------

'Release date: 2017-12-18'

There were no new code changes in version 3.6.4 since v3.6.4rc1.


File: python.info,  Node: Python 3 6 4 release candidate 1,  Next: Python 3 6 3 final,  Prev: Python 3 6 4 final,  Up: 変更履歴

1.23.68 Python 3.6.4 release candidate 1
----------------------------------------

'Release date: 2017-12-05'

* Menu:

* Core and Builtins: Core and Builtins<64>.
* Library: Library<64>.
* Documentation: Documentation<58>.
* Tests: Tests<59>.
* Build: Build<62>.
* Windows: Windows<56>.
* macOS: macOS<46>.
* IDLE: IDLE<48>.
* Tools/Demos: Tools/Demos<33>.
* C API: C API<58>.


File: python.info,  Node: Core and Builtins<64>,  Next: Library<64>,  Up: Python 3 6 4 release candidate 1

1.23.68.1 Core and Builtins
...........................

   - bpo-32176(1): co_flags.CO_NOFREE is now always set correctly by the
     code object constructor based on freevars and cellvars, rather than
     needing to be set correctly by the caller.  This ensures it will be
     cleared automatically when additional cell references are injected
     into a modified code object and function.

   - bpo-31949(2): Fixed several issues in printing tracebacks
     (PyTraceBack_Print()).  Setting sys.tracebacklimit to 0 or less now
     suppresses printing tracebacks.  Setting sys.tracebacklimit to None
     now causes using the default limit.  Setting sys.tracebacklimit to
     an integer larger than LONG_MAX now means using the limit LONG_MAX
     rather than the default limit.  Fixed integer overflows in the case
     of more than ‘2**31’ traceback items on Windows.  Fixed output
     errors handling.

   - bpo-30696(3): Fix the interactive interpreter looping endlessly
     when no memory.

   - bpo-20047(4): Bytearray methods partition() and rpartition() now
     accept only bytes-like objects as separator, as documented.  In
     particular they now raise TypeError rather of returning a bogus
     result when an integer is passed as a separator.

   - bpo-31852(5): Fix a segmentation fault caused by a combination of
     the async soft keyword and continuation lines.

   - bpo-21720(6): BytesWarning no longer emitted when the 'fromlist'
     argument of ‘__import__()’ or the ‘__all__’ attribute of the module
     contain bytes instances.

   - bpo-31825(7): Fixed OverflowError in the 'unicode-escape' codec and
     in codecs.escape_decode() when decode an escaped non-ascii byte.

   - bpo-28603(8): Print the full context/cause chain of exceptions on
     interpreter exit, even if an exception in the chain is unhashable
     or compares equal to later ones.  Patch by Zane Bitter.

   - bpo-31786(9): Fix timeout rounding in the select module to round
     correctly negative timeouts between -1.0 and 0.0.  The functions
     now block waiting for events as expected.  Previously, the call was
     incorrectly non-blocking.  Patch by Pablo Galindo.

   - bpo-31642(10): Restored blocking "from package import module" by
     setting sys.modules["package.module"] to None.

   - bpo-31626(11): Fixed a bug in debug memory allocator.  There was a
     write to freed memory after shrinking a memory block.

   - bpo-31619(12): Fixed a ValueError when convert a string with large
     number of underscores to integer with binary base.

   - bpo-31592(13): Fixed an assertion failure in Python parser in case
     of a bad ‘unicodedata.normalize()’.  Patch by Oren Milman.

   - bpo-31588(14): Raise a ‘TypeError’ with a helpful error message
     when class creation fails due to a metaclass with a bad
     ‘__prepare__()’ method.  Patch by Oren Milman.

   - bpo-31566(15): Fix an assertion failure in ‘_warnings.warn()’ in
     case of a bad ‘__name__’ global.  Patch by Oren Milman.

   - bpo-31505(16): Fix an assertion failure in ‘json’, in case
     ‘_json.make_encoder()’ received a bad ‘encoder()’ argument.  Patch
     by Oren Milman.

   - bpo-31492(17): Fix assertion failures in case of failing to import
     from a module with a bad ‘__name__’ attribute, and in case of
     failing to access an attribute of such a module.  Patch by Oren
     Milman.

   - bpo-31490(18): Fix an assertion failure in ‘ctypes’ class
     definition, in case the class has an attribute whose name is
     specified in ‘_anonymous_’ but not in ‘_fields_’.  Patch by Oren
     Milman.

   - bpo-31478(19): Fix an assertion failure in ‘_random.Random.seed()’
     in case the argument has a bad ‘__abs__()’ method.  Patch by Oren
     Milman.

   - bpo-31315(20): Fix an assertion failure in imp.create_dynamic(),
     when spec.name is not a string.  Patch by Oren Milman.

   - bpo-31311(21): Fix a crash in the ‘__setstate__()’ method of
     ‘ctypes._CData’, in case of a bad ‘__dict__’.  Patch by Oren
     Milman.

   - bpo-31293(22): Fix crashes in true division and multiplication of a
     timedelta object by a float with a bad as_integer_ratio() method.
     Patch by Oren Milman.

   - bpo-31285(23): Fix an assertion failure in
     ‘warnings.warn_explicit’, when the return value of the received
     loader's ‘get_source()’ has a bad ‘splitlines()’ method.  Patch by
     Oren Milman.

   - bpo-30817(24): ‘PyErr_PrintEx()’ clears now the ignored exception
     that may be raised by ‘_PySys_SetObjectId()’, for example when no
     memory.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32176

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31949

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30696

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20047

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31852

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21720

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31825

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28603

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31786

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31642

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31626

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31619

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31592

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31588

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31566

   (16) https://bugs.python.org/issue?@action=redirect&bpo=31505

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31492

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31490

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31478

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31315

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31311

   (22) https://bugs.python.org/issue?@action=redirect&bpo=31293

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31285

   (24) https://bugs.python.org/issue?@action=redirect&bpo=30817


File: python.info,  Node: Library<64>,  Next: Documentation<58>,  Prev: Core and Builtins<64>,  Up: Python 3 6 4 release candidate 1

1.23.68.2 Library
.................

   - bpo-28556(1): Two minor fixes for ‘typing’ module: allow shallow
     copying instances of generic classes, improve interaction of
     ‘__init_subclass__’ with generics.  Original PRs by Ivan
     Levkivskyi.

   - bpo-27240(2): The header folding algorithm for the new email
     policies has been rewritten, which also fixes bpo-30788(3),
     bpo-31831(4), and bpo-32182(5).  In particular, RFC2231 folding is
     now done correctly.

   - bpo-32186(6): io.FileIO.readall() and io.FileIO.read() now release
     the GIL when getting the file size.  Fixed hang of all threads with
     inaccessible NFS server.  Patch by Nir Soffer.

   - bpo-12239(7): Make ‘msilib.SummaryInformation.GetProperty()’ return
     ‘None’ when the value of property is ‘VT_EMPTY’.  Initial patch by
     Mark Mc Mahon.

   - bpo-31325(8): Fix wrong usage of *note collections.namedtuple():
     1ac. in the *note RobotFileParser.parse(): 1a0d. method.  Initial
     patch by Robin Wellner.

   - bpo-12382(9): ‘msilib.OpenDatabase()’ now raises a better exception
     message when it couldn't open or create an MSI file.  Initial patch
     by William Tisäter.

   - bpo-32110(10): ‘codecs.StreamReader.read(n)’ now returns not more
     than 'n' characters/bytes for non-negative 'n'.  This makes it
     compatible with ‘read()’ methods of other file-like objects.

   - bpo-32072(11): Fixed issues with binary plists: Fixed saving
     bytearrays.  Identical objects will be saved only once.  Equal
     references will be load as identical objects.  Added support for
     saving and loading recursive data structures.

   - bpo-32034(12): Make asyncio.IncompleteReadError and
     LimitOverrunError pickleable.

   - bpo-32015(13): Fixed the looping of asyncio in the case of
     reconnection the socket during waiting async read/write from/to the
     socket.

   - bpo-32011(14): Restored support of loading marshal files with the
     TYPE_INT64 code.  These files can be produced in Python 2.7.

   - bpo-31970(15): Reduce performance overhead of asyncio debug mode.

   - bpo-9678(16): Fixed determining the MAC address in the uuid module:
     Using ifconfig on NetBSD and OpenBSD. Using arp on Linux, FreeBSD,
     NetBSD and OpenBSD. Based on patch by Takayuki Shimizukawa.

   - bpo-30057(17): Fix potential missed signal in signal.signal().

   - bpo-31933(18): Fix Blake2 params leaf_size and node_offset on big
     endian platforms.  Patch by Jack O'Connor.

   - bpo-31927(19): Fixed compilation of the socket module on NetBSD 8.
     Fixed assertion failure or reading arbitrary data when parse a
     AF_BLUETOOTH address on NetBSD and DragonFly BSD.

   - bpo-27666(20): Fixed stack corruption in curses.box() and
     curses.ungetmouse() when the size of types chtype or mmask_t is
     less than the size of C long.  curses.box() now accepts characters
     as arguments.  Based on patch by Steve Fink.

   - bpo-31897(21): plistlib now catches more errors when read binary
     plists and raises InvalidFileException instead of unexpected
     exceptions.

   - bpo-25720(22): Fix the method for checking pad state of curses
     WINDOW. Patch by Masayuki Yamamoto.

   - bpo-31893(23): Fixed the layout of the kqueue_event structure on
     OpenBSD and NetBSD. Fixed the comparison of the kqueue_event
     objects.

   - bpo-31891(24): Fixed building the curses module on NetBSD.

   - bpo-28416(25): Instances of pickle.Pickler subclass with the
     persistent_id() method and pickle.Unpickler subclass with the
     persistent_load() method no longer create reference cycles.

   - bpo-28326(26): Fix multiprocessing.Process when stdout and/or
     stderr is closed or None.

   - bpo-31457(27): If nested log adapters are used, the inner
     ‘process()’ methods are no longer omitted.

   - bpo-31457(28): The ‘manager’ property on LoggerAdapter objects is
     now properly settable.

   - bpo-31806(29): Fix timeout rounding in time.sleep(),
     threading.Lock.acquire() and socket.socket.settimeout() to round
     correctly negative timeouts between -1.0 and 0.0.  The functions
     now block waiting for events as expected.  Previously, the call was
     incorrectly non-blocking.  Patch by Pablo Galindo.

   - bpo-28603(30): traceback: Fix a TypeError that occurred during
     printing of exception tracebacks when either the current exception
     or an exception in its context/cause chain is unhashable.  Patch by
     Zane Bitter.

   - bpo-30058(31): Fixed buffer overflow in select.kqueue.control().

   - bpo-31770(32): Prevent a crash when calling the ‘__init__()’ method
     of a ‘sqlite3.Cursor’ object more than once.  Patch by Oren Milman.

   - bpo-31672(33): ‘idpattern’ in ‘string.Template’ matched some
     non-ASCII characters.  Now it uses ‘-i’ regular expression local
     flag to avoid non-ASCII characters.

   - bpo-31764(34): Prevent a crash in ‘sqlite3.Cursor.close()’ in case
     the ‘Cursor’ object is uninitialized.  Patch by Oren Milman.

   - bpo-31752(35): Fix possible crash in timedelta constructor called
     with custom integers.

   - bpo-31701(36): On Windows, faulthandler.enable() now ignores MSC
     and COM exceptions.

   - bpo-31728(37): Prevent crashes in ‘_elementtree’ due to unsafe
     cleanup of ‘Element.text’ and ‘Element.tail’.  Patch by Oren
     Milman.

   - bpo-31620(38): an empty asyncio.Queue now doesn't leak memory when
     queue.get pollers timeout

   - bpo-31632(39): Fix method set_protocol() of class
     _SSLProtocolTransport in asyncio module.  This method was
     previously modifying a wrong reference to the protocol.

   - bpo-31675(40): Fixed memory leaks in Tkinter's methods splitlist()
     and split() when pass a string larger than 2 GiB.

   - bpo-31673(41): Fixed typo in the name of Tkinter's method
     adderrorinfo().

   - bpo-30806(42): Fix the string representation of a netrc object.

   - bpo-15037(43): Added a workaround for getkey() in curses for
     ncurses 5.7 and earlier.

   - bpo-25351(44): Avoid venv activate failures with undefined
     variables

   - bpo-25532(45): inspect.unwrap() will now only try to unwrap an
     object sys.getrecursionlimit() times, to protect against objects
     which create a new object on every attribute access.

   - bpo-30347(46): Stop crashes when concurrently iterate over
     itertools.groupby() iterators.

   - bpo-31516(47): ‘threading.current_thread()’ should not return a
     dummy thread at shutdown.

   - bpo-31351(48): python -m ensurepip now exits with non-zero exit
     code if pip bootstrapping has failed.

   - bpo-31482(49): ‘random.seed()’ now works with bytes in version=1

   - bpo-31334(50): Fix ‘poll.poll([timeout])’ in the ‘select’ module
     for arbitrary negative timeouts on all OSes where it can only be a
     non-negative integer or -1.  Patch by Riccardo Coccioli.

   - bpo-31310(51): multiprocessing's semaphore tracker should be
     launched again if crashed.

   - bpo-31308(52): Make multiprocessing's forkserver process immune to
     Ctrl-C and other user interruptions.  If it crashes, restart it
     when necessary.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27240

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30788

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31831

   (5) https://bugs.python.org/issue?@action=redirect&bpo=32182

   (6) https://bugs.python.org/issue?@action=redirect&bpo=32186

   (7) https://bugs.python.org/issue?@action=redirect&bpo=12239

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31325

   (9) https://bugs.python.org/issue?@action=redirect&bpo=12382

   (10) https://bugs.python.org/issue?@action=redirect&bpo=32110

   (11) https://bugs.python.org/issue?@action=redirect&bpo=32072

   (12) https://bugs.python.org/issue?@action=redirect&bpo=32034

   (13) https://bugs.python.org/issue?@action=redirect&bpo=32015

   (14) https://bugs.python.org/issue?@action=redirect&bpo=32011

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31970

   (16) https://bugs.python.org/issue?@action=redirect&bpo=9678

   (17) https://bugs.python.org/issue?@action=redirect&bpo=30057

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31933

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31927

   (20) https://bugs.python.org/issue?@action=redirect&bpo=27666

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31897

   (22) https://bugs.python.org/issue?@action=redirect&bpo=25720

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31893

   (24) https://bugs.python.org/issue?@action=redirect&bpo=31891

   (25) https://bugs.python.org/issue?@action=redirect&bpo=28416

   (26) https://bugs.python.org/issue?@action=redirect&bpo=28326

   (27) https://bugs.python.org/issue?@action=redirect&bpo=31457

   (28) https://bugs.python.org/issue?@action=redirect&bpo=31457

   (29) https://bugs.python.org/issue?@action=redirect&bpo=31806

   (30) https://bugs.python.org/issue?@action=redirect&bpo=28603

   (31) https://bugs.python.org/issue?@action=redirect&bpo=30058

   (32) https://bugs.python.org/issue?@action=redirect&bpo=31770

   (33) https://bugs.python.org/issue?@action=redirect&bpo=31672

   (34) https://bugs.python.org/issue?@action=redirect&bpo=31764

   (35) https://bugs.python.org/issue?@action=redirect&bpo=31752

   (36) https://bugs.python.org/issue?@action=redirect&bpo=31701

   (37) https://bugs.python.org/issue?@action=redirect&bpo=31728

   (38) https://bugs.python.org/issue?@action=redirect&bpo=31620

   (39) https://bugs.python.org/issue?@action=redirect&bpo=31632

   (40) https://bugs.python.org/issue?@action=redirect&bpo=31675

   (41) https://bugs.python.org/issue?@action=redirect&bpo=31673

   (42) https://bugs.python.org/issue?@action=redirect&bpo=30806

   (43) https://bugs.python.org/issue?@action=redirect&bpo=15037

   (44) https://bugs.python.org/issue?@action=redirect&bpo=25351

   (45) https://bugs.python.org/issue?@action=redirect&bpo=25532

   (46) https://bugs.python.org/issue?@action=redirect&bpo=30347

   (47) https://bugs.python.org/issue?@action=redirect&bpo=31516

   (48) https://bugs.python.org/issue?@action=redirect&bpo=31351

   (49) https://bugs.python.org/issue?@action=redirect&bpo=31482

   (50) https://bugs.python.org/issue?@action=redirect&bpo=31334

   (51) https://bugs.python.org/issue?@action=redirect&bpo=31310

   (52) https://bugs.python.org/issue?@action=redirect&bpo=31308


File: python.info,  Node: Documentation<58>,  Next: Tests<59>,  Prev: Library<64>,  Up: Python 3 6 4 release candidate 1

1.23.68.3 Documentation
.......................

   - bpo-32105(1): Added asyncio.BaseEventLoop.connect_accepted_socket
     versionadded marker.

   - bpo-31537(2): Fix incorrect usage of ‘get_history_length’ in
     readline documentation example code.  Patch by Brad Smith.

   - bpo-30085(3): The operator functions without double underscores are
     preferred for clarity.  The one with underscores are only kept for
     back-compatibility.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32105

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31537

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30085


File: python.info,  Node: Tests<59>,  Next: Build<62>,  Prev: Documentation<58>,  Up: Python 3 6 4 release candidate 1

1.23.68.4 Tests
...............

   - bpo-31380(1): Skip test_httpservers test_undecodable_file on macOS:
     fails on APFS.

   - bpo-31705(2): Skip test_socket.test_sha256() on Linux kernel older
     than 4.5.  The test fails with ENOKEY on kernel 3.10 (on ppc64le).
     A fix was merged into the kernel 4.5.

   - bpo-31174(3): Fix test_tools.test_unparse: DirectoryTestCase now
     stores the names sample to always test the same files.  It prevents
     false alarms when hunting reference leaks.

   - bpo-30695(4): Add the ‘set_nomemory(start, stop)’ and
     ‘remove_mem_hooks()’ functions to the ‘_testcapi’ module.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31380

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31705

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31174

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30695


File: python.info,  Node: Build<62>,  Next: Windows<56>,  Prev: Tests<59>,  Up: Python 3 6 4 release candidate 1

1.23.68.5 Build
...............

   - bpo-32059(1): ‘detect_modules()’ in ‘setup.py’ now also searches
     the sysroot paths when cross-compiling.

   - bpo-31957(2): Fixes Windows SDK version detection when building for
     Windows.

   - bpo-31609(3): Fixes quotes in PCbuild/clean.bat

   - bpo-31934(4): Abort the build when building out of a not clean
     source tree.

   - bpo-31926(5): Fixed Argument Clinic sometimes causing compilation
     errors when there was more than one function and/or method in a .c
     file with the same name.

   - bpo-28791(6): Update Windows builds to use SQLite 3.21.0.

   - bpo-28791(7): Update OS X installer to use SQLite 3.21.0.

   - bpo-22140(8): Prevent double substitution of prefix in
     python-config.sh.

   - bpo-31536(9): Avoid wholesale rebuild after ‘make regen-all’ if
     nothing changed.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32059

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31957

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31609

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31934

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31926

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28791

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28791

   (8) https://bugs.python.org/issue?@action=redirect&bpo=22140

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31536


File: python.info,  Node: Windows<56>,  Next: macOS<46>,  Prev: Build<62>,  Up: Python 3 6 4 release candidate 1

1.23.68.6 Windows
.................

   - bpo-1102(1): Return ‘None’ when ‘View.Fetch()’ returns
     ‘ERROR_NO_MORE_ITEMS’ instead of raising ‘MSIError’.  Initial patch
     by Anthony Tuininga.

   - bpo-31944(2): Fixes Modify button in Apps and Features dialog.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=1102

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31944


File: python.info,  Node: macOS<46>,  Next: IDLE<48>,  Prev: Windows<56>,  Up: Python 3 6 4 release candidate 1

1.23.68.7 macOS
...............

   - bpo-31392(1): Update macOS installer to use OpenSSL 1.0.2m

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31392


File: python.info,  Node: IDLE<48>,  Next: Tools/Demos<33>,  Prev: macOS<46>,  Up: Python 3 6 4 release candidate 1

1.23.68.8 IDLE
..............

   - bpo-32207(1): Improve tk event exception tracebacks in IDLE. When
     tk event handling is driven by IDLE's run loop, a confusing and
     distracting queue.EMPTY traceback context is no longer added to tk
     event exception tracebacks.  The traceback is now the same as when
     event handling is driven by user code.  Patch based on a suggestion
     by Serhiy Storchaka.

   - bpo-32164(2): Delete unused file idlelib/tabbedpages.py.  Use of
     TabbedPageSet in configdialog was replaced by ttk.Notebook.

   - bpo-32100(3): IDLE: Fix old and new bugs in pathbrowser; improve
     tests.  Patch mostly by Cheryl Sabella.

   - bpo-31858(4): IDLE - Restrict shell prompt manipulation to the
     shell.  Editor and output windows only see an empty last prompt
     line.  This simplifies the code and fixes a minor bug when newline
     is inserted.  Sys.ps1, if present, is read on Shell start-up, but
     is not set or changed.

   - bpo-31860(5): The font sample in the IDLE configuration dialog is
     now editable.  Changes persist while IDLE remains open

   - bpo-31836(6): Test_code_module now passes if run after test_idle,
     which sets ps1.  The code module uses sys.ps1 if present or sets it
     to '>>> ' if not.  Test_code_module now properly tests both
     behaviors.  Ditto for ps2.

   - bpo-28603(7): Fix a TypeError that caused a shell restart when
     printing a traceback that includes an exception that is unhashable.
     Patch by Zane Bitter.

   - bpo-13802(8): Use non-Latin characters in the IDLE's Font settings
     sample.  Even if one selects a font that defines a limited subset
     of the unicode Basic Multilingual Plane, tcl/tk will use other
     fonts that define a character.  The expanded example give users of
     non-Latin characters a better idea of what they might see in IDLE's
     shell and editors.  To make room for the expanded sample, frames on
     the Font tab are re-arranged.  The Font/Tabs help explains a bit
     about the additions.

   - bpo-31460(9): Simplify the API of IDLE's Module Browser.  Passing a
     widget instead of an flist with a root widget opens the option of
     creating a browser frame that is only part of a window.  Passing a
     full file name instead of pieces assumed to come from a .py file
     opens the possibility of browsing python files that do not end in
     .py.

   - bpo-31649(10): IDLE - Make _htest, _utest parameters keyword only.

   - bpo-31559(11): Remove test order dependence in
     idle_test.test_browser.

   - bpo-31459(12): Rename IDLE's module browser from Class Browser to
     Module Browser.  The original module-level class and method browser
     became a module browser, with the addition of module-level
     functions, years ago.  Nested classes and functions were added
     yesterday.  For back-compatibility, the virtual event
     <<open-class-browser>>, which appears on the Keys tab of the
     Settings dialog, is not changed.  Patch by Cheryl Sabella.

   - bpo-31500(13): Default fonts now are scaled on HiDPI displays.

   - bpo-1612262(14): IDLE module browser now shows nested classes and
     functions.  Original patches for code and tests by Guilherme Polo
     and Cheryl Sabella, respectively.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32207

   (2) https://bugs.python.org/issue?@action=redirect&bpo=32164

   (3) https://bugs.python.org/issue?@action=redirect&bpo=32100

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31858

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31860

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31836

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28603

   (8) https://bugs.python.org/issue?@action=redirect&bpo=13802

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31460

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31649

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31559

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31459

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31500

   (14) https://bugs.python.org/issue?@action=redirect&bpo=1612262


File: python.info,  Node: Tools/Demos<33>,  Next: C API<58>,  Prev: IDLE<48>,  Up: Python 3 6 4 release candidate 1

1.23.68.9 Tools/Demos
.....................

   - bpo-30722(1): Make redemo work with Python 3.6 and newer versions.
     Also, remove the ‘LOCALE’ option since it doesn't work with string
     patterns in Python 3.  Patch by Christoph Sarnowski.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30722


File: python.info,  Node: C API<58>,  Prev: Tools/Demos<33>,  Up: Python 3 6 4 release candidate 1

1.23.68.10 C API
................

   - bpo-20891(1): Fix PyGILState_Ensure().  When PyGILState_Ensure() is
     called in a non-Python thread before PyEval_InitThreads(), only
     call PyEval_InitThreads() after calling PyThreadState_New() to fix
     a crash.

   - bpo-31532(2): Fix memory corruption due to allocator mix in
     getpath.c between Py_GetPath() and Py_SetPath()

   - bpo-30697(3): The ‘PyExc_RecursionErrorInst’ singleton is removed
     and ‘PyErr_NormalizeException()’ does not use it anymore.  This
     singleton is persistent and its members being never cleared may
     cause a segfault during finalization of the interpreter.  See also
     bpo-22898(4).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20891

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31532

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30697

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22898


File: python.info,  Node: Python 3 6 3 final,  Next: Python 3 6 3 release candidate 1,  Prev: Python 3 6 4 release candidate 1,  Up: 変更履歴

1.23.69 Python 3.6.3 final
--------------------------

'Release date: 2017-10-03'

* Menu:

* Library: Library<65>.
* Build: Build<63>.


File: python.info,  Node: Library<65>,  Next: Build<63>,  Up: Python 3 6 3 final

1.23.69.1 Library
.................

   - bpo-31641(1): Re-allow arbitrary iterables in
     ‘concurrent.futures.as_completed()’.  Fixes regression in 3.6.3rc1.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31641


File: python.info,  Node: Build<63>,  Prev: Library<65>,  Up: Python 3 6 3 final

1.23.69.2 Build
...............

   - bpo-31662(1): Fix typos in Windows ‘uploadrelease.bat’ script.  Fix
     Windows Doc build issues in ‘Doc/make.bat’.

   - bpo-31423(2): Fix building the PDF documentation with newer
     versions of Sphinx.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31662

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31423


File: python.info,  Node: Python 3 6 3 release candidate 1,  Next: Python 3 6 2 final,  Prev: Python 3 6 3 final,  Up: 変更履歴

1.23.70 Python 3.6.3 release candidate 1
----------------------------------------

'Release date: 2017-09-18'

* Menu:

* Security: Security<39>.
* Core and Builtins: Core and Builtins<65>.
* Library: Library<66>.
* Documentation: Documentation<59>.
* Tests: Tests<60>.
* Build: Build<64>.
* Windows: Windows<57>.
* IDLE: IDLE<49>.
* Tools/Demos: Tools/Demos<34>.


File: python.info,  Node: Security<39>,  Next: Core and Builtins<65>,  Up: Python 3 6 3 release candidate 1

1.23.70.1 Security
..................

   - bpo-29781(1): SSLObject.version() now correctly returns None when
     handshake over BIO has not been performed yet.

   - bpo-30947(2): Upgrade libexpat embedded copy from version 2.2.1 to
     2.2.3 to get security fixes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29781

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30947


File: python.info,  Node: Core and Builtins<65>,  Next: Library<66>,  Prev: Security<39>,  Up: Python 3 6 3 release candidate 1

1.23.70.2 Core and Builtins
...........................

   - bpo-31471(1): Fix an assertion failure in ‘subprocess.Popen()’ on
     Windows, in case the env argument has a bad ‘keys()’ method.  Patch
     by Oren Milman.

   - bpo-31418(2): Fix an assertion failure in ‘PyErr_WriteUnraisable()’
     in case of an exception with a bad ‘__module__’ attribute.  Patch
     by Oren Milman.

   - bpo-31416(3): Fix assertion failures in case of a bad
     warnings.filters or warnings.defaultaction.  Patch by Oren Milman.

   - bpo-31411(4): Raise a TypeError instead of SystemError in case
     warnings.onceregistry is not a dictionary.  Patch by Oren Milman.

   - bpo-31373(5): Fix several possible instances of undefined behavior
     due to floating-point demotions.

   - bpo-30465(6): Location information (‘lineno’ and ‘col_offset’) in
     f-strings is now (mostly) correct.  This fixes tools like flake8
     from showing warnings on the wrong line (typically the first line
     of the file).

   - bpo-31343(7): Include sys/sysmacros.h for major(), minor(), and
     makedev().  GNU C libray plans to remove the functions from
     sys/types.h.

   - bpo-31291(8): Fix an assertion failure in
     ‘zipimport.zipimporter.get_data’ on Windows, when the return value
     of ‘pathname.replace('/','\\')’ isn't a string.  Patch by Oren
     Milman.

   - bpo-31271(9): Fix an assertion failure in the ‘write()’ method of
     ‘io.TextIOWrapper’, when the encoder doesn't return a bytes object.
     Patch by Oren Milman.

   - bpo-31243(10): Fix a crash in some methods of ‘io.TextIOWrapper’,
     when the decoder's state is invalid.  Patch by Oren Milman.

   - bpo-30721(11): ‘print’ now shows correct usage hint for using
     Python 2 redirection syntax.  Patch by Sanyam Khurana.

   - bpo-31070(12): Fix a race condition in importlib
     _get_module_lock().

   - bpo-31095(13): Fix potential crash during GC caused by ‘tp_dealloc’
     which doesn't call ‘PyObject_GC_UnTrack()’.

   - bpo-31071(14): Avoid masking original TypeError in call with *
     unpacking when other arguments are passed.

   - bpo-30978(15): str.format_map() now passes key lookup exceptions
     through.  Previously any exception was replaced with a KeyError
     exception.

   - bpo-30808(16): Use _Py_atomic API for concurrency-sensitive signal
     state.

   - bpo-30876(17): Relative import from unloaded package now reimports
     the package instead of failing with SystemError.  Relative import
     from non-package now fails with ImportError rather than
     SystemError.

   - bpo-30703(18): Improve signal delivery.  Avoid using
     Py_AddPendingCall from signal handler, to avoid calling
     signal-unsafe functions.  The tests I'm adding here fail without
     the rest of the patch, on Linux and OS X. This means our signal
     delivery logic had defects (some signals could be lost).

   - bpo-30765(19): Avoid blocking in pthread_mutex_lock() when
     PyThread_acquire_lock() is asked not to block.

   - bpo-31161(20): Make sure the 'Missing parentheses' syntax error
     message is only applied to SyntaxError, not to subclasses.  Patch
     by Martijn Pieters.

   - bpo-30814(21): Fixed a race condition when import a submodule from
     a package.

   - bpo-30597(22): ‘print’ now shows expected input in custom error
     message when used as a Python 2 statement.  Patch by Sanyam
     Khurana.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31471

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31418

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31416

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31411

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31373

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30465

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31343

   (8) https://bugs.python.org/issue?@action=redirect&bpo=31291

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31271

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31243

   (11) https://bugs.python.org/issue?@action=redirect&bpo=30721

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31070

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31095

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31071

   (15) https://bugs.python.org/issue?@action=redirect&bpo=30978

   (16) https://bugs.python.org/issue?@action=redirect&bpo=30808

   (17) https://bugs.python.org/issue?@action=redirect&bpo=30876

   (18) https://bugs.python.org/issue?@action=redirect&bpo=30703

   (19) https://bugs.python.org/issue?@action=redirect&bpo=30765

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31161

   (21) https://bugs.python.org/issue?@action=redirect&bpo=30814

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30597


File: python.info,  Node: Library<66>,  Next: Documentation<59>,  Prev: Core and Builtins<65>,  Up: Python 3 6 3 release candidate 1

1.23.70.3 Library
.................

   - bpo-31499(1): xml.etree: Fix a crash when a parser is part of a
     reference cycle.

   - bpo-28556(2): typing.get_type_hints now finds the right globalns
     for classes and modules by default (when no ‘globalns’ was
     specified by the caller).

   - bpo-28556(3): Speed improvements to the ‘typing’ module.  Original
     PRs by Ivan Levkivskyi and Mitar.

   - bpo-31544(4): The C accelerator module of ElementTree ignored
     exceptions raised when looking up TreeBuilder target methods in
     XMLParser().

   - bpo-31234(5): socket.create_connection() now fixes manually a
     reference cycle: clear the variable storing the last exception on
     success.

   - bpo-31457(6): LoggerAdapter objects can now be nested.

   - bpo-31400(7): Improves SSL error handling to avoid losing error
     numbers.

   - bpo-28958(8): ssl.SSLContext() now uses OpenSSL error information
     when a context cannot be instantiated.

   - bpo-27340(9): SSLSocket.sendall() now uses memoryview to create
     slices of data.  This fixes support for all bytes-like object.  It
     is also more efficient and avoids costly copies.

   - bpo-31178(10): Fix string concatenation bug in rare error path in
     the subprocess module

   - bpo-31350(11): Micro-optimize ‘asyncio._get_running_loop()’ to
     become up to 10% faster.

   - bpo-31170(12): expat: Update libexpat from 2.2.3 to 2.2.4.  Fix
     copying of partial characters for UTF-8 input (libexpat bug 115):
     ‘https://github.com/libexpat/libexpat/issues/115’

   - bpo-29136(13): Add TLS 1.3 cipher suites and OP_NO_TLSv1_3.

   - bpo-29212(14): Fix concurrent.futures.thread.ThreadPoolExecutor
     threads to have a non repr() based thread name by default when no
     thread_name_prefix is supplied.  They will now identify themselves
     as "ThreadPoolExecutor-y_n".

   - bpo-9146(15): Fix a segmentation fault in _hashopenssl when
     standard hash functions such as md5 are not available in the linked
     OpenSSL library.  As in some special FIPS-140 build environments.

   - bpo-27144(16): The ‘map()’ and ‘as_completed()’ iterators in
     ‘concurrent.futures’ now avoid keeping a reference to yielded
     objects.

   - bpo-10746(17): Fix ctypes producing wrong PEP 3118(18) type codes
     for integer types.

   - bpo-22536(19): The subprocess module now sets the filename when
     FileNotFoundError is raised on POSIX systems due to the executable
     or cwd not being found.

   - bpo-31249(20): concurrent.futures: WorkItem.run() used by
     ThreadPoolExecutor now breaks a reference cycle between an
     exception object and the WorkItem object.

   - bpo-31247(21): xmlrpc.server now explicitly breaks reference cycles
     when using sys.exc_info() in code handling exceptions.

   - bpo-30102(22): The ssl and hashlib modules now call
     OPENSSL_add_all_algorithms_noconf() on OpenSSL < 1.1.0.  The
     function detects CPU features and enables optimizations on some CPU
     architectures such as POWER8.  Patch is based on research from
     Gustavo Serra Scalet.

   - bpo-31185(23): Fixed miscellaneous errors in asyncio speedup
     module.

   - bpo-31135(24): ttk: fix the destroy() method of LabeledScale and
     OptionMenu classes.  Call the parent destroy() method even if the
     used attribute doesn't exist.  The LabeledScale.destroy() method
     now also explicitly clears label and scale attributes to help the
     garbage collector to destroy all widgets.

   - bpo-31107(25): Fix ‘copyreg._slotnames()’ mangled attribute
     calculation for classes whose name begins with an underscore.
     Patch by Shane Harvey.

   - bpo-31061(26): Fixed a crash when using asyncio and threads.

   - bpo-30502(27): Fix handling of long oids in ssl.  Based on patch by
     Christian Heimes.

   - bpo-30119(28): ftplib.FTP.putline() now throws ValueError on
     commands that contains CR or LF. Patch by Donghee Na.

   - bpo-30595(29): multiprocessing.Queue.get() with a timeout now polls
     its reader in non-blocking mode if it succeeded to acquire the lock
     but the acquire took longer than the timeout.

   - bpo-29403(30): Fix ‘unittest.mock’'s autospec to not fail on
     method-bound builtin functions.  Patch by Aaron Gallagher.

   - bpo-30961(31): Fix decrementing a borrowed reference in
     tracemalloc.

   - bpo-25684(32): Change ‘ttk.OptionMenu’ radiobuttons to be unique
     across instances of ‘OptionMenu’.

   - bpo-30886(33): Fix multiprocessing.Queue.join_thread(): it now
     waits until the thread completes, even if the thread was started by
     the same process which created the queue.

   - bpo-29854(34): Fix segfault in readline when using readline's
     history-size option.  Patch by Nir Soffer.

   - bpo-30319(35): socket.close() now ignores ECONNRESET error.

   - bpo-30828(36): Fix out of bounds write in
     ‘asyncio.CFuture.remove_done_callback()’.

   - bpo-30807(37): signal.setitimer() may disable the timer when passed
     a tiny value.  Tiny values (such as 1e-6) are valid non-zero values
     for setitimer(), which is specified as taking
     microsecond-resolution intervals.  However, on some platform, our
     conversion routine could convert 1e-6 into a zero interval,
     therefore disabling the timer instead of (re-)scheduling it.

   - bpo-30441(38): Fix bug when modifying os.environ while iterating
     over it

   - bpo-30532(39): Fix email header value parser dropping folding white
     space in certain cases.

   - bpo-30879(40): os.listdir() and os.scandir() now emit bytes names
     when called with bytes-like argument.

   - bpo-30746(41): Prohibited the '=' character in environment variable
     names in ‘os.putenv()’ and ‘os.spawn*()’.

   - bpo-29755(42): Fixed the lgettext() family of functions in the
     gettext module.  They now always return bytes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31499

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31544

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31234

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31457

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31400

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28958

   (9) https://bugs.python.org/issue?@action=redirect&bpo=27340

   (10) https://bugs.python.org/issue?@action=redirect&bpo=31178

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31350

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31170

   (13) https://bugs.python.org/issue?@action=redirect&bpo=29136

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29212

   (15) https://bugs.python.org/issue?@action=redirect&bpo=9146

   (16) https://bugs.python.org/issue?@action=redirect&bpo=27144

   (17) https://bugs.python.org/issue?@action=redirect&bpo=10746

   (18) https://peps.python.org/pep-3118/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=22536

   (20) https://bugs.python.org/issue?@action=redirect&bpo=31249

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31247

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30102

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31185

   (24) https://bugs.python.org/issue?@action=redirect&bpo=31135

   (25) https://bugs.python.org/issue?@action=redirect&bpo=31107

   (26) https://bugs.python.org/issue?@action=redirect&bpo=31061

   (27) https://bugs.python.org/issue?@action=redirect&bpo=30502

   (28) https://bugs.python.org/issue?@action=redirect&bpo=30119

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30595

   (30) https://bugs.python.org/issue?@action=redirect&bpo=29403

   (31) https://bugs.python.org/issue?@action=redirect&bpo=30961

   (32) https://bugs.python.org/issue?@action=redirect&bpo=25684

   (33) https://bugs.python.org/issue?@action=redirect&bpo=30886

   (34) https://bugs.python.org/issue?@action=redirect&bpo=29854

   (35) https://bugs.python.org/issue?@action=redirect&bpo=30319

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30828

   (37) https://bugs.python.org/issue?@action=redirect&bpo=30807

   (38) https://bugs.python.org/issue?@action=redirect&bpo=30441

   (39) https://bugs.python.org/issue?@action=redirect&bpo=30532

   (40) https://bugs.python.org/issue?@action=redirect&bpo=30879

   (41) https://bugs.python.org/issue?@action=redirect&bpo=30746

   (42) https://bugs.python.org/issue?@action=redirect&bpo=29755


File: python.info,  Node: Documentation<59>,  Next: Tests<60>,  Prev: Library<66>,  Up: Python 3 6 3 release candidate 1

1.23.70.4 Documentation
.......................

   - bpo-31294(1): Fix incomplete code snippet in the
     ZeroMQSocketListener and ZeroMQSocketHandler examples and adapt
     them to Python 3.

   - bpo-21649(2): Add RFC 7525 and Mozilla server side TLS links to SSL
     documentation.

   - bpo-30803(3): Clarify doc on truth value testing.  Original patch
     by Peter Thomassen.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31294

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21649

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30803


File: python.info,  Node: Tests<60>,  Next: Build<64>,  Prev: Documentation<59>,  Up: Python 3 6 3 release candidate 1

1.23.70.5 Tests
...............

   - bpo-31320(1): Silence traceback in test_ssl

   - bpo-25674(2): Remove sha256.tbs-internet.com ssl test

   - bpo-30715(3): Address ALPN callback changes for OpenSSL 1.1.0f.
     The latest version behaves like OpenSSL 1.0.2 and no longer aborts
     handshake.

   - bpo-30822(4): regrtest: Exclude tzdata from regrtest -all.  When
     running the test suite using -use=all / -u all, exclude tzdata
     since it makes test_datetime too slow (15-20 min on some buildbots)
     which then times out on some buildbots.  Fix also regrtest command
     line parser to allow passing -u extralargefile to run
     test_zipfile64.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31320

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25674

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30715

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30822


File: python.info,  Node: Build<64>,  Next: Windows<57>,  Prev: Tests<60>,  Up: Python 3 6 3 release candidate 1

1.23.70.6 Build
...............

   - bpo-30854(1): Fix compile error when compiling -without-threads.
     Patch by Masayuki Yamamoto.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30854


File: python.info,  Node: Windows<57>,  Next: IDLE<49>,  Prev: Build<64>,  Up: Python 3 6 3 release candidate 1

1.23.70.7 Windows
.................

   - bpo-30389(1): Adds detection of Visual Studio 2017 to distutils on
     Windows.

   - bpo-31340(2): Change to building with MSVC v141 (included with
     Visual Studio 2017)

   - bpo-30581(3): os.cpu_count() now returns the correct number of
     processors on Windows when the number of logical processors is
     greater than 64.

   - bpo-30731(4): Add a missing xmlns to python.manifest so that it
     matches the schema.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30389

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31340

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30581

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30731


File: python.info,  Node: IDLE<49>,  Next: Tools/Demos<34>,  Prev: Windows<57>,  Up: Python 3 6 3 release candidate 1

1.23.70.8 IDLE
..............

   - bpo-31493(1): IDLE code context - fix code update and font update
     timers.  Canceling timers prevents a warning message when test_idle
     completes.

   - bpo-31488(2): IDLE - Update non-key options in former extension
     classes.  When applying configdialog changes, call .reload for each
     feature class.  Change ParenMatch so updated options affect
     existing instances attached to existing editor windows.

   - bpo-31477(3): IDLE - Improve rstrip entry in doc.  Strip trailing
     whitespace strips more than blank spaces.  Multiline string
     literals are not skipped.

   - bpo-31480(4): IDLE - make tests pass with zzdummy extension
     disabled by default.

   - bpo-31421(5): Document how IDLE runs tkinter programs.  IDLE calls
     tcl/tk update in the background in order to make live interaction
     and experimentation with tkinter applications much easier.

   - bpo-31414(6): IDLE - fix tk entry box tests by deleting first.
     Adding to an int entry is not the same as deleting and inserting
     because int('') will fail.

   - bpo-31051(7): Rearrange IDLE configdialog GenPage into Window,
     Editor, and Help sections.

   - bpo-30617(8): IDLE - Add docstrings and tests for outwin subclass
     of editor.  Move some data and functions from the class to module
     level.  Patch by Cheryl Sabella.

   - bpo-31287(9): IDLE - Do not modify tkinter.message in
     test_configdialog.

   - bpo-27099(10): Convert IDLE's built-in 'extensions' to regular
     features.  About 10 IDLE features were implemented as supposedly
     optional extensions.  Their different behavior could be confusing
     or worse for users and not good for maintenance.  Hence the
     conversion.  The main difference for users is that user
     configurable key bindings for builtin features are now handled
     uniformly.  Now, editing a binding in a keyset only affects its
     value in the keyset.  All bindings are defined together in the
     system-specific default keysets in config-extensions.def.  All
     custom keysets are saved as a whole in config-extension.cfg.  All
     take effect as soon as one clicks Apply or Ok.  The affected events
     are '<<force-open-completions>>', '<<expand-word>>',
     '<<force-open-calltip>>', '<<flash-paren>>',
     '<<format-paragraph>>', '<<run-module>>', '<<check-module>>', and
     '<<zoom-height>>'.  Any (global) customizations made before 3.6.3
     will not affect their keyset-specific customization after 3.6.3.
     and vice versa.  Initial patch by Charles Wohlganger.

   - bpo-31206(11): IDLE: Factor HighPage(Frame) class from
     ConfigDialog.  Patch by Cheryl Sabella.

   - bpo-31001(12): Add tests for configdialog highlight tab.  Patch by
     Cheryl Sabella.

   - bpo-31205(13): IDLE: Factor KeysPage(Frame) class from
     ConfigDialog.  The slightly modified tests continue to pass.  Patch
     by Cheryl Sabella.

   - bpo-31130(14): IDLE - stop leaks in test_configdialog.  Initial
     patch by Victor Stinner.

   - bpo-31002(15): Add tests for configdialog keys tab.  Patch by
     Cheryl Sabella.

   - bpo-19903(16): IDLE: Calltips use ‘inspect.signature’ instead of
     ‘inspect.getfullargspec’.  This improves calltips for builtins
     converted to use Argument Clinic.  Patch by Louie Lu.

   - bpo-31083(17): IDLE - Add an outline of a TabPage class in
     configdialog.  Update existing classes to match outline.  Initial
     patch by Cheryl Sabella.

   - bpo-31050(18): Factor GenPage(Frame) class from ConfigDialog.  The
     slightly modified tests continue to pass.  Patch by Cheryl Sabella.

   - bpo-31004(19): IDLE - Factor FontPage(Frame) class from
     ConfigDialog.  Slightly modified tests continue to pass.  Fix
     General tests.  Patch mostly by Cheryl Sabella.

   - bpo-30781(20): IDLE - Use ttk widgets in ConfigDialog.  Patches by
     Terry Jan Reedy and Cheryl Sabella.

   - bpo-31060(21): IDLE - Finish rearranging methods of ConfigDialog
     Grouping methods pertaining to each tab and the buttons will aid
     writing tests and improving the tabs and will enable splitting the
     groups into classes.

   - bpo-30853(22): IDLE - Factor a VarTrace class out of ConfigDialog.
     Instance tracers manages pairs consisting of a tk variable and a
     callback function.  When tracing is turned on, setting the variable
     calls the function.  Test coverage for the new class is 100%.

   - bpo-31003(23): IDLE: Add more tests for General tab.

   - bpo-30993(24): IDLE - Improve configdialog font page and tests.  In
     configdialog: Document causal pathways in create_font_tab
     docstring.  Simplify some attribute names.  Move set_samples calls
     to var_changed_font (idea from Cheryl Sabella).  Move related
     functions to positions after the create widgets function.  In
     test_configdialog: Fix test_font_set so not order dependent.  Fix
     renamed test_indent_scale so it tests the widget.  Adjust tests for
     movement of set_samples call.  Add tests for load functions.  Put
     all font tests in one class and tab indent tests in another.
     Except for two lines, these tests completely cover the related
     functions.

   - bpo-30981(25): IDLE - Add more configdialog font page tests.

   - bpo-28523(26): IDLE: replace 'colour' with 'color' in configdialog.

   - bpo-30917(27): Add tests for idlelib.config.IdleConf.  Increase
     coverage from 46% to 96%.  Patch by Louie Lu.

   - bpo-30934(28): Document coverage details for idlelib tests.  Add
     section to idlelib/idle-test/README.txt.  Include check that
     branches are taken both ways.  Exclude IDLE-specific code that does
     not run during unit tests.

   - bpo-30913(29): IDLE: Document ConfigDialog tk Vars, methods, and
     widgets in docstrings This will facilitate improving the dialog and
     splitting up the class.  Original patch by Cheryl Sabella.

   - bpo-30899(30): IDLE: Add tests for ConfigParser subclasses in
     config.  Patch by Louie Lu.

   - bpo-30881(31): IDLE: Add docstrings to browser.py.  Patch by Cheryl
     Sabella.

   - bpo-30851(32): IDLE: Remove unused variables in configdialog.  One
     is a duplicate, one is set but cannot be altered by users.  Patch
     by Cheryl Sabella.

   - bpo-30870(33): IDLE: In Settings dialog, select font with Up, Down
     keys as well as mouse.  Initial patch by Louie Lu.

   - bpo-8231(34): IDLE: call config.IdleConf.GetUserCfgDir only once.

   - bpo-30779(35): IDLE: Factor ConfigChanges class from configdialog,
     put in config; test.  * In config, put dump test code in a
     function; run it and unittest in 'if __name__ == '__main__'.  * Add
     class config.ConfigChanges based on changes_class_v4.py on bpo
     issue.  * Add class test_config.ChangesTest, partly using
     configdialog_tests_v1.py.  * Revise configdialog to use
     ConfigChanges; see tracker msg297804.  * Revise test_configdialog
     to match configdialog changes.  * Remove configdialog functions
     unused or moved to ConfigChanges.  Cheryl Sabella contributed parts
     of the patch.

   - bpo-30777(36): IDLE: configdialog - Add docstrings and fix
     comments.  Patch by Cheryl Sabella.

   - bpo-30495(37): IDLE: Improve textview with docstrings, PEP8 names,
     and more tests.  Patch by Cheryl Sabella.

   - bpo-30723(38): IDLE: Make several improvements to parenmatch.  Add
     'parens' style to highlight both opener and closer.  Make 'default'
     style, which is not default, a synonym for 'opener'.  Make
     time-delay work the same with all styles.  Add help for config
     dialog extensions tab, including help for parenmatch.  Add new
     tests.  Original patch by Charles Wohlganger.

   - bpo-30674(39): IDLE: add docstrings to grep module.  Patch by
     Cheryl Sabella

   - bpo-21519(40): IDLE's basic custom key entry dialog now detects
     duplicates properly.  Original patch by Saimadhav Heblikar.

   - bpo-29910(41): IDLE no longer deletes a character after commenting
     out a region by a key shortcut.  Add ‘return 'break'’ for this and
     other potential conflicts between IDLE and default key bindings.

   - bpo-30728(42): Review and change idlelib.configdialog names.
     Lowercase method and attribute names.  Replace 'colour' with
     'color', expand overly cryptic names, delete unneeded underscores.
     Replace ‘import *’ with specific imports.  Patches by Cheryl
     Sabella.

   - bpo-6739(43): IDLE: Verify user-entered key sequences by trying to
     bind them with tk.  Add tests for all 3 validation functions.
     Original patch by G Polo.  Tests added by Cheryl Sabella.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31493

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31488

   (3) https://bugs.python.org/issue?@action=redirect&bpo=31477

   (4) https://bugs.python.org/issue?@action=redirect&bpo=31480

   (5) https://bugs.python.org/issue?@action=redirect&bpo=31421

   (6) https://bugs.python.org/issue?@action=redirect&bpo=31414

   (7) https://bugs.python.org/issue?@action=redirect&bpo=31051

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30617

   (9) https://bugs.python.org/issue?@action=redirect&bpo=31287

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27099

   (11) https://bugs.python.org/issue?@action=redirect&bpo=31206

   (12) https://bugs.python.org/issue?@action=redirect&bpo=31001

   (13) https://bugs.python.org/issue?@action=redirect&bpo=31205

   (14) https://bugs.python.org/issue?@action=redirect&bpo=31130

   (15) https://bugs.python.org/issue?@action=redirect&bpo=31002

   (16) https://bugs.python.org/issue?@action=redirect&bpo=19903

   (17) https://bugs.python.org/issue?@action=redirect&bpo=31083

   (18) https://bugs.python.org/issue?@action=redirect&bpo=31050

   (19) https://bugs.python.org/issue?@action=redirect&bpo=31004

   (20) https://bugs.python.org/issue?@action=redirect&bpo=30781

   (21) https://bugs.python.org/issue?@action=redirect&bpo=31060

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30853

   (23) https://bugs.python.org/issue?@action=redirect&bpo=31003

   (24) https://bugs.python.org/issue?@action=redirect&bpo=30993

   (25) https://bugs.python.org/issue?@action=redirect&bpo=30981

   (26) https://bugs.python.org/issue?@action=redirect&bpo=28523

   (27) https://bugs.python.org/issue?@action=redirect&bpo=30917

   (28) https://bugs.python.org/issue?@action=redirect&bpo=30934

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30913

   (30) https://bugs.python.org/issue?@action=redirect&bpo=30899

   (31) https://bugs.python.org/issue?@action=redirect&bpo=30881

   (32) https://bugs.python.org/issue?@action=redirect&bpo=30851

   (33) https://bugs.python.org/issue?@action=redirect&bpo=30870

   (34) https://bugs.python.org/issue?@action=redirect&bpo=8231

   (35) https://bugs.python.org/issue?@action=redirect&bpo=30779

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30777

   (37) https://bugs.python.org/issue?@action=redirect&bpo=30495

   (38) https://bugs.python.org/issue?@action=redirect&bpo=30723

   (39) https://bugs.python.org/issue?@action=redirect&bpo=30674

   (40) https://bugs.python.org/issue?@action=redirect&bpo=21519

   (41) https://bugs.python.org/issue?@action=redirect&bpo=29910

   (42) https://bugs.python.org/issue?@action=redirect&bpo=30728

   (43) https://bugs.python.org/issue?@action=redirect&bpo=6739


File: python.info,  Node: Tools/Demos<34>,  Prev: IDLE<49>,  Up: Python 3 6 3 release candidate 1

1.23.70.9 Tools/Demos
.....................

   - bpo-30983(1): gdb integration commands (py-bt, etc.)  work on
     optimized shared builds now, too.  PEP 523(2) introduced
     _PyEval_EvalFrameDefault which inlines PyEval_EvalFrameEx on
     non-debug shared builds.  This broke the ability to use py-bt,
     py-up, and a few other Python-specific gdb integrations.  The
     problem is fixed by only looking for _PyEval_EvalFrameDefault
     frames in python-gdb.py.  Original patch by Bruno "Polaco"
     Penteado.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30983

   (2) https://peps.python.org/pep-0523/


File: python.info,  Node: Python 3 6 2 final,  Next: Python 3 6 2 release candidate 2,  Prev: Python 3 6 3 release candidate 1,  Up: 変更履歴

1.23.71 Python 3.6.2 final
--------------------------

'Release date: 2017-07-17'

No changes since release candidate 2


File: python.info,  Node: Python 3 6 2 release candidate 2,  Next: Python 3 6 2 release candidate 1,  Prev: Python 3 6 2 final,  Up: 変更履歴

1.23.72 Python 3.6.2 release candidate 2
----------------------------------------

'Release date: 2017-07-07'

* Menu:

* Security: Security<40>.


File: python.info,  Node: Security<40>,  Up: Python 3 6 2 release candidate 2

1.23.72.1 Security
..................

   - bpo-30730(1): Prevent environment variables injection in subprocess
     on Windows.  Prevent passing other environment variables and
     command arguments.

   - bpo-30694(2): Upgrade expat copy from 2.2.0 to 2.2.1 to get fixes
     of multiple security vulnerabilities including: CVE 2017-9233(3)
     (External entity infinite loop DoS), CVE 2016-9063(4) (Integer
     overflow, re-fix), CVE 2016-0718(5) (Fix regression bugs from
     2.2.0's fix to CVE 2016-0718(6)) and CVE 2012-0876(7) (Counter hash
     flooding with SipHash).  Note: the CVE 2016-5300(8) (Use
     os-specific entropy sources like getrandom) doesn't impact Python,
     since Python already gets entropy from the OS to set the expat
     secret using ‘XML_SetHashSalt()’.

   - bpo-30500(9): Fix urllib.parse.splithost() to correctly parse
     fragments.  For example, ‘splithost('//127.0.0.1#@evil.com/')’ now
     correctly returns the ‘127.0.0.1’ host, instead of treating
     ‘@evil.com’ as the host in an authentication (‘login@host’).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30730

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30694

   (3) https://www.cve.org/CVERecord?id=CVE-2017-9233

   (4) https://www.cve.org/CVERecord?id=CVE-2016-9063

   (5) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (6) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (7) https://www.cve.org/CVERecord?id=CVE-2012-0876

   (8) https://www.cve.org/CVERecord?id=CVE-2016-5300

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30500


File: python.info,  Node: Python 3 6 2 release candidate 1,  Next: Python 3 6 1 final,  Prev: Python 3 6 2 release candidate 2,  Up: 変更履歴

1.23.73 Python 3.6.2 release candidate 1
----------------------------------------

'Release date: 2017-06-17'

* Menu:

* Security: Security<41>.
* Core and Builtins: Core and Builtins<66>.
* Library: Library<67>.
* IDLE: IDLE<50>.
* C API: C API<59>.
* Build: Build<65>.
* Documentation: Documentation<60>.
* Tools/Demos: Tools/Demos<35>.
* Tests: Tests<61>.
* Windows: Windows<58>.


File: python.info,  Node: Security<41>,  Next: Core and Builtins<66>,  Up: Python 3 6 2 release candidate 1

1.23.73.1 Security
..................

   - bpo-29591(1): Update expat copy from 2.1.1 to 2.2.0 to get fixes of
     CVE 2016-0718(2) and CVE 2016-4472(3).  See
     ‘https://sourceforge.net/p/expat/bugs/537/’ for more information.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29591

   (2) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (3) https://www.cve.org/CVERecord?id=CVE-2016-4472


File: python.info,  Node: Core and Builtins<66>,  Next: Library<67>,  Prev: Security<41>,  Up: Python 3 6 2 release candidate 1

1.23.73.2 Core and Builtins
...........................

   - bpo-30682(1): Removed a too-strict assertion that failed for
     certain f-strings, such as eval("f'\n'") and eval("f'\r'").

   - bpo-30604(2): Move co_extra_freefuncs to not be per-thread to avoid
     crashes

   - bpo-29104(3): Fixed parsing backslashes in f-strings.

   - bpo-27945(4): Fixed various segfaults with dict when input
     collections are mutated during searching, inserting or comparing.
     Based on patches by Duane Griffin and Tim Mitchell.

   - bpo-25794(5): Fixed type.__setattr__() and type.__delattr__() for
     non-interned attribute names.  Based on patch by Eryk Sun.

   - bpo-30039(6): If a KeyboardInterrupt happens when the interpreter
     is in the middle of resuming a chain of nested 'yield from' or
     'await' calls, it's now correctly delivered to the innermost frame.

   - bpo-12414(7): sys.getsizeof() on a code object now returns the
     sizes which includes the code struct and sizes of objects which it
     references.  Patch by Donghee Na.

   - bpo-29949(8): Fix memory usage regression of set and frozenset
     object.

   - bpo-29935(9): Fixed error messages in the index() method of tuple,
     list and deque when pass indices of wrong type.

   - bpo-29859(10): Show correct error messages when any of the
     pthread_* calls in thread_pthread.h fails.

   - bpo-28876(11): ‘bool(range)’ works even if ‘len(range)’ raises
     *note OverflowError: 84e.

   - bpo-29600(12): Fix wrapping coroutine return values in
     StopIteration.

   - bpo-28856(13): Fix an oversight that %b format for bytes should
     support objects follow the buffer protocol.

   - bpo-29714(14): Fix a regression that bytes format may fail when
     containing zero bytes inside.

   - bpo-29478(15): If max_line_length=None is specified while using the
     Compat32 policy, it is no longer ignored.  Patch by Mircea Cosbuc.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30682

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30604

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29104

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27945

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25794

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30039

   (7) https://bugs.python.org/issue?@action=redirect&bpo=12414

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29949

   (9) https://bugs.python.org/issue?@action=redirect&bpo=29935

   (10) https://bugs.python.org/issue?@action=redirect&bpo=29859

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28876

   (12) https://bugs.python.org/issue?@action=redirect&bpo=29600

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28856

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29714

   (15) https://bugs.python.org/issue?@action=redirect&bpo=29478


File: python.info,  Node: Library<67>,  Next: IDLE<50>,  Prev: Core and Builtins<66>,  Up: Python 3 6 2 release candidate 1

1.23.73.3 Library
.................

   - bpo-30616(1): Functional API of enum allows to create empty enums.
     Patched by Donghee Na

   - bpo-30038(2): Fix race condition between signal delivery and wakeup
     file descriptor.  Patch by Nathaniel Smith.

   - bpo-23894(3): lib2to3 now recognizes ‘rb'...'’ and ‘f'...'’
     strings.

   - bpo-23890(4): unittest.TestCase.assertRaises() now manually breaks
     a reference cycle to not keep objects alive longer than expected.

   - bpo-30149(5): inspect.signature() now supports callables with
     variable-argument parameters wrapped with partialmethod.  Patch by
     Donghee Na.

   - bpo-30645(6): Fix path calculation in imp.load_package(), fixing it
     for cases when a package is only shipped with bytecodes.  Patch by
     Alexandru Ardelean.

   - bpo-29931(7): Fixed comparison check for ipaddress.ip_interface
     objects.  Patch by Sanjay Sundaresan.

   - bpo-30605(8): re.compile() no longer raises a BytesWarning when
     compiling a bytes instance with misplaced inline modifier.  Patch
     by Roy Williams.

   - bpo-24484(9): Avoid race condition in multiprocessing cleanup
     (#2159)

   - bpo-28994(10): The traceback no longer displayed for SystemExit
     raised in a callback registered by atexit.

   - bpo-30508(11): Don't log exceptions if Task/Future "cancel()"
     method was called.

   - bpo-28556(12): Updates to typing module: Add generic
     AsyncContextManager, add support for ContextManager on all
     versions.  Original PRs by Jelle Zijlstra and Ivan Levkivskyi

   - bpo-29870(13): Fix ssl sockets leaks when connection is aborted in
     asyncio/ssl implementation.  Patch by Michaël Sghaïer.

   - bpo-29743(14): Closing transport during handshake process leaks
     open socket.  Patch by Nikolay Kim

   - bpo-27585(15): Fix waiter cancellation in asyncio.Lock.  Patch by
     Mathieu Sornay.

   - bpo-30418(16): On Windows, subprocess.Popen.communicate() now also
     ignore EINVAL on stdin.write() if the child process is still
     running but closed the pipe.

   - bpo-29822(17): inspect.isabstract() now works during
     __init_subclass__.  Patch by Nate Soares.

   - bpo-29581(18): ABCMeta.__new__ now accepts ‘**kwargs’, allowing
     abstract base classes to use keyword parameters in
     __init_subclass__.  Patch by Nate Soares.

   - bpo-30557(19): faulthandler now correctly filters and displays
     exception codes on Windows

   - bpo-30378(20): Fix the problem that logging.handlers.SysLogHandler
     cannot handle IPv6 addresses.

   - bpo-29960(21): Preserve generator state when
     _random.Random.setstate() raises an exception.  Patch by Bryan
     Olson.

   - bpo-30414(22): multiprocessing.Queue._feed background running
     thread do not break from main loop on exception.

   - bpo-30003(23): Fix handling escape characters in HZ codec.  Based
     on patch by Ma Lin.

   - bpo-30301(24): Fix AttributeError when using SimpleQueue.empty()
     under 'spawn' and 'forkserver' start methods.

   - bpo-30329(25): imaplib and poplib now catch the Windows socket
     WSAEINVAL error (code 10022) on shutdown(SHUT_RDWR): An invalid
     operation was attempted.  This error occurs sometimes on SSL
     connections.

   - bpo-30375(26): Warnings emitted when compile a regular expression
     now always point to the line in the user code.  Previously they
     could point into inners of the re module if emitted from inside of
     groups or conditionals.

   - bpo-30048(27): Fixed ‘Task.cancel()’ can be ignored when the task
     is running coroutine and the coroutine returned without any more
     ‘await’.

   - bpo-30266(28): contextlib.AbstractContextManager now supports
     anti-registration by setting __enter__ = None or __exit__ = None,
     following the pattern introduced in bpo-25958(29).  Patch by Jelle
     Zijlstra.

   - bpo-30298(30): Weaken the condition of deprecation warnings for
     inline modifiers.  Now allowed several subsequential inline
     modifiers at the start of the pattern (e.g.  ‘'(?i)(?s)...'’).  In
     verbose mode whitespaces and comments now are allowed before and
     between inline modifiers (e.g.  ‘'(?x) (?i) (?s)...'’).

   - bpo-29990(31): Fix range checking in GB18030 decoder.  Original
     patch by Ma Lin.

   - bpo-26293(32): Change resulted because of zipfile breakage.  (See
     also: bpo-29094(33))

   - bpo-30243(34): Removed the __init__ methods of _json's scanner and
     encoder.  Misusing them could cause memory leaks or crashes.  Now
     scanner and encoder objects are completely initialized in the
     __new__ methods.

   - bpo-30185(35): Avoid KeyboardInterrupt tracebacks in forkserver
     helper process when Ctrl-C is received.

   - bpo-28556(36): Various updates to typing module: add
     typing.NoReturn type, use WrapperDescriptorType, minor bug-fixes.
     Original PRs by Jim Fasarakis-Hilliard and Ivan Levkivskyi.

   - bpo-30205(37): Fix getsockname() for unbound AF_UNIX sockets on
     Linux.

   - bpo-30070(38): Fixed leaks and crashes in errors handling in the
     parser module.

   - bpo-30061(39): Fixed crashes in IOBase methods __next__() and
     readlines() when readline() or __next__() respectively return
     non-sizeable object.  Fixed possible other errors caused by not
     checking results of PyObject_Size(), PySequence_Size(), or
     PyMapping_Size().

   - bpo-30017(40): Allowed calling the close() method of the zip entry
     writer object multiple times.  Writing to a closed writer now
     always produces a ValueError.

   - bpo-30068(41): _io._IOBase.readlines will check if it's closed
     first when hint is present.

   - bpo-29694(42): Fixed race condition in pathlib mkdir with flags
     parents=True.  Patch by Armin Rigo.

   - bpo-29692(43): Fixed arbitrary unchaining of RuntimeError
     exceptions in contextlib.contextmanager.  Patch by Siddharth
     Velankar.

   - bpo-29998(44): Pickling and copying ImportError now preserves name
     and path attributes.

   - bpo-29953(45): Fixed memory leaks in the replace() method of
     datetime and time objects when pass out of bound fold argument.

   - bpo-29942(46): Fix a crash in itertools.chain.from_iterable when
     encountering long runs of empty iterables.

   - bpo-27863(47): Fixed multiple crashes in ElementTree caused by race
     conditions and wrong types.

   - bpo-28699(48): Fixed a bug in pools in multiprocessing.pool that
     raising an exception at the very first of an iterable may swallow
     the exception or make the program hang.  Patch by Davin Potts and
     Xiang Zhang.

   - bpo-25803(49): Avoid incorrect errors raised by
     Path.mkdir(exist_ok=True) when the OS gives priority to errors such
     as EACCES over EEXIST.

   - bpo-29861(50): Release references to tasks, their arguments and
     their results as soon as they are finished in multiprocessing.Pool.

   - bpo-29884(51): faulthandler: Restore the old sigaltstack during
     teardown.  Patch by Christophe Zeitouny.

   - bpo-25455(52): Fixed crashes in repr of recursive buffered
     file-like objects.

   - bpo-29800(53): Fix crashes in partial.__repr__ if the keys of
     partial.keywords are not strings.  Patch by Michael Seifert.

   - bpo-29742(54): get_extra_info() raises exception if get called on
     closed ssl transport.  Patch by Nikolay Kim.

   - bpo-8256(55): Fixed possible failing or crashing input() if
     attributes "encoding" or "errors" of sys.stdin or sys.stdout are
     not set or are not strings.

   - bpo-28298(56): Fix a bug that prevented array 'Q', 'L' and 'I' from
     accepting big intables (objects that have __int__) as elements.
     Patch by Oren Milman.

   - bpo-28231(57): The zipfile module now accepts path-like objects for
     external paths.

   - bpo-26915(58): index() and count() methods of
     collections.abc.Sequence now check identity before checking
     equality when do comparisons.

   - bpo-29615(59): SimpleXMLRPCDispatcher no longer chains KeyError (or
     any other exception) to exception(s) raised in the dispatched
     methods.  Patch by Petr Motejlek.

   - bpo-30177(60): path.resolve(strict=False) no longer cuts the path
     after the first element not present in the filesystem.  Patch by
     Antoine Pietri.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30616

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30038

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23894

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23890

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30149

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30645

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29931

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30605

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24484

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28994

   (11) https://bugs.python.org/issue?@action=redirect&bpo=30508

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (13) https://bugs.python.org/issue?@action=redirect&bpo=29870

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29743

   (15) https://bugs.python.org/issue?@action=redirect&bpo=27585

   (16) https://bugs.python.org/issue?@action=redirect&bpo=30418

   (17) https://bugs.python.org/issue?@action=redirect&bpo=29822

   (18) https://bugs.python.org/issue?@action=redirect&bpo=29581

   (19) https://bugs.python.org/issue?@action=redirect&bpo=30557

   (20) https://bugs.python.org/issue?@action=redirect&bpo=30378

   (21) https://bugs.python.org/issue?@action=redirect&bpo=29960

   (22) https://bugs.python.org/issue?@action=redirect&bpo=30414

   (23) https://bugs.python.org/issue?@action=redirect&bpo=30003

   (24) https://bugs.python.org/issue?@action=redirect&bpo=30301

   (25) https://bugs.python.org/issue?@action=redirect&bpo=30329

   (26) https://bugs.python.org/issue?@action=redirect&bpo=30375

   (27) https://bugs.python.org/issue?@action=redirect&bpo=30048

   (28) https://bugs.python.org/issue?@action=redirect&bpo=30266

   (29) https://bugs.python.org/issue?@action=redirect&bpo=25958

   (30) https://bugs.python.org/issue?@action=redirect&bpo=30298

   (31) https://bugs.python.org/issue?@action=redirect&bpo=29990

   (32) https://bugs.python.org/issue?@action=redirect&bpo=26293

   (33) https://bugs.python.org/issue?@action=redirect&bpo=29094

   (34) https://bugs.python.org/issue?@action=redirect&bpo=30243

   (35) https://bugs.python.org/issue?@action=redirect&bpo=30185

   (36) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (37) https://bugs.python.org/issue?@action=redirect&bpo=30205

   (38) https://bugs.python.org/issue?@action=redirect&bpo=30070

   (39) https://bugs.python.org/issue?@action=redirect&bpo=30061

   (40) https://bugs.python.org/issue?@action=redirect&bpo=30017

   (41) https://bugs.python.org/issue?@action=redirect&bpo=30068

   (42) https://bugs.python.org/issue?@action=redirect&bpo=29694

   (43) https://bugs.python.org/issue?@action=redirect&bpo=29692

   (44) https://bugs.python.org/issue?@action=redirect&bpo=29998

   (45) https://bugs.python.org/issue?@action=redirect&bpo=29953

   (46) https://bugs.python.org/issue?@action=redirect&bpo=29942

   (47) https://bugs.python.org/issue?@action=redirect&bpo=27863

   (48) https://bugs.python.org/issue?@action=redirect&bpo=28699

   (49) https://bugs.python.org/issue?@action=redirect&bpo=25803

   (50) https://bugs.python.org/issue?@action=redirect&bpo=29861

   (51) https://bugs.python.org/issue?@action=redirect&bpo=29884

   (52) https://bugs.python.org/issue?@action=redirect&bpo=25455

   (53) https://bugs.python.org/issue?@action=redirect&bpo=29800

   (54) https://bugs.python.org/issue?@action=redirect&bpo=29742

   (55) https://bugs.python.org/issue?@action=redirect&bpo=8256

   (56) https://bugs.python.org/issue?@action=redirect&bpo=28298

   (57) https://bugs.python.org/issue?@action=redirect&bpo=28231

   (58) https://bugs.python.org/issue?@action=redirect&bpo=26915

   (59) https://bugs.python.org/issue?@action=redirect&bpo=29615

   (60) https://bugs.python.org/issue?@action=redirect&bpo=30177


File: python.info,  Node: IDLE<50>,  Next: C API<59>,  Prev: Library<67>,  Up: Python 3 6 2 release candidate 1

1.23.73.4 IDLE
..............

   - bpo-15786(1): Fix several problems with IDLE's autocompletion box.
     The following should now work: clicking on selection box items;
     using the scrollbar; selecting an item by hitting Return.  Hangs on
     MacOSX should no longer happen.  Patch by Louie Lu.

   - bpo-25514(2): Add doc subsubsection about IDLE failure to start.
     Popup no-connection message directs users to this section.

   - bpo-30642(3): Fix reference leaks in IDLE tests.  Patches by Louie
     Lu and Terry Jan Reedy.

   - bpo-30495(4): Add docstrings for textview.py and use PEP8 names.
     Patches by Cheryl Sabella and Terry Jan Reedy.

   - bpo-30290(5): Help-about: use pep8 names and add tests.  Increase
     coverage to 100%.  Patches by Louie Lu, Cheryl Sabella, and Terry
     Jan Reedy.

   - bpo-30303(6): Add _utest option to textview; add new tests.
     Increase coverage to 100%.  Patches by Louie Lu and Terry Jan
     Reedy.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15786

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25514

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30642

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30495

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30290

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30303


File: python.info,  Node: C API<59>,  Next: Build<65>,  Prev: IDLE<50>,  Up: Python 3 6 2 release candidate 1

1.23.73.5 C API
...............

   - bpo-27867(1): Function PySlice_GetIndicesEx() no longer replaced
     with a macro if Py_LIMITED_API is not set.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27867


File: python.info,  Node: Build<65>,  Next: Documentation<60>,  Prev: C API<59>,  Up: Python 3 6 2 release candidate 1

1.23.73.6 Build
...............

   - bpo-29941(1): Add ‘--with-assertions’ configure flag to explicitly
     enable C ‘assert()’ checks.  Defaults to off.  ‘--with-pydebug’
     implies ‘--with-assertions’.

   - bpo-28787(2): Fix out-of-tree builds of Python when configured with
     ‘--with--dtrace’.

   - bpo-29243(3): Prevent unnecessary rebuilding of Python during ‘make
     test’, ‘make install’ and some other make targets when configured
     with ‘--enable-optimizations’.

   - bpo-23404(4): Don't regenerate generated files based on file
     modification time anymore: the action is now explicit.  Replace
     ‘make touch’ with ‘make regen-all’.

   - bpo-29643(5): Fix ‘--enable-optimization’ didn't work.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29941

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28787

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29243

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23404

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29643


File: python.info,  Node: Documentation<60>,  Next: Tools/Demos<35>,  Prev: Build<65>,  Up: Python 3 6 2 release candidate 1

1.23.73.7 Documentation
.......................

   - bpo-30176(1): Add missing attribute related constants in curses
     documentation.

   - bpo-30052(2): the link targets for *note bytes(): 1a4. and *note
     bytearray(): 508. are now their respective type definitions, rather
     than the corresponding builtin function entries.  Use *note bytes:
     1a24. and *note bytearray: 1a25. to reference the latter.  In order
     to ensure this and future cross-reference updates are applied
     automatically, the daily documentation builds now disable the
     default output caching features in Sphinx.

   - bpo-26985(3): Add missing info of code object in inspect
     documentation.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30176

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30052

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26985


File: python.info,  Node: Tools/Demos<35>,  Next: Tests<61>,  Prev: Documentation<60>,  Up: Python 3 6 2 release candidate 1

1.23.73.8 Tools/Demos
.....................

   - bpo-29367(1): python-gdb.py now supports also ‘method-wrapper’
     (‘wrapperobject’) objects.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29367


File: python.info,  Node: Tests<61>,  Next: Windows<58>,  Prev: Tools/Demos<35>,  Up: Python 3 6 2 release candidate 1

1.23.73.9 Tests
...............

   - bpo-30357(1): test_thread: setUp() now uses
     support.threading_setup() and support.threading_cleanup() to wait
     until threads complete to avoid random side effects on following
     tests.  Initial patch written by Grzegorz Grzywacz.

   - bpo-30197(2): Enhanced functions swap_attr() and swap_item() in the
     test.support module.  They now work when delete replaced attribute
     or item inside the with statement.  The old value of the attribute
     or item (or None if it doesn't exist) now will be assigned to the
     target of the "as" clause, if there is one.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30357

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30197


File: python.info,  Node: Windows<58>,  Prev: Tests<61>,  Up: Python 3 6 2 release candidate 1

1.23.73.10 Windows
..................

   - bpo-30687(1): Locate msbuild.exe on Windows when building rather
     than vcvarsall.bat

   - bpo-30450(2): The build process on Windows no longer depends on
     Subversion, instead pulling external code from GitHub via a Python
     script.  If Python 3.6 is not found on the system (via ‘py -3.6’),
     NuGet is used to download a copy of 32-bit Python.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30687

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30450


File: python.info,  Node: Python 3 6 1 final,  Next: Python 3 6 1 release candidate 1,  Prev: Python 3 6 2 release candidate 1,  Up: 変更履歴

1.23.74 Python 3.6.1 final
--------------------------

'Release date: 2017-03-21'

* Menu:

* Core and Builtins: Core and Builtins<67>.
* Build: Build<66>.


File: python.info,  Node: Core and Builtins<67>,  Next: Build<66>,  Up: Python 3 6 1 final

1.23.74.1 Core and Builtins
...........................

   - bpo-29723(1): The ‘sys.path[0]’ initialization change for
     bpo-29139(2) caused a regression by revealing an inconsistency in
     how sys.path is initialized when executing ‘__main__’ from a
     zipfile, directory, or other import location.  The interpreter now
     consistently avoids ever adding the import location's parent
     directory to ‘sys.path’, and ensures no other ‘sys.path’ entries
     are inadvertently modified when inserting the import location named
     on the command line.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29723

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29139


File: python.info,  Node: Build<66>,  Prev: Core and Builtins<67>,  Up: Python 3 6 1 final

1.23.74.2 Build
...............

   - bpo-27593(1): fix format of git information used in sys.version

   - Fix incompatible comment in python.h

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27593


File: python.info,  Node: Python 3 6 1 release candidate 1,  Next: Python 3 6 0 final,  Prev: Python 3 6 1 final,  Up: 変更履歴

1.23.75 Python 3.6.1 release candidate 1
----------------------------------------

'Release date: 2017-03-04'

* Menu:

* Core and Builtins: Core and Builtins<68>.
* Library: Library<68>.
* IDLE: IDLE<51>.
* Windows: Windows<59>.
* C API: C API<60>.
* Documentation: Documentation<61>.
* Tests: Tests<62>.
* Build: Build<67>.


File: python.info,  Node: Core and Builtins<68>,  Next: Library<68>,  Up: Python 3 6 1 release candidate 1

1.23.75.1 Core and Builtins
...........................

   - bpo-28893(1): Set correct __cause__ for errors about invalid
     awaitables returned from __aiter__ and __anext__.

   - bpo-29683(2): Fixes to memory allocation in _PyCode_SetExtra.
     Patch by Brian Coleman.

   - bpo-29684(3): Fix minor regression of
     PyEval_CallObjectWithKeywords.  It should raise TypeError when
     kwargs is not a dict.  But it might cause segv when args=NULL and
     kwargs is not a dict.

   - bpo-28598(4): Support __rmod__ for subclasses of str being called
     before str.__mod__.  Patch by Martijn Pieters.

   - bpo-29607(5): Fix stack_effect computation for CALL_FUNCTION_EX.
     Patch by Matthieu Dartiailh.

   - bpo-29602(6): Fix incorrect handling of signed zeros in complex
     constructor for complex subclasses and for inputs having a
     __complex__ method.  Patch by Serhiy Storchaka.

   - bpo-29347(7): Fixed possibly dereferencing undefined pointers when
     creating weakref objects.

   - bpo-29438(8): Fixed use-after-free problem in key sharing dict.

   - bpo-29319(9): Prevent RunMainFromImporter overwriting sys.path[0].

   - bpo-29337(10): Fixed possible BytesWarning when compare the code
     objects.  Warnings could be emitted at compile time.

   - bpo-29327(11): Fixed a crash when pass the iterable keyword
     argument to sorted().

   - bpo-29034(12): Fix memory leak and use-after-free in os module
     (path_converter).

   - bpo-29159(13): Fix regression in bytes(x) when x.__index__() raises
     Exception.

   - bpo-28932(14): Do not include <sys/random.h> if it does not exist.

   - bpo-25677(15): Correct the positioning of the syntax error caret
     for indented blocks.  Based on patch by Michael Layzell.

   - bpo-29000(16): Fixed bytes formatting of octals with zero padding
     in alternate form.

   - bpo-26919(17): On Android, operating system data is now always
     encoded/decoded to/from UTF-8, instead of the locale encoding to
     avoid inconsistencies with os.fsencode() and os.fsdecode() which
     are already using UTF-8.

   - bpo-28991(18): functools.lru_cache() was susceptible to an obscure
     reentrancy bug triggerable by a monkey-patched len() function.

   - bpo-28739(19): f-string expressions are no longer accepted as
     docstrings and by ast.literal_eval() even if they do not include
     expressions.

   - bpo-28512(20): Fixed setting the offset attribute of SyntaxError by
     PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().

   - bpo-28918(21): Fix the cross compilation of xxlimited when Python
     has been built with Py_DEBUG defined.

   - bpo-28731(22): Optimize _PyDict_NewPresized() to create correct
     size dict.  Improve speed of dict literal with constant keys up to
     30%.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28893

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29683

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29684

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28598

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29607

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29602

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29347

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29438

   (9) https://bugs.python.org/issue?@action=redirect&bpo=29319

   (10) https://bugs.python.org/issue?@action=redirect&bpo=29337

   (11) https://bugs.python.org/issue?@action=redirect&bpo=29327

   (12) https://bugs.python.org/issue?@action=redirect&bpo=29034

   (13) https://bugs.python.org/issue?@action=redirect&bpo=29159

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28932

   (15) https://bugs.python.org/issue?@action=redirect&bpo=25677

   (16) https://bugs.python.org/issue?@action=redirect&bpo=29000

   (17) https://bugs.python.org/issue?@action=redirect&bpo=26919

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28991

   (19) https://bugs.python.org/issue?@action=redirect&bpo=28739

   (20) https://bugs.python.org/issue?@action=redirect&bpo=28512

   (21) https://bugs.python.org/issue?@action=redirect&bpo=28918

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28731


File: python.info,  Node: Library<68>,  Next: IDLE<51>,  Prev: Core and Builtins<68>,  Up: Python 3 6 1 release candidate 1

1.23.75.2 Library
.................

   - bpo-29169(1): Update zlib to 1.2.11.

   - bpo-29623(2): Allow use of path-like object as a single argument in
     ConfigParser.read().  Patch by David Ellis.

   - bpo-28963(3): Fix out of bound iteration in
     asyncio.Future.remove_done_callback implemented in C.

   - bpo-29704(4): asyncio.subprocess.SubprocessStreamProtocol no longer
     closes before all pipes are closed.

   - bpo-29271(5): Fix Task.current_task and Task.all_tasks implemented
     in C to accept None argument as their pure Python implementation.

   - bpo-29703(6): Fix asyncio to support instantiation of new event
     loops in child processes.

   - bpo-29376(7): Fix assertion error in
     threading._DummyThread.is_alive().

   - bpo-28624(8): Add a test that checks that cwd parameter of Popen()
     accepts PathLike objects.  Patch by Sayan Chowdhury.

   - bpo-28518(9): Start a transaction implicitly before a DML
     statement.  Patch by Aviv Palivoda.

   - bpo-29532(10): Altering a kwarg dictionary passed to
     functools.partial() no longer affects a partial object after
     creation.

   - bpo-29110(11): Fix file object leak in aifc.open() when file is
     given as a filesystem path and is not in valid AIFF format.  Patch
     by Anthony Zhang.

   - bpo-28556(12): Various updates to typing module: typing.Counter,
     typing.ChainMap, improved ABC caching, etc.  Original PRs by Jelle
     Zijlstra, Ivan Levkivskyi, Manuel Krebber, and Łukasz Langa.

   - bpo-29100(13): Fix datetime.fromtimestamp() regression introduced
     in Python 3.6.0: check minimum and maximum years.

   - bpo-29519(14): Fix weakref spewing exceptions during interpreter
     shutdown when used with a rare combination of multiprocessing and
     custom codecs.

   - bpo-29416(15): Prevent infinite loop in pathlib.Path.mkdir

   - bpo-29444(16): Fixed out-of-bounds buffer access in the group()
     method of the match object.  Based on patch by WGH.

   - bpo-29335(17): Fix subprocess.Popen.wait() when the child process
     has exited to a stopped instead of terminated state (ex: when under
     ptrace).

   - bpo-29290(18): Fix a regression in argparse that help messages
     would wrap at non-breaking spaces.

   - bpo-28735(19): Fixed the comparison of mock.MagickMock with
     mock.ANY.

   - bpo-29316(20): Restore the provisional status of typing module, add
     corresponding note to documentation.  Patch by Ivan L.

   - bpo-29219(21): Fixed infinite recursion in the repr of
     uninitialized ctypes.CDLL instances.

   - bpo-29011(22): Fix an important omission by adding Deque to the
     typing module.

   - bpo-28969(23): Fixed race condition in C implementation of
     functools.lru_cache.  KeyError could be raised when cached function
     with full cache was simultaneously called from different threads
     with the same uncached arguments.

   - bpo-29142(24): In urllib.request, suffixes in no_proxy environment
     variable with leading dots could match related hostnames again
     (e.g.  .b.c matches a.b.c).  Patch by Milan Oberkirch.

   - bpo-28961(25): Fix unittest.mock._Call helper: don't ignore the
     name parameter anymore.  Patch written by Jiajun Huang.

   - bpo-29203(26): functools.lru_cache() now respects PEP 468(27) and
     preserves the order of keyword arguments.  f(a=1, b=2) is now
     cached separately from f(b=2, a=1) since both calls could
     potentially give different results.

   - bpo-15812(28): inspect.getframeinfo() now correctly shows the first
     line of a context.  Patch by Sam Breese.

   - bpo-29094(29): Offsets in a ZIP file created with extern file
     object and modes "w" and "x" now are relative to the start of the
     file.

   - bpo-29085(30): Allow random.Random.seed() to use high quality OS
     randomness rather than the pid and time.

   - bpo-29061(31): Fixed bug in secrets.randbelow() which would hang
     when given a negative input.  Patch by Brendan Donegan.

   - bpo-29079(32): Prevent infinite loop in pathlib.resolve() on
     Windows

   - bpo-13051(33): Fixed recursion errors in large or resized
     curses.textpad.Textbox.  Based on patch by Tycho Andersen.

   - bpo-29119(34): Fix weakrefs in the pure python version of
     collections.OrderedDict move_to_end() method.  Contributed by Andra
     Bogildea.

   - bpo-9770(35): curses.ascii predicates now work correctly with
     negative integers.

   - bpo-28427(36): old keys should not remove new values from
     WeakValueDictionary when collecting from another thread.

   - bpo-28923(37): Remove editor artifacts from Tix.py.

   - bpo-29055(38): Neaten-up empty population error on random.choice()
     by suppressing the upstream exception.

   - bpo-28871(39): Fixed a crash when deallocate deep ElementTree.

   - bpo-19542(40): Fix bugs in WeakValueDictionary.setdefault() and
     WeakValueDictionary.pop() when a GC collection happens in another
     thread.

   - bpo-20191(41): Fixed a crash in resource.prlimit() when passing a
     sequence that doesn't own its elements as limits.

   - bpo-28779(42): multiprocessing.set_forkserver_preload() would crash
     the forkserver process if a preloaded module instantiated some
     multiprocessing objects such as locks.

   - bpo-28847(43): dbm.dumb now supports reading read-only files and no
     longer writes the index file when it is not changed.

   - bpo-26937(44): The chown() method of the tarfile.TarFile class does
     not fail now when the grp module cannot be imported, as for example
     on Android platforms.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29169

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29623

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28963

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29704

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29271

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29703

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29376

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28624

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28518

   (10) https://bugs.python.org/issue?@action=redirect&bpo=29532

   (11) https://bugs.python.org/issue?@action=redirect&bpo=29110

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (13) https://bugs.python.org/issue?@action=redirect&bpo=29100

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29519

   (15) https://bugs.python.org/issue?@action=redirect&bpo=29416

   (16) https://bugs.python.org/issue?@action=redirect&bpo=29444

   (17) https://bugs.python.org/issue?@action=redirect&bpo=29335

   (18) https://bugs.python.org/issue?@action=redirect&bpo=29290

   (19) https://bugs.python.org/issue?@action=redirect&bpo=28735

   (20) https://bugs.python.org/issue?@action=redirect&bpo=29316

   (21) https://bugs.python.org/issue?@action=redirect&bpo=29219

   (22) https://bugs.python.org/issue?@action=redirect&bpo=29011

   (23) https://bugs.python.org/issue?@action=redirect&bpo=28969

   (24) https://bugs.python.org/issue?@action=redirect&bpo=29142

   (25) https://bugs.python.org/issue?@action=redirect&bpo=28961

   (26) https://bugs.python.org/issue?@action=redirect&bpo=29203

   (27) https://peps.python.org/pep-0468/

   (28) https://bugs.python.org/issue?@action=redirect&bpo=15812

   (29) https://bugs.python.org/issue?@action=redirect&bpo=29094

   (30) https://bugs.python.org/issue?@action=redirect&bpo=29085

   (31) https://bugs.python.org/issue?@action=redirect&bpo=29061

   (32) https://bugs.python.org/issue?@action=redirect&bpo=29079

   (33) https://bugs.python.org/issue?@action=redirect&bpo=13051

   (34) https://bugs.python.org/issue?@action=redirect&bpo=29119

   (35) https://bugs.python.org/issue?@action=redirect&bpo=9770

   (36) https://bugs.python.org/issue?@action=redirect&bpo=28427

   (37) https://bugs.python.org/issue?@action=redirect&bpo=28923

   (38) https://bugs.python.org/issue?@action=redirect&bpo=29055

   (39) https://bugs.python.org/issue?@action=redirect&bpo=28871

   (40) https://bugs.python.org/issue?@action=redirect&bpo=19542

   (41) https://bugs.python.org/issue?@action=redirect&bpo=20191

   (42) https://bugs.python.org/issue?@action=redirect&bpo=28779

   (43) https://bugs.python.org/issue?@action=redirect&bpo=28847

   (44) https://bugs.python.org/issue?@action=redirect&bpo=26937


File: python.info,  Node: IDLE<51>,  Next: Windows<59>,  Prev: Library<68>,  Up: Python 3 6 1 release candidate 1

1.23.75.3 IDLE
..............

   - bpo-29071(1): IDLE colors f-string prefixes (but not invalid ur
     prefixes).

   - bpo-28572(2): Add 10% to coverage of IDLE's test_configdialog.
     Update and augment description of the configuration system.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29071

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28572


File: python.info,  Node: Windows<59>,  Next: C API<60>,  Prev: IDLE<51>,  Up: Python 3 6 1 release candidate 1

1.23.75.4 Windows
.................

   - bpo-29579(1): Removes readme.txt from the installer

   - bpo-29326(2): Ignores blank lines in ._pth files (Patch by Alexey
     Izbyshev)

   - bpo-28164(3): Correctly handle special console filenames (patch by
     Eryk Sun)

   - bpo-29409(4): Implement PEP 529(5) for io.FileIO (Patch by Eryk
     Sun)

   - bpo-29392(6): Prevent crash when passing invalid arguments into
     msvcrt module.

   - bpo-25778(7): winreg does not truncate string correctly (Patch by
     Eryk Sun)

   - bpo-28896(8): Deprecate WindowsRegistryFinder and disable it by
     default.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29579

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29326

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28164

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29409

   (5) https://peps.python.org/pep-0529/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29392

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25778

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28896


File: python.info,  Node: C API<60>,  Next: Documentation<61>,  Prev: Windows<59>,  Up: Python 3 6 1 release candidate 1

1.23.75.5 C API
...............

   - bpo-27867(1): Function PySlice_GetIndicesEx() is replaced with a
     macro if Py_LIMITED_API is not set or set to the value between
     0x03050400 and 0x03060000 (not including) or 0x03060100 or higher.

   - bpo-29083(2): Fixed the declaration of some public API functions.
     PyArg_VaParse() and PyArg_VaParseTupleAndKeywords() were not
     available in limited API. PyArg_ValidateKeywordArguments(),
     PyArg_UnpackTuple() and Py_BuildValue() were not available in
     limited API of version < 3.3 when PY_SSIZE_T_CLEAN is defined.

   - bpo-29058(3): All stable API extensions added after Python 3.2 are
     now available only when Py_LIMITED_API is set to the PY_VERSION_HEX
     value of the minimum Python version supporting this API.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27867

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29083

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29058


File: python.info,  Node: Documentation<61>,  Next: Tests<62>,  Prev: C API<60>,  Up: Python 3 6 1 release candidate 1

1.23.75.6 Documentation
.......................

   - bpo-28929(1): Link the documentation to its source file on GitHub.

   - bpo-25008(2): Document smtpd.py as effectively deprecated and add a
     pointer to aiosmtpd, a third-party asyncio-based replacement.

   - bpo-26355(3): Add canonical header link on each page to
     corresponding major version of the documentation.  Patch by
     Matthias Bussonnier.

   - bpo-29349(4): Fix Python 2 syntax in code for building the
     documentation.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28929

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25008

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26355

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29349


File: python.info,  Node: Tests<62>,  Next: Build<67>,  Prev: Documentation<61>,  Up: Python 3 6 1 release candidate 1

1.23.75.7 Tests
...............

   - bpo-28087(1): Skip test_asyncore and test_eintr poll failures on
     macOS. Skip some tests of select.poll when running on macOS due to
     unresolved issues with the underlying system poll function on some
     macOS versions.

   - bpo-29571(2): to match the behaviour of the ‘re.LOCALE’ flag,
     test_re.test_locale_flag now uses
     ‘locale.getpreferredencoding(False)’ to determine the candidate
     encoding for the test regex (allowing it to correctly skip the test
     when the default locale encoding is a multi-byte encoding)

   - bpo-28950(3): Disallow -j0 to be combined with -T/-l in regrtest
     command line arguments.

   - bpo-28683(4): Fix the tests that bind() a unix socket and raise
     PermissionError on Android for a non-root user.

   - bpo-26939(5): Add the support.setswitchinterval() function to fix
     test_functools hanging on the Android armv7 qemu emulator.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28087

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29571

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28950

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28683

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26939


File: python.info,  Node: Build<67>,  Prev: Tests<62>,  Up: Python 3 6 1 release candidate 1

1.23.75.8 Build
...............

   - bpo-27593(1): sys.version and the platform module python_build(),
     python_branch(), and python_revision() functions now use git
     information rather than hg when building from a repo.

   - bpo-29572(2): Update Windows build and OS X installers to use
     OpenSSL 1.0.2k.

   - bpo-26851(3): Set Android compilation and link flags.

   - bpo-28768(4): Fix implicit declaration of function _setmode.  Patch
     by Masayuki Yamamoto

   - bpo-29080(5): Removes hard dependency on hg.exe from
     PCBuild/build.bat

   - bpo-23903(6): Added missed names to PC/python3.def.

   - bpo-28762(7): lockf() is available on Android API level 24, but the
     F_LOCK macro is not defined in android-ndk-r13.

   - bpo-28538(8): Fix the compilation error that occurs because
     if_nameindex() is available on Android API level 24, but the
     if_nameindex structure is not defined.

   - bpo-20211(9): Do not add the directory for installing C header
     files and the directory for installing object code libraries to the
     cross compilation search paths.  Original patch by Thomas
     Petazzoni.

   - bpo-28849(10): Do not define sys.implementation._multiarch on
     Android.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27593

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29572

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26851

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28768

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29080

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23903

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28762

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28538

   (9) https://bugs.python.org/issue?@action=redirect&bpo=20211

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28849


File: python.info,  Node: Python 3 6 0 final,  Next: Python 3 6 0 release candidate 2,  Prev: Python 3 6 1 release candidate 1,  Up: 変更履歴

1.23.76 Python 3.6.0 final
--------------------------

'Release date: 2016-12-23'

No changes since release candidate 2


File: python.info,  Node: Python 3 6 0 release candidate 2,  Next: Python 3 6 0 release candidate 1,  Prev: Python 3 6 0 final,  Up: 変更履歴

1.23.77 Python 3.6.0 release candidate 2
----------------------------------------

'Release date: 2016-12-16'

* Menu:

* Core and Builtins: Core and Builtins<69>.
* Tools/Demos: Tools/Demos<36>.
* Windows: Windows<60>.
* Build: Build<68>.


File: python.info,  Node: Core and Builtins<69>,  Next: Tools/Demos<36>,  Up: Python 3 6 0 release candidate 2

1.23.77.1 Core and Builtins
...........................

   - bpo-28147(1): Fix a memory leak in split-table dictionaries:
     setattr() must not convert combined table into split table.  Patch
     written by INADA Naoki.

   - bpo-28990(2): Fix asyncio SSL hanging if connection is closed
     before handshake is completed.  (Patch by HoHo-Ho)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28147

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28990


File: python.info,  Node: Tools/Demos<36>,  Next: Windows<60>,  Prev: Core and Builtins<69>,  Up: Python 3 6 0 release candidate 2

1.23.77.2 Tools/Demos
.....................

   - bpo-28770(1): Fix python-gdb.py for fastcalls.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28770


File: python.info,  Node: Windows<60>,  Next: Build<68>,  Prev: Tools/Demos<36>,  Up: Python 3 6 0 release candidate 2

1.23.77.3 Windows
.................

   - bpo-28896(1): Deprecate WindowsRegistryFinder.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28896


File: python.info,  Node: Build<68>,  Prev: Windows<60>,  Up: Python 3 6 0 release candidate 2

1.23.77.4 Build
...............

   - bpo-28898(1): Prevent gdb build errors due to HAVE_LONG_LONG
     redefinition.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28898


File: python.info,  Node: Python 3 6 0 release candidate 1,  Next: Python 3 6 0 beta 4,  Prev: Python 3 6 0 release candidate 2,  Up: 変更履歴

1.23.78 Python 3.6.0 release candidate 1
----------------------------------------

'Release date: 2016-12-06'

* Menu:

* Core and Builtins: Core and Builtins<70>.
* Library: Library<69>.
* C API: C API<61>.
* Documentation: Documentation<62>.
* Tools/Demos: Tools/Demos<37>.


File: python.info,  Node: Core and Builtins<70>,  Next: Library<69>,  Up: Python 3 6 0 release candidate 1

1.23.78.1 Core and Builtins
...........................

   - bpo-23722(1): Rather than silently producing a class that doesn't
     support zero-argument ‘super()’ in methods, failing to pass the new
     ‘__classcell__’ namespace entry up to ‘type.__new__’ now results in
     a ‘DeprecationWarning’ and a class that supports zero-argument
     ‘super()’.

   - bpo-28797(2): Modifying the class __dict__ inside the __set_name__
     method of a descriptor that is used inside that class no longer
     prevents calling the __set_name__ method of other descriptors.

   - bpo-28782(3): Fix a bug in the implementation ‘yield from’ when
     checking if the next instruction is YIELD_FROM. Regression
     introduced by WORDCODE (bpo-26647(4)).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23722

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28797

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28782

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26647


File: python.info,  Node: Library<69>,  Next: C API<61>,  Prev: Core and Builtins<70>,  Up: Python 3 6 0 release candidate 1

1.23.78.2 Library
.................

   - bpo-27030(1): Unknown escapes in re.sub() replacement template are
     allowed again.  But they still are deprecated and will be disabled
     in 3.7.

   - bpo-28835(2): Fix a regression introduced in
     warnings.catch_warnings(): call warnings.showwarning() if it was
     overridden inside the context manager.

   - bpo-27172(3): To assist with upgrades from 2.7, the previously
     documented deprecation of ‘inspect.getfullargspec()’ has been
     reversed.  This decision may be revisited again after the Python
     2.7 branch is no longer officially supported.

   - bpo-26273(4): Add new ‘socket.TCP_CONGESTION’ (Linux 2.6.13) and
     ‘socket.TCP_USER_TIMEOUT’ (Linux 2.6.37) constants.  Patch written
     by Omar Sandoval.

   - bpo-24142(5): Reading a corrupt config file left configparser in an
     invalid state.  Original patch by Florian Höch.

   - bpo-28843(6): Fix asyncio C Task to handle exceptions
     __traceback__.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27030

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28835

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27172

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26273

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24142

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28843


File: python.info,  Node: C API<61>,  Next: Documentation<62>,  Prev: Library<69>,  Up: Python 3 6 0 release candidate 1

1.23.78.3 C API
...............

   - bpo-28808(1): PyUnicode_CompareWithASCIIString() now never raises
     exceptions.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28808


File: python.info,  Node: Documentation<62>,  Next: Tools/Demos<37>,  Prev: C API<61>,  Up: Python 3 6 0 release candidate 1

1.23.78.4 Documentation
.......................

   - bpo-23722(1): The data model reference and the porting section in
     the What's New guide now cover the additional ‘__classcell__’
     handling needed for custom metaclasses to fully support PEP 487(2)
     and zero-argument ‘super()’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23722

   (2) https://peps.python.org/pep-0487/


File: python.info,  Node: Tools/Demos<37>,  Prev: Documentation<62>,  Up: Python 3 6 0 release candidate 1

1.23.78.5 Tools/Demos
.....................

   - bpo-28023(1): Fix python-gdb.py didn't support new dict
     implementation.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28023


File: python.info,  Node: Python 3 6 0 beta 4,  Next: Python 3 6 0 beta 3,  Prev: Python 3 6 0 release candidate 1,  Up: 変更履歴

1.23.79 Python 3.6.0 beta 4
---------------------------

'Release date: 2016-11-21'

* Menu:

* Core and Builtins: Core and Builtins<71>.
* Library: Library<70>.
* Documentation: Documentation<63>.
* Tests: Tests<63>.
* Build: Build<69>.


File: python.info,  Node: Core and Builtins<71>,  Next: Library<70>,  Up: Python 3 6 0 beta 4

1.23.79.1 Core and Builtins
...........................

   - bpo-28532(1): Show sys.version when -V option is supplied twice.

   - bpo-27100(2): The with-statement now checks for __enter__ before it
     checks for __exit__.  This gives less confusing error messages when
     both methods are missing.  Patch by Jonathan Ellington.

   - bpo-28746(3): Fix the set_inheritable() file descriptor method on
     platforms that do not have the ioctl FIOCLEX and FIONCLEX commands.

   - bpo-26920(4): Fix not getting the locale's charset upon
     initializing the interpreter, on platforms that do not have
     langinfo.

   - bpo-28648(5): Fixed crash in Py_DecodeLocale() in debug build on
     Mac OS X when decode astral characters.  Patch by Xiang Zhang.

   - bpo-19398(6): Extra slash no longer added to sys.path components in
     case of empty compile-time PYTHONPATH components.

   - bpo-28665(7): Improve speed of the STORE_DEREF opcode by 40%.

   - bpo-28583(8): PyDict_SetDefault didn't combine split table when
     needed.  Patch by Xiang Zhang.

   - bpo-27243(9): Change PendingDeprecationWarning ->
     DeprecationWarning.  As it was agreed in the issue, __aiter__
     returning an awaitable should result in PendingDeprecationWarning
     in 3.5 and in DeprecationWarning in 3.6.

   - bpo-26182(10): Fix a refleak in code that raises
     DeprecationWarning.

   - bpo-28721(11): Fix asynchronous generators aclose() and athrow() to
     handle StopAsyncIteration propagation properly.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28532

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27100

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28746

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26920

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28648

   (6) https://bugs.python.org/issue?@action=redirect&bpo=19398

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28665

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28583

   (9) https://bugs.python.org/issue?@action=redirect&bpo=27243

   (10) https://bugs.python.org/issue?@action=redirect&bpo=26182

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28721


File: python.info,  Node: Library<70>,  Next: Documentation<63>,  Prev: Core and Builtins<71>,  Up: Python 3 6 0 beta 4

1.23.79.2 Library
.................

   - bpo-28752(1): Restored the __reduce__() methods of datetime
     objects.

   - bpo-28727(2): Regular expression patterns, _sre.SRE_Pattern objects
     created by re.compile(), become comparable (only x==y and x!=y
     operators).  This change should fix the bpo-18383(3): don't
     duplicate warning filters when the warnings module is reloaded
     (thing usually only done in unit tests).

   - bpo-20572(4): The subprocess.Popen.wait method's undocumented
     endtime parameter now raises a DeprecationWarning.

   - bpo-25659(5): In ctypes, prevent a crash calling the from_buffer()
     and from_buffer_copy() methods on abstract classes like Array.

   - bpo-19717(6): Makes Path.resolve() succeed on paths that do not
     exist.  Patch by Vajrasky Kok

   - bpo-28563(7): Fixed possible DoS and arbitrary code execution when
     handle plural form selections in the gettext module.  The
     expression parser now supports exact syntax supported by GNU
     gettext.

   - bpo-28387(8): Fixed possible crash in _io.TextIOWrapper deallocator
     when the garbage collector is invoked in other thread.  Based on
     patch by Sebastian Cufre.

   - bpo-28600(9): Optimize loop.call_soon.

   - bpo-28613(10): Fix get_event_loop() return the current loop if
     called from coroutines/callbacks.

   - bpo-28634(11): Fix asyncio.isfuture() to support unittest.Mock.

   - bpo-26081(12): Fix refleak in _asyncio.Future.__iter__().throw.

   - bpo-28639(13): Fix inspect.isawaitable to always return bool Patch
     by Justin Mayfield.

   - bpo-28652(14): Make loop methods reject socket kinds they do not
     support.

   - bpo-28653(15): Fix a refleak in functools.lru_cache.

   - bpo-28703(16): Fix asyncio.iscoroutinefunction to handle Mock
     objects.

   - bpo-28704(17): Fix create_unix_server to support Path-like objects
     (PEP 519).

   - bpo-28720(18): Add collections.abc.AsyncGenerator.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28752

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28727

   (3) https://bugs.python.org/issue?@action=redirect&bpo=18383

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20572

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25659

   (6) https://bugs.python.org/issue?@action=redirect&bpo=19717

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28563

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28387

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28600

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28613

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28634

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26081

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28639

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28652

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28653

   (16) https://bugs.python.org/issue?@action=redirect&bpo=28703

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28704

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28720


File: python.info,  Node: Documentation<63>,  Next: Tests<63>,  Prev: Library<70>,  Up: Python 3 6 0 beta 4

1.23.79.3 Documentation
.......................

   - bpo-28513(1): Documented command-line interface of zipfile.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28513


File: python.info,  Node: Tests<63>,  Next: Build<69>,  Prev: Documentation<63>,  Up: Python 3 6 0 beta 4

1.23.79.4 Tests
...............

   - bpo-28666(1): Now test.support.rmtree is able to remove unwritable
     or unreadable directories.

   - bpo-23839(2): Various caches now are cleared before running every
     test file.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28666

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23839


File: python.info,  Node: Build<69>,  Prev: Tests<63>,  Up: Python 3 6 0 beta 4

1.23.79.5 Build
...............

   - bpo-10656(1): Fix out-of-tree building on AIX. Patch by Tristan
     Carel and Michael Haubenwallner.

   - bpo-26359(2): Rename -with-optimiations to -enable-optimizations.

   - bpo-28676(3): Prevent missing 'getentropy' declaration warning on
     macOS. Patch by Gareth Rees.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=10656

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26359

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28676


File: python.info,  Node: Python 3 6 0 beta 3,  Next: Python 3 6 0 beta 2,  Prev: Python 3 6 0 beta 4,  Up: 変更履歴

1.23.80 Python 3.6.0 beta 3
---------------------------

'Release date: 2016-10-31'

* Menu:

* Core and Builtins: Core and Builtins<72>.
* Library: Library<71>.
* Windows: Windows<61>.
* Build: Build<70>.
* Tests: Tests<64>.


File: python.info,  Node: Core and Builtins<72>,  Next: Library<71>,  Up: Python 3 6 0 beta 3

1.23.80.1 Core and Builtins
...........................

   - bpo-28128(1): Deprecation warning for invalid str and byte escape
     sequences now prints better information about where the error
     occurs.  Patch by Serhiy Storchaka and Eric Smith.

   - bpo-28509(2): dict.update() no longer allocate unnecessary large
     memory.

   - bpo-28426(3): Fixed potential crash in PyUnicode_AsDecodedObject()
     in debug build.

   - bpo-28517(4): Fixed of-by-one error in the peephole optimizer that
     caused keeping unreachable code.

   - bpo-28214(5): Improved exception reporting for problematic
     __set_name__ attributes.

   - bpo-23782(6): Fixed possible memory leak in _PyTraceback_Add() and
     exception loss in PyTraceBack_Here().

   - bpo-28471(7): Fix "Python memory allocator called without holding
     the GIL" crash in socket.setblocking.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28128

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28509

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28426

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28517

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28214

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23782

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28471


File: python.info,  Node: Library<71>,  Next: Windows<61>,  Prev: Core and Builtins<72>,  Up: Python 3 6 0 beta 3

1.23.80.2 Library
.................

   - bpo-27517(1): LZMA compressor and decompressor no longer raise
     exceptions if given empty data twice.  Patch by Benjamin Fogle.

   - bpo-28549(2): Fixed segfault in curses's addch() with ncurses6.

   - bpo-28449(3): tarfile.open() with mode "r" or "r:" now tries to
     open a tar file with compression before trying to open it without
     compression.  Otherwise it had 50% chance failed with
     ignore_zeros=True.

   - bpo-23262(4): The webbrowser module now supports Firefox 36+ and
     derived browsers.  Based on patch by Oleg Broytman.

   - bpo-27939(5): Fixed bugs in tkinter.ttk.LabeledScale and
     tkinter.Scale caused by representing the scale as float value
     internally in Tk.  tkinter.IntVar now works if float value is set
     to underlying Tk variable.

   - bpo-18844(6): The various ways of specifying weights for
     random.choices() now produce the same result sequences.

   - bpo-28255(7): calendar.TextCalendar().prmonth() no longer prints a
     space at the start of new line after printing a month's calendar.
     Patch by Xiang Zhang.

   - bpo-20491(8): The textwrap.TextWrapper class now honors
     non-breaking spaces.  Based on patch by Kaarle Ritvanen.

   - bpo-28353(9): os.fwalk() no longer fails on broken links.

   - bpo-28430(10): Fix iterator of C implemented asyncio.Future doesn't
     accept non-None value is passed to it.send(val).

   - bpo-27025(11): Generated names for Tkinter widgets now start by the
     "!"  prefix for readability.

   - bpo-25464(12): Fixed HList.header_exists() in tkinter.tix module by
     addin a workaround to Tix library bug.

   - bpo-28488(13): shutil.make_archive() no longer adds entry "./" to
     ZIP archive.

   - bpo-25953(14): re.sub() now raises an error for invalid numerical
     group reference in replacement template even if the pattern is not
     found in the string.  Error message for invalid group reference now
     includes the group index and the position of the reference.  Based
     on patch by SilentGhost.

   - bpo-18219(15): Optimize csv.DictWriter for large number of columns.
     Patch by Mariatta Wijaya.

   - bpo-28448(16): Fix C implemented asyncio.Future didn't work on
     Windows.

   - bpo-28480(17): Fix error building socket module when multithreading
     is disabled.

   - bpo-24452(18): Make webbrowser support Chrome on Mac OS X.

   - bpo-20766(19): Fix references leaked by pdb in the handling of
     SIGINT handlers.

   - bpo-28492(20): Fix how StopIteration exception is raised in
     _asyncio.Future.

   - bpo-28500(21): Fix asyncio to handle async gens GC from another
     thread.

   - bpo-26923(22): Fix asyncio.Gather to refuse being cancelled once
     all children are done.  Patch by Johannes Ebke.

   - bpo-26796(23): Don't configure the number of workers for default
     threadpool executor.  Initial patch by Hans Lawrenz.

   - bpo-28544(24): Implement asyncio.Task in C.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27517

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28549

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28449

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23262

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27939

   (6) https://bugs.python.org/issue?@action=redirect&bpo=18844

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28255

   (8) https://bugs.python.org/issue?@action=redirect&bpo=20491

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28353

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28430

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27025

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25464

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28488

   (14) https://bugs.python.org/issue?@action=redirect&bpo=25953

   (15) https://bugs.python.org/issue?@action=redirect&bpo=18219

   (16) https://bugs.python.org/issue?@action=redirect&bpo=28448

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28480

   (18) https://bugs.python.org/issue?@action=redirect&bpo=24452

   (19) https://bugs.python.org/issue?@action=redirect&bpo=20766

   (20) https://bugs.python.org/issue?@action=redirect&bpo=28492

   (21) https://bugs.python.org/issue?@action=redirect&bpo=28500

   (22) https://bugs.python.org/issue?@action=redirect&bpo=26923

   (23) https://bugs.python.org/issue?@action=redirect&bpo=26796

   (24) https://bugs.python.org/issue?@action=redirect&bpo=28544


File: python.info,  Node: Windows<61>,  Next: Build<70>,  Prev: Library<71>,  Up: Python 3 6 0 beta 3

1.23.80.3 Windows
.................

   - bpo-28522(1): Fixes mishandled buffer reallocation in getpathp.c

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28522


File: python.info,  Node: Build<70>,  Next: Tests<64>,  Prev: Windows<61>,  Up: Python 3 6 0 beta 3

1.23.80.4 Build
...............

   - bpo-28444(1): Fix missing extensions modules when cross compiling.

   - bpo-28208(2): Update Windows build and OS X installers to use
     SQLite 3.14.2.

   - bpo-28248(3): Update Windows build and OS X installers to use
     OpenSSL 1.0.2j.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28444

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28208

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28248


File: python.info,  Node: Tests<64>,  Prev: Build<70>,  Up: Python 3 6 0 beta 3

1.23.80.5 Tests
...............

   - bpo-26944(1): Fix test_posix for Android where 'id -G' is entirely
     wrong or missing the effective gid.

   - bpo-28409(2): regrtest: fix the parser of command line arguments.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26944

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28409


File: python.info,  Node: Python 3 6 0 beta 2,  Next: Python 3 6 0 beta 1,  Prev: Python 3 6 0 beta 3,  Up: 変更履歴

1.23.81 Python 3.6.0 beta 2
---------------------------

'Release date: 2016-10-10'

* Menu:

* Core and Builtins: Core and Builtins<73>.
* Library: Library<72>.
* Windows: Windows<62>.
* C API: C API<62>.
* Build: Build<71>.
* Tests: Tests<65>.


File: python.info,  Node: Core and Builtins<73>,  Next: Library<72>,  Up: Python 3 6 0 beta 2

1.23.81.1 Core and Builtins
...........................

   - bpo-28183(1): Optimize and cleanup dict iteration.

   - bpo-26081(2): Added C implementation of asyncio.Future.  Original
     patch by Yury Selivanov.

   - bpo-28379(3): Added sanity checks and tests for
     PyUnicode_CopyCharacters().  Patch by Xiang Zhang.

   - bpo-28376(4): The type of long range iterator is now registered as
     Iterator.  Patch by Oren Milman.

   - bpo-28376(5): Creating instances of range_iterator by calling
     range_iterator type now is deprecated.  Patch by Oren Milman.

   - bpo-28376(6): The constructor of range_iterator now checks that
     step is not 0.  Patch by Oren Milman.

   - bpo-26906(7): Resolving special methods of uninitialized type now
     causes implicit initialization of the type instead of a fail.

   - bpo-18287(8): PyType_Ready() now checks that tp_name is not NULL.
     Original patch by Niklas Koep.

   - bpo-24098(9): Fixed possible crash when AST is changed in process
     of compiling it.

   - bpo-28201(10): Dict reduces possibility of 2nd conflict in hash
     table when hashes have same lower bits.

   - bpo-28350(11): String constants with null character no longer
     interned.

   - bpo-26617(12): Fix crash when GC runs during weakref callbacks.

   - bpo-27942(13): String constants now interned recursively in tuples
     and frozensets.

   - bpo-21578(14): Fixed misleading error message when ImportError
     called with invalid keyword args.

   - bpo-28203(15): Fix incorrect type in complex(1.0, {2:3}) error
     message.  Patch by Soumya Sharma.

   - bpo-28086(16): Single var-positional argument of tuple subtype was
     passed unscathed to the C-defined function.  Now it is converted to
     exact tuple.

   - bpo-28214(17): Now __set_name__ is looked up on the class instead
     of the instance.

   - bpo-27955(18): Fallback on reading /dev/urandom device when the
     getrandom() syscall fails with EPERM, for example when blocked by
     SECCOMP.

   - bpo-28192(19): Don't import readline in isolated mode.

   - Upgrade internal unicode databases to Unicode version 9.0.0.

   - bpo-28131(20): Fix a regression in zipimport's compile_source().
     zipimport should use the same optimization level as the
     interpreter.

   - bpo-28126(21): Replace Py_MEMCPY with memcpy().  Visual Studio can
     properly optimize memcpy().

   - bpo-28120(22): Fix dict.pop() for splitted dictionary when trying
     to remove a "pending key" (Not yet inserted in split-table).  Patch
     by Xiang Zhang.

   - bpo-26182(23): Raise DeprecationWarning when async and await
     keywords are used as variable/attribute/class/function name.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28183

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26081

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28379

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28376

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28376

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28376

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26906

   (8) https://bugs.python.org/issue?@action=redirect&bpo=18287

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24098

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28201

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28350

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26617

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27942

   (14) https://bugs.python.org/issue?@action=redirect&bpo=21578

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28203

   (16) https://bugs.python.org/issue?@action=redirect&bpo=28086

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28214

   (18) https://bugs.python.org/issue?@action=redirect&bpo=27955

   (19) https://bugs.python.org/issue?@action=redirect&bpo=28192

   (20) https://bugs.python.org/issue?@action=redirect&bpo=28131

   (21) https://bugs.python.org/issue?@action=redirect&bpo=28126

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28120

   (23) https://bugs.python.org/issue?@action=redirect&bpo=26182


File: python.info,  Node: Library<72>,  Next: Windows<62>,  Prev: Core and Builtins<73>,  Up: Python 3 6 0 beta 2

1.23.81.2 Library
.................

   - bpo-27998(1): Fixed bytes path support in os.scandir() on Windows.
     Patch by Eryk Sun.

   - bpo-28317(2): The disassembler now decodes FORMAT_VALUE argument.

   - bpo-26293(3): Fixed writing ZIP files that starts not from the
     start of the file.  Offsets in ZIP file now are relative to the
     start of the archive in conforming to the specification.

   - bpo-28380(4): unittest.mock Mock autospec functions now properly
     support assert_called, assert_not_called, and assert_called_once.

   - bpo-27181(5): remove statistics.geometric_mean and defer until 3.7.

   - bpo-28229(6): lzma module now supports pathlib.

   - bpo-28321(7): Fixed writing non-BMP characters with binary format
     in plistlib.

   - bpo-28225(8): bz2 module now supports pathlib.  Initial patch by
     Ethan Furman.

   - bpo-28227(9): gzip now supports pathlib.  Patch by Ethan Furman.

   - bpo-27358(10): Optimized merging var-keyword arguments and improved
     error message when passing a non-mapping as a var-keyword argument.

   - bpo-28257(11): Improved error message when passing a non-iterable
     as a var-positional argument.  Added opcode
     BUILD_TUPLE_UNPACK_WITH_CALL.

   - bpo-28322(12): Fixed possible crashes when unpickle itertools
     objects from incorrect pickle data.  Based on patch by John Leitch.

   - bpo-28228(13): imghdr now supports pathlib.

   - bpo-28226(14): compileall now supports pathlib.

   - bpo-28314(15): Fix function declaration (C flags) for the
     getiterator() method of xml.etree.ElementTree.Element.

   - bpo-28148(16): Stop using localtime() and gmtime() in the time
     module.  Introduced platform independent _PyTime_localtime API that
     is similar to POSIX localtime_r, but available on all platforms.
     Patch by Ed Schouten.

   - bpo-28253(17): Fixed calendar functions for extreme months: 0001-01
     and 9999-12.  Methods itermonthdays() and itermonthdays2() are
     reimplemented so that they don't call itermonthdates() which can
     cause datetime.date under/overflow.

   - bpo-28275(18): Fixed possible use after free in the decompress()
     methods of the LZMADecompressor and BZ2Decompressor classes.
     Original patch by John Leitch.

   - bpo-27897(19): Fixed possible crash in
     sqlite3.Connection.create_collation() if pass invalid string-like
     object as a name.  Patch by Xiang Zhang.

   - bpo-18844(20): random.choices() now has k as a keyword-only
     argument to improve the readability of common cases and come into
     line with the signature used in other languages.

   - bpo-18893(21): Fix invalid exception handling in
     Lib/ctypes/macholib/dyld.py.  Patch by Madison May.

   - bpo-27611(22): Fixed support of default root window in the
     tkinter.tix module.  Added the master parameter in the DisplayStyle
     constructor.

   - bpo-27348(23): In the traceback module, restore the formatting of
     exception messages like "Exception: None".  This fixes a regression
     introduced in 3.5a2.

   - bpo-25651(24): Allow false values to be used for msg parameter of
     subTest().

   - bpo-27778(25): Fix a memory leak in os.getrandom() when the
     getrandom() is interrupted by a signal and a signal handler raises
     a Python exception.

   - bpo-28200(26): Fix memory leak on Windows in the os module (fix
     path_converter() function).

   - bpo-25400(27): RobotFileParser now correctly returns default values
     for crawl_delay and request_rate.  Initial patch by Peter Wirtz.

   - bpo-27932(28): Prevent memory leak in win32_ver().

   - Fix UnboundLocalError in socket._sendfile_use_sendfile.

   - bpo-28075(29): Check for ERROR_ACCESS_DENIED in Windows
     implementation of os.stat().  Patch by Eryk Sun.

   - bpo-22493(30): Warning message emitted by using inline flags in the
     middle of regular expression now contains a (truncated) regex
     pattern.  Patch by Tim Graham.

   - bpo-25270(31): Prevent codecs.escape_encode() from raising
     SystemError when an empty bytestring is passed.

   - bpo-28181(32): Get antigravity over HTTPS. Patch by Kaartic
     Sivaraam.

   - bpo-25895(33): Enable WebSocket URL schemes in
     urllib.parse.urljoin.  Patch by Gergely Imreh and Markus
     Holtermann.

   - bpo-28114(34): Fix a crash in parse_envlist() when env contains
     byte strings.  Patch by Eryk Sun.

   - bpo-27599(35): Fixed buffer overrun in binascii.b2a_qp() and
     binascii.a2b_qp().

   - bpo-27906(36): Fix socket accept exhaustion during high TCP
     traffic.  Patch by Kevin Conway.

   - bpo-28174(37): Handle when SO_REUSEPORT isn't properly supported.
     Patch by Seth Michael Larson.

   - bpo-26654(38): Inspect functools.partial in
     asyncio.Handle.__repr__.  Patch by iceboy.

   - bpo-26909(39): Fix slow pipes IO in asyncio.  Patch by INADA Naoki.

   - bpo-28176(40): Fix callbacks race in
     asyncio.SelectorLoop.sock_connect.

   - bpo-27759(41): Fix selectors incorrectly retain invalid file
     descriptors.  Patch by Mark Williams.

   - bpo-28368(42): Refuse monitoring processes if the child watcher has
     no loop attached.  Patch by Vincent Michel.

   - bpo-28369(43): Raise RuntimeError when transport's FD is used with
     add_reader, add_writer, etc.

   - bpo-28370(44): Speedup asyncio.StreamReader.readexactly.  Patch by
     Коренберг Марк.

   - bpo-28371(45): Deprecate passing asyncio.Handles to
     run_in_executor.

   - bpo-28372(46): Fix asyncio to support formatting of non-python
     coroutines.

   - bpo-28399(47): Remove UNIX socket from FS before binding.  Patch by
     Коренберг Марк.

   - bpo-27972(48): Prohibit Tasks to await on themselves.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27998

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28317

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26293

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28380

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27181

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28229

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28321

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28225

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28227

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27358

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28257

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28322

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28228

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28226

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28314

   (16) https://bugs.python.org/issue?@action=redirect&bpo=28148

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28253

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28275

   (19) https://bugs.python.org/issue?@action=redirect&bpo=27897

   (20) https://bugs.python.org/issue?@action=redirect&bpo=18844

   (21) https://bugs.python.org/issue?@action=redirect&bpo=18893

   (22) https://bugs.python.org/issue?@action=redirect&bpo=27611

   (23) https://bugs.python.org/issue?@action=redirect&bpo=27348

   (24) https://bugs.python.org/issue?@action=redirect&bpo=25651

   (25) https://bugs.python.org/issue?@action=redirect&bpo=27778

   (26) https://bugs.python.org/issue?@action=redirect&bpo=28200

   (27) https://bugs.python.org/issue?@action=redirect&bpo=25400

   (28) https://bugs.python.org/issue?@action=redirect&bpo=27932

   (29) https://bugs.python.org/issue?@action=redirect&bpo=28075

   (30) https://bugs.python.org/issue?@action=redirect&bpo=22493

   (31) https://bugs.python.org/issue?@action=redirect&bpo=25270

   (32) https://bugs.python.org/issue?@action=redirect&bpo=28181

   (33) https://bugs.python.org/issue?@action=redirect&bpo=25895

   (34) https://bugs.python.org/issue?@action=redirect&bpo=28114

   (35) https://bugs.python.org/issue?@action=redirect&bpo=27599

   (36) https://bugs.python.org/issue?@action=redirect&bpo=27906

   (37) https://bugs.python.org/issue?@action=redirect&bpo=28174

   (38) https://bugs.python.org/issue?@action=redirect&bpo=26654

   (39) https://bugs.python.org/issue?@action=redirect&bpo=26909

   (40) https://bugs.python.org/issue?@action=redirect&bpo=28176

   (41) https://bugs.python.org/issue?@action=redirect&bpo=27759

   (42) https://bugs.python.org/issue?@action=redirect&bpo=28368

   (43) https://bugs.python.org/issue?@action=redirect&bpo=28369

   (44) https://bugs.python.org/issue?@action=redirect&bpo=28370

   (45) https://bugs.python.org/issue?@action=redirect&bpo=28371

   (46) https://bugs.python.org/issue?@action=redirect&bpo=28372

   (47) https://bugs.python.org/issue?@action=redirect&bpo=28399

   (48) https://bugs.python.org/issue?@action=redirect&bpo=27972


File: python.info,  Node: Windows<62>,  Next: C API<62>,  Prev: Library<72>,  Up: Python 3 6 0 beta 2

1.23.81.3 Windows
.................

   - bpo-28402(1): Adds signed catalog files for stdlib on Windows.

   - bpo-28333(2): Enables Unicode for ps1/ps2 and input() prompts.
     (Patch by Eryk Sun)

   - bpo-28251(3): Improvements to help manuals on Windows.

   - bpo-28110(4): launcher.msi has different product codes between
     32-bit and 64-bit

   - bpo-28161(5): Opening CON for write access fails

   - bpo-28162(6): WindowsConsoleIO readall() fails if first line starts
     with Ctrl+Z

   - bpo-28163(7): WindowsConsoleIO fileno() passes wrong flags to
     _open_osfhandle

   - bpo-28164(8): _PyIO_get_console_type fails for various paths

   - bpo-28137(9): Renames Windows path file to ._pth

   - bpo-28138(10): Windows ._pth file should allow import site

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28402

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28333

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28251

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28110

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28161

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28162

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28163

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28164

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28137

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28138


File: python.info,  Node: C API<62>,  Next: Build<71>,  Prev: Windows<62>,  Up: Python 3 6 0 beta 2

1.23.81.4 C API
...............

   - bpo-28426(1): Deprecated undocumented functions
     PyUnicode_AsEncodedObject(), PyUnicode_AsDecodedObject(),
     PyUnicode_AsDecodedUnicode() and PyUnicode_AsEncodedUnicode().

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28426


File: python.info,  Node: Build<71>,  Next: Tests<65>,  Prev: C API<62>,  Up: Python 3 6 0 beta 2

1.23.81.5 Build
...............

   - bpo-28258(1): Fixed build with Estonian locale (python-config and
     distclean targets in Makefile).  Patch by Arfrever Frehtes
     Taifersar Arahesis.

   - bpo-26661(2): setup.py now detects system libffi with multiarch
     wrapper.

   - bpo-15819(3): Remove redundant include search directory option for
     building outside the source tree.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28258

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26661

   (3) https://bugs.python.org/issue?@action=redirect&bpo=15819


File: python.info,  Node: Tests<65>,  Prev: Build<71>,  Up: Python 3 6 0 beta 2

1.23.81.6 Tests
...............

   - bpo-28217(1): Adds _testconsole module to test console input.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28217


File: python.info,  Node: Python 3 6 0 beta 1,  Next: Python 3 6 0 alpha 4,  Prev: Python 3 6 0 beta 2,  Up: 変更履歴

1.23.82 Python 3.6.0 beta 1
---------------------------

'Release date: 2016-09-12'

* Menu:

* Core and Builtins: Core and Builtins<74>.
* Library: Library<73>.
* IDLE: IDLE<52>.
* C API: C API<63>.
* Tests: Tests<66>.
* Build: Build<72>.
* Tools/Demos: Tools/Demos<38>.
* Windows: Windows<63>.


File: python.info,  Node: Core and Builtins<74>,  Next: Library<73>,  Up: Python 3 6 0 beta 1

1.23.82.1 Core and Builtins
...........................

   - bpo-23722(1): The __class__ cell used by zero-argument super() is
     now initialized from type.__new__ rather than __build_class__, so
     class methods relying on that will now work correctly when called
     from metaclass methods during class creation.  Patch by Martin
     Teichmann.

   - bpo-25221(2): Fix corrupted result from PyLong_FromLong(0) when
     Python is compiled with NSMALLPOSINTS = 0.

   - bpo-27080(3): Implement formatting support for PEP 515(4).  Initial
     patch by Chris Angelico.

   - bpo-27199(5): In tarfile, expose copyfileobj bufsize to improve
     throughput.  Patch by Jason Fried.

   - bpo-27948(6): In f-strings, only allow backslashes inside the
     braces (where the expressions are).  This is a breaking change from
     the 3.6 alpha releases, where backslashes are allowed anywhere in
     an f-string.  Also, require that expressions inside f-strings be
     enclosed within literal braces, and not escapes like
     ‘f'\x7b"hi"\x7d'’.

   - bpo-28046(7): Remove platform-specific directories from sys.path.

   - bpo-28071(8): Add early-out for differencing from an empty set.

   - bpo-25758(9): Prevents zipimport from unnecessarily encoding a
     filename (patch by Eryk Sun)

   - bpo-25856(10): The __module__ attribute of extension classes and
     functions now is interned.  This leads to more compact pickle data
     with protocol 4.

   - bpo-27213(11): Rework CALL_FUNCTION* opcodes to produce shorter and
     more efficient bytecode.  Patch by Demur Rumed, design by Serhiy
     Storchaka, reviewed by Serhiy Storchaka and Victor Stinner.

   - bpo-26331(12): Implement tokenizing support for PEP 515(13).  Patch
     by Georg Brandl.

   - bpo-27999(14): Make "global after use" a SyntaxError, and ditto for
     nonlocal.  Patch by Ivan Levkivskyi.

   - bpo-28003(15): Implement PEP 525(16) - Asynchronous Generators.

   - bpo-27985(17): Implement PEP 526(18) - Syntax for Variable
     Annotations.  Patch by Ivan Levkivskyi.

   - bpo-26058(19): Add a new private version to the builtin dict type,
     incremented at each dictionary creation and at each dictionary
     change.  Implementation of the PEP 509.

   - bpo-27364(20): A backslash-character pair that is not a valid
     escape sequence now generates a DeprecationWarning.  Patch by
     Emanuel Barry.

   - bpo-27350(21): ‘dict’ implementation is changed like PyPy.  It is
     more compact and preserves insertion order.  (Concept developed by
     Raymond Hettinger and patch by Inada Naoki.)

   - bpo-27911(22): Remove unnecessary error checks in
     ‘exec_builtin_or_dynamic()’.

   - bpo-27078(23): Added BUILD_STRING opcode.  Optimized f-strings
     evaluation.

   - bpo-17884(24): Python now requires systems with inttypes.h and
     stdint.h

   - bpo-27961(25): Require platforms to support ‘long long’.  Python
     hasn't compiled without ‘long long’ for years, so this is basically
     a formality.

   - bpo-27355(26): Removed support for Windows CE. It was never
     finished, and Windows CE is no longer a relevant platform for
     Python.

   - Implement PEP 523(27).

   - bpo-27870(28): A left shift of zero by a large integer no longer
     attempts to allocate large amounts of memory.

   - bpo-25402(29): In int-to-decimal-string conversion, improve the
     estimate of the intermediate memory required, and remove an
     unnecessarily strict overflow check.  Patch by Serhiy Storchaka.

   - bpo-27214(30): In long_invert, be more careful about modifying
     object returned by long_add, and remove an unnecessary check for
     small longs.  Thanks Oren Milman for analysis and patch.

   - bpo-27506(31): Support passing the bytes/bytearray.translate()
     "delete" argument by keyword.

   - bpo-27812(32): Properly clear out a generator's frame's
     backreference to the generator to prevent crashes in frame.clear().

   - bpo-27811(33): Fix a crash when a coroutine that has not been
     awaited is finalized with warnings-as-errors enabled.

   - bpo-27587(34): Fix another issue found by PVS-Studio: Null pointer
     check after use of 'def' in _PyState_AddModule().  Initial patch by
     Christian Heimes.

   - bpo-27792(35): The modulo operation applied to ‘bool’ and other
     ‘int’ subclasses now always returns an ‘int’.  Previously the
     return type depended on the input values.  Patch by Xiang Zhang.

   - bpo-26984(36): int() now always returns an instance of exact int.

   - bpo-25604(37): Fix a minor bug in integer true division; this bug
     could potentially have caused off-by-one-ulp results on platforms
     with unreliable ldexp implementations.

   - bpo-24254(38): Make class definition namespace ordered by default.

   - bpo-27662(39): Fix an overflow check in ‘List_New’: the original
     code was checking against ‘Py_SIZE_MAX’ instead of the correct
     upper bound of ‘Py_SSIZE_T_MAX’.  Patch by Xiang Zhang.

   - bpo-27782(40): Multi-phase extension module import now correctly
     allows the ‘m_methods’ field to be used to add module level
     functions to instances of non-module types returned from
     ‘Py_create_mod’.  Patch by Xiang Zhang.

   - bpo-27936(41): The round() function accepted a second None argument
     for some types but not for others.  Fixed the inconsistency by
     accepting None for all numeric types.

   - bpo-27487(42): Warn if a submodule argument to "python -m" or
     runpy.run_module() is found in sys.modules after parent packages
     are imported, but before the submodule is executed.

   - bpo-27157(43): Make only type() itself accept the one-argument
     form.  Patch by Eryk Sun and Emanuel Barry.

   - bpo-27558(44): Fix a SystemError in the implementation of "raise"
     statement.  In a brand new thread, raise a RuntimeError since there
     is no active exception to reraise.  Patch written by Xiang Zhang.

   - bpo-28008(45): Implement PEP 530(46) - asynchronous comprehensions.

   - bpo-27942(47): Fix memory leak in codeobject.c

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23722

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25221

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27080

   (4) https://peps.python.org/pep-0515/

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27199

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27948

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28046

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28071

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25758

   (10) https://bugs.python.org/issue?@action=redirect&bpo=25856

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27213

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26331

   (13) https://peps.python.org/pep-0515/

   (14) https://bugs.python.org/issue?@action=redirect&bpo=27999

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28003

   (16) https://peps.python.org/pep-0525/

   (17) https://bugs.python.org/issue?@action=redirect&bpo=27985

   (18) https://peps.python.org/pep-0526/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26058

   (20) https://bugs.python.org/issue?@action=redirect&bpo=27364

   (21) https://bugs.python.org/issue?@action=redirect&bpo=27350

   (22) https://bugs.python.org/issue?@action=redirect&bpo=27911

   (23) https://bugs.python.org/issue?@action=redirect&bpo=27078

   (24) https://bugs.python.org/issue?@action=redirect&bpo=17884

   (25) https://bugs.python.org/issue?@action=redirect&bpo=27961

   (26) https://bugs.python.org/issue?@action=redirect&bpo=27355

   (27) https://peps.python.org/pep-0523/

   (28) https://bugs.python.org/issue?@action=redirect&bpo=27870

   (29) https://bugs.python.org/issue?@action=redirect&bpo=25402

   (30) https://bugs.python.org/issue?@action=redirect&bpo=27214

   (31) https://bugs.python.org/issue?@action=redirect&bpo=27506

   (32) https://bugs.python.org/issue?@action=redirect&bpo=27812

   (33) https://bugs.python.org/issue?@action=redirect&bpo=27811

   (34) https://bugs.python.org/issue?@action=redirect&bpo=27587

   (35) https://bugs.python.org/issue?@action=redirect&bpo=27792

   (36) https://bugs.python.org/issue?@action=redirect&bpo=26984

   (37) https://bugs.python.org/issue?@action=redirect&bpo=25604

   (38) https://bugs.python.org/issue?@action=redirect&bpo=24254

   (39) https://bugs.python.org/issue?@action=redirect&bpo=27662

   (40) https://bugs.python.org/issue?@action=redirect&bpo=27782

   (41) https://bugs.python.org/issue?@action=redirect&bpo=27936

   (42) https://bugs.python.org/issue?@action=redirect&bpo=27487

   (43) https://bugs.python.org/issue?@action=redirect&bpo=27157

   (44) https://bugs.python.org/issue?@action=redirect&bpo=27558

   (45) https://bugs.python.org/issue?@action=redirect&bpo=28008

   (46) https://peps.python.org/pep-0530/

   (47) https://bugs.python.org/issue?@action=redirect&bpo=27942


File: python.info,  Node: Library<73>,  Next: IDLE<52>,  Prev: Core and Builtins<74>,  Up: Python 3 6 0 beta 1

1.23.82.2 Library
.................

   - bpo-28732(1): Fix crash in os.spawnv() with no elements in args

   - bpo-28485(2): Always raise ValueError for negative
     compileall.compile_dir(workers=...)  parameter, even when
     multithreading is unavailable.

   - bpo-28037(3): Use sqlite3_get_autocommit() instead of setting
     Connection->inTransaction manually.

   - bpo-25283(4): Attributes tm_gmtoff and tm_zone are now available on
     all platforms in the return values of time.localtime() and
     time.gmtime().

   - bpo-24454(5): Regular expression match object groups are now
     accessible using __getitem__.  "mo[x]" is equivalent to
     "mo.group(x)".

   - bpo-10740(6): sqlite3 no longer implicitly commit an open
     transaction before DDL statements.

   - bpo-17941(7): Add a 'module' parameter to collections.namedtuple().

   - bpo-22493(8): Inline flags now should be used only at the start of
     the regular expression.  Deprecation warning is emitted if uses
     them in the middle of the regular expression.

   - bpo-26885(9): xmlrpc now supports unmarshalling additional data
     types used by Apache XML-RPC implementation for numerics and None.

   - bpo-28070(10): Fixed parsing inline verbose flag in regular
     expressions.

   - bpo-19500(11): Add client-side SSL session resumption to the ssl
     module.

   - bpo-28022(12): Deprecate ssl-related arguments in favor of
     SSLContext.  The deprecation include manual creation of SSLSocket
     and certfile/keyfile (or similar) in ftplib, httplib, imaplib,
     smtplib, poplib and urllib.

   - bpo-28043(13): SSLContext has improved default settings:
     OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_COMPRESSION,
     OP_CIPHER_SERVER_PREFERENCE, OP_SINGLE_DH_USE, OP_SINGLE_ECDH_USE
     and HIGH ciphers without MD5.

   - bpo-24693(14): Changed some RuntimeError's in the zipfile module to
     more appropriate types.  Improved some error messages and debugging
     output.

   - bpo-17909(15): ‘json.load’ and ‘json.loads’ now support binary
     input encoded as UTF-8, UTF-16 or UTF-32.  Patch by Serhiy
     Storchaka.

   - bpo-27137(16): the pure Python fallback implementation of
     ‘functools.partial’ now matches the behaviour of its accelerated C
     counterpart for subclassing, pickling and text representation
     purposes.  Patch by Emanuel Barry and Serhiy Storchaka.

   - Fix possible integer overflows and crashes in the mmap module with
     unusual usage patterns.

   - bpo-1703178(17): Fix the ability to pass the -link-objects option
     to the distutils build_ext command.

   - bpo-28019(18): itertools.count() no longer rounds non-integer step
     in range between 1.0 and 2.0 to 1.

   - bpo-18401(19): Pdb now supports the 'readrc' keyword argument to
     control whether .pdbrc files should be read.  Patch by Martin
     Matusiak and Sam Kimbrel.

   - bpo-25969(20): Update the lib2to3 grammar to handle the unpacking
     generalizations added in 3.5.

   - bpo-14977(21): mailcap now respects the order of the lines in the
     mailcap files ("first match"), as required by RFC 1542.  Patch by
     Michael Lazar.

   - bpo-28082(22): Convert re flag constants to IntFlag.

   - bpo-28025(23): Convert all ssl module constants to IntEnum and
     IntFlags.  SSLContext properties now return flags and enums.

   - bpo-23591(24): Add Flag, IntFlag, and auto() to enum module.

   - bpo-433028(25): Added support of modifier spans in regular
     expressions.

   - bpo-24594(26): Validates persist parameter when opening MSI
     database

   - bpo-17582(27): xml.etree.ElementTree nows preserves whitespaces in
     attributes (Patch by Duane Griffin.  Reviewed and approved by
     Stefan Behnel.)

   - bpo-28047(28): Fixed calculation of line length used for the base64
     CTE in the new email policies.

   - bpo-27576(29): Fix call order in OrderedDict.__init__().

   - email.generator.DecodedGenerator now supports the policy keyword.

   - bpo-28027(30): Remove undocumented modules from ‘Lib/plat-*’: IN,
     CDROM, DLFCN, TYPES, CDIO, and STROPTS.

   - bpo-27445(31): Don't pass str(_charset) to MIMEText.set_payload().
     Patch by Claude Paroz.

   - bpo-24277(32): The new email API is no longer provisional, and the
     docs have been reorganized and rewritten to emphasize the new API.

   - bpo-22450(33): urllib now includes an ‘Accept: */*’ header among
     the default headers.  This makes the results of REST API requests
     more consistent and predictable especially when proxy servers are
     involved.

   - lib2to3.pgen3.driver.load_grammar() now creates a stable cache file
     between runs given the same Grammar.txt input regardless of the
     hash randomization setting.

   - bpo-28005(34): Allow ImportErrors in encoding implementation to
     propagate.

   - bpo-26667(35): Support path-like objects in importlib.util.

   - bpo-27570(36): Avoid zero-length memcpy() etc calls with null
     source pointers in the "ctypes" and "array" modules.

   - bpo-22233(37): Break email header lines 'only' on the RFC specified
     CR and LF characters, not on arbitrary unicode line breaks.  This
     also fixes a bug in HTTP header parsing.

   - bpo-27331(38): The email.mime classes now all accept an optional
     policy keyword.

   - bpo-27988(39): Fix email iter_attachments incorrect mutation of
     payload list.

   - bpo-16113(40): Add SHA-3 and SHAKE support to hashlib module.

   - Eliminate a tautological-pointer-compare warning in _scproxy.c.

   - bpo-27776(41): The *note os.urandom(): 4ec. function does now block
     on Linux 3.17 and newer until the system urandom entropy pool is
     initialized to increase the security.  This change is part of the
     PEP 524(42).

   - bpo-27778(43): Expose the Linux ‘getrandom()’ syscall as a new
     *note os.getrandom(): c8b. function.  This change is part of the
     PEP 524(44).

   - bpo-27691(45): Fix ssl module's parsing of GEN_RID subject
     alternative name fields in X.509 certs.

   - bpo-18844(46): Add random.choices().

   - bpo-25761(47): Improved error reporting about truncated pickle data
     in C implementation of unpickler.  UnpicklingError is now raised
     instead of AttributeError and ValueError in some cases.

   - bpo-26798(48): Add BLAKE2 (blake2b and blake2s) to hashlib.

   - bpo-26032(49): Optimized globbing in pathlib by using os.scandir();
     it is now about 1.5-4 times faster.

   - bpo-25596(50): Optimized glob() and iglob() functions in the glob
     module; they are now about 3-6 times faster.

   - bpo-27928(51): Add scrypt (password-based key derivation function)
     to hashlib module (requires OpenSSL 1.1.0).

   - bpo-27850(52): Remove 3DES from ssl module's default cipher list to
     counter measure sweet32 attack ( CVE 2016-2183(53)).

   - bpo-27766(54): Add ChaCha20 Poly1305 to ssl module's default cipher
     list.  (Required OpenSSL 1.1.0 or LibreSSL).

   - bpo-25387(55): Check return value of winsound.MessageBeep.

   - bpo-27866(56): Add SSLContext.get_ciphers() method to get a list of
     all enabled ciphers.

   - bpo-27744(57): Add AF_ALG (Linux Kernel crypto) to socket module.

   - bpo-26470(58): Port ssl and hashlib module to OpenSSL 1.1.0.

   - bpo-11620(59): Fix support for SND_MEMORY in winsound.PlaySound.
     Based on a patch by Tim Lesher.

   - bpo-11734(60): Add support for IEEE 754 half-precision floats to
     the struct module.  Based on a patch by Eli Stevens.

   - bpo-27919(61): Deprecated ‘extra_path’ distribution option in
     distutils packaging.

   - bpo-23229(62): Add new ‘cmath’ constants: ‘cmath.inf’ and
     ‘cmath.nan’ to match ‘math.inf’ and ‘math.nan’, and also
     ‘cmath.infj’ and ‘cmath.nanj’ to match the format used by complex
     repr.

   - bpo-27842(63): The csv.DictReader now returns rows of type
     OrderedDict.  (Contributed by Steve Holden.)

   - Remove support for passing a file descriptor to os.access.  It
     never worked but previously didn't raise.

   - bpo-12885(64): Fix error when distutils encounters symlink.

   - bpo-27881(65): Fixed possible bugs when setting
     sqlite3.Connection.isolation_level.  Based on patch by Xiang Zhang.

   - bpo-27861(66): Fixed a crash in sqlite3.Connection.cursor() when a
     factory creates not a cursor.  Patch by Xiang Zhang.

   - bpo-19884(67): Avoid spurious output on OS X with Gnu Readline.

   - bpo-27706(68): Restore deterministic behavior of
     random.Random().seed() for string seeds using seeding version 1.
     Allows sequences of calls to random() to exactly match those
     obtained in Python 2.  Patch by Nofar Schnider.

   - bpo-10513(69): Fix a regression in Connection.commit().  Statements
     should not be reset after a commit.

   - bpo-12319(70): Chunked transfer encoding support added to
     http.client.HTTPConnection requests.  The
     urllib.request.AbstractHTTPHandler class does not enforce a
     Content-Length header any more.  If a HTTP request has a file or
     iterable body, but no Content-Length header, the library now falls
     back to use chunked transfer-encoding.

   - A new version of typing.py from ‘https://github.com/python/typing’:
     - Collection (only for 3.6) (bpo-27598(71)) - Add FrozenSet to
     __all__ (upstream #261) - fix crash in _get_type_vars() (upstream
     #259) - Remove the dict constraint in ForwardRef._eval_type
     (upstream #252)

   - bpo-27832(72): Make ‘_normalize’ parameter to ‘Fraction’
     constructor keyword-only, so that ‘Fraction(2, 3, 4)’ now raises
     ‘TypeError’.

   - bpo-27539(73): Fix unnormalised ‘Fraction.__pow__’ result in the
     case of negative exponent and negative base.

   - bpo-21718(74): cursor.description is now available for queries
     using CTEs.

   - bpo-27819(75): In distutils sdists, simply produce the "gztar"
     (gzipped tar format) distributions on all platforms unless
     "formats" is supplied.

   - bpo-2466(76): posixpath.ismount now correctly recognizes mount
     points which the user does not have permission to access.

   - bpo-9998(77): On Linux, ctypes.util.find_library now looks in
     LD_LIBRARY_PATH for shared libraries.

   - bpo-27573(78): exit message for code.interact is now configurable.

   - bpo-27930(79): Improved behaviour of
     logging.handlers.QueueListener.  Thanks to Paulo Andrade and Petr
     Viktorin for the analysis and patch.

   - bpo-6766(80): Distributed reference counting added to
     multiprocessing to support nesting of shared values / proxy
     objects.

   - bpo-21201(81): Improves readability of multiprocessing error
     message.  Thanks to Wojciech Walczak for patch.

   - asyncio: Add set_protocol / get_protocol to Transports.

   - bpo-27456(82): asyncio: Set TCP_NODELAY by default.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28732

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28485

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28037

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25283

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24454

   (6) https://bugs.python.org/issue?@action=redirect&bpo=10740

   (7) https://bugs.python.org/issue?@action=redirect&bpo=17941

   (8) https://bugs.python.org/issue?@action=redirect&bpo=22493

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26885

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28070

   (11) https://bugs.python.org/issue?@action=redirect&bpo=19500

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28022

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28043

   (14) https://bugs.python.org/issue?@action=redirect&bpo=24693

   (15) https://bugs.python.org/issue?@action=redirect&bpo=17909

   (16) https://bugs.python.org/issue?@action=redirect&bpo=27137

   (17) https://bugs.python.org/issue?@action=redirect&bpo=1703178

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28019

   (19) https://bugs.python.org/issue?@action=redirect&bpo=18401

   (20) https://bugs.python.org/issue?@action=redirect&bpo=25969

   (21) https://bugs.python.org/issue?@action=redirect&bpo=14977

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28082

   (23) https://bugs.python.org/issue?@action=redirect&bpo=28025

   (24) https://bugs.python.org/issue?@action=redirect&bpo=23591

   (25) https://bugs.python.org/issue?@action=redirect&bpo=433028

   (26) https://bugs.python.org/issue?@action=redirect&bpo=24594

   (27) https://bugs.python.org/issue?@action=redirect&bpo=17582

   (28) https://bugs.python.org/issue?@action=redirect&bpo=28047

   (29) https://bugs.python.org/issue?@action=redirect&bpo=27576

   (30) https://bugs.python.org/issue?@action=redirect&bpo=28027

   (31) https://bugs.python.org/issue?@action=redirect&bpo=27445

   (32) https://bugs.python.org/issue?@action=redirect&bpo=24277

   (33) https://bugs.python.org/issue?@action=redirect&bpo=22450

   (34) https://bugs.python.org/issue?@action=redirect&bpo=28005

   (35) https://bugs.python.org/issue?@action=redirect&bpo=26667

   (36) https://bugs.python.org/issue?@action=redirect&bpo=27570

   (37) https://bugs.python.org/issue?@action=redirect&bpo=22233

   (38) https://bugs.python.org/issue?@action=redirect&bpo=27331

   (39) https://bugs.python.org/issue?@action=redirect&bpo=27988

   (40) https://bugs.python.org/issue?@action=redirect&bpo=16113

   (41) https://bugs.python.org/issue?@action=redirect&bpo=27776

   (42) https://peps.python.org/pep-0524/

   (43) https://bugs.python.org/issue?@action=redirect&bpo=27778

   (44) https://peps.python.org/pep-0524/

   (45) https://bugs.python.org/issue?@action=redirect&bpo=27691

   (46) https://bugs.python.org/issue?@action=redirect&bpo=18844

   (47) https://bugs.python.org/issue?@action=redirect&bpo=25761

   (48) https://bugs.python.org/issue?@action=redirect&bpo=26798

   (49) https://bugs.python.org/issue?@action=redirect&bpo=26032

   (50) https://bugs.python.org/issue?@action=redirect&bpo=25596

   (51) https://bugs.python.org/issue?@action=redirect&bpo=27928

   (52) https://bugs.python.org/issue?@action=redirect&bpo=27850

   (53) https://www.cve.org/CVERecord?id=CVE-2016-2183

   (54) https://bugs.python.org/issue?@action=redirect&bpo=27766

   (55) https://bugs.python.org/issue?@action=redirect&bpo=25387

   (56) https://bugs.python.org/issue?@action=redirect&bpo=27866

   (57) https://bugs.python.org/issue?@action=redirect&bpo=27744

   (58) https://bugs.python.org/issue?@action=redirect&bpo=26470

   (59) https://bugs.python.org/issue?@action=redirect&bpo=11620

   (60) https://bugs.python.org/issue?@action=redirect&bpo=11734

   (61) https://bugs.python.org/issue?@action=redirect&bpo=27919

   (62) https://bugs.python.org/issue?@action=redirect&bpo=23229

   (63) https://bugs.python.org/issue?@action=redirect&bpo=27842

   (64) https://bugs.python.org/issue?@action=redirect&bpo=12885

   (65) https://bugs.python.org/issue?@action=redirect&bpo=27881

   (66) https://bugs.python.org/issue?@action=redirect&bpo=27861

   (67) https://bugs.python.org/issue?@action=redirect&bpo=19884

   (68) https://bugs.python.org/issue?@action=redirect&bpo=27706

   (69) https://bugs.python.org/issue?@action=redirect&bpo=10513

   (70) https://bugs.python.org/issue?@action=redirect&bpo=12319

   (71) https://bugs.python.org/issue?@action=redirect&bpo=27598

   (72) https://bugs.python.org/issue?@action=redirect&bpo=27832

   (73) https://bugs.python.org/issue?@action=redirect&bpo=27539

   (74) https://bugs.python.org/issue?@action=redirect&bpo=21718

   (75) https://bugs.python.org/issue?@action=redirect&bpo=27819

   (76) https://bugs.python.org/issue?@action=redirect&bpo=2466

   (77) https://bugs.python.org/issue?@action=redirect&bpo=9998

   (78) https://bugs.python.org/issue?@action=redirect&bpo=27573

   (79) https://bugs.python.org/issue?@action=redirect&bpo=27930

   (80) https://bugs.python.org/issue?@action=redirect&bpo=6766

   (81) https://bugs.python.org/issue?@action=redirect&bpo=21201

   (82) https://bugs.python.org/issue?@action=redirect&bpo=27456


File: python.info,  Node: IDLE<52>,  Next: C API<63>,  Prev: Library<73>,  Up: Python 3 6 0 beta 1

1.23.82.3 IDLE
..............

   - bpo-15308(1): Add 'interrupt execution' (^C) to Shell menu.  Patch
     by Roger Serwy, updated by Bayard Randel.

   - bpo-27922(2): Stop IDLE tests from 'flashing' gui widgets on the
     screen.

   - bpo-27891(3): Consistently group and sort imports within idlelib
     modules.

   - bpo-17642(4): add larger font sizes for classroom projection.

   - Add version to title of IDLE help window.

   - bpo-25564(5): In section on IDLE - console differences, mention
     that using exec means that __builtins__ is defined for each
     statement.

   - bpo-27821(6): Fix 3.6.0a3 regression that prevented custom key sets
     from being selected when no custom theme was defined.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15308

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27922

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27891

   (4) https://bugs.python.org/issue?@action=redirect&bpo=17642

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25564

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27821


File: python.info,  Node: C API<63>,  Next: Tests<66>,  Prev: IDLE<52>,  Up: Python 3 6 0 beta 1

1.23.82.4 C API
...............

   - bpo-26900(1): Excluded underscored names and other private API from
     limited API.

   - bpo-26027(2): Add support for path-like objects in
     PyUnicode_FSConverter() & PyUnicode_FSDecoder().

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26900

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26027


File: python.info,  Node: Tests<66>,  Next: Build<72>,  Prev: C API<63>,  Up: Python 3 6 0 beta 1

1.23.82.5 Tests
...............

   - bpo-27427(1): Additional tests for the math module.  Patch by
     Francisco Couzo.

   - bpo-27953(2): Skip math and cmath tests that fail on OS X 10.4 due
     to a poor libm implementation of tan.

   - bpo-26040(3): Improve test_math and test_cmath coverage and rigour.
     Patch by Jeff Allen.

   - bpo-27787(4): Call gc.collect() before checking each test for
     "dangling threads", since the dangling threads are weak references.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27427

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27953

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26040

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27787


File: python.info,  Node: Build<72>,  Next: Tools/Demos<38>,  Prev: Tests<66>,  Up: Python 3 6 0 beta 1

1.23.82.6 Build
...............

   - bpo-27566(1): Fix clean target in freeze makefile (patch by Lisa
     Roach)

   - bpo-27705(2): Update message in validate_ucrtbase.py

   - bpo-27976(3): Deprecate building _ctypes with the bundled copy of
     libffi on non-OSX UNIX platforms.

   - bpo-27983(4): Cause lack of llvm-profdata tool when using clang as
     required for PGO linking to be a configure time error rather than
     make time when ‘--with-optimizations’ is enabled.  Also improve our
     ability to find the llvm-profdata tool on MacOS and some Linuxes.

   - bpo-21590(5): Support for DTrace and SystemTap probes.

   - bpo-26307(6): The profile-opt build now applies PGO to the built-in
     modules.

   - bpo-26359(7): Add the -with-optimizations flag to turn on LTO and
     PGO build support when available.

   - bpo-27917(8): Set platform triplets for Android builds.

   - bpo-25825(9): Update references to the $(LIBPL) installation path
     on AIX. This path was changed in 3.2a4.

   - Update OS X installer to use SQLite 3.14.1 and XZ 5.2.2.

   - bpo-21122(10): Fix LTO builds on OS X.

   - bpo-17128(11): Build OS X installer with a private copy of OpenSSL.
     Also provide a sample Install Certificates command script to
     install a set of root certificates from the third-party certifi
     module.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27566

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27705

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27976

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27983

   (5) https://bugs.python.org/issue?@action=redirect&bpo=21590

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26307

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26359

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27917

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25825

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21122

   (11) https://bugs.python.org/issue?@action=redirect&bpo=17128


File: python.info,  Node: Tools/Demos<38>,  Next: Windows<63>,  Prev: Build<72>,  Up: Python 3 6 0 beta 1

1.23.82.7 Tools/Demos
.....................

   - bpo-27952(1): Get Tools/scripts/fixcid.py working with Python 3 and
     the current "re" module, avoid invalid Python backslash escapes,
     and fix a bug parsing escaped C quote signs.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27952


File: python.info,  Node: Windows<63>,  Prev: Tools/Demos<38>,  Up: Python 3 6 0 beta 1

1.23.82.8 Windows
.................

   - bpo-28065(1): Update xz dependency to 5.2.2 and build it from
     source.

   - bpo-25144(2): Ensures TargetDir is set before continuing with
     custom install.

   - bpo-1602(3): Windows console doesn't input or print Unicode (PEP
     528)

   - bpo-27781(4): Change file system encoding on Windows to UTF-8 (PEP
     529)

   - bpo-27731(5): Opt-out of MAX_PATH on Windows 10

   - bpo-6135(6): Adds encoding and errors parameters to subprocess.

   - bpo-27959(7): Adds oem encoding, alias ansi to mbcs, move aliasmbcs
     to codec lookup.

   - bpo-27982(8): The functions of the winsound module now accept
     keyword arguments.

   - bpo-20366(9): Build full text search support into SQLite on
     Windows.

   - bpo-27756(10): Adds new icons for Python files and processes on
     Windows.  Designs by Cherry Wang.

   - bpo-27883(11): Update sqlite to 3.14.1.0 on Windows.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28065

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25144

   (3) https://bugs.python.org/issue?@action=redirect&bpo=1602

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27781

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27731

   (6) https://bugs.python.org/issue?@action=redirect&bpo=6135

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27959

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27982

   (9) https://bugs.python.org/issue?@action=redirect&bpo=20366

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27756

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27883


File: python.info,  Node: Python 3 6 0 alpha 4,  Next: Python 3 6 0 alpha 3,  Prev: Python 3 6 0 beta 1,  Up: 変更履歴

1.23.83 Python 3.6.0 alpha 4
----------------------------

'Release date: 2016-08-15'

* Menu:

* Core and Builtins: Core and Builtins<75>.
* Library: Library<74>.
* IDLE: IDLE<53>.
* Tests: Tests<67>.
* Windows: Windows<64>.
* Build: Build<73>.


File: python.info,  Node: Core and Builtins<75>,  Next: Library<74>,  Up: Python 3 6 0 alpha 4

1.23.83.1 Core and Builtins
...........................

   - bpo-27704(1): Optimized creating bytes and bytearray from byte-like
     objects and iterables.  Speed up to 3 times for short objects.
     Original patch by Naoki Inada.

   - bpo-26823(2): Large sections of repeated lines in tracebacks are
     now abbreviated as "[Previous line repeated {count} more times]" by
     the builtin traceback rendering.  Patch by Emanuel Barry.

   - bpo-27574(3): Decreased an overhead of parsing keyword arguments in
     functions implemented with using Argument Clinic.

   - bpo-22557(4): Now importing already imported modules is up to 2.5
     times faster.

   - bpo-17596(5): Include <wincrypt.h> to help with Min GW building.

   - bpo-17599(6): On Windows, rename the privately defined
     REPARSE_DATA_BUFFER structure to avoid conflicting with the
     definition from Min GW.

   - bpo-27507(7): Add integer overflow check in bytearray.extend().
     Patch by Xiang Zhang.

   - bpo-27581(8): Don't rely on wrapping for overflow check in
     PySequence_Tuple().  Patch by Xiang Zhang.

   - bpo-1621(9): Avoid signed integer overflow in list and tuple
     operations.  Patch by Xiang Zhang.

   - bpo-27419(10): Standard __import__() no longer look up "__import__"
     in globals or builtins for importing submodules or "from import".
     Fixed a crash if raise a warning about unabling to resolve package
     from __spec__ or __package__.

   - bpo-27083(11): Respect the PYTHONCASEOK environment variable under
     Windows.

   - bpo-27514(12): Make having too many statically nested blocks a
     SyntaxError instead of SystemError.

   - bpo-27366(13): Implemented PEP 487(14) (Simpler customization of
     class creation).  Upon subclassing, the __init_subclass__
     classmethod is called on the base class.  Descriptors are
     initialized with __set_name__ after class creation.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27704

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26823

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27574

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22557

   (5) https://bugs.python.org/issue?@action=redirect&bpo=17596

   (6) https://bugs.python.org/issue?@action=redirect&bpo=17599

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27507

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27581

   (9) https://bugs.python.org/issue?@action=redirect&bpo=1621

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27419

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27083

   (12) https://bugs.python.org/issue?@action=redirect&bpo=27514

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27366

   (14) https://peps.python.org/pep-0487/


File: python.info,  Node: Library<74>,  Next: IDLE<53>,  Prev: Core and Builtins<75>,  Up: Python 3 6 0 alpha 4

1.23.83.2 Library
.................

   - bpo-26027(1): Add PEP 519(2)/__fspath__() support to the os and
     os.path modules.  Includes code from Jelle Zijlstra.  (See also:
     bpo-27524(3))

   - bpo-27598(4): Add Collections to collections.abc.  Patch by Ivan
     Levkivskyi, docs by Neil Girdhar.

   - bpo-25958(5): Support "anti-registration" of special methods from
     various ABCs, like __hash__, __iter__ or __len__.  All these (and
     several more) can be set to None in an implementation class and the
     behavior will be as if the method is not defined at all.
     (Previously, this mechanism existed only for __hash__, to make
     mutable classes unhashable.)  Code contributed by Andrew Barnert
     and Ivan Levkivskyi.

   - bpo-16764(6): Support keyword arguments to zlib.decompress().
     Patch by Xiang Zhang.

   - bpo-27736(7): Prevent segfault after interpreter re-initialization
     due to ref count problem introduced in code for bpo-27038(8) in
     3.6.0a3.  Patch by Xiang Zhang.

   - bpo-25628(9): The 'verbose' and 'rename' parameters for
     collections.namedtuple are now keyword-only.

   - bpo-12345(10): Add mathematical constant tau to math and cmath.
     See also PEP 628(11).

   - bpo-26823(12): traceback.StackSummary.format now abbreviates large
     sections of repeated lines as "[Previous line repeated {count} more
     times]" (this change then further affects other traceback display
     operations in the module).  Patch by Emanuel Barry.

   - bpo-27664(13): Add to
     concurrent.futures.thread.ThreadPoolExecutor() the ability to
     specify a thread name prefix.

   - bpo-27181(14): Add geometric_mean and harmonic_mean to statistics
     module.

   - bpo-27573(15): code.interact now prints an message when exiting.

   - bpo-6422(16): Add autorange method to timeit.Timer objects.

   - bpo-27773(17): Correct some memory management errors
     server_hostname in _ssl.wrap_socket().

   - bpo-26750(18): unittest.mock.create_autospec() now works properly
     for subclasses of property() and other data descriptors.  Removes
     the never publicly used, never documented
     unittest.mock.DescriptorTypes tuple.

   - bpo-26754(19): Undocumented support of general bytes-like objects
     as path in compile() and similar functions is now deprecated.

   - bpo-26800(20): Undocumented support of general bytes-like objects
     as paths in os functions is now deprecated.

   - bpo-26981(21): Add _order_ compatibility shim to enum.Enum for
     Python 2/3 code bases.

   - bpo-27661(22): Added tzinfo keyword argument to datetime.combine.

   - In the curses module, raise an error if window.getstr() or
     window.instr() is passed a negative value.

   - bpo-27783(23): Fix possible usage of uninitialized memory in
     operator.methodcaller.

   - bpo-27774(24): Fix possible Py_DECREF on unowned object in _sre.

   - bpo-27760(25): Fix possible integer overflow in binascii.b2a_qp.

   - bpo-27758(26): Fix possible integer overflow in the _csv module for
     large record lengths.

   - bpo-27568(27): Prevent HTTPoxy attack ( CVE 2016-1000110(28)).
     Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is
     set, which indicates that the script is in CGI mode.

   - bpo-7063(29): Remove dead code from the "array" module's slice
     handling.  Patch by Chuck.

   - bpo-27656(30): Do not assume sched.h defines any SCHED_* constants.

   - bpo-27130(31): In the "zlib" module, fix handling of large buffers
     (typically 4 GiB) when compressing and decompressing.  Previously,
     inputs were limited to 4 GiB, and compression and decompression
     operations did not properly handle results of 4 GiB.

   - bpo-24773(32): Implemented PEP 495(33) (Local Time Disambiguation).

   - Expose the EPOLLEXCLUSIVE constant (when it is defined) in the
     select module.

   - bpo-27567(34): Expose the EPOLLRDHUP and POLLRDHUP constants in the
     select module.

   - bpo-1621(35): Avoid signed int negation overflow in the "audioop"
     module.

   - bpo-27533(36): Release GIL in nt._isdir

   - bpo-17711(37): Fixed unpickling by the persistent ID with protocol
     0.  Original patch by Alexandre Vassalotti.

   - bpo-27522(38): Avoid an unintentional reference cycle in
     email.feedparser.

   - bpo-27512(39): Fix a segfault when os.fspath() called an
     __fspath__() method that raised an exception.  Patch by Xiang
     Zhang.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26027

   (2) https://peps.python.org/pep-0519/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27524

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27598

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25958

   (6) https://bugs.python.org/issue?@action=redirect&bpo=16764

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27736

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27038

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25628

   (10) https://bugs.python.org/issue?@action=redirect&bpo=12345

   (11) https://peps.python.org/pep-0628/

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26823

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27664

   (14) https://bugs.python.org/issue?@action=redirect&bpo=27181

   (15) https://bugs.python.org/issue?@action=redirect&bpo=27573

   (16) https://bugs.python.org/issue?@action=redirect&bpo=6422

   (17) https://bugs.python.org/issue?@action=redirect&bpo=27773

   (18) https://bugs.python.org/issue?@action=redirect&bpo=26750

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26754

   (20) https://bugs.python.org/issue?@action=redirect&bpo=26800

   (21) https://bugs.python.org/issue?@action=redirect&bpo=26981

   (22) https://bugs.python.org/issue?@action=redirect&bpo=27661

   (23) https://bugs.python.org/issue?@action=redirect&bpo=27783

   (24) https://bugs.python.org/issue?@action=redirect&bpo=27774

   (25) https://bugs.python.org/issue?@action=redirect&bpo=27760

   (26) https://bugs.python.org/issue?@action=redirect&bpo=27758

   (27) https://bugs.python.org/issue?@action=redirect&bpo=27568

   (28) https://www.cve.org/CVERecord?id=CVE-2016-1000110

   (29) https://bugs.python.org/issue?@action=redirect&bpo=7063

   (30) https://bugs.python.org/issue?@action=redirect&bpo=27656

   (31) https://bugs.python.org/issue?@action=redirect&bpo=27130

   (32) https://bugs.python.org/issue?@action=redirect&bpo=24773

   (33) https://peps.python.org/pep-0495/

   (34) https://bugs.python.org/issue?@action=redirect&bpo=27567

   (35) https://bugs.python.org/issue?@action=redirect&bpo=1621

   (36) https://bugs.python.org/issue?@action=redirect&bpo=27533

   (37) https://bugs.python.org/issue?@action=redirect&bpo=17711

   (38) https://bugs.python.org/issue?@action=redirect&bpo=27522

   (39) https://bugs.python.org/issue?@action=redirect&bpo=27512


File: python.info,  Node: IDLE<53>,  Next: Tests<67>,  Prev: Library<74>,  Up: Python 3 6 0 alpha 4

1.23.83.3 IDLE
..............

   - bpo-27714(1): text_textview and test_autocomplete now pass when
     re-run in the same process.  This occurs when test_idle fails when
     run with the -w option but without -jn.  Fix warning from
     test_config.

   - bpo-27621(2): Put query response validation error messages in the
     query box itself instead of in a separate messagebox.  Redo tests
     to match.  Add Mac OSX refinements.  Original patch by Mark
     Roseman.

   - bpo-27620(3): Escape key now closes Query box as cancelled.

   - bpo-27609(4): IDLE: tab after initial whitespace should tab, not
     autocomplete.  This fixes problem with writing docstrings at least
     twice indented.

   - bpo-27609(5): Explicitly return None when there are also non-None
     returns.  In a few cases, reverse a condition and eliminate a
     return.

   - bpo-25507(6): IDLE no longer runs buggy code because of its tkinter
     imports.  Users must include the same imports required to run
     directly in Python.

   - bpo-27173(7): Add 'IDLE Modern Unix' to the built-in key sets.
     Make the default key set depend on the platform.  Add tests for the
     changes to the config module.

   - bpo-27452(8): add line counter and crc to IDLE configHandler test
     dump.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27714

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27621

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27620

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27609

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27609

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25507

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27173

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27452


File: python.info,  Node: Tests<67>,  Next: Windows<64>,  Prev: IDLE<53>,  Up: Python 3 6 0 alpha 4

1.23.83.4 Tests
...............

   - bpo-25805(1): Skip a test in test_pkgutil as needed that doesn't
     work when ‘__name__ == __main__’.  Patch by SilentGhost.

   - bpo-27472(2): Add test.support.unix_shell as the path to the
     default shell.

   - bpo-27369(3): In test_pyexpat, avoid testing an error message
     detail that changed in Expat 2.2.0.

   - bpo-27594(4): Prevent assertion error when running test_ast with
     coverage enabled: ensure code object has a valid first line number.
     Patch suggested by Ivan Levkivskyi.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25805

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27472

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27369

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27594


File: python.info,  Node: Windows<64>,  Next: Build<73>,  Prev: Tests<67>,  Up: Python 3 6 0 alpha 4

1.23.83.5 Windows
.................

   - bpo-27647(1): Update bundled Tcl/Tk to 8.6.6.

   - bpo-27610(2): Adds PEP 514(3) metadata to Windows installer

   - bpo-27469(4): Adds a shell extension to the launcher so that drag
     and drop works correctly.

   - bpo-27309(5): Enables proper Windows styles in python[w].exe
     manifest.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27647

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27610

   (3) https://peps.python.org/pep-0514/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27469

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27309


File: python.info,  Node: Build<73>,  Prev: Windows<64>,  Up: Python 3 6 0 alpha 4

1.23.83.6 Build
...............

   - bpo-27713(1): Suppress spurious build warnings when updating
     importlib's bootstrap files.  Patch by Xiang Zhang

   - bpo-25825(2): Correct the references to Modules/python.exp, which
     is required on AIX. The references were accidentally changed in
     3.5.0a1.

   - bpo-27453(3): CPP invocation in configure must use CPPFLAGS. Patch
     by Chi Hsuan Yen.

   - bpo-27641(4): The configure script now inserts comments into the
     makefile to prevent the pgen and _freeze_importlib executables from
     being cross-compiled.

   - bpo-26662(5): Set PYTHON_FOR_GEN in configure as the Python program
     to be used for file generation during the build.

   - bpo-10910(6): Avoid C++ compilation errors on FreeBSD and OS X.
     Also update FreedBSD version checks for the original ctype UTF-8
     workaround.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27713

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25825

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27453

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27641

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26662

   (6) https://bugs.python.org/issue?@action=redirect&bpo=10910


File: python.info,  Node: Python 3 6 0 alpha 3,  Next: Python 3 6 0 alpha 2,  Prev: Python 3 6 0 alpha 4,  Up: 変更履歴

1.23.84 Python 3.6.0 alpha 3
----------------------------

'Release date: 2016-07-11'

* Menu:

* Security: Security<42>.
* Core and Builtins: Core and Builtins<76>.
* Library: Library<75>.
* IDLE: IDLE<54>.
* C API: C API<64>.
* Build: Build<74>.
* Tools/Demos: Tools/Demos<39>.
* Documentation: Documentation<64>.
* Tests: Tests<68>.


File: python.info,  Node: Security<42>,  Next: Core and Builtins<76>,  Up: Python 3 6 0 alpha 3

1.23.84.1 Security
..................

   - bpo-27278(1): Fix os.urandom() implementation using getrandom() on
     Linux.  Truncate size to INT_MAX and loop until we collected enough
     random bytes, instead of casting a directly Py_ssize_t to int.

   - bpo-22636(2): Avoid shell injection problems with
     ctypes.util.find_library().

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27278

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22636


File: python.info,  Node: Core and Builtins<76>,  Next: Library<75>,  Prev: Security<42>,  Up: Python 3 6 0 alpha 3

1.23.84.2 Core and Builtins
...........................

   - bpo-27473(1): Fixed possible integer overflow in bytes and
     bytearray concatenations.  Patch by Xiang Zhang.

   - bpo-23034(2): The output of a special Python build with defined
     COUNT_ALLOCS, SHOW_ALLOC_COUNT or SHOW_TRACK_COUNT macros is now
     off by default.  It can be re-enabled using the "-X showalloccount"
     option.  It now outputs to stderr instead of stdout.

   - bpo-27443(3): __length_hint__() of bytearray iterators no longer
     return a negative integer for a resized bytearray.

   - bpo-27007(4): The fromhex() class methods of bytes and bytearray
     subclasses now return an instance of corresponding subclass.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27473

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23034

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27443

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27007


File: python.info,  Node: Library<75>,  Next: IDLE<54>,  Prev: Core and Builtins<76>,  Up: Python 3 6 0 alpha 3

1.23.84.3 Library
.................

   - bpo-26844(1): Fix error message for imp.find_module() to refer to
     'path' instead of 'name'.  Patch by Lev Maximov.

   - bpo-23804(2): Fix SSL zero-length recv() calls to not block and not
     raise an error about unclean EOF.

   - bpo-27466(3): Change time format returned by
     http.cookie.time2netscape, confirming the netscape cookie format
     and making it consistent with documentation.

   - bpo-21708(4): Deprecated dbm.dumb behavior that differs from common
     dbm behavior: creating a database in 'r' and 'w' modes and
     modifying a database in 'r' mode.

   - bpo-26721(5): Change the socketserver.StreamRequestHandler.wfile
     attribute to implement BufferedIOBase.  In particular, the write()
     method no longer does partial writes.

   - bpo-22115(6): Added methods trace_add, trace_remove and trace_info
     in the tkinter.Variable class.  They replace old methods
     trace_variable, trace, trace_vdelete and trace_vinfo that use
     obsolete Tcl commands and might not work in future versions of Tcl.
     Fixed old tracing methods: trace_vdelete() with wrong mode no
     longer break tracing, trace_vinfo() now always returns a list of
     pairs of strings, tracing in the "u" mode now works.

   - bpo-26243(7): Only the level argument to zlib.compress() is keyword
     argument now.  The first argument is positional-only.

   - bpo-27038(8): Expose the DirEntry type as os.DirEntry.  Code patch
     by Jelle Zijlstra.

   - bpo-27186(9): Update os.fspath()/PyOS_FSPath() to check the return
     value of __fspath__() to be either str or bytes.

   - bpo-18726(10): All optional parameters of the dump(), dumps(),
     load() and loads() functions and JSONEncoder and JSONDecoder class
     constructors in the json module are now keyword-only.

   - bpo-27319(11): Methods selection_set(), selection_add(),
     selection_remove() and selection_toggle() of ttk.TreeView now allow
     passing multiple items as multiple arguments instead of passing
     them as a tuple.  Deprecated undocumented ability of calling the
     selection() method with arguments.

   - bpo-27079(12): Fixed curses.ascii functions isblank(), iscntrl()
     and ispunct().

   - bpo-27294(13): Numerical state in the repr for Tkinter event
     objects is now represented as a combination of known flags.

   - bpo-27177(14): Match objects in the re module now support
     index-like objects as group indices.  Based on patches by Jeroen
     Demeyer and Xiang Zhang.

   - bpo-26754(15): Some functions (compile() etc) accepted a filename
     argument encoded as an iterable of integers.  Now only strings and
     byte-like objects are accepted.

   - bpo-26536(16): socket.ioctl now supports SIO_LOOPBACK_FAST_PATH.
     Patch by Daniel Stokes.

   - bpo-27048(17): Prevents distutils failing on Windows when
     environment variables contain non-ASCII characters

   - bpo-27330(18): Fixed possible leaks in the ctypes module.

   - bpo-27238(19): Got rid of bare excepts in the turtle module.
     Original patch by Jelle Zijlstra.

   - bpo-27122(20): When an exception is raised within the context being
     managed by a contextlib.ExitStack() and one of the exit stack
     generators catches and raises it in a chain, do not re-raise the
     original exception when exiting, let the new chained one through.
     This avoids the PEP 479(21) bug described in issue25782.

   - bpo-16864(22): sqlite3.Cursor.lastrowid now supports REPLACE
     statement.  Initial patch by Alex LordThorsen.

   - bpo-26386(23): Fixed ttk.TreeView selection operations with item
     id's containing spaces.

   - bpo-8637(24): Honor a pager set by the env var MANPAGER (in
     preference to one set by the env var PAGER).

   - bpo-16182(25): Fix various functions in the "readline" module to
     use the locale encoding, and fix get_begidx() and get_endidx() to
     return code point indexes.

   - bpo-27392(26): Add loop.connect_accepted_socket().  Patch by Jim
     Fulton.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26844

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23804

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27466

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21708

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26721

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22115

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26243

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27038

   (9) https://bugs.python.org/issue?@action=redirect&bpo=27186

   (10) https://bugs.python.org/issue?@action=redirect&bpo=18726

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27319

   (12) https://bugs.python.org/issue?@action=redirect&bpo=27079

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27294

   (14) https://bugs.python.org/issue?@action=redirect&bpo=27177

   (15) https://bugs.python.org/issue?@action=redirect&bpo=26754

   (16) https://bugs.python.org/issue?@action=redirect&bpo=26536

   (17) https://bugs.python.org/issue?@action=redirect&bpo=27048

   (18) https://bugs.python.org/issue?@action=redirect&bpo=27330

   (19) https://bugs.python.org/issue?@action=redirect&bpo=27238

   (20) https://bugs.python.org/issue?@action=redirect&bpo=27122

   (21) https://peps.python.org/pep-0479/

   (22) https://bugs.python.org/issue?@action=redirect&bpo=16864

   (23) https://bugs.python.org/issue?@action=redirect&bpo=26386

   (24) https://bugs.python.org/issue?@action=redirect&bpo=8637

   (25) https://bugs.python.org/issue?@action=redirect&bpo=16182

   (26) https://bugs.python.org/issue?@action=redirect&bpo=27392


File: python.info,  Node: IDLE<54>,  Next: C API<64>,  Prev: Library<75>,  Up: Python 3 6 0 alpha 3

1.23.84.4 IDLE
..............

   - bpo-27477(1): IDLE search dialogs now use ttk widgets.

   - bpo-27173(2): Add 'IDLE Modern Unix' to the built-in key sets.
     Make the default key set depend on the platform.  Add tests for the
     changes to the config module.

   - bpo-27452(3): make command line "idle-test> python test_help.py"
     work.  __file__ is relative when python is started in the file's
     directory.

   - bpo-27452(4): add line counter and crc to IDLE configHandler test
     dump.

   - bpo-27380(5): IDLE: add query.py with base Query dialog and ttk
     widgets.  Module had subclasses SectionName, ModuleName, and
     HelpSource, which are used to get information from users by
     configdialog and file =>Load Module.  Each subclass has itw own
     validity checks.  Using ModuleName allows users to edit bad module
     names instead of starting over.  Add tests and delete the two files
     combined into the new one.

   - bpo-27372(6): Test_idle no longer changes the locale.

   - bpo-27365(7): Allow non-ascii chars in IDLE NEWS.txt, for
     contributor names.

   - bpo-27245(8): IDLE: Cleanly delete custom themes and key bindings.
     Previously, when IDLE was started from a console or by import, a
     cascade of warnings was emitted.  Patch by Serhiy Storchaka.

   - bpo-24137(9): Run IDLE, test_idle, and htest with tkinter default
     root disabled.  Fix code and tests that fail with this restriction.
     Fix htests to not create a second and redundant root and mainloop.

   - bpo-27310(10): Fix IDLE.app failure to launch on OS X due to
     vestigial import.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27477

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27173

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27452

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27452

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27380

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27372

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27365

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27245

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24137

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27310


File: python.info,  Node: C API<64>,  Next: Build<74>,  Prev: IDLE<54>,  Up: Python 3 6 0 alpha 3

1.23.84.5 C API
...............

   - bpo-26754(1): PyUnicode_FSDecoder() accepted a filename argument
     encoded as an iterable of integers.  Now only strings and byte-like
     objects are accepted.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26754


File: python.info,  Node: Build<74>,  Next: Tools/Demos<39>,  Prev: C API<64>,  Up: Python 3 6 0 alpha 3

1.23.84.6 Build
...............

   - bpo-28066(1): Fix the logic that searches build directories for
     generated include files when building outside the source tree.

   - bpo-27442(2): Expose the Android API level that python was built
     against, in sysconfig.get_config_vars() as 'ANDROID_API_LEVEL'.

   - bpo-27434(3): The interpreter that runs the cross-build, found in
     PATH, must now be of the same feature version (e.g.  3.6) as the
     source being built.

   - bpo-26930(4): Update Windows builds to use OpenSSL 1.0.2h.

   - bpo-23968(5): Rename the platform directory from plat-$(MACHDEP) to
     plat-$(PLATFORM_TRIPLET). Rename the config directory (LIBPL) from
     config-$(LDVERSION) to config-$(LDVERSION)-$(PLATFORM_TRIPLET).
     Install the platform specific _sysconfigdata module into the
     platform directory and rename it to include the ABIFLAGS.

   - Don't use largefile support for GNU/Hurd.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28066

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27442

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27434

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26930

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23968


File: python.info,  Node: Tools/Demos<39>,  Next: Documentation<64>,  Prev: Build<74>,  Up: Python 3 6 0 alpha 3

1.23.84.7 Tools/Demos
.....................

   - bpo-27332(1): Fixed the type of the first argument of module-level
     functions generated by Argument Clinic.  Patch by Petr Viktorin.

   - bpo-27418(2): Fixed Tools/importbench/importbench.py.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27332

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27418


File: python.info,  Node: Documentation<64>,  Next: Tests<68>,  Prev: Tools/Demos<39>,  Up: Python 3 6 0 alpha 3

1.23.84.8 Documentation
.......................

   - bpo-19489(1): Moved the search box from the sidebar to the header
     and footer of each page.  Patch by Ammar Askar.

   - bpo-27285(2): Update documentation to reflect the deprecation of
     ‘pyvenv’ and normalize on the term "virtual environment".  Patch by
     Steve Piercy.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19489

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27285


File: python.info,  Node: Tests<68>,  Prev: Documentation<64>,  Up: Python 3 6 0 alpha 3

1.23.84.9 Tests
...............

   - bpo-27027(1): Added test.support.is_android that is True when this
     is an Android build.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27027


File: python.info,  Node: Python 3 6 0 alpha 2,  Next: Python 3 6 0 alpha 1,  Prev: Python 3 6 0 alpha 3,  Up: 変更履歴

1.23.85 Python 3.6.0 alpha 2
----------------------------

'Release date: 2016-06-13'

* Menu:

* Security: Security<43>.
* Core and Builtins: Core and Builtins<77>.
* Library: Library<76>.
* IDLE: IDLE<55>.
* Documentation: Documentation<65>.
* Tests: Tests<69>.
* Windows: Windows<65>.
* Build: Build<75>.
* C API: C API<65>.
* Tools/Demos: Tools/Demos<40>.


File: python.info,  Node: Security<43>,  Next: Core and Builtins<77>,  Up: Python 3 6 0 alpha 2

1.23.85.1 Security
..................

   - bpo-26556(1): Update expat to 2.1.1, fixes CVE 2015-1283(2).

   - Fix TLS stripping vulnerability in smtplib, CVE 2016-0772(3).
     Reported by Team Oststrom.

   - bpo-26839(4): On Linux, *note os.urandom(): 4ec. now calls
     ‘getrandom()’ with ‘GRND_NONBLOCK’ to fall back on reading
     ‘/dev/urandom’ if the urandom entropy pool is not initialized yet.
     Patch written by Colm Buckley.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26556

   (2) https://www.cve.org/CVERecord?id=CVE-2015-1283

   (3) https://www.cve.org/CVERecord?id=CVE-2016-0772

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26839


File: python.info,  Node: Core and Builtins<77>,  Next: Library<76>,  Prev: Security<43>,  Up: Python 3 6 0 alpha 2

1.23.85.2 Core and Builtins
...........................

   - bpo-27095(1): Simplified MAKE_FUNCTION and removed MAKE_CLOSURE
     opcodes.  Patch by Demur Rumed.

   - bpo-27190(2): Raise NotSupportedError if sqlite3 is older than
     3.3.1.  Patch by Dave Sawyer.

   - bpo-27286(3): Fixed compiling BUILD_MAP_UNPACK_WITH_CALL opcode.
     Calling function with generalized unpacking (PEP 448) and
     conflicting keyword names could cause undefined behavior.

   - bpo-27140(4): Added BUILD_CONST_KEY_MAP opcode.

   - bpo-27186(5): Add support for os.PathLike objects to open() (part
     of PEP 519(6)).

   - bpo-27066(7): Fixed SystemError if a custom opener (for open())
     returns a negative number without setting an exception.

   - bpo-26983(8): float() now always return an instance of exact float.
     The deprecation warning is emitted if __float__ returns an instance
     of a strict subclass of float.  In a future versions of Python this
     can be an error.

   - bpo-27097(9): Python interpreter is now about 7% faster due to
     optimized instruction decoding.  Based on patch by Demur Rumed.

   - bpo-26647(10): Python interpreter now uses 16-bit wordcode instead
     of bytecode.  Patch by Demur Rumed.

   - bpo-23275(11): Allow assigning to an empty target list in round
     brackets: () = iterable.

   - bpo-27243(12): Update the __aiter__ protocol: instead of returning
     an awaitable that resolves to an asynchronous iterator, the
     asynchronous iterator should be returned directly.  Doing the
     former will trigger a PendingDeprecationWarning.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27095

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27190

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27286

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27140

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27186

   (6) https://peps.python.org/pep-0519/

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27066

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26983

   (9) https://bugs.python.org/issue?@action=redirect&bpo=27097

   (10) https://bugs.python.org/issue?@action=redirect&bpo=26647

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23275

   (12) https://bugs.python.org/issue?@action=redirect&bpo=27243


File: python.info,  Node: Library<76>,  Next: IDLE<55>,  Prev: Core and Builtins<77>,  Up: Python 3 6 0 alpha 2

1.23.85.3 Library
.................

   - Comment out socket (SO_REUSEPORT) and posix (O_SHLOCK, O_EXLOCK)
     constants exposed on the API which are not implemented on GNU/Hurd.
     They would not work at runtime anyway.

   - bpo-27025(1): Generated names for Tkinter widgets are now more
     meaningful and recognizable.

   - bpo-25455(2): Fixed crashes in repr of recursive
     ElementTree.Element and functools.partial objects.

   - bpo-27294(3): Improved repr for Tkinter event objects.

   - bpo-20508(4): Improve exception message of
     IPv{4,6}Network.__getitem__.  Patch by Gareth Rees.

   - bpo-21386(5): Implement missing IPv4Address.is_global property.  It
     was documented since 07a5610bae9d.  Initial patch by Roger Luethi.

   - bpo-27029(6): Removed deprecated support of universal newlines mode
     from ZipFile.open().

   - bpo-27030(7): Unknown escapes consisting of ‘'\'’ and an ASCII
     letter in regular expressions now are errors.  The re.LOCALE flag
     now can be used only with bytes patterns.

   - bpo-27186(8): Add os.PathLike support to DirEntry (part of PEP
     519(9)).  Initial patch by Jelle Zijlstra.

   - bpo-20900(10): distutils register command now decodes HTTP
     responses correctly.  Initial patch by ingrid.

   - bpo-27186(11): Add os.PathLike support to pathlib, removing its
     provisional status (part of PEP 519).  Initial patch by Dusty
     Phillips.

   - bpo-27186(12): Add support for os.PathLike objects to os.fsencode()
     and os.fsdecode() (part of PEP 519(13)).

   - bpo-27186(14): Introduce os.PathLike and os.fspath() (part of PEP
     519(15)).

   - A new version of typing.py provides several new classes and
     features: @overload outside stubs, Reversible, DefaultDict, Text,
     ContextManager, Type[], NewType(), TYPE_CHECKING, and numerous bug
     fixes (note that some of the new features are not yet implemented
     in mypy or other static analyzers).  Also classes for PEP 492(16)
     (Awaitable, AsyncIterable, AsyncIterator) have been added (in fact
     they made it into 3.5.1 but were never mentioned).

   - bpo-25738(17): Stop http.server.BaseHTTPRequestHandler.send_error()
     from sending a message body for 205 Reset Content.  Also, don't
     send Content header fields in responses that don't have a body.
     Patch by Susumu Koshiba.

   - bpo-21313(18): Fix the "platform" module to tolerate when
     sys.version contains truncated build information.

   - bpo-23883(19): Added missing APIs to __all__ to match the
     documented APIs for the following modules: cgi, mailbox, mimetypes,
     plistlib and smtpd.  Patches by Jacek Kołodziej.

   - bpo-27164(20): In the zlib module, allow decompressing raw Deflate
     streams with a predefined zdict.  Based on patch by Xiang Zhang.

   - bpo-24291(21): Fix wsgiref.simple_server.WSGIRequestHandler to
     completely write data to the client.  Previously it could do
     partial writes and truncate data.  Also,
     wsgiref.handler.ServerHandler can now handle stdout doing partial
     writes, but this is deprecated.

   - bpo-21272(22): Use _sysconfigdata.py to initialize
     distutils.sysconfig.

   - bpo-19611(23): *note inspect: 72. now reports the implicit ‘.0’
     parameters generated by the compiler for comprehension and
     generator expression scopes as if they were positional-only
     parameters called ‘implicit0’.  Patch by Jelle Zijlstra.

   - bpo-26809(24): Add ‘__all__’ to *note string: be.  Patch by Emanuel
     Barry.

   - bpo-26373(25): subprocess.Popen.communicate now correctly ignores
     BrokenPipeError when the child process dies before .communicate()
     is called in more/all circumstances.

   - signal, socket, and ssl module IntEnum constant name lookups now
     return a consistent name for values having multiple names.  Ex:
     signal.Signals(6) now refers to itself as signal.SIGALRM rather
     than flipping between that and signal.SIGIOT based on the
     interpreter's hash randomization seed.

   - bpo-27167(26): Clarify the subprocess.CalledProcessError error
     message text when the child process died due to a signal.

   - bpo-25931(27): Don't define socketserver.Forking* names on
     platforms such as Windows that do not support os.fork().

   - bpo-21776(28): distutils.upload now correctly handles HTTPError.
     Initial patch by Claudiu Popa.

   - bpo-26526(29): Replace custom parse tree validation in the parser
     module with a simple DFA validator.

   - bpo-27114(30): Fix SSLContext._load_windows_store_certs fails with
     PermissionError

   - bpo-18383(31): Avoid creating duplicate filters when using
     filterwarnings and simplefilter.  Based on patch by Alex Shkop.

   - bpo-23026(32): winreg.QueryValueEx() now return an integer for
     REG_QWORD type.

   - bpo-26741(33): subprocess.Popen destructor now emits a
     ResourceWarning warning if the child process is still running.

   - bpo-27056(34): Optimize pickle.load() and pickle.loads(), up to 10%
     faster to deserialize a lot of small objects.

   - bpo-21271(35): New keyword only parameters in reset_mock call.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27025

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25455

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27294

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20508

   (5) https://bugs.python.org/issue?@action=redirect&bpo=21386

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27029

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27030

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27186

   (9) https://peps.python.org/pep-0519/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=20900

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27186

   (12) https://bugs.python.org/issue?@action=redirect&bpo=27186

   (13) https://peps.python.org/pep-0519/

   (14) https://bugs.python.org/issue?@action=redirect&bpo=27186

   (15) https://peps.python.org/pep-0519/

   (16) https://peps.python.org/pep-0492/

   (17) https://bugs.python.org/issue?@action=redirect&bpo=25738

   (18) https://bugs.python.org/issue?@action=redirect&bpo=21313

   (19) https://bugs.python.org/issue?@action=redirect&bpo=23883

   (20) https://bugs.python.org/issue?@action=redirect&bpo=27164

   (21) https://bugs.python.org/issue?@action=redirect&bpo=24291

   (22) https://bugs.python.org/issue?@action=redirect&bpo=21272

   (23) https://bugs.python.org/issue?@action=redirect&bpo=19611

   (24) https://bugs.python.org/issue?@action=redirect&bpo=26809

   (25) https://bugs.python.org/issue?@action=redirect&bpo=26373

   (26) https://bugs.python.org/issue?@action=redirect&bpo=27167

   (27) https://bugs.python.org/issue?@action=redirect&bpo=25931

   (28) https://bugs.python.org/issue?@action=redirect&bpo=21776

   (29) https://bugs.python.org/issue?@action=redirect&bpo=26526

   (30) https://bugs.python.org/issue?@action=redirect&bpo=27114

   (31) https://bugs.python.org/issue?@action=redirect&bpo=18383

   (32) https://bugs.python.org/issue?@action=redirect&bpo=23026

   (33) https://bugs.python.org/issue?@action=redirect&bpo=26741

   (34) https://bugs.python.org/issue?@action=redirect&bpo=27056

   (35) https://bugs.python.org/issue?@action=redirect&bpo=21271


File: python.info,  Node: IDLE<55>,  Next: Documentation<65>,  Prev: Library<76>,  Up: Python 3 6 0 alpha 2

1.23.85.4 IDLE
..............

   - bpo-5124(1): Paste with text selected now replaces the selection on
     X11.  This matches how paste works on Windows, Mac, most modern
     Linux apps, and ttk widgets.  Original patch by Serhiy Storchaka.

   - bpo-24750(2): Switch all scrollbars in IDLE to ttk versions.  Where
     needed, minimal tests are added to cover changes.

   - bpo-24759(3): IDLE requires tk 8.5 and availability ttk widgets.
     Delete now unneeded tk version tests and code for older versions.
     Add test for IDLE syntax colorizer.

   - bpo-27239(4): idlelib.macosx.isXyzTk functions initialize as
     needed.

   - bpo-27262(5): move Aqua unbinding code, which enable context menus,
     to macosx.

   - bpo-24759(6): Make clear in idlelib.idle_test.__init__ that the
     directory is a private implementation of test.test_idle and tool
     for maintainers.

   - bpo-27196(7): Stop 'ThemeChanged' warnings when running IDLE tests.
     These persisted after other warnings were suppressed in #20567.
     Apply Serhiy Storchaka's update_idletasks solution to four test
     files.  Record this additional advice in idle_test/README.txt

   - bpo-20567(8): Revise idle_test/README.txt with advice about
     avoiding tk warning messages from tests.  Apply advice to several
     IDLE tests.

   - bpo-24225(9): Update idlelib/README.txt with new file names and
     event handlers.

   - bpo-27156(10): Remove obsolete code not used by IDLE.

   - bpo-27117(11): Make colorizer htest and turtledemo work with dark
     themes.  Move code for configuring text widget colors to a new
     function.

   - bpo-24225(12): Rename many ‘idlelib/*.py’ and ‘idle_test/test_*.py’
     files.  Edit files to replace old names with new names when the old
     name referred to the module rather than the class it contained.
     See the issue and IDLE section in What's New in 3.6 for more.

   - bpo-26673(13): When tk reports font size as 0, change to size 10.
     Such fonts on Linux prevented the configuration dialog from
     opening.

   - bpo-21939(14): Add test for IDLE's percolator.  Original patch by
     Saimadhav Heblikar.

   - bpo-21676(15): Add test for IDLE's replace dialog.  Original patch
     by Saimadhav Heblikar.

   - bpo-18410(16): Add test for IDLE's search dialog.  Original patch
     by Westley Martínez.

   - bpo-21703(17): Add test for undo delegator.  Patch mostly by
     Saimadhav Heblikar .

   - bpo-27044(18): Add ConfigDialog.remove_var_callbacks to stop memory
     leaks.

   - bpo-23977(19): Add more asserts to test_delegator.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5124

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24750

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24759

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27239

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27262

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24759

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27196

   (8) https://bugs.python.org/issue?@action=redirect&bpo=20567

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24225

   (10) https://bugs.python.org/issue?@action=redirect&bpo=27156

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27117

   (12) https://bugs.python.org/issue?@action=redirect&bpo=24225

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26673

   (14) https://bugs.python.org/issue?@action=redirect&bpo=21939

   (15) https://bugs.python.org/issue?@action=redirect&bpo=21676

   (16) https://bugs.python.org/issue?@action=redirect&bpo=18410

   (17) https://bugs.python.org/issue?@action=redirect&bpo=21703

   (18) https://bugs.python.org/issue?@action=redirect&bpo=27044

   (19) https://bugs.python.org/issue?@action=redirect&bpo=23977


File: python.info,  Node: Documentation<65>,  Next: Tests<69>,  Prev: IDLE<55>,  Up: Python 3 6 0 alpha 2

1.23.85.5 Documentation
.......................

   - bpo-16484(1): Change the default PYTHONDOCS URL to "https:", and
     fix the resulting links to use lowercase.  Patch by Sean Rodman,
     test by Kaushik Nadikuditi.

   - bpo-24136(2): Document the new PEP 448(3) unpacking syntax of 3.5.

   - bpo-22558(4): Add remaining doc links to source code for
     Python-coded modules.  Patch by Yoni Lavi.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=16484

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24136

   (3) https://peps.python.org/pep-0448/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22558


File: python.info,  Node: Tests<69>,  Next: Windows<65>,  Prev: Documentation<65>,  Up: Python 3 6 0 alpha 2

1.23.85.6 Tests
...............

   - bpo-25285(1): regrtest now uses subprocesses when the -j1 command
     line option is used: each test file runs in a fresh child process.
     Before, the -j1 option was ignored.

   - bpo-25285(2): Tools/buildbot/test.bat script now uses -j1 by
     default to run each test file in fresh child process.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25285

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25285


File: python.info,  Node: Windows<65>,  Next: Build<75>,  Prev: Tests<69>,  Up: Python 3 6 0 alpha 2

1.23.85.7 Windows
.................

   - bpo-27064(1): The py.exe launcher now defaults to Python 3.  The
     Windows launcher ‘py.exe’ no longer prefers an installed Python 2
     version over Python 3 by default when used interactively.

   - bpo-17500(2): Remove unused and outdated icons.  (See also:
     ‘https://github.com/python/pythondotorg/issues/945’)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27064

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17500


File: python.info,  Node: Build<75>,  Next: C API<65>,  Prev: Windows<65>,  Up: Python 3 6 0 alpha 2

1.23.85.8 Build
...............

   - bpo-27229(1): Fix the cross-compiling pgen rule for in-tree builds.
     Patch by Xavier de Gaye.

   - bpo-26930(2): Update OS X 10.5+ 32-bit-only installer to build and
     link with OpenSSL 1.0.2h.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27229

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26930


File: python.info,  Node: C API<65>,  Next: Tools/Demos<40>,  Prev: Build<75>,  Up: Python 3 6 0 alpha 2

1.23.85.9 C API
...............

   - bpo-27186(1): Add the PyOS_FSPath() function (part of PEP 519(2)).

   - bpo-26282(3): PyArg_ParseTupleAndKeywords() now supports
     positional-only parameters.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27186

   (2) https://peps.python.org/pep-0519/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26282


File: python.info,  Node: Tools/Demos<40>,  Prev: C API<65>,  Up: Python 3 6 0 alpha 2

1.23.85.10 Tools/Demos
......................

   - bpo-26282(1): Argument Clinic now supports positional-only and
     keyword parameters in the same function.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26282


File: python.info,  Node: Python 3 6 0 alpha 1,  Next: Python 3 5 5 final,  Prev: Python 3 6 0 alpha 2,  Up: 変更履歴

1.23.86 Python 3.6.0 alpha 1
----------------------------

'Release date: 2016-05-16'

* Menu:

* Security: Security<44>.
* Core and Builtins: Core and Builtins<78>.
* Library: Library<77>.
* IDLE: IDLE<56>.
* Documentation: Documentation<66>.
* Tests: Tests<70>.
* Build: Build<76>.
* Windows: Windows<66>.
* Tools/Demos: Tools/Demos<41>.
* C API: C API<66>.


File: python.info,  Node: Security<44>,  Next: Core and Builtins<78>,  Up: Python 3 6 0 alpha 1

1.23.86.1 Security
..................

   - bpo-26657(1): Fix directory traversal vulnerability with
     http.server on Windows.  This fixes a regression that was
     introduced in 3.3.4rc1 and 3.4.0rc1.  Based on patch by Philipp
     Hagemeister.

   - bpo-26313(2): ssl.py _load_windows_store_certs fails if windows
     cert store is empty.  Patch by Baji.

   - bpo-25939(3): On Windows open the cert store readonly in
     ssl.enum_certificates.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26657

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26313

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25939


File: python.info,  Node: Core and Builtins<78>,  Next: Library<77>,  Prev: Security<44>,  Up: Python 3 6 0 alpha 1

1.23.86.2 Core and Builtins
...........................

   - bpo-20041(1): Fixed TypeError when frame.f_trace is set to None.
     Patch by Xavier de Gaye.

   - bpo-26168(2): Fixed possible refleaks in failing Py_BuildValue()
     with the "N" format unit.

   - bpo-26991(3): Fix possible refleak when creating a function with
     annotations.

   - bpo-27039(4): Fixed bytearray.remove() for values greater than 127.
     Based on patch by Joe Jevnik.

   - bpo-23640(5): int.from_bytes() no longer bypasses constructors for
     subclasses.

   - bpo-27005(6): Optimized the float.fromhex() class method for exact
     float.  It is now 2 times faster.

   - bpo-18531(7): Single var-keyword argument of dict subtype was
     passed unscathed to the C-defined function.  Now it is converted to
     exact dict.

   - bpo-26811(8): gc.get_objects() no longer contains a broken tuple
     with NULL pointer.

   - bpo-20120(9): Use RawConfigParser for .pypirc parsing, removing
     support for interpolation unintentionally added with move to Python
     3.  Behavior no longer does any interpolation in .pypirc files,
     matching behavior in Python 2.7 and Setuptools 19.0.

   - bpo-26249(10): Memory functions of the *note PyMem_Malloc(): c33.
     domain (*note PYMEM_DOMAIN_MEM: c37.) now use the *note pymalloc
     allocator: cdd. rather than system ‘malloc()’.  Applications
     calling *note PyMem_Malloc(): c33. without holding the GIL can now
     crash: use ‘PYTHONMALLOC=debug’ environment variable to validate
     the usage of memory allocators in your application.

   - bpo-26802(11): Optimize function calls only using unpacking like
     ‘func(*tuple)’ (no other positional argument, no keyword): avoid
     copying the tuple.  Patch written by Joe Jevnik.

   - bpo-26659(12): Make the builtin slice type support cycle
     collection.

   - bpo-26718(13): super.__init__ no longer leaks memory if called
     multiple times.  NOTE: A direct call of super.__init__ is not
     endorsed!

   - bpo-27138(14): Fix the doc comment for FileFinder.find_spec().

   - bpo-27147(15): Mention PEP 420(16) in the importlib docs.

   - bpo-25339(17): PYTHONIOENCODING now has priority over locale in
     setting the error handler for stdin and stdout.

   - bpo-26494(18): Fixed crash on iterating exhausting iterators.
     Affected classes are generic sequence iterators, iterators of str,
     bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict,
     corresponding views and os.scandir() iterator.

   - bpo-26574(19): Optimize ‘bytes.replace(b'', b'.')’ and
     ‘bytearray.replace(b'', b'.')’.  Patch written by Josh Snider.

   - bpo-26581(20): If coding cookie is specified multiple times on a
     line in Python source code file, only the first one is taken to
     account.

   - bpo-19711(21): Add tests for reloading namespace packages.

   - bpo-21099(22): Switch applicable importlib tests to use PEP 451(23)
     API.

   - bpo-26563(24): Debug hooks on Python memory allocators now raise a
     fatal error if functions of the *note PyMem_Malloc(): c33. family
     are called without holding the GIL.

   - bpo-26564(25): On error, the debug hooks on Python memory
     allocators now use the *note tracemalloc: e8. module to get the
     traceback where a memory block was allocated.

   - bpo-26558(26): The debug hooks on Python memory allocator *note
     PyObject_Malloc(): c36. now detect when functions are called
     without holding the GIL.

   - bpo-26516(27): Add *note PYTHONMALLOC: c32. environment variable to
     set the Python memory allocators and/or install debug hooks.

   - bpo-26516(28): The *note PyMem_SetupDebugHooks(): c38. function can
     now also be used on Python compiled in release mode.

   - bpo-26516(29): The *note PYTHONMALLOCSTATS: 1ac1. environment
     variable can now also be used on Python compiled in release mode.
     It now has no effect if set to an empty string.

   - bpo-26516(30): In debug mode, debug hooks are now also installed on
     Python memory allocators when Python is configured without
     pymalloc.

   - bpo-26464(31): Fix str.translate() when string is ASCII and first
     replacements removes character, but next replacement uses a
     non-ASCII character or a string longer than 1 character.
     Regression introduced in Python 3.5.0.

   - bpo-22836(32): Ensure exception reports from PyErr_Display() and
     PyErr_WriteUnraisable() are sensible even when formatting them
     produces secondary errors.  This affects the reports produced by
     sys.__excepthook__() and when __del__() raises an exception.

   - bpo-26302(33): Correct behavior to reject comma as a legal
     character for cookie names.

   - bpo-26136(34): Upgrade the warning when a generator raises
     StopIteration from PendingDeprecationWarning to DeprecationWarning.
     Patch by Anish Shah.

   - bpo-26204(35): The compiler now ignores all constant statements:
     bytes, str, int, float, complex, name constants (None, False,
     True), Ellipsis and ast.Constant; not only str and int.  For
     example, ‘1.0’ is now ignored in ‘def f(): 1.0’.

   - bpo-4806(36): Avoid masking the original TypeError exception when
     using star (‘*’) unpacking in function calls.  Based on patch by
     Hagen Fürstenau and Daniel Urban.

   - bpo-26146(37): Add a new kind of AST node: ‘ast.Constant’.  It can
     be used by external AST optimizers, but the compiler does not emit
     directly such node.

   - bpo-23601(38): Sped-up allocation of dict key objects by using
     Python's small object allocator.  (Contributed by Julian Taylor.)

   - bpo-18018(39): Import raises ImportError instead of SystemError if
     a relative import is attempted without a known parent package.

   - bpo-25843(40): When compiling code, don't merge constants if they
     are equal but have a different types.  For example, ‘f1, f2 =
     lambda: 1, lambda: 1.0’ is now correctly compiled to two different
     functions: ‘f1()’ returns ‘1’ (‘int’) and ‘f2()’ returns ‘1.0’
     (‘float’), even if ‘1’ and ‘1.0’ are equal.

   - bpo-26107(41): The format of the ‘co_lnotab’ attribute of code
     objects changes to support negative line number delta.

   - bpo-26154(42): Add a new private _PyThreadState_UncheckedGet()
     function to get the current Python thread state, but don't issue a
     fatal error if it is NULL. This new function must be used instead
     of accessing directly the _PyThreadState_Current variable.  The
     variable is no more exposed since Python 3.5.1 to hide the exact
     implementation of atomic C types, to avoid compiler issues.

   - bpo-25791(43): If __package__ != __spec__.parent or if neither
     __package__ or __spec__ are defined then ImportWarning is raised.

   - bpo-22995(44): [UPDATE] Comment out the one of the pickleability
     tests in _PyObject_GetState() due to regressions observed in
     Cython-based projects.

   - bpo-25961(45): Disallowed null characters in the type name.

   - bpo-25973(46): Fix segfault when an invalid nonlocal statement
     binds a name starting with two underscores.

   - bpo-22995(47): Instances of extension types with a state that
     aren't subclasses of list or dict and haven't implemented any
     pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__,
     __getnewargs_ex__, or __getstate__), can no longer be pickled.
     Including memoryview.

   - bpo-20440(48): Massive replacing unsafe attribute setting code with
     special macro Py_SETREF.

   - bpo-25766(49): Special method __bytes__() now works in str
     subclasses.

   - bpo-25421(50): __sizeof__ methods of builtin types now use dynamic
     basic size.  This allows sys.getsize() to work correctly with their
     subclasses with __slots__ defined.

   - bpo-25709(51): Fixed problem with in-place string concatenation and
     utf-8 cache.

   - bpo-5319(52): New Py_FinalizeEx() API allowing Python to set an
     exit status of 120 on failure to flush buffered streams.

   - bpo-25485(53): telnetlib.Telnet is now a context manager.

   - bpo-24097(54): Fixed crash in object.__reduce__() if slot name is
     freed inside __getattr__.

   - bpo-24731(55): Fixed crash on converting objects with special
     methods __bytes__, __trunc__, and __float__ returning instances of
     subclasses of bytes, int, and float to subclasses of bytes, int,
     and float correspondingly.

   - bpo-25630(56): Fix a possible segfault during argument parsing in
     functions that accept filesystem paths.

   - bpo-23564(57): Fixed a partially broken sanity check in the
     _posixsubprocess internals regarding how fds_to_pass were passed to
     the child.  The bug had no actual impact as subprocess.py already
     avoided it.

   - bpo-25388(58): Fixed tokenizer crash when processing undecodable
     source code with a null byte.

   - bpo-25462(59): The hash of the key now is calculated only once in
     most operations in C implementation of OrderedDict.

   - bpo-22995(60): Default implementation of __reduce__ and
     __reduce_ex__ now rejects builtin types with not defined __new__.

   - bpo-24802(61): Avoid buffer overreads when int(), float(),
     compile(), exec() and eval() are passed bytes-like objects.  These
     objects are not necessarily terminated by a null byte, but the
     functions assumed they were.

   - bpo-25555(62): Fix parser and AST: fill lineno and col_offset of
     "arg" node when compiling AST from Python objects.

   - bpo-24726(63): Fixed a crash and leaking NULL in repr() of
     OrderedDict that was mutated by direct calls of dict methods.

   - bpo-25449(64): Iterating OrderedDict with keys with unstable hash
     now raises KeyError in C implementations as well as in Python
     implementation.

   - bpo-25395(65): Fixed crash when highly nested OrderedDict
     structures were garbage collected.

   - bpo-25401(66): Optimize bytes.fromhex() and bytearray.fromhex():
     they are now between 2x and 3.5x faster.

   - bpo-25399(67): Optimize bytearray % args using the new private
     _PyBytesWriter API. Formatting is now between 2.5 and 5 times
     faster.

   - bpo-25274(68): sys.setrecursionlimit() now raises a RecursionError
     if the new recursion limit is too low depending at the current
     recursion depth.  Modify also the "lower-water mark" formula to
     make it monotonic.  This mark is used to decide when the overflowed
     flag of the thread state is reset.

   - bpo-24402(69): Fix input() to prompt to the redirected stdout when
     sys.stdout.fileno() fails.

   - bpo-25349(70): Optimize bytes % args using the new private
     _PyBytesWriter API. Formatting is now up to 2 times faster.

   - bpo-24806(71): Prevent builtin types that are not allowed to be
     subclassed from being subclassed through multiple inheritance.

   - bpo-25301(72): The UTF-8 decoder is now up to 15 times as fast for
     error handlers: ‘ignore’, ‘replace’ and ‘surrogateescape’.

   - bpo-24848(73): Fixed a number of bugs in UTF-7 decoding of
     misformed data.

   - bpo-25267(74): The UTF-8 encoder is now up to 75 times as fast for
     error handlers: ‘ignore’, ‘replace’, ‘surrogateescape’,
     ‘surrogatepass’.  Patch co-written with Serhiy Storchaka.

   - bpo-25280(75): Import trace messages emitted in verbose (-v) mode
     are no longer formatted twice.

   - bpo-25227(76): Optimize ASCII and latin1 encoders with the
     ‘surrogateescape’ error handler: the encoders are now up to 3 times
     as fast.  Initial patch written by Serhiy Storchaka.

   - bpo-25003(77): On Solaris 11.3 or newer, os.urandom() now uses the
     getrandom() function instead of the getentropy() function.  The
     getentropy() function is blocking to generate very good quality
     entropy, os.urandom() doesn't need such high-quality entropy.

   - bpo-9232(78): Modify Python's grammar to allow trailing commas in
     the argument list of a function declaration.  For example, "def
     f(*, a = 3,): pass" is now legal.  Patch from Mark Dickinson.

   - bpo-24965(79): Implement PEP 498(80) "Literal String
     Interpolation".  This allows you to embed expressions inside
     f-strings, which are converted to normal strings at run time.
     Given x=3, then f'value={x}' == 'value=3'.  Patch by Eric V. Smith.

   - bpo-26478(81): Fix semantic bugs when using binary operators with
     dictionary views and tuples.

   - bpo-26171(82): Fix possible integer overflow and heap corruption in
     zipimporter.get_data().

   - bpo-25660(83): Fix TAB key behaviour in REPL with readline.

   - bpo-26288(84): Optimize PyLong_AsDouble.

   - bpo-26289(85): Optimize floor and modulo division for single-digit
     longs.  Microbenchmarks show 2-2.5x improvement.  Built-in 'divmod'
     function is now also ~10% faster.  (See also: bpo-26315(86))

   - bpo-25887(87): Raise a RuntimeError when a coroutine object is
     awaited more than once.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20041

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26168

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26991

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27039

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23640

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27005

   (7) https://bugs.python.org/issue?@action=redirect&bpo=18531

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26811

   (9) https://bugs.python.org/issue?@action=redirect&bpo=20120

   (10) https://bugs.python.org/issue?@action=redirect&bpo=26249

   (11) https://bugs.python.org/issue?@action=redirect&bpo=26802

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26659

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26718

   (14) https://bugs.python.org/issue?@action=redirect&bpo=27138

   (15) https://bugs.python.org/issue?@action=redirect&bpo=27147

   (16) https://peps.python.org/pep-0420/

   (17) https://bugs.python.org/issue?@action=redirect&bpo=25339

   (18) https://bugs.python.org/issue?@action=redirect&bpo=26494

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26574

   (20) https://bugs.python.org/issue?@action=redirect&bpo=26581

   (21) https://bugs.python.org/issue?@action=redirect&bpo=19711

   (22) https://bugs.python.org/issue?@action=redirect&bpo=21099

   (23) https://peps.python.org/pep-0451/

   (24) https://bugs.python.org/issue?@action=redirect&bpo=26563

   (25) https://bugs.python.org/issue?@action=redirect&bpo=26564

   (26) https://bugs.python.org/issue?@action=redirect&bpo=26558

   (27) https://bugs.python.org/issue?@action=redirect&bpo=26516

   (28) https://bugs.python.org/issue?@action=redirect&bpo=26516

   (29) https://bugs.python.org/issue?@action=redirect&bpo=26516

   (30) https://bugs.python.org/issue?@action=redirect&bpo=26516

   (31) https://bugs.python.org/issue?@action=redirect&bpo=26464

   (32) https://bugs.python.org/issue?@action=redirect&bpo=22836

   (33) https://bugs.python.org/issue?@action=redirect&bpo=26302

   (34) https://bugs.python.org/issue?@action=redirect&bpo=26136

   (35) https://bugs.python.org/issue?@action=redirect&bpo=26204

   (36) https://bugs.python.org/issue?@action=redirect&bpo=4806

   (37) https://bugs.python.org/issue?@action=redirect&bpo=26146

   (38) https://bugs.python.org/issue?@action=redirect&bpo=23601

   (39) https://bugs.python.org/issue?@action=redirect&bpo=18018

   (40) https://bugs.python.org/issue?@action=redirect&bpo=25843

   (41) https://bugs.python.org/issue?@action=redirect&bpo=26107

   (42) https://bugs.python.org/issue?@action=redirect&bpo=26154

   (43) https://bugs.python.org/issue?@action=redirect&bpo=25791

   (44) https://bugs.python.org/issue?@action=redirect&bpo=22995

   (45) https://bugs.python.org/issue?@action=redirect&bpo=25961

   (46) https://bugs.python.org/issue?@action=redirect&bpo=25973

   (47) https://bugs.python.org/issue?@action=redirect&bpo=22995

   (48) https://bugs.python.org/issue?@action=redirect&bpo=20440

   (49) https://bugs.python.org/issue?@action=redirect&bpo=25766

   (50) https://bugs.python.org/issue?@action=redirect&bpo=25421

   (51) https://bugs.python.org/issue?@action=redirect&bpo=25709

   (52) https://bugs.python.org/issue?@action=redirect&bpo=5319

   (53) https://bugs.python.org/issue?@action=redirect&bpo=25485

   (54) https://bugs.python.org/issue?@action=redirect&bpo=24097

   (55) https://bugs.python.org/issue?@action=redirect&bpo=24731

   (56) https://bugs.python.org/issue?@action=redirect&bpo=25630

   (57) https://bugs.python.org/issue?@action=redirect&bpo=23564

   (58) https://bugs.python.org/issue?@action=redirect&bpo=25388

   (59) https://bugs.python.org/issue?@action=redirect&bpo=25462

   (60) https://bugs.python.org/issue?@action=redirect&bpo=22995

   (61) https://bugs.python.org/issue?@action=redirect&bpo=24802

   (62) https://bugs.python.org/issue?@action=redirect&bpo=25555

   (63) https://bugs.python.org/issue?@action=redirect&bpo=24726

   (64) https://bugs.python.org/issue?@action=redirect&bpo=25449

   (65) https://bugs.python.org/issue?@action=redirect&bpo=25395

   (66) https://bugs.python.org/issue?@action=redirect&bpo=25401

   (67) https://bugs.python.org/issue?@action=redirect&bpo=25399

   (68) https://bugs.python.org/issue?@action=redirect&bpo=25274

   (69) https://bugs.python.org/issue?@action=redirect&bpo=24402

   (70) https://bugs.python.org/issue?@action=redirect&bpo=25349

   (71) https://bugs.python.org/issue?@action=redirect&bpo=24806

   (72) https://bugs.python.org/issue?@action=redirect&bpo=25301

   (73) https://bugs.python.org/issue?@action=redirect&bpo=24848

   (74) https://bugs.python.org/issue?@action=redirect&bpo=25267

   (75) https://bugs.python.org/issue?@action=redirect&bpo=25280

   (76) https://bugs.python.org/issue?@action=redirect&bpo=25227

   (77) https://bugs.python.org/issue?@action=redirect&bpo=25003

   (78) https://bugs.python.org/issue?@action=redirect&bpo=9232

   (79) https://bugs.python.org/issue?@action=redirect&bpo=24965

   (80) https://peps.python.org/pep-0498/

   (81) https://bugs.python.org/issue?@action=redirect&bpo=26478

   (82) https://bugs.python.org/issue?@action=redirect&bpo=26171

   (83) https://bugs.python.org/issue?@action=redirect&bpo=25660

   (84) https://bugs.python.org/issue?@action=redirect&bpo=26288

   (85) https://bugs.python.org/issue?@action=redirect&bpo=26289

   (86) https://bugs.python.org/issue?@action=redirect&bpo=26315

   (87) https://bugs.python.org/issue?@action=redirect&bpo=25887


File: python.info,  Node: Library<77>,  Next: IDLE<56>,  Prev: Core and Builtins<78>,  Up: Python 3 6 0 alpha 1

1.23.86.3 Library
.................

   - bpo-27057(1): Fix os.set_inheritable() on Android, ioctl() is
     blocked by SELinux and fails with EACCESS. The function now falls
     back to fcntl().  Patch written by Michał Bednarski.

   - bpo-27014(2): Fix infinite recursion using typing.py.  Thanks to
     Kalle Tuure!

   - bpo-27031(3): Removed dummy methods in Tkinter widget classes:
     tk_menuBar() and tk_bindForTraversal().

   - bpo-14132(4): Fix urllib.request redirect handling when the target
     only has a query string.  Original fix by Ján Janech.

   - bpo-17214(5): The "urllib.request" module now percent-encodes
     non-ASCII bytes found in redirect target URLs.  Some servers send
     Location header fields with non-ASCII bytes, but "http.client"
     requires the request target to be ASCII-encodable, otherwise a
     UnicodeEncodeError is raised.  Based on patch by Christian Heimes.

   - bpo-27033(6): The default value of the decode_data parameter for
     smtpd.SMTPChannel and smtpd.SMTPServer constructors is changed to
     False.

   - bpo-27034(7): Removed deprecated class asynchat.fifo.

   - bpo-26870(8): Added readline.set_auto_history(), which can stop
     entries being automatically added to the history list.  Based on
     patch by Tyler Crompton.

   - bpo-26039(9): zipfile.ZipFile.open() can now be used to write data
     into a ZIP file, as well as for extracting data.  Patch by Thomas
     Kluyver.

   - bpo-26892(10): Honor debuglevel flag in urllib.request.HTTPHandler.
     Patch contributed by Chi Hsuan Yen.

   - bpo-22274(11): In the subprocess module, allow stderr to be
     redirected to stdout even when stdout is not redirected.  Patch by
     Akira Li.

   - bpo-26807(12): mock_open 'files' no longer error on readline at end
     of file.  Patch from Yolanda Robla.

   - bpo-25745(13): Fixed leaking a userptr in curses panel destructor.

   - bpo-26977(14): Removed unnecessary, and ignored, call to sum of
     squares helper in statistics.pvariance.

   - bpo-26002(15): Use bisect in statistics.median instead of a linear
     search.  Patch by Upendra Kuma.

   - bpo-25974(16): Make use of new Decimal.as_integer_ratio() method in
     statistics module.  Patch by Stefan Krah.

   - bpo-26996(17): Add secrets module as described in PEP 506(18).

   - bpo-26881(19): The modulefinder module now supports extended opcode
     arguments.

   - bpo-23815(20): Fixed crashes related to directly created instances
     of types in _tkinter and curses.panel modules.

   - bpo-17765(21): weakref.ref() no longer silently ignores keyword
     arguments.  Patch by Georg Brandl.

   - bpo-26873(22): xmlrpc now raises ResponseError on unsupported type
     tags instead of silently return incorrect result.

   - bpo-26915(23): The __contains__ methods in the collections ABCs now
     check for identity before checking equality.  This better matches
     the behavior of the concrete classes, allows sensible handling of
     NaNs, and makes it easier to reason about container invariants.

   - bpo-26711(24): Fixed the comparison of plistlib.Data with other
     types.

   - bpo-24114(25): Fix an uninitialized variable in ‘ctypes.util’.  The
     bug only occurs on SunOS when the ctypes implementation searches
     for the ‘crle’ program.  Patch by Xiang Zhang.  Tested on SunOS by
     Kees Bos.

   - bpo-26864(26): In urllib.request, change the proxy bypass host
     checking against no_proxy to be case-insensitive, and to not match
     unrelated host names that happen to have a bypassed hostname as a
     suffix.  Patch by Xiang Zhang.

   - bpo-24902(27): Print server URL on http.server startup.  Initial
     patch by Felix Kaiser.

   - bpo-25788(28): fileinput.hook_encoded() now supports an "errors"
     argument for passing to open.  Original patch by Joseph Hackman.

   - bpo-26634(29): recursive_repr() now sets __qualname__ of wrapper.
     Patch by Xiang Zhang.

   - bpo-26804(30): urllib.request will prefer lower_case proxy
     environment variables over UPPER_CASE or Mixed_Case ones.  Patch
     contributed by Hans-Peter Jansen.

   - bpo-26837(31): assertSequenceEqual() now correctly outputs
     non-stringified differing items (like bytes in the -b mode).  This
     affects assertListEqual() and assertTupleEqual().

   - bpo-26041(32): Remove "will be removed in Python 3.7" from
     deprecation messages of platform.dist() and
     platform.linux_distribution().  Patch by Kumaripaba Miyurusara
     Athukorala.

   - bpo-26822(33): itemgetter, attrgetter and methodcaller objects no
     longer silently ignore keyword arguments.

   - bpo-26733(34): Disassembling a class now disassembles class and
     static methods.  Patch by Xiang Zhang.

   - bpo-26801(35): Fix error handling in *note
     shutil.get_terminal_size(): 10d6, catch *note AttributeError: 326.
     instead of *note NameError: 40b.  Patch written by Emanuel Barry.

   - bpo-24838(36): tarfile's ustar and gnu formats now correctly
     calculate name and link field limits for multibyte character
     encodings like utf-8.

   - bpo-26717(37): Stop encoding Latin-1-ized WSGI paths with UTF-8.
     Patch by Anthony Sottile.

   - bpo-26782(38): Add STARTUPINFO to subprocess.__all__ on Windows.

   - bpo-26404(39): Add context manager to socketserver.  Patch by Aviv
     Palivoda.

   - bpo-26735(40): Fix *note os.urandom(): 4ec. on Solaris 11.3 and
     newer when reading more than 1,024 bytes: call ‘getrandom()’
     multiple times with a limit of 1024 bytes per call.

   - bpo-26585(41): Eliminate http.server._quote_html() and use
     html.escape(quote=False).  Patch by Xiang Zhang.

   - bpo-26685(42): Raise OSError if closing a socket fails.

   - bpo-16329(43): Add .webm to mimetypes.types_map.  Patch by
     Giampaolo Rodola'.

   - bpo-13952(44): Add .csv to mimetypes.types_map.  Patch by Geoff
     Wilson.

   - bpo-26587(45): the site module now allows .pth files to specify
     files to be added to sys.path (e.g.  zip files).

   - bpo-25609(46): Introduce contextlib.AbstractContextManager and
     typing.ContextManager.

   - bpo-26709(47): Fixed Y2038 problem in loading binary PLists.

   - bpo-23735(48): Handle terminal resizing with Readline 6.3+ by
     installing our own SIGWINCH handler.  Patch by Eric Price.

   - bpo-25951(49): Change SSLSocket.sendall() to return None, as
     explicitly documented for plain socket objects.  Patch by Aviv
     Palivoda.

   - bpo-26586(50): In http.server, respond with "413 Request header
     fields too large" if there are too many header fields to parse,
     rather than killing the connection and raising an unhandled
     exception.  Patch by Xiang Zhang.

   - bpo-26676(51): Added missing XMLPullParser to ElementTree.__all__.

   - bpo-22854(52): Change BufferedReader.writable() and
     BufferedWriter.readable() to always return False.

   - bpo-26492(53): Exhausted iterator of array.array now conforms with
     the behavior of iterators of other mutable sequences: it lefts
     exhausted even if iterated array is extended.

   - bpo-26641(54): doctest.DocFileTest and doctest.testfile() now
     support packages (module splitted into multiple directories) for
     the package parameter.

   - bpo-25195(55): Fix a regression in mock.MagicMock.  _Call is a
     subclass of tuple (changeset 3603bae63c13 only works for classes)
     so we need to implement __ne__ ourselves.  Patch by Andrew Plummer.

   - bpo-26644(56): Raise ValueError rather than SystemError when a
     negative length is passed to SSLSocket.recv() or read().

   - bpo-23804(57): Fix SSL recv(0) and read(0) methods to return zero
     bytes instead of up to 1024.

   - bpo-26616(58): Fixed a bug in datetime.astimezone() method.

   - bpo-26637(59): The *note importlib: 6b. module now emits an *note
     ImportError: 3f2. rather than a *note TypeError: 502. if *note
     __import__(): 8a2. is tried during the Python shutdown process but
     *note sys.path: 38e. is already cleared (set to ‘None’).

   - bpo-21925(60): *note warnings.formatwarning(): 1980. now catches
     exceptions when calling *note linecache.getline(): df0. and *note
     tracemalloc.get_object_traceback(): 1ac3. to be able to log *note
     ResourceWarning: 225. emitted late during the Python shutdown
     process.

   - bpo-23848(61): On Windows, faulthandler.enable() now also installs
     an exception handler to dump the traceback of all Python threads on
     any Windows exception, not only on UNIX signals (SIGSEGV, SIGFPE,
     SIGABRT).

   - bpo-26530(62): Add C functions ‘_PyTraceMalloc_Track()’ and
     ‘_PyTraceMalloc_Untrack()’ to track memory blocks using the *note
     tracemalloc: e8. module.  Add ‘_PyTraceMalloc_GetTraceback()’ to
     get the traceback of an object.

   - bpo-26588(63): The _tracemalloc now supports tracing memory
     allocations of multiple address spaces (domains).

   - bpo-24266(64): Ctrl+C during Readline history search now cancels
     the search mode when compiled with Readline 7.

   - bpo-26590(65): Implement a safe finalizer for the _socket.socket
     type.  It now releases the GIL to close the socket.

   - bpo-18787(66): spwd.getspnam() now raises a PermissionError if the
     user doesn't have privileges.

   - bpo-26560(67): Avoid potential ValueError in
     BaseHandler.start_response.  Initial patch by Peter Inglesby.

   - bpo-26567(68): Add a new function *note PyErr_ResourceWarning():
     ce5. function to pass the destroyed object.  Add a 'source'
     attribute to ‘warnings.WarningMessage’.  Add
     warnings._showwarnmsg() which uses tracemalloc to get the traceback
     where source object was allocated.

   - bpo-26569(69): Fix *note pyclbr.readmodule(): 7f6. and *note
     pyclbr.readmodule_ex(): 7f7. to support importing packages.

   - bpo-26499(70): Account for remaining Content-Length in
     HTTPResponse.readline() and read1().  Based on patch by Silent
     Ghost.  Also document that HTTPResponse now supports these methods.

   - bpo-25320(71): Handle sockets in directories unittest discovery is
     scanning.  Patch from Victor van den Elzen.

   - bpo-16181(72): cookiejar.http2time() now returns None if year is
     higher than datetime.MAXYEAR.

   - bpo-26513(73): Fixes platform module detection of Windows Server

   - bpo-23718(74): Fixed parsing time in week 0 before Jan 1.  Original
     patch by Tamás Bence Gedai.

   - bpo-26323(75): Add Mock.assert_called() and
     Mock.assert_called_once() methods to unittest.mock.  Patch written
     by Amit Saha.

   - bpo-20589(76): Invoking Path.owner() and Path.group() on Windows
     now raise NotImplementedError instead of ImportError.

   - bpo-26177(77): Fixed the keys() method for Canvas and Scrollbar
     widgets.

   - bpo-15068(78): Got rid of excessive buffering in fileinput.  The
     bufsize parameter is now deprecated and ignored.

   - bpo-19475(79): Added an optional argument timespec to the datetime
     isoformat() method to choose the precision of the time component.

   - bpo-2202(80): Fix UnboundLocalError in
     AbstractDigestAuthHandler.get_algorithm_impls.  Initial patch by
     Mathieu Dupuy.

   - bpo-26167(81): Minimized overhead in copy.copy() and
     copy.deepcopy().  Optimized copying and deepcopying bytearrays,
     NotImplemented, slices, short lists, tuples, dicts, sets.

   - bpo-25718(82): Fixed pickling and copying the accumulate() iterator
     with total is None.

   - bpo-26475(83): Fixed debugging output for regular expressions with
     the (?x) flag.

   - bpo-26482(84): Allowed pickling recursive dequeues.

   - bpo-26335(85): Make mmap.write() return the number of bytes written
     like other write methods.  Patch by Jakub Stasiak.

   - bpo-26457(86): Fixed the subnets() methods in IP network classes
     for the case when resulting prefix length is equal to maximal
     prefix length.  Based on patch by Xiang Zhang.

   - bpo-26385(87): Remove the file if the internal open() call in
     NamedTemporaryFile() fails.  Patch by Silent Ghost.

   - bpo-26402(88): Fix XML-RPC client to retry when the server shuts
     down a persistent connection.  This was a regression related to the
     new http.client.RemoteDisconnected exception in 3.5.0a4.

   - bpo-25913(89): Leading ‘<~’ is optional now in base64.a85decode()
     with adobe=True.  Patch by Swati Jaiswal.

   - bpo-26186(90): Remove an invalid type check in
     importlib.util.LazyLoader.

   - bpo-26367(91): importlib.__import__() raises ImportError like
     builtins.__import__() when ‘level’ is specified but without an
     accompanying package specified.

   - bpo-26309(92): In the "socketserver" module, shut down the request
     (closing the connected socket) when verify_request() returns false.
     Patch by Aviv Palivoda.

   - bpo-23430(93): Change the socketserver module to only catch
     exceptions raised from a request handler that are derived from
     Exception (instead of BaseException).  Therefore SystemExit and
     KeyboardInterrupt no longer trigger the handle_error() method, and
     will now to stop a single-threaded server.

   - bpo-25995(94): os.walk() no longer uses FDs proportional to the
     tree depth.

   - bpo-25994(95): Added the close() method and the support of the
     context manager protocol for the os.scandir() iterator.

   - bpo-23992(96): multiprocessing: make MapResult not fail-fast upon
     exception.

   - bpo-26243(97): Support keyword arguments to zlib.compress().  Patch
     by Aviv Palivoda.

   - bpo-26117(98): The os.scandir() iterator now closes file descriptor
     not only when the iteration is finished, but when it was failed
     with error.

   - bpo-25949(99): __dict__ for an OrderedDict instance is now created
     only when needed.

   - bpo-25911(100): Restored support of bytes paths in os.walk() on
     Windows.

   - bpo-26045(101): Add UTF-8 suggestion to error message when posting
     a non-Latin-1 string with http.client.

   - bpo-26039(102): Added zipfile.ZipInfo.from_file() and
     zipinfo.ZipInfo.is_dir().  Patch by Thomas Kluyver.

   - bpo-12923(103): Reset FancyURLopener's redirect counter even if
     there is an exception.  Based on patches by Brian Brazil and Daniel
     Rocco.

   - bpo-25945(104): Fixed a crash when unpickle the functools.partial
     object with wrong state.  Fixed a leak in failed functools.partial
     constructor.  "args" and "keywords" attributes of functools.partial
     have now always types tuple and dict correspondingly.

   - bpo-26202(105): copy.deepcopy() now correctly copies range()
     objects with non-atomic attributes.

   - bpo-23076(106): Path.glob() now raises a ValueError if it's called
     with an invalid pattern.  Patch by Thomas Nyberg.

   - bpo-19883(107): Fixed possible integer overflows in zipimport.

   - bpo-26227(108): On Windows, getnameinfo(), gethostbyaddr() and
     gethostbyname_ex() functions of the socket module now decode the
     hostname from the ANSI code page rather than UTF-8.

   - bpo-26099(109): The site module now writes an error into stderr if
     sitecustomize module can be imported but executing the module raise
     an ImportError.  Same change for usercustomize.

   - bpo-26147(110): xmlrpc now works with strings not encodable with
     used non-UTF-8 encoding.

   - bpo-25935(111): Garbage collector now breaks reference loops with
     OrderedDict.

   - bpo-16620(112): Fixed AttributeError in msilib.Directory.glob().

   - bpo-26013(113): Added compatibility with broken protocol 2 pickles
     created in old Python 3 versions (3.4.3 and lower).

   - bpo-26129(114): Deprecated accepting non-integers in
     grp.getgrgid().

   - bpo-25850(115): Use cross-compilation by default for 64-bit
     Windows.

   - bpo-25822(116): Add docstrings to the fields of urllib.parse
     results.  Patch contributed by Swati Jaiswal.

   - bpo-22642(117): Convert trace module option parsing mechanism to
     argparse.  Patch contributed by SilentGhost.

   - bpo-24705(118): Fix sysconfig._parse_makefile not expanding ${}
     vars appearing before $() vars.

   - bpo-26069(119): Remove the deprecated apis in the trace module.

   - bpo-22138(120): Fix mock.patch behavior when patching descriptors.
     Restore original values after patching.  Patch contributed by Sean
     McCully.

   - bpo-25672(121): In the ssl module, enable the
     SSL_MODE_RELEASE_BUFFERS mode option if it is safe to do so.

   - bpo-26012(122): Don't traverse into symlinks for ‘**’ pattern in
     pathlib.Path.[r]glob().

   - bpo-24120(123): Ignore PermissionError when traversing a tree with
     pathlib.Path.[r]glob().  Patch by Ulrich Petri.

   - bpo-21815(124): Accept ] characters in the data portion of imap
     responses, in order to handle the flags with square brackets
     accepted and produced by servers such as gmail.

   - bpo-25447(125): fileinput now uses sys.stdin as-is if it does not
     have a buffer attribute (restores backward compatibility).

   - bpo-25971(126): Optimized creating Fractions from floats by 2 times
     and from Decimals by 3 times.

   - bpo-25802(127): Document as deprecated the remaining
     implementations of importlib.abc.Loader.load_module().

   - bpo-25928(128): Add Decimal.as_integer_ratio().

   - bpo-25447(129): Copying the lru_cache() wrapper object now always
     works, independently from the type of the wrapped object (by
     returning the original object unchanged).

   - bpo-25768(130): Have the functions in compileall return booleans
     instead of ints and add proper documentation and tests for the
     return values.

   - bpo-24103(131): Fixed possible use after free in
     ElementTree.XMLPullParser.

   - bpo-25860(132): os.fwalk() no longer skips remaining directories
     when error occurs.  Original patch by Samson Lee.

   - bpo-25914(133): Fixed and simplified OrderedDict.__sizeof__.

   - bpo-25869(134): Optimized deepcopying ElementTree; it is now 20
     times faster.

   - bpo-25873(135): Optimized iterating ElementTree.  Iterating
     elements Element.iter() is now 40% faster, iterating text
     Element.itertext() is now up to 2.5 times faster.

   - bpo-25902(136): Fixed various refcount issues in ElementTree
     iteration.

   - bpo-22227(137): The TarFile iterator is reimplemented using
     generator.  This implementation is simpler that using class.

   - bpo-25638(138): Optimized ElementTree.iterparse(); it is now 2x
     faster.  Optimized ElementTree parsing; it is now 10% faster.

   - bpo-25761(139): Improved detecting errors in broken pickle data.

   - bpo-25717(140): Restore the previous behaviour of tolerating most
     fstat() errors when opening files.  This was a regression in 3.5a1,
     and stopped anonymous temporary files from working in special
     cases.

   - bpo-24903(141): Fix regression in number of arguments compileall
     accepts when '-d' is specified.  The check on the number of
     arguments has been dropped completely as it never worked correctly
     anyway.

   - bpo-25764(142): In the subprocess module, preserve any exception
     caused by fork() failure when preexec_fn is used.

   - bpo-25771(143): Tweak the exception message for
     importlib.util.resolve_name() when 'package' isn't specified but
     necessary.

   - bpo-6478(144): _strptime's regexp cache now is reset after changing
     timezone with time.tzset().

   - bpo-14285(145): When executing a package with the "python -m
     package" option, and package initialization fails, a proper
     traceback is now reported.  The "runpy" module now lets exceptions
     from package initialization pass back to the caller, rather than
     raising ImportError.

   - bpo-19771(146): Also in runpy and the "-m" option, omit the
     irrelevant message ".  .  .  is a package and cannot be directly
     executed" if the package could not even be initialized (e.g.  due
     to a bad ‘*.pyc’ file).

   - bpo-25177(147): Fixed problem with the mean of very small and very
     large numbers.  As a side effect, statistics.mean and
     statistics.variance should be significantly faster.

   - bpo-25718(148): Fixed copying object with state with boolean value
     is false.

   - bpo-10131(149): Fixed deep copying of minidom documents.  Based on
     patch by Marian Ganisin.

   - bpo-7990(150): dir() on ElementTree.Element now lists properties:
     "tag", "text", "tail" and "attrib".  Original patch by Santoso
     Wijaya.

   - bpo-25725(151): Fixed a reference leak in pickle.loads() when
     unpickling invalid data including tuple instructions.

   - bpo-25663(152): In the Readline completer, avoid listing duplicate
     global names, and search the global namespace before searching
     builtins.

   - bpo-25688(153): Fixed file leak in ElementTree.iterparse() raising
     an error.

   - bpo-23914(154): Fixed SystemError raised by unpickler on broken
     pickle data.

   - bpo-25691(155): Fixed crash on deleting ElementTree.Element
     attributes.

   - bpo-25624(156): ZipFile now always writes a ZIP_STORED header for
     directory entries.  Patch by Dingyuan Wang.

   - bpo-25626(157): Change three zlib functions to accept sizes that
     fit in Py_ssize_t, but internally cap those sizes to UINT_MAX. This
     resolves a regression in 3.5 where GzipFile.read() failed to read
     chunks larger than 2 or 4 GiB. The change affects the
     zlib.Decompress.decompress() max_length parameter, the
     zlib.decompress() bufsize parameter, and the
     zlib.Decompress.flush() length parameter.

   - bpo-25583(158): Avoid incorrect errors raised by
     os.makedirs(exist_ok=True) when the OS gives priority to errors
     such as EACCES over EEXIST.

   - bpo-25593(159): Change semantics of EventLoop.stop() in asyncio.

   - bpo-6973(160): When we know a subprocess.Popen process has died, do
     not allow the send_signal(), terminate(), or kill() methods to do
     anything as they could potentially signal a different process.

   - bpo-23883(161): Added missing APIs to __all__ to match the
     documented APIs for the following modules: calendar, csv, enum,
     fileinput, ftplib, logging, optparse, tarfile, threading and wave.
     Also added a test.support.check__all__() helper.  Patches by Jacek
     Kołodziej, Mauro S. M. Rodrigues and Joel Taddei.

   - bpo-25590(162): In the Readline completer, only call getattr() once
     per attribute.  Also complete names of attributes such as
     properties and slots which are listed by dir() but not yet created
     on an instance.

   - bpo-25498(163): Fix a crash when garbage-collecting ctypes objects
     created by wrapping a memoryview.  This was a regression made in
     3.5a1.  Based on patch by Eryksun.

   - bpo-25584(164): Added "escape" to the __all__ list in the glob
     module.

   - bpo-25584(165): Fixed recursive glob() with patterns starting with
     ‘**’.

   - bpo-25446(166): Fix regression in smtplib's AUTH LOGIN support.

   - bpo-18010(167): Fix the pydoc web server's module search function
     to handle exceptions from importing packages.

   - bpo-25554(168): Got rid of circular references in regular
     expression parsing.

   - bpo-18973(169): Command-line interface of the calendar module now
     uses argparse instead of optparse.

   - bpo-25510(170): fileinput.FileInput.readline() now returns b''
     instead of '' at the end if the FileInput was opened with binary
     mode.  Patch by Ryosuke Ito.

   - bpo-25503(171): Fixed inspect.getdoc() for inherited docstrings of
     properties.  Original patch by John Mark Vandenberg.

   - bpo-25515(172): Always use os.urandom as a source of randomness in
     uuid.uuid4.

   - bpo-21827(173): Fixed textwrap.dedent() for the case when largest
     common whitespace is a substring of smallest leading whitespace.
     Based on patch by Robert Li.

   - bpo-25447(174): The lru_cache() wrapper objects now can be copied
     and pickled (by returning the original object unchanged).

   - bpo-25390(175): typing: Don't crash on Union[str, Pattern].

   - bpo-25441(176): asyncio: Raise error from drain() when socket is
     closed.

   - bpo-25410(177): Cleaned up and fixed minor bugs in C implementation
     of OrderedDict.

   - bpo-25411(178): Improved Unicode support in SMTPHandler through
     better use of the email package.  Thanks to user simon04 for the
     patch.

   - Move the imp module from a PendingDeprecationWarning to
     DeprecationWarning.

   - bpo-25407(179): Remove mentions of the formatter module being
     removed in Python 3.6.

   - bpo-25406(180): Fixed a bug in C implementation of
     OrderedDict.move_to_end() that caused segmentation fault or hang in
     iterating after moving several items to the start of ordered dict.

   - bpo-25382(181): pickletools.dis() now outputs implicit memo index
     for the MEMOIZE opcode.

   - bpo-25357(182): Add an optional newline parameter to
     binascii.b2a_base64().  base64.b64encode() uses it to avoid a
     memory copy.

   - bpo-24164(183): Objects that need calling ‘__new__’ with keyword
     arguments, can now be pickled using pickle protocols older than
     protocol version 4.

   - bpo-25364(184): zipfile now works in threads disabled builds.

   - bpo-25328(185): smtpd's SMTPChannel now correctly raises a
     ValueError if both decode_data and enable_SMTPUTF8 are set to true.

   - bpo-16099(186): RobotFileParser now supports Crawl-delay and
     Request-rate extensions.  Patch by Nikolay Bogoychev.

   - bpo-25316(187): distutils raises OSError instead of
     DistutilsPlatformError when MSVC is not installed.

   - bpo-25380(188): Fixed protocol for the STACK_GLOBAL opcode in
     pickletools.opcodes.

   - bpo-23972(189): Updates asyncio datagram create method allowing
     reuseport and reuseaddr socket options to be set prior to binding
     the socket.  Mirroring the existing asyncio create_server method
     the reuseaddr option for datagram sockets defaults to True if the
     O/S is 'posix' (except if the platform is Cygwin).  Patch by Chris
     Laws.

   - bpo-25304(190): Add asyncio.run_coroutine_threadsafe().  This lets
     you submit a coroutine to a loop from another thread, returning a
     concurrent.futures.Future.  By Vincent Michel.

   - bpo-25232(191): Fix CGIRequestHandler to split the query from the
     URL at the first question mark (?)  rather than the last.  Patch
     from Xiang Zhang.

   - bpo-24657(192): Prevent CGIRequestHandler from collapsing slashes
     in the query part of the URL as if it were a path.  Patch from
     Xiang Zhang.

   - bpo-25287(193): Don't add crypt.METHOD_CRYPT to crypt.methods if
     it's not supported.  Check if it is supported, it may not be
     supported on OpenBSD for example.

   - bpo-23600(194): Default implementation of tzinfo.fromutc() was
     returning wrong results in some cases.

   - bpo-25203(195): Failed readline.set_completer_delims() no longer
     left the module in inconsistent state.

   - bpo-25011(196): rlcompleter now omits private and special attribute
     names unless the prefix starts with underscores.

   - bpo-25209(197): rlcompleter now can add a space or a colon after
     completed keyword.

   - bpo-22241(198): timezone.utc name is now plain 'UTC', not
     'UTC-00:00'.

   - bpo-23517(199): fromtimestamp() and utcfromtimestamp() methods of
     datetime.datetime now round microseconds to nearest with ties going
     to nearest even integer (ROUND_HALF_EVEN), as round(float), instead
     of rounding towards -Infinity (ROUND_FLOOR).

   - bpo-23552(200): Timeit now warns when there is substantial (4x)
     variance between best and worst times.  Patch from Serhiy
     Storchaka.

   - bpo-24633(201): site-packages/README -> README.txt.

   - bpo-24879(202): help() and pydoc can now list named tuple fields in
     the order they were defined rather than alphabetically.  The
     ordering is determined by the _fields attribute if present.

   - bpo-24874(203): Improve speed of itertools.cycle() and make its
     pickle more compact.

   - Fix crash in itertools.cycle.__setstate__() when the first argument
     wasn't a list.

   - bpo-20059(204): urllib.parse raises ValueError on all invalid
     ports.  Patch by Martin Panter.

   - bpo-24360(205): Improve __repr__ of argparse.Namespace() for
     invalid identifiers.  Patch by Matthias Bussonnier.

   - bpo-23426(206): run_setup was broken in distutils.  Patch from
     Alexander Belopolsky.

   - bpo-13938(207): 2to3 converts StringTypes to a tuple.  Patch from
     Mark Hammond.

   - bpo-2091(208): open() accepted a 'U' mode string containing '+',
     but 'U' can only be used with 'r'.  Patch from Jeff Balogh and John
     O'Connor.

   - bpo-8585(209): improved tests for zipimporter2.  Patch from Mark
     Lawrence.

   - bpo-18622(210): unittest.mock.mock_open().reset_mock would recurse
     infinitely.  Patch from Nicola Palumbo and Laurent De Buyst.

   - bpo-24426(211): Fast searching optimization in regular expressions
     now works for patterns that starts with capturing groups.  Fast
     searching optimization now can't be disabled at compile time.

   - bpo-23661(212): unittest.mock side_effects can now be exceptions
     again.  This was a regression vs Python 3.4.  Patch from Ignacio
     Rossi

   - bpo-13248(213): Remove deprecated inspect.getmoduleinfo function.

   - bpo-25578(214): Fix (another) memory leak in
     SSLSocket.getpeercer().

   - bpo-25530(215): Disable the vulnerable SSLv3 protocol by default
     when creating ssl.SSLContext.

   - bpo-25569(216): Fix memory leak in SSLSocket.getpeercert().

   - bpo-25471(217): Sockets returned from accept() shouldn't appear to
     be nonblocking.

   - bpo-25319(218): When threading.Event is reinitialized, the
     underlying condition should use a regular lock rather than a
     recursive lock.

   - Skip getaddrinfo if host is already resolved.  Patch by A. Jesse
     Jiryu Davis.

   - bpo-26050(219): Add asyncio.StreamReader.readuntil() method.  Patch
     by Марк Коренберг.

   - bpo-25924(220): Avoid unnecessary serialization of getaddrinfo(3)
     calls on OS X versions 10.5 or higher.  Original patch by A. Jesse
     Jiryu Davis.

   - bpo-26406(221): Avoid unnecessary serialization of getaddrinfo(3)
     calls on current versions of OpenBSD and NetBSD. Patch by A. Jesse
     Jiryu Davis.

   - bpo-26848(222): Fix asyncio/subprocess.communicate() to handle
     empty input.  Patch by Jack O'Connor.

   - bpo-27040(223): Add loop.get_exception_handler method

   - bpo-27041(224): asyncio: Add loop.create_future method

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27057

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27014

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27031

   (4) https://bugs.python.org/issue?@action=redirect&bpo=14132

   (5) https://bugs.python.org/issue?@action=redirect&bpo=17214

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27033

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27034

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26870

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26039

   (10) https://bugs.python.org/issue?@action=redirect&bpo=26892

   (11) https://bugs.python.org/issue?@action=redirect&bpo=22274

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26807

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25745

   (14) https://bugs.python.org/issue?@action=redirect&bpo=26977

   (15) https://bugs.python.org/issue?@action=redirect&bpo=26002

   (16) https://bugs.python.org/issue?@action=redirect&bpo=25974

   (17) https://bugs.python.org/issue?@action=redirect&bpo=26996

   (18) https://peps.python.org/pep-0506/

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26881

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23815

   (21) https://bugs.python.org/issue?@action=redirect&bpo=17765

   (22) https://bugs.python.org/issue?@action=redirect&bpo=26873

   (23) https://bugs.python.org/issue?@action=redirect&bpo=26915

   (24) https://bugs.python.org/issue?@action=redirect&bpo=26711

   (25) https://bugs.python.org/issue?@action=redirect&bpo=24114

   (26) https://bugs.python.org/issue?@action=redirect&bpo=26864

   (27) https://bugs.python.org/issue?@action=redirect&bpo=24902

   (28) https://bugs.python.org/issue?@action=redirect&bpo=25788

   (29) https://bugs.python.org/issue?@action=redirect&bpo=26634

   (30) https://bugs.python.org/issue?@action=redirect&bpo=26804

   (31) https://bugs.python.org/issue?@action=redirect&bpo=26837

   (32) https://bugs.python.org/issue?@action=redirect&bpo=26041

   (33) https://bugs.python.org/issue?@action=redirect&bpo=26822

   (34) https://bugs.python.org/issue?@action=redirect&bpo=26733

   (35) https://bugs.python.org/issue?@action=redirect&bpo=26801

   (36) https://bugs.python.org/issue?@action=redirect&bpo=24838

   (37) https://bugs.python.org/issue?@action=redirect&bpo=26717

   (38) https://bugs.python.org/issue?@action=redirect&bpo=26782

   (39) https://bugs.python.org/issue?@action=redirect&bpo=26404

   (40) https://bugs.python.org/issue?@action=redirect&bpo=26735

   (41) https://bugs.python.org/issue?@action=redirect&bpo=26585

   (42) https://bugs.python.org/issue?@action=redirect&bpo=26685

   (43) https://bugs.python.org/issue?@action=redirect&bpo=16329

   (44) https://bugs.python.org/issue?@action=redirect&bpo=13952

   (45) https://bugs.python.org/issue?@action=redirect&bpo=26587

   (46) https://bugs.python.org/issue?@action=redirect&bpo=25609

   (47) https://bugs.python.org/issue?@action=redirect&bpo=26709

   (48) https://bugs.python.org/issue?@action=redirect&bpo=23735

   (49) https://bugs.python.org/issue?@action=redirect&bpo=25951

   (50) https://bugs.python.org/issue?@action=redirect&bpo=26586

   (51) https://bugs.python.org/issue?@action=redirect&bpo=26676

   (52) https://bugs.python.org/issue?@action=redirect&bpo=22854

   (53) https://bugs.python.org/issue?@action=redirect&bpo=26492

   (54) https://bugs.python.org/issue?@action=redirect&bpo=26641

   (55) https://bugs.python.org/issue?@action=redirect&bpo=25195

   (56) https://bugs.python.org/issue?@action=redirect&bpo=26644

   (57) https://bugs.python.org/issue?@action=redirect&bpo=23804

   (58) https://bugs.python.org/issue?@action=redirect&bpo=26616

   (59) https://bugs.python.org/issue?@action=redirect&bpo=26637

   (60) https://bugs.python.org/issue?@action=redirect&bpo=21925

   (61) https://bugs.python.org/issue?@action=redirect&bpo=23848

   (62) https://bugs.python.org/issue?@action=redirect&bpo=26530

   (63) https://bugs.python.org/issue?@action=redirect&bpo=26588

   (64) https://bugs.python.org/issue?@action=redirect&bpo=24266

   (65) https://bugs.python.org/issue?@action=redirect&bpo=26590

   (66) https://bugs.python.org/issue?@action=redirect&bpo=18787

   (67) https://bugs.python.org/issue?@action=redirect&bpo=26560

   (68) https://bugs.python.org/issue?@action=redirect&bpo=26567

   (69) https://bugs.python.org/issue?@action=redirect&bpo=26569

   (70) https://bugs.python.org/issue?@action=redirect&bpo=26499

   (71) https://bugs.python.org/issue?@action=redirect&bpo=25320

   (72) https://bugs.python.org/issue?@action=redirect&bpo=16181

   (73) https://bugs.python.org/issue?@action=redirect&bpo=26513

   (74) https://bugs.python.org/issue?@action=redirect&bpo=23718

   (75) https://bugs.python.org/issue?@action=redirect&bpo=26323

   (76) https://bugs.python.org/issue?@action=redirect&bpo=20589

   (77) https://bugs.python.org/issue?@action=redirect&bpo=26177

   (78) https://bugs.python.org/issue?@action=redirect&bpo=15068

   (79) https://bugs.python.org/issue?@action=redirect&bpo=19475

   (80) https://bugs.python.org/issue?@action=redirect&bpo=2202

   (81) https://bugs.python.org/issue?@action=redirect&bpo=26167

   (82) https://bugs.python.org/issue?@action=redirect&bpo=25718

   (83) https://bugs.python.org/issue?@action=redirect&bpo=26475

   (84) https://bugs.python.org/issue?@action=redirect&bpo=26482

   (85) https://bugs.python.org/issue?@action=redirect&bpo=26335

   (86) https://bugs.python.org/issue?@action=redirect&bpo=26457

   (87) https://bugs.python.org/issue?@action=redirect&bpo=26385

   (88) https://bugs.python.org/issue?@action=redirect&bpo=26402

   (89) https://bugs.python.org/issue?@action=redirect&bpo=25913

   (90) https://bugs.python.org/issue?@action=redirect&bpo=26186

   (91) https://bugs.python.org/issue?@action=redirect&bpo=26367

   (92) https://bugs.python.org/issue?@action=redirect&bpo=26309

   (93) https://bugs.python.org/issue?@action=redirect&bpo=23430

   (94) https://bugs.python.org/issue?@action=redirect&bpo=25995

   (95) https://bugs.python.org/issue?@action=redirect&bpo=25994

   (96) https://bugs.python.org/issue?@action=redirect&bpo=23992

   (97) https://bugs.python.org/issue?@action=redirect&bpo=26243

   (98) https://bugs.python.org/issue?@action=redirect&bpo=26117

   (99) https://bugs.python.org/issue?@action=redirect&bpo=25949

   (100) https://bugs.python.org/issue?@action=redirect&bpo=25911

   (101) https://bugs.python.org/issue?@action=redirect&bpo=26045

   (102) https://bugs.python.org/issue?@action=redirect&bpo=26039

   (103) https://bugs.python.org/issue?@action=redirect&bpo=12923

   (104) https://bugs.python.org/issue?@action=redirect&bpo=25945

   (105) https://bugs.python.org/issue?@action=redirect&bpo=26202

   (106) https://bugs.python.org/issue?@action=redirect&bpo=23076

   (107) https://bugs.python.org/issue?@action=redirect&bpo=19883

   (108) https://bugs.python.org/issue?@action=redirect&bpo=26227

   (109) https://bugs.python.org/issue?@action=redirect&bpo=26099

   (110) https://bugs.python.org/issue?@action=redirect&bpo=26147

   (111) https://bugs.python.org/issue?@action=redirect&bpo=25935

   (112) https://bugs.python.org/issue?@action=redirect&bpo=16620

   (113) https://bugs.python.org/issue?@action=redirect&bpo=26013

   (114) https://bugs.python.org/issue?@action=redirect&bpo=26129

   (115) https://bugs.python.org/issue?@action=redirect&bpo=25850

   (116) https://bugs.python.org/issue?@action=redirect&bpo=25822

   (117) https://bugs.python.org/issue?@action=redirect&bpo=22642

   (118) https://bugs.python.org/issue?@action=redirect&bpo=24705

   (119) https://bugs.python.org/issue?@action=redirect&bpo=26069

   (120) https://bugs.python.org/issue?@action=redirect&bpo=22138

   (121) https://bugs.python.org/issue?@action=redirect&bpo=25672

   (122) https://bugs.python.org/issue?@action=redirect&bpo=26012

   (123) https://bugs.python.org/issue?@action=redirect&bpo=24120

   (124) https://bugs.python.org/issue?@action=redirect&bpo=21815

   (125) https://bugs.python.org/issue?@action=redirect&bpo=25447

   (126) https://bugs.python.org/issue?@action=redirect&bpo=25971

   (127) https://bugs.python.org/issue?@action=redirect&bpo=25802

   (128) https://bugs.python.org/issue?@action=redirect&bpo=25928

   (129) https://bugs.python.org/issue?@action=redirect&bpo=25447

   (130) https://bugs.python.org/issue?@action=redirect&bpo=25768

   (131) https://bugs.python.org/issue?@action=redirect&bpo=24103

   (132) https://bugs.python.org/issue?@action=redirect&bpo=25860

   (133) https://bugs.python.org/issue?@action=redirect&bpo=25914

   (134) https://bugs.python.org/issue?@action=redirect&bpo=25869

   (135) https://bugs.python.org/issue?@action=redirect&bpo=25873

   (136) https://bugs.python.org/issue?@action=redirect&bpo=25902

   (137) https://bugs.python.org/issue?@action=redirect&bpo=22227

   (138) https://bugs.python.org/issue?@action=redirect&bpo=25638

   (139) https://bugs.python.org/issue?@action=redirect&bpo=25761

   (140) https://bugs.python.org/issue?@action=redirect&bpo=25717

   (141) https://bugs.python.org/issue?@action=redirect&bpo=24903

   (142) https://bugs.python.org/issue?@action=redirect&bpo=25764

   (143) https://bugs.python.org/issue?@action=redirect&bpo=25771

   (144) https://bugs.python.org/issue?@action=redirect&bpo=6478

   (145) https://bugs.python.org/issue?@action=redirect&bpo=14285

   (146) https://bugs.python.org/issue?@action=redirect&bpo=19771

   (147) https://bugs.python.org/issue?@action=redirect&bpo=25177

   (148) https://bugs.python.org/issue?@action=redirect&bpo=25718

   (149) https://bugs.python.org/issue?@action=redirect&bpo=10131

   (150) https://bugs.python.org/issue?@action=redirect&bpo=7990

   (151) https://bugs.python.org/issue?@action=redirect&bpo=25725

   (152) https://bugs.python.org/issue?@action=redirect&bpo=25663

   (153) https://bugs.python.org/issue?@action=redirect&bpo=25688

   (154) https://bugs.python.org/issue?@action=redirect&bpo=23914

   (155) https://bugs.python.org/issue?@action=redirect&bpo=25691

   (156) https://bugs.python.org/issue?@action=redirect&bpo=25624

   (157) https://bugs.python.org/issue?@action=redirect&bpo=25626

   (158) https://bugs.python.org/issue?@action=redirect&bpo=25583

   (159) https://bugs.python.org/issue?@action=redirect&bpo=25593

   (160) https://bugs.python.org/issue?@action=redirect&bpo=6973

   (161) https://bugs.python.org/issue?@action=redirect&bpo=23883

   (162) https://bugs.python.org/issue?@action=redirect&bpo=25590

   (163) https://bugs.python.org/issue?@action=redirect&bpo=25498

   (164) https://bugs.python.org/issue?@action=redirect&bpo=25584

   (165) https://bugs.python.org/issue?@action=redirect&bpo=25584

   (166) https://bugs.python.org/issue?@action=redirect&bpo=25446

   (167) https://bugs.python.org/issue?@action=redirect&bpo=18010

   (168) https://bugs.python.org/issue?@action=redirect&bpo=25554

   (169) https://bugs.python.org/issue?@action=redirect&bpo=18973

   (170) https://bugs.python.org/issue?@action=redirect&bpo=25510

   (171) https://bugs.python.org/issue?@action=redirect&bpo=25503

   (172) https://bugs.python.org/issue?@action=redirect&bpo=25515

   (173) https://bugs.python.org/issue?@action=redirect&bpo=21827

   (174) https://bugs.python.org/issue?@action=redirect&bpo=25447

   (175) https://bugs.python.org/issue?@action=redirect&bpo=25390

   (176) https://bugs.python.org/issue?@action=redirect&bpo=25441

   (177) https://bugs.python.org/issue?@action=redirect&bpo=25410

   (178) https://bugs.python.org/issue?@action=redirect&bpo=25411

   (179) https://bugs.python.org/issue?@action=redirect&bpo=25407

   (180) https://bugs.python.org/issue?@action=redirect&bpo=25406

   (181) https://bugs.python.org/issue?@action=redirect&bpo=25382

   (182) https://bugs.python.org/issue?@action=redirect&bpo=25357

   (183) https://bugs.python.org/issue?@action=redirect&bpo=24164

   (184) https://bugs.python.org/issue?@action=redirect&bpo=25364

   (185) https://bugs.python.org/issue?@action=redirect&bpo=25328

   (186) https://bugs.python.org/issue?@action=redirect&bpo=16099

   (187) https://bugs.python.org/issue?@action=redirect&bpo=25316

   (188) https://bugs.python.org/issue?@action=redirect&bpo=25380

   (189) https://bugs.python.org/issue?@action=redirect&bpo=23972

   (190) https://bugs.python.org/issue?@action=redirect&bpo=25304

   (191) https://bugs.python.org/issue?@action=redirect&bpo=25232

   (192) https://bugs.python.org/issue?@action=redirect&bpo=24657

   (193) https://bugs.python.org/issue?@action=redirect&bpo=25287

   (194) https://bugs.python.org/issue?@action=redirect&bpo=23600

   (195) https://bugs.python.org/issue?@action=redirect&bpo=25203

   (196) https://bugs.python.org/issue?@action=redirect&bpo=25011

   (197) https://bugs.python.org/issue?@action=redirect&bpo=25209

   (198) https://bugs.python.org/issue?@action=redirect&bpo=22241

   (199) https://bugs.python.org/issue?@action=redirect&bpo=23517

   (200) https://bugs.python.org/issue?@action=redirect&bpo=23552

   (201) https://bugs.python.org/issue?@action=redirect&bpo=24633

   (202) https://bugs.python.org/issue?@action=redirect&bpo=24879

   (203) https://bugs.python.org/issue?@action=redirect&bpo=24874

   (204) https://bugs.python.org/issue?@action=redirect&bpo=20059

   (205) https://bugs.python.org/issue?@action=redirect&bpo=24360

   (206) https://bugs.python.org/issue?@action=redirect&bpo=23426

   (207) https://bugs.python.org/issue?@action=redirect&bpo=13938

   (208) https://bugs.python.org/issue?@action=redirect&bpo=2091

   (209) https://bugs.python.org/issue?@action=redirect&bpo=8585

   (210) https://bugs.python.org/issue?@action=redirect&bpo=18622

   (211) https://bugs.python.org/issue?@action=redirect&bpo=24426

   (212) https://bugs.python.org/issue?@action=redirect&bpo=23661

   (213) https://bugs.python.org/issue?@action=redirect&bpo=13248

   (214) https://bugs.python.org/issue?@action=redirect&bpo=25578

   (215) https://bugs.python.org/issue?@action=redirect&bpo=25530

   (216) https://bugs.python.org/issue?@action=redirect&bpo=25569

   (217) https://bugs.python.org/issue?@action=redirect&bpo=25471

   (218) https://bugs.python.org/issue?@action=redirect&bpo=25319

   (219) https://bugs.python.org/issue?@action=redirect&bpo=26050

   (220) https://bugs.python.org/issue?@action=redirect&bpo=25924

   (221) https://bugs.python.org/issue?@action=redirect&bpo=26406

   (222) https://bugs.python.org/issue?@action=redirect&bpo=26848

   (223) https://bugs.python.org/issue?@action=redirect&bpo=27040

   (224) https://bugs.python.org/issue?@action=redirect&bpo=27041


File: python.info,  Node: IDLE<56>,  Next: Documentation<66>,  Prev: Library<77>,  Up: Python 3 6 0 alpha 1

1.23.86.4 IDLE
..............

   - bpo-20640(1): Add tests for idlelib.configHelpSourceEdit.  Patch by
     Saimadhav Heblikar.

   - In the 'IDLE-console differences' section of the IDLE doc, clarify
     how running with IDLE affects sys.modules and the standard streams.

   - bpo-25507(2): fix incorrect change in IOBinding that prevented
     printing.  Augment IOBinding htest to include all major IOBinding
     functions.

   - bpo-25905(3): Revert unwanted conversion of ' to ’ RIGHT SINGLE
     QUOTATION MARK in README.txt and open this and NEWS.txt with
     'ascii'.  Re-encode CREDITS.txt to utf-8 and open it with 'utf-8'.

   - bpo-15348(4): Stop the debugger engine (normally in a user process)
     before closing the debugger window (running in the IDLE process).
     This prevents the RuntimeErrors that were being caught and ignored.

   - bpo-24455(5): Prevent IDLE from hanging when a) closing the shell
     while the debugger is active (15347); b) closing the debugger with
     the [X] button (15348); and c) activating the debugger when already
     active (24455).  The patch by Mark Roseman does this by making two
     changes.  1.  Suspend and resume the gui.interaction method with
     the tcl vwait mechanism intended for this purpose (instead of
     root.mainloop & .quit).  2.  In gui.run, allow any existing
     interaction to terminate first.

   - Change 'The program' to 'Your program' in an IDLE 'kill program?'
     message to make it clearer that the program referred to is the
     currently running user program, not IDLE itself.

   - bpo-24750(6): Improve the appearance of the IDLE editor window
     status bar.  Patch by Mark Roseman.

   - bpo-25313(7): Change the handling of new built-in text color themes
     to better address the compatibility problem introduced by the
     addition of IDLE Dark.  Consistently use the revised
     idleConf.CurrentTheme everywhere in idlelib.

   - bpo-24782(8): Extension configuration is now a tab in the IDLE
     Preferences dialog rather than a separate dialog.  The former tabs
     are now a sorted list.  Patch by Mark Roseman.

   - bpo-22726(9): Re-activate the config dialog help button with some
     content about the other buttons and the new IDLE Dark theme.

   - bpo-24820(10): IDLE now has an 'IDLE Dark' built-in text color
     theme.  It is more or less IDLE Classic inverted, with a cobalt
     blue background.  Strings, comments, keywords, ...  are still
     green, red, orange, ...  .  To use it with IDLEs released before
     November 2015, hit the 'Save as New Custom Theme' button and enter
     a new name, such as 'Custom Dark'.  The custom theme will work with
     any IDLE release, and can be modified.

   - bpo-25224(11): README.txt is now an idlelib index for IDLE
     developers and curious users.  The previous user content is now in
     the IDLE doc chapter.  'IDLE' now means 'Integrated Development and
     Learning Environment'.

   - bpo-24820(12): Users can now set breakpoint colors in Settings ->
     Custom Highlighting.  Original patch by Mark Roseman.

   - bpo-24972(13): Inactive selection background now matches active
     selection background, as configured by users, on all systems.
     Found items are now always highlighted on Windows.  Initial patch
     by Mark Roseman.

   - bpo-24570(14): Idle: make calltip and completion boxes appear on
     Macs affected by a tk regression.  Initial patch by Mark Roseman.

   - bpo-24988(15): Idle ScrolledList context menus (used in debugger)
     now work on Mac Aqua.  Patch by Mark Roseman.

   - bpo-24801(16): Make right-click for context menu work on Mac Aqua.
     Patch by Mark Roseman.

   - bpo-25173(17): Associate tkinter messageboxes with a specific
     widget.  For Mac OSX, make them a 'sheet'.  Patch by Mark Roseman.

   - bpo-25198(18): Enhance the initial html viewer now used for Idle
     Help.  Properly indent fixed-pitch text (patch by Mark Roseman).
     Give code snippet a very Sphinx-like light blueish-gray background.
     Re-use initial width and height set by users for shell and editor.
     When the Table of Contents (TOC) menu is used, put the section
     header at the top of the screen.

   - bpo-25225(19): Condense and rewrite Idle doc section on text
     colors.

   - bpo-21995(20): Explain some differences between IDLE and console
     Python.

   - bpo-22820(21): Explain need for 'print' when running file from Idle
     editor.

   - bpo-25224(22): Doc: augment Idle feature list and no-subprocess
     section.

   - bpo-25219(23): Update doc for Idle command line options.  Some were
     missing and notes were not correct.

   - bpo-24861(24): Most of idlelib is private and subject to change.
     Use idleib.idle.* to start Idle.  See idlelib.__init__.__doc__.

   - bpo-25199(25): Idle: add synchronization comments for future
     maintainers.

   - bpo-16893(26): Replace help.txt with help.html for Idle doc
     display.  The new idlelib/help.html is rstripped
     Doc/build/html/library/idle.html.  It looks better than help.txt
     and will better document Idle as released.  The tkinter html viewer
     that works for this file was written by Rose Roseman.  The now
     unused EditorWindow.HelpDialog class and helt.txt file are
     deprecated.

   - bpo-24199(27): Deprecate unused idlelib.idlever with possible
     removal in 3.6.

   - bpo-24790(28): Remove extraneous code (which also create 2 & 3
     conflicts).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20640

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25507

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25905

   (4) https://bugs.python.org/issue?@action=redirect&bpo=15348

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24455

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24750

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25313

   (8) https://bugs.python.org/issue?@action=redirect&bpo=24782

   (9) https://bugs.python.org/issue?@action=redirect&bpo=22726

   (10) https://bugs.python.org/issue?@action=redirect&bpo=24820

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25224

   (12) https://bugs.python.org/issue?@action=redirect&bpo=24820

   (13) https://bugs.python.org/issue?@action=redirect&bpo=24972

   (14) https://bugs.python.org/issue?@action=redirect&bpo=24570

   (15) https://bugs.python.org/issue?@action=redirect&bpo=24988

   (16) https://bugs.python.org/issue?@action=redirect&bpo=24801

   (17) https://bugs.python.org/issue?@action=redirect&bpo=25173

   (18) https://bugs.python.org/issue?@action=redirect&bpo=25198

   (19) https://bugs.python.org/issue?@action=redirect&bpo=25225

   (20) https://bugs.python.org/issue?@action=redirect&bpo=21995

   (21) https://bugs.python.org/issue?@action=redirect&bpo=22820

   (22) https://bugs.python.org/issue?@action=redirect&bpo=25224

   (23) https://bugs.python.org/issue?@action=redirect&bpo=25219

   (24) https://bugs.python.org/issue?@action=redirect&bpo=24861

   (25) https://bugs.python.org/issue?@action=redirect&bpo=25199

   (26) https://bugs.python.org/issue?@action=redirect&bpo=16893

   (27) https://bugs.python.org/issue?@action=redirect&bpo=24199

   (28) https://bugs.python.org/issue?@action=redirect&bpo=24790


File: python.info,  Node: Documentation<66>,  Next: Tests<70>,  Prev: IDLE<56>,  Up: Python 3 6 0 alpha 1

1.23.86.5 Documentation
.......................

   - bpo-26736(1): Used HTTPS for external links in the documentation if
     possible.

   - bpo-6953(2): Rework the Readline module documentation to group
     related functions together, and add more details such as what
     underlying Readline functions and variables are accessed.

   - bpo-23606(3): Adds note to ctypes documentation regarding
     cdll.msvcrt.

   - bpo-24952(4): Clarify the default size argument of stack_size() in
     the "threading" and "_thread" modules.  Patch from Mattip.

   - bpo-26014(5): Update 3.x packaging documentation: * "See also"
     links to the new docs are now provided in the legacy pages * links
     to setuptools documentation have been updated

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26736

   (2) https://bugs.python.org/issue?@action=redirect&bpo=6953

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23606

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24952

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26014


File: python.info,  Node: Tests<70>,  Next: Build<76>,  Prev: Documentation<66>,  Up: Python 3 6 0 alpha 1

1.23.86.6 Tests
...............

   - bpo-21916(1): Added tests for the turtle module.  Patch by ingrid,
     Gregory Loyse and Jelle Zijlstra.

   - bpo-26295(2): When using "python3 -m test -testdir=TESTDIR",
     regrtest doesn't add "test."  prefix to test module names.

   - bpo-26523(3): The multiprocessing thread pool
     (multiprocessing.dummy.Pool) was untested.

   - bpo-26015(4): Added new tests for pickling iterators of mutable
     sequences.

   - bpo-26325(5): Added test.support.check_no_resource_warning() to
     check that no ResourceWarning is emitted.

   - bpo-25940(6): Changed test_ssl to use its internal local server
     more.  This avoids relying on svn.python.org, which recently
     changed root certificate.

   - bpo-25616(7): Tests for OrderedDict are extracted from
     test_collections into separate file test_ordered_dict.

   - bpo-25449(8): Added tests for OrderedDict subclasses.

   - bpo-25188(9): Add -P/-pgo to test.regrtest to suppress error output
     when running the test suite for the purposes of a PGO build.
     Initial patch by Alecsandru Patrascu.

   - bpo-22806(10): Add ‘python -m test --list-tests’ command to list
     tests.

   - bpo-18174(11): ‘python -m test --huntrleaks ...’ now also checks
     for leak of file descriptors.  Patch written by Richard Oudkerk.

   - bpo-25260(12): Fix ‘python -m test --coverage’ on Windows.  Remove
     the list of ignored directories.

   - ‘PCbuild\rt.bat’ now accepts an unlimited number of arguments to
     pass along to regrtest.py.  Previously there was a limit of 9.

   - bpo-26583(13): Skip test_timestamp_overflow in test_import if
     bytecode files cannot be written.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21916

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26295

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26523

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26015

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26325

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25940

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25616

   (8) https://bugs.python.org/issue?@action=redirect&bpo=25449

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25188

   (10) https://bugs.python.org/issue?@action=redirect&bpo=22806

   (11) https://bugs.python.org/issue?@action=redirect&bpo=18174

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25260

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26583


File: python.info,  Node: Build<76>,  Next: Windows<66>,  Prev: Tests<70>,  Up: Python 3 6 0 alpha 1

1.23.86.7 Build
...............

   - bpo-21277(1): Don't try to link _ctypes with a ffi_convenience
     library.

   - bpo-26884(2): Fix linking extension modules for cross builds.
     Patch by Xavier de Gaye.

   - bpo-26932(3): Fixed support of RTLD_* constants defined as enum
     values, not via macros (in particular on Android).  Patch by Chi
     Hsuan Yen.

   - bpo-22359(4): Disable the rules for running _freeze_importlib and
     pgen when cross-compiling.  The output of these programs is
     normally saved with the source code anyway, and is still
     regenerated when doing a native build.  Patch by Xavier de Gaye.

   - bpo-21668(5): Link audioop, _datetime, _ctypes_test modules to
     libm, except on Mac OS X. Patch written by Chi Hsuan Yen.

   - bpo-25702(6): A -with-lto configure option has been added that will
     enable link time optimizations at build time during a make
     profile-opt.  Some compilers and toolchains are known to not
     produce stable code when using LTO, be sure to test things
     thoroughly before relying on it.  It can provide a few % speed up
     over profile-opt alone.

   - bpo-26624(7): Adds validation of ucrtbase[d].dll version with
     warning for old versions.

   - bpo-17603(8): Avoid error about nonexistent fileblocks.o file by
     using a lower-level check for st_blocks in struct stat.

   - bpo-26079(9): Fixing the build output folder for tix-8.4.3.6.
     Patch by Bjoern Thiel.

   - bpo-26465(10): Update Windows builds to use OpenSSL 1.0.2g.

   - bpo-25348(11): Added ‘--pgo’ and ‘--pgo-job’ arguments to
     ‘PCbuild\build.bat’ for building with Profile-Guided Optimization.
     The old ‘PCbuild\build_pgo.bat’ script is removed.

   - bpo-25827(12): Add support for building with ICC to ‘configure’,
     including a new ‘--with-icc’ flag.

   - bpo-25696(13): Fix installation of Python on UNIX with make -j9.

   - bpo-24986(14): It is now possible to build Python on Windows
     without errors when external libraries are not available.

   - bpo-24421(15): Compile Modules/_math.c once, before building
     extensions.  Previously it could fail to compile properly if the
     math and cmath builds were concurrent.

   - bpo-26465(16): Update OS X 10.5+ 32-bit-only installer to build and
     link with OpenSSL 1.0.2g.

   - bpo-26268(17): Update Windows builds to use OpenSSL 1.0.2f.

   - bpo-25136(18): Support Apple Xcode 7's new textual SDK stub
     libraries.

   - bpo-24324(19): Do not enable unreachable code warnings when using
     gcc as the option does not work correctly in older versions of gcc
     and has been silently removed as of gcc-4.5.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21277

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26884

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26932

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22359

   (5) https://bugs.python.org/issue?@action=redirect&bpo=21668

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25702

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26624

   (8) https://bugs.python.org/issue?@action=redirect&bpo=17603

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26079

   (10) https://bugs.python.org/issue?@action=redirect&bpo=26465

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25348

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25827

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25696

   (14) https://bugs.python.org/issue?@action=redirect&bpo=24986

   (15) https://bugs.python.org/issue?@action=redirect&bpo=24421

   (16) https://bugs.python.org/issue?@action=redirect&bpo=26465

   (17) https://bugs.python.org/issue?@action=redirect&bpo=26268

   (18) https://bugs.python.org/issue?@action=redirect&bpo=25136

   (19) https://bugs.python.org/issue?@action=redirect&bpo=24324


File: python.info,  Node: Windows<66>,  Next: Tools/Demos<41>,  Prev: Build<76>,  Up: Python 3 6 0 alpha 1

1.23.86.8 Windows
.................

   - bpo-27053(1): Updates make_zip.py to correctly generate library ZIP
     file.

   - bpo-26268(2): Update the prepare_ssl.py script to handle OpenSSL
     releases that don't include the contents of the include directory
     (that is, 1.0.2e and later).

   - bpo-26071(3): bdist_wininst created binaries fail to start and find
     32bit Python

   - bpo-26073(4): Update the list of magic numbers in launcher

   - bpo-26065(5): Excludes venv from library when generating embeddable
     distro.

   - bpo-25022(6): Removed very outdated PC/example_nt/ directory.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27053

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26268

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26071

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26073

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26065

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25022


File: python.info,  Node: Tools/Demos<41>,  Next: C API<66>,  Prev: Windows<66>,  Up: Python 3 6 0 alpha 1

1.23.86.9 Tools/Demos
.....................

   - bpo-26799(1): Fix python-gdb.py: don't get C types once when the
     Python code is loaded, but get C types on demand.  The C types can
     change if python-gdb.py is loaded before the Python executable.
     Patch written by Thomas Ilsche.

   - bpo-26271(2): Fix the Freeze tool to properly use flags passed
     through configure.  Patch by Daniel Shaulov.

   - bpo-26489(3): Add dictionary unpacking support to
     Tools/parser/unparse.py.  Patch by Guo Ci Teo.

   - bpo-26316(4): Fix variable name typo in Argument Clinic.

   - bpo-25440(5): Fix output of python-config -extension-suffix.

   - bpo-25154(6): The pyvenv script has been deprecated in favour of
     ‘python3 -m venv’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26799

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26271

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26489

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26316

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25440

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25154


File: python.info,  Node: C API<66>,  Prev: Tools/Demos<41>,  Up: Python 3 6 0 alpha 1

1.23.86.10 C API
................

   - bpo-26312(1): SystemError is now raised in all programming bugs
     with using PyArg_ParseTupleAndKeywords().  RuntimeError did raised
     before in some programming bugs.

   - bpo-26198(2): ValueError is now raised instead of TypeError on
     buffer overflow in parsing "es#" and "et#" format units.
     SystemError is now raised instead of TypeError on programmatical
     error in parsing format string.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26312

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26198


File: python.info,  Node: Python 3 5 5 final,  Next: Python 3 5 5 release candidate 1,  Prev: Python 3 6 0 alpha 1,  Up: 変更履歴

1.23.87 Python 3.5.5 final
--------------------------

'Release date: 2018-02-04'

There were no new changes in version 3.5.5.


File: python.info,  Node: Python 3 5 5 release candidate 1,  Next: Python 3 5 4 final,  Prev: Python 3 5 5 final,  Up: 変更履歴

1.23.88 Python 3.5.5 release candidate 1
----------------------------------------

'Release date: 2018-01-23'

* Menu:

* Security: Security<45>.
* Core and Builtins: Core and Builtins<79>.
* Library: Library<78>.


File: python.info,  Node: Security<45>,  Next: Core and Builtins<79>,  Up: Python 3 5 5 release candidate 1

1.23.88.1 Security
..................

   - bpo-32551(1): The ‘sys.path[0]’ initialization change for
     bpo-29139(2) caused a regression by revealing an inconsistency in
     how sys.path is initialized when executing ‘__main__’ from a
     zipfile, directory, or other import location.  This is considered a
     potential security issue, as it may lead to privileged processes
     unexpectedly loading code from user controlled directories in
     situations where that was not previously the case.  The interpreter
     now consistently avoids ever adding the import location's parent
     directory to ‘sys.path’, and ensures no other ‘sys.path’ entries
     are inadvertently modified when inserting the import location named
     on the command line.  (Originally reported as bpo-29723(3) against
     Python 3.6rc1, but it was missed at the time that the then upcoming
     Python 3.5.4 release would also be affected)

   - bpo-30657(4): Fixed possible integer overflow in
     PyBytes_DecodeEscape, CVE 2017-1000158(5).  Original patch by Jay
     Bosamiya; rebased to Python 3 by Miro Hrončok.

   - bpo-30947(6): Upgrade libexpat embedded copy from version 2.2.1 to
     2.2.3 to get security fixes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32551

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29139

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29723

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30657

   (5) https://www.cve.org/CVERecord?id=CVE-2017-1000158

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30947


File: python.info,  Node: Core and Builtins<79>,  Next: Library<78>,  Prev: Security<45>,  Up: Python 3 5 5 release candidate 1

1.23.88.2 Core and Builtins
...........................

   - bpo-31095(1): Fix potential crash during GC caused by ‘tp_dealloc’
     which doesn't call ‘PyObject_GC_UnTrack()’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=31095


File: python.info,  Node: Library<78>,  Prev: Core and Builtins<79>,  Up: Python 3 5 5 release candidate 1

1.23.88.3 Library
.................

   - bpo-32072(1): Fixed issues with binary plists: Fixed saving
     bytearrays.  Identical objects will be saved only once.  Equal
     references will be load as identical objects.  Added support for
     saving and loading recursive data structures.

   - bpo-31170(2): expat: Update libexpat from 2.2.3 to 2.2.4.  Fix
     copying of partial characters for UTF-8 input (libexpat bug 115):
     ‘https://github.com/libexpat/libexpat/issues/115’

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=32072

   (2) https://bugs.python.org/issue?@action=redirect&bpo=31170


File: python.info,  Node: Python 3 5 4 final,  Next: Python 3 5 4 release candidate 1,  Prev: Python 3 5 5 release candidate 1,  Up: 変更履歴

1.23.89 Python 3.5.4 final
--------------------------

'Release date: 2017-08-07'

* Menu:

* Library: Library<79>.


File: python.info,  Node: Library<79>,  Up: Python 3 5 4 final

1.23.89.1 Library
.................

   - bpo-30119(1): ftplib.FTP.putline() now throws ValueError on
     commands that contains CR or LF. Patch by Donghee Na.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30119


File: python.info,  Node: Python 3 5 4 release candidate 1,  Next: Python 3 5 3 final,  Prev: Python 3 5 4 final,  Up: 変更履歴

1.23.90 Python 3.5.4 release candidate 1
----------------------------------------

'Release date: 2017-07-23'

* Menu:

* Security: Security<46>.
* Core and Builtins: Core and Builtins<80>.
* Library: Library<80>.
* Documentation: Documentation<67>.
* Tests: Tests<71>.
* Build: Build<77>.
* Windows: Windows<67>.
* C API: C API<67>.


File: python.info,  Node: Security<46>,  Next: Core and Builtins<80>,  Up: Python 3 5 4 release candidate 1

1.23.90.1 Security
..................

   - bpo-30730(1): Prevent environment variables injection in subprocess
     on Windows.  Prevent passing other environment variables and
     command arguments.

   - bpo-30694(2): Upgrade expat copy from 2.2.0 to 2.2.1 to get fixes
     of multiple security vulnerabilities including: CVE 2017-9233(3)
     (External entity infinite loop DoS), CVE 2016-9063(4) (Integer
     overflow, re-fix), CVE 2016-0718(5) (Fix regression bugs from
     2.2.0's fix to CVE 2016-0718(6)) and CVE 2012-0876(7) (Counter hash
     flooding with SipHash).  Note: the CVE 2016-5300(8) (Use
     os-specific entropy sources like getrandom) doesn't impact Python,
     since Python already gets entropy from the OS to set the expat
     secret using ‘XML_SetHashSalt()’.

   - bpo-30500(9): Fix urllib.parse.splithost() to correctly parse
     fragments.  For example, ‘splithost('//127.0.0.1#@evil.com/')’ now
     correctly returns the ‘127.0.0.1’ host, instead of treating
     ‘@evil.com’ as the host in an authentication (‘login@host’).

   - bpo-29591(10): Update expat copy from 2.1.1 to 2.2.0 to get fixes
     of CVE 2016-0718(11) and CVE 2016-4472(12).  See
     ‘https://sourceforge.net/p/expat/bugs/537/’ for more information.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30730

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30694

   (3) https://www.cve.org/CVERecord?id=CVE-2017-9233

   (4) https://www.cve.org/CVERecord?id=CVE-2016-9063

   (5) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (6) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (7) https://www.cve.org/CVERecord?id=CVE-2012-0876

   (8) https://www.cve.org/CVERecord?id=CVE-2016-5300

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30500

   (10) https://bugs.python.org/issue?@action=redirect&bpo=29591

   (11) https://www.cve.org/CVERecord?id=CVE-2016-0718

   (12) https://www.cve.org/CVERecord?id=CVE-2016-4472


File: python.info,  Node: Core and Builtins<80>,  Next: Library<80>,  Prev: Security<46>,  Up: Python 3 5 4 release candidate 1

1.23.90.2 Core and Builtins
...........................

   - bpo-30876(1): Relative import from unloaded package now reimports
     the package instead of failing with SystemError.  Relative import
     from non-package now fails with ImportError rather than
     SystemError.

   - bpo-30765(2): Avoid blocking in pthread_mutex_lock() when
     PyThread_acquire_lock() is asked not to block.

   - bpo-27945(3): Fixed various segfaults with dict when input
     collections are mutated during searching, inserting or comparing.
     Based on patches by Duane Griffin and Tim Mitchell.

   - bpo-25794(4): Fixed type.__setattr__() and type.__delattr__() for
     non-interned attribute names.  Based on patch by Eryk Sun.

   - bpo-29935(5): Fixed error messages in the index() method of tuple,
     list and deque when pass indices of wrong type.

   - bpo-28876(6): ‘bool(range)’ works even if ‘len(range)’ raises *note
     OverflowError: 84e.

   - bpo-29600(7): Fix wrapping coroutine return values in
     StopIteration.

   - bpo-29537(8): Restore runtime compatibility with bytecode files
     generated by CPython 3.5.0 to 3.5.2, and adjust the eval loop to
     avoid the problems that could be caused by the malformed variant of
     the BUILD_MAP_UNPACK_WITH_CALL opcode that they may contain.  Patch
     by Petr Viktorin, Serhiy Storchaka, and Nick Coghlan.

   - bpo-28598(9): Support __rmod__ for subclasses of str being called
     before str.__mod__.  Patch by Martijn Pieters.

   - bpo-29602(10): Fix incorrect handling of signed zeros in complex
     constructor for complex subclasses and for inputs having a
     __complex__ method.  Patch by Serhiy Storchaka.

   - bpo-29347(11): Fixed possibly dereferencing undefined pointers when
     creating weakref objects.

   - bpo-29438(12): Fixed use-after-free problem in key sharing dict.

   - bpo-29319(13): Prevent RunMainFromImporter overwriting sys.path[0].

   - bpo-29337(14): Fixed possible BytesWarning when compare the code
     objects.  Warnings could be emitted at compile time.

   - bpo-29478(15): If max_line_length=None is specified while using the
     Compat32 policy, it is no longer ignored.  Patch by Mircea Cosbuc.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30876

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30765

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27945

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25794

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29935

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28876

   (7) https://bugs.python.org/issue?@action=redirect&bpo=29600

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29537

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28598

   (10) https://bugs.python.org/issue?@action=redirect&bpo=29602

   (11) https://bugs.python.org/issue?@action=redirect&bpo=29347

   (12) https://bugs.python.org/issue?@action=redirect&bpo=29438

   (13) https://bugs.python.org/issue?@action=redirect&bpo=29319

   (14) https://bugs.python.org/issue?@action=redirect&bpo=29337

   (15) https://bugs.python.org/issue?@action=redirect&bpo=29478


File: python.info,  Node: Library<80>,  Next: Documentation<67>,  Prev: Core and Builtins<80>,  Up: Python 3 5 4 release candidate 1

1.23.90.3 Library
.................

   - bpo-29403(1): Fix ‘unittest.mock’'s autospec to not fail on
     method-bound builtin functions.  Patch by Aaron Gallagher.

   - bpo-30961(2): Fix decrementing a borrowed reference in tracemalloc.

   - bpo-30886(3): Fix multiprocessing.Queue.join_thread(): it now waits
     until the thread completes, even if the thread was started by the
     same process which created the queue.

   - bpo-29854(4): Fix segfault in readline when using readline's
     history-size option.  Patch by Nir Soffer.

   - bpo-30807(5): signal.setitimer() may disable the timer when passed
     a tiny value.  Tiny values (such as 1e-6) are valid non-zero values
     for setitimer(), which is specified as taking
     microsecond-resolution intervals.  However, on some platform, our
     conversion routine could convert 1e-6 into a zero interval,
     therefore disabling the timer instead of (re-)scheduling it.

   - bpo-30441(6): Fix bug when modifying os.environ while iterating
     over it

   - bpo-30532(7): Fix email header value parser dropping folding white
     space in certain cases.

   - bpo-29169(8): Update zlib to 1.2.11.

   - bpo-30879(9): os.listdir() and os.scandir() now emit bytes names
     when called with bytes-like argument.

   - bpo-30746(10): Prohibited the '=' character in environment variable
     names in ‘os.putenv()’ and ‘os.spawn*()’.

   - bpo-29755(11): Fixed the lgettext() family of functions in the
     gettext module.  They now always return bytes.

   - bpo-30645(12): Fix path calculation in imp.load_package(), fixing
     it for cases when a package is only shipped with bytecodes.  Patch
     by Alexandru Ardelean.

   - bpo-23890(13): unittest.TestCase.assertRaises() now manually breaks
     a reference cycle to not keep objects alive longer than expected.

   - bpo-30149(14): inspect.signature() now supports callables with
     variable-argument parameters wrapped with partialmethod.  Patch by
     Donghee Na.

   - bpo-29931(15): Fixed comparison check for ipaddress.ip_interface
     objects.  Patch by Sanjay Sundaresan.

   - bpo-24484(16): Avoid race condition in multiprocessing cleanup.

   - bpo-28994(17): The traceback no longer displayed for SystemExit
     raised in a callback registered by atexit.

   - bpo-30508(18): Don't log exceptions if Task/Future "cancel()"
     method was called.

   - bpo-28556(19): Updates to typing module: Add generic
     AsyncContextManager, add support for ContextManager on all
     versions.  Original PRs by Jelle Zijlstra and Ivan Levkivskyi

   - bpo-29870(20): Fix ssl sockets leaks when connection is aborted in
     asyncio/ssl implementation.  Patch by Michaël Sghaïer.

   - bpo-29743(21): Closing transport during handshake process leaks
     open socket.  Patch by Nikolay Kim

   - bpo-27585(22): Fix waiter cancellation in asyncio.Lock.  Patch by
     Mathieu Sornay.

   - bpo-30418(23): On Windows, subprocess.Popen.communicate() now also
     ignore EINVAL on stdin.write() if the child process is still
     running but closed the pipe.

   - bpo-30378(24): Fix the problem that logging.handlers.SysLogHandler
     cannot handle IPv6 addresses.

   - bpo-29960(25): Preserve generator state when
     _random.Random.setstate() raises an exception.  Patch by Bryan
     Olson.

   - bpo-30414(26): multiprocessing.Queue._feed background running
     thread do not break from main loop on exception.

   - bpo-30003(27): Fix handling escape characters in HZ codec.  Based
     on patch by Ma Lin.

   - bpo-30301(28): Fix AttributeError when using SimpleQueue.empty()
     under 'spawn' and 'forkserver' start methods.

   - bpo-30329(29): imaplib and poplib now catch the Windows socket
     WSAEINVAL error (code 10022) on shutdown(SHUT_RDWR): An invalid
     operation was attempted.  This error occurs sometimes on SSL
     connections.

   - bpo-30375(30): Warnings emitted when compile a regular expression
     now always point to the line in the user code.  Previously they
     could point into inners of the re module if emitted from inside of
     groups or conditionals.

   - bpo-30048(31): Fixed ‘Task.cancel()’ can be ignored when the task
     is running coroutine and the coroutine returned without any more
     ‘await’.

   - bpo-29990(32): Fix range checking in GB18030 decoder.  Original
     patch by Ma Lin.

   - bpo-26293(33): Change resulted because of zipfile breakage.  (See
     also: bpo-29094(34))

   - bpo-30243(35): Removed the __init__ methods of _json's scanner and
     encoder.  Misusing them could cause memory leaks or crashes.  Now
     scanner and encoder objects are completely initialized in the
     __new__ methods.

   - bpo-30185(36): Avoid KeyboardInterrupt tracebacks in forkserver
     helper process when Ctrl-C is received.

   - bpo-28556(37): Various updates to typing module: add
     typing.NoReturn type, use WrapperDescriptorType, minor bug-fixes.
     Original PRs by Jim Fasarakis-Hilliard and Ivan Levkivskyi.

   - bpo-30205(38): Fix getsockname() for unbound AF_UNIX sockets on
     Linux.

   - bpo-30070(39): Fixed leaks and crashes in errors handling in the
     parser module.

   - bpo-30061(40): Fixed crashes in IOBase methods __next__() and
     readlines() when readline() or __next__() respectively return
     non-sizeable object.  Fixed possible other errors caused by not
     checking results of PyObject_Size(), PySequence_Size(), or
     PyMapping_Size().

   - bpo-30068(41): _io._IOBase.readlines will check if it's closed
     first when hint is present.

   - bpo-29694(42): Fixed race condition in pathlib mkdir with flags
     parents=True.  Patch by Armin Rigo.

   - bpo-29692(43): Fixed arbitrary unchaining of RuntimeError
     exceptions in contextlib.contextmanager.  Patch by Siddharth
     Velankar.

   - bpo-29998(44): Pickling and copying ImportError now preserves name
     and path attributes.

   - bpo-29942(45): Fix a crash in itertools.chain.from_iterable when
     encountering long runs of empty iterables.

   - bpo-27863(46): Fixed multiple crashes in ElementTree caused by race
     conditions and wrong types.

   - bpo-28699(47): Fixed a bug in pools in multiprocessing.pool that
     raising an exception at the very first of an iterable may swallow
     the exception or make the program hang.  Patch by Davin Potts and
     Xiang Zhang.

   - bpo-25803(48): Avoid incorrect errors raised by
     Path.mkdir(exist_ok=True) when the OS gives priority to errors such
     as EACCES over EEXIST.

   - bpo-29861(49): Release references to tasks, their arguments and
     their results as soon as they are finished in multiprocessing.Pool.

   - bpo-29884(50): faulthandler: Restore the old sigaltstack during
     teardown.  Patch by Christophe Zeitouny.

   - bpo-25455(51): Fixed crashes in repr of recursive buffered
     file-like objects.

   - bpo-29800(52): Fix crashes in partial.__repr__ if the keys of
     partial.keywords are not strings.  Patch by Michael Seifert.

   - bpo-29742(53): get_extra_info() raises exception if get called on
     closed ssl transport.  Patch by Nikolay Kim.

   - bpo-8256(54): Fixed possible failing or crashing input() if
     attributes "encoding" or "errors" of sys.stdin or sys.stdout are
     not set or are not strings.

   - bpo-28298(55): Fix a bug that prevented array 'Q', 'L' and 'I' from
     accepting big intables (objects that have __int__) as elements.
     Patch by Oren Milman.

   - bpo-29615(56): SimpleXMLRPCDispatcher no longer chains KeyError (or
     any other exception) to exception(s) raised in the dispatched
     methods.  Patch by Petr Motejlek.

   - bpo-29704(57): asyncio.subprocess.SubprocessStreamProtocol no
     longer closes before all pipes are closed.

   - bpo-29703(58): Fix asyncio to support instantiation of new event
     loops in child processes.

   - bpo-29376(59): Fix assertion error in
     threading._DummyThread.is_alive().

   - bpo-29110(60): Fix file object leak in aifc.open() when file is
     given as a filesystem path and is not in valid AIFF format.  Patch
     by Anthony Zhang.

   - bpo-28961(61): Fix unittest.mock._Call helper: don't ignore the
     name parameter anymore.  Patch written by Jiajun Huang.

   - bpo-29532(62): Altering a kwarg dictionary passed to
     functools.partial() no longer affects a partial object after
     creation.

   - bpo-28556(63): Various updates to typing module: typing.Counter,
     typing.ChainMap, improved ABC caching, etc.  Original PRs by Jelle
     Zijlstra, Ivan Levkivskyi, Manuel Krebber, and Łukasz Langa.

   - bpo-29100(64): Fix datetime.fromtimestamp() regression introduced
     in Python 3.6.0: check minimum and maximum years.

   - bpo-29519(65): Fix weakref spewing exceptions during interpreter
     shutdown when used with a rare combination of multiprocessing and
     custom codecs.

   - bpo-29416(66): Prevent infinite loop in pathlib.Path.mkdir

   - bpo-29444(67): Fixed out-of-bounds buffer access in the group()
     method of the match object.  Based on patch by WGH.

   - bpo-29335(68): Fix subprocess.Popen.wait() when the child process
     has exited to a stopped instead of terminated state (ex: when under
     ptrace).

   - bpo-29290(69): Fix a regression in argparse that help messages
     would wrap at non-breaking spaces.

   - bpo-28735(70): Fixed the comparison of mock.MagickMock with
     mock.ANY.

   - bpo-29011(71): Fix an important omission by adding Deque to the
     typing module.

   - bpo-29219(72): Fixed infinite recursion in the repr of
     uninitialized ctypes.CDLL instances.

   - bpo-28969(73): Fixed race condition in C implementation of
     functools.lru_cache.  KeyError could be raised when cached function
     with full cache was simultaneously called from different threads
     with the same uncached arguments.

   - bpo-29142(74): In urllib.request, suffixes in no_proxy environment
     variable with leading dots could match related hostnames again
     (e.g.  .b.c matches a.b.c).  Patch by Milan Oberkirch.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29403

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30961

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30886

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29854

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30807

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30441

   (7) https://bugs.python.org/issue?@action=redirect&bpo=30532

   (8) https://bugs.python.org/issue?@action=redirect&bpo=29169

   (9) https://bugs.python.org/issue?@action=redirect&bpo=30879

   (10) https://bugs.python.org/issue?@action=redirect&bpo=30746

   (11) https://bugs.python.org/issue?@action=redirect&bpo=29755

   (12) https://bugs.python.org/issue?@action=redirect&bpo=30645

   (13) https://bugs.python.org/issue?@action=redirect&bpo=23890

   (14) https://bugs.python.org/issue?@action=redirect&bpo=30149

   (15) https://bugs.python.org/issue?@action=redirect&bpo=29931

   (16) https://bugs.python.org/issue?@action=redirect&bpo=24484

   (17) https://bugs.python.org/issue?@action=redirect&bpo=28994

   (18) https://bugs.python.org/issue?@action=redirect&bpo=30508

   (19) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (20) https://bugs.python.org/issue?@action=redirect&bpo=29870

   (21) https://bugs.python.org/issue?@action=redirect&bpo=29743

   (22) https://bugs.python.org/issue?@action=redirect&bpo=27585

   (23) https://bugs.python.org/issue?@action=redirect&bpo=30418

   (24) https://bugs.python.org/issue?@action=redirect&bpo=30378

   (25) https://bugs.python.org/issue?@action=redirect&bpo=29960

   (26) https://bugs.python.org/issue?@action=redirect&bpo=30414

   (27) https://bugs.python.org/issue?@action=redirect&bpo=30003

   (28) https://bugs.python.org/issue?@action=redirect&bpo=30301

   (29) https://bugs.python.org/issue?@action=redirect&bpo=30329

   (30) https://bugs.python.org/issue?@action=redirect&bpo=30375

   (31) https://bugs.python.org/issue?@action=redirect&bpo=30048

   (32) https://bugs.python.org/issue?@action=redirect&bpo=29990

   (33) https://bugs.python.org/issue?@action=redirect&bpo=26293

   (34) https://bugs.python.org/issue?@action=redirect&bpo=29094

   (35) https://bugs.python.org/issue?@action=redirect&bpo=30243

   (36) https://bugs.python.org/issue?@action=redirect&bpo=30185

   (37) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (38) https://bugs.python.org/issue?@action=redirect&bpo=30205

   (39) https://bugs.python.org/issue?@action=redirect&bpo=30070

   (40) https://bugs.python.org/issue?@action=redirect&bpo=30061

   (41) https://bugs.python.org/issue?@action=redirect&bpo=30068

   (42) https://bugs.python.org/issue?@action=redirect&bpo=29694

   (43) https://bugs.python.org/issue?@action=redirect&bpo=29692

   (44) https://bugs.python.org/issue?@action=redirect&bpo=29998

   (45) https://bugs.python.org/issue?@action=redirect&bpo=29942

   (46) https://bugs.python.org/issue?@action=redirect&bpo=27863

   (47) https://bugs.python.org/issue?@action=redirect&bpo=28699

   (48) https://bugs.python.org/issue?@action=redirect&bpo=25803

   (49) https://bugs.python.org/issue?@action=redirect&bpo=29861

   (50) https://bugs.python.org/issue?@action=redirect&bpo=29884

   (51) https://bugs.python.org/issue?@action=redirect&bpo=25455

   (52) https://bugs.python.org/issue?@action=redirect&bpo=29800

   (53) https://bugs.python.org/issue?@action=redirect&bpo=29742

   (54) https://bugs.python.org/issue?@action=redirect&bpo=8256

   (55) https://bugs.python.org/issue?@action=redirect&bpo=28298

   (56) https://bugs.python.org/issue?@action=redirect&bpo=29615

   (57) https://bugs.python.org/issue?@action=redirect&bpo=29704

   (58) https://bugs.python.org/issue?@action=redirect&bpo=29703

   (59) https://bugs.python.org/issue?@action=redirect&bpo=29376

   (60) https://bugs.python.org/issue?@action=redirect&bpo=29110

   (61) https://bugs.python.org/issue?@action=redirect&bpo=28961

   (62) https://bugs.python.org/issue?@action=redirect&bpo=29532

   (63) https://bugs.python.org/issue?@action=redirect&bpo=28556

   (64) https://bugs.python.org/issue?@action=redirect&bpo=29100

   (65) https://bugs.python.org/issue?@action=redirect&bpo=29519

   (66) https://bugs.python.org/issue?@action=redirect&bpo=29416

   (67) https://bugs.python.org/issue?@action=redirect&bpo=29444

   (68) https://bugs.python.org/issue?@action=redirect&bpo=29335

   (69) https://bugs.python.org/issue?@action=redirect&bpo=29290

   (70) https://bugs.python.org/issue?@action=redirect&bpo=28735

   (71) https://bugs.python.org/issue?@action=redirect&bpo=29011

   (72) https://bugs.python.org/issue?@action=redirect&bpo=29219

   (73) https://bugs.python.org/issue?@action=redirect&bpo=28969

   (74) https://bugs.python.org/issue?@action=redirect&bpo=29142


File: python.info,  Node: Documentation<67>,  Next: Tests<71>,  Prev: Library<80>,  Up: Python 3 5 4 release candidate 1

1.23.90.4 Documentation
.......................

   - bpo-30176(1): Add missing attribute related constants in curses
     documentation.

   - bpo-26985(2): Add missing info of code object in inspect
     documentation.

   - bpo-28929(3): Link the documentation to its source file on GitHub.

   - bpo-25008(4): Document smtpd.py as effectively deprecated and add a
     pointer to aiosmtpd, a third-party asyncio-based replacement.

   - bpo-26355(5): Add canonical header link on each page to
     corresponding major version of the documentation.  Patch by
     Matthias Bussonnier.

   - bpo-29349(6): Fix Python 2 syntax in code for building the
     documentation.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30176

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26985

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28929

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25008

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26355

   (6) https://bugs.python.org/issue?@action=redirect&bpo=29349


File: python.info,  Node: Tests<71>,  Next: Build<77>,  Prev: Documentation<67>,  Up: Python 3 5 4 release candidate 1

1.23.90.5 Tests
...............

   - bpo-30822(1): Fix regrtest command line parser to allow passing -u
     extralargefile to run test_zipfile64.

   - bpo-30383(2): regrtest: Enhance regrtest and backport features from
     the master branch.  Add options: -coverage, -testdir, -list-tests
     (list test files, don't run them), -list-cases (list test
     identifiers, don't run them, bpo-30523(3)), -matchfile (load a list
     of test filters from a text file, bpo-30540(4)), -slowest (alias to
     -slow).  Enhance output: add timestamp, test result, currently
     running tests, "Tests result: xxx" summary with total duration,
     etc.  Fix reference leak hunting in regrtest, -huntrleaks: regrtest
     now warms up caches, create explicitly all internal singletons
     which are created on demand to prevent false positives when
     checking for reference leaks.  (bpo-30675(5)).

   - bpo-30357(6): test_thread: setUp() now uses
     support.threading_setup() and support.threading_cleanup() to wait
     until threads complete to avoid random side effects on following
     tests.  Initial patch written by Grzegorz Grzywacz.

   - bpo-28087(7): Skip test_asyncore and test_eintr poll failures on
     macOS. Skip some tests of select.poll when running on macOS due to
     unresolved issues with the underlying system poll function on some
     macOS versions.

   - bpo-30197(8): Enhanced functions swap_attr() and swap_item() in the
     test.support module.  They now work when delete replaced attribute
     or item inside the with statement.  The old value of the attribute
     or item (or None if it doesn't exist) now will be assigned to the
     target of the "as" clause, if there is one.

   - bpo-29571(9): to match the behaviour of the ‘re.LOCALE’ flag,
     test_re.test_locale_flag now uses
     ‘locale.getpreferredencoding(False)’ to determine the candidate
     encoding for the test regex (allowing it to correctly skip the test
     when the default locale encoding is a multi-byte encoding)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30822

   (2) https://bugs.python.org/issue?@action=redirect&bpo=30383

   (3) https://bugs.python.org/issue?@action=redirect&bpo=30523

   (4) https://bugs.python.org/issue?@action=redirect&bpo=30540

   (5) https://bugs.python.org/issue?@action=redirect&bpo=30675

   (6) https://bugs.python.org/issue?@action=redirect&bpo=30357

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28087

   (8) https://bugs.python.org/issue?@action=redirect&bpo=30197

   (9) https://bugs.python.org/issue?@action=redirect&bpo=29571


File: python.info,  Node: Build<77>,  Next: Windows<67>,  Prev: Tests<71>,  Up: Python 3 5 4 release candidate 1

1.23.90.6 Build
...............

   - bpo-29243(1): Prevent unnecessary rebuilding of Python during ‘make
     test’, ‘make install’ and some other make targets when configured
     with ‘--enable-optimizations’.

   - bpo-23404(2): Don't regenerate generated files based on file
     modification time anymore: the action is now explicit.  Replace
     ‘make touch’ with ‘make regen-all’.

   - bpo-29643(3): Fix ‘--enable-optimization’ didn't work.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29243

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23404

   (3) https://bugs.python.org/issue?@action=redirect&bpo=29643


File: python.info,  Node: Windows<67>,  Next: C API<67>,  Prev: Build<77>,  Up: Python 3 5 4 release candidate 1

1.23.90.7 Windows
.................

   - bpo-30687(1): Locate msbuild.exe on Windows when building rather
     than vcvarsall.bat

   - bpo-29392(2): Prevent crash when passing invalid arguments into
     msvcrt module.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=30687

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29392


File: python.info,  Node: C API<67>,  Prev: Windows<67>,  Up: Python 3 5 4 release candidate 1

1.23.90.8 C API
...............

   - bpo-27867(1): Function PySlice_GetIndicesEx() is replaced with a
     macro if Py_LIMITED_API is set to the value between 0x03050400 and
     0x03060000 (not including) or 0x03060100 or higher.

   - bpo-29083(2): Fixed the declaration of some public API functions.
     PyArg_VaParse() and PyArg_VaParseTupleAndKeywords() were not
     available in limited API. PyArg_ValidateKeywordArguments(),
     PyArg_UnpackTuple() and Py_BuildValue() were not available in
     limited API of version < 3.3 when PY_SSIZE_T_CLEAN is defined.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27867

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29083


File: python.info,  Node: Python 3 5 3 final,  Next: Python 3 5 3 release candidate 1,  Prev: Python 3 5 4 release candidate 1,  Up: 変更履歴

1.23.91 Python 3.5.3 final
--------------------------

'Release date: 2017-01-17'

There were no code changes between 3.5.3rc1 and 3.5.3 final.


File: python.info,  Node: Python 3 5 3 release candidate 1,  Next: Python 3 5 2 final,  Prev: Python 3 5 3 final,  Up: 変更履歴

1.23.92 Python 3.5.3 release candidate 1
----------------------------------------

'Release date: 2017-01-02'

* Menu:

* Security: Security<47>.
* Core and Builtins: Core and Builtins<81>.
* Library: Library<81>.
* IDLE: IDLE<57>.
* C API: C API<68>.
* Documentation: Documentation<68>.
* Tests: Tests<72>.
* Tools/Demos: Tools/Demos<42>.
* Windows: Windows<68>.
* Build: Build<78>.


File: python.info,  Node: Security<47>,  Next: Core and Builtins<81>,  Up: Python 3 5 3 release candidate 1

1.23.92.1 Security
..................

   - bpo-27278(1): Fix os.urandom() implementation using getrandom() on
     Linux.  Truncate size to INT_MAX and loop until we collected enough
     random bytes, instead of casting a directly Py_ssize_t to int.

   - bpo-22636(2): Avoid shell injection problems with
     ctypes.util.find_library().

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27278

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22636


File: python.info,  Node: Core and Builtins<81>,  Next: Library<81>,  Prev: Security<47>,  Up: Python 3 5 3 release candidate 1

1.23.92.2 Core and Builtins
...........................

   - bpo-29073(1): bytearray formatting no longer truncates on first
     null byte.

   - bpo-28932(2): Do not include <sys/random.h> if it does not exist.

   - bpo-28147(3): Fix a memory leak in split-table dictionaries:
     setattr() must not convert combined table into split table.

   - bpo-25677(4): Correct the positioning of the syntax error caret for
     indented blocks.  Based on patch by Michael Layzell.

   - bpo-29000(5): Fixed bytes formatting of octals with zero padding in
     alternate form.

   - bpo-28512(6): Fixed setting the offset attribute of SyntaxError by
     PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject().

   - bpo-28991(7): functools.lru_cache() was susceptible to an obscure
     reentrancy bug caused by a monkey-patched len() function.

   - bpo-28648(8): Fixed crash in Py_DecodeLocale() in debug build on
     Mac OS X when decode astral characters.  Patch by Xiang Zhang.

   - bpo-19398(9): Extra slash no longer added to sys.path components in
     case of empty compile-time PYTHONPATH components.

   - bpo-28426(10): Fixed potential crash in PyUnicode_AsDecodedObject()
     in debug build.

   - bpo-23782(11): Fixed possible memory leak in _PyTraceback_Add() and
     exception loss in PyTraceBack_Here().

   - bpo-28379(12): Added sanity checks and tests for
     PyUnicode_CopyCharacters().  Patch by Xiang Zhang.

   - bpo-28376(13): The type of long range iterator is now registered as
     Iterator.  Patch by Oren Milman.

   - bpo-28376(14): The constructor of range_iterator now checks that
     step is not 0.  Patch by Oren Milman.

   - bpo-26906(15): Resolving special methods of uninitialized type now
     causes implicit initialization of the type instead of a fail.

   - bpo-18287(16): PyType_Ready() now checks that tp_name is not NULL.
     Original patch by Niklas Koep.

   - bpo-24098(17): Fixed possible crash when AST is changed in process
     of compiling it.

   - bpo-28350(18): String constants with null character no longer
     interned.

   - bpo-26617(19): Fix crash when GC runs during weakref callbacks.

   - bpo-27942(20): String constants now interned recursively in tuples
     and frozensets.

   - bpo-21578(21): Fixed misleading error message when ImportError
     called with invalid keyword args.

   - bpo-28203(22): Fix incorrect type in error message from
     ‘complex(1.0, {2:3})’.  Patch by Soumya Sharma.

   - bpo-27955(23): Fallback on reading /dev/urandom device when the
     getrandom() syscall fails with EPERM, for example when blocked by
     SECCOMP.

   - bpo-28131(24): Fix a regression in zipimport's compile_source().
     zipimport should use the same optimization level as the
     interpreter.

   - bpo-25221(25): Fix corrupted result from PyLong_FromLong(0) when
     Python is compiled with NSMALLPOSINTS = 0.

   - bpo-25758(26): Prevents zipimport from unnecessarily encoding a
     filename (patch by Eryk Sun)

   - bpo-28189(27): dictitems_contains no longer swallows compare
     errors.  (Patch by Xiang Zhang)

   - bpo-27812(28): Properly clear out a generator's frame's
     backreference to the generator to prevent crashes in frame.clear().

   - bpo-27811(29): Fix a crash when a coroutine that has not been
     awaited is finalized with warnings-as-errors enabled.

   - bpo-27587(30): Fix another issue found by PVS-Studio: Null pointer
     check after use of 'def' in _PyState_AddModule().  Initial patch by
     Christian Heimes.

   - bpo-26020(31): set literal evaluation order did not match
     documented behaviour.

   - bpo-27782(32): Multi-phase extension module import now correctly
     allows the ‘m_methods’ field to be used to add module level
     functions to instances of non-module types returned from
     ‘Py_create_mod’.  Patch by Xiang Zhang.

   - bpo-27936(33): The round() function accepted a second None argument
     for some types but not for others.  Fixed the inconsistency by
     accepting None for all numeric types.

   - bpo-27487(34): Warn if a submodule argument to "python -m" or
     runpy.run_module() is found in sys.modules after parent packages
     are imported, but before the submodule is executed.

   - bpo-27558(35): Fix a SystemError in the implementation of "raise"
     statement.  In a brand new thread, raise a RuntimeError since there
     is no active exception to reraise.  Patch written by Xiang Zhang.

   - bpo-27419(36): Standard __import__() no longer look up "__import__"
     in globals or builtins for importing submodules or "from import".
     Fixed handling an error of non-string package name.

   - bpo-27083(37): Respect the PYTHONCASEOK environment variable under
     Windows.

   - bpo-27514(38): Make having too many statically nested blocks a
     SyntaxError instead of SystemError.

   - bpo-27473(39): Fixed possible integer overflow in bytes and
     bytearray concatenations.  Patch by Xiang Zhang.

   - bpo-27507(40): Add integer overflow check in bytearray.extend().
     Patch by Xiang Zhang.

   - bpo-27581(41): Don't rely on wrapping for overflow check in
     PySequence_Tuple().  Patch by Xiang Zhang.

   - bpo-27443(42): __length_hint__() of bytearray iterators no longer
     return a negative integer for a resized bytearray.

   - bpo-27942(43): Fix memory leak in codeobject.c

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29073

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28932

   (3) https://bugs.python.org/issue?@action=redirect&bpo=28147

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25677

   (5) https://bugs.python.org/issue?@action=redirect&bpo=29000

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28512

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28991

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28648

   (9) https://bugs.python.org/issue?@action=redirect&bpo=19398

   (10) https://bugs.python.org/issue?@action=redirect&bpo=28426

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23782

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28379

   (13) https://bugs.python.org/issue?@action=redirect&bpo=28376

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28376

   (15) https://bugs.python.org/issue?@action=redirect&bpo=26906

   (16) https://bugs.python.org/issue?@action=redirect&bpo=18287

   (17) https://bugs.python.org/issue?@action=redirect&bpo=24098

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28350

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26617

   (20) https://bugs.python.org/issue?@action=redirect&bpo=27942

   (21) https://bugs.python.org/issue?@action=redirect&bpo=21578

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28203

   (23) https://bugs.python.org/issue?@action=redirect&bpo=27955

   (24) https://bugs.python.org/issue?@action=redirect&bpo=28131

   (25) https://bugs.python.org/issue?@action=redirect&bpo=25221

   (26) https://bugs.python.org/issue?@action=redirect&bpo=25758

   (27) https://bugs.python.org/issue?@action=redirect&bpo=28189

   (28) https://bugs.python.org/issue?@action=redirect&bpo=27812

   (29) https://bugs.python.org/issue?@action=redirect&bpo=27811

   (30) https://bugs.python.org/issue?@action=redirect&bpo=27587

   (31) https://bugs.python.org/issue?@action=redirect&bpo=26020

   (32) https://bugs.python.org/issue?@action=redirect&bpo=27782

   (33) https://bugs.python.org/issue?@action=redirect&bpo=27936

   (34) https://bugs.python.org/issue?@action=redirect&bpo=27487

   (35) https://bugs.python.org/issue?@action=redirect&bpo=27558

   (36) https://bugs.python.org/issue?@action=redirect&bpo=27419

   (37) https://bugs.python.org/issue?@action=redirect&bpo=27083

   (38) https://bugs.python.org/issue?@action=redirect&bpo=27514

   (39) https://bugs.python.org/issue?@action=redirect&bpo=27473

   (40) https://bugs.python.org/issue?@action=redirect&bpo=27507

   (41) https://bugs.python.org/issue?@action=redirect&bpo=27581

   (42) https://bugs.python.org/issue?@action=redirect&bpo=27443

   (43) https://bugs.python.org/issue?@action=redirect&bpo=27942


File: python.info,  Node: Library<81>,  Next: IDLE<57>,  Prev: Core and Builtins<81>,  Up: Python 3 5 3 release candidate 1

1.23.92.3 Library
.................

   - bpo-15812(1): inspect.getframeinfo() now correctly shows the first
     line of a context.  Patch by Sam Breese.

   - bpo-29094(2): Offsets in a ZIP file created with extern file object
     and modes "w" and "x" now are relative to the start of the file.

   - bpo-13051(3): Fixed recursion errors in large or resized
     curses.textpad.Textbox.  Based on patch by Tycho Andersen.

   - bpo-29119(4): Fix weakrefs in the pure python version of
     collections.OrderedDict move_to_end() method.  Contributed by Andra
     Bogildea.

   - bpo-9770(5): curses.ascii predicates now work correctly with
     negative integers.

   - bpo-28427(6): old keys should not remove new values from
     WeakValueDictionary when collecting from another thread.

   - bpo-28923(7): Remove editor artifacts from Tix.py.

   - bpo-28871(8): Fixed a crash when deallocate deep ElementTree.

   - bpo-19542(9): Fix bugs in WeakValueDictionary.setdefault() and
     WeakValueDictionary.pop() when a GC collection happens in another
     thread.

   - bpo-20191(10): Fixed a crash in resource.prlimit() when pass a
     sequence that doesn't own its elements as limits.

   - bpo-28779(11): multiprocessing.set_forkserver_preload() would crash
     the forkserver process if a preloaded module instantiated some
     multiprocessing objects such as locks.

   - bpo-28847(12): dbm.dumb now supports reading read-only files and no
     longer writes the index file when it is not changed.

   - bpo-25659(13): In ctypes, prevent a crash calling the from_buffer()
     and from_buffer_copy() methods on abstract classes like Array.

   - bpo-28732(14): Fix crash in os.spawnv() with no elements in args

   - bpo-28485(15): Always raise ValueError for negative
     compileall.compile_dir(workers=...)  parameter, even when
     multithreading is unavailable.

   - bpo-28387(16): Fixed possible crash in _io.TextIOWrapper
     deallocator when the garbage collector is invoked in other thread.
     Based on patch by Sebastian Cufre.

   - bpo-27517(17): LZMA compressor and decompressor no longer raise
     exceptions if given empty data twice.  Patch by Benjamin Fogle.

   - bpo-28549(18): Fixed segfault in curses's addch() with ncurses6.

   - bpo-28449(19): tarfile.open() with mode "r" or "r:" now tries to
     open a tar file with compression before trying to open it without
     compression.  Otherwise it had 50% chance failed with
     ignore_zeros=True.

   - bpo-23262(20): The webbrowser module now supports Firefox 36+ and
     derived browsers.  Based on patch by Oleg Broytman.

   - bpo-27939(21): Fixed bugs in tkinter.ttk.LabeledScale and
     tkinter.Scale caused by representing the scale as float value
     internally in Tk.  tkinter.IntVar now works if float value is set
     to underlying Tk variable.

   - bpo-28255(22): calendar.TextCalendar().prmonth() no longer prints a
     space at the start of new line after printing a month's calendar.
     Patch by Xiang Zhang.

   - bpo-20491(23): The textwrap.TextWrapper class now honors
     non-breaking spaces.  Based on patch by Kaarle Ritvanen.

   - bpo-28353(24): os.fwalk() no longer fails on broken links.

   - bpo-25464(25): Fixed HList.header_exists() in tkinter.tix module by
     addin a workaround to Tix library bug.

   - bpo-28488(26): shutil.make_archive() no longer add entry "./" to
     ZIP archive.

   - bpo-24452(27): Make webbrowser support Chrome on Mac OS X.

   - bpo-20766(28): Fix references leaked by pdb in the handling of
     SIGINT handlers.

   - bpo-26293(29): Fixed writing ZIP files that starts not from the
     start of the file.  Offsets in ZIP file now are relative to the
     start of the archive in conforming to the specification.

   - bpo-28321(30): Fixed writing non-BMP characters with binary format
     in plistlib.

   - bpo-28322(31): Fixed possible crashes when unpickle itertools
     objects from incorrect pickle data.  Based on patch by John Leitch.

   - Fix possible integer overflows and crashes in the mmap module with
     unusual usage patterns.

   - bpo-1703178(32): Fix the ability to pass the -link-objects option
     to the distutils build_ext command.

   - bpo-28253(33): Fixed calendar functions for extreme months: 0001-01
     and 9999-12.  Methods itermonthdays() and itermonthdays2() are
     reimplemented so that they don't call itermonthdates() which can
     cause datetime.date under/overflow.

   - bpo-28275(34): Fixed possible use after free in the decompress()
     methods of the LZMADecompressor and BZ2Decompressor classes.
     Original patch by John Leitch.

   - bpo-27897(35): Fixed possible crash in
     sqlite3.Connection.create_collation() if pass invalid string-like
     object as a name.  Patch by Xiang Zhang.

   - bpo-18893(36): Fix invalid exception handling in
     Lib/ctypes/macholib/dyld.py.  Patch by Madison May.

   - bpo-27611(37): Fixed support of default root window in the
     tkinter.tix module.

   - bpo-27348(38): In the traceback module, restore the formatting of
     exception messages like "Exception: None".  This fixes a regression
     introduced in 3.5a2.

   - bpo-25651(39): Allow false values to be used for msg parameter of
     subTest().

   - bpo-27932(40): Prevent memory leak in win32_ver().

   - Fix UnboundLocalError in socket._sendfile_use_sendfile.

   - bpo-28075(41): Check for ERROR_ACCESS_DENIED in Windows
     implementation of os.stat().  Patch by Eryk Sun.

   - bpo-25270(42): Prevent codecs.escape_encode() from raising
     SystemError when an empty bytestring is passed.

   - bpo-28181(43): Get antigravity over HTTPS. Patch by Kaartic
     Sivaraam.

   - bpo-25895(44): Enable WebSocket URL schemes in
     urllib.parse.urljoin.  Patch by Gergely Imreh and Markus
     Holtermann.

   - bpo-27599(45): Fixed buffer overrun in binascii.b2a_qp() and
     binascii.a2b_qp().

   - bpo-19003(46): m email.generator now replaces only ‘\r’ and/or ‘\n’
     line endings, per the RFC, instead of all unicode line endings.

   - bpo-28019(47): itertools.count() no longer rounds non-integer step
     in range between 1.0 and 2.0 to 1.

   - bpo-25969(48): Update the lib2to3 grammar to handle the unpacking
     generalizations added in 3.5.

   - bpo-14977(49): mailcap now respects the order of the lines in the
     mailcap files ("first match"), as required by RFC 1542.  Patch by
     Michael Lazar.

   - bpo-24594(50): Validates persist parameter when opening MSI
     database

   - bpo-17582(51): xml.etree.ElementTree nows preserves whitespaces in
     attributes (Patch by Duane Griffin.  Reviewed and approved by
     Stefan Behnel.)

   - bpo-28047(52): Fixed calculation of line length used for the base64
     CTE in the new email policies.

   - bpo-27445(53): Don't pass str(_charset) to MIMEText.set_payload().
     Patch by Claude Paroz.

   - bpo-22450(54): urllib now includes an ‘Accept: */*’ header among
     the default headers.  This makes the results of REST API requests
     more consistent and predictable especially when proxy servers are
     involved.

   - lib2to3.pgen3.driver.load_grammar() now creates a stable cache file
     between runs given the same Grammar.txt input regardless of the
     hash randomization setting.

   - bpo-27570(55): Avoid zero-length memcpy() etc calls with null
     source pointers in the "ctypes" and "array" modules.

   - bpo-22233(56): Break email header lines 'only' on the RFC specified
     CR and LF characters, not on arbitrary unicode line breaks.  This
     also fixes a bug in HTTP header parsing.

   - bpo-27988(57): Fix email iter_attachments incorrect mutation of
     payload list.

   - bpo-27691(58): Fix ssl module's parsing of GEN_RID subject
     alternative name fields in X.509 certs.

   - bpo-27850(59): Remove 3DES from ssl module's default cipher list to
     counter measure sweet32 attack ( CVE 2016-2183(60)).

   - bpo-27766(61): Add ChaCha20 Poly1305 to ssl module's default cipher
     list.  (Required OpenSSL 1.1.0 or LibreSSL).

   - bpo-26470(62): Port ssl and hashlib module to OpenSSL 1.1.0.

   - Remove support for passing a file descriptor to os.access.  It
     never worked but previously didn't raise.

   - bpo-12885(63): Fix error when distutils encounters symlink.

   - bpo-27881(64): Fixed possible bugs when setting
     sqlite3.Connection.isolation_level.  Based on patch by Xiang Zhang.

   - bpo-27861(65): Fixed a crash in sqlite3.Connection.cursor() when a
     factory creates not a cursor.  Patch by Xiang Zhang.

   - bpo-19884(66): Avoid spurious output on OS X with Gnu Readline.

   - bpo-27706(67): Restore deterministic behavior of
     random.Random().seed() for string seeds using seeding version 1.
     Allows sequences of calls to random() to exactly match those
     obtained in Python 2.  Patch by Nofar Schnider.

   - bpo-10513(68): Fix a regression in Connection.commit().  Statements
     should not be reset after a commit.

   - A new version of typing.py from ‘https://github.com/python/typing’:
     Collection (only for 3.6) (bpo-27598(69)).  Add FrozenSet to
     __all__ (upstream #261).  Fix crash in _get_type_vars() (upstream
     #259).  Remove the dict constraint in ForwardRef._eval_type
     (upstream #252).

   - bpo-27539(70): Fix unnormalised ‘Fraction.__pow__’ result in the
     case of negative exponent and negative base.

   - bpo-21718(71): cursor.description is now available for queries
     using CTEs.

   - bpo-2466(72): posixpath.ismount now correctly recognizes mount
     points which the user does not have permission to access.

   - bpo-27773(73): Correct some memory management errors
     server_hostname in _ssl.wrap_socket().

   - bpo-26750(74): unittest.mock.create_autospec() now works properly
     for subclasses of property() and other data descriptors.

   - In the curses module, raise an error if window.getstr() or
     window.instr() is passed a negative value.

   - bpo-27783(75): Fix possible usage of uninitialized memory in
     operator.methodcaller.

   - bpo-27774(76): Fix possible Py_DECREF on unowned object in _sre.

   - bpo-27760(77): Fix possible integer overflow in binascii.b2a_qp.

   - bpo-27758(78): Fix possible integer overflow in the _csv module for
     large record lengths.

   - bpo-27568(79): Prevent HTTPoxy attack ( CVE 2016-1000110(80)).
     Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is
     set, which indicates that the script is in CGI mode.

   - bpo-27656(81): Do not assume sched.h defines any SCHED_* constants.

   - bpo-27130(82): In the "zlib" module, fix handling of large buffers
     (typically 4 GiB) when compressing and decompressing.  Previously,
     inputs were limited to 4 GiB, and compression and decompression
     operations did not properly handle results of 4 GiB.

   - bpo-27533(83): Release GIL in nt._isdir

   - bpo-17711(84): Fixed unpickling by the persistent ID with protocol
     0.  Original patch by Alexandre Vassalotti.

   - bpo-27522(85): Avoid an unintentional reference cycle in
     email.feedparser.

   - bpo-26844(86): Fix error message for imp.find_module() to refer to
     'path' instead of 'name'.  Patch by Lev Maximov.

   - bpo-23804(87): Fix SSL zero-length recv() calls to not block and
     not raise an error about unclean EOF.

   - bpo-27466(88): Change time format returned by
     http.cookie.time2netscape, confirming the netscape cookie format
     and making it consistent with documentation.

   - bpo-26664(89): Fix activate.fish by removing mis-use of ‘$’.

   - bpo-22115(90): Fixed tracing Tkinter variables: trace_vdelete()
     with wrong mode no longer break tracing, trace_vinfo() now always
     returns a list of pairs of strings, tracing in the "u" mode now
     works.

   - Fix a scoping issue in importlib.util.LazyLoader which triggered an
     UnboundLocalError when lazy-loading a module that was already put
     into sys.modules.

   - bpo-27079(91): Fixed curses.ascii functions isblank(), iscntrl()
     and ispunct().

   - bpo-26754(92): Some functions (compile() etc) accepted a filename
     argument encoded as an iterable of integers.  Now only strings and
     byte-like objects are accepted.

   - bpo-27048(93): Prevents distutils failing on Windows when
     environment variables contain non-ASCII characters

   - bpo-27330(94): Fixed possible leaks in the ctypes module.

   - bpo-27238(95): Got rid of bare excepts in the turtle module.
     Original patch by Jelle Zijlstra.

   - bpo-27122(96): When an exception is raised within the context being
     managed by a contextlib.ExitStack() and one of the exit stack
     generators catches and raises it in a chain, do not re-raise the
     original exception when exiting, let the new chained one through.
     This avoids the PEP 479(97) bug described in issue25782.

   - bpo-26386(98): Fixed ttk.TreeView selection operations with item
     id's containing spaces.

   - bpo-16182(99): Fix various functions in the "readline" module to
     use the locale encoding, and fix get_begidx() and get_endidx() to
     return code point indexes.

   - bpo-27392(100): Add loop.connect_accepted_socket().  Patch by Jim
     Fulton.

   - bpo-27930(101): Improved behaviour of
     logging.handlers.QueueListener.  Thanks to Paulo Andrade and Petr
     Viktorin for the analysis and patch.

   - bpo-21201(102): Improves readability of multiprocessing error
     message.  Thanks to Wojciech Walczak for patch.

   - bpo-27456(103): asyncio: Set TCP_NODELAY by default.

   - bpo-27906(104): Fix socket accept exhaustion during high TCP
     traffic.  Patch by Kevin Conway.

   - bpo-28174(105): Handle when SO_REUSEPORT isn't properly supported.
     Patch by Seth Michael Larson.

   - bpo-26654(106): Inspect functools.partial in
     asyncio.Handle.__repr__.  Patch by iceboy.

   - bpo-26909(107): Fix slow pipes IO in asyncio.  Patch by INADA
     Naoki.

   - bpo-28176(108): Fix callbacks race in
     asyncio.SelectorLoop.sock_connect.

   - bpo-27759(109): Fix selectors incorrectly retain invalid file
     descriptors.  Patch by Mark Williams.

   - bpo-28368(110): Refuse monitoring processes if the child watcher
     has no loop attached.  Patch by Vincent Michel.

   - bpo-28369(111): Raise RuntimeError when transport's FD is used with
     add_reader, add_writer, etc.

   - bpo-28370(112): Speedup asyncio.StreamReader.readexactly.  Patch by
     Коренберг Марк.

   - bpo-28371(113): Deprecate passing asyncio.Handles to
     run_in_executor.

   - bpo-28372(114): Fix asyncio to support formatting of non-python
     coroutines.

   - bpo-28399(115): Remove UNIX socket from FS before binding.  Patch
     by Коренберг Марк.

   - bpo-27972(116): Prohibit Tasks to await on themselves.

   - bpo-26923(117): Fix asyncio.Gather to refuse being cancelled once
     all children are done.  Patch by Johannes Ebke.

   - bpo-26796(118): Don't configure the number of workers for default
     threadpool executor.  Initial patch by Hans Lawrenz.

   - bpo-28600(119): Optimize loop.call_soon().

   - bpo-28613(120): Fix get_event_loop() return the current loop if
     called from coroutines/callbacks.

   - bpo-28639(121): Fix inspect.isawaitable to always return bool Patch
     by Justin Mayfield.

   - bpo-28652(122): Make loop methods reject socket kinds they do not
     support.

   - bpo-28653(123): Fix a refleak in functools.lru_cache.

   - bpo-28703(124): Fix asyncio.iscoroutinefunction to handle Mock
     objects.

   - bpo-24142(125): Reading a corrupt config file left the parser in an
     invalid state.  Original patch by Florian Höch.

   - bpo-28990(126): Fix SSL hanging if connection is closed before
     handshake completed.  (Patch by HoHo-Ho)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15812

   (2) https://bugs.python.org/issue?@action=redirect&bpo=29094

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13051

   (4) https://bugs.python.org/issue?@action=redirect&bpo=29119

   (5) https://bugs.python.org/issue?@action=redirect&bpo=9770

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28427

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28923

   (8) https://bugs.python.org/issue?@action=redirect&bpo=28871

   (9) https://bugs.python.org/issue?@action=redirect&bpo=19542

   (10) https://bugs.python.org/issue?@action=redirect&bpo=20191

   (11) https://bugs.python.org/issue?@action=redirect&bpo=28779

   (12) https://bugs.python.org/issue?@action=redirect&bpo=28847

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25659

   (14) https://bugs.python.org/issue?@action=redirect&bpo=28732

   (15) https://bugs.python.org/issue?@action=redirect&bpo=28485

   (16) https://bugs.python.org/issue?@action=redirect&bpo=28387

   (17) https://bugs.python.org/issue?@action=redirect&bpo=27517

   (18) https://bugs.python.org/issue?@action=redirect&bpo=28549

   (19) https://bugs.python.org/issue?@action=redirect&bpo=28449

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23262

   (21) https://bugs.python.org/issue?@action=redirect&bpo=27939

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28255

   (23) https://bugs.python.org/issue?@action=redirect&bpo=20491

   (24) https://bugs.python.org/issue?@action=redirect&bpo=28353

   (25) https://bugs.python.org/issue?@action=redirect&bpo=25464

   (26) https://bugs.python.org/issue?@action=redirect&bpo=28488

   (27) https://bugs.python.org/issue?@action=redirect&bpo=24452

   (28) https://bugs.python.org/issue?@action=redirect&bpo=20766

   (29) https://bugs.python.org/issue?@action=redirect&bpo=26293

   (30) https://bugs.python.org/issue?@action=redirect&bpo=28321

   (31) https://bugs.python.org/issue?@action=redirect&bpo=28322

   (32) https://bugs.python.org/issue?@action=redirect&bpo=1703178

   (33) https://bugs.python.org/issue?@action=redirect&bpo=28253

   (34) https://bugs.python.org/issue?@action=redirect&bpo=28275

   (35) https://bugs.python.org/issue?@action=redirect&bpo=27897

   (36) https://bugs.python.org/issue?@action=redirect&bpo=18893

   (37) https://bugs.python.org/issue?@action=redirect&bpo=27611

   (38) https://bugs.python.org/issue?@action=redirect&bpo=27348

   (39) https://bugs.python.org/issue?@action=redirect&bpo=25651

   (40) https://bugs.python.org/issue?@action=redirect&bpo=27932

   (41) https://bugs.python.org/issue?@action=redirect&bpo=28075

   (42) https://bugs.python.org/issue?@action=redirect&bpo=25270

   (43) https://bugs.python.org/issue?@action=redirect&bpo=28181

   (44) https://bugs.python.org/issue?@action=redirect&bpo=25895

   (45) https://bugs.python.org/issue?@action=redirect&bpo=27599

   (46) https://bugs.python.org/issue?@action=redirect&bpo=19003

   (47) https://bugs.python.org/issue?@action=redirect&bpo=28019

   (48) https://bugs.python.org/issue?@action=redirect&bpo=25969

   (49) https://bugs.python.org/issue?@action=redirect&bpo=14977

   (50) https://bugs.python.org/issue?@action=redirect&bpo=24594

   (51) https://bugs.python.org/issue?@action=redirect&bpo=17582

   (52) https://bugs.python.org/issue?@action=redirect&bpo=28047

   (53) https://bugs.python.org/issue?@action=redirect&bpo=27445

   (54) https://bugs.python.org/issue?@action=redirect&bpo=22450

   (55) https://bugs.python.org/issue?@action=redirect&bpo=27570

   (56) https://bugs.python.org/issue?@action=redirect&bpo=22233

   (57) https://bugs.python.org/issue?@action=redirect&bpo=27988

   (58) https://bugs.python.org/issue?@action=redirect&bpo=27691

   (59) https://bugs.python.org/issue?@action=redirect&bpo=27850

   (60) https://www.cve.org/CVERecord?id=CVE-2016-2183

   (61) https://bugs.python.org/issue?@action=redirect&bpo=27766

   (62) https://bugs.python.org/issue?@action=redirect&bpo=26470

   (63) https://bugs.python.org/issue?@action=redirect&bpo=12885

   (64) https://bugs.python.org/issue?@action=redirect&bpo=27881

   (65) https://bugs.python.org/issue?@action=redirect&bpo=27861

   (66) https://bugs.python.org/issue?@action=redirect&bpo=19884

   (67) https://bugs.python.org/issue?@action=redirect&bpo=27706

   (68) https://bugs.python.org/issue?@action=redirect&bpo=10513

   (69) https://bugs.python.org/issue?@action=redirect&bpo=27598

   (70) https://bugs.python.org/issue?@action=redirect&bpo=27539

   (71) https://bugs.python.org/issue?@action=redirect&bpo=21718

   (72) https://bugs.python.org/issue?@action=redirect&bpo=2466

   (73) https://bugs.python.org/issue?@action=redirect&bpo=27773

   (74) https://bugs.python.org/issue?@action=redirect&bpo=26750

   (75) https://bugs.python.org/issue?@action=redirect&bpo=27783

   (76) https://bugs.python.org/issue?@action=redirect&bpo=27774

   (77) https://bugs.python.org/issue?@action=redirect&bpo=27760

   (78) https://bugs.python.org/issue?@action=redirect&bpo=27758

   (79) https://bugs.python.org/issue?@action=redirect&bpo=27568

   (80) https://www.cve.org/CVERecord?id=CVE-2016-1000110

   (81) https://bugs.python.org/issue?@action=redirect&bpo=27656

   (82) https://bugs.python.org/issue?@action=redirect&bpo=27130

   (83) https://bugs.python.org/issue?@action=redirect&bpo=27533

   (84) https://bugs.python.org/issue?@action=redirect&bpo=17711

   (85) https://bugs.python.org/issue?@action=redirect&bpo=27522

   (86) https://bugs.python.org/issue?@action=redirect&bpo=26844

   (87) https://bugs.python.org/issue?@action=redirect&bpo=23804

   (88) https://bugs.python.org/issue?@action=redirect&bpo=27466

   (89) https://bugs.python.org/issue?@action=redirect&bpo=26664

   (90) https://bugs.python.org/issue?@action=redirect&bpo=22115

   (91) https://bugs.python.org/issue?@action=redirect&bpo=27079

   (92) https://bugs.python.org/issue?@action=redirect&bpo=26754

   (93) https://bugs.python.org/issue?@action=redirect&bpo=27048

   (94) https://bugs.python.org/issue?@action=redirect&bpo=27330

   (95) https://bugs.python.org/issue?@action=redirect&bpo=27238

   (96) https://bugs.python.org/issue?@action=redirect&bpo=27122

   (97) https://peps.python.org/pep-0479/

   (98) https://bugs.python.org/issue?@action=redirect&bpo=26386

   (99) https://bugs.python.org/issue?@action=redirect&bpo=16182

   (100) https://bugs.python.org/issue?@action=redirect&bpo=27392

   (101) https://bugs.python.org/issue?@action=redirect&bpo=27930

   (102) https://bugs.python.org/issue?@action=redirect&bpo=21201

   (103) https://bugs.python.org/issue?@action=redirect&bpo=27456

   (104) https://bugs.python.org/issue?@action=redirect&bpo=27906

   (105) https://bugs.python.org/issue?@action=redirect&bpo=28174

   (106) https://bugs.python.org/issue?@action=redirect&bpo=26654

   (107) https://bugs.python.org/issue?@action=redirect&bpo=26909

   (108) https://bugs.python.org/issue?@action=redirect&bpo=28176

   (109) https://bugs.python.org/issue?@action=redirect&bpo=27759

   (110) https://bugs.python.org/issue?@action=redirect&bpo=28368

   (111) https://bugs.python.org/issue?@action=redirect&bpo=28369

   (112) https://bugs.python.org/issue?@action=redirect&bpo=28370

   (113) https://bugs.python.org/issue?@action=redirect&bpo=28371

   (114) https://bugs.python.org/issue?@action=redirect&bpo=28372

   (115) https://bugs.python.org/issue?@action=redirect&bpo=28399

   (116) https://bugs.python.org/issue?@action=redirect&bpo=27972

   (117) https://bugs.python.org/issue?@action=redirect&bpo=26923

   (118) https://bugs.python.org/issue?@action=redirect&bpo=26796

   (119) https://bugs.python.org/issue?@action=redirect&bpo=28600

   (120) https://bugs.python.org/issue?@action=redirect&bpo=28613

   (121) https://bugs.python.org/issue?@action=redirect&bpo=28639

   (122) https://bugs.python.org/issue?@action=redirect&bpo=28652

   (123) https://bugs.python.org/issue?@action=redirect&bpo=28653

   (124) https://bugs.python.org/issue?@action=redirect&bpo=28703

   (125) https://bugs.python.org/issue?@action=redirect&bpo=24142

   (126) https://bugs.python.org/issue?@action=redirect&bpo=28990


File: python.info,  Node: IDLE<57>,  Next: C API<68>,  Prev: Library<81>,  Up: Python 3 5 3 release candidate 1

1.23.92.4 IDLE
..............

   - bpo-15308(1): Add 'interrupt execution' (^C) to Shell menu.  Patch
     by Roger Serwy, updated by Bayard Randel.

   - bpo-27922(2): Stop IDLE tests from 'flashing' gui widgets on the
     screen.

   - Add version to title of IDLE help window.

   - bpo-25564(3): In section on IDLE - console differences, mention
     that using exec means that __builtins__ is defined for each
     statement.

   - bpo-27714(4): text_textview and test_autocomplete now pass when
     re-run in the same process.  This occurs when test_idle fails when
     run with the -w option but without -jn.  Fix warning from
     test_config.

   - bpo-25507(5): IDLE no longer runs buggy code because of its tkinter
     imports.  Users must include the same imports required to run
     directly in Python.

   - bpo-27452(6): add line counter and crc to IDLE configHandler test
     dump.

   - bpo-27365(7): Allow non-ascii chars in IDLE NEWS.txt, for
     contributor names.

   - bpo-27245(8): IDLE: Cleanly delete custom themes and key bindings.
     Previously, when IDLE was started from a console or by import, a
     cascade of warnings was emitted.  Patch by Serhiy Storchaka.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15308

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27922

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25564

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27714

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25507

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27452

   (7) https://bugs.python.org/issue?@action=redirect&bpo=27365

   (8) https://bugs.python.org/issue?@action=redirect&bpo=27245


File: python.info,  Node: C API<68>,  Next: Documentation<68>,  Prev: IDLE<57>,  Up: Python 3 5 3 release candidate 1

1.23.92.5 C API
...............

   - bpo-28808(1): PyUnicode_CompareWithASCIIString() now never raises
     exceptions.

   - bpo-26754(2): PyUnicode_FSDecoder() accepted a filename argument
     encoded as an iterable of integers.  Now only strings and
     bytes-like objects are accepted.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28808

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26754


File: python.info,  Node: Documentation<68>,  Next: Tests<72>,  Prev: C API<68>,  Up: Python 3 5 3 release candidate 1

1.23.92.6 Documentation
.......................

   - bpo-28513(1): Documented command-line interface of zipfile.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28513


File: python.info,  Node: Tests<72>,  Next: Tools/Demos<42>,  Prev: Documentation<68>,  Up: Python 3 5 3 release candidate 1

1.23.92.7 Tests
...............

   - bpo-28950(1): Disallow -j0 to be combined with -T/-l/-M in regrtest
     command line arguments.

   - bpo-28666(2): Now test.support.rmtree is able to remove unwritable
     or unreadable directories.

   - bpo-23839(3): Various caches now are cleared before running every
     test file.

   - bpo-28409(4): regrtest: fix the parser of command line arguments.

   - bpo-27787(5): Call gc.collect() before checking each test for
     "dangling threads", since the dangling threads are weak references.

   - bpo-27369(6): In test_pyexpat, avoid testing an error message
     detail that changed in Expat 2.2.0.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28950

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28666

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23839

   (4) https://bugs.python.org/issue?@action=redirect&bpo=28409

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27787

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27369


File: python.info,  Node: Tools/Demos<42>,  Next: Windows<68>,  Prev: Tests<72>,  Up: Python 3 5 3 release candidate 1

1.23.92.8 Tools/Demos
.....................

   - bpo-27952(1): Get Tools/scripts/fixcid.py working with Python 3 and
     the current "re" module, avoid invalid Python backslash escapes,
     and fix a bug parsing escaped C quote signs.

   - bpo-27332(2): Fixed the type of the first argument of module-level
     functions generated by Argument Clinic.  Patch by Petr Viktorin.

   - bpo-27418(3): Fixed Tools/importbench/importbench.py.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27952

   (2) https://bugs.python.org/issue?@action=redirect&bpo=27332

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27418


File: python.info,  Node: Windows<68>,  Next: Build<78>,  Prev: Tools/Demos<42>,  Up: Python 3 5 3 release candidate 1

1.23.92.9 Windows
.................

   - bpo-28251(1): Improvements to help manuals on Windows.

   - bpo-28110(2): launcher.msi has different product codes between
     32-bit and 64-bit

   - bpo-25144(3): Ensures TargetDir is set before continuing with
     custom install.

   - bpo-27469(4): Adds a shell extension to the launcher so that drag
     and drop works correctly.

   - bpo-27309(5): Enabled proper Windows styles in python[w].exe
     manifest.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28251

   (2) https://bugs.python.org/issue?@action=redirect&bpo=28110

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25144

   (4) https://bugs.python.org/issue?@action=redirect&bpo=27469

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27309


File: python.info,  Node: Build<78>,  Prev: Windows<68>,  Up: Python 3 5 3 release candidate 1

1.23.92.10 Build
................

   - bpo-29080(1): Removes hard dependency on hg.exe from
     PCBuild/build.bat

   - bpo-23903(2): Added missed names to PC/python3.def.

   - bpo-10656(3): Fix out-of-tree building on AIX. Patch by Tristan
     Carel and Michael Haubenwallner.

   - bpo-26359(4): Rename -with-optimiations to -enable-optimizations.

   - bpo-28444(5): Fix missing extensions modules when cross compiling.

   - bpo-28248(6): Update Windows build and OS X installers to use
     OpenSSL 1.0.2j.

   - bpo-28258(7): Fixed build with Estonian locale (python-config and
     distclean targets in Makefile).  Patch by Arfrever Frehtes
     Taifersar Arahesis.

   - bpo-26661(8): setup.py now detects system libffi with multiarch
     wrapper.

   - bpo-28066(9): Fix the logic that searches build directories for
     generated include files when building outside the source tree.

   - bpo-15819(10): Remove redundant include search directory option for
     building outside the source tree.

   - bpo-27566(11): Fix clean target in freeze makefile (patch by Lisa
     Roach)

   - bpo-27705(12): Update message in validate_ucrtbase.py

   - bpo-27983(13): Cause lack of llvm-profdata tool when using clang as
     required for PGO linking to be a configure time error rather than
     make time when -with-optimizations is enabled.  Also improve our
     ability to find the llvm-profdata tool on MacOS and some Linuxes.

   - bpo-26307(14): The profile-opt build now applies PGO to the
     built-in modules.

   - bpo-26359(15): Add the -with-optimizations configure flag.

   - bpo-27713(16): Suppress spurious build warnings when updating
     importlib's bootstrap files.  Patch by Xiang Zhang

   - bpo-25825(17): Correct the references to Modules/python.exp and
     ld_so_aix, which are required on AIX. This updates references to an
     installation path that was changed in 3.2a4, and undoes changed
     references to the build tree that were made in 3.5.0a1.

   - bpo-27453(18): CPP invocation in configure must use CPPFLAGS. Patch
     by Chi Hsuan Yen.

   - bpo-27641(19): The configure script now inserts comments into the
     makefile to prevent the pgen and _freeze_importlib executables from
     being cross-compiled.

   - bpo-26662(20): Set PYTHON_FOR_GEN in configure as the Python
     program to be used for file generation during the build.

   - bpo-10910(21): Avoid C++ compilation errors on FreeBSD and OS X.
     Also update FreedBSD version checks for the original ctype UTF-8
     workaround.

   - bpo-28676(22): Prevent missing 'getentropy' declaration warning on
     macOS. Patch by Gareth Rees.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=29080

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23903

   (3) https://bugs.python.org/issue?@action=redirect&bpo=10656

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26359

   (5) https://bugs.python.org/issue?@action=redirect&bpo=28444

   (6) https://bugs.python.org/issue?@action=redirect&bpo=28248

   (7) https://bugs.python.org/issue?@action=redirect&bpo=28258

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26661

   (9) https://bugs.python.org/issue?@action=redirect&bpo=28066

   (10) https://bugs.python.org/issue?@action=redirect&bpo=15819

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27566

   (12) https://bugs.python.org/issue?@action=redirect&bpo=27705

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27983

   (14) https://bugs.python.org/issue?@action=redirect&bpo=26307

   (15) https://bugs.python.org/issue?@action=redirect&bpo=26359

   (16) https://bugs.python.org/issue?@action=redirect&bpo=27713

   (17) https://bugs.python.org/issue?@action=redirect&bpo=25825

   (18) https://bugs.python.org/issue?@action=redirect&bpo=27453

   (19) https://bugs.python.org/issue?@action=redirect&bpo=27641

   (20) https://bugs.python.org/issue?@action=redirect&bpo=26662

   (21) https://bugs.python.org/issue?@action=redirect&bpo=10910

   (22) https://bugs.python.org/issue?@action=redirect&bpo=28676


File: python.info,  Node: Python 3 5 2 final,  Next: Python 3 5 2 release candidate 1,  Prev: Python 3 5 3 release candidate 1,  Up: 変更履歴

1.23.93 Python 3.5.2 final
--------------------------

'Release date: 2016-06-26'

* Menu:

* Core and Builtins: Core and Builtins<82>.
* Tests: Tests<73>.
* IDLE: IDLE<58>.


File: python.info,  Node: Core and Builtins<82>,  Next: Tests<73>,  Up: Python 3 5 2 final

1.23.93.1 Core and Builtins
...........................

   - bpo-26930(1): Update Windows builds to use OpenSSL 1.0.2h.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26930


File: python.info,  Node: Tests<73>,  Next: IDLE<58>,  Prev: Core and Builtins<82>,  Up: Python 3 5 2 final

1.23.93.2 Tests
...............

   - bpo-26867(1): Ubuntu's openssl OP_NO_SSLv3 is forced on by default;
     fix test.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26867


File: python.info,  Node: IDLE<58>,  Prev: Tests<73>,  Up: Python 3 5 2 final

1.23.93.3 IDLE
..............

   - bpo-27365(1): Allow non-ascii in idlelib/NEWS.txt - minimal part
     for 3.5.2.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27365


File: python.info,  Node: Python 3 5 2 release candidate 1,  Next: Python 3 5 1 final,  Prev: Python 3 5 2 final,  Up: 変更履歴

1.23.94 Python 3.5.2 release candidate 1
----------------------------------------

'Release date: 2016-06-12'

* Menu:

* Security: Security<48>.
* Core and Builtins: Core and Builtins<83>.
* Library: Library<82>.
* IDLE: IDLE<59>.
* Documentation: Documentation<69>.
* Tests: Tests<74>.
* Build: Build<79>.
* Windows: Windows<69>.
* Tools/Demos: Tools/Demos<43>.


File: python.info,  Node: Security<48>,  Next: Core and Builtins<83>,  Up: Python 3 5 2 release candidate 1

1.23.94.1 Security
..................

   - bpo-26556(1): Update expat to 2.1.1, fixes CVE 2015-1283(2).

   - Fix TLS stripping vulnerability in smtplib, CVE 2016-0772(3).
     Reported by Team Oststrom.

   - bpo-26839(4): On Linux, *note os.urandom(): 4ec. now calls
     ‘getrandom()’ with ‘GRND_NONBLOCK’ to fall back on reading
     ‘/dev/urandom’ if the urandom entropy pool is not initialized yet.
     Patch written by Colm Buckley.

   - bpo-26657(5): Fix directory traversal vulnerability with
     http.server on Windows.  This fixes a regression that was
     introduced in 3.3.4rc1 and 3.4.0rc1.  Based on patch by Philipp
     Hagemeister.

   - bpo-26313(6): ssl.py _load_windows_store_certs fails if windows
     cert store is empty.  Patch by Baji.

   - bpo-25939(7): On Windows open the cert store readonly in
     ssl.enum_certificates.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26556

   (2) https://www.cve.org/CVERecord?id=CVE-2015-1283

   (3) https://www.cve.org/CVERecord?id=CVE-2016-0772

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26839

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26657

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26313

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25939


File: python.info,  Node: Core and Builtins<83>,  Next: Library<82>,  Prev: Security<48>,  Up: Python 3 5 2 release candidate 1

1.23.94.2 Core and Builtins
...........................

   - bpo-27066(1): Fixed SystemError if a custom opener (for open())
     returns a negative number without setting an exception.

   - bpo-20041(2): Fixed TypeError when frame.f_trace is set to None.
     Patch by Xavier de Gaye.

   - bpo-26168(3): Fixed possible refleaks in failing Py_BuildValue()
     with the "N" format unit.

   - bpo-26991(4): Fix possible refleak when creating a function with
     annotations.

   - bpo-27039(5): Fixed bytearray.remove() for values greater than 127.
     Patch by Joe Jevnik.

   - bpo-23640(6): int.from_bytes() no longer bypasses constructors for
     subclasses.

   - bpo-26811(7): gc.get_objects() no longer contains a broken tuple
     with NULL pointer.

   - bpo-20120(8): Use RawConfigParser for .pypirc parsing, removing
     support for interpolation unintentionally added with move to Python
     3.  Behavior no longer does any interpolation in .pypirc files,
     matching behavior in Python 2.7 and Setuptools 19.0.

   - bpo-26659(9): Make the builtin slice type support cycle collection.

   - bpo-26718(10): super.__init__ no longer leaks memory if called
     multiple times.  NOTE: A direct call of super.__init__ is not
     endorsed!

   - bpo-25339(11): PYTHONIOENCODING now has priority over locale in
     setting the error handler for stdin and stdout.

   - bpo-26494(12): Fixed crash on iterating exhausting iterators.
     Affected classes are generic sequence iterators, iterators of str,
     bytes, bytearray, list, tuple, set, frozenset, dict, OrderedDict,
     corresponding views and os.scandir() iterator.

   - bpo-26581(13): If coding cookie is specified multiple times on a
     line in Python source code file, only the first one is taken to
     account.

   - bpo-26464(14): Fix str.translate() when string is ASCII and first
     replacements removes character, but next replacement uses a
     non-ASCII character or a string longer than 1 character.
     Regression introduced in Python 3.5.0.

   - bpo-22836(15): Ensure exception reports from PyErr_Display() and
     PyErr_WriteUnraisable() are sensible even when formatting them
     produces secondary errors.  This affects the reports produced by
     sys.__excepthook__() and when __del__() raises an exception.

   - bpo-26302(16): Correct behavior to reject comma as a legal
     character for cookie names.

   - bpo-4806(17): Avoid masking the original TypeError exception when
     using star (‘*’) unpacking in function calls.  Based on patch by
     Hagen Fürstenau and Daniel Urban.

   - bpo-27138(18): Fix the doc comment for FileFinder.find_spec().

   - bpo-26154(19): Add a new private _PyThreadState_UncheckedGet()
     function to get the current Python thread state, but don't issue a
     fatal error if it is NULL. This new function must be used instead
     of accessing directly the _PyThreadState_Current variable.  The
     variable is no more exposed since Python 3.5.1 to hide the exact
     implementation of atomic C types, to avoid compiler issues.

   - bpo-26194(20): Deque.insert() gave odd results for bounded deques
     that had reached their maximum size.  Now an IndexError will be
     raised when attempting to insert into a full deque.

   - bpo-25843(21): When compiling code, don't merge constants if they
     are equal but have a different types.  For example, ‘f1, f2 =
     lambda: 1, lambda: 1.0’ is now correctly compiled to two different
     functions: ‘f1()’ returns ‘1’ (‘int’) and ‘f2()’ returns ‘1.0’
     (‘int’), even if ‘1’ and ‘1.0’ are equal.

   - bpo-22995(22): [UPDATE] Comment out the one of the pickleability
     tests in _PyObject_GetState() due to regressions observed in
     Cython-based projects.

   - bpo-25961(23): Disallowed null characters in the type name.

   - bpo-25973(24): Fix segfault when an invalid nonlocal statement
     binds a name starting with two underscores.

   - bpo-22995(25): Instances of extension types with a state that
     aren't subclasses of list or dict and haven't implemented any
     pickle-related methods (__reduce__, __reduce_ex__, __getnewargs__,
     __getnewargs_ex__, or __getstate__), can no longer be pickled.
     Including memoryview.

   - bpo-20440(26): Massive replacing unsafe attribute setting code with
     special macro Py_SETREF.

   - bpo-25766(27): Special method __bytes__() now works in str
     subclasses.

   - bpo-25421(28): __sizeof__ methods of builtin types now use dynamic
     basic size.  This allows sys.getsize() to work correctly with their
     subclasses with __slots__ defined.

   - bpo-25709(29): Fixed problem with in-place string concatenation and
     utf-8 cache.

   - bpo-27147(30): Mention PEP 420(31) in the importlib docs.

   - bpo-24097(32): Fixed crash in object.__reduce__() if slot name is
     freed inside __getattr__.

   - bpo-24731(33): Fixed crash on converting objects with special
     methods __bytes__, __trunc__, and __float__ returning instances of
     subclasses of bytes, int, and float to subclasses of bytes, int,
     and float correspondingly.

   - bpo-26478(34): Fix semantic bugs when using binary operators with
     dictionary views and tuples.

   - bpo-26171(35): Fix possible integer overflow and heap corruption in
     zipimporter.get_data().

   - bpo-25660(36): Fix TAB key behaviour in REPL with readline.

   - bpo-25887(37): Raise a RuntimeError when a coroutine object is
     awaited more than once.

   - bpo-27243(38): Update the __aiter__ protocol: instead of returning
     an awaitable that resolves to an asynchronous iterator, the
     asynchronous iterator should be returned directly.  Doing the
     former will trigger a PendingDeprecationWarning.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27066

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20041

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26168

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26991

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27039

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23640

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26811

   (8) https://bugs.python.org/issue?@action=redirect&bpo=20120

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26659

   (10) https://bugs.python.org/issue?@action=redirect&bpo=26718

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25339

   (12) https://bugs.python.org/issue?@action=redirect&bpo=26494

   (13) https://bugs.python.org/issue?@action=redirect&bpo=26581

   (14) https://bugs.python.org/issue?@action=redirect&bpo=26464

   (15) https://bugs.python.org/issue?@action=redirect&bpo=22836

   (16) https://bugs.python.org/issue?@action=redirect&bpo=26302

   (17) https://bugs.python.org/issue?@action=redirect&bpo=4806

   (18) https://bugs.python.org/issue?@action=redirect&bpo=27138

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26154

   (20) https://bugs.python.org/issue?@action=redirect&bpo=26194

   (21) https://bugs.python.org/issue?@action=redirect&bpo=25843

   (22) https://bugs.python.org/issue?@action=redirect&bpo=22995

   (23) https://bugs.python.org/issue?@action=redirect&bpo=25961

   (24) https://bugs.python.org/issue?@action=redirect&bpo=25973

   (25) https://bugs.python.org/issue?@action=redirect&bpo=22995

   (26) https://bugs.python.org/issue?@action=redirect&bpo=20440

   (27) https://bugs.python.org/issue?@action=redirect&bpo=25766

   (28) https://bugs.python.org/issue?@action=redirect&bpo=25421

   (29) https://bugs.python.org/issue?@action=redirect&bpo=25709

   (30) https://bugs.python.org/issue?@action=redirect&bpo=27147

   (31) https://peps.python.org/pep-0420/

   (32) https://bugs.python.org/issue?@action=redirect&bpo=24097

   (33) https://bugs.python.org/issue?@action=redirect&bpo=24731

   (34) https://bugs.python.org/issue?@action=redirect&bpo=26478

   (35) https://bugs.python.org/issue?@action=redirect&bpo=26171

   (36) https://bugs.python.org/issue?@action=redirect&bpo=25660

   (37) https://bugs.python.org/issue?@action=redirect&bpo=25887

   (38) https://bugs.python.org/issue?@action=redirect&bpo=27243


File: python.info,  Node: Library<82>,  Next: IDLE<59>,  Prev: Core and Builtins<83>,  Up: Python 3 5 2 release candidate 1

1.23.94.3 Library
.................

   - bpo-21386(1): Implement missing IPv4Address.is_global property.  It
     was documented since 07a5610bae9d.  Initial patch by Roger Luethi.

   - bpo-20900(2): distutils register command now decodes HTTP responses
     correctly.  Initial patch by ingrid.

   - A new version of typing.py provides several new classes and
     features: @overload outside stubs, Reversible, DefaultDict, Text,
     ContextManager, Type[], NewType(), TYPE_CHECKING, and numerous bug
     fixes (note that some of the new features are not yet implemented
     in mypy or other static analyzers).  Also classes for PEP 492(3)
     (Awaitable, AsyncIterable, AsyncIterator) have been added (in fact
     they made it into 3.5.1 but were never mentioned).

   - bpo-25738(4): Stop http.server.BaseHTTPRequestHandler.send_error()
     from sending a message body for 205 Reset Content.  Also, don't
     send Content header fields in responses that don't have a body.
     Patch by Susumu Koshiba.

   - bpo-21313(5): Fix the "platform" module to tolerate when
     sys.version contains truncated build information.

   - bpo-27164(6): In the zlib module, allow decompressing raw Deflate
     streams with a predefined zdict.  Based on patch by Xiang Zhang.

   - bpo-24291(7): Fix wsgiref.simple_server.WSGIRequestHandler to
     completely write data to the client.  Previously it could do
     partial writes and truncate data.  Also,
     wsgiref.handler.ServerHandler can now handle stdout doing partial
     writes, but this is deprecated.

   - bpo-26809(8): Add ‘__all__’ to *note string: be.  Patch by Emanuel
     Barry.

   - bpo-26373(9): subprocess.Popen.communicate now correctly ignores
     BrokenPipeError when the child process dies before .communicate()
     is called in more/all circumstances.

   - bpo-21776(10): distutils.upload now correctly handles HTTPError.
     Initial patch by Claudiu Popa.

   - bpo-27114(11): Fix SSLContext._load_windows_store_certs fails with
     PermissionError

   - bpo-18383(12): Avoid creating duplicate filters when using
     filterwarnings and simplefilter.  Based on patch by Alex Shkop.

   - bpo-27057(13): Fix os.set_inheritable() on Android, ioctl() is
     blocked by SELinux and fails with EACCESS. The function now falls
     back to fcntl().  Patch written by Michał Bednarski.

   - bpo-27014(14): Fix infinite recursion using typing.py.  Thanks to
     Kalle Tuure!

   - bpo-14132(15): Fix urllib.request redirect handling when the target
     only has a query string.  Original fix by Ján Janech.

   - bpo-17214(16): The "urllib.request" module now percent-encodes
     non-ASCII bytes found in redirect target URLs.  Some servers send
     Location header fields with non-ASCII bytes, but "http.client"
     requires the request target to be ASCII-encodable, otherwise a
     UnicodeEncodeError is raised.  Based on patch by Christian Heimes.

   - bpo-26892(17): Honor debuglevel flag in urllib.request.HTTPHandler.
     Patch contributed by Chi Hsuan Yen.

   - bpo-22274(18): In the subprocess module, allow stderr to be
     redirected to stdout even when stdout is not redirected.  Patch by
     Akira Li.

   - bpo-26807(19): mock_open 'files' no longer error on readline at end
     of file.  Patch from Yolanda Robla.

   - bpo-25745(20): Fixed leaking a userptr in curses panel destructor.

   - bpo-26977(21): Removed unnecessary, and ignored, call to sum of
     squares helper in statistics.pvariance.

   - bpo-26881(22): The modulefinder module now supports extended opcode
     arguments.

   - bpo-23815(23): Fixed crashes related to directly created instances
     of types in _tkinter and curses.panel modules.

   - bpo-17765(24): weakref.ref() no longer silently ignores keyword
     arguments.  Patch by Georg Brandl.

   - bpo-26873(25): xmlrpc now raises ResponseError on unsupported type
     tags instead of silently return incorrect result.

   - bpo-26711(26): Fixed the comparison of plistlib.Data with other
     types.

   - bpo-24114(27): Fix an uninitialized variable in ‘ctypes.util’.  The
     bug only occurs on SunOS when the ctypes implementation searches
     for the ‘crle’ program.  Patch by Xiang Zhang.  Tested on SunOS by
     Kees Bos.

   - bpo-26864(28): In urllib.request, change the proxy bypass host
     checking against no_proxy to be case-insensitive, and to not match
     unrelated host names that happen to have a bypassed hostname as a
     suffix.  Patch by Xiang Zhang.

   - bpo-26634(29): recursive_repr() now sets __qualname__ of wrapper.
     Patch by Xiang Zhang.

   - bpo-26804(30): urllib.request will prefer lower_case proxy
     environment variables over UPPER_CASE or Mixed_Case ones.  Patch
     contributed by Hans-Peter Jansen.

   - bpo-26837(31): assertSequenceEqual() now correctly outputs
     non-stringified differing items (like bytes in the -b mode).  This
     affects assertListEqual() and assertTupleEqual().

   - bpo-26041(32): Remove "will be removed in Python 3.7" from
     deprecation messages of platform.dist() and
     platform.linux_distribution().  Patch by Kumaripaba Miyurusara
     Athukorala.

   - bpo-26822(33): itemgetter, attrgetter and methodcaller objects no
     longer silently ignore keyword arguments.

   - bpo-26733(34): Disassembling a class now disassembles class and
     static methods.  Patch by Xiang Zhang.

   - bpo-26801(35): Fix error handling in *note
     shutil.get_terminal_size(): 10d6, catch *note AttributeError: 326.
     instead of *note NameError: 40b.  Patch written by Emanuel Barry.

   - bpo-24838(36): tarfile's ustar and gnu formats now correctly
     calculate name and link field limits for multibyte character
     encodings like utf-8.

   - bpo-26717(37): Stop encoding Latin-1-ized WSGI paths with UTF-8.
     Patch by Anthony Sottile.

   - bpo-26735(38): Fix *note os.urandom(): 4ec. on Solaris 11.3 and
     newer when reading more than 1,024 bytes: call ‘getrandom()’
     multiple times with a limit of 1024 bytes per call.

   - bpo-16329(39): Add .webm to mimetypes.types_map.  Patch by
     Giampaolo Rodola'.

   - bpo-13952(40): Add .csv to mimetypes.types_map.  Patch by Geoff
     Wilson.

   - bpo-26709(41): Fixed Y2038 problem in loading binary PLists.

   - bpo-23735(42): Handle terminal resizing with Readline 6.3+ by
     installing our own SIGWINCH handler.  Patch by Eric Price.

   - bpo-26586(43): In http.server, respond with "413 Request header
     fields too large" if there are too many header fields to parse,
     rather than killing the connection and raising an unhandled
     exception.  Patch by Xiang Zhang.

   - bpo-22854(44): Change BufferedReader.writable() and
     BufferedWriter.readable() to always return False.

   - bpo-25195(45): Fix a regression in mock.MagicMock.  _Call is a
     subclass of tuple (changeset 3603bae63c13 only works for classes)
     so we need to implement __ne__ ourselves.  Patch by Andrew Plummer.

   - bpo-26644(46): Raise ValueError rather than SystemError when a
     negative length is passed to SSLSocket.recv() or read().

   - bpo-23804(47): Fix SSL recv(0) and read(0) methods to return zero
     bytes instead of up to 1024.

   - bpo-26616(48): Fixed a bug in datetime.astimezone() method.

   - bpo-21925(49): *note warnings.formatwarning(): 1980. now catches
     exceptions on ‘linecache.getline(...)’ to be able to log *note
     ResourceWarning: 225. emitted late during the Python shutdown
     process.

   - bpo-24266(50): Ctrl+C during Readline history search now cancels
     the search mode when compiled with Readline 7.

   - bpo-26560(51): Avoid potential ValueError in
     BaseHandler.start_response.  Initial patch by Peter Inglesby.

   - bpo-26569(52): Fix *note pyclbr.readmodule(): 7f6. and *note
     pyclbr.readmodule_ex(): 7f7. to support importing packages.

   - bpo-26499(53): Account for remaining Content-Length in
     HTTPResponse.readline() and read1().  Based on patch by Silent
     Ghost.  Also document that HTTPResponse now supports these methods.

   - bpo-25320(54): Handle sockets in directories unittest discovery is
     scanning.  Patch from Victor van den Elzen.

   - bpo-16181(55): cookiejar.http2time() now returns None if year is
     higher than datetime.MAXYEAR.

   - bpo-26513(56): Fixes platform module detection of Windows Server

   - bpo-23718(57): Fixed parsing time in week 0 before Jan 1.  Original
     patch by Tamás Bence Gedai.

   - bpo-20589(58): Invoking Path.owner() and Path.group() on Windows
     now raise NotImplementedError instead of ImportError.

   - bpo-26177(59): Fixed the keys() method for Canvas and Scrollbar
     widgets.

   - bpo-15068(60): Got rid of excessive buffering in the fileinput
     module.  The bufsize parameter is no longer used.

   - bpo-2202(61): Fix UnboundLocalError in
     AbstractDigestAuthHandler.get_algorithm_impls.  Initial patch by
     Mathieu Dupuy.

   - bpo-25718(62): Fixed pickling and copying the accumulate() iterator
     with total is None.

   - bpo-26475(63): Fixed debugging output for regular expressions with
     the (?x) flag.

   - bpo-26457(64): Fixed the subnets() methods in IP network classes
     for the case when resulting prefix length is equal to maximal
     prefix length.  Based on patch by Xiang Zhang.

   - bpo-26385(65): Remove the file if the internal open() call in
     NamedTemporaryFile() fails.  Patch by Silent Ghost.

   - bpo-26402(66): Fix XML-RPC client to retry when the server shuts
     down a persistent connection.  This was a regression related to the
     new http.client.RemoteDisconnected exception in 3.5.0a4.

   - bpo-25913(67): Leading ‘<~’ is optional now in base64.a85decode()
     with adobe=True.  Patch by Swati Jaiswal.

   - bpo-26186(68): Remove an invalid type check in
     importlib.util.LazyLoader.

   - bpo-26367(69): importlib.__import__() raises SystemError like
     builtins.__import__() when ‘level’ is specified but without an
     accompanying package specified.

   - bpo-26309(70): In the "socketserver" module, shut down the request
     (closing the connected socket) when verify_request() returns false.
     Patch by Aviv Palivoda.

   - bpo-25995(71): os.walk() no longer uses FDs proportional to the
     tree depth.

   - bpo-26117(72): The os.scandir() iterator now closes file descriptor
     not only when the iteration is finished, but when it was failed
     with error.

   - bpo-25911(73): Restored support of bytes paths in os.walk() on
     Windows.

   - bpo-26045(74): Add UTF-8 suggestion to error message when posting a
     non-Latin-1 string with http.client.

   - bpo-12923(75): Reset FancyURLopener's redirect counter even if
     there is an exception.  Based on patches by Brian Brazil and Daniel
     Rocco.

   - bpo-25945(76): Fixed a crash when unpickle the functools.partial
     object with wrong state.  Fixed a leak in failed functools.partial
     constructor.  "args" and "keywords" attributes of functools.partial
     have now always types tuple and dict correspondingly.

   - bpo-26202(77): copy.deepcopy() now correctly copies range() objects
     with non-atomic attributes.

   - bpo-23076(78): Path.glob() now raises a ValueError if it's called
     with an invalid pattern.  Patch by Thomas Nyberg.

   - bpo-19883(79): Fixed possible integer overflows in zipimport.

   - bpo-26227(80): On Windows, getnameinfo(), gethostbyaddr() and
     gethostbyname_ex() functions of the socket module now decode the
     hostname from the ANSI code page rather than UTF-8.

   - bpo-26147(81): xmlrpc now works with strings not encodable with
     used non-UTF-8 encoding.

   - bpo-25935(82): Garbage collector now breaks reference loops with
     OrderedDict.

   - bpo-16620(83): Fixed AttributeError in msilib.Directory.glob().

   - bpo-26013(84): Added compatibility with broken protocol 2 pickles
     created in old Python 3 versions (3.4.3 and lower).

   - bpo-25850(85): Use cross-compilation by default for 64-bit Windows.

   - bpo-17633(86): Improve zipimport's support for namespace packages.

   - bpo-24705(87): Fix sysconfig._parse_makefile not expanding ${} vars
     appearing before $() vars.

   - bpo-22138(88): Fix mock.patch behavior when patching descriptors.
     Restore original values after patching.  Patch contributed by Sean
     McCully.

   - bpo-25672(89): In the ssl module, enable the
     SSL_MODE_RELEASE_BUFFERS mode option if it is safe to do so.

   - bpo-26012(90): Don't traverse into symlinks for ‘**’ pattern in
     pathlib.Path.[r]glob().

   - bpo-24120(91): Ignore PermissionError when traversing a tree with
     pathlib.Path.[r]glob().  Patch by Ulrich Petri.

   - bpo-25447(92): fileinput now uses sys.stdin as-is if it does not
     have a buffer attribute (restores backward compatibility).

   - bpo-25447(93): Copying the lru_cache() wrapper object now always
     works, independently from the type of the wrapped object (by
     returning the original object unchanged).

   - bpo-24103(94): Fixed possible use after free in
     ElementTree.XMLPullParser.

   - bpo-25860(95): os.fwalk() no longer skips remaining directories
     when error occurs.  Original patch by Samson Lee.

   - bpo-25914(96): Fixed and simplified OrderedDict.__sizeof__.

   - bpo-25902(97): Fixed various refcount issues in ElementTree
     iteration.

   - bpo-25717(98): Restore the previous behaviour of tolerating most
     fstat() errors when opening files.  This was a regression in 3.5a1,
     and stopped anonymous temporary files from working in special
     cases.

   - bpo-24903(99): Fix regression in number of arguments compileall
     accepts when '-d' is specified.  The check on the number of
     arguments has been dropped completely as it never worked correctly
     anyway.

   - bpo-25764(100): In the subprocess module, preserve any exception
     caused by fork() failure when preexec_fn is used.

   - bpo-6478(101): _strptime's regexp cache now is reset after changing
     timezone with time.tzset().

   - bpo-14285(102): When executing a package with the "python -m
     package" option, and package initialization fails, a proper
     traceback is now reported.  The "runpy" module now lets exceptions
     from package initialization pass back to the caller, rather than
     raising ImportError.

   - bpo-19771(103): Also in runpy and the "-m" option, omit the
     irrelevant message ".  .  .  is a package and cannot be directly
     executed" if the package could not even be initialized (e.g.  due
     to a bad ‘*.pyc’ file).

   - bpo-25177(104): Fixed problem with the mean of very small and very
     large numbers.  As a side effect, statistics.mean and
     statistics.variance should be significantly faster.

   - bpo-25718(105): Fixed copying object with state with boolean value
     is false.

   - bpo-10131(106): Fixed deep copying of minidom documents.  Based on
     patch by Marian Ganisin.

   - bpo-25725(107): Fixed a reference leak in pickle.loads() when
     unpickling invalid data including tuple instructions.

   - bpo-25663(108): In the Readline completer, avoid listing duplicate
     global names, and search the global namespace before searching
     builtins.

   - bpo-25688(109): Fixed file leak in ElementTree.iterparse() raising
     an error.

   - bpo-23914(110): Fixed SystemError raised by unpickler on broken
     pickle data.

   - bpo-25691(111): Fixed crash on deleting ElementTree.Element
     attributes.

   - bpo-25624(112): ZipFile now always writes a ZIP_STORED header for
     directory entries.  Patch by Dingyuan Wang.

   - Skip getaddrinfo if host is already resolved.  Patch by A. Jesse
     Jiryu Davis.

   - bpo-26050(113): Add asyncio.StreamReader.readuntil() method.  Patch
     by Марк Коренберг.

   - bpo-25924(114): Avoid unnecessary serialization of getaddrinfo(3)
     calls on OS X versions 10.5 or higher.  Original patch by A. Jesse
     Jiryu Davis.

   - bpo-26406(115): Avoid unnecessary serialization of getaddrinfo(3)
     calls on current versions of OpenBSD and NetBSD. Patch by A. Jesse
     Jiryu Davis.

   - bpo-26848(116): Fix asyncio/subprocess.communicate() to handle
     empty input.  Patch by Jack O'Connor.

   - bpo-27040(117): Add loop.get_exception_handler method

   - bpo-27041(118): asyncio: Add loop.create_future method

   - bpo-27223(119): asyncio: Fix _read_ready and _write_ready to
     respect _conn_lost.  Patch by Łukasz Langa.

   - bpo-22970(120): asyncio: Fix inconsistency cancelling
     Condition.wait.  Patch by David Coles.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21386

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20900

   (3) https://peps.python.org/pep-0492/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25738

   (5) https://bugs.python.org/issue?@action=redirect&bpo=21313

   (6) https://bugs.python.org/issue?@action=redirect&bpo=27164

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24291

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26809

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26373

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21776

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27114

   (12) https://bugs.python.org/issue?@action=redirect&bpo=18383

   (13) https://bugs.python.org/issue?@action=redirect&bpo=27057

   (14) https://bugs.python.org/issue?@action=redirect&bpo=27014

   (15) https://bugs.python.org/issue?@action=redirect&bpo=14132

   (16) https://bugs.python.org/issue?@action=redirect&bpo=17214

   (17) https://bugs.python.org/issue?@action=redirect&bpo=26892

   (18) https://bugs.python.org/issue?@action=redirect&bpo=22274

   (19) https://bugs.python.org/issue?@action=redirect&bpo=26807

   (20) https://bugs.python.org/issue?@action=redirect&bpo=25745

   (21) https://bugs.python.org/issue?@action=redirect&bpo=26977

   (22) https://bugs.python.org/issue?@action=redirect&bpo=26881

   (23) https://bugs.python.org/issue?@action=redirect&bpo=23815

   (24) https://bugs.python.org/issue?@action=redirect&bpo=17765

   (25) https://bugs.python.org/issue?@action=redirect&bpo=26873

   (26) https://bugs.python.org/issue?@action=redirect&bpo=26711

   (27) https://bugs.python.org/issue?@action=redirect&bpo=24114

   (28) https://bugs.python.org/issue?@action=redirect&bpo=26864

   (29) https://bugs.python.org/issue?@action=redirect&bpo=26634

   (30) https://bugs.python.org/issue?@action=redirect&bpo=26804

   (31) https://bugs.python.org/issue?@action=redirect&bpo=26837

   (32) https://bugs.python.org/issue?@action=redirect&bpo=26041

   (33) https://bugs.python.org/issue?@action=redirect&bpo=26822

   (34) https://bugs.python.org/issue?@action=redirect&bpo=26733

   (35) https://bugs.python.org/issue?@action=redirect&bpo=26801

   (36) https://bugs.python.org/issue?@action=redirect&bpo=24838

   (37) https://bugs.python.org/issue?@action=redirect&bpo=26717

   (38) https://bugs.python.org/issue?@action=redirect&bpo=26735

   (39) https://bugs.python.org/issue?@action=redirect&bpo=16329

   (40) https://bugs.python.org/issue?@action=redirect&bpo=13952

   (41) https://bugs.python.org/issue?@action=redirect&bpo=26709

   (42) https://bugs.python.org/issue?@action=redirect&bpo=23735

   (43) https://bugs.python.org/issue?@action=redirect&bpo=26586

   (44) https://bugs.python.org/issue?@action=redirect&bpo=22854

   (45) https://bugs.python.org/issue?@action=redirect&bpo=25195

   (46) https://bugs.python.org/issue?@action=redirect&bpo=26644

   (47) https://bugs.python.org/issue?@action=redirect&bpo=23804

   (48) https://bugs.python.org/issue?@action=redirect&bpo=26616

   (49) https://bugs.python.org/issue?@action=redirect&bpo=21925

   (50) https://bugs.python.org/issue?@action=redirect&bpo=24266

   (51) https://bugs.python.org/issue?@action=redirect&bpo=26560

   (52) https://bugs.python.org/issue?@action=redirect&bpo=26569

   (53) https://bugs.python.org/issue?@action=redirect&bpo=26499

   (54) https://bugs.python.org/issue?@action=redirect&bpo=25320

   (55) https://bugs.python.org/issue?@action=redirect&bpo=16181

   (56) https://bugs.python.org/issue?@action=redirect&bpo=26513

   (57) https://bugs.python.org/issue?@action=redirect&bpo=23718

   (58) https://bugs.python.org/issue?@action=redirect&bpo=20589

   (59) https://bugs.python.org/issue?@action=redirect&bpo=26177

   (60) https://bugs.python.org/issue?@action=redirect&bpo=15068

   (61) https://bugs.python.org/issue?@action=redirect&bpo=2202

   (62) https://bugs.python.org/issue?@action=redirect&bpo=25718

   (63) https://bugs.python.org/issue?@action=redirect&bpo=26475

   (64) https://bugs.python.org/issue?@action=redirect&bpo=26457

   (65) https://bugs.python.org/issue?@action=redirect&bpo=26385

   (66) https://bugs.python.org/issue?@action=redirect&bpo=26402

   (67) https://bugs.python.org/issue?@action=redirect&bpo=25913

   (68) https://bugs.python.org/issue?@action=redirect&bpo=26186

   (69) https://bugs.python.org/issue?@action=redirect&bpo=26367

   (70) https://bugs.python.org/issue?@action=redirect&bpo=26309

   (71) https://bugs.python.org/issue?@action=redirect&bpo=25995

   (72) https://bugs.python.org/issue?@action=redirect&bpo=26117

   (73) https://bugs.python.org/issue?@action=redirect&bpo=25911

   (74) https://bugs.python.org/issue?@action=redirect&bpo=26045

   (75) https://bugs.python.org/issue?@action=redirect&bpo=12923

   (76) https://bugs.python.org/issue?@action=redirect&bpo=25945

   (77) https://bugs.python.org/issue?@action=redirect&bpo=26202

   (78) https://bugs.python.org/issue?@action=redirect&bpo=23076

   (79) https://bugs.python.org/issue?@action=redirect&bpo=19883

   (80) https://bugs.python.org/issue?@action=redirect&bpo=26227

   (81) https://bugs.python.org/issue?@action=redirect&bpo=26147

   (82) https://bugs.python.org/issue?@action=redirect&bpo=25935

   (83) https://bugs.python.org/issue?@action=redirect&bpo=16620

   (84) https://bugs.python.org/issue?@action=redirect&bpo=26013

   (85) https://bugs.python.org/issue?@action=redirect&bpo=25850

   (86) https://bugs.python.org/issue?@action=redirect&bpo=17633

   (87) https://bugs.python.org/issue?@action=redirect&bpo=24705

   (88) https://bugs.python.org/issue?@action=redirect&bpo=22138

   (89) https://bugs.python.org/issue?@action=redirect&bpo=25672

   (90) https://bugs.python.org/issue?@action=redirect&bpo=26012

   (91) https://bugs.python.org/issue?@action=redirect&bpo=24120

   (92) https://bugs.python.org/issue?@action=redirect&bpo=25447

   (93) https://bugs.python.org/issue?@action=redirect&bpo=25447

   (94) https://bugs.python.org/issue?@action=redirect&bpo=24103

   (95) https://bugs.python.org/issue?@action=redirect&bpo=25860

   (96) https://bugs.python.org/issue?@action=redirect&bpo=25914

   (97) https://bugs.python.org/issue?@action=redirect&bpo=25902

   (98) https://bugs.python.org/issue?@action=redirect&bpo=25717

   (99) https://bugs.python.org/issue?@action=redirect&bpo=24903

   (100) https://bugs.python.org/issue?@action=redirect&bpo=25764

   (101) https://bugs.python.org/issue?@action=redirect&bpo=6478

   (102) https://bugs.python.org/issue?@action=redirect&bpo=14285

   (103) https://bugs.python.org/issue?@action=redirect&bpo=19771

   (104) https://bugs.python.org/issue?@action=redirect&bpo=25177

   (105) https://bugs.python.org/issue?@action=redirect&bpo=25718

   (106) https://bugs.python.org/issue?@action=redirect&bpo=10131

   (107) https://bugs.python.org/issue?@action=redirect&bpo=25725

   (108) https://bugs.python.org/issue?@action=redirect&bpo=25663

   (109) https://bugs.python.org/issue?@action=redirect&bpo=25688

   (110) https://bugs.python.org/issue?@action=redirect&bpo=23914

   (111) https://bugs.python.org/issue?@action=redirect&bpo=25691

   (112) https://bugs.python.org/issue?@action=redirect&bpo=25624

   (113) https://bugs.python.org/issue?@action=redirect&bpo=26050

   (114) https://bugs.python.org/issue?@action=redirect&bpo=25924

   (115) https://bugs.python.org/issue?@action=redirect&bpo=26406

   (116) https://bugs.python.org/issue?@action=redirect&bpo=26848

   (117) https://bugs.python.org/issue?@action=redirect&bpo=27040

   (118) https://bugs.python.org/issue?@action=redirect&bpo=27041

   (119) https://bugs.python.org/issue?@action=redirect&bpo=27223

   (120) https://bugs.python.org/issue?@action=redirect&bpo=22970


File: python.info,  Node: IDLE<59>,  Next: Documentation<69>,  Prev: Library<82>,  Up: Python 3 5 2 release candidate 1

1.23.94.4 IDLE
..............

   - bpo-5124(1): Paste with text selected now replaces the selection on
     X11.  This matches how paste works on Windows, Mac, most modern
     Linux apps, and ttk widgets.  Original patch by Serhiy Storchaka.

   - bpo-24759(2): Make clear in idlelib.idle_test.__init__ that the
     directory is a private implementation of test.test_idle and tool
     for maintainers.

   - bpo-27196(3): Stop 'ThemeChanged' warnings when running IDLE tests.
     These persisted after other warnings were suppressed in #20567.
     Apply Serhiy Storchaka's update_idletasks solution to four test
     files.  Record this additional advice in idle_test/README.txt

   - bpo-20567(4): Revise idle_test/README.txt with advice about
     avoiding tk warning messages from tests.  Apply advice to several
     IDLE tests.

   - bpo-27117(5): Make colorizer htest and turtledemo work with dark
     themes.  Move code for configuring text widget colors to a new
     function.

   - bpo-26673(6): When tk reports font size as 0, change to size 10.
     Such fonts on Linux prevented the configuration dialog from
     opening.

   - bpo-21939(7): Add test for IDLE's percolator.  Original patch by
     Saimadhav Heblikar.

   - bpo-21676(8): Add test for IDLE's replace dialog.  Original patch
     by Saimadhav Heblikar.

   - bpo-18410(9): Add test for IDLE's search dialog.  Original patch by
     Westley Martínez.

   - bpo-21703(10): Add test for IDLE's undo delegator.  Original patch
     by Saimadhav Heblikar .

   - bpo-27044(11): Add ConfigDialog.remove_var_callbacks to stop memory
     leaks.

   - bpo-23977(12): Add more asserts to test_delegator.

   - bpo-20640(13): Add tests for idlelib.configHelpSourceEdit.  Patch
     by Saimadhav Heblikar.

   - In the 'IDLE-console differences' section of the IDLE doc, clarify
     how running with IDLE affects sys.modules and the standard streams.

   - bpo-25507(14): fix incorrect change in IOBinding that prevented
     printing.  Augment IOBinding htest to include all major IOBinding
     functions.

   - bpo-25905(15): Revert unwanted conversion of ' to ’ RIGHT SINGLE
     QUOTATION MARK in README.txt and open this and NEWS.txt with
     'ascii'.  Re-encode CREDITS.txt to utf-8 and open it with 'utf-8'.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5124

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24759

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27196

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20567

   (5) https://bugs.python.org/issue?@action=redirect&bpo=27117

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26673

   (7) https://bugs.python.org/issue?@action=redirect&bpo=21939

   (8) https://bugs.python.org/issue?@action=redirect&bpo=21676

   (9) https://bugs.python.org/issue?@action=redirect&bpo=18410

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21703

   (11) https://bugs.python.org/issue?@action=redirect&bpo=27044

   (12) https://bugs.python.org/issue?@action=redirect&bpo=23977

   (13) https://bugs.python.org/issue?@action=redirect&bpo=20640

   (14) https://bugs.python.org/issue?@action=redirect&bpo=25507

   (15) https://bugs.python.org/issue?@action=redirect&bpo=25905


File: python.info,  Node: Documentation<69>,  Next: Tests<74>,  Prev: IDLE<59>,  Up: Python 3 5 2 release candidate 1

1.23.94.5 Documentation
.......................

   - bpo-19489(1): Moved the search box from the sidebar to the header
     and footer of each page.  Patch by Ammar Askar.

   - bpo-24136(2): Document the new PEP 448(3) unpacking syntax of 3.5.

   - bpo-26736(4): Used HTTPS for external links in the documentation if
     possible.

   - bpo-6953(5): Rework the Readline module documentation to group
     related functions together, and add more details such as what
     underlying Readline functions and variables are accessed.

   - bpo-23606(6): Adds note to ctypes documentation regarding
     cdll.msvcrt.

   - bpo-25500(7): Fix documentation to not claim that __import__ is
     searched for in the global scope.

   - bpo-26014(8): Update 3.x packaging documentation: * "See also"
     links to the new docs are now provided in the legacy pages * links
     to setuptools documentation have been updated

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19489

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24136

   (3) https://peps.python.org/pep-0448/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26736

   (5) https://bugs.python.org/issue?@action=redirect&bpo=6953

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23606

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25500

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26014


File: python.info,  Node: Tests<74>,  Next: Build<79>,  Prev: Documentation<69>,  Up: Python 3 5 2 release candidate 1

1.23.94.6 Tests
...............

   - bpo-21916(1): Added tests for the turtle module.  Patch by ingrid,
     Gregory Loyse and Jelle Zijlstra.

   - bpo-26523(2): The multiprocessing thread pool
     (multiprocessing.dummy.Pool) was untested.

   - bpo-26015(3): Added new tests for pickling iterators of mutable
     sequences.

   - bpo-26325(4): Added test.support.check_no_resource_warning() to
     check that no ResourceWarning is emitted.

   - bpo-25940(5): Changed test_ssl to use self-signed.pythontest.net.
     This avoids relying on svn.python.org, which recently changed root
     certificate.

   - bpo-25616(6): Tests for OrderedDict are extracted from
     test_collections into separate file test_ordered_dict.

   - bpo-26583(7): Skip test_timestamp_overflow in test_import if
     bytecode files cannot be written.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21916

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26523

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26015

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26325

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25940

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25616

   (7) https://bugs.python.org/issue?@action=redirect&bpo=26583


File: python.info,  Node: Build<79>,  Next: Windows<69>,  Prev: Tests<74>,  Up: Python 3 5 2 release candidate 1

1.23.94.7 Build
...............

   - bpo-26884(1): Fix linking extension modules for cross builds.
     Patch by Xavier de Gaye.

   - bpo-22359(2): Disable the rules for running _freeze_importlib and
     pgen when cross-compiling.  The output of these programs is
     normally saved with the source code anyway, and is still
     regenerated when doing a native build.  Patch by Xavier de Gaye.

   - bpo-27229(3): Fix the cross-compiling pgen rule for in-tree builds.
     Patch by Xavier de Gaye.

   - bpo-21668(4): Link audioop, _datetime, _ctypes_test modules to
     libm, except on Mac OS X. Patch written by Xavier de Gaye.

   - bpo-25702(5): A -with-lto configure option has been added that will
     enable link time optimizations at build time during a make
     profile-opt.  Some compilers and toolchains are known to not
     produce stable code when using LTO, be sure to test things
     thoroughly before relying on it.  It can provide a few % speed up
     over profile-opt alone.

   - bpo-26624(6): Adds validation of ucrtbase[d].dll version with
     warning for old versions.

   - bpo-17603(7): Avoid error about nonexistent fileblocks.o file by
     using a lower-level check for st_blocks in struct stat.

   - bpo-26079(8): Fixing the build output folder for tix-8.4.3.6.
     Patch by Bjoern Thiel.

   - bpo-26465(9): Update Windows builds to use OpenSSL 1.0.2g.

   - bpo-24421(10): Compile Modules/_math.c once, before building
     extensions.  Previously it could fail to compile properly if the
     math and cmath builds were concurrent.

   - bpo-25348(11): Added ‘--pgo’ and ‘--pgo-job’ arguments to
     ‘PCbuild\build.bat’ for building with Profile-Guided Optimization.
     The old ‘PCbuild\build_pgo.bat’ script is now deprecated, and
     simply calls ‘PCbuild\build.bat --pgo %*’.

   - bpo-25827(12): Add support for building with ICC to ‘configure’,
     including a new ‘--with-icc’ flag.

   - bpo-25696(13): Fix installation of Python on UNIX with make -j9.

   - bpo-26930(14): Update OS X 10.5+ 32-bit-only installer to build and
     link with OpenSSL 1.0.2h.

   - bpo-26268(15): Update Windows builds to use OpenSSL 1.0.2f.

   - bpo-25136(16): Support Apple Xcode 7's new textual SDK stub
     libraries.

   - bpo-24324(17): Do not enable unreachable code warnings when using
     gcc as the option does not work correctly in older versions of gcc
     and has been silently removed as of gcc-4.5.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26884

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22359

   (3) https://bugs.python.org/issue?@action=redirect&bpo=27229

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21668

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25702

   (6) https://bugs.python.org/issue?@action=redirect&bpo=26624

   (7) https://bugs.python.org/issue?@action=redirect&bpo=17603

   (8) https://bugs.python.org/issue?@action=redirect&bpo=26079

   (9) https://bugs.python.org/issue?@action=redirect&bpo=26465

   (10) https://bugs.python.org/issue?@action=redirect&bpo=24421

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25348

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25827

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25696

   (14) https://bugs.python.org/issue?@action=redirect&bpo=26930

   (15) https://bugs.python.org/issue?@action=redirect&bpo=26268

   (16) https://bugs.python.org/issue?@action=redirect&bpo=25136

   (17) https://bugs.python.org/issue?@action=redirect&bpo=24324


File: python.info,  Node: Windows<69>,  Next: Tools/Demos<43>,  Prev: Build<79>,  Up: Python 3 5 2 release candidate 1

1.23.94.8 Windows
.................

   - bpo-27053(1): Updates make_zip.py to correctly generate library ZIP
     file.

   - bpo-26268(2): Update the prepare_ssl.py script to handle OpenSSL
     releases that don't include the contents of the include directory
     (that is, 1.0.2e and later).

   - bpo-26071(3): bdist_wininst created binaries fail to start and find
     32bit Python

   - bpo-26073(4): Update the list of magic numbers in launcher

   - bpo-26065(5): Excludes venv from library when generating embeddable
     distro.

   - bpo-17500(6): Remove unused and outdated icons.  (See also:
     ‘https://github.com/python/pythondotorg/issues/945’)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=27053

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26268

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26071

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26073

   (5) https://bugs.python.org/issue?@action=redirect&bpo=26065

   (6) https://bugs.python.org/issue?@action=redirect&bpo=17500


File: python.info,  Node: Tools/Demos<43>,  Prev: Windows<69>,  Up: Python 3 5 2 release candidate 1

1.23.94.9 Tools/Demos
.....................

   - bpo-26799(1): Fix python-gdb.py: don't get C types once when the
     Python code is loaded, but get C types on demand.  The C types can
     change if python-gdb.py is loaded before the Python executable.
     Patch written by Thomas Ilsche.

   - bpo-26271(2): Fix the Freeze tool to properly use flags passed
     through configure.  Patch by Daniel Shaulov.

   - bpo-26489(3): Add dictionary unpacking support to
     Tools/parser/unparse.py.  Patch by Guo Ci Teo.

   - bpo-26316(4): Fix variable name typo in Argument Clinic.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=26799

   (2) https://bugs.python.org/issue?@action=redirect&bpo=26271

   (3) https://bugs.python.org/issue?@action=redirect&bpo=26489

   (4) https://bugs.python.org/issue?@action=redirect&bpo=26316


File: python.info,  Node: Python 3 5 1 final,  Next: Python 3 5 1 release candidate 1,  Prev: Python 3 5 2 release candidate 1,  Up: 変更履歴

1.23.95 Python 3.5.1 final
--------------------------

'Release date: 2015-12-06'

* Menu:

* Core and Builtins: Core and Builtins<84>.
* Windows: Windows<70>.


File: python.info,  Node: Core and Builtins<84>,  Next: Windows<70>,  Up: Python 3 5 1 final

1.23.95.1 Core and Builtins
...........................

   - bpo-25709(1): Fixed problem with in-place string concatenation and
     utf-8 cache.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25709


File: python.info,  Node: Windows<70>,  Prev: Core and Builtins<84>,  Up: Python 3 5 1 final

1.23.95.2 Windows
.................

   - bpo-25715(1): Python 3.5.1 installer shows wrong upgrade path and
     incorrect logic for launcher detection.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25715


File: python.info,  Node: Python 3 5 1 release candidate 1,  Next: Python 3 5 0 final,  Prev: Python 3 5 1 final,  Up: 変更履歴

1.23.96 Python 3.5.1 release candidate 1
----------------------------------------

'Release date: 2015-11-22'

* Menu:

* Core and Builtins: Core and Builtins<85>.
* Library: Library<83>.
* IDLE: IDLE<60>.
* Documentation: Documentation<70>.
* Tests: Tests<75>.
* Build: Build<80>.
* Windows: Windows<71>.
* Tools/Demos: Tools/Demos<44>.


File: python.info,  Node: Core and Builtins<85>,  Next: Library<83>,  Up: Python 3 5 1 release candidate 1

1.23.96.1 Core and Builtins
...........................

   - bpo-25630(1): Fix a possible segfault during argument parsing in
     functions that accept filesystem paths.

   - bpo-23564(2): Fixed a partially broken sanity check in the
     _posixsubprocess internals regarding how fds_to_pass were passed to
     the child.  The bug had no actual impact as subprocess.py already
     avoided it.

   - bpo-25388(3): Fixed tokenizer crash when processing undecodable
     source code with a null byte.

   - bpo-25462(4): The hash of the key now is calculated only once in
     most operations in C implementation of OrderedDict.

   - bpo-22995(5): Default implementation of __reduce__ and
     __reduce_ex__ now rejects builtin types with not defined __new__.

   - bpo-25555(6): Fix parser and AST: fill lineno and col_offset of
     "arg" node when compiling AST from Python objects.

   - bpo-24802(7): Avoid buffer overreads when int(), float(),
     compile(), exec() and eval() are passed bytes-like objects.  These
     objects are not necessarily terminated by a null byte, but the
     functions assumed they were.

   - bpo-24726(8): Fixed a crash and leaking NULL in repr() of
     OrderedDict that was mutated by direct calls of dict methods.

   - bpo-25449(9): Iterating OrderedDict with keys with unstable hash
     now raises KeyError in C implementations as well as in Python
     implementation.

   - bpo-25395(10): Fixed crash when highly nested OrderedDict
     structures were garbage collected.

   - bpo-25274(11): sys.setrecursionlimit() now raises a RecursionError
     if the new recursion limit is too low depending at the current
     recursion depth.  Modify also the "lower-water mark" formula to
     make it monotonic.  This mark is used to decide when the overflowed
     flag of the thread state is reset.

   - bpo-24402(12): Fix input() to prompt to the redirected stdout when
     sys.stdout.fileno() fails.

   - bpo-24806(13): Prevent builtin types that are not allowed to be
     subclassed from being subclassed through multiple inheritance.

   - bpo-24848(14): Fixed a number of bugs in UTF-7 decoding of
     misformed data.

   - bpo-25280(15): Import trace messages emitted in verbose (-v) mode
     are no longer formatted twice.

   - bpo-25003(16): On Solaris 11.3 or newer, os.urandom() now uses the
     getrandom() function instead of the getentropy() function.  The
     getentropy() function is blocking to generate very good quality
     entropy, os.urandom() doesn't need such high-quality entropy.

   - bpo-25182(17): The stdprinter (used as sys.stderr before the io
     module is imported at startup) now uses the backslashreplace error
     handler.

   - bpo-25131(18): Make the line number and column offset of set/dict
     literals and comprehensions correspond to the opening brace.

   - bpo-25150(19): Hide the private ‘_Py_atomic_XXX’ symbols from the
     public Python.h header to fix a compilation error with OpenMP.
     PyThreadState_GET() becomes an alias to PyThreadState_Get() to
     avoid ABI incompatibilities.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25630

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23564

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25388

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25462

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22995

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25555

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24802

   (8) https://bugs.python.org/issue?@action=redirect&bpo=24726

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25449

   (10) https://bugs.python.org/issue?@action=redirect&bpo=25395

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25274

   (12) https://bugs.python.org/issue?@action=redirect&bpo=24402

   (13) https://bugs.python.org/issue?@action=redirect&bpo=24806

   (14) https://bugs.python.org/issue?@action=redirect&bpo=24848

   (15) https://bugs.python.org/issue?@action=redirect&bpo=25280

   (16) https://bugs.python.org/issue?@action=redirect&bpo=25003

   (17) https://bugs.python.org/issue?@action=redirect&bpo=25182

   (18) https://bugs.python.org/issue?@action=redirect&bpo=25131

   (19) https://bugs.python.org/issue?@action=redirect&bpo=25150


File: python.info,  Node: Library<83>,  Next: IDLE<60>,  Prev: Core and Builtins<85>,  Up: Python 3 5 1 release candidate 1

1.23.96.2 Library
.................

   - bpo-25626(1): Change three zlib functions to accept sizes that fit
     in Py_ssize_t, but internally cap those sizes to UINT_MAX. This
     resolves a regression in 3.5 where GzipFile.read() failed to read
     chunks larger than 2 or 4 GiB. The change affects the
     zlib.Decompress.decompress() max_length parameter, the
     zlib.decompress() bufsize parameter, and the
     zlib.Decompress.flush() length parameter.

   - bpo-25583(2): Avoid incorrect errors raised by
     os.makedirs(exist_ok=True) when the OS gives priority to errors
     such as EACCES over EEXIST.

   - bpo-25593(3): Change semantics of EventLoop.stop() in asyncio.

   - bpo-6973(4): When we know a subprocess.Popen process has died, do
     not allow the send_signal(), terminate(), or kill() methods to do
     anything as they could potentially signal a different process.

   - bpo-25590(5): In the Readline completer, only call getattr() once
     per attribute.

   - bpo-25498(6): Fix a crash when garbage-collecting ctypes objects
     created by wrapping a memoryview.  This was a regression made in
     3.5a1.  Based on patch by Eryksun.

   - bpo-25584(7): Added "escape" to the __all__ list in the glob
     module.

   - bpo-25584(8): Fixed recursive glob() with patterns starting with
     ‘**’.

   - bpo-25446(9): Fix regression in smtplib's AUTH LOGIN support.

   - bpo-18010(10): Fix the pydoc web server's module search function to
     handle exceptions from importing packages.

   - bpo-25554(11): Got rid of circular references in regular expression
     parsing.

   - bpo-25510(12): fileinput.FileInput.readline() now returns b''
     instead of '' at the end if the FileInput was opened with binary
     mode.  Patch by Ryosuke Ito.

   - bpo-25503(13): Fixed inspect.getdoc() for inherited docstrings of
     properties.  Original patch by John Mark Vandenberg.

   - bpo-25515(14): Always use os.urandom as a source of randomness in
     uuid.uuid4.

   - bpo-21827(15): Fixed textwrap.dedent() for the case when largest
     common whitespace is a substring of smallest leading whitespace.
     Based on patch by Robert Li.

   - bpo-25447(16): The lru_cache() wrapper objects now can be copied
     and pickled (by returning the original object unchanged).

   - bpo-25390(17): typing: Don't crash on Union[str, Pattern].

   - bpo-25441(18): asyncio: Raise error from drain() when socket is
     closed.

   - bpo-25410(19): Cleaned up and fixed minor bugs in C implementation
     of OrderedDict.

   - bpo-25411(20): Improved Unicode support in SMTPHandler through
     better use of the email package.  Thanks to user simon04 for the
     patch.

   - bpo-25407(21): Remove mentions of the formatter module being
     removed in Python 3.6.

   - bpo-25406(22): Fixed a bug in C implementation of
     OrderedDict.move_to_end() that caused segmentation fault or hang in
     iterating after moving several items to the start of ordered dict.

   - bpo-25364(23): zipfile now works in threads disabled builds.

   - bpo-25328(24): smtpd's SMTPChannel now correctly raises a
     ValueError if both decode_data and enable_SMTPUTF8 are set to true.

   - bpo-25316(25): distutils raises OSError instead of
     DistutilsPlatformError when MSVC is not installed.

   - bpo-25380(26): Fixed protocol for the STACK_GLOBAL opcode in
     pickletools.opcodes.

   - bpo-23972(27): Updates asyncio datagram create method allowing
     reuseport and reuseaddr socket options to be set prior to binding
     the socket.  Mirroring the existing asyncio create_server method
     the reuseaddr option for datagram sockets defaults to True if the
     O/S is 'posix' (except if the platform is Cygwin).  Patch by Chris
     Laws.

   - bpo-25304(28): Add asyncio.run_coroutine_threadsafe().  This lets
     you submit a coroutine to a loop from another thread, returning a
     concurrent.futures.Future.  By Vincent Michel.

   - bpo-25232(29): Fix CGIRequestHandler to split the query from the
     URL at the first question mark (?)  rather than the last.  Patch
     from Xiang Zhang.

   - bpo-24657(30): Prevent CGIRequestHandler from collapsing slashes in
     the query part of the URL as if it were a path.  Patch from Xiang
     Zhang.

   - bpo-24483(31): C implementation of functools.lru_cache() now
     calculates key's hash only once.

   - bpo-22958(32): Constructor and update method of
     weakref.WeakValueDictionary now accept the self and the dict
     keyword arguments.

   - bpo-22609(33): Constructor of collections.UserDict now accepts the
     self keyword argument.

   - bpo-25111(34): Fixed comparison of traceback.FrameSummary.

   - bpo-25262(35): Added support for BINBYTES8 opcode in Python
     implementation of unpickler.  Highest 32 bits of 64-bit size for
     BINUNICODE8 and BINBYTES8 opcodes no longer silently ignored on
     32-bit platforms in C implementation.

   - bpo-25034(36): Fix string.Formatter problem with auto-numbering and
     nested format_specs.  Patch by Anthon van der Neut.

   - bpo-25233(37): Rewrite the guts of asyncio.Queue and
     asyncio.Semaphore to be more understandable and correct.

   - bpo-25203(38): Failed readline.set_completer_delims() no longer
     left the module in inconsistent state.

   - bpo-23600(39): Default implementation of tzinfo.fromutc() was
     returning wrong results in some cases.

   - bpo-23329(40): Allow the ssl module to be built with older versions
     of LibreSSL.

   - Prevent overflow in _Unpickler_Read.

   - bpo-25047(41): The XML encoding declaration written by Element Tree
     now respects the letter case given by the user.  This restores the
     ability to write encoding names in uppercase like "UTF-8", which
     worked in Python 2.

   - bpo-25135(42): Make deque_clear() safer by emptying the deque
     before clearing.  This helps avoid possible reentrancy issues.

   - bpo-19143(43): platform module now reads Windows version from
     kernel32.dll to avoid compatibility shims.

   - bpo-25092(44): Fix datetime.strftime() failure when errno was
     already set to EINVAL.

   - bpo-23517(45): Fix rounding in fromtimestamp() and
     utcfromtimestamp() methods of datetime.datetime: microseconds are
     now rounded to nearest with ties going to nearest even integer
     (ROUND_HALF_EVEN), instead of being rounding towards minus infinity
     (ROUND_FLOOR). It's important that these methods use the same
     rounding mode than datetime.timedelta to keep the property:
     (datetime(1970,1,1) + timedelta(seconds=t)) ==
     datetime.utcfromtimestamp(t).  It also the rounding mode used by
     round(float) for example.

   - bpo-25155(46): Fix datetime.datetime.now() and
     datetime.datetime.utcnow() on Windows to support date after year
     2038.  It was a regression introduced in Python 3.5.0.

   - bpo-25108(47): Omitted internal frames in traceback functions
     print_stack(), format_stack(), and extract_stack() called without
     arguments.

   - bpo-25118(48): Fix a regression of Python 3.5.0 in os.waitpid() on
     Windows.

   - bpo-24684(49): socket.socket.getaddrinfo() now calls
     PyUnicode_AsEncodedString() instead of calling the encode() method
     of the host, to handle correctly custom string with an encode()
     method which doesn't return a byte string.  The encoder of the IDNA
     codec is now called directly instead of calling the encode() method
     of the string.

   - bpo-25060(50): Correctly compute stack usage of the BUILD_MAP
     opcode.

   - bpo-24857(51): Comparing call_args to a long sequence now correctly
     returns a boolean result instead of raising an exception.  Patch by
     A Kaptur.

   - bpo-23144(52): Make sure that HTMLParser.feed() returns all the
     data, even when convert_charrefs is True.

   - bpo-24982(53): shutil.make_archive() with the "zip" format now adds
     entries for directories (including empty directories) in ZIP file.

   - bpo-25019(54): Fixed a crash caused by setting non-string key of
     expat parser.  Based on patch by John Leitch.

   - bpo-16180(55): Exit pdb if file has syntax error, instead of
     trapping user in an infinite loop.  Patch by Xavier de Gaye.

   - bpo-24891(56): Fix a race condition at Python startup if the file
     descriptor of stdin (0), stdout (1) or stderr (2) is closed while
     Python is creating sys.stdin, sys.stdout and sys.stderr objects.
     These attributes are now set to None if the creation of the object
     failed, instead of raising an OSError exception.  Initial patch
     written by Marco Paolini.

   - bpo-24992(57): Fix error handling and a race condition (related to
     garbage collection) in collections.OrderedDict constructor.

   - bpo-24881(58): Fixed setting binary mode in Python implementation
     of FileIO on Windows and Cygwin.  Patch from Akira Li.

   - bpo-25578(59): Fix (another) memory leak in SSLSocket.getpeercer().

   - bpo-25530(60): Disable the vulnerable SSLv3 protocol by default
     when creating ssl.SSLContext.

   - bpo-25569(61): Fix memory leak in SSLSocket.getpeercert().

   - bpo-25471(62): Sockets returned from accept() shouldn't appear to
     be nonblocking.

   - bpo-25319(63): When threading.Event is reinitialized, the
     underlying condition should use a regular lock rather than a
     recursive lock.

   - bpo-21112(64): Fix regression in unittest.expectedFailure on
     subclasses.  Patch from Berker Peksag.

   - bpo-24764(65): cgi.FieldStorage.read_multi() now ignores the
     Content-Length header in part headers.  Patch written by Peter
     Landry and reviewed by Pierre Quentel.

   - bpo-24913(66): Fix overrun error in deque.index().  Found by John
     Leitch and Bryce Darling.

   - bpo-24774(67): Fix docstring in http.server.test.  Patch from
     Chiu-Hsiang Hsu.

   - bpo-21159(68): Improve message in
     configparser.InterpolationMissingOptionError.  Patch from Łukasz
     Langa.

   - bpo-20362(69): Honour TestCase.longMessage correctly in
     assertRegex.  Patch from Ilia Kurenkov.

   - bpo-23572(70): Fixed functools.singledispatch on classes with false
     metaclasses.  Patch by Ethan Furman.

   - asyncio: ensure_future() now accepts awaitable objects.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25626

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25583

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25593

   (4) https://bugs.python.org/issue?@action=redirect&bpo=6973

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25590

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25498

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25584

   (8) https://bugs.python.org/issue?@action=redirect&bpo=25584

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25446

   (10) https://bugs.python.org/issue?@action=redirect&bpo=18010

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25554

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25510

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25503

   (14) https://bugs.python.org/issue?@action=redirect&bpo=25515

   (15) https://bugs.python.org/issue?@action=redirect&bpo=21827

   (16) https://bugs.python.org/issue?@action=redirect&bpo=25447

   (17) https://bugs.python.org/issue?@action=redirect&bpo=25390

   (18) https://bugs.python.org/issue?@action=redirect&bpo=25441

   (19) https://bugs.python.org/issue?@action=redirect&bpo=25410

   (20) https://bugs.python.org/issue?@action=redirect&bpo=25411

   (21) https://bugs.python.org/issue?@action=redirect&bpo=25407

   (22) https://bugs.python.org/issue?@action=redirect&bpo=25406

   (23) https://bugs.python.org/issue?@action=redirect&bpo=25364

   (24) https://bugs.python.org/issue?@action=redirect&bpo=25328

   (25) https://bugs.python.org/issue?@action=redirect&bpo=25316

   (26) https://bugs.python.org/issue?@action=redirect&bpo=25380

   (27) https://bugs.python.org/issue?@action=redirect&bpo=23972

   (28) https://bugs.python.org/issue?@action=redirect&bpo=25304

   (29) https://bugs.python.org/issue?@action=redirect&bpo=25232

   (30) https://bugs.python.org/issue?@action=redirect&bpo=24657

   (31) https://bugs.python.org/issue?@action=redirect&bpo=24483

   (32) https://bugs.python.org/issue?@action=redirect&bpo=22958

   (33) https://bugs.python.org/issue?@action=redirect&bpo=22609

   (34) https://bugs.python.org/issue?@action=redirect&bpo=25111

   (35) https://bugs.python.org/issue?@action=redirect&bpo=25262

   (36) https://bugs.python.org/issue?@action=redirect&bpo=25034

   (37) https://bugs.python.org/issue?@action=redirect&bpo=25233

   (38) https://bugs.python.org/issue?@action=redirect&bpo=25203

   (39) https://bugs.python.org/issue?@action=redirect&bpo=23600

   (40) https://bugs.python.org/issue?@action=redirect&bpo=23329

   (41) https://bugs.python.org/issue?@action=redirect&bpo=25047

   (42) https://bugs.python.org/issue?@action=redirect&bpo=25135

   (43) https://bugs.python.org/issue?@action=redirect&bpo=19143

   (44) https://bugs.python.org/issue?@action=redirect&bpo=25092

   (45) https://bugs.python.org/issue?@action=redirect&bpo=23517

   (46) https://bugs.python.org/issue?@action=redirect&bpo=25155

   (47) https://bugs.python.org/issue?@action=redirect&bpo=25108

   (48) https://bugs.python.org/issue?@action=redirect&bpo=25118

   (49) https://bugs.python.org/issue?@action=redirect&bpo=24684

   (50) https://bugs.python.org/issue?@action=redirect&bpo=25060

   (51) https://bugs.python.org/issue?@action=redirect&bpo=24857

   (52) https://bugs.python.org/issue?@action=redirect&bpo=23144

   (53) https://bugs.python.org/issue?@action=redirect&bpo=24982

   (54) https://bugs.python.org/issue?@action=redirect&bpo=25019

   (55) https://bugs.python.org/issue?@action=redirect&bpo=16180

   (56) https://bugs.python.org/issue?@action=redirect&bpo=24891

   (57) https://bugs.python.org/issue?@action=redirect&bpo=24992

   (58) https://bugs.python.org/issue?@action=redirect&bpo=24881

   (59) https://bugs.python.org/issue?@action=redirect&bpo=25578

   (60) https://bugs.python.org/issue?@action=redirect&bpo=25530

   (61) https://bugs.python.org/issue?@action=redirect&bpo=25569

   (62) https://bugs.python.org/issue?@action=redirect&bpo=25471

   (63) https://bugs.python.org/issue?@action=redirect&bpo=25319

   (64) https://bugs.python.org/issue?@action=redirect&bpo=21112

   (65) https://bugs.python.org/issue?@action=redirect&bpo=24764

   (66) https://bugs.python.org/issue?@action=redirect&bpo=24913

   (67) https://bugs.python.org/issue?@action=redirect&bpo=24774

   (68) https://bugs.python.org/issue?@action=redirect&bpo=21159

   (69) https://bugs.python.org/issue?@action=redirect&bpo=20362

   (70) https://bugs.python.org/issue?@action=redirect&bpo=23572


File: python.info,  Node: IDLE<60>,  Next: Documentation<70>,  Prev: Library<83>,  Up: Python 3 5 1 release candidate 1

1.23.96.3 IDLE
..............

   - bpo-15348(1): Stop the debugger engine (normally in a user process)
     before closing the debugger window (running in the IDLE process).
     This prevents the RuntimeErrors that were being caught and ignored.

   - bpo-24455(2): Prevent IDLE from hanging when a) closing the shell
     while the debugger is active (15347); b) closing the debugger with
     the [X] button (15348); and c) activating the debugger when already
     active (24455).  The patch by Mark Roseman does this by making two
     changes.  1.  Suspend and resume the gui.interaction method with
     the tcl vwait mechanism intended for this purpose (instead of
     root.mainloop & .quit).  2.  In gui.run, allow any existing
     interaction to terminate first.

   - Change 'The program' to 'Your program' in an IDLE 'kill program?'
     message to make it clearer that the program referred to is the
     currently running user program, not IDLE itself.

   - bpo-24750(3): Improve the appearance of the IDLE editor window
     status bar.  Patch by Mark Roseman.

   - bpo-25313(4): Change the handling of new built-in text color themes
     to better address the compatibility problem introduced by the
     addition of IDLE Dark.  Consistently use the revised
     idleConf.CurrentTheme everywhere in idlelib.

   - bpo-24782(5): Extension configuration is now a tab in the IDLE
     Preferences dialog rather than a separate dialog.  The former tabs
     are now a sorted list.  Patch by Mark Roseman.

   - bpo-22726(6): Re-activate the config dialog help button with some
     content about the other buttons and the new IDLE Dark theme.

   - bpo-24820(7): IDLE now has an 'IDLE Dark' built-in text color
     theme.  It is more or less IDLE Classic inverted, with a cobalt
     blue background.  Strings, comments, keywords, ...  are still
     green, red, orange, ...  .  To use it with IDLEs released before
     November 2015, hit the 'Save as New Custom Theme' button and enter
     a new name, such as 'Custom Dark'.  The custom theme will work with
     any IDLE release, and can be modified.

   - bpo-25224(8): README.txt is now an idlelib index for IDLE
     developers and curious users.  The previous user content is now in
     the IDLE doc chapter.  'IDLE' now means 'Integrated Development and
     Learning Environment'.

   - bpo-24820(9): Users can now set breakpoint colors in Settings ->
     Custom Highlighting.  Original patch by Mark Roseman.

   - bpo-24972(10): Inactive selection background now matches active
     selection background, as configured by users, on all systems.
     Found items are now always highlighted on Windows.  Initial patch
     by Mark Roseman.

   - bpo-24570(11): Idle: make calltip and completion boxes appear on
     Macs affected by a tk regression.  Initial patch by Mark Roseman.

   - bpo-24988(12): Idle ScrolledList context menus (used in debugger)
     now work on Mac Aqua.  Patch by Mark Roseman.

   - bpo-24801(13): Make right-click for context menu work on Mac Aqua.
     Patch by Mark Roseman.

   - bpo-25173(14): Associate tkinter messageboxes with a specific
     widget.  For Mac OSX, make them a 'sheet'.  Patch by Mark Roseman.

   - bpo-25198(15): Enhance the initial html viewer now used for Idle
     Help.  Properly indent fixed-pitch text (patch by Mark Roseman).
     Give code snippet a very Sphinx-like light blueish-gray background.
     Re-use initial width and height set by users for shell and editor.
     When the Table of Contents (TOC) menu is used, put the section
     header at the top of the screen.

   - bpo-25225(16): Condense and rewrite Idle doc section on text
     colors.

   - bpo-21995(17): Explain some differences between IDLE and console
     Python.

   - bpo-22820(18): Explain need for 'print' when running file from Idle
     editor.

   - bpo-25224(19): Doc: augment Idle feature list and no-subprocess
     section.

   - bpo-25219(20): Update doc for Idle command line options.  Some were
     missing and notes were not correct.

   - bpo-24861(21): Most of idlelib is private and subject to change.
     Use idleib.idle.* to start Idle.  See idlelib.__init__.__doc__.

   - bpo-25199(22): Idle: add synchronization comments for future
     maintainers.

   - bpo-16893(23): Replace help.txt with help.html for Idle doc
     display.  The new idlelib/help.html is rstripped
     Doc/build/html/library/idle.html.  It looks better than help.txt
     and will better document Idle as released.  The tkinter html viewer
     that works for this file was written by Mark Roseman.  The now
     unused EditorWindow.HelpDialog class and helt.txt file are
     deprecated.

   - bpo-24199(24): Deprecate unused idlelib.idlever with possible
     removal in 3.6.

   - bpo-24790(25): Remove extraneous code (which also create 2 & 3
     conflicts).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15348

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24455

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24750

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25313

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24782

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22726

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24820

   (8) https://bugs.python.org/issue?@action=redirect&bpo=25224

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24820

   (10) https://bugs.python.org/issue?@action=redirect&bpo=24972

   (11) https://bugs.python.org/issue?@action=redirect&bpo=24570

   (12) https://bugs.python.org/issue?@action=redirect&bpo=24988

   (13) https://bugs.python.org/issue?@action=redirect&bpo=24801

   (14) https://bugs.python.org/issue?@action=redirect&bpo=25173

   (15) https://bugs.python.org/issue?@action=redirect&bpo=25198

   (16) https://bugs.python.org/issue?@action=redirect&bpo=25225

   (17) https://bugs.python.org/issue?@action=redirect&bpo=21995

   (18) https://bugs.python.org/issue?@action=redirect&bpo=22820

   (19) https://bugs.python.org/issue?@action=redirect&bpo=25224

   (20) https://bugs.python.org/issue?@action=redirect&bpo=25219

   (21) https://bugs.python.org/issue?@action=redirect&bpo=24861

   (22) https://bugs.python.org/issue?@action=redirect&bpo=25199

   (23) https://bugs.python.org/issue?@action=redirect&bpo=16893

   (24) https://bugs.python.org/issue?@action=redirect&bpo=24199

   (25) https://bugs.python.org/issue?@action=redirect&bpo=24790


File: python.info,  Node: Documentation<70>,  Next: Tests<75>,  Prev: IDLE<60>,  Up: Python 3 5 1 release candidate 1

1.23.96.4 Documentation
.......................

   - bpo-22558(1): Add remaining doc links to source code for
     Python-coded modules.  Patch by Yoni Lavi.

   - bpo-12067(2): Rewrite Comparisons section in the Expressions
     chapter of the language reference.  Some of the details of
     comparing mixed types were incorrect or ambiguous.  NotImplemented
     is only relevant at a lower level than the Expressions chapter.
     Added details of comparing range() objects, and default behaviour
     and consistency suggestions for user-defined classes.  Patch from
     Andy Maier.

   - bpo-24952(3): Clarify the default size argument of stack_size() in
     the "threading" and "_thread" modules.  Patch from Mattip.

   - bpo-23725(4): Overhaul tempfile docs.  Note deprecated status of
     mktemp.  Patch from Zbigniew Jędrzejewski-Szmek.

   - bpo-24808(5): Update the types of some PyTypeObject fields.  Patch
     by Joseph Weston.

   - bpo-22812(6): Fix unittest discovery examples.  Patch from Pam
     McA'Nulty.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22558

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12067

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24952

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23725

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24808

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22812


File: python.info,  Node: Tests<75>,  Next: Build<80>,  Prev: Documentation<70>,  Up: Python 3 5 1 release candidate 1

1.23.96.5 Tests
...............

   - bpo-25449(1): Added tests for OrderedDict subclasses.

   - bpo-25099(2): Make test_compileall not fail when an entry on
     sys.path cannot be written to (commonly seen in administrative
     installs on Windows).

   - bpo-23919(3): Prevents assert dialogs appearing in the test suite.

   - ‘PCbuild\rt.bat’ now accepts an unlimited number of arguments to
     pass along to regrtest.py.  Previously there was a limit of 9.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25449

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25099

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23919


File: python.info,  Node: Build<80>,  Next: Windows<71>,  Prev: Tests<75>,  Up: Python 3 5 1 release candidate 1

1.23.96.6 Build
...............

   - bpo-24915(1): Add LLVM support for PGO builds and use the test
     suite to generate the profile data.  Initial patch by Alecsandru
     Patrascu of Intel.

   - bpo-24910(2): Windows MSIs now have unique display names.

   - bpo-24986(3): It is now possible to build Python on Windows without
     errors when external libraries are not available.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24915

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24910

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24986


File: python.info,  Node: Windows<71>,  Next: Tools/Demos<44>,  Prev: Build<80>,  Up: Python 3 5 1 release candidate 1

1.23.96.7 Windows
.................

   - bpo-25450(1): Updates shortcuts to start Python in installation
     directory.

   - bpo-25164(2): Changes default all-users install directory to match
     per-user directory.

   - bpo-25143(3): Improves installer error messages for unsupported
     platforms.

   - bpo-25163(4): Display correct directory in installer when using
     non-default settings.

   - bpo-25361(5): Disables use of SSE2 instructions in Windows 32-bit
     build

   - bpo-25089(6): Adds logging to installer for case where launcher is
     not selected on upgrade.

   - bpo-25165(7): Windows uninstallation should not remove launcher if
     other versions remain

   - bpo-25112(8): py.exe launcher is missing icons

   - bpo-25102(9): Windows installer does not precompile for -O or -OO.

   - bpo-25081(10): Makes Back button in installer go back to upgrade
     page when upgrading.

   - bpo-25091(11): Increases font size of the installer.

   - bpo-25126(12): Clarifies that the non-web installer will download
     some components.

   - bpo-25213(13): Restores requestedExecutionLevel to manifest to
     disable UAC virtualization.

   - bpo-25022(14): Removed very outdated PC/example_nt/ directory.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25450

   (2) https://bugs.python.org/issue?@action=redirect&bpo=25164

   (3) https://bugs.python.org/issue?@action=redirect&bpo=25143

   (4) https://bugs.python.org/issue?@action=redirect&bpo=25163

   (5) https://bugs.python.org/issue?@action=redirect&bpo=25361

   (6) https://bugs.python.org/issue?@action=redirect&bpo=25089

   (7) https://bugs.python.org/issue?@action=redirect&bpo=25165

   (8) https://bugs.python.org/issue?@action=redirect&bpo=25112

   (9) https://bugs.python.org/issue?@action=redirect&bpo=25102

   (10) https://bugs.python.org/issue?@action=redirect&bpo=25081

   (11) https://bugs.python.org/issue?@action=redirect&bpo=25091

   (12) https://bugs.python.org/issue?@action=redirect&bpo=25126

   (13) https://bugs.python.org/issue?@action=redirect&bpo=25213

   (14) https://bugs.python.org/issue?@action=redirect&bpo=25022


File: python.info,  Node: Tools/Demos<44>,  Prev: Windows<71>,  Up: Python 3 5 1 release candidate 1

1.23.96.8 Tools/Demos
.....................

   - bpo-25440(1): Fix output of python-config -extension-suffix.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25440


File: python.info,  Node: Python 3 5 0 final,  Next: Python 3 5 0 release candidate 4,  Prev: Python 3 5 1 release candidate 1,  Up: 変更履歴

1.23.97 Python 3.5.0 final
--------------------------

'Release date: 2015-09-13'

* Menu:

* Build: Build<81>.


File: python.info,  Node: Build<81>,  Up: Python 3 5 0 final

1.23.97.1 Build
...............

   - bpo-25071(1): Windows installer should not require TargetDir
     parameter when installing quietly.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25071


File: python.info,  Node: Python 3 5 0 release candidate 4,  Next: Python 3 5 0 release candidate 3,  Prev: Python 3 5 0 final,  Up: 変更履歴

1.23.98 Python 3.5.0 release candidate 4
----------------------------------------

'Release date: 2015-09-09'

* Menu:

* Library: Library<84>.
* Build: Build<82>.


File: python.info,  Node: Library<84>,  Next: Build<82>,  Up: Python 3 5 0 release candidate 4

1.23.98.1 Library
.................

   - bpo-25029(1): Fixes MemoryError in test_strptime.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25029


File: python.info,  Node: Build<82>,  Prev: Library<84>,  Up: Python 3 5 0 release candidate 4

1.23.98.2 Build
...............

   - bpo-25027(1): Reverts partial-static build options and adds
     vcruntime140.dll to Windows installation.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=25027


File: python.info,  Node: Python 3 5 0 release candidate 3,  Next: Python 3 5 0 release candidate 2,  Prev: Python 3 5 0 release candidate 4,  Up: 変更履歴

1.23.99 Python 3.5.0 release candidate 3
----------------------------------------

'Release date: 2015-09-07'

* Menu:

* Core and Builtins: Core and Builtins<86>.
* Library: Library<85>.


File: python.info,  Node: Core and Builtins<86>,  Next: Library<85>,  Up: Python 3 5 0 release candidate 3

1.23.99.1 Core and Builtins
...........................

   - bpo-24305(1): Prevent import subsystem stack frames from being
     counted by the warnings.warn(stacklevel=) parameter.

   - bpo-24912(2): Prevent __class__ assignment to immutable built-in
     objects.

   - bpo-24975(3): Fix AST compilation for PEP 448(4) syntax.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24305

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24912

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24975

   (4) https://peps.python.org/pep-0448/


File: python.info,  Node: Library<85>,  Prev: Core and Builtins<86>,  Up: Python 3 5 0 release candidate 3

1.23.99.2 Library
.................

   - bpo-24917(1): time_strftime() buffer over-read.

   - bpo-24748(2): To resolve a compatibility problem found with py2exe
     and pywin32, imp.load_dynamic() once again ignores previously
     loaded modules to support Python modules replacing themselves with
     extension modules.  Patch by Petr Viktorin.

   - bpo-24635(3): Fixed a bug in typing.py where isinstance([],
     typing.Iterable) would return True once, then False on subsequent
     calls.

   - bpo-24989(4): Fixed buffer overread in BytesIO.readline() if a
     position is set beyond size.  Based on patch by John Leitch.

   - bpo-24913(5): Fix overrun error in deque.index().  Found by John
     Leitch and Bryce Darling.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24917

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24748

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24635

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24989

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24913


File: python.info,  Node: Python 3 5 0 release candidate 2,  Next: Python 3 5 0 release candidate 1,  Prev: Python 3 5 0 release candidate 3,  Up: 変更履歴

1.23.100 Python 3.5.0 release candidate 2
-----------------------------------------

'Release date: 2015-08-25'

* Menu:

* Core and Builtins: Core and Builtins<87>.
* Library: Library<86>.


File: python.info,  Node: Core and Builtins<87>,  Next: Library<86>,  Up: Python 3 5 0 release candidate 2

1.23.100.1 Core and Builtins
............................

   - bpo-24769(1): Interpreter now starts properly when dynamic loading
     is disabled.  Patch by Petr Viktorin.

   - bpo-21167(2): NAN operations are now handled correctly when python
     is compiled with ICC even if -fp-model strict is not specified.

   - bpo-24492(3): A "package" lacking a __name__ attribute when trying
     to perform a ‘from .. import ...’ statement will trigger an
     ImportError instead of an AttributeError.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24769

   (2) https://bugs.python.org/issue?@action=redirect&bpo=21167

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24492


File: python.info,  Node: Library<86>,  Prev: Core and Builtins<87>,  Up: Python 3 5 0 release candidate 2

1.23.100.2 Library
..................

   - bpo-24847(1): Removes vcruntime140.dll dependency from Tcl/Tk.

   - bpo-24839(2): platform._syscmd_ver raises DeprecationWarning

   - bpo-24867(3): Fix Task.get_stack() for 'async def' coroutines

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24847

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24839

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24867


File: python.info,  Node: Python 3 5 0 release candidate 1,  Next: Python 3 5 0 beta 4,  Prev: Python 3 5 0 release candidate 2,  Up: 変更履歴

1.23.101 Python 3.5.0 release candidate 1
-----------------------------------------

'Release date: 2015-08-09'

* Menu:

* Core and Builtins: Core and Builtins<88>.
* Library: Library<87>.
* IDLE: IDLE<61>.
* Documentation: Documentation<71>.
* Tests: Tests<76>.


File: python.info,  Node: Core and Builtins<88>,  Next: Library<87>,  Up: Python 3 5 0 release candidate 1

1.23.101.1 Core and Builtins
............................

   - bpo-24667(1): Resize odict in all cases that the underlying dict
     resizes.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24667


File: python.info,  Node: Library<87>,  Next: IDLE<61>,  Prev: Core and Builtins<88>,  Up: Python 3 5 0 release candidate 1

1.23.101.2 Library
..................

   - bpo-24824(1): Signatures of codecs.encode() and codecs.decode() now
     are compatible with pydoc.

   - bpo-24634(2): Importing uuid should not try to load libc on Windows

   - bpo-24798(3): _msvccompiler.py doesn't properly support manifests

   - bpo-4395(4): Better testing and documentation of binary operators.
     Patch by Martin Panter.

   - bpo-23973(5): Update typing.py from GitHub repo.

   - bpo-23004(6): mock_open() now reads binary data correctly when the
     type of read_data is bytes.  Initial patch by Aaron Hill.

   - bpo-23888(7): Handle fractional time in cookie expiry.  Patch by
     ssh.

   - bpo-23652(8): Make it possible to compile the select module against
     the libc headers from the Linux Standard Base, which do not include
     some EPOLL macros.  Patch by Matt Frank.

   - bpo-22932(9): Fix timezones in email.utils.formatdate.  Patch from
     Dmitry Shachnev.

   - bpo-23779(10): imaplib raises TypeError if authenticator tries to
     abort.  Patch from Craig Holmquist.

   - bpo-23319(11): Fix ctypes.BigEndianStructure, swap correctly bytes.
     Patch written by Matthieu Gautier.

   - bpo-23254(12): Document how to close the TCPServer listening
     socket.  Patch from Martin Panter.

   - bpo-19450(13): Update Windows and OS X installer builds to use
     SQLite 3.8.11.

   - bpo-17527(14): Add PATCH to wsgiref.validator.  Patch from Luca
     Sbardella.

   - bpo-24791(15): Fix grammar regression for call syntax: 'g(*a or
     b)'.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24824

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24634

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24798

   (4) https://bugs.python.org/issue?@action=redirect&bpo=4395

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23973

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23004

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23888

   (8) https://bugs.python.org/issue?@action=redirect&bpo=23652

   (9) https://bugs.python.org/issue?@action=redirect&bpo=22932

   (10) https://bugs.python.org/issue?@action=redirect&bpo=23779

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23319

   (12) https://bugs.python.org/issue?@action=redirect&bpo=23254

   (13) https://bugs.python.org/issue?@action=redirect&bpo=19450

   (14) https://bugs.python.org/issue?@action=redirect&bpo=17527

   (15) https://bugs.python.org/issue?@action=redirect&bpo=24791


File: python.info,  Node: IDLE<61>,  Next: Documentation<71>,  Prev: Library<87>,  Up: Python 3 5 0 release candidate 1

1.23.101.3 IDLE
...............

   - bpo-23672(1): Allow Idle to edit and run files with astral chars in
     name.  Patch by Mohd Sanad Zaki Rizvi.

   - bpo-24745(2): Idle editor default font.  Switch from Courier to
     platform-sensitive TkFixedFont.  This should not affect current
     customized font selections.  If there is a problem, edit
     $HOME/.idlerc/config-main.cfg and remove '‘fontXXX’' entries from
     [Editor Window].  Patch by Mark Roseman.

   - bpo-21192(3): Idle editor.  When a file is run, put its name in the
     restart bar.  Do not print false prompts.  Original patch by Adnan
     Umer.

   - bpo-13884(4): Idle menus.  Remove tearoff lines.  Patch by Roger
     Serwy.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23672

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24745

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21192

   (4) https://bugs.python.org/issue?@action=redirect&bpo=13884


File: python.info,  Node: Documentation<71>,  Next: Tests<76>,  Prev: IDLE<61>,  Up: Python 3 5 0 release candidate 1

1.23.101.4 Documentation
........................

   - bpo-24129(1): Clarify the reference documentation for name
     resolution.  This includes removing the assumption that readers
     will be familiar with the name resolution scheme Python used prior
     to the introduction of lexical scoping for function namespaces.
     Patch by Ivan Levkivskyi.

   - bpo-20769(2): Improve reload() docs.  Patch by Dorian Pula.

   - bpo-23589(3): Remove duplicate sentence from the FAQ. Patch by
     Yongzhi Pan.

   - bpo-24729(4): Correct IO tutorial to match implementation regarding
     encoding parameter to open function.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24129

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20769

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23589

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24729


File: python.info,  Node: Tests<76>,  Prev: Documentation<71>,  Up: Python 3 5 0 release candidate 1

1.23.101.5 Tests
................

   - bpo-24751(1): When running regrtest with the ‘-w’ command line
     option, a test run is no longer marked as a failure if all tests
     succeed when re-run.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24751


File: python.info,  Node: Python 3 5 0 beta 4,  Next: Python 3 5 0 beta 3,  Prev: Python 3 5 0 release candidate 1,  Up: 変更履歴

1.23.102 Python 3.5.0 beta 4
----------------------------

'Release date: 2015-07-26'

* Menu:

* Core and Builtins: Core and Builtins<89>.
* Library: Library<88>.
* Build: Build<83>.


File: python.info,  Node: Core and Builtins<89>,  Next: Library<88>,  Up: Python 3 5 0 beta 4

1.23.102.1 Core and Builtins
............................

   - bpo-23573(1): Restored optimization of bytes.rfind() and
     bytearray.rfind() for single-byte argument on Linux.

   - bpo-24569(2): Make PEP 448(3) dictionary evaluation more
     consistent.

   - bpo-24583(4): Fix crash when set is mutated while being updated.

   - bpo-24407(5): Fix crash when dict is mutated while being updated.

   - bpo-24619(6): New approach for tokenizing async/await.  As a
     consequence, it is now possible to have one-line 'async def foo():
     await ..'  functions.

   - bpo-24687(7): Plug refleak on SyntaxError in function parameters
     annotations.

   - bpo-15944(8): memoryview: Allow arbitrary formats when casting to
     bytes.  Patch by Martin Panter.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23573

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24569

   (3) https://peps.python.org/pep-0448/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24583

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24407

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24619

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24687

   (8) https://bugs.python.org/issue?@action=redirect&bpo=15944


File: python.info,  Node: Library<88>,  Next: Build<83>,  Prev: Core and Builtins<89>,  Up: Python 3 5 0 beta 4

1.23.102.2 Library
..................

   - bpo-23441(1): rcompleter now prints a tab character instead of
     displaying possible completions for an empty word.  Initial patch
     by Martin Sekera.

   - bpo-24683(2): Fixed crashes in _json functions called with
     arguments of inappropriate type.

   - bpo-21697(3): shutil.copytree() now correctly handles symbolic
     links that point to directories.  Patch by Eduardo Seabra and
     Thomas Kluyver.

   - bpo-14373(4): Fixed segmentation fault when gc.collect() is called
     during constructing lru_cache (C implementation).

   - bpo-24695(5): Fix a regression in traceback.print_exception().  If
     exc_traceback is None we shouldn't print a traceback header like
     described in the documentation.

   - bpo-24620(6): Random.setstate() now validates the value of state
     last element.

   - bpo-22485(7): Fixed an issue that caused ‘inspect.getsource’ to
     return incorrect results on nested functions.

   - bpo-22153(8): Improve unittest docs.  Patch from Martin Panter and
     evilzero.

   - bpo-24580(9): Symbolic group references to open group in re
     patterns now are explicitly forbidden as well as numeric group
     references.

   - bpo-24206(10): Fixed __eq__ and __ne__ methods of inspect classes.

   - bpo-24631(11): Fixed regression in the timeit module with multiline
     setup.

   - bpo-18622(12): unittest.mock.mock_open().reset_mock would recurse
     infinitely.  Patch from Nicola Palumbo and Laurent De Buyst.

   - bpo-23661(13): unittest.mock side_effects can now be exceptions
     again.  This was a regression vs Python 3.4.  Patch from Ignacio
     Rossi

   - bpo-24608(14): chunk.Chunk.read() now always returns bytes, not
     str.

   - bpo-18684(15): Fixed reading out of the buffer in the re module.

   - bpo-24259(16): tarfile now raises a ReadError if an archive is
     truncated inside a data segment.

   - bpo-15014(17): SMTP.auth() and SMTP.login() now support RFC 4954's
     optional initial-response argument to the SMTP AUTH command.

   - bpo-24669(18): Fix inspect.getsource() for 'async def' functions.
     Patch by Kai Groner.

   - bpo-24688(19): ast.get_docstring() for 'async def' functions.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23441

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24683

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21697

   (4) https://bugs.python.org/issue?@action=redirect&bpo=14373

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24695

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24620

   (7) https://bugs.python.org/issue?@action=redirect&bpo=22485

   (8) https://bugs.python.org/issue?@action=redirect&bpo=22153

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24580

   (10) https://bugs.python.org/issue?@action=redirect&bpo=24206

   (11) https://bugs.python.org/issue?@action=redirect&bpo=24631

   (12) https://bugs.python.org/issue?@action=redirect&bpo=18622

   (13) https://bugs.python.org/issue?@action=redirect&bpo=23661

   (14) https://bugs.python.org/issue?@action=redirect&bpo=24608

   (15) https://bugs.python.org/issue?@action=redirect&bpo=18684

   (16) https://bugs.python.org/issue?@action=redirect&bpo=24259

   (17) https://bugs.python.org/issue?@action=redirect&bpo=15014

   (18) https://bugs.python.org/issue?@action=redirect&bpo=24669

   (19) https://bugs.python.org/issue?@action=redirect&bpo=24688


File: python.info,  Node: Build<83>,  Prev: Library<88>,  Up: Python 3 5 0 beta 4

1.23.102.3 Build
................

   - bpo-24603(1): Update Windows builds and OS X 10.5 installer to use
     OpenSSL 1.0.2d.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24603


File: python.info,  Node: Python 3 5 0 beta 3,  Next: Python 3 5 0 beta 2,  Prev: Python 3 5 0 beta 4,  Up: 変更履歴

1.23.103 Python 3.5.0 beta 3
----------------------------

'Release date: 2015-07-05'

* Menu:

* Core and Builtins: Core and Builtins<90>.
* Library: Library<89>.
* Tests: Tests<77>.
* Documentation: Documentation<72>.
* Build: Build<84>.


File: python.info,  Node: Core and Builtins<90>,  Next: Library<89>,  Up: Python 3 5 0 beta 3

1.23.103.1 Core and Builtins
............................

   - bpo-24467(1): Fixed possible buffer over-read in bytearray.  The
     bytearray object now always allocates place for trailing null byte
     and it's buffer now is always null-terminated.

   - Upgrade to Unicode 8.0.0.

   - bpo-24345(2): Add Py_tp_finalize slot for the stable ABI.

   - bpo-24400(3): Introduce a distinct type for PEP 492(4) coroutines;
     add types.CoroutineType, inspect.getcoroutinestate,
     inspect.getcoroutinelocals; coroutines no longer use CO_GENERATOR
     flag; sys.set_coroutine_wrapper works only for 'async def'
     coroutines; inspect.iscoroutine no longer uses
     collections.abc.Coroutine, it's intended to test for pure 'async
     def' coroutines only; add new opcode: GET_YIELD_FROM_ITER; fix
     generators wrapper used in types.coroutine to be instance of
     collections.abc.Generator; collections.abc.Awaitable and
     collections.abc.Coroutine can no longer be used to detect
     generator-based coroutines-use inspect.isawaitable instead.

   - bpo-24450(5): Add gi_yieldfrom to generators and cr_await to
     coroutines.  Contributed by Benno Leslie and Yury Selivanov.

   - bpo-19235(6): Add new RecursionError exception.  Patch by Georg
     Brandl.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24467

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24345

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24400

   (4) https://peps.python.org/pep-0492/

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24450

   (6) https://bugs.python.org/issue?@action=redirect&bpo=19235


File: python.info,  Node: Library<89>,  Next: Tests<77>,  Prev: Core and Builtins<90>,  Up: Python 3 5 0 beta 3

1.23.103.2 Library
..................

   - bpo-21750(1): mock_open.read_data can now be read from each
     instance, as it could in Python 3.3.

   - bpo-24552(2): Fix use after free in an error case of the _pickle
     module.

   - bpo-24514(3): tarfile now tolerates number fields consisting of
     only whitespace.

   - bpo-19176(4): Fixed doctype() related bugs in C implementation of
     ElementTree.  A deprecation warning no longer issued by XMLParser
     subclass with default doctype() method.  Direct call of doctype()
     now issues a warning.  Parser's doctype() now is not called if
     target's doctype() is called.  Based on patch by Martin Panter.

   - bpo-20387(5): Restore semantic round-trip correctness in
     tokenize/untokenize for tab-indented blocks.

   - bpo-24456(6): Fixed possible buffer over-read in adpcm2lin() and
     lin2adpcm() functions of the audioop module.

   - bpo-24336(7): The contextmanager decorator now works with functions
     with keyword arguments called "func" and "self".  Patch by Martin
     Panter.

   - bpo-24522(8): Fix possible integer overflow in json accelerator
     module.

   - bpo-24489(9): ensure a previously set C errno doesn't disturb
     cmath.polar().

   - bpo-24408(10): Fixed AttributeError in measure() and metrics()
     methods of tkinter.Font.

   - bpo-14373(11): C implementation of functools.lru_cache() now can be
     used with methods.

   - bpo-24347(12): Set KeyError if PyDict_GetItemWithError returns
     NULL.

   - bpo-24348(13): Drop superfluous incref/decref.

   - bpo-24359(14): Check for changed OrderedDict size during iteration.

   - bpo-24368(15): Support keyword arguments in OrderedDict methods.

   - bpo-24362(16): Simplify the C OrderedDict fast nodes resize logic.

   - bpo-24377(17): Fix a ref leak in OrderedDict.__repr__.

   - bpo-24369(18): Defend against key-changes during iteration.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21750

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24552

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24514

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19176

   (5) https://bugs.python.org/issue?@action=redirect&bpo=20387

   (6) https://bugs.python.org/issue?@action=redirect&bpo=24456

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24336

   (8) https://bugs.python.org/issue?@action=redirect&bpo=24522

   (9) https://bugs.python.org/issue?@action=redirect&bpo=24489

   (10) https://bugs.python.org/issue?@action=redirect&bpo=24408

   (11) https://bugs.python.org/issue?@action=redirect&bpo=14373

   (12) https://bugs.python.org/issue?@action=redirect&bpo=24347

   (13) https://bugs.python.org/issue?@action=redirect&bpo=24348

   (14) https://bugs.python.org/issue?@action=redirect&bpo=24359

   (15) https://bugs.python.org/issue?@action=redirect&bpo=24368

   (16) https://bugs.python.org/issue?@action=redirect&bpo=24362

   (17) https://bugs.python.org/issue?@action=redirect&bpo=24377

   (18) https://bugs.python.org/issue?@action=redirect&bpo=24369


File: python.info,  Node: Tests<77>,  Next: Documentation<72>,  Prev: Library<89>,  Up: Python 3 5 0 beta 3

1.23.103.3 Tests
................

   - bpo-24373(1): _testmultiphase and xxlimited now use tp_traverse and
     tp_finalize to avoid reference leaks encountered when combining
     tp_dealloc with PyType_FromSpec (see bpo-16690(2) for details)

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24373

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16690


File: python.info,  Node: Documentation<72>,  Next: Build<84>,  Prev: Tests<77>,  Up: Python 3 5 0 beta 3

1.23.103.4 Documentation
........................

   - bpo-24458(1): Update documentation to cover multi-phase
     initialization for extension modules (PEP 489).  Patch by Petr
     Viktorin.

   - bpo-24351(2): Clarify what is meant by "identifier" in the context
     of string.Template instances.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24458

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24351


File: python.info,  Node: Build<84>,  Prev: Documentation<72>,  Up: Python 3 5 0 beta 3

1.23.103.5 Build
................

   - bpo-24432(1): Update Windows builds and OS X 10.5 installer to use
     OpenSSL 1.0.2c.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24432


File: python.info,  Node: Python 3 5 0 beta 2,  Next: Python 3 5 0 beta 1,  Prev: Python 3 5 0 beta 3,  Up: 変更履歴

1.23.104 Python 3.5.0 beta 2
----------------------------

'Release date: 2015-05-31'

* Menu:

* Core and Builtins: Core and Builtins<91>.
* Library: Library<90>.


File: python.info,  Node: Core and Builtins<91>,  Next: Library<90>,  Up: Python 3 5 0 beta 2

1.23.104.1 Core and Builtins
............................

   - bpo-24284(1): The startswith and endswith methods of the str class
     no longer return True when finding the empty string and the indexes
     are completely out of range.

   - bpo-24115(2): Update uses of PyObject_IsTrue(), PyObject_Not(),
     PyObject_IsInstance(), PyObject_RichCompareBool() and
     _PyDict_Contains() to check for and handle errors correctly.

   - bpo-24328(3): Fix importing one character extension modules.

   - bpo-11205(4): In dictionary displays, evaluate the key before the
     value.

   - bpo-24285(5): Fixed regression that prevented importing extension
     modules from inside packages.  Patch by Petr Viktorin.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24284

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24115

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24328

   (4) https://bugs.python.org/issue?@action=redirect&bpo=11205

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24285


File: python.info,  Node: Library<90>,  Prev: Core and Builtins<91>,  Up: Python 3 5 0 beta 2

1.23.104.2 Library
..................

   - bpo-23247(1): Fix a crash in the StreamWriter.reset() of CJK
     codecs.

   - bpo-24270(2): Add math.isclose() and cmath.isclose() functions as
     per PEP 485(3).  Contributed by Chris Barker and Tal Einat.

   - bpo-5633(4): Fixed timeit when the statement is a string and the
     setup is not.

   - bpo-24326(5): Fixed audioop.ratecv() with non-default weightB
     argument.  Original patch by David Moore.

   - bpo-16991(6): Add a C implementation of OrderedDict.

   - bpo-23934(7): Fix inspect.signature to fail correctly for builtin
     types lacking signature information.  Initial patch by James
     Powell.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23247

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24270

   (3) https://peps.python.org/pep-0485/

   (4) https://bugs.python.org/issue?@action=redirect&bpo=5633

   (5) https://bugs.python.org/issue?@action=redirect&bpo=24326

   (6) https://bugs.python.org/issue?@action=redirect&bpo=16991

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23934


File: python.info,  Node: Python 3 5 0 beta 1,  Next: Python 3 5 0 alpha 4,  Prev: Python 3 5 0 beta 2,  Up: 変更履歴

1.23.105 Python 3.5.0 beta 1
----------------------------

'Release date: 2015-05-24'

* Menu:

* Core and Builtins: Core and Builtins<92>.
* Library: Library<91>.
* IDLE: IDLE<62>.
* Tests: Tests<78>.
* Documentation: Documentation<73>.
* Tools/Demos: Tools/Demos<45>.


File: python.info,  Node: Core and Builtins<92>,  Next: Library<91>,  Up: Python 3 5 0 beta 1

1.23.105.1 Core and Builtins
............................

   - bpo-24276(1): Fixed optimization of property descriptor getter.

   - bpo-24268(2): PEP 489: Multi-phase extension module initialization.
     Patch by Petr Viktorin.

   - bpo-23955(3): Add pyvenv.cfg option to suppress
     registry/environment lookup for generating sys.path on Windows.

   - bpo-24257(4): Fixed system error in the comparison of faked
     types.SimpleNamespace.

   - bpo-22939(5): Fixed integer overflow in iterator object.  Patch by
     Clement Rouault.

   - bpo-23985(6): Fix a possible buffer overrun when deleting a slice
     from the front of a bytearray and then appending some other bytes
     data.

   - bpo-24102(7): Fixed exception type checking in standard error
     handlers.

   - bpo-15027(8): The UTF-32 encoder is now 3x to 7x faster.

   - bpo-23290(9): Optimize set_merge() for cases where the target is
     empty.  (Contributed by Serhiy Storchaka.)

   - bpo-2292(10): PEP 448: Additional Unpacking Generalizations.

   - bpo-24096(11): Make warnings.warn_explicit more robust against
     mutation of the warnings.filters list.

   - bpo-23996(12): Avoid a crash when a delegated generator raises an
     unnormalized StopIteration exception.  Patch by Stefan Behnel.

   - bpo-23910(13): Optimize property() getter calls.  Patch by Joe
     Jevnik.

   - bpo-23911(14): Move path-based importlib bootstrap code to a
     separate frozen module.

   - bpo-24192(15): Fix namespace package imports.

   - bpo-24022(16): Fix tokenizer crash when processing undecodable
     source code.

   - bpo-9951(17): Added a hex() method to bytes, bytearray, and
     memoryview.

   - bpo-22906(18): PEP 479: Change StopIteration handling inside
     generators.

   - bpo-24017(19): PEP 492: Coroutines with async and await syntax.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24276

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24268

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23955

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24257

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22939

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23985

   (7) https://bugs.python.org/issue?@action=redirect&bpo=24102

   (8) https://bugs.python.org/issue?@action=redirect&bpo=15027

   (9) https://bugs.python.org/issue?@action=redirect&bpo=23290

   (10) https://bugs.python.org/issue?@action=redirect&bpo=2292

   (11) https://bugs.python.org/issue?@action=redirect&bpo=24096

   (12) https://bugs.python.org/issue?@action=redirect&bpo=23996

   (13) https://bugs.python.org/issue?@action=redirect&bpo=23910

   (14) https://bugs.python.org/issue?@action=redirect&bpo=23911

   (15) https://bugs.python.org/issue?@action=redirect&bpo=24192

   (16) https://bugs.python.org/issue?@action=redirect&bpo=24022

   (17) https://bugs.python.org/issue?@action=redirect&bpo=9951

   (18) https://bugs.python.org/issue?@action=redirect&bpo=22906

   (19) https://bugs.python.org/issue?@action=redirect&bpo=24017


File: python.info,  Node: Library<91>,  Next: IDLE<62>,  Prev: Core and Builtins<92>,  Up: Python 3 5 0 beta 1

1.23.105.2 Library
..................

   - bpo-14373(1): Added C implementation of functools.lru_cache().
     Based on patches by Matt Joiner and Alexey Kachayev.

   - bpo-24230(2): The tempfile module now accepts bytes for prefix,
     suffix and dir parameters and returns bytes in such situations
     (matching the os module APIs).

   - bpo-22189(3): collections.UserString now supports __getnewargs__(),
     __rmod__(), casefold(), format_map(), isprintable(), and
     maketrans().  Patch by Joe Jevnik.

   - bpo-24244(4): Prevents termination when an invalid format string is
     encountered on Windows in strftime.

   - bpo-23973(5): PEP 484: Add the typing module.

   - bpo-23086(6): The collections.abc.Sequence() abstract base class
     added 'start' and 'stop' parameters to the index() mixin.  Patch by
     Devin Jeanpierre.

   - bpo-20035(7): Replaced the ‘tkinter._fix’ module used for setting
     up the Tcl/Tk environment on Windows with a private function in the
     ‘_tkinter’ module that makes no permanent changes to the
     environment.

   - bpo-24257(8): Fixed segmentation fault in sqlite3.Row constructor
     with faked cursor type.

   - bpo-15836(9): assertRaises(), assertRaisesRegex(), assertWarns()
     and assertWarnsRegex() assertments now check the type of the first
     argument to prevent possible user error.  Based on patch by Daniel
     Wagner-Hall.

   - bpo-9858(10): Add missing method stubs to _io.RawIOBase.  Patch by
     Laura Rupprecht.

   - bpo-22955(11): attrgetter, itemgetter and methodcaller objects in
     the operator module now support pickling.  Added readable and
     evaluable repr for these objects.  Based on patch by Josh
     Rosenberg.

   - bpo-22107(12): tempfile.gettempdir() and tempfile.mkdtemp() now try
     again when a directory with the chosen name already exists on
     Windows as well as on Unix.  tempfile.mkstemp() now fails early if
     parent directory is not valid (not exists or is a file) on Windows.

   - bpo-23780(13): Improved error message in os.path.join() with single
     argument.

   - bpo-6598(14): Increased time precision and random number range in
     email.utils.make_msgid() to strengthen the uniqueness of the
     message ID.

   - bpo-24091(15): Fixed various crashes in corner cases in C
     implementation of ElementTree.

   - bpo-21931(16): msilib.FCICreate() now raises TypeError in the case
     of a bad argument instead of a ValueError with a bogus FCI error
     number.  Patch by Jeffrey Armstrong.

   - bpo-13866(17): 'quote_via' argument added to
     urllib.parse.urlencode.

   - bpo-20098(18): New mangle_from policy option for email, default
     True for compat32, but False for all other policies.

   - bpo-24211(19): The email library now supports RFC 6532: it can
     generate headers using utf-8 instead of encoded words.

   - bpo-16314(20): Added support for the LZMA compression in distutils.

   - bpo-21804(21): poplib now supports RFC 6856 (UTF8).

   - bpo-18682(22): Optimized pprint functions for builtin scalar types.

   - bpo-22027(23): smtplib now supports RFC 6531 (SMTPUTF8).

   - bpo-23488(24): Random generator objects now consume 2x less memory
     on 64-bit.

   - bpo-1322(25): platform.dist() and platform.linux_distribution()
     functions are now deprecated.  Initial patch by Vajrasky Kok.

   - bpo-22486(26): Added the math.gcd() function.  The fractions.gcd()
     function now is deprecated.  Based on patch by Mark Dickinson.

   - bpo-24064(27): Property() docstrings are now writeable.  (Patch by
     Berker Peksag.)

   - bpo-22681(28): Added support for the koi8_t encoding.

   - bpo-22682(29): Added support for the kz1048 encoding.

   - bpo-23796(30): peek and read1 methods of BufferedReader now raise
     ValueError if they called on a closed object.  Patch by John
     Hergenroeder.

   - bpo-21795(31): smtpd now supports the 8BITMIME extension whenever
     the new 'decode_data' constructor argument is set to False.

   - bpo-24155(32): optimize heapq.heapify() for better cache
     performance when heapifying large lists.

   - bpo-21800(33): imaplib now supports RFC 5161 (enable), RFC 6855
     (utf8/internationalized email) and automatically encodes non-ASCII
     usernames and passwords to UTF8.

   - bpo-20274(34): When calling a _sqlite.Connection, it now complains
     if passed any keyword arguments.  Previously it silently ignored
     them.

   - bpo-20274(35): Remove ignored and erroneous "kwargs" parameters
     from three METH_VARARGS methods on _sqlite.Connection.

   - bpo-24134(36): assertRaises(), assertRaisesRegex(), assertWarns()
     and assertWarnsRegex() checks now emits a deprecation warning when
     callable is None or keyword arguments except msg is passed in the
     context manager mode.

   - bpo-24018(37): Add a collections.abc.Generator abstract base class.
     Contributed by Stefan Behnel.

   - bpo-23880(38): Tkinter's getint() and getdouble() now support
     Tcl_Obj.  Tkinter's getdouble() now supports any numbers (in
     particular int).

   - bpo-22619(39): Added negative limit support in the traceback
     module.  Based on patch by Dmitry Kazakov.

   - bpo-24094(40): Fix possible crash in json.encode with poorly
     behaved dict subclasses.

   - bpo-9246(41): On POSIX, os.getcwd() now supports paths longer than
     1025 bytes.  Patch written by William Orr.

   - bpo-17445(42): add difflib.diff_bytes() to support comparison of
     byte strings (fixes a regression from Python 2).

   - bpo-23917(43): Fall back to sequential compilation when
     ProcessPoolExecutor doesn't exist.  Patch by Claudiu Popa.

   - bpo-23008(44): Fixed resolving attributes with boolean value is
     False in pydoc.

   - Fix asyncio issue 235: LifoQueue and PriorityQueue's put didn't
     increment unfinished tasks (this bug was introduced when
     JoinableQueue was merged with Queue).

   - bpo-23908(45): os functions now reject paths with embedded null
     character on Windows instead of silently truncating them.

   - bpo-23728(46): binascii.crc_hqx() could return an integer outside
     of the range 0-0xffff for empty data.

   - bpo-23887(47): urllib.error.HTTPError now has a proper repr()
     representation.  Patch by Berker Peksag.

   - asyncio: New event loop APIs: set_task_factory() and
     get_task_factory().

   - asyncio: async() function is deprecated in favour of
     ensure_future().

   - bpo-24178(48): asyncio.Lock, Condition, Semaphore, and
     BoundedSemaphore support new 'async with' syntax.  Contributed by
     Yury Selivanov.

   - bpo-24179(49): Support 'async for' for asyncio.StreamReader.
     Contributed by Yury Selivanov.

   - bpo-24184(50): Add AsyncIterator and AsyncIterable ABCs to
     collections.abc.  Contributed by Yury Selivanov.

   - bpo-22547(51): Implement informative __repr__ for
     inspect.BoundArguments.  Contributed by Yury Selivanov.

   - bpo-24190(52): Implement inspect.BoundArgument.apply_defaults()
     method.  Contributed by Yury Selivanov.

   - bpo-20691(53): Add 'follow_wrapped' argument to
     inspect.Signature.from_callable() and inspect.signature().
     Contributed by Yury Selivanov.

   - bpo-24248(54): Deprecate inspect.Signature.from_function() and
     inspect.Signature.from_builtin().

   - bpo-23898(55): Fix inspect.classify_class_attrs() to support
     attributes with overloaded __eq__ and __bool__.  Patch by Mike
     Bayer.

   - bpo-24298(56): Fix inspect.signature() to correctly unwrap wrappers
     around bound methods.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14373

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24230

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22189

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24244

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23973

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23086

   (7) https://bugs.python.org/issue?@action=redirect&bpo=20035

   (8) https://bugs.python.org/issue?@action=redirect&bpo=24257

   (9) https://bugs.python.org/issue?@action=redirect&bpo=15836

   (10) https://bugs.python.org/issue?@action=redirect&bpo=9858

   (11) https://bugs.python.org/issue?@action=redirect&bpo=22955

   (12) https://bugs.python.org/issue?@action=redirect&bpo=22107

   (13) https://bugs.python.org/issue?@action=redirect&bpo=23780

   (14) https://bugs.python.org/issue?@action=redirect&bpo=6598

   (15) https://bugs.python.org/issue?@action=redirect&bpo=24091

   (16) https://bugs.python.org/issue?@action=redirect&bpo=21931

   (17) https://bugs.python.org/issue?@action=redirect&bpo=13866

   (18) https://bugs.python.org/issue?@action=redirect&bpo=20098

   (19) https://bugs.python.org/issue?@action=redirect&bpo=24211

   (20) https://bugs.python.org/issue?@action=redirect&bpo=16314

   (21) https://bugs.python.org/issue?@action=redirect&bpo=21804

   (22) https://bugs.python.org/issue?@action=redirect&bpo=18682

   (23) https://bugs.python.org/issue?@action=redirect&bpo=22027

   (24) https://bugs.python.org/issue?@action=redirect&bpo=23488

   (25) https://bugs.python.org/issue?@action=redirect&bpo=1322

   (26) https://bugs.python.org/issue?@action=redirect&bpo=22486

   (27) https://bugs.python.org/issue?@action=redirect&bpo=24064

   (28) https://bugs.python.org/issue?@action=redirect&bpo=22681

   (29) https://bugs.python.org/issue?@action=redirect&bpo=22682

   (30) https://bugs.python.org/issue?@action=redirect&bpo=23796

   (31) https://bugs.python.org/issue?@action=redirect&bpo=21795

   (32) https://bugs.python.org/issue?@action=redirect&bpo=24155

   (33) https://bugs.python.org/issue?@action=redirect&bpo=21800

   (34) https://bugs.python.org/issue?@action=redirect&bpo=20274

   (35) https://bugs.python.org/issue?@action=redirect&bpo=20274

   (36) https://bugs.python.org/issue?@action=redirect&bpo=24134

   (37) https://bugs.python.org/issue?@action=redirect&bpo=24018

   (38) https://bugs.python.org/issue?@action=redirect&bpo=23880

   (39) https://bugs.python.org/issue?@action=redirect&bpo=22619

   (40) https://bugs.python.org/issue?@action=redirect&bpo=24094

   (41) https://bugs.python.org/issue?@action=redirect&bpo=9246

   (42) https://bugs.python.org/issue?@action=redirect&bpo=17445

   (43) https://bugs.python.org/issue?@action=redirect&bpo=23917

   (44) https://bugs.python.org/issue?@action=redirect&bpo=23008

   (45) https://bugs.python.org/issue?@action=redirect&bpo=23908

   (46) https://bugs.python.org/issue?@action=redirect&bpo=23728

   (47) https://bugs.python.org/issue?@action=redirect&bpo=23887

   (48) https://bugs.python.org/issue?@action=redirect&bpo=24178

   (49) https://bugs.python.org/issue?@action=redirect&bpo=24179

   (50) https://bugs.python.org/issue?@action=redirect&bpo=24184

   (51) https://bugs.python.org/issue?@action=redirect&bpo=22547

   (52) https://bugs.python.org/issue?@action=redirect&bpo=24190

   (53) https://bugs.python.org/issue?@action=redirect&bpo=20691

   (54) https://bugs.python.org/issue?@action=redirect&bpo=24248

   (55) https://bugs.python.org/issue?@action=redirect&bpo=23898

   (56) https://bugs.python.org/issue?@action=redirect&bpo=24298


File: python.info,  Node: IDLE<62>,  Next: Tests<78>,  Prev: Library<91>,  Up: Python 3 5 0 beta 1

1.23.105.3 IDLE
...............

   - bpo-23184(1): remove unused names and imports in idlelib.  Initial
     patch by Al Sweigart.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23184


File: python.info,  Node: Tests<78>,  Next: Documentation<73>,  Prev: IDLE<62>,  Up: Python 3 5 0 beta 1

1.23.105.4 Tests
................

   - bpo-21520(1): test_zipfile no longer fails if the word 'bad'
     appears anywhere in the name of the current directory.

   - bpo-9517(2): Move script_helper into the support package.  Patch by
     Christie Wilson.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=21520

   (2) https://bugs.python.org/issue?@action=redirect&bpo=9517


File: python.info,  Node: Documentation<73>,  Next: Tools/Demos<45>,  Prev: Tests<78>,  Up: Python 3 5 0 beta 1

1.23.105.5 Documentation
........................

   - bpo-22155(1): Add File Handlers subsection with createfilehandler
     to tkinter doc.  Remove obsolete example from FAQ. Patch by Martin
     Panter.

   - bpo-24029(2): Document the name binding behavior for submodule
     imports.

   - bpo-24077(3): Fix typo in man page for -I command option: -s, not
     -S

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22155

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24029

   (3) https://bugs.python.org/issue?@action=redirect&bpo=24077


File: python.info,  Node: Tools/Demos<45>,  Prev: Documentation<73>,  Up: Python 3 5 0 beta 1

1.23.105.6 Tools/Demos
......................

   - bpo-24000(1): Improved Argument Clinic's mapping of converters to
     legacy "format units".  Updated the documentation to match.

   - bpo-24001(2): Argument Clinic converters now use accept={type}
     instead of types={'type'} to specify the types the converter
     accepts.

   - bpo-23330(3): h2py now supports arbitrary filenames in #include.

   - bpo-24031(4): make patchcheck now supports git checkouts, too.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=24000

   (2) https://bugs.python.org/issue?@action=redirect&bpo=24001

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23330

   (4) https://bugs.python.org/issue?@action=redirect&bpo=24031


File: python.info,  Node: Python 3 5 0 alpha 4,  Next: Python 3 5 0 alpha 3,  Prev: Python 3 5 0 beta 1,  Up: 変更履歴

1.23.106 Python 3.5.0 alpha 4
-----------------------------

'Release date: 2015-04-19'

* Menu:

* Core and Builtins: Core and Builtins<93>.
* Library: Library<92>.
* Build: Build<85>.
* Tests: Tests<79>.
* Tools/Demos: Tools/Demos<46>.
* C API: C API<69>.


File: python.info,  Node: Core and Builtins<93>,  Next: Library<92>,  Up: Python 3 5 0 alpha 4

1.23.106.1 Core and Builtins
............................

   - bpo-22980(1): Under Linux, GNU/KFreeBSD and the Hurd, C extensions
     now include the architecture triplet in the extension name, to make
     it easy to test builds for different ABIs in the same working tree.
     Under OS X, the extension name now includes PEP 3149(2)-style
     information.

   - bpo-22631(3): Added Linux-specific socket constant
     CAN_RAW_FD_FRAMES. Patch courtesy of Joe Jevnik.

   - bpo-23731(4): Implement PEP 488(5): removal of .pyo files.

   - bpo-23726(6): Don't enable GC for user subclasses of non-GC types
     that don't add any new fields.  Patch by Eugene Toder.

   - bpo-23309(7): Avoid a deadlock at shutdown if a daemon thread is
     aborted while it is holding a lock to a buffered I/O object, and
     the main thread tries to use the same I/O object (typically stdout
     or stderr).  A fatal error is emitted instead.

   - bpo-22977(8): Fixed formatting Windows error messages on Wine.
     Patch by Martin Panter.

   - bpo-23466(9): %c, %o, %x, and %X in bytes formatting now raise
     TypeError on non-integer input.

   - bpo-24044(10): Fix possible null pointer dereference in list.sort
     in out of memory conditions.

   - bpo-21354(11): PyCFunction_New function is exposed by python DLL
     again.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22980

   (2) https://peps.python.org/pep-3149/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22631

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23731

   (5) https://peps.python.org/pep-0488/

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23726

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23309

   (8) https://bugs.python.org/issue?@action=redirect&bpo=22977

   (9) https://bugs.python.org/issue?@action=redirect&bpo=23466

   (10) https://bugs.python.org/issue?@action=redirect&bpo=24044

   (11) https://bugs.python.org/issue?@action=redirect&bpo=21354


File: python.info,  Node: Library<92>,  Next: Build<85>,  Prev: Core and Builtins<93>,  Up: Python 3 5 0 alpha 4

1.23.106.2 Library
..................

   - bpo-23840(1): tokenize.open() now closes the temporary binary file
     on error to fix a resource warning.

   - bpo-16914(2): new debuglevel 2 in smtplib adds timestamps to debug
     output.

   - bpo-7159(3): urllib.request now supports sending auth credentials
     automatically after the first 401.  This enhancement is a superset
     of the enhancement from bpo-19494(4) and supersedes that change.

   - bpo-23703(5): Fix a regression in urljoin() introduced in
     901e4e52b20a.  Patch by Demian Brecht.

   - bpo-4254(6): Adds _curses.update_lines_cols().  Patch by Arnon
     Yaari

   - bpo-19933(7): Provide default argument for ndigits in round.  Patch
     by Vajrasky Kok.

   - bpo-23193(8): Add a numeric_owner parameter to
     tarfile.TarFile.extract and tarfile.TarFile.extractall.  Patch by
     Michael Vogt and Eric Smith.

   - bpo-23342(9): Add a subprocess.run() function than returns a
     CalledProcess instance for a more consistent API than the existing
     call* functions.

   - bpo-21217(10): inspect.getsourcelines() now tries to compute the
     start and end lines from the code object, fixing an issue when a
     lambda function is used as decorator argument.  Patch by Thomas
     Ballinger and Allison Kaptur.

   - bpo-24521(11): Fix possible integer overflows in the pickle module.

   - bpo-22931(12): Allow '[' and ']' in cookie values.

   - The keywords attribute of functools.partial is now always a
     dictionary.

   - bpo-23811(13): Add missing newline to the PyCompileError error
     message.  Patch by Alex Shkop.

   - bpo-21116(14): Avoid blowing memory when allocating a
     multiprocessing shared array that's larger than 50% of the
     available RAM. Patch by Médéric Boquien.

   - bpo-22982(15): Improve BOM handling when seeking to multiple
     positions of a writable text file.

   - bpo-23464(16): Removed deprecated asyncio JoinableQueue.

   - bpo-23529(17): Limit the size of decompressed data when reading
     from GzipFile, BZ2File or LZMAFile.  This defeats denial of service
     attacks using compressed bombs (i.e.  compressed payloads which
     decompress to a huge size).  Patch by Martin Panter and Nikolaus
     Rath.

   - bpo-21859(18): Added Python implementation of io.FileIO.

   - bpo-23865(19): close() methods in multiple modules now are
     idempotent and more robust at shutdown.  If they need to release
     multiple resources, all are released even if errors occur.

   - bpo-23400(20): Raise same exception on both Python 2 and 3 if
     sem_open is not available.  Patch by Davin Potts.

   - bpo-10838(21): The subprocess now module includes SubprocessError
     and TimeoutError in its list of exported names for the users wild
     enough to use ‘from subprocess import *’.

   - bpo-23411(22): Added DefragResult, ParseResult, SplitResult,
     DefragResultBytes, ParseResultBytes, and SplitResultBytes to
     urllib.parse.__all__.  Patch by Martin Panter.

   - bpo-23881(23): urllib.request.ftpwrapper constructor now closes the
     socket if the FTP connection failed to fix a ResourceWarning.

   - bpo-23853(24): *note socket.socket.sendall(): d75. does no more
     reset the socket timeout each time data is sent successfully.  The
     socket timeout is now the maximum total duration to send all data.

   - bpo-22721(25): An order of multiline pprint output of set or dict
     containing orderable and non-orderable elements no longer depends
     on iteration order of set or dict.

   - bpo-15133(26): _tkinter.tkapp.getboolean() now supports Tcl_Obj and
     always returns bool.  tkinter.BooleanVar now validates input values
     (accepted bool, int, str, and Tcl_Obj).  tkinter.BooleanVar.get()
     now always returns bool.

   - bpo-10590(27): xml.sax.parseString() now supports string argument.

   - bpo-23338(28): Fixed formatting ctypes error messages on Cygwin.
     Patch by Makoto Kato.

   - bpo-15582(29): inspect.getdoc() now follows inheritance chains.

   - bpo-2175(30): SAX parsers now support a character stream of
     InputSource object.

   - bpo-16840(31): Tkinter now supports 64-bit integers added in Tcl
     8.4 and arbitrary precision integers added in Tcl 8.5.

   - bpo-23834(32): Fix socket.sendto(), use the C Py_ssize_t type to
     store the result of sendto() instead of the C int type.

   - bpo-23618(33): *note socket.socket.connect(): d70. now waits until
     the connection completes instead of raising *note InterruptedError:
     d55. if the connection is interrupted by signals, signal handlers
     don't raise an exception and the socket is blocking or has a
     timeout.  *note socket.socket.connect(): d70. still raise *note
     InterruptedError: d55. for non-blocking sockets.

   - bpo-21526(34): Tkinter now supports new boolean type in Tcl 8.5.

   - bpo-23836(35): Fix the faulthandler module to handle reentrant
     calls to its signal handlers.

   - bpo-23838(36): linecache now clears the cache and returns an empty
     result on MemoryError.

   - bpo-10395(37): Added os.path.commonpath().  Implemented in
     posixpath and ntpath.  Based on patch by Rafik Draoui.

   - bpo-23611(38): Serializing more "lookupable" objects (such as
     unbound methods or nested classes) now are supported with pickle
     protocols < 4.

   - bpo-13583(39): sqlite3.Row now supports slice indexing.

   - bpo-18473(40): Fixed 2to3 and 3to2 compatible pickle mappings.
     Fixed ambiguous reverse mappings.  Added many new mappings.  Import
     mapping is no longer applied to modules already mapped with full
     name mapping.

   - bpo-23485(41): select.select() is now retried automatically with
     the recomputed timeout when interrupted by a signal, except if the
     signal handler raises an exception.  This change is part of the PEP
     475(42).

   - bpo-23752(43): When built from an existing file descriptor,
     io.FileIO() now only calls fstat() once.  Before fstat() was called
     twice, which was not necessary.

   - bpo-23704(44): collections.deque() objects now support __add__,
     __mul__, and __imul__().

   - bpo-23171(45): csv.Writer.writerow() now supports arbitrary
     iterables.

   - bpo-23745(46): The new email header parser now handles duplicate
     MIME parameter names without error, similar to how get_param
     behaves.

   - bpo-22117(47): Fix os.utime(), it now rounds the timestamp towards
     minus infinity (-inf) instead of rounding towards zero.

   - bpo-23310(48): Fix MagicMock's initializer to work with
     __methods__, just like configure_mock().  Patch by Kasia Jachim.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23840

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16914

   (3) https://bugs.python.org/issue?@action=redirect&bpo=7159

   (4) https://bugs.python.org/issue?@action=redirect&bpo=19494

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23703

   (6) https://bugs.python.org/issue?@action=redirect&bpo=4254

   (7) https://bugs.python.org/issue?@action=redirect&bpo=19933

   (8) https://bugs.python.org/issue?@action=redirect&bpo=23193

   (9) https://bugs.python.org/issue?@action=redirect&bpo=23342

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21217

   (11) https://bugs.python.org/issue?@action=redirect&bpo=24521

   (12) https://bugs.python.org/issue?@action=redirect&bpo=22931

   (13) https://bugs.python.org/issue?@action=redirect&bpo=23811

   (14) https://bugs.python.org/issue?@action=redirect&bpo=21116

   (15) https://bugs.python.org/issue?@action=redirect&bpo=22982

   (16) https://bugs.python.org/issue?@action=redirect&bpo=23464

   (17) https://bugs.python.org/issue?@action=redirect&bpo=23529

   (18) https://bugs.python.org/issue?@action=redirect&bpo=21859

   (19) https://bugs.python.org/issue?@action=redirect&bpo=23865

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23400

   (21) https://bugs.python.org/issue?@action=redirect&bpo=10838

   (22) https://bugs.python.org/issue?@action=redirect&bpo=23411

   (23) https://bugs.python.org/issue?@action=redirect&bpo=23881

   (24) https://bugs.python.org/issue?@action=redirect&bpo=23853

   (25) https://bugs.python.org/issue?@action=redirect&bpo=22721

   (26) https://bugs.python.org/issue?@action=redirect&bpo=15133

   (27) https://bugs.python.org/issue?@action=redirect&bpo=10590

   (28) https://bugs.python.org/issue?@action=redirect&bpo=23338

   (29) https://bugs.python.org/issue?@action=redirect&bpo=15582

   (30) https://bugs.python.org/issue?@action=redirect&bpo=2175

   (31) https://bugs.python.org/issue?@action=redirect&bpo=16840

   (32) https://bugs.python.org/issue?@action=redirect&bpo=23834

   (33) https://bugs.python.org/issue?@action=redirect&bpo=23618

   (34) https://bugs.python.org/issue?@action=redirect&bpo=21526

   (35) https://bugs.python.org/issue?@action=redirect&bpo=23836

   (36) https://bugs.python.org/issue?@action=redirect&bpo=23838

   (37) https://bugs.python.org/issue?@action=redirect&bpo=10395

   (38) https://bugs.python.org/issue?@action=redirect&bpo=23611

   (39) https://bugs.python.org/issue?@action=redirect&bpo=13583

   (40) https://bugs.python.org/issue?@action=redirect&bpo=18473

   (41) https://bugs.python.org/issue?@action=redirect&bpo=23485

   (42) https://peps.python.org/pep-0475/

   (43) https://bugs.python.org/issue?@action=redirect&bpo=23752

   (44) https://bugs.python.org/issue?@action=redirect&bpo=23704

   (45) https://bugs.python.org/issue?@action=redirect&bpo=23171

   (46) https://bugs.python.org/issue?@action=redirect&bpo=23745

   (47) https://bugs.python.org/issue?@action=redirect&bpo=22117

   (48) https://bugs.python.org/issue?@action=redirect&bpo=23310


File: python.info,  Node: Build<85>,  Next: Tests<79>,  Prev: Library<92>,  Up: Python 3 5 0 alpha 4

1.23.106.3 Build
................

   - bpo-23817(1): FreeBSD now uses "1.0" in the SOVERSION as other
     operating systems, instead of just "1".

   - bpo-23501(2): Argument Clinic now generates code into separate
     files by default.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23817

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23501


File: python.info,  Node: Tests<79>,  Next: Tools/Demos<46>,  Prev: Build<85>,  Up: Python 3 5 0 alpha 4

1.23.106.4 Tests
................

   - bpo-23799(1): Added test.support.start_threads() for running and
     cleaning up multiple threads.

   - bpo-22390(2): test.regrtest now emits a warning if temporary files
     or directories are left after running a test.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23799

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22390


File: python.info,  Node: Tools/Demos<46>,  Next: C API<69>,  Prev: Tests<79>,  Up: Python 3 5 0 alpha 4

1.23.106.5 Tools/Demos
......................

   - bpo-18128(1): pygettext now uses standard +NNNN format in the
     POT-Creation-Date header.

   - bpo-23935(2): Argument Clinic's understanding of format units
     accepting bytes, bytearrays, and buffers is now consistent with
     both the documentation and the implementation.

   - bpo-23944(3): Argument Clinic now wraps long impl prototypes at
     column 78.

   - bpo-20586(4): Argument Clinic now ensures that functions without
     docstrings have signatures.

   - bpo-23492(5): Argument Clinic now generates argument parsing code
     with PyArg_Parse instead of PyArg_ParseTuple if possible.

   - bpo-23500(6): Argument Clinic is now smarter about generating the
     "#ifndef" (empty) definition of the methoddef macro: it's only
     generated once, even if Argument Clinic processes the same symbol
     multiple times, and it's emitted at the end of all processing
     rather than immediately after the first use.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18128

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23935

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23944

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20586

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23492

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23500


File: python.info,  Node: C API<69>,  Prev: Tools/Demos<46>,  Up: Python 3 5 0 alpha 4

1.23.106.6 C API
................

   - bpo-23998(1): PyImport_ReInitLock() now checks for lock allocation
     error

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23998


File: python.info,  Node: Python 3 5 0 alpha 3,  Next: Python 3 5 0 alpha 2,  Prev: Python 3 5 0 alpha 4,  Up: 変更履歴

1.23.107 Python 3.5.0 alpha 3
-----------------------------

'Release date: 2015-03-28'

* Menu:

* Core and Builtins: Core and Builtins<94>.
* Library: Library<93>.
* Build: Build<86>.
* Tests: Tests<80>.
* Tools/Demos: Tools/Demos<47>.


File: python.info,  Node: Core and Builtins<94>,  Next: Library<93>,  Up: Python 3 5 0 alpha 3

1.23.107.1 Core and Builtins
............................

   - bpo-23573(1): Increased performance of string search operations
     (str.find, str.index, str.count, the in operator, str.split,
     str.partition) with arguments of different kinds (UCS1, UCS2,
     UCS4).

   - bpo-23753(2): Python doesn't support anymore platforms without
     stat() or fstat(), these functions are always required.

   - bpo-23681(3): The -b option now affects comparisons of bytes with
     int.

   - bpo-23632(4): Memoryviews now allow tuple indexing (including for
     multi-dimensional memoryviews).

   - bpo-23192(5): Fixed generator lambdas.  Patch by Bruno Cauet.

   - bpo-23629(6): Fix the default __sizeof__ implementation for
     variable-sized objects.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23573

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23753

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23681

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23632

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23192

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23629


File: python.info,  Node: Library<93>,  Next: Build<86>,  Prev: Core and Builtins<94>,  Up: Python 3 5 0 alpha 3

1.23.107.2 Library
..................

   - bpo-14260(1): The groupindex attribute of regular expression
     pattern object now is non-modifiable mapping.

   - bpo-23792(2): Ignore KeyboardInterrupt when the pydoc pager is
     active.  This mimics the behavior of the standard unix pagers, and
     prevents pipepager from shutting down while the pager itself is
     still running.

   - bpo-23775(3): pprint() of OrderedDict now outputs the same
     representation as repr().

   - bpo-23765(4): Removed IsBadStringPtr calls in ctypes

   - bpo-22364(5): Improved some re error messages using regex for
     hints.

   - bpo-23742(6): ntpath.expandvars() no longer loses unbalanced single
     quotes.

   - bpo-21717(7): The zipfile.ZipFile.open function now supports 'x'
     (exclusive creation) mode.

   - bpo-21802(8): The reader in BufferedRWPair now is closed even when
     closing writer failed in BufferedRWPair.close().

   - bpo-23622(9): Unknown escapes in regular expressions that consist
     of ‘'\'’ and ASCII letter now raise a deprecation warning and will
     be forbidden in Python 3.6.

   - bpo-23671(10): string.Template now allows specifying the "self"
     parameter as a keyword argument.  string.Formatter now allows
     specifying the "self" and the "format_string" parameters as keyword
     arguments.

   - bpo-23502(11): The pprint module now supports mapping proxies.

   - bpo-17530(12): pprint now wraps long bytes objects and bytearrays.

   - bpo-22687(13): Fixed some corner cases in breaking words in
     tetxtwrap.  Got rid of quadratic complexity in breaking long words.

   - bpo-4727(14): The copy module now uses pickle protocol 4 (PEP 3154)
     and supports copying of instances of classes whose __new__ method
     takes keyword-only arguments.

   - bpo-23491(15): Added a zipapp module to support creating executable
     zip file archives of Python code.  Registered ".pyz" and ".pyzw"
     extensions on Windows for these archives (PEP 441).

   - bpo-23657(16): Avoid explicit checks for str in zipapp, adding
     support for pathlib.Path objects as arguments.

   - bpo-23688(17): Added support of arbitrary bytes-like objects and
     avoided unnecessary copying of memoryview in gzip.GzipFile.write().
     Original patch by Wolfgang Maier.

   - bpo-23252(18): Added support for writing ZIP files to unseekable
     streams.

   - bpo-23647(19): Increase imaplib's MAXLINE to accommodate modern
     mailbox sizes.

   - bpo-23539(20): If body is None, http.client.HTTPConnection.request
     now sets Content-Length to 0 for PUT, POST, and PATCH headers to
     avoid 411 errors from some web servers.

   - bpo-22351(21): The nntplib.NNTP constructor no longer leaves the
     connection and socket open until the garbage collector cleans them
     up.  Patch by Martin Panter.

   - bpo-23704(22): collections.deque() objects now support methods for
     index(), insert(), and copy().  This allows deques to be registered
     as a MutableSequence and it improves their substitutability for
     lists.

   - bpo-23715(23): *note signal.sigwaitinfo(): d78. and *note
     signal.sigtimedwait(): d77. are now retried when interrupted by a
     signal not in the 'sigset' parameter, if the signal handler does
     not raise an exception.  signal.sigtimedwait() recomputes the
     timeout with a monotonic clock when it is retried.

   - bpo-23001(24): Few functions in modules mmap, ossaudiodev, socket,
     ssl, and codecs, that accepted only read-only bytes-like object now
     accept writable bytes-like object too.

   - bpo-23646(25): If time.sleep() is interrupted by a signal, the
     sleep is now retried with the recomputed delay, except if the
     signal handler raises an exception (PEP 475).

   - bpo-23136(26): _strptime now uniformly handles all days in week 0,
     including Dec 30 of previous year.  Based on patch by Jim Carroll.

   - bpo-23700(27): Iterator of NamedTemporaryFile now keeps a reference
     to NamedTemporaryFile instance.  Patch by Bohuslav Kabrda.

   - bpo-22903(28): The fake test case created by unittest.loader when
     it fails importing a test module is now picklable.

   - bpo-22181(29): On Linux, os.urandom() now uses the new getrandom()
     syscall if available, syscall introduced in the Linux kernel 3.17.
     It is more reliable and more secure, because it avoids the need of
     a file descriptor and waits until the kernel has enough entropy.

   - bpo-2211(30): Updated the implementation of the http.cookies.Morsel
     class.  Setting attributes key, value and coded_value directly now
     is deprecated.  update() and setdefault() now transform and check
     keys.  Comparing for equality now takes into account attributes
     key, value and coded_value.  copy() now returns a Morsel, not a
     dict.  repr() now contains all attributes.  Optimized checking keys
     and quoting values.  Added new tests.  Original patch by Demian
     Brecht.

   - bpo-18983(31): Allow selection of output units in timeit.  Patch by
     Julian Gindi.

   - bpo-23631(32): Fix traceback.format_list when a traceback has been
     mutated.

   - bpo-23568(33): Add rdivmod support to MagicMock() objects.  Patch
     by Håkan Lövdahl.

   - bpo-2052(34): Add charset parameter to HtmlDiff.make_file().

   - bpo-23668(35): Support os.truncate and os.ftruncate on Windows.

   - bpo-23138(36): Fixed parsing cookies with absent keys or values in
     cookiejar.  Patch by Demian Brecht.

   - bpo-23051(37): multiprocessing.Pool methods imap() and
     imap_unordered() now handle exceptions raised by an iterator.
     Patch by Alon Diamant and Davin Potts.

   - bpo-23581(38): Add matmul support to MagicMock.  Patch by Håkan
     Lövdahl.

   - bpo-23566(39): enable(), register(), dump_traceback() and
     dump_traceback_later() functions of faulthandler now accept file
     descriptors.  Patch by Wei Wu.

   - bpo-22928(40): Disabled HTTP header injections in http.client.
     Original patch by Demian Brecht.

   - bpo-23615(41): Modules bz2, tarfile and tokenize now can be
     reloaded with imp.reload().  Patch by Thomas Kluyver.

   - bpo-23605(42): os.walk() now calls os.scandir() instead of
     os.listdir().  The usage of os.scandir() reduces the number of
     calls to os.stat().  Initial patch written by Ben Hoyt.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14260

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23792

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23775

   (4) https://bugs.python.org/issue?@action=redirect&bpo=23765

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22364

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23742

   (7) https://bugs.python.org/issue?@action=redirect&bpo=21717

   (8) https://bugs.python.org/issue?@action=redirect&bpo=21802

   (9) https://bugs.python.org/issue?@action=redirect&bpo=23622

   (10) https://bugs.python.org/issue?@action=redirect&bpo=23671

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23502

   (12) https://bugs.python.org/issue?@action=redirect&bpo=17530

   (13) https://bugs.python.org/issue?@action=redirect&bpo=22687

   (14) https://bugs.python.org/issue?@action=redirect&bpo=4727

   (15) https://bugs.python.org/issue?@action=redirect&bpo=23491

   (16) https://bugs.python.org/issue?@action=redirect&bpo=23657

   (17) https://bugs.python.org/issue?@action=redirect&bpo=23688

   (18) https://bugs.python.org/issue?@action=redirect&bpo=23252

   (19) https://bugs.python.org/issue?@action=redirect&bpo=23647

   (20) https://bugs.python.org/issue?@action=redirect&bpo=23539

   (21) https://bugs.python.org/issue?@action=redirect&bpo=22351

   (22) https://bugs.python.org/issue?@action=redirect&bpo=23704

   (23) https://bugs.python.org/issue?@action=redirect&bpo=23715

   (24) https://bugs.python.org/issue?@action=redirect&bpo=23001

   (25) https://bugs.python.org/issue?@action=redirect&bpo=23646

   (26) https://bugs.python.org/issue?@action=redirect&bpo=23136

   (27) https://bugs.python.org/issue?@action=redirect&bpo=23700

   (28) https://bugs.python.org/issue?@action=redirect&bpo=22903

   (29) https://bugs.python.org/issue?@action=redirect&bpo=22181

   (30) https://bugs.python.org/issue?@action=redirect&bpo=2211

   (31) https://bugs.python.org/issue?@action=redirect&bpo=18983

   (32) https://bugs.python.org/issue?@action=redirect&bpo=23631

   (33) https://bugs.python.org/issue?@action=redirect&bpo=23568

   (34) https://bugs.python.org/issue?@action=redirect&bpo=2052

   (35) https://bugs.python.org/issue?@action=redirect&bpo=23668

   (36) https://bugs.python.org/issue?@action=redirect&bpo=23138

   (37) https://bugs.python.org/issue?@action=redirect&bpo=23051

   (38) https://bugs.python.org/issue?@action=redirect&bpo=23581

   (39) https://bugs.python.org/issue?@action=redirect&bpo=23566

   (40) https://bugs.python.org/issue?@action=redirect&bpo=22928

   (41) https://bugs.python.org/issue?@action=redirect&bpo=23615

   (42) https://bugs.python.org/issue?@action=redirect&bpo=23605


File: python.info,  Node: Build<86>,  Next: Tests<80>,  Prev: Library<93>,  Up: Python 3 5 0 alpha 3

1.23.107.3 Build
................

   - bpo-23585(1): make patchcheck will ensure the interpreter is built.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23585


File: python.info,  Node: Tests<80>,  Next: Tools/Demos<47>,  Prev: Build<86>,  Up: Python 3 5 0 alpha 3

1.23.107.4 Tests
................

   - bpo-23583(1): Added tests for standard IO streams in IDLE.

   - bpo-22289(2): Prevent test_urllib2net failures due to ftp
     connection timeout.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23583

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22289


File: python.info,  Node: Tools/Demos<47>,  Prev: Tests<80>,  Up: Python 3 5 0 alpha 3

1.23.107.5 Tools/Demos
......................

   - bpo-22826(1): The result of open() in Tools/freeze/bkfile.py is now
     better compatible with regular files (in particular it now supports
     the context management protocol).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22826


File: python.info,  Node: Python 3 5 0 alpha 2,  Next: Python 3 5 0 alpha 1,  Prev: Python 3 5 0 alpha 3,  Up: 変更履歴

1.23.108 Python 3.5.0 alpha 2
-----------------------------

'Release date: 2015-03-09'

* Menu:

* Core and Builtins: Core and Builtins<95>.
* Library: Library<94>.
* Build: Build<87>.
* C API: C API<70>.
* Windows: Windows<72>.


File: python.info,  Node: Core and Builtins<95>,  Next: Library<94>,  Up: Python 3 5 0 alpha 2

1.23.108.1 Core and Builtins
............................

   - bpo-23571(1): PyObject_Call() and PyCFunction_Call() now raise a
     SystemError if a function returns a result and raises an exception.
     The SystemError is chained to the previous exception.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23571


File: python.info,  Node: Library<94>,  Next: Build<87>,  Prev: Core and Builtins<95>,  Up: Python 3 5 0 alpha 2

1.23.108.2 Library
..................

   - bpo-22524(1): New os.scandir() function, part of the PEP 471(2):
     "os.scandir() function - a better and faster directory iterator".
     Patch written by Ben Hoyt.

   - bpo-23103(3): Reduced the memory consumption of IPv4Address and
     IPv6Address.

   - bpo-21793(4): BaseHTTPRequestHandler again logs response code as
     numeric, not as stringified enum.  Patch by Demian Brecht.

   - bpo-23476(5): In the ssl module, enable OpenSSL's
     X509_V_FLAG_TRUSTED_FIRST flag on certificate stores when it is
     available.

   - bpo-23576(6): Avoid stalling in SSL reads when EOF has been reached
     in the SSL layer but the underlying connection hasn't been closed.

   - bpo-23504(7): Added an __all__ to the types module.

   - bpo-23563(8): Optimized utility functions in urllib.parse.

   - bpo-7830(9): Flatten nested functools.partial.

   - bpo-20204(10): Added the __module__ attribute to _tkinter classes.

   - bpo-19980(11): Improved help() for non-recognized strings.
     help('') now shows the help on str.  help('help') now shows the
     help on help().  Original patch by Mark Lawrence.

   - bpo-23521(12): Corrected pure python implementation of timedelta
     division.  Eliminated OverflowError from ‘timedelta * float’ for
     some floats; Corrected rounding in timedelta true division.

   - bpo-21619(13): Popen objects no longer leave a zombie after exit in
     the with statement if the pipe was broken.  Patch by Martin Panter.

   - bpo-22936(14): Make it possible to show local variables in
     tracebacks for both the traceback module and unittest.

   - bpo-15955(15): Add an option to limit the output size in
     bz2.decompress().  Patch by Nikolaus Rath.

   - bpo-6639(16): Module-level turtle functions no longer raise
     TclError after closing the window.

   - bpo-814253(17): Group references and conditional group references
     now work in lookbehind assertions in regular expressions.  (See
     also: bpo-9179(18))

   - bpo-23215(19): Multibyte codecs with custom error handlers that
     ignores errors consumed too much memory and raised SystemError or
     MemoryError.  Original patch by Aleksi Torhamo.

   - bpo-5700(20): io.FileIO() called flush() after closing the file.
     flush() was not called in close() if closefd=False.

   - bpo-23374(21): Fixed pydoc failure with non-ASCII files when stdout
     encoding differs from file system encoding (e.g.  on Mac OS).

   - bpo-23481(22): Remove RC4 from the SSL module's default cipher
     list.

   - bpo-21548(23): Fix pydoc.synopsis() and pydoc.apropos() on modules
     with empty docstrings.

   - bpo-22885(24): Fixed arbitrary code execution vulnerability in the
     dbm.dumb module.  Original patch by Claudiu Popa.

   - bpo-23239(25): ssl.match_hostname() now supports matching of IP
     addresses.

   - bpo-23146(26): Fix mishandling of absolute Windows paths with
     forward slashes in pathlib.

   - bpo-23096(27): Pickle representation of floats with protocol 0 now
     is the same for both Python and C implementations.

   - bpo-19105(28): pprint now more efficiently uses free space at the
     right.

   - bpo-14910(29): Add allow_abbrev parameter to
     argparse.ArgumentParser.  Patch by Jonathan Paugh, Steven Bethard,
     paul j3 and Daniel Eriksson.

   - bpo-21717(30): tarfile.open() now supports 'x' (exclusive creation)
     mode.

   - bpo-23344(31): marshal.dumps() is now 20-25% faster on average.

   - bpo-20416(32): marshal.dumps() with protocols 3 and 4 is now 40-50%
     faster on average.

   - bpo-23421(33): Fixed compression in tarfile CLI. Patch by wdv4758h.

   - bpo-23367(34): Fix possible overflows in the unicodedata module.

   - bpo-23361(35): Fix possible overflow in Windows subprocess creation
     code.

   - logging.handlers.QueueListener now takes a respect_handler_level
     keyword argument which, if set to True, will pass messages to
     handlers taking handler levels into account.

   - bpo-19705(36): turtledemo now has a visual sorting algorithm demo.
     Original patch from Jason Yeo.

   - bpo-23801(37): Fix issue where cgi.FieldStorage did not always
     ignore the entire preamble to a multipart body.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22524

   (2) https://peps.python.org/pep-0471/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23103

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21793

   (5) https://bugs.python.org/issue?@action=redirect&bpo=23476

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23576

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23504

   (8) https://bugs.python.org/issue?@action=redirect&bpo=23563

   (9) https://bugs.python.org/issue?@action=redirect&bpo=7830

   (10) https://bugs.python.org/issue?@action=redirect&bpo=20204

   (11) https://bugs.python.org/issue?@action=redirect&bpo=19980

   (12) https://bugs.python.org/issue?@action=redirect&bpo=23521

   (13) https://bugs.python.org/issue?@action=redirect&bpo=21619

   (14) https://bugs.python.org/issue?@action=redirect&bpo=22936

   (15) https://bugs.python.org/issue?@action=redirect&bpo=15955

   (16) https://bugs.python.org/issue?@action=redirect&bpo=6639

   (17) https://bugs.python.org/issue?@action=redirect&bpo=814253

   (18) https://bugs.python.org/issue?@action=redirect&bpo=9179

   (19) https://bugs.python.org/issue?@action=redirect&bpo=23215

   (20) https://bugs.python.org/issue?@action=redirect&bpo=5700

   (21) https://bugs.python.org/issue?@action=redirect&bpo=23374

   (22) https://bugs.python.org/issue?@action=redirect&bpo=23481

   (23) https://bugs.python.org/issue?@action=redirect&bpo=21548

   (24) https://bugs.python.org/issue?@action=redirect&bpo=22885

   (25) https://bugs.python.org/issue?@action=redirect&bpo=23239

   (26) https://bugs.python.org/issue?@action=redirect&bpo=23146

   (27) https://bugs.python.org/issue?@action=redirect&bpo=23096

   (28) https://bugs.python.org/issue?@action=redirect&bpo=19105

   (29) https://bugs.python.org/issue?@action=redirect&bpo=14910

   (30) https://bugs.python.org/issue?@action=redirect&bpo=21717

   (31) https://bugs.python.org/issue?@action=redirect&bpo=23344

   (32) https://bugs.python.org/issue?@action=redirect&bpo=20416

   (33) https://bugs.python.org/issue?@action=redirect&bpo=23421

   (34) https://bugs.python.org/issue?@action=redirect&bpo=23367

   (35) https://bugs.python.org/issue?@action=redirect&bpo=23361

   (36) https://bugs.python.org/issue?@action=redirect&bpo=19705

   (37) https://bugs.python.org/issue?@action=redirect&bpo=23801


File: python.info,  Node: Build<87>,  Next: C API<70>,  Prev: Library<94>,  Up: Python 3 5 0 alpha 2

1.23.108.3 Build
................

   - bpo-23445(1): pydebug builds now use "gcc -Og" where possible, to
     make the resulting executable faster.

   - bpo-23686(2): Update OS X 10.5 installer build to use OpenSSL
     1.0.2a.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23445

   (2) https://bugs.python.org/issue?@action=redirect&bpo=23686


File: python.info,  Node: C API<70>,  Next: Windows<72>,  Prev: Build<87>,  Up: Python 3 5 0 alpha 2

1.23.108.4 C API
................

   - bpo-20204(1): Deprecation warning is now raised for builtin types
     without the __module__ attribute.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20204


File: python.info,  Node: Windows<72>,  Prev: C API<70>,  Up: Python 3 5 0 alpha 2

1.23.108.5 Windows
..................

   - bpo-23465(1): Implement PEP 486(2) - Make the Python Launcher aware
     of virtual environments.  Patch by Paul Moore.

   - bpo-23437(3): Make user scripts directory versioned on Windows.
     Patch by Paul Moore.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23465

   (2) https://peps.python.org/pep-0486/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=23437


File: python.info,  Node: Python 3 5 0 alpha 1,  Prev: Python 3 5 0 alpha 2,  Up: 変更履歴

1.23.109 Python 3.5.0 alpha 1
-----------------------------

'Release date: 2015-02-08'

* Menu:

* Core and Builtins: Core and Builtins<96>.
* Library: Library<95>.
* IDLE: IDLE<63>.
* Build: Build<88>.
* C API: C API<71>.
* Documentation: Documentation<74>.
* Tests: Tests<81>.
* Tools/Demos: Tools/Demos<48>.
* Windows: Windows<73>.


File: python.info,  Node: Core and Builtins<96>,  Next: Library<95>,  Up: Python 3 5 0 alpha 1

1.23.109.1 Core and Builtins
............................

   - bpo-23285(1): PEP 475 - EINTR handling.

   - bpo-22735(2): Fix many edge cases (including crashes) involving
     custom mro() implementations.

   - bpo-22896(3): Avoid using PyObject_AsCharBuffer(),
     PyObject_AsReadBuffer() and PyObject_AsWriteBuffer().

   - bpo-21295(4): Revert some changes (bpo-16795(5)) to AST line
     numbers and column offsets that constituted a regression.

   - bpo-22986(6): Allow changing an object's __class__ between a
     dynamic type and static type in some cases.

   - bpo-15859(7): PyUnicode_EncodeFSDefault(), PyUnicode_EncodeMBCS()
     and PyUnicode_EncodeCodePage() now raise an exception if the object
     is not a Unicode object.  For PyUnicode_EncodeFSDefault(), it was
     already the case on platforms other than Windows.  Patch written by
     Campbell Barton.

   - bpo-21408(8): The default __ne__() now returns NotImplemented if
     __eq__() returned NotImplemented.  Original patch by Martin Panter.

   - bpo-23321(9): Fixed a crash in str.decode() when error handler
     returned replacement string longer than malformed input data.

   - bpo-22286(10): The "backslashreplace" error handlers now works with
     decoding and translating.

   - bpo-23253(11): Delay-load ShellExecute[AW] in os.startfile for
     reduced startup overhead on Windows.

   - bpo-22038(12): pyatomic.h now uses stdatomic.h or GCC built-in
     functions for atomic memory access if available.  Patch written by
     Vitor de Lima and Gustavo Temple.

   - bpo-20284(13): %-interpolation (aka printf) formatting added for
     bytes and bytearray.

   - bpo-23048(14): Fix jumping out of an infinite while loop in the
     pdb.

   - bpo-20335(15): bytes constructor now raises TypeError when encoding
     or errors is specified with non-string argument.  Based on patch by
     Renaud Blanch.

   - bpo-22834(16): If the current working directory ends up being set
     to a non-existent directory then import will no longer raise
     FileNotFoundError.

   - bpo-22869(17): Move the interpreter startup & shutdown code to a
     new dedicated pylifecycle.c module

   - bpo-22847(18): Improve method cache efficiency.

   - bpo-22335(19): Fix crash when trying to enlarge a bytearray to
     0x7fffffff bytes on a 32-bit platform.

   - bpo-22653(20): Fix an assertion failure in debug mode when doing a
     reentrant dict insertion in debug mode.

   - bpo-22643(21): Fix integer overflow in Unicode case operations
     (upper, lower, title, swapcase, casefold).

   - bpo-17636(22): Circular imports involving relative imports are now
     supported.

   - bpo-22604(23): Fix assertion error in debug mode when dividing a
     complex number by (nan+0j).

   - bpo-21052(24): Do not raise ImportWarning when sys.path_hooks or
     sys.meta_path are set to None.

   - bpo-16518(25): Use 'bytes-like object required' in error messages
     that previously used the far more cryptic "'x' does not support the
     buffer protocol.

   - bpo-22470(26): Fixed integer overflow issues in "backslashreplace",
     "xmlcharrefreplace", and "surrogatepass" error handlers.

   - bpo-22540(27): speed up ‘PyObject_IsInstance’ and
     ‘PyObject_IsSubclass’ in the common case that the second argument
     has metaclass ‘type’.

   - bpo-18711(28): Add a new ‘PyErr_FormatV’ function, similar to
     ‘PyErr_Format’ but accepting a ‘va_list’ argument.

   - bpo-22520(29): Fix overflow checking when generating the repr of a
     unicode object.

   - bpo-22519(30): Fix overflow checking in PyBytes_Repr.

   - bpo-22518(31): Fix integer overflow issues in latin-1 encoding.

   - bpo-16324(32): _charset parameter of MIMEText now also accepts
     email.charset.Charset instances.  Initial patch by Claude Paroz.

   - bpo-1764286(33): Fix inspect.getsource() to support decorated
     functions.  Patch by Claudiu Popa.

   - bpo-18554(34): os.__all__ includes posix functions.

   - bpo-21391(35): Use os.path.abspath in the shutil module.

   - bpo-11471(36): avoid generating a JUMP_FORWARD instruction at the
     end of an if-block if there is no else-clause.  Original patch by
     Eugene Toder.

   - bpo-22215(37): Now ValueError is raised instead of TypeError when
     str or bytes argument contains not permitted null character or
     byte.

   - bpo-22258(38): Fix the internal function set_inheritable() on
     Illumos.  This platform exposes the function ‘ioctl(FIOCLEX)’, but
     calling it fails with errno is ENOTTY: "Inappropriate ioctl for
     device".  set_inheritable() now falls back to the slower ‘fcntl()’
     (‘F_GETFD’ and then ‘F_SETFD’).

   - bpo-21389(39): Displaying the __qualname__ of the underlying
     function in the repr of a bound method.

   - bpo-22206(40): Using pthread, PyThread_create_key() now sets errno
     to ENOMEM and returns -1 (error) on integer overflow.

   - bpo-20184(41): Argument Clinic based signature introspection added
     for 30 of the builtin functions.

   - bpo-22116(42): C functions and methods (of the
     'builtin_function_or_method' type) can now be weakref'ed.  Patch by
     Wei Wu.

   - bpo-22077(43): Improve index error messages for bytearrays, bytes,
     lists, and tuples by adding 'or slices'.  Added ', not <typename>'
     for bytearrays.  Original patch by Claudiu Popa.

   - bpo-20179(44): Apply Argument Clinic to bytes and bytearray.  Patch
     by Tal Einat.

   - bpo-22082(45): Clear interned strings in slotdefs.

   - Upgrade Unicode database to Unicode 7.0.0.

   - bpo-21897(46): Fix a crash with the f_locals attribute with closure
     variables when frame.clear() has been called.

   - bpo-21205(47): Add a new ‘__qualname__’ attribute to generator, the
     qualified name, and use it in the representation of a generator
     (‘repr(gen)’).  The default name of the generator (‘__name__’
     attribute) is now get from the function instead of the code.  Use
     ‘gen.gi_code.co_name’ to get the name of the code.

   - bpo-21669(48): With the aid of heuristics in SyntaxError.__init__,
     the parser now attempts to generate more meaningful (or at least
     more search engine friendly) error messages when "exec" and "print"
     are used as statements.

   - bpo-21642(49): In the conditional if-else expression, allow an
     integer written with no space between itself and the ‘else’ keyword
     (e.g.  ‘True if 42else False’) to be valid syntax.

   - bpo-21523(50): Fix over-pessimistic computation of the stack effect
     of some opcodes in the compiler.  This also fixes a quadratic
     compilation time issue noticeable when compiling code with a large
     number of "and" and "or" operators.

   - bpo-21418(51): Fix a crash in the builtin function super() when
     called without argument and without current frame (ex: embedded
     Python).

   - bpo-21425(52): Fix flushing of standard streams in the interactive
     interpreter.

   - bpo-21435(53): In rare cases, when running finalizers on objects in
     cyclic trash a bad pointer dereference could occur due to a subtle
     flaw in internal iteration logic.

   - bpo-21377(54): PyBytes_Concat() now tries to concatenate in-place
     when the first argument has a reference count of 1.  Patch by
     Nikolaus Rath.

   - bpo-20355(55): -W command line options now have higher priority
     than the PYTHONWARNINGS environment variable.  Patch by Arfrever.

   - bpo-21274(56): Define PATH_MAX for GNU/Hurd in Python/pythonrun.c.

   - bpo-20904(57): Support setting FPU precision on m68k.

   - bpo-21209(58): Fix sending tuples to custom generator objects with
     the yield from syntax.

   - bpo-21193(59): pow(a, b, c) now raises ValueError rather than
     TypeError when b is negative.  Patch by Josh Rosenberg.

   - bpo-21176(60): PEP 465: Add the '@' operator for matrix
     multiplication.

   - bpo-21134(61): Fix segfault when str is called on an uninitialized
     UnicodeEncodeError, UnicodeDecodeError, or UnicodeTranslateError
     object.

   - bpo-19537(62): Fix PyUnicode_DATA() alignment under m68k.  Patch by
     Andreas Schwab.

   - bpo-20929(63): Add a type cast to avoid shifting a negative number.

   - bpo-20731(64): Properly position in source code files even if they
     are opened in text mode.  Patch by Serhiy Storchaka.

   - bpo-20637(65): Key-sharing now also works for instance dictionaries
     of subclasses.  Patch by Peter Ingebretson.

   - bpo-8297(66): Attributes missing from modules now include the
     module name in the error text.  Original patch by ysj.ray.

   - bpo-19995(67): %c, %o, %x, and %X now raise TypeError on
     non-integer input.

   - bpo-19655(68): The ASDL parser - used by the build process to
     generate code for managing the Python AST in C - was rewritten.
     The new parser is self contained and does not require to carry long
     the spark.py parser-generator library; spark.py was removed from
     the source base.

   - bpo-12546(69): Allow ‘\x00’ to be used as a fill character when
     using str, int, float, and complex __format__ methods.

   - bpo-20480(70): Add ipaddress.reverse_pointer.  Patch by Leon Weber.

   - bpo-13598(71): Modify string.Formatter to support auto-numbering of
     replacement fields.  It now matches the behavior of str.format() in
     this regard.  Patches by Phil Elson and Ramchandra Apte.

   - bpo-8931(72): Make alternate formatting ('#') for type 'c' raise an
     exception.  In versions prior to 3.5, '#' with 'c' had no effect.
     Now specifying it is an error.  Patch by Torsten Landschoff.

   - bpo-23165(73): Perform overflow checks before allocating memory in
     the _Py_char2wchar function.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23285

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22735

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22896

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21295

   (5) https://bugs.python.org/issue?@action=redirect&bpo=16795

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22986

   (7) https://bugs.python.org/issue?@action=redirect&bpo=15859

   (8) https://bugs.python.org/issue?@action=redirect&bpo=21408

   (9) https://bugs.python.org/issue?@action=redirect&bpo=23321

   (10) https://bugs.python.org/issue?@action=redirect&bpo=22286

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23253

   (12) https://bugs.python.org/issue?@action=redirect&bpo=22038

   (13) https://bugs.python.org/issue?@action=redirect&bpo=20284

   (14) https://bugs.python.org/issue?@action=redirect&bpo=23048

   (15) https://bugs.python.org/issue?@action=redirect&bpo=20335

   (16) https://bugs.python.org/issue?@action=redirect&bpo=22834

   (17) https://bugs.python.org/issue?@action=redirect&bpo=22869

   (18) https://bugs.python.org/issue?@action=redirect&bpo=22847

   (19) https://bugs.python.org/issue?@action=redirect&bpo=22335

   (20) https://bugs.python.org/issue?@action=redirect&bpo=22653

   (21) https://bugs.python.org/issue?@action=redirect&bpo=22643

   (22) https://bugs.python.org/issue?@action=redirect&bpo=17636

   (23) https://bugs.python.org/issue?@action=redirect&bpo=22604

   (24) https://bugs.python.org/issue?@action=redirect&bpo=21052

   (25) https://bugs.python.org/issue?@action=redirect&bpo=16518

   (26) https://bugs.python.org/issue?@action=redirect&bpo=22470

   (27) https://bugs.python.org/issue?@action=redirect&bpo=22540

   (28) https://bugs.python.org/issue?@action=redirect&bpo=18711

   (29) https://bugs.python.org/issue?@action=redirect&bpo=22520

   (30) https://bugs.python.org/issue?@action=redirect&bpo=22519

   (31) https://bugs.python.org/issue?@action=redirect&bpo=22518

   (32) https://bugs.python.org/issue?@action=redirect&bpo=16324

   (33) https://bugs.python.org/issue?@action=redirect&bpo=1764286

   (34) https://bugs.python.org/issue?@action=redirect&bpo=18554

   (35) https://bugs.python.org/issue?@action=redirect&bpo=21391

   (36) https://bugs.python.org/issue?@action=redirect&bpo=11471

   (37) https://bugs.python.org/issue?@action=redirect&bpo=22215

   (38) https://bugs.python.org/issue?@action=redirect&bpo=22258

   (39) https://bugs.python.org/issue?@action=redirect&bpo=21389

   (40) https://bugs.python.org/issue?@action=redirect&bpo=22206

   (41) https://bugs.python.org/issue?@action=redirect&bpo=20184

   (42) https://bugs.python.org/issue?@action=redirect&bpo=22116

   (43) https://bugs.python.org/issue?@action=redirect&bpo=22077

   (44) https://bugs.python.org/issue?@action=redirect&bpo=20179

   (45) https://bugs.python.org/issue?@action=redirect&bpo=22082

   (46) https://bugs.python.org/issue?@action=redirect&bpo=21897

   (47) https://bugs.python.org/issue?@action=redirect&bpo=21205

   (48) https://bugs.python.org/issue?@action=redirect&bpo=21669

   (49) https://bugs.python.org/issue?@action=redirect&bpo=21642

   (50) https://bugs.python.org/issue?@action=redirect&bpo=21523

   (51) https://bugs.python.org/issue?@action=redirect&bpo=21418

   (52) https://bugs.python.org/issue?@action=redirect&bpo=21425

   (53) https://bugs.python.org/issue?@action=redirect&bpo=21435

   (54) https://bugs.python.org/issue?@action=redirect&bpo=21377

   (55) https://bugs.python.org/issue?@action=redirect&bpo=20355

   (56) https://bugs.python.org/issue?@action=redirect&bpo=21274

   (57) https://bugs.python.org/issue?@action=redirect&bpo=20904

   (58) https://bugs.python.org/issue?@action=redirect&bpo=21209

   (59) https://bugs.python.org/issue?@action=redirect&bpo=21193

   (60) https://bugs.python.org/issue?@action=redirect&bpo=21176

   (61) https://bugs.python.org/issue?@action=redirect&bpo=21134

   (62) https://bugs.python.org/issue?@action=redirect&bpo=19537

   (63) https://bugs.python.org/issue?@action=redirect&bpo=20929

   (64) https://bugs.python.org/issue?@action=redirect&bpo=20731

   (65) https://bugs.python.org/issue?@action=redirect&bpo=20637

   (66) https://bugs.python.org/issue?@action=redirect&bpo=8297

   (67) https://bugs.python.org/issue?@action=redirect&bpo=19995

   (68) https://bugs.python.org/issue?@action=redirect&bpo=19655

   (69) https://bugs.python.org/issue?@action=redirect&bpo=12546

   (70) https://bugs.python.org/issue?@action=redirect&bpo=20480

   (71) https://bugs.python.org/issue?@action=redirect&bpo=13598

   (72) https://bugs.python.org/issue?@action=redirect&bpo=8931

   (73) https://bugs.python.org/issue?@action=redirect&bpo=23165


File: python.info,  Node: Library<95>,  Next: IDLE<63>,  Prev: Core and Builtins<96>,  Up: Python 3 5 0 alpha 1

1.23.109.2 Library
..................

   - bpo-23399(1): pyvenv creates relative symlinks where possible.

   - bpo-20289(2): cgi.FieldStorage() now supports the context
     management protocol.

   - bpo-13128(3): Print response headers for CONNECT requests when
     debuglevel > 0.  Patch by Demian Brecht.

   - bpo-15381(4): Optimized io.BytesIO to make less allocations and
     copyings.

   - bpo-22818(5): Splitting on a pattern that could match an empty
     string now raises a warning.  Patterns that can only match empty
     strings are now rejected.

   - bpo-23099(6): Closing io.BytesIO with exported buffer is rejected
     now to prevent corrupting exported buffer.

   - bpo-23326(7): Removed __ne__ implementations.  Since fixing default
     __ne__ implementation in bpo-21408(8) they are redundant.

   - bpo-23363(9): Fix possible overflow in itertools.permutations.

   - bpo-23364(10): Fix possible overflow in itertools.product.

   - bpo-23366(11): Fixed possible integer overflow in
     itertools.combinations.

   - bpo-23369(12): Fixed possible integer overflow in
     _json.encode_basestring_ascii.

   - bpo-23353(13): Fix the exception handling of generators in
     PyEval_EvalFrameEx().  At entry, save or swap the exception state
     even if PyEval_EvalFrameEx() is called with throwflag=0.  At exit,
     the exception state is now always restored or swapped, not only if
     why is WHY_YIELD or WHY_RETURN. Patch co-written with Antoine
     Pitrou.

   - bpo-14099(14): Restored support of writing ZIP files to tellable
     but non-seekable streams.

   - bpo-14099(15): Writing to ZipFile and reading multiple ZipExtFiles
     is threadsafe now.

   - bpo-19361(16): JSON decoder now raises JSONDecodeError instead of
     ValueError.

   - bpo-18518(17): timeit now rejects statements which can't be
     compiled outside a function or a loop (e.g.  "return" or "break").

   - bpo-23094(18): Fixed readline with frames in Python implementation
     of pickle.

   - bpo-23268(19): Fixed bugs in the comparison of ipaddress classes.

   - bpo-21408(20): Removed incorrect implementations of __ne__() which
     didn't returned NotImplemented if __eq__() returned NotImplemented.
     The default __ne__() now works correctly.

   - bpo-19996(21): ‘email.feedparser.FeedParser’ now handles
     (malformed) headers with no key rather than assuming the body has
     started.

   - bpo-20188(22): Support Application-Layer Protocol Negotiation
     (ALPN) in the ssl module.

   - bpo-23133(23): Pickling of ipaddress objects now produces more
     compact and portable representation.

   - bpo-23248(24): Update ssl error codes from latest OpenSSL git
     master.

   - bpo-23266(25): Much faster implementation of
     ipaddress.collapse_addresses() when there are many non-consecutive
     addresses.

   - bpo-23098(26): 64-bit dev_t is now supported in the os module.

   - bpo-21817(27): When an exception is raised in a task submitted to a
     ProcessPoolExecutor, the remote traceback is now displayed in the
     parent process.  Patch by Claudiu Popa.

   - bpo-15955(28): Add an option to limit output size when
     decompressing LZMA data.  Patch by Nikolaus Rath and Martin Panter.

   - bpo-23250(29): In the http.cookies module, capitalize "HttpOnly"
     and "Secure" as they are written in the standard.

   - bpo-23063(30): In the distutils' check command, fix parsing of reST
     with code or code-block directives.

   - bpo-23209(31): selectors.BaseSelector.get_key() now raises a
     RuntimeError if the selector is closed.  And
     selectors.BaseSelector.close() now clears its internal reference to
     the selector mapping to break a reference cycle.  Initial patch
     written by Martin Richard.  (See also: bpo-23225(32))

   - bpo-17911(33): Provide a way to seed the linecache for a PEP-302
     module without actually loading the code.

   - bpo-17911(34): Provide a new object API for traceback, including
     the ability to not lookup lines at all until the traceback is
     actually rendered, without any trace of the original objects being
     kept alive.

   - bpo-19777(35): Provide a home() classmethod on Path objects.
     Contributed by Victor Salgado and Mayank Tripathi.

   - bpo-23206(36): Make ‘json.dumps(..., ensure_ascii=False)’ as fast
     as the default case of ‘ensure_ascii=True’.  Patch by Naoki Inada.

   - bpo-23185(37): Add math.inf and math.nan constants.

   - bpo-23186(38): Add ssl.SSLObject.shared_ciphers() and
     ssl.SSLSocket.shared_ciphers() to fetch the client's list ciphers
     sent at handshake.

   - bpo-23143(39): Remove compatibility with OpenSSLs older than 0.9.8.

   - bpo-23132(40): Improve performance and introspection support of
     comparison methods created by functool.total_ordering.

   - bpo-19776(41): Add an expanduser() method on Path objects.

   - bpo-23112(42): Fix SimpleHTTPServer to correctly carry the query
     string and fragment when it redirects to add a trailing slash.

   - bpo-21793(43): Added http.HTTPStatus enums (i.e.  HTTPStatus.OK,
     HTTPStatus.NOT_FOUND). Patch by Demian Brecht.

   - bpo-23093(44): In the io, module allow more operations to work on
     detached streams.

   - bpo-23111(45): In the ftplib, make ssl.PROTOCOL_SSLv23 the default
     protocol version.

   - bpo-22585(46): On OpenBSD 5.6 and newer, os.urandom() now calls
     getentropy(), instead of reading /dev/urandom, to get pseudo-random
     bytes.

   - bpo-19104(47): pprint now produces evaluable output for wrapped
     strings.

   - bpo-23071(48): Added missing names to codecs.__all__.  Patch by
     Martin Panter.

   - bpo-22783(49): Pickling now uses the NEWOBJ opcode instead of the
     NEWOBJ_EX opcode if possible.

   - bpo-15513(50): Added a __sizeof__ implementation for pickle
     classes.

   - bpo-19858(51): pickletools.optimize() now aware of the MEMOIZE
     opcode, can produce more compact result and no longer produces
     invalid output if input data contains MEMOIZE opcodes together with
     PUT or BINPUT opcodes.

   - bpo-22095(52): Fixed HTTPConnection.set_tunnel with default port.
     The port value in the host header was set to "None".  Patch by
     Demian Brecht.

   - bpo-23016(53): A warning no longer produces an AttributeError when
     the program is run with pythonw.exe.

   - bpo-21775(54): shutil.copytree(): fix crash when copying to VFAT.
     An exception handler assumed that OSError objects always have a
     'winerror' attribute.  That is not the case, so the exception
     handler itself raised AttributeError when run on Linux (and,
     presumably, any other non-Windows OS). Patch by Greg Ward.

   - bpo-1218234(55): Fix inspect.getsource() to load updated source of
     reloaded module.  Initial patch by Berker Peksag.

   - bpo-21740(56): Support wrapped callables in doctest.  Patch by
     Claudiu Popa.

   - bpo-23009(57): Make sure selectors.EpollSelector.select() works
     when no FD is registered.

   - bpo-22959(58): In the constructor of http.client.HTTPSConnection,
     prefer the context's check_hostname attribute over the
     'check_hostname' parameter.

   - bpo-22696(59): Add function *note sys.is_finalizing(): a5d. to know
     about interpreter shutdown.

   - bpo-16043(60): Add a default limit for the amount of data
     xmlrpclib.gzip_decode will return.  This resolves CVE
     2013-1753(61).

   - bpo-14099(62): ZipFile.open() no longer reopen the underlying file.
     Objects returned by ZipFile.open() can now operate independently of
     the ZipFile even if the ZipFile was created by passing in a
     file-like object as the first argument to the constructor.

   - bpo-22966(63): Fix __pycache__ pyc file name clobber when
     pyc_compile is asked to compile a source file containing multiple
     dots in the source file name.

   - bpo-21971(64): Update turtledemo doc and add module to the index.

   - bpo-21032(65): Fixed socket leak if HTTPConnection.getresponse()
     fails.  Original patch by Martin Panter.

   - bpo-22407(66): Deprecated the use of re.LOCALE flag with str
     patterns or re.ASCII. It was newer worked.

   - bpo-22902(67): The "ip" command is now used on Linux to determine
     MAC address in uuid.getnode().  Pach by Bruno Cauet.

   - bpo-22960(68): Add a context argument to xmlrpclib.ServerProxy
     constructor.

   - bpo-22389(69): Add contextlib.redirect_stderr().

   - bpo-21356(70): Make ssl.RAND_egd() optional to support LibreSSL.
     The availability of the function is checked during the compilation.
     Patch written by Bernard Spil.

   - bpo-22915(71): SAX parser now supports files opened with file
     descriptor or bytes path.

   - bpo-22609(72): Constructors and update methods of mapping classes
     in the collections module now accept the self keyword argument.

   - bpo-22940(73): Add readline.append_history_file.

   - bpo-19676(74): Added the "namereplace" error handler.

   - bpo-22788(75): Add 'context' parameter to
     logging.handlers.HTTPHandler.

   - bpo-22921(76): Allow SSLContext to take the 'hostname' parameter
     even if OpenSSL doesn't support SNI.

   - bpo-22894(77): TestCase.subTest() would cause the test suite to be
     stopped when in failfast mode, even in the absence of failures.

   - bpo-22796(78): HTTP cookie parsing is now stricter, in order to
     protect against potential injection attacks.

   - bpo-22370(79): Windows detection in pathlib is now more robust.

   - bpo-22841(80): Reject coroutines in asyncio add_signal_handler().
     Patch by Ludovic.Gasc.

   - bpo-19494(81): Added urllib.request.HTTPBasicPriorAuthHandler.
     Patch by Matej Cepl.

   - bpo-22578(82): Added attributes to the re.error class.

   - bpo-22849(83): Fix possible double free in the io.TextIOWrapper
     constructor.

   - bpo-12728(84): Different Unicode characters having the same
     uppercase but different lowercase are now matched in
     case-insensitive regular expressions.

   - bpo-22821(85): Fixed fcntl() with integer argument on 64-bit
     big-endian platforms.

   - bpo-21650(86): Add an ‘--sort-keys’ option to ‘json.tool’ CLI.

   - bpo-22824(87): Updated reprlib output format for sets to use set
     literals.  Patch contributed by Berker Peksag.

   - bpo-22824(88): Updated reprlib output format for arrays to display
     empty arrays without an unnecessary empty list.  Suggested by
     Serhiy Storchaka.

   - bpo-22406(89): Fixed the uu_codec codec incorrectly ported to 3.x.
     Based on patch by Martin Panter.

   - bpo-17293(90): uuid.getnode() now determines MAC address on AIX
     using netstat.  Based on patch by Aivars Kalvāns.

   - bpo-22769(91): Fixed ttk.Treeview.tag_has() when called without
     arguments.

   - bpo-22417(92): Verify certificates by default in httplib (PEP 476).

   - bpo-22775(93): Fixed unpickling of http.cookies.SimpleCookie with
     protocol 2 and above.  Patch by Tim Graham.

   - bpo-22776(94): Brought excluded code into the scope of a try block
     in SysLogHandler.emit().

   - bpo-22665(95): Add missing get_terminal_size and SameFileError to
     shutil.__all__.

   - bpo-6623(96): Remove deprecated Netrc class in the ftplib module.
     Patch by Matt Chaput.

   - bpo-17381(97): Fixed handling of case-insensitive ranges in regular
     expressions.

   - bpo-22410(98): Module level functions in the re module now cache
     compiled locale-dependent regular expressions taking into account
     the locale.

   - bpo-22759(99): Query methods on pathlib.Path() (exists(), is_dir(),
     etc.)  now return False when the underlying stat call raises
     NotADirectoryError.

   - bpo-8876(100): distutils now falls back to copying files when hard
     linking doesn't work.  This allows use with special filesystems
     such as VirtualBox shared folders.

   - bpo-22217(101): Implemented reprs of classes in the zipfile module.

   - bpo-22457(102): Honour load_tests in the start_dir of discovery.

   - bpo-18216(103): gettext now raises an error when a .mo file has an
     unsupported major version number.  Patch by Aaron Hill.

   - bpo-13918(104): Provide a locale.delocalize() function which can
     remove locale-specific number formatting from a string representing
     a number, without then converting it to a specific type.  Patch by
     Cédric Krier.

   - bpo-22676(105): Make the pickling of global objects which don't
     have a __module__ attribute less slow.

   - bpo-18853(106): Fixed ResourceWarning in shlex.__nain__.

   - bpo-9351(107): Defaults set with set_defaults on an argparse
     subparser are no longer ignored when also set on the parent parser.

   - bpo-7559(108): unittest test loading ImportErrors are reported as
     import errors with their import exception rather than as attribute
     errors after the import has already failed.

   - bpo-19746(109): Make it possible to examine the errors from
     unittest discovery without executing the test suite.  The new
     ‘errors’ attribute on ‘TestLoader’ exposes these non-fatal errors
     encountered during discovery.

   - bpo-21991(110): Make email.headerregistry's header 'params'
     attributes be read-only (MappingProxyType).  Previously the
     dictionary was modifiable but a new one was created on each access
     of the attribute.

   - bpo-22638(111): SSLv3 is now disabled throughout the standard
     library.  It can still be enabled by instantiating a SSLContext
     manually.

   - bpo-22641(112): In asyncio, the default SSL context for client
     connections is now created using ssl.create_default_context(), for
     stronger security.

   - bpo-17401(113): Include closefd in io.FileIO repr.

   - bpo-21338(114): Add silent mode for compileall.  quiet parameters
     of compile_{dir, file, path} functions now have a multilevel value.
     Also, -q option of the CLI now have a multilevel value.  Patch by
     Thomas Kluyver.

   - bpo-20152(115): Convert the array and cmath modules to Argument
     Clinic.

   - bpo-18643(116): Add socket.socketpair() on Windows.

   - bpo-22435(117): Fix a file descriptor leak when socketserver bind
     fails.

   - bpo-13096(118): Fixed segfault in CTypes POINTER handling of large
     values.

   - bpo-11694(119): Raise ConversionError in xdrlib as documented.
     Patch by Filip Gruszczyński and Claudiu Popa.

   - bpo-19380(120): Optimized parsing of regular expressions.

   - bpo-1519638(121): Now unmatched groups are replaced with empty
     strings in re.sub() and re.subn().

   - bpo-18615(122): sndhdr.what/whathdr now return a namedtuple.

   - bpo-22462(123): Fix pyexpat's creation of a dummy frame to make it
     appear in exception tracebacks.

   - bpo-21965(124): Add support for in-memory SSL to the ssl module.
     Patch by Geert Jansen.

   - bpo-21173(125): Fix len() on a WeakKeyDictionary when .clear() was
     called with an iterator alive.

   - bpo-11866(126): Eliminated race condition in the computation of
     names for new threads.

   - bpo-21905(127): Avoid RuntimeError in pickle.whichmodule() when
     sys.modules is mutated while iterating.  Patch by Olivier Grisel.

   - bpo-11271(128): concurrent.futures.Executor.map() now takes a
     'chunksize' argument to allow batching of tasks in child processes
     and improve performance of ProcessPoolExecutor.  Patch by Dan
     O'Reilly.

   - bpo-21883(129): os.path.join() and os.path.relpath() now raise a
     TypeError with more helpful error message for unsupported or
     mismatched types of arguments.

   - bpo-22219(130): The zipfile module CLI now adds entries for
     directories (including empty directories) in ZIP file.

   - bpo-22449(131): In the ssl.SSLContext.load_default_certs, consult
     the environmental variables SSL_CERT_DIR and SSL_CERT_FILE on
     Windows.

   - bpo-22508(132): The email.__version__ variable has been removed;
     the email code is no longer shipped separately from the stdlib, and
     __version__ hasn't been updated in several releases.

   - bpo-20076(133): Added non derived UTF-8 aliases to locale aliases
     table.

   - bpo-20079(134): Added locales supported in glibc 2.18 to locale
     alias table.

   - bpo-20218(135): Added convenience methods read_text/write_text and
     read_bytes/ write_bytes to pathlib.Path objects.

   - bpo-22396(136): On 32-bit AIX platform, don't expose
     os.posix_fadvise() nor os.posix_fallocate() because their
     prototypes in system headers are wrong.

   - bpo-22517(137): When an io.BufferedRWPair object is deallocated,
     clear its weakrefs.

   - bpo-22437(138): Number of capturing groups in regular expression is
     no longer limited by 100.

   - bpo-17442(139): InteractiveInterpreter now displays the full
     chained traceback in its showtraceback method, to match the built
     in interactive interpreter.

   - bpo-23392(140): Added tests for marshal C API that works with
     FILE*.

   - bpo-10510(141): distutils register and upload methods now use HTML
     standards compliant CRLF line endings.

   - bpo-9850(142): Fixed macpath.join() for empty first component.
     Patch by Oleg Oshmyan.

   - bpo-5309(143): distutils' build and build_ext commands now accept a
     ‘-j’ option to enable parallel building of extension modules.

   - bpo-22448(144): Improve canceled timer handles cleanup to prevent
     unbound memory usage.  Patch by Joshua Moore-Oliva.

   - bpo-22427(145): TemporaryDirectory no longer attempts to clean up
     twice when used in the with statement in generator.

   - bpo-22362(146): Forbidden ambiguous octal escapes out of range
     0-0o377 in regular expressions.

   - bpo-20912(147): Now directories added to ZIP file have correct Unix
     and MS-DOS directory attributes.

   - bpo-21866(148): ZipFile.close() no longer writes ZIP64 central
     directory records if allowZip64 is false.

   - bpo-22278(149): Fix urljoin problem with relative urls, a
     regression observed after changes to issue22118 were submitted.

   - bpo-22415(150): Fixed debugging output of the GROUPREF_EXISTS
     opcode in the re module.  Removed trailing spaces in debugging
     output.

   - bpo-22423(151): Unhandled exception in thread no longer causes
     unhandled AttributeError when sys.stderr is None.

   - bpo-21332(152): Ensure that ‘bufsize=1’ in subprocess.Popen()
     selects line buffering, rather than block buffering.  Patch by
     Akira Li.

   - bpo-21091(153): Fix API bug:
     email.message.EmailMessage.is_attachment is now a method.

   - bpo-21079(154): Fix email.message.EmailMessage.is_attachment to
     return the correct result when the header has parameters as well as
     a value.

   - bpo-22247(155): Add NNTPError to nntplib.__all__.

   - bpo-22366(156): urllib.request.urlopen will accept a context object
     (SSLContext) as an argument which will then be used for HTTPS
     connection.  Patch by Alex Gaynor.

   - bpo-4180(157): The warnings registries are now reset when the
     filters are modified.

   - bpo-22419(158): Limit the length of incoming HTTP request in
     wsgiref server to 65536 bytes and send a 414 error code for higher
     lengths.  Patch contributed by Devin Cook.

   - Lax cookie parsing in http.cookies could be a security issue when
     combined with non-standard cookie handling in some web browsers.
     Reported by Sergey Bobrov.

   - bpo-20537(159): logging methods now accept an exception instance as
     well as a Boolean value or exception tuple.  Thanks to Yury
     Selivanov for the patch.

   - bpo-22384(160): An exception in Tkinter callback no longer crashes
     the program when it is run with pythonw.exe.

   - bpo-22168(161): Prevent turtle AttributeError with non-default
     Canvas on OS X.

   - bpo-21147(162): sqlite3 now raises an exception if the request
     contains a null character instead of truncating it.  Based on patch
     by Victor Stinner.

   - bpo-13968(163): The glob module now supports recursive search in
     subdirectories using the ‘**’ pattern.

   - bpo-21951(164): Fixed a crash in Tkinter on AIX when called Tcl
     command with empty string or tuple argument.

   - bpo-21951(165): Tkinter now most likely raises MemoryError instead
     of crash if the memory allocation fails.

   - bpo-22338(166): Fix a crash in the json module on memory allocation
     failure.

   - bpo-12410(167): imaplib.IMAP4 now supports the context management
     protocol.  Original patch by Tarek Ziadé.

   - bpo-21270(168): We now override tuple methods in mock.call objects
     so that they can be used as normal call attributes.

   - bpo-16662(169): ‘load_tests()’ is now unconditionally run when it
     is present in a package's ‘__init__.py’.
     ‘TestLoader.loadTestsFromModule()’ still accepts use_load_tests,
     but it is deprecated and ignored.  A new keyword-only attribute
     ‘pattern’ is added and documented.  Patch given by Robert Collins,
     tweaked by Barry Warsaw.

   - bpo-22226(170): First letter no longer is stripped from the
     "status" key in the result of Treeview.heading().

   - bpo-19524(171): Fixed resource leak in the HTTP connection when an
     invalid response is received.  Patch by Martin Panter.

   - bpo-20421(172): Add a .version() method to SSL sockets exposing the
     actual protocol version in use.

   - bpo-19546(173): configparser exceptions no longer expose
     implementation details.  Chained KeyErrors are removed, which leads
     to cleaner tracebacks.  Patch by Claudiu Popa.

   - bpo-22051(174): turtledemo no longer reloads examples to re-run
     them.  Initialization of variables and gui setup should be done in
     main(), which is called each time a demo is run, but not on import.

   - bpo-21933(175): Turtledemo users can change the code font size with
     a menu selection or control(command) '-' or '+' or
     control-mousewheel.  Original patch by Lita Cho.

   - bpo-21597(176): The separator between the turtledemo text pane and
     the drawing canvas can now be grabbed and dragged with a mouse.
     The code text pane can be widened to easily view or copy the full
     width of the text.  The canvas can be widened on small screens.
     Original patches by Jan Kanis and Lita Cho.

   - bpo-18132(177): Turtledemo buttons no longer disappear when the
     window is shrunk.  Original patches by Jan Kanis and Lita Cho.

   - bpo-22043(178): time.monotonic() is now always available.
     ‘threading.Lock.acquire()’, ‘threading.RLock.acquire()’ and socket
     operations now use a monotonic clock, instead of the system clock,
     when a timeout is used.

   - bpo-21527(179): Add a default number of workers to
     ThreadPoolExecutor equal to 5 times the number of CPUs.  Patch by
     Claudiu Popa.

   - bpo-22216(180): smtplib now resets its state more completely after
     a quit.  The most obvious consequence of the previous behavior was
     a STARTTLS failure during a connect/starttls/quit/connect/starttls
     sequence.

   - bpo-22098(181): ctypes' BigEndianStructure and
     LittleEndianStructure now define an empty __slots__ so that
     subclasses don't always get an instance dict.  Patch by Claudiu
     Popa.

   - bpo-22185(182): Fix an occasional RuntimeError in
     threading.Condition.wait() caused by mutation of the waiters queue
     without holding the lock.  Patch by Doug Zongker.

   - bpo-22287(183): On UNIX, _PyTime_gettimeofday() now uses
     clock_gettime(CLOCK_REALTIME) if available.  As a side effect,
     Python now depends on the librt library on Solaris and on Linux
     (only with glibc older than 2.17).

   - bpo-22182(184): Use e.args to unpack exceptions correctly in
     distutils.file_util.move_file.  Patch by Claudiu Popa.

   - The webbrowser module now uses subprocess's start_new_session=True
     rather than a potentially risky preexec_fn=os.setsid call.

   - bpo-22042(185): signal.set_wakeup_fd(fd) now raises an exception if
     the file descriptor is in blocking mode.

   - bpo-16808(186): inspect.stack() now returns a named tuple instead
     of a tuple.  Patch by Daniel Shahaf.

   - bpo-22236(187): Fixed Tkinter images copying operations in
     NoDefaultRoot mode.

   - bpo-2527(188): Add a 'globals' argument to timeit functions, in
     order to override the globals namespace in which the timed code is
     executed.  Patch by Ben Roberts.

   - bpo-22118(189): Switch urllib.parse to use RFC 3986 semantics for
     the resolution of relative URLs, rather than RFCs 1808 and 2396.
     Patch by Demian Brecht.

   - bpo-21549(190): Added the "members" parameter to TarFile.list().

   - bpo-19628(191): Allow compileall recursion depth to be specified
     with a -r option.

   - bpo-15696(192): Add a __sizeof__ implementation for mmap objects on
     Windows.

   - bpo-22068(193): Avoided reference loops with Variables and Fonts in
     Tkinter.

   - bpo-22165(194): SimpleHTTPRequestHandler now supports undecodable
     file names.

   - bpo-15381(195): Optimized line reading in io.BytesIO.

   - bpo-8797(196): Raise HTTPError on failed Basic Authentication
     immediately.  Initial patch by Sam Bull.

   - bpo-20729(197): Restored the use of lazy
     iterkeys()/itervalues()/iteritems() in the mailbox module.

   - bpo-21448(198): Changed FeedParser feed() to avoid 'O'('n'^2)
     behavior when parsing long line.  Original patch by Raymond
     Hettinger.

   - bpo-22184(199): The functools LRU Cache decorator factory now gives
     an earlier and clearer error message when the user forgets the
     required parameters.

   - bpo-17923(200): glob() patterns ending with a slash no longer match
     non-dirs on AIX. Based on patch by Delhallt.

   - bpo-21725(201): Added support for RFC 6531 (SMTPUTF8) in smtpd.

   - bpo-22176(202): Update the ctypes module's libffi to v3.1.  This
     release adds support for the Linux AArch64 and POWERPC ELF ABIv2
     little endian architectures.

   - bpo-5411(203): Added support for the "xztar" format in the shutil
     module.

   - bpo-21121(204): Don't force 3rd party C extensions to be built with
     -Werror=declaration-after-statement.

   - bpo-21975(205): Fixed crash when using uninitialized sqlite3.Row
     (in particular when unpickling pickled sqlite3.Row).  sqlite3.Row
     is now initialized in the __new__() method.

   - bpo-20170(206): Convert posixmodule to use Argument Clinic.

   - bpo-21539(207): Add an 'exists_ok' argument to ‘Pathlib.mkdir()’ to
     mimic ‘mkdir -p’ and ‘os.makedirs()’ functionality.  When true,
     ignore ‘FileExistsErrors’.  Patch by Berker Peksag.

   - bpo-22127(208): Bypass IDNA for pure-ASCII host names in the socket
     module (in particular for numeric IPs).

   - bpo-21047(209): set the default value for the 'convert_charrefs'
     argument of HTMLParser to True.  Patch by Berker Peksag.

   - Add an __all__ to html.entities.

   - bpo-15114(210): the strict mode and argument of HTMLParser,
     HTMLParser.error, and the HTMLParserError exception have been
     removed.

   - bpo-22085(211): Dropped support of Tk 8.3 in Tkinter.

   - bpo-21580(212): Now Tkinter correctly handles bytes arguments
     passed to Tk.  In particular this allows initializing images from
     binary data.

   - bpo-22003(213): When initialized from a bytes object, io.BytesIO()
     now defers making a copy until it is mutated, improving performance
     and memory use on some use cases.  Patch by David Wilson.

   - bpo-22018(214): On Windows, signal.set_wakeup_fd() now also
     supports sockets.  A side effect is that Python depends to the
     WinSock library.

   - bpo-22054(215): Add os.get_blocking() and os.set_blocking()
     functions to get and set the blocking mode of a file descriptor
     (False if the O_NONBLOCK flag is set, True otherwise).  These
     functions are not available on Windows.

   - bpo-17172(216): Make turtledemo start as active on OS X even when
     run with subprocess.  Patch by Lita Cho.

   - bpo-21704(217): Fix build error for _multiprocessing when
     semaphores are not available.  Patch by Arfrever Frehtes Taifersar
     Arahesis.

   - bpo-20173(218): Convert sha1, sha256, sha512 and md5 to
     ArgumentClinic.  Patch by Vajrasky Kok.

   - Fix repr(_socket.socket) on Windows 64-bit: don't fail with
     OverflowError on closed socket.  repr(socket.socket) already works
     fine.

   - bpo-22033(219): Reprs of most Python implemented classes now
     contain actual class name instead of hardcoded one.

   - bpo-21947(220): The dis module can now disassemble
     generator-iterator objects based on their gi_code attribute.  Patch
     by Clement Rouault.

   - bpo-16133(221): The asynchat.async_chat.handle_read() method now
     ignores BlockingIOError exceptions.

   - bpo-22044(222): Fixed premature DECREF in call_tzinfo_method.
     Patch by Tom Flanagan.

   - bpo-19884(223): readline: Disable the meta modifier key if stdout
     is not a terminal to not write the ANSI sequence ‘"\033[1034h"’
     into stdout.  This sequence is used on some terminal (ex:
     TERM=xterm-256color") to enable support of 8 bit characters.

   - bpo-4350(224): Removed a number of out-of-dated and non-working for
     a long time Tkinter methods.

   - bpo-6167(225): Scrollbar.activate() now returns the name of active
     element if the argument is not specified.  Scrollbar.set() now
     always accepts only 2 arguments.

   - bpo-15275(226): Clean up and speed up the ntpath module.

   - bpo-21888(227): plistlib's load() and loads() now work if the fmt
     parameter is specified.

   - bpo-22032(228): __qualname__ instead of __name__ is now always used
     to format fully qualified class names of Python implemented
     classes.

   - bpo-22031(229): Reprs now always use hexadecimal format with the
     "0x" prefix when contain an id in form " at 0x...".

   - bpo-22018(230): signal.set_wakeup_fd() now raises an OSError
     instead of a ValueError on ‘fstat()’ failure.

   - bpo-21044(231): tarfile.open() now handles fileobj with an integer
     'name' attribute.  Based on patch by Antoine Pietri.

   - bpo-21966(232): Respect -q command-line option when code module is
     ran.

   - bpo-19076(233): Don't pass the redundant 'file' argument to
     self.error().

   - bpo-16382(234): Improve exception message of warnings.warn() for
     bad category.  Initial patch by Phil Elson.

   - bpo-21932(235): os.read() now uses a *note Py_ssize_t(): a2e. type
     instead of int for the size to support reading more than 2 GB at
     once.  On Windows, the size is truncated to INT_MAX. As any call to
     os.read(), the OS may read less bytes than the number of requested
     bytes.

   - bpo-21942(236): Fixed source file viewing in pydoc's server mode on
     Windows.

   - bpo-11259(237): asynchat.async_chat().set_terminator() now raises a
     ValueError if the number of received bytes is negative.

   - bpo-12523(238): asynchat.async_chat.push() now raises a TypeError
     if it doesn't get a bytes string

   - bpo-21707(239): Add missing kwonlyargcount argument to
     ModuleFinder.replace_paths_in_code().

   - bpo-20639(240): calling Path.with_suffix('') allows removing the
     suffix again.  Patch by July Tikhonov.

   - bpo-21714(241): Disallow the construction of invalid paths using
     Path.with_name().  Original patch by Antony Lee.

   - bpo-15014(242): Added 'auth' method to smtplib to make implementing
     auth mechanisms simpler, and used it internally in the login
     method.

   - bpo-21151(243): Fixed a segfault in the winreg module when ‘None’
     is passed as a ‘REG_BINARY’ value to SetValueEx.  Patch by John
     Ehresman.

   - bpo-21090(244): io.FileIO.readall() does not ignore I/O errors
     anymore.  Before, it ignored I/O errors if at least the first C
     call read() succeed.

   - bpo-5800(245): headers parameter of wsgiref.headers.Headers is now
     optional.  Initial patch by Pablo Torres Navarrete and SilentGhost.

   - bpo-21781(246): ssl.RAND_add() now supports strings longer than 2
     GB.

   - bpo-21679(247): Prevent extraneous fstat() calls during open().
     Patch by Bohuslav Kabrda.

   - bpo-21863(248): cProfile now displays the module name of C
     extension functions, in addition to their own name.

   - bpo-11453(249): asyncore: emit a ResourceWarning when an unclosed
     file_wrapper object is destroyed.  The destructor now closes the
     file if needed.  The close() method can now be called twice: the
     second call does nothing.

   - bpo-21858(250): Better handling of Python exceptions in the sqlite3
     module.

   - bpo-21476(251): Make sure the email.parser.BytesParser
     TextIOWrapper is discarded after parsing, so the input file isn't
     unexpectedly closed.

   - bpo-20295(252): imghdr now recognizes OpenEXR format images.

   - bpo-21729(253): Used the "with" statement in the dbm.dumb module to
     ensure files closing.  Patch by Claudiu Popa.

   - bpo-21491(254): socketserver: Fix a race condition in child
     processes reaping.

   - bpo-21719(255): Added the ‘st_file_attributes’ field to
     os.stat_result on Windows.

   - bpo-21832(256): Require named tuple inputs to be exact strings.

   - bpo-21722(257): The distutils "upload" command now exits with a
     non-zero return code when uploading fails.  Patch by Martin
     Dengler.

   - bpo-21723(258): asyncio.Queue: support any type of number (ex:
     float) for the maximum size.  Patch written by Vajrasky Kok.

   - bpo-21711(259): support for "site-python" directories has now been
     removed from the site module (it was deprecated in 3.4).

   - bpo-17552(260): new socket.sendfile() method allowing a file to be
     sent over a socket by using high-performance os.sendfile() on UNIX.
     Patch by Giampaolo Rodola'.

   - bpo-18039(261): dbm.dump.open() now always creates a new database
     when the flag has the value 'n'.  Patch by Claudiu Popa.

   - bpo-21326(262): Add a new is_closed() method to
     asyncio.BaseEventLoop.  run_forever() and run_until_complete()
     methods of asyncio.BaseEventLoop now raise an exception if the
     event loop was closed.

   - bpo-21766(263): Prevent a security hole in CGIHTTPServer by URL
     unquoting paths before checking for a CGI script at that path.

   - bpo-21310(264): Fixed possible resource leak in failed open().

   - bpo-21256(265): Printout of keyword args should be in deterministic
     order in a mock function call.  This will help to write better
     doctests.

   - bpo-21677(266): Fixed chaining nonnormalized exceptions in io
     close() methods.

   - bpo-11709(267): Fix the pydoc.help function to not fail when
     sys.stdin is not a valid file.

   - bpo-21515(268): tempfile.TemporaryFile now uses os.O_TMPFILE flag
     is available.

   - bpo-13223(269): Fix pydoc.writedoc so that the HTML documentation
     for methods that use 'self' in the example code is generated
     correctly.

   - bpo-21463(270): In urllib.request, fix pruning of the FTP cache.

   - bpo-21618(271): The subprocess module could fail to close open fds
     that were inherited by the calling process and already higher than
     POSIX resource limits would otherwise allow.  On systems with a
     functioning /proc/self/fd or /dev/fd interface the max is now
     ignored and all fds are closed.

   - bpo-20383(272): Introduce importlib.util.module_from_spec() as the
     preferred way to create a new module.

   - bpo-21552(273): Fixed possible integer overflow of too long string
     lengths in the tkinter module on 64-bit platforms.

   - bpo-14315(274): The zipfile module now ignores extra fields in the
     central directory that are too short to be parsed instead of
     letting a struct.unpack error bubble up as this "bad data" appears
     in many real world zip files in the wild and is ignored by other
     zip tools.

   - bpo-13742(275): Added "key" and "reverse" parameters to
     heapq.merge().  (First draft of patch contributed by Simon Sapin.)

   - bpo-21402(276): tkinter.ttk now works when default root window is
     not set.

   - bpo-3015(277): ‘_tkinter.create()’ now creates ‘tkapp’ object with
     ‘wantobjects=1’ by default.

   - bpo-10203(278): sqlite3.Row now truly supports sequence protocol.
     In particular it supports reverse() and negative indices.  Original
     patch by Claudiu Popa.

   - bpo-18807(279): If copying (no symlinks) specified for a venv, then
     the python interpreter aliases (python, python3) are now created by
     copying rather than symlinking.

   - bpo-20197(280): Added support for the WebP image type in the imghdr
     module.  Patch by Fabrice Aneche and Claudiu Popa.

   - bpo-21513(281): Speedup some properties of IP addresses
     (IPv4Address, IPv6Address) such as .is_private or .is_multicast.

   - bpo-21137(282): Improve the repr for threading.Lock() and its
     variants by showing the "locked" or "unlocked" status.  Patch by
     Berker Peksag.

   - bpo-21538(283): The plistlib module now supports loading of binary
     plist files when reference or offset size is not a power of two.

   - bpo-21455(284): Add a default backlog to socket.listen().

   - bpo-21525(285): Most Tkinter methods which accepted tuples now
     accept lists too.

   - bpo-22166(286): With the assistance of a new internal
     _codecs._forget_codec helping function, test_codecs now clears the
     encoding caches to avoid the appearance of a reference leak

   - bpo-22236(287): Tkinter tests now don't reuse default root window.
     New root window is created for every test class.

   - bpo-10744(288): Fix PEP 3118(289) format strings on ctypes objects
     with a nontrivial shape.

   - bpo-20826(290): Optimize ipaddress.collapse_addresses().

   - bpo-21487(291): Optimize ipaddress.summarize_address_range() and
     ipaddress.{IPv4Network,IPv6Network}.subnets().

   - bpo-21486(292): Optimize parsing of netmasks in
     ipaddress.IPv4Network and ipaddress.IPv6Network.

   - bpo-13916(293): Disallowed the surrogatepass error handler for non
     UTF-* encodings.

   - bpo-20998(294): Fixed re.fullmatch() of repeated single character
     pattern with ignore case.  Original patch by Matthew Barnett.

   - bpo-21075(295): fileinput.FileInput now reads bytes from standard
     stream if binary mode is specified.  Patch by Sam Kimbrel.

   - bpo-19775(296): Add a samefile() method to pathlib Path objects.
     Initial patch by Vajrasky Kok.

   - bpo-21226(297): Set up modules properly in
     PyImport_ExecCodeModuleObject (and friends).

   - bpo-21398(298): Fix a unicode error in the pydoc pager when the
     documentation contains characters not encodable to the stdout
     encoding.

   - bpo-16531(299): ipaddress.IPv4Network and ipaddress.IPv6Network now
     accept an (address, netmask) tuple argument, so as to easily
     construct network objects from existing addresses.

   - bpo-21156(300): importlib.abc.InspectLoader.source_to_code() is now
     a staticmethod.

   - bpo-21424(301): Simplified and optimized heaqp.nlargest() and
     nmsmallest() to make fewer tuple comparisons.

   - bpo-21396(302): Fix TextIOWrapper(..., write_through=True) to not
     force a flush() on the underlying binary stream.  Patch by akira.

   - bpo-18314(303): Unlink now removes junctions on Windows.  Patch by
     Kim Gräsman

   - bpo-21088(304): Bugfix for curses.window.addch() regression in
     3.4.0.  In porting to Argument Clinic, the first two arguments were
     reversed.

   - bpo-21407(305): _decimal: The module now supports function
     signatures.

   - bpo-10650(306): Remove the non-standard 'watchexp' parameter from
     the Decimal.quantize() method in the Python version.  It had never
     been present in the C version.

   - bpo-21469(307): Reduced the risk of false positives in robotparser
     by checking to make sure that robots.txt has been read or does not
     exist prior to returning True in can_fetch().

   - bpo-19414(308): Have the OrderedDict mark deleted links as
     unusable.  This gives an early failure if the link is deleted
     during iteration.

   - bpo-21421(309): Add __slots__ to the MappingViews ABC. Patch by
     Josh Rosenberg.

   - bpo-21101(310): Eliminate double hashing in the C speed-up code for
     collections.Counter().

   - bpo-21321(311): itertools.islice() now releases the reference to
     the source iterator when the slice is exhausted.  Patch by Anton
     Afanasyev.

   - bpo-21057(312): TextIOWrapper now allows the underlying binary
     stream's read() or read1() method to return an arbitrary bytes-like
     object (such as a memoryview).  Patch by Nikolaus Rath.

   - bpo-20951(313): SSLSocket.send() now raises either SSLWantReadError
     or SSLWantWriteError on a non-blocking socket if the operation
     would block.  Previously, it would return 0.  Patch by Nikolaus
     Rath.

   - bpo-13248(314): removed previously deprecated asyncore.dispatcher
     __getattr__ cheap inheritance hack.

   - bpo-9815(315): assertRaises now tries to clear references to local
     variables in the exception's traceback.

   - bpo-19940(316): ssl.cert_time_to_seconds() now interprets the given
     time string in the UTC timezone (as specified in RFC 5280), not the
     local timezone.

   - bpo-13204(317): Calling sys.flags.__new__ would crash the
     interpreter, now it raises a TypeError.

   - bpo-19385(318): Make operations on a closed dbm.dumb database
     always raise the same exception.

   - bpo-21207(319): Detect when the os.urandom cached fd has been
     closed or replaced, and open it anew.

   - bpo-21291(320): subprocess's Popen.wait() is now thread safe so
     that multiple threads may be calling wait() or poll() on a Popen
     instance at the same time without losing the Popen.returncode
     value.

   - bpo-21127(321): Path objects can now be instantiated from str
     subclass instances (such as ‘numpy.str_’).

   - bpo-15002(322): urllib.response object to use _TemporaryFileWrapper
     (and _TemporaryFileCloser) facility.  Provides a better way to
     handle file descriptor close.  Patch contributed by Christian
     Theune.

   - bpo-12220(323): mindom now raises a custom ValueError indicating it
     doesn't support spaces in URIs instead of letting a 'split'
     ValueError bubble up.

   - bpo-21068(324): The ssl.PROTOCOL* constants are now enum members.

   - bpo-21276(325): posixmodule: Don't define USE_XATTRS on KFreeBSD
     and the Hurd.

   - bpo-21262(326): New method assert_not_called for Mock.  It raises
     AssertionError if the mock has been called.

   - bpo-21238(327): New keyword argument ‘unsafe’ to Mock.  It raises
     ‘AttributeError’ incase of an attribute startswith assert or
     assret.

   - bpo-20896(328): ssl.get_server_certificate() now uses
     PROTOCOL_SSLv23, not PROTOCOL_SSLv3, for maximum compatibility.

   - bpo-21239(329): patch.stopall() didn't work deterministically when
     the same name was patched more than once.

   - bpo-21203(330): Updated fileConfig and dictConfig to remove
     inconsistencies.  Thanks to Jure Koren for the patch.

   - bpo-21222(331): Passing name keyword argument to
     mock.create_autospec now works.

   - bpo-21197(332): Add lib64 -> lib symlink in venvs on 64-bit non-OS
     X POSIX.

   - bpo-17498(333): Some SMTP servers disconnect after certain errors,
     violating strict RFC conformance.  Instead of losing the error code
     when we issue the subsequent RSET, smtplib now returns the error
     code and defers raising the SMTPServerDisconnected error until the
     next command is issued.

   - bpo-17826(334): setting an iterable side_effect on a mock function
     created by create_autospec now works.  Patch by Kushal Das.

   - bpo-7776(335): Fix ‘Host:’ header and reconnection when using
     http.client.HTTPConnection.set_tunnel().  Patch by Nikolaus Rath.

   - bpo-20968(336): unittest.mock.MagicMock now supports division.
     Patch by Johannes Baiter.

   - bpo-21529(337): Fix arbitrary memory access in
     JSONDecoder.raw_decode with a negative second parameter.  Bug
     reported by Guido Vranken.  (See also: CVE 2014-4616(338))

   - bpo-21169(339): getpass now handles non-ascii characters that the
     input stream encoding cannot encode by re-encoding using the
     replace error handler.

   - bpo-21171(340): Fixed undocumented filter API of the rot13 codec.
     Patch by Berker Peksag.

   - bpo-20539(341): Improved math.factorial error message for large
     positive inputs and changed exception type (OverflowError ->
     ValueError) for large negative inputs.

   - bpo-21172(342): isinstance check relaxed from dict to
     collections.Mapping.

   - bpo-21155(343): asyncio.EventLoop.create_unix_server() now raises a
     ValueError if path and sock are specified at the same time.

   - bpo-21136(344): Avoid unnecessary normalization of Fractions
     resulting from power and other operations.  Patch by Raymond
     Hettinger.

   - bpo-17621(345): Introduce importlib.util.LazyLoader.

   - bpo-21076(346): signal module constants were turned into enums.
     Patch by Giampaolo Rodola'.

   - bpo-20636(347): Improved the repr of Tkinter widgets.

   - bpo-19505(348): The items, keys, and values views of OrderedDict
     now support reverse iteration using reversed().

   - bpo-21149(349): Improved thread-safety in logging cleanup during
     interpreter shutdown.  Thanks to Devin Jeanpierre for the patch.

   - bpo-21058(350): Fix a leak of file descriptor in *note
     tempfile.NamedTemporaryFile(): 492, close the file descriptor if
     *note io.open(): 4e6. fails

   - bpo-21200(351): Return None from pkgutil.get_loader() when __spec__
     is missing.

   - bpo-21013(352): Enhance ssl.create_default_context() when used for
     server side sockets to provide better security by default.

   - bpo-20145(353): ‘assertRaisesRegex’ and ‘assertWarnsRegex’ now
     raise a ‘TypeError’ if the second argument is not a string or
     compiled regex.

   - bpo-20633(354): Replace relative import by absolute import.

   - bpo-20980(355): Stop wrapping exception when using ThreadPool.

   - bpo-21082(356): In os.makedirs, do not set the process-wide umask.
     Note this changes behavior of makedirs when exist_ok=True.

   - bpo-20990(357): Fix issues found by pyflakes for multiprocessing.

   - bpo-21015(358): SSL contexts will now automatically select an
     elliptic curve for ECDH key exchange on OpenSSL 1.0.2 and later,
     and otherwise default to "prime256v1".

   - bpo-21000(359): Improve the command-line interface of json.tool.

   - bpo-20995(360): Enhance default ciphers used by the ssl module to
     enable better security and prioritize perfect forward secrecy.

   - bpo-20884(361): Don't assume that __file__ is defined on
     importlib.__init__.

   - bpo-21499(362): Ignore __builtins__ in several
     test_importlib.test_api tests.

   - bpo-20627(363): xmlrpc.client.ServerProxy is now a context manager.

   - bpo-19165(364): The formatter module now raises DeprecationWarning
     instead of PendingDeprecationWarning.

   - bpo-13936(365): Remove the ability of datetime.time instances to be
     considered false in boolean contexts.

   - bpo-18931(366): selectors module now supports /dev/poll on Solaris.
     Patch by Giampaolo Rodola'.

   - bpo-19977(367): When the ‘LC_TYPE’ locale is the POSIX locale (‘C’
     locale), *note sys.stdin: 507. and *note sys.stdout: aa4. are now
     using the ‘surrogateescape’ error handler, instead of the ‘strict’
     error handler.

   - bpo-20574(368): Implement incremental decoder for cp65001 code
     (Windows code page 65001, Microsoft UTF-8).

   - bpo-20879(369): Delay the initialization of encoding and decoding
     tables for base32, ascii85 and base85 codecs in the base64 module,
     and delay the initialization of the unquote_to_bytes() table of the
     urllib.parse module, to not waste memory if these modules are not
     used.

   - bpo-19157(370): Include the broadcast address in the usuable hosts
     for IPv6 in ipaddress.

   - bpo-11599(371): When an external command (e.g.  compiler) fails,
     distutils now prints out the whole command line (instead of just
     the command name) if the environment variable DISTUTILS_DEBUG is
     set.

   - bpo-4931(372): distutils should not produce unhelpful "error: None"
     messages anymore.  distutils.util.grok_environment_error is kept
     but doc-deprecated.

   - bpo-20875(373): Prevent possible gzip "'read' is not defined"
     NameError.  Patch by Claudiu Popa.

   - bpo-11558(374): ‘email.message.Message.attach’ now returns a more
     useful error message if ‘attach’ is called on a message for which
     ‘is_multipart’ is False.

   - bpo-20283(375): RE pattern methods now accept the string keyword
     parameters as documented.  The pattern and source keyword
     parameters are left as deprecated aliases.

   - bpo-20778(376): Fix modulefinder to work with bytecode-only
     modules.

   - bpo-20791(377): copy.copy() now doesn't make a copy when the input
     is a bytes object.  Initial patch by Peter Otten.

   - bpo-19748(378): On AIX, time.mktime() now raises an OverflowError
     for year outsize range [1902; 2037].

   - bpo-19573(379): inspect.signature: Use enum for parameter kind
     constants.

   - bpo-20726(380): inspect.signature: Make Signature and Parameter
     picklable.

   - bpo-17373(381): Add inspect.Signature.from_callable method.

   - bpo-20378(382): Improve repr of inspect.Signature and
     inspect.Parameter.

   - bpo-20816(383): Fix inspect.getcallargs() to raise correct
     TypeError for missing keyword-only arguments.  Patch by Jeremiah
     Lowin.

   - bpo-20817(384): Fix inspect.getcallargs() to fail correctly if more
     than 3 arguments are missing.  Patch by Jeremiah Lowin.

   - bpo-6676(385): Ensure a meaningful exception is raised when
     attempting to parse more than one XML document per pyexpat
     xmlparser instance.  (Original patches by Hirokazu Yamamoto and
     Amaury Forgeot d'Arc, with suggested wording by David Gutteridge)

   - bpo-21117(386): Fix inspect.signature to better support
     functools.partial.  Due to the specifics of functools.partial
     implementation, positional-or-keyword arguments passed as keyword
     arguments become keyword-only.

   - bpo-20334(387): inspect.Signature and inspect.Parameter are now
     hashable.  Thanks to Antony Lee for bug reports and suggestions.

   - bpo-15916(388): doctest.DocTestSuite returns an empty
     unittest.TestSuite instead of raising ValueError if it finds no
     tests

   - bpo-21209(389): Fix asyncio.tasks.CoroWrapper to workaround a bug
     in yield-from implementation in CPythons prior to 3.4.1.

   - asyncio: Add gi_{frame,running,code} properties to CoroWrapper
     (upstream bpo-163(390)).

   - bpo-21311(391): Avoid exception in _osx_support with non-standard
     compiler configurations.  Patch by John Szakmeister.

   - bpo-11571(392): Ensure that the turtle window becomes the topmost
     window when launched on OS X.

   - bpo-21801(393): Validate that __signature__ is None or an instance
     of Signature.

   - bpo-21923(394): Prevent AttributeError in
     distutils.sysconfig.customize_compiler due to possible
     uninitialized _config_vars.

   - bpo-21323(395): Fix http.server to again handle scripts in CGI
     subdirectories, broken by the fix for security bpo-19435(396).
     Patch by Zach Byrne.

   - bpo-22733(397): Fix ffi_prep_args not zero-extending argument
     values correctly on 64-bit Windows.

   - bpo-23302(398): Default to TCP_NODELAY=1 upon establishing an
     HTTPConnection.  Removed use of hard-coded MSS as it's an
     optimization that's no longer needed with Nagle disabled.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23399

   (2) https://bugs.python.org/issue?@action=redirect&bpo=20289

   (3) https://bugs.python.org/issue?@action=redirect&bpo=13128

   (4) https://bugs.python.org/issue?@action=redirect&bpo=15381

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22818

   (6) https://bugs.python.org/issue?@action=redirect&bpo=23099

   (7) https://bugs.python.org/issue?@action=redirect&bpo=23326

   (8) https://bugs.python.org/issue?@action=redirect&bpo=21408

   (9) https://bugs.python.org/issue?@action=redirect&bpo=23363

   (10) https://bugs.python.org/issue?@action=redirect&bpo=23364

   (11) https://bugs.python.org/issue?@action=redirect&bpo=23366

   (12) https://bugs.python.org/issue?@action=redirect&bpo=23369

   (13) https://bugs.python.org/issue?@action=redirect&bpo=23353

   (14) https://bugs.python.org/issue?@action=redirect&bpo=14099

   (15) https://bugs.python.org/issue?@action=redirect&bpo=14099

   (16) https://bugs.python.org/issue?@action=redirect&bpo=19361

   (17) https://bugs.python.org/issue?@action=redirect&bpo=18518

   (18) https://bugs.python.org/issue?@action=redirect&bpo=23094

   (19) https://bugs.python.org/issue?@action=redirect&bpo=23268

   (20) https://bugs.python.org/issue?@action=redirect&bpo=21408

   (21) https://bugs.python.org/issue?@action=redirect&bpo=19996

   (22) https://bugs.python.org/issue?@action=redirect&bpo=20188

   (23) https://bugs.python.org/issue?@action=redirect&bpo=23133

   (24) https://bugs.python.org/issue?@action=redirect&bpo=23248

   (25) https://bugs.python.org/issue?@action=redirect&bpo=23266

   (26) https://bugs.python.org/issue?@action=redirect&bpo=23098

   (27) https://bugs.python.org/issue?@action=redirect&bpo=21817

   (28) https://bugs.python.org/issue?@action=redirect&bpo=15955

   (29) https://bugs.python.org/issue?@action=redirect&bpo=23250

   (30) https://bugs.python.org/issue?@action=redirect&bpo=23063

   (31) https://bugs.python.org/issue?@action=redirect&bpo=23209

   (32) https://bugs.python.org/issue?@action=redirect&bpo=23225

   (33) https://bugs.python.org/issue?@action=redirect&bpo=17911

   (34) https://bugs.python.org/issue?@action=redirect&bpo=17911

   (35) https://bugs.python.org/issue?@action=redirect&bpo=19777

   (36) https://bugs.python.org/issue?@action=redirect&bpo=23206

   (37) https://bugs.python.org/issue?@action=redirect&bpo=23185

   (38) https://bugs.python.org/issue?@action=redirect&bpo=23186

   (39) https://bugs.python.org/issue?@action=redirect&bpo=23143

   (40) https://bugs.python.org/issue?@action=redirect&bpo=23132

   (41) https://bugs.python.org/issue?@action=redirect&bpo=19776

   (42) https://bugs.python.org/issue?@action=redirect&bpo=23112

   (43) https://bugs.python.org/issue?@action=redirect&bpo=21793

   (44) https://bugs.python.org/issue?@action=redirect&bpo=23093

   (45) https://bugs.python.org/issue?@action=redirect&bpo=23111

   (46) https://bugs.python.org/issue?@action=redirect&bpo=22585

   (47) https://bugs.python.org/issue?@action=redirect&bpo=19104

   (48) https://bugs.python.org/issue?@action=redirect&bpo=23071

   (49) https://bugs.python.org/issue?@action=redirect&bpo=22783

   (50) https://bugs.python.org/issue?@action=redirect&bpo=15513

   (51) https://bugs.python.org/issue?@action=redirect&bpo=19858

   (52) https://bugs.python.org/issue?@action=redirect&bpo=22095

   (53) https://bugs.python.org/issue?@action=redirect&bpo=23016

   (54) https://bugs.python.org/issue?@action=redirect&bpo=21775

   (55) https://bugs.python.org/issue?@action=redirect&bpo=1218234

   (56) https://bugs.python.org/issue?@action=redirect&bpo=21740

   (57) https://bugs.python.org/issue?@action=redirect&bpo=23009

   (58) https://bugs.python.org/issue?@action=redirect&bpo=22959

   (59) https://bugs.python.org/issue?@action=redirect&bpo=22696

   (60) https://bugs.python.org/issue?@action=redirect&bpo=16043

   (61) https://www.cve.org/CVERecord?id=CVE-2013-1753

   (62) https://bugs.python.org/issue?@action=redirect&bpo=14099

   (63) https://bugs.python.org/issue?@action=redirect&bpo=22966

   (64) https://bugs.python.org/issue?@action=redirect&bpo=21971

   (65) https://bugs.python.org/issue?@action=redirect&bpo=21032

   (66) https://bugs.python.org/issue?@action=redirect&bpo=22407

   (67) https://bugs.python.org/issue?@action=redirect&bpo=22902

   (68) https://bugs.python.org/issue?@action=redirect&bpo=22960

   (69) https://bugs.python.org/issue?@action=redirect&bpo=22389

   (70) https://bugs.python.org/issue?@action=redirect&bpo=21356

   (71) https://bugs.python.org/issue?@action=redirect&bpo=22915

   (72) https://bugs.python.org/issue?@action=redirect&bpo=22609

   (73) https://bugs.python.org/issue?@action=redirect&bpo=22940

   (74) https://bugs.python.org/issue?@action=redirect&bpo=19676

   (75) https://bugs.python.org/issue?@action=redirect&bpo=22788

   (76) https://bugs.python.org/issue?@action=redirect&bpo=22921

   (77) https://bugs.python.org/issue?@action=redirect&bpo=22894

   (78) https://bugs.python.org/issue?@action=redirect&bpo=22796

   (79) https://bugs.python.org/issue?@action=redirect&bpo=22370

   (80) https://bugs.python.org/issue?@action=redirect&bpo=22841

   (81) https://bugs.python.org/issue?@action=redirect&bpo=19494

   (82) https://bugs.python.org/issue?@action=redirect&bpo=22578

   (83) https://bugs.python.org/issue?@action=redirect&bpo=22849

   (84) https://bugs.python.org/issue?@action=redirect&bpo=12728

   (85) https://bugs.python.org/issue?@action=redirect&bpo=22821

   (86) https://bugs.python.org/issue?@action=redirect&bpo=21650

   (87) https://bugs.python.org/issue?@action=redirect&bpo=22824

   (88) https://bugs.python.org/issue?@action=redirect&bpo=22824

   (89) https://bugs.python.org/issue?@action=redirect&bpo=22406

   (90) https://bugs.python.org/issue?@action=redirect&bpo=17293

   (91) https://bugs.python.org/issue?@action=redirect&bpo=22769

   (92) https://bugs.python.org/issue?@action=redirect&bpo=22417

   (93) https://bugs.python.org/issue?@action=redirect&bpo=22775

   (94) https://bugs.python.org/issue?@action=redirect&bpo=22776

   (95) https://bugs.python.org/issue?@action=redirect&bpo=22665

   (96) https://bugs.python.org/issue?@action=redirect&bpo=6623

   (97) https://bugs.python.org/issue?@action=redirect&bpo=17381

   (98) https://bugs.python.org/issue?@action=redirect&bpo=22410

   (99) https://bugs.python.org/issue?@action=redirect&bpo=22759

   (100) https://bugs.python.org/issue?@action=redirect&bpo=8876

   (101) https://bugs.python.org/issue?@action=redirect&bpo=22217

   (102) https://bugs.python.org/issue?@action=redirect&bpo=22457

   (103) https://bugs.python.org/issue?@action=redirect&bpo=18216

   (104) https://bugs.python.org/issue?@action=redirect&bpo=13918

   (105) https://bugs.python.org/issue?@action=redirect&bpo=22676

   (106) https://bugs.python.org/issue?@action=redirect&bpo=18853

   (107) https://bugs.python.org/issue?@action=redirect&bpo=9351

   (108) https://bugs.python.org/issue?@action=redirect&bpo=7559

   (109) https://bugs.python.org/issue?@action=redirect&bpo=19746

   (110) https://bugs.python.org/issue?@action=redirect&bpo=21991

   (111) https://bugs.python.org/issue?@action=redirect&bpo=22638

   (112) https://bugs.python.org/issue?@action=redirect&bpo=22641

   (113) https://bugs.python.org/issue?@action=redirect&bpo=17401

   (114) https://bugs.python.org/issue?@action=redirect&bpo=21338

   (115) https://bugs.python.org/issue?@action=redirect&bpo=20152

   (116) https://bugs.python.org/issue?@action=redirect&bpo=18643

   (117) https://bugs.python.org/issue?@action=redirect&bpo=22435

   (118) https://bugs.python.org/issue?@action=redirect&bpo=13096

   (119) https://bugs.python.org/issue?@action=redirect&bpo=11694

   (120) https://bugs.python.org/issue?@action=redirect&bpo=19380

   (121) https://bugs.python.org/issue?@action=redirect&bpo=1519638

   (122) https://bugs.python.org/issue?@action=redirect&bpo=18615

   (123) https://bugs.python.org/issue?@action=redirect&bpo=22462

   (124) https://bugs.python.org/issue?@action=redirect&bpo=21965

   (125) https://bugs.python.org/issue?@action=redirect&bpo=21173

   (126) https://bugs.python.org/issue?@action=redirect&bpo=11866

   (127) https://bugs.python.org/issue?@action=redirect&bpo=21905

   (128) https://bugs.python.org/issue?@action=redirect&bpo=11271

   (129) https://bugs.python.org/issue?@action=redirect&bpo=21883

   (130) https://bugs.python.org/issue?@action=redirect&bpo=22219

   (131) https://bugs.python.org/issue?@action=redirect&bpo=22449

   (132) https://bugs.python.org/issue?@action=redirect&bpo=22508

   (133) https://bugs.python.org/issue?@action=redirect&bpo=20076

   (134) https://bugs.python.org/issue?@action=redirect&bpo=20079

   (135) https://bugs.python.org/issue?@action=redirect&bpo=20218

   (136) https://bugs.python.org/issue?@action=redirect&bpo=22396

   (137) https://bugs.python.org/issue?@action=redirect&bpo=22517

   (138) https://bugs.python.org/issue?@action=redirect&bpo=22437

   (139) https://bugs.python.org/issue?@action=redirect&bpo=17442

   (140) https://bugs.python.org/issue?@action=redirect&bpo=23392

   (141) https://bugs.python.org/issue?@action=redirect&bpo=10510

   (142) https://bugs.python.org/issue?@action=redirect&bpo=9850

   (143) https://bugs.python.org/issue?@action=redirect&bpo=5309

   (144) https://bugs.python.org/issue?@action=redirect&bpo=22448

   (145) https://bugs.python.org/issue?@action=redirect&bpo=22427

   (146) https://bugs.python.org/issue?@action=redirect&bpo=22362

   (147) https://bugs.python.org/issue?@action=redirect&bpo=20912

   (148) https://bugs.python.org/issue?@action=redirect&bpo=21866

   (149) https://bugs.python.org/issue?@action=redirect&bpo=22278

   (150) https://bugs.python.org/issue?@action=redirect&bpo=22415

   (151) https://bugs.python.org/issue?@action=redirect&bpo=22423

   (152) https://bugs.python.org/issue?@action=redirect&bpo=21332

   (153) https://bugs.python.org/issue?@action=redirect&bpo=21091

   (154) https://bugs.python.org/issue?@action=redirect&bpo=21079

   (155) https://bugs.python.org/issue?@action=redirect&bpo=22247

   (156) https://bugs.python.org/issue?@action=redirect&bpo=22366

   (157) https://bugs.python.org/issue?@action=redirect&bpo=4180

   (158) https://bugs.python.org/issue?@action=redirect&bpo=22419

   (159) https://bugs.python.org/issue?@action=redirect&bpo=20537

   (160) https://bugs.python.org/issue?@action=redirect&bpo=22384

   (161) https://bugs.python.org/issue?@action=redirect&bpo=22168

   (162) https://bugs.python.org/issue?@action=redirect&bpo=21147

   (163) https://bugs.python.org/issue?@action=redirect&bpo=13968

   (164) https://bugs.python.org/issue?@action=redirect&bpo=21951

   (165) https://bugs.python.org/issue?@action=redirect&bpo=21951

   (166) https://bugs.python.org/issue?@action=redirect&bpo=22338

   (167) https://bugs.python.org/issue?@action=redirect&bpo=12410

   (168) https://bugs.python.org/issue?@action=redirect&bpo=21270

   (169) https://bugs.python.org/issue?@action=redirect&bpo=16662

   (170) https://bugs.python.org/issue?@action=redirect&bpo=22226

   (171) https://bugs.python.org/issue?@action=redirect&bpo=19524

   (172) https://bugs.python.org/issue?@action=redirect&bpo=20421

   (173) https://bugs.python.org/issue?@action=redirect&bpo=19546

   (174) https://bugs.python.org/issue?@action=redirect&bpo=22051

   (175) https://bugs.python.org/issue?@action=redirect&bpo=21933

   (176) https://bugs.python.org/issue?@action=redirect&bpo=21597

   (177) https://bugs.python.org/issue?@action=redirect&bpo=18132

   (178) https://bugs.python.org/issue?@action=redirect&bpo=22043

   (179) https://bugs.python.org/issue?@action=redirect&bpo=21527

   (180) https://bugs.python.org/issue?@action=redirect&bpo=22216

   (181) https://bugs.python.org/issue?@action=redirect&bpo=22098

   (182) https://bugs.python.org/issue?@action=redirect&bpo=22185

   (183) https://bugs.python.org/issue?@action=redirect&bpo=22287

   (184) https://bugs.python.org/issue?@action=redirect&bpo=22182

   (185) https://bugs.python.org/issue?@action=redirect&bpo=22042

   (186) https://bugs.python.org/issue?@action=redirect&bpo=16808

   (187) https://bugs.python.org/issue?@action=redirect&bpo=22236

   (188) https://bugs.python.org/issue?@action=redirect&bpo=2527

   (189) https://bugs.python.org/issue?@action=redirect&bpo=22118

   (190) https://bugs.python.org/issue?@action=redirect&bpo=21549

   (191) https://bugs.python.org/issue?@action=redirect&bpo=19628

   (192) https://bugs.python.org/issue?@action=redirect&bpo=15696

   (193) https://bugs.python.org/issue?@action=redirect&bpo=22068

   (194) https://bugs.python.org/issue?@action=redirect&bpo=22165

   (195) https://bugs.python.org/issue?@action=redirect&bpo=15381

   (196) https://bugs.python.org/issue?@action=redirect&bpo=8797

   (197) https://bugs.python.org/issue?@action=redirect&bpo=20729

   (198) https://bugs.python.org/issue?@action=redirect&bpo=21448

   (199) https://bugs.python.org/issue?@action=redirect&bpo=22184

   (200) https://bugs.python.org/issue?@action=redirect&bpo=17923

   (201) https://bugs.python.org/issue?@action=redirect&bpo=21725

   (202) https://bugs.python.org/issue?@action=redirect&bpo=22176

   (203) https://bugs.python.org/issue?@action=redirect&bpo=5411

   (204) https://bugs.python.org/issue?@action=redirect&bpo=21121

   (205) https://bugs.python.org/issue?@action=redirect&bpo=21975

   (206) https://bugs.python.org/issue?@action=redirect&bpo=20170

   (207) https://bugs.python.org/issue?@action=redirect&bpo=21539

   (208) https://bugs.python.org/issue?@action=redirect&bpo=22127

   (209) https://bugs.python.org/issue?@action=redirect&bpo=21047

   (210) https://bugs.python.org/issue?@action=redirect&bpo=15114

   (211) https://bugs.python.org/issue?@action=redirect&bpo=22085

   (212) https://bugs.python.org/issue?@action=redirect&bpo=21580

   (213) https://bugs.python.org/issue?@action=redirect&bpo=22003

   (214) https://bugs.python.org/issue?@action=redirect&bpo=22018

   (215) https://bugs.python.org/issue?@action=redirect&bpo=22054

   (216) https://bugs.python.org/issue?@action=redirect&bpo=17172

   (217) https://bugs.python.org/issue?@action=redirect&bpo=21704

   (218) https://bugs.python.org/issue?@action=redirect&bpo=20173

   (219) https://bugs.python.org/issue?@action=redirect&bpo=22033

   (220) https://bugs.python.org/issue?@action=redirect&bpo=21947

   (221) https://bugs.python.org/issue?@action=redirect&bpo=16133

   (222) https://bugs.python.org/issue?@action=redirect&bpo=22044

   (223) https://bugs.python.org/issue?@action=redirect&bpo=19884

   (224) https://bugs.python.org/issue?@action=redirect&bpo=4350

   (225) https://bugs.python.org/issue?@action=redirect&bpo=6167

   (226) https://bugs.python.org/issue?@action=redirect&bpo=15275

   (227) https://bugs.python.org/issue?@action=redirect&bpo=21888

   (228) https://bugs.python.org/issue?@action=redirect&bpo=22032

   (229) https://bugs.python.org/issue?@action=redirect&bpo=22031

   (230) https://bugs.python.org/issue?@action=redirect&bpo=22018

   (231) https://bugs.python.org/issue?@action=redirect&bpo=21044

   (232) https://bugs.python.org/issue?@action=redirect&bpo=21966

   (233) https://bugs.python.org/issue?@action=redirect&bpo=19076

   (234) https://bugs.python.org/issue?@action=redirect&bpo=16382

   (235) https://bugs.python.org/issue?@action=redirect&bpo=21932

   (236) https://bugs.python.org/issue?@action=redirect&bpo=21942

   (237) https://bugs.python.org/issue?@action=redirect&bpo=11259

   (238) https://bugs.python.org/issue?@action=redirect&bpo=12523

   (239) https://bugs.python.org/issue?@action=redirect&bpo=21707

   (240) https://bugs.python.org/issue?@action=redirect&bpo=20639

   (241) https://bugs.python.org/issue?@action=redirect&bpo=21714

   (242) https://bugs.python.org/issue?@action=redirect&bpo=15014

   (243) https://bugs.python.org/issue?@action=redirect&bpo=21151

   (244) https://bugs.python.org/issue?@action=redirect&bpo=21090

   (245) https://bugs.python.org/issue?@action=redirect&bpo=5800

   (246) https://bugs.python.org/issue?@action=redirect&bpo=21781

   (247) https://bugs.python.org/issue?@action=redirect&bpo=21679

   (248) https://bugs.python.org/issue?@action=redirect&bpo=21863

   (249) https://bugs.python.org/issue?@action=redirect&bpo=11453

   (250) https://bugs.python.org/issue?@action=redirect&bpo=21858

   (251) https://bugs.python.org/issue?@action=redirect&bpo=21476

   (252) https://bugs.python.org/issue?@action=redirect&bpo=20295

   (253) https://bugs.python.org/issue?@action=redirect&bpo=21729

   (254) https://bugs.python.org/issue?@action=redirect&bpo=21491

   (255) https://bugs.python.org/issue?@action=redirect&bpo=21719

   (256) https://bugs.python.org/issue?@action=redirect&bpo=21832

   (257) https://bugs.python.org/issue?@action=redirect&bpo=21722

   (258) https://bugs.python.org/issue?@action=redirect&bpo=21723

   (259) https://bugs.python.org/issue?@action=redirect&bpo=21711

   (260) https://bugs.python.org/issue?@action=redirect&bpo=17552

   (261) https://bugs.python.org/issue?@action=redirect&bpo=18039

   (262) https://bugs.python.org/issue?@action=redirect&bpo=21326

   (263) https://bugs.python.org/issue?@action=redirect&bpo=21766

   (264) https://bugs.python.org/issue?@action=redirect&bpo=21310

   (265) https://bugs.python.org/issue?@action=redirect&bpo=21256

   (266) https://bugs.python.org/issue?@action=redirect&bpo=21677

   (267) https://bugs.python.org/issue?@action=redirect&bpo=11709

   (268) https://bugs.python.org/issue?@action=redirect&bpo=21515

   (269) https://bugs.python.org/issue?@action=redirect&bpo=13223

   (270) https://bugs.python.org/issue?@action=redirect&bpo=21463

   (271) https://bugs.python.org/issue?@action=redirect&bpo=21618

   (272) https://bugs.python.org/issue?@action=redirect&bpo=20383

   (273) https://bugs.python.org/issue?@action=redirect&bpo=21552

   (274) https://bugs.python.org/issue?@action=redirect&bpo=14315

   (275) https://bugs.python.org/issue?@action=redirect&bpo=13742

   (276) https://bugs.python.org/issue?@action=redirect&bpo=21402

   (277) https://bugs.python.org/issue?@action=redirect&bpo=3015

   (278) https://bugs.python.org/issue?@action=redirect&bpo=10203

   (279) https://bugs.python.org/issue?@action=redirect&bpo=18807

   (280) https://bugs.python.org/issue?@action=redirect&bpo=20197

   (281) https://bugs.python.org/issue?@action=redirect&bpo=21513

   (282) https://bugs.python.org/issue?@action=redirect&bpo=21137

   (283) https://bugs.python.org/issue?@action=redirect&bpo=21538

   (284) https://bugs.python.org/issue?@action=redirect&bpo=21455

   (285) https://bugs.python.org/issue?@action=redirect&bpo=21525

   (286) https://bugs.python.org/issue?@action=redirect&bpo=22166

   (287) https://bugs.python.org/issue?@action=redirect&bpo=22236

   (288) https://bugs.python.org/issue?@action=redirect&bpo=10744

   (289) https://peps.python.org/pep-3118/

   (290) https://bugs.python.org/issue?@action=redirect&bpo=20826

   (291) https://bugs.python.org/issue?@action=redirect&bpo=21487

   (292) https://bugs.python.org/issue?@action=redirect&bpo=21486

   (293) https://bugs.python.org/issue?@action=redirect&bpo=13916

   (294) https://bugs.python.org/issue?@action=redirect&bpo=20998

   (295) https://bugs.python.org/issue?@action=redirect&bpo=21075

   (296) https://bugs.python.org/issue?@action=redirect&bpo=19775

   (297) https://bugs.python.org/issue?@action=redirect&bpo=21226

   (298) https://bugs.python.org/issue?@action=redirect&bpo=21398

   (299) https://bugs.python.org/issue?@action=redirect&bpo=16531

   (300) https://bugs.python.org/issue?@action=redirect&bpo=21156

   (301) https://bugs.python.org/issue?@action=redirect&bpo=21424

   (302) https://bugs.python.org/issue?@action=redirect&bpo=21396

   (303) https://bugs.python.org/issue?@action=redirect&bpo=18314

   (304) https://bugs.python.org/issue?@action=redirect&bpo=21088

   (305) https://bugs.python.org/issue?@action=redirect&bpo=21407

   (306) https://bugs.python.org/issue?@action=redirect&bpo=10650

   (307) https://bugs.python.org/issue?@action=redirect&bpo=21469

   (308) https://bugs.python.org/issue?@action=redirect&bpo=19414

   (309) https://bugs.python.org/issue?@action=redirect&bpo=21421

   (310) https://bugs.python.org/issue?@action=redirect&bpo=21101

   (311) https://bugs.python.org/issue?@action=redirect&bpo=21321

   (312) https://bugs.python.org/issue?@action=redirect&bpo=21057

   (313) https://bugs.python.org/issue?@action=redirect&bpo=20951

   (314) https://bugs.python.org/issue?@action=redirect&bpo=13248

   (315) https://bugs.python.org/issue?@action=redirect&bpo=9815

   (316) https://bugs.python.org/issue?@action=redirect&bpo=19940

   (317) https://bugs.python.org/issue?@action=redirect&bpo=13204

   (318) https://bugs.python.org/issue?@action=redirect&bpo=19385

   (319) https://bugs.python.org/issue?@action=redirect&bpo=21207

   (320) https://bugs.python.org/issue?@action=redirect&bpo=21291

   (321) https://bugs.python.org/issue?@action=redirect&bpo=21127

   (322) https://bugs.python.org/issue?@action=redirect&bpo=15002

   (323) https://bugs.python.org/issue?@action=redirect&bpo=12220

   (324) https://bugs.python.org/issue?@action=redirect&bpo=21068

   (325) https://bugs.python.org/issue?@action=redirect&bpo=21276

   (326) https://bugs.python.org/issue?@action=redirect&bpo=21262

   (327) https://bugs.python.org/issue?@action=redirect&bpo=21238

   (328) https://bugs.python.org/issue?@action=redirect&bpo=20896

   (329) https://bugs.python.org/issue?@action=redirect&bpo=21239

   (330) https://bugs.python.org/issue?@action=redirect&bpo=21203

   (331) https://bugs.python.org/issue?@action=redirect&bpo=21222

   (332) https://bugs.python.org/issue?@action=redirect&bpo=21197

   (333) https://bugs.python.org/issue?@action=redirect&bpo=17498

   (334) https://bugs.python.org/issue?@action=redirect&bpo=17826

   (335) https://bugs.python.org/issue?@action=redirect&bpo=7776

   (336) https://bugs.python.org/issue?@action=redirect&bpo=20968

   (337) https://bugs.python.org/issue?@action=redirect&bpo=21529

   (338) https://www.cve.org/CVERecord?id=CVE-2014-4616

   (339) https://bugs.python.org/issue?@action=redirect&bpo=21169

   (340) https://bugs.python.org/issue?@action=redirect&bpo=21171

   (341) https://bugs.python.org/issue?@action=redirect&bpo=20539

   (342) https://bugs.python.org/issue?@action=redirect&bpo=21172

   (343) https://bugs.python.org/issue?@action=redirect&bpo=21155

   (344) https://bugs.python.org/issue?@action=redirect&bpo=21136

   (345) https://bugs.python.org/issue?@action=redirect&bpo=17621

   (346) https://bugs.python.org/issue?@action=redirect&bpo=21076

   (347) https://bugs.python.org/issue?@action=redirect&bpo=20636

   (348) https://bugs.python.org/issue?@action=redirect&bpo=19505

   (349) https://bugs.python.org/issue?@action=redirect&bpo=21149

   (350) https://bugs.python.org/issue?@action=redirect&bpo=21058

   (351) https://bugs.python.org/issue?@action=redirect&bpo=21200

   (352) https://bugs.python.org/issue?@action=redirect&bpo=21013

   (353) https://bugs.python.org/issue?@action=redirect&bpo=20145

   (354) https://bugs.python.org/issue?@action=redirect&bpo=20633

   (355) https://bugs.python.org/issue?@action=redirect&bpo=20980

   (356) https://bugs.python.org/issue?@action=redirect&bpo=21082

   (357) https://bugs.python.org/issue?@action=redirect&bpo=20990

   (358) https://bugs.python.org/issue?@action=redirect&bpo=21015

   (359) https://bugs.python.org/issue?@action=redirect&bpo=21000

   (360) https://bugs.python.org/issue?@action=redirect&bpo=20995

   (361) https://bugs.python.org/issue?@action=redirect&bpo=20884

   (362) https://bugs.python.org/issue?@action=redirect&bpo=21499

   (363) https://bugs.python.org/issue?@action=redirect&bpo=20627

   (364) https://bugs.python.org/issue?@action=redirect&bpo=19165

   (365) https://bugs.python.org/issue?@action=redirect&bpo=13936

   (366) https://bugs.python.org/issue?@action=redirect&bpo=18931

   (367) https://bugs.python.org/issue?@action=redirect&bpo=19977

   (368) https://bugs.python.org/issue?@action=redirect&bpo=20574

   (369) https://bugs.python.org/issue?@action=redirect&bpo=20879

   (370) https://bugs.python.org/issue?@action=redirect&bpo=19157

   (371) https://bugs.python.org/issue?@action=redirect&bpo=11599

   (372) https://bugs.python.org/issue?@action=redirect&bpo=4931

   (373) https://bugs.python.org/issue?@action=redirect&bpo=20875

   (374) https://bugs.python.org/issue?@action=redirect&bpo=11558

   (375) https://bugs.python.org/issue?@action=redirect&bpo=20283

   (376) https://bugs.python.org/issue?@action=redirect&bpo=20778

   (377) https://bugs.python.org/issue?@action=redirect&bpo=20791

   (378) https://bugs.python.org/issue?@action=redirect&bpo=19748

   (379) https://bugs.python.org/issue?@action=redirect&bpo=19573

   (380) https://bugs.python.org/issue?@action=redirect&bpo=20726

   (381) https://bugs.python.org/issue?@action=redirect&bpo=17373

   (382) https://bugs.python.org/issue?@action=redirect&bpo=20378

   (383) https://bugs.python.org/issue?@action=redirect&bpo=20816

   (384) https://bugs.python.org/issue?@action=redirect&bpo=20817

   (385) https://bugs.python.org/issue?@action=redirect&bpo=6676

   (386) https://bugs.python.org/issue?@action=redirect&bpo=21117

   (387) https://bugs.python.org/issue?@action=redirect&bpo=20334

   (388) https://bugs.python.org/issue?@action=redirect&bpo=15916

   (389) https://bugs.python.org/issue?@action=redirect&bpo=21209

   (390) https://bugs.python.org/issue?@action=redirect&bpo=163

   (391) https://bugs.python.org/issue?@action=redirect&bpo=21311

   (392) https://bugs.python.org/issue?@action=redirect&bpo=11571

   (393) https://bugs.python.org/issue?@action=redirect&bpo=21801

   (394) https://bugs.python.org/issue?@action=redirect&bpo=21923

   (395) https://bugs.python.org/issue?@action=redirect&bpo=21323

   (396) https://bugs.python.org/issue?@action=redirect&bpo=19435

   (397) https://bugs.python.org/issue?@action=redirect&bpo=22733

   (398) https://bugs.python.org/issue?@action=redirect&bpo=23302


File: python.info,  Node: IDLE<63>,  Next: Build<88>,  Prev: Library<95>,  Up: Python 3 5 0 alpha 1

1.23.109.3 IDLE
...............

   - bpo-20577(1): Configuration of the max line length for the
     FormatParagraph extension has been moved from the General tab of
     the Idle preferences dialog to the FormatParagraph tab of the
     Config Extensions dialog.  Patch by Tal Einat.

   - bpo-16893(2): Update Idle doc chapter to match current Idle and add
     new information.

   - bpo-3068(3): Add Idle extension configuration dialog to Options
     menu.  Changes are written to HOME/.idlerc/config-extensions.cfg.
     Original patch by Tal Einat.

   - bpo-16233(4): A module browser (File : Class Browser, Alt+C)
     requires an editor window with a filename.  When Class Browser is
     requested otherwise, from a shell, output window, or 'Untitled'
     editor, Idle no longer displays an error box.  It now pops up an
     Open Module box (Alt+M). If a valid name is entered and a module is
     opened, a corresponding browser is also opened.

   - bpo-4832(5): Save As to type Python files automatically adds .py to
     the name you enter (even if your system does not display it).  Some
     systems automatically add .txt when type is Text files.

   - bpo-21986(6): Code objects are not normally pickled by the pickle
     module.  To match this, they are no longer pickled when running
     under Idle.

   - bpo-17390(7): Adjust Editor window title; remove 'Python', move
     version to end.

   - bpo-14105(8): Idle debugger breakpoints no longer disappear when
     inserting or deleting lines.

   - bpo-17172(9): Turtledemo can now be run from Idle.  Currently, the
     entry is on the Help menu, but it may move to Run.  Patch by
     Ramchandra Apt and Lita Cho.

   - bpo-21765(10): Add support for non-ascii identifiers to
     HyperParser.

   - bpo-21940(11): Add unittest for WidgetRedirector.  Initial patch by
     Saimadhav Heblikar.

   - bpo-18592(12): Add unittest for SearchDialogBase.  Patch by Phil
     Webster.

   - bpo-21694(13): Add unittest for ParenMatch.  Patch by Saimadhav
     Heblikar.

   - bpo-21686(14): add unittest for HyperParser.  Original patch by
     Saimadhav Heblikar.

   - bpo-12387(15): Add missing upper(lower)case versions of default
     Windows key bindings for Idle so Caps Lock does not disable them.
     Patch by Roger Serwy.

   - bpo-21695(16): Closing a Find-in-files output window while the
     search is still in progress no longer closes Idle.

   - bpo-18910(17): Add unittest for textView.  Patch by Phil Webster.

   - bpo-18292(18): Add unittest for AutoExpand.  Patch by Saihadhav
     Heblikar.

   - bpo-18409(19): Add unittest for AutoComplete.  Patch by Phil
     Webster.

   - bpo-21477(20): htest.py - Improve framework, complete set of tests.
     Patches by Saimadhav Heblikar

   - bpo-18104(21): Add idlelib/idle_test/htest.py with a few sample
     tests to begin consolidating and improving human-validated tests of
     Idle.  Change other files as needed to work with htest.  Running
     the module as __main__ runs all tests.

   - bpo-21139(22): Change default paragraph width to 72, the PEP 8(23)
     recommendation.

   - bpo-21284(24): Paragraph reformat test passes after user changes
     reformat width.

   - bpo-17654(25): Ensure IDLE menus are customized properly on OS X
     for non-framework builds and for all variants of Tk.

   - bpo-23180(26): Rename IDLE "Windows" menu item to "Window".  Patch
     by Al Sweigart.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=20577

   (2) https://bugs.python.org/issue?@action=redirect&bpo=16893

   (3) https://bugs.python.org/issue?@action=redirect&bpo=3068

   (4) https://bugs.python.org/issue?@action=redirect&bpo=16233

   (5) https://bugs.python.org/issue?@action=redirect&bpo=4832

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21986

   (7) https://bugs.python.org/issue?@action=redirect&bpo=17390

   (8) https://bugs.python.org/issue?@action=redirect&bpo=14105

   (9) https://bugs.python.org/issue?@action=redirect&bpo=17172

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21765

   (11) https://bugs.python.org/issue?@action=redirect&bpo=21940

   (12) https://bugs.python.org/issue?@action=redirect&bpo=18592

   (13) https://bugs.python.org/issue?@action=redirect&bpo=21694

   (14) https://bugs.python.org/issue?@action=redirect&bpo=21686

   (15) https://bugs.python.org/issue?@action=redirect&bpo=12387

   (16) https://bugs.python.org/issue?@action=redirect&bpo=21695

   (17) https://bugs.python.org/issue?@action=redirect&bpo=18910

   (18) https://bugs.python.org/issue?@action=redirect&bpo=18292

   (19) https://bugs.python.org/issue?@action=redirect&bpo=18409

   (20) https://bugs.python.org/issue?@action=redirect&bpo=21477

   (21) https://bugs.python.org/issue?@action=redirect&bpo=18104

   (22) https://bugs.python.org/issue?@action=redirect&bpo=21139

   (23) https://peps.python.org/pep-0008/

   (24) https://bugs.python.org/issue?@action=redirect&bpo=21284

   (25) https://bugs.python.org/issue?@action=redirect&bpo=17654

   (26) https://bugs.python.org/issue?@action=redirect&bpo=23180


File: python.info,  Node: Build<88>,  Next: C API<71>,  Prev: IDLE<63>,  Up: Python 3 5 0 alpha 1

1.23.109.4 Build
................

   - bpo-15506(1): Use standard PKG_PROG_PKG_CONFIG autoconf macro in
     the configure script.

   - bpo-22935(2): Allow the ssl module to be compiled if openssl
     doesn't support SSL 3.

   - bpo-22592(3): Drop support of the Borland C compiler to build
     Python.  The distutils module still supports it to build
     extensions.

   - bpo-22591(4): Drop support of MS-DOS, especially of the DJGPP
     compiler (MS-DOS port of GCC).

   - bpo-16537(5): Check whether self.extensions is empty in setup.py.
     Patch by Jonathan Hosmer.

   - bpo-22359(6): Remove incorrect uses of recursive make.  Patch by
     Jonas Wagner.

   - bpo-21958(7): Define HAVE_ROUND when building with Visual Studio
     2013 and above.  Patch by Zachary Turner.

   - bpo-18093(8): the programs that embed the CPython runtime are now
     in a separate "Programs" directory, rather than being kept in the
     Modules directory.

   - bpo-15759(9): "make suspicious", "make linkcheck" and "make
     doctest" in Doc/ now display special message when and only when
     there are failures.

   - bpo-21141(10): The Windows build process no longer attempts to find
     Perl, instead relying on OpenSSL source being configured and ready
     to build.  The ‘PCbuild\build_ssl.py’ script has been re-written
     and re-named to ‘PCbuild\prepare_ssl.py’, and takes care of
     configuring OpenSSL source for both 32 and 64 bit platforms.
     OpenSSL sources obtained from svn.python.org will always be
     pre-configured and ready to build.

   - bpo-21037(11): Add a build option to enable AddressSanitizer
     support.

   - bpo-19962(12): The Windows build process now creates "python.bat"
     in the root of the source tree, which passes all arguments through
     to the most recently built interpreter.

   - bpo-21285(13): Refactor and fix curses configure check to always
     search in a ncursesw directory.

   - bpo-15234(14): For BerkeleyDB and Sqlite, only add the found
     library and include directories if they aren't already being
     searched.  This avoids an explicit runtime library dependency.

   - bpo-17861(15): Tools/scripts/generate_opcode_h.py automatically
     regenerates Include/opcode.h from Lib/opcode.py if the latter gets
     any change.

   - bpo-20644(16): OS X installer build support for documentation build
     changes in 3.4.1: assume externally supplied sphinx-build is
     available in /usr/bin.

   - bpo-20022(17): Eliminate use of deprecated bundlebuilder in OS X
     builds.

   - bpo-15968(18): Incorporated Tcl, Tk, and Tix builds into the
     Windows build solution.

   - bpo-17095(19): Fix Modules/Setup 'shared' support.

   - bpo-21811(20): Anticipated fixes to support OS X versions > 10.9.

   - bpo-21166(21): Prevent possible segfaults and other random failures
     of python -generate-posix-vars in pybuilddir.txt build target.

   - bpo-18096(22): Fix library order returned by python-config.

   - bpo-17219(23): Add library build dir for Python extension
     cross-builds.

   - bpo-22919(24): Windows build updated to support VC 14.0 (Visual
     Studio 2015), which will be used for the official release.

   - bpo-21236(25): Build _msi.pyd with cabinet.lib instead of fci.lib

   - bpo-17128(26): Use private version of OpenSSL for OS X 10.5+
     installer.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=15506

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22935

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22592

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22591

   (5) https://bugs.python.org/issue?@action=redirect&bpo=16537

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22359

   (7) https://bugs.python.org/issue?@action=redirect&bpo=21958

   (8) https://bugs.python.org/issue?@action=redirect&bpo=18093

   (9) https://bugs.python.org/issue?@action=redirect&bpo=15759

   (10) https://bugs.python.org/issue?@action=redirect&bpo=21141

   (11) https://bugs.python.org/issue?@action=redirect&bpo=21037

   (12) https://bugs.python.org/issue?@action=redirect&bpo=19962

   (13) https://bugs.python.org/issue?@action=redirect&bpo=21285

   (14) https://bugs.python.org/issue?@action=redirect&bpo=15234

   (15) https://bugs.python.org/issue?@action=redirect&bpo=17861

   (16) https://bugs.python.org/issue?@action=redirect&bpo=20644

   (17) https://bugs.python.org/issue?@action=redirect&bpo=20022

   (18) https://bugs.python.org/issue?@action=redirect&bpo=15968

   (19) https://bugs.python.org/issue?@action=redirect&bpo=17095

   (20) https://bugs.python.org/issue?@action=redirect&bpo=21811

   (21) https://bugs.python.org/issue?@action=redirect&bpo=21166

   (22) https://bugs.python.org/issue?@action=redirect&bpo=18096

   (23) https://bugs.python.org/issue?@action=redirect&bpo=17219

   (24) https://bugs.python.org/issue?@action=redirect&bpo=22919

   (25) https://bugs.python.org/issue?@action=redirect&bpo=21236

   (26) https://bugs.python.org/issue?@action=redirect&bpo=17128


File: python.info,  Node: C API<71>,  Next: Documentation<74>,  Prev: Build<88>,  Up: Python 3 5 0 alpha 1

1.23.109.5 C API
................

   - bpo-14203(1): Remove obsolete support for view==NULL in
     PyBuffer_FillInfo(), bytearray_getbuffer(), bytesiobuf_getbuffer()
     and array_buffer_getbuf().  All functions now raise BufferError in
     that case.

   - bpo-22445(2): PyBuffer_IsContiguous() now implements precise
     contiguity tests, compatible with NumPy's
     NPY_RELAXED_STRIDES_CHECKING compilation flag.  Previously the
     function reported false negatives for corner cases.

   - bpo-22079(3): PyType_Ready() now checks that statically allocated
     type has no dynamically allocated bases.

   - bpo-22453(4): Removed non-documented macro PyObject_REPR().

   - bpo-18395(5): Rename ‘_Py_char2wchar()’ to *note Py_DecodeLocale():
     b95, rename ‘_Py_wchar2char()’ to *note Py_EncodeLocale(): b96, and
     document these functions.

   - bpo-21233(6): Add new C functions: PyMem_RawCalloc(),
     PyMem_Calloc(), PyObject_Calloc(), _PyObject_GC_Calloc().
     bytes(int) is now using ‘calloc()’ instead of ‘malloc()’ for large
     objects which is faster and use less memory.

   - bpo-20942(7): PyImport_ImportFrozenModuleObject() no longer sets
     __file__ to match what importlib does; this affects
     _frozen_importlib as well as any module loaded using
     imp.init_frozen().

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=14203

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22445

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22079

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22453

   (5) https://bugs.python.org/issue?@action=redirect&bpo=18395

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21233

   (7) https://bugs.python.org/issue?@action=redirect&bpo=20942


File: python.info,  Node: Documentation<74>,  Next: Tests<81>,  Prev: C API<71>,  Up: Python 3 5 0 alpha 1

1.23.109.6 Documentation
........................

   - bpo-19548(1): Update the codecs module documentation to better
     cover the distinction between text encodings and other codecs,
     together with other clarifications.  Patch by Martin Panter.

   - bpo-22394(2): Doc/Makefile now supports ‘make venv
     PYTHON=../python’ to create a venv for generating the
     documentation, e.g., ‘make html PYTHON=venv/bin/python3’.

   - bpo-21514(3): The documentation of the json module now refers to
     new JSON RFC 7159 instead of obsoleted RFC 4627.

   - bpo-21777(4): The binary sequence methods on bytes and bytearray
     are now documented explicitly, rather than assuming users will be
     able to derive the expected behaviour from the behaviour of the
     corresponding str methods.

   - bpo-6916(5): undocument deprecated asynchat.fifo class.

   - bpo-17386(6): Expanded functionality of the ‘Doc/make.bat’ script
     to make it much more comparable to ‘Doc/Makefile’.

   - bpo-21312(7): Update the thread_foobar.h template file to include
     newer threading APIs.  Patch by Jack McCracken.

   - bpo-21043(8): Remove the recommendation for specific CA
     organizations and to mention the ability to load the OS
     certificates.

   - bpo-20765(9): Add missing documentation for PurePath.with_name()
     and PurePath.with_suffix().

   - bpo-19407(10): New package installation and distribution guides
     based on the Python Packaging Authority tools.  Existing guides
     have been retained as legacy links from the distutils docs, as they
     still contain some required reference material for tool developers
     that isn't recorded anywhere else.

   - bpo-19697(11): Document cases where __main__.__spec__ is None.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=19548

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22394

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21514

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21777

   (5) https://bugs.python.org/issue?@action=redirect&bpo=6916

   (6) https://bugs.python.org/issue?@action=redirect&bpo=17386

   (7) https://bugs.python.org/issue?@action=redirect&bpo=21312

   (8) https://bugs.python.org/issue?@action=redirect&bpo=21043

   (9) https://bugs.python.org/issue?@action=redirect&bpo=20765

   (10) https://bugs.python.org/issue?@action=redirect&bpo=19407

   (11) https://bugs.python.org/issue?@action=redirect&bpo=19697


File: python.info,  Node: Tests<81>,  Next: Tools/Demos<48>,  Prev: Documentation<74>,  Up: Python 3 5 0 alpha 1

1.23.109.7 Tests
................

   - bpo-18982(1): Add tests for CLI of the calendar module.

   - bpo-19548(2): Added some additional checks to test_codecs to ensure
     that statements in the updated documentation remain accurate.
     Patch by Martin Panter.

   - bpo-22838(3): All test_re tests now work with unittest test
     discovery.

   - bpo-22173(4): Update lib2to3 tests to use unittest test discovery.

   - bpo-16000(5): Convert test_curses to use unittest.

   - bpo-21456(6): Skip two tests in test_urllib2net.py if _ssl module
     not present.  Patch by Remi Pointel.

   - bpo-20746(7): Fix test_pdb to run in refleak mode (-R). Patch by
     Xavier de Gaye.

   - bpo-22060(8): test_ctypes has been somewhat cleaned up and
     simplified; it now uses unittest test discovery to find its tests.

   - bpo-22104(9): regrtest.py no longer holds a reference to the suite
     of tests loaded from test modules that don't define test_main().

   - bpo-22111(10): Assorted cleanups in test_imaplib.  Patch by Milan
     Oberkirch.

   - bpo-22002(11): Added ‘load_package_tests’ function to test.support
     and used it to implement/augment test discovery in test_asyncio,
     test_email, test_importlib, test_json, and test_tools.

   - bpo-21976(12): Fix test_ssl to accept LibreSSL version strings.
     Thanks to William Orr.

   - bpo-21918(13): Converted test_tools from a module to a package
     containing separate test files for each tested script.

   - bpo-9554(14): Use modern unittest features in test_argparse.
     Initial patch by Denver Coneybeare and Radu Voicilas.

   - bpo-20155(15): Changed HTTP method names in failing tests in
     test_httpservers so that packet filtering software (specifically
     Windows Base Filtering Engine) does not interfere with the
     transaction semantics expected by the tests.

   - bpo-19493(16): Refactored the ctypes test package to skip tests
     explicitly rather than silently.

   - bpo-18492(17): All resources are now allowed when tests are not run
     by regrtest.py.

   - bpo-21634(18): Fix pystone micro-benchmark: use floor division
     instead of true division to benchmark integers instead of
     floating-point numbers.  Set pystone version to 1.2.  Patch written
     by Lennart Regebro.

   - bpo-21605(19): Added tests for Tkinter images.

   - bpo-21493(20): Added test for ntpath.expanduser().  Original patch
     by Claudiu Popa.

   - bpo-19925(21): Added tests for the spwd module.  Original patch by
     Vajrasky Kok.

   - bpo-21522(22): Added Tkinter tests for Listbox.itemconfigure(),
     PanedWindow.paneconfigure(), and Menu.entryconfigure().

   - bpo-17756(23): Fix test_code test when run from the installed
     location.

   - bpo-17752(24): Fix distutils tests when run from the installed
     location.

   - bpo-18604(25): Consolidated checks for GUI availability.  All
     platforms now at least check whether Tk can be instantiated when
     the GUI resource is requested.

   - bpo-21275(26): Fix a socket test on KFreeBSD.

   - bpo-21223(27): Pass test_site/test_startup_imports when some of the
     extensions are built as builtins.

   - bpo-20635(28): Added tests for Tk geometry managers.

   - Add test case for freeze.

   - bpo-20743(29): Fix a reference leak in test_tcl.

   - bpo-21097(30): Move test_namespace_pkgs into test_importlib.

   - bpo-21503(31): Use test_both() consistently in test_importlib.

   - bpo-20939(32): Avoid various network test failures due to new
     redirect of ‘http://www.python.org/’ to ‘https://www.python.org’:
     use ‘http://www.example.com’ instead.

   - bpo-20668(33): asyncio tests no longer rely on tests.txt file.
     (Patch by Vajrasky Kok)

   - bpo-21093(34): Prevent failures of ctypes test_macholib on OS X if
     a copy of libz exists in $HOME/lib or /usr/local/lib.

   - bpo-22770(35): Prevent some Tk segfaults on OS X when running gui
     tests.

   - bpo-23211(36): Workaround test_logging failure on some OS X 10.6
     systems.

   - bpo-23345(37): Prevent test_ssl failures with large OpenSSL patch
     level values (like 0.9.8zc).

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18982

   (2) https://bugs.python.org/issue?@action=redirect&bpo=19548

   (3) https://bugs.python.org/issue?@action=redirect&bpo=22838

   (4) https://bugs.python.org/issue?@action=redirect&bpo=22173

   (5) https://bugs.python.org/issue?@action=redirect&bpo=16000

   (6) https://bugs.python.org/issue?@action=redirect&bpo=21456

   (7) https://bugs.python.org/issue?@action=redirect&bpo=20746

   (8) https://bugs.python.org/issue?@action=redirect&bpo=22060

   (9) https://bugs.python.org/issue?@action=redirect&bpo=22104

   (10) https://bugs.python.org/issue?@action=redirect&bpo=22111

   (11) https://bugs.python.org/issue?@action=redirect&bpo=22002

   (12) https://bugs.python.org/issue?@action=redirect&bpo=21976

   (13) https://bugs.python.org/issue?@action=redirect&bpo=21918

   (14) https://bugs.python.org/issue?@action=redirect&bpo=9554

   (15) https://bugs.python.org/issue?@action=redirect&bpo=20155

   (16) https://bugs.python.org/issue?@action=redirect&bpo=19493

   (17) https://bugs.python.org/issue?@action=redirect&bpo=18492

   (18) https://bugs.python.org/issue?@action=redirect&bpo=21634

   (19) https://bugs.python.org/issue?@action=redirect&bpo=21605

   (20) https://bugs.python.org/issue?@action=redirect&bpo=21493

   (21) https://bugs.python.org/issue?@action=redirect&bpo=19925

   (22) https://bugs.python.org/issue?@action=redirect&bpo=21522

   (23) https://bugs.python.org/issue?@action=redirect&bpo=17756

   (24) https://bugs.python.org/issue?@action=redirect&bpo=17752

   (25) https://bugs.python.org/issue?@action=redirect&bpo=18604

   (26) https://bugs.python.org/issue?@action=redirect&bpo=21275

   (27) https://bugs.python.org/issue?@action=redirect&bpo=21223

   (28) https://bugs.python.org/issue?@action=redirect&bpo=20635

   (29) https://bugs.python.org/issue?@action=redirect&bpo=20743

   (30) https://bugs.python.org/issue?@action=redirect&bpo=21097

   (31) https://bugs.python.org/issue?@action=redirect&bpo=21503

   (32) https://bugs.python.org/issue?@action=redirect&bpo=20939

   (33) https://bugs.python.org/issue?@action=redirect&bpo=20668

   (34) https://bugs.python.org/issue?@action=redirect&bpo=21093

   (35) https://bugs.python.org/issue?@action=redirect&bpo=22770

   (36) https://bugs.python.org/issue?@action=redirect&bpo=23211

   (37) https://bugs.python.org/issue?@action=redirect&bpo=23345


File: python.info,  Node: Tools/Demos<48>,  Next: Windows<73>,  Prev: Tests<81>,  Up: Python 3 5 0 alpha 1

1.23.109.8 Tools/Demos
......................

   - bpo-22314(1): pydoc now works when the LINES environment variable
     is set.

   - bpo-22615(2): Argument Clinic now supports the "type" argument for
     the int converter.  This permits using the int converter with enums
     and typedefs.

   - bpo-20076(3): The makelocalealias.py script no longer ignores UTF-8
     mapping.

   - bpo-20079(4): The makelocalealias.py script now can parse the
     SUPPORTED file from glibc sources and supports command line options
     for source paths.

   - bpo-22201(5): Command-line interface of the zipfile module now
     correctly extracts ZIP files with directory entries.  Patch by Ryan
     Wilson.

   - bpo-22120(6): For functions using an unsigned integer return
     converter, Argument Clinic now generates a cast to that type for
     the comparison to -1 in the generated code.  (This suppresses a
     compilation warning.)

   - bpo-18974(7): Tools/scripts/diff.py now uses argparse instead of
     optparse.

   - bpo-21906(8): Make Tools/scripts/md5sum.py work in Python 3.  Patch
     by Zachary Ware.

   - bpo-21629(9): Fix Argument Clinic's "-converters" feature.

   - Add support for ‘yield from’ to 2to3.

   - Add support for the PEP 465(10) matrix multiplication operator to
     2to3.

   - bpo-16047(11): Fix module exception list and __file__ handling in
     freeze.  Patch by Meador Inge.

   - bpo-11824(12): Consider ABI tags in freeze.  Patch by Meador Inge.

   - bpo-20535(13): PYTHONWARNING no longer affects the run_tests.py
     script.  Patch by Arfrever Frehtes Taifersar Arahesis.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=22314

   (2) https://bugs.python.org/issue?@action=redirect&bpo=22615

   (3) https://bugs.python.org/issue?@action=redirect&bpo=20076

   (4) https://bugs.python.org/issue?@action=redirect&bpo=20079

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22201

   (6) https://bugs.python.org/issue?@action=redirect&bpo=22120

   (7) https://bugs.python.org/issue?@action=redirect&bpo=18974

   (8) https://bugs.python.org/issue?@action=redirect&bpo=21906

   (9) https://bugs.python.org/issue?@action=redirect&bpo=21629

   (10) https://peps.python.org/pep-0465/

   (11) https://bugs.python.org/issue?@action=redirect&bpo=16047

   (12) https://bugs.python.org/issue?@action=redirect&bpo=11824

   (13) https://bugs.python.org/issue?@action=redirect&bpo=20535


File: python.info,  Node: Windows<73>,  Prev: Tools/Demos<48>,  Up: Python 3 5 0 alpha 1

1.23.109.9 Windows
..................

   - bpo-23260(1): Update Windows installer

   - The bundled version of Tcl/Tk has been updated to 8.6.3.  The most
     visible result of this change is the addition of new native file
     dialogs when running on Windows Vista or newer.  See Tcl/Tk's TIP
     432 for more information.  Also, this version of Tcl/Tk includes
     support for Windows 10.

   - bpo-17896(2): The Windows build scripts now expect external library
     sources to be in ‘PCbuild\..\externals’ rather than
     ‘PCbuild\..\..’.

   - bpo-17717(3): The Windows build scripts now use a copy of NASM
     pulled from svn.python.org to build OpenSSL.

   - bpo-21907(4): Improved the batch scripts provided for building
     Python.

   - bpo-22644(5): The bundled version of OpenSSL has been updated to
     1.0.1j.

   - bpo-10747(6): Use versioned labels in the Windows start menu.
     Patch by Olive Kilburn.

   - bpo-22980(7): .pyd files with a version and platform tag (for
     example, ".cp35-win32.pyd") will now be loaded in preference to
     those without tags.

'(For information about older versions, consult the HISTORY file.)'

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=23260

   (2) https://bugs.python.org/issue?@action=redirect&bpo=17896

   (3) https://bugs.python.org/issue?@action=redirect&bpo=17717

   (4) https://bugs.python.org/issue?@action=redirect&bpo=21907

   (5) https://bugs.python.org/issue?@action=redirect&bpo=22644

   (6) https://bugs.python.org/issue?@action=redirect&bpo=10747

   (7) https://bugs.python.org/issue?@action=redirect&bpo=22980


File: python.info,  Node: Python チュートリアル,  Next: Python のセットアップと利用,  Prev: What's New in Python,  Up: Top

2 Python チュートリアル
***********************

Python は強力で、学びやすいプログラミング言語です。効率的な高レベルデー
タ構造と、シンプルで効果的なオブジェクト指向プログラミング機構を備えてい
ます。 Python は、洗練された文法・動的なデータ型付け・インタープリタであ
ることなどから、スクリプティングや高速アプリケーション開発(Rapid
Application Development: RAD)に理想的なプログラミング言語となっています
。

Python Web サイト(‘https://www.python.org’) は、 Python インタープリタと
標準ライブラリのソースコードと、主要プラットフォームごとにコンパイル済み
のバイナリファイルを無料で配布しています。また、Python ウェブサイトには
、無料のサードパーティモジュールやプログラム、ツール、ドキュメントなども
紹介しています。

Python インタプリタは、簡単に C/C++ 言語などで実装された関数やデータ型を
組み込み、拡張できます。また、アプリケーションのカスタマイズを行う、拡張
言語としても適しています。

このチュートリアルは、Python 言語の基本的な概念と機能を、形式ばらずに紹
介します。読むだけではなく、Pythonインタープリタで実際にサンプルを実行す
ると理解が深まりますが、サンプルはそれぞれ独立していますので、ただ読むだ
けでも良いでしょう。

標準オブジェクトやモジュールの詳細は、 *note Python 標準ライブラリ: 12a.
を参照してください。 また、正式な言語定義は、 *note Python
言語リファレンス: 12b. にあります。 C 言語や C++ 言語で拡張モジュールを
書くなら、 *note Python インタプリタの拡張と埋め込み: 1b46. や *note
Python/C API リファレンスマニュアル: 1b47. を参照してください。Python の
解説書も販売されています。

このチュートリアルは、Python全体を対象とした、包括的な解説書ではありませ
ん。よく使われる機能に限っても、全ては紹介していません。その代わり、この
チュートリアルでは、Pythonのもっとも特徴的な機能を中心に紹介して、この言
語の持ち味や、スタイルを感じられるようにしています。このチュートリアルを
読み終えると、Python のモジュールやプログラムを読み書きできるようになっ
ているでしょう。また、*note Python 標準ライブラリ: 12a. のさまざまな
Python ライブラリモジュールを、詳しく調べられるようになっているはずです
。

*note 用語集: 1b48. にも目を通しておくと良いでしょう。

* Menu:

* やる気を高めよう::
* Python インタプリタを使う::
* 形式ばらない Python の紹介::
* その他の制御フローツール::
* データ構造::
* モジュール: モジュール<2>.
* 入力と出力::
* エラーと例外::
* クラス::
* 標準ライブラリミニツアー::
* 標準ライブラリミニツアー: 標準ライブラリミニツアー --- その 2. その 2
* 仮想環境とパッケージ::
* さあ何を？::
* 対話入力編集と履歴置換::
* 浮動小数点演算、その問題と制限::
* 付録::


File: python.info,  Node: やる気を高めよう,  Next: Python インタプリタを使う,  Up: Python チュートリアル

2.1 やる気を高めよう
====================

コンピュータを使っていろいろな作業をしていると、自動化したい作業が出てく
るでしょう。たとえば、たくさんのテキストファイルで検索-置換操作を行いた
い、大量の写真ファイルを込み入ったやりかたでファイル名を整理して変更した
り、などです。ちょっとした専用のデータベースや、何か専用のGUIアプリケー
ション、シンプルなゲームを作りたいかもしれません。

あなたがプロのソフト開発者として、C/C++/Java ライブラリを扱う必要がある
けども、通常の編集/コンパイル/テスト/再コンパイルのサイクルを遅すぎると
感じているかもしれません。上記ライブラリのためのテストを書くことにうんざ
りしているかもしれません。または、拡張言語を持つアプリケーションを書いて
いるなら、そのために新しい言語一式の設計と実装をしたくないでしょう。

Pythonはそんなあなたのための言語です。

そういった処理は、Unix シェルスクリプトや Windows バッチファイルで書くこ
ともできます。しかし、シェルスクリプトはファイル操作やテキストデータの操
作には向いていますが、GUIアプリケーションやゲームにはむいていません。
C/C++/Java プログラムを書くこともできますが、最初の試し書きだけでもかな
りの時間がかかってしまいます。Pythonはもっと簡単に利用でき、Windows、
macOS、そして Unix オペレーティングシステムで動作し、あなたの仕事をすば
やく片付ける助けになるでしょう。

Python は簡単に利用できますが、本物のプログラミング言語であり、シェルス
クリプトやバッチファイルよりも多くの機構があり、大きなプログラムの開発に
も適しています。一方では、Python は C よりたくさんのエラーチェックを実行
時に行っており、また可変長配列や辞書などの高級な型を組込みで持つ '超高級
言語(very-high-level language)' です。Python は Awk や Perl などよりも汎
用的なデータ型を備えており、より多くの領域で利用できます。また、Pythonは
これらの言語と比べても、少なくとも同じぐらいには簡単です。

Python では、プログラムをモジュールに分割して、他の Python プログラムで
再利用できます。Python には膨大な標準モジュールが付属していて、プログラ
ムを作る上での基盤として、あるいは Python プログラミングを学ぶためのサン
プルとして利用できます。標準モジュールには、ファイル I/O、システムコール
、ソケットといった機能や、Tk のようなグラフィカルユーザインターフェース
ツールキットを使うためのインターフェイスなども提供しています。

Python はインタプリタ言語です。コンパイルやリンクの必要がないので、プロ
グラムを開発する際にかなりの時間を節約できます。インタプリタは対話的にも
使えるので、言語の様々な機能について実験してみたり、書き捨てのプログラム
を書いたり、ボトムアップでプログラムを開発する際に、関数をテストしたりと
いったことが簡単にできます。便利な電卓にもなります。

Python では、とてもコンパクトで読みやすいプログラムを書けます。Python で
書かれたプログラムは大抵、同じ機能の C 言語, C++ 言語や Java のプログラ
ムよりもはるかに短くなります。これには以下のようないくつかの理由がありま
す:

   * 高レベルのデータ型によって、複雑な操作を一つの実行文で表現できます
     。

   * 実行文のグループ化を、グループの開始や終了の括弧ではなくインデント
     で行えます。

   * 変数や引数の宣言が不要です。

Python には '拡張性' があります: C 言語でプログラムを書く方法を知ってい
るなら、簡単に新たな組み込み関数やモジュールを、簡単にインタプリタに追加
できます。これによって、いちばん時間のかかる処理を高速化したり、ベンダ特
有のグラフィクスライブラリなどの、 バイナリ形式でしか手に入らないライブ
ラリを Python にリンクしたりできます。その気になれば、Python インタプリ
タを C で書かれたアプリケーションにリンクして、アプリケーションに対する
拡張言語や命令言語としても使えます。

ところで、この言語は BBC のショー番組、"モンティパイソンの空飛ぶサーカス
(Monty Python's Flying Circus)" から取ったもので、爬虫類とは関係ありませ
ん。このドキュメントでは、モンティパイソンの寸劇への参照が許可されている
だけでなく、むしろ推奨されています！

さて、皆さんはもう Python にワクワクして、もうちょっと詳しく調べてみたく
なったはずです。プログラミング言語を習得する最良の方法は使ってみることで
すから、このチュートリアルではみなさんが読んだ内容を Python インタプリタ
で試してみることをおすすめします。

次の章では、まずインタプリタの使い方を説明します。これはわかりきった内容
かもしれませんが、後に説明する例題を試してみる上で不可欠なことです。

チュートリアルの残りの部分では、Python プログラム言語と実行システムの様
々な機能を例題を交えて紹介します。単純な式、実行文、データ型から始めて、
関数とモジュールを経て、最後には例外処理やユーザ定義クラスといったやや高
度な概念にも触れます。


File: python.info,  Node: Python インタプリタを使う,  Next: 形式ばらない Python の紹介,  Prev: やる気を高めよう,  Up: Python チュートリアル

2.2 Python インタプリタを使う
=============================

* Menu:

* インタプリタを起動する::
* インタプリタとその環境::


File: python.info,  Node: インタプリタを起動する,  Next: インタプリタとその環境,  Up: Python インタプリタを使う

2.2.1 インタプリタを起動する
----------------------------

Python が使用可能な環境では、インタプリタは一般的に
‘/usr/local/bin/python3.13’ にインストールされています。使用している
Unix シェルの検索パスに ‘/usr/local/bin’ を追加すると、次のコマンドでイ
ンタプリタを開始できます:

     python3.13

(1) どのディレクトリに Python インタプリタをインストールするかはインスト
ール時に選択できるので、インタプリタは他のディレクトリにあるかもしれませ
ん; 身近な Python に詳しい人か、システム管理者に聞いてみてください。 (例
えば、その他の場所としては ‘/usr/local/python’ が一般的です。)

*note Microsoft ストア: 1b51. からPythonのインストールを行った Windows マ
シンでは、 ‘python3.13’ コマンドが利用できます。 *note py.exe ランチャ:
588. をインストールした場合、 ‘py’ コマンドが使えます。 Python を起動す
る他の方法については *note 補足; 環境変数の設定: 1b52. を参照してくださ
い。

ファイル終端文字 (Unixでは ‘Control-D’ 、DOS や Windows では
‘Control-Z’) を一次プロンプト (訳注: '>>>' のこと) に入力すると、インタ
プリタが終了ステータス 0 で終了します。もしこの操作がうまく働かないなら
、コマンド: ‘quit()’ と入力すればインタプリタを終了できます。

GNU Readline(2) ライブラリをサポートしているシステム上では、対話的行編集
やヒストリ置換、コード補完のインタプリタの行編集機能が利用できます。コマ
ンドライン編集機能がサポートされているかを最も手っ取り早く調べる方法は、
おそらく最初に表示された Python プロンプトに ‘Control-P’ を入力してみる
ことでしょう。ビープ音が鳴るなら、コマンドライン編集機能があります。編集
キーについての解説は付録 *note 対話入力編集と履歴置換: 1b53. を参照して
ください。何も起こらないように見えるか、 ‘^P’ がエコーバックされるなら、
コマンドライン編集機能は利用できません。この場合、現在編集中の行から文字
を削除するにはバックスペースを使うしかありません。

インタプリタは Unix シェルと同じように使えます。標準入力が端末に接続され
た状態では、コマンドを対話的に読み込んで実行します。ファイル名を引数に指
定するか、‘python3 < filename’ のように標準入力ファイルとして指定すると
、インタプリタはファイルから 'スクリプト' を読み込んで実行します。

インタプリタを ‘python -c command [arg] ...’ のように起動する方法もあり
ます。この形式では、シェルの *note -c: 5aa. オプションと同じように、
'command' に指定した文を実行します。 Python 文には、スペースなどのシェル
にとって特殊な意味をもつ文字がしばしば含まれるので、 'command' 全体をク
ォート(訳注: ‘'’)で囲っておいたほうが良いでしょう。

Python のモジュールには、スクリプトとしても便利に使えるものがあります。
‘python -m module [arg] ...’ のように起動すると、 'module' のソースファ
イルを、フルパスを指定して起動したかのように実行できます。

スクリプトファイルを使用する場合、スクリプトの実行が完了した後、そのまま
対話モードに入れると便利なことがあります。これには *note -i: 1484. をス
クリプト名の前に追加します。

全てのコマンドラインオプションは *note コマンドラインと環境: 192a. で説
明されています。

* Menu:

* 引数の受け渡し::
* 対話モード::

   ---------- Footnotes ----------

   (1) Unixでは、Python 3.x インタープリタの実行ファイルはデフォルトでは
‘python’ という名前ではインストールされません。同時にインストールされた
Python 2.x 実行ファイルと衝突させないためです。

   (2) https://tiswww.case.edu/php/chet/readline/rltop.html


File: python.info,  Node: 引数の受け渡し,  Next: 対話モード,  Up: インタプリタを起動する

2.2.1.1 引数の受け渡し
......................

スクリプト名と引数を指定してインタプリタを起動した場合、スクリプト名やス
クリプト名以後に指定した引数は、文字列のリストに変換されて ‘sys’ モジュ
ールの ‘argv’ 変数に格納されます。 ‘import sys’ とすることでこのリストに
アクセスできます。 ‘sys.argv’ には少なくとも一つ要素が入っています。スク
リプト名も引数も指定しなければ、 ‘sys.argv[0]’ は空の文字列になります。
スクリプト名の代わりに ‘'-'’ (標準入力を意味します) を指定すると、
‘sys.argv[0]’ は ‘'-'’ になります。 *note -c: 5aa. 'command' を使うと、
‘sys.argv[0]’ は ‘'-c'’ になります。 *note -m: 5ab. 'module' を使った場
合、 ‘sys.argv[0]’ はモジュールのフルパスになります。 Python インタープ
リタは、*note -c: 5aa. 'command' や *note -m: 5ab. 'module' の後ろに指定
したオプションは無視します。無視された引数は、‘sys.argv’ を使って
'command' や 'module' から参照できます。


File: python.info,  Node: 対話モード,  Prev: 引数の受け渡し,  Up: インタプリタを起動する

2.2.1.2 対話モード
..................

インタプリタが命令を端末 (tty) やコマンドプロンプトから読み取っている場
合、インタプリタは '対話モード (interactive mode)' で動作しているといい
ます。 このモードでは、インタプリタは '一次プロンプト (primary prompt)'
を表示して、ユーザにコマンドを入力するよう促します。一次プロンプトは普通
、三つの「大なり記号」 (‘>>>’) です。継続行では、インタプリタは '二次プ
ロンプト (secondary prompt)' を表示します。二次プロンプトは、デフォルト
では三つのドット (‘...’) です。 インタプリタは、最初のプロンプトを出す前
にバージョン番号と著作権表示から始まる起動メッセージを出力します:

     $ python3.13
     Python 3.13 (default, April 4 2023, 09:25:04)
     [GCC 10.2.0] on linux
     Type "help", "copyright", "credits" or "license" for more information.
     >>>

継続行は、複数行の構文を入力するときに使います。例えば、 *note if: 2ca.
文は継続行を使用します

     >>> the_world_is_flat = True
     >>> if the_world_is_flat:
     ...     print("Be careful not to fall off!")
     ...
     Be careful not to fall off!

対話モードについての詳細は *note 対話モード: 155. を参照してください。


File: python.info,  Node: インタプリタとその環境,  Prev: インタプリタを起動する,  Up: Python インタプリタを使う

2.2.2 インタプリタとその環境
----------------------------

* Menu:

* ソースコードの文字コード::


File: python.info,  Node: ソースコードの文字コード,  Up: インタプリタとその環境

2.2.2.1 ソースコードの文字コード
................................

デフォルトでは、Python のソースコードは UTF-8 でエンコードされているもの
として扱われます。UTF-8 では、世界中のほとんどの言語の文字を、同時に文字
列リテラル、識別子、コメントなどに書けます。-- ただし、標準ライブラリは
識別子に ASCII 文字のみを利用していて、その他のポータブルなコードもその
慣習に従うべきです。それらの文字を正しく表示するためには、エディターはそ
のファイルが UTF-8 である事を識別して、そのファイルに含まれている文字を
全てサポートしたフォントを使わなければなりません。

デフォルトエンコーディング以外のエンコーディングを使用するには、ファイル
の '先頭' の行に特別なコメントを追加しなければなりません。書式は以下の通
りです:

     # -*- coding: encoding -*-

'encoding' には、Python が *note codecs: 14. でサポートしている有効なエ
ンコーディングを指定します。

例えば、Windows-1252 エンコーディングを使用するには、ソースコードファイ
ルの先頭行は下記のようにします:

     # -*- coding: cp1252 -*-

ソースコードが *note UNIX "shebang" 行: 1b5b. で始まる場合には、'先頭行'
のルールは当てはまりません。 この場合には、エンコーディングの宣言はファ
イルの2行目に追加します。 例えば以下のようになります:

     #!/usr/bin/env python3
     # -*- coding: cp1252 -*-

脚注
....


File: python.info,  Node: 形式ばらない Python の紹介,  Next: その他の制御フローツール,  Prev: Python インタプリタを使う,  Up: Python チュートリアル

2.3 形式ばらない Python の紹介
==============================

以下のサンプルでは、入力と出力はプロンプト (*note >>>: 152. や *note
...: 153.) の有無で区別します: 例を実際に試す場合は、プロンプトが表示さ
れているときに、サンプル中のプロンプトから後ろの内容全てを入力します。

このマニュアルにあるサンプルの多くは、対話プロンプトで入力されるものでも
コメントを含んでいます。 Python におけるコメント文は、ハッシュ文字 ‘#’ で
始まり、物理行の終わりまで続きます。コメントは行の先頭にも、空白やコード
の後にも書くことができますが、文字列リテラルの内部に置くことはできません
。文字列リテラル中のハッシュ文字はただのハッシュ文字です。コメントはコー
ドを明快にするためのものであり、Pythonはコメントを解釈しません。なので、
サンプルコードを実際に入力して試して見るときは、コメントを省いても大丈夫
です。

いくつかの例です:

     # this is the first comment
     spam = 1  # and this is the second comment
               # ... and now a third!
     text = "# This is not a comment because it's inside quotes."

* Menu:

* Python を電卓として使う::
* プログラミングへの第一歩::


File: python.info,  Node: Python を電卓として使う,  Next: プログラミングへの第一歩,  Up: 形式ばらない Python の紹介

2.3.1 Python を電卓として使う
-----------------------------

それでは、簡単な Python コマンドをいくつか試してみましょう。インタプリタ
を起動して、一次プロンプト、 ‘>>>’ が現れるのを待ちます。 (そう長くはか
からないはずです)

* Menu:

* 数::
* テキスト::
* リスト型 (list): リスト型 list.


File: python.info,  Node: 数,  Next: テキスト,  Up: Python を電卓として使う

2.3.1.1 数
..........

インタプリタは、簡単な電卓のように動作します: 式を入力すると、その結果が
表示されます。 式の文法は素直なものです: 演算子 ‘+’ 、 ‘-’ 、 ‘*’ 、 ‘/’
によって算術演算を行うことができ、丸括弧 (‘()’) をグループ化に使うことが
できます。 例えば:

     >>> 2 + 2
     4
     >>> 50 - 5*6
     20
     >>> (50 - 5*6) / 4
     5.0
     >>> 8 / 5  # division always returns a floating-point number
     1.6

整数 (例えば、 ‘2’ 、 ‘4’ 、 ‘20’) は *note int: 238. 型であり、小数部を
持つ数 (例えば、 ‘5.0’ 、 ‘1.6’) は *note float: 2ce. 型です。数値型につ
いては後のチュートリアルでさらに見ていきます。

除算 (‘/’) は常に浮動小数点数を返します。 ‘//’ 演算子は *note 整数除算:
912. を行い、整数値を返します; 剰余は、‘%’ で求めます。:

     >>> 17 / 3  # classic division returns a float
     5.666666666666667
     >>>
     >>> 17 // 3  # floor division discards the fractional part
     5
     >>> 17 % 3  # the % operator returns the remainder of the division
     2
     >>> 5 * 3 + 2  # floored quotient * divisor + remainder
     17

Python では、冪乗を計算するのに ‘**’ 演算子が使えます (1):

     >>> 5 ** 2  # 5 squared
     25
     >>> 2 ** 7  # 2 to the power of 7
     128

等号 (‘=’) は変数に値を代入するときに使います。代入を行っても、結果は出
力されず、次の入力プロンプトが表示されます。:

     >>> width = 20
     >>> height = 5 * 9
     >>> width * height
     900

変数が "定義" されていない (つまり値が代入されていない) 場合、その変数を
使おうとするとエラーが発生します:

     >>> n  # try to access an undefined variable
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     NameError: name 'n' is not defined

浮動小数点を完全にサポートしています。演算対象の値(オペランド)に複数の型
が入り混じっている場合、演算子は整数のオペランドを浮動小数点型に変換しま
す:

     >>> 4 * 3.75 - 1
     14.0

対話モードでは、最後に表示された結果は変数 ‘_’ に代入されます。このこと
を利用すると、Python を電卓として使うときに、計算を連続して行う作業が多
少楽になります。以下に例を示します:

     >>> tax = 12.5 / 100
     >>> price = 100.50
     >>> price * tax
     12.5625
     >>> price + _
     113.0625
     >>> round(_, 2)
     113.06

この変数には読取りだけを行い、明示的な代入を行ってはいけません -- そんな
ことをすれば、同じ名前で別のローカル変数が生成され、元の特別な動作をする
組み込み変数を覆い隠してしておかしなことになってしまうかもしれません。

*note int: 238. と *note float: 2ce. に加え、 Python は *note Decimal:
27d. や *note Fraction: 1c8. などの他の数値型もサポートしています。
*note 複素数: 1b63. も組み込み型としてサポートしており、 ‘j’ もしくは
‘J’ 接尾辞を使って虚部を示します (例: ‘3+5j’)。

   ---------- Footnotes ----------

   (1) ‘**’ は ‘-’ より優先順位が高いので、‘-3**2’ は ‘-(3**2)’ と解釈さ
れ、計算結果は ‘-9’ になります。これを避けて ‘9’ を得たければ、‘(-3)**2’
と書きます。


File: python.info,  Node: テキスト,  Next: リスト型 list,  Prev: 数,  Up: Python を電卓として使う

2.3.1.2 テキスト
................

Python は数値だけでなくテキスト (いわゆる「文字列」である *note str:
418. 型によって表現されます) を扱うことができます。 ‘!’ のような文字や
‘rabbit’ のような単語、 ‘Paris’ のような名前、 ‘Got your back.’ ような文
もすべて文字列です。 文字列はシングルクォート (‘'...'’) またはダブルクォ
ート (‘"..."’) で囲み、どちらを使っても違いはありません (1) 。

     >>> 'spam eggs'  # single quotes
     'spam eggs'
     >>> "Paris rabbit got your back :)! Yay!"  # double quotes
     'Paris rabbit got your back :)! Yay!'
     >>> '1975'  # digits and numerals enclosed in quotes are also strings
     '1975'

クォートの中でクォートを使いたい場合、 ‘\’ を前に付け加えることで「エス
ケープ」をする必要があります。 もしくは、文字列で使用したいクォートとは
別の方のクォートで囲むこともできます。

     >>> 'doesn\'t'  # use \' to escape the single quote...
     "doesn't"
     >>> "doesn't"  # ...or use double quotes instead
     "doesn't"
     >>> '"Yes," they said.'
     '"Yes," they said.'
     >>> "\"Yes,\" they said."
     '"Yes," they said.'
     >>> '"Isn\'t," they said.'
     '"Isn\'t," they said.'

Python シェルでは、文字列を定義するときと文字列が出力されるときでは見え
方が異なることがあります。 *note print(): f42. 関数を使うと、両端のクォ
ートがなくなり、エスケープされた文字や特殊文字が表示されるため、より読み
やすい形で出力できます。

     >>> s = 'First line.\nSecond line.'  # \n means newline
     >>> s  # without print(), special characters are included in the string
     'First line.\nSecond line.'
     >>> print(s)  # with print(), special characters are interpreted, so \n produces new line
     First line.
     Second line.

‘\’ に続く文字を特殊文字として解釈されたくない場合は、最初の引用符の前に
‘r’ を付けた 'raw strings' が使えます:

     >>> print('C:\some\name')  # here \n means newline!
     C:\some
     ame
     >>> print(r'C:\some\name')  # note the r before the quote
     C:\some\name

raw文字列には微妙な面があります: raw文字列は奇数個の'''' 文字では終了で
きません。詳細と解決方法については *note the FAQ entry: 1b66. を参照して
ください。

String literals can span multiple lines.  One way is using
triple-quotes: ‘"""..."""’ or ‘'''...'''’.  End of lines are
automatically included in the string, but it's possible to prevent this
by adding a ‘\’ at the end of the line.  In the following example, the
initial newline is not included:

     >>> print("""\
     ... Usage: thingy [OPTIONS]
     ...      -h                        Display this usage message
     ...      -H hostname               Hostname to connect to
     ... """)
     Usage: thingy [OPTIONS]
          -h                        Display this usage message
          -H hostname               Hostname to connect to

     >>>

文字列は ‘+’ 演算子で連結させる (くっつけて一つにする) ことができ、‘*’ 演
算子で反復させることができます:

     >>> # 3 times 'un', followed by 'ium'
     >>> 3 * 'un' + 'ium'
     'unununium'

連続して並んでいる複数の '文字列リテラル' (つまり、引用符に囲われた文字
列) は、自動的に連結されます。

     >>> 'Py' 'thon'
     'Python'

この機能は、長い文字列を改行したいときにとても役に立ちます:

     >>> text = ('Put several strings within parentheses '
     ...         'to have them joined together.')
     >>> text
     'Put several strings within parentheses to have them joined together.'

これは 2 つのリテラルどうしに対してのみ働き、変数や式には働きません:

     >>> prefix = 'Py'
     >>> prefix 'thon'  # can't concatenate a variable and a string literal
       File "<stdin>", line 1
         prefix 'thon'
                ^^^^^^
     SyntaxError: invalid syntax
     >>> ('un' * 3) 'ium'
       File "<stdin>", line 1
         ('un' * 3) 'ium'
                    ^^^^^
     SyntaxError: invalid syntax

変数どうしや変数とリテラルを連結したい場合は、‘+’ を使ってください:

     >>> prefix + 'thon'
     'Python'

文字列は 'インデックス' (添字) を指定して文字を取得できます。最初の文字
のインデックスは 0 になります。文字を表す、専用のデータ型は用意されてい
ません; 文字とは、単に長さが 1 の文字列です:

     >>> word = 'Python'
     >>> word[0]  # character in position 0
     'P'
     >>> word[5]  # character in position 5
     'n'

インデックスには、負の値も指定できまます。この場合、右から数えていきます
:

     >>> word[-1]  # last character
     'n'
     >>> word[-2]  # second-last character
     'o'
     >>> word[-6]
     'P'

-0 は 0 と区別できないので、負のインデックスは -1 から始まります。

インデクス表記に加え、 'スライス' もサポートされています。インデクス表記
は個々の文字を取得するのに使いますが、 'スライス' を使うと部分文字列を取
得することができます:

     >>> word[0:2]  # characters from position 0 (included) to 2 (excluded)
     'Py'
     >>> word[2:5]  # characters from position 2 (included) to 5 (excluded)
     'tho'

スライスのインデックスには、便利なデフォルト値があります; 最初のインデッ
クスを省略すると、0 と見なされます。二番め のインデックスを省略すると、
スライスする文字列のサイズとみなされます。

     >>> word[:2]   # character from the beginning to position 2 (excluded)
     'Py'
     >>> word[4:]   # characters from position 4 (included) to the end
     'on'
     >>> word[-2:]  # characters from the second-last (included) to the end
     'on'

開始値は常に含まれ、終了値は常に含まれないことに注意してください。なので
‘s[:i] + s[i:]’ は常に ‘s’ と等しくなります:

     >>> word[:2] + word[2:]
     'Python'
     >>> word[:4] + word[4:]
     'Python'

スライスの使い方をおぼえる良い方法は、インデックスが文字と文字の 'あいだ
(between)' を指しており、最初の文字の左端が 0 になっていると考えることで
す。そうすると、 'n' 文字からなる文字列中の最後の文字の右端はインデック
ス 'n' となります。例えばこうです:

      +---+---+---+---+---+---+
      | P | y | t | h | o | n |
      +---+---+---+---+---+---+
      0   1   2   3   4   5   6
     -6  -5  -4  -3  -2  -1

1行目の数字は文字列の 0 から 6 までのインデックスの位置を示しています;
2行目は対応する負のインデックスを示しています。'i' から 'j' までのスライ
スは、それぞれ 'i' と付いた境界から 'j' と付いた境界までの全ての文字から
成っています。

正のインデックスの場合、スライスされたシーケンスの長さは、スライスの両端
のインデックスが範囲内にあるかぎり、インデックス間の差になります。例えば
、 ‘word[1:3]’ の長さは 2 になります。

大き過ぎるインデックスを使おうとするとエラーが発生します:

     >>> word[42]  # the word only has 6 characters
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     IndexError: string index out of range

しかし、スライスで範囲外のインデックスを使ったときは、上手く対応して扱っ
てくれます:

     >>> word[4:42]
     'on'
     >>> word[42:]
     ''

Python の文字列は変更できません - つまり *note 不変: 1272. です。従って
、文字列のインデックスで指定したある場所に代入を行うとエラーが発生します
:

     >>> word[0] = 'J'
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: 'str' object does not support item assignment
     >>> word[2:] = 'py'
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: 'str' object does not support item assignment

元の文字列と別の文字列が必要な場合は、新しく文字列を作成してください:

     >>> 'J' + word[1:]
     'Jython'
     >>> word[:2] + 'py'
     'Pypy'

組込み関数 *note len(): 5fa. は文字列の長さ (length) を返します:

     >>> s = 'supercalifragilisticexpialidocious'
     >>> len(s)
     34

参考
....

*note テキストシーケンス型 -- str: 1b67.

     文字列は代表的な 'シーケンス型' で、シーケンス型でサポートされてい
     る共通の操作をサポートしています。

*note 文字列メソッド: 1b68.

     文字列は、基本的な変換や検索を行うための数多くのメソッドをサポート
     しています。

*note f-strings: 977.

     式の埋め込みをサポートした文字列リテラル

*note 書式指定文字列の文法: 1358.

     *note str.format(): 5ed. を使った文字列のフォーマットについての情報
     があります。

*note printf 形式の文字列書式化: 698.

     文字列が ‘%’ 演算子の左オペランドである場合に呼び出される古いフォー
     マット操作について、詳しく記述されています。

   ---------- Footnotes ----------

   (1) 他の言語と違って、‘\n’ のような特殊文字は、単引用符 (‘'...'’) と
二重引用符 (‘"..."’) で同じ意味を持ちます。両者の唯一の違いは、単引用符
で囲われた箇所では ‘"’ をエスケープする必要がない (ただし ‘\'’ はエスケ
ープする必要がある) ことで、逆もまた同様です。


File: python.info,  Node: リスト型 list,  Prev: テキスト,  Up: Python を電卓として使う

2.3.1.3 リスト型 (list)
.......................

Pythonは多くの '複合 (compound)' データ型を備えており、複数の値をまとめ
るのに使われます。最も汎用性が高いのは 'リスト (list)' で、コンマ区切り
の値 (要素) の並びを角括弧で囲んだものとして書き表されます。リストは異な
る型の要素を含むこともありますが、通常は同じ型の要素のみを持ちます。

     >>> squares = [1, 4, 9, 16, 25]
     >>> squares
     [1, 4, 9, 16, 25]

文字列 (や他の全ての組み込みの *note シーケンス: 4be. 型) のように、リス
トはインデックスやスライスができます:

     >>> squares[0]  # indexing returns the item
     1
     >>> squares[-1]
     25
     >>> squares[-3:]  # slicing returns a new list
     [9, 16, 25]

リストは、リストの連結などもサポートしています:

     >>> squares + [36, 49, 64, 81, 100]
     [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

*note 不変: 1272. な文字列とは違って、リストは *note 可変: 1273. 型です
ので、要素を入れ替えられます:

     >>> cubes = [1, 8, 27, 65, 125]  # something's wrong here
     >>> 4 ** 3  # the cube of 4 is 64, not 65!
     64
     >>> cubes[3] = 64  # replace the wrong value
     >>> cubes
     [1, 8, 27, 64, 125]

‘list.append()’ を使って、リストの末尾に新しい要素を追加できます (このメ
ソッドについては後で詳しく見ていきます):

     >>> cubes.append(216)  # add the cube of 6
     >>> cubes.append(7 ** 3)  # and the cube of 7
     >>> cubes
     [1, 8, 27, 64, 125, 216, 343]

単純な代入ではPythonは決してデータをコピーしません。リストを変数に代入す
ると、その変数は '既存のリスト' を参照します。ある変数を通してリストに任
意の変更を行うと、そのリストを参照したすべての他の変数を通して確認できま
す。:

     >>> rgb = ["Red", "Green", "Blue"]
     >>> rgba = rgb
     >>> id(rgb) == id(rgba)  # they reference the same object
     True
     >>> rgba.append("Alph")
     >>> rgb
     ["Red", "Green", "Blue", "Alph"]

全てのスライス操作は、指定された要素を含む新しいリストを返します。例えば
、次のスライスは、リストの *note 浅いコピー: 1b6b. を返します。:

     >>> correct_rgba = rgba[:]
     >>> correct_rgba[-1] = "Alpha"
     >>> correct_rgba
     ["Red", "Green", "Blue", "Alpha"]
     >>> rgba
     ["Red", "Green", "Blue", "Alph"]

スライスには、代入もできます。スライスの代入で、リストのサイズを変更した
り、全てを削除したりもできます:

     >>> letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
     >>> letters
     ['a', 'b', 'c', 'd', 'e', 'f', 'g']
     >>> # replace some values
     >>> letters[2:5] = ['C', 'D', 'E']
     >>> letters
     ['a', 'b', 'C', 'D', 'E', 'f', 'g']
     >>> # now remove them
     >>> letters[2:5] = []
     >>> letters
     ['a', 'b', 'f', 'g']
     >>> # clear the list by replacing all the elements with an empty list
     >>> letters[:] = []
     >>> letters
     []

組込み関数 *note len(): 5fa. はリストにも使えます:

     >>> letters = ['a', 'b', 'c', 'd']
     >>> len(letters)
     4

リストを入れ子 (ほかのリストを含むリストを造る) にできます。例えば:

     >>> a = ['a', 'b', 'c']
     >>> n = [1, 2, 3]
     >>> x = [a, n]
     >>> x
     [['a', 'b', 'c'], [1, 2, 3]]
     >>> x[0]
     ['a', 'b', 'c']
     >>> x[0][1]
     'b'


File: python.info,  Node: プログラミングへの第一歩,  Prev: Python を電卓として使う,  Up: 形式ばらない Python の紹介

2.3.2 プログラミングへの第一歩
------------------------------

もちろん、2 たす 2 よりももっと複雑な課題にも Python を使えます。 例えば
、Fibonacci series(1) の先頭の部分列は次のように書けます:

     >>> # Fibonacci series:
     >>> # the sum of two elements defines the next
     >>> a, b = 0, 1
     >>> while a < 10:
     ...     print(a)
     ...     a, b = b, a+b
     ...
     0
     1
     1
     2
     3
     5
     8

上の例では、いくつか新しい機能を使用しています。

   * 最初の行には '複数同時の代入 (multiple assignment)' が入っています:
     変数 ‘a’ と ‘b’ は、それぞれ同時に新しい値 0 と 1 になっています。
     この代入は、最後の行でも使われています。代入文では、まず右辺の式が
     すべて評価され、次に代入が行われます。右辺の式は、左から右へと順番
     に評価されます。

   * *note while: 1b6e. は、条件 (ここでは '' a < 10'') が真である限り実
     行を繰り返し (ループし) ます。Python では、C 言語と同様に、ゼロでな
     い整数値は真となり、ゼロは偽です。条件式には、文字列値やリスト値な
     ども使えます。それ以外のシーケンスも、条件式として使用できます。長
     さが 1 以上のシーケンスは真で、空のシーケンスは偽になります。サンプ
     ルで使われている条件テストはシンプルな比較です。標準的な比較演算子
     は C 言語と同様です: すなわち、 ‘<’ (より小さい)、 ‘>’ (より大きい
     )、 ‘==’ (等しい)、 ‘<=’ (より小さいか等しい)、 ‘>=’ (より大きいか
     等しい)、および ‘!=’ (等しくない)、です。

   * ループの '本体 (body)' は、 'インデント (indent, 字下げ)' されてい
     ます: インデントは Python において、実行文をグループにまとめる方法
     です。対話的プロンプトでは、インデントされた各行を入力するにはタブ
     や (複数個の) スペースを使わなければなりません。実用的には、もっと
     複雑な処理を入力する場合はテキストエディタを使うことになるでしょう
     。 ほとんどのテキストエディタは、自動インデント機能を持っています。
     複合文を対話的に入力するときには、入力完了のしるしとして最後に空行
     を入力します。これは、パーザはどれが最後の行を入力なのか、判断でき
     ないためです。基本的なブロック内では、全ての行は同じだけインデント
     されていなければならないので注意してください。

   * *note print(): f42. 関数は、与えられた引数の値を書き出します。これ
     は (前に電卓の例でやったような) 単に出力したい式を書くのとは、複数
     の引数や浮動小数点量や文字列に対する扱い方が違います。*note
     print(): f42. 関数では、文字列は引用符無しで出力され、要素の間に空
     白が挿入されて、このように出力の書式が整えられます:

          >>> i = 256*256
          >>> print('The value of i is', i)
          The value of i is 65536

     キーワード引数 'end' を使うと、出力の末尾に改行文字を出力しないよう
     にしたり、別の文字列を末尾に出力したりできます:

          >>> a, b = 0, 1
          >>> while a < 1000:
          ...     print(a, end=',')
          ...     a, b = b, a+b
          ...
          0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,

脚注
....

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Fibonacci_sequence


File: python.info,  Node: その他の制御フローツール,  Next: データ構造,  Prev: 形式ばらない Python の紹介,  Up: Python チュートリアル

2.4 その他の制御フローツール
============================

前章で紹介した *note while: 1b6e. 文の他にも、 Python にはいくつか制御フ
ローツールがあり、本章で説明します。

* Menu:

* if 文::
* for 文::
* range() 関数: range 関数.
* break and continue Statements::
* else Clauses on Loops::
* pass 文::
* match 文::
* 関数を定義する::
* 関数定義についてもう少し::
* 間奏曲; コーディングスタイル: 間奏曲 コーディングスタイル.


File: python.info,  Node: if 文,  Next: for 文,  Up: その他の制御フローツール

2.4.1 ‘if’ 文
-------------

おそらく最もおなじみの文型は *note if: 2ca. 文でしょう。例えば:

     >>> x = int(input("Please enter an integer: "))
     Please enter an integer: 42
     >>> if x < 0:
     ...     x = 0
     ...     print('Negative changed to zero')
     ... elif x == 0:
     ...     print('Zero')
     ... elif x == 1:
     ...     print('Single')
     ... else:
     ...     print('More')
     ...
     More

ゼロ個以上の *note elif: 1b74. 部を使うことができ、 *note else: 171. 部
を付けることもできます。キーワード '‘elif’' は 'else if' を短くしたもの
で、過剰なインデントを避けるのに役立ちます。一連の ‘if’ ...  ‘elif’ ...
‘elif’ ...  は、他の言語における ‘switch’ 文や ‘case’ 文の代用となります
。

いくつかの定数と同じ値かを比較する場合や、特定の型や属性かを確認する場合
には、‘match’ 文が便利です。詳細は *note match 文: 1b75. を参照してくだ
さい。


File: python.info,  Node: for 文,  Next: range 関数,  Prev: if 文,  Up: その他の制御フローツール

2.4.2 ‘for’ 文
--------------

Python の *note for: 2c9. 文は、読者が C 言語や Pascal 言語で使いなれて
いるかもしれない *note for: 2c9. 文とは少し違います。 (Pascal のように)
常に算術型の数列にわたる反復を行ったり、 (C のように) 繰返しステップと停
止条件を両方ともユーザが定義できるようにするのとは違い、Python の ‘for’
文は、任意のシーケンス型 (リストまたは文字列) にわたって反復を行います。
反復の順番はシーケンス中に要素が現れる順番です。例えば:

     >>> # 文字列計測:
     >>> words = ['cat', 'window', 'defenestrate']
     >>> for w in words:
     ...     print(w, len(w))
     ...
     cat 3
     window 6
     defenestrate 12

コレクションオブジェクトの値を反復処理をしているときに、そのコレクション
オブジェクトを変更するコードは理解するのが面倒になり得ます。 そうするよ
りも、コレクションオブジェクトのコピーに対して反復処理をするか、新しいコ
レクションオブジェクトを作成する方が通常は理解しやすいです:

     # コレクション作成
     users = {'Hans': 'active', 'Éléonore': 'inactive', '景太郎': 'active'}

     # 方針:  コピーを反復
     for user, status in users.copy().items():
         if status == 'inactive':
             del users[user]

     # 方針:  新コレクション作成
     active_users = {}
     for user, status in users.items():
         if status == 'active':
             active_users[user] = status


File: python.info,  Node: range 関数,  Next: break and continue Statements,  Prev: for 文,  Up: その他の制御フローツール

2.4.3 ‘range()’ 関数
--------------------

数列にわたって反復を行う必要がある場合、組み込み関数 *note range(): 911.
が便利です。この関数は算術型の数列を生成します:

     >>> for i in range(5):
     ...     print(i)
     ...
     0
     1
     2
     3
     4

指定した終端値は生成されるシーケンスには入りません。‘range(10)’ は 10 個
の値を生成し、長さ 10 のシーケンスにおける各項目のインデクスとなります。
range を別の数から開始したり、他の増加量 (負でも; 増加量は時に 'ステップ
(step)' と呼ばれることもあります) を指定することもできます:

     >>> list(range(5, 10))
     [5, 6, 7, 8, 9]

     >>> list(range(0, 10, 3))
     [0, 3, 6, 9]

     >>> list(range(-10, -100, -30))
     [-10, -40, -70]

あるシーケンスにわたってインデクスで反復を行うには、 *note range(): 911.
と *note len(): 5fa. を次のように組み合わせられます:

     >>> a = ['Mary', 'had', 'a', 'little', 'lamb']
     >>> for i in range(len(a)):
     ...     print(i, a[i])
     ...
     0 Mary
     1 had
     2 a
     3 little
     4 lamb

しかし、多くの場合は *note enumerate(): 1424. 関数を使う方が便利です。
*note ループのテクニック: 1b7a. を参照してください。

range を直接出力すると変なことになります:

     >>> range(10)
     range(0, 10)

*note range(): 911. が返すオブジェクトは、いろいろな点でリストであるかの
ように振る舞いますが、本当はリストではありません。これは、イテレートした
時に望んだ数列の連続した要素を返すオブジェクトです。しかし実際にリストを
作るわけではないので、スペースの節約になります。

このようなオブジェクトは *note イテラブル: 10ad. と呼ばれます。 これらは
関数や構成物のターゲットとして、あるだけの項目を逐次与えるのに適していま
す。 *note for: 2c9. 文がそのような構成物であることはすでに見てきており
、イテラブルを受け取る関数の例には *note sum(): 437. があります:

     >>> sum(range(4))  # 0 + 1 + 2 + 3
     6

この後には、イテラブルを返したりイテラブルを引数で受け取るいくつかの関数
が出てきます。 *note データ構造: 1b7b. では、 *note list(): 5dc. につい
てより詳しく説明します。


File: python.info,  Node: break and continue Statements,  Next: else Clauses on Loops,  Prev: range 関数,  Up: その他の制御フローツール

2.4.4 ‘break’ and ‘continue’ Statements
---------------------------------------

The *note break: a77. statement breaks out of the innermost enclosing
*note for: 2c9. or *note while: 1b6e. loop:

     >>> for n in range(2, 10):
     ...     for x in range(2, n):
     ...         if n % x == 0:
     ...             print(f"{n} equals {x} * {n//x}")
     ...             break
     ...
     4 equals 2 * 2
     6 equals 2 * 3
     8 equals 2 * 4
     9 equals 3 * 3

The *note continue: 998. statement continues with the next iteration of
the loop:

     >>> for num in range(2, 10):
     ...     if num % 2 == 0:
     ...         print(f"Found an even number {num}")
     ...         continue
     ...     print(f"Found an odd number {num}")
     ...
     Found an even number 2
     Found an odd number 3
     Found an even number 4
     Found an odd number 5
     Found an even number 6
     Found an odd number 7
     Found an even number 8
     Found an odd number 9


File: python.info,  Node: else Clauses on Loops,  Next: pass 文,  Prev: break and continue Statements,  Up: その他の制御フローツール

2.4.5 ‘else’ Clauses on Loops
-----------------------------

In a ‘for’ or ‘while’ loop the ‘break’ statement may be paired with an
‘else’ clause.  If the loop finishes without executing the ‘break’, the
‘else’ clause executes.

In a *note for: 2c9. loop, the ‘else’ clause is executed after the loop
finishes its final iteration, that is, if no break occurred.

*note while: 1b6e. 文の場合は、ループ条件が偽となったあとに実行されます
。

In either kind of loop, the ‘else’ clause is 'not' executed if the loop
was terminated by a *note break: a77.  Of course, other ways of ending
the loop early, such as a *note return: 99c. or a raised exception, will
also skip execution of the *note else: 171. clause.

その例として、素数を探索する ‘for’ 文を以下に示します:

     >>> for n in range(2, 10):
     ...     for x in range(2, n):
     ...         if n % x == 0:
     ...             print(n, 'equals', x, '*', n//x)
     ...             break
     ...     else:
     ...         # loop fell through without finding a factor
     ...         print(n, 'is a prime number')
     ...
     2 is a prime number
     3 is a prime number
     4 equals 2 * 2
     5 is a prime number
     6 equals 2 * 3
     7 is a prime number
     8 equals 2 * 4
     9 equals 3 * 3

(Yes, this is the correct code.  Look closely: the ‘else’ clause belongs
to the ‘for’ loop, 'not' the ‘if’ statement.)

One way to think of the else clause is to imagine it paired with the
‘if’ inside the loop.  As the loop executes, it will run a sequence like
if/if/if/else.  The ‘if’ is inside the loop, encountered a number of
times.  If the condition is ever true, a ‘break’ will happen.  If the
condition is never true, the ‘else’ clause outside the loop will
execute.

When used with a loop, the ‘else’ clause has more in common with the
‘else’ clause of a *note try: 6b4. statement than it does with that of
‘if’ statements: a ‘try’ statement's ‘else’ clause runs when no
exception occurs, and a loop's ‘else’ clause runs when no ‘break’
occurs.  For more on the ‘try’ statement and exceptions, see *note
例外を処理する: 1b81.


File: python.info,  Node: pass 文,  Next: match 文,  Prev: else Clauses on Loops,  Up: その他の制御フローツール

2.4.6 ‘pass’ 文
---------------

*note pass: 1b84. 文は何もしません。 *note pass: 1b84. は、文を書くこと
が構文上要求されているが、プログラム上何の動作もする必要がない時に使われ
ます:

     >>> while True:
     ...     pass  # Busy-wait for keyboard interrupt (Ctrl+C)
     ...

これは最小のクラスを作るときによく使われる方法です:

     >>> class MyEmptyClass:
     ...     pass
     ...

*note pass: 1b84. のもう 1 つの使い道は、新しいコードを書いているときの
関数や条件文の仮置きの本体としてです。こうすることで、より抽象的なレベル
で考え続けられます。 ‘pass’ は何事も無く無視されます

     >>> def initlog(*args):
     ...     pass   # Remember to implement this!
     ...


File: python.info,  Node: match 文,  Next: 関数を定義する,  Prev: pass 文,  Up: その他の制御フローツール

2.4.7 ‘match’ 文
----------------

*note match: 7d8. 文は1つの式を指定し、その値と次に続く1つ以上のcaseブロ
ックに指定されたパターンを比較します。この機能はCやJava、JavaScript(や他
の多数の言語)のswitch文と表面的には似ていますが、RustやHaskellのパターン
マッチングにより似ています。最初にマッチしたパターンのみが実行され、コン
ポーネント(シーケンスの要素やオブジェクトの属性)から値を取り出して変数に
代入することもできます。

最も単純な形式は、対象の値に対して1つ以上のリテラルです:

     def http_error(status):
         match status:
             case 400:
                 return "Bad request"
             case 404:
                 return "Not found"
             case 418:
                 return "I'm a teapot"
             case _:
                 return "Something's wrong with the internet"

最後のブロックについて: 変数名 ‘_’ は 'ワイルドカード' の働きをし、マッ
チに絶対失敗しません。マッチするケースがない場合は、そのブロックも実行さ
れません。

複数のリテラルを ‘|’ ("or")を使用して組み合わせて1つのパターンにできます
:

     case 401 | 403 | 404:
         return "Not allowed"

パターンはアンパック代入ができ、変数に結びつけられます:

     # point is an (x, y) tuple
     match point:
         case (0, 0):
             print("Origin")
         case (0, y):
             print(f"Y={y}")
         case (x, 0):
             print(f"X={x}")
         case (x, y):
             print(f"X={x}, Y={y}")
         case _:
             raise ValueError("Not a point")

このコードは注意して見てください！ 最初のパターンには2つのリテラルがあり
、上で示したリテラルパターンの拡張と考えることができます。 しかし次の2つ
のパターンはリテラルと変数の組み合わせのため、対象(‘point’)から値を取り
出して変数に '結びつけ' ます。 4番目のパターンは2つの値を取り込みます。
これは、アンパック代入 ‘(x, y) = point’ と概念的に似ています。

データを構造化するためにクラスを使っている場合は、クラス名の後ろにコンス
トラクターのように引数のリストを指定できます。属性の値は変数に取り込まれ
ます。

     class Point:
         def __init__(self, x, y):
             self.x = x
             self.y = y

     def where_is(point):
         match point:
             case Point(x=0, y=0):
                 print("Origin")
             case Point(x=0, y=y):
                 print(f"Y={y}")
             case Point(x=x, y=0):
                 print(f"X={x}")
             case Point():
                 print("Somewhere else")
             case _:
                 print("Not a point")

いくつかの組み込みクラスでは位置引数が使用でき、属性の順番を提供します
(例: データクラス)。クラスの ‘__match_args__’ 特殊属性によって、パターン
の中で属性の明確な位置を定義することもできます。("x", "y")が設定された場
合、以下のすべてのパターンは等価です(すべて属性 ‘y’ が ‘var’ 変数に結び
つけられます):

     Point(1, var)
     Point(1, y=var)
     Point(x=1, y=var)
     Point(y=var, x=1)

おすすめのパターンの読み方は、パターンが、代入文の左辺に配置するものを拡
張した形式であるとみなすことです。 これにより、どの変数になにが代入され
るかが分かります。 単独の名前（上記の ‘var’ など）だけがマッチ文で値が代
入されます。ドット付きの名前（‘foo.bar’ など）、属性名（上記の ‘x=’、
‘y=’ など ）、クラス名（名前の後ろの "(...)"  によって判別される。上記の
‘Point’ など）には値は代入されません。

パターンはいくらでも入れ子 (ネスト) にすることができます。例えば、
‘__match_args__’ を追加した Point クラスのリストに対して次のようにマッチ
を行うことができます:

     class Point:
         __match_args__ = ('x', 'y')
         def __init__(self, x, y):
             self.x = x
             self.y = y

     match points:
         case []:
             print("No points")
         case [Point(0, 0)]:
             print("The origin")
         case [Point(x, y)]:
             print(f"Single point {x}, {y}")
         case [Point(0, y1), Point(0, y2)]:
             print(f"Two on the Y axis at {y1}, {y2}")
         case _:
             print("Something else")

パターンに ‘if’ 節を追加できます。これは "ガード" と呼ばれます。ガードが
falseの場合、‘match’ は次のcaseブロックの処理に移動します。ガードを評価
する前に値が取り込まれることに注意してください:

     match point:
         case Point(x, y) if x == y:
             print(f"Y=X at {x}")
         case Point(x, y):
             print(f"Not on the diagonal")

この文のその他のいくつか重要な特徴:

   - アンパック代入のように、タプルとリストのパターンでは正確に同じ意味
     で、任意のシーケンスと一致します。重要な例外として、イテレーターや
     文字列ではマッチしません。

   - シーケンスパターンは拡張アンパックをサポート: ‘[x, y, *rest]’ と
     ‘(x, y, *rest)’ はアンパック代入として同じように動作します。‘*’ の
     あとの変数名は ‘_’ でもよく、そのため ‘(x, y, *_)’ は最低でも2つの
     アイテムを持つシーケンスにマッチし、残りのアイテムは変数に結びつけ
     られません。

   - マッピングパターン: ‘{"bandwidth": b, "latency": l}’ は辞書から
     ‘"bandwidth"’ と ‘"latency"’ の値を取り込みます。シーケンスパターン
     とは異なり、それ以外のキーは無視されます。アンパッキングのような
     ‘**rest’ もサポートされています（しかし、 ‘**_’ は冗長なため禁止さ
     れています）。

   - サブパターンでは ‘as’ キーワードを使用して値を取り込みます:

          case (Point(x1, y1), Point(x2, y2) as p2): ...

     この例では入力から2番目の要素を ‘p2’ として取り込みます（入力が2つ
     のポイントのシーケンスである場合）

   - ほとんどのリテラルは同一性を比較しますが、シングルトンの ‘True’、
     ‘False’、‘None’ では識別値を比較します。

   - パターンには名前を付けた定数が使用できます。値を取り込む変数として
     と解釈することを防ぐために、ドット付きの変数名にする必要があります
     。

          from enum import Enum
          class Color(Enum):
              RED = 'red'
              GREEN = 'green'
              BLUE = 'blue'

          color = Color(input("Enter your choice of 'red', 'blue' or 'green': "))

          match color:
              case Color.RED:
                  print("I see red!")
              case Color.GREEN:
                  print("Grass is green")
              case Color.BLUE:
                  print("I'm feeling the blues :(")

より詳細な説明と追加の例は PEP 636(1) にチュートリアル形式で記述してあり
ます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0636/


File: python.info,  Node: 関数を定義する,  Next: 関数定義についてもう少し,  Prev: match 文,  Up: その他の制御フローツール

2.4.8 関数を定義する
--------------------

フィボナッチ数列 (Fibonacci series) を任意の上限値まで書き出すような関数
を作成できます:

     >>> def fib(n):    # write Fibonacci series less than n
     ...     """Print a Fibonacci series less than n."""
     ...     a, b = 0, 1
     ...     while a < n:
     ...         print(a, end=' ')
     ...         a, b = b, a+b
     ...     print()
     ...
     >>> # Now call the function we just defined:
     >>> fib(2000)
     0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597

*note def: 13ff. は関数の '定義 (definition)' を導くキーワードです。
*note def: 13ff. の後には、関数名と仮引数を丸括弧で囲んだリストを続けな
ければなりません。関数の実体を構成する実行文は次の行から始め、インデント
されていなければなりません。

関数の本体の記述する文の最初の行は文字列リテラルにすることもできます。そ
の場合、この文字列は関数のドキュメンテーション文字列 (documentation
string)、または 'docstring' と呼ばれます。 (docstring については *note
ドキュメンテーション文字列: 1b88. でさらに扱っています。) ドキュメンテー
ション文字列を使ったツールには、オンライン文書や印刷文書を自動的に生成し
たり、ユーザが対話的にコードから直接閲覧できるようにするものがあります。
自分が書くコードにドキュメンテーション文字列を入れるのはよい習慣です。書
く癖をつけてください。

関数を '実行 (execution)' するとき、関数のローカル変数のために使われる新
たなシンボルテーブル (symbol table) が用意されます。 もっと正確にいうと
、関数内で変数への代入を行うと、その値はすべてこのローカルなシンボルテー
ブルに記憶されます。 一方、変数の参照を行うと、まずローカルなシンボルテ
ーブルが検索され、次にさらに外側の関数のローカルなシンボルテーブルを検索
し、その後グローバルなシンボルテーブルを調べ、最後に組み込みの名前テーブ
ルを調べます。 従って、関数の中では (グローバル変数が *note global: 16f.
文で指定されていたり、外側の関数の変数が *note nonlocal: 1279. 文で指定
されていない限り) グローバル変数や外側の関数の変数に直接値を代入できませ
んが、参照することはできます。

関数を呼び出す際の実際の引数 (実引数) は、関数が呼び出されるときに関数の
ローカルなシンボルテーブル内に取り込まれます。そうすることで、実引数は
'値渡し (call by value)' で関数に渡されることになります (ここでの '値
(value)' とは常にオブジェクトへの '参照(reference)' をいい、オブジェクト
の値そのものではありません) (1)。ある関数がほかの関数を呼び出すときや、
自身を再帰的に呼び出すときには、新たな呼び出しのためにローカルなシンボル
テーブルが新たに作成されます。

関数の定義を行うと、関数名は関数オブジェクトとともに現在のシンボルテーブ
ル内に取り入れられます。インタープリタはその名前が指すオブジェクトをユー
ザ定義関数 (user-defined function) として認識します。他の名前も同じ関数
オブジェクトを指すことができ、またその関数にアクセスするために使用するこ
とができます:

     >>> fib
     <function fib at 10042ed0>
     >>> f = fib
     >>> f(100)
     0 1 1 2 3 5 8 13 21 34 55 89

他の言語出身の人からは、 ‘fib’ は値を返さないので関数ではなく手続き
(procedure) だと異論があるかもしれませんね。技術的に言えば、実際には
*note return: 99c. 文を持たない関数もややつまらない値ですが値を返してい
ます。この値は ‘None’ と呼ばれます (これは組み込みの名前です)。 ‘None’ だ
けを書き出そうとすると、インタプリタは通常出力を抑制します。本当に出力し
たいのなら、以下のように *note print(): f42. を使うと見ることができます:

     >>> fib(0)
     >>> print(fib(0))
     None

フィボナッチ数列の数からなるリストを出力する代わりに、値を返すような関数
を書くのは簡単です:

     >>> def fib2(n):  # return Fibonacci series up to n
     ...     """Return a list containing the Fibonacci series up to n."""
     ...     result = []
     ...     a, b = 0, 1
     ...     while a < n:
     ...         result.append(a)    # see below
     ...         a, b = b, a+b
     ...     return result
     ...
     >>> f100 = fib2(100)    # call it
     >>> f100                # write the result
     [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

この例は Python の新しい機能を示しています:

   * *note return: 99c. 文では、関数から一つ値を返します。 ‘return’ の引
     数となる式がない場合、 ‘None’ が返ります。関数が終了したときにも
     ‘None’ が返ります。

   * ‘result.append(a)’ という文で、 ‘result’ オブジェクトの 'メソッド'
     が呼び出されます。メソッドとは、オブジェクトに「属する」関数のこと
     であり、 ‘obj.methodname’ と表されます。ここで、 ‘obj’ は何らかのオ
     ブジェクト (式の場合もあります) であり、 ‘methodname’ はそのオブジ
     ェクトの型で定義されたメソッド名です。色々な型がそれぞれ独自のメソ
     ッドを定義しています。異なる型が同じ名前のメソッドを持つことも可能
     であり、どちらの方のものであるかという曖昧さは生まれません。
     (>>*<<クラス*を使って独自の型やメソッドを自分で定義することもできま
     す。参照: *note クラス: 1b89.) 例にある ‘append()’ メソッドは、リス
     トオブジェクトに対して定義されているもので、リストの末尾に新しい要
     素を追加します。この例では ‘result = result + [a]’ と等価ですが、計
     算効率の上ではベターです。

   ---------- Footnotes ----------

   (1) 実のところ、'オブジェクトへの参照渡し (call by object reference)'
という言ったほうがより正確です。というのは、変更可能なオブジェクトが渡さ
れると、呼び出された側の関数がオブジェクトに行った変更 (例えばリストに挿
入された要素) はすべて、関数の呼び出し側にも反映されるからです。


File: python.info,  Node: 関数定義についてもう少し,  Next: 間奏曲 コーディングスタイル,  Prev: 関数を定義する,  Up: その他の制御フローツール

2.4.9 関数定義についてもう少し
------------------------------

可変個の引数を伴う関数を定義することもできます。引数の定義方法には 3 つ
の形式があり、それらを組み合わせることができます。

* Menu:

* デフォルトの引数値::
* キーワード引数::
* 特殊なパラメータ::
* 任意引数リスト::
* 引数リストのアンパック::
* ラムダ式::
* ドキュメンテーション文字列::
* 関数のアノテーション::


File: python.info,  Node: デフォルトの引数値,  Next: キーワード引数,  Up: 関数定義についてもう少し

2.4.9.1 デフォルトの引数値
..........................

もっとも便利なのは、一つ以上の引数に対してデフォルトの値を指定する形式で
す。この形式を使うと、定義されている引数より少ない個数の引数で呼び出せる
関数を作成します:

     def ask_ok(prompt, retries=4, reminder='Please try again!'):
         while True:
             reply = input(prompt)
             if reply in {'y', 'ye', 'yes'}:
                 return True
             if reply in {'n', 'no', 'nop', 'nope'}:
                 return False
             retries = retries - 1
             if retries < 0:
                 raise ValueError('invalid user response')
             print(reminder)

この関数はいくつかの方法で呼び出せます:

   * 必須の引数のみ与える: ‘ask_ok('Do you really want to quit?')’

   * 一つのオプション引数を与える: ‘ask_ok('OK to overwrite the file?',
     2)’

   * 全ての引数を与える: ‘ask_ok('OK to overwrite the file?', 2, 'Come
     on, only yes or no!')’

この例では *note in: 2cb. キーワードが導入されています。このキーワードは
シーケンスが特定の値を含んでいるかどうか調べるのに使われます。

デフォルト値は、関数が定義された時点で、関数を '定義している' 側のスコー
プ (scope) で評価されるので

     i = 5

     def f(arg=i):
         print(arg)

     i = 6
     f()

は ‘5’ を出力します。

'重要な警告:' デフォルト値は 1 度だけしか評価されません。デフォルト値が
リストや辞書のような変更可能なオブジェクトの時にはその影響がでます。例え
ば以下の関数は、後に続く関数呼び出しで関数に渡されている引数を累積します
:

     def f(a, L=[]):
         L.append(a)
         return L

     print(f(1))
     print(f(2))
     print(f(3))

このコードは、以下を出力します

     [1]
     [1, 2]
     [1, 2, 3]

後続の関数呼び出しでデフォルト値を共有したくなければ、代わりに以下のよう
に関数を書くことができます:

     def f(a, L=None):
         if L is None:
             L = []
         L.append(a)
         return L


File: python.info,  Node: キーワード引数,  Next: 特殊なパラメータ,  Prev: デフォルトの引数値,  Up: 関数定義についてもう少し

2.4.9.2 キーワード引数
......................

関数を ‘kwarg=value’ という形式の *note キーワード引数: ce0. を使って呼
び出すこともできます。例えば、以下の関数:

     def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'):
         print("-- This parrot wouldn't", action, end=' ')
         print("if you put", voltage, "volts through it.")
         print("-- Lovely plumage, the", type)
         print("-- It's", state, "!")

は、必須引数 (‘voltage’) とオプション引数 (‘state’、‘action’、‘type’) を
受け付けます。この関数は以下のいずれかの方法で呼び出せます:

     parrot(1000)                                          # 1 positional argument
     parrot(voltage=1000)                                  # 1 keyword argument
     parrot(voltage=1000000, action='VOOOOOM')             # 2 keyword arguments
     parrot(action='VOOOOOM', voltage=1000000)             # 2 keyword arguments
     parrot('a million', 'bereft of life', 'jump')         # 3 positional arguments
     parrot('a thousand', state='pushing up the daisies')  # 1 positional, 1 keyword

が、以下の呼び出しは不適切です:

     parrot()                     # required argument missing
     parrot(voltage=5.0, 'dead')  # non-keyword argument after a keyword argument
     parrot(110, voltage=220)     # duplicate value for the same argument
     parrot(actor='John Cleese')  # unknown keyword argument

関数の呼び出しにおいて、キーワード引数は位置引数の後でなければなりません
。渡されるキーワード引数は全て、関数で受け付けられる引数のいずれかに対応
していなければならず (例えば、‘actor’ はこの ‘parrot’ 関数の引数として適
切ではありません)、順序は重要ではありません。これはオプションでない引数
でも同様です (例えば、‘parrot(voltage=1000)’ も適切です)。いかなる引数も
値を複数回は受け取れません。この制限により失敗する例は:

     >>> def function(a):
     ...     pass
     ...
     >>> function(0, a=0)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: function() got multiple values for argument 'a'

仮引数の最後に ‘**name’ の形式のものがあると、それまでの仮引数に対応した
ものを除くすべてのキーワード引数が入った辞書 (*note マッピング型 --
dict: a94. を参照) を受け取ります。 ‘**name’ は ‘*name’ の形式をとる、仮
引数のリストを超えた位置引数の入った *note タプル: 1b90. を受け取る引数
(次の小節で述べます) と組み合わせられます。 (‘*name’ は ‘**name’ より前
になければなりません)。 例えば、ある関数の定義を以下のようにすると:

     def cheeseshop(kind, *arguments, **keywords):
         print("-- Do you have any", kind, "?")
         print("-- I'm sorry, we're all out of", kind)
         for arg in arguments:
             print(arg)
         print("-" * 40)
         for kw in keywords:
             print(kw, ":", keywords[kw])

呼び出しは以下のようになり:

     cheeseshop("Limburger", "It's very runny, sir.",
                "It's really very, VERY runny, sir.",
                shopkeeper="Michael Palin",
                client="John Cleese",
                sketch="Cheese Shop Sketch")

もちろん以下のように出力されます:

     -- Do you have any Limburger ?
     -- I'm sorry, we're all out of Limburger
     It's very runny, sir.
     It's really very, VERY runny, sir.
     ----------------------------------------
     shopkeeper : Michael Palin
     client : John Cleese
     sketch : Cheese Shop Sketch

なお、複数のキーワード引数を与えた場合に、それらが出力される順序は、関数
呼び出しで与えられた順序と同じになります。


File: python.info,  Node: 特殊なパラメータ,  Next: 任意引数リスト,  Prev: キーワード引数,  Up: 関数定義についてもう少し

2.4.9.3 特殊なパラメータ
........................

デフォルトでは、引数は位置またはキーワードによる明示で Python 関数に渡さ
れます。 可読性とパフォーマンスのために、その引数が位置、位置またはキー
ワード、キーワードのどれで渡されるかを開発者が判定するのに関数定義だけを
見ればよいように、引数の渡され方を制限することには意味があります。

関数定義は次のようになります:

     def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):
           -----------    ----------     ----------
             |             |                  |
             |        Positional or keyword   |
             |                                - Keyword only
              -- Positional only

ここで、‘/’ と ‘*’ はオプションです。使用された場合、これらの記号は、引
数が関数に渡される方法、すなわち、位置専用、位置またはキーワード、キーワ
ード専用、といった引数の種類を示します。キーワード引数は、名前付き引数と
も呼ばれます。

* Menu:

* 位置またはキーワード引数::
* 位置専用引数: 位置専用引数<2>.
* キーワード専用引数::
* 関数の例::
* 要約::


File: python.info,  Node: 位置またはキーワード引数,  Next: 位置専用引数<2>,  Up: 特殊なパラメータ

2.4.9.4 位置またはキーワード引数
................................

関数定義に ‘/’ も ‘*’ もない場合は、引数は位置またはキーワードで関数に渡
されます。


File: python.info,  Node: 位置専用引数<2>,  Next: キーワード専用引数,  Prev: 位置またはキーワード引数,  Up: 特殊なパラメータ

2.4.9.5 位置専用引数
....................

これをもう少し詳しく見てみると、特定の引数を '位置専用' と印を付けられま
す。 '位置専用' の場合、引数の順序が重要であり、キーワードで引数を渡せま
せん。 位置専用引数は ‘/’ （スラッシュ）の前に配置されます。 ‘/’ は、位
置専用引数を残りの引数から論理的に分離するために使用されます。 関数定義
に ‘/’ がない場合、位置専用引数はありません。

‘/’ の後の引数は、 '位置またはキーワード' 、もしくは、 'キーワード専用'
です。


File: python.info,  Node: キーワード専用引数,  Next: 関数の例,  Prev: 位置専用引数<2>,  Up: 特殊なパラメータ

2.4.9.6 キーワード専用引数
..........................

引数をキーワード引数で渡す必要があることを示す 'キーワード専用' として引
数をマークするには、引数リストの最初の 'キーワード専用' 引数の直前に ‘*’
を配置します。


File: python.info,  Node: 関数の例,  Next: 要約,  Prev: キーワード専用引数,  Up: 特殊なパラメータ

2.4.9.7 関数の例
................

‘/’ および ‘*’ といったマーカーに注意を払って、次の関数定義の例を見てく
ださい:

     >>> def standard_arg(arg):
     ...     print(arg)
     ...
     >>> def pos_only_arg(arg, /):
     ...     print(arg)
     ...
     >>> def kwd_only_arg(*, arg):
     ...     print(arg)
     ...
     >>> def combined_example(pos_only, /, standard, *, kwd_only):
     ...     print(pos_only, standard, kwd_only)

最も馴染みのある形式の最初の関数定義 ‘standard_arg’ は、呼び出し規約に制
限を設けておらず、引数は位置またはキーワードで渡されます:

     >>> standard_arg(2)
     2

     >>> standard_arg(arg=2)
     2

2番目の関数の ‘pos_only_arg’ は、 ‘/’ が関数定義にあるので、引数は位置専
用になります:

     >>> pos_only_arg(1)
     1

     >>> pos_only_arg(arg=1)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: pos_only_arg() got some positional-only arguments passed as keyword arguments: 'arg'

The third function ‘kwd_only_arg’ only allows keyword arguments as
indicated by a ‘*’ in the function definition:

     >>> kwd_only_arg(3)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: kwd_only_arg() takes 0 positional arguments but 1 was given

     >>> kwd_only_arg(arg=3)
     3

そして最後の関数は3つの引数の種類を一つの関数定義の中で使用しています:

     >>> combined_example(1, 2, 3)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: combined_example() takes 2 positional arguments but 3 were given

     >>> combined_example(1, 2, kwd_only=3)
     1 2 3

     >>> combined_example(1, standard=2, kwd_only=3)
     1 2 3

     >>> combined_example(pos_only=1, standard=2, kwd_only=3)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: combined_example() got some positional-only arguments passed as keyword arguments: 'pos_only'

最後に、位置引数 ‘name’ と ‘name’ をキーとして持つ ‘**kwds’ の間に潜在的
な衝突がある関数定義を考えてみましょう。

     def foo(name, **kwds):
         return 'name' in kwds

キーワードに ‘'name'’ を入れても、先頭の引数と同じになってしまうため、こ
の関数が ‘True’ を返すような呼び出しの方法はありません。例えば、次のよう
になってしまいます:

     >>> foo(1, **{'name': 2})
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: foo() got multiple values for argument 'name'
     >>>

しかし位置専用を示す ‘/’ を使用すれば可能になります。 ‘name’ は位置引数
として、そして ‘'name'’ はキーワード引数のキーワードとして認識されるから
です:

     >>> def foo(name, /, **kwds):
     ...     return 'name' in kwds
     ...
     >>> foo(1, **{'name': 2})
     True

言い換えると、位置専用引数であれば、その名前を ‘**kwds’ の中で使用しても
、曖昧にならないということです。


File: python.info,  Node: 要約,  Prev: 関数の例,  Up: 特殊なパラメータ

2.4.9.8 要約
............

使用例で、関数定義でどの種類の引数を使うかべきかがわかると思います:

     def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):

ガイドとしては、

   * もし引数の名前をユーザーに知らせる必要がないなら、位置専用引数を使
     用しましょう。これは引数の名前がユーザーにとって意味がなく、関数が
     呼ばれたときの引数の順序が問題であり、または、位置引数と任意のキー
     ワードを使用する必要がある場合に便利です。

   * 引数の名前に意味があり、それにより関数の定義がより明らかになる、ま
     たは、ユーザーが引数の順番に縛られることを避けたほうがいいと考える
     のなら、キーワード専用引数を使用しましょう。

   * APIの場合、将来引数の名前が変更された場合にAPIの変更ができなくなる
     ことを防ぐために、位置専用引数を使用しましょう。


File: python.info,  Node: 任意引数リスト,  Next: 引数リストのアンパック,  Prev: 特殊なパラメータ,  Up: 関数定義についてもう少し

2.4.9.9 任意引数リスト
......................

最後に、最も使うことの少ない選択肢として、関数が任意の個数の引数で呼び出
せるよう指定する方法があります。これらの引数はタプル (*note
タプルとシーケンス: 1b90. を参照) に格納されます。可変個の引数の前に、ゼ
ロ個かそれ以上の引数があっても構いません。

     def write_multiple_items(file, separator, *args):
         file.write(separator.join(args))

通常このような '可変' 引数は、関数に渡される入力引数の残りを全て掬い取る
ために、仮引数リストの最後に置かれます。 ‘*args’ 引数の後にある仮引数は
'キーワード専用' 引数で、位置引数ではなくキーワード引数としてのみ使える
ことを意味します。

     >>> def concat(*args, sep="/"):
     ...     return sep.join(args)
     ...
     >>> concat("earth", "mars", "venus")
     'earth/mars/venus'
     >>> concat("earth", "mars", "venus", sep=".")
     'earth.mars.venus'


File: python.info,  Node: 引数リストのアンパック,  Next: ラムダ式,  Prev: 任意引数リスト,  Up: 関数定義についてもう少し

2.4.9.10 引数リストのアンパック
...............................

引数がすでにリストやタプルになっていて、個別な位置引数を要求する関数呼び
出しに渡すためにアンパックする必要がある場合には、逆の状況が起こります。
例えば、組み込み関数 *note range(): 911. は引数 'start' と 'stop' を別に
与える必要があります。個別に引数を与えることができない場合、関数呼び出し
を ‘*’ 演算子を使って書き、リストやタプルから引数をアンパックします:

     >>> list(range(3, 6))            # normal call with separate arguments
     [3, 4, 5]
     >>> args = [3, 6]
     >>> list(range(*args))            # call with arguments unpacked from a list
     [3, 4, 5]

同じやりかたで、‘**’ オペレータを使って辞書でもキーワード引数を渡すこと
ができます:

     >>> def parrot(voltage, state='a stiff', action='voom'):
     ...     print("-- This parrot wouldn't", action, end=' ')
     ...     print("if you put", voltage, "volts through it.", end=' ')
     ...     print("E's", state, "!")
     ...
     >>> d = {"voltage": "four million", "state": "bleedin' demised", "action": "VOOM"}
     >>> parrot(**d)
     -- This parrot wouldn't VOOM if you put four million volts through it. E's bleedin' demised !


File: python.info,  Node: ラムダ式,  Next: ドキュメンテーション文字列,  Prev: 引数リストのアンパック,  Up: 関数定義についてもう少し

2.4.9.11 ラムダ式
.................

キーワード *note lambda: 126d. を使うと、名前のない小さな関数を生成でき
ます。例えば ‘lambda a, b: a+b’ は、二つの引数の和を返す関数です。ラムダ
式の関数は、関数オブジェクトが要求されている場所にならどこでも使うことが
できます。ラムダ式は、構文上単一の式に制限されています。意味付け的には、
ラムダ形式は単に通常の関数定義に構文的な糖衣をかぶせたものに過ぎません。
入れ子構造になった関数定義と同様、ラムダ式もそれを取り囲むスコープから変
数を参照することができます:

     >>> def make_incrementor(n):
     ...     return lambda x: x + n
     ...
     >>> f = make_incrementor(42)
     >>> f(0)
     42
     >>> f(1)
     43

上記の例は、関数を返すところでラムダ式を使っています。もう1つの例では、
ちょっとした関数を引数として渡すのに使っています:

     >>> pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]
     >>> pairs.sort(key=lambda pair: pair[1])
     >>> pairs
     [(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]


File: python.info,  Node: ドキュメンテーション文字列,  Next: 関数のアノテーション,  Prev: ラムダ式,  Up: 関数定義についてもう少し

2.4.9.12 ドキュメンテーション文字列
...................................

ドキュメンテーション文字列については、その内容と書式に関する慣習をいくつ
か挙げます。

最初の行は、常に対象物の目的を短く簡潔にまとめたものでなくてはなりません
。簡潔に書くために、対象物の名前や型を明示する必要はありません。名前や型
は他の方法でも得られるからです (名前がたまたま関数の演算内容を記述する動
詞である場合は例外です)。最初の行は大文字で始まり、ピリオドで終わってい
なければなりません。

ドキュメンテーション文字列中にさらに記述すべき行がある場合、二行目は空行
にし、まとめの行と残りの記述部分を視覚的に分離します。つづく行は一つまた
はそれ以上の段落で、対象物の呼び出し規約や副作用について記述します。

Python のパーザは複数行にわたる Python 文字列リテラルからインデントを剥
ぎ取らないので、ドキュメントを処理するツールでは必要に応じてインデントを
剥ぎ取らなければなりません。この処理は以下の規約に従って行います。最初の
行の '後にある' 空行でない最初の行が、ドキュメント全体のインデントの量を
決めます。(最初の行は通常、文字列を開始するクオートに隣り合っているので
、インデントが文字列リテラル中に現れないためです。) このインデント量と
"等価な" 空白が、文字列のすべての行頭から剥ぎ取られます。インデントの量
が少ない行を書いてはならないのですが、もしそういう行があると、先頭の空白
すべてが剥ぎ取られます。インデントの空白の大きさが等しいかどうかは、タブ
文字を (通常は 8 文字のスペースとして) 展開した後に調べられます。

以下に複数行のドキュメンテーション文字列の例を示します:

     >>> def my_function():
     ...     """Do nothing, but document it.
     ...
     ...     No, really, it doesn't do anything.
     ...     """
     ...     pass
     ...
     >>> print(my_function.__doc__)
     Do nothing, but document it.

         No, really, it doesn't do anything.


File: python.info,  Node: 関数のアノテーション,  Prev: ドキュメンテーション文字列,  Up: 関数定義についてもう少し

2.4.9.13 関数のアノテーション
.............................

*note 関数アノテーション: 1ba0. はユーザ定義関数で使用される型についての
完全にオプションなメタデータ情報です (詳細は PEP 3107(1) と PEP 484(2) を
参照してください)。

*note アノテーション: 1ba1. は、関数の ‘__annotations__’ 属性に辞書とし
て格納され、関数の他の部分には影響しません。 パラメータアノテーションは
、パラメータ名のあとのコロンと式で定義され、その式の評価結果がアノテーシ
ョンとなります。 戻り値アノテーションは、パラメータリストと *note def:
13ff. 文の終わりを表すコロンの間で、 ‘->’ の後ろに式を書くことで定義され
ます。 次の例では、必須引数と任意引数、戻り値にアノテーションが付与され
ています:

     >>> def f(ham: str, eggs: str = 'eggs') -> str:
     ...     print("Annotations:", f.__annotations__)
     ...     print("Arguments:", ham, eggs)
     ...     return ham + ' and ' + eggs
     ...
     >>> f('spam')
     Annotations: {'ham': <class 'str'>, 'return': <class 'str'>, 'eggs': <class 'str'>}
     Arguments: spam eggs
     'spam and eggs'

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3107/

   (2) https://peps.python.org/pep-0484/


File: python.info,  Node: 間奏曲 コーディングスタイル,  Prev: 関数定義についてもう少し,  Up: その他の制御フローツール

2.4.10 間奏曲: コーディングスタイル
-----------------------------------

これからより長くより複雑な Python のコードを書いていくので、そろそろ 'コ
ーディングスタイル' について語っても良い頃です。ほとんどの言語は様々なス
タイルで書け (もっと簡潔に言えば 'フォーマットでき')、スタイルによって読
み易さが異なります。他人にとって読み易いコードにしようとするのはどんなと
きでも良い考えであり、良いコーディングスタイルを採用することが非常に強力
な助けになります。

Python には、ほとんどのプロジェクトが守っているスタイルガイドとして PEP
8(1) があります。それは非常に読み易く目に優しいコーディングスタイルを推
奨しています。全ての Python 開発者はある時点でそれを読むべきです。ここに
最も重要な点を抜き出しておきます:

   * インデントには空白 4 つを使い、タブは使わないこと。

     空白 4 つは (深くネストできる) 小さいインデントと (読み易い) 大きい
     インデントのちょうど中間に当たります。タブは混乱させるので、使わず
     におくのが良いです。

   * ソースコードの幅が 79 文字を越えないように行を折り返すこと。

     こうすることで小さいディスプレイを使っているユーザも読み易くなり、
     大きなディスプレイではソースコードファイルを並べることもできるよう
     になります。

   * 関数やクラスや関数内の大きめのコードブロックの区切りに空行を使うこ
     と。

   * 可能なら、コメントは行に独立で書くこと。

   * docstring を使うこと。

   * 演算子の前後とコンマの後には空白を入れ、括弧類のすぐ内側には空白を
     入れないこと: ‘a = f(1, 2) + g(3, 4)’。

   * クラスや関数に一貫性のある名前を付けること。慣習では
     ‘UpperCamelCase’ をクラス名に使い、 ‘lowercase_with_underscores’ を
     関数名やメソッド名に使います。常に ‘self’ をメソッドの第 1 引数の名
     前 (クラスやメソッドについては *note クラス初見: 1ba4. を見よ) とし
     て使うこと。

   * あなたのコードを世界中で使ってもらうつもりなら、風変りなエンコーデ
     ィングは使わないこと。どんな場合でも、Python のデフォルト UTF-8 ま
     たはプレーン ASCII が最も上手くいきます。

   * 同様に、ほんの少しでも他の言語を話す人がコードを読んだりメンテナン
     スする可能性があるのであれば、非 ASCII 文字も識別子に使うべきではあ
     りません。

脚注
....

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0008/


File: python.info,  Node: データ構造,  Next: モジュール<2>,  Prev: その他の制御フローツール,  Up: Python チュートリアル

2.5 データ構造
==============

この章では、すでに学んだことについてより詳しく説明するとともに、いくつか
新しいことを追加します。

* Menu:

* リスト型についてもう少し::
* del 文::
* タプルとシーケンス::
* 集合型::
* 辞書型 (dictionary): 辞書型 dictionary.
* ループのテクニック::
* 条件についてもう少し::
* シーケンスとその他の型の比較::


File: python.info,  Node: リスト型についてもう少し,  Next: del 文,  Up: データ構造

2.5.1 リスト型についてもう少し
------------------------------

リストデータ型には、他にもいくつかメソッドがあります。リストオブジェクト
のすべてのメソッドを以下に示します:

 -- メソッド: list.append (x)

     Add an item to the end of the list.  Similar to ‘a[len(a):] = [x]’.

 -- メソッド: list.extend (iterable)

     Extend the list by appending all the items from the iterable.
     Similar to ‘a[len(a):] = iterable’.

 -- メソッド: list.insert (i, x)

     指定した位置に要素を挿入します。第 1 引数は、リストのインデクスで、
     そのインデクスを持つ要素の直前に挿入が行われます。従って、
     ‘a.insert(0, x)’ はリストの先頭に挿入を行います。また
     ‘a.insert(len(a), x)’ は ‘a.append(x)’ と等価です。

 -- メソッド: list.remove (x)

     リスト中で 'x' と等しい値を持つ最初の要素を削除します。該当する要素
     がなければ *note ValueError: 1e3. が送出されます。

 -- メソッド: list.pop ([i])

     指定された位置の要素をリストから取り除き、それを返します。インデッ
     クスが指定されていない場合、 ‘a.pop()’ はリスト末尾の要素を取り除い
     て返します。リストが空であるか、インデックスがリストの範囲外の場合
     は、*note IndexError: 14de. を送出します。

 -- メソッド: list.clear ()

     Remove all items from the list.  Similar to ‘del a[:]’.

 -- メソッド: list.index (x[, start[, end]])

     リスト中で 'x' と等しい値を持つ最初の要素の位置をゼロから始まる添字
     で返します。 該当する要素がなければ *note ValueError: 1e3. が送出さ
     れます。

     任意の引数である 'start' と 'end' はスライス記法として解釈され、リ
     ストの探索範囲を指定できます。返される添字は、'start' 引数からの相
     対位置ではなく、リスト全体の先頭からの位置になります。

 -- メソッド: list.count (x)

     リストでの 'x' の出現回数を返します。

 -- メソッド: list.sort (*, key=None, reverse=False)

     リストの項目を、インプレース演算 (in place、元のデータを演算結果で
     置き換えるやりかた) でソートします。引数はソート方法のカスタマイズ
     に使えます。 *note sorted(): b9c. の説明を参照してください。

 -- メソッド: list.reverse ()

     リストの要素を、インプレース演算で逆順にします。

 -- メソッド: list.copy ()

     Return a shallow copy of the list.  Similar to ‘a[:]’.

以下にリストのメソッドをほぼ全て使った例を示します:

     >>> fruits = ['orange', 'apple', 'pear', 'banana', 'kiwi', 'apple', 'banana']
     >>> fruits.count('apple')
     2
     >>> fruits.count('tangerine')
     0
     >>> fruits.index('banana')
     3
     >>> fruits.index('banana', 4)  # Find next banana starting at position 4
     6
     >>> fruits.reverse()
     >>> fruits
     ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange']
     >>> fruits.append('grape')
     >>> fruits
     ['banana', 'apple', 'kiwi', 'banana', 'pear', 'apple', 'orange', 'grape']
     >>> fruits.sort()
     >>> fruits
     ['apple', 'apple', 'banana', 'banana', 'grape', 'kiwi', 'orange', 'pear']
     >>> fruits.pop()
     'pear'

‘insert’, ‘remove’, ‘sort’ などのリストを操作するメソッドの戻り値が表示
されていないことに気が付いたかもしれません。これらのメソッドは ‘None’ を
返しています。(1) これは Python の変更可能なデータ構造全てについての設計
上の原則となっています。

もうひとつ気付くとしたら、すべてのデータでソートや比較できるわけではない
ということです。 例えば、 ‘[None, 'hello', 10]’ はソートされません。なぜ
なら整数は文字列と比べられませんし、 ‘None’ は他の型と比べられないからで
す。 また、順序関係が定義されていない型もあります。 例えば、 ‘3+4j <
5+7j’ は有効な比較ではありません。

* Menu:

* リストをスタックとして使う::
* リストをキューとして使う::
* リストの内包表記: リストの内包表記<2>.
* ネストしたリストの内包表記::

   ---------- Footnotes ----------

   (1) 他の言語では変更可能なオブジェクトを返して、
‘d->insert("a")->remove("b")->sort();’ のようなメソッドチェインを許して
いる場合もあります。


File: python.info,  Node: リストをスタックとして使う,  Next: リストをキューとして使う,  Up: リスト型についてもう少し

2.5.1.1 リストをスタックとして使う
..................................

リスト型のメソッドのおかげで、簡単にリストをスタックとして使えます。スタ
ックでは、最後に追加された要素が最初に取り出されます ("last-in,
first-out")。スタックの一番上に要素を追加するには ‘append()’ を使います
。スタックの一番上から要素を取り出すには ‘pop()’ をインデックスを指定せ
ずに使います。例えば以下のようにします:

     >>> stack = [3, 4, 5]
     >>> stack.append(6)
     >>> stack.append(7)
     >>> stack
     [3, 4, 5, 6, 7]
     >>> stack.pop()
     7
     >>> stack
     [3, 4, 5, 6]
     >>> stack.pop()
     6
     >>> stack.pop()
     5
     >>> stack
     [3, 4]


File: python.info,  Node: リストをキューとして使う,  Next: リストの内包表記<2>,  Prev: リストをスタックとして使う,  Up: リスト型についてもう少し

2.5.1.2 リストをキューとして使う
................................

リストをキュー (queue) として使うことも可能です。この場合、最初に追加し
た要素を最初に取り出します ("first-in, first-out")。しかし、リストでは効
率的にこの目的を達成することが出来ません。追加（append）や取り出し（
pop）をリストの末尾に対して行うと速いのですが、挿入（insert）や取り出し
（pop）をリストの先頭に対して行うと遅くなってしまいます（他の要素をひと
つずつずらす必要があるからです）。

キューの実装には、 *note collections.deque: 5a6. を使うと良いでしょう。
このクラスは良く設計されていて、高速な追加（append）と取り出し（pop）を
両端に対して実現しています。例えば以下のようにします:

     >>> from collections import deque
     >>> queue = deque(["Eric", "John", "Michael"])
     >>> queue.append("Terry")           # Terry arrives
     >>> queue.append("Graham")          # Graham arrives
     >>> queue.popleft()                 # The first to arrive now leaves
     'Eric'
     >>> queue.popleft()                 # The second to arrive now leaves
     'John'
     >>> queue                           # Remaining queue in order of arrival
     deque(['Michael', 'Terry', 'Graham'])


File: python.info,  Node: リストの内包表記<2>,  Next: ネストしたリストの内包表記,  Prev: リストをキューとして使う,  Up: リスト型についてもう少し

2.5.1.3 リストの内包表記
........................

リスト内包表記はリストを生成する簡潔な手段を提供しています。主な利用場面
は、あるシーケンスや iterable (イテレート可能オブジェクト) のそれぞれの
要素に対してある操作を行った結果を要素にしたリストを作ったり、ある条件を
満たす要素だけからなる部分シーケンスを作成することです。

例えば、次のような平方のリストを作りたいとします:

     >>> squares = []
     >>> for x in range(10):
     ...     squares.append(x**2)
     ...
     >>> squares
     [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

これはループが終了した後にも存在する ‘x’ という名前の変数を作る (または
上書きする) ことに注意してください。以下のようにして平方のリストをいかな
る副作用もなく計算することができます:

     squares = list(map(lambda x: x**2, range(10)))

もしくは、以下でも同じです:

     squares = [x**2 for x in range(10)]

これはより簡潔で読みやすいです。

リスト内包表記は、括弧の中の 式、 ‘for’ 句、そして0個以上の ‘for’ か
‘if’ 句で構成されます。 リスト内包表記の実行結果は、 ‘for’ と ‘if’ 句の
コンテキスト中で式を評価した結果からなる新しいリストです。 例えば、次の
リスト内包表記は2つのリストの要素から、違うもの同士をペアにします。

     >>> [(x, y) for x in [1,2,3] for y in [3,1,4] if x != y]
     [(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]

これは次のコードと等価です:

     >>> combs = []
     >>> for x in [1,2,3]:
     ...     for y in [3,1,4]:
     ...         if x != y:
     ...             combs.append((x, y))
     ...
     >>> combs
     [(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)]

*note for: 2c9. と *note if: 2ca. 文が両方のコードで同じ順序になっている
ことに注目してください。

式がタプルの場合 (例: 上の例で式が ‘(x, y)’ の場合) は、タプルに円括弧が
必要です。

     >>> vec = [-4, -2, 0, 2, 4]
     >>> # create a new list with the values doubled
     >>> [x*2 for x in vec]
     [-8, -4, 0, 4, 8]
     >>> # filter the list to exclude negative numbers
     >>> [x for x in vec if x >= 0]
     [0, 2, 4]
     >>> # apply a function to all the elements
     >>> [abs(x) for x in vec]
     [4, 2, 0, 2, 4]
     >>> # call a method on each element
     >>> freshfruit = ['  banana', '  loganberry ', 'passion fruit  ']
     >>> [weapon.strip() for weapon in freshfruit]
     ['banana', 'loganberry', 'passion fruit']
     >>> # create a list of 2-tuples like (number, square)
     >>> [(x, x**2) for x in range(6)]
     [(0, 0), (1, 1), (2, 4), (3, 9), (4, 16), (5, 25)]
     >>> # the tuple must be parenthesized, otherwise an error is raised
     >>> [x, x**2 for x in range(6)]
       File "<stdin>", line 1
         [x, x**2 for x in range(6)]
          ^^^^^^^
     SyntaxError: did you forget parentheses around the comprehension target?
     >>> # flatten a list using a listcomp with two 'for'
     >>> vec = [[1,2,3], [4,5,6], [7,8,9]]
     >>> [num for elem in vec for num in elem]
     [1, 2, 3, 4, 5, 6, 7, 8, 9]

リスト内包表記の式には、複雑な式や関数呼び出しのネストができます:

     >>> from math import pi
     >>> [str(round(pi, i)) for i in range(1, 6)]
     ['3.1', '3.14', '3.142', '3.1416', '3.14159']


File: python.info,  Node: ネストしたリストの内包表記,  Prev: リストの内包表記<2>,  Up: リスト型についてもう少し

2.5.1.4 ネストしたリストの内包表記
..................................

リスト内包表記中の最初の式は任意の式なので、そこに他のリスト内包表記を書
くこともできます。

次の、長さ4のリスト3つからなる、3x4 の matrix について考えます:

     >>> matrix = [
     ...     [1, 2, 3, 4],
     ...     [5, 6, 7, 8],
     ...     [9, 10, 11, 12],
     ... ]

次のリスト内包表記は、matrix の行と列を入れ替えます:

     >>> [[row[i] for row in matrix] for i in range(4)]
     [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]

前の節で見たように、内側のリスト内包表記は、続く *note for: 2c9. のコン
テキストの中で評価されます。そのため、この例は次のコードと等価です:

     >>> transposed = []
     >>> for i in range(4):
     ...     transposed.append([row[i] for row in matrix])
     ...
     >>> transposed
     [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]

これをもう一度変換すると、次のコードと等価になります:

     >>> transposed = []
     >>> for i in range(4):
     ...     # the following 3 lines implement the nested listcomp
     ...     transposed_row = []
     ...     for row in matrix:
     ...         transposed_row.append(row[i])
     ...     transposed.append(transposed_row)
     ...
     >>> transposed
     [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12]]

実際には複雑な流れの式よりも組み込み関数を使う方が良いです。この場合
*note zip(): 79b. 関数が良い仕事をしてくれるでしょう:

     >>> list(zip(*matrix))
     [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)]

この行にあるアスタリスクの詳細については *note 引数リストのアンパック:
1b99. を参照してください。


File: python.info,  Node: del 文,  Next: タプルとシーケンス,  Prev: リスト型についてもう少し,  Up: データ構造

2.5.2 ‘del’ 文
--------------

リストから要素を削除する際、値を指定する代わりにインデックスを指定する方
法があります。それが *note del: 1711. 文です。これは ‘pop()’ メソッドと
違い、値を返しません。 ‘del’ 文はリストからスライスを除去したり、リスト
全体を削除することもできます(以前はスライスに空のリストを代入して行って
いました)。例えば以下のようにします:

     >>> a = [-1, 1, 66.25, 333, 333, 1234.5]
     >>> del a[0]
     >>> a
     [1, 66.25, 333, 333, 1234.5]
     >>> del a[2:4]
     >>> a
     [1, 66.25, 1234.5]
     >>> del a[:]
     >>> a
     []

*note del: 1711. は変数全体の削除にも使えます:

     >>> del a

この文の後で名前 ‘a’ を参照すると、(別の値を ‘a’ に代入するまで) エラー
になります。 *note del: 1711. の別の用途についてはまた後で取り上げます。


File: python.info,  Node: タプルとシーケンス,  Next: 集合型,  Prev: del 文,  Up: データ構造

2.5.3 タプルとシーケンス
------------------------

リストや文字列には、インデクスやスライスを使った演算のように、数多くの共
通の性質があることを見てきました。これらは 'シーケンス (sequence)' デー
タ型 (*note シーケンス型 -- list, tuple, range: 1bb3. を参照) の二つの例
です。 Python はまだ進歩の過程にある言語なので、他のシーケンスデータ型が
追加されるかもしれません。標準のシーケンス型はもう一つあります: 'タプル
(tuple)' 型です。

タプルはコンマで区切られたいくつかの値からなります。例えば以下のように書
きます:

     >>> t = 12345, 54321, 'hello!'
     >>> t[0]
     12345
     >>> t
     (12345, 54321, 'hello!')
     >>> # Tuples may be nested:
     >>> u = t, (1, 2, 3, 4, 5)
     >>> u
     ((12345, 54321, 'hello!'), (1, 2, 3, 4, 5))
     >>> # Tuples are immutable:
     >>> t[0] = 88888
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: 'tuple' object does not support item assignment
     >>> # but they can contain mutable objects:
     >>> v = ([1, 2, 3], [3, 2, 1])
     >>> v
     ([1, 2, 3], [3, 2, 1])

ご覧のとおり、タプルの表示には常に丸括弧がついていて、タプルのネストが正
しく解釈されるようになっています。タプルを書くときは必ずしも丸括弧で囲ま
なくてもいいですが、(タプルが大きな式の一部だった場合は) 丸括弧が必要な
場合もあります。タプルの要素を代入することはできません。しかし、タプルに
リストのような変更可能型を含めることはできます。

タプルはリストと似ていますが、たいてい異なる場面と異なる目的で利用されま
す。タプルは *note 不変: 1272. で、複数の型の要素からなることもあり、要
素はアンパック(この節の後半に出てきます)操作やインデックス (あるいは
*note namedtuples: 1ac. の場合は属性)でアクセスすることが多いです。一方
、リストは *note 可変: 1273. で、要素はたいてい同じ型のオブジェクトであ
り、たいていイテレートによってアクセスします。

問題は 0 個または 1 個の項目からなるタプルの構築です。これらの操作を行う
ため、構文には特別な細工がされています。空のタプルは空の丸括弧ペアで構築
できます。一つの要素を持つタプルは、値の後ろにコンマを続ける (単一の値を
丸括弧で囲むだけでは不十分です) ことで構築できます。美しくはないけれども
、効果的です。例えば以下のようにします:

     >>> empty = ()
     >>> singleton = 'hello',    # <-- note trailing comma
     >>> len(empty)
     0
     >>> len(singleton)
     1
     >>> singleton
     ('hello',)

文 ‘t = 12345, 54321, 'hello!'’ は 'タプルのパック (tuple packing)' の例
です。値 ‘12345’, ‘54321’, ‘'hello!'’ が一つのタプルにパックされます。逆
の演算も可能です:

     >>> x, y, z = t

この操作は、'シーケンスのアンパック (sequence unpacking)' とでも呼ぶべき
もので、右辺には全てのシーケンス型を使うことができます。シーケンスのアン
パックでは、等号の左辺に列挙されている変数が、右辺のシーケンスの長さと同
じ数だけあることが要求されます。複数同時の代入が実はタプルのパックとシー
ケンスのアンパックを組み合わせたものに過ぎないことに注意してください。


File: python.info,  Node: 集合型,  Next: 辞書型 dictionary,  Prev: タプルとシーケンス,  Up: データ構造

2.5.4 集合型
------------

Python には、 '集合 (set)' を扱うためのデータ型もあります。集合とは、重
複する要素をもたない、順序づけられていない要素の集まりです。 Set オブジ
ェクトは、和 (union)、積 (intersection)、差 (difference)、対称差
(symmetric difference)といった数学的な演算もサポートしています。

中括弧、または *note set(): 5a3. 関数は set を生成するために使用すること
ができます。注: 空集合を作成するためには ‘set()’ を使用しなければなりま
せん (‘{}’ ではなく)。後者は空の辞書を作成します。辞書は次のセクションで
議論するデータ構造です。

簡単なデモンストレーションを示します:

     >>> basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
     >>> print(basket)                      # show that duplicates have been removed
     {'orange', 'banana', 'pear', 'apple'}
     >>> 'orange' in basket                 # fast membership testing
     True
     >>> 'crabgrass' in basket
     False

     >>> # Demonstrate set operations on unique letters from two words
     >>>
     >>> a = set('abracadabra')
     >>> b = set('alacazam')
     >>> a                                  # unique letters in a
     {'a', 'r', 'b', 'c', 'd'}
     >>> a - b                              # letters in a but not in b
     {'r', 'd', 'b'}
     >>> a | b                              # letters in a or b or both
     {'a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'}
     >>> a & b                              # letters in both a and b
     {'a', 'c'}
     >>> a ^ b                              # letters in a or b but not both
     {'r', 'd', 'b', 'm', 'z', 'l'}

*note リスト内包: 1bae. と同様に、 set 内包もサポートされています:

     >>> a = {x for x in 'abracadabra' if x not in 'abc'}
     >>> a
     {'r', 'd'}


File: python.info,  Node: 辞書型 dictionary,  Next: ループのテクニック,  Prev: 集合型,  Up: データ構造

2.5.5 辞書型 (dictionary)
-------------------------

もう一つ、有用な型が Python に組み込まれています。それは '辞書
(dictionary)' (*note マッピング型 -- dict: a94. を参照)です。辞書は他の
言語にも "連想記憶 (associated memory)" や "連想配列 (associative
array)" という名前で存在することがあります。ある範囲の数でインデックス化
されているシーケンスと異なり、辞書は 'キー (key)' でインデックス化されて
います。このキーは何らかの変更不能な型になります。文字列、数値は常にキー
にすることができます。タプルは、文字列、数値、その他のタプルのみを含む場
合はキーにすることができます。直接、あるいは間接的に変更可能なオブジェク
トを含むタプルはキーにできません。リストをキーとして使うことはできません
。これは、リストにスライスやインデックス指定の代入を行ったり、
‘append()’ や ‘extend()’ のようなメソッドを使うと、インプレースで変更す
ることができるためです。

辞書は 'キー(key): 値(value)' のペアの集合であり、キーが (辞書の中で)一
意でなければならない、と考えるとよいでしょう。波括弧 (brace) のペア:
‘{}’ は空の辞書を生成します。カンマで区切られた key: value のペアを波括
弧ペアの間に入れると、辞書の初期値となる key: value が追加されます; この
表現方法は出力時に辞書が書き出されるのと同じ方法です。

辞書での主な操作は、ある値を何らかのキーを付けて記憶することと、キーを指
定して値を取り出すことです。 ‘del’ で key: value のペアを削除することも
できます。すでに使われているキーを使って値を記憶すると、以前そのキーに関
連づけられていた値は忘れ去られてしまいます。存在しないキーを使って値を取
り出そうとするとエラーになります。

辞書オブジェクトに対し ‘list(d)’ を実行すると、辞書で使われている全ての
キーからなるリストをキーが挿入された順番で返します (ソートされたリストが
欲しい場合は、代わりに ‘sorted(d)’ を使ってください)。ある単一のキーが辞
書にあるかどうか調べるには、 *note in: 2cb. キーワードを使います。

以下に、辞書を使った簡単な例を示します:

     >>> tel = {'jack': 4098, 'sape': 4139}
     >>> tel['guido'] = 4127
     >>> tel
     {'jack': 4098, 'sape': 4139, 'guido': 4127}
     >>> tel['jack']
     4098
     >>> del tel['sape']
     >>> tel['irv'] = 4127
     >>> tel
     {'jack': 4098, 'guido': 4127, 'irv': 4127}
     >>> list(tel)
     ['jack', 'guido', 'irv']
     >>> sorted(tel)
     ['guido', 'irv', 'jack']
     >>> 'guido' in tel
     True
     >>> 'jack' not in tel
     False

*note dict(): 237. コンストラクタは、キーと値のペアのタプルを含むリスト
から辞書を生成します:

     >>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])
     {'sape': 4139, 'guido': 4127, 'jack': 4098}

さらに、辞書内包表現を使って、任意のキーと値のペアから辞書を作れます:

     >>> {x: x**2 for x in (2, 4, 6)}
     {2: 4, 4: 16, 6: 36}

キーが単純な文字列の場合、キーワード引数を使って定義する方が単純な場合も
あります:

     >>> dict(sape=4139, guido=4127, jack=4098)
     {'sape': 4139, 'guido': 4127, 'jack': 4098}


File: python.info,  Node: ループのテクニック,  Next: 条件についてもう少し,  Prev: 辞書型 dictionary,  Up: データ構造

2.5.6 ループのテクニック
------------------------

辞書に対してループを行う際、 *note items(): 79a. メソッドを使うと、キー
とそれに対応する値を同時に取り出せます。

     >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
     >>> for k, v in knights.items():
     ...     print(k, v)
     ...
     gallahad the pure
     robin the brave

シーケンスにわたるループを行う際、 *note enumerate(): 1424. 関数を使うと
、要素のインデックスと要素を同時に取り出すことができます。

     >>> for i, v in enumerate(['tic', 'tac', 'toe']):
     ...     print(i, v)
     ...
     0 tic
     1 tac
     2 toe

二つまたはそれ以上のシーケンス型を同時にループするために、関数 *note
zip(): 79b. を使って各要素をひと組みにすることができます。

     >>> questions = ['name', 'quest', 'favorite color']
     >>> answers = ['lancelot', 'the holy grail', 'blue']
     >>> for q, a in zip(questions, answers):
     ...     print('What is your {0}?  It is {1}.'.format(q, a))
     ...
     What is your name?  It is lancelot.
     What is your quest?  It is the holy grail.
     What is your favorite color?  It is blue.

シーケンスを逆方向に渡ってループするには、まずシーケンスの範囲を順方向に
指定し、次いで関数 *note reversed(): 831. を呼び出します。

     >>> for i in reversed(range(1, 10, 2)):
     ...     print(i)
     ...
     9
     7
     5
     3
     1

シーケンスをソートされた順序でループするには、 *note sorted(): b9c. 関数
を使います。この関数は元の配列を変更せず、ソート済みの新たな配列を返しま
す。

     >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
     >>> for i in sorted(basket):
     ...     print(i)
     ...
     apple
     apple
     banana
     orange
     orange
     pear

シーケンスに *note set(): 5a3. を使うと、重複要素が除去されます。 シーケ
ンスに *note set(): 5a3. を使った上で、 *note sorted(): b9c. を使うとい
う組み合わせ方は、順番が整列されているシーケンスで、同一要素に 1 度のみ
ループでアクセスする慣用的な方法です。

     >>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
     >>> for f in sorted(set(basket)):
     ...     print(f)
     ...
     apple
     banana
     orange
     pear

ときどきループ内でリストを変更したい誘惑に駆られるでしょうが、代わりに新
しいリストを作ってしまうほうがより簡単で安全なことが、ままあります

     >>> import math
     >>> raw_data = [56.2, float('NaN'), 51.7, 55.3, 52.5, float('NaN'), 47.8]
     >>> filtered_data = []
     >>> for value in raw_data:
     ...     if not math.isnan(value):
     ...         filtered_data.append(value)
     ...
     >>> filtered_data
     [56.2, 51.7, 55.3, 52.5, 47.8]


File: python.info,  Node: 条件についてもう少し,  Next: シーケンスとその他の型の比較,  Prev: ループのテクニック,  Up: データ構造

2.5.7 条件についてもう少し
--------------------------

‘while’ や ‘if’ 文で使った条件 (condition) には、値の比較だけでなく、他
の演算子も使うことができます。

比較演算子 ‘in’ および ‘not in’ は、ある値があるコンテナーの中に存在する
か (または存在しないか) どうかを確認するメンバーシップテストです。演算子
‘is’ および ‘is not’ は、二つのオブジェクトが実際に同じオブジェクトであ
るかどうかを調べます。全ての比較演算子は同じ優先順位を持っており、ともに
数値演算子よりも低い優先順位となります。

比較は連結させることができます。例えば、 ‘a < b == c’ は、 ‘a’ が ‘b’ よ
り小さく、かつ ‘b’ と ‘c’ が等しいかどうかをテストします。

ブール演算子 ‘and’ や ‘or’ で比較演算を組み合わせることができます。そし
て、比較演算 (あるいは何らかのブール式) の結果の否定は ‘not’ でとれます
。これらの演算子は全て、比較演算子よりも低い優先順位になっています。 ‘A
and not B or C’ と ‘(A and (not B)) or C’ が等価になるように、ブール演算
子の中で、 ‘not’ の優先順位が最も高く、 ‘or’ が最も低くなっています。も
ちろん、丸括弧を使えば望みの組み合わせを表現できます。

ブール演算子 ‘and’ と ‘or’ は、いわゆる '短絡 (short-circuit)' 演算子で
す。これらの演算子の引数は左から右へと順に評価され、結果が確定した時点で
評価を止めます。例えば、 ‘A’ と ‘C’ は真で ‘B’ が偽のとき、 ‘A and B and
C’ は式 ‘C’ を評価しません。一般に、短絡演算子の戻り値をブール値ではなく
て一般的な値として用いると、値は最後に評価された引数になります。

比較や他のブール式の結果を変数に代入することもできます。例えば、

     >>> string1, string2, string3 = '', 'Trondheim', 'Hammer Dance'
     >>> non_null = string1 or string2 or string3
     >>> non_null
     'Trondheim'

Pythonでは、Cとは異なり、式の中での代入は *note セイウチ演算子: 1bbb.
‘:=’ を使用して明示的に行う必要があることに注意してください。これにより
、 ‘==’ が意図されていたところに ‘=’ を入力してしまうという、Cプログラム
で発生する一般的なクラスの問題を回避できます。


File: python.info,  Node: シーケンスとその他の型の比較,  Prev: 条件についてもう少し,  Up: データ構造

2.5.8 シーケンスとその他の型の比較
----------------------------------

概して、シーケンスオブジェクトは、同じシーケンス型の他のオブジェクトと比
較できます。比較には '辞書的な (lexicographical)' 順序が用いられます。ま
ず、最初の二つの要素を比較し、その値が等しくなければその時点で比較結果が
決まります。等しければ次の二つの要素を比較し、以降シーケンスの要素が尽き
るまで続けます。比較しようとする二つの要素がいずれも同じシーケンス型であ
れば、そのシーケンス間での辞書比較を再帰的に行います。二つのシーケンスの
全ての要素の比較結果が等しくなれば、シーケンスは等しいとみなされます。片
方のシーケンスがもう一方の先頭部分にあたる部分シーケンスならば、短い方の
シーケンスが小さいシーケンスとみなされます。文字列に対する辞書的な順序づ
けには、個々の文字ごとに ASCII 順序を用います。以下に、同じ型のオブジェ
クトを持つシーケンス間での比較を行った例を示します:

     (1, 2, 3)              < (1, 2, 4)
     [1, 2, 3]              < [1, 2, 4]
     'ABC' < 'C' < 'Pascal' < 'Python'
     (1, 2, 3, 4)           < (1, 2, 4)
     (1, 2)                 < (1, 2, -1)
     (1, 2, 3)             == (1.0, 2.0, 3.0)
     (1, 2, ('aa', 'ab'))   < (1, 2, ('abc', 'a'), 4)

違う型のオブジェクト同士を ‘<’ や ‘>’ で比較することも、それらのオブジェ
クトが適切な比較メソッドを提供しているのであれば許可されます。例えば、異
なる数値型同士の比較では、その数値によって比較が行われます。例えば、 0 と
0.0 は等価です。一方、適切な比較順序がない場合は、インタープリターは
*note TypeError: 502. 例外を発生させます。

脚注
....


File: python.info,  Node: モジュール<2>,  Next: 入力と出力,  Prev: データ構造,  Up: Python チュートリアル

2.6 モジュール
==============

Python インタプリタを終了させ、再び起動すると、これまでに行ってきた定義
(関数や変数) は失われています。ですから、より長いプログラムを書きたいな
ら、テキストエディタを使ってインタプリタへの入力を用意しておき、手作業の
代わりにファイルを入力に使って動作させるとよいでしょう。この作業を 'スク
リプト (script)' の作成と言います。プログラムが長くなるにつれ、メンテナ
ンスを楽にするために、スクリプトをいくつかのファイルに分割したくなるかも
しれません。また、いくつかのプログラムで書いてきた便利な関数について、そ
の定義をコピーすることなく個々のプログラムで使いたいと思うかもしれません
。

こういった要求をサポートするために、Python では定義をファイルに書いてお
き、スクリプトの中やインタプリタの対話インスタンス上で使う方法があります
。このファイルを 'モジュール (module)' と呼びます。モジュールにある定義
は、他のモジュールや 'main' モジュール (実行のトップレベルや電卓モードで
アクセスできる変数の集まりを指します) に 'import' (取り込み) することが
できます。

モジュールは Python の定義や文が入ったファイルです。ファイル名はモジュー
ル名に接尾語 ‘.py’ がついたものになります。モジュールの中では、(文字列の
) モジュール名をグローバル変数 ‘__name__’ で取得できます。例えば、お気に
入りのテキストエディタを使って、現在のディレクトリに以下の内容のファイル
‘fibo.py’ を作成してみましょう:

     # Fibonacci numbers module

     def fib(n):    # write Fibonacci series up to n
         a, b = 0, 1
         while a < n:
             print(a, end=' ')
             a, b = b, a+b
         print()

     def fib2(n):   # return Fibonacci series up to n
         result = []
         a, b = 0, 1
         while a < n:
             result.append(a)
             a, b = b, a+b
         return result

次に Python インタプリタに入り、モジュールを以下のコマンドで import しま
しょう:

     >>> import fibo

この操作では、‘fibo’ で定義された関数の名前を直接現在の *note namespace:
1bc1. (詳細は *note Python のスコープと名前空間: 1bc2. を参照してくださ
い)に追加することはありません。単にモジュール名 ‘fibo’ だけを名前空間に
追加します。関数にはモジュール名を使ってアクセスします:

     >>> fibo.fib(1000)
     0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
     >>> fibo.fib2(100)
     [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
     >>> fibo.__name__
     'fibo'

関数を度々使うのなら、ローカルな名前に代入できます:

     >>> fib = fibo.fib
     >>> fib(500)
     0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

* Menu:

* モジュールについてもうすこし::
* 標準モジュール::
* dir() 関数: dir 関数.
* パッケージ::


File: python.info,  Node: モジュールについてもうすこし,  Next: 標準モジュール,  Up: モジュール<2>

2.6.1 モジュールについてもうすこし
----------------------------------

モジュールには、関数定義に加えて実行文を入れることができます。これらの実
行文はモジュールを初期化するためのものです。これらの実行文は、インポート
文の中で '最初に' モジュール名が見つかったときにだけ実行されます。(1) (フ
ァイルがスクリプトとして実行される場合も実行されます。)

各々のモジュールは、自分のプライベートな名前空間を持っていて、モジュール
で定義されている関数はこのテーブルをグローバルな名前空間として使います。
したがって、モジュールの作者は、ユーザのグローバル変数と偶然的な衝突が起
こる心配をせずに、グローバルな変数をモジュールで使うことができます。一方
、自分が行っている操作をきちんと理解していれば、モジュール内の関数を参照
するのと同じ表記法 ‘modname.itemname’ で、モジュールのグローバル変数をい
じることもできます。

モジュールは他のモジュールをインポートできます。 *note import: 5ac. 文は
モジュール（さらに言えばスクリプトでも）の先頭に置きますが、これは慣習で
あって必須ではありません。インポートされたモジュール名は、モジュールのト
ップレベル（関数やクラスの外）に書いてあれば、モジュールのグローバルな名
前空間に置かれます。

*note import: 5ac. 文には、あるモジュール内の名前を、import を実行してい
るモジュールの名前空間内に直接取り込むという変型があります。例えば:

     >>> from fibo import fib, fib2
     >>> fib(500)
     0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

この操作は、import の対象となるモジュール名をローカルな名前空間内に取り
入れることはありません (従って上の例では、 ‘fibo’ は定義されません)。

モジュールで定義されている名前を全て import するという変型もあります:

     >>> from fibo import *
     >>> fib(500)
     0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

この書き方ではアンダースコア (‘_’) で始まるものを除いてすべての名前をイ
ンポートします。殆どの場面で、Python プログラマーはこの書き方を使いませ
ん。未知の名前がインタープリターに読み込まれ、定義済みの名前を上書きして
しまう可能性があるからです。

一般的には、モジュールやパッケージから ‘*’ を import するというやり方に
は賛同できません。というのは、この操作を行うとしばしば可読性に乏しいコー
ドになるからです。しかし、対話セッションでキータイプの量を減らすために使
うのは構わないでしょう。

モジュール名の後に ‘as’ が続いていた場合は、 ‘as’ の後ろの名前を直接、イ
ンポートされたモジュールが束縛します。

     >>> import fibo as fib
     >>> fib.fib(500)
     0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

これは実質的には ‘import fibo’ と同じ方法でモジュールをインポートしてい
て、唯一の違いはインポートしたモジュールが ‘fib’ という名前で取り扱える
ようになっていることです。

このインポート方法は *note from: 127d. が付いていても使え、同じ効果が得
られます:

     >>> from fibo import fib as fibonacci
     >>> fibonacci(500)
     0 1 1 2 3 5 8 13 21 34 55 89 144 233 377

     注釈: 実行効率上の理由で、各モジュールはインタープリタの 1 セッショ
     ンごとに 1 回だけ import されます。従って、モジュールを修正した場合
     には、インタープリタを再起動させなければなりません - もしくは、その
     場で手直ししてテストしたいモジュールが 1 つだった場合には、例えば
     ‘import importlib; importlib.reload(modulename)’ のように *note
     importlib.reload(): 4e2. を使ってください。

* Menu:

* モジュールをスクリプトとして実行する::
* モジュール検索パス::
* "コンパイル" された Python ファイル::

   ---------- Footnotes ----------

   (1) 実際には、関数定義も '実行' される '文' です。モジュールレベルの
関数定義を実行すると、関数名はモジュールのグローバルな名前空間に追加され
ます。


File: python.info,  Node: モジュールをスクリプトとして実行する,  Next: モジュール検索パス,  Up: モジュールについてもうすこし

2.6.1.1 モジュールをスクリプトとして実行する
............................................

Python モジュールを

     python fibo.py <arguments>

と実行すると、‘__name__’ に ‘__main__’ が設定されている点を除いて import
したときと同じようにモジュール内のコードが実行されます。つまりモジュール
の末尾に:

     if __name__ == "__main__":
         import sys
         fib(int(sys.argv[1]))

このコードを追加することで、このファイルが import できるモジュールである
と同時にスクリプトとしても使えるようになります。なぜならモジュールが
"main" ファイルとして起動されたときだけ、コマンドラインを解釈するコード
が実行されるからです:

     $ python fibo.py 50
     0 1 1 2 3 5 8 13 21 34

モジュールが import された場合は、そのコードは実行されません:

     >>> import fibo
     >>>

この方法はモジュールに便利なユーザインターフェースを提供したり、テストの
ために (スクリプトをモジュールとして起動しテストスイートを実行して) 使わ
れます。


File: python.info,  Node: モジュール検索パス,  Next: "コンパイル" された Python ファイル,  Prev: モジュールをスクリプトとして実行する,  Up: モジュールについてもうすこし

2.6.1.2 モジュール検索パス
..........................

‘spam’ という名前のモジュールをインポートするとき、インタープリタはまず
その名前の組み込みモジュールを探します。モジュール名の一覧は *note
sys.builtin_module_names: 1bc9. にあります。見つからなかった場合は、
‘spam.py’ という名前のファイルを *note sys.path: 38e. にあるディレクトリ
のリストから探します。 *note sys.path: 38e. は以下の場所に初期化されます
:

   * 入力されたスクリプトのあるディレクトリ (あるいはファイルが指定され
     なかったときはカレントディレクトリ)。

   * *note PYTHONPATH: fe8. (ディレクトリ名のリスト。シェル変数の ‘PATH’
     と同じ構文)。

   * インストール方法に依存したデフォルト（慣例として ‘site-packages’ デ
     ィレクトリーが含まれ、*note site: b5. モジュールによって処理される
     ）。

詳細は *note sys.path モジュール検索パスの初期化: 1bca. を参照してくださ
い。

     注釈: シンボリックリンクをサポートするファイルシステム上では、入力
     されたスクリプトのあるディレクトリはシンボリックリンクをたどった後
     に計算されます。言い換えるとシンボリックリンクを含むディレクトリは
     モジュール検索パスに追加 'されません'。

初期化された後、 Python プログラムは *note sys.path: 38e. を修正すること
ができます。スクリプトファイルを含むディレクトリが検索パスの先頭、標準ラ
イブラリパスよりも前に追加されます。なので、ライブラリのディレクトリにあ
るファイルよりも、そのディレクトリにある同じ名前のスクリプトが優先してイ
ンポートされます。これは、標準ライブラリを意図して置き換えているのでない
限りは間違いのもとです。より詳しい情報は *note 標準モジュール: 1bcb. を
参照してください。


File: python.info,  Node: "コンパイル" された Python ファイル,  Prev: モジュール検索パス,  Up: モジュールについてもうすこし

2.6.1.3 "コンパイル" された Python ファイル
...........................................

モジュールの読み込みを高速化するため、Python はコンパイル済みの各モジュ
ールを ‘__pycache__’ ディレクトリの ‘module.`version'.pyc’ ファイルとし
てキャッシュします。ここで version はコンパイルされたファイルのフォーマ
ットを表すもので、一般的には Python のバージョン番号です。例えば、
CPython のリリース 3.3 の、コンパイル済みの spam.py は
‘__pycache__/spam.cpython-33.pyc’ としてキャッシュされるでしょう。この命
名の慣習により、Python の異なる複数のリリースやバージョンのコンパイル済
みモジュールが共存できます。

Python はソースの変更日時をコンパイル済みのものと比較し、コンパイル済み
のものが最新でなくなり再コンパイルが必要になっていないかを確認します。こ
れは完全に自動で処理されます。また、コンパイル済みモジュールはプラットフ
ォーム非依存なため、アーキテクチャの異なるシステム間で同一のライブラリを
共有することもできます。

Python は2つの場合にキャッシュのチェックを行いません。ひとつは、コマンド
ラインから直接モジュールが読み込まれた場合で、常に再コンパイルされ、結果
を保存することはありません。2つめは、ソース・モジュールのない場合で、キ
ャッシュの確認を行いません。ソースのない (コンパイル済みのもののみの) 配
布をサポートするには、コンパイル済みモジュールはソース・ディレクトリにな
くてはならず、ソース・ディレクトリにソース・モジュールがあってはいけませ
ん。

エキスパート向けのTips:

   * コンパイル済みモジュールのサイズを小さくするために、Python コマンド
     に *note -O: d82. または *note -OO: d83. スイッチを使うことができま
     す。‘-O’ スイッチは assert ステートメントを除去し、‘-OO’ スイッチは
     assert ステートメントと __doc__ 文字列を除去します。いくつかのプロ
     グラムはこれらの除去されるものに依存している可能性があるため、自分
     が何をしているかを理解しているときに限ってこれらのオプションを使う
     べきです。"最適化" されたモジュールは ‘opt-’ タグを持ち、通常のコン
     パイル済みモジュールよりサイズが小さくなります。将来のリリースでは
     最適化の影響が変わる可能性があります。

   * ‘.pyc’ ファイルや ‘.pyo’ ファイルから読み出されたとしても、プログラ
     ムは ‘.py’ ファイルから読み出されたときより何ら高速に動作するわけで
     はありません。‘.pyc’ ファイルで高速化されるのは、読み込みにかかる時
     間だけです。

   * *note compileall: 19. モジュールを使ってディレクトリ内の全てのモジ
     ュールに対して .pyc ファイルを作ることができます。

   * この処理に関する詳細は、判定のフローチャートを含めて、 PEP 3147(1)
     に記載されています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3147/


File: python.info,  Node: 標準モジュール,  Next: dir 関数,  Prev: モジュールについてもうすこし,  Up: モジュール<2>

2.6.2 標準モジュール
--------------------

Python は標準モジュールライブラリを同梱していて、別の Python ライブラリ
リファレンスというドキュメントで解説しています。幾つかのモジュールは言語
のコアにはアクセスしないものの、効率や、システムコールなどOSの機能を利用
するために、インタープリター内部にビルトインされています。そういったモジ
ュールセットはまたプラットフォームに依存した構成オプションです。例えば、
*note winreg: fe. モジュールは Windows システムでのみ提供されています。
1つ注目に値するモジュールとして、 *note sys: c3. モジュールは、全ての
Python インタープリターにビルトインされています。 ‘sys.ps1’ と ‘sys.ps2’
という変数は一次プロンプトと二次プロンプトに表示する文字列を定義していま
す:

     >>> import sys
     >>> sys.ps1
     '>>> '
     >>> sys.ps2
     '... '
     >>> sys.ps1 = 'C> '
     C> print('Yuck!')
     Yuck!
     C>

これらの二つの変数は、インタプリタが対話モードにあるときだけ定義されてい
ます。

変数 ‘sys.path’ は文字列からなるリストで、インタプリタがモジュールを検索
するときのパスを決定します。 ‘sys.path’ は環境変数 *note PYTHONPATH:
fe8. から得たデフォルトパスに、 *note PYTHONPATH: fe8. が設定されていな
ければ組み込みのデフォルト値に設定されます。標準的なリスト操作で変更する
ことができます:

     >>> import sys
     >>> sys.path.append('/ufs/guido/lib/python')


File: python.info,  Node: dir 関数,  Next: パッケージ,  Prev: 標準モジュール,  Up: モジュール<2>

2.6.3 ‘dir()’ 関数
------------------

組込み関数 *note dir(): 5fe. は、あるモジュールがどんな名前を定義してい
るか調べるために使われます。 *note dir(): 5fe. はソートされた文字列のリ
ストを返します:

     >>> import fibo, sys
     >>> dir(fibo)
     ['__name__', 'fib', 'fib2']
     >>> dir(sys)
     ['__breakpointhook__', '__displayhook__', '__doc__', '__excepthook__',
      '__interactivehook__', '__loader__', '__name__', '__package__', '__spec__',
      '__stderr__', '__stdin__', '__stdout__', '__unraisablehook__',
      '_clear_type_cache', '_current_frames', '_debugmallocstats', '_framework',
      '_getframe', '_git', '_home', '_xoptions', 'abiflags', 'addaudithook',
      'api_version', 'argv', 'audit', 'base_exec_prefix', 'base_prefix',
      'breakpointhook', 'builtin_module_names', 'byteorder', 'call_tracing',
      'callstats', 'copyright', 'displayhook', 'dont_write_bytecode', 'exc_info',
      'excepthook', 'exec_prefix', 'executable', 'exit', 'flags', 'float_info',
      'float_repr_style', 'get_asyncgen_hooks', 'get_coroutine_origin_tracking_depth',
      'getallocatedblocks', 'getdefaultencoding', 'getdlopenflags',
      'getfilesystemencodeerrors', 'getfilesystemencoding', 'getprofile',
      'getrecursionlimit', 'getrefcount', 'getsizeof', 'getswitchinterval',
      'gettrace', 'hash_info', 'hexversion', 'implementation', 'int_info',
      'intern', 'is_finalizing', 'last_traceback', 'last_type', 'last_value',
      'maxsize', 'maxunicode', 'meta_path', 'modules', 'path', 'path_hooks',
      'path_importer_cache', 'platform', 'prefix', 'ps1', 'ps2', 'pycache_prefix',
      'set_asyncgen_hooks', 'set_coroutine_origin_tracking_depth', 'setdlopenflags',
      'setprofile', 'setrecursionlimit', 'setswitchinterval', 'settrace', 'stderr',
      'stdin', 'stdout', 'thread_info', 'unraisablehook', 'version', 'version_info',
      'warnoptions']

引数がなければ、 *note dir(): 5fe. は現在定義している名前を列挙します:

     >>> a = [1, 2, 3, 4, 5]
     >>> import fibo
     >>> fib = fibo.fib
     >>> dir()
     ['__builtins__', '__name__', 'a', 'fib', 'fibo', 'sys']

変数、モジュール、関数、その他の、すべての種類の名前をリストすることに注
意してください。

*note dir(): 5fe. は、組込みの関数や変数の名前はリストしません。これらの
名前からなるリストが必要なら、標準モジュール *note builtins: e. で定義さ
れています:

     >>> import builtins
     >>> dir(builtins)
     ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException',
      'BlockingIOError', 'BrokenPipeError', 'BufferError', 'BytesWarning',
      'ChildProcessError', 'ConnectionAbortedError', 'ConnectionError',
      'ConnectionRefusedError', 'ConnectionResetError', 'DeprecationWarning',
      'EOFError', 'Ellipsis', 'EnvironmentError', 'Exception', 'False',
      'FileExistsError', 'FileNotFoundError', 'FloatingPointError',
      'FutureWarning', 'GeneratorExit', 'IOError', 'ImportError',
      'ImportWarning', 'IndentationError', 'IndexError', 'InterruptedError',
      'IsADirectoryError', 'KeyError', 'KeyboardInterrupt', 'LookupError',
      'MemoryError', 'NameError', 'None', 'NotADirectoryError', 'NotImplemented',
      'NotImplementedError', 'OSError', 'OverflowError',
      'PendingDeprecationWarning', 'PermissionError', 'ProcessLookupError',
      'ReferenceError', 'ResourceWarning', 'RuntimeError', 'RuntimeWarning',
      'StopIteration', 'SyntaxError', 'SyntaxWarning', 'SystemError',
      'SystemExit', 'TabError', 'TimeoutError', 'True', 'TypeError',
      'UnboundLocalError', 'UnicodeDecodeError', 'UnicodeEncodeError',
      'UnicodeError', 'UnicodeTranslateError', 'UnicodeWarning', 'UserWarning',
      'ValueError', 'Warning', 'ZeroDivisionError', '_', '__build_class__',
      '__debug__', '__doc__', '__import__', '__name__', '__package__', 'abs',
      'all', 'any', 'ascii', 'bin', 'bool', 'bytearray', 'bytes', 'callable',
      'chr', 'classmethod', 'compile', 'complex', 'copyright', 'credits',
      'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec', 'exit',
      'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr',
      'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass',
      'iter', 'len', 'license', 'list', 'locals', 'map', 'max', 'memoryview',
      'min', 'next', 'object', 'oct', 'open', 'ord', 'pow', 'print', 'property',
      'quit', 'range', 'repr', 'reversed', 'round', 'set', 'setattr', 'slice',
      'sorted', 'staticmethod', 'str', 'sum', 'super', 'tuple', 'type', 'vars',
      'zip']


File: python.info,  Node: パッケージ,  Prev: dir 関数,  Up: モジュール<2>

2.6.4 パッケージ
----------------

パッケージ (package) は、Python のモジュール名前空間を "ドット付きモジュ
ール名" を使って構造化する手段です。例えば、モジュール名 ‘A.B’ は、 ‘A’
というパッケージのサブモジュール ‘B’ を表します。ちょうど、モジュールを
利用すると、別々のモジュールの著者が互いのグローバル変数名について心配し
なくても済むようになるのと同じように、ドット付きモジュール名を利用すると
、 NumPy や Pillow のように複数モジュールからなるパッケージの著者が、互
いのモジュール名について心配しなくても済むようになります。

音声ファイルや音声データを一様に扱うためのモジュールのコレクション ("パ
ッケージ") を設計したいと仮定しましょう。 音声ファイルには多くの異なった
形式がある (通常は拡張子、 例えば ‘.wav’, ‘.aiff’, ‘.au’ などで認識され
ます) ので、増え続ける様々なファイル形式を相互変換するモジュールを、 作
成したりメンテナンスしたりする必要があるかもしれません。 また、 音声デー
タに対して実行したい様々な独自の操作 (ミキシング、 エコーの追加、 イコラ
イザ関数の適用、 人工的なステレオ効果の作成など) があるかもしれません。
そうなると、 こうした操作を実行するモジュールを果てしなく書くことになる
でしょう。 以下に (階層的なファイルシステムで表現した) パッケージの構造
案を示します:

     sound/                          Top-level package
           __init__.py               Initialize the sound package
           formats/                  Subpackage for file format conversions
                   __init__.py
                   wavread.py
                   wavwrite.py
                   aiffread.py
                   aiffwrite.py
                   auread.py
                   auwrite.py
                   ...
           effects/                  Subpackage for sound effects
                   __init__.py
                   echo.py
                   surround.py
                   reverse.py
                   ...
           filters/                  Subpackage for filters
                   __init__.py
                   equalizer.py
                   vocoder.py
                   karaoke.py
                   ...

パッケージを import する際、 Python は ‘sys.path’ 上のディレクトリを検索
して、トップレベルのパッケージの入ったサブディレクトリを探します。

ファイルを含むディレクトリをパッケージとしてPython に扱わせるには、ファ
イル ‘__init__.py’ が必要です(より高度な機能 *note namespace package:
1bd2. を使う場合を除く)。 これにより、 ‘string’ のようなよくある名前のデ
ィレクトリにより、モジュール検索パスの後の方で見つかる正しいモジュールが
意図せず隠蔽されてしまうのを防ぐためです。 最も簡単なケースでは
‘__init__.py’ はただの空ファイルで構いませんが、 ‘__init__.py’ ではパッ
ケージのための初期化コードを実行したり、後述の ‘__all__’ 変数を設定して
もかまいません。

パッケージのユーザは、個々のモジュールをパッケージから import することが
できます。例えば:

     import sound.effects.echo

この操作はサブモジュール ‘sound.effects.echo’ をロードします。このモジュ
ールは、以下のように完全な名前で参照しなければなりません。

     sound.effects.echo.echofilter(input, output, delay=0.7, atten=4)

サブモジュールを import するもう一つの方法を示します:

     from sound.effects import echo

これもサブモジュール ‘echo’ をロードし、パッケージ名なしで利用可能にしま
す。なのでこう使えます:

     echo.echofilter(input, output, delay=0.7, atten=4)

さらにもう一つのバリエーションとして、必要な関数や変数を直接 import する
方法があります:

     from sound.effects.echo import echofilter

また、これもサブモジュール ‘echo’ をロードしますが、 ‘echofilter()’ 関数
を直接利用可能にします:

     echofilter(input, output, delay=0.7, atten=4)

‘from package import item’ を使う場合、 'item' はパッケージ 'package' の
サブモジュール (またはサブパッケージ) でもかまいませんし、関数やクラス、
変数のような、 'package' で定義されている別の名前でもかまわないことに注
意してください。 ‘import’ 文はまず、 'item' がパッケージ内で定義されてい
るかどうか調べます。定義されていなければ、 'item' はモジュール名であると
仮定して、モジュールをロードしようと試みます。もしモジュールが見つからな
ければ、 *note ImportError: 3f2. が送出されます。

反対に、 ‘import item.subitem.subsubitem’ のような構文を使った場合、最後
の ‘subsubitem’ を除く各要素はパッケージでなければなりません。最後の要素
はモジュールかパッケージにできますが、一つ前の要素で定義されているクラス
や関数や変数にはできません。

* Menu:

* パッケージから * を import する::
* パッケージ内参照::
* 複数ディレクトリ中のパッケージ::


File: python.info,  Node: パッケージから * を import する,  Next: パッケージ内参照,  Up: パッケージ

2.6.4.1 パッケージから * を import する
.......................................

それでは、ユーザが ‘from sound.effects import *’ と書いたら、どうなるの
でしょうか？理想的には、何らかの方法でファイルシステムが調べられ、そのパ
ッケージにどんなサブモジュールがあるかを調べ上げ、全てを import する、と
いう処理を望むことでしょう。これには長い時間がかかってしまうこともありま
すし、あるサブモジュールを import することで、そのモジュールが明示的に
import されたときのみ発生して欲しい副作用が起きてしまうかもしれません。

唯一の解決策は、パッケージの作者にパッケージの索引を明示的に提供させる と
いうものです。 *note import: 5ac. 文の使う規約は、パッケージの
‘__init__.py’ コードに ‘__all__’ という名前のリストが定義されていれば、
‘from package import *’ が現れたときに import すべきモジュール名のリスト
として使う、というものです。 パッケージの新バージョンがリリースされると
きにリストを最新の状態に更新するのは パッケージの作者の責任となります。
自分のパッケージから * を import するという使い方が考えられないならば、
パッケージの作者はこの使い方をサポートしないことにしてもかまいません。 例
えば、ファイル ‘sound/effects/__init__.py’ には、次のような コードを入れ
てもよいかもしれません:

     __all__ = ["echo", "surround", "reverse"]

これが意味するのは、 ‘from sound.effects import *’ とすると、名前の挙が
った 3つのサブモジュールが ‘sound.effects’ パッケージから import される
、ということです。

注意点として、サブモジュールはローカルな名前で隠されることがあります。例
として、 ‘reverse’ 関数を ‘sound/effects/__init__.py’ に足すと、 ‘from
sound.effects import *’ では ‘echo’ と ‘surround’ の２サブモジュールだけ
import されます。 ‘reverse’ サブモジュールは import 'されません' 。それ
はローカルに定義された ‘reverse’ 関数で隠されたので:

     __all__ = [
         "echo",      # refers to the 'echo.py' file
         "surround",  # refers to the 'surround.py' file
         "reverse",   # !!! refers to the 'reverse' function now !!!
     ]

     def reverse(msg: str):  # <-- this name shadows the 'reverse.py' submodule
         return msg[::-1]    #     in the case of a 'from sound.effects import *'

もしも ‘__all__’ が定義されていなければ、実行文 ‘from sound.effects
import *’ は、パッケージ ‘sound.effects’ の全てのサブモジュールを現在の
名前空間の中へ import 'しません' 。この文は単に(場合によっては初期化コー
ド ‘__init__.py’ を実行して) パッケージ ‘sound.effects’ が import された
ということを確認し、そのパッケージで定義されている名前を全て import する
だけです。 import される名前には、 ‘__init__.py’ で定義された名前 (と、
明示的にロードされたサブモジュール) が含まれます。パッケージのサブモジュ
ールで、以前の *note import: 5ac. 文で明示的にロードされたものも含みます
。以下のコードを考えてください:

     import sound.effects.echo
     import sound.effects.surround
     from sound.effects import *

上の例では、 ‘echo’ と ‘surround’ モジュールが現在の名前空間に import さ
れます。これらのモジュールは ‘from...import’ 文が実行された際に
‘sound.effects’ 内で定義されているからです。 (この機構は ‘__all__’ が定
義されているときにも働きます。)

特定のモジュールでは ‘import *’ を使ったときに、特定のパターンに従った名
前のみを公開 (export) するように設計されてはいますが、それでもやはり製品
のコードでは良いことではないと考えます。

‘from package import specific_submodule’ を使っても何も問題はないことに
留意してください！実際この表記法は、import を行うモジュールが他のパッケ
ージと同じ名前を持つサブモジュールを使わなければならない場合を除いて推奨
される方式です。


File: python.info,  Node: パッケージ内参照,  Next: 複数ディレクトリ中のパッケージ,  Prev: パッケージから * を import する,  Up: パッケージ

2.6.4.2 パッケージ内参照
........................

パッケージが (前述の例の ‘sound’ パッケージのように) サブパッケージの集
まりに構造化されている場合、絶対 import を使って兄弟関係にあるパッケージ
を参照できます。例えば、モジュール ‘sound.filters.vocoder’ で
‘sound.effects’ パッケージの ‘echo’ モジュールが必要な場合、 ‘from
sound.effects import echo’ が使えます。

また、明示的な相対importを ‘from module import name’ の形式の import 文
で利用できます。この明示的な相対 import では、先頭のドットで現在および親
パッケージを指定します。 ‘surround’ モジュールの例では、以下のように記述
できます:

     from . import echo
     from .. import formats
     from ..filters import equalizer

相対 import は現在のモジュール名をベースにすることに注意してください。メ
インモジュールの名前は常に ‘"__main__"’ なので、Python アプリケーション
のメインモジュールとして利用されることを意図しているモジュールでは絶対
import を利用するべきです。


File: python.info,  Node: 複数ディレクトリ中のパッケージ,  Prev: パッケージ内参照,  Up: パッケージ

2.6.4.3 複数ディレクトリ中のパッケージ
......................................

Packages support one more special attribute, *note __path__: 1bd8.  This
is initialized to be a *note sequence: 4be. of strings containing the
name of the directory holding the package's ‘__init__.py’ before the
code in that file is executed.  This variable can be modified; doing so
affects future searches for modules and subpackages contained in the
package.

この機能はほとんど必要にはならないのですが、パッケージ内存在するモジュー
ル群を拡張するために使うことができます。

脚注
....


File: python.info,  Node: 入力と出力,  Next: エラーと例外,  Prev: モジュール<2>,  Up: Python チュートリアル

2.7 入力と出力
==============

プログラムの出力方法にはいくつかの種類があります。 データを人間が読める
形で出力することもあれば、将来使うためにファイルに書くこともあります。 こ
の章では、こうした幾つかの出力の方法について話します。

* Menu:

* 出力を見やすくフォーマットする::
* ファイルを読み書きする::


File: python.info,  Node: 出力を見やすくフォーマットする,  Next: ファイルを読み書きする,  Up: 入力と出力

2.7.1 出力を見やすくフォーマットする
------------------------------------

これまでに、値を出力する二つの方法: '式文 (expression statement)' と
*note print(): f42. 関数が出てきました。 (第三はファイルオブジェクトの
*note write(): 1bde. メソッドを使う方法です。標準出力を表すファイルは
‘sys.stdout’ で参照できます。詳細はライブラリリファレンスを参照してくだ
さい。)

単に空白区切りで値を並べただけの出力よりも、フォーマットを制御したいと思
うことはよくあることでしょう。 出力をフォーマットする方法はいくつかあり
ます。

   * *note フォーマット済み文字列リテラル: 1bdf. を使うには、開き引用符
     や三重の開き引用符の前に ‘f’ あるいは ‘F’ を付けて文字列を始めます
     。 この文字列の内側では、文字 ‘{’ と文字 ‘}’ の間に Python の式が書
     け、その式から変数やリテラル値が参照できます。

          >>> year = 2016
          >>> event = 'Referendum'
          >>> f'Results of the {year} {event}'
          'Results of the 2016 Referendum'

   * 文字列の *note str.format(): 5ed. メソッドは、もう少し手間がかかり
     ます。 ここでも ‘{’ と ‘}’ を使って変数に代入する場所の印を付けて、
     細かいフォーマットの指示を出せますが、フォーマットされる対象の情報
     を与える必要があります。次のコードには、変数をフォーマットする方法
     の例が二つあります:

          >>> yes_votes = 42_572_654
          >>> total_votes = 85_705_149
          >>> percentage = yes_votes / total_votes
          >>> '{:-9} YES votes  {:2.2%}'.format(yes_votes, percentage)
          ' 42572654 YES votes  49.67%'

     ‘yes_votes’ が、スペースと、負数の場合は負符号で埋められていること
     に注意してください。この例では、100を掛けた ‘percentage’ を、パーセ
     ント記号付きで小数点以下2桁で表示することも行っています。 (詳細は、
     *note 書式指定ミニ言語仕様: 1c9. を参照してください。)

   * 最後に、文字列のスライス操作や結合操作を使い、全ての文字列を自分で
     処理し、思い通りのレイアウトを作成できます。 文字列型には、文字列の
     間隔を調整して指定されたカラム幅に揃えるのに便利な操作を行うメソッ
     ドがいくつかあります。

凝った出力である必要は無いけれど、デバッグ目的で変数をすばやく表示したい
ときは、 *note repr(): 7c8. 関数か *note str(): 418. 関数でどんな値も文
字列に変換できます。

*note str(): 418. 関数は値の人間に読める表現を返すためのもので、 *note
repr(): 7c8. 関数はインタープリタに読める (あるいは同値となる構文がない
場合は必ず *note SyntaxError: 172. になるような) 表現を返すためのもので
す。人間が読むのに適した特定の表現を持たないオブジェクトにおいては、
*note str(): 418. は *note repr(): 7c8. と同じ値を返します。数値や、リス
トや辞書を始めとするデータ構造など、多くの値がどちらの関数に対しても同じ
表現を返します。一方、文字列は、2つの異なる表現を持っています。

いくつかの例です:

     >>> s = 'Hello, world.'
     >>> str(s)
     'Hello, world.'
     >>> repr(s)
     "'Hello, world.'"
     >>> str(1/7)
     '0.14285714285714285'
     >>> x = 10 * 3.25
     >>> y = 200 * 200
     >>> s = 'The value of x is ' + repr(x) + ', and y is ' + repr(y) + '...'
     >>> print(s)
     The value of x is 32.5, and y is 40000...
     >>> # The repr() of a string adds string quotes and backslashes:
     >>> hello = 'hello, world\n'
     >>> hellos = repr(hello)
     >>> print(hellos)
     'hello, world\n'
     >>> # The argument to repr() may be any Python object:
     >>> repr((x, y, ('spam', 'eggs')))
     "(32.5, 40000, ('spam', 'eggs'))"

*note string: be. モジュールの *note Template: 653. クラスも、文字列中の
値を置換する別の方法を提供しています。 ‘$x’ のようなプレースホルダーを使
い、その箇所と辞書にある値を置き換えますが、使えるフォーマット方式はとて
も少ないです。

* Menu:

* フォーマット済み文字列リテラル::
* 文字列の format() メソッド: 文字列の format メソッド.
* 文字列の手作業でのフォーマット::
* 古い文字列書式設定方法::


File: python.info,  Node: フォーマット済み文字列リテラル,  Next: 文字列の format メソッド,  Up: 出力を見やすくフォーマットする

2.7.1.1 フォーマット済み文字列リテラル
......................................

*note フォーマット済み文字リテラル: 977. (短くして f-string とも呼びます
) では、文字列の頭に ‘f’ か ‘F’ を付け、式を ‘{expression}’ と書くことで
、 Python の式の値を文字列の中に入れ込めます。

オプションのフォーマット指定子を式の後ろに付けられます。 このフォーマッ
ト指定子によって値のフォーマット方式を制御できます。 次の例では、円周率
πを小数点以下3桁に丸めてフォーマットしています:

     >>> import math
     >>> print(f'The value of pi is approximately {math.pi:.3f}.')
     The value of pi is approximately 3.142.

‘':'’ の後ろに整数をつけると、そのフィールドの最小の文字幅を指定できます
。 この機能は縦を揃えるのに便利です。

     >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 7678}
     >>> for name, phone in table.items():
     ...     print(f'{name:10} ==> {phone:10d}')
     ...
     Sjoerd     ==>       4127
     Jack       ==>       4098
     Dcab       ==>       7678

他の修飾子は、フォーマットする前に値を変換するのに使えます。 ‘'!a'’ は
*note ascii(): 138e. を、 ‘'!s'’ は *note str(): 418. を、 ‘'!r'’ は
*note repr(): 7c8. を適用します:

     >>> animals = 'eels'
     >>> print(f'My hovercraft is full of {animals}.')
     My hovercraft is full of eels.
     >>> print(f'My hovercraft is full of {animals!r}.')
     My hovercraft is full of 'eels'.

‘=’ 指定子を使用すると式を展開して、式、イコール記、式を評価した文字列表
現、の形式で表示されます。

     >>> bugs = 'roaches'
     >>> count = 13
     >>> area = 'living room'
     >>> print(f'Debugging {bugs=} {count=} {area=}')
     Debugging bugs='roaches' count=13 area='living room'

‘=’ 指定子の詳細については *note self-documenting expressions: 975. を参
照してください。 フォーマットについての仕様は *note
書式指定ミニ言語仕様: 1c9. のリファレンスガイドを参照してください。


File: python.info,  Node: 文字列の format メソッド,  Next: 文字列の手作業でのフォーマット,  Prev: フォーマット済み文字列リテラル,  Up: 出力を見やすくフォーマットする

2.7.1.2 文字列の format() メソッド
..................................

*note str.format(): 5ed. メソッドの基本的な使い方は次のようなものです:

     >>> print('We are the {} who say "{}!"'.format('knights', 'Ni'))
     We are the knights who say "Ni!"

括弧とその中の文字(これをフォーマットフィールドと呼びます)は、 *note
str.format(): 5ed. メソッドに渡されたオブジェクトに置換されます。括弧の
中の数字は *note str.format(): 5ed. メソッドに渡されたオブジェクトの位置
を表すのに使えます。

     >>> print('{0} and {1}'.format('spam', 'eggs'))
     spam and eggs
     >>> print('{1} and {0}'.format('spam', 'eggs'))
     eggs and spam

*note str.format(): 5ed. メソッドにキーワード引数が渡された場合、その値
はキーワード引数の名前によって参照されます。

     >>> print('This {food} is {adjective}.'.format(
     ...       food='spam', adjective='absolutely horrible'))
     This spam is absolutely horrible.

順序引数とキーワード引数を組み合わせて使うこともできます:

     >>> print('The story of {0}, {1}, and {other}.'.format('Bill', 'Manfred',
     ...                                                    other='Georg'))
     The story of Bill, Manfred, and Georg.

もしも長い書式文字列があり、それを分割したくない場合には、変数を引数の位
置ではなく変数の名前で参照できるとよいでしょう。これは、辞書を引数に渡し
て、角括弧 ‘'[]'’ を使って辞書のキーを参照することで可能です。

     >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
     >>> print('Jack: {0[Jack]:d}; Sjoerd: {0[Sjoerd]:d}; '
     ...       'Dcab: {0[Dcab]:d}'.format(table))
     Jack: 4098; Sjoerd: 4127; Dcab: 8637678

辞書 ‘table’ を ‘**’ 記法を使ってキーワード引数として渡す方法もあります
。

     >>> table = {'Sjoerd': 4127, 'Jack': 4098, 'Dcab': 8637678}
     >>> print('Jack: {Jack:d}; Sjoerd: {Sjoerd:d}; Dcab: {Dcab:d}'.format(**table))
     Jack: 4098; Sjoerd: 4127; Dcab: 8637678

全てのローカルな変数が入った辞書を返す組み込み関数 *note vars(): 19ad. と
組み合わせると特に便利です。

     >>> table = {k: str(v) for k, v in vars().items()}
     >>> message = " ".join([f'{k}: ' + '{' + k +'};' for k in table.keys()])
     >>> print(message.format(**table))
     __name__: __main__; __doc__: None; __package__: None; __loader__: ...

例として、下のコード行は与えられた整数とその2乗と3乗がきちんと揃った列を
生成します:

     >>> for x in range(1, 11):
     ...     print('{0:2d} {1:3d} {2:4d}'.format(x, x*x, x*x*x))
     ...
      1   1    1
      2   4    8
      3   9   27
      4  16   64
      5  25  125
      6  36  216
      7  49  343
      8  64  512
      9  81  729
     10 100 1000

*note str.format(): 5ed. による文字列書式設定の完全な解説は、 *note
書式指定文字列の文法: 1358. を参照してください。


File: python.info,  Node: 文字列の手作業でのフォーマット,  Next: 古い文字列書式設定方法,  Prev: 文字列の format メソッド,  Up: 出力を見やすくフォーマットする

2.7.1.3 文字列の手作業でのフォーマット
......................................

次は 2 乗と 3 乗の値からなる同じ表を手作業でフォーマットしたものです:

     >>> for x in range(1, 11):
     ...     print(repr(x).rjust(2), repr(x*x).rjust(3), end=' ')
     ...     # Note use of 'end' on previous line
     ...     print(repr(x*x*x).rjust(4))
     ...
      1   1    1
      2   4    8
      3   9   27
      4  16   64
      5  25  125
      6  36  216
      7  49  343
      8  64  512
      9  81  729
     10 100 1000

(各カラムの間のスペース一個分は *note print(): f42. の動作で追加されてい
ることに注意してください。 *note print(): f42. は常に引数間に空白を追加
します。)

文字列オブジェクトの *note str.rjust(): 1be4. メソッドは、指定された幅の
フィールド内に文字列が右寄せで入るように左側に空白を追加します。 同様の
メソッドとして、 *note str.ljust(): 1be5. と *note str.center(): 1be6. が
あります。 これらのメソッドは何か出力を行うわけではなく、ただ新しい文字
列を返します。 入力文字列が長すぎる場合、文字列を切り詰めることはせず、
値をそのまま返します。この仕様のためにカラムのレイアウトが滅茶苦茶になる
かもしれませんが、嘘の値が代わりに書き出されるよりはましです。 (本当に切
り詰めを行いたいのなら、全てのカラムに ‘x.ljust(n)[:n]’ のようにスライス
表記を加えることもできます。)

もう一つのメソッド、 *note str.zfill(): 1457. は、数値文字列の左側をゼロ
詰めします。このメソッドは正と負の符号を正しく扱います:

     >>> '12'.zfill(5)
     '00012'
     >>> '-3.14'.zfill(7)
     '-003.14'
     >>> '3.14159265359'.zfill(5)
     '3.14159265359'


File: python.info,  Node: 古い文字列書式設定方法,  Prev: 文字列の手作業でのフォーマット,  Up: 出力を見やすくフォーマットする

2.7.1.4 古い文字列書式設定方法
..............................

% 演算子 (剰余) は文字列のフォーマットでも使えます。 ‘format % values’
('format' は文字列) という文字列が与えられた場合、 'format' 中の ‘%’ 変
換指定はゼロあるいは 'values' の余りの要素に置換えられます。この操作は文
字列補間として知られています。例えば:

     >>> import math
     >>> print('The value of pi is approximately %5.3f.' % math.pi)
     The value of pi is approximately 3.142.

より詳しい情報は *note printf 形式の文字列書式化: 698. にあります。


File: python.info,  Node: ファイルを読み書きする,  Prev: 出力を見やすくフォーマットする,  Up: 入力と出力

2.7.2 ファイルを読み書きする
----------------------------

*note open(): 4e5. は *note file object: 1193. を返します。大抵、
‘open(filename, mode, encoding=None)’ のように2つの位置引数と1つのキーワ
ード引数を伴って呼び出されます。

     >>> f = open('workfile', 'w', encoding="utf-8")

最初の引数はファイル名の入った文字列です。二つめの引数も文字列で、ファイ
ルをどのように使うかを示す数個の文字が入っています。 'mode' は、ファイル
が読み出し専用なら ‘'r'’ 、書き込み専用 (同名の既存のファイルがあれば消
去されます) なら ‘'w'’ とします。 ‘'a'’ はファイルを追記用に開きます。フ
ァイルに書き込まれた内容は自動的にファイルの終端に追加されます。 ‘'r+'’
はファイルを読み書き両用に開きます。 'mode' 引数は省略可能で、省略された
場合には ‘'r'’ であると仮定します。

通常、ファイルはテキストモード ('text mode') で開かれ、特定の 'エンコー
ディング' でエンコードされたファイルに対して文字列を読み書きします。'エ
ンコーディング' が指定されなければ、デフォルトはプラットフォーム依存です
(*note open(): 4e5. を参照してください)。UTF-8は現在の事実上の標準のため
、異なるエンコーディングを指定したい場合以外は ‘encoding="utf-8"’ の指定
がおすすめです。モードに ‘'b'’ をつけるとファイルを 'binary mode' で開き
ます。バイナリーモードでのデータは *note bytes: 1a4. オブジェクトで読み
書きします。ファイルをバイナリーモードで開くときは 'エンコーディング' は
指定できません。

テキストモードの読み取りでは、プラットフォーム固有の行末記号 (Unix では
‘\n’ 、Windows では ‘\r\n’) をただの ‘\n’ に変換するのがデフォルトの動作
です。テキストモードの書き込みでは、 ‘\n’ が出てくる箇所をプラットフォー
ム固有の行末記号に戻すのがデフォルトの動作です。この裏で行われるファイル
データの変換はテキストファイルには上手く働きますが、 ‘JPEG’ ファイルや
‘EXE’ ファイルのようなバイナリデータを破壊する恐れがあります。そのような
ファイルを読み書きする場合には注意して、バイナリモードを使うようにしてく
ださい。

ファイルオブジェクトを扱うときに *note with: 59c. キーワードを使うのは良
い習慣です。 その利点は、処理中に例外が発生しても必ず最後にファイルをち
ゃんと閉じることです。 ‘with’ を使うと、同じことを *note try: 6b4.-*note
finally: 997. ブロックを使って書くよりずっと簡潔に書けます:

     >>> with open('workfile', encoding="utf-8") as f:
     ...     read_data = f.read()

     >>> # We can check that the file has been automatically closed.
     >>> f.closed
     True

もし *note with: 59c. キーワードを使用しない場合は、ファイルを閉じ、この
ファイルのために利用されたシステムのリソースを直ちに解放するために
‘f.close()’ を呼び出してください。

     警告: ‘f.write()’ を ‘with’ キーワードや ‘f.close()’ を使わずに呼び
     出した場合、プログラムが正常に終了した場合でも、 ‘f.write()’ の実引
     数がディスクに完全に '書き込まれないことがあります' 。

*note with: 59c. 文や ‘f.close()’ の呼び出しによって閉じられた後にファイ
ルオブジェクトを使おうとするとそこで処理が失敗します。:

     >>> f.close()
     >>> f.read()
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ValueError: I/O operation on closed file.

* Menu:

* ファイルオブジェクトのメソッド::
* json による構造化されたデータの保存::


File: python.info,  Node: ファイルオブジェクトのメソッド,  Next: json による構造化されたデータの保存,  Up: ファイルを読み書きする

2.7.2.1 ファイルオブジェクトのメソッド
......................................

この節の以降の例は、 ‘f’ というファイルオブジェクトが既に生成されている
ものと仮定します。

ファイルの内容を読み出すには、 ‘f.read(size)’ を呼び出します。このメソッ
ドはある量のデータを読み出して、文字列 (テキストモードの場合) か bytes オ
ブジェクト (バイナリーモードの場合) として返します。 'size' はオプション
の数値引数です。 'size' が省略されたり負の数であった場合、ファイルの内容
全てを読み出して返します。ただし、ファイルがマシンのメモリの二倍の大きさ
もある場合にはどうなるかわかりません。 'size' が負でない数ならば、最大で
(テキストモードの場合) 'size' 文字、(バイナリモードの場合) 'size' バイト
を読み出して返します。ファイルの終端にすでに達していた場合、 ‘f.read()’
は空の文字列 (‘''’) を返します。

     >>> f.read()
     'This is the entire file.\n'
     >>> f.read()
     ''

‘f.readline()’ はファイルから 1 行だけを読み取ります。改行文字 (‘\n’) は
読み出された文字列の終端に残ります。改行が省略されるのは、ファイルが改行
で終わっていない場合の最終行のみです。これは、戻り値があいまいでないよう
にするためです; ‘f.readline()’ が空の文字列を返したら、ファイルの終端に
達したことが分かります。一方、空行は ‘'\n'’、すなわち改行 1 文字だけから
なる文字列で表現されます。

     >>> f.readline()
     'This is the first line of the file.\n'
     >>> f.readline()
     'Second line of the file\n'
     >>> f.readline()
     ''

ファイルから複数行を読み取るには、ファイルオブジェクトに対してループを書
く方法があります。この方法はメモリを効率的に使え、高速で、簡潔なコードに
なります:

     >>> for line in f:
     ...     print(line, end='')
     ...
     This is the first line of the file.
     Second line of the file

ファイルのすべての行をリスト形式で読み取りたいなら、‘list(f)’ や
‘f.readlines()’ を使うこともできます。

‘f.write(string)’ は、'string' の内容をファイルに書き込み、書き込まれた
文字数を返します。

     >>> f.write('This is a test\n')
     15

オブジェクトの他の型は、書き込む前に変換しなければなりません - 文字列 (テ
キストモード) と bytes オブジェクト (バイナリーモード) のいずれかです:

     >>> value = ('the answer', 42)
     >>> s = str(value)  # convert the tuple to string
     >>> f.write(s)
     18

‘f.tell()’ は、ファイルオブジェクトのファイル中における現在の位置を示す
整数を返します。ファイル中の現在の位置は、バイナリモードではファイルの先
頭からのバイト数で、テキストモードでは不明瞭な値で表されます。

ファイルオブジェクトの位置を変更するには、‘f.seek(offset, whence)’ を使
います。ファイル位置は基準点 (reference point) にオフセット値 'offset' を
足して計算されます。参照点は 'whence' 引数で選びます。'whence' の値が 0
ならばファイルの 先頭から測り、1 ならば現在のファイル位置を使い、2 なら
ばファイルの終端を参照点として使います。'whence' は省略することができ、
デフォルトの値は 0、すなわち参照点としてファイルの先頭を使います。

     >>> f = open('workfile', 'rb+')
     >>> f.write(b'0123456789abcdef')
     16
     >>> f.seek(5)      # Go to the 6th byte in the file
     5
     >>> f.read(1)
     b'5'
     >>> f.seek(-3, 2)  # Go to the 3rd byte before the end
     13
     >>> f.read(1)
     b'd'

テキストファイル (mode 文字列に ‘b’ を付けなかった場合) では、ファイルの
先頭からの相対位置に対するシークだけが許可されています (例外として、
‘seek(0, 2)’ でファイルの末尾へのシークは可能です)。また、唯一の有効な
'offset' 値は ‘f.tell()’ から返された値か、0 のいずれかです。それ以外の
'offset' 値は未定義の振る舞いを引き起こします。

ファイルオブジェクトには、他にも *note isatty(): 1bec. や *note
truncate(): 12e0. といった、あまり使われないメソッドがあります。ファイル
オブジェクトについての完全なガイドは、ライブラリリファレンスを参照してく
ださい。


File: python.info,  Node: json による構造化されたデータの保存,  Prev: ファイルオブジェクトのメソッド,  Up: ファイルを読み書きする

2.7.2.2 ‘json’ による構造化されたデータの保存
.............................................

文字列は簡単にファイルに読み書きできます。数値の場合には少し努力が必要で
す。というのも、 *note read(): 1bef. メソッドは文字列しか返さないため、
*note int(): 238. のような関数にその文字列を渡して、たとえば文字列
‘'123'’ のような文字列を、数値 123 に変換しなくてはならないからです。も
っと複雑なデータ型、例えば入れ子になったリストや辞書の場合、手作業でのパ
ースやシリアライズは困難になります。

ユーザが毎回コードを書いたりデバッグしたりして複雑なデータ型をファイルに
保存するかわりに、Python では一般的なデータ交換形式である JSON
(JavaScript Object Notation)(1) を使うことができます。この標準モジュール
*note json: 76. は、Python のデータ 階層を取り、文字列表現に変換します。
この処理は 'シリアライズ (serializing)' と呼ばれます。文字列表現からデー
タを再構築することは、'デシリアライズ (deserializing)' と呼ばれます。シ
リアライズされてからデシリアライズされるまでの間に、オブジェクトの文字列
表現はファイルやデータの形で保存したり、ネットワークを通じて離れたマシン
に送ったりすることができます。

     注釈: JSON 形式は現代的なアプリケーションでデータをやりとりする際に
     よく使われます。多くのプログラマーが既に JSON に詳しいため、JSON は
     データの相互交換をする場合の良い選択肢です。

オブジェクト ‘x’ があり、その JSON 形式の文字列表現を見るには、単純な1行
のコードを書くだけです:

     >>> import json
     >>> x = [1, 'simple', 'list']
     >>> json.dumps(x)
     '[1, "simple", "list"]'

*note dumps(): d13. に似た関数に、*note dump(): d12. があり、こちらは単
純にオブジェクトを *note text file: 1bf0. にシリアライズします。‘f’ が書
き込み用に開かれた *note text file: 1bf0. だとすると、次のように書くこと
ができます:

     json.dump(x, f)

逆にデシリアライズするには、‘f’ が読み込み用に開かれた *note binary
file: 1bf1. か *note text file: 1bf0. だとすると、次のようになります:

     x = json.load(f)

     注釈: JSONファイルは必ずUTF-8でエンコードします。JSONファイルを
     *note text file: 1bf0. として読み込み、書き込みで開くときには、
     ‘encoding="utf-8"’ を指定します。

このような単純なシリアライズをする手法は、リストや辞書を扱うことはできま
すが、任意のクラス・インスタンスを JSON にシリアライズするにはもう少し努
力しなくてはなりません。*note json: 76. モジュールのリファレンスにこれに
ついての解説があります。

参考
....

*note pickle: 95. - pickle モジュール

*note JSON: 1bee. とは対照的に、 'pickle' は任意の複雑な Python オブジェ
クトをシリアライズ可能なプロトコルです。しかし、Python に特有のプロトコ
ルで、他の言語で記述されたアプリケーションと通信するのには使えません。さ
らに、デフォルトでは安全でなく、信頼できない送信元から送られてきた、スキ
ルのある攻撃者によって生成された pickle データをデシリアライズすると、攻
撃者により任意のコードが実行されてしまいます。

   ---------- Footnotes ----------

   (1) https://json.org


File: python.info,  Node: エラーと例外,  Next: クラス,  Prev: 入力と出力,  Up: Python チュートリアル

2.8 エラーと例外
================

これまでエラーメッセージについては簡単に触れるだけでしたが、チュートリア
ル中の例を自分で試していたら、実際にいくつかのエラーメッセージを見ている
ことでしょう。エラーには (少なくとも) 二つのはっきり異なる種類があります
。それは '構文エラー (syntax error)' と '例外 (exception)' です。

* Menu:

* 構文エラー::
* 例外::
* 例外を処理する::
* 例外を送出する::
* 例外の連鎖::
* ユーザー定義例外::
* クリーンアップ動作を定義する::
* 定義済みクリーンアップ処理::
* 複数の関連しない例外の送出と処理::
* ノートによって例外を充実させる::


File: python.info,  Node: 構文エラー,  Next: 例外,  Up: エラーと例外

2.8.1 構文エラー
----------------

構文エラーは構文解析エラー (parsing error) としても知られており、Python
を勉強している間に最もよく遭遇する問題の一つでしょう:

     >>> while True print('Hello world')
       File "<stdin>", line 1
         while True print('Hello world')
                    ^^^^^
     SyntaxError: invalid syntax

パーサは違反の起きている行を表示し、小さな「矢印」を表示して、行中でエラ
ーが検出されたトークンを示します。エラーは指し示された '前の' トークンが
存在しないために発生する可能性があります。上記の例では、エラーは関数
*note print(): f42. で検出されています。コロン (‘':'’) がその前に無いか
らです。入力がスクリプトから来ている場合は、どこを見ればよいか分かるよう
にファイル名と行番号が出力されます。


File: python.info,  Node: 例外,  Next: 例外を処理する,  Prev: 構文エラー,  Up: エラーと例外

2.8.2 例外
----------

たとえ文や式が構文的に正しくても、実行しようとしたときにエラーが発生する
かもしれません。実行中に検出されたエラーは '例外 (exception)' と呼ばれ、
常に致命的とは限りません。これから、Python プログラムで例外をどのように
扱うかを学んでいきます。ほとんどの例外はプログラムで処理されず、以下に示
されるようなメッセージになります:

     >>> 10 * (1/0)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
         10 * (1/0)
               ~^~
     ZeroDivisionError: division by zero
     >>> 4 + spam*3
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
         4 + spam*3
             ^^^^
     NameError: name 'spam' is not defined
     >>> '2' + 2
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
         '2' + 2
         ~~~~^~~
     TypeError: can only concatenate str (not "int") to str

エラーメッセージの最終行は何が起こったかを示しています。例外は様々な型
(type) で起こり、その型がエラーメッセージの一部として出力されます。上の
例での型は *note ZeroDivisionError: 913, *note NameError: 40b, *note
TypeError: 502. です。例外型として出力される文字列は、発生した例外の組み
込み名です。これは全ての組み込み例外について成り立ちますが、ユーザ定義の
例外では (成り立つようにするのは有意義な慣習ですが) 必ずしも成り立ちませ
ん。標準例外の名前は組み込みの識別子です (予約語ではありません)。

残りの行は例外の詳細で、その例外の型と何が起きたかに依存します。

エラーメッセージの先頭部分では、例外が発生した実行コンテキスト (context)
を、スタックのトレースバック (stack traceback) の形式で示しています。一
般には、この部分にはソースコード行をリストしたトレースバックが表示されま
す。しかし、標準入力から読み取られたコードは表示されません。

*note 組み込み例外: 17ee. には、組み込み例外とその意味がリストされていま
す。


File: python.info,  Node: 例外を処理する,  Next: 例外を送出する,  Prev: 例外,  Up: エラーと例外

2.8.3 例外を処理する
--------------------

例外を選別して処理するようなプログラムを書くことができます。以下の例を見
てください。この例では、有効な文字列が入力されるまでユーザに入力を促しま
すが、ユーザがプログラムに (‘Control-C’ か、またはオペレーティングシステ
ムがサポートしている何らかのキーを使って) 割り込みをかけてプログラムを中
断させることができるようにしています。ユーザが生成した割り込みは、 *note
KeyboardInterrupt: 99f. 例外が送出されることで通知されるということに注意
してください。

     >>> while True:
     ...     try:
     ...         x = int(input("Please enter a number: "))
     ...         break
     ...     except ValueError:
     ...         print("Oops!  That was no valid number.  Try again...")
     ...

*note try: 6b4. 文は下記のように動作します。

   * まず、 'try 節 (try clause)' (キーワード *note try: 6b4. と *note
     except: 170. の間の文) が実行されます。

   * 何も例外が発生しなければ、 'except 節' をスキップして *note try:
     6b4. 文の実行を終えます。

   * *note try: 6b4. 節内の実行中に例外が発生すると、その節の残りは飛ば
     されます。次に、例外型が *note except: 170. キーワードの後に指定さ
     れている例外に一致する場合、except 節が実行された後、 try/except ブ
     ロックの後ろへ実行が継続されます。

   * もしも 'except 節' で指定された例外と一致しない例外が発生すると、そ
     の例外は *note try: 6b4. 文の外側に渡されます。例外に対するハンドラ
     (handler、処理部) がどこにもなければ、 '処理されない例外 (unhandled
     exception)' となり、エラーメッセージを出して実行を停止します。

一つの *note try: 6b4. 文には複数の 'except 節' が付けられ、別々の例外に
対するハンドラを指定できます。 多くとも一つのハンドラしか実行されません
。 ハンドラは対応する 'try 節' 内で発生した例外だけを処理し、同じ ‘try’
節内の別の例外ハンドラで起きた例外は処理しません。 'except 節' では丸括
弧で囲ったタプルという形で複数の例外を指定できます。例えば次のようにしま
す:

     ... except (RuntimeError, TypeError, NameError):
     ...     pass

*note except: 170. 節 内のクラスは、そのクラスや派生クラスのインスタンス
である例外とマッチします（その逆はありません -- 派生クラスが書かれた
'except節' は、その基底クラスのインスタンスにはマッチしません）。例えば
、次のコードは B, C, D の順に出力されます:

     class B(Exception):
         pass

     class C(B):
         pass

     class D(C):
         pass

     for cls in [B, C, D]:
         try:
             raise cls()
         except D:
             print("D")
         except C:
             print("C")
         except B:
             print("B")

'except 節' が逆に並んでいた場合 (‘except B’ が最初にくる場合)、 B, B, B
と出力されるはずだったことに注意してください -- 最初に一致した 'except 節
' が駆動されるのです。

例外が発生するとき、例外は関連付けられた値を持つことができます。この値は
例外の '引数 (arguments)' とも呼ばれます。引数の有無および引数の型は、例
外の型に依存します。

except節は例外名の後に変数を指定できます。その変数は例外インスタンスに紐
付けられ、一般的には引数を保持する ‘args’ 属性を持ちます。利便性のため、
組み込み例外型には *note __str__(): 5e9. が定義されており、明示的に
‘.args’ を参照せずとも すべての引数を表示できます。

     >>> try:
     ...     raise Exception('spam', 'eggs')
     ... except Exception as inst:
     ...     print(type(inst))    # the exception type
     ...     print(inst.args)     # arguments stored in .args
     ...     print(inst)          # __str__ allows args to be printed directly,
     ...                          # but may be overridden in exception subclasses
     ...     x, y = inst.args     # unpack args
     ...     print('x =', x)
     ...     print('y =', y)
     ...
     <class 'Exception'>
     ('spam', 'eggs')
     ('spam', 'eggs')
     x = spam
     y = eggs

例外の *note __str__(): 5e9. 出力は、処理されない例外のメッセージ末尾
('詳細') として表示されます。

*note BaseException: 584. はすべての例外に共通する基底クラスです。そのサ
ブクラスの一つである *note Exception: 9a7. は、致命的でない例外すべての
基底クラスです。 *note Exception: 9a7. のサブクラスではない例外は、一般
的にプログラムが終了することを示すために使われているため処理されません。
例えば、*note sys.exit(): 1318. によって送出される *note SystemExit:
d0e. や、ユーザーがプログラムを中断させたいときに送出される *note
KeyboardInterrupt: 99f. があります。

*note Exception: 9a7. はほぼすべての例外を捕捉するワイルドカードとして使
えます。しかし良い例外処理の手法とは、処理対象の例外の型をできる限り詳細
に書き、予期しない例外はそのまま伝わるようにすることです。

*note Exception: 9a7. に対する最も一般的な例外処理のパターンでは、例外を
表示あるいはログ出力してから再度送出します(呼び出し側でも例外を処理でき
るようにします):

     import sys

     try:
         f = open('myfile.txt')
         s = f.readline()
         i = int(s.strip())
     except OSError as err:
         print("OS error:", err)
     except ValueError:
         print("Could not convert data to an integer.")
     except Exception as err:
         print(f"Unexpected {err=}, {type(err)=}")
         raise

*note try: 6b4. ...  *note except: 170. 文には、オプションで 'else 節
(else clause)' を設けることができます。 *note else: 171. 節を設ける場合
、全ての *note except: 170. 節よりも後ろに置かなければなりません。 *note
else: 171. 節は 'try 節' で全く例外が送出されなかったときに実行されるコ
ードを書くのに役立ちます。例えば次のようにします:

     for arg in sys.argv[1:]:
         try:
             f = open(arg, 'r')
         except OSError:
             print('cannot open', arg)
         else:
             print(arg, 'has', len(f.readlines()), 'lines')
             f.close()

追加のコードを付け加えるのは *note try: 6b4. 節よりも ‘else’ 節の方がよ
いでしょう。 なぜなら、そうすることで ‘try’ ...  ‘except’ 文で保護された
コードから送出されたもの以外の例外を過って捕捉してしまうという事態を避け
られるからです。

例外ハンドラは、'try 節' の直接内側で発生した例外を処理するだけではなく
その 'try 節' から (たとえ間接的にでも) 呼び出された関数の内部で発生した
例外も処理します。例えば:

     >>> def this_fails():
     ...     x = 1/0
     ...
     >>> try:
     ...     this_fails()
     ... except ZeroDivisionError as err:
     ...     print('Handling run-time error:', err)
     ...
     Handling run-time error: division by zero


File: python.info,  Node: 例外を送出する,  Next: 例外の連鎖,  Prev: 例外を処理する,  Up: エラーと例外

2.8.4 例外を送出する
--------------------

*note raise: 5b7. 文を使って、特定の例外を発生させることができます。例え
ば:

     >>> raise NameError('HiThere')
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
         raise NameError('HiThere')
     NameError: HiThere

*note raise: 5b7. の唯一の引数は送出される例外を指し示します。 これは例
外インスタンスか例外クラス(*note BaseException: 584. を継承したクラス、
たとえば *note Exception: 9a7. やそのサブクラス)でなければなりません。 例
外クラスが渡された場合は、引数無しのコンストラクタが呼び出され、暗黙的に
インスタンス化されます:

     raise ValueError  # shorthand for 'raise ValueError()'

例外が発生したかどうかを判定したいだけで、その例外を処理するつもりがなけ
れば、単純な形式の *note raise: 5b7. 文を使って例外を再送出させることが
できます:

     >>> try:
     ...     raise NameError('HiThere')
     ... except NameError:
     ...     print('An exception flew by!')
     ...     raise
     ...
     An exception flew by!
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
         raise NameError('HiThere')
     NameError: HiThere


File: python.info,  Node: 例外の連鎖,  Next: ユーザー定義例外,  Prev: 例外を送出する,  Up: エラーと例外

2.8.5 例外の連鎖
----------------

*note except: 170. 節の中で未処理の例外が発生した場合、その未処理の例外
は処理された例外のエラーメッセージに含まれます:

     >>> try:
     ...     open("database.sqlite")
     ... except OSError:
     ...     raise RuntimeError("unable to handle error")
     ...
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
         open("database.sqlite")
         ~~~~^^^^^^^^^^^^^^^^^^^
     FileNotFoundError: [Errno 2] No such file or directory: 'database.sqlite'

     During handling of the above exception, another exception occurred:

     Traceback (most recent call last):
       File "<stdin>", line 4, in <module>
         raise RuntimeError("unable to handle error")
     RuntimeError: unable to handle error

ある例外が他の例外から直接影響されていることを示すために、*note raise:
5b7. 文にオプションの *note from: 5b7. 句を指定します:

     # exc must be exception instance or None.
     raise RuntimeError from exc

これは例外を変換するときに便利です。例えば:

     >>> def func():
     ...     raise ConnectionError
     ...
     >>> try:
     ...     func()
     ... except ConnectionError as exc:
     ...     raise RuntimeError('Failed to open database') from exc
     ...
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
         func()
         ~~~~^^
       File "<stdin>", line 2, in func
     ConnectionError

     The above exception was the direct cause of the following exception:

     Traceback (most recent call last):
       File "<stdin>", line 4, in <module>
         raise RuntimeError('Failed to open database') from exc
     RuntimeError: Failed to open database

また、自動的な例外の連鎖を無効にするには ‘from None’ を指定します。

     >>> try:
     ...     open('database.sqlite')
     ... except OSError:
     ...     raise RuntimeError from None
     ...
     Traceback (most recent call last):
       File "<stdin>", line 4, in <module>
         raise RuntimeError from None
     RuntimeError

例外の連鎖の仕組みに関して、詳しくは *note 組み込み例外: 17ee. を参照し
てください。


File: python.info,  Node: ユーザー定義例外,  Next: クリーンアップ動作を定義する,  Prev: 例外の連鎖,  Up: エラーと例外

2.8.6 ユーザー定義例外
----------------------

プログラム上で新しい例外クラスを作成することで、独自の例外を指定すること
ができます (Python のクラスについては *note クラス: 1b89. 参照)。例外は
、典型的に *note Exception: 9a7. クラスから、直接または間接的に派生した
ものです。

例外クラスでは、普通のクラスができることなら何でも定義することができます
が、通常は単純なものにしておきます。大抵は、いくつかの属性だけを提供し、
例外が発生したときにハンドラがエラーに関する情報を取り出せるようにする程
度にとどめます。

ほとんどの例外は、標準の例外の名前付けと同様に、"Error" で終わる名前で定
義されています。

多くの標準モジュールでは、モジュールで定義されている関数内で発生する可能
性のあるエラーを報告させるために、独自の例外を定義しています。


File: python.info,  Node: クリーンアップ動作を定義する,  Next: 定義済みクリーンアップ処理,  Prev: ユーザー定義例外,  Up: エラーと例外

2.8.7 クリーンアップ動作を定義する
----------------------------------

*note try: 6b4. 文にはもう一つオプションの節があります。この節はクリーン
アップ動作を定義するためのもので、どんな状況でも必ず実行されます。例を示
します:

     >>> try:
     ...     raise KeyboardInterrupt
     ... finally:
     ...     print('Goodbye, world!')
     ...
     Goodbye, world!
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
         raise KeyboardInterrupt
     KeyboardInterrupt

もし *note finally: 997. 節がある場合、 *note try: 6b4. 文が終わる前の最
後の処理を、 ‘finally’ 節が実行します。 ‘try’ 文が例外を発生させるか否か
に関わらず、 ‘finally’ 節は実行されます。以下では、例外が発生するという
更に複雑なケースを議論します:

   * もし ‘try’ 文の実行中に例外が発生したら、その例外は *note except:
     170. 節によって処理されるでしょう。もしその例外が ‘except’ 節によっ
     て処理されなければ、 ‘finally’ 節が実行された後に、その例外が再送出
     されます。

   * ‘except’ 節または ‘else’ 節の実行中に例外が発生することがあり得ます
     。その場合も、 ‘finally’ 節が実行された後に例外が再送出されます。

   * ‘finally’ 節で *note break: a77.、*note continue: 998. または *note
     return: 99c. 文が実行された場合、例外は再送出されません。

   * もし ‘try’ 文が *note break: a77. 文、 *note continue: 998. 文また
     は *note return: 99c. 文のいずれかに達すると、その ‘break’ 文、
     ‘continue’ 文または ‘return’ 文の実行の直前に ‘finally’ 節が実行さ
     れます。

   * もし ‘finally’ 節が ‘return’ 文を含む場合、返される値は ‘try’ 節の
     ‘return’ 文ではなく、‘finally’ 節の ‘return’ 文によるものになります
     。

例えば:

     >>> def bool_return():
     ...     try:
     ...         return True
     ...     finally:
     ...         return False
     ...
     >>> bool_return()
     False

より複雑な例:

     >>> def divide(x, y):
     ...     try:
     ...         result = x / y
     ...     except ZeroDivisionError:
     ...         print("division by zero!")
     ...     else:
     ...         print("result is", result)
     ...     finally:
     ...         print("executing finally clause")
     ...
     >>> divide(2, 1)
     result is 2.0
     executing finally clause
     >>> divide(2, 0)
     division by zero!
     executing finally clause
     >>> divide("2", "1")
     executing finally clause
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
         divide("2", "1")
         ~~~~~~^^^^^^^^^^
       File "<stdin>", line 3, in divide
         result = x / y
                  ~~^~~
     TypeError: unsupported operand type(s) for /: 'str' and 'str'

見てわかるとおり、 *note finally: 997. 節はどの場合にも実行されています
。 文字列で割り算をすることで発生した *note TypeError: 502. は *note
except: 170. 節で処理されていないので、 ‘finally’ 節実行後に再度送出され
ています。

実世界のアプリケーションでは、 *note finally: 997. 節は(ファイルやネット
ワーク接続などの)外部リソースを、利用が成功したかどうかにかかわらず解放
するために便利です。


File: python.info,  Node: 定義済みクリーンアップ処理,  Next: 複数の関連しない例外の送出と処理,  Prev: クリーンアップ動作を定義する,  Up: エラーと例外

2.8.8 定義済みクリーンアップ処理
--------------------------------

オブジェクトのなかには、その利用の成否にかかわらず、不要になった際に実行
される標準的なクリーンアップ処理が定義されているものがあります。以下の、
ファイルをオープンして内容を画面に表示する例をみてください。

     for line in open("myfile.txt"):
         print(line, end="")

このコードの問題点は、コードの実行が終わった後に不定の時間ファイルを開い
たままでいることです。これは単純なスクリプトでは問題になりませんが、大き
なアプリケーションでは問題になりえます。 *note with: 59c. 文はファイルの
ようなオブジェクトが常に、即座に正しくクリーンアップされることを保証しま
す。

     with open("myfile.txt") as f:
         for line in f:
             print(line, end="")

この文が実行されたあとで、たとえ行の処理中に問題があったとしても、ファイ
ル 'f' は常に close されます。ファイルなどの、定義済みクリーンアップ処理
を持つオブジェクトについては、それぞれのドキュメントで示されます。


File: python.info,  Node: 複数の関連しない例外の送出と処理,  Next: ノートによって例外を充実させる,  Prev: 定義済みクリーンアップ処理,  Up: エラーと例外

2.8.9 複数の関連しない例外の送出と処理
--------------------------------------

いくつか発生した例外の報告が必要な状況があります。並列処理のフレームワー
クでは、複数のタスクが平行して失敗することがたびたびあります。他にも最初
の例外を送出するよりも、処理を継続して複数の例外を集約した方が望ましいユ
ースケースもあります。

組み込みの *note ExceptionGroup: 19b. は例外インスタンスのリストをまとめ
、同時に送出できるようにします。ExceptionGroupも例外なので、他の例外と同
じように捕捉できます。:

     >>> def f():
     ...     excs = [OSError('error 1'), SystemError('error 2')]
     ...     raise ExceptionGroup('there were problems', excs)
     ...
     >>> f()
       + Exception Group Traceback (most recent call last):
       |   File "<stdin>", line 1, in <module>
       |     f()
       |     ~^^
       |   File "<stdin>", line 3, in f
       |     raise ExceptionGroup('there were problems', excs)
       | ExceptionGroup: there were problems (2 sub-exceptions)
       +-+---------------- 1 ----------------
         | OSError: error 1
         +---------------- 2 ----------------
         | SystemError: error 2
         +------------------------------------
     >>> try:
     ...     f()
     ... except Exception as e:
     ...     print(f'caught {type(e)}: e')
     ...
     caught <class 'ExceptionGroup'>: e
     >>>

‘except’ の代わりに ‘except*’ を使用すると、グループの中にある特定の型に
一致した例外だけを選択して処理できます。以下の例では、ネストした例外グル
ープに対して各 ‘except*’ 節で特定の型の例外を取り出し、それ以外の例外は
他の節に伝えられ、最終的に例外が送出されます。:

     >>> def f():
     ...     raise ExceptionGroup(
     ...         "group1",
     ...         [
     ...             OSError(1),
     ...             SystemError(2),
     ...             ExceptionGroup(
     ...                 "group2",
     ...                 [
     ...                     OSError(3),
     ...                     RecursionError(4)
     ...                 ]
     ...             )
     ...         ]
     ...     )
     ...
     >>> try:
     ...     f()
     ... except* OSError as e:
     ...     print("There were OSErrors")
     ... except* SystemError as e:
     ...     print("There were SystemErrors")
     ...
     There were OSErrors
     There were SystemErrors
       + Exception Group Traceback (most recent call last):
       |   File "<stdin>", line 2, in <module>
       |     f()
       |     ~^^
       |   File "<stdin>", line 2, in f
       |     raise ExceptionGroup(
       |     ...<12 lines>...
       |     )
       | ExceptionGroup: group1 (1 sub-exception)
       +-+---------------- 1 ----------------
         | ExceptionGroup: group2 (1 sub-exception)
         +-+---------------- 1 ----------------
           | RecursionError: 4
           +------------------------------------
     >>>

例外グループの中に含める例外は、型ではなくインスタンスである必要があるこ
とに注意してください。これは一般的に、以下のパターンようにプログラムで送
出された複数の例外を捕捉することが多いためです。:

     >>> excs = []
     ... for test in tests:
     ...     try:
     ...         test.run()
     ...     except Exception as e:
     ...         excs.append(e)
     ...
     >>> if excs:
     ...    raise ExceptionGroup("Test Failures", excs)
     ...


File: python.info,  Node: ノートによって例外を充実させる,  Prev: 複数の関連しない例外の送出と処理,  Up: エラーと例外

2.8.10 ノートによって例外を充実させる
-------------------------------------

例外を送出するために生成するときに、通常は発生したエラーを説明する情報で
初期化されます。例外を受け取ったあとに情報を追加すると便利な場合がありま
す。この目的のために、例外は ‘add_note(note)’ メソッドを持ちます。このメ
ソッドは文字列を受け取り、例外のノートのリストに追加します。標準のトレー
スバックでは例外の後に、全てのノートが追加した順番に出力されます。:

     >>> try:
     ...     raise TypeError('bad type')
     ... except Exception as e:
     ...     e.add_note('Add some information')
     ...     e.add_note('Add some more information')
     ...     raise
     ...
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
         raise TypeError('bad type')
     TypeError: bad type
     Add some information
     Add some more information
     >>>

たとえば、複数の例外を1つの例外グループにまとめるときに、各エラーのコン
テキスト情報を追加したい場合があります。以下のグループ内の各例外が持つノ
ートは、エラーがいつ発生したかを示しています。:

     >>> def f():
     ...     raise OSError('operation failed')
     ...
     >>> excs = []
     >>> for i in range(3):
     ...     try:
     ...         f()
     ...     except Exception as e:
     ...         e.add_note(f'Happened in Iteration {i+1}')
     ...         excs.append(e)
     ...
     >>> raise ExceptionGroup('We have some problems', excs)
       + Exception Group Traceback (most recent call last):
       |   File "<stdin>", line 1, in <module>
       |     raise ExceptionGroup('We have some problems', excs)
       | ExceptionGroup: We have some problems (3 sub-exceptions)
       +-+---------------- 1 ----------------
         | Traceback (most recent call last):
         |   File "<stdin>", line 3, in <module>
         |     f()
         |     ~^^
         |   File "<stdin>", line 2, in f
         |     raise OSError('operation failed')
         | OSError: operation failed
         | Happened in Iteration 1
         +---------------- 2 ----------------
         | Traceback (most recent call last):
         |   File "<stdin>", line 3, in <module>
         |     f()
         |     ~^^
         |   File "<stdin>", line 2, in f
         |     raise OSError('operation failed')
         | OSError: operation failed
         | Happened in Iteration 2
         +---------------- 3 ----------------
         | Traceback (most recent call last):
         |   File "<stdin>", line 3, in <module>
         |     f()
         |     ~^^
         |   File "<stdin>", line 2, in f
         |     raise OSError('operation failed')
         | OSError: operation failed
         | Happened in Iteration 3
         +------------------------------------
     >>>


File: python.info,  Node: クラス,  Next: 標準ライブラリミニツアー,  Prev: エラーと例外,  Up: Python チュートリアル

2.9 クラス
==========

クラスはデータと機能を組み合わせる方法を提供します。 新規にクラスを作成
することで、新しいオブジェクトの '型' を作成し、その型を持つ新しい 'イン
スタンス' が作れます。 クラスのそれぞれのインスタンスは自身の状態を保持
する属性を持てます。 クラスのインスタンスは、その状態を変更するための (そ
のクラスが定義する) メソッドも持てます。

Python は、他のプログラミング言語と比較して、最小限の構文と意味付けを使
ってクラスを言語に追加しています。Python のクラスは、C++ と Modula-3 の
クラスメカニズムを混ぜたものです。Python のクラス機構はオブジェクト指向
プログラミングの標準的な機能を全て提供しています。クラスの継承メカニズム
は、複数の基底クラスを持つことができ、派生クラスで基底クラスの任意のメソ
ッドをオーバライドすることができます。メソッドでは、基底クラスのメソッド
を同じ名前で呼び出すことができます。オブジェクトには任意の種類と数のデー
タを格納することができます。モジュールと同じく、クラス機構も Python の動
的な性質に従うように設計されています。クラスは実行時に生成され、生成後に
変更することができます。

C++ の用語で言えば、通常のクラスメンバ (データメンバも含む) は (*note
プライベート変数: 1c0a. に書かれている例外を除いて) 'public' であり、メ
ンバ関数はすべて '仮想関数(virtual)' です。 Modula-3 にあるような、オブ
ジェクトのメンバをメソッドから参照するための短縮した記法は使えません: メ
ソッド関数の宣言では、オブジェクト自体を表す第一引数を明示しなければなり
ません。第一引数のオブジェクトはメソッド呼び出しの際に暗黙の引数として渡
されます。 Smalltalk に似て、クラスはそれ自体がオブジェクトです。そのた
め、 import や名前変更といった操作が可能です。 C++ や Modula-3 と違って
、ユーザーは組込み型を基底クラスにして拡張を行えます。また、C++ とは同じ
で Modula-3 とは違う点として、特別な構文を伴うほとんどの組み込み演算子
(算術演算子 (arithmetic operator) や添字表記) はクラスインスタンスで使う
ために再定義できます。

(クラスに関して普遍的な用語定義がないので、 Smalltalk と C++ の用語を場
合に応じて使っていくことにします。 C++ よりも Modula-3 の方がオブジェク
ト指向の意味論が Python に近いので、 Modula-3 の用語を使いたいのですが、
ほとんどの読者は Modula-3 についてしらないでしょうから。)

* Menu:

* 名前とオブジェクトについて::
* Python のスコープと名前空間::
* クラス初見::
* いろいろな注意点::
* 継承::
* プライベート変数::
* 残りのはしばし::
* イテレータ (iterator): イテレータ iterator.
* ジェネレータ (generator): ジェネレータ generator.
* ジェネレータ式::


File: python.info,  Node: 名前とオブジェクトについて,  Next: Python のスコープと名前空間,  Up: クラス

2.9.1 名前とオブジェクトについて
--------------------------------

オブジェクトには個体性があり、同一のオブジェクトに(複数のスコープから) 複
数の名前を割り当てることができます。この機能は他の言語では別名づけ
(alias) として知られています。 Python を一見しただけでは、別名づけの重要
性は分からないことが多く、変更不能な基本型 (数値、文字列、タプル)を扱う
ときには無視して差し支えありません。しかしながら、別名付けは、リストや辞
書や他の多くの型など、変更可能な型を扱う Python コード上で驚くべき効果が
あります。別名付けはいくつかの点でポインタのように振舞い、このことは通常
はプログラムに利するように使われます。例えば、オブジェクトの受け渡しは、
実装上はポインタが渡されるだけなのでコストの低い操作になります。また、関
数があるオブジェクトを引数として渡されたとき、関数の呼び出し側からオブジ
ェクトに対する変更を見ることができます -- これにより、 Pascal にあるよう
な二つの引数渡し機構をもつ必要をなくしています。


File: python.info,  Node: Python のスコープと名前空間,  Next: クラス初見,  Prev: 名前とオブジェクトについて,  Up: クラス

2.9.2 Python のスコープと名前空間
---------------------------------

クラスを紹介する前に、Python のスコープのルールについてあることを話して
おかなければなりません。クラス定義は巧みなトリックを名前空間に施すので、
何が起こっているのかを完全に理解するには、スコープと名前空間がどのように
動作するかを理解する必要があります。ちなみに、この問題に関する知識は全て
の Python プログラマにとって有用です。

まず定義から始めましょう。

'名前空間 (namespace)' とは、名前からオブジェクトへの対応付け (mapping)
です。ほとんどの名前空間は、現状では Python の辞書として実装されています
が、そのことは通常は (パフォーマンス以外では) 目立つことはないし、将来は
変更されるかもしれません。名前空間の例には、組込み名の集合 (*note abs():
1c0e. 等の関数や組込み例外名)、モジュール内のグローバルな名前、関数を呼
び出したときのローカルな名前があります。オブジェクトの属性からなる集合も
また、ある意味では名前空間です。名前空間について知っておくべき重要なこと
は、異なった名前空間にある名前の間には全く関係がないということです。例え
ば、二つの別々のモジュールの両方で関数 ‘maximize’ という関数を定義するこ
とができ、定義自体は混同されることはありません -- モジュールのユーザは名
前の前にモジュール名をつけなければなりません。

ところで、 '属性' という言葉は、ドットに続く名前すべてに対して使っていま
す -- 例えば式 ‘z.real’ で、 ‘real’ はオブジェクト ‘z’ の属性です。厳密
にいえば、モジュール内の名前に対する参照は属性の参照です。式
‘modname.funcname’ では、 ‘modname’ はあるモジュールオブジェクトで、
‘funcname’ はその属性です。この場合には、モジュールの属性とモジュールの
中で定義されているグローバル名の間には、直接的な対応付けがされます。これ
らの名前は同じ名前空間を共有しているのです！ (1)

属性は読取り専用にも、書込み可能にもできます。書込み可能であれば、属性に
代入することができます。モジュール属性は書込み可能で、
‘modname.the_answer = 42’ と書くことができます。書込み可能な属性は、
*note del: 1711. 文で削除することもできます。例えば、 ‘del
modname.the_answer’ は、 ‘modname’ で指定されたオブジェクトから属性
‘the_answer’ を除去します。

名前空間は様々な時点で作成され、その寿命も様々です。組み込みの名前が入っ
た名前空間は Python インタプリタが起動するときに作成され、決して削除され
ることはありません。モジュールのグローバルな名前空間は、モジュール定義が
読み込まれたときに作成されます。通常、モジュールの名前空間は、インタプリ
タが終了するまで残ります。インタプリタのトップレベルで実行された文は、ス
クリプトファイルから読み出されたものでも対話的に読み出されたものでも、
*note __main__: 1. という名前のモジュールの一部分であるとみなされるので
、独自の名前空間を持つことになります。 (組み込みの名前は実際にはモジュー
ル内に存在します。そのモジュールは *note builtins: e. と呼ばれています。
)

関数のローカルな名前空間は、関数が呼び出されたときに作成され、関数から戻
ったときや、関数内で例外が送出され、かつ関数内で処理されなかった場合に削
除されます。 (実際には、忘れられる、と言ったほうが起きていることをよく表
しています。) もちろん、再帰呼出しのときには、各々の呼び出しで各自のロー
カルな名前空間があります。

'スコープ (scope)' とは、ある名前空間が直接アクセスできるような、 Python
プログラムのテキスト上の領域です。 "直接アクセス可能" とは、修飾なしに
(訳注: ‘spam.egg’ ではなく単に ‘egg’ のように) 名前を参照した際に、その
名前空間から名前を見つけようと試みることを意味します。

スコープは静的に決定されますが、動的に使用されます。実行中はいつでも、直
接名前空間にアクセス可能な、3つまたは4つの入れ子になったスコープがありま
す:

   * 最初に探される、最も内側のスコープは、ローカルな名前を持っています
     。

   * 外側の(enclosing)関数のスコープは、近いほうから順に探され、ローカル
     でもグローバルでもない名前を持っています。

   * 次のスコープは、現在のモジュールのグローバルな名前を持っています。

   * 一番外側の(最後に検索される)スコープはビルトイン名を持っています。

名前が global と宣言されている場合、その名前に対する参照や代入は全て、モ
ジュールのグローバルな名前の入った最後から2番目のスコープに対して直接行
われます。最内スコープの外側にある変数に再束縛するには、 *note nonlocal:
1279. 文が使えます。nonlocal と宣言されなかった変数は、全て読み出し専用
となります (そのような変数に対する書き込みは、単に '新しい' ローカル変数
をもっとも内側のスコープで作成し、外部のスコープの値は変化しません)。

通常、ローカルスコープは (プログラムテキスト上の) 現在の関数のローカルな
名前を参照します。関数の外側では、ローカルスコープはグローバルな名前空間
と同じ名前空間、モジュールの名前空間を参照します。クラス定義では、ローカ
ルスコープの中にもう一つ名前空間が置かれます。

スコープはテキスト上で決定されていると理解することが重要です。モジュール
内で定義される関数のグローバルなスコープは、関数がどこから呼び出されても
、どんな別名をつけて呼び出されても、そのモジュールの名前空間になります。
反対に、実際の名前の検索は実行時に動的に行われます -- とはいえ、言語の定
義は、"コンパイル" 時の静的な名前解決の方向に進化しているので、動的な名
前解決に頼ってはいけません！ (事実、ローカルな変数は既に静的に決定されて
います。)

Python の特徴として、*note global: 16f. や *note nonlocal: 1279. 文が有
効でない場合は、名前に対する参照は常に最も内側のスコープに対して有効にな
ります。 代入はデータをコピーしません。オブジェクトを名前に束縛するだけ
です。削除も同様で、‘del x’ は、ローカルスコープの名前空間から ‘x’ に対
する拘束を取り除きます。 つまるところ、新しい名前を与えるようなすべての
操作は、ローカルスコープを使って行われます。 *note import: 5ac. 文、関数
の定義は、モジュールや関数名をローカルスコープの名前に拘束します。

*note global: 16f. 文を使うと、特定の変数がグローバルスコープに存在し、
そこで再束縛されることを指示できます。 *note nonlocal: 1279. 文は、特定
の変数が外側のスコープに存在し、そこで再束縛されることを指示します。

* Menu:

* スコープと名前空間の例::

   ---------- Footnotes ----------

   (1) Except for one thing.  Module objects have a secret read-only
attribute called *note __dict__: 526. which returns the dictionary used
to implement the module's namespace; the name ‘__dict__’ is an attribute
but not a global name.  Obviously, using this violates the abstraction
of namespace implementation, and should be restricted to things like
post-mortem debuggers.


File: python.info,  Node: スコープと名前空間の例,  Up: Python のスコープと名前空間

2.9.2.1 スコープと名前空間の例
..............................

異なるスコープと名前空間がどのように参照されるか、また *note global:
16f. および *note nonlocal: 1279. が変数の束縛にどう影響するか、この例で
実演します:

     def scope_test():
         def do_local():
             spam = "local spam"

         def do_nonlocal():
             nonlocal spam
             spam = "nonlocal spam"

         def do_global():
             global spam
             spam = "global spam"

         spam = "test spam"
         do_local()
         print("After local assignment:", spam)
         do_nonlocal()
         print("After nonlocal assignment:", spam)
         do_global()
         print("After global assignment:", spam)

     scope_test()
     print("In global scope:", spam)

このコード例の出力は:

     After local assignment: test spam
     After nonlocal assignment: nonlocal spam
     After global assignment: nonlocal spam
     In global scope: global spam

このとおり、(デフォルトの) 'ローカルな' 代入は 'scope_test' 上の 'spam'
への束縛を変更しませんでした。 *note nonlocal: 1279. 代入は 'scope_test'
上の 'spam' への束縛を変更し、 *note global: 16f. 代入はモジュールレベル
の束縛を変更しました。

またここから、 *note global: 16f. 代入の前には 'spam' に何も束縛されてい
なかったことも分かります。


File: python.info,  Node: クラス初見,  Next: いろいろな注意点,  Prev: Python のスコープと名前空間,  Up: クラス

2.9.3 クラス初見
----------------

クラスでは、新しい構文を少しと、三つの新たなオブジェクト型、そして新たな
意味付けをいくつか取り入れています。

* Menu:

* クラス定義の構文::
* クラスオブジェクト::
* インスタンスオブジェクト::
* メソッドオブジェクト::
* クラスとインスタンス変数::


File: python.info,  Node: クラス定義の構文,  Next: クラスオブジェクト,  Up: クラス初見

2.9.3.1 クラス定義の構文
........................

クラス定義の最も単純な形式は、次のようになります:

     class ClassName:
         <statement-1>
         .
         .
         .
         <statement-N>

関数定義 (*note def: 13ff. 文) と同様、クラス定義が効果をもつにはまず実
行しなければなりません。 (クラス定義を *note if: 2ca. 文の分岐先や関数内
部に置くことも、考え方としてはありえます。)

実際には、クラス定義の内側にある文は、通常は関数定義になりますが、他の文
を書くこともでき、それが役に立つこともあります -- これについては後で述べ
ます。クラス内の関数定義は通常、メソッドの呼び出し規約で決められた独特の
形式の引数リストを持ちます -- これについても後で述べます。

クラス定義に入ると、新たな名前空間が作成され、ローカルな名前空間として使
われます -- 従って、ローカルな変数に対する全ての代入はこの新たな名前空間
に入ります。特に、関数定義を行うと、新たな関数の名前はこの名前空間に結び
付けられます。

クラス定義から普通に (定義の終端に到達して) 抜けると、 'クラスオブジェク
ト (class object)' が生成されます。クラスオブジェクトは、基本的にはクラ
ス定義で作成された名前空間の内容をくるむラッパー (wrapper) です。クラス
オブジェクトについては次の節で詳しく学ぶことにします。 (クラス定義に入る
前に有効だった) 元のローカルスコープが復帰し、生成されたクラスオブジェク
トは復帰したローカルスコープにクラス定義のヘッダで指定した名前 (上の例で
は ‘ClassName’) で結び付けられます。


File: python.info,  Node: クラスオブジェクト,  Next: インスタンスオブジェクト,  Prev: クラス定義の構文,  Up: クラス初見

2.9.3.2 クラスオブジェクト
..........................

クラスオブジェクトでは２種類の演算、属性参照とインスタンス生成をサポート
しています。

'属性参照 (attribute reference)' は、Python におけるすべての属性参照で使
われている標準的な構文、 ‘obj.name’ を使います。クラスオブジェクトが生成
された際にクラスの名前空間にあった名前すべてが有効な属性名です。従って、
以下のようなクラス定義では:

     class MyClass:
         """A simple example class"""
         i = 12345

         def f(self):
             return 'hello world'

then ‘MyClass.i’ and ‘MyClass.f’ are valid attribute references,
returning an integer and a function object, respectively.  Class
attributes can also be assigned to, so you can change the value of
‘MyClass.i’ by assignment.  *note __doc__: 1c16. is also a valid
attribute, returning the docstring belonging to the class: ‘"A simple
example class"’.

クラスの 'インスタンス化 (instantiation)' には関数記法を使います。クラス
オブジェクトのことを、クラスの新しいインスタンスを返す、引数のない関数の
ように扱ってください。上記クラスで例示すると:

     x = MyClass()

は、クラスの新しい 'インスタンス (instance)' を生成し、そのオブジェクト
をローカル変数 ‘x’ へ代入します。

インスタンス化操作 (クラスオブジェクトの "呼出し") では、空のオブジェク
トが作られます。多くのクラスでは、特定の初期状態にカスタマイズされたオブ
ジェクトを作りたいです。そのために、クラスには *note __init__(): 67c. と
いう名前の特殊メソッドを定義できます。例えば次のようにします:

     def __init__(self):
         self.data = []

クラスが *note __init__(): 67c. メソッドを定義している場合、クラスをイン
スタンス化すると、新しく作られたクラスインスタンスに対して自動的に
‘__init__()’ を呼び出します。 従って この例では、新たな初期済みインスタ
ンスを次のようにして得られます:

     x = MyClass()

もちろん、より大きな柔軟性を持たせるために、 *note __init__(): 67c. メソ
ッドに複数の引数をもたせることができます。その場合、次の例のように、クラ
スのインスタンス化操作に渡された引数は ‘__init__()’ に渡されます。例えば
、

     >>> class Complex:
     ...     def __init__(self, realpart, imagpart):
     ...         self.r = realpart
     ...         self.i = imagpart
     ...
     >>> x = Complex(3.0, -4.5)
     >>> x.r, x.i
     (3.0, -4.5)


File: python.info,  Node: インスタンスオブジェクト,  Next: メソッドオブジェクト,  Prev: クラスオブジェクト,  Up: クラス初見

2.9.3.3 インスタンスオブジェクト
................................

ところで、インスタンスオブジェクトを使うと何ができるのでしょうか？インス
タンスオブジェクトが理解できる唯一の操作は、属性の参照です。有効な属性名
には (データ属性およびメソッドの) 二種類あります。

'データ属性 (data attribute)' は、 Smalltalk の "インスタンス変数" や
C++の "データメンバ" に相当します。データ属性を宣言する必要はありません
。ローカル変数と同様に、これらの属性は最初に代入された時点で湧き出てきま
す。例えば、上で生成した ‘MyClass’ のインスタンス ‘x’ に対して、次のコー
ドを実行すると、跡を残さず値 ‘16’ を印字します:

     x.counter = 1
     while x.counter < 10:
         x.counter = x.counter * 2
     print(x.counter)
     del x.counter

もう一つのインスタンス属性の参照は、 'メソッド' です。メソッドとは、オブ
ジェクトに "属する" 関数のことです。

インスタンスオブジェクトで有効なメソッド名は、そのクラスによります。定義
により、クラスの全ての関数オブジェクトである属性がインスタンスオブジェク
トの妥当なメソッド名に決まります。従って、例では、‘MyClass.f’ は関数なの
で、‘x.f’ はメソッドの参照として有効です。しかし、‘MyClass.i’ は関数では
ないので、‘x.i’ はメソッドの参照として有効ではありません。‘x.f’ は
‘MyClass.f’ と同じものではありません -- 関数オブジェクトではなく、'メソ
ッドオブジェクト (method object)' です。


File: python.info,  Node: メソッドオブジェクト,  Next: クラスとインスタンス変数,  Prev: インスタンスオブジェクト,  Up: クラス初見

2.9.3.4 メソッドオブジェクト
............................

普通、メソッドはバインドされた直後に呼び出されます:

     x.f()

この ‘MyClass’ の例では、文字列 ‘'hello world'’ が返されます。しかし、必
ずしもすぐメソッドを呼び出さなければならないわけではありません。 ‘x.f’ は
メソッドオブジェクトであり、どこかに入れておいて後で呼び出すことができま
す。例えば次のコードは:

     xf = x.f
     while True:
         print(xf())

‘hello world’ を時が終わるまで印字し続けるでしょう。

メソッドが呼び出されるときには実際には何が起きているのでしょうか？ ‘f()’
の関数定義では引数を一つ指定していたにもかかわらず、上の例では ‘x.f()’ が
引数なしで呼び出されています。引数はどうなったのでしょうか？たしか、引数
が必要な関数を引数無しで呼び出すと、 Python が例外を送出するはずです --
たとえその引数が実際には使われなくても…。

もう答は想像できているかもしれませんね: メソッドについて特別なこととして
、インスタンスオブジェクトが関数の第1引数として渡されます。 例では、
‘x.f()’ という呼び出しは、 ‘MyClass.f(x)’ と厳密に等価なものです。 一般
に、 'n' 個の引数リストもったメソッドの呼出しは、そのメソッドのインスタ
ンスオブジェクトを最初の引数の前に挿入した引数リストで、メソッドに対応す
る関数を呼び出すことと等価です。

一般的に、メソッドは以下のように動作します。インスタンスの非データ属性が
参照されたときは、そのインスタンスのクラスが検索されます。その名前が有効
なクラス属性を表している関数オブジェクトなら、インスタンスオブジェクトと
関数オブジェクトの両方への参照がメソッドオブジェクトにパックされます。メ
ソッドオブジェクトが引数リストと共に呼び出されるとき、インスタンスオブジ
ェクトと渡された引数リストから新しい引数リストを作成して、元の関数オブジ
ェクトを新しい引数リストで呼び出します。


File: python.info,  Node: クラスとインスタンス変数,  Prev: メソッドオブジェクト,  Up: クラス初見

2.9.3.5 クラスとインスタンス変数
................................

一般的に、インスタンス変数はそれぞれのインスタンスについて固有のデータの
ためのもので、クラス変数はそのクラスのすべてのインスタンスによって共有さ
れる属性やメソッドのためのものです:

     class Dog:

         kind = 'canine'         # 全インスタンスで共有されるクラス変数

         def __init__(self, name):
             self.name = name    # インスタンスごとに固有のインスタンス変数

     >>> d = Dog('Fido')
     >>> e = Dog('Buddy')
     >>> d.kind                  # すべての犬で共有
     'canine'
     >>> e.kind                  # すべての犬で共有
     'canine'
     >>> d.name                  # d 固有
     'Fido'
     >>> e.name                  # e 固有
     'Buddy'

*note 名前とオブジェクトについて: 1c0c. で議論したように、共有データはリ
ストや辞書のような *note mutable: 1273. オブジェクトが関与すると驚くべき
効果を持ち得ます。例えば、以下のコードの 'tricks' リストはクラス変数とし
て使われるべきではありません、なぜならたった一つのリストがすべての 'Dog'
インスタンスによって共有されることになり得るからです:

     class Dog:

         tricks = []             # クラス変数の間違った使用

         def __init__(self, name):
             self.name = name

         def add_trick(self, trick):
             self.tricks.append(trick)

     >>> d = Dog('Fido')
     >>> e = Dog('Buddy')
     >>> d.add_trick('roll over')
     >>> e.add_trick('play dead')
     >>> d.tricks                # 意図せず すべての犬で共有
     ['roll over', 'play dead']

このクラスの正しい設計ではインスタンス変数を代わりに使用するべきです:

     class Dog:

         def __init__(self, name):
             self.name = name
             self.tricks = []    # 犬ごとに新しい空リストを作る

         def add_trick(self, trick):
             self.tricks.append(trick)

     >>> d = Dog('Fido')
     >>> e = Dog('Buddy')
     >>> d.add_trick('roll over')
     >>> e.add_trick('play dead')
     >>> d.tricks
     ['roll over']
     >>> e.tricks
     ['play dead']


File: python.info,  Node: いろいろな注意点,  Next: 継承,  Prev: クラス初見,  Up: クラス

2.9.4 いろいろな注意点
----------------------

インスタンスとクラスの両方で同じ属性名が使用されている場合、属性検索はイ
ンスタンスが優先されます。

     >>> class Warehouse:
     ...    purpose = 'storage'
     ...    region = 'west'
     ...
     >>> w1 = Warehouse()
     >>> print(w1.purpose, w1.region)
     storage west
     >>> w2 = Warehouse()
     >>> w2.region = 'east'
     >>> print(w2.purpose, w2.region)
     storage east

データ属性は、メソッドから参照できると同時に、通常のオブジェクトのユーザ
("クライアント") からも参照できます。言い換えると、クラスは純粋な抽象デ
ータ型として使うことができません。実際、 Python では、データ隠蔽を補強す
るための機構はなにもありません -- データの隠蔽はすべて規約に基づいていま
す。 (逆に、C 言語で書かれた Python の実装では実装の詳細を完全に隠蔽し、
必要に応じてオブジェクトへのアクセスを制御できます。この機構は C 言語で
書かれた Python 拡張で使うことができます。)

クライアントはデータ属性を注意深く扱うべきです -- クライアントは、メソッ
ドが維持しているデータ属性の不変式を踏みにじり、台無しにするかもしれませ
ん。クライアントは、名前の衝突が回避されている限り、メソッドの有効性に影
響を及ぼすことなくインスタンスに独自の属性を追加することができる、という
ことに注意してください -- ここでも、名前付けの規約は頭痛の種を無くしてく
れます。

メソッドの中から、データ属性を (または別のメソッドも！) 参照するための短
縮された記法はありません。私は、この仕様がメソッドの可読性を高めていると
感じています。あるメソッドを眺めているときにローカルな変数とインスタンス
変数をはっきり区別できるからです。

よく、メソッドの最初の引数を ‘self’ と呼びます。この名前付けは単なる慣習
でしかありません。 ‘self’ という名前は、 Python では何ら特殊な意味を持ち
ません。とはいえ、この慣行に従わないと、コードは他の Python プログラマに
とってやや読みにくいものとなります。また、 'クラスブラウザ (class
browser)' プログラムがこの慣行をあてにして書かれているかもしれません。

クラス属性である関数オブジェクトはいずれも、そのクラスのインスタンスのた
めのメソッドを定義しています。関数定義は、テキスト上でクラス定義の中に入
っている必要はありません。関数オブジェクトをクラスのローカルな変数の中に
代入するのも OK です。例えば以下のコードのようにします:

     # クラス外で定義された関数
     def f1(self, x, y):
         return min(x, x+y)

     class C:
         f = f1

         def g(self):
             return 'hello world'

         h = g

これで、 ‘f’ 、 ‘g’ 、および ‘h’ は、すべて ‘C’ の属性であり関数オブジェ
クトを参照しています。従って、これらは、すべて ‘C’ のインスタンスのメソ
ッドとなります -- ‘h’ は ‘g’ と全く等価です。これを実践しても、大抵は単
にプログラムの読者に混乱をもたらすだけなので注意してください。

メソッドは、 ‘self’ 引数のメソッド属性を使って、他のメソッドを呼び出すこ
とができます:

     class Bag:
         def __init__(self):
             self.data = []

         def add(self, x):
             self.data.append(x)

         def addtwice(self, x):
             self.add(x)
             self.add(x)

メソッドは、通常の関数と同じようにしてグローバルな名前を参照します。ある
メソッドに関するグローバルスコープは、その定義を含むモジュールです。(ク
ラスはグローバルなスコープとして用いられることはありません。) メソッドで
グローバルなデータを使う良い理由はほとんどありませんが、グローバルなスコ
ープを使うべき場面は多々あります。一つ挙げると、メソッド内から、グローバ
ルなスコープに import された関数やモジュールや、そのモジュール中で定義さ
れた関数やクラスを使うことができます。通常、メソッドの入っているクラス自
体はグローバルなスコープ内で定義されています。次の節では、メソッドが自分
のクラスを参照する理由として正当なものを見てみましょう。

個々の値はオブジェクトなので、 'クラス' ('型' とも言います) を持っていま
す。それは ‘object.__class__’ に保持されています。


File: python.info,  Node: 継承,  Next: プライベート変数,  Prev: いろいろな注意点,  Up: クラス

2.9.5 継承
----------

言うまでもなく、継承の概念をサポートしない言語機能は "クラス" と呼ぶに値
しません。派生クラス (derived class) を定義する構文は次のようになります:

     class DerivedClassName(BaseClassName):
         <statement-1>
         .
         .
         .
         <statement-N>

基底クラス (base class) の名前 ‘BaseClassName’ は、派生クラス定義の入っ
ているスコープからアクセスできる名前空間で定義されていなければなりません
。基底クラス名のかわりに任意の式を入れることもできます。これは次の例のよ
うに、基底クラスが別モジュールで定義されているときに便利なことがあります
:

     class DerivedClassName(modname.BaseClassName):

派生クラス定義の実行は、基底クラスの場合と同じように進められます。クラス
オブジェクトが構築される時、基底クラスが記憶されます。記憶された基底クラ
スは、属性参照を解決するために使われます。要求された属性がクラスに見つか
らなかった場合、基底クラスに検索が進みます。この規則は、基底クラスが他の
何らかのクラスから派生したものであった場合、再帰的に適用されます。

派生クラスのインスタンス化では、特別なことは何もありません。
‘DerivedClassName()’ はクラスの新たなインスタンスを生成します。メソッド
の参照は次のようにして解決されます。まず対応するクラス属性が検索されます
。検索は、必要に応じ、基底クラス連鎖を下って行われ、検索の結果として何ら
かの関数オブジェクトがもたらされた場合、メソッド参照は有効なものとなりま
す。

派生クラスは基底クラスのメソッドを上書き (override) することができます。
メソッドは同じオブジェクトの別のメソッドを呼び出す際に何ら特殊な権限を持
ちません。このため、ある基底クラスのメソッドが、同じ基底クラスで定義され
ているもう一つのメソッド呼び出しを行っている場合、派生クラスで上書きされ
た何らかのメソッドが呼び出されることになるかもしれません。 (C++ プログラ
マへ: Python では、すべてのメソッドは事実上 ‘virtual’ です。)

派生クラスで上書きしているメソッドでは、基底クラスの同名のメソッドを置き
換えるのではなく、拡張したいのかもしれません。基底クラスのメソッドを直接
呼び出す簡単な方法があります。単に ‘BaseClassName.methodname(self,
arguments)’ を呼び出すだけです。この仕様は、場合によってはクライアントで
も役に立ちます。 (この呼び出し方が動作するのは、基底クラスがグローバルス
コープの ‘BaseClassName’ という名前でアクセスできるときだけです。)

Python には継承に関係する 2 つの組み込み関数があります:

   * *note isinstance(): 40e. を使うとインスタンスの型が調べられます。
     ‘isinstance(obj, int)’ は ‘obj.__class__’ が *note int: 238. や
     *note int: 238. の派生クラスの場合に限り ‘True’ になります。

   * *note issubclass(): 78c. を使うとクラスの継承関係が調べられます。
     *note bool: 434. は *note int: 238. のサブクラスなので
     ‘issubclass(bool, int)’ は ‘True’ です。しかし、 *note float: 2ce.
     は *note int: 238. のサブクラスではないので ‘issubclass(float,
     int)’ は ‘False’ です。

* Menu:

* 多重継承::


File: python.info,  Node: 多重継承,  Up: 継承

2.9.5.1 多重継承
................

Python では、多重継承 (multiple inheritance) の形式もサポートしています
。複数の基底クラスをもつクラス定義は次のようになります:

     class DerivedClassName(Base1, Base2, Base3):
         <statement-1>
         .
         .
         .
         <statement-N>

ほとんどのシンプルな多重継承において、親クラスから継承される属性の検索は
、深さ優先で、左から右に、そして継承の階層の中で同じクラスが複数出てくる
（訳注: ダイアモンド継承と呼ばれます）場合に２度探索をしない、と考えるこ
とができます。なので、ある属性が ‘DerivedClassName’ で見つからない場合、
まず ‘Base1’ から検索され、そして（再帰的に） ‘Base1’ の基底クラスから検
索され、それでも見つからなかった場合は ‘Base2’ から検索される、といった
具合になります。

実際には、それよりもう少しだけ複雑です。協調的な *note super(): 4a8. の
呼び出しのためにメソッドの解決順序は動的に変更されます。このアプローチは
他の多重継承のある言語で call-next-method として知られており、単一継承し
かない言語の super 呼び出しよりも強力です。

動的順序付けが必要なのは、すべての多重継承で１つ以上のダイヤモンド継承
(少なくとも 1 つの祖先クラスに対して最下位クラスから到達する経路が複数あ
る状態) が見られるためです。例えば、全ての新形式のクラスは *note object:
a5a. を継承しているので、どの多重継承でも *note object: a5a. への到達経
路が複数あります。基底クラスが複数回アクセスされないようにするために、動
的アルゴリズムで検索順序を線形化します。それは、各クラスで指定されている
左から右への順序は崩さず、各々の祖先クラスを一度だけ呼び出し、かつ単調に
なる (つまり祖先クラスの検索順序に影響を与えずにクラスをサブクラス化でき
る) ように行います。まとめると、これらの特徴のおかげで信頼性と拡張性のあ
る多重継承したクラスを設計することができるのです。詳細は、 *note The
Python 2.3 Method Resolution Order: 144f. を見てください。


File: python.info,  Node: プライベート変数,  Next: 残りのはしばし,  Prev: 継承,  Up: クラス

2.9.6 プライベート変数
----------------------

オブジェクトの中からしかアクセス出来ない "プライベート" インスタンス変数
は、 Python にはありません。しかし、ほとんどの Python コードが従っている
慣習があります。アンダースコアで始まる名前 (例えば ‘_spam’) は、 (関数で
あれメソッドであれデータメンバであれ) 非 public なAPIとして扱います。こ
れらは、予告なく変更されるかもしれない実装の詳細として扱われるべきです。

クラスのプライベートメンバについて適切なユースケース(特にサブクラスで定
義された名前との衝突を避ける場合)があるので、名前マングリング ('name
mangling') と呼ばれる、限定されたサポート機構があります。 ‘__spam’ (先頭
に二個以上の下線文字、末尾に一個以下の下線文字) という形式の識別子は、
‘_classname__spam’ へとテキスト置換されるようになりました。ここで
‘classname’ は、現在のクラス名から先頭の下線文字をはぎとった名前になりま
す。このような難号化 (mangle) は、識別子の文法的な位置にかかわらず行われ
るので、クラス定義内に現れた識別子全てに対して実行されます。

参考
....

詳細と特例は、 *note private name mangling specifications: 1c24. 。

名前マングリングは、サブクラスが内部のメソッド呼び出しを壊さずにメソッド
をオーバーライドするのに便利です。例えば:

     class Mapping:
         def __init__(self, iterable):
             self.items_list = []
             self.__update(iterable)

         def update(self, iterable):
             for item in iterable:
                 self.items_list.append(item)

         __update = update   # 元の update() メソッドのプライベートコピー

     class MappingSubclass(Mapping):

         def update(self, keys, values):
             # update() への新シグネチャ導入
             # しかし __init__() は壊さない
             for item in zip(keys, values):
                 self.items_list.append(item)

上の例は、もし仮に ‘MappingSubclass’ に ‘__update’ 識別子を実装したとし
てもきちんと動きます。 その理由は、 ‘Mapping’ クラスではその識別子を
‘_Mapping__update’ に、 ‘MappingSubclass’ クラスでは
‘_MappingSubclass__update’ にそれぞれ置き換えるからです。

難号化の規則は主に不慮の事故を防ぐためのものだということに注意してくださ
い; 確信犯的な方法で、プライベートとされている変数にアクセスしたり変更す
ることは依然として可能なのです。デバッガのような特殊な状況では、この仕様
は便利ですらあります。

‘exec()’ や ‘eval()’ へ渡されたコードでは、呼出し元のクラス名を現在のク
ラスと見なさないことに注意してください。この仕様は ‘global’ 文の効果と似
ており、その効果もまた同様に、バイトコンパイルされたコードに制限されてい
ます。同じ制約が ‘getattr()’ と ‘setattr()’ と ‘delattr()’ にも適用され
ます。また、‘__dict__’ を直接参照するときにも適用されます。


File: python.info,  Node: 残りのはしばし,  Next: イテレータ iterator,  Prev: プライベート変数,  Up: クラス

2.9.7 残りのはしばし
--------------------

Pascal の "レコード (record)" や、C 言語の "構造体 (struct)" のような、
名前つきのデータ要素を一まとめにするデータ型があると便利なことがあります
。慣用的な手法として、この目的のために *note dataclasses: 27. を使用しま
す。

     from dataclasses import dataclass

     @dataclass
     class Employee:
         name: str
         dept: str
         salary: int

     >>> john = Employee('john', 'computer lab', 1000)
     >>> john.dept
     'computer lab'
     >>> john.salary
     1000

ある特定の抽象データ型を要求する Python コードの断片に、そのデータ型のメ
ソッドをエミュレーションするクラスを代わりに渡すことができます。例えば、
ファイルオブジェクトから何らかのデータを構築する関数がある場合、 *note
read(): 1bef. と *note readline(): 1c27. を持つクラスを定義して、ファイ
ルではなく文字列バッファからデータを取得するようにしておき、引数として渡
すことができます。

*note Instance method objects: 1c28. にも属性があります。 *note
m.__self__: 1370. はメソッド ‘m()’ の属しているインスタンスオブジェクト
で、*note m.__func__: 12ca. はそのメソッドに対応する *note function
object: 279. です。


File: python.info,  Node: イテレータ iterator,  Next: ジェネレータ generator,  Prev: 残りのはしばし,  Up: クラス

2.9.8 イテレータ (iterator)
---------------------------

すでに気づいているでしょうが、 *note for: 2c9. 文を使うとほとんどのコン
テナオブジェクトにわたってループを行うことができます:

     for element in [1, 2, 3]:
         print(element)
     for element in (1, 2, 3):
         print(element)
     for key in {'one':1, 'two':2}:
         print(key)
     for char in "123":
         print(char)
     for line in open("myfile.txt"):
         print(line, end='')

こういう要素へのアクセス方法は明確で簡潔で使い易いものです。イテレータの
活用は Python へ広く行き渡り、統一感を持たせています。裏では ‘for’ 文は
コンテナオブジェクトに対して *note iter(): 7a2. 関数を呼んでいます。関数
は、コンテナの中の要素に1つずつアクセスする *note __next__(): 129b. メソ
ッドが定義されているイテレータオブジェクトを返します。これ以上要素が無い
場合は、 *note __next__(): 129b. メソッドは *note StopIteration: bc8. 例
外を送出し、その通知を受け *note for: 2c9. ループは終了します。組み込み
の *note next(): 7a3. 関数を使って *note __next__(): 129b. メソッドを直
接呼ぶこともできます; この例は関数がどう働くのかを示しています:

     >>> s = 'abc'
     >>> it = iter(s)
     >>> it
     <str_iterator object at 0x10c90e650>
     >>> next(it)
     'a'
     >>> next(it)
     'b'
     >>> next(it)
     'c'
     >>> next(it)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
         next(it)
     StopIteration

イテレータプロトコルの裏にある仕組みを観察していれば、自作のクラスにイテ
レータとしての振舞いを追加するのは簡単です。 *note __next__(): 129b. メ
ソッドを持つオブジェクトを返す *note __iter__(): 1c2b. メソッドを定義す
るのです。クラスが ‘__next__()’ メソッドを定義している場合、
‘__iter__()’ メソッドは単に ‘self’ を返すことも可能です:

     class Reverse:
         """シーケンスを後ろからまわるイテレータ."""
         def __init__(self, data):
             self.data = data
             self.index = len(data)

         def __iter__(self):
             return self

         def __next__(self):
             if self.index == 0:
                 raise StopIteration
             self.index = self.index - 1
             return self.data[self.index]

     >>> rev = Reverse('spam')
     >>> iter(rev)
     <__main__.Reverse object at 0x00A1DB50>
     >>> for char in rev:
     ...     print(char)
     ...
     m
     a
     p
     s


File: python.info,  Node: ジェネレータ generator,  Next: ジェネレータ式,  Prev: イテレータ iterator,  Up: クラス

2.9.9 ジェネレータ (generator)
------------------------------

*note ジェネレータ: 1035. は、イテレータを作成するための簡潔で強力なツー
ルです。ジェネレータは通常の関数のように書かれますが、何らかのデータを返
すときには *note yield: 99b. 文を使います。そのジェネレータに対して
*note next(): 7a3. が呼び出されるたびに、ジェネレータは以前に中断した処
理を再開します (ジェネレータは、全てのデータ値と最後にどの文が実行された
かを記憶しています)。以下の例を見れば、ジェネレータがとても簡単に作成で
きることがわかります:

     def reverse(data):
         for index in range(len(data)-1, -1, -1):
             yield data[index]

     >>> for char in reverse('golf'):
     ...     print(char)
     ...
     f
     l
     o
     g

ジェネレータでできることは、前の節で解説したクラスを使ったイテレータでも
実現できます。ジェネレータの定義がコンパクトになるのは *note __iter__():
1c2e. メソッドと *note __next__(): 1c2f. メソッドが自動で作成されるから
です。

ジェネレータのもう一つの重要な機能は、呼び出しごとにローカル変数と実行状
態が自動的に保存されるということです。これにより、 ‘self.index’ や
‘self.data’ といったインスタンス変数を使ったアプローチよりも簡単に関数を
書くことができるようになります。

メソッドを自動生成したりプログラムの実行状態を自動保存するほかに、ジェネ
レータは終了時に自動的に *note StopIteration: bc8. を送出します。これら
の機能を組み合わせると、通常の関数を書くのと同じ労力で、簡単にイテレータ
を生成できます。


File: python.info,  Node: ジェネレータ式,  Prev: ジェネレータ generator,  Up: クラス

2.9.10 ジェネレータ式
---------------------

単純なジェネレータなら式として簡潔にコーディングできます。 その式はリス
ト内包表記に似た構文を使いますが、角括弧ではなく丸括弧で囲います。 ジェ
ネレータ式は、関数の中でジェネレータをすぐに使いたいような状況のために用
意されています。 ジェネレータ式は完全なジェネレータの定義よりコンパクト
ですが、ちょっと融通の効かないところがあります。 同じ内容を返すリスト内
包表記よりはメモリに優しいことが多いという利点があります。

例:

     >>> sum(i*i for i in range(10))                 # 平方和
     285

     >>> xvec = [10, 20, 30]
     >>> yvec = [7, 5, 3]
     >>> sum(x*y for x,y in zip(xvec, yvec))         # ドット積
     260

     >>> unique_words = set(word for line in page  for word in line.split())

     >>> valedictorian = max((student.gpa, student.name) for student in graduates)

     >>> data = 'golf'
     >>> list(data[i] for i in range(len(data)-1, -1, -1))
     ['f', 'l', 'o', 'g']

脚注
....


File: python.info,  Node: 標準ライブラリミニツアー,  Next: 標準ライブラリミニツアー --- その 2,  Prev: クラス,  Up: Python チュートリアル

2.10 標準ライブラリミニツアー
=============================

* Menu:

* OSへのインターフェース::
* ファイルのワイルドカード表記::
* コマンドライン引数::
* エラー出力のリダイレクトとプログラムの終了::
* 文字列のパターンマッチング::
* 数学::
* インターネットへのアクセス::
* 日付と時刻::
* データ圧縮::
* パフォーマンスの計測::
* 品質管理::
* バッテリー同梱::


File: python.info,  Node: OSへのインターフェース,  Next: ファイルのワイルドカード表記,  Up: 標準ライブラリミニツアー

2.10.1 OSへのインターフェース
-----------------------------

*note os: 91. モジュールは、オペレーティングシステムと対話するための多く
の関数を提供しています:

     >>> import os
     >>> os.getcwd()      # Return the current working directory
     'C:\\Python313'
     >>> os.chdir('/server/accesslogs')   # Change current working directory
     >>> os.system('mkdir today')   # Run the command mkdir in the system shell
     0

‘from os import *’ ではなく、 ‘import os’ 形式を使うようにしてください。
そうすることで、動作が大きく異なる組み込み関数 *note open(): 4e5. が
*note os.open(): d5f. で遮蔽されるのを避けられます。

組み込み関数 *note dir(): 5fe. および *note help(): 8a5. は、 *note os:
91. のような大規模なモジュールで作業をするときに、対話的な操作上の助けに
なります:

     >>> import os
     >>> dir(os)
     <returns a list of all module functions>
     >>> help(os)
     <returns an extensive manual page created from the module's docstrings>

ファイルやディレクトリの日常的な管理作業のために、より簡単に使える高水準
のインターフェースが *note shutil: b3. モジュールで提供されています:

     >>> import shutil
     >>> shutil.copyfile('data.db', 'archive.db')
     'archive.db'
     >>> shutil.move('/build/executables', 'installdir')
     'installdir'


File: python.info,  Node: ファイルのワイルドカード表記,  Next: コマンドライン引数,  Prev: OSへのインターフェース,  Up: 標準ライブラリミニツアー

2.10.2 ファイルのワイルドカード表記
-----------------------------------

*note glob: 5a. モジュールでは、ディレクトリのワイルドカード検索からファ
イルのリストを生成するための関数を提供しています:

     >>> import glob
     >>> glob.glob('*.py')
     ['primes.py', 'random.py', 'quote.py']


File: python.info,  Node: コマンドライン引数,  Next: エラー出力のリダイレクトとプログラムの終了,  Prev: ファイルのワイルドカード表記,  Up: 標準ライブラリミニツアー

2.10.3 コマンドライン引数
-------------------------

一般的なユーティリティスクリプトでは、よくコマンドライン引数を扱う必要が
あります。コマンドライン引数は モジュールの 'argv' 属性にリストとして保
存されています。例として以下の ‘demo.py’ ファイルを見てみましょう:

     # File demo.py
     import sys
     print(sys.argv)

以下は、コマンドライン上で ‘python demo.py one two three’ と実行した時の
出力です:

     ['demo.py', 'one', 'two', 'three']

*note argparse: 5. モジュールは、コマンドライン引数を処理するための更に
洗練された仕組みを提供します。次のスクリプトは1つ以上のファイル名を抽出
し、オプションで行数を表示します。

     import argparse

     parser = argparse.ArgumentParser(
         prog='top',
         description='Show top lines from each file')
     parser.add_argument('filenames', nargs='+')
     parser.add_argument('-l', '--lines', type=int, default=10)
     args = parser.parse_args()
     print(args)

コマンドラインで ‘python top.py --lines=5 alpha.txt beta.txt’ を実行する
と、上のスクリプトは ‘args.lines’ を ‘5’ 、 ‘args.filenames’ を
‘['alpha.txt', 'beta.txt']’ に設定します。


File: python.info,  Node: エラー出力のリダイレクトとプログラムの終了,  Next: 文字列のパターンマッチング,  Prev: コマンドライン引数,  Up: 標準ライブラリミニツアー

2.10.4 エラー出力のリダイレクトとプログラムの終了
-------------------------------------------------

*note sys: c3. モジュールには、 'stdin', 'stdout', 'stderr' を表す属性も
存在します。 'stderr' は、警告やエラーメッセージを出力して、 'stdout' が
リダイレクトされた場合でも読めるようにするために便利です:

     >>> sys.stderr.write('Warning, log file not found starting a new one\n')
     Warning, log file not found starting a new one

‘sys.exit()’ は、スクリプトを終了させるもっとも直接的な方法です。


File: python.info,  Node: 文字列のパターンマッチング,  Next: 数学,  Prev: エラー出力のリダイレクトとプログラムの終了,  Up: 標準ライブラリミニツアー

2.10.5 文字列のパターンマッチング
---------------------------------

*note re: a7. モジュールでは、より高度な文字列処理のための正規表現を提供
しています。正規表現は複雑な一致検索や操作に対して簡潔で最適化された解決
策を提供します:

     >>> import re
     >>> re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest')
     ['foot', 'fell', 'fastest']
     >>> re.sub(r'(\b[a-z]+) \1', r'\1', 'cat in the the hat')
     'cat in the hat'

最小限の機能だけが必要なら、読みやすくデバッグしやすい文字列メソッドの方
がお勧めです:

     >>> 'tea for too'.replace('too', 'two')
     'tea for two'


File: python.info,  Node: 数学,  Next: インターネットへのアクセス,  Prev: 文字列のパターンマッチング,  Up: 標準ライブラリミニツアー

2.10.6 数学
-----------

*note math: 81. モジュールは、浮動小数点演算のための C 言語ライブラリ関
数にアクセスする手段を提供しています:

     >>> import math
     >>> math.cos(math.pi / 4)
     0.70710678118654757
     >>> math.log(1024, 2)
     10.0

*note random: a6. モジュールは、乱数に基づいた要素選択のためのツールを提
供しています:

     >>> import random
     >>> random.choice(['apple', 'pear', 'banana'])
     'apple'
     >>> random.sample(range(100), 10)   # sampling without replacement
     [30, 83, 16, 4, 8, 81, 41, 50, 18, 33]
     >>> random.random()    # random float from the interval [0.0, 1.0)
     0.17970987693706186
     >>> random.randrange(6)    # random integer chosen from range(6)
     4

*note statistics: bd. モジュールは数値データの基礎的な統計的特性（平均、
中央値、分散等）を計算します:

     >>> import statistics
     >>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]
     >>> statistics.mean(data)
     1.6071428571428572
     >>> statistics.median(data)
     1.25
     >>> statistics.variance(data)
     1.3720238095238095

SciPy プロジェクト <‘https://scipy.org’> は数値処理のための多くのモジュ
ールを提供しています。


File: python.info,  Node: インターネットへのアクセス,  Next: 日付と時刻,  Prev: 数学,  Up: 標準ライブラリミニツアー

2.10.7 インターネットへのアクセス
---------------------------------

インターネットにアクセスしたりインターネットプロトコルを処理したりするた
めの多くのモジュールがあります。最も単純な2つのモジュールは、 URL からデ
ータを取得するための *note urllib.request: f4. と、メールを送るための
*note smtplib: b7. です:

     >>> from urllib.request import urlopen
     >>> with urlopen('http://worldtimeapi.org/api/timezone/etc/UTC.txt') as response:
     ...     for line in response:
     ...         line = line.decode()             # Convert bytes to a str
     ...         if line.startswith('datetime'):
     ...             print(line.rstrip())         # Remove trailing newline
     ...
     datetime: 2022-01-01T01:36:47.689215+00:00

     >>> import smtplib
     >>> server = smtplib.SMTP('localhost')
     >>> server.sendmail('soothsayer@example.org', 'jcaesar@example.org',
     ... """To: jcaesar@example.org
     ... From: soothsayer@example.org
     ...
     ... Beware the Ides of March.
     ... """)
     >>> server.quit()

(2つ目の例は localhost でメールサーバーが動いている必要があることに注意
してください。)


File: python.info,  Node: 日付と時刻,  Next: データ圧縮,  Prev: インターネットへのアクセス,  Up: 標準ライブラリミニツアー

2.10.8 日付と時刻
-----------------

*note datetime: 28. モジュールは、日付や時刻を操作するためのクラスを、単
純な方法と複雑な方法の両方で提供しています。日付や時刻に対する算術がサポ
ートされている一方、実装では出力のフォーマットや操作のための効率的なデー
タメンバ抽出に重点を置いています。このモジュールでは、タイムゾーンに対応
したオブジェクトもサポートしています。

     >>> # dates are easily constructed and formatted
     >>> from datetime import date
     >>> now = date.today()
     >>> now
     datetime.date(2003, 12, 2)
     >>> now.strftime("%m-%d-%y. %d %b %Y is a %A on the %d day of %B.")
     '12-02-03. 02 Dec 2003 is a Tuesday on the 02 day of December.'

     >>> # dates support calendar arithmetic
     >>> birthday = date(1964, 7, 31)
     >>> age = now - birthday
     >>> age.days
     14368


File: python.info,  Node: データ圧縮,  Next: パフォーマンスの計測,  Prev: 日付と時刻,  Up: 標準ライブラリミニツアー

2.10.9 データ圧縮
-----------------

一般的なデータアーカイブと圧縮形式は、以下のようなモジュールによって直接
的にサポートされます: *note zlib: 119, *note gzip: 5d, *note bz2: f,
*note lzma: 7e, *note zipfile: 117, *note tarfile: c8.。

     >>> import zlib
     >>> s = b'witch which has which witches wrist watch'
     >>> len(s)
     41
     >>> t = zlib.compress(s)
     >>> len(t)
     37
     >>> zlib.decompress(t)
     b'witch which has which witches wrist watch'
     >>> zlib.crc32(s)
     226805979


File: python.info,  Node: パフォーマンスの計測,  Next: 品質管理,  Prev: データ圧縮,  Up: 標準ライブラリミニツアー

2.10.10 パフォーマンスの計測
----------------------------

Python ユーザの中には、同じ問題を異なったアプローチで解いた際の相対的な
パフォーマンスについて知りたいという深い興味を持っている人がいます。
Python は、そういった疑問に即座に答える計測ツールを提供しています。

例えば、引数の入れ替え操作に対して、伝統的なアプローチの代わりにタプルの
パックやアンパックを使ってみたいと思うかもしれません。 *note timeit: d8.
モジュールを使えば、パフォーマンスがほんの少し良いことがすぐに分かります
:

     >>> from timeit import Timer
     >>> Timer('t=a; a=b; b=t', 'a=1; b=2').timeit()
     0.57535828626024577
     >>> Timer('a,b = b,a', 'a=1; b=2').timeit()
     0.54962537085770791

*note timeit: d8. では小さい粒度を提供しているのに対し、 *note profile:
9d. や *note pstats: 9e. モジュールではより大きなコードブロックにおいて
律速となる部分を判定するためのツールを提供しています。


File: python.info,  Node: 品質管理,  Next: バッテリー同梱,  Prev: パフォーマンスの計測,  Up: 標準ライブラリミニツアー

2.10.11 品質管理
----------------

高い品質のソフトウェアを開発するための一つのアプローチは、各関数に対して
開発と同時にテストを書き、開発の過程で頻繁にテストを走らせるというもので
す。

*note doctest: 31. モジュールでは、モジュールを検索してプログラムの
docstring に埋め込まれたテストの評価を行うためのツールを提供しています。
テストの作り方は単純で、典型的な呼び出し例とその結果を docstring にカッ
ト&ペーストするだけです。この作業は、ユーザに使用例を与えるという意味で
ドキュメントの情報を増やすと同時に、ドキュメントに書かれているコードが正
しい事を確認できるようになります:

     def average(values):
         """Computes the arithmetic mean of a list of numbers.

         >>> print(average([20, 30, 70]))
         40.0
         """
         return sum(values) / len(values)

     import doctest
     doctest.testmod()   # automatically validate the embedded tests

*note unittest: ef. モジュールは *note doctest: 31. モジュールほど気楽に
使えるものではありませんが、より網羅的なテストセットを別のファイルで管理
することができます:

     import unittest

     class TestStatisticalFunctions(unittest.TestCase):

         def test_average(self):
             self.assertEqual(average([20, 30, 70]), 40.0)
             self.assertEqual(round(average([1, 5, 7]), 1), 4.3)
             with self.assertRaises(ZeroDivisionError):
                 average([])
             with self.assertRaises(TypeError):
                 average(20, 30, 70)

     unittest.main()  # Calling from the command line invokes all tests


File: python.info,  Node: バッテリー同梱,  Prev: 品質管理,  Up: 標準ライブラリミニツアー

2.10.12 バッテリー同梱
----------------------

Python には "バッテリー同梱 (batteries included)" 哲学があります。この哲
学は、洗練され、安定した機能を持つ Python の膨大なパッケージ群に如実に表
れています。例えば:

   * *note xmlrpc.client: 114. および *note xmlrpc.server: 115. モジュー
     ルは、遠隔手続き呼び出し (remote procedure call) を全く大したことの
     ない作業に変えてしまいます。モジュール名とは違い、XML を扱うための
     直接的な知識は必要ありません。

   * *note email: 32. パッケージは、MIME やその他の RFC 2822(1) に基づく
     メッセージ文書を含む電子メールメッセージを管理するためのライブラリ
     です。実際にメッセージを送信したり受信したりする *note smtplib: b7.
     や *note poplib: 9a. と違って、email パッケージには (添付文書を含む
     ) 複雑なメッセージ構造の構築やデコードを行ったり、インターネット標
     準のエンコードやヘッダプロトコルの実装を行ったりするための完全なツ
     ールセットを備えています。

   * *note json: 76. パッケージはこの一般的なデータ交換形式のパースをロ
     バストにサポートしています。*note csv: 21. モジュールはデータベース
     や表計算で一般的にサポートされている CSV ファイルを直接読み書きする
     のをサポートしています。*note xml.etree.ElementTree: 10c.、*note
     xml.dom: 108. ならびに *note xml.sax: 110. パッケージは XML の処理
     をサポートしています。総合すると、これらのモジュールによって Python
     アプリケーションと他のツールの間でとても簡単にデータを受け渡すこと
     が出来ます。

   * *note sqlite3: ba. モジュールは SQLite データベースライブラリのラッ
     パーです。若干非標準の SQL シンタックスを用いて更新や接続出来る永続
     的なデータベースを提供します。

   * 国際化に関する機能は、 *note gettext: 59, *note locale: 7a, *note
     codecs: 14. パッケージといったモジュール群でサポートされています。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2822.html


File: python.info,  Node: 標準ライブラリミニツアー --- その 2,  Next: 仮想環境とパッケージ,  Prev: 標準ライブラリミニツアー,  Up: Python チュートリアル

2.11 標準ライブラリミニツアー -- その 2
=======================================

ツアーの第2部では、プロフェッショナルプログラミングを支えるもっと高度な
モジュールをカバーします。ここで挙げるモジュールは、小さなスクリプトの開
発ではほとんど使いません。

* Menu:

* 出力のフォーマット::
* 文字列テンプレート::
* バイナリデータレコードの操作::
* マルチスレッディング: マルチスレッディング<2>.
* ログ記録::
* 弱参照::
* リスト操作のためのツール::
* 10 進浮動小数演算::


File: python.info,  Node: 出力のフォーマット,  Next: 文字列テンプレート,  Up: 標準ライブラリミニツアー --- その 2

2.11.1 出力のフォーマット
-------------------------

*note reprlib: a9. モジュールは、大きなコンテナや、深くネストしたコンテ
ナを省略して表示するバージョンの *note repr(): 7c8. を提供しています:

     >>> import reprlib
     >>> reprlib.repr(set('supercalifragilisticexpialidocious'))
     "{'a', 'c', 'd', 'e', 'f', 'g', ...}"

*note pprint: 9c. モジュールは、組み込み型やユーザ定義型をわかりやすく表
示するための洗練された制御手段を提供しています。表示結果が複数行にわたる
場合は、 "pretty printer" と呼ばれるものが改行やインデントを追加して、デ
ータ構造がより明確になるように印字します:

     >>> import pprint
     >>> t = [[[['black', 'cyan'], 'white', ['green', 'red']], [['magenta',
     ...     'yellow'], 'blue']]]
     ...
     >>> pprint.pprint(t, width=30)
     [[[['black', 'cyan'],
        'white',
        ['green', 'red']],
       [['magenta', 'yellow'],
        'blue']]]

*note textwrap: d5. モジュールは、段落で構成された文章を、指定したスクリ
ーン幅にぴったり収まるように調整します:

     >>> import textwrap
     >>> doc = """The wrap() method is just like fill() except that it returns
     ... a list of strings instead of one big string with newlines to separate
     ... the wrapped lines."""
     ...
     >>> print(textwrap.fill(doc, width=40))
     The wrap() method is just like fill()
     except that it returns a list of strings
     instead of one big string with newlines
     to separate the wrapped lines.

*note locale: 7a. モジュールは、文化により異なるデータ表現形式のデータベ
ースにアクセスします。 *note locale: 7a. の *note format(): 5eb. 関数の
grouping 属性を使えば、数値を適切な桁区切り文字によりグループ化された形
式に変換できます:

     >>> import locale
     >>> locale.setlocale(locale.LC_ALL, 'English_United States.1252')
     'English_United States.1252'
     >>> conv = locale.localeconv()          # get a mapping of conventions
     >>> x = 1234567.8
     >>> locale.format_string("%d", x, grouping=True)
     '1,234,567'
     >>> locale.format_string("%s%.*f", (conv['currency_symbol'],
     ...                      conv['frac_digits'], x), grouping=True)
     '$1,234,567.80'


File: python.info,  Node: 文字列テンプレート,  Next: バイナリデータレコードの操作,  Prev: 出力のフォーマット,  Up: 標準ライブラリミニツアー --- その 2

2.11.2 文字列テンプレート
-------------------------

*note string: be. モジュールには、柔軟で、エンドユーザが簡単に編集できる
簡単な構文を備えた *note Template: 653. クラスが入っています。このクラス
を使うと、ユーザがアプリケーションを修正することなしにアプリケーションの
出力をカスタマイズできるようになります。

テンプレートでは、‘$’ と有効な Python 識別子名 (英数字とアンダースコア)
からなるプレースホルダ名を使います。プレースホルダの周りを {} で囲えば、
プレースホルダの後ろにスペースを挟まず、英数文字を続けることができます。
‘$$’ のようにすると、‘$’ 自体をエスケープできます:

     >>> from string import Template
     >>> t = Template('${village}folk send $$10 to $cause.')
     >>> t.substitute(village='Nottingham', cause='the ditch fund')
     'Nottinghamfolk send $10 to the ditch fund.'

*note substitute(): 1c54. メソッドは、プレースホルダに相当する値が辞書や
キーワード引数にない場合に *note KeyError: 31d. を送出します。メールマー
ジ機能のようなアプリケーションの場合、ユーザが入力するデータは不完全なこ
とがあるので、欠落したデータがあるとプレースホルダをそのままにして出力す
る *note safe_substitute(): 1c55. メソッドを使う方が適切かもしれません:

     >>> t = Template('Return the $item to $owner.')
     >>> d = dict(item='unladen swallow')
     >>> t.substitute(d)
     Traceback (most recent call last):
       ...
     KeyError: 'owner'
     >>> t.safe_substitute(d)
     'Return the unladen swallow to $owner.'

区切り文字はデフォルトは ‘$’ ですが、*note Template: 653. のサブクラスを
派生すると変更することができます。例えば、画像ブラウザ用に一括で名前を変
更するユーティリティを作っていたとして、現在の日付や画像のシーケンス番号
、ファイル形式といったプレースホルダにパーセント記号を使うことにしたら、
次のようになります:

     >>> import time, os.path
     >>> photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg']
     >>> class BatchRename(Template):
     ...     delimiter = '%'
     ...
     >>> fmt = input('Enter rename style (%d-date %n-seqnum %f-format):  ')
     Enter rename style (%d-date %n-seqnum %f-format):  Ashley_%n%f

     >>> t = BatchRename(fmt)
     >>> date = time.strftime('%d%b%y')
     >>> for i, filename in enumerate(photofiles):
     ...     base, ext = os.path.splitext(filename)
     ...     newname = t.substitute(d=date, n=i, f=ext)
     ...     print('{0} --> {1}'.format(filename, newname))

     img_1074.jpg --> Ashley_0.jpg
     img_1076.jpg --> Ashley_1.jpg
     img_1077.jpg --> Ashley_2.jpg

テンプレートのもう一つの用途は、複数ある出力フォーマットからのプログラム
ロジックの分離です。これにより、XMLファイル用、プレーンテキストのレポー
ト用、HTMLのwebレポート用のテンプレートに、同じプログラムロジックから値
を埋め込むことができます。


File: python.info,  Node: バイナリデータレコードの操作,  Next: マルチスレッディング<2>,  Prev: 文字列テンプレート,  Up: 標準ライブラリミニツアー --- その 2

2.11.3 バイナリデータレコードの操作
-----------------------------------

*note struct: c0. モジュールでは、様々な長さのバイナリレコード形式を操作
する *note pack(): 1248. や *note unpack(): 1731. といった関数を提供して
います。 以下の例では、 *note zipfile: 117. モジュールを使わずに、ZIP フ
ァイルのヘッダ情報を巡回する方法を示しています。‘"H"’ と ‘"I"’ というパ
ック符号は、それぞれ2バイトと4バイトの符号無し 整数を表しています。
‘"<"’ は、そのパック符号が standard サイズであり、バイトオーダーがリトル
エンディアンであることを示しています:

     import struct

     with open('myfile.zip', 'rb') as f:
         data = f.read()

     start = 0
     for i in range(3):                      # show the first 3 file headers
         start += 14
         fields = struct.unpack('<IIIHH', data[start:start+16])
         crc32, comp_size, uncomp_size, filenamesize, extra_size = fields

         start += 16
         filename = data[start:start+filenamesize]
         start += filenamesize
         extra = data[start:start+extra_size]
         print(filename, hex(crc32), comp_size, uncomp_size)

         start += extra_size + comp_size     # skip to the next header


File: python.info,  Node: マルチスレッディング<2>,  Next: ログ記録,  Prev: バイナリデータレコードの操作,  Up: 標準ライブラリミニツアー --- その 2

2.11.4 マルチスレッディング
---------------------------

スレッド処理 (threading) とは、順序的な依存関係にない複数のタスクを分割
するテクニックです。スレッドは、ユーザの入力を受け付けつつ、背後で別のタ
スクを動かすようなアプリケーションの応答性を高めます。同じような使用例と
して、I/O を別のスレッドの計算処理と並列して動作させるというものがありま
す。

以下のコードでは、高水準のモジュール *note threading: d6. でメインのプロ
グラムを動かしながら背後で別のタスクを動作させられるようにする方法を示し
ています:

     import threading, zipfile

     class AsyncZip(threading.Thread):
         def __init__(self, infile, outfile):
             threading.Thread.__init__(self)
             self.infile = infile
             self.outfile = outfile

         def run(self):
             f = zipfile.ZipFile(self.outfile, 'w', zipfile.ZIP_DEFLATED)
             f.write(self.infile)
             f.close()
             print('Finished background zip of:', self.infile)

     background = AsyncZip('mydata.txt', 'myarchive.zip')
     background.start()
     print('The main program continues to run in foreground.')

     background.join()    # Wait for the background task to finish
     print('Main program waited until background was done.')

マルチスレッドアプリケーションを作る上で最も難しい問題は、データやリソー
スを共有するスレッド間の調整 (coordination)です。この問題を解決するため
、*note threading: d6. モジュールではロックやイベント、状態変数、セマフ
ォといった数々の同期プリミティブを提供しています。

こうしたツールは強力な一方、ちょっとした設計上の欠陥で再現困難な問題を引
き起こすことがあります。したがって、タスク間調整では *note queue: a4. モ
ジュールを使って他の複数のスレッドからのリクエストを一つのスレッドに送り
込み、一つのリソースへのアクセスをできるだけ一つのスレッドに集中させるほ
うが良いでしょう。スレッド間の通信や調整に *note Queue: 1356. オブジェク
トを使うと、設計が容易になり、可読性が高まり、信頼性が増します。


File: python.info,  Node: ログ記録,  Next: 弱参照,  Prev: マルチスレッディング<2>,  Up: 標準ライブラリミニツアー --- その 2

2.11.5 ログ記録
---------------

*note logging: 7b. モジュールでは、数多くの機能をそなえた柔軟性のあるロ
グ記録システムを提供しています。最も簡単な使い方では、ログメッセージをフ
ァイルや ‘sys.stderr’ に送信します:

     import logging
     logging.debug('Debugging information')
     logging.info('Informational message')
     logging.warning('Warning:config file %s not found', 'server.conf')
     logging.error('Error occurred')
     logging.critical('Critical error -- shutting down')

これは以下の出力を生成します:

     WARNING:root:Warning:config file server.conf not found
     ERROR:root:Error occurred
     CRITICAL:root:Critical error -- shutting down

デフォルトでは、*note info(): 1c5c. と *note debug(): df7. による出力は
抑制され、出力は標準エラーに送信されます。選択可能な送信先には、email、
データグラム、ソケット、HTTP サーバへの送信などがあります。新たにフィル
タを作成すると、*note DEBUG: 1c5d.、*note INFO: 1c5e.、*note WARNING:
1c5f.、*note ERROR: 1c60.、*note CRITICAL: 1c61. といったメッセージのプ
ライオリティによって異なる送信先を選択することができます。

ログ記録システムは Python から直接設定することもできますし、アプリケーシ
ョンを変更しなくてもカスタマイズできるよう、ユーザが編集可能な設定ファイ
ルによって設定することもできます。


File: python.info,  Node: 弱参照,  Next: リスト操作のためのツール,  Prev: ログ記録,  Up: 標準ライブラリミニツアー --- その 2

2.11.6 弱参照
-------------

Python は自動的にメモリを管理します (ほとんどのオブジェクトは参照カウン
ト方式で管理し、 *note ガベージコレクション: 1884. で循環参照を除去しま
す)。オブジェクトに対する最後の参照がなくなってしばらくするとメモリは解
放されます。

このようなアプローチはほとんどのアプリケーションでうまく動作しますが、中
にはオブジェクトをどこか別の場所で利用している間だけ追跡しておきたい場合
もあります。残念ながら、オブジェクトを追跡するだけでオブジェクトに対する
恒久的な参照を作ることになってしまいます。 *note weakref: fc. モジュール
では、オブジェクトへの参照を作らずに追跡するためのツールを提供しています
。弱参照オブジェクトが不要になると、弱参照 (weakref) テーブルから自動的
に除去され、コールバック関数がトリガされます。弱参照を使う典型的な応用例
には、作成コストの大きいオブジェクトのキャッシュがあります:

     >>> import weakref, gc
     >>> class A:
     ...     def __init__(self, value):
     ...         self.value = value
     ...     def __repr__(self):
     ...         return str(self.value)
     ...
     >>> a = A(10)                   # create a reference
     >>> d = weakref.WeakValueDictionary()
     >>> d['primary'] = a            # does not create a reference
     >>> d['primary']                # fetch the object if it is still alive
     10
     >>> del a                       # remove the one reference
     >>> gc.collect()                # run garbage collection right away
     0
     >>> d['primary']                # entry was automatically removed
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
         d['primary']                # entry was automatically removed
       File "C:/python313/lib/weakref.py", line 46, in __getitem__
         o = self.data[key]()
     KeyError: 'primary'


File: python.info,  Node: リスト操作のためのツール,  Next: 10 進浮動小数演算,  Prev: 弱参照,  Up: 標準ライブラリミニツアー --- その 2

2.11.7 リスト操作のためのツール
-------------------------------

多くのデータ構造は、組み込みリスト型を使った実装で事足ります。とはいえ、
時には組み込みリストとは違うパフォーマンス上のトレードオフを持つような実
装が必要になこともあります。

*note array: 6. (配列) モジュールでは、*note array: 185. オブジェクトを
提供しています。配列はリストに似ていますが、同種のデータのみを よりコン
パクトに格納します。 以下の例に示すのは、通常 1 要素あたり 16 バイト使う
Python の int オブジェクトのリストではなく、2 バイト使う符号無しバイナリ
整数 (タイプコード ‘"H"’) の配列です:

     >>> from array import array
     >>> a = array('H', [4000, 10, 700, 22222])
     >>> sum(a)
     26932
     >>> a[1:3]
     array('H', [10, 700])

*note collections: 16. モジュールでは、 *note deque: 5a6. オブジェクトを
提供しています。リスト型に似ていますが、データの追加と左端からの取り出し
が速く、その一方で中間にある値の参照は遅くなります。こうしたオブジェクト
はキューや木構造の幅優先探索の実装に向いています:

     >>> from collections import deque
     >>> d = deque(["task1", "task2", "task3"])
     >>> d.append("task4")
     >>> print("Handling", d.popleft())
     Handling task1

     unsearched = deque([starting_node])
     def breadth_first_search(unsearched):
         node = unsearched.popleft()
         for m in gen_moves(node):
             if is_goal(m):
                 return m
             unsearched.append(m)

リストの代わりの実装以外にも、標準ライブラリにはソート済みのリストを操作
するための関数を備えた *note bisect: d. のようなツールも提供しています:

     >>> import bisect
     >>> scores = [(100, 'perl'), (200, 'tcl'), (400, 'lua'), (500, 'python')]
     >>> bisect.insort(scores, (300, 'ruby'))
     >>> scores
     [(100, 'perl'), (200, 'tcl'), (300, 'ruby'), (400, 'lua'), (500, 'python')]

*note heapq: 5f. モジュールは、通常のリストでヒープを実装するための関数
を提供しています。ヒープでは、最も低い値をもつエントリがつねにゼロの位置
に配置されます。ヒープは、毎回リストをソートすることなく、最小の値をもつ
要素に繰り返しアクセスするようなアプリケーションで便利です:

     >>> from heapq import heapify, heappop, heappush
     >>> data = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]
     >>> heapify(data)                      # rearrange the list into heap order
     >>> heappush(data, -5)                 # add a new entry
     >>> [heappop(data) for i in range(3)]  # fetch the three smallest entries
     [-5, 0, 1]


File: python.info,  Node: 10 進浮動小数演算,  Prev: リスト操作のためのツール,  Up: 標準ライブラリミニツアー --- その 2

2.11.8 10 進浮動小数演算
------------------------

*note decimal: 2e. モジュールでは、 10 進浮動小数の算術演算をサポートす
る *note Decimal: 27d. データ型を提供しています。組み込みの 2 進浮動小数
の実装である *note float: 2ce. に比べて、このクラスがとりわけ便利なのは
、以下の場合です

   * 財務アプリケーションやその他の正確な10進表記が必要なアプリケーショ
     ン、

   * 精度の制御、

   * 法的または規制上の理由に基づく値丸めの制御、

   * 有効桁数の追跡が必要になる場合

   * ユーザが手計算の結果と同じ演算結果を期待するようなアプリケーション
     。

例えば、70 セントの電話代にかかる 5% の税金を計算しようとすると、10 進の
浮動小数点値と 2 進の浮動小数点値では違う結果になってしまいます。計算結
果を四捨五入してセント単位にしようとすると、以下のように違いがはっきり現
れます:

     >>> from decimal import *
     >>> round(Decimal('0.70') * Decimal('1.05'), 2)
     Decimal('0.74')
     >>> round(.70 * 1.05, 2)
     0.73

上の例で、*note Decimal: 27d. を使った計算では、末尾桁のゼロが保存されて
おり、有効数字2桁の被乗数から自動的に有効数字を 4 桁と判断しています。
*note Decimal: 27d. は手計算と 同じ方法で計算を行い、2 進浮動小数が 10 進
小数成分を正確に表現できないことに よって起きる問題を回避しています。

*note Decimal: 27d. クラスは厳密な値を表現できるため、2 進浮動小数点数で
は 期待通りに計算できないような剰余の計算や等値テストも実現できます:

     >>> Decimal('1.00') % Decimal('.10')
     Decimal('0.00')
     >>> 1.00 % 0.10
     0.09999999999999995

     >>> sum([Decimal('0.1')]*10) == Decimal('1.0')
     True
     >>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0
     False

*note decimal: 2e. モジュールを使うと、必要なだけの精度で算術演算を行え
ます:

     >>> getcontext().prec = 36
     >>> Decimal(1) / Decimal(7)
     Decimal('0.142857142857142857142857142857142857')


File: python.info,  Node: 仮想環境とパッケージ,  Next: さあ何を？,  Prev: 標準ライブラリミニツアー --- その 2,  Up: Python チュートリアル

2.12 仮想環境とパッケージ
=========================

* Menu:

* はじめに: はじめに<4>.
* 仮想環境の作成::
* pip を使ったパッケージ管理::


File: python.info,  Node: はじめに<4>,  Next: 仮想環境の作成,  Up: 仮想環境とパッケージ

2.12.1 はじめに
---------------

Python アプリケーションはよく標準ライブラリ以外のパッケージやモジュール
を利用します。またアプリケーションがあるバグ修正を必要としていたり、過去
のバージョンのインターフェイスに依存しているために、ライブラリの特定のバ
ージョンを必要とすることもあります。

そのため、1つのインストールされたPythonが全てのアプリケーションの要求に
対応することは不可能です。もしアプリケーションAがあるモジュールのバージ
ョン 1.0 を要求していて、別のアプリケーションBが同じモジュールのバージョ
ン 2.0 を要求している場合、2つの要求は衝突していて、1.0 と 2.0 のどちら
かのバージョンをインストールしても片方のアプリケーションが動きません。

この問題の解決策は *note 仮想環境: 1c6c. を作ることです。仮想環境とは、
特定のバージョンの Python と幾つかの追加パッケージを含んだ Python インス
トールを構成するディレクトリです。

別のアプリケーションはそれぞれ別の仮想環境を使うことができます。先の例に
あった要求の衝突を解決する場合、アプリケーションAが固有の仮想環境を持っ
てそこにライブラリのバージョン 1.0 をインストールし、アプリケーションBが
持つ別の仮想環境にライブラリのバージョン 2.0 をインストールすることがで
きます。そしてアプリケーションBがライブラリのバージョンを 3.0 に更新する
ことを要求する場合も、アプリケーションAに影響しません。


File: python.info,  Node: 仮想環境の作成,  Next: pip を使ったパッケージ管理,  Prev: はじめに<4>,  Up: 仮想環境とパッケージ

2.12.2 仮想環境の作成
---------------------

仮想環境の作成・管理に使われるモジュールは、 *note venv: f9. と呼ばれま
す。 *note venv: f9. は、コマンドが実行された Python のバージョン (*note
-version: ce9. オプションで表示される) をインストールします。例えば、
‘python3.12’ でコマンドを実行すると、バージョン 3.12 がインストールされ
ます。

仮想環境を作るには、仮想環境を置くディレクトリを決めて、 そのディレクト
リのパスを指定して、 *note venv: f9. をスクリプトとして実行します:

     python -m venv tutorial-env

これは ‘tutorial-env’ ディレクトリがなければ作成して、その中に Python イ
ンタプリタ、その他関連するファイルのコピーを含むサブディレクトリを作りま
す。

仮想環境の一般的なディレクトリの場所は ‘.venv’ です。この名前は、通常は
シェルで隠されているため、ディレクトリが存在する理由を説明する名前を付け
ても、邪魔にはなりません。また、一部のツールでサポートされている ‘.env’
環境変数定義ファイルによるクラッシュも防止します。

仮想環境を作ったら、それを有効化する必要があります。

Windows の場合:

     tutorial-env\Scripts\activate

Unix や Mac OS の場合:

     source tutorial-env/bin/activate

(このスクリプトは bash shell で書かれています。 ‘csh’ や ‘fish’ を利用し
ている場合、代わりに利用できる ‘activate.csh’ と ‘activate.fish’ スクリ
プトがあります。)

仮想環境を有効化すると、シェルのプロンプトに利用中の仮想環境が表示される
ようになり、‘python’ を実行するとその仮想環境の Python を実行するように
なります:

     $ source ~/envs/tutorial-env/bin/activate
     (tutorial-env) $ python
     Python 3.5.1 (default, May  6 2016, 10:59:36)
       ...
     >>> import sys
     >>> sys.path
     ['', '/usr/local/lib/python35.zip', ...,
     '~/envs/tutorial-env/lib/python3.5/site-packages']
     >>>

仮想環境を無効化するには、ターミナルに:

     deactivate

と入力します。


File: python.info,  Node: pip を使ったパッケージ管理,  Prev: 仮想環境の作成,  Up: 仮想環境とパッケージ

2.12.3 pip を使ったパッケージ管理
---------------------------------

　‘pip’ と呼ばれるプログラムでパッケージをインストール、アップグレード、
削除することができます。デフォルトでは ‘pip’ は Python Package Index(1)
からパッケージをインストールします。ブラウザを使って Python Package
Index を閲覧することができます。

‘pip’ は "install" 、 "uninstall" 、 "freeze" など、いくつかのサブコマン
ドを持っています。 (‘pip’ の完全なドキュメントは *note Python
モジュールのインストール: ec0. ガイドを参照してください。)

パッケージ名を指定してそのパッケージの最新版をインストールすることができ
ます:

     (tutorial-env) $ python -m pip install novas
     Collecting novas
       Downloading novas-3.1.1.3.tar.gz (136kB)
     Installing collected packages: novas
       Running setup.py install for novas
     Successfully installed novas-3.1.1.3

パッケージ名のあとに ‘==’ とバージョン番号を付けることで、特定のバージョ
ンのパッケージをインストールすることもできます:

     (tutorial-env) $ python -m pip install requests==2.6.0
     Collecting requests==2.6.0
       Using cached requests-2.6.0-py2.py3-none-any.whl
     Installing collected packages: requests
     Successfully installed requests-2.6.0

同じコマンドを再び実行した場合、‘pip’ は要求されたバージョンがインストー
ル済みだと表示して何もしません。別のバージョン番号を指定すればそのバージ
ョンをインストールしますし、‘python -m pip install --upgrade’ を実行すれ
ばそのパッケージを最新版に更新します:

     (tutorial-env) $ python -m pip install --upgrade requests
     Collecting requests
     Installing collected packages: requests
       Found existing installation: requests 2.6.0
         Uninstalling requests-2.6.0:
           Successfully uninstalled requests-2.6.0
     Successfully installed requests-2.7.0

‘python -m pip uninstall’ コマンドに削除するパッケージ名を1つ以上指定し
ます。

‘python -m pip show’ は指定されたパッケージの情報を表示します:

     (tutorial-env) $ python -m pip show requests
     ---
     Metadata-Version: 2.0
     Name: requests
     Version: 2.7.0
     Summary: Python HTTP for Humans.
     Home-page: http://python-requests.org
     Author: Kenneth Reitz
     Author-email: me@kennethreitz.com
     License: Apache 2.0
     Location: /Users/akuchling/envs/tutorial-env/lib/python3.4/site-packages
     Requires:

‘python -m pip list’ は仮想環境にインストールされた全てのパッケージを表
示します:

     (tutorial-env) $ python -m pip list
     novas (3.1.1.3)
     numpy (1.9.2)
     pip (7.0.3)
     requests (2.7.0)
     setuptools (16.0)

‘python -m pip freeze’ はインストールされたパッケージ一覧を、‘python -m
pip install’ が解釈するフォーマットで生成します。一般的な慣習として、こ
のリストを ‘requirements.txt’ というファイルに保存します:

     (tutorial-env) $ python -m pip freeze > requirements.txt
     (tutorial-env) $ cat requirements.txt
     novas==3.1.1.3
     numpy==1.9.2
     requests==2.7.0

‘requirements.txt’ をバージョン管理システムにコミットして、アプリケーシ
ョンの一部として配布することができます。ユーザーは必要なパッケージを
‘install -r’ でインストールできます:

     (tutorial-env) $ python -m pip install -r requirements.txt
     Collecting novas==3.1.1.3 (from -r requirements.txt (line 1))
       ...
     Collecting numpy==1.9.2 (from -r requirements.txt (line 2))
       ...
     Collecting requests==2.7.0 (from -r requirements.txt (line 3))
       ...
     Installing collected packages: novas, numpy, requests
       Running setup.py install for novas
     Successfully installed novas-3.1.1.3 numpy-1.9.2 requests-2.7.0

‘pip’ にはたくさんのオプションがあります。 ‘pip’ の完全なドキュメントは
*note Python モジュールのインストール: ec0. を参照してください。パッケー
ジを作成してそれを Python Package Index で公開したい場合、 Python
packaging user guide(2) を参照してください。

   ---------- Footnotes ----------

   (1) https://pypi.org

   (2) 
https://packaging.python.org/en/latest/tutorials/packaging-projects/


File: python.info,  Node: さあ何を？,  Next: 対話入力編集と履歴置換,  Prev: 仮想環境とパッケージ,  Up: Python チュートリアル

2.13 さあ何を？
===============

このチュートリアルを読んだことで、おそらく Python を使ってみようという関
心はますます強くなったことでしょう -- 現実世界の問題を解決するために、
Python を適用してみたくなったはずです。さて、それではどこで勉強をしたら
よいのでしょうか？

このチュートリアルは Python のドキュメンテーションセットの一部です。セッ
トの中の他のドキュメンテーションをいくつか紹介します:

   * *note Python 標準ライブラリ: 12a.:

     このマニュアルをざっと眺めておくと便利です。このマニュアルは型、関
     数、標準ライブラリのモジュールについての完全なリファレンスです。標
     準的なPython配布物は 'たくさんの' 追加コードを含んでいます。Unix メ
     ールボックスの読み込み、HTTPによるドキュメント取得、乱数の生成、コ
     マンドラインオプションの構文解析、データ圧縮やその他たくさんのタス
     クのためのモジュールがあります。ライブラリリファレンスをざっと見る
     ことで、何が利用できるかのイメージをつかむことができます。

   * *note Python モジュールのインストール: ec0. は、他のPythonユーザに
     よって書かれた追加モジュールをどうやってインストールするかを説明し
     ています。

   * *note Python 言語リファレンス: 12b.: Pythonの文法とセマンティクスを
     詳しく説明しています。読むのは大変ですが、言語の完全なガイドとして
     有用です。

さらなる Python に関するリソース:

   * ‘https://www.python.org’: 有名なPythonのWebサイト。コードやドキュメ
     ント、Pythonに関するWebページへのポインターを含んでいます。

   * ‘https://docs.python.org’: Pythonドキュメントへの素早いアクセスを提
     供します。

   * ‘https://pypi.org’: Python パッケージインデックス、以前は Cheese
     Shop (1) という愛称でも呼ばれていました。これは、ユーザ作成のダウン
     ロードできる Python モジュールの索引です。コードのリリースをしたら
     、ここに登録することで他の人が見つけられます。

   * ‘https://code.activestate.com/recipes/langs/python/’: Python クック
     ブックはコード例、モジュール、実用的なスクリプトの巨大なコレクショ
     ンです。主要なものは同名の本Python Cookbook (O'Reilly & Associates,
     ISBN 0-596-00797-3)に収録されています。

   * ‘https://pyvideo.org’ は学会やユーザグループの会合から Python 関連
     のビデオのリンクを集めています。

   * ‘https://scipy.org’: Scientific Python プロジェクトは配列の高速な計
     算・操作モジュールに加え、線形代数、フーリエ変換、非線形ソルバー、
     乱数分布、統計分析などの多くのパッケージを提供しています。

Python 関連の質問や問題の報告については、ニュースグループ
‘comp.lang.python’ に投稿するか、またはメーリングリスト
<python-list@python.org> に送ることができます。ニュースグループとメーリ
ングリストはゲートウェイされます。したがって、片方に投稿されたメッセージ
は、もう片方へ自動的に転送されます。質問(と回答)、新しい機能の提案、新し
いモジュールの発表などで、1日に数百通の投稿があります。メーリングリスト
のアーカイブは ‘https://mail.python.org/pipermail/’ で利用可能です。

投稿の前に、必ず *note よくある質問: 1c72. (FAQとも呼ばれます) のリスト
をチェックしてください。 FAQ は繰り返し取り上げられる多くの質問に答えて
います。あなたの問題に対する解決が既に含まれているかもしれません。

脚注
....

   ---------- Footnotes ----------

   (1) "Cheese Shop" は Monty Python のスケッチです: お客さんがチーズ屋
に入ったけれど、彼が求めたチーズはどれも無いとclerkが言った。


File: python.info,  Node: 対話入力編集と履歴置換,  Next: 浮動小数点演算、その問題と制限,  Prev: さあ何を？,  Up: Python チュートリアル

2.14 対話入力編集と履歴置換
===========================

いくつかのバージョンの Python インタプリタでは、Korn シェルや GNU Bash シ
ェルに見られる機能に似た、現在の入力行に対する編集機能や履歴置換機能をサ
ポートしています。この機能は様々な編集スタイルをサポートしている、GNU
Readline(1) ライブラリを使って実装されています。このライブラリには独自の
ドキュメントがあり、ここでそれを繰り返すつもりはありません。

* Menu:

* タブ補完と履歴編集::
* 対話的インタープリタの代替::

   ---------- Footnotes ----------

   (1) https://tiswww.case.edu/php/chet/readline/rltop.html


File: python.info,  Node: タブ補完と履歴編集,  Next: 対話的インタープリタの代替,  Up: 対話入力編集と履歴置換

2.14.1 タブ補完と履歴編集
-------------------------

変数とモジュール名の補完はインタプリタの起動時に *note
自動的に有効化されます: f96. 。 従って ‘Tab’ キーは補完機能を呼び出し、
Python の文の名前、現在のローカル変数、および利用可能なモジュール名を検
索します。 ‘string.a’ のようなドットで区切られた式については、最後の
‘'.'’ までの式を評価し、結果として得られたオブジェクトの属性から補完候補
を示します。 *note __getattr__(): 49f. メソッドを持ったオブジェクトが式
に含まれている場合、 *note __getattr__(): 49f. がアプリケーション定義の
コードを実行するかもしれないので注意してください。デフォルトの設定ではあ
なたのユーザーディレクトリの ‘.python_history’ という名前のファイルに履
歴を保存します。 履歴は次回の対話的なインタプリタのセッションで再び利用
することができます。


File: python.info,  Node: 対話的インタープリタの代替,  Prev: タブ補完と履歴編集,  Up: 対話入力編集と履歴置換

2.14.2 対話的インタープリタの代替
---------------------------------

この機能は、初期の版のインタープリタに比べれば大きな進歩です。とはいえ、
まだいくつかの要望が残されています。例えば、行を継続するときに正しいイン
デントが提示されたら快適でしょう (パーサは次の行でインデントトークンが必
要かどうかを知っています)。補完機構がインタープリタのシンボルテーブルを
使ってもよいかもしれません。括弧やクォートなどの対応をチェックする (ある
いは指示する) コマンドも有用でしょう。

より優れた対話的インタープリタの代替の一つに IPython(1) があります。この
インタープリタは、様々なところで使われていて、タブ補完、オブジェクト探索
や先進的な履歴管理といった機能を持っています。他のアプリケーションにカス
タマイズされたり、組込まれこともあります。別の優れたインタラクティブ環境
としては bpython(2) があります。

   ---------- Footnotes ----------

   (1) https://ipython.org/

   (2) https://bpython-interpreter.org/


File: python.info,  Node: 浮動小数点演算、その問題と制限,  Next: 付録,  Prev: 対話入力編集と履歴置換,  Up: Python チュートリアル

2.15 浮動小数点演算、その問題と制限
===================================

浮動小数点数はコンピューターのハードウェア上は2進数(binary)の分数で表さ
れます。 たとえば、'10進数' の分数では ‘0.625’ は 6/10 + 2/100 + 5/1000
という値を持ち、'2進数' の分数では ‘0.101’ は 1/2 + 0/4 + 1/8 という値を
持ちます。 この2つの分数はまったく同じ値を持ち、唯一異なる点は1つ目が
10進数の分数で書かれており、2つ目は2進数の分数で書かれているということで
す。

残念なことに、ほとんどの小数は 2 進法の分数として正確に表わすことができ
ません。その結果、一般に、入力した 10 進の浮動小数点数は、 2 進法の浮動
小数点数で近似された後、実際にマシンに記憶されます。

最初は基数 10 を使うと問題を簡単に理解できます。分数 1/3 を考えてみまし
ょう。分数 1/3 は、基数 10 の分数として、以下のように近似することができ
ます:

     0.3

さらに正確な近似は、

     0.33

さらに正確な近似は、

     0.333

となり、以後同様です。何個桁数を増やして書こうが、結果は決して厳密な 1/3
にはなりません。しかし、少しづつ正確な近似にはなっていくでしょう。

同様に、基数を 2 とした表現で何桁使おうとも、10 進数の 0.1 は基数を 2 と
した小数で正確に表現することはできません。基数 2 では、1/10 は循環小数
(repeating fraction) となります

     0.0001100110011001100110011001100110011001100110011...

どこか有限の桁で止めると、近似値を得ることになります。近年の殆どのコンピ
ュータでは float 型は、最上位ビットから数えて最初の 53 ビットを分子、2 の
冪乗を分母とした、二進小数で近似されます。1/10 の場合は、二進小数は
‘3602879701896397 / 2 ** 55’ となります。これは、1/10 に近いですが、厳密
に同じ値ではありません。

値が表示される方法のために、ほとんどのユーザは、近似に気づきません。
Python はマシンに格納されている二進近似値の10進小数での近似値を表示する
ので、格納されている値が元の10進小数の近似値でしか無いことを忘れがちです
。ほとんどのマシンで、もし Python が2進数で近似された 0.1 の近似値をその
まま10進数で表示していたら、その結果は次のようになったでしょう:

     >>> 0.1
     0.1000000000000000055511151231257827021181583404541015625

これは、ほとんどの人が必要と感じるよりも多すぎる桁数です。なので、Python
は丸めた値を表示することで、桁数を扱いやすい範囲にとどめます:

     >>> 1 / 10
     0.1

表示された結果が正確に 1/10 であるように見えたとしても、実際に格納されて
いる値は最も近く表現できる二進小数であるということだけは覚えておいてくだ
さい。

幾つかの異なる10進数の値が、同じ2進有理数の近似値を共有しています。例え
ば、‘0.1’ と ‘0.10000000000000001’ と
‘0.1000000000000000055511151231257827021181583404541015625’ はどれも
‘3602879701896397 / 2 ** 55’ に近似されます。同じ近似値を共有しているの
で、どの10進数の値も ‘eval(repr(x)) == x’ という条件を満たしたまま同じよ
うに表示されます。

昔の Python は、プロンプトと *note repr(): 7c8. ビルトイン関数は 17 桁の
有効数字を持つ ‘0.10000000000000001’ のような10進数の値を選んで表示して
いました。 Python 3.1 からは、ほとんどの場面で ‘0.1’ のような最も短い桁
数の10進数の値を選ぶようになりました。

この動作は2進数の浮動小数点にとってはごく自然なものです。これは Python の
バグではありませんし、あなたのコードのバグでもありません。ハードウェアの
浮動小数点演算をサポートしている全ての言語で同じ種類の問題を見つけること
ができます (いくつかの言語ではデフォルトの、あるいはどの出力モードを選ん
でも、この差を '表示' しないかもしれませんが)。

よりよい出力のために、文字列フォーマットを利用して有効桁数を制限した10進
数表現を得ることができます:

     >>> format(math.pi, '.12g')  # give 12 significant digits
     '3.14159265359'

     >>> format(math.pi, '.2f')   # give 2 digits after the point
     '3.14'

     >>> repr(math.pi)
     '3.141592653589793'

これが、実際のコンピューター上の値の '表示' を丸めているだけの、いわば錯
覚だということを認識しておいてください。

もう一つの錯覚を紹介します。例えば、0.1 が正確には 1/10 ではないために、
それを3回足した値もまた正確には 0.3 ではありません:

     >>> 0.1 + 0.1 + 0.1 == 0.3
     False

0.1 はこれ以上 1/10 に近くなることができない値で、 0.3 もまた 3/10 に一
番近い値なので、 *note round(): 12a8. 関数を使って計算前に丸めを行なって
も意味がありません:

     >>> round(0.1, 1) + round(0.1, 1) + round(0.1, 1) == round(0.3, 1)
     False

数値を意図した正確な値に近づけることはできませんが、 *note
math.isclose(): d7d. 関数は不正確な値を比べるのに便利です:

     >>> math.isclose(0.1 + 0.1 + 0.1, 0.3)
     True

あるいは、 *note round(): 12a8. 関数を粗い近似値比較に使うこともできます
:

     >>> round(math.pi, ndigits=2) == round(22 / 7, ndigits=2)
     True

このように2進数の浮動小数点の演算には多くの驚きがあります。「0.1」の問題
について詳しい説明は、「表現エラー」セクションで行います。2進数の浮動小
数点の仕組みと、実際によく遭遇する問題各種についての分かりやすい概要は、
Examples of Floating Point Problems(1) を参照してください。その他よくあ
る驚きの より詳細な説明は The Perils of Floating Point(2) も参照してくだ
さい。

究極的にいうと、"容易な答えはありません"。ですが、浮動小数点数のことを過
度に警戒しないでください！ Python の float 型操作におけるエラーは浮動小
数点処理ハードウェアから受けついたものであり、ほとんどのマシン上では一つ
の演算あたり高々 2**53 分の 1 です。この誤差はほとんどの作業で充分以上の
ものですが、浮動小数点演算は 10 進の演算ではなく、浮動小数点の演算を新た
に行うと、新たな丸め誤差の影響を受けることを心にとどめておいてください。

異常なケースが存在する一方で、普段の浮動小数点演算の利用では、単に最終的
な結果の値を必要な 10 進の桁数に丸めて表示するのなら、最終的には期待通り
の結果を得ることになるでしょう。たいては *note str(): 418. で十分ですが
、きめ細かな制御をしたければ、 *note 書式指定文字列の文法: 1358. にある
*note str.format(): 5ed. メソッドのフォーマット仕様を参照してください。

正確な10進数表現が必要となるような場合には、 *note decimal: 2e. モジュー
ルを利用してみてください。このモジュールは会計アプリケーションや高精度の
計算が求められるアプリケーションに適した、10進数の計算を実装しています。

別の正確な計算方法として、 *note fractions: 53. モジュールが有理数に基づ
く計算を実装しています (1/3 のような数を正確に表すことができます)。

あなたが浮動小数点演算のヘビーユーザーなら、SciPy プロジェクトが提供して
いる NumPy パッケージやその他の数学用パッケージを調べてみるべきです。
<‘https://scipy.org’> を参照してください。

Python は '本当に' float の正確な値が必要なレアケースに対応するためのツ
ールを提供しています。 *note float.as_integer_ratio(): 1c7c. メソッドは
float の値を有理数として表現します:

     >>> x = 3.14159
     >>> x.as_integer_ratio()
     (3537115888337719, 1125899906842624)

この分数は正確なので、元の値を完全に復元することができます:

     >>> x == 3537115888337719 / 1125899906842624
     True

*note float.hex(): 1c7d. メソッドは float の値を16進数で表現します。この
値もコンピューターが持っている正確な値を表現できます:

     >>> x.hex()
     '0x1.921f9f01b866ep+1'

この正確な16進数表現はもとの float 値を正確に復元するために使うことがで
きます:

     >>> x == float.fromhex('0x1.921f9f01b866ep+1')
     True

この16進数表現は正確なので、値を (プラットフォームにも依存せず) バージョ
ンの異なるPython 間でやり取りしたり、他のこのフォーマットをサポートした
言語 (Java や C99 など) と正確にやり取りするのに利用することができます。

別の便利なツールとして、合計処理における精度のロスを緩和してくれる *note
sum(): 437. 関数があります。これは累計加算中の丸めに拡張精度を使います。
これにより、誤差が最終的な合計値に影響を与えるまで蓄積されなくなり、結果
が改善されます:

     >>> 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 == 1.0
     False
     >>> sum([0.1] * 10) == 1.0
     True

The *note math.fsum(): 137c. goes further and tracks all of the "lost
digits" as values are added onto a running total so that the result has
only a single rounding.  This is slower than *note sum(): 437. but will
be more accurate in uncommon cases where large magnitude inputs mostly
cancel each other out leaving a final sum near zero:

     >>> arr = [-0.10430216751806065, -266310978.67179024, 143401161448607.16,
     ...        -143401161400469.7, 266262841.31058735, -0.003244936839808227]
     >>> float(sum(map(Fraction, arr)))   # Exact summation with single rounding
     8.042173697819788e-13
     >>> math.fsum(arr)                   # Single rounding
     8.042173697819788e-13
     >>> sum(arr)                         # Multiple roundings in extended precision
     8.042178034628478e-13
     >>> total = 0.0
     >>> for x in arr:
     ...     total += x                   # Multiple roundings in standard precision
     ...
     >>> total                            # Straight addition has no correct digits!
     -0.0051575902860057365

* Menu:

* 表現エラー::

   ---------- Footnotes ----------

   (1) 
https://jvns.ca/blog/2023/01/13/examples-of-floating-point-problems/

   (2) http://www.indowsway.com/floatingpoint.htm


File: python.info,  Node: 表現エラー,  Up: 浮動小数点演算、その問題と制限

2.15.1 表現エラー
-----------------

この章では、"0.1" の例について詳細に説明し、このようなケースに対してどの
ようにすれば正確な分析を自分で行えるかを示します。ここでは、 2 進法表現
の浮動小数点数についての基礎的な知識があるものとして話を進めます。

表現エラー('Representation error')は、いくつかの (実際にはほとんどの) 10
進の小数が 2 進法 (基数 2)の分数として表現できないという事実に関係してい
ます。これは Python (あるいは Perl, C, C++, Java, Fortran.  およびその他
多く) が期待通りの正確な 10 進数を表示できない主要な理由です。

なぜそうなるのでしょう？ 1/10 は２進法の小数で厳密に表現できません。少な
くとも2000年以降、ほぼすべてのマシンは IEEE 754 2進数の浮動小数点演算を
用いており、ほぼすべてのプラットフォームでは Python の浮動小数点を IEEE
754 binary64 "倍精度 (double precision)" 値に対応付けます。 IEEE 754
binary64 値は 53 ビットの精度を持つため、計算機に入力を行おうとすると、
可能な限り 0.1 を最も近い値の分数に変換し、'J'/2**'N' の形式にしようと努
力します。'J' はちょうど 53 ビットの精度の整数です。

     1 / 10 ~= J / (2**N)

を書き直すと

     J ~= 2**N / 10

となります。 'J' は厳密に 53 ビットの精度を持っている (‘>= 2**52’ だが
‘< 2**53’ ) ことを思い出すと、 'N' として最適な値は 56 になります:

     >>> 2**52 <=  2**56 // 10  < 2**53
     True

すなわち、56 は 'J' をちょうど 53 ビットの精度のままに保つ 'N' の唯一の
値です。'J' の取りえる値はその商を丸めたものです:

     >>> q, r = divmod(2**56, 10)
     >>> r
     6

剰余が 10 の半分以上なので、最良の近似は切り上げて丸めたものになります。
:

     >>> q+1
     7205759403792794

従って、IEEE 754の倍精度における 1/10 の取りえる最良の近似は:

     7205759403792794 / 2 ** 56

分子と分母を2で割って分数を小さくします:

     3602879701896397 / 2 ** 55

丸めたときに切り上げたので、この値は実際には 1/10 より少し大きいことに注
目してください。 もし切り捨てをした場合は、商は 1/10 よりもわずかに小さ
くなります。どちらにしろ '厳密な' 1/10 ではありません！

つまり、計算機は 1/10 を "理解する" ことは決してありません。計算機が理解
できるのは、上記のような厳密な分数であり、IEEE 754 の倍精度浮動小数点数
で得られるもっともよい近似は以下になります:

     >>> 0.1 * 2 ** 55
     3602879701896397.0

この分数に 10**55 を掛ければ、55 桁の十進数の値を見ることができます:

     >>> 3602879701896397 * 10 ** 55 // 2 ** 55
     1000000000000000055511151231257827021181583404541015625

これは、計算機が記憶している正確な数値が、10 進数値
0.1000000000000000055511151231257827021181583404541015625 にほぼ等しいと
いうことです。多くの言語 (古いバージョンの Python を含む) では、完全な
10 進値を表示するのではなく、結果を有効数字 17 桁に丸めます:

     >>> format(0.1, '.17f')
     '0.10000000000000001'

*note fractions: 53. モジュールと *note decimal: 2e. モジュールを使うと
これらの計算を簡単に行えます:

     >>> from decimal import Decimal
     >>> from fractions import Fraction

     >>> Fraction.from_float(0.1)
     Fraction(3602879701896397, 36028797018963968)

     >>> (0.1).as_integer_ratio()
     (3602879701896397, 36028797018963968)

     >>> Decimal.from_float(0.1)
     Decimal('0.1000000000000000055511151231257827021181583404541015625')

     >>> format(Decimal.from_float(0.1), '.17')
     '0.10000000000000001'


File: python.info,  Node: 付録,  Prev: 浮動小数点演算、その問題と制限,  Up: Python チュートリアル

2.16 付録
=========

* Menu:

* 対話モード: 対話モード<2>.


File: python.info,  Node: 対話モード<2>,  Up: 付録

2.16.1 対話モード
-----------------

対話型の *note REPL: 150. は2種類あります。 クラシックな基本インタープリ
タは最低限の行制御機能を持つ全プラットフォームでサポートされています。

On Windows, or Unix-like systems with *note curses: 23. support, a new
interactive shell is used by default.  This one supports color,
multiline editing, history browsing, and paste mode.  To disable color,
see *note 色の制御: 151. for details.  Function keys provide some
additional functionality.  ‘F1’ enters the interactive help browser
*note pydoc: a3.  ‘F2’ allows for browsing command-line history with
neither output nor the *note >>>: 152. and *note ...: 153. prompts.
‘F3’ enters "paste mode", which makes pasting larger blocks of code
easier.  Press ‘F3’ to return to the regular prompt.

新しい対話型シェルでは、 ‘exit’ または ‘quit’ と打ってシェルを終えます。
これらのコマンドの後に呼び出し括弧を追加する必要はありません。

新しい対話型シェルを望まない場合は、環境変数 *note PYTHON_BASIC_REPL:
154. で無効にできます。

* Menu:

* エラー処理::
* 実行可能な Python スクリプト::
* 対話モード用の起動時実行ファイル::
* カスタマイズ用モジュール::


File: python.info,  Node: エラー処理,  Next: 実行可能な Python スクリプト,  Up: 対話モード<2>

2.16.1.1 エラー処理
...................

エラーが発生すると、インタープリタはエラーメッセージとスタックトレースを
表示します。対話モードでは、それから元のプロンプトに戻ります; ファイルか
ら実行した場合は、スタックトレースを表示してゼロ以外の終了ステータスで終
了します（*note try: 6b4. 文の *note except: 170. 節で処理された例外は、
ここでいうエラーにはあたりません。）一部のエラーは無条件に致命的であり、
ゼロ以外の終了ステータスで終了します; これは内部の不整合やある種のメモリ
不足の場合に適用されます。エラーメッセージは全て標準エラー出力に書き込ま
れます; これに対して、通常は実行した命令から出力される内容は標準出力に書
き込まれます。

割り込み文字 (interrupt character、普通は ‘Control-C’ か ‘Delete’) を一
次または二次プロンプトに対してタイプすると、入力が取り消されて一次プロン
プトに戻ります。 (1) コマンドの実行中に割り込み文字をタイプすると *note
KeyboardInterrupt: 99f. 例外が送出されます。この例外は *note try: 6b4. 文
で処理できます。

   ---------- Footnotes ----------

   (1) GNU Readline パッケージに関する問題のせいで妨げられることがありま
す。


File: python.info,  Node: 実行可能な Python スクリプト,  Next: 対話モード用の起動時実行ファイル,  Prev: エラー処理,  Up: 対話モード<2>

2.16.1.2 実行可能な Python スクリプト
.....................................

BSD 風の Unix システムでは、Python スクリプトはシェルスクリプトのように
直接実行可能にできます。これを行うには、以下の行

     #!/usr/bin/env python3

(ここではインタプリタがユーザの ‘PATH’ 上にあると仮定しています) をスク
リプトの先頭に置き、スクリプトファイルに実行可能モードを設定します。
‘#!’ はファイルの最初の２文字でなければなりません。プラットフォームによ
っては、この最初の行を終端する改行文字が Windows 形式 (‘'\r\n'’) ではな
く、 Unix形式(‘'\n'’)でなければならないことがあります。ハッシュまたはポ
ンド文字、すなわち ‘'#'’ は、Python ではコメントを書き始めるために使われ
ていることに注意してください。

‘chmod’ コマンドを使えば、スクリプトに実行モードや実行権限を与えることが
できます。

     $ chmod +x myscript.py

Windows では、"実行モード" のような概念はありません。Python のインストー
ラーは自動的に ‘.py’ ファイルを ‘python.exe’ に関連付けるので、Python フ
ァイルをダブルクリックするとそれをスクリプトとして実行します。‘.pyw’ 拡
張子も(訳注: ‘pythonw.exe’ に)関連付けられ、通常コンソールウィンドウを抑
制して実行します。


File: python.info,  Node: 対話モード用の起動時実行ファイル,  Next: カスタマイズ用モジュール,  Prev: 実行可能な Python スクリプト,  Up: 対話モード<2>

2.16.1.3 対話モード用の起動時実行ファイル
.........................................

Python を対話的に使うときには、インタプリタが起動する度に実行される何ら
かの標準的なコマンドがあると便利なことがよくあります。これを行うには、
*note PYTHONSTARTUP: f95. と呼ばれる環境変数を、インタプリタ起動時に実行
されるコマンドが入ったファイル名に設定します。この機能は Unix シェルの
‘.profile’ に似ています。

このファイルは対話セッションのときだけ読み出されます。 Python がコマンド
をスクリプトから読み出しているときや、 ‘/dev/tty’ がコマンドの入力元とし
て明示的に指定されている(この場合対話的セッションのように動作します) 'わ
けではない' 場合にはこのファイルは読み出されません。ファイル内のコマンド
は、対話的コマンドが実行される名前空間と同じ名前空間内で実行されます。こ
のため、ファイル内で定義されていたり import されたオブジェクトは、そのま
ま対話セッション内で使うことができます。また、このファイル内で ‘sys.ps1’
や ‘sys.ps2’ を変更して、プロンプトを変更することもできます。

もし現在のディレクトリから追加でスタートアップファイルを読み出したいのな
ら、グローバルのスタートアップファイルの中に ‘if
os.path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())’ のよ
うなプログラムを書くことができます。スクリプト中でスタートアップファイル
を使いたいのなら、以下のようにしてスクリプト中で明示的に実行しなければな
りません:

     import os
     filename = os.environ.get('PYTHONSTARTUP')
     if filename and os.path.isfile(filename):
         with open(filename) as fobj:
             startup_file = fobj.read()
         exec(startup_file)


File: python.info,  Node: カスタマイズ用モジュール,  Prev: 対話モード用の起動時実行ファイル,  Up: 対話モード<2>

2.16.1.4 カスタマイズ用モジュール
.................................

Python はユーザーが Python をカスタマイズするための2つのフック、
sitecustomize と usercustomize を提供しています。これがどのように動作し
ているかを知るには、まずはユーザーの site-packages ディレクトリの場所を
見つける必要があります。Python を起動して次のコードを実行してください:

     >>> import site
     >>> site.getusersitepackages()
     '/home/user/.local/lib/python3.x/site-packages'

‘usercustomize.py’ をそのディレクトリに作成して、そこでやりたいことをす
べて書くことができます。このファイルは自動インポートを無効にする *note
-s: 1353. オプションを使わない限り、全ての Python の起動時に実行されます
。

sitecustomize モジュールも同じように動作しますが、一般的にコンピューター
の管理者によって、グローバルの site-packages ディレクトリに作成され、
usercustomize より先にインポートされます。詳細は *note site: b5. モジュ
ールのドキュメントを参照してください。

脚注
....


File: python.info,  Node: Python のセットアップと利用,  Next: Python 言語リファレンス,  Prev: Python チュートリアル,  Up: Top

3 Python のセットアップと利用
*****************************

このドキュメントでは 異なるプラットフォームでのPython環境のセットアップ
の一般的な方法、インタプリタの起動とPythonでの作業を楽にする方法を説明し
ます。

* Menu:

* コマンドラインと環境::
* Unix プラットフォームで Python を使う::
* Python を構成する::
* Windows で Python を使う::
* Using Python on macOS::
* Using Python on Android::
* Using Python on iOS::
* エディタと IDE::


File: python.info,  Node: コマンドラインと環境,  Next: Unix プラットフォームで Python を使う,  Up: Python のセットアップと利用

3.1 コマンドラインと環境
========================

CPython インタプリタはコマンドラインと環境を読み取って様々な設定を行ない
ます。

'CPython 実装の詳細:' 他の実装のコマンドラインスキームは CPython とは異
なります。さらなる情報は *note 別のPythonの実装: 1c90. を参照してくださ
い。

* Menu:

* コマンドライン::
* 環境変数::


File: python.info,  Node: コマンドライン,  Next: 環境変数,  Up: コマンドラインと環境

3.1.1 コマンドライン
--------------------

Python を起動するとき、以下のうち任意のオプションを指定できます:

     python [-bBdEhiIOPqRsSuvVWx?] [-c command | -m module-name | script | - ] [args]

もちろん、もっとも一般的な利用方法は、単純にスクリプトを起動することです
:

     python myscript.py

* Menu:

* インターフェイスオプション::
* 一般オプション::
* その他のオプション::
* 色の制御::
* 使うべきでないオプション::


File: python.info,  Node: インターフェイスオプション,  Next: 一般オプション,  Up: コマンドライン

3.1.1.1 インターフェイスオプション
..................................

インタプリタのインターフェイスは UNIX シェルのものに似ていますが、より多
くの起動方法を提供しています:

   * When called with standard input connected to a tty device, it
     prompts for commands and executes them until an EOF (an end-of-file
     character, you can produce that with ‘Ctrl-D’ on UNIX or ‘Ctrl-Z,
     Enter’ on Windows) is read.  For more on interactive mode, see
     *note 対話モード: 155.

   * ファイル名引数か、標準入力としてファイルを渡された場合、そのファイ
     ルからスクリプトを読み込んで実行します。

   * ディレクトリ名を引数に受け取った場合、そのディレクトリから適切な名
     前のスクリプトファイルを読み込んで実行します。

   * ‘-c コマンド’ オプションを利用して起動された場合、 'コマンド' とし
     て渡された Python の文を実行します。 'コマンド' の部分には改行で区
     切られた複数行を指定することもできます。行の先頭の空白文字は Python
     文の重要要素です！

   * ‘-m モジュール名’ として Python モジュールパスにあるモジュールを指
     定された場合、そのモジュールをスクリプトとして実行します。

非インタラクティブモードでは、入力の全体が実行前にパースされます。

インタプリタによって消費されるオプションリストが終了したあと、継続する全
ての引数は *note sys.argv: 1236. に渡ります。 - ただし、添字 0 の先頭要
素(‘sys.argv[0]’) はプログラムのソース自体を示す文字列です。

 -- Option: -c <command>

     'command' 内の Python コードを実行します。 'command' は改行によって
     区切られた1行以上の文です。通常のモジュールのコードと同じく、行頭の
     空白文字は意味を持ちます。

     このオプションが指定された場合、 *note sys.argv: 1236. の最初の要素
     は ‘"-c"’ になり、カレントディレクトリが *note sys.path: 38e. の先
     頭に追加されます (そのディレクトリにあるモジュールをトップレベルモ
     ジュールとして import 出来るようになります)。

     引数 ‘command’ を指定して *note 監査イベント: 1825.
     ‘cpython.run_command’ を送出します。

 -- Option: -m <module-name>

     *note sys.path: 38e. から指定されたモジュール名のモジュールを探し、
     その内容を *note __main__: 1. モジュールとして実行します。

     引数は 'module' 名なので、拡張子 (‘.py’) を含めてはいけません。モジ
     ュール名は有効な Python の絶対モジュール名 (absolute module name) で
     あるべきですが、実装がそれを強制しているとは限りません (例えば、ハ
     イフンを名前に含める事を許可するかもしれません)。

     パッケージ名 (名前空間パッケージも含む) でも構いません。通常のモジ
     ュールの代わりにパッケージ名が与えられた場合、インタプリタは
     ‘<pkg>.__main__’ を main モジュールとして実行します。この挙動はスク
     リプト引数として渡されたディレクトリや zip ファイルをインタプリタが
     処理するのと意図的に同じにしています。

          注釈: このオプションは組み込みモジュールや C で書かれた拡張モ
          ジュールには利用できません。 Python モジュールファイルを持って
          いないからです。しかし、コンパイル済みのモジュールは、たとえ元
          のソースファイルがなくても利用可能です。

     このオプションが指定された場合、 *note sys.argv: 1236. の最初の要素
     はモジュールファイルのフルパスになります (モジュールファイルを検索
     している間、最初の要素は ‘"-m"’ に設定されます)。 *note -c: 5aa. オ
     プションと同様に、カレントディレクトリが *note sys.path: 38e. の先
     頭に追加されます。

     *note -I: 92c. option can be used to run the script in isolated
     mode where *note sys.path: 38e. contains neither the current
     directory nor the user's site-packages directory.  All ‘PYTHON*’
     environment variables are ignored, too.

     多くの標準ライブラリモジュールにはスクリプトとして実行された時のた
     めのコードがあります。例えば、 *note timeit: d8. モジュールは次のよ
     うに実行可能です:

          python -m timeit -s "setup here" "benchmarked code here"
          python -m timeit -h # for details

     引数 ‘module-name’ を指定して *note 監査イベント: 1825.
     ‘cpython.run_module’ を送出します。

     参考
     ....

     *note runpy.run_module(): 1777.

          Python コードで直接使える等価な機能

     PEP 338(1) - モジュールをスクリプトとして実行する

     バージョン 3.1 で変更: ‘__main__’ サブモジュールを実行するパッケー
     ジ名が提供されました。

     バージョン 3.4 で変更: 名前空間パッケージもサポートされました

 -- Describe: -

     標準入力 (*note sys.stdin: 507.) からコマンドを読み込みます。標準入
     力がターミナルだった場合、暗黙的に *note -i: 1484. オプションが指定
     されます。

     このオプションが指定された場合、 *note sys.argv: 1236. の最初の要素
     は ‘"-"’ で、カレントディレクトリが *note sys.path: 38e. の先頭に追
     加されます。

     引数無しで *note 監査イベント: 1825. ‘cpython.run_stdin’ を送出しま
     す。

 -- Describe: <script>

     'script' 内の Python コードを実行します。 'script' は、Python ファ
     イル、 ‘__main__.py’ ファイルがあるディレクトリ、 ‘__main__.py’ フ
     ァイルがある zip ファイルのいずれかの、ファイルシステム上の (絶対ま
     たは相対) パスでなければなりません。

     このオプションが指定された場合、 *note sys.argv: 1236. の最初の要素
     はコマンドラインで指定されたスクリプト名になります。

     スクリプト名が Python ファイルを直接指定していた場合、そのファイル
     を含むディレクトリが *note sys.path: 38e. の先頭に追加され、そのフ
     ァイルは *note __main__: 1. モジュールとして実行されます。

     スクリプト名がディレクトリか zip ファイルを指定していた場合、スクリ
     プト名が *note sys.path: 38e. に追加され、その中の ‘__main__.py’ フ
     ァイルが *note __main__: 1. モジュールとして実行されます。

     *note -I: 92c. option can be used to run the script in isolated
     mode where *note sys.path: 38e. contains neither the script's
     directory nor the user's site-packages directory.  All ‘PYTHON*’
     environment variables are ignored, too.

     引数 ‘filename’ を指定して *note 監査イベント: 1825.
     ‘cpython.run_file’ を送出します。

     参考
     ....

     *note runpy.run_path(): 166.

          Python コードで直接使える等価な機能

インターフェイスオプションが与えられなかった場合、*note -i: 1484. が暗黙
的に指定され、‘sys.argv[0]’ が空の文字列 (‘""’) になり、 現在のディレク
トリが *note sys.path: 38e. の先頭に追加されます。また、利用可能であれば
タブ補完と履歴編集が自動的に有効かされます (*note readline の設定: f96.
を参照してください)。

参考
....

*note インタプリタを起動する: 1b50.

バージョン 3.4 で変更: タブ補完と履歴の編集が自動的に有効化されます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0338/


File: python.info,  Node: 一般オプション,  Next: その他のオプション,  Prev: インターフェイスオプション,  Up: コマンドライン

3.1.1.2 一般オプション
......................

 -- Option: -?
 -- Option: -h
 -- Option: --help

     Print a short description of all command line options and
     corresponding environment variables and exit.

 -- Option: --help-env

     Print a short description of Python-specific environment variables
     and exit.

     Added in version 3.11.

 -- Option: --help-xoptions

     Print a description of implementation-specific *note -X: 15c.
     options and exit.

     Added in version 3.11.

 -- Option: --help-all

     Print complete usage information and exit.

     Added in version 3.11.

 -- Option: -V
 -- Option: --version

     Python のバージョン番号を表示して終了します。出力の例:

          Python 3.8.0b2+

     2つ指定すると、次のようにより多くのビルドの情報を表示します:

          Python 3.8.0b2+ (3.8:0c076caaa8, Apr 20 2019, 21:55:00)
          [GCC 6.2.0 20161005]

     Added in version 3.6: ‘-VV’ オプション。


File: python.info,  Node: その他のオプション,  Next: 色の制御,  Prev: 一般オプション,  Up: コマンドライン

3.1.1.3 その他のオプション
..........................

 -- Option: -b

     Issue a warning when converting *note bytes: 1a4. or *note
     bytearray: 508. to *note str: 418. without specifying encoding or
     comparing ‘bytes’ or ‘bytearray’ with ‘str’ or ‘bytes’ with *note
     int: 238.  Issue an error when the option is given twice (‘-bb’).

     バージョン 3.5 で変更: Affects also comparisons of *note bytes:
     1a4. with *note int: 238.

 -- Option: -B

     与えられた場合、Python はソースモジュールのインポート時に ‘.pyc’ フ
     ァイルの作成を試みません。 *note PYTHONDONTWRITEBYTECODE: 1376. 環
     境変数も参照してください。

 -- Option: --check-hash-based-pycs default|always|never

     Control the validation behavior of hash-based ‘.pyc’ files.  See
     *note キャッシュされたバイトコードの無効化: 5b6.  When set to
     ‘default’, checked and unchecked hash-based bytecode cache files
     are validated according to their default semantics.  When set to
     ‘always’, all hash-based ‘.pyc’ files, whether checked or
     unchecked, are validated against their corresponding source file.
     When set to ‘never’, hash-based ‘.pyc’ files are not validated
     against their corresponding source files.

     The semantics of timestamp-based ‘.pyc’ files are unaffected by
     this option.

 -- Option: -d

     Turn on parser debugging output (for expert only).  See also the
     *note PYTHONDEBUG: 1c9c. environment variable.

     This option requires a *note debug build of Python: 1da, otherwise
     it's ignored.

 -- Option: -E

     Ignore all ‘PYTHON*’ environment variables, e.g.  *note PYTHONPATH:
     fe8. and *note PYTHONHOME: 396, that might be set.

     See also the *note -P: 56e. and *note -I: 92c. (isolated) options.

 -- Option: -i

     最初の引数にスクリプトが指定された場合や *note -c: 5aa. オプション
     が利用された場合、 *note sys.stdin: 507. がターミナルに出力されない
     場合も含めて、スクリプトかコマンドを実行した後にインタラクティブモ
     ードに入ります。 *note PYTHONSTARTUP: f95. ファイルは読み込みません
     。

     このオプションはグローバル変数や、スクリプトが例外を発生させるとき
     にそのスタックトレースを調べるのに便利です。 *note PYTHONINSPECT:
     1483. も参照してください。

 -- Option: -I

     Python を隔離モードで実行します。*note -E: 92b.、*note -P: 56e.、お
     よび *note -s: 1353. オプションも暗黙的に指定されます。

     In isolated mode *note sys.path: 38e. contains neither the script's
     directory nor the user's site-packages directory.  All ‘PYTHON*’
     environment variables are ignored, too.  Further restrictions may
     be imposed to prevent the user from injecting malicious code.

     Added in version 3.4.

 -- Option: -O

     Remove assert statements and any code conditional on the value of
     *note __debug__: 7a5.  Augment the filename for compiled (*note
     bytecode: 16c.) files by adding ‘.opt-1’ before the ‘.pyc’
     extension (see PEP 488(1)).  See also *note PYTHONOPTIMIZE: 1c9d.

     バージョン 3.5 で変更: PEP 488(2) に従って ‘.pyc’ ファイル名を変更
     します。

 -- Option: -OO

     Do *note -O: d82. and also discard docstrings.  Augment the
     filename for compiled (*note bytecode: 16c.) files by adding
     ‘.opt-2’ before the ‘.pyc’ extension (see PEP 488(3)).

     バージョン 3.5 で変更: PEP 488(4) に従って ‘.pyc’ ファイル名を変更
     します。

 -- Option: -P

     Don't prepend a potentially unsafe path to *note sys.path: 38e.:

        * ‘python -m module’ command line: Don't prepend the current
          working directory.

        * ‘python script.py’ command line: Don't prepend the script's
          directory.  If it's a symbolic link, resolve symbolic links.

        * ‘python -c code’ and ‘python’ (REPL) command lines: Don't
          prepend an empty string, which means the current working
          directory.

     See also the *note PYTHONSAFEPATH: 56f. environment variable, and
     *note -E: 92b. and *note -I: 92c. (isolated) options.

     Added in version 3.11.

 -- Option: -q

     インタラクティブモードでも copyright とバージョンのメッセージを表示
     しません。

     Added in version 3.2.

 -- Option: -R

     Turn on hash randomization.  This option only has an effect if the
     *note PYTHONHASHSEED: 1052. environment variable is set to ‘0’,
     since hash randomization is enabled by default.

     On previous versions of Python, this option turns on hash
     randomization, so that the *note __hash__(): ac9. values of str and
     bytes objects are "salted" with an unpredictable random value.
     Although they remain constant within an individual Python process,
     they are not predictable between repeated invocations of Python.

     Hash randomization is intended to provide protection against a
     denial-of-service caused by carefully chosen inputs that exploit
     the worst case performance of a dict construction, 'O'('n'^2)
     complexity.  See ‘http://ocert.org/advisories/ocert-2011-003.html’
     for details.

     *note PYTHONHASHSEED: 1052. によってハッシュシードの固定値を秘密に
     することが出来ます。

     Added in version 3.2.3.

     バージョン 3.7 で変更: このオプションが無視されなくなりました.

 -- Option: -s

     *note ユーザのサイトパッケージのディレクトリ: 1c9f. を *note
     sys.path: 38e. に追加しません。

     See also *note PYTHONNOUSERSITE: 1354.

     参考
     ....

     PEP 370(5) - ユーザごとの ‘site-packages’ ディレクトリ

 -- Option: -S

     *note site: b5. モジュールの import と、そのモジュールが行なってい
     た site ごとの *note sys.path: 38e. への操作を無効にします。後で
     *note site: b5. を明示的に import しても、これらの操作は実行されま
     せん (実行したい場合は、 *note site.main(): 1ca0. を呼び出してくだ
     さい)。

 -- Option: -u

     Force the stdout and stderr streams to be unbuffered.  This option
     has no effect on the stdin stream.

     *note PYTHONUNBUFFERED: 1910. も参照してください。

     バージョン 3.7 で変更: The text layer of the stdout and stderr
     streams now is unbuffered.

 -- Option: -v

     モジュールが初期化されるたびにメッセージを出力し、それがどこ (ファ
     イル名やビルトインモジュール) からロードされたのかを表示します。 二
     回与えられた場合 (‘-vv’) は、モジュールを検索するときにチェックした
     ファイルごとにメッセージを出力します。また、終了時のモジュールクリ
     ーンアップに関する情報も提供します。

     バージョン 3.10 で変更: The *note site: b5. module reports the
     site-specific paths and ‘.pth’ files being processed.

     *note PYTHONVERBOSE: 1ca1. も参照してください。

 -- Option: -W arg

     警告制御。 Python の警告機構はデフォルトでは警告メッセージを *note
     sys.stderr: 907. に表示します。

     The simplest settings apply a particular action unconditionally to
     all warnings emitted by a process (even those that are otherwise
     ignored by default):

          -Wdefault  # Warn once per call location
          -Werror    # Convert to exceptions
          -Walways   # Warn every time
          -Wall      # Same as -Walways
          -Wmodule   # Warn once per calling module
          -Wonce     # Warn once per Python process
          -Wignore   # Never warn

     The action names can be abbreviated as desired and the interpreter
     will resolve them to the appropriate action name.  For example,
     ‘-Wi’ is the same as ‘-Wignore’.

     引数の完全形は次のようになります:

          action:message:category:module:lineno

     Empty fields match all values; trailing empty fields may be
     omitted.  For example ‘-W ignore::DeprecationWarning’ ignores all
     DeprecationWarning warnings.

     The 'action' field is as explained above but only applies to
     warnings that match the remaining fields.

     The 'message' field must match the whole warning message; this
     match is case-insensitive.

     The 'category' field matches the warning category (ex:
     ‘DeprecationWarning’).  This must be a class name; the match test
     whether the actual warning category of the message is a subclass of
     the specified warning category.

     The 'module' field matches the (fully qualified) module name; this
     match is case-sensitive.

     The 'lineno' field matches the line number, where zero matches all
     line numbers and is thus equivalent to an omitted line number.

     複数の *note -W: 896. オプションを指定することができます。警告が1つ
     以上のオプションとマッチしたときは、最後にマッチしたオプションのア
     クションが有効になります。不正な *note -W: 896. オプションは無視さ
     れます (最初の警告が発生したときに、不正なオプションに対する警告メ
     ッセージが表示されます)。

     Warnings can also be controlled using the *note PYTHONWARNINGS:
     b78. environment variable and from within a Python program using
     the *note warnings: fa. module.  For example, the *note
     warnings.filterwarnings(): 144e. function can be used to use a
     regular expression on the warning message.

     詳しくは *note 警告フィルタ: 897. と *note Describing Warning
     Filters: 1ca3. を参照してください。

 -- Option: -x

     Unix 以外の形式の ‘#!cmd’ を使うために、ソースの最初の行をスキップ
     します。これは、DOS専用のハックのみを目的としています。

 -- Option: -X

     様々な実装固有のオプションのために予約されています。現在のところ
     CPython は以下の値を定義しています:

        * ‘-X faulthandler’ to enable *note faulthandler: 4e.  See also
          *note PYTHONFAULTHANDLER: 1055.

          Added in version 3.3.

        * ‘-X showrefcount’ to output the total reference count and
          number of used memory blocks when the program finishes or
          after each statement in the interactive interpreter.  This
          only works on *note debug builds: 1da.

          Added in version 3.4.

        * ‘-X tracemalloc’ to start tracing Python memory allocations
          using the *note tracemalloc: e8. module.  By default, only the
          most recent frame is stored in a traceback of a trace.  Use
          ‘-X tracemalloc=NFRAME’ to start tracing with a traceback
          limit of 'NFRAME' frames.  See *note tracemalloc.start():
          1ca5. and *note PYTHONTRACEMALLOC: 1ca6. for more information.

          Added in version 3.4.

        * ‘-X int_max_str_digits’ configures the *note integer string
          conversion length limitation: 5bf.  See also *note
          PYTHONINTMAXSTRDIGITS: 1728.

          Added in version 3.11.

        * ‘-X importtime’ to show how long each import takes.  It shows
          module name, cumulative time (including nested imports) and
          self time (excluding nested imports).  Note that its output
          may be broken in multi-threaded application.  Typical usage is
          ‘python3 -X importtime -c 'import asyncio'’.  See also *note
          PYTHONPROFILEIMPORTTIME: ac3.

          Added in version 3.7.

        * ‘-X dev’: enable *note Python Development Mode: 1d9,
          introducing additional runtime checks that are too expensive
          to be enabled by default.  See also *note PYTHONDEVMODE: abb.

          Added in version 3.7.

        * ‘-X utf8’ enables the *note Python UTF-8 Mode: 622.  ‘-X
          utf8=0’ explicitly disables *note Python UTF-8 Mode: 622.
          (even when it would otherwise activate automatically).  See
          also *note PYTHONUTF8: aa6.

          Added in version 3.7.

        * ‘-X pycache_prefix=PATH’ enables writing ‘.pyc’ files to a
          parallel tree rooted at the given directory instead of to the
          code tree.  See also *note PYTHONPYCACHEPREFIX: 971.

          Added in version 3.8.

        * ‘-X warn_default_encoding’ issues a *note EncodingWarning:
          1ca7. when the locale-specific default encoding is used for
          opening files.  See also *note PYTHONWARNDEFAULTENCODING: 787.

          Added in version 3.10.

        * ‘-X no_debug_ranges’ disables the inclusion of the tables
          mapping extra location information (end line, start column
          offset and end column offset) to every instruction in code
          objects.  This is useful when smaller code objects and pyc
          files are desired as well as suppressing the extra visual
          location indicators when the interpreter displays tracebacks.
          See also *note PYTHONNODEBUGRANGES: 580.

          Added in version 3.11.

        * ‘-X frozen_modules’ determines whether or not frozen modules
          are ignored by the import machinery.  A value of ‘on’ means
          they get imported and ‘off’ means they are ignored.  The
          default is ‘on’ if this is an installed Python (the normal
          case).  If it's under development (running from the source
          tree) then the default is ‘off’.  Note that the
          ‘importlib_bootstrap’ and ‘importlib_bootstrap_external’
          frozen modules are always used, even if this flag is set to
          ‘off’.  See also *note PYTHON_FROZEN_MODULES: 173.

          Added in version 3.11.

        * ‘-X perf’ enables support for the Linux ‘perf’ profiler.  When
          this option is provided, the ‘perf’ profiler will be able to
          report Python calls.  This option is only available on some
          platforms and will do nothing if is not supported on the
          current system.  The default value is "off".  See also *note
          PYTHONPERFSUPPORT: 43b. and *note Python support for the Linux
          perf profiler: 174.

          Added in version 3.12.

        * ‘-X perf_jit’ enables support for the Linux ‘perf’ profiler
          with DWARF support.  When this option is provided, the ‘perf’
          profiler will be able to report Python calls using DWARF
          information.  This option is only available on some platforms
          and will do nothing if is not supported on the current system.
          The default value is "off".  See also *note
          PYTHON_PERF_JIT_SUPPORT: 175. and *note Python support for the
          Linux perf profiler: 174.

          Added in version 3.13.

        * ‘-X cpu_count=N’ overrides *note os.cpu_count(): 1a7, *note
          os.process_cpu_count(): 1a6, and *note
          multiprocessing.cpu_count(): f3c.  'n' must be greater than or
          equal to 1.  This option may be useful for users who need to
          limit CPU resources of a container system.  See also *note
          PYTHON_CPU_COUNT: 1f1.  If 'n' is ‘default’, nothing is
          overridden.

          Added in version 3.13.

        * ‘-X presite=PACKAGE.MODULE’ specifies a module that should be
          imported before the *note site: b5. module is executed and
          before the *note __main__: 1. module exists.  Therefore, the
          imported module isn't *note __main__: 1.  This can be used to
          execute code early during Python initialization.  Python needs
          to be *note built in debug mode: 1da. for this option to
          exist.  See also *note PYTHON_PRESITE: 1ca8.

          Added in version 3.13.

        * ‘-X gil=0,1’ forces the GIL to be disabled or enabled,
          respectively.  Setting to ‘0’ is only available in builds
          configured with *note -disable-gil: 15a.  See also *note
          PYTHON_GIL: 15b. and *note Free-threaded CPython: 125.

          Added in version 3.13.

     任意の値を渡し、 *note sys._xoptions: 1ca9. 辞書から取り出すことも
     出来ます。

     Added in version 3.2.

     バージョン 3.9 で変更: Removed the ‘-X showalloccount’ option.

     バージョン 3.10 で変更: Removed the ‘-X oldparser’ option.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0488/

   (2) https://peps.python.org/pep-0488/

   (3) https://peps.python.org/pep-0488/

   (4) https://peps.python.org/pep-0488/

   (5) https://peps.python.org/pep-0370/


File: python.info,  Node: 色の制御,  Next: 使うべきでないオプション,  Prev: その他のオプション,  Up: コマンドライン

3.1.1.4 色の制御
................

デフォルトでは、 Python インタープリターは、トレースバックの表示などの特
定の状況で、出力を色でハイライトするように構成されています。この振る舞い
は、異なる環境変数を設定することで制御できます。

環境変数 ‘TERM’ を ‘dumb’ に設定することで、色付けを無効にできます。

FORCE_COLOR(1) 環境変数が設定されている場合、 TERM の値にかかわらず、色
付けは有効になります。これは、ターミナルではないが ANSI エスケープシーケ
ンスを表示できる CI システムで有効です。

NO_COLOR(2) 環境変数が設定されている場合、 Python は出力のすべての色を無
効にします。これは ‘FORCE_COLOR’ よりも優先されます。

これらのすべての環境変数は、色の出力の制御のために他のツールにも使用され
ます。 Python インタープリターでのみ色の出力を制御するには、 *note
PYTHON_COLORS: 130. 環境変数を使用できます。この変数は、 ‘FORCE_COLOR’ よ
りも優先される ‘NO_COLOR’ よりも、さらに優先されます。

   ---------- Footnotes ----------

   (1) https://force-color.org/

   (2) https://no-color.org/


File: python.info,  Node: 使うべきでないオプション,  Prev: 色の制御,  Up: コマンドライン

3.1.1.5 使うべきでないオプション
................................

 -- Option: -J

     Jython(1) のために予約されています。

   ---------- Footnotes ----------

   (1) https://www.jython.org/


File: python.info,  Node: 環境変数,  Prev: コマンドライン,  Up: コマンドラインと環境

3.1.2 環境変数
--------------

以下の環境変数は Python の挙動に影響します。環境変数は -E や -I 以外のコ
マンドラインスイッチの前に処理されます。衝突したときにコマンドラインスイ
ッチが環境変数をオーバーライドするのは慣例です。

 -- 環境変数: PYTHONHOME

     標準 Python ライブラリの場所を変更します。デフォルトでは、ライブラ
     リは ‘`prefix'/lib/python`version'’ と
     ‘`exec_prefix'/lib/python`version'’ から検索されます。ここで、
     ‘`prefix'’ と ‘`exec_prefix'’ はインストール依存のディレクトリで、
     両方共デフォルトでは ‘/usr/local’ です。

     *note PYTHONHOME: 396. が1つのディレクトリに設定されている場合、そ
     の値は ‘`prefix'’ と ‘`exec_prefix'’ の両方を置き換えます。それらに
     別々の値を指定したい場合は、 *note PYTHONHOME: 396. を
     ‘`prefix':`exec_prefix'’ のように指定します。

 -- 環境変数: PYTHONPATH

     モジュールファイルのデフォルトの検索パスを追加します。この環境変数
     のフォーマットはシェルの ‘PATH’ と同じで、 *note os.pathsep: 1cae.
     (Unix ならコロン、 Windows ならセミコロン) で区切られた1つ以上のデ
     ィレクトリパスです。存在しないディレクトリは警告なしに無視されます
     。

     通常のディレクトリに加えて、 *note PYTHONPATH: fe8. のエントリはピ
     ュアPython モジュール(ソース形式でもコンパイルされた形式でも) を含
     む zip ファイルを参照することもできます。拡張モジュールは zip ファ
     イルの中から import することはできません。

     デフォルトの検索パスはインストール依存ですが、通常は
     ‘`prefix'/lib/python`version'’ で始まります。 (上の *note
     PYTHONHOME: 396. を参照してください。) これは '常に' *note
     PYTHONPATH: fe8. に追加されます。

     上の *note インターフェイスオプション: 1c93. で説明されているように
     、追加の検索パスディレクトリが *note PYTHONPATH: fe8. の手前に追加
     されます。検索パスは Python プログラムから *note sys.path: 38e. 変
     数として操作することができます。

 -- 環境変数: PYTHONSAFEPATH

     If this is set to a non-empty string, don't prepend a potentially
     unsafe path to *note sys.path: 38e.: see the *note -P: 56e. option
     for details.

     Added in version 3.11.

 -- 環境変数: PYTHONPLATLIBDIR

     If this is set to a non-empty string, it overrides the *note
     sys.platlibdir: 906. value.

     Added in version 3.9.

 -- 環境変数: PYTHONSTARTUP

     この変数が読み込み可能なファイル名の場合、対話モードで最初のプロン
     プトが表示される前にそのファイルの Python コマンドが実行されます。
     ファイル内で定義されているオブジェクトやインポートされたオブジェク
     トを対話セッションで修飾せずに使用するために、ファイルは対話的なコ
     マンドと同じ名前空間で実行されます。 このファイルの中で、プロンプト
     *note sys.ps1: 1caf. や *note sys.ps2: 1cb0.、ならびにフック *note
     sys.__interactivehook__: f94. も変更できます。

     Raises an *note auditing event: 1825. ‘cpython.run_startup’ with
     the filename as the argument when called on startup.

 -- 環境変数: PYTHONOPTIMIZE

     この変数に空でない文字列を設定するのは *note -O: d82. オプションを
     指定するのと等価です。整数を設定した場合、 *note -O: d82. を複数回
     指定したのと同じになります。

 -- 環境変数: PYTHONBREAKPOINT

     If this is set, it names a callable using dotted-path notation.
     The module containing the callable will be imported and then the
     callable will be run by the default implementation of *note
     sys.breakpointhook(): aa8. which itself is called by built-in *note
     breakpoint(): 215.  If not set, or set to the empty string, it is
     equivalent to the value "pdb.set_trace".  Setting this to the
     string "0" causes the default implementation of *note
     sys.breakpointhook(): aa8. to do nothing but return immediately.

     Added in version 3.7.

 -- 環境変数: PYTHONDEBUG

     この変数に空でない文字列を設定するのは *note -d: 1c9b. オプションを
     指定するのと等価です。整数を指定した場合、 *note -d: 1c9b. を複数回
     指定したのと同じになります。

     This environment variable requires a *note debug build of Python:
     1da, otherwise it's ignored.

 -- 環境変数: PYTHONINSPECT

     この変数に空でない文字列を設定するのは *note -i: 1484. オプションを
     指定するのと等価です。

     この変数は Python コードから *note os.environ: 118a. を使って変更し
     て、プログラム終了時のインスペクトモードを強制することができます。

     引数無しで *note 監査イベント: 1825. ‘cpython.run_stdin’ を送出しま
     す。

     バージョン 3.12.5 で変更: (also 3.11.10, 3.10.15, 3.9.20, and
     3.8.20) Emits audit events.

     バージョン 3.13 で変更: Uses PyREPL if possible, in which case
     *note PYTHONSTARTUP: f95. is also executed.  Emits audit events.

 -- 環境変数: PYTHONUNBUFFERED

     この変数に空でない文字列を設定するのは *note -u: 190f. オプションを
     指定するのと等価です。

 -- 環境変数: PYTHONVERBOSE

     この変数に空でない文字列を設定するのは *note -v: 13cc. オプションを
     指定するのと等価です。整数を設定した場合、 *note -v: 13cc. を複数回
     指定したのと同じになります。

 -- 環境変数: PYTHONCASEOK

     この環境変数が設定されている場合、 Python は *note import: 5ac. 文
     で大文字/小文字を区別しません。 これは Windows と macOS でのみ動作
     します。

 -- 環境変数: PYTHONDONTWRITEBYTECODE

     この変数に空でない文字列を設定した場合、 Python はソースモジュール
     のインポート時に ‘.pyc’ ファイルを作成しようとはしなくなります。
     *note -B: 1375. オプションを指定するのと等価です。

 -- 環境変数: PYTHONPYCACHEPREFIX

     If this is set, Python will write ‘.pyc’ files in a mirror
     directory tree at this path, instead of in ‘__pycache__’
     directories within the source tree.  This is equivalent to
     specifying the *note -X: 15c. ‘pycache_prefix=PATH’ option.

     Added in version 3.8.

 -- 環境変数: PYTHONHASHSEED

     この変数が設定されていない場合や ‘random’ に設定された場合、乱数値
     が str、bytes オブジェクトのハッシュのシードに使われます。

     *note PYTHONHASHSEED: 1052. が整数値に設定された場合、その値はハッ
     シュランダム化が扱う型の hash() 生成の固定シードに使われます。

     その目的は再現性のあるハッシュを可能にすることです。例えばインター
     プリタ自身の自己テストや Python プロセスのクラスタでハッシュ値を共
     有するのに用います。

     整数は [0,4294967295] の十進数でなければなりません。0 を指定すると
     ハッシュランダム化は無効化されます。

     Added in version 3.2.3.

 -- 環境変数: PYTHONINTMAXSTRDIGITS

     If this variable is set to an integer, it is used to configure the
     interpreter's global *note integer string conversion length
     limitation: 5bf.

     Added in version 3.11.

 -- 環境変数: PYTHONIOENCODING

     この変数がインタープリタ実行前に設定されていた場合、
     ‘encodingname:errorhandler’ という文法で標準入力/標準出力/標準エラ
     ー出力のエンコードを上書きします。 ‘encodingname’ と
     ‘:errorhandler’ の部分はどちらも任意で、*note str.encode(): 8a3. と
     同じ意味を持ちます。

     標準エラー出力の場合、‘:errorhandler’ の部分は無視されます; ハンド
     ラは常に ‘'backslashreplace'’ です。

     バージョン 3.4 で変更: ‘encodingname’ の部分が任意になりました。

     バージョン 3.6 で変更: On Windows, the encoding specified by this
     variable is ignored for interactive console buffers unless *note
     PYTHONLEGACYWINDOWSSTDIO: c29. is also specified.  Files and pipes
     redirected through the standard streams are not affected.

 -- 環境変数: PYTHONNOUSERSITE

     この環境変数が設定されている場合、 Python は *note ユーザ
     site-packages ディレクトリ: 1c9f. を *note sys.path: 38e. に追加し
     ません。

     参考
     ....

     PEP 370(1) - ユーザごとの ‘site-packages’ ディレクトリ

 -- 環境変数: PYTHONUSERBASE

     Defines the *note user base directory: 12eb, which is used to
     compute the path of the *note user site-packages directory: 1c9f.
     and *note installation paths: 1cb1. for ‘python -m pip install
     --user’.

     参考
     ....

     PEP 370(2) - ユーザごとの ‘site-packages’ ディレクトリ

 -- 環境変数: PYTHONEXECUTABLE

     この環境変数が設定された場合、 ‘sys.argv[0]’ に、C ランタイムから取
     得した値の代わりにこの環境変数の値が設定されます。macOS でのみ動作
     します。

 -- 環境変数: PYTHONWARNINGS

     This is equivalent to the *note -W: 896. option.  If set to a comma
     separated string, it is equivalent to specifying *note -W: 896.
     multiple times, with filters later in the list taking precedence
     over those earlier in the list.

     The simplest settings apply a particular action unconditionally to
     all warnings emitted by a process (even those that are otherwise
     ignored by default):

          PYTHONWARNINGS=default  # Warn once per call location
          PYTHONWARNINGS=error    # Convert to exceptions
          PYTHONWARNINGS=always   # Warn every time
          PYTHONWARNINGS=all      # Same as PYTHONWARNINGS=always
          PYTHONWARNINGS=module   # Warn once per calling module
          PYTHONWARNINGS=once     # Warn once per Python process
          PYTHONWARNINGS=ignore   # Never warn

     詳しくは *note 警告フィルタ: 897. と *note Describing Warning
     Filters: 1ca3. を参照してください。

 -- 環境変数: PYTHONFAULTHANDLER

     If this environment variable is set to a non-empty string, *note
     faulthandler.enable(): c6c. is called at startup: install a handler
     for *note SIGSEGV: 1cb3, *note SIGFPE: 1cb4, *note SIGABRT: 1cb5,
     *note SIGBUS: 1cb6. and *note SIGILL: 1cb7. signals to dump the
     Python traceback.  This is equivalent to *note -X: 15c.
     ‘faulthandler’ option.

     Added in version 3.3.

 -- 環境変数: PYTHONTRACEMALLOC

     If this environment variable is set to a non-empty string, start
     tracing Python memory allocations using the *note tracemalloc: e8.
     module.  The value of the variable is the maximum number of frames
     stored in a traceback of a trace.  For example,
     ‘PYTHONTRACEMALLOC=1’ stores only the most recent frame.  See the
     *note tracemalloc.start(): 1ca5. function for more information.
     This is equivalent to setting the *note -X: 15c. ‘tracemalloc’
     option.

     Added in version 3.4.

 -- 環境変数: PYTHONPROFILEIMPORTTIME

     If this environment variable is set to a non-empty string, Python
     will show how long each import takes.  This is equivalent to
     setting the *note -X: 15c. ‘importtime’ option.

     Added in version 3.7.

 -- 環境変数: PYTHONASYNCIODEBUG

     この環境変数が空でない文字列に設定された場合、*note asyncio: 8. モ
     ジュールの *note デバッグモード: 1cb9. が有効化されます。

     Added in version 3.4.

 -- 環境変数: PYTHONMALLOC

     Set the Python memory allocators and/or install debug hooks.

     Set the family of memory allocators used by Python:

        * ‘default’: use the *note default memory allocators: 1cba.

        * ‘malloc’: use the ‘malloc()’ function of the C library for all
          domains (*note PYMEM_DOMAIN_RAW: 1cbb, *note PYMEM_DOMAIN_MEM:
          c37, *note PYMEM_DOMAIN_OBJ: c35.).

        * ‘pymalloc’: use the *note pymalloc allocator: cdd. for *note
          PYMEM_DOMAIN_MEM: c37. and *note PYMEM_DOMAIN_OBJ: c35.
          domains and use the ‘malloc()’ function for the *note
          PYMEM_DOMAIN_RAW: 1cbb. domain.

        * ‘mimalloc’: use the *note mimalloc allocator: 1cbc. for *note
          PYMEM_DOMAIN_MEM: c37. and *note PYMEM_DOMAIN_OBJ: c35.
          domains and use the ‘malloc()’ function for the *note
          PYMEM_DOMAIN_RAW: 1cbb. domain.

     Install *note debug hooks: 1cbd.:

        * ‘debug’: install debug hooks on top of the *note default
          memory allocators: 1cba.

        * ‘malloc_debug’: same as ‘malloc’ but also install debug hooks.

        * ‘pymalloc_debug’: same as ‘pymalloc’ but also install debug
          hooks.

        * ‘mimalloc_debug’: same as ‘mimalloc’ but also install debug
          hooks.

     Added in version 3.6.

     バージョン 3.7 で変更: Added the ‘"default"’ allocator.

 -- 環境変数: PYTHONMALLOCSTATS

     空でない文字列に設定されると、Python は新たなオブジェクトアリーナが
     生成される時と、シャットダウン時に *note pymalloc メモリアロケータ:
     cdd. の統計情報を表示します。

     This variable is ignored if the *note PYTHONMALLOC: c32.
     environment variable is used to force the ‘malloc()’ allocator of
     the C library, or if Python is configured without ‘pymalloc’
     support.

     バージョン 3.6 で変更: This variable can now also be used on Python
     compiled in release mode.  It now has no effect if set to an empty
     string.

 -- 環境変数: PYTHONLEGACYWINDOWSFSENCODING

     If set to a non-empty string, the default *note filesystem encoding
     and error handler: 505. mode will revert to their pre-3.6 values of
     'mbcs' and 'replace', respectively.  Otherwise, the new defaults
     'utf-8' and 'surrogatepass' are used.

     This may also be enabled at runtime with *note
     sys._enablelegacywindowsfsencoding(): 28e.

     *note Availability: 1cbe.: Windows.

     Added in version 3.6: より詳しくは PEP 529(3) を参照してください。

 -- 環境変数: PYTHONLEGACYWINDOWSSTDIO

     If set to a non-empty string, does not use the new console reader
     and writer.  This means that Unicode characters will be encoded
     according to the active console code page, rather than using utf-8.

     This variable is ignored if the standard streams are redirected (to
     files or pipes) rather than referring to console buffers.

     *note Availability: 1cbe.: Windows.

     Added in version 3.6.

 -- 環境変数: PYTHONCOERCECLOCALE

     If set to the value ‘0’, causes the main Python command line
     application to skip coercing the legacy ASCII-based C and POSIX
     locales to a more capable UTF-8 based alternative.

     If this variable is 'not' set (or is set to a value other than
     ‘0’), the ‘LC_ALL’ locale override environment variable is also not
     set, and the current locale reported for the ‘LC_CTYPE’ category is
     either the default ‘C’ locale, or else the explicitly ASCII-based
     ‘POSIX’ locale, then the Python CLI will attempt to configure the
     following locales for the ‘LC_CTYPE’ category in the order listed
     before loading the interpreter runtime:

        * ‘C.UTF-8’

        * ‘C.utf8’

        * ‘UTF-8’

     If setting one of these locale categories succeeds, then the
     ‘LC_CTYPE’ environment variable will also be set accordingly in the
     current process environment before the Python runtime is
     initialized.  This ensures that in addition to being seen by both
     the interpreter itself and other locale-aware components running in
     the same process (such as the GNU ‘readline’ library), the updated
     setting is also seen in subprocesses (regardless of whether or not
     those processes are running a Python interpreter), as well as in
     operations that query the environment rather than the current C
     locale (such as Python's own *note locale.getdefaultlocale():
     2bb.).

     Configuring one of these locales (either explicitly or via the
     above implicit locale coercion) automatically enables the
     ‘surrogateescape’ *note error handler: 1751. for *note sys.stdin:
     507. and *note sys.stdout: aa4. (*note sys.stderr: 907. continues
     to use ‘backslashreplace’ as it does in any other locale).  This
     stream handling behavior can be overridden using *note
     PYTHONIOENCODING: fd5. as usual.

     For debugging purposes, setting ‘PYTHONCOERCECLOCALE=warn’ will
     cause Python to emit warning messages on ‘stderr’ if either the
     locale coercion activates, or else if a locale that 'would' have
     triggered coercion is still active when the Python runtime is
     initialized.

     Also note that even when locale coercion is disabled, or when it
     fails to find a suitable target locale, *note PYTHONUTF8: aa6. will
     still activate by default in legacy ASCII-based locales.  Both
     features must be disabled in order to force the interpreter to use
     ‘ASCII’ instead of ‘UTF-8’ for system interfaces.

     *note Availability: 1cbe.: Unix.

     Added in version 3.7: より詳しくは PEP 538(4) を参照をしてください
     。

 -- 環境変数: PYTHONDEVMODE

     If this environment variable is set to a non-empty string, enable
     *note Python Development Mode: 1d9, introducing additional runtime
     checks that are too expensive to be enabled by default.  This is
     equivalent to setting the *note -X: 15c. ‘dev’ option.

     Added in version 3.7.

 -- 環境変数: PYTHONUTF8

     If set to ‘1’, enable the *note Python UTF-8 Mode: 622.

     If set to ‘0’, disable the *note Python UTF-8 Mode: 622.

     Setting any other non-empty string causes an error during
     interpreter initialisation.

     Added in version 3.7.

 -- 環境変数: PYTHONWARNDEFAULTENCODING

     If this environment variable is set to a non-empty string, issue a
     *note EncodingWarning: 1ca7. when the locale-specific default
     encoding is used.

     詳細は *note Opt-in EncodingWarning: 1cbf. を参照してください。

     Added in version 3.10.

 -- 環境変数: PYTHONNODEBUGRANGES

     If this variable is set, it disables the inclusion of the tables
     mapping extra location information (end line, start column offset
     and end column offset) to every instruction in code objects.  This
     is useful when smaller code objects and pyc files are desired as
     well as suppressing the extra visual location indicators when the
     interpreter displays tracebacks.

     Added in version 3.11.

 -- 環境変数: PYTHONPERFSUPPORT

     If this variable is set to a nonzero value, it enables support for
     the Linux ‘perf’ profiler so Python calls can be detected by it.

     If set to ‘0’, disable Linux ‘perf’ profiler support.

     See also the *note -X perf: 15c. command-line option and *note
     Python support for the Linux perf profiler: 174.

     Added in version 3.12.

 -- 環境変数: PYTHON_PERF_JIT_SUPPORT

     If this variable is set to a nonzero value, it enables support for
     the Linux ‘perf’ profiler so Python calls can be detected by it
     using DWARF information.

     If set to ‘0’, disable Linux ‘perf’ profiler support.

     See also the *note -X perf_jit: 15c. command-line option and *note
     Python support for the Linux perf profiler: 174.

     Added in version 3.13.

 -- 環境変数: PYTHON_CPU_COUNT

     If this variable is set to a positive integer, it overrides the
     return values of *note os.cpu_count(): 1a7. and *note
     os.process_cpu_count(): 1a6.

     See also the *note -X cpu_count: 15c. command-line option.

     Added in version 3.13.

 -- 環境変数: PYTHON_FROZEN_MODULES

     If this variable is set to ‘on’ or ‘off’, it determines whether or
     not frozen modules are ignored by the import machinery.  A value of
     ‘on’ means they get imported and ‘off’ means they are ignored.  The
     default is ‘on’ for non-debug builds (the normal case) and ‘off’
     for debug builds.  Note that the ‘importlib_bootstrap’ and
     ‘importlib_bootstrap_external’ frozen modules are always used, even
     if this flag is set to ‘off’.

     See also the *note -X frozen_modules: 15c. command-line option.

     Added in version 3.13.

 -- 環境変数: PYTHON_COLORS

     If this variable is set to ‘1’, the interpreter will colorize
     various kinds of output.  Setting it to ‘0’ deactivates this
     behavior.  See also *note 色の制御: 151.

     Added in version 3.13.

 -- 環境変数: PYTHON_BASIC_REPL

     If this variable is set to ‘1’, the interpreter will not attempt to
     load the Python-based *note REPL: 150. that requires *note curses:
     23. and *note readline: a8, and will instead use the traditional
     parser-based *note REPL: 150.

     Added in version 3.13.

 -- 環境変数: PYTHON_HISTORY

     This environment variable can be used to set the location of a
     ‘.python_history’ file (by default, it is ‘.python_history’ in the
     user's home directory).

     Added in version 3.13.

 -- 環境変数: PYTHON_GIL

     If this variable is set to ‘1’, the global interpreter lock (GIL)
     will be forced on.  Setting it to ‘0’ forces the GIL off (needs
     Python configured with the *note -disable-gil: 15a. build option).

     See also the *note -X gil: 15c. command-line option, which takes
     precedence over this variable, and *note Free-threaded CPython:
     125.

     Added in version 3.13.

* Menu:

* デバッグモード変数::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0370/

   (2) https://peps.python.org/pep-0370/

   (3) https://peps.python.org/pep-0529/

   (4) https://peps.python.org/pep-0538/


File: python.info,  Node: デバッグモード変数,  Up: 環境変数

3.1.2.1 デバッグモード変数
..........................

 -- 環境変数: PYTHONDUMPREFS

     設定された場合、 Python はインタプリタのシャットダウン後に残ってい
     るオブジェクトと参照カウントをダンプします。

     Needs Python configured with the *note -with-trace-refs: 36e. build
     option.

 -- 環境変数: PYTHONDUMPREFSFILE

     If set, Python will dump objects and reference counts still alive
     after shutting down the interpreter into a file under the path
     given as the value to this environment variable.

     Needs Python configured with the *note -with-trace-refs: 36e. build
     option.

     Added in version 3.11.

 -- 環境変数: PYTHON_PRESITE

     If this variable is set to a module, that module will be imported
     early in the interpreter lifecycle, before the *note site: b5.
     module is executed, and before the *note __main__: 1. module is
     created.  Therefore, the imported module is not treated as *note
     __main__: 1.

     This can be used to execute code early during Python
     initialization.

     To import a submodule, use ‘package.module’ as the value, like in
     an import statement.

     See also the *note -X presite: 15c. command-line option, which
     takes precedence over this variable.

     Needs Python configured with the *note -with-pydebug: 3fb. build
     option.

     Added in version 3.13.


File: python.info,  Node: Unix プラットフォームで Python を使う,  Next: Python を構成する,  Prev: コマンドラインと環境,  Up: Python のセットアップと利用

3.2 Unix プラットフォームで Python を使う
=========================================

* Menu:

* 最新バージョンの Python の取得とインストール::
* Python のビルド::
* Python に関係するパスとファイル::
* その他::
* Custom OpenSSL::


File: python.info,  Node: 最新バージョンの Python の取得とインストール,  Next: Python のビルド,  Up: Unix プラットフォームで Python を使う

3.2.1 最新バージョンの Python の取得とインストール
--------------------------------------------------

* Menu:

* Linux::
* FreeBSD と OpenBSD::


File: python.info,  Node: Linux,  Next: FreeBSD と OpenBSD,  Up: 最新バージョンの Python の取得とインストール

3.2.1.1 Linux
.............

Python comes preinstalled on most Linux distributions, and is available
as a package on all others.  However there are certain features you
might want to use that are not available on your distro's package.  You
can compile the latest version of Python from source.

In the event that the latest version of Python doesn't come preinstalled
and isn't in the repositories as well, you can make packages for your
own distro.  Have a look at the following links:

参考
....

‘https://www.debian.org/doc/manuals/maint-guide/first.en.html’

     Debian ユーザー向け

‘https://en.opensuse.org/Portal:Packaging’

     OpenSuse ユーザー向け

‘https://docs.fedoraproject.org/en-US/package-maintainers/Packaging_Tutorial_GNU_Hello/’

     Fedora ユーザー向け

‘https://slackbook.org/html/package-management-making-packages.html’

     Slackware ユーザー向け


File: python.info,  Node: FreeBSD と OpenBSD,  Prev: Linux,  Up: 最新バージョンの Python の取得とインストール

3.2.1.2 FreeBSD と OpenBSD
..........................

   * FreeBSD ユーザーが Python パッケージを追加するには次のようにしてく
     ださい:

          pkg install python3

   * OpenBSD ユーザーが Python パッケージを追加するには次のようにしてく
     ださい:

          pkg_add -r python

          pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/<insert your architecture here>/python-<version>.tgz

     例えば、i386 ユーザーが Python 2.5.1 を取得するには次のようにします
     :

          pkg_add ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/python-2.5.1p2.tgz


File: python.info,  Node: Python のビルド,  Next: Python に関係するパスとファイル,  Prev: 最新バージョンの Python の取得とインストール,  Up: Unix プラットフォームで Python を使う

3.2.2 Python のビルド
---------------------

CPython を自分でコンパイルしたい場合は、まず ソース(1) を入手します。 最
新リリース版のソースをダウンロード、あるいはソースリポジトリから新しく ク
ローン(2) を作成してください。(パッチの作成に貢献したい場合はクローンが
必要になるでしょう。)

ビルド手順は通常のコマンドで行います

     ./configure
     make
     make install

*note Configure のオプション: 1cc8. や特定の Unix プラットフォームにおけ
る注意点は Python ソースツリーのルートにある README.rst(3) に細かく記載
されています。

     警告: ‘make install’ は ‘python3’ バイナリを上書きまたはリンクを破
     壊してしまうかもしれません。そのため、‘make install’ の代わりに
     ‘`exec_prefix'/bin/python`version'’ のみインストールする ‘make
     altinstall’ が推奨されています。

   ---------- Footnotes ----------

   (1) https://www.python.org/downloads/source/

   (2) https://devguide.python.org/setup/#get-the-source-code

   (3) https://github.com/python/cpython/tree/3.13/README.rst


File: python.info,  Node: Python に関係するパスとファイル,  Next: その他,  Prev: Python のビルド,  Up: Unix プラットフォームで Python を使う

3.2.3 Python に関係するパスとファイル
-------------------------------------

これらはローカルインストールの慣例に応じて変化します; *note prefix:
1cca. と *note exec_prefix: 1ccb. はインストール状況に依存していて、GNU
ソフトウェアによって解釈されます; この二つは同じである場合があります。

例えば、ほとんどの Linux システムでは、両方のデフォルトが ‘/usr’ です。

ファイル/ディレクトリ                               意味
                                                    
---------------------------------------------------------------------------------------------------
                                                    
‘`exec_prefix'/bin/python3’                         インタプリタの推奨される場所
                                                    
                                                    
‘`prefix'/lib/python`version'’,                     標準モジュールを格納するディレクトリの、推奨
‘`exec_prefix'/lib/python`version'’                 される場所。
                                                    
                                                    
‘`prefix'/include/python`version'’,                 Python 拡張や Python の埋込みに必要となる
‘`exec_prefix'/include/python`version'’             include ファイルを格納するディレクトリの推奨
                                                    される場所。
                                                    


File: python.info,  Node: その他,  Next: Custom OpenSSL,  Prev: Python に関係するパスとファイル,  Up: Unix プラットフォームで Python を使う

3.2.4 その他
------------

Python スクリプトを Unix で簡単に使うためには、例えば次のようにしてスク
リプトを実行可能ファイルにし、

     $ chmod +x script

適切な shebang 行をスクリプトの先頭に置きます。たいていの場合良い方法は

     #!/usr/bin/env python3

で、 ‘PATH’ 全体から Python インタープリターを探します。しかし、いくつか
の Unix は ‘env’ コマンドを持たないので、インタープリターのパスを
‘/usr/bin/python3’ のようにハードコードしなければならないかもしれません
。

シェルコマンドを Python スクリプトから使うには、 *note subprocess: c1. モ
ジュールを参照してください。


File: python.info,  Node: Custom OpenSSL,  Prev: その他,  Up: Unix プラットフォームで Python を使う

3.2.5 Custom OpenSSL
--------------------

  1. To use your vendor's OpenSSL configuration and system trust store,
     locate the directory with ‘openssl.cnf’ file or symlink in ‘/etc’.
     On most distribution the file is either in ‘/etc/ssl’ or
     ‘/etc/pki/tls’.  The directory should also contain a ‘cert.pem’
     file and/or a ‘certs’ directory.

          $ find /etc/ -name openssl.cnf -printf "%h\n"
          /etc/ssl

  2. Download, build, and install OpenSSL. Make sure you use
     ‘install_sw’ and not ‘install’.  The ‘install_sw’ target does not
     override ‘openssl.cnf’.

          $ curl -O https://www.openssl.org/source/openssl-VERSION.tar.gz
          $ tar xzf openssl-VERSION
          $ pushd openssl-VERSION
          $ ./config \
              --prefix=/usr/local/custom-openssl \
              --libdir=lib \
              --openssldir=/etc/ssl
          $ make -j1 depend
          $ make -j8
          $ make install_sw
          $ popd

  3. Build Python with custom OpenSSL (see the configure
     ‘--with-openssl’ and ‘--with-openssl-rpath’ options)

          $ pushd python-3.x.x
          $ ./configure -C \
              --with-openssl=/usr/local/custom-openssl \
              --with-openssl-rpath=auto \
              --prefix=/usr/local/python-3.x.x
          $ make -j8
          $ make altinstall

     注釈: Patch releases of OpenSSL have a backwards compatible ABI.
     You don't need to recompile Python to update OpenSSL. It's
     sufficient to replace the custom OpenSSL installation with a newer
     version.


File: python.info,  Node: Python を構成する,  Next: Windows で Python を使う,  Prev: Unix プラットフォームで Python を使う,  Up: Python のセットアップと利用

3.3 Python を構成する
=====================

* Menu:

* ビルド要件::
* 生成されるファイル::
* Configureオプション::
* Python ビルドシステム::
* Compiler and linker flags::


File: python.info,  Node: ビルド要件,  Next: 生成されるファイル,  Up: Python を構成する

3.3.1 ビルド要件
----------------

CPython のビルドに必要な機能と最小バージョン:

   * C11(1) コンパイラ。 C11 オプション機能(2) は不要です。

   * Windows では、 Microsoft Visual Studio 2017 以降が必要です。

   * Support for IEEE 754(3) floating-point numbers and floating-point
     Not-a-Number (NaN)(4).

   * Support for threads.

   * OpenSSL 1.1.1 is the minimum version and OpenSSL 3.0.9 is the
     recommended minimum version for the *note ssl: bb. and *note
     hashlib: 5e. extension modules.

   * SQLite 3.15.2 for the *note sqlite3: ba. extension module.

   * Tcl/Tk 8.5.12 for the *note tkinter: d9. module.

   * Autoconf 2.71 and aclocal 1.16.5 are required to regenerate the
     ‘configure’ script.

バージョン 3.1 で変更: Tcl/Tk version 8.3.1 is now required.

バージョン 3.5 で変更: On Windows, Visual Studio 2015 or later is now
required.  Tcl/Tk version 8.4 is now required.

バージョン 3.6 で変更: Selected C99 features are now required, like
‘<stdint.h>’ and ‘static inline’ functions.

バージョン 3.7 で変更: Thread support and OpenSSL 1.0.2 are now
required.

バージョン 3.10 で変更: OpenSSL 1.1.1 is now required.  Require SQLite
3.7.15.

バージョン 3.11 で変更: C11 compiler, IEEE 754 and NaN support are now
required.  On Windows, Visual Studio 2017 or later is required.  Tcl/Tk
version 8.5.12 is now required for the *note tkinter: d9. module.

バージョン 3.13 で変更: Autoconf 2.71, aclocal 1.16.5 and SQLite 3.15.2
are now required.

See also PEP 7(5) "Style Guide for C Code" and PEP 11(6) "CPython
platform support".

   ---------- Footnotes ----------

   (1) https://en.cppreference.com/w/c/11

   (2) 
https://en.wikipedia.org/wiki/C11_(C_standard_revision)#Optional_features

   (3) https://en.wikipedia.org/wiki/IEEE_754

   (4) https://en.wikipedia.org/wiki/NaN#Floating_point

   (5) https://peps.python.org/pep-0007/

   (6) https://peps.python.org/pep-0011/


File: python.info,  Node: 生成されるファイル,  Next: Configureオプション,  Prev: ビルド要件,  Up: Python を構成する

3.3.2 生成されるファイル
------------------------

To reduce build dependencies, Python source code contains multiple
generated files.  Commands to regenerate all generated files:

     make regen-all
     make regen-stdlib-module-names
     make regen-limited-abi
     make regen-configure

The ‘Makefile.pre.in’ file documents generated files, their inputs, and
tools used to regenerate them.  Search for ‘regen-*’ make targets.

* Menu:

* 構成スクリプト::


File: python.info,  Node: 構成スクリプト,  Up: 生成されるファイル

3.3.2.1 構成スクリプト
......................

The ‘make regen-configure’ command regenerates the ‘aclocal.m4’ file and
the ‘configure’ script using the ‘Tools/build/regen-configure.sh’ shell
script which uses an Ubuntu container to get the same tools versions and
have a reproducible output.

The container is optional, the following command can be run locally:

     autoreconf -ivf -Werror

The generated files can change depending on the exact
‘autoconf-archive’, ‘aclocal’ and ‘pkg-config’ versions.


File: python.info,  Node: Configureオプション,  Next: Python ビルドシステム,  Prev: 生成されるファイル,  Up: Python を構成する

3.3.3 Configureオプション
-------------------------

List all ‘configure’ script options using:

     ./configure --help

Pythonのソース配布の中の ‘Misc/SpecialBuilds.txt’ も参照してください。

* Menu:

* 一般的なオプション::
* C コンパイラのオプション::
* リンカのオプション::
* サードパーティ依存関係のオプション::
* WebAssembly オプション::
* インストールオプション::
* パフォーマンスに関するオプション::
* Python Debug Build::
* Debug options::
* リンカのオプション: リンカのオプション<2>.
* Libraries options::
* Security Options::
* macOS のオプション::
* iOS のオプション::
* クロスコンパイルのオプション::


File: python.info,  Node: 一般的なオプション,  Next: C コンパイラのオプション,  Up: Configureオプション

3.3.3.1 一般的なオプション
..........................

 -- Option: --enable-loadable-sqlite-extensions

     Support loadable extensions in the ‘_sqlite’ extension module
     (default is no) of the *note sqlite3: ba. module.

     *note sqlite3: ba. モジュールの *note
     sqlite3.Connection.enable_load_extension(): 809. メソッドを参照して
     ください。

     Added in version 3.6.

 -- Option: --disable-ipv6

     IPv6サポートを無効にします(サポートされている場合はデフォルトで有効
     )、 *note socket: b8. モジュールを参照してください。

 -- Option: --enable-big-digits=[15|30]

     Python *note int: 238. の桁の大きさをビット単位で定義します: 15ビッ
     トまたは30ビットです。

     デフォルトでは、桁の大きさは30です。

     ‘PYLONG_BITS_IN_DIGIT’ を ‘15’ または ‘30’ に定義します。

     *note sys.int_info.bits_per_digit: 1264. を参照してください。

 -- Option: --with-suffix=SUFFIX

     Python の実行ファイルの接尾辞を 'SUFFIX' に設定します。

     デフォルトの接尾辞は、 Windows と macOS では ‘.exe’ ( ‘python.exe’
     実行ファイル)、 Emscripten node では ‘.js’ 、 Emscripten browser で
     は ‘.html’ 、 WASI では ‘.wasm’ 、その他のプラットフォームでは空文
     字列になります ( ‘python’ 実行ファイル)。

     バージョン 3.11 で変更: WASM プラットフォームのデフォルトの接頭辞は
     、 ‘.js’ 、 ‘.html’ 、 ‘.wasm’ のうちの1つです。

 -- Option: --with-tzpath=<list of absolute paths separated by pathsep>

     デフォルトのタイムゾーン検索パスを *note zoneinfo.TZPATH: 1cda. に
     設定します。*note zoneinfo: 11a. モジュールの *note Compile-time
     configuration: 1cdb. を参照してください。

     デフォルト:
     ‘/usr/share/zoneinfo:/usr/lib/zoneinfo:/usr/share/lib/zoneinfo:/etc/zoneinfo’

     *note os.pathsep: 1cae. パスセパレータを参照してください。

     Added in version 3.9.

 -- Option: --without-decimal-contextvar

     コルーチンローカルコンテキスト(デフォルト)ではなく、スレッドローカ
     ルコンテキストを使用して ‘_decimal’ 拡張モジュールをビルドします。
     *note decimal: 2e. モジュールを参照してください。

     *note decimal.HAVE_CONTEXTVAR: 1cdd. および *note contextvars: 1d.
     モジュールを参照してください。

     Added in version 3.9.

 -- Option: --with-dbmliborder=<list of backend names>

     *note dbm: 29. モジュールの DB バックエンドをチェックする順序をオー
     バーライドします。

     有効な値は、バックエンド名をコロン( ‘:’ )で区切った文字列です:

        * ‘ndbm’;

        * ‘gdbm’;

        * ‘bdb’。

 -- Option: --without-c-locale-coercion

     UTF-8 ベースのロケールへの C ロケールの強制を無効にします(デフォル
     トで有効)。

     ‘PY_COERCE_C_LOCALE’ マクロは定義しないでください。

     *note PYTHONCOERCECLOCALE: aa3. および PEP 538(1) を参照してくださ
     い。

 -- Option: --without-freelists

     Disable all freelists except the empty tuple singleton.

     Added in version 3.11.

 -- Option: --with-platlibdir=DIRNAME

     Python のライブラリディレクトリ名(デフォルトは ‘lib’ )。

     Fedora と SuSE は64ビットプラットフォームで ‘lib64’ を使用します。

     *note sys.platlibdir: 906. を参照してください。

     Added in version 3.9.

 -- Option: --with-wheel-pkg-dir=PATH

     *note ensurepip: 4b. モジュールが使用する wheel パッケージのディレ
     クトリです(デフォルトはなし)。

     Linux ディストリビューションのパッケージングポリシーの中には、依存
     関係をバンドルすることを推奨しているものがあります。例えば、 Fedora
     は wheel パッケージを ‘/usr/share/python-wheels/’ ディレクトリにイ
     ンストールし、 ‘ensurepip._bundled’ パッケージはインストールしませ
     ん。

     Added in version 3.10.

 -- Option: --with-pkg-config=[check|yes|no]

     configure がビルドの依存関係を検出するために ‘pkg-config’ を使用す
     るかどうかを設定します。

        * ‘check’ (デフォルト): ‘pkg-config’ はオプションです。

        * ‘yes’ : ‘pkg-config’ は必須です。

        * ‘no’ : ‘pkg-config’ が存在しても、 configure は使用しません。

     Added in version 3.11.

 -- Option: --enable-pystats

     Turn on internal Python performance statistics gathering.

     By default, statistics gathering is off.  Use ‘python3 -X pystats’
     command or set ‘PYTHONSTATS=1’ environment variable to turn on
     statistics gathering at Python startup.

     At Python exit, dump statistics if statistics gathering was on and
     not cleared.

     Effects:

        * Add *note -X pystats: 15c. command line option.

        * Add ‘PYTHONSTATS’ environment variable.

        * Define the ‘Py_STATS’ macro.

        * Add functions to the *note sys: c3. module:

             * ‘sys._stats_on()’: Turns on statistics gathering.

             * ‘sys._stats_off()’: Turns off statistics gathering.

             * ‘sys._stats_clear()’: Clears the statistics.

             * ‘sys._stats_dump()’: Dump statistics to file, and clears
               the statistics.

     The statistics will be dumped to a arbitrary (probably unique) file
     in ‘/tmp/py_stats/’ (Unix) or ‘C:\temp\py_stats\’ (Windows).  If
     that directory does not exist, results will be printed on stderr.

     統計情報を読むには ‘Tools/scripts/summarize_stats.py’ を使用してく
     ださい。

     Statistics:

        * Opcode:

             * Specialization: success, failure, hit, deferred, miss,
               deopt, failures;

             * Execution count;

             * Pair count.

        * Call:

             * Inlined Python calls;

             * PyEval calls;

             * Frames pushed;

             * Frame object created;

             * Eval calls: vector, generator, legacy, function
               VECTORCALL, build class, slot, function "ex", API,
               method.

        * Object:

             * incref and decref;

             * interpreter incref and decref;

             * allocations: all, 512 bytes, 4 kiB, big;

             * free;

             * to/from free lists;

             * dictionary materialized/dematerialized;

             * type cache;

             * optimization attempts;

             * optimization traces created/executed;

             * uops executed.

        * Garbage collector:

             * Garbage collections;

             * Objects visited;

             * Objects collected.

     Added in version 3.11.

 -- Option: --disable-gil

     Enables 'experimental' support for running Python without the *note
     global interpreter lock: 12e. (GIL): free threading build.

     Defines the ‘Py_GIL_DISABLED’ macro and adds ‘"t"’ to *note
     sys.abiflags: a32.

     See *note Free-threaded CPython: 125. for more detail.

     Added in version 3.13.

 -- Option: --enable-experimental-jit=[no|yes|yes-off|interpreter]

     Indicate how to integrate the *note JIT compiler: 126.

        * ‘no’ - build the interpreter without the JIT.

        * ‘yes’ - build the interpreter with the JIT.

        * ‘yes-off’ - build the interpreter with the JIT but disable it
          by default.

        * ‘interpreter’ - build the interpreter without the JIT, but
          with the tier 2 enabled interpreter.

     By convention, ‘--enable-experimental-jit’ is a shorthand for
     ‘--enable-experimental-jit=yes’.

     Added in version 3.13.

 -- Option: PKG_CONFIG

     Path to ‘pkg-config’ utility.

 -- Option: PKG_CONFIG_LIBDIR

 -- Option: PKG_CONFIG_PATH

     ‘pkg-config’ options.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0538/


File: python.info,  Node: C コンパイラのオプション,  Next: リンカのオプション,  Prev: 一般的なオプション,  Up: Configureオプション

3.3.3.2 C コンパイラのオプション
................................

 -- Option: CC

     C コンパイラのコマンド。

 -- Option: CFLAGS

     C コンパイラのフラグ。

 -- Option: CPP

     C プリプロセッサのコマンド。

 -- Option: CPPFLAGS

     C プリプロセッサのフラグ。 (‘-IINCLUDE_DIR’ など)


File: python.info,  Node: リンカのオプション,  Next: サードパーティ依存関係のオプション,  Prev: C コンパイラのオプション,  Up: Configureオプション

3.3.3.3 リンカのオプション
..........................

 -- Option: LDFLAGS

     リンカのフラグ。 (‘-LLIBRARY_DIRECTORY’ など)

 -- Option: LIBS

     リンカに渡すライブラリ。 (‘-lLIBRARY’ など)

 -- Option: MACHDEP

     マシン依存のライブラリファイルの名前。


File: python.info,  Node: サードパーティ依存関係のオプション,  Next: WebAssembly オプション,  Prev: リンカのオプション,  Up: Configureオプション

3.3.3.4 サードパーティ依存関係のオプション
..........................................

Added in version 3.11.

 -- Option: BZIP2_CFLAGS

 -- Option: BZIP2_LIBS

     C compiler and linker flags to link Python to ‘libbz2’, used by
     *note bz2: f. module, overriding ‘pkg-config’.

 -- Option: CURSES_CFLAGS

 -- Option: CURSES_LIBS

     C compiler and linker flags for ‘libncurses’ or ‘libncursesw’, used
     by *note curses: 23. module, overriding ‘pkg-config’.

 -- Option: GDBM_CFLAGS

 -- Option: GDBM_LIBS

     C compiler and linker flags for ‘gdbm’.

 -- Option: LIBB2_CFLAGS

 -- Option: LIBB2_LIBS

     C compiler and linker flags for ‘libb2’ (*note BLAKE2: 1cf9.), used
     by *note hashlib: 5e. module, overriding ‘pkg-config’.

 -- Option: LIBEDIT_CFLAGS

 -- Option: LIBEDIT_LIBS

     C compiler and linker flags for ‘libedit’, used by *note readline:
     a8. module, overriding ‘pkg-config’.

 -- Option: LIBFFI_CFLAGS

 -- Option: LIBFFI_LIBS

     C compiler and linker flags for ‘libffi’, used by *note ctypes: 22.
     module, overriding ‘pkg-config’.

 -- Option: LIBMPDEC_CFLAGS

 -- Option: LIBMPDEC_LIBS

     C compiler and linker flags for ‘libmpdec’, used by *note decimal:
     2e. module, overriding ‘pkg-config’.

          注釈: These environment variables have no effect unless *note
          -with-system-libmpdec: 3eb. is specified.

 -- Option: LIBLZMA_CFLAGS

 -- Option: LIBLZMA_LIBS

     C compiler and linker flags for ‘liblzma’, used by *note lzma: 7e.
     module, overriding ‘pkg-config’.

 -- Option: LIBREADLINE_CFLAGS

 -- Option: LIBREADLINE_LIBS

     C compiler and linker flags for ‘libreadline’, used by *note
     readline: a8. module, overriding ‘pkg-config’.

 -- Option: LIBSQLITE3_CFLAGS

 -- Option: LIBSQLITE3_LIBS

     C compiler and linker flags for ‘libsqlite3’, used by *note
     sqlite3: ba. module, overriding ‘pkg-config’.

 -- Option: LIBUUID_CFLAGS

 -- Option: LIBUUID_LIBS

     C compiler and linker flags for ‘libuuid’, used by *note uuid: f8.
     module, overriding ‘pkg-config’.

 -- Option: PANEL_CFLAGS

 -- Option: PANEL_LIBS

     C compiler and linker flags for PANEL, overriding ‘pkg-config’.

     C compiler and linker flags for ‘libpanel’ or ‘libpanelw’, used by
     *note curses.panel: 25. module, overriding ‘pkg-config’.

 -- Option: TCLTK_CFLAGS

 -- Option: TCLTK_LIBS

     C compiler and linker flags for TCLTK, overriding ‘pkg-config’.

 -- Option: ZLIB_CFLAGS

 -- Option: ZLIB_LIBS

     C compiler and linker flags for ‘libzlib’, used by *note gzip: 5d.
     module, overriding ‘pkg-config’.


File: python.info,  Node: WebAssembly オプション,  Next: インストールオプション,  Prev: サードパーティ依存関係のオプション,  Up: Configureオプション

3.3.3.5 WebAssembly オプション
..............................

 -- Option: --with-emscripten-target=[browser|node]

     ‘wasm32-emscripten’ のビルドフレーバーを設定します。

        * ‘browser’ (デフォルト): 最小限の stdlib 、デフォルトの MEMFS を
          プリロードします。

        * ‘node’: NODERAWFS と pthread をサポートします。

     Added in version 3.11.

 -- Option: --enable-wasm-dynamic-linking

     WASM のダイナミックリンクサポートをオンにします。

     ダイナミックリンクにより ‘dlopen’ が可能になります。デッドコードの
     排除や機能追加に制限があるため、実行ファイルのファイルサイズが大き
     くなります。

     Added in version 3.11.

 -- Option: --enable-wasm-pthreads

     WASM の pthreads サポートをオンにします。

     Added in version 3.11.


File: python.info,  Node: インストールオプション,  Next: パフォーマンスに関するオプション,  Prev: WebAssembly オプション,  Up: Configureオプション

3.3.3.6 インストールオプション
..............................

 -- Option: --prefix=PREFIX

     アーキテクチャに依存しないファイルを PREFIX にインストールします。
     Unix の場合、デフォルトは ‘/usr/local’ です。

     この値は、実行時に *note sys.prefix: 390. を使って取得することがで
     きます。

     例として、 ‘--prefix="$HOME/.local/"’ を使用すると、 Python をその
     ホームディレクトリにインストールすることができます。

 -- Option: --exec-prefix=EPREFIX

     アーキテクチャ依存のファイルを EPREFIX にインストールします。デフォ
     ルトは *note -prefix: 1cca. です。

     この値は、実行時に *note sys.exec_prefix: 38c. を使って取得すること
     ができます。

 -- Option: --disable-test-modules

     *note test: cb. パッケージや ‘_testcapi’ 拡張モジュール(デフォルト
     でビルド、インストールされます)のようなテストモジュールをビルド、イ
     ンストールしないようにします。

     Added in version 3.10.

 -- Option: --with-ensurepip=[upgrade|install|no]

     Python のインストール時に実行される *note ensurepip: 4b. コマンドを
     選択します:

        * ‘upgrade’ (デフォルト): ‘python -m ensurepip --altinstall
          --upgrade’ コマンドを実行します。

        * ‘install’: ‘python -m ensurepip --altinstall’ コマンドを実行し
          ます。

        * ‘no’: ensurepip を実行しない;

     Added in version 3.6.


File: python.info,  Node: パフォーマンスに関するオプション,  Next: Python Debug Build,  Prev: インストールオプション,  Up: Configureオプション

3.3.3.7 パフォーマンスに関するオプション
........................................

Configuring Python using ‘--enable-optimizations --with-lto’ (PGO + LTO)
is recommended for best performance.  The experimental ‘--enable-bolt’
flag can also be used to improve performance.

 -- Option: --enable-optimizations

     *note PROFILE_TASK: 1676. を使用して Profile Guided Optimization
     (PGO) を有効にします(デフォルトでは無効です)。

     Cコンパイラの Clang では、 PGO のために ‘llvm-profdata’ プログラム
     が必要です。macOS では、 GCC もこれを必要とします: GCC は macOS の
     Clang のエイリアスにすぎません。

     Disable also semantic interposition in libpython if
     ‘--enable-shared’ and GCC is used: add
     ‘-fno-semantic-interposition’ to the compiler and linker flags.

          注釈: During the build, you may encounter compiler warnings
          about profile data not being available for some source files.
          These warnings are harmless, as only a subset of the code is
          exercised during profile data acquisition.  To disable these
          warnings on Clang, manually suppress them by adding
          ‘-Wno-profile-instr-unprofiled’ to *note CFLAGS: 145c.

     Added in version 3.6.

     バージョン 3.10 で変更: GCC で ‘-fno-semantic-interposition’ を使用
     する。

 -- 環境変数: PROFILE_TASK

     Environment variable used in the Makefile: Python command line
     arguments for the PGO generation task.

     デフォルト: ‘-m test --pgo --timeout=$(TESTTIMEOUT)’

     Added in version 3.8.

     バージョン 3.13 で変更: Task failure is no longer ignored silently.

 -- Option: --with-lto=[full|thin|no|yes]

     Enable Link Time Optimization (LTO) in any build (disabled by
     default).

     The C compiler Clang requires ‘llvm-ar’ for LTO (‘ar’ on macOS), as
     well as an LTO-aware linker (‘ld.gold’ or ‘lld’).

     Added in version 3.6.

     Added in version 3.11: To use ThinLTO feature, use
     ‘--with-lto=thin’ on Clang.

     バージョン 3.12 で変更: Use ThinLTO as the default optimization
     policy on Clang if the compiler accepts the flag.

 -- Option: --enable-bolt

     Enable usage of the BOLT post-link binary optimizer(1) (disabled by
     default).

     BOLT is part of the LLVM project but is not always included in
     their binary distributions.  This flag requires that ‘llvm-bolt’
     and ‘merge-fdata’ are available.

     BOLT is still a fairly new project so this flag should be
     considered experimental for now.  Because this tool operates on
     machine code its success is dependent on a combination of the build
     environment + the other optimization configure args + the CPU
     architecture, and not all combinations are supported.  BOLT
     versions before LLVM 16 are known to crash BOLT under some
     scenarios.  Use of LLVM 16 or newer for BOLT optimization is
     strongly encouraged.

     The ‘BOLT_INSTRUMENT_FLAGS’ and ‘BOLT_APPLY_FLAGS’ ‘configure’
     variables can be defined to override the default set of arguments
     for ‘llvm-bolt’ to instrument and apply BOLT data to binaries,
     respectively.

     Added in version 3.12.

 -- Option: BOLT_APPLY_FLAGS

     Arguments to ‘llvm-bolt’ when creating a BOLT optimized binary(2).

     Added in version 3.12.

 -- Option: BOLT_INSTRUMENT_FLAGS

     Arguments to ‘llvm-bolt’ when instrumenting binaries.

     Added in version 3.12.

 -- Option: --with-computed-gotos

     Enable computed gotos in evaluation loop (enabled by default on
     supported compilers).

 -- Option: --without-mimalloc

     Disable the fast *note mimalloc: 1cbc. allocator (enabled by
     default).

     See also *note PYTHONMALLOC: c32. environment variable.

 -- Option: --without-pymalloc

     Disable the specialized Python memory allocator *note pymalloc:
     cdd. (enabled by default).

     See also *note PYTHONMALLOC: c32. environment variable.

 -- Option: --without-doc-strings

     Disable static documentation strings to reduce the memory footprint
     (enabled by default).  Documentation strings defined in Python are
     not affected.

     Don't define the ‘WITH_DOC_STRINGS’ macro.

     See the ‘PyDoc_STRVAR()’ macro.

 -- Option: --enable-profiling

     Enable C-level code profiling with ‘gprof’ (disabled by default).

 -- Option: --with-strict-overflow

     Add ‘-fstrict-overflow’ to the C compiler flags (by default we add
     ‘-fno-strict-overflow’ instead).

   ---------- Footnotes ----------

   (1) https://github.com/llvm/llvm-project/tree/main/bolt

   (2) https://github.com/facebookarchive/BOLT


File: python.info,  Node: Python Debug Build,  Next: Debug options,  Prev: パフォーマンスに関するオプション,  Up: Configureオプション

3.3.3.8 Python Debug Build
..........................

A debug build is Python built with the *note -with-pydebug: 3fb.
configure option.

Effects of a debug build:

   * Display all warnings by default: the list of default warning
     filters is empty in the *note warnings: fa. module.

   * Add ‘d’ to *note sys.abiflags: a32.

   * Add ‘sys.gettotalrefcount()’ function.

   * Add *note -X showrefcount: 15c. command line option.

   * Add *note -d: 1c9b. command line option and *note PYTHONDEBUG:
     1c9c. environment variable to debug the parser.

   * Add support for the ‘__lltrace__’ variable: enable low-level
     tracing in the bytecode evaluation loop if the variable is defined.

   * Install *note debug hooks on memory allocators: 1cba. to detect
     buffer overflow and other memory errors.

   * Define ‘Py_DEBUG’ and ‘Py_REF_DEBUG’ macros.

   * Add runtime checks: code surrounded by ‘#ifdef Py_DEBUG’ and
     ‘#endif’.  Enable ‘assert(...)’ and ‘_PyObject_ASSERT(...)’
     assertions: don't set the ‘NDEBUG’ macro (see also the *note
     -with-assertions: 365. configure option).  Main runtime checks:

        * Add sanity checks on the function arguments.

        * Unicode and int objects are created with their memory filled
          with a pattern to detect usage of uninitialized objects.

        * Ensure that functions which can clear or replace the current
          exception are not called with an exception raised.

        * Check that deallocator functions don't change the current
          exception.

        * The garbage collector (*note gc.collect(): a08. function) runs
          some basic checks on objects consistency.

        * The ‘Py_SAFE_DOWNCAST()’ macro checks for integer underflow
          and overflow when downcasting from wide types to narrow types.

See also the *note Python Development Mode: 1d9. and the *note
-with-trace-refs: 36e. configure option.

バージョン 3.8 で変更: Release builds and debug builds are now ABI
compatible: defining the ‘Py_DEBUG’ macro no longer implies the
‘Py_TRACE_REFS’ macro (see the *note -with-trace-refs: 36e. option).


File: python.info,  Node: Debug options,  Next: リンカのオプション<2>,  Prev: Python Debug Build,  Up: Configureオプション

3.3.3.9 Debug options
.....................

 -- Option: --with-pydebug

     *note Build Python in debug mode: 1da.: define the ‘Py_DEBUG’ macro
     (disabled by default).

 -- Option: --with-trace-refs

     Enable tracing references for debugging purpose (disabled by
     default).

     Effects:

        * Define the ‘Py_TRACE_REFS’ macro.

        * Add *note sys.getobjects(): 3fe. function.

        * Add *note PYTHONDUMPREFS: 974. environment variable.

     The *note PYTHONDUMPREFS: 974. environment variable can be used to
     dump objects and reference counts still alive at Python exit.

     *note Statically allocated objects: 74a. are not traced.

     Added in version 3.8.

     バージョン 3.13 で変更: This build is now ABI compatible with
     release build and *note debug build: 1da.

 -- Option: --with-assertions

     Build with C assertions enabled (default is no): ‘assert(...);’ and
     ‘_PyObject_ASSERT(...);’.

     If set, the ‘NDEBUG’ macro is not defined in the *note OPT: 1d1d.
     compiler variable.

     See also the *note -with-pydebug: 3fb. option (*note debug build:
     1da.) which also enables assertions.

     Added in version 3.6.

 -- Option: --with-valgrind

     Enable Valgrind support (default is no).

 -- Option: --with-dtrace

     Enable DTrace support (default is no).

     See *note Instrumenting CPython with DTrace and SystemTap: c3a.

     Added in version 3.6.

 -- Option: --with-address-sanitizer

     Enable AddressSanitizer memory error detector, ‘asan’ (default is
     no).

     Added in version 3.6.

 -- Option: --with-memory-sanitizer

     Enable MemorySanitizer allocation error detector, ‘msan’ (default
     is no).

     Added in version 3.6.

 -- Option: --with-undefined-behavior-sanitizer

     Enable UndefinedBehaviorSanitizer undefined behaviour detector,
     ‘ubsan’ (default is no).

     Added in version 3.6.

 -- Option: --with-thread-sanitizer

     Enable ThreadSanitizer data race detector, ‘tsan’ (default is no).

     Added in version 3.13.


File: python.info,  Node: リンカのオプション<2>,  Next: Libraries options,  Prev: Debug options,  Up: Configureオプション

3.3.3.10 リンカのオプション
...........................

 -- Option: --enable-shared

     Enable building a shared Python library: ‘libpython’ (default is
     no).

 -- Option: --without-static-libpython

     Do not build ‘libpythonMAJOR.MINOR.a’ and do not install ‘python.o’
     (built and enabled by default).

     Added in version 3.10.


File: python.info,  Node: Libraries options,  Next: Security Options,  Prev: リンカのオプション<2>,  Up: Configureオプション

3.3.3.11 Libraries options
..........................

 -- Option: --with-libs='lib1 ...'

     Link against additional libraries (default is no).

 -- Option: --with-system-expat

     Build the ‘pyexpat’ module using an installed ‘expat’ library
     (default is no).

 -- Option: --with-system-libmpdec

     Build the ‘_decimal’ extension module using an installed
     ‘mpdecimal’ library, see the *note decimal: 2e. module (default is
     yes).

     Added in version 3.3.

     バージョン 3.13 で変更: Default to using the installed ‘mpdecimal’
     library.

     Deprecated since version 3.13, will be removed in version 3.15: A
     copy of the ‘mpdecimal’ library sources will no longer be
     distributed with Python 3.15.

     参考
     ....

     *note LIBMPDEC_CFLAGS: 1cfe. and *note LIBMPDEC_LIBS: 1cff.

 -- Option: --with-readline=readline|editline

     Designate a backend library for the *note readline: a8. module.

        * readline: Use readline as the backend.

        * editline: Use editline as the backend.

     Added in version 3.10.

 -- Option: --without-readline

     Don't build the *note readline: a8. module (built by default).

     Don't define the ‘HAVE_LIBREADLINE’ macro.

     Added in version 3.10.

 -- Option: --with-libm=STRING

     Override ‘libm’ math library to 'STRING' (default is
     system-dependent).

 -- Option: --with-libc=STRING

     Override ‘libc’ C library to 'STRING' (default is
     system-dependent).

 -- Option: --with-openssl=DIR

     Root of the OpenSSL directory.

     Added in version 3.7.

 -- Option: --with-openssl-rpath=[no|auto|DIR]

     Set runtime library directory (rpath) for OpenSSL libraries:

        * ‘no’ (default): don't set rpath;

        * ‘auto’: auto-detect rpath from *note -with-openssl: 1d2b. and
          ‘pkg-config’;

        * 'DIR': set an explicit rpath.

     Added in version 3.10.


File: python.info,  Node: Security Options,  Next: macOS のオプション,  Prev: Libraries options,  Up: Configureオプション

3.3.3.12 Security Options
.........................

 -- Option: --with-hash-algorithm=[fnv|siphash13|siphash24]

     Select hash algorithm for use in ‘Python/pyhash.c’:

        * ‘siphash13’ (default);

        * ‘siphash24’;

        * ‘fnv’.

     Added in version 3.4.

     Added in version 3.11: ‘siphash13’ is added and it is the new
     default.

 -- Option:
          --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2

     Built-in hash modules:

        * ‘md5’;

        * ‘sha1’;

        * ‘sha256’;

        * ‘sha512’;

        * ‘sha3’ (with shake);

        * ‘blake2’.

     Added in version 3.9.

 -- Option: --with-ssl-default-suites=[python|openssl|STRING]

     Override the OpenSSL default cipher suites string:

        * ‘python’ (default): use Python's preferred selection;

        * ‘openssl’: leave OpenSSL's defaults untouched;

        * 'STRING': use a custom string

     See the *note ssl: bb. module.

     Added in version 3.7.

     バージョン 3.10 で変更: The settings ‘python’ and 'STRING' also set
     TLS 1.2 as minimum protocol version.


File: python.info,  Node: macOS のオプション,  Next: iOS のオプション,  Prev: Security Options,  Up: Configureオプション

3.3.3.13 macOS のオプション
...........................

Mac/README.rst(1) を参照。

 -- Option: --enable-universalsdk

 -- Option: --enable-universalsdk=SDKDIR

     ユニバーサルバイナリビルドを作成します。 'SDKDIR' はビルドの実行に
     どの macOS SDK が使用されるべきかを指定します (デフォルトでは指定し
     ません) 。

 -- Option: --enable-framework

 -- Option: --enable-framework=INSTALLDIR

     従来の Unix インストールではなく、 Python.framework を作成します。
     オプションの 'INSTALLDIR' はインストール先のパスを指定します (デフ
     ォルトでは指定しません) 。

 -- Option: --with-universal-archs=ARCH

     作成するユニバーサルバイナリの種類を指定します。このオプションは、
     *note -enable-universalsdk: 939. が指定された場合のみ有効です。

     オプション:

        * ‘universal2’;

        * ‘32-bit’;

        * ‘64-bit’;

        * ‘3-way’;

        * ‘intel’;

        * ‘intel-32’;

        * ‘intel-64’;

        * ‘all’。

 -- Option: --with-framework-name=FRAMEWORK

     macOS の Python フレームワークの名前を指定します。 *note
     -enable-framework: 1d32. が指定された場合のみ有効です (デフォルトで
     は ‘Python’) 。

 -- Option: --with-app-store-compliance

 -- Option: --with-app-store-compliance=PATCH-FILE

     Python 標準ライブラリは、 macOS と iOS の App Store による配布用に
     送信された場合に、自動検査ツールのエラーを発生させることが知られて
     いる文字列を含んでいます。このオプションを有効にした場合、 App
     Store コンプライアンスに合わせて修正することが知られているパッチの
     リストを適用します。カスタムのパッチファイルを指定することもできま
     す。このオプションはデフォルトでは無効になっています。

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Mac/README.rst


File: python.info,  Node: iOS のオプション,  Next: クロスコンパイルのオプション,  Prev: macOS のオプション,  Up: Configureオプション

3.3.3.14 iOS のオプション
.........................

iOS/README.rst(1) を参照。

 -- Option: --enable-framework=INSTALLDIR

     Python.framework を作成します。 macOS とは違い、インストールパスを
     指定する 'INSTALLDIR' 引数は必須です。

 -- Option: --with-framework-name=FRAMEWORK

     フレームワークの名前を指定します (デフォルト: ‘Python’) 。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/iOS/README.rst


File: python.info,  Node: クロスコンパイルのオプション,  Prev: iOS のオプション,  Up: Configureオプション

3.3.3.15 クロスコンパイルのオプション
.....................................

クロスコンパイル、またはクロスビルドは、異なる CPU アーキテクチャやプラ
ットフォーム用に Python をビルドするために使用できます。クロスコンパイル
には、ビルドプラットフォーム用の Python インタープリターが必要です。ビル
ドする Python のバージョンは、クロスコンパイルされたホスト Python のバー
ジョンと一致する必要があります。

 -- Option: --build=BUILD

     BUILD でビルドするための設定です。通常は、 ‘config.guess’ により推
     測されます。

 -- Option: --host=HOST

     HOST (ターゲットプラットフォーム) で動作するプログラムをビルドする
     ためのクロスコンパイル。

 -- Option: --with-build-python=path/to/python

     クロスコンパイル用のビルド ‘python’ バイナリへのパス。

     Added in version 3.11.

 -- Option: CONFIG_SITE=file

     構成をオーバーライドするファイルを指す環境変数。

     'config.site' ファイルの例:

          # config.site-aarch64
          ac_cv_buggy_getaddrinfo=no
          ac_cv_file__dev_ptmx=yes
          ac_cv_file__dev_ptc=no

 -- Option: HOSTRUNNER

     クロスコンパイル用にホストプラットフォームの CPython を実行するプロ
     グラム。

     Added in version 3.11.

クロスコンパイルの例:

     CONFIG_SITE=config.site-aarch64 ../configure \
         --build=x86_64-pc-linux-gnu \
         --host=aarch64-unknown-linux-gnu \
         --with-build-python=../x86_64/python


File: python.info,  Node: Python ビルドシステム,  Next: Compiler and linker flags,  Prev: Configureオプション,  Up: Python を構成する

3.3.4 Python ビルドシステム
---------------------------

* Menu:

* ビルドシステムの主要なファイル::
* 主要なビルドステップ::
* Main Makefile targets::
* C extensions::


File: python.info,  Node: ビルドシステムの主要なファイル,  Next: 主要なビルドステップ,  Up: Python ビルドシステム

3.3.4.1 ビルドシステムの主要なファイル
......................................

   * ‘configure.ac’ => ‘configure’;

   * ‘Makefile.pre.in’ => ‘Makefile’ (‘configure’ により作成されます);

   * ‘pyconfig.h’ (‘configure’ により作成されます);

   * ‘Modules/Setup’: ‘Module/makesetup’ シェルスクリプトを使用して
     Makefile がビルドする C 拡張。


File: python.info,  Node: 主要なビルドステップ,  Next: Main Makefile targets,  Prev: ビルドシステムの主要なファイル,  Up: Python ビルドシステム

3.3.4.2 主要なビルドステップ
............................

   * C files (‘.c’) are built as object files (‘.o’).

   * A static ‘libpython’ library (‘.a’) is created from objects files.

   * ‘python.o’ and the static ‘libpython’ library are linked into the
     final ‘python’ program.

   * C extensions are built by the Makefile (see ‘Modules/Setup’).


File: python.info,  Node: Main Makefile targets,  Next: C extensions,  Prev: 主要なビルドステップ,  Up: Python ビルドシステム

3.3.4.3 Main Makefile targets
.............................

* Menu:

* make::
* make platform::
* make profile-opt::
* make clean::
* make distclean::
* make install::
* make test::
* make buildbottest::
* make regen-all::


File: python.info,  Node: make,  Next: make platform,  Up: Main Makefile targets

3.3.4.4 make
............

For the most part, when rebuilding after editing some code or refreshing
your checkout from upstream, all you need to do is execute ‘make’, which
(per Make's semantics) builds the default target, the first one defined
in the Makefile.  By tradition (including in the CPython project) this
is usually the ‘all’ target.  The ‘configure’ script expands an
‘autoconf’ variable, ‘@DEF_MAKE_ALL_RULE@’ to describe precisely which
targets ‘make all’ will build.  The three choices are:

   * ‘profile-opt’ (configured with ‘--enable-optimizations’)

   * ‘build_wasm’ (configured with ‘--with-emscripten-target’)

   * ‘build_all’ (configured without explicitly using either of the
     others)

Depending on the most recent source file changes, Make will rebuild any
targets (object files and executables) deemed out-of-date, including
running ‘configure’ again if necessary.  Source/target dependencies are
many and maintained manually however, so Make sometimes doesn't have all
the information necessary to correctly detect all targets which need to
be rebuilt.  Depending on which targets aren't rebuilt, you might
experience a number of problems.  If you have build or test problems
which you can't otherwise explain, ‘make clean && make’ should work
around most dependency problems, at the expense of longer build times.


File: python.info,  Node: make platform,  Next: make profile-opt,  Prev: make,  Up: Main Makefile targets

3.3.4.5 make platform
.....................

Build the ‘python’ program, but don't build the standard library
extension modules.  This generates a file named ‘platform’ which
contains a single line describing the details of the build platform,
e.g., ‘macosx-14.3-arm64-3.12’ or ‘linux-x86_64-3.13’.


File: python.info,  Node: make profile-opt,  Next: make clean,  Prev: make platform,  Up: Main Makefile targets

3.3.4.6 make profile-opt
........................

Build Python using profile-guided optimization (PGO). You can use the
configure *note -enable-optimizations: 82d. option to make this the
default target of the ‘make’ command (‘make all’ or just ‘make’).


File: python.info,  Node: make clean,  Next: make distclean,  Prev: make profile-opt,  Up: Main Makefile targets

3.3.4.7 make clean
..................

Remove built files.


File: python.info,  Node: make distclean,  Next: make install,  Prev: make clean,  Up: Main Makefile targets

3.3.4.8 make distclean
......................

In addition to the work done by ‘make clean’, remove files created by
the configure script.  ‘configure’ will have to be run before building
again.  (1)

   ---------- Footnotes ----------

   (1) ‘git clean -fdx’ is an even more extreme way to "clean" your
checkout.  It removes all files not known to Git.  When bug hunting
using ‘git bisect’, this is recommended between probes
(https://github.com/python/cpython/issues/114505#issuecomment-1907021718)
to guarantee a completely clean build.  'Use with care', as it will
delete all files not checked into Git, including your new, uncommitted
work.


File: python.info,  Node: make install,  Next: make test,  Prev: make distclean,  Up: Main Makefile targets

3.3.4.9 make install
....................

Build the ‘all’ target and install Python.


File: python.info,  Node: make test,  Next: make buildbottest,  Prev: make install,  Up: Main Makefile targets

3.3.4.10 make test
..................

Build the ‘all’ target and run the Python test suite with the
‘--fast-ci’ option.  Variables:

   * ‘TESTOPTS’: additional regrtest command-line options.

   * ‘TESTPYTHONOPTS’: additional Python command-line options.

   * ‘TESTTIMEOUT’: timeout in seconds (default: 10 minutes).


File: python.info,  Node: make buildbottest,  Next: make regen-all,  Prev: make test,  Up: Main Makefile targets

3.3.4.11 make buildbottest
..........................

This is similar to ‘make test’, but uses the ‘--slow-ci’ option and
default timeout of 20 minutes, instead of ‘--fast-ci’ option.


File: python.info,  Node: make regen-all,  Prev: make buildbottest,  Up: Main Makefile targets

3.3.4.12 make regen-all
.......................

Regenerate (almost) all generated files.  These include (but are not
limited to) bytecode cases, and parser generator file.  ‘make
regen-stdlib-module-names’ and ‘autoconf’ must be run separately for the
remaining *note generated files: 1cd2.


File: python.info,  Node: C extensions,  Prev: Main Makefile targets,  Up: Python ビルドシステム

3.3.4.13 C extensions
.....................

Some C extensions are built as built-in modules, like the ‘sys’ module.
They are built with the ‘Py_BUILD_CORE_BUILTIN’ macro defined.  Built-in
modules have no ‘__file__’ attribute:

     >>> import sys
     >>> sys
     <module 'sys' (built-in)>
     >>> sys.__file__
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     AttributeError: module 'sys' has no attribute '__file__'

Other C extensions are built as dynamic libraries, like the ‘_asyncio’
module.  They are built with the ‘Py_BUILD_CORE_MODULE’ macro defined.
Example on Linux x86-64:

     >>> import _asyncio
     >>> _asyncio
     <module '_asyncio' from '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'>
     >>> _asyncio.__file__
     '/usr/lib64/python3.9/lib-dynload/_asyncio.cpython-39-x86_64-linux-gnu.so'

‘Modules/Setup’ is used to generate Makefile targets to build C
extensions.  At the beginning of the files, C extensions are built as
built-in modules.  Extensions defined after the ‘*shared*’ marker are
built as dynamic libraries.

The ‘PyAPI_FUNC()’, ‘PyAPI_DATA()’ and *note PyMODINIT_FUNC: 147c.
macros of ‘Include/exports.h’ are defined differently depending if the
‘Py_BUILD_CORE_MODULE’ macro is defined:

   * Use ‘Py_EXPORTED_SYMBOL’ if the ‘Py_BUILD_CORE_MODULE’ is defined

   * Use ‘Py_IMPORTED_SYMBOL’ otherwise.

If the ‘Py_BUILD_CORE_BUILTIN’ macro is used by mistake on a C extension
built as a shared library, its ‘PyInit_XXX()’ function is not exported,
causing an *note ImportError: 3f2. on import.


File: python.info,  Node: Compiler and linker flags,  Prev: Python ビルドシステム,  Up: Python を構成する

3.3.5 Compiler and linker flags
-------------------------------

Options set by the ‘./configure’ script and environment variables and
used by ‘Makefile’.

* Menu:

* Preprocessor flags::
* Compiler flags::
* Linker flags::


File: python.info,  Node: Preprocessor flags,  Next: Compiler flags,  Up: Compiler and linker flags

3.3.5.1 Preprocessor flags
..........................

 -- 環境変数: CONFIGURE_CPPFLAGS

     Value of *note CPPFLAGS: 145e. variable passed to the ‘./configure’
     script.

     Added in version 3.6.

 -- 環境変数: CPPFLAGS

     (Objective) C/C++ preprocessor flags, e.g.  ‘-IINCLUDE_DIR’ if you
     have headers in a nonstandard directory 'include_dir'.

     Both *note CPPFLAGS: 145e. and *note LDFLAGS: 145d. need to contain
     the shell's value to be able to build extension modules using the
     directories specified in the environment variables.

 -- 環境変数: BASECPPFLAGS

     Added in version 3.4.

 -- 環境変数: PY_CPPFLAGS

     Extra preprocessor flags added for building the interpreter object
     files.

     Default: ‘$(BASECPPFLAGS) -I. -I$(srcdir)/Include
     $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)’.

     Added in version 3.2.


File: python.info,  Node: Compiler flags,  Next: Linker flags,  Prev: Preprocessor flags,  Up: Compiler and linker flags

3.3.5.2 Compiler flags
......................

 -- 環境変数: CC

     C コンパイラのコマンド。

     Example: ‘gcc -pthread’.

 -- 環境変数: CXX

     C++ compiler command.

     Example: ‘g++ -pthread’.

 -- 環境変数: CFLAGS

     C コンパイラのフラグ。

 -- 環境変数: CFLAGS_NODIST

     *note CFLAGS_NODIST: 1d55. is used for building the interpreter and
     stdlib C extensions.  Use it when a compiler flag should 'not' be
     part of *note CFLAGS: 145c. once Python is installed (gh-65320(1)).

     In particular, *note CFLAGS: 145c. should not contain:

        * the compiler flag ‘-I’ (for setting the search path for
          include files).  The ‘-I’ flags are processed from left to
          right, and any flags in *note CFLAGS: 145c. would take
          precedence over user- and package-supplied ‘-I’ flags.

        * hardening flags such as ‘-Werror’ because distributions cannot
          control whether packages installed by users conform to such
          heightened standards.

     Added in version 3.5.

 -- 環境変数: COMPILEALL_OPTS

     Options passed to the *note compileall: 19. command line when
     building PYC files in ‘make install’.  Default: ‘-j0’.

     Added in version 3.12.

 -- 環境変数: EXTRA_CFLAGS

     Extra C compiler flags.

 -- 環境変数: CONFIGURE_CFLAGS

     Value of *note CFLAGS: 145c. variable passed to the ‘./configure’
     script.

     Added in version 3.2.

 -- 環境変数: CONFIGURE_CFLAGS_NODIST

     Value of *note CFLAGS_NODIST: 1d55. variable passed to the
     ‘./configure’ script.

     Added in version 3.5.

 -- 環境変数: BASECFLAGS

     Base compiler flags.

 -- 環境変数: OPT

     Optimization flags.

 -- 環境変数: CFLAGS_ALIASING

     Strict or non-strict aliasing flags used to compile
     ‘Python/dtoa.c’.

     Added in version 3.7.

 -- 環境変数: CCSHARED

     Compiler flags used to build a shared library.

     For example, ‘-fPIC’ is used on Linux and on BSD.

 -- 環境変数: CFLAGSFORSHARED

     Extra C flags added for building the interpreter object files.

     Default: ‘$(CCSHARED)’ when *note -enable-shared: 82e. is used, or
     an empty string otherwise.

 -- 環境変数: PY_CFLAGS

     Default: ‘$(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS)
     $(EXTRA_CFLAGS)’.

 -- 環境変数: PY_CFLAGS_NODIST

     Default: ‘$(CONFIGURE_CFLAGS_NODIST) $(CFLAGS_NODIST)
     -I$(srcdir)/Include/internal’.

     Added in version 3.5.

 -- 環境変数: PY_STDMODULE_CFLAGS

     C flags used for building the interpreter object files.

     Default: ‘$(PY_CFLAGS) $(PY_CFLAGS_NODIST) $(PY_CPPFLAGS)
     $(CFLAGSFORSHARED)’.

     Added in version 3.7.

 -- 環境変数: PY_CORE_CFLAGS

     Default: ‘$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE’.

     Added in version 3.2.

 -- 環境変数: PY_BUILTIN_MODULE_CFLAGS

     Compiler flags to build a standard library extension module as a
     built-in module, like the *note posix: 9b. module.

     Default: ‘$(PY_STDMODULE_CFLAGS) -DPy_BUILD_CORE_BUILTIN’.

     Added in version 3.8.

 -- 環境変数: PURIFY

     Purify command.  Purify is a memory debugger program.

     Default: empty string (not used).

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/65320


File: python.info,  Node: Linker flags,  Prev: Compiler flags,  Up: Compiler and linker flags

3.3.5.3 Linker flags
....................

 -- 環境変数: LINKCC

     Linker command used to build programs like ‘python’ and
     ‘_testembed’.

     Default: ‘$(PURIFY) $(CC)’.

 -- 環境変数: CONFIGURE_LDFLAGS

     Value of *note LDFLAGS: 145d. variable passed to the ‘./configure’
     script.

     Avoid assigning *note CFLAGS: 145c, *note LDFLAGS: 145d, etc.  so
     users can use them on the command line to append to these values
     without stomping the pre-set values.

     Added in version 3.2.

 -- 環境変数: LDFLAGS_NODIST

     *note LDFLAGS_NODIST: 1d67. is used in the same manner as *note
     CFLAGS_NODIST: 1d55.  Use it when a linker flag should 'not' be
     part of *note LDFLAGS: 145d. once Python is installed
     (gh-65320(1)).

     In particular, *note LDFLAGS: 145d. should not contain:

        * the compiler flag ‘-L’ (for setting the search path for
          libraries).  The ‘-L’ flags are processed from left to right,
          and any flags in *note LDFLAGS: 145d. would take precedence
          over user- and package-supplied ‘-L’ flags.

 -- 環境変数: CONFIGURE_LDFLAGS_NODIST

     Value of *note LDFLAGS_NODIST: 1d67. variable passed to the
     ‘./configure’ script.

     Added in version 3.8.

 -- 環境変数: LDFLAGS

     Linker flags, e.g.  ‘-LLIB_DIR’ if you have libraries in a
     nonstandard directory 'lib_dir'.

     Both *note CPPFLAGS: 145e. and *note LDFLAGS: 145d. need to contain
     the shell's value to be able to build extension modules using the
     directories specified in the environment variables.

 -- 環境変数: LIBS

     Linker flags to pass libraries to the linker when linking the
     Python executable.

     Example: ‘-lrt’.

 -- 環境変数: LDSHARED

     Command to build a shared library.

     Default: ‘@LDSHARED@ $(PY_LDFLAGS)’.

 -- 環境変数: BLDSHARED

     Command to build ‘libpython’ shared library.

     Default: ‘@BLDSHARED@ $(PY_CORE_LDFLAGS)’.

 -- 環境変数: PY_LDFLAGS

     Default: ‘$(CONFIGURE_LDFLAGS) $(LDFLAGS)’.

 -- 環境変数: PY_LDFLAGS_NODIST

     Default: ‘$(CONFIGURE_LDFLAGS_NODIST) $(LDFLAGS_NODIST)’.

     Added in version 3.8.

 -- 環境変数: PY_CORE_LDFLAGS

     Linker flags used for building the interpreter object files.

     Added in version 3.8.

脚注
....

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/65320


File: python.info,  Node: Windows で Python を使う,  Next: Using Python on macOS,  Prev: Python を構成する,  Up: Python のセットアップと利用

3.4 Windows で Python を使う
============================

このドキュメントは、 Python を Microsoft Windows で使うときに知っておく
べき、 Windows 固有の動作についての概要を伝えることを目的としています。

ほとんどの Unix システムとサービスとは違って、Windows には、システムがサ
ポートする Python インストールが含まれていません。Python を利用可能にす
るために、CPython チームは長年の間、すべての リリース(1) で Windows イン
ストーラをコンパイルしてきました。単独のユーザで使われるコアインタープリ
ターとライブラリをユーザーごとに追加する Python インストールを、これらイ
ンストーラーは主として意図しています。インストーラでは単一マシンのすべて
のユーザ用にインストールすることもでき、また、これとは分離されたアプリケ
ーションローカルな配布物の ZIP ファイルも入手可能です。

PEP 11(2) で明記しているとおり Python のリリースは、Microsoft が延長サポ
ート期間であるとしている Windows プラットフォームのみをサポートします。
つまり Python 3.13 は Windows 8.1 とそれより新しい Windows をサポートす
るということです。 Windows 7 サポートが必要な場合は、Python 3.8 をインス
トールしてください。

Windows で使えるインストーラには多くの様々なものがあり、それぞれが利点と
欠点を持っています。

*note 完全版インストーラ: 1d71. には全てのコンポーネントが含まれており、
Python を使う開発者がどんな種類のプロジェクトでも最適な選択肢です。

*note Microsoft ストアパッケージ: 1b51. は、スクリプトやパッケージの実行
、 IDLE の使用やその他開発環境に適したシンプルな構成の Python です。
Windows 10 以上が求められはしますが、他のプログラムを壊すことなく安全に
インストールできます。 Python やそのツールを起動する多くの便利なコマンド
も提供しています。

*note nuget.org パッケージ: 1d72. は、継続的インテグレーションのための軽
量なインストール構成です。 これは Python パッケージのビルドやスクリプト
の実行にも使えますが、アップデート可能ではなく、ユーザーインターフェイス
ツールもありません。

*note 埋め込み可能なパッケージ: 1d73. は、他の大きなアプリケーションに埋
め込むのに適した、 Python の最小パッケージです。

* Menu:

* 完全版インストーラ::
* Microsoft ストアパッケージ::
* nuget.org パッケージ: nuget org パッケージ.
* 埋め込み可能なパッケージ::
* 別のバンドル::
* Python を構成する: Python を構成する<2>.
* UTF-8 モード::
* Windows の Python ランチャ::
* モジュールの検索::
* 追加のモジュール::
* Windows 上で Python をコンパイルする::
* ほかのプラットフォーム::

   ---------- Footnotes ----------

   (1) https://www.python.org/downloads/

   (2) https://peps.python.org/pep-0011/


File: python.info,  Node: 完全版インストーラ,  Next: Microsoft ストアパッケージ,  Up: Windows で Python を使う

3.4.1 完全版インストーラ
------------------------

* Menu:

* インストール手順::
* MAX_PATH の制限を除去する::
* インストーラの GUI なしでインストールする::
* ダウンロード不要なインストール::
* インストール後の変更::
* フリースレッドバイナリ (Free-threaded Binaries) のインストール: フリースレッドバイナリ Free-threaded Binaries のインストール.


File: python.info,  Node: インストール手順,  Next: MAX_PATH の制限を除去する,  Up: 完全版インストーラ

3.4.1.1 インストール手順
........................

ダウンロードできる Python 3.13 のインストーラは 4 つあります。 インタプ
リタの 32 ビット版、64 ビット版がそれぞれ 2 つずつあります。 'WEB インス
トーラ' は最初のダウンロードサイズは小さく、必要なコンポーネントはインス
トーラ実行時に必要に応じて自動的にダウンロードします。 'オフラインインス
トーラ' にはデフォルトインストールに必要なコンポーネントが含まれていて、
インターネット接続はオプショナルな機能のためにだけに必要となります。 イ
ンストール時にダウンロードを避けるほかの方法については *note
ダウンロード不要なインストール: 1d76. を参照して下さい。

インストーラを開始すると、2つの選択肢からひとつを選べます:

[image src="python-figures/win_installer.png"]


"Install Now" を選択した場合:

   * 管理者権限は '不要です' (ただし C ランタイムライブラリのシステム更
     新が必要であったり、 *note Windows の Python ランチャ: 588. をすべ
     てのユーザ向けにインストールする場合は必要です)。

   * Python はあなたのユーザディレクトリにインストールされます。

   * *note Windows の Python ランチャ: 588. はこのインストールウィザード
     最初のページの下部のチェックボックス指定に従ってインストールされま
     す。

   * 標準ライブラリ、テストスイート、ランチャ、pip がインストールされま
     す。

   * このインストールウィザード最初の下部のチェックボックスをチェックす
     れば、環境変数 ‘PATH’ にインストールディレクトリが追加されます。

   * ショートカットはカレントユーザだけに可視になります。

"Customize installation" を選択すると、インストール場所、その他オプショ
ンやインストール後のアクションの変更などのインストールの有りようを選べま
す。デバッグシンボルやデバッグバイナリをインストールするならこちらを選択
する必要があるでしょう。

すべてのユーザのためのインストールのためには "Customize installation" を
選んでください。この場合:

   * 管理者資格か承認が必要かもしれません。

   * Python は Program Files ディレクトリにインストールされます。

   * *note Windows の Python ランチャ: 588. は Windows ディレクトリにイ
     ンストールされます。

   * オプショナルな機能はインストール中に選択できます。

   * 標準ライブラリをバイトコードにプリコンパイルできます。

   * そう選択すれば、インストールディレクトリはシステム環境変数 ‘PATH’ に
     追加されます。

   * ショートカットがすべてのユーザで利用できるようになります。


File: python.info,  Node: MAX_PATH の制限を除去する,  Next: インストーラの GUI なしでインストールする,  Prev: インストール手順,  Up: 完全版インストーラ

3.4.1.2 MAX_PATH の制限を除去する
.................................

Windows は歴史的にパスの長さが 260 文字に制限されています。 つまり、これ
より長いパスは解決できず結果としてエラーになるということです。

Windows の最新版では、この制限は約 32,000 文字まで拡張できます。 管理者
が、グループポリシーの "Win32 の長いパスを有効にする (Enable Win32 long
paths)" を有効にするか、レジストリキー
‘HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem’ の
‘LongPathsEnabled’ の値を ‘1’ に設定する必要があります。

これにより、 *note open(): 4e5. 関数や *note os: 91. モジュール、他のほ
とんどのパスの機能が 260 文字より長いパスを受け入れ、返すことができるよ
うになります。

これらのオプションを変更したら、それ以上の設定は必要ありません。

バージョン 3.6 で変更: Python で長いパスのサポートが可能になりました。


File: python.info,  Node: インストーラの GUI なしでインストールする,  Next: ダウンロード不要なインストール,  Prev: MAX_PATH の制限を除去する,  Up: 完全版インストーラ

3.4.1.3 インストーラの GUI なしでインストールする
.................................................

インストーラの GUI で利用できるすべてのオプションは、コマンドラインから
も指定できます。これによりユーザとの対話なしで数多くの機器に同じインスト
ールを行うような、スクリプト化されたインストールを行うことができます。ち
ょっとしたデフォルトの変更のために、GUI を抑制することなしにこれらコマン
ドラインオプションをセットすることもできます。

インストーラーには、以下のオプション (‘/?’ でインストーラを実行すること
で確認できます) を渡すことができます:

名前                      説明
                          
---------------------------------------------------------------------------------------
                          
/passive                  ユーザーの操作なしでも進捗を表示する
                          
                          
/quiet                    UI を表示せずにインストール・アンインストールする
                          
                          
/simple                   ユーザーによるカスタマイズができないようにする
                          
                          
/uninstall                (確認無しで) Python を削除する
                          
                          
/layout [ディレクトリ]    すべてのコンポーネントを事前にダウンロードする
                          
                          
/log [ファイル名]         ログファイルの場所を指定する
                          

ほかのすべてのオプションは ‘name=value’ の形で渡します。value は大抵 ‘0’
で機能を無効化、 ‘1’ で機能を有効化、であるとかパスの指定です。利用可能
なオプションの完全なリストは以下の通りです。

名前                            説明                                       デフォルト
                                                                           
----------------------------------------------------------------------------------------------------------
                                                                           
InstallAllUsers                 システムワイドなインストールを実行する。   0
                                                                           
                                                                           
TargetDir                       インストール先ディレクトリ。               InstallAllUsers に基いて選択
                                                                           されます。
                                                                           
                                                                           
DefaultAllUsersTargetDir        すべてのユーザ向けインストールのためのデ   ‘%ProgramFiles%\Python X.Y’
                                フォルトインストール先ディレクトリ。       または
                                                                           ‘%ProgramFiles(x86)%\Python
                                                                           X.Y’
                                                                           
                                                                           
DefaultJustForMeTargetDir       自分一人用インストールのためのデフォルト   ‘%LocalAppData%\Programs\Python\PythonXY’
                                インストール先ディレクトリ。               または
                                                                           ‘%LocalAppData%\Programs\Python\PythonXY-32’
                                                                           または
                                                                           ‘%LocalAppData%\Programs\Python\PythonXY-64’
                                                                           
                                                                           
DefaultCustomTargetDir          カスタムインストールディレクトリとしてデ   (空)
                                フォルトで GUI に表示される値。            
                                
                                                                           
AssociateFiles                  ランチャもインストールする場合に、ファイ   1
                                ルの関連付けを行う。                       
                                
                                                                           
CompileAll                      すべての ‘.py’ ファイルをバイトコンパイ    0
                                ルして ‘.pyc’ を作る。                     
                                
                                                                           
PrependPath                     ‘PATH’ にインストールディレクトリと        0
                                Scripts ディレクトリを先頭に追加し、       
                                ‘PATHEXT’ に ‘.PY’ を追加する。
                                
                                                                           
AppendPath                      ‘PATH’ にインストールディレクトリと        0
                                Scripts ディレクトリを追加し、 ‘PATHEXT’   
                                に ‘.PY’ を追加する。
                                
                                                                           
Shortcuts                       インストールするインタプリタ、ドキュメン   1
                                ト、IDLE へのショートカットを作る。        
                                
                                                                           
Include_doc                     Python マニュアルをインストールする。      1
                                                                           
                                                                           
Include_debug                   デバッグバイナリをインストールする。       0
                                                                           
                                                                           
Include_dev                     開発者用ヘッダーとライブラリをインストー   1
                                ルする。これを省略すると、使用不可能なイ   
                                ンストールになる可能性があります。
                                
                                                                           
Include_exe                     ‘python.exe’ と関連するファイルをインス    1
                                トールする。これを省略すると、使用不可能   
                                なインストールになる可能性があります。
                                
                                                                           
Include_launcher                *note Windows の Python ランチャ: 588. を  1
                                インストールする。                         
                                
                                                                           
InstallLauncherAllUsers         すべてのユーザーにランチャーをインストー   1
                                ルする。 ‘Include_launcher’ が 1 に設定    
                                されている必要があります。
                                
                                                                           
Include_lib                     標準ライブラリと拡張モジュールをインスト   1
                                ールする。これを省略すると、使用不可能な   
                                インストールになる可能性があります。
                                
                                                                           
Include_pip                     バンドル版の pip と setuptools をインス    1
                                トールする。                               
                                
                                                                           
Include_symbols                 デバッグシンボル (‘*.pdb’) をインストー    0
                                ルする。                                   
                                
                                                                           
Include_tcltk                   Tcl/Tk サポートと IDLE をインストールす    1
                                る。                                       
                                
                                                                           
Include_test                    標準ライブラリのテストスイートをインスト   1
                                ールする。                                 
                                
                                                                           
Include_tools                   ユーティリティスクリプトをインストールす   1
                                る。                                       
                                
                                                                           
LauncherOnly                    ランチャのみをインストールする。これは他   0
                                のほとんどのオプションを上書きします。     
                                
                                                                           
SimpleInstall                   最大限のインストーラ GUI を無効にする。    0
                                                                           
                                                                           
SimpleInstallDescription        単純化されたインストーラ GUI を使う際に    (空)
                                表示するカスタムメッセージ。               
                                

例えばデフォルトでシステムワイドな Python インストレーションを静かに行う
には、以下コマンドを使えます (コマンドプロンプトより):

     python-3.9.0.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0

テストスイートなしの Python のパーソナルなコピーのインストールをユーザに
簡単に行わせるには、以下コマンドのショートカットを作れば良いです。これは
インストーラの最初のページを単純化して表示し、また、カスタマイズできない
ようにします:

     python-3.9.0.exe InstallAllUsers=0 Include_launcher=0 Include_test=0
         SimpleInstall=1 SimpleInstallDescription="Just for me, no test suite."

(ランチャのインストールを省略するとファイルの関連付けも省略されるので、
これはランチャインストールを含めたシステムワイドなインストールをした場合
のユーザごとインストールに限った場合のお勧めです。)

上でリストしたオプションは、実行ファイルと同じ場所の ‘unattend.xml’ と名
付けられたファイルで与えることもできます。このファイルはオプションとその
値のリストを指定します。値がアトリビュートとして与えられた場合、それは数
値であれば数値に変換されます。エレメントテキストで与える場合は常に文字列
のままです。以下は、先の例と同じオプションをセットするファイルの実例です
:

     <Options>
         <Option Name="InstallAllUsers" Value="no" />
         <Option Name="Include_launcher" Value="0" />
         <Option Name="Include_test" Value="no" />
         <Option Name="SimpleInstall" Value="yes" />
         <Option Name="SimpleInstallDescription">Just for me, no test suite</Option>
     </Options>


File: python.info,  Node: ダウンロード不要なインストール,  Next: インストール後の変更,  Prev: インストーラの GUI なしでインストールする,  Up: 完全版インストーラ

3.4.1.4 ダウンロード不要なインストール
......................................

Python のいくつかの機能は最初にダウンロードしたインストーラには含まれて
いないため、それらの機能をインストールしようと選択するとインターネット接
続が必要になります。 インターネット接続が必要にならないように、全てのコ
ンポーネントをすぐにできる限りダウンロードして、完全な '配置構成
(layout)' を作成し、どんな機能が選択されたかに関わらず、それ以上インター
ネット接続を必要がないようにします。 この方法のダウンロードサイズは必要
以上に大きくなるかもしれませんが、たくさんの回数インストールしようとする
場合には、ローカルにキャッシュされたコピーを持つことはとても有用です。

コマンドプロンプトから以下のコマンドを実行して、必要なファイルをできる限
り全てダウンロードします。 ‘python-3.9.0.exe’ 部分は実際のインストーラの
名前に置き換え、同名のファイルどうしの衝突が起こらないように、個別のディ
レクトリ内に配置構成を作るのを忘れないようにしてください。

     python-3.9.0.exe /layout [optional target directory]

進捗表示を隠すのに ‘/quiet’ オプションを指定することもできます。


File: python.info,  Node: インストール後の変更,  Next: フリースレッドバイナリ Free-threaded Binaries のインストール,  Prev: ダウンロード不要なインストール,  Up: 完全版インストーラ

3.4.1.5 インストール後の変更
............................

いったん Python がインストールされたら、Windows のシステム機能の「プログ
ラムと機能」ツールから機能の追加や削除ができます。Python のエントリを選
択して「アンインストールと変更」を選ぶことで、インストーラをメンテナンス
モードで開きます。

インストーラ GUI で "Modify" を選ぶと、チェックボックスの選択を変えるこ
とで機能の追加削除ができます - チェックボックスの選択を変えなければ、何
かがインストールされたり削除されたりはしません。いくつかのオプションはこ
のモードでは変更することはできません。インストールディレクトリなどです。
それらを変えたいのであれば、完全に削除してから再インストールする必要があ
ります。

"Repair" では、現在の設定で本来インストールされるべきすべてのファイルを
検証し、削除されていたり更新されていたりするファイルを修正します。

"Uninstall" は Python を完全に削除します。「プログラムと機能」内の自身の
エントリを持つ *note Windows の Python ランチャ: 588. の例外が起こります
。


File: python.info,  Node: フリースレッドバイナリ Free-threaded Binaries のインストール,  Prev: インストール後の変更,  Up: 完全版インストーラ

3.4.1.6 フリースレッドバイナリ (Free-threaded Binaries) のインストール
......................................................................

Added in version 3.13: (実験的)

     注釈: このセクションで説明されているすべての項目は実験的とみなされ
     ており、将来のリリースで変更される可能性があります。

To install pre-built binaries with free-threading enabled (see PEP
703(1)), you should select "Customize installation".  The second page of
options includes the "Download free-threaded binaries" checkbox.

[image src="python-figures/win_install_freethreaded.png"]


Selecting this option will download and install additional binaries to
the same location as the main Python install.  The main executable is
called ‘python3.13t.exe’, and other binaries either receive a ‘t’ suffix
or a full ABI suffix.  Python source files and bundled third-party
dependencies are shared with the main install.

The free-threaded version is registered as a regular Python install with
the tag ‘3.13t’ (with a ‘-32’ or ‘-arm64’ suffix as normal for those
platforms).  This allows tools to discover it, and for the *note Windows
の Python ランチャ: 588. to support ‘py.exe -3.13t’.  Note that the
launcher will interpret ‘py.exe -3’ (or a ‘python3’ shebang) as "the
latest 3.x install", which will prefer the free-threaded binaries over
the regular ones, while ‘py.exe -3.13’ will not.  If you use the short
style of option, you may prefer to not install the free-threaded
binaries at this time.

To specify the install option at the command line, use
‘Include_freethreaded=1’.  See *note ダウンロード不要なインストール:
1d76. for instructions on pre-emptively downloading the additional
binaries for offline install.  The options to include debug symbols and
binaries also apply to the free-threaded builds.

Free-threaded binaries are also available *note on nuget.org: 1d72.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0703/


File: python.info,  Node: Microsoft ストアパッケージ,  Next: nuget org パッケージ,  Prev: 完全版インストーラ,  Up: Windows で Python を使う

3.4.2 Microsoft ストアパッケージ
--------------------------------

Added in version 3.7.2.

Microsoft ストアパッケージは、例えば生徒が主に対話型で使うことを意図した
簡単にインストールできる Python インタプリタです。

このパッケージをインストールするには、最新の Windows 10 のアップデートに
なっていることを確認し、 Microsoft ストアアプリで "Python 3.13" と検索し
ます。 選んだアプリが Python Software Foundation が公開したものであるこ
とを確認して、インストールします。

     警告: Python は常に Microsoft ストアで無料で利用できます。 もしお金
     を払うように要求されたなら、正しいパッケージを選んでいません。

インストールした後は、スタートメニューから Python を見付けて起動するでし
ょう。 あるいは、 ‘python’ とタイプしてコマンドプロンプトや PowerShell の
セッションから使えるでしょう。 さらに、 ‘pip’ や ‘idle’ とタイプして pip
あるいは IDLE を利用できます。 IDLE はスタートメニューからも見付けられま
す。

All three commands are also available with version number suffixes, for
example, as ‘python3.exe’ and ‘python3.x.exe’ as well as ‘python.exe’
(where ‘3.x’ is the specific version you want to launch, such as 3.13).
Open "Manage App Execution Aliases" through Start to select which
version of Python is associated with each command.  It is recommended to
make sure that ‘pip’ and ‘idle’ are consistent with whichever version of
‘python’ is selected.

仮想環境は ‘python -m venv’ で作成し、有効化して普通に使えます。

既に別のバージョンの Python をインストールして ‘PATH’ 変数に追加してある
場合は、 Microsoft ストアのものではない ‘python.exe’ として使えます。 新
しくインストールした Python にアクセスするには、 ‘python3.exe’ あるいは
‘python3.x.exe’ として使えます。

‘py.exe’ ランチャーはこの Python のインストールを見つけますが、従来のイ
ンストーラーによるインストールを優先します。

Python を除去するには、「設定」を開き「アプリと機能」を使うか、「スター
ト」にある Python を右クリックしてアンインストールします。 アンインスト
ールでは、この Python に直接インストールした全てのパッケージが除去されま
すが、仮想環境はどれも除去されません。

* Menu:

* 既知の問題::


File: python.info,  Node: 既知の問題,  Up: Microsoft ストアパッケージ

3.4.2.1 既知の問題
..................

* Menu:

* Redirection of local data, registry, and temporary paths: Redirection of local data registry and temporary paths.


File: python.info,  Node: Redirection of local data registry and temporary paths,  Up: 既知の問題

3.4.2.2 Redirection of local data, registry, and temporary paths
................................................................

Microsoft ストアアプリの制限により、 Python スクリプトには ‘TEMP’ やレジ
ストリのような共有の場所への完全な書き込み権限は無いでしょう。 その代わ
り、個人用のところへ書き込みます。 スクリプトで共有の場所で変更しなけれ
ばならない場合は、完全版のインストーラでインストールする必要があります。

At runtime, Python will use a private copy of well-known Windows folders
and the registry.  For example, if the environment variable ‘%APPDATA%’
is ‘c:\Users\<user>\AppData\’, then when writing to
‘C:\Users\<user>\AppData\Local’ will write to
‘C:\Users\<user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\Local\’.

When reading files, Windows will return the file from the private
folder, or if that does not exist, the real Windows directory.  For
example reading ‘C:\Windows\System32’ returns the contents of
‘C:\Windows\System32’ plus the contents of ‘C:\Program
Files\WindowsApps\package_name\VFS\SystemX86’.

You can find the real path of any existing file using *note
os.path.realpath(): 206.:

     >>> import os
     >>> test_file = 'C:\\Users\\example\\AppData\\Local\\test.txt'
     >>> os.path.realpath(test_file)
     'C:\\Users\\example\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\Local\\test.txt'

When writing to the Windows Registry, the following behaviors exist:

   * Reading from ‘HKLM\\Software’ is allowed and results are merged
     with the ‘registry.dat’ file in the package.

   * Writing to ‘HKLM\\Software’ is not allowed if the corresponding
     key/value exists, i.e.  modifying existing keys.

   * Writing to ‘HKLM\\Software’ is allowed as long as a corresponding
     key/value does not exist in the package and the user has the
     correct access permissions.

For more detail on the technical basis for these limitations, please
consult Microsoft's documentation on packaged full-trust apps, currently
available at
docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes(1)

   ---------- Footnotes ----------

   (1) 
https://learn.microsoft.com/windows/msix/desktop/desktop-to-uwp-behind-the-scenes


File: python.info,  Node: nuget org パッケージ,  Next: 埋め込み可能なパッケージ,  Prev: Microsoft ストアパッケージ,  Up: Windows で Python を使う

3.4.3 nuget.org パッケージ
--------------------------

Added in version 3.5.2.

nuget.org パッケージはサイズを縮小した Python 環境で、システム全体で使え
る Python が無い継続的インテグレーションやビルドシステムで使うことを意図
しています。 nuget は ".NET のためのパッケージマネージャ" ですが、ビルド
時に使うツールを含んだパッケージに対しても非常に上手く動作します。

nuget の使用方法についての最新の情報を得るには nuget.org(1) に行ってくだ
さい。 ここから先は Python 開発者にとって十分な要約です。

‘nuget.exe’ コマンドラインツールは、例えば curl や PowerShell を使って
‘https://aka.ms/nugetclidl’ から直接ダウンロードできるでしょう。 このツ
ールを次のように使って、 64 bit あるいは 32 bit のマシン向けの最新バージ
ョンの Python がインストールできます:

     nuget.exe install python -ExcludeVersion -OutputDirectory .
     nuget.exe install pythonx86 -ExcludeVersion -OutputDirectory .

特定のバージョンを選択するには、 ‘-Version 3.x.y’ を追加してください。 出
力ディレクトリは ‘.’ から変更されることがあり、パッケージはサブディレク
トリにインストールされます。 デフォルトではサブディレクトリはパッケージ
と同じ名前になり、 ‘-ExcludeVersion’ オプションを付けないとこの名前はイ
ンストールされたバージョンを含みます。 サブディレクトリの中にはインスト
ールされた Python を含んでいる ‘tools’ ディレクトリがあります:

     # Without -ExcludeVersion
     > .\python.3.5.2\tools\python.exe -V
     Python 3.5.2

     # With -ExcludeVersion
     > .\python\tools\python.exe -V
     Python 3.5.2

一般的には、 nuget パッケージはアップグレードできず、より新しいバージョ
ンは横並びにインストールされ、フルパスで参照されます。 そうする代わりに
、手動で直接パッケージを削除し、再度インストールすることもできます。 多
くの CI システムは、ビルド間でファイルを保存しておかない場合、この作業を
自動的に行います。

‘tools’ ディレクトリと同じ場所に ‘build\native’ ディレクトリがあります。
このディレクトリは、インストールされた Python を参照する C++ プロジェク
トで使える MSBuild プロパティファイル ‘python.props’ を含みます。 ここに
設定を入れると自動的にヘッダを使い、ビルド時にライプラリをインポートしま
す。

The package information pages on nuget.org are
www.nuget.org/packages/python(2) for the 64-bit version,
www.nuget.org/packages/pythonx86(3) for the 32-bit version, and
www.nuget.org/packages/pythonarm64(4) for the ARM64 version

* Menu:

* フリースレッドパッケージ (Free-threaded packages): フリースレッドパッケージ Free-threaded packages.

   ---------- Footnotes ----------

   (1) https://www.nuget.org/

   (2) https://www.nuget.org/packages/python

   (3) https://www.nuget.org/packages/pythonx86

   (4) https://www.nuget.org/packages/pythonarm64


File: python.info,  Node: フリースレッドパッケージ Free-threaded packages,  Up: nuget org パッケージ

3.4.3.1 フリースレッドパッケージ (Free-threaded packages)
.........................................................

Added in version 3.13: (実験的)

     注釈: このセクションで説明されているすべての項目は実験的とみなされ
     ており、将来のリリースで変更される可能性があります。

フリースレッドバイナリ (free-threaded binaries) を含むパッケージは、
64-bit 版では python-freethreaded(1) 、 32-bit 版では
pythonx86-freethreaded(2) 、 ARM64 版では pythonarm64-freethreaded(3) と
命名されます。これらのパッケージはともに ‘python3.13t.exe’ と
‘python.exe’ エントリーポイントを含み、どちらもフリースレッドで実行され
ます。

   ---------- Footnotes ----------

   (1) https://www.nuget.org/packages/python-freethreaded

   (2) https://www.nuget.org/packages/pythonx86-freethreaded

   (3) https://www.nuget.org/packages/pythonarm64-freethreaded


File: python.info,  Node: 埋め込み可能なパッケージ,  Next: 別のバンドル,  Prev: nuget org パッケージ,  Up: Windows で Python を使う

3.4.4 埋め込み可能なパッケージ
------------------------------

Added in version 3.5.

埋め込み用の配布 (embedded distribution) は、最小限の Python 環境を含ん
だ ZIP ファイルです。これは、エンドユーザから直接的にアクセスされるので
はなく何かアプリケーションの一部として動作することを意図したものです。

展開されると、埋め込み用の配布は、環境変数、システムレジストリの設定、イ
ンストールされているパッケージといったユーザのシステムから (ほぼ) 完全に
独立しています。 ZIP 内には標準ライブラリがプリコンパイルにより最適化さ
れた ‘.pyc’ として含まれ、また、 ‘python3.dll’, ‘python37.dll’,
‘python.exe’, ‘pythonw.exe’ のすべてが入っています。(IDLE のようなすべて
の依存物を含む) Tcl/tk、pip、Python ドキュメントは含まれていません。

     注釈: The embedded distribution does not include the Microsoft C
     Runtime(1) and it is the responsibility of the application
     installer to provide this.  The runtime may have already been
     installed on a user's system previously or automatically via
     Windows Update, and can be detected by finding ‘ucrtbase.dll’ in
     the system directory.

サードパーティのパッケージはアプリケーションのインストーラによって、埋め
込み用配布と同じ場所にインストールされるべきです。通常の Python インスト
レーションのように依存性管理に pip を使うことは、この配布ではサポートさ
れません。ですが、ちょっとした注意を払えば、自動更新のために pip を含め
て利用することはできるかもしれません。一般的には、ユーザに更新を提供する
前に開発者が新しいバージョンとの互換性を保証できるよう、サードパーティー
のパッケージはアプリケーションの一部として扱われるべきです
("vendoring")。

この配布の 2 つのお勧めできるユースケースを、以下で説明します。

* Menu:

* Python アプリケーション::
* Python の埋め込み::

   ---------- Footnotes ----------

   (1) 
https://learn.microsoft.com/cpp/windows/latest-supported-vc-redist#visual-studio-2015-2017-2019-and-2022


File: python.info,  Node: Python アプリケーション,  Next: Python の埋め込み,  Up: 埋め込み可能なパッケージ

3.4.4.1 Python アプリケーション
...............................

Python で記述された、必ずしもユーザにその事実を意識させる必要のないアプ
リケーションです。埋め込み用配布はこのケースで、インストールパッケージ内
に Python のプライベートバージョンを含めるのに使えるでしょう。その事実が
どのように透過的であるべきかに依存して (あるいは逆に、どのようにプロフェ
ッショナルにみえるべきか)、2 つの選択肢があります。

ランチャとなる特別な実行ファイルを使うことはちょっとしたコーディングを必
要としますが、ユーザにとっては最も透過的なユーザ体験となります。カスタマ
イズされたランチャでは、何もしなければ Python で実行されるプログラムの明
白な目印はありません; アイコンはカスタマイズし、会社名やバージョン情報を
指定し、ファイルの関連付けがそれに相応しく振舞うようにできます。ほとんど
のケースではカスタムランチャは、ハードコードされたコマンドライン文字列で
単純に ‘Py_Main’ を呼び出すので済むはずです。

より簡単なアプローチは、 ‘python.exe’ または ‘pythonw.exe’ を必要なコマ
ンドライン引数とともに直接呼び出すバッチファイルかショートカットを提供す
ることです。この場合、そのアプリケーションは実際の名前ではなく Python で
あるようにみえるので、ほかに動作している Python プロセスやファイルの関連
付けと区別するのにユーザが困るかもしれません。

後者のアプローチではパッケージは、パス上で利用可能であることを保証するた
めに、Python 実行ファイルと同じディレクトリにインストールされるべきです
。特別なランチャの場合はアプリケーション起動前に検索パスを指定する機会が
あるので、パッケージはほかの場所に配置できます。


File: python.info,  Node: Python の埋め込み,  Prev: Python アプリケーション,  Up: 埋め込み可能なパッケージ

3.4.4.2 Python の埋め込み
.........................

ネイティブコードで書かれ、時々スクリプト言語のようなものを必要とするよう
なアプリケーションです。Python 埋め込み用の配布はこの目的に使えます。一
般的に、アプリケーションの大半がネイティブコード内にあり、一部が
‘python.exe’ を呼び出すか、直接的に ‘python3.dll’ を使います。どちらのケ
ースでも、ロード可能な Python インタプリタを提供するのには、埋め込み用の
配布を展開してアプリケーションのインストレーションのサブディレクトリに置
くことで十分です。

アプリケーションが使うパッケージは、インタプリタ初期化前に検索パスを指定
する機会があるので、任意の場所にインストールできます。また、埋め込み用配
布を使うのと通常の Python インストレーションを使うのとでの根本的な違いは
ありません。


File: python.info,  Node: 別のバンドル,  Next: Python を構成する<2>,  Prev: 埋め込み可能なパッケージ,  Up: Windows で Python を使う

3.4.5 別のバンドル
------------------

標準の CPython の配布物の他に、追加の機能を持っている修正されたパッケー
ジがあります。以下は人気のあるバージョンとそのキーとなる機能です:

ActivePython(1)

     マルチプラットフォーム互換のインストーラー、ドキュメント、 PyWin32

Anaconda(2)

     人気のある (numpy, scipy や pandas のような) 科学系モジュールと、パ
     ッケージマネージャ ‘conda’ 。

Enthought Deployment Manager(3)

     "次世代の Python 環境とパッケージマネージャー" ("The Next
     Generation Python Environment and Package Manager")。

     以前は Enthought が Canopy を提供していましたが、これは 2016 年にサ
     ポートが終了しました(4)。

WinPython(5)

     ビルド済みの科学系パッケージと、パッケージのビルドのためのツールを
     含む、Windows 固有のディストリビューション。

これらパッケージは Python や他のライブラリの最新バージョンが含まれるとは
限りませんし、コア Python チームはこれらを保守もしませんしサポートもしま
せんのでご理解ください。

   ---------- Footnotes ----------

   (1) https://www.activestate.com/products/python/

   (2) https://www.anaconda.com/download/

   (3) https://assets.enthought.com/downloads/edm/

   (4) 
https://support.enthought.com/hc/en-us/articles/360038600051-Canopy-GUI-end-of-life-transition-to-the-Enthought-Deployment-Manager-EDM-and-Visual-Studio-Code

   (5) https://winpython.github.io/


File: python.info,  Node: Python を構成する<2>,  Next: UTF-8 モード,  Prev: 別のバンドル,  Up: Windows で Python を使う

3.4.6 Python を構成する
-----------------------

コマンドプロンプトより便利に Python を実行するために、Windows のデフォル
トの環境変数をいくつか変えたいと思うかもしれません。インストーラは
‘PATH’ と ‘PATHEXT’ 変数を構成させるオプションを提供してはいますが、これ
は単独のシステムワイドなインストレーションの場合にだけ頼りになるものです
。もしもあなたが定常的に複数バージョンの Python を使うのであれば、 *note
Windows の Python ランチャ: 588. の利用を検討してください。

* Menu:

* 補足; 環境変数の設定: 補足 環境変数の設定.
* Python 実行ファイルを見つける::


File: python.info,  Node: 補足 環境変数の設定,  Next: Python 実行ファイルを見つける,  Up: Python を構成する<2>

3.4.6.1 補足: 環境変数の設定
............................

Windows では、環境変数を恒久的にユーザレベルとシステムレベルの両方で設定
でき、あるいはコマンドプロンプトから一時的にも設定できます。

一時的に環境変数を設定するには、コマンドプロンプトを開き ‘set’ コマンド
を使います:

     C:\>set PATH=C:\Program Files\Python 3.9;%PATH%
     C:\>set PYTHONPATH=%PYTHONPATH%;C:\My_python_lib
     C:\>python

これらの変更は、以降に実行される同じコンソール内で実行される任意のコマン
ドに適用され、また、そのコンソールから開始するすべてのアプリケーションに
引き継がれます。

パーセント記号で変数名を囲んだものは既存の変数の値で展開されるので、新し
い値を最初にも最後にも追加することができます。 ‘python.exe’ が入っている
ディレクトリを ‘PATH’ に追加することは、Python の適切なバージョンが起動
するように保証するための一般的な方法です。

デフォルトの環境変数を恒久的に変更するには、「スタート」をクリックして検
索ボックスで「環境変数を編集」を検索するか、(コンピュータのプロパティな
どから) システムの詳細設定 を開いて 環境変数の設定 ボタンをクリックして
ください。これで立ち上がるダイアログで、ユーザ環境変数とシステム環境変数
を追加したり修正したりできます。システム変数を変更するにはあなたのマシン
への制限のないアクセス (つまり管理者権限) が必要です。

     注釈: Windows はシステム変数の '後ろに' ユーザ変数を結合します。こ
     の振る舞いにより ‘PATH’ の修正時に期待とは異なる結果になることがあ
     ります。

     *note PYTHONPATH: fe8. 変数は Python のすべてのバージョンで使われる
     ので、インストールされているすべての Python バージョンに互換性のあ
     るコードだけがパスの一覧に含まれているのでない限り、これは恒久的な
     設定をすべきではありません。

参考
....

‘https://learn.microsoft.com/windows/win32/procthread/environment-variables’

     Windows の環境変数の概要

‘https://learn.microsoft.com/windows-server/administration/windows-commands/set_1’

     一時的に環境変数を変更するための ‘set’ コマンドについて

‘https://learn.microsoft.com/windows-server/administration/windows-commands/setx’

     恒久的に環境変数を変更するための ‘setx’ コマンドについて。


File: python.info,  Node: Python 実行ファイルを見つける,  Prev: 補足 環境変数の設定,  Up: Python を構成する<2>

3.4.6.2 Python 実行ファイルを見つける
.....................................

バージョン 3.5 で変更.

自動的に作成される Python インタープリタのスタートメニュー項目を使うだけ
でなく、Python をコマンドプロンプトから起動したいと思うかもしれません。
インストーラにはそのための設定を行うオプションがあります。

インストーラの最初のページに "Add Python to PATH" というラベルのオプショ
ンがあり、これを選択するとインストーラはインストール場所を環境変数
‘PATH’ に追加します。 ‘Scripts\’ フォルダの場所も追加されます。 これによ
りコマンドプロンプトから ‘python’ とタイプしてインタプリタを起動したり、
‘pip’ とタイプしてパッケージインストーラを起動したりできます。 コマンド
ラインからの起動なので、スクリプトをコマンドライン引数付きで起動すること
もできます。 *note コマンドライン: fd2. の文章を参照して下さい。

インストール時にこのオプションを有効にしていなかったとしても、インストー
ラを再度実行して「Modify」を選んで、それを有効にし直せます。あるいはそう
せずとも、 ‘PATH’ 変数は手動で修正できます。 *note 補足; 環境変数の設定:
1b52. を参照してください。環境変数 ‘PATH’ には Python インストールディレ
クトリを含む必要があります。ほかのエントリとはセミコロンで区切って繋いで
ください。これの実例は以下のようになります (以下最初の 2 つのエントリは
既に存在しているものと仮定しています):

     C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Python 3.9


File: python.info,  Node: UTF-8 モード,  Next: Windows の Python ランチャ,  Prev: Python を構成する<2>,  Up: Windows で Python を使う

3.4.7 UTF-8 モード
------------------

Added in version 3.7.

Windows still uses legacy encodings for the system encoding (the ANSI
Code Page).  Python uses it for the default encoding of text files (e.g.
*note locale.getencoding(): 2be.).

This may cause issues because UTF-8 is widely used on the internet and
most Unix systems, including WSL (Windows Subsystem for Linux).

You can use the *note Python UTF-8 Mode: 622. to change the default text
encoding to UTF-8.  You can enable the *note Python UTF-8 Mode: 622. via
the ‘-X utf8’ command line option, or the ‘PYTHONUTF8=1’ environment
variable.  See *note PYTHONUTF8: aa6. for enabling UTF-8 mode, and *note
補足; 環境変数の設定: 1b52. for how to modify environment variables.

When the *note Python UTF-8 Mode: 622. is enabled, you can still use the
system encoding (the ANSI Code Page) via the "mbcs" codec.

Note that adding ‘PYTHONUTF8=1’ to the default environment variables
will affect all Python 3.7+ applications on your system.  If you have
any Python 3.7+ applications which rely on the legacy system encoding,
it is recommended to set the environment variable temporarily or use the
‘-X utf8’ command line option.

     注釈: Even when UTF-8 mode is disabled, Python uses UTF-8 by
     default on Windows for:

        * Console I/O including standard I/O (see PEP 528(1) for
          details).

        * The *note filesystem encoding: 505. (see PEP 529(2) for
          details).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0528/

   (2) https://peps.python.org/pep-0529/


File: python.info,  Node: Windows の Python ランチャ,  Next: モジュールの検索,  Prev: UTF-8 モード,  Up: Windows で Python を使う

3.4.8 Windows の Python ランチャ
--------------------------------

Added in version 3.3.

Windows の Python ランチャは、異なる Python のバージョンの位置の特定と実
行を助けるユーティリティです。スクリプト (またはコマンドライン) で特定の
Python のバージョンの設定を与えられると、位置を特定し、そのバージョンを
実行します。

環境変数 ‘PATH’ による方法と違って、このランチャは Python の一番適切なバ
ージョンを、正しく選択します。このランチャはシステムワイドなものよりもユ
ーザごとのインストレーションの方を優先し、また、新しくインストールされた
順よりも言語のバージョンを優先します。

ランチャのオリジナルの仕様は PEP 397(1) にあります。

* Menu:

* 最初に::
* シェバン (shebang) 行: シェバン shebang 行.
* シェバン行の引数::
* カスタマイズ::
* 診断::
* Dry Run::
* Install on demand::
* Return codes::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0397/


File: python.info,  Node: 最初に,  Next: シェバン shebang 行,  Up: Windows の Python ランチャ

3.4.8.1 最初に
..............

* Menu:

* コマンドラインから起動する::
* 仮想環境 (Virtual environments): 仮想環境 Virtual environments.
* スクリプトから起動する::
* ファイルの関連付けから起動する::


File: python.info,  Node: コマンドラインから起動する,  Next: 仮想環境 Virtual environments,  Up: 最初に

3.4.8.2 コマンドラインから起動する
..................................

バージョン 3.6 で変更.

Python 3.3 とそれ以降のシステムワイドなインストールでは、ランチャーが
‘PATH’ に追加されます。ランチャーは、入手可能なあらゆる Python のバージ
ョンに互換性があるため、実際にどのバージョンの Python がインストールされ
ているのかは重要ではありません。ランチャーが使えるかを確認するには以下の
コマンドをコマンドプロンプトで実行してください:

     py

インストールされている最新バージョンの Python が起動するはずです。 通常
どおりに終了することもできますし、追加のコマンドライン引数を指定して直接
Python に渡すこともできます。

複数のバージョンの Python (たとえば 3.7 と 3.13) がインストールされてい
る場合は、Python 3.13 が起動することになります。Python 3.7 を起動したい
なら、次のコマンドを実行してみてください:

     py -3.7

インストールしてある Python 2 の最新バージョンを起動したい場合は、次のコ
マンドを実行してみてください:

     py -2

以下のようなエラーが出るようであれば、ランチャはインストールされていませ
ん:

     'py' is not recognized as an internal or external command,
     operable program or batch file.

このコマンド:

     py --list

これは、現在インストールされている Python のバージョンを表示します。

The ‘-x.y’ argument is the short form of the ‘-V:Company/Tag’ argument,
which allows selecting a specific Python runtime, including those that
may have come from somewhere other than python.org.  Any runtime
registered by following PEP 514(1) will be discoverable.  The ‘--list’
command lists all available runtimes using the ‘-V:’ format.

When using the ‘-V:’ argument, specifying the Company will limit
selection to runtimes from that provider, while specifying only the Tag
will select from all providers.  Note that omitting the slash implies a
tag:

     # Select any '3.*' tagged runtime
     py -V:3

     # Select any 'PythonCore' released runtime
     py -V:PythonCore/

     # Select PythonCore's latest Python 3 runtime
     py -V:PythonCore/3

The short form of the argument (‘-3’) only ever selects from core Python
releases, and not other distributions.  However, the longer form
(‘-V:3’) will select from any.

The Company is matched on the full string, case-insensitive.  The Tag is
matched on either the full string, or a prefix, provided the next
character is a dot or a hyphen.  This allows ‘-V:3.1’ to match ‘3.1-32’,
but not ‘3.10’.  Tags are sorted using numerical ordering (‘3.10’ is
newer than ‘3.1’), but are compared using text (‘-V:3.01’ does not match
‘3.1’).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0514/


File: python.info,  Node: 仮想環境 Virtual environments,  Next: スクリプトから起動する,  Prev: コマンドラインから起動する,  Up: 最初に

3.4.8.3 仮想環境 (Virtual environments)
.......................................

Added in version 3.5.

(標準ライブラリの *note venv: f9. モジュールか外部ツール ‘virtualenv’ で
作った) 仮想環境がアクティブな状態で Python の明示的なバージョンを指定せ
ずにランチャを起動すると、ランチャはグローバルなインタプリタではなくその
仮想環境のものを実行します。グローバルなほうのインタプリタを実行するには
、仮想環境の動作を停止するか、または明示的にグローバルな Python バージョ
ンを指定してください。


File: python.info,  Node: スクリプトから起動する,  Next: ファイルの関連付けから起動する,  Prev: 仮想環境 Virtual environments,  Up: 最初に

3.4.8.4 スクリプトから起動する
..............................

テスト用の Python スクリプトを作成しましょう。‘hello.py’ という名前で以
下の内容のファイルを作成してください

     #! python
     import sys
     sys.stdout.write("hello from Python %s\n" % (sys.version,))

hello.py が存在するディレクトリで、下記コマンドを実行してください:

     py hello.py

インストールされている最新の Python 2.x のバージョン番号が表示されるはず
です。では、1行目を以下のように変更してみてください:

     #! python3

コマンドを再実行すると、今度は最新の Python 3.x の情報が表示されるはずで
す。これまでのコマンドラインの例と同様に、より細かいバージョン修飾子を指
定することもできます。Python 3.7 がインストールされている場合、最初の行
を ‘#! python3.7’ に変更すると、3.7 のバージョン情報が表示されるはずです
。

コマンドからの呼び出しとは異なり、後ろに何もつかない "python" はインスト
ールされている Python2.x の最新バージョンを利用することに注意してくださ
い。これは後方互換性と、 ‘python’ が一般的に Python 2 を指すUnix との互
換性のためです。


File: python.info,  Node: ファイルの関連付けから起動する,  Prev: スクリプトから起動する,  Up: 最初に

3.4.8.5 ファイルの関連付けから起動する
......................................

インストール時に、ランチャは Python ファイル (すなわち ‘.py’, ‘.pyw’,
‘.pyc’ ファイル) に関連付けられたはずです。そのため、これらのファイルを
Windows のエクスプローラーでダブルクリックした際はランチャが使われ、上で
述べたのと同じ機能を使ってスクリプトが使われるべきバージョンを指定できる
ようになります。

このことによる重要な利点は、単一のランチャが先頭行の内容によって複数の
Python バージョンを同時にサポートできることです。


File: python.info,  Node: シェバン shebang 行,  Next: シェバン行の引数,  Prev: 最初に,  Up: Windows の Python ランチャ

3.4.8.6 シェバン (shebang) 行
.............................

スクリプトファイルの先頭の行が ‘#!’ で始まっている場合は、その行はシェバ
ン (shebang) 行として知られています。 Linux や他の Unix 系 OS はこうした
行をもともとサポートしているため、それらのシステムでは、スクリプトがどの
ように実行されるかを示すために広く使われます。 Windows の Python ランチ
ャは、Windows 上の Python スクリプトが同じ機能を使用できるようにし、上の
例ではそれらの機能の使用法を示しています。

Python スクリプトのシェバン行を Unix-Windows 間で移植可能にするため、こ
のランチャは、どのインタプリタが使われるかを指定するための大量の '仮想'
コマンドをサポートしています。サポートされる仮想コマンドには以下のものが
あります:

   * ‘/usr/bin/env’

   * ‘/usr/bin/python’

   * ‘/usr/local/bin/python’

   * ‘python’

具体的に、もしスクリプトの1行目が

     #! /usr/bin/python

で始まっていたら、デフォルトの Python またはアクティブな仮想環境の位置が
特定され、使用されます。多くの Unix 上で動作する Python スクリプトにはす
でにこの行が存在する傾向がありますので、ランチャによりそれらのスクリプト
を修正なしで使うことができるはずです。あなたが新しいスクリプトを Windows
上で書いていて、Unix 上でも有用であってほしいと思うなら、シェバン行のう
ち ‘/usr’ で始まるものを使用すべきです。

上記のどの仮想コマンドでも、(メジャーバージョンだけや、メジャー・マイナ
ーバージョンの両方で) 明示的にバージョンを指定できます。 さらに、 "-32"
をマイナーバージョンの後ろに追加して 32-bit 版を要求できます。 例えば、
‘/usr/bin/python3.7-32’ は 32-bit の Python 3.7 を使うよう要求します。仮
想環境がアクティブになっている場合は、バージョンは無視され、その環境が使
用されます。

Added in version 3.7: python ランチャの 3.7 からは、末尾に "-64" を付け
て 64-bit 版を要求できます。 さらに、マイナーバージョン無しのメジャーバ
ージョンとアーキテクチャだけ (例えば、 ‘/usr/bin/python3-64’) で指定でき
ます。

バージョン 3.11 で変更: The "-64" suffix is deprecated, and now implies
"any architecture that is not provably i386/32-bit".  To request a
specific environment, use the new ‘-V:TAG’ argument with the complete
tag.

バージョン 3.13 で変更: Virtual commands referencing ‘python’ now prefer
an active virtual environment rather than searching ‘PATH’.  This
handles cases where the shebang specifies ‘/usr/bin/env python3’ but
‘python3.exe’ is not present in the active environment.

The ‘/usr/bin/env’ form of shebang line has one further special
property.  Before looking for installed Python interpreters, this form
will search the executable ‘PATH’ for a Python executable matching the
name provided as the first argument.  This corresponds to the behaviour
of the Unix ‘env’ program, which performs a ‘PATH’ search.  If an
executable matching the first argument after the ‘env’ command cannot be
found, but the argument starts with ‘python’, it will be handled as
described for the other virtual commands.  The environment variable
‘PYLAUNCHER_NO_SEARCH_PATH’ may be set (to any value) to skip this
search of ‘PATH’.

Shebang lines that do not match any of these patterns are looked up in
the ‘[commands]’ section of the launcher's *note .INI file: 1d91.  This
may be used to handle certain commands in a way that makes sense for
your system.  The name of the command must be a single argument (no
spaces in the shebang executable), and the value substituted is the full
path to the executable (additional arguments specified in the .INI will
be quoted as part of the filename).

     [commands]
     /bin/xpython=C:\Program Files\XPython\python.exe

Any commands not found in the .INI file are treated as 'Windows'
executable paths that are absolute or relative to the directory
containing the script file.  This is a convenience for Windows-only
scripts, such as those generated by an installer, since the behavior is
not compatible with Unix-style shells.  These paths may be quoted, and
may include multiple arguments, after which the path to the script and
any additional arguments will be appended.


File: python.info,  Node: シェバン行の引数,  Next: カスタマイズ,  Prev: シェバン shebang 行,  Up: Windows の Python ランチャ

3.4.8.7 シェバン行の引数
........................

シェバン行では Python インタプリタに渡される追加の引数を指定することもで
きます。たとえば、シェバン行に以下のように書かれているとしましょう:

     #! /usr/bin/python -v

この場合、Python は ‘-v’ オプション付きで起動するでしょう


File: python.info,  Node: カスタマイズ,  Next: 診断,  Prev: シェバン行の引数,  Up: Windows の Python ランチャ

3.4.8.8 カスタマイズ
....................

* Menu:

* INI ファイルによるカスタマイズ::
* デフォルトのPythonバージョンのカスタマイズ::


File: python.info,  Node: INI ファイルによるカスタマイズ,  Next: デフォルトのPythonバージョンのカスタマイズ,  Up: カスタマイズ

3.4.8.9 INI ファイルによるカスタマイズ
......................................

ランチャは2つの .ini ファイルを探しに行きます。具体的には、現在のユーザ
ーのアプリケーションデータディレクトリ (‘%LOCALAPPDATA%’ または
‘$env:LocalAppData’) の ‘py.ini’ と、ランチャと同じディレクトリにある
‘py.ini’ です。'コンソール' 版のランチャ (つまり py.exe) と 'Windows' 版
のランチャ (つまり pyw.exe) は同一の .ini ファイルを使用します。

"application data" ディレクトリで指定された設定は、実行ファイルの隣にあ
るものより優先されます。そのため、ランチャの隣にある .ini ファイルへの書
き込みアクセスができないユーザは、グローバルな .ini ファイル内のコマンド
を上書き (override) できます。


File: python.info,  Node: デフォルトのPythonバージョンのカスタマイズ,  Prev: INI ファイルによるカスタマイズ,  Up: カスタマイズ

3.4.8.10 デフォルトのPythonバージョンのカスタマイズ
...................................................

どのバージョンの Python をコマンドで使用するかを定めるため、バージョン修
飾子がコマンドに含められることがあります。 バージョン修飾子はメジャーバ
ージョン番号で始まり、オプションのピリオド ('.')  とマイナーバージョン指
定子がそれに続きます。 さらに、 "-32" や "-64" を追記して 32-bit あるい
は 64-bit のどちらの実装が要求されるかを指示できます。

たとえば、‘#!python’ というシェバン行はバージョン修飾子を含みませんが、
‘#!python3’ はメジャーバージョンを指定するバージョン修飾子を含みます。

コマンドにバージョン修飾子が見つからない場合、環境変数 ‘PY_PYTHON’ を設
定して、デフォルトのバージョン修飾子を指定できます。 設定されていない場
合、デフォルト値は "3" です。 この変数には "3", "3.7", "3.7-32",
"3.7-64" のような任意の値をコマンドラインから指定できます。 ("-64" オプ
ションは Python 3.7 以降のランチャでしか使えないことに注意してください。
)

マイナーバージョン修飾子が見つからない場合、環境変数 ‘PY_PYTHON{major}’
(ここで ‘{major}’ は、上記で決定された現在のメジャーバージョン修飾子) を
設定して完全なバージョンを指定することができます。そういったオプションが
見つからなければ、ランチャはインストール済みの Python バージョンを列挙し
て、見つかったそのメジャーバージョン向けマイナーリリースのうち最新のもの
を使用します。保証されているわけではありませんが、通常はそのメジャーバー
ジョン系で最も後にインストールしたバージョンになります。

64-bit Windows で、同一の (major.minor) Python バージョンの 32-bit と
64-bit の両方の実装がインストールされていた場合、64-bit バージョンのほう
が常に優先されます。これはランチャが 32-bit と 64-bit のどちらでも言える
ことで、32-bit のランチャは、指定されたバージョンが使用可能であれば、
64-bit の Python を優先して実行します。これは、どのバージョンが PC にイ
ンストールされているかのみでランチャの挙動を予見でき、それらがインストー
ルされた順番に関係なくなる (つまり最後にインストールされた Python とラン
チャが 32-bit か 64-bit かを知らなくともよい) ようにするためです。上に記
したとおり、オプションの "-32", "-64" サフィックスでこの挙動を変更できま
す。

例:

   * 関連するオプションが設定されていない場合、‘python’ および ‘python2’
     コマンドはインストールされている最新の Python 2.x バージョンを使用
     し、‘python3’ コマンドはインストールされている最新の Python 3.x を
     使用します。

   * ‘python3.7’ コマンドは、バージョンが完全に指定されているため、全く
     オプションを参照しません。

   * ‘PY_PYTHON=3’ の場合、‘python’ および ‘python3’ コマンドはともにイ
     ンストールされている最新の Python 3 を使用します。

   * ‘PY_PYTHON=3.7-32’ の場合、‘python’ コマンドは 32-bit 版の 3.7 を使
     用しますが、‘python3’ コマンドはインストールされている最新の Python
     を使用します (メジャーバージョンが指定されているため、PY_PYTHON は
     全く考慮されません。)

   * ‘PY_PYTHON=3’ で ‘PY_PYTHON3=3.7’ の場合、‘python’ および ‘python3’
     はどちらも 3.7 を使用します

環境変数に加え、同じ設定をランチャが使う INI ファイルで構成することがで
きます。INI ファイルの該当するセクションは ‘[defaults]’ と呼ばれ、キー名
は環境変数のキー名から ‘PY_’ という接頭辞を取ったものと同じです (INI フ
ァイルのキー名は大文字小文字を区別しないことにご注意ください)。環境変数
の内容は INI ファイルでの指定を上書きします。

例えば:

   * ‘PY_PYTHON=3.7’ と設定することは、INI ファイルに下記が含まれること
     と等価です:

     [defaults]
     python=3.7

   * ‘PY_PYTHON=3’ と ‘PY_PYTHON3=3.7’ を設定することは、INI ファイルに
     下記が含まれることと等価です:

     [defaults]
     python=3
     python3=3.7


File: python.info,  Node: 診断,  Next: Dry Run,  Prev: カスタマイズ,  Up: Windows の Python ランチャ

3.4.8.11 診断
.............

環境変数 ‘PYLAUNCHER_DEBUG’ が設定されていたら (設定値が何であっても)、
ランチャは診断情報を stderr (つまりコンソール) に出力します。この情報の
メッセージは詳細で 'しかも' きついものですが、どういったバージョンの
Python が検知されたか、なぜ特定のバージョンが選択されたか、そして、対象
の Python を実行するのに使われた正確なコマンドラインを教えてくれます。こ
れは主にテストやデバッグのためのものです。


File: python.info,  Node: Dry Run,  Next: Install on demand,  Prev: 診断,  Up: Windows の Python ランチャ

3.4.8.12 Dry Run
................

If an environment variable ‘PYLAUNCHER_DRYRUN’ is set (to any value),
the launcher will output the command it would have run, but will not
actually launch Python.  This may be useful for tools that want to use
the launcher to detect and then launch Python directly.  Note that the
command written to standard output is always encoded using UTF-8, and
may not render correctly in the console.


File: python.info,  Node: Install on demand,  Next: Return codes,  Prev: Dry Run,  Up: Windows の Python ランチャ

3.4.8.13 Install on demand
..........................

If an environment variable ‘PYLAUNCHER_ALLOW_INSTALL’ is set (to any
value), and the requested Python version is not installed but is
available on the Microsoft Store, the launcher will attempt to install
it.  This may require user interaction to complete, and you may need to
run the command again.

An additional ‘PYLAUNCHER_ALWAYS_INSTALL’ variable causes the launcher
to always try to install Python, even if it is detected.  This is mainly
intended for testing (and should be used with ‘PYLAUNCHER_DRYRUN’).


File: python.info,  Node: Return codes,  Prev: Install on demand,  Up: Windows の Python ランチャ

3.4.8.14 Return codes
.....................

The following exit codes may be returned by the Python launcher.
Unfortunately, there is no way to distinguish these from the exit code
of Python itself.

The names of codes are as used in the sources, and are only for
reference.  There is no way to access or resolve them apart from reading
this page.  Entries are listed in alphabetical order of names.

名前                    値          説明
                                    
----------------------------------------------------------------------------------------
                                    
RC_BAD_VENV_CFG         107         A ‘pyvenv.cfg’ was found but is corrupt.
                                    
                                    
RC_CREATE_PROCESS       101         Failed to launch Python.
                                    
                                    
RC_INSTALLING           111         An install was started, but the command will need
                                    to be re-run after it completes.
                                    
                                    
RC_INTERNAL_ERROR       109         Unexpected error.  Please report a bug.
                                    
                                    
RC_NO_COMMANDLINE       108         Unable to obtain command line from the operating
                                    system.
                                    
                                    
RC_NO_PYTHON            103         Unable to locate the requested version.
                                    
                                    
RC_NO_VENV_CFG          106         A ‘pyvenv.cfg’ was required but not found.
                                    


File: python.info,  Node: モジュールの検索,  Next: 追加のモジュール,  Prev: Windows の Python ランチャ,  Up: Windows で Python を使う

3.4.9 モジュールの検索
----------------------

These notes supplement the description at *note sys.path
モジュール検索パスの初期化: 1bca. with detailed Windows notes.

‘._pth’ ファイルが見付からなかったときは、 Windows では *note sys.path:
38e. は次のように設定されます:

   * 最初に空のエントリが追加されます。これはカレントディレクトリを指し
     ています。

   * その次に、 *note PYTHONPATH: fe8. 環境変数が存在するとき、 *note
     環境変数: 5bb. で解説されているように追加されます。 Windows ではド
     ライブ識別子 (‘C:\’ など)と区別するために、この環境変数に含まれるパ
     スの区切り文字はセミコロンでなければならない事に注意してください。

   * 追加で "アプリケーションのパス" を ‘HKEY_CURRENT_USER’ か
     ‘HKEY_LOCAL_MACHINE’ の中の
     ‘\SOFTWARE\Python\PythonCore{version}\PythonPath’ のサブキーとして
     登録することができます。サブキーはデフォルト値としてセミコロンで区
     切られたパス文字列を持つことができ、書くパスが *note sys.path: 38e.
     に追加されます。 (既存のインストーラーはすべて HKLM しか利用しない
     ので、 HKCU は通常空です)

   * *note PYTHONHOME: 396. が設定されている場合、それが "Python Home" と
     して扱われます。 それ以外の場合、 "Python Home" を推定するために
     Python の実行ファイルのパスから "目印ファイル" (‘Lib\os.py’ または
     ‘pythonXY.zip’) が探されます。 Python home が見つかった場合、そこか
     らいくつかのサブディレクトリ (‘Lib’, ‘plat-win’ など) が *note
     sys.path: 38e. に追加されます。 見つからなかった場合、コアとなる
     Python path はレジストリに登録された PythonPath から構築されます。

   * Python Home が見つからず、環境変数 *note PYTHONPATH: fe8. が指定さ
     れず、レジストリエントリが見つからなかった場合、関連するデフォルト
     のパスが利用されます (例: ‘.\Lib;.\plat-win’ など)。

メインの実行ファイルと同じ場所か一つ上のディレクトリに ‘pyvenv.cfg’ があ
る場合、以下の異なった規則が適用されます:

   * *note PYTHONHOME: 396. が設定されておらず、 ‘home’ が絶対パスの場合
     、home 推定の際メインの実行ファイルから推定するのではなくこのパスを
     使います。

結果としてこうなります:

   * ‘python.exe’ かそれ以外の Python ディレクトリにある .exe ファイルを
     実行したとき (インストールされている場合でも PCbuild から直接実行さ
     れている場合でも) core path が利用され、レジストリ内の core path は
     無視されます。それ以外のレジストリの "application paths" は常に読み
     込まれます。

   * Python が他の .exe ファイル (他のディレクトリに存在する場合や、
     COM経由で組み込まれる場合など) にホストされている場合は、 "Python
     Home" は推定されず、レジストリにある core path が利用されます。それ
     以外のレジストリの "application paths" は常に読み込まれます。

   * Python がその home を見つけられず、レジストリの値もない場合 (これは
     いくつかのとてもおかしなインストレーションセットアップの凍結された
     .exe)、パスは最小限のデフォルトとして相対パスが使われます。

自身のアプリケーションや配布物に Python をバンドルしたい場合には、以下の
助言 (のいずれかまたは組合せ) によりほかのインストレーションとの衝突を避
けることができます:

   * Include a ‘._pth’ file alongside your executable containing the
     directories to include.  This will ignore paths listed in the
     registry and environment variables, and also ignore *note site: b5.
     unless ‘import site’ is listed.

   * If you are loading ‘python3.dll’ or ‘python37.dll’ in your own
     executable, explicitly set *note PyConfig.module_search_paths: 37c.
     before *note Py_InitializeFromConfig(): 39f.

   * 自身のアプリケーションから ‘python.exe’ を起動する前に、 *note
     PYTHONPATH: fe8. をクリアしたり上書きし、 *note PYTHONHOME: 396. を
     セットしてください。

   * If you cannot use the previous suggestions (for example, you are a
     distribution that allows people to run ‘python.exe’ directly),
     ensure that the landmark file (‘Lib\os.py’) exists in your install
     directory.  (Note that it will not be detected inside a ZIP file,
     but a correctly named ZIP file will be detected instead.)

これらはシステムワイドにインストールされたファイルが、あなたのアプリケー
ションにバンドルされた標準ライブラリのコピーに優先しないようにします。こ
れをしなければあなたのアプリケーションのユーザは、何かしら問題を抱えるか
もしれません。上で列挙した最初の提案が最善です。ほかのものはレジストリ内
の非標準のパスやユーザの site-packages の影響を少し受けやすいからです。

バージョン 3.6 で変更: Add ‘._pth’ file support and removes ‘applocal’
option from ‘pyvenv.cfg’.

バージョン 3.6 で変更: Add ‘python`XX'.zip’ as a potential landmark when
directly adjacent to the executable.

バージョン 3.6 で非推奨: Modules specified in the registry under
‘Modules’ (not ‘PythonPath’) may be imported by *note
importlib.machinery.WindowsRegistryFinder: cf8.  This finder is enabled
on Windows in 3.6.0 and earlier, but may need to be explicitly added to
*note sys.meta_path: cf9. in the future.


File: python.info,  Node: 追加のモジュール,  Next: Windows 上で Python をコンパイルする,  Prev: モジュールの検索,  Up: Windows で Python を使う

3.4.10 追加のモジュール
-----------------------

Python は全プラットフォーム互換を目指していますが、 Windows にしかないユ
ニークな機能もあります。標準ライブラリと外部のライブラリの両方で、幾つか
のモジュールと、そういった機能を使うためのスニペットがあります。

Windows 固有の標準モジュールは、 *note MS Windows 固有のサービス: 1d9c.
に書かれています。

* Menu:

* PyWin32::
* cx_Freeze::


File: python.info,  Node: PyWin32,  Next: cx_Freeze,  Up: 追加のモジュール

3.4.10.1 PyWin32
................

The PyWin32(1) module by Mark Hammond is a collection of modules for
advanced Windows-specific support.  This includes utilities for:

   * Component Object Model(2) (COM)

   * Win32 API 呼び出し

   * レジストリ

   * イベントログ

   * Microsoft Foundation Classes(3) (MFC) user interfaces

PythonWin(4) は PyWin32 に付属している、サンプルのMFCアプリケーションで
す。これはビルトインのデバッガを含む、組み込み可能なIDEです。

参考
....

Win32 How Do I...?(5)

     by Tim Golden

Python and COM(6)

     by David and Paul Boddie

   ---------- Footnotes ----------

   (1) https://pypi.org/project/PyWin32/

   (2) 
https://learn.microsoft.com/windows/win32/com/component-object-model-com-portal

   (3) https://learn.microsoft.com/cpp/mfc/mfc-desktop-applications

   (4) 
https://web.archive.org/web/20060524042422/https://www.python.org/windows/pythonwin/

   (5) https://timgolden.me.uk/python/win32_how_do_i.html

   (6) https://www.boddie.org.uk/python/COM.html


File: python.info,  Node: cx_Freeze,  Prev: PyWin32,  Up: 追加のモジュール

3.4.10.2 cx_Freeze
..................

cx_Freeze(1) wraps Python scripts into executable Windows programs
(‘`*'.exe’ files).  When you have done this, you can distribute your
application without requiring your users to install Python.

   ---------- Footnotes ----------

   (1) https://cx-freeze.readthedocs.io/en/latest/


File: python.info,  Node: Windows 上で Python をコンパイルする,  Next: ほかのプラットフォーム,  Prev: 追加のモジュール,  Up: Windows で Python を使う

3.4.11 Windows 上で Python をコンパイルする
-------------------------------------------

CPython を自分でコンパイルしたい場合、最初にすべきことは ソース(1) を取
得することです。最新リリース版のソースか、新しい チェックアウト(2) をダ
ウンロードできます。

ソースツリーには Microsoft Visual Studio でのビルドのソリューションファ
イルとプロジェクトファイルが含まれていて、これが公式の Python リリースに
使われているコンパイラです。これらファイルは ‘PCbuild’ ディレクトリ内に
あります。

ビルドプロセスについての一般的な情報は、‘PCbuild/readme.txt’ にあります
。

拡張モジュールについては、 *note Windows 上での C および C++
拡張モジュールのビルド: 1da0. を参照してください。

   ---------- Footnotes ----------

   (1) https://www.python.org/downloads/source/

   (2) https://devguide.python.org/setup/#get-the-source-code


File: python.info,  Node: ほかのプラットフォーム,  Prev: Windows 上で Python をコンパイルする,  Up: Windows で Python を使う

3.4.12 ほかのプラットフォーム
-----------------------------

Python の継続的な開発の中で、過去にサポートされていた幾つかのプラットフ
ォームが (ユーザーや開発者の不足のために) サポートされなくなっています。
すべてのサポートされないプラットフォームについての詳細は PEP 11(1) をチ
ェックしてください。

   * Windows CE(2) is no longer supported(3) since Python 3 (if it ever
     was).

   * The Cygwin(4) installer offers to install the Python interpreter(5)
     as well

コンパイル済みインストーラが提供されているプラットフォームについての詳細
な情報は Python for Windows(6) を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0011/

   (2) https://pythonce.sourceforge.net/

   (3) https://github.com/python/cpython/issues/71542

   (4) https://cygwin.com/

   (5) https://cygwin.com/packages/summary/python3.html

   (6) https://www.python.org/downloads/windows/


File: python.info,  Node: Using Python on macOS,  Next: Using Python on Android,  Prev: Windows で Python を使う,  Up: Python のセットアップと利用

3.5 Using Python on macOS
=========================

This document aims to give an overview of macOS-specific behavior you
should know about to get started with Python on Mac computers.  Python
on a Mac running macOS is very similar to Python on other Unix-derived
platforms, but there are some differences in installation and some
features.

There are various ways to obtain and install Python for macOS. Pre-built
versions of the most recent versions of Python are available from a
number of distributors.  Much of this document describes use of the
Pythons provided by the CPython release team for download from the
python.org website(1).  See *note Alternative Distributions: 1da5. for
some other options.
* Menu:

* Using Python for macOS from python.org: Using Python for macOS from python org.
* Alternative Distributions::
* 追加の Python パッケージのインストール::
* GUI プログラミング::
* 高度なトピック::
* 他のリソース::

   ---------- Footnotes ----------

   (1) https://www.python.org/downloads/


File: python.info,  Node: Using Python for macOS from python org,  Next: Alternative Distributions,  Up: Using Python on macOS

3.5.1 Using Python for macOS from ‘python.org’
----------------------------------------------

* Menu:

* インストール手順: インストール手順<2>.
* Python スクリプトの実行方法::


File: python.info,  Node: インストール手順<2>,  Next: Python スクリプトの実行方法,  Up: Using Python for macOS from python org

3.5.1.1 インストール手順
........................

For current Python versions(1) (other than those in ‘security’ status),
the release team produces a 'Python for macOS' installer package for
each new release.  A list of available installers is available here(2).
We recommend using the most recent supported Python version where
possible.  Current installers provide a universal2 binary(3) build of
Python which runs natively on all Macs (Apple Silicon and Intel) that
are supported by a wide range of macOS versions, currently typically
from at least 'macOS 10.13 High Sierra' on.

The downloaded file is a standard macOS installer package file (‘.pkg’).
File integrity information (checksum, size, sigstore signature, etc) for
each file is included on the release download page.  Installer packages
and their contents are signed and notarized with ‘Python Software
Foundation’ Apple Developer ID certificates to meet macOS Gatekeeper
requirements(4).

For a default installation, double-click on the downloaded installer
package file.  This should launch the standard macOS Installer app and
display the first of several installer windows steps.

[image src="python-figures/mac_installer_01_introduction.png"]


Clicking on the 'Continue' button brings up the 'Read Me' for this
installer.  Besides other important information, the 'Read Me' documents
which Python version is going to be installed and on what versions of
macOS it is supported.  You may need to scroll through to read the whole
file.  By default, this 'Read Me' will also be installed in
‘/Applications/Python 3.13/’ and available to read anytime.

[image src="python-figures/mac_installer_02_readme.png"]


Clicking on 'Continue' proceeds to display the license for Python and
for other included software.  You will then need to 'Agree' to the
license terms before proceeding to the next step.  This license file
will also be installed and available to be read later.

[image src="python-figures/mac_installer_03_license.png"]


After the license terms are accepted, the next step is the 'Installation
Type' display.  For most uses, the standard set of installation
operations is appropriate.

[image src="python-figures/mac_installer_04_installation_type.png"]


By pressing the 'Customize' button, you can choose to omit or select
certain package components of the installer.  Click on each package name
to see a description of what it installs.  To also install support for
the optional experimental free-threaded feature, see *note
フリースレッドバイナリ (Free-threaded Binaries) のインストール: 159.

[image src="python-figures/mac_installer_05_custom_install.png"]


In either case, clicking 'Install' will begin the install process by
asking permission to install new software.  A macOS user name with
‘Administrator’ privilege is needed as the installed Python will be
available to all users of the Mac.

When the installation is complete, the 'Summary' window will appear.

[image src="python-figures/mac_installer_06_summary.png"]


Double-click on the ‘Install Certificates.command’ icon or file in the
‘/Applications/Python 3.13/’ window to complete the installation.

[image src="python-figures/mac_installer_07_applications.png"]


This will open a temporary ‘Terminal’ shell window that will use the new
Python to download and install SSL root certificates for its use.

[image src="python-figures/mac_installer_08_install_certificates.png"]


If ‘Successfully installed certifi’ and ‘update complete’ appears in the
terminal window, the installation is complete.  Close this terminal
window and the installer window.

A default install will include:

   * A ‘Python 3.13’ folder in your ‘Applications’ folder.  In here you
     find ‘IDLE’, the development environment that is a standard part of
     official Python distributions; and ‘Python Launcher’, which handles
     double-clicking Python scripts from the macOS Finder(5).

   * A framework ‘/Library/Frameworks/Python.framework’, which includes
     the Python executable and libraries.  The installer adds this
     location to your shell path.  To uninstall Python, you can remove
     these three things.  Symlinks to the Python executable are placed
     in ‘/usr/local/bin/’.

     注釈: Recent versions of macOS include a ‘python3’ command in
     ‘/usr/bin/python3’ that links to a usually older and incomplete
     version of Python provided by and for use by the Apple development
     tools, ‘Xcode’ or the ‘Command Line Tools for Xcode’.  You should
     never modify or attempt to delete this installation, as it is
     Apple-controlled and is used by Apple-provided or third-party
     software.  If you choose to install a newer Python version from
     ‘python.org’, you will have two different but functional Python
     installations on your computer that can co-exist.  The default
     installer options should ensure that its ‘python3’ will be used
     instead of the system ‘python3’.

   ---------- Footnotes ----------

   (1) https://www.python.org/downloads/

   (2) https://www.python.org/downloads/macos/

   (3) https://en.wikipedia.org/wiki/Universal_binary

   (4) https://support.apple.com/en-us/102445

   (5) https://support.apple.com/en-us/HT201732


File: python.info,  Node: Python スクリプトの実行方法,  Prev: インストール手順<2>,  Up: Using Python for macOS from python org

3.5.1.2 Python スクリプトの実行方法
...................................

There are two ways to invoke the Python interpreter.  If you are
familiar with using a Unix shell in a terminal window, you can invoke
‘python3.13’ or ‘python3’ optionally followed by one or more command
line options (described in *note コマンドラインと環境: 192a.).  The
Python tutorial also has a useful section on *note using Python
interactively from a shell: 155.

You can also invoke the interpreter through an integrated development
environment.  *note IDLE: fe0. is a basic editor and interpreter
environment which is included with the standard distribution of Python.
‘IDLE’ includes a Help menu that allows you to access Python
documentation.  If you are completely new to Python, you can read the
tutorial introduction in that document.

There are many other editors and IDEs available, see *note エディタと
IDE: 1dab. for more information.

To run a Python script file from the terminal window, you can invoke the
interpreter with the name of the script file:

     ‘python3.13’ ‘myscript.py’

To run your script from the Finder, you can either:

   * Drag it to ‘Python Launcher’.

   * Select ‘Python Launcher’ as the default application to open your
     script (or any ‘.py’ script) through the Finder Info window and
     double-click it.  ‘Python Launcher’ has various preferences to
     control how your script is launched.  Option-dragging allows you to
     change these for one invocation, or use its ‘Preferences’ menu to
     change things globally.

Be aware that running the script directly from the macOS Finder might
produce different results than when running from a terminal window as
the script will not be run in the usual shell environment including any
setting of environment variables in shell profiles.  And, as with any
other script or program, be certain of what you are about to run.


File: python.info,  Node: Alternative Distributions,  Next: 追加の Python パッケージのインストール,  Prev: Using Python for macOS from python org,  Up: Using Python on macOS

3.5.2 Alternative Distributions
-------------------------------

Besides the standard ‘python.org’ for macOS installer, there are
third-party distributions for macOS that may include additional
functionality.  Some popular distributions and their key features:

ActivePython(1)

     Installer with multi-platform compatibility, documentation

Anaconda(2)

     Popular scientific modules (such as numpy, scipy, and pandas) and
     the ‘conda’ package manager.

Homebrew(3)

     Package manager for macOS including multiple versions of Python and
     many third-party Python-based packages (including numpy, scipy, and
     pandas).

MacPorts(4)

     Another package manager for macOS including multiple versions of
     Python and many third-party Python-based packages.  May include
     pre-built versions of Python and many packages for older versions
     of macOS.

Note that distributions might not include the latest versions of Python
or other libraries, and are not maintained or supported by the core
Python team.

   ---------- Footnotes ----------

   (1) https://www.activestate.com/products/python/

   (2) https://www.anaconda.com/download/

   (3) https://brew.sh

   (4) https://www.macports.org


File: python.info,  Node: 追加の Python パッケージのインストール,  Next: GUI プログラミング,  Prev: Alternative Distributions,  Up: Using Python on macOS

3.5.3 追加の Python パッケージのインストール
--------------------------------------------

Refer to the Python Packaging User Guide(1) for more information.

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/tutorials/installing-packages/


File: python.info,  Node: GUI プログラミング,  Next: 高度なトピック,  Prev: 追加の Python パッケージのインストール,  Up: Using Python on macOS

3.5.4 GUI プログラミング
------------------------

Python で Mac 上の GUI アプリケーションをビルドする方法がいくつかありま
す。

The standard Python GUI toolkit is *note tkinter: d9, based on the
cross-platform Tk toolkit (‘https://www.tcl.tk’).  A macOS-native
version of Tk is included with the installer.

'PyObjC' is a Python binding to Apple's Objective-C/Cocoa framework.
Information on PyObjC is available from pyobjc(1).

A number of alternative macOS GUI toolkits are available including:

   * PySide(2): Official Python bindings to the Qt GUI toolkit(3).

   * PyQt(4): Alternative Python bindings to Qt.

   * Kivy(5): A cross-platform GUI toolkit that supports desktop and
     mobile platforms.

   * Toga(6): Part of the BeeWare Project(7); supports desktop, mobile,
     web and console apps.

   * wxPython(8): A cross-platform toolkit that supports desktop
     operating systems.

   ---------- Footnotes ----------

   (1) https://pypi.org/project/pyobjc/

   (2) https://www.qt.io/qt-for-python

   (3) https://wiki.qt.io/Qt_for_Python

   (4) https://riverbankcomputing.com/software/pyqt/

   (5) https://kivy.org

   (6) https://toga.readthedocs.io

   (7) https://beeware.org

   (8) https://wxpython.org


File: python.info,  Node: 高度なトピック,  Next: 他のリソース,  Prev: GUI プログラミング,  Up: Using Python on macOS

3.5.5 高度なトピック
--------------------

* Menu:

* フリースレッドバイナリ (Free-threaded Binaries) のインストール: フリースレッドバイナリ Free-threaded Binaries のインストール<2>.
* Installing using the command line::
* Python アプリケーションの配布::
* App Store コンプライアンス::


File: python.info,  Node: フリースレッドバイナリ Free-threaded Binaries のインストール<2>,  Next: Installing using the command line,  Up: 高度なトピック

3.5.5.1 フリースレッドバイナリ (Free-threaded Binaries) のインストール
......................................................................

Added in version 3.13: (実験的)

     注釈: このセクションで説明されているすべての項目は実験的とみなされ
     ており、将来のリリースで変更される可能性があります。

The ‘python.org’ *note Python for macOS: 1da7. installer package can
optionally install an additional build of Python 3.13 that supports PEP
703(1), the experimental free-threading feature (running with the *note
global interpreter lock: 12e. disabled).  Check the release page on
‘python.org’ for possible updated information.

Because this feature is still considered experimental, the support for
it is not installed by default.  It is packaged as a separate install
option, available by clicking the 'Customize' button on the
'Installation Type' step of the installer as described above.

[image src="python-figures/mac_installer_09_custom_install_free_threaded.png"]


If the box next to the 'Free-threaded Python' package name is checked, a
separate ‘PythonT.framework’ will also be installed alongside the normal
‘Python.framework’ in ‘/Library/Frameworks’.  This configuration allows
a free-threaded Python 3.13 build to co-exist on your system with a
traditional (GIL only) Python 3.13 build with minimal risk while
installing or testing.  This installation layout is itself experimental
and is subject to change in future releases.

Known cautions and limitations:

   - The 'UNIX command-line tools' package, which is selected by
     default, will install links in ‘/usr/local/bin’ for ‘python3.13t’,
     the free-threaded interpreter, and ‘python3.13t-config’, a
     configuration utility which may be useful for package builders.
     Since ‘/usr/local/bin’ is typically included in your shell ‘PATH’,
     in most cases no changes to your ‘PATH’ environment variables
     should be needed to use ‘python3.13t’.

   - For this release, the 'Shell profile updater' package and the
     ‘Update Shell Profile.command’ in ‘/Applications/Python 3.13/’ do
     not support the free-threaded package.

   - The free-threaded build and the traditional build have separate
     search paths and separate ‘site-packages’ directories so, by
     default, if you need a package available in both builds, it may
     need to be installed in both.  The free-threaded package will
     install a separate instance of ‘pip’ for use with ‘python3.13t’.

        - To install a package using ‘pip’ without a ‘venv’:

               ‘python3.13t’ ‘-m pip install <package_name>’

   - When working with multiple Python environments, it is usually
     safest and easiest to *note create and use virtual environments:
     1c69.  This can avoid possible command name conflicts and confusion
     about which Python is in use:

          ‘python3.13t’ ‘-m venv <venv_name>’

     then ‘activate’.

   - To run a free-threaded version of IDLE:

          ‘python3.13t’ ‘-m idlelib’

   - The interpreters in both builds respond to the same *note PYTHON
     environment variables: 5bb. which may have unexpected results, for
     example, if you have ‘PYTHONPATH’ set in a shell profile.  If
     necessary, there are *note command line options: 1c93. like ‘-E’ to
     ignore these environment variables.

   - The free-threaded build links to the third-party shared libraries,
     such as ‘OpenSSL’ and ‘Tk’, installed in the traditional framework.
     This means that both builds also share one set of trust
     certificates as installed by the ‘Install Certificates.command’
     script, thus it only needs to be run once.

   - If you cannot depend on the link in ‘/usr/local/bin’ pointing to
     the ‘python.org’ free-threaded ‘python3.13t’ (for example, if you
     want to install your own version there or some other distribution
     does), you can explicitly set your shell ‘PATH’ environment
     variable to include the ‘PythonT’ framework ‘bin’ directory:

          export PATH="/Library/Frameworks/PythonT.framework/Versions/3.13/bin":"$PATH"

     The traditional framework installation by default does something
     similar, except for ‘Python.framework’.  Be aware that having both
     framework ‘bin’ directories in ‘PATH’ can lead to confusion if
     there are duplicate names like ‘python3.13’ in both; which one is
     actually used depends on the order they appear in ‘PATH’.  The
     ‘which python3.x’ or ‘which python3.xt’ commands can show which
     path is being used.  Using virtual environments can help avoid such
     ambiguities.  Another option might be to create a shell ‘alias’ to
     the desired interpreter, like:

          alias py3.13="/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13"
          alias py3.13t="/Library/Frameworks/PythonT.framework/Versions/3.13/bin/python3.13t"

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0703/


File: python.info,  Node: Installing using the command line,  Next: Python アプリケーションの配布,  Prev: フリースレッドバイナリ Free-threaded Binaries のインストール<2>,  Up: 高度なトピック

3.5.5.2 Installing using the command line
.........................................

If you want to use automation to install the ‘python.org’ installer
package (rather than by using the familiar macOS ‘Installer’ GUI app),
the macOS command line ‘installer’ utility lets you select non-default
options, too.  If you are not familiar with ‘installer’, it can be
somewhat cryptic (see ‘man installer’ for more information).  As an
example, the following shell snippet shows one way to do it, using the
‘3.13.0b2’ release and selecting the free-threaded interpreter option:

     RELEASE="python-3.13.0b2-macos11.pkg"

     # download installer pkg
     curl -O https://www.python.org/ftp/python/3.13.0/${RELEASE}

     # create installer choicechanges to customize the install:
     #    enable the PythonTFramework-3.13 package
     #    while accepting the other defaults (install all other packages)
     cat > ./choicechanges.plist <<EOF
     <?xml version="1.0" encoding="UTF-8"?>
     <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
     <plist version="1.0">
     <array>
             <dict>
                     <key>attributeSetting</key>
                     <integer>1</integer>
                     <key>choiceAttribute</key>
                     <string>selected</string>
                     <key>choiceIdentifier</key>
                     <string>org.python.Python.PythonTFramework-3.13</string>
             </dict>
     </array>
     </plist>
     EOF

     sudo installer -pkg ./${RELEASE} -applyChoiceChangesXML ./choicechanges.plist -target /

You can then test that both installer builds are now available with
something like:

     $ # test that the free-threaded interpreter was installed if the Unix Command Tools package was enabled
     $ /usr/local/bin/python3.13t -VV
     Python 3.13.0b2 experimental free-threading build (v3.13.0b2:3a83b172af, Jun  5 2024, 12:57:31) [Clang 15.0.0 (clang-1500.3.9.4)]
     $ #    and the traditional interpreter
     $ /usr/local/bin/python3.13 -VV
     Python 3.13.0b2 (v3.13.0b2:3a83b172af, Jun  5 2024, 12:50:24) [Clang 15.0.0 (clang-1500.3.9.4)]
     $ # test that they are also available without the prefix if /usr/local/bin is on $PATH
     $ python3.13t -VV
     Python 3.13.0b2 experimental free-threading build (v3.13.0b2:3a83b172af, Jun  5 2024, 12:57:31) [Clang 15.0.0 (clang-1500.3.9.4)]
     $ python3.13 -VV
     Python 3.13.0b2 (v3.13.0b2:3a83b172af, Jun  5 2024, 12:50:24) [Clang 15.0.0 (clang-1500.3.9.4)]

     注釈: Current ‘python.org’ installers only install to fixed
     locations like ‘/Library/Frameworks/’, ‘/Applications’, and
     ‘/usr/local/bin’.  You cannot use the ‘installer’ ‘-domain’ option
     to install to other locations.


File: python.info,  Node: Python アプリケーションの配布,  Next: App Store コンプライアンス,  Prev: Installing using the command line,  Up: 高度なトピック

3.5.5.3 Python アプリケーションの配布
.....................................

Python コードをスタンドアローンな配布アプリケーションに変換するツールに
は様々なものがあります:

   * py2app(1): Supports creating macOS ‘.app’ bundles from a Python
     project.

   * Briefcase(2): Part of the BeeWare Project(3); a cross-platform
     packaging tool that supports creation of ‘.app’ bundles on macOS,
     as well as managing signing and notarization.

   * PyInstaller(4): A cross-platform packaging tool that creates a
     single file or folder as a distributable artifact.

   ---------- Footnotes ----------

   (1) https://pypi.org/project/py2app/

   (2) https://briefcase.readthedocs.io

   (3) https://beeware.org

   (4) https://pyinstaller.org/


File: python.info,  Node: App Store コンプライアンス,  Prev: Python アプリケーションの配布,  Up: 高度なトピック

3.5.5.4 App Store コンプライアンス
..................................

Apps submitted for distribution through the macOS App Store must pass
Apple's app review process.  This process includes a set of automated
validation rules that inspect the submitted application bundle for
problematic code.

The Python standard library contains some code that is known to violate
these automated rules.  While these violations appear to be false
positives, Apple's review rules cannot be challenged.  Therefore, it is
necessary to modify the Python standard library for an app to pass App
Store review.

The Python source tree contains a patch file(1) that will remove all
code that is known to cause issues with the App Store review process.
This patch is applied automatically when CPython is configured with the
*note -with-app-store-compliance: 1556. option.

This patch is not normally required to use CPython on a Mac; nor is it
required if you are distributing an app 'outside' the macOS App Store.
It is 'only' required if you are using the macOS App Store as a
distribution channel.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Mac/Resources/app-store-compliance.patch


File: python.info,  Node: 他のリソース,  Prev: 高度なトピック,  Up: Using Python on macOS

3.5.6 他のリソース
------------------

The python.org Help page(1) has links to many useful resources.  The
Pythonmac-SIG mailing list(2) is another support resource specifically
for Python users and developers on the Mac.

   ---------- Footnotes ----------

   (1) https://www.python.org/about/help/

   (2) https://www.python.org/community/sigs/current/pythonmac-sig/


File: python.info,  Node: Using Python on Android,  Next: Using Python on iOS,  Prev: Using Python on macOS,  Up: Python のセットアップと利用

3.6 Using Python on Android
===========================

Python on Android is unlike Python on desktop platforms.  On a desktop
platform, Python is generally installed as a system resource that can be
used by any user of that computer.  Users then interact with Python by
running a ‘python’ executable and entering commands at an interactive
prompt, or by running a Python script.

On Android, there is no concept of installing as a system resource.  The
only unit of software distribution is an "app".  There is also no
console where you could run a ‘python’ executable, or interact with a
Python REPL.

As a result, the only way you can use Python on Android is in embedded
mode – that is, by writing a native Android application, embedding a
Python interpreter using ‘libpython’, and invoking Python code using the
*note Python embedding API: 1dbc.  The full Python interpreter, the
standard library, and all your Python code is then packaged into your
app for its own private use.

The Python standard library has some notable omissions and restrictions
on Android.  See the *note API availability guide: 1dbd. for details.

* Menu:

* Adding Python to an Android app::


File: python.info,  Node: Adding Python to an Android app,  Up: Using Python on Android

3.6.1 Adding Python to an Android app
-------------------------------------

These instructions are only needed if you're planning to compile Python
for Android yourself.  Most users should 'not' need to do this.
Instead, use one of the following tools, which will provide a much
easier experience:

   * Briefcase(1), from the BeeWare project

   * Buildozer(2), from the Kivy project

   * Chaquopy(3)

   * pyqtdeploy(4)

   * Termux(5)

If you're sure you want to do all of this manually, read on.  You can
use the testbed app(6) as a guide; each step below contains a link to
the relevant file.

   * Build Python by following the instructions in Android/README.md(7).

   * Add code to your build.gradle(8) file to copy the following items
     into your project.  All except your own Python code can be copied
     from ‘cross-build/HOST/prefix/lib’:

        * In your JNI libraries:

             * ‘libpython*.*.so’

             * ‘lib*_python.so’ (external libraries such as OpenSSL)

        * In your assets:

             * ‘python*.*’ (the Python standard library)

             * ‘python*.*/site-packages’ (your own Python code)

   * Add code to your app to extract the assets to the filesystem(9).

   * Add code to your app to start Python in embedded mode(10).  This
     will need to be C code called via JNI.

   ---------- Footnotes ----------

   (1) https://briefcase.readthedocs.io

   (2) https://buildozer.readthedocs.io

   (3) https://chaquo.com/chaquopy

   (4) https://www.riverbankcomputing.com/static/Docs/pyqtdeploy/

   (5) https://termux.dev/en/

   (6) https://github.com/python/cpython/tree/3.13/Android/testbed

   (7) https://github.com/python/cpython/tree/3.13/Android/README.md

   (8) 
https://github.com/python/cpython/tree/3.13/Android/testbed/app/build.gradle.kts

   (9) 
https://github.com/python/cpython/tree/3.13/Android/testbed/app/src/main/java/org/python/testbed/MainActivity.kt

   (10) 
https://github.com/python/cpython/tree/3.13/Android/testbed/app/src/main/c/main_activity.c


File: python.info,  Node: Using Python on iOS,  Next: エディタと IDE,  Prev: Using Python on Android,  Up: Python のセットアップと利用

3.7 Using Python on iOS
=======================


Authors: Russell Keith-Magee (2024-03)

Python on iOS is unlike Python on desktop platforms.  On a desktop
platform, Python is generally installed as a system resource that can be
used by any user of that computer.  Users then interact with Python by
running a ‘python’ executable and entering commands at an interactive
prompt, or by running a Python script.

On iOS, there is no concept of installing as a system resource.  The
only unit of software distribution is an "app".  There is also no
console where you could run a ‘python’ executable, or interact with a
Python REPL.

As a result, the only way you can use Python on iOS is in embedded mode
- that is, by writing a native iOS application, and embedding a Python
interpreter using ‘libPython’, and invoking Python code using the *note
Python embedding API: 1dbc.  The full Python interpreter, the standard
library, and all your Python code is then packaged as a standalone
bundle that can be distributed via the iOS App Store.

If you're looking to experiment for the first time with writing an iOS
app in Python, projects such as BeeWare(1) and Kivy(2) will provide a
much more approachable user experience.  These projects manage the
complexities associated with getting an iOS project running, so you only
need to deal with the Python code itself.

* Menu:

* Python at runtime on iOS::
* Installing Python on iOS::
* App Store Compliance::

   ---------- Footnotes ----------

   (1) https://beeware.org

   (2) https://kivy.org


File: python.info,  Node: Python at runtime on iOS,  Next: Installing Python on iOS,  Up: Using Python on iOS

3.7.1 Python at runtime on iOS
------------------------------

* Menu:

* iOS version compatibility::
* Platform identification::
* Standard library availability::
* Binary extension modules::
* Compiler stub binaries::


File: python.info,  Node: iOS version compatibility,  Next: Platform identification,  Up: Python at runtime on iOS

3.7.1.1 iOS version compatibility
.................................

The minimum supported iOS version is specified at compile time, using
the *note -host: 1d3c. option to ‘configure’.  By default, when compiled
for iOS, Python will be compiled with a minimum supported iOS version of
13.0.  To use a different minimum iOS version, provide the version
number as part of the ‘--host’ argument - for example,
‘--host=arm64-apple-ios15.4-simulator’ would compile an ARM64 simulator
build with a deployment target of 15.4.


File: python.info,  Node: Platform identification,  Next: Standard library availability,  Prev: iOS version compatibility,  Up: Python at runtime on iOS

3.7.1.2 Platform identification
...............................

When executing on iOS, ‘sys.platform’ will report as ‘ios’.  This value
will be returned on an iPhone or iPad, regardless of whether the app is
running on the simulator or a physical device.

Information about the specific runtime environment, including the iOS
version, device model, and whether the device is a simulator, can be
obtained using *note platform.ios_ver(): 1dc5.  *note platform.system():
1dc6. will report ‘iOS’ or ‘iPadOS’, depending on the device.

*note os.uname(): 10e9. reports kernel-level details; it will report a
name of ‘Darwin’.


File: python.info,  Node: Standard library availability,  Next: Binary extension modules,  Prev: Platform identification,  Up: Python at runtime on iOS

3.7.1.3 Standard library availability
.....................................

The Python standard library has some notable omissions and restrictions
on iOS. See the *note API availability guide for iOS: 1dbd. for details.


File: python.info,  Node: Binary extension modules,  Next: Compiler stub binaries,  Prev: Standard library availability,  Up: Python at runtime on iOS

3.7.1.4 Binary extension modules
................................

One notable difference about iOS as a platform is that App Store
distribution imposes hard requirements on the packaging of an
application.  One of these requirements governs how binary extension
modules are distributed.

The iOS App Store requires that 'all' binary modules in an iOS app must
be dynamic libraries, contained in a framework with appropriate
metadata, stored in the ‘Frameworks’ folder of the packaged app.  There
can be only a single binary per framework, and there can be no
executable binary material outside the ‘Frameworks’ folder.

This conflicts with the usual Python approach for distributing binaries,
which allows a binary extension module to be loaded from any location on
‘sys.path’.  To ensure compliance with App Store policies, an iOS
project must post-process any Python packages, converting ‘.so’ binary
modules into individual standalone frameworks with appropriate metadata
and signing.  For details on how to perform this post-processing, see
the guide for *note adding Python to your project: 1dc9.

To help Python discover binaries in their new location, the original
‘.so’ file on ‘sys.path’ is replaced with a ‘.fwork’ file.  This file is
a text file containing the location of the framework binary, relative to
the app bundle.  To allow the framework to resolve back to the original
location, the framework must contain a ‘.origin’ file that contains the
location of the ‘.fwork’ file, relative to the app bundle.

For example, consider the case of an import ‘from foo.bar import _whiz’,
where ‘_whiz’ is implemented with the binary module
‘sources/foo/bar/_whiz.abi3.so’, with ‘sources’ being the location
registered on ‘sys.path’, relative to the application bundle.  This
module 'must' be distributed as
‘Frameworks/foo.bar._whiz.framework/foo.bar._whiz’ (creating the
framework name from the full import path of the module), with an
‘Info.plist’ file in the ‘.framework’ directory identifying the binary
as a framework.  The ‘foo.bar._whiz’ module would be represented in the
original location with a ‘sources/foo/bar/_whiz.abi3.fwork’ marker file,
containing the path ‘Frameworks/foo.bar._whiz/foo.bar._whiz’.  The
framework would also contain
‘Frameworks/foo.bar._whiz.framework/foo.bar._whiz.origin’, containing
the path to the ‘.fwork’ file.

When running on iOS, the Python interpreter will install an *note
AppleFrameworkLoader: 1dca. that is able to read and import ‘.fwork’
files.  Once imported, the ‘__file__’ attribute of the binary module
will report as the location of the ‘.fwork’ file.  However, the *note
ModuleSpec: 1dcb. for the loaded module will report the ‘origin’ as the
location of the binary in the framework folder.


File: python.info,  Node: Compiler stub binaries,  Prev: Binary extension modules,  Up: Python at runtime on iOS

3.7.1.5 Compiler stub binaries
..............................

Xcode doesn't expose explicit compilers for iOS; instead, it uses an
‘xcrun’ script that resolves to a full compiler path (e.g., ‘xcrun --sdk
iphoneos clang’ to get the ‘clang’ for an iPhone device).  However,
using this script poses two problems:

   * The output of ‘xcrun’ includes paths that are machine specific,
     resulting in a sysconfig module that cannot be shared between
     users; and

   * It results in ‘CC’/‘CPP’/‘LD’/‘AR’ definitions that include spaces.
     There is a lot of C ecosystem tooling that assumes that you can
     split a command line at the first space to get the path to the
     compiler executable; this isn't the case when using ‘xcrun’.

To avoid these problems, Python provided stubs for these tools.  These
stubs are shell script wrappers around the underingly ‘xcrun’ tools,
distributed in a ‘bin’ folder distributed alongside the compiled iOS
framework.  These scripts are relocatable, and will always resolve to
the appropriate local system paths.  By including these scripts in the
bin folder that accompanies a framework, the contents of the ‘sysconfig’
module becomes useful for end-users to compile their own modules.  When
compiling third-party Python modules for iOS, you should ensure these
stub binaries are on your path.


File: python.info,  Node: Installing Python on iOS,  Next: App Store Compliance,  Prev: Python at runtime on iOS,  Up: Using Python on iOS

3.7.2 Installing Python on iOS
------------------------------

* Menu:

* Tools for building iOS apps::
* Adding Python to an iOS project::


File: python.info,  Node: Tools for building iOS apps,  Next: Adding Python to an iOS project,  Up: Installing Python on iOS

3.7.2.1 Tools for building iOS apps
...................................

Building for iOS requires the use of Apple's Xcode tooling.  It is
strongly recommended that you use the most recent stable release of
Xcode.  This will require the use of the most (or second-most) recently
released macOS version, as Apple does not maintain Xcode for older macOS
versions.  The Xcode Command Line Tools are not sufficient for iOS
development; you need a 'full' Xcode install.

If you want to run your code on the iOS simulator, you'll also need to
install an iOS Simulator Platform.  You should be prompted to select an
iOS Simulator Platform when you first run Xcode.  Alternatively, you can
add an iOS Simulator Platform by selecting from the Platforms tab of the
Xcode Settings panel.


File: python.info,  Node: Adding Python to an iOS project,  Prev: Tools for building iOS apps,  Up: Installing Python on iOS

3.7.2.2 Adding Python to an iOS project
.......................................

Python can be added to any iOS project, using either Swift or Objective
C. The following examples will use Objective C; if you are using Swift,
you may find a library like PythonKit(1) to be helpful.

To add Python to an iOS Xcode project:

  1. Build or obtain a Python ‘XCFramework’.  See the instructions in
     iOS/README.rst(2) (in the CPython source distribution) for details
     on how to build a Python ‘XCFramework’.  At a minimum, you will
     need a build that supports ‘arm64-apple-ios’, plus one of either
     ‘arm64-apple-ios-simulator’ or ‘x86_64-apple-ios-simulator’.

  2. Drag the ‘XCframework’ into your iOS project.  In the following
     instructions, we'll assume you've dropped the ‘XCframework’ into
     the root of your project; however, you can use any other location
     that you want by adjusting paths as needed.

  3. Drag the ‘iOS/Resources/dylib-Info-template.plist’ file into your
     project, and ensure it is associated with the app target.

  4. Add your application code as a folder in your Xcode project.  In
     the following instructions, we'll assume that your user code is in
     a folder named ‘app’ in the root of your project; you can use any
     other location by adjusting paths as needed.  Ensure that this
     folder is associated with your app target.

  5. Select the app target by selecting the root node of your Xcode
     project, then the target name in the sidebar that appears.

  6. In the "General" settings, under "Frameworks, Libraries and
     Embedded Content", add ‘Python.xcframework’, with "Embed & Sign"
     selected.

  7. In the "Build Settings" tab, modify the following:

        - Build Options

             * User Script Sandboxing: No

             * Enable Testability: Yes

        - Search Paths

             * Framework Search Paths: ‘$(PROJECT_DIR)’

             * Header Search Paths:
               ‘"$(BUILT_PRODUCTS_DIR)/Python.framework/Headers"’

        - Apple Clang - Warnings - All languages

             * Quoted Include In Framework Header: No

  8. Add a build step that copies the Python standard library into your
     app.  In the "Build Phases" tab, add a new "Run Script" build step
     'before' the "Embed Frameworks" step, but 'after' the "Copy Bundle
     Resources" step.  Name the step "Install Target Specific Python
     Standard Library", disable the "Based on dependency analysis"
     checkbox, and set the script content to:

          set -e

          mkdir -p "$CODESIGNING_FOLDER_PATH/python/lib"
          if [ "$EFFECTIVE_PLATFORM_NAME" = "-iphonesimulator" ]; then
              echo "Installing Python modules for iOS Simulator"
              rsync -au --delete "$PROJECT_DIR/Python.xcframework/ios-arm64_x86_64-simulator/lib/" "$CODESIGNING_FOLDER_PATH/python/lib/"
          else
              echo "Installing Python modules for iOS Device"
              rsync -au --delete "$PROJECT_DIR/Python.xcframework/ios-arm64/lib/" "$CODESIGNING_FOLDER_PATH/python/lib/"
          fi

     Note that the name of the simulator "slice" in the XCframework may
     be different, depending the CPU architectures your ‘XCFramework’
     supports.

  9. Add a second build step that processes the binary extension modules
     in the standard library into "Framework" format.  Add a "Run
     Script" build step 'directly after' the one you added in step 8,
     named "Prepare Python Binary Modules".  It should also have "Based
     on dependency analysis" unchecked, with the following script
     content:

          set -e

          install_dylib () {
              INSTALL_BASE=$1
              FULL_EXT=$2

              # The name of the extension file
              EXT=$(basename "$FULL_EXT")
              # The location of the extension file, relative to the bundle
              RELATIVE_EXT=${FULL_EXT#$CODESIGNING_FOLDER_PATH/}
              # The path to the extension file, relative to the install base
              PYTHON_EXT=${RELATIVE_EXT/$INSTALL_BASE/}
              # The full dotted name of the extension module, constructed from the file path.
              FULL_MODULE_NAME=$(echo $PYTHON_EXT | cut -d "." -f 1 | tr "/" ".");
              # A bundle identifier; not actually used, but required by Xcode framework packaging
              FRAMEWORK_BUNDLE_ID=$(echo $PRODUCT_BUNDLE_IDENTIFIER.$FULL_MODULE_NAME | tr "_" "-")
              # The name of the framework folder.
              FRAMEWORK_FOLDER="Frameworks/$FULL_MODULE_NAME.framework"

              # If the framework folder doesn't exist, create it.
              if [ ! -d "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER" ]; then
                  echo "Creating framework for $RELATIVE_EXT"
                  mkdir -p "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER"
                  cp "$CODESIGNING_FOLDER_PATH/dylib-Info-template.plist" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist"
                  plutil -replace CFBundleExecutable -string "$FULL_MODULE_NAME" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist"
                  plutil -replace CFBundleIdentifier -string "$FRAMEWORK_BUNDLE_ID" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/Info.plist"
              fi

              echo "Installing binary for $FRAMEWORK_FOLDER/$FULL_MODULE_NAME"
              mv "$FULL_EXT" "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME"
              # Create a placeholder .fwork file where the .so was
              echo "$FRAMEWORK_FOLDER/$FULL_MODULE_NAME" > ${FULL_EXT%.so}.fwork
              # Create a back reference to the .so file location in the framework
              echo "${RELATIVE_EXT%.so}.fwork" > "$CODESIGNING_FOLDER_PATH/$FRAMEWORK_FOLDER/$FULL_MODULE_NAME.origin"
           }

           PYTHON_VER=$(ls -1 "$CODESIGNING_FOLDER_PATH/python/lib")
           echo "Install Python $PYTHON_VER standard library extension modules..."
           find "$CODESIGNING_FOLDER_PATH/python/lib/$PYTHON_VER/lib-dynload" -name "*.so" | while read FULL_EXT; do
              install_dylib python/lib/$PYTHON_VER/lib-dynload/ "$FULL_EXT"
           done

           # Clean up dylib template
           rm -f "$CODESIGNING_FOLDER_PATH/dylib-Info-template.plist"

           echo "Signing frameworks as $EXPANDED_CODE_SIGN_IDENTITY_NAME ($EXPANDED_CODE_SIGN_IDENTITY)..."
           find "$CODESIGNING_FOLDER_PATH/Frameworks" -name "*.framework" -exec /usr/bin/codesign --force --sign "$EXPANDED_CODE_SIGN_IDENTITY" ${OTHER_CODE_SIGN_FLAGS:-} -o runtime --timestamp=none --preserve-metadata=identifier,entitlements,flags --generate-entitlement-der "{}" \;

  10. Add Objective C code to initialize and use a Python interpreter in
     embedded mode.  You should ensure that:

        * *note UTF-8 mode: 3c4. is 'enabled';

        * *note Buffered stdio: 3b9. is 'disabled';

        * *note Writing bytecode: 3b5. is 'disabled';

        * *note Signal handlers: 88c. are 'enabled';

        * ‘PYTHONHOME’ for the interpreter is configured to point at the
          ‘python’ subfolder of your app's bundle; and

        * The ‘PYTHONPATH’ for the interpreter includes:

             - the ‘python/lib/python3.X’ subfolder of your app's
               bundle,

             - the ‘python/lib/python3.X/lib-dynload’ subfolder of your
               app's bundle, and

             - the ‘app’ subfolder of your app's bundle

     Your app's bundle location can be determined using ‘[[NSBundle
     mainBundle] resourcePath]’.

Steps 8, 9 and 10 of these instructions assume that you have a single
folder of pure Python application code, named ‘app’.  If you have
third-party binary modules in your app, some additional steps will be
required:

   * You need to ensure that any folders containing third-party binaries
     are either associated with the app target, or copied in as part of
     step 8.  Step 8 should also purge any binaries that are not
     appropriate for the platform a specific build is targeting (i.e.,
     delete any device binaries if you're building an app targeting the
     simulator).

   * Any folders that contain third-party binaries must be processed
     into framework form by step 9.  The invocation of ‘install_dylib’
     that processes the ‘lib-dynload’ folder can be copied and adapted
     for this purpose.

   * If you're using a separate folder for third-party packages, ensure
     that folder is included as part of the ‘PYTHONPATH’ configuration
     in step 10.

   ---------- Footnotes ----------

   (1) https://github.com/pvieito/PythonKit

   (2) https://github.com/python/cpython/tree/3.13/iOS/README.rst


File: python.info,  Node: App Store Compliance,  Prev: Installing Python on iOS,  Up: Using Python on iOS

3.7.3 App Store Compliance
--------------------------

The only mechanism for distributing apps to third-party iOS devices is
to submit the app to the iOS App Store; apps submitted for distribution
must pass Apple's app review process.  This process includes a set of
automated validation rules that inspect the submitted application bundle
for problematic code.

The Python standard library contains some code that is known to violate
these automated rules.  While these violations appear to be false
positives, Apple's review rules cannot be challenged; so, it is
necessary to modify the Python standard library for an app to pass App
Store review.

The Python source tree contains a patch file(1) that will remove all
code that is known to cause issues with the App Store review process.
This patch is applied automatically when building for iOS.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Mac/Resources/app-store-compliance.patch


File: python.info,  Node: エディタと IDE,  Prev: Using Python on iOS,  Up: Python のセットアップと利用

3.8 エディタと IDE
==================

Python プログラミング言語をサポートする IDE はたくさんあります。 多くの
エディタや IDE にはシンタックスハイライト機能、デバッグツール、 PEP 8(1)
チェック機能があります。

包括的な一覧を見るには、 Python Editors(2) や Integrated Development
Environments(3) を訪れてください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0008/

   (2) https://wiki.python.org/moin/PythonEditors

   (3) https://wiki.python.org/moin/IntegratedDevelopmentEnvironments


File: python.info,  Node: Python 言語リファレンス,  Next: Python 標準ライブラリ,  Prev: Python のセットアップと利用,  Up: Top

4 Python 言語リファレンス
*************************

このリファレンスマニュアルでは、Python 言語の文法と、 "コアとなるセマン
ティクス" について記述します。このマニュアルはそっけない書き方かもしれま
せんが、正確さと完全さを優先しています。必須でない組み込みオブジェクト型
や組み込み関数、組み込みモジュールに関するセマンティクスは、 *note
Python 標準ライブラリ: 12a. で述べられています。形式ばらない Python 言語
入門には、 *note Python チュートリアル: 1b45. を参照してください。 C 言
語あるいはC++プログラマ向けには、このマニュアルとは別に二つのマニュアル
があります。 *note Python インタプリタの拡張と埋め込み: 1b46. では、
Python 拡張モジュールを書くための高レベルな様式について述べています。ま
た、 *note Python/C API リファレンスマニュアル: 1b47. では、C/C++ プログ
ラマが利用できるインターフェースについて詳細に記述しています。

* Menu:

* はじめに: はじめに<5>.
* 字句解析::
* データモデル::
* 実行モデル::
* インポートシステム::
* 式 (expression): 式 expression.
* 単純文 (simple statement): 単純文 simple statement.
* 複合文 (compound statement): 複合文 compound statement.
* トップレベル要素::
* 完全な文法仕様::


File: python.info,  Node: はじめに<5>,  Next: 字句解析,  Up: Python 言語リファレンス

4.1 はじめに
============

このリファレンスマニュアルは、Python プログラミング言語自体に関する記述
です。チュートリアルとして書かれたものではありません。

私は本マニュアルをできるだけ正確に書こうとする一方で、文法や字句解析以外
の全てについて、形式化された仕様記述ではなく英語を使うことにしました。そ
うすることで、このドキュメントが平均的な読者にとってより読みやすくなって
いるはずですが、ややあいまいな部分も残っていることでしょう。従って、もし
読者のあなたが火星から来ている人で、このドキュメントだけから Python を再
度実装しようとしているのなら、色々と推測しなければならないことがあり、実
際にはおそらく全く別の言語を実装する羽目になるでしょう。逆に、あなたが
Python を利用しており、Python 言語のある特定の領域において、厳密な規則が
何か疑問に思った場合、その答えはこのドキュメントで確実に見つけられること
でしょう。もしより形式化された言語定義をお望みなら、あなたの時間を提供し
ていただいてかまいません -- もしくは、クローン生成装置でも発明してくださ
い :-)。

実装に関する詳細を言語リファレンスのドキュメントに載せすぎるのは危険なこ
とです -- 実装は変更されるかもしれず、同じ言語でも異なる実装は異なった動
作をするかもしれないからです。一方、CPython が広く使われている一つの
Python 実装 (別の実装も支持され続けていますが) なので、特定のクセについ
ては、特に実装によって何らかの制限が加えられている場合には、触れておく価
値があります。従って、このテキスト全体にわたって短い "実装に関する注釈
(imprementation notes)" がちりばめられています。

Python 実装はいずれも、数々の組み込みモジュールと標準モジュールが付属し
ます。それらについては、 *note Python 標準ライブラリ: 12a. でドキュメン
ト化されています。いくつかの組み込みモジュールについては、言語定義と重要
なかかわりをもっているときについて触れています。

* Menu:

* 別のPythonの実装::
* 本マニュアルにおける表記法::


File: python.info,  Node: 別のPythonの実装,  Next: 本マニュアルにおける表記法,  Up: はじめに<5>

4.1.1 別のPythonの実装
----------------------

Pythonの実装としては、群を抜いて有名な実装がひとつ存在しています。それ以
外の実装に関しても、特定のユーザ間で興味が持たれています。

よく知られている実装には以下のものがあります:

CPython

     これは最も保守されている初代のPython実装で、C言語で書かれています。
     ほとんどの場合、言語の新機能がいち早く実装されます。

Jython

     Javaで実装されたPythonです。この実装はJavaアプリケーションのための
     スクリプト言語として、もしくはJavaクラスライブラリを使ったアプリケ
     ーションを作成するために使用することができます。また、Javaライブラ
     リのテストを作成するためにもしばしば使用されています。さらなる情報
     については the Jython website(1) を参照してください。

Python for .NET

     この実装は内部ではCPythonを使用していますが、 .NETアプリケーション
     によって管理されているので、 .NETライブラリを参照することが可能です
     。この実装はBrian Lloydによって作成されました。さらなる情報について
     は、 Python for .NET home page(2) を参照してください。

IronPython

     .NETでPythonを使用するためのもう一つの実装です。Python.NETとは異な
     り、完全にILを生成することができるPythonの実装あり、直接Pythonコー
     ドを.NETアセンブリにコンパイルします。これはJythonの初代の開発者で
     あるJim Huguninによって作られました。さらなる情報については the
     IronPython website(3) を参照してください。

PyPy

     完全にPythonで書かれたPythonの実装です。他の実装には見られない、ス
     タックレスのサポートや、実行時 (Just in Time) コンパイラなどの高度
     な機能をサポートしています。このプロジェクトの一つの目的は、（
     Pythonで書かれていることによって、）インタプリタを簡単に修正できる
     ようにして、言語自体での実験を後押しすることです。さらなる情報は
     the PyPy project's home page(4) にあります。

これらの各実装はこのマニュアルで文書化された言語とは多少異なっている、も
しくは、標準のPythonドキュメントと何処が異なっているかを定めた情報が公開
されているでしょう。あなたが使用している実装上で、代替手段を使う必要があ
るかどうかを判断するためには、各実装の仕様書を参照してください。

   ---------- Footnotes ----------

   (1) https://www.jython.org/

   (2) https://pythonnet.github.io/

   (3) https://ironpython.net/

   (4) https://pypy.org/


File: python.info,  Node: 本マニュアルにおける表記法,  Prev: 別のPythonの実装,  Up: はじめに<5>

4.1.2 本マニュアルにおける表記法
--------------------------------

The descriptions of lexical analysis and syntax use a modified
Backus–Naur form (BNF)(1) grammar notation.  This uses the following
style of definition:

     name      ::= lc_letter (lc_letter | "_")*
     lc_letter ::= "a"..."z"

最初の行は、‘name’ が ‘lc_letter’ の後ろにゼロ個またはそれ以上の
‘lc_letter’ とアンダースコアが続いたものであることを示しています。そして
、‘lc_letter’ は ‘'a'’ から ‘'z'’ までの何らかの文字一字であることを示し
ます。 (この規則は、このドキュメントに記述されている字句規則と構文規則に
おいて定義されている名前 (name) で一貫して使われています)。

各規則は name (規則によって定義されているものの名前) と ‘::=’ から始まり
ます。垂直線 (‘|’) は、複数の選択項目を分かち書きするときに使います; こ
の記号は、この記法において最も結合優先度の低い演算子です。アスタリスク
(‘*’) は、直前にくる要素のゼロ個以上の繰り返しを表します; 同様に、プラス
(‘+’) は一個以上の繰り返しで、角括弧 (‘[ ]’) に囲われた字句は、字句がゼ
ロ個か一個出現する (別の言い方をすれば、囲いの中の字句はオプションである
) ことを示します。‘*’ および ‘+’ 演算子の結合範囲は可能な限り狭くなって
います; 字句のグループ化には丸括弧を使います。リテラル文字列はクオートで
囲われます。空白はトークンを分割しているときのみ意味を持ちます。規則は通
常、一行中に収められています; 多数の選択肢のある規則は、最初の行につづい
て、垂直線の後ろに各々別の行として記述されます。

(上の例のような) 字句定義では、他に二つの慣習が使われています: 三つのド
ットで区切られている二つのリテラル文字は、二つの文字の ASCII 文字コード
における (包含的な) 範囲から文字を一字選ぶことを示します。各カッコ中の字
句 (‘<...>’) は、定義済みのシンボルを記述する非形式的なやりかたです; 例
えば、'制御文字' を書き表す必要があるときなどに使われることがあります。

字句と構文規則の定義の間で使われている表記はほとんど同じですが、その意味
には大きな違いがあります: 字句定義は入力ソース中の個々の文字を取り扱いま
すが、構文定義は字句解析で生成された一連のトークンを取り扱います。次節
("字句解析") における BNF はすべて字句定義のためのものです; それ以降の章
では、構文定義のために使っています。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form


File: python.info,  Node: 字句解析,  Next: データモデル,  Prev: はじめに<5>,  Up: Python 言語リファレンス

4.2 字句解析
============

Python で書かれたプログラムは 'パーザ (parser)' に読み込まれます。パーザ
への入力は、 '字句解析器 (lexical analyzer)' によって生成された一連の 'ト
ークン (token)' からなります。この章では、字句解析器がファイルをトークン
列に分解する方法について解説します。

Python はプログラムテキストを Unicode コードポイントとして読み込みます。
ソースファイルのエンコーディングはエンコーディング宣言で与えられ、デフォ
ルトは UTF-8 です。詳細は PEP 3120(1) を参照してください。ソースファイル
がデコードできなければ、 *note SyntaxError: 172. が送出されます。

* Menu:

* 行構造::
* その他のトークン::
* 識別子 (identifier) およびキーワード (keyword): 識別子 identifier およびキーワード keyword.
* リテラル::
* 演算子::
* デリミタ (delimiter): デリミタ delimiter.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3120/


File: python.info,  Node: 行構造,  Next: その他のトークン,  Up: 字句解析

4.2.1 行構造
------------

Python プログラムは多数の '論理行 (logical lines)' に分割されます。

* Menu:

* 論理行 (logical line): 論理行 logical line.
* 物理行 (physical line): 物理行 physical line.
* コメント (Comments): コメント Comments.
* エンコード宣言 (encoding declaration): エンコード宣言 encoding declaration.
* 明示的な行継続::
* 非明示的な行継続::
* 空行::
* インデント::
* トークン間の空白::


File: python.info,  Node: 論理行 logical line,  Next: 物理行 physical line,  Up: 行構造

4.2.1.1 論理行 (logical line)
.............................

論理行の終端は、トークン NEWLINE で表されます。構文上許されている場合 (複
合文: compound statement 中の実行文: statement) を除いて、実行文は論理行
間にまたがることはできません。論理行は一行またはそれ以上の '物理行
(physical line)' からなり、物理行の末尾には明示的または非明示的な '行連
結(line joining)' 規則が続きます。


File: python.info,  Node: 物理行 physical line,  Next: コメント Comments,  Prev: 論理行 logical line,  Up: 行構造

4.2.1.2 物理行 (physical line)
..............................

物理行とは、行終端コードで区切られた文字列のことです。 ソースファイルや
ソース文字列では、各プラットフォームごとの標準の行終端コードを使用するこ
とができます。 Unix形式ではASCII LF (行送り: linefeed)文字、 Windows形式
ではASCII 配列の CR LF (復帰: return に続いて行送り) 、 Macintosh形式で
はASCII CR (復帰) 文字です。 これら全ての形式のコードは、違うプラットフ
ォームでも等しく使用することができます。 入力の末尾も、最後の物理行の暗
黙的な終端としての役割を果たします。

Pythonに埋め込む場合には、標準のC言語の改行文字の変換規則 (ASCII LFを表
現した文字コード ‘\n’ が行終端となります) に従って、 Python APIにソース
コードを渡す必要があります。


File: python.info,  Node: コメント Comments,  Next: エンコード宣言 encoding declaration,  Prev: 物理行 physical line,  Up: 行構造

4.2.1.3 コメント (Comments)
...........................

コメントは文字列リテラル内に入っていないハッシュ文字 (‘#’) から始まり、
同じ物理行の末端で終わります。 非明示的な行継続規則が適用されていない限
り、コメントは論理行を終端させます。 コメントは構文上無視されます。


File: python.info,  Node: エンコード宣言 encoding declaration,  Next: 明示的な行継続,  Prev: コメント Comments,  Up: 行構造

4.2.1.4 エンコード宣言 (encoding declaration)
.............................................

Python スクリプト中の一行目か二行目にあるコメントが正規表現
‘coding[=:]\s*([-\w.]+)’ にマッチする場合、コメントはエンコード宣言とし
て処理されます; この表現の最初のグループがソースコードファイルのエンコー
ドを指定します。エンコード宣言は自身の行になければなりません。二行目にあ
る場合、一行目もコメントのみの行でなければなりません。エンコード宣言式と
して推奨する形式は

     # -*- coding: <encoding-name> -*-

これは GNU Emacs で認識できます。または

     # vim:fileencoding=<encoding-name>

これは、Bram Moolenar による VIM が認識できる形式です。

If no encoding declaration is found, the default encoding is UTF-8.  If
the implicit or explicit encoding of a file is UTF-8, an initial UTF-8
byte-order mark (b'xefxbbxbf') is ignored rather than being a syntax
error.

エンコーディングが宣言される場合、そのエンコーディング名は Python によっ
て認識できなければなりません (*note 標準エンコーディング: d86. を参照し
てください)。宣言されたエンコーディングは、例えば文字列リテラル、コメン
ト、識別子などの、全ての字句解析に使われます。


File: python.info,  Node: 明示的な行継続,  Next: 非明示的な行継続,  Prev: エンコード宣言 encoding declaration,  Up: 行構造

4.2.1.5 明示的な行継続
......................

二つまたはそれ以上の物理行を論理行としてつなげるためには、バックスラッシ
ュ文字 (‘\’) を使って以下のようにします: 物理行が文字列リテラルやコメン
ト中の文字でないバックスラッシュで終わっている場合、後続する行とつなげて
一つの論理行を構成し、バックスラッシュおよびバックスラッシュの後ろにある
行末文字を削除します。例えば:

     if 1900 < year < 2100 and 1 <= month <= 12 \
        and 1 <= day <= 31 and 0 <= hour < 24 \
        and 0 <= minute < 60 and 0 <= second < 60:   # Looks like a valid date
             return 1

バックスラッシュで終わる行にはコメントを入れることはできません。また、バ
ックスラッシュを使ってコメントを継続することはできません。バックスラッシ
ュが文字列リテラル中にある場合を除き、バックスラッシュの後ろにトークンを
継続することはできません (すなわち、物理行内の文字列リテラル以外のトーク
ンをバックスラッシュを使って分断することはできません)。上記以外の場所で
は、文字列リテラル外にあるバックスラッシュはどこにあっても不正となります
。


File: python.info,  Node: 非明示的な行継続,  Next: 空行,  Prev: 明示的な行継続,  Up: 行構造

4.2.1.6 非明示的な行継続
........................

丸括弧 (parentheses)、角括弧 (square bracket) 、および波括弧 (curly
brace) 内の式は、バックスラッシュを使わずに一行以上の物理行に分割するこ
とができます。例えば:

     month_names = ['Januari', 'Februari', 'Maart',      # These are the
                    'April',   'Mei',      'Juni',       # Dutch names
                    'Juli',    'Augustus', 'September',  # for the months
                    'Oktober', 'November', 'December']   # of the year

非明示的に継続された行にはコメントを含めることができます。継続行のインデ
ントは重要ではありません。空の継続行を書くことができます。非明示的な継続
行中には、NEWLINE トークンは存在しません。非明示的な行の継続は、三重クオ
ートされた文字列 (下記参照) でも発生します; この場合には、コメントを含め
ることができません。


File: python.info,  Node: 空行,  Next: インデント,  Prev: 非明示的な行継続,  Up: 行構造

4.2.1.7 空行
............

スペース、タブ、フォームフィード、およびコメントのみを含む論理行は無視さ
れます (すなわち、NEWLINE トークンは生成されません)。文を対話的に入力し
ている際には、空行の扱いは行読み込み-評価-出力 (read-eval-print) ループ
の実装によって異なることがあります。標準的な対話的インタプリタの実装では
、完全な空行でできた論理行 (すなわち、空白文字もコメントも全く含まない空
行) は、複数行からなる文の終端を示します。


File: python.info,  Node: インデント,  Next: トークン間の空白,  Prev: 空行,  Up: 行構造

4.2.1.8 インデント
..................

論理行の行頭にある、先頭の空白 (スペースおよびタブ) の連なりは、その行の
インデントレベルを計算するために使われます。インデントレベルは、実行文の
グループ化方法を決定するために用いられます。

タブは (左から右の方向に) 1 つにつき 8 つのスペースで置き換えられ、置き
換え後の文字数は 8 の倍数になります (Unix で使われている規則と同じになる
よう意図されています)。そして、最初の非空白文字までのスペースの総数が、
その行のインデントを決定します。インデントは、バックスラッシュで複数の物
理行に分割できません; 最初のバックスラッシュまでの空白がインデントを決定
します。

ソースファイルがタブとスペースを混在させ、その意味づけがタブのスペース換
算数に依存するようなら、インデントは不合理なものとして却下されます。その
場合は *note TabError: 50e. が送出されます。

'プラットフォーム間の互換性に関する注意:' 非 UNIX プラットフォームにおけ
るテキストエディタの性質上、一つのソースファイル内でタブとインデントを混
在させて使うのは賢明ではありません。また、プラットフォームによっては、最
大インデントレベルを明示的に制限しているかもしれません。

フォームフィード文字が行の先頭にあっても構いません; フォームフィード文字
は上のインデントレベル計算時には無視されます。フォームフィード文字が先頭
の空白中の他の場所にある場合、その影響は未定義です (例えば、スペースの数
を 0 にリセットするかもしれません)。

連続する行における各々のインデントレベルは、 INDENT および DEDENT トーク
ンを生成するために使われます。トークンの生成はスタックを用いて以下のよう
に行われます。

ファイル中の最初の行を読み出す前に、スタックにゼロが一つ積まれ (push さ
れ) ます; このゼロは決して除去 (pop) されることはありません。スタックの
先頭に積まれてゆく数字は、常にスタックの末尾から先頭にかけて厳密に増加す
るようになっています。各論理行の開始位置において、その行のインデントレベ
ル値がスタックの先頭の値と比較されます。値が等しければ何もしません。イン
デントレベル値がスタック上の値よりも大きければ、インデントレベル値はスタ
ックに積まれ、INDENT トークンが一つ生成されます。インデントレベル値がス
タック上の値よりも小さい場合、その値はスタック内のいずれかの値と '等しく
なければなりません' ; スタック上のインデントレベル値よりも大きい値はすべ
て除去され、値が一つ除去されるごとに DEDENT トークンが一つ生成されます。
ファイルの末尾では、スタックに残っているゼロより大きい値は全て除去され、
値が一つ除去されるごとに DEDENT トークンが一つ生成されます。

以下の例に正しく (しかし当惑させるように) インデントされた Python コード
の一部を示します:

     def perm(l):
             # Compute the list of all permutations of l
         if len(l) <= 1:
                       return [l]
         r = []
         for i in range(len(l)):
                  s = l[:i] + l[i+1:]
                  p = perm(s)
                  for x in p:
                   r.append(l[i:i+1] + x)
         return r

以下の例は、様々なインデントエラーになります:

      def perm(l):                       # error: first line indented
     for i in range(len(l)):             # error: not indented
         s = l[:i] + l[i+1:]
             p = perm(l[:i] + l[i+1:])   # error: unexpected indent
             for x in p:
                     r.append(l[i:i+1] + x)
                 return r                # error: inconsistent dedent

(実際は、最初の 3 つのエラーはパーザによって検出されます; 最後のエラーの
みが字句解析器で見つかります -- ‘return r’ のインデントは、スタックから
逐次除去されていくどのインデントレベル値とも一致しません)


File: python.info,  Node: トークン間の空白,  Prev: インデント,  Up: 行構造

4.2.1.9 トークン間の空白
........................

論理行の先頭や文字列の内部にある場合を除き、空白文字であるスペース、タブ
、およびフォームフィードは、トークンを分割するために自由に利用することが
できます。二つのトークンを並べて書くと別のトークンとしてみなされてしまう
ような場合には、トークンの間に空白が必要となります (例えば、ab は一つの
トークンですが、 a b は二つのトークンとなります)。


File: python.info,  Node: その他のトークン,  Next: 識別子 identifier およびキーワード keyword,  Prev: 行構造,  Up: 字句解析

4.2.2 その他のトークン
----------------------

NEWLINE、INDENT、および DEDENT の他、以下のトークンのカテゴリ: '識別子
(identifier)', 'キーワード(keyword)', 'リテラル', '演算子 (operator)',
'デリミタ (delimiter)' が存在します。空白文字 (上で述べた行終端文字以外)
はトークンではありませんが、トークンを区切る働きがあります。トークンの解
析にあいまいさが生じた場合、トークンは左から右に読んで不正でないトークン
を構築できる最長の文字列を含むように構築されます。


File: python.info,  Node: 識別子 identifier およびキーワード keyword,  Next: リテラル,  Prev: その他のトークン,  Up: 字句解析

4.2.3 識別子 (identifier) およびキーワード (keyword)
----------------------------------------------------

識別子 (または '名前 (name)') は、以下の字句定義で記述されます。

Python における識別子の構文は、Unicode 標準仕様添付書類 UAX-31 に基づき
、詳細と変更点は以下で定義します。詳しくは PEP 3131(1) を参照してくださ
い。

Within the ASCII range (U+0001..U+007F), the valid characters for
identifiers include the uppercase and lowercase letters ‘A’ through ‘Z’,
the underscore ‘_’ and, except for the first character, the digits ‘0’
through ‘9’.  Python 3.0 introduced additional characters from outside
the ASCII range (see PEP 3131(2)).  For these characters, the
classification uses the version of the Unicode Character Database as
included in the *note unicodedata: ee. module.

識別子の長さには制限がありません。大小文字は区別されます。

     identifier   ::= xid_start xid_continue*
     id_start     ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>
     id_continue  ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>
     xid_start    ::= <all characters in id_start whose NFKC normalization is in "id_start xid_continue*">
     xid_continue ::= <all characters in id_continue whose NFKC normalization is in "id_continue*">

上で言及した Unicode カテゴリコードは以下を表します:

   * 'Lu' - 大文字 (uppercase letters)

   * 'Ll' - 小文字 (lowercase letters)

   * 'Lt' - 先頭が大文字 (titlecase letters)

   * 'Lm' - 修飾文字 (modifier letters)

   * 'Lo' - その他の文字 (other letters)

   * 'Nl' - 数値を表す文字 (letter numbers)

   * 'Mn' - 字幅のない記号 (nonspacing marks)

   * 'Mc' - 字幅のある結合記号 (spacing combining marks)

   * 'Nd' - 10 進数字 (decimal numbers)

   * 'Pc' - 連結用句読記号 (connector punctuations)

   * 'Other_ID_Start' - explicit list of characters in PropList.txt(3)
     to support backwards compatibility

   * 'Other_ID_Continue' - 同様

すべての識別子は、解析中は正規化形式 NFKC に変換されます。識別子間の比較
は NFKC に基づきます。

A non-normative HTML file listing all valid identifier characters for
Unicode 15.1.0 can be found at
‘https://www.unicode.org/Public/15.1.0/ucd/DerivedCoreProperties.txt’

* Menu:

* キーワード (keyword): キーワード keyword.
* ソフトキーワード::
* 予約済みの識別子種 (reserved classes of identifiers): 予約済みの識別子種 reserved classes of identifiers.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3131/

   (2) https://peps.python.org/pep-3131/

   (3) https://www.unicode.org/Public/15.1.0/ucd/PropList.txt


File: python.info,  Node: キーワード keyword,  Next: ソフトキーワード,  Up: 識別子 identifier およびキーワード keyword

4.2.3.1 キーワード (keyword)
............................

以下の識別子は、予約語、または Python 言語における 'キーワード
(keyword)' として使われ、通常の識別子として使うことはできません。キーワ
ードは厳密に下記の通りに綴らなければなりません:

     False      await      else       import     pass
     None       break      except     in         raise
     True       class      finally    is         return
     and        continue   for        lambda     try
     as         def        from       nonlocal   while
     assert     del        global     not        with
     async      elif       if         or         yield


File: python.info,  Node: ソフトキーワード,  Next: 予約済みの識別子種 reserved classes of identifiers,  Prev: キーワード keyword,  Up: 識別子 identifier およびキーワード keyword

4.2.3.2 ソフトキーワード
........................

Added in version 3.10.

Some identifiers are only reserved under specific contexts.  These are
known as 'soft keywords'.  The identifiers ‘match’, ‘case’, ‘type’ and
‘_’ can syntactically act as keywords in certain contexts, but this
distinction is done at the parser level, not when tokenizing.

As soft keywords, their use in the grammar is possible while still
preserving compatibility with existing code that uses these names as
identifier names.

‘match’, ‘case’, and ‘_’ are used in the *note match: 7d8. statement.
‘type’ is used in the *note type: 404. statement.

バージョン 3.12 で変更: ‘type’ is now a soft keyword.


File: python.info,  Node: 予約済みの識別子種 reserved classes of identifiers,  Prev: ソフトキーワード,  Up: 識別子 identifier およびキーワード keyword

4.2.3.3 予約済みの識別子種 (reserved classes of identifiers)
............................................................

ある種の (キーワードを除く) 識別子には、特殊な意味があります。これらの識
別子種は、先頭や末尾にあるアンダースコア文字のパターンで区別されます:

‘_*’

     Not imported by ‘from module import *’.

‘_’

     In a ‘case’ pattern within a *note match: 7d8. statement, ‘_’ is a
     *note soft keyword: 7d7. that denotes a *note wildcard: 7d9.

     Separately, the interactive interpreter makes the result of the
     last evaluation available in the variable ‘_’.  (It is stored in
     the *note builtins: e. module, alongside built-in functions like
     ‘print’.)

     Elsewhere, ‘_’ is a regular identifier.  It is often used to name
     "special" items, but it is not special to Python itself.

          注釈: 名前 ‘_’ は、しばしば国際化 (internationalization) と共
          に用いられます; この慣習についての詳しい情報は、 *note
          gettext: 59. を参照してください。

          It is also commonly used for unused variables.

‘__*__’

     システムで定義された (system-defined) 名前です。非公式には
     "dunder"な名前と呼ばれます(訳注: double underscoresの略)。これらの
     名前はインタープリタと (標準ライブラリを含む) 実装上で定義されてい
     ます。 現行のシステムでの名前は *note 特殊メソッド名: c3c. などで話
     題に挙げられています。 Python の将来のバージョンではより多くの名前
     が定義されることになります。このドキュメントで明記されている用法に
     従わない、 'あらゆる' ‘__*__’ の名前は、いかなるコンテキストにおけ
     る利用でも、警告無く損害を引き起こすことがあります。

‘__*’

     クラスプライベート (class-private) な名前です。このカテゴリに属する
     名前は、クラス定義のコンテキスト上で用いられた場合、基底クラスと派
     生クラスの "プライベートな" 属性間で名前衝突が起こるのを防ぐために
     書き直されます。 *note 識別子 (identifier、または名前 (name)):
     1e02. を参照してください。


File: python.info,  Node: リテラル,  Next: 演算子,  Prev: 識別子 identifier およびキーワード keyword,  Up: 字句解析

4.2.4 リテラル
--------------

リテラル (literal) とは、いくつかの組み込み型の定数を表記したものです。

* Menu:

* 文字列およびバイト列リテラル::
* 文字列リテラルの結合 (concatenation): 文字列リテラルの結合 concatenation.
* f-strings::
* 数値リテラル::
* 整数リテラル::
* Floating-point literals::
* 虚数 (imaginary) リテラル: 虚数 imaginary リテラル.


File: python.info,  Node: 文字列およびバイト列リテラル,  Next: 文字列リテラルの結合 concatenation,  Up: リテラル

4.2.4.1 文字列およびバイト列リテラル
....................................

文字列リテラルは以下の字句定義で記述されます:

     stringliteral   ::= [stringprefix](shortstring | longstring)
     stringprefix    ::= "r" | "u" | "R" | "U" | "f" | "F"
                         | "fr" | "Fr" | "fR" | "FR" | "rf" | "rF" | "Rf" | "RF"
     shortstring     ::= "'" shortstringitem* "'" | '"' shortstringitem* '"'
     longstring      ::= "'''" longstringitem* "'''" | '"""' longstringitem* '"""'
     shortstringitem ::= shortstringchar | stringescapeseq
     longstringitem  ::= longstringchar | stringescapeseq
     shortstringchar ::= <any source character except "\" or newline or the quote>
     longstringchar  ::= <any source character except "\">
     stringescapeseq ::= "\" <any source character>

     bytesliteral   ::= bytesprefix(shortbytes | longbytes)
     bytesprefix    ::= "b" | "B" | "br" | "Br" | "bR" | "BR" | "rb" | "rB" | "Rb" | "RB"
     shortbytes     ::= "'" shortbytesitem* "'" | '"' shortbytesitem* '"'
     longbytes      ::= "'''" longbytesitem* "'''" | '"""' longbytesitem* '"""'
     shortbytesitem ::= shortbyteschar | bytesescapeseq
     longbytesitem  ::= longbyteschar | bytesescapeseq
     shortbyteschar ::= <any ASCII character except "\" or newline or the quote>
     longbyteschar  ::= <any ASCII character except "\">
     bytesescapeseq ::= "\" <any ASCII character>

上記の生成規則で示されていない文法的な制限が一つあります。リテラルの
*note stringprefix: 1e08. や *note bytesprefix: 1e11. と残りの部分の間に
空白を入れてはならないことです。ソースコード文字セット (source character
set) はエンコーディング宣言で定義されます。エンコーディング宣言がなけれ
ば UTF-8 です。節 *note エンコード宣言 (encoding declaration): 1de9. を
参照してください。

In plain English: Both types of literals can be enclosed in matching
single quotes (‘'’) or double quotes (‘"’).  They can also be enclosed
in matching groups of three single or double quotes (these are generally
referred to as 'triple-quoted strings').  The backslash (‘\’) character
is used to give special meaning to otherwise ordinary characters like
‘n’, which means 'newline' when escaped (‘\n’).  It can also be used to
escape characters that otherwise have a special meaning, such as
newline, backslash itself, or the quote character.  See *note escape
sequences: 426. below for examples.

バイト列リテラルには、常に ‘'b'’ や ‘'B'’ が接頭します。これらによって、
*note str: 418. 型ではなく *note bytes: 1a4. 型のインスタンスが作成され
ます。バイト列リテラルは ASCII 文字のみ含むことができます。 128 以上の数
値を持つバイトはエスケープして表されなければなりません。

Both string and bytes literals may optionally be prefixed with a letter
‘'r'’ or ‘'R'’; such constructs are called 'raw string literals' and
'raw bytes literals' respectively and treat backslashes as literal
characters.  As a result, in raw string literals, ‘'\U'’ and ‘'\u'’
escapes are not treated specially.

Added in version 3.3: raw バイト列リテラルの ‘'rb'’ プレフィックスが
‘'br'’ の同義語として追加されました。

Python 2.x と 3.x 両対応のコードベースのメンテナンスを単純化するために、
レガシー unicode リテラル (‘u'value'’) のサポートが再び導入されました。
詳細は PEP 414(1) を参照してください。

‘'f'’ または ‘'F'’ の接頭辞が付いた文字列リテラルはフォーマット済み文字
列リテラル（ 'formatted string literal' ）です。詳細については *note
フォーマット済み文字列リテラル: 977. を参照してください。接頭辞の ‘'f'’
は ‘'r'’ と組み合わせられますが、 ‘'b'’ や ‘'u'’ と組み合わせることはで
きません。つまりフォーマット済みの raw 文字列リテラルは可ですが、フォー
マット済みのバイト列リテラルは不可です。

三重クオートリテラル中には、三連のエスケープされないクオート文字でリテラ
ルを終端してしまわないかぎり、エスケープされていない改行やクオートを書く
ことができます (さらに、それらはそのまま文字列中に残ります)。(ここでいう
"クオート" とは、文字列の囲みを開始するときに使った文字を示し、‘'’ か
‘"’ のいずれかです。)

* Menu:

* Escape sequences::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0414/


File: python.info,  Node: Escape sequences,  Up: 文字列およびバイト列リテラル

4.2.4.2 Escape sequences
........................

‘'r'’ または ‘'R'’ 接頭文字がつかないかぎり、文字列またはバイト列リテラ
ル中のエスケープシーケンスは標準 C で使われているのと同様の法則にしたが
って解釈されます。以下に Python で認識されるエスケープシーケンスを示しま
す:

エスケープシーケンス          意味                                  注釈
                                                                    
--------------------------------------------------------------------------------
                                                                    
‘\’<newline>                  バックスラッシュと改行文字が無視さ    (1)
                              れます                                
                              
                                                                    
‘\\’                          バックスラッシュ (‘\’)
                              
                                                                    
‘\'’                          一重引用符 (‘'’)
                              
                                                                    
‘\"’                          二重引用符 (‘"’)
                              
                                                                    
‘\a’                          ASCII 端末ベル (BEL)
                              
                                                                    
‘\b’                          ASCII バックスペース (BS)
                              
                                                                    
‘\f’                          ASCII フォームフィード (FF)
                              
                                                                    
‘\n’                          ASCII 行送り (LF)
                              
                                                                    
‘\r’                          ASCII 復帰 (CR)
                              
                                                                    
‘\t’                          ASCII 水平タブ (TAB)
                              
                                                                    
‘\v’                          ASCII 垂直タブ (VT)
                              
                                                                    
‘\OOO’                        8 進数値 'ooo' を持つ文字             (2,4)
                                                                    
                                                                    
‘\xHH’                        16 進数値 'hh' を持つ文字             (3,4)
                                                                    

文字列でのみ認識されるエスケープシーケンスは以下のとおりです:

エスケープシーケンス          意味                                  注釈
                                                                    
--------------------------------------------------------------------------------
                                                                    
‘\N{NAME}’                    Unicode データベース中で 'name' と    (5)
                              いう名前の文字                        
                              
                                                                    
‘\uXXXX’                      16-bit の十六進値 'xxxx' を持つ文字   (6)
                                                                    
                                                                    
‘\UXXXXXXXX’                  32-bit の十六進値 'xxxxxxxx' を持つ   (7)
                              文字                                  
                              

注釈:

  1. A backslash can be added at the end of a line to ignore the
     newline:

          >>> 'This string will not include \
          ... backslashes or newline characters.'
          'This string will not include backslashes or newline characters.'

     The same result can be achieved using *note triple-quoted strings:
     1e06, or parentheses and *note string literal concatenation: 1e1a.

  2. 標準 C と同じく、最大で 3 桁の 8 進数まで受理します。

     バージョン 3.11 で変更: Octal escapes with value larger than
     ‘0o377’ produce a *note DeprecationWarning: 18a.

     バージョン 3.12 で変更: Octal escapes with value larger than
     ‘0o377’ produce a *note SyntaxWarning: 432.  In a future Python
     version they will be eventually a *note SyntaxError: 172.

  3. 標準 C とは違い、ちょうど 2 桁の 16 進数しか受理されません。

  4. バイト列リテラル中では、十六進および八進エスケープは与えられた値の
     バイトを表します。文字列リテラル中では、エスケープ文字は与えられた
     値を持つ Unicode 文字を表します。

  5. 
     バージョン 3.3 で変更: name aliases (1) に対するサポートが追加され
     ました。

  6. ちょうど 4 桁の 16 進数しか受理されません。

  7. あらゆるユニコード文字はこのようにしてエンコードすることができます
     。正確に8文字の16進数字が必要です。

標準の C とは違い、認識されなかったエスケープシーケンスはすべて、そのま
ま文字列中に残ります。すなわち、'バックスラッシュも結果中に残ります'。
(この挙動はデバッグの際に便利です: エスケープシーケンスが誤入力されたら
、その出力結果が失敗しているのが分かりやすくなります。) 文字列中でのみ認
識されるエスケープシーケンスは、バイト列リテラルには、認識されないエスケ
ープシーケンスとして分類されるので注意してください。

バージョン 3.6 で変更: Unrecognized escape sequences produce a *note
DeprecationWarning: 18a.

バージョン 3.12 で変更: Unrecognized escape sequences produce a *note
SyntaxWarning: 432.  In a future Python version they will be eventually
a *note SyntaxError: 172.

raw リテラルでも、引用符はバックスラッシュでエスケープできますが、バック
スラッシュ自体も文字列に残ります; 例えば、‘r"\""’ は有効な文字列リテラル
で、バックスラッシュと二重引用符からなる文字列を表します; ‘r"\"’ は無効
な文字列リテラルです (raw リテラルを奇数個連なったバックスラッシュで終わ
らせることはできません)。具体的には、(バックスラッシュが直後のクオート文
字をエスケープしてしまうので) 'raw文字列を単一のバックスラッシュで終わら
せることはできません' さらに、バックスラッシュの直後に改行がきても、行継
続を意味する 'のではなく'、リテラルの一部であるそれら二つの文字として解
釈されます。

   ---------- Footnotes ----------

   (1) ‘https://www.unicode.org/Public/15.1.0/ucd/NameAliases.txt’


File: python.info,  Node: 文字列リテラルの結合 concatenation,  Next: f-strings,  Prev: 文字列およびバイト列リテラル,  Up: リテラル

4.2.4.3 文字列リテラルの結合 (concatenation)
............................................

文字列やバイト列リテラルは、互いに異なる引用符を使っていても (空白文字で
区切っても) 複数隣接させることができます。これは各々の文字列を結合するの
と同じ意味を持ちます。したがって、‘"hello" 'world'’ は ‘"helloworld"’ と
同じです。この機能を使うと、バックスラッシュを減らしたり、長い文字列を手
軽に分離して複数行にまたがらせたり、あるいは部分文字列ごとにコメントを追
加することさえできます。例えば:

     re.compile("[A-Za-z_]"       # letter or underscore
                "[A-Za-z0-9_]*"   # letter, digit or underscore
               )

この機能は文法レベルで定義されていますが、スクリプトをコンパイルする際の
処理として実現されることに注意してください。実行時に文字列表現を結合した
ければ、 '+' 演算子を使わなければなりません。また、リテラルの結合におい
ては、結合する各要素に異なる引用符形式を使ったり (raw 文字列と三重引用符
を混ぜることさえできます) 、フォーマット済み文字列リテラルと通常の文字列
リテラルを結合したりすることもできますので注意してください。


File: python.info,  Node: f-strings,  Next: 数値リテラル,  Prev: 文字列リテラルの結合 concatenation,  Up: リテラル

4.2.4.4 f-strings
.................

Added in version 3.6.

フォーマット済み文字列リテラル（ 'formatted string literal' ）または
'f-string' は、接頭辞 ‘'f'’ または ‘'F'’ の付いた文字列リテラルです。こ
れらの文字列には、波括弧 ‘{}’ で区切られた式である置換フィールドを含める
ことができます。他の文字列リテラルの場合は内容が常に一定で変わることが無
いのに対して、フォーマット済み文字列リテラルは実行時に式として評価されま
す。

エスケープシーケンスは通常の文字列リテラルと同様にデコードされます (ただ
しリテラルが raw 文字列でもある場合は除きます) 。エスケープシーケンスを
デコードした後は、文字列の内容は次の文法で解釈されます:

     f_string          ::= (literal_char | "{{" | "}}" | replacement_field)*
     replacement_field ::= "{" f_expression ["="] ["!" conversion] [":" format_spec] "}"
     f_expression      ::= (conditional_expression | "*" or_expr)
                             ("," conditional_expression | "," "*" or_expr)* [","]
                           | yield_expression
     conversion        ::= "s" | "r" | "a"
     format_spec       ::= (literal_char | replacement_field)*
     literal_char      ::= <any code point except "{", "}" or NULL>

文字列のうち、波括弧で囲まれた部分以外は文字通り解釈されます。ただし、二
重波括弧 ‘'{{'’ および ‘'}}'’ は単一の波括弧に置き換えられます。単一の開
き波括弧 ‘'{'’ は置換フィールドの始まりを意味し、その中身は Python の式
で始まります。(デバッグ時に便利な機能として) 式のテキストと、評価後の値
との両者を表示したい場合には、式の後に等号 ‘'='’ を加えてください。その
後ろには、感嘆符 ‘'!'’ によって導入される変換フィールドを続けることがで
きます。さらに、‘':'’ に続いて書式指定子を追加できます。置換フィールドは
単一の閉じ波括弧 ‘'}'’ で終わります。

Expressions in formatted string literals are treated like regular Python
expressions surrounded by parentheses, with a few exceptions.  An empty
expression is not allowed, and both *note lambda: 126d. and assignment
expressions ‘:=’ must be surrounded by explicit parentheses.  Each
expression is evaluated in the context where the formatted string
literal appears, in order from left to right.  Replacement expressions
can contain newlines in both single-quoted and triple-quoted f-strings
and they can contain comments.  Everything that comes after a ‘#’ inside
a replacement field is a comment (even closing braces and quotes).  In
that case, replacement fields must be closed in a different line.

     >>> f"abc{a # This is a comment }"
     ... + 3}"
     'abc5'

バージョン 3.7 で変更: Python 3.7 より前のバージョンでは、*note await:
19e. 式および *note async for: a79. 句を含む内包表記は、実装に伴う問題の
都合により許されていませんでした。

バージョン 3.12 で変更: Prior to Python 3.12, comments were not allowed
inside f-string replacement fields.

等号 ‘'='’ が指定されたとき、出力文字列は、式のテキスト表現、等号 ‘'='’、
および評価された式を含みます。開き波括弧 ‘'{'’ の直後、式の中、および
‘'='’ の後に含まれる空白文字はすべて保存されます。書式指定子が存在しない
限り、‘'='’ を指定した場合は、式に対して *note repr(): 7c8. を適用した結
果が出力になります。一方、書式指定子が存在する場合は、変換フィールドで
‘'!r'’ が指定されていない限り、デフォルトで *note str(): 418. が適用され
ます。

Added in version 3.8: 等号 ‘'='’。

もし変換フィールドが指定されていた場合、式の評価結果はフォーマットの前に
変換されます。変換 ‘'!s'’ は *note str(): 418. を、 ‘'!r'’ は *note
repr(): 7c8. を、そして ‘'!a'’ は *note ascii(): 138e. を呼び出します。

The result is then formatted using the *note format(): 5eb. protocol.
The format specifier is passed to the *note __format__(): 5ea. method of
the expression or conversion result.  An empty string is passed when the
format specifier is omitted.  The formatted result is then included in
the final value of the whole string.

Top-level format specifiers may include nested replacement fields.
These nested fields may include their own conversion fields and *note
format specifiers: 1c9, but may not include more deeply nested
replacement fields.  The *note format specifier mini-language: 1c9. is
the same as that used by the *note str.format(): 5ed. method.

フォーマット済み文字列リテラルは他の文字列リテラルと結合できますが、置換
フィールドを複数のリテラルに分割して書くことはできません。

フォーマット済み文字列リテラルの例をいくつか挙げます:

     >>> name = "Fred"
     >>> f"He said his name is {name!r}."
     "He said his name is 'Fred'."
     >>> f"He said his name is {repr(name)}."  # repr() is equivalent to !r
     "He said his name is 'Fred'."
     >>> width = 10
     >>> precision = 4
     >>> value = decimal.Decimal("12.34567")
     >>> f"result: {value:{width}.{precision}}"  # nested fields
     'result:      12.35'
     >>> today = datetime(year=2017, month=1, day=27)
     >>> f"{today:%B %d, %Y}"  # using date format specifier
     'January 27, 2017'
     >>> f"{today=:%B %d, %Y}" # using date format specifier and debugging
     'today=January 27, 2017'
     >>> number = 1024
     >>> f"{number:#0x}"  # using integer format specifier
     '0x400'
     >>> foo = "bar"
     >>> f"{ foo = }" # preserves whitespace
     " foo = 'bar'"
     >>> line = "The mill's closed"
     >>> f"{line = }"
     'line = "The mill\'s closed"'
     >>> f"{line = :20}"
     "line = The mill's closed   "
     >>> f"{line = !r:20}"
     'line = "The mill\'s closed" '

Reusing the outer f-string quoting type inside a replacement field is
permitted:

     >>> a = dict(x=2)
     >>> f"abc {a["x"]} def"
     'abc 2 def'

バージョン 3.12 で変更: Prior to Python 3.12, reuse of the same quoting
type of the outer f-string inside a replacement field was not possible.

Backslashes are also allowed in replacement fields and are evaluated the
same way as in any other context:

     >>> a = ["a", "b", "c"]
     >>> print(f"List a contains:\n{"\n".join(a)}")
     List a contains:
     a
     b
     c

バージョン 3.12 で変更: Prior to Python 3.12, backslashes were not
permitted inside an f-string replacement field.

フォーマット済み文字列リテラルは、たとえ式を含んでいなかったとしても、
docstring としては使えません。

     >>> def foo():
     ...     f"Not a docstring"
     ...
     >>> foo.__doc__ is None
     True

フォーマット済み文字列リテラルを Python に追加した提案 PEP 498(1) も参照
してください。また関連する文字列フォーマットの仕組みを使っている *note
str.format(): 5ed. も参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0498/


File: python.info,  Node: 数値リテラル,  Next: 整数リテラル,  Prev: f-strings,  Up: リテラル

4.2.4.5 数値リテラル
....................

There are three types of numeric literals: integers, floating-point
numbers, and imaginary numbers.  There are no complex literals (complex
numbers can be formed by adding a real number and an imaginary number).

数値リテラルには符号が含まれていないことに注意してください; ‘-1’ のよう
な句は、実際には単項演算子 (unary operator) '‘-’' とリテラル ‘1’ を組み
合わせたものです。


File: python.info,  Node: 整数リテラル,  Next: Floating-point literals,  Prev: 数値リテラル,  Up: リテラル

4.2.4.6 整数リテラル
....................

整数リテラルは以下の字句定義で記述されます:

     integer      ::= decinteger | bininteger | octinteger | hexinteger
     decinteger   ::= nonzerodigit (["_"] digit)* | "0"+ (["_"] "0")*
     bininteger   ::= "0" ("b" | "B") (["_"] bindigit)+
     octinteger   ::= "0" ("o" | "O") (["_"] octdigit)+
     hexinteger   ::= "0" ("x" | "X") (["_"] hexdigit)+
     nonzerodigit ::= "1"..."9"
     digit        ::= "0"..."9"
     bindigit     ::= "0" | "1"
     octdigit     ::= "0"..."7"
     hexdigit     ::= digit | "a"..."f" | "A"..."F"

値がメモリ上に収まるかどうかという問題を除けば、整数リテラルには長さの制
限がありません。

アンダースコアはリテラルの値を判断するにあたって無視されます。そのためア
ンダースコアを使って数字をグループ化することで読みやすくできます。アンダ
ースコアは数字と数字の間に 1 つだけ、あるいは ‘0x’ のような基数指定の直
後に 1 つだけ挿入できます。

なお、非 0 の十進数の先頭には 0 を付けられません。これは、Python がバー
ジョン 3.0 以前に使っていた C 形式の八進リテラルとの曖昧さを回避するため
です。

整数リテラルの例をいくつか示します:

     7     2147483647                        0o177    0b100110111
     3     79228162514264337593543950336     0o377    0xdeadbeef
           100_000_000_000                   0b_1110_0101

バージョン 3.6 で変更: グループ化を目的としたリテラル中のアンダースコア
が許されるようになりました。


File: python.info,  Node: Floating-point literals,  Next: 虚数 imaginary リテラル,  Prev: 整数リテラル,  Up: リテラル

4.2.4.7 Floating-point literals
...............................

Floating-point literals are described by the following lexical
definitions:

     floatnumber   ::= pointfloat | exponentfloat
     pointfloat    ::= [digitpart] fraction | digitpart "."
     exponentfloat ::= (digitpart | pointfloat) exponent
     digitpart     ::= digit (["_"] digit)*
     fraction      ::= "." digitpart
     exponent      ::= ("e" | "E") ["+" | "-"] digitpart

Note that the integer and exponent parts are always interpreted using
radix 10.  For example, ‘077e010’ is legal, and denotes the same number
as ‘77e10’.  The allowed range of floating-point literals is
implementation-dependent.  As in integer literals, underscores are
supported for digit grouping.

Some examples of floating-point literals:

     3.14    10.    .001    1e100    3.14e-10    0e0    3.14_15_93

バージョン 3.6 で変更: グループ化を目的としたリテラル中のアンダースコア
が許されるようになりました。


File: python.info,  Node: 虚数 imaginary リテラル,  Prev: Floating-point literals,  Up: リテラル

4.2.4.8 虚数 (imaginary) リテラル
.................................

虚数リテラルは以下のような字句定義で記述されます:

     imagnumber ::= (floatnumber | digitpart) ("j" | "J")

An imaginary literal yields a complex number with a real part of 0.0.
Complex numbers are represented as a pair of floating-point numbers and
have the same restrictions on their range.  To create a complex number
with a nonzero real part, add a floating-point number to it, e.g.,
‘(3+4j)’.  Some examples of imaginary literals:

     3.14j   10.j    10j     .001j   1e100j   3.14e-10j   3.14_15_93j


File: python.info,  Node: 演算子,  Next: デリミタ delimiter,  Prev: リテラル,  Up: 字句解析

4.2.5 演算子
------------

以下のトークンは演算子です:

     +       -       *       **      /       //      %      @
     <<      >>      &       |       ^       ~       :=
     <       >       <=      >=      ==      !=


File: python.info,  Node: デリミタ delimiter,  Prev: 演算子,  Up: 字句解析

4.2.6 デリミタ (delimiter)
--------------------------

以下のトークンは文法上のデリミタとして働きます:

     (       )       [       ]       {       }
     ,       :       !       .       ;       @       =
     ->      +=      -=      *=      /=      //=     %=
     @=      &=      |=      ^=      >>=     <<=     **=

ピリオドは浮動小数点数や虚数リテラル中にも置けます。ピリオド三つの列はス
ライス表記における省略符号 (ellipsis) リテラルとして特別な意味を持ちます
。リスト後半の累算代入演算子 (augmented assignment operator) は、字句的
にはデリミタとして振舞いますが、演算も行います。

以下の印字可能 ASCII 文字は、他のトークンの一部として特殊な意味を持って
いたり、字句解析器にとって重要な意味を持っています:

     '       "       #       \

以下の印字可能 ASCII 文字は、Python では使われていません。これらの文字が
文字列リテラルやコメントの外にある場合、無条件にエラーとなります:

     $       ?       `

脚注
....


File: python.info,  Node: データモデル,  Next: 実行モデル,  Prev: 字句解析,  Up: Python 言語リファレンス

4.3 データモデル
================

* Menu:

* オブジェクト、値、および型::
* 標準型の階層::
* 特殊メソッド名::
* コルーチン::


File: python.info,  Node: オブジェクト、値、および型,  Next: 標準型の階層,  Up: データモデル

4.3.1 オブジェクト、値、および型
--------------------------------

Python における 'オブジェクト (object)' とは、データを抽象的に表したもの
です。Python プログラムにおけるデータは全て、オブジェクトまたはオブジェ
クト間の関係として表されます。(ある意味では、プログラムコードもまたオブ
ジェクトとして表されます。これはフォン・ノイマン: Von Neumann の "プログ
ラム記憶方式コンピュータ: stored program computer" のモデルに適合します
。)

すべてのオブジェクトは、同一性 (identity)、型、値をもっています。 '同一
性' は生成されたあとは変更されません。これはオブジェクトのアドレスのよう
なものだと考えられるかもしれません。 *note is: 2cc. 演算子は2つのオブジ
ェクトの同一性を比較します。 *note id(): 13ca. 関数は同一性を表す整数を
返します。

'CPython 実装の詳細:' CPython では、‘id(x)’ は ‘x’ が格納されているメモ
リ上のアドレスを返します。

オブジェクトの型はオブジェクトがサポートする操作 (例: *note len(): 5fa.
をサポートするか) と、オブジェクトが取りうる値を決定します。 *note
type(): d16. 関数はオブジェクトの型 (型自体もオブジェクトです) を返しま
す。同一性と同じく、オブジェクトの型('type') も変更不可能です。 (1)

オブジェクトによっては '値' を変更することが可能です。値を変更できるオブ
ジェクトのことを 'mutable' と呼びます。生成後に値を変更できないオブジェ
クトのことを 'immutable' と呼びます。(mutable なオブジェクトへの参照を格
納している immutableなコンテナオブジェクトの値は、その格納しているオブジ
ェクトの値が変化した時に変化しますが、コンテナがどのオブジェクトを格納し
ているのかが変化しないのであれば immutable だと考えることができます。し
たがって、immutable かどうかは値が変更可能かどうかと完全に一致するわけで
はありません) オブジェクトが mutable かどうかはその型によって決まります
。例えば、数値型、文字列型とタプル型のインスタンスは immutable で、dict
や list は mutable です。

オブジェクトを明示的に破壊することはできません; しかし、オブジェクトに到
達不能 (unreachable) になると、ガベージコレクション (garbage-collection)
によって処理されるかもしれません。ガベージコレクションを遅らせたり、全く
行わない実装も許されています -- 到達可能なオブジェクトを処理してしまわな
いかぎり、ガベージコレクションをどう実装するかは実装品質の問題です。

'CPython 実装の詳細:' 現在の CPython 実装では参照カウント
(reference-counting) 方式を使っており、(オプションとして) 循環参照を行っ
ているガベージオブジェクトを遅延検出します。この実装ではほとんどのオブジ
ェクトを到達不能になると同時に処理することができますが、循環参照を含むガ
ベージオブジェクトの収集が確実に行われるよう保証しているわけではありませ
ん。循環参照を持つガベージオブジェクト収集の制御については、 *note gc:
56. モジュールを参照してください。 CPython以外の実装は別の方式を使ってお
り、CPythonも将来は別の方式を使うかもしれません。オブジェクトが到達不能
になったときに即座に終了処理されることに頼らないでください (ですからファ
イルは必ず明示的に閉じてください)。

Note that the use of the implementation's tracing or debugging
facilities may keep objects alive that would normally be collectable.
Also note that catching an exception with a *note try: 6b4...*note
except: 170. statement may keep objects alive.

Some objects contain references to "external" resources such as open
files or windows.  It is understood that these resources are freed when
the object is garbage-collected, but since garbage collection is not
guaranteed to happen, such objects also provide an explicit way to
release the external resource, usually a ‘close()’ method.  Programs are
strongly recommended to explicitly close such objects.  The *note try:
6b4...*note finally: 997. statement and the *note with: 59c. statement
provide convenient ways to do this.

他のオブジェクトに対する参照をもつオブジェクトもあります; これらは 'コン
テナ (container)' と呼ばれます。コンテナオブジェクトの例として、タプル、
リスト、および辞書が挙げられます。オブジェクトへの参照自体がコンテナの値
の一部です。ほとんどの場合、コンテナの値というと、コンテナに入っているオ
ブジェクトの値のことを指し、それらオブジェクトのアイデンティティではあり
ません; しかしながら、コンテナの変更可能性について述べる場合、今まさにコ
ンテナに入っているオブジェクトのアイデンティティのことを指します。したが
って、 (タプルのように) 変更不能なオブジェクトが変更可能なオブジェクトへ
の参照を含む場合、その値が変化するのは変更可能なオブジェクトが変更された
時、ということになります。

Types affect almost all aspects of object behavior.  Even the importance
of object identity is affected in some sense: for immutable types,
operations that compute new values may actually return a reference to
any existing object with the same type and value, while for mutable
objects this is not allowed.  For example, after ‘a = 1; b = 1’, 'a' and
'b' may or may not refer to the same object with the value one,
depending on the implementation.  This is because *note int: 238. is an
immutable type, so the reference to ‘1’ can be reused.  This behaviour
depends on the implementation used, so should not be relied upon, but is
something to be aware of when making use of object identity tests.
However, after ‘c = []; d = []’, 'c' and 'd' are guaranteed to refer to
two different, unique, newly created empty lists.  (Note that ‘e = f =
[]’ assigns the 'same' object to both 'e' and 'f'.)

   ---------- Footnotes ----------

   (1) 特定の条件が満たされた場合、オブジェクトの type を変更することが
'できます' 。これは、正しく扱われなかった場合にとても奇妙な動作を引き起
こすので、一般的には良い考えではありません。


File: python.info,  Node: 標準型の階層,  Next: 特殊メソッド名,  Prev: オブジェクト、値、および型,  Up: データモデル

4.3.2 標準型の階層
------------------

以下は Python に組み込まれている型のリストです。(実装によって、C、Java、
またはその他の言語で書かれた) 拡張モジュールで、その他の型が定義されてい
ることがあります。新たな型 (有理数や、整数を効率的に記憶する配列、など)
の追加は、たいてい標準ライブラリを通して提供されますが、将来のバージョン
の Python では、型の階層構造にこのような追加がなされるかもしれません。

以下に説明する型のいくつかには、 '特殊属性 (special attribute)' を列挙し
た段落があります。これらの属性は実装へのアクセス手段を提供するもので、一
般的な用途に利用するためのものではありません。特殊属性の定義は将来変更さ
れる可能性があります。

* Menu:

* None::
* NotImplemented::
* Ellipsis::
* numbers.Number: numbers Number.
* シーケンス型 (sequence): シーケンス型 sequence.
* 集合型: 集合型<2>.
* マッピング型 (mapping): マッピング型 mapping.
* 呼び出し可能型 (callable type): 呼び出し可能型 callable type.
* モジュール: モジュール<3>.
* カスタムクラス型::
* クラスインスタンス (class instance): クラスインスタンス class instance.
* I/O オブジェクト (ファイルオブジェクトの別名): I/O オブジェクト ファイルオブジェクトの別名.
* 内部型 (internal type): 内部型 internal type.


File: python.info,  Node: None,  Next: NotImplemented,  Up: 標準型の階層

4.3.2.1 None
............

この型には単一の値しかありません。この値を持つオブジェクトはただ一つしか
存在しません。このオブジェクトは組み込み名 ‘None’ でアクセスされます。こ
のオブジェクトは、様々な状況で値が存在しないことをしめします。例えば、明
示的に値を返さない関数は ‘None’ を返します。 ‘None’ の真値 (truth value)
は偽 (false) です。


File: python.info,  Node: NotImplemented,  Next: Ellipsis,  Prev: None,  Up: 標準型の階層

4.3.2.2 NotImplemented
......................

This type has a single value.  There is a single object with this value.
This object is accessed through the built-in name *note NotImplemented:
79d.  Numeric methods and rich comparison methods should return this
value if they do not implement the operation for the operands provided.
(The interpreter will then try the reflected operation, or some other
fallback, depending on the operator.)  It should not be evaluated in a
boolean context.

詳細は *note 算術演算の実装: 1e49. を参照してください。

バージョン 3.9 で変更: Evaluating *note NotImplemented: 79d. in a
boolean context is deprecated.  While it currently evaluates as true, it
will emit a *note DeprecationWarning: 18a.  It will raise a *note
TypeError: 502. in a future version of Python.


File: python.info,  Node: Ellipsis,  Next: numbers Number,  Prev: NotImplemented,  Up: 標準型の階層

4.3.2.3 Ellipsis
................

この型には単一の値しかありません。この値を持つオブジェクトはただ一つしか
存在しません。このオブジェクトはリテラル ‘...’ またはPythonで決められて
いる名前 ‘Ellipsis’ でアクセスされます。真理値は真 (true)です。


File: python.info,  Node: numbers Number,  Next: シーケンス型 sequence,  Prev: Ellipsis,  Up: 標準型の階層

4.3.2.4 ‘numbers.Number’
........................

数値リテラルによって作成されたり、算術演算や組み込みの算術関数によって返
されるオブジェクトです。数値オブジェクトは変更不能です; 一度値が生成され
ると、二度と変更されることはありません。Python の数値オブジェクトはいう
までもなく数学で言うところの数値と強く関係していますが、コンピュータ内で
数値を表現する際に伴う制限を受けています。

*note __repr__(): 5e8. と *note __str__(): 5e9. から計算された数値クラス
の文字列表現には次のような特性があります:

   * その文字列は、クラスコンストラクタに渡したときに、元の数値の値を持
     つオブジェクトを生成する有効な数値リテラルです。

   * できるなら、10を底として表現されます。

   * 小数点の前にある 1 つのゼロを除いて、上に連なるゼロは表示されません
     。

   * 小数点の後にある 1 つのゼロを除いて、下に連なるゼロは表示されません
     。

   * 符号は数値が負数のときのみ表示されます。

Python distinguishes between integers, floating-point numbers, and
complex numbers:

* Menu:

* numbers.Integral (整数): numbers Integral 整数.
* numbers.Real (float) (実数): numbers Real float 実数.
* numbers.Complex (complex): numbers Complex complex.


File: python.info,  Node: numbers Integral 整数,  Next: numbers Real float 実数,  Up: numbers Number

4.3.2.5 ‘numbers.Integral’ (整数)
.................................

整数型は、整数(正の数および負の数)を表す数学的集合内における要素を表現す
る型です。

     注釈: 
     整数表現に関する規則は、負の整数を含むシフト演算やマスク演算におい
     て、最も有意義な解釈ができるように意図されています。

整数には 2 種類あります:

整数 (*note int: 238.)

     無制限の範囲の数を表現しますが、利用可能な (仮想) メモリサイズの制
     限のみを受けます。シフト演算やマスク演算のために2進数表現を持つと想
     定されます。負の数は符号ビットが左に無限に延びているような錯覚を与
     える 2 の補数表現の変型で表されます。

ブール値 (*note bool: 434.)

     真偽値の False と True を表します。‘False’ と ‘True’ を表す 2 つの
     オブジェクトのみがブール値オブジェクトです。ブール型は整数型の派生
     型であり、ほとんどの状況でそれぞれ 0 と 1 のように振る舞いますが、
     例外として文字列に変換されたときはそれぞれ ‘"False"’ および
     ‘"True"’ という文字列が返されます。


File: python.info,  Node: numbers Real float 実数,  Next: numbers Complex complex,  Prev: numbers Integral 整数,  Up: numbers Number

4.3.2.6 ‘numbers.Real’ (‘float’) (実数)
.......................................

These represent machine-level double precision floating-point numbers.
You are at the mercy of the underlying machine architecture (and C or
Java implementation) for the accepted range and handling of overflow.
Python does not support single-precision floating-point numbers; the
savings in processor and memory usage that are usually the reason for
using these are dwarfed by the overhead of using objects in Python, so
there is no reason to complicate the language with two kinds of
floating-point numbers.


File: python.info,  Node: numbers Complex complex,  Prev: numbers Real float 実数,  Up: numbers Number

4.3.2.7 ‘numbers.Complex’ (‘complex’)
.....................................

These represent complex numbers as a pair of machine-level double
precision floating-point numbers.  The same caveats apply as for
floating-point numbers.  The real and imaginary parts of a complex
number ‘z’ can be retrieved through the read-only attributes ‘z.real’
and ‘z.imag’.


File: python.info,  Node: シーケンス型 sequence,  Next: 集合型<2>,  Prev: numbers Number,  Up: 標準型の階層

4.3.2.8 シーケンス型 (sequence)
...............................

These represent finite ordered sets indexed by non-negative numbers.
The built-in function *note len(): 5fa. returns the number of items of a
sequence.  When the length of a sequence is 'n', the index set contains
the numbers 0, 1, ..., 'n'-1.  Item 'i' of sequence 'a' is selected by
‘a[i]’.  Some sequences, including built-in sequences, interpret
negative subscripts by adding the sequence length.  For example, ‘a[-2]’
equals ‘a[n-2]’, the second to last item of sequence a with length ‘n’.

Sequences also support slicing: ‘a[i:j]’ selects all items with index
'k' such that 'i' ‘<=’ 'k' ‘<’ 'j'.  When used as an expression, a slice
is a sequence of the same type.  The comment above about negative
indexes also applies to negative slice positions.

シーケンスによっては、第三の "ステップ (step)" パラメタを持つ "拡張スラ
イス (extended slice)" もサポートしています: ‘a[i:j:k]’ は、 ‘x = i +
n*k’, 'n' ‘>=’ ‘0’ かつ 'i' ‘<=’ 'x' ‘<’ 'j' であるようなインデクス 'x'
を持つような 'a' 全ての要素を選択します。

シーケンスは、変更可能なものか、そうでないかで区別されています:

* Menu:

* 変更不能なシーケンス (immutable sequence): 変更不能なシーケンス immutable sequence.
* 変更可能なシーケンス型 (mutable sequence): 変更可能なシーケンス型 mutable sequence.


File: python.info,  Node: 変更不能なシーケンス immutable sequence,  Next: 変更可能なシーケンス型 mutable sequence,  Up: シーケンス型 sequence

4.3.2.9 変更不能なシーケンス (immutable sequence)
.................................................

変更不能なシーケンス型のオブジェクトは、一度生成されるとその値を変更する
ことができません。 (オブジェクトに他のオブジェクトへの参照が入っている場
合、参照されているオブジェクトは変更可能なオブジェクトでもよく、その値は
変更される可能性があります; しかし、変更不能なオブジェクトが直接参照して
いるオブジェクトの集合自体は、変更することができません。)

以下の型は変更不能なシーケンス型です:

文字列型 (string)

     文字列はUnicodeコードポイントを表現する値の配列です。文字列中のどの
     コードポイントも ‘U+0000 - U+10FFFF’ の範囲で表現されることができま
     す。Pythonは char 型を持ちません。代わりに、文字列中のどのコードポ
     イントも長さ ''1'' の文字列オブジェクトとして表現することができます
     。組み込み関数 *note ord(): 1e51. は文字列形式を ‘U+0000 -
     U+10FFFF’ の範囲の整数に変換します。また、組み込み関数 *note chr():
     15d6. は ‘0 - 10FFFF’ の範囲の整数を対応する長さ ‘1’ の文字列に変換
     します。*note str.encode(): 8a3. はテキストエンコーディングを使うこ
     とで *note str: 418. を *note bytes: 1a4. に変換するために使うこと
     ができます。また、*note bytes.decode(): 8a4. によりその逆が実行する
     ことができます。

タプル型 (tuple)

     タプルの要素は任意の Python オブジェクトです。二つ以上の要素からな
     るタプルは、個々の要素を表現する式をカンマで区切って構成します。単
     一の要素からなるタプル (単集合 'singleton') を作るには、要素を表現
     する式の直後にカンマをつけます (単一の式だけではタプルを形成しませ
     ん。これは、式をグループ化するのに丸括弧を使えるようにしなければな
     らないからです)。要素の全くない丸括弧の対を作ると空のタプルになりま
     す。

bytes

     A bytes object is an immutable array.  The items are 8-bit bytes,
     represented by integers in the range 0 <= x < 256.  Bytes literals
     (like ‘b'abc'’) and the built-in *note bytes(): 1a4. constructor
     can be used to create bytes objects.  Also, bytes objects can be
     decoded to strings via the *note decode(): 8a4. method.


File: python.info,  Node: 変更可能なシーケンス型 mutable sequence,  Prev: 変更不能なシーケンス immutable sequence,  Up: シーケンス型 sequence

4.3.2.10 変更可能なシーケンス型 (mutable sequence)
..................................................

変更可能なシーケンスは、作成した後で変更することができます。変更可能なシ
ーケンスでは、添字表記やスライス表記を使って指定された要素に代入を行うこ
とができ、 *note del: 1711. (delete) 文を使って要素を削除することができ
ます。

     注釈: 
     The *note collections: 16. and *note array: 6. module provide
     additional examples of mutable sequence types.

Python に最初から組み込まれている変更可能なシーケンス型は、今のところ二
つです:

リスト型 (list)

     リストの要素は任意の Python オブジェクトにできます。リストは、角括
     弧の中にカンマで区切られた式を並べて作ります。 (長さが 0 や 1 のシ
     ーケンスを作るために特殊な場合分けは必要ないことに注意してください
     。)

バイト配列

     bytearray オブジェクトは変更可能な配列です。組み込みの *note
     bytearray(): 508. コンストラクタによって作成されます。変更可能なこ
     とを除けば (つまりハッシュ化できない)、 byte array は変更不能な
     *note bytes: 1a4. オブジェクトと同じインターフェースと機能を提供し
     ます。


File: python.info,  Node: 集合型<2>,  Next: マッピング型 mapping,  Prev: シーケンス型 sequence,  Up: 標準型の階層

4.3.2.11 集合型
...............

集合型は、順序のない、ユニークで不変なオブジェクトの有限集合を表現します
。そのため、(配列の)添字を使ったインデックスアクセスはできません。ただし
、イテレートは可能で、組み込み関数 *note len(): 5fa. は集合の要素数を返
します。集合型の一般的な使い方は、集合に属しているかの高速なテスト、シー
ケンスからの重複の排除、共通集合・和集合・差・対称差といった数学的な演算
の計算です。

集合の要素には、辞書のキーと同じ普遍性に関するルールが適用されます。数値
型は通常の数値比較のルールに従うことに注意してください。もし2つの数値の
比較結果が同値である(例えば、 ‘1’ と ‘1.0’)なら、そのうちの1つのみを集合
に含めることができます。

現在、2つの組み込み集合型があります:

集合型

     可変な集合型です。組み込みの *note set(): 5a3. コンストラクタで作成
     され、後から ‘add()’ などのいくつかのメソッドで更新できます。

Frozen set 型

     不変な集合型です。組み込みの *note frozenset(): 5a4. コンストラクタ
     によって作成されます。 frozenset は不変で *note ハッシュ可能: 5db.
     なので、別の集合型の要素になったり、辞書のキーにすることができます
     。


File: python.info,  Node: マッピング型 mapping,  Next: 呼び出し可能型 callable type,  Prev: 集合型<2>,  Up: 標準型の階層

4.3.2.12 マッピング型 (mapping)
...............................

任意のインデクス集合でインデクス化された、オブジェクトからなる有限の集合
を表現します。添字表記 ‘a[k]’ は、 ‘k’ でインデクス指定された要素を ‘a’
から選択します; 選択された要素は式の中で使うことができ、代入や *note
del: 1711. 文の対象にすることができます。組み込み関数 *note len(): 5fa.
は、マッピング内の要素数を返します。

Python に最初から組み込まれているマッピング型は、今のところ一つだけです:

* Menu:

* 辞書型 (dictionary): 辞書型 dictionary<2>.


File: python.info,  Node: 辞書型 dictionary<2>,  Up: マッピング型 mapping

4.3.2.13 辞書型 (dictionary)
............................

ほぼ任意の値でインデクスされたオブジェクトからなる有限の集合を表します。
キー (key) として使えない値の唯一の型は、リストや辞書、そしてオブジェク
トの同一性でなく値で比較されるその他の変更可能な型です。 これは、辞書型
を効率的に実装する上で、キーのハッシュ値が不変である必要があるためです。
数値型をキーに使う場合、キー値は通常の数値比較における規則に従います: 二
つの値が等しくなる場合 (例えば ‘1’ と ‘1.0’)、互いに同じ辞書のエントリを
表すインデクスとして使うことができます。

辞書は挿入の順序を保持します。つまり、キーは辞書に追加された順番に生成さ
れていきます。既存のキーを置き換えても、キーの順序は変わりません。キーを
削除したのちに再挿入すると、元の場所ではなく辞書の最後に追加されます。

Dictionaries are mutable; they can be created by the ‘{}’ notation (see
section *note 辞書表示: d4c.).

拡張モジュール *note dbm.ndbm: 2c. 、 *note dbm.gnu: 2b. は、 *note
collections: 16. モジュールのように、別のマッピング型の例を提供していま
す。

バージョン 3.7 で変更: Pythonのバージョン3.6では、辞書は挿入順序を保持し
ませんでした。CPython 3.6では挿入順序は保持されましたが、それは策定され
た言語の仕様というより、その当時の実装の細部とみなされていました。


File: python.info,  Node: 呼び出し可能型 callable type,  Next: モジュール<3>,  Prev: マッピング型 mapping,  Up: 標準型の階層

4.3.2.14 呼び出し可能型 (callable type)
.......................................

関数呼び出し操作 (*note 呼び出し (call): d4a. 参照) を行うことができる型
です:

* Menu:

* ユーザ定義関数 (user-defined function): ユーザ定義関数 user-defined function.
* インスタンスメソッド::
* ジェネレータ関数 (generator function): ジェネレータ関数 generator function.
* コルーチン関数 (coroutine function): コルーチン関数 coroutine function.
* 非同期ジェネレータ関数 (asynchronous generator function): 非同期ジェネレータ関数 asynchronous generator function.
* 組み込み関数 (built-in function): 組み込み関数 built-in function.
* 組み込みメソッド (built-in method): 組み込みメソッド built-in method.
* クラス: クラス<2>.
* クラスのインスタンス::


File: python.info,  Node: ユーザ定義関数 user-defined function,  Next: インスタンスメソッド,  Up: 呼び出し可能型 callable type

4.3.2.15 ユーザ定義関数 (user-defined function)
...............................................

ユーザ定義関数オブジェクトは、関数定義を行うことで生成されます (*note
関数定義: 1ba0. 参照)。関数は、仮引数 (formal parameter) リストと同じ数
の要素が入った引数リストとともに呼び出されます。

* Menu:

* Special read-only attributes::
* Special writable attributes::


File: python.info,  Node: Special read-only attributes,  Next: Special writable attributes,  Up: ユーザ定義関数 user-defined function

4.3.2.16 Special read-only attributes
.....................................

属性                                                   意味
                                                       
--------------------------------------------------------------------------------------------------------------
                                                       
 -- の属性: function.__globals__                       A reference to the *note dictionary: 237. that holds
                                                       the function's *note global variables: 1e59. - the
                                                       global namespace of the module in which the function
                                                       was defined.
                                                       
                                                       
 -- の属性: function.__closure__                       ‘None’ or a *note tuple: 349. of cells that contain
                                                       bindings for the names specified in the
                                                       *note co_freevars: 1e5a. attribute of the function's
                                                       *note code object: 27a.
                                                       
                                                       セルオブジェクトは属性 ‘cell_contents’ を持っていま
                                                       す。 これはセルの値を設定するのに加えて、セルの値を
                                                       得るのにも使えます。
                                                       


File: python.info,  Node: Special writable attributes,  Prev: Special read-only attributes,  Up: ユーザ定義関数 user-defined function

4.3.2.17 Special writable attributes
....................................

Most of these attributes check the type of the assigned value:

属性                                                   意味
                                                       
--------------------------------------------------------------------------------------------------------------
                                                       
 -- の属性: function.__doc__                           関数のドキュメンテーション文字列です。ドキュメンテー
                                                       ションがない場合は ‘None’ になります。
                                                       
                                                       
 -- の属性: function.__name__                          The function's name.  See also:
                                                       *note __name__ attributes: 103b.
                                                       
                                                       
 -- の属性: function.__qualname__                      The function's *note qualified name: 18ab.  See
                                                       also: *note __qualname__ attributes: 103a.
                                                       
                                                       Added in version 3.3.
                                                       
                                                       
 -- の属性: function.__module__                        関数が定義されているモジュールの名前です。モジュール
                                                       名がない場合は ‘None’ になります。
                                                       
                                                       
 -- の属性: function.__defaults__                      A *note tuple: 349. containing default
                                                       *note parameter: 1e5e. values for those parameters
                                                       that have defaults, or ‘None’ if no parameters have
                                                       a default value.
                                                       
                                                       
 -- の属性: function.__code__                          The *note code object: 1b4. representing the
                                                       compiled function body.
                                                       
                                                       
 -- の属性: function.__dict__                          The namespace supporting arbitrary function
                                                       attributes.  See also:
                                                       *note __dict__ attributes: 526.
                                                       
                                                       
 -- の属性: function.__annotations__                   A *note dictionary: 237. containing annotations of
                                                       *note parameters: 1e5e.  The keys of the dictionary
                                                       are the parameter names, and ‘'return'’ for the
                                                       return annotation, if provided.  See also:
                                                       *note Annotations Best Practices: 7a4.
                                                       
                                                       
 -- の属性: function.__kwdefaults__                    A *note dictionary: 237. containing defaults for
                                                       keyword-only *note parameters: 1e5e.
                                                       
                                                       
 -- の属性: function.__type_params__                   A *note tuple: 349. containing the
                                                       *note type parameters: 293. of a
                                                       *note generic function: 41f.
                                                       
                                                       Added in version 3.12.
                                                       

Function objects also support getting and setting arbitrary attributes,
which can be used, for example, to attach metadata to functions.
Regular attribute dot-notation is used to get and set such attributes.

'CPython 実装の詳細:' CPython's current implementation only supports
function attributes on user-defined functions.  Function attributes on
*note built-in functions: 1e60. may be supported in the future.

Additional information about a function's definition can be retrieved
from its *note code object: 1b4. (accessible via the *note __code__:
27a. attribute).


File: python.info,  Node: インスタンスメソッド,  Next: ジェネレータ関数 generator function,  Prev: ユーザ定義関数 user-defined function,  Up: 呼び出し可能型 callable type

4.3.2.18 インスタンスメソッド
.............................

インスタンスメソッドオブジェクトは、クラス、クラスインスタンスと任意の呼
び出し可能オブジェクト (通常はユーザ定義関数) を結びつけます。

Special read-only attributes:

 -- の属性: method.__self__                            Refers to the class instance object to which the
                                                       method is *note bound: 1e62.
                                                       
                                                       
 -- の属性: method.__func__                            Refers to the original *note function object: 279.
                                                       
                                                       
 -- の属性: method.__doc__                             The method's documentation (same as
                                                       *note method.__func__.__doc__: 11a9.).  A
                                                       *note string: 418. if the original function had a
                                                       docstring, else ‘None’.
                                                       
                                                       
 -- の属性: method.__name__                            The name of the method (same as
                                                       *note method.__func__.__name__: 12a2.)
                                                       
                                                       
 -- の属性: method.__module__                          The name of the module the method was defined in, or
                                                       ‘None’ if unavailable.
                                                       

Methods also support accessing (but not setting) the arbitrary function
attributes on the underlying *note function object: 279.

User-defined method objects may be created when getting an attribute of
a class (perhaps via an instance of that class), if that attribute is a
user-defined *note function object: 279. or a *note classmethod: 14c.
object.  When an instance method object is created by retrieving a
user-defined *note function object: 279. from a class via one of its
instances, its *note __self__: 1370. attribute is the instance, and the
method object is said to be 'bound'.  The new method's *note __func__:
12ca. attribute is the original function object.

When an instance method object is created by retrieving a *note
classmethod: 14c. object from a class or instance, its *note __self__:
1370. attribute is the class itself, and its *note __func__: 12ca.
attribute is the function object underlying the class method.

When an instance method object is called, the underlying function (*note
__func__: 12ca.) is called, inserting the class instance (*note
__self__: 1370.) in front of the argument list.  For instance, when ‘C’
is a class which contains a definition for a function ‘f()’, and ‘x’ is
an instance of ‘C’, calling ‘x.f(1)’ is equivalent to calling ‘C.f(x,
1)’.

When an instance method object is derived from a *note classmethod: 14c.
object, the "class instance" stored in *note __self__: 1370. will
actually be the class itself, so that calling either ‘x.f(1)’ or
‘C.f(1)’ is equivalent to calling ‘f(C,1)’ where ‘f’ is the underlying
function.

It is important to note that user-defined functions which are attributes
of a class instance are not converted to bound methods; this 'only'
happens when the function is an attribute of the class.


File: python.info,  Node: ジェネレータ関数 generator function,  Next: コルーチン関数 coroutine function,  Prev: インスタンスメソッド,  Up: 呼び出し可能型 callable type

4.3.2.19 ジェネレータ関数 (generator function)
..............................................

*note yield: 99b. 文 (*note yield 文: 99b. の節を参照) を使う関数もしく
はメソッドは 'ジェネレータ関数' と呼ばれます。 そのような関数が呼び出さ
れたときは常に、関数の本体を実行するのに使える *note イテレータ: 191. オ
ブジェクトを返します: イテレータの *note iterator.__next__(): 129b. メソ
ッドを呼び出すと、 ‘yield’ 文を使って値が提供されるまで関数を実行します
。 関数の *note return: 99c. 文を実行するか終端に達したときは、 *note
StopIteration: bc8. 例外が送出され、イテレータが返すべき値の最後まで到達
しています。


File: python.info,  Node: コルーチン関数 coroutine function,  Next: 非同期ジェネレータ関数 asynchronous generator function,  Prev: ジェネレータ関数 generator function,  Up: 呼び出し可能型 callable type

4.3.2.20 コルーチン関数 (coroutine function)
............................................

*note async def: 59b. を使用して定義された関数やメソッドを 'コルーチン関
数 (coroutine function)' と呼びます。 呼び出された時、そのような関数は
*note coroutine: 45e. オブジェクトを返します。 コルーチン関数は *note
async with: 59f. や *note async for: a79. 文だけでなく *note await: 19e.
式を持つことが出来ます。 *note コルーチンオブジェクト: 1e68. を参照して
ください。


File: python.info,  Node: 非同期ジェネレータ関数 asynchronous generator function,  Next: 組み込み関数 built-in function,  Prev: コルーチン関数 coroutine function,  Up: 呼び出し可能型 callable type

4.3.2.21 非同期ジェネレータ関数 (asynchronous generator function)
.................................................................

*note async def: 59b. を使って定義され、 *note yield: 99b. 文を使用して
いる関数やメソッドを 'asynchronous generator function' と呼びます。 その
ような関数は、呼び出されたとき、*note 非同期イテレータ: 190. オブジェク
トを返します。 このオブジェクトは *note async for: a79. 文で関数の本体を
実行するのに使えます。

非同期イテレータの *note aiterator.__anext__: 1e6a. メソッドを呼び出すと
、他の処理が待たされているときに、 *note yield: 99b. 式を使い値を提供す
るところまで処理を進める *note awaitable: 192. を返します。 その関数が空
の *note return: 99c. 文を実行する、もしくは処理の終わりに到達したときは
、 *note StopAsyncIteration: 1998. 例外が送出され、非同期イテレータは出
力すべき値の最後に到達したことになります。


File: python.info,  Node: 組み込み関数 built-in function,  Next: 組み込みメソッド built-in method,  Prev: 非同期ジェネレータ関数 asynchronous generator function,  Up: 呼び出し可能型 callable type

4.3.2.22 組み込み関数 (built-in function)
.........................................

A built-in function object is a wrapper around a C function.  Examples
of built-in functions are *note len(): 5fa. and *note math.sin(): 1463.
(*note math: 81. is a standard built-in module).  The number and type of
the arguments are determined by the C function.  Special read-only
attributes:

   * ‘__doc__’ is the function's documentation string, or ‘None’ if
     unavailable.  See *note function.__doc__: 11a9.

   * ‘__name__’ is the function's name.  See *note function.__name__:
     12a2.

   * ‘__self__’ is set to ‘None’ (but see the next item).

   * ‘__module__’ is the name of the module the function was defined in
     or ‘None’ if unavailable.  See *note function.__module__: 1e5d.


File: python.info,  Node: 組み込みメソッド built-in method,  Next: クラス<2>,  Prev: 組み込み関数 built-in function,  Up: 呼び出し可能型 callable type

4.3.2.23 組み込みメソッド (built-in method)
...........................................

This is really a different disguise of a built-in function, this time
containing an object passed to the C function as an implicit extra
argument.  An example of a built-in method is ‘alist.append()’, assuming
'alist' is a list object.  In this case, the special read-only attribute
‘__self__’ is set to the object denoted by 'alist'.  (The attribute has
the same semantics as it does with *note other instance methods: 1370.)


File: python.info,  Node: クラス<2>,  Next: クラスのインスタンス,  Prev: 組み込みメソッド built-in method,  Up: 呼び出し可能型 callable type

4.3.2.24 クラス
...............

Classes are callable.  These objects normally act as factories for new
instances of themselves, but variations are possible for class types
that override *note __new__(): 54c.  The arguments of the call are
passed to ‘__new__()’ and, in the typical case, to *note __init__():
67c. to initialize the new instance.


File: python.info,  Node: クラスのインスタンス,  Prev: クラス<2>,  Up: 呼び出し可能型 callable type

4.3.2.25 クラスのインスタンス
.............................

任意のクラスのインスタンスは、クラスで *note __call__(): 523. メソッドを
定義することで呼び出し可能になります。


File: python.info,  Node: モジュール<3>,  Next: カスタムクラス型,  Prev: 呼び出し可能型 callable type,  Up: 標準型の階層

4.3.2.26 モジュール
...................

Modules are a basic organizational unit of Python code, and are created
by the *note import system: 1e73. as invoked either by the *note import:
5ac. statement, or by calling functions such as *note
importlib.import_module(): 4e1. and built-in *note __import__(): 8a2.  A
module object has a namespace implemented by a *note dictionary: 237.
object (this is the dictionary referenced by the *note __globals__:
12a1. attribute of functions defined in the module).  Attribute
references are translated to lookups in this dictionary, e.g., ‘m.x’ is
equivalent to ‘m.__dict__["x"]’.  A module object does not contain the
code object used to initialize the module (since it isn't needed once
the initialization is done).

属性の代入を行うと、モジュールの名前空間辞書の内容を更新します。例えば、
‘m.x = 1’ は ‘m.__dict__["x"] = 1’ と同じです。

* Menu:

* Import-related attributes on module objects::
* Other writable attributes on module objects::
* Module dictionaries::


File: python.info,  Node: Import-related attributes on module objects,  Next: Other writable attributes on module objects,  Up: モジュール<3>

4.3.2.27 Import-related attributes on module objects
....................................................

Module objects have the following attributes that relate to the *note
import system: 1e73.  When a module is created using the machinery
associated with the import system, these attributes are filled in based
on the module's *note spec: 1e76, before the *note loader: 1614.
executes and loads the module.

To create a module dynamically rather than using the import system, it's
recommended to use *note importlib.util.module_from_spec(): ddf, which
will set the various import-controlled attributes to appropriate values.
It's also possible to use the *note types.ModuleType: de0. constructor
to create modules directly, but this technique is more error-prone, as
most attributes must be manually set on the module object after it has
been created when using this approach.

     注意: With the exception of *note __name__: 1350, it is 'strongly'
     recommended that you rely on *note __spec__: 1e77. and its
     attributes instead of any of the other individual attributes listed
     in this subsection.  Note that updating an attribute on ‘__spec__’
     will not update the corresponding attribute on the module itself:

          >>> import typing
          >>> typing.__name__, typing.__spec__.name
          ('typing', 'typing')
          >>> typing.__spec__.name = 'spelling'
          >>> typing.__name__, typing.__spec__.name
          ('typing', 'spelling')
          >>> typing.__name__ = 'keyboard_smashing'
          >>> typing.__name__, typing.__spec__.name
          ('keyboard_smashing', 'spelling')

 -- の属性: module.__name__

     The name used to uniquely identify the module in the import system.
     For a directly executed module, this will be set to ‘"__main__"’.

     This attribute must be set to the fully qualified name of the
     module.  It is expected to match the value of *note
     module.__spec__.name: 1e78.

 -- の属性: module.__spec__

     A record of the module's import-system-related state.

     Set to the *note module spec: 1dcb. that was used when importing
     the module.  See *note Module specs: 1e79. for more details.

     Added in version 3.4.

 -- の属性: module.__package__

     The *note package: 1e7a. a module belongs to.

     If the module is top-level (that is, not a part of any specific
     package) then the attribute should be set to ‘''’ (the empty
     string).  Otherwise, it should be set to the name of the module's
     package (which can be equal to *note module.__name__: 1350. if the
     module itself is a package).  See PEP 366(1) for further details.

     This attribute is used instead of *note __name__: 1350. to
     calculate explicit relative imports for main modules.  It defaults
     to ‘None’ for modules created dynamically using the *note
     types.ModuleType: de0. constructor; use *note
     importlib.util.module_from_spec(): ddf. instead to ensure the
     attribute is set to a *note str: 418.

     It is 'strongly' recommended that you use *note
     module.__spec__.parent: 2ba. instead of ‘module.__package__’.
     *note __package__: 2b9. is now only used as a fallback if
     ‘__spec__.parent’ is not set, and this fallback path is deprecated.

     バージョン 3.4 で変更: This attribute now defaults to ‘None’ for
     modules created dynamically using the *note types.ModuleType: de0.
     constructor.  Previously the attribute was optional.

     バージョン 3.6 で変更: The value of ‘__package__’ is expected to be
     the same as *note __spec__.parent: 2ba.  *note __package__: 2b9. is
     now only used as a fallback during import resolution if
     ‘__spec__.parent’ is not defined.

     バージョン 3.10 で変更: *note ImportWarning: 4c7. is raised if an
     import resolution falls back to ‘__package__’ instead of *note
     __spec__.parent: 2ba.

     バージョン 3.12 で変更: Raise *note DeprecationWarning: 18a.
     instead of *note ImportWarning: 4c7. when falling back to
     ‘__package__’ during import resolution.

     Deprecated since version 3.13, will be removed in version 3.15:
     ‘__package__’ will cease to be set or taken into consideration by
     the import system or standard library.

 -- の属性: module.__loader__

     The *note loader: 1614. object that the import machinery used to
     load the module.

     This attribute is mostly useful for introspection, but can be used
     for additional loader-specific functionality, for example getting
     data associated with a loader.

     ‘__loader__’ defaults to ‘None’ for modules created dynamically
     using the *note types.ModuleType: de0. constructor; use *note
     importlib.util.module_from_spec(): ddf. instead to ensure the
     attribute is set to a *note loader: 1614. object.

     It is 'strongly' recommended that you use *note
     module.__spec__.loader: 2c4. instead of ‘module.__loader__’.

     バージョン 3.4 で変更: This attribute now defaults to ‘None’ for
     modules created dynamically using the *note types.ModuleType: de0.
     constructor.  Previously the attribute was optional.

     Deprecated since version 3.12, will be removed in version 3.16:
     Setting ‘__loader__’ on a module while failing to set
     ‘__spec__.loader’ is deprecated.  In Python 3.16, ‘__loader__’ will
     cease to be set or taken into consideration by the import system or
     the standard library.

 -- の属性: module.__path__

     A (possibly empty) *note sequence: 4be. of strings enumerating the
     locations where the package's submodules will be found.
     Non-package modules should not have a ‘__path__’ attribute.  See
     *note __path__ attributes on modules: 1e7b. for more details.

     It is 'strongly' recommended that you use *note
     module.__spec__.submodule_search_locations: 1e7c. instead of
     ‘module.__path__’.

 -- の属性: module.__file__

 -- の属性: module.__cached__

     ‘__file__’ and ‘__cached__’ are both optional attributes that may
     or may not be set.  Both attributes should be a *note str: 418.
     when they are available.

     ‘__file__’ indicates the pathname of the file from which the module
     was loaded (if loaded from a file), or the pathname of the shared
     library file for extension modules loaded dynamically from a shared
     library.  It might be missing for certain types of modules, such as
     C modules that are statically linked into the interpreter, and the
     *note import system: 1e73. may opt to leave it unset if it has no
     semantic meaning (for example, a module loaded from a database).

     If ‘__file__’ is set then the ‘__cached__’ attribute might also be
     set, which is the path to any compiled version of the code (for
     example, a byte-compiled file).  The file does not need to exist to
     set this attribute; the path can simply point to where the compiled
     file 'would' exist (see PEP 3147(2)).

     Note that ‘__cached__’ may be set even if ‘__file__’ is not set.
     However, that scenario is quite atypical.  Ultimately, the *note
     loader: 1614. is what makes use of the module spec provided by the
     *note finder: 1e7e. (from which ‘__file__’ and ‘__cached__’ are
     derived).  So if a loader can load from a cached module but
     otherwise does not load from a file, that atypical scenario may be
     appropriate.

     It is 'strongly' recommended that you use *note
     module.__spec__.cached: 2b8. instead of ‘module.__cached__’.

     Deprecated since version 3.13, will be removed in version 3.15:
     Setting ‘__cached__’ on a module while failing to set
     ‘__spec__.cached’ is deprecated.  In Python 3.15, ‘__cached__’ will
     cease to be set or taken into consideration by the import system or
     standard library.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0366/

   (2) https://peps.python.org/pep-3147/


File: python.info,  Node: Other writable attributes on module objects,  Next: Module dictionaries,  Prev: Import-related attributes on module objects,  Up: モジュール<3>

4.3.2.28 Other writable attributes on module objects
....................................................

As well as the import-related attributes listed above, module objects
also have the following writable attributes:

 -- の属性: module.__doc__

     The module's documentation string, or ‘None’ if unavailable.  See
     also: *note __doc__ attributes: 8f6.

 -- の属性: module.__annotations__

     モジュールの本体の実行中に収集した *note 変数アノテーション: d23. を
     格納する辞書です。 *note __annotations__: 1e80. を利用するベストプ
     ラクティスについては、 *note アノテーションのHOWTO: 7a4. を参照して
     ください。


File: python.info,  Node: Module dictionaries,  Prev: Other writable attributes on module objects,  Up: モジュール<3>

4.3.2.29 Module dictionaries
............................

Module objects also have the following special read-only attribute:

 -- の属性: module.__dict__

     The module's namespace as a dictionary object.  Uniquely among the
     attributes listed here, ‘__dict__’ cannot be accessed as a global
     variable from within a module; it can only be accessed as an
     attribute on module objects.

     'CPython 実装の詳細:' CPython がモジュール辞書を削除する方法により
     、モジュール辞書が生きた参照を持っていたとしてもその辞書はモジュー
     ルがスコープから外れた時に削除されます。これを避けるには、辞書をコ
     ピーするか、辞書を直接使っている間モジュールを保持してください。


File: python.info,  Node: カスタムクラス型,  Next: クラスインスタンス class instance,  Prev: モジュール<3>,  Up: 標準型の階層

4.3.2.30 カスタムクラス型
.........................

Custom class types are typically created by class definitions (see
section *note クラス定義: 12a5.).  A class has a namespace implemented
by a dictionary object.  Class attribute references are translated to
lookups in this dictionary, e.g., ‘C.x’ is translated to
‘C.__dict__["x"]’ (although there are a number of hooks which allow for
other means of locating attributes).  When the attribute name is not
found there, the attribute search continues in the base classes.  This
search of the base classes uses the C3 method resolution order which
behaves correctly even in the presence of 'diamond' inheritance
structures where there are multiple inheritance paths leading back to a
common ancestor.  Additional details on the C3 MRO used by Python can be
found at *note The Python 2.3 Method Resolution Order: 144f.

When a class attribute reference (for class ‘C’, say) would yield a
class method object, it is transformed into an instance method object
whose *note __self__: 1370. attribute is ‘C’.  When it would yield a
*note staticmethod: 3ef. object, it is transformed into the object
wrapped by the static method object.  See section *note デスクリプタ
(descriptor) の実装: c1d. for another way in which attributes retrieved
from a class may differ from those actually contained in its *note
__dict__: 526.

クラス属性を代入すると、そのクラスの辞書だけが更新され、基底クラスの辞書
は更新しません。

クラスオブジェクトを呼び出す (上記を参照) と、クラスインスタンスを生成し
ます (下記を参照)。

* Menu:

* Special attributes::
* Special methods::


File: python.info,  Node: Special attributes,  Next: Special methods,  Up: カスタムクラス型

4.3.2.31 Special attributes
...........................

属性                                                   意味
                                                       
--------------------------------------------------------------------------------------------------------------
                                                       
 -- の属性: type.__name__                              The class's name.  See also:
                                                       *note __name__ attributes: 103b.
                                                       
                                                       
 -- の属性: type.__qualname__                          The class's *note qualified name: 18ab.  See also:
                                                       *note __qualname__ attributes: 103a.
                                                       
                                                       
 -- の属性: type.__module__                            クラスが定義されているモジュールの名前。
                                                       
                                                       
 -- の属性: type.__dict__                              A *note mapping proxy: 43a. providing a read-only
                                                       view of the class's namespace.  See also:
                                                       *note __dict__ attributes: 526.
                                                       
                                                       
 -- の属性: type.__bases__                             A *note tuple: 349. containing the class's bases.
                                                       In most cases, for a class defined as ‘class X(A, B,
                                                       C)’, ‘X.__bases__’ will be exactly equal to ‘(A, B,
                                                       C)’.
                                                       
                                                       
 -- の属性: type.__doc__                               The class's documentation string, or ‘None’ if
                                                       undefined.  Not inherited by subclasses.
                                                       
                                                       
 -- の属性: type.__annotations__                       A dictionary containing
                                                       *note variable annotations: d23. collected during
                                                       class body execution.  For best practices on working
                                                       with ‘__annotations__’, please see
                                                       *note Annotations Best Practices: 7a4.
                                                       
                                                            注意: Accessing the ‘__annotations__’ attribute
                                                            of a class object directly may yield incorrect
                                                            results in the presence of metaclasses.  In
                                                            addition, the attribute may not exist for some
                                                            classes.  Use
                                                            *note inspect.get_annotations(): 7de. to
                                                            retrieve class annotations safely.
                                                       
                                                       
 -- の属性: type.__type_params__                       A *note tuple: 349. containing the
                                                       *note type parameters: 293. of a
                                                       *note generic class: 41e.
                                                       
                                                       Added in version 3.12.
                                                       
                                                       
 -- の属性: type.__static_attributes__                 A *note tuple: 349. containing names of attributes
                                                       of this class which are assigned through ‘self.X’
                                                       from any function in its body.
                                                       
                                                       Added in version 3.13.
                                                       
                                                       
 -- の属性: type.__firstlineno__                       The line number of the first line of the class
                                                       definition, including decorators.  Setting the
                                                       ‘__module__’ attribute removes the ‘__firstlineno__’
                                                       item from the type's dictionary.
                                                       
                                                       Added in version 3.13.
                                                       
                                                       
 -- の属性: type.__mro__                               The *note tuple: 349. of classes that are considered
                                                       when looking for base classes during method
                                                       resolution.
                                                       


File: python.info,  Node: Special methods,  Prev: Special attributes,  Up: カスタムクラス型

4.3.2.32 Special methods
........................

In addition to the special attributes described above, all Python
classes also have the following two methods available:

 -- メソッド: type.mro ()

     This method can be overridden by a metaclass to customize the
     method resolution order for its instances.  It is called at class
     instantiation, and its result is stored in *note __mro__: 1e89.

 -- メソッド: type.__subclasses__ ()

     Each class keeps a list of weak references to its immediate
     subclasses.  This method returns a list of all those references
     still alive.  The list is in definition order.  Example:

          >>> class A: pass
          >>> class B(A): pass
          >>> A.__subclasses__()
          [<class 'B'>]


File: python.info,  Node: クラスインスタンス class instance,  Next: I/O オブジェクト ファイルオブジェクトの別名,  Prev: カスタムクラス型,  Up: 標準型の階層

4.3.2.33 クラスインスタンス (class instance)
............................................

A class instance is created by calling a class object (see above).  A
class instance has a namespace implemented as a dictionary which is the
first place in which attribute references are searched.  When an
attribute is not found there, and the instance's class has an attribute
by that name, the search continues with the class attributes.  If a
class attribute is found that is a user-defined function object, it is
transformed into an instance method object whose *note __self__: 1370.
attribute is the instance.  Static method and class method objects are
also transformed; see above under "Classes".  See section *note
デスクリプタ (descriptor) の実装: c1d. for another way in which
attributes of a class retrieved via its instances may differ from the
objects actually stored in the class's *note __dict__: 526.  If no class
attribute is found, and the object's class has a *note __getattr__():
49f. method, that is called to satisfy the lookup.

属性の代入や削除を行うと、インスタンスの辞書を更新しますが、クラスの辞書
を更新することはありません。クラスで *note __setattr__(): 1e8d. や *note
__delattr__(): 1e8e. メソッドが定義されている場合、直接インスタンスの辞
書を更新する代わりにこれらのメソッドが呼び出されます。

クラスインスタンスは、ある特定の名前のメソッドを持っている場合、数値型や
シーケンス型、あるいはマップ型のように振舞うことができます。 *note
特殊メソッド名: c3c. を参照してください。

* Menu:

* Special attributes: Special attributes<2>.


File: python.info,  Node: Special attributes<2>,  Up: クラスインスタンス class instance

4.3.2.34 Special attributes
...........................

 -- の属性: object.__class__

     クラスインスタンスが属しているクラスです。

 -- の属性: object.__dict__

     A dictionary or other mapping object used to store an object's
     (writable) attributes.  Not all instances have a ‘__dict__’
     attribute; see the section on *note __slots__: 1e90. for more
     details.


File: python.info,  Node: I/O オブジェクト ファイルオブジェクトの別名,  Next: 内部型 internal type,  Prev: クラスインスタンス class instance,  Up: 標準型の階層

4.3.2.35 I/O オブジェクト (ファイルオブジェクトの別名)
......................................................

*note file object: 1193. は開かれたファイルを表します。ファイルオブジェ
クトを作るための様々なショートカットがあります: *note open(): 4e5. 組み
込み関数、 *note os.popen(): a55. 、 *note os.fdopen(): 1e92. 、ソケット
オブジェクトの *note makefile(): 1170. メソッド (あるいは拡張モジュール
から提供される他の関数やメソッド) 。

オブジェクト ‘sys.stdin’ 、 ‘sys.stdout’ および ‘sys.stderr’ は、インタ
プリタの標準入力、標準出力、および標準エラー出力ストリームに対応するファ
イルオブジェクトに初期化されます。これらはすべてテキストモードで開かれ、
*note io.TextIOBase: 661. 抽象クラスによって定義されたインターフェースに
従います。


File: python.info,  Node: 内部型 internal type,  Prev: I/O オブジェクト ファイルオブジェクトの別名,  Up: 標準型の階層

4.3.2.36 内部型 (internal type)
...............................

インタプリタが内部的に使っているいくつかの型は、ユーザに公開されています
。これらの定義は将来のインタプリタのバージョンでは変更される可能性があり
ますが、ここでは記述の完全性のために触れておきます。

* Menu:

* コードオブジェクト::
* フレーム (frame) オブジェクト: フレーム frame オブジェクト.
* トレースバック (traceback) オブジェクト: トレースバック traceback オブジェクト.
* スライス (slice) オブジェクト: スライス slice オブジェクト.
* 静的メソッド (static method) オブジェクト: 静的メソッド static method オブジェクト.
* クラスメソッドオブジェクト::


File: python.info,  Node: コードオブジェクト,  Next: フレーム frame オブジェクト,  Up: 内部型 internal type

4.3.2.37 コードオブジェクト
...........................

コードオブジェクトは 'バイトコンパイルされた (byte-compiled)' 実行可能な
Python コード、別名 *note バイトコード: 16c. を表現します。コードオブジ
ェクトと関数オブジェクトの違いは、関数オブジェクトが関数のグローバル変数
(関数を定義しているモジュールのグローバル) に対して明示的な参照を持って
いるのに対し、コードオブジェクトにはコンテキストがないということです; ま
た、関数オブジェクトではデフォルト引数値を記憶できますが、コードオブジェ
クトではできません (実行時に計算される値を表現するため)。関数オブジェク
トと違い、コードオブジェクトは変更不可能で、変更可能なオブジェクトへの参
照を (直接、間接に関わらず) 含みません。

* Menu:

* Special read-only attributes: Special read-only attributes<2>.
* Methods on code objects::


File: python.info,  Node: Special read-only attributes<2>,  Next: Methods on code objects,  Up: コードオブジェクト

4.3.2.38 Special read-only attributes
.....................................

 -- の属性: codeobject.co_name                         The function name
                                                       
                                                       
 -- の属性: codeobject.co_qualname                     The fully qualified function name
                                                       
                                                       Added in version 3.11.
                                                       
                                                       
 -- の属性: codeobject.co_argcount                     The total number of positional
                                                       *note parameters: 1e5e. (including positional-only
                                                       parameters and parameters with default values) that
                                                       the function has
                                                       
                                                       
 -- の属性: codeobject.co_posonlyargcount              The number of positional-only
                                                       *note parameters: 1e5e. (including arguments with
                                                       default values) that the function has
                                                       
                                                       
 -- の属性: codeobject.co_kwonlyargcount               The number of keyword-only *note parameters: 1e5e.
                                                       (including arguments with default values) that the
                                                       function has
                                                       
                                                       
 -- の属性: codeobject.co_nlocals                      The number of *note local variables: 1e59. used by
                                                       the function (including parameters)
                                                       
                                                       
 -- の属性: codeobject.co_varnames                     A *note tuple: 349. containing the names of the
                                                       local variables in the function (starting with the
                                                       parameter names)
                                                       
                                                       
 -- の属性: codeobject.co_cellvars                     A *note tuple: 349. containing the names of
                                                       *note local variables: 1e59. that are referenced
                                                       from at least one *note nested scope: 1e9e. inside
                                                       the function
                                                       
                                                       
 -- の属性: codeobject.co_freevars                     A *note tuple: 349. containing the names of
                                                       *note free (closure) variables: 1e9f. that a
                                                       *note nested scope: 1e9e. references in an outer
                                                       scope.  See also *note function.__closure__: 129e.
                                                       
                                                       Note: references to global and builtin names are
                                                       'not' included.
                                                       
                                                       
 -- の属性: codeobject.co_code                         A string representing the sequence of
                                                       *note bytecode: 16c. instructions in the function
                                                       
                                                       
 -- の属性: codeobject.co_consts                       A *note tuple: 349. containing the literals used by
                                                       the *note bytecode: 16c. in the function
                                                       
                                                       
 -- の属性: codeobject.co_names                        A *note tuple: 349. containing the names used by the
                                                       *note bytecode: 16c. in the function
                                                       
                                                       
 -- の属性: codeobject.co_filename                     The name of the file from which the code was
                                                       compiled
                                                       
                                                       
 -- の属性: codeobject.co_firstlineno                  The line number of the first line of the function
                                                       
                                                       
 -- の属性: codeobject.co_lnotab                       A string encoding the mapping from
                                                       *note bytecode: 16c. offsets to line numbers.  For
                                                       details, see the source code of the interpreter.
                                                       
                                                       バージョン 3.12 で非推奨: This attribute of code
                                                       objects is deprecated, and may be removed in Python
                                                       3.15.
                                                       
                                                       
 -- の属性: codeobject.co_stacksize                    The required stack size of the code object
                                                       
                                                       
 -- の属性: codeobject.co_flags                        An *note integer: 238. encoding a number of flags
                                                       for the interpreter.
                                                       

The following flag bits are defined for *note co_flags: 1ea5.: bit
‘0x04’ is set if the function uses the ‘*arguments’ syntax to accept an
arbitrary number of positional arguments; bit ‘0x08’ is set if the
function uses the ‘**keywords’ syntax to accept arbitrary keyword
arguments; bit ‘0x20’ is set if the function is a generator.  See *note
Code Objects Bit Flags: 1ea6. for details on the semantics of each flags
that might be present.

Future feature declarations (‘from __future__ import division’) also use
bits in *note co_flags: 1ea5. to indicate whether a code object was
compiled with a particular feature enabled: bit ‘0x2000’ is set if the
function was compiled with future division enabled; bits ‘0x10’ and
‘0x1000’ were used in earlier versions of Python.

Other bits in *note co_flags: 1ea5. are reserved for internal use.

If a code object represents a function, the first item in *note
co_consts: 1ea1. is the documentation string of the function, or ‘None’
if undefined.


File: python.info,  Node: Methods on code objects,  Prev: Special read-only attributes<2>,  Up: コードオブジェクト

4.3.2.39 Methods on code objects
................................

 -- メソッド: codeobject.co_positions ()

     Returns an iterable over the source code positions of each *note
     bytecode: 16c. instruction in the code object.

     The iterator returns *note tuple: 349.s containing the
     ‘(start_line, end_line, start_column, end_column)’.  The 'i-th'
     tuple corresponds to the position of the source code that compiled
     to the 'i-th' code unit.  Column information is 0-indexed utf-8
     byte offsets on the given source line.

     This positional information can be missing.  A non-exhaustive lists
     of cases where this may happen:

        - Running the interpreter with *note -X: 15c. ‘no_debug_ranges’.

        - Loading a pyc file compiled while using *note -X: 15c.
          ‘no_debug_ranges’.

        - Position tuples corresponding to artificial instructions.

        - Line and column numbers that can't be represented due to
          implementation specific limitations.

     When this occurs, some or all of the tuple elements can be *note
     None: 641.

     Added in version 3.11.

          注釈: This feature requires storing column positions in code
          objects which may result in a small increase of disk usage of
          compiled Python files or interpreter memory usage.  To avoid
          storing the extra information and/or deactivate printing the
          extra traceback information, the *note -X: 15c.
          ‘no_debug_ranges’ command line flag or the *note
          PYTHONNODEBUGRANGES: 580. environment variable can be used.

 -- メソッド: codeobject.co_lines ()

     Returns an iterator that yields information about successive ranges
     of *note bytecode: 16c.s.  Each item yielded is a ‘(start, end,
     lineno)’ *note tuple: 349.:

        * ‘start’ (an *note int: 238.) represents the offset (inclusive)
          of the start of the *note bytecode: 16c. range

        * ‘end’ (an *note int: 238.) represents the offset (exclusive)
          of the end of the *note bytecode: 16c. range

        * ‘lineno’ is an *note int: 238. representing the line number of
          the *note bytecode: 16c. range, or ‘None’ if the bytecodes in
          the given range have no line number

     The items yielded will have the following properties:

        * The first range yielded will have a ‘start’ of 0.

        * The ‘(start, end)’ ranges will be non-decreasing and
          consecutive.  That is, for any pair of *note tuple: 349.s, the
          ‘start’ of the second will be equal to the ‘end’ of the first.

        * No range will be backwards: ‘end >= start’ for all triples.

        * The last *note tuple: 349. yielded will have ‘end’ equal to
          the size of the *note bytecode: 16c.

     Zero-width ranges, where ‘start == end’, are allowed.  Zero-width
     ranges are used for lines that are present in the source code, but
     have been eliminated by the *note bytecode: 16c. compiler.

     Added in version 3.10.

     参考
     ....

     PEP 626(1) - Precise line numbers for debugging and other tools.

          The PEP that introduced the ‘co_lines()’ method.

 -- メソッド: codeobject.replace (**kwargs)

     Return a copy of the code object with new values for the specified
     fields.

     Code objects are also supported by the generic function *note
     copy.replace(): 137.

     Added in version 3.8.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0626/


File: python.info,  Node: フレーム frame オブジェクト,  Next: トレースバック traceback オブジェクト,  Prev: コードオブジェクト,  Up: 内部型 internal type

4.3.2.40 フレーム (frame) オブジェクト
......................................

Frame objects represent execution frames.  They may occur in *note
traceback objects: ac2, and are also passed to registered trace
functions.

* Menu:

* Special read-only attributes: Special read-only attributes<3>.
* Special writable attributes: Special writable attributes<2>.
* Frame object methods::


File: python.info,  Node: Special read-only attributes<3>,  Next: Special writable attributes<2>,  Up: フレーム frame オブジェクト

4.3.2.41 Special read-only attributes
.....................................

 -- の属性: frame.f_back                               Points to the previous stack frame (towards the
                                                       caller), or ‘None’ if this is the bottom stack frame
                                                       
                                                       
 -- の属性: frame.f_code                               The *note code object: 1b4. being executed in this
                                                       frame.  Accessing this attribute raises an
                                                       *note auditing event: 1825. ‘object.__getattr__’
                                                       with arguments ‘obj’ and ‘"f_code"’.
                                                       
                                                       
 -- の属性: frame.f_locals                             The mapping used by the frame to look up
                                                       *note local variables: 1e59.  If the frame refers to
                                                       an *note optimized scope: 163, this may return a
                                                       write-through proxy object.
                                                       
                                                       バージョン 3.13 で変更: Return a proxy for optimized
                                                       scopes.
                                                       
                                                       
 -- の属性: frame.f_globals                            The dictionary used by the frame to look up
                                                       *note global variables: 1e59.
                                                       
                                                       
 -- の属性: frame.f_builtins                           The dictionary used by the frame to look up
                                                       *note built-in (intrinsic) names: 1e59.
                                                       
                                                       
 -- の属性: frame.f_lasti                              The "precise instruction" of the frame object (this
                                                       is an index into the *note bytecode: 16c. string of
                                                       the *note code object: 1b4.)
                                                       


File: python.info,  Node: Special writable attributes<2>,  Next: Frame object methods,  Prev: Special read-only attributes<3>,  Up: フレーム frame オブジェクト

4.3.2.42 Special writable attributes
....................................

 -- の属性: frame.f_trace                              If not ‘None’, this is a function called for various
                                                       events during code execution (this is used by
                                                       debuggers).  Normally an event is triggered for each
                                                       new source line (see *note f_trace_lines: ba9.).
                                                       
                                                       
 -- の属性: frame.f_trace_lines                        Set this attribute to *note False: b05. to disable
                                                       triggering a tracing event for each source line.
                                                       
                                                       
 -- の属性: frame.f_trace_opcodes                      Set this attribute to *note True: bdb. to allow
                                                       per-opcode events to be requested.  Note that this
                                                       may lead to undefined interpreter behaviour if
                                                       exceptions raised by the trace function escape to
                                                       the function being traced.
                                                       
                                                       
 -- の属性: frame.f_lineno                             The current line number of the frame - writing to
                                                       this from within a trace function jumps to the given
                                                       line (only for the bottom-most frame).  A debugger
                                                       can implement a Jump command (aka Set Next
                                                       Statement) by writing to this attribute.
                                                       


File: python.info,  Node: Frame object methods,  Prev: Special writable attributes<2>,  Up: フレーム frame オブジェクト

4.3.2.43 Frame object methods
.............................

フレームオブジェクトはメソッドを一つサポートします:

 -- メソッド: frame.clear ()

     This method clears all references to *note local variables: 1e59.
     held by the frame.  Also, if the frame belonged to a *note
     generator: 1035, the generator is finalized.  This helps break
     reference cycles involving frame objects (for example when catching
     an *note exception: 17ee. and storing its *note traceback: ac2. for
     later use).

     *note RuntimeError: 17a. is raised if the frame is currently
     executing or suspended.

     Added in version 3.4.

     バージョン 3.13 で変更: Attempting to clear a suspended frame
     raises *note RuntimeError: 17a. (as has always been the case for
     executing frames).


File: python.info,  Node: トレースバック traceback オブジェクト,  Next: スライス slice オブジェクト,  Prev: フレーム frame オブジェクト,  Up: 内部型 internal type

4.3.2.44 トレースバック (traceback) オブジェクト
................................................

Traceback objects represent the stack trace of an *note exception: 1bf4.
A traceback object is implicitly created when an exception occurs, and
may also be explicitly created by calling *note types.TracebackType:
ac0.

バージョン 3.7 で変更: Traceback objects can now be explicitly
instantiated from Python code.

For implicitly created tracebacks, when the search for an exception
handler unwinds the execution stack, at each unwound level a traceback
object is inserted in front of the current traceback.  When an exception
handler is entered, the stack trace is made available to the program.
(See section *note try 文: 6b4.)  It is accessible as the third item of
the tuple returned by *note sys.exc_info(): 656, and as the *note
__traceback__: 1296. attribute of the caught exception.

When the program contains no suitable handler, the stack trace is
written (nicely formatted) to the standard error stream; if the
interpreter is interactive, it is also made available to the user as
*note sys.last_traceback: 48d.

For explicitly created tracebacks, it is up to the creator of the
traceback to determine how the *note tb_next: ac1. attributes should be
linked to form a full stack trace.

Special read-only attributes:

 -- の属性: traceback.tb_frame                         Points to the execution *note frame: 6ab. of the
                                                       current level.
                                                       
                                                       Accessing this attribute raises an
                                                       *note auditing event: 1825. ‘object.__getattr__’
                                                       with arguments ‘obj’ and ‘"tb_frame"’.
                                                       
                                                       
 -- の属性: traceback.tb_lineno                        Gives the line number where the exception occurred
                                                       
                                                       
 -- の属性: traceback.tb_lasti                         Indicates the "precise instruction".
                                                       

The line number and last instruction in the traceback may differ from
the line number of its *note frame object: 6ab. if the exception
occurred in a *note try: 6b4. statement with no matching except clause
or with a *note finally: 997. clause.

 -- の属性: traceback.tb_next

     The special writable attribute ‘tb_next’ is the next level in the
     stack trace (towards the frame where the exception occurred), or
     ‘None’ if there is no next level.

     バージョン 3.7 で変更: This attribute is now writable


File: python.info,  Node: スライス slice オブジェクト,  Next: 静的メソッド static method オブジェクト,  Prev: トレースバック traceback オブジェクト,  Up: 内部型 internal type

4.3.2.45 スライス (slice) オブジェクト
......................................

スライスオブジェクトは、 *note __getitem__(): 264. メソッドのためのスラ
イスを表すのに使われます。スライスオブジェクトは組み込みの *note
slice(): 436. 関数でも生成されます。

読み出し専用の特殊属性: *note start: 1eb6. は下限です; *note stop: 1eb7.
は上限です; *note step: 1eb8. はステップの値です; それぞれ省略された場合
は ‘None’ となっています。これらの属性は任意の型を持てます。

スライスオブジェクトはメソッドを一つサポートします:

 -- メソッド: slice.indices (self, length)

     このメソッドは単一の整数引数 'length' を取り、スライスオブジェクト
     が 'length' 要素のシーケンスに適用されたときに表現する、スライスに
     関する情報を計算します。このメソッドは 3 つの整数からなるタプルを返
     します; それぞれ 'start' および 'stop' のインデックスと、'step' す
     なわちスライスのまたぎ幅です。インデックス値がないか、範囲外の値で
     あれば、通常のスライスと変わらないやりかたで扱われます。


File: python.info,  Node: 静的メソッド static method オブジェクト,  Next: クラスメソッドオブジェクト,  Prev: スライス slice オブジェクト,  Up: 内部型 internal type

4.3.2.46 静的メソッド (static method) オブジェクト
..................................................

静的メソッドは、上で説明したような関数オブジェクトからメソッドオブジェク
トへの変換を阻止するための方法を提供します。静的メソッドオブジェクトは他
の何らかのオブジェクト、通常はユーザ定義メソッドオブジェクトを包むラッパ
です。静的メソッドをクラスやクラスインスタンスから取得すると、実際に返さ
れるオブジェクトはラップされたオブジェクトになり、それ以上は変換の対象に
はなりません。静的メソッドオブジェクトは通常呼び出し可能なオブジェクトを
ラップしますが、静的オブジェクト自体は呼び出し可能です。静的オブジェクト
は組み込みコンストラクタ *note staticmethod(): 3ef. で生成されます。


File: python.info,  Node: クラスメソッドオブジェクト,  Prev: 静的メソッド static method オブジェクト,  Up: 内部型 internal type

4.3.2.47 クラスメソッドオブジェクト
...................................

A class method object, like a static method object, is a wrapper around
another object that alters the way in which that object is retrieved
from classes and class instances.  The behaviour of class method objects
upon such retrieval is described above, under *note "instance methods":
1c28.  Class method objects are created by the built-in *note
classmethod(): 14c. constructor.


File: python.info,  Node: 特殊メソッド名,  Next: コルーチン,  Prev: 標準型の階層,  Up: データモデル

4.3.3 特殊メソッド名
--------------------

クラスは、特殊な名前のメソッドを定義して、特殊な構文 (算術演算や添え字表
記、スライス表記など) による特定の演算を実装できます。これは、Python の
演算子オーバロード ('operator overloading') へのアプローチです。これによ
り、クラスは言語の演算子に対する独自の振る舞いを定義できます。例えば、あ
るクラスが *note __getitem__(): 264. という名前のメソッドを定義しており
、 ‘x’ がこのクラスのインスタンスであるとすると、 ‘x[i]’ は
‘type(x).__getitem__(x, i)’ とほぼ等価です。特に注釈のない限り、適切なメ
ソッドが定義されていないとき、このような演算を試みると例外 (たいていは
*note AttributeError: 326. か *note TypeError: 502.) が送出されます。

特殊メソッドに ‘None’ を設定することは、それに対応する演算が利用できない
ことを意味します。 例えば、クラスの *note __iter__(): 1ebc. を ‘None’ に
設定した場合、そのクラスはイテラブルにはならず、そのインスタンスに対し
*note iter(): 7a2. を呼び出すと (*note __getitem__(): 264. に処理が戻さ
れずに) *note TypeError: 502. を送出します。 (1)

組み込み型をエミュレートするクラスを実装するときは、模範とされるオブジェ
クトにとって意味がある範囲に実装をとどめるのが重要です。例えば、あるシー
ケンスは個々の要素の取得はきちんと動くかもしれませんが、スライスの展開が
意味をなさないかもしれません。 (W3C のドキュメントオブジェクトモデルにあ
る ‘NodeList’ インターフェースがその一例です。)

* Menu:

* 基本的なカスタマイズ::
* 属性値アクセスをカスタマイズする::
* クラス生成をカスタマイズする::
* インスタンスのカスタマイズとサブクラスチェック::
* ジェネリック型をエミュレートする::
* 呼び出し可能オブジェクトをエミュレートする::
* コンテナをエミュレートする::
* 数値型をエミュレートする::
* with文とコンテキストマネージャ::
* クラスパターンマッチの位置引数のカスタマイズ::
* Emulating buffer types::
* 特殊メソッド検索::

   ---------- Footnotes ----------

   (1) The *note __hash__(): ac9, *note __iter__(): 1ebc, *note
__reversed__(): 1ebd, *note __contains__(): 1ebe, *note
__class_getitem__(): 706. and *note __fspath__(): c20. methods have
special handling for this.  Others will still raise a *note TypeError:
502, but may do so by relying on the behavior that ‘None’ is not
callable.


File: python.info,  Node: 基本的なカスタマイズ,  Next: 属性値アクセスをカスタマイズする,  Up: 特殊メソッド名

4.3.3.1 基本的なカスタマイズ
............................

 -- メソッド: object.__new__ (cls[, ...])

     クラス 'cls' の新しいインスタンスを作るために呼び出されます。 *note
     __new__(): 54c. は静的メソッドで (このメソッドは特別扱いされている
     ので、明示的に静的メソッドと宣言する必要はありません)、インスタンス
     を生成するよう要求されているクラスを第一引数にとります。残りの引数
     はオブジェクトのコンストラクタの式 (クラスの呼び出し文) に渡されま
     す。 *note __new__(): 54c. の戻り値は新しいオブジェクトのインスタン
     ス (通常は 'cls' のインスタンス) でなければなりません。

     典型的な実装では、クラスの新たなインスタンスを生成するときには
     ‘super().__new__(cls[, ...])’ に適切な引数を指定してスーパクラスの
     *note __new__(): 54c. メソッドを呼び出し、新たに生成されたインスタ
     ンスに必要な変更を加えてから返します。

     もし *note __new__(): 54c. が オブジェクトの作成中に呼び出され、
     'cls' のインスタンスを返した場合には、 ‘__init__(self[, ...])’ のよ
     うにして新しいインスタンスの *note __init__(): 67c. が呼び出されま
     す。このとき、 'self' は新たに生成されたインスタンスで、残りの引数
     はオブジェクトコンストラクタに渡された引数と同じになります。

     *note __new__(): 54c. が 'cls' のインスタンスを返さない場合、インス
     タンスの *note __init__(): 67c. メソッドは呼び出されません。

     *note __new__(): 54c. の主な目的は、変更不能な型 (int, str, tuple な
     ど) のサブクラスでインスタンス生成をカスタマイズすることにあります
     。また、クラス生成をカスタマイズするために、カスタムのメタクラスで
     よくオーバーライドされます。

 -- メソッド: object.__init__ (self[, ...])

     インスタンスが (*note __new__(): 54c. によって) 生成された後、それ
     が呼び出し元に返される前に呼び出されます。引数はクラスのコンストラ
     クタ式に渡したものです。基底クラスとその派生クラスがともに *note
     __init__(): 67c. メソッドを持つ場合、派生クラスの *note __init__():
     67c. メソッドは基底クラスの *note __init__(): 67c. メソッドを明示的
     に呼び出して、インスタンスの基底クラス部分が適切に初期化されること
     保証しなければなりません。例えば、 ‘super().__init__([args...])’ 。

     *note __new__(): 54c. と *note __init__(): 67c. は連携してオブジェ
     クトを構成する (*note __new__(): 54c. が作成し、 *note __init__():
     67c. がそれをカスタマイズする) ので、 *note __init__(): 67c. から非
     ‘None’ 値を返してはいけません; そうしてしまうと、実行時に *note
     TypeError: 502. が送出されてしまいます。

 -- メソッド: object.__del__ (self)

     インスタンスが破棄されるときに呼び出されます。 これはファイナライザ
     や (適切ではありませんが) デストラクタとも呼ばれます。 基底クラスが
     *note __del__(): 1ec1. メソッドを持っている場合は、派生クラスの
     *note __del__(): 1ec1. メソッドは何であれ、基底クラスの *note
     __del__(): 1ec1. メソッドを明示的に呼び出して、インスタンスの基底ク
     ラス部分をきちんと確実に削除しなければなりません。

     *note __del__(): 1ec1. メソッドが破棄しようとしているインスタンスへ
     の新しい参照を作り、破棄を送らせることは (推奨されないものの) 可能
     です。 これはオブジェクトの '復活' と呼ばれます。 復活したオブジェ
     クトが再度破棄される直前に *note __del__(): 1ec1. が呼び出されるか
     どうかは実装依存です; 現在の *note CPython: 6c1. の実装では最初の一
     回しか呼び出されません。

     It is not guaranteed that *note __del__(): 1ec1. methods are called
     for objects that still exist when the interpreter exits.  *note
     weakref.finalize: a4a. provides a straightforward way to register a
     cleanup function to be called when an object is garbage collected.

          注釈: ‘del x’ は直接 ‘x.__del__()’ を呼び出しません -- 前者は
          ‘x’ の参照カウントを 1 つ減らし、後者は ‘x’ の参照カウントが 0
          まで落ちたときのみ呼び出されます。

     'CPython 実装の詳細:' It is possible for a reference cycle to
     prevent the reference count of an object from going to zero.  In
     this case, the cycle will be later detected and deleted by the
     *note cyclic garbage collector: 1884.  A common cause of reference
     cycles is when an exception has been caught in a local variable.
     The frame's locals then reference the exception, which references
     its own traceback, which references the locals of all frames caught
     in the traceback.

     参考
     ....

     *note gc: 56. モジュールのドキュメント。

          警告: メソッド *note __del__(): 1ec1. は不安定な状況で呼び出さ
          れるため、実行中に発生した例外は無視され、代わりに
          ‘sys.stderr’ に警告が表示されます。特に:

             * *note __del__(): 1ec1. は、任意のコードが実行されていると
               きに、任意のスレッドから呼び出せます。 *note __del__():
               1ec1. で、ロックを取ったり、ブロックするリソースを呼び出
               したりする必要がある場合、 *note __del__(): 1ec1. の実行
               により中断されたコードにより、そのリソースが既に取得され
               ていて、デッドロックが起きるかもしれません。

             * *note __del__(): 1ec1. は、インタプリタのシャットダウン中
               に実行できます。 従って、(他のモジュールも含めた) アクセ
               スする必要があるグローバル変数はすでに削除されているか、
               ‘None’ に設定されているかもしれません。 Python は、単一の
               アンダースコアで始まる名前のグローバルオブジェクトは、他
               のグローバル変数が削除される前にモジュールから削除される
               ことを保証します; そのようなグローバル変数への他からの参
               照が存在しない場合、*note __del__(): 1ec1. メソッドが呼ば
               れた時点で、インポートされたモジュールがまだ利用可能であ
               ることを保証するのに役立つかもしれません。

 -- メソッド: object.__repr__ (self)

     *note repr(): 7c8. 組み込み関数によって呼び出され、オブジェクトを表
     す「公式の (official)」文字列を計算します。可能なら、これは (適切な
     環境が与えられれば) 同じ値のオブジェクトを再生成するのに使える、有
     効な Python 式のようなものであるべきです。できないなら、 ‘<...some
     useful description...>’ 形式の文字列が返されるべきです。戻り値は文
     字列オブジェクトでなければなりません。クラスが *note __repr__():
     5e8. を定義していて *note __str__(): 5e9. は定義していなければ、そ
     のクラスのインスタンスの「非公式の (informal)」文字列表現が要求され
     たときにも *note __repr__(): 5e8. が使われます。

     This is typically used for debugging, so it is important that the
     representation is information-rich and unambiguous.  A default
     implementation is provided by the *note object: a5a. class itself.

 -- メソッド: object.__str__ (self)

     Called by *note str(object): 418, the default *note __format__():
     5ea. implementation, and the built-in function *note print(): f42,
     to compute the "informal" or nicely printable string representation
     of an object.  The return value must be a *note str: 1b67. object.

     *note __str__(): 5e9. が有効な Python 表現を返すことが期待されない
     という点で、このメソッドは *note object.__repr__(): 5e8. とは異なり
     ます: より便利な、または簡潔な表現を使用することができます。

     組み込み型 *note object: a5a. によって定義されたデフォルト実装は、
     *note object.__repr__(): 5e8. を呼び出します。

 -- メソッド: object.__bytes__ (self)

     Called by *note bytes: 1a24. to compute a byte-string
     representation of an object.  This should return a *note bytes:
     1a4. object.  The *note object: a5a. class itself does not provide
     this method.

 -- メソッド: object.__format__ (self, format_spec)

     *note format(): 5eb. 組み込み関数、さらには *note
     フォーマット済み文字列リテラル: 977. の評価、 *note str.format():
     5ed. メソッドによって呼び出され、オブジェクトの "フォーマット化され
     た (formatted)" 文字列表現を作ります。 'format_spec' 引数は、 必要
     なフォーマット化オプションの記述を含む文字列です。 'format_spec' 引
     数の解釈は、 *note __format__(): 5ea. を実装する型によりますが、 ほ
     とんどのクラスは組み込み型のいずれかにフォーマット化を委譲したり、
     同じようなフォーマット化オプション構文を使います。

     標準のフォーマット構文の解説は、 *note 書式指定ミニ言語仕様: 1c9. を
     参照してください。

     戻り値は文字列オブジェクトでなければなりません。

     The default implementation by the *note object: a5a. class should
     be given an empty 'format_spec' string.  It delegates to *note
     __str__(): 5e9.

     バージョン 3.4 で変更: 空でない文字列が渡された場合 ‘object’ 自身の
     __format__ メソッドは *note TypeError: 502. を送出します。

     バージョン 3.7 で変更: ‘object.__format__(x, '')’ は
     ‘format(str(x), '')’ ではなく ‘str(x)’ と等価になりました。

 -- メソッド: object.__lt__ (self, other)
 -- メソッド: object.__le__ (self, other)
 -- メソッド: object.__eq__ (self, other)
 -- メソッド: object.__ne__ (self, other)
 -- メソッド: object.__gt__ (self, other)
 -- メソッド: object.__ge__ (self, other)

     これらはいわゆる "拡張比較 (rich comparison)" メソッドです。演算子
     シンボルとメソッド名の対応は以下の通りです: ‘x<y’ は ‘x.__lt__(y)’
     を呼び出します; ‘x<=y’ は ‘x.__le__(y)’ を呼び出します; ‘x==y’ は
     ‘x.__eq__(y)’ を呼び出します; ‘x!=y’ は ‘x.__ne__(y)’ を呼び出しま
     す; ‘x>y’ は ‘x.__gt__(y)’ を呼び出します; ‘x>=y’ は ‘x.__ge__(y)’
     を呼び出します。

     A rich comparison method may return the singleton *note
     NotImplemented: 79d. if it does not implement the operation for a
     given pair of arguments.  By convention, ‘False’ and ‘True’ are
     returned for a successful comparison.  However, these methods can
     return any value, so if the comparison operator is used in a
     Boolean context (e.g., in the condition of an ‘if’ statement),
     Python will call *note bool(): 434. on the value to determine if
     the result is true or false.

     By default, ‘object’ implements *note __eq__(): ac8. by using ‘is’,
     returning *note NotImplemented: 79d. in the case of a false
     comparison: ‘True if x is y else NotImplemented’.  For *note
     __ne__(): 14c1, by default it delegates to *note __eq__(): ac8. and
     inverts the result unless it is ‘NotImplemented’.  There are no
     other implied relationships among the comparison operators or
     default implementations; for example, the truth of ‘(x<y or x==y)’
     does not imply ‘x<=y’.  To automatically generate ordering
     operations from a single root operation, see *note
     functools.total_ordering(): f0f.

     By default, the *note object: a5a. class provides implementations
     consistent with *note 値の比較: 17e6.: equality compares according
     to object identity, and order comparisons raise *note TypeError:
     502.  Each default method may generate these results directly, but
     may also return *note NotImplemented: 79d.

     カスタムの比較演算をサポートしていて、辞書のキーに使うことができる
     *note ハッシュ可能: 5db. オブジェクトを作るときの重要な注意点につい
     て、 *note __hash__(): ac9. のドキュメント内に書かれているので参照
     してください。

     There are no swapped-argument versions of these methods (to be used
     when the left argument does not support the operation but the right
     argument does); rather, *note __lt__(): 12d9. and *note __gt__():
     12db. are each other's reflection, *note __le__(): 12da. and *note
     __ge__(): 12dc. are each other's reflection, and *note __eq__():
     ac8. and *note __ne__(): 14c1. are their own reflection.  If the
     operands are of different types, and the right operand's type is a
     direct or indirect subclass of the left operand's type, the
     reflected method of the right operand has priority, otherwise the
     left operand's method has priority.  Virtual subclassing is not
     considered.

     When no appropriate method returns any value other than *note
     NotImplemented: 79d, the ‘==’ and ‘!=’ operators will fall back to
     ‘is’ and ‘is not’, respectively.

 -- メソッド: object.__hash__ (self)

     組み込みの *note hash(): 5b5. 関数や、 *note set: 5a3, *note
     frozenset: 5a4, *note dict: 237. のようなハッシュを使ったコレクショ
     ン型の要素に対する操作から呼び出されます。 ‘__hash__()’ メソッドは
     整数を返さなければなりません。 このメソッドに必要な性質は、比較結果
     が等しいオブジェクトは同じハッシュ値を持つということです; オブジェ
     クトを比較するときでも利用される要素をタプルに詰めてハッシュ値を計
     算することで、それぞれの要素のハッシュ値を混合することをおすすめし
     ます。

          def __hash__(self):
              return hash((self.name, self.nick, self.color))

          注釈: *note hash(): 5b5. はオブジェクト独自の *note
          __hash__(): ac9. メソッドが返す値を *note Py_ssize_t: a2e. の
          サイズに切り詰めます。 これは 64-bit でビルドされていると 8 バ
          イトで、 32-bit でビルドされていると 4 バイトです。 オブジェク
          トの *note __hash__(): ac9. が異なる bit サイズのビルドでも可
          搬性が必要である場合は、必ず全てのサポートするビルドの bit 幅
          をチェックしてください。 そうする簡単な方法は ‘python -c
          "import sys; print(sys.hash_info.width)"’ を実行することです。

     クラスが *note __eq__(): ac8. メソッドを定義していないなら、 *note
     __hash__(): ac9. メソッドも定義してはなりません; クラスが *note
     __eq__(): ac8. を定義していても *note __hash__(): ac9. を定義してい
     ないなら、そのインスタンスはハッシュ可能コレクションの要素として使
     えません。クラスがミュータブルなオブジェクトを定義しており、 *note
     __eq__(): ac8. メソッドを実装しているなら、 *note __hash__(): ac9.
     を定義してはなりません。これは、*note ハッシュ可能: 5db. コレクショ
     ンの実装においてキーのハッシュ値がイミュータブルであることが要求さ
     れているからです (オブジェクトのハッシュ値が変化すると、誤ったハッ
     シュバケツ: hash bucket に入ってしまいます)。

     User-defined classes have *note __eq__(): ac8. and *note
     __hash__(): ac9. methods by default (inherited from the *note
     object: a5a. class); with them, all objects compare unequal (except
     with themselves) and ‘x.__hash__()’ returns an appropriate value
     such that ‘x == y’ implies both that ‘x is y’ and ‘hash(x) ==
     hash(y)’.

     *note __eq__(): ac8. をオーバーライドしていて *note __hash__():
     ac9. を定義していないクラスでは、 *note __hash__(): ac9. は暗黙的に
     ‘None’ に設定されます。 クラスの *note __hash__(): ac9. メソッドが
     ‘None’ の場合、そのクラスのインスタンスのハッシュ値を取得しようとす
     ると適切な *note TypeError: 502. が送出され、 ‘isinstance(obj,
     collections.abc.Hashable)’ でチェックするとハッシュ不能なものとして
     正しく認識されます。

     *note __eq__(): ac8. をオーバーライドしたクラスが親クラスからの
     *note __hash__(): ac9. の 実装を保持したいなら、明示的に ‘__hash__
     = <ParentClass>.__hash__’ を設定することで、それをインタプリタに伝
     えなければなりません。

     *note __eq__(): ac8. をオーバーライドしていないクラスがハッシュサポ
     ートを抑制したい場合、クラス定義に ‘__hash__ = None’ を含めてくださ
     い。クラス自身で明示的に *note TypeError: 502. を送出する *note
     __hash__(): ac9. を定義すると、 ‘isinstance(obj,
     collections.abc.Hashable)’ 呼び出しで誤ってハッシュ可能と識別される
     でしょう。

          注釈: デフォルトでは、文字列とバイト列の *note __hash__():
          ac9. 値は予測不可能なランダム値で "ソルト" されます。 ハッシュ
          値は単独の Python プロセス内では定数であり続けますが、Python を
          繰り返し起動する毎に、予測できなくなります。

          This is intended to provide protection against a
          denial-of-service caused by carefully chosen inputs that
          exploit the worst case performance of a dict insertion,
          'O'('n'^2) complexity.  See
          ‘http://ocert.org/advisories/ocert-2011-003.html’ for details.

          ハッシュ値の変更は、集合のイテレーション順序に影響します。
          Python はこの順序付けを保証していません (そして通常 32-bit と
          64-bit の間でも異なります)。

          *note PYTHONHASHSEED: 1052. も参照してください。

     バージョン 3.3 で変更: ハッシュのランダム化がデフォルトで有効になり
     ました。

 -- メソッド: object.__bool__ (self)

     Called to implement truth value testing and the built-in operation
     ‘bool()’; should return ‘False’ or ‘True’.  When this method is not
     defined, *note __len__(): 1ec3. is called, if it is defined, and
     the object is considered true if its result is nonzero.  If a class
     defines neither ‘__len__()’ nor ‘__bool__()’ (which is true of the
     *note object: a5a. class itself), all its instances are considered
     true.


File: python.info,  Node: 属性値アクセスをカスタマイズする,  Next: クラス生成をカスタマイズする,  Prev: 基本的なカスタマイズ,  Up: 特殊メソッド名

4.3.3.2 属性値アクセスをカスタマイズする
........................................

以下のメソッドを定義して、クラスインスタンスへの属性アクセス ( ‘x.name’
の使用、 ‘x.name’ への代入、 ‘x.name’ の削除) の意味をカスタマイズするこ
とができます。

 -- メソッド: object.__getattr__ (self, name)

     Called when the default attribute access fails with an *note
     AttributeError: 326. (either *note __getattribute__(): ba0. raises
     an *note AttributeError: 326. because 'name' is not an instance
     attribute or an attribute in the class tree for ‘self’; or *note
     __get__(): 1490. of a 'name' property raises *note AttributeError:
     326.).  This method should either return the (computed) attribute
     value or raise an *note AttributeError: 326. exception.  The *note
     object: a5a. class itself does not provide this method.

     Note that if the attribute is found through the normal mechanism,
     *note __getattr__(): 49f. is not called.  (This is an intentional
     asymmetry between *note __getattr__(): 49f. and *note
     __setattr__(): 1e8d.)  This is done both for efficiency reasons and
     because otherwise *note __getattr__(): 49f. would have no way to
     access other attributes of the instance.  Note that at least for
     instance variables, you can take total control by not inserting any
     values in the instance attribute dictionary (but instead inserting
     them in another object).  See the *note __getattribute__(): ba0.
     method below for a way to actually get total control over attribute
     access.

 -- メソッド: object.__getattribute__ (self, name)

     クラスのインスタンスに対する属性アクセスを実装するために、無条件に
     呼び出されます。クラスが *note __getattr__(): 49f. も定義している場
     合、 *note __getattr__(): 49f. は、 *note __getattribute__(): ba0.
     で明示的に呼び出すか、 *note AttributeError: 326. 例外を送出しない
     限り呼ばれません。このメソッドは (計算された) 属性値を返すか、
     *note AttributeError: 326. 例外を送出します。このメソッドが再帰的に
     際限なく呼び出されてしまうのを防ぐため、実装の際には常に、必要な属
     性全てへのアクセスで、例えば ‘object.__getattribute__(self, name)’
     のように基底クラスのメソッドを同じ属性名を使って呼び出さなければな
     りません。

          注釈: This method may still be bypassed when looking up
          special methods as the result of implicit invocation via
          language syntax or *note built-in functions: 1e60.  See *note
          特殊メソッド検索: 1ec6.

     セキュリティに関わるような ‘obj’ と ‘name’ を渡しての
     ‘object.__getattr__’ を使った属性アクセスは *note 監査イベント:
     1825. を送出します。

 -- メソッド: object.__setattr__ (self, name, value)

     属性の代入が試みられた際に呼び出されます。これは通常の代入の過程 (す
     なわち、インスタンス辞書への値の代入) の代わりに呼び出されます。
     'name' は属性名で、'value' はその属性に代入する値です。

     *note __setattr__(): 1e8d. の中でインスタンス属性への代入が必要なら
     、基底クラスのこれと同じ名前のメソッドを呼び出さなければなりません
     。例えば、 ‘object.__setattr__(self, name, value)’ とします。

     セキュリティに関わるような ‘obj’ と ‘name’ と ‘value’ を渡しての
     ‘object.__setattr__’ を使った属性のアサインは *note 監査イベント:
     1825. を送出します。

 -- メソッド: object.__delattr__ (self, name)

     *note __setattr__(): 1e8d. に似ていますが、代入ではなく値の削除を行
     います。このメソッドを実装するのは、オブジェクトにとって ‘del
     obj.name’ が意味がある場合だけにしなければなりません。

     セキュリティに関わるような ‘obj’ と ‘name’ を渡しての
     ‘object.__getattr__’ を使った属性の削除は *note 監査イベント: 1825.
     を送出します。

 -- メソッド: object.__dir__ (self)

     Called when *note dir(): 5fe. is called on the object.  An iterable
     must be returned.  *note dir(): 5fe. converts the returned iterable
     to a list and sorts it.

* Menu:

* モジュールの属性値アクセスをカスタマイズする::
* デスクリプタ (descriptor) の実装: デスクリプタ descriptor の実装.
* デスクリプタの呼び出し::
* __slots__: __slots__<2>.


File: python.info,  Node: モジュールの属性値アクセスをカスタマイズする,  Next: デスクリプタ descriptor の実装,  Up: 属性値アクセスをカスタマイズする

4.3.3.3 モジュールの属性値アクセスをカスタマイズする
....................................................

特殊な名前の ‘__getattr__’ と ‘__dir__’ も、モジュール属性へのアクセスを
カスタマイズするのに使えます。 モジュールレベルの ‘__getattr__’ 関数は属
性名である 1 引数を受け取り、計算した値を返すか *note AttributeError:
326. を送出します。 属性がモジュールオブジェクトから、通常の検索、つまり
*note object.__getattribute__(): ba0. で見付からなかった場合は、 *note
AttributeError: 326. を送出する前に、モジュールの ‘__dict__’ から
‘__getattr__’ が検索されます。 見付かった場合は、その属性名で呼び出され
、結果が返されます。

The ‘__dir__’ function should accept no arguments, and return an
iterable of strings that represents the names accessible on module.  If
present, this function overrides the standard *note dir(): 5fe. search
on a module.

より細かい粒度でのモジュールの動作 (属性やプロパティの設定など) のカスタ
マイズのために、モジュールオブジェクトの ‘__class__’ 属性に *note
types.ModuleType: de0. のサブクラスが設定できます。 例えば次のようになり
ます:

     import sys
     from types import ModuleType

     class VerboseModule(ModuleType):
         def __repr__(self):
             return f'Verbose {self.__name__}'

         def __setattr__(self, attr, value):
             print(f'Setting {attr}...')
             super().__setattr__(attr, value)

     sys.modules[__name__].__class__ = VerboseModule

     注釈: モジュールの ‘__getattr__’ を定義したり ‘__class__’ を設定し
     たりしても、影響があるのは属性アクセスの構文が使われる検索だけです
     - モジュールの globals への直接アクセスは (モジュール内のコードから
     とモジュールの globals のどちらでも) 影響を受けません。

バージョン 3.5 で変更: モジュールの属性 ‘__class__’ が書き込み可能になり
ました。

Added in version 3.7: ‘__getattr__’ モジュール属性と ‘__dir__’ モジュー
ル属性。

参考
....

PEP 562(1) - モジュールの __getattr__ と __dir__

     モジュールの ‘__getattr__’ 関数および ‘__dir__’ 関数の説明。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0562/


File: python.info,  Node: デスクリプタ descriptor の実装,  Next: デスクリプタの呼び出し,  Prev: モジュールの属性値アクセスをカスタマイズする,  Up: 属性値アクセスをカスタマイズする

4.3.3.4 デスクリプタ (descriptor) の実装
........................................

The following methods only apply when an instance of the class
containing the method (a so-called 'descriptor' class) appears in an
'owner' class (the descriptor must be in either the owner's class
dictionary or in the class dictionary for one of its parents).  In the
examples below, "the attribute" refers to the attribute whose name is
the key of the property in the owner class' *note __dict__: 526.  The
*note object: a5a. class itself does not implement any of these
protocols.

 -- メソッド: object.__get__ (self, instance, owner=None)

     オーナークラス（クラス属性アクセスの場合）や、クラスのインスタンス
     （インスタンス属性アクセスの場合）の属性取得時に呼び出されます。
     'instance' を通じて属性をアクセスする時に、オプションの 'owner' 引
     数はオーナークラスです。 'owner' を通じて属性アクセスするときは
     ‘None’ です。

     このメソッドは、算出された属性値を返すか、 *note AttributeError:
     326. 例外を送出します。

     PEP 252(1) は *note __get__(): 1490. は1つや2つの引数を持つ呼び出し
     可能オブジェクトであると定義しています。Pythonの組み込みのデスクリ
     プタはこの仕様をサポートしていますが、サードパーティ製のツールの中
     には両方の引数を必要とするものもあります。Pythonの *note
     __getattribute__(): ba0. 実装は必要かどうかに関わらず、両方の引数を
     常に渡します。

 -- メソッド: object.__set__ (self, instance, value)

     オーナークラスのインスタンス 'instance' 上の属性を新たな値 'value'
     に設定する際に呼び出されます。

     *note __set__(): 1eca. あるいは *note __delete__(): 156c. を追加す
     ると、デスクリプタは「データデスクリプタ」に変わります。詳細は
     *note デスクリプタの呼び出し: 1ecb. を参照してください。

 -- メソッド: object.__delete__ (self, instance)

     オーナークラスのインスタンス 'instance' 上の属性を削除する際に呼び
     出されます。

Instances of descriptors may also have the ‘__objclass__’ attribute
present:

 -- の属性: object.__objclass__

     The attribute ‘__objclass__’ is interpreted by the *note inspect:
     72. module as specifying the class where this object was defined
     (setting this appropriately can assist in runtime introspection of
     dynamic class attributes).  For callables, it may indicate that an
     instance of the given type (or a subclass) is expected or required
     as the first positional argument (for example, CPython sets this
     attribute for unbound methods that are implemented in C).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0252/


File: python.info,  Node: デスクリプタの呼び出し,  Next: __slots__<2>,  Prev: デスクリプタ descriptor の実装,  Up: 属性値アクセスをカスタマイズする

4.3.3.5 デスクリプタの呼び出し
..............................

一般にデスクリプタとは、特殊な "束縛に関する動作 (binding behaviour)" を
もつオブジェクト属性のことです。デスクリプタは、デスクリプタプロトコル
(descriptor protocol) のメソッド: *note __get__(): 1490, *note
__set__(): 1eca, および *note __delete__(): 156c. を使って、属性アクセス
をオーバーライドしているものです。これらのメソッドのいずれかがオブジェク
トに対して定義されている場合、オブジェクトはデスクリプタであるといいます
。

属性アクセスのデフォルトの動作は、オブジェクトの辞書から値を取り出したり
、値を設定したり、削除したりするというものです。例えば、 ‘a.x’ による属
性の検索では、まず ‘a.__dict__['x']’ 、次に ‘type(a).__dict__['x']’ 、そ
して ‘type(a)’ の基底クラスでメタクラスでないものに続く、といった具合に
連鎖が起こります。

しかし、検索対象の値が、デスクリプタメソッドのいずれかを定義しているオブ
ジェクトであれば、Python はデフォルトの動作をオーバーライドして、代わり
にデスクリプタメソッドを呼び出します。先述の連鎖の中のどこでデスクリプタ
メソッドが呼び出されるかは、どのデスクリプタメソッドが定義されていて、ど
のように呼び出されたかに依存します。

デスクリプタ呼び出しの基点となるのは、属性名への束縛 (binding) 、すなわ
ち ‘a.x’ です。引数がどのようにデスクリプタに結合されるかは ‘a’ に依存し
ます:

直接呼び出し (Direct Call)

     最も単純で、かつめったに使われない呼び出し操作は、コード中で直接デ
     スクリプタメソッドの呼び出し: ‘x.__get__(a)’ を行うというものです。

インスタンス束縛 (Instance Binding)

     オブジェクトインスタンスへ束縛すると、‘a.x’ は呼び出し
     ‘type(a).__dict__['x'].__get__(a, type(a))’ に変換されます。

クラス束縛 (Class Binding)

     クラスへ束縛すると、‘A.x’ は呼び出し ‘A.__dict__['x'].__get__(None,
     A)’ に変換されます。

super 束縛 (Super Binding)

     ‘super(A, a).x’ のようなドットを使ったルックアップは
     ‘a.__class__.__mro__’ を探索して、 ‘A’ の前のクラス ‘B’ をまず探し
     、 ‘B.__dict__['x'].__get__(a, A)’ を返します。もしデスクリプタでな
     ければ ‘x’ を変更せずに返します。

For instance bindings, the precedence of descriptor invocation depends
on which descriptor methods are defined.  A descriptor can define any
combination of *note __get__(): 1490, *note __set__(): 1eca. and *note
__delete__(): 156c.  If it does not define ‘__get__()’, then accessing
the attribute will return the descriptor object itself unless there is a
value in the object's instance dictionary.  If the descriptor defines
‘__set__()’ and/or ‘__delete__()’, it is a data descriptor; if it
defines neither, it is a non-data descriptor.  Normally, data
descriptors define both ‘__get__()’ and ‘__set__()’, while non-data
descriptors have just the ‘__get__()’ method.  Data descriptors with
‘__get__()’ and ‘__set__()’ (and/or ‘__delete__()’) defined always
override a redefinition in an instance dictionary.  In contrast,
non-data descriptors can be overridden by instances.

(*note @staticmethod: 3ef. や *note @classmethod: 14c. を含む) Python メ
ソッドは、非データデスクリプタとして実装されています。その結果、インスタ
ンスではメソッドを再定義したりオーバーライドできます。このことにより、個
々のインスタンスが同じクラスの他のインスタンスと互いに異なる動作を獲得す
ることができます。

*note property(): 179. 関数はデータデスクリプタとして実装されています。
従って、インスタンスはあるプロパティの動作をオーバーライドすることができ
ません。


File: python.info,  Node: __slots__<2>,  Prev: デスクリプタの呼び出し,  Up: 属性値アクセスをカスタマイズする

4.3.3.6 __slots__
.................

'__slots__' を使うと、(プロパティのように) データメンバを明示的に宣言し
、 (明示的に '__slots__' で宣言しているか親クラスに存在しているかでない
限り) *note __dict__: 526. や '__weakref__' を作成しないようにできます。

*note __dict__: 526. を使うのに比べて、節約できるメモリ空間はかなり大き
いです。 属性探索のスピードもかなり向上できます。

 -- データ: object.__slots__

     このクラス変数には、インスタンスが用いる変数名を表す、文字列、イテ
     ラブル、または文字列のシーケンスを代入できます。'__slots__' は、各
     インスタンスに対して宣言された変数に必要な記憶領域を確保し、*note
     __dict__: 526. と '__weakref__' が自動的に生成されないようにします
     。
Notes on using '__slots__':

   * '__slots__' を持たないクラスから継承するとき、インスタンスの *note
     __dict__: 526. 属性と '__weakref__' 属性は常に利用可能です。

   * *note __dict__: 526. 変数がない場合、 '__slots__' に列挙されていな
     い新たな変数をインスタンスに代入することはできません。列挙されてい
     ない変数名を使って代入しようとした場合、 *note AttributeError: 326.
     が送出されます。新たな変数を動的に代入したいのなら、 '__slots__' を
     宣言する際に ‘'__dict__'’ を変数名のシーケンスに追加してください。

   * '__slots__' を定義しているクラスの各インスタンスに '__weakref__' 変
     数がない場合、インスタンスに対する弱参照 (*note weak references:
     fc.) はサポートされません。弱参照のサポートが必要なら、 '__slots__'
     を宣言する際に ‘'__weakref__'’ を変数名のシーケンスに追加してくださ
     い。

   * '__slots__' は、クラスのレベルで各変数に対する *note デスクリプタ:
     c1d. を使って実装されます。その結果、 '__slots__' に定義されている
     インスタンス変数のデフォルト値はクラス属性を使って設定できなくなっ
     ています; そうしないと、デスクリプタによる代入をクラス属性が上書き
     してしまうからです。

   * The action of a '__slots__' declaration is not limited to the class
     where it is defined.  '__slots__' declared in parents are available
     in child classes.  However, instances of a child subclass will get
     a *note __dict__: 526. and '__weakref__' unless the subclass also
     defines '__slots__' (which should only contain names of any
     'additional' slots).

   * あるクラスで、基底クラスですでに定義されているスロットを定義した場
     合、基底クラスのスロットで定義されているインスタンス変数は (デスク
     リプタを基底クラスから直接取得しない限り) アクセスできなくなります
     。これにより、プログラムの趣意が不定になってしまいます。将来は、こ
     の問題を避けるために何らかのチェックが追加されるかもしれません。

   * *note TypeError: 502. will be raised if nonempty '__slots__' are
     defined for a class derived from a *note "variable-length" built-in
     type: 1ed0. such as *note int: 238, *note bytes: 1a4, and *note
     tuple: 349.

   * Any non-string *note iterable: 10ad. may be assigned to
     '__slots__'.

   * If a *note dictionary: 237. is used to assign '__slots__', the
     dictionary keys will be used as the slot names.  The values of the
     dictionary can be used to provide per-attribute docstrings that
     will be recognised by *note inspect.getdoc(): 9c8. and displayed in
     the output of *note help(): 8a5.

   * *note __class__: 1452. assignment works only if both classes have
     the same '__slots__'.

   * 複数のスロットを持つ親クラスを使った *note 多重継承: 1c22. はできま
     すが、スロットで作成された属性を持つ親クラスは 1 つに限られます (他
     の基底クラスのスロットは空でなければなりません) - それに違反すると
     *note TypeError: 502. が送出されます。

   * もし '__slots__' に対して *note イテレータ: 191. を使用すると、イテ
     レータの値ごとに *note デスクリプタ: 1ed1. が作られます。しかし、
     '__slots__' 属性は空のイテレータとなります。


File: python.info,  Node: クラス生成をカスタマイズする,  Next: インスタンスのカスタマイズとサブクラスチェック,  Prev: 属性値アクセスをカスタマイズする,  Up: 特殊メソッド名

4.3.3.7 クラス生成をカスタマイズする
....................................

クラスが他のクラスを継承するときに必ず、親クラスの *note
__init_subclass__(): 5fd. が呼び出されます。これを利用すると、サブクラス
の挙動を変更するクラスを書くことができます。これは、クラスデコレータとと
ても良く似ていますが、クラスデコレータが、それが適用された特定のクラスに
のみに影響するのに対して、 ‘__init_subclass__’ は、もっぱら、このメソッ
ドを定義したクラスの将来のサブクラスに適用されます。

 -- メソッド: classmethod object.__init_subclass__ (cls)

     このメソッドは、それが定義されたクラスが継承された際に必ず呼び出さ
     れます。'cls' は新しいサブクラスです。もし、このメソッドがインスタ
     ンスメソッドとして定義されると、暗黙的にクラスメソッドに変換されま
     す。

     Keyword arguments which are given to a new class are passed to the
     parent class's ‘__init_subclass__’.  For compatibility with other
     classes using ‘__init_subclass__’, one should take out the needed
     keyword arguments and pass the others over to the base class, as
     in:

          class Philosopher:
              def __init_subclass__(cls, /, default_name, **kwargs):
                  super().__init_subclass__(**kwargs)
                  cls.default_name = default_name

          class AustralianPhilosopher(Philosopher, default_name="Bruce"):
              pass

     ‘object.__init_subclass__’ のデフォルト実装は何も行いませんが、何ら
     かの引数とともに呼び出された場合は、エラーを送出します。

          注釈: メタクラスのヒント ‘metaclass’ は残りの型機構によって消
          費され、 ‘__init_subclass__’ 実装に渡されることはありません。
          実際のメタクラス (明示的なヒントではなく) は、 ‘type(cls)’ と
          してアクセスできます。

     Added in version 3.6.

When a class is created, ‘type.__new__()’ scans the class variables and
makes callbacks to those with a *note __set_name__(): c1c. hook.

 -- メソッド: object.__set_name__ (self, owner, name)

     オーナーとなるクラス 'owner' が作成された時点で自動的に呼び出されま
     す。 オブジェクトはそのクラスの 'name' に割り当てられます。

          class A:
              x = C()  # Automatically calls: x.__set_name__(A, 'x')

     If the class variable is assigned after the class is created, *note
     __set_name__(): c1c. will not be called automatically.  If needed,
     *note __set_name__(): c1c. can be called directly:

          class A:
             pass

          c = C()
          A.x = c                  # The hook is not called
          c.__set_name__(A, 'x')   # Manually invoke the hook

     詳細は *note クラスオブジェクトの作成: c18. を参照してください。

     Added in version 3.6.

* Menu:

* メタクラス::
* MRO エントリの解決::
* 適切なメタクラスの決定::
* クラスの名前空間の準備::
* クラス本体の実行::
* クラスオブジェクトの作成::
* メタクラスの用途::


File: python.info,  Node: メタクラス,  Next: MRO エントリの解決,  Up: クラス生成をカスタマイズする

4.3.3.8 メタクラス
..................

デフォルトでは、クラスは *note type(): d16. を使って構築されます。 クラ
ス本体は新しい名前空間で実行され、クラス名が ‘type(name, bases,
namespace)’ の結果にローカルに束縛されます。

クラス生成プロセスはカスタマイズできます。 そのためにはクラス定義行で
‘metaclass’ キーワード引数を渡すか、そのような引数を定義行に含む既存のク
ラスを継承します。 次の例で ‘MyClass’ と ‘MySubclass’ は両方とも ‘Meta’
のインスタンスです:

     class Meta(type):
         pass

     class MyClass(metaclass=Meta):
         pass

     class MySubclass(MyClass):
         pass

クラス定義の中で指定された他のキーワード引数は、後述するすべてのメタクラ
ス操作に渡されます。

クラス定義が実行される際に、以下のステップが生じます:

   * MRO エントリの解決が行われる;

   * 適切なメタクラスが決定される;

   * クラスの名前空間が準備される;

   * クラスの本体が実行される;

   * クラスオブジェクトが作られる。


File: python.info,  Node: MRO エントリの解決,  Next: 適切なメタクラスの決定,  Prev: メタクラス,  Up: クラス生成をカスタマイズする

4.3.3.9 MRO エントリの解決
..........................

 -- メソッド: object.__mro_entries__ (self, bases)

     If a base that appears in a class definition is not an instance of
     *note type: d16, then an ‘__mro_entries__()’ method is searched on
     the base.  If an ‘__mro_entries__()’ method is found, the base is
     substituted with the result of a call to ‘__mro_entries__()’ when
     creating the class.  The method is called with the original bases
     tuple passed to the 'bases' parameter, and must return a tuple of
     classes that will be used instead of the base.  The returned tuple
     may be empty: in these cases, the original base is ignored.

参考
....

*note types.resolve_bases(): b6a.

     Dynamically resolve bases that are not instances of *note type:
     d16.

*note types.get_original_bases(): 49a.

     Retrieve a class's "original bases" prior to modifications by *note
     __mro_entries__(): 1ed6.

PEP 560(1)

     Core support for typing module and generic types.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0560/


File: python.info,  Node: 適切なメタクラスの決定,  Next: クラスの名前空間の準備,  Prev: MRO エントリの解決,  Up: クラス生成をカスタマイズする

4.3.3.10 適切なメタクラスの決定
...............................

クラス定義に対して適切なメタクラスは、以下のように決定されます:

   * 基底も明示的なメタクラスも与えられていない場合は、 *note type():
     d16. が使われます;

   * 明示的なメタクラスが与えられていて、それが *note type(): d16. のイ
     ンスタンス 'ではない' 場合、それをメタクラスとして直接使います;

   * 明示的なメタクラスとして *note type(): d16. のインスタンスが与えら
     れたか、基底が定義されていた場合は、最も派生した (継承関係で最も下
     の) メタクラスが使われます。

最も派生的なメタクラスは、(もしあれば) 明示的に指定されたメタクラスと、
指定されたすべてのベースクラスのメタクラスから選ばれます。最も派生的なメ
タクラスは、これらのメタクラス候補のすべてのサブタイプであるようなもので
す。メタクラス候補のどれもその基準を満たさなければ、クラス定義は
‘TypeError’ で失敗します。


File: python.info,  Node: クラスの名前空間の準備,  Next: クラス本体の実行,  Prev: 適切なメタクラスの決定,  Up: クラス生成をカスタマイズする

4.3.3.11 クラスの名前空間の準備
...............................

適切なメタクラスが指定されると、クラスの名前空間が用意されます。もしメタ
クラスが ‘__prepare__’ 属性を持っている場合、 ‘namespace =
metaclass.__prepare__(name, bases, **kwds)’ が呼ばれます。追加のキーワー
ド引数は、もしクラス定義にあれば設定されます。 ‘__prepare__’ メソッドは
*note クラスメソッド: 14c. として実装する必要があります。 ‘__prepare__’
が作成して返した名前空間は ‘__new__’ に渡されますが、最終的なクラスオブ
ジェクトは新しい ‘dict’ にコピーして作成されます。

メタクラスに ‘__prepare__’ 属性がない場合、クラスの名前空間は空の 順序付
きマッピングとして初期化されます。

参考
....

PEP 3115(1) - Metaclasses in Python 3000

     ‘__prepare__’ 名前空間フックの導入

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3115/


File: python.info,  Node: クラス本体の実行,  Next: クラスオブジェクトの作成,  Prev: クラスの名前空間の準備,  Up: クラス生成をカスタマイズする

4.3.3.12 クラス本体の実行
.........................

クラス本体が (大まかには) ‘exec(body, globals(), namespace)’ として実行
されます。通常の呼び出しと *note exec(): 164. の重要な違いは、クラス定義
が関数内部で行われる場合、レキシカルスコープによってクラス本体 (任意のメ
ソッドを含む) が現在のスコープと外側のスコープから名前を参照できるという
点です。

しかし、クラス定義が関数内部で行われる時でさえ、クラス内部で定義されたメ
ソッドはクラススコープで定義された名前を見ることはできません。クラス変数
はインスタンスメソッドかクラスメソッドの最初のパラメータからアクセスする
か、次の節で説明する、暗黙的に静的スコープが切られている ‘__class__’ 参
照からアクセスしなければなりません。


File: python.info,  Node: クラスオブジェクトの作成,  Next: メタクラスの用途,  Prev: クラス本体の実行,  Up: クラス生成をカスタマイズする

4.3.3.13 クラスオブジェクトの作成
.................................

クラス本体の実行によってクラスの名前空間が初期化されたら、
‘metaclass(name, bases, namespace, **kwds)’ を呼び出すことでクラスオブジ
ェクトが作成されます (ここで渡される追加のキーワードは ‘__prepare__’ に
渡されるものと同じです)。

このクラスオブジェクトは、 *note super(): 4a8. の無引数形式によって参照
されるものです。 ‘__class__’ は、クラス本体中のメソッドが ‘__class__’ ま
たは ‘super’ のいずれかを参照している場合に、コンパイラによって作成され
る暗黙のクロージャー参照です。これは、メソッドに渡された最初の引数に基づ
いて現在の呼び出しを行うために使用されるクラスまたはインスタンスが識別さ
れる一方、 *note super(): 4a8. の無引数形式がレキシカルスコープに基づい
て定義されているクラスを正確に識別することを可能にします。

'CPython 実装の詳細:' CPython 3.6 以降では、 ‘__class__’ セルは、クラス
名前空間にある ‘__classcell__’ エントリーとしてメタクラスに渡されます。
‘__class__’ セルが存在していた場合は、そのクラスが正しく初期化されるため
に、 ‘type.__new__’ の呼び出しに到達するまで上に伝搬されます。 失敗した
場合は、Python 3.8 では *note RuntimeError: 17a. になります。

デフォルトのメタクラス *note type: d16. や最終的には ‘type.__new__’ を呼
び出すメタクラスを使っているときは、クラスオブジェクトを作成した後に次の
カスタム化の手順が起動されます:

  1. ‘type.__new__’ メソッドが *note __set_name__(): c1c. が定義されてい
     るクラスの名前空間にある全ての属性を収集します;

  2. それらの ‘__set_name__’ メソッドが、そのメソッドが定義されているク
     ラス、およびそこに属する属性に割り当てられている名前を引数として呼
     び出されます;

  3. 新しいクラスのメソッド解決順序ですぐ上に位置する親クラスで *note
     __init_subclass__(): 5fd. フックが呼び出されます。

クラスオブジェクトが作成された後には、クラス定義に含まれているクラスデコ
レータ (もしあれば) にクラスオブジェクトが渡され、デコレータが返すオブジ
ェクトがここで定義されたクラスとしてローカルの名前空間に束縛されます。

When a new class is created by ‘type.__new__’, the object provided as
the namespace parameter is copied to a new ordered mapping and the
original object is discarded.  The new copy is wrapped in a read-only
proxy, which becomes the *note __dict__: c2b. attribute of the class
object.

参考
....

PEP 3135(1) - New super

     暗黙の ‘__class__’ クロージャ参照について記述しています

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3135/


File: python.info,  Node: メタクラスの用途,  Prev: クラスオブジェクトの作成,  Up: クラス生成をカスタマイズする

4.3.3.14 メタクラスの用途
.........................

メタクラスは限りない潜在的利用価値を持っています。これまで試されてきたア
イデアには、列挙型、ログ記録、インターフェースのチェック、 自動デリゲー
ション、自動プロパティ生成、プロキシ、フレームワーク、そして自動リソース
ロック／同期といったものがあります。


File: python.info,  Node: インスタンスのカスタマイズとサブクラスチェック,  Next: ジェネリック型をエミュレートする,  Prev: クラス生成をカスタマイズする,  Up: 特殊メソッド名

4.3.3.15 インスタンスのカスタマイズとサブクラスチェック
.......................................................

以下のメソッドは組み込み関数 *note isinstance(): 40e. と *note
issubclass(): 78c. のデフォルトの動作を上書きするのに利用します。

特に、 *note abc.ABCMeta: ee4. メタクラスは、抽象基底クラス (ABCs) を"仮
想基底クラス (virtual base classes)" として、他の ABC を含む、任意のクラ
スや (組み込み型を含む) 型に追加するために、これらのメソッドを実装してい
ます。

 -- メソッド: type.__instancecheck__ (self, instance)

     'instance' が (直接、または間接的に) 'class' のインスタンスと考えら
     れる場合に true を返します。定義されていれば、
     ‘isinstance(instance, class)’ の実装のために呼び出されます。

 -- メソッド: type.__subclasscheck__ (self, subclass)

     'subclass' が (直接、または間接的に) 'class' のサブクラスと考えられ
     る場合に true を返します。定義されていれば、 ‘issubclass(subclass,
     class)’ の実装のために呼び出されます。

なお、これらのメソッドは、クラスの型 (メタクラス) 上で検索されます。実際
のクラスにクラスメソッドとして定義することはできません。これは、インスタ
ンスそれ自体がクラスであるこの場合にのみ、インスタンスに呼び出される特殊
メソッドの検索と一貫しています。

参考
....

PEP 3119(1) - 抽象基底クラスの導入

     Includes the specification for customizing *note isinstance(): 40e.
     and *note issubclass(): 78c. behavior through *note
     __instancecheck__(): 1edd. and *note __subclasscheck__(): 1ede,
     with motivation for this functionality in the context of adding
     Abstract Base Classes (see the *note abc: 4. module) to the
     language.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3119/


File: python.info,  Node: ジェネリック型をエミュレートする,  Next: 呼び出し可能オブジェクトをエミュレートする,  Prev: インスタンスのカスタマイズとサブクラスチェック,  Up: 特殊メソッド名

4.3.3.16 ジェネリック型をエミュレートする
.........................................

When using *note type annotations: 424, it is often useful to
'parameterize' a *note generic type: 405. using Python's square-brackets
notation.  For example, the annotation ‘list[int]’ might be used to
signify a *note list: 5dc. in which all the elements are of type *note
int: 238.

参考
....

PEP 484(1) - 型ヒント

     Introducing Python's framework for type annotations

*note Generic Alias Types: 67e.

     Documentation for objects representing parameterized generic
     classes

*note ジェネリクス: 1ee0, *note user-defined generics: 49b. and *note typing.Generic: 157c.

     実行時にパラメータ設定が可能であり、かつ静的な型チェッカーが理解で
     きるジェネリッククラスを実装する方法のドキュメントです。

A class can 'generally' only be parameterized if it defines the special
class method ‘__class_getitem__()’.

 -- メソッド: classmethod object.__class_getitem__ (cls, key)

     'key' にある型引数で特殊化されたジェネリッククラスを表すオブジェク
     トを返します。

     When defined on a class, ‘__class_getitem__()’ is automatically a
     class method.  As such, there is no need for it to be decorated
     with *note @classmethod: 14c. when it is defined.

* Menu:

* The purpose of __class_getitem__::
* __class_getitem__ versus __getitem__::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/


File: python.info,  Node: The purpose of __class_getitem__,  Next: __class_getitem__ versus __getitem__,  Up: ジェネリック型をエミュレートする

4.3.3.17 The purpose of '__class_getitem__'
...........................................

The purpose of *note __class_getitem__(): 706. is to allow runtime
parameterization of standard-library generic classes in order to more
easily apply *note type hints: 1ee2. to these classes.

To implement custom generic classes that can be parameterized at runtime
and understood by static type-checkers, users should either inherit from
a standard library class that already implements *note
__class_getitem__(): 706, or inherit from *note typing.Generic: 157c,
which has its own implementation of ‘__class_getitem__()’.

Custom implementations of *note __class_getitem__(): 706. on classes
defined outside of the standard library may not be understood by
third-party type-checkers such as mypy.  Using ‘__class_getitem__()’ on
any class for purposes other than type hinting is discouraged.


File: python.info,  Node: __class_getitem__ versus __getitem__,  Prev: The purpose of __class_getitem__,  Up: ジェネリック型をエミュレートする

4.3.3.18 '__class_getitem__' versus '__getitem__'
.................................................

Usually, the *note subscription: 1ee5. of an object using square
brackets will call the *note __getitem__(): 264. instance method defined
on the object's class.  However, if the object being subscribed is
itself a class, the class method *note __class_getitem__(): 706. may be
called instead.  ‘__class_getitem__()’ should return a *note
GenericAlias: 67e. object if it is properly defined.

Presented with the *note expression: 1ee6. ‘obj[x]’, the Python
interpreter follows something like the following process to decide
whether *note __getitem__(): 264. or *note __class_getitem__(): 706.
should be called:

     from inspect import isclass

     def subscribe(obj, x):
         """Return the result of the expression 'obj[x]'"""

         class_of_obj = type(obj)

         # If the class of obj defines __getitem__,
         # call class_of_obj.__getitem__(obj, x)
         if hasattr(class_of_obj, '__getitem__'):
             return class_of_obj.__getitem__(obj, x)

         # Else, if obj is a class and defines __class_getitem__,
         # call obj.__class_getitem__(x)
         elif isclass(obj) and hasattr(obj, '__class_getitem__'):
             return obj.__class_getitem__(x)

         # Else, raise an exception
         else:
             raise TypeError(
                 f"'{class_of_obj.__name__}' object is not subscriptable"
             )

In Python, all classes are themselves instances of other classes.  The
class of a class is known as that class's *note metaclass: 1ee7, and
most classes have the *note type: d16. class as their metaclass.  *note
type: d16. does not define *note __getitem__(): 264, meaning that
expressions such as ‘list[int]’, ‘dict[str, float]’ and ‘tuple[str,
bytes]’ all result in *note __class_getitem__(): 706. being called:

     >>> # list has class "type" as its metaclass, like most classes:
     >>> type(list)
     <class 'type'>
     >>> type(dict) == type(list) == type(tuple) == type(str) == type(bytes)
     True
     >>> # "list[int]" calls "list.__class_getitem__(int)"
     >>> list[int]
     list[int]
     >>> # list.__class_getitem__ returns a GenericAlias object:
     >>> type(list[int])
     <class 'types.GenericAlias'>

However, if a class has a custom metaclass that defines *note
__getitem__(): 264, subscribing the class may result in different
behaviour.  An example of this can be found in the *note enum: 4c.
module:

     >>> from enum import Enum
     >>> class Menu(Enum):
     ...     """A breakfast menu"""
     ...     SPAM = 'spam'
     ...     BACON = 'bacon'
     ...
     >>> # Enum classes have a custom metaclass:
     >>> type(Menu)
     <class 'enum.EnumMeta'>
     >>> # EnumMeta defines __getitem__,
     >>> # so __class_getitem__ is not called,
     >>> # and the result is not a GenericAlias object:
     >>> Menu['SPAM']
     <Menu.SPAM: 'spam'>
     >>> type(Menu['SPAM'])
     <enum 'Menu'>

参考
....

PEP 560(1) - typing モジュールとジェネリック型に対する言語コアによるサポート

     Introducing *note __class_getitem__(): 706, and outlining when a
     *note subscription: 1ee5. results in ‘__class_getitem__()’ being
     called instead of *note __getitem__(): 264.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0560/


File: python.info,  Node: 呼び出し可能オブジェクトをエミュレートする,  Next: コンテナをエミュレートする,  Prev: ジェネリック型をエミュレートする,  Up: 特殊メソッド名

4.3.3.19 呼び出し可能オブジェクトをエミュレートする
...................................................

 -- メソッド: object.__call__ (self[, args...])

     Called when the instance is "called" as a function; if this method
     is defined, ‘x(arg1, arg2, ...)’ roughly translates to
     ‘type(x).__call__(x, arg1, ...)’.  The *note object: a5a. class
     itself does not provide this method.


File: python.info,  Node: コンテナをエミュレートする,  Next: 数値型をエミュレートする,  Prev: 呼び出し可能オブジェクトをエミュレートする,  Up: 特殊メソッド名

4.3.3.20 コンテナをエミュレートする
...................................

The following methods can be defined to implement container objects.
None of them are provided by the *note object: a5a. class itself.
Containers usually are *note sequences: 4be. (such as *note lists: 5dc.
or *note tuples: 349.) or *note mappings: 118c. (like *note
dictionaries: 1eec.), but can represent other containers as well.  The
first set of methods is used either to emulate a sequence or to emulate
a mapping; the difference is that for a sequence, the allowable keys
should be the integers 'k' for which ‘0 <= k < N’ where 'N' is the
length of the sequence, or *note slice: 436. objects, which define a
range of items.  It is also recommended that mappings provide the
methods ‘keys()’, ‘values()’, ‘items()’, ‘get()’, ‘clear()’,
‘setdefault()’, ‘pop()’, ‘popitem()’, ‘copy()’, and ‘update()’ behaving
similar to those for Python's standard *note dictionary: 237. objects.
The *note collections.abc: 17. module provides a *note MutableMapping:
107e. *note abstract base class: 1186. to help create those methods from
a base set of *note __getitem__(): 264, *note __setitem__(): 146e, *note
__delitem__(): 146f, and ‘keys()’.  Mutable sequences should provide
methods ‘append()’, ‘count()’, ‘index()’, ‘extend()’, ‘insert()’,
‘pop()’, ‘remove()’, ‘reverse()’ and ‘sort()’, like Python standard
*note list: 5dc. objects.  Finally, sequence types should implement
addition (meaning concatenation) and multiplication (meaning repetition)
by defining the methods *note __add__(): 1eed, *note __radd__(): 1eee,
*note __iadd__(): 1eef, *note __mul__(): 1ef0, *note __rmul__(): 1ef1.
and *note __imul__(): 1ef2. described below; they should not define
other numerical operators.  It is recommended that both mappings and
sequences implement the *note __contains__(): 1ebe. method to allow
efficient use of the ‘in’ operator; for mappings, ‘in’ should search the
mapping's keys; for sequences, it should search through the values.  It
is further recommended that both mappings and sequences implement the
*note __iter__(): 1ebc. method to allow efficient iteration through the
container; for mappings, ‘__iter__()’ should iterate through the
object's keys; for sequences, it should iterate through the values.

 -- メソッド: object.__len__ (self)

     Called to implement the built-in function *note len(): 5fa.  Should
     return the length of the object, an integer ‘>=’ 0.  Also, an
     object that doesn't define a *note __bool__(): 12a3. method and
     whose ‘__len__()’ method returns zero is considered to be false in
     a Boolean context.

     'CPython 実装の詳細:' In CPython, the length is required to be at
     most *note sys.maxsize: 1195.  If the length is larger than
     ‘sys.maxsize’ some features (such as *note len(): 5fa.) may raise
     *note OverflowError: 84e.  To prevent raising ‘OverflowError’ by
     truth value testing, an object must define a *note __bool__():
     12a3. method.

 -- メソッド: object.__length_hint__ (self)

     Called to implement *note operator.length_hint(): f3a.  Should
     return an estimated length for the object (which may be greater or
     less than the actual length).  The length must be an integer ‘>=’
     0.  The return value may also be *note NotImplemented: 79d, which
     is treated the same as if the ‘__length_hint__’ method didn't exist
     at all.  This method is purely an optimization and is never
     required for correctness.

     Added in version 3.4.

     注釈: スライシングは、以下の 3 メソッドによって排他的に行われます。
     次のような呼び出しは

          a[1:2] = b

     次のように翻訳され

          a[slice(1, 2, None)] = b

     以下も同様です。存在しないスライスの要素は ‘None’ で埋められます。

 -- メソッド: object.__getitem__ (self, key)

     Called to implement evaluation of ‘self[key]’.  For *note sequence:
     4be. types, the accepted keys should be integers.  Optionally, they
     may support *note slice: 436. objects as well.  Negative index
     support is also optional.  If 'key' is of an inappropriate type,
     *note TypeError: 502. may be raised; if 'key' is a value outside
     the set of indexes for the sequence (after any special
     interpretation of negative values), *note IndexError: 14de. should
     be raised.  For *note mapping: 118c. types, if 'key' is missing
     (not in the container), *note KeyError: 31d. should be raised.

          注釈: *note for: 2c9. ループでは、シーケンスの終端を正しく検出
          できるようにするために、不正なインデクスに対して *note
          IndexError: 14de. が送出されるものと期待しています。

          注釈: When *note subscripting: 1ee5. a 'class', the special
          class method *note __class_getitem__(): 706. may be called
          instead of ‘__getitem__()’.  See *note __class_getitem__
          versus __getitem__: 1ee4. for more details.

 -- メソッド: object.__setitem__ (self, key, value)

     ‘self[key]’ に対する代入を実装するために呼び出されます。 *note
     __getitem__(): 264. と同じ注意事項があてはまります。このメソッドを
     実装できるのは、あるキーに対する値の変更をサポートしているか、新た
     なキーを追加できるようなマップの場合と、ある要素を置き換えることが
     できるシーケンスの場合だけです。不正な 'key' に対しては、 *note
     __getitem__(): 264. メソッドと同様の例外の送出を行わなければなりま
     せん。

 -- メソッド: object.__delitem__ (self, key)

     ‘self[key]’ の削除を実装するために呼び出されます。 *note
     __getitem__(): 264. と同じ注意事項があてはまります。このメソッドを
     実装できるのは、キーの削除をサポートしているマップの場合と、要素を
     削除できるシーケンスの場合だけです。不正な 'key' に対しては、 *note
     __getitem__(): 264. メソッドと同様の例外の送出を行わなければなりま
     せん。

 -- メソッド: object.__missing__ (self, key)

     ‘self[key]’ の実装において辞書内にキーが存在しなかった場合に、 dict
     のサブクラスのために *note dict: 237.*note __getitem__(): 264. によ
     って呼び出されます。

 -- メソッド: object.__iter__ (self)

     このメソッドは、コンテナに対して *note イテレータ: 191. が要求され
     た際に呼び出されます。このメソッドは、コンテナ内の全てのオブジェク
     トに渡って反復処理できるような、新たなイテレータオブジェクトを返さ
     なければなりません。マッピングでは、コンテナ内のキーに渡って反復処
     理しなければなりません。

 -- メソッド: object.__reversed__ (self)

     *note reversed(): 831. 組み込み関数が逆方向イテレーションを実装する
     ために、(存在すれば)呼び出します。コンテナ内の全要素を逆順にイテレ
     ートする、新しいイテレータを返すべきです。

     *note __reversed__(): 1ebd. メソッドが定義されていない場合、 *note
     reversed(): 831. 組込み関数は sequence プロトコル (*note __len__():
     1ec3. と *note __getitem__(): 264.) を使った方法にフォールバックし
     ます。 sequence プロトコルをサポートしたオブジェクトは、 *note
     reversed(): 831. よりも効率のいい実装を提供できる場合にのみ *note
     __reversed__(): 1ebd. を定義するべきです。

帰属テスト演算子 (*note in: 2cb. および *note not in: 5fb.) は通常、コン
テナの要素に対する反復処理のように実装されます。しかし、コンテナオブジェ
クトで以下の特殊メソッドを定義して、より効率的な実装を行ったり、オブジェ
クトがイテラブルでなくてもよいようにできます。

 -- メソッド: object.__contains__ (self, item)

     帰属テスト演算を実装するために呼び出されます。 'item' が 'self' 内
     に存在する場合には真を、そうでない場合には偽を返さなければなりませ
     ん。マップオブジェクトの場合、値やキーと値の組ではなく、キーに対す
     る帰属テストを考えなければなりません。

     *note __contains__(): 1ebe. を定義しないオブジェクトに対しては、メ
     ンバシップテストはまず、 *note __iter__(): 1ebc. を使った反復を試み
     ます、次に古いシーケンス反復プロトコル *note __getitem__(): 264. を
     使います、 *note 言語レファレンスのこの節: 1ef4. を参照して下さい。


File: python.info,  Node: 数値型をエミュレートする,  Next: with文とコンテキストマネージャ,  Prev: コンテナをエミュレートする,  Up: 特殊メソッド名

4.3.3.21 数値型をエミュレートする
.................................

以下のメソッドを定義して、数値型オブジェクトをエミュレートすることができ
ます。特定の種類の数値型ではサポートされていないような演算に対応するメソ
ッド (非整数の数値に対するビット単位演算など) は、未定義のままにしておか
なければなりません。

 -- メソッド: object.__add__ (self, other)
 -- メソッド: object.__sub__ (self, other)
 -- メソッド: object.__mul__ (self, other)
 -- メソッド: object.__matmul__ (self, other)
 -- メソッド: object.__truediv__ (self, other)
 -- メソッド: object.__floordiv__ (self, other)
 -- メソッド: object.__mod__ (self, other)
 -- メソッド: object.__divmod__ (self, other)
 -- メソッド: object.__pow__ (self, other[, modulo])
 -- メソッド: object.__lshift__ (self, other)
 -- メソッド: object.__rshift__ (self, other)
 -- メソッド: object.__and__ (self, other)
 -- メソッド: object.__xor__ (self, other)
 -- メソッド: object.__or__ (self, other)

     これらのメソッドを呼んで二項算術演算子 (‘+’, ‘-’, ‘*’, ‘@’, ‘/’,
     ‘//’, ‘%’, *note divmod(): 96f, *note pow(): 9a0, ‘**’, ‘<<’, ‘>>’,
     ‘&’, ‘^’, ‘|’) を実装します。 例えば 'x' が *note __add__(): 1eed.
     メソッドのあるクラスのインスタンスである場合、式 ‘x + y’ を評価する
     と ‘type(x).__add__(x, y)’ が呼ばれます。 *note __divmod__(): 1efa.
     メソッドは *note __floordiv__(): 149d. と *note __mod__(): 1ef9. を
     使用するのと等価でなければなりません。 *note __truediv__(): 149c. と
     関連してはなりません。 組み込みの *note pow(): 9a0. 関数の三項のも
     のがサポートされていなければならない場合、 *note __pow__(): 79e. は
     オプションの第三引数を受け取るものとして定義されなければなりません
     。

     If one of those methods does not support the operation with the
     supplied arguments, it should return *note NotImplemented: 79d.

 -- メソッド: object.__radd__ (self, other)
 -- メソッド: object.__rsub__ (self, other)
 -- メソッド: object.__rmul__ (self, other)
 -- メソッド: object.__rmatmul__ (self, other)
 -- メソッド: object.__rtruediv__ (self, other)
 -- メソッド: object.__rfloordiv__ (self, other)
 -- メソッド: object.__rmod__ (self, other)
 -- メソッド: object.__rdivmod__ (self, other)
 -- メソッド: object.__rpow__ (self, other[, modulo])
 -- メソッド: object.__rlshift__ (self, other)
 -- メソッド: object.__rrshift__ (self, other)
 -- メソッド: object.__rand__ (self, other)
 -- メソッド: object.__rxor__ (self, other)
 -- メソッド: object.__ror__ (self, other)

     These methods are called to implement the binary arithmetic
     operations (‘+’, ‘-’, ‘*’, ‘@’, ‘/’, ‘//’, ‘%’, *note divmod():
     96f, *note pow(): 9a0, ‘**’, ‘<<’, ‘>>’, ‘&’, ‘^’, ‘|’) with
     reflected (swapped) operands.  These functions are only called if
     the left operand does not support the corresponding operation (1)
     and the operands are of different types.  (2)  For instance, to
     evaluate the expression ‘x - y’, where 'y' is an instance of a
     class that has an *note __rsub__(): 1f00. method,
     ‘type(y).__rsub__(y, x)’ is called if ‘type(x).__sub__(x, y)’
     returns *note NotImplemented: 79d.

     ただし、三項演算子 *note pow(): 9a0. が *note __rpow__(): 79f. を呼
     ぶことはないので注意してください (型強制の規則が非常に難解になるか
     らです)。

          注釈: 右側の被演算子の型が左側の被演算子の型のサブクラスであり
          、このサブクラスであるメソッドに対する反射メソッドと異なる実装
          が定義されている場合には、左側の被演算子の非反射メソッドが呼ば
          れる前に、このメソッドが呼ばれます。この振る舞いにより、サブク
          ラスが親の演算をオーバーライドすることが可能になります。

 -- メソッド: object.__iadd__ (self, other)
 -- メソッド: object.__isub__ (self, other)
 -- メソッド: object.__imul__ (self, other)
 -- メソッド: object.__imatmul__ (self, other)
 -- メソッド: object.__itruediv__ (self, other)
 -- メソッド: object.__ifloordiv__ (self, other)
 -- メソッド: object.__imod__ (self, other)
 -- メソッド: object.__ipow__ (self, other[, modulo])
 -- メソッド: object.__ilshift__ (self, other)
 -- メソッド: object.__irshift__ (self, other)
 -- メソッド: object.__iand__ (self, other)
 -- メソッド: object.__ixor__ (self, other)
 -- メソッド: object.__ior__ (self, other)

     These methods are called to implement the augmented arithmetic
     assignments (‘+=’, ‘-=’, ‘*=’, ‘@=’, ‘/=’, ‘//=’, ‘%=’, ‘**=’,
     ‘<<=’, ‘>>=’, ‘&=’, ‘^=’, ‘|=’).  These methods should attempt to
     do the operation in-place (modifying 'self') and return the result
     (which could be, but does not have to be, 'self').  If a specific
     method is not defined, or if that method returns *note
     NotImplemented: 79d, the augmented assignment falls back to the
     normal methods.  For instance, if 'x' is an instance of a class
     with an *note __iadd__(): 1eef. method, ‘x += y’ is equivalent to
     ‘x = x.__iadd__(y)’ .  If *note __iadd__(): 1eef. does not exist,
     or if ‘x.__iadd__(y)’ returns ‘NotImplemented’, ‘x.__add__(y)’ and
     ‘y.__radd__(x)’ are considered, as with the evaluation of ‘x + y’.
     In certain situations, augmented assignment can result in
     unexpected errors (see *note なぜ加算はされるのに a_tuple[i] +=
     ['item'] は例外を送出するのですか?: 1f15.), but this behavior is in
     fact part of the data model.

 -- メソッド: object.__neg__ (self)
 -- メソッド: object.__pos__ (self)
 -- メソッド: object.__abs__ (self)
 -- メソッド: object.__invert__ (self)

     呼び出して単項算術演算 (‘-’, ‘+’, *note abs(): 1c0e. および ‘~’) を
     実装します。

 -- メソッド: object.__complex__ (self)
 -- メソッド: object.__int__ (self)
 -- メソッド: object.__float__ (self)

     組み込み関数の *note complex(): 2cf, *note int(): 238, *note
     float(): 2ce. の実装から呼び出されます。 適切な型の値を返さなければ
     なりません。

 -- メソッド: object.__index__ (self)

     呼び出して *note operator.index(): 1879. を実装します。 Python が数
     値オブジェクトを整数オブジェクトに損失なく変換する必要がある場合 (た
     とえばスライシングや、組み込みの *note bin(): 127a. 、 *note hex():
     129d. 、 *note oct(): 129c. 関数) は常に呼び出されます。 このメソッ
     ドがあるとその数値オブジェクトが整数型であることが示唆されます。 整
     数を返さなければなりません。

     もし *note __int__(): 6e7, *note __float__(): 99a, *note
     __complex__(): 5b1. が定義されていない場合、組み込み関数の *note
     int(): 238, *note float(): 2ce, *note complex(): 2cf. は *note
     __index__(): 6e8. にフォールバックします。

 -- メソッド: object.__round__ (self[, ndigits])
 -- メソッド: object.__trunc__ (self)
 -- メソッド: object.__floor__ (self)
 -- メソッド: object.__ceil__ (self)

     組み込み関数の *note round(): 12a8. と *note math: 81. モジュール関
     数の *note trunc(): 136b, *note floor(): 1369, *note ceil(): 136a.
     の実装から呼び出されます。 'ndigits' が ‘__round__()’ に渡されない
     限りは、これらの全てのメソッドは *note Integral: 1f1d. (たいていは
     *note int: 238.) に切り詰められたオブジェクトの値を返すべきです。

     The built-in function *note int(): 238. falls back to *note
     __trunc__(): 6e6. if neither *note __int__(): 6e7. nor *note
     __index__(): 6e8. is defined.

     バージョン 3.11 で変更: *note int(): 238. の *note __trunc__():
     6e6. への処理の委譲は非推奨になりました。

   ---------- Footnotes ----------

   (1) "Does not support" here means that the class has no such method,
or the method returns *note NotImplemented: 79d.  Do not set the method
to ‘None’ if you want to force fallback to the right operand's reflected
method—that will instead have the opposite effect of explicitly
'blocking' such fallback.

   (2) 同じ型の被演算子については、無反転のメソッド (たとえば *note
__add__(): 1eed.) が失敗した場合、その演算はサポートされていないとみなさ
れます。これは、反射したメソッドが呼び出されない理由です。


File: python.info,  Node: with文とコンテキストマネージャ,  Next: クラスパターンマッチの位置引数のカスタマイズ,  Prev: 数値型をエミュレートする,  Up: 特殊メソッド名

4.3.3.22 with文とコンテキストマネージャ
.......................................

コンテキストマネージャ('context manager') とは、 *note with: 59c. 文の実
行時にランタイムコンテキストを定義するオブジェクトです。コンテキストマネ
ージャは、コードブロックを実行するために必要な入り口および出口の処理を扱
います。コンテキストマネージャは通常、 ‘with’ 文（ *note with 文: 59c. の
章を参照）により起動されますが、これらのメソッドを直接呼び出すことで起動
することもできます。

コンテキストマネージャの代表的な使い方としては、様々なグローバル情報の保
存および更新、リソースのロックとアンロック、ファイルのオープンとクローズ
などが挙げられます。

For more information on context managers, see *note
コンテキストマネージャ型: 1f20.  The *note object: a5a. class itself
does not provide the context manager methods.

 -- メソッド: object.__enter__ (self)

     コンテキストマネージャのの入り口で実行される処理です。 *note with:
     59c. 文は、文の ‘as’ 節で規定された値を返すこのメソッドを呼び出しま
     す。

 -- メソッド: object.__exit__ (self, exc_type, exc_value, traceback)

     コンテキストマネージャの出口で実行される処理です。パラメータは、コ
     ンテキストが終了した原因となった例外について説明しています。コンテ
     キストが例外を送出せず終了した場合は、全ての引き数に *note None:
     641. が設定されます。

     もし、例外が送出され、かつメソッドが例外を抑制したい場合（すなわち
     、例外が伝播されるのを防ぎたい場合）、このメソッドは True を返す必
     要があります。そうでなければ、このメソッドの終了後、例外は通常通り
     伝播することになります。

     Note that *note __exit__(): 12ce. methods should not reraise the
     passed-in exception; this is the caller's responsibility.

参考
....

PEP 343(1) - "with" ステートメント

     Python の *note with: 59c. 文の仕様、背景、および例が記載されていま
     す。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0343/


File: python.info,  Node: クラスパターンマッチの位置引数のカスタマイズ,  Next: Emulating buffer types,  Prev: with文とコンテキストマネージャ,  Up: 特殊メソッド名

4.3.3.23 クラスパターンマッチの位置引数のカスタマイズ
.....................................................

パターンの中でクラス名を利用する場合、位置引数はデフォルトでは利用できま
せん。 ‘MyClass’ で特別なサポートがないと、 ‘case MyClass(x, y)’ は通常
無効です。このようなパターンを利用するには、 '__match_args__' 属性をクラ
スに定義する必要があります。

 -- データ: object.__match_args__

     このクラス変数には文字列のタプルがアサイン可能です。このクラスがク
     ラスパターンの位置引数の中で利用されると、それぞれの位置引数は対応
     する '__match_args__' の中の値をキーワードとする、キーワード引数に
     変換されます。この属性がない時は、 ‘()’ が設定されているのと同義で
     す。

例えば、もし ‘MyClass.__match_args__’ に ‘("left", "center", "right")’ が
定義されていた場合、 ‘case MyClass(x, y)’ は ‘case MyClass(left=x,
center=y)’ と同義です。パターンの引数の数は、 '__match_args__' の要素数
と同等かそれ以下でなければならない点に注意してください。もし、多かった場
合には、パターンマッチは *note TypeError: 502. を送出します。

Added in version 3.10.

参考
....

PEP 634(1) - 構造的パターンマッチ

     ‘match’ 文の詳細。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0634/


File: python.info,  Node: Emulating buffer types,  Next: 特殊メソッド検索,  Prev: クラスパターンマッチの位置引数のカスタマイズ,  Up: 特殊メソッド名

4.3.3.24 Emulating buffer types
...............................

The *note buffer protocol: 371. provides a way for Python objects to
expose efficient access to a low-level memory array.  This protocol is
implemented by builtin types such as *note bytes: 1a4. and *note
memoryview: 435, and third-party libraries may define additional buffer
types.

While buffer types are usually implemented in C, it is also possible to
implement the protocol in Python.

 -- メソッド: object.__buffer__ (self, flags)

     Called when a buffer is requested from 'self' (for example, by the
     *note memoryview: 435. constructor).  The 'flags' argument is an
     integer representing the kind of buffer requested, affecting for
     example whether the returned buffer is read-only or writable.
     *note inspect.BufferFlags: 42c. provides a convenient way to
     interpret the flags.  The method must return a *note memoryview:
     435. object.

 -- メソッド: object.__release_buffer__ (self, buffer)

     Called when a buffer is no longer needed.  The 'buffer' argument is
     a *note memoryview: 435. object that was previously returned by
     *note __buffer__(): 42b.  The method must release any resources
     associated with the buffer.  This method should return ‘None’.
     Buffer objects that do not need to perform any cleanup are not
     required to implement this method.

Added in version 3.12.

参考
....

PEP 688(1) - Making the buffer protocol accessible in Python

     Introduces the Python ‘__buffer__’ and ‘__release_buffer__’
     methods.

*note collections.abc.Buffer: 2a4.

     ABC for buffer types.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0688/


File: python.info,  Node: 特殊メソッド検索,  Prev: Emulating buffer types,  Up: 特殊メソッド名

4.3.3.25 特殊メソッド検索
.........................

カスタムクラスでは、特殊メソッドの暗黙の呼び出しは、オブジェクトのインス
タンス辞書ではなく、オブジェクトの型で定義されているときにのみ正しく動作
することが保証されます。この動作のため、以下のコードは例外を送出します:

     >>> class C:
     ...     pass
     ...
     >>> c = C()
     >>> c.__len__ = lambda: 5
     >>> len(c)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: object of type 'C' has no len()

この動作の背景となる理由は、 *note __hash__(): ac9. と *note __repr__():
5e8. といった type オブジェクトを含むすべてのオブジェクトで定義されてい
る特殊メソッドにあります。これらのメソッドの暗黙の検索が通常の検索プロセ
スを使った場合、 type オブジェクト自体に対して実行されたときに失敗してし
まいます:

     >>> 1 .__hash__() == hash(1)
     True
     >>> int.__hash__() == hash(int)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: descriptor '__hash__' of 'int' object needs an argument

クラスの非結合メソッドをこのようにして実行しようとすることは、'metaclass
confusion' と呼ばれることもあり、特殊メソッドを検索するときはインスタン
スをバイパスすることで回避されます:

     >>> type(1).__hash__(1) == hash(1)
     True
     >>> type(int).__hash__(int) == hash(int)
     True

正確性のためにインスタンス属性をスキップするのに加えて、特殊メソッド検索
はオブジェクトのメタクラスを含めて、 *note __getattribute__(): ba0. メソ
ッドもバイパスします:

     >>> class Meta(type):
     ...     def __getattribute__(*args):
     ...         print("Metaclass getattribute invoked")
     ...         return type.__getattribute__(*args)
     ...
     >>> class C(object, metaclass=Meta):
     ...     def __len__(self):
     ...         return 10
     ...     def __getattribute__(*args):
     ...         print("Class getattribute invoked")
     ...         return object.__getattribute__(*args)
     ...
     >>> c = C()
     >>> c.__len__()                 # Explicit lookup via instance
     Class getattribute invoked
     10
     >>> type(c).__len__(c)          # Explicit lookup via type
     Metaclass getattribute invoked
     10
     >>> len(c)                      # Implicit lookup
     10

このように *note __getattribute__(): ba0. 機構をバイパスすることで、特殊
メソッドの扱いに関するある程度の自由度と引き換えに (特殊メソッドはインタ
プリタから一貫して実行されるためにクラスオブジェクトに設定 'しなければな
らない')、インタープリタを高速化するための大きな余地が手に入ります。


File: python.info,  Node: コルーチン,  Prev: 特殊メソッド名,  Up: データモデル

4.3.4 コルーチン
----------------

* Menu:

* 待機可能オブジェクト (Awaitable Object): 待機可能オブジェクト Awaitable Object.
* コルーチンオブジェクト::
* 非同期イテレータ (Asynchronous Iterator): 非同期イテレータ Asynchronous Iterator.
* 非同期コンテキストマネージャ (Asynchronous Context Manager): 非同期コンテキストマネージャ Asynchronous Context Manager.


File: python.info,  Node: 待機可能オブジェクト Awaitable Object,  Next: コルーチンオブジェクト,  Up: コルーチン

4.3.4.1 待機可能オブジェクト (Awaitable Object)
...............................................

*note awaitable: 192. オブジェクトは一般的には *note __await__(): 1f28.
メソッドが実装されています。 *note async def: 59b. 関数が返す *note
Coroutineオブジェクト: 45e. は待機可能です。

     注釈: *note types.coroutine(): e53. デコレータでデコレータが付けら
     れたジェネレータから返される *note generator iterator: bac. オブジ
     ェクトも待機可能ですが、 *note __await__(): 1f28. は実装されていま
     せん。

 -- メソッド: object.__await__ (self)

     Must return an *note iterator: 191.  Should be used to implement
     *note awaitable: 192. objects.  For instance, *note asyncio.Future:
     b9b. implements this method to be compatible with the *note await:
     19e. expression.  The *note object: a5a. class itself is not
     awaitable and does not provide this method.

          注釈: The language doesn't place any restriction on the type
          or value of the objects yielded by the iterator returned by
          ‘__await__’, as this is specific to the implementation of the
          asynchronous execution framework (e.g.  *note asyncio: 8.)
          that will be managing the *note awaitable: 192. object.

Added in version 3.5.

参考
....

待機可能オブジェクトについてより詳しくは PEP 492(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0492/


File: python.info,  Node: コルーチンオブジェクト,  Next: 非同期イテレータ Asynchronous Iterator,  Prev: 待機可能オブジェクト Awaitable Object,  Up: コルーチン

4.3.4.2 コルーチンオブジェクト
..............................

*note Coroutineオブジェクト: 45e. は *note awaitable: 192. オブジェクト
です。*note __await__(): 1f28. を呼び出し、その返り値に対し反復処理をす
ることでコルーチンの実行を制御できます。コルーチンの実行が完了し制御を戻
したとき、イテレータは *note StopIteration: bc8. を送出し、その例外の
*note value: 1f2a. 属性に返り値を持たせます。コルーチンが例外を送出した
場合は、イテレータにより伝搬されます。コルーチンから *note
StopIteration: bc8. 例外を外に送出すべきではありません。

コルーチンには以下に挙げるメソッドもあり、これらはジェネレータのメソッド
からの類似です (*note ジェネレータ-イテレータメソッド: 1f2b. を参照して
ください)。 ただし、ジェネレータと違って、コルーチンは反復処理を直接はサ
ポートしていません。

バージョン 3.5.2 で変更: コルーチンで2回以上待機 (await) すると *note
RuntimeError: 17a. となります。

 -- メソッド: coroutine.send (value)

     Starts or resumes execution of the coroutine.  If 'value' is
     ‘None’, this is equivalent to advancing the iterator returned by
     *note __await__(): 1f28.  If 'value' is not ‘None’, this method
     delegates to the *note send(): 1036. method of the iterator that
     caused the coroutine to suspend.  The result (return value, *note
     StopIteration: bc8, or other exception) is the same as when
     iterating over the ‘__await__()’ return value, described above.

 -- メソッド: coroutine.throw (value)

 -- メソッド: coroutine.throw (type[, value[, traceback]])

     コルーチンで指定された例外を送出します。 このメソッドは、イテレータ
     にコルーチンを一時停止する *note throw(): 4c5. メソッドがある場合に
     処理を委任します。 そうでない場合には、中断した地点から例外が送出さ
     れます。 結果 (返り値か *note StopIteration: bc8. かその他の例外) は
     、上で解説したような *note __await__(): 1f28. の返り値に対して反復
     処理を行ったときと同じです。 例外がコルーチンの中で捕捉されなかった
     場合、呼び出し元へ伝搬されます。

     バージョン 3.12 で変更: The second signature (type[, value[,
     traceback]]) is deprecated and may be removed in a future version
     of Python.

 -- メソッド: coroutine.close ()

     コルーチンが自分自身の後片付けをし終了します。 コルーチンが一時停止
     している場合は、コルーチンを一時停止させたイテレータに *note
     close(): 1659. メソッドがあれば、まずはそれに処理を委任します。 そ
     して一時停止した地点から *note GeneratorExit: 136f. が送出され、た
     だちにコルーチンが自分自身の後片付けを行います。 最後に、実行が開始
     されていなかった場合でも、コルーチンに実行が完了した印を付けます。

     コルーチンオブジェクトが破棄されるときには、上記の手順を経て自動的
     に閉じられます。


File: python.info,  Node: 非同期イテレータ Asynchronous Iterator,  Next: 非同期コンテキストマネージャ Asynchronous Context Manager,  Prev: コルーチンオブジェクト,  Up: コルーチン

4.3.4.3 非同期イテレータ (Asynchronous Iterator)
................................................

'非同期イテレータ' の ‘__anext__’ メソッドからは非同期のコードが呼べます
。

非同期イテレータは *note async for: a79. 文の中で使えます。

The *note object: a5a. class itself does not provide these methods.

 -- メソッド: object.__aiter__ (self)

     '非同期イテレータ' オブジェクトを返さなくてはなりません。

 -- メソッド: object.__anext__ (self)

     イテレータの次の値を返す '待機可能オブジェクト' を返さなければなり
     ません。 反復処理が終了したときには *note StopAsyncIteration: 1998.
     エラーを送出すべきです。

非同期イテラブルオブジェクトの例:

     class Reader:
         async def readline(self):
             ...

         def __aiter__(self):
             return self

         async def __anext__(self):
             val = await self.readline()
             if val == b'':
                 raise StopAsyncIteration
             return val

Added in version 3.5.

バージョン 3.7 で変更: Python 3.7 より前では、 *note __aiter__(): bc9. は
*note 非同期イテレータ: 190. になる 'awaitable' を返せました。

Python 3.7 からは、 *note __aiter__(): bc9. は非同期イテレータオブジェク
トを返さなければなりません。 それ以外のものを返すと *note TypeError:
502. になります。


File: python.info,  Node: 非同期コンテキストマネージャ Asynchronous Context Manager,  Prev: 非同期イテレータ Asynchronous Iterator,  Up: コルーチン

4.3.4.4 非同期コンテキストマネージャ (Asynchronous Context Manager)
...................................................................

'非同期コンテキストマネージャ' は、 ‘__aenter__’ メソッドと ‘__aexit__’
メソッド内部で実行を一時停止できる 'コンテキストマネージャ' です。

非同期コンテキストマネージャは *note async with: 59f. 文の中で使えます。

The *note object: a5a. class itself does not provide these methods.

 -- メソッド: object.__aenter__ (self)

     Semantically similar to *note __enter__(): 592, the only difference
     being that it must return an 'awaitable'.

 -- メソッド: object.__aexit__ (self, exc_type, exc_value, traceback)

     Semantically similar to *note __exit__(): 12ce, the only difference
     being that it must return an 'awaitable'.

非同期コンテキストマネージャクラスの例:

     class AsyncContextManager:
         async def __aenter__(self):
             await log('entering context')

         async def __aexit__(self, exc_type, exc, tb):
             await log('exiting context')

Added in version 3.5.

脚注
....


File: python.info,  Node: 実行モデル,  Next: インポートシステム,  Prev: データモデル,  Up: Python 言語リファレンス

4.4 実行モデル
==============

* Menu:

* プログラムの構造::
* 名前づけと束縛 (naming and binding): 名前づけと束縛 naming and binding.
* 例外: 例外<2>.


File: python.info,  Node: プログラムの構造,  Next: 名前づけと束縛 naming and binding,  Up: 実行モデル

4.4.1 プログラムの構造
----------------------

Python プログラムはコードブロックから構成されます。 ブロック ('block') は
、一つのまとまりとして実行される Python プログラムテキストの断片です。 モ
ジュール、関数本体、そしてクラス定義はブロックであり、対話的に入力された
個々のコマンドもブロックです。 スクリプトファイル (インタープリタに標準
入力として与えられたり、インタープリタにコマンドライン引数として与えられ
たファイル) もコードブロックです。 スクリプトコマンド (インタープリタの
コマンドライン上で *note -c: 5aa. オプションで指定されたコマンド) もコー
ドブロックです。 引数 *note -m: 5ab. を使用して、コマンドラインからトッ
プレベルスクリプト(すなわちモジュール ‘__main__’ )として実行されるモジュ
ールもまたコードブロックです。組み込み関数 *note eval(): 165. や *note
exec(): 164. に渡された文字列引数もコードブロックです。

コードブロックは、実行フレーム ('execution frame') 上で実行されます。実
行フレームには、 (デバッグに使われる) 管理情報が収められています。また、
現在のコードブロックの実行が完了した際に、どのようにプログラムの実行を継
続するかを決定しています。


File: python.info,  Node: 名前づけと束縛 naming and binding,  Next: 例外<2>,  Prev: プログラムの構造,  Up: 実行モデル

4.4.2 名前づけと束縛 (naming and binding)
-----------------------------------------

* Menu:

* 名前の束縛::
* 名前解決::
* Annotation scopes::
* Lazy evaluation::
* 組み込みと制限付きの実行::
* 動的な機能とのやりとり::


File: python.info,  Node: 名前の束縛,  Next: 名前解決,  Up: 名前づけと束縛 naming and binding

4.4.2.1 名前の束縛
..................

'名前 (name)' は、オブジェクトを参照します。名前を導入するには、名前への
束縛 (name binding) 操作を行います。

以下の構文が名前を束縛します:

   * formal parameters to functions,

   * クラス定義,

   * 関数定義,

   * 代入式,

   * *note targets: 1f39. that are identifiers if occurring in an
     assignment:

        + *note for: 2c9. loop header,

        + after ‘as’ in a *note with: 59c. statement, *note except: 170.
          clause, *note except*: 582. clause, or in the as-pattern in
          structural pattern matching,

        + in a capture pattern in structural pattern matching

   * *note import: 5ac. 文.

   * *note type: 404. statements.

   * *note type parameter lists: 293.

The ‘import’ statement of the form ‘from ... import *’ binds all names
defined in the imported module, except those beginning with an
underscore.  This form may only be used at the module level.

*note del: 1711. 文で指定される対象は、(*note del: 1711. の意味付けは、
実際は名前の解放 (unbind) ですが) 文の目的上、束縛済みのものとみなされま
す。

代入文や import 文はいずれも、クラスや関数定義、モジュールレベル (トップ
レベルのコードブロック) 内で起こります。

If a name is bound in a block, it is a local variable of that block,
unless declared as *note nonlocal: 1279. or *note global: 16f.  If a
name is bound at the module level, it is a global variable.  (The
variables of the module code block are local and global.)  If a variable
is used in a code block but not defined there, it is a *note free
variable: 1f3a.

プログラムテキスト中に名前が出現するたびに、その名前が使われている最も内
側の関数ブロック中で作成された '束縛 (binding)' を使って名前の参照が行わ
れます。


File: python.info,  Node: 名前解決,  Next: Annotation scopes,  Prev: 名前の束縛,  Up: 名前づけと束縛 naming and binding

4.4.2.2 名前解決
................

スコープ ('scope') は、ブロック内の名前の可視性を決めます。 ローカル変数
があるブロック内で定義されている場合、変数のスコープはそのブロックを含み
ます。 関数ブロック内で名前の定義を行った場合、その中のブロックが名前に
別の束縛を行わない限り、定義ブロック内の全てのブロックを含むようにスコー
プが拡張されます。

ある名前がコードブロック内で使われると、その名前を最も近傍から囲うような
スコープ (最内スコープ: nearest enclosing scope) を使って束縛の解決を行
います。こうしたスコープからなる、あるコードブロック内で参照できるスコー
プ全ての集合は、ブロックの環境('environment')と呼ばれます。

名前が全く見付からなかったときは、 *note NameError: 40b. 例外が送出され
ます。 現在のスコープが関数のもので、名前が使われる場所でローカル変数が
まだ値に束縛されていない場合、 *note UnboundLocalError: 14df. 例外が送出
されます。 *note UnboundLocalError: 14df. は *note NameError: 40b. の子
クラスです。

ある名前がコードブロック内のどこかで束縛操作されていたら、そのブロック内
で使われるその名前はすべて、現在のブロックへの参照として扱われます。この
ため、ある名前がそのブロック内で束縛される前に使われるとエラーにつながり
ます。この規則は敏感です。Python には宣言がなく、コードブロックのどこで
も名前束縛操作ができます。あるコードブロックにおけるローカル変数は、ブロ
ックのテキスト全体から名前束縛操作を走査することで決定されます。例は
*note UnboundLocalError についての FAQ 項目: 1f3d. を参照してください。

If the *note global: 16f. statement occurs within a block, all uses of
the names specified in the statement refer to the bindings of those
names in the top-level namespace.  Names are resolved in the top-level
namespace by searching the global namespace, i.e.  the namespace of the
module containing the code block, and the builtins namespace, the
namespace of the module *note builtins: e.  The global namespace is
searched first.  If the names are not found there, the builtins
namespace is searched next.  If the names are also not found in the
builtins namespace, new variables are created in the global namespace.
The global statement must precede all uses of the listed names.

*note global: 16f. 文は、同じブロックの束縛操作と同じスコープを持ちます
。ある自由変数の最内スコープに global 文がある場合、その自由変数はグロー
バル変数とみなされます。

The *note nonlocal: 1279. statement causes corresponding names to refer
to previously bound variables in the nearest enclosing function scope.
*note SyntaxError: 172. is raised at compile time if the given name does
not exist in any enclosing function scope.  *note Type parameters: 293.
cannot be rebound with the ‘nonlocal’ statement.

あるモジュールの名前空間は、そのモジュールが最初に import された時に自動
的に作成されます。スクリプトの主モジュール (main module) は常に *note
__main__: 1. と呼ばれます。

Class definition blocks and arguments to *note exec(): 164. and *note
eval(): 165. are special in the context of name resolution.  A class
definition is an executable statement that may use and define names.
These references follow the normal rules for name resolution with an
exception that unbound local variables are looked up in the global
namespace.  The namespace of the class definition becomes the attribute
dictionary of the class.  The scope of names defined in a class block is
limited to the class block; it does not extend to the code blocks of
methods.  This includes comprehensions and generator expressions, but it
does not include *note annotation scopes: 16d, which have access to
their enclosing class scopes.  This means that the following will fail:

     class A:
         a = 42
         b = list(a + i for i in range(10))

However, the following will succeed:

     class A:
         type Alias = Nested
         class Nested: pass

     print(A.Alias.__value__)  # <type 'A.Nested'>


File: python.info,  Node: Annotation scopes,  Next: Lazy evaluation,  Prev: 名前解決,  Up: 名前づけと束縛 naming and binding

4.4.2.3 Annotation scopes
.........................

*note Type parameter lists: 293. and *note type: 404. statements
introduce 'annotation scopes', which behave mostly like function scopes,
but with some exceptions discussed below.  *note Annotations: 424.
currently do not use annotation scopes, but they are expected to use
annotation scopes in Python 3.13 when PEP 649(1) is implemented.

Annotation scopes are used in the following contexts:

   * Type parameter lists for *note generic type aliases: 422.

   * Type parameter lists for *note generic functions: 41f.  A generic
     function's annotations are executed within the annotation scope,
     but its defaults and decorators are not.

   * Type parameter lists for *note generic classes: 41e.  A generic
     class's base classes and keyword arguments are executed within the
     annotation scope, but its decorators are not.

   * The bounds, constraints, and default values for type parameters
     (*note lazily evaluated: 423.).

   * The value of type aliases (*note lazily evaluated: 423.).

Annotation scopes differ from function scopes in the following ways:

   * Annotation scopes have access to their enclosing class namespace.
     If an annotation scope is immediately within a class scope, or
     within another annotation scope that is immediately within a class
     scope, the code in the annotation scope can use names defined in
     the class scope as if it were executed directly within the class
     body.  This contrasts with regular functions defined within
     classes, which cannot access names defined in the class scope.

   * Expressions in annotation scopes cannot contain *note yield: 99b,
     ‘yield from’, *note await: 19e, or *note ;=: 1f3f. expressions.
     (These expressions are allowed in other scopes contained within the
     annotation scope.)

   * Names defined in annotation scopes cannot be rebound with *note
     nonlocal: 1279. statements in inner scopes.  This includes only
     type parameters, as no other syntactic elements that can appear
     within annotation scopes can introduce new names.

   * While annotation scopes have an internal name, that name is not
     reflected in the *note qualified name: 18ab. of objects defined
     within the scope.  Instead, the *note __qualname__: 103a. of such
     objects is as if the object were defined in the enclosing scope.

Added in version 3.12: Annotation scopes were introduced in Python 3.12
as part of PEP 695(2).

バージョン 3.13 で変更: Annotation scopes are also used for type
parameter defaults, as introduced by PEP 696(3).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0649/

   (2) https://peps.python.org/pep-0695/

   (3) https://peps.python.org/pep-0696/


File: python.info,  Node: Lazy evaluation,  Next: 組み込みと制限付きの実行,  Prev: Annotation scopes,  Up: 名前づけと束縛 naming and binding

4.4.2.4 Lazy evaluation
.......................

The values of type aliases created through the *note type: 404.
statement are 'lazily evaluated'.  The same applies to the bounds,
constraints, and default values of type variables created through the
*note type parameter syntax: 293.  This means that they are not
evaluated when the type alias or type variable is created.  Instead,
they are only evaluated when doing so is necessary to resolve an
attribute access.

例:

     >>> type Alias = 1/0
     >>> Alias.__value__
     Traceback (most recent call last):
       ...
     ZeroDivisionError: division by zero
     >>> def func[T: 1/0](): pass
     >>> T = func.__type_params__[0]
     >>> T.__bound__
     Traceback (most recent call last):
       ...
     ZeroDivisionError: division by zero

Here the exception is raised only when the ‘__value__’ attribute of the
type alias or the ‘__bound__’ attribute of the type variable is
accessed.

This behavior is primarily useful for references to types that have not
yet been defined when the type alias or type variable is created.  For
example, lazy evaluation enables creation of mutually recursive type
aliases:

     from typing import Literal

     type SimpleExpr = int | Parenthesized
     type Parenthesized = tuple[Literal["("], Expr, Literal[")"]]
     type Expr = SimpleExpr | tuple[SimpleExpr, Literal["+", "-"], Expr]

Lazily evaluated values are evaluated in *note annotation scope: 16d,
which means that names that appear inside the lazily evaluated value are
looked up as if they were used in the immediately enclosing scope.

Added in version 3.12.


File: python.info,  Node: 組み込みと制限付きの実行,  Next: 動的な機能とのやりとり,  Prev: Lazy evaluation,  Up: 名前づけと束縛 naming and binding

4.4.2.5 組み込みと制限付きの実行
................................

'CPython 実装の詳細:' ユーザは ‘__builtins__’ に触れるべきではありません
; これは厳密に実装の詳細です。組み込みの名前空間の中の値をオーバーライド
したいユーザは、 *note builtins: e. モジュールを *note import: 5ac. して
、その属性を適切に変更するべきです。

あるコードブロックの実行に関連する組み込み名前空間は、実際にはコードブロ
ックのグローバル名前空間から名前 ‘__builtins__’ を検索することで見つかり
ます; ‘__builtins__’ は辞書かモジュールでなければなりません (後者の場合
はモジュールの辞書が使われます)。デフォルトでは、 *note __main__: 1. モ
ジュール中においては、 ‘__builtins__’ は組み込みモジュール *note
builtins: e. です; それ以外の任意のモジュールにおいては、 ‘__builtins__’
は *note builtins: e. モジュール自身の辞書のエイリアスです。


File: python.info,  Node: 動的な機能とのやりとり,  Prev: 組み込みと制限付きの実行,  Up: 名前づけと束縛 naming and binding

4.4.2.6 動的な機能とのやりとり
..............................

自由変数の名前解決はコンパイル時でなく実行時に行われます。つまり、以下の
コードは42を出力します:

     i = 10
     def f():
         print(i)
     i = 42
     f()

*note eval(): 165. と *note exec(): 164. 関数は、名前の解決に、現在の環
境の全てを使えるわけではありません。名前は呼び出し側のローカルやグローバ
ル名前空間で解決できます。自由変数は最内名前空間ではなく、グローバル名前
空間から解決されます。 (1) *note exec(): 164. と *note eval(): 165. 関数
にはオプションの引数があり、グローバルとローカル名前空間をオーバライドで
きます。名前空間が一つしか指定されなければ、両方の名前空間として使われま
す。

   ---------- Footnotes ----------

   (1) この制限は、上記の操作によって実行されるコードが、モジュールをコ
ンパイルしたときには利用できないために起こります。


File: python.info,  Node: 例外<2>,  Prev: 名前づけと束縛 naming and binding,  Up: 実行モデル

4.4.3 例外
----------

例外とは、コードブロックの通常の制御フローを中断して、エラーやその他の例
外的な状況を処理できるようにするための手段です。例外はエラーが検出された
時点で '送出 (raise)' されます; 例外は、エラーが発生部の周辺のコードブロ
ックか、エラーが発生したコードブロック直接または間接的に呼び出しているコ
ードブロックで '処理 (handle)' することができます。

Python インタプリタは、ランタイムエラー (ゼロ除算など) が検出されると例
外を送出します。Python プログラムから、 *note raise: 5b7. 文を使って明示
的に例外を送出することもできます。例外ハンドラ (exception handler) は、
*note try: 6b4. ...  *note except: 170. 文で指定することができます。
*note try: 6b4. 文の *note finally: 997. 節を使うとクリーンアップコード
(cleanup code) を指定できます。このコードは例外は処理しませんが、先行す
るコードブロックで例外が起きても起きなくても実行されます。

Python は、エラー処理に "プログラムの終了 (termination)" モデルを用いて
います: 例外ハンドラは、プログラムに何が発生したかを把握することができ、
ハンドラの外側のレベルに処理を継続することはできますが、(問題のあったコ
ード部分を最初から実行しなおすのでない限り) エラーの原因を修復したり、実
行に失敗した操作をやり直すことはできません。

例外が全く処理されないとき、インタプリタはプログラムの実行を終了させるか
、対話メインループに処理を戻します。 どちらの場合も、例外が *note
SystemExit: d0e. でなければ、スタックのトレースバックを出力します。

例外は、クラスインスタンスによって識別されます。 *note except: 170. 節は
インスタンスのクラスにもとづいて選択されます: これはインスタンスのクラス
か、その *note 非仮想基底クラス: 1186. を参照します。このインスタンスは
ハンドラによって受け取られ、例外条件に関する追加情報を伝えることができま
す。

     注釈: 例外のメッセージは、Python API 仕様には含まれていません。メッ
     セージの内容は、ある Python のバージョンと次のバージョンの間で警告
     なしに変更される可能性があるので、複数バージョンのインタプリタで動
     作するようなコードは、例外メッセージの内容に依存させるべきではあり
     ません。

*note try: 6b4. 文については、 *note try 文: 6b4. 節、 *note raise: 5b7.
文については *note raise 文: 5b7. 節も参照してください。

脚注
....


File: python.info,  Node: インポートシステム,  Next: 式 expression,  Prev: 実行モデル,  Up: Python 言語リファレンス

4.5 インポートシステム
======================

ある 1 つの *note module: 15c3. にある Python コードから他のモジュールを
*note インポート: 1f49. することで、そこにあるコードへアクセスできるよう
になります。 *note import: 5ac. 文はインポート機構を動かす最も一般的な方
法ですが、それが唯一の方法ではありません。 *note
importlib.import_module(): 4e1. や組み込みの *note __import__(): 8a2. と
いった関数を使っても、インポート機構を動かすことができます。

*note import: 5ac. 文は 2 つの処理を連続して行っています; ある名前のモジ
ュールを探し、その検索結果をローカルスコープの名前に束縛します。
‘import’ 文の検索処理は、適切な引数で *note __import__(): 8a2. 関数を呼
び出すこととして定義されています。 *note __import__(): 8a2. の戻り値は
‘import’ 文の名前束縛処理の実行で使われます。名前束縛処理の厳密な詳細は
‘import’ 文を参照してください。

*note __import__(): 8a2. を直接呼び出すとモジュールの検索のみが行われ、
見つかった場合、モジュールの作成処理が行われます。親パッケージのインポー
トや (*note sys.modules: 18d6. を含む) 様々なキャッシュの更新などの副作
用は起きるかもしれませんが、 *note import: 5ac. 文のみが名前束縛処理を行
います。

*note import: 5ac. 文が実行されるときには、標準の組み込み関数 *note
__import__(): 8a2. が呼ばれます。インポートシステムを呼び出すその他の
(*note importlib.import_module(): 4e1. 関数のような) メカニズムは、*note
__import__(): 8a2. の呼び出しをバイパスして独自のインポート・セマンティ
クスを実装している可能性があります。

モジュールが初めてインポートされるとき、 Python はそのモジュールを検索し
、見付かった場合、モジュールオブジェクトを作成し、初期化します (1) 。そ
の名前のモジュールが見付からなかった場合、 *note ModuleNotFoundError:
b15. が送出されます。 Python には、インポート機構が実行されたときに名前
からモジュールを検索する様々な戦略が実装されています。これらの戦略は、こ
れ以降の節で解説される様々なフックを使って、修正したり拡張したりできます
。

バージョン 3.3 で変更: インポートシステムが PEP 302(2) の第 2 フェーズの
完全な実装へ更新されました。もはや暗黙的なインポート機構はありません - イ
ンポート機構全体は *note sys.meta_path: cf9. を通して公開されています。
加えて、ネイティブの名前空間パッケージのサポートは実装されています ( PEP
420(3) を参照) 。

* Menu:

* importlib: importlib<10>.
* パッケージ: パッケージ<2>.
* 検索::
* ロード::
* パスベース・ファインダー::
* 標準のインポートシステムを置き換える::
* Package Relative Imports::
* __main__ に対する特別な考慮::
* 参考資料::

   ---------- Footnotes ----------

   (1) *note types.ModuleType: de0. を参照してください。

   (2) https://peps.python.org/pep-0302/

   (3) https://peps.python.org/pep-0420/


File: python.info,  Node: importlib<10>,  Next: パッケージ<2>,  Up: インポートシステム

4.5.1 ‘importlib’
-----------------

*note importlib: 6b. モジュールはインポート機構とやり取りするための便利
な API を提供します。例えば *note importlib.import_module(): 4e1. は、イ
ンポート機構を実行するための組み込みの *note __import__(): 8a2. よりもシ
ンプルで推奨される API を提供します。より詳細なことは *note importlib:
6b. ライブラリのドキュメントを参照してください。


File: python.info,  Node: パッケージ<2>,  Next: 検索,  Prev: importlib<10>,  Up: インポートシステム

4.5.2 パッケージ
----------------

Python にはモジュールオブジェクトの種類は 1 種類しかなく、 Python 、 C 、
それ以外のもののどれで実装されているかに関係なく、すべてのモジュールはこ
の種類になります。モジュールの組織化を助け、名前階層を提供するために、
Python には *note パッケージ: 1e7a. という概念があります。

パッケージはファイルシステムのディレクトリ、モジュールはディレクトリにあ
るファイルと考えることができますが、パッケージやモジュールはファイルシス
テムから生まれる必要はないので、この比喩を額面通りに受け取ってはいけませ
ん。この文書の目的のために、ディレクトリとファイルという便利な比喩を使う
ことにします。ファイルシステムのディレクトリのように、パッケージは階層構
造を成し、通常のモジュールだけでなく、サブパッケージを含むこともあります
。

すべてのパッケージはモジュールですが、すべてのモジュールがパッケージとは
限らないことを心に留めておくのが重要です。もしくは他の言い方をすると、パ
ッケージは単なる特別な種類のモジュールであると言えます。特に、‘__path__’
属性を持つ任意のモジュールはパッケージと見なされます。

すべてのモジュールは名前を持ちます。Python の属性アクセスの文法と同様に
、サブパッケージの名前は親パッケージ名とドット記号で区切られます。したが
って、*note email: 32. という名前のパッケージや、それが含む *note
email.mime: 3c. という名前のサブパッケージ、さらにそれに含まれる *note
email.mime.text: 44. と言う名前のモジュールを考えることができます。

* Menu:

* 通常のパッケージ::
* 名前空間パッケージ::


File: python.info,  Node: 通常のパッケージ,  Next: 名前空間パッケージ,  Up: パッケージ<2>

4.5.2.1 通常のパッケージ
........................

Python では、 *note 通常のパッケージ: 1f4d. と *note 名前空間パッケージ:
1bd2. の 2 種類のパッケージが定義されています。通常のパッケージは Python
3.2 以前から存在する伝統的なパッケージです。典型的な通常のパッケージは
‘__init__.py’ ファイルを含むディレクトリとして実装されます。通常のパッケ
ージがインポートされたとき、この ‘__init__.py’ ファイルが暗黙的に実行さ
れ、それで定義しているオブジェクトがパッケージ名前空間にある名前に束縛さ
れます。 ‘__init__.py’ ファイルは、他のモジュールに書ける Python コード
と同じものを含むことができ、モジュールがインポートされたときに Python は
モジュールに属性を追加したりします。

例えば、以下のようなファイルシステム配置は、3 つのサブパッケージを持つ最
上位の ‘parent’ パッケージを定義します:

     parent/
         __init__.py
         one/
             __init__.py
         two/
             __init__.py
         three/
             __init__.py

‘parent.one’ をインポートすると暗黙的に ‘parent/__init__.py’ と
‘parent/one/__init__.py’ が実行されます。その後に ‘parent.two’ もしくは
‘parent.three’ をインポートすると、それぞれ ‘parent/two/__init__.py’ や
‘parent/three/__init__.py’ が実行されます。


File: python.info,  Node: 名前空間パッケージ,  Prev: 通常のパッケージ,  Up: パッケージ<2>

4.5.2.2 名前空間パッケージ
..........................

名前空間パッケージは様々な *note ポーション: 1f4f. を寄せ集めたもので、
それぞれのポーションはサブパッケージを親パッケージに提供します。ポーショ
ンはファイルシステムの別々の場所にあることもあります。ポーションは、 zip
ファイルの中やネットワーク上や、それ以外のインポート時に Python が探すど
こかの場所で見つかることもあります。名前空間パッケージはファイルシステム
上のオブジェクトに対応することもあるし、そうでないこともあります; それら
は実際の実体のない仮想モジュールです。

名前空間パッケージは、 ‘__path__’ 属性に普通のリストは使いません。その代
わりに独自の iterable 型を使っていて、ポーションの親パッケージのパス (も
しくは最上位パッケージのための *note sys.path: 38e.) が変わった場合、そ
のパッケージでの次のインポートの際に、新たに自動でパッケージポーションを
検索します。

名前空間パッケージには ‘parent/__init__.py’ ファイルはありません。それど
ころか、異なるポーションがそれぞれ提供する複数の ‘parent’ ディレクトリが
インポート検索の際に見つかることもあります。したがって ‘parent/one’ は物
理的に ‘parent/two’ の隣りにあるとは限りません。その場合、そのパッケージ
かサブパッケージのうち 1 つがインポートされたとき、Python は最上位の
‘parent’ パッケージのための名前空間パッケージを作成します。

名前空間パッケージの仕様については PEP 420(1) も参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0420/


File: python.info,  Node: 検索,  Next: ロード,  Prev: パッケージ<2>,  Up: インポートシステム

4.5.3 検索
----------

検索を始めるためには、 Python はインポートされるモジュール (もしくはパッ
ケージですが、ここでの議論の目的においてはささいな違いです) の *note
完全修飾: 18ab. 名を必要とします。この名前は、 *note import: 5ac. 文の様
々な引数や *note importlib.import_module(): 4e1. および *note
__import__(): 8a2. 関数のパラメータから得られます。

この名前はインポート検索の様々なフェーズで使われ、これは例えば
‘foo.bar.baz’ のようなドットで区切られたサブモジュールへのパスだったりし
ます。この場合、 Python は最初に ‘foo’ を、次に ‘foo.bar’ 、そして最後に
‘foo.bar.baz’ をインポートしようとします。中間のいずれかのインポートに失
敗した場合は、 *note ModuleNotFoundError: b15. が送出されます。

* Menu:

* モジュールキャッシュ::
* ファインダーとローダー::
* インポートフック::
* メタパス::


File: python.info,  Node: モジュールキャッシュ,  Next: ファインダーとローダー,  Up: 検索

4.5.3.1 モジュールキャッシュ
............................

インポート検索で最初に調べる場所は *note sys.modules: 18d6. です。このマ
ッピングは、中間のパスを含む、これまでにインポートされたすべてのモジュー
ルのキャッシュを提供します。なので ‘foo.bar.baz’ がインポート済みの場合
、 *note sys.modules: 18d6. は ‘foo’ 、 ‘foo.bar’ 、 ‘foo.bar.baz’ のエ
ントリーを含みます。それぞれのキーはその値として対応するモジュールオブジ
ェクトを持ちます。

インポートではモジュール名は *note sys.modules: 18d6. から探され、存在し
た場合は、対応する値がインポートされるべきモジュールであり、この処理は完
了します。しかし値が ‘None’ だった場合、 *note ModuleNotFoundError: b15.
が送出されます。モジュール名が見付からなかった場合は、 Python はモジュー
ルの検索を続けます。

*note sys.modules: 18d6. は書き込み可能です。キーの削除は対応するモジュ
ールを破壊しない (他のモジュールがそのモジュールへの参照を持っている) か
もしれませんが、指定されたモジュールのキャッシュされたエントリーを無効に
し、それが次にインポートされたとき Python にそのモジュールを改めて検索さ
せることになります。キーを ‘None’ に対応付けることもできますが、次にその
モジュールがインポートされるときに *note ModuleNotFoundError: b15. とな
ってしまいます。

たとえモジュールオブジェクトへの参照を保持しておいて、 *note
sys.modules: 18d6. にキャッシュされたエントリーを無効にし、その指定した
モジュールを再インポートしたとしても、 2 つのモジュールオブジェクトは同
じでは 'ない' ことに注意してください。それとは対照的に、 *note
importlib.reload(): 4e2. は '同じ' モジュールオブジェクトを再利用し、モ
ジュールのコードを再実行することで単にモジュールの内容を再初期化するだけ
です。


File: python.info,  Node: ファインダーとローダー,  Next: インポートフック,  Prev: モジュールキャッシュ,  Up: 検索

4.5.3.2 ファインダーとローダー
..............................

*note sys.modules: 18d6. に指定されたモジュールが見つからなかった場合は
、 Python のインポートプロトコルが起動され、モジュールを見つけロードしま
す。このプロトコルは 2 つの概念的なオブジェクト、 *note ファインダー:
1e7e. と *note ローダー: 1614. から成ります。ファインダーの仕事は、知っ
ている戦略を使って指定されたモジュールを見つけられるかどうか判断すること
です。両方のインターフェースを実装しているオブジェクトは *note
インポーター: 1f54. と呼ばれます - インポーターは要求されたモジュールが
ロードできると分かったとき、自分自身を返します。

Python にはデフォルトのファインダーとインポーターがいくつかあります。 1
つ目のものは組み込みモジュールの見つけ方を知っていて、 2 つ目のものは凍
結されたモジュール (訳注: freeze ツールで処理されたモジュールのこと。
*note プログラミング FAQ: 1f55. の「どうしたら Python スクリプトからスタ
ンドアロンバイナリを作れますか？」の項目を参照) の見つけ方を知っています
。 3 つ目のものは *note インポートパス: 1f56. からモジュールを探します。
*note インポートパス: 1f56. はファイルシステムのパスや zip ファイルの位
置を示すリストです。このリストは、 URL で特定できるもののような、位置を
示すことのできる任意のリソースの検索にまで拡張することもできます。

インポート機構は拡張可能なので、モジュール検索の範囲とスコープを拡張する
ために新しいファインダーを付け加えることができます。

ファインダーは実際にはモジュールをロードしません。指定されたモジュールが
見つかった場合、ファインダーは 'module spec' (モジュール仕様)、すなわち
モジュールのインポート関連の情報をカプセル化したものを返します。モジュー
ルのロード時にインポート機構はそれを利用します。

次の節では、インポート機構を拡張するための新しいファインダーやローダーの
作成と登録を含め、ファインダーとローダーのプロトコルについてより詳しく解
説します。

バージョン 3.4 で変更: Python の以前のバージョンでは、ファインダーは直接
*note ローダー: 1614. を返していましたが、現在はローダーを '含む' モジュ
ール仕様を返します。ローダーはインポート中はまだ使われていますが、責任は
減りました。


File: python.info,  Node: インポートフック,  Next: メタパス,  Prev: ファインダーとローダー,  Up: 検索

4.5.3.3 インポートフック
........................

インポート機構は拡張可能なように設計されています; その主となる仕組みは
'インポートフック' です。インポートフックには 2 種類あります: 'メタフッ
ク' と 'インポートパスフック' です。

メタフックはインポート処理の最初、 *note sys.modules: 18d6. キャッシュの
検索以外のインポート処理より前に呼び出されます。これにより、 *note
sys.path: 38e. の処理や凍結されたモジュールや組み込みのモジュールでさえ
も、メタフックで上書きすることができます。メタフックは以下で解説するよう
に、 *note sys.meta_path: cf9. に新しいファインダーオブジェクトを追加す
ることで登録されます。

インポートパスフックは、 *note sys.path: 38e. (もしくは
‘package.__path__’) の処理の一部として、対応するパス要素を取り扱うところ
で呼び出されます。インポートパスフックは以下で解説するように、新しい呼び
出し可能オブジェクトを *note sys.path_hooks: fee. に追加することで登録さ
れます。


File: python.info,  Node: メタパス,  Prev: インポートフック,  Up: 検索

4.5.3.4 メタパス
................

When the named module is not found in *note sys.modules: 18d6, Python
next searches *note sys.meta_path: cf9, which contains a list of meta
path finder objects.  These finders are queried in order to see if they
know how to handle the named module.  Meta path finders must implement a
method called *note find_spec(): 834. which takes three arguments: a
name, an import path, and (optionally) a target module.  The meta path
finder can use any strategy it wants to determine whether it can handle
the named module or not.

meta path finder が指定されたモジュールの扱い方を知っている場合は、ファ
インダは spec オブジェクトを返します。指定されたモジュールを扱えない場合
は ‘None’ を返します。 *note sys.meta_path: cf9. に対する処理が spec を
返さずにリストの末尾に到達してしまった場合は、 *note
ModuleNotFoundError: b15. を送出します。その他の送出された例外はそのまま
呼び出し元に伝播され、インポート処理を異常終了させます。

The *note find_spec(): 834. method of meta path finders is called with
two or three arguments.  The first is the fully qualified name of the
module being imported, for example ‘foo.bar.baz’.  The second argument
is the path entries to use for the module search.  For top-level
modules, the second argument is ‘None’, but for submodules or
subpackages, the second argument is the value of the parent package's
‘__path__’ attribute.  If the appropriate ‘__path__’ attribute cannot be
accessed, a *note ModuleNotFoundError: b15. is raised.  The third
argument is an existing module object that will be the target of loading
later.  The import system passes in a target module only during reload.

メタパスは、1 回のインポート要求で複数回走査される可能性があります。例え
ば、関係するモジュールがどれもまだキャッシュされていないとしたときに
‘foo.bar.baz’ をインポートすると、最初は各メタパス・ファインダー (‘mpf’)
に対して ‘mpf.find_spec("foo", None, None)’ を呼び出して、最上位のインポ
ート処理を行います。‘foo’ がインポートされた後に、
‘mpf.find_spec("foo.bar", foo.__path__, None)’ を呼び出していく 2 回目の
メタパスの走査が行われ、‘foo.bar’ がインポートされます。‘foo.bar’ のイン
ポートまで行われたら、最後の走査で ‘mpf.find_spec("foo.bar.baz",
foo.bar.__path__, None)’ を呼び出していきます。

あるメタパス・ファインダーは最上位のインポートのみサポートしています。こ
れらのインポーターは、2 つ目の引数に ‘None’ 以外のものが渡されたとき、常
に ‘None’ を返します。

Python のデフォルトの *note sys.meta_path: cf9. は 3 つのパスファインダ
ーを持っています。組み込みモジュールのインポートの方法を知っているもの、
凍結されたモジュールのインポートの方法を知っているもの、 *note
インポートパス: 1f56. からのモジュールのインポートの方法を知っているもの
(つまり *note パスベース・ファインダー: 1f59.) があります。

バージョン 3.4 で変更: The *note find_spec(): 834. method of meta path
finders replaced ‘find_module()’, which is now deprecated.  While it
will continue to work without change, the import machinery will try it
only if the finder does not implement *note find_spec(): 834.

バージョン 3.10 で変更: Use of ‘find_module()’ by the import system now
raises *note ImportWarning: 4c7.

バージョン 3.12 で変更: ‘find_module()’ has been removed.  Use *note
find_spec(): 834. instead.


File: python.info,  Node: ロード,  Next: パスベース・ファインダー,  Prev: 検索,  Up: インポートシステム

4.5.4 ロード
------------

モジュール仕様が見つかった場合、インポート機構はモジュールをロードする時
にそれ (およびそれに含まれるローダー) を使います。これは、インポートのロ
ード部分で起こることの近似です:

     module = None
     if spec.loader is not None and hasattr(spec.loader, 'create_module'):
         # It is assumed 'exec_module' will also be defined on the loader.
         module = spec.loader.create_module(spec)
     if module is None:
         module = ModuleType(spec.name)
     # The import-related module attributes get set here:
     _init_module_attrs(spec, module)

     if spec.loader is None:
         # unsupported
         raise ImportError
     if spec.origin is None and spec.submodule_search_locations is not None:
         # namespace package
         sys.modules[spec.name] = module
     elif not hasattr(spec.loader, 'exec_module'):
         module = spec.loader.load_module(spec.name)
     else:
         sys.modules[spec.name] = module
         try:
             spec.loader.exec_module(module)
         except BaseException:
             try:
                 del sys.modules[spec.name]
             except KeyError:
                 pass
             raise
     return sys.modules[spec.name]

以下の詳細に注意してください:

   * *note sys.modules: 18d6. の中に与えられた名前を持つ既存のモジュール
     オブジェクトがあるなら、 import は既にそれを返しているでしょう。

   * モジュールは、ローダーがモジュールコードを実行する前に *note
     sys.modules: 18d6. に存在しています。 モジュールコードが (直接的ま
     たは間接的に) 自分自身をインポートする可能性があるので、これは重要
     です; モジュールを *note sys.modules: 18d6. に追加することで、最悪
     のケースでは無限の再帰が、そして最良のケースでは複数回のロードが、
     前もって防止されます。

   * ロード処理に失敗した場合、その失敗したモジュールは - そして、そのモ
     ジュールだけが - *note sys.modules: 18d6. から取り除かれます。
     *note sys.modules: 18d6. キャッシュに既に含まれていたすべてのモジュ
     ールと、副作用としてロードに成功したすべてのモジュールは、常にキャ
     ッシュに残されます。これはリロードとは対照的で、リロードの場合は失
     敗したモジュールも *note sys.modules: 18d6. に残されます。

   * *note 後のセクション: 1e74. で要約されるように、モジュールが作られ
     てから実行されるまでの間にインポート機構はインポート関連のモジュー
     ル属性を設定します (上記擬似コード例の "_init_module_attrs")。

   * モジュール実行はモジュールの名前空間が構築されるロードの重要な瞬間
     です。実行はローダーに完全に委任され、ローダーは何をどのように構築
     するかを決定することになります。

   * ロードの間に作成されて exec_module() に渡されたモジュールは、インポ
     ートの終わりに返されるものとは異なるかもしれません (1)。

バージョン 3.4 で変更: インポートシステムはローダーの定型的な責任を引き
継ぎました。これらは以前は *note importlib.abc.Loader.load_module():
835. メソッドによって実行されました。

* Menu:

* ローダー::
* サブモジュール::
* Module specs::
* __path__ attributes on modules::
* モジュールの repr::
* キャッシュされたバイトコードの無効化::

   ---------- Footnotes ----------

   (1) importlib の実装は、戻り値を直接使うことは避けています。その代わ
りに、モジュール名を調べて *note sys.modules: 18d6. からモジュールオブジ
ェクトを得ます。こうすることの間接的な効果は、インポートされたモジュール
が *note sys.modules: 18d6. にいる自分自身を置き換えることがあるというこ
とです。これは実装依存の動作であり、他の Python 実装では保証されていない
動作です。


File: python.info,  Node: ローダー,  Next: サブモジュール,  Up: ロード

4.5.4.1 ローダー
................

モジュールローダーは、ロードの重要な機能であるモジュール実行機能を提供し
ます。インポート機構は、実行しようとするモジュールオブジェクトを単一の引
数として *note importlib.abc.Loader.exec_module(): 836. メソッドを呼び出
します。 *note importlib.abc.Loader.exec_module(): 836. から返された任意
の値は無視されます。

ローダーは以下の仕様を満たしていなければいけません:

   * モジュールが (組み込みモジュールや動的に読み込まれる拡張モジュール
     ではなくて) Python モジュールだった場合、ローダーはモジュールのグロ
     ーバル名前空間 (‘module.__dict__’) で、モジュールのコードを実行すべ
     きです。

   * *note exec_module(): 836. の呼び出し中に *note ImportError: 3f2. 以
     外の例外が送出され、伝播されてきたとしても、モジュールをロードでき
     ない場合は *note ImportError: 3f2. を送出すべきです。

多くの場合、ファインダーとローダーは同じオブジェクトで構いません; そのよ
うな場合では *note find_spec(): 834. メソッドは単に ‘self’ (訳注: オブジ
ェクト自身) を返すだけです。

モジュールローダーは、 *note create_module(): c7c. メソッドを実装するこ
とでロード中にモジュールオブジェクトを作成することを選択できます。このメ
ソッドは、モジュール仕様を引数に取って、ロード中に使う新しいモジュールオ
ブジェクトを返します。 ‘create_module()’ はモジュールオブジェクトに属性
を設定する必要はありません。もしこのメソッドが ‘None’ を返すなら、インポ
ート機構は新しいモジュールを自身で作成します。

Added in version 3.4: ローダーの *note create_module(): c7c. メソッド。

バージョン 3.4 で変更: *note load_module(): 835. メソッドは *note
exec_module(): 836. によって置き換えられ、インポート機構がロードのすべて
の定型的な処理を引き受けました。

既存のローダーとの互換性のため、もしローダーに ‘load_module()’ メソッド
が存在し、かつローダーが ‘exec_module()’ を実装していなければ、インポー
ト機構はローダーの ‘load_module()’ メソッドを使います。しかし、
‘load_module()’ は deprecated であり、ローダーは代わりに ‘exec_module()’
を実装すべきです。

‘load_module()’ メソッドは、モジュールを実行することに加えて上記で説明さ
れたすべての定型的なロード機能を実施しなければなりません。同じ制約が適用
されます。以下は追加の明確化です:

   * *note sys.modules: 18d6. に与えられた名前のモジュールが存在している
     場合、ローダーはその既存のモジュールを使わなければいけません。 (そ
     うしないと *note importlib.reload(): 4e2. は正しく動かないでしょう
     。) 指定されたモジュールが *note sys.modules: 18d6. に存在しない場
     合、ローダーは新しいモジュールオブジェクトを作成し、 *note
     sys.modules: 18d6. に追加しなければいけません。

   * 無限の再帰または複数回のロードを防止するために、ローダーがモジュー
     ルコードを実行する前にモジュールは *note sys.modules: 18d6. に存在
     しなければなりません ('must')。

   * ロード処理に失敗した場合、ローダーは *note sys.modules: 18d6. に追
     加したモジュールを取り除かなければいけませんが、それはロードに失敗
     したモジュール 'のみ' を、そのモジュールがローダー自身に明示的にロ
     ードされた場合に限り、除去しなければなりません。

バージョン 3.5 で変更: ‘exec_module()’ が定義されていて
‘create_module()’ が定義されていない場合、 *note DeprecationWarning:
18a. が送出されるようになりました。

バージョン 3.6 で変更: ‘exec_module()’ が定義されていて
‘create_module()’ が定義されていない場合、 *note ImportError: 3f2. が送
出されるようになりました。

バージョン 3.10 で変更: ‘load_module()’ を使用すると *note
ImportWarning: 4c7. が発生します。


File: python.info,  Node: サブモジュール,  Next: Module specs,  Prev: ローダー,  Up: ロード

4.5.4.2 サブモジュール
......................

サブモジュールをロードするのにどのようなメカニズム (例えば、 ‘importlib’
API 、 ‘import’ または ‘import-from’ ステートメント、またはビルトイン関
数の ‘__import__’) が使われた場合でも、バインディングはサブモジュールオ
ブジェクトを親モジュールの名前空間に配置します。例えば、もしパッケージ
‘spam’ がサブモジュール ‘foo’ を持っていた場合、 ‘spam.foo’ をインポート
した後は ‘spam’ は値がサブモジュールに束縛された属性 ‘foo’ を持ちます。
以下のディレクトリ構造を持っているとしましょう:

     spam/
         __init__.py
         foo.py

そして ‘spam/__init__.py’ は以下のようになっているとします:

     from .foo import Foo

このとき、以下を実行することにより ‘spam’ モジュールの中に ‘foo’ と
‘Foo’ に束縛された名前が置かれます:

     >>> import spam
     >>> spam.foo
     <module 'spam.foo' from '/tmp/imports/spam/foo.py'>
     >>> spam.Foo
     <class 'spam.foo.Foo'>

Python の慣れ親しんだ名前束縛ルールからするとこれは驚きかもしれませんが
、それは実際インポートシステムの基本的な機能です。不変に保たなければなら
ないのは (上記のインポートの後などで) ‘sys.modules['spam']’ と
‘sys.modules['spam.foo']’ が存在する場合、後者が前者の ‘foo’ 属性として
存在しなければならないということです。


File: python.info,  Node: Module specs,  Next: __path__ attributes on modules,  Prev: サブモジュール,  Up: ロード

4.5.4.3 Module specs
....................

インポート機構は、インポートの間 (特にロードの前) に、個々のモジュールに
ついてのさまざまな情報を扱います。情報のほとんどはすべてのモジュールで共
通です。モジュール仕様の目的は、このインポート関連の情報をモジュールの単
位でカプセル化することです。

インポートの際にモジュール仕様を使うことは、インポートシステムコンポーネ
ント間、例えばモジュール仕様を作成するファインダーとそれを実行するローダ
ーの間で状態を転送することを可能にします。最も重要なのは、それによってイ
ンポート機構がロードの定型的な作業を実行できるようになるということです。
これに対して、モジュール仕様なしではローダがその責任を担っていました。

The module's spec is exposed as *note module.__spec__: 1e77.  Setting
‘__spec__’ appropriately applies equally to *note modules initialized
during interpreter startup: 1f5e.  The one exception is ‘__main__’,
where ‘__spec__’ is *note set to None in some cases: 1f5f.

See *note ModuleSpec: 1dcb. for details on the contents of the module
spec.

Added in version 3.4.


File: python.info,  Node: __path__ attributes on modules,  Next: モジュールの repr,  Prev: Module specs,  Up: ロード

4.5.4.4 __path__ attributes on modules
......................................

The *note __path__: 1bd8. attribute should be a (possibly empty) *note
sequence: 4be. of strings enumerating the locations where the package's
submodules will be found.  By definition, if a module has a ‘__path__’
attribute, it is a *note package: 1e7a.

A package's *note __path__: 1bd8. attribute is used during imports of
its subpackages.  Within the import machinery, it functions much the
same as *note sys.path: 38e, i.e.  providing a list of locations to
search for modules during import.  However, ‘__path__’ is typically much
more constrained than ‘sys.path’.

The same rules used for *note sys.path: 38e. also apply to a package's
‘__path__’.  *note sys.path_hooks: fee. (described below) are consulted
when traversing a package's ‘__path__’.

A package's ‘__init__.py’ file may set or alter the package's *note
__path__: 1bd8. attribute, and this was typically the way namespace
packages were implemented prior to PEP 420(1).  With the adoption of PEP
420(2), namespace packages no longer need to supply ‘__init__.py’ files
containing only ‘__path__’ manipulation code; the import machinery
automatically sets ‘__path__’ correctly for the namespace package.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0420/

   (2) https://peps.python.org/pep-0420/


File: python.info,  Node: モジュールの repr,  Next: キャッシュされたバイトコードの無効化,  Prev: __path__ attributes on modules,  Up: ロード

4.5.4.5 モジュールの repr
.........................

デフォルトでは、すべてのモジュールは利用可能な repr を持っています。ただ
しこれは、これまでに説明した属性の設定内容に依存しており、モジュール仕様
によってモジュールオブジェクトの repr をより明示的に制御することができま
す。

もしモジュールが仕様 (‘__spec__’) を持っていれば、インポート機構はそこか
ら repr を生成しようとします。もしそれが失敗するか、または仕様が存在しな
ければ、インポートシステムはモジュールで入手可能なあらゆる情報を使ってデ
フォルトの repr を構築します。それは ‘module.__name__’,
‘module.__file__’, ‘module.__loader__’ を (足りない情報についてはデフォ
ルト値を使って補いながら) repr への入力として使おうと試みます。

これが使われている正確な規則です:

   * モジュールが ‘__spec__’ 属性を持っていれば、仕様に含まれる情報が
     repr を生成するために使われます。 "name", "loader", "origin",
     "has_location" 属性が参照されます。

   * モジュールに ‘__file__’ 属性がある場合は、モジュールの repr の一部
     として使われます。

   * モジュールに ‘__file__’ はないが ‘__loader__’ があり、その値が
     ‘None’ ではない場合は、ローダーの repr がモジュールの repr の一部と
     して使われます。

   * そうでなければ、単にモジュールの ‘__name__’ を repr の中で使います
     。

バージョン 3.12 で変更: Use of ‘module_repr()’, having been deprecated
since Python 3.4, was removed in Python 3.12 and is no longer called
during the resolution of a module's repr.


File: python.info,  Node: キャッシュされたバイトコードの無効化,  Prev: モジュールの repr,  Up: ロード

4.5.4.6 キャッシュされたバイトコードの無効化
............................................

Before Python loads cached bytecode from a ‘.pyc’ file, it checks
whether the cache is up-to-date with the source ‘.py’ file.  By default,
Python does this by storing the source's last-modified timestamp and
size in the cache file when writing it.  At runtime, the import system
then validates the cache file by checking the stored metadata in the
cache file against the source's metadata.

Python also supports "hash-based" cache files, which store a hash of the
source file's contents rather than its metadata.  There are two variants
of hash-based ‘.pyc’ files: checked and unchecked.  For checked
hash-based ‘.pyc’ files, Python validates the cache file by hashing the
source file and comparing the resulting hash with the hash in the cache
file.  If a checked hash-based cache file is found to be invalid, Python
regenerates it and writes a new checked hash-based cache file.  For
unchecked hash-based ‘.pyc’ files, Python simply assumes the cache file
is valid if it exists.  Hash-based ‘.pyc’ files validation behavior may
be overridden with the *note -check-hash-based-pycs: 1c9a. flag.

バージョン 3.7 で変更: Added hash-based ‘.pyc’ files.  Previously,
Python only supported timestamp-based invalidation of bytecode caches.


File: python.info,  Node: パスベース・ファインダー,  Next: 標準のインポートシステムを置き換える,  Prev: ロード,  Up: インポートシステム

4.5.5 パスベース・ファインダー
------------------------------

上で触れた通り、 Python にはいくつかのデフォルトのメタパス・ファインダー
が備わっています。そのうちの 1 つは *note パスベース・ファインダー:
1f59. (*note PathFinder: fed.) と呼ばれ、 *note パスエントリ: 1f64. のリ
ストである *note インポートパス: 1f56. を検索します。それぞれのパスエン
トリは、モジュールを探す場所を指しています。

パスベース・ファインダー自体は何かのインポート方法を知っているわけではあ
りません。その代わりに、個々のパスエントリを走査し、それぞれに特定の種類
のパスの扱いを知っているパスエントリ・ファインダーを関連付けます。

デフォルトのパスエントリ・ファインダーは、ファイルシステム上のモジュール
を見つけるためのすべてのセマンティクスを実装しています。それは Python ソ
ースコード (‘.py’ ファイル) 、Python バイトコード (‘.pyc’ ファイル) 、共
有ライブラリ (例えば ‘.so’ ファイル) などの特別なファイルタイプを処理し
ます。標準ライブラリの *note zipimport: 118. モジュールによってサポート
される場合は、デフォルトのパスエントリ・ファインダーは (共有ライブラリ以
外の) すべてのファイルタイプの zip ファイルからのロードも扱います。

パスエントリはファイルシステム上の場所に限定される必要はありません。URL
やデータベースクエリやその他文字列で指定できる場所を参照することも可能で
す。

パスベース・ファインダーにはフックやプロトコルを追加することができ、それ
によって検索可能なパスエントリの種類を拡張し、カスタマイズすることができ
ます。例えば、ネットワーク上の URL をパスエントリとしてサポートしたい場
合、 web 上のモジュールを見つけるために HTTP の取り扱い方を実装したフッ
クを書くことができます。この (呼び出し可能オブジェクトである) フックは、
下で解説するプロトコルをサポートする *note パスエントリ・ファインダー:
1046. を返します。このプロトコルは web からモジュールのローダーを取得す
るのに使われます。

警告の言葉: この節と前の節の両方で 'ファインダー' という言葉が、 *note
メタパス・ファインダー: 1045. と *note パスエントリ・ファインダー: 1046.
という用語で区別されて使われています。これら 2 種類のファインダーは非常
に似ており、似たプロトコルをサポートし、インポート処理で同じように機能し
ますが、微妙に異なっているのを心に留めておくのは重要です。特に、メタパス
・ファインダーはインポート処理の開始時、 *note sys.meta_path: cf9. の走
査が動くときに動作します。

それとは対照的に、パスエントリ・ファインダーはある意味でパスベース・ファ
インダーの実装詳細であり、実際 *note sys.meta_path: cf9. からパスベース
・ファインダーが取り除かれた場合、パスエントリ・ファインダーの実装は何も
実行されないでしょう。

* Menu:

* パスエントリ・ファインダー::
* パスエントリ・ファインダー・プロトコル::


File: python.info,  Node: パスエントリ・ファインダー,  Next: パスエントリ・ファインダー・プロトコル,  Up: パスベース・ファインダー

4.5.5.1 パスエントリ・ファインダー
..................................

*note パスベース・ファインダー: 1f59. には、文字列 *note パスエントリ:
1f64. で指定された場所の Python モジュールや Python パッケージを見つけ、
ロードする責任があります。ほとんどのパスエントリはファイルシステム上の場
所を指定していますが、そこに制限される必要はありません。

メタパス・ファインダーとして、 *note パスベース・ファインダー: 1f59. に
は前に解説した *note find_spec(): 834. プロトコルが実装されていますが、
これに加えて *note インポートパス: 1f56. からモジュールを見つけ、ロード
する方法をカスタマイズするために使えるフックを提供しています。

*note パスベース・ファインダー: 1f59. は *note sys.path: 38e. 、 *note
sys.path_hooks: fee. 、 *note sys.path_importer_cache: 5ae. という 3 つ
の変数を使います。さらにパッケージオブジェクトの ‘__path__’ 属性も使いま
す。これらによって、インポート処理をカスタマイズする方法が提供されます。

*note sys.path: 38e. contains a list of strings providing search
locations for modules and packages.  It is initialized from the *note
PYTHONPATH: fe8. environment variable and various other installation-
and implementation-specific defaults.  Entries in *note sys.path: 38e.
can name directories on the file system, zip files, and potentially
other "locations" (see the *note site: b5. module) that should be
searched for modules, such as URLs, or database queries.  Only strings
should be present on *note sys.path: 38e.; all other data types are
ignored.

*note パスベース・ファインダー: 1f59. は *note メタパス・ファインダー:
1045. なので、インポート機構は、前で解説したパスベース・ファインダーの
*note find_spec(): fdc. メソッドを呼び出すことで *note インポートパス:
1f56. の検索を始めます。 ‘path’ 引数が *note find_spec(): fdc. に渡され
たときは、それは走査するパス文字列のリスト - 典型的にはそのパッケージの
中でインポートしているパッケージの ‘__path__’ 属性になります。 ‘path’ 引
数が ‘None’ だった場合、それは最上位のインポートであることを示していて、
*note sys.path: 38e. が使われます。

The path based finder iterates over every entry in the search path, and
for each of these, looks for an appropriate *note path entry finder:
1046. (*note PathEntryFinder: 83b.) for the path entry.  Because this
can be an expensive operation (e.g.  there may be ‘stat()’ call
overheads for this search), the path based finder maintains a cache
mapping path entries to path entry finders.  This cache is maintained in
*note sys.path_importer_cache: 5ae. (despite the name, this cache
actually stores finder objects rather than being limited to *note
importer: 1f54. objects).  In this way, the expensive search for a
particular *note path entry: 1f64. location's *note path entry finder:
1046. need only be done once.  User code is free to remove cache entries
from *note sys.path_importer_cache: 5ae. forcing the path based finder
to perform the path entry search again.

path entry がキャッシュの中に無かった場合、 path based finder は *note
sys.path_hooks: fee. の中の呼び出し可能オブジェクトを全て辿ります。 この
リストのそれぞれの *note path entry フック: 1f66. は、検索する path
entry という引数 1 つを渡して呼び出されます。 その呼び出し可能オブジェク
トは path entry を扱える *note path entry finder: 1046. を返すか、 *note
ImportError: 3f2. を送出します。 *note ImportError: 3f2. は、フックが
*note path entry: 1f64. のための *note path entry finder: 1046. を探せな
いことを報せるために path based finder が使います。 この例外は処理されず
、 *note import path: 1f56. を辿っていく処理が続けられます。 フックは引
数として文字列またはバイト列オブジェクトを期待します; バイト列オブジェク
トのエンコーディングはフックに任されていて (例えば、ファイルシステムのエ
ンコーディングの UTF-8 やそれ以外などです) 、フックが引数をデコードでき
なかった場合は *note ImportError: 3f2. を送出すべきです。

*note sys.path_hooks: fee. を辿る処理が *note
パスエントリ・ファインダー: 1046. を何も返さずに終わった場合、パスベース
・ファインダーの *note find_spec(): fdc. メソッドは、 *note
sys.path_importer_cache: 5ae. に (このパスエントリに対するファインダーが
存在しないことを示すために) ‘None’ を保存し、 *note
メタパス・ファインダー: 1045. はモジュールが見つからなかったことを伝える
ために ‘None’ を返します。

*note sys.path_hooks: fee. 上の *note パスエントリフック: 1f66. 呼び出し
可能オブジェクトの戻り値のいずれかが *note パスエントリ・ファインダー:
1046. 'であった' 場合、後で出てくるモジュール仕様を探すためのプロトコル
が使われ、それがモジュールをロードするために使われます。

（空の文字列によって表される）現在のディレクトリは、 *note sys.path:
38e. の他のエントリとは多少異なる方法で処理されます。まず、現在のディレ
クトリが存在しないことが判明した場合、 *note sys.path_importer_cache:
5ae. には何も追加されません。次に、現在のディレクトリに対する値は個々の
モジュールのルックアップで毎回新たに検索されます。 3番目に、 *note
sys.path_importer_cache: 5ae. に使われ、 *note
importlib.machinery.PathFinder.find_spec(): fdc. が返すパスは、実際のデ
ィレクトリであって空の文字列ではありません。


File: python.info,  Node: パスエントリ・ファインダー・プロトコル,  Prev: パスエントリ・ファインダー,  Up: パスベース・ファインダー

4.5.5.2 パスエントリ・ファインダー・プロトコル
..............................................

モジュールと初期化されたパッケージのインポートをサポートするため、および
名前空間パッケージのポーションとして提供するために、パスエントリ・ファイ
ンダーは *note find_spec(): 838. メソッドを実装しなければいけません。

*note find_spec(): 838. は 2 つの引数を取ります。インポートしようとして
いるモジュールの完全修飾名と、 (オプションの) 対象モジュールです。
‘find_spec()’ はモジュールに対応する完全に初期化 (populated) された仕様
を返します。この仕様は (1つの例外を除いて) 常に "loader" セットを持って
います。

To indicate to the import machinery that the spec represents a namespace
*note portion: 1f4f, the path entry finder sets
‘submodule_search_locations’ to a list containing the portion.

バージョン 3.4 で変更: *note find_spec(): 838. replaced ‘find_loader()’
and ‘find_module()’, both of which are now deprecated, but will be used
if ‘find_spec()’ is not defined.

古いパスエントリ・ファインダーの中には、 ‘find_spec()’ の代わりにこれら
2 つの deperecated なメソッドのうちのいずれかを実装しているものがあるか
もしれません。これらのメソッドは後方互換性のためにまだ考慮されています。
しかし、パスエントリ・ファインダーに ‘find_spec()’ が実装されていれば、
古いメソッドは無視されます。

‘find_loader()’ takes one argument, the fully qualified name of the
module being imported.  ‘find_loader()’ returns a 2-tuple where the
first item is the loader and the second item is a namespace *note
portion: 1f4f.

他のインポート機構の実装に対する後方互換性のために、多くのパスエントリ・
ファインダーは、メタパス・ファインダーがサポートするのと同じ伝統的な
‘find_module()’ メソッドもサポートしています。しかし、パスエントリ・ファ
インダーの ‘find_module()’ メソッドは、決して ‘path’ 引数では呼び出され
ません (このメソッドは、パスフックの最初の呼び出しから適切なパス情報を記
録する動作が期待されています)。

パスエントリ・ファインダーの ‘find_module()’ メソッドは deprecated です
。なぜなら、その方法ではパスエントリ・ファインダーが名前空間パッケージに
対してポーションを提供することができないからです。もし ‘find_loader()’ と
‘find_module()’ の両方がパスエントリ・ファインダーに存在したら、インポー
トシステムは常に ‘find_module()’ よりも ‘find_loader()’ を優先して呼び出
します。

バージョン 3.10 で変更: Calls to ‘find_module()’ and ‘find_loader()’ by
the import system will raise *note ImportWarning: 4c7.

バージョン 3.12 で変更: ‘find_module()’ and ‘find_loader()’ have been
removed.


File: python.info,  Node: 標準のインポートシステムを置き換える,  Next: Package Relative Imports,  Prev: パスベース・ファインダー,  Up: インポートシステム

4.5.6 標準のインポートシステムを置き換える
------------------------------------------

インポートシステム全体を置き換えるための最も信頼性のある仕組みは、 *note
sys.meta_path: cf9. のデフォルトの内容を削除し、全部をカスタムのメタパス
フックで置き換えるものです。

もし、 import 文の動作だけを変更し、インポートシステムにアクセスする他の
API には影響を与えなくてもよければ、組み込みの *note __import__(): 8a2.
関数を置き換えるだけで十分です。この手法は、ある 1 つのモジュール内だけ
で import 文の動作を変更するのにも用いられます。

(標準のインポートシステム全体を停止するのではなく) すでにメタパスにいる
フックからあるモジュールのインポートを選択的に防ぐためには、 *note
find_spec(): 834. から ‘None’ を返す代わりに、直接 *note
ModuleNotFoundError: b15. を送出するだけで十分です。 ‘None’ を返すのはメ
タパスの走査を続けるべきであることを意味しますが、例外を送出するとすぐに
走査を打ち切ります。


File: python.info,  Node: Package Relative Imports,  Next: __main__ に対する特別な考慮,  Prev: 標準のインポートシステムを置き換える,  Up: インポートシステム

4.5.7 Package Relative Imports
------------------------------

Relative imports use leading dots.  A single leading dot indicates a
relative import, starting with the current package.  Two or more leading
dots indicate a relative import to the parent(s) of the current package,
one level per dot after the first.  For example, given the following
package layout:

     package/
         __init__.py
         subpackage1/
             __init__.py
             moduleX.py
             moduleY.py
         subpackage2/
             __init__.py
             moduleZ.py
         moduleA.py

In either ‘subpackage1/moduleX.py’ or ‘subpackage1/__init__.py’, the
following are valid relative imports:

     from .moduleY import spam
     from .moduleY import spam as ham
     from . import moduleY
     from ..subpackage1 import moduleY
     from ..subpackage2.moduleZ import eggs
     from ..moduleA import foo

Absolute imports may use either the ‘import <>’ or ‘from <> import <>’
syntax, but relative imports may only use the second form; the reason
for this is that:

     import XXX.YYY.ZZZ

should expose ‘XXX.YYY.ZZZ’ as a usable expression, but .moduleY is not
a valid expression.


File: python.info,  Node: __main__ に対する特別な考慮,  Next: 参考資料,  Prev: Package Relative Imports,  Up: インポートシステム

4.5.8 __main__ に対する特別な考慮
---------------------------------

*note __main__: 1. モジュールは、 Python のインポートシステムに関連する
特別なケースです。 *note 他の場所: 1f5e. で言及されているように、
‘__main__’ モジュールは *note sys: c3. や *note builtins: e. などと同様
にインタプリタースタートアップで直接初期化されます。しかし、前者 2 つの
モジュールと違って、 ‘__main__’ は厳密にはビルトインのモジュールとしての
資格を持っていません。これは、 ‘__main__’ が初期化される方法がインタプリ
タが起動されるときのフラグやその他のオプションに依存するためです。

* Menu:

* __main__.__spec__: __main__ __spec__.


File: python.info,  Node: __main__ __spec__,  Up: __main__ に対する特別な考慮

4.5.8.1 __main__.__spec__
.........................

*note __main__: 1. がどのように初期化されるかに依存して、
‘__main__.__spec__’ は適切に設定されることもあれば ‘None’ になることもあ
ります。

Python が *note -m: 5ab. オプションを付けて実行された場合には、
‘__spec__’ は対応するモジュールまたはパッケージのモジュール仕様に設定さ
れます。また、ディレクトリや zip ファイル、または他の *note sys.path:
38e. エントリを実行する処理の一部として ‘__main__’ モジュールがロードさ
れる場合にも ‘__spec__’ が生成 (populate) されます。

*note それ以外のケース: 1c93. では、 ‘__main__.__spec__’ は ‘None’ に設
定されます。これは、 *note __main__: 1. を生成 (populate) するために使わ
れたコードがインポート可能なモジュールと直接一致していないためです:

   - 対話プロンプト

   - *note -c: 5aa. オプション

   - stdin から起動された場合

   - ソースファイルやバイトコードファイルから直接起動された場合

最後のケースでは、たとえ技術的にはファイルがモジュールとして直接インポー
トできた 'としても' ‘__main__.__spec__’ は常に ‘None’ になることに注意し
てください。もし *note __main__: 1. において有効なモジュールメタデータが
必要なら *note -m: 5ab. スイッチを使ってください。

‘__main__’ がインポート可能なモジュールと一致し、 ‘__main__.__spec__’ が
それに応じて設定されていたとしても、それでもなお、この 2 つのモジュール
は別物とみなされることに注意してください。これは、 ‘if __name__ ==
"__main__":’ チェックによって保証されるブロックは、 ‘__main__’ 名前空間
を生成 (populate) するためにモジュールが使用される時にだけ実行され、通常
のインポート時には実行されない、という事実に起因しています。


File: python.info,  Node: 参考資料,  Prev: __main__ に対する特別な考慮,  Up: インポートシステム

4.5.9 参考資料
--------------

Python の初期の頃からすると、インポート機構は目覚ましい発展を遂げました
。 一部細かいところがドキュメントが書かれたときから変わってはいますが、
最初期の パッケージの仕様(1) はまだ読むことができます。

オリジナルの *note sys.meta_path: cf9. の仕様は PEP 302(2) で、その後継
となる拡張が PEP 420(3) です。

PEP 420(4) introduced *note namespace packages: 1bd2. for Python 3.3.
PEP 420(5) also introduced the ‘find_loader()’ protocol as an
alternative to ‘find_module()’.

PEP 366(6) は、メインモジュールでの明示的な相対インポートのために追加し
た ‘__package__’ 属性の解説をしています。

PEP 328(7) は絶対インポート、明示的な相対インポート、および、当初
‘__name__’ で提案し、後に PEP 366(8) が ‘__package__’ で定めた仕様を導入
しました。

PEP 338(9) はモジュールをスクリプトとして実行するときの仕様を定めていま
す。

PEP 451(10) は、モジュール仕様オブジェクトにおけるモジュール毎のインポー
ト状態のカプセル化を追加しています。また、ローダーの定型的な責任のほとん
どをインポート機構に肩代わりさせています。これらの変更により、インポート
システムのいくつかの API が deprecate され、またファインダーとローダーに
は新しいメソッドが追加されました。

脚注
....

   ---------- Footnotes ----------

   (1) https://www.python.org/doc/essays/packages/

   (2) https://peps.python.org/pep-0302/

   (3) https://peps.python.org/pep-0420/

   (4) https://peps.python.org/pep-0420/

   (5) https://peps.python.org/pep-0420/

   (6) https://peps.python.org/pep-0366/

   (7) https://peps.python.org/pep-0328/

   (8) https://peps.python.org/pep-0366/

   (9) https://peps.python.org/pep-0338/

   (10) https://peps.python.org/pep-0451/


File: python.info,  Node: 式 expression,  Next: 単純文 simple statement,  Prev: インポートシステム,  Up: Python 言語リファレンス

4.6 式 (expression)
===================

この章では、Python の式における個々の要素の意味について解説します。

'表記法に関する注意:' この章と以降の章での拡張BNF (extended BNF) 表記は
、字句解析規則ではなく、構文規則を記述するために用いられています。ある構
文規則 (のある表現方法) が、以下の形式

     name ::= othername

で記述されていて、この構文特有の意味付け (semantics) が記述されていない
場合、 ‘name’ の形式をとる構文の意味付けは ‘othername’ の意味付けと同じ
になります。

* Menu:

* 算術変換 (arithmetic conversion): 算術変換 arithmetic conversion.
* アトム、原子的要素 (atom): アトム、原子的要素 atom.
* プライマリ::
* Await 式::
* べき乗演算 (power operator): べき乗演算 power operator.
* 単項算術演算とビット単位演算 (unary arithmetic and bitwise operation): 単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
* 二項算術演算 (binary arithmetic operation): 二項算術演算 binary arithmetic operation.
* シフト演算 (shifting operation): シフト演算 shifting operation.
* ビット単位演算の二項演算 (binary bitwise operation): ビット単位演算の二項演算 binary bitwise operation.
* 比較::
* ブール演算 (boolean operation): ブール演算 boolean operation.
* 代入式: 代入式<2>.
* 条件式 (Conditional Expressions): 条件式 Conditional Expressions.
* ラムダ (lambda): ラムダ lambda.
* 式のリスト::
* 評価順序::
* 演算子の優先順位::


File: python.info,  Node: 算術変換 arithmetic conversion,  Next: アトム、原子的要素 atom,  Up: 式 expression

4.6.1 算術変換 (arithmetic conversion)
--------------------------------------

以下の算術演算子の記述で、「数値引数は共通の型に変換されます」と書かれて
いるとき、組み込み型に対する演算子の実装は以下の通りに動作します:

   * 片方の引数が複素数型であれば、他方は複素数型に変換されます;

   * otherwise, if either argument is a floating-point number, the other
     is converted to floating point;

   * それ以外場合は、両方の引数は整数でなければならず、変換の必要はあり
     ません。

特定の演算子 ('%' 演算子の左引数としての文字列) には、さらに別の規則が適
用されます。拡張は、それ自身の型変換のふるまいを定義していなければなりま
せん。


File: python.info,  Node: アトム、原子的要素 atom,  Next: プライマリ,  Prev: 算術変換 arithmetic conversion,  Up: 式 expression

4.6.2 アトム、原子的要素 (atom)
-------------------------------

atom は、式の一番基本的な要素です。もっとも単純な atom は、識別子または
リテラルです。丸括弧、角括弧、または波括弧で囲われた形式 (form) もまた、
構文上アトムに分類されます。atom の構文は以下のようになります:

     atom      ::= identifier | literal | enclosure
     enclosure ::= parenth_form | list_display | dict_display | set_display
                   | generator_expression | yield_atom

* Menu:

* 識別子 (identifier、または名前 (name)): 識別子 identifier、または名前 name.
* リテラル: リテラル<2>.
* 丸括弧形式 (parenthesized form): 丸括弧形式 parenthesized form.
* リスト、集合、辞書の表示::
* リスト表示::
* 集合表示::
* 辞書表示::
* ジェネレータ式: ジェネレータ式<2>.
* Yield 式::


File: python.info,  Node: 識別子 identifier、または名前 name,  Next: リテラル<2>,  Up: アトム、原子的要素 atom

4.6.2.1 識別子 (identifier、または名前 (name))
..............................................

アトムの形になっている識別子 (identifier) は名前 (name) です。字句定義に
ついては *note 識別子 (identifier) およびキーワード (keyword): 1df6. 節
を、名前付けや束縛については *note 名前づけと束縛 (naming and binding):
1e59. 節を参照してください。

名前があるオブジェクトに束縛されている場合、名前 atom を評価するとそのオ
ブジェクトになります。名前が束縛されていない場合、 atom を評価しようとす
ると *note NameError: 40b. 例外を送出します。

* Menu:

* Private name mangling::


File: python.info,  Node: Private name mangling,  Up: 識別子 identifier、または名前 name

4.6.2.2 Private name mangling
.............................

When an identifier that textually occurs in a class definition begins
with two or more underscore characters and does not end in two or more
underscores, it is considered a 'private name' of that class.

参考
....

The *note class specifications: 12a5.

More precisely, private names are transformed to a longer form before
code is generated for them.  If the transformed name is longer than 255
characters, implementation-defined truncation may happen.

The transformation is independent of the syntactical context in which
the identifier is used but only the following private identifiers are
mangled:

   - Any name used as the name of a variable that is assigned or read or
     any name of an attribute being accessed.

     The *note __name__: 103b. attribute of nested functions, classes,
     and type aliases is however not mangled.

   - The name of imported modules, e.g., ‘__spam’ in ‘import __spam’.
     If the module is part of a package (i.e., its name contains a dot),
     the name is 'not' mangled, e.g., the ‘__foo’ in ‘import __foo.bar’
     is not mangled.

   - The name of an imported member, e.g., ‘__f’ in ‘from spam import
     __f’.

The transformation rule is defined as follows:

   - The class name, with leading underscores removed and a single
     leading underscore inserted, is inserted in front of the
     identifier, e.g., the identifier ‘__spam’ occurring in a class
     named ‘Foo’, ‘_Foo’ or ‘__Foo’ is transformed to ‘_Foo__spam’.

   - If the class name consists only of underscores, the transformation
     is the identity, e.g., the identifier ‘__spam’ occurring in a class
     named ‘_’ or ‘__’ is left as is.


File: python.info,  Node: リテラル<2>,  Next: 丸括弧形式 parenthesized form,  Prev: 識別子 identifier、または名前 name,  Up: アトム、原子的要素 atom

4.6.2.3 リテラル
................

Python では、文字列やバイト列リテラルと、様々な数値リテラルをサポートし
ています:

     literal ::= stringliteral | bytesliteral
                 | integer | floatnumber | imagnumber

Evaluation of a literal yields an object of the given type (string,
bytes, integer, floating-point number, complex number) with the given
value.  The value may be approximated in the case of floating-point and
imaginary (complex) literals.  See section *note リテラル: 1e04. for
details.

リテラルは全て変更不能なデータ型に対応します。このため、オブジェクトのア
イデンティティはオブジェクトの値ほど重要ではありません。同じ値を持つ複数
のリテラルを評価した場合、(それらのリテラルがプログラムの同じ場所由来の
ものであっても、そうでなくても) 同じオブジェクトを指しているか、まったく
同じ値を持つ別のオブジェクトになります。


File: python.info,  Node: 丸括弧形式 parenthesized form,  Next: リスト、集合、辞書の表示,  Prev: リテラル<2>,  Up: アトム、原子的要素 atom

4.6.2.4 丸括弧形式 (parenthesized form)
.......................................

丸括弧形式とは、式リストの一形態で、丸括弧で囲ったものです:

     parenth_form ::= "(" [starred_expression] ")"

丸括弧で囲われた式のリストは、個々の式が表現するものになります: リスト内
に少なくとも一つのカンマが入っていた場合、タプルになります; そうでない場
合、式のリストを構成している単一の式自体の値になります。

中身が空の丸括弧のペアは、空のタプルオブジェクトを表します。 タプルは変
更不能なので、リテラルと同じ規則が適用されます (すなわち、空のタプルが二
箇所で使われると、それらは同じオブジェクトになることもあるし、ならないこ
ともあります)。

タプルは丸括弧で作成されるのではなく、カンマによって作成されることに注意
してください。例外は空のタプルで、この場合には丸括弧が '必要です' -- 丸
括弧のつかない "何も記述しない式 (nothing)" を使えるようにしてしまうと、
文法があいまいなものになってしまい、よくあるタイプミスが検出されなくなっ
てしまいます。


File: python.info,  Node: リスト、集合、辞書の表示,  Next: リスト表示,  Prev: 丸括弧形式 parenthesized form,  Up: アトム、原子的要素 atom

4.6.2.5 リスト、集合、辞書の表示
................................

リスト、集合、辞書を構築するために、 Python は "表示 (display)" と呼ばれ
る特別な構文を提供していて、次の二種類ずつがあります:

   * コンテナの内容を明示的に列挙する

   * '内包表記 (comprehension)' と呼ばれる、ループ処理とフィルター処理の
     組み合わせを用いた計算結果

内包表記の共通の構文要素は次の通りです:

     comprehension ::= assignment_expression comp_for
     comp_for      ::= ["async"] "for" target_list "in" or_test [comp_iter]
     comp_iter     ::= comp_for | comp_if
     comp_if       ::= "if" or_test [comp_iter]

内包表記はまず単一の式、続いて少なくとも 1 個の ‘for’ 節、さらに続いて 0
個以上の ‘for’ 節あるいは ‘if’ 節からなります。 この場合、各々の ‘for’ 節
や ‘if’ 節を、左から右へ深くなっていくネストしたブロックとみなし、ネスト
の最内のブロックに到達するごとに内包表記の先頭にある式を評価した結果が、
最終的にできあがるコンテナの各要素になります。

ただし、最も左にある ‘for’ 節のイテラブル式を除いて、内包表記は暗黙的に
ネストされた個別のスコープで実行されます。 この仕組みのおかげで、対象の
リスト内で代入された名前が外側のスコープに "漏れる" ことはありません。

最も左にある ‘for’ 節のイテラブル式は、それを直接囲んでいるスコープでそ
のまま評価され、暗黙的な入れ子のスコープに引数として渡されます。 後に続
く ‘for’ 節と、最も左にある ‘for’ 節のフィルター条件はイテラブル式を直接
囲んでいるスコープでは評価できません。というのは、それらは最も左のイテラ
ブルから得られる値に依存しているかもしれないからです。 例えば次の通りで
す: ‘[x*y for x in range(10) for y in range(x, x+10)]’ 。

内包表記が常に適切な型のコンテナになるのを保証するために、 ‘yield’ 式や
‘yield from’ 式は暗黙的な入れ子のスコープでは禁止されています。

Since Python 3.6, in an *note async def: 59b. function, an ‘async for’
clause may be used to iterate over a *note asynchronous iterator: 190.
A comprehension in an ‘async def’ function may consist of either a ‘for’
or ‘async for’ clause following the leading expression, may contain
additional ‘for’ or ‘async for’ clauses, and may also use *note await:
19e. expressions.

If a comprehension contains ‘async for’ clauses, or if it contains
‘await’ expressions or other asynchronous comprehensions anywhere except
the iterable expression in the leftmost ‘for’ clause, it is called an
'asynchronous comprehension'.  An asynchronous comprehension may suspend
the execution of the coroutine function in which it appears.  See also
PEP 530(1).

Added in version 3.6: 非同期内包表記が導入されました。

バージョン 3.8 で変更: ‘yield’ および ‘yield from’ は暗黙的な入れ子のス
コープでは禁止となりました。

バージョン 3.11 で変更: Asynchronous comprehensions are now allowed
inside comprehensions in asynchronous functions.  Outer comprehensions
implicitly become asynchronous.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0530/


File: python.info,  Node: リスト表示,  Next: 集合表示,  Prev: リスト、集合、辞書の表示,  Up: アトム、原子的要素 atom

4.6.2.6 リスト表示
..................

リスト表示は、角括弧で囲われた式の系列です。系列は空の系列であってもかま
いません:

     list_display ::= "[" [flexible_expression_list | comprehension] "]"

リスト表示は、新しいリストオブジェクトを与えます。リストの内容は、式のリ
ストまたはリスト内包表記 (list comprehension) で指定されます。 カンマで
区切られた式のリストが与えられたときは、それらの各要素は左から右へと順に
評価され、その順にリスト内に配置されます。 内包表記が与えられたときは、
内包表記の結果の要素でリストが構成されます。


File: python.info,  Node: 集合表示,  Next: 辞書表示,  Prev: リスト表示,  Up: アトム、原子的要素 atom

4.6.2.7 集合表示
................

集合表示は波括弧で表され、キーと値を分けるコロンがないことで辞書表現と区
別されます:

     set_display ::= "{" (flexible_expression_list | comprehension) "}"

集合表示は、新しいミュータブルな集合オブジェクトを与えます。集合の内容は
、式の並びまたは内包表記によって指定されます。 カンマ区切りの式のリスト
が与えられたときは、その要素は左から右へ順に評価され、集合オブジェクトに
加えられます。 内包表記が与えられたときは、内包表記の結果の要素で集合が
構成されます。

空集合は ‘{}’ で構成できません。このリテラルは空の辞書を構成します。


File: python.info,  Node: 辞書表示,  Next: ジェネレータ式<2>,  Prev: 集合表示,  Up: アトム、原子的要素 atom

4.6.2.8 辞書表示
................

A dictionary display is a possibly empty series of dict items (key/value
pairs) enclosed in curly braces:

     dict_display       ::= "{" [dict_item_list | dict_comprehension] "}"
     dict_item_list     ::= dict_item ("," dict_item)* [","]
     dict_item          ::= expression ":" expression | "**" or_expr
     dict_comprehension ::= expression ":" expression comp_for

辞書表示は、新たな辞書オブジェクトを表します。

If a comma-separated sequence of dict items is given, they are evaluated
from left to right to define the entries of the dictionary: each key
object is used as a key into the dictionary to store the corresponding
value.  This means that you can specify the same key multiple times in
the dict item list, and the final dictionary's value for that key will
be the last one given.

A double asterisk ‘**’ denotes 'dictionary unpacking'.  Its operand must
be a *note mapping: 118c.  Each mapping item is added to the new
dictionary.  Later values replace values already set by earlier dict
items and earlier dictionary unpackings.

Added in version 3.5: 辞書表示のアンパックは最初に PEP 448(1) で提案され
ました。

辞書内包表記は、リストや集合の内包表記とは対照的に、通常の "for" や "if"
節の前に、コロンで分けられた 2 つの式が必要です。内包表記が起動すると、
結果のキーと値の要素が、作られた順に新しい辞書に挿入されます。

Restrictions on the types of the key values are listed earlier in
section *note 標準型の階層: 1e46.  (To summarize, the key type should be
*note hashable: 5db, which excludes all mutable objects.)  Clashes
between duplicate keys are not detected; the last value (textually
rightmost in the display) stored for a given key value prevails.

バージョン 3.8 で変更: Python 3.8 より前のバージョンでは、辞書内包表記に
おいて、キーと値の評価順序は明示されていませんでした。CPython では、値が
キーより先に評価されていました。バージョン 3.8 からは PEP 572(2) で提案
されているように、キーが値より先に評価されます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0448/

   (2) https://peps.python.org/pep-0572/


File: python.info,  Node: ジェネレータ式<2>,  Next: Yield 式,  Prev: 辞書表示,  Up: アトム、原子的要素 atom

4.6.2.9 ジェネレータ式
......................

ジェネレータ式 (generator expression) とは、丸括弧を使ったコンパクトなジ
ェネレータ表記法です:

     generator_expression ::= "(" expression comp_for ")"

ジェネレータ式は新たなジェネレータオブジェクトを与えます。この構文は内包
表記とほぼ同じですが、角括弧や波括弧ではなく、丸括弧で囲まれます。

ジェネレータ式の中で使われている変数は、 (通常のジェネレータと同じように
) そのジェネレータオブジェクトに対して *note __next__(): 1c2f. メソッド
が呼ばれるときまで評価が遅延されます。 ただし、最も左にある ‘for’ 節のイ
テラブル式は直ちに評価されます。そのためそこで生じたエラーは、最初の値が
得られた時点ではなく、ジェネレータ式が定義された時点で発せられます。 後
に続く ‘for’ 節と、最も左にある ‘for’ 節のフィルター条件はイテラブル式を
直接囲んでいるスコープでは評価できません。というのは、それらは最も左のイ
テラブルから得られる値に依存しているかもしれないからです。 例えば次の通
りです: ‘(x*y for x in range(10) for y in range(x, x+10))’ 。

関数の唯一の引数として渡す場合には、丸括弧を省略できます。詳しくは *note
呼び出し (call): d4a. 節を参照してください。

ジェネレータ式自身の期待される動作を妨げないために、 ‘yield’ 式や ‘yield
from’ 式は暗黙的に定義されたジェネレータでは禁止されています。

ジェネレータ式が ‘async for’ 節あるいは *note await: 19e. 式を含んでいる
場合、それは '非同期ジェネレータ式' と呼ばれます。 非同期ジェネレータ式
は、非同期イテレータである新しい非同期ジェネレータオブジェクトを返します
(*note 非同期イテレータ (Asynchronous Iterator): d47. を参照してください
)。

Added in version 3.6: 非同期ジェネレータ式が導入されました。

バージョン 3.7 で変更: Python 3.7 より前では、非同期ジェネレータ式は
*note async def: 59b. コルーチンでしか使えませんでした。 3.7 からは、任
意の関数で非同期ジェネレータ式が使えるようになりました。

バージョン 3.8 で変更: ‘yield’ および ‘yield from’ は暗黙的な入れ子のス
コープでは禁止となりました。


File: python.info,  Node: Yield 式,  Prev: ジェネレータ式<2>,  Up: アトム、原子的要素 atom

4.6.2.10 Yield 式
.................

     yield_atom       ::= "(" yield_expression ")"
     yield_from       ::= "yield" "from" expression
     yield_expression ::= "yield" yield_list | yield_from

yield 式は *note ジェネレータ: 1035. 関数や *note 非同期ジェネレータ:
1f99. 関数を定義するときに使われます。従って、関数定義の本体でのみ使えま
す。 関数の本体で yield 式 を使用するとその関数はジェネレータ関数になり
、 *note async def: 59b. 関数の本体で使用するとそのコルーチン関数は非同
期ジェネレータ関数になります。 例えば次のようになります:

     def gen():  # defines a generator function
         yield 123

     async def agen(): # defines an asynchronous generator function
         yield 123

含まれているスコープの副作用のため、 ‘yield’ 式は暗黙的に定義されたスコ
ープの一部として内包表記やジェネレータ式を実装するのに使うことは許可され
ていません。

バージョン 3.8 で変更: yield 式は、暗黙的な入れ子のスコープで内包表記や
ジェネレータ式を実装するための使用が禁止になりました。

ジェネレータ関数についてはすぐ下で説明されています。非同期ジェネレータ関
数は、 *note 非同期ジェネレータ関数 (asynchronous generator function):
1f9a. 節に分けて説明されています。

When a generator function is called, it returns an iterator known as a
generator.  That generator then controls the execution of the generator
function.  The execution starts when one of the generator's methods is
called.  At that time, the execution proceeds to the first yield
expression, where it is suspended again, returning the value of *note
yield_list: 1f9b. to the generator's caller, or ‘None’ if *note
yield_list: 1f9b. is omitted.  By suspended, we mean that all local
state is retained, including the current bindings of local variables,
the instruction pointer, the internal evaluation stack, and the state of
any exception handling.  When the execution is resumed by calling one of
the generator's methods, the function can proceed exactly as if the
yield expression were just another external call.  The value of the
yield expression after resuming depends on the method which resumed the
execution.  If *note __next__(): 1c2f. is used (typically via either a
*note for: 2c9. or the *note next(): 7a3. builtin) then the result is
*note None: 641.  Otherwise, if *note send(): 1036. is used, then the
result will be the value passed in to that method.

これまで説明した内容から、ジェネレータ関数はコルーチンにとてもよく似てい
ます。ジェネレータ関数は何度も生成し、1つ以上のエントリポイントを持ち、
その実行は一時停止されます。ジェネレータ関数は yield した後で実行の継続
を制御できないことが唯一の違いです。その制御は常にジェネレータの呼び出し
元へ移されます。

yield 式は *note try: 6b4. 構造内で使用できます。ジェネレータの (参照カ
ウントがゼロに達するか、ガベージコレクションによる) 完了前に再開されない
場合、ジェネレータ-イテレータの *note close(): 1659. メソッドが呼ばれ、
*note finally: 997. 節が実行されます。

‘yield from <expr>’ を使用した場合、与えられた式はイテラブルでなければな
りません。そのイテラブルをイテレートすることで生成された値は現在のジェネ
レータのメソッドの呼び出し元へ直接渡されます。*note send(): 1036. で渡さ
れたあらゆる値と *note throw(): 4c5. で渡されたあらゆる例外は根底のイテ
レータに適切なメソッドがあれば渡されます。適切なメソッドがない場合、
*note send(): 1036. は *note AttributeError: 326. か *note TypeError:
502. を、*note throw(): 4c5. は渡された例外を即座に送出します。

根底のイテレータの完了時、引き起こされた *note StopIteration: bc8. イン
スタンスの *note value: 1f2a. 属性はその yield 式の値となります。 *note
StopIteration: bc8. を起こす際に明示的にセットされるか、サブイテレータが
ジェネレータであれば (サブイテレータからかえる値で) 自動的にセットされる
かのどちらかです。

バージョン 3.3 で変更: サブイテレータに制御フローを委譲するために ‘yield
from <expr>’ が追加されました。

yield 式が代入文の単独の右辺式であるとき、括弧は省略できます。

参考
....

PEP 255(1) - 単純なジェネレータ

     Python へのジェネレータと *note yield: 99b. 文の導入提案。

PEP 342(2) - 拡張されたジェネレータを用いたコルーチン

     シンプルなコルーチンとして利用できるように、ジェネレータの構文と
     API を拡張する提案。

PEP 380(3) - サブジェネレータへの委譲構文

     サブジェネレータの委譲を簡単にするための、 *note yield_from: 1f97.
     構文の導入提案。

PEP 525(4) - 非同期ジェネレータ

     コルーチン関数へのジェネレータの実装能力の追加による PEP 492(5) の
     拡張提案。

* Menu:

* ジェネレータ-イテレータメソッド::
* 使用例::
* 非同期ジェネレータ関数 (asynchronous generator function): 非同期ジェネレータ関数 asynchronous generator function<2>.
* 非同期ジェネレータイテレータメソッド::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0255/

   (2) https://peps.python.org/pep-0342/

   (3) https://peps.python.org/pep-0380/

   (4) https://peps.python.org/pep-0525/

   (5) https://peps.python.org/pep-0492/


File: python.info,  Node: ジェネレータ-イテレータメソッド,  Next: 使用例,  Up: Yield 式

4.6.2.11 ジェネレータ-イテレータメソッド
........................................

この説ではジェネレータイテレータのメソッドについて説明します。これらはジ
ェネレータ関数の実行制御に使用できます。

以下のジェネレータメソッドの呼び出しは、ジェネレータが既に実行中の場合
*note ValueError: 1e3. 例外を送出する点に注意してください。

 -- メソッド: generator.__next__ ()

     Starts the execution of a generator function or resumes it at the
     last executed yield expression.  When a generator function is
     resumed with a *note __next__(): 1c2f. method, the current yield
     expression always evaluates to *note None: 641.  The execution then
     continues to the next yield expression, where the generator is
     suspended again, and the value of the *note yield_list: 1f9b. is
     returned to *note __next__(): 1c2f.'s caller.  If the generator
     exits without yielding another value, a *note StopIteration: bc8.
     exception is raised.

     このメソッドは通常、例えば *note for: 2c9. ループや組み込みの *note
     next(): 7a3. 関数によって暗黙に呼び出されます。

 -- メソッド: generator.send (value)

     ジェネレータ関数の内部へ値を "送り"、実行を再開します。引数の
     'value' はその時点の yield 式の結果になります。 *note send(): 1036.
     メソッドは次にジェネレータが生成した値を返し、ジェネレータが次の値
     を生成することなく終了すると *note StopIteration: bc8. を送出します
     。 *note send(): 1036. が呼び出されてジェネレータが開始するときは、
     値を受け取る yield 式が存在しないので、 *note None: 641. を引数とし
     て呼び出さなければなりません。

 -- メソッド: generator.throw (value)

 -- メソッド: generator.throw (type[, value[, traceback]])

     ジェネレータが中断した位置で例外を発生させて、そのジェネレータ関数
     が生成する次の値を返します。ジェネレータが値を生成することなく終了
     すると *note StopIteration: bc8. が発生します。ジェネレータ関数が渡
     された例外を捕捉しない、もしくは違う例外を発生させるなら、その例外
     は呼び出し元へ伝搬されます。

     In typical use, this is called with a single exception instance
     similar to the way the *note raise: 5b7. keyword is used.

     For backwards compatibility, however, the second signature is
     supported, following a convention from older versions of Python.
     The 'type' argument should be an exception class, and 'value'
     should be an exception instance.  If the 'value' is not provided,
     the 'type' constructor is called to get an instance.  If
     'traceback' is provided, it is set on the exception, otherwise any
     existing *note __traceback__: 1296. attribute stored in 'value' may
     be cleared.

     バージョン 3.12 で変更: The second signature (type[, value[,
     traceback]]) is deprecated and may be removed in a future version
     of Python.

 -- メソッド: generator.close ()

     Raises a *note GeneratorExit: 136f. at the point where the
     generator function was paused.  If the generator function catches
     the exception and returns a value, this value is returned from
     *note close(): 1659.  If the generator function is already closed,
     or raises *note GeneratorExit: 136f. (by not catching the
     exception), *note close(): 1659. returns *note None: 641.  If the
     generator yields a value, a *note RuntimeError: 17a. is raised.  If
     the generator raises any other exception, it is propagated to the
     caller.  If the generator has already exited due to an exception or
     normal exit, *note close(): 1659. returns *note None: 641. and has
     no other effect.

     バージョン 3.13 で変更: If a generator returns a value upon being
     closed, the value is returned by *note close(): 1659.


File: python.info,  Node: 使用例,  Next: 非同期ジェネレータ関数 asynchronous generator function<2>,  Prev: ジェネレータ-イテレータメソッド,  Up: Yield 式

4.6.2.12 使用例
...............

以下の簡単なサンプルはジェネレータとジェネレータ関数の振る舞いを実際に紹
介します:

     >>> def echo(value=None):
     ...     print("Execution starts when 'next()' is called for the first time.")
     ...     try:
     ...         while True:
     ...             try:
     ...                 value = (yield value)
     ...             except Exception as e:
     ...                 value = e
     ...     finally:
     ...         print("Don't forget to clean up when 'close()' is called.")
     ...
     >>> generator = echo(1)
     >>> print(next(generator))
     Execution starts when 'next()' is called for the first time.
     1
     >>> print(next(generator))
     None
     >>> print(generator.send(2))
     2
     >>> generator.throw(TypeError, "spam")
     TypeError('spam',)
     >>> generator.close()
     Don't forget to clean up when 'close()' is called.

‘yield from’ の使用例は、"What's New in Python."  の *note PEP 380;
サブジェネレータへの委譲構文: 1003. を参照してください。


File: python.info,  Node: 非同期ジェネレータ関数 asynchronous generator function<2>,  Next: 非同期ジェネレータイテレータメソッド,  Prev: 使用例,  Up: Yield 式

4.6.2.13 非同期ジェネレータ関数 (asynchronous generator function)
.................................................................

*note async def: 59b. を使用して定義された関数やメソッドに yield 式があ
ると、その関数は *note 非同期ジェネレータ: 1f99. 関数として定義されます
。

非同期ジェネレータ関数が呼び出されると、非同期ジェネレータオブジェクトと
呼ばれる非同期イテレータが返されます。 そして、そのオブジェクトはジェネ
レータ関数の実行を制御します。 通常、非同期ジェネレータオブジェクトは、
コルーチン関数内の *note async for: a79. 文で使われ、これはジェネレータ
オブジェクトが *note for: 2c9. 文で使われる様子に類似します。

Calling one of the asynchronous generator's methods returns an *note
awaitable: 192. object, and the execution starts when this object is
awaited on.  At that time, the execution proceeds to the first yield
expression, where it is suspended again, returning the value of *note
yield_list: 1f9b. to the awaiting coroutine.  As with a generator,
suspension means that all local state is retained, including the current
bindings of local variables, the instruction pointer, the internal
evaluation stack, and the state of any exception handling.  When the
execution is resumed by awaiting on the next object returned by the
asynchronous generator's methods, the function can proceed exactly as if
the yield expression were just another external call.  The value of the
yield expression after resuming depends on the method which resumed the
execution.  If *note __anext__(): 1f9f. is used then the result is *note
None: 641.  Otherwise, if *note asend(): 8a7. is used, then the result
will be the value passed in to that method.

If an asynchronous generator happens to exit early by *note break: a77,
the caller task being cancelled, or other exceptions, the generator's
async cleanup code will run and possibly raise exceptions or access
context variables in an unexpected context-perhaps after the lifetime of
tasks it depends, or during the event loop shutdown when the
async-generator garbage collection hook is called.  To prevent this, the
caller must explicitly close the async generator by calling *note
aclose(): 8a6. method to finalize the generator and ultimately detach it
from the event loop.

非同期ジェネレータ関数では、 *note try: 6b4. 構造内の任意の場所で yield
式が使用できます。 ただし、非同期ジェネレータが、(参照カウントがゼロに達
するか、ガベージコレクションによる) 終了処理より前に再開されない場合、
‘try’ 構造内の yield 式は失敗となり、実行待ちだった *note finally: 997.
節が実行されます。 このケースでは、非同期ジェネレータが作動しているイベ
ントループやスケジューラの責務は、非同期ジェネレータの *note aclose():
8a6. メソッドを呼び出し、残りのコルーチンオブジェクトを実行し、それによ
って実行待ちだった ‘finally’ 節が実行できるようにします。

To take care of finalization upon event loop termination, an event loop
should define a 'finalizer' function which takes an asynchronous
generator-iterator and presumably calls *note aclose(): 8a6. and
executes the coroutine.  This 'finalizer' may be registered by calling
*note sys.set_asyncgen_hooks(): 158a.  When first iterated over, an
asynchronous generator-iterator will store the registered 'finalizer' to
be called upon finalization.  For a reference example of a 'finalizer'
method see the implementation of ‘asyncio.Loop.shutdown_asyncgens’ in
Lib/asyncio/base_events.py(1).

‘yield from <expr>’ 式は、非同期ジェネレータ関数で使われると文法エラーに
なります。

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/base_events.py


File: python.info,  Node: 非同期ジェネレータイテレータメソッド,  Prev: 非同期ジェネレータ関数 asynchronous generator function<2>,  Up: Yield 式

4.6.2.14 非同期ジェネレータイテレータメソッド
.............................................

この小節では、ジェネレータ関数の実行制御に使われる非同期ジェネレータイテ
レータのメソッドについて説明します。

 -- メソッド: coroutine agen.__anext__ ()

     Returns an awaitable which when run starts to execute the
     asynchronous generator or resumes it at the last executed yield
     expression.  When an asynchronous generator function is resumed
     with an *note __anext__(): 1f9f. method, the current yield
     expression always evaluates to *note None: 641. in the returned
     awaitable, which when run will continue to the next yield
     expression.  The value of the *note yield_list: 1f9b. of the yield
     expression is the value of the *note StopIteration: bc8. exception
     raised by the completing coroutine.  If the asynchronous generator
     exits without yielding another value, the awaitable instead raises
     a *note StopAsyncIteration: 1998. exception, signalling that the
     asynchronous iteration has completed.

     このメソッドは通常、 *note for: 2c9. ループによって暗黙に呼び出され
     ます。

 -- メソッド: coroutine agen.asend (value)

     Returns an awaitable which when run resumes the execution of the
     asynchronous generator.  As with the *note send(): 1036. method for
     a generator, this "sends" a value into the asynchronous generator
     function, and the 'value' argument becomes the result of the
     current yield expression.  The awaitable returned by the *note
     asend(): 8a7. method will return the next value yielded by the
     generator as the value of the raised *note StopIteration: bc8, or
     raises *note StopAsyncIteration: 1998. if the asynchronous
     generator exits without yielding another value.  When *note
     asend(): 8a7. is called to start the asynchronous generator, it
     must be called with *note None: 641. as the argument, because there
     is no yield expression that could receive the value.

 -- メソッド: coroutine agen.athrow (value)

 -- メソッド: coroutine agen.athrow (type[, value[, traceback]])

     Returns an awaitable that raises an exception of type ‘type’ at the
     point where the asynchronous generator was paused, and returns the
     next value yielded by the generator function as the value of the
     raised *note StopIteration: bc8. exception.  If the asynchronous
     generator exits without yielding another value, a *note
     StopAsyncIteration: 1998. exception is raised by the awaitable.  If
     the generator function does not catch the passed-in exception, or
     raises a different exception, then when the awaitable is run that
     exception propagates to the caller of the awaitable.

     バージョン 3.12 で変更: The second signature (type[, value[,
     traceback]]) is deprecated and may be removed in a future version
     of Python.

 -- メソッド: coroutine agen.aclose ()

     Returns an awaitable that when run will throw a *note
     GeneratorExit: 136f. into the asynchronous generator function at
     the point where it was paused.  If the asynchronous generator
     function then exits gracefully, is already closed, or raises *note
     GeneratorExit: 136f. (by not catching the exception), then the
     returned awaitable will raise a *note StopIteration: bc8.
     exception.  Any further awaitables returned by subsequent calls to
     the asynchronous generator will raise a *note StopAsyncIteration:
     1998. exception.  If the asynchronous generator yields a value, a
     *note RuntimeError: 17a. is raised by the awaitable.  If the
     asynchronous generator raises any other exception, it is propagated
     to the caller of the awaitable.  If the asynchronous generator has
     already exited due to an exception or normal exit, then further
     calls to *note aclose(): 8a6. will return an awaitable that does
     nothing.


File: python.info,  Node: プライマリ,  Next: Await 式,  Prev: アトム、原子的要素 atom,  Up: 式 expression

4.6.3 プライマリ
----------------

プライマリは、言語において最も結合の強い操作を表します。文法は以下のよう
になります:

     primary ::= atom | attributeref | subscription | slicing | call

* Menu:

* 属性参照::
* 添字表記 (subscription): 添字表記 subscription.
* スライス表記 (slicing): スライス表記 slicing.
* 呼び出し (call): 呼び出し call.


File: python.info,  Node: 属性参照,  Next: 添字表記 subscription,  Up: プライマリ

4.6.3.1 属性参照
................

属性参照は、プライマリの後ろにピリオドと名前を連ねたものです:

     attributeref ::= primary "." identifier

The primary must evaluate to an object of a type that supports attribute
references, which most objects do.  This object is then asked to produce
the attribute whose name is the identifier.  The type and value produced
is determined by the object.  Multiple evaluations of the same attribute
reference may yield different objects.

This production can be customized by overriding the *note
__getattribute__(): ba0. method or the *note __getattr__(): 49f. method.
The ‘__getattribute__()’ method is called first and either returns a
value or raises *note AttributeError: 326. if the attribute is not
available.

If an *note AttributeError: 326. is raised and the object has a
‘__getattr__()’ method, that method is called as a fallback.


File: python.info,  Node: 添字表記 subscription,  Next: スライス表記 slicing,  Prev: 属性参照,  Up: プライマリ

4.6.3.2 添字表記 (subscription)
...............................

The subscription of an instance of a *note container class: 1eeb. will
generally select an element from the container.  The subscription of a
*note generic class: 405. will generally return a *note GenericAlias:
67e. object.

     subscription ::= primary "[" flexible_expression_list "]"

When an object is subscripted, the interpreter will evaluate the primary
and the expression list.

The primary must evaluate to an object that supports subscription.  An
object may support subscription through defining one or both of *note
__getitem__(): 264. and *note __class_getitem__(): 706.  When the
primary is subscripted, the evaluated result of the expression list will
be passed to one of these methods.  For more details on when
‘__class_getitem__’ is called instead of ‘__getitem__’, see *note
__class_getitem__ versus __getitem__: 1ee4.

If the expression list contains at least one comma, or if any of the
expressions are starred, the expression list will evaluate to a *note
tuple: 349. containing the items of the expression list.  Otherwise, the
expression list will evaluate to the value of the list's sole member.

バージョン 3.11 で変更: Expressions in an expression list may be
starred.  See PEP 646(1).

組み込みオブジェクトでは、*note __getitem__(): 264.　によって添字表記を
サポートするオブジェクトには 2 種類あります:

  1. マッピング。プライマリが *note マッピング: 118c. であれば、式リスト
     の値評価結果はマップ内のいずれかのキー値に相当するオブジェクトにな
     らなければなりません。添字表記は、そのキーに対応するマッピング内の
     値 (value) を選択します。組み込みのマッピングクラスの例は *note
     dict: 237. クラスです。

  2. シーケンス。プライマリが *note シーケンス: 4be. であれば、式リスト
     の評価結果は *note int: 238. または *note slice: 436. (以下の節で論
     じます) でなければなりません。組み込みのシーケンスクラスの例には
     *note str: 418.、*note list: 5dc.、*note tuple: 349. クラスが含まれ
     ます。

The formal syntax makes no special provision for negative indices in
*note sequences: 4be.  However, built-in sequences all provide a *note
__getitem__(): 264. method that interprets negative indices by adding
the length of the sequence to the index so that, for example, ‘x[-1]’
selects the last item of ‘x’.  The resulting value must be a nonnegative
integer less than the number of items in the sequence, and the
subscription selects the item whose index is that value (counting from
zero).  Since the support for negative indices and slicing occurs in the
object's *note __getitem__(): 264. method, subclasses overriding this
method will need to explicitly add that support.

*note 文字列: 418. は文字 ('character') を要素とする特別な種類のシーケン
スです。文字は個別の型ではなく、 1 文字だけからなる文字列です。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0646/


File: python.info,  Node: スライス表記 slicing,  Next: 呼び出し call,  Prev: 添字表記 subscription,  Up: プライマリ

4.6.3.3 スライス表記 (slicing)
..............................

スライス表記はシーケンスオブジェクト (文字列、タプルまたはリスト) におけ
るある範囲の要素を選択します。スライス表記は式として用いたり、代入や
*note del: 1711. 文の対象として用いたりできます。スライス表記の構文は以
下のようになります:

     slicing      ::= primary "[" slice_list "]"
     slice_list   ::= slice_item ("," slice_item)* [","]
     slice_item   ::= expression | proper_slice
     proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]
     lower_bound  ::= expression
     upper_bound  ::= expression
     stride       ::= expression

上記の形式的な構文法にはあいまいなところがあります: 式リストに見えるもの
は、スライスリストにも見えるため、添字表記はスライス表記としても解釈され
うるということです。(スライスリストが適切なスライスを含まない場合)、これ
以上の構文の複雑化はせず、スライス表記としての解釈よりも添字表記としての
解釈が優先されるように定義することで、あいまいさを取り除いています。

The semantics for a slicing are as follows.  The primary is indexed
(using the same *note __getitem__(): 264. method as normal subscription)
with a key that is constructed from the slice list, as follows.  If the
slice list contains at least one comma, the key is a tuple containing
the conversion of the slice items; otherwise, the conversion of the lone
slice item is the key.  The conversion of a slice item that is an
expression is that expression.  The conversion of a proper slice is a
slice object (see section *note 標準型の階層: 1e46.) whose *note start:
1eb6, *note stop: 1eb7. and *note step: 1eb8. attributes are the values
of the expressions given as lower bound, upper bound and stride,
respectively, substituting ‘None’ for missing expressions.


File: python.info,  Node: 呼び出し call,  Prev: スライス表記 slicing,  Up: プライマリ

4.6.3.4 呼び出し (call)
.......................

呼び出しは、呼び出し可能オブジェクト (例えば *note function: 1fb4.) を
*note arguments: 415. の系列とともに呼び出します。系列は空の系列であって
もかまいません:

     call                 ::= primary "(" [argument_list [","] | comprehension] ")"
     argument_list        ::= positional_arguments ["," starred_and_keywords]
                                ["," keywords_arguments]
                              | starred_and_keywords ["," keywords_arguments]
                              | keywords_arguments
     positional_arguments ::= positional_item ("," positional_item)*
     positional_item      ::= assignment_expression | "*" expression
     starred_and_keywords ::= ("*" expression | keyword_item)
                              ("," "*" expression | "," keyword_item)*
     keywords_arguments   ::= (keyword_item | "**" expression)
                              ("," keyword_item | "," "**" expression)*
     keyword_item         ::= identifier "=" expression

最後の位置引数やキーワード引数の後にカンマをつけてもかまいません。構文の
意味付けに影響を及ぼすことはありません。

The primary must evaluate to a callable object (user-defined functions,
built-in functions, methods of built-in objects, class objects, methods
of class instances, and all objects having a *note __call__(): 523.
method are callable).  All argument expressions are evaluated before the
call is attempted.  Please refer to section *note 関数定義: 1ba0. for
the syntax of formal *note parameter: 1e5e. lists.

キーワード引数が存在する場合、以下のようにして最初に位置引数 (positional
argument) に変換されます。まず、値の入っていないスロットが仮引数に対して
生成されます。N 個の位置引数がある場合、位置引数は先頭の N スロットに配
置されます。次に、各キーワード引数について、識別子を使って対応するスロッ
トを決定します (識別子が最初の仮引数名と同じなら、最初のスロットを使う、
といった具合です)。スロットがすでにすべて埋まっていたなら *note
TypeError: 502. 例外が送出されます。それ以外の場合、引数をスロットに埋め
ていきます。 (式が ‘None’ であっても、その式でスロットを埋めます)。全て
の引数が処理されたら、まだ埋められていないスロットをそれぞれに対応する関
数定義時のデフォルト値で埋めます。(デフォルト値は、関数が定義されたとき
に一度だけ計算されます; 従って、リストや辞書のような変更可能なオブジェク
トがデフォルト値として使われると、対応するスロットに引数を指定しない限り
、このオブジェクトが全ての呼び出しから共有されます; このような状況は通常
避けるべきです。) デフォルト値が指定されていない、値の埋められていないス
ロットが残っている場合 *note TypeError: 502. 例外が送出されます。そうで
ない場合、値の埋められたスロットからなるリストが呼び出しの引数として使わ
れます。

'CPython 実装の詳細:' 実装では、名前を持たない位置引数を受け取る組み込み
関数を提供されるかもしれません。そういった引数がドキュメント化のために
'名付けられて' いたとしても、実際には名付けられていないのでキーワードで
は提供されません。 CPython では、C 言語で実装された関数の、名前を持たな
い位置引数をパースするために *note PyArg_ParseTuple(): 53d. を使用します
。

仮引数スロットの数よりも多くの位置引数がある場合、構文 ‘*identifier’ を
使って指定された仮引数がないかぎり、 *note TypeError: 502. 例外が送出さ
れます; 仮引数 ‘*identifier’ がある場合、この仮引数は余分な位置引数が入
ったタプル (もしくは、余分な位置引数がない場合には空のタプル) を受け取り
ます。

キーワード引数のいずれかが仮引数名に対応しない場合、構文 ‘**identifier’
を使って指定された仮引数がない限り、 *note TypeError: 502. 例外が送出さ
れます; 仮引数 ‘**identifier’ がある場合、この仮引数は余分なキーワード引
数が入った (キーワードをキーとし、引数値をキーに対応する値とした) 辞書を
受け取ります。余分なキーワード引数がない場合には、空の (新たな) 辞書を受
け取ります。

関数呼び出しに ‘*expression’ という構文が現れる場合は、 ‘expression’ の
評価結果は *note イテラブル: 10ad. でなければなりません。 そのイテラブル
の要素は、追加の位置引数であるかのように扱われます。 ‘f(x1, x2, *y, x3,
x4)’ という呼び出しにおいて、 'y' の評価結果がシーケンス 'y1', ..., 'yM'
だった場合は、この呼び出しは M+4 個の位置引数 'x1', 'x2', 'y1', ...,
'yM', 'x3', 'x4' での呼び出しと同じになります。

この結論としては、 ‘*expression’ 構文がキーワード引数の '後ろ' に来るこ
ともありますが、キーワード引数 (と任意の ‘**expression’ 引数 - 下を参照)
よりも '前' にあるものとして処理されます。 従って、このような動作になり
ます:

     >>> def f(a, b):
     ...     print(a, b)
     ...
     >>> f(b=1, *(2,))
     2 1
     >>> f(a=1, *(2,))
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: f() got multiple values for keyword argument 'a'
     >>> f(1, *(2,))
     1 2

キーワード引数と ‘*expression’ 構文を同じ呼び出しで一緒に使うことはあま
りないので、実際に上記のような混乱が頻繁に生じることはありません。

関数呼び出しで ‘**expression’ 構文が使われた場合、 ‘expression’ の評価結
果は *note マッピング: 118c. でなければなりません。その内容は追加のキー
ワード引数として扱われます。 キーにマッチする引数が (明示的なキーワード
引数によって、あるいは他のアンパックの中で) 既に値を与えられていたなら、
*note TypeError: 502. 例外が送出されます。

When ‘**expression’ is used, each key in this mapping must be a string.
Each value from the mapping is assigned to the first formal parameter
eligible for keyword assignment whose name is equal to the key.  A key
need not be a Python identifier (e.g.  ‘"max-temp °F"’ is acceptable,
although it will not match any formal parameter that could be declared).
If there is no match to a formal parameter the key-value pair is
collected by the ‘**’ parameter, if there is one, or if there is not, a
*note TypeError: 502. exception is raised.

‘*identifier’ や ‘**identifier’ 構文を使った仮引数は、位置引数スロットや
キーワード引数名にすることができません。

バージョン 3.5 で変更: 関数呼び出しは任意の数の ‘*’ アンパックと ‘**’ ア
ンパックを受け取り、位置引数はイテラブルアンパック (‘*’) の後ろに置け、
キーワード引数は辞書アンパック (‘**’) の後ろに置けるようになりました。 最
初に PEP 448(1) で提案されました。

呼び出しを行うと、例外を送出しない限り、常に何らかの値を返します。
‘None’ を返す場合もあります。戻り値がどのように算出されるかは、呼び出し
可能オブジェクトの形態によって異なります。

各形態では--

ユーザ定義関数:

     The code block for the function is executed, passing it the
     argument list.  The first thing the code block will do is bind the
     formal parameters to the arguments; this is described in section
     *note 関数定義: 1ba0.  When the code block executes a *note return:
     99c. statement, this specifies the return value of the function
     call.  If execution reaches the end of the code block without
     executing a *note return: 99c. statement, the return value is
     ‘None’.

組み込み関数またはメソッド:

     結果はインタプリタに依存します; 組み込み関数やメソッドの詳細は
     *note 組み込み関数: 122e. を参照してください。

クラスオブジェクト:

     そのクラスの新しいインスタンスが返されます。

クラスインスタンスメソッド:

     対応するユーザ定義の関数が呼び出されます。このとき、呼び出し時の引
     数リストより一つ長い引数リストで呼び出されます: インスタンスが引数
     リストの先頭に追加されます。

クラスインスタンス:

     The class must define a *note __call__(): 523. method; the effect
     is then the same as if that method was called.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0448/


File: python.info,  Node: Await 式,  Next: べき乗演算 power operator,  Prev: プライマリ,  Up: 式 expression

4.6.4 Await 式
--------------

*note awaitable: 192. オブジェクトでの *note coroutine: 45e. 実行を一時
停止します。 *note coroutine function: d44. 内でのみ使用できます。

     await_expr ::= "await" primary

Added in version 3.5.


File: python.info,  Node: べき乗演算 power operator,  Next: 単項算術演算とビット単位演算 unary arithmetic and bitwise operation,  Prev: Await 式,  Up: 式 expression

4.6.5 べき乗演算 (power operator)
---------------------------------

べき乗演算は、左側にある単項演算子よりも強い結合優先順位となります。一方
、右側にある単項演算子よりは弱い結合優先順位になっています。構文は以下の
ようになります:

     power ::= (await_expr | primary) ["**" u_expr]

従って、べき乗演算子と単項演算子からなる演算列が丸括弧で囲われていない場
合、演算子は右から左へと評価されます (この場合は演算子の評価順序を強制し
ません。つまり ‘-1**2’ は ‘-1’ になります)。

べき乗演算子の意味は、二つの引数で呼び出される組み込み関数 *note pow():
9a0. と同じで、左引数を右引数乗して与えます。数値引数はまず共通の型に変
換され、結果はその型です。

整数の被演算子では、第二引数が負でない限り、結果は被演算子と同じ型になり
ます; 第二引数が負の場合、全ての引数は浮動小数点型に変換され、浮動小数点
型が返されます。例えば ‘10**2’ は ‘100’ を返しますが、‘10**-2’ は ‘0.01’
を返します。

‘0.0’ を負の数でべき乗すると *note ZeroDivisionError: 913. を送出します
。負の数を小数でべき乗した結果は複素数 (*note complex: 2cf. number) にな
ります。 (以前のバージョンでは *note ValueError: 1e3. を送出していました
)

This operation can be customized using the special *note __pow__(): 79e.
and *note __rpow__(): 79f. methods.


File: python.info,  Node: 単項算術演算とビット単位演算 unary arithmetic and bitwise operation,  Next: 二項算術演算 binary arithmetic operation,  Prev: べき乗演算 power operator,  Up: 式 expression

4.6.6 単項算術演算とビット単位演算 (unary arithmetic and bitwise operation)
---------------------------------------------------------------------------

全ての単項算術演算とビット単位演算は、同じ優先順位を持っています:

     u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr

The unary ‘-’ (minus) operator yields the negation of its numeric
argument; the operation can be overridden with the *note __neg__():
1f16. special method.

The unary ‘+’ (plus) operator yields its numeric argument unchanged; the
operation can be overridden with the *note __pos__(): 1f17. special
method.

The unary ‘~’ (invert) operator yields the bitwise inversion of its
integer argument.  The bitwise inversion of ‘x’ is defined as ‘-(x+1)’.
It only applies to integral numbers or to custom objects that override
the *note __invert__(): 1f19. special method.

上記の三つはいずれも、引数が正しい型でない場合には *note TypeError: 502.
例外が送出されます。


File: python.info,  Node: 二項算術演算 binary arithmetic operation,  Next: シフト演算 shifting operation,  Prev: 単項算術演算とビット単位演算 unary arithmetic and bitwise operation,  Up: 式 expression

4.6.7 二項算術演算 (binary arithmetic operation)
------------------------------------------------

二項算術演算は、慣習的な優先順位を踏襲しています。演算子のいずれかは、特
定の非数値型にも適用されるので注意してください。べき乗 (power) 演算子を
除き、演算子には二つのレベル、すなわち乗算的 (multiplicatie) 演算子と加
算的 (additie) 演算子しかありません:

     m_expr ::= u_expr | m_expr "*" u_expr | m_expr "@" m_expr |
                m_expr "//" u_expr | m_expr "/" u_expr |
                m_expr "%" u_expr
     a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr

‘*’ (乗算: multiplication) 演算子は、引数同士の積を与えます。引数は、両
方とも数値であるか、片方が整数で他方がシーケンスかのどちらかでなければな
りません。前者の場合、数値は共通の型に変換された後乗算されます。後者の場
合、シーケンスの繰り返し操作が行われます。繰り返し数を負にすると、空のシ
ーケンスを与えます。

This operation can be customized using the special *note __mul__():
1ef0. and *note __rmul__(): 1ef1. methods.

‘@’ (at) 演算子は行列の乗算に対し使用されます。 Python の組み込み型はこ
の演算子を実装していません。

This operation can be customized using the special *note __matmul__():
1ef8. and *note __rmatmul__(): 1f01. methods.

Added in version 3.5.

‘/’ (除算: division) および ‘//’ (切り捨て除算: floor division) は、引数
同士の商を与えます。数値引数はまず共通の型に変換されます。整数の除算結果
は浮動小数点になりますが、整数の切り捨て除算結果は整数になります; この場
合、結果は数学的な除算に 'floor' 関数 を適用したものになります。ゼロによ
る除算を行うと *note ZeroDivisionError: 913. 例外を送出します。

The division operation can be customized using the special *note
__truediv__(): 149c. and *note __rtruediv__(): 1f02. methods.  The floor
division operation can be customized using the special *note
__floordiv__(): 149d. and *note __rfloordiv__(): 1f03. methods.

The ‘%’ (modulo) operator yields the remainder from the division of the
first argument by the second.  The numeric arguments are first converted
to a common type.  A zero right argument raises the *note
ZeroDivisionError: 913. exception.  The arguments may be floating-point
numbers, e.g., ‘3.14%0.7’ equals ‘0.34’ (since ‘3.14’ equals ‘4*0.7 +
0.34’.)  The modulo operator always yields a result with the same sign
as its second operand (or zero); the absolute value of the result is
strictly smaller than the absolute value of the second operand (1).

切り捨て除算演算と剰余演算は、恒等式: ‘x == (x//y)*y + (x%y)’ の関係にあ
ります。切り捨て除算や剰余はまた、組み込み関数 *note divmod(): 96f.:
‘divmod(x, y) == (x//y, x%y)’ とも関係しています。 (2) 。

‘%’ 演算子は、数値に対する剰余演算を行うのに加えて、文字列 (string) オブ
ジェクトにオーバーロードされ、旧式の文字列の書式化 (いわゆる補間) を行い
ます。文字列の書式化の構文は Python ライブラリリファレンス *note printf
形式の文字列書式化: 698. 節を参照してください。

The 'modulo' operation can be customized using the special *note
__mod__(): 1ef9. and *note __rmod__(): 1f04. methods.

The floor division operator, the modulo operator, and the *note
divmod(): 96f. function are not defined for complex numbers.  Instead,
convert to a floating-point number using the *note abs(): 1c0e. function
if appropriate.

‘+’ (加算) 演算は、引数同士の和を与えます。引数は双方とも数値型か、双方
とも同じ型のシーケンスでなければなりません。前者の場合、数値は共通の型に
変換され、加算されます。後者の場合、シーケンスは結合 (concatenate) され
ます。

This operation can be customized using the special *note __add__():
1eed. and *note __radd__(): 1eee. methods.

‘-’ (減算) 演算は、引数間で減算を行った値を返します。数値引数はまず共通
の型に変換されます。

This operation can be customized using the special *note __sub__():
1ef7. and *note __rsub__(): 1f00. methods.

   ---------- Footnotes ----------

   (1) ‘abs(x%y) < abs(y)’ は数学的には真となりますが、浮動小数点に対す
る演算の場合には、値丸め (roundoff) のために数値計算的に真にならない場合
があります。例えば、Python の浮動小数点型が IEEE754 倍精度数型になってい
るプラットフォームを仮定すると、 ‘-1e-100 % 1e100’ は ‘1e100’ と同じ符号
になるはずなのに、計算結果は ‘-1e-100 + 1e100’ となります。これは数値計
算的には厳密に ‘1e100’ と等価です。関数 *note math.fmod(): 1fc8. は、最
初の引数と符号が一致するような値を返すので、上記の場合には ‘-1e-100’ を
返します。どちらのアプローチが適切かは、アプリケーションに依存します。

   (2) x が y の正確な整数倍に非常に近いと、丸めのために ‘x//y’ が
‘(x-x%y)//y’ よりも 1 だけ大きくなる可能性があります。そのような場合、
Python は ‘divmod(x,y)[0] * y + x % y’ が ‘x’ に非常に近くなるという関係
を保つために、後者の値を返します。


File: python.info,  Node: シフト演算 shifting operation,  Next: ビット単位演算の二項演算 binary bitwise operation,  Prev: 二項算術演算 binary arithmetic operation,  Up: 式 expression

4.6.8 シフト演算 (shifting operation)
-------------------------------------

シフト演算は、算術演算よりも低い優先順位を持っています:

     shift_expr ::= a_expr | shift_expr ("<<" | ">>") a_expr

これらは整数を引数にとります。引数は共通の型に変換されます。シフト演算は
第一引数を、第二引数で与えられたビット数だけ、左または右にビットシフトし
ます。

The left shift operation can be customized using the special *note
__lshift__(): 1efb. and *note __rlshift__(): 1f06. methods.  The right
shift operation can be customized using the special *note __rshift__():
1efc. and *note __rrshift__(): 1f07. methods.

'n' ビットの右シフトは ‘pow(2,n)’ による除算として定義されます。'n' ビッ
トの左シフトは ‘pow(2,n)’ による乗算として定義されます。


File: python.info,  Node: ビット単位演算の二項演算 binary bitwise operation,  Next: 比較,  Prev: シフト演算 shifting operation,  Up: 式 expression

4.6.9 ビット単位演算の二項演算 (binary bitwise operation)
---------------------------------------------------------

以下の三つのビット単位演算には、それぞれ異なる優先順位レベルがあります:

     and_expr ::= shift_expr | and_expr "&" shift_expr
     xor_expr ::= and_expr | xor_expr "^" and_expr
     or_expr  ::= xor_expr | or_expr "|" xor_expr

The ‘&’ operator yields the bitwise AND of its arguments, which must be
integers or one of them must be a custom object overriding *note
__and__(): 1efd. or *note __rand__(): 1f08. special methods.

The ‘^’ operator yields the bitwise XOR (exclusive OR) of its arguments,
which must be integers or one of them must be a custom object overriding
*note __xor__(): 1efe. or *note __rxor__(): 1f09. special methods.

The ‘|’ operator yields the bitwise (inclusive) OR of its arguments,
which must be integers or one of them must be a custom object overriding
*note __or__(): 1eff. or *note __ror__(): 1f0a. special methods.


File: python.info,  Node: 比較,  Next: ブール演算 boolean operation,  Prev: ビット単位演算の二項演算 binary bitwise operation,  Up: 式 expression

4.6.10 比較
-----------

C 言語と違って、Python における比較演算子は同じ優先順位をもっており、全
ての算術演算子、シフト演算子、ビット単位演算子よりも低くなっています。ま
た ‘a < b < c’ が数学で伝統的に用いられているのと同じ解釈になる点も C 言
語と違います:

     comparison    ::= or_expr (comp_operator or_expr)*
     comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="
                       | "is" ["not"] | ["not"] "in"

Comparisons yield boolean values: ‘True’ or ‘False’.  Custom 'rich
comparison methods' may return non-boolean values.  In this case Python
will call *note bool(): 434. on such value in boolean contexts.

比較はいくらでも連鎖することができます。例えば ‘x < y <= z’ は ‘x < y
and y <= z’ と等価になります。ただしこの場合、前者では ‘y’ はただ一度だ
け評価される点が異なります (どちらの場合でも、 ‘x < y’ が偽になると ‘z’
の値はまったく評価されません)。

形式的には、 'a', 'b', 'c', ..., 'y', 'z' が式で 'op1', 'op2', ...,
'opN' が比較演算子である場合、 ‘a op1 b op2 c ... y opN z’ は ‘a op1 b
and b op2 c and ... y opN z’ と等価になります。ただし、前者では各式は多
くても一度しか評価されません。

‘a op1 b op2 c’ と書いた場合、 'a' から 'c' までの範囲にあるかどうかのテ
ストを指すのではないことに注意してください。例えば ‘x < y > z’ は (きれ
いな書き方ではありませんが) 完全に正しい文法です。

* Menu:

* 値の比較::
* 所属検査演算::
* 同一性の比較::


File: python.info,  Node: 値の比較,  Next: 所属検査演算,  Up: 比較

4.6.10.1 値の比較
.................

演算子 ‘<’, ‘>’, ‘==’, ‘>=’, ‘<=’, および ‘!=’ は2つのオブジェクトの値を
比較します。 オブジェクトが同じ型を持つ必要はりません。

*note オブジェクト、値、および型: 1e43. の章では、オブジェクトは (型や
id に加えて) 値を持つことを述べています。 オブジェクトの値は Python では
やや抽象的な概念です: 例えば、オブジェクトの値にアクセスする正統な方法は
ありません。 また、その全てのデータ属性から構成されるなどの特定の方法で
、オブジェクトの値を構築する必要性もありません。 比較演算子は、オブジェ
クトの値とは何かについての特定の概念を実装しています。 この比較の実装に
よって、間接的にオブジェクトの値を定義していると考えることもできます。

Because all types are (direct or indirect) subtypes of *note object:
a5a, they inherit the default comparison behavior from *note object:
a5a.  Types can customize their comparison behavior by implementing
'rich comparison methods' like *note __lt__(): 12d9, described in *note
基本的なカスタマイズ: 1ec0.

等価比較 (‘==’ および ‘!=’) のデフォルトの振る舞いは、オブジェクトの同一
性に基づいています。 従って、同一のインスタンスの等価比較の結果は等しい
となり、同一でないインスタンスの等価比較の結果は等しくないとなります。 デ
フォルトの振る舞いをこのようにしたのは、全てのオブジェクトを反射的
(reflexive つまり ‘x is y’ ならば ‘x == y’) なものにしたかったからです。

デフォルトの順序比較 (‘<’, ‘>’, ‘<=’, ‘>=’) は提供されません; 比較しよう
とすると *note TypeError: 502. が送出されます。 この振る舞いをデフォルト
の振る舞いにした動機は、等価性と同じような不変性が欠けているからです。

同一でないインスタンスは常に等価でないとする等価比較のデフォルトの振る舞
いは、型が必要とするオブジェクトの値や値に基づいた等価性の実用的な定義と
は対照的に思えるでしょう。 そのような型では比較の振る舞いをカスタマイズ
する必要が出てきて、実際にたくさんの組み込み型でそれが行われています。

次のリストでは、最重要の組み込み型の比較の振る舞いを解説しています。

   * いくつかの組み込みの数値型 (*note 数値型 int, float, complex:
     1b63.) と標準ライブラリの型 *note fractions.Fraction: 1c8. および
     *note decimal.Decimal: 27d. は、これらの型の範囲で異なる型とも比較
     できますが、複素数では順序比較がサポートされていないという制限があ
     ります。 関わる型の制限の範囲内では、精度のロス無しに数学的に (アル
     ゴリズム的に) 正しい比較が行われます。

     非数値である ‘float('NaN')’ と ‘decimal.Decimal('NaN')’ は特別です
     。 数と非数値との任意の順序比較は偽です。 直観に反する帰結として、
     非数値は自分自身と等価ではないことになります。 例えば ‘x =
     float('NaN')’ ならば、 ‘3 < x’, ‘x < 3’, ‘x == x’ は全て偽で、‘x !=
     x’ は真です。 この振る舞いは IEEE 754 に従ったものです。

   * ‘None’ and *note NotImplemented: 79d. are singletons.  PEP 8(1)
     advises that comparisons for singletons should always be done with
     ‘is’ or ‘is not’, never the equality operators.

   * バイナリシーケンス (*note bytes: 1a4. または *note bytearray: 508.
     のインスタンス) は、これらの型の範囲で異なる型とも比較できます。 比
     較は要素の数としての値を使った辞書式順序で行われます。

   * 文字列 (*note str: 418. のインスタンス) の比較は、文字の Unicode の
     コードポイントの数としての値 (組み込み関数 *note ord(): 1e51. の返
     り値) を使った辞書式順序で行われます。 (2)

     文字列とバイナリシーケンスは直接には比較できません。

   * シーケンス (*note tuple: 349, *note list: 5dc, or *note range: 911.
     のインスタンス) の比較は、同じ型どうしでしか行えず、 range は順序比
     較をサポートしていません。 異なる型どうしの等価比較の結果は等価でな
     いとなり、異なる型どうしの順序比較は *note TypeError: 502. を送出し
     ます。

     Sequences compare lexicographically using comparison of
     corresponding elements.  The built-in containers typically assume
     identical objects are equal to themselves.  That lets them bypass
     equality tests for identical objects to improve performance and to
     maintain their internal invariants.

     組み込みのコレクションどうしの辞書式比較は次のように動作します:

        - 比較の結果が等価となる2つのコレクションは、同じ型、同じ長さ、
          対応する要素どうしの比較の結果が等価でなければなりません (例え
          ば、 ‘[1,2] == (1,2)’ は型が同じでないので偽です)。

        - 順序比較をサポートしているコレクションの順序は、最初の等価でな
          い要素の順序と同じになります (例えば、 ‘[1,2,x] <= [1,2,y]’ は
          ‘x <= y’ と同じ値になります)。 対応する要素が存在しない場合、
          短い方のコレクションの方が先の順序となります (例えば、 ‘[1,2]
          < [1,2,3]’ は真です)。

   * マッピング (*note dict: 237. のインスタンス) の比較の結果が等価とな
     るのは、同じ ‘(key, value)’ を持っているときかつそのときに限ります
     。 キーと値の等価比較では反射性が強制されます。

     順序比較 (‘<’, ‘>’, ‘<=’, ‘>=’) は *note TypeError: 502. を送出しま
     す。

   * 集合 (*note set: 5a3. または *note frozenset: 5a4. のインスタンス)
     の比較は、これらの型の範囲で異なる型とも行えます。

     集合には、部分集合あるいは上位集合かどうかを基準とする順序比較が定
     義されています。 この関係は全順序を定義しません (例えば、 ‘{1,2}’ と
     ‘{2,3}’ という2つの集合は片方がもう一方の部分集合でもなく上位集合で
     もありません)。 従って、集合は全順序性に依存する関数の引数として適
     切ではありません (例えば、 *note min(): ed3, *note max(): ed4,
     *note sorted(): b9c. は集合のリストを入力として与えると未定義な結果
     となります)。

     集合の比較では、その要素の反射性が強制されます。

   * 他の組み込み型のほとんどは比較メソッドが実装されておらず、デフォル
     トの比較の振る舞いを継承します。

比較の振る舞いをカスタマイズしたユーザ定義クラスは、可能なら次の一貫性の
規則に従う必要があります:

   * 等価比較は反射的でなければなりません。 つまり、同一のオブジェクトは
     等しくなければなりません:

          ‘x is y’ ならば ‘x == y’

   * 比較は対称的でなければなりません。 つまり、以下の式の結果は同じでな
     ければなりません:

          ‘x == y’ と ‘y == x’

          ‘x != y’ と ‘y != x’

          ‘x < y’ と ‘y > x’

          ‘x <= y’ と ‘y >= x’

   * 比較は推移的でなければなりません。 以下の (包括的でない) 例がその説
     明です:

          ‘x > y and y > z’ ならば ‘x > z’

          ‘x < y and y <= z’ ならば ‘x < z’

   * 比較の逆は真偽値の否定でなければなりません。 つまり、以下の式の結果
     は同じでなければなりません:

          ‘x == y’ と ‘not x != y’

          ‘x < y’ と ‘not x >= y’ (全順序の場合)

          ‘x > y’ と ‘not x <= y’ (全順序の場合)

     最後の2式は全順序コレクションに当てはまります (たとえばシーケンスに
     は当てはまりますが、集合やマッピングには当てはまりません)。 *note
     total_ordering(): f0f. デコレータも参照してください。

   * *note hash(): 5b5. の結果は等価性と一貫している必要があります。 等
     価なオブジェクトどうしは同じハッシュ値を持つか、ハッシュ値が計算で
     きないものとされる必要があります。

Python はこの一貫性規則を強制しません。 事実、非数値がこの規則に従わない
例となります。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0008/

   (2) Unicode 標準では、 'コードポイント (code point)' (例えば、U+0041)
と '抽象文字 (abstract character)' (例えば、"LATIN CAPITAL LETTER A") を
区別します。 Unicode のほとんどの抽象文字は 1 つのコードポイントだけを使
って表現されますが、複数のコードポイントの列を使っても表現できる抽象文字
もたくさんあります。 例えば、抽象文字 "LATIN CAPITAL LETTER C WITH
CEDILLA" はコード位置 U+00C7 にある '合成済み文字 (precomposed
character)' 1 つだけでも表現できますし、コード位置 U+0043 (LATIN CAPITAL
LETTER C) にある '基底文字 (base character)' の後ろに、コード位置 U+0327
(COMBINING CEDILLA) にある '結合文字 (combining character)' が続く列とし
ても表現できます。

文字列の比較操作は Unicode のコードポイントのレベルで行われます。 これは
人間にとっては直感的ではないかもしれません。 例えば、 ‘"\u00C7" ==
"\u0043\u0327"’ は、どちらの文字も同じ抽象文字 "LATIN CAPITAL LETTER C
WITH CEDILLA" を表現しているにもかかわらず、その結果は ‘False’ となりま
す。

抽象文字のレベルで (つまり、人間にとって直感的な方法で) 文字列を比較する
には *note unicodedata.normalize(): 6a0. を使ってください。


File: python.info,  Node: 所属検査演算,  Next: 同一性の比較,  Prev: 値の比較,  Up: 比較

4.6.10.2 所属検査演算
.....................

演算子 *note in: 2cb. および *note not in: 5fb. は所属関係を調べます。
‘x in s’ の評価は、 'x' が 's' の要素であれば ‘True’ となり、そうでなけ
れば ‘False’ となります。 ‘x not in s’ は ‘x in s’ の否定を返します。 す
べての組み込みのシーケンス型と集合型に加えて、辞書も ‘in’ を辞書が与えら
れたキーを持っているかを調べる演算子としてサポートしています。 リスト、
タプル、集合、凍結集合、辞書、 collections.deque のようなコンテナ型にお
いて、式 ‘x in y’ は ‘any(x is e or x == e for e in y)’ と等価です。

文字列やバイト列型については、 ‘x in y’ は 'x' が 'y' の部分文字列である
とき、かつそのときに限り ‘True’ になります。これは ‘y.find(x) != -1’ と
等価です。空文字列は、他の任意の文字列の部分文字列とみなされます。従って
‘"" in "abc"’ は ‘True’ を返すことになります。

For user-defined classes which define the *note __contains__(): 1ebe.
method, ‘x in y’ returns ‘True’ if ‘y.__contains__(x)’ returns a true
value, and ‘False’ otherwise.

For user-defined classes which do not define *note __contains__(): 1ebe.
but do define *note __iter__(): 1ebc, ‘x in y’ is ‘True’ if some value
‘z’, for which the expression ‘x is z or x == z’ is true, is produced
while iterating over ‘y’.  If an exception is raised during the
iteration, it is as if *note in: 2cb. raised that exception.

Lastly, the old-style iteration protocol is tried: if a class defines
*note __getitem__(): 264, ‘x in y’ is ‘True’ if and only if there is a
non-negative integer index 'i' such that ‘x is y[i] or x == y[i]’, and
no lower integer index raises the *note IndexError: 14de. exception.
(If any other exception is raised, it is as if *note in: 2cb. raised
that exception).

演算子 *note not in: 5fb. は *note in: 2cb. の真理値を反転した値として定
義されています。


File: python.info,  Node: 同一性の比較,  Prev: 所属検査演算,  Up: 比較

4.6.10.3 同一性の比較
.....................

演算子 *note is: 2cc. および *note is not: 1fd8. は、オブジェクトの同一
性に対するテストを行います: ‘x is y’ は、 'x' と 'y' が同じオブジェクト
を指すとき、かつそのときに限り真になります。 オブジェクトの同一性は
*note id(): 13ca. 関数を使って判定されます。 ‘x is not y’ は *note is:
2cc. の真値を反転したものになります。 (1)

   ---------- Footnotes ----------

   (1) 自動的なガベージコレクション、フリーリスト、ディスクリプタの動的
特性のために、インスタンスメソッドや定数の比較を行うようなときに *note
is: 2cc. 演算子の利用は、一見すると普通ではない振る舞いだと気付くかもし
れません。詳細はそれぞれのドキュメントを確認してください。


File: python.info,  Node: ブール演算 boolean operation,  Next: 代入式<2>,  Prev: 比較,  Up: 式 expression

4.6.11 ブール演算 (boolean operation)
-------------------------------------

     or_test  ::= and_test | or_test "or" and_test
     and_test ::= not_test | and_test "and" not_test
     not_test ::= comparison | "not" not_test

In the context of Boolean operations, and also when expressions are used
by control flow statements, the following values are interpreted as
false: ‘False’, ‘None’, numeric zero of all types, and empty strings and
containers (including strings, tuples, lists, dictionaries, sets and
frozensets).  All other values are interpreted as true.  User-defined
objects can customize their truth value by providing a *note __bool__():
12a3. method.

演算子 *note not: 1fdb. は、引数が偽である場合には ‘True’ を、それ以外の
場合には ‘False’ になります。

式 ‘x and y’ は、まず 'x' を評価します; 'x' が偽なら 'x' の値を返します;
それ以外の場合には、 'y' を評価した結果値を返します。

式 ‘x or y’ は、まず 'x' を評価します; 'x' が真なら 'x' の値を返します;
それ以外の場合には、 'y' を評価した結果値を返します。

なお、 *note and: 2c8. も *note or: 2cd. も、返す値を ‘True’ や ‘False’
に制限せず、最後に評価した引数を返します。 この仕様が便利なときもありま
す。例えば ‘s’ が文字列で、空文字列ならデフォルトの値に置き換えたいとき
、式 ‘s or 'foo'’ は望んだ値を与えます。 *note not: 1fdb. は必ず新しい値
を作成するので、引数の型に関係なくブール値を返します (例えば、 ‘not
'foo'’ は ‘''’ ではなく ‘False’ になります)。


File: python.info,  Node: 代入式<2>,  Next: 条件式 Conditional Expressions,  Prev: ブール演算 boolean operation,  Up: 式 expression

4.6.12 代入式
-------------

     assignment_expression ::= [identifier ":="] expression

An assignment expression (sometimes also called a "named expression" or
"walrus") assigns an *note expression: 1fe1. to an *note identifier:
1df8, while also returning the value of the *note expression: 1fe1.

One common use case is when handling matched regular expressions:

     if matching := pattern.search(data):
         do_something(matching)

Or, when processing a file stream in chunks:

     while chunk := file.read(9000):
         process(chunk)

Assignment expressions must be surrounded by parentheses when used as
expression statements and when used as sub-expressions in slicing,
conditional, lambda, keyword-argument, and comprehension-if expressions
and in ‘assert’, ‘with’, and ‘assignment’ statements.  In all other
places where they can be used, parentheses are not required, including
in ‘if’ and ‘while’ statements.

Added in version 3.8: 代入式に関してより詳しくは PEP 572(1) を参照してく
ださい。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0572/


File: python.info,  Node: 条件式 Conditional Expressions,  Next: ラムダ lambda,  Prev: 代入式<2>,  Up: 式 expression

4.6.13 条件式 (Conditional Expressions)
---------------------------------------

     conditional_expression ::= or_test ["if" or_test "else" expression]
     expression             ::= conditional_expression | lambda_expr

条件式 (しばしば "三項演算子" と呼ばれます) は最も優先度が低いPython の
演算です。

‘x if C else y’ という式は最初に 'x' ではなく条件 'C' を評価します。 'C'
が true の場合 'x' が評価され値が返されます。 それ以外の場合には 'y' が
評価され返されます。

条件演算に関してより詳しくは PEP 308(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0308/


File: python.info,  Node: ラムダ lambda,  Next: 式のリスト,  Prev: 条件式 Conditional Expressions,  Up: 式 expression

4.6.14 ラムダ (lambda)
----------------------

     lambda_expr ::= "lambda" [parameter_list] ":" expression

ラムダ式 (ラムダ形式とも呼ばれます) は無名関数を作成するのに使います。 式
‘lambda parameters: expression’ は関数オブジェクトになります。 この無名
オブジェクトは以下に定義されている関数オブジェクト同様に動作します:

     def <lambda>(parameters):
         return expression

引数の一覧の構文は *note 関数定義: 1ba0. を参照してください。ラムダ式で
作成された関数は文やアノテーションを含むことができない点に注意してくださ
い。


File: python.info,  Node: 式のリスト,  Next: 評価順序,  Prev: ラムダ lambda,  Up: 式 expression

4.6.15 式のリスト
-----------------

     starred_expression       ::= ["*"] or_expr
     flexible_expression      ::= assignment_expression | starred_expression
     flexible_expression_list ::= flexible_expression ("," flexible_expression)* [","]
     starred_expression_list  ::= starred_expression ("," starred_expression)* [","]
     expression_list          ::= expression ("," expression)* [","]
     yield_list               ::= expression_list | starred_expression "," [starred_expression_list]

リスト表示や辞書表示の一部になっているものを除き、少なくとも一つのカンマ
を含む式のリストはタプルになります。 タプルの長さは、リストにある式の数
に等しくなります。 式は左から右へ評価されます。

アスタリスク ‘*’ は 'イテラブルのアンパック' を意味します。 この被演算子
は *note イテラブル: 10ad. でなければなりません。 このイテラブルはアンパ
ックされた位置で要素のシーケンスに展開され、新しいタプル、リスト、集合に
入れ込まれます。

Added in version 3.5: 式リストでのイテラブルのアンパックは最初に PEP
448(1) で提案されました。

Added in version 3.11: Any item in an expression list may be starred.
See PEP 646(2).

A trailing comma is required only to create a one-item tuple, such as
‘1,’; it is optional in all other cases.  A single expression without a
trailing comma doesn't create a tuple, but rather yields the value of
that expression.  (To create an empty tuple, use an empty pair of
parentheses: ‘()’.)

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0448/

   (2) https://peps.python.org/pep-0646/


File: python.info,  Node: 評価順序,  Next: 演算子の優先順位,  Prev: 式のリスト,  Up: 式 expression

4.6.16 評価順序
---------------

Python は、式を左から右へと順に評価します。 ただし、代入式を評価するとき
は、右辺が左辺よりも先に評価されます。

以下に示す実行文の各行での評価順序は、添え字の数字順序と同じになります:

     expr1, expr2, expr3, expr4
     (expr1, expr2, expr3, expr4)
     {expr1: expr2, expr3: expr4}
     expr1 + expr2 * (expr3 - expr4)
     expr1(expr2, expr3, *expr4, **expr5)
     expr3, expr4 = expr1, expr2


File: python.info,  Node: 演算子の優先順位,  Prev: 評価順序,  Up: 式 expression

4.6.17 演算子の優先順位
-----------------------

以下の表は Python における演算子の優先順位を要約したものです。優先順位の
最も高い (結合が最も強い) ものから最も低い (結合が最も弱い) ものに並べて
あります。同じボックス内の演算子の優先順位は同じです。構文が明示的に示さ
れていないものは二項演算子です。同じボックス内の演算子は、左から右へとグ
ループ化されます (例外として、べき乗および条件式は右から左にグループ化さ
れます)。

*note 比較: 1fd1. 節で述べられているように、比較、所属、同一性のテストは
全てが同じ優先順位を持っていて、左から右に連鎖するという特徴を持っている
ことに注意してください。

演算子                                              説明
                                                    
----------------------------------------------------------------------------------------------
                                                    
‘(expressions...)’,                                 結合式または括弧式、リスト表示、辞書表
                                                    示、集合表示
‘[expressions...]’, ‘{key: value...}’,              
‘{expressions...}’

‘x[index]’, ‘x[index:index]’, ‘x(arguments...)’,    添字指定、スライス操作、呼び出し、属性
‘x.attribute’                                       参照
                                                    
                                                    
*note await x: 19e.                                 Await 式
                                                    
                                                    
‘**’                                                べき乗 (1)
                                                    
                                                    
‘+x’, ‘-x’, ‘~x’                                    正数、負数、ビット単位 NOT
                                                    
                                                    
‘*’, ‘@’, ‘/’, ‘//’, ‘%’                            乗算、行列乗算、除算、切り捨て除算、剰
                                                    余 (2)
                                                    
                                                    
‘+’, ‘-’                                            加算および減算
                                                    
                                                    
‘<<’, ‘>>’                                          シフト演算
                                                    
                                                    
‘&’                                                 ビット単位 AND
                                                    
                                                    
‘^’                                                 ビット単位 XOR
                                                    
                                                    
‘|’                                                 ビット単位 OR
                                                    
                                                    
*note in: 2cb, *note not in: 5fb, *note is: 2cc,    所属や同一性のテストを含む比較
*note is not: 1fd8, ‘<’, ‘<=’, ‘>’, ‘>=’, ‘!=’,     
‘==’

*note not x: 1fdb.                                  ブール演算 NOT
                                                    
                                                    
*note and: 2c8.                                     ブール演算 AND
                                                    
                                                    
*note or: 2cd.                                      ブール演算 OR
                                                    
                                                    
*note if: 1fe3. - ‘else’                            条件式
                                                    
                                                    
*note lambda: 126d.                                 ラムダ式
                                                    
                                                    
‘:=’                                                代入式
                                                    

脚注
....

   ---------- Footnotes ----------

   (1) べき乗演算子 ‘**’ は、右側にある単項算術演算子あるいは単項ビット
演算子より弱い結合優先順位となります。 つまり ‘2**-1’ は ‘0.5’ になりま
す。

   (2) ‘%’ 演算子は文字列フォーマットにも使われ、同じ優先順位が当てはま
ります。


File: python.info,  Node: 単純文 simple statement,  Next: 複合文 compound statement,  Prev: 式 expression,  Up: Python 言語リファレンス

4.7 単純文 (simple statement)
=============================

単純文とは、単一の論理行内に収められる文です。単一の行内には、複数の単純
文をセミコロンで区切って入れることができます。単純文の構文は以下の通りで
す:

     simple_stmt ::= expression_stmt
                     | assert_stmt
                     | assignment_stmt
                     | augmented_assignment_stmt
                     | annotated_assignment_stmt
                     | pass_stmt
                     | del_stmt
                     | return_stmt
                     | yield_stmt
                     | raise_stmt
                     | break_stmt
                     | continue_stmt
                     | import_stmt
                     | future_stmt
                     | global_stmt
                     | nonlocal_stmt
                     | type_stmt

* Menu:

* 式文 (expression statement): 式文 expression statement.
* 代入文 (assignment statement): 代入文 assignment statement.
* assert 文::
* pass 文: pass 文<2>.
* del 文: del 文<2>.
* return 文::
* yield 文::
* raise 文::
* break 文::
* continue 文::
* import 文::
* global 文::
* nonlocal 文::
* The type statement::


File: python.info,  Node: 式文 expression statement,  Next: 代入文 assignment statement,  Up: 単純文 simple statement

4.7.1 式文 (expression statement)
---------------------------------

式文は、(主に対話的な使い方では) 値を計算して出力するために使ったり、(通
常は) プロシジャ (procedure: 有意な結果を返さない関数のことです; Python
では、プロシジャは値 ‘None’ を返します) を呼び出すために使います。その他
の使い方でも式文を使うことができますし、有用なこともあります。式文の構文
は以下の通りです:

     expression_stmt ::= starred_expression

式文は式のリスト (単一の式のこともあります) を値評価します。

対話モードでは、値が ‘None’ でなければ、値を組み込み関数 *note repr():
7c8. で文字列に変換して、その結果の文字列を標準出力に一行使って書き出し
ます。 (‘None’ になる式文の値は書き出されないので、プロシジャの呼び出し
を行っても出力は得られません。)


File: python.info,  Node: 代入文 assignment statement,  Next: assert 文,  Prev: 式文 expression statement,  Up: 単純文 simple statement

4.7.2 代入文 (assignment statement)
-----------------------------------

代入文は、名前を値に (再) 束縛したり、変更可能なオブジェクトの属性や要素
を変更したりするために使われます:

     assignment_stmt ::= (target_list "=")+ (starred_expression | yield_expression)
     target_list     ::= target ("," target)* [","]
     target          ::= identifier
                         | "(" [target_list] ")"
                         | "[" [target_list] "]"
                         | attributeref
                         | subscription
                         | slicing
                         | "*" target

('attributeref', 'subscription', 'slicing' の構文については *note
プライマリ: 1fa3. 節を参照してください。)

代入文は式のリスト (これは単一の式でも、カンマで区切られた式リストでもよ
く、後者はタプルになることを思い出してください) を評価し、得られたそれぞ
れのオブジェクトをターゲット (target) のリストに対して左から右へと代入し
てゆきます。

代入はターゲット (リスト) の形式に従って再帰的に行われます。ターゲットが
変更可能なオブジェクト (属性参照、添字表記、またはスライス) の一部である
場合、この変更可能なオブジェクトは最終的に代入を実行して、その代入が有効
な操作であるか判断しなければなりません。代入が不可能な場合には例外を発行
することもできます。型ごとにみられる規則や、送出される例外は、そのオブジ
ェクト型定義で与えられています (*note 標準型の階層: 1e46. 節を参照してく
ださい).

ターゲットリストは、丸括弧や角括弧で囲まれていてもよく、それに対するオブ
ジェクトの代入は、以下のように再帰的に定義されています。

   * ターゲットリストのターゲットが1つだけでコンマが続いておらず、任意に
     丸括弧で囲われている場合、オブジェクトはそのターゲットに代入されま
     す。

   * その他:

        * "星付き"のターゲットと呼ばれる、頭にアスタリスクが一つ付いたタ
          ーゲットがターゲットリストに一つだけ含まれている場合: オブジェ
          クトはイテラブルで、少なくともターゲットリストのターゲットの数
          よりも一つ少ない要素を持たなければなりません。 星付きのターゲ
          ットより前のターゲットに、イテラブルの先頭の要素が左から右へ代
          入されます。 星付きのターゲットより後ろのターゲットに、イテラ
          ブルの末尾の要素が代入されます。 星付きのターゲットに、イテラ
          ブルの残った要素のリストが代入されます (リスト空でもかまいませ
          ん)。

        * そうでない場合: オブジェクトは、ターゲットリストのターゲットと
          同じ数の要素を持つイテラブルでなければならず、要素は左から右へ
          対応するターゲットに代入されます。

単一のターゲットへの単一のオブジェクトの代入は、以下のようにして再帰的に
定義されています。

   * ターゲットが識別子 (名前) の場合:

        * 名前が現在のコードブロック内の *note global: 16f. や *note
          nonlocal: 1279. 文に書かれていないければ: 名前は現在のローカル
          名前空間内のオブジェクトに束縛されます。

        * そうでなければ: 名前はそれぞれグローバル名前空間内か、 *note
          nonlocal: 1279. で決められた外側の名前空間内のオブジェクトに束
          縛されます。

     名前がすでに束縛済みの場合、再束縛 (rebind) がおこなわれます。再束
     縛によって、以前その名前に束縛されていたオブジェクトの参照カウント
     (reference count) がゼロになった場合、オブジェクトは解放
     (deallocate) され、デストラクタ (destructor) が (存在すれば) 呼び出
     されます。

   * ターゲットが属性参照の場合: 参照されている一次語の式が値評価されま
     す。値は代入可能な属性を伴うオブジェクトでなければなりません; そう
     でなければ、 *note TypeError: 502. が送出されます。次に、このオブジ
     ェクトに対して、被代入オブジェクトを指定した属性に代入してよいか問
     い合わせます; 代入を実行できない場合、例外 (通常は *note
     AttributeError: 326. ですが、必然ではありません) を送出します。 注
     意: オブジェクトがクラスインスタンスで、代入演算子の両辺に属性参照
     があるとき、右辺式の ‘a.x’ はインスタンスの属性と (インスタンスの属
     性が存在しなければ) クラス属性のどちらにもアクセスする可能性があり
     ます。左辺のターゲット ‘a.x’ は常にインスタンスの属性として割り当て
     られ、必要ならば生成されます。このとおり、現れる二つの ‘a.x’ は同じ
     値を参照するとは限りません: 右辺式はクラス属性を参照し、左辺は新し
     いインスタンス属性を代入のターゲットとして生成するようなとき:

          class Cls:
              x = 3             # class variable
          inst = Cls()
          inst.x = inst.x + 1   # writes inst.x as 4 leaving Cls.x as 3

     このことは、 *note property(): 179. で作成されたプロパティのような
     デスクリプタ属性に対しては、必ずしもあてはまるとは限りません。

   * ターゲットが添字表記なら: 参照されている一次語式が評価されます。参
     照から (リストのような) ミュータブルなシーケンスオブジェクトか、(辞
     書のような) マッピングオブジェクトが得られなければなりません。次に
     、添字表記の表す式が評価されます。

     一次語が (リストのような) ミュータブルなシーケンスオブジェクトであ
     れば、添字表記は整数を与えなければなりません。整数が負なら、シーケ
     ンスの長さが加算されます。整数は最終的に、シーケンスの長さよりも小
     さな非負の整数でなくてはならず、シーケンスは、そのインデクスに持つ
     要素に被代入オブジェクトを代入してよいか問い合わせられます。インデ
     クスが範囲外なら、 *note IndexError: 14de. が送出されます (添字指定
     されたシーケンスに代入を行っても、リスト要素の新たな追加はできませ
     ん)。

     If the primary is a mapping object (such as a dictionary), the
     subscript must have a type compatible with the mapping's key type,
     and the mapping is then asked to create a key/value pair which maps
     the subscript to the assigned object.  This can either replace an
     existing key/value pair with the same key value, or insert a new
     key/value pair (if no key with the same value existed).

     For user-defined objects, the *note __setitem__(): 146e. method is
     called with appropriate arguments.

   * ターゲットがスライスなら: 参照されている一次語式が評価されます。一
     次語式は、(リストのような) ミュータブルなシーケンスオブジェクトを与
     えなければなりません。被代入オブジェクトは同じ型のシーケンスオブジ
     ェクトでなければなりません。次に、スライスの下限と上限を示す式があ
     れば評価されます; デフォルト値はそれぞれ 0 とシーケンスの長さです。
     上限と下限の評価は整数でなければなりません。いずれかの境界が負数な
     ら、シーケンスの長さが加算されます。最終的に、境界は 0 からシーケン
     スの長さまでに収まるように刈りこまれます。最後に、スライスを被代入
     オブジェクトで置き換えてよいかシーケンスオブジェクトに問い合わせま
     す。ターゲットシーケンスで許されている限り、スライスの長さは被代入
     シーケンスの長さと異なっていてよく、この場合にはターゲットシーケン
     スの長さが変更されます。

'CPython 実装の詳細:' 現在の実装では、ターゲットの構文は式の構文と同じで
あるとみなされており、無効な構文はコード生成フェーズ中に詳細なエラーメッ
セージを伴って拒否されます。

代入の定義によれば、左辺と右辺のオーバーラップは '同時 (simultaneous)' で
す (例えば ‘a, b = b, a’ は二つの変数を入れ替えます) が、代入対象となる
変数群 'どうし' のオーバーラップは左から右へ起こり、混乱の元です。例えば
、以下のプログラムは ‘[0, 2]’ を出力してしまいます:

     x = [0, 1]
     i = 0
     i, x[i] = 1, 2         # i is updated, then x[i] is updated
     print(x)

参考
....

PEP 3132(1) - Extended Iterable Unpacking

     ‘*target’ の指定機能。

* Menu:

* 累算代入文 (augmented assignment statement): 累算代入文 augmented assignment statement.
* 注釈付き代入文 (annotated assignment statements): 注釈付き代入文 annotated assignment statements.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3132/


File: python.info,  Node: 累算代入文 augmented assignment statement,  Next: 注釈付き代入文 annotated assignment statements,  Up: 代入文 assignment statement

4.7.2.1 累算代入文 (augmented assignment statement)
...................................................

累算代入文は、二項演算と代入文を組み合わせて一つの文にしたものです:

     augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)
     augtarget                 ::= identifier | attributeref | subscription | slicing
     augop                     ::= "+=" | "-=" | "*=" | "@=" | "/=" | "//=" | "%=" | "**="
                                   | ">>=" | "<<=" | "&=" | "^=" | "|="

(最後の3つの構文定義については *note プライマリ: 1fa3. を参照してくださ
い。)

累算代入文は、ターゲット (通常の代入文と違って、アンパックは起こりません
) と式リストを評価し、それら二つの被演算子間で特定の累算代入型の二項演算
を行い、結果をもとのターゲットに代入します。ターゲットは一度しか評価され
ません。

An augmented assignment statement like ‘x += 1’ can be rewritten as ‘x =
x + 1’ to achieve a similar, but not exactly equal effect.  In the
augmented version, ‘x’ is only evaluated once.  Also, when possible, the
actual operation is performed 'in-place', meaning that rather than
creating a new object and assigning that to the target, the old object
is modified instead.

通常の代入とは違い、累算代入文は右辺を評価する '前に' 左辺を評価します。
たとえば、‘a[i] += f(x)’ はまず ‘a[i]’ を調べ、‘f(x)’ を評価して加算を行
い、最後に結果を ‘a[i]’ に割り当てます。

累算代入文で行われる代入は、タプルへの代入や、一文中に複数のターゲットが
存在する場合を除き、通常の代入と同じように扱われます。同様に、累算代入で
行われる二項演算は、場合によって 'インプレース演算' が行われることを除き
、通常の二項演算と同じです。

属性参照のターゲットの場合、 *note
クラス属性とインスタンス属性についての注意: 1ffd. と同様に通常の代入が適
用されます。


File: python.info,  Node: 注釈付き代入文 annotated assignment statements,  Prev: 累算代入文 augmented assignment statement,  Up: 代入文 assignment statement

4.7.2.2 注釈付き代入文 (annotated assignment statements)
........................................................

*note 注釈: d23. 代入は、1 つの文の中で変数や属性のアノテーションとオプ
ションの代入文を組み合わせたものです:

     annotated_assignment_stmt ::= augtarget ":" expression
                                   ["=" (starred_expression | yield_expression)]

通常の *note 代入文 (assignment statement): 1f39. との違いは、代入先が 1
つに限定されることだけです。

The assignment target is considered "simple" if it consists of a single
name that is not enclosed in parentheses.  For simple assignment
targets, if in class or module scope, the annotations are evaluated and
stored in a special class or module attribute ‘__annotations__’ that is
a dictionary mapping from variable names (mangled if private) to
evaluated annotations.  This attribute is writable and is automatically
created at the start of class or module body execution, if annotations
are found statically.

If the assignment target is not simple (an attribute, subscript node, or
parenthesized name), the annotation is evaluated if in class or module
scope, but not stored.

関数スコープで名前に注釈が付いていた場合は、その名前はその関数スコープで
ローカルなものになります。 注釈は絶対に評価されず、関数スコープにも格納
されません。

If the right hand side is present, an annotated assignment performs the
actual assignment before evaluating annotations (where applicable).  If
the right hand side is not present for an expression target, then the
interpreter evaluates the target except for the last *note
__setitem__(): 146e. or *note __setattr__(): 1e8d. call.

参考
....

PEP 526(1) - Syntax for Variable Annotations

     (クラス変数やインスタンス変数を含んだ) 変数の型注釈を付ける、コメン
     トで表現するのではない文法の追加提案。

PEP 484(2) - Type hints

     *note typing: ed. モジュールを追加し、静的解析ツールや IDE で使える
     型アノテーションの標準的な文法を提供する提案。

バージョン 3.8 で変更: Now annotated assignments allow the same
expressions in the right hand side as regular assignments.  Previously,
some expressions (like un-parenthesized tuple expressions) caused a
syntax error.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0526/

   (2) https://peps.python.org/pep-0484/


File: python.info,  Node: assert 文,  Next: pass 文<2>,  Prev: 代入文 assignment statement,  Up: 単純文 simple statement

4.7.3 ‘assert’ 文
-----------------

assert 文は、プログラム内にデバッグ用アサーション (debugging assertion)
を仕掛けるための便利な方法です:

     assert_stmt ::= "assert" expression ["," expression]

単純な形式 ‘assert expression’ は

     if __debug__:
         if not expression: raise AssertionError

と等価です。拡張形式 ‘assert expression1, expression2’ は、これと等価で
す

     if __debug__:
         if not expression1: raise AssertionError(expression2)

上記の等価関係は、 *note __debug__: 7a5. と *note AssertionError: 675. が
、同名の組み込み変数を参照しているという前提の上に成り立っています。現在
の実装では、組み込み変数 *note __debug__: 7a5. は通常の状況では ‘True’ で
あり、最適化が要求された場合（コマンドラインオプション *note -O: d82.）
は ‘False’ です。現状のコード生成器は、コンパイル時に最適化が要求されて
いると assert 文のコードを一切出力しません。実行に失敗した式のソースコー
ドをエラーメッセージ内に入れる必要はありません; コードはスタックトレース
内で表示されます。

*note __debug__: 7a5. への代入は不正な操作です。組み込み変数の値は、イン
タプリタが開始するときに決定されます。


File: python.info,  Node: pass 文<2>,  Next: del 文<2>,  Prev: assert 文,  Up: 単純文 simple statement

4.7.4 ‘pass’ 文
---------------

     pass_stmt ::= "pass"

*note pass: 1b84. はヌル操作 (null operation) です -- *note pass: 1b84.
が実行されても、何も起きません。 *note pass: 1b84. は、構文法的には文が
必要だが、コードとしては何も実行したくない場合のプレースホルダとして有用
です。例えば:

     def f(arg): pass    # a function that does nothing (yet)

     class C: pass       # a class with no methods (yet)


File: python.info,  Node: del 文<2>,  Next: return 文,  Prev: pass 文<2>,  Up: 単純文 simple statement

4.7.5 ‘del’ 文
--------------

     del_stmt ::= "del" target_list

オブジェクトの削除 (deletion) は、代入の定義と非常に似た方法で再帰的に定
義されています。ここでは完全な詳細は記述せず、いくつかのヒントを述べるに
とどめます。

ターゲットリストに対する削除は、各々のターゲットを左から右へと順に再帰的
に削除します。

名前の削除は、ローカルまたはグローバル名前空間からその名前の束縛を取り除
きます。どちらの名前空間かは、名前が同じコードブロック内の *note global:
16f. 文で宣言されているかどうかによります。名前が未束縛 (unbound) なら、
*note NameError: 40b. 例外が送出されます。

属性参照、添字表記、およびスライスの削除操作は、対象となる一次語オブジェ
クトに渡されます; スライスの削除は一般的には適切な型の空のスライスを代入
するのと等価です (が、この仕様自体もスライスされるオブジェクトで決定され
ています)。

バージョン 3.2 で変更: 以前は、ある名前がネストしたブロックの自由変数と
して表れる場合は、ローカル名前空間からその名前を削除することは不正な処理
でした。


File: python.info,  Node: return 文,  Next: yield 文,  Prev: del 文<2>,  Up: 単純文 simple statement

4.7.6 ‘return’ 文
-----------------

     return_stmt ::= "return" [expression_list]

*note return: 99c. は、関数定義内で構文法的にネストして現れますが、ネス
トしたクラス定義内には現れません。

式リストがある場合、リストが値評価されます。それ以外の場合は ‘None’ で置
き換えられます。

*note return: 99c. を使うと、式リスト (または ‘None’) を戻り値として、現
在の関数呼び出しから抜け出します。

*note return: 99c. によって、 *note finally: 997. 節をともなう *note
try: 6b4. 文の外に処理が引き渡されると、実際に関数から抜ける前に
‘finally’ 節が実行されます。

ジェネレータ関数では、 *note return: 99c. 文はジェネレータの終わりを示し
、 *note StopIteration: bc8. 例外を送出させます。返された値は (あれば)、
*note StopIteration: bc8. を構成する引数に使われ、 *note
StopIteration.value: 1f2a. 属性になります。

非同期ジェネレータ関数では、引数無しの *note return: 99c. 文は非同期ジェ
ネレータの終わりを示し、 *note StopAsyncIteration: 1998. を送出させます
。 引数ありの ‘return’ 文は、非同期ジェネレータ関数では文法エラーです。


File: python.info,  Node: yield 文,  Next: raise 文,  Prev: return 文,  Up: 単純文 simple statement

4.7.7 ‘yield’ 文
----------------

     yield_stmt ::= yield_expression

*note yield: 99b. 文は意味的に *note yield 式: 1f95. と同じです。yield 文
を用いると yield 式文で必要な括弧を省略することが出来ます。例えば、yield
文

     yield <expr>
     yield from <expr>

は以下の yield 式文と等価です

     (yield <expr>)
     (yield from <expr>)

yield 式及び文は *note generator: 1035. を定義するときに、その本体内での
み使うことが出来ます。関数定義内で yield を使用することで、その定義は通
常の関数でなくジェネレータ関数になります。

*note yield: 99b. の意味の完全な説明は、 *note Yield 式: 1f95. 節を参照
してください。


File: python.info,  Node: raise 文,  Next: break 文,  Prev: yield 文,  Up: 単純文 simple statement

4.7.8 ‘raise’ 文
----------------

     raise_stmt ::= "raise" [expression ["from" expression]]

If no expressions are present, *note raise: 5b7. re-raises the exception
that is currently being handled, which is also known as the 'active
exception'.  If there isn't currently an active exception, a *note
RuntimeError: 17a. exception is raised indicating that this is an error.

そうでなければ、 *note raise: 5b7. は最初の式を、例外オブジェクトとして
評価します。これは、 *note BaseException: 584. のサブクラスまたはインス
タンスでなければなりません。クラスなら、例外インスタンスが必要なとき、ク
ラスを無引数でインスタンス化することで得られます。

例外の '型' は例外インスタンスのクラスで、 '値' はインスタンスそのもので
す。

A traceback object is normally created automatically when an exception
is raised and attached to it as the *note __traceback__: 1296.
attribute.  You can create an exception and set your own traceback in
one step using the *note with_traceback(): 2012. exception method (which
returns the same exception instance, with its traceback set to its
argument), like so:

     raise Exception("foo occurred").with_traceback(tracebackobj)

The ‘from’ clause is used for exception chaining: if given, the second
'expression' must be another exception class or instance.  If the second
expression is an exception instance, it will be attached to the raised
exception as the *note __cause__: 1298. attribute (which is writable).
If the expression is an exception class, the class will be instantiated
and the resulting exception instance will be attached to the raised
exception as the ‘__cause__’ attribute.  If the raised exception is not
handled, both exceptions will be printed:

     >>> try:
     ...     print(1 / 0)
     ... except Exception as exc:
     ...     raise RuntimeError("Something bad happened") from exc
     ...
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
         print(1 / 0)
               ~~^~~
     ZeroDivisionError: division by zero

     The above exception was the direct cause of the following exception:

     Traceback (most recent call last):
       File "<stdin>", line 4, in <module>
         raise RuntimeError("Something bad happened") from exc
     RuntimeError: Something bad happened

A similar mechanism works implicitly if a new exception is raised when
an exception is already being handled.  An exception may be handled when
an *note except: 170. or *note finally: 997. clause, or a *note with:
59c. statement, is used.  The previous exception is then attached as the
new exception's *note __context__: 1297. attribute:

     >>> try:
     ...     print(1 / 0)
     ... except:
     ...     raise RuntimeError("Something bad happened")
     ...
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
         print(1 / 0)
               ~~^~~
     ZeroDivisionError: division by zero

     During handling of the above exception, another exception occurred:

     Traceback (most recent call last):
       File "<stdin>", line 4, in <module>
         raise RuntimeError("Something bad happened")
     RuntimeError: Something bad happened

Exception chaining can be explicitly suppressed by specifying *note
None: 641. in the ‘from’ clause:

     >>> try:
     ...     print(1 / 0)
     ... except:
     ...     raise RuntimeError("Something bad happened") from None
     ...
     Traceback (most recent call last):
       File "<stdin>", line 4, in <module>
     RuntimeError: Something bad happened

例外に関する追加情報は *note 例外: 1f45. 節にあります。また、例外処理に
関する情報は *note try 文: 6b4. 節にあります。

バージョン 3.3 で変更: *note None: 641. が ‘raise X from Y’ の ‘Y’ とし
て使えるようになりました。

Added the *note __suppress_context__: 2013. attribute to suppress
automatic display of the exception context.

バージョン 3.11 で変更: If the traceback of the active exception is
modified in an *note except: 170. clause, a subsequent ‘raise’ statement
re-raises the exception with the modified traceback.  Previously, the
exception was re-raised with the traceback it had when it was caught.


File: python.info,  Node: break 文,  Next: continue 文,  Prev: raise 文,  Up: 単純文 simple statement

4.7.9 ‘break’ 文
----------------

     break_stmt ::= "break"

*note break: a77. 文は、構文としては *note for: 2c9. ループや *note
while: 1b6e. ループの内側でのみ出現することができますが、ループ内の関数
定義やクラス定義の内側には出現できません。

*note break: a77. 文は、文を囲う最も内側のループを終了させ、ループにオプ
ションの ‘else’ 節がある場合にはそれをスキップします。

*note for: 2c9. ループを *note break: a77. によって終了すると、ループ制
御ターゲットはその時の値を保持します。

*note break: a77. が *note finally: 997. 節を伴う *note try: 6b4. 文の外
側に処理を渡す際には、ループを実際に抜ける前にその ‘finally’ 節が実行さ
れます。


File: python.info,  Node: continue 文,  Next: import 文,  Prev: break 文,  Up: 単純文 simple statement

4.7.10 ‘continue’ 文
--------------------

     continue_stmt ::= "continue"

*note continue: 998. 文は *note for: 2c9. ループや *note while: 1b6e. ル
ープ内のネストで構文法的にのみ現れますが、ループ内の関数定義やクラス定義
の中には現れません。 *note continue: 998. 文は、文を囲う最も内側のループ
の次の周期に処理を継続します。

*note continue: 998. が *note finally: 997. 句を持った *note try: 6b4. 文
を抜けるとき、その ‘finally’ 句が次のループサイクルを始める前に実行され
ます。


File: python.info,  Node: import 文,  Next: global 文,  Prev: continue 文,  Up: 単純文 simple statement

4.7.11 ‘import’ 文
------------------

     import_stmt     ::= "import" module ["as" identifier] ("," module ["as" identifier])*
                         | "from" relative_module "import" identifier ["as" identifier]
                         ("," identifier ["as" identifier])*
                         | "from" relative_module "import" "(" identifier ["as" identifier]
                         ("," identifier ["as" identifier])* [","] ")"
                         | "from" relative_module "import" "*"
     module          ::= (identifier ".")* identifier
     relative_module ::= "."* module | "."+

(*note from: 127d. 節が無い) 基本の import 文は 2 つのステップで実行され
ます:

  1. モジュールを見付け出し、必要であればロードし初期化する

  2. *note import: 5ac. 文が表れるスコープのローカル名前空間で名前を定義
     する。

文が (カンマで区切られた) 複数の節を含んでいるときは、ちょうどその節が個
別の import 文に分割されたかのように、2つのステップが節ごとに個別に実行
されます。

モジュールを見付け、ロードする 1 つ目のステップの詳細については、 *note
インポートシステム: 1e73. の節により詳しく書かれています。そこでは、イン
ポートシステムの動作をカスタマイズするのに使える全てのフックの仕組みだけ
でなく、様々な種類のインポートできるパッケージとモジュールについても解説
されています。このステップが失敗するということは、おそらくモジュールが見
付からないか、 'あるいは' モジュールにあるコードの実行を含め、モジュール
の初期化の途中でエラーが起きるかのどちらかが起きていることに注意してくだ
さい。

要求したモジュールが無事に取得できた場合、次の 3 つのうちの 1 つの方法で
ローカル名前空間で使えるようになります:

   * モジュール名の後に ‘as’ が続いていた場合は、 ‘as’ の後ろの名前を直
     接、インポートされたモジュールが束縛します。

   * 他の名前が指定されておらず、インポートされているモジュールが最上位
     のモジュールだった場合、そのモジュール名がインポートされたモジュー
     ルへの参照として、ローカル名前空間で束縛されます

   * インポートされているモジュールが最上位のモジュール 'でない' 場合、
     モジュールを含む最上位のパッケージ名が、そのパッケージへの参照とし
     て、ローカル名前空間で束縛されます。インポートされたモジュールには
     、直接ではなく完全修飾名を使ってアクセスしなければなりません

*note from: 127d. 形式ではもう少し複雑な手順を踏みます:

  1. *note from: 127d. 節で指定されたモジュールを見付け出し、必要であれ
     ばロードし初期化する;

  2. *note import: 5ac. 節で指定されたそれぞれの識別子に対し以下の処理を
     行う:

       1. インポートされたモジュールがその識別子名の属性を持っているかを
          確認する

       2. その識別子名の属性を持っていなかった場合は、その識別子名でサブ
          モジュールのインポートを試み、インポートされたモジュールにその
          属性があるか再度確認する

       3. 属性が見付からない場合は、 *note ImportError: 3f2. を送出する
          。

       4. 属性が見付かった場合は、 ‘as’ 節があるならそこの名前、そうでな
          いなら属性名を使って、その値への参照がローカル名前空間に保存さ
          れる

例:

     import foo                 # foo imported and bound locally
     import foo.bar.baz         # foo, foo.bar, and foo.bar.baz imported, foo bound locally
     import foo.bar.baz as fbb  # foo, foo.bar, and foo.bar.baz imported, foo.bar.baz bound as fbb
     from foo.bar import baz    # foo, foo.bar, and foo.bar.baz imported, foo.bar.baz bound as baz
     from foo import attr       # foo imported and foo.attr bound as attr

識別子のリストが星 (‘'*'’) に置き換わっている場合は、モジュールで定義さ
れている公開された全ての名前が、 *note import: 5ac. 文がいるスコープのロ
ーカル名前空間に束縛されます。

モジュールで定義される '公開された名前' は、モジュールの名前空間にある
‘__all__’ という名前の変数を調べることで決定されます; その変数が定義され
ている場合は、それはモジュールで定義されたかインポートされた名前からなる
、文字列のシーケンスでなければいけません。‘__all__’ で列挙された名前は、
全て公開されていると見なされ、存在することが要求されます。‘__all__’ が定
義されていない場合、公開された名前とは、モジュールの名前空間で見付かった
、アンダースコア文字 (‘'_'’) で始まらない全ての名前のことです。‘__all__’
は全ての公開 API を含むべきです。これは API の一部でないもの (そのモジュ
ールでインポートされ使われているライブラリモジュールなど) をうっかり外部
に公開してしまわないための仕組みです。

インポートのワイルドカード形式 -- ‘from module import *’ -- は、モジュー
ルレベルでのみ許されます。クラスや関数定義でこの形式を使おうとすると、
*note SyntaxError: 172. が送出されます。

インポートするモジュールを指定するとき、そのモジュールの絶対名 (absolute
name) を指定する必要はありません。モジュールやパッケージが他のパッケージ
に含まれている場合、共通のトップパッケージからそのパッケージ名を記述する
ことなく相対インポートすることができます。 *note from: 127d. の後に指定
されるモジュールやパッケージの先頭に複数個のドットを付けることで、正確な
名前を指定することなしに現在のパッケージ階層からいくつ上の階層へ行くかを
指定することができます。先頭のドットが 1 つの場合、 import をおこなって
いるモジュールが存在する現在のパッケージを示します。 3 つのドットは 2 つ
上のレベルを示します。なので、 ‘pkg’ パッケージの中のモジュールで ‘from
. import mod’ を実行すると、 ‘pkg.mod’ をインポートすることになります。
‘pkg.subpkg1’ の中から ‘from ..subpkg2 import mod’ を実行すると、
‘pkg.subpkg2.mod’ をインポートします。相対インポートの仕様は *note
Package Relative Imports: 1f6a. の節に含まれています。

どのモジュールがロードされるべきかを動的に決めたいアプリケーションのため
に、組み込み関数 *note importlib.import_module(): 4e1. が提供されていま
す。

Raises an *note auditing event: 1825. ‘import’ with arguments ‘module’,
‘filename’, ‘sys.path’, ‘sys.meta_path’, ‘sys.path_hooks’.

* Menu:

* future 文 (future statement): future 文 future statement.


File: python.info,  Node: future 文 future statement,  Up: import 文

4.7.11.1 future 文 (future statement)
.....................................

'future 文' は、将来の特定の新たな機能が標準化された Python のリリースで
利用可能になるような構文や意味付けを使って、特定のモジュールをコンパイル
させるための、コンパイラに対する指示句 (directive) です。

future 文は互換性のない変更がされた将来の Python のバージョンに容易に移
行するためのものです。future 文によって新機能が標準となるリリースの前に
それをモジュール単位で使用することが出来ます。

     future_stmt ::= "from" "__future__" "import" feature ["as" identifier]
                     ("," feature ["as" identifier])*
                     | "from" "__future__" "import" "(" feature ["as" identifier]
                     ("," feature ["as" identifier])* [","] ")"
     feature     ::= identifier

future 文は、モジュールの先頭周辺に書かなければなりません。 future 文の
前に書いてよい内容は以下です :

   * モジュールのドキュメンテーション文字列 ( あれば )

   * コメント ,

   * 空行 ,

   * その他の future 文。

future 文を使う必要がある唯一の機能は ‘annotations’ です ( PEP 563(1) を
参照してください)。

future 文で有効にできる歴史的な機能は、今でも Python 3 が認識します。 そ
のリストは ‘absolute_import’, ‘division’, ‘generator_stop’,
‘generators’, ‘unicode_literals’, ‘print_function’, ‘nested_scopes’,
‘with_statement’ です。 これらは既に全てが有効になっていて、後方互換性の
ためだけに残されているため、冗長なだけです。

future 文は、コンパイル時に特別なやり方で認識され、扱われます: 言語の中
核をなす構文構成 (construct) に対する意味付けが変更されている場合、変更
部分はしばしば異なるコードを生成することで実現されています。新たな機能に
よって、(新たな予約語のような) 互換性のない新たな構文が取り入れられるこ
とさえあります。この場合、コンパイラはモジュールを別のやりかたで解析する
必要があるかもしれません。こうしたコード生成に関する決定は、実行時まで先
延ばしすることはできません。

これまでの全てのリリースにおいて、コンパイラはどの機能が定義済みかを知っ
ており、 future 文に未知の機能が含まれている場合にはコンパイル時エラーを
送出します。

future 文の実行時における直接的な意味付けは、 import 文と同じです。標準
モジュール *note __future__: 0. があり、これについては後で述べます。
*note __future__: 0. は、 future 文が実行される際に通常の方法で import さ
れます。

future 文の実行時における特別な意味付けは、 future 文で有効化される特定
の機能によって変わります。

以下の文には、何ら特殊な意味はないので注意してください:

     import __future__ [as name]

これは future 文ではありません; この文は通常の import 文であり、その他の
特殊な意味付けや構文的な制限はありません。

Code compiled by calls to the built-in functions *note exec(): 164. and
*note compile(): 177. that occur in a module ‘M’ containing a future
statement will, by default, use the new syntax or semantics associated
with the future statement.  This can be controlled by optional arguments
to *note compile(): 177. -- see the documentation of that function for
details.

対話的インタプリタのプロンプトでタイプ入力した future 文は、その後のイン
タプリタセッション中で有効になります。インタプリタを *note -i: 1484. オ
プションで起動して実行すべきスクリプト名を渡し、スクリプト中に future 文
を入れておくと、新たな機能はスクリプトが実行された後に開始する対話セッシ
ョンで有効になります。

参考
....

PEP 236(2) - Back to the __future__

     __future__ 機構の原案

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0563/

   (2) https://peps.python.org/pep-0236/


File: python.info,  Node: global 文,  Next: nonlocal 文,  Prev: import 文,  Up: 単純文 simple statement

4.7.12 ‘global’ 文
------------------

     global_stmt ::= "global" identifier ("," identifier)*

*note global: 16f. 文は、現在のコードブロック全体で維持される宣言文です
。 *note global: 16f. 文は、列挙した識別子をグローバル変数として解釈する
よう指定することを意味します。 ‘global’ を使わずにグローバル変数に代入を
行うことは不可能ですが、自由変数を使えばその変数をグローバルであると宣言
せずにグローバル変数を参照することができます。

*note global: 16f. 文で列挙する名前は、同じコードブロック中で、プログラ
ムテキスト上 ‘global’ 文より前に使ってはなりません。

*note global: 16f. 文で列挙する名前は、仮引数として、または *note with:
59c. 文や *note except: 170. 節のターゲットとして定義されたり、*note
for: 2c9. のターゲットリスト、*note class: 12a5. 定義、関数定義、*note
import: 5ac. 文、変数アノテーションの中で定義されたりしてはなりません。

'CPython 実装の詳細:' 現在の実装では、これらの制限のうち幾つかについては
強制していませんが、プログラムでこの緩和された仕様を乱用すべきではありま
せん。将来の実装では、この制限を強制したり、暗黙のうちにプログラムの意味
付けを変更したりする可能性があります。

'プログラマのための注意点:' *note global: 16f. はパーザに対する指示句
(directive) です。この指示句は、 ‘global’ 文と同時に読み込まれたコードに
対してのみ適用されます。特に、組み込みの *note exec(): 164. 関数内に入っ
ている ‘global’ 文は、関数の呼び出しを '含んでいる' コードブロック内に効
果を及ぼすことはなく、そのような文字列に含まれているコードは、関数の呼び
出しを含むコード内の ‘global’ 文に影響を受けません。同様のことが、関数
*note eval(): 165. および *note compile(): 177. にも当てはまります。


File: python.info,  Node: nonlocal 文,  Next: The type statement,  Prev: global 文,  Up: 単純文 simple statement

4.7.13 ‘nonlocal’ 文
--------------------

     nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*

When the definition of a function or class is nested (enclosed) within
the definitions of other functions, its nonlocal scopes are the local
scopes of the enclosing functions.  The *note nonlocal: 1279. statement
causes the listed identifiers to refer to names previously bound in
nonlocal scopes.  It allows encapsulated code to rebind such nonlocal
identifiers.  If a name is bound in more than one nonlocal scope, the
nearest binding is used.  If a name is not bound in any nonlocal scope,
or if there is no nonlocal scope, a *note SyntaxError: 172. is raised.

The nonlocal statement applies to the entire scope of a function or
class body.  A *note SyntaxError: 172. is raised if a variable is used
or assigned to prior to its nonlocal declaration in the scope.

参考
....

PEP 3104(1) - Access to Names in Outer Scopes

     *note nonlocal: 1279. 文の詳細。

'Programmer's note:' *note nonlocal: 1279. is a directive to the parser
and applies only to code parsed along with it.  See the note for the
*note global: 16f. statement.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3104/


File: python.info,  Node: The type statement,  Prev: nonlocal 文,  Up: 単純文 simple statement

4.7.14 The ‘type’ statement
---------------------------

     type_stmt ::= 'type' identifier [type_params] "=" expression

The ‘type’ statement declares a type alias, which is an instance of
*note typing.TypeAliasType: 421.

For example, the following statement creates a type alias:

     type Point = tuple[float, float]

This code is roughly equivalent to:

     annotation-def VALUE_OF_Point():
         return tuple[float, float]
     Point = typing.TypeAliasType("Point", VALUE_OF_Point())

‘annotation-def’ indicates an *note annotation scope: 16d, which behaves
mostly like a function, but with several small differences.

The value of the type alias is evaluated in the annotation scope.  It is
not evaluated when the type alias is created, but only when the value is
accessed through the type alias's ‘__value__’ attribute (see *note Lazy
evaluation: 423.).  This allows the type alias to refer to names that
are not yet defined.

Type aliases may be made generic by adding a *note type parameter list:
293. after the name.  See *note Generic type aliases: 422. for more.

‘type’ is a *note soft keyword: 7d7.

Added in version 3.12.

参考
....

PEP 695(1) - Type Parameter Syntax

     Introduced the ‘type’ statement and syntax for generic classes and
     functions.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0695/


File: python.info,  Node: 複合文 compound statement,  Next: トップレベル要素,  Prev: 単純文 simple statement,  Up: Python 言語リファレンス

4.8 複合文 (compound statement)
===============================

複合文には、他の文 (のグループ) が入ります; 複合文は、中に入っている他の
文の実行の制御に何らかのやり方で影響を及ぼします。一般的には、複合文は複
数行にまたがって書かれますが、全部の文を一行に連ねた単純な書き方もありま
す。

*note if: 2ca. 、 *note while: 1b6e. 、および *note for: 2c9. 文は、伝統
的な制御フロー構成を実現します。 *note try: 6b4. は例外処理および/または
一連の文に対するクリーンアップコードを指定します。それに対して、 *note
with: 59c. 文はコードのかたまりの前後でコードの初期化と終了処理を実行で
きるようにします。関数とクラス定義もまた、構文的には複合文です。

複合文は、一つ以上の '節 (clause)' からなります。節は、ヘッダと 'スイー
ト (suite)' からなります。一つの複合文を成す各節のヘッダは、全て同じイン
デントレベルに置かれます。各節のヘッダは一意に識別するキーワードで始まり
、コロンで終わります。スイートは、節によって制御される文の集まりです。ス
イートは、ヘッダがある行のコロンの後にセミコロンで区切って置かれた一つ以
上の単純文、または、ヘッダに続く行で一つ多くインデントされた文の集まりで
す。後者の形式のスイートに限り、さらに複合文をネストできます; 以下の文は
、 *note else: 171. 節がどちらの *note if: 2ca. 節に属するかがはっきりし
ないなどの理由から不正になります:

     if test1: if test2: print(x)

また、このコンテキスト中では、セミコロンによる結合はコロンより強いです。
従って、以下の例では、 *note print(): f42. の呼び出しはは全て実行される
か、全く実行されないかのどちらかです:

     if x < y < z: print(x); print(y); print(z)

まとめると、以下のようになります:

     compound_stmt ::= if_stmt
                       | while_stmt
                       | for_stmt
                       | try_stmt
                       | with_stmt
                       | match_stmt
                       | funcdef
                       | classdef
                       | async_with_stmt
                       | async_for_stmt
                       | async_funcdef
     suite         ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT
     statement     ::= stmt_list NEWLINE | compound_stmt
     stmt_list     ::= simple_stmt (";" simple_stmt)* [";"]

なお、文は常に ‘NEWLINE’ か、その後に ‘DEDENT’ が続いたもので終了します
。また、オプションの継続節は必ず、文を開始できない予約語で始まるので、曖
昧さは存在しません。 (Python では、 'ぶら下がり (dangling) *note else:
171.' 問題は、ネストされた *note if: 2ca. 文をインデントさせることで解決
されます)。

以下の節における文法規則の記述方式は、明確さのために、各節を別々の行に書
くようにしています。
* Menu:

* if 文: if 文<2>.
* while 文::
* for 文: for 文<2>.
* try 文::
* with 文::
* match 文: match 文<2>.
* 関数定義::
* クラス定義::
* コルーチン: コルーチン<2>.
* Type parameter lists::


File: python.info,  Node: if 文<2>,  Next: while 文,  Up: 複合文 compound statement

4.8.1 ‘if’ 文
-------------

*note if: 2ca. 文は、条件分岐を実行するために使われます:

     if_stmt ::= "if" assignment_expression ":" suite
                 ("elif" assignment_expression ":" suite)*
                 ["else" ":" suite]

*note if: 2ca. 文は、式を一つ一つ評価してゆき、真になるまで続けて、真に
なった節のスイートだけを選択します (真: true と偽: false の定義について
は、 *note ブール演算 (boolean operation): 1fd9. 節を参照してください);
次に、選択したスイートを実行します (そして、 *note if: 2ca. 文の他の部分
は、実行や評価をされません)。全ての式が偽になった場合、 *note else: 171.
節があれば、そのスイートが実行されます。


File: python.info,  Node: while 文,  Next: for 文<2>,  Prev: if 文<2>,  Up: 複合文 compound statement

4.8.2 ‘while’ 文
----------------

*note while: 1b6e. 文は、式の値が真である間、実行を繰り返すために使われ
ます:

     while_stmt ::= "while" assignment_expression ":" suite
                    ["else" ":" suite]

*note while: 1b6e. 文は式を繰り返し真偽評価し、真であれば最初のスイート
を実行します。式が偽であれば (最初から偽になっていることもありえます)、
‘else’ 節がある場合にはそれを実行し、ループを終了します。

最初のスイート内で *note break: a77. 文が実行されると、 ‘else’ 節のスイ
ートを実行することなくループを終了します。 *note continue: 998. 文が最初
のスイート内で実行されると、スイート内にある残りの文の実行をスキップして
、式の真偽評価に戻ります。


File: python.info,  Node: for 文<2>,  Next: try 文,  Prev: while 文,  Up: 複合文 compound statement

4.8.3 ‘for’ 文
--------------

*note for: 2c9. 文は、シーケンス (文字列、タプルまたはリスト) や、その他
の反復可能なオブジェクト (iterable object) 内の要素に渡って反復処理を行
うために使われます:

     for_stmt ::= "for" target_list "in" starred_list ":" suite
                  ["else" ":" suite]

‘starred_list’ 式は一度だけ評価され、評価結果として *note イテラブル:
10ad. オブジェクトを返す必要があります。そのイテラブルから *note
イテレータ: 191. が作られます。まず、イテレータから生成される最初の要素
が、通常の代入式のルールに従って ‘target_list’ に代入され(*note 代入文
(assignment statement): 1f39. 節参照)、１つ目のスイート (suite) が実行さ
れます。これが、イテレータから生成される各要素に対して繰り返されます。イ
テレータのすべての要素が処理されたあと、 ‘else’ 節がもしあれば実行され、
ループ処理が終了します。

最初のスイートの中で *note break: a77. 文が実行されると、 ‘else’ 節のス
イートを実行することなくループを終了します。 *note continue: 998. 文が最
初のスイート内で実行されると、スイート内にある残りの文の実行をスキップし
て、次の要素の処理に移るか、これ以上次の要素が無い場合は ‘else’ 節の処理
に移ります。

for ループはターゲットリスト内の変数への代入を行います。 これにより、for
ループ内も含めて、それ以前の全ての代入は上書きされます:

     for i in range(10):
         print(i)
         i = 5             # this will not affect the for-loop
                           # because i will be overwritten with the next
                           # index in the range

ループが終了してもターゲットリスト内の名前は削除されませんが、イテラブル
が空の場合には、ループでの代入は全く行われません。ヒント: 組み込み型
*note range(): 911. は、 整数の不変算術列を表します。例えば、 ‘range(3)’
を反復すると0、1そして2の順に結果を返します。

バージョン 3.11 で変更: 式のリストの中でアスタリスク付きの式 (starred
elements) を指定できるようになりました。


File: python.info,  Node: try 文,  Next: with 文,  Prev: for 文<2>,  Up: 複合文 compound statement

4.8.4 ‘try’ 文
--------------

‘try’ 文は、ひとまとめの文に対して、例外処理および/またはクリーンアップ
コードを指定します:

     try_stmt  ::= try1_stmt | try2_stmt | try3_stmt
     try1_stmt ::= "try" ":" suite
                   ("except" [expression ["as" identifier]] ":" suite)+
                   ["else" ":" suite]
                   ["finally" ":" suite]
     try2_stmt ::= "try" ":" suite
                   ("except" "*" expression ["as" identifier] ":" suite)+
                   ["else" ":" suite]
                   ["finally" ":" suite]
     try3_stmt ::= "try" ":" suite
                   "finally" ":" suite

例外に関するその他の情報は *note 例外: 1f45. 節にあります。また、 *note
raise: 5b7. 文の使用による例外の生成に関する情報は、 *note raise 文:
5b7. 節にあります。

* Menu:

* except 節::
* except* 節::
* else 節::
* finally 節::


File: python.info,  Node: except 節,  Next: except* 節,  Up: try 文

4.8.4.1 ‘except’ 節
...................

The ‘except’ clause(s) specify one or more exception handlers.  When no
exception occurs in the *note try: 6b4. clause, no exception handler is
executed.  When an exception occurs in the ‘try’ suite, a search for an
exception handler is started.  This search inspects the ‘except’ clauses
in turn until one is found that matches the exception.  An
expression-less ‘except’ clause, if present, must be last; it matches
any exception.

For an ‘except’ clause with an expression, the expression must evaluate
to an exception type or a tuple of exception types.  The raised
exception matches an ‘except’ clause whose expression evaluates to the
class or a *note non-virtual base class: 1186. of the exception object,
or to a tuple that contains such a class.

例外がどの ‘except’ 節にも合致しなかった場合、現在のコードを囲うさらに外
側、そして呼び出しスタックへと検索を続けます。 (1)

‘except’ 節のヘッダにある式を値評価するときに例外が発生すると、元々のハ
ンドラ検索はキャンセルされ、新たな例外に対する例外ハンドラの検索を現在の
*note except: 170. 節の外側のコードや呼び出しスタックに対して行います
(*note try: 6b4. 文全体が例外を発行したかのように扱われます)。

対応する ‘except’ 節が見つかると、‘except’ 節のスイートが実行されます。
その際、 ‘as’ キーワードが ‘except’ 節に存在すれば、その後で指定されてい
るターゲットに例外が代入されます。全ての ‘except’ 節は実行可能なブロック
を持っていなければなりません。このブロックの末尾に到達すると、通常は
*note try: 6b4. 文全体の直後から実行を継続します。(このことは、ネストさ
れた二つの例外ハンドラが同じ例外に対して存在し、内側のハンドラ内の ‘try’
節で例外が発生した場合、外側のハンドラはその例外を処理しないことを意味し
ます。)

例外が ‘as target’ を使って代入されたとき、それは ‘except’ 節の終わりに
消去されます。これはちょうど、以下のコード:

     except E as N:
         foo

が、以下のコードに翻訳されたかのようなものです:

     except E as N:
         try:
             foo
         finally:
             del N

よって、例外を ‘except’ 節以降で参照できるようにするためには、別の名前に
代入されなければなりません。例外が削除されるのは、トレースバックが付与さ
れると、そのスタックフレームと循環参照を形作り、次のガベージ収集までその
フレーム内のすべての局所変数を生存させてしまうからです。

‘except’ 節のスイートが実行される前に、例外が *note sys: c3. モジュール
に格納されます。 ‘except’ 節の中では、 *note sys.exception(): 657. を呼
び出す事によってこの例外にアクセスすることができます。 例外ハンドラを抜
けると、 *note sys: c3. モジュールに格納されている例外の値が、一つ前の値
に戻ります:

     >>> print(sys.exception())
     None
     >>> try:
     ...     raise TypeError
     ... except:
     ...     print(repr(sys.exception()))
     ...     try:
     ...          raise ValueError
     ...     except:
     ...         print(repr(sys.exception()))
     ...     print(repr(sys.exception()))
     ...
     TypeError()
     ValueError()
     TypeError()
     >>> print(sys.exception())
     None

   ---------- Footnotes ----------

   (1) 例外は、別の例外を送出するような *note finally: 997. 節が無い場合
にのみ呼び出しスタックへ伝わります。新しい例外によって、古い例外は失われ
ます。


File: python.info,  Node: except* 節,  Next: else 節,  Prev: except 節,  Up: try 文

4.8.4.2 ‘except*’ 節
....................

The ‘except*’ clause(s) are used for handling *note ExceptionGroup:
19b.s.  The exception type for matching is interpreted as in the case of
*note except: 170, but in the case of exception groups we can have
partial matches when the type matches some of the exceptions in the
group.  This means that multiple ‘except*’ clauses can execute, each
handling part of the exception group.  Each clause executes at most once
and handles an exception group of all matching exceptions.  Each
exception in the group is handled by at most one ‘except*’ clause, the
first that matches it.

     >>> try:
     ...     raise ExceptionGroup("eg",
     ...         [ValueError(1), TypeError(2), OSError(3), OSError(4)])
     ... except* TypeError as e:
     ...     print(f'caught {type(e)} with nested {e.exceptions}')
     ... except* OSError as e:
     ...     print(f'caught {type(e)} with nested {e.exceptions}')
     ...
     caught <class 'ExceptionGroup'> with nested (TypeError(2),)
     caught <class 'ExceptionGroup'> with nested (OSError(3), OSError(4))
       + Exception Group Traceback (most recent call last):
       |   File "<stdin>", line 2, in <module>
       | ExceptionGroup: eg
       +-+---------------- 1 ----------------
         | ValueError: 1
         +------------------------------------

Any remaining exceptions that were not handled by any ‘except*’ clause
are re-raised at the end, along with all exceptions that were raised
from within the ‘except*’ clauses.  If this list contains more than one
exception to reraise, they are combined into an exception group.

If the raised exception is not an exception group and its type matches
one of the ‘except*’ clauses, it is caught and wrapped by an exception
group with an empty message string.

     >>> try:
     ...     raise BlockingIOError
     ... except* BlockingIOError as e:
     ...     print(repr(e))
     ...
     ExceptionGroup('', (BlockingIOError()))

An ‘except*’ clause must have a matching expression; it cannot be
‘except*:’.  Furthermore, this expression cannot contain exception group
types, because that would have ambiguous semantics.

It is not possible to mix *note except: 170. and ‘except*’ in the same
*note try: 6b4.  *note break: a77, *note continue: 998. and *note
return: 99c. cannot appear in an ‘except*’ clause.


File: python.info,  Node: else 節,  Next: finally 節,  Prev: except* 節,  Up: try 文

4.8.4.3 ‘else’ 節
.................

オプションの ‘else’ 節は、コントロールフローが *note try: 6b4. スイート
を抜け、例外が送出されず、 *note return: 99c. 文、 *note continue: 998.
文、 *note break: a77. 文のいずれもが実行されなかった場合に実行されます
。 ‘else’ 節で起きた例外は、手前にある *note except: 170. 節では処理され
ません。


File: python.info,  Node: finally 節,  Prev: else 節,  Up: try 文

4.8.4.4 ‘finally’ 節
....................

‘finally’ 節がある場合は、 '後始末' の対処を指定します。まず *note
except: 170. 節や *note else: 171. 節を含め、 *note try: 6b4. 節が実行さ
れます。それらの節の中で例外が起き、その例外が処理されていない場合には、
例外は一時的に保存されます。次に ‘finally’ 節が実行されます。保存された
例外があった場合は、 ‘finally’ 節の末尾で再送出されます。 ‘finally’ 節で
別の例外が送出される場合は、保存されていた例外は新しい例外のコンテキスト
として設定されます。 ‘finally’ 節で *note return: 99c. 文、 *note break:
a77. 文あるいは *note continue: 998. 文を実行した場合は、保存された例外
は破棄されます:

     >>> def f():
     ...     try:
     ...         1/0
     ...     finally:
     ...         return 42
     ...
     >>> f()
     42

‘finally’ 節を実行している間は、プログラムからは例外情報は利用できません
。

*note try: 6b4...‘finally’ 文の *note try: 6b4. スイート内で *note
return: 99c. 、 *note break: a77. 、または *note continue: 998. 文が実行
された場合、 ‘finally’ 節も、この文を '抜け出る途中に' 実行されます。

関数の返り値は最後に実行された *note return: 99c. 文によって決まります。
‘finally’ 節は必ず実行されるため、‘finally’ 節で実行された ‘return’ 文は
常に最後に実行されることになります:

     >>> def foo():
     ...     try:
     ...         return 'try'
     ...     finally:
     ...         return 'finally'
     ...
     >>> foo()
     'finally'

バージョン 3.8 で変更: Python3.8 以前では、実装上の問題により ‘finally’
節での *note continue: 998. 文は不正でした。


File: python.info,  Node: with 文,  Next: match 文<2>,  Prev: try 文,  Up: 複合文 compound statement

4.8.5 ‘with’ 文
---------------

*note with: 59c. 文は、ブロックの実行を、コンテキストマネージャによって
定義されたメソッドでラップするために使われます (*note
with文とコンテキストマネージャ: 1f1e. セクションを参照してください)。こ
れにより、よくある *note try: 6b4...*note except: 170...*note finally:
997. 利用パターンをカプセル化して便利に再利用することができます。

     with_stmt          ::= "with" ( "(" with_stmt_contents ","? ")" | with_stmt_contents ) ":" suite
     with_stmt_contents ::= with_item ("," with_item)*
     with_item          ::= expression ["as" target]

一つの "要素" を持つ *note with: 59c. 文の実行は以下のように進行します:

  1. コンテキスト式 (*note with_item: 2040. で与えられた式) を評価するこ
     とで、コンテキストマネージャを取得します。

  2. コンテキストマネージャの *note __enter__(): 592. メソッドが、後で使
     うためにロードされます。

  3. コンテキストマネージャの *note __exit__(): 12ce. メソッドが、後で使
     うためにロードされます。

  4. コンテキストマネージャの *note __enter__(): 592. メソッドが呼ばれま
     す。

  5. *note with: 59c. 文にターゲットが含まれていたら、それに *note
     __enter__(): 592. からの戻り値が代入されます。

          注釈: *note with: 59c. 文は、 *note __enter__(): 592. メソッド
          がエラーなく終了した場合には *note __exit__(): 12ce. が常に呼
          ばれることを保証します。ですので、もしターゲットリストへの代入
          中にエラーが発生した場合には、これはそのスイートの中で発生した
          エラーと同じように扱われます。以下のステップ 7 を参照してくだ
          さい。

  6. スイートが実行されます。

  7. コンテキストマネージャの *note __exit__(): 12ce. メソッドが呼ばれま
     す。スイートが例外によって終了されたのなら、その例外の型、値、トレ
     ースバックが *note __exit__(): 12ce. に引数として渡されます。そうで
     なければ、 3 つの *note None: 641. 引数が与えられます。

     スイートが例外により終了され、 *note __exit__(): 12ce. メソッドから
     の戻り値が偽（false）ならば、例外が再送出されます。この戻り値が真（
     true）ならば例外は抑制され、実行は *note with: 59c. 文の次の文から
     続きます。

     もしそのスイートが例外でない何らかの理由で終了した場合、その *note
     __exit__(): 12ce. からの戻り値は無視されて、実行は発生した終了の種
     類に応じた通常の位置から継続します。

以下のコード:

     with EXPRESSION as TARGET:
         SUITE

これは次と等価です:

     manager = (EXPRESSION)
     enter = type(manager).__enter__
     exit = type(manager).__exit__
     value = enter(manager)

     try:
         TARGET = value
         SUITE
     except:
         if not exit(manager, *sys.exc_info()):
             raise
     else:
         exit(manager, None, None, None)

複数の要素があるとき、コンテキストマネージャは複数の *note with: 59c. 文
がネストされたかのように進行します:

     with A() as a, B() as b:
         SUITE

これは次と等価です:

     with A() as a:
         with B() as b:
             SUITE

括弧で囲むことにより、複数のコンテキストマネージャを複数行に渡って書くこ
とができます。 例:

     with (
         A() as a,
         B() as b,
     ):
         SUITE

バージョン 3.1 で変更: 複数のコンテキスト式をサポートしました。

バージョン 3.10 で変更: 括弧で囲むことで、文を複数行に分割して書けるよう
になりました。

参考
....

PEP 343(1) - "with" ステートメント

     Python の *note with: 59c. 文の仕様、背景、および例が記載されていま
     す。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0343/


File: python.info,  Node: match 文<2>,  Next: 関数定義,  Prev: with 文,  Up: 複合文 compound statement

4.8.6 ‘match’ 文
----------------

Added in version 3.10.

match 文はパターンマッチングを行う目的で使われます。 構文:

     match_stmt   ::= 'match' subject_expr ":" NEWLINE INDENT case_block+ DEDENT
     subject_expr ::= star_named_expression "," star_named_expressions?
                      | named_expression
     case_block   ::= 'case' patterns [guard] ":" block

     注釈: このセクションでは、一重引用符で囲まれているものは *note
     ソフトキーワード: 7d7. を表します。

パターンマッチングは、パターン (‘case’ の後ろ) とマッチング対象の値
(‘match’ の後ろ)を入力とします。 パターン (サブパターンを含みうる) は、
マッチング対象の値に対して、マッチするかどうかの判定が行われます。結果と
して次のことが起こります:

   * マッチ成功、もしくはマッチ失敗 (パターン成功・失敗とも呼ばれます)。

   * マッチした値の名前への束縛。必要な条件は後述します。

‘match’ と ‘case’ キーワードは *note ソフトキーワード: 7d7. です。

参考
....

   * PEP 634(1) - 構造的パターンマッチ: 仕様

   * PEP 636(2) - 構造的パターンマッチ: チュートリアル

* Menu:

* 概要::
* ガード::
* 論駁不可能なケースブロック::
* パターン::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0634/

   (2) https://peps.python.org/pep-0636/


File: python.info,  Node: 概要,  Next: ガード,  Up: match 文<2>

4.8.6.1 概要
............

match 文の論理的な動作の流れの概要は次の通りです:

  1. サブジェクト式 ‘subject_expr’ が評価され、サブジェクト値が得られま
     す。 サブジェクト式がコンマを含む場合、 *note 通常のルール: 2046. に
     従ってタプルが作成されます。

  2. ‘case_block’ 内の各パターンに対して、サブジェクト値がマッチするかど
     うかをチェックします。 マッチ成功・失敗の具体的なルールは後述します
     。 マッチングのチェックにより、パターン内の名前の一部あるいはすべて
     に値が束縛されます。 具体的な束縛ルールはパターンの種類によって異な
     るため、後述します。 'マッチが成功したパターンの中で束縛された名前
     は、そのパターンのブロック内だけでなく、 match 文の後でも使用するこ
     とができます'。

          注釈: パターンマッチが全体として失敗しても、その中に含まれるサ
          ブパターンが成功する可能性があります。 失敗したマッチで発生す
          る名前束縛を前提としたコードを書かないように気をつけてください
          。 逆に、マッチが失敗したあとで変数の値が変わっていないという
          のも前提にしないでください。 実際どういう振る舞いになるかは
          Python の実装依存であり、実装間で異なる可能性があります。 色々
          な実装が最適化を行えるよう、意図的に実装依存としています。

  3. パターンが成功した場合、該当のガードが (もしあれば) 評価されます。
     この場合、パターン内の名前がすべて束縛されていることが保証されてい
     ます。

        * ガードの評価値が真であるか、もしくはガードがなければ、
          ‘case_block’ 内の ‘block’ が実行されます。

        * そうでなければ、次の ‘case_block’ に対して再び上記の処理が実行
          されます。

        * これ以上 case block が存在しない場合は、 match 文が終了します
          。

     注釈: 基本的に、 match 文のパターンが評価されるという前提でコードを
     書くべきではありません。 インタープリタの実装によっては、結果をキャ
     ッシュするなどの最適化を行い、評価をスキップする可能性があります。

簡単な match 文の例:

     >>> flag = False
     >>> match (100, 200):
     ...    case (100, 300):  # Mismatch: 200 != 300
     ...        print('Case 1')
     ...    case (100, 200) if flag:  # Successful match, but guard fails
     ...        print('Case 2')
     ...    case (100, y):  # Matches and binds y to 200
     ...        print(f'Case 3, y: {y}')
     ...    case _:  # Pattern not attempted
     ...        print('Case 4, I match anything!')
     ...
     Case 3, y: 200

この例では、 ‘if flag’ がガードです。 ガードについては次のセクションを参
照してください。


File: python.info,  Node: ガード,  Next: 論駁不可能なケースブロック,  Prev: 概要,  Up: match 文<2>

4.8.6.2 ガード
..............

     guard ::= "if" named_expression

‘guard’ (‘case’ 一部として現れる) が成功してはじめて、その ‘case’ ブロッ
クのコードが実行されます。 ガードは *note if: 2ca. の後に式を書く形で表
記されます。

‘guard’ 付きの ‘case’ ブロックの処理の流れは次のとおりです:

  1. ‘case’ ブロックのパターンが成功するかどうかをチェックする。 失敗し
     た場合は、 ‘guard’ は評価されず、次の ‘case’ ブロックのチェックに進
     む。

  2. パターンが成功した場合は、 ‘guard’ の評価が行われます。

        * ‘guard’ 条件の評価値が真である場合、該当の case ブロックが選択
          されます。

        * ‘guard’ 条件の評価値が偽の場合、該当の case ブロックは選択され
          ません。

        * ‘guard’ の評価中に例外が送出された場合は、その例外がそのまま送
          出されます。

ガードは式であるため、副作用を起こすことができます。 ガードの評価は、最
初の case ブロックから順に、パターンが失敗した case ブロックは飛ばしつつ
、一つづつ評価されなければいけません (つまり、ガードの評価は書かれている
順番で実行される必要があります)。 また、case ブロックが選択された時点で
、ガードの評価をそれ以上行ってはいけません。


File: python.info,  Node: 論駁不可能なケースブロック,  Next: パターン,  Prev: ガード,  Up: match 文<2>

4.8.6.3 論駁不可能なケースブロック
..................................

論駁不可能なケースブロックとは、何にでもマッチするケースブロックのことで
す。 match 文の中で、論駁不可能なケースブロックは最大一つまで、かつ最後
に位置する必要があります。

ケースブロックが論駁不可能であるためには、ガードがなく、パターンが論駁不
可能である必要があります。 パターンが論駁不可能であるためには、その文法
上の構造のみから、それが常に成功することが証明できる必要があります。 論
駁不可能なパターンは以下のようなもののみです:

   * 左辺が論駁不可能である *note AS パターン: 204b.

   * 含まれるパターンのうち少なくとも一つが論駁不可能である *note OR
     パターン: 204c.

   * *note キャプチャパターン: 204d.

   * *note ワイルドカードパターン: 7d9.

   * 括弧で囲われた、論駁不可能なパターン


File: python.info,  Node: パターン,  Prev: 論駁不可能なケースブロック,  Up: match 文<2>

4.8.6.4 パターン
................

     注釈: このセクションでは、通常のEBNFを拡張した文法記法を使用します
     。

        * ‘SEP.RULE+’ という表記は ‘RULE (SEP RULE)*’ の略です。

        * ‘!RULE’ は否定先読みの条件を表します。

‘patterns’ のトップレベルの構文は以下の通りです:

     patterns       ::= open_sequence_pattern | pattern
     pattern        ::= as_pattern | or_pattern
     closed_pattern ::= | literal_pattern
                        | capture_pattern
                        | wildcard_pattern
                        | value_pattern
                        | group_pattern
                        | sequence_pattern
                        | mapping_pattern
                        | class_pattern

以下の説明では分かりやすさのため、パターンの振る舞いを簡単に言い表した場
合の説明を「簡単に言うと」の後に書いています (そのほとんどは、Raymond
Hettinger 氏のドキュメントに影響を受けてのものです)。 ただし、これはあく
まで理解を助けるためのであり、内部的な実装を必ずしも反映したものでは 'あ
りません' 。 また、使用可能なすべてのパターン構造を網羅しているわけでは
ありません。

* Menu:

* OR パターン::
* AS パターン::
* リテラルパターン::
* キャプチャパターン::
* ワイルドカードパターン::
* 値パターン::
* グループパターン::
* シーケンスパターン::
* マッピングパターン::
* クラスパターン::


File: python.info,  Node: OR パターン,  Next: AS パターン,  Up: パターン

4.8.6.5 OR パターン
...................

OR パターンは、縦線 ‘|’ で区切られた複数のパターンからなります。 構文:

     or_pattern ::= "|".closed_pattern+

最後のサブパターン以外、 *note 論駁不可能: 2049. であってはいけません。
また、曖昧さ回避のため、各サブパターンが束縛する名前の組み合わせは、すべ
て同じである必要があります。

OR パターンでは、サブジェクト値に対して順に各サブパターンのマッチングが
行われます。 マッチが成功するとそこで終了し、この OR パターンは成功した
とみなされます。 一方、どのサブパターンも成功しなければ、この OR パター
ンは失敗したことになります。

簡単に言うと、 ‘P1 | P2 | ...’ というパターンは ‘P1’ をマッチしようとし
、失敗すれば ‘P2’ を試します。 いずれかのパターンがマッチが成功すれば直
ちに成功となり、それ以外の場合は失敗となります。


File: python.info,  Node: AS パターン,  Next: リテラルパターン,  Prev: OR パターン,  Up: パターン

4.8.6.6 AS パターン
...................

AS パターンはサブジェクト値に対して、 *note as: 203c. キーワードの左側に
ある OR パターンをマッチさせます。 構文:

     as_pattern ::= or_pattern "as" capture_pattern

OR パターンが失敗すれば、この AS パターンは失敗となります。 成功すれば、
サブジェクト値が as キーワードの右側の名前に束縛され、この AS パターンは
成功となります。 ‘capture_pattern’ として ‘_’ を指定することはできません
。

簡単に言うと、 ‘P as NAME’ は ‘P’ をマッチさせ、成功した場合に ‘NAME =
<subject>’ の代入を行います。


File: python.info,  Node: リテラルパターン,  Next: キャプチャパターン,  Prev: AS パターン,  Up: パターン

4.8.6.7 リテラルパターン
........................

リテラルパターンは、一部を除く Python の *note リテラル: 1e04. に対応し
ます。 構文:

     literal_pattern ::= signed_number
                         | signed_number "+" NUMBER
                         | signed_number "-" NUMBER
                         | strings
                         | "None"
                         | "True"
                         | "False"
     signed_number   ::= ["-"] NUMBER

‘strings’ というルールと ‘NUMBER’ というトークンは *note Python
の文法仕様: 205a. で定義されています。 クォート３つで囲われた文字列や
raw 文字列、 raw バイト列も使用可能です。 *note f-strings: 977. は使用で
きません。

‘signed_number '+' NUMBER’ と ‘signed_number '-' NUMBER’ という構文は
*note 複素数: 1e3a. を表現するためのものです。 そのため、左側には実数、
右側には虚数を書く必要があります。 例: ‘3 + 4j’ 。

簡単に言うと、 ‘LITERAL’ は ‘<subject> == LITERAL’ であるときのみ成功す
るパターンです。 シングルトンである ‘None’ と ‘True’ 、 ‘False’ は *note
is: 2cc. 演算子を使って比較されます。


File: python.info,  Node: キャプチャパターン,  Next: ワイルドカードパターン,  Prev: リテラルパターン,  Up: パターン

4.8.6.8 キャプチャパターン
..........................

キャプチャパターンは、サブジェクト値を名前に束縛します。 構文:

     capture_pattern ::= !'_' NAME

アンダースコア一文字の ‘_’ はキャプチャパターンではありません (‘!'_'’ が
表しているのはこの条件です) 。 *note wildcard_pattern: 205d. として扱わ
れます。

パターン一つの中で、一つの名前は一度しか束縛することができません。 例え
ば、 ‘case x, x: ...’ は間違いですが、 ‘case [x] | x: ...’ は正しいです
。

キャプチャパターンは常に成功します。 束縛された名前のスコープは、 PEP
572(1) で確立された代入式演算子のスコープルールと同じです。 すなわち、当
てはまる *note global: 16f. 文 か *note nonlocal: 1279. 文がない限り、そ
の局所変数のスコープは、該当の match 文を包む最も内側の関数となります。

簡単に言うと、 ‘NAME’ は常に成功し、 ‘NAME = <subject>’ の代入が行われま
す。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0572/


File: python.info,  Node: ワイルドカードパターン,  Next: 値パターン,  Prev: キャプチャパターン,  Up: パターン

4.8.6.9 ワイルドカードパターン
..............................

ワイルドカードパターンは常に成功 (何に対してもマッチする) し、名前の束縛
はしません。 構文:

     wildcard_pattern ::= '_'

‘_’ は、パターンの中で使用された場合は常に *note ソフトキーワード: 7d7.
です。 しかし、パターンの中でない場合はソフトキーワードではありません。
たとえサブジェクト式や ‘guard’ 、 ‘case’ ブロックの中でも、通常の変数と
なります。

簡単に言うと、 ‘_’ は常に成功します。


File: python.info,  Node: 値パターン,  Next: グループパターン,  Prev: ワイルドカードパターン,  Up: パターン

4.8.6.10 値パターン
...................

値パターンは Python で名前の付けられた値を表します。 構文:

     value_pattern ::= attr
     attr          ::= name_or_attr "." NAME
     name_or_attr  ::= attr | NAME

ドットがついたこの名前は、Python 標準の *note 名前解決ルール: 1f3c. によ
って解決されます。 このパターンは、解決された値がサブジェクト値と等しい
(比較演算子 ‘==’ に基づく) ときに成功となります。

簡単に言うと、 ‘NAME1.NAME2’ は ‘<subject> == NAME1.NAME2’ であるときの
み成功します。

     注釈: 一つの match 文で同じ値が複数回出現する場合は、インタープリタ
     が最初に解決された値をキャッシュし、名前解決を何度も行うことなく値
     を再利用する可能性があります。 このキャッシュは、その match 文のそ
     の実行一回の間だけで再利用されます。


File: python.info,  Node: グループパターン,  Next: シーケンスパターン,  Prev: 値パターン,  Up: パターン

4.8.6.11 グループパターン
.........................

A group pattern allows users to add parentheses around patterns to
emphasize the intended grouping.  Otherwise, it has no additional
syntax.  Syntax:

     group_pattern ::= "(" pattern ")"

In simple terms ‘(P)’ has the same effect as ‘P’.


File: python.info,  Node: シーケンスパターン,  Next: マッピングパターン,  Prev: グループパターン,  Up: パターン

4.8.6.12 シーケンスパターン
...........................

A sequence pattern contains several subpatterns to be matched against
sequence elements.  The syntax is similar to the unpacking of a list or
tuple.

     sequence_pattern       ::= "[" [maybe_sequence_pattern] "]"
                                | "(" [open_sequence_pattern] ")"
     open_sequence_pattern  ::= maybe_star_pattern "," [maybe_sequence_pattern]
     maybe_sequence_pattern ::= ",".maybe_star_pattern+ ","?
     maybe_star_pattern     ::= star_pattern | pattern
     star_pattern           ::= "*" (capture_pattern | wildcard_pattern)

There is no difference if parentheses or square brackets are used for
sequence patterns (i.e.  ‘(...)’ vs ‘[...]’ ).

     注釈: A single pattern enclosed in parentheses without a trailing
     comma (e.g.  ‘(3 | 4)’) is a *note group pattern: 2064.  While a
     single pattern enclosed in square brackets (e.g.  ‘[3 | 4]’) is
     still a sequence pattern.

At most one star subpattern may be in a sequence pattern.  The star
subpattern may occur in any position.  If no star subpattern is present,
the sequence pattern is a fixed-length sequence pattern; otherwise it is
a variable-length sequence pattern.

The following is the logical flow for matching a sequence pattern
against a subject value:

  1. If the subject value is not a sequence (1), the sequence pattern
     fails.

  2. If the subject value is an instance of ‘str’, ‘bytes’ or
     ‘bytearray’ the sequence pattern fails.

  3. The subsequent steps depend on whether the sequence pattern is
     fixed or variable-length.

     If the sequence pattern is fixed-length:

       1. If the length of the subject sequence is not equal to the
          number of subpatterns, the sequence pattern fails

       2. Subpatterns in the sequence pattern are matched to their
          corresponding items in the subject sequence from left to
          right.  Matching stops as soon as a subpattern fails.  If all
          subpatterns succeed in matching their corresponding item, the
          sequence pattern succeeds.

     Otherwise, if the sequence pattern is variable-length:

       1. If the length of the subject sequence is less than the number
          of non-star subpatterns, the sequence pattern fails.

       2. The leading non-star subpatterns are matched to their
          corresponding items as for fixed-length sequences.

       3. If the previous step succeeds, the star subpattern matches a
          list formed of the remaining subject items, excluding the
          remaining items corresponding to non-star subpatterns
          following the star subpattern.

       4. Remaining non-star subpatterns are matched to their
          corresponding subject items, as for a fixed-length sequence.

          注釈: The length of the subject sequence is obtained via *note
          len(): 5fa. (i.e.  via the ‘__len__()’ protocol).  This length
          may be cached by the interpreter in a similar manner as *note
          value patterns: 2060.

In simple terms ‘[P1, P2, P3,’ ...  ‘, P<N>]’ matches only if all the
following happens:

   * ‘<subject>’ がシーケンスかをチェックする

   * ‘len(subject) == <N>’

   * ‘P1’ matches ‘<subject>[0]’ (note that this match can also bind
     names)

   * ‘P2’ matches ‘<subject>[1]’ (note that this match can also bind
     names)

   * ...  and so on for the corresponding pattern/element.

   ---------- Footnotes ----------

   (1) In pattern matching, a sequence is defined as one of the
following:

   * *note collections.abc.Sequence: 1194. を継承したクラス。

   * *note collections.abc.Sequence: 1194. として登録されたPythonクラス
     。

   * a builtin class that has its (CPython) *note Py_TPFLAGS_SEQUENCE:
     180f. bit set

   * a class that inherits from any of the above

The following standard library classes are sequences:

   * *note array.array: 185.

   * *note collections.deque: 5a6.

   * *note list: 5dc.

   * *note memoryview: 435.

   * *note range: 911.

   * *note tuple: 349.

     注釈: Subject values of type ‘str’, ‘bytes’, and ‘bytearray’ do not
     match sequence patterns.


File: python.info,  Node: マッピングパターン,  Next: クラスパターン,  Prev: シーケンスパターン,  Up: パターン

4.8.6.13 マッピングパターン
...........................

A mapping pattern contains one or more key-value patterns.  The syntax
is similar to the construction of a dictionary.  Syntax:

     mapping_pattern     ::= "{" [items_pattern] "}"
     items_pattern       ::= ",".key_value_pattern+ ","?
     key_value_pattern   ::= (literal_pattern | value_pattern) ":" pattern
                             | double_star_pattern
     double_star_pattern ::= "**" capture_pattern

At most one double star pattern may be in a mapping pattern.  The double
star pattern must be the last subpattern in the mapping pattern.

Duplicate keys in mapping patterns are disallowed.  Duplicate literal
keys will raise a *note SyntaxError: 172.  Two keys that otherwise have
the same value will raise a *note ValueError: 1e3. at runtime.

The following is the logical flow for matching a mapping pattern against
a subject value:

  1. If the subject value is not a mapping (1),the mapping pattern
     fails.

  2. If every key given in the mapping pattern is present in the subject
     mapping, and the pattern for each key matches the corresponding
     item of the subject mapping, the mapping pattern succeeds.

  3. If duplicate keys are detected in the mapping pattern, the pattern
     is considered invalid.  A *note SyntaxError: 172. is raised for
     duplicate literal values; or a *note ValueError: 1e3. for named
     keys of the same value.

     注釈: Key-value pairs are matched using the two-argument form of
     the mapping subject's ‘get()’ method.  Matched key-value pairs must
     already be present in the mapping, and not created on-the-fly via
     ‘__missing__()’ or *note __getitem__(): 264.

In simple terms ‘{KEY1: P1, KEY2: P2, ... }’ matches only if all the
following happens:

   * ‘<subject>’ がマッピングかをチェックする

   * ‘KEY1 in <subject>’

   * ‘P1’ は ‘<subject>[KEY1]’ にマッチする

   * ...  and so on for the corresponding KEY/pattern pair.

   ---------- Footnotes ----------

   (1) In pattern matching, a mapping is defined as one of the
following:

   * a class that inherits from *note collections.abc.Mapping: 898.

   * a Python class that has been registered as *note
     collections.abc.Mapping: 898.

   * a builtin class that has its (CPython) *note Py_TPFLAGS_MAPPING:
     180e. bit set

   * a class that inherits from any of the above

The standard library classes *note dict: 237. and *note
types.MappingProxyType: 43a. are mappings.


File: python.info,  Node: クラスパターン,  Prev: マッピングパターン,  Up: パターン

4.8.6.14 クラスパターン
.......................

A class pattern represents a class and its positional and keyword
arguments (if any).  Syntax:

     class_pattern       ::= name_or_attr "(" [pattern_arguments ","?] ")"
     pattern_arguments   ::= positional_patterns ["," keyword_patterns]
                             | keyword_patterns
     positional_patterns ::= ",".pattern+
     keyword_patterns    ::= ",".keyword_pattern+
     keyword_pattern     ::= NAME "=" pattern

The same keyword should not be repeated in class patterns.

The following is the logical flow for matching a class pattern against a
subject value:

  1. If ‘name_or_attr’ is not an instance of the builtin *note type:
     d16. , raise *note TypeError: 502.

  2. If the subject value is not an instance of ‘name_or_attr’ (tested
     via *note isinstance(): 40e.), the class pattern fails.

  3. If no pattern arguments are present, the pattern succeeds.
     Otherwise, the subsequent steps depend on whether keyword or
     positional argument patterns are present.

     For a number of built-in types (specified below), a single
     positional subpattern is accepted which will match the entire
     subject; for these types keyword patterns also work as for other
     types.

     If only keyword patterns are present, they are processed as
     follows, one by one:

     I. The keyword is looked up as an attribute on the subject.

             * If this raises an exception other than *note
               AttributeError: 326, the exception bubbles up.

             * If this raises *note AttributeError: 326, the class
               pattern has failed.

             * Else, the subpattern associated with the keyword pattern
               is matched against the subject's attribute value.  If
               this fails, the class pattern fails; if this succeeds,
               the match proceeds to the next keyword.

     II. If all keyword patterns succeed, the class pattern succeeds.

     If any positional patterns are present, they are converted to
     keyword patterns using the *note __match_args__: 182a. attribute on
     the class ‘name_or_attr’ before matching:

     I. The equivalent of ‘getattr(cls, "__match_args__", ())’ is
     called.

             * If this raises an exception, the exception bubbles up.

             * If the returned value is not a tuple, the conversion
               fails and *note TypeError: 502. is raised.

             * If there are more positional patterns than
               ‘len(cls.__match_args__)’, *note TypeError: 502. is
               raised.

             * Otherwise, positional pattern ‘i’ is converted to a
               keyword pattern using ‘__match_args__[i]’ as the keyword.
               ‘__match_args__[i]’ must be a string; if not *note
               TypeError: 502. is raised.

             * If there are duplicate keywords, *note TypeError: 502. is
               raised.

          参考
          ....

          *note クラスパターンマッチの位置引数のカスタマイズ: 1f21.

     II. Once all positional patterns have been converted to keyword patterns,

          the match proceeds as if there were only keyword patterns.

     For the following built-in types the handling of positional
     subpatterns is different:

        * *note bool: 434.

        * *note bytearray: 508.

        * *note bytes: 1a4.

        * *note dict: 237.

        * *note float: 2ce.

        * *note frozenset: 5a4.

        * *note int: 238.

        * *note list: 5dc.

        * *note set: 5a3.

        * *note str: 418.

        * *note tuple: 349.

     These classes accept a single positional argument, and the pattern
     there is matched against the whole object rather than an attribute.
     For example ‘int(0|1)’ matches the value ‘0’, but not the value
     ‘0.0’.

In simple terms ‘CLS(P1, attr=P2)’ matches only if the following
happens:

   * ‘isinstance(<subject>, CLS)’

   * convert ‘P1’ to a keyword pattern using ‘CLS.__match_args__’

   * For each keyword argument ‘attr=P2’:

        * ‘hasattr(<subject>, "attr")’

        * ‘P2’ は ‘<subject>.attr’ にマッチする

   * ...  and so on for the corresponding keyword argument/pattern pair.

参考
....

   * PEP 634(1) - 構造的パターンマッチ: 仕様

   * PEP 636(2) - 構造的パターンマッチ: チュートリアル

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0634/

   (2) https://peps.python.org/pep-0636/


File: python.info,  Node: 関数定義,  Next: クラス定義,  Prev: match 文<2>,  Up: 複合文 compound statement

4.8.7 関数定義
--------------

関数定義は、ユーザ定義関数オブジェクトを定義します (*note 標準型の階層:
1e46. 節参照):

     funcdef                   ::= [decorators] "def" funcname [type_params] "(" [parameter_list] ")"
                                   ["->" expression] ":" suite
     decorators                ::= decorator+
     decorator                 ::= "@" assignment_expression NEWLINE
     parameter_list            ::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]]
                                     | parameter_list_no_posonly
     parameter_list_no_posonly ::= defparameter ("," defparameter)* ["," [parameter_list_starargs]]
                                   | parameter_list_starargs
     parameter_list_starargs   ::= "*" [star_parameter] ("," defparameter)* ["," ["**" parameter [","]]]
                                   | "**" parameter [","]
     parameter                 ::= identifier [":" expression]
     star_parameter            ::= identifier [":" ["*"] expression]
     defparameter              ::= parameter ["=" expression]
     funcname                  ::= identifier

関数定義は実行可能な文です。関数定義を実行すると、現在のローカルな名前空
間内で関数名を関数オブジェクト (関数の実行可能コードをくるむラッパー) に
束縛します。この関数オブジェクトには、関数が呼び出された際に使われるグロ
ーバルな名前空間として、現在のグローバルな名前空間への参照が入っています
。

関数定義は関数本体を実行しません; 関数本体は関数が呼び出された時にのみ実
行されます。 (1)

関数定義は一つ以上の *note デコレータ: 6fc. 式でラップできます。デコレー
タ式は関数を定義するとき、関数定義の入っているスコープで評価されます。そ
の結果は、関数オブジェクトを唯一の引数にとる呼び出し可能オブジェクトでな
ければなりません。関数オブジェクトの代わりに、返された値が関数名に束縛さ
れます。複数のデコレータはネストして適用されます。例えば、以下のようなコ
ード:

     @f1(arg)
     @f2
     def func(): pass

は、だいたい次と等価です

     def func(): pass
     func = f1(arg)(f2(func))

ただし、前者のコードでは元々の関数を ‘func’ という名前へ一時的に束縛する
ことはない、というところを除きます。

バージョン 3.9 で変更: Functions may be decorated with any valid *note
assignment_expression: 1f3f.  Previously, the grammar was much more
restrictive; see PEP 614(2) for details.

A list of *note type parameters: 293. may be given in square brackets
between the function's name and the opening parenthesis for its
parameter list.  This indicates to static type checkers that the
function is generic.  At runtime, the type parameters can be retrieved
from the function's *note __type_params__: 1e5f. attribute.  See *note
Generic functions: 41f. for more.

バージョン 3.12 で変更: Type parameter lists are new in Python 3.12.

1 つ以上の *note 仮引数: 1e5e. が 'parameter' ‘=’ 'expression' の形を取
っているとき、関数は "デフォルト引数値" を持つと言います。デフォルト値を
持つ仮引数では、呼び出し時にそれに対応する *note 実引数: 415. は省略でき
、その場合は仮引数のデフォルト値が使われます。ある引数がデフォルト値を持
っている場合、それ以降 "‘*’" が出てくるまでの引数は全てデフォルト値を持
っていなければなりません - これは文法定義では表現されていない構文的制限
です。

'デフォルト引数値は関数定義が実行されるときに左から右へ評価されます。' こ
れは、デフォルト引数の式は関数が定義されるときにただ一度だけ評価され、同
じ "計算済みの" 値が呼び出しのたびに使用されることを意味します。この仕様
を理解しておくことは特に、デフォルト引数値がリストや辞書のようなミュータ
ブルなオブジェクトであるときに重要です: 関数がこのオブジェクトを変更 (例
えばリストに要素を追加) すると、このデフォルト引数値が変更の影響を受けて
しまします。一般には、これは意図しない動作です。このような動作を避けるに
は、デフォルト値として ‘None’ を使い、この値を関数本体の中で明示的にテス
トします。例えば以下のようにします:

     def whats_on_the_telly(penguin=None):
         if penguin is None:
             penguin = []
         penguin.append("property of the zoo")
         return penguin

関数呼び出しの意味付けに関する詳細は、 *note 呼び出し (call): d4a. 節で
述べられています。 関数呼び出しを行うと、パラメタリストに記述された全て
のパラメタに、位置引数、キーワード引数、デフォルト値のいずれかから値が代
入されます。 "‘*identifier’" 形式が存在すれば、余ったすべての位置引数を
受け取ったタプルに初期化されます。 このデフォルト値は空のタプルです。
"‘**identifier’" 形式が存在すれば、余ったすべてのキーワード引数を受け取
った順序付きのマッピングオブジェクトに初期化されます。 このデフォルト値
は同じ型の空のマッピングオブジェクトです。 "‘*’" や "‘*identifier’" の後
のパラメタはキーワード専用パラメータで、キーワード引数によってのみ渡され
ます。 "‘/’" の前のパラメタは位置専用パラメータで、位置引数によってのみ
渡されます。

バージョン 3.8 で変更: The ‘/’ function parameter syntax may be used to
indicate positional-only parameters.  See PEP 570(3) for details.

Parameters may have an *note annotation: 1ba1. of the form "‘:
expression’" following the parameter name.  Any parameter may have an
annotation, even those of the form ‘*identifier’ or ‘**identifier’.  (As
a special case, parameters of the form ‘*identifier’ may have an
annotation "‘: *expression’".)  Functions may have "return" annotation
of the form "‘-> expression’" after the parameter list.  These
annotations can be any valid Python expression.  The presence of
annotations does not change the semantics of a function.  The annotation
values are available as values of a dictionary keyed by the parameters'
names in the ‘__annotations__’ attribute of the function object.  If the
‘annotations’ import from *note __future__: 0. is used, annotations are
preserved as strings at runtime which enables postponed evaluation.
Otherwise, they are evaluated when the function definition is executed.
In this case annotations may be evaluated in a different order than they
appear in the source code.

バージョン 3.11 で変更: Parameters of the form "‘*identifier’" may have
an annotation "‘: *expression’".  See PEP 646(4).

式を即時に使用するために、無名関数 (名前に束縛されていない関数) を作成す
ることもできます。 これは *note ラムダ (lambda): 126d. の節で解説されて
いるラムダ式を使います。 ラムダ式は簡略化された関数定義の簡略表現に過ぎ
ないことに注意してください; "*note def: 13ff." 文で定義された関数もラム
ダ式で作成された関数のように、引数として渡せたり、他の名前に割り当てるこ
とができます。 複数の式とアノテーションが実行できるので、 "‘def’" 形式の
方がより強力です。

'プログラマへのメモ:' 関数は第一級オブジェクトです。関数定義内で実行され
た "‘def’" 文は、返り値や引数として渡せるローカル関数を定義します。ネス
トした関数内で使われる自由変数は、 def を含んでいる関数のローカル変数に
アクセスできます。詳細は *note 名前づけと束縛 (naming and binding):
1e59. 節を参照してください。

参考
....

PEP 3107(5) - Function Annotations

     関数アノテーションの元の仕様書。

PEP 484(6) - 型ヒント

     アノテーションの標準的な意味付けである型ヒントの定義。

PEP 526(7) - Syntax for Variable Annotations

     Ability to type hint variable declarations, including class
     variables and instance variables.

PEP 563(8) - アノテーションの遅延評価

     実行時にアノテーションを貪欲評価するのではなく文字列形式で保持する
     ことによる、アノテーションにおける前方参照のサポート

PEP 318(9) - Decorators for Functions and Methods

     Function and method decorators were introduced.  Class decorators
     were introduced in PEP 3129(10).

   ---------- Footnotes ----------

   (1) A string literal appearing as the first statement in the function
body is transformed into the function's *note __doc__: 11a9. attribute
and therefore the function's *note docstring: 2086.

   (2) https://peps.python.org/pep-0614/

   (3) https://peps.python.org/pep-0570/

   (4) https://peps.python.org/pep-0646/

   (5) https://peps.python.org/pep-3107/

   (6) https://peps.python.org/pep-0484/

   (7) https://peps.python.org/pep-0526/

   (8) https://peps.python.org/pep-0563/

   (9) https://peps.python.org/pep-0318/

   (10) https://peps.python.org/pep-3129/


File: python.info,  Node: クラス定義,  Next: コルーチン<2>,  Prev: 関数定義,  Up: 複合文 compound statement

4.8.8 クラス定義
----------------

クラス定義は、クラスオブジェクトを定義します (*note 標準型の階層: 1e46.
節参照):

     classdef    ::= [decorators] "class" classname [type_params] [inheritance] ":" suite
     inheritance ::= "(" [argument_list] ")"
     classname   ::= identifier

クラス定義は実行可能な文です。継承リストは通常、基底クラスリストを与えま
す (より高度な使い方は、 *note メタクラス: 1ed4. を参照してください)。で
すから、リストのそれぞれの要素の評価はサブクラス化しても良いクラスである
べきです。継承リストのないクラスは、デフォルトで、基底クラス *note
object: a5a. を継承するので:

     class Foo:
         pass

は、以下と同等です

     class Foo(object):
         pass

次にクラスのスイートが、新たな実行フレーム (*note 名前づけと束縛 (naming
and binding): 1e59. を参照してください) 内で、新たに作られたローカル名前
空間と元々のグローバル名前空間を使って実行されます (通常、このスイートに
は主に関数定義が含まれます)。クラスのスイートが実行し終えると、実行フレ
ームは破棄されますが、ローカルな名前空間は保存されます。(1) 次に、継承リ
ストを基底クラスに、保存されたローカル名前空間を属性値辞書に、それぞれ使
ってクラスオブジェクトが生成されます。最後に、もとのローカル名前空間にお
いて、クラス名がこのクラスオブジェクトに束縛されます。

The order in which attributes are defined in the class body is preserved
in the new class's *note __dict__: c2b.  Note that this is reliable only
right after the class is created and only for classes that were defined
using the definition syntax.

クラス作成は、 *note メタクラス: 1ed4. を利用して大幅にカスタマイズでき
ます。

関数をデコレートするのと同じように、クラスもデコレートすることが出来ます
、

     @f1(arg)
     @f2
     class Foo: pass

は、だいたい次と等価です

     class Foo: pass
     Foo = f1(arg)(f2(Foo))

デコレータ式の評価規則は関数デコレータと同じです。結果はクラス名に束縛さ
れます。

バージョン 3.9 で変更: Classes may be decorated with any valid *note
assignment_expression: 1f3f.  Previously, the grammar was much more
restrictive; see PEP 614(2) for details.

A list of *note type parameters: 293. may be given in square brackets
immediately after the class's name.  This indicates to static type
checkers that the class is generic.  At runtime, the type parameters can
be retrieved from the class's *note __type_params__: 1e88. attribute.
See *note Generic classes: 41e. for more.

バージョン 3.12 で変更: Type parameter lists are new in Python 3.12.

'プログラマのための注釈:' クラス定義内で定義された変数はクラス属性であり
、全てのインスタンス間で共有されます。インスタンス属性は、メソッドの中で
‘self.name = value’ とすることで設定できます。クラス属性もインスタンス属
性も "‘self.name’" 表記でアクセスでき、この表記でアクセスしたとき、イン
スタンス属性は同名のクラス属性を隠蔽します。クラス属性は、インスタンス属
性のデフォルト値として使えますが、そこにミュータブルな値を使うと予期せぬ
結果につながります。 *note 記述子: c1d. を使うと、詳細な実装が異なるイン
スタンス変数を作成できます。

参考
....

PEP 3115(3) - Metaclasses in Python 3000

     メタクラスの宣言を現在の文法と、メタクラス付きのクラスがどのように
     構築されるかの意味論を変更した提案

PEP 3129(4) - クラスデコレータ

     クラスデコレータを追加した提案。 関数デコレータとメソッドデコレータ
     は PEP 318(5) で導入されました。

   ---------- Footnotes ----------

   (1) A string literal appearing as the first statement in the class
body is transformed into the namespace's *note __doc__: 1c16. item and
therefore the class's *note docstring: 2086.

   (2) https://peps.python.org/pep-0614/

   (3) https://peps.python.org/pep-3115/

   (4) https://peps.python.org/pep-3129/

   (5) https://peps.python.org/pep-0318/


File: python.info,  Node: コルーチン<2>,  Next: Type parameter lists,  Prev: クラス定義,  Up: 複合文 compound statement

4.8.9 コルーチン
----------------

Added in version 3.5.

* Menu:

* コルーチン関数定義::
* async for 文::
* async with 文::


File: python.info,  Node: コルーチン関数定義,  Next: async for 文,  Up: コルーチン<2>

4.8.9.1 コルーチン関数定義
..........................

     async_funcdef ::= [decorators] "async" "def" funcname "(" [parameter_list] ")"
                       ["->" expression] ":" suite

Python で実行しているコルーチンは多くの時点で一時停止と再開ができます
(*note coroutine: 45e. を参照)。*note await: 19e. 式である *note async
for: a79. と *note async with: 59f. はコルーチン関数の本体でしか使えませ
ん。

Functions defined with ‘async def’ syntax are always coroutine
functions, even if they do not contain ‘await’ or ‘async’ keywords.

コルーチン関数の本体の中で ‘yield from’ 式を使用すると *note
SyntaxError: 172. になります。

コルーチン関数の例:

     async def func(param1, param2):
         do_stuff()
         await some_coroutine()

バージョン 3.7 で変更: ‘await’ and ‘async’ are now keywords; previously
they were only treated as such inside the body of a coroutine function.


File: python.info,  Node: async for 文,  Next: async with 文,  Prev: コルーチン関数定義,  Up: コルーチン<2>

4.8.9.2 ‘async for’ 文
......................

     async_for_stmt ::= "async" for_stmt

*note asynchronous iterable: d45. は、その ‘__anext__’ メソッドで非同期
なコードを実行可能な、*note asynchronous iterator: 190. を直接返す
‘__aiter__’ メソッドを提供しています。

‘async for’ 文によって非同期なイテラブルを簡単にイテレーションすることが
できます。

以下のコード:

     async for TARGET in ITER:
         SUITE
     else:
         SUITE2

は意味論的に以下と等価です:

     iter = (ITER)
     iter = type(iter).__aiter__(iter)
     running = True

     while running:
         try:
             TARGET = await type(iter).__anext__(iter)
         except StopAsyncIteration:
             running = False
         else:
             SUITE
     else:
         SUITE2

詳細は *note __aiter__(): bc9. や *note __anext__(): 1e6a. を参照してく
ださい。

コルーチン関数の本体の外で ‘async for’ 文を使用すると *note SyntaxError:
172. になります。


File: python.info,  Node: async with 文,  Prev: async for 文,  Up: コルーチン<2>

4.8.9.3 ‘async with’ 文
.......................

     async_with_stmt ::= "async" with_stmt

*note asynchronous context manager: 5a1. は、 'enter' メソッドと 'exit'
メソッド内部で実行を一時停止できる *note context manager: 59e. です。

以下のコード:

     async with EXPRESSION as TARGET:
         SUITE

これは次と等価です:

     manager = (EXPRESSION)
     aenter = type(manager).__aenter__
     aexit = type(manager).__aexit__
     value = await aenter(manager)
     hit_except = False

     try:
         TARGET = value
         SUITE
     except:
         hit_except = True
         if not await aexit(manager, *sys.exc_info()):
             raise
     finally:
         if not hit_except:
             await aexit(manager, None, None, None)

詳細は *note __aenter__(): 1f30. や *note __aexit__(): 158e. を参照して
ください。

コルーチン関数の本体の外で ‘async with’ 文を使用すると *note
SyntaxError: 172. になります。

参考
....

PEP 492(1) - async 構文および await 構文付きのコルーチン

     コルーチンを Python のまともな独り立ちした概念にし、サポートする構
     文を追加した提案。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0492/


File: python.info,  Node: Type parameter lists,  Prev: コルーチン<2>,  Up: 複合文 compound statement

4.8.10 Type parameter lists
---------------------------

Added in version 3.12.

バージョン 3.13 で変更: Support for default values was added (see PEP
696(1)).

     type_params  ::= "[" type_param ("," type_param)* "]"
     type_param   ::= typevar | typevartuple | paramspec
     typevar      ::= identifier (":" expression)? ("=" expression)?
     typevartuple ::= "*" identifier ("=" expression)?
     paramspec    ::= "**" identifier ("=" expression)?

*note Functions: 13ff. (including *note coroutines: 59b.), *note
classes: 12a5. and *note type aliases: 404. may contain a type parameter
list:

     def max[T](args: list[T]) -> T:
         ...

     async def amax[T](args: list[T]) -> T:
         ...

     class Bag[T]:
         def __iter__(self) -> Iterator[T]:
             ...

         def add(self, arg: T) -> None:
             ...

     type ListOrSet[T] = list[T] | set[T]

Semantically, this indicates that the function, class, or type alias is
generic over a type variable.  This information is primarily used by
static type checkers, and at runtime, generic objects behave much like
their non-generic counterparts.

Type parameters are declared in square brackets (‘[]’) immediately after
the name of the function, class, or type alias.  The type parameters are
accessible within the scope of the generic object, but not elsewhere.
Thus, after a declaration ‘def func[T](): pass’, the name ‘T’ is not
available in the module scope.  Below, the semantics of generic objects
are described with more precision.  The scope of type parameters is
modeled with a special function (technically, an *note annotation scope:
16d.) that wraps the creation of the generic object.

Generic functions, classes, and type aliases have a *note
__type_params__: 2098. attribute listing their type parameters.

Type parameters come in three kinds:

   * *note typing.TypeVar: 143, introduced by a plain name (e.g., ‘T’).
     Semantically, this represents a single type to a type checker.

   * *note typing.TypeVarTuple: 145, introduced by a name prefixed with
     a single asterisk (e.g., ‘*Ts’).  Semantically, this stands for a
     tuple of any number of types.

   * *note typing.ParamSpec: 144, introduced by a name prefixed with two
     asterisks (e.g., ‘**P’).  Semantically, this stands for the
     parameters of a callable.

*note typing.TypeVar: 143. declarations can define 'bounds' and
'constraints' with a colon (‘:’) followed by an expression.  A single
expression after the colon indicates a bound (e.g.  ‘T: int’).
Semantically, this means that the ‘typing.TypeVar’ can only represent
types that are a subtype of this bound.  A parenthesized tuple of
expressions after the colon indicates a set of constraints (e.g.  ‘T:
(str, bytes)’).  Each member of the tuple should be a type (again, this
is not enforced at runtime).  Constrained type variables can only take
on one of the types in the list of constraints.

For ‘typing.TypeVar’s declared using the type parameter list syntax, the
bound and constraints are not evaluated when the generic object is
created, but only when the value is explicitly accessed through the
attributes ‘__bound__’ and ‘__constraints__’.  To accomplish this, the
bounds or constraints are evaluated in a separate *note annotation
scope: 16d.

*note typing.TypeVarTuple: 145.s and *note typing.ParamSpec: 144.s
cannot have bounds or constraints.

All three flavors of type parameters can also have a 'default value',
which is used when the type parameter is not explicitly provided.  This
is added by appending a single equals sign (‘=’) followed by an
expression.  Like the bounds and constraints of type variables, the
default value is not evaluated when the object is created, but only when
the type parameter's ‘__default__’ attribute is accessed.  To this end,
the default value is evaluated in a separate *note annotation scope:
16d.  If no default value is specified for a type parameter, the
‘__default__’ attribute is set to the special sentinel object *note
typing.NoDefault: 243.

The following example indicates the full set of allowed type parameter
declarations:

     def overly_generic[
        SimpleTypeVar,
        TypeVarWithDefault = int,
        TypeVarWithBound: int,
        TypeVarWithConstraints: (str, bytes),
        *SimpleTypeVarTuple = (int, float),
        **SimpleParamSpec = (str, bytearray),
     ](
        a: SimpleTypeVar,
        b: TypeVarWithDefault,
        c: TypeVarWithBound,
        d: Callable[SimpleParamSpec, TypeVarWithConstraints],
        *e: SimpleTypeVarTuple,
     ): ...

* Menu:

* Generic functions::
* Generic classes::
* Generic type aliases::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0696/


File: python.info,  Node: Generic functions,  Next: Generic classes,  Up: Type parameter lists

4.8.10.1 Generic functions
..........................

Generic functions are declared as follows:

     def func[T](arg: T): ...

This syntax is equivalent to:

     annotation-def TYPE_PARAMS_OF_func():
         T = typing.TypeVar("T")
         def func(arg: T): ...
         func.__type_params__ = (T,)
         return func
     func = TYPE_PARAMS_OF_func()

Here ‘annotation-def’ indicates an *note annotation scope: 16d, which is
not actually bound to any name at runtime.  (One other liberty is taken
in the translation: the syntax does not go through attribute access on
the *note typing: ed. module, but creates an instance of *note
typing.TypeVar: 143. directly.)

The annotations of generic functions are evaluated within the annotation
scope used for declaring the type parameters, but the function's
defaults and decorators are not.

The following example illustrates the scoping rules for these cases, as
well as for additional flavors of type parameters:

     @decorator
     def func[T: int, *Ts, **P](*args: *Ts, arg: Callable[P, T] = some_default):
         ...

Except for the *note lazy evaluation: 423. of the *note TypeVar: 143.
bound, this is equivalent to:

     DEFAULT_OF_arg = some_default

     annotation-def TYPE_PARAMS_OF_func():

         annotation-def BOUND_OF_T():
             return int
         # In reality, BOUND_OF_T() is evaluated only on demand.
         T = typing.TypeVar("T", bound=BOUND_OF_T())

         Ts = typing.TypeVarTuple("Ts")
         P = typing.ParamSpec("P")

         def func(*args: *Ts, arg: Callable[P, T] = DEFAULT_OF_arg):
             ...

         func.__type_params__ = (T, Ts, P)
         return func
     func = decorator(TYPE_PARAMS_OF_func())

The capitalized names like ‘DEFAULT_OF_arg’ are not actually bound at
runtime.


File: python.info,  Node: Generic classes,  Next: Generic type aliases,  Prev: Generic functions,  Up: Type parameter lists

4.8.10.2 Generic classes
........................

Generic classes are declared as follows:

     class Bag[T]: ...

This syntax is equivalent to:

     annotation-def TYPE_PARAMS_OF_Bag():
         T = typing.TypeVar("T")
         class Bag(typing.Generic[T]):
             __type_params__ = (T,)
             ...
         return Bag
     Bag = TYPE_PARAMS_OF_Bag()

Here again ‘annotation-def’ (not a real keyword) indicates an *note
annotation scope: 16d, and the name ‘TYPE_PARAMS_OF_Bag’ is not actually
bound at runtime.

Generic classes implicitly inherit from *note typing.Generic: 157c.  The
base classes and keyword arguments of generic classes are evaluated
within the type scope for the type parameters, and decorators are
evaluated outside that scope.  This is illustrated by this example:

     @decorator
     class Bag(Base[T], arg=T): ...

これは次と等価です:

     annotation-def TYPE_PARAMS_OF_Bag():
         T = typing.TypeVar("T")
         class Bag(Base[T], typing.Generic[T], arg=T):
             __type_params__ = (T,)
             ...
         return Bag
     Bag = decorator(TYPE_PARAMS_OF_Bag())


File: python.info,  Node: Generic type aliases,  Prev: Generic classes,  Up: Type parameter lists

4.8.10.3 Generic type aliases
.............................

The *note type: 404. statement can also be used to create a generic type
alias:

     type ListOrSet[T] = list[T] | set[T]

Except for the *note lazy evaluation: 423. of the value, this is
equivalent to:

     annotation-def TYPE_PARAMS_OF_ListOrSet():
         T = typing.TypeVar("T")

         annotation-def VALUE_OF_ListOrSet():
             return list[T] | set[T]
         # In reality, the value is lazily evaluated
         return typing.TypeAliasType("ListOrSet", VALUE_OF_ListOrSet(), type_params=(T,))
     ListOrSet = TYPE_PARAMS_OF_ListOrSet()

Here, ‘annotation-def’ (not a real keyword) indicates an *note
annotation scope: 16d.  The capitalized names like
‘TYPE_PARAMS_OF_ListOrSet’ are not actually bound at runtime.

脚注
....


File: python.info,  Node: トップレベル要素,  Next: 完全な文法仕様,  Prev: 複合文 compound statement,  Up: Python 言語リファレンス

4.9 トップレベル要素
====================

Python インタプリタは、標準入力や、プログラムの引数として与えられたスク
リプト、対話的にタイプ入力された命令、モジュールのソースファイルなど、様
々な入力源から入力を得ることができます。この章では、それぞれの場合に用い
られる構文法について説明しています。

* Menu:

* 完全な Python プログラム::
* ファイル入力::
* 対話的入力::
* 式入力::


File: python.info,  Node: 完全な Python プログラム,  Next: ファイル入力,  Up: トップレベル要素

4.9.1 完全な Python プログラム
------------------------------

言語仕様の中では、その言語を処理するインタプリタがどのように起動されるか
まで規定する必要はないのですが、完全な Python プログラムの概念を知ってお
くと役に立ちます。完全な Python プログラムは、最小限に初期化された環境:
全ての組み込み変数と標準モジュールが利用可能で、かつ *note sys: c3. (様
々なシステムサービス)、 *note builtins: e. (組み込み関数、例外、および
‘None’)、 *note __main__: 1. の 3 つを除く全てのモジュールが初期化されて
いない状態で動作します。 *note __main__: 1. は、完全なプログラムを実行す
る際に、ローカルおよびグローバルな名前空間を提供するために用いられます。

完全な Python プログラムの構文は、下の節で述べるファイル入力のためのもの
です。

インタプリタは、対話的モード (interactive mode) で起動されることもありま
す; この場合、インタプリタは完全なプログラムを読んで実行するのではなく、
一度に単一の実行文 (複合文のときもあります) を読み込んで実行します。初期
状態の環境は、完全なプログラムを実行するときの環境と同じです; 各実行文は
、 *note __main__: 1. の名前空間内で実行されます。

完全なプログラムは3つの形式でインタープリタに渡せます: *note -c: 5aa.
'string' コマンドラインオプションで、コマンドラインの第 1 引数で渡される
ファイル、あるいは標準入力として渡します。 ファイルや標準入力が tty デバ
イスだった場合、インタープリタは対話モードに入ります。 それ以外の場合は
、ファイルを完全なプログラムとして実行します。


File: python.info,  Node: ファイル入力,  Next: 対話的入力,  Prev: 完全な Python プログラム,  Up: トップレベル要素

4.9.2 ファイル入力
------------------

非対話的なファイルから読み出された入力は、全て同じ形式:

     file_input ::= (NEWLINE | statement)*

をとります。この構文法は、以下の状況で用いられます:

   * (ファイルや文字列内の) 完全な Python プログラムを構文解析するとき;

   * モジュールを構文解析するとき;

   * *note exec(): 164. で渡された文字列を構文解析するとき;


File: python.info,  Node: 対話的入力,  Next: 式入力,  Prev: ファイル入力,  Up: トップレベル要素

4.9.3 対話的入力
----------------

対話モードでの入力は、以下の文法の下に構文解析されます:

     interactive_input ::= [stmt_list] NEWLINE | compound_stmt NEWLINE

対話モードでは、(トップレベルの) 複合文の最後に空白行を入れなくてはなら
ないことに注意してください; これは、複合文の終端をパーザが検出するための
手がかりとして必要です。


File: python.info,  Node: 式入力,  Prev: 対話的入力,  Up: トップレベル要素

4.9.4 式入力
------------

式入力には *note eval(): 165. が使われます。これは先頭の空白を無視します
。 *note eval(): 165. に対する文字列引数は、以下の形式をとらなければなり
ません:

     eval_input ::= expression_list NEWLINE*


File: python.info,  Node: 完全な文法仕様,  Prev: トップレベル要素,  Up: Python 言語リファレンス

4.10 完全な文法仕様
===================

以下に示すのは Python の完全な文法です。CPython のパーサを生成するための
文法定義から直接導かれたものです (Grammar/python.gram(1) を参照のこと)。
ここに示すのは、コード生成およびエラー処理に関係する部分を省略したバージ
ョンです。

文法の記法は EBNF(2) と PEG(3) との混合です。特に、‘&’ にシンボル、トー
クンまたは括弧でくくられたグループが続く場合、それは正の先読み (positive
lookahead) (すなわち、文法にマッチするためには必要だが、マッチ後に消費さ
れない) です。一方で、‘!’ は負の先読み (negative lookahead) (すなわち、
マッチ 'しない' ために必要) です。 PEG の順序付き選択 (ordered choice) の
区切り文字として (伝統的に使われている ‘/’ ではなく) ‘|’ を使用します。
文法の記法について、詳しくは PEP 617(4) を見てください。

     # PEG grammar for Python

     @trailer '''
     void *
     _PyPegen_parse(Parser *p)
     {
         // Initialize keywords
         p->keywords = reserved_keywords;
         p->n_keyword_lists = n_keyword_lists;
         p->soft_keywords = soft_keywords;

         // Run parser
         void *result = NULL;
         if (p->start_rule == Py_file_input) {
             result = file_rule(p);
         } else if (p->start_rule == Py_single_input) {
             result = interactive_rule(p);
         } else if (p->start_rule == Py_eval_input) {
             result = eval_rule(p);
         } else if (p->start_rule == Py_func_type_input) {
             result = func_type_rule(p);
         }

         return result;
     }
     '''

     # ========================= START OF THE GRAMMAR =========================

     # General grammatical elements and rules:
     #
     # * Strings with double quotes (") denote SOFT KEYWORDS
     # * Strings with single quotes (') denote KEYWORDS
     # * Upper case names (NAME) denote tokens in the Grammar/Tokens file
     # * Rule names starting with "invalid_" are used for specialized syntax errors
     #     - These rules are NOT used in the first pass of the parser.
     #     - Only if the first pass fails to parse, a second pass including the invalid
     #       rules will be executed.
     #     - If the parser fails in the second phase with a generic syntax error, the
     #       location of the generic failure of the first pass will be used (this avoids
     #       reporting incorrect locations due to the invalid rules).
     #     - The order of the alternatives involving invalid rules matter
     #       (like any rule in PEG).
     #
     # Grammar Syntax (see PEP 617 for more information):
     #
     # rule_name: expression
     #   Optionally, a type can be included right after the rule name, which
     #   specifies the return type of the C or Python function corresponding to the
     #   rule:
     # rule_name[return_type]: expression
     #   If the return type is omitted, then a void * is returned in C and an Any in
     #   Python.
     # e1 e2
     #   Match e1, then match e2.
     # e1 | e2
     #   Match e1 or e2.
     #   The first alternative can also appear on the line after the rule name for
     #   formatting purposes. In that case, a | must be used before the first
     #   alternative, like so:
     #       rule_name[return_type]:
     #            | first_alt
     #            | second_alt
     # ( e )
     #   Match e (allows also to use other operators in the group like '(e)*')
     # [ e ] or e?
     #   Optionally match e.
     # e*
     #   Match zero or more occurrences of e.
     # e+
     #   Match one or more occurrences of e.
     # s.e+
     #   Match one or more occurrences of e, separated by s. The generated parse tree
     #   does not include the separator. This is otherwise identical to (e (s e)*).
     # &e
     #   Succeed if e can be parsed, without consuming any input.
     # !e
     #   Fail if e can be parsed, without consuming any input.
     # ~
     #   Commit to the current alternative, even if it fails to parse.
     # &&e
     #   Eager parse e. The parser will not backtrack and will immediately
     #   fail with SyntaxError if e cannot be parsed.
     #

     # STARTING RULES
     # ==============

     file[mod_ty]: a=[statements] ENDMARKER { _PyPegen_make_module(p, a) }
     interactive[mod_ty]: a=statement_newline { _PyAST_Interactive(a, p->arena) }
     eval[mod_ty]: a=expressions NEWLINE* ENDMARKER { _PyAST_Expression(a, p->arena) }
     func_type[mod_ty]: '(' a=[type_expressions] ')' '->' b=expression NEWLINE* ENDMARKER { _PyAST_FunctionType(a, b, p->arena) }

     # GENERAL STATEMENTS
     # ==================

     statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }

     statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmts { a }

     statement_newline[asdl_stmt_seq*]:
         | a=compound_stmt NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
         | simple_stmts
         | NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, CHECK(stmt_ty, _PyAST_Pass(EXTRA))) }
         | ENDMARKER { _PyPegen_interactive_exit(p) }

     simple_stmts[asdl_stmt_seq*]:
         | a=simple_stmt !';' NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } # Not needed, there for speedup
         | a[asdl_stmt_seq*]=';'.simple_stmt+ [';'] NEWLINE { a }

     # NOTE: assignment MUST precede expression, else parsing a simple assignment
     # will throw a SyntaxError.
     simple_stmt[stmt_ty] (memo):
         | assignment
         | &"type" type_alias
         | e=star_expressions { _PyAST_Expr(e, EXTRA) }
         | &'return' return_stmt
         | &('import' | 'from') import_stmt
         | &'raise' raise_stmt
         | 'pass' { _PyAST_Pass(EXTRA) }
         | &'del' del_stmt
         | &'yield' yield_stmt
         | &'assert' assert_stmt
         | 'break' { _PyAST_Break(EXTRA) }
         | 'continue' { _PyAST_Continue(EXTRA) }
         | &'global' global_stmt
         | &'nonlocal' nonlocal_stmt

     compound_stmt[stmt_ty]:
         | &('def' | '@' | 'async') function_def
         | &'if' if_stmt
         | &('class' | '@') class_def
         | &('with' | 'async') with_stmt
         | &('for' | 'async') for_stmt
         | &'try' try_stmt
         | &'while' while_stmt
         | match_stmt

     # SIMPLE STATEMENTS
     # =================

     # NOTE: annotated_rhs may start with 'yield'; yield_expr must start with 'yield'
     assignment[stmt_ty]:
         | a=NAME ':' b=expression c=['=' d=annotated_rhs { d }] {
             CHECK_VERSION(
                 stmt_ty,
                 6,
                 "Variable annotation syntax is",
                 _PyAST_AnnAssign(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, c, 1, EXTRA)
             ) }
         | a=('(' b=single_target ')' { b }
              | single_subscript_attribute_target) ':' b=expression c=['=' d=annotated_rhs { d }] {
             CHECK_VERSION(stmt_ty, 6, "Variable annotations syntax is", _PyAST_AnnAssign(a, b, c, 0, EXTRA)) }
         | a[asdl_expr_seq*]=(z=star_targets '=' { z })+ b=(yield_expr | star_expressions) !'=' tc=[TYPE_COMMENT] {
              _PyAST_Assign(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
         | a=single_target b=augassign ~ c=(yield_expr | star_expressions) {
              _PyAST_AugAssign(a, b->kind, c, EXTRA) }
         | invalid_assignment

     annotated_rhs[expr_ty]: yield_expr | star_expressions

     augassign[AugOperator*]:
         | '+=' { _PyPegen_augoperator(p, Add) }
         | '-=' { _PyPegen_augoperator(p, Sub) }
         | '*=' { _PyPegen_augoperator(p, Mult) }
         | '@=' { CHECK_VERSION(AugOperator*, 5, "The '@' operator is", _PyPegen_augoperator(p, MatMult)) }
         | '/=' { _PyPegen_augoperator(p, Div) }
         | '%=' { _PyPegen_augoperator(p, Mod) }
         | '&=' { _PyPegen_augoperator(p, BitAnd) }
         | '|=' { _PyPegen_augoperator(p, BitOr) }
         | '^=' { _PyPegen_augoperator(p, BitXor) }
         | '<<=' { _PyPegen_augoperator(p, LShift) }
         | '>>=' { _PyPegen_augoperator(p, RShift) }
         | '**=' { _PyPegen_augoperator(p, Pow) }
         | '//=' { _PyPegen_augoperator(p, FloorDiv) }

     return_stmt[stmt_ty]:
         | 'return' a=[star_expressions] { _PyAST_Return(a, EXTRA) }

     raise_stmt[stmt_ty]:
         | 'raise' a=expression b=['from' z=expression { z }] { _PyAST_Raise(a, b, EXTRA) }
         | 'raise' { _PyAST_Raise(NULL, NULL, EXTRA) }

     global_stmt[stmt_ty]: 'global' a[asdl_expr_seq*]=','.NAME+ {
         _PyAST_Global(CHECK(asdl_identifier_seq*, _PyPegen_map_names_to_ids(p, a)), EXTRA) }

     nonlocal_stmt[stmt_ty]: 'nonlocal' a[asdl_expr_seq*]=','.NAME+ {
         _PyAST_Nonlocal(CHECK(asdl_identifier_seq*, _PyPegen_map_names_to_ids(p, a)), EXTRA) }

     del_stmt[stmt_ty]:
         | 'del' a=del_targets &(';' | NEWLINE) { _PyAST_Delete(a, EXTRA) }
         | invalid_del_stmt

     yield_stmt[stmt_ty]: y=yield_expr { _PyAST_Expr(y, EXTRA) }

     assert_stmt[stmt_ty]: 'assert' a=expression b=[',' z=expression { z }] { _PyAST_Assert(a, b, EXTRA) }

     import_stmt[stmt_ty]:
         | invalid_import
         | import_name
         | import_from

     # Import statements
     # -----------------

     import_name[stmt_ty]: 'import' a=dotted_as_names { _PyAST_Import(a, EXTRA) }
     # note below: the ('.' | '...') is necessary because '...' is tokenized as ELLIPSIS
     import_from[stmt_ty]:
         | 'from' a=('.' | '...')* b=dotted_name 'import' c=import_from_targets {
             _PyAST_ImportFrom(b->v.Name.id, c, _PyPegen_seq_count_dots(a), EXTRA) }
         | 'from' a=('.' | '...')+ 'import' b=import_from_targets {
             _PyAST_ImportFrom(NULL, b, _PyPegen_seq_count_dots(a), EXTRA) }
     import_from_targets[asdl_alias_seq*]:
         | '(' a=import_from_as_names [','] ')' { a }
         | import_from_as_names !','
         | '*' { (asdl_alias_seq*)_PyPegen_singleton_seq(p, CHECK(alias_ty, _PyPegen_alias_for_star(p, EXTRA))) }
         | invalid_import_from_targets
     import_from_as_names[asdl_alias_seq*]:
         | a[asdl_alias_seq*]=','.import_from_as_name+ { a }
     import_from_as_name[alias_ty]:
         | a=NAME b=['as' z=NAME { z }] { _PyAST_alias(a->v.Name.id,
                                                    (b) ? ((expr_ty) b)->v.Name.id : NULL,
                                                    EXTRA) }
     dotted_as_names[asdl_alias_seq*]:
         | a[asdl_alias_seq*]=','.dotted_as_name+ { a }
     dotted_as_name[alias_ty]:
         | a=dotted_name b=['as' z=NAME { z }] { _PyAST_alias(a->v.Name.id,
                                                           (b) ? ((expr_ty) b)->v.Name.id : NULL,
                                                           EXTRA) }
     dotted_name[expr_ty]:
         | a=dotted_name '.' b=NAME { _PyPegen_join_names_with_dot(p, a, b) }
         | NAME

     # COMPOUND STATEMENTS
     # ===================

     # Common elements
     # ---------------

     block[asdl_stmt_seq*] (memo):
         | NEWLINE INDENT a=statements DEDENT { a }
         | simple_stmts
         | invalid_block

     decorators[asdl_expr_seq*]: a[asdl_expr_seq*]=('@' f=named_expression NEWLINE { f })+ { a }

     # Class definitions
     # -----------------

     class_def[stmt_ty]:
         | a=decorators b=class_def_raw { _PyPegen_class_def_decorators(p, a, b) }
         | class_def_raw

     class_def_raw[stmt_ty]:
         | invalid_class_def_raw
         | 'class' a=NAME t=[type_params] b=['(' z=[arguments] ')' { z }] ':' c=block {
             _PyAST_ClassDef(a->v.Name.id,
                          (b) ? ((expr_ty) b)->v.Call.args : NULL,
                          (b) ? ((expr_ty) b)->v.Call.keywords : NULL,
                          c, NULL, t, EXTRA) }

     # Function definitions
     # --------------------

     function_def[stmt_ty]:
         | d=decorators f=function_def_raw { _PyPegen_function_def_decorators(p, d, f) }
         | function_def_raw

     function_def_raw[stmt_ty]:
         | invalid_def_raw
         | 'def' n=NAME t=[type_params] '(' params=[params] ')' a=['->' z=expression { z }] ':' tc=[func_type_comment] b=block {
             _PyAST_FunctionDef(n->v.Name.id,
                             (params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)),
                             b, NULL, a, NEW_TYPE_COMMENT(p, tc), t, EXTRA) }
         | 'async' 'def' n=NAME t=[type_params] '(' params=[params] ')' a=['->' z=expression { z }] ':' tc=[func_type_comment] b=block {
             CHECK_VERSION(
                 stmt_ty,
                 5,
                 "Async functions are",
                 _PyAST_AsyncFunctionDef(n->v.Name.id,
                                 (params) ? params : CHECK(arguments_ty, _PyPegen_empty_arguments(p)),
                                 b, NULL, a, NEW_TYPE_COMMENT(p, tc), t, EXTRA)
             ) }

     # Function parameters
     # -------------------

     params[arguments_ty]:
         | invalid_parameters
         | parameters

     parameters[arguments_ty]:
         | a=slash_no_default b[asdl_arg_seq*]=param_no_default* c=param_with_default* d=[star_etc] {
             CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, a, NULL, b, c, d)) }
         | a=slash_with_default b=param_with_default* c=[star_etc] {
             CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, NULL, a, NULL, b, c)) }
         | a[asdl_arg_seq*]=param_no_default+ b=param_with_default* c=[star_etc] {
             _PyPegen_make_arguments(p, NULL, NULL, a, b, c) }
         | a=param_with_default+ b=[star_etc] { _PyPegen_make_arguments(p, NULL, NULL, NULL, a, b)}
         | a=star_etc { _PyPegen_make_arguments(p, NULL, NULL, NULL, NULL, a) }

     # Some duplication here because we can't write (',' | &')'),
     # which is because we don't support empty alternatives (yet).

     slash_no_default[asdl_arg_seq*]:
         | a[asdl_arg_seq*]=param_no_default+ '/' ',' { a }
         | a[asdl_arg_seq*]=param_no_default+ '/' &')' { a }
     slash_with_default[SlashWithDefault*]:
         | a=param_no_default* b=param_with_default+ '/' ',' { _PyPegen_slash_with_default(p, (asdl_arg_seq *)a, b) }
         | a=param_no_default* b=param_with_default+ '/' &')' { _PyPegen_slash_with_default(p, (asdl_arg_seq *)a, b) }

     star_etc[StarEtc*]:
         | invalid_star_etc
         | '*' a=param_no_default b=param_maybe_default* c=[kwds] {
             _PyPegen_star_etc(p, a, b, c) }
         | '*' a=param_no_default_star_annotation b=param_maybe_default* c=[kwds] {
             _PyPegen_star_etc(p, a, b, c) }
         | '*' ',' b=param_maybe_default+ c=[kwds] {
             _PyPegen_star_etc(p, NULL, b, c) }
         | a=kwds { _PyPegen_star_etc(p, NULL, NULL, a) }

     kwds[arg_ty]:
         | invalid_kwds
         | '**' a=param_no_default { a }

     # One parameter.  This *includes* a following comma and type comment.
     #
     # There are three styles:
     # - No default
     # - With default
     # - Maybe with default
     #
     # There are two alternative forms of each, to deal with type comments:
     # - Ends in a comma followed by an optional type comment
     # - No comma, optional type comment, must be followed by close paren
     # The latter form is for a final parameter without trailing comma.
     #

     param_no_default[arg_ty]:
         | a=param ',' tc=TYPE_COMMENT? { _PyPegen_add_type_comment_to_arg(p, a, tc) }
         | a=param tc=TYPE_COMMENT? &')' { _PyPegen_add_type_comment_to_arg(p, a, tc) }
     param_no_default_star_annotation[arg_ty]:
         | a=param_star_annotation ',' tc=TYPE_COMMENT? { _PyPegen_add_type_comment_to_arg(p, a, tc) }
         | a=param_star_annotation tc=TYPE_COMMENT? &')' { _PyPegen_add_type_comment_to_arg(p, a, tc) }
     param_with_default[NameDefaultPair*]:
         | a=param c=default ',' tc=TYPE_COMMENT? { _PyPegen_name_default_pair(p, a, c, tc) }
         | a=param c=default tc=TYPE_COMMENT? &')' { _PyPegen_name_default_pair(p, a, c, tc) }
     param_maybe_default[NameDefaultPair*]:
         | a=param c=default? ',' tc=TYPE_COMMENT? { _PyPegen_name_default_pair(p, a, c, tc) }
         | a=param c=default? tc=TYPE_COMMENT? &')' { _PyPegen_name_default_pair(p, a, c, tc) }
     param[arg_ty]: a=NAME b=annotation? { _PyAST_arg(a->v.Name.id, b, NULL, EXTRA) }
     param_star_annotation[arg_ty]: a=NAME b=star_annotation { _PyAST_arg(a->v.Name.id, b, NULL, EXTRA) }
     annotation[expr_ty]: ':' a=expression { a }
     star_annotation[expr_ty]: ':' a=star_expression { a }
     default[expr_ty]: '=' a=expression { a } | invalid_default

     # If statement
     # ------------

     if_stmt[stmt_ty]:
         | invalid_if_stmt
         | 'if' a=named_expression ':' b=block c=elif_stmt {
             _PyAST_If(a, b, CHECK(asdl_stmt_seq*, _PyPegen_singleton_seq(p, c)), EXTRA) }
         | 'if' a=named_expression ':' b=block c=[else_block] { _PyAST_If(a, b, c, EXTRA) }
     elif_stmt[stmt_ty]:
         | invalid_elif_stmt
         | 'elif' a=named_expression ':' b=block c=elif_stmt {
             _PyAST_If(a, b, CHECK(asdl_stmt_seq*, _PyPegen_singleton_seq(p, c)), EXTRA) }
         | 'elif' a=named_expression ':' b=block c=[else_block] { _PyAST_If(a, b, c, EXTRA) }
     else_block[asdl_stmt_seq*]:
         | invalid_else_stmt
         | 'else' &&':' b=block { b }

     # While statement
     # ---------------

     while_stmt[stmt_ty]:
         | invalid_while_stmt
         | 'while' a=named_expression ':' b=block c=[else_block] { _PyAST_While(a, b, c, EXTRA) }

     # For statement
     # -------------

     for_stmt[stmt_ty]:
         | invalid_for_stmt
         | 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
             _PyAST_For(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA) }
         | 'async' 'for' t=star_targets 'in' ~ ex=star_expressions ':' tc=[TYPE_COMMENT] b=block el=[else_block] {
             CHECK_VERSION(stmt_ty, 5, "Async for loops are", _PyAST_AsyncFor(t, ex, b, el, NEW_TYPE_COMMENT(p, tc), EXTRA)) }
         | invalid_for_target

     # With statement
     # --------------

     with_stmt[stmt_ty]:
         | invalid_with_stmt_indent
         | 'with' '(' a[asdl_withitem_seq*]=','.with_item+ ','? ')' ':' tc=[TYPE_COMMENT] b=block {
            _PyAST_With(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
         | 'with' a[asdl_withitem_seq*]=','.with_item+ ':' tc=[TYPE_COMMENT] b=block {
             _PyAST_With(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
         | 'async' 'with' '(' a[asdl_withitem_seq*]=','.with_item+ ','? ')' ':' b=block {
            CHECK_VERSION(stmt_ty, 5, "Async with statements are", _PyAST_AsyncWith(a, b, NULL, EXTRA)) }
         | 'async' 'with' a[asdl_withitem_seq*]=','.with_item+ ':' tc=[TYPE_COMMENT] b=block {
            CHECK_VERSION(stmt_ty, 5, "Async with statements are", _PyAST_AsyncWith(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA)) }
         | invalid_with_stmt

     with_item[withitem_ty]:
         | e=expression 'as' t=star_target &(',' | ')' | ':') { _PyAST_withitem(e, t, p->arena) }
         | invalid_with_item
         | e=expression { _PyAST_withitem(e, NULL, p->arena) }

     # Try statement
     # -------------

     try_stmt[stmt_ty]:
         | invalid_try_stmt
         | 'try' &&':' b=block f=finally_block { _PyAST_Try(b, NULL, NULL, f, EXTRA) }
         | 'try' &&':' b=block ex[asdl_excepthandler_seq*]=except_block+ el=[else_block] f=[finally_block] { _PyAST_Try(b, ex, el, f, EXTRA) }
         | 'try' &&':' b=block ex[asdl_excepthandler_seq*]=except_star_block+ el=[else_block] f=[finally_block] {
             CHECK_VERSION(stmt_ty, 11, "Exception groups are",
                           _PyAST_TryStar(b, ex, el, f, EXTRA)) }


     # Except statement
     # ----------------

     except_block[excepthandler_ty]:
         | invalid_except_stmt_indent
         | 'except' e=expression t=['as' z=NAME { z }] ':' b=block {
             _PyAST_ExceptHandler(e, (t) ? ((expr_ty) t)->v.Name.id : NULL, b, EXTRA) }
         | 'except' ':' b=block { _PyAST_ExceptHandler(NULL, NULL, b, EXTRA) }
         | invalid_except_stmt
     except_star_block[excepthandler_ty]:
         | invalid_except_star_stmt_indent
         | 'except' '*' e=expression t=['as' z=NAME { z }] ':' b=block {
             _PyAST_ExceptHandler(e, (t) ? ((expr_ty) t)->v.Name.id : NULL, b, EXTRA) }
         | invalid_except_stmt
     finally_block[asdl_stmt_seq*]:
         | invalid_finally_stmt
         | 'finally' &&':' a=block { a }

     # Match statement
     # ---------------

     match_stmt[stmt_ty]:
         | "match" subject=subject_expr ':' NEWLINE INDENT cases[asdl_match_case_seq*]=case_block+ DEDENT {
             CHECK_VERSION(stmt_ty, 10, "Pattern matching is", _PyAST_Match(subject, cases, EXTRA)) }
         | invalid_match_stmt

     subject_expr[expr_ty]:
         | value=star_named_expression ',' values=star_named_expressions? {
             _PyAST_Tuple(CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, value, values)), Load, EXTRA) }
         | named_expression

     case_block[match_case_ty]:
         | invalid_case_block
         | "case" pattern=patterns guard=guard? ':' body=block {
             _PyAST_match_case(pattern, guard, body, p->arena) }

     guard[expr_ty]: 'if' guard=named_expression { guard }

     patterns[pattern_ty]:
         | patterns[asdl_pattern_seq*]=open_sequence_pattern {
             _PyAST_MatchSequence(patterns, EXTRA) }
         | pattern

     pattern[pattern_ty]:
         | as_pattern
         | or_pattern

     as_pattern[pattern_ty]:
         | pattern=or_pattern 'as' target=pattern_capture_target {
             _PyAST_MatchAs(pattern, target->v.Name.id, EXTRA) }
         | invalid_as_pattern

     or_pattern[pattern_ty]:
         | patterns[asdl_pattern_seq*]='|'.closed_pattern+ {
             asdl_seq_LEN(patterns) == 1 ? asdl_seq_GET(patterns, 0) : _PyAST_MatchOr(patterns, EXTRA) }

     closed_pattern[pattern_ty] (memo):
         | literal_pattern
         | capture_pattern
         | wildcard_pattern
         | value_pattern
         | group_pattern
         | sequence_pattern
         | mapping_pattern
         | class_pattern

     # Literal patterns are used for equality and identity constraints
     literal_pattern[pattern_ty]:
         | value=signed_number !('+' | '-') { _PyAST_MatchValue(value, EXTRA) }
         | value=complex_number { _PyAST_MatchValue(value, EXTRA) }
         | value=strings { _PyAST_MatchValue(value, EXTRA) }
         | 'None' { _PyAST_MatchSingleton(Py_None, EXTRA) }
         | 'True' { _PyAST_MatchSingleton(Py_True, EXTRA) }
         | 'False' { _PyAST_MatchSingleton(Py_False, EXTRA) }

     # Literal expressions are used to restrict permitted mapping pattern keys
     literal_expr[expr_ty]:
         | signed_number !('+' | '-')
         | complex_number
         | strings
         | 'None' { _PyAST_Constant(Py_None, NULL, EXTRA) }
         | 'True' { _PyAST_Constant(Py_True, NULL, EXTRA) }
         | 'False' { _PyAST_Constant(Py_False, NULL, EXTRA) }

     complex_number[expr_ty]:
         | real=signed_real_number '+' imag=imaginary_number {
             _PyAST_BinOp(real, Add, imag, EXTRA) }
         | real=signed_real_number '-' imag=imaginary_number  {
             _PyAST_BinOp(real, Sub, imag, EXTRA) }

     signed_number[expr_ty]:
         | NUMBER
         | '-' number=NUMBER { _PyAST_UnaryOp(USub, number, EXTRA) }

     signed_real_number[expr_ty]:
         | real_number
         | '-' real=real_number { _PyAST_UnaryOp(USub, real, EXTRA) }

     real_number[expr_ty]:
         | real=NUMBER { _PyPegen_ensure_real(p, real) }

     imaginary_number[expr_ty]:
         | imag=NUMBER { _PyPegen_ensure_imaginary(p, imag) }

     capture_pattern[pattern_ty]:
         | target=pattern_capture_target { _PyAST_MatchAs(NULL, target->v.Name.id, EXTRA) }

     pattern_capture_target[expr_ty]:
         | !"_" name=NAME !('.' | '(' | '=') {
             _PyPegen_set_expr_context(p, name, Store) }

     wildcard_pattern[pattern_ty]:
         | "_" { _PyAST_MatchAs(NULL, NULL, EXTRA) }

     value_pattern[pattern_ty]:
         | attr=attr !('.' | '(' | '=') { _PyAST_MatchValue(attr, EXTRA) }

     attr[expr_ty]:
         | value=name_or_attr '.' attr=NAME {
             _PyAST_Attribute(value, attr->v.Name.id, Load, EXTRA) }

     name_or_attr[expr_ty]:
         | attr
         | NAME

     group_pattern[pattern_ty]:
         | '(' pattern=pattern ')' { pattern }

     sequence_pattern[pattern_ty]:
         | '[' patterns=maybe_sequence_pattern? ']' { _PyAST_MatchSequence(patterns, EXTRA) }
         | '(' patterns=open_sequence_pattern? ')' { _PyAST_MatchSequence(patterns, EXTRA) }

     open_sequence_pattern[asdl_seq*]:
         | pattern=maybe_star_pattern ',' patterns=maybe_sequence_pattern? {
             _PyPegen_seq_insert_in_front(p, pattern, patterns) }

     maybe_sequence_pattern[asdl_seq*]:
         | patterns=','.maybe_star_pattern+ ','? { patterns }

     maybe_star_pattern[pattern_ty]:
         | star_pattern
         | pattern

     star_pattern[pattern_ty] (memo):
         | '*' target=pattern_capture_target {
             _PyAST_MatchStar(target->v.Name.id, EXTRA) }
         | '*' wildcard_pattern {
             _PyAST_MatchStar(NULL, EXTRA) }

     mapping_pattern[pattern_ty]:
         | '{' '}' {
             _PyAST_MatchMapping(NULL, NULL, NULL, EXTRA) }
         | '{' rest=double_star_pattern ','? '}' {
             _PyAST_MatchMapping(NULL, NULL, rest->v.Name.id, EXTRA) }
         | '{' items=items_pattern ',' rest=double_star_pattern ','? '}' {
             _PyAST_MatchMapping(
                 CHECK(asdl_expr_seq*, _PyPegen_get_pattern_keys(p, items)),
                 CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, items)),
                 rest->v.Name.id,
                 EXTRA) }
         | '{' items=items_pattern ','? '}' {
             _PyAST_MatchMapping(
                 CHECK(asdl_expr_seq*, _PyPegen_get_pattern_keys(p, items)),
                 CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, items)),
                 NULL,
                 EXTRA) }

     items_pattern[asdl_seq*]:
         | ','.key_value_pattern+

     key_value_pattern[KeyPatternPair*]:
         | key=(literal_expr | attr) ':' pattern=pattern {
             _PyPegen_key_pattern_pair(p, key, pattern) }

     double_star_pattern[expr_ty]:
         | '**' target=pattern_capture_target { target }

     class_pattern[pattern_ty]:
         | cls=name_or_attr '(' ')' {
             _PyAST_MatchClass(cls, NULL, NULL, NULL, EXTRA) }
         | cls=name_or_attr '(' patterns=positional_patterns ','? ')' {
             _PyAST_MatchClass(cls, patterns, NULL, NULL, EXTRA) }
         | cls=name_or_attr '(' keywords=keyword_patterns ','? ')' {
             _PyAST_MatchClass(
                 cls, NULL,
                 CHECK(asdl_identifier_seq*, _PyPegen_map_names_to_ids(p,
                     CHECK(asdl_expr_seq*, _PyPegen_get_pattern_keys(p, keywords)))),
                 CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, keywords)),
                 EXTRA) }
         | cls=name_or_attr '(' patterns=positional_patterns ',' keywords=keyword_patterns ','? ')' {
             _PyAST_MatchClass(
                 cls,
                 patterns,
                 CHECK(asdl_identifier_seq*, _PyPegen_map_names_to_ids(p,
                     CHECK(asdl_expr_seq*, _PyPegen_get_pattern_keys(p, keywords)))),
                 CHECK(asdl_pattern_seq*, _PyPegen_get_patterns(p, keywords)),
                 EXTRA) }
         | invalid_class_pattern

     positional_patterns[asdl_pattern_seq*]:
         | args[asdl_pattern_seq*]=','.pattern+ { args }

     keyword_patterns[asdl_seq*]:
         | ','.keyword_pattern+

     keyword_pattern[KeyPatternPair*]:
         | arg=NAME '=' value=pattern { _PyPegen_key_pattern_pair(p, arg, value) }

     # Type statement
     # ---------------

     type_alias[stmt_ty]:
         | "type" n=NAME t=[type_params] '=' b=expression {
             CHECK_VERSION(stmt_ty, 12, "Type statement is",
             _PyAST_TypeAlias(CHECK(expr_ty, _PyPegen_set_expr_context(p, n, Store)), t, b, EXTRA)) }

     # Type parameter declaration
     # --------------------------

     type_params[asdl_type_param_seq*]:
         | invalid_type_params
         | '[' t=type_param_seq ']' {
             CHECK_VERSION(asdl_type_param_seq *, 12, "Type parameter lists are", t) }

     type_param_seq[asdl_type_param_seq*]: a[asdl_type_param_seq*]=','.type_param+ [','] { a }

     type_param[type_param_ty] (memo):
         | a=NAME b=[type_param_bound] c=[type_param_default] { _PyAST_TypeVar(a->v.Name.id, b, c, EXTRA) }
         | '*' a=NAME colon=':' e=expression {
                 RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
                     ? "cannot use constraints with TypeVarTuple"
                     : "cannot use bound with TypeVarTuple")
             }
         | '*' a=NAME b=[type_param_starred_default] { _PyAST_TypeVarTuple(a->v.Name.id, b, EXTRA) }
         | '**' a=NAME colon=':' e=expression {
                 RAISE_SYNTAX_ERROR_STARTING_FROM(colon, e->kind == Tuple_kind
                     ? "cannot use constraints with ParamSpec"
                     : "cannot use bound with ParamSpec")
             }
         | '**' a=NAME b=[type_param_default] { _PyAST_ParamSpec(a->v.Name.id, b, EXTRA) }

     type_param_bound[expr_ty]: ':' e=expression { e }
     type_param_default[expr_ty]: '=' e=expression {
         CHECK_VERSION(expr_ty, 13, "Type parameter defaults are", e) }
     type_param_starred_default[expr_ty]: '=' e=star_expression {
         CHECK_VERSION(expr_ty, 13, "Type parameter defaults are", e) }

     # EXPRESSIONS
     # -----------

     expressions[expr_ty]:
         | a=expression b=(',' c=expression { c })+ [','] {
             _PyAST_Tuple(CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, a, b)), Load, EXTRA) }
         | a=expression ',' { _PyAST_Tuple(CHECK(asdl_expr_seq*, _PyPegen_singleton_seq(p, a)), Load, EXTRA) }
         | expression

     expression[expr_ty] (memo):
         | invalid_expression
         | invalid_legacy_expression
         | a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, a, c, EXTRA) }
         | disjunction
         | lambdef

     yield_expr[expr_ty]:
         | 'yield' 'from' a=expression { _PyAST_YieldFrom(a, EXTRA) }
         | 'yield' a=[star_expressions] { _PyAST_Yield(a, EXTRA) }

     star_expressions[expr_ty]:
         | a=star_expression b=(',' c=star_expression { c })+ [','] {
             _PyAST_Tuple(CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, a, b)), Load, EXTRA) }
         | a=star_expression ',' { _PyAST_Tuple(CHECK(asdl_expr_seq*, _PyPegen_singleton_seq(p, a)), Load, EXTRA) }
         | star_expression

     star_expression[expr_ty] (memo):
         | '*' a=bitwise_or { _PyAST_Starred(a, Load, EXTRA) }
         | expression

     star_named_expressions[asdl_expr_seq*]: a[asdl_expr_seq*]=','.star_named_expression+ [','] { a }

     star_named_expression[expr_ty]:
         | '*' a=bitwise_or { _PyAST_Starred(a, Load, EXTRA) }
         | named_expression

     assignment_expression[expr_ty]:
         | a=NAME ':=' ~ b=expression {
             CHECK_VERSION(expr_ty, 8, "Assignment expressions are",
             _PyAST_NamedExpr(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), b, EXTRA)) }

     named_expression[expr_ty]:
         | assignment_expression
         | invalid_named_expression
         | expression !':='

     disjunction[expr_ty] (memo):
         | a=conjunction b=('or' c=conjunction { c })+ { _PyAST_BoolOp(
             Or,
             CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, a, b)),
             EXTRA) }
         | conjunction

     conjunction[expr_ty] (memo):
         | a=inversion b=('and' c=inversion { c })+ { _PyAST_BoolOp(
             And,
             CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, a, b)),
             EXTRA) }
         | inversion

     inversion[expr_ty] (memo):
         | 'not' a=inversion { _PyAST_UnaryOp(Not, a, EXTRA) }
         | comparison

     # Comparison operators
     # --------------------

     comparison[expr_ty]:
         | a=bitwise_or b=compare_op_bitwise_or_pair+ {
             _PyAST_Compare(
                 a,
                 CHECK(asdl_int_seq*, _PyPegen_get_cmpops(p, b)),
                 CHECK(asdl_expr_seq*, _PyPegen_get_exprs(p, b)),
                 EXTRA) }
         | bitwise_or

     compare_op_bitwise_or_pair[CmpopExprPair*]:
         | eq_bitwise_or
         | noteq_bitwise_or
         | lte_bitwise_or
         | lt_bitwise_or
         | gte_bitwise_or
         | gt_bitwise_or
         | notin_bitwise_or
         | in_bitwise_or
         | isnot_bitwise_or
         | is_bitwise_or

     eq_bitwise_or[CmpopExprPair*]: '==' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, Eq, a) }
     noteq_bitwise_or[CmpopExprPair*]:
         | (tok='!=' { _PyPegen_check_barry_as_flufl(p, tok) ? NULL : tok}) a=bitwise_or {_PyPegen_cmpop_expr_pair(p, NotEq, a) }
     lte_bitwise_or[CmpopExprPair*]: '<=' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, LtE, a) }
     lt_bitwise_or[CmpopExprPair*]: '<' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, Lt, a) }
     gte_bitwise_or[CmpopExprPair*]: '>=' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, GtE, a) }
     gt_bitwise_or[CmpopExprPair*]: '>' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, Gt, a) }
     notin_bitwise_or[CmpopExprPair*]: 'not' 'in' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, NotIn, a) }
     in_bitwise_or[CmpopExprPair*]: 'in' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, In, a) }
     isnot_bitwise_or[CmpopExprPair*]: 'is' 'not' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, IsNot, a) }
     is_bitwise_or[CmpopExprPair*]: 'is' a=bitwise_or { _PyPegen_cmpop_expr_pair(p, Is, a) }

     # Bitwise operators
     # -----------------

     bitwise_or[expr_ty]:
         | a=bitwise_or '|' b=bitwise_xor { _PyAST_BinOp(a, BitOr, b, EXTRA) }
         | bitwise_xor

     bitwise_xor[expr_ty]:
         | a=bitwise_xor '^' b=bitwise_and { _PyAST_BinOp(a, BitXor, b, EXTRA) }
         | bitwise_and

     bitwise_and[expr_ty]:
         | a=bitwise_and '&' b=shift_expr { _PyAST_BinOp(a, BitAnd, b, EXTRA) }
         | shift_expr

     shift_expr[expr_ty]:
         | a=shift_expr '<<' b=sum { _PyAST_BinOp(a, LShift, b, EXTRA) }
         | a=shift_expr '>>' b=sum { _PyAST_BinOp(a, RShift, b, EXTRA) }
         | invalid_arithmetic
         | sum

     # Arithmetic operators
     # --------------------

     sum[expr_ty]:
         | a=sum '+' b=term { _PyAST_BinOp(a, Add, b, EXTRA) }
         | a=sum '-' b=term { _PyAST_BinOp(a, Sub, b, EXTRA) }
         | term

     term[expr_ty]:
         | a=term '*' b=factor { _PyAST_BinOp(a, Mult, b, EXTRA) }
         | a=term '/' b=factor { _PyAST_BinOp(a, Div, b, EXTRA) }
         | a=term '//' b=factor { _PyAST_BinOp(a, FloorDiv, b, EXTRA) }
         | a=term '%' b=factor { _PyAST_BinOp(a, Mod, b, EXTRA) }
         | a=term '@' b=factor { CHECK_VERSION(expr_ty, 5, "The '@' operator is", _PyAST_BinOp(a, MatMult, b, EXTRA)) }
         | invalid_factor
         | factor

     factor[expr_ty] (memo):
         | '+' a=factor { _PyAST_UnaryOp(UAdd, a, EXTRA) }
         | '-' a=factor { _PyAST_UnaryOp(USub, a, EXTRA) }
         | '~' a=factor { _PyAST_UnaryOp(Invert, a, EXTRA) }
         | power

     power[expr_ty]:
         | a=await_primary '**' b=factor { _PyAST_BinOp(a, Pow, b, EXTRA) }
         | await_primary

     # Primary elements
     # ----------------

     # Primary elements are things like "obj.something.something", "obj[something]", "obj(something)", "obj" ...

     await_primary[expr_ty] (memo):
         | 'await' a=primary { CHECK_VERSION(expr_ty, 5, "Await expressions are", _PyAST_Await(a, EXTRA)) }
         | primary

     primary[expr_ty]:
         | a=primary '.' b=NAME { _PyAST_Attribute(a, b->v.Name.id, Load, EXTRA) }
         | a=primary b=genexp { _PyAST_Call(a, CHECK(asdl_expr_seq*, (asdl_expr_seq*)_PyPegen_singleton_seq(p, b)), NULL, EXTRA) }
         | a=primary '(' b=[arguments] ')' {
             _PyAST_Call(a,
                      (b) ? ((expr_ty) b)->v.Call.args : NULL,
                      (b) ? ((expr_ty) b)->v.Call.keywords : NULL,
                      EXTRA) }
         | a=primary '[' b=slices ']' { _PyAST_Subscript(a, b, Load, EXTRA) }
         | atom

     slices[expr_ty]:
         | a=slice !',' { a }
         | a[asdl_expr_seq*]=','.(slice | starred_expression)+ [','] { _PyAST_Tuple(a, Load, EXTRA) }

     slice[expr_ty]:
         | a=[expression] ':' b=[expression] c=[':' d=[expression] { d }] { _PyAST_Slice(a, b, c, EXTRA) }
         | a=named_expression { a }

     atom[expr_ty]:
         | NAME
         | 'True' { _PyAST_Constant(Py_True, NULL, EXTRA) }
         | 'False' { _PyAST_Constant(Py_False, NULL, EXTRA) }
         | 'None' { _PyAST_Constant(Py_None, NULL, EXTRA) }
         | &(STRING|FSTRING_START) strings
         | NUMBER
         | &'(' (tuple | group | genexp)
         | &'[' (list | listcomp)
         | &'{' (dict | set | dictcomp | setcomp)
         | '...' { _PyAST_Constant(Py_Ellipsis, NULL, EXTRA) }

     group[expr_ty]:
         | '(' a=(yield_expr | named_expression) ')' { a }
         | invalid_group

     # Lambda functions
     # ----------------

     lambdef[expr_ty]:
         | 'lambda' a=[lambda_params] ':' b=expression {
             _PyAST_Lambda((a) ? a : CHECK(arguments_ty, _PyPegen_empty_arguments(p)), b, EXTRA) }

     lambda_params[arguments_ty]:
         | invalid_lambda_parameters
         | lambda_parameters

     # lambda_parameters etc. duplicates parameters but without annotations
     # or type comments, and if there's no comma after a parameter, we expect
     # a colon, not a close parenthesis.  (For more, see parameters above.)
     #
     lambda_parameters[arguments_ty]:
         | a=lambda_slash_no_default b[asdl_arg_seq*]=lambda_param_no_default* c=lambda_param_with_default* d=[lambda_star_etc] {
             CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, a, NULL, b, c, d)) }
         | a=lambda_slash_with_default b=lambda_param_with_default* c=[lambda_star_etc] {
             CHECK_VERSION(arguments_ty, 8, "Positional-only parameters are", _PyPegen_make_arguments(p, NULL, a, NULL, b, c)) }
         | a[asdl_arg_seq*]=lambda_param_no_default+ b=lambda_param_with_default* c=[lambda_star_etc] {
             _PyPegen_make_arguments(p, NULL, NULL, a, b, c) }
         | a=lambda_param_with_default+ b=[lambda_star_etc] { _PyPegen_make_arguments(p, NULL, NULL, NULL, a, b)}
         | a=lambda_star_etc { _PyPegen_make_arguments(p, NULL, NULL, NULL, NULL, a) }

     lambda_slash_no_default[asdl_arg_seq*]:
         | a[asdl_arg_seq*]=lambda_param_no_default+ '/' ',' { a }
         | a[asdl_arg_seq*]=lambda_param_no_default+ '/' &':' { a }

     lambda_slash_with_default[SlashWithDefault*]:
         | a=lambda_param_no_default* b=lambda_param_with_default+ '/' ',' { _PyPegen_slash_with_default(p, (asdl_arg_seq *)a, b) }
         | a=lambda_param_no_default* b=lambda_param_with_default+ '/' &':' { _PyPegen_slash_with_default(p, (asdl_arg_seq *)a, b) }

     lambda_star_etc[StarEtc*]:
         | invalid_lambda_star_etc
         | '*' a=lambda_param_no_default b=lambda_param_maybe_default* c=[lambda_kwds] {
             _PyPegen_star_etc(p, a, b, c) }
         | '*' ',' b=lambda_param_maybe_default+ c=[lambda_kwds] {
             _PyPegen_star_etc(p, NULL, b, c) }
         | a=lambda_kwds { _PyPegen_star_etc(p, NULL, NULL, a) }

     lambda_kwds[arg_ty]:
         | invalid_lambda_kwds
         | '**' a=lambda_param_no_default { a }

     lambda_param_no_default[arg_ty]:
         | a=lambda_param ',' { a }
         | a=lambda_param &':' { a }
     lambda_param_with_default[NameDefaultPair*]:
         | a=lambda_param c=default ',' { _PyPegen_name_default_pair(p, a, c, NULL) }
         | a=lambda_param c=default &':' { _PyPegen_name_default_pair(p, a, c, NULL) }
     lambda_param_maybe_default[NameDefaultPair*]:
         | a=lambda_param c=default? ',' { _PyPegen_name_default_pair(p, a, c, NULL) }
         | a=lambda_param c=default? &':' { _PyPegen_name_default_pair(p, a, c, NULL) }
     lambda_param[arg_ty]: a=NAME { _PyAST_arg(a->v.Name.id, NULL, NULL, EXTRA) }

     # LITERALS
     # ========

     fstring_middle[expr_ty]:
         | fstring_replacement_field
         | t=FSTRING_MIDDLE { _PyPegen_constant_from_token(p, t) }
     fstring_replacement_field[expr_ty]:
         | '{' a=annotated_rhs debug_expr='='? conversion=[fstring_conversion] format=[fstring_full_format_spec] rbrace='}' {
             _PyPegen_formatted_value(p, a, debug_expr, conversion, format, rbrace, EXTRA) }
         | invalid_replacement_field
     fstring_conversion[ResultTokenWithMetadata*]:
         | conv_token="!" conv=NAME { _PyPegen_check_fstring_conversion(p, conv_token, conv) }
     fstring_full_format_spec[ResultTokenWithMetadata*]:
         | colon=':' spec=fstring_format_spec* { _PyPegen_setup_full_format_spec(p, colon, (asdl_expr_seq *) spec, EXTRA) }
     fstring_format_spec[expr_ty]:
         | t=FSTRING_MIDDLE { _PyPegen_decoded_constant_from_token(p, t) }
         | fstring_replacement_field
     fstring[expr_ty]:
         | a=FSTRING_START b=fstring_middle* c=FSTRING_END { _PyPegen_joined_str(p, a, (asdl_expr_seq*)b, c) }

     string[expr_ty]: s[Token*]=STRING { _PyPegen_constant_from_string(p, s) }
     strings[expr_ty] (memo): a[asdl_expr_seq*]=(fstring|string)+ { _PyPegen_concatenate_strings(p, a, EXTRA) }

     list[expr_ty]:
         | '[' a=[star_named_expressions] ']' { _PyAST_List(a, Load, EXTRA) }

     tuple[expr_ty]:
         | '(' a=[y=star_named_expression ',' z=[star_named_expressions] { _PyPegen_seq_insert_in_front(p, y, z) } ] ')' {
             _PyAST_Tuple(a, Load, EXTRA) }

     set[expr_ty]: '{' a=star_named_expressions '}' { _PyAST_Set(a, EXTRA) }

     # Dicts
     # -----

     dict[expr_ty]:
         | '{' a=[double_starred_kvpairs] '}' {
             _PyAST_Dict(
                 CHECK(asdl_expr_seq*, _PyPegen_get_keys(p, a)),
                 CHECK(asdl_expr_seq*, _PyPegen_get_values(p, a)),
                 EXTRA) }
         | '{' invalid_double_starred_kvpairs '}'

     double_starred_kvpairs[asdl_seq*]: a=','.double_starred_kvpair+ [','] { a }

     double_starred_kvpair[KeyValuePair*]:
         | '**' a=bitwise_or { _PyPegen_key_value_pair(p, NULL, a) }
         | kvpair

     kvpair[KeyValuePair*]: a=expression ':' b=expression { _PyPegen_key_value_pair(p, a, b) }

     # Comprehensions & Generators
     # ---------------------------

     for_if_clauses[asdl_comprehension_seq*]:
         | a[asdl_comprehension_seq*]=for_if_clause+ { a }

     for_if_clause[comprehension_ty]:
         | 'async' 'for' a=star_targets 'in' ~ b=disjunction c[asdl_expr_seq*]=('if' z=disjunction { z })* {
             CHECK_VERSION(comprehension_ty, 6, "Async comprehensions are", _PyAST_comprehension(a, b, c, 1, p->arena)) }
         | 'for' a=star_targets 'in' ~ b=disjunction c[asdl_expr_seq*]=('if' z=disjunction { z })* {
             _PyAST_comprehension(a, b, c, 0, p->arena) }
         | 'async'? 'for' (bitwise_or (',' bitwise_or)* [',']) !'in' {
             RAISE_SYNTAX_ERROR("'in' expected after for-loop variables") }
         | invalid_for_target

     listcomp[expr_ty]:
         | '[' a=named_expression b=for_if_clauses ']' { _PyAST_ListComp(a, b, EXTRA) }
         | invalid_comprehension

     setcomp[expr_ty]:
         | '{' a=named_expression b=for_if_clauses '}' { _PyAST_SetComp(a, b, EXTRA) }
         | invalid_comprehension

     genexp[expr_ty]:
         | '(' a=( assignment_expression | expression !':=') b=for_if_clauses ')' { _PyAST_GeneratorExp(a, b, EXTRA) }
         | invalid_comprehension

     dictcomp[expr_ty]:
         | '{' a=kvpair b=for_if_clauses '}' { _PyAST_DictComp(a->key, a->value, b, EXTRA) }
         | invalid_dict_comprehension

     # FUNCTION CALL ARGUMENTS
     # =======================

     arguments[expr_ty] (memo):
         | a=args [','] &')' { a }
         | invalid_arguments

     args[expr_ty]:
         | a[asdl_expr_seq*]=','.(starred_expression | ( assignment_expression | expression !':=') !'=')+ b=[',' k=kwargs {k}] {
             _PyPegen_collect_call_seqs(p, a, b, EXTRA) }
         | a=kwargs { _PyAST_Call(_PyPegen_dummy_name(p),
                               CHECK_NULL_ALLOWED(asdl_expr_seq*, _PyPegen_seq_extract_starred_exprs(p, a)),
                               CHECK_NULL_ALLOWED(asdl_keyword_seq*, _PyPegen_seq_delete_starred_exprs(p, a)),
                               EXTRA) }

     kwargs[asdl_seq*]:
         | a=','.kwarg_or_starred+ ',' b=','.kwarg_or_double_starred+ { _PyPegen_join_sequences(p, a, b) }
         | ','.kwarg_or_starred+
         | ','.kwarg_or_double_starred+

     starred_expression[expr_ty]:
         | invalid_starred_expression
         | '*' a=expression { _PyAST_Starred(a, Load, EXTRA) }
         | '*' { RAISE_SYNTAX_ERROR("Invalid star expression") }

     kwarg_or_starred[KeywordOrStarred*]:
         | invalid_kwarg
         | a=NAME '=' b=expression {
             _PyPegen_keyword_or_starred(p, CHECK(keyword_ty, _PyAST_keyword(a->v.Name.id, b, EXTRA)), 1) }
         | a=starred_expression { _PyPegen_keyword_or_starred(p, a, 0) }

     kwarg_or_double_starred[KeywordOrStarred*]:
         | invalid_kwarg
         | a=NAME '=' b=expression {
             _PyPegen_keyword_or_starred(p, CHECK(keyword_ty, _PyAST_keyword(a->v.Name.id, b, EXTRA)), 1) }
         | '**' a=expression { _PyPegen_keyword_or_starred(p, CHECK(keyword_ty, _PyAST_keyword(NULL, a, EXTRA)), 1) }

     # ASSIGNMENT TARGETS
     # ==================

     # Generic targets
     # ---------------

     # NOTE: star_targets may contain *bitwise_or, targets may not.
     star_targets[expr_ty]:
         | a=star_target !',' { a }
         | a=star_target b=(',' c=star_target { c })* [','] {
             _PyAST_Tuple(CHECK(asdl_expr_seq*, _PyPegen_seq_insert_in_front(p, a, b)), Store, EXTRA) }

     star_targets_list_seq[asdl_expr_seq*]: a[asdl_expr_seq*]=','.star_target+ [','] { a }

     star_targets_tuple_seq[asdl_expr_seq*]:
         | a=star_target b=(',' c=star_target { c })+ [','] { (asdl_expr_seq*) _PyPegen_seq_insert_in_front(p, a, b) }
         | a=star_target ',' { (asdl_expr_seq*) _PyPegen_singleton_seq(p, a) }

     star_target[expr_ty] (memo):
         | '*' a=(!'*' star_target) {
             _PyAST_Starred(CHECK(expr_ty, _PyPegen_set_expr_context(p, a, Store)), Store, EXTRA) }
         | target_with_star_atom

     target_with_star_atom[expr_ty] (memo):
         | a=t_primary '.' b=NAME !t_lookahead { _PyAST_Attribute(a, b->v.Name.id, Store, EXTRA) }
         | a=t_primary '[' b=slices ']' !t_lookahead { _PyAST_Subscript(a, b, Store, EXTRA) }
         | star_atom

     star_atom[expr_ty]:
         | a=NAME { _PyPegen_set_expr_context(p, a, Store) }
         | '(' a=target_with_star_atom ')' { _PyPegen_set_expr_context(p, a, Store) }
         | '(' a=[star_targets_tuple_seq] ')' { _PyAST_Tuple(a, Store, EXTRA) }
         | '[' a=[star_targets_list_seq] ']' { _PyAST_List(a, Store, EXTRA) }

     single_target[expr_ty]:
         | single_subscript_attribute_target
         | a=NAME { _PyPegen_set_expr_context(p, a, Store) }
         | '(' a=single_target ')' { a }

     single_subscript_attribute_target[expr_ty]:
         | a=t_primary '.' b=NAME !t_lookahead { _PyAST_Attribute(a, b->v.Name.id, Store, EXTRA) }
         | a=t_primary '[' b=slices ']' !t_lookahead { _PyAST_Subscript(a, b, Store, EXTRA) }

     t_primary[expr_ty]:
         | a=t_primary '.' b=NAME &t_lookahead { _PyAST_Attribute(a, b->v.Name.id, Load, EXTRA) }
         | a=t_primary '[' b=slices ']' &t_lookahead { _PyAST_Subscript(a, b, Load, EXTRA) }
         | a=t_primary b=genexp &t_lookahead {
             _PyAST_Call(a, CHECK(asdl_expr_seq*, (asdl_expr_seq*)_PyPegen_singleton_seq(p, b)), NULL, EXTRA) }
         | a=t_primary '(' b=[arguments] ')' &t_lookahead {
             _PyAST_Call(a,
                      (b) ? ((expr_ty) b)->v.Call.args : NULL,
                      (b) ? ((expr_ty) b)->v.Call.keywords : NULL,
                      EXTRA) }
         | a=atom &t_lookahead { a }

     t_lookahead: '(' | '[' | '.'

     # Targets for del statements
     # --------------------------

     del_targets[asdl_expr_seq*]: a[asdl_expr_seq*]=','.del_target+ [','] { a }

     del_target[expr_ty] (memo):
         | a=t_primary '.' b=NAME !t_lookahead { _PyAST_Attribute(a, b->v.Name.id, Del, EXTRA) }
         | a=t_primary '[' b=slices ']' !t_lookahead { _PyAST_Subscript(a, b, Del, EXTRA) }
         | del_t_atom

     del_t_atom[expr_ty]:
         | a=NAME { _PyPegen_set_expr_context(p, a, Del) }
         | '(' a=del_target ')' { _PyPegen_set_expr_context(p, a, Del) }
         | '(' a=[del_targets] ')' { _PyAST_Tuple(a, Del, EXTRA) }
         | '[' a=[del_targets] ']' { _PyAST_List(a, Del, EXTRA) }

     # TYPING ELEMENTS
     # ---------------

     # type_expressions allow */** but ignore them
     type_expressions[asdl_expr_seq*]:
         | a=','.expression+ ',' '*' b=expression ',' '**' c=expression {
             (asdl_expr_seq*)_PyPegen_seq_append_to_end(
                 p,
                 CHECK(asdl_seq*, _PyPegen_seq_append_to_end(p, a, b)),
                 c) }
         | a=','.expression+ ',' '*' b=expression { (asdl_expr_seq*)_PyPegen_seq_append_to_end(p, a, b) }
         | a=','.expression+ ',' '**' b=expression { (asdl_expr_seq*)_PyPegen_seq_append_to_end(p, a, b) }
         | '*' a=expression ',' '**' b=expression {
             (asdl_expr_seq*)_PyPegen_seq_append_to_end(
                 p,
                 CHECK(asdl_seq*, _PyPegen_singleton_seq(p, a)),
                 b) }
         | '*' a=expression { (asdl_expr_seq*)_PyPegen_singleton_seq(p, a) }
         | '**' a=expression { (asdl_expr_seq*)_PyPegen_singleton_seq(p, a) }
         | a[asdl_expr_seq*]=','.expression+ {a}

     func_type_comment[Token*]:
         | NEWLINE t=TYPE_COMMENT &(NEWLINE INDENT) { t }  # Must be followed by indented block
         | invalid_double_type_comments
         | TYPE_COMMENT

     # ========================= END OF THE GRAMMAR ===========================



     # ========================= START OF INVALID RULES =======================

     # From here on, there are rules for invalid syntax with specialised error messages
     invalid_arguments:
         | ((','.(starred_expression | ( assignment_expression | expression !':=') !'=')+ ',' kwargs) | kwargs) a=',' ','.(starred_expression !'=')+ {
             RAISE_SYNTAX_ERROR_STARTING_FROM(a, "iterable argument unpacking follows keyword argument unpacking") }
         | a=expression b=for_if_clauses ',' [args | expression for_if_clauses] {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, _PyPegen_get_last_comprehension_item(PyPegen_last_item(b, comprehension_ty)), "Generator expression must be parenthesized") }
         | a=NAME b='=' expression for_if_clauses {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?")}
         | (args ',')? a=NAME b='=' &(',' | ')') {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected argument value expression")}
         | a=args b=for_if_clauses { _PyPegen_nonparen_genexp_in_call(p, a, b) }
         | args ',' a=expression b=for_if_clauses {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, _PyPegen_get_last_comprehension_item(PyPegen_last_item(b, comprehension_ty)), "Generator expression must be parenthesized") }
         | a=args ',' args { _PyPegen_arguments_parsing_error(p, a) }
     invalid_kwarg:
         | a[Token*]=('True'|'False'|'None') b='=' {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to %s", PyBytes_AS_STRING(a->bytes)) }
         | a=NAME b='=' expression for_if_clauses {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?")}
         | !(NAME '=') a=expression b='=' {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(
                 a, b, "expression cannot contain assignment, perhaps you meant \"==\"?") }
         | a='**' expression '=' b=expression {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to keyword argument unpacking") }

     # IMPORTANT: Note that the "_without_invalid" suffix causes the rule to not call invalid rules under it
     expression_without_invalid[expr_ty]:
         | a=disjunction 'if' b=disjunction 'else' c=expression { _PyAST_IfExp(b, a, c, EXTRA) }
         | disjunction
         | lambdef
     invalid_legacy_expression:
         | a=NAME !'(' b=star_expressions {
             _PyPegen_check_legacy_stmt(p, a) ? RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b,
                 "Missing parentheses in call to '%U'. Did you mean %U(...)?", a->v.Name.id, a->v.Name.id) : NULL}

     invalid_expression:
         # !(NAME STRING) is not matched so we don't show this error with some invalid string prefixes like: kf"dsfsdf"
         # Soft keywords need to also be ignored because they can be parsed as NAME NAME
        | !(NAME STRING | SOFT_KEYWORD) a=disjunction b=expression_without_invalid {
             _PyPegen_check_legacy_stmt(p, a) ? NULL : p->tokens[p->mark-1]->level == 0 ? NULL :
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Perhaps you forgot a comma?") }
        | a=disjunction 'if' b=disjunction !('else'|':') { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "expected 'else' after 'if' expression") }
        | a='lambda' [lambda_params] b=':' &FSTRING_MIDDLE  {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "f-string: lambda expressions are not allowed without parentheses") }

     invalid_named_expression(memo):
         | a=expression ':=' expression {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
                 a, "cannot use assignment expressions with %s", _PyPegen_get_expr_name(a)) }
         | a=NAME '=' b=bitwise_or !('='|':=') {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '==' or ':=' instead of '='?") }
         | !(list|tuple|genexp|'True'|'None'|'False') a=bitwise_or b='=' bitwise_or !('='|':=') {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot assign to %s here. Maybe you meant '==' instead of '='?",
                                               _PyPegen_get_expr_name(a)) }

     invalid_assignment:
         | a=invalid_ann_assign_target ':' expression {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
                 a,
                 "only single target (not %s) can be annotated",
                 _PyPegen_get_expr_name(a)
             )}
         | a=star_named_expression ',' star_named_expressions* ':' expression {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "only single target (not tuple) can be annotated") }
         | a=expression ':' expression {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "illegal target for annotation") }
         | (star_targets '=')* a=star_expressions '=' {
             RAISE_SYNTAX_ERROR_INVALID_TARGET(STAR_TARGETS, a) }
         | (star_targets '=')* a=yield_expr '=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "assignment to yield expression not possible") }
         | a=star_expressions augassign annotated_rhs {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(
                 a,
                 "'%s' is an illegal expression for augmented assignment",
                 _PyPegen_get_expr_name(a)
             )}
     invalid_ann_assign_target[expr_ty]:
         | list
         | tuple
         | '(' a=invalid_ann_assign_target ')' { a }
     invalid_del_stmt:
         | 'del' a=star_expressions {
             RAISE_SYNTAX_ERROR_INVALID_TARGET(DEL_TARGETS, a) }
     invalid_block:
         | NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block") }
     invalid_comprehension:
         | ('[' | '(' | '{') a=starred_expression for_if_clauses {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "iterable unpacking cannot be used in comprehension") }
         | ('[' | '{') a=star_named_expression ',' b=star_named_expressions for_if_clauses {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, PyPegen_last_item(b, expr_ty),
             "did you forget parentheses around the comprehension target?") }
         | ('[' | '{') a=star_named_expression b=',' for_if_clauses {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "did you forget parentheses around the comprehension target?") }
     invalid_dict_comprehension:
         | '{' a='**' bitwise_or for_if_clauses '}' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "dict unpacking cannot be used in dict comprehension") }
     invalid_parameters:
         | a="/" ',' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "at least one argument must precede /") }
         | (slash_no_default | slash_with_default) param_maybe_default* a='/' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "/ may appear only once") }
         | slash_no_default? param_no_default* invalid_parameters_helper a=param_no_default {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "parameter without a default follows parameter with a default") }
         | param_no_default* a='(' param_no_default+ ','? b=')' {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "Function parameters cannot be parenthesized") }
         | (slash_no_default | slash_with_default)? param_maybe_default* '*' (',' | param_no_default) param_maybe_default* a='/' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "/ must be ahead of *") }
         | param_maybe_default+ '/' a='*' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expected comma between / and *") }
     invalid_default:
         | a='=' &(')'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expected default value expression") }
     invalid_star_etc:
         | a='*' (')' | ',' (')' | '**')) { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "named arguments must follow bare *") }
         | '*' ',' TYPE_COMMENT { RAISE_SYNTAX_ERROR("bare * has associated type comment") }
         | '*' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional argument cannot have default value") }
         | '*' (param_no_default | ',') param_maybe_default* a='*' (param_no_default | ',') {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* argument may appear only once") }
     invalid_kwds:
         | '**' param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-keyword argument cannot have default value") }
         | '**' param ',' a=param { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "arguments cannot follow var-keyword argument") }
         | '**' param ',' a[Token*]=('*'|'**'|'/') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "arguments cannot follow var-keyword argument") }
     invalid_parameters_helper: # This is only there to avoid type errors
         | a=slash_with_default { _PyPegen_singleton_seq(p, a) }
         | param_with_default+
     invalid_lambda_parameters:
         | a="/" ',' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "at least one argument must precede /") }
         | (lambda_slash_no_default | lambda_slash_with_default) lambda_param_maybe_default* a='/' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "/ may appear only once") }
         | lambda_slash_no_default? lambda_param_no_default* invalid_lambda_parameters_helper a=lambda_param_no_default {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "parameter without a default follows parameter with a default") }
         | lambda_param_no_default* a='(' ','.lambda_param+ ','? b=')' {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "Lambda expression parameters cannot be parenthesized") }
         | (lambda_slash_no_default | lambda_slash_with_default)? lambda_param_maybe_default* '*' (',' | lambda_param_no_default) lambda_param_maybe_default* a='/' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "/ must be ahead of *") }
         | lambda_param_maybe_default+ '/' a='*' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expected comma between / and *") }
     invalid_lambda_parameters_helper:
         | a=lambda_slash_with_default { _PyPegen_singleton_seq(p, a) }
         | lambda_param_with_default+
     invalid_lambda_star_etc:
         | '*' (':' | ',' (':' | '**')) { RAISE_SYNTAX_ERROR("named arguments must follow bare *") }
         | '*' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-positional argument cannot have default value") }
         | '*' (lambda_param_no_default | ',') lambda_param_maybe_default* a='*' (lambda_param_no_default | ',') {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "* argument may appear only once") }
     invalid_lambda_kwds:
         | '**' lambda_param a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "var-keyword argument cannot have default value") }
         | '**' lambda_param ',' a=lambda_param { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "arguments cannot follow var-keyword argument") }
         | '**' lambda_param ',' a[Token*]=('*'|'**'|'/') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "arguments cannot follow var-keyword argument") }
     invalid_double_type_comments:
         | TYPE_COMMENT NEWLINE TYPE_COMMENT NEWLINE INDENT {
             RAISE_SYNTAX_ERROR("Cannot have two type comments on def") }
     invalid_with_item:
         | expression 'as' a=expression &(',' | ')' | ':') {
             RAISE_SYNTAX_ERROR_INVALID_TARGET(STAR_TARGETS, a) }

     invalid_for_target:
         | 'async'? 'for' a=star_expressions {
             RAISE_SYNTAX_ERROR_INVALID_TARGET(FOR_TARGETS, a) }

     invalid_group:
         | '(' a=starred_expression ')' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use starred expression here") }
         | '(' a='**' expression ')' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use double starred expression here") }
     invalid_import:
         | a='import' ','.dotted_name+ 'from' dotted_name {
             RAISE_SYNTAX_ERROR_STARTING_FROM(a, "Did you mean to use 'from ... import ...' instead?") }
         | 'import' token=NEWLINE {
             RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }

     invalid_import_from_targets:
         | import_from_as_names ',' NEWLINE {
             RAISE_SYNTAX_ERROR("trailing comma not allowed without surrounding parentheses") }
         | token=NEWLINE {
             RAISE_SYNTAX_ERROR_STARTING_FROM(token, "Expected one or more names after 'import'") }

     invalid_with_stmt:
         | ['async'] 'with' ','.(expression ['as' star_target])+ NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | ['async'] 'with' '(' ','.(expressions ['as' star_target])+ ','? ')' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
     invalid_with_stmt_indent:
         | ['async'] a='with' ','.(expression ['as' star_target])+ ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'with' statement on line %d", a->lineno) }
         | ['async'] a='with' '(' ','.(expressions ['as' star_target])+ ','? ')' ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'with' statement on line %d", a->lineno) }

     invalid_try_stmt:
         | a='try' ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'try' statement on line %d", a->lineno) }
         | 'try' ':' block !('except' | 'finally') { RAISE_SYNTAX_ERROR("expected 'except' or 'finally' block") }
         | 'try' ':' block* except_block+ a='except' b='*' expression ['as' NAME] ':' {
             RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot have both 'except' and 'except*' on the same 'try'") }
         | 'try' ':' block* except_star_block+ a='except' [expression ['as' NAME]] ':' {
             RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot have both 'except' and 'except*' on the same 'try'") }
     invalid_except_stmt:
         | 'except' '*'? a=expression ',' expressions ['as' NAME ] ':' {
             RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types must be parenthesized") }
         | a='except' '*'? expression ['as' NAME ] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | a='except' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | a='except' '*' (NEWLINE | ':') { RAISE_SYNTAX_ERROR("expected one or more exception types") }
     invalid_finally_stmt:
         | a='finally' ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'finally' statement on line %d", a->lineno) }
     invalid_except_stmt_indent:
         | a='except' expression ['as' NAME ] ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'except' statement on line %d", a->lineno) }
         | a='except' ':' NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block after 'except' statement on line %d", a->lineno) }
     invalid_except_star_stmt_indent:
         | a='except' '*' expression ['as' NAME ] ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'except*' statement on line %d", a->lineno) }
     invalid_match_stmt:
         | "match" subject_expr NEWLINE { CHECK_VERSION(void*, 10, "Pattern matching is", RAISE_SYNTAX_ERROR("expected ':'") ) }
         | a="match" subject=subject_expr ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'match' statement on line %d", a->lineno) }
     invalid_case_block:
         | "case" patterns guard? NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | a="case" patterns guard? ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'case' statement on line %d", a->lineno) }
     invalid_as_pattern:
         | or_pattern 'as' a="_" { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "cannot use '_' as a target") }
         | or_pattern 'as' !NAME a=expression { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "invalid pattern target") }
     invalid_class_pattern:
         | name_or_attr '(' a=invalid_class_argument_pattern  { RAISE_SYNTAX_ERROR_KNOWN_RANGE(
             PyPegen_first_item(a, pattern_ty),
             PyPegen_last_item(a, pattern_ty),
             "positional patterns follow keyword patterns") }
     invalid_class_argument_pattern[asdl_pattern_seq*]:
         | [positional_patterns ','] keyword_patterns ',' a=positional_patterns { a }
     invalid_if_stmt:
         | 'if' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | a='if' a=named_expression ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'if' statement on line %d", a->lineno) }
     invalid_elif_stmt:
         | 'elif' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | a='elif' named_expression ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'elif' statement on line %d", a->lineno) }
     invalid_else_stmt:
         | a='else' ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'else' statement on line %d", a->lineno) }
     invalid_while_stmt:
         | 'while' named_expression NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | a='while' named_expression ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'while' statement on line %d", a->lineno) }
     invalid_for_stmt:
         | ['async'] 'for' star_targets 'in' star_expressions NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | ['async'] a='for' star_targets 'in' star_expressions ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after 'for' statement on line %d", a->lineno) }
     invalid_def_raw:
         | ['async'] a='def' NAME [type_params] '(' [params] ')' ['->' expression] ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after function definition on line %d", a->lineno) }
         | ['async'] 'def' NAME [type_params] &&'(' [params] ')' ['->' expression] &&':' [func_type_comment] block
     invalid_class_def_raw:
         | 'class' NAME [type_params] ['(' [arguments] ')'] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
         | a='class' NAME [type_params] ['(' [arguments] ')'] ':' NEWLINE !INDENT {
             RAISE_INDENTATION_ERROR("expected an indented block after class definition on line %d", a->lineno) }

     invalid_double_starred_kvpairs:
         | ','.double_starred_kvpair+ ',' invalid_kvpair
         | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "cannot use a starred expression in a dictionary value") }
         | expression a=':' &('}'|',') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
     invalid_kvpair:
         | a=expression !(':') {
             RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, a->lineno, a->end_col_offset - 1, a->end_lineno, -1, "':' expected after dictionary key") }
         | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "cannot use a starred expression in a dictionary value") }
         | expression a=':' &('}'|',') {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
     invalid_starred_expression:
         | a='*' expression '=' b=expression { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "cannot assign to iterable argument unpacking") }

     invalid_replacement_field:
         | '{' a='=' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: valid expression required before '='") }
         | '{' a='!' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: valid expression required before '!'") }
         | '{' a=':' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: valid expression required before ':'") }
         | '{' a='}' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: valid expression required before '}'") }
         | '{' !annotated_rhs { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: expecting a valid expression after '{'")}
         | '{' annotated_rhs !('=' | '!' | ':' | '}') {
             PyErr_Occurred() ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: expecting '=', or '!', or ':', or '}'") }
         | '{' annotated_rhs '=' !('!' | ':' | '}') {
             PyErr_Occurred() ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: expecting '!', or ':', or '}'") }
         | '{' annotated_rhs '='? invalid_conversion_character
         | '{' annotated_rhs '='? ['!' NAME] !(':' | '}') {
             PyErr_Occurred() ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: expecting ':' or '}'") }
         | '{' annotated_rhs '='? ['!' NAME] ':' fstring_format_spec* !'}' {
             PyErr_Occurred() ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: expecting '}', or format specs") }
         | '{' annotated_rhs '='? ['!' NAME] !'}' {
             PyErr_Occurred() ? NULL : RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: expecting '}'") }

     invalid_conversion_character:
         | '!' &(':' | '}') { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: missing conversion character") }
         | '!' !NAME { RAISE_SYNTAX_ERROR_ON_NEXT_TOKEN("f-string: invalid conversion character") }

     invalid_arithmetic:
         | sum ('+'|'-'|'*'|'/'|'%'|'//'|'@') a='not' b=inversion { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "'not' after an operator must be parenthesized") }
     invalid_factor:
         | ('+' | '-' | '~') a='not' b=factor { RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "'not' after an operator must be parenthesized") }

     invalid_type_params:
         | '[' token=']' {
             RAISE_SYNTAX_ERROR_STARTING_FROM(
                 token,
                 "Type parameter list cannot be empty")}

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Grammar/python.gram

   (2) https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form

   (3) https://en.wikipedia.org/wiki/Parsing_expression_grammar

   (4) https://peps.python.org/pep-0617/


File: python.info,  Node: Python 標準ライブラリ,  Next: Python インタプリタの拡張と埋め込み,  Prev: Python 言語リファレンス,  Up: Top

5 Python 標準ライブラリ
***********************

*note Python 言語リファレンス: 12b. ではプログラミング言語 Python の厳密
な構文とセマンティクスについて説明されていますが、このライブラリリファレ
ンスマニュアルでは Python とともに配付されている標準ライブラリについて説
明します。また Python 配布物に収められていることの多いオプションのコンポ
ーネントについても説明します。

Python の標準ライブラリはとても拡張性があり、下の長い目次のリストで判る
ように幅広いものを用意しています。このライブラリには、例えばファイル I/O
のように、Python プログラマが直接アクセスできないシステム機能へのアクセ
ス機能を提供する (Cで書かれた) 組み込みモジュールや、日々のプログラミン
グで生じる多くの問題に標準的な解決策を提供するPython で書かれたモジュー
ルが入っています。これら数多くのモジュールには、プラットフォーム固有の事
情をプラットフォーム独立な API へと昇華させることにより、Pythonプログラ
ムに移植性を持たせ、それを高めるという明確な意図があります。

Windows 向けの Python インストーラはたいてい標準ライブラリのすべてを含み
、しばしばそれ以外の追加のコンポーネントも含んでいます。Unix 系のオペレ
ーティングシステムの場合は Python は一揃いのパッケージとして提供されるの
が普通で、オプションのコンポーネントを手に入れるにはオペレーティングシス
テムのパッケージツールを使うことになるでしょう。

標準ライブラリに加えて、数10万のコンポーネントが (独立したプログラムやモ
ジュールからパッケージ、アプリケーション開発フレームワークまで) 活動して
いるコレクションとしてPython Package Index(1) から入手可能です。

* Menu:

* はじめに: はじめに<6>.
* 組み込み関数::
* 組み込み定数::
* 組み込み型::
* 組み込み例外::
* テキスト処理サービス::
* バイナリデータ処理::
* データ型::
* 数値と数学モジュール::
* 関数型プログラミング用モジュール::
* ファイルとディレクトリへのアクセス::
* データの永続化::
* データ圧縮とアーカイブ::
* ファイルフォーマット::
* 暗号関連のサービス::
* 汎用オペレーティングシステムサービス::
* 並行実行::
* ネットワーク通信とプロセス間通信::
* インターネット上のデータの操作::
* 構造化マークアップツール::
* インターネットプロトコルとサポート::
* マルチメディアサービス::
* 国際化::
* プログラムのフレームワーク::
* Tk を用いたグラフィカルユーザーインターフェース::
* 開発ツール::
* デバッグとプロファイル::
* ソフトウェア・パッケージと配布::
* Python ランタイムサービス::
* カスタム Python インタプリタ::
* モジュールのインポート::
* Python言語サービス::
* MS Windows 固有のサービス::
* Unix 固有のサービス::
* モジュールのコマンドラインインターフェース (CLI): モジュールのコマンドラインインターフェース CLI.
* 取って代わられたモジュール群::
* セキュリティで考慮すべき点: セキュリティで考慮すべき点<6>.

   ---------- Footnotes ----------

   (1) https://pypi.org


File: python.info,  Node: はじめに<6>,  Next: 組み込み関数,  Up: Python 標準ライブラリ

5.1 はじめに
============

この "Python ライブラリ" には様々な内容が収録されています。

このライブラリには、数値型やリスト型のような、通常は言語の "核" をなす部
分とみなされるデータ型が含まれています。Python 言語のコア部分では、これ
らの型に対してリテラル表現形式を与え、意味づけ上のいくつかの制約を与えて
いますが、完全にその意味づけを定義しているわけではありません。(一方で、
言語のコア部分では演算子のスペルや優先順位のような構文法的な属性を定義し
ています。)

このライブラリにはまた、組み込み関数と例外が納められています -- 組み込み
関数および例外は、全ての Python で書かれたコード上で、 *note import:
5ac. 文を使わずに使うことができるオブジェクトです。これらの組み込み要素
のうちいくつかは言語のコア部分で定義されていますが、大半は言語コアの意味
づけ上不可欠なものではないのでここでしか記述されていません。

とはいえ、このライブラリの大部分に収録されているのはモジュールのコレクシ
ョンです。このコレクションを細分化する方法はいろいろあります。あるモジュ
ールは C 言語で書かれ、Python インタプリタに組み込まれています; 一方別の
モジュールは Python で書かれ、ソースコードの形式で取り込まれます。またあ
るモジュールは、例えば実行スタックの追跡結果を出力するといった、Python に
非常に特化したインターフェースを提供し、一方他のモジュールでは、特定のハ
ードウェアにアクセスするといった、特定のオペレーティングシステムに特化し
たインターフェースを提供し、さらに別のモジュールでは WWW (ワールドワイド
ウェブ) のような特定のアプリケーション分野に特化したインターフェースを提
供しています。モジュールによっては全てのバージョン、全ての移植版の
Python で利用することができたり、背後にあるシステムがサポートしている場
合にのみ使えたり、Python をコンパイルしてインストールする際に特定の設定
オプションを選んだときにのみ利用できたりします。

このマニュアルは "内部から外部へ" と構成されています。つまり、最初に組み
込みの関数を記述し、組み込みのデータ型、例外、そして最後に各モジュールと
続きます。モジュールは関係のあるものでグループ化して一つの章にしています
。

つまり、このマニュアルを最初から読み始め、読み飽きたところで次の章に進め
ば、 Python ライブラリで利用できるモジュールやサポートしているアプリケー
ション領域の概要をそこそこ理解できるということです。もちろん、このマニュ
アルを小説のように読む必要は 'ありません' -- (マニュアルの先頭部分にある
) 目次にざっと目を通したり、 (最後尾にある) 索引でお目当ての関数やモジュ
ール、用語を探すことだってできます。もしランダムな項目について勉強してみ
たいのなら、ランダムにページを選び (*note random: a6. 参照)、そこから 1,
2 節読むこともできます。このマニュアルの各節をどんな順番で読むかに関わら
ず、 *note 組み込み関数: 122e. の章から始めるとよいでしょう。マニュアル
の他の部分は、この節の内容について知っているものとして書かれているからで
す。

それでは、ショーの始まりです！

* Menu:

* 利用可能性について::


File: python.info,  Node: 利用可能性について,  Up: はじめに<6>

5.1.1 利用可能性について
------------------------

   * 「利用できる環境 : Unix 」の意味はこの関数が Unix システムにあるこ
     とが多いということです。このことは特定の OS における存在を主張する
     ものではありません。

   * If not separately noted, all functions that claim "Availability:
     Unix" are supported on macOS, iOS and Android, all of which build
     on a Unix core.

   * 利用可能性の注釈に最小カーネルバージョンと最小 libc バージョンの両
     方が含まれている場合は、両方の条件を満たさなければなりません。例え
     ば、 'Availability: Linux >= 3.17 with glibc >= 2.27' という注釈付
     きの機能には、 Linux 3.17 以上と、 glibc 2.27 以上の両方が必要です
     。

* Menu:

* WebAssembly プラットフォーム::
* Mobile platforms::


File: python.info,  Node: WebAssembly プラットフォーム,  Next: Mobile platforms,  Up: 利用可能性について

5.1.1.1 WebAssembly プラットフォーム
....................................

WebAssembly(1) プラットフォームである ‘wasm32-emscripten’
(Emscripten(2)) と ‘wasm32-wasi’ (WASI(3)) は、 POSIX API のサブセットを
提供します。 WebAssembly ランタイムとブラウザーはサンドボックス化されて
おり、ホストや外部リソースへのアクセスが制限されています。プロセス、スレ
ッド、ネットワーク、シグナル、または他の形のプロセス間通信 (IPC) を使用
する標準ライブラリモジュールは、利用不可か、他の Unix ライクなシステムの
ようには動作しません。ファイル I/O 、ファイルシステム、 Unix の権限関係
の機能も制限されています。 Emscripten はブロッキング I/O を許可しません
。 *note sleep(): 669. のような他のブロッキング操作は、ブラウザーのイベ
ントループをブロックします。

WebAssembly プラットフォーム上での Python の 性質と振る舞いは、
Emscripten(4)-SDK や WASI(5)-SDK のバージョン、 WASM ランタイム (ブラウ
ザ、 NodeJS 、 wasmtime(6)) 、Python のビルド時フラグによって決まります
。 WebAssembly や Emscripten 、 WASI は標準を発展させており、ネットワー
クなどの機能は将来的にサポートされるかもしれません

ブラウザ上の Python では、ユーザーは Pyodide(7) や PyScript(8) を検討す
べきでしょう。 PyScript は、 Pyodide をもとにして構築されており、
Pyodide 自体は CPython や Emscripten 上に構築されています。 Pyodide は、
ブラウザの JavaScript と DOM API だけでなく、 JavaScript の
‘XMLHttpRequest’ や ‘Fetch’ API による制限されたネットワーク機能へのアク
セスを提供します。

   * プロセス関連の API は利用不可能か、常にエラーにより失敗します。これ
     には、新しいプロセスを作成 (*note fork(): 17c. や *note execve():
     10cc.) 、プロセスを待機 (*note waitpid(): d67.) 、シグナルを送信
     (*note kill(): 132f.) 、もしくはプロセスと通信する API が含まれます
     。 *note subprocess: c1. はインポート可能ですが、機能しません。

   * The *note socket: b8. module is available, but is limited and
     behaves differently from other platforms.  On Emscripten, sockets
     are always non-blocking and require additional JavaScript code and
     helpers on the server to proxy TCP through WebSockets; see
     Emscripten Networking(9) for more information.  WASI snapshot
     preview 1 only permits sockets from an existing file descriptor.

   * Some functions are stubs that either don't do anything and always
     return hardcoded values.

   * Functions related to file descriptors, file permissions, file
     ownership, and links are limited and don't support some operations.
     For example, WASI does not permit symlinks with absolute file
     names.

   ---------- Footnotes ----------

   (1) https://webassembly.org/

   (2) https://emscripten.org/

   (3) https://wasi.dev/

   (4) https://emscripten.org/

   (5) https://wasi.dev/

   (6) https://wasmtime.dev/

   (7) https://pyodide.org/

   (8) https://pyscript.net/

   (9) https://emscripten.org/docs/porting/networking.html


File: python.info,  Node: Mobile platforms,  Prev: WebAssembly プラットフォーム,  Up: 利用可能性について

5.1.1.2 Mobile platforms
........................

Android and iOS are, in most respects, POSIX operating systems.  File
I/O, socket handling, and threading all behave as they would on any
POSIX operating system.  However, there are several major differences:

   * Mobile platforms can only use Python in "embedded" mode.  There is
     no Python REPL, and no ability to use separate executables such as
     ‘python’ or ‘pip’.  To add Python code to your mobile app, you must
     use the *note Python embedding API: 1dbc.  For more details, see
     *note Using Python on Android: 1dba. and *note Using Python on iOS:
     1dc0.

   * Subprocesses:

        * On Android, creating subprocesses is possible but officially
          unsupported(1).  In particular, Android does not support any
          part of the System V IPC API, so *note multiprocessing: 86. is
          not available.

        * An iOS app cannot use any form of subprocessing,
          multiprocessing, or inter-process communication.  If an iOS
          app attempts to create a subprocess, the process creating the
          subprocess will either lock up, or crash.  An iOS app has no
          visibility of other applications that are running, nor any
          ability to communicate with other running applications,
          outside of the iOS-specific APIs that exist for this purpose.

   * Mobile apps have limited access to modify system resources (such as
     the system clock).  These resources will often be 'readable', but
     attempts to modify those resources will usually fail.

   * Console input and output:

        * On Android, the native ‘stdout’ and ‘stderr’ are not connected
          to anything, so Python installs its own streams which redirect
          messages to the system log.  These can be seen under the tags
          ‘python.stdout’ and ‘python.stderr’ respectively.

        * iOS apps have a limited concept of console output.  ‘stdout’
          and ‘stderr’ 'exist', and content written to ‘stdout’ and
          ‘stderr’ will be visible in logs when running in Xcode, but
          this content 'won't' be recorded in the system log.  If a user
          who has installed your app provides their app logs as a
          diagnostic aid, they will not include any detail written to
          ‘stdout’ or ‘stderr’.

        * Mobile apps have no usable ‘stdin’ at all.  While apps can
          display an on-screen keyboard, this is a software feature, not
          something that is attached to ‘stdin’.

          As a result, Python modules that involve console manipulation
          (such as *note curses: 23. and *note readline: a8.) are not
          available on mobile platforms.

   ---------- Footnotes ----------

   (1) https://issuetracker.google.com/issues/128554619#comment4


File: python.info,  Node: 組み込み関数,  Next: 組み込み定数,  Prev: はじめに<6>,  Up: Python 標準ライブラリ

5.2 組み込み関数
================

Python インタプリタには数多くの関数と型が組み込まれており、いつでも利用
できます。それらをここにアルファベット順に挙げます。

組み込み関数

--------------------------------------------------------------------------------------------------------------------
                                                                                      
     'A'                           'E'                         'L'                         'R'
     *note abs(): 1c0e.            *note enumerate(): 1424.     *note len(): 5fa.          *note range(): 20bb.
     *note aiter(): 7a0.           *note eval(): 165.          *note list(): 20b9.         *note repr(): 7c8.
     *note all(): 13c9.            *note exec(): 164.          *note locals(): 127.        *note reversed(): 831.
     *note anext(): 7a1.                                                                   *note round(): 12a8.
     *note any(): 13c8.            'F'                         'M'                         
     *note ascii(): 138e.          *note filter(): 830.        *note map(): 82f.           'S'
                                   *note float(): 2ce.         *note max(): ed4.           *note set(): 20bc.
     'B'                           *note format(): 5eb.        *note memoryview(): 20ba.     *note setattr(): 20bd.
     *note bin(): 127a.            *note frozenset(): 20b8.     *note min(): ed3.          *note slice(): 436.
     *note bool(): 434.                                                                    *note sorted(): b9c.
     *note breakpoint(): 215.      'G'                         'N'                         *note staticmethod(): 3ef.
     *note bytearray(): 1a25.      *note getattr(): b9f.       *note next(): 7a3.          *note str(): 20be.
     *note bytes(): 1a24.          *note globals(): 17d2.                                  *note sum(): 437.
                                                               'O'                         *note super(): 4a8.
     'C'                           'H'                         *note object(): a5a.        
     *note callable(): 1196.       *note hasattr(): 49e.       *note oct(): 129c.          'T'
     *note chr(): 15d6.            *note hash(): 5b5.          *note open(): 4e5.          *note tuple(): 20bf.
     *note classmethod(): 14c.     *note help(): 8a5.          *note ord(): 1e51.          *note type(): d16.
     *note compile(): 177.         *note hex(): 129d.                                      
     *note complex(): 2cf.                                     'P'                         'V'
                                   'I'                         *note pow(): 9a0.           *note vars(): 19ad.
     'D'                           *note id(): 13ca.           *note print(): f42.         
     *note delattr(): 20b6.        *note input(): 12a6.        *note property(): 179.      'Z'
     *note dict(): 20b7.           *note int(): 238.                                       *note zip(): 79b.
     *note dir(): 5fe.             *note isinstance(): 40e.                                
     *note divmod(): 96f.          *note issubclass(): 78c.                                '_'
                                   *note iter(): 7a2.                                      *note __import__(): 8a2.
                                                                                      

 -- の関数: abs (x)

     数の絶対値を返します。引数は整数、浮動小数点数または *note
     __abs__(): 1f18. が実装されたオブジェクトです。引数が複素数なら、そ
     の絶対値 (magnitude) が返されます。

 -- の関数: aiter (async_iterable)

     *note asynchronous iterable: d45. から *note asynchronous iterator:
     190. を返します。 ‘x.__aiter__()’ を呼び出すのと等価です。

     なお、 *note iter(): 7a2. とは異なり、 *note aiter(): 7a0. は第二引
     数を持ちません。

     Added in version 3.10.

 -- の関数: all (iterable)

     'iterable' の全ての要素が真ならば (もしくは 'iterable' が空ならば)
     ‘True’ を返します。以下のコードと等価です:

          def all(iterable):
              for element in iterable:
                  if not element:
                      return False
              return True

 -- の関数: awaitable anext (async_iterator)

 -- の関数: awaitable anext (async_iterator, default)

     待ち受け中に、与えられた非同期イテレータ (*note asynchronous
     iterator: 190.) を返します。イテレータが枯渇した場合、 'default' が
     与えられていれば 'default' を返します。

     これは組み込みの *note next(): 7a3. 関数の非同期版であり、同じよう
     に動作します。

     これは 'async_iterator' の *note __anext__(): 1e6a. メソッドを呼び
     出し、待ち受け可能オブジェクト (*note awaitable: 192.) を返します。
     待ち受けることによりイテレータの次の値を返します。 'default' が与え
     られた場合、イテレータが枯渇したときにその値が返されます。
     'default' が与えられない場合は *note StopAsyncIteration: 1998. が送
     出されます。

     Added in version 3.10.

 -- の関数: any (iterable)

     'iterable' のいずれかの要素が真ならば ‘True’ を返します。'iterable'
     が空なら ‘False’ を返します。以下のコードと等価です:

          def any(iterable):
              for element in iterable:
                  if element:
                      return True
              return False

 -- の関数: ascii (object)

     *note repr(): 7c8. と同様、オブジェクトの印字可能な表現を含む文字列
     を返しますが、*note repr(): 7c8. によって返された文字列中の非 ASCII
     文字は ‘\x’ 、 ‘\u’ 、 ‘\U’ エスケープを使ってエスケープされます。
     これは Python 2 の *note repr(): 7c8. によって返されるのと同じ文字
     列を作ります。

 -- の関数: bin (x)

     整数を先頭に "0b" が付いた 2 進文字列に変換します。 結果は Python の
     式としても使える形式になります。 'x' が Python の *note int: 238. オ
     ブジェクトでない場合、整数を返す *note __index__(): 6e8. メソッドが
     定義されていなければなりません。 いくつかの例を示します:

          >>> bin(3)
          '0b11'
          >>> bin(-10)
          '-0b1010'

     先頭に "0b" が付いて欲しい、もしくは付いて欲しくない場合には、次の
     方法のどちらでも使えます。

          >>> format(14, '#b'), format(14, 'b')
          ('0b1110', '1110')
          >>> f'{14:#b}', f'{14:b}'
          ('0b1110', '1110')

     より詳しいことは *note format(): 5eb. も参照してください。

 -- クラス: bool (object=False, /)

     真偽値、すなわち ‘True’ か ‘False’ のいずれかを返します。引数は標準
     の *note 真偽値判定手続き: 20c0. を用いて変換されます。引数が偽かま
     たは省略された場合、この関数は ‘False’ を返します。それ以外の場合は
     ‘True’ を返します。 *note bool: 434. クラスは *note int: 238. クラ
     スの派生クラスです (*note 数値型 int, float, complex: 1b63. を参照
     してください)。このクラスからさらに派生することはできません。このク
     ラスのインスタンスは ‘False’ と ‘True’ のみです (*note ブーリアン型
     - bool: 20c1. を参照してください)。

     バージョン 3.7 で変更: 引数は位置専用になりました。

 -- の関数: breakpoint (*args, **kws)

     この関数は、呼び出された箇所にて処理をデバッガに移行します。具体的
     には、 *note sys.breakpointhook(): aa8. を呼び出し、 ‘args’ と
     ‘kws’ をそのまま渡します。デフォルトでは、 ‘sys.breakpointhook()’ は
     引数なしで *note pdb.set_trace(): 216. を呼び出すだけです。その場合
     、これは単なる便利関数でデバッガに入るために *note pdb: 94. を明示
     的にインポートしたり多くのコードを書いたりせずに済むだけです。です
     が、 *note sys.breakpointhook(): aa8. は別の関数に設定でき、 *note
     breakpoint(): 215. はそれを自動で呼び出すため、自分好みのデバッガに
     処理を移行させることができます。 *note sys.breakpointhook(): aa8. に
     アクセスできない場合、この関数は *note RuntimeError: 17a. を送出し
     ます。

     デフォルトでは、環境変数 *note PYTHONBREAKPOINT: aa9. をセットする
     ことで *note breakpoint(): 215. の動作を変えることができます。 使い
     方の詳細は *note sys.breakpointhook(): aa8. を参照してください。

     ただし、 *note sys.breakpointhook(): aa8. が別の関数で置き換えられ
     ている場合、上記の環境変数によって必ずしも動作を変えることができな
     いことに注意してください。

     引数 ‘breakpointhook’ 付きで *note 監査イベント: 1825.
     ‘builtins.breakpoint’ を送出します。

     Added in version 3.7.

 -- クラス: bytearray (source=b'')

 -- クラス: bytearray (source, encoding)

 -- クラス: bytearray (source, encoding, errors)

     新しいバイト配列を返します。*note bytearray: 508. クラスは0 <= x <
     256の範囲の整数からなる変更可能な配列です。*note
     ミュータブルなシーケンス型: 20c2. に記述されている変更可能な配列に
     対する普通のメソッドの大半を備えています。また、*note bytes: 1a4. 型
     が持つメソッドの大半も備えています（see *note bytes と bytearray
     の操作: 20c3.)。

     オプションの 'source' 引数は、配列を異なる方法で初期化するのに使わ
     れます:

        * '文字列' の場合、 'encoding' (と、オプションの 'errors') 引数
          も与えなければなりません。このとき *note bytearray(): 508. は
          文字列を *note str.encode(): 8a3. でバイトに変換して返します。

        * '整数' の場合、配列はそのサイズになり、null バイトで初期化され
          ます。

        * *note バッファインターフェース: 371. に適合するオブジェクトの
          場合、そのオブジェクトの読み出し専用バッファがバイト配列の初期
          化に使われます。

        * 'イテラブル' の場合、範囲 ‘0 <= x < 256’ 内の整数のイテラブル
          でなければならず、それらが配列の初期の内容として使われます。

     引数がなければ、長さ 0 の配列が生成されます。

     *note バイナリシーケンス型 -- bytes, bytearray, memoryview: 20c4. と
     *note bytearray オブジェクト: 20c5. も参照してください。

 -- クラス: bytes (source=b'')

 -- クラス: bytes (source, encoding)

 -- クラス: bytes (source, encoding, errors)

     範囲 ‘0 <= x < 256’ の整数のイミュータブルなシーケンスである
     "bytes" オブジェクトを返します。 *note bytes: 1a4. は *note
     bytearray: 508. のイミュータブル版であり、オブジェクトを変化させな
     いメソッドや、インデックス指定、オブジェクトのスライスについてのふ
     るまいは同じです。

     従って、コンストラクタ引数は *note bytearray(): 508. のものと同様に
     解釈されます。

     バイト列オブジェクトはリテラルでも生成できます。 *note
     文字列およびバイト列リテラル: 1e06. を参照してください。

     *note バイナリシーケンス型 -- bytes, bytearray, memoryview: 20c4,
     *note バイトオブジェクト: 20c6, *note bytes と bytearray の操作:
     20c3. も参照してください。

 -- の関数: callable (object)

     'object' 引数が呼び出し可能オブジェクトであれば *note True: bdb. を
     、そうでなければ *note False: b05. を返します。この関数が ‘True’ を
     返しても、呼び出しは失敗する可能性がありますが、‘False’ であれば、
     'object' の呼び出しは決して成功しません。なお、クラスは呼び出し可能
     (クラスを呼び出すと新しいインスタンスを返します) です。また、インス
     タンスはクラスが *note __call__(): 523. メソッドを持つなら呼び出し
     可能です。

     Added in version 3.2: この関数は Python 3.0 で一度取り除かれました
     が、Python 3.2 で復活しました。

 -- の関数: chr (i)

     Unicode コードポイントが整数 'i' である文字を表す文字列を返します。
     例えば ‘chr(97)’ は文字列 ‘'a'’ を、 ‘chr(8364)’ は文字列 ‘'€'’ を
     返します。 *note ord(): 1e51. の逆です。

     引数の有効な範囲は 0 から 1,114,111 (16 進数で 0x10FFFF) です。 'i'
     が範囲外の場合 *note ValueError: 1e3. が送出されます。

 -- の関数: @classmethod

     メソッドをクラスメソッドへ変換します。

     クラスメソッドは、インスタンスメソッドが暗黙の第一引数としてインス
     タンスをとるように、第一引数としてクラスをとります。クラスメソッド
     を宣言するには、以下のイディオムを使います:

          class C:
              @classmethod
              def f(cls, arg1, arg2): ...

     ‘@classmethod’ 形式は関数 *note デコレータ: 6fc. です。詳しくは
     *note 関数定義: 1ba0. を参照してください。

     クラスメソッドは、(‘C.f()’ のように) クラスから呼び出すことも、
     (‘C().f()’ のように) インスタンスから呼び出すこともできます。 イン
     スタンスはそのクラスが何であるかを除いて無視されます。 クラスメソッ
     ドが派生クラスから呼び出される場合は、その派生クラスオブジェクトが
     暗黙の第一引数として渡されます。

     クラスメソッドは C++ や Java の静的メソッドとは異なります。静的メソ
     ッドは、この節の *note staticmethod(): 3ef. を参照してください。ク
     ラスメソッドについてより詳しいことは *note 標準型の階層: 1e46. を参
     照してください。

     バージョン 3.9 で変更: クラスメソッドは *note property(): 179. など
     、他の *note デスクリプタ: 1ed1. をラップすることができるようになり
     ました。

     バージョン 3.10 で変更: Class methods now inherit the method
     attributes (*note __module__: 1e5d, *note __name__: 12a2, *note
     __qualname__: 1e5c, *note __doc__: 11a9. and *note __annotations__:
     11a8.) and have a new ‘__wrapped__’ attribute.

     Deprecated since version 3.11, removed in version 3.13: クラスメソ
     ッドは *note property(): 179. など、他の *note デスクリプタ: 1ed1.
     をラップすることができなくなりました。

 -- の関数: compile (source, filename, mode, flags=0,
          dont_inherit=False, optimize=-1)

     'source' をコードオブジェクト、もしくは、 AST オブジェクトにコンパ
     イルします。 コードオブジェクトは *note exec(): 164. 文で実行したり
     、 *note eval(): 165. 呼び出しで評価できます。 'source' は通常の文
     字列、 バイト列、 AST オブジェクトのいずれでもかまいません。 AST オ
     ブジェクトへの、また、 AST オブジェクトからのコンパイルの方法は、
     *note ast: 7. モジュールのドキュメントを参照してください。

     'filename' 引数には、コードの読み出し元のファイルを与えなければなり
     ません; ファイルから読み出されるのでなければ、認識可能な値を渡して
     下さい (‘'<string>'’ が一般的に使われます)。

     'mode' 引数は、コンパイルされるコードの種類を指定します; 'source' が
     一連の文から成るなら ‘'exec'’ 、単一の式から成るなら ‘'eval'’ 、単
     一の対話的文の場合 ‘'single'’ です。(後者の場合、評価が ‘None’ 以外
     である式文が印字されます)。

     オプション引数 'flags' と 'dont_inherit' は、どの *note
     コンパイラオプション: 20c7. を有効化するか、 *note 将来の機能: 16e.
     のどれを許可するかを制御します。どちらの引数も存在しない (またはど
     ちらもゼロである) 場合は、 *note compile(): 177. の呼び出し元のコー
     ドに作用したものと同じフラグでコンパイルされます。 'flags' 引数が与
     えられて 'dont_inherit' が与えられない (またはゼロ) の場合、上記に
     加えて 'flags' 引数で与えられたコンパイラオプションと future 文が使
     われます。 'dont_inherit' がゼロでない整数の場合、 'flags' 引数で指
     定されたオプションだけが有効です - 呼び出し元コードに適用されたフラ
     グ (将来の機能とコンパイラオプション) は無視されます。

     有効化するコンパイラオプションと future 文はビットフィールドで指定
     可能で、ビット単位の OR をとることで複数のオプションを一緒に指定す
     ることができます。特定の future 機能を指定するために必要なビットフ
     ィールドの情報は、 *note __future__: 0. モジュールにおける *note
     _Feature: 20c8. インスタンスの *note compiler_flag: 20c9. 属性で得
     ることができます。 *note コンパイラフラグ: 20c7. の情報は *note
     ast: 7. モジュールの ‘PyCF_’ で始まるフラグで得ることができます。

     引数 'optimize' は、コンパイラの最適化レベルを指定します; デフォル
     トの値 ‘-1’ は、インタプリタの *note -O: d82. オプションで与えられ
     るのと同じ最適化レベルを選びます。明示的なレベルは、 ‘0’ (最適化な
     し、 ‘__debug__’ は真)、 ‘1’ (assert は取り除かれ、 ‘__debug__’ は
     偽)、 ‘2’ (docstring も取り除かれる) です。

     この関数は、コンパイルされたソースが不正である場合 *note
     SyntaxError: 172. を、ソースがヌルバイトを含む場合 *note
     ValueError: 1e3. を送出します。

     Python コードをパースしてその AST 表現を得たいのであれば、 *note
     ast.parse(): 18d. を参照してください。

     引数 ‘source’ と ‘filename’ を指定して *note 監査イベント: 1825.
     ‘compile’ を送出します。これは、暗黙に行われるコンパイルでも送出さ
     れる可能性があります。

          注釈: 複数行に渡るコードの文字列を ‘'single'’ や ‘'eval'’ モー
          ドでコンパイルするとき、入力は一つ以上の改行文字で終端されなけ
          ればなりません。これは、 *note code: 13. モジュールで不完全な
          文と完全な文を検知しやすくするためです。

          警告: AST オブジェクトにコンパイルしているときに、十分に大きい
          文字列や複雑な文字列によって Python の抽象構文木コンパイラのス
          タックが深さの限界を越えることで、 Python インタプリタをクラッ
          シュさせられます。

     バージョン 3.2 で変更: Windows や Mac の改行も受け付けます。また
     ‘'exec'’ モードでの入力が改行で終わっている必要もありません。
     'optimize' 引数が追加されました。

     バージョン 3.5 で変更: 以前は 'source' にヌルバイトがあったときに
     *note TypeError: 502. を送出していました。

     Added in version 3.8: ‘ast.PyCF_ALLOW_TOP_LEVEL_AWAIT’ フラグを渡し
     てトップレベルの ‘await’, ‘async for’, および ‘async with’ のサポー
     トを有効化することができるようになりました。

 -- クラス: complex (number=0, /)

 -- クラス: complex (string, /)

 -- クラス: complex (real=0, imag=0)

     単一の文字列や数値を複素数に変換する、あるいは実部と虚部から複素数
     を作成します。

     例:

          >>> complex('+1.23')
          (1.23+0j)
          >>> complex('-4.5j')
          -4.5j
          >>> complex('-1.23+4.5j')
          (-1.23+4.5j)
          >>> complex('\t( -1.23+4.5J )\n')
          (-1.23+4.5j)
          >>> complex('-Infinity+NaNj')
          (-inf+nanj)
          >>> complex(1.23)
          (1.23+0j)
          >>> complex(imag=-4.5)
          -4.5j
          >>> complex(-1.23, 4.5)
          (-1.23+4.5j)

     引数が文字列の場合、実数部（ *note float(): 2ce. と同じ形式）、虚数
     部（同様の形式で ‘'j'’ または ‘'J'’ 接尾辞）どちらか、あるいは両方
     （この場合、虚数部の符号は必須）を含まなければなりません。文字列 は
     空白や括弧 ‘'('’ と''')''' で囲むこともできますが、無視されます。文
     字列は、 ‘'+'’ 、‘'-'’ 、 ‘'j'’ または ‘'J'’ 接尾辞 、そして10進数
     の間に空白を含んではなりません。たとえば ‘complex('1+2j')’ はよいで
     すが、 ‘complex('1 + 2j')’ は *note ValueError: 1e3. を送出します。
     より正確には、入力は括弧および先頭と末尾の空白文字を除去した後、以
     下の文法における *note complexvalue: 20ca. の生成規則を満たす必要が
     あります:

          complexvalue ::= floatvalue |
                           floatvalue ("j" | "J") |
                           floatvalue sign absfloatvalue ("j" | "J")

     引数が数値の場合、コンストラクタは *note int: 238. や *note float:
     2ce. のように数値変換します。一般的な Python オブジェクト ‘x’ では
     、 ‘complex(x)’ は ‘x.__complex__()’ に委譲します。 *note
     __complex__(): 5b1. が定義されていない場合は *note __float__():
     99a. にフォールバックします。 ‘__float__()’ も定義されていない場合
     には、 *note __index__(): 6e8. にフォールバックします。

     ２引数が指定されるかキーワード引数が使われている場合、各引数は任意
     の数値型（複素数を含む）となります。両方の引数が実数の場合には、実
     数成分 'real' と虚数成分 'imag' を持つ複素数を返します。引数が両方
     とも複素数の場合、実数成分 ‘real.real-imag.imag’ と虚数成分
     ‘real.imag+imag.real’ を持つ複素数を返します。引数の片方が実数の場
     合、前述の式ではその実数成分のみ使われます。

     引数がすべて省略された場合は、 ‘0j’ を返します。

     複素数型については *note 数値型 int, float, complex: 1b63. に説明が
     あります。

     バージョン 3.6 で変更: コードリテラル中で桁をグループ化するのにアン
     ダースコアを利用できます。

     バージョン 3.8 で変更: *note __complex__(): 5b1. と *note
     __float__(): 99a. が定義されていない場合、 *note __index__(): 6e8.
     へフォールバックします。

 -- の関数: delattr (object, name)

     *note setattr(): 20bd. の親戚です。引数はオブジェクトと文字列です。
     文字列はオブジェクトの属性名のいずれかでなければなりません。対象の
     オブジェクトが許可する場合に限り、この関数は指定された名前の属性を
     削除します。たとえば、 ‘delattr(x, 'foobar')’ は ‘del x.foobar’ と
     等価です。 'name' は Python の識別子である必要はありません (*note
     setattr(): 20bd. を参照してください)。

 -- クラス: dict (**kwarg)

 -- クラス: dict (mapping, **kwarg)

 -- クラス: dict (iterable, **kwarg)

     新しい辞書を作成します。 *note dict: 237. オブジェクトは辞書クラス
     です。このクラスに関するドキュメンテーションは *note dict: 237. と
     *note マッピング型 -- dict: a94. を参照してください。

     他のコンテナについては、 ビルトインの *note list: 5dc, *note set:
     5a3, *note tuple: 349. クラスおよび *note collections: 16. モジュー
     ルを参照してください。

 -- の関数: dir ()

 -- の関数: dir (object)

     引数がない場合、現在のローカルスコープにある名前のリストを返します
     。引数がある場合、そのオブジェクトの有効な属性のリストを返そうと試
     みます。

     オブジェクトが *note __dir__(): 1ec7. という名のメソッドを持つなら
     、そのメソッドが呼び出され、属性のリストを返さなければなりません。
     これにより、カスタムの *note __getattr__(): 49f. や *note
     __getattribute__(): ba0. 関数を実装するオブジェクトは、*note dir():
     5fe. が属性を報告するやり方をカスタマイズできます。

     オブジェクトが *note __dir__(): 1ec7. を提供しない場合、その型オブ
     ジェクトと、定義されていればオブジェクトの *note __dict__: 526. 属
     性から、できるだけ情報を集めようとします。結果のリストは必ずしも完
     全ではなく、カスタムの *note __getattr__(): 49f. を持つ場合は不正確
     かもしれません。

     デフォルトの *note dir(): 5fe. メカニズムは、完全というより最重要な
     情報を作成しようとするため、異なる型のオブジェクトでは異なって振る
     舞います:

        * オブジェクトがモジュールオブジェクトの場合、リストにはモジュー
          ルの属性の名前が含まれます。

        * オブジェクトが型オブジェクトやクラスオブジェクトの場合、リスト
          にはその属性の名前と、再帰的にたどったその基底クラスの属性が含
          まれます。

        * それ以外の場合には、リストにはオブジェクトの属性名、クラス属性
          名、再帰的にたどった基底クラスの属性名が含まれます。

     返されるリストはアルファベット順に並べられています。例えば:

          >>> import struct
          >>> dir()   # show the names in the module namespace
          ['__builtins__', '__name__', 'struct']
          >>> dir(struct)   # show the names in the struct module
          ['Struct', '__all__', '__builtins__', '__cached__', '__doc__', '__file__',
           '__initializing__', '__loader__', '__name__', '__package__',
           '_clearcache', 'calcsize', 'error', 'pack', 'pack_into',
           'unpack', 'unpack_from']
          >>> class Shape:
          ...     def __dir__(self):
          ...         return ['area', 'perimeter', 'location']
          ...
          >>> s = Shape()
          >>> dir(s)
          ['area', 'location', 'perimeter']

          注釈: *note dir(): 5fe. は主に対話プロンプトでの使用に便利なよ
          うに提供されているので、厳密性や一貫性を重視して定義された名前
          のセットというよりも、むしろ興味を引くような名前のセットを返そ
          うとします。また、この関数の細かい動作はリリース間で変わる可能
          性があります。例えば、引数がクラスであるとき、メタクラス属性は
          結果のリストに含まれません。

 -- の関数: divmod (a, b)

     2つの (複素数でない) 数を引数としてとり、整数の除法を行ったときの商
     と剰余からなる2つの数のペアを返します。被演算子の型が異なる場合、二
     項算術演算子での規則が適用されます。整数に対する結果は ‘(a // b, a
     % b)’ と同じです。浮動小数点数では、結果は ‘(q, a % b)’ とあらわさ
     れます。 'q' は通常 ‘math.floor(a / b)’ ですが、それより 1 少ないこ
     ともあります。いずれにせよ ‘q * b + a % b’ は 'a' に非常に近い値に
     なります。もし ‘a % b’ がゼロでないときは、その符号は 'b' と同じで
     あり、かつ ‘0 <= abs(a % b) < abs(b)’ を満たします。

 -- の関数: enumerate (iterable, start=0)

     enumerate オブジェクトを返します。 'iterable' は、シーケンスか
     *note iterator: 191. か、あるいはイテレーションをサポートするその他
     のオブジェクトでなければなりません。 *note enumerate(): 1424. によ
     って返されたイテレータの *note __next__(): 129b. メソッドは、 (デフ
     ォルトでは 0 となる 'start' からの) カウントと、 'iterable' 上のイ
     テレーションによって得られた値を含むタプルを返します。

          >>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
          >>> list(enumerate(seasons))
          [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]
          >>> list(enumerate(seasons, start=1))
          [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]

     次と等価です:

          def enumerate(iterable, start=0):
              n = start
              for elem in iterable:
                  yield n, elem
                  n += 1

 -- の関数: eval (source, /, globals=None, locals=None)


     パラメータ:

        * ‘source’ (*note str: 418. | *note code object: 1b4.) - Python
          式。

        * ‘globals’ (*note dict: 237. | ‘None’) - グローバル名前空間
          (default: ‘None’) 。

        * ‘locals’ (*note mapping: 118c. | ‘None’) - ローカル名前空間
          (default: ‘None’) 。


     戻り値: 評価された式の結果。


     例外: 構文エラーは例外として報告されます。

          警告: This function executes arbitrary code.  Calling it with
          user-supplied input may lead to security vulnerabilities.

     'expression' 引数のパースと評価は、 'globals' / 'locals' のマッピン
     グ（訳注：dict相当）をグローバル / ローカルの名前空間とした Python
     式 (技術的な言葉では式のリスト - 訳注：詳細は言語リファレンス６章参
     照) として行われます。 'globals' 辞書が渡され それが ‘__builtins__’
     をキーとして持たない場合は、そのキーの下に組み込みモジュール *note
     builtins: e. の辞書への参照が挿入されてから、'expression' が解析さ
     れます。 つまり、 'globals' に独自の ‘__builtins__’ 辞書を含めて
     *note eval(): 165. に渡すことで、実行されるコードで有効となる組み込
     み関数を統制できます。 'locals' マッピングが省略された場合、
     'globals' 辞書がデフォルトとして使われます。どちらのマッピングも省
     略された場合、 *note eval(): 165. が呼び出された環境における
     'globals' と 'locals' のもとで式が評価されます。 注意点として、
     'eval()' は、 *note eval(): 165. を呼び出したスコープからすでに参照
     されている場合（例： *note nonlocal: 1279. 文より）のみ *note
     ネストされたスコープ: 1e9e. (ローカルでないオブジェクト) へのアクセ
     スを持ちます。

     例:

          >>> x = 1
          >>> eval('x+1')
          2

     この関数は (*note compile(): 177. で生成されるような) 任意のコード
     オブジェクトを実行するのにも利用できます。この場合、文字列の代わり
     にコードオブジェクトを渡してください。このコードオブジェクトが、引
     数 'mode' を ‘'exec'’ としてコンパイルされている場合、 *note
     eval(): 165. の戻り値は ‘None’ になります。

     ヒント: *note exec(): 164. 関数により文の動的な実行がサポートされて
     います。*note globals(): 17d2. および *note locals(): 127. 関数は、
     それぞれ現在のグローバルおよびローカルな辞書を返すので、それらを
     *note eval(): 165. や *note exec(): 164. に渡して使うことができます
     。

     ソースコードとして文字列が与えられた場合、先頭と末尾の空白文字およ
     びタブは取り去られます。

     リテラルだけを含む式の文字列を安全に評価できる関数、 *note
     ast.literal_eval(): be6. も参照してください。

     コードオブジェクトを引数として *note 監査イベント: 1825. ‘exec’ を
     送出します。コードコンパイルのイベントも送出されることがあります。

     バージョン 3.13 で変更: 'globals' と 'locals' 引数 はキーワードとし
     て渡せるようになった。

     バージョン 3.13 で変更: デフォルトの 'locals' 名前空間のセマンティ
     クスは、 組み込み *note locals(): 127. の説明のように調整された。

 -- の関数: exec (source, /, globals=None, locals=None, *, closure=None)

          警告: This function executes arbitrary code.  Calling it with
          user-supplied input may lead to security vulnerabilities.

     この関数は Python コードの動的な実行をサポートします。 'source' は
     文字列かコードオブジェクトでなければなりません。文字列の場合、その
     文字列は一連の Python 文として解析され、そして (構文エラーにならな
     い限り) 実行されます。 (1) コードオブジェクトの場合は、単純に実行さ
     れます。どの場合でも、実行されるコードはファイル入力形式として有効
     であることが期待されます (リファレンスマニュアルの *note
     ファイル入力: 20a0. 節を参照してください)。 *note nonlocal: 1279,
     *note yield: 99b, および *note return: 99c. 文は、 *note exec():
     164. 関数に渡されたコードの文脈中でさえ、関数定義の外側で使うことは
     できません。戻り値は ‘None’ です。

     どの場合でも、オプションの部分が省略されると、コードは現在のスコー
     プ内で実行されます。 'globals' だけが与えられた場合、その値は辞書で
     なければならず (かつ辞書のサブクラスであってはならず)、グローバル変
     数とローカル変数の両方に使われます。 'globals' と 'locals' の両方が
     与えられた場合、それぞれグローバル変数とローカル変数に使われます。
     'locals' を指定する場合、その値はマップ型オブジェクトでなければなり
     ません。モジュールレベルでは globals と locals は同じ辞書であること
     に留意してください。

          注釈: ‘exec’ が 'globals' と 'locals' 2つ別々のオブジェクトを
          取る場合、コードはクラス定義に埋め込まれたかのように実行されま
          す。これは、実行されたコードで定義された関数とクラスが、トップ
          レベルで割り当てられた変数にアクセスできないことを意味します（
          「トップレベル」変数はクラス定義にてクラス変数として扱われるた
          め）。

     'globals' 辞書がキー ‘__builtins__’ に対する値を含まなければ、その
     キーに対して、組み込みモジュール *note builtins: e. の辞書への参照
     が挿入されます。ですから、実行されるコードを *note exec(): 164. に
     渡す前に、 'globals' に自作の ‘__builtins__’ 辞書を挿入することで、
     コードがどの組み込みを利用できるか制御できます。

     The 'closure' argument specifies a closure-a tuple of cellvars.
     It's only valid when the 'object' is a code object containing *note
     free (closure) variables: 1e9f.  The length of the tuple must
     exactly match the length of the code object's *note co_freevars:
     1e5a. attribute.

     コードオブジェクトを引数として *note 監査イベント: 1825. ‘exec’ を
     送出します。コードコンパイルのイベントも送出されることがあります。

          注釈: 組み込み関数 *note globals(): 17d2. および *note
          locals(): 127. は、それぞれ現在のグローバルおよびローカルの名
          前空間を返すので、それらを *note exec(): 164. の第二、第三引数
          にそのまま渡して使うと便利なことがあります。

          注釈: 標準では 'locals' は後に述べる関数 *note locals(): 127.
          のように動作します。 *note exec(): 164. の呼び出しが返る時にコ
          ードが 'locals' に与える影響を知りたいなら、明示的に 'locals'
          辞書を渡してください。

     バージョン 3.11 で変更: 'closure' パラメータが追加されました。

     バージョン 3.13 で変更: 'globals' と 'locals' 引数 はキーワードとし
     て渡せるようになった。

     バージョン 3.13 で変更: デフォルトの 'locals' 名前空間のセマンティ
     クスは、 組み込み *note locals(): 127. の説明のように調整された。

 -- の関数: filter (function, iterable)

     'iterable' の要素のうち、 'function' が真であるものからイテレータを
     構築します。 'iterable' にはシーケンスか、イテレーションをサポート
     するコンテナか、イテレータを渡せます。 'function' が ‘None’ のとき
     は恒等関数が指定されたものとして扱われ、 'iterable' のうち偽である
     ものがすべて取り除かれます。

     なお、‘filter(function, iterable)’ は、関数が ‘None’ でなければジェ
     ネレータ式 ‘(item for item in iterable if function(item))’ と同等で
     、関数が ‘None’ なら ‘(item for item in iterable if item)’ と同等で
     す。

     逆の働きをする関数については、 *note itertools.filterfalse(): 20cc.
     を参照してください。 'iterable' の要素のうち、 'function' が偽であ
     るものを返します。

 -- クラス: float (number=0.0, /)

 -- クラス: float (string, /)

     数または文字列から生成された浮動小数点数を返します。

     例:

          >>> float('+1.23')
          1.23
          >>> float('   -12345\n')
          -12345.0
          >>> float('1e-003')
          0.001
          >>> float('+1E6')
          1000000.0
          >>> float('-Infinity')
          -inf

     引数が文字列の場合、10進数でなければなりません。先頭に符号または空
     白を含んでもかまいません。符号は ‘'+'’ か ‘'-'’ のいずれかです。正
     符号 ‘'+'’ は生成される値に対して何の効果もありません。引数は NaN
     (not-a-number) や正または負の無限大をあらわす文字列でもかまいません
     。より正確にいうと、入力は先頭と末尾の空白文字を除き、以下に示す
     *note floatvalue: 20cd. の生成規則に従う必要があります:

          sign          ::= "+" | "-"
          infinity      ::= "Infinity" | "inf"
          nan           ::= "nan"
          digit         ::= <a Unicode decimal digit, i.e. characters in Unicode general category Nd>
          digitpart     ::= digit (["_"] digit)*
          number        ::= [digitpart] "." digitpart | digitpart ["."]
          exponent      ::= ("e" | "E") [sign] digitpart
          floatnumber   ::= number [exponent]
          absfloatvalue ::= floatnumber | infinity | nan
          floatvalue    ::= [sign] absfloatvalue

     大文字と小文字は重要ではないので、例えば、 "inf", "Inf",
     "INFINITY", "iNfINity" はすべて正の無限大を表す綴りとして受け入れら
     れます。

     また、引数が整数または浮動小数点数なら、 (Python の浮動小数点数の精
     度で) 同じ値の浮動小数点数が返されます。 引数が Python の浮動小数点
     数の範囲外なら、 *note OverflowError: 84e. が送出されます。

     一般の Python オブジェクト ‘x’ に対して、‘float(x)’ は
     ‘x.__float__()’ に委譲します。 *note __float__(): 99a. が定義されて
     いない場合、*note __index__(): 6e8. へフォールバックします。

     引数が与えられなければ、‘0.0’ が返されます。

     浮動小数点数型については、 *note 数値型 int, float, complex: 1b63.
     も参照してください。

     バージョン 3.6 で変更: コードリテラル中で桁をグループ化するのにアン
     ダースコアを利用できます。

     バージョン 3.7 で変更: 引数は位置専用になりました。

     バージョン 3.8 で変更: *note __float__(): 99a. が定義されていない場
     合、 *note __index__(): 6e8. へフォールバックします。

 -- の関数: format (value, format_spec='')

     'value' を 'format_spec' で指示された通りに "整形" した文字列表現に
     変換します。 'format_spec' の解釈は 'value' 引数の型に依存しますが
     、ほとんどの組み込み型で使われる標準的な構文が存在します: *note
     書式指定ミニ言語仕様: 1c9.。

     デフォルトの 'format_spec' は空の文字列です。それは通常 *note
     str(value): 418. の呼び出しと同じ結果になります。

     ‘format(value, format_spec)’ の呼び出しは、
     ‘type(value).__format__(value, format_spec)’ に翻訳され、これは
     value の *note __format__(): 5ea. メソッドの検索をするとき、インス
     タンス辞書を回避します。このメソッドの探索が *note object: a5a. に
     到達しても 'format_spec' が空にならなかったり、 'format_spec' や返
     り値が文字列でなかったりした場合、 *note TypeError: 502. が送出され
     ます。

     バージョン 3.4 で変更: 'format_spec' が空の文字列でない場合
     ‘object().__format__(format_spec)’ は *note TypeError: 502. を送出
     します。

 -- クラス: frozenset (iterable=set())

     新しい *note frozenset: 5a4. オブジェクトを返します。オプションで
     'iterable' から得られた要素を含みます。 ‘frozenset’ はビルトインク
     ラスです。このクラスに関するドキュメントは *note frozenset: 5a4. と
     *note set（集合）型 -- set, frozenset: 20d7. を参照してください。

     他のコンテナについては、ビルトインクラス *note set: 5a3, *note
     list: 5dc, *note tuple: 349, *note dict: 237. や *note collections:
     16. モジュールを見てください。

 -- の関数: getattr (object, name)

 -- の関数: getattr (object, name, default)

     'object' の指定された属性の値を返します。 'name' は文字列でなければ
     なりません。与えられた文字列がオブジェクトの属性名のうちいずれかに
     一致すれば、戻り値はその属性の値になります。たとえば、 ‘getattr(x,
     'foobar')’ は ‘x.foobar’ と等価です。もし指定された属性が存在しない
     場合、 'default' が指定されていればその値が返されます。そうでない場
     合は *note AttributeError: 326. が送出されます。 'name' は Python 識
     別子である必要はありません (*note setattr(): 20bd. を参照してくださ
     い)。

          注釈: *note プライベートな名前のマングリング: 1c24. はコンパイ
          ル時に行われます。そのため、プライベートな属性 (先頭に2つのア
          ンダースコアを伴う名前を持つ属性) の値を *note getattr(): b9f.
          で取り出すためには、属性名を手動でマングリングする必要がありま
          す。

 -- の関数: globals ()

     現在のモジュールの名前空間を実装した辞書を返します。関数内のコード
     に対しては、関数が定義されるときに辞書が設定され、その関数がどこか
     ら呼ばれたかにかかわらず同じ内容になります。

 -- の関数: hasattr (object, name)

     引数はオブジェクトと文字列です。文字列がオブジェクトの属性名の一つ
     であった場合 ‘True’ を、そうでない場合 ‘False’ を返します。 (この関
     数は、 ‘getattr(object, name)’ を呼び出して *note AttributeError:
     326. を送出するかどうかを見ることで実装されています。)

 -- の関数: hash (object)

     オブジェクトのハッシュ値を (存在すれば) 返します。ハッシュ値は整数
     です。これらは辞書を検索する際に辞書のキーを高速に比較するために使
     われます。等しい値となる数値は等しいハッシュ値を持ちます (1 と 1.0
     のように型が異なっていてもです)。

          注釈: 独自の *note __hash__(): ac9. メソッドを実装したオブジェ
          クトを使う場合、*note hash(): 5b5. が実行するマシンのビット幅
          に合わせて戻り値を切り捨てることに注意してください。

 -- の関数: help ()

 -- の関数: help (request)

     組み込みヘルプシステムを起動します。(この関数は対話的な使用のための
     ものです。) 引数が与えられていない場合、対話的ヘルプシステムはイン
     タプリタコンソール上で起動します。引数が文字列の場合、文字列はモジ
     ュール、関数、クラス、メソッド、キーワード、またはドキュメントの項
     目名として検索され、ヘルプページがコンソール上に印字されます。引数
     がその他のオブジェクトの場合、そのオブジェクトに関するヘルプページ
     が生成されます。

     *note help(): 8a5. を呼び出したときに関数の引数リストにスラッシュ
     (/) が現れた場合は、スラッシュより前の引数が位置専用引数だという意
     味であることに注意してください。より詳しい情報は、 *note
     位置専用引数についての FAQ の項目: 20d8. を参照してください。

     この関数は、 *note site: b5. モジュールから、組み込みの名前空間に移
     されました。

     バージョン 3.4 で変更: *note pydoc: a3. と *note inspect: 72. への
     変更により、呼び出し可能オブジェクトの報告されたシグニチャがより包
     括的で一貫性のあるものになりました。

 -- の関数: hex (x)

     整数を先頭に "0x" が付いた小文字の 16 進文字列に変換します。 'x' が
     Python の *note int: 238. オブジェクトでない場合、整数を返す *note
     __index__(): 6e8. メソッドが定義されていなければなりません。 いくつ
     かの例を示します:

          >>> hex(255)
          '0xff'
          >>> hex(-42)
          '-0x2a'

     整数を大文字の 16 進文字列や小文字の 16 進文字列、先頭の "0x" 付き
     や "0x" 無しに変換したい場合は、次に挙げる方法が使えます:

          >>> '%#x' % 255, '%x' % 255, '%X' % 255
          ('0xff', 'ff', 'FF')
          >>> format(255, '#x'), format(255, 'x'), format(255, 'X')
          ('0xff', 'ff', 'FF')
          >>> f'{255:#x}', f'{255:x}', f'{255:X}'
          ('0xff', 'ff', 'FF')

     より詳しいことは *note format(): 5eb. も参照してください。

     16を底として16進数文字列を整数に変換するには *note int(): 238. も参
     照してください。

          注釈: 浮動小数点数の16進文字列表記を得たい場合には、 *note
          float.hex(): 1c7d. メソッドを使って下さい。

 -- の関数: id (object)

     オブジェクトの "識別値" を返します。この値は整数で、このオブジェク
     トの有効期間中は一意かつ定数であることが保証されています。有効期間
     が重ならない 2 つのオブジェクトは同じ *note id(): 13ca. 値を持つか
     もしれません。

     'CPython 実装の詳細:' これはオブジェクトのメモリアドレスです。

     引数 ‘id’ を指定して *note 監査イベント: 1825. ‘builtins.id’ を送出
     します。

 -- の関数: input ()

 -- の関数: input (prompt)

     引数 'prompt' が存在すれば、それが末尾の改行を除いて標準出力に書き
     出されます。次に、この関数は入力から 1 行を読み込み、文字列に変換し
     て (末尾の改行を除いて) 返します。 EOF が読み込まれたとき、 *note
     EOFError: 12a7. が送出されます。例:

          >>> s = input('--> ')
          --> Monty Python's Flying Circus
          >>> s
          "Monty Python's Flying Circus"

     *note readline: a8. モジュールが読み込まれていれば、 *note input():
     12a6. はそれを使って精緻な行編集やヒストリ機能を提供します。

     入力を読み込む前に、引数 ‘prompt’ 付きで *note 監査イベント: 1825.
     ‘builtins.input’ を送出します。

     入力の読み込みに成功した後に、その結果付きで *note 監査イベント:
     1825. ‘builtins.input/result’ を送出します。

 -- クラス: int (number=0, /)

 -- クラス: int (string, /, base=10)

     数または文字列から生成された整数オブジェクトを返します。引数が指定
     されない場合は ‘0’ を返します。

     例:

          >>> int(123.45)
          123
          >>> int('123')
          123
          >>> int('   -12_345\n')
          -12345
          >>> int('FACE', 16)
          64206
          >>> int('0xface', 0)
          64206
          >>> int('01110011', base=2)
          115

     引数に *note __int__(): 6e7. が定義されている場合は、 ‘int(x)’ は
     ‘x.__int__()’ を返します。引数に *note __index__(): 6e8. が定義され
     ている場合は、 ‘x.__index__()’ を返します。引数に *note
     __trunc__(): 6e6. が定義されている場合は、 ‘x.__trunc__()’ を返しま
     す。浮動小数点数については、これは 0 に近い側へ切り捨てます。

     引数が数値でないか、または 'base' が与えられた場合、引数は 'base' を
     基数とした整数を表現する文字列、 *note bytes: 1a4. インスタンス、ま
     たは *note bytearray: 508. インスタンスのいずれかでなければなりませ
     ん。文字列は先頭に ‘+’ または ‘-’ を伴ったり (符号と数値の間に空白
     文字を入れてはいけません)、数値の先頭に任意の数のゼロを付けたり、前
     後に空白文字を付けたり、各桁を単一の下線で区切ったりしても有効です
     。

     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に指定した場合、文字列は *note
     コードにおける整数リテラル: 1e27. と同じように解釈されます。すなわ
     ち、プレフィックスによって基数が2, 8, 10, または 16 のどれになるか
     が決まります。基数を0にした場合先頭にゼロを追加することはできません
     : すなわち ‘int('010', 0)’ は基数を0に指定しているため不正ですが、
     ‘int('010')’ や ‘int('010', 8)’ は有効です。

     整数型については、 *note 数値型 int, float, complex: 1b63. も参照し
     てください。

     バージョン 3.4 で変更: 'base' が *note int: 238. のインスタンスでな
     く、'base' オブジェクトが *note base.__index__: 6e8. メソッドを持っ
     ている場合、そのメソッドを呼んで底に対する整数を得ることができます
     。以前のバージョンでは *note base.__index__: 6e8. ではなく *note
     base.__int__: 6e7. を使用していました。

     バージョン 3.6 で変更: コードリテラル中で桁をグループ化するのにアン
     ダースコアを利用できます。

     バージョン 3.7 で変更: 第1引数は位置専用になりました。

     バージョン 3.8 で変更: *note __int__(): 6e7. が定義されていない場合
     、 *note __index__(): 6e8. へフォールバックします。

     バージョン 3.11 で変更: *note __trunc__(): 6e6. への処理の委譲は非
     推奨になりました。

     バージョン 3.11 で変更: *note int: 238. への文字列入力やその文字列
     表現は、サービス拒否攻撃 (DoS 攻撃) を避けるために制限されることが
     あります。文字列を *note int: 238. に変換したり *note int: 238. を
     文字列に変換したりする際にその制限を超えた場合、 *note ValueError:
     1e3. が送出されます。詳しくは *note
     整数文字列の変換における長さ制限: 5bf. を参照してください。

 -- の関数: isinstance (object, classinfo)

     'object' 引数が 'classinfo' 引数に指定した型、またはその (直接、間
     接、または *note 仮想: 1186. の) サブクラスのインスタンスである場合
     に ‘True’ を返します。 'object' が与えられた型のオブジェクトでない
     場合、この関数は常に ‘False’ を返します。 'classinfo' が型オブジェ
     クトのタプル (または再帰的にそのようなタプルを含むタプル) や複数の
     型の *note Union 型: 78d. である場合、 'object' がそれらの型のいず
     れかのインスタンスであれば ‘True’ を返します。 'classinfo' が型や型
     からなるタプルまたは再帰的タプルのいずれでもない場合、 *note
     TypeError: 502. 例外が送出されます。タプルの中で先行する型に対する
     チェックが成功した場合、後続の不正な型に対して *note TypeError:
     502. が送出されないことがあります。

     バージョン 3.10 で変更: 'classinfo' に *note Union 型: 78d. を指定
     できるようになりました。

 -- の関数: issubclass (class, classinfo)

     'class' が 'classinfo' の (直接、間接、または *note 仮想: 1186. の)
     サブクラスである場合に ‘True’ を返します。クラスは自身のサブクラス
     とみなされます。 'classinfo' はクラスオブジェクトのタプル (または再
     帰的にそのようなタプルを含むタプル) やクラスオブジェクトの *note
     Union 型: 78d. でもよく、この場合は 'class' が 'classinfo' のいずれ
     かのクラスのサブクラスであれば ‘True’ を返します。上記以外の値が指
     定された場合、 *note TypeError: 502. 例外が送出されます。

     バージョン 3.10 で変更: 'classinfo' に *note Union 型: 78d. を指定
     できるようになりました。

 -- の関数: iter (object)

 -- の関数: iter (object, sentinel)

     *note iterator: 191. オブジェクトを返します。第二引数があるかどうか
     によって第一引数の解釈は大きく異なります。第二引数がない場合、
     'object' は *note iterable: 10ad. プロトコル (*note __iter__():
     1ebc. メソッド) をサポートするコレクションオブジェクトか、またはシ
     ーケンスプロトコル (‘0’ から始まる整数を引数にとる *note
     __getitem__(): 264. メソッド) をサポートするオブジェクトでなければ
     なりません。第一引数がどちらのプロトコルもサポートしない場合は
     *note TypeError: 502. 例外が送出されます。第二引数 'sentinel' が与
     えられた場合、 'object' は呼び出し可能オブジェクトでなければなりま
     せん。この場合に生成されるイテレータは *note __next__(): 129b. メソ
     ッドを呼び出すごとに引数なしで 'object' を呼び出します; 戻り値が
     'sentinel' と等しければ、 *note StopIteration: bc8. が送出されます
     。それ以外の場合は戻り値がそのまま返されます。

     *note イテレータ型: 20d9. も見てください。

     2引数形式の *note iter(): 7a2. の便利な利用方法の1つは、ブロックリ
     ーダーの構築です。 例えば、バイナリのデータベースファイルから固定幅
     のブロックをファイルの終端に到達するまで読み出すには次のようにしま
     す:

          from functools import partial
          with open('mydata.db', 'rb') as f:
              for block in iter(partial(f.read, 64), b''):
                  process_block(block)

 -- の関数: len (s)

     オブジェクトの長さ (要素の数) を返します。引数はシーケンス (文字列
     、バイト列、タプル、リスト、range 等) かコレクション (辞書、集合、
     凍結集合等) です。

     'CPython 実装の詳細:' ‘len’ は、例えば *note range(2 ** 100): 911.
     のような、 *note sys.maxsize: 1195. を超える長さに対して *note
     OverflowError: 84e. を送出します。

 -- クラス: list

 -- クラス: list (iterable)

     *note list: 5dc. は、実際には関数ではなくミュータブルなシーケンス型
     で、 *note リスト型 (list): 20da. と *note シーケンス型 -- list,
     tuple, range: 1bb3. にドキュメント化されています。

 -- の関数: locals ()

          現在のローカル シンボル テーブルを表すマッピング オブジェクト
          を返します。これは変数名をキーとし、現在バインドされている参照
          を値とします。

          モジュール スコープでは、単一の名前空間で *note exec(): 164. や
          *note eval(): 165. を使う場合と同じく、この関数は *note
          globals(): 17d2. と同じ名前空間を返します。

          クラス スコープでは、メタクラス コンストラクタに渡された名前空
          間を返します。

          ‘exec()’ や ‘eval()’ が引数 local と global が分けて使われてる
          場合では、関数の呼び出しで渡されたローカル名前空間を返します。

          上記どの場合でも、特定の実行フレーム内での各 ‘locals()’ は '同
          じ' マッピング オブジェクトを返します。 ‘locals()’ から返され
          たマッピング オブジェクトを通じて行われた変更は、代入、再代入
          、または削除されたローカル変数として可視化されます。そしてロー
          カル変数の代入、再代入、または削除は、返されたマッピング オブ
          ジェクトの内容へ直ちに反映されます。

          *note optimized scope: 163. （関数、ジェネレーター、コルーチン
          を含む）では、 ‘locals()’ を呼び出すと、代わりに関数のローカル
          変数と非ローカル セル参照の現在のバインディングを含んだ新しい
          辞書を返します。この場合、返された辞書を使って行われた変更は、
          対応するローカル変数や非ローカル セル参照には '書き戻されませ
          ん' 。また、ローカル変数や非ローカル セル参照へ代入、再代入、
          削除を行っても、以前に返された辞書の内容には '影響しません' 。

          ‘locals()’ 呼び出しが関数、ジェネレータ、コルーチン内の内包表
          記内にあれば、これはそれを含むスコープから呼び出すことと同等で
          す。ただし内包表記の初期化された反復変数が含まれます。他のスコ
          ープでは、内包表記がネストされた関数として実行されているかのよ
          うに振舞います。

          ‘locals()’ 呼び出しがジェネレータ式の一部であれば、ネストされ
          たジェネレータ関数内の呼び出しと同等です。

     バージョン 3.12 で変更: 内包表記における ‘locals()’ の振る舞い は、
     PEP 709(2) で説明されているように更新されました。

     バージョン 3.13 で変更: PEP 667(3) の一部として、この関数から返され
     るマッピングオブジェクトを変更するセマンティクスが定義されました。
     *note optimized scopes: 163. の振る舞いは上記のようになりました。定
     義されただけで、その他のスコープの振る舞いは以前のバージョンのまま
     です。

 -- の関数: map (function, iterable, *iterables)

     'function' を 'iterable' の全ての要素に適用して結果を生成 (yield) す
     るイテレータを返します。追加の 'iterables' 引数が渡された場合、
     'function' は渡されたイテラブルと同じ数の引数を取らなければならず、
     関数は全てのイテラブルから並行して得られた要素の組に対して適用され
     ます。複数のイテラブルが渡された場合、そのうちで最も短いイテラブル
     が使い尽くされた段階で止まります。関数の入力が引数タプルとして単一
     のイテラブルの形で整理されている場合は、 *note itertools.starmap():
     10b5. を参照してください。

 -- の関数: max (iterable, *, key=None)

 -- の関数: max (iterable, *, default, key=None)

 -- の関数: max (arg1, arg2, *args, key=None)

     iterable の中で最大の要素、または2つ以上の引数の中で最大のものを返
     します。

     位置引数が1つだけ与えられた場合、それは空でない *note iterable:
     10ad. でなくてはいけません。その iterable の最大の要素が返されます
     。2 つ以上のキーワード無しの位置引数が与えられた場合、その位置引数
     の中で最大のものが返されます。

     任意のキーワード専用引数が 2 つあります。 'key' 引数は引数を 1 つ取
     る順序関数 (*note list.sort(): b9d. のもののように) を指定します。
     'default' 引数は与えられたイテラブルが空の場合に返すオブジェクトを
     指定します。 イテラブルが空で 'default' が与えられていない場合
     *note ValueError: 1e3. が送出されます。

     最大の要素が複数あるとき、この関数はそのうち最初に現れたものを返し
     ます。これは、‘sorted(iterable, key=keyfunc, reverse=True)[0]’ や
     ‘heapq.nlargest(1, iterable, key=keyfunc)’ のような、他のソート安定
     性を維持するツールと両立します。

     バージョン 3.4 で変更: キーワード専用引数 'default' が追加されまし
     た。

     バージョン 3.8 で変更: 'key' 引数が ‘None’ であることを許容します。

 -- クラス: memoryview (object)

     与えられたオブジェクトから作られた "メモリビュー" オブジェクトを返
     します。詳しくは *note メモリビュー: 20db. を参照してください。

 -- の関数: min (iterable, *, key=None)

 -- の関数: min (iterable, *, default, key=None)

 -- の関数: min (arg1, arg2, *args, key=None)

     iterable の中で最小の要素、または2つ以上の引数の中で最小のものを返
     します。

     位置引数が1つだけ与えられた場合、それは空でない *note iterable:
     10ad. でなくてはいけません。その iterable の最小の要素が返されます
     。2 つ以上のキーワード無しの位置引数が与えられた場合、その位置引数
     の中で最小のものが返されます。

     任意のキーワード専用引数が 2 つあります。 'key' 引数は引数を 1 つ取
     る順序関数 (*note list.sort(): b9d. のもののように) を指定します。
     'default' 引数は与えられたイテラブルが空の場合に返すオブジェクトを
     指定します。 イテラブルが空で 'default' が与えられていない場合
     *note ValueError: 1e3. が送出されます。

     最小の要素が複数あるとき、この関数はそのうち最初に現れたものを返し
     ます。これは、‘sorted(iterable, key=keyfunc)[0]’ や
     ‘heapq.nsmallest(1, iterable, key=keyfunc)’ のような、他のソート安
     定性を維持するツールと両立します。

     バージョン 3.4 で変更: キーワード専用引数 'default' が追加されまし
     た。

     バージョン 3.8 で変更: 'key' 引数が ‘None’ であることを許容します。

 -- の関数: next (iterator)

 -- の関数: next (iterator, default)

     *note iterator: 191. の *note __next__(): 129b. メソッドを呼び出す
     ことにより、次の要素を取得します。イテレータが使い尽くされた場合、
     'default' が与えられていればその値が返されます。そうでない場合は
     *note StopIteration: bc8. が送出されます。

 -- クラス: object

     This is the ultimate base class of all other classes.  It has
     methods that are common to all instances of Python classes.  When
     the constructor is called, it returns a new featureless object.
     The constructor does not accept any arguments.

          注釈: *note object: a5a. instances do 'not' have *note
          __dict__: 526. attributes, so you can't assign arbitrary
          attributes to an instance of *note object: a5a.

 -- の関数: oct (x)

     整数を先頭に "0o" が付いた 8 進文字列に変換します。 結果は Python の
     式としても使える形式になります。 'x' が Python の *note int: 238. オ
     ブジェクトでない場合、整数を返す *note __index__(): 6e8. メソッドが
     定義されていなければなりません。 例えば、次のようになります:

          >>> oct(8)
          '0o10'
          >>> oct(-56)
          '-0o70'

     整数を接頭辞 "0o" 付きや "0o" 無しの 8 進文字列に変換したい場合は、
     次に挙げる方法のいずれかを使ってください。

          >>> '%#o' % 10, '%o' % 10
          ('0o12', '12')
          >>> format(10, '#o'), format(10, 'o')
          ('0o12', '12')
          >>> f'{10:#o}', f'{10:o}'
          ('0o12', '12')

     より詳しいことは *note format(): 5eb. も参照してください。

 -- の関数: open (file, mode='r', buffering=-1, encoding=None,
          errors=None, newline=None, closefd=True, opener=None)

     'file' を開き、対応する *note ファイルオブジェクト: 1193. を返しま
     す。ファイルを開くことができなければ、*note OSError: 3f0. が送出さ
     れます。 この関数の利用例について、 *note ファイルを読み書きする:
     1be9. を参照してください。

     'file' は *note path-like object: 280. で、開くファイルのパス名 (絶
     対パスまたは現在の作業ディレクトリからの相対パス) あるいはラップす
     るファイルの整数のファイルデスクリプタを与えます。 (ファイルデスク
     リプタが与えられた場合、 'closefd' が ‘False’ に設定されていないか
     ぎり、この関数が返す I/O オブジェクトがクローズされるときにファイル
     デスクリプタもクローズされます。)

     'mode' オプション文字列はファイルが開かれる際のモードを指定します。
     デフォルトは ‘'r'’ で、読み込み用にテキストモードで開くという意味で
     す。その他によく使われるモードとして、書き込み用の ‘'w'’ (ファイル
     が既に存在する場合は上書きします) 、排他的な生成をあらわす ‘'x'’ 、
     そして追記用の ‘'a'’ ( 'いくつかの' Unix システムでは、 'すべての'
     書き込みは現在のシーク位置にかかわらずファイルの末尾に追記する、と
     いう意味です) です。テキストモードで 'encoding' が指定されない場合
     に使われるエンコーディングは、プラットフォーム依存です: 現在のロケ
     ールエンコーディングを取得するために *note locale.getencoding():
     2be. が呼ばれます。 (生のバイトデータを読み書きする際にはバイナリモ
     ードを使い、 'encoding' は指定しません。) 指定できるモードは以下の
     通りです:

     文字          意味
                   
     ----------------------------------------------------------------------------------
                   
     ‘'r'’         読み込み用に開く (デフォルト)
                   
                   
     ‘'w'’         書き込み用に開き、まずファイルを切り詰める
                   
                   
     ‘'x'’         排他的な生成に開き、ファイルが存在する場合は失敗する
                   
                   
     ‘'a'’         書き込み用に開き、ファイルが存在する場合には末尾に追記する
                   
                   
     ‘'b'’         バイナリモード
                   
                   
     ‘'t'’         テキストモード (デフォルト)
                   
                   
     ‘'+'’         更新用に開く (読み込み・書き込み用)
                   

     デフォルトのモードは ‘'r'’ (テキストの読み込み用に開く、 ‘'rt'’ と
     同義) です。 ‘'w+'’ と ‘'w+b'’ はファイルを開いて上書きします。
     ‘'r+'’ と ‘'r+b'’ はファイルを上書きせずに開きます。

     *note 概要: 20dd. で触れられているように、Python はバイナリとテキス
     トの I/O を区別します。('mode' 引数に ‘'b'’ を含めて) バイナリモー
     ドで開かれたファイルは、内容をいかなるデコーディングもせずに *note
     bytes: 1a4. オブジェクトとして返します。(デフォルトや、 'mode' 引数
     に ‘'t'’ が含まれたときの) テキストモードでは、ファイルの内容は
     *note str: 418. として返され、バイト列はまず、プラットフォーム依存
     のエンコーディングか、'encoding' が指定された場合は指定されたエンコ
     ーディングを使ってデコードされます。

          注釈: Python は、下層のオペレーティングシステムがテキストファ
          イルをどう認識するかには依存しません; すべての処理は Python 自
          身で行われ、よってプラットフォーム非依存です。

     'buffering' はオプションの整数で、バッファリングのポリシーを設定す
     るために使われます。 バッファリングを無効化するためには0を渡してく
     ださい (バイナリモードでのみ設定可能です)。また行単位でのバッファリ
     ングには1を設定してください (テキストモードでの書き込み時のみ有効で
     す)。固定サイズのチャンクバッファに対するサイズをバイト単位で指定し
     たい場合は、1より大きい整数を渡してください。この形式でバッファサイ
     ズを指定した場合、バイナリ形式でバッファリングをサポートする I/O
     (buffered I/O) にはそのまま適用されますが、 ‘TextIOWrapper’ (すなわ
     ち ‘mode='r+'’ のモードでオープンされたファイル) では別のバッファリ
     ングを行うかもしれません。 ‘TextIOWrapper’ でバッファリングを無効化
     するには、 *note io.TextIOWrapper.reconfigure(): b17. で
     ‘write_through’ フラグを使うことを検討してください。 'buffering' 引
     数が与えられなかった場合、デフォルトのバッファリングポリシーは以下
     のように動作します:

        * バイナリファイルは固定サイズのチャンクでバッファリングされます
          。バッファサイズは、下層のデバイスの「ブロックサイズ」を決定す
          るヒューリスティックを用いて選択され、それが不可能な場合は代わ
          りに *note io.DEFAULT_BUFFER_SIZE: 162d. が使われます。多くの
          システムでは、バッファサイズは通常 4096 か 8192 バイト長です。

        * 「対話的な」テキストファイル (*note isatty(): 1bec. が ‘True’
          を返すファイル) は行バッファリングを使用します。 その他のテキ
          ストファイルは、上で説明したバイナリファイル用の方針を使用しま
          す。

     'encoding' はファイルのエンコードやデコードに使われる *note text
     encoding: 20de. の名前です。このオプションはテキストモードでのみ使
     用してください。デフォルトエンコーディングはプラットフォーム依存
     (*note locale.getencoding(): 2be. が返すもの) ですが、Pythonでサポ
     ートされているエンコーディングはどれでも使えます。詳しくは *note
     codecs: 14. モジュール内のサポートしているエンコーディングのリスト
     を参照してください。

     'errors' はオプションの文字列で、エンコードやデコードでのエラーをど
     のように扱うかを指定するものです。バイナリモードでは使用できません
     。様々な標準のエラーハンドラが使用可能です (*note エラーハンドラ:
     1751. に列記されています) が、 *note codecs.register_error(): 143e.
     に登録されているエラー処理の名前も使用可能です。標準のエラーハンド
     ラの名前には、以下のようなものがあります:

        * ‘'strict'’ はエンコーディングエラーがあると例外 *note
          ValueError: 1e3. を発生させます。デフォルト値である ‘None’ も
          同じ効果です。

        * ‘'ignore'’ はエラーを無視します。エンコーディングエラーを無視
          することで、データが失われる可能性があることに注意してください
          。

        * ‘'replace'’ は、不正な形式のデータが存在した場所に(‘'?'’ のよ
          うな) 置換マーカーを挿入します。

        * ‘'surrogateescape'’ は正しくないバイト列をユニコードの下位サロ
          ゲート領域のうち U+DC80 から U+DCFF の範囲のコードユニットであ
          らわします。データの書き込み時に ‘surrogateescape’ エラーハン
          ドラが使われると、これらのサロゲートコードユニットは元と同じバ
          イト列に変換されます。これはエンコーディングが不明なファイルを
          処理するのに便利です。

        * ‘'xmlcharrefreplace'’ はファイルへの書き込み時のみサポートされ
          ます。そのエンコーディングでサポートされない文字は、‘&#NNN;’ 形
          式の適切な XML 文字参照で置換されます。

        * ‘'backslashreplace'’ は不正なデータを Python のバックスラッシ
          ュ付きのエスケープシーケンスで置換します。

        * ‘'namereplace'’ (書き込み時のみサポートされています) はサポー
          トされていない文字を ‘\N{...}’ エスケープシーケンスで置換しま
          す。

     'newline' はストリームから受け取った改行文字をどのようにパースする
     かを決定します。 ‘None’, ‘''’, ‘'\n'’, ‘'\r'’, または ‘'\r\n'’ のい
     ずれかを指定できます。これは以下のように動作します:

        * ストリームからの入力の読み込み時、'newline' が ‘None’ の場合、
          ユニバーサル改行モードが有効になります。入力中の行は ‘'\n'’,
          ‘'\r'’, または ‘'\r\n'’ で終わり、呼び出し元に返される前に
          ‘'\n'’ に変換されます。 ‘''’ の場合、ユニバーサル改行モードは
          有効になりますが、行末は変換されずに呼び出し元に返されます。そ
          の他の正当な値の場合、入力行は与えられた文字列でのみ終わり、行
          末は変換されずに呼び出し元に返されます。

        * ストリームへの出力の書き込み時、'newline' が ‘None’ の場合、全
          ての ‘'\n'’ 文字はシステムのデフォルトの行セパレータ *note
          os.linesep: 20df. に変換されます。 'newline' が ‘''’ または
          ‘'\n'’ の場合は変換されません。'newline' がその他の正当な値の
          場合、全ての ‘'\n'’ 文字は与えられた文字列に変換されます。

     'closefd' が ‘False’ で、ファイル名ではなくてファイル記述子が与えら
     れた場合、下層のファイル記述子はファイルが閉じられた後も開いたまま
     となります。 ファイル名が与えられた場合、'closefd' は ‘True’ (デフ
     ォルト値) でなければなりません。 そうでない場合エラーが送出されます
     。

     呼び出し可能オブジェクトを 'opener' として与えることで、カスタムの
     オープナーが使えます。そしてファイルオブジェクトの下層のファイル記
     述子は、'opener' を ('file', 'flags') で呼び出して得られます。
     'opener' は開いたファイル記述子を返さなければなりません。 (*note
     os.open: d5f. を 'opener' として渡すと、‘None’ を渡したのと同様の機
     能になります)。

     新たに作成されたファイルは *note 継承不可: ec4. です。

     次の例は *note os.open(): d5f. 関数の *note dir_fd: 10c8. 引数を使
     い、与えられたディレクトリからの相対パスで指定されたファイルを開き
     ます:

          >>> import os
          >>> dir_fd = os.open('somedir', os.O_RDONLY)
          >>> def opener(path, flags):
          ...     return os.open(path, flags, dir_fd=dir_fd)
          ...
          >>> with open('spamspam.txt', 'w', opener=opener) as f:
          ...     print('This will be written to somedir/spamspam.txt', file=f)
          ...
          >>> os.close(dir_fd)  # ファイル記述子の解放漏れがないように

     *note open(): 4e5. 関数が返す *note file object: 1193. の型はモード
     に依存します。 *note open(): 4e5. をファイルをテキストモード
     (‘'w'’, ‘'r'’, ‘'wt'’, ‘'rt'’, など) で開くのに使ったときは *note
     io.TextIOBase: 661. (特に *note io.TextIOWrapper: 786.) のサブクラ
     スを返します。 ファイルをバッファリング付きのバイナリモードで開くの
     に使ったときは *note io.BufferedIOBase: 660. のサブクラスを返します
     。 実際のクラスは様々です。 読み込みバイナリモードでは *note
     io.BufferedReader: 11df. を返します。 書き込みバイナリモードや追記
     バイナリモードでは *note io.BufferedWriter: 20e0. を返します。 読み
     書きモードでは *note io.BufferedRandom: 20e1. を返します。 バッファ
     リングが無効なときはrawストリーム、すなわち *note io.RawIOBase:
     10a3. のサブクラスである *note io.FileIO: 12df. を返します。

     *note fileinput: 51. 、(*note open(): 4e5. が宣言された場所である)
     *note io: 73. 、 *note os: 91. 、 *note os.path: 92. 、 *note
     tempfile: c9. 、 *note shutil: b3. などの、ファイル操作モジュールも
     参照してください。

     引数 ‘path’, ‘mode’, ‘flags’ を指定して *note 監査イベント: 1825.
     ‘open’ を送出します。

     ‘mode’ と ‘flags’ の2つの引数は呼び出し時の値から修正されたり、推量
     により設定されたりする可能性があります。

     バージョン 3.3 で変更:

        * 'opener' 引数を追加しました。

        * ‘'x'’ モードを追加しました。

        * 以前は *note IOError: 1026. が送出されました; それは現在 *note
          OSError: 3f0. のエイリアスです。

        * 既存のファイルを 排他的生成モード(‘'x'’)で開いた場合、 *note
          FileExistsError: fea. を送出するようになりました。

     バージョン 3.4 で変更:

        * ファイルが継承不可になりました。

     バージョン 3.5 で変更:

        * システムコールが中断されシグナルハンドラが例外を送出しなかった
          場合、この関数は *note InterruptedError: d55. 例外を送出する代
          わりにシステムコールを再試行するようになりました (論拠について
          は PEP 475(4) を参照してください)。

        * ‘'namereplace'’ エラーハンドラが追加されました。

     バージョン 3.6 で変更:

        * *note os.PathLike: c1f. を実装したオブジェクトを受け入れるよう
          になりました。

        * Windowsでは、コンソールバッファのオープンは、*note io.FileIO:
          12df. ではなく、*note io.RawIOBase: 10a3. のサブクラスを返すで
          しょう。

     バージョン 3.11 で変更: ‘'U'’ モードは削除されました。

 -- の関数: ord (c)

     1 文字の Unicode 文字を表す文字列に対し、その文字の Unicode コード
     ポイントを表す整数を返します。例えば、 ‘ord('a')’ は整数 ‘97’ を返
     し、 ‘ord('€')’ (ユーロ記号) は ‘8364’ を返します。これは *note
     chr(): 15d6. の逆です。

 -- の関数: pow (base, exp, mod=None)

     'base' の 'exp' 乗を返します; 'mod' があれば、'base' の 'exp' 乗に
     対する 'mod' の剰余を返します (‘pow(base, exp) % mod’ より効率よく
     計算されます)。二引数の形式 ‘pow(base, exp)’ は、冪乗演算子を使った
     ‘base**exp’ と等価です。

     引数は数値型でなければなりません。型混合の場合、二項算術演算におけ
     る型強制規則が適用されます。 *note int: 238. オペランドの場合、第
     2引数が負でない限り、結果は (型強制後の) オペランドと同じ型になりま
     す; 第2引数が負の場合、全ての引数は浮動小数点数に変換され、浮動小数
     点数の結果が返されます。例えば、 ‘pow(10, 2)’ は ‘100’ を返しますが
     、 ‘pow(10, -2)’ は ‘0.01’ を返します。底が *note int: 238. 型また
     は *note float: 2ce. 型で負の値であり、かつ指数が整数でない場合、複
     素数の結果が返されます。例えば、 ‘pow(-9, 0.5)’ は ‘3j’ に近い値を
     返します。一方で底が *note int: 238. 型または *note float: 2ce. の
     負の数であり、指数が整数の場合、浮動小数点数の結果が返されます。例
     えば、‘pow(-9, 2.0)’ は ‘81.0’ を返します。

     'base' と 'exp' が *note int: 238. オペランドで 'mod' が存在すると
     き、 'mod' もまた整数型でなければならず、かつゼロであってはいけませ
     ん。 'mod' が存在して 'exp' が負の整数の場合、 'base' は 'mod' と互
     いに素 (最大公約数が1) でなければなりません。この場合、 'inv_base'
     を 'base' に対する 'mod' を法とするモジュラ逆数 ('base' と
     'inv_base' の積を 'mod' で割った余りが1になるような数) として、
     ‘pow(inv_base, -exp, mod)’ が返されます。

     以下は ‘97’ を法とする ‘38’ のモジュラ逆数の計算例です:

          >>> pow(38, -1, mod=97)
          23
          >>> 23 * 38 % 97 == 1
          True

     バージョン 3.8 で変更: *note int: 238. オペランドに対して、三引数形
     式の ‘pow’ で第二引数に負の値を取ることができるようになりました。こ
     れによりモジュラ逆数の計算が可能になります。

     バージョン 3.8 で変更: キーワード引数を取ることができるようになりま
     した。以前は位置引数だけがサポートされていました。

 -- の関数: print (*objects, sep=' ', end='\n', file=None, flush=False)

     'objects' を 'sep' で区切りながらテキストストリーム 'file' に表示し
     、最後に 'end' を表示します。'sep' 、 'end' 、 'file' 、 'flush' を
     与える場合、キーワード引数として与える必要があります。

     キーワードなしの引数はすべて、 *note str(): 418. がするように文字列
     に変換され、 'sep' で区切られながらストリームに書き出され、最後に
     'end' が続きます。 'sep' と 'end' の両方とも、文字列でなければなり
     ません。これらを ‘None’ にすると、デフォルトの値が使われます。
     'objects' が与えられなければ、 *note print(): f42. は 'end' だけを
     書き出します。

     'file' 引数は、 ‘write(string)’ メソッドを持つオブジェクトでなけれ
     ばなりません。指定されないか、 ‘None’ である場合、 *note
     sys.stdout: aa4. が使われます。表示される引数は全てテキスト文字列に
     変換されますから、 *note print(): f42. はバイナリモードファイルオブ
     ジェクトには使用できません。代わりに ‘file.write(...)’ を使ってくだ
     さい。

     出力がバッファ化されるかどうかは通常 'file' で決まりますが、'flush'
     キーワード引数が真ならストリームは強制的にフラッシュされます。

     バージョン 3.3 で変更: キーワード引数 'flush' が追加されました。

 -- クラス: property (fget=None, fset=None, fdel=None, doc=None)

     property 属性を返します。

     'fget' は属性値を取得するための関数です。'fset' は属性値を設定する
     ための関数です。'fdel' は属性値を削除するための関数です。'doc' は属
     性の docstring を作成します。

     典型的な使用法は、属性 ‘x’ の処理の定義です:

          class C:
              def __init__(self):
                  self._x = None

              def getx(self):
                  return self._x

              def setx(self, value):
                  self._x = value

              def delx(self):
                  del self._x

              x = property(getx, setx, delx, "I'm the 'x' property.")

     'c' が 'C' のインスタンスならば、‘c.x’ は getter を呼び出し、‘c.x =
     value’ は setter を、‘del c.x’ は deleter を呼び出します。

     'doc' は、与えられれば property 属性のドキュメント文字列になります
     。 与えられなければ、 property は 'fget' のドキュメント文字列 (もし
     あれば) をコピーします。 そのため *note property(): 179. を *note
     デコレータ: 6fc. として使えば、読み出し専用 property を作るのは容易
     です:

          class Parrot:
              def __init__(self):
                  self._voltage = 100000

              @property
              def voltage(self):
                  """Get the current voltage."""
                  return self._voltage

     ‘@property’ デコレータは ‘voltage()’ を同じ名前のまま 読み出し専用
     属性の "getter" にし、'voltage' のドキュメント文字列を "Get the
     current voltage."  に設定します。

      -- の関数: @getter

      -- の関数: @setter

      -- の関数: @deleter

          property オブジェクトは ‘getter’, ‘setter’, ‘deleter’ メソッド
          を持っています。これらのメソッドをデコレータとして使うと、対応
          するアクセサ関数がデコレートされた関数に設定された、 property
          のコピーを作成できます。 これを一番分かりやすく説明する例があ
          ります:

               class C:
                   def __init__(self):
                       self._x = None

                   @property
                   def x(self):
                       """I'm the 'x' property."""
                       return self._x

                   @x.setter
                   def x(self, value):
                       self._x = value

                   @x.deleter
                   def x(self):
                       del self._x

          このコードは最初の例と等価です。追加の関数には、必ず元の
          property と同じ名前 (この例では ‘x’) を与えて下さい。

          返される property オブジェクトも、コンストラクタの引数に対応し
          た ‘fget’, ‘fset’, および ‘fdel’ 属性を持ちます。

     バージョン 3.5 で変更: 属性オブジェクトのドックストリングが書き込み
     可能になりました。

      -- の属性: __name__

          プロパティ名を保持する属性。プロパティ名は実行時に変更できます
          。

          Added in version 3.13.

 -- クラス: range (stop)

 -- クラス: range (start, stop, step=1)

     *note range: 911. は、実際には関数ではなくイミュータブルなシーケン
     ス型で、 *note range: 20e2. と *note シーケンス型 -- list, tuple,
     range: 1bb3. にドキュメント化されています。

 -- の関数: repr (object)

     オブジェクトの印字可能な表現を含む文字列を返します。この関数は多く
     の型について、 *note eval(): 165. に渡されたときと同じ値を持つよう
     なオブジェクトを表す文字列を生成しようとします。そうでない場合は、
     山括弧に囲まれたオブジェクトの型の名前と追加の情報 (大抵の場合はオ
     ブジェクトの名前とアドレスを含みます) を返します。クラスは、 *note
     __repr__(): 5e8. メソッドを定義することで、この関数によりそのクラス
     のインスタンスが返すものを制御することができます。*note
     sys.displayhook(): 14c9. にアクセスできない場合、この関数は *note
     RuntimeError: 17a. を送出します。

     このクラスは、eval 評価可能な独自の representation を持ちます:

          class Person:
             def __init__(self, name, age):
                self.name = name
                self.age = age

             def __repr__(self):
                return f"Person('{self.name}', {self.age})"

 -- の関数: reversed (seq)

     要素を逆順に取り出すイテレータ (reverse *note iterator: 191.) を返
     します。 'seq' は *note __reversed__(): 1ebd. メソッドを持つか、シ
     ーケンス型プロトコル ( *note __len__(): 1ec3. メソッド、および、
     ‘0’ 以上の整数を引数とする *note __getitem__(): 264. メソッド) をサ
     ポートするオブジェクトでなければなりません。

 -- の関数: round (number, ndigits=None)

     'number' を小数点以下 'ndigits' 桁の精度で丸めた値を返します。
     'ndigits' が省略されたり、‘None’ だった場合、入力値に最も近い整数を
     返します。

     *note round(): 12a8. をサポートする組み込み型では、値は 10 のマイナ
     ス 'ndigits' 乗の倍数の中で最も近いものに丸められます; 二つの倍数が
     同じだけ近いなら、偶数を選ぶ方に (そのため、例えば ‘round(0.5)’ と
     ‘round(-0.5)’ は両方とも ‘0’ に、 ‘round(1.5)’ は ‘2’ に) 丸められ
     ます。 'ndigits' には任意の整数値が有効となります (正の整数、ゼロ、
     負の整数)。 返り値は 'ndigits' が指定されていないか ‘None’ の場合は
     整数、そうでなければ返り値は 'number' と同じ型です。

     一般的な Python オブジェクト ‘number’ に対して、‘round’ は処理を
     ‘number.__round__’ に移譲します。

          注釈: 浮動小数点数に対する *note round(): 12a8. の振る舞いは意
          外なものかもしれません: 例えば、 ‘round(2.675, 2)’ は予想通り
          の ‘2.68’ ではなく ‘2.67’ を与えます。これはバグではありません
          : これはほとんどの小数が浮動小数点数で正確に表せないことの結果
          です。詳しくは *note 浮動小数点演算、その問題と制限: 1c7b. を
          参照してください。

 -- クラス: set

 -- クラス: set (iterable)

     オプションで 'iterable' の要素を持つ、新しい *note set: 5a3. オブジ
     ェクトを返します。 ‘set’ は組み込みクラスです。このクラスについて詳
     しい情報は *note set: 5a3. や *note set（集合）型 -- set,
     frozenset: 20d7. を参照してください。

     他のコンテナについては *note collections: 16. モジュールや組み込み
     の *note frozenset: 5a4. 、 *note list: 5dc. 、 *note tuple: 349. 、
     *note dict: 237. クラスを参照してください。

 -- の関数: setattr (object, name, value)

     *note getattr(): b9f. の相方です。引数はオブジェクト、文字列、それ
     から任意の値です。文字列は既存の属性または新たな属性の名前にできま
     す。この関数は指定したオブジェクトが許せば、値を属性に関連付けます
     。例えば、 ‘setattr(x, 'foobar', 123)’ は ‘x.foobar = 123’ と等価で
     す。

     *note __getattribute__(): ba0. のカスタマイズや *note __slots__:
     1493. を通じてオブジェクトが強制していない限り、 'name' は *note
     識別子 (identifier) およびキーワード (keyword): 1df6. で定義されて
     いる Python 識別子である必要はありません。属性名が識別子でない場合
     、ドットを使った属性へのアクセスはできませんが、 *note getattr():
     b9f. などを通じてアクセス可能です。

          注釈: *note プライベートな名前のマングリング: 1c24. はコンパイ
          ル時に行われます。そのため、プライベートな属性 (先頭に2つのア
          ンダースコアを伴う名前を持つ属性) の値を *note setattr():
          20bd. でセットするためには、属性名を手動でマングリングする必要
          があります。

 -- クラス: slice (stop)

 -- クラス: slice (start, stop, step=None)

     ‘range(start, stop, step)’ で指定されたインデックスのセットを表す
     *note slice: 20e3. オブジェクトを返します。 引数 'start' と 'step'
     のデフォルトは ‘None’ です。

      -- の属性: start

      -- の属性: stop

      -- の属性: step

          スライスオブジェクトには読み出し専用のデータ属性 ‘start’
          ‘stop’ ‘step’ があり、これらは単に引数の値（またはそのデフォル
          ト値）を返します。 スライスオブジェクトは特に他の機能を持ちま
          せんが、 NumPy や他のサードパーティパッケージで使われています
          。

     スライスオブジェクトは、拡張インデックス構文が使われた場合にも作ら
     れます。 例： ‘a[start:stop:step]’ や ‘a[start:stop, i]’ 。 *note
     iterator: 191. を返す代替バージョンについては *note
     itertools.islice(): b1a. を参照して下さい。

     バージョン 3.12 で変更: スライスオブジェクトが *note hashable: 5db.
     (ハッシュ可能) となりました (ただし、属性 *note start: 1eb6. 、
     *note stop: 1eb7. 、 *note step: 1eb8. がすべてハッシュ可能である場
     合に限ります)。

 -- の関数: sorted (iterable, /, *, key=None, reverse=False)

     'iterable' の要素を並べ替えた新たなリストを返します。

     2 つのオプション引数があり、これらはキーワード引数として指定されな
     ければなりません。

     'key' には 1 引数関数を指定します。これは 'iterable' の各要素から比
     較キーを展開するのに使われます (例えば、 ‘key=str.lower’ のように指
     定します)。 デフォルト値は ‘None’ です (要素を直接比較します)。

     'reverse' は真偽値です。 ‘True’ がセットされた場合、リストの要素は
     個々の比較が反転したものとして並び替えられます。

     旧式の 'cmp' 関数を 'key' 関数に変換するには *note
     functools.cmp_to_key(): 11aa. を使用してください。

     組み込みの *note sorted(): b9c. 関数は安定なことが保証されています
     。同等な要素の相対順序を変更しないことが保証されていれば、ソートは
     安定です。これは複数のパスでソートを行なうのに役立ちます（例えば部
     署でソートしてから給与の等級でソートする場合）。

     ソートアルゴリズムは、要素間の比較に ‘<’ 演算子だけを使います。した
     がってソートのためには *note __lt__(): 12d9. メソッドを定義すれば十
     分なはずですが、 PEP 8(5) は6つの *note 比較演算子: 1fd1. を全て実
     装することを推奨しています。これにより、異なるメソッドを必要とする
     *note max(): ed4. のような他のソートツールを、同じデータに対して適
     用することによって起こりうるバグを避ける助けになります。6つの比較演
     算子を全て実装することは、リフレクションによって *note __gt__():
     12db. メソッドを呼び出す可能性のある型混合の比較での混乱を避けるこ
     とにも役立ちます。

     ソートの例と簡単なチュートリアルは *note ソートのテクニック: 11ab.
     を参照して下さい。

 -- の関数: @staticmethod

     メソッドを静的メソッドへ変換します。

     静的メソッドは暗黙の第一引数を受け取りません。静的メソッドを宣言す
     るには、このイディオムを使ってください:

          class C:
              @staticmethod
              def f(arg1, arg2, argN): ...

     ‘@staticmethod’ 形式は関数 *note デコレータ: 6fc. です。詳しくは
     *note 関数定義: 1ba0. を参照してください。

     静的メソッドは (‘C.f()’ のように) クラスに対して呼び出すことも、
     (‘C().f()’ のように) インスタンスに対して呼び出すこともできます。さ
     らに、静的メソッド *note descriptor: 1ed1. は呼び出し可能でもあるた
     め、(‘f()’ のように) クラス定義の中でも使用できます。

     Python における静的メソッドは Java や C++ における静的メソッドと類
     似しています。クラスコンストラクタの代替を生成するのに役立つ変種、
     *note classmethod(): 14c. も参照してください。

     あらゆるデコレータと同じく、 ‘staticmethod’ は普通の関数のように呼
     べ、その返り値で処理が行えます。 この機能は、クラス本体から関数を参
     照する必要があり、かつ、インスタンスメソッドに自動変換されるのを避
     けたいケースで必要になります。 そのようなケースでは、このイディオム
     が使えます:

          def regular_function():
              ...

          class C:
              method = staticmethod(regular_function)

     静的メソッドについて詳しい情報は *note 標準型の階層: 1e46. を参照し
     てください。

     バージョン 3.10 で変更: Static methods now inherit the method
     attributes (*note __module__: 1e5d, *note __name__: 12a2, *note
     __qualname__: 1e5c, *note __doc__: 11a9. and *note __annotations__:
     11a8.), have a new ‘__wrapped__’ attribute, and are now callable as
     regular functions.

 -- クラス: str (object='')

 -- クラス: str (object=b'', encoding='utf-8', errors='strict')

     'object' の *note str: 418. 版を返します。詳細は *note str(): 418.
     を参照してください。

     ‘str’ は組み込みの文字列 *note クラス: 189c. です。文字列に関する一
     般的な情報は、*note テキストシーケンス型 -- str: 1b67. を参照してく
     ださい。

 -- の関数: sum (iterable, /, start=0)

     'start' と 'iterable' の要素を左から右へ合計し、総和を返します。
     'iterable' の要素は通常は数値で、start の値は文字列であってはなりま
     せん。

     使う場面によっては、 *note sum(): 437. よりもいい選択肢があります。
     文字列からなるシーケンスを結合する高速かつ望ましい方法は
     ‘''.join(sequence)’ を呼ぶことです。浮動小数点数値を拡張された精度
     で加算するには、 *note math.fsum(): 137c. を参照してください。一連
     のイテラブルを連結するには、 *note itertools.chain(): 20e4. の使用
     を考えてください。

     バージョン 3.8 で変更: 'start' パラメータをキーワード引数として指定
     することができるようになりました。

     バージョン 3.12 で変更: 浮動小数点数の総和を計算するとき、ほとんど
     の環境でより高精度な結果とより良い互換性が得られるアルゴリズムを使
     用するようになりました。

 -- クラス: super

 -- クラス: super (type, object_or_type=None)

     メソッドの呼び出しを 'type' の親または兄弟クラスに委譲するプロキシ
     オブジェクトを返します。これはクラスの中でオーバーライドされた継承
     メソッドにアクセスするのに便利です。

     'object_or_type' はメソッドの検索のための *note method resolution
     order: 20e5. (メソッド解決順序) を決定します。検索は 'type' 直後の
     クラスから開始します。

     For example, if *note __mro__: 1e89. of 'object_or_type' is ‘D -> B
     -> C -> A -> object’ and the value of 'type' is ‘B’, then *note
     super(): 4a8. searches ‘C -> A -> object’.

     The *note __mro__: 1e89. attribute of the class corresponding to
     'object_or_type' lists the method resolution search order used by
     both *note getattr(): b9f. and *note super(): 4a8.  The attribute
     is dynamic and can change whenever the inheritance hierarchy is
     updated.

     第 2 引数が省かれたなら、返されるスーパーオブジェクトは束縛されませ
     ん。第 2 引数がオブジェクトであれば、 ‘isinstance(obj, type)’ は真
     でなければなりません。第 2 引数が型であれば、 ‘issubclass(type2,
     type)’ は真でなければなりません (これはクラスメソッドに役に立つでし
     ょう)。

     クラスの通常のメソッド中で直接呼び出される場合、どちらの引数も省け
     ます (「ゼロ引数 ‘super()’ 」) 。この場合、 'type' はその囲んでいる
     クラスとなり、 'obj' は直接囲んでいる関数の第一引数 (通常は ‘self’
     ) となります。 (つまり、ゼロ引数 ‘super()’ は、ネストされた関数では
     期待どおりに動作しません。これには 暗にネストされた関数を作るジェネ
     レータ式も含まれます)

     'super' の典型的な用途は 2 つあります。第一に、単継承のクラス階層構
     造で 'super' は名前を明示することなく親クラスを参照するのに使え、そ
     れゆえコードをメンテナンスしやすくなります。この用途は他のプログラ
     ミング言語で見られる 'super' の用途によく似ています。

     2つ目の用途は動的な実行環境において協調的 (cooperative) な多重継承
     をサポートすることです。これは Python に特有の用途で、静的にコンパ
     イルされる言語や、単継承のみをサポートする言語には見られないもので
     す。この機能により、同じ名前のメソッドを実装する複数の基底クラスを
     使った "ダイヤモンド型* の継承構造を実装することができます。良い設
     計は、そのような実装において、どのような場合でも同じ呼び出しシグネ
     チャを持つように強制します。 (理由は呼び出しの順序が実行時に決定さ
     れること、呼び出し順序はクラス階層構造の変化に順応すること、そして
     呼び出し順序が実行時まで未知の兄弟クラスが含まれる場合があることで
     す)。

     両方の用途において、典型的なスーパークラスの呼び出しは次のようにな
     ります:

          class C(B):
              def method(self, arg):
                  super().method(arg)    # これは次と同じことを行います:
                                         # super(C, self).method(arg)

     メソッドのルックアップに加えて、 *note super(): 4a8. は属性のルック
     アップに対しても同様に動作します。考えうる用途のひとつは親クラスや
     兄弟クラスの *note descriptors: 1ed1. (デスクリプタ) を呼び出すこと
     です。

     なお、*note super(): 4a8. は ‘super().__getitem__(name)’ のような明
     示的なドット表記属性探索の束縛処理の一部として実装されています。こ
     れは、 *note __getattribute__(): ba0. メソッドを予測可能な順序でク
     ラスを検索するように実装し、協調的な多重継承をサポートすることで実
     現されています。従って、 *note super(): 4a8. は文や ‘super()[name]’
     のような演算子を使った暗黙の探索向けには定義されていません。

     また、 *note super(): 4a8. の使用は引数無しの形式を除きメソッド内部
     に限定されないことにも注目して下さい。2引数の形式は、必要な要素を正
     確に指定するので、適当な参照を作ることができます。クラス定義中にお
     ける引数無しの形式は、定義されているクラスを取り出すのに必要な詳細
     を、通常の方法で現在のインスタンスにアクセスするようにコンパイラが
     埋めるのではたらきます。

     *note super(): 4a8. を用いて協調的なクラスを設計する方法の実践的な
     提案は、 guide to using super()(6) を参照してください。

 -- クラス: tuple

 -- クラス: tuple (iterable)

     *note tuple: 349. は、実際は関数ではなくイミュータブルなシーケンス
     型で、*note タプル型 (tuple): 2046. と *note シーケンス型 -- list,
     tuple, range: 1bb3. にドキュメント化されています。

 -- クラス: type (object)

 -- クラス: type (name, bases, dict, **kwds)

     With one argument, return the type of an 'object'.  The return
     value is a type object and generally the same object as returned by
     *note object.__class__: 1452.

     オブジェクトの型の判定には、 *note isinstance(): 40e. 組み込み関数
     を使うことが推奨されます。これはサブクラスを考慮するからです。

     With three arguments, return a new type object.  This is
     essentially a dynamic form of the *note class: 12a5. statement.
     The 'name' string is the class name and becomes the *note __name__:
     1450. attribute.  The 'bases' tuple contains the base classes and
     becomes the *note __bases__: 1451. attribute; if empty, *note
     object: a5a, the ultimate base of all classes, is added.  The
     'dict' dictionary contains attribute and method definitions for the
     class body; it may be copied or wrapped before becoming the *note
     __dict__: c2b. attribute.  The following two statements create
     identical ‘type’ objects:

          >>> class X:
          ...     a = 1
          ...
          >>> X = type('X', (), dict(a=1))

     See also:

        * *note Documentation on attributes and methods on classes:
          1e83.

        * *note 型オブジェクト: 20e6.

     三引数形式の呼び出しに与えられたキーワード引数は、('metaclass' を除
     く) クラス定義におけるキーワード引数と同様に、適切なメタクラスの機
     構 (通常は *note __init_subclass__(): 5fd.) に渡されます。

     *note クラス生成をカスタマイズする: c19. も参照してください。

     バージョン 3.6 で変更: Subclasses of ‘type’ which don't override
     ‘type.__new__’ may no longer use the one-argument form to get the
     type of an object.

 -- の関数: vars ()

 -- の関数: vars (object)

     Return the *note __dict__: 526. attribute for a module, class,
     instance, or any other object with a ‘__dict__’ attribute.

     Objects such as modules and instances have an updateable *note
     __dict__: 526. attribute; however, other objects may have write
     restrictions on their ‘__dict__’ attributes (for example, classes
     use a *note types.MappingProxyType: 43a. to prevent direct
     dictionary updates).

     引数がない場合 *note vars(): 19ad. は *note locals(): 127. のように
     動作します。

     指定されたオブジェクトに *note __dict__: 526. 属性がない場合 (たと
     えばそのクラスが *note __slots__: 1493. 属性を定義している場合)、
     *note TypeError: 502. 例外が送出されます。

     バージョン 3.13 で変更: この関数を引数なしで呼び出したときの返り値
     は、 *note locals(): 127. 組み込み関数での説明に更新されました。

 -- の関数: zip (*iterables, strict=False)

     複数のイテラブルを並行に反復処理し、各イテラブルの要素からなるタプ
     ルを生成します。

     以下はプログラム例です:

          >>> for item in zip([1, 2, 3], ['sugar', 'spice', 'everything nice']):
          ...     print(item)
          ...
          (1, 'sugar')
          (2, 'spice')
          (3, 'everything nice')

     より正式な定義: *note zip(): 79b. は、 'i' 番目のタプルが 引数に与
     えた各イテラブルの 'i' 番目の要素を含むような、タプルのイテレータを
     返します。

     *note zip(): 79b. に対する別の考え方は、この関数は行を列に、また列
     を行に変換するということです。これは 行列の転置(7) とよく似ています
     。

     *note zip(): 79b. は遅延評価です: イテラブルが ‘for’ ループに渡され
     たり、 *note list: 5dc. でラップされたりするなどして反復処理される
     まで、要素が実際に処理されることはありません。

     ここで考慮すべきことは、 *note zip(): 79b. に渡されるイテラブルが異
     なる長さを持つことがあるという点です; ときには意図的な場合もあり、
     またときにはイテラブルを準備するコードにおけるバグのこともあるでし
     ょう。 Python はこの問題に対して3つの異なるアプローチを提供します:

        * デフォルトでは、 *note zip(): 79b. は最も短いイテラブルが消費
          しきった時点で停止します。より繰り返し数の長いイテラブルの残り
          の要素は無視して、結果を最も短いイテラブルの長さに切り詰めます
          :

               >>> list(zip(range(3), ['fee', 'fi', 'fo', 'fum']))
               [(0, 'fee'), (1, 'fi'), (2, 'fo')]

        * *note zip(): 79b. は、しばしば受け取ったイテラブルが全て同じ長
          さであるという想定の下で使われます。そのような場合、
          ‘strict=True’ オプションの利用が推奨されます。その出力は通常の
          *note zip(): 79b. と同じです:

               >>> list(zip(('a', 'b', 'c'), (1, 2, 3), strict=True))
               [('a', 1), ('b', 2), ('c', 3)]

          しかし、デフォルトの動作と異なり、あるイテラブルが他のイテラブ
          ルよりも先に消費しきった場合に *note ValueError: 1e3. 例外を送
          出します:

               >>> for item in zip(range(3), ['fee', 'fi', 'fo', 'fum'], strict=True):
               ...     print(item)
               ...
               (0, 'fee')
               (1, 'fi')
               (2, 'fo')
               Traceback (most recent call last):
                 ...
               ValueError: zip() argument 2 is longer than argument 1

          ‘strict=True’ 引数なしの場合、長さの異なるイテラブルを生じる原
          因となるいかなるバグも、この時点では問題なく処理されます。そし
          て代わりにプログラムの別の場所で、原因を特定しにくいバグとして
          検出されることになるでしょう。

        * 短いイテラブルを一定の値でパディングして全てのイテラブルが同じ
          長さになるようにすることもできます。この機能は *note
          itertools.zip_longest(): 126e. で提供されます。

     エッジケース: 引数としてイテラブルをひとつだけ渡した場合、 *note
     zip(): 79b. は 1 タプルのイテレータを返します。引数なしの場合は空の
     イテレータを返します。

     ヒントとコツ:

        * イテラブルの左から右への評価順序は保証されています。そのため
          ‘zip(*[iter(s)]*n, strict=True)’ を使ってデータ系列を長さ n の
          グループにクラスタリングするイディオムが使えます。これは、各出
          力タプルがイテレータを ‘n’ 回呼び出した結果となるよう、 '同じ'
          イテレータを ‘n’ 回繰り返します。これは入力を長さ n のチャンク
          に分割する効果があります。

        * *note zip(): 79b. に続けて ‘*’ 演算子を使うと、zip したリスト
          を元に戻せます:

               >>> x = [1, 2, 3]
               >>> y = [4, 5, 6]
               >>> list(zip(x, y))
               [(1, 4), (2, 5), (3, 6)]
               >>> x2, y2 = zip(*zip(x, y))
               >>> x == list(x2) and y == list(y2)
               True

     バージョン 3.10 で変更: ‘strict’ 引数が追加されました。

 -- の関数: __import__ (name, globals=None, locals=None, fromlist=(),
          level=0)

          注釈: これは *note importlib.import_module(): 4e1. とは違い、
          日常の Python プログラミングでは必要ない高等な関数です。

     この関数は *note import: 5ac. 文により呼び出されます。 (*note
     builtins: e. モジュールをインポートして ‘builtins.__import__’ に代
     入することで) この関数を置き換えて ‘import’ 文のセマンティクスを変
     更することができますが、同様のことをするのに通常はインポートフック
     ( PEP 302(8) 参照) を利用する方が簡単で、かつデフォルトのインポート
     実装が使用されていることを仮定するコードとの間で問題が起きないので
     、このやり方は '強く' 推奨されません。 *note __import__(): 8a2. を
     直接使用することも推奨されず、 *note importlib.import_module():
     4e1. の方が好まれます。

     この関数は、モジュール 'name' をインポートし、 'globals' と
     'locals' が与えられれば、パッケージのコンテキストで名前をどう解釈す
     るか決定するのに使います。 'fromlist' は 'name' で与えられるモジュ
     ールからインポートされるべきオブジェクトまたはサブモジュールの名前
     を与ます。標準の実装では 'locals' 引数はまったく使われず、
     'globals' は *note import: 5ac. 文のパッケージコンテキストを決定す
     るためにのみ使われます。

     'level' は絶対と相対どちらのインポートを使うかを指定します。 ‘0’ (デ
     フォルト) は絶対インポートのみ実行します。正の 'level' の値は、
     *note __import__(): 8a2. を呼び出したディレクトリから検索対象となる
     親ディレクトリの数を示します (詳細は PEP 328(9) を参照してください
     )。

     'name' 変数が ‘package.module’ 形式であるとき、通常は、'name' で指
     名されたモジュール 'ではなく'、最上位のパッケージ (最初のドットまで
     の名前) が返されます。しかしながら、空でない 'fromlist' 引数が与え
     られると、 'name' で指名されたモジュールが返されます。

     例えば、文 ‘import spam’ は、以下のコードのようなバイトコードに帰結
     します:

          spam = __import__('spam', globals(), locals(), [], 0)

     文 ‘import spam.ham’ は、この呼び出しになります:

          spam = __import__('spam.ham', globals(), locals(), [], 0)

     ここで *note __import__(): 8a2. がどのように最上位モジュールを返し
     ているかに注意して下さい。 *note import: 5ac. 文により名前が束縛さ
     れたオブジェクトになっています。

     一方で、文 ‘from spam.ham import eggs, sausage as saus’ は、以下と
     なります

          _temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], 0)
          eggs = _temp.eggs
          saus = _temp.sausage

     ここで、*note __import__(): 8a2. から ‘spam.ham’ モジュールが返され
     ます。このオブジェクトから、インポートされる名前が取り出され、それ
     ぞれの名前として代入されます。

     単純に名前からモジュール (パッケージの範囲内であるかも知れません) を
     インポートしたいなら、 *note importlib.import_module(): 4e1. を使っ
     てください。

     バージョン 3.3 で変更: 負の 'level' の値はサポートされなくなりまし
     た (デフォルト値の 0 に変更されます)。

     バージョン 3.9 で変更: コマンドラインオプション *note -E: 92b. or
     *note -I: 92c. が指定された場合、環境変数 *note PYTHONCASEOK: 92a.
     は無視されるようになりました。

脚注
....

   ---------- Footnotes ----------

   (1) なお、パーサは Unix スタイルの行末の記法しか受け付けません。コー
ドをファイルから読んでいるなら、必ず、改行変換モードで Windows や Mac ス
タイルの改行を変換してください。

   (2) https://peps.python.org/pep-0709/

   (3) https://peps.python.org/pep-0667/

   (4) https://peps.python.org/pep-0475/

   (5) https://peps.python.org/pep-0008/

   (6) 
https://rhettinger.wordpress.com/2011/05/26/super-considered-super/

   (7) https://en.wikipedia.org/wiki/Transpose

   (8) https://peps.python.org/pep-0302/

   (9) https://peps.python.org/pep-0328/


File: python.info,  Node: 組み込み定数,  Next: 組み込み型,  Prev: 組み込み関数,  Up: Python 標準ライブラリ

5.3 組み込み定数
================

組み込み名前空間にはいくつかの定数があります。定数の一覧:

 -- データ: False

     *note bool: 434. 型の偽値です。‘False’ への代入は不正で、*note
     SyntaxError: 172. を送出します。

 -- データ: True

     *note bool: 434. 型の真値です。‘True’ への代入は不正で、*note
     SyntaxError: 172. を送出します。

 -- データ: None

     関数にデフォルト引数が渡されなかったときなどに、値の非存在を表すの
     に頻繁に用いられるオブジェクトです。‘None’ への代入は不正で、*note
     SyntaxError: 172. を送出します。‘None’ が *note NoneType: 81d. 型の
     唯一のインスタンスです。

 -- データ: NotImplemented

     特殊な二項演算のメソッド (e.g.  *note __eq__(): ac8, *note
     __lt__(): 12d9, *note __add__(): 1eed, *note __rsub__(): 1f00,
     etc.)  が、他の型に対して演算が実装されていないことを示すために返す
     特殊値です。インプレースの特殊な二項演算のメソッド (e.g.  *note
     __imul__(): 1ef2, *note __iand__(): 1f12, etc.)  も同じ理由でこの値
     を返すことがあります。この処理では真偽値コンテキストでの評価はして
     はいけません。‘NotImplemented’ が *note types.NotImplementedType:
     81e. 型の唯一のインスタンスです。

          注釈: 二項演算の (あるいはインプレースの) メソッドが
          ‘NotImplemented’ を返した場合、インタープリタはもう一方の型で
          定義された対の演算で代用を試みます (あるいは演算によっては他の
          代替手段も試みます)。試行された演算全てが ‘NotImplemented’ を
          返した場合、インタープリタは適切な例外を送出します。
          ‘NotImplemented’ を正しく返さないと、誤解を招きかねないエラー
          メッセージになったり、 ‘NotImplemented’ が Python コードに返さ
          れるようなことになります。

          例として *note 算術演算の実装: 1e49. を参照してください。

          注釈: ‘NotImplementedError’ と ‘NotImplemented’ は、似たような
          名前と目的を持っていますが、相互に変換できません。 利用する際
          には、 *note NotImplementedError: 209. を参照してください。

     バージョン 3.9 で変更: ‘NotImplemented’ の評価は非推奨です。 現時点
     で真と評価されていても *note DeprecationWarning: 18a. が出ます。 こ
     の警告は将来のバージョンの Python で *note TypeError: 502. を送出し
     ます。

 -- データ: Ellipsis

     Ellipsis リテラル "‘...’" と同じです。 主に拡張スライス構文やユーザ
     定義のコンテナデータ型において使われる特殊な値です。‘Ellipsis’ が
     *note types.EllipsisType: 81c. 型の唯一のインスタンスです。

 -- データ: __debug__

     この定数は、Python が *note -O: d82. オプションを有効にして開始され
     たのでなければ真です。 *note assert: 936. 文も参照して下さい。

     注釈: 名前 *note None: 641. 、 *note False: b05. 、 *note True:
     bdb. 、 *note __debug__: 7a5. は再代入できない (これらに対する代入
     は、たとえ属性名としてであっても *note SyntaxError: 172. が送出され
     ます) ので、これらは「真の」定数であると考えられます。

* Menu:

* site モジュールで追加される定数::


File: python.info,  Node: site モジュールで追加される定数,  Up: 組み込み定数

5.3.1 ‘site’ モジュールで追加される定数
---------------------------------------

*note site: b5. モジュール (*note -S: 1179. コマンドラインオプションが指
定されない限り、スタートアップ時に自動的にインポートされます) は組み込み
名前空間にいくつかの定数を追加します。それらは対話的インタープリタシェル
で有用ですが、プログラム中では使うべきではありません。

 -- データ: quit (code=None)
 -- データ: exit (code=None)

     表示されたときに "Use quit() or Ctrl-D (i.e.  EOF) to exit" のよう
     なメッセージを表示し、呼び出されたときには指定された終了コードを伴
     って *note SystemExit: d0e. を送出するオブジェクトです。

 -- データ: help

     Object that when printed, prints the message "Type help() for
     interactive help, or help(object) for help about object.", and when
     called, acts as described *note elsewhere: 8a5.

 -- データ: copyright
 -- データ: credits

     表示あるいは呼び出されたときに、それぞれ著作権あるいはクレジットの
     テキストが表示されるオブジェクトです。

 -- データ: license

     表示されたときに "Type license() to see the full license text" とい
     うメッセージを表示し、呼び出されたときには完全なライセンスのテキス
     トをページャのような形式で (1画面分づつ) 表示するオブジェクトです。


File: python.info,  Node: 組み込み型,  Next: 組み込み例外,  Prev: 組み込み定数,  Up: Python 標準ライブラリ

5.4 組み込み型
==============

以下のセクションでは、インタプリタに組み込まれている標準型について記述し
ます。

主要な組み込み型は、数値、シーケンス、マッピング、クラス、インスタンス、
および例外です。

コレクションクラスには、ミュータブルなものがあります。コレクションのメン
バをインプレースに足し、引き、または並べ替えて、特定の要素を返さないメソ
ッドは、コレクション自身ではなく ‘None’ を返します。

演算には、複数の型でサポートされているものがあります; 特に、ほぼ全てのオ
ブジェクトは、等価比較でき、真理値を判定でき、 (*note repr(): 7c8. 関数
や、わずかに異なる *note str(): 418. 関数によって) 文字列に変換できます
。オブジェクトが *note print(): f42. 関数で印字されるとき、文字列に変換
する関数が暗黙に使われます。

* Menu:

* 真理値判定::
* ブール演算: ブール演算 --- and or not. and, or, not
* 比較: 比較<2>.
* 数値型 int, float, complex: 数値型 int float complex.
* ブーリアン型 - bool::
* イテレータ型::
* シーケンス型: シーケンス型 --- list tuple range. list, tuple, range
* テキストシーケンス型: テキストシーケンス型 --- str. str
* バイナリシーケンス型: バイナリシーケンス型 --- bytes bytearray memoryview. bytes, bytearray, memoryview
* set（集合）型: set（集合）型 --- set frozenset. set, frozenset
* マッピング型: マッピング型 --- dict. dict
* コンテキストマネージャ型::
* 型アノテーション型: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン. ジェネリックエイリアス 、 ユニオン
* その他の組み込み型::
* 特殊属性::
* 整数と文字列の変換での長さ制限::


File: python.info,  Node: 真理値判定,  Next: ブール演算 --- and or not,  Up: 組み込み型

5.4.1 真理値判定
----------------

どのようなオブジェクトでも真理値として判定でき、 *note if: 2ca. や *note
while: 1b6e. の条件あるいは以下のブール演算の被演算子として使えます。

オブジェクトは、デフォルトでは真と判定されます。ただし、そのクラスが
*note __bool__(): 12a3. メソッドを定義していて ‘False’ を返す場合、また
は *note __len__(): 1ec3. メソッドを定義していてゼロを返す場合は偽と判定
されます。 (1) 以下は偽と判定される主な組み込みオブジェクトです:

   * 偽であると定義されている定数: ‘None’ と ‘False’

   * 数値型におけるゼロ: ‘0’, ‘0.0’, ‘0j’, ‘Decimal(0)’, ‘Fraction(0,
     1)’

   * 空のシーケンスまたはコレクション: ‘''’, ‘()’, ‘[]’, ‘{}’, ‘set()’,
     ‘range(0)’

ブール値の結果を返す演算および組み込み関数は、特に注釈のない限り常に偽値
として ‘0’ または ‘False’ を返し、真値として ‘1’ または ‘True’ を返しま
す。 (重要な例外: ブール演算 ‘or’ および ‘and’ は常に被演算子のうちの一
つを返します。)

   ---------- Footnotes ----------

   (1) これらの特殊なメソッドのさらなる情報については、 Python リファレ
ンスマニュアル (*note 基本的なカスタマイズ: 1ec0.) を参照してください。


File: python.info,  Node: ブール演算 --- and or not,  Next: 比較<2>,  Prev: 真理値判定,  Up: 組み込み型

5.4.2 ブール演算 -- ‘and’, ‘or’, ‘not’
--------------------------------------

以下にブール演算を、優先順位が低い順に示します:

演算              結果                                  注釈
                                                        
--------------------------------------------------------------------
                                                        
‘x or y’          'x' が真なら 'x', そうでなければ      (1)
                  'y'                                   
                  
                                                        
‘x and y’         'x' が偽なら 'x', そうでなければ      (2)
                  'y'                                   
                  
                                                        
‘not x’           'x' が偽なら ‘True’, そうでなければ   (3)
                  ‘False’                               
                  

注釈:

  1. この演算子は短絡評価されます。つまり第一引数が偽のときにのみ、第二
     引数が評価されます。

  2. この演算子は短絡評価されます。つまり第一引数が真のときにのみ、第二
     引数が評価されます。

  3. ‘not’ は非ブール演算子よりも優先度が低いので、 ‘not a == b’ は ‘not
     (a == b)’ と解釈され、 ‘a == not b’ は構文エラーです。


File: python.info,  Node: 比較<2>,  Next: 数値型 int float complex,  Prev: ブール演算 --- and or not,  Up: 組み込み型

5.4.3 比較
----------

Python には 8 種の比較演算があります。比較演算の優先順位は全て同じです
(ブール演算より高い優先順位です)。比較は任意に連鎖できます; 例えば、 ‘x
< y <= z’ は ‘x < y and y <= z’ とほぼ等価ですが、この 'y' は一度だけし
か評価されません (どちらにしても、 ‘x < y’ が偽となれば 'z' は評価されま
せん)。

以下の表に比較演算をまとめます:

演算             意味
                 
-----------------------------------------------
                 
‘<’              より小さい
                 
                 
‘<=’             以下
                 
                 
‘>’              より大きい
                 
                 
‘>=’             以上
                 
                 
‘==’             等しい
                 
                 
‘!=’             等しくない
                 
                 
‘is’             同一のオブジェクトである
                 
                 
‘is not’         同一のオブジェクトでない
                 

異なる数値型の場合を除き、異なる型のオブジェクト同士は等価になることはあ
りません。 ‘==’ 演算子は常に定義されていますが、いくつかのオブジェクト型
(たとえばクラスオブジェクト) では *note is: 2cc. と同等になります。 ‘<’,
‘<=’, ‘>’ および ‘>=’ 演算子は、それらの意味が明快である場合に限って定義
されます; たとえば、オペランドのいずれかが複素数である場合、これらの演算
子は *note TypeError: 502. 例外を送出します。

あるクラスの同一でないインスタンスは、通常等価でないとされますが、そのク
ラスが *note __eq__(): ac8. メソッドを定義している場合は除きます。

クラスのインスタンスは、そのクラスがメソッド *note __lt__(): 12d9. 、
*note __le__(): 12da. 、 *note __gt__(): 12db. 、 *note __ge__(): 12dc.
のうち十分なものを定義していない限り、同じクラスの別のインスタンスや他の
型のオブジェクトとは順序付けできません (一般に、比較演算子の通常の意味を
求めるなら、 *note __lt__(): 12d9. と *note __eq__(): ac8. だけで十分で
す)。

*note is: 2cc. および *note is not: 1fd8. 演算子の振る舞いはカスタマイズ
できません。また、これらはいかなる 2 つのオブジェクトにも適用でき、決し
て例外を送出しません。

*note in: 2cb. と *note not in: 5fb. という構文上で同じ優先度を持つ演算
子がさらに 2 つあり、 *note iterable: 10ad. または *note __contains__():
1ebe. を実装した型でサポートされています。


File: python.info,  Node: 数値型 int float complex,  Next: ブーリアン型 - bool,  Prev: 比較<2>,  Up: 組み込み型

5.4.4 数値型 ‘int’, ‘float’, ‘complex’
--------------------------------------

数値型には 3 種類あります: '整数' 、 '浮動小数点数' 、 '複素数' です。さ
らに、ブール型は整数のサブタイプです。整数には精度の制限がありません。浮
動小数点型はたいていは C の double を使って実装されています; あなたのプ
ログラムが動作するマシンでの浮動小数点型の精度と内部表現は、 *note
sys.float_info: 1956. から入手可能です。複素数は実部と虚部を持ち、それぞ
れが浮動小数点数です。複素数 'z' から実部および虚部を取り出すには、
‘z.real’ および ‘z.imag’ を使ってください。 (標準ライブラリには、さらに
分数のための数値型 *note fractions.Fraction: 1c8. や、ユーザによる精度の
定義が可能な浮動小数点数のための *note decimal.Decimal: 27d. があります
。)

数値は、数値リテラルによって、あるいは組み込み関数や演算子の戻り値として
生成されます。 (十六進、八進、二進数を含む) 修飾のない整数リテラルは、整
数を生成します。小数点または指数表記を含む数値リテラルは浮動小数点数を生
成します。数値リテラルに ‘'j'’ または ‘'J'’ をつけると純虚数 (実部がゼロ
の複素数) を生成し、それに整数や浮動小数点数を加えることにより実部と虚部
を持つ複素数を得ることができます。

Python は型混合の算術演算に完全に対応しています: ある二項算術演算子の被
演算子の数値型が互いに異なるとき、"より狭い方" の型の被演算子はもう片方
の型に合わせて広げられます。ここで整数は浮動小数点数より狭く、浮動小数点
数は複素数より狭いです。 たくさんの異なる型の数値間での比較は、それらの
厳密な数で比較したかのように振る舞います。 (1)

コンストラクタ *note int(): 238. 、 *note float(): 2ce. 、 *note
complex(): 2cf. で、特定の型の数を生成できます。

全ての (複素数を除く) 組み込み数値型は以下の演算に対応しています (演算の
優先順位については、 *note 演算子の優先順位: 1ff1. を参照してください):

演算                      結果                                  注釈          完全なドキュメント
                                                                              
-------------------------------------------------------------------------------------------------------
                                                                              
‘x + y’                   'x' と 'y' の和
                          
                                                                              
‘x - y’                   'x' と 'y' の差
                          
                                                                              
‘x * y’                   'x' と 'y' の積
                          
                                                                              
‘x / y’                   'x' と 'y' の商
                          
                                                                              
‘x // y’                  'x' と 'y' の商を切り下げたもの       (1)(2)
                                                                
                                                                              
‘x % y’                   ‘x / y’ の剰余                        (2)
                                                                
                                                                              
‘-x’                      'x' の符号反転
                          
                                                                              
‘+x’                      'x' そのまま
                          
                                                                              
‘abs(x)’                  'x' の絶対値または大きさ                            *note abs(): 1c0e.
                                                                              
                                                                              
‘int(x)’                  'x' の整数への変換                    (3)(6)        *note int(): 238.
                                                                              
                                                                              
‘float(x)’                'x' の浮動小数点数への変換            (4)(6)        *note float(): 2ce.
                                                                              
                                                                              
‘complex(re, im)’         実部 're', 虚部 'im' の複素数。       (6)           *note complex(): 2cf.
                          'im' の既定値はゼロ。                               
                          
                                                                              
‘c.conjugate()’           複素数 'c' の共役複素数
                          
                                                                              
‘divmod(x, y)’            ‘(x // y, x % y)’ からなるペア        (2)           *note divmod(): 96f.
                                                                              
                                                                              
‘pow(x, y)’               'x' の 'y' 乗                         (5)           *note pow(): 9a0.
                                                                              
                                                                              
‘x ** y’                  'x' の 'y' 乗                         (5)
                                                                

注釈:

  1. 整数の除算とも呼ばれます。 *note int: 238. 型のオペランドに対しては
     、結果は *note int: 238. 型になります。 *note float: 2ce. 型のオペ
     ランドに対しては、結果は *note float: 2ce. 型になります。一般に結果
     の型は必ずしも *note int: 238. 型ではありませんが、結果は常に整数で
     す。結果は常に負の無限大の方向に丸められます: ‘1//2’ は ‘0’ 、
     ‘(-1)//2’ は ‘-1’ 、 ‘1//(-2)’ は ‘-1’ 、そして ‘(-1)//(-2)’ は ‘0’
     です。

  2. 複素数型には使えません。適用可能な場合には代わりに *note abs():
     1c0e. で浮動小数点型に変換してください。

  3. 
     *note float: 2ce. から *note int: 238. への変換は小数点以下を切り捨
     てます。別の変換方法については関数 *note math.floor(): 1369. や
     *note math.ceil(): 136a. を参照してください。

  4. 浮動小数点数は、文字列 "nan" と "inf" を、オプションの接頭辞 "+" ま
     たは "-" と共に、非数 (Not a Number (NaN)) や正、負の無限大として受
     け付けます。

  5. Python は、プログラム言語一般でそうであるように、 ‘pow(0, 0)’ およ
     び ‘0 ** 0’ を ‘1’ と定義します。

  6. 受け付けられる数値リテラルは数字 ‘0’ から ‘9’ または等価な Unicode
     (‘Nd’ プロパティを持つコードポイント) を含みます。

     ‘Nd’ プロパティを持つコードポイントの完全なリストは Unicode 標準(2)
     をご覧ください。

全ての *note numbers.Real: 20fb. 型 (*note int: 238. 、 *note float:
2ce.) は以下の演算も含みます:

演算                     結果
                         
---------------------------------------------------------------------------
                         
*note math.trunc(x): 136b.'x' を *note Integral: 1f1d. (整数) に切り捨て
                         ます
                         
                         
*note round(x[, n]): 12a8.'x' を 'n' 桁に丸めます。丸め方は偶数丸めです。
                         'n' が省略されれば 0 がデフォルトとなります。
                         
                         
*note math.floor(x): 1369.'x' 以下の最大の *note Integral: 1f1d. (整数) を
                         返します
                         
                         
*note math.ceil(x): 136a.'x' 以上の最小の *note Integral: 1f1d. (整数) を
                         返します
                         

その他の数値演算は、 *note math: 81. や *note cmath: 11. モジュールをご
覧ください。

* Menu:

* 整数型におけるビット単位演算::
* 整数型における追加のメソッド::
* 浮動小数点数に対する追加のメソッド::
* 数値型のハッシュ化::

   ---------- Footnotes ----------

   (1) この結果として、リスト ‘[1, 2]’ は ‘[1.0, 2.0]’ と等しいと見なさ
れます。タプルの場合も同様です。

   (2) 
https://unicode.org/Public/UNIDATA/extracted/DerivedNumericType.txt


File: python.info,  Node: 整数型におけるビット単位演算,  Next: 整数型における追加のメソッド,  Up: 数値型 int float complex

5.4.4.1 整数型におけるビット単位演算
....................................

ビット単位演算は整数についてのみ意味を持ちます。 ビット単位演算の結果は
、あたかも両方の値の先頭を無限個の符号ビットで埋めたものに対して計算した
かのような値になります。

二項ビット単位演算の優先順位は全て、数値演算よりも低く、比較よりも高くな
っています; 単項演算 ‘~’ の優先順位は他の単項数値演算 (‘+’ および ‘-’) と
同じです。

以下の表では、ビット単位演算を優先順位が低い順に並べています:

演算             結果                                 注釈
                                                      
---------------------------------------------------------------------
                                                      
‘x | y’          'x' と 'y' のビット単位 '論理和'     (4)
                                                      
                                                      
‘x ^ y’          'x' と 'y' のビット単位 '排他的論    (4)
                 理和'                                
                 
                                                      
‘x & y’          'x' と 'y' のビット単位 '論理積'     (4)
                                                      
                                                      
‘x << n’         'x' の 'n' ビット左シフト            (1)(2)
                                                      
                                                      
‘x >> n’         'x' の 'n' ビット右シフト            (1)(3)
                                                      
                                                      
‘~x’             'x' のビット反転
                 

注釈:

  1. 負値のシフト数は不正であり、 *note ValueError: 1e3. が送出されます
     。

  2. 'n' ビットの左シフトは、 ‘pow(2, n)’ による乗算と等価です。

  3. 'n' ビットの右シフトは、 ‘pow(2, n)’ による切り捨て除算と等価です。

  4. 桁の長い方の値に少なくとも 1 つ余計に符号ビットを付け加えた幅 (計算
     するビット幅は ‘1 + max(x.bit_length(), y.bit_length())’ かそれ以上
     ) でこれらの計算を行えば、無限個の符号ビットがあるかのように計算し
     たのと同じ結果を得るのに十分です。


File: python.info,  Node: 整数型における追加のメソッド,  Next: 浮動小数点数に対する追加のメソッド,  Prev: 整数型におけるビット単位演算,  Up: 数値型 int float complex

5.4.4.2 整数型における追加のメソッド
....................................

整数型は *note numbers.Integral: 1f1d. *note 抽象基底クラス: 1186. を実
装します。さらに、追加のメソッドをいくつか提供します:

 -- メソッド: int.bit_length ()

     整数を、符号と先頭の 0 は除いて二進法で表すために必要なビットの数を
     返します:

          >>> n = -37
          >>> bin(n)
          '-0b100101'
          >>> n.bit_length()
          6

     正確には、 ‘x’ が非 0 なら、 ‘x.bit_length()’ は ‘2**(k-1) <=
     abs(x) < 2**k’ を満たす唯一の正の整数 ‘k’ です。同様に、 ‘abs(x)’ が
     十分小さくて対数を適切に丸められるとき、 ‘k = 1 + int(log(abs(x),
     2))’ です。 ‘x’ が 0 なら、 ‘x.bit_length()’ は ‘0’ を返します。

     次と等価です:

          def bit_length(self):
              s = bin(self)       # binary representation:  bin(-37) --> '-0b100101'
              s = s.lstrip('-0b') # remove leading zeros and minus sign
              return len(s)       # len('100101') --> 6

     Added in version 3.1.

 -- メソッド: int.bit_count ()

     整数の絶対値の二進数表現における 1 の数を返します。これは
     population count としても知られています。 例:

          >>> n = 19
          >>> bin(n)
          '0b10011'
          >>> n.bit_count()
          3
          >>> (-n).bit_count()
          3

     次と等価です:

          def bit_count(self):
              return bin(self).count("1")

     Added in version 3.10.

 -- メソッド: int.to_bytes (length=1, byteorder='big', *, signed=False)

     整数を表すバイト列を返します。

          >>> (1024).to_bytes(2, byteorder='big')
          b'\x04\x00'
          >>> (1024).to_bytes(10, byteorder='big')
          b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00'
          >>> (-1024).to_bytes(10, byteorder='big', signed=True)
          b'\xff\xff\xff\xff\xff\xff\xff\xff\xfc\x00'
          >>> x = 1000
          >>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
          b'\xe8\x03'

     整数は 'length' バイトで表されます、デフォルト値は 1 です。整数が与
     えられた数のバイトで表せなければ、 *note OverflowError: 84e. が送出
     されます。

     'byteorder' 引数は、整数を表すのに使われるバイトオーダーを決定しま
     す。デフォルト値は ‘"big"’ です。 'byteorder' が ‘"big"’ なら、最上
     位のバイトがバイト配列の最初に来ます。 'byteorder' が ‘"little"’ な
     ら、最上位のバイトがバイト配列の最後に来ます。

     'signed' 引数は、整数を表すのに 2 の補数を使うかどうかを決定します
     。 'signed' が ‘False’ で、負の整数が与えられたなら、 *note
     OverflowError: 84e. が送出されます。 'signed' のデフォルト値は
     ‘False’ です。

     上記のデフォルト値は整数を 1 バイトのオブジェクトに適切に変換するの
     に使うことができます:

          >>> (65).to_bytes()
          b'A'

     ただし、デフォルト引数で 255 より大きな整数を変換しないでください。
     そうでなければ *note OverflowError: 84e. 例外を引き起こします。

     次と等価です:

          def to_bytes(n, length=1, byteorder='big', signed=False):
              if byteorder == 'little':
                  order = range(length)
              elif byteorder == 'big':
                  order = reversed(range(length))
              else:
                  raise ValueError("byteorder must be either 'little' or 'big'")

              return bytes((n >> i*8) & 0xff for i in order)

     Added in version 3.2.

     バージョン 3.11 で変更: ‘length’ と ‘byteorder’ 引数にデフォルト値
     を追加しました。

 -- メソッド: classmethod int.from_bytes (bytes, byteorder='big', *,
          signed=False)

     与えられたバイト列の整数表現を返します。

          >>> int.from_bytes(b'\x00\x10', byteorder='big')
          16
          >>> int.from_bytes(b'\x00\x10', byteorder='little')
          4096
          >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=True)
          -1024
          >>> int.from_bytes(b'\xfc\x00', byteorder='big', signed=False)
          64512
          >>> int.from_bytes([255, 0, 0], byteorder='big')
          16711680

     引数 'bytes' は *note bytes-like object: cfb. か、または bytes を生
     成する iterable でなければなりません。

     'byteorder' 引数は、整数を表すのに使われるバイトオーダーを決定しま
     す。デフォルト値は ‘"big"’ です。 'byteorder' が ‘"big"’ なら、最上
     位のバイトがバイト配列の最初に来ます。 'byteorder' が ‘"little"’ な
     ら、最上位のバイトがバイト配列の最後に来ます。ホストシステムにネイ
     ティブのバイトオーダーを要求するには、 *note sys.byteorder: 2100. を
     バイトオーダーの値として使ってください。

     'signed' 引数は、整数を表すのに 2 の補数を使うかどうかを決定します
     。

     次と等価です:

          def from_bytes(bytes, byteorder='big', signed=False):
              if byteorder == 'little':
                  little_ordered = list(bytes)
              elif byteorder == 'big':
                  little_ordered = list(reversed(bytes))
              else:
                  raise ValueError("byteorder must be either 'little' or 'big'")

              n = sum(b << i*8 for i, b in enumerate(little_ordered))
              if signed and little_ordered and (little_ordered[-1] & 0x80):
                  n -= 1 << 8*len(little_ordered)

              return n

     Added in version 3.2.

     バージョン 3.11 で変更: ‘byteorder’ 引数にデフォルト値を追加しまし
     た。

 -- メソッド: int.as_integer_ratio ()

     比が元の数と等しくなるような整数のペアを返します。戻り値の分母に相
     当する数は正の整数です。元の数が整数の場合の比は、常にその整数が分
     子であり、分母は ‘1’ です。

     Added in version 3.8.

 -- メソッド: int.is_integer ()

     常に ‘True’ を返します。 *note float.is_integer(): 2101. に対するダ
     ックタイピングの互換性のために存在しています。

     Added in version 3.12.


File: python.info,  Node: 浮動小数点数に対する追加のメソッド,  Next: 数値型のハッシュ化,  Prev: 整数型における追加のメソッド,  Up: 数値型 int float complex

5.4.4.3 浮動小数点数に対する追加のメソッド
..........................................

浮動小数点数型は、 *note numbers.Real: 20fb. *note 抽象基底クラス: 1186.
を実装しています。浮動小数点型はまた、以下の追加のメソッドを持ちます。

 -- メソッド: float.as_integer_ratio ()

     比が厳密に元の浮動小数点数であるような一対の整数を返します。比は既
     約分数として与えられ、分母は正の値です。無限大に対しては *note
     OverflowError: 84e. を、非数 (NaN) に対しては *note ValueError:
     1e3. を送出します。

 -- メソッド: float.is_integer ()

     浮動小数点数インスタンスが有限の整数値なら ‘True’ を、そうでなけれ
     ば ‘False’ を返します:

          >>> (-2.0).is_integer()
          True
          >>> (3.2).is_integer()
          False

16 進表記の文字列へ、または、 16 進表記からの変換をサポートする二つのメ
ソッドがあります。 Python の浮動小数点数は内部的には2進数で保持されるの
で、浮動小数点数の '10進数' へまたは '10進数' からの変換には若干の丸め誤
差があります。それに対し、16 進表記では、浮動小数点数を正確に表現できま
す。これはデバッグのときや、数学的な用途 (numerical work) に便利でしょう
。

 -- メソッド: float.hex ()

     浮動小数点数の 16 進文字列表現を返します。有限の浮動小数点数に対し
     、この表現は常に ‘0x’ で始まり ‘p’ と指数が続きます。

 -- メソッド: classmethod float.fromhex (s)

     16 進文字列表現 's' で表される、浮動小数点数を返すクラスメソッドで
     す。文字列 's' は、前や後にホワイトスペースを含んでいても構いません
     。

*note float.fromhex(): 2103. はクラスメソッドですが、 *note float.hex():
1c7d. はインスタンスメソッドであることに注意して下さい。

16 進文字列表現は以下の書式となります:

     [sign] ['0x'] integer ['.' fraction] ['p' exponent]

‘sign’ は必須ではなく、 ‘+’ と ‘-’ のどちらかです。 ‘integer’ と
‘fraction’ は 16 進数の文字列で、 ‘exponent’ は 10 進数で符号もつけられ
ます。大文字・小文字は区別されず、最低でも 1 つの 16 進数文字を整数部も
しくは小数部に含む必要があります。この制限は C99 規格のセクション
6.4.4.2 で規定されていて、 Java 1.5 以降でも使われています。特に、 *note
float.hex(): 1c7d. の出力は C や Java コード中で、浮動小数点数の 16 進表
記として役に立つでしょう。また、 C の ‘%a’ 書式や、 Java の
‘Double.toHexString’ で書きだされた文字列は *note float.fromhex(): 2103.
で受け付けられます。

なお、指数部は 16 進数ではなく 10 進数で書かれ、係数に掛けられる 2 の累
乗を与えます。例えば、16 進文字列 ‘0x3.a7p10’ は浮動小数点数 ‘(3 +
10./16 + 7./16**2) * 2.0**10’ すなわち ‘3740.0’ を表します:

     >>> float.fromhex('0x3.a7p10')
     3740.0

逆変換を ‘3740.0’ に適用すると、同じ数を表す異なる 16 進文字列表現を返し
ます:

     >>> float.hex(3740.0)
     '0x1.d380000000000p+11'


File: python.info,  Node: 数値型のハッシュ化,  Prev: 浮動小数点数に対する追加のメソッド,  Up: 数値型 int float complex

5.4.4.4 数値型のハッシュ化
..........................

数 ‘x’ と ‘y’ に対して、型が異なっていたとしても、 ‘x == y’ であれば必ず
‘hash(x) == hash(y)’ であることが要請されます (詳細は *note __hash__():
ac9. メソッドドキュメントを参照してください)。実装の簡単さと 複数の数値
型 (*note int: 238. 、 *note float: 2ce. 、 *note decimal.Decimal: 27d.
、 *note fractions.Fraction: 1c8. を含みます) 間の効率のため、Python の
数値型に対するハッシュ値はある単一の数学的関数に基づいていて、 その関数
はすべての有理数に対し定義されているため、 *note int: 238. と *note
fractions.Fraction: 1c8. のすべてのインスタンスと、 *note float: 2ce. と
*note decimal.Decimal: 27d. のすべての有限なインスタンスに 対して適用さ
れます。本質的には、この関数は定数の素数 ‘P’ に対して ‘P’ を法とする還元
で与えられます。 値 ‘P’ は、 *note sys.hash_info: fca. の *note modulus:
2106. 属性として Python で利用できます。

'CPython 実装の詳細:' 現在使われている素数は、32 bit C long のマシンでは
‘P = 2**31 - 1’ 、 64-bit C long のマシンでは ‘P = 2**61 - 1’ です。

詳細な規則はこうです:

   - ‘x = m / n’ が非負の有理数で、 ‘n’ が ‘P’ で割り切れないなら、
     ‘invmod(n, P)’ を ‘n’ を ‘P’ で割った剰余の (剰余演算の意味での) 逆
     数を与えるものとして、 ‘hash(x)’ を ‘m * invmod(n, P) % P’ と定義し
     ます。

   - ‘x = m / n’ が非負の有理数で、 ‘n’ が ‘P’ で割り切れる (が ‘m’ は割
     り切れない) なら、 ‘n’ は ‘P’ で割った余りの逆数を持たず、上の規則
     は適用できません。この場合、 ‘hash(x)’ を定数 ‘sys.hash_info.inf’ と
     定義します。

   - ‘x = m / n’ が負の有理数なら、 ‘hash(x)’ を ‘-hash(-x)’ と定義しま
     す。その結果のハッシュが ‘-1’ なら、 ‘-2’ に置き換えます。

   - 特定の値 ‘sys.hash_info.inf’ 、 ‘-sys.hash_info.inf’ は、正の無限大
     、負の無限大のハッシュ値を (それぞれ) 表すのに使われます。

   - 複素 (*note complex: 2cf.) 数 ‘z’ に対して、実部と虚部のハッシュ値
     は、 ‘hash(z.real) + sys.hash_info.imag * hash(z.imag)’ の
     ‘2**sys.hash_info.width’ を法とする還元を計算することにより組み合わ
     せられ、よってこれは ‘range(-2**(sys.hash_info.width - 1),
     2**(sys.hash_info.width - 1))’ に収まります。再び、結果が ‘-1’ なら
     、 ‘-2’ で置き換えられます。

上述の規則をわかりやすくするため、有理数 *note float: 2ce. や、 *note
complex: 2cf. のハッシュを計算する組み込みのハッシュと等価な Python コー
ドの例を挙げます:

     import sys, math

     def hash_fraction(m, n):
         """Compute the hash of a rational number m / n.

         Assumes m and n are integers, with n positive.
         Equivalent to hash(fractions.Fraction(m, n)).

         """
         P = sys.hash_info.modulus
         # Remove common factors of P.  (Unnecessary if m and n already coprime.)
         while m % P == n % P == 0:
             m, n = m // P, n // P

         if n % P == 0:
             hash_value = sys.hash_info.inf
         else:
             # Fermat's Little Theorem: pow(n, P-1, P) is 1, so
             # pow(n, P-2, P) gives the inverse of n modulo P.
             hash_value = (abs(m) % P) * pow(n, P - 2, P) % P
         if m < 0:
             hash_value = -hash_value
         if hash_value == -1:
             hash_value = -2
         return hash_value

     def hash_float(x):
         """Compute the hash of a float x."""

         if math.isnan(x):
             return object.__hash__(x)
         elif math.isinf(x):
             return sys.hash_info.inf if x > 0 else -sys.hash_info.inf
         else:
             return hash_fraction(*x.as_integer_ratio())

     def hash_complex(z):
         """Compute the hash of a complex number z."""

         hash_value = hash_float(z.real) + sys.hash_info.imag * hash_float(z.imag)
         # do a signed reduction modulo 2**sys.hash_info.width
         M = 2**(sys.hash_info.width - 1)
         hash_value = (hash_value & (M - 1)) - (hash_value & M)
         if hash_value == -1:
             hash_value = -2
         return hash_value


File: python.info,  Node: ブーリアン型 - bool,  Next: イテレータ型,  Prev: 数値型 int float complex,  Up: 組み込み型

5.4.5 ブーリアン型 - ‘bool’
---------------------------

ブーリアン型は真理値を表現します。 *note bool: 434. 型はただ2つの定数イ
ンスタンス ‘True’ と ‘False’ を持ちます。

組み込み関数 *note bool(): 434. は、もしその値が真理値として解釈可能なら
ば、任意の値を真偽値に変換します (上記 *note 真理値判定: 20c0. 節を参照
してください)。

論理演算には *note ブーリアン演算子: 20f6. ‘and’, ‘or’ および ‘not’ を使
ってください。2つの真偽値に対してビット演算子 ‘&’, ‘|’, ‘^’ を適用した場
合は、それぞれ論理演算 "and", "or", "xor" に相当するブール値を返します。
しかしながら、論理演算子 ‘and’, ‘or’ および ‘!=’ を使うほうが ‘&’, ‘|’ や
‘^’ を使うよりも好ましいです。

バージョン 3.12 で非推奨: The use of the bitwise inversion operator ‘~’
is deprecated and will raise an error in Python 3.16.

*note bool: 434. は *note int: 238. のサブクラスです (*note 数値型 int,
float, complex: 1b63. を参照してください)。多くの数値的なコンテキストに
おいて、 ‘False’ と ‘True’ はそれぞれ整数 0 と 1 であるかのように振る舞
います。しかし、そのような振る舞いを信頼することは推奨されません; *note
int(): 238. を使って明示的に整数値に変換してください。


File: python.info,  Node: イテレータ型,  Next: シーケンス型 --- list tuple range,  Prev: ブーリアン型 - bool,  Up: 組み込み型

5.4.6 イテレータ型
------------------

Python はコンテナでの反復処理の概念をサポートしています。この概念は 2 つ
の別々のメソッドを使って実装されています; これらのメソッドを使ってユーザ
定義のクラスで反復を行えるようにできます。後に詳しく述べるシーケンスは、
必ず反復処理メソッドをサポートしています。

コンテナオブジェクトが *note イテラブル: 10ad. のサポートを提供するため
には、一つのメソッドが定義されていなければなりません:

 -- メソッド: container.__iter__ ()

     *note iterator: 191. オブジェクトを返します。オブジェクトは後述する
     イテレータプロトコルをサポートする必要があります。もしコンテナが異
     なる種類の反復処理をサポートするなら、それぞれの反復処理のためのイ
     テレータを要求するメソッドをそれぞれ提供しても構いません 。(複数の
     形式の反復処理を提供するオブジェクトの例として、幅優先探索と深さ優
     先探索をサポートする木構造が挙げられます。)このメソッドは Python/C
     API での Python オブジェクトの型構造体の *note tp_iter: 1497. スロ
     ットに対応します。

イテレータオブジェクト自体は以下の 2 つのメソッドをサポートする必要があ
ります。これらのメソッドは 2 つ合わせて 'iterator protocol': (イテレータ
プロトコル) を成します:

 -- メソッド: iterator.__iter__ ()

     *note iterator: 191. オブジェクト自体を返します。このメソッドはコン
     テナとイテレータの両方を *note for: 2c9. および *note in: 2cb. 文で
     使えるようにするために必要です。このメソッドは Python/C API におい
     て Python オブジェクトを表す型構造体の *note tp_iter: 1497. スロッ
     トに対応します。

 -- メソッド: iterator.__next__ ()

     *note iterator: 191. の次のアイテムを返します。もしそれ以上アイテム
     が無ければ *note StopIteration: bc8. 例外を送出します。 このメソッ
     ドは Python/C APIでのPythonオブジェクトの型構造体の *note
     tp_iternext: 1498. スロットに対応します。

Python では、いくつかのイテレータオブジェクトを定義して、一般のシーケン
ス型、特殊なシーケンス型、辞書型、その他の特殊な形式に渡って反復をサポー
トしています。特殊型は、イテレータプロトコルの実装以外では重要ではありま
せん。

イテレータの *note __next__(): 129b. メソッドが一旦 *note StopIteration:
bc8. を送出したなら、以降の呼び出しでも例外を送出し続けなければなりませ
ん。この特性に従わない実装は壊れているとみなされます。

* Menu:

* ジェネレータ型::


File: python.info,  Node: ジェネレータ型,  Up: イテレータ型

5.4.6.1 ジェネレータ型
......................

Python における *note generator: 1035. (ジェネレータ) は、イテレータプロ
トコルを実装する便利な方法を提供します。コンテナオブジェクトの *note
__iter__(): 1c2e. メソッドがジェネレータとして実装されていれば、そのメソ
ッドは ‘__iter__()’ および *note __next__(): 1c2f. メソッドを提供するイ
テレータオブジェクト (厳密にはジェネレータオブジェクト) を自動的に返しま
す。ジェネレータに関する詳細な情報は、 *note yield 式のドキュメント:
1f95. にあります。


File: python.info,  Node: シーケンス型 --- list tuple range,  Next: テキストシーケンス型 --- str,  Prev: イテレータ型,  Up: 組み込み型

5.4.7 シーケンス型 -- ‘list’, ‘tuple’, ‘range’
----------------------------------------------

基本的なシーケンス型は 3 つあります: リスト、タプル、range オブジェクト
です。*note バイナリデータ: 20c4. や *note テキスト文字列: 1b67. を処理
するように仕立てられたシーケンス型は、セクションを割いて解説します。

* Menu:

* 共通のシーケンス演算::
* イミュータブルなシーケンス型::
* ミュータブルなシーケンス型::
* リスト型 (list): リスト型 list<2>.
* タプル型 (tuple): タプル型 tuple.
* range::


File: python.info,  Node: 共通のシーケンス演算,  Next: イミュータブルなシーケンス型,  Up: シーケンス型 --- list tuple range

5.4.7.1 共通のシーケンス演算
............................

以下の表にある演算は、ほとんどのミュータブル、イミュータブル両方のシーケ
ンスでサポートされています。カスタムのシーケンス型にこれらの演算を完全に
実装するのが簡単になるように、 *note collections.abc.Sequence: 1194. ABC
が提供されています。

以下のテーブルで、シーケンス演算を優先順位が低い順に挙げます。表内で、
's' と 't' は同じ型のシーケンス、 'n'、 'i'、 'j' 、 'k' は整数、'x' は
's' に課された型と値の条件を満たす任意のオブジェクトです。

‘in’ および ‘not in’ 演算の優先順位は比較演算と同じです。‘+’ (結合) およ
び ‘*’ (繰り返し)の優先順位は対応する数値演算と同じです。 (1)

演算                           結果                                 注釈
                                                                    
-----------------------------------------------------------------------------------
                                                                    
‘x in s’                       's' のある要素が 'x' と等しければ    (1)
                               ‘True’ , そうでなければ ‘False’      
                               
                                                                    
‘x not in s’                   's' のある要素が 'x' と等しければ    (1)
                               ‘False’, そうでなければ ‘True’       
                               
                                                                    
‘s + t’                        's' と 't' の結合                    (6)(7)
                                                                    
                                                                    
‘s * n’ または ‘n * s’         's' 自身を 'n' 回足すのと同じ        (2)(7)
                                                                    
                                                                    
‘s[i]’                         's' の 0 から数えて 'i' 番目の要素   (3)
                                                                    
                                                                    
‘s[i:j]’                       's' の 'i' から 'j' までのスライス   (3)(4)
                                                                    
                                                                    
‘s[i:j:k]’                     's' の 'i' から 'j' まで、 'k' 毎    (3)(5)
                               のスライス                           
                               
                                                                    
‘len(s)’                       's' の長さ
                               
                                                                    
‘min(s)’                       's' の最小の要素
                               
                                                                    
‘max(s)’                       's' の最大の要素
                               
                                                                    
‘s.index(x[, i[, j]])’         's' 中で 'x' が最初に出現するイン    (8)
                               デックス (インデックス 'i' 以降か    
                               らインデックス 'j' までの範囲)
                               
                                                                    
‘s.count(x)’                   's' 中に 'x' が出現する回数
                               

同じ型のシーケンスは比較もサポートしています。特に、タプルとリストは対応
する要素を比較することで辞書式順序で比較されます。つまり、等しいとされる
ためには、すべての要素が等しく、両シーケンスの型も長さも等しくなければな
りません。(完全な詳細は言語リファレンスの *note 比較: 1fd1. を参照してく
ださい。)

ミュータブルなシーケンスに対する前方および逆方向イテレータはインデックス
を使って要素にアクセスします。インデックスは、仮に参照するシーケンスが変
化したとしても前方 (または後方) に進み続けます。イテレータは *note
IndexError: 14de. または *note StopIteration: bc8. に出会った場合 (また
はインデックスがゼロより小さくなった場合) にのみ終了します。

注釈:

  1. ‘in’ および ‘not in’ 演算は、一般に単純な包含判定にのみ使われますが
     、(*note str: 418, *note bytes: 1a4, *note bytearray: 508. のような
     ) 特殊なシーケンスでは部分シーケンス判定にも使われます:

          >>> "gg" in "eggs"
          True

  2. ‘0’ 未満の値 'n' は ‘0’ として扱われます (これは 's' と同じ型の空の
     シーケンスを表します)。シーケンス 's' の要素はコピーされないので注
     意してください; コピーではなく要素に対する参照カウントが増えます。
     これは Python に慣れていないプログラマをよく悩ませます。例えば以下
     のコードを考えます:

          >>> lists = [[]] * 3
          >>> lists
          [[], [], []]
          >>> lists[0].append(3)
          >>> lists
          [[3], [3], [3]]

     ここで、‘[[]]’ が空リストを含む 1 要素のリストなので、‘[[]] * 3’ の
     3 要素はこの一つの空リスト (への参照) です。‘lists’ のいずれかの要
     素を変更すると、その一つのリストが変更されます。別々のリストのリス
     トを作るにはこうします:

          >>> lists = [[] for i in range(3)]
          >>> lists[0].append(3)
          >>> lists[1].append(5)
          >>> lists[2].append(7)
          >>> lists
          [[3], [5], [7]]

     別の説明が FAQ エントリ *note
     多次元のリストを作るにはどうしますか？: 210f. にあります。

  3. 'i' または 'j' が負の数の場合、インデックスはシーケンスの末端からの
     相対インデックスになります: ‘len(s) + i’ または ‘len(s) + j’ が代わ
     りに使われます。 ただし ‘-0’ はやはり ‘0’ であることに注意してくだ
     さい。

  4. 's' の 'i' から 'j' へのスライスは ‘i <= k < j’ となるようなインデ
     ックス 'k' を持つ要素からなるシーケンスとして定義されます。 'i' ま
     たは 'j' が ‘len(s)’ よりも大きい場合、 ‘len(s)’ を使います。 'i' が
     省略されるか ‘None’ だった場合、 ‘0’ を使います。 'j' が省略される
     か ‘None’ だった場合、 ‘len(s)’ を使います。 'i' が 'j' 以上の場合
     、スライスは空のシーケンスになります。

  5. 's' の「 'i' から 'j' まででステップが 'k' のスライス」は、インデッ
     クス ‘x = i + n*k’ （ただし n は ‘0 <= n < (j-i)/k’ を満たす任意の
     整数）を持つ要素からなるシーケンスとして定義されます。言い換えると
     インデックスは ‘i’, ‘i+k’, ‘i+2*k’, ‘i+3*k’ と続き、 'j' に達したと
     ころでストップします (ただし 'j' は含みません)。 'k' が正の数である
     場合、 'i' または 'j' が ‘len(s)’ より大きければ ‘len(s)’ を代わり
     に使用します。 'k' が負の数である場合、 'i' または 'j' が ‘len(s) -
     1’ より大きければ ‘len(s) - 1’ を代わりに使用します。 'i' または
     'j' を省略または ‘None’ を指定すると、 "端" (どちらの端かは 'k' の
     符号に依存) の値を代わりに使用します。なお 'k' はゼロにできないので
     注意してください。また 'k' に ‘None’ を指定すると、 ‘1’ が指定され
     たものとして扱われます。

  6. イミュータブルなシーケンスの結合は、常に新しいオブジェクトを返しま
     す。これは、結合の繰り返しでシーケンスを構築する実行時間コストがシ
     ーケンスの長さの合計の二次式になることを意味します。実行時間コスト
     を線形にするには、代わりに以下のいずれかにしてください:

        * *note str: 418. オブジェクトを結合するには、リストを構築して最
          後に *note str.join(): 2110. を使うか、 *note io.StringIO:
          ef3. インスタンスに書き込んで完成してから値を取得してください

        * *note bytes: 1a4. オブジェクトを結合するなら、同様に *note
          bytes.join(): 2111. や *note io.BytesIO: e6d. を使うか、 *note
          bytearray: 508. オブジェクトでインプレースに結合できます。
          *note bytearray: 508. オブジェクトはミュータブルで、効率のいい
          割り当て超過機構を備えています

        * *note tuple: 349. オブジェクトを結合するなら、代わりに *note
          list: 5dc. を拡張してください

        * その他の型については、関連するクラスのドキュメントを調べてくだ
          さい

  7. シーケンス型には、 (*note range: 911. のように) 特殊なパターンに従
     う項目のシーケンスのみをサポートするものがあり、それらはシーケンス
     の結合や繰り返しをサポートしません。

  8. ‘index’ は 'x' が 's' 中に見つからないとき *note ValueError: 1e3. を
     送出します。追加の引数 'i' と 'j' は、すべての実装がサポートしてい
     るわけではありません。追加の引数を渡すのは、おおよそ
     ‘s[i:j].index(x)’ を使うのと等価ですが、データをコピーしなくて済む
     し、返されるのはスライスの最初ではなくシーケンスの最初からの相対イ
     ンデクスです。

   ---------- Footnotes ----------

   (1) パーザが演算対象の型を識別できるようにするために、このような優先
順位でなければならないのです。


File: python.info,  Node: イミュータブルなシーケンス型,  Next: ミュータブルなシーケンス型,  Prev: 共通のシーケンス演算,  Up: シーケンス型 --- list tuple range

5.4.7.2 イミュータブルなシーケンス型
....................................

イミュータブルなシーケンス型が一般に実装している演算のうち、ミュータブル
なシーケンス型がサポートしていないのは、組み込みの *note hash(): 5b5. だ
けです。

このサポートにより、*note tuple: 349. インスタンスのようなイミュータブル
なシーケンスは、 *note dict: 237. のキーとして使え、 *note set: 5a3. や
*note frozenset: 5a4. インスタンスに保存できます。

ハッシュ不可能な値を含むイミュータブルなシーケンスをハッシュ化しようとす
ると、 *note TypeError: 502. となります。


File: python.info,  Node: ミュータブルなシーケンス型,  Next: リスト型 list<2>,  Prev: イミュータブルなシーケンス型,  Up: シーケンス型 --- list tuple range

5.4.7.3 ミュータブルなシーケンス型
..................................

以下のテーブルにある演算は、ほとんどのミュータブルなシーケンスでサポート
されています。カスタムのシーケンス型にこれらの演算を完全に実装するのが簡
単になるように、 *note collections.abc.MutableSequence: 186. ABC が提供
されています。

このテーブルで、 's' はミュータブルなシーケンス型のインスタンス、 't' は
任意のイテラブルオブジェクト、 'x' は 's' に課された型と値の条件を満たす
任意のオブジェクト (例えば、 *note bytearray: 508. は値の制限 ‘0 <= x <=
255’ に合う整数のみを受け付けます) です。

演算                               結果                                 注釈
                                                                        
--------------------------------------------------------------------------------------------------
                                                                        
‘s[i] = x’                         's' の要素 'i' を 'x' と入れ替えま
                                   す
                                   
                                                                        
‘s[i:j] = t’                       's' の 'i' から 'j' 番目までのスラ
                                   イスをイテラブル 't' の内容に入れ
                                   替えます
                                   
                                                                        
‘del s[i:j]’                       ‘s[i:j] = []’ と同じです
                                   
                                                                        
‘s[i:j:k] = t’                     ‘s[i:j:k]’ の要素を 't' の要素と入   (1)
                                   れ替えます                           
                                   
                                                                        
‘del s[i:j:k]’                     リストから ‘s[i:j:k]’ の要素を削除
                                   します
                                   
                                                                        
‘s.append(x)’                      'x' をシーケンスの最後に加えます
                                   (‘s[len(s):len(s)] = [x]’ と同じ)
                                   
                                                                        
‘s.clear()’                        's' から全ての要素を取り除きます     (5)
                                   (‘del s[:]’ と同じ)                  
                                   
                                                                        
‘s.copy()’                         's' の浅いコピーを作成します         (5)
                                   (‘s[:]’ と同じ)                      
                                   
                                                                        
‘s.extend(t)’ または ‘s += t’      's' を 't' の内容で拡張します (ほ
                                   とんど ‘s[len(s):len(s)] = t’ と同
                                   じ)
                                   
                                                                        
‘s *= n’                           's' をその内容を 'n' 回繰り返した    (6)
                                   もので更新                           
                                   
                                                                        
‘s.insert(i, x)’                   's' の 'i' で与えられたインデック
                                   スに 'x' を挿入します。 (‘s[i:i] =
                                   [x]’ と同じ)
                                   
                                                                        
‘s.pop()’ または ‘s.pop(i)’        's' から 'i' 番目の要素を取り出し    (2)
                                   、また取り除きます                   
                                   
                                                                        
‘s.remove(x)’                      's' から ‘s[i]’ が 'x' と等価とな    (3)
                                   る最初の要素を取り除きます           
                                   
                                                                        
‘s.reverse()’                      's' をインプレースに逆転させます     (4)
                                                                        

注釈:

  1. 'k' が ‘1’ と等しくない場合、 't' はそれが入れ替えるスライスと同じ
     長さでなければなりません。

  2. オプションの引数 'i' は標準で ‘-1’ なので、標準では最後の要素をリス
     トから除去して返します。

  3. ‘remove()’ は 's' に 'x' が見つからなければ *note ValueError: 1e3.
     を送出します。

  4. ‘reverse()’ メソッドは、大きなシーケンスを反転するときの容量の節約
     のため、シーケンスをインプレースに変化させます。副作用としてこの演
     算が行われることをユーザに気づかせるために、これは反転したシーケン
     スを返しません。

  5. ‘clear()’ および ‘copy()’ は、スライシング操作をサポートしないミュ
     ータブルなコンテナ (*note dict: 237. や *note set: 5a3. など) のイ
     ンターフェースとの一貫性のために含まれています。 ‘copy()’ は *note
     collections.abc.MutableSequence: 186. ABC の一部ではありませんが、
     ほとんどのミュータブルなシーケンスクラスが提供しています。

     Added in version 3.3: ‘clear()’ および ‘copy()’ メソッド。

  6. 値 'n' は整数であるか、*note __index__(): 6e8. を実装したオブジェク
     トです。 'n' の値がゼロまたは負数の場合、シーケンスをクリアします。
     *note 共通のシーケンス演算: 210e. で ‘s * n’ について説明したとおり
     、シーケンスの要素はコピーされないので注意してください; コピーでは
     なく要素に対する参照カウントが増えます。


File: python.info,  Node: リスト型 list<2>,  Next: タプル型 tuple,  Prev: ミュータブルなシーケンス型,  Up: シーケンス型 --- list tuple range

5.4.7.4 リスト型 (list)
.......................

リストはミュータブルなシーケンスで、一般的に同種の項目の集まりを格納する
ために使われます (厳密な類似の度合いはアプリケーションによって異なる場合
があります)。

 -- クラス: list ([iterable])

     リストの構成にはいくつかの方法があります:

        * 角括弧の対を使い、空のリストを表す: ‘[]’

        * 角括弧を使い、項目をカンマで区切る: ‘[a]’、‘[a, b, c]’

        * リスト内包表記を使う: ‘[x for x in iterable]’

        * 型コンストラクタを使う: ‘list()’ または ‘list(iterable)’

     コンストラクタは、 'iterable' の項目と同じ項目で同じ順のリストを構
     築します。 'iterable' は、シーケンス、イテレートをサポートするコン
     テナ、またはイテレータオブジェクトです。 'iterable' が既にリストな
     ら、 ‘iterable[:]’ と同様にコピーが作られて返されます。例えば、
     ‘list('abc')’ は ‘['a', 'b', 'c']’ を、 ‘list( (1, 2, 3) )’ は ‘[1,
     2, 3]’ を返します。引数が与えられなければ、このコンストラクタは新し
     い空のリスト ‘[]’ を作成します。

     リストを作る方法は、他にも組み込み関数 *note sorted(): b9c. などい
     ろいろあります。

     リストは *note 共通の: 210e. および *note ミュータブルの: 20c2. シ
     ーケンス演算をすべて実装します。リストは、更に以下のメソッドも提供
     します:

      -- メソッド: sort (*, key=None, reverse=False)

          このメソッドは、項目間の ‘<’ 比較のみを用いてリストをインプレ
          ースにソートします。例外は抑制されません。比較演算がどこかで失
          敗したら、ソート演算自体が失敗します (そしてリストは部分的に変
          更された状態で残されるでしょう)。

          *note sort(): b9d. は、キーワードでしか渡せない 2 つの引数
          (*note キーワード専用引数: 285.) を受け付けます:

          'key' は一引数をとる関数を指定し、リストのそれぞれの要素から比
          較キーを取り出すのに使います (例えば、 ‘key=str.lower’)。それ
          ぞれの項目に対応するキーは一度計算され、ソート処理全体に使われ
          ます。デフォルトの値 ‘None’ は、別のキー値を計算せず、リストの
          値が直接ソートされることを意味します。

          2.x 形式の 'cmp' 関数を 'key' 関数に変換するために、*note
          functools.cmp_to_key(): 11aa. ユーティリティが利用できます。

          'reverse' は真偽値です。 ‘True’ がセットされた場合、リストの要
          素は個々の比較が反転したものとして並び替えられます。

          このメソッドは、大きなシーケンスをソートするときの容量の節約の
          ため、シーケンスをインプレースに変化させます。副作用としてこの
          演算が行われることをユーザに気づかせるために、これはソートした
          シーケンスを返しません (新しいリストインスタンスを明示的に要求
          するには *note sorted(): b9c. を使ってください)。

          *note sort(): b9d. メソッドは安定していることが保証されていま
          す。ソートは、等しい要素の相対順序が変更されないことが保証され
          ていれば、安定しています。これは複数パスのソートを行なう (例え
          ば部署でソートして、それから給与の等級でソートする) のに役立ち
          ます。

          ソートの例と簡単なチュートリアルは *note ソートのテクニック:
          11ab. を参照して下さい。

          'CPython 実装の詳細:' リストがソートされている間、または変更し
          ようとする試みの影響中、あるいは検査中でさえ、リストは未定義で
          す。Python の C 実装では、それらが続いている間、リストは空とし
          て出力され、リストがソート中に変更されていることを検知できたら
          *note ValueError: 1e3. を送出します。


File: python.info,  Node: タプル型 tuple,  Next: range,  Prev: リスト型 list<2>,  Up: シーケンス型 --- list tuple range

5.4.7.5 タプル型 (tuple)
........................

タプルはイミュータブルなシーケンスで、一般的に異種のデータの集まり (組み
込みの *note enumerate(): 1424. で作られた 2-タプルなど) を格納するため
に使われます。タプルはまた、同種のデータのイミュータブルなシーケンスが必
要な場合 (*note set: 5a3. インスタンスや *note dict: 237. インスタンスに
保存できるようにするためなど) にも使われます。

 -- クラス: tuple ([iterable])

     タプルの構成にはいくつかの方法があります:

        * 丸括弧の対を使い、空のタプルを表す: ‘()’

        * カンマを使い、単要素のタプルを表す: ‘a,’ または ‘(a,)’

        * 項目をカンマで区切る: ‘a, b, c’ または ‘(a, b, c)’

        * 組み込みの *note tuple(): 349. を使う: ‘tuple()’ または
          ‘tuple(iterable)’

     コンストラクタは、 'iterable' の項目と同じ項目で同じ順のタプルを構
     築します。 'iterable' は、シーケンス、イテレートをサポートするコン
     テナ、またはイテレータオブジェクトです。 'iterable' が既にタプルな
     ら、そのまま返されます。例えば、 ‘tuple('abc')’ は ‘('a', 'b',
     'c')’ を、 ‘tuple( [1, 2, 3] )’ は ‘(1, 2, 3)’ を返します。引数が与
     えられなければ、このコンストラクタは新しい空のタプル ‘()’ を作成し
     ます。

     なお、タプルを作るのはカンマであり、丸括弧ではありません。丸括弧は
     省略可能ですが、空のタプルの場合や構文上の曖昧さを避けるのに必要な
     時は例外です。例えば、 ‘f(a, b, c)’ は三引数の関数呼び出しですが、
     ‘f((a, b, c))’ は 3-タプルを唯一の引数とする関数の呼び出しです。

     タプルは *note 共通の: 210e. シーケンス演算をすべて実装します。

異種のデータの集まりで、インデックスによってアクセスするよりも名前によっ
てアクセスしたほうが明確になるものには、単純なタプルオブジェクトよりも
*note collections.namedtuple(): 1ac. が向いているかもしれません。


File: python.info,  Node: range,  Prev: タプル型 tuple,  Up: シーケンス型 --- list tuple range

5.4.7.6 range
.............

*note range: 911. 型は、数のイミュータブルなシーケンスを表し、一般に
*note for: 2c9. ループにおいて特定の回数のループに使われます。

 -- クラス: range (stop)

 -- クラス: range (start, stop[, step])

     range コンストラクタの引数は整数 (組み込みの *note int: 238. または
     *note __index__(): 6e8. 特殊メソッドを実装するオブジェクト) でなけ
     ればなりません。'step' 引数が省略された場合のデフォルト値は ‘1’ で
     す。'start' 引数が省略された場合のデフォルト値は ‘0’ です。 'step'
     が 0 の場合、*note ValueError: 1e3. が送出されます。

     'step' が正の場合、range ‘r’ の内容は式 ‘r[i] = start + step*i’ で
     決定されます。ここで、 ‘i >= 0’ かつ ‘r[i] < stop’ です。

     'step' が負の場合も、range ‘r’ の内容は式 ‘r[i] = start + step*i’ で
     決定されます。ただし、制約条件は ‘i >= 0’ かつ ‘r[i] > stop’ です。

     ‘r[0]’ が値の制約を満たさない場合、range オブジェクトは空になります
     。range は負のインデックスをサポートしますが、これらは正のインデッ
     クスにより決定されるシーケンスの末尾からのインデックス指定として解
     釈されます。

     range は *note sys.maxsize: 1195. より大きい絶対値を含むことができ
     ますが、いくつかの機能 (*note len(): 5fa. など) は *note
     OverflowError: 84e. を送出することがあります。

     range の例:

          >>> list(range(10))
          [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
          >>> list(range(1, 11))
          [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
          >>> list(range(0, 30, 5))
          [0, 5, 10, 15, 20, 25]
          >>> list(range(0, 10, 3))
          [0, 3, 6, 9]
          >>> list(range(0, -10, -1))
          [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
          >>> list(range(0))
          []
          >>> list(range(1, 0))
          []

     range は *note 共通の: 210e. シーケンス演算を、結合と繰り返し以外す
     べて実装します (range オブジェクトは厳格なパターンに従うシーケンス
     のみを表せ、繰り返しと結合はたいていそのパターンを破るという事実に
     よります)。

      -- の属性: start

          引数 'start' の値 (この引数が与えられていない場合は ‘0’)

      -- の属性: stop

          引数 'stop' の値

      -- の属性: step

          引数 'step' の値 (この引数が与えられていない場合は ‘1’)

*note range: 911. 型が通常の *note list: 5dc. や *note tuple: 349. にま
さる点は、*note range: 911. オブジェクトがサイズや表す範囲にかかわらず常
に一定の (小さな) 量のメモリを使うことです (‘start’、‘stop’、‘step’ の値
のみを保存し、後は必要に応じて個々の項目や部分 range を計算するためです
)。

range オブジェクトは *note collections.abc.Sequence: 1194. ABC を実装し
、包含判定、要素インデックス検索、スライシングのような機能を提供し、負の
インデックスをサポートします (*note シーケンス型 -- list, tuple, range:
1bb3. を参照):

     >>> r = range(0, 20, 2)
     >>> r
     range(0, 20, 2)
     >>> 11 in r
     False
     >>> 10 in r
     True
     >>> r.index(10)
     5
     >>> r[5]
     10
     >>> r[:5]
     range(0, 10, 2)
     >>> r[-1]
     18

‘==’ および ‘!=’ による range オブジェクトの等価性の判定は、これらをシー
ケンスとして比較します。つまり、二つの range オブジェクトは同じ値のシー
ケンスを表すなら等しいとみなされます。(なお、二つの等しいとされる range
オブジェクトが異なる *note start: 2118, *note stop: 2119. および *note
step: 211a. 属性を持つことがあります。例えば ‘range(0) == range(2, 1,
3)’ や ‘range(0, 3, 2) == range(0, 4, 2)’。)

バージョン 3.2 で変更: シーケンス ABC を実装。スライスと負のインデックス
のサポート。*note int: 238. オブジェクトの帰属判定を、すべてのアイテムを
イテレートする代わりに、定数時間で行います。

バージョン 3.3 で変更: (オブジェクトの同一性に基づいて比較する代わりに)
range オブジェクトをそれらが定義する値のシーケンスに基づいて比較するよう
に '==' と '!=' を定義しました。

属性 *note start: 2118, *note stop: 2119. および *note step: 211a. が追
加。

参考
....

   * linspace レシピ(1) は浮動小数点数向けの遅延評価版 range を実装する
     方法を紹介しています。

   ---------- Footnotes ----------

   (1) 
https://code.activestate.com/recipes/579000-equally-spaced-numbers-linspace/


File: python.info,  Node: テキストシーケンス型 --- str,  Next: バイナリシーケンス型 --- bytes bytearray memoryview,  Prev: シーケンス型 --- list tuple range,  Up: 組み込み型

5.4.8 テキストシーケンス型 -- ‘str’
-----------------------------------

Python のテキストデータは *note str: 418. オブジェクト、すなわち '文字列
' として扱われます。文字列は Unicode コードポイントのイミュータブルな
*note シーケンス: 1bb3. です。文字列リテラルには様々な記述方法があります
:

   * シングルクォート: ‘'"ダブル" クォートを埋め込むことができます'’

   * ダブルクォート: ‘"'シングル' クォートを埋め込むことができます"’。

   * 三重引用符: ‘'''三つのシングルクォート'''’, ‘"""三つのダブルクォー
     ト"""’

三重引用符文字列は、複数行に分けることができます。関連付けられる空白はす
べて文字列リテラルに含まれます。

単式の一部であり間に空白のみを含む文字列リテラルは、一つの文字列リテラル
に暗黙に変換されます。つまり、‘("spam " "eggs") == "spam eggs"’ です。

サポートされている *note エスケープシーケンス: 426. や、ほとんどのエスケ
ープシーケンスの処理を無効化する ‘r’ ("raw") 接頭辞など、文字列リテラル
のさまざまな形式についての詳細は *note 文字列およびバイト列リテラル:
1e06. を参照してください。

文字列は他のオブジェクトに *note str: 418. コンストラクタを使うことでも
生成できます。

"character" 型が特別に用意されているわけではないので、文字列のインデック
ス指定を行うと長さ 1 の文字列を作成します。つまり、空でない文字列 's' に
対し、‘s[0] == s[0:1]’ です。

ミュータブルな文字列型もありませんが、ミュータブルな断片から効率よく文字
列を構成するのに *note str.join(): 2110. や *note io.StringIO: ef3. が使
えます。

バージョン 3.3 で変更: Python 2 シリーズとの後方互換性のため、文字列リテ
ラルの ‘u’ 接頭辞が改めて許可されました。それは文字列リテラルとしての意
味には影響がなく、 ‘r’ 接頭辞と結合することはできません。

 -- クラス: str (object='')

 -- クラス: str (object=b'', encoding='utf-8', errors='strict')

     'object' の *note 文字列: 1b67. 版を返します。 'object' が与えられ
     なかった場合、空文字列が返されます。それ以外の場合 ‘str()’ の動作は
     、 'encoding' や 'errors' が与えられたかどうかによって次のように変
     わります。

     'encoding' も 'errors' も与えられない場合、 ‘str(object)’ は "形式
     ばらず"、 表示用にきれいに整えられた 'object' の文字列表現である
     *note type(object).__str__(object): 5e9. を返します。文字列オブジェ
     クトに対しては、文字列そのものです。 'object' が *note __str__():
     5e9. メソッドを持たない場合、 *note str(): 418. は代わりに *note
     repr(object): 7c8. の結果を返します。

     'encoding' か 'errors' の少なくとも一方が与えられた場合、 'object'
     は *note bytes-like object: cfb. (たとえば *note bytes: 1a4. や
     *note bytearray: 508.) でなくてはなりません。'object' が *note
     bytes: 1a4. (もしくは *note bytearray: 508.) オブジェクトである場合
     は、 ‘str(bytes, encoding, errors)’ は *note bytes.decode(encoding,
     errors): 8a4. と等価です。そうでない場合は、 *note bytes.decode():
     8a4. が呼ばれる前に buffer オブジェクトの下層にある bytes オブジェ
     クトが取得されます。 buffer オブジェクトについて詳しい情報は、
     *note バイナリシーケンス型 -- bytes, bytearray, memoryview: 20c4. や
     *note バッファプロトコル (buffer Protocol): 371. を参照してください
     。

     'encoding' 引数や 'errors' 引数無しに *note bytes: 1a4. オブジェク
     トを *note str(): 418. に渡すと、略式の文字列表現を返す 1 つ目の場
     合に該当します。(Python のコマンドラインオプション *note -b: 5ad. も
     参照してください) 例えば:

          >>> str(b'Zoot!')
          "b'Zoot!'"

     ‘str’ クラスとそのメソッドについて詳しくは、 *note
     テキストシーケンス型 — str: 1b67. や *note 文字列メソッド: 1b68. の
     節を参照してください。フォーマットされた文字列を出力するには、
     *note f-strings: 977. と *note カスタムの文字列書式化: 211c. の節を
     参照してください。加えて、 *note テキスト処理サービス: 211d. の節も
     参照してください。

* Menu:

* 文字列メソッド: 文字列メソッド<2>.
* printf 形式の文字列書式化::


File: python.info,  Node: 文字列メソッド<2>,  Next: printf 形式の文字列書式化,  Up: テキストシーケンス型 --- str

5.4.8.1 文字列メソッド
......................

文字列は *note 共通の: 210e. シーケンス演算全てに加え、以下に述べるメソ
ッドを実装します。

文字列は、二形式の文字列書式化をサポートします。一方は柔軟さが高くカスタ
マイズできます (*note str.format(): 5ed.、 *note 書式指定文字列の文法:
1358. 、および *note カスタムの文字列書式化: 211c. を参照してください)。
他方は C 言語の ‘printf’ 形式の書式化に基づいてより狭い範囲と型を扱うも
ので、正しく扱うのは少し難しいですが、扱える場合ではたいていこちらのほう
が高速です (*note printf 形式の文字列書式化: 698.)。

標準ライブラリの *note テキスト処理サービス: 211f. 節は、その他テキスト
に関する様々なユーティリティ (*note re: a7. モジュールによる正規表現サポ
ートなど) を提供するいくつかのモジュールをカバーしています。

 -- メソッド: str.capitalize ()

     最初の文字を大文字にし、残りを小文字にした文字列のコピーを返します
     。

     バージョン 3.8 で変更: 最初の文字が大文字ではなくタイトルケースに置
     き換えられるようになりました。つまり二重音字のような文字はすべての
     文字が大文字にされるのではなく、最初の文字だけ大文字にされるように
     なります。

 -- メソッド: str.casefold ()

     文字列の casefold されたコピーを返します。casefold された文字列は、
     大文字小文字に関係ないマッチに使えます。

     casefold は、小文字化と似ていますが、より積極的です。これは文字列の
     大文字小文字の区別をすべて取り去ることを意図しているためです。例え
     ば、ドイツ語の小文字 ‘'ß'’ は ‘"ss"’ と同じです。これは既に小文字な
     ので、*note lower(): 1758. は ‘'ß'’ に何もしませんが、*note
     casefold(): da3. はこれを ‘"ss"’ に変換します。

     casefold のアルゴリズムは、 Unicode 標準の 3.13 章 'Default Case
     Folding' に説明されています(1) 。

     Added in version 3.3.

 -- メソッド: str.center (width[, fillchar])

     'width' の長さをもつ中央寄せされた文字列を返します。パディングには
     'fillchar' で指定された値 (デフォルトでは ASCII スペース) が使われ
     ます。 'width' が ‘len(s)’ 以下なら元の文字列が返されます。

 -- メソッド: str.count (sub[, start[, end]])

     ['start', 'end'] の範囲に、部分文字列 'sub' が重複せず出現する回数
     を返します。オプション引数 'start' および 'end' はスライス表記と同
     じように解釈されます。

     'sub' が空の場合は、文字と文字の間にある空文字列の数、すなわち文字
     列の長さに1を加えたものを返します。

 -- メソッド: str.encode (encoding='utf-8', errors='strict')

     *note bytes: 1a4. にエンコードされた文字列を返します。

     'encoding' のデフォルト値は ‘'utf-8'’ です; 指定可能な値については
     *note 標準エンコーディング: d86. を参照してください。

     'errors' はエンコーディングエラーをどのように取り扱うかを制御します
     。 ‘'strict'’ (デフォルト) では *note UnicodeError: 1275. 例外が送
     出されます。そのほかに指定可能な値は ‘'ignore'’, ‘'replace'’,
     ‘'xmlcharrefreplace'’, ‘'backslashreplace'’ と、そして *note
     codecs.register_error(): 143e. で登録された名前です。詳しくは *note
     エラーハンドラ: 1751. を参照してください。

     パフォーマンス上の理由から、 'errors' の値の妥当性は、エンコーディ
     ングエラーが実際に発生するか、 *note Python 開発モード: 1d9. が有効
     になっているか、もしくは *note デバッグビルド: 1da. が使われていな
     い限りチェックされません。

     バージョン 3.1 で変更: キーワード引数のサポートが追加されました。

     バージョン 3.9 で変更: 'errors' 引数の値は *note Python 開発モード:
     1d9. と *note デバッグモード: 1da. でチェックされるようになりました
     。

 -- メソッド: str.endswith (suffix[, start[, end]])

     文字列が指定された 'suffix' で終わるなら ‘True’ を、そうでなければ
     ‘False’ を返します。 'suffix' は見つけたい複数の接尾語のタプルでも
     構いません。オプションの 'start' があれば、その位置から判定を始めま
     す。オプションの 'end' があれば、その位置で比較を止めます。

 -- メソッド: str.expandtabs (tabsize=8)

     文字列内の全てのタブ文字が 1 つ以上のスペースで置換された、文字列の
     コピーを返します。スペースの数は現在の桁 (column) 位置と 'tabsize'
     に依存します。タブ位置は 'tabsize' 文字毎に存在します (デフォルト値
     である 8 の場合、タブ位置は 0, 8, 16 などになります)。文字列を展開
     するため、まず現桁位置がゼロにセットされ、文字列が 1 文字ずつ調べら
     れます。文字がタブ文字 (‘\t’) であれば、現桁位置が次のタブ位置と一
     致するまで、1 つ以上のスペースが結果の文字列に挿入されます。(タブ文
     字自体はコピーされません。) 文字が改行文字 (‘\n’ もしくは ‘\r’) の
     場合、文字がコピーされ、現桁位置は 0 にリセットされます。その他の文
     字は変更されずにコピーされ、現桁位置は、その文字の表示のされ方 (訳
     注: 全角、半角など) に関係なく、1 ずつ増加します。

          >>> '01\t012\t0123\t01234'.expandtabs()
          '01      012     0123    01234'
          >>> '01\t012\t0123\t01234'.expandtabs(4)
          '01  012 0123    01234'

 -- メソッド: str.find (sub[, start[, end]])

     文字列のスライス ‘s[start:end]’ に部分文字列 'sub' が含まれる場合、
     その最小のインデックスを返します。オプション引数 'start' および
     'end' はスライス表記と同様に解釈されます。 'sub' が見つからなかった
     場合 ‘-1’ を返します。

          注釈: *note find(): e71. メソッドは、 'sub' の位置を知りたいと
          きにのみ使うべきです。 'sub' が部分文字列であるかどうかのみを
          調べるには、 *note in: 2cb. 演算子を使ってください:

               >>> 'Py' in 'Python'
               True

 -- メソッド: str.format (*args, **kwargs)

     文字列の書式化操作を行います。このメソッドを呼び出す文字列は通常の
     文字、または、 ‘{}’ で区切られた置換フィールドを含みます。それぞれ
     の置換フィールドは位置引数のインデックスナンバー、または、キーワー
     ド引数の名前を含みます。返り値は、それぞれの置換フィールドが対応す
     る引数の文字列値で置換された文字列のコピーです。

          >>> "The sum of 1 + 2 is {0}".format(1+2)
          'The sum of 1 + 2 is 3'

     書式指定のオプションについては、書式指定文字列を規定する *note
     書式指定文字列の文法: 1358. を参照してください。

          注釈: 数値 (*note int: 238, *note float: 2ce, *note complex:
          2cf, *note decimal.Decimal: 27d. とサブクラス) を ‘n’ の整数表
          現型 (例: ‘'{:n}'.format(1234)’) でフォーマットするとき、
          ‘LC_CTYPE’ ロケールと ‘LC_NUMERIC’ ロケールの一方または両方が
          1 バイトより長い非 ASCII 文字であると同時に異なる値である場合
          、この関数は ‘localeconv()’ の ‘decimal_point’ と
          ‘thousands_sep’ フィールドを読み取るため一時的に ‘LC_CTYPE’ ロ
          ケールに ‘LC_NUMERIC’ のロケール値を設定します。この一時的な変
          更は他のスレッドの動作に影響します。

     バージョン 3.7 で変更: 数値を ‘n’ の整数表現型でフォーマットすると
     き、この関数は一時的に ‘LC_CTYPE’ ロケールに ‘LC_NUMERIC’ のロケー
     ル値を設定する場合があります。

 -- メソッド: str.format_map (mapping, /)

     ‘str.format(**mapping)’ と似ていますが、 ‘mapping’ は *note dict:
     237. にコピーされず、直接使われます。これは例えば ‘mapping’ が dict
     のサブクラスであるときに便利です:

          >>> class Default(dict):
          ...     def __missing__(self, key):
          ...         return key
          ...
          >>> '{name} was born in {country}'.format_map(Default(name='Guido'))
          'Guido was born in country'

     Added in version 3.2.

 -- メソッド: str.index (sub[, start[, end]])

     *note find(): e71. と同様ですが、部分文字列が見つからなかったとき
     *note ValueError: 1e3. を送出します。

 -- メソッド: str.isalnum ()

     文字列中の全ての文字が英数字で、かつ 1 文字以上あるなら ‘True’ を、
     そうでなければ ‘False’ を返します。文字 ‘c’ は以下のいずれかが
     ‘True’ を返せば英数字です: ‘c.isalpha()’ 、 ‘c.isdecimal()’ 、
     ‘c.isdigit()’ 、 ‘c.isnumeric()’ 。

 -- メソッド: str.isalpha ()

     文字列中のすべての文字がアルファベットで、かつ文字列が1文字以上であ
     るならば ‘True’ を返します。それ以外は ‘False’ を返します。ここでア
     ルファベットとは Unicode 文字列データベースで "Letter" として定義さ
     れているもの、すなわち、一般カテゴリプロパティ "Lm", "Lt", "Lu",
     "Ll", または "Lo" のいずれかをもつ文字です。なお、この定義は
     Unicode 標準 の 4.10 章 'Letters, Alphabetic, and Ideographic' で定
     義されているアルファベットプロパティ(2) とは異なります。

 -- メソッド: str.isascii ()

     文字列が空であるか、文字列の全ての文字が ASCII である場合に ‘True’
     を、それ以外の場合に ‘False’ を返します。 ASCII 文字のコードポイン
     トは U+0000-U+007F の範囲にあります。

     Added in version 3.7.

 -- メソッド: str.isdecimal ()

     文字列中の全ての文字が十進数字で、かつ 1 文字以上あるなら ‘True’ を
     、そうでなければ ‘False’ を返します。十進数字とは十進数を書くのに使
     われる文字のことで、たとえば U+0660 (ARABIC-INDIC DIGIT ZERO) など
     も含みます。正式には、Unicode の一般カテゴリ "Nd" に含まれる文字を
     指します。

 -- メソッド: str.isdigit ()

     文字列中の全ての文字が数字で、かつ 1 文字以上あるなら ‘True’ を、そ
     うでなければ ‘False’ を返します。ここでの数字とは、十進数字に加えて
     、互換上付き数字のような特殊操作を必要とする数字を含みます。また 10
     を基数とした表現ができないカローシュティー数字のような体系の文字も
     含みます。正式には、数字とは、プロパティ値 Numeric_Type=Digit また
     は Numeric_Type=Decimal を持つ文字です。

 -- メソッド: str.isidentifier ()

     文字列が、 *note 識別子 (identifier) およびキーワード (keyword):
     1df6. 節の言語定義における有効な識別子であれば ‘True’ を返します。

     *note keyword.iskeyword(): 2126. は、文字列 ‘s’ が *note def: 13ff.
     や *note class: 12a5. のような予約済みの識別子かどうかを調べるのに
     使うことができます。

     例:

          >>> from keyword import iskeyword

          >>> 'hello'.isidentifier(), iskeyword('hello')
          (True, False)
          >>> 'def'.isidentifier(), iskeyword('def')
          (True, True)

 -- メソッド: str.islower ()

     文字列中の大小文字の区別のある文字 (3) 全てが小文字で、かつ大小文字
     の区別のある文字が 1 文字以上あるなら ‘True’ を、そうでなければ
     ‘False’ を返します。

 -- メソッド: str.isnumeric ()

     文字列中の全ての文字が数を表す文字で、かつ 1 文字以上あるなら
     ‘True’ を、そうでなければ ‘False’ を返します。数を表す文字は、数字
     と、Unicode の数値プロパティを持つ全ての文字を含みます。たとえば
     U+2155 (VULGAR FRACTION ONE FIFTH)。正式には、数を表す文字は、プロ
     パティ値 Numeric_Type=Digit、 Numeric_Type=Decimal または
     Numeric_Type=Numeric を持つものです。

 -- メソッド: str.isprintable ()

     文字列中のすべての文字が印字可能であるか、文字列が空であれば ‘True’
     を、そうでなければ ‘False’ を返します。非印字可能文字は、 Unicode 文
     字データベースで "Other" または "Separator" と定義されている文字の
     、印字可能と見なされる ASCII space (0x20) 以外のものです。(なお、こ
     の文脈での印字可能文字は、文字列に *note repr(): 7c8. が呼び出され
     るときにエスケープすべきでない文字のことです。これは *note
     sys.stdout: aa4. や *note sys.stderr: 907. に書き込まれる文字列の操
     作とは関係ありません。)

 -- メソッド: str.isspace ()

     文字列が空白文字だけからなり、かつ 1 文字以上ある場合には ‘True’ を
     返し、そうでない場合は ‘False’ を返します。

     Unicode 文字データベース (*note unicodedata: ee. を参照) で一般カテ
     ゴリが ‘Zs’ ("Seperator, space") であるか、 双方向クラスが　‘WS’、
     ‘B’、 ‘S’ のいずれかである場合、その文字は '空白文字(whitespace)' で
     す。

 -- メソッド: str.istitle ()

     文字列がタイトルケース文字列であり、かつ 1 文字以上ある場合、例えば
     大文字は大小文字の区別のない文字の後にのみ続き、小文字は大小文字の
     区別のある文字の後ろにのみ続く場合には ‘True’ を返します。そうでな
     い場合は ‘False’ を返します。

 -- メソッド: str.isupper ()

     文字列中の大小文字の区別のある文字 (4) 全てが大文字で、かつ大小文字
     の区別のある文字が 1 文字以上あるなら ‘True’ を、そうでなければ
     ‘False’ を返します。

          >>> 'BANANA'.isupper()
          True
          >>> 'banana'.isupper()
          False
          >>> 'baNana'.isupper()
          False
          >>> ' '.isupper()
          False

 -- メソッド: str.join (iterable)

     'iterable' 中の文字列を結合した文字列を返します。 'iterable' に
     *note bytes: 1a4. オブジェクトのような非文字列の値が存在するなら、
     *note TypeError: 502. が送出されます。要素間のセパレータは、このメ
     ソッドを提供する文字列です。

 -- メソッド: str.ljust (width[, fillchar])

     長さ 'width' の左揃えした文字列を返します。パディングは指定された
     'fillchar' (デフォルトでは ASCII スペース) を使って行われます。
     'width' が ‘len(s)’ 以下ならば、元の文字列が返されます。

 -- メソッド: str.lower ()

     全ての大小文字の区別のある文字 (5) が小文字に変換された、文字列のコ
     ピーを返します。

     小文字化のアルゴリズムは Unicode Standardの 3.13 章 'Default Case
     Folding' で説明されています(6)。

 -- メソッド: str.lstrip ([chars])

     文字列の先頭の文字を除去したコピーを返します。引数 'chars' は除去さ
     れる文字の集合を指定する文字列です。 'chars' が省略されるか ‘None’
     の場合、空白文字が除去されます。 'chars' 文字列は接頭辞ではなく、そ
     の値に含まれる文字の組み合わせ全てがはぎ取られます:

          >>> '   spacious   '.lstrip()
          'spacious   '
          >>> 'www.example.com'.lstrip('cmowz.')
          'example.com'

     文字の集合全てではなく、指定した文字列そのものを接頭辞として削除す
     るメソッドについては、 *note str.removeprefix(): 89d. を参照してく
     ださい。使用例:

          >>> 'Arthur: three!'.lstrip('Arthur: ')
          'ee!'
          >>> 'Arthur: three!'.removeprefix('Arthur: ')
          'three!'

 -- メソッド: static str.maketrans (x[, y[, z]])

     この静的メソッドは *note str.translate(): 212d. に使える変換テーブ
     ルを返します。

     引数を 1 つだけ与える場合、それは Unicode 序数 (整数) または文字 (長
     さ 1 の文字列) を、Unicode 序数、(任意長の) 文字列、または ‘None’ に
     対応づける辞書でなければなりません。このとき、文字で指定したキーは
     序数に変換されます。

     引数を 2 つ指定する場合、それらは同じ長さの文字列である必要があり、
     結果の辞書では、x のそれぞれの文字が y の同じ位置の文字に対応付けら
     れます。第 3 引数を指定する場合、文字列を指定する必要があり、それに
     含まれる文字が ‘None’ に対応付けられます。

 -- メソッド: str.partition (sep)

     文字列を 'sep' の最初の出現位置で区切り、 3 要素のタプルを返します
     。タプルの内容は、区切りの前の部分、区切り文字列そのもの、そして区
     切りの後ろの部分です。もし区切れなければ、タプルには元の文字列その
     ものとその後ろに二つの空文字列が入ります。

 -- メソッド: str.removeprefix (prefix, /)

     文字列が 'prefix' で始まる場合、 ‘string[len(prefix):]’ を返します
     。それ以外の場合、元の文字列のコピーを返します:

          >>> 'TestHook'.removeprefix('Test')
          'Hook'
          >>> 'BaseTestCase'.removeprefix('Test')
          'BaseTestCase'

     Added in version 3.9.

 -- メソッド: str.removesuffix (suffix, /)

     文字列が 'suffix' で終わる場合、 ‘string[:-len(suffix)]’ を返します
     。それ以外の場合、元の文字列のコピーを返します:

          >>> 'MiscTests'.removesuffix('Tests')
          'Misc'
          >>> 'TmpDirMixin'.removesuffix('Tests')
          'TmpDirMixin'

     Added in version 3.9.

 -- メソッド: str.replace (old, new, count=-1)

     文字列中にあらわれる部分文字列 'old' を全て 'new' に置き換えた、文
     字列のコピーを返します。 'count' が与えられた場合、先頭から 'count'
     で指定された数の部分文字列だけを置き換えます。 'count' の指定がない
     か、または ‘-1’ が与えられた場合、全ての部分文字列が置き換えられま
     す。

     バージョン 3.13 で変更: 'count' はキーワード引数として指定可能にな
     りました。

 -- メソッド: str.rfind (sub[, start[, end]])

     文字列中の領域 ‘s[start:end]’ に 'sub' が含まれる場合、その最大のイ
     ンデックスを返します。オプション引数 'start' および 'end' はスライ
     ス表記と同様に解釈されます。 'sub' が見つからなかった場合 ‘-1’ を返
     します。

 -- メソッド: str.rindex (sub[, start[, end]])

     *note rfind(): e72. と同様ですが、 'sub' が見つからなかった場合
     *note ValueError: 1e3. を送出します。

 -- メソッド: str.rjust (width[, fillchar])

     'width' の長さをもつ右寄せした文字列を返します。パディングには
     'fillchar' で指定された文字(デフォルトでは ASCII スペース)が使われ
     ます。 'width' が ‘len(s)’ 以下の場合、元の文字列が返されます。

 -- メソッド: str.rpartition (sep)

     文字列を 'sep' の最後の出現位置で区切り、 3 要素のタプルを返します
     。タプルの内容は、区切りの前の部分、区切り文字列そのもの、そして区
     切りの後ろの部分です。もし区切れなければ、タプルには二つの空文字列
     とその後ろに元の文字列そのものが入ります。

 -- メソッド: str.rsplit (sep=None, maxsplit=-1)

     'sep' を区切り文字とした、文字列中の単語のリストを返します。
     'maxsplit' が与えられた場合、文字列の '右端' から最大 'maxsplit' 回
     分割を行います。'sep' が指定されていない、あるいは ‘None’ のとき、
     全ての空白文字が区切り文字となります。右から分割していくことを除け
     ば、 *note rsplit(): 1227. は後ほど詳しく述べる *note split(): e73.
     と同様に振る舞います。

 -- メソッド: str.rstrip ([chars])

     文字列の末尾部分を除去したコピーを返します。引数 'chars' は除去され
     る文字集合を指定する文字列です。 'chars' が省略されるか ‘None’ の場
     合、空白文字が除去されます。 'chars' 文字列は接尾語ではなく、そこに
     含まれる文字の組み合わせ全てがはぎ取られます:

          >>> '   spacious   '.rstrip()
          '   spacious'
          >>> 'mississippi'.rstrip('ipz')
          'mississ'

     文字の集合全てではなく、指定した文字列そのものを接尾辞として削除す
     るメソッドについては *note str.removesuffix(): 89e. を参照してくだ
     さい。使用例:

          >>> 'Monty Python'.rstrip(' Python')
          'M'
          >>> 'Monty Python'.removesuffix(' Python')
          'Monty'

 -- メソッド: str.split (sep=None, maxsplit=-1)

     文字列を 'sep' をデリミタ文字列として区切った単語のリストを返します
     。'maxsplit' が与えられていれば、最大で 'maxsplit' 回分割されます
     (つまり、リストは最大 ‘maxsplit+1’ 要素になります)。 'maxsplit' が
     与えられないか ‘-1’ なら、分割の回数に制限はありません (可能なだけ
     分割されます)。

     'sep' が与えられた場合、連続した区切り文字はまとめられず、空の文字
     列を区切っていると判断されます(例えば ‘'1,,2'.split(',')’ は ‘['1',
     '', '2']’ を返します)。引数 'sep' は複数の文字を1つの区切り文字にも
     できます (複数の区切り文字で分割するには *note re.split(): 282. を
     使用します)。区切り文字を指定して空の文字列を分割すると、 ‘['']’ を
     返します。

     例えば:

          >>> '1,2,3'.split(',')
          ['1', '2', '3']
          >>> '1,2,3'.split(',', maxsplit=1)
          ['1', '2,3']
          >>> '1,2,,3,'.split(',')
          ['1', '2', '', '3', '']
          >>> '1<>2<>3<4'.split('<>')
          ['1', '2', '3<4']

     'sep' が指定されていないか ‘None’ の場合、異なる分割アルゴリズムが
     適用されます。連続する空白文字はひとつのデリミタとみなされます。ま
     た、文字列の先頭や末尾に空白があっても、結果の最初や最後に空文字列
     は含まれません。よって、空文字列や空白だけの文字列を ‘None’ デリミ
     タで分割すると ‘[]’ が返されます。

     例えば:

          >>> '1 2 3'.split()
          ['1', '2', '3']
          >>> '1 2 3'.split(maxsplit=1)
          ['1', '2 3']
          >>> '   1   2   3   '.split()
          ['1', '2', '3']

 -- メソッド: str.splitlines (keepends=False)

     文字列を改行部分で分解し、各行からなるリストを返します。 'keepends'
     に真が与えらない限り、返されるリストに改行は含まれません。

     このメソッドは以下の行境界で分解します。特に、以下の境界は *note
     universal newlines: d08. のスーパーセットです。

     表現                        説明
                                 
     --------------------------------------------------------------
                                 
     ‘\n’                        改行
                                 
                                 
     ‘\r’                        復帰
                                 
                                 
     ‘\r\n’                      改行 + 復帰
                                 
                                 
     ‘\v’ or ‘\x0b’              垂直タブ
                                 
                                 
     ‘\f’ or ‘\x0c’              改ページ
                                 
                                 
     ‘\x1c’                      ファイル区切り
                                 
                                 
     ‘\x1d’                      グループ区切り
                                 
                                 
     ‘\x1e’                      レコード区切り
                                 
                                 
     ‘\x85’                      改行 (C1 制御コード)
                                 
                                 
     ‘\u2028’                    行区切り
                                 
                                 
     ‘\u2029’                    段落区切り
                                 

     バージョン 3.2 で変更: ‘\v’ と ‘\f’ が行境界のリストに追加されまし
     た。

     例えば:

          >>> 'ab c\n\nde fg\rkl\r\n'.splitlines()
          ['ab c', '', 'de fg', 'kl']
          >>> 'ab c\n\nde fg\rkl\r\n'.splitlines(keepends=True)
          ['ab c\n', '\n', 'de fg\r', 'kl\r\n']

     *note split(): e73. とは違って、デリミタ文字列 'sep' が与えられたと
     き、このメソッドは空文字列に空リストを返し、終末の改行は結果に行を
     追加しません:

          >>> "".splitlines()
          []
          >>> "One line\n".splitlines()
          ['One line']

     比較のために ‘split('\n')’ は以下のようになります:

          >>> ''.split('\n')
          ['']
          >>> 'Two lines\n'.split('\n')
          ['Two lines', '']

 -- メソッド: str.startswith (prefix[, start[, end]])

     文字列が指定された 'prefix' で始まるなら ‘True’ を、そうでなければ
     ‘False’ を返します。 'prefix' は見つけたい複数の接頭語のタプルでも
     構いません。オプションの 'start' があれば、その位置から判定を始めま
     す。オプションの 'end' があれば、その位置で比較を止めます。

 -- メソッド: str.strip ([chars])

     文字列の先頭および末尾部分を除去したコピーを返します。引数 'chars'
     は除去される文字集合を指定する文字列です。 'chars' が省略されるか
     ‘None’ の場合、空白文字が除去されます。 'chars' 文字列は接頭語でも
     接尾語でもなく、そこに含まれる文字の組み合わせ全てがはぎ取られます:

          >>> '   spacious   '.strip()
          'spacious'
          >>> 'www.example.com'.strip('cmowz.')
          'example'

     文字列の最も外側の先頭および末尾から、引数 'chars' 値がはぎ取られま
     す。文字列の先頭から 'chars' の文字集合に含まれない文字に達するまで
     、文字が削除されます。文字列の末尾に対しても同様の操作が行われます
     。例えば、次のようになります:

          >>> comment_string = '#....... Section 3.2.1 Issue #32 .......'
          >>> comment_string.strip('.#! ')
          'Section 3.2.1 Issue #32'

 -- メソッド: str.swapcase ()

     大文字が小文字に、小文字が大文字に変換された、文字列のコピーを返し
     ます。なお、 ‘s.swapcase().swapcase() == s’ が真であるとは限りませ
     ん。

 -- メソッド: str.title ()

     文字列を、単語ごとに大文字から始まり、残りの文字のうち大小文字の区
     別があるものは全て小文字にする、タイトルケースにして返します。

     例えば:

          >>> 'Hello world'.title()
          'Hello World'

     このアルゴリズムは、連続した文字の集まりという、言語から独立した単
     純な単語の定義を使います。この定義は多くの状況ではうまく機能します
     が、短縮形や所有格のアポストロフィが単語の境界になってしまい、望み
     の結果を得られない場合があります:

          >>> "they're bill's friends from the UK".title()
          "They'Re Bill'S Friends From The Uk"

     *note string.capwords(): 2130. 関数は単語をスペースでのみ分割するた
     め、この問題はありません。

     または、正規表現を使うことでアポストロフィに対応できます:

          >>> import re
          >>> def titlecase(s):
          ...     return re.sub(r"[A-Za-z]+('[A-Za-z]+)?",
          ...                   lambda mo: mo.group(0).capitalize(),
          ...                   s)
          ...
          >>> titlecase("they're bill's friends.")
          "They're Bill's Friends."

 -- メソッド: str.translate (table)

     与えられた変換テーブルに基づいて文字列を構成する各文字をマッピング
     し、マッピング後の文字列のコピーを返します。変換テーブルは、*note
     __getitem__(): 264. によるインデックス指定を実装するオブジェクトで
     ある必要があります。一般的には、 *note mapping: 118c. または *note
     sequence: 4be. です。Unicode 序数 (整数) でインデックス指定する場合
     、変換テーブルのオブジェクトは次のいずれも行うことができます。
     Unicode 序数または文字列を返して文字を 1 文字以上の別の文字にマッピ
     ングすること、‘None’ を返して返り値の文字列から指定した文字を削除す
     ること、例外 *note LookupError: 2131. を送出して文字をその文字自身
     にマッピングすること。

     文字から文字への異なる形式のマッピングから変換マップを作成するため
     に、 *note str.maketrans(): da6. が使えます。

     文字のマッピングを好みに合わせてより柔軟に変更する方法については、
     *note codecs: 14. モジュールも参照してください。

 -- メソッド: str.upper ()

     全ての大小文字の区別のある文字 (7) が大文字に変換された、文字列のコ
     ピーを返します。なお ‘s.upper().isupper()’ は、 ‘s’ が大小文字の区
     別のある文字を含まなかったり、結果の文字の Unicode カテゴリが "Lu"
     ではなく例えば "Lt" (Letter, titlecase) などであったら、 ‘False’ に
     なりえます。

     大文字化のアルゴリズムは Unicode 標準の 3.13 章 'Default Case
     Folding' で説明されています(8) 。

 -- メソッド: str.zfill (width)

     長さが 'width' になるよう ASCII ‘'0'’ で左詰めした文字列のコピーを
     返します。先頭が符号接頭辞 (‘'+'’/‘'-'’) だった場合、 ‘'0'’ は符号
     の前ではなく '後' に挿入されます。'width' が ‘len(s)’ 以下の場合元
     の文字列を返します。

     例えば:

          >>> "42".zfill(5)
          '00042'
          >>> "-42".zfill(5)
          '-0042'

   ---------- Footnotes ----------

   (1) https://www.unicode.org/versions/Unicode15.1.0/ch03.pdf

   (2) https://www.unicode.org/versions/Unicode15.1.0/ch04.pdf

   (3) 大小文字の区別のある文字とは、一般カテゴリプロパティが "Lu"
(Letter, uppercase (大文字))、 "Ll" (Letter, lowercase (小文字))、 "Lt"
(Letter、titlecase (先頭が大文字)) のいずれかであるものです。

   (4) 大小文字の区別のある文字とは、一般カテゴリプロパティが "Lu"
(Letter, uppercase (大文字))、 "Ll" (Letter, lowercase (小文字))、 "Lt"
(Letter、titlecase (先頭が大文字)) のいずれかであるものです。

   (5) 大小文字の区別のある文字とは、一般カテゴリプロパティが "Lu"
(Letter, uppercase (大文字))、 "Ll" (Letter, lowercase (小文字))、 "Lt"
(Letter、titlecase (先頭が大文字)) のいずれかであるものです。

   (6) https://www.unicode.org/versions/Unicode15.1.0/ch03.pdf

   (7) 大小文字の区別のある文字とは、一般カテゴリプロパティが "Lu"
(Letter, uppercase (大文字))、 "Ll" (Letter, lowercase (小文字))、 "Lt"
(Letter、titlecase (先頭が大文字)) のいずれかであるものです。

   (8) https://www.unicode.org/versions/Unicode15.1.0/ch03.pdf


File: python.info,  Node: printf 形式の文字列書式化,  Prev: 文字列メソッド<2>,  Up: テキストシーケンス型 --- str

5.4.8.2 ‘printf’ 形式の文字列書式化
...................................

     注釈: ここで解説されているフォーマット操作には、(タプルや辞書を正し
     く表示するのに失敗するなどの) よくある多くの問題を引き起こす、様々
     な欠陥が出現します。 新しい *note フォーマット済み文字列リテラル:
     977. や *note str.format(): 5ed. インターフェースや *note
     テンプレート文字列: 2134. が、これらの問題を回避する助けになるでし
     ょう。 これらの代替手段には、それ自身に、トレードオフや、簡潔さ、柔
     軟さ、拡張性といった利点があります。

文字列オブジェクトには独特の組み込み演算子: ‘%’ 演算子 (モジュロ) があり
ます。これは 文字列の '書式化' あるいは '補間' 演算子としても知られてい
ます。 ‘format % values’ ('format' は文字列とします) が与えられると、
'format' の中の ‘%’ による変換の指定は0こ以上の 'values' の要素で置き換
えられます。この動作は C 言語における ‘sprintf()’ 関数の利用方法に似てい
ます。使用例:

     >>> print('%s has %d quote types.' % ('Python', 2))
     Python has 2 quote types.

'format' が単一の引数しか要求しない場合、 'values' はタプルでない単一の
オブジェクトでもかまいません。 (1) それ以外の場合、 'values' はフォーマ
ット文字列中で指定された項目と正確に同じ数の要素からなるタプルか、単一の
マップオブジェクトでなければなりません。

一つの変換指定子は 2 またはそれ以上の文字を含み、その構成要素は以下から
なりますが、示した順に出現しなければなりません:

  1. 指定子の開始を示す文字 ‘'%'’ 。

  2. マップキー (オプション)。丸括弧で囲った文字列からなります (例えば
     ‘(somename)’) 。

  3. 変換フラグ (オプション)。一部の変換型の結果に影響します。

  4. 最小のフィールド幅 (オプション)。 ‘'*'’ (アスタリスク) を指定した場
     合、実際の文字列幅が 'values' タプルの次の要素から読み出されます。
     タプルには最小フィールド幅やオプションの精度指定の後に変換したいオ
     ブジェクトがくるようにします。

  5. 精度 (オプション)。 ‘'.'’ (ドット) とその後に続く精度で与えられます
     。 ‘'*'’ (アスタリスク) を指定した場合、精度の桁数は 'values' タプ
     ルの次の要素から読み出されます。タプルには精度指定の後に変換したい
     値がくるようにします。

  6. 精度長変換子 (オプション)。

  7. 変換型。

‘%’ 演算子の右側の引数が辞書の場合 (またはその他のマップ型の場合), 文字
列中のフォーマットには、辞書に挿入されているキーを丸括弧で囲い、文字
‘'%'’ の直後にくるようにしたものが含まれていなければ 'なりません' 。マッ
プキーはフォーマット化したい値をマップから選び出します。例えば:

     >>> print('%(language)s has %(number)03d quote types.' %
     ...       {'language': "Python", "number": 2})
     Python has 002 quote types.

この場合、 ‘*’ 指定子をフォーマットに含めてはいけません (‘*’ 指定子は順
番付けされたパラメタのリストが必要だからです)。

変換フラグ文字を以下に示します:

Flag          意味
              
----------------------------------------------------------------------------------------
              
‘'#'’         値の変換に (下で定義されている) "別の形式" を使います。
              
              
‘'0'’         数値型に対してゼロによるパディングを行います。
              
              
‘'-'’         変換された値を左寄せにします (‘'0'’ と同時に与えた場合、 ‘'0'’ を上書き
              します) 。
              
              
‘' '’         (スペース) 符号付きの変換で正の数の場合、前に一つスペースを空けます (そ
              うでない場合は空文字になります) 。
              
              
‘'+'’         変換の先頭に符号文字 (‘'+'’ または ‘'-'’) を付けます("スペース" フラグ
              を上書きします) 。
              

精度長変換子(‘h’, ‘l’,または ‘L’) を使うことができますが、 Python では必
要ないため無視されます。 - つまり、例えば ‘%ld’ は ‘%d’ と等価です。

変換型を以下に示します:

変換             意味                                                      注釈
                                                                           
---------------------------------------------------------------------------------------
                                                                           
‘'d'’            符号付き 10 進整数。
                 
                                                                           
‘'i'’            符号付き 10 進整数。
                 
                                                                           
‘'o'’            符号付き 8 進数。                                         (1)
                                                                           
                                                                           
‘'u'’            旧式の型 - ‘'d'’ と同じです。                             (6)
                                                                           
                                                                           
‘'x'’            符号付き 16 進数 (小文字)。                               (2)
                                                                           
                                                                           
‘'X'’            符号付き 16 進数 (大文字)。                               (2)
                                                                           
                                                                           
‘'e'’            指数表記の浮動小数点数 (小文字)。                         (3)
                                                                           
                                                                           
‘'E'’            指数表記の浮動小数点数 (大文字)。                         (3)
                                                                           
                                                                           
‘'f'’            10 進浮動小数点数。                                       (3)
                                                                           
                                                                           
‘'F'’            10 進浮動小数点数。                                       (3)
                                                                           
                                                                           
‘'g'’            浮動小数点数。指数部が -4 以上または精度以下の場合には    (4)
                 小文字指数表記、それ以外の場合には10進表記。              
                 
                                                                           
‘'G'’            浮動小数点数。指数部が -4 以上または精度以下の場合には    (4)
                 大文字指数表記、それ以外の場合には10進表記。              
                 
                                                                           
‘'c'’            文字一文字 (整数または一文字からなる文字列を受理します
                 )。
                 
                                                                           
‘'r'’            文字列 (Python オブジェクトを *note repr(): 7c8. で変換   (5)
                 します)。                                                 
                 
                                                                           
‘'s'’            文字列 (Python オブジェクトを *note str(): 418. で変換    (5)
                 します)。                                                 
                 
                                                                           
‘'a'’            文字列 (Python オブジェクトを *note ascii(): 138e. で変   (5)
                 換します)。                                               
                 
                                                                           
‘'%'’            引数を変換せず、返される文字列中では文字 ‘'%'’ になりま
                 す。
                 

注釈:

  1. 別の形式を指定（訳注: 変換フラグ ‘#’ を使用）すると 8 進数を表す接
     頭辞 (‘'0o'’) が最初の数字の前に挿入されます。

  2. 別の形式を指定（訳注: 変換フラグ ‘#’ を使用）すると 16 進数を表す接
     頭辞 ‘'0x'’ または ‘'0X'’ (使用するフォーマット文字が ‘'x'’ か
     ‘'X'’ に依存します) が最初の数字の前に挿入されます。

  3. この形式にした場合、変換結果には常に小数点が含まれ、それはその後ろ
     に数字が続かない場合にも適用されます。

     指定精度は小数点の後の桁数を決定し、そのデフォルトは 6 です。

  4. この形式にした場合、変換結果には常に小数点が含まれ他の形式とは違っ
     て末尾の 0 は取り除かれません。

     指定精度は小数点の前後の有効桁数を決定し、そのデフォルトは 6 です。

  5. 精度が ‘N’ なら、出力は ‘N’ 文字に切り詰められます。

  6. PEP 237(2) を参照してください。

Python 文字列には明示的な長さ情報があるので、 ‘%s’ 変換において ‘'\0'’ を
文字列の末端と仮定したりはしません。

バージョン 3.1 で変更: 絶対値が 1e50 を超える数値の ‘%f’ 変換が ‘%g’ 変
換に置き換えられなくなりました。

   ---------- Footnotes ----------

   (1) 従って、一個のタプルだけをフォーマット出力したい場合には出力した
いタプルを唯一の要素とする単一のタプルを 'values' に与えなくてはなりませ
ん。

   (2) https://peps.python.org/pep-0237/


File: python.info,  Node: バイナリシーケンス型 --- bytes bytearray memoryview,  Next: set（集合）型 --- set frozenset,  Prev: テキストシーケンス型 --- str,  Up: 組み込み型

5.4.9 バイナリシーケンス型 -- ‘bytes’, ‘bytearray’, ‘memoryview’
----------------------------------------------------------------

バイナリデータを操作するためのコア組み込み型は *note bytes: 1a4. および
*note bytearray: 508. です。これらは、別のバイナリオブジェクトのメモリに
コピーを作成すること無くアクセスするための *note バッファプロトコル:
371. を利用する *note memoryview: 435. でサポートされています。

*note array: 6. モジュールは、32 ビット整数や IEEE754 倍精度浮動小数点値
のような基本データ型の、効率的な保存をサポートしています。

* Menu:

* バイトオブジェクト::
* bytearray オブジェクト::
* bytes と bytearray の操作::
* printf 形式での bytes の書式化::
* メモリビュー::


File: python.info,  Node: バイトオブジェクト,  Next: bytearray オブジェクト,  Up: バイナリシーケンス型 --- bytes bytearray memoryview

5.4.9.1 バイトオブジェクト
..........................

bytes はバイトの不変なシーケンスです。多くのメジャーなプロトコルが
ASCIIテキストエンコーディングをベースにしているので、 bytes オブジェクト
は ASCII 互換のデータに対してのみ動作する幾つかのメソッドを提供していて
、文字列オブジェクトと他の多くの点で近いです。

 -- クラス: bytes ([source[, encoding[, errors]]])

     まず、 bytes リテラルの構文は文字列リテラルとほぼ同じで、 ‘b’ とい
     うプリフィックスを付けます:

        * シングルクォート: ‘b'still allows embedded "double" quotes'’

        * ダブルクォート: ‘b"still allows embedded 'single' quotes"’.

        * 3重クォート: ‘b'''3 single quotes'''’, ‘b"""3 double
          quotes"""’

     bytes リテラルでは (ソースコードのエンコーディングに関係なく)
     ASCII文字のみが許可されています。 127より大きい値を bytes リテラル
     に記述する場合は適切なエスケープシーケンスを書く必要があります。

     文字列リテラルと同じく、 bytes リテラルでも ‘r’ プリフィックスを用
     いてエスケープシーケンスの処理を無効にすることができます。 bytes リ
     テラルの様々な形式やサポートされているエスケープシーケンスについて
     は *note 文字列およびバイト列リテラル: 1e06. を参照してください。

     bytesリテラルと repr 出力は ASCII テキストをベースにしたものですが
     、 bytes オブジェクトは、各値が ‘0 <= x < 256’ の範囲に収まるような
     整数 (この制限に違反しようとすると *note ValueError: 1e3. が発生し
     ます) の不変なシーケンスとして振る舞います。多くのバイナリフォーマ
     ットがASCIIテキストを元にした要素を持っていたり何らかのテキスト操作
     アルゴリズムによって操作されるものの、任意のバイナリデータが一般に
     テキストになっているわけではないことを強調するためにこのように設計
     されました (何も考えずにテキスト操作アルゴリズムをASCII非互換なバイ
     ナリデータフォーマットに対して行うとデータを破壊することがあります
     )。

     リテラル以外に、幾つかの方法で bytes オブジェクトを作ることができま
     す:

        * 指定された長さの、0で埋められた bytes オブジェクト:
          ‘bytes(10)’

        * 整数の iterable から: ‘bytes(range(20))’

        * 既存のバイナリデータからバッファプロトコルでコピーする:
          ‘bytes(obj)’

     *note bytes: 1a24. ビルトイン関数も参照してください。

     16 進数で 2 桁の数は正確に 1 バイトに相当するため、16 進整はバイナ
     リデータを表現する形式として広く使われています。 従って、 bytes 型
     にはその形式でデータを読み取るための追加のクラスメソッドがあります
     。

      -- メソッド: classmethod fromhex (string)

          この *note bytes: 1a4. のクラスメソッドは、与えられた文字列オ
          ブジェクトをデコードして bytes オブジェクトを返します。それぞ
          れのバイトを 16 進数 2 桁で表現した文字列を指定しなければなり
          ません。ASCII 空白文字は無視されます。

               >>> bytes.fromhex('2Ef0 F1f2  ')
               b'.\xf0\xf1\xf2'

          バージョン 3.7 で変更: *note bytes.fromhex(): abd. は文字列に
          ある空白だけでなく、 ASCII の空白文字全てをスキップするように
          なりました。

     bytes オブジェクトをその 16 進表記に変換するための、反対向きの変換
     関数があります。

      -- メソッド: hex ([sep[, bytes_per_sep]])

          インスタンス内の 1 バイトにつき 2 つの 16 進数を含む、文字列オ
          ブジェクトを返します。

               >>> b'\xf0\xf1\xf2'.hex()
               'f0f1f2'

          16進数文字列を読みやすく表示したい場合、単一文字パラメータ
          'sep' を指定してセパレータを出力に含めることができます。デフォ
          ルトでは、セパレータはバイトごとに表示が区切られるように追加さ
          れます。2つ目のオプションパラメータ 'bytes_per_sep' はセパレー
          タを入れる間隔を制御します。正の整数値はセパレータの位置を右か
          ら計算し、負の整数値は左から計算します。

               >>> value = b'\xf0\xf1\xf2'
               >>> value.hex('-')
               'f0-f1-f2'
               >>> value.hex('_', 2)
               'f0_f1f2'
               >>> b'UUDDLRLRAB'.hex(' ', -4)
               '55554444 4c524c52 4142'

          Added in version 3.5.

          バージョン 3.8 で変更: *note bytes.hex(): d36. が、16進数出力
          の各バイトを分割するセパレータを挿入するためのオプションパラメ
          ータ 'sep' と 'bytes_per_sep' をサポートするようになりました。

bytes オブジェクトは (タプルに似た) 整数のシーケンスなので、 bytes オブ
ジェクト 'b' について、 ‘b[0]’ は整数になり、 ‘b[0:1]’ は長さ 1 の bytes
オブジェクトになります。 (この動作は、文字列に対するインデックス指定もス
ライスも長さ 1 の文字列を返すのと対照的です。)

bytes オブジェクトの repr 出力はリテラル形式 (‘b'...'’) になります。
‘bytes([46, 46, 46])’ などの形式よりも便利な事が多いからです。 bytes オ
ブジェクトはいつでも ‘list(b)’ で整数のリストに変換できます。


File: python.info,  Node: bytearray オブジェクト,  Next: bytes と bytearray の操作,  Prev: バイトオブジェクト,  Up: バイナリシーケンス型 --- bytes bytearray memoryview

5.4.9.2 bytearray オブジェクト
..............................

*note bytearray: 508. オブジェクトは *note bytes: 1a4. オブジェクトの可
変なバージョンです。

 -- クラス: bytearray ([source[, encoding[, errors]]])

     bytearray に専用のリテラル構文はないので、コンストラクタを使って作
     成します:

        * 空のインスタンスを作る: ‘bytearray()’

        * 指定された長さの0で埋められたインスタンスを作る:
          ‘bytearray(10)’

        * 整数の iterable から: ‘bytearray(range(20))’

        * 既存のバイナリデータからバッファプロトコルを通してコピーする:
          ‘bytearray(b'Hi!')’

     bytearray オブジェクトは可変なので、 *note bytes と bytearray
     の操作: 20c3. で解説されている bytes オブジェクトと共通の操作に加え
     て、 *note mutable: 20c2. シーケンス操作もサポートしています。

     *note bytearray: 1a25. ビルトイン関数も参照してください。

     16 進数で 2 桁の数は正確に 1 バイトに相当するため、16 進整はバイナ
     リデータを表現する形式として広く使われています。 従って、 bytearray
     型にはその形式でデータを読み取るための追加のクラスメソッドがありま
     す。

      -- メソッド: classmethod fromhex (string)

          この *note bytearray: 508. のクラスメソッドは、与えられた文字
          列オブジェクトをデコードして bytearray オブジェクトを返します
          。それぞれのバイトを 16 進数 2 桁で表現した文字列を指定しなけ
          ればなりません。ASCII 空白文字は無視されます。

               >>> bytearray.fromhex('2Ef0 F1f2  ')
               bytearray(b'.\xf0\xf1\xf2')

          バージョン 3.7 で変更: *note bytearray.fromhex(): abe. は文字
          列にある空白だけでなく、 ASCII の空白文字全てをスキップするよ
          うになりました。

     bytearray オブジェクトをその 16 進表記に変換するための、反対向きの
     変換関数があります。

      -- メソッド: hex ([sep[, bytes_per_sep]])

          インスタンス内の 1 バイトにつき 2 つの 16 進数を含む、文字列オ
          ブジェクトを返します。

               >>> bytearray(b'\xf0\xf1\xf2').hex()
               'f0f1f2'

          Added in version 3.5.

          バージョン 3.8 で変更: *note bytes.hex(): d36. と同様に、
          *note bytearray.hex(): d37. が、16進数出力の各バイトを分割する
          セパレータを挿入するためのオプションパラメータ 'sep' と
          'bytes_per_sep' をサポートするようになりました。

bytearray オブジェクトは整数のシーケンス (リストのようなもの) なので、
bytearray オブジェクト 'b' について、 ‘b[0]’ は整数になり、 ‘b[0:1]’ は
長さ 1 の bytearray オブジェクトになります。(これは、文字列においてイン
デックス指定もスライスも長さ 1 の文字列を返すのと対照的です。)

bytearray オブジェクトの表記はバイトのリテラル形式 (‘bytearray(b'...')’)
を使用します。これは ‘bytearray([46, 46, 46])’ などの形式よりも便利な事
が多いためです。 bytearray オブジェクトはいつでも ‘list(b)’ で整数のリス
トに変換できます。


File: python.info,  Node: bytes と bytearray の操作,  Next: printf 形式での bytes の書式化,  Prev: bytearray オブジェクト,  Up: バイナリシーケンス型 --- bytes bytearray memoryview

5.4.9.3 bytes と bytearray の操作
.................................

bytes と bytearray は両方共 *note 一般のシーケンス操作: 210e. をサポート
しています。また、両方とも *note bytes-like object: cfb. をサポートして
いる任意のオブジェクトを対象に操作することもできます。この柔軟性により
bytes と bytearray を自由に混ぜてもエラーを起こすことなく扱うことができ
ます。ただし、操作の結果のオブジェクトはその操作の順序に依存することにな
ります。

     注釈: 文字列のメソッドが引数として bytes を受け付けないのと同様、
     bytes オブジェクトと bytearray オブジェクトのメソッドは引数として文
     字列を受け付けません。例えば、以下のように書かなければなりません:

          a = "abc"
          b = a.replace("a", "f")

     および:

          a = b"abc"
          b = a.replace(b"a", b"f")

いくつかの bytes と bytearray の操作は ASCII と互換性のあるバイナリフォ
ーマットが使われていると仮定していますので、フォーマットの不明なバイナリ
データに対して使うことは避けるべきです。こうした制約については以下で説明
します。

     注釈: これらの ASCII ベースの演算を使って ASCII ベースではないバイ
     ナリデータを操作すると、データを破壊する恐れがあります。

以下の bytes および bytearray オブジェクトのメソッドは、任意のバイナリデ
ータに対して使用できます。

 -- メソッド: bytes.count (sub[, start[, end]])
 -- メソッド: bytearray.count (sub[, start[, end]])

     ['start', 'end'] の範囲に、部分シーケンス 'sub' が重複せず出現する
     回数を返します。オプション引数 'start' および 'end' はスライス表記
     と同じように解釈されます。

     検索対象の部分シーケンスは、任意の *note bytes-like object: cfb. ま
     たは 0 から 255 の範囲の整数にできます。

     'sub' が空の場合は、文字と文字の間にある空のスライスの数、すなわち
     bytesオブジェクトの長さに1を加えたものを返します。

     バージョン 3.3 で変更: 部分シーケンスとして 0 から 255 の範囲の整数
     も受け取れるようになりました。

 -- メソッド: bytes.removeprefix (prefix, /)
 -- メソッド: bytearray.removeprefix (prefix, /)

     バリナリーデータが文字列 'prefix' で始まる場合、
     ‘bytes[len(prefix):]’ を返します。それ以外の場合、元のバイナリーデ
     ータのコピーを返します:

          >>> b'TestHook'.removeprefix(b'Test')
          b'Hook'
          >>> b'BaseTestCase'.removeprefix(b'Test')
          b'BaseTestCase'

     'prefix' は、任意の *note bytes-like object: cfb. にできます。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

     Added in version 3.9.

 -- メソッド: bytes.removesuffix (suffix, /)
 -- メソッド: bytearray.removesuffix (suffix, /)

     バイナリーデータが文字列 'suffix' で終わり、 'suffix' が空でない場
     合、 ‘bytes[:-len(suffix)]’ を返します。それ以外の場合、元のバイナ
     リーデータのコピーを返します:

          >>> b'MiscTests'.removesuffix(b'Tests')
          b'Misc'
          >>> b'TmpDirMixin'.removesuffix(b'Tests')
          b'TmpDirMixin'

     'suffix' は、任意の *note bytes-like object: cfb. にできます。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

     Added in version 3.9.

 -- メソッド: bytes.decode (encoding='utf-8', errors='strict')
 -- メソッド: bytearray.decode (encoding='utf-8', errors='strict')

     *note str: 418. にデコードされたbytesを返します。

     'encoding' のデフォルト値は ‘'utf-8'’ です; 指定可能な値については
     *note 標準エンコーディング: d86. を参照してください。

     'errors' はデコーディングエラーをどのように取り扱うかを制御します。
     ‘'strict'’ (デフォルト) では *note UnicodeError: 1275. 例外が送出さ
     れます。そのほかに指定可能な値は ‘'ignore'’, ‘'replace'’ と、そして
     *note codecs.register_error(): 143e. で登録された名前です。詳しくは
     *note エラーハンドラ: 1751. を参照してください。

     パフォーマンス上の理由から、 'errors' の値の妥当性は、デコーディン
     グエラーが実際に発生するか、 *note Python 開発モード: 1d9. が有効に
     なっているか、もしくは *note デバッグビルド: 1da. が使われていない
     限りチェックされません。

          注釈: 引数 'encoding' を *note str: 418. に渡すと *note
          bytes-like object: cfb. を直接デコードすることができます。つま
          り、一時的な ‘bytes’ や ‘bytearray’ オブジェクトを作成する必要
          はありません。

     バージョン 3.1 で変更: キーワード引数のサポートが追加されました。

     バージョン 3.9 で変更: 'errors' 引数の値は *note Python 開発モード:
     1d9. と *note デバッグモード: 1da. でチェックされるようになりました
     。

 -- メソッド: bytes.endswith (suffix[, start[, end]])
 -- メソッド: bytearray.endswith (suffix[, start[, end]])

     バイナリデータが指定された 'suffix' で終わる場合は ‘True’ を、そう
     でなければ ‘False’ を返します。 'suffix' は見つけたい複数の接尾語の
     タプルでも構いません。オプションの 'start' が指定されている場合、そ
     の位置から判定を開始します。オプションの 'end' が指定されている場合
     、その位置で比較を終了します。

     検索対象の接尾語 (複数も可) は、任意の *note bytes-like object:
     cfb. にできます。

 -- メソッド: bytes.find (sub[, start[, end]])
 -- メソッド: bytearray.find (sub[, start[, end]])

     スライス ‘s[start:end]’ に部分シーケンス 'sub' が含まれる場合、デー
     タ中のその 'sub' の最小のインデックスを返します。オプション引数
     'start' および 'end' はスライス表記と同様に解釈されます。 'sub' が
     見つからなかった場合、 ‘-1’ を返します。

     検索対象の部分シーケンスは、任意の *note bytes-like object: cfb. ま
     たは 0 から 255 の範囲の整数にできます。

          注釈: *note find(): 17a8. メソッドは、 'sub' の位置を知りたい
          ときにのみ使うべきです。 'sub' が部分文字列 (訳注: おそらく原
          文の誤り、正しくは部分シーケンス) であるかどうかのみを調べるに
          は、 *note in: 2cb. 演算子を使ってください:

               >>> b'Py' in b'Python'
               True

     バージョン 3.3 で変更: 部分シーケンスとして 0 から 255 の範囲の整数
     も受け取れるようになりました。

 -- メソッド: bytes.index (sub[, start[, end]])
 -- メソッド: bytearray.index (sub[, start[, end]])

     *note find(): 17a8. と同様ですが、部分シーケンスが見つからなかった
     場合 *note ValueError: 1e3. を送出します。

     検索対象の部分シーケンスは、任意の *note bytes-like object: cfb. ま
     たは 0 から 255 の範囲の整数にできます。

     バージョン 3.3 で変更: 部分シーケンスとして 0 から 255 の範囲の整数
     も受け取れるようになりました。

 -- メソッド: bytes.join (iterable)
 -- メソッド: bytearray.join (iterable)

     'iterable' 中のバイナリデータを結合した bytes または bytearray オブ
     ジェクトを返します。 'iterable' に *note str: 418. オブジェクトなど
     *note bytes-like objects: cfb. ではない値が含まれている場合、 *note
     TypeError: 502. が送出されます。なお要素間のセパレータは、このメソ
     ッドを提供する bytes または bytearray オブジェクトとなります。

 -- メソッド: static bytes.maketrans (from, to)
 -- メソッド: static bytearray.maketrans (from, to)

     この静的メソッドは、 *note bytes.translate(): 2146. に渡すのに適し
     た変換テーブルを返します。このテーブルは、 'from' 中の各バイトを
     'to' の同じ位置にあるバイトにマッピングします。 'from' と 'to' は両
     方とも同じ長さの *note bytes-like objects: cfb. でなければなりませ
     ん。

     Added in version 3.1.

 -- メソッド: bytes.partition (sep)
 -- メソッド: bytearray.partition (sep)

     区切り 'sep' が最初に出現する位置でシーケンスを分割し、 3 要素のタ
     プルを返します。タプルの内容は、区切りの前の部分、その区切りオブジ
     ェクトまたはその bytearray 型のコピー、そして区切りの後ろの部分です
     。もし区切りが見つからなければ、タプルには元のシーケンスのコピーと
     、その後ろに二つの空の bytes または bytearray オブジェクトが入りま
     す。

     検索する区切りとしては、任意の *note bytes-like object: cfb. を指定
     できます。

 -- メソッド: bytes.replace (old, new[, count])
 -- メソッド: bytearray.replace (old, new[, count])

     部分シーケンス 'old' を全て 'new' に置換したシーケンスを返します。
     オプション引数 'count' が与えられている場合、先頭から 'count' 個の
     'old' だけを置換します。

     検索する部分シーケンスおよび置換後の部分シーケンスとしては、任意の
     *note bytes-like object: cfb. を指定できます。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.rfind (sub[, start[, end]])
 -- メソッド: bytearray.rfind (sub[, start[, end]])

     シーケンス中の領域 ‘s[start:end]’ に 'sub' が含まれる場合、その最大
     のインデックスを返します。オプション引数 'start' および 'end' はス
     ライス表記と同様に解釈されます。 'sub' が見つからなかった場合 ‘-1’
     を返します。

     検索対象の部分シーケンスは、任意の *note bytes-like object: cfb. ま
     たは 0 から 255 の範囲の整数にできます。

     バージョン 3.3 で変更: 部分シーケンスとして 0 から 255 の範囲の整数
     も受け取れるようになりました。

 -- メソッド: bytes.rindex (sub[, start[, end]])
 -- メソッド: bytearray.rindex (sub[, start[, end]])

     *note rfind(): 17a9. と同様ですが、部分シーケンス 'sub' が見つから
     なかった場合 *note ValueError: 1e3. を送出します。

     検索対象の部分シーケンスは、任意の *note bytes-like object: cfb. ま
     たは 0 から 255 の範囲の整数にできます。

     バージョン 3.3 で変更: 部分シーケンスとして 0 から 255 の範囲の整数
     も受け取れるようになりました。

 -- メソッド: bytes.rpartition (sep)
 -- メソッド: bytearray.rpartition (sep)

     区切り 'sep' が最後に出現する位置でシーケンスを分割し、 3 要素のタ
     プルを返します。タプルの内容は、区切りの前の部分、その区切りオブジ
     ェクトまたはその bytearray 型のコピー、そして区切りの後ろの部分です
     。もし区切れなければ、タプルには二つの空の bytes または bytearray オ
     ブジェクトと、その後ろに元のシーケンスのコピーが入ります。

     検索する区切りとしては、任意の *note bytes-like object: cfb. を指定
     できます。

 -- メソッド: bytes.startswith (prefix[, start[, end]])
 -- メソッド: bytearray.startswith (prefix[, start[, end]])

     バイナリデータが指定された 'prefix' で始まる場合は ‘True’ を、そう
     でなければ ‘False’ を返します。 'prefix' は見つけたい複数の接頭語の
     タプルでも構いません。オプションの 'start' が指定されている場合、そ
     の位置から判定を開始します。オプションの 'end' が指定されている場合
     、その位置で比較を終了します。

     検索対象の接頭語 (複数も可) は、任意の *note bytes-like object:
     cfb. にできます。

 -- メソッド: bytes.translate (table, /, delete=b'')
 -- メソッド: bytearray.translate (table, /, delete=b'')

     オプション引数 'delete' に現れるすべてのバイトを除去し、残ったバイ
     トを与えられた変換テーブルに従ってマップした、バイト列やバイト配列
     オブジェクトのコピーを返します。変換テーブルは長さ 256 のバイト列オ
     ブジェクトでなければなりません。

     変換テーブルの作成に、 *note bytes.maketrans(): 1246. メソッドを使
     うこともできます。

     文字を削除するだけの変換には、 'table' 引数を ‘None’ に設定してくだ
     さい:

          >>> b'read this short text'.translate(None, b'aeiou')
          b'rd ths shrt txt'

     バージョン 3.6 で変更: 'delete' はキーワード引数として指定可能にな
     りました。

以下の bytes および bytearray オブジェクトのメソッドは、 ASCII と互換性
のあるバイナリフォーマットが使われていると仮定していますが、適切な引数を
指定すれば任意のバイナリデータに使用できます。なお、このセクションで紹介
する bytearray のメソッドはすべてインプレースで動作 'せず' 、新しいオブ
ジェクトを生成します。

 -- メソッド: bytes.center (width[, fillbyte])
 -- メソッド: bytearray.center (width[, fillbyte])

     長さ 'width' の中央寄せされたシーケンスのコピーを返します。パディン
     グには 'fillbyte' で指定された値 (デフォルトでは ASCII スペース) が
     使われます。 *note bytes: 1a4. オブジェクトの場合、 'width' が
     ‘len(s)’ 以下なら元のシーケンスが返されます。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.ljust (width[, fillbyte])
 -- メソッド: bytearray.ljust (width[, fillbyte])

     長さ 'width' の左寄せされたシーケンスのコピーを返します。パディング
     には 'fillbyte' で指定された値 (デフォルトでは ASCII スペース) が使
     われます。 *note bytes: 1a4. オブジェクトの場合、 'width' が
     ‘len(s)’ 以下なら元のシーケンスが返されます。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.lstrip ([chars])
 -- メソッド: bytearray.lstrip ([chars])

     先頭から特定のバイト値を除去したコピーを返します。引数 'chars' は除
     去されるバイト値の集合を指定するバイナリシーケンスです － この名前
     は、このメソッドが通常は ASCII 文字列に対して使われることに由来して
     います。 'chars' が省略されるか ‘None’ の場合、 ASCII の空白文字 (訳
     注: 空白文字の定義については *note bytearray.isspace(): 2158. を参
     照) が除去されます。なお 'chars' 引数と一致する接頭辞が除去されるの
     ではなく、それに含まれるバイトの組み合わせ全てが除去されます:

          >>> b'   spacious   '.lstrip()
          b'spacious   '
          >>> b'www.example.com'.lstrip(b'cmowz.')
          b'example.com'

     削除したいバイト値のバイナリシーケンスには、 *note bytes-like
     object: cfb. を指定することができます。バイナリシーケンスで指定した
     文字の集合全てではなく、指定した文字列そのものを接頭辞として削除す
     るメソッドについては、 *note removeprefix(): 213b. を参照してくださ
     い。使用例:

          >>> b'Arthur: three!'.lstrip(b'Arthur: ')
          b'ee!'
          >>> b'Arthur: three!'.removeprefix(b'Arthur: ')
          b'three!'

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.rjust (width[, fillbyte])
 -- メソッド: bytearray.rjust (width[, fillbyte])

     長さ 'width' の右寄せされたシーケンスのコピーを返します。パディング
     には 'fillbyte' で指定された値 (デフォルトでは ASCII スペース) が使
     われます。 *note bytes: 1a4. オブジェクトの場合、 'width' が
     ‘len(s)’ 以下なら元のシーケンスが返されます。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.rsplit (sep=None, maxsplit=-1)
 -- メソッド: bytearray.rsplit (sep=None, maxsplit=-1)

     'sep' を区切りとして、同じ型の部分シーケンスに分割します。
     'maxsplit' が与えられた場合、シーケンスの '右端' から最大
     'maxsplit' 回だけ分割を行います。 'sep' が指定されていないか ‘None’
     のとき、 ASCII 空白文字の組み合わせで作られる部分シーケンスすべてが
     区切りとなります。右から分割していくことを除けば、 *note rsplit():
     215c. は後ほど詳しく述べる *note split(): 215d. と同様に振る舞いま
     す。

 -- メソッド: bytes.rstrip ([chars])
 -- メソッド: bytearray.rstrip ([chars])

     末尾から特定のバイト値を除去したコピーを返します。引数 'chars' は除
     去されるバイト値の集合を指定するバイナリシーケンスです － この名前
     は、このメソッドが通常は ASCII 文字列に対して使われることに由来して
     います。 'chars' が省略されるか ‘None’ の場合、 ASCII の空白文字 (訳
     注: 空白文字の定義については *note bytearray.isspace(): 2158. を参
     照) が除去されます。なお 'chars' 引数と一致する接尾辞が除去されるの
     ではなく、それに含まれるバイトの組み合わせ全てが除去されます:

          >>> b'   spacious   '.rstrip()
          b'   spacious'
          >>> b'mississippi'.rstrip(b'ipz')
          b'mississ'

     削除したいバイト値のバイナリシーケンスには、 *note bytes-like
     object: cfb. を指定することができます。バイナリシーケンスで指定した
     文字の集合全てではなく、指定した文字列そのものを接尾辞として削除す
     るメソッドについては、 *note removesuffix(): 213d. を参照してくださ
     い。使用例:

          >>> b'Monty Python'.rstrip(b' Python')
          b'M'
          >>> b'Monty Python'.removesuffix(b' Python')
          b'Monty'

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.split (sep=None, maxsplit=-1)
 -- メソッド: bytearray.split (sep=None, maxsplit=-1)

     'sep' を区切りとして、同じ型の部分シーケンスに分割します。
     'maxsplit' が与えられ、かつ負の数でない場合、シーケンスの '左端' か
     ら最大 'maxsplit' 回だけ分割を行います (したがって結果のリストの要
     素数は最大で ‘maxsplit+1’ になります)。 'maxsplit' が指定されていな
     いか ‘-1’ のとき、分割の回数に制限はありません (可能なだけ分割され
     ます)。

     'sep' が与えられた場合、連続した区切り用バイト値はまとめられず、空
     の部分シーケンスを区切っていると判断されます(例えば
     ‘b'1,,2'.split(b',')’ は ‘[b'1', b'', b'2']’ を返します)。引数
     'sep' は複数バイトのシーケンスを1つの区切り文字にもできます。空のシ
     ーケンスを分割すると、分割するオブジェクトの型によって ‘[b'']’ また
     は ‘[bytearray(b'')]’ が返ります。引数 'sep' には、あらゆる *note
     bytes-like object: cfb. を指定できます。

     例えば:

          >>> b'1,2,3'.split(b',')
          [b'1', b'2', b'3']
          >>> b'1,2,3'.split(b',', maxsplit=1)
          [b'1', b'2,3']
          >>> b'1,2,,3,'.split(b',')
          [b'1', b'2', b'', b'3', b'']
          >>> b'1<>2<>3<4'.split(b'<>')
          [b'1', b'2', b'3<4']

     'sep' が指定されていないか ‘None’ の場合、異なる分割アルゴリズムが
     適用されます。連続する ASCII 空白文字はひとつの区切りとみなされ、ま
     たシーケンスの先頭や末尾に空白があっても、結果の最初や最後に空のシ
     ーケンスは含まれません。したがって区切りを指定せずに空のシーケンス
     や ASCII 空白文字だけのシーケンスを分割すると、 ‘[]’ が返されます。

     例えば:

          >>> b'1 2 3'.split()
          [b'1', b'2', b'3']
          >>> b'1 2 3'.split(maxsplit=1)
          [b'1', b'2 3']
          >>> b'   1   2   3   '.split()
          [b'1', b'2', b'3']

 -- メソッド: bytes.strip ([chars])
 -- メソッド: bytearray.strip ([chars])

     先頭および末尾から特定のバイト値を除去したコピーを返します。引数
     'chars' は除去されるバイト値の集合を指定するバイナリシーケンスです
     － この名前は、このメソッドが通常は ASCII 文字列に対して使われるこ
     とに由来しています。 'chars' が省略されるか ‘None’ の場合、 ASCII の
     空白文字 (訳注: 空白文字の定義については *note bytearray.isspace():
     2158. を参照) が除去されます。なお 'chars' 引数と一致する接頭辞およ
     び接尾辞が除去されるのではなく、それに含まれるバイトの組み合わせ全
     てが除去されます:

          >>> b'   spacious   '.strip()
          b'spacious'
          >>> b'www.example.com'.strip(b'cmowz.')
          b'example'

     除去対象のバイト値を含むバイナリシーケンスには、任意の *note
     bytes-like object: cfb. を指定できます。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

以下の bytes および bytearray オブジェクトのメソッドは、 ASCII と互換性
のあるバイナリフォーマットが使われていると仮定しており、任意のバイナリデ
ータに対して使用すべきではありません。なお、このセクションで紹介する
bytearray のメソッドはすべてインプレースで動作 'せず' 、新しいオブジェク
トを生成します。

 -- メソッド: bytes.capitalize ()
 -- メソッド: bytearray.capitalize ()

     各バイトを ASCII 文字と解釈して、最初のバイトを大文字にし、残りを小
     文字にしたシーケンスのコピーを返します。 ASCII 文字と解釈できないバ
     イト値は、変更されません。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.expandtabs (tabsize=8)
 -- メソッド: bytearray.expandtabs (tabsize=8)

     桁 (column) 位置と指定されたタブ幅 (tab size) に応じて、全ての
     ASCII タブ文字を 1 つ以上の ASCII スペース文字に置換したシーケンス
     のコピーを返します。ここで 'tabsize' バイトごとの桁位置をタブ位置と
     します (デフォルト値である 8 の場合、タブ位置は 0 桁目、 8 桁目、
     16 桁目、と続いていきます)。シーケンスを展開するにあたって、まず現
     桁位置をゼロに設定し、シーケンスを 1 バイトずつ調べていきます。もし
     バイト値が ASCII タブ文字 (‘b'\t'’) であれば、現桁位置が次のタブ位
     置と一致するまで 1 つ以上の ASCII スペース文字を結果のシーケンスに
     挿入していきます（ASCII タブ文字自体はコピーしません）。もしバイト
     値が ASCII 改行文字 (‘b'\n'’ もしくは ‘b'\r'’) であれば、そのままコ
     ピーした上で現桁位置を 0 にリセットします。その他のバイト値について
     は変更せずにコピーし、そのバイト値の表示のされ方（訳注: 全角、半角
     など）に関わらず現桁位置を 1 つ増加させます:

          >>> b'01\t012\t0123\t01234'.expandtabs()
          b'01      012     0123    01234'
          >>> b'01\t012\t0123\t01234'.expandtabs(4)
          b'01  012 0123    01234'

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.isalnum ()
 -- メソッド: bytearray.isalnum ()

     シーケンスが空でなく、かつ全てのバイト値が ASCII 文字のアルファベッ
     トまたは数字である場合は ‘True’ を、そうでなければ ‘False’ を返しま
     す。ここでの ASCII 文字のアルファベットとはシーケンス
     ‘b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれ
     るバイト値です。 ASCII 文字の数字とは ‘b'0123456789'’ に含まれるバ
     イト値です。

     例えば:

          >>> b'ABCabc1'.isalnum()
          True
          >>> b'ABC abc1'.isalnum()
          False

 -- メソッド: bytes.isalpha ()
 -- メソッド: bytearray.isalpha ()

     シーケンスが空でなく、かつ全てのバイト値が ASCII 文字のアルファベッ
     トである場合は ‘True’ を、そうでなければ ‘False’ を返します。ここで
     の ASCII 文字のアルファベットとはシーケンス
     ‘b'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれ
     るバイト値です。

     例えば:

          >>> b'ABCabc'.isalpha()
          True
          >>> b'ABCabc1'.isalpha()
          False

 -- メソッド: bytes.isascii ()
 -- メソッド: bytearray.isascii ()

     シーケンスが空であるか、シーケンスの全てのバイトが ASCII である場合
     に ‘True’ を、それ以外の場合に ‘False’ を返します。 ASCII バイトは
     0-0x7F の範囲にあります。

     Added in version 3.7.

 -- メソッド: bytes.isdigit ()
 -- メソッド: bytearray.isdigit ()

     シーケンスが空でなく、かつ全てのバイト値が ASCII 文字の数字である場
     合は ‘True’ を、そうでなければ ‘False’ を返します。ここでの ASCII 文
     字の数字とは ‘b'0123456789'’ に含まれるバイト値です。

     例えば:

          >>> b'1234'.isdigit()
          True
          >>> b'1.23'.isdigit()
          False

 -- メソッド: bytes.islower ()
 -- メソッド: bytearray.islower ()

     シーケンス中に小文字アルファベットの ASCII 文字が一つ以上あり、かつ
     大文字アルファベットの ASCII 文字が一つも無い場合に ‘True’ を返しま
     す。そうでなければ ‘False’ を返します。

     例えば:

          >>> b'hello world'.islower()
          True
          >>> b'Hello world'.islower()
          False

     ここでの小文字の ASCII 文字とは ‘b'abcdefghijklmnopqrstuvwxyz'’ に
     含まれるバイト値です。また大文字の ASCII 文字とは
     ‘b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれるバイト値です。

 -- メソッド: bytes.isspace ()
 -- メソッド: bytearray.isspace ()

     シーケンスが空でなく、かつ全てのバイト値が ASCII 空白文字である場合
     は ‘True’ を、そうでなければ ‘False’ を返します。ここでの ASCII 空
     白文字とはシーケンス ‘b' \t\n\r\x0b\f'’ に含まれるバイト値です (半
     角スペース、タブ、ラインフィード、キャリッジリターン、垂直タブ、フ
     ォームフィード) 。

 -- メソッド: bytes.istitle ()
 -- メソッド: bytearray.istitle ()

     シーケンスが空でなく、かつ ASCII のタイトルケース文字列になっている
     場合は ‘True’ を、そうでなければ ‘False’ を返します。「タイトルケー
     ス文字列」の定義については *note bytes.title(): 2174. を参照してく
     ださい。

     例えば:

          >>> b'Hello World'.istitle()
          True
          >>> b'Hello world'.istitle()
          False

 -- メソッド: bytes.isupper ()
 -- メソッド: bytearray.isupper ()

     シーケンス中に大文字アルファベットの ASCII 文字が一つ以上あり、かつ
     小文字アルファベットの ASCII 文字が一つも無い場合に ‘True’ を返しま
     す。そうでなければ ‘False’ を返します。

     例えば:

          >>> b'HELLO WORLD'.isupper()
          True
          >>> b'Hello world'.isupper()
          False

     ここでの小文字の ASCII 文字とは ‘b'abcdefghijklmnopqrstuvwxyz'’ に
     含まれるバイト値です。また大文字の ASCII 文字とは
     ‘b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれるバイト値です。

 -- メソッド: bytes.lower ()
 -- メソッド: bytearray.lower ()

     シーケンスに含まれる大文字アルファベットの ASCII 文字を全て小文字ア
     ルファベットに変換したシーケンスのコピーを返します。

     例えば:

          >>> b'Hello World'.lower()
          b'hello world'

     ここでの小文字の ASCII 文字とは ‘b'abcdefghijklmnopqrstuvwxyz'’ に
     含まれるバイト値です。また大文字の ASCII 文字とは
     ‘b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれるバイト値です。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.splitlines (keepends=False)
 -- メソッド: bytearray.splitlines (keepends=False)

     バイナリシーケンスを ASCII の改行コードで分割し、各行をリストにして
     返します。このメソッドは *note universal newlines: d08. アプローチ
     で行を分割します。 'keepends' 引数に真を与えた場合を除き、改行コー
     ドは結果のリストに含まれません。

     例えば:

          >>> b'ab c\n\nde fg\rkl\r\n'.splitlines()
          [b'ab c', b'', b'de fg', b'kl']
          >>> b'ab c\n\nde fg\rkl\r\n'.splitlines(keepends=True)
          [b'ab c\n', b'\n', b'de fg\r', b'kl\r\n']

     *note split(): 2160. とは違って、空シーケンスに対して区切り 'sep' を
     与えて呼び出すと空のリストを返します。またシーケンス末尾に改行コー
     ドがある場合、（訳註: その後ろに空行があるとは判断せず）余分な行を
     生成することはありません:

          >>> b"".split(b'\n'), b"Two lines\n".split(b'\n')
          ([b''], [b'Two lines', b''])
          >>> b"".splitlines(), b"One line\n".splitlines()
          ([], [b'One line'])

 -- メソッド: bytes.swapcase ()
 -- メソッド: bytearray.swapcase ()

     シーケンスに含まれる小文字アルファベットの ASCII 文字を全て大文字ア
     ルファベットに変換し、さらに大文字アルファベットを同様に小文字アル
     ファベットに変換したシーケンスのコピーを返します。

     例えば:

          >>> b'Hello World'.swapcase()
          b'hELLO wORLD'

     ここでの小文字の ASCII 文字とは ‘b'abcdefghijklmnopqrstuvwxyz'’ に
     含まれるバイト値です。また大文字の ASCII 文字とは
     ‘b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれるバイト値です。

     Unlike *note str.swapcase(): 212e, 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.

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.title ()
 -- メソッド: bytearray.title ()

     タイトルケース化したバイナリシーケンスを返します。具体的には、各単
     語が大文字アルファベットの ASCII 文字で始まり、かつ残りの文字が小文
     字アルファベットになっているシーケンスが返ります。大文字小文字の区
     別が無いバイト値については変更されずそのままになります。

     例えば:

          >>> b'Hello world'.title()
          b'Hello World'

     ここでの小文字の ASCII 文字とは ‘b'abcdefghijklmnopqrstuvwxyz'’ に
     含まれるバイト値です。また大文字の ASCII 文字とは
     ‘b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれるバイト値です。その他のバ
     イト値については、大文字小文字の区別はありません。

     このアルゴリズムは、連続した文字の集まりという、言語から独立した単
     純な単語の定義を使います。この定義は多くの状況ではうまく機能します
     が、短縮形や所有格のアポストロフィが単語の境界になってしまい、望み
     の結果を得られない場合があります:

          >>> b"they're bill's friends from the UK".title()
          b"They'Re Bill'S Friends From The Uk"

     正規表現を使うことでアポストロフィに対応できます:

          >>> import re
          >>> def titlecase(s):
          ...     return re.sub(rb"[A-Za-z]+('[A-Za-z]+)?",
          ...                   lambda mo: mo.group(0)[0:1].upper() +
          ...                              mo.group(0)[1:].lower(),
          ...                   s)
          ...
          >>> titlecase(b"they're bill's friends.")
          b"They're Bill's Friends."

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.upper ()
 -- メソッド: bytearray.upper ()

     シーケンスに含まれる小文字アルファベットの ASCII 文字を全て大文字ア
     ルファベットに変換したシーケンスのコピーを返します。

     例えば:

          >>> b'Hello World'.upper()
          b'HELLO WORLD'

     ここでの小文字の ASCII 文字とは ‘b'abcdefghijklmnopqrstuvwxyz'’ に
     含まれるバイト値です。また大文字の ASCII 文字とは
     ‘b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'’ に含まれるバイト値です。

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。

 -- メソッド: bytes.zfill (width)
 -- メソッド: bytearray.zfill (width)

     長さが 'width' になるよう ASCII ‘b'0'’ で左詰めしたシーケンスのコピ
     ーを返します。先頭が符号接頭辞 (‘b'+'’/‘b'-'’) だった場合、 ‘b'0'’
     は符号の前ではなく '後' に挿入されます。 *note bytes: 1a4. オブジェ
     クトの場合、 'width' が ‘len(seq)’ 以下であれば元のシーケンスが返り
     ます。

     例えば:

          >>> b"42".zfill(5)
          b'00042'
          >>> b"-42".zfill(5)
          b'-0042'

          注釈: bytearray のこのメソッドはインプレースでは動作 'しません
          ' - 一切変化が無い場合でも、常に新しいオブジェクトを生成します
          。


File: python.info,  Node: printf 形式での bytes の書式化,  Next: メモリビュー,  Prev: bytes と bytearray の操作,  Up: バイナリシーケンス型 --- bytes bytearray memoryview

5.4.9.4 ‘printf’ 形式での bytes の書式化
........................................

     注釈: ここで述べる書式化演算には様々な癖があり、よく間違いの元にな
     っています (タプルや辞書を正しく表示できないなど)。もし表示する値が
     タプルや辞書かもしれない場合、それをタプルに包むようにしてください
     。

bytes オブジェクト (‘bytes’/‘bytearray’) には固有の操作: ‘%’ 演算子 (モ
ジュロ) があります。この演算子は bytes の '書式化' または '補間' 演算子
とも呼ばれます。‘format % values’ ('format' は bytes オブジェクト) とす
ると、'format' 中の ‘%’ 変換指定は 'values' 中のゼロ個またはそれ以上の要
素で置換されます。この動作は C 言語における ‘sprintf()’ に似ています。

'format' が単一の引数しか要求しない場合、 'values' はタプルではない単一
のオブジェクトで問題ありません。 (1) それ以外の場合、 'values' は書式シ
ーケンス（訳註: 先の例での 'format' ）中で指定された項目と正確に同じ数の
要素を含むタプルか、単一のマッピング型のオブジェクト (たとえば辞書) でな
ければなりません。

一つの変換指定子は 2 またはそれ以上の文字を含み、その構成要素は以下から
なりますが、示した順に出現しなければなりません:

  1. 指定子の開始を示す文字 ‘'%'’ 。

  2. マップキー (オプション)。丸括弧で囲った文字列からなります (例えば
     ‘(somename)’) 。

  3. 変換フラグ (オプション)。一部の変換型の結果に影響します。

  4. 最小のフィールド幅 (オプション)。 ‘'*'’ (アスタリスク) を指定した場
     合、実際の文字列幅が 'values' タプルの次の要素から読み出されます。
     タプルには最小フィールド幅やオプションの精度指定の後に変換したいオ
     ブジェクトがくるようにします。

  5. 精度 (オプション)。 ‘'.'’ (ドット) とその後に続く精度で与えられます
     。 ‘'*'’ (アスタリスク) を指定した場合、精度の桁数は 'values' タプ
     ルの次の要素から読み出されます。タプルには精度指定の後に変換したい
     値がくるようにします。

  6. 精度長変換子 (オプション)。

  7. 変換型。

‘%’ 演算子の右側の引数が辞書の場合 (またはその他のマッピング型の場合) 、
bytes オブジェクト中のフォーマットには、辞書のキーを丸括弧で囲って文字
‘'%'’ の直後に書いたものが含まれていなければ 'なりません' 。マップキーは
書式化したい値をマッピングから選び出します。例えば:

     >>> print(b'%(language)s has %(number)03d quote types.' %
     ...       {b'language': b"Python", b"number": 2})
     b'Python has 002 quote types.'

この場合、 ‘*’ 指定子をフォーマットに含めてはいけません (‘*’ 指定子は順
番付けされたパラメタのリストが必要だからです)。

変換フラグ文字を以下に示します:

Flag          意味
              
----------------------------------------------------------------------------------------
              
‘'#'’         値の変換に (下で定義されている) "別の形式" を使います。
              
              
‘'0'’         数値型に対してゼロによるパディングを行います。
              
              
‘'-'’         変換された値を左寄せにします (‘'0'’ と同時に与えた場合、 ‘'0'’ を上書き
              します) 。
              
              
‘' '’         (スペース) 符号付きの変換で正の数の場合、前に一つスペースを空けます (そ
              うでない場合は空文字になります) 。
              
              
‘'+'’         変換の先頭に符号文字 (‘'+'’ または ‘'-'’) を付けます("スペース" フラグ
              を上書きします) 。
              

精度長変換子(‘h’, ‘l’,または ‘L’) を使うことができますが、 Python では必
要ないため無視されます。 - つまり、例えば ‘%ld’ は ‘%d’ と等価です。

変換型を以下に示します:

変換             意味                                                      注釈
                                                                           
---------------------------------------------------------------------------------------
                                                                           
‘'d'’            符号付き 10 進整数。
                 
                                                                           
‘'i'’            符号付き 10 進整数。
                 
                                                                           
‘'o'’            符号付き 8 進数。                                         (1)
                                                                           
                                                                           
‘'u'’            旧式の型 - ‘'d'’ と同じです。                             (8)
                                                                           
                                                                           
‘'x'’            符号付き 16 進数 (小文字)。                               (2)
                                                                           
                                                                           
‘'X'’            符号付き 16 進数 (大文字)。                               (2)
                                                                           
                                                                           
‘'e'’            指数表記の浮動小数点数 (小文字)。                         (3)
                                                                           
                                                                           
‘'E'’            指数表記の浮動小数点数 (大文字)。                         (3)
                                                                           
                                                                           
‘'f'’            10 進浮動小数点数。                                       (3)
                                                                           
                                                                           
‘'F'’            10 進浮動小数点数。                                       (3)
                                                                           
                                                                           
‘'g'’            浮動小数点数。指数部が -4 以上または精度以下の場合には    (4)
                 小文字指数表記、それ以外の場合には10進表記。              
                 
                                                                           
‘'G'’            浮動小数点数。指数部が -4 以上または精度以下の場合には    (4)
                 大文字指数表記、それ以外の場合には10進表記。              
                 
                                                                           
‘'c'’            1 バイト (整数または要素 1 つの ‘bytes’/‘bytearray’ オ
                 ブジェクトを受理します)
                 
                                                                           
‘'b'’            バイナリシーケンス (*note buffer protocol: 371. をサポ    (5)
                 ートするか、 *note __bytes__(): 5b2. メソッドがあるオブ   
                 ジェクト)
                 
                                                                           
‘'s'’            ‘'s'’ は ‘'b'’ の別名です。Python 2/3 の両方を対象とし    (6)
                 たコードでのみ使用すべきです。                            
                 
                                                                           
‘'a'’            バイナリシーケンス (Python オブジェクトを                 (5)
                 ‘repr(obj).encode('ascii', 'backslashreplace')’ で変換    
                 します)。
                 
                                                                           
‘'r'’            ‘'r'’ は ‘'a'’ の別名です。Python 2/3 の両方を対象とし    (7)
                 たコードでのみ使用すべきです。                            
                 
                                                                           
‘'%'’            引数を変換せず、返される文字列中では文字 ‘'%'’ になりま
                 す。
                 

注釈:

  1. 別の形式を指定（訳注: 変換フラグ ‘#’ を使用）すると 8 進数を表す接
     頭辞 (‘'0o'’) が最初の数字の前に挿入されます。

  2. 別の形式を指定（訳注: 変換フラグ ‘#’ を使用）すると 16 進数を表す接
     頭辞 ‘'0x'’ または ‘'0X'’ (使用するフォーマット文字が ‘'x'’ か
     ‘'X'’ に依存します) が最初の数字の前に挿入されます。

  3. この形式にした場合、変換結果には常に小数点が含まれ、それはその後ろ
     に数字が続かない場合にも適用されます。

     指定精度は小数点の後の桁数を決定し、そのデフォルトは 6 です。

  4. この形式にした場合、変換結果には常に小数点が含まれ他の形式とは違っ
     て末尾の 0 は取り除かれません。

     指定精度は小数点の前後の有効桁数を決定し、そのデフォルトは 6 です。

  5. 精度が ‘N’ なら、出力は ‘N’ 文字に切り詰められます。

  6. ‘b'%s'’ は非推奨ですが、3.x 系では削除されません。

  7. ‘b'%r'’ は非推奨ですが、3.x 系では削除されません。

  8. PEP 237(2) を参照してください。

     注釈: bytearray のこのメソッドはインプレースでは動作 'しません' - 一
     切変化が無い場合でも、常に新しいオブジェクトを生成します。

参考
....

PEP 461(3) - bytes と bytearray への % 書式化の追加

Added in version 3.5.

   ---------- Footnotes ----------

   (1) 従って、一個のタプルだけをフォーマット出力したい場合には出力した
いタプルを唯一の要素とする単一のタプルを 'values' に与えなくてはなりませ
ん。

   (2) https://peps.python.org/pep-0237/

   (3) https://peps.python.org/pep-0461/


File: python.info,  Node: メモリビュー,  Prev: printf 形式での bytes の書式化,  Up: バイナリシーケンス型 --- bytes bytearray memoryview

5.4.9.5 メモリビュー
....................

*note memoryview: 435. オブジェクトは、Python コードが *note
バッファプロトコル: 371. をサポートするオブジェクトの内部データへ、コピ
ーすることなくアクセスすることを可能にします。

 -- クラス: memoryview (object)

     'object' を参照する *note memoryview: 435. を作成します。 'object'
     はバッファプロトコルをサポートしていなければなりません。バッファプ
     ロトコルをサポートする組み込みオブジェクトには、 *note bytes: 1a4.
     、 *note bytearray: 508. などがあります。

     *note memoryview: 435. は元となる 'object' が扱うメモリーの最小単位
     を '要素' として扱います。多くの単純なオブジェクト、例えば *note
     bytes: 1a4. や *note bytearray: 508. では、要素は単バイトになります
     が、他の *note array.array: 185. 等の型では、要素はより大きくなりえ
     ます。

     ‘len(view)’ はビューの入れ子になったリスト表現である *note tolist:
     2184. の長さと等しくなります。ビューが ‘view.ndim = 1’ を満たす場合
     はビューの要素数とも等しくなります。

     バージョン 3.12 で変更: ‘view.ndim == 0’ で ‘len(view)’ の場合、1の
     代わりに *note TypeError: 502. を返すようになりました。

     *note itemsize: 2185. 属性は各要素のバイト数を与えます。

     *note memoryview: 435. はスライスおよびインデックス指定で内容を取得
     できます。一次元のスライスは部分ビューになります:

          >>> v = memoryview(b'abcefg')
          >>> v[1]
          98
          >>> v[-1]
          103
          >>> v[1:4]
          <memory at 0x7f3ddc9f4350>
          >>> bytes(v[1:4])
          b'bce'

     もしメモリビューの *note format: 1014. が *note struct: c0. モジュ
     ールによって定義されているネイティブのフォーマット指定子であれば、
     整数または整数のタプルでのインデックス指定により適切な型の '要素1つ
     ' を得ることができます。一次元のメモリビューでは、整数または整数 1
     つのタプルでインデックス指定できます。多次元のメモリビューでは、そ
     の次元数を 'ndim' としたとき、ちょうど 'ndim' 個の整数からなるタプ
     ルでインデックス指定できます。ゼロ次元のメモリビューでは、空のタプ
     ルでインデックス指定できます。

     *note format: 1014. が単バイト単位ではない例を示します:

          >>> import array
          >>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])
          >>> m = memoryview(a)
          >>> m[0]
          -11111111
          >>> m[-1]
          44444444
          >>> m[::2].tolist()
          [-11111111, -33333333]

     メモリビューの参照しているオブジェクトが書き込み可能であれば、一次
     元スライスでの代入が可能です。ただしサイズの変更はできません:

          >>> data = bytearray(b'abcefg')
          >>> v = memoryview(data)
          >>> v.readonly
          False
          >>> v[0] = ord(b'z')
          >>> data
          bytearray(b'zbcefg')
          >>> v[1:4] = b'123'
          >>> data
          bytearray(b'z123fg')
          >>> v[2:3] = b'spam'
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
          ValueError: memoryview assignment: lvalue and rvalue have different structures
          >>> v[2:6] = b'spam'
          >>> data
          bytearray(b'z1spam')

     'B', 'b', 'c' いずれかのフォーマットの *note ハッシュ可能: 5db. な
     (読み出し専用の) 型の1次元メモリビューもまた、ハッシュ可能です。ハ
     ッシュは ‘hash(m) == hash(m.tobytes())’ として定義されています:

          >>> v = memoryview(b'abcefg')
          >>> hash(v) == hash(b'abcefg')
          True
          >>> hash(v[2:4]) == hash(b'ce')
          True
          >>> hash(v[::-2]) == hash(b'abcefg'[::-2])
          True

     バージョン 3.3 で変更: 1 次元のメモリビューがスライス可能になりまし
     た。 'B', 'b', 'c' いずれかのフォーマットの 1 次元のメモリビューが
     *note ハッシュ可能: 5db. になりました。

     バージョン 3.4 で変更: memoryview は自動的に *note
     collections.abc.Sequence: 1194. へ登録されるようになりました。

     バージョン 3.5 で変更: メモリビューは整数のタプルでインデックス指定
     できるようになりました。

     *note memoryview: 435. にはいくつかのメソッドがあります:

      -- メソッド: __eq__ (exporter)

          memoryview と PEP 3118(1) エクスポーターは、 shape が同じで、
          *note struct: c0. のフォーマットで解釈したときの値が同じ場合に
          同値になります。

          *note tolist(): 2184. がサポートしている *note struct: c0. フ
          ォーマットの一部では、 ‘v.tolist() == w.tolist()’ が成り立つと
          きに ‘v’ == ‘w’ になります:

               >>> import array
               >>> a = array.array('I', [1, 2, 3, 4, 5])
               >>> b = array.array('d', [1.0, 2.0, 3.0, 4.0, 5.0])
               >>> c = array.array('b', [5, 3, 1])
               >>> x = memoryview(a)
               >>> y = memoryview(b)
               >>> x == a == y == b
               True
               >>> x.tolist() == a.tolist() == y.tolist() == b.tolist()
               True
               >>> z = y[::-2]
               >>> z == c
               True
               >>> z.tolist() == c.tolist()
               True

          どちらかの書式文字列が *note struct: c0. モジュールにサポート
          されていなければ、 (書式文字列とバッファの内容が同一でも) オブ
          ジェクトは常に等しくないものとして比較されます:

               >>> from ctypes import BigEndianStructure, c_long
               >>> class BEPoint(BigEndianStructure):
               ...     _fields_ = [("x", c_long), ("y", c_long)]
               ...
               >>> point = BEPoint(100, 200)
               >>> a = memoryview(point)
               >>> b = memoryview(point)
               >>> a == point
               False
               >>> a == b
               False

          浮動小数点数の場合と同様 memoryview オブジェクトに対する ‘v is
          w’ は ‘v == w’ を意味 'しない' ことに注意してください。

          バージョン 3.3 で変更: 以前のバージョンは、要素フォーマットと
          論理的な配列構造を無視して生のメモリを比較していました。

      -- メソッド: tobytes (order='C')

          バッファ中のデータをバイト文字列として返します。これはメモリビ
          ューに対して *note bytes: 1a4. コンストラクタを呼び出すのと同
          等です。

               >>> m = memoryview(b"abc")
               >>> m.tobytes()
               b'abc'
               >>> bytes(m)
               b'abc'

          連続でない配列については、結果はすべての要素がバイトに変換され
          たものを含むフラットなリスト表現に等しくなります。 *note
          tobytes(): 2187. は、 *note struct: c0. モジュール文法にないも
          のを含むすべての書式文字列をサポートします。

          Added in version 3.8: 'order' は {'C', 'F', 'A'} のいずれかを
          取ることができます。 'order' が 'C' か 'F' の場合、元の配列は
          C または Fortran のデータ並びにそれぞれ変換されます。連続した
          データに対するビューの場合、 'A' は物理メモリ上のデータの正確
          なコピーを返します。特に、メモリ上における Fortran のデータ並
          びは保存されます。不連続なデータに対するビューの場合、データは
          まず C のデータ並びに変換されます。 'order=None' は 'order='C"
          と同じです。

      -- メソッド: hex ([sep[, bytes_per_sep]])

          バッファ中の各バイトを 2 つの 16 進数で表した文字列を返します:

               >>> m = memoryview(b"abc")
               >>> m.hex()
               '616263'

          Added in version 3.5.

          バージョン 3.8 で変更: *note bytes.hex(): d36. と同様に、
          *note memoryview.hex(): d38. は、16進数出力のバイト文字列を分
          割するセパレータを挿入するためのオプションパラメータ 'sep' と
          'bytes_per_sep' をサポートするようになりました。

      -- メソッド: tolist ()

          バッファ中のデータを要素のリストとして返します。

               >>> memoryview(b'abc').tolist()
               [97, 98, 99]
               >>> import array
               >>> a = array.array('d', [1.1, 2.2, 3.3])
               >>> m = memoryview(a)
               >>> m.tolist()
               [1.1, 2.2, 3.3]

          バージョン 3.3 で変更: *note tolist(): 2184. が *note struct:
          c0. モジュール文法に含まれるすべての単一文字の native フォーマ
          ットと多次元の表現をサポートするようになりました。

      -- メソッド: toreadonly ()

          読み込み専用のメモリビューオブジェクトを返します。元のメモリビ
          ューオブジェクトは変更されません。

               >>> m = memoryview(bytearray(b'abc'))
               >>> mm = m.toreadonly()
               >>> mm.tolist()
               [97, 98, 99]
               >>> mm[0] = 42
               Traceback (most recent call last):
                 File "<stdin>", line 1, in <module>
               TypeError: cannot modify read-only memory
               >>> m[0] = 43
               >>> mm.tolist()
               [43, 98, 99]

          Added in version 3.8.

      -- メソッド: release ()

          memoryview オブジェクトによって晒されている、元になるバッファ
          を解放します。多くのオブジェクトはビューに支配されているときに
          特殊なふるまいをします (例えば、 *note bytearray: 508. は大き
          さの変更を一時的に禁止します)。ですから、release() を呼び出す
          ことは、これらの制約をできるだけ早く取り除く (そしてぶら下がっ
          たリソースをすべて解放する) のに便利です。

          After this method has been called, any further operation on
          the view raises a *note ValueError: 1e3. (except *note
          release(): 118e. itself which can be called multiple times):

               >>> m = memoryview(b'abc')
               >>> m.release()
               >>> m[0]
               Traceback (most recent call last):
                 File "<stdin>", line 1, in <module>
               ValueError: operation forbidden on released memoryview object

          コンテキストマネージャプロトコルは、 ‘with’ 文を使って同様の効
          果を得るのに使えます:

               >>> with memoryview(b'abc') as m:
               ...     m[0]
               ...
               97
               >>> m[0]
               Traceback (most recent call last):
                 File "<stdin>", line 1, in <module>
               ValueError: operation forbidden on released memoryview object

          Added in version 3.2.

      -- メソッド: cast (format[, shape])

          memoryview を新しいフォーマットか shape にキャストします。
          'shape' はデフォルトで ‘[byte_length//new_itemsize]’ で、 1次
          元配列になります。戻り値は memoryview ですが、バッファー自体は
          コピーされません。サポートされている変換は 1次元配列 -> C言語
          型の連続配列 と C言語型の連続配列 -> 1次元配列 です（参考:
          *note contiguous: 1016.）。

          キャスト後のフォーマットは単一要素のネイティブフォーマットに限
          定され、 *note struct: c0. の文法で指定します。利用可能なフォ
          ーマットのひとつはバイトフォーマット ('B', 'b' または 'c') で
          す。キャスト後のバイト長は元の長さと同じでなければなりません。
          全てのフォーマットのバイト長は、オペレーティングシステムに依存
          することに注意してください。

          1次元 long から 1次元 unsigned byte へのキャスト:

               >>> import array
               >>> a = array.array('l', [1,2,3])
               >>> x = memoryview(a)
               >>> x.format
               'l'
               >>> x.itemsize
               8
               >>> len(x)
               3
               >>> x.nbytes
               24
               >>> y = x.cast('B')
               >>> y.format
               'B'
               >>> y.itemsize
               1
               >>> len(y)
               24
               >>> y.nbytes
               24

          1次元 unsigned byte から 1次元 char へのキャスト:

               >>> b = bytearray(b'zyz')
               >>> x = memoryview(b)
               >>> x[0] = b'a'
               Traceback (most recent call last):
                 ...
               TypeError: memoryview: invalid type for format 'B'
               >>> y = x.cast('c')
               >>> y[0] = b'a'
               >>> b
               bytearray(b'ayz')

          1次元 byte から 3次元 int へ、そして 1次元 signed char へのキ
          ャスト:

               >>> import struct
               >>> buf = struct.pack("i"*12, *list(range(12)))
               >>> x = memoryview(buf)
               >>> y = x.cast('i', shape=[2,2,3])
               >>> y.tolist()
               [[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]]
               >>> y.format
               'i'
               >>> y.itemsize
               4
               >>> len(y)
               2
               >>> y.nbytes
               48
               >>> z = y.cast('b')
               >>> z.format
               'b'
               >>> z.itemsize
               1
               >>> len(z)
               48
               >>> z.nbytes
               48

          1次元 unsigned long から 2次元 unsigned long へのキャスト:

               >>> buf = struct.pack("L"*6, *list(range(6)))
               >>> x = memoryview(buf)
               >>> y = x.cast('L', shape=[2,3])
               >>> len(y)
               2
               >>> y.nbytes
               48
               >>> y.tolist()
               [[0, 1, 2], [3, 4, 5]]

          Added in version 3.3.

          バージョン 3.5 で変更: 単バイトのビューへキャストする場合、キ
          ャスト元のフォーマットについて制約は無くなりました。

     読み出し専用の属性もいくつか使えます:

      -- の属性: obj

          memoryview が参照しているオブジェクト:

               >>> b  = bytearray(b'xyz')
               >>> m = memoryview(b)
               >>> m.obj is b
               True

          Added in version 3.3.

      -- の属性: nbytes

          ‘nbytes == product(shape) * itemsize == len(m.tobytes())’.  そ
          の配列が連続表現において利用するスペースです。これは ‘len(m)’
          と一致するとは限りません:

               >>> import array
               >>> a = array.array('i', [1,2,3,4,5])
               >>> m = memoryview(a)
               >>> len(m)
               5
               >>> m.nbytes
               20
               >>> y = m[::2]
               >>> len(y)
               3
               >>> y.nbytes
               12
               >>> len(y.tobytes())
               12

          多次元配列:

               >>> import struct
               >>> buf = struct.pack("d"*12, *[1.5*x for x in range(12)])
               >>> x = memoryview(buf)
               >>> y = x.cast('d', shape=[3,4])
               >>> y.tolist()
               [[0.0, 1.5, 3.0, 4.5], [6.0, 7.5, 9.0, 10.5], [12.0, 13.5, 15.0, 16.5]]
               >>> len(y)
               3
               >>> y.nbytes
               96

          Added in version 3.3.

      -- の属性: readonly

          メモリが読み出し専用かどうかを示す真偽値です。

      -- の属性: format

          ビューの中の各要素に対する (*note struct: c0. モジュールスタイ
          ルの) フォーマットを含む文字列。 memoryview は、任意のフォーマ
          ット文字列を使ってエクスポーターから作成することができます。し
          かし、いくつかのメソッド(例えば *note tolist(): 2184.) はネイ
          ティブの単一要素フォーマットに制限されます。

          バージョン 3.3 で変更: フォーマット ‘'B'’ は struct モジュール
          構文で扱われるようになりました。これは ‘memoryview(b'abc')[0]
          == b'abc'[0] == 97’ ということを意味します。

      -- の属性: itemsize

          memoryview の各要素のバイト単位の大きさ:

               >>> import array, struct
               >>> m = memoryview(array.array('H', [32000, 32001, 32002]))
               >>> m.itemsize
               2
               >>> m[0]
               32000
               >>> struct.calcsize('H') == m.itemsize
               True

      -- の属性: ndim

          メモリが表す多次元配列が何次元かを示す整数です。

      -- の属性: shape

          メモリが表している N 次元配列の形状を表す、長さ *note ndim:
          1018. の整数のタプルです。

          バージョン 3.3 で変更: ndim = 0 の場合は ‘None’ ではなく空のタ
          プルとなるよう変更されました。

      -- の属性: strides

          配列のそれぞれの次元に対して、それぞれの要素にアクセスするのに
          必要なバイト数を表す、長さ *note ndim: 1018. の整数のタプルで
          す。

          バージョン 3.3 で変更: ndim = 0 の場合は ‘None’ ではなく空のタ
          プルとなるよう変更されました。

      -- の属性: suboffsets

          PILスタイルの配列の内部で利用している値。この値はただの情報と
          して公開されています。

      -- の属性: c_contiguous

          メモリーが C 形式の順序で連続しているかどうかを示す真偽値（参
          考: *note contiguous: 1016. ）。

          Added in version 3.3.

      -- の属性: f_contiguous

          メモリーがFortran形式の順序で連続しているかどうかを示す真偽値
          （参考: *note contiguous: 1016. ）。

          Added in version 3.3.

      -- の属性: contiguous

          メモリーが連続しているかどうかを示す真偽値（参考: *note
          contiguous: 1016. ）。

          Added in version 3.3.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3118/


File: python.info,  Node: set（集合）型 --- set frozenset,  Next: マッピング型 --- dict,  Prev: バイナリシーケンス型 --- bytes bytearray memoryview,  Up: 組み込み型

5.4.10 set（集合）型 -- ‘set’, ‘frozenset’
------------------------------------------

'set' オブジェクトは、固有の *note hashable: 5db. オブジェクトの順序なし
コレクションです。通常の用途には、帰属テスト、シーケンスからの重複除去、
積集合、和集合、差集合、対称差 (排他的論理和) のような数学的演算の計算が
含まれます。(他のコンテナについては組み込みの *note dict: 237, *note
list: 5dc, *note tuple: 349. クラスや *note collections: 16. モジュール
を参照してください。)

集合は、他のコレクションと同様、 ‘x in set’, ‘len(set)’, ‘for x in set’
をサポートします。コレクションには順序がないので、集合は挿入の順序や要素
の位置を記録しません。従って、集合はインデクシング、スライシング、その他
のシーケンス的な振舞いをサポートしません。

*note set: 5a3. および *note frozenset: 5a4. という、2つの組み込みの集合
型があります。 *note set: 5a3. はミュータブルで、‘add()’ や ‘remove()’ の
ようなメソッドを使って内容を変更できます。ミュータブルなため、ハッシュ値
を持たず、また辞書のキーや他の集合の要素として用いることができません。一
方、*note frozenset: 5a4. 型はイミュータブルで、*note ハッシュ可能: 5db.
です。作成後に内容を改変できないため、辞書のキーや他の集合の要素として用
いることができます。

空でない *note set: 5a3. (*note frozenset: 5a4. ではない) は、*note set:
5a3. コンストラクタに加え、要素を波括弧中にカンマで区切って列挙すること
でも生成できます。例: ‘{'jack', 'sjoerd'}’。

どちらのクラスのコンストラクタも同様に働きます:

 -- クラス: set ([iterable])
 -- クラス: frozenset ([iterable])

     'iterable' から要素を取り込んだ、新しい *note set: 5a3. もしくは
     *note frozenset: 5a4. オブジェクトを返します。 集合の要素は *note
     ハッシュ可能: 5db. なものでなくてはなりません。集合の集合を表現する
     ためには、内側の集合は *note frozenset: 5a4. オブジェクトでなくては
     なりません。'iterable' が指定されない場合、新しい空の集合が返されま
     す。

     集合はいくつかの方法で生成できます:

        * 波括弧内にカンマ区切りで要素を列挙する: ‘{'jack', 'sjoerd'}’

        * 集合内包表記を使う: ‘{c for c in 'abracadabra' if c not in
          'abc'}’

        * 型コンストラクタを使う: ‘set()’, ‘set('foobar')’, ‘set(['a',
          'b', 'foo'])’

     *note set: 5a3. および *note frozenset: 5a4. のインスタンスは以下の
     操作を提供します:

      -- Describe: len(s)

          集合 's' の要素数 ('s' の濃度) を返します。

      -- Describe: x in s

          'x' が 's' のメンバーに含まれるか判定します。

      -- Describe: x not in s

          'x' が 's' のメンバーに含まれていないことを判定します。

      -- メソッド: isdisjoint (other)

          集合が 'other' と共通の要素を持たないとき、‘True’ を返します。
          集合はそれらの積集合が空集合となるときのみ、互いに素
          (disjoint) となります。

      -- メソッド: issubset (other)

      -- メソッド: set <= other

          set の全ての要素が 'other' に含まれるか判定します。

      -- メソッド: set < other

          set が 'other' の真部分集合であるかを判定します。つまり、 ‘set
          <= other and set != other’ と等価です。

      -- メソッド: issuperset (other)

      -- メソッド: set >= other

          'other' の全ての要素が set に含まれるか判定します。

      -- メソッド: set > other

          set が 'other' の真上位集合であるかを判定します。つまり、 ‘set
          >= other and set != other’ と等価です。

      -- メソッド: union (*others)

      -- メソッド: set | other | ...

          set と全ての other の要素からなる新しい集合を返します。

      -- メソッド: intersection (*others)

      -- メソッド: set & other & ...

          set と全ての other に共通する要素を持つ、新しい集合を返します
          。

      -- メソッド: difference (*others)

      -- メソッド: set - other - ...

          set に含まれて、かつ、全ての other に含まれない要素を持つ、新
          しい集合を返します。

      -- メソッド: symmetric_difference (other)

      -- メソッド: set ^ other

          set と 'other' のいずれか一方だけに含まれる要素を持つ新しい集
          合を返します。

      -- メソッド: copy ()

          集合の浅いコピーを返します。

     なお、演算子でない版の *note union(): 1426, *note intersection():
     1427, *note difference(): 2193, *note symmetric_difference(): 2194,
     *note issubset(): 2191, *note issuperset(): 2192. メソッドは、任意
     のイテラブルを引数として受け付けます。対して、演算子を使う版では、
     引数は集合でなくてはなりません。これは、‘set('abc') & 'cbs'’ のよう
     な誤りがちな構文を予防し、より読みやすい
     ‘set('abc').intersection('cbs')’ を支持します。

     *note set: 5a3. と *note frozenset: 5a4. のどちらも、集合同士の比較
     をサポートします。二つの集合は、それぞれの集合の要素全てが他方にも
     含まれている (互いに他方の部分集合である) とき、かつそのときに限り
     等しいです。一方の集合が他方の集合の真部分集合である (部分集合であ
     るが等しくない) とき、かつそのときに限り一方の集合は他方の集合より
     小さいです。一方の集合が他方の集合の真上位集合である (上位集合であ
     るが等しくない) とき、かつそのときに限り一方の集合は他方の集合より
     大きいです。

     *note set: 5a3. のインスタンスは、 *note frozenset: 5a4. のインスタ
     ンスと、要素に基づいて比較されます。例えば、 ‘set('abc') ==
     frozenset('abc')’ や ‘set('abc') in set([frozenset('abc')])’ は
     ‘True’ を返します。

     部分集合と等価性の比較は全順序付けを行う関数へと一般化することはで
     きません。例えば、互いに素である二つの非空集合は、等しくなく、他方
     の部分集合でもありませんから、以下の 'すべて' に ‘False’ を返します
     : ‘a<b’, ‘a==b’, そして ‘a>b’.

     集合は半順序（部分集合関係）しか定義しないので、集合のリストにおけ
     る *note list.sort(): b9d. メソッドの出力は未定義です。

     集合の要素は、辞書のキーのように、 *note ハッシュ可能: 5db. でなけ
     ればなりません。

     *note set: 5a3. インスタンスと *note frozenset: 5a4. インスタンスを
     取り混ぜての二項演算は、第一被演算子の型を返します。例えば:
     ‘frozenset('ab') | set('bc')’ は *note frozenset: 5a4. インスタンス
     を返します。

     以下の表に挙げる演算は *note set: 5a3. に適用されますが、*note
     frozenset: 5a4. のイミュータブルなインスタンスには適用されません:

      -- メソッド: update (*others)

      -- メソッド: set |= other | ...

          全ての other の要素を追加し、 set を更新します。

      -- メソッド: intersection_update (*others)

      -- メソッド: set &= other & ...

          元の set と全ての other に共通する要素だけを残して set を更新
          します。

      -- メソッド: difference_update (*others)

      -- メソッド: set -= other | ...

          'other' に含まれる要素を取り除き、 set を更新します。

      -- メソッド: symmetric_difference_update (other)

      -- メソッド: set ^= other

          どちらかにのみ含まれて、共通には持たない要素のみで set を更新
          します。

      -- メソッド: add (elem)

          要素 'elem' を set に追加します。

      -- メソッド: remove (elem)

          要素 'elem' を set から取り除きます。'elem' が set に含まれて
          いなければ *note KeyError: 31d. を送出します。

      -- メソッド: discard (elem)

          要素 'elem' が set に含まれていれば、取り除きます。

      -- メソッド: pop ()

          's' から任意の要素を取り除き、それを返します。集合が空の場合、
          *note KeyError: 31d. を送出します

      -- メソッド: clear ()

          set の全ての要素を取り除きます。

     なお、演算子でない版の *note update(): 2196, *note
     intersection_update(): 1428, *note difference_update(): 2197, およ
     び *note symmetric_difference_update(): 1429. メソッドは、任意のイ
     テラブルを引数として受け付けます。

     *note __contains__(): 1ebe, *note remove(): 2199, *note discard():
     219a. メソッドの引数 'elem' は集合かもしれないことに注意してくださ
     い。 その集合と等価な *note frozenset: 5a4. の検索をサポートするた
     めに、 'elem' から一時的な frozenset を作成します。


File: python.info,  Node: マッピング型 --- dict,  Next: コンテキストマネージャ型,  Prev: set（集合）型 --- set frozenset,  Up: 組み込み型

5.4.11 マッピング型 -- ‘dict’
-----------------------------

*note マッピング: 118c. オブジェクトは、 *note ハッシュ可能: 5db. な値を
任意のオブジェクトに対応付けます。マッピングはミュータブルなオブジェクト
です。現在、標準のマッピング型は辞書 ('dictionary') だけです。 (他のコン
テナについては組み込みの *note list: 5dc, *note set: 5a3, および *note
tuple: 349. クラスと、 *note collections: 16. モジュールを参照してくださ
い。)

辞書のキーには、 'ほぼ' どんな値も使うことができます。 キーとして使えな
いのは、 *note hashable: 5db. (ハッシュ可能) でない値、すなわちリストや
辞書のようなミュータブルな型 (内包する値ではなくオブジェクト自体が同一で
あるかによって比較が行われるような型)です。 比較した際に等しいとみなされ
る値 (例えば ‘1’ と ‘1.0’ と ‘True’) は、どれを使っても同じエントリーに
関連付けられます。

 -- クラス: dict (**kwargs)

 -- クラス: dict (mapping, **kwargs)

 -- クラス: dict (iterable, **kwargs)

     オプションの位置引数と空の可能性もあるキーワード引数の集合により初
     期化された新しい辞書を返します。

     辞書はいくつかの方法で生成できます:

        * 波括弧内にカンマ区切りで ‘key: value’ 対を列挙する: ‘{'jack':
          4098, 'sjoerd': 4127}’ あるいは ‘{4098: 'jack', 4127:
          'sjoerd'}’

        * 辞書内包表記を使う: ‘{}’, ‘{x: x ** 2 for x in range(10)}’

        * 型コンストラクタを使う: ‘dict()’, ‘dict([('foo', 100), ('bar',
          200)])’, ‘dict(foo=100, bar=200)’

     If no positional argument is given, an empty dictionary is created.
     If a positional argument is given and it defines a ‘keys()’ method,
     a dictionary is created by calling *note __getitem__(): 264. on the
     argument with each returned key from the method.  Otherwise, the
     positional argument must be an *note iterable: 10ad. object.  Each
     item in the iterable must itself be an iterable with exactly two
     elements.  The first element of each item becomes a key in the new
     dictionary, and the second element the corresponding value.  If a
     key occurs more than once, the last value for that key becomes the
     corresponding value in the new dictionary.

     キーワード引数が与えられた場合、キーワード引数とその値が位置引数か
     ら作られた辞書に追加されます。既に存在しているキーが追加された場合
     、キーワード引数の値は位置引数の値を置き換えます。

     例を出すと、次の例は全て ‘{"one": 1, "two": 2, "three": 3}’ に等し
     い辞書を返します:

          >>> a = dict(one=1, two=2, three=3)
          >>> b = {'one': 1, 'two': 2, 'three': 3}
          >>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
          >>> d = dict([('two', 2), ('one', 1), ('three', 3)])
          >>> e = dict({'three': 3, 'one': 1, 'two': 2})
          >>> f = dict({'one': 1, 'three': 3}, two=2)
          >>> a == b == c == d == e == f
          True

     最初の例のようにキーワード引数を与える方法では、キーは有効な Python
     の識別子でなければなりません。それ以外の方法では、辞書のキーとして
     有効などんなキーでも使えます。

     以下は辞書型がサポートする操作です (それゆえ、カスタムのマップ型も
     これらの操作をサポートするべきです):

      -- Describe: list(d)

          辞書 'd' で使われている全てのキーのリストを返します。

      -- Describe: len(d)

          辞書 'd' の項目数を返します。

      -- Describe: d[key]

          'd' のキー 'key' の項目を返します。マップに 'key' が存在しなけ
          れば、 *note KeyError: 31d. を送出します。

          辞書のサブクラスが ‘__missing__()’ メソッドを定義していて、
          'key' が存在しない場合、 ‘d[key]’ 演算はこのメソッドをキー
          'key' を引数として呼び出します。 ‘d[key]’ 演算は、
          ‘__missing__(key)’ の呼び出しによって返された値をそのまま返す
          か、送出されたものをそのまま送出します。他の演算やメソッドは
          ‘__missing__()’ を呼び出しません。 ‘__missing__()’ が定義され
          ていない場合、 *note KeyError: 31d. が送出されます。
          ‘__missing__()’ はメソッドでなければならず、インスタンス変数で
          あってはなりません:

               >>> class Counter(dict):
               ...     def __missing__(self, key):
               ...         return 0
               ...
               >>> c = Counter()
               >>> c['red']
               0
               >>> c['red'] += 1
               >>> c['red']
               1

          ここでお見せした例は *note collections.Counter: 1067. 実装の一
          部です。これとは違った ‘__missing__’ が *note
          collections.defaultdict: 118d. で使われています。

      -- Describe: d[key] = value

          ‘d[key]’ に 'value' を設定します。

      -- Describe: del d[key]

          'd' から ‘d[key]’ を削除します。マップに 'key' が存在しなけれ
          ば、 *note KeyError: 31d. を送出します。

      -- Describe: key in d

          'd' がキー 'key' を持っていれば ‘True’ を、そうでなければ、
          ‘False’ を返します。

      -- Describe: key not in d

          ‘not key in d’ と等価です。

      -- Describe: iter(d)

          辞書のキーに渡るイテレータを返します。これは ‘iter(d.keys())’
          へのショートカットです。

      -- メソッド: clear ()

          辞書の全ての項目を消去します。

      -- メソッド: copy ()

          辞書の浅いコピーを返します。

      -- メソッド: classmethod fromkeys (iterable, value=None, /)

          'iterable' からキーを取り、値を 'value' に設定した、新しい辞書
          を作成します。

          *note fromkeys(): 219f. は新しい辞書を返すクラスメソッドです。
          'value' はデフォルトで ‘None’ となります。 作られる辞書内のす
          べての値が同一のインスタンスを指すことになるため、'value' にミ
          ュータブルなオブジェクト (例えば空のリスト) を指定しても通常意
          味はありません。 別々の値を指すようにしたい場合は、代わりに
          *note 辞書内包表記: d4c. を使用してください。

      -- メソッド: get (key, default=None)

          'key' が辞書にあれば 'key' に対する値を、そうでなければ
          'default' を返します。 'default' が与えられなかった場合、デフ
          ォルトでは ‘None’ となります。そのため、このメソッドは *note
          KeyError: 31d. を送出することはありません。

      -- メソッド: items ()

          辞書の項目 (‘(key, value)’ 対) の新しいビューを返します。*note
          ビューオブジェクトのドキュメント: 21a1. を参照してください。

      -- メソッド: keys ()

          辞書のキーの新しいビューを返します。*note
          ビューオブジェクトのドキュメント: 21a1. を参照してください。

      -- メソッド: pop (key[, default])

          'key' が辞書に存在すればその値を辞書から消去して返し、そうでな
          ければ 'default' を返します。 'default' が与えられず、かつ
          'key' が辞書に存在しなければ *note KeyError: 31d. を送出します
          。

      -- メソッド: popitem ()

          任意の ‘(key, value)’ 対を辞書から消去して返します。 対は LIFO
          (後入れ、先出し) の順序で返却されます。

          集合のアルゴリズムで使われるのと同じように、 *note popitem():
          14d0. は辞書に繰り返し適用して消去するのに便利です。辞書が空で
          あれば、 *note popitem(): 14d0. の呼び出しは *note KeyError:
          31d. を送出します。

          バージョン 3.7 で変更: LIFO 順序が保証されるようになりました。
          以前のバージョンでは、 *note popitem(): 14d0. は任意の
          key/value 対を返していました。

      -- Describe: reversed(d)

          辞書のキーに渡る逆イテレータを返します。これは
          ‘reversed(d.keys())’ へのショートカットです。

          Added in version 3.8.

      -- メソッド: setdefault (key, default=None)

          もし、 'key' が辞書に存在すれば、その値を返します。そうでなけ
          れば、値を 'default' として 'key' を挿入し、 'default' を返し
          ます。 'default' のデフォルトは ‘None’ です。

      -- メソッド: update ([other])

          辞書の内容を 'other' のキーと値で更新します。既存のキーは上書
          きされます。返り値は ‘None’ です。

          *note update(): 140a. accepts either another object with a
          ‘keys()’ method (in which case *note __getitem__(): 264. is
          called with every key returned from the method) or an iterable
          of key/value pairs (as tuples or other 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)’.

      -- メソッド: values ()

          辞書の値の新しいビューを返します。*note
          ビューオブジェクトのドキュメント: 21a1. を参照してください。

          ‘dict.values()’ で得られた２つのビューの等しさを比較すると、必
          ず ‘False’ が返ります。 ‘dict.values()’ どうしを比較したときも
          同様です:

               >>> d = {'a': 1}
               >>> d.values() == d.values()
               False

      -- Describe: d | other

          'd' と 'other' のキーと値を統合した新しい辞書を作成します。
          'd' と 'other' のキーに重複がある場合は、 'other' の方の値が優
          先されます。

          Added in version 3.9.

      -- Describe: d |= other

          辞書 'd' のキーと値を 'other' で更新します。 'other' は *note
          マッピング: 118c. か、またはキーと値のペアの *note イテラブル:
          10ad. です。 'd' と 'other' のキーに重複がある場合は、 'other'
          の方の値が優先されます。

          Added in version 3.9.

     複数の辞書は、(順序に関係なく) 同じ ‘(key, value)’ の対を持つ場合に
     、そしてその場合にのみ等しくなります。順序比較 ('<', '<=', '>=',
     '>') は *note TypeError: 502. を送出します。

     辞書は挿入順序を保存するようになりました。 キーの更新は順序には影響
     が無いことに注意してください。 いったん削除されてから再度追加された
     キーは末尾に挿入されます。:

          >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
          >>> d
          {'one': 1, 'two': 2, 'three': 3, 'four': 4}
          >>> list(d)
          ['one', 'two', 'three', 'four']
          >>> list(d.values())
          [1, 2, 3, 4]
          >>> d["one"] = 42
          >>> d
          {'one': 42, 'two': 2, 'three': 3, 'four': 4}
          >>> del d["two"]
          >>> d["two"] = None
          >>> d
          {'one': 42, 'three': 3, 'four': 4, 'two': None}

     バージョン 3.7 で変更: 辞書の順序が挿入順序であることが保証されるよ
     うになりました。この振る舞いは CPython 3.6 の実装詳細でした。

     辞書と辞書のビューは ‘reversed()’ で順序を逆にすることができます:

          >>> d = {"one": 1, "two": 2, "three": 3, "four": 4}
          >>> d
          {'one': 1, 'two': 2, 'three': 3, 'four': 4}
          >>> list(reversed(d))
          ['four', 'three', 'two', 'one']
          >>> list(reversed(d.values()))
          [4, 3, 2, 1]
          >>> list(reversed(d.items()))
          [('four', 4), ('three', 3), ('two', 2), ('one', 1)]

     バージョン 3.8 で変更: 辞書がリバース可能になりました。

参考
....

*note dict: 237. の読み出し専用ビューを作るために *note
types.MappingProxyType: 43a. を使うことができます。

* Menu:

* 辞書ビューオブジェクト::


File: python.info,  Node: 辞書ビューオブジェクト,  Up: マッピング型 --- dict

5.4.11.1 辞書ビューオブジェクト
...............................

*note dict.keys(): 798, *note dict.values(): 799, *note dict.items():
79a. によって返されるオブジェクトは、 'ビューオブジェクト' です。これら
は、辞書の項目の動的なビューを提供し、辞書が変更された時、ビューはその変
更を反映します。

辞書ビューは、イテレートすることで対応するデータを yield できます。また
、帰属判定をサポートします:

 -- Describe: len(dictview)

     辞書の項目数を返します。

 -- Describe: iter(dictview)

     辞書のキー、値、または (‘(key, value)’ のタプルとして表される) 項目
     に渡るイテレータを返します。

     キーと値は挿入順序で反復されます。 これにより、 ‘(value, key)’ の対
     の列を ‘pairs = zip(d.values(), d.keys())’ のように *note zip():
     79b. で作成できます。 同じリストを作成する他の方法は、 ‘pairs =
     [(v, k) for (k, v) in d.items()]’ です。

     辞書の項目の追加や削除中にビューをイテレートすると、 *note
     RuntimeError: 17a. を送出したり、すべての項目に渡ってイテレートでき
     なかったりします。

     バージョン 3.7 で変更: 辞書の順序が挿入順序であると保証されるように
     なりました。

 -- Describe: x in dictview

     'x' が元の辞書のキー、値、または項目 (項目の場合、 'x' は ‘(key,
     value)’ タプルです) にあるとき ‘True’ を返します。

 -- Describe: reversed(dictview)

     辞書のキーもしくは値、項目の順序を逆にしたイテレーターを返します。
     戻り値のビューは、挿入された順とは逆の順でイテレートします。

     バージョン 3.8 で変更: 辞書のビューがリバース可能になりました。

 -- Describe: dictview.mapping

     ビューの参照先の辞書をラップする *note types.MappingProxyType: 43a.
     オブジェクト を返します。

     Added in version 3.10.

キーのビューは要素に重複がなくハッシュ可能 (*note hashable: 5db.) である
ため、集合の特性を持ちます。項目のビューも、 キーと値の対に重複がなく、
かつキーがハッシュ可能であるため、集合的な演算を持っています。もし項目の
全ての値がハッシュ可能ならば、項目のビューは集合と相互に演算することが可
能です。 (値のビューは一般に要素に重複があるため、集合の特性を持つとはみ
なされません。) 集合の特性を持つビューに対しては、 *note
collections.abc.Set: 21a3. 抽象基底クラスで定義された全ての演算が利用可
能です (たとえば ‘==’, ‘<’ や ‘^’ など)。 集合演算に対しては、集合はオペ
ランドとして集合しか取ることができないのに対して、これら集合の特性を持つ
ビューはオペランドとして任意のイテラブルを取ることができます。

辞書ビューの使用法の例:

     >>> dishes = {'eggs': 2, 'sausage': 1, 'bacon': 1, 'spam': 500}
     >>> keys = dishes.keys()
     >>> values = dishes.values()

     >>> # iteration
     >>> n = 0
     >>> for val in values:
     ...     n += val
     ...
     >>> print(n)
     504

     >>> # keys and values are iterated over in the same order (insertion order)
     >>> list(keys)
     ['eggs', 'sausage', 'bacon', 'spam']
     >>> list(values)
     [2, 1, 1, 500]

     >>> # view objects are dynamic and reflect dict changes
     >>> del dishes['eggs']
     >>> del dishes['sausage']
     >>> list(keys)
     ['bacon', 'spam']

     >>> # set operations
     >>> keys & {'eggs', 'bacon', 'salad'}
     {'bacon'}
     >>> keys ^ {'sausage', 'juice'} == {'juice', 'sausage', 'bacon', 'spam'}
     True
     >>> keys | ['juice', 'juice', 'juice'] == {'bacon', 'spam', 'juice'}
     True

     >>> # get back a read-only proxy for the original dictionary
     >>> values.mapping
     mappingproxy({'bacon': 1, 'spam': 500})
     >>> values.mapping['spam']
     500


File: python.info,  Node: コンテキストマネージャ型,  Next: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン,  Prev: マッピング型 --- dict,  Up: 組み込み型

5.4.12 コンテキストマネージャ型
-------------------------------

Python の *note with: 59c. 文は、コンテキストマネージャによって定義され
る実行時コンテキストの概念をサポートします。これは、文の本体が実行される
前に進入し文の終わりで脱出する実行時コンテキストを、ユーザ定義クラスが定
義できるようにする一対のメソッドで実装されます:

 -- メソッド: contextmanager.__enter__ ()

     実行時コンテキストに入り、このオブジェクトまたは他の実行時コンテキ
     ストに関連したオブジェクトを返します。このメソッドが返す値はこのコ
     ンテキストマネージャを使う *note with: 59c. 文の ‘as’ 節の識別子に
     束縛されます。

     自分自身を返すコンテキストマネージャの例として *note
     ファイルオブジェクト: 1193. があります。ファイルオブジェクトは
     __enter__() から自分自身を返し、 *note open(): 4e5. が *note with:
     59c. 文のコンテキスト式として使われるようにします。

     関連オブジェクトを返すコンテキストマネージャの例としては *note
     decimal.localcontext(): 176f. が返すものがあります。このマネージャ
     はアクティブな10進数コンテキストをオリジナルのコンテキストのコピー
     にセットしてそのコピーを返します。こうすることで, *note with: 59c.
     文の本体の内部で、‘with’ 文の外側のコードに影響を与えずに、 10進数
     コンテキストを変更できます。

 -- メソッド: contextmanager.__exit__ (exc_type, exc_val, exc_tb)

     実行時コンテキストから抜け、(発生していた場合) 例外を抑制するかどう
     かを示すブール値フラグを返します。 *note with: 59c. 文の本体の実行
     中に例外が発生した場合、引数にはその例外の型と値とトレースバック情
     報を渡します。そうでない場合、引数は全て ‘None’ となります。

     このメソッドから真値が返されると *note with: 59c. 文は例外の発生を
     抑え、 ‘with’ 文の直後の文に実行を続けます。そうでなければ、このメ
     ソッドの実行を終えると例外の伝播が続きます。このメソッドの実行中に
     起きた例外は ‘with’ 文の本体の実行中に起こった例外を置き換えてしま
     います。

     渡された例外を明示的に再送出すべきではありません。その代わりに、こ
     のメソッドが偽の値を返すことでメソッドの正常終了と送出された例外を
     抑制しないことを伝えるべきです。このようにすればコンテキストマネー
     ジャは *note __exit__(): 12ce. メソッド自体が失敗したのかどうかを簡
     単に見分けることができます。

Python は、易しいスレッド同期、ファイルなどのオブジェクトの即時クローズ
、アクティブな小数算術コンテキストの単純な操作をサポートするために、いく
つかのコンテキストマネージャを用意しています。各型はコンテキスト管理プロ
トコルを実装しているという以上の特別の取り扱いを受けるわけではありません
。例については *note contextlib: 1c. モジュールを参照してください。

Python の *note ジェネレータ: 1035. と *note contextlib.contextmanager:
11d3. *note デコレータ: 6fc. はこのプロトコルの簡便な実装方法を提供しま
す。ジェネレータ関数を *note contextlib.contextmanager: 11d3. デコレータ
でデコレートすると、デコレートされないジェネレータ関数が作成するイテレー
タの代わりに、必要な *note __enter__(): 21a5. および *note __exit__():
21a6. メソッドを実装したコンテキストマネージャを返すようになります。

これらのメソッドのために Python/C API の中の Python オブジェクトの型構造
体に特別なスロットが作られたわけではないことに注意してください。これらの
メソッドを定義したい拡張型はこれらを通常の Python からアクセスできるメソ
ッドとして提供しなければなりません。実行時コンテキストを準備するオーバー
ヘッドに比べたら、一回のクラス辞書の探索のオーバーヘッドは無視できます。


File: python.info,  Node: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン,  Next: その他の組み込み型,  Prev: コンテキストマネージャ型,  Up: 組み込み型

5.4.13 型アノテーション型 -- ジェネリックエイリアス 、 ユニオン
---------------------------------------------------------------

*note 型アノテーション: 424. の中心となる組み込みの型は *note
ジェネリックエイリアス: 67e. と *note ユニオン: 78d. です。

* Menu:

* ジェネリックエイリアス型::
* Union 型::


File: python.info,  Node: ジェネリックエイリアス型,  Next: Union 型,  Up: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン

5.4.13.1 ジェネリックエイリアス型
.................................

‘GenericAlias’ オブジェクトは一般的に、クラスに *note 添字表記: 1ee5. を
することで作られます。 *note list: 5dc. や *note dict: 237. のような
*note コンテナ系のクラス: 1eeb. に対して使われることがほとんどです。 例
えば、 ‘list[int]’ は ‘list’ クラスに *note int: 238. という引数を与えた
添字表記をすることで作られる ‘GenericAlias’ オブジェクトです。
‘GenericAlias’ オブジェクトは主に *note 型アノテーション: 424. の用途で
使われます。

     注釈: 一般に、クラスへの添字表記は、そのクラスが特殊メソッド *note
     __class_getitem__(): 706. を実装しているときに限り可能です。

‘GenericAlias’ オブジェクトは 'パラメータ付きジェネリック型' を実装した
ジェネリック型 (*note generic type: 405.) の代用として振る舞います。

コンテナクラスに対してクラスの *note 添字表記: 1ee5. に与えられた単一ま
たは複数の引数は、そのオブジェクトが包含する要素の型をあらわします。たと
えば ‘set[bytes]’ という表記は、全ての要素が *note bytes: 1a4. であるよ
うな *note set: 5a3. をあらわす型アノテーションとして使うことができます
。

*note __class_getitem__(): 706. メソッドを定義しているけれどもコンテナで
ないクラスに対しては、クラスの添字表記に与えられた単一または複数の引数は
、しばしばオブジェクトに定義された単一または複数のメソッドの戻り値の型を
あらわします。たとえば、 *note 正規表現操作: a7. は *note str: 418. と
*note bytes: 1a4. の両方のデータ型に対して使うことができます:

   * ‘x = re.search('foo', 'foo')’ とした場合、 ‘x’ は *note re.Match:
     f54. オブジェクトとなり、 ‘x.group(0)’ と ‘x[0]’ の戻り値はどちらも
     *note str: 418. となります。このようなオブジェクトは、
     ‘GenericAlias’ を使った型アノテーション ‘re.Match[str]’ で表現する
     ことができます。

   * ‘y = re.search(b'bar', b'bar')’ (ここで ‘b’ は *note bytes: 1a4. 型
     をあらわします) とした場合、‘y’ もまた ‘re.Match’ のインスタンスと
     なりますが、 ‘y.group(0)’ と ‘y[0]’ の戻り値はどちらも *note bytes:
     1a4. 型になります。型アノテーションでは、このような *note re.Match:
     f54. オブジェクトは ‘re.Match[bytes]’ と表現することになるでしょう
     。

‘GenericAlias’ オブジェクトは *note types.GenericAlias: 7b6. クラスのイ
ンスタンスです。このクラスは直接 ‘GenericAlias’ オブジェクトを生成するの
に使うこともできます。

 -- Describe: T[X, Y, ...]

     型 "X", "Y", またはさらに多くの引数でパラメータ化される型 ‘T’ を表
     現する ‘GenericAlias’ を生成します。引数の数は ‘T’ の使われ方によっ
     て決まります。たとえば、 *note float: 2ce. 型の要素を含む *note
     list: 5dc. を引数にとる関数の型アノテーションは次のようになります:

          def average(values: list[float]) -> float:
              return sum(values) / len(values)

     もうひとつの例として *note mapping: 118c. オブジェクトの場合を示し
     ます。ここではキーと値の2つの型をパラメータとするジェネリック型であ
     る *note dict: 237. を使っています。この例では、関数はキーが *note
     str: 418. 型、値が *note int: 238. 型であるような ‘dict’ を引数にと
     ります:

          def send_post_request(url: str, body: dict[str, int]) -> None:
              ...

組み込み関数 *note isinstance(): 40e. と *note issubclass(): 78c. は第二
引数として ‘GenericAlias’ 型を指定することはできません:

     >>> isinstance([1, 2], list[str])
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: isinstance() argument 2 cannot be a parameterized generic

Python 実行時には *note 型アノテーション: 424. は強制されません。この性
質はジェネリック型とその型パラメータにもおよびます。 ‘GenericAlias’ から
コンテナオブジェクトを生成した場合、コンテナ内の要素は型のチェックを受け
ません。たとえば、以下のコードは推奨されませんが、エラーになることなく実
行できます:

     >>> t = list[str]
     >>> t([1, 2, 3])
     [1, 2, 3]

しかも、パラメータ付きジェネリック型は、オブジェクト生成時にパラメータの
型情報を削除します:

     >>> t = list[str]
     >>> type(t)
     <class 'types.GenericAlias'>

     >>> l = t()
     >>> type(l)
     <class 'list'>

*note repr(): 7c8. や *note str(): 418. のジェネリック型に対する呼び出し
は、パラメータ型を表示します:

     >>> repr(list[int])
     'list[int]'

     >>> str(list[int])
     'list[int]'

ジェネリックコンテナ型の *note __getitem__(): 264. メソッドは、
‘dict[str][str]’ のようなミスを許さないように、例外を送出します:

     >>> dict[str][str]
     Traceback (most recent call last):
       ...
     TypeError: dict[str] is not a generic class

一方で、同様の式は *note 型変数: 1ee0. が使われた場合は有効です。添字の
数は''GenericAlias'' オブジェクトの *note __args__: 21a9. 属性における型
変数の数と同じでなければなりません:

     >>> from typing import TypeVar
     >>> Y = TypeVar('Y')
     >>> dict[str, Y][int]
     dict[str, int]

* Menu:

* 標準ジェネリッククラス::
* GenericAlias オブジェクトの特別な属性::


File: python.info,  Node: 標準ジェネリッククラス,  Next: GenericAlias オブジェクトの特別な属性,  Up: ジェネリックエイリアス型

5.4.13.2 標準ジェネリッククラス
...............................

以下の標準ライブラリクラスは、パラメータ付きジェネリック型をサポートしま
す。このリストは完全に網羅されていない可能性があります。

   * *note tuple: 349.

   * *note list: 5dc.

   * *note dict: 237.

   * *note set: 5a3.

   * *note frozenset: 5a4.

   * *note type: d16.

   * *note collections.deque: 5a6.

   * *note collections.defaultdict: 118d.

   * *note collections.OrderedDict: 5a5.

   * *note collections.Counter: 1067.

   * *note collections.ChainMap: bea.

   * ’’*note collections.abc.Awaitable: da9.

   * *note collections.abc.Coroutine: daa.

   * *note collections.abc.AsyncIterable: dac.

   * *note collections.abc.AsyncIterator: dab.

   * *note collections.abc.AsyncGenerator: c58.

   * *note collections.abc.Iterable: 21ab.

   * *note collections.abc.Iterator: 21ac.

   * *note collections.abc.Generator: da8.

   * *note collections.abc.Reversible: c57.

   * *note collections.abc.Container: 21ad.

   * *note collections.abc.Collection: c56.

   * *note collections.abc.Callable: 7b5.

   * *note collections.abc.Set: 21a3.

   * *note collections.abc.MutableSet: 21ae.

   * *note collections.abc.Mapping: 898.

   * *note collections.abc.MutableMapping: 107e.

   * *note collections.abc.Sequence: 1194.

   * *note collections.abc.MutableSequence: 186.

   * *note collections.abc.ByteString: 2a3.

   * *note collections.abc.MappingView: 21af.

   * *note collections.abc.KeysView: 21b0.

   * *note collections.abc.ItemsView: 21b1.

   * *note collections.abc.ValuesView: 21b2.

   * *note contextlib.AbstractContextManager: c5b.

   * *note contextlib.AbstractAsyncContextManager: af9.

   * *note dataclasses.Field: 21b3.

   * *note functools.cached_property: 50c.

   * *note functools.partialmethod: a49.

   * *note os.PathLike: c1f.

   * *note queue.LifoQueue: 21b4.

   * *note queue.Queue: 1356.

   * *note queue.PriorityQueue: 21b5.

   * *note queue.SimpleQueue: b38.

   * *note re.Pattern: f53.

   * *note re.Match: f54.

   * *note shelve.BsdDbShelf: 21b6.

   * *note shelve.DbfilenameShelf: 21b7.

   * *note shelve.Shelf: f67.

   * *note types.MappingProxyType: 43a.

   * *note weakref.WeakKeyDictionary: 18d9.

   * *note weakref.WeakMethod: fba.

   * *note weakref.WeakSet: 5a7.

   * *note weakref.WeakValueDictionary: 18d8.


File: python.info,  Node: GenericAlias オブジェクトの特別な属性,  Prev: 標準ジェネリッククラス,  Up: ジェネリックエイリアス型

5.4.13.3 ‘GenericAlias’ オブジェクトの特別な属性
................................................

全てのパラメータ付きジェネリック型は、下記に示す読み出し専用の属性を実装
しています。

 -- の属性: genericalias.__origin__

     この属性は、対応するパラメータ付きでないジェネリッククラスを指しま
     す:

          >>> list[int].__origin__
          <class 'list'>

 -- の属性: genericalias.__args__

     この属性は、ジェネリッククラスの元の *note __class_getitem__():
     706. に渡された *note tuple: 349. です (長さが1の場合もあります):

          >>> dict[str, list[int]].__args__
          (<class 'str'>, list[int])

 -- の属性: genericalias.__parameters__

     この属性は、 ‘__args__’ にある固有の型変数のタプルで、必要に応じて
     遅延計算されます (空の可能性もあります):

          >>> from typing import TypeVar

          >>> T = TypeVar('T')
          >>> list[T].__parameters__
          (~T,)

          注釈: *note typing.ParamSpec: 144. パラメータを含む
          ‘GenericAlias’ オブジェクトは、代入後に正しい ‘__parameters__’
          を持たない可能性があります。これは *note typing.ParamSpec:
          144. が主に静的な型チェックを目的としているためです。

 -- の属性: genericalias.__unpacked__

     これは、型エイリアスが ‘*’ 演算子を使って取り出された場合に真となる
     真偽値です (*note TypeVarTuple: 145. を参照してください)。

     Added in version 3.11.

参考
....

PEP 484(1) - 型ヒント

     型アノテーションのための Python のフレームワークへの導入です。

PEP 585(2) - 標準コレクション型の型ヒントにおける総称型 (generics) の使用

     特殊なクラスメソッド *note __class_getitem__(): 706. を実装している
     場合に、標準ライブラリのクラスに対してネイティブにパラメータ表記を
     可能にする機能への導入です。

*note ジェネリクス: 1ee0, *note ユーザー定義のジェネリック型: 49b, および *note typing.Generic: 157c.

     実行時にパラメータ設定が可能であり、かつ静的な型チェッカーが理解で
     きるジェネリッククラスを実装する方法のドキュメントです。

Added in version 3.9.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0585/


File: python.info,  Node: Union 型,  Prev: ジェネリックエイリアス型,  Up: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン

5.4.13.4 Union 型
.................

Unionオブジェクトは、複数の *note type objects: 20e6. を ‘|’ (bit演算の
or)演算した値を保持します。この型は主に *note type annotations: 424. に
使用します。Union型の式は *note typing.Union: 607. と比べて型ヒントの構
文がわかりやすくなります。

 -- Describe: X | Y | ...

     'X' と 'Y' などの型を保持するUnionオブジェクトを定義すします。‘X |
     Y’ はXとYのいずれかを意味します。これは ‘typing.Union[X, Y]’ と等価
     です。たとえば、以下の関数は引数として *note int: 238. 型または
     *note float: 2ce. 型を想定しています。:

          def square(number: int | float) -> int | float:
              return number ** 2

          注釈: ‘|’ のオペランドは、実行時に1つ以上の前方参照をメンバー
          として含むようなユニオンを定義するために使うことはできません。
          たとえば、 ‘"Foo"’ がまだ定義されていないクラスへの参照である
          場合、 ‘int | "Foo"’ は実行時に失敗します。前方参照を含むユニ
          オンは、 ‘"int | Foo"’ のように、ユニオン全体を文字列としてあ
          らわしてください。

 -- Describe: union_object == other

     Unionオブジェクトは他のUnionオブジェクトとの等価性をテストできます
     。以下は詳細です:

        * ユニオン型のユニオン型は平滑化されます:

               (int | str) | float == int | str | float

        * 余分な型は削除されます:

               int | str | int == int | str

        * ユニオン型を比較すると順序は無視されます:

               int | str == str | int

        * *note typing.Union: 607. と互換性があります:

               int | str == typing.Union[int, str]

        * Optional型は ‘None’ とのUnion型で記述できます:

               str | None == typing.Optional[str]

 -- Describe: isinstance(obj, union_object)

 -- Describe: issubclass(obj, union_object)

     *note isinstance(): 40e. と *note issubclass(): 78c. の呼び出しはど
     ちらもUnionオブジェクトをサポートしています。

          >>> isinstance("", int | str)
          True

     しかし、Unionオブジェクトの中の *note parameterized generics: 67e.
     はチェックできません:

          >>> isinstance(1, int | list[int])  # short-circuit evaluation
          True
          >>> isinstance([1], int | list[int])
          Traceback (most recent call last):
            ...
          TypeError: isinstance() argument 2 cannot be a parameterized generic

ユーザー定義の Union オブジェクトは *note types.UnionType: 606. からアク
セスすることができ、 *note isinstance(): 40e. によるチェックにも使うこと
ができます。型からオブジェクトをインスタンスかすることができません:

     >>> import types
     >>> isinstance(int | str, types.UnionType)
     True
     >>> types.UnionType()
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: cannot create 'types.UnionType' instances

     注釈: ‘X | Y’ 構文をサポートするために、型オブジェクトに ‘__or__()’
     メソッドが追加されました。メタクラスで ‘__or__()’ を実装すると
     Unionをオーバーライドする場合があります:

          >>> class M(type):
          ...     def __or__(self, other):
          ...         return "Hello"
          ...
          >>> class C(metaclass=M):
          ...     pass
          ...
          >>> C | int
          'Hello'
          >>> int | C
          int | C

参考
....

PEP 604(1) - ‘X | Y’ 構文とUnion型を提案しているPEP

Added in version 3.10.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0604/


File: python.info,  Node: その他の組み込み型,  Next: 特殊属性,  Prev: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン,  Up: 組み込み型

5.4.14 その他の組み込み型
-------------------------

インタプリタは、その他いくつかの種類のオブジェクトをサポートしています。
これらのほとんどは 1 つまたは 2 つの演算だけをサポートしています。

* Menu:

* モジュール: モジュール<4>.
* クラスおよびクラスインスタンス::
* 関数::
* メソッド::
* コードオブジェクト: コードオブジェクト<2>.
* 型オブジェクト::
* ヌルオブジェクト::
* Ellipsis オブジェクト::
* NotImplemented オブジェクト::
* 内部オブジェクト::


File: python.info,  Node: モジュール<4>,  Next: クラスおよびクラスインスタンス,  Up: その他の組み込み型

5.4.14.1 モジュール
...................

モジュールに対する唯一の特殊な演算は属性アクセス: ‘m.name’ です。ここで
'm' はモジュールで、 'name' は 'm' のシンボルテーブル上に定義された名前
にアクセスします。モジュール属性に代入することもできます。 (なお、*note
import: 5ac. 文は、厳密にいえば、モジュールオブジェクトに対する演算では
ありません; ‘import foo’ は 'foo' と名づけられたモジュールオブジェクトの
存在を必要とはせず、'foo' と名づけられたモジュールの (外部の) '定義' を
必要とします。)

全てのモジュールにある特殊属性が *note __dict__: 526. です。これはモジュ
ールのシンボルテーブルを含む辞書です。この辞書を書き換えると実際にモジュ
ールのシンボルテーブルを変更することができますが、*note __dict__: 526. 属
性を直接代入することはできません (‘m.__dict__['a'] = 1’ と書いて ‘m.a’ を
‘1’ に定義することはできますが、‘m.__dict__ = {}’ と書くことはできません
)。 *note __dict__: 526. を直接書き換えることは推奨されません。

インタプリタ内に組み込まれたモジュールは、 ‘<module 'sys' (built-in)>’ の
ように書かれます。ファイルから読み出された場合、 ‘<module 'os' from
'/usr/local/lib/pythonX.Y/os.pyc'>’ と書かれます。


File: python.info,  Node: クラスおよびクラスインスタンス,  Next: 関数,  Prev: モジュール<4>,  Up: その他の組み込み型

5.4.14.2 クラスおよびクラスインスタンス
.......................................

これらについては *note オブジェクト、値、および型: 1e43. および *note
クラス定義: 12a5. を参照してください。


File: python.info,  Node: 関数,  Next: メソッド,  Prev: クラスおよびクラスインスタンス,  Up: その他の組み込み型

5.4.14.3 関数
.............

関数オブジェクトは関数定義によって生成されます。関数オブジェクトに対する
唯一の操作は、それを呼び出すことです: ‘func(argument-list)’ 。

関数オブジェクトには実際には二種類あります: 組み込み関数とユーザ定義関数
です。どちらも同じ操作 (関数の呼び出し) をサポートしますが、実装は異なる
ので、オブジェクトの型も異なります。

詳細は、 *note 関数定義: 1ba0. を参照してください。


File: python.info,  Node: メソッド,  Next: コードオブジェクト<2>,  Prev: 関数,  Up: その他の組み込み型

5.4.14.4 メソッド
.................

メソッドは属性表記を使って呼び出される関数です。メソッドには二種類ありま
す: (リストの ‘append()’ のような) *note built-in methods: 1e6d. と、
*note class instance method: 1c28. です。組み込みメソッドは、それをサポ
ートする型と一緒に記述されています。

インスタンスを通してメソッド (クラスの名前空間内で定義された関数) にアク
セスすると、特殊なオブジェクトが得られます。それは束縛メソッド ('bound
method') オブジェクトで、インスタンスメソッド (*note instance method:
1c28.) とも呼ばれます。呼び出された時、引数リストに ‘self’ 引数が追加さ
れます。束縛メソッドには 2 つの特殊読み出し専用属性があります。 *note
m.__self__: 1370. はそのメソッドが操作するオブジェクトで、*note
m.__func__: 12ca. はそのメソッドを実装している関数です。 ‘m(arg-1,
arg-2, ..., arg-n)’ の呼び出しは、 ‘m.__func__(m.__self__, arg-1, arg-2,
..., arg-n)’ の呼び出しと完全に等価です。

*note function objects: 279. と同様に、メソッドオブジェクトは任意の属性
の取得をサポートしています。しかし、メソッド属性は実際には下層の関数オブ
ジェクト (*note method.__func__: 12ca.) に記憶されているので、バインドさ
れるメソッドにメソッド属性を設定することは許されていません。メソッドに属
性を設定しようとすると *note AttributeError: 326. が送出されます。メソッ
ドの属性を設定するためには、次のようにその下層の関数オブジェクトに明示的
に設定する必要があります:

     >>> class C:
     ...     def method(self):
     ...         pass
     ...
     >>> c = C()
     >>> c.method.whoami = 'my name is method'  # can't set on the method
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     AttributeError: 'method' object has no attribute 'whoami'
     >>> c.method.__func__.whoami = 'my name is method'
     >>> c.method.whoami
     'my name is method'

詳細は *note インスタンスメソッド: 1c28. を参照してください。


File: python.info,  Node: コードオブジェクト<2>,  Next: 型オブジェクト,  Prev: メソッド,  Up: その他の組み込み型

5.4.14.5 コードオブジェクト
...........................

コードオブジェクトは、関数本体のような "擬似コンパイルされた" Python の
実行可能コードを表すために実装系によって使われます。コードオブジェクトは
グローバルな実行環境への参照を持たない点で関数オブジェクトとは異なります
。コードオブジェクトは組み込み関数 *note compile(): 177. によって返され
、また関数オブジェクトの *note __code__: 27a. 属性として取り出せます。
*note code: 13. モジュールも参照してください。

*note __code__: 27a. へのアクセスは ‘object.__getattr__’ に ‘obj’ と
‘"__code__"’ を渡して行いますが、 *note 監査イベント: 1825. を送出します
。

コードオブジェクトは、組み込み関数 *note exec(): 164. や *note eval():
165. に (ソース文字列の代わりに) 渡すことで、実行や評価できます。

詳細は、 *note 標準型の階層: 1e46. を参照してください。


File: python.info,  Node: 型オブジェクト,  Next: ヌルオブジェクト,  Prev: コードオブジェクト<2>,  Up: その他の組み込み型

5.4.14.6 型オブジェクト
.......................

型オブジェクトは様々なオブジェクト型を表します。オブジェクトの型は組み込
み関数 *note type(): d16. でアクセスされます。型オブジェクトには特有の操
作はありません。標準モジュール *note types: ec. には全ての組み込み型名が
定義されています。

型はこのように書き表されます: ‘<class 'int'>’ 。


File: python.info,  Node: ヌルオブジェクト,  Next: Ellipsis オブジェクト,  Prev: 型オブジェクト,  Up: その他の組み込み型

5.4.14.7 ヌルオブジェクト
.........................

このオブジェクトは明示的に値を返さない関数によって返されます。このオブジ
ェクトには特有の操作はありません。ヌルオブジェクトは一つだけで、 ‘None’
(組み込み名) と名づけられています。 ‘type(None)()’ は同じシングルトンを
作成します。

‘None’ と書き表されます。


File: python.info,  Node: Ellipsis オブジェクト,  Next: NotImplemented オブジェクト,  Prev: ヌルオブジェクト,  Up: その他の組み込み型

5.4.14.8 Ellipsis オブジェクト
..............................

このオブジェクトは一般にスライシングによって使われます (*note
スライス表記 (slicing): 1fab. を参照してください)。特殊な演算は何もサポ
ートしていません。Ellipsis オブジェクトは一つだけで、その名前は *note
Ellipsis: 20ea. (組み込み名) です。‘type(Ellipsis)()’ は単一の *note
Ellipsis: 20ea. を作成します。

‘Ellipsis’ または ‘...’ と書き表されます。


File: python.info,  Node: NotImplemented オブジェクト,  Next: 内部オブジェクト,  Prev: Ellipsis オブジェクト,  Up: その他の組み込み型

5.4.14.9 NotImplemented オブジェクト
....................................

このオブジェクトは、対応していない型に対して比較演算や二項演算が求められ
たとき、それらの演算から返されます。詳細は *note 比較: 1fd1. を参照して
ください。 *note NotImplemented: 79d. オブジェクトは一つだけです。
‘type(NotImplemented)()’ はこの単一のインスタンスを作成します。

‘NotImplemented’ と書き表されます。


File: python.info,  Node: 内部オブジェクト,  Prev: NotImplemented オブジェクト,  Up: その他の組み込み型

5.4.14.10 内部オブジェクト
..........................

この情報は *note 標準型の階層: 1e46. を参照してください。*note stack
frame objects: 6ab.、*note traceback objects: ac2.、スライスオブジェクト
について記述されています。


File: python.info,  Node: 特殊属性,  Next: 整数と文字列の変換での長さ制限,  Prev: その他の組み込み型,  Up: 組み込み型

5.4.15 特殊属性
---------------

実装は、いくつかのオブジェクト型に対して、適切な場合には特殊な読み出し専
用の属性を追加します。そのうちいくつかは *note dir(): 5fe. 組込み関数で
報告されません。

 -- の属性: definition.__name__

     クラス、関数、メソッド、デスクリプタ、ジェネレータインスタンスの名
     前です。

 -- の属性: definition.__qualname__

     クラス、関数、メソッド、デスクリプタ、ジェネレータインスタンスの
     *note 修飾名: 18ab. です。

     Added in version 3.3.

 -- の属性: definition.__module__

     The name of the module in which a class or function was defined.

 -- の属性: definition.__doc__

     The documentation string of a class or function, or ‘None’ if
     undefined.

 -- の属性: definition.__type_params__

     The *note type parameters: 293. of generic classes, functions, and
     *note type aliases: 420.  For classes and functions that are not
     generic, this will be an empty tuple.

     Added in version 3.12.


File: python.info,  Node: 整数と文字列の変換での長さ制限,  Prev: 特殊属性,  Up: 組み込み型

5.4.16 整数と文字列の変換での長さ制限
-------------------------------------

CPythonはDoS(サービス妨害攻撃)を軽減するために *note int: 238. と *note
str: 418. の間の変換に全体的な制限を設けました。この制限は10進数や2のべ
き乗以外の基数に 'のみ' 適用されます。16進数、8進数と2進数は制限がありま
せん。上限値は設定できます。

CPython の *note int: 238. 型は、任意の長さの数をバイナリ形式で保存した
ものです (一般に "bignum" または多倍長整数として知られています)。基数が
2のべき乗でない限り、線形の時間で文字列をバイナリ整数に、あるいはバイナ
リ整数を文字列に変換できるアルゴリズムは存在しません。10進数に対するアル
ゴリズムでは、最もよく知られているものでさえ、2次に近い (sub-quadratic)
複雑さになります。高速な CPU でも、 ‘int('1' * 500_000)’ のような大きな
数の変換は1秒以上かかる可能性があります。

変換するサイズを制限することは、 CVE 2020-10735(1) を回避する実践的な方
法を提供します。

制限は、非線形な変換アルゴリズムが必要とされる場合に、入力または出力文字
列の桁数に対して適用されます。アンダースコアや正負の符号はカウントされま
せん。

演算の結果が制限を超えると、*note ValueError: 1e3. が送出されます:

     >>> import sys
     >>> sys.set_int_max_str_digits(4300)  # Illustrative, this is the default.
     >>> _ = int('2' * 5432)
     Traceback (most recent call last):
     ...
     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
     >>> i = int('2' * 4300)
     >>> len(str(i))
     4300
     >>> i_squared = i*i
     >>> len(str(i_squared))
     Traceback (most recent call last):
     ...
     ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit
     >>> len(hex(i_squared))
     7144
     >>> assert int(hex(i_squared), base=16) == i*i  # Hexadecimal is unlimited.

デフォルトの上限値は4,300桁で、*note
sys.int_info.default_max_str_digits: 1264. で定義されています。設定可能
な最小の上限値は 640 桁で、 *note
sys.int_info.str_digits_check_threshold: 1264. で定義されています。

確認:

     >>> import sys
     >>> assert sys.int_info.default_max_str_digits == 4300, sys.int_info
     >>> assert sys.int_info.str_digits_check_threshold == 640, sys.int_info
     >>> msg = int('578966293710682886880994035146873798396722250538762761564'
     ...           '9252925514383915483333812743580549779436104706260696366600'
     ...           '571186405732').to_bytes(53, 'big')
     ...

Added in version 3.11.

* Menu:

* 影響のあるAPI::
* 上限値を設定する::
* 推奨設定::

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2020-10735


File: python.info,  Node: 影響のあるAPI,  Next: 上限値を設定する,  Up: 整数と文字列の変換での長さ制限

5.4.16.1 影響のあるAPI
......................

制限は *note int: 238. と *note str: 418. または *note bytes: 1a4. の間
での変換で時間がかかる可能性があると適用されます:

   * ‘int(string)’ でデフォルトの基数10。

   * ‘int(string, base)’ で2のべき乗以外のすべての基数。

   * ‘str(integer)’

   * ‘repr(integer)’

   * 他の10進数での文字列変換。たとえば ‘f"{integer}"’、
     ‘"{}".format(integer)’ や ‘b"%d" % integer’。

制限は、線形アルゴリズムの関数では適用されません。

   * ‘int(string, base)’ で基数が2、4、8、16または32。

   * *note int.from_bytes(): 17ba. と *note int.to_bytes(): 17fa. 。

   * *note hex(): 129d, *note oct(): 129c, *note bin(): 127a.

   * *note 書式指定ミニ言語仕様: 1c9. での16進数、8進数、2進数での表現。

   * *note str: 418. から *note float: 2ce.。

   * *note str: 418. から *note decimal.Decimal: 27d.。


File: python.info,  Node: 上限値を設定する,  Next: 推奨設定,  Prev: 影響のあるAPI,  Up: 整数と文字列の変換での長さ制限

5.4.16.2 上限値を設定する
.........................

Pythonを起動する前に環境変数またはインタープリタのコマンドラインのフラグ
で上限値を設定できます。

   * *note PYTHONINTMAXSTRDIGITS: 1728.、たとえば
     ‘PYTHONINTMAXSTRDIGITS=640 python3’ は上限値を640に設定し、
     ‘PYTHONINTMAXSTRDIGITS=0 python3’ は制限を無効化します。

   * *note -X int_max_str_digits: 15c.、たとえば ‘python3 -X
     int_max_str_digits=640’

   * *note sys.flags.int_max_str_digits: 21d8. には *note
     PYTHONINTMAXSTRDIGITS: 1728. または *note -X int_max_str_digits:
     15c. の値が設定されます。環境変数と ‘-X’ オプションの両方が指定され
     た場合は ‘-X’ オプションが優先されます。 '-1' という値はどちらも未
     設定であることを表し、その場合は *note
     sys.int_info.default_max_str_digits: 21d9. の値が初期化時に使用され
     ます。

コードでは、以下の *note sys: c3. APIを使用して現在の上限値を調べ、新し
い値を設定できます。

   * *note sys.get_int_max_str_digits(): 21da. と *note
     sys.set_int_max_str_digits(): 1729. はインタープリタ全体での上限値
     を取得、設定できます。サブインタープリタはそれぞれの上限値を持ちま
     す。

デフォルト値と最小値に関する情報は *note sys.int_info: 1264. で参照でき
ます:

   * *note sys.int_info.default_max_str_digits: 1264. はコンパイル時のデ
     フォルト上限値です。

   * *note sys.int_info.str_digits_check_threshold: 1264. は上限値として
     指定できる最低の値です(0の場合は無効になります)。

Added in version 3.11.

     注意: 小さな上限値を設定することで、問題が起きる '可能性があります'
     。まれではありますが、ソースコード内で閾値を超える定数が10進数の整
     数として存在するコードが存在します。値に制限をつけることの帰結は、
     10進数の整数リテラルで制限を超える長さを持つ定数を含むコードのパー
     ス時、すなわち通常は起動時、モジュールのインポート時、またはインス
     トール時など、そのコードのための ‘.pyc’ ファイルが作られるまでのど
     こかの時点でのエラーです。大きな定数を含むソースコードに対する回避
     策は、その定数を、 ‘0x’ を使って値の制限を持たない16進数の値に変換
     することです。

     小さな上限値を使う場合、アプリケーションを徹底的にテストしてくださ
     い。環境変数やフラグを使って、制限が起動時や、さらにはインストール
     の段階で Python が ‘.py’ ファイルを事前にコンパイルして ‘.pyc’ ファ
     イルを作成する際にも適用されるようにした状態で、確実にテストが実行
     されるようにしてください。


File: python.info,  Node: 推奨設定,  Prev: 上限値を設定する,  Up: 整数と文字列の変換での長さ制限

5.4.16.3 推奨設定
.................

デフォルトの *note sys.int_info.default_max_str_digits: 21d9. は、ほとん
どのアプリケーションで適切な値であると期待されます。もしあなたのアプリケ
ーションが異なる制限値を必要とする場合は、メインのエントリーポイントから
、 Python バージョンに依存しないコードを使って制限値を設定してください。
こうしなければならない理由は、これらの API が 3.12 以前のセキュリテイパ
ッチリリースで追加されたためです。

以下はプログラム例です:

     >>> import sys
     >>> if hasattr(sys, "set_int_max_str_digits"):
     ...     upper_bound = 68000
     ...     lower_bound = 4004
     ...     current_limit = sys.get_int_max_str_digits()
     ...     if current_limit == 0 or current_limit > upper_bound:
     ...         sys.set_int_max_str_digits(upper_bound)
     ...     elif current_limit < lower_bound:
     ...         sys.set_int_max_str_digits(lower_bound)

完全に無効にするには、‘0’ に設定します。

脚注
....


File: python.info,  Node: 組み込み例外,  Next: テキスト処理サービス,  Prev: 組み込み型,  Up: Python 標準ライブラリ

5.5 組み込み例外
================

Python において、すべての例外は *note BaseException: 584. から派生したク
ラスのインスタンスでなければなりません。特定のクラスを言及する *note
except: 170. 節を伴う *note try: 6b4. 文において、その節はそのクラスから
派生した例外クラスも処理しますが、そのクラスの派生 '元' の例外クラスは処
理しません。サブクラス化の関係にない 2 つの例外クラスは、それらが同じ名
前だった場合でも等しくなりえません。

この章で挙げる組み込み例外は、インタプリタや組み込み関数によって生成され
ます。特に注記しないかぎり、これらはエラーの詳しい原因を示す "関連値
(associated value)" を持ちます。この値は、複数の情報 (エラーコードや、そ
のコードを説明する文字列など) の文字列かタプルです。関連値は通常、例外ク
ラスのコンストラクタに引数として渡されます。

ユーザによるコードも組み込み例外を送出できます。これを使って、例外ハンド
ラをテストしたり、インタプリタが同じ例外を送出する状況と "ちょうど同じよ
うな" エラー条件であることを報告したりできます。しかし、ユーザのコードが
適切でないエラーを送出するのを妨げる方法はないので注意してください。

組み込み例外クラスは新たな例外を定義するためにサブクラス化することができ
ます。新しい例外は、*note Exception: 9a7. クラスかそのサブクラスの一つか
ら派生することをお勧めします。 *note BaseException: 584. からは派生しな
いで下さい。例外を定義する上での詳しい情報は、 Python チュートリアルの
*note ユーザー定義例外: 1bfe. の項目にあります。

* Menu:

* 例外コンテキスト::
* 組み込み例外から継承する::
* 基底クラス::
* 具象例外::
* 警告::
* 例外グループ::
* 例外のクラス階層::


File: python.info,  Node: 例外コンテキスト,  Next: 組み込み例外から継承する,  Up: 組み込み例外

5.5.1 例外コンテキスト
----------------------

例外オブジェクトの3つの属性は、例外が送出された常用に関する情報を提供し
ます:

 -- の属性: BaseException.__context__
 -- の属性: BaseException.__cause__
 -- の属性: BaseException.__suppress_context__

     When raising a new exception while another exception is already
     being handled, the new exception's ‘__context__’ attribute is
     automatically set to the handled exception.  An exception may be
     handled when an *note except: 170. or *note finally: 997. clause,
     or a *note with: 59c. statement, is used.

     This implicit exception context can be supplemented with an
     explicit cause by using ‘from’ with *note raise: 5b7.:

          raise new_exc from original_exc

     *note from: 5b7. に続く式は例外か ‘None’ でなくてはなりません。 式
     は送出される例外の ‘__cause__’ として設定されます。 ‘__cause__’ を
     設定することは、 ‘__suppress_context__’ 属性を暗黙的に ‘True’ に設
     定することにもなるので、 ‘raise new_exc from None’ を使うことで効率
     的に古い例外を新しいもので置き換えて表示する (例えば、 *note
     KeyError: 31d. を *note AttributeError: 326. に置き換え)、古い例外
     はデバッグ時の調査で使えるよう ‘__context__’ に残すことができます。

     デフォルトの traceback 表示コードは、例外自体の traceback に加え、
     これらの連鎖された例外を表示します。‘__cause__’ で明示的に連鎖させ
     た例外は、存在するならば常に表示されます。‘__context__’ で暗黙に連
     鎖させた例外は、‘__cause__’ が *note None: 641. かつ
     ‘__suppress_context__’ が false の場合にのみ表示されます。

     いずれにせよ、連鎖された例外に続いて、その例外自体は常に表示されま
     す。そのため、traceback の最終行には、常に送出された最後の例外が表
     示されます。


File: python.info,  Node: 組み込み例外から継承する,  Next: 基底クラス,  Prev: 例外コンテキスト,  Up: 組み込み例外

5.5.2 組み込み例外から継承する
------------------------------

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.

'CPython 実装の詳細:' Most built-in exceptions are implemented in C for
efficiency, see: Objects/exceptions.c(1).  Some have custom memory
layouts which makes it impossible to create a subclass that inherits
from multiple exception types.  The memory layout of a type is an
implementation detail and might change between Python versions, leading
to new conflicts in the future.  Therefore, it's recommended to avoid
subclassing multiple exception types altogether.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Objects/exceptions.c


File: python.info,  Node: 基底クラス,  Next: 具象例外,  Prev: 組み込み例外から継承する,  Up: 組み込み例外

5.5.3 基底クラス
----------------

以下の例外は、主に他の例外の基底クラスとして使われます。

 -- 例外: BaseException

     全ての組み込み例外の基底クラスです。ユーザ定義の例外に直接継承され
     ることは意図されていません (継承には *note Exception: 9a7. を使って
     ください)。このクラスのインスタンスに *note str(): 418. が呼ばれた
     場合、インスタンスへの引数の表現か、引数が無い場合には空文字列が返
     されます。

      -- の属性: args

          例外コンストラクタに与えられた引数のタプルです。組み込み例外は
          普通、エラーメッセージを与える一つの文字列だけを引数として呼ば
          れますが、中には (*note OSError: 3f0. など) いくつかの引数を必
          要とし、このタプルの要素に特別な意味を込めるものもあります。

      -- メソッド: with_traceback (tb)

          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 features of PEP 3134(1) became
          available.  The following example shows how we can convert an
          instance of ‘SomeException’ into an instance of
          ‘OtherException’ while preserving the traceback.  Once raised,
          the current frame is pushed onto the traceback of the
          ‘OtherException’, as would have happened to the traceback of
          the original ‘SomeException’ had we allowed it to propagate to
          the caller.

               try:
                   ...
               except SomeException:
                   tb = sys.exception().__traceback__
                   raise OtherException(...).with_traceback(tb)

      -- の属性: __traceback__

          A writable field that holds the *note traceback object: ac2.
          associated with this exception.  See also: *note raise 文:
          5b7.

      -- メソッド: add_note (note)

          例外のノートとして文字列 ‘note’ を追加します。ノートは標準のト
          レースバックで例外文字列の後に表示されます。‘note’ が文字列以
          外の場合 *note TypeError: 502. が送出されます。

          Added in version 3.11.

      -- の属性: __notes__

          *note add_note(): 585. で追加された例外のノートのリスト。この
          属性は *note add_note(): 585. を呼び出すと生成されます。

          Added in version 3.11.

 -- 例外: Exception

     システム終了以外の全ての組み込み例外はこのクラスから派生しています
     。全てのユーザ定義例外もこのクラスから派生させるべきです。

 -- 例外: ArithmeticError

     算術上の様々なエラーに対して送出される組み込み例外 *note
     OverflowError: 84e, *note ZeroDivisionError: 913, *note
     FloatingPointError: 21e3. の基底クラスです。

 -- 例外: BufferError

     *note バッファ: 371. に関連する操作が行えなかったときに送出されます
     。

 -- 例外: LookupError

     マッピングまたはシーケンスで使われたキーやインデクスが無効な場合に
     送出される例外 *note IndexError: 14de. および *note KeyError: 31d.
     の基底クラスです。 *note codecs.lookup(): 931. によって直接送出され
     ることもあります。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3134/


File: python.info,  Node: 具象例外,  Next: 警告,  Prev: 基底クラス,  Up: 組み込み例外

5.5.4 具象例外
--------------

以下の例外は、通常送出される例外です。

 -- 例外: AssertionError

     *note assert: 936. 文が失敗した場合に送出されます。

 -- 例外: AttributeError

     属性参照 (*note 属性参照: 1fa5. を参照) や代入が失敗した場合に送出
     されます (オブジェクトが属性の参照や属性の代入をまったくサポートし
     ていない場合には *note TypeError: 502. が送出されます)。

     コンストラクタのキーワード専用引数を使って ‘name’ および ‘obj’ 属性
     を設定できます。設定された場合、アクセスが試みられた属性の名前と、
     その属性にアクセスしたオブジェクトを、それぞれ表します。

     バージョン 3.10 で変更: ‘name’ および ‘obj’ 属性が追加されました。

 -- 例外: EOFError

     *note input(): 12a6. が何もデータを読まずに end-of-file (EOF) に達
     した場合に送出されます。(注意: ‘io.IOBase.read()’ と *note
     io.IOBase.readline(): 12f8. メソッドは、EOF に達すると空文字列を返
     します。)

 -- 例外: FloatingPointError

     現在は使われていません。

 -- 例外: GeneratorExit

     *note ジェネレータ: 1035. や *note コルーチン: 45e. が閉じられたと
     きに送出されます。 *note generator.close(): 1659. と *note
     coroutine.close(): 1f2d. を参照してください。この例外は厳密に言えば
     エラーではないので、 *note Exception: 9a7. ではなく *note
     BaseException: 584. を直接継承しています。

 -- 例外: ImportError

     *note import: 5ac. 文でモジュールをロードしようとして問題が発生する
     と送出されます。 ‘from ... import’ の中の"from list" (訳注：‘...’ の
     部分)の名前が見つからないときにも送出されます。

     オブションのキーワード専用引数 'name' と 'path' は、対応する属性に
     設定されます:

      -- の属性: name

          インポートを試みたモジュールの名前。

      -- の属性: path

          例外を引き起こしたファイルのパス。

     バージョン 3.3 で変更: *note name: 21e5. および *note path: 21e6. 属
     性が追加されました。

 -- 例外: ModuleNotFoundError

     *note ImportError: 3f2. のサブクラスで、*note import: 5ac. 文でモジ
     ュールが見つからない場合に送出されます。また、 *note sys.modules:
     18d6. に ‘None’ が含まれる場合にも送出されます。

     Added in version 3.6.

 -- 例外: IndexError

     シーケンスの添字が範囲外の場合に送出されます。 (スライスのインデク
     スはシーケンスの範囲に収まるように暗黙のうちに調整されます; インデ
     クスが整数でない場合、 *note TypeError: 502. が送出されます。)

 -- 例外: KeyError

     マッピング (辞書) のキーが、既存のキーの集合内に見つからなかった場
     合に送出されます。

 -- 例外: KeyboardInterrupt

     ユーザが割り込みキー (通常は ‘Control-C’ または ‘Delete’) を押した
     場合に送出されます。実行中、割り込みは定期的に監視されます。*note
     Exception: 9a7. を捕捉するコードに誤って捕捉されてインタプリタの終
     了が阻害されないように、この例外は *note BaseException: 584. を継承
     しています。

          注釈: Catching a *note KeyboardInterrupt: 99f. requires
          special consideration.  Because it can be raised at
          unpredictable points, it may, in some circumstances, leave the
          running program in an inconsistent state.  It is generally
          best to allow *note KeyboardInterrupt: 99f. to end the program
          as quickly as possible or avoid raising it entirely.  (See
          *note Note on Signal Handlers and Exceptions: 21e7.)

 -- 例外: MemoryError

     ある操作中にメモリが不足したが、その状況は (オブジェクトをいくつか
     消去することで) まだ復旧可能かもしれない場合に送出されます。この例
     外の関連値は、メモリ不足になった (内部) 操作の種類を示す文字列です
     。下層のメモリ管理アーキテクチャ (C の ‘malloc()’ 関数) のために、
     インタプリタが現状から完璧に復旧できるとはかぎらないので注意してく
     ださい。それでも、プログラムの暴走が原因の場合に備えて実行スタック
     のトレースバックを出力できるように、例外が送出されます。

 -- 例外: NameError

     ローカルまたはグローバルの名前が見つからなかった場合に送出されます
     。これは非修飾の (訳注: ‘spam.egg’ ではなく単に ‘egg’ のような) 名
     前のみに適用されます。関連値は見つからなかった名前を含むエラーメッ
     セージです。

     コンストラクタのキーワード専用引数を使って ‘name’ 属性を設定できま
     す。設定された場合、アクセスが試みられた変数の名前を表します。

     バージョン 3.10 で変更: ‘name’ 属性が追加されました。

 -- 例外: NotImplementedError

     この例外は *note RuntimeError: 17a. から派生しています。ユーザ定義
     の基底クラスにおいて、抽象メソッドが派生クラスでオーバライドされる
     ことを要求する場合にこの例外を送出しなくてはなりません。またはクラ
     スは実装中であり本来の実装を追加する必要があることを示します。

          注釈: 演算子やメソッドがサポートされていないことを示す目的でこ
          の例外を使用するべきではありません。そのようなケースではオペレ
          ータやメソッドを未定義のままとするか、サブクラスの場合は *note
          None: 641. を設定してください。

          注釈: ‘NotImplementedError’ と *note NotImplemented: 79d. は、
          似たような名前と目的を持っていますが、相互に変換できません。 利
          用する際には、‘NotImplemented’ を参照してください。

 -- 例外: OSError ([arg])

 -- 例外: OSError (errno, strerror[, filename[, winerror[, filename2]]])

     この例外はシステム関数がシステム関連のエラーを返した場合に送出され
     ます。例えば "file not found" や "disk full" のような I/O の失敗が
     発生したときです (引数の型が不正な場合や、他の偶発的なエラーは除き
     ます)。

     コンストラクタの2番目の形式は下記の対応する属性を設定します。指定さ
     れなかった場合属性はデフォルトで *note None: 641. です。後方互換性
     のために、引数が3つ渡された場合、*note args: 538. 属性は最初の2つの
     要素のみからなるタプルを持ちます。

     コンストラクタは実際には、 *note OS exceptions: 21e8. で述べられて
     いる *note OSError: 3f0. のサブクラスを返すことがよくあります。特定
     のサブクラスは最終的な *note errno: 21e9. 値によります。この挙動は
     *note OSError: 3f0. を直接またはエイリアスで構築し、サブクラス化時
     に継承されなかった場合にのみ発生します。

      -- の属性: errno

          C 変数 ‘errno’ に由来する数値エラーコードです。

      -- の属性: winerror

          Windows において、ネイティブ Windows エラーコードを与えます。
          そして *note errno: 21e9. 属性は POSIX でいうネイティブエラー
          コードへのおよその翻訳です。

          Windows では、'winerror' コンストラクタ引数が整数の場合 *note
          errno: 21e9. 属性は Windows エラーコードから決定され、'errno'
          引数は無視されます。他のプラットフォームでは 'winerror' 引数は
          無視され、 *note winerror: 21ea. 属性は存在しません。

      -- の属性: strerror

          OS が提供するような、対応するエラーメッセージです。 POSIX では
          ‘perror()’ で、Windows では ‘FormatMessage()’ で体裁化されます
          。

      -- の属性: filename
      -- の属性: filename2

          ファイルシステムパスが1つ関与する例外 (例えば *note open():
          4e5. や *note os.unlink(): 10c6.) の場合、*note filename:
          21ec. は関数に渡されたファイル名です。 ファイルシステムパスが
          2つ関与する関数 (例えば *note os.rename(): 10c2.) の場合、
          *note filename2: 21ed. は関数に渡された2つ目のファイル名です。

     バージョン 3.3 で変更: *note EnvironmentError: 1027, *note IOError:
     1026, *note WindowsError: 1028, *note socket.error: 1029, *note
     select.error: 102a, ‘mmap.error’ が *note OSError: 3f0. に統合され
     ました。コンストラクタはサブクラスを返すかもしれません。

     バージョン 3.4 で変更: *note filename: 21ec. 属性が *note
     filesystem encoding and error handler: 505. のエンコーディングでエ
     ンコードやデコードされた名前から、関数に渡された元々のファイル名に
     なりました。 また、'filename2' コンストラクタ引数が追加されました。

 -- 例外: OverflowError

     算術演算の結果が表現できない大きな値になった場合に送出されます。こ
     れは整数では起こりません (むしろ *note MemoryError: 1627. が送出さ
     れることになるでしょう)。しかし、歴史的な理由のため、要求された範囲
     の外の整数に対して OverflowError が送出されることがあります。C の浮
     動小数点演算の例外処理は標準化されていないので、ほとんどの浮動小数
     点演算もチェックされません。

 -- 例外: PythonFinalizationError

     This exception is derived from *note RuntimeError: 17a.  It is
     raised when an operation is blocked during interpreter shutdown
     also known as *note Python finalization: 134.

     Examples of operations which can be blocked with a *note
     PythonFinalizationError: 133. during the Python finalization:

        * Creating a new Python thread.

        * *note os.fork(): 17c.

     *note sys.is_finalizing(): a5d. 関数も参照してください。

     Added in version 3.13: 以前は *note RuntimeError: 17a. をそのまま送
     出していました。

 -- 例外: RecursionError

     この例外は *note RuntimeError: 17a. を継承しています。インタープリ
     タが最大再帰深度 (*note sys.getrecursionlimit(): 490. を参照) の超
     過を検出すると送出されます。

     Added in version 3.5: 以前は *note RuntimeError: 17a. をそのまま送
     出していました。

 -- 例外: ReferenceError

     *note weakref.proxy(): a20. によって生成された弱参照 (weak
     reference) プロキシを使って、ガーベジコレクションによって回収された
     後の参照対象オブジェクトの属性にアクセスした場合に送出されます。弱
     参照については *note weakref: fc. モジュールを参照してください。

 -- 例外: RuntimeError

     他のカテゴリに分類できないエラーが検出された場合に送出されます。関
     連値は、何が問題だったのかをより詳細に示す文字列です。

 -- 例外: StopIteration

     組込み関数 *note next(): 7a3. と *note iterator: 191. の *note
     __next__(): 129b. メソッドによって、そのイテレータが生成するアイテ
     ムがこれ以上ないことを伝えるために送出されます。

      -- の属性: value

          この例外オブジェクトには一つの属性 ‘value’ があり、例外を構成
          する際に引数として与えられ、デフォルトは *note None: 641. です
          。

     *note generator: 1035. や *note coroutine: 45e. 関数が返るとき、新
     しい *note StopIteration: bc8. インスタンスが送出されます。 関数の
     返り値は例外のコンストラクタの *note value: 1f2a. 引数として使われ
     ます。

     ジェネレータのコードが直接的あるいは間接的に *note StopIteration:
     bc8. を送出する場合は、 *note RuntimeError: 17a. に変換されます
     (*note StopIteration: bc8. は変換後の例外の原因として保持されます
     )。

     バージョン 3.3 で変更: ‘value’ 属性とジェネレータ関数が値を返すため
     にそれを使う機能が追加されました。

     バージョン 3.5 で変更: ‘from __future__ import generator_stop’ によ
     る RuntimeError への変換が導入されました。 PEP 479(1) を参照してく
     ださい。

     バージョン 3.7 で変更: PEP 479(2) が全てのコードでデフォルトで有効
     化されました: ジェネレータから送出された *note StopIteration: bc8.
     は *note RuntimeError: 17a. に変換されます。

 -- 例外: StopAsyncIteration

     イテレーションを停止するために、 *note asynchronous iterator: 190.
     オブジェクトの *note __anext__(): 1e6a. メソッドによって返される必
     要があります。

     Added in version 3.5.

 -- 例外: SyntaxError (message, details)

     パーザが構文エラーに遭遇した場合に送出されます。この例外は *note
     import: 5ac. 文、組み込み関数 *note compile(): 177.、*note exec():
     164. や *note eval(): 165. 、初期化スクリプトの読み込みや標準入力で
     (対話的な実行時にも) 起こる可能性があります。

     例外インスタンスの *note str(): 418. はエラーメッセージのみを返しま
     す。詳細はタプルで、個々の属性としても利用できます。

      -- の属性: filename

          構文エラーが発生したファイルの名前。

      -- の属性: lineno

          ファイルのエラーが発生した行番号。1から数えはじめるため、ファ
          イルの最初の行の ‘lineno’ は1です。

      -- の属性: offset

          行のエラーが発生した列番号。1から数えはじめるため、行の最初の
          文字の ‘offset’ は1です。

      -- の属性: text

          エラーを含むソースコードのテキスト。

      -- の属性: end_lineno

          ファイルのエラーが発生した最後の行番号。1から数えはじめるため
          、ファイルの最初の行の ‘lineno’ は1です。

      -- の属性: end_offset

          行のエラーが発生した最後の列番号。1から数えはじめるため、行の
          最初の文字の ‘offset’ は1です。

     For errors in f-string fields, the message is prefixed by
     "f-string: " and the offsets are offsets in a text constructed from
     the replacement expression.  For example, compiling f'Bad {a b}
     field' results in this args attribute: ('f-string: ...', ('', 1, 2,
     '(a b)n', 1, 5)).

     バージョン 3.10 で変更: *note end_lineno: 21f2. および *note
     end_offset: 21f3. 属性が追加されました。

 -- 例外: IndentationError

     正しくないインデントに関する構文エラーの基底クラスです。これは
     *note SyntaxError: 172. のサブクラスです。

 -- 例外: TabError

     タブとスペースを一貫しない方法でインデントに使っているときに送出さ
     れます。これは *note IndentationError: 773. のサブクラスです。

 -- 例外: SystemError

     インタプリタが内部エラーを発見したが、状況は全ての望みを棄てさせる
     ほど深刻ではないと思われる場合に送出されます。関連値は (下位層で) ど
     の動作が失敗したかを示す文字列です。

     使用中の Python インタプリタの作者または保守担当者にこのエラーを報
     告してください。このとき、Python インタプリタのバージョン
     (‘sys.version’ 。Python の対話的セッションを開始した際にも出力され
     ます)、正確なエラーメッセージ (例外の関連値) を忘れずに報告してくだ
     さい。可能な場合にはエラーを引き起こしたプログラムのソースコードも
     報告してください。

 -- 例外: SystemExit

     この例外は *note sys.exit(): 1318. 関数から送出されます。*note
     Exception: 9a7. をキャッチするコードに誤ってキャッチされないように
     、*note Exception: 9a7. ではなく *note BaseException: 584. を継承し
     ています。これにより例外は上の階層に適切に伝わり、インタープリタを
     終了させます。この例外が処理されなかった場合はスタックのトレースバ
     ックを表示せずに Python インタープリタは終了します。コンストラクタ
     は *note sys.exit(): 1318. に渡されるオプション引数と同じものを受け
     取ります。値が整数の場合、システムの終了ステータス (C 言語の
     ‘exit()’ 関数に渡すもの)を指定します。値が ‘None’ の場合、終了ステ
     ータスは 0 です。それ以外の型の場合 (例えば str)、 オブジェクトの値
     が表示され、終了ステータスは 1 です。

     *note sys.exit(): 1318. は、クリーンアップのための処理 (*note try:
     6b4. 文の *note finally: 997. 節) が実行されるようにするため、また
     デバッガが制御不能になるリスクを冒さずにスクリプトを実行できるよう
     にするために例外に変換されます。即座に終了することが真に強く必要で
     あるとき (例えば、*note os.fork(): 17c. を呼んだ後の子プロセス内) に
     は *note os._exit(): 21f4. 関数を使うことができます。

      -- の属性: code

          コンストラクタに渡された終了ステータス又はエラーメッセージ。
          (デフォルトは ‘None’)

 -- 例外: TypeError

     組み込み演算または関数が適切でない型のオブジェクトに対して適用され
     た際に送出されます。関連値は型の不整合に関して詳細を述べた文字列で
     す。

     この例外は、そのオブジェクトで実行しようとした操作がサポートされて
     おらず、その予定もない場合にユーザーコードから送出されるかもしれま
     せん。オブジェクトでその操作をサポートするつもりだが、まだ実装を提
     供していないのであれば、送出する適切な例外は *note
     NotImplementedError: 209. です。

     誤った型の引数が渡された場合は (例えば、*note int: 238. が期待され
     るのに、*note list: 5dc. が渡された) *note TypeError: 502. となるべ
     きです。しかし、誤った値(例えば、期待する範囲外の数)が引数として渡
     された場合は、 *note ValueError: 1e3. となるべきです。

 -- 例外: UnboundLocalError

     関数やメソッド内のローカルな変数に対して参照を行ったが、その変数に
     は値が代入されていなかった場合に送出されます。 *note NameError:
     40b. のサブクラスです。

 -- 例外: UnicodeError

     Unicode に関するエンコードまたはデコードのエラーが発生した際に送出
     されます。 *note ValueError: 1e3. のサブクラスです。

     *note UnicodeError: 1275. はエンコードまたはデコードのエラーの説明
     を属性として持っています。例えば、 ‘err.object[err.start:err.end]’
     は、無効な入力のうちコーデックが処理に失敗した箇所を表します。

      -- の属性: encoding

          エラーを送出したエンコーディングの名前です。

      -- の属性: reason

          そのコーデックエラーを説明する文字列です。

      -- の属性: object

          コーデックがエンコードまたはデコードしようとしたオブジェクトで
          す。

      -- の属性: start

          *note object: a5a. の最初の無効なデータのインデクスです。

      -- の属性: end

          *note object: a5a. の最後の無効なデータの次のインデクスです。

 -- 例外: UnicodeEncodeError

     Unicode 関連のエラーがエンコード中に発生した際に送出されます。
     *note UnicodeError: 1275. のサブクラスです。

 -- 例外: UnicodeDecodeError

     Unicode 関連のエラーがデコード中に発生した際に送出されます。 *note
     UnicodeError: 1275. のサブクラスです。

 -- 例外: UnicodeTranslateError

     Unicode 関連のエラーが変換中に発生した際に送出されます。 *note
     UnicodeError: 1275. のサブクラスです。

 -- 例外: ValueError

     演算子や関数が、正しい型だが適切でない値を持つ引数を受け取ったとき
     や、 *note IndexError: 14de. のようなより詳細な例外では記述できない
     状況で送出されます。

 -- 例外: ZeroDivisionError

     除算や剰余演算の第二引数が 0 であった場合に送出されます。関連値は文
     字列で、その演算における被演算子と演算子の型を示します。

以下の例外は、過去のバージョンとの後方互換性のために残されています;
Python 3.3 より、これらは *note OSError: 3f0. のエイリアスです。

 -- 例外: EnvironmentError

 -- 例外: IOError

 -- 例外: WindowsError

     Windows でのみ利用できます。

* Menu:

* OS 例外::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0479/

   (2) https://peps.python.org/pep-0479/


File: python.info,  Node: OS 例外,  Up: 具象例外

5.5.4.1 OS 例外
...............

以下の例外は *note OSError: 3f0. のサブクラスで、システムエラーコードに
依存して送出されます。

 -- 例外: BlockingIOError

     ある操作が、ノンブロッキング操作に設定されたオブジェクト (例えばソ
     ケット) をブロックしそうになった場合に送出されます。‘errno’ *note
     EAGAIN: 21fa, *note EALREADY: 21fb, *note EWOULDBLOCK: 21fc. および
     *note EINPROGRESS: 21fd. に対応します。

     *note BlockingIOError: 102b. は、 *note OSError: 3f0. の属性に加え
     て一つの属性を持ちます:

      -- の属性: characters_written

          ストリームがブロックされるまでに書き込まれた文字数を含む整数で
          す。この属性は *note io: 73. からのバッファ I/O クラスを使って
          いるときに利用できます。

 -- 例外: ChildProcessError

     子プロセスの操作が失敗した場合に送出されます。‘errno’ *note ECHILD:
     21ff. に対応します。

 -- 例外: ConnectionError

     コネクション関係の問題の基底クラス。

     サブクラスは *note BrokenPipeError: 1030, *note
     ConnectionAbortedError: 1031, *note ConnectionRefusedError: 1032,
     *note ConnectionResetError: 1033. です。

 -- 例外: BrokenPipeError

     *note ConnectionError: dd7. のサブクラスで、もう一方の端が閉じられ
     たパイプに書き込こもうとするか、書き込みのためにシャットダウンされ
     たソケットに書き込こもうとした場合に発生します。 ‘errno’ *note
     EPIPE: 2200. と *note ESHUTDOWN: 2201. に対応します。

 -- 例外: ConnectionAbortedError

     *note ConnectionError: dd7. のサブクラスで、接続の試行が通信相手に
     よって中断された場合に発生します。 ‘errno’ *note ECONNABORTED:
     2202. に対応します。

 -- 例外: ConnectionRefusedError

     *note ConnectionError: dd7. のサブクラスで、接続の試行が通信相手に
     よって拒否された場合に発生します。 ‘errno’ *note ECONNREFUSED:
     2203. に対応します。

 -- 例外: ConnectionResetError

     *note ConnectionError: dd7. のサブクラスで、接続が通信相手によって
     リセットされた場合に発生します。 ‘errno’ *note ECONNRESET: 2204. に
     対応します。

 -- 例外: FileExistsError

     すでに存在するファイルやディレクトリを作成しようとした場合に送出さ
     れます。‘errno’ *note EEXIST: 2205. に対応します。

 -- 例外: FileNotFoundError

     要求されたファイルやディレクトリが存在しない場合に送出されます。
     ‘errno’ *note ENOENT: 2206. に対応します。

 -- 例外: InterruptedError

     システムコールが入力信号によって中断された場合に送出されます。
     ‘errno’ *note EINTR: d54. に対応します。

     バージョン 3.5 で変更: シグナルハンドラが例外を送出せず、システムコ
     ールが信号で中断された場合 Python は *note InterruptedError: d55. を
     送出する代わりにシステムコールを再試行するようになりました (論拠に
     ついては PEP 475(1) を参照してください) 。

 -- 例外: IsADirectoryError

     ディレクトリに (*note os.remove(): 10c1. などの) ファイル操作が要求
     された場合に送出されます。‘errno’ *note EISDIR: 2207. に対応します
     。

 -- 例外: NotADirectoryError

     ディレクトリへの操作(たとえば *note os.listdir(): 10cd.)をディレク
     トリ以外に対して要求された場合に送出されます。多くのPOSIXプラットフ
     ォームではディレクトリではないファイルをディレクトリとして開いたり
     移動するときにも発生する場合があります。‘errno’ *note ENOTDIR:
     2208. に対応します。

 -- 例外: PermissionError

     十分なアクセス権、例えばファイルシステム権限のない操作が試みられた
     場合に送出されます。‘errno’ *note EACCES: 2209.、*note EPERM: 1737.
     および *note ENOTCAPABLE: 172a. に対応します。

     バージョン 3.11.1 で変更: WASIの *note ENOTCAPABLE: 172a. は *note
     PermissionError: d10. にマップされました。

 -- 例外: ProcessLookupError

     与えられたプロセスが存在しない場合に送出されます。‘errno’ *note
     ESRCH: 220a. に対応します。

 -- 例外: TimeoutError

     システム関数がシステムレベルでタイムアウトした場合に送出されます。
     ‘errno’ *note ETIMEDOUT: 220b. に対応します。

Added in version 3.3: 上記のすべての *note OSError: 3f0. サブクラスが追
加されました。

参考
....

PEP 3151(2) - OS および IO 例外階層の手直し

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/

   (2) https://peps.python.org/pep-3151/


File: python.info,  Node: 警告,  Next: 例外グループ,  Prev: 具象例外,  Up: 組み込み例外

5.5.5 警告
----------

次の例外は警告カテゴリとして使われます。詳細については *note
警告カテゴリ: 220e. のドキュメントを参照してください。

 -- 例外: Warning

     警告カテゴリの基底クラスです。

 -- 例外: UserWarning

     ユーザコードによって生成される警告の基底クラスです。

 -- 例外: DeprecationWarning

     他の Python 開発者へ向けて警告を発するときの、廃止予定の機能につい
     ての警告の基底クラスです。

     ‘__main__’ モジュールを除いて( PEP 565(1))、デフォルトの警告フィル
     ターで無効化されています。*note Python Development Mode: 1d9. を有
     効にするとこの警告が表示されます。

     The deprecation policy is described in PEP 387(2).

 -- 例外: PendingDeprecationWarning

     古くなって将来的に廃止される予定だが、今のところは廃止されていない
     機能についての警告の基底クラスです。

     近々起こる可能性のある機能廃止について警告を発することはまれなので
     、このクラスはめったに使われず、既に決まっている廃止については
     *note DeprecationWarning: 18a. が望ましいです。

     デフォルトの警告フィルターで無効化されています。*note Python
     Development Mode: 1d9. を有効にするとこの警告が表示されます。

     The deprecation policy is described in PEP 387(3).

 -- 例外: SyntaxWarning

     曖昧な構文に対する警告の基底クラスです。

 -- 例外: RuntimeWarning

     あいまいなランタイム挙動に対する警告の基底クラスです。

 -- 例外: FutureWarning

     Python で書かれたアプリケーションのエンドユーザーへ向けて警告を発す
     るときの、廃止予定の機能についての警告の基底クラスです。

 -- 例外: ImportWarning

     モジュールインポートの誤りと思われるものに対する警告の基底クラスで
     す。

     デフォルトの警告フィルターで無効化されています。*note Python
     Development Mode: 1d9. を有効にするとこの警告が表示されます。

 -- 例外: UnicodeWarning

     Unicode に関連した警告の基底クラスです。

 -- 例外: EncodingWarning

     エンコーディングに関連した警告の基底クラスです。

     詳細は *note Opt-in EncodingWarning: 1cbf. を参照してください。

     Added in version 3.10.

 -- 例外: BytesWarning

     *note bytes: 1a4. や *note bytearray: 508. に関連した警告の基底クラ
     スです。

 -- 例外: ResourceWarning

     リソースの使用に関連した警告の基底クラスです。

     デフォルトの警告フィルターで無効化されています。*note Python
     Development Mode: 1d9. を有効にするとこの警告が表示されます。

     Added in version 3.2.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0565/

   (2) https://peps.python.org/pep-0387/

   (3) https://peps.python.org/pep-0387/


File: python.info,  Node: 例外グループ,  Next: 例外のクラス階層,  Prev: 警告,  Up: 組み込み例外

5.5.6 例外グループ
------------------

以下は関係がない複数の例外を送出する必要があるときに使用します。例外グル
ープは例外の階層構造の一部のため、他の例外と同様 *note except: 170. で処
理できます。また、*note except*: 582. によって判別でき、例外グループに含
まれている例外の型に基づいてサブグループにマッチします。

 -- 例外: ExceptionGroup (msg, excs)

 -- 例外: BaseExceptionGroup (msg, excs)

     この2つの例外型は一連の例外 ‘excs’ を包含します。‘msg’ 引数は文字列
     の必要があります。2つのクラスの異なる点は、*note BaseException:
     584. は *note BaseExceptionGroup: 240. を拡張して任意の例外を含めら
     れますが、*note ExceptionGroup: 19b. は *note Exception: 9a7. を拡
     張して *note Exception: 9a7. のサブクラスのみを含められます。この設
     計により ‘except Exception’ は *note ExceptionGroup: 19b. をキャッ
     チしますが、*note BaseExceptionGroup: 240. はキャッチしません。

     *note BaseExceptionGroup: 240. のコンストラクターは含まれる例外がす
     べて *note Exception: 9a7. の場合は *note BaseExceptionGroup: 240.
     ではなく *note ExceptionGroup: 19b. を返すように自動的に選択されま
     す。一方 *note ExceptionGroup: 19b. コンストラクタは、*note
     Exception: 9a7. サブクラス以外の例外を含む場合は *note TypeError:
     502. を送出します。

      -- の属性: message

          コンストラクタの ‘msg’ 引数。この属性は読み込み専用です。

      -- の属性: exceptions

          コンストラクタに渡された一連の ‘excs’ に含まれる例外のタプルで
          す。この属性は読み込み専用です。

      -- メソッド: subgroup (condition)

          現在のグループで '条件' にマッチする礼儀のみを含む例外グループ
          を返します。結果が空の場合は ‘None’ を返します。

          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 in an ‘except’ clause.  The
          condition can also be a callable (other than a type object)
          that accepts an exception as its single argument and returns
          true for the exceptions that should be in the subgroup.

          The nesting structure of the current exception is preserved in
          the result, as are the values of its *note message: 2213,
          *note __traceback__: 1296, *note __cause__: 1298, *note
          __context__: 1297. and *note __notes__: 21e1. fields.  Empty
          nested groups are omitted from the result.

          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.

          Added in version 3.13: ‘condition’ can be any callable which
          is not a type object.

      -- メソッド: split (condition)

          *note subgroup(): 1625. と似てますが ‘(match, rest)’ のペアを
          返します。‘match’ は ‘subgroup(condition)’ で ‘rest’ は残りの
          マッチしない部分です。

      -- メソッド: derive (excs)

          同じ *note message: 2213. の例外グループを返しますが、‘excs’ の
          例外を含んでいます。

          This method is used by *note subgroup(): 1625. and *note
          split(): 1626, which are used in various contexts to break up
          an exception group.  A subclass needs to override it in order
          to make *note subgroup(): 1625. and *note split(): 1626.
          return instances of the subclass rather than *note
          ExceptionGroup: 19b.

          *note subgroup(): 1625. と *note split(): 1626. は *note
          __traceback__: 1296.、*note __cause__: 1298.、*note
          __context__: 1297. と *note __notes__: 21e1. フィールドを元の
          例外グループから *note derive(): 1624. が返す例外グループにコ
          ピーするため、*note derive(): 1624. ではこれらのフィールドを更
          新する必要がありません。

               >>> class MyGroup(ExceptionGroup):
               ...     def derive(self, excs):
               ...         return MyGroup(self.message, excs)
               ...
               >>> e = MyGroup("eg", [ValueError(1), TypeError(2)])
               >>> e.add_note("a note")
               >>> e.__context__ = Exception("context")
               >>> e.__cause__ = Exception("cause")
               >>> try:
               ...    raise e
               ... except Exception as e:
               ...    exc = e
               ...
               >>> match, rest = exc.split(ValueError)
               >>> exc, exc.__context__, exc.__cause__, exc.__notes__
               (MyGroup('eg', [ValueError(1), TypeError(2)]), Exception('context'), Exception('cause'), ['a note'])
               >>> match, match.__context__, match.__cause__, match.__notes__
               (MyGroup('eg', [ValueError(1)]), Exception('context'), Exception('cause'), ['a note'])
               >>> rest, rest.__context__, rest.__cause__, rest.__notes__
               (MyGroup('eg', [TypeError(2)]), Exception('context'), Exception('cause'), ['a note'])
               >>> exc.__traceback__ is match.__traceback__ is rest.__traceback__
               True

     Note that *note BaseExceptionGroup: 240. defines *note __new__():
     54c, so subclasses that need a different constructor signature need
     to override that rather than *note __init__(): 67c.  For example,
     the following defines an exception group subclass which accepts an
     exit_code and and constructs the group's message from it.

          class Errors(ExceptionGroup):
             def __new__(cls, errors, exit_code):
                self = super().__new__(Errors, f"exit code: {exit_code}", errors)
                self.exit_code = exit_code
                return self

             def derive(self, excs):
                return Errors(excs, self.exit_code)

     Like *note ExceptionGroup: 19b, any subclass of *note
     BaseExceptionGroup: 240. which is also a subclass of *note
     Exception: 9a7. can only wrap instances of *note Exception: 9a7.

     Added in version 3.11.


File: python.info,  Node: 例外のクラス階層,  Prev: 例外グループ,  Up: 組み込み例外

5.5.7 例外のクラス階層
----------------------

組み込み例外のクラス階層は以下のとおりです:

     BaseException
      ├── BaseExceptionGroup
      ├── GeneratorExit
      ├── KeyboardInterrupt
      ├── SystemExit
      └── Exception
           ├── ArithmeticError
           │    ├── FloatingPointError
           │    ├── OverflowError
           │    └── ZeroDivisionError
           ├── AssertionError
           ├── AttributeError
           ├── BufferError
           ├── EOFError
           ├── ExceptionGroup [BaseExceptionGroup]
           ├── ImportError
           │    └── ModuleNotFoundError
           ├── LookupError
           │    ├── IndexError
           │    └── KeyError
           ├── MemoryError
           ├── NameError
           │    └── UnboundLocalError
           ├── OSError
           │    ├── BlockingIOError
           │    ├── ChildProcessError
           │    ├── ConnectionError
           │    │    ├── BrokenPipeError
           │    │    ├── ConnectionAbortedError
           │    │    ├── ConnectionRefusedError
           │    │    └── ConnectionResetError
           │    ├── FileExistsError
           │    ├── FileNotFoundError
           │    ├── InterruptedError
           │    ├── IsADirectoryError
           │    ├── NotADirectoryError
           │    ├── PermissionError
           │    ├── ProcessLookupError
           │    └── TimeoutError
           ├── ReferenceError
           ├── RuntimeError
           │    ├── NotImplementedError
           │    ├── PythonFinalizationError
           │    └── RecursionError
           ├── StopAsyncIteration
           ├── StopIteration
           ├── SyntaxError
           │    └── IndentationError
           │         └── TabError
           ├── SystemError
           ├── TypeError
           ├── ValueError
           │    └── UnicodeError
           │         ├── UnicodeDecodeError
           │         ├── UnicodeEncodeError
           │         └── UnicodeTranslateError
           └── Warning
                ├── BytesWarning
                ├── DeprecationWarning
                ├── EncodingWarning
                ├── FutureWarning
                ├── ImportWarning
                ├── PendingDeprecationWarning
                ├── ResourceWarning
                ├── RuntimeWarning
                ├── SyntaxWarning
                ├── UnicodeWarning
                └── UserWarning


File: python.info,  Node: テキスト処理サービス,  Next: バイナリデータ処理,  Prev: 組み込み例外,  Up: Python 標準ライブラリ

5.6 テキスト処理サービス
========================

この章で説明するモジュールは幅広い文字列操作や様々なテキスト処理サービス
を提供しています。

*note codecs: 14. モジュールはテキスト処理と高い関連性を持った *note
バイナリデータ処理: 2218. のなかで説明されています。加えて Python の組み
込み文字列型の *note テキストシーケンス型 -- str: 1b67. のドキュメントも
参照して下さい。

* Menu:

* string: string --- 一般的な文字列操作. 一般的な文字列操作
* re: re --- 正規表現操作. 正規表現操作
* difflib: difflib --- 差分の計算の補助. 差分の計算の補助
* textwrap: textwrap --- テキストの折り返しと詰め込み. テキストの折り返しと詰め込み
* unicodedata: unicodedata --- Unicode データベース. Unicode データベース
* stringprep: stringprep --- インターネットの文字列調製. インターネットの文字列調製
* readline: readline --- GNU readline のインターフェース. GNU readline のインターフェース
* rlcompleter: rlcompleter --- GNU readline の補完機能. GNU readline の補完機能


File: python.info,  Node: string --- 一般的な文字列操作,  Next: re --- 正規表現操作,  Up: テキスト処理サービス

5.6.1 ‘string’ -- 一般的な文字列操作
------------------------------------

'ソースコード:' Lib/string.py(1)

__________________________________________________________________

参考
....

*note テキストシーケンス型 -- str: 1b67.

*note 文字列メソッド: 1b68.

* Menu:

* 文字列定数::
* カスタムの文字列書式化::
* 書式指定文字列の文法::
* テンプレート文字列::
* ヘルパー関数::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/string.py


File: python.info,  Node: 文字列定数,  Next: カスタムの文字列書式化,  Up: string --- 一般的な文字列操作

5.6.1.1 文字列定数
..................

このモジュールで定義されている定数は以下の通りです:

 -- データ: string.ascii_letters

     後述の *note ascii_lowercase: 221c. と *note ascii_uppercase: 221d.
     を合わせたもの。この値はロケールに依存しません。

 -- データ: string.ascii_lowercase

     小文字 ‘'abcdefghijklmnopqrstuvwxyz'’ 。この値はロケールに依存せず
     、固定です。

 -- データ: string.ascii_uppercase

     大文字 ‘'ABCDEFGHIJKLMNOPQRSTUVWXYZ'’ 。この値はロケールに依存せず
     、固定です。

 -- データ: string.digits

     文字列 ‘'0123456789'’ です。

 -- データ: string.hexdigits

     文字列 ‘'0123456789abcdefABCDEF'’ です。

 -- データ: string.octdigits

     文字列 ‘'01234567'’ です。

 -- データ: string.punctuation

     ‘C’ ロケールにおいて、区切り文字 (punctuation characters) として扱
     われる ASCII 文字の文字列です: ‘!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~’.

 -- データ: string.printable

     印刷可能な ASCII 文字で構成される文字列です。 *note digits: 221e,
     *note ascii_letters: 1293, *note punctuation: 2221. および *note
     whitespace: 2223. を組み合わせたものです。

 -- データ: string.whitespace

     空白 (whitespace) として扱われる ASCII 文字全てを含む文字列です。ほ
     とんどのシステムでは、これはスペース (space)、タブ (tab)、改行
     (linefeed)、復帰 (return)、改頁 (formfeed)、垂直タブ (vertical tab)
     です。


File: python.info,  Node: カスタムの文字列書式化,  Next: 書式指定文字列の文法,  Prev: 文字列定数,  Up: string --- 一般的な文字列操作

5.6.1.2 カスタムの文字列書式化
..............................

組み込みの文字列 (string) クラスには、 PEP 3101(1) で記述されている
*note format(): 5ed. メソッドによって複雑な変数置換と値のフォーマットを
行う機能があります。 *note string: be. モジュールの *note Formatter:
e85. クラスでは、組み込みの *note format(): 5ed. メソッドと同じ実装を使
用して、独自の文字列フォーマットの振る舞いを作成してカスタマイズすること
ができます。

 -- クラス: string.Formatter

     *note Formatter: e85. クラスは、以下のメソッドを持ちます:

      -- メソッド: format (format_string, /, *args, **kwargs)

          主要な API メソッドです。書式文字列と、任意の位置引数およびキ
          ーワード引数のセットを取ります。これは、*note vformat(): 2225.
          を呼び出す単なるラッパーです。

          バージョン 3.7 で変更: 書式文字列は *note 位置専用: a53. の引
          数となりました。

      -- メソッド: vformat (format_string, args, kwargs)

          この関数はフォーマットの実際の仕事をします。この関数は、
          ‘*args’ および ‘**kwargs’ シンタックスを使用して、辞書を個々の
          引数として unpack してから再度 pack するのではなく、引数として
          あらかじめ用意した辞書を渡したい場合のために、独立した関数とし
          て公開されます。 *note vformat(): 2225. は、書式文字列を文字デ
          ータと置換フィールドに分解する仕事をします。それは、以下に記述
          する様々なメソッドを呼び出します。

     さらに、 *note Formatter: e85. ではサブクラスによって置き換えられる
     ことを意図した次のようないくつかのメソッドが定義されています。

      -- メソッド: parse (format_string)

          format_stringを探査し、タプル、 ('literal_text', 'field_name',
          'format_spec', 'conversion') のイテラブルを返します。これは
          *note vformat(): 2225. が文字列を文字としての文字データや置換
          フィールドに展開するために使用されます。

          タプルの値は、概念的に文字としての文字データと、それに続く単一
          の置換フィールドを表現します。文字としての文字データが無い場合
          は (ふたつの置換フィールドが連続した場合などに起き得ます) 、
          'literal_text' は長さが 0 の文字列となります。置換フィールドが
          無い場合は、 'field_name', 'format_spec' および 'conversion' が
          ‘None’ となります。

      -- メソッド: get_field (field_name, args, kwargs)

          引数として与えた *note parse(): 2226. (上記参照) により返され
          る 'field_name' を書式指定対象オブジェクトに変換します。返り値
          はタプル、 (obj, used_key) です。デフォルトでは PEP 3101(2) に
          規定される "0[name]" や "label.title" のような形式の文字列を引
          数としてとります。 'args' と 'kwargs' は *note vformat():
          2225. に渡されます。返り値 'used_key' は、 *note get_value():
          2228. の 'key' 引数と同じ意味を持ちます。

      -- メソッド: get_value (key, args, kwargs)

          与えられたフィールドの値を取り出します。 'key' 引数は整数でも
          文字列でも構いません。整数の場合は、位置引数 'args' のインデッ
          クス番号を示します。文字列の場合は、名前付きの引数 'kwargs' を
          意味します。

          'args' 引数は、 *note vformat(): 2225. への位置引数のリストに
          設定され、 'kwargs' 引数は、キーワード引数の辞書に設定されます
          。

          フィールド名が (ピリオドで区切られた) いくつかの要素からなって
          いる場合、最初の要素のみがこれらの関数に渡されます。残りの要素
          に関しては、通常の属性またはインデックスアクセスと同様に処理さ
          れます。

          つまり、例えば、フィールドが '0.name' と表現されるとき、 *note
          get_value(): 2228. は、 'key' 引数が 0 として呼び出されます。
          属性 ‘name’ は、組み込みの *note getattr(): b9f. 関数が呼び出
          され、 *note get_value(): 2228. が返されたのちに検索されます。

          インデックスまたはキーワードが存在しないアイテムを参照した場合
          、 *note IndexError: 14de. または *note KeyError: 31d. が送出
          されます。

      -- メソッド: check_unused_args (used_args, args, kwargs)

          希望に応じて未使用の引数がないか確認する機能を実装します。この
          関数への引数は、書式指定文字列で実際に参照されるすべての引数の
          キーの set (位置引数の整数、名前付き引数の文字列) と、vformat
          に渡される 'args' と 'kwargs' への参照です。使用されない引数の
          set は、これらのパラメータから計算されます。 *note
          check_unused_args(): 2229. は、確認の結果が偽である場合に例外
          を送出するものとみなされます。

      -- メソッド: format_field (value, format_spec)

          *note format_field(): 222a. は単純に組み込みのグローバル関数
          *note format(): 5eb. を呼び出します。このメソッドは、サブクラ
          スをオーバーライドするために提供されます。

      -- メソッド: convert_field (value, conversion)

          (*note get_field(): 2227. が返す) 値を (*note parse(): 2226. メ
          ソッドが返すタプルの形式で) 与えられた変換タイプとして変換しま
          す。デフォルトバージョンは 's' (str), 'r' (repr), 'a' (ascii)
          変換タイプを理解します。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3101/

   (2) https://peps.python.org/pep-3101/


File: python.info,  Node: 書式指定文字列の文法,  Next: テンプレート文字列,  Prev: カスタムの文字列書式化,  Up: string --- 一般的な文字列操作

5.6.1.3 書式指定文字列の文法
............................

*note str.format(): 5ed. メソッドと *note Formatter: e85. クラスは、文字
列の書式指定に同じ文法を共有します (ただし、 *note Formatter: e85. サブ
クラスでは、独自の書式指定文法を定義することが可能です)。 この文法は
*note フォーマット済み文字列リテラル: 977. の文法と関係してはいますが、
少し洗練されておらず、特に任意の式がサポートされていません。

書式指定文字列は波括弧 ‘{}’ に囲まれた "置換フィールド" を含みます。波括
弧に囲まれた部分以外は全て単純な文字として扱われ、変更を加えることなく出
力へコピーされます。波括弧を文字として扱う必要がある場合は、二重にするこ
とでエスケープすることができます: ‘{{’ および ‘}}’ 。

置換フィールドの文法は以下です:

     replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"
     field_name        ::= arg_name ("." attribute_name | "[" element_index "]")*
     arg_name          ::= [identifier | digit+]
     attribute_name    ::= identifier
     element_index     ::= digit+ | index_string
     index_string      ::= <any source character except "]"> +
     conversion        ::= "r" | "s" | "a"
     format_spec       ::= format-spec:format_spec

もっと簡単にいうと、置換フィールドは 'field_name' で始められます。これに
よって指定したオブジェクトの値が、置換フィールドの代わりに書式化され出力
に挿入されます。'field_name' の後に、感嘆符 ‘'!'’ を挟んで 'conversion'
フィールドを続けることができます。最後にコロン ‘':'’ を挟んで、
'format_spec' を書くことができます。これは、置換される値の非デフォルトの
書式を指定します。

*note 書式指定ミニ言語仕様: 1c9. 節も参照して下さい。

'field_name' それ自身は、数かキーワードのいずれかである 'arg_name' から
始まります。それが数である場合、位置引数を参照します。また、それがキーワ
ードである場合、指定されたキーワード引数を参照します。文字列に対して
*note str.isdecimal(): 2124. を呼び出した結果が真の場合、 'arg_name' は
数として扱われます。書式文字列中で数の arg_names が順に 0, 1, 2, ...  で
ある場合、それらはすべて (いくつかではありません) 省略することができます
。そして数 0, 1, 2, ...  は、自動的にその順で挿入されます。 'arg_name' は
引用符で区切られていないので、書式文字列内の任意の辞書キー (例えば文字列
‘'10'’ や ‘':-]'’ など) を指定することはできません。 'arg_name' の後に任
意の数のインデックス式または属性式を続けることができます。 ‘'.name'’ 形
式の式は *note getattr(): b9f. を使用して指定された属性を選択します。一
方、 ‘'[index]'’ 形式の式は *note __getitem__(): 264. を使用してインデッ
クス参照を行います。

バージョン 3.1 で変更: *note str.format(): 5ed. を使い、位置引数指定を省
略することができます。 ‘'{} {}'.format(a, b)’ は ‘'{0} {1}'.format(a,
b)’ と同じになります。

バージョン 3.4 で変更: *note Formatter: e85. を使い、位置引数指定を省略
することができます。

簡単な書式指定文字列の例を挙げます:

     "First, thou shalt count to {0}"  # References first positional argument
     "Bring me a {}"                   # Implicitly references the first positional argument
     "From {} to {}"                   # Same as "From {0} to {1}"
     "My quest is {name}"              # References keyword argument 'name'
     "Weight in tons {0.weight}"       # 'weight' attribute of first positional arg
     "Units destroyed: {players[0]}"   # First element of keyword argument 'players'.

'置換 (conversion)' フィールドにより書式変換前に型の強制変換が実施されま
す。通常、値の書式変換は *note __format__(): 5ea. によって実施されます。
しかしながら、場合によっては、文字列として変換することを強制したり、書式
指定の定義をオーバーライドしたくなることもあります。 *note __format__():
5ea. の呼び出し前に値を文字列に変換すると、通常の書式変換の処理は飛ばさ
れます。

現在 3つの変換フラグがサポートされています: 値に対して *note str(): 418.
を呼ぶ ‘'!s'’ 、 *note repr(): 7c8. を呼ぶ ‘'!r'’ 、 *note ascii():
138e. を呼ぶ ‘'!a'’。

いくつかの例です:

     "Harold's a clever {0!s}"        # Calls str() on the argument first
     "Bring out the holy {name!r}"    # Calls repr() on the argument first
     "More {!a}"                      # Calls ascii() on the argument first

'format_spec' フィールドは、フィールド幅、文字揃え、埋め方、精度などの、
値を表現する仕様を含みます。それぞれの値の型は、 "formatting
mini-language" 、または、 'format_spec' の実装で定義されます。

ほとんどの組み込み型は、次のセクションに記載された共通の formatting
mini-language をサポートします。

'format_spec' フィールド内には入れ子になった置換フィールドを含めることも
できます。入れ子になった置換フィールドにはフィールド名、変換フラグ、書式
指定を含めることができますが、さらに入れ子の階層を含めることはできません
。 format_spec 中の置換フィールドは 'format_spec' 文字列が解釈される前に
置き換えられます。これにより、値の書式を動的に指定することができます。

*note 書式指定例: 2235. のいくつかの例も参照して下さい。

* Menu:

* 書式指定ミニ言語仕様::
* 書式指定例::


File: python.info,  Node: 書式指定ミニ言語仕様,  Next: 書式指定例,  Up: 書式指定文字列の文法

5.6.1.4 書式指定ミニ言語仕様
............................

書式指定 ("Format specifications") は書式指定文字列の個々の値を表現する
方法を指定するための、置換フィールドで使用されます (*note
書式指定文字列の文法: 1358. および *note f-strings: 977. を参照してくだ
さい) 。 それらは、組み込み関数の *note format(): 5eb. 関数に直接渡され
ます。 それぞれの書式指定可能な型について、書式指定がどのように解釈され
るかが規定されます。

多くの組み込み型は、書式指定に関して以下のオプションを実装します。しかし
ながら、いくつかの書式指定オプションは数値型でのみサポートされます。

一般的な取り決めとして、空の書式指定は、値に対して *note str(): 418. を
呼び出したときと同じ結果を与えます。通常、空でない書式指定はその結果を変
更します。

一般的な書式指定子 ('standard format specifier') の書式は以下です:

     format_spec     ::= [[fill]align][sign]["z"]["#"]["0"][width][grouping_option]["." precision][type]
     fill            ::= <any character>
     align           ::= "<" | ">" | "=" | "^"
     sign            ::= "+" | "-" | " "
     width           ::= digit+
     grouping_option ::= "_" | ","
     precision       ::= digit+
     type            ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"

有効な 'align' 値を指定する場合、その前に 'fill' 文字を付けることができ
ます。 この文字には任意の文字を指定でき、省略された場合はデフォルトの空
白文字となります。 *note formatted string literal: 977. の中や *note
str.format(): 5ed. メソッドを使う場合はリテラルの波括弧 ("‘{’" と "‘}’")
を 'fill' 文字として使えないことに注意してください。 ただし、波括弧を入
れ子になった置換フィールド内に挿入することはできます。 この制限は *note
format(): 5eb. 関数には影響しません。

様々な align オプションの意味は以下のとおりです:

オプション    意味
              
-----------------------------------------------------------------------------
              
‘'<'’         利用可能なスペースにおいて、左詰めを強制します (ほとんどのオ
              ブジェクトにおいてのデフォルト)。
              
              
‘'>'’         利用可能なスペースにおいて、右詰めを強制します (いくつかのオ
              ブジェクトにおいてのデフォルト)。
              
              
‘'='’         Forces the padding to be placed after the sign (if any) but
              before the digits.  This is used for printing fields in the
              form '+000000120'.  This alignment option is only valid for
              numeric types, excluding *note complex: 2cf.  It becomes the
              default for numbers when '0' immediately precedes the field
              width.
              
              
‘'^'’         利用可能なスペースにおいて、中央寄せを強制します。
              

最小のフィールド幅が定義されない限り、フィールド幅はデータを表示するため
に必要な幅と同じになることに注意して下さい。そのため、その場合には、
align オプションは意味を持ちません。

'sign' オプションは数値型に対してのみ有効であり、以下のうちのひとつとな
ります:

オプション    意味
              
-----------------------------------------------------------------------------
              
‘'+'’         符号の使用を、正数、負数の両方に対して指定します。
              
              
‘'-'’         符号の使用を、負数に対してのみ指定します (デフォルトの挙動で
              す)。
              
              
空白          空白を正数の前に付け、負号を負数の前に使用することを指定しま
              す。
              

‘'z'’ オプションはマイナス0の浮動小数点数をフォーマットの制度で丸めたあ
とにプラス0に強制的に変換します。このオプションは浮動小数点数型に対して
のみ有効です。

バージョン 3.11 で変更: ‘'z'’ オプションが追加されました ( PEP 682(1) も
参照)。

‘'#'’ オプションは、変換に「別形式」を使用します。別形式は、異なる型に対
して違った風に定義されます。このオプションは、整数、浮動小数点数、複素数
でのみ有効です。整数に対して2進法、8進法、または16進法の出力が使用される
場合、このオプションは出力される値にそれぞれ ‘'0b'’, ‘'0o'’, ‘'0x'’,
‘'0X'’ 接頭辞を加えます。浮動小数点数、複素数については、別形式では、小
数点文字の後に数字がなくても変換結果には常に小数点文字が含まれます。通常
は、数字が続く場合にのみ小数点文字がこれらの変換結果に現われます。さらに
、‘'g'’ と ‘'G'’ の変換については、最後の 0 は結果から取り除かれません。

‘','’ オプションは、千の位のセパレータにカンマを使うことを合図します。ロ
ケール依存のセパレータには、代わりに ‘'n'’ の整数表現形式を使ってくださ
い。

バージョン 3.1 で変更: ‘','’ オプションが追加されました ( PEP 378(2) も
参照)。

‘'_'’ オプションは、浮動小数点数の表現型と整数の表現型 ‘'d'’ における千
倍ごとの区切り文字にアンダースコアを使うというしるしです。 整数の表現型
の ‘'b'’, ‘'o'’, ‘'x'’, ‘'X'’ では、4桁ごとにアンダースコアが挿入されま
す。 他の表現型でこのオプションを指定するとエラーになります。

バージョン 3.6 で変更: ‘'_'’ オプションが追加されました ( PEP 515(3) も
参照)。

'width' は10進数の整数で、接頭辞、セパレータ、他のフォーマット文字を含ん
だ最小の合計フィールド幅を定義します。指定されない場合、フィールド幅はそ
の内容により決定されます。

When no explicit alignment is given, preceding the 'width' field by a
zero (‘'0'’) character enables sign-aware zero-padding for numeric
types, excluding *note complex: 2cf.  This is equivalent to a 'fill'
character of ‘'0'’ with an 'alignment' type of ‘'='’.

バージョン 3.10 で変更: 'width' フィールドに ‘'0'’ を前置することは、文
字列に対するデフォルトの整列に影響を与えなくなりました。

'precision' は、表現型 ‘'f'’ または ‘'F'’ の場合小数点以下、表現型 ‘'g'’
または ‘'G'’ の場合は小数点以上と以下が何桁で表示されるべきかを示す10進
整数です。文字列の表現型の場合は最大フィールド幅、言い換えるとフィールド
の内容から何文字が使用されるかを示します。'precision' は整数の表現型には
使用できません。

最後に、'type' は、データがどのように表現されるかを決定します。

利用可能な文字列の表現型は以下です:

     型            意味
                   
     -----------------------------------------------------------------------------
                   
     ‘'s'’         文字列。これがデフォルトの値で、多くの場合省略されます。
                   
                   
     None          ‘'s'’ と同じです。
                   

利用可能な整数の表現型は以下です:

     型            意味
                   
     -----------------------------------------------------------------------------
                   
     ‘'b'’         2進数。出力される数値は2を基数とします。
                   
                   
     ‘'c'’         文字。数値を対応する Unicode 文字に変換します。
                   
                   
     ‘'d'’         10進数。出力される数値は10を基数とします。
                   
                   
     ‘'o'’         8進数。出力される数値は8を基数とします。
                   
                   
     ‘'x'’         16進数。出力される数値は16を基数とします。 10進で9を超える数
                   字には小文字が使われます。
                   
                   
     ‘'X'’         16進数。出力される数値は16を基数とします。10進で9を超える数
                   字には大文字が使われます。‘'#'’ が指定された場合、接頭辞
                   ‘'0x'’ も大文字 ‘'0X'’ になります
                   
                   
     ‘'n'’         数値。現在のロケールに従い、区切り文字を挿入することを除けば
                   、 ‘'d'’ と同じです。
                   
                   
     None          ‘'d'’ と同じです。
                   

これらの表現型に加えて、整数は (‘'n'’ と ‘None’ を除く) 以下の浮動小数点
数の表現型で書式指定できます。 そうすることで整数は書式変換される前に
*note float(): 2ce. を使って浮動小数点数に変換されます。

利用可能な *note float: 2ce. と *note Decimal: 27d. の表現型は以下です:

     型            意味
                   
     -----------------------------------------------------------------------------
                   
     ‘'e'’         Scientific notation.  For a given precision ‘p’, formats the
                   number in scientific notation with the letter 'e' separating
                   the coefficient from the exponent.  The coefficient has one
                   digit before and ‘p’ digits after the decimal point, for a
                   total of ‘p + 1’ significant digits.  With no precision
                   given, uses a precision of ‘6’ digits after the decimal
                   point for *note float: 2ce, and shows all coefficient digits
                   for *note Decimal: 27d.  If ‘p=0’, the decimal point is
                   omitted unless the ‘#’ option is used.
                   
                   
     ‘'E'’         指数表記です。大文字の 'E' を使うことを除いては、 ‘'e'’ と同
                   じです。
                   
                   
     ‘'f'’         Fixed-point notation.  For a given precision ‘p’, formats
                   the number as a decimal number with exactly ‘p’ digits
                   following the decimal point.  With no precision given, uses
                   a precision of ‘6’ digits after the decimal point for
                   *note float: 2ce, and uses a precision large enough to show
                   all coefficient digits for *note Decimal: 27d.  If ‘p=0’,
                   the decimal point is omitted unless the ‘#’ option is used.
                   
                   
     ‘'F'’         固定小数点数表記です。‘nan’ が ‘NAN’ に、‘inf’ が ‘INF’ に変
                   換されることを除き ‘'f'’ と同じです。
                   
                   
     ‘'g'’         汎用表記です。与えられた精度 ‘p >= 1’ に対して、この表記では
                   数値を有効桁数 ‘p’ に丸めた上で、数値の大きさに応じて固定小
                   数点表記または科学的表記で表します。精度 ‘0’ は精度 ‘1’ と同
                   じものと取り扱われます。
                   
                   正確なルールは次の通りです: 書式 ‘'e'’ 型および精度 ‘p-1’ 桁
                   で数値をフォーマットした結果、指数部が ‘exp’ になったと仮定
                   します。このとき ‘m <= exp < p’ ならば、数値は書式 ‘'f'’ 型
                   および精度 ‘p-1-exp’ 桁でフォーマットされます。ただし ‘m’ は
                   浮動小数点数では -4 であり、 *note Decimals: 27d. に対しては
                   -6 です。それ以外の場合、数値は書式 ‘'e'’ 型および精度 ‘p-1’
                   桁でフォーマットされます。どちらの場合でも、仮数部の有効でな
                   い末尾のゼロは取り除かれます。また小数点以下に表示する桁が無
                   い場合、 ‘'#'’ オプションが使われた場合をのぞき、小数点は除
                   去されます。
                   
                   精度が指定されない場合、 *note float: 2ce. に対しては有効桁
                   数として ‘6’ 桁を適用します。 *note Decimal: 27d. では、フォ
                   ーマット結果の係数部は実際の値の桁数によって決まります; 絶対
                   値が ‘1e-6’ より小さい値や、最下位桁の値が1より大きい値では
                   科学的表記が使われます。それ以外の場合は固定小数点表記が使わ
                   れます。
                   
                   正と負の無限大と 0 および NaN は精度に関係なくそれぞれ
                   ‘inf’, ‘-inf’, ‘0’, ‘-0’ および ‘nan’ となります。
                   
                   
     ‘'G'’         汎用フォーマットです。数値が大きくなったとき、 ‘'E'’ に切り
                   替わることを除き、 ‘'g'’ と同じです。無限大と NaN の表示も大
                   文字になります。
                   
                   
     ‘'n'’         数値です。現在のロケールに合わせて、数値分割文字が挿入される
                   ことを除き、 ‘'g'’ と同じです。
                   
                   
     ‘'%'’         パーセンテージです。数値は 100 倍され、固定小数点数フォーマ
                   ット (‘'f'’) でパーセント記号付きで表示されます。
                   
                   
     None          For *note float: 2ce. this is like the ‘'g'’ type, except
                   that when fixed-point notation is used to format the result,
                   it always includes at least one digit past the decimal
                   point, and switches to the scientific notation when ‘exp >=
                   p - 1’.  When the precision is not specified, the latter
                   will be as large as needed to represent the given value
                   faithfully.
                   
                   *note Decimal: 27d. に対しては、現在の decimal コンテキスト
                   における ‘context.capitals’ の値に応じて、 ‘'g'’ か ‘'G'’ の
                   どちらかと同じになります。
                   
                   全体として、他の書式修正指定によって変更された
                   *note str(): 418. の出力に一致するような結果になります。
                   

The available presentation types for *note complex: 2cf. are the same as
those for *note float: 2ce. (‘'%'’ is not allowed).  Both the real and
imaginary components of a complex number are formatted as floating-point
numbers, according to the specified presentation type.  They are
separated by the mandatory sign of the imaginary part, the latter being
terminated by a ‘j’ suffix.  If the presentation type is missing, the
result will match the output of *note str(): 418. (complex numbers with
a non-zero real part are also surrounded by parentheses), possibly
altered by other format modifiers.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0682/

   (2) https://peps.python.org/pep-0378/

   (3) https://peps.python.org/pep-0515/


File: python.info,  Node: 書式指定例,  Prev: 書式指定ミニ言語仕様,  Up: 書式指定文字列の文法

5.6.1.5 書式指定例
..................

この節では、 *note str.format(): 5ed. 構文の例を紹介し、さらに従来の
‘%’-書式と比較します。

多くの場合、新構文に ‘{}’ を加え、 ‘%’ の代わりに ‘:’ を使うことで、古い
‘%’-書式に類似した書式になります。例えば、‘'%03.2f'’ は ‘'{:03.2f}'’ と
変換できます。

以下の例で示すように、新構文はさらに新たに様々なオプションもサポートして
います。

位置引数を使ったアクセス:

     >>> '{0}, {1}, {2}'.format('a', 'b', 'c')
     'a, b, c'
     >>> '{}, {}, {}'.format('a', 'b', 'c')  # 3.1+ only
     'a, b, c'
     >>> '{2}, {1}, {0}'.format('a', 'b', 'c')
     'c, b, a'
     >>> '{2}, {1}, {0}'.format(*'abc')      # unpacking argument sequence
     'c, b, a'
     >>> '{0}{1}{0}'.format('abra', 'cad')   # arguments' indices can be repeated
     'abracadabra'

名前を使ったアクセス:

     >>> 'Coordinates: {latitude}, {longitude}'.format(latitude='37.24N', longitude='-115.81W')
     'Coordinates: 37.24N, -115.81W'
     >>> coord = {'latitude': '37.24N', 'longitude': '-115.81W'}
     >>> 'Coordinates: {latitude}, {longitude}'.format(**coord)
     'Coordinates: 37.24N, -115.81W'

引数の属性へのアクセス:

     >>> c = 3-5j
     >>> ('The complex number {0} is formed from the real part {0.real} '
     ...  'and the imaginary part {0.imag}.').format(c)
     'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.'
     >>> class Point:
     ...     def __init__(self, x, y):
     ...         self.x, self.y = x, y
     ...     def __str__(self):
     ...         return 'Point({self.x}, {self.y})'.format(self=self)
     ...
     >>> str(Point(4, 2))
     'Point(4, 2)'

引数の要素へのアクセス:

     >>> coord = (3, 5)
     >>> 'X: {0[0]};  Y: {0[1]}'.format(coord)
     'X: 3;  Y: 5'

‘%s’ と ‘%r’ の置き換え:

     >>> "repr() shows quotes: {!r}; str() doesn't: {!s}".format('test1', 'test2')
     "repr() shows quotes: 'test1'; str() doesn't: test2"

テキストの幅を指定した整列:

     >>> '{:<30}'.format('left aligned')
     'left aligned                  '
     >>> '{:>30}'.format('right aligned')
     '                 right aligned'
     >>> '{:^30}'.format('centered')
     '           centered           '
     >>> '{:*^30}'.format('centered')  # use '*' as a fill char
     '***********centered***********'

‘%+f’ と ‘%-f’, ‘% f’ の置換、そして符号の指定:

     >>> '{:+f}; {:+f}'.format(3.14, -3.14)  # show it always
     '+3.140000; -3.140000'
     >>> '{: f}; {: f}'.format(3.14, -3.14)  # show a space for positive numbers
     ' 3.140000; -3.140000'
     >>> '{:-f}; {:-f}'.format(3.14, -3.14)  # show only the minus -- same as '{:f}; {:f}'
     '3.140000; -3.140000'

‘%x’ と ‘%o’ の置換、そして値に対する異なる底の変換:

     >>> # format also supports binary numbers
     >>> "int: {0:d};  hex: {0:x};  oct: {0:o};  bin: {0:b}".format(42)
     'int: 42;  hex: 2a;  oct: 52;  bin: 101010'
     >>> # with 0x, 0o, or 0b as prefix:
     >>> "int: {0:d};  hex: {0:#x};  oct: {0:#o};  bin: {0:#b}".format(42)
     'int: 42;  hex: 0x2a;  oct: 0o52;  bin: 0b101010'

千の位のセパレータにカンマを使用する:

     >>> '{:,}'.format(1234567890)
     '1,234,567,890'

パーセントを表示する:

     >>> points = 19
     >>> total = 22
     >>> 'Correct answers: {:.2%}'.format(points/total)
     'Correct answers: 86.36%'

型特有の書式指定を使う:

     >>> import datetime
     >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
     >>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
     '2010-07-04 12:15:58'

引数をネストする、さらに複雑な例:

     >>> for align, text in zip('<^>', ['left', 'center', 'right']):
     ...     '{0:{fill}{align}16}'.format(text, fill=align, align=align)
     ...
     'left<<<<<<<<<<<<'
     '^^^^^center^^^^^'
     '>>>>>>>>>>>right'
     >>>
     >>> octets = [192, 168, 0, 1]
     >>> '{:02X}{:02X}{:02X}{:02X}'.format(*octets)
     'C0A80001'
     >>> int(_, 16)
     3232235521
     >>>
     >>> width = 5
     >>> for num in range(5,12):
     ...     for base in 'dXob':
     ...         print('{0:{width}{base}}'.format(num, base=base, width=width), end=' ')
     ...     print()
     ...
         5     5     5   101
         6     6     6   110
         7     7     7   111
         8     8    10  1000
         9     9    11  1001
        10     A    12  1010
        11     B    13  1011


File: python.info,  Node: テンプレート文字列,  Next: ヘルパー関数,  Prev: 書式指定文字列の文法,  Up: string --- 一般的な文字列操作

5.6.1.6 テンプレート文字列
..........................

テンプレート文字列では PEP 292(1) で解説されている単純な文字列置換ができ
ます。 テンプレート文字列の主な使い道は国際化 (i18n) です。というのは、
その国際化の文脈において、より簡潔な文法と機能を持つテンプレート文字列を
使うと、 Python にある他の組み込みの文字列フォーマット機能よりも翻訳がし
やすいからです。 テンプレート文字列の上に構築された国際化のためのライプ
ラリの例として、 flufl.i18n(2) を調べてみてください。

テンプレート文字列は ‘$’ に基づいた置換をサポートしていて、次の規則が使
われています:

   * ‘$$’ はエスケープ文字です; ‘$’ 一つに置換されます。

   * ‘$identifier’ は ‘"identifier"’ のマッピングキーに合致する置換プレ
     ースホルダーを指定します。デフォルトでは、 ‘"identifier"’ は大文字
     と小文字を区別しない ASCII 英数字 (アンダースコアを含む) からなら文
     字列に制限されています。文字列はアンダースコアか ASCII 文字から始ま
     るものでなければなりません。‘$’ の後に識別子に使えない文字が出現す
     ると、そこでプレースホルダ名の指定が終わります。

   * ‘${identifier}’ は ‘$identifier’ と同じです。プレースホルダ名の後ろ
     に識別子として使える文字列が続いていて、それをプレースホルダ名の一
     部として扱いたくない場合、例えば ‘"${noun}ification"’ のような場合
     に必要な書き方です。

上記以外の書き方で文字列中に ‘$’ を使うと *note ValueError: 1e3. を送出
します。

*note string: be. モジュールでは、上記のような規則を実装した *note
Template: 653. クラスを提供しています。 *note Template: 653. のメソッド
を以下に示します:

 -- クラス: string.Template (template)

     コンストラクタはテンプレート文字列になる引数を一つだけ取ります。

      -- メソッド: substitute (mapping={}, /, **kwds)

          テンプレート置換を行い、新たな文字列を生成して返します。
          'mapping' はテンプレート中のプレースホルダに対応するキーを持つ
          ような任意の辞書類似オブジェクトです。辞書を指定する代わりに、
          キーワード引数も指定でき、その場合にはキーワードをプレースホル
          ダ名に対応させます。'mapping' と 'kwds' の両方が指定され、内容
          が重複した場合には、'kwds' に指定したプレースホルダを優先しま
          す。

      -- メソッド: safe_substitute (mapping={}, /, **kwds)

          *note substitute(): 1c54. と同じですが、プレースホルダに対応す
          るものを 'mapping' や 'kwds' から見つけられなかった場合に、
          *note KeyError: 31d. 例外を送出する代わりにもとのプレースホル
          ダがそのまま入ります。また、 *note substitute(): 1c54. とは違
          い、規則外の書き方で ‘$’ を使った場合でも、 *note ValueError:
          1e3. を送出せず単に ‘$’ を返します。

          その他の例外も発生し得る一方で、このメソッドが「安全 (safe) 」
          と呼ばれているのは、置換操作は常に、例外を送出する代わりに利用
          可能な文字列を返そうとするからです。別の見方をすれば、 *note
          safe_substitute(): 1c55. は区切り間違いによるぶら下がり
          (dangling delimiter) や波括弧の非対応、 Python の識別子として
          無効なプレースホルダ名を含むような不正なテンプレートを何も警告
          せずに無視するため、安全とはいえないのです。

      -- メソッド: is_valid ()

          *note substitute(): 1c54. が *note ValueError: 1e3. を送出する
          原因となるような、不正なプレースホルダーをテンプレートが含む場
          合、偽を返します。

          Added in version 3.11.

      -- メソッド: get_identifiers ()

          テンプレート内の有効な識別子のリストを、その識別子が最初に現れ
          る順番で返します。不正な識別子は無視されます。

          Added in version 3.11.

     *note Template: 653. のインスタンスは、次のような public な属性を提
     供しています:

      -- の属性: template

          コンストラクタの引数 'template' に渡されたオブジェクトです。通
          常、この値を変更すべきではありませんが、読み出し専用アクセスを
          強制しているわけではありません。

Templateの使い方の例を以下に示します:

     >>> from string import Template
     >>> s = Template('$who likes $what')
     >>> s.substitute(who='tim', what='kung pao')
     'tim likes kung pao'
     >>> d = dict(who='tim')
     >>> Template('Give $who $100').substitute(d)
     Traceback (most recent call last):
     ...
     ValueError: Invalid placeholder in string: line 1, col 11
     >>> Template('$who likes $what').substitute(d)
     Traceback (most recent call last):
     ...
     KeyError: 'what'
     >>> Template('$who likes $what').safe_substitute(d)
     'tim likes $what'

さらに進んだ使い方: *note Template: 653. のサブクラスを派生して、プレー
スホルダの書式、区切り文字、テンプレート文字列の解釈に使われている正規表
現全体をカスタマイズできます。こうした作業には、以下のクラス属性をオーバ
ライドします:

   * 'delimiter' - プレースホルダの開始を示すリテラル文字列です。 デフォ
     ルトの値は ‘$’ です。 実装系はこの文字列に対して必要に応じて *note
     re.escape(): bd7. を呼び出すので、正規表現になってしまうような文字
     列にしては 'なりません' 。 さらにクラスを作成した後に delimiter を
     変更できない (つまり、別の delimiter を設定したいのであれば、サブク
     ラスの名前空間で行わなければならない) ことに注意してください。

   * 'idpattern' - これは波括弧なしのプレースホルダーを記述する正規表現
     です。デフォルト値は正規表現 ‘(?a:[_a-z][_a-z0-9]*)’ です。
     'idpattern' が与えられており、かつ 'braceidpattern' が ‘None’ の場
     合、このパターンは波括弧付きのプレースホルダーにも適用されます。

          注釈: 'flags' のデフォルトは ‘re.IGNORECASE’ なので、 ‘[a-z]’
          というパターンはいくつかの非 ASCII 文字に適合できます。 そのた
          め、ここではローカルの ‘a’ フラグを使っています。

     バージョン 3.7 で変更: 'braceidpattern' を使用すると、中括弧の内側
     と外側で使用する別々のパターンを定義できます。

   * 'braceidpattern' - これは 'idpattern' に似ていますが、波括弧付きプ
     レースホルダーのパターンを記述します。デフォルトは ‘None’ で、
     'idpattern' が適用されます (すなわち、波括弧の内側と外側の両方に同
     じパターンが使われます) 。 'braceidpattern' を使うと、波括弧付きと
     波括弧なしのプレースホルダーにそれぞれ異なるパターンを定義すること
     ができます。

     Added in version 3.7.

   * 'flags' - 代入の認識のために使用される正規表現をコンパイルする際に
     適用される正規表現フラグ。デフォルト値は ‘re.IGNORECASE’ です。
     ‘re.VERBOSE’ が常にフラグに追加されるということに注意してください。
     したがって、カスタムな 'idpattern' は verbose 正規表現の規約に従わ
     なければなりません。

     Added in version 3.2.

他にも、クラス属性 'pattern' をオーバライドして、正規表現パターン全体を
指定できます。オーバライドを行う場合、 'pattern' の値は 4 つの名前つきキ
ャプチャグループ (capturing group) を持った正規表現オブジェクトでなけれ
ばなりません。これらのキャプチャグループは、上で説明した規則と、無効なプ
レースホルダに対する規則に対応しています:

   * 'escaped' - このグループはエスケープシーケンス、すなわちデフォルト
     パターンにおける ‘$$’ に対応します。

   * 'named' - このグループは波括弧でくくらないプレースホルダ名に対応し
     ます; キャプチャグループに区切り文字を含めてはなりません。

   * 'braced' - このグループは波括弧でくくったプレースホルダ名に対応しま
     す; キャプチャグループに区切り文字を含めてはなりません。

   * 'invalid' - このグループはそのほかの区切り文字のパターン (通常は区
     切り文字一つ) に対応し、正規表現の末尾に出現しなければなりません。

このクラスのメソッドは、これらの名前付きグループに1つもマッチすることな
くパターンがテンプレートにマッチした場合、 *note ValueError: 1e3. を送出
します。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0292/

   (2) https://flufli18n.readthedocs.io/en/latest/


File: python.info,  Node: ヘルパー関数,  Prev: テンプレート文字列,  Up: string --- 一般的な文字列操作

5.6.1.7 ヘルパー関数
....................

 -- の関数: string.capwords (s, sep=None)

     *note str.split(): e73. を使って引数を単語に分割し、 *note
     str.capitalize(): 2120. を使ってそれぞれの単語の先頭の文字を大文字
     に変換し、 *note str.join(): 2110. を使ってつなぎ合わせます。オプシ
     ョンの第2引数 'sep' が与えられないか ‘None’ の場合、この置換処理は
     文字列中の連続する空白文字をスペース一つに置き換え、先頭と末尾の空
     白を削除します、それ以外の場合には 'sep' は split と join に使われ
     ます。


File: python.info,  Node: re --- 正規表現操作,  Next: difflib --- 差分の計算の補助,  Prev: string --- 一般的な文字列操作,  Up: テキスト処理サービス

5.6.2 ‘re’ -- 正規表現操作
--------------------------

'ソースコード:' Lib/re/(1)

__________________________________________________________________

このモジュールは Perl に見られる正規表現マッチング操作と同様のものを提供
します。

パターンおよび検索される文字列には、Unicode 文字列 (*note str: 418.) や
8 ビット文字列 (*note bytes: 1a4.) を使います。ただし、Unicode 文字列と
8 ビット文字列の混在はできません。つまり、Unicode 文字列にバイト列のパタ
ーンでマッチングしたり、その逆はできません。同様に、置換時の置換文字列は
パターンおよび検索文字列の両方と同じ型でなくてはなりません。

正規表現では、特殊な形式を表すためや、特殊文字をその特殊な意味を発動させ
ず使うために、バックスラッシュ文字 (‘'\'’) を使います。こうしたバックス
ラッシュの使い方は、 Python の文字列リテラルにおける同じ文字の使い方と衝
突します。例えば、リテラルのバックスラッシュにマッチさせるには、パターン
文字列として ‘'\\\\'’ と書かなければなりません。なぜなら、正規表現は
‘\\’ でなければならないうえ、それぞれのバックスラッシュは標準の Python 文
字列リテラルで ‘\\’ と表現せねばならないからです。 Python の文字列リテラ
ルにおいて、バックスラッシュの使用による不正なエスケープ文字がある場合は
、*note SyntaxWarning: 432. が発生し、将来的には *note SyntaxError: 172.
になることにも注意してください。この動作は、正規表現として有効な文字列に
対しても同様です。

これを解決するには、正規表現パターンに Python の raw 文字列記法を使いま
す。 ‘'r'’ を前置した文字列リテラル内ではバックスラッシュが特別扱いされ
ません。従って ‘"\n"’ が改行一文字からなる文字列であるのに対して、
‘r"\n"’ は ‘'\'’ と ‘'n'’ の二文字からなる文字列です。通常、 Python コー
ド中では、パターンをこの raw 文字列記法を使って表現します。

重要なこととして、大抵の正規表現操作は、モジュールレベルの関数としても、
*note コンパイル済み正規表現: f53. のメソッドとしても利用できます。関数
は正規表現オブジェクトを前もってコンパイルする必要がない近道ですが、微調
整のための変数が減ります。

参考
....

サードパーティの regex(2) モジュールは、標準ライブラリの *note re: a7. モ
ジュールと互換な API を持ちながら、追加の機能とより徹底した Unicode サポ
ートを提供します。

* Menu:

* 正規表現のシンタックス::
* モジュールコンテンツ::
* 正規表現オブジェクト::
* マッチオブジェクト::
* 正規表現の例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/re/

   (2) https://pypi.org/project/regex/


File: python.info,  Node: 正規表現のシンタックス,  Next: モジュールコンテンツ,  Up: re --- 正規表現操作

5.6.2.1 正規表現のシンタックス
..............................

正規表現 (または RE) は、その表現にマッチ (match) する文字列の集合を指定
します。このモジュールの関数を使えば、ある文字列が与えられた正規表現にマ
ッチするか (または、与えられた正規表現がある文字列にマッチするか、と言い
換えても同じことになります) を検査できます。

正規表現を連結することで新しい正規表現を作れます。'A' と 'B' がともに正
規表現であれば 'AB' も正規表現です。一般的に、ある文字列 'p' が 'A' にマ
ッチし、別の文字列 'q' が 'B' にマッチするなら、文字列 'pq' は AB にマッ
チします。ただし、 'A' または 'B' に優先度の低い演算が含まれる場合や、
'A' と 'B' との間に境界条件がある場合や、番号付けされたグループ参照をし
ている場合、を除きます。こうして、ここで述べるような簡単な基本表現から、
複雑な表現を容易に構築できます。正規表現に関する理論と実装の詳細について
は Friedl 本 *note [Frie09]: 2246. か、コンパイラの構築に関するテキスト
を参照してください。

以下で正規表現の形式を簡単に説明します。詳細な情報ややさしい説明は、
*note 正規表現 HOWTO: 2247. を参照してください。

正規表現には、特殊文字と通常文字の両方を含められます。 ‘'A'’ 、 ‘'a'’ 、
または ‘'0'’ のようなほとんどの通常文字は、最も単純な正規表現です。これ
は単純に、その文字自体にマッチします。通常文字は連結できるので、 ‘last’
は文字列 ‘'last'’ にマッチします。 (この節では以降、正規表現は一般にクオ
ートを使わず ‘この特殊スタイルで’ 表記し、マッチ対象の文字列は、 ‘'シン
グルクオートで括って'’ 表記します。)

‘'|'’ や ‘'('’ といったいくつかの文字は特殊です。特殊文字は通常文字の種
別を表したり、周辺の通常文字に対する解釈方法に影響します。

繰り返しの演算子または修飾子 (‘*’、 ‘+’、 ‘?’、 ‘{m,n}’ など) は直接入れ
子にはできません。これは、非貪欲な修飾子の接尾辞 ‘?’ や他の実装での他の
修飾子との曖昧さを回避します。内側で繰り返したものをさらに繰り返すには、
丸括弧が使えます。例えば、正規表現 ‘(?:a{6})*’ は 6 の倍数個の ‘'a'’ 文
字にマッチします。

特殊文字を以下に示します:

‘.’

     (ドット) デフォルトのモードでは改行以外の任意の文字にマッチします。
     *note DOTALL: 2248. フラグが指定されていれば改行も含む全ての文字に
     マッチします。‘(?s:.)’ はフラグにかかわらず全ての文字にマッチします
     。

‘^’

     (キャレット) 文字列の先頭にマッチし、 *note MULTILINE: 2249. モード
     では各改行の直後にもマッチします。

‘$’

     文字列の末尾、あるいは文字列の末尾の改行の直前にマッチし、 *note
     MULTILINE: 2249. モードでは改行の前にもマッチします。 ‘foo’ は
     'foo' と 'foobar' の両方にマッチしますが、正規表現 ‘foo$’ は 'foo'
     だけにマッチします。興味深いことに、 ‘'foo1\nfoo2\n'’ を ‘foo.$’ で
     検索した場合、通常は 'foo2' だけにマッチしますが、 *note MULTILINE:
     2249. モードでは 'foo1' にもマッチします。 ‘$’ だけで ‘'foo\n'’ を
     検索した場合、2 つの (空の) マッチを見つけます: 1つは改行の直前で、
     もう1つは文字列の末尾です。

‘*’

     直前の正規表現を 0 回以上、できるだけ多く繰り返したものにマッチさせ
     る結果の正規表現にします。例えば ‘ab*’ は 'a'、'ab'、または 'a' に
     任意個数の 'b' を続けたものにマッチします。

‘+’

     直前の正規表現を 1 回以上繰り返したものにマッチさせる結果の正規表現
     にします。例えば ‘ab+’ は 'a' に 1 つ以上の 'b' が続いたものにマッ
     チし、単なる 'a' にはマッチしません。

‘?’

     直前の正規表現を 0 回か 1 回繰り返したものにマッチさせる結果の正規
     表現にします。例えば ‘ab?’ は 'a' あるいは 'ab' にマッチします。

‘*?’, ‘+?’, ‘??’

     ‘'*'’ 、 ‘'+'’ 、および ‘'?'’ 修飾子は全て '貪欲 (greedy)' マッチで
     、できるだけ多くのテキストにマッチします。この挙動が望ましくない時
     もあります。例えば正規表現 ‘<.*>’ が ‘'<a> b <c>'’ に対してマッチさ
     れると、 ‘'<a>'’ だけでなく文字列全体にマッチしてしまいます。修飾子
     の後に ‘?’ を追加すると、 '非貪欲 (non-greedy)' あるいは '最小
     (minimal)' のマッチが行われ、できるだけ '少ない' 文字にマッチします
     。正規表現 ‘<.*?>’ を使うと ‘'<a>'’ だけにマッチします。

‘*+’, ‘++’, ‘?+’

     Like the ‘'*'’, ‘'+'’, and ‘'?'’ quantifiers, those where ‘'+'’ is
     appended also match as many times as possible.  However, unlike the
     true greedy quantifiers, these do not allow back-tracking when the
     expression following it fails to match.  These are known as
     'possessive' quantifiers.  For example, ‘a*a’ will match ‘'aaaa'’
     because the ‘a*’ will match all 4 ‘'a'’s, but, when the final ‘'a'’
     is encountered, the expression is backtracked so that in the end
     the ‘a*’ ends up matching 3 ‘'a'’s total, and the fourth ‘'a'’ is
     matched by the final ‘'a'’.  However, when ‘a*+a’ is used to match
     ‘'aaaa'’, the ‘a*+’ will match all 4 ‘'a'’, but when the final
     ‘'a'’ fails to find any more characters to match, the expression
     cannot be backtracked and will thus fail to match.  ‘x*+’, ‘x++’
     and ‘x?+’ are equivalent to ‘(?>x*)’, ‘(?>x+)’ and ‘(?>x?)’
     correspondingly.

     Added in version 3.11.

‘{m}’

     直前の正規表現をちょうど 'm' 回繰り返したものにマッチさせるよう指定
     します。それより少ないマッチでは正規表現全体がマッチしません。例え
     ば、 ‘a{6}’ は 6 個ちょうどの ‘'a'’ 文字にマッチしますが、 5 個では
     マッチしません。

‘{m,n}’

     直前の正規表現を 'm' 回から 'n' 回、できるだけ多く繰り返したものに
     マッチさせる結果の正規表現にします。例えば、‘a{3,5}’ は、3 個から 5
     個の ‘'a'’ 文字にマッチします。'm' を省略すると下限は 0 に指定され
     、'n' を省略すると上限は無限に指定されます。例として、 ‘a{4,}b’ は
     ‘'aaaab'’ や、1,000 個の ‘'a'’ 文字に ‘'b'’ が続いたものにマッチし
     ますが、‘'aaab'’ にはマッチしません。コンマは省略できません、省略す
     ると修飾子が上で述べた形式と混同されてしまうからです。

‘{m,n}?’

     結果の正規表現は、前にある正規表現を、'm' 回から 'n' 回まで繰り返し
     たものにマッチし、できるだけ '少なく' 繰り返したものにマッチするよ
     うにします。これは、前の数量詞の非貪欲版です。例えば、 6 文字文字列
     ‘'aaaaaa'’ では、 ‘a{3,5}’ は、5 個の ‘'a'’ 文字にマッチしますが、
     ‘a{3,5}?’ は 3 個の文字にマッチするだけです。

‘{m,n}+’

     Causes the resulting RE to match from 'm' to 'n' repetitions of the
     preceding RE, attempting to match as many repetitions as possible
     'without' establishing any backtracking points.  This is the
     possessive version of the quantifier above.  For example, on the
     6-character string ‘'aaaaaa'’, ‘a{3,5}+aa’ attempt to match 5 ‘'a'’
     characters, then, requiring 2 more ‘'a'’s, will need more
     characters than available and thus fail, while ‘a{3,5}aa’ will
     match with ‘a{3,5}’ capturing 5, then 4 ‘'a'’s by backtracking and
     then the final 2 ‘'a'’s are matched by the final ‘aa’ in the
     pattern.  ‘x{m,n}+’ is equivalent to ‘(?>x{m,n})’.

     Added in version 3.11.

‘\’

     特殊文字をエスケープ ( ‘'*'’ や ‘'?'’ などの文字にマッチできるよう
     にする) し、または特殊シーケンスを合図します。特殊シーケンスは後で
     議論します。

     パターンを表現するのに raw 文字列を使っていないのであれば、 Python
     ももまた、バックスラッシュを文字列リテラルでエスケープシーケンスと
     して使うことを思い出して下さい。そのエスケープシーケンスを Python の
     パーザが認識しないなら、そのバックスラッシュとそれに続く文字が結果
     の文字列に含まれます。しかし、Python が結果のシーケンスを認識するな
     ら、そのバックスラッシュは 2 回繰り返さなければいけません。これは複
     雑で理解しにくいので、ごく単純な表現以外は、全て raw 文字列を使うこ
     とを強く推奨します。

‘[]’

     文字の集合を指定するのに使います。集合の中では:

        * 文字を個別に指定できます。 ‘[amk]’ は ‘'a'’ 、 ‘'m'’ または
          ‘'k'’ にマッチします。

        * 連続した文字の範囲を、 ‘'-'’ を2 つの文字で挟んで指定できます
          。例えば、 ‘[a-z]’ はあらゆる小文字の ASCII 文字にマッチします
          。‘[0-5][0-9]’ は ‘00’ から ‘59’ まで全ての 2 桁の数字にマッチ
          します。‘[0-9A-Fa-f]’ は任意の 16 進数字にマッチします。‘-’ が
          エスケープされているか (例: ‘[a\-z]’)、先頭や末尾の文字にされ
          ていると (例: ‘[-a]’ や ‘[a-]’)、リテラル ‘'-'’ にマッチします
          。

        * 集合の中では、特殊文字はその特殊な意味を失います。例えば
          ‘[(+*)]’ はリテラル文字 ‘'('’ 、 ‘'+'’ 、 ‘'*'’ 、または ‘')'’
          のどれにでもマッチします。

        * ‘\w’ や ‘\S’ のような文字クラス (後述) も集合の中で受理されま
          すが、それにマッチする文字は使用するフラグ (*note flags:
          224a.) に依存します。

        * '補集合' をとって範囲内にない文字にマッチできます。集合の最初
          の文字が ‘'^'’ なら、集合に '含まれない' 全ての文字にマッチし
          ます。例えば、 ‘[^5]’ は ‘'5'’ を除くあらゆる文字にマッチし、
          ‘[^^]’ は ‘'^'’ を除くあらゆる文字にマッチします。 ‘^’ は集合
          の最初の文字でなければ特別の意味を持ちません。

        * 集合の中でリテラル ‘']'’ にマッチさせるには、その前にバックス
          ラッシュをつけるか、集合の先頭に置きます。例えば、 ‘[()[\]{}]’
          と ‘[]()[{}]’ はどちらも閉じ角括弧、開き角括弧、波括弧、丸括弧
          にマッチします。

        * Unicode Technical Standard #18(1) にあるような集合の入れ子や集
          合操作が将来追加される可能性があります。これは構文を変化させる
          もので、この変化を容易にするために、さしあたって曖昧な事例には
          *note FutureWarning: 3ee. が送出されます。これはリテラル ‘'['’
          で始まる集合や、リテラル文字の連続 ‘'--'’ 、 ‘'&&'’ 、 ‘'~~'’
          および ‘'||'’ を含む集合を含みます。警告を避けるにはバックスラ
          ッシュでエスケープしてください。

     バージョン 3.7 で変更: 文字セットが将来意味論的に変化する構造を含む
     なら *note FutureWarning: 3ee. が送出されます。

‘|’

     'A' と 'B' を任意の正規表現として、 ‘A|B’ は 'A' と 'B' のいずれか
     にマッチする正規表現を作成します。この方法で任意の数の正規表現を
     ‘'|'’ で分離できます。これはグループ (下記参照) 中でも使えます。対
     象文字列を走査するとき、‘'|'’ で分離された正規表現は左から右へ順に
     試されます。一つのパターンが完全にマッチしたとき、そのパターン枝が
     受理されます。つまり、ひとたび 'A' がマッチしてしまえば、例え 'B' に
     よって全体のマッチが長くなるとしても、 'B' はもはや走査されません。
     言いかえると、 ‘'|'’ 演算子は決して貪欲にはなりません。リテラル
     ‘'|'’ にマッチするには、 ‘\|’ を使うか、 ‘[|]’ のように文字クラス中
     に囲みます。

‘(...)’

     丸括弧で囲まれた正規表現にマッチするとともに、グループの開始と終了
     を表します。グループの中身は以下で述べるように、マッチが実行された
     後で回収したり、その文字列中で以降 ‘\number’ 特殊シーケンスでマッチ
     したりできます。リテラル ‘'('’ や ‘')'’ にマッチするには、‘\(’ や
     ‘\)’ を使うか、文字クラス中に囲みます: ‘[(]’、 ‘[)]’ 。

‘(?...)’

     これは拡張記法です (‘'('’ に続く ‘'?'’ はそれ以上の意味を持ちません
     ) 。 ‘'?'’ に続く最初の文字がこの構造の意味と特有の構文を決定します
     。拡張は一般に新しいグループを作成しません。ただし ‘(?P<name>...)’
     はこの法則の唯一の例外です。現在サポートされている拡張は以下の通り
     です。

‘(?aiLmsux)’

     (One or more letters from the set ‘'a'’, ‘'i'’, ‘'L'’, ‘'m'’,
     ‘'s'’, ‘'u'’, ‘'x'’.)  The group matches the empty string; the
     letters set the corresponding flags for the entire regular
     expression:

        * *note re.A: 224b. (ASCIIのみにマッチ)

        * *note re.I: 224c. (大文字小文字を無視)

        * *note re.L: 224d. (ロケール依存)

        * *note re.M: 224e. (マルチライン)

        * *note re.S: 224f. (ドットはすべてにマッチ)

        * *note re.U: 2250. (Unicodeマッチ)

        * *note re.X: 2251. (冗長)

     (The flags are described in *note モジュールコンテンツ: 2252.)
     This is useful if you wish to include the flags as part of the
     regular expression, instead of passing a 'flag' argument to the
     *note re.compile(): ba1. function.  Flags should be used first in
     the expression string.

     バージョン 3.11 で変更: This construction can only be used at the
     start of the expression.

‘(?:...)’

     普通の丸括弧の、キャプチャしない版です。丸括弧で囲まれた正規表現に
     マッチしますが、このグループがマッチした部分文字列は、マッチを実行
     したあとで回収することも、そのパターン中で以降参照することも 'でき
     ません' 。

‘(?aiLmsux-imsx:...)’

     (Zero or more letters from the set ‘'a'’, ‘'i'’, ‘'L'’, ‘'m'’,
     ‘'s'’, ‘'u'’, ‘'x'’, optionally followed by ‘'-'’ followed by one
     or more letters from the ‘'i'’, ‘'m'’, ‘'s'’, ‘'x'’.)  The letters
     set or remove the corresponding flags for the part of the
     expression:

        * *note re.A: 224b. (ASCIIのみにマッチ)

        * *note re.I: 224c. (大文字小文字を無視)

        * *note re.L: 224d. (ロケール依存)

        * *note re.M: 224e. (マルチライン)

        * *note re.S: 224f. (ドットはすべてにマッチ)

        * *note re.U: 2250. (Unicodeマッチ)

        * *note re.X: 2251. (冗長)

     (The flags are described in *note モジュールコンテンツ: 2252.)

     文字 ‘'a'’ 、 ‘'L'’ および ‘'u'’ は相互に排他であり、組み合わせるこ
     とも ‘'-'’ に続けることもできません。その代わり、これらの内一つがイ
     ンライングループ中に現れると、外側のグループでのマッチングモードを
     上書きします。 Unicode パターン中では ‘(?a:...)’ は ASCII 限定マッ
     チングに切り替え、 ‘(?u:...)’ は Unicode マッチング (デフォルト) に
     切り替えます。バイト列パターン中では、 ‘(?L:...)’ はロケール依存マ
     ッチングに切り替え、 ‘(?a:...)’ は ASCII 限定マッチング (デフォルト
     ) に切り替えます。この上書きは狭いインライングループにのみ影響し、
     元のマッチングモードはグループ外では復元されます。

     Added in version 3.6.

     バージョン 3.7 で変更: 文字 ‘'a'’ 、 ‘'L'’ および ‘'u'’ もグループ
     中で使えます。

‘(?>...)’

     Attempts to match ‘...’ as if it was a separate regular expression,
     and if successful, continues to match the rest of the pattern
     following it.  If the subsequent pattern fails to match, the stack
     can only be unwound to a point 'before' the ‘(?>...)’ because once
     exited, the expression, known as an 'atomic group', has thrown away
     all stack points within itself.  Thus, ‘(?>.*).’ would never match
     anything because first the ‘.*’ would match all characters
     possible, then, having nothing left to match, the final ‘.’ would
     fail to match.  Since there are no stack points saved in the Atomic
     Group, and there is no stack point before it, the entire expression
     would thus fail to match.

     Added in version 3.11.

‘(?P<name>...)’

     通常の丸括弧に似ていますが、このグループがマッチした部分文字列はシ
     ンボリックグループ名 'name' でアクセスできます。グループ名は有効な
     Python 識別子でなければならず、*note bytes: 1a4. パターンでは
     ASCIIの範囲のバイトのみを含めることができます。各グループ名は 1 個
     の正規表現内で一度だけ定義されていなければなりません。シンボリック
     グループは、そのグループが名前付けされていなかったかのように番号付
     けされたグループでもあります。

     名前付きグループは 3 つのコンテキストで参照できます。パターンが
     ‘(?P<quote>['\"]).*?(?P=quote)’ (シングルまたはダブルクオートで囲ま
     れた文字列にマッチ) ならば:

     グループ "quote" を参照するコンテキスト     参照する方法
                                                 
     -----------------------------------------------------------------------------------
                                                 
     その同じパターン中                             * ‘(?P=quote)’ (示したとおり)
                                                 
                                                    * ‘\1’
                                                 
                                                 
     マッチオブジェクト 'm' の処理時                * ‘m.group('quote')’
                                                 
                                                    * ‘m.end('quote')’ (など)
                                                 
                                                 
     ‘re.sub()’ の 'repl' 引数へ渡される文字列      * ‘\g<quote>’
     中                                          
                                                    * ‘\g<1>’
                                                 
                                                    * ‘\1’
                                                 

     バージョン 3.12 で変更: *note bytes: 1a4. パターンではグループの '名
     前' にASCIIの範囲(‘b'\x00'’-‘b'\x7f'’)のバイトのみを含めることがで
     きます。

‘(?P=name)’

     名前付きグループへの後方参照です。これは 'name' という名前の既出の
     グループがマッチした文字列にマッチします。

‘(?#...)’

     コメントです。括弧の中身は単純に無視されます。

‘(?=...)’

     ‘...’ が次に続くものにマッチすればマッチしますが、文字列をまったく
     消費しません。これは '先読みアサーション (lookahead assertion)' と
     呼ばれます。例えば、‘Isaac (?=Asimov)’ は ‘'Isaac '’ に、その後に
     ‘'Asimov'’ が続く場合にのみ、マッチします。

‘(?!...)’

     ‘...’ が次に続くものにマッチしなければマッチします。これは '否定先
     読みアサーション (negative lookahead assertion)' です。例えば、
     ‘Isaac (?!Asimov)’ は ‘'Isaac '’ に、その後に ‘'Asimov'’ が続か 'な
     い' 場合にのみ、マッチします。

‘(?<=...)’

     その文字列における現在位置の前に、現在位置で終わる ‘...’ とのマッチ
     があれば、マッチします。これは '後読みアサーション' と呼ばれます。
     ‘(?<=abc)def’ は、後読みは 3 文字をバックアップし、含まれているパタ
     ーンがマッチするか検査するので ‘'abcdef'’ にマッチを見つけます。含
     まれるパターンは、固定長の文字列にのみマッチしなければなりません。
     すなわち、 ‘abc’ や ‘a|b’ は許されますが、‘a*’ や ‘a{3,4}’ は許され
     ません。肯定後読みアサーションで始まるパターンは、検索される文字列
     の先頭とは決してマッチしないことに注意して下さい。*note match():
     11fe. 関数ではなく *note search(): 11fd. 関数を使う方が望ましいでし
     ょう:

          >>> import re
          >>> m = re.search('(?<=abc)def', 'abcdef')
          >>> m.group(0)
          'def'

     この例ではハイフンに続く単語を探します:

          >>> m = re.search(r'(?<=-)\w+', 'spam-egg')
          >>> m.group(0)
          'egg'

     バージョン 3.5 で変更: 固定長のグループ参照をサポートするようになり
     ました。

‘(?<!...)’

     その文字列における現在位置の前に ‘...’ とのマッチがなければ、マッチ
     します。これは '否定後読みアサーション(negative lookbehind
     assertion)' と呼ばれます。肯定後読みアサーションと同様に、含まれる
     パターンは固定長の文字列にのみマッチしなければなりません。否定後読
     みアサーションで始まるパターンは検索される文字列の先頭でマッチでき
     ます。

‘(?(id/name)yes-pattern|no-pattern)’

     与えられた 'id' や 'name' のグループが存在すれば ‘yes-pattern’ との
     、存在しなければ ‘no-pattern’ とのマッチを試みます。‘no-pattern’ は
     オプションであり省略できます。例えば、
     ‘(<)?(\w+@\w+(?:\.\w+)+)(?(1)>|$)’ は貧弱な E-mail マッチングパター
     ンで、‘'<user@host.com>'’ や ‘'user@host.com'’ にはマッチしますが、
     ‘'<user@host.com'’ や ‘'user@host.com>'’ にはマッチしません。

     バージョン 3.12 で変更: グループ 'id' にはASCIIの数字のみを含めるこ
     とができます。*note bytes: 1a4. パターンではグループの '名前' に
     ASCIIの範囲(‘b'\x00'’-‘b'\x7f'’)のバイトのみを含めることができます
     。

特殊シーケンスは ‘'\'’ と以下のリストの文字から構成されます。通常文字が
ASCII 数字でも ASCII 文字でもなければ、結果の正規表現は 2 番目の文字にマ
ッチします。例えば、‘\$’ は文字 ‘'$'’ にマッチします。

‘\number’

     同じ番号のグループの中身にマッチします。グループは 1 から始まる番号
     をつけられます。例えば、 ‘(.+) \1’ は、 ‘'the the'’ あるいは ‘'55
     55'’ にマッチしますが、 ‘'thethe'’ にはマッチしません(グループの後
     のスペースに注意して下さい)。この特殊シーケンスは最初の 99 グループ
     のうちの一つとのマッチにのみ使えます。 'number' の最初の桁が 0 であ
     るか、 'number' が 3 桁の 8 進数であれば、それはグループのマッチと
     してではなく、 8 進値 'number' を持つ文字として解釈されます。文字ク
     ラスの ‘'['’ と ‘']'’ の間では全ての数値エスケープが文字として扱わ
     れます。

‘\A’

     文字列の先頭でのみマッチします。

‘\b’

     空文字列にマッチしますが、単語の先頭か末尾でのみです。単語は単語文
     字の並びとして定義されます。形式的には、 ‘\b’ は ‘\w’ と ‘\W’ 文字
     (またはその逆) との、あるいは ‘\w’ と文字列の先頭・末尾との境界とし
     て定義されます。例えば、 ‘r'\bat\b'’ は ‘'at'’ 、 ‘'at.'’、
     ‘'(at)'’ や ‘'as at ay'’ にはマッチしますが、 ‘'attempt'’ や
     ‘'atlas'’ にはマッチしません。

     The default word characters in Unicode (str) patterns are Unicode
     alphanumerics and the underscore, but this can be changed by using
     the *note ASCII: 5f8. flag.  Word boundaries are determined by the
     current locale if the *note LOCALE: b3a. flag is used.

          注釈: Inside a character range, ‘\b’ represents the backspace
          character, for compatibility with Python's string literals.

‘\B’

     空文字列にマッチしますが、それが単語の先頭か末尾 'でない' ときのみ
     です。つまり ‘r'at\B'’ は ‘'athens'’、 ‘'atom'’、‘'attorney'’ にマ
     ッチしますが、 ‘'at'’、 ‘'at.'’ や ‘'at!'’ にはマッチしません。
     ‘\B’ は ‘\b’ のちょうど反対で、 Unicode パターンにおける単語文字は
     Unicode 英数字およびアンダースコアですが、 これは *note ASCII: 5f8.
     フラグを使って変更できます。 *note LOCALE: b3a. フラグが使われてい
     るなら単語の境界は現在のロケールによって決定されます。

          注釈: Note that ‘\B’ does not match an empty string, which
          differs from RE implementations in other programming languages
          such as Perl.  This behavior is kept for compatibility
          reasons.

‘\d’

     Unicode (str) パターンでは:

          任意の Unicode 10 進数字 (Unicode 文字カテゴリ [Nd](2))にマッ
          チします。これは ‘[0-9]’ とその他多数の数字を含みます。

          *note ASCII: 5f8. フラグを使用すると ‘[0-9]’ にマッチします。

     8 ビット (bytes) パターンでは:

          任意のASCII文字の 10 進数字にマッチします。これは ‘[0-9]’ と等
          価です。

‘\D’

     Matches any character which is not a decimal digit.  This is the
     opposite of ‘\d’.

     *note ASCII: 5f8. フラグを使用すると ‘[^0-9]’ にマッチします。

‘\s’

     Unicode (str) パターンでは:

          Matches Unicode whitespace characters (as defined by *note
          str.isspace(): 2129.).  This includes ‘[ \t\n\r\f\v]’, and
          also many other characters, for example the non-breaking
          spaces mandated by typography rules in many languages.

          *note ASCII: 5f8. フラグを使用すると ‘[ \t\n\r\f\v]’ にマッチ
          します。

     8 ビット (bytes) パターンでは:

          ASCII 文字セットで空白文字と見なされる文字にマッチします。これ
          は ‘[ \t\n\r\f\v]’ と等価です。

‘\S’

     Matches any character which is not a whitespace character.  This is
     the opposite of ‘\s’.

     *note ASCII: 5f8. フラグを使用すると ‘[^ \t\n\r\f\v]’ にマッチしま
     す。

‘\w’

     Unicode (str) パターンでは:

          Matches Unicode word characters; this includes all Unicode
          alphanumeric characters (as defined by *note str.isalnum():
          2122.), as well as the underscore (‘_’).

          *note ASCII: 5f8. フラグを使用すると ‘[a-zA-Z0-9_]’ にマッチし
          ます。

     8 ビット (bytes) パターンでは:

          ASCII 文字セットで英数字と見なされる文字にマッチします。これは
          ‘[a-zA-Z0-9_]’ と等価です。*note LOCALE: b3a. フラグが使われて
          いるなら、現在のロケールで英数字と見なされる文字およびアンダー
          スコアにマッチします。

‘\W’

     Matches any character which is not a word character.  This is the
     opposite of ‘\w’.  By default, matches non-underscore (‘_’)
     characters for which *note str.isalnum(): 2122. returns ‘False’.

     *note ASCII: 5f8. フラグを使用すると ‘[^a-zA-Z0-9_]’ にマッチします
     。

     If the *note LOCALE: b3a. flag is used, matches characters which
     are neither alphanumeric in the current locale nor the underscore.

‘\Z’

     文字列の末尾でのみマッチします。

Python 文字列リテラルでサポートされている *note エスケープシーケンス:
426. のほとんども正規表現パーザで受理されます:

     \a      \b      \f      \n
     \N      \r      \t      \u
     \U      \v      \x      \\

(‘\b’ は単語の境界を表すのに使われ、文字クラス中でのみ "後退
(backspace)" 文字を意味することに注意してください。)

‘'\u'’、‘'\U'’ および ‘'\N'’ エスケープシーケンスは、Unicode (str)パター
ン内でのみ認識されます。バイト列ではエラーとなります。ASCII 文字のエスケ
ープで未知のものは将来使うために予約されていて、エラーとして扱われます。

8 進エスケープは限られた形式でのみ含まれます。その最初の桁が 0 であるか
、それが 3 桁の 8 進数であるならば、それは 8 進エスケープと見なされます
。そうでなければ、それはグループ参照です。文字列リテラルでは、8 進エスケ
ープは常にたかだか 3 桁長です。

バージョン 3.3 で変更: ‘'\u'’ と ‘'\U'’ エスケープシーケンスが追加されま
した。

バージョン 3.6 で変更: ‘'\'’ と ASCII 文字からなる未知のエスケープはエラ
ーになります。

バージョン 3.8 で変更: ‘'\N{NAME}'’ エスケープシーケンスが追加されました
。文字列リテラルでは、同名のUnicode 文字に展開されます。(‘'\N{EM DASH}'’
など)

   ---------- Footnotes ----------

   (1) https://unicode.org/reports/tr18/

   (2) https://www.unicode.org/versions/Unicode15.0.0/ch04.pdf#G134153


File: python.info,  Node: モジュールコンテンツ,  Next: 正規表現オブジェクト,  Prev: 正規表現のシンタックス,  Up: re --- 正規表現操作

5.6.2.2 モジュールコンテンツ
............................

このモジュールはいくつかの関数、定数、例外を定義します。このうちいくつか
の関数は、コンパイル済み正規表現がそなえる完全な機能のメソッドを簡易にし
たものです。些細なものを除くほとんどのアプリケーションは常にコンパイル済
み形式を使います。

* Menu:

* フラグ::
* 関数: 関数<2>.
* 例外: 例外<3>.


File: python.info,  Node: フラグ,  Next: 関数<2>,  Up: モジュールコンテンツ

5.6.2.3 フラグ
..............

バージョン 3.6 で変更: フラグ定数は、*note enum.IntFlag: 2255. のサブク
ラスである *note RegexFlag: 5f9. のインスタンスになりました。

 -- クラス: re.RegexFlag

     An *note enum.IntFlag: 2255. class containing the regex options
     listed below.

     Added in version 3.11: - added to ‘__all__’

 -- データ: re.A
 -- データ: re.ASCII

     ‘\w’、‘\W’、‘\b’、‘\B’、‘\d’、‘\D’、‘\s’、および ‘\S’ において、
     ASCII 文字のみでマッチングを行います。これは Unicode(str) パターン
     でのみ意味があり、バイト列パターンでは無視されます。

     インラインフラグの ‘(?a)’ に相当します。

          注釈: The *note U: 2250. flag still exists for backward
          compatibility, but is redundant in Python 3 since matches are
          Unicode by default for ‘str’ patterns, and Unicode matching
          isn't allowed for bytes patterns.  *note UNICODE: b3b. and the
          inline flag ‘(?u)’ are similarly redundant.

 -- データ: re.DEBUG

     コンパイルした表現に関するデバッグ情報を出力します。

     対応するインラインフラグはありません。

 -- データ: re.I
 -- データ: re.IGNORECASE

     Perform case-insensitive matching; expressions like ‘[A-Z]’ will
     also match lowercase letters.  Full Unicode matching (such as ‘Ü’
     matching ‘ü’) also works unless the *note ASCII: 5f8. flag is used
     to disable non-ASCII matches.  The current locale does not change
     the effect of this flag unless the *note LOCALE: b3a. flag is also
     used.

     インラインフラグの ‘(?i)’ に相当します。

     Unicode パターン ‘[a-z]’ または ‘[A-Z]’ が *note IGNORECASE: 168c.
     フラグとあわせて使われたとき、52 の ASCII 文字に加えて 4 の非 ASCII
     文字 'İ' (U+0130, Latin capital letter I with dot above) 、 'ı'
     (U+0131, Latin small letter dotless i) 、 'ſ' (U+017F, Latin small
     letter long s) および 'K' (U+212A, Kelvin sign) にマッチすることに
     注意してください。 *note ASCII: 5f8. フラグが使われているなら、文字
     'a' から 'z' および 'A' から 'Z' にのみマッチします。

 -- データ: re.L
 -- データ: re.LOCALE

     Make ‘\w’, ‘\W’, ‘\b’, ‘\B’ and case-insensitive matching dependent
     on the current locale.  This flag can be used only with bytes
     patterns.

     インラインフラグの ‘(?L)’ に相当します。

          警告: This flag is discouraged; consider Unicode matching
          instead.  The locale mechanism is very unreliable as it only
          handles one "culture" at a time and only works with 8-bit
          locales.  Unicode matching is enabled by default for Unicode
          (str) patterns and it is able to handle different locales and
          languages.

     バージョン 3.6 で変更: *note LOCALE: b3a. はバイト列パターンにのみ
     使え、*note ASCII: 5f8. と互換ではありません。

     バージョン 3.7 で変更: *note LOCALE: b3a. フラグがあるコンパイル済
     み正規表現オブジェクトはコンパイル時のロケールに依存しなくなりまし
     た。マッチング時のロケールのみがマッチングの結果に影響します。

 -- データ: re.M
 -- データ: re.MULTILINE

     指定されると、パターン文字 ‘'^'’ は、文字列の先頭および各行の先頭
     (各改行の直後)とマッチします；そしてパターン文字 ‘'$'’ は文字列の末
     尾および各行の末尾 (改行の直前) とマッチします。デフォルトでは、
     ‘'^'’ は、文字列の先頭とだけマッチし、 ‘'$'’ は、文字列の末尾および
     文字列の末尾の改行の直前(がもしあれば)とマッチします。

     インラインフラグの ‘(?m)’ に相当します。

 -- データ: re.NOFLAG

     Indicates no flag being applied, the value is ‘0’.  This flag may
     be used as a default value for a function keyword argument or as a
     base value that will be conditionally ORed with other flags.
     Example of use as a default value:

          def myfunc(text, flag=re.NOFLAG):
              return re.match(text, flag)

     Added in version 3.11.

 -- データ: re.S
 -- データ: re.DOTALL

     特殊文字 ‘'.'’ を、改行を含む任意の文字と、とにかくマッチさせます；
     このフラグがなければ、 ‘'.'’ は、改行 '以外の' 任意の文字とマッチし
     ます。

     インラインフラグの ‘(?s)’ に相当します。

 -- データ: re.U
 -- データ: re.UNICODE

     In Python 3, Unicode characters are matched by default for ‘str’
     patterns.  This flag is therefore redundant with 'no effect' and is
     only kept for backward compatibility.

     See *note ASCII: 5f8. to restrict matching to ASCII characters
     instead.

 -- データ: re.X
 -- データ: re.VERBOSE

     このフラグは正規表現を、パターンの論理的な節を視覚的に分割し、コメ
     ントを加えることで、見た目よく読みやすく書けるようにします。パター
     ン中の空白は、文字クラス中にあるときと、エスケープされていないバッ
     クスラッシュの後にあるときと、 ‘*?’ 、 ‘(?:’ や ‘(?P<...>’ のような
     トークン中を除いて無視されます。たとえば、 ‘(? :’ and ‘* ?’ は許さ
     れません。ある行が文字クラス中でもエスケープされていないバックスラ
     ッシュの後でもない ‘#’ を含むなら、一番左のそのような ‘#’ から行末
     までの全ての文字は無視されます。

     つまり、10 進数字にマッチする下記のふたつの正規表現オブジェクトは、
     機能的に等価です:

          a = re.compile(r"""\d +  # the integral part
                             \.    # the decimal point
                             \d *  # some fractional digits""", re.X)
          b = re.compile(r"\d+\.\d*")

     インラインフラグの ‘(?x)’ に相当します。


File: python.info,  Node: 関数<2>,  Next: 例外<3>,  Prev: フラグ,  Up: モジュールコンテンツ

5.6.2.4 関数
............

 -- の関数: re.compile (pattern, flags=0)

     正規表現パターンを *note 正規表現オブジェクト: f53. にコンパイルし
     、以下に述べる *note match(): 225a. 、 *note search(): 225b. その他
     のメソッドを使ってマッチングに使えるようにします。

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

     シーケンス

          prog = re.compile(pattern)
          result = prog.match(string)

     は、以下と同等です

          result = re.match(pattern, string)

     が、 *note re.compile(): ba1. を使い、結果の正規表現オブジェクトを
     保存して再利用するほうが、一つのプログラムでその表現を何回も使うと
     きに効率的です。

          注釈: *note re.compile(): ba1. やモジュールレベルのマッチング
          関数に渡された最新のパターンはコンパイル済みのものがキャッシュ
          されるので、一度に正規表現を少ししか使わないプログラムでは正規
          表現をコンパイルする必要はありません。

 -- の関数: re.search (pattern, string, flags=0)

     'string' 全体を走査して、正規表現 'pattern' がマッチを発生する最初
     の位置を探して、対応する *note Match: c96. を返します。もし文字列内
     に、そのパターンとマッチする位置がないならば、 ‘None’ を返します；
     これは、文字列内のある点で長さゼロのマッチを探すこととは異なること
     に注意して下さい。

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

 -- の関数: re.match (pattern, string, flags=0)

     もし 'string' の先頭で 0 個以上の文字が正規表現 'pattern' とマッチ
     すれば、対応する *note Match: c96. を返します。もし文字列がパターン
     とマッチしなければ、 ‘None’ を返します；これは長さゼロのマッチとは
     異なることに注意して下さい。

     *note MULTILINE: 2249. モードにおいても、*note re.match(): 11fe. は
     各行の先頭でマッチするのではなく、文字列の先頭でのみマッチすること
     に注意してください。

     'string' 中のどこででもマッチさせたいなら、代わりに *note search():
     11fd. を使ってください (*note search() vs.  match(): 225c. も参照し
     てください)。

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

 -- の関数: re.fullmatch (pattern, string, flags=0)

     'string' 全体が正規表現 'pattern' にマッチするなら、対応する *note
     Match: c96. を返します。文字列がパターンにマッチしないなら ‘None’ を
     返します。これは長さ 0 のマッチとは異なることに注意して下さい。

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

     Added in version 3.4.

 -- の関数: re.split (pattern, string, maxsplit=0, flags=0)

     'string' を、出現した 'pattern' で分割します。 'pattern' 中でキャプ
     チャの丸括弧が使われていれば、パターン中の全てのグループのテキスト
     も結果のリストの一部として返されます。'maxsplit' が 0 でなければ、
     分割は最大 'maxsplit' 回起こり、残りの文字列はリストの最終要素とし
     て返されます。

          >>> re.split(r'\W+', 'Words, words, words.')
          ['Words', 'words', 'words', '']
          >>> re.split(r'(\W+)', 'Words, words, words.')
          ['Words', ', ', 'words', ', ', 'words', '.', '']
          >>> re.split(r'\W+', 'Words, words, words.', maxsplit=1)
          ['Words', 'words, words.']
          >>> re.split('[a-f]+', '0a3B9', flags=re.IGNORECASE)
          ['0', '3', '9']

     セパレータ中にキャプチャグループがあり、それが文字列の先頭にマッチ
     するなら、結果は空文字列で始まります。同じことが文字列の末尾にも言
     えます。

          >>> re.split(r'(\W+)', '...words, words...')
          ['', '...', 'words', ', ', 'words', '...', '']

     そうして、結果のリストにおいて、セパレータの構成要素は常に同じ相対
     的インデックスに見つかります。

     パターンへの空マッチは、直前の空マッチに隣接していないときのみ文字
     列を分割します。

          >>> re.split(r'\b', 'Words, words, words.')
          ['', 'Words', ', ', 'words', ', ', 'words', '.']
          >>> re.split(r'\W*', '...words...')
          ['', '', 'w', 'o', 'r', 'd', 's', '', '']
          >>> re.split(r'(\W*)', '...words...')
          ['', '...', '', '', 'w', '', 'o', '', 'r', '', 'd', '', 's', '...', '', '', '']

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

     バージョン 3.1 で変更: オプションの flags 引数が追加されました。

     バージョン 3.7 で変更: 空文字列にマッチしうるパターンでの分割をサポ
     ートするようになりました。

     バージョン 3.13 で非推奨: Passing 'maxsplit' and 'flags' as
     positional arguments is deprecated.  In future Python versions they
     will be *note keyword-only parameters: 285.

 -- の関数: re.findall (pattern, string, flags=0)

     Return all non-overlapping matches of 'pattern' in 'string', as a
     list of strings or tuples.  The 'string' is scanned left-to-right,
     and matches are returned in the order found.  Empty matches are
     included in the result.

     The result depends on the number of capturing groups in the
     pattern.  If there are no groups, return a list of strings matching
     the whole pattern.  If there is exactly one group, return a list of
     strings matching that group.  If multiple groups are present,
     return a list of tuples of strings matching the groups.
     Non-capturing groups do not affect the form of the result.

          >>> re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest')
          ['foot', 'fell', 'fastest']
          >>> re.findall(r'(\w+)=(\d+)', 'set width=20 and height=10')
          [('width', '20'), ('height', '10')]

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

     バージョン 3.7 で変更: 空でないマッチが前の空マッチの直後から始めら
     れるようになりました。

 -- の関数: re.finditer (pattern, string, flags=0)

     'string' 中の正規表現 'pattern' の重複しないマッチ全てに渡る *note
     Match: c96. オブジェクトを yield する *note イテレータ: 191. を返し
     ます。 'string' は左から右へ走査され、マッチは見つかった順で返され
     ます。空マッチは結果に含まれます。

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

     バージョン 3.7 で変更: 空でないマッチが前の空マッチの直後から始めら
     れるようになりました。

 -- の関数: re.sub (pattern, repl, string, count=0, flags=0)

     'string' 中に出現する最も左の重複しない 'pattern' を置換 'repl' で
     置換することで得られる文字列を返します。 パターンが見つからない場合
     、 'string' がそのまま返されます。 'repl' は文字列または関数です。
     'repl' が文字列の場合は、その中の全てのバックスラッシュエスケープが
     処理されます。 ‘\n’ は 1 つの改行文字に変換され、 ‘\r’ はキャリッジ
     リターンに変換される、などです。 ASCII 文字のエスケープで未知のもの
     は将来使うために予約されていて、エラーとして扱われます。 それ以外の
     ‘\&’ のような未知のエスケープは残されます。 ‘\6’ のような後方参照は
     、パターンのグループ 6 がマッチした部分文字列で置換されます。 例え
     ば:

          >>> re.sub(r'def\s+([a-zA-Z_][a-zA-Z_0-9]*)\s*\(\s*\):',
          ...        r'static PyObject*\npy_\1(void)\n{',
          ...        'def myfunc():')
          'static PyObject*\npy_myfunc(void)\n{'

     もし 'repl' が関数であれば、重複しない 'pattern' が発生するたびにそ
     の関数が呼ばれます。この関数は一つの *note Match: c96. 引数を取り、
     置換文字列を返します。例えば:

          >>> def dashrepl(matchobj):
          ...     if matchobj.group(0) == '-': return ' '
          ...     else: return '-'
          ...
          >>> re.sub('-{1,2}', dashrepl, 'pro----gram-files')
          'pro--gram files'
          >>> re.sub(r'\sAND\s', ' & ', 'Baked Beans And Spam', flags=re.IGNORECASE)
          'Baked Beans & Spam'

     パターンは、文字列でも *note Pattern: 1748. でも構いません。

     オプション引数 'count' は出現したパターンを置換する最大の回数です。
     'count' は非負整数です。省略されるか 0 なら、出現した全てが置換され
     ます。パターンへの空マッチは前の空マッチに隣接していないときのみ置
     換されるので、 ‘sub('x*', '-', 'abxd')’ は ‘'-a-b--d-'’ を返します
     。

     文字列型 'repl' 引数では、上で述べた文字エスケープや後方参照に加え
     て、 ‘\g<name>’ は ‘(?P<name>...)’ 構文で定義された ‘name’ という名
     前のグループがマッチした部分文字列を使い、 ‘\g<number>’ は対応する
     グループ番号を使います。よって ‘\g<2>’ は ‘\2’ と等価ですが、
     ‘\g<2>0’ のような置換においても曖昧になりません。 ‘\20’ は、グルー
     プ 20 への参照として解釈され、グループ 2 への参照にリテラル文字
     ‘'0'’ が続いたものとしては解釈されません。後方参照 ‘\g<0>’ は正規表
     現とマッチした部分文字列全体で置き換わります。

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

     バージョン 3.1 で変更: オプションの flags 引数が追加されました。

     バージョン 3.5 で変更: マッチしなかったグループは空文字列に置き換え
     られます。

     バージョン 3.6 で変更: 'pattern' 中に ‘'\'’ と ASCII 文字からなる未
     知のエスケープがあると、エラーになります。

     バージョン 3.7 で変更: Unknown escapes in 'repl' consisting of
     ‘'\'’ and an ASCII letter now are errors.  Empty matches for the
     pattern are replaced when adjacent to a previous non-empty match.

     バージョン 3.12 で変更: Group 'id' can only contain ASCII digits.
     In *note bytes: 1a4. replacement strings, group 'name' can only
     contain bytes in the ASCII range (‘b'\x00'’-‘b'\x7f'’).

     バージョン 3.13 で非推奨: Passing 'count' and 'flags' as positional
     arguments is deprecated.  In future Python versions they will be
     *note keyword-only parameters: 285.

 -- の関数: re.subn (pattern, repl, string, count=0, flags=0)

     *note sub(): 283. と同じ操作を行いますが、タプル ‘(new_string、
     number_of_subs_made)’ を返します。

     The expression's behaviour can be modified by specifying a 'flags'
     value.  Values can be any of the *note flags: 224a. variables,
     combined using bitwise OR (the ‘|’ operator).

 -- の関数: re.escape (pattern)

     'pattern' 中の特殊文字をエスケープします。これは正規表現メタ文字を
     含みうる任意のリテラル文字列にマッチしたい時に便利です。

          >>> print(re.escape('https://www.python.org'))
          https://www\.python\.org

          >>> legal_chars = string.ascii_lowercase + string.digits + "!#$%&'*+-.^_`|~:"
          >>> print('[%s]+' % re.escape(legal_chars))
          [abcdefghijklmnopqrstuvwxyz0123456789!\#\$%\&'\*\+\-\.\^_`\|\~:]+

          >>> operators = ['+', '-', '*', '/', '**']
          >>> print('|'.join(map(re.escape, sorted(operators, reverse=True))))
          /|\-|\+|\*\*|\*

     この関数は、バックスラッシュのみをエスケープするべき *note sub():
     283. および *note subn(): 284. における置換文字列に使われてはなりま
     せん。例えば:

          >>> digits_re = r'\d+'
          >>> sample = '/usr/sbin/sendmail - 0 errors, 12 warnings'
          >>> print(re.sub(digits_re, digits_re.replace('\\', r'\\'), sample))
          /usr/sbin/sendmail - \d+ errors, \d+ warnings

     バージョン 3.3 で変更: ‘'_'’ 文字がエスケープされなくなりました。

     バージョン 3.7 で変更: 正規表現で特別な意味を持つ文字だけがエスケー
     プされます。結果として、 ‘'!'’、 ‘'"'’、 ‘'%'’、 ‘"'"’、 ‘','’、
     ‘'/'’、 ‘':'’、 ‘';'’、 ‘'<'’、 ‘'='’、 ‘'>'’、 ‘'@'’、 と ‘"`"’ は
     もはやエスケープされません。

 -- の関数: re.purge ()

     正規表現キャッシュをクリアします。


File: python.info,  Node: 例外<3>,  Prev: 関数<2>,  Up: モジュールコンテンツ

5.6.2.5 例外
............

 -- 例外: re.PatternError (msg, pattern=None, pos=None)

     Exception raised when a string passed to one of the functions here
     is not a valid regular expression (for example, it might contain
     unmatched parentheses) or when some other error occurs during
     compilation or matching.  It is never an error if a string contains
     no match for a pattern.  The ‘PatternError’ instance has the
     following additional attributes:

      -- の属性: msg

          フォーマットされていないエラーメッセージです。

      -- の属性: pattern

          正規表現のパターンです。

      -- の属性: pos

          'pattern' のコンパイルに失敗した場所のインデックスです (‘None’
          の場合もあります)。

      -- の属性: lineno

          'pos' に対応する行です (‘None’ の場合もあります)。

      -- の属性: colno

          'pos' に対応する列です (‘None’ の場合もあります)。

     バージョン 3.5 で変更: 追加の属性が追加されました。

     バージョン 3.13 で変更: ‘PatternError’ was originally named
     ‘error’; the latter is kept as an alias for backward compatibility.


File: python.info,  Node: 正規表現オブジェクト,  Next: マッチオブジェクト,  Prev: モジュールコンテンツ,  Up: re --- 正規表現操作

5.6.2.6 正規表現オブジェクト
............................

 -- クラス: re.Pattern

     Compiled regular expression object returned by *note re.compile():
     ba1.

     バージョン 3.9 で変更: *note re.Pattern: 1748. supports ‘[]’ to
     indicate a Unicode (str) or bytes pattern.  See *note
     ジェネリックエイリアス型: 67e.

 -- メソッド: Pattern.search (string[, pos[, endpos]])

     'string' 全体を走査して、この正規表現がマッチを発生する最初の位置を
     探して、対応する *note Match: c96. を返します。もし文字列内に、その
     パターンとマッチする位置がないならば、 ‘None’ を返します；これは、
     文字列内のある点で長さゼロのマッチを探すこととは異なることに注意し
     て下さい。

     オプションの第二引数 'pos' は、文字列のどこから探し始めるかを指定す
     るインデックスで、デフォルトでは 0 です。これは文字列のスライスと完
     全には同じではありません。パターン文字 ‘'^'’ は本当の文字列の先頭と
     改行の直後でマッチしますが、検索を開始するインデックスでマッチする
     とは限りません。

     オプションの引数 'endpos' は文字列がどこまで検索されるかを制限しま
     す。文字列の長さが 'endpos' 文字だったかのようになるので、'pos' か
     ら ‘endpos - 1’ の文字に対してだけマッチを探します。'endpos' が
     'pos' よりも小さいと、マッチは見つかりません。そうでなければ、'rx'
     をコンパイル済み正規表現オブジェクトとして、‘rx.search(string, 0,
     50)’ は ‘rx.search(string[:50], 0)’ と等価です。

          >>> pattern = re.compile("d")
          >>> pattern.search("dog")     # Match at index 0
          <re.Match object; span=(0, 1), match='d'>
          >>> pattern.search("dog", 1)  # No match; search doesn't include the "d"

 -- メソッド: Pattern.match (string[, pos[, endpos]])

     もし 'string' の先頭で 0 個以上の文字がこの正規表現とマッチすれば、
     対応する *note Match: c96. を返します。もし文字列がパターンとマッチ
     しなければ、 ‘None’ を返します；これは長さゼロのマッチとは異なるこ
     とに注意して下さい。

     オプションの 'pos' および 'endpos' 引数は *note search(): 225b. メ
     ソッドのものと同じ意味です。

          >>> pattern = re.compile("o")
          >>> pattern.match("dog")      # No match as "o" is not at the start of "dog".
          >>> pattern.match("dog", 1)   # Match as "o" is the 2nd character of "dog".
          <re.Match object; span=(1, 2), match='o'>

     'string' 中のどこででもマッチさせたいなら、代わりに *note search():
     225b. を使ってください (*note search() vs.  match(): 225c. も参照し
     てください)。

 -- メソッド: Pattern.fullmatch (string[, pos[, endpos]])

     'string' 全体がこの正規表現にマッチするなら、対応する *note Match:
     c96. を返します。文字列がパターンにマッチしないなら ‘None’ を返しま
     す。これは長さ 0 のマッチとは異なることに注意して下さい。

     オプションの 'pos' および 'endpos' 引数は *note search(): 225b. メ
     ソッドのものと同じ意味です。

          >>> pattern = re.compile("o[gh]")
          >>> pattern.fullmatch("dog")      # No match as "o" is not at the start of "dog".
          >>> pattern.fullmatch("ogre")     # No match as not the full string matches.
          >>> pattern.fullmatch("doggie", 1, 3)   # Matches within given limits.
          <re.Match object; span=(1, 3), match='og'>

     Added in version 3.4.

 -- メソッド: Pattern.split (string, maxsplit=0)

     *note split(): 282. 関数にこのコンパイル済みパターンを使うのと同じ
     です。

 -- メソッド: Pattern.findall (string[, pos[, endpos]])

     *note findall(): ff4. 関数にこのコンパイル済みパターンを使うのと似
     ていますが、オプションの 'pos' および 'endpos' 引数で *note
     search(): 11fd. のように検索範囲を制限できます。

 -- メソッド: Pattern.finditer (string[, pos[, endpos]])

     *note finditer(): 14a3. 関数にこのコンパイル済みパターンを使うのと
     似ていますが、オプションの 'pos' および 'endpos' 引数で *note
     search(): 11fd. のように検索範囲を制限できます。

 -- メソッド: Pattern.sub (repl, string, count=0)

     *note sub(): 283. 関数にこのコンパイル済みパターンを使うのと同じで
     す。

 -- メソッド: Pattern.subn (repl, string, count=0)

     *note subn(): 284. 関数にこのコンパイル済みパターンを使うのと同じで
     す。

 -- の属性: Pattern.flags

     正規表現のマッチングフラグです。これは *note compile(): ba1. に与え
     られたフラグ、パターン中の ‘(?...)’ インラインフラグ、およびパター
     ンが Unicode 文字列だった時の *note UNICODE: b3b. のような暗黙のフ
     ラグの組み合わせです。

 -- の属性: Pattern.groups

     パターン中のキャプチャグループの数です。

 -- の属性: Pattern.groupindex

     ‘(?P<id>)’ で定義されたあらゆるシンボリックグループ名をグループ番号
     へ写像する辞書です。シンボリックグループがパターン中で全く使われて
     いなければ、この辞書は空です。

 -- の属性: Pattern.pattern

     パターンオブジェクトがコンパイルされた元のパターン文字列です。

バージョン 3.7 で変更: *note copy.copy(): 4fd. および *note
copy.deepcopy(): b3c. をサポートするようになりました。コンパイル済み正規
表現オブジェクトはアトミックであると見なされます。


File: python.info,  Node: マッチオブジェクト,  Next: 正規表現の例,  Prev: 正規表現オブジェクト,  Up: re --- 正規表現操作

5.6.2.7 マッチオブジェクト
..........................

マッチオブジェクトのブール値は常に ‘True’ です。 *note match(): 225a. お
よび *note search(): 225b. はマッチがないとき ‘None’ を返すので、マッチ
があるか単純な ‘if’ 文で判定できます。

     match = re.search(pattern, string)
     if match:
         process(match)

 -- クラス: re.Match

     Match object returned by successful ‘match’es and ‘search’es.

     バージョン 3.9 で変更: *note re.Match: c96. supports ‘[]’ to
     indicate a Unicode (str) or bytes match.  See *note
     ジェネリックエイリアス型: 67e.

 -- メソッド: Match.expand (template)

     Return the string obtained by doing backslash substitution on the
     template string 'template', as done by the *note sub(): 2268.
     method.  Escapes such as ‘\n’ are converted to the appropriate
     characters, and numeric backreferences (‘\1’, ‘\2’) and named
     backreferences (‘\g<1>’, ‘\g<name>’) are replaced by the contents
     of the corresponding group.  The backreference ‘\g<0>’ will be
     replaced by the entire match.

     バージョン 3.5 で変更: マッチしなかったグループは空文字列に置き換え
     られます。

 -- メソッド: Match.group ([group1, ...])

     このマッチの 1 つ以上のサブグループを返します。引数が 1 つなら結果
     は 1 つの文字列です。複数の引数があれば、結果は引数ごとに 1 項目の
     タプルです。引数がなければ、 'group1' はデフォルトで 0 (マッチ全体
     が返される) です。 'groupN' 引数が 0 なら、対応する返り値はマッチし
     た文字列全体です。1 以上 99 以下なら、丸括弧による対応するグループ
     にマッチする文字列です。グループ番号が負であるかパターン中で定義さ
     れたグループの数より大きければ、 *note IndexError: 14de. 例外が送出
     されます。あるグループがパターンのマッチしなかった部分に含まれてい
     るなら、対応する結果は ‘None’ です。あるグループがパターンの複数回
     マッチした部分に含まれているなら、最後のマッチが返されます。

          >>> m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist")
          >>> m.group(0)       # The entire match
          'Isaac Newton'
          >>> m.group(1)       # The first parenthesized subgroup.
          'Isaac'
          >>> m.group(2)       # The second parenthesized subgroup.
          'Newton'
          >>> m.group(1, 2)    # Multiple arguments give us a tuple.
          ('Isaac', 'Newton')

     正規表現が ‘(?P<name>...)’ 構文を使うなら、 'groupN' 引数はグループ
     名でグループを識別する文字列でも構いません。文字列引数がパターン中
     でグループ名として使われていなければ、 *note IndexError: 14de. 例外
     が送出されます。

     やや複雑な例:

          >>> m = re.match(r"(?P<first_name>\w+) (?P<last_name>\w+)", "Malcolm Reynolds")
          >>> m.group('first_name')
          'Malcolm'
          >>> m.group('last_name')
          'Reynolds'

     名前付きグループはインデックスでも参照できます:

          >>> m.group(1)
          'Malcolm'
          >>> m.group(2)
          'Reynolds'

     あるグループが複数回マッチすると、その最後のマッチにのみアクセスで
     きます:

          >>> m = re.match(r"(..)+", "a1b2c3")  # Matches 3 times.
          >>> m.group(1)                        # Returns only the last match.
          'c3'

 -- メソッド: Match.__getitem__ (g)

     これは ‘m.group(g)’ と同等です。これでマッチの個別のグループに簡単
     にアクセスできます:

          >>> m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist")
          >>> m[0]       # The entire match
          'Isaac Newton'
          >>> m[1]       # The first parenthesized subgroup.
          'Isaac'
          >>> m[2]       # The second parenthesized subgroup.
          'Newton'

     Named groups are supported as well:

          >>> m = re.match(r"(?P<first_name>\w+) (?P<last_name>\w+)", "Isaac Newton")
          >>> m['first_name']
          'Isaac'
          >>> m['last_name']
          'Newton'

     Added in version 3.6.

 -- メソッド: Match.groups (default=None)

     このマッチの、1 からパターン中のグループ数まで、全てのサブグループ
     を含むタプルを返します。'default' 引数はマッチに関係しなかったグル
     ープに使われます。デフォルトでは ‘None’ です。

     例えば:

          >>> m = re.match(r"(\d+)\.(\d+)", "24.1632")
          >>> m.groups()
          ('24', '1632')

     少数位およびその後の全てをオプションにすると、全てのグループがマッ
     チに関係するとは限りません。そういったグループは 'default' 引数が与
     えられない限りデフォルトで ‘None’ になります。

          >>> m = re.match(r"(\d+)\.?(\d+)?", "24")
          >>> m.groups()      # Second group defaults to None.
          ('24', None)
          >>> m.groups('0')   # Now, the second group defaults to '0'.
          ('24', '0')

 -- メソッド: Match.groupdict (default=None)

     このマッチの、全ての '名前付き' サブグループを含む、サブグループ名
     をキーとする辞書を返します。 'default' 引数はマッチに関係しなかった
     グループに使われます。デフォルトは ‘None’ です。例えば:

          >>> m = re.match(r"(?P<first_name>\w+) (?P<last_name>\w+)", "Malcolm Reynolds")
          >>> m.groupdict()
          {'first_name': 'Malcolm', 'last_name': 'Reynolds'}

 -- メソッド: Match.start ([group])
 -- メソッド: Match.end ([group])

     'group' がマッチした部分文字列の先頭と末尾のインデックスを返します
     。 'group' はデフォルトで 0 (マッチした部分文字列全体という意味) で
     す。 'group' が存在してかつマッチには寄与していなかったなら ‘-1’ を
     返します。マッチオブジェクト 'm' と、マッチに寄与したグループ 'g' に
     対して、グループ 'g' がマッチした部分文字列 (‘m.group(g)’ と等価で
     す) は以下の通りです

          m.string[m.start(g):m.end(g)]

     'group' が空文字列にマッチしていたら ‘m.start(group)’ は
     ‘m.end(group)’ と等しくなることに注意して下さい。例えば、 ‘m =
     re.search('b(c?)', 'cba')’ とすると、 ‘m.start(0)’ は 1 で、
     ‘m.end(0)’ は 2 で、 ‘m.start(1)’ と ‘m.end(1)’ はともに 2 であり、
     ‘m.start(2)’ は *note IndexError: 14de. 例外を発生します。

     メールアドレスから 'remove_this' を取り除く例:

          >>> email = "tony@tiremove_thisger.net"
          >>> m = re.search("remove_this", email)
          >>> email[:m.start()] + email[m.end():]
          'tony@tiger.net'

 -- メソッド: Match.span ([group])

     マッチ 'm' について、2 タプル ‘(m.start(group), m.end(group))’ を返
     します。 'group' がマッチに寄与していなければ、これは ‘(-1, -1)’ で
     す。 'group' はデフォルトで 0 、マッチ全体です。

 -- の属性: Match.pos

     *note 正規表現オブジェクト: f53. の *note search(): 225b. や *note
     match(): 225a. に渡された 'pos' の値です。これは正規表現エンジンが
     マッチを探し始める位置の文字列のインデックスです。

 -- の属性: Match.endpos

     *note 正規表現オブジェクト: f53. の *note search(): 225b. や *note
     match(): 225a. に渡された 'endpos' の値です。これは正規表現エンジン
     がそれ以上は進まない文字列のインデックスです。

 -- の属性: Match.lastindex

     最後にマッチしたキャプチャグループの整数インデックスです。どのグル
     ープも全くマッチしなければ ‘None’ です。例えば、表現 ‘(a)b’ 、
     ‘((a)(b))’ や ‘((ab))’ が ‘'ab'’ に適用されると ‘lastindex == 1’ と
     なり、同じ文字列に ‘(a)(b)’ が適用されると ‘lastindex == 2’ となり
     ます。

 -- の属性: Match.lastgroup

     最後にマッチしたキャプチャグループの名前です。そのグループに名前が
     ないか、どのグループも全くマッチしていなければ ‘None’ です。

 -- の属性: Match.re

     このマッチインスタンスを生じさせた *note match(): 225a. または
     *note search(): 225b. メソッドの属する *note 正規表現オブジェクト:
     f53. です。

 -- の属性: Match.string

     *note match(): 225a. や *note search(): 225b. へ渡された文字列です
     。

バージョン 3.7 で変更: *note copy.copy(): 4fd. および *note
copy.deepcopy(): b3c. をサポートするようになりました。マッチオブジェクト
はアトミックであると見なされます。


File: python.info,  Node: 正規表現の例,  Prev: マッチオブジェクト,  Up: re --- 正規表現操作

5.6.2.8 正規表現の例
....................

* Menu:

* ペアの確認::
* scanf() をシミュレートする: scanf をシミュレートする.
* search() vs. match(): search vs match.
* 電話帳を作る::
* テキストの秘匿::
* 全ての副詞を見つける::
* 全ての副詞とその位置を見つける::
* Raw 文字列記法::
* トークナイザを書く::


File: python.info,  Node: ペアの確認,  Next: scanf をシミュレートする,  Up: 正規表現の例

5.6.2.9 ペアの確認
..................

この例では、マッチオブジェクトをより美しく表示するために、この補助関数を
使用します:

     def displaymatch(match):
         if match is None:
             return None
         return '<Match: %r, groups=%r>' % (match.group(), match.groups())

あなたがポーカープログラムを書いているとします。プレイヤーの手札は 5 文
字の文字列によって表され、それぞれの文字が 1 枚のカードを表します。 "a"
はエース、 "k" はキング、 "q" はクイーン、 "j" はジャック、 "t" は 10、
そして "2" から "9" はその数字のカードを表します。

与えられた文字列が有効な手札であるか見るには、以下のようにできます:

     >>> valid = re.compile(r"^[a2-9tjqk]{5}$")
     >>> displaymatch(valid.match("akt5q"))  # Valid.
     "<Match: 'akt5q', groups=()>"
     >>> displaymatch(valid.match("akt5e"))  # Invalid.
     >>> displaymatch(valid.match("akt"))    # Invalid.
     >>> displaymatch(valid.match("727ak"))  # Valid.
     "<Match: '727ak', groups=()>"

最後の手札、 ‘"727ak"’ 、はペア、すなわち同じ値の 2 枚のカードを含みます
。正規表現でこれにマッチするには、このように後方参照を使えます:

     >>> pair = re.compile(r".*(.).*\1")
     >>> displaymatch(pair.match("717ak"))     # Pair of 7s.
     "<Match: '717', groups=('7',)>"
     >>> displaymatch(pair.match("718ak"))     # No pairs.
     >>> displaymatch(pair.match("354aa"))     # Pair of aces.
     "<Match: '354aa', groups=('a',)>"

ペアになっているのがどのカードか調べるには、このようにマッチオブジェクト
の *note group(): 2270. メソッドを使えます:

     >>> pair = re.compile(r".*(.).*\1")
     >>> pair.match("717ak").group(1)
     '7'

     # Error because re.match() returns None, which doesn't have a group() method:
     >>> pair.match("718ak").group(1)
     Traceback (most recent call last):
       File "<pyshell#23>", line 1, in <module>
         re.match(r".*(.).*\1", "718ak").group(1)
     AttributeError: 'NoneType' object has no attribute 'group'

     >>> pair.match("354aa").group(1)
     'a'


File: python.info,  Node: scanf をシミュレートする,  Next: search vs match,  Prev: ペアの確認,  Up: 正規表現の例

5.6.2.10 scanf() をシミュレートする
...................................

Python には現在のところ、 ‘scanf()’ に相当するものがありません。正規表現
は一般的に、 ‘scanf()’ のフォーマット文字列より強力ですが、冗長でもあり
ます。以下の表に、 ‘scanf()’ のフォーマットトークンと正規表現のおおよそ
の対応付けを示します。

‘scanf()’ トークン                   正規表現
                                     
---------------------------------------------------------------------------------------
                                     
‘%c’                                 ‘.’
                                     
                                     
‘%5c’                                ‘.{5}’
                                     
                                     
‘%d’                                 ‘[-+]?\d+’
                                     
                                     
‘%e’, ‘%E’, ‘%f’, ‘%g’               ‘[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?’
                                     
                                     
‘%i’                                 ‘[-+]?(0[xX][\dA-Fa-f]+|0[0-7]*|\d+)’
                                     
                                     
‘%o’                                 ‘[-+]?[0-7]+’
                                     
                                     
‘%s’                                 ‘\S+’
                                     
                                     
‘%u’                                 ‘\d+’
                                     
                                     
‘%x’, ‘%X’                           ‘[-+]?(0[xX])?[\dA-Fa-f]+’
                                     

以下のような文字列からファイル名と数を抽出するには

     /usr/sbin/sendmail - 0 errors, 4 warnings

以下のように ‘scanf()’ フォーマットを使えます

     %s - %d errors, %d warnings

等価な正規表現はこうです

     (\S+) - (\d+) errors, (\d+) warnings


File: python.info,  Node: search vs match,  Next: 電話帳を作る,  Prev: scanf をシミュレートする,  Up: 正規表現の例

5.6.2.11 search() vs. match()
.............................

Python offers different primitive operations based on regular
expressions:

   + *note re.match(): 11fe. checks for a match only at the beginning of
     the string

   + *note re.search(): 11fd. checks for a match anywhere in the string
     (this is what Perl does by default)

   + *note re.fullmatch(): f52. checks for entire string to be a match

例えば:

     >>> re.match("c", "abcdef")    # No match
     >>> re.search("c", "abcdef")   # Match
     <re.Match object; span=(2, 3), match='c'>
     >>> re.fullmatch("p.*n", "python") # Match
     <re.Match object; span=(0, 6), match='python'>
     >>> re.fullmatch("r.*n", "python") # No match

‘'^'’ で始まる正規表現を *note search(): 11fd. で使って、マッチを文字列
の先頭でのみに制限できます:

     >>> re.match("c", "abcdef")    # No match
     >>> re.search("^c", "abcdef")  # No match
     >>> re.search("^a", "abcdef")  # Match
     <re.Match object; span=(0, 1), match='a'>

ただし、 *note MULTILINE: 2249. モードにおいて *note match(): 11fe. は文
字列の先頭でのみマッチし、 ‘'^'’ で始まる正規表現で *note search():
11fd. を使うと各行の先頭でマッチすることに注意してください。

     >>> re.match("X", "A\nB\nX", re.MULTILINE)  # No match
     >>> re.search("^X", "A\nB\nX", re.MULTILINE)  # Match
     <re.Match object; span=(4, 5), match='X'>


File: python.info,  Node: 電話帳を作る,  Next: テキストの秘匿,  Prev: search vs match,  Up: 正規表現の例

5.6.2.12 電話帳を作る
.....................

*note split(): 282. は渡されたパターンで文字列を分割してリストにします。
このメソッドは、テキストデータをデータ構造に変換して、読みやすくしたり、
以下の例で実演する電話帳作成のように Python で編集したりしやすくするのに
、非常に役に立ちます。

最初に、入力を示します。通常、これはファイルからの入力になるでしょう。こ
こでは、3重引用符の書式とします。

     >>> text = """Ross McFluff: 834.345.1254 155 Elm Street
     ...
     ... Ronald Heathmore: 892.345.3428 436 Finley Avenue
     ... Frank Burger: 925.541.7625 662 South Dogwood Way
     ...
     ...
     ... Heather Albrecht: 548.326.4584 919 Park Place"""

各項目は 1 つ以上の改行で区切られています。まずは文字列を変換して、空行
でない各行を項目とするリストにします:

     >>> entries = re.split("\n+", text)
     >>> entries
     ['Ross McFluff: 834.345.1254 155 Elm Street',
     'Ronald Heathmore: 892.345.3428 436 Finley Avenue',
     'Frank Burger: 925.541.7625 662 South Dogwood Way',
     'Heather Albrecht: 548.326.4584 919 Park Place']

そして各項目を、ファーストネーム、ラストネーム、電話番号、住所に分割して
リストにします。分割パターンである空白文字は住所にも含まれるので、 *note
split(): 282. の ‘maxsplit’ 引数を使います:

     >>> [re.split(":? ", entry, maxsplit=3) for entry in entries]
     [['Ross', 'McFluff', '834.345.1254', '155 Elm Street'],
     ['Ronald', 'Heathmore', '892.345.3428', '436 Finley Avenue'],
     ['Frank', 'Burger', '925.541.7625', '662 South Dogwood Way'],
     ['Heather', 'Albrecht', '548.326.4584', '919 Park Place']]

この ‘:?’ パターンはラストネームの次のコロンにマッチして、分割結果のリス
トに出てこないようにします。 ‘maxsplit’ を ‘4’ にすれば、家屋番号とスト
リート名を分割できます:

     >>> [re.split(":? ", entry, maxsplit=4) for entry in entries]
     [['Ross', 'McFluff', '834.345.1254', '155', 'Elm Street'],
     ['Ronald', 'Heathmore', '892.345.3428', '436', 'Finley Avenue'],
     ['Frank', 'Burger', '925.541.7625', '662', 'South Dogwood Way'],
     ['Heather', 'Albrecht', '548.326.4584', '919', 'Park Place']]


File: python.info,  Node: テキストの秘匿,  Next: 全ての副詞を見つける,  Prev: 電話帳を作る,  Up: 正規表現の例

5.6.2.13 テキストの秘匿
.......................

*note sub(): 283. は出現する各パターンを文字列で、または関数の返り値で置
き換えます。この例ではテキストを「秘匿」する関数と合わせて *note sub():
283. を使うところを実演します。具体的には、文中の各単語について、最初と
最後の文字を除く全ての文字をランダムに並び替えます:

     >>> def repl(m):
     ...     inner_word = list(m.group(2))
     ...     random.shuffle(inner_word)
     ...     return m.group(1) + "".join(inner_word) + m.group(3)
     ...
     >>> text = "Professor Abdolmalek, please report your absences promptly."
     >>> re.sub(r"(\w)(\w+)(\w)", repl, text)
     'Poefsrosr Aealmlobdk, pslaee reorpt your abnseces plmrptoy.'
     >>> re.sub(r"(\w)(\w+)(\w)", repl, text)
     'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.'


File: python.info,  Node: 全ての副詞を見つける,  Next: 全ての副詞とその位置を見つける,  Prev: テキストの秘匿,  Up: 正規表現の例

5.6.2.14 全ての副詞を見つける
.............................

*note search(): 11fd. は最初のパターンにのみマッチしますが、 *note
findall(): ff4. は出現する '全ての' パターンにマッチします。例えば、ライ
ターがあるテキストの全ての副詞を見つけたいなら、以下のように *note
findall(): ff4. を使えます:

     >>> text = "He was carefully disguised but captured quickly by police."
     >>> re.findall(r"\w+ly\b", text)
     ['carefully', 'quickly']


File: python.info,  Node: 全ての副詞とその位置を見つける,  Next: Raw 文字列記法,  Prev: 全ての副詞を見つける,  Up: 正規表現の例

5.6.2.15 全ての副詞とその位置を見つける
.......................................

パターンの全てのマッチについて、マッチしたテキスト以上の情報が必要なら、
文字列ではなく *note Match: c96. を返す *note finditer(): 14a3. が便利で
す。先の例に続いて、ライターがあるテキストの全ての副詞 'およびその位置'
を見つけたいなら、以下のように *note finditer(): 14a3. を使えます:

     >>> text = "He was carefully disguised but captured quickly by police."
     >>> for m in re.finditer(r"\w+ly\b", text):
     ...     print('%02d-%02d: %s' % (m.start(), m.end(), m.group(0)))
     07-16: carefully
     40-47: quickly


File: python.info,  Node: Raw 文字列記法,  Next: トークナイザを書く,  Prev: 全ての副詞とその位置を見つける,  Up: 正規表現の例

5.6.2.16 Raw 文字列記法
.......................

Raw 文字列記法 (‘r"text"’) で正規表現をまともに保てます。それがなければ
、正規表現中のバックスラッシュ (‘'\'’) を個々にバックスラッシュを前置し
てエスケープしなければなりません。例えば、以下の 2 行のコードは機能的に
等価です:

     >>> re.match(r"\W(.)\1\W", " ff ")
     <re.Match object; span=(0, 4), match=' ff '>
     >>> re.match("\\W(.)\\1\\W", " ff ")
     <re.Match object; span=(0, 4), match=' ff '>

リテラルのバックスラッシュにマッチさせたいなら、正規表現中ではエスケープ
する必要があります。Raw 文字列記法では、‘r"\\"’ になります。Raw 文字列記
法を用いないと、‘"\\\\"’ としなくてはならず、以下のコードは機能的に等価
です:

     >>> re.match(r"\\", r"\\")
     <re.Match object; span=(0, 1), match='\\'>
     >>> re.match("\\\\", r"\\")
     <re.Match object; span=(0, 1), match='\\'>


File: python.info,  Node: トークナイザを書く,  Prev: Raw 文字列記法,  Up: 正規表現の例

5.6.2.17 トークナイザを書く
...........................

トークナイザやスキャナ(1) は文字列を解析し、文字のグループにカテゴリ分け
します。これはコンパイラやインタプリタを書くうえで役立つ第一段階です。

テキストのカテゴリは正規表現で指定されます。この技法では、それらを一つの
マスター正規表現に結合し、マッチの連続についてループします:

     from typing import NamedTuple
     import re

     class Token(NamedTuple):
         type: str
         value: str
         line: int
         column: int

     def tokenize(code):
         keywords = {'IF', 'THEN', 'ENDIF', 'FOR', 'NEXT', 'GOSUB', 'RETURN'}
         token_specification = [
             ('NUMBER',   r'\d+(\.\d*)?'),  # Integer or decimal number
             ('ASSIGN',   r':='),           # Assignment operator
             ('END',      r';'),            # Statement terminator
             ('ID',       r'[A-Za-z]+'),    # Identifiers
             ('OP',       r'[+\-*/]'),      # Arithmetic operators
             ('NEWLINE',  r'\n'),           # Line endings
             ('SKIP',     r'[ \t]+'),       # Skip over spaces and tabs
             ('MISMATCH', r'.'),            # Any other character
         ]
         tok_regex = '|'.join('(?P<%s>%s)' % pair for pair in token_specification)
         line_num = 1
         line_start = 0
         for mo in re.finditer(tok_regex, code):
             kind = mo.lastgroup
             value = mo.group()
             column = mo.start() - line_start
             if kind == 'NUMBER':
                 value = float(value) if '.' in value else int(value)
             elif kind == 'ID' and value in keywords:
                 kind = value
             elif kind == 'NEWLINE':
                 line_start = mo.end()
                 line_num += 1
                 continue
             elif kind == 'SKIP':
                 continue
             elif kind == 'MISMATCH':
                 raise RuntimeError(f'{value!r} unexpected on line {line_num}')
             yield Token(kind, value, line_num, column)

     statements = '''
         IF quantity THEN
             total := total + price * quantity;
             tax := price * 0.05;
         ENDIF;
     '''

     for token in tokenize(statements):
         print(token)

このトークナイザは以下の出力を作成します:

     Token(type='IF', value='IF', line=2, column=4)
     Token(type='ID', value='quantity', line=2, column=7)
     Token(type='THEN', value='THEN', line=2, column=16)
     Token(type='ID', value='total', line=3, column=8)
     Token(type='ASSIGN', value=':=', line=3, column=14)
     Token(type='ID', value='total', line=3, column=17)
     Token(type='OP', value='+', line=3, column=23)
     Token(type='ID', value='price', line=3, column=25)
     Token(type='OP', value='*', line=3, column=31)
     Token(type='ID', value='quantity', line=3, column=33)
     Token(type='END', value=';', line=3, column=41)
     Token(type='ID', value='tax', line=4, column=8)
     Token(type='ASSIGN', value=':=', line=4, column=12)
     Token(type='ID', value='price', line=4, column=15)
     Token(type='OP', value='*', line=4, column=21)
     Token(type='NUMBER', value=0.05, line=4, column=23)
     Token(type='END', value=';', line=4, column=27)
     Token(type='ENDIF', value='ENDIF', line=5, column=4)
     Token(type='END', value=';', line=5, column=9)

(Frie09) Friedl, Jeffrey.  Mastering Regular Expressions.  3rd ed.,
O'Reilly Media, 2009.  当書の第三版ではもはや Python についてまったく取
り扱っていませんが、初版では良い正規表現を書くことを綿密に取り扱っていま
した。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Lexical_analysis


File: python.info,  Node: difflib --- 差分の計算の補助,  Next: textwrap --- テキストの折り返しと詰め込み,  Prev: re --- 正規表現操作,  Up: テキスト処理サービス

5.6.3 ‘difflib’ -- 差分の計算の補助
-----------------------------------

'ソースコード:' Lib/difflib.py(1)

__________________________________________________________________

このモジュールは、シーケンスを比較するためのクラスや関数を提供しています
。例えば、ファイルの差分を計算して、それを HTML や context diff, unified
diff などいろいろなフォーマットで出力するために、このモジュールを利用で
きます。ディレクトリやファイル群を比較するためには、 *note filecmp: 50.
モジュールも参照してください。

 -- クラス: difflib.SequenceMatcher

     柔軟性のあるクラスで、二つのシーケンスの要素が *note ハッシュ可能:
     5db. な型であれば、どの型の要素を含むシーケンスも比較可能です。基本
     的なアルゴリズムは、1980年代の後半に発表された Ratcliff と
     Obershelp による"ゲシュタルトパターンマッチング"と大げさに名づけら
     れたアルゴリズム以前から知られている、やや凝ったアルゴリズムです。
     その考え方は、"junk" 要素を含まない最も長い互いに隣接したマッチ列を
     探すことです。ここで、 "junk" 要素とは、空行や空白などの、意味を持
     たない要素のことです。 (junk を処理するのは、Ratcliff と Obershelp
     のアルゴリズムに追加された拡張です。)この考え方は、マッチ列の左右に
     隣接するシーケンスの断片に対して再帰的にあてはめられます。この方法
     では編集を最小にするシーケンスは生まれませんが、人間の目からみて「
     正しい感じ」にマッチする傾向があります。

     '実行時間:' 基本的な Ratcliff-Obershelp アルゴリズムは、最悪の場合
     3乗、期待値で2乗となります。 *note SequenceMatcher: fe4. オブジェク
     トでは、最悪のケースで2乗、期待値は比較されるシーケンス中に共通に現
     れる要素数に非常にややこしく依存しています。最良の場合は線形時間に
     なります。

     '自動 junk ヒューリスティック:' *note SequenceMatcher: fe4. は、シ
     ーケンスの特定の要素を自動的に junk として扱うヒューリスティックを
     サポートしています。このヒューリスティックは、各個要素がシーケンス
     内に何回現れるかを数えます。ある要素の重複数が (最初のものは除いて)
     合計でシーケンスの 1% 以上になり、そのシーケンスが 200 要素以上なら
     、その要素は "popular" であるものとしてマークされ、シーケンスのマッ
     チングの目的からは junk として扱われます。このヒューリスティックは
     、 *note SequenceMatcher: fe4. の作成時に ‘autojunk’ パラメタを
     ‘False’ に設定することで無効化できます。

     バージョン 3.2 で変更: Added the 'autojunk' parameter.

 -- クラス: difflib.Differ

     テキスト行からなるシーケンスを比較するクラスです。人が読むことので
     きる差分を作成します。 Differ クラスは *note SequenceMatcher: fe4.
     クラスを利用して、行からなるシーケンスを比較したり、(ほぼ)同一の行
     内の文字を比較したりします。

     *note Differ: 2289. クラスによる差分の各行は、2文字のコードで始まり
     ます:

     コード         意味
                    
     ---------------------------------------------------------------
                    
     ‘'- '’         行はシーケンス1にのみ存在する
                    
                    
     ‘'+ '’         行はシーケンス2にのみ存在する
                    
                    
     ‘' '’          行は両方のシーケンスで同一
                    
                    
     ‘'? '’         行は入力シーケンスのどちらにも存在しない
                    

     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.

 -- クラス: difflib.HtmlDiff

     このクラスは、二つのテキストを左右に並べて比較表示し、行間あるいは
     行内の変更点を強調表示するような HTML テーブル (またはテーブルの入
     った完全な HTML ファイル) を生成するために使います。テーブルは完全
     差分モード、コンテキスト差分モードのいずれでも生成できます。

     このクラスのコンストラクタは以下のようになっています:

      -- メソッド: __init__ (tabsize=8, wrapcolumn=None, linejunk=None,
               charjunk=IS_CHARACTER_JUNK)

          *note HtmlDiff: 228a. のインスタンスを初期化します。

          'tabsize' はオプションのキーワード引数で、タブストップ幅を指定
          します。デフォルトは ‘8’ です。

          'wrapcolumn' はオプションのキーワード引数で、テキストを折り返
          すカラム幅を指定します。デフォルトは ‘None’ で折り返しを行いま
          せん。

          'linejunk' および 'charjunk' はオプションのキーワード引数で、
          *note ndiff(): 228c. (*note HtmlDiff: 228a. はこの関数を使って
          左右のテキストの差分を HTML で生成します) に渡されます。それぞ
          れの引数のデフォルト値および説明は *note ndiff(): 228c. のドキ
          ュメントを参照してください。

     以下のメソッドが public になっています:

      -- メソッド: make_file (fromlines, tolines, fromdesc='',
               todesc='', context=False, numlines=5, *, charset='utf-8')

          'fromlines' と 'tolines' (いずれも文字列のリスト) を比較し、行
          間または行内の変更点が強調表示された行差分の入った表を持つ完全
          な HTML ファイルを文字列で返します。

          'fromdesc' および 'todesc' はオプションのキーワード引数で、差
          分表示テーブルにおけるそれぞれ差分元、差分先ファイルのカラムの
          ヘッダになる文字列を指定します (いずれもデフォルト値は空文字列
          です)。

          'context' および 'numlines' はともにオプションのキーワード引数
          です。'context' を ‘True’ にするとコンテキスト差分を表示し、デ
          フォルトの ‘False’ にすると完全なファイル差分を表示します。
          'numlines' のデフォルト値は ‘5’ で、'context' が ‘True’ の場合
          、'numlines' は強調部分の前後にあるコンテキスト行の数を制御し
          ます。'context' が ‘False’ の場合、'numlines' は "next" と書か
          れたハイパーリンクをたどった時に到達する場所が次の変更部分より
          何行前にあるかを制御します (値をゼロにした場合、"next" ハイパ
          ーリンクを辿ると変更部分の強調表示がブラウザの最上部に表示され
          るようになります)。

               注釈: 'fromdesc' と 'todesc' はエスケープされていない
               HTMLとして解釈されます。信頼できないソースからの入力を受
               け取る際には適切にエスケープされるべきです。

          バージョン 3.5 で変更: 'charset' キーワード専用引数が追加され
          ました。HTML 文書のデフォルトの文字集合が ‘'ISO-8859-1'’ から
          ‘'utf-8'’ に変更されました。

      -- メソッド: make_table (fromlines, tolines, fromdesc='',
               todesc='', context=False, numlines=5)

          'fromlines' と 'tolines' (いずれも文字列のリスト) を比較し、行
          間または行内の変更点が強調表示された行差分の入った完全な HTML
          テーブルを文字列で返します。

          このメソッドの引数は、 *note make_file(): dbc. メソッドの引数
          と同じです。

 -- の関数: difflib.context_diff (a, b, fromfile='', tofile='',
          fromfiledate='', tofiledate='', n=3, lineterm='\n')

     'a' と 'b' (文字列のリスト) を比較し、差分 (差分形式の行を生成する
     *note ジェネレータ: 1035.) を、 context diff のフォーマット(以下「
     コンテキスト形式」)で返します。

     コンテキスト形式は、変更があった行に前後数行を加えてある、コンパク
     トな表現方法です。変更箇所は、変更前/変更後に分けて表します。コンテ
     キスト (変更箇所前後の行) の行数は 'n' で指定し、デフォルト値は 3 で
     す。

     デフォルトで、 diff 制御行 (‘***’ や ‘---’ を含む行) は改行付きで生
     成されます。 *note io.IOBase.readlines(): 228f. で作られた入力が
     *note io.IOBase.writelines(): 2290. で扱うのに適した diff になるの
     で (なぜなら入力と出力の両方が改行付きのため) 、これは有用です。

     行末に改行文字を持たない入力に対しては、出力でも改行文字を付加しな
     いように 'lineterm' 引数に ‘""’ を渡してください。

     コンテキスト形式は、通常、ヘッダにファイル名と変更時刻を持っていま
     す。この情報は、文字列 'fromfile', 'tofile', 'fromfiledate',
     'tofiledate' で指定できます。変更時刻の書式は、通常、ISO 8601 フォ
     ーマットで表されます。指定しなかった場合のデフォルト値は、空文字列
     です。

          >>> import sys
          >>> from difflib import *
          >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n']
          >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n']
          >>> sys.stdout.writelines(context_diff(s1, s2, fromfile='before.py',
          ...                        tofile='after.py'))
          *** before.py
          --- after.py
          ***************
          *** 1,4 ****
          ! bacon
          ! eggs
          ! ham
            guido
          --- 1,4 ----
          ! python
          ! eggy
          ! hamster
            guido

     より詳細な例は、 *note difflib のコマンドラインインターフェース:
     2291. を参照してください。

 -- の関数: difflib.get_close_matches (word, possibilities, n=3,
          cutoff=0.6)

     「十分」なマッチの上位のリストを返します。'word' はマッチさせたいシ
     ーケンス (大概は文字列) です。'possibilities' は 'word' にマッチさ
     せるシーケンスのリスト (大概は文字列のリスト) です。

     オプションの引数 'n' (デフォルトでは ‘3’)はメソッドの返すマッチの最
     大数です。'n' は ‘0’ より大きくなければなりません。

     オプションの引数 'cutoff' (デフォルトでは ‘0.6’)は、区間 [0, 1] に
     入る小数の値です。'word' との一致率がそれ未満の 'possibilities' の
     要素は無視されます。

     'possibilities' の要素でマッチした上位(多くても 'n' 個)は、類似度の
     スコアに応じて(一番似たものを先頭に)ソートされたリストとして返され
     ます。

          >>> get_close_matches('appel', ['ape', 'apple', 'peach', 'puppy'])
          ['apple', 'ape']
          >>> import keyword
          >>> get_close_matches('wheel', keyword.kwlist)
          ['while']
          >>> get_close_matches('pineapple', keyword.kwlist)
          []
          >>> get_close_matches('accept', keyword.kwlist)
          ['except']

 -- の関数: difflib.ndiff (a, b, linejunk=None,
          charjunk=IS_CHARACTER_JUNK)

     'a' と 'b' (文字列のリスト) を比較し、差分 (差分形式の行を生成する
     *note ジェネレータ: 1035.) を、 *note Differ: 2289. のスタイルで返
     します。

     オプションのキーワード引数 'linejunk' と 'charjunk' には、フィルタ
     関数 (または ‘None’) を渡します。

     'linejunk': 文字列型の引数 1 つを受け取る関数です。文字列が junk の
     場合は真を、そうでない場合は偽を返します。デフォルトでは ‘None’ で
     す。モジュールレべルの関数 *note IS_LINE_JUNK(): 2293. は、高々 1 つ
     のシャープ記号(‘'#'’)を除いて可視の文字を含まない行をフィルタリング
     するものです。しかし、下層にある *note SequenceMatcher: fe4. クラス
     が、どの行が雑音となるほど頻繁に登場するかを動的に分析します。この
     クラスによる分析は、この関数を使用するよりも通常うまく動作します。

     'charjunk': 文字 (長さ1の文字列) を受け取る関数です。文字列が junk
     の場合は真を、そうでない場合は偽を返します。デフォルトでは、モジュ
     ールレべルの関数 *note IS_CHARACTER_JUNK(): 2294. であり、これは空
     白文字類 (空白またはタブ、改行文字をこれに含めてはいけません) をフ
     ィルタして排除します。

          >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
          ...              'ore\ntree\nemu\n'.splitlines(keepends=True))
          >>> print(''.join(diff), end="")
          - one
          ?  ^
          + ore
          ?  ^
          - two
          - three
          ?  -
          + tree
          + emu

 -- の関数: difflib.restore (sequence, which)

     差分を生成した元の二つのシーケンスのうち一つを返します。

     *note Differ.compare(): 2296. または *note ndiff(): 228c. によって
     生成された 'sequence' を与えられると、行頭のプレフィクスを取りのぞ
     いてファイル 1 または 2 (引数 'which' で指定される) に由来する行を
     復元します。

     例:

          >>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
          ...              'ore\ntree\nemu\n'.splitlines(keepends=True))
          >>> diff = list(diff) # materialize the generated delta into a list
          >>> print(''.join(restore(diff, 1)), end="")
          one
          two
          three
          >>> print(''.join(restore(diff, 2)), end="")
          ore
          tree
          emu

 -- の関数: difflib.unified_diff (a, b, fromfile='', tofile='',
          fromfiledate='', tofiledate='', n=3, lineterm='\n')

     'a' と 'b' (文字列のリスト) を比較し、差分 (差分形式の行を生成する
     *note ジェネレータ: 1035.) を、 unified diff フォーマット(以下「ユ
     ニファイド形式」)で返します。

     ユニファイド形式は変更があった行にコンテキストとなる前後数行を加え
     た、コンパクトな表現方法です。変更箇所は (変更前/変更後を分離したブ
     ロックではなく) インラインスタイルで表されます。コンテキストの行数
     は、'n' で指定し、デフォルト値は 3 です。

     デフォルトで、 diff 制御行 (‘---’, ‘+++’, ‘@@’ を含む行) は改行付き
     で生成されます。 *note io.IOBase.readlines(): 228f. で作られた入力
     が *note io.IOBase.writelines(): 2290. で扱うのに適した diff になる
     ので (なぜなら入力と出力の両方が改行付きのため) 、これは有用です。

     行末に改行文字を持たない入力に対しては、出力でも改行文字を付加しな
     いように 'lineterm' 引数に ‘""’ を渡してください。

     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', 'tofile', 'fromfiledate', and 'tofiledate'.
     The modification times are normally expressed in the ISO 8601
     format.  If not specified, the strings default to blanks.

          >>> s1 = ['bacon\n', 'eggs\n', 'ham\n', 'guido\n']
          >>> s2 = ['python\n', 'eggy\n', 'hamster\n', 'guido\n']
          >>> sys.stdout.writelines(unified_diff(s1, s2, fromfile='before.py', tofile='after.py'))
          --- before.py
          +++ after.py
          @@ -1,4 +1,4 @@
          -bacon
          -eggs
          -ham
          +python
          +eggy
          +hamster
           guido

     より詳細な例は、 *note difflib のコマンドラインインターフェース:
     2291. を参照してください。

 -- の関数: difflib.diff_bytes (dfunc, a, b, fromfile=b'', tofile=b'',
          fromfiledate=b'', tofiledate=b'', n=3, lineterm=b'\n')

     'dfunc' を使用して 'a' と 'b' (bytes オブジェクトのリスト) を比較し
     て、差分形式の行 (これも bytes オブジェクトです) を*dfunc* の戻り値
     の形式で返します。'dfunc' は、呼び出し可能である必要があります。一
     般に、これは *note unified_diff(): 2297. または *note
     context_diff(): 228e. です。

     未知のエンコーディングまたは一貫性のないエンコーディングのデータ同
     士を比較できます。'n' 以外のすべての入力は、bytes オブジェクトであ
     る必要があります。'n' 以外のすべての入力を損失なく str に変換して、
     ‘dfunc(a, b, fromfile, tofile, fromfiledate, tofiledate, n,
     lineterm)’ を呼び出すことにより動作します。'dfunc' の出力は、bytes
     型に変換されます。これにより、受け取る差分形式の行のエンコーディン
     グは、'a' と 'b' の未知または一貫性のないエンコーディングと同一にな
     ります。

     Added in version 3.5.

 -- の関数: difflib.IS_LINE_JUNK (line)

     無視できる行のとき ‘True’ を返します。行 'line' は空白、または
     ‘'#'’ ひとつのときに無視できます。それ以外のときには無視できません
     。古いバージョンでは *note ndiff(): 228c. の引数 'linejunk' にデフ
     ォルトで使用されました。

 -- の関数: difflib.IS_CHARACTER_JUNK (ch)

     無視できる文字のとき ‘True’ を返します。文字 'ch' が空白、またはタ
     ブ文字のときには無視できます。それ以外の時には無視できません。
     *note ndiff(): 228c. の引数 'charjunk' としてデフォルトで使用されま
     す。

参考
....

Pattern Matching: The Gestalt Approach(2)

     John W. Ratcliff と D. E. Metzener による類似のアルゴリズムに関する
     議論。Dr.  Dobb's Journal(3) 1988年7月号掲載。

* Menu:

* SequenceMatcherオブジェクト::
* SequenceMatcher の例::
* Differ オブジェクト::
* Differ の例::
* difflib のコマンドラインインターフェース::
* ndiff example::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/difflib.py

   (2) 
https://www.drdobbs.com/database/pattern-matching-the-gestalt-approach/184407970

   (3) https://www.drdobbs.com/


File: python.info,  Node: SequenceMatcherオブジェクト,  Next: SequenceMatcher の例,  Up: difflib --- 差分の計算の補助

5.6.3.1 SequenceMatcherオブジェクト
...................................

*note SequenceMatcher: fe4. クラスには、以下のようなコンストラクタがあり
ます:

 -- クラス: difflib.SequenceMatcher (isjunk=None, a='', b='',
          autojunk=True)

     オプションの引数 'isjunk' は、‘None’ (デフォルトの値です) にするか
     、単一の引数をとる関数でなければなりません。後者の場合、関数はシー
     ケンスの要素を受け取り、要素が junk であり、無視すべきである場合に
     限り真を返すようにしなければなりません。'isjunk' に ‘None’ を渡すと
     、‘lambda x: False’ を渡したのと同じになります; すなわち、いかなる
     要素も無視しなくなります。例えば以下のような引数を渡すと:

          lambda x: x in " \t"

     空白とタブ文字を無視して文字のシーケンスを比較します。

     オプションの引数 'a' と 'b' は、比較される文字列で、デフォルトでは
     空の文字列です。両方のシーケンスの要素は、 *note ハッシュ可能: 5db.
     である必要があります。

     オプションの引数 'autojunk' は、自動 junk ヒューリスティックを無効
     にするために使えます。

     バージョン 3.2 で変更: Added the 'autojunk' parameter.

     SequenceMatcher オブジェクトは3つのデータ属性を持っています:
     'bjunk' は、 'isjunk' が ‘True’ であるような 'b' の要素の集合です;
     'bpopular' は、 (無効でなければ) ヒューリスティックによって popular
     であると考えられる非ジャンク要素の集合です; 'b2j' は、 'b' の残りの
     要素をそれらが生じる位置のリストに写像する dict です。この 3 つは
     *note set_seqs(): 229a. または *note set_seq2(): 229b. で 'b' がリ
     セットされる場合は常にリセットされます。

     Added in version 3.2: 'bjunk' および 'bpopular' 属性。

     *note SequenceMatcher: fe4. オブジェクトは以下のメソッドを持ちます:

      -- メソッド: set_seqs (a, b)

          比較される2つの文字列を設定します。

     *note SequenceMatcher: fe4. オブジェクトは、2つ目のシーケンスについ
     ての詳細な情報を計算し、キャッシュします。 1つのシーケンスをいくつ
     ものシーケンスと比較する場合、まず *note set_seq2(): 229b. を使って
     文字列を設定しておき、別の文字列を1つずつ比較するために、繰り返し
     *note set_seq1(): 229c. を呼び出します。

      -- メソッド: set_seq1 (a)

          比較を行う1つ目のシーケンスを設定します。比較される2つ目のシー
          ケンスは変更されません。

      -- メソッド: set_seq2 (b)

          比較を行う2つ目のシーケンスを設定します。比較される1つ目のシー
          ケンスは変更されません。

      -- メソッド: find_longest_match (alo=0, ahi=None, blo=0, bhi=None)

          ‘a[alo:ahi]’ と ‘b[blo:bhi]’ の中から、最長のマッチ列を探しま
          す。

          'isjunk' が省略されたか ‘None’ の時、 *note
          find_longest_match(): 18c9. は ‘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' 内で最初に始まるものを
          返します。

               >>> s = SequenceMatcher(None, " abcd", "abcd abcd")
               >>> s.find_longest_match(0, 5, 0, 9)
               Match(a=0, b=4, size=5)

          引数 'isjunk' が与えられている場合、上記の通り、はじめに最長の
          マッチ列を判定します。ブロック内に junk 要素が見当たらないよう
          な追加条件の際はこれに該当しません。次にそのマッチ列を、その両
          側の junk 要素にマッチするよう、できる限り広げていきます。その
          ため結果となる列は、探している列のたまたま直前にあった同一の
          junk 以外の junk にはマッチしません。

          以下は前と同じサンプルですが、空白を junk とみなしています。こ
          れは ‘' abcd'’ が2つ目の列の末尾にある ‘' abcd'’ にマッチしな
          いようにしています。代わりに ‘'abcd'’ にはマッチします。そして
          2つ目の文字列中、一番左の ‘'abcd'’ にマッチします:

               >>> s = SequenceMatcher(lambda x: x==" ", " abcd", "abcd abcd")
               >>> s.find_longest_match(0, 5, 0, 9)
               Match(a=1, b=0, size=4)

          どんな列にもマッチしない時は、‘(alo, blo, 0)’ を返します。

          このメソッドは *note named tuple: 61a. ‘Match(a, b, size)’ を
          返します。

          バージョン 3.9 で変更: デフォルト引数が追加されました。

      -- メソッド: get_matching_blocks ()

          マッチした互いに重複の無いシーケンスを表す、3つ組の値のリスト
          を返します。 それぞれの値は ‘(i, j, n)’ という形式で表され、
          ‘a[i:i+n] == b[j:j+n]’ という関係を意味します。3つの値は 'i' と
          'j' の間で単調に増加します。

          最後の3つ組はダミーで、‘(len(a), len(b), 0)’ という値を持ちま
          す。これは ‘n == 0’ である唯一のタプルです。もし ‘(i, j, n)’ と
          ‘(i', j', n')’ がリストで並んでいる3つ組で、2つ目が最後の3つ組
          でなければ、‘i+n < i'’ または ‘j+n < j'’ です。言い換えると並
          んでいる3つ組は常に隣接していない同じブロックを表しています。

               >>> s = SequenceMatcher(None, "abxcd", "abcd")
               >>> s.get_matching_blocks()
               [Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)]

      -- メソッド: get_opcodes ()

          'a' を 'b' にするための方法を記述する5つのタプルを返します。そ
          れぞれのタプルは ‘(tag, i1, i2, j1, j2)’ という形式であらわさ
          れます。最初のタプルは ‘i1 == j1 == 0’ であり、'i1' はその前に
          あるタプルの 'i2' と同じ値です。同様に 'j1' は前の 'j2' と同じ
          値になります。

          'tag' の値は文字列であり、次のような意味です:

          値                  意味
                              
          ----------------------------------------------------------------------
                              
          ‘'replace'’         ‘a[i1:i2]’ は ‘b[j1:j2]’ に置き換えられる。
                              
                              
          ‘'delete'’          ‘a[i1:i2]’ は削除される。この時、‘j1 == j2’ で
                              ある。
                              
                              
          ‘'insert'’          ‘b[j1:j2]’ が ‘a[i1:i1]’ に挿入される。この時
                              ‘i1 == i2’ である。
                              
                              
          ‘'equal'’           ‘a[i1:i2] == b[j1:j2]’ (サブシーケンスは等しい
                              ).
                              

          例えば:

               >>> a = "qabxcd"
               >>> b = "abycdf"
               >>> s = SequenceMatcher(None, a, b)
               >>> for tag, i1, i2, j1, j2 in s.get_opcodes():
               ...     print('{:7}   a[{}:{}] --> b[{}:{}] {!r:>8} --> {!r}'.format(
               ...         tag, i1, i2, j1, j2, a[i1:i2], b[j1:j2]))
               delete    a[0:1] --> b[0:0]      'q' --> ''
               equal     a[1:3] --> b[0:2]     'ab' --> 'ab'
               replace   a[3:4] --> b[2:3]      'x' --> 'y'
               equal     a[4:6] --> b[3:5]     'cd' --> 'cd'
               insert    a[6:6] --> b[5:6]       '' --> 'f'

      -- メソッド: get_grouped_opcodes (n=3)

          最大 'n' 行までのコンテキストを含むグループを生成するような、
          *note ジェネレータ: 1035. を返します。

          このメソッドは、 *note get_opcodes(): 229e. で返されるグループ
          の中から、似たような差異のかたまりに分け、間に挟まっている変更
          の無い部分を省きます。

          グループは *note get_opcodes(): 229e. と同じ書式で返されます。

      -- メソッド: ratio ()

          [0, 1] の範囲の浮動小数点数で、シーケンスの類似度を測る値を返
          します。

          T が2つのシーケンスの要素数の総計だと仮定し、M をマッチした数
          とすると、この値は 2.0*M / T であらわされます。もしシーケンス
          がまったく同じ場合、値は ‘1.0’ となり、まったく異なる場合には
          ‘0.0’ となります。

          このメソッドは *note get_matching_blocks(): 229d. または *note
          get_opcodes(): 229e. がまだ呼び出されていない場合には非常にコ
          ストが高いです。この場合、上限を素早く計算するために、 *note
          quick_ratio(): 22a1. もしくは *note real_quick_ratio(): 22a2.
          を最初に試してみる方がいいかもしれません。

               注釈: 注意: *note ratio(): 22a0. の呼び出しの結果は引数の
               順序に依存します。例えば次の通りです:

                    >>> SequenceMatcher(None, 'tide', 'diet').ratio()
                    0.25
                    >>> SequenceMatcher(None, 'diet', 'tide').ratio()
                    0.5

      -- メソッド: quick_ratio ()

          *note ratio(): 22a0. の上界を、より高速に計算します。

      -- メソッド: real_quick_ratio ()

          *note ratio(): 22a0. の上界を、非常に高速に計算します。

The three methods that return the ratio of matching to total characters
can give different results due to differing levels of approximation,
although *note quick_ratio(): 22a1. and *note real_quick_ratio(): 22a2.
are always at least as large as *note ratio(): 22a0.:

     >>> s = SequenceMatcher(None, "abcd", "bcde")
     >>> s.ratio()
     0.75
     >>> s.quick_ratio()
     0.75
     >>> s.real_quick_ratio()
     1.0


File: python.info,  Node: SequenceMatcher の例,  Next: Differ オブジェクト,  Prev: SequenceMatcherオブジェクト,  Up: difflib --- 差分の計算の補助

5.6.3.2 SequenceMatcher の例
............................

この例は2つの文字列を比較します。空白を "junk" とします:

     >>> s = SequenceMatcher(lambda x: x == " ",
     ...                     "private Thread currentThread;",
     ...                     "private volatile Thread currentThread;")

*note ratio(): 22a0. returns a float in [0, 1], measuring the similarity
of the sequences.  As a rule of thumb, a *note ratio(): 22a0. value over
0.6 means the sequences are close matches:

     >>> print(round(s.ratio(), 3))
     0.866

If you're only interested in where the sequences match, *note
get_matching_blocks(): 229d. is handy:

     >>> for block in s.get_matching_blocks():
     ...     print("a[%d] and b[%d] match for %d elements" % block)
     a[0] and b[0] match for 8 elements
     a[8] and b[17] match for 21 elements
     a[29] and b[38] match for 0 elements

Note that the last tuple returned by *note get_matching_blocks(): 229d.
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’.

If you want to know how to change the first sequence into the second,
use *note get_opcodes(): 229e.:

     >>> for opcode in s.get_opcodes():
     ...     print("%6s a[%d:%d] b[%d:%d]" % opcode)
      equal a[0:8] b[0:8]
     insert a[8:8] b[8:17]
      equal a[8:29] b[17:38]

参考
....

   * *note SequenceMatcher: fe4. を使った、シンプルで使えるコードを知る
     には、このモジュールの関数 *note get_close_matches(): 2292. を参照
     してください。

   * Simple version control recipe(1) for a small application built with
     *note SequenceMatcher: fe4.

   ---------- Footnotes ----------

   (1) 
https://code.activestate.com/recipes/576729-simple-version-control/


File: python.info,  Node: Differ オブジェクト,  Next: Differ の例,  Prev: SequenceMatcher の例,  Up: difflib --- 差分の計算の補助

5.6.3.3 Differ オブジェクト
...........................

*note Differ: 2289. オブジェクトによって生成された差分が '最小' であるな
どとは言いません。むしろ、最小の差分はしばしば直観に反しています。その理
由は、どこでもできるとなれば一致を見いだしてしまうからで、ときには思いが
けなく100ページも離れたマッチになってしまうのです。一致点を互いに隣接し
たマッチに制限することで、場合によって長めの差分を出力するというコストを
掛けることにはなっても、ある種の局所性を保つことができるのです。

*note Differ: 2289. は、以下のようなコンストラクタを持ちます:

 -- クラス: difflib.Differ (linejunk=None, charjunk=None)

     オプションのキーワードパラメータ 'linejunk' と 'charjunk' は、フィ
     ルタ関数を渡します (使わないときは ‘None’):

     'linejunk': ひとつの文字列引数を受け取る関数です。文字列が junk の
     ときに真を返します。デフォルトでは、‘None’ であり、どんな行であって
     も junk とは見なされません。

     'charjunk': この関数は文字(長さ1の文字列)を引数として受け取り、文字
     が junk であるときに真を返します。デフォルトは ‘None’ であり、どん
     な文字も junk とは見なされません。

     これらの junk フィルター関数により、差分を発見するマッチングが高速
     化し、差分の行や文字が無視されることがなくなります。説明については
     、 *note find_longest_match(): 18c9. メソッドの 'isjunk' 引数の説明
     をご覧ください。

     *note Differ: 2289. オブジェクトは、以下の1つのメソッドを通して利用
     されます。（差分を生成します）:

      -- メソッド: compare (a, b)

          文字列からなる2つのシーケンスを比較し、差分（を表す文字列から
          なるシーケンス）を生成します。

          各シーケンスの要素は、改行で終わる独立した単一行からなる文字列
          でなければなりません。そのようなシーケンスは、ファイル風オブジ
          ェクトの *note readlines(): 228f. メソッドによって得ることがで
          きます。（得られる）差分は改行文字で終了する文字列のシーケンス
          として得られ、ファイル風オブジェクトの *note writelines():
          2290. メソッドによって出力できる形になっています。


File: python.info,  Node: Differ の例,  Next: difflib のコマンドラインインターフェース,  Prev: Differ オブジェクト,  Up: difflib --- 差分の計算の補助

5.6.3.4 Differ の例
...................

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 *note readlines(): 228f. method of
file-like objects):

     >>> text1 = '''  1. Beautiful is better than ugly.
     ...   2. Explicit is better than implicit.
     ...   3. Simple is better than complex.
     ...   4. Complex is better than complicated.
     ... '''.splitlines(keepends=True)
     >>> len(text1)
     4
     >>> text1[0][-1]
     '\n'
     >>> text2 = '''  1. Beautiful is better than ugly.
     ...   3.   Simple is better than complex.
     ...   4. Complicated is better than complex.
     ...   5. Flat is better than nested.
     ... '''.splitlines(keepends=True)

次に Differ オブジェクトをインスタンス化します:

     >>> d = Differ()

注意: *note Differ: 2289. オブジェクトをインスタンス化するとき、行 junk
と文字 junk をフィルタリングする関数を渡すことができます。詳細は *note
Differ(): 2289. コンストラクタを参照してください。

最後に、2つを比較します:

     >>> result = list(d.compare(text1, text2))

‘result’ は文字列のリストなので、pretty-printしてみましょう:

     >>> from pprint import pprint
     >>> pprint(result)
     ['    1. Beautiful is better than ugly.\n',
      '-   2. Explicit is better than implicit.\n',
      '-   3. Simple is better than complex.\n',
      '+   3.   Simple is better than complex.\n',
      '?     ++\n',
      '-   4. Complex is better than complicated.\n',
      '?            ^                     ---- ^\n',
      '+   4. Complicated is better than complex.\n',
      '?           ++++ ^                      ^\n',
      '+   5. Flat is better than nested.\n']

これは、複数行の文字列として、次のように出力されます:

     >>> import sys
     >>> sys.stdout.writelines(result)
         1. Beautiful is better than ugly.
     -   2. Explicit is better than implicit.
     -   3. Simple is better than complex.
     +   3.   Simple is better than complex.
     ?     ++
     -   4. Complex is better than complicated.
     ?            ^                     ---- ^
     +   4. Complicated is better than complex.
     ?           ++++ ^                      ^
     +   5. Flat is better than nested.


File: python.info,  Node: difflib のコマンドラインインターフェース,  Next: ndiff example,  Prev: Differ の例,  Up: difflib --- 差分の計算の補助

5.6.3.5 difflib のコマンドラインインターフェース
................................................

This example shows how to use difflib to create a ‘diff’-like utility.

     """ Command line interface to difflib.py providing diffs in four formats:

     * ndiff:    lists every line and highlights interline changes.
     * context:  highlights clusters of changes in a before/after format.
     * unified:  highlights clusters of changes in an inline format.
     * html:     generates side by side comparison with change highlights.

     """

     import sys, os, difflib, argparse
     from datetime import datetime, timezone

     def file_mtime(path):
         t = datetime.fromtimestamp(os.stat(path).st_mtime,
                                    timezone.utc)
         return t.astimezone().isoformat()

     def main():

         parser = argparse.ArgumentParser()
         parser.add_argument('-c', action='store_true', default=False,
                             help='Produce a context format diff (default)')
         parser.add_argument('-u', action='store_true', default=False,
                             help='Produce a unified format diff')
         parser.add_argument('-m', action='store_true', default=False,
                             help='Produce HTML side by side diff '
                                  '(can use -c and -l in conjunction)')
         parser.add_argument('-n', action='store_true', default=False,
                             help='Produce a ndiff format diff')
         parser.add_argument('-l', '--lines', type=int, default=3,
                             help='Set number of context lines (default 3)')
         parser.add_argument('fromfile')
         parser.add_argument('tofile')
         options = parser.parse_args()

         n = options.lines
         fromfile = options.fromfile
         tofile = options.tofile

         fromdate = file_mtime(fromfile)
         todate = file_mtime(tofile)
         with open(fromfile) as ff:
             fromlines = ff.readlines()
         with open(tofile) as tf:
             tolines = tf.readlines()

         if options.u:
             diff = difflib.unified_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)
         elif options.n:
             diff = difflib.ndiff(fromlines, tolines)
         elif options.m:
             diff = difflib.HtmlDiff().make_file(fromlines,tolines,fromfile,tofile,context=options.c,numlines=n)
         else:
             diff = difflib.context_diff(fromlines, tolines, fromfile, tofile, fromdate, todate, n=n)

         sys.stdout.writelines(diff)

     if __name__ == '__main__':
         main()


File: python.info,  Node: ndiff example,  Prev: difflib のコマンドラインインターフェース,  Up: difflib --- 差分の計算の補助

5.6.3.6 ndiff example
.....................

This example shows how to use *note difflib.ndiff(): 228c.

     """ndiff [-q] file1 file2
         or
     ndiff (-r1 | -r2) < ndiff_output > file1_or_file2

     Print a human-friendly file difference report to stdout.  Both inter-
     and intra-line differences are noted.  In the second form, recreate file1
     (-r1) or file2 (-r2) on stdout, from an ndiff report on stdin.

     In the first form, if -q ("quiet") is not specified, the first two lines
     of output are

     -: file1
     +: file2

     Each remaining line begins with a two-letter code:

         "- "    line unique to file1
         "+ "    line unique to file2
         "  "    line common to both files
         "? "    line not present in either input file

     Lines beginning with "? " attempt to guide the eye to intraline
     differences, and were not present in either input file.  These lines can be
     confusing if the source files contain tab characters.

     The first file can be recovered by retaining only lines that begin with
     "  " or "- ", and deleting those 2-character prefixes; use ndiff with -r1.

     The second file can be recovered similarly, but by retaining only "  " and
     "+ " lines; use ndiff with -r2; or, on Unix, the second file can be
     recovered by piping the output through

         sed -n '/^[+ ] /s/^..//p'
     """

     __version__ = 1, 7, 0

     import difflib, sys

     def fail(msg):
         out = sys.stderr.write
         out(msg + "\n\n")
         out(__doc__)
         return 0

     # open a file & return the file object; gripe and return 0 if it
     # couldn't be opened
     def fopen(fname):
         try:
             return open(fname)
         except IOError as detail:
             return fail("couldn't open " + fname + ": " + str(detail))

     # open two files & spray the diff to stdout; return false iff a problem
     def fcompare(f1name, f2name):
         f1 = fopen(f1name)
         f2 = fopen(f2name)
         if not f1 or not f2:
             return 0

         a = f1.readlines(); f1.close()
         b = f2.readlines(); f2.close()
         for line in difflib.ndiff(a, b):
             print(line, end=' ')

         return 1

     # crack args (sys.argv[1:] is normal) & compare;
     # return false iff a problem

     def main(args):
         import getopt
         try:
             opts, args = getopt.getopt(args, "qr:")
         except getopt.error as detail:
             return fail(str(detail))
         noisy = 1
         qseen = rseen = 0
         for opt, val in opts:
             if opt == "-q":
                 qseen = 1
                 noisy = 0
             elif opt == "-r":
                 rseen = 1
                 whichfile = val
         if qseen and rseen:
             return fail("can't specify both -q and -r")
         if rseen:
             if args:
                 return fail("no args allowed with -r option")
             if whichfile in ("1", "2"):
                 restore(whichfile)
                 return 1
             return fail("-r value must be 1 or 2")
         if len(args) != 2:
             return fail("need 2 filename args")
         f1name, f2name = args
         if noisy:
             print('-:', f1name)
             print('+:', f2name)
         return fcompare(f1name, f2name)

     # read ndiff output from stdin, and print file1 (which=='1') or
     # file2 (which=='2') to stdout

     def restore(which):
         restored = difflib.restore(sys.stdin.readlines(), which)
         sys.stdout.writelines(restored)

     if __name__ == '__main__':
         main(sys.argv[1:])


File: python.info,  Node: textwrap --- テキストの折り返しと詰め込み,  Next: unicodedata --- Unicode データベース,  Prev: difflib --- 差分の計算の補助,  Up: テキスト処理サービス

5.6.4 ‘textwrap’ -- テキストの折り返しと詰め込み
------------------------------------------------

'ソースコード:' Lib/textwrap.py(1)

__________________________________________________________________

*note textwrap: d5. モジュールは、実際の処理を行う *note TextWrapper:
f9a. とともに、いくつかの便利な関数を提供しています。1つか2つの文字列を
wrap あるいは fill するだけの場合は便利関数で十分ですが、多くの処理を行
う場合は効率のために *note TextWrapper: f9a. のインスタンスを使うべきで
しょう。

 -- の関数: textwrap.wrap (text, width=70, *, initial_indent='',
          subsequent_indent='', expand_tabs=True,
          replace_whitespace=True, fix_sentence_endings=False,
          break_long_words=True, drop_whitespace=True,
          break_on_hyphens=True, tabsize=8, max_lines=None,
          placeholder=' [...]')

     'text' (文字列)内の段落を一つだけ折り返しを行います。したがって、す
     べての行が高々 'width' 文字の長さになります。最後に改行が付かない出
     力行のリストを返します。

     オプションのキーワード引数は、以下で説明する *note TextWrapper:
     f9a. のインスタンス属性に対応しています。

     *note wrap(): 146c. の動作についての詳細は *note
     TextWrapper.wrap(): 22ad. メソッドを参照してください。

 -- の関数: textwrap.fill (text, width=70, *, initial_indent='',
          subsequent_indent='', expand_tabs=True,
          replace_whitespace=True, fix_sentence_endings=False,
          break_long_words=True, drop_whitespace=True,
          break_on_hyphens=True, tabsize=8, max_lines=None,
          placeholder=' [...]')

     'text' 内の段落を一つだけ折り返しを行い、折り返しが行われた段落を含
     む一つの文字列を返します。 *note fill(): 146b. はこれの省略表現です

          "\n".join(wrap(text, ...))

     特に、 *note fill(): 146b. は *note wrap(): 146c. とまったく同じ名
     前のキーワード引数を受け取ります。

 -- の関数: textwrap.shorten (text, width, *,
          fix_sentence_endings=False, break_long_words=True,
          break_on_hyphens=True, placeholder=' [...]')

     与えられた 'text' を折りたたみ、切り詰めて、与えられた 'width' に収
     まるようにします。

     最初に、'text' 内の空白が折りたたまれます (すべての空白を、1 文字の
     空白文字で置き換えます)。結果が 'width' 内に収まった場合、その結果
     が返されます。width に収まらない場合、残りの文字数と 'placeholder'
     との和が 'width' 内に収まるように、末尾から単語が切り捨てられます:

          >>> textwrap.shorten("Hello  world!", width=12)
          'Hello world!'
          >>> textwrap.shorten("Hello  world!", width=11)
          'Hello [...]'
          >>> textwrap.shorten("Hello world", width=10, placeholder="...")
          'Hello...'

     オプションのキーワード引数は、以下で説明する *note TextWrapper:
     f9a. インスタンスの属性に対応します。文字列が *note TextWrapper:
     f9a. の *note fill(): 146b. 関数に渡される前に、空白が折りたたまれ
     ます。そのため、*note tabsize: 22ae.、*note expand_tabs: 22af.、
     *note drop_whitespace: 22b0.、*note replace_whitespace: 22b1. の値
     を変更しても、意味がありません。

     Added in version 3.4.

 -- の関数: textwrap.dedent (text)

     'text' の各行に対し、共通して現れる先頭の空白を削除します。

     この関数は通常、三重引用符で囲われた文字列をスクリーン/その他の左端
     にそろえ、なおかつソースコード中ではインデントされた形式を損なわな
     いようにするために使われます。

     タブとスペースはともにホワイトスペースとして扱われますが、同じでは
     ないことに注意してください: ‘" hello"’ という行と ‘"\thello"’ は、
     同じ先頭の空白文字をもっていないとみなされます。

     空白文字しか含まない行は入力の際に無視され、出力の際に単一の改行文
     字に正規化されます。

     例えば:

          def test():
              # end first line with \ to avoid the empty line!
              s = '''\
              hello
                world
              '''
              print(repr(s))          # prints '    hello\n      world\n    '
              print(repr(dedent(s)))  # prints 'hello\n  world\n'

 -- の関数: textwrap.indent (text, prefix, predicate=None)

     'text' の中の選択された行の先頭に 'prefix' を追加します。

     行の分割は ‘text.splitlines(True)’ で行います。

     デフォルトでは、(改行文字を含む)空白文字だけの行を除いてすべての行
     に 'prefix' を追加します。

     例えば:

          >>> s = 'hello\n\n \nworld'
          >>> indent(s, '  ')
          '  hello\n\n \n  world'

     省略可能な 'predicate' 引数を使って、どの行をインデントするかを制御
     することができます。例えば、空行や空白文字のみの行にも 'prefix' を
     追加するのは簡単です:

          >>> print(indent(s, '+ ', lambda line: True))
          + hello
          +
          +
          + world

     Added in version 3.3.

*note wrap(): 146c.、*note fill(): 146b.、*note shorten(): f9d. は *note
TextWrapper: f9a. インスタンスを作成し、その一つのメソッドを呼び出すこと
で機能します。そのインスタンスは再利用されません。したがって、*note
wrap(): 146c. や *note fill(): 146b. を使用して多くのテキスト文字列を処
理するアプリケーションについては、独自の *note TextWrapper: f9a. オブジ
ェクトを作成する方が効率が良い方法でしょう。

テキストはなるべく空白か、ハイフンを含む語のハイフンの直後で折り返されま
す。 *note TextWrapper.break_long_words: 22b3. が偽に設定されていなけれ
ば、必要な場合に長い語が分解されます。

 -- クラス: textwrap.TextWrapper (**kwargs)

     *note TextWrapper: f9a. コンストラクタはたくさんのオプションのキー
     ワード引数を受け取ります。それぞれのキーワード引数は一つのインスタ
     ンス属性に対応します。したがって、例えば

          wrapper = TextWrapper(initial_indent="* ")

     はこれと同じです

          wrapper = TextWrapper()
          wrapper.initial_indent = "* "

     同じ *note TextWrapper: f9a. オブジェクトは何回も再利用できます。ま
     た、使用中にインスタンス属性へ代入することでそのオプションのどれで
     も変更できます。

     *note TextWrapper: f9a. インスタンス属性(とコンストラクタのキーワー
     ド引数)は以下の通りです:

      -- の属性: width

          (デフォルト: ‘70’) 折り返しが行われる行の最大の長さ。入力行に
          *note width: 22b4. より長い単一の語が無い限り、 *note
          TextWrapper: f9a. は *note width: 22b4. 文字より長い出力行が無
          いことを保証します。

      -- の属性: expand_tabs

          (デフォルト: ‘True’) もし真ならば、そのときは 'text' 内のすべ
          てのタブ文字は 'text' の *note expandtabs(): 2121. メソッドを
          用いて空白に展開されます。

      -- の属性: tabsize

          (デフォルト: ‘8’) *note expand_tabs: 22af. が真の場合、 'text'
          の中のすべてのTAB文字は tabsize と現在のカラムに応じて、ゼロ以
          上のスペースに展開されます。

          Added in version 3.3.

      -- の属性: replace_whitespace

          (デフォルト: ‘True’) 真の場合、 *note wrap(): 146c. メソッドは
          タブの展開の後、 wrap 処理の前に各種空白文字をスペース1文字に
          置換します。置換される空白文字は: TAB, 改行, 垂直TAB, FF, CR
          (‘'\t\n\v\f\r'’) です。

               注釈: *note expand_tabs: 22af. が偽で *note
               replace_whitespace: 22b1. が真ならば、各タブ文字は1つの空
               白に置き換えられます。それはタブ展開と同じでは 'ありませ
               ん' 。

               注釈: *note replace_whitespace: 22b1. が偽の場合、改行が
               行の途中で現れることで出力がおかしくなることがあります。
               このため、テキストを(*note str.splitlines(): 1228. などを
               使って)段落ごとに分けて別々に wrap する必要があります。

      -- の属性: drop_whitespace

          (デフォルト: ‘True’) 真の場合、(wrap 処理のあとインデント処理
          の前に) 各行の最初と最後の空白文字を削除します。ただし、段落の
          最初の空白については、次の文字が空白文字でない場合は削除されま
          せん。削除される空白文字が行全体に及ぶ場合は、行自体を削除しま
          す。

      -- の属性: initial_indent

          (default: ‘''’) wrap の出力の最初の行の先頭に付与する文字列。
          最初の行の長さに加算されます。空文字列の場合インデントされませ
          ん。

      -- の属性: subsequent_indent

          (デフォルト: ‘''’) 一行目以外の折り返しが行われる出力のすべて
          の行の先頭に付けられる文字列。一行目以外の各行の折り返しまでの
          長さにカウントされます。

      -- の属性: fix_sentence_endings

          (デフォルト: ‘False’) もし真ならば、 *note TextWrapper: f9a. は
          文の終わりを見つけようとし、確実に文がちょうど二つの空白で常に
          区切られているようにします。これは一般的に固定スペースフォント
          のテキストに対して望ましいです。しかし、文の検出アルゴリズムは
          完全ではありません: 文の終わりには、後ろに空白がある ‘'.'’,
          ‘'!'’ または ‘'?'’ の中の一つ、ことによると ‘'"'’ あるいは
          ‘"'"’ が付随する小文字があると仮定しています。このアルゴリズム
          に伴う一つの問題は下記の"Dr."と

               [...] Dr. Frankenstein's monster [...]

          下記の"Spot."の間の差異を検出できないことです

               [...] See Spot. See Spot run [...]

          *note fix_sentence_endings: 22b7. はデフォルトで偽です。

          文検出アルゴリズムは"小文字"の定義のために ‘string.lowercase’
          に依存し、同一行の文を区切るためにピリオドの後に二つの空白を使
          う慣習に依存しているため、英文テキストに限定されたものです。

      -- の属性: break_long_words

          (デフォルト: ‘True’) もし真ならば、そのとき *note width: 22b4.
          より長い行が確実にないようにするために、 *note width: 22b4. よ
          り長い語は切られます。偽ならば、長い語は切られないでしょう。そ
          して、 *note width: 22b4. より長い行があるかもしれません。
          (*note width: 22b4. を超える分を最小にするために、長い語は単独
          で一行に置かれるでしょう。)

      -- の属性: break_on_hyphens

          (デフォルト: ‘True’) 真の場合、英語で一般的なように、ラップ処
          理は空白か合成語に含まれるハイフンの直後で行われます。偽の場合
          、空白だけが改行に適した位置として判断されます。ただし、本当に
          語の途中で改行が行われないようにするためには、 *note
          break_long_words: 22b3. 属性を真に設定する必要があります。過去
          のバージョンでのデフォルトの振る舞いは、常にハイフンの直後での
          改行を許していました。

      -- の属性: max_lines

          (デフォルト ‘None’) ‘None’ 以外の場合、出力は行数 'max_lines'
          を超えないようにされ、切り詰める際には出力の最後の行を
          'placeholder' に置き換えます。

          Added in version 3.4.

      -- の属性: placeholder

          (デフォルト: ‘' [...]'’) 切り詰める場合に出力の最後の行に置く
          文字列です。

          Added in version 3.4.

     *note TextWrapper: f9a. はモジュールレベルの簡易関数に類似したいく
     つかの公開メソッドも提供します:

      -- メソッド: wrap (text)

          1段落の文字列 'text' を、各行が *note width: 22b4. 文字以下に
          なるように wrap します。 wrap のすべてのオプションは *note
          TextWrapper: f9a. インスタンスの属性から取得します。結果の、行
          末に改行のない行のリストを返します。出力の内容が空になる場合は
          、返すリストも空になります。

      -- メソッド: fill (text)

          'text' 内の段落を一つだけ折り返しを行い、折り返しが行われた段
          落を含む一つの文字列を返します。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/textwrap.py


File: python.info,  Node: unicodedata --- Unicode データベース,  Next: stringprep --- インターネットの文字列調製,  Prev: textwrap --- テキストの折り返しと詰め込み,  Up: テキスト処理サービス

5.6.5 ‘unicodedata’ -- Unicode データベース
-------------------------------------------

__________________________________________________________________

このモジュールは、すべてのユニコード文字の文字プロパティを定義するユニコ
ード文字データベース (UCD) へのアクセスを提供します。このデータベースに
含まれているデータは、 UCD バージョン 15.1.0(1) から作成されています。

このモジュールは、ユニコード標準付録 #44 「 ユニコード文字データベース
(2) 」で定義されているのと同じ名前およびシンボルを使用します。このモジュ
ールは次のような関数を定義します:

 -- の関数: unicodedata.lookup (name)

     名前に対応する文字を探します。その名前の文字が見つかった場合、その
     文字が返されます。見つからなかった場合には、 *note KeyError: 31d. を
     発生させます。

     バージョン 3.3 で変更: name aliases (3) と named sequences (4) のサ
     ポートが追加されました。

 -- の関数: unicodedata.name (chr[, default])

     文字 'chr' に付いている名前を、文字列で返します。名前が定義されてい
     ない場合には 'default' が返されますが、この引数が与えられていなけれ
     ば *note ValueError: 1e3. を発生させます。

 -- の関数: unicodedata.decimal (chr[, default])

     文字 'chr' に割り当てられている十進数を、整数で返します。この値が定
     義されていない場合には 'default' が返されますが、この引数が与えられ
     ていなければ *note ValueError: 1e3. を発生させます。

 -- の関数: unicodedata.digit (chr[, default])

     文字 'chr' に割り当てられている数値を、整数で返します。この値が定義
     されていない場合には 'default' が返されますが、この引数が与えられて
     いなければ *note ValueError: 1e3. を発生させます。

 -- の関数: unicodedata.numeric (chr[, default])

     文字 'chr' に割り当てられている数値を、float で返します。この値が定
     義されていない場合には 'default' が返されますが、この引数が与えられ
     ていなければ *note ValueError: 1e3. を発生させます。

 -- の関数: unicodedata.category (chr)

     文字 'chr' に割り当てられた、汎用カテゴリを返します。

 -- の関数: unicodedata.bidirectional (chr)

     文字 'chr' に割り当てられた、双方向クラスを返します。そのような値が
     定義されていない場合、空の文字列が返されます。

 -- の関数: unicodedata.combining (chr)

     文字 'chr' に割り当てられた正規結合クラスを返します。結合クラス定義
     されていない場合、‘0’ が返されます。

 -- の関数: unicodedata.east_asian_width (chr)

     ユニコード文字 'chr' に割り当てられたeast asian widthを文字列で返し
     ます。

 -- の関数: unicodedata.mirrored (chr)

     文字 'chr' に割り当てられた、鏡像化のプロパティを返します。その文字
     が双方向テキスト内で鏡像化された文字である場合には ‘1’ を、それ以外
     の場合には ‘0’ を返します。

 -- の関数: unicodedata.decomposition (chr)

     文字 'chr' に割り当てられた、文字分解マッピングを、文字列型で返しま
     す。そのようなマッピングが定義されていない場合、空の文字列が返され
     ます。

 -- の関数: unicodedata.normalize (form, unistr)

     Unicode 文字列 'unistr' の正規形 'form' を返します。 'form' の有効
     な値は、'NFC'、'NFKC'、'NFD'、'NFKD' です。

     Unicode 規格は標準等価性 (canonical equivalence) と互換等価性
     (compatibility equivalence) に基づいて、様々な Unicode文字列の正規
     形を定義します。Unicode では、複数の方法で表現できる文字があります
     。たとえば、文字 U+00C7 (LATIN CAPITAL LETTER C WITH CEDILLA) は、
     U+0043 (LATIN CAPITAL LETTER C) U+0327 (COMBINING CEDILLA) というシ
     ーケンスとしても表現できます。

     各文字には2つの正規形があり、それぞれ正規形 C と正規形 D といいます
     。正規形 D (NFD) は標準分解 (canonical decomposition) としても知ら
     れており、各文字を分解された形に変換します。正規形 C (NFC) は標準分
     解を適用した後、結合済文字を再構成します。

     互換等価性に基づいて、2つの正規形が加えられています。Unicode では、
     一般に他の文字との統合がサポートされている文字があります。たとえば
     、U+2160 (ROMAN NUMERAL ONE) は事実上 U+0049 (LATIN CAPITAL LETTER
     I) と同じものです。しかし、Unicode では、既存の文字集合 (たとえば
     gb2312) との互換性のために、これがサポートされています。

     正規形 KD (NFKD) は、互換分解 (compatibility decomposition) を適用
     します。すなわち、すべての互換文字を、等価な文字で置換します。正規
     形 KC (NFKC) は、互換分解を適用してから、標準分解を適用します。

     2つのunicode文字列が正規化されていて人間の目に同じに見えても、片方
     が結合文字を持っていてもう片方が持っていない場合、それらは完全に同
     じではありません。

 -- の関数: unicodedata.is_normalized (form, unistr)

     Unicode 文字列 'unistr' が正規形 'form' かどうかを返します。 'form'
     の有効な値は、'NFC'、'NFKC'、'NFD'、'NFKD' です。

     Added in version 3.8.

更に、本モジュールは以下の定数を公開します:

 -- データ: unicodedata.unidata_version

     このモジュールで使われている Unicode データベースのバージョン。

 -- データ: unicodedata.ucd_3_2_0

     これはモジュール全体と同じメソッドを具えたオブジェクトですが、
     Unicode データベースバージョン 3.2 を代わりに使っており、この特定の
     バージョンの Unicode データベースを必要とするアプリケーション(IDNA
     など)のためものです。

例:

     >>> import unicodedata
     >>> unicodedata.lookup('LEFT CURLY BRACKET')
     '{'
     >>> unicodedata.name('/')
     'SOLIDUS'
     >>> unicodedata.decimal('9')
     9
     >>> unicodedata.decimal('a')
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ValueError: not a decimal
     >>> unicodedata.category('A')  # 'L'etter, 'u'ppercase
     'Lu'
     >>> unicodedata.bidirectional('\u0660') # 'A'rabic, 'N'umber
     'AN'

脚注
....

   ---------- Footnotes ----------

   (1) https://www.unicode.org/Public/15.1.0/ucd

   (2) https://www.unicode.org/reports/tr44/

   (3) ‘https://www.unicode.org/Public/15.1.0/ucd/NameAliases.txt’

   (4) ‘https://www.unicode.org/Public/15.1.0/ucd/NamedSequences.txt’


File: python.info,  Node: stringprep --- インターネットの文字列調製,  Next: readline --- GNU readline のインターフェース,  Prev: unicodedata --- Unicode データベース,  Up: テキスト処理サービス

5.6.6 ‘stringprep’ -- インターネットの文字列調製
------------------------------------------------

'ソースコード:' Lib/stringprep.py(1)

__________________________________________________________________

(ホスト名のような) インターネット上にある存在に識別名をつける際、しばし
ば識別名間の "等価性" 比較を行う必要があります。厳密には、例えば大小文字
の区別をするかしないかいったように、比較をどのように行うかはアプリケーシ
ョンの領域に依存します。また、例えば "印字可能な" 文字で構成された識別名
だけを許可するといったように、可能な識別名を制限することも必要となるかも
しれません。

RFC 3454(2) では、インターネットプロトコル上で Unicode 文字列を "調製
(prepare)" するためのプロシジャを定義しています。文字列は通信路に載せら
れる前に調製プロシジャで処理され、その結果ある正規化された形式になります
。RFC ではあるテーブルの集合を定義しており、それらはプロファイルにまとめ
られています。各プロファイルでは、どのテーブルを使い、 ‘stringprep’ プロ
シジャのどのオプション部分がプロファイルの一部になっているかを定義してい
ます。 ‘stringprep’ プロファイルの一つの例は ‘nameprep’ で、国際化された
ドメイン名に使われます。

*note stringprep: bf. モジュールは RFC 3454(3) のテーブルを公開している
に過ぎません。これらのテーブルは辞書やリストとして表現するには大きすぎる
ので、このモジュールでは Unicode 文字データベースを内部的に利用していま
す。モジュールソースコード自体は ‘mkstringprep.py’ ユーティリティを使っ
て生成されました。

その結果、これらのテーブルはデータ構造体ではなく、関数として公開されてい
ます。RFC には 2 種類のテーブル: 集合およびマップ、が存在します。集合に
ついては、 *note stringprep: bf. は "特性関数 (characteristic function)"
、すなわち引数が集合の一部である場合に ‘True’ を返す関数を提供します。マ
ッピングについては、マップ関数: キーが与えられると、それに関連付けられた
値を返す関数を提供します。以下はこのモジュールで利用可能な全ての関数を列
挙したものです。

 -- の関数: stringprep.in_table_a1 (code)

     'code' がテーブル A.1 (Unicode 3.2 における未割り当てコードポイント
     : unassigned code point) かどうか判定します。

 -- の関数: stringprep.in_table_b1 (code)

     'code' がテーブル B.1 (一般には何にも対応付けられていない: commonly
     mapped to nothing) かどうか判定します。

 -- の関数: stringprep.map_table_b2 (code)

     テーブル B.2 (NFKC で用いられる大小文字の対応付け) に従って、'code'
     に対応付けられた値を返します。

 -- の関数: stringprep.map_table_b3 (code)

     テーブル B.3 (正規化を伴わない大小文字の対応付け) に従って、'code'
     に対応付けられた値を返します。

 -- の関数: stringprep.in_table_c11 (code)

     'code' がテーブル C.1.1 (ASCII スペース文字) かどうか判定します。

 -- の関数: stringprep.in_table_c12 (code)

     'code' がテーブル C.1.2 (非 ASCII スペース文字) かどうか判定します
     。

 -- の関数: stringprep.in_table_c11_c12 (code)

     'code' がテーブル C.1 (スペース文字、C.1.1 および C.1.2 の和集合) か
     どうか判定します。

 -- の関数: stringprep.in_table_c21 (code)

     'code' がテーブル C.2.1 (ASCII 制御文字) かどうか判定します。

 -- の関数: stringprep.in_table_c22 (code)

     'code' がテーブル C.2.2 (非 ASCII 制御文字) かどうか判定します。

 -- の関数: stringprep.in_table_c21_c22 (code)

     'code' がテーブル C.2 (制御文字、C.2.1 および C.2.2 の和集合) かど
     うか判定します。

 -- の関数: stringprep.in_table_c3 (code)

     'code' がテーブル C.3 (プライベート利用) かどうか判定します。

 -- の関数: stringprep.in_table_c4 (code)

     'code' がテーブル C.4 (非文字コードポイント: non-character code
     points) かどうか判定します。

 -- の関数: stringprep.in_table_c5 (code)

     'code' がテーブル C.5 (サロゲーションコード) かどうか判定します。

 -- の関数: stringprep.in_table_c6 (code)

     'code' がテーブル C.6 (平文:plain text として不適切) かどうか判定し
     ます。

 -- の関数: stringprep.in_table_c7 (code)

     'code' がテーブル C.7 (標準表現:canonical representation として不適
     切) かどうか判定します。

 -- の関数: stringprep.in_table_c8 (code)

     'code' がテーブル C.8 (表示プロパティの変更または撤廃) かどうか判定
     します。

 -- の関数: stringprep.in_table_c9 (code)

     'code' がテーブル C.9 (タグ文字) かどうか判定します。

 -- の関数: stringprep.in_table_d1 (code)

     'code' がテーブル D.1 (双方向プロパティ "R" または "AL" を持つ文字)
     かどうか判定します。

 -- の関数: stringprep.in_table_d2 (code)

     'code' がテーブル D.2 (双方向プロパティ "L" を持つ文字) かどうか判
     定します。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/stringprep.py

   (2) https://datatracker.ietf.org/doc/html/rfc3454.html

   (3) https://datatracker.ietf.org/doc/html/rfc3454.html


File: python.info,  Node: readline --- GNU readline のインターフェース,  Next: rlcompleter --- GNU readline の補完機能,  Prev: stringprep --- インターネットの文字列調製,  Up: テキスト処理サービス

5.6.7 ‘readline’ -- GNU readline のインターフェース
---------------------------------------------------

__________________________________________________________________

*note readline: a8. モジュールでは、補完や Python インタプリタからの履歴
ファイルの読み書きを容易にするための多くの関数を定義しています。 このモ
ジュールは直接、または *note rlcompleter: ab. モジュールを介して使うこと
ができます。 *note rlcompleter: ab. モジュールは対話的プロンプトで
Python 識別子の補完をサポートするものです。 このモジュールで利用される設
定は、インタプリタの対話プロンプトならびに組み込みの *note input():
12a6. 関数の両方の挙動に影響します。

readline のキーバインディングは初期化ファイルで設定できます。 このファイ
ルは、たいていはホームディレクトリに ‘.inputrc’ という名前で置いてありま
す。 GNU Readline マニュアルの Readline Init File(1) を参照して、そのフ
ァイルの形式や可能な構成、 Readline ライブラリ全体の機能を知ってください
。

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

     注釈: 下層の Readline ライブラリー API は GNU readline ではなく
     ‘editline’ (‘libedit’) ライブラリーで実装される可能性があります。
     macOS では *note readline: a8. モジュールはどのライブラリーが使われ
     ているかを実行時に検出します。

     The configuration file for ‘editline’ is different from that of GNU
     readline.  If you programmatically load configuration strings you
     can use *note backend: 1613. to determine which library is being
     used.

     If you use ‘editline’/‘libedit’ readline emulation on macOS, the
     initialization file located in your home directory is named
     ‘.editrc’.  For example, the following content in ‘~/.editrc’ will
     turn ON 'vi' keybindings and TAB completion:

          python:bind -v
          python:bind ^I rl_complete

     Also note that different libraries may use different history file
     formats.  When switching the underlying library, existing history
     files may become unusable.

 -- データ: readline.backend

     The name of the underlying Readline library being used, either
     ‘"readline"’ or ‘"editline"’.

     Added in version 3.13.

* Menu:

* 初期化ファイル::
* 行バッファ::
* 履歴ファイル::
* 履歴リスト::
* 開始フック::
* 補完::
* 使用例: 使用例<2>.

   ---------- Footnotes ----------

   (1) 
https://tiswww.cwru.edu/php/chet/readline/rluserman.html#Readline-Init-File


File: python.info,  Node: 初期化ファイル,  Next: 行バッファ,  Up: readline --- GNU readline のインターフェース

5.6.7.1 初期化ファイル
......................

以下の関数は初期化ファイルならびにユーザ設定関連のものです:

 -- の関数: readline.parse_and_bind (string)

     'string' 引数で渡された最初の行を実行します。これにより下層のライブ
     ラリーの ‘rl_parse_and_bind()’ が呼ばれます。

 -- の関数: readline.read_init_file ([filename])

     readline 初期化ファイルを実行します。デフォルトのファイル名は最後に
     使用されたファイル名です。これにより下層のライブラリーの
     ‘rl_read_init_file()’ が呼ばれます。


File: python.info,  Node: 行バッファ,  Next: 履歴ファイル,  Prev: 初期化ファイル,  Up: readline --- GNU readline のインターフェース

5.6.7.2 行バッファ
..................

以下の関数は行バッファを操作します:

 -- の関数: readline.get_line_buffer ()

     行バッファ (下層のライブラリーの ‘rl_line_buffer’) の現在の内容を返
     します。

 -- の関数: readline.insert_text (string)

     テキストをカーサー位置の行バッファに挿入します。これにより下層のラ
     イブラリーの ‘rl_insert_text()’ が呼ばれますが、戻り値は無視されま
     す。

 -- の関数: readline.redisplay ()

     スクリーンの表示を変更して行バッファの現在の内容を反映させます。こ
     れにより下層のライブラリーの ‘rl_redisplay()’ が呼ばれます。


File: python.info,  Node: 履歴ファイル,  Next: 履歴リスト,  Prev: 行バッファ,  Up: readline --- GNU readline のインターフェース

5.6.7.3 履歴ファイル
....................

以下の関数は履歴ファイルを操作します:

 -- の関数: readline.read_history_file ([filename])

     readline 履歴ファイルを読み込み、履歴リストに追加します。デフォルト
     のファイル名は ‘~/.history’ です。これにより下層のライブラリーの
     ‘read_history()’ が呼ばれます。

 -- の関数: readline.write_history_file ([filename])

     履歴リストを readline 履歴ファイルに保存します。既存のファイルは上
     書きされます。デフォルトのファイル名は ‘~/.history’ です。これによ
     り下層のライブラリーの ‘write_history()’ が呼ばれます。

 -- の関数: readline.append_history_file (nelements[, filename])

     履歴の最後の 'nelements' 項目をファイルに追加します。デフォルトのフ
     ァイル名は ‘~/.history’ です。ファイルは存在していなくてはなりませ
     ん。これにより下層のライブラリーの ‘append_history()’ が呼ばれます
     。Python がこの機能をサポートするライブラリーのバージョンでコンパイ
     ルされたときのみ、この関数は存在します。

     Added in version 3.5.

 -- の関数: readline.get_history_length ()
 -- の関数: readline.set_history_length (length)

     Set or return the desired number of lines to save in the history
     file.  The *note write_history_file(): 22e5. function uses this
     value to truncate the history file, by calling
     ‘history_truncate_file()’ in the underlying library.  Negative
     values imply unlimited history file size.


File: python.info,  Node: 履歴リスト,  Next: 開始フック,  Prev: 履歴ファイル,  Up: readline --- GNU readline のインターフェース

5.6.7.4 履歴リスト
..................

以下の関数はグローバルな履歴リストを操作します:

 -- の関数: readline.clear_history ()

     現在の履歴をクリアします。これにより下層のライブラリーの
     ‘clear_history()’ が呼ばれます。Python がこの機能をサポートするライ
     ブラリーのバージョンでコンパイルされたときのみ、この関数は存在しま
     す。

 -- の関数: readline.get_current_history_length ()

     履歴に現在ある項目の数を返します。 (*note get_history_length():
     22e6. は履歴ファイルに書かれる最大行数を返します。)

 -- の関数: readline.get_history_item (index)

     現在の履歴の 'index' 番目の項目を返します。添字は1から始まります。
     これにより下層のライブラリーの ‘history_get()’ が呼ばれます。

 -- の関数: readline.remove_history_item (pos)

     履歴から指定された位置の項目を削除します。添字は0から始まります。こ
     れにより下層のライブラリーの ‘remove_history()’ が呼ばれます。

 -- の関数: readline.replace_history_item (pos, line)

     指定された位置の項目を 'line' で置き換えます。添字は0から始まります
     。これにより下層のライブラリーの ‘replace_history_entry()’ が呼ばれ
     ます。

 -- の関数: readline.add_history (line)

     最後に入力したかのように、 'line' を履歴バッファに追加します。これ
     により下層のライブラリーの ‘add_history()’ が呼ばれます。

 -- の関数: readline.set_auto_history (enabled)

     Enable or disable automatic calls to ‘add_history()’ when reading
     input via readline.  The 'enabled' argument should be a Boolean
     value that when true, enables auto history, and that when false,
     disables auto history.

     Added in version 3.6.

     'CPython 実装の詳細:' Auto history is enabled by default, and
     changes to this do not persist across multiple sessions.


File: python.info,  Node: 開始フック,  Next: 補完,  Prev: 履歴リスト,  Up: readline --- GNU readline のインターフェース

5.6.7.5 開始フック
..................

 -- の関数: readline.set_startup_hook ([function])

     Set or remove the function invoked by the ‘rl_startup_hook’
     callback of the underlying library.  If 'function' is specified, it
     will be used as the new hook function; if omitted or ‘None’, any
     function already installed is removed.  The hook is called with no
     arguments just before readline prints the first prompt.

 -- の関数: readline.set_pre_input_hook ([function])

     Set or remove the function invoked by the ‘rl_pre_input_hook’
     callback of the underlying library.  If 'function' is specified, it
     will be used as the new hook function; if omitted or ‘None’, any
     function already installed is removed.  The hook is called with no
     arguments after the first prompt has been printed and just before
     readline starts reading input characters.  This function only
     exists if Python was compiled for a version of the library that
     supports it.


File: python.info,  Node: 補完,  Next: 使用例<2>,  Prev: 開始フック,  Up: readline --- GNU readline のインターフェース

5.6.7.6 補完
............

The following functions relate to implementing a custom word completion
function.  This is typically operated by the Tab key, and can suggest
and automatically complete a word being typed.  By default, Readline is
set up to be used by *note rlcompleter: ab. to complete Python
identifiers for the interactive interpreter.  If the *note readline: a8.
module is to be used with a custom completer, a different set of word
delimiters should be set.

 -- の関数: readline.set_completer ([function])

     completer 関数を設定または削除します。'function' が指定された場合、
     新たな completer 関数として用いられます; 省略された場合や ‘None’ の
     場合、現在インストールされている completer 関数は削除されます。
     completer 関数は ‘function(text, state)’ の形式で、関数が文字列でな
     い値を返すまで 'state' を ‘0’, ‘1’, ‘2’, ..., にして呼び出します。
     この関数は 'text' から始まる補完結果として次に来そうなものを返さな
     ければなりません。

     The installed completer function is invoked by the 'entry_func'
     callback passed to ‘rl_completion_matches()’ in the underlying
     library.  The 'text' string comes from the first parameter to the
     ‘rl_attempted_completion_function’ callback of the underlying
     library.

 -- の関数: readline.get_completer ()

     completer 関数を取得します。completer 関数が設定されていなければ
     ‘None’ を返します。

 -- の関数: readline.get_completion_type ()

     Get the type of completion being attempted.  This returns the
     ‘rl_completion_type’ variable in the underlying library as an
     integer.

 -- の関数: readline.get_begidx ()
 -- の関数: readline.get_endidx ()

     Get the beginning or ending index of the completion scope.  These
     indexes are the 'start' and 'end' arguments passed to the
     ‘rl_attempted_completion_function’ callback of the underlying
     library.  The values may be different in the same input editing
     scenario based on the underlying C readline implementation.  Ex:
     libedit is known to behave differently than libreadline.

 -- の関数: readline.set_completer_delims (string)
 -- の関数: readline.get_completer_delims ()

     Set or get the word delimiters for completion.  These determine the
     start of the word to be considered for completion (the completion
     scope).  These functions access the
     ‘rl_completer_word_break_characters’ variable in the underlying
     library.

 -- の関数: readline.set_completion_display_matches_hook ([function])

     Set or remove the completion display function.  If 'function' is
     specified, it will be used as the new completion display function;
     if omitted or ‘None’, any completion display function already
     installed is removed.  This sets or clears the
     ‘rl_completion_display_matches_hook’ callback in the underlying
     library.  The completion display function is called as
     ‘function(substitution, [matches], longest_match_length)’ once each
     time matches need to be displayed.


File: python.info,  Node: 使用例<2>,  Prev: 補完,  Up: readline --- GNU readline のインターフェース

5.6.7.7 使用例
..............

以下の例では、ユーザのホームディレクトリにある履歴ファイル
‘.python_history’ の読み込みと保存を自動的に行うために、 *note readline:
a8. モジュールの履歴の読み書き関数をどのように使うかを示しています。以下
のソースコードは通常、対話セッション中はユーザの *note PYTHONSTARTUP:
f95. ファイルから自動的に実行されます:

     import atexit
     import os
     import readline

     histfile = os.path.join(os.path.expanduser("~"), ".python_history")
     try:
         readline.read_history_file(histfile)
         # default history len is -1 (infinite), which may grow unruly
         readline.set_history_length(1000)
     except FileNotFoundError:
         pass

     atexit.register(readline.write_history_file, histfile)

Python が *note 対話モード: f93. で実行される時、このコードは実際には自
動的に実行されます ( *note readline の設定: f96. を参照してください)。

次の例では上記と同じ目的を達成できますが、ここでは新規の履歴のみを追加す
ることで、並行して対話セッションがサポートされます:

     import atexit
     import os
     import readline
     histfile = os.path.join(os.path.expanduser("~"), ".python_history")

     try:
         readline.read_history_file(histfile)
         h_len = readline.get_current_history_length()
     except FileNotFoundError:
         open(histfile, 'wb').close()
         h_len = 0

     def save(prev_h_len, histfile):
         new_h_len = readline.get_current_history_length()
         readline.set_history_length(1000)
         readline.append_history_file(new_h_len - prev_h_len, histfile)
     atexit.register(save, h_len, histfile)

次の例では *note code.InteractiveConsole: 22f8. クラスを拡張し、履歴の保
存・復旧をサポートします。

     import atexit
     import code
     import os
     import readline

     class HistoryConsole(code.InteractiveConsole):
         def __init__(self, locals=None, filename="<console>",
                      histfile=os.path.expanduser("~/.console-history")):
             code.InteractiveConsole.__init__(self, locals, filename)
             self.init_history(histfile)

         def init_history(self, histfile):
             readline.parse_and_bind("tab: complete")
             if hasattr(readline, "read_history_file"):
                 try:
                     readline.read_history_file(histfile)
                 except FileNotFoundError:
                     pass
                 atexit.register(self.save_history, histfile)

         def save_history(self, histfile):
             readline.set_history_length(1000)
             readline.write_history_file(histfile)


File: python.info,  Node: rlcompleter --- GNU readline の補完機能,  Prev: readline --- GNU readline のインターフェース,  Up: テキスト処理サービス

5.6.8 ‘rlcompleter’ -- GNU readline の補完機能
----------------------------------------------

'ソースコード:' Lib/rlcompleter.py(1)

__________________________________________________________________

The ‘rlcompleter’ module defines a completion function suitable to be
passed to *note set_completer(): 22f1. in the *note readline: a8.
module.

When this module is imported on a Unix platform with the *note readline:
a8. module available, an instance of the *note Completer: 18ae. class is
automatically created and its *note complete(): 22fb. method is set as
the *note readline completer: 22f0.  The method provides completion of
valid Python *note identifiers and keywords: 1df6.

以下はプログラム例です:

     >>> import rlcompleter
     >>> import readline
     >>> readline.parse_and_bind("tab: complete")
     >>> readline. <TAB PRESSED>
     readline.__doc__          readline.get_line_buffer(  readline.read_init_file(
     readline.__file__         readline.insert_text(      readline.set_completer(
     readline.__name__         readline.parse_and_bind(
     >>> readline.

The ‘rlcompleter’ module is designed for use with Python's *note
interactive mode: f93.  Unless Python is run with the *note -S: 1179.
option, the module is automatically imported and configured (see *note
readline の設定: f96.).

*note readline: a8. のないプラットフォームでも、このモジュールで定義され
る *note Completer: 18ae. クラスは独自の目的に使えます。

 -- クラス: rlcompleter.Completer

     Completerオブジェクトは以下のメソッドを持っています:

      -- メソッド: complete (text, state)

          Return the next possible completion for 'text'.

          When called by the *note readline: a8. module, this method is
          called successively with ‘state == 0, 1, 2, ...’ until the
          method returns ‘None’.

          もし 'text' がピリオド(‘'.'’)を含まない場合、 *note __main__:
          1. 、 *note builtins: e. で定義されている名前か、キーワード
          (*note keyword: 78. モジュールで定義されている) から補完されま
          す。

          If called for a dotted name, it will try to evaluate anything
          without obvious side-effects (functions will not be evaluated,
          but it can generate calls to *note __getattr__(): 49f.) up to
          the last part, and find matches for the rest via the *note
          dir(): 5fe. function.  Any exception raised during the
          evaluation of the expression is caught, silenced and *note
          None: 641. is returned.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/rlcompleter.py


File: python.info,  Node: バイナリデータ処理,  Next: データ型,  Prev: テキスト処理サービス,  Up: Python 標準ライブラリ

5.7 バイナリデータ処理
======================

この章で紹介されているモジュールはバイナリデータを扱うための基本的な処理
を提供しています。ファイルフォーマットやネットワークプロトコルなど、その
他のバイナリデータ処理については、それぞれの節で解説されています。

*note テキスト処理サービス: 211f. で紹介する一部のライブラリには、 ASCII
互換のバイナリフォーマットで利用できるもの (例: *note re: a7.) や 、すべ
てのバイナリデータで利用できるもの (例: *note difflib: 2f.) があります。

加えて、 *note バイナリシーケンス型 -- bytes, bytearray, memoryview:
20c4. に書かれているPythonビルトインデータ型についても参照してください。

* Menu:

* struct: struct --- バイト列をパックされたバイナリデータとして解釈する. バイト列をパックされたバイナリデータとして解釈する
* codecs: codecs --- codec レジストリと基底クラス. codec レジストリと基底クラス


File: python.info,  Node: struct --- バイト列をパックされたバイナリデータとして解釈する,  Next: codecs --- codec レジストリと基底クラス,  Up: バイナリデータ処理

5.7.1 ‘struct’ -- バイト列をパックされたバイナリデータとして解釈する
--------------------------------------------------------------------

'ソースコード:' Lib/struct.py(1)

__________________________________________________________________

This module converts between Python values and C structs represented as
Python *note bytes: 1a4. objects.  Compact *note format strings: 2301.
describe the intended conversions to/from Python values.  The module's
functions and objects can be used for two largely distinct applications,
data exchange with external sources (files or network connections), or
data transfer between the Python application and the C layer.

     注釈: When no prefix character is given, native mode is the
     default.  It packs or unpacks data based on the platform and
     compiler on which the Python interpreter was built.  The result of
     packing a given C struct includes pad bytes which maintain proper
     alignment for the C types involved; similarly, alignment is taken
     into account when unpacking.  In contrast, when communicating data
     between external sources, the programmer is responsible for
     defining byte ordering and padding between elements.  See *note
     バイトオーダ、サイズ、アラインメント: 2302. for details.

いくつかの *note struct: c0. の関数 (および *note Struct: 1615. のメソッ
ド) は 'buffer' 引数を取ります。 これは *note バッファプロトコル (buffer
Protocol): 371. を実装していて読み取り可能または読み書き可能なバッファを
提供するオブジェクトのことです。この目的のために使われる最も一般的な型は
*note bytes: 1a4. と *note bytearray: 508. ですが、バイトの配列とみなす
ことができるような他の多くの型がバッファプロトコルを実装しています。その
ため、それらは *note bytes: 1a4. オブジェクトから追加のコピーなしで読み
出しや書き込みができます。

* Menu:

* 関数と例外::
* 書式文字列::
* Applications::
* クラス: クラス<3>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/struct.py


File: python.info,  Node: 関数と例外,  Next: 書式文字列,  Up: struct --- バイト列をパックされたバイナリデータとして解釈する

5.7.1.1 関数と例外
..................

このモジュールは以下の例外と関数を定義しています:

 -- 例外: struct.error

     様々な状況で送出される例外です。引数は何が問題なのかを記述する文字
     列です。

 -- の関数: struct.pack (format, v1, v2, ...)

     フォーマット文字列 'format' に従い値 'v1', 'v2', ...  をパックして
     、バイト列オブジェクトを返します。引数は指定したフォーマットが要求
     する型と正確に一致していなければなりません。

 -- の関数: struct.pack_into (format, buffer, offset, v1, v2, ...)

     フォーマット文字列 'format' に従い値 'v1', 'v2', ...  をパックして
     バイト列にし、書き込み可能な 'buffer' のオフセット 'offset' 位置よ
     り書き込みます。オフセットは省略出来ません。

 -- の関数: struct.unpack (format, buffer)

     (‘pack(format, ...)’ でパックされたであろう) バッファ 'buffer' を、
     書式文字列 'format' に従ってアンパックします。 値が一つしかない場合
     を含め、結果はタプルで返されます。 バッファのバイトサイズは、 *note
     calcsize(): 192f. の返り値である書式文字列が要求するサイズと一致し
     なければなりません。

 -- の関数: struct.unpack_from (format, /, buffer, offset=0)

     バッファ 'buffer' を、 'offset' の位置から書式文字列 'format' に従
     ってアンパックします。 値が一つしかない場合を含め、結果はタプルで返
     されます。 'offset' を始点とするバッファのバイトサイズは、少なくと
     も *note calcsize(): 192f. の返り値である書式文字列が要求するサイズ
     でなければなりません。

 -- の関数: struct.iter_unpack (format, buffer)

     バッファ 'buffer' を、書式文字列 'format' に従ってイテレータ形式で
     アンパックします。 この関数が返すイテレータは、すべての内容を読み終
     わるまでバッファから一定の大きさのチャンクを読み取ります。 バッファ
     のバイトサイズは、 *note calcsize(): 192f. の返り値である書式文字列
     が要求するサイズの倍数でなければなりません。

     イテレーション毎に書式文字列で指定されたタプルを yield します。

     Added in version 3.4.

 -- の関数: struct.calcsize (format)

     書式文字列 'format' に従って、構造体 (それと ‘pack(format, ...)’ に
     よって作成されるバイト列オブジェクト) のサイズを返します。


File: python.info,  Node: 書式文字列,  Next: Applications,  Prev: 関数と例外,  Up: struct --- バイト列をパックされたバイナリデータとして解釈する

5.7.1.2 書式文字列
..................

Format strings describe the data layout when packing and unpacking data.
They are built up from *note format characters: 1013, which specify the
type of data being packed/unpacked.  In addition, special characters
control the *note byte order, size and alignment: 2302.  Each format
string consists of an optional prefix character which describes the
overall properties of the data and one or more format characters which
describe the actual data values and padding.

* Menu:

* バイトオーダ、サイズ、アラインメント::
* 書式指定文字::
* 使用例: 使用例<3>.


File: python.info,  Node: バイトオーダ、サイズ、アラインメント,  Next: 書式指定文字,  Up: 書式文字列

5.7.1.3 バイトオーダ、サイズ、アラインメント
............................................

By default, C types are represented in the machine's native format and
byte order, and properly aligned by skipping pad bytes if necessary
(according to the rules used by the C compiler).  This behavior is
chosen so that the bytes of a packed struct correspond exactly to the
memory layout of the corresponding C struct.  Whether to use native byte
ordering and padding or standard formats depends on the application.

これに代わって、フォーマット文字列の最初の文字を使って、バイトオーダやサ
イズ、アラインメントを指定することができます。指定できる文字を以下のテー
ブルに示します:

文字            バイトオーダ                 サイズ         アラインメン
                                                            ト
                                                            
----------------------------------------------------------------------------
                                                            
‘@’             native                       native         native
                                                            
                                                            
‘=’             native                       standard       none
                                                            
                                                            
‘<’             リトルエンディアン           standard       none
                                                            
                                                            
‘>’             ビッグエンディアン           standard       none
                                                            
                                                            
‘!’             ネットワーク (= ビッグエン   standard       none
                ディアン)                                   
                

フォーマット文字列の最初の文字が上のいずれかでない場合、‘'@'’ であるとみ
なされます。

     注釈: The number 1023 (‘0x3ff’ in hexadecimal) has the following
     byte representations:

        * ‘03 ff’ in big-endian (‘>’)

        * ‘ff 03’ in little-endian (‘<’)

     Python の例:

          >>> import struct
          >>> struct.pack('>h', 1023)
          b'\x03\xff'
          >>> struct.pack('<h', 1023)
          b'\xff\x03'

ネイティブのバイトオーダはビッグエンディアンかリトルエンディアンで、ホス
トシステムに依存します。例えば、Intel x86、AMD64 (x86-64) および Apple
M1 はリトルエンディアンです。IBM z および多くの古いアーキテクチャはビッ
グエンディアンです。使っているシステムでのエンディアンは *note
sys.byteorder: 2100. を使って調べて下さい。

ネイティブのサイズおよびアラインメントは C コンパイラの ‘sizeof’ 式で決
定されます。ネイティブのサイズおよびアラインメントはネイティブのバイトオ
ーダと同時に使われます。

標準のサイズはフォーマット文字だけで決まります。 *note 書式指定文字:
1013. の表を参照して下さい。

‘'@'’ と ‘'='’ の違いに注意してください: 両方ともネイティブのバイトオー
ダですが、後者のバイトサイズとアラインメントは標準のものに合わせてありま
す。

The form ‘'!'’ represents the network byte order which is always
big-endian as defined in IETF RFC 1700(1).

バイトオーダに関して、「(強制的にバイトスワップを行う)ネイティブの逆」を
指定する方法はありません。‘'<'’ または ‘'>'’ のうちふさわしい方を選んで
ください。

注釈:

  1. パディングは構造体のメンバの並びの中にだけ自動で追加されます。最初
     や最後にパディングが追加されることはありません。

  2. ネイティブでないサイズおよびアラインメントが使われる場合にはパディ
     ングは行われません (たとえば '<', '>', '=', '!'  を使った場合です
     )。

  3. 特定の型によるアラインメント要求に従うように構造体の末端をそろえる
     には、繰り返し回数をゼロにした特定の型でフォーマットを終端します。
     *note 使用例: 2308. を参照して下さい。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc1700


File: python.info,  Node: 書式指定文字,  Next: 使用例<3>,  Prev: バイトオーダ、サイズ、アラインメント,  Up: 書式文字列

5.7.1.4 書式指定文字
....................

フォーマット文字 (format character) は以下の意味を持っています; C と
Python の間の変換では、値は正確に以下に指定された型でなくてはなりません:
「標準のサイズ」列は standard サイズ使用時にパックされた値が何バイトかを
示します。つまり、フォーマット文字列が ‘'<'’, ‘'>'’, ‘'!'’, ‘'='’ のいず
れかで始まっている場合のものです。native サイズ使用時にはパックされた値
の大きさはプラットフォーム依存です。

フォーマッ   C の型                         Python の型              標準のサイズ         注釈
ト                                                                                        

-----------------------------------------------------------------------------------------------------------
                                                                                          
‘x’          パディングバイト               値なし                                        (7)
                                                                                          
                                                                                          
‘c’          char                           長さ 1 のバイト列        1
                                                                     
                                                                                          
‘b’          signed char                    整数                     1                    (1), (2)
                                                                                          
                                                                                          
‘B’          unsigned char                  整数                     1                    (2)
                                                                                          
                                                                                          
‘?’          _Bool                          真偽値型(bool)           1                    (1)
                                                                                          
                                                                                          
‘h’          short                          整数                     2                    (2)
                                                                                          
                                                                                          
‘H’          unsigned short                 整数                     2                    (2)
                                                                                          
                                                                                          
‘i’          int                            整数                     4                    (2)
                                                                                          
                                                                                          
‘I’          unsigned int                   整数                     4                    (2)
                                                                                          
                                                                                          
‘l’          long                           整数                     4                    (2)
                                                                                          
                                                                                          
‘L’          unsigned long                  整数                     4                    (2)
                                                                                          
                                                                                          
‘q’          long long                      整数                     8                    (2)
                                                                                          
                                                                                          
‘Q’          unsigned long long             整数                     8                    (2)
                                                                                          
                                                                                          
‘n’          ‘ssize_t’                      整数                                          (3)
                                                                                          
                                                                                          
‘N’          ‘size_t’                       整数                                          (3)
                                                                                          
                                                                                          
‘e’          (6)                            浮動小数点数             2                    (4)
                                                                                          
                                                                                          
‘f’          float                          浮動小数点数             4                    (4)
                                                                                          
                                                                                          
‘d’          double                         浮動小数点数             8                    (4)
                                                                                          
                                                                                          
‘s’          char[]                         bytes                                         (9)
                                                                                          
                                                                                          
‘p’          char[]                         bytes                                         (8)
                                                                                          
                                                                                          
‘P’          void*                          整数                                          (5)
                                                                                          

バージョン 3.3 で変更: ‘'n'’ および ‘'N'’ フォーマットのサポートが追加さ
れました。

バージョン 3.6 で変更: ‘'e'’ フォーマットのサポートが追加されました。

注釈:

  1. 
     The ‘'?'’ conversion code corresponds to the _Bool type defined by
     C standards since C99.  In standard mode, it is represented by one
     byte.

  2. When attempting to pack a non-integer using any of the integer
     conversion codes, if the non-integer has a *note __index__(): 6e8.
     method then that method is called to convert the argument to an
     integer before packing.

     バージョン 3.2 で変更: Added use of the *note __index__(): 6e8.
     method for non-integers.

  3. ‘'n'’ および ‘'N'’ 変換コードは (デフォルトもしくはバイトオーダ文字
     ‘'@'’ 付きで選択される) native サイズ使用時のみ利用できます。
     standard サイズ使用時には、自身のアプリケーションに適する他の整数フ
     ォーマットを使うことができます。

  4. ‘'f'’ 、 ‘'d'’ および ‘'e'’ 変換コードについて、パックされた表現は
     IEEE 754 binary32 (‘'f'’ の場合) 、 binary64 (‘'d'’ の場合) 、また
     はbinary16(‘'e'’ の場合) フォーマットが、プラットフォームにおける浮
     動小数点数のフォーマットに関係なく使われます。

  5. ‘'P'’ フォーマット文字はネイティブバイトオーダでのみ利用可能です (デ
     フォルトのネットワークバイトオーダに設定するか、‘'@'’ バイトオーダ
     指定文字を指定しなければなりません)。‘'='’ を指定した場合、ホスト計
     算機のバイトオーダに基づいてリトルエンディアンとビッグエンディアン
     のどちらを使うかを決めます。struct モジュールはこの設定をネイティブ
     のオーダ設定として解釈しないので、‘'P'’ を使うことはできません。

  6. IEEE 754 の binary16 "半精度" 型は、 IEEE 754 standard(1) の2008 年
     の改訂で導入されました。 半精度型は、符号 bit 、5 bit の指数部、 11
     bit の精度 (明示的には 10 bit が保存される) を持ち、おおよそ
     ‘6.1e-05’ から ‘6.5e+04’ までの数を完全な精度で表現できます。 この
     型は C コンパイラでは広くはサポートされていません: たいていのマシン
     では、保存するのに unsigned short が使えますが、数学の演算には使え
     ません。 詳しいことは Wikipedia の half-precision floating-point
     format(2) のページを参照してください。

  7. When packing, ‘'x'’ inserts one NUL byte.

  8. フォーマット文字 ‘'p'’ は "Pascal 文字列 (pascal string)" をコード
     します。Pascal 文字列は count で与えられる '固定長のバイト列' に収
     められた短い可変長の文字列です。このデータの先頭の 1 バイトには文字
     列の長さか255 のうち、小さい方の数が収められます。その後に文字列の
     バイトデータが続きます。 *note pack(): 1248. に渡された Pascal 文字
     列の長さが長すぎた (count-1 よりも長い) 場合、先頭の ‘count-1’ バイ
     トが書き込まれます。文字列が ‘count-1’ よりも短い場合、指定した
     count バイトに達するまでの残りの部分はヌルで埋められます。 *note
     unpack(): 1731. では、フォーマット文字 ‘'p'’ は指定された ‘count’ バ
     イトだけデータを読み込みますが、返される文字列は決して 255 文字を超
     えることはないので注意してください。

  9. For the ‘'s'’ format character, the count is interpreted as the
     length of the bytes, not a repeat count like for the other format
     characters; for example, ‘'10s'’ means a single 10-byte string
     mapping to or from a single Python byte string, while ‘'10c'’ means
     10 separate one byte character elements (e.g., ‘cccccccccc’)
     mapping to or from ten different Python byte objects.  (See *note
     使用例: 2308. for a concrete demonstration of the difference.)  If
     a count is not given, it defaults to 1.  For packing, the string is
     truncated or padded with null bytes as appropriate to make it fit.
     For unpacking, the resulting bytes object always has exactly the
     specified number of bytes.  As a special case, ‘'0s'’ means a
     single, empty string (while ‘'0c'’ means 0 characters).

フォーマット文字の前に整数をつけ、繰り返し回数 (count) を指定することが
できます。例えば、フォーマット文字列 ‘'4h'’ は ‘'hhhh'’ と全く同じ意味で
す。

フォーマット文字間の空白文字は無視されます; count とフォーマット文字の間
にはスペースを入れてはいけません。

整数フォーマット (‘'b'’, ‘'B'’, ‘'h'’, ‘'H'’, ‘'i'’, ‘'I'’, ‘'l'’,
‘'L'’, ‘'q'’, ‘'Q'’) のいずれかを使って値 ‘x’ をパックするとき ‘x’ がフ
ォーマットの適切な値の範囲に無い場合、 *note struct.error: 12f2. が送出
されます。

バージョン 3.1 で変更: 以前は、いくつかの整数フォーマットが適切な範囲に
ない値を覆い隠して、 *note struct.error: 12f2. の代わりに *note
DeprecationWarning: 18a. を送出していました。

‘'?'’ フォーマット文字では、返り値は *note True: bdb. または *note
False: b05. です。パックするときには、引数オブジェクトの論理値としての値
が使われます。 0 または 1 のネイティブや標準の真偽値表現でパックされ、ア
ンパックされるときはゼロでない値は ‘True’ になります。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/IEEE_754-2008_revision

   (2) 
https://en.wikipedia.org/wiki/Half-precision_floating-point_format


File: python.info,  Node: 使用例<3>,  Prev: 書式指定文字,  Up: 書式文字列

5.7.1.5 使用例
..............

     注釈: Native byte order examples (designated by the ‘'@'’ format
     prefix or lack of any prefix character) may not match what the
     reader's machine produces as that depends on the platform and
     compiler.

Pack and unpack integers of three different sizes, using big endian
ordering:

     >>> from struct import *
     >>> pack(">bhl", 1, 2, 3)
     b'\x01\x00\x02\x00\x00\x00\x03'
     >>> unpack('>bhl', b'\x01\x00\x02\x00\x00\x00\x03')
     (1, 2, 3)
     >>> calcsize('>bhl')
     7

Attempt to pack an integer which is too large for the defined field:

     >>> pack(">h", 99999)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     struct.error: 'h' format requires -32768 <= number <= 32767

Demonstrate the difference between ‘'s'’ and ‘'c'’ format characters:

     >>> pack("@ccc", b'1', b'2', b'3')
     b'123'
     >>> pack("@3s", b'123')
     b'123'

アンパックした結果のフィールドは、変数に割り当てるか named tuple でラッ
プすることによって名前を付けることができます:

     >>> record = b'raymond   \x32\x12\x08\x01\x08'
     >>> name, serialnum, school, gradelevel = unpack('<10sHHb', record)

     >>> from collections import namedtuple
     >>> Student = namedtuple('Student', 'name serialnum school gradelevel')
     >>> Student._make(unpack('<10sHHb', record))
     Student(name=b'raymond   ', serialnum=4658, school=264, gradelevel=8)

The ordering of format characters may have an impact on size in native
mode since padding is implicit.  In standard mode, the user is
responsible for inserting any desired padding.  Note in the first ‘pack’
call below that three NUL bytes were added after the packed ‘'#'’ to
align the following integer on a four-byte boundary.  In this example,
the output was produced on a little endian machine:

     >>> pack('@ci', b'#', 0x12131415)
     b'#\x00\x00\x00\x15\x14\x13\x12'
     >>> pack('@ic', 0x12131415, b'#')
     b'\x15\x14\x13\x12#'
     >>> calcsize('@ci')
     8
     >>> calcsize('@ic')
     5

The following format ‘'llh0l'’ results in two pad bytes being added at
the end, assuming the platform's longs are aligned on 4-byte boundaries:

     >>> pack('@llh0l', 1, 2, 3)
     b'\x00\x00\x00\x01\x00\x00\x00\x02\x00\x03\x00\x00'

参考
....

*note array: 6. モジュール

     一様なデータ型からなるバイナリ記録データのパック。

*note json: 76. モジュール

     JSON encoder and decoder.

*note pickle: 95. モジュール

     Python object serialization.


File: python.info,  Node: Applications,  Next: クラス<3>,  Prev: 書式文字列,  Up: struct --- バイト列をパックされたバイナリデータとして解釈する

5.7.1.6 Applications
....................

Two main applications for the *note struct: c0. module exist, data
interchange between Python and C code within an application or another
application compiled using the same compiler (*note native formats:
230d.), and data interchange between applications using agreed upon data
layout (*note standard formats: 230e.).  Generally speaking, the format
strings constructed for these two domains are distinct.

* Menu:

* Native Formats::
* Standard Formats::


File: python.info,  Node: Native Formats,  Next: Standard Formats,  Up: Applications

5.7.1.7 Native Formats
......................

When constructing format strings which mimic native layouts, the
compiler and machine architecture determine byte ordering and padding.
In such cases, the ‘@’ format character should be used to specify native
byte ordering and data sizes.  Internal pad bytes are normally inserted
automatically.  It is possible that a zero-repeat format code will be
needed at the end of a format string to round up to the correct byte
boundary for proper alignment of consecutive chunks of data.

Consider these two simple examples (on a 64-bit, little-endian machine):

     >>> calcsize('@lhl')
     24
     >>> calcsize('@llh')
     18

Data is not padded to an 8-byte boundary at the end of the second format
string without the use of extra padding.  A zero-repeat format code
solves that problem:

     >>> calcsize('@llh0l')
     24

The ‘'x'’ format code can be used to specify the repeat, but for native
formats it is better to use a zero-repeat format like ‘'0l'’.

By default, native byte ordering and alignment is used, but it is better
to be explicit and use the ‘'@'’ prefix character.


File: python.info,  Node: Standard Formats,  Prev: Native Formats,  Up: Applications

5.7.1.8 Standard Formats
........................

When exchanging data beyond your process such as networking or storage,
be precise.  Specify the exact byte order, size, and alignment.  Do not
assume they match the native order of a particular machine.  For
example, network byte order is big-endian, while many popular CPUs are
little-endian.  By defining this explicitly, the user need not care
about the specifics of the platform their code is running on.  The first
character should typically be ‘<’ or ‘>’ (or ‘!’).  Padding is the
responsibility of the programmer.  The zero-repeat format character
won't work.  Instead, the user must explicitly add ‘'x'’ pad bytes where
needed.  Revisiting the examples from the previous section, we have:

     >>> calcsize('<qh6xq')
     24
     >>> pack('<qh6xq', 1, 2, 3) == pack('@lhl', 1, 2, 3)
     True
     >>> calcsize('@llh')
     18
     >>> pack('@llh', 1, 2, 3) == pack('<qqh', 1, 2, 3)
     True
     >>> calcsize('<qqh6x')
     24
     >>> calcsize('@llh0l')
     24
     >>> pack('@llh0l', 1, 2, 3) == pack('<qqh6x', 1, 2, 3)
     True

The above results (executed on a 64-bit machine) aren't guaranteed to
match when executed on different machines.  For example, the examples
below were executed on a 32-bit machine:

     >>> calcsize('<qqh6x')
     24
     >>> calcsize('@llh0l')
     12
     >>> pack('@llh0l', 1, 2, 3) == pack('<qqh6x', 1, 2, 3)
     False


File: python.info,  Node: クラス<3>,  Prev: Applications,  Up: struct --- バイト列をパックされたバイナリデータとして解釈する

5.7.1.9 クラス
..............

*note struct: c0. モジュールは次の型を定義します:

 -- クラス: struct.Struct (format)

     フォーマット文字列 'format' に従ってバイナリデータを読み書きする、
     新しい Struct オブジェクトを返します。 ‘Struct’ オブジェクトを一度
     作ってからそのメソッドを呼び出すと、フォーマット文字列のコンパイル
     が一度だけになるので、モジュールレベルの関数を同じフォーマットで呼
     び出すよりも効率的です。

          注釈: The compiled versions of the most recent format strings
          passed to the module-level functions are cached, so programs
          that use only a few format strings needn't worry about reusing
          a single *note Struct: 1615. instance.

     コンパイルされた Struct オブジェクトは以下のメソッドと属性をサポー
     トします:

      -- メソッド: pack (v1, v2, ...)

          *note pack(): 1248. 関数と同じ、コンパイルされたフォーマットを
          利用するメソッドです。 (‘len(result)’ は *note size: 2314. と
          等しいでしょう)

      -- メソッド: pack_into (buffer, offset, v1, v2, ...)

          *note pack_into(): 2304. 関数と同じ、コンパイルされたフォーマ
          ットを利用するメソッドです。

      -- メソッド: unpack (buffer)

          *note unpack(): 1731. 関数と同じ、コンパイルされたフォーマット
          を利用するメソッドです。 (buffer のバイト数は *note size:
          2314. と等しくなければなりません)。

      -- メソッド: unpack_from (buffer, offset=0)

          *note unpack_from(): 2305. 関数と同じ、コンパイルされたフォー
          マットを利用するメソッドです。 ('offset' を始点とする buffer の
          バイト数は少なくとも *note size: 2314. 以上でなければなりませ
          ん)。

      -- メソッド: iter_unpack (buffer)

          *note iter_unpack(): f8b. 関数と同じ、コンパイルされたフォーマ
          ットを利用するメソッドです。 (buffer のバイト数は *note size:
          2314. の倍数でなければなりません)。

          Added in version 3.4.

      -- の属性: format

          この Struct オブジェクトを作成する時に利用されたフォーマット文
          字列です。

          バージョン 3.7 で変更: The format string type is now *note
          str: 418. instead of *note bytes: 1a4.

      -- の属性: size

          *note format: 5eb. 属性に対応する構造体の (従って *note
          pack(): 1248. メソッドによって作成されるバイト列オブジェクトの
          ) サイズです。

     バージョン 3.13 で変更: The 'repr()' of structs has changed.  It is
     now:

          >>> Struct('i')
          Struct('i')


File: python.info,  Node: codecs --- codec レジストリと基底クラス,  Prev: struct --- バイト列をパックされたバイナリデータとして解釈する,  Up: バイナリデータ処理

5.7.2 ‘codecs’ -- codec レジストリと基底クラス
----------------------------------------------

'ソースコード:' Lib/codecs.py(1)

__________________________________________________________________

このモジュールは、標準的な Python codec (エンコーダとデコーダ) 用の基底
クラスを定義し、codec とエラー処理検索プロセスを管理する内部の Python
codec レジストリへのアクセスを提供します。多くの codec はテキストをバイ
トにエンコードする (そしてバイトをテキストにデコードする) *note
テキストエンコーディング: 20de. ですが、テキストをテキストに、またはバイ
トをバイトにエンコードする codec も提供されています。カスタムの codec は
任意の型間でエンコードとデコードを行えますが、一部のモジュール機能は
*note テキストエンコーディング: 20de. か *note bytes: 1a4. へのエンコー
ドのみに制限されています。

このモジュールでは、任意の codec でエンコードやデコードを行うための、以
下の関数が定義されています。

 -- の関数: codecs.encode (obj, encoding='utf-8', errors='strict')

     'encoding' に記載された codec を使用して 'obj' をエンコードします。

     希望のエラー処理スキームを 'errors' に設定することができます。デフ
     ォルトのエラーハンドラ (エラー処理関数) は ‘'strict'’ です。これは
     エンコードエラーは *note ValueError: 1e3. (もしくは *note
     UnicodeEncodeError: 643. のような、より codec に固有のサブクラス) を
     送出することを意味します。codec エラー処理についてのより詳しい情報
     は *note Codec 基底クラス: 231a. を参照してください。

 -- の関数: codecs.decode (obj, encoding='utf-8', errors='strict')

     'encoding' に記載された codec を使用して 'obj' をデコードします。

     希望のエラー処理スキームを 'errors' に設定することができます。デフ
     ォルトのエラーハンドラは ‘'strict'’ です。これはデコードエラーは
     *note ValueError: 1e3. (もしくは *note UnicodeDecodeError: 9e1. の
     ような、より codec に固有のサブクラス) を送出することを意味します。
     codec エラー処理についてのより詳しい情報は *note Codec 基底クラス:
     231a. を参照してください。

各 codec についての詳細も、次のようにして直接調べることができます。

 -- の関数: codecs.lookup (encoding)

     Python codec レジストリから codec 情報を探し、以下で定義するような
     *note CodecInfo: 1660. オブジェクトを返します。

     エンコーディングの検索は、まずレジストリのキャッシュから行います。
     見つからなければ、登録されている検索関数のリストから探します。
     *note CodecInfo: 1660. オブジェクトが一つも見つからなければ *note
     LookupError: 2131. を送出します。見つかったら、その *note
     CodecInfo: 1660. オブジェクトはキャッシュに保存され、呼び出し側に返
     されます。

 -- クラス: codecs.CodecInfo (encode, decode, streamreader=None,
          streamwriter=None, incrementalencoder=None,
          incrementaldecoder=None, name=None)

     codec レジストリ内を検索する場合の、codec の詳細です。コントラクタ
     引数は、次の同名の属性に保存されます。

      -- の属性: name

          エンコーディングの名前です。

      -- の属性: encode
      -- の属性: decode

          ステートレスなエンコーディングとデコーディングの関数です。これ
          らは、Codec インスタンスの *note encode(): 231e. メソッドと
          *note decode(): 231f. メソッドと同じインターフェースを持ってい
          る必要があります (see *note Codec のインターフェース: 2320. を
          参照)。この関数またはメソッドは、ステートレスモードで動作する
          ことが想定されています。

      -- の属性: incrementalencoder
      -- の属性: incrementaldecoder

          インクリメンタル・エンコーダとデコーダのクラスまたはファクトリ
          関数です。これらは、基底クラスの *note IncrementalEncoder:
          2323. と *note IncrementalDecoder: 2324. が定義するインターフ
          ェースをそれぞれ提供する必要があります。インクリメンタルな
          codec は、ステート (内部状態) を保持することができます。

      -- の属性: streamwriter
      -- の属性: streamreader

          ストリームライターとリーダーのクラスまたはファクトリ関数です。
          これらは、基底クラスの *note StreamWriter: 2327. と *note
          StreamReader: 2328. が定義するインターフェースをそれぞれ提供す
          る必要があります。ストリーム codec は、ステートを保持すること
          ができます。

さまざまな codec 構成要素へのアクセスを簡便化するために、このモジュール
は以下のような関数を提供しています。これらの関数は、 codec の検索に
*note lookup(): 931. を使います:

 -- の関数: codecs.getencoder (encoding)

     与えられたエンコーディングに対する codec を検索し、エンコーダ関数を
     返します。

     エンコーディングが見つからなければ *note LookupError: 2131. を送出
     します。

 -- の関数: codecs.getdecoder (encoding)

     与えられたエンコーディングに対する codec を検索し、デコーダ関数を返
     します。

     エンコーディングが見つからなければ *note LookupError: 2131. を送出
     します。

 -- の関数: codecs.getincrementalencoder (encoding)

     与えられたエンコーディングに対する codec を検索し、インクリメンタル
     ・エンコーダクラスまたはファクトリ関数を返します。

     エンコーディングが見つからないか、 codec がインクリメンタル・エンコ
     ーダをサポートしなければ *note LookupError: 2131. を送出します。

 -- の関数: codecs.getincrementaldecoder (encoding)

     与えられたエンコーディングに対する codec を検索し、インクリメンタル
     ・デコーダクラスまたはファクトリ関数を返します。

     エンコーディングが見つからないか、 codec がインクリメンタル・デコー
     ダをサポートしなければ *note LookupError: 2131. を送出します。

 -- の関数: codecs.getreader (encoding)

     与えられたエンコーディングに対する codec を検索し、*note
     StreamReader: 2328. クラスまたはファクトリ関数を返します。

     エンコーディングが見つからなければ *note LookupError: 2131. を送出
     します。

 -- の関数: codecs.getwriter (encoding)

     与えられたエンコーディングに対する codec を検索し、*note
     StreamWriter: 2327. クラスまたはファクトリ関数を返します。

     エンコーディングが見つからなければ *note LookupError: 2131. を送出
     します。

次のように、適切な codec 検索関数を登録することで、カスタムの codecs を
利用することができます。

 -- の関数: codecs.register (search_function)

     Register a codec search function.  Search functions are expected to
     take one argument, being the encoding name in all lower case
     letters with hyphens and spaces converted to underscores, and
     return a *note CodecInfo: 1660. object.  In case a search function
     cannot find a given encoding, it should return ‘None’.

     バージョン 3.9 で変更: Hyphens and spaces are converted to
     underscore.

 -- の関数: codecs.unregister (search_function)

     Unregister a codec search function and clear the registry's cache.
     If the search function is not registered, do nothing.

     Added in version 3.10.

エンコードされたテキストファイルを処理する場合、組み込みの *note open():
4e5. とそれに関連付けられた *note io: 73. モジュールの使用が推奨されてい
ますが、このモジュールは追加のユーティリティ関数とクラスを提供し、バイナ
リファイルを処理する場合に幅広い codecs を利用できるようにします。

 -- の関数: codecs.open (filename, mode='r', encoding=None,
          errors='strict', buffering=-1)

     エンコードされたファイルを 'mode' を使って開き、透過的なエンコード
     /デコードを提供する *note StreamReaderWriter: 2330. のインスタンス
     を返します。デフォルトのファイルモードは ‘'r'’ 、つまり、読み出しモ
     ードでファイルを開きます。

          注釈: 'encoding' が ‘None’ でなければ、下層のエンコードされた
          ファイルは、常にバイナリモードで開きます。読み書き時に、
          ‘'\n'’ の自動変換は行われません。'mode' 引数は、組み込みの
          *note open(): 4e5. 関数が受け入れる任意のバイナリモードにする
          ことができます。‘'b'’ が自動的に付加されます。

     'encoding' は、そのファイルに対して使用されるエンコーディングを指定
     します。バイトにエンコードする、あるいはバイトからデコードするすべ
     てのエンコーディングが許可されます。ファイルメソッドがサポートする
     データ型は、使用される codec によって異なります。

     エラーハンドリングのために 'errors' を渡すことができます。これはデ
     フォルトでは ‘'strict'’ で、エンコード時にエラーがあれば *note
     ValueError: 1e3. を送出します。

     'buffering' has the same meaning as for the built-in *note open():
     4e5. function.  It defaults to -1 which means that the default
     buffer size will be used.

     バージョン 3.11 で変更: ‘'U'’ モードは削除されました。

 -- の関数: codecs.EncodedFile (file, data_encoding, file_encoding=None,
          errors='strict')

     透過的なエンコード変換を行うファイルのラップされたバージョンである
     、*note StreamRecoder: 195c. インスタンスを返します。元のファイルは
     、ラップされたバージョンが閉じられる時に、閉じられます。

     ラップされたファイルに書き込まれたデータは、指定された
     'data_encoding' に従ってデコードされ、次に 'file_encoding' を使用し
     て元のファイルにバイトとして書き出されます。元のファイルから読み出
     されたバイトは、'file_encoding' に従ってデコードされ、結果は
     'data_encoding' を使用してエンコードされます。

     'file_encoding' が与えられなければ、'data_encoding' がデフォルトに
     なります。

     エラーハンドリングのために 'errors' を渡すことができます。これはデ
     フォルトでは ‘'strict'’ で、エンコード時にエラーがあれば *note
     ValueError: 1e3. を送出します。

 -- の関数: codecs.iterencode (iterator, encoding, errors='strict',
          **kwargs)

     インクリメンタル・エンコーダを使って、 'iterator' から供給される入
     力を反復的にエンコードします。この関数は *note generator: 1035. で
     す。 'errors' 引数は (他のあらゆるキーワード引数と同様に) インクリ
     メンタル・エンコーダにそのまま引き渡されます。

     この関数では、コーデックはエンコードするテキストの *note str: 418.
     オブジェクトを受け付ける必要があります。 従って、 ‘base64_codec’ の
     ようなバイトからバイトへのエンコーダはサポートしていません。

 -- の関数: codecs.iterdecode (iterator, encoding, errors='strict',
          **kwargs)

     インクリメンタル・デコーダを使って、 'iterator' から供給される入力
     を反復的にデコードします。この関数は *note generator: 1035. です。
     'errors' 引数は (他のあらゆるキーワード引数と同様に) インクリメンタ
     ル・デコーダにそのまま引き渡されます。

     この関数では、コーデックはエンコードする *note bytes: 1a4. オブジェ
     クトを受け付ける必要があります。 従って、 ‘rot_13’ のようなテキスト
     からテキストへのエンコーダが *note iterencode(): 2332. で同等に使え
     るとしても、この関数ではサポートしていません。

このモジュールは以下のような定数も定義しています。プラットフォーム依存な
ファイルを読み書きするのに役立ちます:

 -- データ: codecs.BOM
 -- データ: codecs.BOM_BE
 -- データ: codecs.BOM_LE
 -- データ: codecs.BOM_UTF8
 -- データ: codecs.BOM_UTF16
 -- データ: codecs.BOM_UTF16_BE
 -- データ: codecs.BOM_UTF16_LE
 -- データ: codecs.BOM_UTF32
 -- データ: codecs.BOM_UTF32_BE
 -- データ: codecs.BOM_UTF32_LE

     これらの定数は、いくつかのエンコーディングの Unicode のバイトオーダ
     マーク (BOM) で、様々なバイトシーケンスを定義します。これらは、
     UTF-16 と UTF-32 のデータストリームで使用するバイトオーダを指定した
     り、 UTF-8 で Unicode シグネチャとして使われます。 *note BOM_UTF16:
     2338. は、プラットフォームのネイティブバイトオーダによって *note
     BOM_UTF16_BE: 2339. または *note BOM_UTF16_LE: 233a. です。 *note
     BOM: 2334. は *note BOM_UTF16: 2338. のエイリアスです。同様に、
     *note BOM_LE: 2336. は *note BOM_UTF16_LE: 233a. の、 *note BOM_BE:
     2335. は *note BOM_UTF16_BE: 2339. のエイリアスです。その他の定数は
     UTF-8 と UTF-32 エンコーディングの BOM を表します。

* Menu:

* Codec 基底クラス::
* エンコーディングと Unicode::
* 標準エンコーディング::
* Python 特有のエンコーディング::
* encodings.idna: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA. アプリケーションにおける国際化ドメイン名 (IDNA)
* encodings.mbcs: encodings mbcs --- Windows ANSI コードページ. Windows ANSI コードページ
* encodings.utf_8_sig: encodings utf_8_sig --- BOM 印付き UTF-8. BOM 印付き UTF-8

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/codecs.py


File: python.info,  Node: Codec 基底クラス,  Next: エンコーディングと Unicode,  Up: codecs --- codec レジストリと基底クラス

5.7.2.1 Codec 基底クラス
........................

*note codecs: 14. モジュールは、 codec オブジェクトを操作するインターフ
ェースを定義する一連の基底クラスを定義します。このモジュールは、カスタム
の codec の実装の基礎として使用することもできます。

Python で codec として使えるようにするには、ステートレスエンコーダ、ステ
ートレスデコーダ、ストリームリーダ、ストリームライタの 4 つのインターフ
ェースを定義する必要があります。通常は、ストリームリーダとライタはステー
トレスエンコーダとデコーダを再利用して、ファイルプロトコルを実装します。
codec の作者は、codec がエンコードとデコードのエラーの処理方法も定義する
必要があります。
* Menu:

* エラーハンドラ::
* ステートレスなエンコードとデコード::
* インクリメンタルなエンコードとデコード::
* ストリームのエンコードとデコード::


File: python.info,  Node: エラーハンドラ,  Next: ステートレスなエンコードとデコード,  Up: Codec 基底クラス

5.7.2.2 エラーハンドラ
......................

エラー処理の簡便化と標準化のため、コーデックは、'errors' 文字列引数を指
定した場合に別のエラー処理を行うような仕組みを実装してもかまいません:

     >>> 'German ß, ♬'.encode(encoding='ascii', errors='backslashreplace')
     b'German \\xdf, \\u266c'
     >>> 'German ß, ♬'.encode(encoding='ascii', errors='xmlcharrefreplace')
     b'German &#223;, &#9836;'

The following error handlers can be used with all Python *note
標準エンコーディング: d86. codecs:

値                            意味
                              
----------------------------------------------------------------------------------
                              
‘'strict'’                    *note UnicodeError: 1275. (または、そのサブクラス
                              ) を送出します。これがデフォルトの動作です。
                              *note strict_errors(): 2341. で実装されています。
                              
                              
‘'ignore'’                    不正な形式のデータを無視し、何も通知することなく
                              処理を継続します。*note ignore_errors(): 2342. で
                              実装されています。
                              
                              
‘'replace'’                   Replace with a replacement marker.  On encoding,
                              use ‘?’ (ASCII character).  On decoding, use ‘?’
                              (U+FFFD, the official REPLACEMENT CHARACTER).
                              Implemented in *note replace_errors(): 2343.
                              
                              
‘'backslashreplace'’          Replace with backslashed escape sequences.  On
                              encoding, use hexadecimal form of Unicode code
                              point with formats ‘\xHH’ ‘\uXXXX’ ‘\UXXXXXXXX’.
                              On decoding, use hexadecimal form of byte value
                              with format ‘\xHH’.  Implemented in
                              *note backslashreplace_errors(): 2344.
                              
                              
‘'surrogateescape'’           デコード時には、バイト列を ‘U+DC80’ から ‘U+DCFF’
                              の範囲の個々のサロゲートコードで置き換えます。デ
                              ータのエンコード時に ‘'surrogateescape'’ エラーハ
                              ンドラが使用されると、このコードは同じバイト列に
                              戻されます。 (詳しくは PEP 383(1) を参照。)
                              

The following error handlers are only applicable to encoding (within
*note text encodings: 20de.):

値                            意味
                              
----------------------------------------------------------------------------------
                              
‘'xmlcharrefreplace'’         Replace with XML/HTML numeric character
                              reference, which is a decimal form of Unicode
                              code point with format ‘&#NUM;’.  Implemented in
                              *note xmlcharrefreplace_errors(): 2345.
                              
                              
‘'namereplace'’               Replace with ‘\N{...}’ escape sequences, what
                              appears in the braces is the Name property from
                              Unicode Character Database.  Implemented in
                              *note namereplace_errors(): 2346.
                              

さらに、次のエラーハンドラは与えられた codec に特有です:

値                      Codecs                       意味
                                                     
-----------------------------------------------------------------------------------------------------
                                                     
‘'surrogatepass'’       utf-8, utf-16, utf-32,       Allow encoding and decoding surrogate code
                        utf-16-be, utf-16-le,        point (‘U+D800’ - ‘U+DFFF’) as normal code
                        utf-32-be, utf-32-le         point.  Otherwise these codecs treat the
                                                     presence of surrogate code point in
                                                     *note str: 418. as an error.
                                                     

Added in version 3.1: ‘'surrogateescape'’ および ‘'surrogatepass'’ エラ
ーハンドラ。

バージョン 3.4 で変更: The ‘'surrogatepass'’ error handler now works
with utf-16* and utf-32* codecs.

Added in version 3.5: ‘'namereplace'’ エラーハンドラです。

バージョン 3.5 で変更: The ‘'backslashreplace'’ error handler now works
with decoding and translating.

次のように、名前付きの新しいエラーハンドラを登録することで、許可される値
の集合を拡張することができます。

 -- の関数: codecs.register_error (name, error_handler)

     エラーハンドラ 'error_handler' を名前 'name' で登録します。エンコー
     ド中およびデコード中にエラーが送出された場合、'name' が errors 引数
     として指定されていれば 'error_handler' が呼び出されます。

     'error_handler' はエラーの場所に関する情報の入った *note
     UnicodeEncodeError: 643. インスタンスとともに呼び出されます。エラー
     処理関数はこの例外を送出するか、別の例外を送出するか、入力のエンコ
     ードできなかった部分の代替文字列とエンコードを再開する場所が入った
     タプルを返す必要があります。代替文字列は *note str: 418. または
     *note bytes: 1a4. のいずれかにすることができます。代替文字列がバイ
     ト列である場合、エンコーダは単に出力バッファにそれをコピーします。
     代替文字列が文字列である場合、エンコーダは代替文字列をエンコードし
     ます。元の入力中の指定位置からエンコードが再開されます。位置を負の
     値にすると、入力文字列の末端からの相対位置として扱われます。境界の
     外側にある位置を返した場合には *note IndexError: 14de. が送出されま
     す。

     デコードと翻訳の動作は似ていますが、エラーハンドラに渡されるのが
     *note UnicodeDecodeError: 9e1. か *note UnicodeTranslateError:
     21f9. である点と、エラーハンドラの置換した内容が直接出力されるとい
     う点が異なります。

登録済みのエラーハンドラ (標準エラーハンドラを含む) は、次のようにその名
前で検索することができます。

 -- の関数: codecs.lookup_error (name)

     名前 'name' で登録済みのエラーハンドラを返します。

     エラーハンドラが見つからなければ *note LookupError: 2131. を送出し
     ます。

以下の標準エラーハンドラも、モジュールレベルの関数として利用できます。

 -- の関数: codecs.strict_errors (exception)

     Implements the ‘'strict'’ error handling.

     Each encoding or decoding error raises a *note UnicodeError: 1275.

 -- の関数: codecs.ignore_errors (exception)

     Implements the ‘'ignore'’ error handling.

     Malformed data is ignored; encoding or decoding is continued
     without further notice.

 -- の関数: codecs.replace_errors (exception)

     Implements the ‘'replace'’ error handling.

     Substitutes ‘?’ (ASCII character) for encoding errors or ‘?’
     (U+FFFD, the official REPLACEMENT CHARACTER) for decoding errors.

 -- の関数: codecs.backslashreplace_errors (exception)

     Implements the ‘'backslashreplace'’ error handling.

     Malformed data is replaced by a backslashed escape sequence.  On
     encoding, use the hexadecimal form of Unicode code point with
     formats ‘\xHH’ ‘\uXXXX’ ‘\UXXXXXXXX’.  On decoding, use the
     hexadecimal form of byte value with format ‘\xHH’.

     バージョン 3.5 で変更: Works with decoding and translating.

 -- の関数: codecs.xmlcharrefreplace_errors (exception)

     Implements the ‘'xmlcharrefreplace'’ error handling (for encoding
     within *note text encoding: 20de. only).

     The unencodable character is replaced by an appropriate XML/HTML
     numeric character reference, which is a decimal form of Unicode
     code point with format ‘&#NUM;’ .

 -- の関数: codecs.namereplace_errors (exception)

     Implements the ‘'namereplace'’ error handling (for encoding within
     *note text encoding: 20de. only).

     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}’ .

     Added in version 3.5.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0383/


File: python.info,  Node: ステートレスなエンコードとデコード,  Next: インクリメンタルなエンコードとデコード,  Prev: エラーハンドラ,  Up: Codec 基底クラス

5.7.2.3 ステートレスなエンコードとデコード
..........................................

基底の *note Codec: 2348. クラスは以下のメソッドを定義します。これらのメ
ソッドは、内部状態を持たないエンコーダ／デコーダ関数のインターフェースを
定義します:

 -- クラス: codecs.Codec

      -- メソッド: encode (input, errors='strict')

          オブジェクト 'input' エンコードし、(出力オブジェクト, 消費した
          長さ) のタプルを返します。例えば、 *note
          テキストエンコーディング: 20de. は文字列オブジェクトを特有の文
          字セット (例えば ‘cp1252’ や ‘iso-8859-1’) を用いてバイト列オ
          ブジェクトに変換します。

          'errors' 引数は適用するエラー処理を定義します。‘'strict'’ 処理
          がデフォルトです。

          このメソッドは *note Codec: 2348. に内部状態を保存してはなりま
          せん。効率よくエンコードするために状態を保持しなければならない
          ような codecs には *note StreamWriter: 2327. を使ってください
          。

          エンコーダは長さが 0 の入力を処理できなければなりません。この
          場合、空のオブジェクトを出力オブジェクトとして返さなければなり
          ません。

      -- メソッド: decode (input, errors='strict')

          オブジェクト 'input' をデコードし、(出力オブジェクト, 消費した
          長さ) のタプルを返します。例えば、 *note
          テキストエンコーディング: 20de. は、特定の文字集合エンコーディ
          ングでエンコードされたバイト列オブジェクトを文字列オブジェクト
          に変換します。

          テキストエンコーディングとバイト列からバイト列への codec では
          、'input' は bytes オブジェクト、または読み出し専用のバッファ
          インターフェースを提供するオブジェクトである必要があります。例
          えば、buffer オブジェクトやメモリマップドファイルでなければな
          りません。

          'errors' 引数は適用するエラー処理を定義します。‘'strict'’ 処理
          がデフォルトです。

          このメソッドは、 *note Codec: 2348. インスタンスに内部状態を保
          存してはなりません。効率よくエンコード／デコードするために状態
          を保持しなければならないような codecs には *note StreamReader:
          2328. を使ってください。

          デコーダは長さが 0 の入力を処理できなければなりません。この場
          合、空のオブジェクトを出力オブジェクトとして返さなければなりま
          せん。


File: python.info,  Node: インクリメンタルなエンコードとデコード,  Next: ストリームのエンコードとデコード,  Prev: ステートレスなエンコードとデコード,  Up: Codec 基底クラス

5.7.2.4 インクリメンタルなエンコードとデコード
..............................................

*note IncrementalEncoder: 2323. クラスおよび *note IncrementalDecoder:
2324. クラスはそれぞれインクリメンタル・エンコードおよびデコードのための
基本的なインターフェースを提供します。エンコード／デコードは内部状態を持
たないエンコーダ／デコーダを一度呼び出すことで行なわれるのではなく、イン
クリメンタル・エンコーダ／デコーダの *note encode(): 234a./*note
decode(): 234b. メソッドを複数回呼び出すことで行なわれます。インクリメン
タル・エンコーダ／デコーダはメソッド呼び出しの間エンコード／デコード処理
の進行を管理します。

*note encode(): 234a./*note decode(): 234b. メソッド呼び出しの出力結果を
まとめたものは、入力をひとまとめにして内部状態を持たないエンコーダ／デコ
ーダでエンコード／デコードしたものと同じになります。

* Menu:

* IncrementalEncoder オブジェクト::
* IncrementalDecoder オブジェクト::


File: python.info,  Node: IncrementalEncoder オブジェクト,  Next: IncrementalDecoder オブジェクト,  Up: インクリメンタルなエンコードとデコード

5.7.2.5 IncrementalEncoder オブジェクト
.......................................

*note IncrementalEncoder: 2323. クラスは入力を複数ステップでエンコードす
るのに使われます。全てのインクリメンタル・エンコーダが Python codec レジ
ストリと互換性を持つために定義すべきメソッドとして、このクラスには以下の
メソッドが定義されています。

 -- クラス: codecs.IncrementalEncoder (errors='strict')

     *note IncrementalEncoder: 2323. インスタンスのコンストラクタ。

     全てのインクリメンタル・エンコーダはこのコンストラクタインターフェ
     ースを提供しなければなりません。さらにキーワード引数を付け加えるの
     は構いませんが、Python codec レジストリで利用されるのはここで定義さ
     れているものだけです。

     *note IncrementalEncoder: 2323. は、 'errors' キーワード引数を提供
     することで、様々なエラー取扱方法を実装することができます。取り得る
     値については *note エラーハンドラ: 1751. を参照してください。

     'errors' 引数は、同名の属性に代入されます。この属性を変更すると、
     *note IncrementalEncoder: 2323. オブジェクトが生きている間に、異な
     るエラー処理方法に切り替えることができるようになります。

      -- メソッド: encode (object, final=False)

          'object' を(エンコーダの現在の状態を考慮に入れて)エンコードし
          、得られたエンコードされたオブジェクトを返します。 *note
          encode(): ecc. 呼び出しがこれで最後という時には 'final' は真で
          なければなりません(デフォルトは偽です)。

      -- メソッド: reset ()

          エンコーダを初期状態にリセットします。出力は破棄されます。
          ‘.encode(object, final=True)’ を呼び出して、必要に応じて空バイ
          ト列またはテキスト文字列を渡すことにより、エンコーダをリセット
          し、出力を取得します。

      -- メソッド: getstate ()

          エンコーダの現在の状態を返します。それは必ず整数でなければなり
          ません。実装は、‘0’ が最も一般的な状態であることを保証すべきで
          す。 (整数より複雑な状態は、状態を marshal/pickle して生じた文
          字列のバイトを整数にコード化することによって整数に変換すること
          ができます。)

      -- メソッド: setstate (state)

          エンコーダの状態を 'state' にセットします。 'state' は *note
          getstate(): 234f. によって返されたエンコーダ状態でなければなり
          ません。


File: python.info,  Node: IncrementalDecoder オブジェクト,  Prev: IncrementalEncoder オブジェクト,  Up: インクリメンタルなエンコードとデコード

5.7.2.6 IncrementalDecoder オブジェクト
.......................................

*note IncrementalDecoder: 2324. クラスは入力を複数ステップでデコードする
のに使われます。全てのインクリメンタル・デコーダが Python codec レジスト
リと互換性を持つために定義すべきメソッドとして、このクラスには以下のメソ
ッドが定義されています。

 -- クラス: codecs.IncrementalDecoder (errors='strict')

     *note IncrementalDecoder: 2324. インスタンスのコンストラクタ。

     全てのインクリメンタル・デコーダはこのコンストラクタインターフェー
     スを提供しなければなりません。さらにキーワード引数を付け加えるのは
     構いませんが、Python codec レジストリで利用されるのはここで定義され
     ているものだけです。

     *note IncrementalDecoder: 2324. は、 'errors' キーワード引数を提供
     することで、様々なエラー取扱方法を実装することができます。取り得る
     値については *note エラーハンドラ: 1751. を参照してください。

     'errors' 引数は、同名の属性に代入されます。この属性を変更すると、
     *note IncrementalDecoder: 2324. オブジェクトが生きている間に、異な
     るエラー処理方法に切り替えることができるようになります。

      -- メソッド: decode (object, final=False)

          'object' を(デコーダの現在の状態を考慮に入れて)デコードし、得
          られたデコードされたオブジェクトを返します。 *note decode():
          ecd. 呼び出しがこれで最後という時には 'final' は真でなければな
          りません(デフォルトは偽です)。もし 'final' が真ならばデコーダ
          は入力をデコードし切り全てのバッファをフラッシュしなければなり
          ません。そうできない場合(たとえば入力の最後に不完全なバイト列
          があるから)、デコーダは内部状態を持たない場合と同じようにエラ
          ーの取り扱いを開始しなければなりません(例外を送出するかもしれ
          ません)。

      -- メソッド: reset ()

          デコーダを初期状態にリセットします。

      -- メソッド: getstate ()

          デコーダの現在の状態を返します。これは2要素を含むタプルでなけ
          ればなりません。1番目はまだデコードされていない入力を含むバッ
          ファです。2番目は整数で、付加的な状態情報です (実装は ‘0’ が最
          も一般的な付加的な状態情報であることを保証すべきです)。この付
          加的な状態情報が ‘0’ である場合、デコーダを入力がバッファされ
          ていない状態に戻して、付加的な状態情報を ‘0’ にセットすること
          が可能でなければなりません。その結果、以前バッファされた入力を
          デコーダに与えることで、何の出力もせずにデコーダを前の状態に戻
          します。 (整数より複雑な付加的な状態情報は、情報を
          marshal/pickle して、結果として生じる文字列のバイト列を整数に
          エンコードすることで、整数に変換することができます。)

      -- メソッド: setstate (state)

          デコーダの状態を 'state' にセットします。 'state' は *note
          getstate(): 2354. によって返されたデコーダの状態でなければなり
          ません。


File: python.info,  Node: ストリームのエンコードとデコード,  Prev: インクリメンタルなエンコードとデコード,  Up: Codec 基底クラス

5.7.2.7 ストリームのエンコードとデコード
........................................

The *note StreamWriter: 2327. and *note StreamReader: 2328. classes
provide generic working interfaces which can be used to implement new
encoding submodules very easily.  See ‘encodings.utf_8’ for an example
of how this is done.

* Menu:

* StreamWriter オブジェクト::
* StreamReader オブジェクト::
* StreamReaderWriter オブジェクト::
* StreamRecoder オブジェクト::


File: python.info,  Node: StreamWriter オブジェクト,  Next: StreamReader オブジェクト,  Up: ストリームのエンコードとデコード

5.7.2.8 StreamWriter オブジェクト
.................................

*note StreamWriter: 2327. クラスは *note Codec: 2348. のサブクラスで、以
下のメソッドを定義しています。全てのストリームライタは、 Python の codec
レジストリとの互換性を保つために、これらのメソッドを定義する必要がありま
す。

 -- クラス: codecs.StreamWriter (stream, errors='strict')

     *note StreamWriter: 2327. インスタンスのコンストラクタです。

     全てのストリームライタはコンストラクタとしてこのインターフェースを
     提供しなければなりません。キーワード引数を追加しても構いませんが、
     Python の codec レジストリはここで定義されている引数だけを使います
     。

     'stream' 引数は、特定の codec に対応して、テキストまたはバイナリデ
     ータの書き込みが可能なファイルライクオブジェクトである必要がありま
     す。

     *note StreamWriter: 2327. は、 'errors' キーワード引数を提供するこ
     とで、様々なエラー取扱方法を実装することができます。下層のストリー
     ム codec がサポートできる標準エラーハンドラについては *note
     エラーハンドラ: 1751. を参照してください。

     'errors' 引数は、同名の属性に代入されます。この属性を変更すると、
     *note StreamWriter: 2327. オブジェクトが生きている間に、異なるエラ
     ー処理に変更できます。

      -- メソッド: write (object)

          'object' の内容をエンコードしてストリームに書き出します。

      -- メソッド: writelines (list)

          Writes the concatenated iterable of strings to the stream
          (possibly by reusing the *note write(): 2359. method).
          Infinite or very large iterables are not supported.  The
          standard bytes-to-bytes codecs do not support this method.

      -- メソッド: reset ()

          内部状態保持に使われた codec のバッファをリセットします。

          このメソッドが呼び出された場合、出力先データをきれいな状態にし
          、わざわざストリーム全体を再スキャンして状態を元に戻さなくても
          新しくデータを追加できるようにしなければなりません。

ここまでで挙げたメソッドの他にも、 *note StreamWriter: 2327. では背後に
あるストリームの他の全てのメソッドや属性を継承しなければなりません。


File: python.info,  Node: StreamReader オブジェクト,  Next: StreamReaderWriter オブジェクト,  Prev: StreamWriter オブジェクト,  Up: ストリームのエンコードとデコード

5.7.2.9 StreamReader オブジェクト
.................................

*note StreamReader: 2328. クラスは *note Codec: 2348. のサブクラスで、以
下のメソッドを定義しています。全てのストリームリーダは、 Python の codec
レジストリとの互換性を保つために、これらのメソッドを定義する必要がありま
す。

 -- クラス: codecs.StreamReader (stream, errors='strict')

     *note StreamReader: 2328. インスタンスのコンストラクタです。

     全てのストリームリーダはコンストラクタとしてこのインターフェースを
     提供しなければなりません。キーワード引数を追加しても構いませんが、
     Python の codec レジストリはここで定義されている引数だけを使います
     。

     'stream' 引数は、特定の codec に対応して、テキストまたはバイナリデ
     ータの読み出しが可能なファイルライクオブジェクトである必要がありま
     す。

     *note StreamReader: 2328. は、 'errors' キーワード引数を提供するこ
     とで、様々なエラー取扱方法を実装することができます。下層のストリー
     ム codec がサポートできる標準エラーハンドラについては *note
     エラーハンドラ: 1751. を参照してください。

     'errors' 引数は、同名の属性に代入されます。この属性を変更すると、
     *note StreamReader: 2328. オブジェクトが生きている間に、異なるエラ
     ー処理に変更できます。

     'errors' 引数に許される値の集合は *note register_error(): 143e. で
     拡張できます。

      -- メソッド: read (size=-1, chars=-1, firstline=False)

          ストリームからのデータをデコードし、デコード済のオブジェクトを
          返します。

          'chars' 引数は、いくつのデコードされたコードポイントまたはバイ
          ト列を返すかを表します。 *note read(): 235e. メソッドは、要求
          された数以上のデータを返すことはありませんが、データがそれより
          少ない場合には要求された数未満のデータを返す場合があります。

          'size' 引数は、デコード用に読み込むエンコードされたバイト列ま
          たはコードポイントの、およその最大バイト数を表します。デコーダ
          はこの値を適切な値に変更できます。デフォルト値 -1 の場合、可能
          な限り多くのデータを読み込みます。この引数の目的は、巨大なファ
          イルの一括デコードを防ぐことにあります。

          'firstline' フラグは、1行目さえ返せばその後の行でデコードエラ
          ーがあっても無視して十分だ、ということを示します。

          このメソッドは貪欲な読み込み戦略を取るべきです。すなわち、エン
          コーディング定義と size の値が許す範囲で、できるだけ多くのデー
          タを読むべきだということです。たとえば、ストリーム上にエンコー
          ディングの終端や状態の目印があれば、それも読み込みます。

      -- メソッド: readline (size=None, keepends=True)

          入力ストリームから1行読み込み、デコード済みのデータを返します
          。

          'size' が与えられた場合、ストリームの *note read(): 235e. メソ
          ッドに size 引数として渡されます。

          'keepends' が偽の場合には行末の改行が削除された行が返ります。

      -- メソッド: readlines (sizehint=None, keepends=True)

          入力ストリームから全ての行を読み込み、行のリストとして返します
          。

          'keepends' が真なら、改行は、codec の *note decode(): ecd. メ
          ソッドを使って実装され、リスト要素の中に含まれます。

          'sizehint' が与えられた場合、ストリームの *note read(): 235e.
          メソッドに 'size' 引数として渡されます。

      -- メソッド: reset ()

          内部状態保持に使われた codec のバッファをリセットします。

          ストリームの読み位置を再設定してはならないので注意してください
          。このメソッドはデコードの際にエラーから復帰できるようにするた
          めのものです。

ここまでで挙げたメソッドの他にも、 *note StreamReader: 2328. では背後に
あるストリームの他の全てのメソッドや属性を継承しなければなりません。


File: python.info,  Node: StreamReaderWriter オブジェクト,  Next: StreamRecoder オブジェクト,  Prev: StreamReader オブジェクト,  Up: ストリームのエンコードとデコード

5.7.2.10 StreamReaderWriter オブジェクト
........................................

*note StreamReaderWriter: 2330. は、読み書き両方に使えるストリームをラッ
プできる便利なクラスです。

*note lookup(): 931. 関数が返すファクトリ関数を使って、インスタンスを生
成するという設計です。

 -- クラス: codecs.StreamReaderWriter (stream, Reader, Writer,
          errors='strict')

     *note StreamReaderWriter: 2330. インスタンスを生成します。 'stream'
     はファイル類似のオブジェクトです。 'Reader' と 'Writer' は、それぞ
     れ *note StreamReader: 2328. と *note StreamWriter: 2327. インター
     フェースを提供するファクトリ関数かファクトリクラスでなければなりま
     せん。エラー処理は、ストリームリーダとライタで定義したものと同じよ
     うに行われます。

*note StreamReaderWriter: 2330. インスタンスは、 *note StreamReader:
2328. クラスと *note StreamWriter: 2327. クラスを合わせたインターフェー
スを継承します。元になるストリームからは、他のメソッドや属性を継承します
。


File: python.info,  Node: StreamRecoder オブジェクト,  Prev: StreamReaderWriter オブジェクト,  Up: ストリームのエンコードとデコード

5.7.2.11 StreamRecoder オブジェクト
...................................

*note StreamRecoder: 195c. はデータをあるエンコーディングから別のエンコ
ーディングに変換します。異なるエンコーディング環境を扱うとき、便利な場合
があります。

*note lookup(): 931. 関数が返すファクトリ関数を使って、インスタンスを生
成するという設計です。

 -- クラス: codecs.StreamRecoder (stream, encode, decode, Reader,
          Writer, errors='strict')

     Creates a *note StreamRecoder: 195c. instance which implements a
     two-way conversion: 'encode' and 'decode' work on the frontend —
     the data visible to code calling *note read(): 235e. and *note
     write(): 2359, while 'Reader' and 'Writer' work on the backend —
     the data in 'stream'.

     これらのオブジェクトを使って、たとえば、 Latin-1 から UTF-8 への変
     換、あるいは逆向きの変換を、透過的に行うことができます。

     'stream' 引数はファイルライクオブジェクトでなくてはなりません。

     'encode' 引数と 'decode' 引数は *note Codec: 2348. のインターフェー
     スに忠実でなくてはなりません。'Reader' と 'Writer' は、それぞれ
     *note StreamReader: 2328. と *note StreamWriter: 2327. のインターフ
     ェースを提供するオブジェクトのファクトリ関数かクラスでなくてはなり
     ません。

     エラー処理はストリーム・リーダやライタで定義されている方法と同じよ
     うに行われます。

*note StreamRecoder: 195c. インスタンスは、 *note StreamReader: 2328. と
*note StreamWriter: 2327. クラスを合わせたインターフェースを定義します。
また、元のストリームのメソッドと属性も継承します。


File: python.info,  Node: エンコーディングと Unicode,  Next: 標準エンコーディング,  Prev: Codec 基底クラス,  Up: codecs --- codec レジストリと基底クラス

5.7.2.12 エンコーディングと Unicode
...................................

文字列は内部的に ‘U+0000’-‘U+10FFFF’ の範囲のコードポイントのシーケンス
として格納されます (実装に関する詳細については PEP 393(1) を参照してくだ
さい)。 文字列オブジェクトが CPU とメモリの外で使用されるようになると、
エンディアンやこれらの配列をバイト列として格納する方法が問題になります。
他のコーデックでも同様ですが、文字列オブジェクトをバイト列に変換すること
は 'エンコード' と呼ばれます。 また、バイト列から文字列オブジェクトを再
生成することは 'デコード' と呼ばれます。 テキストをシリアライズするコー
デックには多くの種類があります。 それらは、集合的に term:‘テキストエンコ
ーディング <text encoding>’ と呼ばれます。

最も単純なテキストエンコーディング (‘'latin-1'’ または ‘'iso-8859-1'’) で
は、0-255 の範囲にあるコードポイントを ‘0x0’-‘0xff’ のバイトにマップしま
す。 つまり、この codec では ‘U+00FF’ 以上のコードポイントを含む文字列オ
ブジェクトをエンコードすることはできません。 このようなエンコード処理を
しようとすると、次のように *note UnicodeEncodeError: 643. が送出されます
(エラーメッセージの細かところは異なる場合があります。):
‘UnicodeEncodeError: 'latin-1' codec can't encode character '\u1234' in
position 3: ordinal not in range(256)’ 。

他のエンコーディングの一群 (charmap エンコーディングと呼ばれます) があり
、 Unicode コードポイントの別の部分集合と、それらから ‘0x0’-‘0xff’ のバ
イトへの対応付けを選択したものです。 これがどのように行なわれるかを知る
には、単にたとえば ‘encodings/cp1252.py’ (主に Windows で使われるエンコ
ーディングです) を開いてみてください。 256 文字のひとつの文字列定数があ
り、どの文字がどのバイト値へ対応付けられるかが示されています。

これらのエンコーディングはすべて、 Unicode に定義された 1114112 のコード
ポイントのうちの 256 だけをエンコードすることができます。 Unicode のすべ
てのコードポイントを格納するための単純で直接的な方法は、各コードポイント
を連続する4バイトとして格納することです。これには2つの可能性があります:
ビッグエンディアンまたはリトルエンディアンの順にバイトを格納することです
。これら2つのエンコーディングはそれぞれ ‘UTF-32-BE’ および ‘UTF-32-LE’ と
呼ばれます。それらのデメリットは、例えばリトルエンディアンのマシン上で
‘UTF-32-BE’ を使用すると、エンコードでもデコードでも常にバイト順を交換す
る必要があることです。‘UTF-32’ はこの問題を回避します: バイト順は、常に
自然なエンディアンに従います。しかし、これらのバイト順が異なるエンディア
ン性を持つ CPU によって読まれる場合、結局バイト順を交換しなければなりま
せん。‘UTF-16’ あるいは ‘UTF-32’ バイト列のエンディアン性を検出する目的
で、いわゆる BOM (「バイト・オーダー・マーク」) があります。これは
Unicode 文字 ‘U+FEFF’ です。この文字はすべての ‘UTF-16’ あるいは
‘UTF-32’ バイト列の前に置くことができます。この文字のバイトが交換された
バージョン (‘0xFFFE’) は、 Unicode テキストに現われてはならない不正な文
字です。したがって、‘UTF-16’ あるいは ‘UTF-32’ バイト列中の最初の文字が
‘U+FFFE’ であるように見える場合、デコードの際にバイトを交換しなければな
りません。不運にも文字 ‘U+FEFF’ は ‘ZERO WIDTH NO-BREAK SPACE’ として別
の目的を持っていました: 幅を持たず、単語を分割することを許容しない文字。
それは、例えばリガチャアルゴリズムにヒントを与えるために使用することがで
きます。 Unicode 4.0 で、‘ZERO WIDTH NO-BREAK SPACE’ としての ‘U+FEFF’ の
使用は廃止予定になりました (この役割は ‘U+2060’ (‘WORD JOINER’) によって
引き継がれました)。しかしながら、 Unicode ソフトウェアは、依然として両方
の役割の ‘U+FEFF’ を扱うことができなければなりません: BOM として、エンコ
ードされたバイトのメモリレイアウトを決定する手段であり、一旦バイト列が文
字列にデコードされたならば消えます; ‘ZERO WIDTH NO-BREAK SPACE’ として、
他の任意の文字のようにデコードされる通常の文字です。

さらにもう一つ Unicode 文字全てをエンコードできるエンコーディングがあり
、UTF-8 と呼ばれています。UTF-8 は8ビットエンコーディングで、したがって
UTF-8 にはバイト順の問題はありません。UTF-8 バイト列の各バイトは二つのパ
ートから成ります。二つはマーカ(上位数ビット)とペイロードです。マーカは
0ビットから4ビットの ‘1’ の列に ‘0’ のビットが一つ続いたものです。
Unicode 文字は次のようにエンコードされます (x はペイロードを表わし、連結
されると一つの Unicode 文字を表わします):

範囲                                    エンコーディング
                                        
-------------------------------------------------------------------------------------------
                                        
‘U-00000000’ ...  ‘U-0000007F’          0xxxxxxx
                                        
                                        
‘U-00000080’ ...  ‘U-000007FF’          110xxxxx 10xxxxxx
                                        
                                        
‘U-00000800’ ...  ‘U-0000FFFF’          1110xxxx 10xxxxxx 10xxxxxx
                                        
                                        
‘U-00010000’ ...  ‘U-0010FFFF’          11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
                                        

Unicode 文字の最下位ビットとは最も右にある x のビットです。

UTF-8 は8ビットエンコーディングなので BOM は必要とせず、デコードされた文
字列中の ‘U+FEFF’ は(たとえ最初の文字であったとしても) ‘ZERO WIDTH
NO-BREAK SPACE’ として扱われます。

外部からの情報無しには、文字列のエンコーディングにどのエンコーディングが
使われたのか信頼できる形で決定することは不可能です。どの charmap エンコ
ーディングもどんなランダムなバイト列でもデコードできます。しかし UTF-8 で
はそれは可能ではありません。任意のバイト列を許さないような構造を持ってい
るからです。UTF-8 エンコーディングであることを検知する信頼性を向上させる
ために、Microsoft は Notepad プログラム用に UTF-8 の変種 (Python では
‘"utf-8-sig"’ と呼んでいます) を考案しました。Unicode 文字がファイルに書
き込まれる前に UTF-8 でエンコードした BOM (バイト列では ‘0xef’, ‘0xbb’,
‘0xbf’ のように見えます) が書き込まれます。このようなバイト値で charmap
エンコードされたファイルが始まることはほとんどあり得ない (たとえば
iso-8859-1 では

          LATIN SMALL LETTER I WITH DIAERESIS
          RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
          INVERTED QUESTION MARK

のようになる)ので、‘utf-8-sig’ エンコーディングがバイト列から正しく推測
される確率を高めます。つまりここでは BOM はバイト列を生成する際のバイト
順を決定できるように使われているのではなく、エンコーディングを推測する助
けになる印として使われているのです。‘utf-8-sig’ codec はエンコーディング
の際ファイルに最初の3文字として ‘0xef’, ‘0xbb’, ‘0xbf’ を書き込みます。
デコーディングの際はファイルの先頭に現れたこれら3バイトはスキップします
。UTF-8 では BOM の使用は推奨されておらず、一般的には避けるべきです。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/


File: python.info,  Node: 標準エンコーディング,  Next: Python 特有のエンコーディング,  Prev: エンコーディングと Unicode,  Up: codecs --- codec レジストリと基底クラス

5.7.2.13 標準エンコーディング
.............................

Python には数多くの codec が組み込みで付属します。これらは C 言語の関数
、対応付けを行うテーブルの両方で提供されています。以下のテーブルでは
codec と、いくつかの良く知られている別名と、エンコーディングが使われる言
語を列挙します。別名のリスト、言語のリストともしらみつぶしに網羅されてい
るわけではありません。大文字と小文字、またはアンダースコアの代りにハイフ
ンにしただけの綴りも有効な別名です; そのため、例えば ‘'utf-8'’ は
‘'utf_8'’ codec の正当な別名です。

'CPython 実装の詳細:' いくつかの一般的なエンコーディングは、パフォーマン
スを改善するために codec の検索機構を回避することがあります。 このような
最適化の機会を認識するのは、 CPython の限定された (大文字小文字を区別し
ない) 別名に対してのみです: utf-8, utf8, latin-1, latin1, iso-8859-1,
iso8859-1, mbcs (Windows のみ), ascii, us-ascii, utf-16, utf16, utf-32,
utf32 およびダッシュの代わりにアンダースコアを用いたもの。 これらのエン
コーディングの別のつづりを使用すると実行時間の低下を招くかもしれません。

バージョン 3.6 で変更: us-ascii に対して最適化の機会が認識されるようにな
りました。

多くの文字セットは同じ言語をサポートしています。これらの文字セットは個々
の文字 (例えば、EURO SIGN がサポートされているかどうか) や、文字のコード
部分への割り付けが異なります。特に欧州言語では、典型的に以下の変種が存在
します:

   * ISO 8859 コードセット

   * Microsoft Windows コードページで、8859 コード形式から導出されている
     が、制御文字を追加のグラフィック文字と置き換えたもの

   * IBM EBCDIC コードページ

   * ASCII 互換の IBM PC コードページ

Codec                 別名                                 言語
                                                           
------------------------------------------------------------------------------------------------
                                                           
ascii                 646, us-ascii                        英語
                                                           
                                                           
big5                  big5-tw, csbig5                      繁体字中国語
                                                           
                                                           
big5hkscs             big5-hkscs, hkscs                    繁体字中国語
                                                           
                                                           
cp037                 IBM037, IBM039                       英語
                                                           
                                                           
cp273                 273, IBM273, csIBM273                ドイツ語
                                                           
                                                           Added in version 3.4.
                                                           
                                                           
cp424                 EBCDIC-CP-HE, IBM424                 ヘブライ語
                                                           
                                                           
cp437                 437, IBM437                          英語
                                                           
                                                           
cp500                 EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500   西ヨーロッパ言語
                                                           
                                                           
cp720                                                      アラビア語
                                                           
                                                           
cp737                                                      ギリシャ語
                                                           
                                                           
cp775                 IBM775                               バルト沿岸国
                                                           
                                                           
cp850                 850, IBM850                          西ヨーロッパ言語
                                                           
                                                           
cp852                 852, IBM852                          中央および東ヨーロッパ
                                                           
                                                           
cp855                 855, IBM855                          ブルガリア、ベラルーシ、マケドニア
                                                           、ロシア、セルビア
                                                           
                                                           
cp856                                                      ヘブライ語
                                                           
                                                           
cp857                 857, IBM857                          トルコ語
                                                           
                                                           
cp858                 858, IBM858                          西ヨーロッパ言語
                                                           
                                                           
cp860                 860, IBM860                          ポルトガル語
                                                           
                                                           
cp861                 861, CP-IS, IBM861                   アイスランド語
                                                           
                                                           
cp862                 862, IBM862                          ヘブライ語
                                                           
                                                           
cp863                 863, IBM863                          カナダ
                                                           
                                                           
cp864                 IBM864                               アラビア語
                                                           
                                                           
cp865                 865, IBM865                          デンマーク、ノルウェー
                                                           
                                                           
cp866                 866, IBM866                          ロシア語
                                                           
                                                           
cp869                 869, CP-GR, IBM869                   ギリシャ語
                                                           
                                                           
cp874                                                      タイ語
                                                           
                                                           
cp875                                                      ギリシャ語
                                                           
                                                           
cp932                 932, ms932, mskanji, ms-kanji,       日本語
                      windows-31j                          
                      
                                                           
cp949                 949, ms949, uhc                      韓国語
                                                           
                                                           
cp950                 950, ms950                           繁体字中国語
                                                           
                                                           
cp1006                                                     Urdu
                                                           
                                                           
cp1026                ibm1026                              トルコ語
                                                           
                                                           
cp1125                1125, ibm1125, cp866u, ruscii        ウクライナ語
                                                           
                                                           Added in version 3.4.
                                                           
                                                           
cp1140                ibm1140                              西ヨーロッパ言語
                                                           
                                                           
cp1250                windows-1250                         中央および東ヨーロッパ
                                                           
                                                           
cp1251                windows-1251                         ブルガリア、ベラルーシ、マケドニア
                                                           、ロシア、セルビア
                                                           
                                                           
cp1252                windows-1252                         西ヨーロッパ言語
                                                           
                                                           
cp1253                windows-1253                         ギリシャ語
                                                           
                                                           
cp1254                windows-1254                         トルコ語
                                                           
                                                           
cp1255                windows-1255                         ヘブライ語
                                                           
                                                           
cp1256                windows-1256                         アラビア語
                                                           
                                                           
cp1257                windows-1257                         バルト沿岸国
                                                           
                                                           
cp1258                windows-1258                         ベトナム
                                                           
                                                           
euc_jp                eucjp, ujis, u-jis                   日本語
                                                           
                                                           
euc_jis_2004          jisx0213, eucjis2004                 日本語
                                                           
                                                           
euc_jisx0213          eucjisx0213                          日本語
                                                           
                                                           
euc_kr                euckr, korean, ksc5601, ks_c-5601,   韓国語
                      ks_c-5601-1987, ksx1001, ks_x-1001   
                      
                                                           
gb2312                chinese, csiso58gb231280, euc-cn,    簡体字中国語
                      euccn, eucgb2312-cn, gb2312-1980,    
                      gb2312-80, iso-ir-58
                      
                                                           
gbk                   936, cp936, ms936                    Unified Chinese
                                                           
                                                           
gb18030               gb18030-2000                         Unified Chinese
                                                           
                                                           
hz                    hzgb, hz-gb, hz-gb-2312              簡体字中国語
                                                           
                                                           
iso2022_jp            csiso2022jp, iso2022jp,              日本語
                      iso-2022-jp                          
                      
                                                           
iso2022_jp_1          iso2022jp-1, iso-2022-jp-1           日本語
                                                           
                                                           
iso2022_jp_2          iso2022jp-2, iso-2022-jp-2           日本語, 韓国語, 簡体字中国語, 西欧
                                                           , ギリシャ語
                                                           
                                                           
iso2022_jp_2004       iso2022jp-2004, iso-2022-jp-2004     日本語
                                                           
                                                           
iso2022_jp_3          iso2022jp-3, iso-2022-jp-3           日本語
                                                           
                                                           
iso2022_jp_ext        iso2022jp-ext, iso-2022-jp-ext       日本語
                                                           
                                                           
iso2022_kr            csiso2022kr, iso2022kr,              韓国語
                      iso-2022-kr                          
                      
                                                           
latin_1               iso-8859-1, iso8859-1, 8859,         西ヨーロッパ言語
                      cp819, latin, latin1, L1             
                      
                                                           
iso8859_2             iso-8859-2, latin2, L2               中央および東ヨーロッパ
                                                           
                                                           
iso8859_3             iso-8859-3, latin3, L3               エスペラント、マルタ
                                                           
                                                           
iso8859_4             iso-8859-4, latin4, L4               バルト沿岸国
                                                           
                                                           
iso8859_5             iso-8859-5, cyrillic                 ブルガリア、ベラルーシ、マケドニア
                                                           、ロシア、セルビア
                                                           
                                                           
iso8859_6             iso-8859-6, arabic                   アラビア語
                                                           
                                                           
iso8859_7             iso-8859-7, greek, greek8            ギリシャ語
                                                           
                                                           
iso8859_8             iso-8859-8, hebrew                   ヘブライ語
                                                           
                                                           
iso8859_9             iso-8859-9, latin5, L5               トルコ語
                                                           
                                                           
iso8859_10            iso-8859-10, latin6, L6              北欧語
                                                           
                                                           
iso8859_11            iso-8859-11, thai                    タイ語
                                                           
                                                           
iso8859_13            iso-8859-13, latin7, L7              バルト沿岸国
                                                           
                                                           
iso8859_14            iso-8859-14, latin8, L8              ケルト語
                                                           
                                                           
iso8859_15            iso-8859-15, latin9, L9              西ヨーロッパ言語
                                                           
                                                           
iso8859_16            iso-8859-16, latin10, L10            南東ヨーロッパ
                                                           
                                                           
johab                 cp1361, ms1361                       韓国語
                                                           
                                                           
koi8_r                                                     ロシア語
                                                           
                                                           
koi8_t                                                     タジク
                                                           
                                                           Added in version 3.5.
                                                           
                                                           
koi8_u                                                     ウクライナ語
                                                           
                                                           
kz1048                kz_1048, strk1048_2002, rk1048       カザフ
                                                           
                                                           Added in version 3.5.
                                                           
                                                           
mac_cyrillic          maccyrillic                          ブルガリア、ベラルーシ、マケドニア
                                                           、ロシア、セルビア
                                                           
                                                           
mac_greek             macgreek                             ギリシャ語
                                                           
                                                           
mac_iceland           maciceland                           アイスランド語
                                                           
                                                           
mac_latin2            maclatin2, maccentraleurope,         中央および東ヨーロッパ
                      mac_centeuro                         
                      
                                                           
mac_roman             macroman, macintosh                  西ヨーロッパ言語
                                                           
                                                           
mac_turkish           macturkish                           トルコ語
                                                           
                                                           
ptcp154               csptcp154, pt154, cp154,             カザフ
                      cyrillic-asian                       
                      
                                                           
shift_jis             csshiftjis, shiftjis, sjis, s_jis    日本語
                                                           
                                                           
shift_jis_2004        shiftjis2004, sjis_2004, sjis2004    日本語
                                                           
                                                           
shift_jisx0213        shiftjisx0213, sjisx0213,            日本語
                      s_jisx0213                           
                      
                                                           
utf_32                U32, utf32                           全ての言語
                                                           
                                                           
utf_32_be             UTF-32BE                             全ての言語
                                                           
                                                           
utf_32_le             UTF-32LE                             全ての言語
                                                           
                                                           
utf_16                U16, utf16                           全ての言語
                                                           
                                                           
utf_16_be             UTF-16BE                             全ての言語
                                                           
                                                           
utf_16_le             UTF-16LE                             全ての言語
                                                           
                                                           
utf_7                 U7, unicode-1-1-utf-7                全ての言語
                                                           
                                                           
utf_8                 U8, UTF, utf8, cp65001               全ての言語
                                                           
                                                           
utf_8_sig                                                  全ての言語
                                                           

バージョン 3.4 で変更: utf-16* と utf-32* のエンコーダは、サロゲートコー
ドポイント (‘U+D800’-‘U+DFFF’) がエンコードされることを許可しなくなりま
した。utf-32* デコーダは、サロゲートコードポイントに対応するバイト列をデ
コードしなくなりました。

バージョン 3.8 で変更: ‘cp65001’ is now an alias to ‘utf_8’.


File: python.info,  Node: Python 特有のエンコーディング,  Next: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA,  Prev: 標準エンコーディング,  Up: codecs --- codec レジストリと基底クラス

5.7.2.14 Python 特有のエンコーディング
......................................

予め定義された codec のいくつかは Python 特有のものなので、それらの
codec 名は Python の外では無意味なものとなります。以下に、想定されている
入出力のタイプに基づいて、それらを表にしました（テキストエンコーディング
は codec の最も一般的な使用例ですが、その根底にある codec 基盤は、ただの
テキストエンコーディングというよりも、任意のデータの変換をサポートしてい
ることに注意してください）。非対称的な codec については、記載された意味
がエンコーディングの方向を説明しています。

* Menu:

* テキストエンコーディング::
* バイナリ変換 (Binary Transforms): バイナリ変換 Binary Transforms.
* テキスト変換 (Text Transforms): テキスト変換 Text Transforms.


File: python.info,  Node: テキストエンコーディング,  Next: バイナリ変換 Binary Transforms,  Up: Python 特有のエンコーディング

5.7.2.15 テキストエンコーディング
.................................

次の codec では、 Unicode におけるテキストエンコーディングと同様に、
*note str: 418. から *note bytes: 1a4. へのエンコードと、 *note
bytes-like object: cfb. から *note str: 418. へのデコードを提供します。

Codec                    別名          意味
                                       
-----------------------------------------------------------------------
                                       
idna                                   RFC 3490(1) の実装です。
                                       *note encodings.idna: 48. も
                                       参照してください。
                                       ‘errors='strict'’ のみがサポ
                                       ートされています。
                                       
                                       
mbcs                     ansi, dbcs    Windows のみ: 被演算子を ANSI
                                       コードページ (CP_ACP) に従っ
                                       てエンコードします。
                                       
                                       
oem                                    Windows のみ: 被演算子を OEM
                                       コードページ (CP_OEMCP) に従
                                       ってエンコードします。
                                       
                                       Added in version 3.6.
                                       
                                       
palmos                                 PalmOS 3.5 のエンコーディング
                                       です。
                                       
                                       
punycode                               RFC 3492(2) の実装です。ステ
                                       ートフル codecs は、サポート
                                       されません。
                                       
                                       
raw_unicode_escape                     Latin-1 encoding with
                                       ‘\uXXXX’ and ‘\UXXXXXXXX’ for
                                       other code points.  Existing
                                       backslashes are not escaped
                                       in any way.  It is used in
                                       the Python pickle protocol.
                                       
                                       
undefined                              空文字列を含む全ての変換に対
                                       して例外を送出します。エラー
                                       ハンドラは無視されます。
                                       
                                       
unicode_escape                         ASCII でエンコードされた
                                       Python ソースコード内の、
                                       Unicode リテラルに適したエン
                                       コーディングです。ただし、引
                                       用符はエスケープされません。
                                       Latin-1 ソースコードからデコ
                                       ードします。実際には、Python
                                       のソースコードはデフォルトで
                                       は UTF-8 を使用することに注意
                                       してください。
                                       

バージョン 3.8 で変更: "unicode_internal" codec is removed.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3490.html

   (2) https://datatracker.ietf.org/doc/html/rfc3492.html


File: python.info,  Node: バイナリ変換 Binary Transforms,  Next: テキスト変換 Text Transforms,  Prev: テキストエンコーディング,  Up: Python 特有のエンコーディング

5.7.2.16 バイナリ変換 (Binary Transforms)
.........................................

以下の codec は、*note bytes-like object: cfb. から *note bytes: 1a4. マ
ッピングへのバイナリ変換を提供します。*note bytes.decode(): 8a4. はこの
変換をサポートしておらず、 *note str: 418. を出力するだけです。

Codec                      別名                   意味                               エンコーダ / デコーダ
                                                                                     
------------------------------------------------------------------------------------------------------------------------
                                                                                     
base64_codec (1)           base64, base_64        被演算子をマルチラインの MIME      *note base64.encodebytes(): 921.
                                                  base64 に変換します (結果は常に    /
                                                  末尾の ‘'\n'’ を含みます)。        *note base64.decodebytes(): 922.
                                                                                     
                                                  バージョン 3.4 で変更: 任意の
                                                  *note bytes-like object: cfb. を
                                                  エンコードとデコード用の入力とし
                                                  て受け取ります。
                                                  
                                                                                     
bz2_codec                  bz2                    被演算子をbz2を使って圧縮します    *note bz2.compress(): 236c. /
                                                  。                                 *note bz2.decompress(): 1064.
                                                                                     
                                                                                     
hex_codec                  hex                    被演算子をバイトあたり 2 桁の 16   *note binascii.b2a_hex(): 236d.
                                                  進数の表現に変換します。           /
                                                                                     *note binascii.a2b_hex(): 236e.
                                                                                     
                                                                                     
quopri_codec               quopri,                被演算子を MIME quoted printable   ‘quotetabs=True’ を指定した
                           quotedprintable,       形式に変換します。                 *note quopri.encode(): 236f. /
                           quoted_printable                                          *note quopri.decode(): 2370.
                                                                                     
                                                                                     
uu_codec                   uu                     被演算子を uuencode を用いて変換
                                                  します。
                                                  
                                                                                     
zlib_codec                 zip, zlib              被演算子を gzip を用いて圧縮しま   *note zlib.compress(): 60b. /
                                                  す。                               *note zlib.decompress(): cdb.
                                                                                     

Added in version 3.2: バイナリ変換が復活しました。(訳注: 2.x にはあった
ものが 3.0 で削除されていた。)

バージョン 3.4 で変更: バイナリ変換のエイリアスが復活しました。(訳注:
2.x にはあったエイリアス。3.2 でエイリアスは復活しなかった。)

   ---------- Footnotes ----------

   (1) *note バイト様オブジェクト: cfb. に加えて、‘'base64_codec'’ も
*note str: 418. の ASCII のみのインスタンスをデコード用に受け入れるよう
になりました


File: python.info,  Node: テキスト変換 Text Transforms,  Prev: バイナリ変換 Binary Transforms,  Up: Python 特有のエンコーディング

5.7.2.17 テキスト変換 (Text Transforms)
.......................................

以下の codec は、*note str: 418. から *note str: 418. マッピングへのテキ
スト変換を提供します。*note str.encode(): 8a3. はこの変換をサポートして
おらず、 *note bytes: 1a4. を出力するだけです。

Codec                    別名          意味
                                       
-----------------------------------------------------------------------
                                       
rot_13                   rot13         被演算子のシーザー暗号
                                       (Caesar-cypher) を返します。
                                       

Added in version 3.2: ‘rot_13’ テキスト変換が復活しました。(訳注: 2.x に
はあったものが 3.0 で削除されていた。)

バージョン 3.4 で変更: ‘rot13’ エイリアスが復活しました。(訳注: 2.x には
あったエイリアス。3.2 でエイリアスは復活しなかった。)


File: python.info,  Node: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA,  Next: encodings mbcs --- Windows ANSI コードページ,  Prev: Python 特有のエンコーディング,  Up: codecs --- codec レジストリと基底クラス

5.7.2.18 ‘encodings.idna’ -- アプリケーションにおける国際化ドメイン名 (IDNA)
............................................................................

このモジュールでは RFC 3490(1) (アプリケーションにおける国際化ドメイン名
、 IDNA: Internationalized Domain Names in Applications) および RFC
3492(2) (Nameprep: 国際化ドメイン名 (IDN) のための stringprep プロファイ
ル) を実装しています。このモジュールは ‘punycode’ エンコーディングおよび
*note stringprep: bf. の上に構築されています。

If you need the IDNA 2008 standard from RFC 5891(3) and RFC 5895(4), use
the third-party idna(5) module.

これらの RFC はともに、非 ASCII 文字の入ったドメイン名をサポートするため
のプロトコルを定義しています。 (‘www.Alliancefrançaise.nu’ のような) 非
ASCII 文字を含むドメイン名は、 ASCII と互換性のあるエンコーディング
(ACE、 ‘www.xn--alliancefranaise-npb.nu’ のような形式) に変換されます。
ドメイン名の ACE 形式は、 DNS クエリ、 HTTP ‘Host’ フィールドなどといっ
た、プロトコル中で任意の文字を使えないような全ての局面で用いられます。こ
の変換はアプリケーション内で行われます; 可能ならユーザからは不可視となり
ます: アプリケーションは Unicode ドメインラベルをネットワークに載せる際
に IDNA に、 ACE ドメインラベルをユーザに提供する前に Unicode に、それぞ
れ透過的に変換しなければなりません。

Python ではこの変換をいくつかの方法でサポートします: ‘idna’ codec は
Unicode と ACE 間の変換を行い、入力文字列を RFC 3490 の section 3.1(6) で
定義されている区切り文字に基づいてラベルに分解し、各ラベルを要求通りに
ACE に変換します。逆に、入力のバイト文字列を ‘.’ 区切り文字でラベルに分
解し、 ACE ラベルを Unicode に変換します。さらに、 *note socket: b8. モ
ジュールは Unicode ホスト名を ACE に透過的に変換するため、アプリケーショ
ンはホスト名を *note socket: b8. モジュールに渡す際にホスト名の変換に煩
わされることがありません。その上で、ホスト名を関数パラメタとして持つ、
*note http.client: 65. や *note ftplib: 54. のようなモジュールでは
Unicode ホスト名を受理します (*note http.client: 65. でもまた、 ‘Host’ フ
ィールドにある IDNA ホスト名を、フィールド全体を送信する場合に透過的に送
信します)。

(逆引きなどによって) ネットワーク越しにホスト名を受信する際、Unicode へ
の自動変換は行われません: こうしたホスト名をユーザに提供したいアプリケー
ションでは、Unicode にデコードしてやる必要があります。

*note encodings.idna: 48. ではまた、 nameprep 手続きを実装しています。
nameprep はホスト名に対してある正規化を行って、国際化ドメイン名で大小文
字を区別しないようにするとともに、類似の文字を一元化します。 nameprep 関
数は必要なら直接使うこともできます。

 -- の関数: encodings.idna.nameprep (label)

     'label' を nameprep したバージョンを返します。現在の実装ではクエリ
     文字列を仮定しているので、‘AllowUnassigned’ は真です。

 -- の関数: encodings.idna.ToASCII (label)

     RFC 3490(7) 仕様に従ってラベルを ASCIIに変換します。
     ‘UseSTD3ASCIIRules’ は偽であると仮定します。

 -- の関数: encodings.idna.ToUnicode (label)

     RFC 3490(8) 仕様に従ってラベルを Unicode に変換します。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3490.html

   (2) https://datatracker.ietf.org/doc/html/rfc3492.html

   (3) https://datatracker.ietf.org/doc/html/rfc5891.html

   (4) https://datatracker.ietf.org/doc/html/rfc5895.html

   (5) https://pypi.org/project/idna/

   (6) https://datatracker.ietf.org/doc/html/rfc3490.html#section-3.1

   (7) https://datatracker.ietf.org/doc/html/rfc3490.html

   (8) https://datatracker.ietf.org/doc/html/rfc3490.html


File: python.info,  Node: encodings mbcs --- Windows ANSI コードページ,  Next: encodings utf_8_sig --- BOM 印付き UTF-8,  Prev: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA,  Up: codecs --- codec レジストリと基底クラス

5.7.2.19 ‘encodings.mbcs’ -- Windows ANSI コードページ
......................................................

This module implements the ANSI codepage (CP_ACP).

*note Availability: 1cbe.: Windows.

バージョン 3.2 で変更: 3.2 以前は 'errors' 引数は無視されました; エンコ
ードには常に ‘'replace'’ が、デコードには ‘'ignore'’ が使われました。

バージョン 3.3 で変更: 任意のエラーハンドラのサポート。


File: python.info,  Node: encodings utf_8_sig --- BOM 印付き UTF-8,  Prev: encodings mbcs --- Windows ANSI コードページ,  Up: codecs --- codec レジストリと基底クラス

5.7.2.20 ‘encodings.utf_8_sig’ -- BOM 印付き UTF-8
..................................................

このモジュールは UTF-8 codec の変種を実装します。エンコーディング時は、
UTF-8 でエンコードしたバイト列の前に UTF-8 でエンコードした BOM を追加し
ます。これは内部状態を持つエンコーダで、この動作は (バイトストリームの最
初の書き込み時に) 一度だけ行なわれます。デコーディング時は、データの最初
に UTF-8 でエンコードされた BOM があれば、それをスキップします。


File: python.info,  Node: データ型,  Next: 数値と数学モジュール,  Prev: バイナリデータ処理,  Up: Python 標準ライブラリ

5.8 データ型
============

この章で解説されるモジュールは日付や時間、型が固定された配列、ヒープキュ
ー、両端キュー、列挙型のような種々の特殊なデータ型を提供します。

Python にはその他にもいくつかの組み込みデータ型があります。特に、 *note
dict: 237. 、 *note list: 5dc. 、 *note set: 5a3. 、 *note frozenset:
5a4. 、そして *note tuple: 349. があります。 *note str: 418. クラスは
Unicode データを扱うことができ、 *note bytes: 1a4. と *note bytearray:
508. クラスはバイナリデータを扱うことができます。

この章では以下のモジュールが記述されています:

* Menu:

* datetime: datetime --- 基本的な日付と時間の型. 基本的な日付と時間の型
* zoneinfo: zoneinfo --- IANA タイムゾーンのサポート. IANA タイムゾーンのサポート
* calendar: calendar --- 一般的なカレンダーに関係する機能群. 一般的なカレンダーに関係する機能群
* collections: collections --- コンテナデータ型. コンテナデータ型
* collections.abc: collections abc --- コンテナの抽象基底クラス. コンテナの抽象基底クラス
* heapq: heapq --- ヒープキューアルゴリズム. ヒープキューアルゴリズム
* bisect: bisect --- 配列二分法アルゴリズム. 配列二分法アルゴリズム
* array: array --- 効率的な数値配列. 効率的な数値配列
* weakref: weakref --- 弱参照. 弱参照
* types: types --- 動的な型生成と組み込み型の名前. 動的な型生成と組み込み型の名前
* copy: copy --- 浅いコピーおよび深いコピー操作. 浅いコピーおよび深いコピー操作
* pprint: pprint --- データの整形表示. データの整形表示
* reprlib: reprlib --- もう一つの repr の実装. もう一つの repr() の実装
* enum: enum --- 列挙型のサポート. 列挙型のサポート
* graphlib: graphlib --- グラフ構造を操作する機能. グラフ構造を操作する機能


File: python.info,  Node: datetime --- 基本的な日付と時間の型,  Next: zoneinfo --- IANA タイムゾーンのサポート,  Up: データ型

5.8.1 ‘datetime’ -- 基本的な日付と時間の型
------------------------------------------

'ソースコード:' Lib/datetime.py(1)

__________________________________________________________________

‘datetime’ モジュールは、日付や時刻を操作するためのクラスを提供していま
す。

日付や時刻に対する算術がサポートされている一方、実装では出力のフォーマッ
トや操作のための効率的な属性の抽出に重点を置いています。

     Tip: *note 書式コード: 237d. に飛ぶ。

参考
....

*note calendar: 10. モジュール

     汎用のカレンダー関連関数。

*note time: d7. モジュール

     時刻へのアクセスと変換。

*note zoneinfo: 11a. モジュール

     IANAタイムゾーンデータベースを表す具体的なタイムゾーン。

dateutil(2) パッケージ

     拡張タイムゾーンと構文解析サポートのあるサードパーティーライブラリ
     。

DateType(3) パッケージ

     Third-party library that introduces distinct static types to e.g.
     allow *note static type checkers: 24e. to differentiate between
     naive and aware datetimes.

* Menu:

* Aware オブジェクトと Naive オブジェクト::
* 定数::
* 利用可能なデータ型::
* timedelta オブジェクト::
* date オブジェクト::
* datetime オブジェクト::
* time オブジェクト::
* tzinfo オブジェクト::
* timezone オブジェクト::
* strftime() と strptime() の振る舞い: strftime と strptime の振る舞い.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/datetime.py

   (2) https://dateutil.readthedocs.io/en/stable/

   (3) https://pypi.org/project/DateType/


File: python.info,  Node: Aware オブジェクトと Naive オブジェクト,  Next: 定数,  Up: datetime --- 基本的な日付と時間の型

5.8.1.1 Aware オブジェクトと Naive オブジェクト
...............................................

日時のオブジェクトは、それらがタイムゾーンの情報を含んでいるかどうかによ
って "aware" あるいは "naive" に分類されます。

タイムゾーンや夏時間の情報のような、アルゴリズム的で政治的な適用可能な時
間調節に関する知識を持っているため、 'aware' オブジェクトは他の aware オ
ブジェクトとの相対関係を特定できます。 aware オブジェクトは解釈の余地の
ない特定の実時刻を表現します。 (1)

'naive' オブジェクトには他の日付時刻オブジェクトとの相対関係を把握するの
に足る情報が含まれません。あるプログラム内の数字がメートルを表わしている
のか、マイルなのか、それとも質量なのかがプログラムによって異なるように、
naive オブジェクトが協定世界時 (UTC) なのか、現地時間なのか、それとも他
のタイムゾーンなのかはそのプログラムに依存します。Naive オブジェクトはい
くつかの現実的な側面を無視してしまうというコストを無視すれば、簡単に理解
でき、うまく利用することができます。

aware オブジェクトを必要とするアプリケーションのために、 *note datetime:
1ae. と *note time: 1b0. オブジェクトは追加のタイムゾーン情報の属性
‘tzinfo’ を持ちます。 *note tzinfo: 5a8. には抽象クラス *note tzinfo:
5a8. のサブクラスのインスタンスを設定できます。 これらの *note tzinfo:
5a8. オブジェクトは UTC 時間からのオフセットやタイムゾーンの名前、夏時間
が実施されるかどうかの情報を保持しています。

ただ一つの具象 *note tzinfo: 5a8. クラスである *note timezone: 1091. ク
ラスが ‘datetime’ モジュールで提供されています。 ‘timezone’ クラスは、
UTCからのオフセットが固定である単純なタイムゾーン（例えばUTCそれ自体）、
および北アメリカにおける東部標準時（EST）／東部夏時間（EDT）のような単純
ではないタイムゾーンの両方を表現できます。より深く詳細までタイムゾーンを
サポートするかはアプリケーションに依存します。世界中の時刻の調整を決める
ルールは合理的というよりかは政治的なもので、頻繁に変わり、UTC を除くと都
合のよい基準というものはありません。

   ---------- Footnotes ----------

   (1) もし相対性理論の効果を無視するならば、ですが


File: python.info,  Node: 定数,  Next: 利用可能なデータ型,  Prev: Aware オブジェクトと Naive オブジェクト,  Up: datetime --- 基本的な日付と時間の型

5.8.1.2 定数
............

‘datetime’ モジュールでは以下の定数を公開しています:

 -- データ: datetime.MINYEAR

     *note date: 1af. や *note datetime: 1ae. オブジェクトで許されている
     、年を表現する最小の数字です。 *note MINYEAR: 2381. は1です。

 -- データ: datetime.MAXYEAR

     *note date: 1af. や *note datetime: 1ae. オブジェクトで許されている
     、年を表現する最大の数字です。 *note MAXYEAR: 2382. は9999です。

 -- の属性: datetime.UTC

     UTCタイムゾーンシングルトン *note datetime.timezone.utc: 5df. の別
     名。

     Added in version 3.11.


File: python.info,  Node: 利用可能なデータ型,  Next: timedelta オブジェクト,  Prev: 定数,  Up: datetime --- 基本的な日付と時間の型

5.8.1.3 利用可能なデータ型
..........................

 -- クラス: datetime.date

     理想的な naive な日付で、これまでもこれからも現在のグレゴリオ暦
     (Gregorian calender) が有効であることを仮定しています。 属性は
     *note year: 2384, *note month: 2385,および *note day: 2386. です。

 -- クラス: datetime.time

     理想的な時刻で、特定の日から独立しており、毎日が厳密に 24*60*60 秒
     であると仮定しています。("うるう秒: leap seconds" の概念はありませ
     ん。) 属性は *note hour: 2387, *note minute: 2388, *note second:
     2389, *note microsecond: 238a, および *note tzinfo: 238b. です。

 -- クラス: datetime.datetime

     日付と時刻を組み合わせたものです。 属性は *note year: 238c, *note
     month: 238d, *note day: 238e, *note hour: 238f, *note minute: 2390,
     *note second: 2391, *note microsecond: 2392, および *note tzinfo:
     2393. です。

 -- クラス: datetime.timedelta

     *note datetime: 1ae. あるいは *note date: 1af. クラスの二つのインス
     タンス間の時間差をマイクロ秒精度で表す経過時間値です。

 -- クラス: datetime.tzinfo

     タイムゾーン情報オブジェクトの抽象基底クラスです。 *note datetime:
     1ae. および *note time: 1b0. クラスで用いられ、カスタマイズ可能な時
     刻修正の概念 (たとえばタイムゾーンや夏時間の計算) を提供します。

 -- クラス: datetime.timezone

     *note tzinfo: 5a8. 抽象基底クラスを UTC からの固定オフセットとして
     実装するクラスです。

     Added in version 3.2.

これらの型のオブジェクトは変更不可能 (immutable) です。

サブクラスの関係は以下のようになります:

     object
         timedelta
         tzinfo
             timezone
         time
         date
             datetime

* Menu:

* 共通の特徴::
* オブジェクトが Aware なのか Naive なのかの判断::


File: python.info,  Node: 共通の特徴,  Next: オブジェクトが Aware なのか Naive なのかの判断,  Up: 利用可能なデータ型

5.8.1.4 共通の特徴
..................

*note date: 1af. 型、*note datetime: 1ae. 型、*note time: 1b0. 型、*note
timezone: 1091. 型には共通する特徴があります:

   - これらの型のオブジェクトは変更不可能 (immutable) です。

   - これらの型のオブジェクトは *note ハッシュ可能: 5db. であり、辞書の
     キーとして使えることになります。

   - これらの型のオブジェクトは *note pickle: 95. モジュールを利用して効
     率的な pickle 化をサポートしています。


File: python.info,  Node: オブジェクトが Aware なのか Naive なのかの判断,  Prev: 共通の特徴,  Up: 利用可能なデータ型

5.8.1.5 オブジェクトが Aware なのか Naive なのかの判断
......................................................

*note date: 1af. 型のオブジェクトは常に naive です。

*note time: 1b0. 型あるいは *note datetime: 1ae. 型のオブジェクトは
aware か naive のどちらかです。

A *note datetime: 1ae. object ‘d’ is aware if both of the following
hold:

  1. ‘d.tzinfo’ が ‘None’ でない

  2. ‘d.tzinfo.utcoffset(d)’ が ‘None’ を返さない

Otherwise, ‘d’ is naive.

A *note time: 1b0. object ‘t’ is aware if both of the following hold:

  1. ‘t.tzinfo’ が ‘None’ でない

  2. ‘t.tzinfo.utcoffset(None)’ が ‘None’ を返さない

Otherwise, ‘t’ is naive.

aware なオブジェクトと naive なオブジェクトの区別は *note timedelta:
99d. オブジェクトにはあてはまりません。


File: python.info,  Node: timedelta オブジェクト,  Next: date オブジェクト,  Prev: 利用可能なデータ型,  Up: datetime --- 基本的な日付と時間の型

5.8.1.6 ‘timedelta’ オブジェクト
................................

*note timedelta: 99d. オブジェクトは経過時間、すなわち二つの *note
datetime: 1ae. または *note date: 1af. のインスタンスの差を表します。

 -- クラス: datetime.timedelta (days=0, seconds=0, microseconds=0,
          milliseconds=0, minutes=0, hours=0, weeks=0)

     全ての引数がオプションで、デフォルト値は0です。 引数は整数、浮動小
     数点数でもよく、正でも負でもかまいません。

     'days', 'seconds', 'microseconds' だけが内部的に保持されます。 引数
     は以下のようにして変換されます:

        * 1 ミリ秒は 1000 マイクロ秒に変換されます。

        * 1 分は 60 秒に変換されます。

        * 1 時間は 3600 秒に変換されます。

        * 1 週間は 7 日に変換されます。

     さらに、値が一意に表されるように days, seconds, microseconds が以下
     のように正規化されます

        * ‘0 <= microseconds < 1000000’

        * ‘0 <= seconds < 3600*24’ (一日中の秒数)

        * ‘-999999999 <= days <= 999999999’

     次の例は、 'days', 'seconds', 'microseconds' に加えて任意の引数がど
     う "集約" され、最終的に3つの属性に正規化されるかの説明をしています
     :

          >>> from datetime import timedelta
          >>> delta = timedelta(
          ...     days=50,
          ...     seconds=27,
          ...     microseconds=10,
          ...     milliseconds=29000,
          ...     minutes=5,
          ...     hours=8,
          ...     weeks=2
          ... )
          >>> # Only days, seconds, and microseconds remain
          >>> delta
          datetime.timedelta(days=64, seconds=29156, microseconds=10)

     引数のいずれかが浮動小数点であり、小数のマイクロ秒が存在する場合、
     小数のマイクロ秒は全ての引数から一度取り置かれ、それらの和は最近接
     偶数のマイクロ秒に丸められます。浮動小数点の引数がない場合、値の変
     換と正規化の過程は厳密な (失われる情報がない) ものとなります。

     日の値を正規化した結果、指定された範囲の外側になった場合には、
     *note OverflowError: 84e. が送出されます。

     負の値を正規化すると、最初は混乱するような値になります。例えば:

          >>> from datetime import timedelta
          >>> d = timedelta(microseconds=-1)
          >>> (d.days, d.seconds, d.microseconds)
          (-1, 86399, 999999)

以下にクラス属性を示します:

 -- の属性: timedelta.min

     最小の値を表す *note timedelta: 99d. オブジェクトで、
     ‘timedelta(-999999999)’ です。

 -- の属性: timedelta.max

     最大の値を表す *note timedelta: 99d. オブジェクトで、
     ‘timedelta(days=999999999, hours=23, minutes=59, seconds=59,
     microseconds=999999)’ です。

 -- の属性: timedelta.resolution

     *note timedelta: 99d. オブジェクトが等しくならない最小の時間差で、
     ‘timedelta(microseconds=1)’ です。

正規化のために、 ‘timedelta.max’ は ‘-timedelta.min’ より大きいことに注
意してください。 ‘-timedelta.max’ は *note timedelta: 99d. オブジェクト
として表現することができません。

インスタンスの属性 (読み出しのみ):

 -- の属性: timedelta.days

     Between -999,999,999 and 999,999,999 inclusive.

 -- の属性: timedelta.seconds

     Between 0 and 86,399 inclusive.

          注意: It is a somewhat common bug for code to unintentionally
          use this attribute when it is actually intended to get a *note
          total_seconds(): 12d4. value instead:

               >>> from datetime import timedelta
               >>> duration = timedelta(seconds=11235813)
               >>> duration.days, duration.seconds
               (130, 3813)
               >>> duration.total_seconds()
               11235813.0

 -- の属性: timedelta.microseconds

     Between 0 and 999,999 inclusive.

サポートされている演算を以下に示します:

演算                                 結果
                                     
-----------------------------------------------------------------------------------------
                                     
‘t1 = t2 + t3’                       ‘t2’ と ‘t3’ の和。演算後、‘t1 - t2 == t3’ および
                                     ‘t1 - t3 == t2’ は真になります。(1)
                                     
                                     
‘t1 = t2 - t3’                       ‘t2’ と ‘t3’ の差。演算後、‘t1 == t2 - t3’ および
                                     ‘t2 == t1 + t3’ は真になります。 (1)(6)
                                     
                                     
‘t1 = t2 * i または t1 = i * t2’     時間差と整数の積。演算後、‘t1 // i == t2’ は ‘i
                                     != 0’ であれば真となります。
                                     
                                     
                                     一般的に、‘t1 * i == t1 * (i-1) + t1’ は真となり
                                     ます。(1)
                                     
                                     
‘t1 = t2 * f’ または ‘t1 = f * t2’   時間差と浮動小数点の積。結果は最近接偶数への丸め
                                     を利用して最も近い timedelta.resolution の倍数に
                                     丸められます。
                                     
                                     
‘f = t2 / t3’                        ‘t2’ を ‘t3’ で除算 (3) したもの。
                                     *note float: 2ce. オブジェクトを返します。
                                     
                                     
‘t1 = t2 / f’ または ‘t1 = t2 / i’   時間差を浮動小数点や整数で除したもの。結果は最近
                                     接偶数への丸めを利用して最も近い
                                     timedelta.resolution の倍数に丸められます。
                                     
                                     
‘t1 = t2 // i’ または ‘t1 = t2 //    floor が計算され、余りは (もしあれば) 捨てられま
t3’                                  す。後者の場合、整数が返されます。(3)
                                     
                                     
‘t1 = t2 % t3’                       剰余が *note timedelta: 99d. オブジェクトとして計
                                     算されます。(3)
                                     
                                     
‘q, r = divmod(t1, t2)’              Computes the quotient and the remainder: ‘q = t1
                                     // t2’ (3) and ‘r = t1 % t2’.  ‘q’ is an integer
                                     and ‘r’ is a *note timedelta: 99d. object.
                                     
                                     
‘+t1’                                同じ値を持つ *note timedelta: 99d. オブジェクトを
                                     返します。(2)
                                     
                                     
‘-t1’                                Equivalent to ‘timedelta(-t1.days, -t1.seconds,
                                     -t1.microseconds)’, and to ‘t1 * -1’.  (1)(4)
                                     
                                     
‘abs(t)’                             ‘t.days >= 0’ のときには ‘+t’, ‘t.days < 0’ のと
                                     きには ‘-t’ となります。(2)
                                     
                                     
‘str(t)’                             ‘[D day[s], ][H]H:MM:SS[.UUUUUU]’ という形式の文
                                     字列を返します。‘t’ が負の値の場合は ‘D’ は負の値
                                     となります。(5)
                                     
                                     
‘repr(t)’                            *note timedelta: 99d. オブジェクトの文字列表現を
                                     返します。その文字列は、正規の属性値を持つコンス
                                     トラクタ呼び出しのコードになっています。
                                     

注釈:

  1. この演算は正確ですが、オーバフローするかもしれません。

  2. この演算は正確であり、オーバフローし得ません。

  3. 0 による除算は *note ZeroDivisionError: 913. を送出します。

  4. ‘-timedelta.max’ は *note timedelta: 99d. オブジェクトで表現するこ
     とができません。

  5. *note timedelta: 99d. オブジェクトの文字列表現は内部表現に類似した
     形に正規化されます。そのため負の timedelta は少し変な結果になります
     。例えば:

          >>> timedelta(hours=-5)
          datetime.timedelta(days=-1, seconds=68400)
          >>> print(_)
          -1 day, 19:00:00

  6. t3 が ‘timedelta.max’ のときを除けば、式 ‘t2 - t3’ は常に、式 ‘t2 +
     (-t3)’ と同等です。t3 が ‘timedelta.max’ の場合、前者の式は結果の値
     が出ますが、後者はオーバーフローを起こします。

上に列挙した操作に加え *note timedelta: 99d. オブジェクトは *note date:
1af. および *note datetime: 1ae. オブジェクトとの間で加減算をサポートし
ています (下を参照してください)。

バージョン 3.2 で変更: *note timedelta: 99d. オブジェクトの別の *note
timedelta: 99d. オブジェクトによる、切り捨て除算と真の除算、および剰余演
算と *note divmod(): 96f. 関数がサポートされるようになりました。 *note
timedelta: 99d. オブジェクトと *note float: 2ce. オブジェクトの真の除算
と掛け算がサポートされるようになりました。

*note timedelta: 99d. オブジェクトは等価性と順序の比較をサポートします。

ブール演算コンテキストでは、 *note timedelta: 99d. オブジェクトは
‘timedelta(0)’ に等しくない場合かつそのときに限り真となります。

インスタンスメソッド:

 -- メソッド: timedelta.total_seconds ()

     この期間に含まれるトータルの秒数を返します。‘td /
     timedelta(seconds=1)’ と等価です。 秒以外の期間の単位では、直接に除
     算する形式 (例えば ‘td / timedelta(microseconds=1)’) が使われます。

     非常に長い期間 (多くのプラットフォームでは270年以上) については、こ
     のメソッドはマイクロ秒の精度を失うことがあることに注意してください
     。

     Added in version 3.2.

* Menu:

* 使用例; timedelta: 使用例 timedelta.


File: python.info,  Node: 使用例 timedelta,  Up: timedelta オブジェクト

5.8.1.7 使用例: ‘timedelta’
...........................

正規化の追加の例です:

     >>> # Components of another_year add up to exactly 365 days
     >>> from datetime import timedelta
     >>> year = timedelta(days=365)
     >>> another_year = timedelta(weeks=40, days=84, hours=23,
     ...                          minutes=50, seconds=600)
     >>> year == another_year
     True
     >>> year.total_seconds()
     31536000.0

*note timedelta: 99d. の計算の例です:

     >>> from datetime import timedelta
     >>> year = timedelta(days=365)
     >>> ten_years = 10 * year
     >>> ten_years
     datetime.timedelta(days=3650)
     >>> ten_years.days // 365
     10
     >>> nine_years = ten_years - year
     >>> nine_years
     datetime.timedelta(days=3285)
     >>> three_years = nine_years // 3
     >>> three_years, three_years.days // 365
     (datetime.timedelta(days=1095), 3)


File: python.info,  Node: date オブジェクト,  Next: datetime オブジェクト,  Prev: timedelta オブジェクト,  Up: datetime --- 基本的な日付と時間の型

5.8.1.8 ‘date’ オブジェクト
...........................

*note date: 1af. オブジェクトは、両方向に無期限に拡張された現在のグレゴ
リオ暦という理想化された暦の日付 (年月日) を表します。

1 年 1 月 1 日は日番号 1、1 年 1 月 2 日は日番号 2 と呼ばれ、他も同様で
す。 (1)

 -- クラス: datetime.date (year, month, day)

     全ての引数が必須です。 引数は整数で、次の範囲に収まっていなければな
     りません:

        * ‘MINYEAR <= year <= MAXYEAR’

        * ‘1 <= month <= 12’

        * ‘1 <= day <= 指定された月と年における日数’

     範囲を超えた引数を与えた場合、 *note ValueError: 1e3. が送出されま
     す。

他のコンストラクタ、および全てのクラスメソッドを以下に示します:

 -- メソッド: classmethod date.today ()

     現在のローカルな日付を返します。

     ‘date.fromtimestamp(time.time())’ と等価です。

 -- メソッド: classmethod date.fromtimestamp (timestamp)

     *note time.time(): 235. で返されるような POSIX タイムスタンプに対応
     するローカルな日付を返します。

     timestamp がプラットフォームの C 関数 ‘localtime()’ がサポートする
     値の範囲から外れていた場合、 *note OverflowError: 84e. を送出するか
     もしれません。また ‘localtime()’ 呼び出しが失敗した場合には *note
     OSError: 3f0. を送出するかもしれません。この範囲は通常は 1970 年か
     ら 2038 年までに制限されています。タイムスタンプの表記にうるう秒を
     含める非 POSIX なシステムでは、うるう秒は *note fromtimestamp():
     156d. では無視されます。

     バージョン 3.3 で変更: timestamp がプラットフォームの C 関数
     ‘localtime()’ のサポートする値の範囲から外れていた場合、 *note
     ValueError: 1e3. ではなく *note OverflowError: 84e. を送出するよう
     になりました。 ‘localtime()’ の呼び出し失敗で *note ValueError:
     1e3. ではなく *note OSError: 3f0. を送出するようになりました。

 -- メソッド: classmethod date.fromordinal (ordinal)

     先発グレゴリオ暦による序数に対応する日付を返します。 1 年 1 月 1 日
     が序数 1 となります。

     *note ValueError: 1e3. is raised unless ‘1 <= ordinal <=
     date.max.toordinal()’.  For any date ‘d’,
     ‘date.fromordinal(d.toordinal()) == d’.

 -- メソッド: classmethod date.fromisoformat (date_string)

     以下の例外を除く、有効な ISO 8601 フォーマットで与えられた
     'date_string' に対応する *note date: 1af. を返します :

       1. 精度の低い日付は現在サポートされていません(‘YYYY-MM’, ‘YYYY’)。

       2. 拡張された日付表現は現在サポートされていません
          (‘±YYYYYY-MM-DD’)。

       3. 序数の日付は現在サポートされていません(‘YYYY-OOO’)。

     例:

          >>> from datetime import date
          >>> date.fromisoformat('2019-12-04')
          datetime.date(2019, 12, 4)
          >>> date.fromisoformat('20191204')
          datetime.date(2019, 12, 4)
          >>> date.fromisoformat('2021-W01-1')
          datetime.date(2021, 1, 4)

     Added in version 3.7.

     バージョン 3.11 で変更: 以前はこのメソッドは ‘YYYY-MM-DD’ フォーマ
     ットのみをサポートしていました。

 -- メソッド: classmethod date.fromisocalendar (year, week, day)

     年月日で指定された ISO 暦の日付に対応する *note date: 1af. を返しま
     す。 この関数は *note date.isocalendar(): 8c3. 関数の逆関数です。

     Added in version 3.8.

以下にクラス属性を示します:

 -- の属性: date.min

     表現できる最も古い日付で、‘date(MINYEAR, 1, 1)’ です。

 -- の属性: date.max

     表現できる最も新しい日付で、‘date(MAXYEAR, 12, 31)’ です。

 -- の属性: date.resolution

     等しくない日付オブジェクト間の最小の差で、‘timedelta(days=1)’ です
     。

インスタンスの属性 (読み出しのみ):

 -- の属性: date.year

     両端値を含む *note MINYEAR: 2381. から *note MAXYEAR: 2382. までの
     値です。

 -- の属性: date.month

     両端値を含む 1 から 12 までの値です。

 -- の属性: date.day

     1 から与えられた月と年における日数までの値です。

サポートされている演算を以下に示します:

演算                                結果
                                    
---------------------------------------------------------------------------------------
                                    
‘date2 = date1 + timedelta’         ‘date2’ は ‘date1’ の ‘timedelta.days’ 日後にな
                                    ります。(1)
                                    
                                    
‘date2 = date1 - timedelta’         ‘date2 + timedelta == date1’ であるような日付
                                    ‘date2’ を計算します。(2)
                                    
                                    
‘timedelta = date1 - date2’         (3)
                                    
                                    
     ‘date1 == date2’               等価性の比較。(4)
     ‘date1 != date2’               

     ‘date1 < date2’                順序の比較。(5)
     ‘date1 > date2’                
     ‘date1 <= date2’
     ‘date1 >= date2’

注釈:

  1. 'date2' は、 ‘timedelta.days > 0’ の場合は進む方向に、
     ‘timedelta.days < 0’ の場合は戻る方向に移動します。 演算後は ‘date2
     - date1 == timedelta.days’ が成立します。 ‘timedelta.seconds’ およ
     び ‘timedelta.microseconds’ は無視されます。 ‘date2.year’ が *note
     MINYEAR: 2381. になってしまったり、 *note MAXYEAR: 2382. より大きく
     なってしまう場合には *note OverflowError: 84e. が送出されます。

  2. ‘timedelta.seconds’ と ‘timedelta.microseconds’ は無視されます。

  3. この演算は厳密で、オーバフローしません。‘timedelta.seconds’ および
     ‘timedelta.microseconds’ は 0 で、演算後には ‘date2 + timedelta ==
     date1’ となります。

  4. 同じ日を表す *note date: 1af. オブジェクトは等しいです。

     *note datetime: 1ae. のインスタンスではない ‘date’ オブジェクトは、
     同じ日を表していても、‘datetime’ オブジェクトとは決して等価にはなり
     ません。

  5. '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()’.

     Order comparison between a ‘date’ object that is not also a *note
     datetime: 1ae. instance and a ‘datetime’ object raises *note
     TypeError: 502.

バージョン 3.13 で変更: Comparison between *note datetime: 1ae. object
and an instance of the *note date: 1af. subclass that is not a
‘datetime’ subclass no longer converts the latter to ‘date’, ignoring
the time part and the time zone.  The default behavior can be changed by
overriding the special comparison methods in subclasses.

ブール演算コンテキストでは、全ての *note time: 1b0. オブジェクトは真とみ
なされます。

インスタンスメソッド:

 -- メソッド: date.replace (year=self.year, month=self.month,
          day=self.day)

     キーワード引数で指定されたパラメータが置き換えられることを除き、同
     じ値を持つ *note date: 1af. オブジェクトを返します。

     以下はプログラム例です:

          >>> from datetime import date
          >>> d = date(2002, 12, 31)
          >>> d.replace(day=26)
          datetime.date(2002, 12, 26)

     *note date: 1af. オブジェクトは汎用的な関数 *note copy.replace():
     137. にもサポートされています。

 -- メソッド: date.timetuple ()

     *note time.localtime(): 14a2. が返すような *note time.struct_time:
     cb8. を返します。

     時分秒が 0 で、 DST フラグが -1 です。

     ‘d.timetuple()’ は次の式と等価です:

          time.struct_time((d.year, d.month, d.day, 0, 0, 0, d.weekday(), yday, -1))

     ここで、 ‘yday = d.toordinal() - date(d.year, 1, 1).toordinal() +
     1’ は本年の 1 月 1 日を 1 としたときの日付番号です。

 -- メソッド: date.toordinal ()

     Return the proleptic Gregorian ordinal of the date, where January 1
     of year 1 has ordinal 1.  For any *note date: 1af. object ‘d’,
     ‘date.fromordinal(d.toordinal()) == d’.

 -- メソッド: date.weekday ()

     月曜日を 0、日曜日を 6 として、曜日を整数で返します。例えば、
     ‘date(2002, 12, 4).weekday() == 2’ であり、水曜日を示します。 *note
     isoweekday(): 23a8. も参照してください。

 -- メソッド: date.isoweekday ()

     月曜日を 1,日曜日を 7 として、曜日を整数で返します。例えば、
     ‘date(2002, 12, 4).isoweekday() == 3’ であり、水曜日を示します。
     *note weekday(): 23a7, *note isocalendar(): 8c3. も参照してください
     。

 -- メソッド: date.isocalendar ()

     ‘year’、‘week’、‘weekday’ の3つで構成された *note named tuple: 61a.
     を返します。

     ISO 暦はグレゴリオ暦の変種として広く用いられています。 (2)

     ISO 年は完全な週が 52 週または 53 週あり、週は月曜から始まって日曜
     に終わります。ISO 年でのある年における最初の週は、その年の木曜日を
     含む最初の (グレゴリオ暦での) 週となります。この週は週番号 1 と呼ば
     れ、この木曜日での ISO 年はグレゴリオ暦における年と等しくなります。

     例えば、2004 年は木曜日から始まるため、ISO 年の最初の週は 2003 年
     12 月 29 日、月曜日から始まり、2004 年 1 月 4 日、日曜日に終わりま
     す

          >>> from datetime import date
          >>> date(2003, 12, 29).isocalendar()
          datetime.IsoCalendarDate(year=2004, week=1, weekday=1)
          >>> date(2004, 1, 4).isocalendar()
          datetime.IsoCalendarDate(year=2004, week=1, weekday=7)

     バージョン 3.9 で変更: 結果が タプル から *note named tuple: 61a. へ
     変更されました。

 -- メソッド: date.isoformat ()

     日付を ISO 8601 書式の ‘YYYY-MM-DD’ で表した文字列を返します:

          >>> from datetime import date
          >>> date(2002, 12, 4).isoformat()
          '2002-12-04'

 -- メソッド: date.__str__ ()

     For a date ‘d’, ‘str(d)’ is equivalent to ‘d.isoformat()’.

 -- メソッド: date.ctime ()

     日付を表す文字列を返します:

          >>> from datetime import date
          >>> date(2002, 12, 4).ctime()
          'Wed Dec  4 00:00:00 2002'

     ‘d.ctime()’ は次の式と等価です:

          time.ctime(time.mktime(d.timetuple()))

     これが等価になるのは、 (*note time.ctime(): 23ac. に呼び出され、
     *note date.ctime(): 23ab. に呼び出されない) ネイティブの C 関数
     ‘ctime()’ が C 標準に準拠しているプラットフォーム上でです。

 -- メソッド: date.strftime (format)

     明示的な書式文字列で制御された、日付を表現する文字列を返します。 時
     間、分、秒を表す書式コードは値 0 になります。 *note strftime() と
     strptime() の振る舞い: 1734. および *note date.isoformat(): 23a9. も
     参照してください。

 -- メソッド: date.__format__ (format)

     *note date.strftime(): c5f. と等価です。 これにより、 *note
     フォーマット済み文字列リテラル: 977. の中や *note str.format():
     5ed. を使っているときに *note date: 1af. オブジェクトの書式文字列を
     指定できます。 *note strftime() と strptime() の振る舞い: 1734. お
     よび *note date.isoformat(): 23a9. も参照してください。

* Menu:

* 使用例; date: 使用例 date.

   ---------- Footnotes ----------

   (1) この暦法は、全ての計算における基本カレンダーである、 Dershowitz と
Reingold の書籍 'Calendrical Calculations' における先発グレゴリオ暦
("proleptic Gregorian") の定義に一致します。 先発グレゴリオ暦の序数とそ
の他多くの暦法どうしの変換アルゴリズムについては、この書籍を参照してくだ
さい。

   (2) 優れた説明は R. H. van Gent の guide to the mathematics of the
ISO 8601 calendar
(https://web.archive.org/web/20220531051136/https://webspace.science.uu.nl/~gent0113/calendar/isocalendar.htm)
を参照してください。


File: python.info,  Node: 使用例 date,  Up: date オブジェクト

5.8.1.9 使用例: ‘date’
......................

イベントまでの日数を数える例を示します:

     >>> import time
     >>> from datetime import date
     >>> today = date.today()
     >>> today
     datetime.date(2007, 12, 5)
     >>> today == date.fromtimestamp(time.time())
     True
     >>> my_birthday = date(today.year, 6, 24)
     >>> if my_birthday < today:
     ...     my_birthday = my_birthday.replace(year=today.year + 1)
     ...
     >>> my_birthday
     datetime.date(2008, 6, 24)
     >>> time_to_birthday = abs(my_birthday - today)
     >>> time_to_birthday.days
     202

さらなる *note date: 1af. を使う例:

     >>> from datetime import date
     >>> d = date.fromordinal(730920) # 730920th day after 1. 1. 0001
     >>> d
     datetime.date(2002, 3, 11)

     >>> # Methods related to formatting string output
     >>> d.isoformat()
     '2002-03-11'
     >>> d.strftime("%d/%m/%y")
     '11/03/02'
     >>> d.strftime("%A %d. %B %Y")
     'Monday 11. March 2002'
     >>> d.ctime()
     'Mon Mar 11 00:00:00 2002'
     >>> 'The {1} is {0:%d}, the {2} is {0:%B}.'.format(d, "day", "month")
     'The day is 11, the month is March.'

     >>> # Methods for to extracting 'components' under different calendars
     >>> t = d.timetuple()
     >>> for i in t:
     ...     print(i)
     2002                # year
     3                   # month
     11                  # day
     0
     0
     0
     0                   # weekday (0 = Monday)
     70                  # 70th day in the year
     -1
     >>> ic = d.isocalendar()
     >>> for i in ic:
     ...     print(i)
     2002                # ISO year
     11                  # ISO week number
     1                   # ISO day number ( 1 = Monday )

     >>> # A date object is immutable; all operations produce a new object
     >>> d.replace(year=2005)
     datetime.date(2005, 3, 11)


File: python.info,  Node: datetime オブジェクト,  Next: time オブジェクト,  Prev: date オブジェクト,  Up: datetime --- 基本的な日付と時間の型

5.8.1.10 ‘datetime’ オブジェクト
................................

*note datetime: 1ae. オブジェクトは *note date: 1af. オブジェクトおよび
*note time: 1b0. オブジェクトの全ての情報が入っている単一のオブジェクト
です。

*note date: 1af. オブジェクトと同様に、 *note datetime: 1ae. は現在のグ
レゴリオ暦が両方向に延長されているものと仮定します。また、 *note time:
1b0. オブジェクトと同様に、 *note datetime: 1ae. は毎日が厳密に 3600*24
秒であると仮定します。

以下にコンストラクタを示します:

 -- クラス: datetime.datetime (year, month, day, hour=0, minute=0,
          second=0, microsecond=0, tzinfo=None, *, fold=0)

     'year', 'month', 'day' 引数は必須です。 'tzinfo' は ‘None’ または
     *note tzinfo: 5a8. サブクラスのインスタンスです。 残りの引数は次の
     範囲の整数でなければなりません:

        * ‘MINYEAR <= year <= MAXYEAR’,

        * ‘1 <= month <= 12’,

        * ‘1 <= day <= 指定された月と年における日数’,

        * ‘0 <= hour < 24’,

        * ‘0 <= minute < 60’,

        * ‘0 <= second < 60’,

        * ‘0 <= microsecond < 1000000’,

        * ‘fold in [0, 1]’.

     範囲を超えた引数を与えた場合、 *note ValueError: 1e3. が送出されま
     す。

     バージョン 3.6 で変更: 'fold' パラメータが追加されました。

他のコンストラクタ、および全てのクラスメソッドを以下に示します:

 -- メソッド: classmethod datetime.today ()

     *note tzinfo: 2393. が ‘None’ である現在のローカルの日付および時刻
     を返します。

     次と等価です:

          datetime.fromtimestamp(time.time())

     *note now(): 4b9, *note fromtimestamp(): 4ba. も参照してください。

     このメソッドの機能は *note now(): 4b9. と等価ですが、 ‘tz’ 引数はあ
     りません。

 -- メソッド: classmethod datetime.now (tz=None)

     現在のローカルな日時を返します。

     オプションの引数 'tz' が ‘None’ であるか指定されていない場合、この
     メソッドは *note today(): 23b1. と同様ですが、可能ならば *note
     time.time(): 235. タイムスタンプを通じて得ることができる、より高い
     精度で時刻を提供します (例えば、プラットフォームが C 関数
     ‘gettimeofday()’ をサポートする場合には可能なことがあります)。

     'tz' が ‘None’ でない場合、 'tz' は *note tzinfo: 5a8. のサブクラス
     のインスタンスでなければならず、現在の日付および時刻は 'tz' のタイ
     ムゾーンに変換されます。

     *note today(): 23b1. および *note utcnow(): 2d3. よりもこの関数を使
     う方が好ましいです。

          注釈: Subsequent calls to ‘datetime.now()’ may return the same
          instant depending on the precision of the underlying clock.

 -- メソッド: classmethod datetime.utcnow ()

     *note tzinfo: 2393. が ‘None’ である現在の UTC の日付および時刻を返
     します。

     このメソッドは *note now(): 4b9. と似ていますが、 naive な *note
     datetime: 1ae. オブジェクトとして現在の UTC 日付および時刻を返しま
     す。 aware な現在の UTC datetime は ‘datetime.now(timezone.utc)’ を
     呼び出すことで取得できます。 *note now(): 4b9. も参照してください。

          警告: naive な ‘datetime’ オブジェクトは多くの ‘datetime’ メソ
          ッドでローカルな時間として扱われるため、 aware な datetime を
          使って UTC の時刻を表すのが好ましいです。 そのため、 UTC での
          現在の時刻を表すオブジェクトの作成では
          ‘datetime.now(timezone.utc)’ を呼び出す方法が推奨されます。

     バージョン 3.12 で非推奨: 代わりに *note UTC: 4bb. で *note
     datetime.now(): 4b9. を使用してください。

 -- メソッド: classmethod datetime.fromtimestamp (timestamp, tz=None)

     *note time.time(): 235. が返すような、 POSIX タイムスタンプに対応す
     るローカルな日付と時刻を返します。オプションの引数 'tz' が ‘None’ で
     あるか、指定されていない場合、タイムスタンプはプラットフォームのロ
     ーカルな日付および時刻に変換され、返される *note datetime: 1ae. オ
     ブジェクトは naive なものになります。

     'tz' が ‘None’ でない場合、 'tz' は *note tzinfo: 5a8. のサブクラス
     のインスタンスでなければならず、タイムスタンプは 'tz' のタイムゾー
     ンに変換されます。

     タイムスタンプがプラットフォームの C 関数 ‘localtime()’ や
     ‘gmtime()’ でサポートされている範囲を超えた場合、 *note
     fromtimestamp(): 4ba. は *note OverflowError: 84e. を送出することが
     あります。この範囲はよく 1970 年から 2038 年に制限されています。 ま
     た ‘localtime()’ や ‘gmtime()’ が失敗した際は *note OSError: 3f0. を
     送出します。 うるう秒がタイムスタンプの概念に含まれている非 POSIX シ
     ステムでは、 *note fromtimestamp(): 4ba. はうるう秒を無視します。 こ
     のため、秒の異なる二つのタイムスタンプが同一の *note datetime: 1ae.
     オブジェクトとなることが起こり得ます。 *note utcfromtimestamp():
     2d4. よりも、このメソッドの方が好ましいです。

     バージョン 3.3 で変更: timestamp がプラットフォームの C 関数
     ‘localtime()’ もしくは ‘gmtime()’ のサポートする値の範囲から外れて
     いた場合、 *note ValueError: 1e3. ではなく *note OverflowError:
     84e. を送出するようになりました。 ‘localtime()’ もしくは ‘gmtime()’
     の呼び出し失敗で *note ValueError: 1e3. ではなく *note OSError:
     3f0. を送出するようになりました。

     バージョン 3.6 で変更: *note fromtimestamp(): 4ba. は *note fold:
     c25. を1にしてインスタンスを返します。

 -- メソッド: classmethod datetime.utcfromtimestamp (timestamp)

     POSIX タイムスタンプに対応する、*note tzinfo: 2393. が ‘None’ の
     UTC での *note datetime: 1ae. を返します。(返されるオブジェクトは
     naive です。)

     タイムスタンプがプラットフォームにおける C 関数 ‘localtime()’ でサ
     ポートされている範囲を超えている場合には *note OverflowError: 84e.
     を、‘gmtime()’ が失敗した場合には *note OSError: 3f0. を送出します
     。 これはたいてい 1970 年から 2038 年に制限されています。

     aware な *note datetime: 1ae. オブジェクトを得るには *note
     fromtimestamp(): 4ba. を呼んでください:

          datetime.fromtimestamp(timestamp, timezone.utc)

     POSIX 互換プラットフォームでは、これは以下の表現と等価です:

          datetime(1970, 1, 1, tzinfo=timezone.utc) + timedelta(seconds=timestamp)

     後者を除き、式は常に年の全範囲 (*note MINYEAR: 2381. から *note
     MAXYEAR: 2382. を含みます) をサポートします。

          警告: naive な ‘datetime’ オブジェクトは多くの ‘datetime’ メソ
          ッドでローカルな時間として扱われるため、 aware な datetime を
          使って UTC の時刻を表すのが好ましいです。 そのため、 UTC での
          ある特定のタイムスタンプを表すオブジェクトの作成では
          ‘datetime.fromtimestamp(timestamp, tz=timezone.utc)’ を呼び出
          す方法が推奨されます。

     バージョン 3.3 で変更: timestamp がプラットフォームの C 関数
     ‘gmtime()’ のサポートする値の範囲から外れていた場合、 *note
     ValueError: 1e3. ではなく *note OverflowError: 84e. を送出するよう
     になりました。 ‘gmtime()’ の呼び出し失敗で *note ValueError: 1e3. で
     はなく *note OSError: 3f0. を送出するようになりました。

     バージョン 3.12 で非推奨: 代わりに *note UTC: 4bb. で *note
     datetime.fromtimestamp(): 4ba. を使用してください。

 -- メソッド: classmethod datetime.fromordinal (ordinal)

     1 年 1 月 1 日を序数 1 とする早期グレゴリオ暦序数に対応する *note
     datetime: 1ae. オブジェクトを返します。 ‘1 <= ordinal <=
     datetime.max.toordinal()’ でなければ *note ValueError: 1e3. が送出
     されます。 返されるオブジェクトの時間、分、秒、およびマイクロ秒はす
     べて 0 で、 *note tzinfo: 2393. は ‘None’ となっています。

 -- メソッド: classmethod datetime.combine (date, time,
          tzinfo=time.tzinfo)

     日付部分と与えられた *note date: 1af. オブジェクトとが等しく、時刻
     部分と与えられた *note time: 1b0. オブジェクトとが等しい、新しい
     *note datetime: 1ae. オブジェクトを返します。 'tzinfo' 引数が与えら
     れた場合、その値は返り値の *note tzinfo: 2393. 属性に設定するのに使
     われます。そうでない場合、 'time' 引数の *note tzinfo: 238b. 属性が
     使われます。'date' 引数に *note datetime: 1ae. オブジェクトが与えら
     れた場合、その時刻部分と *note tzinfo: 2393. 属性は無視されます。

     For any *note datetime: 1ae. object ‘d’, ‘d ==
     datetime.combine(d.date(), d.time(), d.tzinfo)’.

     バージョン 3.6 で変更: 'tzinfo' 引数が追加されました。

 -- メソッド: classmethod datetime.fromisoformat (date_string)

     以下の例外を除く、有効な ISO 8601 フォーマットで与えられた
     'date_string' に対応する *note datetime: 1ae. を返します :

       1. 小数の秒があるタイムゾーンオフセット。

       2. ‘T’ セパレーターを他の1文字のユニコードに置き換えたもの。

       3. 少数の時と分はサポートされていません。

       4. 精度の低い日付は現在サポートされていません(‘YYYY-MM’, ‘YYYY’)。

       5. 拡張された日付表現は現在サポートされていません
          (‘±YYYYYY-MM-DD’)。

       6. 序数の日付は現在サポートされていません(‘YYYY-OOO’)。

     例:

          >>> from datetime import datetime
          >>> datetime.fromisoformat('2011-11-04')
          datetime.datetime(2011, 11, 4, 0, 0)
          >>> datetime.fromisoformat('20111104')
          datetime.datetime(2011, 11, 4, 0, 0)
          >>> datetime.fromisoformat('2011-11-04T00:05:23')
          datetime.datetime(2011, 11, 4, 0, 5, 23)
          >>> datetime.fromisoformat('2011-11-04T00:05:23Z')
          datetime.datetime(2011, 11, 4, 0, 5, 23, tzinfo=datetime.timezone.utc)
          >>> datetime.fromisoformat('20111104T000523')
          datetime.datetime(2011, 11, 4, 0, 5, 23)
          >>> datetime.fromisoformat('2011-W01-2T00:05:23.283')
          datetime.datetime(2011, 1, 4, 0, 5, 23, 283000)
          >>> datetime.fromisoformat('2011-11-04 00:05:23.283')
          datetime.datetime(2011, 11, 4, 0, 5, 23, 283000)
          >>> datetime.fromisoformat('2011-11-04 00:05:23.283+00:00')
          datetime.datetime(2011, 11, 4, 0, 5, 23, 283000, tzinfo=datetime.timezone.utc)
          >>> datetime.fromisoformat('2011-11-04T00:05:23+04:00')
          datetime.datetime(2011, 11, 4, 0, 5, 23,
              tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))

     Added in version 3.7.

     バージョン 3.11 で変更: Previously, this method only supported
     formats that could be emitted by *note date.isoformat(): 23a9. or
     *note datetime.isoformat(): afe.

 -- メソッド: classmethod datetime.fromisocalendar (year, week, day)

     年月日で指定された ISO 暦の日付に対応する *note datetime: 1ae. を返
     します。 datetime の日付でない部分は、標準のデフォルト値で埋められ
     ます。 この関数は *note datetime.isocalendar(): 8c4. の逆関数です。

     Added in version 3.8.

 -- メソッド: classmethod datetime.strptime (date_string, format)

     'date_string' に対応した *note datetime: 1ae. を返します。 'format'
     にしたがって構文解析されます。

     'format' がマイクロ秒やタイムゾーン情報を含まない場合は、以下と等価
     です:

          datetime(*(time.strptime(date_string, format)[0:6]))

     date_string と format が *note time.strptime(): 13d4. で構文解析で
     きない場合や、この関数が時刻タプルを返してこない場合には *note
     ValueError: 1e3. を送出します。*note strftime() と strptime()
     の振る舞い: 1734. および *note datetime.fromisoformat(): 5e2. も参
     照してください。

     バージョン 3.13 で変更: If 'format' specifies a day of month
     without a year a *note DeprecationWarning: 18a. is now emitted.
     This is to avoid a quadrennial leap year bug in code seeking to
     parse only a month and day as the default year used in absence of
     one in the format is not a leap year.  Such 'format' values may
     raise an error as of Python 3.15.  The workaround is to always
     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:

          >>> from datetime import datetime
          >>> date_string = "02/29"
          >>> when = datetime.strptime(f"{date_string};1984", "%m/%d;%Y")  # Avoids leap year bug.
          >>> when.strftime("%B %d")
          'February 29'

以下にクラス属性を示します:

 -- の属性: datetime.min

     表現できる最も古い *note datetime: 1ae. で、 ‘datetime(MINYEAR, 1,
     1, tzinfo=None)’ です。

 -- の属性: datetime.max

     表現できる最も新しい *note datetime: 1ae. で、 ‘datetime(MAXYEAR,
     12, 31, 23, 59, 59, 999999, tzinfo=None)’ です。

 -- の属性: datetime.resolution

     等しくない *note datetime: 1ae. オブジェクト間の最小の差で、
     ‘timedelta(microseconds=1)’ です。

インスタンスの属性 (読み出しのみ):

 -- の属性: datetime.year

     両端値を含む *note MINYEAR: 2381. から *note MAXYEAR: 2382. までの
     値です。

 -- の属性: datetime.month

     両端値を含む 1 から 12 までの値です。

 -- の属性: datetime.day

     1 から与えられた月と年における日数までの値です。

 -- の属性: datetime.hour

     in ‘range(24)’ を満たします。

 -- の属性: datetime.minute

     in ‘range(60)’ を満たします。

 -- の属性: datetime.second

     in ‘range(60)’ を満たします。

 -- の属性: datetime.microsecond

     in ‘range(1000000)’ を満たします。

 -- の属性: datetime.tzinfo

     *note datetime: 1ae. コンストラクタに 'tzinfo' 引数として与えられた
     オブジェクトになり、何も渡されなかった場合には ‘None’ になります。

 -- の属性: datetime.fold

     ‘[0, 1]’ のどちらかです。 繰り返し期間中の実時間の曖昧さ除去に使わ
     れます。 (繰り返し期間は、夏時間の終わりに時計が巻き戻るときや、現
     在のゾーンの UTC オフセットが政治的な理由で減少するときに発生します
     。) 0または1という値は、同じ実時間で表現される 2 つの時刻のうちのそ
     れぞれ早い方または遅い方を表します。

     Added in version 3.6.

サポートされている演算を以下に示します:

演算                                        結果
                                            
---------------------------------------------------------------------------------
                                            
‘datetime2 = datetime1 + timedelta’         (1)
                                            
                                            
‘datetime2 = datetime1 - timedelta’         (2)
                                            
                                            
‘timedelta = datetime1 - datetime2’         (3)
                                            
                                            
     ‘datetime1 == datetime2’               等価性の比較。(4)
     ‘datetime1 != datetime2’               

     ‘datetime1 < datetime2’                順序の比較。(5)
     ‘datetime1 > datetime2’                
     ‘datetime1 <= datetime2’
     ‘datetime1 >= datetime2’

  1. ‘datetime2’ は ‘datetime1’ から時間 ‘timedelta’ 移動したもので、
     ‘timedelta.days > 0’ の場合未来へ、‘timedelta.days < 0’ の場合過去
     へ移動します。 結果は入力の datetime と同じ *note tzinfo: 2393. 属
     性を持ち、演算後には ‘datetime2 - datetime1 == timedelta’ となりま
     す。 ‘datetime2.year’ が *note MINYEAR: 2381. よりも小さいか、
     *note MAXYEAR: 2382. より大きい場合には *note OverflowError: 84e. が
     送出されます。 入力が aware なオブジェクトの場合でもタイムゾーン修
     正は全く行われません。

  2. ‘datetime2 + timedelta == datetime1’ となるような ‘datetime2’ を計
     算します。 ちなみに、結果は入力の datetime と同じ *note tzinfo:
     2393. 属性を持ち、入力が aware だとしてもタイムゾーン修正は全く行わ
     れません。

  3. *note datetime: 1ae. から *note datetime: 1ae. の減算は両方の被演算
     子が naive であるか、両方とも aware である場合にのみ定義されていま
     す。片方が aware でもう一方が naive の場合、 *note TypeError: 502.
     が送出されます。

     If both are naive, or both are aware and have the same *note
     tzinfo: 2393. attribute, the *note tzinfo: 2393. attributes are
     ignored, and the result is a *note timedelta: 99d. object ‘t’ such
     that ‘datetime2 + t == datetime1’.  No time zone adjustments are
     done in this case.

     If both are aware and have different *note tzinfo: 2393.
     attributes, ‘a-b’ acts as if ‘a’ and ‘b’ were first converted to
     naive UTC datetimes.  The result is ‘(a.replace(tzinfo=None) -
     a.utcoffset()) - (b.replace(tzinfo=None) - b.utcoffset())’ except
     that the implementation never overflows.

  4. *note datetime: 1ae. オブジェクトはタイムゾーンを考慮して同じ日付と
     時刻を表す場合、等しいです。

     Naive and aware ‘datetime’ objects are never equal.

     If both comparands are aware, and have the same ‘tzinfo’ attribute,
     the ‘tzinfo’ and *note fold: c25. attributes are ignored and the
     base datetimes are compared.  If both comparands are aware and have
     different *note tzinfo: 2393. attributes, the comparison acts as
     comparands were first converted to UTC datetimes except that the
     implementation never overflows.  ‘datetime’ instances in a repeated
     interval are never equal to ‘datetime’ instances in other time
     zone.

  5. タイムゾーンを考慮して、'datetime1' が時刻として 'datetime2' よりも
     前を表す場合に、'datetime1' は 'datetime2' よりも小さいと見なされま
     す。

     Order comparison between naive and aware *note datetime: 1ae.
     objects raises *note TypeError: 502.

     If both comparands are aware, and have the same ‘tzinfo’ attribute,
     the ‘tzinfo’ and *note fold: c25. attributes are ignored and the
     base datetimes are compared.  If both comparands are aware and have
     different *note tzinfo: 2393. attributes, the comparison acts as
     comparands were first converted to UTC datetimes except that the
     implementation never overflows.

バージョン 3.3 で変更: aware な *note datetime: 1ae. インスタンスと
naive な *note datetime: 1ae. インスタンスの等価比較では *note
TypeError: 502. は送出されません。

バージョン 3.13 で変更: Comparison between *note datetime: 1ae. object
and an instance of the *note date: 1af. subclass that is not a
‘datetime’ subclass no longer converts the latter to ‘date’, ignoring
the time part and the time zone.  The default behavior can be changed by
overriding the special comparison methods in subclasses.

インスタンスメソッド:

 -- メソッド: datetime.date ()

     同じ年、月、日の *note date: 1af. オブジェクトを返します。

 -- メソッド: datetime.time ()

     同じhour、minute、second、microsecond 及び foldを持つ *note time:
     1b0. オブジェクトを返します。 *note tzinfo: 2393. は ‘None’ です。
     *note timetz(): 23b7. も参照してください。

     バージョン 3.6 で変更: 値 foldは返される *note time: 1b0. オブジェ
     クトにコピーされます。

 -- メソッド: datetime.timetz ()

     同じhour、minute、second、microsecond、fold および tzinfo 属性を持
     つ *note time: 1b0. オブジェクトを返します。 *note time(): d7. メソ
     ッドも参照してください。

     バージョン 3.6 で変更: 値 foldは返される *note time: 1b0. オブジェ
     クトにコピーされます。

 -- メソッド: datetime.replace (year=self.year, month=self.month,
          day=self.day, hour=self.hour, minute=self.minute,
          second=self.second, microsecond=self.microsecond,
          tzinfo=self.tzinfo, *, fold=0)

     キーワード引数で指定した属性の値を除き、同じ属性をもつ datetime オ
     ブジェクトを返します。メンバに対する変換を行わずに aware な
     datetime オブジェクトから naive な datetime オブジェクトを生成する
     ために、‘tzinfo=None’ を指定することもできます。

     *note datetime: 1ae. オブジェクトは汎用的な関数 *note
     copy.replace(): 137. にもサポートされています。

     バージョン 3.6 で変更: 'fold' パラメータが追加されました。

 -- メソッド: datetime.astimezone (tz=None)

     'tz' を新たに *note tzinfo: 2393. 属性 として持つ *note datetime:
     1ae. オブジェクトを返します。 日付および時刻データを調整して、返り
     値が 'self' と同じ UTC 時刻を持ち、 'tz' におけるローカルな時刻を表
     すようにします。

     もし与えられた場合、 'tz' は *note tzinfo: 5a8. のサブクラスのイン
     スタンスでなければならず、 インスタンスの *note utcoffset(): 23b8.
     および *note dst(): 23b9. メソッドは ‘None’ を返してはなりません。
     もし 'self' が naive ならば、おそらくシステムのタイムゾーンで時間を
     表現します。

     引数無し (もしくは ‘tz=None’ の形 ) で呼び出された場合、システムの
     ローカルなタイムゾーンが変更先のタイムゾーンだと仮定されます。 変換
     後の datetime インスタンスの ‘.tzinfo’ 属性には、 OS から取得したゾ
     ーン名とオフセットを持つ *note timezone: 1091. インスタンスが設定さ
     れます。

     ‘self.tzinfo’ が 'tz' の場合、 ‘self.astimezone(tz)’ は 'self' に等
     しくなります。つまり、date および time に対する調整は行われません。
     そうでない場合、結果はタイムゾーン 'tz' におけるローカル時刻で、
     'self' と同じ UTC 時刻を表すようになります。これは、‘astz =
     dt.astimezone(tz)’ とした後、 ‘astz - astz.utcoffset()’ は通常 ‘dt
     - dt.utcoffset()’ と同じ date および time を持つことを示します。

     単に *note timezone: 1091. オブジェクト 'tz' を *note datetime: 28.
     オブジェクト 'dt' に追加したいだけで、日付や時刻データへの調整を行
     わないのなら、‘dt.replace(tzinfo=tz)’ を使ってください。単に aware
     な *note datetime: 28. オブジェクト 'dt' から ‘timezone’ オブジェク
     トを除去したいだけで、日付や時刻データの変換を行わないのなら、
     ‘dt.replace(tzinfo=None)’ を使ってください。

     デフォルトの *note tzinfo.fromutc(): 23ba. メソッドを *note tzinfo:
     5a8. のサブクラスで上書きして, *note astimezone(): 99e. が返す結果
     に影響を及ぼすことができます。エラーの場合を無視すると、 *note
     astimezone(): 99e. は以下のように動作します:

          def astimezone(self, tz):
              if self.tzinfo is tz:
                  return self
              # Convert self to UTC, and attach the new timezone object.
              utc = (self - self.utcoffset()).replace(tzinfo=tz)
              # Convert from UTC to tz's local time.
              return tz.fromutc(utc)

     バージョン 3.3 で変更: 'tz' が省略可能になりました。

     バージョン 3.6 で変更: *note datetime.datetime.astimezone(): 99e. メ
     ソッドを naive なインスタンスに対して呼び出せるようになりました。こ
     れは、システムのローカルな時間を表現していると想定されます。

 -- メソッド: datetime.utcoffset ()

     *note tzinfo: 2393. が ‘None’ の場合、 ‘None’ を返し、そうでない場
     合には ‘self.tzinfo.utcoffset(self)’ を返します。 後者の式が ‘None’
     あるいは 1 日以下の大きさを持つ *note timedelta: 99d. オブジェクト
     のいずれかを返さない場合には例外を送出します。

     バージョン 3.7 で変更: UTC オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: datetime.dst ()

     *note tzinfo: 2393. が ‘None’ の場合 ‘None’ を返し、そうでない場合
     には ‘self.tzinfo.dst(self)’ を返します。 後者の式が ‘None’ もしく
     は、1 日未満の大きさを持つ *note timedelta: 99d. オブジェクトのいず
     れかを返さない場合には例外を送出します。

     バージョン 3.7 で変更: DST オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: datetime.tzname ()

     *note tzinfo: 2393. が ‘None’ の場合 ‘None’ を返し、そうでない場合
     には ‘self.tzinfo.tzname(self)’ を返します。 後者の式が ‘None’ か文
     字列オブジェクトのいずれかを返さない場合には例外を送出します。

 -- メソッド: datetime.timetuple ()

     *note time.localtime(): 14a2. が返すような *note time.struct_time:
     cb8. を返します。

     ‘d.timetuple()’ は次の式と等価です:

          time.struct_time((d.year, d.month, d.day,
                            d.hour, d.minute, d.second,
                            d.weekday(), yday, dst))

     ここで ‘yday = d.toordinal() - date(d.year, 1, 1).toordinal() + 1’
     はその年の1月1日を 1 としたときのその日の位置です。 返されるタプル
     の *note tm_isdst: 23bd. フラグは *note dst(): 23b9. メソッドに従っ
     て設定されます: *note tzinfo: 2393. が ‘None’ か *note dst(): 23b9.
     が ‘None’ を返す場合、 ‘tm_isdst’ は ‘-1’ に設定されます; そうでな
     い場合、 *note dst(): 23b9. がゼロでない値を返すと ‘tm_isdst’ は1と
     なります; それ以外の場合には ‘tm_isdst’ は0に設定されます。

 -- メソッド: datetime.utctimetuple ()

     If *note datetime: 1ae. instance ‘d’ is naive, this is the same as
     ‘d.timetuple()’ except that *note tm_isdst: 23bd. is forced to 0
     regardless of what ‘d.dst()’ returns.  DST is never in effect for a
     UTC time.

     If ‘d’ is aware, ‘d’ is normalized to UTC time, by subtracting
     ‘d.utcoffset()’, and a *note time.struct_time: cb8. for the
     normalized time is returned.  ‘tm_isdst’ is forced to 0.  Note that
     an *note OverflowError: 84e. may be raised if ‘d.year’ was
     ‘MINYEAR’ or ‘MAXYEAR’ and UTC adjustment spills over a year
     boundary.

          警告: naive な ‘datetime’ オブジェクトは多くの ‘datetime’ メソ
          ッドでローカルな時間として扱われるため、 aware な datetime を
          使って UTC の時刻を表すのが好ましいです。結果として、 *note
          datetime.utctimetuple(): 23be. は誤解を招きやすい返り値を返す
          かもしれません。 UTC を表す naive な ‘datetime’ があった場合、
          *note datetime.timetuple(): 23bc. が使えるところでは
          ‘datetime.replace(tzinfo=timezone.utc)’ で aware にします。

 -- メソッド: datetime.toordinal ()

     先発グレゴリオ暦における日付序数を返します。
     ‘self.date().toordinal()’ と同じです。

 -- メソッド: datetime.timestamp ()

     *note datetime: 1ae. インスタンスに対応する POSIX タイムスタンプを
     返します。 返り値は *note time.time(): 235. で返される値に近い
     *note float: 2ce. です。

     このメソッドでは naive な *note datetime: 1ae. インスタンスはローカ
     ル時刻とし、プラットフォームの C 関数 ‘mktime()’ に頼って変換を行い
     ます。 *note datetime: 1ae. は多くのプラットフォームの ‘mktime()’ よ
     り広い範囲の値をサポートしているので、遥か過去の時刻や遥か未来の時
     刻に対し、このメソッドは *note OverflowError: 84e. または *note
     OSError: 3f0. を送出するかもしれません。

     aware な *note datetime: 1ae. インスタンスに対しては以下のように返
     り値が計算されます:

          (dt - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()

     Added in version 3.3.

     バージョン 3.6 で変更: The *note timestamp(): 106f. method uses the
     *note fold: c25. attribute to disambiguate the times during a
     repeated interval.

          注釈: UTC 時刻を表す naive な *note datetime: 1ae. インスタン
          スから直接 POSIX タイムスタンプを取得するメソッドはありません
          。 アプリケーションがその変換を使っており、システムのタイムゾ
          ーンが UTC に設定されていなかった場合、 ‘tzinfo=timezone.utc’
          を引数に与えることで POSIX タイムスタンプを取得できます:

               timestamp = dt.replace(tzinfo=timezone.utc).timestamp()

          もしくは直接タイムスタンプを計算することもできます:

               timestamp = (dt - datetime(1970, 1, 1)) / timedelta(seconds=1)

 -- メソッド: datetime.weekday ()

     月曜日を 0、日曜日を 6 として、曜日を整数で返します。
     ‘self.date().weekday()’ と同じです。 *note isoweekday(): 23c1. も参
     照してください。

 -- メソッド: datetime.isoweekday ()

     月曜日を 1、日曜日を 7 として、曜日を整数で返します。
     ‘self.date().isoweekday()’ と等価です。 *note weekday(): 23c0. 、
     *note isocalendar(): 8c4. も参照してください。

 -- メソッド: datetime.isocalendar ()

     ‘year’、‘week’、‘weekday’ の3つで構成された *note named tuple: 61a.
     を返します。 ‘self.date().isocalendar()’ と等価です。

 -- メソッド: datetime.isoformat (sep='T', timespec='auto')

     日時を ISO 8601 書式で表した文字列で返します:

        - *note microsecond: 2392. が 0 でない場合は
          ‘YYYY-MM-DDTHH:MM:SS.ffffff’

        - *note microsecond: 2392. が 0 の場合は ‘YYYY-MM-DDTHH:MM:SS’

     *note utcoffset(): 23b8. が ‘None’ を返さない場合は、文字列の後ろに
     UTC オフセットが追記されます:

        - *note microsecond: 2392. が 0 でない場合は
          ‘YYYY-MM-DDTHH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]’

        - *note microsecond: 2392. が 0 の場合は
          ‘YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]]’

     例:

          >>> from datetime import datetime, timezone
          >>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()
          '2019-05-18T15:17:08.132263'
          >>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat()
          '2019-05-18T15:17:00+00:00'

     オプションの引数 'sep' (デフォルトでは ‘'T'’ です) は 1 文字のセパ
     レータで、結果の文字列の日付と時刻の間に置かれます。例えば:

          >>> from datetime import tzinfo, timedelta, datetime
          >>> class TZ(tzinfo):
          ...     """A time zone with an arbitrary, constant -06:39 offset."""
          ...     def utcoffset(self, dt):
          ...         return timedelta(hours=-6, minutes=-39)
          ...
          >>> datetime(2002, 12, 25, tzinfo=TZ()).isoformat(' ')
          '2002-12-25 00:00:00-06:39'
          >>> datetime(2009, 11, 27, microsecond=100, tzinfo=TZ()).isoformat()
          '2009-11-27T00:00:00.000100-06:39'

     オプション引数 'timespec' は、含める追加の時間の要素の数を指定しま
     す(デフォルトでは ‘'auto'’ です)。以下の内一つを指定してください。

        - ‘'auto'’: *note microsecond: 2392. が0である場合 ‘'seconds'’ と
          等しく、そうでない場合は ‘'microseconds'’ と等しくなります。

        - ‘'hours'’: *note hour: 238f. を2桁の ‘HH’ 書式で含めます。

        - ‘'minutes'’: *note hour: 238f. および *note minute: 2390. を
          ‘HH:MM’ の書式で含めます。

        - ‘'seconds'’: *note hour: 238f. 、 *note minute: 2390. 、 *note
          second: 2391. を ‘HH:MM:SS’ の書式で含めます。

        - ‘'milliseconds'’: 全ての時刻を含みますが、小数第二位をミリ秒に
          切り捨てます。 ‘HH:MM:SS.sss’ の書式で表現します。

        - ‘'microseconds'’: 全ての時刻を ‘HH:MM:SS.mmmmmm’ の書式で含め
          ます。

          注釈: 除外された要素は丸め込みではなく、切り捨てされます。

     不正な 'timespec' 引数には *note ValueError: 1e3. があげられます:

          >>> from datetime import datetime
          >>> datetime.now().isoformat(timespec='minutes')
          '2002-12-25T00:00'
          >>> dt = datetime(2015, 1, 1, 12, 30, 59, 0)
          >>> dt.isoformat(timespec='microseconds')
          '2015-01-01T12:30:59.000000'

     バージョン 3.6 で変更: 'timespec' パラメータを追加しました.

 -- メソッド: datetime.__str__ ()

     For a *note datetime: 1ae. instance ‘d’, ‘str(d)’ is equivalent to
     ‘d.isoformat(' ')’.

 -- メソッド: datetime.ctime ()

     日付および時刻を表す文字列を返します:

          >>> from datetime import datetime
          >>> datetime(2002, 12, 4, 20, 30, 40).ctime()
          'Wed Dec  4 20:30:40 2002'

     出力文字列は入力が aware であれ naive であれ、タイムゾーン情報を含
     み 'ません'。

     ‘d.ctime()’ は次の式と等価です:

          time.ctime(time.mktime(d.timetuple()))

     これが等価になるのは、 (*note time.ctime(): 23ac. に呼び出され、
     *note datetime.ctime(): 23c3. に呼び出されない) ネイティブの C 関数
     ‘ctime()’ が C 標準に準拠しているプラットフォーム上でです。

 -- メソッド: datetime.strftime (format)

     明示的な書式文字列で制御された、日付および時刻を表現する文字列を返
     します。*note strftime() と strptime() の振る舞い: 1734. および
     *note datetime.isoformat(): afe. も参照してください。

 -- メソッド: datetime.__format__ (format)

     *note datetime.strftime(): c5e. と等価です。 これにより、 *note
     フォーマット済み文字列リテラル: 977. の中や *note str.format():
     5ed. を使っているときに *note datetime: 1ae. オブジェクトの書式文字
     列を指定できます。 *note strftime() と strptime() の振る舞い: 1734.
     および *note datetime.isoformat(): afe. も参照してください。

* Menu:

* 使用例; datetime: 使用例 datetime.


File: python.info,  Node: 使用例 datetime,  Up: datetime オブジェクト

5.8.1.11 使用例: ‘datetime’
...........................

*note datetime: 1ae. オブジェクトを使う例:

     >>> from datetime import datetime, date, time, timezone

     >>> # Using datetime.combine()
     >>> d = date(2005, 7, 14)
     >>> t = time(12, 30)
     >>> datetime.combine(d, t)
     datetime.datetime(2005, 7, 14, 12, 30)

     >>> # Using datetime.now()
     >>> datetime.now()
     datetime.datetime(2007, 12, 6, 16, 29, 43, 79043)   # GMT +1
     >>> datetime.now(timezone.utc)
     datetime.datetime(2007, 12, 6, 15, 29, 43, 79060, tzinfo=datetime.timezone.utc)

     >>> # Using datetime.strptime()
     >>> dt = datetime.strptime("21/11/06 16:30", "%d/%m/%y %H:%M")
     >>> dt
     datetime.datetime(2006, 11, 21, 16, 30)

     >>> # Using datetime.timetuple() to get tuple of all attributes
     >>> tt = dt.timetuple()
     >>> for it in tt:
     ...     print(it)
     ...
     2006    # year
     11      # month
     21      # day
     16      # hour
     30      # minute
     0       # second
     1       # weekday (0 = Monday)
     325     # number of days since 1st January
     -1      # dst - method tzinfo.dst() returned None

     >>> # Date in ISO format
     >>> ic = dt.isocalendar()
     >>> for it in ic:
     ...     print(it)
     ...
     2006    # ISO year
     47      # ISO week
     2       # ISO weekday

     >>> # Formatting a datetime
     >>> dt.strftime("%A, %d. %B %Y %I:%M%p")
     'Tuesday, 21. November 2006 04:30PM'
     >>> 'The {1} is {0:%d}, the {2} is {0:%B}, the {3} is {0:%I:%M%p}.'.format(dt, "day", "month", "time")
     'The day is 21, the month is November, the time is 04:30PM.'

下にある例では、1945年までは +4 UTC 、それ以降は +4:30 UTC を使用してい
るアフガニスタンのカブールのタイムゾーン情報を表現する *note tzinfo:
5a8. のサブクラスを定義しています:

     from datetime import timedelta, datetime, tzinfo, timezone

     class KabulTz(tzinfo):
         # Kabul used +4 until 1945, when they moved to +4:30
         UTC_MOVE_DATE = datetime(1944, 12, 31, 20, tzinfo=timezone.utc)

         def utcoffset(self, dt):
             if dt.year < 1945:
                 return timedelta(hours=4)
             elif (1945, 1, 1, 0, 0) <= dt.timetuple()[:5] < (1945, 1, 1, 0, 30):
                 # An ambiguous ("imaginary") half-hour range representing
                 # a 'fold' in time due to the shift from +4 to +4:30.
                 # If dt falls in the imaginary range, use fold to decide how
                 # to resolve. See PEP495.
                 return timedelta(hours=4, minutes=(30 if dt.fold else 0))
             else:
                 return timedelta(hours=4, minutes=30)

         def fromutc(self, dt):
             # Follow same validations as in datetime.tzinfo
             if not isinstance(dt, datetime):
                 raise TypeError("fromutc() requires a datetime argument")
             if dt.tzinfo is not self:
                 raise ValueError("dt.tzinfo is not self")

             # A custom implementation is required for fromutc as
             # the input to this function is a datetime with utc values
             # but with a tzinfo set to self.
             # See datetime.astimezone or fromtimestamp.
             if dt.replace(tzinfo=timezone.utc) >= self.UTC_MOVE_DATE:
                 return dt + timedelta(hours=4, minutes=30)
             else:
                 return dt + timedelta(hours=4)

         def dst(self, dt):
             # Kabul does not observe daylight saving time.
             return timedelta(0)

         def tzname(self, dt):
             if dt >= self.UTC_MOVE_DATE:
                 return "+04:30"
             return "+04"

上に出てきた ‘KabulTz’ の使い方:

     >>> tz1 = KabulTz()

     >>> # Datetime before the change
     >>> dt1 = datetime(1900, 11, 21, 16, 30, tzinfo=tz1)
     >>> print(dt1.utcoffset())
     4:00:00

     >>> # Datetime after the change
     >>> dt2 = datetime(2006, 6, 14, 13, 0, tzinfo=tz1)
     >>> print(dt2.utcoffset())
     4:30:00

     >>> # Convert datetime to another time zone
     >>> dt3 = dt2.astimezone(timezone.utc)
     >>> dt3
     datetime.datetime(2006, 6, 14, 8, 30, tzinfo=datetime.timezone.utc)
     >>> dt2
     datetime.datetime(2006, 6, 14, 13, 0, tzinfo=KabulTz())
     >>> dt2 == dt3
     True


File: python.info,  Node: time オブジェクト,  Next: tzinfo オブジェクト,  Prev: datetime オブジェクト,  Up: datetime --- 基本的な日付と時間の型

5.8.1.12 ‘time’ オブジェクト
............................

*note time: 1b0. オブジェクトは (ローカルの) 日中時刻を表現します。 この
時刻表現は特定の日の影響を受けず、 *note tzinfo: 5a8. オブジェクトを介し
た修正の対象となります。

 -- クラス: datetime.time (hour=0, minute=0, second=0, microsecond=0,
          tzinfo=None, *, fold=0)

     全ての引数はオプションです。 'tzinfo' は ‘None’ または *note
     tzinfo: 5a8. クラスのサブクラスのインスタンスにすることができます。
     残りの引数は整数で、以下のような範囲に入らなければなりません:

        * ‘0 <= hour < 24’,

        * ‘0 <= minute < 60’,

        * ‘0 <= second < 60’,

        * ‘0 <= microsecond < 1000000’,

        * ‘fold in [0, 1]’.

     引数がこれらの範囲外にある場合、 *note ValueError: 1e3. が送出され
     ます。 'tzinfo' のデフォルト値が ‘None’ である以外のデフォルト値は
     0です。

以下にクラス属性を示します:

 -- の属性: time.min

     表現できる最も古い *note time: 1b0. で、 ‘time(0, 0, 0, 0)’ です。

 -- の属性: time.max

     表現できる最も新しい *note time: 1b0. で、 ‘time(23, 59, 59,
     999999)’ です。

 -- の属性: time.resolution

     等しくない *note time: 1b0. オブジェクト間の最小の差で、
     ‘timedelta(microseconds=1)’ ですが, *note time: 1b0. オブジェクト間
     の四則演算はサポートされていないので注意してください。

インスタンスの属性 (読み出しのみ):

 -- の属性: time.hour

     in ‘range(24)’ を満たします。

 -- の属性: time.minute

     in ‘range(60)’ を満たします。

 -- の属性: time.second

     in ‘range(60)’ を満たします。

 -- の属性: time.microsecond

     in ‘range(1000000)’ を満たします。

 -- の属性: time.tzinfo

     *note time: 1b0. コンストラクタに 'tzinfo' 引数として与えられたオブ
     ジェクトになり、何も渡されなかった場合には ‘None’ になります。

 -- の属性: time.fold

     ‘[0, 1]’ のどちらかです。 繰り返し期間中の実時間の曖昧さ除去に使わ
     れます。 (繰り返し期間は、夏時間の終わりに時計が巻き戻るときや、現
     在のゾーンの UTC オフセットが政治的な理由で減少するときに発生します
     。) 0または1という値は、同じ実時間で表現される 2 つの時刻のうちのそ
     れぞれ早い方または遅い方を表します。

     Added in version 3.6.

*note time: 1b0. objects support equality and order comparisons, where
‘a’ is considered less than ‘b’ when ‘a’ precedes ‘b’ in time.

Naive and aware ‘time’ objects are never equal.  Order comparison
between naive and aware ‘time’ objects raises *note TypeError: 502.

比較対象が両方とも aware であり、同じ *note tzinfo: 238b. 属性を持つ場合
、 ‘tzinfo’ と ‘fold’ 属性は無視され時間だけで比較が行われます。比較対象
が両方とも aware であり、異なる ‘tzinfo’ 属性を持つ場合、まず最初に
(‘self.utcoffset()’ で取得できる) それぞれの UTC オフセットを引く調整が
行われます。

バージョン 3.3 で変更: aware な インスタンスと naive な *note time: 1b0.
インスタンスの等価比較では *note TypeError: 502. は送出されません。

ブール値の文脈では、 *note time: 1b0. オブジェクトは常に真とみなされます
。

バージョン 3.5 で変更: Python 3.5 以前は、 *note time: 1b0. オブジェクト
は UTC で深夜を表すときに偽とみなされていました。 この挙動は分かりにくく
、エラーの元となると考えられ、Python 3.5 で削除されました。 全詳細につい
ては bpo-13936(1) を参照してください。

その他のコンストラクタ:

 -- メソッド: classmethod time.fromisoformat (time_string)

     以下の例外を除く、有効な ISO 8601 フォーマットで与えられた
     'time_string' に対応する *note time: 1b0. を返します :

       1. 小数の秒があるタイムゾーンオフセット。

       2. The leading ‘T’, normally required in cases where there may be
          ambiguity between a date and a time, is not required.

       3. Fractional seconds may have any number of digits (anything
          beyond 6 will be truncated).

       4. 少数の時と分はサポートされていません。

     例:

          >>> from datetime import time
          >>> time.fromisoformat('04:23:01')
          datetime.time(4, 23, 1)
          >>> time.fromisoformat('T04:23:01')
          datetime.time(4, 23, 1)
          >>> time.fromisoformat('T042301')
          datetime.time(4, 23, 1)
          >>> time.fromisoformat('04:23:01.000384')
          datetime.time(4, 23, 1, 384)
          >>> time.fromisoformat('04:23:01,000384')
          datetime.time(4, 23, 1, 384)
          >>> time.fromisoformat('04:23:01+04:00')
          datetime.time(4, 23, 1, tzinfo=datetime.timezone(datetime.timedelta(seconds=14400)))
          >>> time.fromisoformat('04:23:01Z')
          datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)
          >>> time.fromisoformat('04:23:01+00:00')
          datetime.time(4, 23, 1, tzinfo=datetime.timezone.utc)

     Added in version 3.7.

     バージョン 3.11 で変更: Previously, this method only supported
     formats that could be emitted by *note time.isoformat(): 23cc.

インスタンスメソッド:

 -- メソッド: time.replace (hour=self.hour, minute=self.minute,
          second=self.second, microsecond=self.microsecond,
          tzinfo=self.tzinfo, *, fold=0)

     キーワード引数で指定したメンバの値を除き、同じ値をもつ *note time:
     1b0. オブジェクトを返します。データに対する変換を行わずに aware な
     *note time: 1b0. オブジェクトから naive な *note time: 1b0. オブジ
     ェクトを生成するために、 ‘tzinfo=None’ を指定することもできます。

     *note time: 1b0. オブジェクトは汎用的な関数 *note copy.replace():
     137. にもサポートされています。

     バージョン 3.6 で変更: 'fold' パラメータが追加されました。

 -- メソッド: time.isoformat (timespec='auto')

     時刻を ISO 8601 書式で表した次の文字列のうち1つを返します:

        - *note microsecond: 238a. が 0 でない場合は ‘HH:MM:SS.ffffff’

        - *note microsecond: 238a. が 0 の場合は ‘HH:MM:SS’

        - *note utcoffset(): 23cd. が ‘None’ を返さない場合、
          ‘HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]]’

        - *note microsecond: 238a. が 0 で *note utcoffset(): 23cd. が
          ‘None’ を返さない場合、 ‘HH:MM:SS+HH:MM[:SS[.ffffff]]’

     オプション引数 'timespec' は、含める追加の時間の要素の数を指定しま
     す(デフォルトでは ‘'auto'’ です)。以下の内一つを指定してください。

        - ‘'auto'’: *note microsecond: 238a. が0である場合 ‘'seconds'’ と
          等しく、そうでない場合は ‘'microseconds'’ と等しくなります。

        - ‘'hours'’: *note hour: 2387. を2桁の ‘HH’ 書式で含めます。

        - ‘'minutes'’: *note hour: 2387. および *note minute: 2388. を
          ‘HH:MM’ の書式で含めます。

        - ‘'seconds'’: *note hour: 2387. 、 *note minute: 2388. 、 *note
          second: 2389. を ‘HH:MM:SS’ の書式で含めます。

        - ‘'milliseconds'’: 全ての時刻を含みますが、小数第二位をミリ秒に
          切り捨てます。 ‘HH:MM:SS.sss’ の書式で表現します。

        - ‘'microseconds'’: 全ての時刻を ‘HH:MM:SS.mmmmmm’ の書式で含め
          ます。

          注釈: 除外された要素は丸め込みではなく、切り捨てされます。

     不正な 'timespec' 引数には *note ValueError: 1e3. があげられます。

     以下はプログラム例です:

          >>> from datetime import time
          >>> time(hour=12, minute=34, second=56, microsecond=123456).isoformat(timespec='minutes')
          '12:34'
          >>> dt = time(hour=12, minute=34, second=56, microsecond=0)
          >>> dt.isoformat(timespec='microseconds')
          '12:34:56.000000'
          >>> dt.isoformat(timespec='auto')
          '12:34:56'

     バージョン 3.6 で変更: 'timespec' パラメータを追加しました.

 -- メソッド: time.__str__ ()

     For a time ‘t’, ‘str(t)’ is equivalent to ‘t.isoformat()’.

 -- メソッド: time.strftime (format)

     明示的な書式文字列で制御された、時刻を表現する文字列を返します。
     *note strftime() と strptime() の振る舞い: 1734. および *note
     time.isoformat(): 23cc. も参照してください。

 -- メソッド: time.__format__ (format)

     *note time.strftime(): 16ee. と等価です。 これにより、 *note
     フォーマット済み文字列リテラル: 977. の中や *note str.format():
     5ed. を使っているときに *note time: 1b0. オブジェクトの書式文字列を
     指定できます。 *note strftime() と strptime() の振る舞い: 1734. お
     よび *note time.isoformat(): 23cc. も参照してください。

 -- メソッド: time.utcoffset ()

     *note tzinfo: 238b. が ‘None’ の場合、 ‘None’ を返し、そうでない場
     合には ‘self.tzinfo.utcoffset(None)’ を返します。 後者の式が ‘None’
     あるいは 1 日以下の大きさを持つ *note timedelta: 99d. オブジェクト
     のいずれかを返さない場合には例外を送出します。

     バージョン 3.7 で変更: UTC オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: time.dst ()

     *note tzinfo: 238b. が ‘None’ の場合 ‘None’ を返し、そうでない場合
     には ‘self.tzinfo.dst(None)’ を返します。 後者の式が ‘None’ もしく
     は、1 日未満の大きさを持つ *note timedelta: 99d. オブジェクトのいず
     れかを返さない場合には例外を送出します。

     バージョン 3.7 で変更: DST オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: time.tzname ()

     *note tzinfo: 238b. が ‘None’ の場合 ‘None’ を返し、そうでない場合
     には ‘self.tzinfo.tzname(None)’ を返します。 後者の式が ‘None’ か文
     字列オブジェクトのいずれかを返さない場合には例外を送出します。

* Menu:

* 使用例; time: 使用例 time.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=13936


File: python.info,  Node: 使用例 time,  Up: time オブジェクト

5.8.1.13 使用例: ‘time’
.......................

*note time: 1b0. オブジェクトを使う例:

     >>> from datetime import time, tzinfo, timedelta
     >>> class TZ1(tzinfo):
     ...     def utcoffset(self, dt):
     ...         return timedelta(hours=1)
     ...     def dst(self, dt):
     ...         return timedelta(0)
     ...     def tzname(self,dt):
     ...         return "+01:00"
     ...     def  __repr__(self):
     ...         return f"{self.__class__.__name__}()"
     ...
     >>> t = time(12, 10, 30, tzinfo=TZ1())
     >>> t
     datetime.time(12, 10, 30, tzinfo=TZ1())
     >>> t.isoformat()
     '12:10:30+01:00'
     >>> t.dst()
     datetime.timedelta(0)
     >>> t.tzname()
     '+01:00'
     >>> t.strftime("%H:%M:%S %Z")
     '12:10:30 +01:00'
     >>> 'The {} is {:%H:%M}.'.format("time", t)
     'The time is 12:10.'


File: python.info,  Node: tzinfo オブジェクト,  Next: timezone オブジェクト,  Prev: time オブジェクト,  Up: datetime --- 基本的な日付と時間の型

5.8.1.14 ‘tzinfo’ オブジェクト
..............................

 -- クラス: datetime.tzinfo

     このクラスは抽象基底クラスで、直接インスタンス化すべきでないことを
     意味します。 *note tzinfo: 5a8. のサブクラスを定義し、ある特定のタ
     イムゾーンに関する情報を保持するようにしてください。

     *note tzinfo: 5a8. (の具体的なサブクラス) のインスタンスは *note
     datetime: 1ae. および *note time: 1b0. オブジェクトのコンストラクタ
     に渡すことができます。後者のオブジェクトでは、データ属性をローカル
     時刻におけるものとして見ており、 *note tzinfo: 5a8. オブジェクトは
     ローカル時刻の UTC からのオフセット、タイムゾーンの名前、 DST オフ
     セットを、渡された日付および時刻オブジェクトからの相対で示すための
     メソッドを提供します。

     具象サブクラスを作成し、(少なくとも) 使いたい *note datetime: 1ae.
     のメソッドが必要とする *note tzinfo: 5a8. のメソッドを実装する必要
     があります。 ‘datetime’ モジュールは *note tzinfo: 5a8. のシンプル
     な具象サブクラス *note timezone: 1091. を提供します。 これは UTC そ
     のものか北アメリカの EST と EDT のような UTC からの固定されたオフセ
     ットを持つタイムゾーンを表せます。

     pickle 化についての特殊な要求事項: *note tzinfo: 5a8. のサブクラス
     は引数なしで呼び出すことのできる *note __init__(): 67c. メソッドを
     持たなければなりません。そうでなければ、 pickle 化することはできま
     すがおそらく unpickle 化することはできないでしょう。これは技術的な
     側面からの要求であり、将来緩和されるかもしれません。

     *note tzinfo: 5a8. の具体的なサブクラスでは、以下のメソッドを実装す
     る必要があります。厳密にどのメソッドが必要なのかは、 aware な
     ‘datetime’ オブジェクトがこのサブクラスのインスタンスをどのように使
     うかに依存します。不確かならば、単に全てを実装してください。

 -- メソッド: tzinfo.utcoffset (dt)

     ローカル時間の UTC からのオフセットを、 UTC から東向きを正とした
     *note timedelta: 99d. オブジェクトで返します。ローカル時間が UTC の
     西側にある場合、この値は負になります。

     このメソッドは UTC からのオフセットの '総計' を表しています。例えば
     、 *note tzinfo: 5a8. オブジェクトがタイムゾーンと DST 修正の両方を
     表現する場合、 *note utcoffset(): 23d5. はそれらの合計を返さなけれ
     ばなりません。 UTC オフセットが未知である場合、 ‘None’ を返します。
     そうでない場合には、返される値は ‘-timedelta(hours=24)’ から
     ‘timedelta(hours=24)’ までの *note timedelta: 99d. 境界を含まないオ
     ブジェクトでなければなりません (オフセットの大きさは 1 日より短くな
     ければなりません)。 ほとんどの *note utcoffset(): 23d5. 実装は、お
     そらく以下の二つのうちの一つに似たものになるでしょう:

          return CONSTANT                 # fixed-offset class
          return CONSTANT + self.dst(dt)  # daylight-aware class

     *note utcoffset(): 23d5. が ‘None’ を返さない場合、 *note dst():
     23d6. も ‘None’ を返してはなりません。

     *note utcoffset(): 23d5. のデフォルトの実装は *note
     NotImplementedError: 209. を送出します。

     バージョン 3.7 で変更: UTC オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: tzinfo.dst (dt)

     夏時間 (DST) 修正を、 *note timedelta: 99d. オブジェクトで返します
     。 DST 情報が未知の場合、 ‘None’ が返されます。

     DST が有効でない場合には ‘timedelta(0)’ を返します。 DST が有効の場
     合、オフセットは *note timedelta: 99d. オブジェクトで返します (詳細
     は *note utcoffset(): 23d5. を参照してください)。 DST オフセットが
     利用可能な場合、この値は *note utcoffset(): 23d5. が返す UTC からの
     オフセットには既に加算されているため、 DST を個別に取得する必要がな
     い限り *note dst(): 23d6. を使って問い合わせる必要はないので注意し
     てください。 例えば、 *note datetime.timetuple(): 23bc. は *note
     tzinfo: 2393. 属性の *note dst(): 23d6. メソッドを呼んで *note
     tm_isdst: 23bd. フラグがセットされているかどうか判断し、 *note
     tzinfo.fromutc(): 23ba. は *note dst(): 23d6. タイムゾーンを移動す
     る際に DST による変更があるかどうかを調べます。

     標準および夏時間の両方をモデル化している *note tzinfo: 5a8. サブク
     ラスのインスタンス 'tz' は以下の式:

     ‘tz.utcoffset(dt) - tz.dst(dt)’

     が、 ‘dt.tzinfo == tz’ 全ての *note datetime: 1ae. オブジェクト
     'dt' について常に同じ結果を返さなければならないという点で、一貫性を
     持っていなければなりません。正常に実装された *note tzinfo: 5a8. の
     サブクラスでは、この式はタイムゾーンにおける "標準オフセット
     (standard offset)" を表し、特定の日や時刻の事情ではなく地理的な位置
     にのみ依存していなくてはなりません。 *note datetime.astimezone():
     99e. の実装はこの事実に依存していますが、違反を検出することができま
     せん; 正しく実装するのはプログラマの責任です。 *note tzinfo: 5a8. の
     サブクラスでこれを保証することができない場合、 *note
     tzinfo.fromutc(): 23ba. の実装をオーバライドして、 ‘astimezone()’ に
     関わらず正しく動作するようにしてもかまいません。

     ほとんどの *note dst(): 23d6. 実装は、おそらく以下の二つのうちの一
     つに似たものになるでしょう:

          def dst(self, dt):
              # a fixed-offset class:  doesn't account for DST
              return timedelta(0)

     もしくは:

          def dst(self, dt):
              # Code to set dston and dstoff to the time zone's DST
              # transition times based on the input dt.year, and expressed
              # in standard local time.

              if dston <= dt.replace(tzinfo=None) < dstoff:
                  return timedelta(hours=1)
              else:
                  return timedelta(0)

     デフォルトの *note dst(): 23d6. 実装は *note NotImplementedError:
     209. を送出します。

     バージョン 3.7 で変更: DST オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: tzinfo.tzname (dt)

     *note datetime: 1ae. オブジェクト 'dt' に対応するタイムゾーン名を文
     字列で返します。 ‘datetime’ モジュールでは文字列名について何も定義
     しておらず、特に何かを意味するといった要求仕様もまったくありません
     。例えば、‘"GMT"’, ‘"UTC"’, ‘"-500"’, ‘"-5:00"’, ‘"EDT"’,
     ‘"US/Eastern"’, ‘"America/New York"’ は全て有効な応答となります。文
     字列名が未知の場合には ‘None’ を返してください。 *note tzinfo: 5a8.
     のサブクラスでは、特に, *note tzinfo: 5a8. クラスが夏時間について記
     述している場合のように、渡された 'dt' の特定の値によって異なった名
     前を返したい場合があるため、文字列値ではなくメソッドとなっているこ
     とに注意してください。

     デフォルトの *note tzname(): 23d7. 実装は *note
     NotImplementedError: 209. を送出します。

以下のメソッドは *note datetime: 1ae. や *note time: 1b0. オブジェクトに
おいて、同名のメソッドが呼び出された際に応じて呼び出されます。 *note
datetime: 1ae. オブジェクトは自身を引数としてメソッドに渡し、 *note
time: 1b0. オブジェクトは引数として ‘None’ をメソッドに渡します。従って
、 *note tzinfo: 5a8. のサブクラスにおけるメソッドは引数 'dt' が ‘None’
の場合と、 *note datetime: 1ae. の場合を受理するように用意しなければなり
ません。

‘None’ が渡された場合、最良の応答方法を決めるのはクラス設計者次第です。
例えば、このクラスが *note tzinfo: 5a8. プロトコルと関係をもたないという
ことを表明させたければ、 ‘None’ が適切です。標準時のオフセットを見つける
他の手段がない場合には、標準 UTC オフセットを返すために
‘utcoffset(None)’ を使うともっと便利かもしれません。

*note datetime: 1ae. オブジェクトが ‘datetime()’ メソッドの応答として返
された場合、 ‘dt.tzinfo’ は 'self' と同じオブジェクトになります。ユーザ
が直接 *note tzinfo: 5a8. メソッドを呼び出さないかぎり、 *note tzinfo:
5a8. メソッドは ‘dt.tzinfo’ と 'self' が同じであることに依存します。その
結果 *note tzinfo: 5a8. メソッドは 'dt' がローカル時間であると解釈するの
で、他のタイムゾーンでのオブジェクトの振る舞いについて心配する必要があり
ません。

サブクラスでオーバーライドすると良い、もう 1 つの *note tzinfo: 5a8. の
メソッドがあります:

 -- メソッド: tzinfo.fromutc (dt)

     デフォルトの 実装で呼び出されます。 *note datetime.astimezone():
     99e. から呼ばれた場合、 ‘dt.tzinfo’ は 'self' であり、 'dt' の日付
     および時刻データは UTC 時刻を表しているものとして見えます。 *note
     fromutc(): 23ba. の目的は、 'self' のローカル時刻に等しい *note
     datetime: 28. オブジェクトを返すことにより日付と時刻データメンバを
     修正することにあります。

     ほとんどの *note tzinfo: 5a8. サブクラスではデフォルトの *note
     fromutc(): 23ba. 実装を問題なく継承できます。デフォルトの実装は、固
     定オフセットのタイムゾーンや、標準時と夏時間の両方について記述して
     いるタイムゾーン、そして DST 移行時刻が年によって異なる場合でさえ、
     扱えるくらい強力なものです。デフォルトの *note fromutc(): 23ba. 実
     装が全ての場合に対して正しく扱うことができないような例は、標準時の
     (UTCからの) オフセットが引数として渡された特定の日や時刻に依存する
     もので、これは政治的な理由によって起きることがあります。デフォルト
     の *note astimezone(): 99e. や *note fromutc(): 23ba. の実装は、結
     果が標準時オフセットの変化にまたがる何時間かの中にある場合、期待通
     りの結果を生成しないかもしれません。

     エラーの場合のためのコードを除き、デフォルトの *note fromutc():
     23ba. の実装は以下のように動作します:

          def fromutc(self, dt):
              # raise ValueError error if dt.tzinfo is not self
              dtoff = dt.utcoffset()
              dtdst = dt.dst()
              # raise ValueError if dtoff is None or dtdst is None
              delta = dtoff - dtdst  # this is self's standard offset
              if delta:
                  dt += delta   # convert to standard local time
                  dtdst = dt.dst()
                  # raise ValueError if dtdst is None
              if dtdst:
                  return dt + dtdst
              else:
                  return dt

次の ‘tzinfo_examples.py’ ファイルには、 *note tzinfo: 5a8. クラスの例が
いくつか載っています:

     from datetime import tzinfo, timedelta, datetime

     ZERO = timedelta(0)
     HOUR = timedelta(hours=1)
     SECOND = timedelta(seconds=1)

     # A class capturing the platform's idea of local time.
     # (May result in wrong values on historical times in
     #  timezones where UTC offset and/or the DST rules had
     #  changed in the past.)
     import time as _time

     STDOFFSET = timedelta(seconds = -_time.timezone)
     if _time.daylight:
         DSTOFFSET = timedelta(seconds = -_time.altzone)
     else:
         DSTOFFSET = STDOFFSET

     DSTDIFF = DSTOFFSET - STDOFFSET

     class LocalTimezone(tzinfo):

         def fromutc(self, dt):
             assert dt.tzinfo is self
             stamp = (dt - datetime(1970, 1, 1, tzinfo=self)) // SECOND
             args = _time.localtime(stamp)[:6]
             dst_diff = DSTDIFF // SECOND
             # Detect fold
             fold = (args == _time.localtime(stamp - dst_diff))
             return datetime(*args, microsecond=dt.microsecond,
                             tzinfo=self, fold=fold)

         def utcoffset(self, dt):
             if self._isdst(dt):
                 return DSTOFFSET
             else:
                 return STDOFFSET

         def dst(self, dt):
             if self._isdst(dt):
                 return DSTDIFF
             else:
                 return ZERO

         def tzname(self, dt):
             return _time.tzname[self._isdst(dt)]

         def _isdst(self, dt):
             tt = (dt.year, dt.month, dt.day,
                   dt.hour, dt.minute, dt.second,
                   dt.weekday(), 0, 0)
             stamp = _time.mktime(tt)
             tt = _time.localtime(stamp)
             return tt.tm_isdst > 0

     Local = LocalTimezone()


     # A complete implementation of current DST rules for major US time zones.

     def first_sunday_on_or_after(dt):
         days_to_go = 6 - dt.weekday()
         if days_to_go:
             dt += timedelta(days_to_go)
         return dt


     # US DST Rules
     #
     # This is a simplified (i.e., wrong for a few cases) set of rules for US
     # DST start and end times. For a complete and up-to-date set of DST rules
     # and timezone definitions, visit the Olson Database (or try pytz):
     # http://www.twinsun.com/tz/tz-link.htm
     # https://sourceforge.net/projects/pytz/ (might not be up-to-date)
     #
     # In the US, since 2007, DST starts at 2am (standard time) on the second
     # Sunday in March, which is the first Sunday on or after Mar 8.
     DSTSTART_2007 = datetime(1, 3, 8, 2)
     # and ends at 2am (DST time) on the first Sunday of Nov.
     DSTEND_2007 = datetime(1, 11, 1, 2)
     # From 1987 to 2006, DST used to start at 2am (standard time) on the first
     # Sunday in April and to end at 2am (DST time) on the last
     # Sunday of October, which is the first Sunday on or after Oct 25.
     DSTSTART_1987_2006 = datetime(1, 4, 1, 2)
     DSTEND_1987_2006 = datetime(1, 10, 25, 2)
     # From 1967 to 1986, DST used to start at 2am (standard time) on the last
     # Sunday in April (the one on or after April 24) and to end at 2am (DST time)
     # on the last Sunday of October, which is the first Sunday
     # on or after Oct 25.
     DSTSTART_1967_1986 = datetime(1, 4, 24, 2)
     DSTEND_1967_1986 = DSTEND_1987_2006

     def us_dst_range(year):
         # Find start and end times for US DST. For years before 1967, return
         # start = end for no DST.
         if 2006 < year:
             dststart, dstend = DSTSTART_2007, DSTEND_2007
         elif 1986 < year < 2007:
             dststart, dstend = DSTSTART_1987_2006, DSTEND_1987_2006
         elif 1966 < year < 1987:
             dststart, dstend = DSTSTART_1967_1986, DSTEND_1967_1986
         else:
             return (datetime(year, 1, 1), ) * 2

         start = first_sunday_on_or_after(dststart.replace(year=year))
         end = first_sunday_on_or_after(dstend.replace(year=year))
         return start, end


     class USTimeZone(tzinfo):

         def __init__(self, hours, reprname, stdname, dstname):
             self.stdoffset = timedelta(hours=hours)
             self.reprname = reprname
             self.stdname = stdname
             self.dstname = dstname

         def __repr__(self):
             return self.reprname

         def tzname(self, dt):
             if self.dst(dt):
                 return self.dstname
             else:
                 return self.stdname

         def utcoffset(self, dt):
             return self.stdoffset + self.dst(dt)

         def dst(self, dt):
             if dt is None or dt.tzinfo is None:
                 # An exception may be sensible here, in one or both cases.
                 # It depends on how you want to treat them.  The default
                 # fromutc() implementation (called by the default astimezone()
                 # implementation) passes a datetime with dt.tzinfo is self.
                 return ZERO
             assert dt.tzinfo is self
             start, end = us_dst_range(dt.year)
             # Can't compare naive to aware objects, so strip the timezone from
             # dt first.
             dt = dt.replace(tzinfo=None)
             if start + HOUR <= dt < end - HOUR:
                 # DST is in effect.
                 return HOUR
             if end - HOUR <= dt < end:
                 # Fold (an ambiguous hour): use dt.fold to disambiguate.
                 return ZERO if dt.fold else HOUR
             if start <= dt < start + HOUR:
                 # Gap (a non-existent hour): reverse the fold rule.
                 return HOUR if dt.fold else ZERO
             # DST is off.
             return ZERO

         def fromutc(self, dt):
             assert dt.tzinfo is self
             start, end = us_dst_range(dt.year)
             start = start.replace(tzinfo=self)
             end = end.replace(tzinfo=self)
             std_time = dt + self.stdoffset
             dst_time = std_time + HOUR
             if end <= dst_time < end + HOUR:
                 # Repeated hour
                 return std_time.replace(fold=1)
             if std_time < start or dst_time >= end:
                 # Standard time
                 return std_time
             if start <= std_time < end - HOUR:
                 # Daylight saving time
                 return dst_time


     Eastern  = USTimeZone(-5, "Eastern",  "EST", "EDT")
     Central  = USTimeZone(-6, "Central",  "CST", "CDT")
     Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
     Pacific  = USTimeZone(-8, "Pacific",  "PST", "PDT")

標準時および夏時間の両方を記述している *note tzinfo: 5a8. のサブクラスで
は、夏時間の移行のときに、回避不能の難解な問題が年に 2 度あるので注意し
てください。 具体的な例として、東部アメリカ時刻 (US Eastern, UTC -0500)
を考えます。 EDT は 3 月の第二日曜日の 1:59 (EST) の 1 分後に開始し、11
月の最初の日曜日の (EDTの) 1:59 に終了します:

       UTC   3:MM  4:MM  5:MM  6:MM  7:MM  8:MM
       EST  22:MM 23:MM  0:MM  1:MM  2:MM  3:MM
       EDT  23:MM  0:MM  1:MM  2:MM  3:MM  4:MM

     start  22:MM 23:MM  0:MM  1:MM  3:MM  4:MM

       end  23:MM  0:MM  1:MM  1:MM  2:MM  3:MM

DSTの開始 ("start" ライン) で、ローカルの実時間は 1:59 から 3:00 に飛び
ます。 この日には、 2:MM という形式の実時間は意味をなさないので、 DST が
始まった日に ‘astimezone(Eastern)’ は ‘hour == 2’ となる結果を返すことは
ありません。 例として、 2016 年の春方向の移行では、次のような結果になり
ます:

     >>> from datetime import datetime, timezone
     >>> from tzinfo_examples import HOUR, Eastern
     >>> u0 = datetime(2016, 3, 13, 5, tzinfo=timezone.utc)
     >>> for i in range(4):
     ...     u = u0 + i*HOUR
     ...     t = u.astimezone(Eastern)
     ...     print(u.time(), 'UTC =', t.time(), t.tzname())
     ...
     05:00:00 UTC = 00:00:00 EST
     06:00:00 UTC = 01:00:00 EST
     07:00:00 UTC = 03:00:00 EDT
     08:00:00 UTC = 04:00:00 EDT

DST が終了 ("end" ライン) で、更なる問題が潜んでいます: ローカルの実時間
で、曖昧さ無しに時を綴れない 1 時間が存在します: それは夏時間の最後の 1
時間です。 東部では、夏時間が終了する日の UTC での 5:MM 形式の時間がそれ
です。 ローカルの実時間は (夏時間の) 1:59 から (標準時の) 1:00 に再び巻
き戻されます。 ローカルの時刻における 1:MM は曖昧です。 そして *note
astimezone(): 99e. は 2 つの隣り合う UTC 時間を同じローカルの時間に対応
付けて、ローカルの時計の振る舞いを真似ます。 東部の例では、 5:MM および
6:MM という形式の UTC 時刻は両方とも東部時刻に変換された際に 1:MM に対応
付けられますが、それ以前の時間は *note fold: c25. 属性を 0 にし、以降の
時間では 1 にします。例えば、 2016 年での秋方向の移行では、次のような結
果になります:

     >>> u0 = datetime(2016, 11, 6, 4, tzinfo=timezone.utc)
     >>> for i in range(4):
     ...     u = u0 + i*HOUR
     ...     t = u.astimezone(Eastern)
     ...     print(u.time(), 'UTC =', t.time(), t.tzname(), t.fold)
     ...
     04:00:00 UTC = 00:00:00 EDT 0
     05:00:00 UTC = 01:00:00 EDT 0
     06:00:00 UTC = 01:00:00 EST 1
     07:00:00 UTC = 02:00:00 EST 0

*note fold: c25. 属性が異なるだけの *note datetime: 1ae. インスタンスは
比較において等しいとみなされることに注意してください。

壁時間に関する曖昧さは、明示的に *note fold: c25. 属性を検証するか、
*note timezone: 1091. が使用されたハイブリッドな *note tzinfo: 5a8. サブ
クラスか、そのほかの絶対時間差を示す *note tzinfo: 5a8. サブクラス(EST
(-5 時間の絶対時間差) のみを表すクラスや、 EDT (-4 時間の絶対時間差) の
みを表すクラス)を使用すると回避できます。 このような曖昧さを許容できない
アプリケーションは、このような手法によって回避すべきです。

参考
....

     *note zoneinfo: 11a.

          ‘datetime’ モジュールには (UTC からの任意の固定オフセットを扱
          う) 基本的な *note timezone: 1091. クラスと、(UTC ‘timezone’ の
          インスタンスである) *note timezone.utc: 5df. 属性があります。

          ‘zoneinfo’ は Python に 'IANA タイムゾーンデータベース' (オル
          ソンデータベースとしても知られています) を導入するもので、これ
          を使うことが推奨されています。

IANA タイムゾーンデータベース(1)

     (しばしば tz、tzdata や zoneinfo と呼ばれる) タイムゾーンデータベー
     スはコードとデータを保持しており、それらは地球全体にわたる多くの代
     表的な場所のローカル時刻の履歴を表しています。政治団体によるタイム
     ゾーンの境界、UTC オフセット、夏時間のルールの変更を反映するため、
     定期的にデータベースが更新されます。

   ---------- Footnotes ----------

   (1) https://www.iana.org/time-zones


File: python.info,  Node: timezone オブジェクト,  Next: strftime と strptime の振る舞い,  Prev: tzinfo オブジェクト,  Up: datetime --- 基本的な日付と時間の型

5.8.1.15 ‘timezone’ オブジェクト
................................

*note timezone: 1091. クラスは *note tzinfo: 5a8. のサブクラスで、各イン
スタンスは UTC からの固定されたオフセットで定義されたタイムゾーンを表し
ています。

このクラスのオブジェクトは、一年のうち異なる日に異なるオフセットが使われ
ていたり、常用時 (civil time) に歴史的な変化が起きた場所のタイムゾーン情
報を表すのには使えないので注意してください。

 -- クラス: datetime.timezone (offset, name=None)

     ローカル時刻と UTC の差分を表す *note timedelta: 99d. オブジェクト
     を 'offset' 引数に指定しなくてはいけません。これは
     ‘-timedelta(hours=24)’ から ‘timedelta(hours=24)’ までの両端を含ま
     ない範囲に収まっていなくてはなりません。そうでない場合 *note
     ValueError: 1e3. が送出されます。

     'name' 引数は必須ではありません。もし指定された場合、その値は *note
     datetime.tzname(): 23bb. メソッドの返り値として使われる文字列でなけ
     ればなりません。

     Added in version 3.2.

     バージョン 3.7 で変更: UTC オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: timezone.utcoffset (dt)

     *note timezone: 1091. インスタンスが構築されたときに指定された固定
     値を返します。

     'dt' 引数は無視されます。 返り値は、ローカル時刻と UTC の差分に等し
     い *note timedelta: 99d. インスタンスです。

     バージョン 3.7 で変更: UTC オフセットが分単位でなければならない制限
     が無くなりました。

 -- メソッド: timezone.tzname (dt)

     *note timezone: 1091. インスタンスが構築されたときに指定された固定
     値を返します。

     'name' が構築時に与えられなかった場合、 ‘tzname(dt)’ によって返され
     る name は以下の様に ‘offset’ の値から生成されます。 'offset' が
     ‘timedelta(0)’ であった場合、 name は "UTC"になります。 それ以外の
     場合、 'UTC±HH:MM' という書式の文字列になり、± は ‘offset’ を、HH と
     MM はそれぞれ二桁の ‘offset.hours’ と ‘offset.minutes’ を表現します
     。

     バージョン 3.6 で変更: ‘offset=timedelta(0)’ によって生成される名前
     はプレーンな ‘'UTC'’ であり ‘'UTC+00:00'’ ではありません。

 -- メソッド: timezone.dst (dt)

     常に ‘None’ を返します。

 -- メソッド: timezone.fromutc (dt)

     ‘dt + offset’ を返します。 'dt' 引数は ‘tzinfo’ が ‘self’ になって
     いる aware な *note datetime: 1ae. インスタンスでなければなりません
     。

以下にクラス属性を示します:

 -- の属性: timezone.utc

     UTC タイムゾーン ‘timezone(timedelta(0))’ です。


File: python.info,  Node: strftime と strptime の振る舞い,  Prev: timezone オブジェクト,  Up: datetime --- 基本的な日付と時間の型

5.8.1.16 ‘strftime()’ と ‘strptime()’ の振る舞い
................................................

*note date: 1af, *note datetime: 1ae, *note time: 1b0. オブジェクトは全
て ‘strftime(format)’ メソッドをサポートし、時刻を表現する文字列を明示的
な書式文字列で統制して作成しています。

逆に *note datetime.strptime(): 156e. クラスメソッドは日付や時刻に対応す
る書式文字列から *note datetime: 1ae. オブジェクトを生成します。

下の表は *note strftime(): c5e. と *note strptime(): 156e. との高レベル
の対比を表しています。

                     ‘strftime’                                                   ‘strptime’
                                                                                  
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
                                                                                  
使用法               オブジェクトを与えられた書式に従って文字列に変換する         指定された対応する書式で文字列を構文解析して *note datetime: 1ae. オブジェクトに
                                                                                  する
                                                                                  
                                                                                  
メソッドの種類       インスタンスメソッド                                         クラスメソッド
                                                                                  
                                                                                  
メソッドを持つクラ   *note date: 1af.; *note datetime: 1ae.; *note time: 1b0.     *note datetime: 1ae.
ス                                                                                

シグネチャ           ‘strftime(format)’                                           ‘strptime(date_string, format)’
                                                                                  

* Menu:

* strftime() と strptime() の書式コード: strftime と strptime の書式コード.
* 技術詳細::


File: python.info,  Node: strftime と strptime の書式コード,  Next: 技術詳細,  Up: strftime と strptime の振る舞い

5.8.1.17 ‘strftime()’ と ‘strptime()’ の書式コード
..................................................

These methods accept format codes that can be used to parse and format
dates:

     >>> datetime.strptime('31/01/22 23:59:59.999999',
     ...                   '%d/%m/%y %H:%M:%S.%f')
     datetime.datetime(2022, 1, 31, 23, 59, 59, 999999)
     >>> _.strftime('%a %d %b %Y, %I:%M%p')
     'Mon 31 Jan 2022, 11:59PM'

以下のリストは 1989 C 標準が要求する全ての書式コードで、標準 C 実装があ
れば全ての環境で動作します。

ディレクティ    意味                                 使用例                       注釈
ブ                                                                                

----------------------------------------------------------------------------------------------
                                                                                  
‘%a’            ロケールの曜日名を短縮形で表示しま        Sun, Mon, ..., Sat (en_US);(1)
                す。                                      So, Mo, ..., Sa (de_DE) 
                                                     
                                                                                  
‘%A’            ロケールの曜日名を表示します。            Sunday, Monday, ..., Saturday (en_US);(1)
                                                          Sonntag, Montag, ..., Samstag (de_DE)
                                                     
                                                                                  
‘%w’            曜日を10進表記した文字列を表示しま   0, 1, ..., 6
                す。0 が日曜日で、6 が土曜日を表し   
                ます。
                
                                                                                  
‘%d’            0埋めした10進数で表記した月中の日    01, 02, ..., 31              (9)
                にち。                                                            
                
                                                                                  
‘%b’            ロケールの月名を短縮形で表示します        Jan, Feb, ..., Dec (en_US);(1)
                。                                        Jan, Feb, ..., Dez (de_DE)
                                                     
                                                                                  
‘%B’            ロケールの月名を表示します。              January, February, ..., December (en_US);(1)
                                                          Januar, Februar, ..., Dezember (de_DE)
                                                     
                                                                                  
‘%m’            0埋めした10進数で表記した月。        01, 02, ..., 12              (9)
                                                                                  
                                                                                  
‘%y’            0埋めした10進数で表記した世紀無し    00, 01, ..., 99              (9)
                の年。                                                            
                
                                                                                  
‘%Y’            西暦 ( 4桁) の 10 進表記を表します   0001, 0002, ..., 2013,       (2)
                。                                   2014, ..., 9998, 9999        
                                                     
                                                                                  
‘%H’            0埋めした10進数で表記した時 (24時    00, 01, ..., 23              (9)
                間表記)。                                                         
                
                                                                                  
‘%I’            0埋めした10進数で表記した時 (12時    01, 02, ..., 12              (9)
                間表記)。                                                         
                
                                                                                  
‘%p’            ロケールの AM もしくは PM と等価な        AM, PM (en_US);         (1), (3)
                文字列になります。                        am, pm (de_DE)          
                                                     
                                                                                  
‘%M’            0埋めした10進数で表記した分。        00, 01, ..., 59              (9)
                                                                                  
                                                                                  
‘%S’            0埋めした10進数で表記した秒。        00, 01, ..., 59              (4), (9)
                                                                                  
                                                                                  
‘%f’            10進数で表記したマイクロ秒 (6桁に    000000, 000001, ...,         (5)
                0埋めされます)。                     999999                       
                                                     
                                                                                  
‘%z’            UTCオフセットを                      (空文字列), +0000, -0400,    (6)
                ‘±HHMM[SS[.ffffff]]’ の形式で表示    +1030, +063415,              
                します (オブジェクトがnaiveであれ    -030712.345216
                ば空文字列)。                        
                
                                                                                  
‘%Z’            タイムゾーンの名前を表示します (オ   (空文字列), UTC, GMT         (6)
                ブジェクトがnaiveであれば空文字列                                 
                )。
                
                                                                                  
‘%j’            0埋めした10進数で表記した年中の日    001, 002, ..., 366           (9)
                にち。                                                            
                
                                                                                  
‘%U’            0埋めした10進数で表記した年中の週    00, 01, ..., 53              (7), (9)
                番号 (週の始まりは日曜日とする)。                                 
                新年の最初の日曜日に先立つ日は 0週
                に属するとします。
                
                                                                                  
‘%W’            0埋めした10進数で表記した年中の週    00, 01, ..., 53              (7), (9)
                番号 (週の始まりは月曜日とする)。                                 
                新年の最初の月曜日に先立つ日は 0週
                に属するとします。
                
                                                                                  
‘%c’            ロケールの日時を適切な形式で表しま        Tue Aug 16 21:30:00 1988 (en_US);(1)
                す。                                      Di 16 Aug 21:30:00 1988 (de_DE)
                                                     
                                                                                  
‘%x’            ロケールの日付を適切な形式で表しま        08/16/88 (None);        (1)
                す。                                      08/16/1988 (en_US);     
                                                          16.08.1988 (de_DE)
                                                     
                                                                                  
‘%X’            ロケールの時間を適切な形式で表しま        21:30:00 (en_US);       (1)
                す。                                      21:30:00 (de_DE)        
                                                     
                                                                                  
‘%%’            文字 ‘'%'’ を表します。              %
                                                     

C89規格により要求されない幾つかの追加のコードが便宜上含まれています。こ
れらのパラメータはすべてISO 8601の日付値に対応しています。

ディレクティ    意味                                 使用例                       注釈
ブ                                                                                

----------------------------------------------------------------------------------------------
                                                                                  
‘%G’            ISO week(‘%V’)の内過半数を含む西暦   0001, 0002, ..., 2013,       (8)
                表記の ISO 8601 year です。          2014, ..., 9998, 9999        
                                                     
                                                                                  
‘%u’            1 を月曜日を表す 10進数表記の ISO    1, 2, ..., 7
                8601 weekday です。                  
                
                                                                                  
‘%V’            週で最初の月曜日を始めとする ISO     01, 02, ..., 53              (8), (9)
                8601 week です。Week 01 は 1月4日                                 
                を含みます。
                
                                                                                  
‘%:z’           UTCオフセットを                      (空文字列), +00:00,          (6)
                ‘±HH:MM[:SS[.ffffff]]’ の形式で表    -04:00, +10:30, +06:34:15,   
                示します (オブジェクトがnaiveであ    -03:07:12.345216
                れば空文字列)。                      
                

これらが *note strftime(): c5e. メソッドと一緒に使用された場合、すべての
プラットフォームで利用できるわけではありません。 ISO 8601 year 指定子お
よびISO 8601 week 指定子は、上記のyear および week number 指定子と互換性
がありません。不完全またはあいまいなISO 8601 指定子で *note strptime():
156e. を呼び出すと、 *note ValueError: 1e3. が送出されます。

Python はプラットフォームの C ライブラリの ‘strftime()’ 関数を呼び出して
いて、プラットフォームごとにその実装が異なるのはよくあることなので、サポ
ートされる書式コード全体はプラットフォームごとに様々です。 手元のプラッ
トフォームでサポートされているフォーマット記号全体を見るには、
‘strftime(3)(1)’ のドキュメントを参照してください。 サポートされていない
フォーマット指定子の扱いもプラットフォーム間で差異があります。

Added in version 3.6: ‘%G’, ‘%u’ および ‘%V’ が追加されました。

Added in version 3.12: ‘%:z’ が追加されました。

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/strftime(3)


File: python.info,  Node: 技術詳細,  Prev: strftime と strptime の書式コード,  Up: strftime と strptime の振る舞い

5.8.1.18 技術詳細
.................

大雑把にいうと、 ‘d.strftime(fmt)’ は *note time: d7. モジュールの
‘time.strftime(fmt, d.timetuple())’ のように動作します。ただし全てのオブ
ジェクトが *note timetuple(): 23a5. メソッドをサポートしているわけではあ
りません。

*note datetime.strptime(): 156e. クラスメソッドでは、デフォルト値は
‘1900-01-01T00:00:00.000’ です。書式文字列で指定されなかった部分はデフォ
ルト値から引っ張ってきます。 (1)

‘datetime.strptime(date_string, format)’ は次の式と等価です:

     datetime(*(time.strptime(date_string, format)[0:6]))

ただし、 ‘datetime.strptime’ はサポートしているが ‘time.strptime’ には無
い、秒未満の単位やタイムゾーンオフセットの情報が format に 含まれている
ときは除きます。

*note time: 1b0. オブジェクトには、年、月、日の値がないため、それらを書
式コードを使うことができません。 無理矢理使った場合、年は1900に置き換え
られ、月と日は1に置き換えられます。

*note date: 1af. オブジェクトには、時、分、秒、マイクロ秒の値がないため
、それらの書式コードを使うことができません。 無理矢理使った場合、これら
の値は0に置き換えられます。

同じ理由で、現在のロケールの文字集合で表現できない Unicode コードポイン
トを含む書式文字列の対処もプラットフォーム依存です。 あるプラットフォー
ムではそういったコードポイントはそのまま出力に出される一方、他のプラット
フォームでは ‘strftime’ が *note UnicodeError: 1275. を送出したり、その
代わりに空文字列を返したりするかもしれません。

注釈:

  1. 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.

  2. *note strptime(): 156e. メソッドは [1, 9999] の範囲の年数全てを構文
     解析できますが、 year < 1000 の範囲の年数は 0 埋めされた 4 桁の数字
     でなければなりません。

     バージョン 3.2 で変更: 以前のバージョンでは、 *note strftime():
     c5e. メソッドは years >= 1900 の範囲の年数しか扱えませんでした。

     バージョン 3.3 で変更: バージョン 3.2 では、 *note strftime(): c5e.
     メソッドは years >= 1000 の範囲の年数しか扱えませんでした。

  3. *note strptime(): 156e. メソッドと共に使われた場合、 ‘%p’ 指定子は
     出力の時間フィールドのみに影響し、 ‘%I’ 指定子が使われたかのように
     振る舞います。

  4. *note time: d7. モジュールと違い、 ‘datetime’ モジュールはうるう秒
     をサポートしていません。

  5. *note strptime(): 156e. メソッドと共に使われた場合、 ‘%f’ 指定子は
     1 桁から 6 桁の数字を受け付け、右側から0埋めされます。 ‘%f’ は C 標
     準規格の書式文字セットの拡張です (とは言え、 datetime モジュールの
     オブジェクトそれぞれに実装されているので、どれででも使えます)。

  6. naive オブジェクトでは、書式コード ‘%z’、‘%:z’ および ‘%Z’ は空文字
     列に置き換えられます。

     aware オブジェクトでは次のようになります:

     ‘%z’

          *note utcoffset(): 23b8. は ‘±HHMM[SS[.ffffff]]’ 形式の文字列
          に変換されます。ここで、 ‘HH’ は UTC オフセットの時間を表す 2
          桁の文字列、 ‘MM’ は UTC オフセットの分数を表す 2 桁の文字列、
          ‘SS’ は UTC オフセットの秒数を表す 2 桁の文字列、 ‘ffffff’ は
          UTC オフセットのマイクロ秒数を表す 6 桁の文字列です。 オフセッ
          トに秒未満の端数が無いときは ‘ffffff’ 部分は省略され、オフセッ
          トに分未満の端数が無いときは ‘ffffff’ 部分も ‘SS’ 部分も省略さ
          れます。 例えば、 *note utcoffset(): 23b8. が
          ‘timedelta(hours=-3, minutes=-30)’ を返す場合、 ‘%z’ は文字列
          ‘'-0330'’ に置き換えられます。

     バージョン 3.7 で変更: UTC オフセットが分単位でなければならない制限
     が無くなりました。

     バージョン 3.7 で変更: ‘%z’ 指定子が *note strptime(): 156e. メソッ
     ドに渡されたときは、時分秒のセパレータとしてコロンが UTC オフセット
     で使えます。 例えば、 ‘'+01:00:00'’ は 1 時間のオフセットだと構文解
     析されます。 加えて、 ‘'Z'’ を渡すことは ‘'+00:00'’ を渡すことと同
     等です。

     ‘%:z’

          Behaves exactly as ‘%z’, but has a colon separator added
          between hours, minutes and seconds.

     ‘%Z’

          In *note strftime(): c5e, ‘%Z’ is replaced by an empty string
          if *note tzname(): 23bb. returns ‘None’; otherwise ‘%Z’ is
          replaced by the returned value, which must be a string.

          *note strptime(): 156e. は ‘%Z’ に特定の値のみを受け入れます:

            1. 使用しているマシンのロケールによる ‘time.tzname’ の任意の
               値

            2. ハードコードされた値 ‘UTC’ または ‘GMT’

          つまり、日本に住んでいる場合は ‘JST’, ‘UTC’ と ‘GMT’ が有効な
          値であり、 ‘EST’ はおそらく無効な値となります。無効な値の場合
          は ‘ValueError’ を送出します。

     バージョン 3.2 で変更: ‘%z’ 指定子が *note strptime(): 156e. メソッ
     ドに与えられた場合、 aware な *note datetime: 1ae. オブジェクトが作
     成されます。返り値の ‘tzinfo’ は *note timezone: 1091. インスタンス
     になっています。

  7. *note strptime(): 156e. メソッドと共に使われた場合、 ‘%U’ と ‘%W’ 指
     定子は、曜日と年(‘%Y’)が指定された場合の計算でのみ使われます。

  8. ‘%U’ および ‘%W’ と同様に、 ‘%V’ は曜日と ISO 年 (‘%G’) が *note
     strptime(): 156e. の書式文字列の中で指定された場合に計算でのみ使わ
     れます。 ‘%G’ と ‘%Y’ は互いに完全な互換性を持たないことにも注意し
     てください。

  9. *note strptime(): 156e. メソッドと共に使われるとき、書式 ‘%d’,
     ‘%m’, ‘%H’, ‘%I’, ‘%M’, ‘%S’, ‘%j’, ‘%U’, ‘%W’, ‘%V’ では先行ゼロは
     任意です。 書式 ‘%y’ では先行ゼロは必須です。

  10. When parsing a month and day using *note strptime(): 156e, always
     include a year in the format.  If the value you need to parse lacks
     a year, append an explicit dummy leap year.  Otherwise your code
     will raise an exception when it encounters leap day because the
     default year used by the parser is not a leap year.  Users run into
     this bug every four years...

          >>> month_day = "02/29"
          >>> datetime.strptime(f"{month_day};1984", "%m/%d;%Y")  # No leap year bug.
          datetime.datetime(1984, 2, 29, 0, 0)

     Deprecated since version 3.13, will be removed in version 3.15:
     *note strptime(): 156e. calls using a format string containing a
     day of month without a year now emit a *note DeprecationWarning:
     18a.  In 3.15 or later we may change this into an error or change
     the default year to a leap year.  See gh-70647(2).

脚注
....

   ---------- Footnotes ----------

   (1) 1900は閏年ではないので ‘datetime.strptime('Feb 29', '%b %d')’ を
渡すと失敗します。

   (2) https://github.com/python/cpython/issues/70647


File: python.info,  Node: zoneinfo --- IANA タイムゾーンのサポート,  Next: calendar --- 一般的なカレンダーに関係する機能群,  Prev: datetime --- 基本的な日付と時間の型,  Up: データ型

5.8.2 ‘zoneinfo’ -- IANA タイムゾーンのサポート
-----------------------------------------------

Added in version 3.9.

'ソースコード:' Lib/zoneinfo(1)

__________________________________________________________________

*note zoneinfo: 11a. モジュールは PEP 615(2) で規定された、IANAのタイム
ゾーンデータベースをサポートした具体的なタイムゾーン実装を提供します。 デ
フォルトでは、*note zoneinfo: 11a. はシステムのタイムゾーンデータが利用
可能であれば使用します。システムのタイムゾーンデータが利用できない場合、
ライブラリはPyPIにあるファーストパーティーのパッケージ tzdata(3) を代わ
りに使用します。

参考
....

モジュール: *note datetime: 28.

     *note ZoneInfo: 8ad. クラスを使用するように設計されたデータ型 *note
     time: 1b0. と *note datetime: 1ae. を提供します。

tzdata(4) パッケージ

     CPythonコアデベロッパーによってメンテナンスされているファーストパー
     ティーのパッケージ。タイムゾーンデータを供給し、PyPIで配布されてい
     る。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

* Menu:

* ZoneInfo を使用する::
* データソース::
* ZoneInfo クラス::
* 関数: 関数<3>.
* Globals::
* 例外と警告::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/zoneinfo

   (2) https://peps.python.org/pep-0615/

   (3) https://pypi.org/project/tzdata/

   (4) https://pypi.org/project/tzdata/


File: python.info,  Node: ZoneInfo を使用する,  Next: データソース,  Up: zoneinfo --- IANA タイムゾーンのサポート

5.8.2.1 ‘ZoneInfo’ を使用する
.............................

*note ZoneInfo: 8ad. は *note datetime.tzinfo: 5a8. 抽象基底クラスの具体
的な実装であり、‘tzinfo’ に指定することを想定しています。コンストラクタ
、*note datetime.replace: 1474. メソッド、*note datetime.astimezone:
99e. メソッドのいずれかで指定します。

     >>> from zoneinfo import ZoneInfo
     >>> from datetime import datetime, timedelta

     >>> dt = datetime(2020, 10, 31, 12, tzinfo=ZoneInfo("America/Los_Angeles"))
     >>> print(dt)
     2020-10-31 12:00:00-07:00

     >>> dt.tzname()
     'PDT'

Datetimes constructed in this way are compatible with datetime
arithmetic and handle daylight saving time transitions with no further
intervention:

     >>> dt_add = dt + timedelta(days=1)

     >>> print(dt_add)
     2020-11-01 12:00:00-08:00

     >>> dt_add.tzname()
     'PST'

These time zones also support the *note fold: c25. attribute introduced
in PEP 495(1).  During offset transitions which induce ambiguous times
(such as a daylight saving time to standard time transition), the offset
from 'before' the transition is used when ‘fold=0’, and the offset
'after' the transition is used when ‘fold=1’, for example:

     >>> dt = datetime(2020, 11, 1, 1, tzinfo=ZoneInfo("America/Los_Angeles"))
     >>> print(dt)
     2020-11-01 01:00:00-07:00

     >>> print(dt.replace(fold=1))
     2020-11-01 01:00:00-08:00

When converting from another time zone, the fold will be set to the
correct value:

     >>> from datetime import timezone
     >>> LOS_ANGELES = ZoneInfo("America/Los_Angeles")
     >>> dt_utc = datetime(2020, 11, 1, 8, tzinfo=timezone.utc)

     >>> # Before the PDT -> PST transition
     >>> print(dt_utc.astimezone(LOS_ANGELES))
     2020-11-01 01:00:00-07:00

     >>> # After the PDT -> PST transition
     >>> print((dt_utc + timedelta(hours=1)).astimezone(LOS_ANGELES))
     2020-11-01 01:00:00-08:00

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0495/


File: python.info,  Node: データソース,  Next: ZoneInfo クラス,  Prev: ZoneInfo を使用する,  Up: zoneinfo --- IANA タイムゾーンのサポート

5.8.2.2 データソース
....................

The ‘zoneinfo’ module does not directly provide time zone data, and
instead pulls time zone information from the system time zone database
or the first-party PyPI package tzdata(1), if available.  Some systems,
including notably Windows systems, do not have an IANA database
available, and so for projects targeting cross-platform compatibility
that require time zone data, it is recommended to declare a dependency
on tzdata.  If neither system data nor tzdata are available, all calls
to *note ZoneInfo: 8ad. will raise *note ZoneInfoNotFoundError: 23e5.

* Menu:

* Configuring the data sources::

   ---------- Footnotes ----------

   (1) https://pypi.org/project/tzdata/


File: python.info,  Node: Configuring the data sources,  Up: データソース

5.8.2.3 Configuring the data sources
....................................

When ‘ZoneInfo(key)’ is called, the constructor first searches the
directories specified in *note TZPATH: 1cda. for a file matching ‘key’,
and on failure looks for a match in the tzdata package.  This behavior
can be configured in three ways:

  1. The default *note TZPATH: 1cda. when not otherwise specified can be
     configured at *note compile time: 1cdb.

  2. *note TZPATH: 1cda. can be configured using *note an environment
     variable: 23e8.

  3. At *note runtime: 23e9, the search path can be manipulated using
     the *note reset_tzpath(): 23ea. function.

* Menu:

* Compile-time configuration::
* Environment configuration::
* Runtime configuration::


File: python.info,  Node: Compile-time configuration,  Next: Environment configuration,  Up: Configuring the data sources

5.8.2.4 Compile-time configuration
..................................

The default *note TZPATH: 1cda. includes several common deployment
locations for the time zone database (except on Windows, where there are
no "well-known" locations for time zone data).  On POSIX systems,
downstream distributors and those building Python from source who know
where their system time zone data is deployed may change the default
time zone path by specifying the compile-time option ‘TZPATH’ (or, more
likely, the *note configure flag -with-tzpath: 1cd9.), which should be a
string delimited by *note os.pathsep: 1cae.

On all platforms, the configured value is available as the ‘TZPATH’ key
in *note sysconfig.get_config_var(): ff5.


File: python.info,  Node: Environment configuration,  Next: Runtime configuration,  Prev: Compile-time configuration,  Up: Configuring the data sources

5.8.2.5 Environment configuration
.................................

When initializing *note TZPATH: 1cda. (either at import time or whenever
*note reset_tzpath(): 23ea. is called with no arguments), the ‘zoneinfo’
module will use the environment variable ‘PYTHONTZPATH’, if it exists,
to set the search path.

 -- 環境変数: PYTHONTZPATH

     This is an *note os.pathsep: 1cae.-separated string containing the
     time zone search path to use.  It must consist of only absolute
     rather than relative paths.  Relative components specified in
     ‘PYTHONTZPATH’ will not be used, but otherwise the behavior when a
     relative path is specified is implementation-defined; CPython will
     raise *note InvalidTZPathWarning: 23ee, but other implementations
     are free to silently ignore the erroneous component or raise an
     exception.

To set the system to ignore the system data and use the tzdata package
instead, set ‘PYTHONTZPATH=""’.


File: python.info,  Node: Runtime configuration,  Prev: Environment configuration,  Up: Configuring the data sources

5.8.2.6 Runtime configuration
.............................

The TZ search path can also be configured at runtime using the *note
reset_tzpath(): 23ea. function.  This is generally not an advisable
operation, though it is reasonable to use it in test functions that
require the use of a specific time zone path (or require disabling
access to the system time zones).


File: python.info,  Node: ZoneInfo クラス,  Next: 関数<3>,  Prev: データソース,  Up: zoneinfo --- IANA タイムゾーンのサポート

5.8.2.7 ‘ZoneInfo’ クラス
.........................

 -- クラス: zoneinfo.ZoneInfo (key)

     文字列 ‘key’ でIANAタイムゾーンを指定した、具体的な *note
     datetime.tzinfo: 5a8. のサブクラス。Calls to the primary
     constructor will always return objects that compare identically;
     put another way, barring cache invalidation via *note
     ZoneInfo.clear_cache(): 23f1, for all values of ‘key’, the
     following assertion will always be true:

          a = ZoneInfo(key)
          b = ZoneInfo(key)
          assert a is b

     ‘key’ must be in the form of a relative, normalized POSIX path,
     with no up-level references.  The constructor will raise *note
     ValueError: 1e3. if a non-conforming key is passed.

     ‘key’ に一致するファイルが見つからない場合、コンストラクタは *note
     ZoneInfoNotFoundError: 23e5. を送出します。

‘ZoneInfo’ クラスには2つの別のコンストラクターがあります:

 -- メソッド: classmethod ZoneInfo.from_file (fobj, /, key=None)

     file-like オブジェクトが返すbytes（バイナリーモードで開いたファイル
     や *note io.BytesIO: e6d. オブジェクト）から ‘ZoneInfo’ オブジェク
     トを構築します。一次コンストラクタと異なり、常に新規オブジェクトを
     構築します。

     The ‘key’ parameter sets the name of the zone for the purposes of
     *note __str__(): 5e9. and *note __repr__(): 5e8.

     このコンストラクタで生成したオブジェクトはpickle化できません（*note
     pickling: 23f3. を参照）。

 -- メソッド: classmethod ZoneInfo.no_cache (key)

     An alternate constructor that bypasses the constructor's cache.  It
     is identical to the primary constructor, but returns a new object
     on each call.  This is most likely to be useful for testing or
     demonstration purposes, but it can also be used to create a system
     with a different cache invalidation strategy.

     Objects created via this constructor will also bypass the cache of
     a deserializing process when unpickled.

          注意: Using this constructor may change the semantics of your
          datetimes in surprising ways, only use it if you know that you
          need to.

次のクラスメソッドもサポートされています:

 -- メソッド: classmethod ZoneInfo.clear_cache (*, only_keys=None)

     A method for invalidating the cache on the ‘ZoneInfo’ class.  If no
     arguments are passed, all caches are invalidated and the next call
     to the primary constructor for each key will return a new instance.

     If an iterable of key names is passed to the ‘only_keys’ parameter,
     only the specified keys will be removed from the cache.  Keys
     passed to ‘only_keys’ but not found in the cache are ignored.

          警告: Invoking this function may change the semantics of
          datetimes using ‘ZoneInfo’ in surprising ways; this modifies
          module state and thus may have wide-ranging effects.  Only use
          it if you know that you need to.

The class has one attribute:

 -- の属性: ZoneInfo.key

     This is a read-only *note attribute: 23f6. that returns the value
     of ‘key’ passed to the constructor, which should be a lookup key in
     the IANA time zone database (e.g.  ‘America/New_York’,
     ‘Europe/Paris’ or ‘Asia/Tokyo’).

     For zones constructed from file without specifying a ‘key’
     parameter, this will be set to ‘None’.

          注釈: Although it is a somewhat common practice to expose
          these to end users, these values are designed to be primary
          keys for representing the relevant zones and not necessarily
          user-facing elements.  Projects like CLDR (the Unicode Common
          Locale Data Repository) can be used to get more user-friendly
          strings from these keys.

* Menu:

* 文字列表現::
* Pickle serialization::


File: python.info,  Node: 文字列表現,  Next: Pickle serialization,  Up: ZoneInfo クラス

5.8.2.8 文字列表現
..................

The string representation returned when calling *note str: 418. on a
*note ZoneInfo: 8ad. object defaults to using the *note ZoneInfo.key:
23f5. attribute (see the note on usage in the attribute documentation):

     >>> zone = ZoneInfo("Pacific/Kwajalein")
     >>> str(zone)
     'Pacific/Kwajalein'

     >>> dt = datetime(2020, 4, 1, 3, 15, tzinfo=zone)
     >>> f"{dt.isoformat()} [{dt.tzinfo}]"
     '2020-04-01T03:15:00+12:00 [Pacific/Kwajalein]'

For objects constructed from a file without specifying a ‘key’
parameter, ‘str’ falls back to calling *note repr(): 7c8.  ‘ZoneInfo’'s
‘repr’ is implementation-defined and not necessarily stable between
versions, but it is guaranteed not to be a valid ‘ZoneInfo’ key.


File: python.info,  Node: Pickle serialization,  Prev: 文字列表現,  Up: ZoneInfo クラス

5.8.2.9 Pickle serialization
............................

Rather than serializing all transition data, ‘ZoneInfo’ objects are
serialized by key, and ‘ZoneInfo’ objects constructed from files (even
those with a value for ‘key’ specified) cannot be pickled.

The behavior of a ‘ZoneInfo’ file depends on how it was constructed:

  1. ‘ZoneInfo(key)’: When constructed with the primary constructor, a
     ‘ZoneInfo’ object is serialized by key, and when deserialized, the
     deserializing process uses the primary and thus it is expected that
     these are expected to be the same object as other references to the
     same time zone.  For example, if ‘europe_berlin_pkl’ is a string
     containing a pickle constructed from ‘ZoneInfo("Europe/Berlin")’,
     one would expect the following behavior:

          >>> a = ZoneInfo("Europe/Berlin")
          >>> b = pickle.loads(europe_berlin_pkl)
          >>> a is b
          True

  2. ‘ZoneInfo.no_cache(key)’: When constructed from the cache-bypassing
     constructor, the ‘ZoneInfo’ object is also serialized by key, but
     when deserialized, the deserializing process uses the cache
     bypassing constructor.  If ‘europe_berlin_pkl_nc’ is a string
     containing a pickle constructed from
     ‘ZoneInfo.no_cache("Europe/Berlin")’, one would expect the
     following behavior:

          >>> a = ZoneInfo("Europe/Berlin")
          >>> b = pickle.loads(europe_berlin_pkl_nc)
          >>> a is b
          False

  3. ‘ZoneInfo.from_file(fobj, /, key=None)’: When constructed from a
     file, the ‘ZoneInfo’ object raises an exception on pickling.  If an
     end user wants to pickle a ‘ZoneInfo’ constructed from a file, it
     is recommended that they use a wrapper type or a custom
     serialization function: either serializing by key or storing the
     contents of the file object and serializing that.

This method of serialization requires that the time zone data for the
required key be available on both the serializing and deserializing
side, similar to the way that references to classes and functions are
expected to exist in both the serializing and deserializing
environments.  It also means that no guarantees are made about the
consistency of results when unpickling a ‘ZoneInfo’ pickled in an
environment with a different version of the time zone data.


File: python.info,  Node: 関数<3>,  Next: Globals,  Prev: ZoneInfo クラス,  Up: zoneinfo --- IANA タイムゾーンのサポート

5.8.2.10 関数
.............

 -- の関数: zoneinfo.available_timezones ()

     Get a set containing all the valid keys for IANA time zones
     available anywhere on the time zone path.  This is recalculated on
     every call to the function.

     This function only includes canonical zone names and does not
     include "special" zones such as those under the ‘posix/’ and
     ‘right/’ directories, or the ‘posixrules’ zone.

          注意: This function may open a large number of files, as the
          best way to determine if a file on the time zone path is a
          valid time zone is to read the "magic string" at the
          beginning.

          注釈: These values are not designed to be exposed to
          end-users; for user facing elements, applications should use
          something like CLDR (the Unicode Common Locale Data
          Repository) to get more user-friendly strings.  See also the
          cautionary note on *note ZoneInfo.key: 23f5.

 -- の関数: zoneinfo.reset_tzpath (to=None)

     Sets or resets the time zone search path (*note TZPATH: 1cda.) for
     the module.  When called with no arguments, *note TZPATH: 1cda. is
     set to the default value.

     Calling ‘reset_tzpath’ will not invalidate the *note ZoneInfo: 8ad.
     cache, and so calls to the primary ‘ZoneInfo’ constructor will only
     use the new ‘TZPATH’ in the case of a cache miss.

     The ‘to’ parameter must be a *note sequence: 4be. of strings or
     *note os.PathLike: c1f. and not a string, all of which must be
     absolute paths.  *note ValueError: 1e3. will be raised if something
     other than an absolute path is passed.


File: python.info,  Node: Globals,  Next: 例外と警告,  Prev: 関数<3>,  Up: zoneinfo --- IANA タイムゾーンのサポート

5.8.2.11 Globals
................

 -- データ: zoneinfo.TZPATH

     A read-only sequence representing the time zone search path - when
     constructing a ‘ZoneInfo’ from a key, the key is joined to each
     entry in the ‘TZPATH’, and the first file found is used.

     ‘TZPATH’ may contain only absolute paths, never relative paths,
     regardless of how it is configured.

     The object that ‘zoneinfo.TZPATH’ points to may change in response
     to a call to *note reset_tzpath(): 23ea, so it is recommended to
     use ‘zoneinfo.TZPATH’ rather than importing ‘TZPATH’ from
     ‘zoneinfo’ or assigning a long-lived variable to ‘zoneinfo.TZPATH’.

     For more information on configuring the time zone search path, see
     *note Configuring the data sources: 23e7.


File: python.info,  Node: 例外と警告,  Prev: Globals,  Up: zoneinfo --- IANA タイムゾーンのサポート

5.8.2.12 例外と警告
...................

 -- 例外: zoneinfo.ZoneInfoNotFoundError

     Raised when construction of a *note ZoneInfo: 8ad. object fails
     because the specified key could not be found on the system.  This
     is a subclass of *note KeyError: 31d.

 -- 例外: zoneinfo.InvalidTZPathWarning

     Raised when *note PYTHONTZPATH: 23ed. contains an invalid component
     that will be filtered out, such as a relative path.


File: python.info,  Node: calendar --- 一般的なカレンダーに関係する機能群,  Next: collections --- コンテナデータ型,  Prev: zoneinfo --- IANA タイムゾーンのサポート,  Up: データ型

5.8.3 ‘calendar’ -- 一般的なカレンダーに関係する機能群
------------------------------------------------------

'ソースコード:' Lib/calendar.py(1)

__________________________________________________________________

このモジュールは Unix の ‘cal’ プログラムのようなカレンダー出力を行い、
それに加えてカレンダーに関する有益な関数群を提供します。標準ではこれらの
カレンダーは（ヨーロッパの慣例に従って）月曜日を週の始まりとし、日曜日を
最後の日としています。 *note setfirstweekday(): 23fe. を用いることで、日
曜日(6)や他の曜日を週の始まりに設定することができます。日付を表す引数は
整数値で与えます。関連する機能として、 *note datetime: 28. と *note
time: d7. モジュールも参照してください。

このモジュールに定義された関数やクラスは理想化されたカレンダー、つまり現
在のグレゴリオ暦を過去と未来両方に無限に拡張したものを使っています。これ
はすべての計算の基礎のカレンダーとなっている、 Dershowitz と Reingold の
本 "Calendrical Calculations" 中の "proleptic Gregorian" のカレンダーの
定義に合致します。ゼロと負の年は ISO 8601 の基準に定められている通りに扱
われます。0 年は 1 BC、-1 年は 2 BC、のように続きます。

 -- クラス: calendar.Calendar (firstweekday=0)

     *note Calendar: 23ff. オブジェクトを作ります。 'firstweekday' は整
     数で週の始まりの曜日を指定するものです。*note MONDAY: 2400. が ‘0’
     (デフォルト)、*note SUNDAY: 2401. なら ‘6’ です。

     *note Calendar: 23ff. オブジェクトは整形されるカレンダーのデータを
     準備するために使えるいくつかのメソッドを提供しています。しかし整形
     機能そのものは提供していません。それはサブクラスの仕事なのです。

     *note Calendar: 23ff. インスタンスには以下のメソッドがあります:

      -- メソッド: iterweekdays ()

          曜日の数字を一週間分生成するイテレータを返します。イテレータか
          ら得られる最初の数字は *note firstweekday: 2403. が返す数字と
          同じになります。

      -- メソッド: itermonthdates (year, month)

          'year' 年 'month' (1-12) 月に対するイテレータを返します。 この
          イテレータはその月の全ての日、およびその月が始まる前の日とその
          月が終わった後の日のうち、週の欠けを埋めるために必要な日を
          (*note datetime.date: 1af. オブジェクトとして) 返します。

      -- メソッド: itermonthdays (year, month)

          Return an iterator for the month 'month' in the year 'year'
          similar to *note itermonthdates(): be7, but not restricted by
          the *note datetime.date: 1af. range.  Days returned will
          simply be day of the month numbers.  For the days outside of
          the specified month, the day number is ‘0’.

      -- メソッド: itermonthdays2 (year, month)

          Return an iterator for the month 'month' in the year 'year'
          similar to *note itermonthdates(): be7, but not restricted by
          the *note datetime.date: 1af. range.  Days returned will be
          tuples consisting of a day of the month number and a week day
          number.

      -- メソッド: itermonthdays3 (year, month)

          Return an iterator for the month 'month' in the year 'year'
          similar to *note itermonthdates(): be7, but not restricted by
          the *note datetime.date: 1af. range.  Days returned will be
          tuples consisting of a year, a month and a day of the month
          numbers.

          Added in version 3.7.

      -- メソッド: itermonthdays4 (year, month)

          Return an iterator for the month 'month' in the year 'year'
          similar to *note itermonthdates(): be7, but not restricted by
          the *note datetime.date: 1af. range.  Days returned will be
          tuples consisting of a year, a month, a day of the month, and
          a day of the week numbers.

          Added in version 3.7.

      -- メソッド: monthdatescalendar (year, month)

          'year' 年 'month' 月の週のリストを返します。週は全て七つの
          *note datetime.date: 1af. オブジェクトからなるリストです。

      -- メソッド: monthdays2calendar (year, month)

          'year' 年 'month' 月の週のリストを返します。週は全て七つの日付
          の数字と曜日を表す数字のタプルからなるリストです。

      -- メソッド: monthdayscalendar (year, month)

          'year' 年 'month' 月の週のリストを返します。週は全て七つの日付
          の数字からなるリストです。

      -- メソッド: yeardatescalendar (year, width=3)

          指定された年のデータを整形に向く形で返します。返される値は月の
          並びのリストです。月の並びは最大で 'width' ヶ月(デフォルトは
          3ヶ月)分です。各月は4ないし6週からなり、各週は1ないし7日からな
          ります。各日は *note datetime.date: 1af. オブジェクトです。

      -- メソッド: yeardays2calendar (year, width=3)

          指定された年のデータを整形に向く形で返します (*note
          yeardatescalendar(): 2409. と同様です)。週のリストの中が日付の
          数字と曜日の数字のタプルになります。月の範囲外の部分の日付はゼ
          ロです。

      -- メソッド: yeardayscalendar (year, width=3)

          指定された年のデータを整形に向く形で返します (*note
          yeardatescalendar(): 2409. と同様です)。週のリストの中が日付の
          数字になります。月の範囲外の日付はゼロです。

 -- クラス: calendar.TextCalendar (firstweekday=0)

     このクラスはプレインテキストのカレンダーを生成するのに使えます。

     *note TextCalendar: 240c. インスタンスには以下のメソッドがあります:

      -- メソッド: formatmonth (theyear, themonth, w=0, l=0)

          ひと月分のカレンダーを複数行の文字列で返します。 'w' により日
          の列幅を変えることができ、それらは中央揃えされます。 'l' によ
          り各週の表示される行数を変えることができます。 *note
          setfirstweekday(): 23fe. メソッドでセットされた週の最初の曜日
          に依存します。

      -- メソッド: prmonth (theyear, themonth, w=0, l=0)

          *note formatmonth(): 240d. で返されるひと月分のカレンダーを出
          力します。

      -- メソッド: formatyear (theyear, w=2, l=1, c=6, m=3)

          'm' 列からなる一年間のカレンダーを複数行の文字列で返します。任
          意の引数 'w', 'l', 'c' はそれぞれ、日付列の表示幅、各週の行数
          及び月と月の間のスペースの数を変更するためのものです。 *note
          setfirstweekday(): 23fe. メソッドでセットされた週の最初の曜日
          に依存します。カレンダーを出力できる最初の年はプラットフォーム
          に依存します。

      -- メソッド: pryear (theyear, w=2, l=1, c=6, m=3)

          *note formatyear(): 240f. で返される一年間のカレンダーを出力し
          ます。

 -- クラス: calendar.HTMLCalendar (firstweekday=0)

     このクラスは HTML のカレンダーを生成するのに使えます。

     ‘HTMLCalendar’ インスタンスには以下のメソッドがあります:

      -- メソッド: formatmonth (theyear, themonth, withyear=True)

          ひと月分のカレンダーを HTML のテーブルとして返します。
          'withyear' が真であればヘッダには年も含まれます。そうでなけれ
          ば月の名前だけが使われます。

      -- メソッド: formatyear (theyear, width=3)

          一年分のカレンダーを HTML のテーブルとして返します。'width' の
          値 (デフォルトでは 3 です) は何ヶ月分を一行に収めるかを指定し
          ます。

      -- メソッド: formatyearpage (theyear, width=3, css='calendar.css',
               encoding=None)

          一年分のカレンダーを一つの完全な HTML ページとして返します。
          'width' の値(デフォルトでは 3 です) は何ヶ月分を一行に収めるか
          を指定します。 'css' は使われるカスケーディングスタイルシート
          の名前です。スタイルシートを使わないようにするために *note
          None: 641. を渡すこともできます。 'encoding' には出力に使うエ
          ンコーディングを指定します (デフォルトではシステムデフォルトの
          エンコーディングです)。

      -- メソッド: formatmonthname (theyear, themonth, withyear=True)

          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.

     ‘HTMLCalendar’ has the following attributes you can override to
     customize the CSS classes used by the calendar:

      -- の属性: cssclasses

          A list of CSS classes used for each weekday.  The default
          class list is:

               cssclasses = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]

          more styles can be added for each day:

               cssclasses = ["mon text-bold", "tue", "wed", "thu", "fri", "sat", "sun red"]

          Note that the length of this list must be seven items.

      -- の属性: cssclass_noday

          The CSS class for a weekday occurring in the previous or
          coming month.

          Added in version 3.7.

      -- の属性: cssclasses_weekday_head

          A list of CSS classes used for weekday names in the header
          row.  The default is the same as *note cssclasses: 2415.

          Added in version 3.7.

      -- の属性: cssclass_month_head

          The month's head CSS class (used by *note formatmonthname():
          2414.).  The default value is ‘"month"’.

          Added in version 3.7.

      -- の属性: cssclass_month

          The CSS class for the whole month's table (used by *note
          formatmonth(): 2411.).  The default value is ‘"month"’.

          Added in version 3.7.

      -- の属性: cssclass_year

          The CSS class for the whole year's table of tables (used by
          *note formatyear(): 2412.).  The default value is ‘"year"’.

          Added in version 3.7.

      -- の属性: cssclass_year_head

          The CSS class for the table head for the whole year (used by
          *note formatyear(): 2412.).  The default value is ‘"year"’.

          Added in version 3.7.

     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:

          "text-bold text-red"

     Here is an example how ‘HTMLCalendar’ can be customized:

          class CustomHTMLCal(calendar.HTMLCalendar):
              cssclasses = [style + " text-nowrap" for style in
                            calendar.HTMLCalendar.cssclasses]
              cssclass_month_head = "text-center month-head"
              cssclass_month = "text-center month"
              cssclass_year = "text-italic lead"

 -- クラス: calendar.LocaleTextCalendar (firstweekday=0, locale=None)

     This subclass of *note TextCalendar: 240c. can be passed a locale
     name in the constructor and will return month and weekday names in
     the specified locale.

 -- クラス: calendar.LocaleHTMLCalendar (firstweekday=0, locale=None)

     This subclass of *note HTMLCalendar: af1. can be passed a locale
     name in the constructor and will return month and weekday names in
     the specified locale.

     注釈: The constructor, ‘formatweekday()’ and ‘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.

単純なテキストのカレンダーに関して、このモジュールには以下のような関数が
提供されています。

 -- の関数: calendar.setfirstweekday (weekday)

     週の最初の曜日(‘0’ は月曜日, ‘6’ は日曜日)を設定します。定数 *note
     MONDAY: 2400, *note TUESDAY: 241c, *note WEDNESDAY: 241d, *note
     THURSDAY: 241e, *note FRIDAY: 241f, *note SATURDAY: 2420. 及び
     *note SUNDAY: 2401. は便宜上提供されています。例えば、日曜日を週の
     開始日に設定するときは:

          import calendar
          calendar.setfirstweekday(calendar.SUNDAY)

 -- の関数: calendar.firstweekday ()

     現在設定されている週の最初の曜日を返します。

 -- の関数: calendar.isleap (year)

     'year' が閏年なら *note True: bdb. を、そうでなければ *note False:
     b05. を返します。

 -- の関数: calendar.leapdays (y1, y2)

     範囲('y1' ...  'y2')指定された期間の閏年の回数を返します。ここで
     'y1' や 'y2' は年を表します。

     この関数は、世紀の境目をまたぐ範囲でも正しく動作します。

 -- の関数: calendar.weekday (year, month, day)

     'year' (‘1970’-...), 'month' (‘1’-‘12’), 'day' (‘1’-‘31’) で与えら
     れた日の曜日(‘0’ は月曜日)を返します。

 -- の関数: calendar.weekheader (n)

     短縮された曜日名を含むヘッダを返します。'n' は各曜日を何文字で表す
     かを指定します。

 -- の関数: calendar.monthrange (year, month)

     'year' と 'month' で指定された月の一日の曜日と日数を返します。

 -- の関数: calendar.monthcalendar (year, month)

     月のカレンダーを行列で返します。各行が週を表し、月の範囲外の日は0に
     なります。それぞれの週は *note setfirstweekday(): 23fe. で設定をし
     ていない限り月曜日から始まります。

 -- の関数: calendar.prmonth (theyear, themonth, w=0, l=0)

     *note month(): 2428. 関数によって返される月のカレンダーを出力します
     。

 -- の関数: calendar.month (theyear, themonth, w=0, l=0)

     Returns a month's calendar in a multi-line string using the *note
     formatmonth(): 240d. of the *note TextCalendar: 240c. class.

 -- の関数: calendar.prcal (year, w=0, l=0, c=6, m=3)

     *note calendar(): 10. 関数で返される一年間のカレンダーを出力します
     。

 -- の関数: calendar.calendar (year, w=2, l=1, c=6, m=3)

     Returns a 3-column calendar for an entire year as a multi-line
     string using the *note formatyear(): 240f. of the *note
     TextCalendar: 240c. class.

 -- の関数: calendar.timegm (tuple)

     カレンダーと直接は関係無いが、 *note time: d7. モジュールの *note
     gmtime(): 1190. 関数が返す形式の時刻を表すタプルを引数に取り、1970
     を基点とするエポック時刻で POSIX エンコーディングであると仮定して、
     対応する Unix タイムスタンプの値を返します。実際には、 *note
     time.gmtime(): 1190. と *note timegm(): 242b. はお互いの逆関数です
     。

*note calendar: 10. モジュールの以下のデータ属性を利用することができます
:

 -- データ: calendar.day_name

     A sequence that represents the days of the week in the current
     locale, where Monday is day number 0.

          >>> import calendar
          >>> list(calendar.day_name)
          ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']

 -- データ: calendar.day_abbr

     A sequence that represents the abbreviated days of the week in the
     current locale, where Mon is day number 0.

          >>> import calendar
          >>> list(calendar.day_abbr)
          ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

 -- データ: calendar.MONDAY
 -- データ: calendar.TUESDAY
 -- データ: calendar.WEDNESDAY
 -- データ: calendar.THURSDAY
 -- データ: calendar.FRIDAY
 -- データ: calendar.SATURDAY
 -- データ: calendar.SUNDAY

     Aliases for the days of the week, where ‘MONDAY’ is ‘0’ and
     ‘SUNDAY’ is ‘6’.

     Added in version 3.12.

 -- クラス: calendar.Day

     Enumeration defining days of the week as integer constants.  The
     members of this enumeration are exported to the module scope as
     *note MONDAY: 2400. through *note SUNDAY: 2401.

     Added in version 3.12.

 -- データ: calendar.month_name

     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.

          >>> import calendar
          >>> list(calendar.month_name)
          ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']

 -- データ: calendar.month_abbr

     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.

          >>> import calendar
          >>> list(calendar.month_abbr)
          ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']

 -- データ: calendar.JANUARY
 -- データ: calendar.FEBRUARY
 -- データ: calendar.MARCH
 -- データ: calendar.APRIL
 -- データ: calendar.MAY
 -- データ: calendar.JUNE
 -- データ: calendar.JULY
 -- データ: calendar.AUGUST
 -- データ: calendar.SEPTEMBER
 -- データ: calendar.OCTOBER
 -- データ: calendar.NOVEMBER
 -- データ: calendar.DECEMBER

     Aliases for the months of the year, where ‘JANUARY’ is ‘1’ and
     ‘DECEMBER’ is ‘12’.

     Added in version 3.12.

 -- クラス: calendar.Month

     Enumeration defining months of the year as integer constants.  The
     members of this enumeration are exported to the module scope as
     *note JANUARY: 2d0. through *note DECEMBER: 2439.

     Added in version 3.12.

The *note calendar: 10. module defines the following exceptions:

 -- 例外: calendar.IllegalMonthError (month)

     A subclass of *note ValueError: 1e3, raised when the given month
     number is outside of the range 1-12 (inclusive).

      -- の属性: month

          The invalid month number.

 -- 例外: calendar.IllegalWeekdayError (weekday)

     A subclass of *note ValueError: 1e3, raised when the given weekday
     number is outside of the range 0-6 (inclusive).

      -- の属性: weekday

          The invalid weekday number.

参考
....

*note datetime: 28. モジュール

     *note time: d7. モジュールと似た機能を持った日付と時間用のオブジェ
     クト指向インターフェース。

*note time: d7. モジュール

     時間に関連した低水準の関数群。

* Menu:

* コマンドラインからの使用::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/calendar.py


File: python.info,  Node: コマンドラインからの使用,  Up: calendar --- 一般的なカレンダーに関係する機能群

5.8.3.1 コマンドラインからの使用
................................

Added in version 2.5.

The *note calendar: 10. module can be executed as a script from the
command line to interactively print a calendar.

     python -m calendar [-h] [-L LOCALE] [-e ENCODING] [-t {text,html}]
                        [-w WIDTH] [-l LINES] [-s SPACING] [-m MONTHS] [-c CSS]
                        [-f FIRST_WEEKDAY] [year] [month]

For example, to print a calendar for the year 2000:

     $ python -m calendar 2000
                                       2000

           January                   February                   March
     Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                     1  2          1  2  3  4  5  6             1  2  3  4  5
      3  4  5  6  7  8  9       7  8  9 10 11 12 13       6  7  8  9 10 11 12
     10 11 12 13 14 15 16      14 15 16 17 18 19 20      13 14 15 16 17 18 19
     17 18 19 20 21 22 23      21 22 23 24 25 26 27      20 21 22 23 24 25 26
     24 25 26 27 28 29 30      28 29                     27 28 29 30 31
     31

            April                      May                       June
     Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                     1  2       1  2  3  4  5  6  7                1  2  3  4
      3  4  5  6  7  8  9       8  9 10 11 12 13 14       5  6  7  8  9 10 11
     10 11 12 13 14 15 16      15 16 17 18 19 20 21      12 13 14 15 16 17 18
     17 18 19 20 21 22 23      22 23 24 25 26 27 28      19 20 21 22 23 24 25
     24 25 26 27 28 29 30      29 30 31                  26 27 28 29 30

             July                     August                  September
     Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                     1  2          1  2  3  4  5  6                   1  2  3
      3  4  5  6  7  8  9       7  8  9 10 11 12 13       4  5  6  7  8  9 10
     10 11 12 13 14 15 16      14 15 16 17 18 19 20      11 12 13 14 15 16 17
     17 18 19 20 21 22 23      21 22 23 24 25 26 27      18 19 20 21 22 23 24
     24 25 26 27 28 29 30      28 29 30 31               25 26 27 28 29 30
     31

           October                   November                  December
     Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
                        1             1  2  3  4  5                   1  2  3
      2  3  4  5  6  7  8       6  7  8  9 10 11 12       4  5  6  7  8  9 10
      9 10 11 12 13 14 15      13 14 15 16 17 18 19      11 12 13 14 15 16 17
     16 17 18 19 20 21 22      20 21 22 23 24 25 26      18 19 20 21 22 23 24
     23 24 25 26 27 28 29      27 28 29 30               25 26 27 28 29 30 31
     30 31

以下のオプションが使用できます:

 -- Option: --help, -h

     ヘルプメッセージを表示して終了します。

 -- Option: --locale LOCALE, -L LOCALE

     The locale to use for month and weekday names.  Defaults to
     English.

 -- Option: --encoding ENCODING, -e ENCODING

     The encoding to use for output.  *note -encoding: 2444. is required
     if *note -locale: 2442. is set.

 -- Option: --type {text,html}, -t {text,html}

     Print the calendar to the terminal as text, or as an HTML document.

 -- Option: --first-weekday FIRST_WEEKDAY, -f FIRST_WEEKDAY

     The weekday to start each week.  Must be a number between 0
     (Monday) and 6 (Sunday).  Defaults to 0.

     Added in version 3.13.

 -- Option: year

     The year to print the calendar for.  Defaults to the current year.

 -- Option: month

     The month of the specified *note year: 244a. to print the calendar
     for.  Must be a number between 1 and 12, and may only be used in
     text mode.  Defaults to printing a calendar for the full year.

'Text-mode options:'

 -- Option: --width WIDTH, -w WIDTH

     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.

 -- Option: --lines LINES, -l LINES

     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.

 -- Option: --spacing SPACING, -s SPACING

     The space between months in columns.  Any value lower than 2 is
     ignored.  Defaults to 6.

 -- Option: --months MONTHS, -m MONTHS

     The number of months printed per row.  Defaults to 3.

'HTML-mode options:'

 -- Option: --css CSS, -c CSS

     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.


File: python.info,  Node: collections --- コンテナデータ型,  Next: collections abc --- コンテナの抽象基底クラス,  Prev: calendar --- 一般的なカレンダーに関係する機能群,  Up: データ型

5.8.4 ‘collections’ -- コンテナデータ型
---------------------------------------

'ソースコード:' Lib/collections/__init__.py(1)

__________________________________________________________________

このモジュールは、汎用の Python 組み込みコンテナ *note dict: 237, *note
list: 5dc, *note set: 5a3, および *note tuple: 349. に代わる、特殊なコン
テナデータ型を実装しています。

*note namedtuple(): 1ac.  名前付きフィールドを持つタプルのサブクラスを作成するファクトリ関数
                          
                          
*note deque: 5a6.         両端における append や pop を高速に行えるリスト風のコンテナ
                          
                          
*note ChainMap: bea.      複数のマッピングの一つのビューを作成する辞書風のクラス
                          
                          
*note Counter: 1067.      *note ハッシュ可能: 5db. なオブジェクトを数え上げる辞書のサブクラス
                          
                          
*note OrderedDict: 5a5.   項目が追加された順序を記憶する辞書のサブクラス
                          
                          
*note defaultdict: 118d.  ファクトリ関数を呼び出して存在しない値を供給する辞書のサブクラス
                          
                          
*note UserDict: 18ff.     辞書のサブクラス化を簡単にする辞書オブジェクトのラッパ
                          
                          
*note UserList: 148c.     リストのサブクラス化を簡単にするリストオブジェクトのラッパ
                          
                          
*note UserString: da2.    文字列のサブクラス化を簡単にする文字列オブジェクトのラッパ
                          

* Menu:

* ChainMap オブジェクト::
* Counter オブジェクト::
* deque オブジェクト::
* defaultdict オブジェクト::
* namedtuple() 名前付きフィールドを持つタプルのファクトリ関数: namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
* OrderedDict オブジェクト::
* UserDict オブジェクト::
* UserList オブジェクト::
* UserString オブジェクト::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/collections/__init__.py


File: python.info,  Node: ChainMap オブジェクト,  Next: Counter オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.1 ‘ChainMap’ オブジェクト
...............................

Added in version 3.3.

*note ChainMap: bea. クラスは、複数のマッピングを素早く連結し、一つの単
位として扱うために提供されています。これはたいてい、新しい辞書を作成して
*note update(): 140a. を繰り返すよりも早いです。

このクラスはネストされたスコープをシミュレートするのに使え、テンプレート
化に便利です。

 -- クラス: collections.ChainMap (*maps)

     *note ChainMap: bea. は、複数の辞書やその他のマッピングをまとめて、
     一つの、更新可能なビューを作成します。 'maps' が指定されないなら、
     一つの空辞書が与えられますから、新しいチェーンは必ず一つ以上のマッ
     ピングをもちます。

     根底のマッピングはリストに保存されます。このリストはパブリックで、
     'maps' 属性を使ってアクセスや更新できます。それ以外に状態はありませ
     ん。

     探索は、根底のマッピングをキーが見つかるまで引き続き探します。対し
     て、書き込み、更新、削除は、最初のマッピングのみ操作します。

     *note ChainMap: bea. は、根底のマッピングを参照によって組み込みます
     。ですから、根底のマッピングの一つが更新されると、その変更は *note
     ChainMap: bea. に反映されます。

     通常の辞書のメソッドすべてがサポートされています。さらに、'maps' 属
     性、新しいサブコンテキストを作成するメソッド、最初のマッピング以外
     のすべてにアクセスするためのプロパティがあります:

      -- の属性: maps

          マッピングのユーザがアップデートできるリストです。このリストは
          最初に探されるものから最後に探されるものの順に並んでいます。こ
          れが唯一のソートされた状態であり、変更してマッピングが探される
          順番を変更できます。このリストは常に一つ以上のマッピングを含ん
          でいなければなりません。

      -- メソッド: new_child (m=None, **kwargs)

          新しいマッピングに現在のインスタンスが持つ全てのマッピングを追
          加したものを持つ新しい *note ChainMap: bea. インスタンスを返し
          ます。 ‘m’ が指定された場合、新しいマッピングのリストの先頭部
          分になります; 指定されない場合は空の辞書が使われます。すなわち
          ‘d.new_child()’ は ‘ChainMap({}, *d.maps)’ と等価になります。
          キーワード引数が指定された場合、それらによって指定されたマッピ
          ングまたは空の辞書が更新されます。このメソッドは、元のマッピン
          グに変更を加えることなく値を更新できるサブコンテキストを生成す
          るのに使われます。

          バージョン 3.4 で変更: オプションの ‘m’ 引数が追加されました。

          バージョン 3.10 で変更: キーワード引数のサポートが追加されまし
          た。

      -- の属性: parents

          現在のインスタンスの最初のマッピング以外のすべてのマッピングを
          含む新しい *note ChainMap: bea. を返すプロパティです。これは最
          初のマッピングを検索から飛ばすのに便利です。使用例は *note
          nonlocal: 1279. キーワードを *note ネストされたスコープ: 1e9e.
          に使う例と似ています。この使用例はまた、組み込み *note
          super(): 4a8. 関数にも似ています。 ‘d.parents’ への参照は
          ‘ChainMap(*d.maps[1:])’ と等価です。

     *note ChainMap: bea. の反復順序は、マッピングを最後から最初へスキャ
     ンして決定されることに注意してください。

          >>> baseline = {'music': 'bach', 'art': 'rembrandt'}
          >>> adjustments = {'art': 'van gogh', 'opera': 'carmen'}
          >>> list(ChainMap(adjustments, baseline))
          ['music', 'art', 'opera']

     これは、末尾のマッピングオブジェクトから始めた一連の *note
     dict.update(): 140a. の呼び出しと同じ順序になります。

          >>> combined = baseline.copy()
          >>> combined.update(adjustments)
          >>> list(combined)
          ['music', 'art', 'opera']

     バージョン 3.9 で変更: PEP 584(1) で規定されている ‘|’ 演算子と
     ‘|=’ 演算子のサポートを追加しました。

参考
....

   * Enthought 社の CodeTools パッケージ(2) に含まれる MultiContext クラ
     ス(3) は、チェーン内のすべてのマッピングへの書き込みをサポートする
     オプションを持ちます。

   * Django のテンプレート用の Context class(4) は、読み出し専用のマッピ
     ングのチェーンです。 *note new_child(): eef. メソッドや *note
     parents: 245a. プロパティに似た push や pop の機能もあります。

   * Nested Contexts recipe(5) は、書き込み・その他の変更が最初のマッピ
     ングにのみ適用されるか、チェーンのすべてのマッピングに適用されるか
     、制御するオプションを持ちます。

   * 非常に単純化した読み出し専用バージョンの Chainmap(6)。

* Menu:

* ChainMap の例とレシピ::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0584/

   (2) https://github.com/enthought/codetools

   (3) 
https://github.com/enthought/codetools/blob/4.0.0/codetools/contexts/multi_context.py

   (4) 
https://github.com/django/django/blob/main/django/template/context.py

   (5) 
https://code.activestate.com/recipes/577434-nested-contexts-a-chain-of-mapping-objects/

   (6) https://code.activestate.com/recipes/305268/


File: python.info,  Node: ChainMap の例とレシピ,  Up: ChainMap オブジェクト

5.8.4.2 ‘ChainMap’ の例とレシピ
...............................

この節では、チェーンされたマッピングを扱う様々な手法を示します。

Python の内部探索チェーンをシミュレートする例:

     import builtins
     pylookup = ChainMap(locals(), globals(), vars(builtins))

ユーザ指定のコマンドライン引数、環境変数、デフォルト値、の順に優先させる
例:

     import os, argparse

     defaults = {'color': 'red', 'user': 'guest'}

     parser = argparse.ArgumentParser()
     parser.add_argument('-u', '--user')
     parser.add_argument('-c', '--color')
     namespace = parser.parse_args()
     command_line_args = {k: v for k, v in vars(namespace).items() if v is not None}

     combined = ChainMap(command_line_args, os.environ, defaults)
     print(combined['color'])
     print(combined['user'])

*note ChainMap: bea. を使ってネストされたコンテキストをシミュレートする
パターンの例:

     c = ChainMap()        # Create root context
     d = c.new_child()     # Create nested child context
     e = c.new_child()     # Child of c, independent from d
     e.maps[0]             # Current context dictionary -- like Python's locals()
     e.maps[-1]            # Root context -- like Python's globals()
     e.parents             # Enclosing context chain -- like Python's nonlocals

     d['x'] = 1            # Set value in current context
     d['x']                # Get first key in the chain of contexts
     del d['x']            # Delete from current context
     list(d)               # All nested values
     k in d                # Check all nested values
     len(d)                # Number of nested values
     d.items()             # All nested items
     dict(d)               # Flatten into a regular dictionary

*note ChainMap: bea. クラスは、探索はチェーン全体に対して行いますが、更
新 (書き込みと削除) は最初のマッピングに対してのみ行います。しかし、深い
書き込みと削除を望むなら、チェーンの深いところで見つかったキーを更新する
サブクラスを簡単に作れます:

     class DeepChainMap(ChainMap):
         'Variant of ChainMap that allows direct updates to inner scopes'

         def __setitem__(self, key, value):
             for mapping in self.maps:
                 if key in mapping:
                     mapping[key] = value
                     return
             self.maps[0][key] = value

         def __delitem__(self, key):
             for mapping in self.maps:
                 if key in mapping:
                     del mapping[key]
                     return
             raise KeyError(key)

     >>> d = DeepChainMap({'zebra': 'black'}, {'elephant': 'blue'}, {'lion': 'yellow'})
     >>> d['lion'] = 'orange'         # update an existing key two levels down
     >>> d['snake'] = 'red'           # new keys get added to the topmost dict
     >>> del d['elephant']            # remove an existing key one level down
     >>> d                            # display result
     DeepChainMap({'zebra': 'black', 'snake': 'red'}, {}, {'lion': 'orange'})


File: python.info,  Node: Counter オブジェクト,  Next: deque オブジェクト,  Prev: ChainMap オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.3 ‘Counter’ オブジェクト
..............................

便利で迅速な検数をサポートするカウンタツールが提供されています。例えば:

     >>> # Tally occurrences of words in a list
     >>> cnt = Counter()
     >>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
     ...     cnt[word] += 1
     ...
     >>> cnt
     Counter({'blue': 3, 'red': 2, 'green': 1})

     >>> # Find the ten most common words in Hamlet
     >>> import re
     >>> words = re.findall(r'\w+', open('hamlet.txt').read().lower())
     >>> Counter(words).most_common(10)
     [('the', 1143), ('and', 966), ('to', 762), ('of', 669), ('i', 631),
      ('you', 554),  ('a', 546), ('my', 514), ('hamlet', 471), ('in', 451)]

 -- クラス: collections.Counter ([iterable-or-mapping])

     *note Counter: 1067. は *note ハッシュ可能: 5db. なオブジェクトをカ
     ウントする *note dict: 237. のサブクラスです。これは、要素を辞書の
     キーとして保存し、そのカウントを辞書の値として保存するコレクション
     です。カウントは、0 や負のカウントを含む整数値をとれます。 *note
     Counter: 1067. クラスは、他の言語のバッグや多重集合のようなものです
     。

     要素は、 'iterable' から数え上げられたり、他の 'mapping' (やカウン
     タ) から初期化されます:

          >>> c = Counter()                           # a new, empty counter
          >>> c = Counter('gallahad')                 # a new counter from an iterable
          >>> c = Counter({'red': 4, 'blue': 2})      # a new counter from a mapping
          >>> c = Counter(cats=4, dogs=8)             # a new counter from keyword args

     カウンタオブジェクトは辞書のインターフェースを持ちますが、存在しな
     い要素に対して *note KeyError: 31d. を送出する代わりに 0 を返すとい
     う違いがあります:

          >>> c = Counter(['eggs', 'ham'])
          >>> c['bacon']                              # count of a missing element is zero
          0

     カウントを 0 に設定しても、要素はカウンタから取り除かれません。完全
     に取り除くには、 ‘del’ を使ってください:

          >>> c['sausage'] = 0                        # counter entry with a zero count
          >>> del c['sausage']                        # del actually removes the entry

     Added in version 3.1.

     バージョン 3.7 で変更: *note Counter: 1067. は *note dict: 237. の
     サブクラスとして要素の挿入順を維持する機能を継承しました。
     'Counter' オブジェクトに対する数学演算も順序を維持します。結果の順
     序はまず左の被演算子における要素の出現順に従い、その後右の被演算子
     において要素が出現する順序になります。

     カウンタオブジェクトは全ての辞書で利用できるメソッドに加えて、以下
     に示す追加のメソッドをサポートしています。

      -- メソッド: elements ()

          それぞれの要素を、そのカウント分の回数だけ繰り返すイテレータを
          返します。要素は挿入した順番で返されます。ある要素のカウントが
          1 未満なら、 *note elements(): 12d2. はそれを無視します。

               >>> c = Counter(a=4, b=2, c=0, d=-2)
               >>> sorted(c.elements())
               ['a', 'a', 'a', 'a', 'b', 'b']

      -- メソッド: most_common ([n])

          最も多い 'n' 要素を、カウントが多いものから少ないものまで順に
          並べたリストを返します。 'n' が省略されるか ‘None’ であれば、
          *note most_common(): 12d1. はカウンタの 'すべての' 要素を返し
          ます。等しいカウントの要素は挿入順に並べられます:

               >>> Counter('abracadabra').most_common(3)
               [('a', 5), ('b', 2), ('r', 2)]

      -- メソッド: subtract ([iterable-or-mapping])

          要素から 'iterable' の要素または 'mapping' の要素が引かれます
          。 *note dict.update(): 140a. に似ていますが、カウントを置き換
          えるのではなく引きます。入力も出力も、 0 や負になりえます。

               >>> c = Counter(a=4, b=2, c=0, d=-2)
               >>> d = Counter(a=1, b=2, c=3, d=4)
               >>> c.subtract(d)
               >>> c
               Counter({'a': 3, 'b': 0, 'c': -3, 'd': -6})

          Added in version 3.2.

      -- メソッド: total ()

          カウントの合計を計算します。

               >>> c = Counter(a=10, b=5, c=0)
               >>> c.total()
               15

          Added in version 3.10.

     普通の辞書のメソッドは、以下の 2 つのメソッドがカウンタに対して異な
     る振る舞いをするのを除き、 *note Counter: 1067. オブジェクトにも利
     用できます。

      -- メソッド: fromkeys (iterable)

          このクラスメソッドは *note Counter: 1067. オブジェクトには実装
          されていません。

      -- メソッド: update ([iterable-or-mapping])

          要素が 'iterable' からカウントされるか、別の 'mapping' (やカウ
          ンタ) が追加されます。 *note dict.update(): 140a. に似ています
          が、カウントを置き換えるのではなく追加します。また、
          'iterable' には ‘(key, value)’ 対のシーケンスではなく、要素の
          シーケンスが求められます。

カウンタオブジェクトは等価、部分集合、上位集合のための次の拡張比較 (rich
comparison) 演算子をサポートします: ‘==’, ‘!=’, ‘<’, ‘<=’, ‘>’, ‘>=’。こ
れらの比較は、存在しない要素をカウントがゼロであるとみなします。すなわち
、 ‘Counter(a=1) == Counter(a=1, b=0)’ は真を返します。

バージョン 3.10 で変更: 拡張比較 (rich comparison) 演算が追加されました
。

バージョン 3.10 で変更: 等価比較において、存在しない要素はカウントがゼロ
であるとみなされるようになりました。かつては ‘Counter(a=3)’ と
‘Counter(a=3, b=0)’ は異なるとみなされていました。

*note Counter: 1067. オブジェクトを使ったよくあるパターン:

     c.total()                       # total of all counts
     c.clear()                       # reset all counts
     list(c)                         # list unique elements
     set(c)                          # convert to a set
     dict(c)                         # convert to a regular dictionary
     c.items()                       # access the (elem, cnt) pairs
     Counter(dict(list_of_pairs))    # convert from a list of (elem, cnt) pairs
     c.most_common()[:-n-1:-1]       # n least common elements
     +c                              # remove zero and negative counts

*note Counter: 1067. オブジェクトを組み合わせて多重集合 (0より大きいカウ
ントを持つカウンタ) を作るためのいくつかの数学演算が提供されています。加
算と減算はそれぞれの要素のカウンタを加算または減算することによりカウンタ
オブジェクトを組み合わせます。積集合と和集合は、それぞれのカウントの最大
値と最小値を返します。等価と包含はそれぞれのカウントを比較します。それぞ
れの演算は符号付きカウントを持った入力を受け付けますが、カウントが0以下
の要素は結果から取り除かれます。

     >>> c = Counter(a=3, b=1)
     >>> d = Counter(a=1, b=2)
     >>> c + d                       # add two counters together:  c[x] + d[x]
     Counter({'a': 4, 'b': 3})
     >>> c - d                       # subtract (keeping only positive counts)
     Counter({'a': 2})
     >>> c & d                       # intersection:  min(c[x], d[x])
     Counter({'a': 1, 'b': 1})
     >>> c | d                       # union:  max(c[x], d[x])
     Counter({'a': 3, 'b': 2})
     >>> c == d                      # equality:  c[x] == d[x]
     False
     >>> c <= d                      # inclusion:  c[x] <= d[x]
     False

単項加算および減算は、空カウンタの加算や空カウンタからの減算へのショート
カットです。

     >>> c = Counter(a=2, b=-4)
     >>> +c
     Counter({'a': 2})
     >>> -c
     Counter({'b': 4})

Added in version 3.3: 単項加算、単項減算、in-place の多重集合操作のサポ
ートが追加されました。

     注釈: カウンタはもともと、推移するカウントを正の整数で表すために設
     計されました。しかし、他の型や負の値を必要とするユースケースを不必
     要に排除することがないように配慮されています。このようなユースケー
     スの助けになるように、この節で最低限の範囲と型の制限について記述し
     ます。

        * *note Counter: 1067. クラス自体は辞書のサブクラスで、キーと値
          に制限はありません。値はカウントを表す数であることを意図してい
          ますが、値フィールドに任意のものを保存 'できます' 。

        * *note most_common(): 12d1. メソッドが要求するのは、値が順序付
          け可能なことだけです。

        * ‘c[key] += 1’ のようなインプレース演算では、値の型に必要なのは
          足し算と引き算ができることだけです。よって分数、浮動小数点数、
          小数も使え、負の値がサポートされています。これと同じことが、 負
          や 0 の値を入力と出力に許す *note update(): 245f. と *note
          subtract(): 11af. メソッド にも言えます。

        * 多重集合メソッドは正の値を扱うユースケースに対してのみ設計され
          ています。入力は負や 0 に出来ますが、正の値の出力のみが生成さ
          れます。型の制限はありませんが、値の型は足し算、引き算、比較を
          サポートしている必要があります。

        * *note elements(): 12d2. メソッドは整数のカウントを要求します。
          これは 0 と負のカウントを無視します。

参考
....

   * Smalltalk の Bag class(1) 。

   * Wikipedia の Multisets(2) の項目。

   * C++ multisets(3) の例を交えたチュートリアル。

   * 数学的な多重集合の演算とそのユースケースは、 'Knuth, Donald.  The
     Art of Computer Programming Volume II, Section 4.6.3, Exercise 19'
     を参照してください。

   * 与えられた要素の集まりからなる与えられた大きさの相違なる多重集合を
     すべて数え上げるには、 *note
     itertools.combinations_with_replacement(): 1252. を参照してください
     :

          map(Counter, combinations_with_replacement('ABC', 2)) # --> AA AB AC BB BC CC

   ---------- Footnotes ----------

   (1) 
https://www.gnu.org/software/smalltalk/manual-base/html_node/Bag.html

   (2) https://en.wikipedia.org/wiki/Multiset

   (3) 
http://www.java2s.com/Tutorial/Cpp/0380__set-multiset/Catalog0380__set-multiset.htm


File: python.info,  Node: deque オブジェクト,  Next: defaultdict オブジェクト,  Prev: Counter オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.4 ‘deque’ オブジェクト
............................

 -- クラス: collections.deque ([iterable[, maxlen]])

     'iterable' で与えられるデータから、新しい deque オブジェクトを
     (*note append(): 2461. をつかって) 左から右に初期化して返します。
     'iterable' が指定されない場合、新しい deque オブジェクトは空になり
     ます。

     Deque とは、スタックとキューを一般化したものです (この名前は「デッ
     ク」と発音され、これは「double-ended queue」の省略形です)。Deque は
     どちらの側からも append と pop が可能で、スレッドセーフでメモリ効率
     がよく、どちらの方向からもおよそ 'O'(1) のパフォーマンスで実行でき
     ます。

     *note list: 5dc. オブジェクトでも同様の操作を実現できますが、これは
     高速な固定長の操作に特化されており、基礎のデータ表現形式のサイズと
     位置を両方変えるような ‘pop(0)’ や ‘insert(0, v)’ などの操作ではメ
     モリ移動のために 'O'('n') のコストを必要とします。

     'maxlen' が指定されなかったり ‘None’ だった場合、 deque は任意のサ
     イズまで大きくなります。 そうでない場合、 deque のサイズは指定され
     た最大長に制限されます。 長さが制限された deque がいっぱいになると
     、新しい要素を追加するときに追加した要素数分だけ追加したのと反対側
     から要素が捨てられます。 長さが制限された deque は Unix における
     ‘tail’ フィルタと似た機能を提供します。 トランザクションの tracking
     や最近使った要素だけを残したいデータプール (pool of data) などにも
     便利です。

     Deque オブジェクトは以下のようなメソッドをサポートしています:

      -- メソッド: append (x)

          'x' を deque の右側につけ加えます。

      -- メソッド: appendleft (x)

          'x' を deque の左側につけ加えます。

      -- メソッド: clear ()

          deque からすべての要素を削除し、長さを 0 にします。

      -- メソッド: copy ()

          deque の浅いコピーを作成します。

          Added in version 3.5.

      -- メソッド: count (x)

          deque の 'x' に等しい要素を数え上げます。

          Added in version 3.2.

      -- メソッド: extend (iterable)

          イテラブルな引数 iterable から得られる要素を deque の右側に追
          加し拡張します。

      -- メソッド: extendleft (iterable)

          イテラブルな引数 iterable から得られる要素を deque の左側に追
          加し拡張します。注意: 左から追加した結果は、イテラブルな引数の
          順序とは逆になります。

      -- メソッド: index (x[, start[, stop]])

          deque 内の 'x' の位置を返します (インデックス 'start' からイン
          デックス 'stop' の両端を含む範囲で)。最初のマッチを返すか、見
          つからない場合には *note ValueError: 1e3. を発生させます。

          Added in version 3.5.

      -- メソッド: insert (i, x)

          'x' を deque の位置 'i' に挿入します。

          挿入によって、長さに制限のある deque の長さが 'maxlen' を超え
          る場合、*note IndexError: 14de. が発生します。

          Added in version 3.5.

      -- メソッド: pop ()

          deque の右側から要素をひとつ削除し、その要素を返します。要素が
          ひとつも存在しない場合は *note IndexError: 14de. を発生させま
          す。

      -- メソッド: popleft ()

          deque の左側から要素をひとつ削除し、その要素を返します。要素が
          ひとつも存在しない場合は *note IndexError: 14de. を発生させま
          す。

      -- メソッド: remove (value)

          'value' の最初に現れるものを削除します。要素が見付からないない
          場合は *note ValueError: 1e3. を送出します。

      -- メソッド: reverse ()

          deque の要素をインプレースに反転し、‘None’ を返します。

          Added in version 3.2.

      -- メソッド: rotate (n=1)

          deque の要素を全体で 'n' ステップだけ右にローテートします。'n'
          が負の値の場合は、左にローテートします。

          deque が空でないときは、 deque をひとつ右にローテートすること
          は ‘d.appendleft(d.pop())’ と同じで、 deque をひとつ左にローテ
          ートすることは ‘d.append(d.popleft())’ と同じです。

     deque オブジェクトは読み出し専用属性も 1 つ提供しています:

      -- の属性: maxlen

          deque の最大長で、制限されていなければ ‘None’ です。

          Added in version 3.1.

上記に加え、 deque はイテレーション, pickle 化, ‘len(d)’, ‘reversed(d)’,
‘copy.copy(d)’, ‘copy.deepcopy(d)’, *note in: 2cb. 演算子による包含の検
査, ‘d[0]’ のような添字による参照をサポートしています。添字によるアクセ
スは、両端の要素では 'O'(1) ですが、中央部分の要素では 'O'('n') と遅くな
ります。高速なランダムアクセスのためには、代わりにリストを使ってください
。

バージョン 3.5 から deque は ‘__add__()’, ‘__mul__()’, ‘__imul__()’ をサ
ポートしました。

例:

     >>> from collections import deque
     >>> d = deque('ghi')                 # make a new deque with three items
     >>> for elem in d:                   # iterate over the deque's elements
     ...     print(elem.upper())
     G
     H
     I

     >>> d.append('j')                    # add a new entry to the right side
     >>> d.appendleft('f')                # add a new entry to the left side
     >>> d                                # show the representation of the deque
     deque(['f', 'g', 'h', 'i', 'j'])

     >>> d.pop()                          # return and remove the rightmost item
     'j'
     >>> d.popleft()                      # return and remove the leftmost item
     'f'
     >>> list(d)                          # list the contents of the deque
     ['g', 'h', 'i']
     >>> d[0]                             # peek at leftmost item
     'g'
     >>> d[-1]                            # peek at rightmost item
     'i'

     >>> list(reversed(d))                # list the contents of a deque in reverse
     ['i', 'h', 'g']
     >>> 'h' in d                         # search the deque
     True
     >>> d.extend('jkl')                  # add multiple elements at once
     >>> d
     deque(['g', 'h', 'i', 'j', 'k', 'l'])
     >>> d.rotate(1)                      # right rotation
     >>> d
     deque(['l', 'g', 'h', 'i', 'j', 'k'])
     >>> d.rotate(-1)                     # left rotation
     >>> d
     deque(['g', 'h', 'i', 'j', 'k', 'l'])

     >>> deque(reversed(d))               # make a new deque in reverse order
     deque(['l', 'k', 'j', 'i', 'h', 'g'])
     >>> d.clear()                        # empty the deque
     >>> d.pop()                          # cannot pop from an empty deque
     Traceback (most recent call last):
         File "<pyshell#6>", line 1, in -toplevel-
             d.pop()
     IndexError: pop from an empty deque

     >>> d.extendleft('abc')              # extendleft() reverses the input order
     >>> d
     deque(['c', 'b', 'a'])

* Menu:

* deque のレシピ::


File: python.info,  Node: deque のレシピ,  Up: deque オブジェクト

5.8.4.5 ‘deque’ のレシピ
........................

この節では deque を使った様々なアプローチを紹介します。

長さが制限された deque は Unix における ‘tail’ フィルタに相当する機能を
提供します:

     def tail(filename, n=10):
         'Return the last n lines of a file'
         with open(filename) as f:
             return deque(f, n)

deque を使用する別のアプローチは、右に要素を追加し左から要素を取り出すこ
とで最近追加した要素のシーケンスを保持することです:

     def moving_average(iterable, n=3):
         # moving_average([40, 30, 50, 46, 39, 44]) --> 40.0 42.0 45.0 43.0
         # https://en.wikipedia.org/wiki/Moving_average
         it = iter(iterable)
         d = deque(itertools.islice(it, n-1))
         d.appendleft(0)
         s = sum(d)
         for elem in it:
             s += elem - d.popleft()
             d.append(elem)
             yield s / n

ラウンドロビンスケジューラ(1) は、入力されたイテレータを *note deque:
5a6. に格納することで実装できます。 値は、位置0にある選択中のイテレータ
から取り出されます。 そのイテレータが値を出し切った場合は、 *note
popleft(): 2467. で除去できます; そうでない場合は、 *note rotate():
1841. メソッドで末尾に回せます:

     def roundrobin(*iterables):
         "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
         iterators = deque(map(iter, iterables))
         while iterators:
             try:
                 while True:
                     yield next(iterators[0])
                     iterators.rotate(-1)
             except StopIteration:
                 # Remove an exhausted iterator.
                 iterators.popleft()

*note rotate(): 1841. メソッドは、 *note deque: 5a6. のスライスや削除の
機能を提供します。 例えば、 純粋な Python 実装の ‘del d[n]’ は
‘rotate()’ メソッドを頼りに、pop される要素の位置を割り出します:

     def delete_nth(d, n):
         d.rotate(-n)
         d.popleft()
         d.rotate(n)

*note deque: 5a6. のスライスの実装でも、同様のアプローチを使います。まず
対象となる要素を *note rotate(): 1841. によって deque の左端まで移動させ
てから、 *note popleft(): 2467. で古い要素を削除します。そして、 *note
extend(): 2464. で新しい要素を追加したのち、循環を逆にします。このアプロ
ーチをやや変えたものとして、Forth スタイルのスタック操作、つまり ‘dup’,
‘drop’, ‘swap’, ‘over’, ‘pick’, ‘rot’, および ‘roll’ を実装するのも簡単
です。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Round-robin_scheduling


File: python.info,  Node: defaultdict オブジェクト,  Next: namedtuple 名前付きフィールドを持つタプルのファクトリ関数,  Prev: deque オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.6 ‘defaultdict’ オブジェクト
..................................

 -- クラス: collections.defaultdict (default_factory=None, /[, ...])

     新しい辞書に似たオブジェクトを返します。 *note defaultdict: 118d. は
     組み込みの *note dict: 237. クラスのサブクラスです。これはメソッド
     をひとつオーバーライドし、書き込み可能なインスタンス変数をひとつ追
     加しています。それ以外の機能は *note dict: 237. クラスと同じですの
     で、ここでは説明しません。

     1つ目の引数は *note default_factory: 246a. 属性の初期値です。デフォ
     ルトは ‘None’ です。残りの引数はキーワード引数も含め、 *note dict:
     237. のコンストラクタに与えられた場合と同様に扱われます。

     *note defaultdict: 118d. オブジェクトは標準の *note dict: 237. に加
     えて、以下のメソッドを実装しています:

      -- メソッド: __missing__ (key)

          もし *note default_factory: 246a. 属性が ‘None’ であれば、この
          メソッドは *note KeyError: 31d. 例外を、 'key' を引数として発
          生させます。

          もし *note default_factory: 246a. 属性が ‘None’ でない場合、こ
          のメソッドは引数なしで呼び出され、与えらえた 'key' に対応する
          デフォルト値を提供します。この値は、辞書内に 'key' に対応して
          登録され、最後に返されます。

          もし *note default_factory: 246a. の呼出が例外を発生させた場合
          には、変更せずそのまま例外を投げます。

          このメソッドは *note dict: 237. クラスの *note __getitem__():
          264. メソッドで、キーが存在しなかった場合によびだされます。値
          を返すか例外を発生させるのどちらにしても、 *note
          __getitem__(): 264. からもそのまま値が返るか例外が発生します。

          なお、 *note __missing__(): 246b. は *note __getitem__(): 264.
          以外のいかなる演算に対しても呼び出され 'ません' 。よって
          ‘get()’ は、普通の辞書と同様に、 *note default_factory: 246a.
          を使うのではなくデフォルトとして ‘None’ を返します。

     *note defaultdict: 118d. オブジェクトは以下のインスタンス変数をサポ
     ートしています:

      -- の属性: default_factory

          この属性は *note __missing__(): 246b. メソッドによって使われま
          す。これは存在すればコンストラクタの第1引数によって初期化され
          、そうでなければ ‘None’ になります。

     バージョン 3.9 で変更: PEP 584(1) で規定されている合成演算子 (‘|’)
     と更新演算子 (‘|=’)が追加されました。

* Menu:

* defaultdict の使用例::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0584/


File: python.info,  Node: defaultdict の使用例,  Up: defaultdict オブジェクト

5.8.4.7 ‘defaultdict’ の使用例
..............................

*note list: 5dc. を *note default_factory: 246a. とすることで、キー=値ペ
アのシーケンスをリストの辞書へ簡単にグループ化できます。:

     >>> s = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]
     >>> d = defaultdict(list)
     >>> for k, v in s:
     ...     d[k].append(v)
     ...
     >>> sorted(d.items())
     [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]

それぞれのキーが最初に登場したとき、マッピングにはまだ存在しません。その
ためエントリは *note default_factory: 246a. 関数が返す空の *note list:
5dc. を使って自動的に作成されます。 ‘list.append()’ 操作は新しいリストに
紐付けられます。キーが再度出現した場合には、通常の参照動作が行われます
(そのキーに対応するリストが返ります)。そして ‘list.append()’ 操作で別の
値をリストに追加します。このテクニックは *note dict.setdefault(): 104e.
を使った等価なものよりシンプルで速いです:

     >>> d = {}
     >>> for k, v in s:
     ...     d.setdefault(k, []).append(v)
     ...
     >>> sorted(d.items())
     [('blue', [2, 4]), ('red', [1]), ('yellow', [1, 3])]

*note default_factory: 246a. を *note int: 238. にすると、 *note
defaultdict: 118d. を(他の言語の bag や multisetのように)要素の数え上げ
に便利に使うことができます:

     >>> s = 'mississippi'
     >>> d = defaultdict(int)
     >>> for k in s:
     ...     d[k] += 1
     ...
     >>> sorted(d.items())
     [('i', 4), ('m', 1), ('p', 2), ('s', 4)]

最初に文字が出現したときは、マッピングが存在しないので *note
default_factory: 246a. 関数が *note int(): 238. を呼んでデフォルトのカウ
ント0を生成します。インクリメント操作が各文字を数え上げます。

常に0を返す *note int(): 238. は特殊な関数でした。定数を生成するより速く
て柔軟な方法は、 0に限らず何でも定数を生成するラムダ関数を使うことです:

     >>> def constant_factory(value):
     ...     return lambda: value
     ...
     >>> d = defaultdict(constant_factory('<missing>'))
     >>> d.update(name='John', action='ran')
     >>> '%(name)s %(action)s to %(object)s' % d
     'John ran to <missing>'

*note default_factory: 246a. を *note set: 5a3. に設定することで、 *note
defaultdict: 118d. をセットの辞書を作るために利用することができます:

     >>> s = [('red', 1), ('blue', 2), ('red', 3), ('blue', 4), ('red', 1), ('blue', 4)]
     >>> d = defaultdict(set)
     >>> for k, v in s:
     ...     d[k].add(v)
     ...
     >>> sorted(d.items())
     [('blue', {2, 4}), ('red', {1, 3})]


File: python.info,  Node: namedtuple 名前付きフィールドを持つタプルのファクトリ関数,  Next: OrderedDict オブジェクト,  Prev: defaultdict オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.8 ‘namedtuple()’ 名前付きフィールドを持つタプルのファクトリ関数
.....................................................................

名前付きタプルは、タプルの中のすべての場所に意味を割り当てて、より読みや
すく自己解説的なコードを書けるようにします。通常のタプルが利用される場所
ならどこでも利用でき、場所に対するインデックスの代わりに名前を使ってフィ
ールドにアクセスできるようになります。

 -- の関数: collections.namedtuple (typename, field_names, *,
          rename=False, defaults=None, module=None)

     'typename' という名前の tuple の新しいサブクラスを返します。新しい
     サブクラスは、 tuple に似ているけれどもインデックスやイテレータだけ
     でなく属性名によるアクセスもできるオブジェクトを作るのに使います。
     このサブクラスのインスタンスは、わかりやすい docstring (型名と属性
     名が入っています) や、 tuple の内容を ‘name=value’ という形のリスト
     で返す使いやすい ‘__repr__()’ も持っています。

     'field_names' は ‘['x', 'y']’ のような文字列のシーケンスです。
     'field_names' には、代わりに各属性名を空白文字 (whitespace) および
     /またはカンマ (,) で区切った文字列を渡すこともできます。例えば、
     ‘'x y'’ や ‘'x, y'’ です。

     アンダースコア (_) で始まる名前を除いて、 Python の正しい識別子
     (identifier) ならなんでも属性名として使うことができます。正しい識別
     子とはアルファベット(letters), 数字(digits), アンダースコア(_) を含
     みますが、数字やアンダースコアで始まる名前や、 'class', 'for',
     'return', 'global', 'pass', 'raise' などといった *note keyword: 78.
     は使えません。

     'rename' が真の場合、不適切なフィールド名は自動的に位置を示す名前に
     置き換えられます。例えば ‘['abc', 'def', 'ghi', 'abc']’ は、予約語
     の ‘def’ と、重複しているフィールド名の ‘abc’ が除去され、‘['abc',
     '_1', 'ghi', '_3']’ に変換されます。

     'defaults' には ‘None’ あるいはデフォルト値の *note iterable: 10ad.
     が指定できます。 デフォルト値を持つフィールドはデフォルト値を持たな
     いフィールドより後ろに来なければならないので、 'defaults' は最も右
     にある変数に適用されます。 例えば、 field_names が ‘['x', 'y',
     'z']’ で defaults が ‘(1, 2)’ の場合、 ‘x’ は必須の引数、 ‘y’ は
     ‘1’ がデフォルト、 ‘z’ は ‘2’ がデフォルトとなります。

     If 'module' is defined, the *note __module__: 34d. attribute of the
     named tuple is set to that value.

     名前付きタプルのインスタンスはインスタンスごとの辞書を持たないので
     、軽量で、普通のタプル以上のメモリを使用しません。

     pickle 化をサポートするには、名前付きタプルのクラス定義は
     'typename' と同じ名前の変数に割り当てなければなりません。

     バージョン 3.1 で変更: 'rename' のサポートが追加されました。

     バージョン 3.6 で変更: 'verbose' と 'rename' 引数が *note
     キーワード専用引数: 285. になりました.

     バージョン 3.6 で変更: 'module' 引数が追加されました。

     バージョン 3.7 で変更: 'verbose' 引数と ‘_source’ 属性が削除されま
     した。

     バージョン 3.7 で変更: 'defaults' 引数と ‘_field_defaults’ 属性が追
     加されました。

     >>> # Basic example
     >>> Point = namedtuple('Point', ['x', 'y'])
     >>> p = Point(11, y=22)     # instantiate with positional or keyword arguments
     >>> p[0] + p[1]             # indexable like the plain tuple (11, 22)
     33
     >>> x, y = p                # unpack like a regular tuple
     >>> x, y
     (11, 22)
     >>> p.x + p.y               # fields also accessible by name
     33
     >>> p                       # readable __repr__ with a name=value style
     Point(x=11, y=22)

名前付きタプルは *note csv: 21. や *note sqlite3: ba. モジュールが返すタ
プルのフィールドに名前を付けるときにとても便利です:

     EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')

     import csv
     for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv", "rb"))):
         print(emp.name, emp.title)

     import sqlite3
     conn = sqlite3.connect('/companydata')
     cursor = conn.cursor()
     cursor.execute('SELECT name, age, title, department, paygrade FROM employees')
     for emp in map(EmployeeRecord._make, cursor.fetchall()):
         print(emp.name, emp.title)

タプルから継承したメソッドに加えて、名前付きタプルは3つの追加メソッドと
2つの属性をサポートしています。フィールド名との衝突を避けるために、メソ
ッド名と属性名はアンダースコアで始まります。

 -- メソッド: classmethod somenamedtuple._make (iterable)

     既存の sequence や Iterable から新しいインスタンスを作るクラスメソ
     ッド.

          >>> t = [11, 22]
          >>> Point._make(t)
          Point(x=11, y=22)

 -- メソッド: somenamedtuple._asdict ()

     フィールド名を対応する値にマッピングする新しい *note dict: 237. を
     返します:

          >>> p = Point(x=11, y=22)
          >>> p._asdict()
          {'x': 11, 'y': 22}

     バージョン 3.1 で変更: 通常の *note dict: 237. の代わりに *note
     OrderedDict: 5a5. を返すようになりました。

     バージョン 3.8 で変更: *note collections.OrderedDict: 5a5. ではなく
     *note dict: 237. を返すようになりました。Python 3.7以降は、通常の辞
     書で順番が保証されています。 *note OrderedDict: 5a5. 特有の機能を使
     いたい場合は、結果を ‘OrderedDict(nt._asdict())’ 型にキャストして使
     用することを推奨します。

 -- メソッド: somenamedtuple._replace (**kwargs)

     指定されたフィールドを新しい値で置き換えた、新しい名前付きタプルを
     作って返します:

          >>> p = Point(x=11, y=22)
          >>> p._replace(x=33)
          Point(x=33, y=22)

          >>> for partnum, record in inventory.items():
          ...     inventory[partnum] = record._replace(price=newprices[partnum], timestamp=time.now())

     名前付きタプルは汎用的な関数 *note copy.replace(): 137. にもサポー
     トされています。

     バージョン 3.13 で変更: キーワード引数が無効な場合は *note
     ValueError: 1e3. のかわりに *note TypeError: 502. が発生します。

 -- の属性: somenamedtuple._fields

     フィールド名をリストにしたタプルです。内省 (introspection) したり、
     既存の名前付きタプルをもとに新しい名前つきタプルを作成する時に便利
     です。

          >>> p._fields            # view the field names
          ('x', 'y')

          >>> Color = namedtuple('Color', 'red green blue')
          >>> Pixel = namedtuple('Pixel', Point._fields + Color._fields)
          >>> Pixel(11, 22, 128, 255, 0)
          Pixel(x=11, y=22, red=128, green=255, blue=0)

 -- の属性: somenamedtuple._field_defaults

     フィールド名からデフォルト値への対応を持つ辞書です。

          >>> Account = namedtuple('Account', ['type', 'balance'], defaults=[0])
          >>> Account._field_defaults
          {'balance': 0}
          >>> Account('premium')
          Account(type='premium', balance=0)

文字列に格納された名前を使って名前つきタプルから値を取得するには *note
getattr(): b9f. 関数を使います:

     >>> getattr(p, 'x')
     11

辞書を名前付きタプルに変換するには、 ‘**’ 演算子 (double-star-operator,
*note 引数リストのアンパック: 1b99. で説明しています) を使います。:

     >>> d = {'x': 11, 'y': 22}
     >>> Point(**d)
     Point(x=11, y=22)

名前付きタプルは通常の Python クラスなので、継承して機能を追加したり変更
するのは容易です。次の例では計算済みフィールドと固定幅の print format を
追加しています:

     >>> class Point(namedtuple('Point', ['x', 'y'])):
     ...     __slots__ = ()
     ...     @property
     ...     def hypot(self):
     ...         return (self.x ** 2 + self.y ** 2) ** 0.5
     ...     def __str__(self):
     ...         return 'Point: x=%6.3f  y=%6.3f  hypot=%6.3f' % (self.x, self.y, self.hypot)

     >>> for p in Point(3, 4), Point(14, 5/7):
     ...     print(p)
     Point: x= 3.000  y= 4.000  hypot= 5.000
     Point: x=14.000  y= 0.714  hypot=14.018

このサブクラスは ‘__slots__’ に空のタプルをセットしています。これにより
、インスタンス辞書の作成を抑制してメモリ使用量を低く保つのに役立ちます。

サブクラス化は新しいフィールドを追加するのには適していません。代わりに、
新しい名前付きタプルを *note _fields: 2470. 属性を元に作成してください:

     >>> Point3D = namedtuple('Point3D', Point._fields + ('z',))

‘__doc__’ フィールドに直接代入することでドックストリングをカスタマイズす
ることが出来ます:

     >>> Book = namedtuple('Book', ['id', 'title', 'authors'])
     >>> Book.__doc__ += ': Hardcover book in active collection'
     >>> Book.id.__doc__ = '13-digit ISBN'
     >>> Book.title.__doc__ = 'Title of first printing'
     >>> Book.authors.__doc__ = 'List of authors sorted by last name'

バージョン 3.5 で変更: 属性ドックストリングが書き込み可能になりました。

参考
....

   * 名前付きタプルに型ヒントを追加する方法については、 *note
     typing.NamedTuple: 290. を参照してください。 *note class: 12a5. キ
     ーワードを使った洗練された記法も紹介されています:

          class Component(NamedTuple):
              part_number: int
              weight: float
              description: Optional[str] = None

   * タプルではなく、辞書をもとにした変更可能な名前空間を作成するには
     *note types.SimpleNamespace(): 1b3. を参照してください。

   * *note dataclasses: 27. モジュールは、生成される特殊メソッドをユーザ
     ー定義クラスに自動的に追加するためのデコレータや関数を提供していま
     す。


File: python.info,  Node: OrderedDict オブジェクト,  Next: UserDict オブジェクト,  Prev: namedtuple 名前付きフィールドを持つタプルのファクトリ関数,  Up: collections --- コンテナデータ型

5.8.4.9 ‘OrderedDict’ オブジェクト
..................................

順序付き辞書は普通の辞書のようですが、順序操作に関係する追加の機能があり
ます。 組み込みの *note dict: 237. クラスが挿入順序を記憶しておく機能 (こ
の新しい振る舞いは Python 3.7 で保証されるようになりました) を獲得した今
となっては、順序付き辞書の重要性は薄れました。

いまだ残っている *note dict: 237. との差分:

   * 通常の *note dict: 237. は対応付けに向いているように設計されました
     。 挿入順序の追跡は二の次です。

   * *note OrderedDict: 5a5. は並べ替え操作に向いているように設計されま
     した。 空間効率、反復処理の速度、更新操作のパフォーマンスは二の次で
     す。

   * *note OrderedDict: 5a5. のアルゴリズムは、頻繁な並べ替え処理を
     *note dict: 237. よりもうまく扱うことができます。後述のレシピに示さ
     れている通り、この性質はさまざまな種類の LRU キャッシュの実装に適し
     ています。

   * *note OrderedDict: 5a5. に対する等価演算は突き合わせ順序もチェック
     します。

     組み込みの *note dict: 237. では、順序を考慮した等価演算は ‘p == q
     and all(k1 == k2 for k1, k2 in zip(p, q))’ で実現することができます
     。

   * *note OrderedDict: 5a5. の ‘popitem()’ メソッドはシグネチャが異なり
     ます。 どの要素を取り出すかを指定するオプション引数を受け付けます。

     組み込みの *note dict: 237. の場合、 OrderedDict の
     ‘od.popitem(last=True)’ と同じ機能は、最も右側の (最後の) 要素を取
     り出すことが保証されている ‘d.popitem()’ が果たします。

     組み込みの *note dict: 237. の場合、 OrderedDict の
     ‘od.popitem(last=False)’ は ‘(k := next(iter(d)), d.pop(k))’ で実現
     できます。これにより、該当する要素のうちで最も左側の (先頭の) もの
     を辞書から削除して返すことができます。

   * *note OrderedDict: 5a5. には、 効率的に要素を末尾に置き直す
     ‘move_to_end()’ メソッドがあります。

     組み込みの *note dict: 237. の場合、キーと値のペアを最も右側 (末尾)
     に移動する OrderedDict の ‘od.move_to_end(k, last=True)’ は ‘d[k] =
     d.pop(k)’ で実現できます。

     組み込みの *note dict: 237. では、キーと値のペアを最も左側 (先頭) に
     移動する OrderedDict の ‘od.move_to_end(k, last=False)’ を実現する
     効率の良い方法はありません。

   * Python 3.8 以前は、 *note dict: 237. には ‘__reversed__()’ メソッド
     が欠けています。

 -- クラス: collections.OrderedDict ([items])

     辞書の順序を並べ直すためのメソッドを持つ *note dict: 237. のサブク
     ラスのインスタンスを返します。

     Added in version 3.1.

      -- メソッド: popitem (last=True)

          順序付き辞書の *note popitem(): 12bb. メソッドは、(key, value)
          対を返して消去します。この対は 'last' が真なら LIFO で、偽なら
          FIFO (first-in, first-out, 先入先出) で返されます。

      -- メソッド: move_to_end (key, last=True)

          存在する 'key' を順序付き辞書の先頭または末尾に移動します。要
          素は 'last' が真 (デフォルト) の場合に最も右側すなわち末尾に移
          動します。また 'last' が偽の場合には先頭に移動します。指定した
          'key' が存在しない場合は *note KeyError: 31d. を送出します。

               >>> d = OrderedDict.fromkeys('abcde')
               >>> d.move_to_end('b')
               >>> ''.join(d)
               'acdeb'
               >>> d.move_to_end('b', last=False)
               >>> ''.join(d)
               'bacde'

          Added in version 3.2.

通常のマッピングのメソッドに加え、順序付き辞書は *note reversed(): 831.
による逆順の反復もサポートしています。 Equality tests between *note
OrderedDict: 5a5. objects are order-sensitive and are roughly equivalent
to ‘list(od1.items())==list(od2.items())’.

Equality tests between *note OrderedDict: 5a5. objects and other *note
Mapping: 898. objects are order-insensitive like regular dictionaries.
This allows *note OrderedDict: 5a5. objects to be substituted anywhere a
regular dictionary is used.

バージョン 3.5 で変更: *note OrderedDict: 5a5. の項目、キー、値の *note
ビュー: 2473. が *note reversed(): 831. による逆順の反復をサポートするよ
うになりました。

バージョン 3.6 で変更: PEP 468(1) の受理によって、*note OrderedDict:
5a5. のコンストラクタと、‘update()’ メソッドに渡したキーワード引数の順序
は保持されます。

バージョン 3.9 で変更: PEP 584(2) で規定されている合成演算子 (‘|’) と更
新演算子 (‘|=’)が追加されました。

* Menu:

* OrderedDict の例とレシピ::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0468/

   (2) https://peps.python.org/pep-0584/


File: python.info,  Node: OrderedDict の例とレシピ,  Up: OrderedDict オブジェクト

5.8.4.10 ‘OrderedDict’ の例とレシピ
...................................

キーが '最後に' 追加されたときの順序を記憶する、順序付き辞書の変種を作る
のは簡単です。 新しい値が既存の値を上書きする場合、元々の挿入位置が最後
尾へ変更されます:

     class LastUpdatedOrderedDict(OrderedDict):
         'Store items in the order the keys were last added'

         def __setitem__(self, key, value):
             super().__setitem__(key, value)
             self.move_to_end(key)

*note OrderedDict: 5a5. は *note functools.lru_cache(): 9bd. の変種を実
装するのにも役に立ちます:

     from collections import OrderedDict
     from time import time

     class TimeBoundedLRU:
         "LRU Cache that invalidates and refreshes old entries."

         def __init__(self, func, maxsize=128, maxage=30):
             self.cache = OrderedDict()      # { args : (timestamp, result)}
             self.func = func
             self.maxsize = maxsize
             self.maxage = maxage

         def __call__(self, *args):
             if args in self.cache:
                 self.cache.move_to_end(args)
                 timestamp, result = self.cache[args]
                 if time() - timestamp <= self.maxage:
                     return result
             result = self.func(*args)
             self.cache[args] = time(), result
             if len(self.cache) > self.maxsize:
                 self.cache.popitem(last=False)
             return result

     class MultiHitLRUCache:
         """ LRU cache that defers caching a result until
             it has been requested multiple times.

             To avoid flushing the LRU cache with one-time requests,
             we don't cache until a request has been made more than once.

         """

         def __init__(self, func, maxsize=128, maxrequests=4096, cache_after=1):
             self.requests = OrderedDict()   # { uncached_key : request_count }
             self.cache = OrderedDict()      # { cached_key : function_result }
             self.func = func
             self.maxrequests = maxrequests  # max number of uncached requests
             self.maxsize = maxsize          # max number of stored return values
             self.cache_after = cache_after

         def __call__(self, *args):
             if args in self.cache:
                 self.cache.move_to_end(args)
                 return self.cache[args]
             result = self.func(*args)
             self.requests[args] = self.requests.get(args, 0) + 1
             if self.requests[args] <= self.cache_after:
                 self.requests.move_to_end(args)
                 if len(self.requests) > self.maxrequests:
                     self.requests.popitem(last=False)
             else:
                 self.requests.pop(args, None)
                 self.cache[args] = result
                 if len(self.cache) > self.maxsize:
                     self.cache.popitem(last=False)
             return result


File: python.info,  Node: UserDict オブジェクト,  Next: UserList オブジェクト,  Prev: OrderedDict オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.11 ‘UserDict’ オブジェクト
................................

クラス *note UserDict: 18ff. は、辞書オブジェクトのラッパとしてはたらき
ます。このクラスの必要性は、 *note dict: 237. から直接的にサブクラス化で
きる能力に部分的に取って代わられました; しかし、根底の辞書に属性としてア
クセスできるので、このクラスを使った方が簡単になることもあります。

 -- クラス: collections.UserDict ([initialdata])

     辞書をシミュレートするクラスです。インスタンスの内容は通常の辞書に
     保存され、 *note UserDict: 18ff. インスタンスの *note data: 2476. 属
     性を通してアクセスできます。 'initialdata' が与えられれば、 *note
     data: 2476. はその内容で初期化されます。他の目的のために使えるよう
     に、 'initialdata' への参照が保存されないことに注意してください。

     マッピングのメソッドと演算をサポートするのに加え、 *note UserDict:
     18ff. インスタンスは以下の属性を提供します:

      -- の属性: data

          *note UserDict: 18ff. クラスの内容を保存するために使われる実際
          の辞書です。


File: python.info,  Node: UserList オブジェクト,  Next: UserString オブジェクト,  Prev: UserDict オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.12 ‘UserList’ オブジェクト
................................

このクラスはリストオブジェクトのラッパとしてはたらきます。これは独自のリ
スト風クラスの基底クラスとして便利で、既存のメソッドをオーバーライドした
り新しいメソッドを加えたりできます。こうして、リストに新しい振る舞いを加
えられます。

このクラスの必要性は、 *note list: 5dc. から直接的にサブクラス化できる能
力に部分的に取って代わられました; しかし、根底のリストに属性としてアクセ
スできるので、このクラスを使った方が簡単になることもあります。

 -- クラス: collections.UserList ([list])

     リストをシミュレートするクラスです。インスタンスの内容は通常のリス
     トに保存され、 *note UserList: 148c. インスタンスの *note data:
     2478. 属性を通してアクセスできます。インスタンスの内容は最初に
     'list' のコピーに設定されますが、デフォルトでは空リスト ‘[]’ です。
     'list' は何らかのイテラブル、例えば通常の Python リストや *note
     UserList: 148c. オブジェクト、です。

     ミュータブルシーケンスのメソッドと演算をサポートするのに加え、
     *note UserList: 148c. インスタンスは以下の属性を提供します:

      -- の属性: data

          *note UserList: 148c. クラスの内容を保存するために使われる実際
          の *note list: 5dc. オブジェクトです。

'サブクラス化の要件:' *note UserList: 148c. のサブクラスは引数なしか、あ
るいは一つの引数のどちらかとともに呼び出せるコンストラクタを提供すること
が期待されています。新しいシーケンスを返すリスト演算は現在の実装クラスの
インスタンスを作成しようとします。そのために、データ元として使われるシー
ケンスオブジェクトである一つのパラメータとともにコンストラクタを呼び出せ
ると想定しています。

派生クラスがこの要求に従いたくないならば、このクラスがサポートしているす
べての特殊メソッドはオーバーライドされる必要があります。その場合に提供さ
れる必要のあるメソッドについての情報は、ソースを参考にしてください。


File: python.info,  Node: UserString オブジェクト,  Prev: UserList オブジェクト,  Up: collections --- コンテナデータ型

5.8.4.13 ‘UserString’ オブジェクト
..................................

クラス *note UserString: da2. は、文字列オブジェクトのラッパとしてはたら
きます。このクラスの必要性は、 *note str: 418. から直接的にサブクラス化
できる能力に部分的に取って代わられました; しかし、根底の文字列に属性とし
てアクセスできるので、このクラスを使った方が簡単になることもあります。

 -- クラス: collections.UserString (seq)

     文字列オブジェクトをシミュレートするクラスです。 インスタンスの内容
     は通常の文字列に保存され、 *note UserString: da2. インスタンスの
     *note data: 247a. 属性を通してアクセスできます。 インスタンスの内容
     には最初に 'seq' のコピーが設定されます。 'seq' 引数は、組み込みの
     *note str(): 418. 関数で文字列に変換できる任意のオブジェクトです。

     文字列のメソッドと演算をサポートするのに加え、 *note UserString:
     da2. インスタンスは次の属性を提供します:

      -- の属性: data

          *note UserString: da2. クラスの内容を保存するために使われる実
          際の *note str: 418. オブジェクトです。

     バージョン 3.5 で変更: 新たなメソッド ‘__getnewargs__’, ‘__rmod__’,
     ‘casefold’, ‘format_map’, ‘isprintable’, ‘maketrans’。


File: python.info,  Node: collections abc --- コンテナの抽象基底クラス,  Next: heapq --- ヒープキューアルゴリズム,  Prev: collections --- コンテナデータ型,  Up: データ型

5.8.5 ‘collections.abc’ -- コンテナの抽象基底クラス
---------------------------------------------------

Added in version 3.3: 以前はこのモジュールは *note collections: 16. モジ
ュールの一部でした。

'ソースコード:' Lib/_collections_abc.py(1)

__________________________________________________________________

このモジュールは、 *note 抽象基底クラス: 1186. を提供します。抽象基底ク
ラスは、クラスが特定のインターフェースを提供しているか、例えば *note
ハッシュ可能: 5db. であるかや *note マッピング: 118c. であるかを判定しま
す。

*note issubclass(): 78c. や *note isinstance(): 40e. を使ったインターフ
ェースに対するテストは、以下の3つのいずれかの方法で動作します。

1） 新しく定義したクラスは抽象基底クラスのいずれかを直接継承することがで
きます。その場合クラスは必要な抽象メソッドを提供しなければなりません。残
りのミックスインメソッドは継承により引き継がれますが、必要ならオーバーラ
イドすることができます。その他のメソッドは必要に応じて追加することができ
ます:

     class C(Sequence):                      # Direct inheritance
         def __init__(self): ...             # Extra method not required by the ABC
         def __getitem__(self, index):  ...  # Required abstract method
         def __len__(self):  ...             # Required abstract method
         def count(self, value): ...         # Optionally override a mixin method

     >>> issubclass(C, Sequence)
     True
     >>> isinstance(C(), Sequence)
     True

2） 既存のクラスや組み込みのクラスを "仮想派生クラス" として ABC に登録
することができます。これらのクラスは、全ての抽象メソッドとミックスインメ
ソッドを含む完全な API を定義する必要があります。これにより、そのクラス
が完全なインターフェースをサポートしているかどうかを、ユーザーが *note
issubclass(): 78c. や *note isinstance(): 40e. で判断できるようになりま
す。このルールの例外は、残りの API から自動的に推測ができるようなメソッ
ドです:

     class D:                                 # No inheritance
         def __init__(self): ...              # Extra method not required by the ABC
         def __getitem__(self, index):  ...   # Abstract method
         def __len__(self):  ...              # Abstract method
         def count(self, value): ...          # Mixin method
         def index(self, value): ...          # Mixin method

     Sequence.register(D)                     # Register instead of inherit

     >>> issubclass(D, Sequence)
     True
     >>> isinstance(D(), Sequence)
     True

この例では、クラス ‘D’ は ‘__contains__’, ‘__iter__’, ‘__reversed__’ を
定義する必要がありません。なぜなら *note in 演算子: 1fd1, the *note
反復: 10ad. ロジック, および *note reversed(): 831. 関数は自動的に
‘__getitem__’ と ‘__len__’ を使うようにフォールバックするからです。

3） いくつかの単純なインターフェースは、必要なメソッドの存在だけで (それ
らのメソッドが *note None: 641. に設定されていなければ) 直接認識されます
:

     class E:
         def __iter__(self): ...
         def __next__(self): ...

     >>> issubclass(E, Iterable)
     True
     >>> isinstance(E(), Iterable)
     True

複雑なインターフェースは、単に特定のメソッドが存在すること以上の定義を持
つため、3番目のテクニックをサポートしていません。それらのインターフェー
スはメソッドの意味やメソッド間の関係まで指定するので、特定のメソッド名の
存在からだけではインターフェースの推測ができません。たとえば、あるクラス
が ‘__getitem__’, ‘__len__’, および ‘__iter__’ を提供するというだけでは
、 *note Sequence: 1194. と *note Mapping: 898. を区別するには不十分です
。

Added in version 3.9: これらの抽象クラスは ‘[]’ をサポートするようになり
ました。 *note ジェネリックエイリアス型: 67e. および PEP 585(2) を参照し
てください。

* Menu:

* コレクション抽象基底クラス::
* コレクションの抽象基底クラス: コレクションの抽象基底クラス -- 詳細な説明. 詳細な説明
* 例とレシピ::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/_collections_abc.py

   (2) https://peps.python.org/pep-0585/


File: python.info,  Node: コレクション抽象基底クラス,  Next: コレクションの抽象基底クラス -- 詳細な説明,  Up: collections abc --- コンテナの抽象基底クラス

5.8.5.1 コレクション抽象基底クラス
..................................

collections モジュールは以下の *note ABC (抽象基底クラス): 1186. を提供
します:

ABC                                継承しているクラス         抽象メソッド                mixin メソッド
                                                                                          
---------------------------------------------------------------------------------------------------------------------------------------------------
                                                                                          
*note Container: 21ad. (1)                                    ‘__contains__’
                                                              
                                                                                          
*note Hashable: 4c2. (2)                                      ‘__hash__’
                                                              
                                                                                          
*note Iterable: 21ab. (3) (4)                                 ‘__iter__’
                                                              
                                                                                          
*note Iterator: 21ac. (5)          *note Iterable: 21ab.      ‘__next__’                  ‘__iter__’
                                                                                          
                                                                                          
*note Reversible: c57. (6)         *note Iterable: 21ab.      ‘__reversed__’
                                                              
                                                                                          
*note Generator: da8. (7)          *note Iterator: 21ac.      ‘send’, ‘throw’             ‘close’, ‘__iter__’, ‘__next__’
                                                                                          
                                                                                          
*note Sized: 4c3. (8)                                         ‘__len__’
                                                              
                                                                                          
*note Callable: 7b5. (9)                                      ‘__call__’
                                                              
                                                                                          
*note Collection: c56. (10)        *note Sized: 4c3,          ‘__contains__’,
                                   *note Iterable: 21ab,      ‘__iter__’, ‘__len__’
                                   *note Container: 21ad.     
                                   
                                                                                          
*note Sequence: 1194.              *note Reversible: c57,     ‘__getitem__’, ‘__len__’    ‘__contains__’, ‘__iter__’, ‘__reversed__’, ‘index’,
                                   *note Collection: c56.                                 ‘count’
                                                                                          
                                                                                          
*note MutableSequence: 186.        *note Sequence: 1194.      ‘__getitem__’,              *note Sequence: 1194. から継承したメソッドと、
                                                              ‘__setitem__’,              ‘append’, ‘clear’, ‘reverse’, ‘extend’, ‘pop’,
                                                              ‘__delitem__’, ‘__len__’,   ‘remove’, ‘__iadd__’
                                                              ‘insert’                    
                                                              
                                                                                          
*note ByteString: 2a3.             *note Sequence: 1194.      ‘__getitem__’, ‘__len__’    *note Sequence: 1194. から継承したメソッド
                                                                                          
                                                                                          
*note Set: 21a3.                   *note Collection: c56.     ‘__contains__’,             ‘__le__’, ‘__lt__’, ‘__eq__’, ‘__ne__’, ‘__gt__’,
                                                              ‘__iter__’, ‘__len__’       ‘__ge__’, ‘__and__’, ‘__or__’, ‘__sub__’, ‘__xor__’,
                                                                                          ‘isdisjoint’
                                                                                          
                                                                                          
*note MutableSet: 21ae.            *note Set: 21a3.           ‘__contains__’,             *note Set: 21a3. から継承したメソッドと、 ‘clear’,
                                                              ‘__iter__’, ‘__len__’,      ‘pop’, ‘remove’, ‘__ior__’, ‘__iand__’, ‘__ixor__’,
                                                              ‘add’, ‘discard’            ‘__isub__’
                                                                                          
                                                                                          
*note Mapping: 898.                *note Collection: c56.     ‘__getitem__’,              ‘__contains__’, ‘keys’, ‘items’, ‘values’, ‘get’,
                                                              ‘__iter__’, ‘__len__’       ‘__eq__’, ‘__ne__’
                                                                                          
                                                                                          
*note MutableMapping: 107e.        *note Mapping: 898.        ‘__getitem__’,              *note Mapping: 898. から継承したメソッドと、 ‘pop’,
                                                              ‘__setitem__’,              ‘popitem’, ‘clear’, ‘update’, ‘setdefault’
                                                              ‘__delitem__’,              
                                                              ‘__iter__’, ‘__len__’
                                                              
                                                                                          
*note MappingView: 21af.           *note Sized: 4c3.                                      ‘__len__’
                                                                                          
                                                                                          
*note ItemsView: 21b1.             *note MappingView: 21af,                               ‘__contains__’, ‘__iter__’
                                   *note Set: 21a3.                                       
                                   
                                                                                          
*note KeysView: 21b0.              *note MappingView: 21af,                               ‘__contains__’, ‘__iter__’
                                   *note Set: 21a3.                                       
                                   
                                                                                          
*note ValuesView: 21b2.            *note MappingView: 21af,                               ‘__contains__’, ‘__iter__’
                                   *note Collection: c56.                                 
                                   
                                                                                          
*note Awaitable: da9. (11)                                    ‘__await__’
                                                              
                                                                                          
*note Coroutine: daa. (12)         *note Awaitable: da9.      ‘send’, ‘throw’             ‘close’
                                                                                          
                                                                                          
*note AsyncIterable: dac. (13)                                ‘__aiter__’
                                                              
                                                                                          
*note AsyncIterator: dab. (14)     *note AsyncIterable: dac.  ‘__anext__’                 ‘__aiter__’
                                                                                          
                                                                                          
*note AsyncGenerator: c58. (15)    *note AsyncIterator: dab.  ‘asend’, ‘athrow’           ‘aclose’, ‘__aiter__’, ‘__anext__’
                                                                                          
                                                                                          
*note Buffer: 2a4. (16)                                       ‘__buffer__’
                                                              

脚注
....

   ---------- Footnotes ----------

   (1) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (2) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (3) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (4) ‘isinstance(obj, Iterable)’ によるチェックは *note Iterable:
21ab. として登録されたクラスや *note __iter__(): 1c2b. メソッドを持つク
ラスを検出しますが、 *note __getitem__(): 264. メソッドにより反復処理を
行うクラスは検出しません。オブジェクトがイテラブル (*note iterable:
10ad.) かどうかを確認する唯一の信頼できる方法は ‘iter(obj)’ を呼び出すこ
とです。

   (5) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (6) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (7) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (8) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (9) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオーバ
ーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定されて
いないことを確かめることによってインターフェースをテストすることをサポー
トします。このテストは単純なインターフェースに対してのみ有効に働きます。
より複雑なインターフェースは基底クラスへの登録や直接派生することが必要に
なります。

   (10) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオー
バーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定され
ていないことを確かめることによってインターフェースをテストすることをサポ
ートします。このテストは単純なインターフェースに対してのみ有効に働きます
。より複雑なインターフェースは基底クラスへの登録や直接派生することが必要
になります。

   (11) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオー
バーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定され
ていないことを確かめることによってインターフェースをテストすることをサポ
ートします。このテストは単純なインターフェースに対してのみ有効に働きます
。より複雑なインターフェースは基底クラスへの登録や直接派生することが必要
になります。

   (12) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオー
バーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定され
ていないことを確かめることによってインターフェースをテストすることをサポ
ートします。このテストは単純なインターフェースに対してのみ有効に働きます
。より複雑なインターフェースは基底クラスへの登録や直接派生することが必要
になります。

   (13) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオー
バーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定され
ていないことを確かめることによってインターフェースをテストすることをサポ
ートします。このテストは単純なインターフェースに対してのみ有効に働きます
。より複雑なインターフェースは基底クラスへの登録や直接派生することが必要
になります。

   (14) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオー
バーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定され
ていないことを確かめることによってインターフェースをテストすることをサポ
ートします。このテストは単純なインターフェースに対してのみ有効に働きます
。より複雑なインターフェースは基底クラスへの登録や直接派生することが必要
になります。

   (15) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオー
バーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定され
ていないことを確かめることによってインターフェースをテストすることをサポ
ートします。このテストは単純なインターフェースに対してのみ有効に働きます
。より複雑なインターフェースは基底クラスへの登録や直接派生することが必要
になります。

   (16) これらの抽象基底クラスは *note __subclasshook__(): 247e. をオー
バーライドして、必要なメソッドが存在し、かつ *note None: 641. に指定され
ていないことを確かめることによってインターフェースをテストすることをサポ
ートします。このテストは単純なインターフェースに対してのみ有効に働きます
。より複雑なインターフェースは基底クラスへの登録や直接派生することが必要
になります。


File: python.info,  Node: コレクションの抽象基底クラス -- 詳細な説明,  Next: 例とレシピ,  Prev: コレクション抽象基底クラス,  Up: collections abc --- コンテナの抽象基底クラス

5.8.5.2 コレクションの抽象基底クラス - 詳細な説明
.................................................

 -- クラス: collections.abc.Container

     *note __contains__(): 1ebe. メソッドを提供するクラスの ABC です。

 -- クラス: collections.abc.Hashable

     *note __hash__(): ac9. メソッドを提供するクラスの ABC です。

 -- クラス: collections.abc.Sized

     *note __len__(): 1ec3. メソッドを提供するクラスの ABC です。

 -- クラス: collections.abc.Callable

     *note __call__(): 523. メソッドを提供するクラスの ABC です。

     ‘Callable’ を型アノテーションで使う方法の詳細は、 *note
     呼び出し可能オブジェクトのアノテーション: 2480. を参照してください
     。

 -- クラス: collections.abc.Iterable

     *note __iter__(): 1c2b. メソッドを提供するクラスの ABC です。

     ‘isinstance(obj, Iterable)’ によるチェックは *note Iterable: 21ab.
     として登録されたクラスや *note __iter__(): 1c2b. メソッドを持つクラ
     スを検出しますが、 *note __getitem__(): 264. メソッドにより反復処理
     を行うクラスは検出しません。オブジェクトがイテラブル (*note
     iterable: 10ad.) かどうかを確認する唯一の信頼できる方法は
     ‘iter(obj)’ を呼び出すことです。

 -- クラス: collections.abc.Collection

     サイズ付きのイテラブルなコンテナクラスの ABC です。

     Added in version 3.6.

 -- クラス: collections.abc.Iterator

     *note __iter__(): 1c2e. メソッドと *note __next__(): 129b. メソッド
     を提供するクラスの ABC です。 *note iterator: 191. の定義も参照して
     ください。

 -- クラス: collections.abc.Reversible

     *note __reversed__(): 1ebd. メソッドを提供するイテラブルクラスの
     ABC です。

     Added in version 3.6.

 -- クラス: collections.abc.Generator

     PEP 342(1) で定義された、*note イテレータ: 191. を *note send():
     1036, *note throw(): 4c5, *note close(): 1659. の各メソッドに拡張す
     るプロトコルを実装する、*note ジェネレータ: 1035. クラスの ABC です
     。

     ‘Generator’ を型アノテーションで使う方法の詳細は、 *note Annotating
     generators and coroutines: 2481. を参照してください。

     Added in version 3.5.

 -- クラス: collections.abc.Sequence
 -- クラス: collections.abc.MutableSequence
 -- クラス: collections.abc.ByteString

     読み出し専用の *note シーケンス: 4be. およびミュータブルな *note
     シーケンス: 4be. の ABC です。

     実装における注意: *note __iter__(): 1c2b, *note __reversed__():
     1ebd, ‘index()’ など、一部の mixin メソッドは、下層の *note
     __getitem__(): 264. メソッドを繰り返し呼び出します。その結果、*note
     __getitem__(): 264. が定数のアクセス速度で実装されている場合、mixin
     メソッドは線形のパフォーマンスとなります。下層のメソッドが線形 (リ
     ンクされたリストの場合など) の場合、mixin は 2 乗のパフォーマンスと
     なるため、多くの場合上書きする必要があるでしょう。

     バージョン 3.5 で変更: index() メソッドは 'stop' と 'start' 引数を
     サポートしました。

     Deprecated since version 3.12, will be removed in version 3.14:
     ABCの *note ByteString: 2a3. は非推奨になりました。型ヒントでは
     ‘bytes | bytearray’ のようなユニオン型または *note
     collections.abc.Buffer: 2a4. を使用してください。ABCとしての場合は
     *note Sequence: 1194. または *note collections.abc.Buffer: 2a4. を
     使用してください。

 -- クラス: collections.abc.Set
 -- クラス: collections.abc.MutableSet

     読み出し専用でミュータブルな *note 集合: 20d7. の ABC です。

 -- クラス: collections.abc.Mapping
 -- クラス: collections.abc.MutableMapping

     読み出し専用の *note マッピング: 118c. およびミュータブルな *note
     マッピング: 118c. の ABC です。

 -- クラス: collections.abc.MappingView
 -- クラス: collections.abc.ItemsView
 -- クラス: collections.abc.KeysView
 -- クラス: collections.abc.ValuesView

     マッピング、要素、キー、値の *note ビュー: 2473. の ABC です。

 -- クラス: collections.abc.Awaitable

     *note await: 19e. で使用できる *note awaitable: 192. オブジェクトの
     ABC です。カスタムの実装は、*note __await__(): 1f28. メソッドを提供
     しなければなりません。

     *note Coroutine: daa. ABC の *note Coroutine: 45e. オブジェクトとイ
     ンスタンスは、すべてこの ABC のインスタンスです。

          注釈: CPython では、ジェネレータベースのコルーチン (*note
          @types.coroutine: e53. で修飾された *note ジェネレータ: 1035.)
          は、 *note __await__(): 1f28. メソッドを持たないにもかかわらず
          *待機可能* ('awaitables') です。 ‘isinstance(gencoro,
          Awaitable)’ はそのようなコルーチンに対して ‘False’ を返します
          。そのようなコルーチンを検出するためには *note
          inspect.isawaitable(): de4. を使ってください。

     Added in version 3.5.

 -- クラス: collections.abc.Coroutine

     *note コルーチン: 45e. と互換性のあるクラスの ABC です。これらは、
     *note コルーチンオブジェクト: 1e68. で定義された *note send():
     1f2c, *note throw(): 4c4, *note close(): 1f2d. のメソッドを実装しま
     す。カスタムの実装は、*note __await__(): 1f28. も実装しなければなり
     ません。*note Coroutine: daa. のすべてのインスタンスは、 *note
     Awaitable: da9. のインスタンスでもあります。

          注釈: CPython では、ジェネレータベースのコルーチン (*note
          @types.coroutine: e53. で修飾された *note ジェネレータ: 1035.)
          は、 *note __await__(): 1f28. メソッドを持たないにもかかわらず
          *待機可能* ('awaitables') です。 ‘isinstance(gencoro,
          Coroutine)’ はそのようなコルーチンに対して ‘False’ を返します
          。そのようなコルーチンを検出するためには *note
          inspect.isawaitable(): de4. を使ってください。

     ‘Coroutine’ を型アノテーションで使う方法の詳細は、 *note Annotating
     generators and coroutines: 2481. を参照してください。型パラメータの
     意味と順序は *note Generator: da8. と同様です。

     Added in version 3.5.

 -- クラス: collections.abc.AsyncIterable

     ‘__aiter__’ メソッドを提供するクラスの ABC です。*note asynchronous
     iterable: d45. の定義も参照してください。

     Added in version 3.5.

 -- クラス: collections.abc.AsyncIterator

     ‘__aiter__’ および ‘__anext__’ メソッドを提供するクラスの ABC です
     。*note asynchronous iterator: 190. の定義も参照してください。

     Added in version 3.5.

 -- クラス: collections.abc.AsyncGenerator

     PEP 525(2) と PEP 492(3) に定義されているプロトコルを実装した *note
     非同期ジェネレータ: 1f99. クラスの ABC です。

     ‘AsyncGenerator’ を型アノテーションで使う方法の詳細は、 *note
     Annotating generators and coroutines: 2481. を参照してください。

     Added in version 3.6.

 -- クラス: collections.abc.Buffer

     *note buffer protocol: 371. を実装する *note __buffer__(): 42b. メ
     ソッドを提供するクラスのABCです。 PEP 688(4) を参照してください。

     Added in version 3.12.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0342/

   (2) https://peps.python.org/pep-0525/

   (3) https://peps.python.org/pep-0492/

   (4) https://peps.python.org/pep-0688/


File: python.info,  Node: 例とレシピ,  Prev: コレクションの抽象基底クラス -- 詳細な説明,  Up: collections abc --- コンテナの抽象基底クラス

5.8.5.3 例とレシピ
..................

抽象基底クラスは、クラスやインスタンスが特定の機能を提供しているかどうか
を調べることを可能にします。例えば:

     size = None
     if isinstance(myvar, collections.abc.Sized):
         size = len(myvar)

幾つかの ABC はコンテナ型 API を提供するクラスを開発するのを助ける mixin
型としても使えます。例えば、 *note Set: 21a3. API を提供するクラスを作る
場合、3つの基本になる抽象メソッド *note __contains__(): 1ebe, *note
__iter__(): 1c2b, *note __len__(): 1ec3. だけが必要です。ABC が残りの
‘__and__()’ や *note isdisjoint(): 2190. といったメソッドを提供します:

     class ListBasedSet(collections.abc.Set):
         ''' Alternate set implementation favoring space over speed
             and not requiring the set elements to be hashable. '''
         def __init__(self, iterable):
             self.elements = lst = []
             for value in iterable:
                 if value not in lst:
                     lst.append(value)

         def __iter__(self):
             return iter(self.elements)

         def __contains__(self, value):
             return value in self.elements

         def __len__(self):
             return len(self.elements)

     s1 = ListBasedSet('abcdef')
     s2 = ListBasedSet('defghi')
     overlap = s1 & s2            # The __and__() method is supported automatically

*note Set: 21a3. と *note MutableSet: 21ae. を mixin 型として利用すると
きの注意点:

  1. 幾つかの set の操作は新しい set を作るので、デフォルトの mixin メソ
     ッドは *note イテラブル: 10ad. から新しいインスタンスを作成する方法
     を必要とします。クラスのコンストラクタは ‘ClassName(iterable)’ の形
     のシグネチャを持つと仮定されます。内部の ‘_from_iterable()’ という
     *note classmethod: 14c. が ‘cls(iterable)’ を呼び出して新しい set を
     作る部分でこの仮定が使われています。コンストラクタのシグネチャが異
     なるクラスで *note Set: 21a3. を使う場合は、 iterable 引数から新し
     いインスタンスを生成できるクラスメソッドあるいは仕様に沿ったメソッ
     ドで ‘_from_iterable()’ をオーバーライドする必要があります。

  2. (たぶん意味はそのままに速度を向上する目的で)比較をオーバーライドす
     る場合、 *note __le__(): 12da. と *note __ge__(): 12dc. だけを再定
     義すれば、その他の演算は自動的に追随します。

  3. *note Set: 21a3. mixin型は set のハッシュ値を計算する ‘_hash()’ メ
     ソッドを提供しますが、すべての set が *note hashable: 5db. や
     immutable とは限らないので、 *note __hash__(): ac9. は提供しません
     。 mixin を使ってハッシュ可能な set を作る場合は、 *note Set: 21a3.
     と *note Hashable(): 4c2. の両方を継承して、 ‘__hash__ = Set._hash’
     と定義してください。

参考
....

   * *note MutableSet: 21ae. を使った例として OrderedSet recipe(1)。

   * ABCs についての詳細は、 *note abc: 4. モジュールと PEP 3119(2) を参
     照してください。

   ---------- Footnotes ----------

   (1) https://code.activestate.com/recipes/576694/

   (2) https://peps.python.org/pep-3119/


File: python.info,  Node: heapq --- ヒープキューアルゴリズム,  Next: bisect --- 配列二分法アルゴリズム,  Prev: collections abc --- コンテナの抽象基底クラス,  Up: データ型

5.8.6 ‘heapq’ -- ヒープキューアルゴリズム
-----------------------------------------

'ソースコード:' Lib/heapq.py(1)

__________________________________________________________________

このモジュールではヒープキューアルゴリズムの一実装を提供しています。優先
度キューアルゴリズムとしても知られています。

ヒープとは、各親ノードがどの子ノードよりも小さいか等しい値を持つ二分木の
ことです。この条件をヒープ不変式と呼びます。

ヒープの実装には、全ての 'k' について、要素をゼロから数えたときに、
‘heap[k] <= heap[2*k+1]’ かつ ‘heap[k] <= heap[2*k+2]’ となる配列を使用
しています。比較のために、存在しない要素を無限大と考えます。ヒープの興味
深い特性は、最小の要素が常にルートの ‘heap[0]’ になることです。

以下の API は教科書におけるヒープアルゴリズムとは 2 つの側面で異なってい
ます: (a) ゼロベースのインデクス化を行っています。これにより、ノードに対
するインデクスとその子ノードのインデクスの関係がやや明瞭でなくなりますが
、Python はゼロベースのインデクス化を使っているのでよりしっくりきます。
(b) われわれの pop メソッドは最大の要素ではなく最小の要素 (教科書では
"min heap:最小ヒープ" と呼ばれています; 教科書では並べ替えをインプレース
で行うのに適した "max heap:最大ヒープ" が一般的です)。

これらの 2 点によって、ユーザに戸惑いを与えることなく、ヒープを通常の
Python リストとして見ることができます: ‘heap[0]’ が最小の要素となり、
‘heap.sort()’ はヒープ不変式を保ちます!

ヒープを作成するには、 ‘[]’ に初期化されたリストを使うか、 *note
heapify(): 2485. を用いて要素の入ったリストを変換します。

次の関数が用意されています:

 -- の関数: heapq.heappush (heap, item)

     'item' を 'heap' に push します。ヒープ不変式を保ちます。

 -- の関数: heapq.heappop (heap)

     pop を行い、 'heap' から最小の要素を返します。ヒープ不変式は保たれ
     ます。ヒープが空の場合、 *note IndexError: 14de. が送出されます。
     pop せずに最小の要素にアクセスするには、 ‘heap[0]’ を使ってください
     。

 -- の関数: heapq.heappushpop (heap, item)

     'item' を 'heap' に push した後、pop を行って 'heap' から最初の要素
     を返します。この一続きの動作を *note heappush(): 1461. に引き続いて
     *note heappop(): 1462. を別々に呼び出すよりも効率的に実行します。

 -- の関数: heapq.heapify (x)

     リスト 'x' をインプレース処理し、線形時間でヒープに変換します。

 -- の関数: heapq.heapreplace (heap, item)

     'heap' から最小の要素を pop して返し、新たに 'item' を push します
     。ヒープのサイズは変更されません。ヒープが空の場合、 *note
     IndexError: 14de. が送出されます。

     この一息の演算は *note heappop(): 1462. に次いで *note heappush():
     1461. を送出するよりも効率的で、固定サイズのヒープを用いている場合
     にはより適しています。 pop/push の組み合わせは必ずヒープから要素を
     一つ返し、それを 'item' と置き換えます。

     返される値は加えられた 'item' よりも大きくなるかもしれません。それ
     を望まないなら、代わりに *note heappushpop(): 2486. を使うことを考
     えてください。この push/pop の組み合わせは二つの値の小さい方を返し
     、大きい方の値をヒープに残します。

このモジュールではさらに3つのヒープに基く汎用関数を提供します。

 -- の関数: heapq.merge (*iterables, key=None, reverse=False)

     複数のソートされた入力をマージ(merge)して一つのソートされた出力にし
     ます (たとえば、複数のログファイルの時刻の入ったエントリーをマージ
     します)。ソートされた値にわたる *note iterator: 191. を返します。

     ‘sorted(itertools.chain(*iterables))’ と似ていますが、イテレータを
     返し、一度にはデータをメモリに読み込まず、それぞれの入力ストリーム
     が予め(最小から最大へ)ソートされていることを仮定します。

     2 つのオプション引数があり、これらはキーワード引数として指定されな
     ければなりません。

     'key' は 1 つの引数からなる *note key function: dd2. を指定します。
     この関数は、入力の各要素から比較のキーを取り出すのに使われます。デ
     フォルト値は ‘None’ です (要素を直接比較します)。

     'reverse' は真偽値です。 ‘True’ を設定した場合、挿入要素は逆向きに
     比較されたかのように結合されます。
     ‘sorted(itertools.chain(*iterables), reverse=True)’ でこれに似た挙
     動を実現するには、全てのイテラブルは降順で並んでいなければなりませ
     ん。

     バージョン 3.5 で変更: オプションの 'key' 引数および 'reverse' 引数
     を追加.

 -- の関数: heapq.nlargest (n, iterable, key=None)

     'iterable' で定義されるデータセットのうち、最大値から降順に 'n' 個
     の値のリストを返します。(あたえられた場合) 'key' は、引数を一つとる
     、'iterable' のそれぞれの要素から比較キーを生成する関数を指定します
     (例 ‘key=str.lower’)。以下のコードと同等です: ‘sorted(iterable,
     key=key, reverse=True)[:n]’

 -- の関数: heapq.nsmallest (n, iterable, key=None)

     'iterable' で定義されるデータセットのうち、最小値から昇順に 'n' 個
     の値のリストを返します。(あたえられた場合) 'key' は、引数を一つとる
     、'iterable' のそれぞれの要素から比較キーを生成する関数を指定します
     (例 ‘key=str.lower’)。以下のコードと同等です: ‘sorted(iterable,
     key=key)[:n]’

後ろ二つの関数は 'n' の値が小さな場合に最適な動作をします。大きな値の時
には *note sorted(): b9c. 関数の方が効率的です。さらに、 ‘n==1’ の時には
*note min(): ed3. および *note max(): ed4. 関数の方が効率的です。この関
数を繰り返し使うことが必要なら、iterable を実際のヒープに変えることを考
えてください。

* Menu:

* 基本的な例::
* 優先度キュー実装の注釈::
* 理論::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/heapq.py


File: python.info,  Node: 基本的な例,  Next: 優先度キュー実装の注釈,  Up: heapq --- ヒープキューアルゴリズム

5.8.6.1 基本的な例
..................

すべての値をヒープに push してから最小値を 1 つずつ pop することで、ヒー
プソート(1) を実装できます:

     >>> def heapsort(iterable):
     ...     h = []
     ...     for value in iterable:
     ...         heappush(h, value)
     ...     return [heappop(h) for i in range(len(h))]
     ...
     >>> heapsort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])
     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

これは ‘sorted(iterable)’ に似ていますが、 *note sorted(): b9c. とは異な
り、この実装はステーブルソートではありません。

ヒープの要素はタプルに出来ます。これは、追跡される主レコードとは別に (タ
スクの優先度のような) 比較値を指定するときに便利です:

     >>> h = []
     >>> heappush(h, (5, 'write code'))
     >>> heappush(h, (7, 'release product'))
     >>> heappush(h, (1, 'write spec'))
     >>> heappush(h, (3, 'create tests'))
     >>> heappop(h)
     (1, 'write spec')

   ---------- Footnotes ----------

   (1) 
https://ja.wikipedia.org/wiki/%E3%83%92%E3%83%BC%E3%83%97%E3%82%BD%E3%83%BC%E3%83%88


File: python.info,  Node: 優先度キュー実装の注釈,  Next: 理論,  Prev: 基本的な例,  Up: heapq --- ヒープキューアルゴリズム

5.8.6.2 優先度キュー実装の注釈
..............................

優先度つきキュー(1) は、ヒープの一般的な使い方で、実装にはいくつか困難な
点があります:

   * ソート安定性: 優先度が等しい二つのタスクが、もともと追加された順序
     で返されるためにはどうしたらいいでしょうか？

   * (priority, task) ペアに対するタプルの比較は、priority が同じで task
     がデフォルトの比較順を持たないときに破綻します。

   * あるタスクの優先度が変化したら、どうやってそれをヒープの新しい位置
     に移動させるのでしょうか？

   * 未解決のタスクが削除される必要があるとき、どのようにそれをキューか
     ら探して削除するのでしょうか？

最初の二つの困難の解決策は、項目を優先度、項目番号、そしてタスクを含む 3
要素のリストとして保存することです。この項目番号は、同じ優先度の二つのタ
スクが、追加された順序で返されるようにするための同点決勝戦として働きます
。そして二つの項目番号が等しくなることはありませんので、タプルの比較が二
つのタスクを直接比べようとすることはありえません。

比較できないタスク問題のもう一つの解決法は、タスクアイテムを無視して優先
順序フィールドだけで比較するラッパークラスです:

     from dataclasses import dataclass, field
     from typing import Any

     @dataclass(order=True)
     class PrioritizedItem:
         priority: int
         item: Any=field(compare=False)

残りの困難は主に、未解決のタスクを探して、その優先度を変更したり、完全に
削除することです。タスクを探すことは、キュー内の項目を指し示す辞書によっ
てなされます。

項目を削除したり、優先度を変更することは、ヒープ構造の不変関係を壊すこと
になるので、もっと難しいです。ですから、可能な解決策は、その項目が無効で
あるものとしてマークし、必要なら変更された優先度の項目を加えることです:

     pq = []                         # list of entries arranged in a heap
     entry_finder = {}               # mapping of tasks to entries
     REMOVED = '<removed-task>'      # placeholder for a removed task
     counter = itertools.count()     # unique sequence count

     def add_task(task, priority=0):
         'Add a new task or update the priority of an existing task'
         if task in entry_finder:
             remove_task(task)
         count = next(counter)
         entry = [priority, count, task]
         entry_finder[task] = entry
         heappush(pq, entry)

     def remove_task(task):
         'Mark an existing task as REMOVED.  Raise KeyError if not found.'
         entry = entry_finder.pop(task)
         entry[-1] = REMOVED

     def pop_task():
         'Remove and return the lowest priority task. Raise KeyError if empty.'
         while pq:
             priority, count, task = heappop(pq)
             if task is not REMOVED:
                 del entry_finder[task]
                 return task
         raise KeyError('pop from an empty priority queue')

   ---------- Footnotes ----------

   (1) 
https://ja.wikipedia.org/wiki/%E5%84%AA%E5%85%88%E5%BA%A6%E3%81%A4%E3%81%8D%E3%82%AD%E3%83%A5%E3%83%BC


File: python.info,  Node: 理論,  Prev: 優先度キュー実装の注釈,  Up: heapq --- ヒープキューアルゴリズム

5.8.6.3 理論
............

ヒープとは、全ての 'k' について、要素を 0 から数えたときに、‘a[k] <=
a[2*k+1]’ かつ ‘a[k] <= a[2*k+2]’ となる配列です。比較のために、存在しな
い要素を無限大と考えます。ヒープの興味深い属性は ‘a[0]’ が常に最小の要素
になることです。

上記の奇妙な不変式は、勝ち抜き戦判定の際に効率的なメモリ表現を行うための
ものです。以下の番号は ‘a[k]’ ではなく 'k' とします:

                                    0

                   1                                 2

           3               4                5               6

       7       8       9       10      11      12      13      14

     15 16   17 18   19 20   21 22   23 24   25 26   27 28   29 30

上の木構造では、各セル 'k' は ‘2*k+1’ および ‘2*k+2’ を最大値としていま
す。スポーツに見られるような通常の 2 つ組勝ち抜き戦では、各セルはその下
にある二つのセルに対する勝者となっていて、個々のセルの勝者を追跡していく
ことにより、そのセルに対する全ての相手を見ることができます。しかしながら
、このような勝ち抜き戦を使う計算機アプリケーションの多くでは、勝歴を追跡
する必要はりません。メモリ効率をより高めるために、勝者が上位に進級した際
、下のレベルから持ってきて置き換えることにすると、あるセルとその下位にあ
る二つのセルは異なる三つの要素を含み、かつ上位のセルは二つの下位のセルに
対して "勝者と" なります。

このヒープ不変式が常に守られれば、インデックス 0 は明らかに最勝者となり
ます。最勝者の要素を除去し、"次の" 勝者を見つけるための最も単純なアルゴ
リズム的手法は、ある敗者要素 (ここでは上図のセル 30 とします) を 0 の場
所に持っていき、この新しい 0 を濾過するようにしてツリーを下らせて値を交
換してゆきます。不変関係が再構築されるまでこれを続けます。この操作は明ら
かに、ツリー内の全ての要素数に対して対数的な計算量となります。全ての要素
について繰り返すと、 'O'('n' log 'n') のソートになります。

このソートの良い点は、新たに挿入する要素が、最後に取り出された 0 番目の
要素よりも "良い値" でない限り、ソートを行っている最中に新たな要素を効率
的に追加できるというところです。この性質は、シミュレーション的な状況で、
ツリーで全ての入力イベントを保持し、"勝者" の状況を最小のスケジュール時
刻にするような場合に特に便利です。あるイベントが他のイベント群の実行をス
ケジュールする際、それらは未来にスケジュールされることになるので、それら
のイベント群を容易にヒープに積むことができます。すなわち、ヒープはスケジ
ューラを実装する上で良いデータ構造であるといえます (私はこれを MIDI シー
ケンサで使っています :-)。

これまで、スケジューラを実装するための様々なデータ構造が広範に研究されて
きました。ヒープは、十分高速で、速度はおおむね一定であり、最悪の場合でも
平均的な速度とさほど変わらないため、良いデータ構造といえます。しかし、最
悪の場合にひどい速度になるとしても、全体的にはより効率の高い他のデータ構
造表現も存在します。

ヒープはまた、巨大なディスクのソートでも非常に有用です。おそらくご存知の
ように、巨大なソートを行うと、複数の "ラン (run)" (予めソートされた配列
で、そのサイズは通常 CPU メモリの量に関係しています) が生成され、続いて
統合処理 (merging) がこれらのランを判定します。この統合処理はしばしば非
常に巧妙に組織されています (1)。重要なのは、最初のソートが可能な限り長い
ランを生成することです。勝ち抜き戦はこれを達成するための良い方法です。も
し利用可能な全てのメモリを使って勝ち抜き戦を行い、要素を置換および濾過処
理して現在のランに収めれば、ランダムな入力に対してメモリの二倍のサイズの
ランを生成することになり、大体順序づけがなされている入力に対してはもっと
高い効率になります。

さらに、ディスク上の 0 番目の要素を出力して、現在の勝ち抜き戦に (最後に
出力した値に "勝って" しまうために) 収められない入力を得たなら、ヒープに
は収まらないため、ヒープのサイズは減少します。解放されたメモリは二つ目の
ヒープを段階的に構築するために巧妙に再利用することができ、この二つ目のヒ
ープは最初のヒープが崩壊していくのと同じ速度で成長します。最初のヒープが
完全に消滅したら、ヒープを切り替えて新たなランを開始します。なんと巧妙で
効率的なのでしょう！

一言で言うと、ヒープは知って得するメモリ構造です。私はいくつかのアプリケ
ーションでヒープを使っていて、'ヒープ' モジュールを常備するのはいい事だ
と考えています。:-)

脚注
....

   ---------- Footnotes ----------

   (1) 現在使われているディスクバランス化アルゴリズムは、最近ではもはや
巧妙というよりも目障りになっています。これは、ディスクのシーク機能が向上
した結果です。巨大な容量を持つテープドライブなど、シーク不能なデバイスで
は、事情は全く異なります。テープの 1 つ 1 つの動きが可能な限り効率的に行
われるように非常に巧妙な処理を (相当前もって) 確保しなければなりません
(統合処理の "進行" に最も多く使用させます)。テープによっては逆方向に読む
ことさえでき、巻き戻しに時間を取られるのを避けるために使うこともできます
。正直、本当に良いテープソートは見ていて素晴らしく驚異的なものです！ソー
トというのは常に偉大な芸術なのです！:-)


File: python.info,  Node: bisect --- 配列二分法アルゴリズム,  Next: array --- 効率的な数値配列,  Prev: heapq --- ヒープキューアルゴリズム,  Up: データ型

5.8.7 ‘bisect’ -- 配列二分法アルゴリズム
----------------------------------------

'ソースコード:' Lib/bisect.py(1)

__________________________________________________________________

This module provides support for maintaining a list in sorted order
without having to sort the list after each insertion.  For long lists of
items with expensive comparison operations, this can be an improvement
over linear searches or frequent resorting.

The module is called *note bisect: d. because it uses a basic bisection
algorithm to do its work.  Unlike other bisection tools that search for
a specific value, the functions in this module are designed to locate an
insertion point.  Accordingly, the functions never call an *note
__eq__(): ac8. method to determine whether a value has been found.
Instead, the functions only call the *note __lt__(): 12d9. method and
will return an insertion point between values in an array.  次の関数が用
意されています:

 -- の関数: bisect.bisect_left (a, x, lo=0, hi=len(a), *, key=None)

     ソートされた順序を保ったまま 'x' を 'a' に挿入できる点を探し当てま
     す。リストの中から検索する部分集合を指定するには、パラメータの 'lo'
     と 'hi' を使います。デフォルトでは、リスト全体が使われます。'x' が
     すでに 'a' に含まれている場合、挿入点は既存のどのエントリーよりも前
     (左)になります。戻り値は、‘list.insert()’ の第一引数として使うのに
     適しています。'a' はすでにソートされているものとします。

     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.

     'key' specifies a *note key function: dd2. 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.

     If 'key' is ‘None’, the elements are compared directly and no key
     function is called.

     バージョン 3.10 で変更: 'key' パラメータが追加されました。

 -- の関数: bisect.bisect_right (a, x, lo=0, hi=len(a), *, key=None)
 -- の関数: bisect.bisect (a, x, lo=0, hi=len(a), *, key=None)

     Similar to *note bisect_left(): 2490, but returns an insertion
     point which comes after (to the right of) any existing entries of
     'x' in 'a'.

     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.

     バージョン 3.10 で変更: 'key' パラメータが追加されました。

 -- の関数: bisect.insort_left (a, x, lo=0, hi=len(a), *, key=None)

     'x' を 'a' にソート順で挿入します。

     This function first runs *note bisect_left(): 2490. to locate an
     insertion point.  Next, it runs the ‘insert()’ method on 'a' to
     insert 'x' at the appropriate position to maintain sort order.

     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.

     Keep in mind that the 'O'(log 'n') search is dominated by the slow
     'O'('n') insertion step.

     バージョン 3.10 で変更: 'key' パラメータが追加されました。

 -- の関数: bisect.insort_right (a, x, lo=0, hi=len(a), *, key=None)
 -- の関数: bisect.insort (a, x, lo=0, hi=len(a), *, key=None)

     Similar to *note insort_left(): 2493, but inserting 'x' in 'a'
     after any existing entries of 'x'.

     This function first runs *note bisect_right(): 2491. to locate an
     insertion point.  Next, it runs the ‘insert()’ method on 'a' to
     insert 'x' at the appropriate position to maintain sort order.

     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.

     Keep in mind that the 'O'(log 'n') search is dominated by the slow
     'O'('n') insertion step.

     バージョン 3.10 で変更: 'key' パラメータが追加されました。

* Menu:

* パフォーマンスに関するメモ::
* ソート済みリストの探索::
* 使用例: 使用例<4>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/bisect.py


File: python.info,  Node: パフォーマンスに関するメモ,  Next: ソート済みリストの探索,  Up: bisect --- 配列二分法アルゴリズム

5.8.7.1 パフォーマンスに関するメモ
..................................

When writing time sensitive code using 'bisect()' and 'insort()', keep
these thoughts in mind:

   * Bisection is effective for searching ranges of values.  For
     locating specific values, dictionaries are more performant.

   * The 'insort()' functions are 'O'('n') because the logarithmic
     search step is dominated by the linear time insertion step.

   * The search functions are stateless and discard key function results
     after they are used.  Consequently, if the search functions are
     used in a loop, the key function may be called again and again on
     the same array elements.  If the key function isn't fast, consider
     wrapping it with *note functools.cache(): 2497. to avoid duplicate
     computations.  Alternatively, consider searching an array of
     precomputed keys to locate the insertion point (as shown in the
     examples section below).

参考
....

   * Sorted Collections(1) is a high performance module that uses
     'bisect' to managed sorted collections of data.

   * bisect を利用して、直接の探索ができ、キー関数をサポートする、完全な
     機能を持つコレクションクラスを組み立てる SortedCollection
     recipe(2)。キーは、探索中に不必要な呼び出しをさせないために、予め計
     算しておきます。

   ---------- Footnotes ----------

   (1) https://grantjenks.com/docs/sortedcollections/

   (2) https://code.activestate.com/recipes/577197-sortedcollection/


File: python.info,  Node: ソート済みリストの探索,  Next: 使用例<4>,  Prev: パフォーマンスに関するメモ,  Up: bisect --- 配列二分法アルゴリズム

5.8.7.2 ソート済みリストの探索
..............................

The above *note bisect functions: 248f. are useful for finding insertion
points but can be tricky or awkward to use for common searching tasks.
The following five functions show how to transform them into the
standard lookups for sorted lists:

     def index(a, x):
         'Locate the leftmost value exactly equal to x'
         i = bisect_left(a, x)
         if i != len(a) and a[i] == x:
             return i
         raise ValueError

     def find_lt(a, x):
         'Find rightmost value less than x'
         i = bisect_left(a, x)
         if i:
             return a[i-1]
         raise ValueError

     def find_le(a, x):
         'Find rightmost value less than or equal to x'
         i = bisect_right(a, x)
         if i:
             return a[i-1]
         raise ValueError

     def find_gt(a, x):
         'Find leftmost value greater than x'
         i = bisect_right(a, x)
         if i != len(a):
             return a[i]
         raise ValueError

     def find_ge(a, x):
         'Find leftmost item greater than or equal to x'
         i = bisect_left(a, x)
         if i != len(a):
             return a[i]
         raise ValueError


File: python.info,  Node: 使用例<4>,  Prev: ソート済みリストの探索,  Up: bisect --- 配列二分法アルゴリズム

5.8.7.3 使用例
..............

The *note bisect(): 2492. function can be useful for numeric table
lookups.  This example uses *note bisect(): 2492. to look up a letter
grade for an exam score (say) based on a set of ordered numeric
breakpoints: 90 and up is an 'A', 80 to 89 is a 'B', and so on:

     >>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):
     ...     i = bisect(breakpoints, score)
     ...     return grades[i]
     ...
     >>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
     ['F', 'A', 'C', 'C', 'B', 'A', 'A']

The *note bisect(): 2492. and *note insort(): 2495. functions also work
with lists of tuples.  The 'key' argument can serve to extract the field
used for ordering records in a table:

     >>> from collections import namedtuple
     >>> from operator import attrgetter
     >>> from bisect import bisect, insort
     >>> from pprint import pprint

     >>> Movie = namedtuple('Movie', ('name', 'released', 'director'))

     >>> movies = [
     ...     Movie('Jaws', 1975, 'Spielberg'),
     ...     Movie('Titanic', 1997, 'Cameron'),
     ...     Movie('The Birds', 1963, 'Hitchcock'),
     ...     Movie('Aliens', 1986, 'Cameron')
     ... ]

     >>> # Find the first movie released after 1960
     >>> by_year = attrgetter('released')
     >>> movies.sort(key=by_year)
     >>> movies[bisect(movies, 1960, key=by_year)]
     Movie(name='The Birds', released=1963, director='Hitchcock')

     >>> # Insert a movie while maintaining sort order
     >>> romance = Movie('Love Story', 1970, 'Hiller')
     >>> insort(movies, romance, key=by_year)
     >>> pprint(movies)
     [Movie(name='The Birds', released=1963, director='Hitchcock'),
      Movie(name='Love Story', released=1970, director='Hiller'),
      Movie(name='Jaws', released=1975, director='Spielberg'),
      Movie(name='Aliens', released=1986, director='Cameron'),
      Movie(name='Titanic', released=1997, director='Cameron')]

If the key function is expensive, it is possible to avoid repeated
function calls by searching a list of precomputed keys to find the index
of a record:

     >>> data = [('red', 5), ('blue', 1), ('yellow', 8), ('black', 0)]
     >>> data.sort(key=lambda r: r[1])       # Or use operator.itemgetter(1).
     >>> keys = [r[1] for r in data]         # Precompute a list of keys.
     >>> data[bisect_left(keys, 0)]
     ('black', 0)
     >>> data[bisect_left(keys, 1)]
     ('blue', 1)
     >>> data[bisect_left(keys, 5)]
     ('red', 5)
     >>> data[bisect_left(keys, 8)]
     ('yellow', 8)


File: python.info,  Node: array --- 効率的な数値配列,  Next: weakref --- 弱参照,  Prev: bisect --- 配列二分法アルゴリズム,  Up: データ型

5.8.8 ‘array’ -- 効率的な数値配列
---------------------------------

__________________________________________________________________

This module defines an object type which can compactly represent an
array of basic values: characters, integers, floating-point numbers.
Arrays are sequence types and behave very much like lists, except that
the type of objects stored in them is constrained.  The type is
specified at object creation time by using a 'type code', which is a
single character.  The following type codes are defined:

型コード        C の型                   Python の型             最小サイズ (バイト単位)     注釈
                                                                                             
---------------------------------------------------------------------------------------------------------
                                                                                             
‘'b'’           signed char              int                     1
                                                                 
                                                                                             
‘'B'’           unsigned char            int                     1
                                                                 
                                                                                             
‘'u'’           wchar_t                  Unicode文字(unicode型   2                           (1)
                                         )                                                   
                                         
                                                                                             
‘'w'’           Py_UCS4                  Unicode文字(unicode型   4
                                         )                       
                                         
                                                                                             
‘'h'’           signed short             int                     2
                                                                 
                                                                                             
‘'H'’           unsigned short           int                     2
                                                                 
                                                                                             
‘'i'’           signed int               int                     2
                                                                 
                                                                                             
‘'I'’           unsigned int             int                     2
                                                                 
                                                                                             
‘'l'’           signed long              int                     4
                                                                 
                                                                                             
‘'L'’           unsigned long            int                     4
                                                                 
                                                                                             
‘'q'’           signed long long         int                     8
                                                                 
                                                                                             
‘'Q'’           unsigned long long       int                     8
                                                                 
                                                                                             
‘'f'’           浮動小数点数             浮動小数点数            4
                                                                 
                                                                                             
‘'d'’           double                   浮動小数点数            8
                                                                 

注釈:

  1. It can be 16 bits or 32 bits depending on the platform.

     バージョン 3.9 で変更: ‘array('u')’ now uses ‘wchar_t’ as C type
     instead of deprecated ‘Py_UNICODE’.  This change doesn't affect its
     behavior because ‘Py_UNICODE’ is alias of ‘wchar_t’ since Python
     3.3.

     Deprecated since version 3.3, will be removed in version 3.16:
     Please migrate to ‘'w'’ typecode.

値の実際の表現はマシンアーキテクチャ (厳密に言うとCの実装) によって決ま
ります。値の実際のサイズは *note array.itemsize: 249d. 属性から得られま
す。

このモジュールは以下の項目を定義しています:

 -- データ: array.typecodes

     すべての利用可能なタイプコードを含む文字列

このモジュールでは次の型を定義しています:

 -- クラス: array.array (typecode[, initializer])

     A new array whose items are restricted by 'typecode', and
     initialized from the optional 'initializer' value, which must be a
     *note bytes: 1a4. or *note bytearray: 508. object, a Unicode
     string, or iterable over elements of the appropriate type.

     If given a *note bytes: 1a4. or *note bytearray: 508. object, the
     initializer is passed to the new array's *note frombytes(): 1243.
     method; if given a Unicode string, the initializer is passed to the
     *note fromunicode(): 249f. method; otherwise, the initializer's
     iterator is passed to the *note extend(): 24a0. method to add
     initial items to the array.

     アレイオブジェクトでは、インデクス指定、スライス、連結および反復と
     いった、 通常のシーケンスの演算をサポートしています。スライス代入を
     使うときは、 代入値は同じ型コードのアレイオブジェクトでなければなり
     ません。 それ以外のオブジェクトを指定すると *note TypeError: 502. を
     送出します。 アレイオブジェクトはバッファインターフェースを実装して
     おり、 *note bytes-like objects: cfb. をサポートしている場所ならど
     こでも利用できます。

     引数 ‘typecode’, ‘initializer’ 付きで *note 監査イベント: 1825.
     ‘array.__new__’ を送出します。

      -- の属性: typecode

          アレイを作るときに使う型コード文字です。

      -- の属性: itemsize

          アレイの要素 1 つの内部表現に使われるバイト長です。

      -- メソッド: append (x)

          値 'x' の新たな要素をアレイの末尾に追加します。

      -- メソッド: buffer_info ()

          アレイの内容を記憶するために使っているバッファの、現在のメモリ
          アドレスと要素数の入ったタプル ‘(address, length)’ を返します
          。バイト単位で表したメモリバッファの大きさは
          ‘array.buffer_info()[1] * array.itemsize’ で計算できます。例え
          ば ‘ioctl()’ 操作のような、メモリアドレスを必要とする低レベル
          な (そして、本質的に危険な) I/Oインターフェースを使って作業す
          る場合に、ときどき便利です。アレイ自体が存在し、長さを変えるよ
          うな演算を適用しない限り、有効な値を返します。

               注釈: C やC++ で書いたコードからアレイオブジェクトを使う
               場合 (‘buffer_info()’ の情報を使う意味のある唯一の方法で
               す) は、アレイオブジェクトでサポートしているバッファイン
               ターフェースを使う方がより理にかなっています。このメソッ
               ドは後方互換性のために保守されており、新しいコードでの使
               用は避けるべきです。バッファインターフェースの説明は
               *note バッファプロトコル (buffer Protocol): 371. にありま
               す。

      -- メソッド: byteswap ()

          アレイのすべての要素に対して「バイトスワップ」 (リトルエンディ
          アンとビッグエンディアンの変換) を行います。このメソッドは大き
          さが 1、2、4 および 8 バイトの値のみをサポートしています。他の
          種類の値に使うと *note RuntimeError: 17a. を送出します。異なる
          バイトオーダを使うマシンで書かれたファイルからデータを読み込む
          ときに役に立ちます。

      -- メソッド: count (x)

          シーケンス中の 'x' の出現回数を返します。

      -- メソッド: extend (iterable)

          'iterable' から要素を取り出し、アレイの末尾に要素を追加します
          。 'iterable' が別のアレイ型である場合、二つのアレイは '全く'
          同じ型コードでなければなりません。それ以外の場合には *note
          TypeError: 502. を送出します。 'iterable' がアレイでない場合、
          アレイに値を追加できるような正しい型の要素からなるイテレーショ
          ン可能オブジェクトでなければなりません。

      -- メソッド: frombytes (buffer)

          Appends items from the *note bytes-like object: cfb,
          interpreting its content as an array of machine values (as if
          it had been read from a file using the *note fromfile(): 24a6.
          method).

          Added in version 3.2: 明確化のため ‘fromstring()’ の名前が
          *note frombytes(): 1243. に変更されました。

      -- メソッド: fromfile (f, n)

          *note ファイルオブジェクト: 1193. 'f' から (マシンのデータ形式
          そのままで) 'n' 個の要素を読み出し、アレイの末尾に要素を追加し
          ます。 'n' 個未満の要素しか読めなかった場合は *note EOFError:
          12a7. を送出しますが、それまでに読み出せた値はアレイに追加され
          ます。

      -- メソッド: fromlist (list)

          リストから要素を追加します。型に関するエラーが発生した場合にア
          レイが変更されないことを除き、 ‘for x in list: a.append(x)’ と
          同じです。

      -- メソッド: fromunicode (s)

          Extends this array with data from the given Unicode string.
          The array must have type code ‘'u'’ or ‘'w'’; otherwise a
          *note ValueError: 1e3. is raised.  Use
          ‘array.frombytes(unicodestring.encode(enc))’ to append Unicode
          data to an array of some other type.

      -- メソッド: index (x[, start[, stop]])

          Return the smallest 'i' such that 'i' is the index of the
          first occurrence of 'x' in the array.  The optional arguments
          'start' and 'stop' can be specified to search for 'x' within a
          subsection of the array.  Raise *note ValueError: 1e3. if 'x'
          is not found.

          バージョン 3.10 で変更: Added optional 'start' and 'stop'
          parameters.

      -- メソッド: insert (i, x)

          アレイ中の位置 'i' の前に値 'x' をもつ新しい要素を挿入します。
          'i' の値が負の場合、アレイの末尾からの相対位置として扱います。

      -- メソッド: pop ([i])

          アレイからインデクスが 'i' の要素を取り除いて返します。オプシ
          ョンの引数はデフォルトで ‘-1’ になっていて、最後の要素を取り除
          いて返すようになっています。

      -- メソッド: remove (x)

          アレイ中の 'x' のうち、最初に現れたものを取り除きます。

      -- メソッド: clear ()

          Remove all elements from the array.

          Added in version 3.13.

      -- メソッド: reverse ()

          アレイの要素の順番を逆にします。

      -- メソッド: tobytes ()

          array をマシンの値の array に変換して、 bytes の形で返します
          (*note tofile(): 24ac. メソッドを使ってファイルに書かれるバイ
          ト列と同じです)。

          Added in version 3.2: ‘tostring()’ is renamed to *note
          tobytes(): 1242. for clarity.

      -- メソッド: tofile (f)

          すべての要素を (マシンの値の形式で) *note file object: 1193.
          'f' に書き込みます。

      -- メソッド: tolist ()

          アレイを同じ要素を持つ普通のリストに変換します。

      -- メソッド: tounicode ()

          Convert the array to a Unicode string.  The array must have a
          type ‘'u'’ or ‘'w'’; otherwise a *note ValueError: 1e3. is
          raised.  Use ‘array.tobytes().decode(enc)’ to obtain a Unicode
          string from an array of some other type.

The string representation of array objects has the form ‘array(typecode,
initializer)’.  The 'initializer' is omitted if the array is empty,
otherwise it is a Unicode string if the 'typecode' is ‘'u'’ or ‘'w'’,
otherwise it is a list of numbers.  The string representation is
guaranteed to be able to be converted back to an array with the same
type and value using *note eval(): 165, so long as the *note array: 185.
class has been imported using ‘from array import array’.  Variables
‘inf’ and ‘nan’ must also be defined if it contains corresponding
floating-point values.  Examples:

     array('l')
     array('w', 'hello \u2641')
     array('l', [1, 2, 3, 4, 5])
     array('d', [1.0, 2.0, 3.14, -inf, nan])

参考
....

*note struct: c0. モジュール

     異なる種類のバイナリデータのパックおよびアンパック。

NumPy(1)

     NumPy パッケージは、別の配列型を定義しています。

   ---------- Footnotes ----------

   (1) https://numpy.org/


File: python.info,  Node: weakref --- 弱参照,  Next: types --- 動的な型生成と組み込み型の名前,  Prev: array --- 効率的な数値配列,  Up: データ型

5.8.9 ‘weakref’ -- 弱参照
-------------------------

'ソースコード:' Lib/weakref.py(1)

__________________________________________________________________

*note weakref: fc. モジュールは、Pythonプログラマがオブジェクトへの弱参
照 ('weak refarence')を作成できるようにします。

以下では、用語リファレント('referent') は弱参照が参照するオブジェクトを
意味します。

オブジェクトへの弱参照があることは、そのオブジェクトを生かしておくのには
不十分です。リファレントへの参照が弱参照しか残っていない場合、 *note
garbage collection: 1884. はリファレントを自由に破棄し、メモリを別のもの
に再利用することができます。しかし、オブジェクトへの強参照がなくても、オ
ブジェクトが実際に破棄されるまでは、弱参照はオブジェクトを返す場合があり
ます。

弱参照の主な用途は、巨大なオブジェクトを保持するキャッシュやマッピングを
実装することです。ここで、キャッシュやマッピングに保持されているからとい
う理由だけで、巨大なオブジェクトが生き続けることは望ましくありません。

例えば、巨大なバイナリ画像のオブジェクトがたくさんあり、それぞれに名前を
関連付けたいとします。 Python の辞書型を使って名前を画像に対応付けたり画
像を名前に対応付けたりすると、画像オブジェクトは辞書内のキーや値に使われ
ているため存続しつづけることになります。 *note weakref: fc. モジュールが
提供している *note WeakKeyDictionary: 18d9. や *note
WeakValueDictionary: 18d8. クラスはその代用で、対応付けを構築するのに弱
参照を使い、キャッシュやマッピングに存在するという理由だけでオブジェクト
を存続させないようにします。例えば、もしある画像オブジェクトが *note
WeakValueDictionary: 18d8. の値になっていた場合、最後に残った画像オブジ
ェクトへの参照を弱参照マッピングが保持していれば、ガーベジコレクションは
このオブジェクトを再利用でき、画像オブジェクトに対する弱参照内の対応付け
は削除されます。

*note WeakKeyDictionary: 18d9. と *note WeakValueDictionary: 18d8. はそ
の実装に弱参照を使用しており、キーや値がガーベジコレクションによって回収
されたことを弱参照辞書に通知するコールバック関数を設定しています。 *note
WeakSet: 5a7. は *note set: 5a3. インターフェースを実装していますが、
*note WeakKeyDictionary: 18d9. のように要素への弱参照を持ちます。

*note finalize: a4a. は、オブジェクトのガベージコレクションの実行時にク
リーンアップ関数が呼び出されるように登録する、単純な方法を提供します。こ
れは、未加工の弱参照上にコールバック関数を設定するよりも簡単です。なぜな
ら、オブジェクトのコレクションが完了するまでファイナライザが生き続けるこ
とを、モジュールが自動的に保証するからです。

ほとんどのプログラムでは弱参照コンテナまたは *note finalize: a4a. のどれ
かを使えば必要なものは揃うはずです。通常は直接自前の弱参照を作成する必要
はありません。低レベルな機構は、より進んだ使い方をするために *note
weakref: fc. モジュールとして公開されています。

全てのオブジェクトが弱参照で参照できるわけではありません。弱参照をサポー
トするオブジェクトは、クラスインスタンス、(C ではなく) Python で書かれた
関数、インスタンスメソッド、set オブジェクト、frozenset オブジェクト、
*note file オブジェクト: 1193. 、 *note generators: 1035. 型のオブジェク
ト、socket オブジェクト、array オジェクト、deque オブジェクト、正規表現
パターンオブジェクト、code オブジェクトです。

バージョン 3.2 で変更: thread.lock, threading.Lock, code オブジェクトの
サポートが追加されました。

*note list: 5dc. や *note dict: 237. など、いくつかの組み込み型は弱参照
を直接サポートしませんが、以下のようにサブクラス化を行えばサポートを追加
できます:

     class Dict(dict):
         pass

     obj = Dict(red=1, green=2, blue=3)   # this object is weak referenceable

'CPython 実装の詳細:' *note tuple: 349. や *note int: 238. など、他の組
み込み型はサブクラス化しても弱参照をサポートしません。

拡張型は、簡単に弱参照をサポートできます。詳細については、 *note
弱参照(Weak Reference)のサポート: 24b1. を参照してください。

When ‘__slots__’ are defined for a given type, weak reference support is
disabled unless a ‘'__weakref__'’ string is also present in the sequence
of strings in the ‘__slots__’ declaration.  See *note __slots__
documentation: 1e90. for details.

 -- クラス: weakref.ref (object[, callback])

     'object' への弱参照を返します。リファレントがまだ生きているならば、
     元のオブジェクトは参照オブジェクトの呼び出しで取り出せす。リファレ
     ントがもはや生きていないならば、参照オブジェクトを呼び出したときに
     *note None: 641. を返します。 'callback' に *note None: 641. 以外の
     値を与えた場合、オブジェクトをまさに後始末処理しようとするときに呼
     び出します。このとき弱参照オブジェクトは 'callback' の唯一のパラメ
     タとして渡されます。リファレントはもはや利用できません。

     同じオブジェクトに対してたくさんの弱参照を作れます。それぞれの弱参
     照に対して登録されたコールバックは、もっとも新しく登録されたコール
     バックからもっとも古いものへと呼び出されます。

     Exceptions raised by the callback will be noted on the standard
     error output, but cannot be propagated; they are handled in exactly
     the same way as exceptions raised from an object's *note __del__():
     1ec1. method.

     'object' が *note ハッシュ可能: 5db. ならば、弱参照はハッシュ可能で
     す。それらは 'object' が削除された後でもそれらのハッシュ値を保持し
     ます。 'object' が削除されてから初めて *note hash(): 5b5. が呼び出
     された場合に、その呼び出しは *note TypeError: 502. を発生させます。

     弱参照は等価性のテストをサポートしていますが、順序をサポートしてい
     ません。参照がまだ生きているならば、 'callback' に関係なく二つの参
     照はそれらのリファレントと同じ等価関係を持ちます。リファレントのど
     ちらか一方が削除された場合、参照オブジェクトが同一である場合に限り
     、その参照は等価です。

     これはサブクラス化可能な型というよりファクトリ関数です。

      -- の属性: __callback__

          この読み出し専用の属性は、現在弱参照に関連付けられているコール
          バックを返します。コールバックが存在しないか、弱参照のリファレ
          ントが生きていない場合、この属性の値は ‘None’ になります。

     バージョン 3.4 で変更: *note __callback__: fbc. 属性が追加されまし
     た。

 -- の関数: weakref.proxy (object[, callback])

     弱参照を使う 'object' へのプロキシを返します。弱参照オブジェクトを
     明示的な参照外しをしながら利用する代わりに、多くのケースでプロキシ
     を利用することができます。返されるオブジェクトは、 'object' が呼び
     出し可能かどうかによって、 ‘ProxyType’ または ‘CallableProxyType’ の
     どちらかの型を持ちます。プロキシオブジェクトはリファレントに関係な
     く *note ハッシュ可能: 5db. ではありません。これによって、それらの
     基本的な変更可能という性質による多くの問題を避けています。そして、
     辞書のキーとしての利用を妨げます。 'callback' は *note ref(): fbb.
     関数の同じ名前のパラメータと同じものです。(-- 訳注: リファレントが
     変更不能型であっても、プロキシはリファレントが消えるという状態の変
     更があるために、変更可能型です。--)

     Accessing an attribute of the proxy object after the referent is
     garbage collected raises *note ReferenceError: 14b8.

     バージョン 3.8 で変更: Extended the operator support on proxy
     objects to include the matrix multiplication operators ‘@’ and
     ‘@=’.

 -- の関数: weakref.getweakrefcount (object)

     'object' を参照する弱参照とプロキシの数を返します。

 -- の関数: weakref.getweakrefs (object)

     'object' を参照するすべての弱参照とプロキシオブジェクトのリストを返
     します。

 -- クラス: weakref.WeakKeyDictionary ([dict])

     キーを弱参照するマッピングクラス。キーへの強参照がなくなったときに
     、辞書のエントリは捨てられます。アプリケーションの他の部分が所有す
     るオブジェクトへ属性を追加することもなく、それらのオブジェクトに追
     加データを関連づけるために使うことができます。これは属性へのアクセ
     スをオーバーライドするオブジェクトに特に便利です。

     Note that when a key with equal value to an existing key (but not
     equal identity) is inserted into the dictionary, it replaces the
     value but does not replace the existing key.  Due to this, when the
     reference to the original key is deleted, it also deletes the entry
     in the dictionary:

          >>> class T(str): pass
          ...
          >>> k1, k2 = T(), T()
          >>> d = weakref.WeakKeyDictionary()
          >>> d[k1] = 1   # d = {k1: 1}
          >>> d[k2] = 2   # d = {k1: 2}
          >>> del k1      # d = {}

     A workaround would be to remove the key prior to reassignment:

          >>> class T(str): pass
          ...
          >>> k1, k2 = T(), T()
          >>> d = weakref.WeakKeyDictionary()
          >>> d[k1] = 1   # d = {k1: 1}
          >>> del d[k1]
          >>> d[k2] = 2   # d = {k2: 2}
          >>> del k1      # d = {k2: 2}

     バージョン 3.9 で変更: PEP 584(2) で規定されている ‘|’ 演算子と
     ‘|=’ 演算子のサポートを追加しました。

*note WeakKeyDictionary: 18d9. オブジェクトは、追加のメソッドを持ちます
。このメソッドは、内部の参照を直接公開します。その参照は、利用される時に
生存しているとは限りません。なので、参照を利用する前に、その参照をチェッ
クする必要があります。これにより、必要なくなったキーの参照が残っているた
めに、ガベージコレクタがそのキーを削除できなくなる事態を避ける事ができま
す。

 -- メソッド: WeakKeyDictionary.keyrefs ()

     キーへの弱参照を持つ iterable オブジェクトを返します。

 -- クラス: weakref.WeakValueDictionary ([dict])

     値を弱参照するマッピングクラス。値への強参照が存在しなくなったとき
     に、辞書のエントリは捨てられます。

     バージョン 3.9 で変更: PEP 584(3) で規定されている ‘|’ 演算子と
     ‘|=’ 演算子のサポートを追加しました。

*note WeakValueDictionary: 18d8. objects have an additional method that
has the same issues as the *note WeakKeyDictionary.keyrefs(): 24b4.
method.

 -- メソッド: WeakValueDictionary.valuerefs ()

     値への弱参照を持つ iterable オブジェクトを返します。

 -- クラス: weakref.WeakSet ([elements])

     要素への弱参照を持つ集合型。要素への強参照が無くなったときに、その
     要素は削除されます。

 -- クラス: weakref.WeakMethod (method[, callback])

     拡張された *note ref: fbb. のサブクラスで、束縛されたメソッドへの弱
     参照をシミュレートします (つまり、クラスで定義され、インスタンスに
     あるメソッド)。 束縛されたメソッドは短命なので、標準の弱参照では保
     持し続けられません。 *note WeakMethod: fba. には、オブジェクトと元
     々の関数が死ぬまで束縛されたメソッドを再作成する特別なコードがあり
     ます:

          >>> class C:
          ...     def method(self):
          ...         print("method called!")
          ...
          >>> c = C()
          >>> r = weakref.ref(c.method)
          >>> r()
          >>> r = weakref.WeakMethod(c.method)
          >>> r()
          <bound method C.method of <__main__.C object at 0x7fc859830220>>
          >>> r()()
          method called!
          >>> del c
          >>> gc.collect()
          0
          >>> r()
          >>>

     'callback' is the same as the parameter of the same name to the
     *note ref(): fbb. function.

     Added in version 3.4.

 -- クラス: weakref.finalize (obj, func, /, *args, **kwargs)

     'obj' がガベージコレクションで回収されるときに呼び出される、呼び出
     し可能なファイナライザオブジェクトを返します。 通常の弱参照とは異な
     り、ファイナライザは参照しているオブジェクトが回収されるまで必ず生
     き残り、そのおかげでライフサイクル管理が大いに簡単になります。

     ファイナライザは (直接もしくはガベージコレクションのときに) 呼び出
     されるまで '生きている' と見なされ、呼び出された後には '死んでいま
     す' 。 生きているファイナライザを呼び出すと、 ‘func(*arg,
     **kwargs)’ を評価した結果を返します。一方、死んでいるファイナライザ
     を呼び出すと *note None: 641. を返します。

     Exceptions raised by finalizer callbacks during garbage collection
     will be shown on the standard error output, but cannot be
     propagated.  They are handled in the same way as exceptions raised
     from an object's *note __del__(): 1ec1. method or a weak
     reference's callback.

     プログラムが終了するとき、生き残ったそれぞれのファイナライザは、自
     身の *note atexit: 9. 属性が偽に設定されるまで呼び出され続けます。
     ファイナライザは生成された順序の逆順で呼び出されます。

     A finalizer will never invoke its callback during the later part of
     the *note interpreter shutdown: 134. when module globals are liable
     to have been replaced by *note None: 641.

      -- メソッド: __call__ ()

          If 'self' is alive then mark it as dead and return the result
          of calling ‘func(*args, **kwargs)’.  If 'self' is dead then
          return *note None: 641.

      -- メソッド: detach ()

          If 'self' is alive then mark it as dead and return the tuple
          ‘(obj, func, args, kwargs)’.  If 'self' is dead then return
          *note None: 641.

      -- メソッド: peek ()

          If 'self' is alive then return the tuple ‘(obj, func, args,
          kwargs)’.  If 'self' is dead then return *note None: 641.

      -- の属性: alive

          ファイナライザが生きている場合には真、そうでない場合には偽のプ
          ロパティです。

      -- の属性: atexit

          A writable boolean property which by default is true.  When
          the program exits, it calls all remaining live finalizers for
          which *note atexit: 24ba. is true.  They are called in reverse
          order of creation.

          注釈: It is important to ensure that 'func', 'args' and
          'kwargs' do not own any references to 'obj', either directly
          or indirectly, since otherwise 'obj' will never be garbage
          collected.  In particular, 'func' should not be a bound method
          of 'obj'.

     Added in version 3.4.

 -- データ: weakref.ReferenceType

     弱参照オブジェクトのための型オブジェクト。

 -- データ: weakref.ProxyType

     呼び出し可能でないオブジェクトのプロキシのための型オブジェクト。

 -- データ: weakref.CallableProxyType

     呼び出し可能なオブジェクトのプロキシのための型オブジェクト。

 -- データ: weakref.ProxyTypes

     プロキシのためのすべての型オブジェクトを含むシーケンス。これは両方
     のプロキシ型の名前付けに依存しないで、オブジェクトがプロキシかどう
     かのテストをより簡単にできます。

参考
....

PEP 205(4) - 弱参照

     この機能の提案と理論的根拠。初期の実装と他の言語における類似の機能
     についての情報へのリンクを含んでいます。

* Menu:

* 弱参照オブジェクト::
* 使用例: 使用例<5>.
* ファイナライザオブジェクト::
* Comparing finalizers with __del__() methods: Comparing finalizers with __del__ methods.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/weakref.py

   (2) https://peps.python.org/pep-0584/

   (3) https://peps.python.org/pep-0584/

   (4) https://peps.python.org/pep-0205/


File: python.info,  Node: 弱参照オブジェクト,  Next: 使用例<5>,  Up: weakref --- 弱参照

5.8.9.1 弱参照オブジェクト
..........................

Weak reference objects have no methods and no attributes besides *note
ref.__callback__: fbc.  A weak reference object allows the referent to
be obtained, if it still exists, by calling it:

     >>> import weakref
     >>> class Object:
     ...     pass
     ...
     >>> o = Object()
     >>> r = weakref.ref(o)
     >>> o2 = r()
     >>> o is o2
     True

リファレントがもはや存在しないならば、参照オブジェクトの呼び出しは *note
None: 641. を返します:

     >>> del o, o2
     >>> print(r())
     None

弱参照オブジェクトがまだ生きているかどうかのテストは、式 ‘ref() is not
None’ を用いて行われます。通常、参照オブジェクトを使う必要があるアプリケ
ーションコードはこのパターンに従います:

     # r is a weak reference object
     o = r()
     if o is None:
         # referent has been garbage collected
         print("Object has been deallocated; can't frobnicate.")
     else:
         print("Object is still live!")
         o.do_something_useful()

"生存性(liveness)"のテストを分割すると、スレッド化されたアプリケーション
において競合状態を作り出します。 (訳注:‘if r() is not None:
r().do_something()’ では、2度目のr()がNoneを返す可能性があります) 弱参照
が呼び出される前に、他のスレッドは弱参照が無効になる原因となり得ます。上
で示したイディオムは、シングルスレッドのアプリケーションと同じくマルチス
レッド化されたアプリケーションにおいても安全です。

サブクラス化を行えば、 *note ref: fbb. オブジェクトの特殊なバージョンを
作成できます。これは *note WeakValueDictionary: 18d8. の実装で使われてお
り、マップ内の各エントリによるメモリのオーバヘッドを減らしています。こう
した実装は、ある参照に追加情報を関連付けたい場合に便利ですし、リファレン
トを取り出すための呼び出し時に何らかの追加処理を行いたい場合にも使えます
。

以下の例では、 *note ref: fbb. のサブクラスを使って、あるオブジェクトに
追加情報を保存し、リファレントがアクセスされたときにその値に作用をできる
ようにするための方法を示しています:

     import weakref

     class ExtendedRef(weakref.ref):
         def __init__(self, ob, callback=None, /, **annotations):
             super().__init__(ob, callback)
             self.__counter = 0
             for k, v in annotations.items():
                 setattr(self, k, v)

         def __call__(self):
             """Return a pair containing the referent and the number of
             times the reference has been called.
             """
             ob = super().__call__()
             if ob is not None:
                 self.__counter += 1
                 ob = (ob, self.__counter)
             return ob


File: python.info,  Node: 使用例<5>,  Next: ファイナライザオブジェクト,  Prev: 弱参照オブジェクト,  Up: weakref --- 弱参照

5.8.9.2 使用例
..............

この簡単な例では、アプリケーションが以前に参照したオブジェクトを取り出す
ためにオブジェクトIDを利用する方法を示します。オブジェクトに生きたままで
あることを強制することなく、オブジェクトの IDを他のデータ構造の中で使う
ことができ、必要に応じてIDからオブジェクトを取り出せます。

     import weakref

     _id2obj_dict = weakref.WeakValueDictionary()

     def remember(obj):
         oid = id(obj)
         _id2obj_dict[oid] = obj
         return oid

     def id2obj(oid):
         return _id2obj_dict[oid]


File: python.info,  Node: ファイナライザオブジェクト,  Next: Comparing finalizers with __del__ methods,  Prev: 使用例<5>,  Up: weakref --- 弱参照

5.8.9.3 ファイナライザオブジェクト
..................................

The main benefit of using *note finalize: a4a. is that it makes it
simple to register a callback without needing to preserve the returned
finalizer object.  For instance

     >>> import weakref
     >>> class Object:
     ...     pass
     ...
     >>> kenny = Object()
     >>> weakref.finalize(kenny, print, "You killed Kenny!")
     <finalize object at ...; for 'Object' at ...>
     >>> del kenny
     You killed Kenny!

ファイナライザは直接呼び出すこともできます。ただし、ファイナライザはコー
ルバックを最大でも一度しか呼び出しません。

     >>> def callback(x, y, z):
     ...     print("CALLBACK")
     ...     return x + y + z
     ...
     >>> obj = Object()
     >>> f = weakref.finalize(obj, callback, 1, 2, z=3)
     >>> assert f.alive
     >>> assert f() == 6
     CALLBACK
     >>> assert not f.alive
     >>> f()                     # callback not called because finalizer dead
     >>> del obj                 # callback not called because finalizer dead

You can unregister a finalizer using its *note detach(): 24b7. method.
This kills the finalizer and returns the arguments passed to the
constructor when it was created.

     >>> obj = Object()
     >>> f = weakref.finalize(obj, callback, 1, 2, z=3)
     >>> f.detach()
     (<...Object object ...>, <function callback ...>, (1, 2), {'z': 3})
     >>> newobj, func, args, kwargs = _
     >>> assert not f.alive
     >>> assert newobj is obj
     >>> assert func(*args, **kwargs) == 6
     CALLBACK

Unless you set the *note atexit: 24ba. attribute to *note False: b05, a
finalizer will be called when the program exits if it is still alive.
For instance

     >>> obj = Object()
     >>> weakref.finalize(obj, print, "obj dead or exiting")
     <finalize object at ...; for 'Object' at ...>
     >>> exit()
     obj dead or exiting


File: python.info,  Node: Comparing finalizers with __del__ methods,  Prev: ファイナライザオブジェクト,  Up: weakref --- 弱参照

5.8.9.4 Comparing finalizers with ‘__del__()’ methods
.....................................................

インスタンスが一時ディレクトリを表す、クラスを作成するとします。そのディ
レクトリは、次のイベントのいずれかが起きた時に、そのディレクトリの内容と
ともに削除されるべきです。

   * オブジェクトのガベージコレクションが行われた場合

   * the object's ‘remove()’ method is called, or

   * プログラムが終了した場合

We might try to implement the class using a *note __del__(): 1ec1.
method as follows:

     class TempDir:
         def __init__(self):
             self.name = tempfile.mkdtemp()

         def remove(self):
             if self.name is not None:
                 shutil.rmtree(self.name)
                 self.name = None

         @property
         def removed(self):
             return self.name is None

         def __del__(self):
             self.remove()

Starting with Python 3.4, *note __del__(): 1ec1. methods no longer
prevent reference cycles from being garbage collected, and module
globals are no longer forced to *note None: 641. during *note
interpreter shutdown: 134.  So this code should work without any issues
on CPython.

However, handling of *note __del__(): 1ec1. methods is notoriously
implementation specific, since it depends on internal details of the
interpreter's garbage collector implementation.

A more robust alternative can be to define a finalizer which only
references the specific functions and objects that it needs, rather than
having access to the full state of the object:

     class TempDir:
         def __init__(self):
             self.name = tempfile.mkdtemp()
             self._finalizer = weakref.finalize(self, shutil.rmtree, self.name)

         def remove(self):
             self._finalizer()

         @property
         def removed(self):
             return not self._finalizer.alive

Defined like this, our finalizer only receives a reference to the
details it needs to clean up the directory appropriately.  If the object
never gets garbage collected the finalizer will still be called at exit.

The other advantage of weakref based finalizers is that they can be used
to register finalizers for classes where the definition is controlled by
a third party, such as running code when a module is unloaded:

     import weakref, sys
     def unloading_module():
         # implicit reference to the module globals from the function body
     weakref.finalize(sys.modules[__name__], unloading_module)

     注釈: If you create a finalizer object in a daemonic thread just as
     the program exits then there is the possibility that the finalizer
     does not get called at exit.  However, in a daemonic thread *note
     atexit.register(): 84a, ‘try: ... finally: ...’ and ‘with: ...’ do
     not guarantee that cleanup occurs either.


File: python.info,  Node: types --- 動的な型生成と組み込み型の名前,  Next: copy --- 浅いコピーおよび深いコピー操作,  Prev: weakref --- 弱参照,  Up: データ型

5.8.10 ‘types’ -- 動的な型生成と組み込み型の名前
------------------------------------------------

'ソースコード:' Lib/types.py(1)

__________________________________________________________________

このモジュールは新しい型の動的な生成を支援するユーティリティ関数を定義し
ます。

さらに、標準の Python インタプリタによって使用されているものの、 *note
int: 238. や *note str: 418. のように組み込みとして公開されていないよう
ないくつかのオブジェクト型の名前を定義しています。

最後に、組み込みになるほど基本的でないような追加の型関連のユーティリティ
と関数をいくつか提供しています。

* Menu:

* 動的な型生成::
* 標準的なインタプリタ型::
* 追加のユーティリティクラスと関数::
* コルーチンユーティリティ関数::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/types.py


File: python.info,  Node: 動的な型生成,  Next: 標準的なインタプリタ型,  Up: types --- 動的な型生成と組み込み型の名前

5.8.10.1 動的な型生成
.....................

 -- の関数: types.new_class (name, bases=(), kwds=None, exec_body=None)

     適切なメタクラスを使用して動的にクラスオブジェクトを生成します。

     最初の3つの引数はクラス定義ヘッダーを構成する—クラス名、基底クラス
     (順番に)、キーワード引数 (例えば ‘metaclass’)—です。

     'exec_body' 引数は、新規に生成されたクラスの名前空間を構築するため
     に使用されるコールバックです。それは唯一の引数としてクラスの名前空
     間を受け取り、クラスの内容で名前空間を直接更新します。コールバック
     が渡されない場合、それは ‘lambda ns: None’ を渡すことと同じ効果があ
     ります。

     Added in version 3.3.

 -- の関数: types.prepare_class (name, bases=(), kwds=None)

     適切なメタクラスを計算してクラスの名前空間を生成します。

     引数はクラス定義ヘッダーを構成する要素—クラス名、基底クラス (順番に
     )、キーワード引数 (例えば ‘metaclass’)—です。

     返り値は ‘metaclass, namespace, kwds’ の3要素のタプルです

     'metaclass' は適切なメタクラスです。'namespace' は用意されたクラス
     の名前空間です。また 'kwds' は、‘'metaclass'’ エントリが削除された
     、渡された 'kwds' 引数の更新されたコピーです。'kwds' 引数が渡されな
     ければ、これは空の dict になります。

     Added in version 3.3.

     バージョン 3.6 で変更: 返されるタプルの ‘namespace’ 要素のデフォル
     ト値が変更されました。 現在では、メタクラスが ‘__prepare__’ メソッ
     ドを持っていないときは、挿入順序を保存するマッピングが使われます。

参考
....

*note メタクラス: 1ed4.

     これらの関数によってサポートされるクラス生成プロセスの完全な詳細

PEP 3115(1) - Metaclasses in Python 3000

     ‘__prepare__’ 名前空間フックの導入

 -- の関数: types.resolve_bases (bases)

     Resolve MRO entries dynamically as specified by PEP 560(2).

     This function looks for items in 'bases' that are not instances of
     *note type: d16, and returns a tuple where each such object that
     has an *note __mro_entries__(): 1ed6. method is replaced with an
     unpacked result of calling this method.  If a 'bases' item is an
     instance of *note type: d16, or it doesn't have an
     ‘__mro_entries__()’ method, then it is included in the return tuple
     unchanged.

     Added in version 3.7.

 -- の関数: types.get_original_bases (cls, /)

     Return the tuple of objects originally given as the bases of 'cls'
     before the *note __mro_entries__(): 1ed6. method has been called on
     any bases (following the mechanisms laid out in PEP 560(3)).  This
     is useful for introspecting *note Generics: 49b.

     For classes that have an ‘__orig_bases__’ attribute, this function
     returns the value of ‘cls.__orig_bases__’.  For classes without the
     ‘__orig_bases__’ attribute, *note cls.__bases__: 1451. is returned.

     例:

          from typing import TypeVar, Generic, NamedTuple, TypedDict

          T = TypeVar("T")
          class Foo(Generic[T]): ...
          class Bar(Foo[int], float): ...
          class Baz(list[str]): ...
          Eggs = NamedTuple("Eggs", [("a", int), ("b", str)])
          Spam = TypedDict("Spam", {"a": int, "b": str})

          assert Bar.__bases__ == (Foo, float)
          assert get_original_bases(Bar) == (Foo[int], float)

          assert Baz.__bases__ == (list,)
          assert get_original_bases(Baz) == (list[str],)

          assert Eggs.__bases__ == (tuple,)
          assert get_original_bases(Eggs) == (NamedTuple,)

          assert Spam.__bases__ == (dict,)
          assert get_original_bases(Spam) == (TypedDict,)

          assert int.__bases__ == (object,)
          assert get_original_bases(int) == (object,)

     Added in version 3.12.

参考
....

PEP 560(4) - typing モジュールとジェネリック型に対する言語コアによるサポ
ート

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3115/

   (2) https://peps.python.org/pep-0560/

   (3) https://peps.python.org/pep-0560/

   (4) https://peps.python.org/pep-0560/


File: python.info,  Node: 標準的なインタプリタ型,  Next: 追加のユーティリティクラスと関数,  Prev: 動的な型生成,  Up: types --- 動的な型生成と組み込み型の名前

5.8.10.2 標準的なインタプリタ型
...............................

このモジュールは、Python インタプリタを実装するために必要な多くの型に対
して名前を提供します。それは、‘listiterator’ 型のような、単に処理中に付
随的に発生するいくつかの型が含まれることを意図的に避けています。

これらの名前は典型的に *note isinstance(): 40e. や *note issubclass():
78c. によるチェックに使われます。

これらのタイプのいずれかをインスタンス化する場合、シグネチャは Python の
バージョンによって異なる可能性があることに注意してください。

以下の型に対して標準的な名前が定義されています:

 -- データ: types.NoneType

     *note None: 641. の型です。

     Added in version 3.10.

 -- データ: types.FunctionType
 -- データ: types.LambdaType

     ユーザ定義の関数と *note lambda: 126d. 式によって生成された関数の型
     です。

     引数 ‘code’ を指定して *note 監査イベント: 1825. ‘function.__new__’
     を送出します。

     この監査イベントは、関数オブジェクトを直接インスタンス化した場合に
     のみ発生し、通常のコンパイル時には発生しません。

 -- データ: types.GeneratorType

     ジェネレータ関数によって生成された *note ジェネレータ: 1035. イテレ
     ータオブジェクトの型です。

 -- データ: types.CoroutineType

     *note async def: 59b. 関数に生成される *note コルーチン: 45e. オブ
     ジェクトです。

     Added in version 3.5.

 -- データ: types.AsyncGeneratorType

     非同期ジェネレータ関数によって作成された *note 非同期ジェネレータ:
     1f99. イテレータオブジェクトの型です。

     Added in version 3.6.

 -- クラス: types.CodeType (**kwargs)

     The type of *note code objects: 1b4. such as returned by *note
     compile(): 177.

     引数 ‘code’, ‘filename’, ‘name’, ‘argcount’, ‘posonlyargcount’,
     ‘kwonlyargcount’, ‘nlocals’, ‘stacksize’, ‘flags’ を指定して *note
     監査イベント: 1825. ‘code.__new__’ を送出します。

     Note that the audited arguments may not match the names or
     positions required by the initializer.  The audit event only occurs
     for direct instantiation of code objects, and is not raised for
     normal compilation.

 -- データ: types.CellType

     The type for cell objects: such objects are used as containers for
     a function's *note closure variables: 1e9f.

     Added in version 3.8.

 -- データ: types.MethodType

     ユーザー定義のクラスのインスタンスのメソッドの型です。

 -- データ: types.BuiltinFunctionType
 -- データ: types.BuiltinMethodType

     *note len(): 5fa. や *note sys.exit(): 1318. のような組み込み関数や
     、組み込み型のメソッドの型です。 (ここでは "組み込み" という単語を
     "Cで書かれた" という意味で使っています)

 -- データ: types.WrapperDescriptorType

     The type of methods of some built-in data types and base classes
     such as *note object.__init__(): 67c. or *note object.__lt__():
     12d9.

     Added in version 3.7.

 -- データ: types.MethodWrapperType

     The type of 'bound' methods of some built-in data types and base
     classes.  For example it is the type of ‘object().__str__’.

     Added in version 3.7.

 -- データ: types.NotImplementedType

     *note NotImplemented: 79d. の型です。

     Added in version 3.10.

 -- データ: types.MethodDescriptorType

     The type of methods of some built-in data types such as *note
     str.join(): 2110.

     Added in version 3.7.

 -- データ: types.ClassMethodDescriptorType

     The type of 'unbound' class methods of some built-in data types
     such as ‘dict.__dict__['fromkeys']’.

     Added in version 3.7.

 -- クラス: types.ModuleType (name, doc=None)

     *note module: 15c3. の型です。コンストラクタは生成するモジュールの
     名前と任意でその *note docstring: 2086. を受け取ります。

     参考
     ....

     *note Documentation on module objects: 1e71.

          Provides details on the special attributes that can be found
          on instances of ‘ModuleType’.

     *note importlib.util.module_from_spec(): ddf.

          Modules created using the ‘ModuleType’ constructor are created
          with many of their special attributes unset or set to default
          values.  ‘module_from_spec()’ provides a more robust way of
          creating ‘ModuleType’ instances which ensures the various
          attributes are set appropriately.

 -- データ: types.EllipsisType

     *note Ellipsis: 20ea. の型です。

     Added in version 3.10.

 -- クラス: types.GenericAlias (t_origin, t_args)

     The type of *note parameterized generics: 67e. such as ‘list[int]’.

     ‘t_origin’ should be a non-parameterized generic class, such as
     ‘list’, ‘tuple’ or ‘dict’.  ‘t_args’ should be a *note tuple: 349.
     (possibly of length 1) of types which parameterize ‘t_origin’:

          >>> from types import GenericAlias

          >>> list[int] == GenericAlias(list, (int,))
          True
          >>> dict[str, int] == GenericAlias(dict, (str, int))
          True

     Added in version 3.9.

     バージョン 3.9.2 で変更: This type can now be subclassed.

     参考
     ....

     *note Generic Alias Types: 67e.

          In-depth documentation on instances of ‘types.GenericAlias’

     PEP 585(1) - 標準コレクション型の型ヒントにおける総称型 (generics) の使用

          Introducing the ‘types.GenericAlias’ class

 -- クラス: types.UnionType

     The type of *note union type expressions: 78d.

     Added in version 3.10.

 -- クラス: types.TracebackType (tb_next, tb_frame, tb_lasti, tb_lineno)

     ‘sys.exception().__traceback__’ に含まれるようなトレースバックオブ
     ジェクトの型です。

     See *note the language reference: ac2. for details of the available
     attributes and operations, and guidance on creating tracebacks
     dynamically.

 -- データ: types.FrameType

     The type of *note frame objects: 6ab. such as found in *note
     tb.tb_frame: 1eb2. if ‘tb’ is a traceback object.

 -- データ: types.GetSetDescriptorType

     The type of objects defined in extension modules with
     ‘PyGetSetDef’, such as *note FrameType.f_locals: 167. or
     ‘array.array.typecode’.  This type is used as descriptor for object
     attributes; it has the same purpose as the *note property: 179.
     type, but for classes defined in extension modules.

 -- データ: types.MemberDescriptorType

     ‘datetime.timedelta.days’ のような、拡張モジュールにおいて
     ‘PyMemberDef’ によって定義されたオブジェクトの型です。この型は、標
     準の変換関数を利用するような、Cのシンプルなデータメンバで利用されま
     す。 *note property: 179. 型と同じ目的を持った型ですが、こちらは拡
     張モジュールで定義された型のためのものです。

     In addition, when a class is defined with a *note __slots__: 1493.
     attribute, then for each slot, an instance of
     ‘MemberDescriptorType’ will be added as an attribute on the class.
     This allows the slot to appear in the class's *note __dict__: c2b.

     'CPython 実装の詳細:' Pythonの他の実装では、この型は
     ‘GetSetDescriptorType’ と同じかもしれません。

 -- クラス: types.MappingProxyType (mapping)

     読み出し専用のマッピングのプロキシです。マッピングのエントリーに関
     する動的なビューを提供します。つまり、マッピングが変わった場合にビ
     ューがこれらの変更を反映するということです。

     Added in version 3.3.

     バージョン 3.9 で変更: Updated to support the new union (‘|’)
     operator from PEP 584(2), which simply delegates to the underlying
     mapping.

      -- Describe: key in proxy

          元になったマッピングが 'key' というキーを持っている場合 ‘True’
          を返します。そうでなければ ‘False’ を返します。

      -- Describe: proxy[key]

          元になったマッピングの 'key' というキーに対応するアイテムを返
          します。 'key' が存在しなければ、 *note KeyError: 31d. が発生
          します。

      -- Describe: iter(proxy)

          元になったマッピングのキーを列挙するイテレータを返します。これ
          は ‘iter(proxy.keys())’ のショートカットです。

      -- Describe: len(proxy)

          元になったマッピングに含まれるアイテムの数を返します。

      -- メソッド: copy ()

          元になったマッピングの浅いコピーを返します。

      -- メソッド: get (key[, default])

          'key' が元になったマッピングに含まれている場合 'key' に対する
          値を返し、そうでなければ 'default' を返します。もし 'default'
          が与えられない場合は、デフォルト値の ‘None’ になります。そのた
          め、このメソッドが *note KeyError: 31d. を発生させることはあり
          ません。

      -- メソッド: items ()

          元になったマッピングの items (‘(key, value)’ ペアの列) に対す
          る新しいビューを返します。

      -- メソッド: keys ()

          元になったマッピングの keys に対する新しいビューを返します。

      -- メソッド: values ()

          元になったマッピングの values に対する新しいビューを返します。

      -- Describe: reversed(proxy)

          Return a reverse iterator over the keys of the underlying
          mapping.

          Added in version 3.9.

      -- Describe: hash(proxy)

          Return a hash of the underlying mapping.

          Added in version 3.12.

 -- クラス: types.CapsuleType

     The type of *note capsule objects: 24d4.

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://peps.python.org/pep-0584/


File: python.info,  Node: 追加のユーティリティクラスと関数,  Next: コルーチンユーティリティ関数,  Prev: 標準的なインタプリタ型,  Up: types --- 動的な型生成と組み込み型の名前

5.8.10.3 追加のユーティリティクラスと関数
.........................................

 -- クラス: types.SimpleNamespace

     名前空間への属性アクセスに加えて意味のある repr を提供するための、
     単純な *note object: a5a. サブクラスです。

     Unlike *note object: a5a, with ‘SimpleNamespace’ you can add and
     remove attributes.

     *note SimpleNamespace: 1b3. objects may be initialized in the same
     way as *note dict: 237.: either with keyword arguments, with a
     single positional argument, or with both.  When initialized with
     keyword arguments, those are directly added to the underlying
     namespace.  Alternatively, when initialized with a positional
     argument, the underlying namespace will be updated with key-value
     pairs from that argument (either a mapping object or an *note
     iterable: 10ad. object producing key-value pairs).  All such keys
     must be strings.

     この型は以下のコードとほぼ等価です:

          class SimpleNamespace:
              def __init__(self, mapping_or_iterable=(), /, **kwargs):
                  self.__dict__.update(mapping_or_iterable)
                  self.__dict__.update(kwargs)

              def __repr__(self):
                  items = (f"{k}={v!r}" for k, v in self.__dict__.items())
                  return "{}({})".format(type(self).__name__, ", ".join(items))

              def __eq__(self, other):
                  if isinstance(self, SimpleNamespace) and isinstance(other, SimpleNamespace):
                     return self.__dict__ == other.__dict__
                  return NotImplemented

     ‘SimpleNamespace’ は ‘class NS: pass’ を置き換えるものとして有用か
     もしれません。ですが、構造化されたレコード型に対しては、これよりは
     むしろ *note namedtuple(): 1ac. を使用してください。

     ‘SimpleNamespace’ objects are supported by *note copy.replace():
     137.

     Added in version 3.3.

     バージョン 3.9 で変更: Attribute order in the repr changed from
     alphabetical to insertion (like ‘dict’).

     バージョン 3.13 で変更: Added support for an optional positional
     argument.

 -- の関数: types.DynamicClassAttribute (fget=None, fset=None,
          fdel=None, doc=None)

     クラスの属性アクセスを __getattr__ に振り替えます。

     これは記述子で、インスタンス経由のアクセスとクラス経由のアクセスで
     振る舞いが異なる属性を定義するのに使います。インスタンスアクセスは
     通常通りですが、クラス経由の属性アクセスはクラスの __getattr__ メソ
     ッドに振り替えられます。これは AttributeError の送出により行われま
     す。

     これによって、インスタンス上で有効なプロパティを持ち、クラス上で同
     名の仮想属性を持つことができます (例については *note enum.Enum:
     5fc. を参照してください)。

     Added in version 3.4.


File: python.info,  Node: コルーチンユーティリティ関数,  Prev: 追加のユーティリティクラスと関数,  Up: types --- 動的な型生成と組み込み型の名前

5.8.10.4 コルーチンユーティリティ関数
.....................................

 -- の関数: types.coroutine (gen_func)

     この関数は、 *note generator: 1035. 関数を、ジェネレータベースのコ
     ルーチンを返す *note coroutine function: d44. に変換します。返され
     るジェネレータベースのコルーチンは依然として *note generator
     iterator: bac. ですが、同時に *note coroutine: 45e. オブジェクトか
     つ *note awaitable: 192. であるとみなされます。ただし、必ずしも
     *note __await__(): 1f28. メソッドを実装する必要はありません。

     'gen_func' はジェネレータ関数で、インプレースに変更されます。

     'gen_func' がジェネレータ関数でない場合、この関数はラップされます。
     この関数が *note collections.abc.Generator: da8. のインスタンスを返
     す場合、このインスタンスは 'awaitable' なプロキシオブジェクトにラッ
     プされます。それ以外のすべての型のオブジェクトは、そのまま返されま
     す。

     Added in version 3.5.


File: python.info,  Node: copy --- 浅いコピーおよび深いコピー操作,  Next: pprint --- データの整形表示,  Prev: types --- 動的な型生成と組み込み型の名前,  Up: データ型

5.8.11 ‘copy’ -- 浅いコピーおよび深いコピー操作
-----------------------------------------------

'ソースコード:' Lib/copy.py(1)

__________________________________________________________________

Python において代入文はオブジェクトをコピーしません。代入はターゲットと
オブジェクトの間に束縛を作ります。ミュータブルなコレクションまたはミュー
タブルなアイテムを含むコレクションについては、元のオブジェクトを変更せず
にコピーを変更できるように、コピーが必要になることが時々あります。このモ
ジュールは、汎用的な浅い (shallow) コピーと深い (deep) コピーの操作 (以
下で説明されます) を提供します。

以下にインターフェースをまとめます:

 -- の関数: copy.copy (obj)

     Return a shallow copy of 'obj'.

 -- の関数: copy.deepcopy (obj[, memo])

     Return a deep copy of 'obj'.

 -- の関数: copy.replace (obj, /, **changes)

     Creates a new object of the same type as 'obj', replacing fields
     with values from 'changes'.

     Added in version 3.13.

 -- 例外: copy.Error

     モジュール特有のエラーを送出します。
浅い (shallow) コピーと深い (deep) コピーの違いが関係するのは、複合オブ
ジェクト (リストやクラスインスタンスのような他のオブジェクトを含むオブジ
ェクト) だけです:

   * '浅いコピー (shallow copy)' は新たな複合オブジェクトを作成し、その
     後 (可能な限り) 元のオブジェクト中に見つかったオブジェクトに対する
     '参照' を挿入します。

   * '深いコピー (deep copy)' は新たな複合オブジェクトを作成し、その後元
     のオブジェクト中に見つかったオブジェクトの 'コピー' を挿入します。

深いコピー操作には、しばしば浅いコピー操作の時には存在しない 2 つの問題
がついてまわります:

   * 再帰的なオブジェクト (直接、間接に関わらず、自分自身に対する参照を
     持つ複合オブジェクト) は再帰ループを引き起こします。

   * 深いコピーは何もかもコピーしてしまうため、例えば複数のコピー間で共
     有するつもりだったデータも余分にコピーしてしまいます。

*note deepcopy(): b3c. 関数では、これらの問題を以下のようにして回避して
います:

   * 現時点でのコピー過程ですでにコピーされたオブジェクトの ‘memo’ 辞書
     を保持する。

   * ユーザ定義のクラスでコピー操作やコピーされる内容の集合を上書きでき
     るようにする。

このモジュールでは、モジュール、メソッド、スタックトレース、スタックフレ
ーム、ファイル、ソケット、ウィンドウ、その他これらに類似の型をコピーしま
せん。このモジュールでは元のオブジェクトを変更せずに返すことで関数とクラ
スを (浅くまたは深く)「コピー」します。これは *note pickle: 95. モジュー
ルでの扱われかたと同じです。

辞書型の浅いコピーは *note dict.copy(): b9e. で、リストの浅いコピーはリ
スト全体を指すスライス (例えば ‘copied_list = original_list[:]’) ででき
ます。

クラスは、コピーを制御するために pickle の制御に使用するのと同じインター
フェースを使用することができます。これらのメソッドについての情報はモジュ
ール *note pickle: 95. の説明を参照してください。実際、 *note copy: 1e.
モジュールは、 *note copyreg: 1f. モジュールによって登録された pickle 関
数を使用します。

In order for a class to define its own copy implementation, it can
define special methods *note __copy__(): 24da. and *note __deepcopy__():
24db.

 -- メソッド: object.__copy__ (self)

     Called to implement the shallow copy operation; no additional
     arguments are passed.

 -- メソッド: object.__deepcopy__ (self, memo)

     Called to implement the deep copy operation; it is passed one
     argument, the 'memo' dictionary.  If the ‘__deepcopy__’
     implementation needs to make a deep copy of a component, it should
     call the *note deepcopy(): b3c. function with the component as
     first argument and the 'memo' dictionary as second argument.  The
     'memo' dictionary should be treated as an opaque object.

Function ‘copy.replace()’ is more limited than *note copy(): 4fd. and
*note deepcopy(): b3c, and only supports named tuples created by *note
namedtuple(): 1ac, *note dataclasses: 27, and other classes which define
method *note __replace__(): 138.

 -- メソッド: object.__replace__ (self, /, **changes)

     This method should create a new object of the same type, replacing
     fields with values from 'changes'.

参考
....

*note pickle: 95. モジュール

     オブジェクト状態の取得と復元をサポートするために使われる特殊メソッ
     ドについて議論されています。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/copy.py


File: python.info,  Node: pprint --- データの整形表示,  Next: reprlib --- もう一つの repr の実装,  Prev: copy --- 浅いコピーおよび深いコピー操作,  Up: データ型

5.8.12 ‘pprint’ -- データの整形表示
-----------------------------------

'ソースコード:' Lib/pprint.py(1)

__________________________________________________________________

*note pprint: 9c. モジュールを使うと、Pythonの任意のデータ構造をインター
プリタへの入力で使われる形式にして "pretty-print" できます。書式化された
構造の中にPythonの基本的なタイプではないオブジェクトがあるなら、表示でき
ないかもしれません。表示できないのは、ファイル、ソケット、あるいはクラス
のようなオブジェクトや、 その他Pythonのリテラルとして表現できない様々な
オブジェクトが含まれていた場合です。

The formatted representation keeps objects on a single line if it can,
and breaks them onto multiple lines if they don't fit within the allowed
width, adjustable by the 'width' parameter defaulting to 80 characters.

辞書は表示される前にキーの順でソートされます。

バージョン 3.9 で変更: *note types.SimpleNamespace: 1b3. の pretty-print
サポートが追加されました。

バージョン 3.10 で変更: *note dataclasses.dataclass: 1ad. の
pretty-print サポートが追加されました。

* Menu:

* 関数: 関数<4>.
* PrettyPrinter オブジェクト::
* 使用例: 使用例<6>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pprint.py


File: python.info,  Node: 関数<4>,  Next: PrettyPrinter オブジェクト,  Up: pprint --- データの整形表示

5.8.12.1 関数
.............

 -- の関数: pprint.pp (object, stream=None, indent=1, width=80,
          depth=None, *, compact=False, sort_dicts=False,
          underscore_numbers=False)

     Prints the formatted representation of 'object', followed by a
     newline.  This function may be used in the interactive interpreter
     instead of the *note print(): f42. function for inspecting values.
     Tip: you can reassign ‘print = pprint.pp’ for use within a scope.


     パラメータ:

        * ‘object’ - The object to be printed.

        * ‘stream’ (*note file-like object: 24e0. | None) - A file-like
          object to which the output will be written by calling its
          ‘write()’ method.  If ‘None’ (the default), *note sys.stdout:
          aa4. is used.

        * ‘indent’ (*note int: 238.) - The amount of indentation added
          for each nesting level.

        * ‘width’ (*note int: 238.) - The desired maximum number of
          characters per line in the output.  If a structure cannot be
          formatted within the width constraint, a best effort will be
          made.

        * ‘depth’ (*note int: 238.‘ | ’‘None’) - The number of nesting
          levels which may be printed.  If the data structure being
          printed is too deep, the next contained level is replaced by
          ‘...’.  If ‘None’ (the default), there is no constraint on the
          depth of the objects being formatted.

        * ‘compact’ (*note bool: 434.) - Control the way long *note
          sequences: 4be. are formatted.  If ‘False’ (the default), each
          item of a sequence will be formatted on a separate line,
          otherwise as many items as will fit within the 'width' will be
          formatted on each output line.

        * ‘sort_dicts’ (*note bool: 434.) - If ‘True’, dictionaries will
          be formatted with their keys sorted, otherwise they will be
          displayed in insertion order (the default).

        * ‘underscore_numbers’ (*note bool: 434.) - If ‘True’, integers
          will be formatted with the ‘_’ character for a thousands
          separator, otherwise underscores are not displayed (the
          default).

          >>> import pprint
          >>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
          >>> stuff.insert(0, stuff)
          >>> pprint.pp(stuff)
          [<Recursion on list with id=...>,
           'spam',
           'eggs',
           'lumberjack',
           'knights',
           'ni']

     Added in version 3.8.

 -- の関数: pprint.pprint (object, stream=None, indent=1, width=80,
          depth=None, *, compact=False, sort_dicts=True,
          underscore_numbers=False)

     Alias for *note pp(): 9f1. with 'sort_dicts' set to ‘True’ by
     default, which would automatically sort the dictionaries' keys, you
     might want to use *note pp(): 9f1. instead where it is ‘False’ by
     default.

 -- の関数: pprint.pformat (object, indent=1, width=80, depth=None, *,
          compact=False, sort_dicts=True, underscore_numbers=False)

     Return the formatted representation of 'object' as a string.
     'indent', 'width', 'depth', 'compact', 'sort_dicts' and
     'underscore_numbers' are passed to the *note PrettyPrinter: f4c.
     constructor as formatting parameters and their meanings are as
     described in the documentation above.

 -- の関数: pprint.isreadable (object)

     'object' を書式化して出力できる("readable") か、あるいは *note
     eval(): 165. を使って値を再構成できるかを返します。再帰的なオブジェ
     クトに対しては常に ‘False’ を返します。

          >>> pprint.isreadable(stuff)
          False

 -- の関数: pprint.isrecursive (object)

     Determine if 'object' requires a recursive representation.  This
     function is subject to the same limitations as noted in *note
     saferepr(): 24e3. below and may raise an *note RecursionError: d39.
     if it fails to detect a recursive object.

 -- の関数: pprint.saferepr (object)

     Return a string representation of 'object', protected against
     recursion in some common data structures, namely instances of *note
     dict: 237, *note list: 5dc. and *note tuple: 349. or subclasses
     whose ‘__repr__’ has not been overridden.  If the representation of
     object exposes a recursive entry, the recursive reference will be
     represented as ‘<Recursion on typename with id=number>’.  The
     representation is not otherwise formatted.

          >>> pprint.saferepr(stuff)
          "[<Recursion on list with id=...>, 'spam', 'eggs', 'lumberjack', 'knights', 'ni']"


File: python.info,  Node: PrettyPrinter オブジェクト,  Next: 使用例<6>,  Prev: 関数<4>,  Up: pprint --- データの整形表示

5.8.12.2 PrettyPrinter オブジェクト
...................................

 -- クラス: pprint.PrettyPrinter (indent=1, width=80, depth=None,
          stream=None, *, compact=False, sort_dicts=True,
          underscore_numbers=False)

     Construct a *note PrettyPrinter: f4c. instance.

     Arguments have the same meaning as for *note pp(): 9f1.  Note that
     they are in a different order, and that 'sort_dicts' defaults to
     ‘True’.

          >>> import pprint
          >>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
          >>> stuff.insert(0, stuff[:])
          >>> pp = pprint.PrettyPrinter(indent=4)
          >>> pp.pprint(stuff)
          [   ['spam', 'eggs', 'lumberjack', 'knights', 'ni'],
              'spam',
              'eggs',
              'lumberjack',
              'knights',
              'ni']
          >>> pp = pprint.PrettyPrinter(width=41, compact=True)
          >>> pp.pprint(stuff)
          [['spam', 'eggs', 'lumberjack',
            'knights', 'ni'],
           'spam', 'eggs', 'lumberjack', 'knights',
           'ni']
          >>> tup = ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead',
          ... ('parrot', ('fresh fruit',))))))))
          >>> pp = pprint.PrettyPrinter(depth=6)
          >>> pp.pprint(tup)
          ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...)))))))

     バージョン 3.4 で変更: 'compact' 引数が追加されました。

     バージョン 3.8 で変更: 'sort_dicts' 引数が追加されました。

     バージョン 3.10 で変更: 'underscore_numbers' 引数が追加されました。

     バージョン 3.11 で変更: No longer attempts to write to ‘sys.stdout’
     if it is ‘None’.

*note PrettyPrinter: f4c. インスタンスには以下のメソッドがあります:

 -- メソッド: PrettyPrinter.pformat (object)

     'object' の書式化した表現を返します。これは *note PrettyPrinter:
     f4c. のコンストラクタに渡されたオプションを考慮して書式化されます。

 -- メソッド: PrettyPrinter.pprint (object)

     'object' の書式化した表現を指定したストリームに出力し、最後に改行し
     ます。

以下のメソッドは、対応する同じ名前の関数と同じ機能を持っています。以下の
メソッドをインスタンスに対して使うと、新たに *note PrettyPrinter: f4c. オ
ブジェクトを作る必要がないのでちょっぴり効果的です。

 -- メソッド: PrettyPrinter.isreadable (object)

     'object' を書式化して出力できる（"readable"）か、あるいは *note
     eval(): 165. を使って値を再構成できるかを返します。これは再帰的なオ
     ブジェクトに対して ‘False’ を返すことに注意して下さい。もし *note
     PrettyPrinter: f4c. の 'depth' 引数が設定されていて、オブジェクトの
     レベルが設定よりも深かったら、 ‘False’ を返します。

 -- メソッド: PrettyPrinter.isrecursive (object)

     オブジェクトが再帰的な表現かどうかを返します。

このメソッドをフックとして、サブクラスがオブジェクトを文字列に変換する方
法を修正するのが可能になっています。デフォルトの実装では、内部で *note
saferepr(): 24e3. を呼び出しています。

 -- メソッド: PrettyPrinter.format (object, context, maxlevels, level)

     次の3つの値を返します。'object' をフォーマット化して文字列にしたも
     の、その結果が読み込み可能かどうかを示すフラグ、再帰が含まれている
     かどうかを示すフラグ。最初の引数は表示するオブジェクトです。 2つめ
     の引数はオブジェクトの *note id(): 13ca. をキーとして含むディクショ
     ナリで、オブジェクトを含んでいる現在の（直接、間接に 'object' のコ
     ンテナとして表示に影響を与える）環境です。ディクショナリ 'context'
     の中でどのオブジェクトが表示されたか表示する必要があるなら、3つめの
     返り値は ‘True’ になります。 *note format(): 1889. メソッドの再帰呼
     び出しではこのディクショナリのコンテナに対してさらにエントリを加え
     ます。 3つめの引数 'maxlevels' で再帰呼び出しのレベルを制限します。
     制限しない場合、 ‘0’ になります。この引数は再帰呼び出しでそのまま渡
     されます。 4つめの引数 'level' で現在のレベルを設定します。再帰呼び
     出しでは、現在の呼び出しより小さい値が渡されます。


File: python.info,  Node: 使用例<6>,  Prev: PrettyPrinter オブジェクト,  Up: pprint --- データの整形表示

5.8.12.3 使用例
...............

To demonstrate several uses of the *note pp(): 9f1. function and its
parameters, let's fetch information about a project from PyPI(1):

     >>> import json
     >>> import pprint
     >>> from urllib.request import urlopen
     >>> with urlopen('https://pypi.org/pypi/sampleproject/1.2.0/json') as resp:
     ...     project_info = json.load(resp)['info']

In its basic form, *note pp(): 9f1. shows the whole object:

     >>> pprint.pp(project_info)
     {'author': 'The Python Packaging Authority',
      'author_email': 'pypa-dev@googlegroups.com',
      'bugtrack_url': None,
      'classifiers': ['Development Status :: 3 - Alpha',
                      'Intended Audience :: Developers',
                      'License :: OSI Approved :: MIT License',
                      'Programming Language :: Python :: 2',
                      'Programming Language :: Python :: 2.6',
                      'Programming Language :: Python :: 2.7',
                      'Programming Language :: Python :: 3',
                      'Programming Language :: Python :: 3.2',
                      'Programming Language :: Python :: 3.3',
                      'Programming Language :: Python :: 3.4',
                      'Topic :: Software Development :: Build Tools'],
      'description': 'A sample Python project\n'
                     '=======================\n'
                     '\n'
                     'This is the description file for the project.\n'
                     '\n'
                     'The file should use UTF-8 encoding and be written using '
                     'ReStructured Text. It\n'
                     'will be used to generate the project webpage on PyPI, and '
                     'should be written for\n'
                     'that purpose.\n'
                     '\n'
                     'Typical contents for this file would include an overview of '
                     'the project, basic\n'
                     'usage examples, etc. Generally, including the project '
                     'changelog in here is not\n'
                     'a good idea, although a simple "What\'s New" section for the '
                     'most recent version\n'
                     'may be appropriate.',
      'description_content_type': None,
      'docs_url': None,
      'download_url': 'UNKNOWN',
      'downloads': {'last_day': -1, 'last_month': -1, 'last_week': -1},
      'home_page': 'https://github.com/pypa/sampleproject',
      'keywords': 'sample setuptools development',
      'license': 'MIT',
      'maintainer': None,
      'maintainer_email': None,
      'name': 'sampleproject',
      'package_url': 'https://pypi.org/project/sampleproject/',
      'platform': 'UNKNOWN',
      'project_url': 'https://pypi.org/project/sampleproject/',
      'project_urls': {'Download': 'UNKNOWN',
                       'Homepage': 'https://github.com/pypa/sampleproject'},
      'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
      'requires_dist': None,
      'requires_python': None,
      'summary': 'A sample Python project',
      'version': '1.2.0'}

結果をある深さ 'depth' に制限することができます (より深い内容には省略記
号が使用されます):

     >>> pprint.pp(project_info, depth=1)
     {'author': 'The Python Packaging Authority',
      'author_email': 'pypa-dev@googlegroups.com',
      'bugtrack_url': None,
      'classifiers': [...],
      'description': 'A sample Python project\n'
                     '=======================\n'
                     '\n'
                     'This is the description file for the project.\n'
                     '\n'
                     'The file should use UTF-8 encoding and be written using '
                     'ReStructured Text. It\n'
                     'will be used to generate the project webpage on PyPI, and '
                     'should be written for\n'
                     'that purpose.\n'
                     '\n'
                     'Typical contents for this file would include an overview of '
                     'the project, basic\n'
                     'usage examples, etc. Generally, including the project '
                     'changelog in here is not\n'
                     'a good idea, although a simple "What\'s New" section for the '
                     'most recent version\n'
                     'may be appropriate.',
      'description_content_type': None,
      'docs_url': None,
      'download_url': 'UNKNOWN',
      'downloads': {...},
      'home_page': 'https://github.com/pypa/sampleproject',
      'keywords': 'sample setuptools development',
      'license': 'MIT',
      'maintainer': None,
      'maintainer_email': None,
      'name': 'sampleproject',
      'package_url': 'https://pypi.org/project/sampleproject/',
      'platform': 'UNKNOWN',
      'project_url': 'https://pypi.org/project/sampleproject/',
      'project_urls': {...},
      'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
      'requires_dist': None,
      'requires_python': None,
      'summary': 'A sample Python project',
      'version': '1.2.0'}

それに加えて、最大の文字幅 'width' を指示することもできます。長いオブジ
ェクトを分離することができなければ、指定された幅を超過します:

     >>> pprint.pp(project_info, depth=1, width=60)
     {'author': 'The Python Packaging Authority',
      'author_email': 'pypa-dev@googlegroups.com',
      'bugtrack_url': None,
      'classifiers': [...],
      'description': 'A sample Python project\n'
                     '=======================\n'
                     '\n'
                     'This is the description file for the '
                     'project.\n'
                     '\n'
                     'The file should use UTF-8 encoding and be '
                     'written using ReStructured Text. It\n'
                     'will be used to generate the project '
                     'webpage on PyPI, and should be written '
                     'for\n'
                     'that purpose.\n'
                     '\n'
                     'Typical contents for this file would '
                     'include an overview of the project, '
                     'basic\n'
                     'usage examples, etc. Generally, including '
                     'the project changelog in here is not\n'
                     'a good idea, although a simple "What\'s '
                     'New" section for the most recent version\n'
                     'may be appropriate.',
      'description_content_type': None,
      'docs_url': None,
      'download_url': 'UNKNOWN',
      'downloads': {...},
      'home_page': 'https://github.com/pypa/sampleproject',
      'keywords': 'sample setuptools development',
      'license': 'MIT',
      'maintainer': None,
      'maintainer_email': None,
      'name': 'sampleproject',
      'package_url': 'https://pypi.org/project/sampleproject/',
      'platform': 'UNKNOWN',
      'project_url': 'https://pypi.org/project/sampleproject/',
      'project_urls': {...},
      'release_url': 'https://pypi.org/project/sampleproject/1.2.0/',
      'requires_dist': None,
      'requires_python': None,
      'summary': 'A sample Python project',
      'version': '1.2.0'}

   ---------- Footnotes ----------

   (1) https://pypi.org


File: python.info,  Node: reprlib --- もう一つの repr の実装,  Next: enum --- 列挙型のサポート,  Prev: pprint --- データの整形表示,  Up: データ型

5.8.13 ‘reprlib’ -- もう一つの ‘repr()’ の実装
----------------------------------------------

'ソースコード:' Lib/reprlib.py(1)

__________________________________________________________________

‘reprlib’ モジュールは、結果の文字列のサイズに対する制限付きでオブジェク
ト表現を生成するための手段を提供します。これは Python デバッガの中で使用
されており、他の文脈でも同様に役に立つかもしれません。

このモジュールはクラスとインスタンス、それに関数を提供します:

 -- クラス: reprlib.Repr (*, maxlevel=6, maxtuple=6, maxlist=6,
          maxarray=5, maxdict=4, maxset=6, maxfrozenset=6, maxdeque=6,
          maxstring=30, maxlong=40, maxother=30, fillvalue='...',
          indent=None)

     組み込み関数 *note repr(): 7c8. に似た関数を実装するために役に立つ
     フォーマット用サービスを提供します。 過度に長い表現を作り出さないよ
     うにするための大きさの制限をオブジェクト型ごとに設定できます。

     The keyword arguments of the constructor can be used as a shortcut
     to set the attributes of the *note Repr: 24ee. instance.  Which
     means that the following initialization:

          aRepr = reprlib.Repr(maxlevel=3)

     は、次のコードと等しいです:

          aRepr = reprlib.Repr()
          aRepr.maxlevel = 3

     See section *note Repr Objects: 24ef. for more information about
     *note Repr: 24ee. attributes.

     バージョン 3.12 で変更: Allow attributes to be set via keyword
     arguments.

 -- データ: reprlib.aRepr

     これは下で説明される *note repr(): 24f1. 関数を提供するために使われ
     る *note Repr: 24ee. のインスタンスです。このオブジェクトの属性を変
     更すると、 *note repr(): 24f1. と Python デバッガが使うサイズ制限に
     影響します。

 -- の関数: reprlib.repr (obj)

     これは ‘aRepr’ の *note repr(): 24f2. メソッドです。同じ名前の組み
     込み関数が返す文字列と似ていますが、最大サイズに制限のある文字列を
     返します。

In addition to size-limiting tools, the module also provides a decorator
for detecting recursive calls to *note __repr__(): 5e8. and substituting
a placeholder string instead.

 -- の関数: @reprlib.recursive_repr (fillvalue='...')

     Decorator for *note __repr__(): 5e8. methods to detect recursive
     calls within the same thread.  If a recursive call is made, the
     'fillvalue' is returned, otherwise, the usual ‘__repr__()’ call is
     made.  For example:

          >>> from reprlib import recursive_repr
          >>> class MyList(list):
          ...     @recursive_repr()
          ...     def __repr__(self):
          ...         return '<' + '|'.join(map(repr, self)) + '>'
          ...
          >>> m = MyList('abc')
          >>> m.append(m)
          >>> m.append('x')
          >>> print(m)
          <'a'|'b'|'c'|...|'x'>

     Added in version 3.2.

* Menu:

* Reprオブジェクト::
* Reprオブジェクトをサブクラス化する::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/reprlib.py


File: python.info,  Node: Reprオブジェクト,  Next: Reprオブジェクトをサブクラス化する,  Up: reprlib --- もう一つの repr の実装

5.8.13.1 Reprオブジェクト
.........................

*note Repr: 24ee. インスタンスはオブジェクト型毎に表現する文字列のサイズ
を制限するために使えるいくつかの属性と、特定のオブジェクト型をフォーマッ
トするメソッドを提供します。

 -- の属性: Repr.fillvalue

     This string is displayed for recursive references.  It defaults to
     ‘...’.

     Added in version 3.11.

 -- の属性: Repr.maxlevel

     再帰的な表現を作る場合の深さ制限。デフォルトは ‘6’ です。

 -- の属性: Repr.maxdict
 -- の属性: Repr.maxlist
 -- の属性: Repr.maxtuple
 -- の属性: Repr.maxset
 -- の属性: Repr.maxfrozenset
 -- の属性: Repr.maxdeque
 -- の属性: Repr.maxarray

     指定されたオブジェクト型に対するエントリ表現の数についての制限。
     *note maxdict: 24f6. に対するデフォルトは ‘4’ で、 *note maxarray:
     24fc. は ‘5’ 、その他に対しては ‘6’ です。

 -- の属性: Repr.maxlong

     整数の表現のおける文字数の最大値。中央の数字が抜け落ちます。デフォ
     ルトは ‘40’ です。

 -- の属性: Repr.maxstring

     文字列の表現における文字数の制限。文字列の"通常の"表現は文字の「元
     」として使われることに注意してください。表現にエスケープシーケンス
     が必要とされる場合、表現が短縮されるときにこれらのエスケープシーケ
     ンスの形式は崩れます。デフォルトは ‘30’ です。

 -- の属性: Repr.maxother

     この制限は *note Repr: 24ee. オブジェクトに利用できる特定のフォーマ
     ットメソッドがないオブジェクト型のサイズをコントロールするために使
     われます。 *note maxstring: 24fe. と同じようなやり方で適用されます
     。デフォルトは ‘20’ です。

 -- の属性: Repr.indent

     If this attribute is set to ‘None’ (the default), the output is
     formatted with no line breaks or indentation, like the standard
     *note repr(): 7c8.  For example:

          >>> example = [
          ...     1, 'spam', {'a': 2, 'b': 'spam eggs', 'c': {3: 4.5, 6: []}}, 'ham']
          >>> import reprlib
          >>> aRepr = reprlib.Repr()
          >>> print(aRepr.repr(example))
          [1, 'spam', {'a': 2, 'b': 'spam eggs', 'c': {3: 4.5, 6: []}}, 'ham']

     If *note indent: 2500. is set to a string, each recursion level is
     placed on its own line, indented by that string:

          >>> aRepr.indent = '-->'
          >>> print(aRepr.repr(example))
          [
          -->1,
          -->'spam',
          -->{
          -->-->'a': 2,
          -->-->'b': 'spam eggs',
          -->-->'c': {
          -->-->-->3: 4.5,
          -->-->-->6: [],
          -->-->},
          -->},
          -->'ham',
          ]

     Setting *note indent: 2500. to a positive integer value behaves as
     if it was set to a string with that number of spaces:

          >>> aRepr.indent = 4
          >>> print(aRepr.repr(example))
          [
              1,
              'spam',
              {
                  'a': 2,
                  'b': 'spam eggs',
                  'c': {
                      3: 4.5,
                      6: [],
                  },
              },
              'ham',
          ]

     Added in version 3.12.

 -- メソッド: Repr.repr (obj)

     このインスタンスで設定されたフォーマットを使う、組み込み *note
     repr(): 7c8. と等価なもの。

 -- メソッド: Repr.repr1 (obj, level)

     *note repr(): 24f2. が使う再帰的な実装。 'obj' の型を使ってどのフォ
     ーマットメソッドを呼び出すかを決定し、それに 'obj' と 'level' を渡
     します。 再帰呼び出しにおいて 'level' の値に対して ‘level - 1’ を与
     える再帰的なフォーマットを実行するために、型に固有のメソッドは
     *note repr1(): 2501. を呼び出します。

 -- メソッド: Repr.repr_TYPE (obj, level)

     型名に基づく名前をもつメソッドとして、特定の型に対するフォーマット
     メソッドは実装されます。メソッド名では、 'TYPE' は
     ‘'_'.join(type(obj).__name__.split())’ に置き換えられます。これらの
     メソッドへのディスパッチは *note repr1(): 2501. によって処理されま
     す。再帰的に値をフォーマットする必要がある型固有のメソッドは、
     ‘self.repr1(subobj, level - 1)’ を呼び出します。


File: python.info,  Node: Reprオブジェクトをサブクラス化する,  Prev: Reprオブジェクト,  Up: reprlib --- もう一つの repr の実装

5.8.13.2 Reprオブジェクトをサブクラス化する
...........................................

The use of dynamic dispatching by *note Repr.repr1(): 2501. allows
subclasses of *note Repr: 24ee. to add support for additional built-in
object types or to modify the handling of types already supported.  This
example shows how special support for file objects could be added:

     import reprlib
     import sys

     class MyRepr(reprlib.Repr):

         def repr_TextIOWrapper(self, obj, level):
             if obj.name in {'<stdin>', '<stdout>', '<stderr>'}:
                 return obj.name
             return repr(obj)

     aRepr = MyRepr()
     print(aRepr.repr(sys.stdin))         # prints '<stdin>'

     <stdin>


File: python.info,  Node: enum --- 列挙型のサポート,  Next: graphlib --- グラフ構造を操作する機能,  Prev: reprlib --- もう一つの repr の実装,  Up: データ型

5.8.14 ‘enum’ -- 列挙型のサポート
---------------------------------

Added in version 3.4.

'ソースコード:' Lib/enum.py(1)

Important
.........

このページには、リファレンス情報だけが含まれています。チュートリアルは、
以下のページを参照してください

   * *note 基本チュートリアル: 2506.

   * *note 上級チュートリアル: 2507.

   * *note Enum クックブック: 2508.

__________________________________________________________________

列挙型とは:

   * 一意の値に紐付けられたシンボリックな名前の集合です

   * 反復可能であり、定義順にその正規の（エイリアスでない）メンバーを返
     します

   * 値を渡してメンバーを返すために、 '呼び出し' 構文を使用します

   * 名前を受け取ってメンバーを返すために、 'インデックス' 構文を使用し
     ます

列挙型は、*note class: 12a5. 構文を使用するか、関数呼び出し構文を使用し
て作成されます:

     >>> from enum import Enum

     >>> # class syntax
     >>> class Color(Enum):
     ...     RED = 1
     ...     GREEN = 2
     ...     BLUE = 3

     >>> # functional syntax
     >>> Color = Enum('Color', [('RED', 1), ('GREEN', 2), ('BLUE', 3)])

Enum の作成に *note class: 12a5. 文を使用できるものの、Enum は通常の
Python クラスではありません。詳細は *note Enum はどう違うのか?: 2509. を
参照してください。

     注釈: 用語

        - クラス ‘Color’ は '列挙型' (または 'Enum') です

        - 属性 ‘Color.RED’, ‘Color.GREEN’ などは '列挙型のメンバー' (ま
          たは 'メンバー') で、機能的には定数です。

        - 列挙型のメンバーは '名前' と '値' を持ちます (‘Color.RED’ の名
          前は ‘RED’ 、 ‘Color.BLUE’ の値は ‘3’ など。)

__________________________________________________________________

* Menu:

* モジュールコンテンツ: モジュールコンテンツ<2>.
* データ型: データ型<2>.
* ユーティリティとデコレータ::
* 注釈::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/enum.py


File: python.info,  Node: モジュールコンテンツ<2>,  Next: データ型<2>,  Up: enum --- 列挙型のサポート

5.8.14.1 モジュールコンテンツ
.............................

     *note EnumType: 5e5.

          Enumおよびそのサブクラスのための ‘type’ です。

     *note Enum: 5fc.

          列挙型定数を作成する基底クラスです。

     *note IntEnum: cad.

          *note int: 238. のサブクラスでもある列挙型定数を作成する基底ク
          ラスです。(*note Notes: 250b.)

     *note StrEnum: 5e6.

          *note str: 418. のサブクラスでもある列挙型定数を作成する基底ク
          ラスです。(*note Notes: 250b.)

     *note Flag: 5ef.

          列挙型定数を作成する基底クラスで、ビット演算を使って組み合わせ
          られ、その結果も *note IntFlag: 2255. メンバーになります。

     *note IntFlag: 2255.

          列挙型定数を作成する基底クラスで、ビット演算子を使って組み合わ
          せられ、その結果も *note IntFlag: 2255. メンバーになります。
          *note IntFlag: 2255. は *note int: 238. のサブクラスでもありま
          す。(*note Notes: 250b.)

     *note ReprEnum: 5e7.

          *note IntEnum: cad.、*note StrEnum: 5e6.、および *note
          IntFlag: 2255. によって使用され、mix-inされた型の *note str():
          418. を保持します。

     *note EnumCheck: 5f2.

          ‘CONTINUOUS’、‘NAMED_FLAGS’、‘UNIQUE’ の値を持つ列挙型です。
          *note verify(): 5f1. と共に使用して、指定された列挙型がさまざ
          まな制約を満たしていることを確認します。

     *note FlagBoundary: 5f0.

          An enumeration with the values ‘STRICT’, ‘CONFORM’, ‘EJECT’,
          and ‘KEEP’ which allows for more fine-grained control over how
          invalid values are dealt with in an enumeration.

     *note auto: c6a.

          インスタンスは列挙型のメンバーに適切な値で置き換えられます。
          *note StrEnum: 5e6. ではデフォルトの値がメンバー名を小文字にし
          たものですが、その他の列挙型のデフォルトは1から連番で増加する
          値となります。

     *note property(): 5f5.

          メンバー名との競合を避けながら *note Enum: 5fc. メンバーに属性
          を持たせます。‘value’ 属性と ‘name’ 属性はこの方法で実装されま
          す。

     *note unique(): 250c.

          一つの名前だけがひとつの値に束縛されていることを保証する Enum
          クラスのデコレーターです。

     *note verify(): 5f1.

          Enum class decorator that checks user-selectable constraints
          on an enumeration.

     *note member(): 5f3.

          ‘obj’ をメンバーにします。デコレータとして使用できます。

     *note nonmember(): 5f4.

          ‘obj’ をメンバーにしません。デコレータとして使用できます。

     *note global_enum(): 5f7.

          Modify the *note str(): 418. and *note repr(): 7c8. 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.

     *note show_flag_values(): 250d.

          フラグに含まれる、全ての2の累乗の整数のリストを返します。

Added in version 3.6: ‘Flag’, ‘IntFlag’, ‘auto’

Added in version 3.11: ‘StrEnum’, ‘EnumCheck’, ‘ReprEnum’,
‘FlagBoundary’, ‘property’, ‘member’, ‘nonmember’, ‘global_enum’,
‘show_flag_values’

__________________________________________________________________


File: python.info,  Node: データ型<2>,  Next: ユーティリティとデコレータ,  Prev: モジュールコンテンツ<2>,  Up: enum --- 列挙型のサポート

5.8.14.2 データ型
.................

 -- クラス: enum.EnumType

     'EnumType' は 'enum' 列挙型の *note メタクラス: 1ee7. です。
     'EnumType' のサブクラスを作成することが可能です - 詳細は *note
     EnumTypeのサブクラスを作る: 250f. を参照してください。

     ‘EnumType’ is responsible for setting the correct ‘__repr__()’,
     ‘__str__()’, ‘__format__()’, and ‘__reduce__()’ methods on the
     final 'enum', as well as creating the enum members, properly
     handling duplicates, providing iteration over the enum class, etc.

      -- メソッド: __call__ (cls, value, names=None, *, module=None,
               qualname=None, type=None, start=1, boundary=None)

          このメソッドは2つの異なる方法で呼び出されます。

             * 既存のメンバーを検索する:


                    cls: 呼び出されるenumクラス。


                    value: 検索する値。

             * ‘cls’ を使って新しい列挙型を作成する（既存の列挙型がメン
               バーを持たない場合のみ）:


                    cls: 呼び出されるenumクラス。


                    value: 新しく作成するEnumの名前。


                    names: 新しく作成するEnumのメンバーの名前/値のリスト
                    。


                    module: 新しく作成するEnumの属するモジュール名。


                    qualname: The actual location in the module where
                    this Enum can be found.


                    type: 新しく作成するEnumのmix-in型。


                    start: Enumの最初の整数値（*note auto: c6a. で使用さ
                    れます）。


                    boundary: bit演算での範囲外の値の扱い方（*note Flag:
                    5ef. のみ）。

      -- メソッド: __contains__ (cls, member)

          メンバーが ‘cls’ に属している場合は ‘True’ を返します:

               >>> some_var = Color.RED
               >>> some_var in Color
               True
               >>> Color.RED.value in Color
               True

     バージョン 3.12 で変更: Python 3.12 以前では、非Enumメンバーの包含
     判定が行われた場合、‘TypeError’ が送出されます。

      -- メソッド: __dir__ (cls)

          ‘['__class__', '__doc__', '__members__', '__module__']’ と、
          'cls' に属するメンバー名を返します:

               >>> dir(Color)
               ['BLUE', 'GREEN', 'RED', '__class__', '__contains__', '__doc__', '__getitem__', '__init_subclass__', '__iter__', '__len__', '__members__', '__module__', '__name__', '__qualname__']

      -- メソッド: __getitem__ (cls, name)

          'cls' 内の一致するメンバーを返すか、*note KeyError: 31d. を送
          出します:

               >>> Color['BLUE']
               <Color.BLUE: 3>

      -- メソッド: __iter__ (cls)

          Returns each member in 'cls' in definition order:

               >>> list(Color)
               [<Color.RED: 1>, <Color.GREEN: 2>, <Color.BLUE: 3>]

      -- メソッド: __len__ (cls)

          'cls' 内のメンバーの数を返します。:

               >>> len(Color)
               3

      -- の属性: __members__

          Returns a mapping of every enum name to its member, including
          aliases

      -- メソッド: __reversed__ (cls)

          'cls' 内の各メンバー を定義順の逆順で返します:

               >>> list(reversed(Color))
               [<Color.BLUE: 3>, <Color.GREEN: 2>, <Color.RED: 1>]

      -- メソッド: _add_alias_ ()

          Adds a new name as an alias to an existing member.  Raises a
          *note NameError: 40b. if the name is already assigned to a
          different member.

      -- メソッド: _add_value_alias_ ()

          Adds a new value as an alias to an existing member.  Raises a
          *note ValueError: 1e3. if the value is already linked with a
          different member.

     Added in version 3.11: Before 3.11 ‘EnumType’ was called
     ‘EnumMeta’, which is still available as an alias.

 -- クラス: enum.Enum

     'Enum' は全ての 'enum' 列挙型の基底クラスです。

      -- の属性: name

          ‘Enum’ メンバーを定義するために使用される名前:

               >>> Color.BLUE.name
               'BLUE'

      -- の属性: value

          ‘Enum’ メンバーに与えられた値:

               >>> Color.RED.value
               1

          Value of the member, can be set in *note __new__(): 251c.

               注釈: 列挙型のメンバー値

               メンバー値は何であっても構いません: *note int: 238, *note
               str: 418. などなど。 正確な値が重要でない場合は、 *note
               auto: c6a. インスタンスを使っておくと、適切な値が選ばれま
               す。 詳細は *note auto: c6a. を参照してください。

               While mutable/unhashable values, such as *note dict: 237,
               *note list: 5dc. or a mutable *note dataclass: 1ad, can
               be used, they will have a quadratic performance impact
               during creation relative to the total number of
               mutable/unhashable values in the enum.

      -- の属性: _name_

          Name of the member.

      -- の属性: _value_

          Value of the member, can be set in *note __new__(): 251c.

      -- の属性: _order_

          No longer used, kept for backward compatibility.  (class
          attribute, removed during class creation).

      -- の属性: _ignore_

          ‘_ignore_’ は列挙の作成中にのみ使用され、作成が完了すると削除
          されます。

          ‘_ignore_’ は、メンバーにならず、作成された列挙から削除される
          名前のリストです。例については、*note TimePeriod: 2521. を参照
          してください。

      -- メソッド: __dir__ (self)

          Returns ‘['__class__', '__doc__', '__module__', 'name',
          'value']’ and any public methods defined on 'self.__class__':

               >>> from datetime import date
               >>> class Weekday(Enum):
               ...     MONDAY = 1
               ...     TUESDAY = 2
               ...     WEDNESDAY = 3
               ...     THURSDAY = 4
               ...     FRIDAY = 5
               ...     SATURDAY = 6
               ...     SUNDAY = 7
               ...     @classmethod
               ...     def today(cls):
               ...         print('today is %s' % cls(date.today().isoweekday()).name)
               ...
               >>> dir(Weekday.SATURDAY)
               ['__class__', '__doc__', '__eq__', '__hash__', '__module__', 'name', 'today', 'value']

      -- メソッド: _generate_next_value_ (name, start, count,
               last_values)


               name: 定義されているメンバーの名前（例：'RED'）。


               start: Enumの開始値。デフォルトは1です。


               count: 定義済みのメンバーの数。現在のメンバーを含めない。


               last_values: 定義済みの値のリスト。

          *note auto: c6a. によって返される次の値を決定するために使用さ
          れる 'staticmethod' です:

               >>> from enum import auto
               >>> class PowersOfThree(Enum):
               ...     @staticmethod
               ...     def _generate_next_value_(name, start, count, last_values):
               ...         return 3 ** (count + 1)
               ...     FIRST = auto()
               ...     SECOND = auto()
               ...
               >>> PowersOfThree.SECOND.value
               9

      -- メソッド: __init__ (self, *args, **kwds)

          デフォルトでは何もしません。メンバーに複数の値が指定されている
          場合、それらの値は ‘__init__’ の別々の引数となります。例えば、

               >>> from enum import Enum
               >>> class Weekday(Enum):
               ...     MONDAY = 1, 'Mon'

          ‘Weekday.__init__()’ は ‘Weekday.__init__(self, 1, 'Mon')’ と
          して呼び出されます。

      -- メソッド: __init_subclass__ (cls, **kwds)

          サブクラスを更に設定するために使用される 'classmethod' です。
          デフォルトでは何も行いません。

      -- メソッド: _missing_ (cls, value)

          'cls' で見つからない値を検索するための 'classmethod' です。デ
          フォルトでは何もしませんが、カスタムの検索の振る舞いを実装する
          ためにオーバーライドすることができます:

               >>> from enum import StrEnum
               >>> class Build(StrEnum):
               ...     DEBUG = auto()
               ...     OPTIMIZED = auto()
               ...     @classmethod
               ...     def _missing_(cls, value):
               ...         value = value.lower()
               ...         for member in cls:
               ...             if member.value == value:
               ...                 return member
               ...         return None
               ...
               >>> Build.DEBUG.value
               'debug'
               >>> Build('deBUG')
               <Build.DEBUG: 'debug'>

      -- メソッド: __new__ (cls, *args, **kwds)

          デフォルトでは存在しません。指定された場合、列挙型のクラス定義
          またはmix-inクラス（例えば ‘int’ など）のいずれかで、メンバー
          に代入されたすべての値が渡されます。例:

               >>> from enum import Enum
               >>> class MyIntEnum(int, Enum):
               ...     TWENTYSIX = '1a', 16

          results in the call ‘int('1a', 16)’ and a value of ‘26’ for
          the member.

               注釈: When writing a custom ‘__new__’, do not use
               ‘super().__new__’ - call the appropriate ‘__new__’
               instead.

      -- メソッド: __repr__ (self)

          'repr()' の呼び出しに使用される文字列を返します。デフォルトで
          は、 'Enum' 名、メンバー名、および値を返しますが、オーバーライ
          ドすることもできます:

               >>> class OtherStyle(Enum):
               ...     ALTERNATE = auto()
               ...     OTHER = auto()
               ...     SOMETHING_ELSE = auto()
               ...     def __repr__(self):
               ...         cls_name = self.__class__.__name__
               ...         return f'{cls_name}.{self.name}'
               ...
               >>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
               (OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')

      -- メソッド: __str__ (self)

          'str()' の呼び出しに使用される文字列を返します。デフォルトでは
          、 'Enum' の名前とメンバーの名前を返しますが、オーバーライドす
          ることもできます:

               >>> class OtherStyle(Enum):
               ...     ALTERNATE = auto()
               ...     OTHER = auto()
               ...     SOMETHING_ELSE = auto()
               ...     def __str__(self):
               ...         return f'{self.name}'
               ...
               >>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
               (<OtherStyle.ALTERNATE: 1>, 'ALTERNATE', 'ALTERNATE')

      -- メソッド: __format__ (self)

          'format()' および 'f-string' の呼び出しに使用される文字列を返
          します。デフォルトでは、*note __str__(): 5ee. の戻り値を返しま
          すが、オーバーライドすることもできます。:

               >>> class OtherStyle(Enum):
               ...     ALTERNATE = auto()
               ...     OTHER = auto()
               ...     SOMETHING_ELSE = auto()
               ...     def __format__(self, spec):
               ...         return f'{self.name}'
               ...
               >>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
               (<OtherStyle.ALTERNATE: 1>, 'OtherStyle.ALTERNATE', 'ALTERNATE')

          注釈: *note Enum: 5fc. で *note auto: c6a. を使用すると、 ‘1’
          から始まりインクリメントする整数が値となります。

     バージョン 3.12 で変更: *note データクラスのサポート: 16ef. の追加

 -- クラス: enum.IntEnum

     'IntEnum' is the same as *note Enum: 5fc, 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.

          >>> from enum import IntEnum
          >>> class Number(IntEnum):
          ...     ONE = 1
          ...     TWO = 2
          ...     THREE = 3
          ...
          >>> Number.THREE
          <Number.THREE: 3>
          >>> Number.ONE + Number.TWO
          3
          >>> Number.THREE + 5
          8
          >>> Number.THREE == 3
          True

          注釈: *note IntEnum: cad. で *note auto: c6a. を使用すると、
          ‘1’ から始まりインクリメントする整数が値となります。

     バージョン 3.11 で変更: *note __str__(): 5e9. は、既存の定数を置き
     換えるユースケースをより良くサポートするために ‘int.__str__()’ に変
     更されました。同じ理由で、*note __format__(): 5ea. は既に
     ‘int.__format__()’ に変更されています。

 -- クラス: enum.StrEnum

     ‘StrEnum’ is the same as *note Enum: 5fc, 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.

          注釈: 標準ライブラリの中には、 *note str: 418. の代わりに
          *note str: 418. のサブクラス（つまり、 ‘type(unknown) == str’
          の代わりに ‘isinstance(unknown, str)’ ）を厳密にチェックする場
          所があります。そのような場所では、 ‘str(StrEnum.member)’ を使
          用する必要があります。

          注釈: *note StrEnum: 5e6. で *note auto: c6a. を使用すると、メ
          ンバー名を小文字に変換したものが値となります。

          注釈: *note __str__(): 5e9. は '既存の定数の置換' ユースケース
          をより良くサポートするために ‘str.__str__()’ となりました。
          *note __format__(): 5ea. も同様に、同じ理由で
          ‘str.__format__()’ となりました。

     Added in version 3.11.

 -- クラス: enum.Flag

     ‘Flag’ is the same as *note Enum: 5fc, but its members support the
     bitwise operators ‘&’ ('AND'), ‘|’ ('OR'), ‘^’ ('XOR'), and ‘~’
     ('INVERT'); the results of those operations are (aliases of)
     members of the enumeration.

      -- メソッド: __contains__ (self, value)

          値を含む場合に 'True' を返します:

               >>> from enum import Flag, auto
               >>> class Color(Flag):
               ...     RED = auto()
               ...     GREEN = auto()
               ...     BLUE = auto()
               ...
               >>> purple = Color.RED | Color.BLUE
               >>> white = Color.RED | Color.GREEN | Color.BLUE
               >>> Color.GREEN in purple
               False
               >>> Color.GREEN in white
               True
               >>> purple in white
               True
               >>> white in purple
               False

      -- メソッド: __iter__(self):

          エイリアスでない、全てのメンバーを返します:

               >>> list(Color.RED)
               [<Color.RED: 1>]
               >>> list(purple)
               [<Color.RED: 1>, <Color.BLUE: 4>]

          Added in version 3.11.

      -- メソッド: __len__(self):

          flag 内のメンバーの数を返します:

               >>> len(Color.GREEN)
               1
               >>> len(white)
               3

          Added in version 3.11.

      -- メソッド: __bool__(self):

          メンバーがflagに含まれている場合は 'True' を返し、それ以外の場
          合は 'False' を返します:

               >>> bool(Color.GREEN)
               True
               >>> bool(white)
               True
               >>> black = Color(0)
               >>> bool(black)
               False

      -- メソッド: __or__ (self, other)

          現在のフラグと他のフラグの論理和となるフラグを返します:

               >>> Color.RED | Color.GREEN
               <Color.RED|GREEN: 3>

      -- メソッド: __and__ (self, other)

          現在のフラグと他のフラグの論理積となるフラグを返します:

               >>> purple & white
               <Color.RED|BLUE: 5>
               >>> purple & Color.GREEN
               <Color: 0>

      -- メソッド: __xor__ (self, other)

          現在のフラグと他のフラグの排他的論理和となるフラグを返します:

               >>> purple ^ white
               <Color.GREEN: 2>
               >>> purple ^ Color.GREEN
               <Color.RED|GREEN|BLUE: 7>

      -- メソッド: __invert__(self):

          Returns all the flags in 'type(self)' that are not in 'self':

               >>> ~white
               <Color: 0>
               >>> ~purple
               <Color.GREEN: 2>
               >>> ~Color.RED
               <Color.GREEN|BLUE: 6>

      -- メソッド: _numeric_repr_ ()

          Function used to format any remaining unnamed numeric values.
          Default is the value's repr; common choices are *note hex():
          129d. and *note oct(): 129c.

          注釈: *note auto: c6a. と *note Flag: 5ef. を一緒に使うと、‘1’
          から始まる2の累乗の整数になります。

     バージョン 3.11 で変更: 値が0のフラグの 'repr()' は変更されました。
     現在は以下のとおりです:

          >>> Color(0)
          <Color: 0>

 -- クラス: enum.IntFlag

     ‘IntFlag’ is the same as *note Flag: 5ef, but its members are also
     integers and can be used anywhere that an integer can be used.

          >>> from enum import IntFlag, auto
          >>> class Color(IntFlag):
          ...     RED = auto()
          ...     GREEN = auto()
          ...     BLUE = auto()
          ...
          >>> Color.RED & 2
          <Color: 0>
          >>> Color.RED | 2
          <Color.RED|GREEN: 3>

     'IntFlag' のメンバーと整数の演算が行われた場合、結果は 'IntFlag' で
     はありません:

          >>> Color.RED + 2
          3

     If a *note Flag: 5ef. operation is performed with an 'IntFlag'
     member and:

        * 結果が有効な 'IntFlag': 'IntFlag' が返されます

        * the result is not a valid 'IntFlag': the result depends on the
          *note FlagBoundary: 5f0. setting

     The *note repr(): 7c8. of unnamed zero-valued flags has changed.
     It is now:

          >>> Color(0)
          <Color: 0>

          注釈: *note auto: c6a. と *note IntFlag: 2255. を一緒に使うと
          、‘1’ から始まる2の累乗の整数になります。

     バージョン 3.11 で変更: *note __str__(): 5e9. は、既存の定数を置き
     換えるユースケースをより良くサポートするために ‘int.__str__()’ に変
     更されました。同じ理由で、*note __format__(): 5ea. は既に
     ‘int.__format__()’ に変更されています。

     ‘IntFlag’ の反転は、与えられたフラグ以外のすべてのフラグの結合とな
     る正の値を返すようになりました。これは既存の *note Flag: 5ef. の振
     る舞いに一致します。

 -- クラス: enum.ReprEnum

     ‘ReprEnum’ uses the *note repr(): 16f0. of *note Enum: 5fc, but the
     *note str(): 418. of the mixed-in data type:

        * ‘int.__str__()’ for *note IntEnum: cad. and *note IntFlag:
          2255.

        * ‘str.__str__()’ for *note StrEnum: 5e6.

     ‘ReprEnum’ を継承することで、*note Enum: 5fc. デフォルトの *note
     str(): 5ee. を使用する代わりに、mix-inされたデータ型の *note str():
     418. / *note format(): 5eb. を使用します。

     Added in version 3.11.

 -- クラス: enum.EnumCheck

     'EnumCheck' には *note verify(): 5f1. デコレータやさまざまな制約を
     保証するために使用されるオプションが含まれています。制約に違反する
     と *note ValueError: 1e3. が発生します。

      -- の属性: UNIQUE

          それぞれの値が1つの名前しか持たないことを確認します:

               >>> from enum import Enum, verify, UNIQUE
               >>> @verify(UNIQUE)
               ... class Color(Enum):
               ...     RED = 1
               ...     GREEN = 2
               ...     BLUE = 3
               ...     CRIMSON = 1
               Traceback (most recent call last):
               ...
               ValueError: aliases found in <enum 'Color'>: CRIMSON -> RED

      -- の属性: CONTINUOUS

          最小値のメンバーと最大値のメンバーの間に欠損値がないことを確認
          します:

               >>> from enum import Enum, verify, CONTINUOUS
               >>> @verify(CONTINUOUS)
               ... class Color(Enum):
               ...     RED = 1
               ...     GREEN = 2
               ...     BLUE = 5
               Traceback (most recent call last):
               ...
               ValueError: invalid enum 'Color': missing values 3, 4

      -- の属性: NAMED_FLAGS

          任意のフラググループ/マスクが、名前付きフラグのみを含むことを
          確認します - 値を指定するのではなく、*note auto(): c6a. によっ
          て生成される場合に便利です:

               >>> from enum import Flag, verify, NAMED_FLAGS
               >>> @verify(NAMED_FLAGS)
               ... class Color(Flag):
               ...     RED = 1
               ...     GREEN = 2
               ...     BLUE = 4
               ...     WHITE = 15
               ...     NEON = 31
               Traceback (most recent call last):
               ...
               ValueError: invalid Flag 'Color': aliases WHITE and NEON are missing combined values of 0x18 [use enum.show_flag_values(value) for details]

          注釈: CONTINUOUSとNAMED_FLAGSは整数値のメンバーとともに動作す
          るように設計されています。

     Added in version 3.11.

 -- クラス: enum.FlagBoundary

     ‘FlagBoundary’ controls how out-of-range values are handled in
     *note Flag: 5ef. and its subclasses.

      -- の属性: STRICT

          範囲外の値は *note ValueError: 1e3. を送出します。これは *note
          Flag: 5ef. のデフォルトです:

               >>> from enum import Flag, STRICT, auto
               >>> class StrictFlag(Flag, boundary=STRICT):
               ...     RED = auto()
               ...     GREEN = auto()
               ...     BLUE = auto()
               ...
               >>> StrictFlag(2**2 + 2**4)
               Traceback (most recent call last):
               ...
               ValueError: <flag 'StrictFlag'> invalid value 20
                   given 0b0 10100
                 allowed 0b0 00111

      -- の属性: CONFORM

          Out-of-range values have invalid values removed, leaving a
          valid *note Flag: 5ef. value:

               >>> from enum import Flag, CONFORM, auto
               >>> class ConformFlag(Flag, boundary=CONFORM):
               ...     RED = auto()
               ...     GREEN = auto()
               ...     BLUE = auto()
               ...
               >>> ConformFlag(2**2 + 2**4)
               <ConformFlag.BLUE: 4>

      -- の属性: EJECT

          Out-of-range values lose their *note Flag: 5ef. membership and
          revert to *note int: 238.

               >>> from enum import Flag, EJECT, auto
               >>> class EjectFlag(Flag, boundary=EJECT):
               ...     RED = auto()
               ...     GREEN = auto()
               ...     BLUE = auto()
               ...
               >>> EjectFlag(2**2 + 2**4)
               20

      -- の属性: KEEP

          Out-of-range values are kept, and the *note Flag: 5ef.
          membership is kept.  This is the default for *note IntFlag:
          2255.:

               >>> from enum import Flag, KEEP, auto
               >>> class KeepFlag(Flag, boundary=KEEP):
               ...     RED = auto()
               ...     GREEN = auto()
               ...     BLUE = auto()
               ...
               >>> KeepFlag(2**2 + 2**4)
               <KeepFlag.BLUE|16: 20>

Added in version 3.11.

__________________________________________________________________

* Menu:

* __dunder__ 名のサポート::
* _sunder_ 名のサポート::


File: python.info,  Node: __dunder__ 名のサポート,  Next: _sunder_ 名のサポート,  Up: データ型<2>

5.8.14.3 ‘__dunder__’ 名のサポート
..................................

*note __members__: 2516. は読み込み専用の、 ‘member_name’:‘member’ を要
素とする順序付きマッピングです。これはクラスでのみ利用可能です。

*note __new__(): 251c, if specified, must create and return the enum
members; it is also a very good idea to set the member's ‘_value_’
appropriately.  Once all the members are created it is no longer used.


File: python.info,  Node: _sunder_ 名のサポート,  Prev: __dunder__ 名のサポート,  Up: データ型<2>

5.8.14.4 ‘_sunder_’ 名のサポート
................................

   - *note _add_alias_(): 2518. - adds a new name as an alias to an
     existing member.

   - *note _add_value_alias_(): 2519. - adds a new value as an alias to
     an existing member.

   - *note _name_: 251d. - メンバー名

   - *note _value_: 251e. - メンバーの値; ‘__new__’ で設定できます

   - *note _missing_(): 2525. - 値が見付からなかったときに使われる検索関
     数; オーバーライドされていることがあります

   - *note _ignore_: 2520. - 名前のリストで、 *note list: 5dc. もしくは
     *note str: 418. です。この名前の要素はメンバーへの変換が行われず、
     最終的なクラスから削除されます。

   - *note _order_: 251f. - no longer used, kept for backward
     compatibility (class attribute, removed during class creation)

   - *note _generate_next_value_(): 2522. - 列挙型のメンバーの適切な値を
     取得するのに使われます。オーバーライドされます。

          注釈: 標準の *note Enum: 5fc. クラスの場合、次の値として選択さ
          れるのは、定義された最大の値に1を加えたものです。

          *note Flag: 5ef. クラスでは、次に選ばれる値は、次の最大の2のべ
          き乗となります。

   - While ‘_sunder_’ names are generally reserved for the further
     development of the *note Enum: 5fc. class and can not be used, some
     are explicitly allowed:

        - ‘_repr_*’ (e.g.  ‘_repr_html_’), as used in IPython's rich
          display(1)

Added in version 3.6: ‘_missing_’, ‘_order_’, ‘_generate_next_value_’

Added in version 3.7: ‘_ignore_’

Added in version 3.13: ‘_add_alias_’, ‘_add_value_alias_’, ‘_repr_*’

__________________________________________________________________

   ---------- Footnotes ----------

   (1) 
https://ipython.readthedocs.io/en/stable/config/integrating.html#rich-display


File: python.info,  Node: ユーティリティとデコレータ,  Next: 注釈,  Prev: データ型<2>,  Up: enum --- 列挙型のサポート

5.8.14.5 ユーティリティとデコレータ
...................................

 -- クラス: enum.auto

     'auto' can be used in place of a value.  If used, the 'Enum'
     machinery will call an *note Enum: 5fc.'s *note
     _generate_next_value_(): 2522. to get an appropriate value.  For
     *note Enum: 5fc. and *note IntEnum: cad. that appropriate value
     will be the last value plus one; for *note Flag: 5ef. and *note
     IntFlag: 2255. it will be the first power-of-two greater than the
     highest value; for *note StrEnum: 5e6. it will be the lower-cased
     version of the member's name.  Care must be taken if mixing
     'auto()' with manually specified values.

     'auto' インスタンスは、代入のトップレベルでのみ解決されます。

        * ‘FIRST = auto()’ は動作します（auto() は ‘1’ に置き換えられま
          す）

        * ‘SECOND = auto(), -2’ は動作します（auto は ‘2’ に置き換えられ
          るため、 ‘SECOND’ 列挙型のメンバーには ‘2, -2’ が使用されます
          ）

        * ‘THREE = [auto(), -3]’ は動作 'しません' （enumメンバー
          ‘THREE’ の作成に ‘<auto instance>, -3’ が使用されます）

     バージョン 3.11.1 で変更: 以前のバージョンでは、 ‘auto()’ は、代入
     行に他のものがあると正しく動作しませんでした。

     ‘_generate_next_value_’ は、 'auto' が使用する値をカスタマイズする
     ためにオーバーライドすることができる。

          注釈: 3.13では、デフォルトの ‘_generate_next_value_’ は常に最
          も高いメンバーの値に1を加えたものを返し、メンバーのいずれかが
          比較できない型である場合には失敗します。

 -- の関数: @enum.property

     A decorator similar to the built-in 'property', but specifically
     for enumerations.  It allows member attributes to have the same
     names as members themselves.

          注釈: 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’.

     Added in version 3.11.

 -- の関数: @enum.unique

     列挙型専用の *note class: 12a5. デコレーターです。列挙型の *note
     __members__: 2516. に別名がないかどうか検索します; 見つかった場合、
     *note ValueError: 1e3. が詳細情報とともに送出されます:

          >>> from enum import Enum, unique
          >>> @unique
          ... class Mistake(Enum):
          ...     ONE = 1
          ...     TWO = 2
          ...     THREE = 3
          ...     FOUR = 3
          ...
          Traceback (most recent call last):
          ...
          ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE

 -- の関数: @enum.verify

     列挙型専用の *note class: 12a5. デコレーターです。対象の列挙型に対
     してチェックを行う制約の指定には *note EnumCheck: 5f2. のメンバーが
     使用されます。

     Added in version 3.11.

 -- の関数: @enum.member

     列挙型で使用するデコレータ: 対象は列挙型のメンバー になります。

     Added in version 3.11.

 -- の関数: @enum.nonmember

     列挙型で使用するデコレータ: 対象は列挙型のメンバー になりません。

     Added in version 3.11.

 -- の関数: @enum.global_enum

     A decorator to change the *note str(): 418. and *note repr(): 7c8.
     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 *note re.RegexFlag:
     5f9. for an example).

     Added in version 3.11.

 -- の関数: enum.show_flag_values (value)

     フラグの 'value' に含まれる全ての2の累乗の整数のリストを返します。

     Added in version 3.11.

__________________________________________________________________


File: python.info,  Node: 注釈,  Prev: ユーティリティとデコレータ,  Up: enum --- 列挙型のサポート

5.8.14.6 注釈
.............

*note IntEnum: cad. 、 *note StrEnum: 5e6. 、 *note IntFlag: 2255.

     これらの3つの列挙型は、既存の整数ベースおよび文字列ベースの値の代替
     として設計されています。そのため、追加の制限があります:

        - ‘__str__’ は、列挙型のメンバーの名前ではなく値を使用します

        - ‘__format__’ は ‘__str__’ を使用するため、列挙型のメンバーの名
          前ではなく値を使用します

     もし、そのような制限が必要でない/望まない場合は、‘int’ または ‘str’
     タイプを継承して、カスタムの基底クラスを作成することができます:

          >>> from enum import Enum
          >>> class MyIntEnum(int, Enum):
          ...     pass

     または列挙型の中で適切な *note str(): 418. などを再代入することもで
     きます:

          >>> from enum import Enum, IntEnum
          >>> class MyIntEnum(IntEnum):
          ...     __str__ = Enum.__str__


File: python.info,  Node: graphlib --- グラフ構造を操作する機能,  Prev: enum --- 列挙型のサポート,  Up: データ型

5.8.15 ‘graphlib’ -- グラフ構造を操作する機能
---------------------------------------------

'ソースコード:' Lib/graphlib.py(1)

__________________________________________________________________

 -- クラス: graphlib.TopologicalSorter (graph=None)

     *note ハッシュ可能: 5db. な頂点のグラフをトポロジカルソートする機能
     を提供します。

     トポロジカル順序はグラフの頂点の線形順序で、頂点 u から 頂点 v への
     有向辺 u-> v 全てについて、頂点 u が頂点 v よりも前にくるような順序
     です。例えば、グラフの頂点が実行するタスクを表し、その辺があるタス
     クが別のタスクよりも前に実行されなければならないという制約を表す場
     合、トポロジカル順序は制約を満たすタスクの実行順序のシーケンスにな
     ります。トポロジカル順序が得られるのは、グラフが有向閉路を持たない
     、つまり有向非巡回グラフである場合でかつその時に限ります。

     もしオプションの 'graph' 引数が与えられた場合、その値は有向非巡回グ
     ラフを表す辞書でなければならず、辞書はそのキーがノードで、その値は
     キーのノードの先行ノードのイテラブルとなります（言い換えると、辞書
     の値はそのキーのノードを指す辺を持つノードのイテラブルです） 辺
     *note add(): 2538. メソッドを使うことで、さらにノードを追加すること
     ができます。

     一般的に、与えられたグラフのソートの実行に必要なステップは以下のよ
     うになります:

        * *note TopologicalSorter: 8af. のインスタンスをオプションの初期
          グラフで生成します。

        * さらにノードをグラフに追加します。

        * *note prepare(): 2539. をグラフ上で呼び出します。

        * *note is_active(): 253a. が ‘True’ の間、 *note get_ready():
          253b. によって返されたノード群をイテレートし、それらを処理しま
          す。ノードの処理が終わる都度、*note done(): 253c. を呼び出しま
          す。

     すぐにグラフのノードをソートした結果が必要で、並行性が不要な場合、
     便利なメソッド *note TopologicalSorter.static_order(): 253d. を直接
     呼び出すことができます:

          >>> graph = {"D": {"B", "C"}, "C": {"A"}, "B": {"A"}}
          >>> ts = TopologicalSorter(graph)
          >>> tuple(ts.static_order())
          ('A', 'C', 'B', 'D')

     このクラスは、簡単に準備が整ったノードの並列処理を行えるよう設計さ
     れています。例えば:

          topological_sorter = TopologicalSorter()

          # Add nodes to 'topological_sorter'...

          topological_sorter.prepare()
          while topological_sorter.is_active():
              for node in topological_sorter.get_ready():
                  # Worker threads or processes take nodes to work on off the
                  # 'task_queue' queue.
                  task_queue.put(node)

              # When the work for a node is done, workers put the node in
              # 'finalized_tasks_queue' so we can get more nodes to work on.
              # The definition of 'is_active()' guarantees that, at this point, at
              # least one node has been placed on 'task_queue' that hasn't yet
              # been passed to 'done()', so this blocking 'get()' must (eventually)
              # succeed.  After calling 'done()', we loop back to call 'get_ready()'
              # again, so put newly freed nodes on 'task_queue' as soon as
              # logically possible.
              node = finalized_tasks_queue.get()
              topological_sorter.done(node)

      -- メソッド: add (node, *predecessors)

          新しいノードとその先行ノードをグラフに追加します。 'node' と
          'predecessors' のすべての要素は *note ハッシュ可能: 5db. でな
          ければなりません。

          同じ node 引数で複数回呼び出した場合、依存関係の集合は、それま
          でに指定した依存関係の和集合になります。

          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.

          *note prepare(): 2539. を呼び出した後にこのメソッドを呼び出す
          と、*note ValueError: 1e3. を送出します。

      -- メソッド: prepare ()

          Mark the graph as finished and check for cycles in the graph.
          If any cycle is detected, *note CycleError: 253e. will be
          raised, but *note get_ready(): 253b. can still be used to
          obtain as many nodes as possible until cycles block more
          progress.  After a call to this function, the graph cannot be
          modified, and therefore no more nodes can be added using *note
          add(): 2538.

      -- メソッド: is_active ()

          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 are still nodes ready that haven't
          yet been returned by *note TopologicalSorter.get_ready():
          253b. or the number of nodes marked *note
          TopologicalSorter.done(): 253c. is less than the number that
          have been returned by *note TopologicalSorter.get_ready():
          253b.

          The *note __bool__(): 12a3. method of this class defers to
          this function, so instead of:

               if ts.is_active():
                   ...

          このように簡単に記述できます:

               if ts:
                   ...

          前もって *note prepare(): 2539. を呼び出さずにこの関数を呼び出
          すと *note ValueError: 1e3. を送出します。

      -- メソッド: done (*nodes)

          Marks a set of nodes returned by *note
          TopologicalSorter.get_ready(): 253b. as processed, unblocking
          any successor of each node in 'nodes' for being returned in
          the future by a call to *note TopologicalSorter.get_ready():
          253b.

          Raises *note ValueError: 1e3. 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 the graph by using *note
          TopologicalSorter.add(): 2538, if called without calling *note
          prepare(): 2539. or if node has not yet been returned by *note
          get_ready(): 253b.

      -- メソッド: get_ready ()

          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 calling *note
          TopologicalSorter.done(): 253c, further calls will return all
          new nodes that have all their predecessors already processed.
          Once no more progress can be made, empty tuples are returned.

          前もって *note prepare(): 2539. を呼び出さずにこの関数を呼び出
          すと *note ValueError: 1e3. を送出します。

      -- メソッド: static_order ()

          Returns an iterator object which will iterate over nodes in a
          topological order.  When using this method, *note prepare():
          2539. and *note done(): 253c. should not be called.  This
          method is equivalent to:

               def static_order(self):
                   self.prepare()
                   while self.is_active():
                       node_group = self.get_ready()
                       yield from node_group
                       self.done(*node_group)

          The particular order that is returned may depend on the
          specific order in which the items were inserted in the graph.
          For example:

               >>> ts = TopologicalSorter()
               >>> ts.add(3, 2, 1)
               >>> ts.add(1, 0)
               >>> print([*ts.static_order()])
               [2, 0, 1, 3]

               >>> ts2 = TopologicalSorter()
               >>> ts2.add(1, 0)
               >>> ts2.add(3, 2, 1)
               >>> print([*ts2.static_order()])
               [0, 2, 1, 3]

          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 *note get_ready(): 253b.) and the order between them is
          determined by the order of insertion.

          If any cycle is detected, *note CycleError: 253e. will be
          raised.

     Added in version 3.9.

* Menu:

* 例外: 例外<4>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/graphlib.py


File: python.info,  Node: 例外<4>,  Up: graphlib --- グラフ構造を操作する機能

5.8.15.1 例外
.............

*note graphlib: 5b. モジュールは以下の例外クラスを定義します:

 -- 例外: graphlib.CycleError

     Subclass of *note ValueError: 1e3. raised by *note
     TopologicalSorter.prepare(): 2539. 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.

     The detected cycle can be accessed via the second element in the
     *note args: 538. attribute of the exception instance and consists
     in a list of nodes, such that each node is, in the graph, an
     immediate 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.


File: python.info,  Node: 数値と数学モジュール,  Next: 関数型プログラミング用モジュール,  Prev: データ型,  Up: Python 標準ライブラリ

5.9 数値と数学モジュール
========================

この章で記述されているモジュールは、数値に関するあるいは数学関係の関数と
データ型を提供します。 *note numbers: 8e. モジュールは、数値の型の抽象的
な階層を定義します。 *note math: 81. と *note cmath: 11. モジュールは、
浮動小数点数と複素数のための様々な数学関数を含んでいます。 *note
decimal: 2e. モジュールは、任意精度の計算を使用して、10進数の正確な表現
をサポートします。

この章では以下のモジュールが記述されています:

* Menu:

* numbers: numbers --- 数の抽象基底クラス. 数の抽象基底クラス
* math: math --- 数学関数. 数学関数
* cmath: cmath --- 複素数用の数学関数. 複素数用の数学関数
* decimal: decimal --- 10進固定小数点と浮動小数点の演算. 10進固定小数点と浮動小数点の演算
* fractions: fractions --- 有理数. 有理数
* random: random --- 疑似乱数を生成する. 疑似乱数を生成する
* statistics: statistics --- 数学的統計関数. 数学的統計関数


File: python.info,  Node: numbers --- 数の抽象基底クラス,  Next: math --- 数学関数,  Up: 数値と数学モジュール

5.9.1 ‘numbers’ -- 数の抽象基底クラス
-------------------------------------

'ソースコード:' Lib/numbers.py(1)

__________________________________________________________________

The ‘numbers’ module ( PEP 3141(2)) defines a hierarchy of numeric *note
abstract base classes: 1186. which progressively define more operations.
None of the types defined in this module are intended to be
instantiated.

 -- クラス: numbers.Number

     数の階層の根。引数 'x' が、種類は何であれ、数であるということだけチ
     ェックしたい場合、‘isinstance(x, Number)’ が使えます。

* Menu:

* 数値塔::
* Notes for type implementers::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/numbers.py

   (2) https://peps.python.org/pep-3141/


File: python.info,  Node: 数値塔,  Next: Notes for type implementers,  Up: numbers --- 数の抽象基底クラス

5.9.1.1 数値塔
..............

 -- クラス: numbers.Complex

     この型のサブクラスは複素数を表し、組み込みの *note complex: 2cf. 型
     を受け付ける演算を含みます。それらは: *note complex: 2cf. および
     *note bool: 434. への変換、 *note real: 2548, *note imag: 2549,
     ‘+’, ‘-’, ‘*’, ‘/’, ‘**’, *note abs(): 1c0e, *note conjugate():
     254a, ‘==’, ‘!=’ です。 ‘-’ と ‘!=’ 以外の全てのものは抽象メソッド
     や抽象プロパティです。

      -- の属性: real

          抽象プロパティ。この数の実部を取り出します。

      -- の属性: imag

          抽象プロパティ。この数の虚部を取り出します。

      -- メソッド: abstractmethod conjugate ()

          抽象プロパティ。複素共役を返します。たとえば、
          ‘(1+3j).conjugate() == (1-3j)’ です。

 -- クラス: numbers.Real

     To *note Complex: 2547, ‘Real’ adds the operations that work on
     real numbers.

     簡潔に言うとそれらは: *note float: 2ce. への変換, *note
     math.trunc(): 136b, *note round(): 12a8, *note math.floor(): 1369,
     *note math.ceil(): 136a, *note divmod(): 96f, ‘//’, ‘%’, ‘<’, ‘<=’,
     ‘>’ および ‘>=’ です。

     Real はまた *note complex(): 2cf, *note real: 2548, *note imag:
     2549. および *note conjugate(): 254a. のデフォルトを提供します。

 -- クラス: numbers.Rational

     *note Real: 20fb. をサブタイプ化し *note numerator: 254b. と *note
     denominator: 254c. のプロパティを加えたものです。これは *note
     float(): 2ce. のデフォルトも提供します。

     The *note numerator: 254b. and *note denominator: 254c. values
     should be instances of *note Integral: 1f1d. and should be in
     lowest terms with *note denominator: 254c. positive.

      -- の属性: numerator

          抽象プロパティ。

      -- の属性: denominator

          抽象プロパティ。

 -- クラス: numbers.Integral

     *note Rational: 1290. をサブタイプ化し *note int: 238. への変換が加
     わります。 *note float(): 2ce, *note numerator: 254b, *note
     denominator: 254c. のデフォルトを提供します。法 (訳注: 割る数、除数
     のこと) を持つ *note pow(): 9a0. に対する抽象メソッドと、ビット列演
     算 ‘<<’, ‘>>’, ‘&’, ‘^’, ‘|’, ‘~’ を追加します。


File: python.info,  Node: Notes for type implementers,  Prev: 数値塔,  Up: numbers --- 数の抽象基底クラス

5.9.1.2 Notes for type implementers
...................................

Implementers should be careful to make equal numbers equal and hash them
to the same values.  This may be subtle if there are two different
extensions of the real numbers.  For example, *note fractions.Fraction:
1c8. implements *note hash(): 5b5. as follows:

     def __hash__(self):
         if self.denominator == 1:
             # Get integers right.
             return hash(self.numerator)
         # Expensive check, but definitely correct.
         if self == float(self):
             return hash(float(self))
         else:
             # Use tuple's hash to avoid a high collision rate on
             # simple fractions.
             return hash((self.numerator, self.denominator))

* Menu:

* さらに数のABCを追加する::
* 算術演算の実装::


File: python.info,  Node: さらに数のABCを追加する,  Next: 算術演算の実装,  Up: Notes for type implementers

5.9.1.3 さらに数のABCを追加する
...............................

数に対する ABC が他にも多く存在しうることは、言うまでもありません。それ
らの ABC を階層に追加する可能性が閉ざされるとしたら、その階層は貧相な階
層でしかありません。たとえば、 ‘MyFoo’ を *note Complex: 2547. と *note
Real: 20fb. の間に付け加えるには、次のようにします:

     class MyFoo(Complex): ...
     MyFoo.register(Real)


File: python.info,  Node: 算術演算の実装,  Prev: さらに数のABCを追加する,  Up: Notes for type implementers

5.9.1.4 算術演算の実装
......................

We want to implement the arithmetic operations so that mixed-mode
operations either call an implementation whose author knew about the
types of both arguments, or convert both to the nearest built in type
and do the operation there.  For subtypes of *note Integral: 1f1d, this
means that *note __add__(): 1eed. and *note __radd__(): 1eee. should be
defined as:

     class MyIntegral(Integral):

         def __add__(self, other):
             if isinstance(other, MyIntegral):
                 return do_my_adding_stuff(self, other)
             elif isinstance(other, OtherTypeIKnowAbout):
                 return do_my_other_adding_stuff(self, other)
             else:
                 return NotImplemented

         def __radd__(self, other):
             if isinstance(other, MyIntegral):
                 return do_my_adding_stuff(other, self)
             elif isinstance(other, OtherTypeIKnowAbout):
                 return do_my_other_adding_stuff(other, self)
             elif isinstance(other, Integral):
                 return int(other) + int(self)
             elif isinstance(other, Real):
                 return float(other) + float(self)
             elif isinstance(other, Complex):
                 return complex(other) + complex(self)
             else:
                 return NotImplemented

ここには5つの異なる *note Complex: 2547. のサブクラス間の混在型の演算が
あります。上のコードの中で ‘MyIntegral’ と ‘OtherTypeIKnowAbout’ に触れ
ない部分を "ボイラープレート" と呼ぶことにしましょう。 ‘a’ を *note
Complex: 2547. のサブタイプである ‘A’ のインスタンス (‘a : A <:
Complex’)、同様に ‘b : B <: Complex’ として、 ‘a + b’ を考えます:

  1. If ‘A’ defines an *note __add__(): 1eed. which accepts ‘b’, all is
     well.

  2. If ‘A’ falls back to the boilerplate code, and it were to return a
     value from *note __add__(): 1eed, we'd miss the possibility that
     ‘B’ defines a more intelligent *note __radd__(): 1eee, so the
     boilerplate should return *note NotImplemented: 79d. from
     ‘__add__()’.  (Or ‘A’ may not implement ‘__add__()’ at all.)

  3. Then ‘B’'s *note __radd__(): 1eee. gets a chance.  If it accepts
     ‘a’, all is well.

  4. ここでボイラープレートに落ち込むならば、もう他に試すべきメソッドは
     ありませんので、デフォルト実装の出番です。

  5. もし ‘B <: A’ ならば、Python は ‘A.__add__’ の前に ‘B.__radd__’ を
     試します。これで良い理由は、 ‘A’ についての知識を持って実装しており
     、 *note Complex: 2547. に委ねる前にこれらのインスタンスを扱えるは
     ずだからです。

If ‘A <: Complex’ and ‘B <: Real’ without sharing any other knowledge,
then the appropriate shared operation is the one involving the built in
*note complex: 2cf, and both *note __radd__(): 1eee. s land there, so
‘a+b == b+a’.

ほとんどの演算はどのような型についても非常に良く似ていますので、与えられ
た演算子について順結合(forward)および逆結合(reverse)のメソッドを生成する
支援関数を定義することは役に立ちます。たとえば、 *note
fractions.Fraction: 1c8. では次のようなものを利用しています:

     def _operator_fallbacks(monomorphic_operator, fallback_operator):
         def forward(a, b):
             if isinstance(b, (int, Fraction)):
                 return monomorphic_operator(a, b)
             elif isinstance(b, float):
                 return fallback_operator(float(a), b)
             elif isinstance(b, complex):
                 return fallback_operator(complex(a), b)
             else:
                 return NotImplemented
         forward.__name__ = '__' + fallback_operator.__name__ + '__'
         forward.__doc__ = monomorphic_operator.__doc__

         def reverse(b, a):
             if isinstance(a, Rational):
                 # Includes ints.
                 return monomorphic_operator(a, b)
             elif isinstance(a, Real):
                 return fallback_operator(float(a), float(b))
             elif isinstance(a, Complex):
                 return fallback_operator(complex(a), complex(b))
             else:
                 return NotImplemented
         reverse.__name__ = '__r' + fallback_operator.__name__ + '__'
         reverse.__doc__ = monomorphic_operator.__doc__

         return forward, reverse

     def _add(a, b):
         """a + b"""
         return Fraction(a.numerator * b.denominator +
                         b.numerator * a.denominator,
                         a.denominator * b.denominator)

     __add__, __radd__ = _operator_fallbacks(_add, operator.add)

     # ...


File: python.info,  Node: math --- 数学関数,  Next: cmath --- 複素数用の数学関数,  Prev: numbers --- 数の抽象基底クラス,  Up: 数値と数学モジュール

5.9.2 ‘math’ -- 数学関数
------------------------

__________________________________________________________________

このモジュールは、 C 標準で定義された数学関数へのアクセスを提供します。

これらの関数で複素数を使うことはできません。複素数に対応する必要があるな
らば、 *note cmath: 11. モジュールにある同じ名前の関数を使ってください。
ほとんどのユーザーは複素数を理解するのに必要なだけの数学を勉強したくない
ので、複素数に対応した関数と対応していない関数の区別がされています。これ
らの関数では複素数が利用できないため、引数に複素数を渡されると、複素数の
結果が返るのではなく例外が発生します。その結果、どういった理由で例外が送
出されたかに早い段階で気づく事ができます。

このモジュールでは次の関数を提供しています。明示的な注記のない限り、戻り
値は全て浮動小数点数になります。

'Number-theoretic and representation functions'

*note ceil(x): 136a.                                     Ceiling of 'x', the smallest integer greater than or equal to 'x'
                                                         
                                                         
*note comb(n, k): 69b.                                   Number of ways to choose 'k' items from 'n' items without repetition and without order
                                                         
                                                         
*note copysign(x, y): 137b.                              Magnitude (absolute value) of 'x' with the sign of 'y'
                                                         
                                                         
*note fabs(x): 2552.                                     Absolute value of 'x'
                                                         
                                                         
*note factorial(n): 915.                                 'n' factorial
                                                         
                                                         
*note floor (x): 1369.                                   Floor of 'x', the largest integer less than or equal to 'x'
                                                         
                                                         
*note fma(x, y, z): 1e6.                                 Fused multiply-add operation: ‘(x * y) + z’
                                                         
                                                         
*note fmod(x, y): 1fc8.                                  Remainder of division ‘x / y’
                                                         
                                                         
*note frexp(x): 2553.                                    Mantissa and exponent of 'x'
                                                         
                                                         
*note fsum(iterable): 137c.                              Sum of values in the input 'iterable'
                                                         
                                                         
*note gcd(*integers): 8de.                               Greatest common divisor of the integer arguments
                                                         
                                                         
*note isclose(a, b, rel_tol, abs_tol): d7d.              Check if the values 'a' and 'b' are close to each other
                                                         
                                                         
*note isfinite(x): 11bc.                                 Check if 'x' is neither an infinity nor a NaN
                                                         
                                                         
*note isinf(x): 1379.                                    Check if 'x' is a positive or negative infinity
                                                         
                                                         
*note isnan(x): 137a.                                    Check if 'x' is a NaN (not a number)
                                                         
                                                         
*note isqrt(n): 9d3.                                     Integer square root of a nonnegative integer 'n'
                                                         
                                                         
*note lcm(*integers): 8df.                               Least common multiple of the integer arguments
                                                         
                                                         
*note ldexp(x, i): 2554.                                 ‘x * (2**i)’, inverse of function *note frexp(): 2553.
                                                         
                                                         
*note modf(x): 2555.                                     Fractional and integer parts of 'x'
                                                         
                                                         
*note nextafter(x, y, steps): 465.                       Floating-point value 'steps' steps after 'x' towards 'y'
                                                         
                                                         
*note perm(n, k): 69c.                                   Number of ways to choose 'k' items from 'n' items without repetition and with order
                                                         
                                                         
*note prod(iterable, start): 9d2.                        Product of elements in the input 'iterable' with a 'start' value
                                                         
                                                         
*note remainder(x, y): b21.                              Remainder of 'x' with respect to 'y'
                                                         
                                                         
*note sumprod(p, q): 464.                                Sum of products from two iterables 'p' and 'q'
                                                         
                                                         
*note trunc(x): 136b.                                    Integer part of 'x'
                                                         
                                                         
*note ulp(x): 8e0.                                       Value of the least significant bit of 'x'
                                                         
                                                         
'Power and logarithmic functions'

*note cbrt(x): 62d.                                      Cube root of 'x'
                                                         
                                                         
*note exp(x): 12e3.                                      'e' raised to the power 'x'
                                                         
                                                         
*note exp2(x): 62c.                                      '2' raised to the power 'x'
                                                         
                                                         
*note expm1(x): 11bd.                                    'e' raised to the power 'x', minus 1
                                                         
                                                         
*note log(x, base): 1465.                                Logarithm of 'x' to the given base ('e' by default)
                                                         
                                                         
*note log1p(x): 1380.                                    Natural logarithm of '1+x' (base 'e')
                                                         
                                                         
*note log2(x): 10af.                                     Base-2 logarithm of 'x'
                                                         
                                                         
*note log10(x): 2556.                                    Base-10 logarithm of 'x'
                                                         
                                                         
*note pow(x, y): 62e.                                    'x' raised to the power 'y'
                                                         
                                                         
*note sqrt(x): 9d4.                                      Square root of 'x'
                                                         
                                                         
'Trigonometric functions'

*note acos(x): 2557.                                     Arc cosine of 'x'
                                                         
                                                         
*note asin(x): 2558.                                     Arc sine of 'x'
                                                         
                                                         
*note atan(x): 2559.                                     Arc tangent of 'x'
                                                         
                                                         
*note atan2(y, x): 255a.                                 ‘atan(y / x)’
                                                         
                                                         
*note cos(x): 1464.                                      Cosine of 'x'
                                                         
                                                         
*note dist(p, q): 9d0.                                   Euclidean distance between two points 'p' and 'q' given as an iterable of coordinates
                                                         
                                                         
*note hypot(*coordinates): 9d1.                          Euclidean norm of an iterable of coordinates
                                                         
                                                         
*note sin(x): 1463.                                      Sine of 'x'
                                                         
                                                         
*note tan(x): 255b.                                      Tangent of 'x'
                                                         
                                                         
'Angular conversion'

*note degrees(x): 255c.                                  Convert angle 'x' from radians to degrees
                                                         
                                                         
*note radians(x): 255d.                                  Convert angle 'x' from degrees to radians
                                                         
                                                         
'Hyperbolic functions'

*note acosh(x): 137d.                                    Inverse hyperbolic cosine of 'x'
                                                         
                                                         
*note asinh(x): 137e.                                    Inverse hyperbolic sine of 'x'
                                                         
                                                         
*note atanh(x): 137f.                                    Inverse hyperbolic tangent of 'x'
                                                         
                                                         
*note cosh(x): 255e.                                     Hyperbolic cosine of 'x'
                                                         
                                                         
*note sinh(x): 255f.                                     Hyperbolic sine of 'x'
                                                         
                                                         
*note tanh(x): 2560.                                     Hyperbolic tangent of 'x'
                                                         
                                                         
'Special functions'

*note erf(x): ba6.                                       Error function(1) at 'x'
                                                         
                                                         
*note erfc(x): ba7.                                      Complementary error function(2) at 'x'
                                                         
                                                         
*note gamma(x): 11be.                                    Gamma function(3) at 'x'
                                                         
                                                         
*note lgamma(x): 11bf.                                   Natural logarithm of the absolute value of the Gamma function(4) at 'x'
                                                         
                                                         
'Constants'

*note pi: 2561.                                          'π' = 3.141592...
                                                         
                                                         
*note e: 2562.                                           'e' = 2.718281...
                                                         
                                                         
*note tau: 2563.                                         'τ' = 2'π' = 6.283185...
                                                         
                                                         
*note inf: c50.                                          Positive infinity
                                                         
                                                         
*note nan: 62f.                                          "Not a number" (NaN)
                                                         

* Menu:

* 数論および数表現の関数::
* 指数関数と対数関数::
* 三角関数::
* 角度変換::
* 双曲線関数::
* 特殊関数::
* 定数: 定数<2>.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Error_function

   (2) https://en.wikipedia.org/wiki/Error_function

   (3) https://en.wikipedia.org/wiki/Gamma_function

   (4) https://en.wikipedia.org/wiki/Gamma_function


File: python.info,  Node: 数論および数表現の関数,  Next: 指数関数と対数関数,  Up: math --- 数学関数

5.9.2.1 数論および数表現の関数
..............................

 -- の関数: math.ceil (x)

     'x' の「天井」 ('x' 以上の最小の整数) を返します。 'x' が浮動小数点
     数でなければ、内部的に *note x.__ceil__: 1f1c. が実行され、 *note
     Integral: 1f1d. 値が返されます。

 -- の関数: math.comb (n, k)

     'n' 個の中から 'k' 個を重複無く順序をつけずに選ぶ方法の数を返します
     。

     ‘k <= n’ のとき ‘n! / (k! * (n - k)!)’ と評価し、‘k > n’ のとき 0 と
     評価します。

     これは ‘(1 + x)ⁿ’ の多項式展開における第 k 項の係数と等しいので、二
     項係数とも呼ばれます。

     いずれかの引数が整数でないなら *note TypeError: 502. を送出します。
     いずれかの引数が負であれば *note ValueError: 1e3. を送出します。

     Added in version 3.8.

 -- の関数: math.copysign (x, y)

     'x' の大きさ (絶対値) で 'y' と同じ符号の浮動小数点数を返します。符
     号付きのゼロをサポートしているプラットフォームでは、‘copysign(1.0,
     -0.0)’ は '-1.0' を返します。

 -- の関数: math.fabs (x)

     'x' の絶対値を返します。

 -- の関数: math.factorial (n)

     'n' の階乗を整数で返します。'n' が整数でないか、負の数の場合は、
     *note ValueError: 1e3. を送出します。

     バージョン 3.10 で変更: Floats with integral values (like ‘5.0’)
     are no longer accepted.

 -- の関数: math.floor (x)

     'x' の「床」 ('x' 以下の最大の整数) を返します。 'x' が浮動小数点数
     でなければ、内部的に *note x.__floor__: 1f1b. が実行され、 *note
     Integral: 1f1d. 値が返されます。

 -- の関数: math.fma (x, y, z)

     Fused multiply-add operation.  Return ‘(x * y) + z’, computed as
     though with infinite precision and range followed by a single round
     to the ‘float’ format.  This operation often provides better
     accuracy than the direct expression ‘(x * y) + z’.

     This function follows the specification of the fusedMultiplyAdd
     operation described in the IEEE 754 standard.  The standard leaves
     one case implementation-defined, namely the result of ‘fma(0, inf,
     nan)’ and ‘fma(inf, 0, nan)’.  In these cases, ‘math.fma’ returns a
     NaN, and does not raise any exception.

     Added in version 3.13.

 -- の関数: math.fmod (x, y)

     プラットフォームの C ライブラリで定義されている ‘fmod(x, y)’ を返し
     ます。 Python の ‘x % y’ という式は必ずしも同じ結果を返さないという
     ことに注意してください。 C 標準の要求では、 ‘fmod(x, y)’ は厳密に
     (数学的に、つまり無限の精度で) ‘x - n*y’ と等価であるよう求めていま
     す。'n' は結果が 'x' と同じ符号と ‘abs(y)’ より小さい絶対値を持つよ
     うなある整数です。Python の ‘x % y’ は、 'y' と同じ符号の結果を返し
     、浮動小数点の引数に対して厳密な解を出せないことがあります。例えば
     、 ‘fmod(-1e-100, 1e100)’ は ‘-1e-100’ ですが、 Python の ‘-1e-100
     % 1e100’ は ‘1e100-1e-100’ になり、浮動小数点型で厳密に表現できず、
     ややこしいことに ‘1e100’ に丸められます。このため、一般には浮動小数
     点の場合には関数 *note fmod(): 1fc8. 、整数の場合には ‘x % y’ を使
     う方がよいでしょう。

 -- の関数: math.frexp (x)

     'x' の仮数と指数を ‘(m, e)’ のペアとして返します。'm' はfloat型で、
     'e' は厳密に ‘x == m * 2**e’ であるような整数型です。'x' がゼロの場
     合は、‘(0.0, 0)’ を返し、それ以外の場合は、‘0.5 <= abs(m) < 1’ です
     。これは浮動小数点型の内部表現を可搬性を保ったまま "分解 (pick
     apart)" するために使われます。

 -- の関数: math.fsum (iterable)

     Return an accurate floating-point sum of values in the iterable.
     Avoids loss of precision by tracking multiple intermediate partial
     sums.

     アルゴリズムの正確性は、 IEEE-754 演算の保証と、丸めモードが偶数丸
     め (half-even) である典型的な場合に依存します。Windows 以外のいくつ
     かのビルドでは、下層の C ライブラリが拡張精度の加算を行い、時々計算
     途中の和を double 型へ丸めてしまうため、最下位ビットが消失すること
     があります。

     For further discussion and two alternative approaches, see the ASPN
     cookbook recipes for accurate floating-point summation(1).

 -- の関数: math.gcd (*integers)

     指定された整数引数の最大公約数を返します。0 でない引数があれば、返
     される値は全ての引数の約数である最大の正の整数です。全ての引数が 0
     なら、返される値は ‘0’ です。引数の無い ‘gcd()’ は ‘0’ を返します。

     Added in version 3.5.

     バージョン 3.9 で変更: 任意の数の引数のサポートが追加されました。以
     前は、二つの引数のみがサポートされていました。

 -- の関数: math.isclose (a, b, *, rel_tol=1e-09, abs_tol=0.0)

     値 'a' と 'b' が互いに近い場合 ‘True’ を、そうでない場合は ‘False’
     を返します。

     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)’.

     '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'.  For example, to set a tolerance of 5%, pass
     ‘rel_tol=0.05’.  The default tolerance is ‘1e-09’, which assures
     that the two values are the same within about 9 decimal digits.
     'rel_tol' must be nonnegative and less than ‘1.0’.

     'abs_tol' is the absolute tolerance; it defaults to ‘0.0’ and it
     must be nonnegative.  When comparing ‘x’ to ‘0.0’, ‘isclose(x, 0)’
     is computed as ‘abs(x) <= rel_tol * abs(x)’, which is ‘False’ for
     any ‘x’ and rel_tol less than ‘1.0’.  So add an appropriate
     positive abs_tol argument to the call.

     IEEE 754 特殊値 ‘NaN’、‘inf’、‘-inf’ は IEEE の規則に従って処理され
     ます。 具体的には、‘NaN’ は自身を含めたあらゆる値に近いとは見なされ
     ません。 ‘inf’ と ‘-inf’ は自身とのみ近いと見なされます。

     Added in version 3.5.

     参考
     ....

     PEP 485(2) - A function for testing approximate equality

 -- の関数: math.isfinite (x)

     'x' が無限でも NaN でもない場合に ‘True’ を返します。それ以外の時に
     は ‘False’ を返します。 (注意: ‘0.0’ は有限数と扱われます。)

     Added in version 3.2.

 -- の関数: math.isinf (x)

     'x' が正ないし負の無限数ならば ‘True’ を返します。それ以外の時には
     ‘False’ を返します。

 -- の関数: math.isnan (x)

     'x' がNaN (not a number、非数) の時に ‘True’ を返します。それ以外の
     場合には ‘False’ を返します。

 -- の関数: math.isqrt (n)

     非負整数 'n' の整数平方根を返します。これは 'n' の正確な平方根の床
     であり、 'a'² ≤ 'n' を満たす最大の整数 'a' と等価です。

     少し応用すれば、'n' ≤ 'a'² を満たす最小の整数 'a' 、言い換えれば
     'n' の正確な平方根の天井を効率的に得られます。正の 'n' に対して、こ
     れは ‘a = 1 + isqrt(n - 1)’ を使って計算できます。

     Added in version 3.8.

 -- の関数: math.lcm (*integers)

     指定された整数引数の最小公倍数を返します。全ての引数が 0 でなければ
     、返される値は全ての引数の倍数である最小の正の整数です。引数に 0 が
     あれば、返される値は ‘0’ です。引数の無い ‘lcm()’ は ‘1’ を返します
     。

     Added in version 3.9.

 -- の関数: math.ldexp (x, i)

     ‘x * (2**i)’ を返します。これは本質的に *note frexp(): 2553. の逆関
     数です。

 -- の関数: math.modf (x)

     'x' の小数部分と整数部分を返します。両方の結果は 'x' の符号を受け継
     ぎます。整数部はfloat型で返されます。

 -- の関数: math.nextafter (x, y, steps=1)

     Return the floating-point value 'steps' steps after 'x' towards
     'y'.

     If 'x' is equal to 'y', return 'y', unless 'steps' is zero.

     例:

        * ‘math.nextafter(x, math.inf)’ goes up: towards positive
          infinity.

        * ‘math.nextafter(x, -math.inf)’ goes down: towards minus
          infinity.

        * ‘math.nextafter(x, 0.0)’ は 0 に近づきます。

        * ‘math.nextafter(x, math.copysign(math.inf, x))’ は 0 から遠ざ
          かります。

     *note math.ulp(): 8e0. を参照してください。

     Added in version 3.9.

     バージョン 3.12 で変更: Added the 'steps' argument.

 -- の関数: math.perm (n, k=None)

     'n' 個の中から 'k' 個を重複無く順序をつけて選ぶ方法の数を返します。

     ‘k <= n’ のとき ‘n! / (n - k)!’ と評価し、‘k > n’ のとき 0 と評価し
     ます。

     If 'k' is not specified or is ‘None’, then 'k' defaults to 'n' and
     the function returns ‘n!’.

     いずれかの引数が整数でないなら *note TypeError: 502. を送出します。
     いずれかの引数が負であれば *note ValueError: 1e3. を送出します。

     Added in version 3.8.

 -- の関数: math.prod (iterable, *, start=1)

     入力 'iterable' の全ての要素の積を計算します。積のデフォルト
     'start' 値は ‘1’ です。

     イテラブルが空のとき、初期値を返します。この関数は特に数値に使うこ
     とを意図されており、非数値を受け付けないことがあります。

     Added in version 3.8.

 -- の関数: math.remainder (x, y)

     IEEE 754 標準方式の 'x' を 'y' で割った剰余を返します。 有限な 'x'
     と有限な 'y' では、分数 ‘x / y’ の厳密な値に最も近い整数を ‘n’ とし
     て、 ‘x - n*y’ がこの返り値となります。 ‘x / y’ が隣り合う 2 つの整
     数のちょうど真ん中だった場合は、最も近い '偶数' が ‘n’ として使われ
     ます。 従って、剰余 ‘r = remainder(x, y)’ は常に ‘abs(r) <= 0.5 *
     abs(y)’ を満たします。

     特殊なケースについては IEEE 754 に従います: 任意の有限な 'x' に対す
     る ‘remainder(x, math.inf)’ 、および任意の非 NaN の 'x' に対する
     ‘remainder(x, 0)’ と ‘remainder(math.inf, x)’ は *note ValueError:
     1e3. を送出します。 剰余演算の結果がゼロの場合、そのゼロは 'x' と同
     じ符号を持ちます。

     On platforms using IEEE 754 binary floating point, the result of
     this operation is always exactly representable: no rounding error
     is introduced.

     Added in version 3.7.

 -- の関数: math.sumprod (p, q)

     Return the sum of products of values from two iterables 'p' and
     'q'.

     Raises *note ValueError: 1e3. if the inputs do not have the same
     length.

     およそ次と等価です:

          sum(itertools.starmap(operator.mul, zip(p, q, strict=True)))

     For float and mixed int/float inputs, the intermediate products and
     sums are computed with extended precision.

     Added in version 3.12.

 -- の関数: math.trunc (x)

     'x' の小数部を取り除き、残った整数部を返します。これは 0 に向かって
     丸められます: ‘trunc()’ は正の 'x' に対しては *note floor(): 1369.
     に等しく、負の 'x' に対しては *note ceil(): 136a. に等しいです。'x'
     が浮動小数点数でなければ、内部的に *note x.__trunc__: 6e6. が実行さ
     れ、 *note Integral: 1f1d. 値が返されます。

 -- の関数: math.ulp (x)

     浮動小数点数 'x' の最下位ビットの値を返します:

        * 'x' が NaN (非数) なら、'x' を返します。

        * 'x' が負なら、‘ulp(-x)’ を返します。

        * 'x' が正の無限大なら、'x' を返します。

        * 'x' が 0 に等しければ、(最小の正の '正規化' 浮動小数点数 *note
          sys.float_info.min: 1956. よりも小さい) 最小の正の表現可能な
          '非正規化' 浮動小数点数を返します。

        * 'x' が表現可能な最大の正の浮動小数点数に等しいなら、'x' より小
          さい最初の浮動小数点数が ‘x - ulp(x)’ であるような、'x' の最下
          位ビットの値を返します。

        * それ以外 ('x' が正の有限な数) なら、'x' より大きい最初の浮動小
          数点数が ‘x + ulp(x)’ であるような、'x' の最下位ビットの値を返
          します。

     ULP は "Unit in the Last Place" の略です。

     *note math.nextafter(): 465. および *note sys.float_info.epsilon:
     1956. も参照してください。

     Added in version 3.9.

*note frexp(): 2553. と *note modf(): 2555. は C のものとは異なった呼び
出し/返しパターンを持っていることに注意してください。引数を1つだけ受け取
り、1組のペアになった値を返すので、2つ目の戻り値を '出力用の引数' 経由で
返したりはしません (Python には出力用の引数はありません)。

*note ceil(): 136a. 、 *note floor(): 1369. 、および *note modf(): 2555.
関数については、非常に大きな浮動小数点数が '全て' 整数そのものになるとい
うことに注意してください。通常、Python の浮動小数点型は 53 ビット以上の
精度をもたない (プラットフォームにおける C double 型と同じ) ので、結果的
に ‘abs(x) >= 2**52’ であるような浮動小数点型 'x' は小数部分を持たなくな
るのです。

   ---------- Footnotes ----------

   (1) 
https://code.activestate.com/recipes/393090-binary-floating-point-summation-accurate-to-full-p/

   (2) https://peps.python.org/pep-0485/


File: python.info,  Node: 指数関数と対数関数,  Next: 三角関数,  Prev: 数論および数表現の関数,  Up: math --- 数学関数

5.9.2.2 指数関数と対数関数
..........................

 -- の関数: math.cbrt (x)

     'x' の立方根を返します。

     Added in version 3.11.

 -- の関数: math.exp (x)

     'e' = 2.718281...  を自然対数の底として、 'e' の 'x' 乗を返します。
     この値は、通常は ‘math.e ** x’ や ‘pow(math.e, x)’ よりも精度が高い
     です。

 -- の関数: math.exp2 (x)

     '2' の 'x' 乗を返します。

     Added in version 3.11.

 -- の関数: math.expm1 (x)

     Return 'e' raised to the power 'x', minus 1.  Here 'e' is the base
     of natural logarithms.  For small floats 'x', the subtraction in
     ‘exp(x) - 1’ can result in a significant loss of precision(1); the
     *note expm1(): 11bd. function provides a way to compute this
     quantity to full precision:

          >>> from math import exp, expm1
          >>> exp(1e-5) - 1  # gives result accurate to 11 places
          1.0000050000069649e-05
          >>> expm1(1e-5)    # result accurate to full precision
          1.0000050000166668e-05

     Added in version 3.2.

 -- の関数: math.log (x[, base])

     引数が1つの場合、'x' の ('e' を底とする)自然対数を返します。

     引数が2つの場合、‘log(x)/log(base)’ として求められる 'base' を底と
     した 'x' の対数を返します。

 -- の関数: math.log1p (x)

     '1+x' の自然対数(つまり底 'e' の対数)を返します。結果はゼロに近い
     'x' に対して正確になるような方法で計算されます。

 -- の関数: math.log2 (x)

     2を底とする 'x' の対数を返します。この関数は、一般に ‘log(x, 2)’ よ
     りも正確な値を返します。

     Added in version 3.3.

     参考
     ....

     *note int.bit_length(): 20ff. は、その整数を二進法で表すのに何ビッ
     ト必要かを返す関数です。符号と先頭のゼロは無視されます。

 -- の関数: math.log10 (x)

     'x' の10を底とした対数(常用対数)を返します。この関数は通常、‘log(x,
     10)’ よりも高精度です。

 -- の関数: math.pow (x, y)

     Return 'x' raised to the power 'y'.  Exceptional cases follow the
     IEEE 754 standard as far as possible.  In particular, ‘pow(1.0, x)’
     and ‘pow(x, 0.0)’ always return ‘1.0’, even when 'x' is a zero or a
     NaN. If both 'x' and 'y' are finite, 'x' is negative, and 'y' is
     not an integer then ‘pow(x, y)’ is undefined, and raises *note
     ValueError: 1e3.

     組み込みの ‘**’ 演算子と違って、 *note math.pow(): 62e. は両方の引
     数を *note float: 2ce. 型に変換します。正確な整数の冪乗を計算するに
     は ‘**’ もしくは組み込みの *note pow(): 9a0. 関数を使ってください。

     バージョン 3.11 で変更: IEEE 754 との一貫性のため、特殊な例である
     ‘pow(0.0, -inf)’ および ‘pow(-0.0, -inf)’ は *note ValueError: 1e3.
     を送出する代わりに ‘inf’ を返すように変更されました。

 -- の関数: math.sqrt (x)

     'x' の平方根を返します。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Loss_of_significance


File: python.info,  Node: 三角関数,  Next: 角度変換,  Prev: 指数関数と対数関数,  Up: math --- 数学関数

5.9.2.3 三角関数
................

 -- の関数: math.acos (x)

     'x' の逆余弦を、ラジアンで返します。結果は ‘0’ と ‘pi’ の間です。

 -- の関数: math.asin (x)

     'x' の逆正弦を、ラジアンで返します。結果は ‘-pi/2’ と ‘pi/2’ の間で
     す。

 -- の関数: math.atan (x)

     'x' の逆正接を、ラジアンで返します。結果は ‘-pi/2’ と ‘pi/2’ の間で
     す。

 -- の関数: math.atan2 (y, x)

     ‘atan(y / x)’ を、ラジアンで返します。戻り値は ‘-pi’ から ‘pi’ の間
     になります。この角度は、極座標平面において原点から ‘(x, y)’ へのベ
     クトルが X 軸の正の方向となす角です。 *note atan2(): 255a. のポイン
     トは、両方の入力の符号が既知であるために、位相角の正しい象限を計算
     できることにあります。例えば、 ‘atan(1)’ と ‘atan2(1, 1)’ はいずれ
     も ‘pi/4’ ですが、 ‘atan2(-1, -1)’ は ‘-3*pi/4’ になります。

 -- の関数: math.cos (x)

     'x' ラジアンの余弦を返します。

 -- の関数: math.dist (p, q)

     それぞれ座標のシーケンス (またはイテラブル) として与えられる点 'p'
     と 'q' の間のユークリッド距離を返します。二点の次元は同じでなければ
     なりません。

     およそ次と等価です:

          sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))

     Added in version 3.8.

 -- の関数: math.hypot (*coordinates)

     ユークリッドノルム ‘sqrt(sum(x**2 for x in coordinates))’ を返しま
     す。これは原点から座標で与えられる点までのベクトルの長さです。

     二次元の点 ‘(x, y)’ では、これは直角三角形の斜辺をピタゴラスの定理
     ‘sqrt(x*x + y*y)’ を用いて計算することと等価です。

     バージョン 3.8 で変更: n 次元の点のサポートが追加されました。以前は
     、二次元の場合しかサポートされていませんでした。

     バージョン 3.10 で変更: アルゴリズムの精度を改良し、最大の誤差が 1
     ulp (最終桁単位) 未満になりました。より一般的には、結果はほとんどの
     場合に 1/2 ulp 以内に正しく丸められます。

 -- の関数: math.sin (x)

     'x' ラジアンの正弦を返します。

 -- の関数: math.tan (x)

     'x' ラジアンの正接を返します。


File: python.info,  Node: 角度変換,  Next: 双曲線関数,  Prev: 三角関数,  Up: math --- 数学関数

5.9.2.4 角度変換
................

 -- の関数: math.degrees (x)

     角 'x' をラジアンから度に変換します。

 -- の関数: math.radians (x)

     角 'x' を度からラジアンに変換します。


File: python.info,  Node: 双曲線関数,  Next: 特殊関数,  Prev: 角度変換,  Up: math --- 数学関数

5.9.2.5 双曲線関数
..................

Hyperbolic functions(1) are analogs of trigonometric functions that are
based on hyperbolas instead of circles.

 -- の関数: math.acosh (x)

     'x' の逆双曲線余弦を返します。

 -- の関数: math.asinh (x)

     'x' の逆双曲線正弦を返します。

 -- の関数: math.atanh (x)

     'x' の逆双曲線正接を返します。

 -- の関数: math.cosh (x)

     'x' の双曲線余弦を返します。

 -- の関数: math.sinh (x)

     'x' の双曲線正弦を返します。

 -- の関数: math.tanh (x)

     'x' の双曲線正接を返します。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Hyperbolic_functions


File: python.info,  Node: 特殊関数,  Next: 定数<2>,  Prev: 双曲線関数,  Up: math --- 数学関数

5.9.2.6 特殊関数
................

 -- の関数: math.erf (x)

     'x' の 誤差関数(1) を返します。

     The *note erf(): ba6. function can be used to compute traditional
     statistical functions such as the cumulative standard normal
     distribution(2):

          def phi(x):
              'Cumulative distribution function for the standard normal distribution'
              return (1.0 + erf(x / sqrt(2.0))) / 2.0

     Added in version 3.2.

 -- の関数: math.erfc (x)

     'x' の相補誤差関数を返します。相補誤差関数(3) は ‘1.0 - erf(x)’ と
     定義されます。この関数は、1からの引き算が 桁落ち(4) をするような大
     きな 'x' に対し使われます。

     Added in version 3.2.

 -- の関数: math.gamma (x)

     'x' の ガンマ関数(5) を返します。

     Added in version 3.2.

 -- の関数: math.lgamma (x)

     'x' のガンマ関数の絶対値の自然対数を返します。

     Added in version 3.2.

   ---------- Footnotes ----------

   (1) 
https://ja.wikipedia.org/wiki/%E8%AA%A4%E5%B7%AE%E9%96%A2%E6%95%B0

   (2) https://en.wikipedia.org/wiki/Cumulative_distribution_function

   (3) 
https://ja.wikipedia.org/wiki/%E8%AA%A4%E5%B7%AE%E9%96%A2%E6%95%B0

   (4) 
https://ja.wikipedia.org/wiki/%E8%AA%A4%E5%B7%AE#.E6.A1.81.E8.90.BD.E3.81.A1

   (5) 
https://ja.wikipedia.org/wiki/%E3%82%AC%E3%83%B3%E3%83%9E%E9%96%A2%E6%95%B0


File: python.info,  Node: 定数<2>,  Prev: 特殊関数,  Up: math --- 数学関数

5.9.2.7 定数
............

 -- データ: math.pi

     利用可能なだけの精度の数学定数 'π' = 3.141592...  (円周率)。

 -- データ: math.e

     利用可能なだけの精度の数学定数 'e' = 2.718281...  (自然対数の底)。

 -- データ: math.tau

     利用可能なだけの精度の数学定数 'τ' = 6.283185...  です。 タウは
     2'π' に等しい円定数で、円周と半径の比です。 タウについて学ぶには Vi
     Hart のビデオ Pi is (still) Wrong(1) をチェックして、パイを二倍食べ
     て Tau day(2) を祝い始めましょう！

     Added in version 3.6.

 -- データ: math.inf

     浮動小数の正の無限大です。(負の無限大には ‘-math.inf’ を使います。)
     ‘float('inf')’ の出力と等価です。

     Added in version 3.5.

 -- データ: math.nan

     A floating-point "not a number" (NaN) value.  Equivalent to the
     output of ‘float('nan')’.  Due to the requirements of the IEEE-754
     standard(3), ‘math.nan’ and ‘float('nan')’ are not considered to
     equal to any other numeric value, including themselves.  To check
     whether a number is a NaN, use the *note isnan(): 137a. function to
     test for NaNs instead of ‘is’ or ‘==’.  Example:

          >>> import math
          >>> math.nan == math.nan
          False
          >>> float('nan') == float('nan')
          False
          >>> math.isnan(math.nan)
          True
          >>> math.isnan(float('nan'))
          True

     Added in version 3.5.

     バージョン 3.11 で変更: 常に利用出来るようになりました。

'CPython 実装の詳細:' *note math: 81. モジュールは、ほとんどが実行プラッ
トフォームにおける C 言語の数学ライブラリ関数に対する薄いラッパでできて
います。 例外時の挙動は、適切である限り C99 標準の Annex F に従います。
現在の実装では、‘sqrt(-1.0)’ や ‘log(0.0)’ といった (C99 Annex F で不正
な演算やゼロ除算を通知することが推奨されている) 不正な操作に対して *note
ValueError: 1e3. を送出し、(例えば ‘exp(1000.0)’ のような) 演算結果がオ
ーバーフローする場合には *note OverflowError: 84e. を送出します。 上記の
関数群は、1つ以上の引数が NaN であった場合を除いて NaN を返しません。 引
数に NaN が与えられた場合は、殆どの関数は NaN を返しますが、 (C99 Annex
F に従って) 別の動作をする場合があります。 例えば、 ‘pow(float('nan'),
0.0)’ や ‘hypot(float('nan'), float('inf'))’ といった場合です。 訳注: 例
外が発生せずに結果が返ると、計算結果がおかしくなった原因が複素数を渡した
ためだということに気づくのが遅れる可能性があります。

Python は signaling NaN と quiet NaN を区別せず、signaling NaN に対する
挙動は未定義とされていることに注意してください。典型的な挙動は、全ての
NaN を quiet NaN として扱うことです。

参考
....

*note cmath: 11. モジュール

     これらの多くの関数の複素数版。

   ---------- Footnotes ----------

   (1) https://www.youtube.com/watch?v=jG7vhMMXagQ

   (2) https://tauday.com/

   (3) https://en.wikipedia.org/wiki/IEEE_754


File: python.info,  Node: cmath --- 複素数用の数学関数,  Next: decimal --- 10進固定小数点と浮動小数点の演算,  Prev: math --- 数学関数,  Up: 数値と数学モジュール

5.9.3 ‘cmath’ -- 複素数用の数学関数
-----------------------------------

__________________________________________________________________

このモジュールは、複素数を扱う数学関数へのアクセスを提供しています。 こ
のモジュール中の関数は整数、浮動小数点数または複素数を引数にとります。 ま
た、 *note __complex__(): 5b1. または *note __float__(): 99a. どちらかの
メソッドを提供している Python オブジェクトも受け付けます。 これらのメソ
ッドはそのオブジェクトを複素数または浮動小数点数に変換するのにそれぞれ使
われ、呼び出された関数はそうして変換された結果を利用します。

     注釈: 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 for complex elementary functions"
     paper, as well as Annex G of C99 and later C standards, we use the
     sign of zero to distinguish one side of the branch cut from the
     other: for a branch cut along (a portion of) the real 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.

     For example, the *note cmath.sqrt(): 256d. function has a branch
     cut along the negative real axis.  An argument of ‘complex(-2.0,
     -0.0)’ is treated as though it lies 'below' the branch cut, and so
     gives a result on the negative imaginary axis:

          >>> cmath.sqrt(complex(-2.0, -0.0))
          -1.4142135623730951j

     But an argument of ‘complex(-2.0, 0.0)’ is treated as though it
     lies above the branch cut:

          >>> cmath.sqrt(complex(-2.0, 0.0))
          1.4142135623730951j

* Menu:

* 極座標変換::
* 指数関数と対数関数: 指数関数と対数関数<2>.
* 三角関数: 三角関数<2>.
* 双曲線関数: 双曲線関数<2>.
* 類別関数::
* 定数: 定数<3>.


File: python.info,  Node: 極座標変換,  Next: 指数関数と対数関数<2>,  Up: cmath --- 複素数用の数学関数

5.9.3.1 極座標変換
..................

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’.

'極座標' は複素数を表現する別の方法です。極座標では、複素数 'z' は半径
'r' と位相角 'phi' で定義されます。半径 'r' は 'z' から原点までの距離で
す。位相 'phi' は x 軸の正の部分から原点と 'z' を結んだ線分までの角度を
反時計回りにラジアンで測った値です。

次の関数はネイティブの直交座標を極座標に変換したりその逆を行うのに使えま
す。

 -- の関数: cmath.phase (x)

     'x' の位相 ('x' の '偏角' とも呼びます) を浮動小数点数で返します。
     ‘phase(x)’ は ‘math.atan2(x.imag, x.real)’ と同等です。返り値は
     [-'π', 'π'] の範囲にあり、この演算の分枝切断は負の実軸に沿って延び
     ています。結果の符号は ‘x.imag’ がゼロであってさえ ‘x.imag’ の符号
     と等しくなります:

          >>> phase(complex(-1.0, 0.0))
          3.141592653589793
          >>> phase(complex(-1.0, -0.0))
          -3.141592653589793

     注釈: 複素数 'x' のモジュラス (絶対値) は組み込みの *note abs():
     1c0e. 関数で計算できます。この演算を行う *note cmath: 11. モジュー
     ルの関数はありません。

 -- の関数: cmath.polar (x)

     'x' の極座標表現を返します。'x' の半径 'r' と 'x' の位相 'phi' の組
     ‘(r, phi)’ を返します。‘polar(x)’ は ‘(abs(x), phase(x))’ に等しい
     です。

 -- の関数: cmath.rect (r, phi)

     Return the complex number 'x' with polar coordinates 'r' and 'phi'.
     Equivalent to ‘complex(r * math.cos(phi), r * math.sin(phi))’.


File: python.info,  Node: 指数関数と対数関数<2>,  Next: 三角関数<2>,  Prev: 極座標変換,  Up: cmath --- 複素数用の数学関数

5.9.3.2 指数関数と対数関数
..........................

 -- の関数: cmath.exp (x)

     'e' を自然対数の底として、 'e' の 'x' 乗を返します。

 -- の関数: cmath.log (x[, base])

     'base' を底とする 'x' の対数を返します。もし 'base' が指定されてい
     ない場合には、'x' の自然対数を返します。分枝切断を一つもち、‘0’ か
     ら負の実数軸に沿って ‘-∞’ へと延びています。

 -- の関数: cmath.log10 (x)

     'x' の底を 10 とする対数を返します。 *note log(): 2574. と同じ分枝
     切断を持ちます。

 -- の関数: cmath.sqrt (x)

     'x' の平方根を返します。 *note log(): 2574. と同じ分枝切断を持ちま
     す。


File: python.info,  Node: 三角関数<2>,  Next: 双曲線関数<2>,  Prev: 指数関数と対数関数<2>,  Up: cmath --- 複素数用の数学関数

5.9.3.3 三角関数
................

 -- の関数: cmath.acos (x)

     'x' の逆余弦を返します。この関数には二つの分枝切断 (branch cut) が
     あります: 一つは 1 から右側に実数軸に沿って∞へと延びています。もう
     一つは -1 から左側に実数軸に沿って -∞へと延びています。

 -- の関数: cmath.asin (x)

     'x' の逆正弦を返します。 *note acos(): 2577. と同じ分枝切断を持ちま
     す。

 -- の関数: cmath.atan (x)

     'x' の逆正接を返します。二つの分枝切断があります: 一つは ‘1j’ から
     虚数軸に沿って ‘∞j’ へと延びています。もう一つは ‘-1j’ から虚数軸に
     沿って ‘-∞j’ へと延びています。

 -- の関数: cmath.cos (x)

     'x' の余弦を返します。

 -- の関数: cmath.sin (x)

     'x' の正弦を返します。

 -- の関数: cmath.tan (x)

     'x' の正接を返します。


File: python.info,  Node: 双曲線関数<2>,  Next: 類別関数,  Prev: 三角関数<2>,  Up: cmath --- 複素数用の数学関数

5.9.3.4 双曲線関数
..................

 -- の関数: cmath.acosh (x)

     'x' の逆双曲線余弦を返します。分枝切断が一つあり、1 の左側に実数軸
     に沿って -∞へと延びています。

 -- の関数: cmath.asinh (x)

     'x' の逆双曲線正弦を返します。二つの分枝切断があります: 一つは ‘1j’
     から虚数軸に沿って ‘∞j’ へと延びています。もう一つは ‘-1j’ から虚数
     軸に沿って ‘-∞j’ へと延びています。

 -- の関数: cmath.atanh (x)

     'x' の逆双曲線正接を返します。二つの分枝切断があります: 一つは ‘1’
     から実数軸に沿って ‘∞’ へと延びています。もう一つは ‘-1’ から実数軸
     に沿って ‘-∞’ へと延びています。

 -- の関数: cmath.cosh (x)

     'x' の双曲線余弦を返します。

 -- の関数: cmath.sinh (x)

     'x' の双曲線正弦を返します。

 -- の関数: cmath.tanh (x)

     'x' の双曲線正接を返します。


File: python.info,  Node: 類別関数,  Next: 定数<3>,  Prev: 双曲線関数<2>,  Up: cmath --- 複素数用の数学関数

5.9.3.5 類別関数
................

 -- の関数: cmath.isfinite (x)

     'x' の実部、虚部ともに有限であれば ‘True’ を返し、それ以外の場合
     ‘False’ を返します。

     Added in version 3.2.

 -- の関数: cmath.isinf (x)

     'x' の実数部または虚数部が正または負の無限大であれば ‘True’ を、そ
     うでなければ ‘False’ を返します。

 -- の関数: cmath.isnan (x)

     'x' の実部と虚部のどちらかが NaN のとき ‘True’ を返し、それ以外の場
     合 ‘False’ を返します。

 -- の関数: cmath.isclose (a, b, *, rel_tol=1e-09, abs_tol=0.0)

     値 'a' と 'b' が互いに近い場合 ‘True’ を、そうでない場合は ‘False’
     を返します。

     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)’.

     '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'.  For example, to set a tolerance of 5%, pass
     ‘rel_tol=0.05’.  The default tolerance is ‘1e-09’, which assures
     that the two values are the same within about 9 decimal digits.
     'rel_tol' must be nonnegative and less than ‘1.0’.

     'abs_tol' is the absolute tolerance; it defaults to ‘0.0’ and it
     must be nonnegative.  When comparing ‘x’ to ‘0.0’, ‘isclose(x, 0)’
     is computed as ‘abs(x) <= rel_tol * abs(x)’, which is ‘False’ for
     any ‘x’ and rel_tol less than ‘1.0’.  So add an appropriate
     positive abs_tol argument to the call.

     IEEE 754 特殊値 ‘NaN’、‘inf’、‘-inf’ は IEEE の規則に従って処理され
     ます。 具体的には、‘NaN’ は自身を含めたあらゆる値に近いとは見なされ
     ません。 ‘inf’ と ‘-inf’ は自身とのみ近いと見なされます。

     Added in version 3.5.

     参考
     ....

     PEP 485(1) - 近似的に等しいことを調べる関数

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0485/


File: python.info,  Node: 定数<3>,  Prev: 類別関数,  Up: cmath --- 複素数用の数学関数

5.9.3.6 定数
............

 -- データ: cmath.pi

     定数 'π' (円周率)で、浮動小数点数です。

 -- データ: cmath.e

     定数 'e' (自然対数の底)で、浮動小数点数です。

 -- データ: cmath.tau

     数学定数 'τ' で、浮動小数点数です。

     Added in version 3.6.

 -- データ: cmath.inf

     浮動小数点数の正の無限大です。‘float('inf')’ と等価です。

     Added in version 3.6.

 -- データ: cmath.infj

     実部がゼロ、虚部が正の無限大の複素数です。‘complex(0.0,
     float('inf'))’ と等価です。

     Added in version 3.6.

 -- データ: cmath.nan

     浮動小数点数の非数 "not a number" (NaN) です。‘float('nan')’ と等価
     です。

     Added in version 3.6.

 -- データ: cmath.nanj

     実部がゼロ、虚部が NaN の複素数です。‘complex(0.0, float('nan'))’ と
     等価です。

     Added in version 3.6.

*note math: 81. と同じような関数が選ばれていますが、全く同じではないので
注意してください。機能を二つのモジュールに分けているのは、複素数に興味が
なかったり、もしかすると複素数とは何かすら知らないようなユーザがいるから
です。そういった人たちはむしろ、 ‘math.sqrt(-1)’ が複素数を返すよりも例
外を送出してほしいと考えます。また、 *note cmath: 11. で定義されている関
数は、たとえ結果が実数で表現可能な場合 (虚数部がゼロの複素数) でも、常に
複素数を返すので注意してください。

分枝切断 (branch cut) に関する注釈: 分枝切断を持つ曲線上では、与えられた
関数は連続ではなくなります。これらは多くの複素関数における必然的な特性で
す。複素関数を計算する必要がある場合、これらの分枝に関して理解しているも
のと仮定しています。悟りに至るために何らかの (到底基礎的とはいえない) 複
素数に関する書をひもといてください。数値計算を目的とした分枝切断の正しい
選択方法についての情報としては、以下がよい参考文献となります:

参考
....

Kahan, W: Branch cuts for complex elementary functions; or, Much ado
about nothings's sign bit.  In Iserles, A., and Powell, M. (eds.), The
state of the art in numerical analysis.  Clarendon Press (1987)
pp165-211.


File: python.info,  Node: decimal --- 10進固定小数点と浮動小数点の演算,  Next: fractions --- 有理数,  Prev: cmath --- 複素数用の数学関数,  Up: 数値と数学モジュール

5.9.4 ‘decimal’ -- 10進固定小数点と浮動小数点の演算
---------------------------------------------------

'ソースコード:' Lib/decimal.py(1)

__________________________________________________________________

*note decimal: 2e. モジュールは、高速で正確に丸められた10進浮動小数点演
算のサポートを提供します。これには、 *note float: 2ce. データ型よりも優
れたいくつかの利点があります。

   * 「(Decimal は) 人々を念頭にデザインされた浮動小数点モデルを元にして
     おり、必然的に最も重要な指針があります - コンピュータは人々が学校で
     習った算術と同じように動作する算術を提供しなければならない」 - 十進
     数演算仕様より。

   * 十進数を正確に表現できます。 ‘1.1’ や ‘2.2’ のような数は、二進数の
     浮動小数点型では正しく表現できません。エンドユーザは普通、 二進数に
     おける ‘1.1 + 2.2’ の近似値が ‘3.3000000000000003’ だからといって、
     そのように表示してほしいとは考えないものです。

   * 値の正確さは算術にも及びます。十進の浮動小数点による計算では、 ‘0.1
     + 0.1 + 0.1 - 0.3’ は厳密にゼロに等しくなります。 二進浮動小数点で
     は ‘5.5511151231257827e-017’ になってしまいます。ゼロに近い値とはい
     え、この誤差は数値間の等価性テストの信頼性を阻害します。また、誤差
     が蓄積されることもあります。こうした理由から、数値間の等価性を厳し
     く保たなければならないようなアプリケーションを考えるなら、十進数に
     よる数値表現が望ましいということになります。

   * *note decimal: 2e. モジュールでは、有効桁数の表記が取り入れられてお
     り、例えば ‘1.30 + 1.20’ は ‘2.50’ になります。すなわち、末尾のゼロ
     は有効数字を示すために残されます。こうした仕様は通貨計算を行うアプ
     リケーションでは慣例です。乗算の場合、「教科書的な」アプローチでは
     、乗算の被演算子すべての桁数を使います。例えば、 ‘1.3 * 1.2’ は
     ‘1.56’ になり、 ‘1.30 * 1.20’ は ‘1.5600’ になります。

   * ハードウェアによる 2 進浮動小数点表現と違い、*note decimal: 2e. モ
     ジュールでは計算精度をユーザが変更できます(デフォルトでは 28 桁です
     )。この桁数はほとんどの問題解決に十分な大きさです:

          >>> from decimal import *
          >>> getcontext().prec = 6
          >>> Decimal(1) / Decimal(7)
          Decimal('0.142857')
          >>> getcontext().prec = 28
          >>> Decimal(1) / Decimal(7)
          Decimal('0.1428571428571428571428571429')

   * 二進と十進の浮動小数点は、いずれも広く公開されている標準仕様のもと
     に実装されています。組み込みの浮動小数点型では、標準仕様で提唱され
     ている機能のほんのささやかな部分を利用できるにすぎませんが、*note
     decimal: 2e. では標準仕様が要求している全ての機能を利用できます。必
     要に応じて、プログラマは値の丸めやシグナル処理を完全に制御できます
     。この中には全ての不正確な操作を例外でブロックして正確な算術を遵守
     させるオプションもあります。

   * decimal モジュールは「偏見なく、正確な丸めなしの十進算術(固定小数点
     算術と呼ばれることもある)と丸めありの浮動小数点数算術」(十進数演算
     仕様より引用)をサポートするようにデザインされました。

このモジュールは、十進数型、算術コンテキスト (context for arithmetic)、
そしてシグナル (signal) という三つの概念を中心に設計されています。

十進数型は変更不能です。これは符号、係数部、そして指数を持ちます。有効桁
数を残すために、仮数部の末尾にあるゼロは切り詰められません。 *note
decimal: 2e. では、 ‘Infinity’, ‘-Infinity’, および ‘NaN’ といった特殊な
値も定義されています。標準仕様では ‘-0’ と ‘+0’ も区別します。

算術コンテキストとは、精度や値丸めの規則、指数部の制限を決めている環境で
す。この環境では、演算結果を表すためのフラグや、演算上発生した特定のシグ
ナルを例外として扱うかどうかを決めるトラップイネーブラも定義しています。
丸め規則には *note ROUND_CEILING: 258d, *note ROUND_DOWN: 258e, *note
ROUND_FLOOR: 258f, *note ROUND_HALF_DOWN: 2590, *note ROUND_HALF_EVEN:
2591, *note ROUND_HALF_UP: 2592, *note ROUND_UP: 2593, および *note
ROUND_05UP: 2594. があります。

シグナルとは、演算の過程で生じる例外的条件です。個々のシグナルは、アプリ
ケーションそれぞれの要求に従って、無視されたり、単なる情報とみなされたり
、例外として扱われたりします。 *note decimal: 2e. モジュールには、 *note
Clamped: 2595, *note InvalidOperation: 107a, *note DivisionByZero: 2596,
*note Inexact: 2597, *note Rounded: 2598, *note Subnormal: 2599, *note
Overflow: 259a, *note Underflow: 259b, および *note FloatOperation:
1072. といったシグナルがあります。

各シグナルには、フラグとトラップイネーブラがあります。演算上何らかのシグ
ナルに遭遇すると、フラグは 1 にセットされます。このとき、もしトラップイ
ネーブラが 1 にセットされていれば、例外を送出します。フラグの値は膠着型
(sticky) なので、演算によるフラグの変化をモニタしたければ、予めフラグを
リセットしておかなければなりません。

参考
....

   * IBM による汎用十進演算仕様、The General Decimal Arithmetic
     Specification(2)。

* Menu:

* クイックスタートチュートリアル::
* Decimal オブジェクト::
* Context オブジェクト::
* 定数: 定数<4>.
* 丸めモード::
* シグナル::
* Floating-Point Notes::
* スレッドを使った処理::
* レシピ::
* Decimal FAQ::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/decimal.py

   (2) https://speleotrove.com/decimal/decarith.html


File: python.info,  Node: クイックスタートチュートリアル,  Next: Decimal オブジェクト,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.1 クイックスタートチュートリアル
......................................

普通、 *note decimal: 2e. を使うときには、モジュールをインポートし、現在
の演算コンテキストを *note getcontext(): 1537. で調べ、必要なら、精度、
丸め、有効なトラップを設定します:

     >>> from decimal import *
     >>> getcontext()
     Context(prec=28, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
             capitals=1, clamp=0, flags=[], traps=[Overflow, DivisionByZero,
             InvalidOperation])

     >>> getcontext().prec = 7       # Set a new precision

*note Decimal: 27d. インスタンスは、整数、文字列、浮動小数点数、またはタ
プルから構成できます。整数や浮動小数点数からの構成は、整数や浮動小数点数
の値を正確に変換します。 *note Decimal: 27d. は "非数 (Not a Number)" を
表す ‘NaN’ や正負の ‘Infinity’ (無限大)、 ‘-0’ といった特殊な値も表現で
きます:

     >>> getcontext().prec = 28
     >>> Decimal(10)
     Decimal('10')
     >>> Decimal('3.14')
     Decimal('3.14')
     >>> Decimal(3.14)
     Decimal('3.140000000000000124344978758017532527446746826171875')
     >>> Decimal((0, (3, 1, 4), -2))
     Decimal('3.14')
     >>> Decimal(str(2.0 ** 0.5))
     Decimal('1.4142135623730951')
     >>> Decimal(2) ** Decimal('0.5')
     Decimal('1.414213562373095048801688724')
     >>> Decimal('NaN')
     Decimal('NaN')
     >>> Decimal('-Infinity')
     Decimal('-Infinity')

*note FloatOperation: 1072. シグナルがトラップされる場合、コンストラクタ
や順序比較において誤って decimal と float が混ざると、例外が送出されます
:

     >>> c = getcontext()
     >>> c.traps[FloatOperation] = True
     >>> Decimal(3.14)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     decimal.FloatOperation: [<class 'decimal.FloatOperation'>]
     >>> Decimal('3.5') < 3.7
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     decimal.FloatOperation: [<class 'decimal.FloatOperation'>]
     >>> Decimal('3.5') == 3.5
     True

Added in version 3.3.

新たな *note Decimal: 27d. の有効桁数は入力の桁数だけで決まります。演算
コンテキストにおける精度や値丸めの設定が影響するのは算術演算の間だけです
。

     >>> getcontext().prec = 6
     >>> Decimal('3.0')
     Decimal('3.0')
     >>> Decimal('3.1415926535')
     Decimal('3.1415926535')
     >>> Decimal('3.1415926535') + Decimal('2.7182818285')
     Decimal('5.85987')
     >>> getcontext().rounding = ROUND_UP
     >>> Decimal('3.1415926535') + Decimal('2.7182818285')
     Decimal('5.85988')

C バージョンの内部制限を超えた場合、decimal の構成は *note
InvalidOperation: 107a. を送出します:

     >>> Decimal("1e9999999999999999999")
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     decimal.InvalidOperation: [<class 'decimal.InvalidOperation'>]

バージョン 3.3 で変更.

Decimals interact well with much of the rest of Python.  Here is a small
decimal floating-point flying circus:

     >>> data = list(map(Decimal, '1.34 1.87 3.45 2.35 1.00 0.03 9.25'.split()))
     >>> max(data)
     Decimal('9.25')
     >>> min(data)
     Decimal('0.03')
     >>> sorted(data)
     [Decimal('0.03'), Decimal('1.00'), Decimal('1.34'), Decimal('1.87'),
      Decimal('2.35'), Decimal('3.45'), Decimal('9.25')]
     >>> sum(data)
     Decimal('19.29')
     >>> a,b,c = data[:3]
     >>> str(a)
     '1.34'
     >>> float(a)
     1.34
     >>> round(a, 1)
     Decimal('1.3')
     >>> int(a)
     1
     >>> a * 5
     Decimal('6.70')
     >>> a * b
     Decimal('2.5058')
     >>> c % a
     Decimal('0.77')

いくつかの数学的関数も Decimal には用意されています:

     >>> getcontext().prec = 28
     >>> Decimal(2).sqrt()
     Decimal('1.414213562373095048801688724')
     >>> Decimal(1).exp()
     Decimal('2.718281828459045235360287471')
     >>> Decimal('10').ln()
     Decimal('2.302585092994045684017991455')
     >>> Decimal('10').log10()
     Decimal('1')

*note quantize(): 1080. メソッドは位を固定して数値を丸めます。このメソッ
ドは、結果を固定の桁数で丸めることがよくある、金融アプリケーションで便利
です:

     >>> Decimal('7.325').quantize(Decimal('.01'), rounding=ROUND_DOWN)
     Decimal('7.32')
     >>> Decimal('7.325').quantize(Decimal('1.'), rounding=ROUND_UP)
     Decimal('8')

前述のように、 *note getcontext(): 1537. 関数を使うと現在の演算コンテキ
ストにアクセスでき、設定を変更できます。ほとんどのアプリケーションはこの
アプローチで十分です。

より高度な作業を行う場合、 *note Context(): 107f. コンストラクタを使って
別の演算コンテキストを作っておくと便利なことがあります。別の演算コンテキ
ストをアクティブにしたければ、 *note setcontext(): 259d. を使います。

*note decimal: 2e. モジュールでは、標準仕様に従って、すぐ利用できる二つ
の標準コンテキスト、 *note BasicContext: 1078. および *note
ExtendedContext: 1079. を提供しています。前者はほとんどのトラップが有効
になっており、とりわけデバッグの際に便利です:

     >>> myothercontext = Context(prec=60, rounding=ROUND_HALF_DOWN)
     >>> setcontext(myothercontext)
     >>> Decimal(1) / Decimal(7)
     Decimal('0.142857142857142857142857142857142857142857142857142857142857')

     >>> ExtendedContext
     Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
             capitals=1, clamp=0, flags=[], traps=[])
     >>> setcontext(ExtendedContext)
     >>> Decimal(1) / Decimal(7)
     Decimal('0.142857143')
     >>> Decimal(42) / Decimal(0)
     Decimal('Infinity')

     >>> setcontext(BasicContext)
     >>> Decimal(42) / Decimal(0)
     Traceback (most recent call last):
       File "<pyshell#143>", line 1, in -toplevel-
         Decimal(42) / Decimal(0)
     DivisionByZero: x / 0

演算コンテキストには、演算中に遭遇した例外的状況をモニタするためのシグナ
ルフラグがあります。フラグが一度セットされると、明示的にクリアするまで残
り続けます。そのため、フラグのモニタを行いたいような演算の前には *note
clear_flags(): 259e. メソッドでフラグをクリアしておくのがベストです。

     >>> setcontext(ExtendedContext)
     >>> getcontext().clear_flags()
     >>> Decimal(355) / Decimal(113)
     Decimal('3.14159292')
     >>> getcontext()
     Context(prec=9, rounding=ROUND_HALF_EVEN, Emin=-999999, Emax=999999,
             capitals=1, clamp=0, flags=[Inexact, Rounded], traps=[])

'flags' エントリから、pi の有理数による近似値が丸められた (コンテキスト
内で決められた精度を超えた桁数が捨てられた) ことと、計算結果が厳密でない
(無視された桁の値に非ゼロのものがあった) ことがわかります。

コンテキストの ‘traps’ 属性に入っている辞書を使うと、個々のトラップをセ
ットできます:

     >>> setcontext(ExtendedContext)
     >>> Decimal(1) / Decimal(0)
     Decimal('Infinity')
     >>> getcontext().traps[DivisionByZero] = 1
     >>> Decimal(1) / Decimal(0)
     Traceback (most recent call last):
       File "<pyshell#112>", line 1, in -toplevel-
         Decimal(1) / Decimal(0)
     DivisionByZero: x / 0

ほとんどのプログラムでは、開始時に一度だけ現在の演算コンテキストを修正し
ます。また、多くのアプリケーションでは、データから *note Decimal: 27d. へ
の変換はループ内で一度だけキャストして行います。コンテキストを設定し、
*note Decimal: 27d. オブジェクトを生成できたら、ほとんどのプログラムは他
の Python 数値型と全く変わらないかのように *note Decimal: 27d. を操作で
きます。


File: python.info,  Node: Decimal オブジェクト,  Next: Context オブジェクト,  Prev: クイックスタートチュートリアル,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.2 Decimal オブジェクト
............................

 -- クラス: decimal.Decimal (value='0', context=None)

     'value' に基づいて新たな *note Decimal: 27d. オブジェクトを構築しま
     す。

     'value' は整数、文字列、タプル、 *note float: 2ce. および他の *note
     Decimal: 27d. オブジェクトにできます。 'value' を指定しない場合、
     ‘Decimal('0')’ を返します。 'value' が文字列の場合、先頭と末尾の空
     白および全てのアンダースコアを取り除いた後には以下の 10進数文字列の
     文法に従わなければなりません:

          sign           ::=  '+' | '-'
          digit          ::=  '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
          indicator      ::=  'e' | 'E'
          digits         ::=  digit [digit]...
          decimal-part   ::=  digits '.' [digits] | ['.'] digits
          exponent-part  ::=  indicator [sign] digits
          infinity       ::=  'Infinity' | 'Inf'
          nan            ::=  'NaN' [digits] | 'sNaN' [digits]
          numeric-value  ::=  decimal-part [exponent-part] | infinity
          numeric-string ::=  [sign] numeric-value | [sign] nan

     他の Unicode 数字も上の ‘digit’ の場所に使うことができます。つまり
     各書記体系における(アラビア-インド系やデーヴァナーガリーなど)の数字
     や、全角数字０(‘'\uff10'’)から９(‘'\uff19'’)までなどです。

     'value' を *note tuple: 349. にする場合、タプルは三つの要素を持ち、
     それぞれ符号 (正なら ‘0’ 、負なら ‘1’)、仮数部を表す数字の *note
     tuple: 349. 、そして指数を表す整数でなければなりません。例えば、
     ‘Decimal((0, (1, 4, 1, 4), -3))’ は ‘Decimal('1.414')’ を返します。

     If 'value' is a *note float: 2ce, the binary floating-point value
     is losslessly converted to its exact decimal equivalent.  This
     conversion can often require 53 or more digits of precision.  For
     example, ‘Decimal(float('1.1'))’ converts to
     ‘Decimal('1.100000000000000088817841970012523233890533447265625')’.

     'context' の精度 (precision) は、記憶される桁数には影響しません。桁
     数は 'value' に指定した桁数だけから決定されます。例えば、演算コンテ
     キストに指定された精度が 3 桁しかなくても、‘Decimal('3.00000')’ は
     5 つのゼロを全て記憶します。

     'context' 引数の目的は、 'value' が正しくない形式の文字列であった場
     合に行う処理を決めることにあります; 演算コンテキストが *note
     InvalidOperation: 107a. をトラップするようになっていれば、例外を送
     出します。それ以外の場合には、コンストラクタは値が ‘NaN’ の *note
     Decimal: 27d. を返します。

     一度生成すると、 *note Decimal: 27d. オブジェクトは変更不能
     (immutable) になります。

     バージョン 3.2 で変更: コンストラクタに対する引数に *note float:
     2ce. インスタンスも許されるようになりました。

     バージョン 3.3 で変更: *note FloatOperation: 1072. トラップがセット
     されていた場合 *note float: 2ce. 引数は例外を送出します。デフォルト
     でトラップはオフです。

     バージョン 3.6 で変更: コード中の整数リテラルや浮動小数点リテラルと
     同様に、アンダースコアを用いて桁をグルーピングできます。

     Decimal floating-point objects share many properties with the other
     built-in numeric types such as *note float: 2ce. and *note int:
     238.  All of the usual math operations and special methods apply.
     Likewise, decimal objects can be copied, pickled, printed, used as
     dictionary keys, used as set elements, compared, sorted, and
     coerced to another type (such as *note float: 2ce. or *note int:
     238.).

     十進オブジェクトの算術演算と整数や浮動小数点数の算術演算には少々違
     いがあります。十進オブジェクトに対して剰余演算を適用すると、計算結
     果の符号は除数の符号ではなく '被除数' の符号と一致します:

          >>> (-7) % 4
          1
          >>> Decimal(-7) % Decimal(4)
          Decimal('-3')

     整数除算演算子 ‘//’ も同様に、実際の商の切り捨てではなく (0に近付く
     ように丸めた) 整数部分を返します。そのため通常の恒等式 ‘x == (x //
     y) * y + x % y’ が維持されます:

          >>> -7 // 4
          -2
          >>> Decimal(-7) // Decimal(4)
          Decimal('-1')

     演算子 ‘%’ と演算子 ‘//’ は (それぞれ) 仕様にあるような ‘剰余’ 操作
     と ‘整数除算’ 操作を実装しています。

     Decimal オブジェクトは一般に、算術演算で浮動小数点数や *note
     fractions.Fraction: 1c8. オブジェクトと組み合わせることができません
     。例えば、 *note Decimal: 27d. に *note float: 2ce. を足そうとする
     と、 *note TypeError: 502. が送出されます。ただし、Python の比較演
     算子を使って *note Decimal: 27d. インスタンス ‘x’ と別の数 ‘y’ を比
     較することができます。これにより、異なる型の数間の等価比較の際に、
     紛らわしい結果を避けます。

     バージョン 3.2 で変更: *note Decimal: 27d. インスタンスと他の数値型
     が混在する比較が完全にサポートされるようになりました。

     In addition to the standard numeric properties, decimal
     floating-point objects also have a number of specialized methods:

      -- メソッド: adjusted ()

          仮数の先頭の一桁だけが残るように右側の数字を追い出す桁シフトを
          行い、その結果の指数部を返します:
          ‘Decimal('321e+5').adjusted()’ は 7 を返します。最上桁の小数点
          からの相対位置を調べる際に使います。

      -- メソッド: as_integer_ratio ()

          与えられた *note Decimal: 27d. インスタンスを、既約分数で分母
          が正数の分数として表現した整数のペア ‘(n, d)’ を返します。

               >>> Decimal('-3.14').as_integer_ratio()
               (-157, 50)

          変換は正確に行われます。無限大に対してはOverflowErrorを、NaNに
          対してはValueError を送出します。

     Added in version 3.6.

      -- メソッド: as_tuple ()

          数値を表現するための *note 名前付きタプル: 61a.:
          ‘DecimalTuple(sign, digittuple, exponent)’ を返します。

      -- メソッド: canonical ()

          引数の標準的(canonical)エンコーディングを返します。現在のとこ
          ろ、 *note Decimal: 27d. インスタンスのエンコーディングは常に
          標準的なので、この操作は引数に手を加えずに返します。

      -- メソッド: compare (other, context=None)

          二つの Decimal インスタンスの値を比較します。 *note compare():
          25a4. は Decimal インスタンスを返し、被演算子のどちらかが NaN
          ならば結果は NaN です:

               a or b is a NaN  ==> Decimal('NaN')
               a < b            ==> Decimal('-1')
               a == b           ==> Decimal('0')
               a > b            ==> Decimal('1')

      -- メソッド: compare_signal (other, context=None)

          この演算は *note compare(): 25a4. とほとんど同じですが、全ての
          NaN がシグナルを送るところが異なります。すなわち、どちらの比較
          対象も発信 (signaling) NaN でないならば無言 (quiet) NaN である
          比較対象があたかも発信 NaN であるかのように扱われます。

      -- メソッド: compare_total (other, context=None)

          二つの対象を数値によらず抽象表現によって比較します。 *note
          compare(): 25a4. に似ていますが、結果は *note Decimal: 27d. に
          全順序を与えます。この順序づけによると、数値的に等しくても異な
          った表現を持つ二つの *note Decimal: 27d. インスタンスの比較は
          等しくなりません:

               >>> Decimal('12.0').compare_total(Decimal('12'))
               Decimal('-1')

          無言 NaN と発信 NaN もこの全順序に位置付けられます。この関数の
          結果は、もし比較対象が同じ表現を持つならば ‘Decimal('0')’ であ
          り、一つめの比較対象が二つめより下位にあれば ‘Decimal('-1')’、
          上位にあれば ‘Decimal('1')’ です。全順序の詳細については仕様を
          参照してください。

          この演算はコンテキストに影響されず、静かです。すなわち、フラグ
          は変更されず、丸めは行われません。例外として、2番目の比較対象
          の厳密な変換ができない場合、C バージョンのライブラリでは
          InvalidOperation 例外を送出するかもしれません。

      -- メソッド: compare_total_mag (other, context=None)

          二つの対象を *note compare_total(): 25a6. のように数値によらず
          抽象表現によって比較しますが、両者の符号を無視します。
          ‘x.compare_total_mag(y)’ は
          ‘x.copy_abs().compare_total(y.copy_abs())’ と等価です。

          この演算はコンテキストに影響されず、静かです。すなわち、フラグ
          は変更されず、丸めは行われません。例外として、2番目の比較対象
          の厳密な変換ができない場合、C バージョンのライブラリでは
          InvalidOperation 例外を送出するかもしれません。

      -- メソッド: conjugate ()

          self を返すだけです。このメソッドは十進演算仕様に適合するため
          だけのものです。

      -- メソッド: copy_abs ()

          引数の絶対値を返します。この演算はコンテキストに影響されず、静
          かです。すなわち、フラグは変更されず、丸めは行われません。

      -- メソッド: copy_negate ()

          引数の符号を変えて返します。この演算はコンテキストに影響されず
          、静かです。すなわち、フラグは変更されず、丸めは行われません。

      -- メソッド: copy_sign (other, context=None)

          最初の演算対象のコピーに二つめと同じ符号を付けて返します。たと
          えば:

               >>> Decimal('2.3').copy_sign(Decimal('-1.5'))
               Decimal('-2.3')

          この演算はコンテキストに影響されず、静かです。すなわち、フラグ
          は変更されず、丸めは行われません。例外として、2番目の比較対象
          の厳密な変換ができない場合、C バージョンのライブラリでは
          InvalidOperation 例外を送出するかもしれません。

      -- メソッド: exp (context=None)

          与えられた数での(自然)指数関数 ‘e**x’ の値を返します。結果は
          *note ROUND_HALF_EVEN: 2591. 丸めモードで正しく丸められます。

               >>> Decimal(1).exp()
               Decimal('2.718281828459045235360287471')
               >>> Decimal(321).exp()
               Decimal('2.561702493119680037517373933E+139')

      -- メソッド: classmethod from_float (f)

          Alternative constructor that only accepts instances of *note
          float: 2ce. or *note int: 238.

          なお、‘Decimal.from_float(0.1)’ は ‘Decimal('0.1')’ と同じでは
          ありません。0.1 は二進浮動小数点数で正確に表せないので、その値
          は表現できる最も近い値、‘0x1.999999999999ap-4’ として記憶され
          ます。浮動小数点数での等価な値は
          ‘0.1000000000000000055511151231257827021181583404541015625’ で
          す。

               注釈: Python 3.2 以降では、 *note Decimal: 27d. インスタ
               ンスは *note float: 2ce. から直接構成できるようになりまし
               た。

               >>> Decimal.from_float(0.1)
               Decimal('0.1000000000000000055511151231257827021181583404541015625')
               >>> Decimal.from_float(float('nan'))
               Decimal('NaN')
               >>> Decimal.from_float(float('inf'))
               Decimal('Infinity')
               >>> Decimal.from_float(float('-inf'))
               Decimal('-Infinity')

          Added in version 3.1.

      -- メソッド: fma (other, third, context=None)

          融合積和(fused multiply-add)です。self*other+third を途中結果
          の積 self*other で丸めを行わずに計算して返します。

               >>> Decimal(2).fma(3, 5)
               Decimal('11')

      -- メソッド: is_canonical ()

          引数が標準的(canonical)ならば *note True: bdb. を返し、そうで
          なければ *note False: b05. を返します。現在のところ、 *note
          Decimal: 27d. のインスタンスは常に標準的なのでこのメソッドの結
          果はいつでも *note True: bdb. です。

      -- メソッド: is_finite ()

          引数が有限の数値ならば *note True: bdb. を、無限大か NaN なら
          ば *note False: b05. を返します。

      -- メソッド: is_infinite ()

          引数が正または負の無限大ならば *note True: bdb. を、そうでなけ
          れば *note False: b05. を返します。

      -- メソッド: is_nan ()

          引数が (無言か発信かは問わず) NaN であれば *note True: bdb. を
          、そうでなければ *note False: b05. を返します。

      -- メソッド: is_normal (context=None)

          引数が '正規(normal)' の有限数値ならば *note True: bdb. を返し
          ます。引数がゼロ、非正規(subnormal)、無限大または NaN であれば
          *note False: b05. を返します。

      -- メソッド: is_qnan ()

          引数が無言 NaN であれば *note True: bdb. を、そうでなければ
          *note False: b05. を返します。

      -- メソッド: is_signed ()

          引数に負の符号がついていれば *note True: bdb. を、そうでなけれ
          ば *note False: b05. を返します。注意すべきはゼロや NaN なども
          符号を持ち得ることです。

      -- メソッド: is_snan ()

          引数が発信 NaN であれば *note True: bdb. を、そうでなければ
          *note False: b05. を返します。

      -- メソッド: is_subnormal (context=None)

          引数が非正規数(subnormal)であれば *note True: bdb. を、そうで
          なければ *note False: b05. を返します。

      -- メソッド: is_zero ()

          引数が(正または負の)ゼロであれば *note True: bdb. を、そうでな
          ければ *note False: b05. を返します。

      -- メソッド: ln (context=None)

          演算対象の自然対数(底 e の対数)を返します。結果は *note
          ROUND_HALF_EVEN: 2591. 丸めモードで正しく丸められます。

      -- メソッド: log10 (context=None)

          演算対象の底 10 の対数を返します。結果は *note
          ROUND_HALF_EVEN: 2591. 丸めモードで正しく丸められます。

      -- メソッド: logb (context=None)

          非零の数値については、 *note Decimal: 27d. インスタンスとして
          調整された指数を返します。演算対象がゼロだった場合、
          ‘Decimal('-Infinity')’ が返され *note DivisionByZero: 2596. フ
          ラグが送出されます。演算対象が無限大だった場合、
          ‘Decimal('Infinity')’ が返されます。

      -- メソッド: logical_and (other, context=None)

          *note logical_and(): 25b9. は二つの '論理引数' (*note
          論理引数: 25ba. 参照)を取る論理演算です。結果は二つの引数の数
          字ごとの ‘and’ です。

      -- メソッド: logical_invert (context=None)

          *note logical_invert(): 25bb. は論理演算です。結果は引数の数字
          ごとの反転です。

      -- メソッド: logical_or (other, context=None)

          *note logical_or(): 25bc. は二つの '論理引数' (*note 論理引数:
          25ba. 参照)を取る論理演算です。結果は二つの引数の数字ごとの
          ‘or’ です。

      -- メソッド: logical_xor (other, context=None)

          *note logical_xor(): 25bd. は二つの '論理引数' (*note
          論理引数: 25ba. 参照)を取る論理演算です。結果は二つの引数の数
          字ごとの排他的論理和です。

      -- メソッド: max (other, context=None)

          ‘max(self, other)’ と同じですが、値を返す前に現在のコンテキス
          トに即した丸め規則を適用します。また、 ‘NaN’ に対して、(コンテ
          キストの設定と、発信か無言どちらのタイプであるかに応じて) シグ
          ナルを発行するか無視します。

      -- メソッド: max_mag (other, context=None)

          *note max(): 25be. メソッドに似ていますが、比較は絶対値で行わ
          れます。

      -- メソッド: min (other, context=None)

          ‘min(self, other)’ と同じですが、値を返す前に現在のコンテキス
          トに即した丸め規則を適用します。また、 ‘NaN’ に対して、(コンテ
          キストの設定と、発信か無言どちらのタイプであるかに応じて) シグ
          ナルを発行するか無視します。

      -- メソッド: min_mag (other, context=None)

          *note min(): 25c0. メソッドに似ていますが、比較は絶対値で行わ
          れます。

      -- メソッド: next_minus (context=None)

          与えられたコンテキスト(またはコンテキストが渡されなければ現ス
          レッドのコンテキスト)において表現可能な、操作対象より小さい最
          大の数を返します。

      -- メソッド: next_plus (context=None)

          与えられたコンテキスト(またはコンテキストが渡されなければ現ス
          レッドのコンテキスト)において表現可能な、操作対象より大きい最
          小の数を返します。

      -- メソッド: next_toward (other, context=None)

          二つの比較対象が等しくなければ、一つめの対象に最も近く二つめの
          対象へ近付く方向の数を返します。もし両者が数値的に等しければ、
          二つめの対象の符号を採った一つめの対象のコピーを返します。

      -- メソッド: normalize (context=None)

          Used for producing canonical values of an equivalence class
          within either the current context or the specified context.

          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 zeros removed and its sign
          preserved.  That is, while the coefficient is non-zero and a
          multiple of ten the coefficient is divided by ten and the
          exponent is incremented by 1.  Otherwise (the coefficient is
          zero) the exponent is set to 0.  In all cases the sign is
          unchanged.

          For example, ‘Decimal('32.100')’ and ‘Decimal('0.321000e+2')’
          both normalize to the equivalent value ‘Decimal('32.1')’.

          Note that rounding is applied 'before' reducing to simplest
          form.

          In the latest versions of the specification, this operation is
          also known as ‘reduce’.

      -- メソッド: number_class (context=None)

          操作対象の 'クラス' を表す文字列を返します。返されるのは以下の
          10種類のいずれかです。

             * ‘"-Infinity"’, 負の無限大であることを示します。

             * ‘"-Normal"’, 負の通常数であることを示します。

             * ‘"-Subnormal"’, 負の非正規数であることを示します。

             * ‘"-Zero"’, 負のゼロであることを示します。

             * ‘"+Zero"’, 正のゼロであることを示します。

             * ‘"+Subnormal"’, 正の非正規数であることを示します。

             * ‘"+Normal"’, 正の通常数であることを示します。

             * ‘"+Infinity"’, 正の無限大であることを示します。

             * ‘"NaN"’, 無言 (quiet) NaN (Not a Number) であることを示し
               ます。

             * ‘"sNaN"’, 発信(signaling) NaN であることを示します。

      -- メソッド: quantize (exp, rounding=None, context=None)

          二つ目の操作対象と同じ指数を持つように丸めを行った、一つめの操
          作対象と等しい値を返します。

               >>> Decimal('1.41421356').quantize(Decimal('1.000'))
               Decimal('1.414')

          他の操作と違い、打ち切り(quantize)操作後の係数の長さが精度を越
          えた場合には、 *note InvalidOperation: 107a. がシグナルされま
          す。これによりエラー条件がない限り打ち切られた指数が常に右側の
          引数と同じになることが保証されます。

          同様に、他の操作と違い、quantize は Underflow を、たとえ結果が
          非正規になったり不正確になったとしても、シグナルしません。

          二つ目の演算対象の指数が一つ目のそれよりも大きければ丸めが必要
          かもしれません。この場合、丸めモードは以下のように決められます
          。‘rounding’ 引数が与えられていればそれが使われます。そうでな
          ければ ‘context’ 引数で決まります。どちらの引数も渡されなけれ
          ば現在のスレッドのコンテキストの丸めモードが使われます。

          処理結果の指数が ‘Emax’ よりも大きい場合や *note Etiny():
          25c7. よりも小さい場合にエラーが返されます。

      -- メソッド: radix ()

          ‘Decimal(10)’ つまり *note Decimal: 27d. クラスがその全ての算
          術を実行する基数を返します。仕様との互換性のために取り入れられ
          ています。

      -- メソッド: remainder_near (other, context=None)

          'self' を 'other' で割った剰余を返します。これは ‘self %
          other’ とは違って、剰余の絶対値を小さくするように符号が選ばれ
          ます。より詳しく言うと、‘n’ を ‘self / other’ の正確な値に最も
          近い整数としたときの ‘self - n * other’ が返り値になります。最
          も近い整数が2つある場合には偶数のものが選ばれます。

          結果が0になる場合の符号は 'self' の符号と同じになります。

               >>> Decimal(18).remainder_near(Decimal(10))
               Decimal('-2')
               >>> Decimal(25).remainder_near(Decimal(10))
               Decimal('5')
               >>> Decimal(35).remainder_near(Decimal(10))
               Decimal('-5')

      -- メソッド: rotate (other, context=None)

          一つ目の演算対象の数字を二つ目で指定された量だけ巡回(rotate)し
          た結果を返します。二つめの演算対象は -precision から precision
          までの範囲の整数でなければなりません。この二つ目の演算対象の絶
          対値を何桁ずらすかを決めます。そしてもし正の数ならば巡回の方向
          は左に、そうでなければ右になります。一つ目の演算対象の仮数部は
          必要ならば精度いっぱいまでゼロで埋められます。符号と指数は変え
          られません。

      -- メソッド: same_quantum (other, context=None)

          'self' と 'other' が同じ指数を持っているか、あるいは双方とも
          ‘NaN’ である場合に真を返します。

          この演算はコンテキストに影響されず、静かです。すなわち、フラグ
          は変更されず、丸めは行われません。例外として、2番目の比較対象
          の厳密な変換ができない場合、C バージョンのライブラリでは
          InvalidOperation 例外を送出するかもしれません。

      -- メソッド: scaleb (other, context=None)

          二つ目の演算対象で調整された指数の一つ目の演算対象を返します。
          同じことですが、一つめの演算対象を ‘10**other’ 倍したものを返
          します。二つ目の演算対象は整数でなければなりません。

      -- メソッド: shift (other, context=None)

          一つ目の演算対象の数字を二つ目で指定された量だけシフトした結果
          を返します。二つ目の演算対象は -precision から precision まで
          の範囲の整数でなければなりません。この二つ目の演算対象の絶対値
          が何桁ずらすかを決めます。そしてもし正の数ならばシフトの方向は
          左に、そうでなければ右になります。一つ目の演算対象の係数は必要
          ならば精度いっぱいまでゼロで埋められます。符号と指数は変えられ
          ません。

      -- メソッド: sqrt (context=None)

          引数の平方根を最大精度で求めます。

      -- メソッド: to_eng_string (context=None)

          文字列に変換します。指数が必要なら工学表記が使われます。

          工学表記法では指数は 3 の倍数になります。これにより、基数の小
          数部には最大で 3 桁までの数字が残されるとともに、末尾に 1 つま
          たは 2 つの 0 の付加が必要とされるかもしれません。

          たとえば、‘Decimal('123E+1')’ は ‘Decimal('1.23E+3')’ に変換さ
          れます。

      -- メソッド: to_integral (rounding=None, context=None)

          *note to_integral_value(): 25d1. メソッドと同じです。
          ‘to_integral’ の名前は古いバージョンとの互換性のために残されて
          います。

      -- メソッド: to_integral_exact (rounding=None, context=None)

          最近傍の整数に値を丸め、丸めが起こった場合には *note Inexact:
          2597. または *note Rounded: 2598. のシグナルを適切に出します。
          丸めモードは以下のように決められます。 ‘rounding’ 引数が与えら
          れていればそれが使われます。そうでなければ ‘context’ 引数で決
          まります。どちらの引数も渡されなければ現在のスレッドのコンテキ
          ストの丸めモードが使われます。

      -- メソッド: to_integral_value (rounding=None, context=None)

          *note Inexact: 2597. や *note Rounded: 2598. といったシグナル
          を出さずに最近傍の整数に値を丸めます。 'rounding' が指定されて
          いれば適用されます; それ以外の場合、値丸めの方法は 'context' の
          設定か現在のコンテキストの設定になります。

     Decimal numbers can be rounded using the *note round(): 12a8.
     function:

      -- Describe: round(number)

      -- Describe: round(number, ndigits)

          If 'ndigits' is not given or ‘None’, returns the nearest *note
          int: 238. to 'number', rounding ties to even, and ignoring the
          rounding mode of the *note Decimal: 27d. context.  Raises
          *note OverflowError: 84e. if 'number' is an infinity or *note
          ValueError: 1e3. if it is a (quiet or signaling) NaN.

          If 'ndigits' is an *note int: 238, the context's rounding mode
          is respected and a *note Decimal: 27d. representing 'number'
          rounded to the nearest multiple of ‘Decimal('1E-ndigits')’ is
          returned; in this case, ‘round(number, ndigits)’ is equivalent
          to ‘self.quantize(Decimal('1E-ndigits'))’.  Returns
          ‘Decimal('NaN')’ if 'number' is a quiet NaN. Raises *note
          InvalidOperation: 107a. if 'number' is an infinity, a
          signaling NaN, or if the length of the coefficient after the
          quantize operation would be greater than the current context's
          precision.  In other words, for the non-corner cases:

             * if 'ndigits' is positive, return 'number' rounded to
               'ndigits' decimal places;

             * if 'ndigits' is zero, return 'number' rounded to the
               nearest integer;

             * if 'ndigits' is negative, return 'number' rounded to the
               nearest multiple of ‘10**abs(ndigits)’.

          例えば:

               >>> from decimal import Decimal, getcontext, ROUND_DOWN
               >>> getcontext().rounding = ROUND_DOWN
               >>> round(Decimal('3.75'))     # context rounding ignored
               4
               >>> round(Decimal('3.5'))      # round-ties-to-even
               4
               >>> round(Decimal('3.75'), 0)  # uses the context rounding
               Decimal('3')
               >>> round(Decimal('3.75'), 1)
               Decimal('3.7')
               >>> round(Decimal('3.75'), -1)
               Decimal('0E+1')

* Menu:

* 論理引数::


File: python.info,  Node: 論理引数,  Up: Decimal オブジェクト

5.9.4.3 論理引数
................

*note logical_and(): 25b9, *note logical_invert(): 25bb, *note
logical_or(): 25bc, および *note logical_xor(): 25bd. メソッドはその引数
が '論理引数' であると想定しています。 '論理引数' とは *note Decimal:
27d. インスタンスで指数と符号は共にゼロであり、各桁の数字が ‘0’ か ‘1’ で
あるものです。


File: python.info,  Node: Context オブジェクト,  Next: 定数<4>,  Prev: Decimal オブジェクト,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.4 Context オブジェクト
............................

コンテキスト (context) とは、算術演算における環境設定です。コンテキスト
は計算精度を決定し、値丸めの方法を設定し、シグナルのどれが例外になるかを
決め、指数の範囲を制限しています。

多重スレッドで処理を行う場合には各スレッドごとに現在のコンテキストがあり
、 *note getcontext(): 1537. や *note setcontext(): 259d. といった関数で
アクセスしたり設定変更できます:

 -- の関数: decimal.getcontext ()

     アクティブなスレッドの現在のコンテキストを返します。

 -- の関数: decimal.setcontext (c)

     アクティブなスレッドのコンテキストを 'c' に設定します。

*note with: 59c. 文と *note localcontext(): 176f. 関数を使って実行するコ
ンテキストを一時的に変更することもできます。

 -- の関数: decimal.localcontext (ctx=None, **kwargs)

     with 文の入口でアクティブなスレッドのコンテキストを 'ctx' のコピー
     に設定し、with 文を抜ける時に元のコンテキストに復旧する、コンテキス
     トマネージャを返します。コンテキストが指定されなければ、現在のコン
     テキストのコピーが使われます。'kwargs' 引数は新しいコンテキストの属
     性を設定するのに使われます。

     たとえば、以下のコードでは精度を42桁に設定し、計算を実行し、そして
     元のコンテキストに復帰します:

          from decimal import localcontext

          with localcontext() as ctx:
              ctx.prec = 42   # Perform a high precision calculation
              s = calculate_something()
          s = +s  # Round the final result back to the default precision

     Using keyword arguments, the code would be the following:

          from decimal import localcontext

          with localcontext(prec=42) as ctx:
              s = calculate_something()
          s = +s

     Raises *note TypeError: 502. if 'kwargs' supplies an attribute that
     *note Context: 107f. doesn't support.  Raises either *note
     TypeError: 502. or *note ValueError: 1e3. if 'kwargs' supplies an
     invalid value for an attribute.

     バージョン 3.11 で変更: *note localcontext(): 176f. now supports
     setting context attributes through the use of keyword arguments.

新たなコンテキストは、以下で説明する *note Context: 107f. コンストラクタ
を使って生成できます。その他にも、 *note decimal: 2e. モジュールでは作成
済みのコンテキストを提供しています:

 -- クラス: decimal.BasicContext

     汎用十進演算仕様で定義されている標準コンテキストの一つです。精度は
     9 桁に設定されています。丸め規則は *note ROUND_HALF_UP: 2592. です
     。すべての演算結果フラグはクリアされています。 *note Inexact: 2597,
     *note Rounded: 2598, *note Subnormal: 2599. を除く全ての演算エラー
     トラップが有効 (例外として扱う) になっています。

     多くのトラップが有効になっているので、デバッグの際に便利なコンテキ
     ストです。

 -- クラス: decimal.ExtendedContext

     汎用十進演算仕様で定義されている標準コンテキストの一つです。精度は
     9 桁に設定されています。丸め規則は *note ROUND_HALF_EVEN: 2591. で
     す。すべての演算結果フラグはクリアされています。トラップは全て無効
     (演算中に一切例外を送出しない) になっています。

     トラップが無効になっているので、エラーの伴う演算結果を ‘NaN’ や
     ‘Infinity’ にし、例外を送出しないようにしたいアプリケーションに向い
     たコンテキストです。このコンテキストを使うと、他の場合にはプログラ
     ムが停止してしまうような状況があっても実行を完了させられます。

 -- クラス: decimal.DefaultContext

     *note Context: 107f. コンストラクタが新たなコンテキストを作成するさ
     いに雛形にするコンテキストです。このコンテキストのフィールド (精度
     の設定など) を変更すると、 *note Context: 107f. コンストラクタが生
     成する新たなコンテキストに影響を及ぼします。

     このコンテキストは、主に多重スレッド環境で便利です。スレッドを開始
     する前に何らかのフィールドを変更しておくと、システム全体のデフォル
     ト設定に効果を及ぼすことができます。スレッドを開始した後にフィール
     ドを変更すると、競合条件を抑制するためにスレッドを同期化しなければ
     ならないので、推奨しません。

     単一スレッドの環境では、このコンテキストを使わないよう薦めます。下
     で述べるように明示的にコンテキストを作成してください。

     デフォルトの値は、 ‘Context.prec’=‘28’, ‘Context.rounding’=*note
     ROUND_HALF_EVEN: 2591. で、トラップ *note Overflow: 259a, *note
     InvalidOperation: 107a, および *note DivisionByZero: 2596. が有効に
     なっています。

上に挙げた三つのコンテキストに加え、 *note Context: 107f. コンストラクタ
を使って新たなコンテキストを生成できます。

 -- クラス: decimal.Context (prec=None, rounding=None, Emin=None,
          Emax=None, capitals=None, clamp=None, flags=None, traps=None)

     新たなコンテキストを生成します。あるフィールドが定義されていないか
     *note None: 641. であれば、 *note DefaultContext: 1077. からデフォ
     ルト値をコピーします。 'flags' フィールドが設定されていいか *note
     None: 641. の場合には、全てのフラグがクリアされます。

     'prec' フィールドは範囲 [‘1’, *note MAX_PREC: 25d6.] 内の整数で、コ
     ンテキストにおける算術演算の計算精度を設定します。

     'rounding' オプションは、節 *note 丸めモード: 25d7. で挙げられる定
     数の一つです。

     'traps' および 'flags' フィールドには、セットしたいシグナルを列挙し
     ます。一般的に、新たなコンテキストを作成するときにはトラップだけを
     設定し、フラグはクリアしておきます。

     'Emin' および 'Emax' フィールドは、許容する指数の外限を指定する整数
     です。 'Emin' は範囲 [*note MIN_EMIN: 25d8, ‘0’] 内で、 'Emax' は範
     囲 [‘0’, *note MAX_EMAX: 25d9.] 内でなければなりません。

     'capitals' フィールドは ‘0’ または ‘1’ (デフォルト) にします。 ‘1’
     に設定すると、指数記号を大文字 ‘E’ で出力します。それ以外の場合には
     ‘Decimal('6.02e+23')’ のように小文字の ‘e’ を使います。

     'clamp' フィールドは、 ‘0’ (デフォルト) または ‘1’ です。 ‘1’ に設
     定されると、このコンテキストにおける *note Decimal: 27d. インスタン
     スの指数 ‘e’ は厳密に範囲 ‘Emin - prec + 1 <= e <= Emax - prec + 1’
     に制限されます。 'clamp' が ‘0’ なら、それより弱い条件が支配します:
     調整された *note Decimal: 27d. インスタンスの指数は最大で ‘Emax’ で
     す。 'clamp' が ‘1’ なら、大きな正規数は、可能なら、指数が減らされ
     、対応する数の 0 が係数に加えられ、指数の制約に合わせられます; これ
     は数の値を保存しますが、有効な末尾の 0 に関する情報を失います。例え
     ば:

          >>> Context(prec=6, Emax=999, clamp=1).create_decimal('1.23e999')
          Decimal('1.23000E+999')

     'clamp' の値 ‘1’ は、IEEE 754 で規定された固定幅十進交換形式と互換
     にできます。

     *note Context: 107f. クラスでは、いくつかの汎用のメソッドの他、現在
     のコンテキストで算術演算を直接行うためのメソッドを数多く定義してい
     ます。加えて、 *note Decimal: 27d. の各メソッドについて(*note
     adjusted(): 25a1. および *note as_tuple(): 25a2. メソッドを例外とし
     て)対応する *note Context: 107f. のメソッドが存在します。たとえば、
     *note Context: 107f. インスタンス ‘C’ と *note Decimal: 27d. インス
     タンス ‘x’ に対して、 ‘C.exp(x)’ は ‘x.exp(context=C)’ と等価です。
     それぞれの *note Context: 107f. メソッドは、Decimal インスタンスが
     受け付けられるところならどこでも、Python の整数 (*note int: 238. の
     インスタンス) を受け付けます。

      -- メソッド: clear_flags ()

          フラグを全て ‘0’ にリセットします。

      -- メソッド: clear_traps ()

          トラップを全て ‘0’ にリセットします。

          Added in version 3.3.

      -- メソッド: copy ()

          コンテキストの複製を返します。

      -- メソッド: copy_decimal (num)

          Decimal インスタンス num のコピーを返します。

      -- メソッド: create_decimal (num)

          'self' をコンテキストとする新たな Decimal インスタンスを 'num'
          から生成します。 *note Decimal: 27d. コンストラクタと違い、数
          値を変換する際にコンテキストの精度、値丸め方法、フラグ、トラッ
          プを適用します。

          定数値はしばしばアプリケーションの要求よりも高い精度を持ってい
          るため、このメソッドが役に立ちます。また、値丸めを即座に行うた
          め、例えば以下のように、入力値に値丸めを行わないために合計値に
          ゼロの加算を追加するだけで結果が変わってしまうといった、現在の
          精度よりも細かい値の影響が紛れ込む問題を防げるという恩恵もあり
          ます。以下の例は、丸められていない入力を使うということは和にゼ
          ロを加えると結果が変わり得るという見本です:

               >>> getcontext().prec = 3
               >>> Decimal('3.4445') + Decimal('1.0023')
               Decimal('4.45')
               >>> Decimal('3.4445') + Decimal(0) + Decimal('1.0023')
               Decimal('4.44')

          このメソッドは IBM 仕様の to-number 演算を実装したものです。引
          数が文字列の場合、前や後ろに余計な空白を付けたり、アンダースコ
          アを含めたりすることは許されません。

      -- メソッド: create_decimal_from_float (f)

          浮動小数点数 'f' から新しい Decimal インスタンスを生成しますが
          、 'self' をコンテキストとして丸めます。 *note
          Decimal.from_float(): 11d5. クラスメソッドとは違い、変換にコン
          テキストの精度、丸めメソッド、フラグ、そしてトラップが適用され
          ます。

               >>> context = Context(prec=5, rounding=ROUND_DOWN)
               >>> context.create_decimal_from_float(math.pi)
               Decimal('3.1415')
               >>> context = Context(prec=5, traps=[Inexact])
               >>> context.create_decimal_from_float(math.pi)
               Traceback (most recent call last):
                   ...
               decimal.Inexact: None

          Added in version 3.1.

      -- メソッド: Etiny ()

          ‘Emin - prec + 1’ に等しい値を返します。演算結果の劣化が起こる
          桁の最小値です。アンダーフローが起きた場合、指数は *note
          Etiny: 25c7. に設定されます。

      -- メソッド: Etop ()

          ‘Emax - prec + 1’ に等しい値を返します。

     *note Decimal: 27d. を使った処理を行う場合、通常は *note Decimal:
     27d. インスタンスを生成して、算術演算を適用するというアプローチをと
     ります。演算はアクティブなスレッドにおける現在のコンテキストの下で
     行われます。もう一つのアプローチは、コンテキストのメソッドを使った
     特定のコンテキスト下での計算です。コンテキストのメソッドは *note
     Decimal: 27d. クラスのメソッドに似ているので、ここでは簡単な説明に
     とどめます。

      -- メソッド: abs (x)

          'x' の絶対値を返します。

      -- メソッド: add (x, y)

          'x' と 'y' の和を返します。

      -- メソッド: canonical (x)

          同じ Decimal オブジェクト 'x' を返します。

      -- メソッド: compare (x, y)

          'x' と 'y' を数値として比較します。

      -- メソッド: compare_signal (x, y)

          二つの演算対象の値を数値として比較します。

      -- メソッド: compare_total (x, y)

          二つの演算対象を抽象的な表現を使って比較します。

      -- メソッド: compare_total_mag (x, y)

          二つの演算対象を抽象的な表現を使い符号を無視して比較します。

      -- メソッド: copy_abs (x)

          'x' のコピーの符号を 0 にセットして返します。

      -- メソッド: copy_negate (x)

          'x' のコピーの符号を反転して返します。

      -- メソッド: copy_sign (x, y)

          'y' から 'x' に符号をコピーします。

      -- メソッド: divide (x, y)

          'x' を 'y' で除算した値を返します。

      -- メソッド: divide_int (x, y)

          'x' を 'y' で除算した値を整数に切り捨てて返します。

      -- メソッド: divmod (x, y)

          二つの数値間の除算を行い、結果の整数部を返します。

      -- メソッド: exp (x)

          ‘e ** x’ を返します。

      -- メソッド: fma (x, y, z)

          'x' を 'y' 倍したものに 'z' を加えて返します。

      -- メソッド: is_canonical (x)

          'x' が標準的(canonical)ならば ‘True’ を返します。そうでなけれ
          ば ‘False’ です。

      -- メソッド: is_finite (x)

          'x' が有限ならば ‘True’ を返します。そうでなければ ‘False’ で
          す。

      -- メソッド: is_infinite (x)

          'x' が無限ならば ‘True’ を返します。そうでなければ ‘False’ で
          す。

      -- メソッド: is_nan (x)

          'x' が qNaN か sNaN であれば ‘True’ を返します。そうでなければ
          ‘False’ です。

      -- メソッド: is_normal (x)

          'x' が通常の数ならば ‘True’ を返します。そうでなければ ‘False’
          です。

      -- メソッド: is_qnan (x)

          'x' が無言 NaN であれば ‘True’ を返します。そうでなければ
          ‘False’ です。

      -- メソッド: is_signed (x)

          'x' が負の数であれば ‘True’ を返します。そうでなければ ‘False’
          です。

      -- メソッド: is_snan (x)

          'x' が発信 NaN であれば ‘True’ を返します。そうでなければ
          ‘False’ です。

      -- メソッド: is_subnormal (x)

          'x' が非正規数であれば ‘True’ を返します。そうでなければ
          ‘False’ です。

      -- メソッド: is_zero (x)

          'x' がゼロであれば ‘True’ を返します。そうでなければ ‘False’ で
          す。

      -- メソッド: ln (x)

          'x' の自然対数(底 e の対数)を返します。

      -- メソッド: log10 (x)

          'x' の底 10 の対数を返します。

      -- メソッド: logb (x)

          演算対象の MSD の大きさの指数部を返します。

      -- メソッド: logical_and (x, y)

          それぞれの桁に論理演算 'and' を当てはめます。

      -- メソッド: logical_invert (x)

          'x' の全ての桁を反転させます。

      -- メソッド: logical_or (x, y)

          それぞれの桁に論理演算 'or' を当てはめます。

      -- メソッド: logical_xor (x, y)

          それぞれの桁に論理演算 'xor' を当てはめます。

      -- メソッド: max (x, y)

          二つの値を数値として比較し、大きいほうを返します。

      -- メソッド: max_mag (x, y)

          値を符号を無視して数値として比較します。

      -- メソッド: min (x, y)

          二つの値を数値として比較し、小さいほうを返します。

      -- メソッド: min_mag (x, y)

          値を符号を無視して数値として比較します。

      -- メソッド: minus (x)

          Python における単項マイナス演算子に対応する演算です。

      -- メソッド: multiply (x, y)

          'x' と 'y' の積を返します。

      -- メソッド: next_minus (x)

          'x' より小さい最大の表現可能な数を返します。

      -- メソッド: next_plus (x)

          'x' より大きい最小の表現可能な数を返します。

      -- メソッド: next_toward (x, y)

          'x' に 'y' の方向に向かって最も近い数を返します。

      -- メソッド: normalize (x)

          'x' をもっとも単純な形にします。

      -- メソッド: number_class (x)

          'x' のクラスを指し示すものを返します。

      -- メソッド: plus (x)

          Python における単項のプラス演算子に対応する演算です。コンテキ
          ストにおける精度や値丸めを適用するので、等値 (identity) 演算と
          は '違います'。

      -- メソッド: power (x, y, modulo=None)

          ‘x’ の ‘y’ 乗を計算します。‘modulo’ が指定されていればモジュロ
          を取ります。

          引数が 2 つの場合、 ‘x**y’ を計算します。‘x’ が負の場合、 ‘y’
          は整数でなければなりません。‘y’ が整数、結果が有限、結果が
          'precision' 桁で正確に表現できる、という条件をすべて満たさない
          場合、結果は不正確になります。結果はコンテキストの丸めモードを
          使って丸められます。結果は常に、Python バージョンにおいて正し
          く丸められます。

          ‘Decimal(0) ** Decimal(0)’ results in ‘InvalidOperation’, and
          if ‘InvalidOperation’ is not trapped, then results in
          ‘Decimal('NaN')’.

          バージョン 3.3 で変更: C モジュールは *note power(): 2609. を
          適切に丸められた *note exp(): 25eb. および *note ln(): 25f6. 関
          数によって計算します。結果は well-defined ですが、「ほとんどの
          場合には適切に丸められる」だけです。

          引数が 3 つの場合、 ‘(x**y) % modulo’ を計算します。この 3 引
          数の形式の場合、引数には以下の制限が課せられます。

             - 全ての引数は整数

             - ‘y’ は非負でなければならない

             - ‘x’ と ‘y’ の少なくともどちらかはゼロでない

             - ‘modulo’ は非零で大きくても 'precision' 桁

          ‘Context.power(x, y, modulo)’ で得られる値は ‘(x**y) % modulo’
          を精度無制限で計算して得られるものと同じ値ですが、より効率的に
          計算されます。結果の指数は ‘x’, ‘y’, ‘modulo’ の指数に関係なく
          ゼロです。この計算は常に正確です。

      -- メソッド: quantize (x, y)

          'x' に値丸めを適用し、指数を 'y' にした値を返します。

      -- メソッド: radix ()

          単に 10 を返します。何せ十進ですから :)

      -- メソッド: remainder (x, y)

          整数除算の剰余を返します。

          剰余がゼロでない場合、符号は割られる数の符号と同じになります。

      -- メソッド: remainder_near (x, y)

          ‘x - y * n’ を返します。ここで 'n' は ‘x / y’ の正確な値に一番
          近い整数です (この結果が 0 ならばその符号は 'x' の符号と同じで
          す)。

      -- メソッド: rotate (x, y)

          'x' の 'y' 回巡回したコピーを返します。

      -- メソッド: same_quantum (x, y)

          2つの演算対象が同じ指数を持っている場合に ‘True’ を返します。

      -- メソッド: scaleb (x, y)

          一つめの演算対象の指数部に二つめの値を加えたものを返します。

      -- メソッド: shift (x, y)

          'x' を 'y' 回シフトしたコピーを返します。

      -- メソッド: sqrt (x)

          'x' の平方根を精度いっぱいまで求めます。

      -- メソッド: subtract (x, y)

          'x' と 'y' の間の差を返します。

      -- メソッド: to_eng_string (x)

          文字列に変換します。指数が必要なら工学表記が使われます。

          工学表記法では指数は 3 の倍数になります。これにより、基数の小
          数部には最大で 3 桁までの数字が残されるとともに、末尾に 1 つま
          たは 2 つの 0 の付加が必要とされるかもしれません。

      -- メソッド: to_integral_exact (x)

          最近傍の整数に値を丸めます。

      -- メソッド: to_sci_string (x)

          数値を科学表記で文字列に変換します。


File: python.info,  Node: 定数<4>,  Next: 丸めモード,  Prev: Context オブジェクト,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.5 定数
............

この節の定数は C モジュールにのみ意味があります。互換性のために、pure
Python 版も含まれます。

                          32-bit                    64-bit
                                                    
----------------------------------------------------------------------------------------
                                                    
 -- データ:               ‘425000000’               ‘999999999999999999’
          decimal.MAX_PREC                          

 -- データ:               ‘425000000’               ‘999999999999999999’
          decimal.MAX_EMAX                          

 -- データ:               ‘-425000000’              ‘-999999999999999999’
          decimal.MIN_EMIN                          

 -- データ:               ‘-849999999’              ‘-1999999999999999997’
          decimal.MIN_ETINY                         

 -- データ: decimal.HAVE_THREADS

     値は ‘True’ です。現在のPythonは常にスレッドを持っているので、非推
     奨になりました。

     バージョン 3.9 で非推奨.

 -- データ: decimal.HAVE_CONTEXTVAR

     The default value is ‘True’.  If Python is *note configured using
     the -without-decimal-contextvar option: 1cdc, the C version uses a
     thread-local rather than a coroutine-local context and the value is
     ‘False’.  This is slightly faster in some nested context scenarios.

     Added in version 3.8.3.


File: python.info,  Node: 丸めモード,  Next: シグナル,  Prev: 定数<4>,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.6 丸めモード
..................

 -- データ: decimal.ROUND_CEILING

     ‘Infinity’ 方向に丸めます。

 -- データ: decimal.ROUND_DOWN

     ゼロ方向に丸めます。

 -- データ: decimal.ROUND_FLOOR

     ‘-Infinity’ 方向に丸めます。

 -- データ: decimal.ROUND_HALF_DOWN

     近い方に、引き分けはゼロ方向に向けて丸めます。

 -- データ: decimal.ROUND_HALF_EVEN

     近い方に、引き分けは偶数整数方向に向けて丸めます。

 -- データ: decimal.ROUND_HALF_UP

     近い方に、引き分けはゼロから遠い方向に向けて丸めます。

 -- データ: decimal.ROUND_UP

     ゼロから遠い方向に丸めます。

 -- データ: decimal.ROUND_05UP

     ゼロ方向に丸めた後の最後の桁が 0 または 5 ならばゼロから遠い方向に
     、そうでなければゼロ方向に丸めます。


File: python.info,  Node: シグナル,  Next: Floating-Point Notes,  Prev: 丸めモード,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.7 シグナル
................

シグナルは、計算中に生じた様々なエラー条件を表現します。各々のシグナルは
一つのコンテキストフラグと一つのトラップイネーブラに対応しています。

コンテキストフラグは、該当するエラー条件に遭遇するたびにセットされます。
演算後にフラグを調べれば、演算に関する情報 (例えば計算が厳密だったかどう
か) がわかります。フラグを調べたら、次の計算を始める前にフラグを全てクリ
アするようにしてください。

あるコンテキストのトラップイネーブラがあるシグナルに対してセットされてい
る場合、該当するエラー条件が生じると Python の例外を送出します。例えば、
*note DivisionByZero: 2596. が設定されていると、エラー条件が生じた際に
*note DivisionByZero: 2596. 例外を送出します。

 -- クラス: decimal.Clamped

     値の表現上の制限に沿わせるために指数部が変更されたことを通知します
     。

     通常、クランプ (clamp) は、指数部がコンテキストにおける指数桁の制限
     値 ‘Emin’ および ‘Emax’ を越えた場合に発生します。可能な場合には、
     係数部にゼロを加えた表現に合わせて指数部を減らします。

 -- クラス: decimal.DecimalException

     他のシグナルの基底クラスで、 *note ArithmeticError: 21e2. のサブク
     ラスです。

 -- クラス: decimal.DivisionByZero

     有限値をゼロで除算したときのシグナルです。

     除算やモジュロ除算、数を負の値で累乗した場合に起きることがあります
     。このシグナルをトラップしない場合、演算結果は ‘Infinity’ または
     ‘-Infinity’ になり、その符号は演算に使った入力に基づいて決まります
     。

 -- クラス: decimal.Inexact

     値の丸めによって演算結果から厳密さが失われたことを通知します。

     このシグナルは値丸め操作中にゼロでない桁を無視した際に生じます。演
     算結果は値丸め後の値です。シグナルのフラグやトラップは、演算結果の
     厳密さが失われたことを検出するために使えるだけです。

 -- クラス: decimal.InvalidOperation

     無効な演算が実行されたことを通知します。

     ユーザが有意な演算結果にならないような操作を要求したことを示します
     。このシグナルをトラップしない場合、 ‘NaN’ を返します。このシグナル
     の発生原因として考えられるのは、以下のような状況です:

          Infinity - Infinity
          0 * Infinity
          Infinity / Infinity
          x % 0
          Infinity % x
          sqrt(-x) and x > 0
          0 ** 0
          x ** (non-integer)
          x ** Infinity

 -- クラス: decimal.Overflow

     数値オーバフローを示すシグナルです。

     このシグナルは、値丸めを行った後の指数部が ‘Context.Emax’ より大き
     いことを示します。シグナルをトラップしない場合、演算結果は値丸めの
     モードにより、表現可能な最大の数値になるように内側へ引き込んで丸め
     を行った値か、 ‘Infinity’ になるように外側に丸めた値のいずれかにな
     ります。いずれの場合も、 *note Inexact: 2597. および *note Rounded:
     2598. が同時にシグナルされます。

 -- クラス: decimal.Rounded

     情報が全く失われていない場合も含み、値丸めが起きたときのシグナルで
     す。

     このシグナルは、値丸めによって桁がなくなると常に発生します。なくな
     った桁がゼロ (例えば ‘5.00’ を丸めて ‘5.0’ になった場合) であっても
     です。このシグナルをトラップしなければ、演算結果をそのまま返します
     。このシグナルは有効桁数の減少を検出する際に使います。

 -- クラス: decimal.Subnormal

     値丸めを行う前に指数部が ‘Emin’ より小さかったことを示すシグナルで
     す。

     演算結果が微小である場合 (指数が小さすぎる場合) に発生します。この
     シグナルをトラップしなければ、演算結果をそのまま返します。

 -- クラス: decimal.Underflow

     演算結果が値丸めによってゼロになった場合に生じる数値アンダフローで
     す。

     演算結果が微小なため、値丸めによってゼロになった場合に発生します。
     *note Inexact: 2597. および *note Subnormal: 2599. シグナルも同時に
     発生します。

 -- クラス: decimal.FloatOperation

     float と Decimal の混合の厳密なセマンティクスを有効にします。

     シグナルがトラップされなかった場合 (デフォルト)、*note Decimal:
     27d. コンストラクタ、 *note create_decimal(): 107b. 、およびすべて
     の比較演算子において float と Decimal の混合が許されます。変換も比
     較も正確です。コンテキストフラグ内に *note FloatOperation: 1072. を
     設定することで、混合操作は現れるたびに暗黙に記録されます。 *note
     from_float(): 11d5. や *note create_decimal_from_float(): 25dd. に
     よる明示的な変換はフラグを設定しません。

     そうでなければ (シグナルがトラップされれば)、等価性比較および明示的
     な変換のみが静かにに行われ、その他の混合演算は *note
     FloatOperation: 1072. を送出します。

これらのシグナルの階層構造をまとめると、以下の表のようになります:

     exceptions.ArithmeticError(exceptions.Exception)
         DecimalException
             Clamped
             DivisionByZero(DecimalException, exceptions.ZeroDivisionError)
             Inexact
                 Overflow(Inexact, Rounded)
                 Underflow(Inexact, Rounded, Subnormal)
             InvalidOperation
             Rounded
             Subnormal
             FloatOperation(DecimalException, exceptions.TypeError)


File: python.info,  Node: Floating-Point Notes,  Next: スレッドを使った処理,  Prev: シグナル,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.8 Floating-Point Notes
............................

* Menu:

* 精度を上げて丸め誤差を抑制する::
* 特殊値::


File: python.info,  Node: 精度を上げて丸め誤差を抑制する,  Next: 特殊値,  Up: Floating-Point Notes

5.9.4.9 精度を上げて丸め誤差を抑制する
......................................

十進浮動小数点数を使うと、十進数表現による誤差を抑制できます (‘0.1’ を正
確に表現できるようになります); しかし、ゼロでない桁が一定の精度を越えて
いる場合には、演算によっては依然として値丸めによる誤差を引き起こします。

The effects of round-off error can be amplified by the addition or
subtraction of nearly offsetting quantities resulting in loss of
significance.  Knuth provides two instructive examples where rounded
floating-point arithmetic with insufficient precision causes the
breakdown of the associative and distributive properties of addition:

     # Examples from Seminumerical Algorithms, Section 4.2.2.
     >>> from decimal import Decimal, getcontext
     >>> getcontext().prec = 8

     >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')
     >>> (u + v) + w
     Decimal('9.5111111')
     >>> u + (v + w)
     Decimal('10')

     >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')
     >>> (u*v) + (u*w)
     Decimal('0.01')
     >>> u * (v+w)
     Decimal('0.0060000')

*note decimal: 2e. モジュールでは、最下桁を失わないように十分に計算精度
を広げることで、上で問題にしたような恒等性をとりもどせます:

     >>> getcontext().prec = 20
     >>> u, v, w = Decimal(11111113), Decimal(-11111111), Decimal('7.51111111')
     >>> (u + v) + w
     Decimal('9.51111111')
     >>> u + (v + w)
     Decimal('9.51111111')
     >>>
     >>> u, v, w = Decimal(20000), Decimal(-6), Decimal('6.0000003')
     >>> (u*v) + (u*w)
     Decimal('0.0060000')
     >>> u * (v+w)
     Decimal('0.0060000')


File: python.info,  Node: 特殊値,  Prev: 精度を上げて丸め誤差を抑制する,  Up: Floating-Point Notes

5.9.4.10 特殊値
...............

*note decimal: 2e. モジュールの数体系では、 ‘NaN’, ‘sNaN’, ‘-Infinity’
‘Infinity’, および二つのゼロ、 ‘+0’ と ‘-0’ といった特殊な値を提供してい
ます。

無限大 (Infinity) は ‘Decimal('Infinity')’ で直接構築できます。また、
*note DivisionByZero: 2596. をトラップせずにゼロで除算を行った場合にも出
てきます。同様に、 *note Overflow: 259a. シグナルをトラップしなければ、
表現可能な最大の数値の制限を越えた値を丸めたときに出てきます。

無限大には符号があり (アフィン: affine であり)、算術演算に使用でき、非常
に巨大で不確定の(indeterminate)値として扱われます。例えば、無限大に何ら
かの定数を加算すると、演算結果は別の無限大になります。

演算によっては結果が不確定になるものがあり、 ‘NaN’ を返します。ただし、
*note InvalidOperation: 107a. シグナルをトラップするようになっていれば例
外を送出します。例えば、 ‘0/0’ は ‘NaN’ を返します。 ‘NaN’ は「非数値
(not a number)」を表します。このような ‘NaN’ は暗黙のうちに生成され、一
度生成されるとそれを他の計算にも流れてゆき、関係する個々の演算全てが個別
の ‘NaN’ を返すようになります。この挙動は、たまに入力値が欠けるような状
況で一連の計算を行う際に便利です -- 特定の計算に対しては無効な結果を示す
フラグを立てつつ計算を進められるからです。

一方、 ‘NaN’ の変種である ‘sNaN’ は関係する全ての演算で演算後にシグナル
を送出します。 ‘sNaN’ は、無効な演算結果に対して特別な処理を行うために計
算を停止する必要がある場合に便利です。

Python の比較演算は ‘NaN’ が関わってくると少し驚くようなことがあります。
等価性のテストの一方の対象が無言または発信 ‘NaN’ である場合いつでも
*note False: b05. を返し(たとえ ‘Decimal('NaN')==Decimal('NaN')’ でも)、
一方で不等価をテストするといつでも *note True: bdb. を返します。二つの
Decimal を ‘<’, ‘<=’, ‘>’ または ‘>=’ を使って比較する試みは一方が ‘NaN’
である場合には *note InvalidOperation: 107a. シグナルを送出し、このシグ
ナルをトラップしなければ結果は *note False: b05. に終わります。汎用十進
演算仕様は直接の比較の振る舞いについて定めていないことに注意しておきまし
ょう。ここでの ‘NaN’ が関係する比較ルールは IEEE 854 標準から持ってきま
した (section 5.7 の Table 3 を見て下さい)。厳格に標準遵守を貫くなら、
*note compare(): 25a4. および *note compare_signal(): 25a5. メソッドを代
わりに使いましょう。

アンダフローの起きた計算は、符号付きのゼロ (signed zero) を返すことがあ
ります。符号は、より高い精度で計算を行った結果の符号と同じになります。符
号付きゼロの大きさはやはりゼロなので、正のゼロと負のゼロは等しいとみなさ
れ、符号は単なる参考にすぎません。

In addition to the two signed zeros which are distinct yet equal, there
are various representations of zero with differing precisions yet
equivalent in value.  This takes a bit of getting used to.  For an eye
accustomed to normalized floating-point representations, it is not
immediately obvious that the following calculation returns a value equal
to zero:

     >>> 1 / Decimal('Infinity')
     Decimal('0E-1000026')


File: python.info,  Node: スレッドを使った処理,  Next: レシピ,  Prev: Floating-Point Notes,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.11 スレッドを使った処理
.............................

関数 *note getcontext(): 1537. は、スレッド毎に別々の *note Context:
107f. オブジェクトにアクセスします。別のスレッドコンテキストを持つという
ことは、複数のスレッドが互いに影響を及ぼさずに (‘getcontext().prec=10’ の
ような) 変更を適用できるということです。

同様に、*note setcontext(): 259d. 関数は自動的に引数のコンテキストを現在
のスレッドのコンテキストに設定します。

*note getcontext(): 1537. を呼び出す前に *note setcontext(): 259d. が呼
び出されていなければ、現在のスレッドで使うための新たなコンテキストを生成
するために *note getcontext(): 1537. が自動的に呼び出されます。

新たなコンテキストは、'DefaultContext' と呼ばれる雛形からコピーされます
。アプリケーションを通じて全てのスレッドに同じ値を使うようにデフォルトを
設定したければ、'DefaultContext' オブジェクトを直接変更します。 *note
getcontext(): 1537. を呼び出すスレッド間で競合条件が生じないようにするた
め、'DefaultContext' への変更はいかなるスレッドを開始するよりも '前に' 行
わなければなりません。以下に例を示します:

     # Set applicationwide defaults for all threads about to be launched
     DefaultContext.prec = 12
     DefaultContext.rounding = ROUND_DOWN
     DefaultContext.traps = ExtendedContext.traps.copy()
     DefaultContext.traps[InvalidOperation] = 1
     setcontext(DefaultContext)

     # Afterwards, the threads can be started
     t1.start()
     t2.start()
     t3.start()
      . . .


File: python.info,  Node: レシピ,  Next: Decimal FAQ,  Prev: スレッドを使った処理,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.12 レシピ
...............

*note Decimal: 27d. クラスの利用を実演している例をいくつか示します。これ
らはユーティリティ関数としても利用できます:

     def moneyfmt(value, places=2, curr='', sep=',', dp='.',
                  pos='', neg='-', trailneg=''):
         """Convert Decimal to a money formatted string.

         places:  required number of places after the decimal point
         curr:    optional currency symbol before the sign (may be blank)
         sep:     optional grouping separator (comma, period, space, or blank)
         dp:      decimal point indicator (comma or period)
                  only specify as blank when places is zero
         pos:     optional sign for positive numbers: '+', space or blank
         neg:     optional sign for negative numbers: '-', '(', space or blank
         trailneg:optional trailing minus indicator:  '-', ')', space or blank

         >>> d = Decimal('-1234567.8901')
         >>> moneyfmt(d, curr='$')
         '-$1,234,567.89'
         >>> moneyfmt(d, places=0, sep='.', dp='', neg='', trailneg='-')
         '1.234.568-'
         >>> moneyfmt(d, curr='$', neg='(', trailneg=')')
         '($1,234,567.89)'
         >>> moneyfmt(Decimal(123456789), sep=' ')
         '123 456 789.00'
         >>> moneyfmt(Decimal('-0.02'), neg='<', trailneg='>')
         '<0.02>'

         """
         q = Decimal(10) ** -places      # 2 places --> '0.01'
         sign, digits, exp = value.quantize(q).as_tuple()
         result = []
         digits = list(map(str, digits))
         build, next = result.append, digits.pop
         if sign:
             build(trailneg)
         for i in range(places):
             build(next() if digits else '0')
         if places:
             build(dp)
         if not digits:
             build('0')
         i = 0
         while digits:
             build(next())
             i += 1
             if i == 3 and digits:
                 i = 0
                 build(sep)
         build(curr)
         build(neg if sign else pos)
         return ''.join(reversed(result))

     def pi():
         """Compute Pi to the current precision.

         >>> print(pi())
         3.141592653589793238462643383

         """
         getcontext().prec += 2  # extra digits for intermediate steps
         three = Decimal(3)      # substitute "three=3.0" for regular floats
         lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24
         while s != lasts:
             lasts = s
             n, na = n+na, na+8
             d, da = d+da, da+32
             t = (t * n) / d
             s += t
         getcontext().prec -= 2
         return +s               # unary plus applies the new precision

     def exp(x):
         """Return e raised to the power of x.  Result type matches input type.

         >>> print(exp(Decimal(1)))
         2.718281828459045235360287471
         >>> print(exp(Decimal(2)))
         7.389056098930650227230427461
         >>> print(exp(2.0))
         7.38905609893
         >>> print(exp(2+0j))
         (7.38905609893+0j)

         """
         getcontext().prec += 2
         i, lasts, s, fact, num = 0, 0, 1, 1, 1
         while s != lasts:
             lasts = s
             i += 1
             fact *= i
             num *= x
             s += num / fact
         getcontext().prec -= 2
         return +s

     def cos(x):
         """Return the cosine of x as measured in radians.

         The Taylor series approximation works best for a small value of x.
         For larger values, first compute x = x % (2 * pi).

         >>> print(cos(Decimal('0.5')))
         0.8775825618903727161162815826
         >>> print(cos(0.5))
         0.87758256189
         >>> print(cos(0.5+0j))
         (0.87758256189+0j)

         """
         getcontext().prec += 2
         i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1
         while s != lasts:
             lasts = s
             i += 2
             fact *= i * (i-1)
             num *= x * x
             sign *= -1
             s += num / fact * sign
         getcontext().prec -= 2
         return +s

     def sin(x):
         """Return the sine of x as measured in radians.

         The Taylor series approximation works best for a small value of x.
         For larger values, first compute x = x % (2 * pi).

         >>> print(sin(Decimal('0.5')))
         0.4794255386042030002732879352
         >>> print(sin(0.5))
         0.479425538604
         >>> print(sin(0.5+0j))
         (0.479425538604+0j)

         """
         getcontext().prec += 2
         i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1
         while s != lasts:
             lasts = s
             i += 2
             fact *= i * (i-1)
             num *= x * x
             sign *= -1
             s += num / fact * sign
         getcontext().prec -= 2
         return +s


File: python.info,  Node: Decimal FAQ,  Prev: レシピ,  Up: decimal --- 10進固定小数点と浮動小数点の演算

5.9.4.13 Decimal FAQ
....................

Q. ‘decimal.Decimal('1234.5')’ などと打ち込むのは煩わしいのですが、対話
式インタプリタを使う際にタイプ量を少なくする方法はありませんか?

A. コンストラクタを1文字に縮める人もいるようです:

     >>> D = decimal.Decimal
     >>> D('1.23') + D('3.45')
     Decimal('4.68')

Q. 小数点以下2桁の固定小数点数のアプリケーションの中で、いくつかの入力が
余計な桁を保持しているのでこれを丸めなければなりません。その他のものに余
計な桁はなくそのまま使えます。どのメソッドを使うのがいいでしょうか?

A. *note quantize(): 1080. メソッドで固定した桁に丸められます。 *note
Inexact: 2597. トラップを設定しておけば、確認にも有用です:

     >>> TWOPLACES = Decimal(10) ** -2       # same as Decimal('0.01')

     >>> # Round to two places
     >>> Decimal('3.214').quantize(TWOPLACES)
     Decimal('3.21')

     >>> # Validate that a number does not exceed two places
     >>> Decimal('3.21').quantize(TWOPLACES, context=Context(traps=[Inexact]))
     Decimal('3.21')

     >>> Decimal('3.214').quantize(TWOPLACES, context=Context(traps=[Inexact]))
     Traceback (most recent call last):
        ...
     Inexact: None

Q. 正当な2桁の入力が得られたとして、その正当性をアプリケーション実行中も
変わらず保ち続けるにはどうすればいいでしょうか?

A. 加減算あるいは整数との乗算のような演算は自動的に固定小数点を守ります
。その他の除算や整数以外の乗算などは小数点以下の桁を変えてしまいますので
実行後は *note quantize(): 1080. ステップが必要です:

     >>> a = Decimal('102.72')           # Initial fixed-point values
     >>> b = Decimal('3.17')
     >>> a + b                           # Addition preserves fixed-point
     Decimal('105.89')
     >>> a - b
     Decimal('99.55')
     >>> a * 42                          # So does integer multiplication
     Decimal('4314.24')
     >>> (a * b).quantize(TWOPLACES)     # Must quantize non-integer multiplication
     Decimal('325.62')
     >>> (b / a).quantize(TWOPLACES)     # And quantize division
     Decimal('0.03')

固定小数点のアプリケーションを開発する際は、 *note quantize(): 1080. の
段階を扱う関数を定義しておくと便利です:

     >>> def mul(x, y, fp=TWOPLACES):
     ...     return (x * y).quantize(fp)
     ...
     >>> def div(x, y, fp=TWOPLACES):
     ...     return (x / y).quantize(fp)

     >>> mul(a, b)                       # Automatically preserve fixed-point
     Decimal('325.62')
     >>> div(b, a)
     Decimal('0.03')

Q. 一つの値に対して多くの表現方法があります。 ‘200’ と ‘200.000’ と
‘2E2’ と ‘.02E+4’ は全て同じ値で違った精度の数です。これらをただ一つの正
規化された値に変換することはできますか?

A. *note normalize(): 25c5. メソッドは全ての等しい値をただ一つの表現に直
します:

     >>> values = map(Decimal, '200 200.000 2E2 .02E+4'.split())
     >>> [v.normalize() for v in values]
     [Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2'), Decimal('2E+2')]

Q. When does rounding occur in a computation?

A. It occurs 'after' the computation.  The philosophy of the decimal
specification is that numbers are considered exact and are created
independent of the current context.  They can even have greater
precision than current context.  Computations process with those exact
inputs and then rounding (or other context operations) is applied to the
'result' of the computation:

     >>> getcontext().prec = 5
     >>> pi = Decimal('3.1415926535')   # More than 5 digits
     >>> pi                             # All digits are retained
     Decimal('3.1415926535')
     >>> pi + 0                         # Rounded after an addition
     Decimal('3.1416')
     >>> pi - Decimal('0.00005')        # Subtract unrounded numbers, then round
     Decimal('3.1415')
     >>> pi + 0 - Decimal('0.00005').   # Intermediate values are rounded
     Decimal('3.1416')

Q. ある種の十進数値はいつも指数表記で表示されます。指数表記以外の表示に
する方法はありますか?

A. 値によっては、指数表記だけが有効桁数を表せる表記法なのです。たとえば
、 ‘5.0E+3’ を ‘5000’ と表してしまうと、値は変わりませんが元々の2桁とい
う有効数字が反映されません。

もしアプリケーションが有効数字の追跡を等閑視するならば、指数部や末尾のゼ
ロを取り除き、有効数字を忘れ、しかし値を変えずにおくことは容易です:

     >>> def remove_exponent(d):
     ...     return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()

     >>> remove_exponent(Decimal('5E+3'))
     Decimal('5000')

Q. 普通の float を *note Decimal: 27d. に変換できますか?

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:

     >>> Decimal(math.pi)
     Decimal('3.141592653589793115997963468544185161590576171875')

Q. 複雑な計算の中で、精度不足や丸めの異常で間違った結果になっていないこ
とをどうやって保証すれば良いでしょうか。

A. decimal モジュールでは検算は容易です。一番良い方法は、大きめの精度や
様々な丸めモードで再計算してみることです。大きく異なった結果が出てきたら
、精度不足や丸めの問題や悪条件の入力、または数値計算的に不安定なアルゴリ
ズムを示唆しています。

Q. コンテキストの精度は計算結果には適用されていますが入力には適用されて
いないようです。様々に異なる精度の入力値を混ぜて計算する時に注意すべきこ
とはありますか?

A. はい。原則として入力値は正確であると見做しておりそれらの値を使った計
算も同様です。結果だけが丸められます。入力の強みは "what you type is
what you get" (打ち込んだ値が得られる値)という点にあります。入力が丸めら
れないということを忘れていると結果が奇妙に見えるというのは弱点です:

     >>> getcontext().prec = 3
     >>> Decimal('3.104') + Decimal('2.104')
     Decimal('5.21')
     >>> Decimal('3.104') + Decimal('0.000') + Decimal('2.104')
     Decimal('5.20')

解決策は、精度を増やすか、単項プラス演算子を使って入力の丸めを強制するこ
とです:

     >>> getcontext().prec = 3
     >>> +Decimal('1.23456789')      # unary plus triggers rounding
     Decimal('1.23')

もしくは、入力を *note Context.create_decimal(): 107b. を使って生成時に
丸めてしまうこともできます:

     >>> Context(prec=5, rounding=ROUND_DOWN).create_decimal('1.2345678')
     Decimal('1.2345')

Q. CPython 実装は大きな数に対しても速いでしょうか?

A. Yes.  In the CPython and PyPy3 implementations, the C/CFFI versions
of the decimal module integrate the high speed libmpdec(1) library for
arbitrary precision correctly rounded decimal floating-point arithmetic
(2).  ‘libmpdec’ uses Karatsuba multiplication(3) for medium-sized
numbers and the Number Theoretic Transform(4) for very large numbers.

The context must be adapted for exact arbitrary precision arithmetic.
‘Emin’ and ‘Emax’ should always be set to the maximum values, ‘clamp’
should always be 0 (the default).  Setting ‘prec’ requires some care.

The easiest approach for trying out bignum arithmetic is to use the
maximum value for ‘prec’ as well (5):

     >>> setcontext(Context(prec=MAX_PREC, Emax=MAX_EMAX, Emin=MIN_EMIN))
     >>> x = Decimal(2) ** 256
     >>> x / 128
     Decimal('904625697166532776746648320380374280103671755200316906558262375061821325312')

For inexact results, *note MAX_PREC: 25d6. is far too large on 64-bit
platforms and the available memory will be insufficient:

     >>> Decimal(1) / 3
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     MemoryError

On systems with overallocation (e.g.  Linux), a more sophisticated
approach is to adjust ‘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:

     >>> import sys
     >>>
     >>> # Maximum number of digits for a single operand using 500MB in 8-byte words
     >>> # with 19 digits per word (4-byte and 9 digits for the 32-bit build):
     >>> maxdigits = 19 * ((500 * 1024**2) // 8)
     >>>
     >>> # Check that this works:
     >>> c = Context(prec=maxdigits, Emax=MAX_EMAX, Emin=MIN_EMIN)
     >>> c.traps[Inexact] = True
     >>> setcontext(c)
     >>>
     >>> # Fill the available precision with nines:
     >>> x = Decimal(0).logical_invert() * 9
     >>> sys.getsizeof(x)
     524288112
     >>> x + 2
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       decimal.Inexact: [<class 'decimal.Inexact'>]

In general (and especially on systems without overallocation), it is
recommended to estimate even tighter bounds and set the *note Inexact:
2597. trap if all calculations are expected to be exact.

   ---------- Footnotes ----------

   (1) https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html

   (2) 
Added in version 3.3.

   (3) https://en.wikipedia.org/wiki/Karatsuba_algorithm

   (4) 
https://en.wikipedia.org/wiki/Discrete_Fourier_transform_(general)#Number-theoretic_transform

   (5) 
バージョン 3.9 で変更: This approach now works for all exact results
except for non-integer powers.


File: python.info,  Node: fractions --- 有理数,  Next: random --- 疑似乱数を生成する,  Prev: decimal --- 10進固定小数点と浮動小数点の演算,  Up: 数値と数学モジュール

5.9.5 ‘fractions’ -- 有理数
---------------------------

'ソースコード:' Lib/fractions.py(1)

__________________________________________________________________

*note fractions: 53. モジュールは有理数計算のサポートを提供します。

Fraction インスタンスは一対の整数、他の有理数、または文字列から生成され
ます。

 -- クラス: fractions.Fraction (numerator=0, denominator=1)

 -- クラス: fractions.Fraction (other_fraction)

 -- クラス: fractions.Fraction (float)

 -- クラス: fractions.Fraction (decimal)

 -- クラス: fractions.Fraction (string)

     The first version requires that 'numerator' and 'denominator' are
     instances of *note numbers.Rational: 1290. and returns a new *note
     Fraction: 1c8. instance with value ‘numerator/denominator’.  If
     'denominator' is ‘0’, it raises a *note ZeroDivisionError: 913.
     The second version requires that 'other_fraction' is an instance of
     *note numbers.Rational: 1290. and returns a *note Fraction: 1c8.
     instance with the same value.  The next two versions accept either
     a *note float: 2ce. or a *note decimal.Decimal: 27d. instance, and
     return a *note Fraction: 1c8. instance with exactly the same value.
     Note that due to the usual issues with binary floating point (see
     *note 浮動小数点演算、その問題と制限: 1c7b.), the argument to
     ‘Fraction(1.1)’ is not exactly equal to 11/10, and so
     ‘Fraction(1.1)’ does 'not' return ‘Fraction(11, 10)’ as one might
     expect.  (But see the documentation for the *note
     limit_denominator(): 2628. method below.)  The last version of the
     constructor expects a string or unicode instance.  The usual form
     for this instance is:

          [sign] numerator ['/' denominator]

     ここで、オプションの ‘sign’ は '+' か '-' のどちらかであり、
     ‘numerator’ および (存在する場合) ‘denominator’ は十進数の数字の文
     字列です (コード中の整数リテラルと同様、アンダースコアを使って桁を
     区切れます)。さらに、 *note float: 2ce. コンストラクタで受け付けら
     れる有限の値を表す文字列は、*note Fraction: 1c8. コンストラクタでも
     受け付けられます。どちらの形式でも、入力される文字列は前後に空白が
     あって構いません。以下に、いくつかの例を示します:

          >>> from fractions import Fraction
          >>> Fraction(16, -10)
          Fraction(-8, 5)
          >>> Fraction(123)
          Fraction(123, 1)
          >>> Fraction()
          Fraction(0, 1)
          >>> Fraction('3/7')
          Fraction(3, 7)
          >>> Fraction(' -3/7 ')
          Fraction(-3, 7)
          >>> Fraction('1.414213 \t\n')
          Fraction(1414213, 1000000)
          >>> Fraction('-.125')
          Fraction(-1, 8)
          >>> Fraction('7e-6')
          Fraction(7, 1000000)
          >>> Fraction(2.25)
          Fraction(9, 4)
          >>> Fraction(1.1)
          Fraction(2476979795053773, 2251799813685248)
          >>> from decimal import Decimal
          >>> Fraction(Decimal('1.1'))
          Fraction(11, 10)

     *note Fraction: 1c8. クラスは抽象基底クラス *note numbers.Rational:
     1290. を継承し、その全てのメソッドと演算を実装します。 *note
     Fraction: 1c8. インスタンスは *note ハッシュ可能: 5db. で、不変
     (immutable) であるものとして扱われます。加えて、 *note Fraction:
     1c8. には以下のプロパティとメソッドがあります:

     バージョン 3.2 で変更: *note Fraction: 1c8. のコンストラクタが
     *note float: 2ce. および *note decimal.Decimal: 27d. インスタンスを
     受け付けるようになりました。

     バージョン 3.9 で変更: The *note math.gcd(): 8de. function is now
     used to normalize the 'numerator' and 'denominator'.  *note
     math.gcd(): 8de. always returns an *note int: 238. type.
     Previously, the GCD type depended on 'numerator' and 'denominator'.

     バージョン 3.11 で変更: Underscores are now permitted when creating
     a *note Fraction: 1c8. instance from a string, following PEP 515(2)
     rules.

     バージョン 3.11 で変更: *note Fraction: 1c8. implements ‘__int__’
     now to satisfy ‘typing.SupportsInt’ instance checks.

     バージョン 3.12 で変更: Space is allowed around the slash for
     string inputs: ‘Fraction('2 / 3')’.

     バージョン 3.12 で変更: *note Fraction: 1c8. instances now support
     float-style formatting, with presentation types ‘"e"’, ‘"E"’,
     ‘"f"’, ‘"F"’, ‘"g"’, ‘"G"’ and ‘"%""’.

     バージョン 3.13 で変更: Formatting of *note Fraction: 1c8.
     instances without a presentation type now supports fill, alignment,
     sign handling, minimum width and grouping.

      -- の属性: numerator

          有理数を既約分数で表したときの分子。

      -- の属性: denominator

          有理数を既約分数で表したときの分母。

      -- メソッド: as_integer_ratio ()

          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.

          Added in version 3.8.

      -- メソッド: is_integer ()

          Return ‘True’ if the Fraction is an integer.

          Added in version 3.12.

      -- メソッド: classmethod from_float (flt)

          Alternative constructor which only accepts instances of *note
          float: 2ce. or *note numbers.Integral: 1f1d.  Beware that
          ‘Fraction.from_float(0.3)’ is not the same value as
          ‘Fraction(3, 10)’.

               注釈: Python 3.2 以降では、 *note float: 2ce. から直接
               *note Fraction: 1c8. インスタンスを構築できるようになりま
               した。

      -- メソッド: classmethod from_decimal (dec)

          Alternative constructor which only accepts instances of *note
          decimal.Decimal: 27d. or *note numbers.Integral: 1f1d.

               注釈: Python 3.2 以降では、 *note decimal.Decimal: 27d. イ
               ンスタンスから直接 *note Fraction: 1c8. インスタンスを構
               築できるようになりました。

      -- メソッド: limit_denominator (max_denominator=1000000)

          分母が高々 max_denominator である、 ‘self’ に最も近い *note
          Fraction: 1c8. を見付けて返します。このメソッドは与えられた浮
          動小数点数の有理数近似を見つけるのに役立ちます:

               >>> from fractions import Fraction
               >>> Fraction('3.1415926535897932').limit_denominator(1000)
               Fraction(355, 113)

          あるいは float で表された有理数を元に戻すのにも使えます:

               >>> from math import pi, cos
               >>> Fraction(cos(pi/3))
               Fraction(4503599627370497, 9007199254740992)
               >>> Fraction(cos(pi/3)).limit_denominator()
               Fraction(1, 2)
               >>> Fraction(1.1).limit_denominator()
               Fraction(11, 10)

      -- メソッド: __floor__ ()

          最大の *note int: 238. ‘<= self’ を返します。このメソッドは
          *note math.floor(): 1369. 関数からでもアクセスできます:

               >>> from math import floor
               >>> floor(Fraction(355, 113))
               3

      -- メソッド: __ceil__ ()

          最小の *note int: 238. ‘>= self’ を返します。このメソッドは
          *note math.ceil(): 136a. 関数からでもアクセスできます。

      -- メソッド: __round__ ()

      -- メソッド: __round__ (ndigits)

          第一のバージョンは、 ‘self’ に最も近い *note int: 238. を偶数
          丸めで返します。第二のバージョンは、このメソッドは ‘self’ に最
          も近い ‘Fraction(1, 10**ndigits)’ の倍数 (論理的に、 ‘ndigits’
          が負なら) を、これも偶数丸めで丸めます。 *note round(): 12a8.
          関数からでもアクセスできます。

      -- メソッド: __format__ (format_spec, /)

          Provides support for formatting of *note Fraction: 1c8.
          instances via the *note str.format(): 5ed. method, the *note
          format(): 5eb. built-in function, or *note Formatted string
          literals: 977.

          If the ‘format_spec’ format specification string does not end
          with one of the presentation types ‘'e'’, ‘'E'’, ‘'f'’, ‘'F'’,
          ‘'g'’, ‘'G'’ or ‘'%'’ then formatting follows the general
          rules for fill, alignment, sign handling, minimum width, and
          grouping as described in the *note format specification
          mini-language: 1c9.  The "alternate form" flag ‘'#'’ is
          supported: if present, it forces the output string to always
          include an explicit denominator, even when the value being
          formatted is an exact integer.  The zero-fill flag ‘'0'’ is
          not supported.

          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 *note float: 2ce. type in the *note 書式指定ミニ言語仕様:
          1c9. section.

          ここに例があります:

               >>> from fractions import Fraction
               >>> format(Fraction(103993, 33102), '_')
               '103_993/33_102'
               >>> format(Fraction(1, 7), '.^+10')
               '...+1/7...'
               >>> format(Fraction(3, 1), '')
               '3'
               >>> format(Fraction(3, 1), '#')
               '3/1'
               >>> format(Fraction(1, 7), '.40g')
               '0.1428571428571428571428571428571428571429'
               >>> format(Fraction('1234567.855'), '_.2f')
               '1_234_567.86'
               >>> f"{Fraction(355, 113):*>20.6e}"
               '********3.141593e+00'
               >>> old_price, new_price = 499, 672
               >>> "{:.2%} price increase".format(Fraction(new_price, old_price) - 1)
               '34.67% price increase'

参考
....

*note numbers: 8e. モジュール

     数値の塔を作り上げる抽象基底クラス。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/fractions.py

   (2) https://peps.python.org/pep-0515/


File: python.info,  Node: random --- 疑似乱数を生成する,  Next: statistics --- 数学的統計関数,  Prev: fractions --- 有理数,  Up: 数値と数学モジュール

5.9.6 ‘random’ -- 疑似乱数を生成する
------------------------------------

'ソースコード:' Lib/random.py(1)

__________________________________________________________________

このモジュールでは様々な分布をもつ擬似乱数生成器を実装しています。

整数用に、ある範囲からの一様な選択があります。シーケンス用には、シーケン
スからのランダムな要素の一様な選択、リストのランダムな置換をインプレース
に生成する関数、順列を置換せずにランダムサンプリングする関数があります。

実数用としては、一様分布、正規分布 (ガウス分布)、対数正規分布、負の指数
分布、ガンマおよびベータ分布を計算する関数があります。角度の分布を生成す
るにはフォン・ミーゼス分布が利用できます。

ほとんど全てのモジュール関数は、基礎となる関数 *note random(): 713. に依
存します。この関数はランダムな浮動小数点数を半開区間 ‘0.0 <= X < 1.0’ 内
に一様に生成します。Python は中心となる乱数生成器としてメルセンヌツイス
タを使います。これは 53 ビット精度の浮動小数点を生成し、周期は
2**19937-1 です。本体は C で実装されていて、高速でスレッドセーフです。メ
ルセンヌツイスタは、現存する中で最も広範囲にテストされた乱数生成器のひと
つです。しかしながら、メルセンヌツイスタは完全に決定論的であるため、全て
の目的に合致しているわけではなく、暗号化の目的には全く向いていません。

このモジュールで提供されている関数は、実際には *note random.Random:
1812. クラスの隠蔽されたインスタンスのメソッドに束縛されています。内部状
態を共有しない生成器を取得するため、自分で *note Random: 1812. のインス
タンスを生成することができます。

Class *note Random: 1812. can also be subclassed if you want to use a
different basic generator of your own devising: see the documentation on
that class for more details.

*note random: a6. モジュールは *note SystemRandom: 2630. クラスも提供し
ていて、このクラスは OS が提供している乱数発生源を利用して乱数を生成する
システム関数 *note os.urandom(): 4ec. を使うものです。

     警告: このモジュールの擬似乱数生成器をセキュリティ目的に使用しては
     いけません。セキュリティや暗号学的な用途については *note secrets:
     ae. モジュールを参照してください。

参考
....

M. Matsumoto and T. Nishimura, "Mersenne Twister: A 623-dimensionally
equidistributed uniform pseudorandom number generator", ACM Transactions
on Modeling and Computer Simulation Vol.  8, No.  1, January pp.3-30
1998.

Complementary-Multiply-with-Carry recipe(2) 長い周期と比較的シンプルな更
新操作を備えた互換性のある別の乱数生成器。

     注釈: The global random number generator and instances of *note
     Random: 1812. are thread-safe.  However, in the free-threaded
     build, concurrent calls to the global generator or to the same
     instance of *note Random: 1812. may encounter contention and poor
     performance.  Consider using separate instances of *note Random:
     1812. per thread instead.

* Menu:

* 保守 (bookkeeping) 関数: 保守 bookkeeping 関数.
* バイト列用の関数::
* 整数用の関数::
* シーケンス用の関数::
* Discrete distributions::
* 実数分布::
* 他の生成器::
* 再現性について::
* 使用例: 使用例<7>.
* レシピ: レシピ<2>.
* コマンドラインでの使用::
* コマンドラインの例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/random.py

   (2) 
https://code.activestate.com/recipes/576707-long-period-random-number-generator/


File: python.info,  Node: 保守 bookkeeping 関数,  Next: バイト列用の関数,  Up: random --- 疑似乱数を生成する

5.9.6.1 保守 (bookkeeping) 関数
...............................

 -- の関数: random.seed (a=None, version=2)

     乱数生成器を初期化します。

     'a' が省略されるか ‘None’ の場合、現在のシステム時刻が使用されます
     。乱数のソースがオペレーティングシステムによって提供される場合、シ
     ステム時刻の代わりにそれが使用されます (利用可能性についての詳細は
     *note os.urandom(): 4ec. 関数を参照)。

     'a' が int の場合、それが直接使われます。

     バージョン2 (デフォルト) では、 *note str: 418, *note bytes: 1a4,
     *note bytearray: 508. オブジェクトは *note int: 238. に変換され、そ
     のビットがすべて使用されます。

     バージョン1 (Python の古いバージョンでの乱数列を再現するために提供
     される) では、 *note str: 418. と *note bytes: 1a4. に対して適用さ
     れるアルゴリズムは、より狭い範囲のシードを生成します。

     バージョン 3.2 で変更: 文字列シードのすべてのビットを使うバージョン
     2スキームに移行。

     バージョン 3.11 で変更: 'seed' は次の型の内のいずれかでなければなり
     ません: ‘None’、*note int: 238.、*note float: 2ce.、*note str:
     418.、*note bytes: 1a4.、*note bytearray: 508.。

 -- の関数: random.getstate ()

     乱数生成器の現在の内部状態を記憶したオブジェクトを返します。このオ
     ブジェクトを *note setstate(): 2633. に渡して内部状態を復元すること
     ができます。

 -- の関数: random.setstate (state)

     'state' は予め *note getstate(): 2632. を呼び出して得ておかなくては
     なりません。 *note setstate(): 2633. は *note getstate(): 2632. が
     呼び出された時の乱数生成器の内部状態を復元します。


File: python.info,  Node: バイト列用の関数,  Next: 整数用の関数,  Prev: 保守 bookkeeping 関数,  Up: random --- 疑似乱数を生成する

5.9.6.2 バイト列用の関数
........................

 -- の関数: random.randbytes (n)

     'n' バイトのランダムなバイト列を生成します。

     セキュリティトークンを生成する目的で、このメソッドを使用しないでく
     ださい。代わりに *note secrets.token_bytes(): 2635. を使用してくだ
     さい。

     Added in version 3.9.


File: python.info,  Node: 整数用の関数,  Next: シーケンス用の関数,  Prev: バイト列用の関数,  Up: random --- 疑似乱数を生成する

5.9.6.3 整数用の関数
....................

 -- の関数: random.randrange (stop)

 -- の関数: random.randrange (start, stop[, step])

     ‘range(start, stop, step)’ の要素からランダムに選ばれた要素を返しま
     す。

     This is roughly equivalent to ‘choice(range(start, stop, step))’
     but supports arbitrarily large ranges and is optimized for common
     cases.

     位置引数のパターンは *note range(): 911. 関数の引数と一致します。

     Keyword arguments should not be used because they can be
     interpreted in unexpected ways.  For example ‘randrange(start=100)’
     is interpreted as ‘randrange(0, 100, 1)’.

     バージョン 3.2 で変更: 一様に分布した値の生成に関して *note
     randrange(): 837. がより洗練されました。以前は ‘int(random()*n)’ の
     ようなやや一様でない分布を生成するスタイルを使用していました。

     バージョン 3.12 で変更: 整数以外の型の自動変換はサポートされなくな
     りました。‘randrange(10.0)’ や ‘randrange(Fraction(10, 1))’ のよう
     な呼び出しは *note TypeError: 502. を送出します。

 -- の関数: random.randint (a, b)

     ‘a <= N <= b’ であるようなランダムな整数 'N' を返します。
     ‘randrange(a, b+1)’ のエイリアスです。

 -- の関数: random.getrandbits (k)

     'k' 桁の乱数ビットを持つ Python の整数を生成し、返します。このメソ
     ッドはメルセンヌツイスタ生成器で提供されており、その他の乱数生成器
     でもオプションの API として提供されている場合があります。*note
     getrandbits(): fd8. が使用可能な場合、*note randrange(): 837. は任
     意の範囲の乱数を生成できるようになります。

     バージョン 3.9 で変更: 'k' の値として 0 が許されるようになりました
     。


File: python.info,  Node: シーケンス用の関数,  Next: Discrete distributions,  Prev: 整数用の関数,  Up: random --- 疑似乱数を生成する

5.9.6.4 シーケンス用の関数
..........................

 -- の関数: random.choice (seq)

     空でないシーケンス 'seq' からランダムに要素を返します。 'seq' が空
     のときは、 *note IndexError: 14de. が送出されます。

 -- の関数: random.choices (population, weights=None, *,
          cum_weights=None, k=1)

     'population' から重複ありで選んだ要素からなる大きさ 'k' のリストを
     返します。'population' が空の場合 *note IndexError: 14de. を送出し
     ます。

     'weights' シーケンスが与えられた場合、相対的な重みに基づいて要素が
     選ばれます。あるいは、'cum_weights' シーケンスが与えられた場合、累
     積的な重み (*note itertools.accumulate(): 9cb. を用いて計算されるか
     もしれません) で要素が選ばれます。例えば、相対的な重み ‘[10, 5, 30,
     5]’ は累積的な重み ‘[10, 15, 45, 50]’ と等価です。内部的には、相対
     的な重みは要素選択の前に累積的な重みに変換されるため、累積的な重み
     を渡すと手間を省けます。

     'weights' および 'cum_weights' が与えられなかった場合、要素は同じ確
     率で選択されます。重みのシーケンスが与えられた場合、その長さは
     'population' シーケンスと同じでなければなりません。'weights' と
     'cum_weights' を同時に与えると *note TypeError: 502. が送出されます
     。

     'weights' や 'cum_weights' には *note random(): a6. が返す *note
     float: 2ce. 値と相互に変換できるような、任意の数値型を使用できます
     (int、float、fraction を含みますが、decimal は除きます)。重みには非
     負で有限の値を指定することが規定されます。全ての重みが 0 の場合、例
     外 *note ValueError: 1e3. が送出されます。

     与えられた種に対して、同じ重みを持つ *note choices(): c94. 関数は、
     一般に *note choice(): 1201. を繰り返し呼び出す場合とは異なるシーケ
     ンスを生成します。 *note choices(): c94. で使用されるアルゴリズムは
     、内部の一貫性とスピードのために浮動小数点演算を使用します。 *note
     choice(): 1201. で使われるアルゴリズムは、丸め誤差による小さな偏り
     を避けるために、デフォルトでは選択を繰り返す整数演算になっています
     。

     Added in version 3.6.

     バージョン 3.9 で変更: 全ての重みが 0 の場合、例外 *note
     ValueError: 1e3. を送出します。

 -- の関数: random.shuffle (x)

     シーケンス 'x' をインプレースにシャッフルします。

     イミュータブルなシーケンスをシャッフルしてシャッフルされたリストを
     新たに返すには、代わりに ‘sample(x, k=len(x))’ を使用してください。

     たとえ ‘len(x)’ が小さくても、'x' の並べ替えの総数 (訳注: 要素数の
     階乗) は大半の乱数生成器の周期よりもすぐに大きくなることに注意して
     ください。つまり、長いシーケンスの大半の並べ替えは決して生成されな
     いだろう、ということです。例えば、長さ 2080 のシーケンスがメルセン
     ヌツイスタ生成器の周期に収まる中で最大のものになります。

     バージョン 3.11 で変更: オプション引数 'random' が削除されました。

 -- の関数: random.sample (population, k, *, counts=None)

     母集団のシーケンスから選ばれた長さ 'k' の一意な要素からなるリストを
     返します。値の置換を行わないランダムサンプリングに用いられます。

     母集団自体を変更せずに、母集団内の要素を含む新たなリストを返します
     。返されたリストは選択された順に並んでいるので、このリストの部分ス
     ライスもランダムなサンプルになります。これにより、くじの当選者 (サ
     ンプル) を1等賞と2等賞（の部分スライス）に分けることも可能です。

     母集団の要素は *note ハッシュ可能: 5db. でなくても、ユニークでなく
     てもかまいません。母集団が繰り返しを含む場合、出現するそれぞれがサ
     ンプルに選択されえます。

     母集団に重複がある場合はその分だけ1つずつ指定するか、キーワード専用
     オプション引数 'counts' で指定することができます。例えば、
     ‘sample(['red', 'blue'], counts=[4, 2], k=5)’ は ‘sample(['red',
     'red', 'red', 'red', 'blue', 'blue'], k=5)’ と等価になります。

     ある範囲の整数からサンプルを取る場合、引数に *note range(): 911. オ
     ブジェクトを使用してください。大きな母集団の場合、これは特に速く、
     メモリ効率が良いです: ‘sample(range(10000000), k=60)’。

     サンプルの大きさが母集団の大きさより大きい場合 *note ValueError:
     1e3. が送出されます。

     バージョン 3.9 で変更: 'counts' 引数が追加されました。

     バージョン 3.11 で変更: The 'population' must be a sequence.
     Automatic conversion of sets to lists is no longer supported.


File: python.info,  Node: Discrete distributions,  Next: 実数分布,  Prev: シーケンス用の関数,  Up: random --- 疑似乱数を生成する

5.9.6.5 Discrete distributions
..............................

The following function generates a discrete distribution.

 -- の関数: random.binomialvariate (n=1, p=0.5)

     Binomial distribution(1).  Return the number of successes for 'n'
     independent trials with the probability of success in each trial
     being 'p':

     Mathematically equivalent to:

          sum(random() < p for i in range(n))

     The number of trials 'n' should be a non-negative integer.  The
     probability of success 'p' should be between ‘0.0 <= p <= 1.0’.
     The result is an integer in the range ‘0 <= X <= n’.

     Added in version 3.12.

   ---------- Footnotes ----------

   (1) https://mathworld.wolfram.com/BinomialDistribution.html


File: python.info,  Node: 実数分布,  Next: 他の生成器,  Prev: Discrete distributions,  Up: random --- 疑似乱数を生成する

5.9.6.6 実数分布
................

以下の関数は特定の実数値分布を生成します。関数の引数の名前は、一般的な数
学の慣例で使われている分布の公式の対応する変数から取られています; これら
の公式のほとんどはどんな統計学のテキストにも載っています。

 -- の関数: random.random ()

     ランダムな浮動小数点数（範囲は ‘0.0 <= X < 1.0’）を返します。

 -- の関数: random.uniform (a, b)

     ‘a <= b’ であれば ‘a <= N <= b’ 、‘b < a’ であれば ‘b <= N <= a’ で
     あるようなランダムな浮動小数点数 'N' を返します。

     端点の値 ‘b’ が範囲に含まれるかどうかは、式 ‘a + (b-a) * random()’
     における浮動小数点の丸めに依存します。

 -- の関数: random.triangular (low, high, mode)

     ‘low <= N <= high’ でありこれら境界値の間に指定された最頻値 'mode'
     を持つようなランダムな浮動小数点数 'N' を返します。境界 'low' と
     'high' のデフォルトは 0 と 1 です。最頻値 'mode' 引数のデフォルトは
     両境界値の中点になり、対称な分布を与えます。

 -- の関数: random.betavariate (alpha, beta)

     ベータ分布です。引数の満たすべき条件は ‘alpha > 0’ および ‘beta >
     0’ です。 0 から 1 の範囲の値を返します。

 -- の関数: random.expovariate (lambd=1.0)

     指数分布です。'lambd' は平均にしたい値の逆数です。(この引数は
     "lambda" と呼ぶべきなのですが、Python の予約語なので使えません。) 返
     す値の範囲は 'lambd' が正なら 0 から正の無限大、'lambd' が負なら負
     の無限大から 0 です。

     バージョン 3.12 で変更: ‘lambd’ にデフォルト値を追加しました。

 -- の関数: random.gammavariate (alpha, beta)

     Gamma distribution.  ('Not' the gamma function!)  The shape and
     scale parameters, 'alpha' and 'beta', must have positive values.
     (Calling conventions vary and some sources define 'beta' as the
     inverse of the scale).

     確率分布関数は:

                    x ** (alpha - 1) * math.exp(-x / beta)
          pdf(x) =  --------------------------------------
                      math.gamma(alpha) * beta ** alpha

 -- の関数: random.gauss (mu=0.0, sigma=1.0)

     正規分布、またはガウス分布と呼ばれます。 'mu' は平均であり、
     'sigma' は標準偏差です。この関数は後で定義する関数 *note
     normalvariate(): 17ad. より少しだけ高速です。

     Multithreading note: When two threads call this function
     simultaneously, it is possible that they will receive the same
     return value.  This can be avoided in three ways.  1) Have each
     thread use a different instance of the random number generator.  2)
     Put locks around all calls.  3) Use the slower, but thread-safe
     *note normalvariate(): 17ad. function instead.

     バージョン 3.11 で変更: 'mu' と 'sigma' にデフォルト値を追加しまし
     た。

 -- の関数: random.lognormvariate (mu, sigma)

     対数正規分布です。この分布を自然対数を用いた分布にした場合、平均
     'mu' で標準偏差 'sigma' の正規分布になります。 'mu' は任意の値を取
     ることができ、'sigma' はゼロより大きくなければなりません。

 -- の関数: random.normalvariate (mu=0.0, sigma=1.0)

     正規分布です。 'mu' は平均で、 'sigma' は標準偏差です。

     バージョン 3.11 で変更: 'mu' と 'sigma' にデフォルト値を追加しまし
     た。

 -- の関数: random.vonmisesvariate (mu, kappa)

     'mu' は平均の角度で、0 から 2*'pi' までのラジアンで表されます。
     'kappa' は濃度パラメータで、ゼロ以上でなければなりません。'kappa' が
     ゼロに等しい場合、この分布は範囲 0 から 2*'pi' の一様でランダムな角
     度の分布に退化します。

 -- の関数: random.paretovariate (alpha)

     パレート分布です。 'alpha' は形状パラメータです。

 -- の関数: random.weibullvariate (alpha, beta)

     ワイブル分布です。 'alpha' は尺度パラメタで、 'beta' は形状パラメー
     タです。


File: python.info,  Node: 他の生成器,  Next: 再現性について,  Prev: 実数分布,  Up: random --- 疑似乱数を生成する

5.9.6.7 他の生成器
..................

 -- クラス: random.Random ([seed])

     *note random: a6. モジュールがデフォルトで使用する疑似乱数生成器を
     実装したクラスです。

     バージョン 3.11 で変更: 以前は 'seed' は任意のハッシュ可能オブジェ
     クトが設定可能でした。現在は ‘None’, *note int: 238, *note float:
     2ce, *note str: 418, *note bytes: 1a4, *note bytearray: 508. に制限
     されています。

     Subclasses of ‘Random’ should override the following methods if
     they wish to make use of a different basic generator:

      -- メソッド: seed (a=None, version=2)

          Override this method in subclasses to customise the *note
          seed(): 1245. behaviour of ‘Random’ instances.

      -- メソッド: getstate ()

          Override this method in subclasses to customise the *note
          getstate(): 2632. behaviour of ‘Random’ instances.

      -- メソッド: setstate (state)

          Override this method in subclasses to customise the *note
          setstate(): 2633. behaviour of ‘Random’ instances.

      -- メソッド: random ()

          Override this method in subclasses to customise the *note
          random(): 713. behaviour of ‘Random’ instances.

     Optionally, a custom generator subclass can also supply the
     following method:

      -- メソッド: getrandbits (k)

          Override this method in subclasses to customise the *note
          getrandbits(): fd8. behaviour of ‘Random’ instances.

 -- クラス: random.SystemRandom ([seed])

     オペレーティングシステムの提供する発生源によって乱数を生成する
     *note os.urandom(): 4ec. 関数を使うクラスです。すべてのシステムで使
     えるメソッドではありません。ソフトウェアの状態に依存してはいけませ
     んし、一連の操作は再現不能です。従って、 *note seed(): 1245. メソッ
     ドは何の影響も及ぼさず、無視されます。 *note getstate(): 2632. と
     *note setstate(): 2633. メソッドが呼び出されると、例外 *note
     NotImplementedError: 209. が送出されます。


File: python.info,  Node: 再現性について,  Next: 使用例<7>,  Prev: 他の生成器,  Up: random --- 疑似乱数を生成する

5.9.6.8 再現性について
......................

疑似乱数生成器から与えられたシーケンスを再現できると便利なことがあります
。シード値を再利用することで、複数のスレッドが実行されていない限り、実行
ごとに同じシーケンスが再現できます。

random モジュールのアルゴリズムやシード処理関数のほとんどは、Python バー
ジョン間で変更される対象となりますが、次の二点は変更されないことが保証さ
れています:

   * 新しいシード処理メソッドが追加されたら、後方互換なシード処理器が提
     供されます。

   * 生成器の *note random(): 2646. メソッドは、互換なシード処理器に同じ
     シードが与えられた場合、引き続き同じシーケンスを生成します。


File: python.info,  Node: 使用例<7>,  Next: レシピ<2>,  Prev: 再現性について,  Up: random --- 疑似乱数を生成する

5.9.6.9 使用例
..............

基礎的な例:

     >>> random()                          # Random float:  0.0 <= x < 1.0
     0.37444887175646646

     >>> uniform(2.5, 10.0)                # Random float:  2.5 <= x <= 10.0
     3.1800146073117523

     >>> expovariate(1 / 5)                # Interval between arrivals averaging 5 seconds
     5.148957571865031

     >>> randrange(10)                     # Integer from 0 to 9 inclusive
     7

     >>> randrange(0, 101, 2)              # Even integer from 0 to 100 inclusive
     26

     >>> choice(['win', 'lose', 'draw'])   # Single random element from a sequence
     'draw'

     >>> deck = 'ace two three four'.split()
     >>> shuffle(deck)                     # Shuffle a list
     >>> deck
     ['four', 'two', 'ace', 'three']

     >>> sample([10, 20, 30, 40, 50], k=4) # Four samples without replacement
     [40, 10, 50, 30]

シミュレーション:

     >>> # Six roulette wheel spins (weighted sampling with replacement)
     >>> choices(['red', 'black', 'green'], [18, 18, 2], k=6)
     ['red', 'green', 'black', 'black', 'red', 'black']

     >>> # Deal 20 cards without replacement from a deck
     >>> # of 52 playing cards, and determine the proportion of cards
     >>> # with a ten-value:  ten, jack, queen, or king.
     >>> deal = sample(['tens', 'low cards'], counts=[16, 36], k=20)
     >>> deal.count('tens') / 20
     0.15

     >>> # Estimate the probability of getting 5 or more heads from 7 spins
     >>> # of a biased coin that settles on heads 60% of the time.
     >>> sum(binomialvariate(n=7, p=0.6) >= 5 for i in range(10_000)) / 10_000
     0.4169

     >>> # Probability of the median of 5 samples being in middle two quartiles
     >>> def trial():
     ...     return 2_500 <= sorted(choices(range(10_000), k=5))[2] < 7_500
     ...
     >>> sum(trial() for i in range(10_000)) / 10_000
     0.7958

サンプルの平均の信頼区間を推定するのに、重複ありでリサンプリングして 統
計的ブートストラップ(1) を行う例:

     # https://www.thoughtco.com/example-of-bootstrapping-3126155
     from statistics import fmean as mean
     from random import choices

     data = [41, 50, 29, 37, 81, 30, 73, 63, 20, 35, 68, 22, 60, 31, 95]
     means = sorted(mean(choices(data, k=len(data))) for i in range(100))
     print(f'The sample mean of {mean(data):.1f} has a 90% confidence '
           f'interval from {means[5]:.1f} to {means[94]:.1f}')

薬と偽薬の間に観察された効果の違いについて、統計的有意性、すなわち p 値
(2) を決定するために、リサンプリング順列試験(3) を行う例:

     # Example from "Statistics is Easy" by Dennis Shasha and Manda Wilson
     from statistics import fmean as mean
     from random import shuffle

     drug = [54, 73, 53, 70, 73, 68, 52, 65, 65]
     placebo = [54, 51, 58, 44, 55, 52, 42, 47, 58, 46]
     observed_diff = mean(drug) - mean(placebo)

     n = 10_000
     count = 0
     combined = drug + placebo
     for i in range(n):
         shuffle(combined)
         new_diff = mean(combined[:len(drug)]) - mean(combined[len(drug):])
         count += (new_diff >= observed_diff)

     print(f'{n} label reshufflings produced only {count} instances with a difference')
     print(f'at least as extreme as the observed difference of {observed_diff:.1f}.')
     print(f'The one-sided p-value of {count / n:.4f} leads us to reject the null')
     print(f'hypothesis that there is no difference between the drug and the placebo.')

マルチサーバーキューにおける到達時間とサービス提供のシミュレーション:

     from heapq import heapify, heapreplace
     from random import expovariate, gauss
     from statistics import mean, quantiles

     average_arrival_interval = 5.6
     average_service_time = 15.0
     stdev_service_time = 3.5
     num_servers = 3

     waits = []
     arrival_time = 0.0
     servers = [0.0] * num_servers  # time when each server becomes available
     heapify(servers)
     for i in range(1_000_000):
         arrival_time += expovariate(1.0 / average_arrival_interval)
         next_server_available = servers[0]
         wait = max(0.0, next_server_available - arrival_time)
         waits.append(wait)
         service_duration = max(0.0, gauss(average_service_time, stdev_service_time))
         service_completed = arrival_time + wait + service_duration
         heapreplace(servers, service_completed)

     print(f'Mean wait: {mean(waits):.1f}   Max wait: {max(waits):.1f}')
     print('Quartiles:', [round(q, 1) for q in quantiles(waits)])

参考
....

Statistics for Hackers(4) Jake Vanderplas(5) による統計解析のビデオ。シ
ミュレーション、サンプリング、シャッフル、交差検定といった基本的な概念の
みを用いています。

Economics Simulation(6) Peter Norvig(7) による市場価格のシミュレーション
。このモジュールが提供する多くのツールや分布 (gauss, uniform, sample,
betavariate, choice, triangular, randrange) の活用法を示しています。

A Concrete Introduction to Probability (using Python)(8) Peter Norvig(9)
によるチュートリアル。確率論の基礎、シミュレーションの書き方、Python を
使用したデータ解析法をカバーしています。

   ---------- Footnotes ----------

   (1) 
https://ja.wikipedia.org/wiki/%E3%83%96%E3%83%BC%E3%83%88%E3%82%B9%E3%83%88%E3%83%A9%E3%83%83%E3%83%97%E6%B3%95

   (2) https://en.wikipedia.org/wiki/P-value

   (3) 
https://en.wikipedia.org/wiki/Resampling_(statistics)#Permutation_tests

   (4) https://www.youtube.com/watch?v=Iq9DzN6mvYA

   (5) https://us.pycon.org/2016/speaker/profile/295/

   (6) https://nbviewer.org/url/norvig.com/ipython/Economics.ipynb

   (7) https://norvig.com/bio.html

   (8) https://nbviewer.org/url/norvig.com/ipython/Probability.ipynb

   (9) https://norvig.com/bio.html


File: python.info,  Node: レシピ<2>,  Next: コマンドラインでの使用,  Prev: 使用例<7>,  Up: random --- 疑似乱数を生成する

5.9.6.10 レシピ
...............

These recipes show how to efficiently make random selections from the
combinatoric iterators in the *note itertools: 75. module:

     def random_product(*args, repeat=1):
         "Random selection from itertools.product(*args, **kwds)"
         pools = [tuple(pool) for pool in args] * repeat
         return tuple(map(random.choice, pools))

     def random_permutation(iterable, r=None):
         "Random selection from itertools.permutations(iterable, r)"
         pool = tuple(iterable)
         r = len(pool) if r is None else r
         return tuple(random.sample(pool, r))

     def random_combination(iterable, r):
         "Random selection from itertools.combinations(iterable, r)"
         pool = tuple(iterable)
         n = len(pool)
         indices = sorted(random.sample(range(n), r))
         return tuple(pool[i] for i in indices)

     def random_combination_with_replacement(iterable, r):
         "Choose r elements with replacement.  Order the result to match the iterable."
         # Result will be in set(itertools.combinations_with_replacement(iterable, r)).
         pool = tuple(iterable)
         n = len(pool)
         indices = sorted(random.choices(range(n), k=r))
         return tuple(pool[i] for i in indices)

The default *note random(): 713. returns multiples of 2⁻⁵³ in the range
'0.0 ≤ x < 1.0'.  All such numbers are evenly spaced and are exactly
representable as Python floats.  However, many other representable
floats in that interval are not possible selections.  For example,
‘0.05954861408025609’ isn't an integer multiple of 2⁻⁵³.

The following recipe takes a different approach.  All floats in the
interval are possible selections.  The mantissa comes from a uniform
distribution of integers in the range '2⁵² ≤ mantissa < 2⁵³'.  The
exponent comes from a geometric distribution where exponents smaller
than '-53' occur half as often as the next larger exponent.

     from random import Random
     from math import ldexp

     class FullRandom(Random):

         def random(self):
             mantissa = 0x10_0000_0000_0000 | self.getrandbits(52)
             exponent = -53
             x = 0
             while not x:
                 x = self.getrandbits(32)
                 exponent += x.bit_length() - 32
             return ldexp(mantissa, exponent)

All *note real valued distributions: 263a. in the class will use the new
method:

     >>> fr = FullRandom()
     >>> fr.random()
     0.05954861408025609
     >>> fr.expovariate(0.25)
     8.87925541791544

The recipe is conceptually equivalent to an algorithm that chooses from
all the multiples of 2⁻¹⁰⁷⁴ in the range '0.0 ≤ x < 1.0'.  All such
numbers are evenly spaced, but most have to be rounded down to the
nearest representable Python float.  (The value 2⁻¹⁰⁷⁴ is the smallest
positive unnormalized float and is equal to ‘math.ulp(0.0)’.)

参考
....

Generating Pseudo-random Floating-Point Values(1) a paper by Allen B.
Downey describing ways to generate more fine-grained floats than
normally generated by *note random(): 713.

   ---------- Footnotes ----------

   (1) https://allendowney.com/research/rand/downey07randfloat.pdf


File: python.info,  Node: コマンドラインでの使用,  Next: コマンドラインの例,  Prev: レシピ<2>,  Up: random --- 疑似乱数を生成する

5.9.6.11 コマンドラインでの使用
...............................

Added in version 3.13.

‘random’ モジュールはコマンドラインから実行できます。

     python -m random [-h] [-c CHOICE [CHOICE ...] | -i N | -f N] [input ...]

以下のオプションが使用できます:

 -- Option: -h, --help

     ヘルプメッセージを表示して終了します。

 -- Option: -c CHOICE [CHOICE ...]
 -- Option: --choice CHOICE [CHOICE ...]

     *note choice(): 1201. を使用してランダムに選択して出力します。

 -- Option: -i <N>
 -- Option: --integer <N>

     *note randint(): 1200. を使用して1からNの間(Nを含む)のランダムな整
     数を出力します。

 -- Option: -f <N>
 -- Option: --float <N>

     Print a random floating-point number between 0 and N inclusive,
     using *note uniform(): 263b.

オプションが指定されない場合、出力は入力に依存します。

   * 文字列または複数: *note -choice: 264f. と同じ。

   * 整数: *note -integer: 2651. と同じ。

   * 浮動小数点数: *note -float: 2653. と同じ。


File: python.info,  Node: コマンドラインの例,  Prev: コマンドラインでの使用,  Up: random --- 疑似乱数を生成する

5.9.6.12 コマンドラインの例
...........................

以下は ‘random’ のコマンドラインインターフェースの例です:

     $ # Choose one at random
     $ python -m random egg bacon sausage spam "Lobster Thermidor aux crevettes with a Mornay sauce"
     Lobster Thermidor aux crevettes with a Mornay sauce

     $ # Random integer
     $ python -m random 6
     6

     $ # Random floating-point number
     $ python -m random 1.8
     1.7080016272295635

     $ # With explicit arguments
     $ python  -m random --choice egg bacon sausage spam "Lobster Thermidor aux crevettes with a Mornay sauce"
     egg

     $ python -m random --integer 6
     3

     $ python -m random --float 1.8
     1.5666339105010318

     $ python -m random --integer 6
     5

     $ python -m random --float 6
     3.1942323316565915


File: python.info,  Node: statistics --- 数学的統計関数,  Prev: random --- 疑似乱数を生成する,  Up: 数値と数学モジュール

5.9.7 ‘statistics’ -- 数学的統計関数
------------------------------------

Added in version 3.4.

'ソースコード:' Lib/statistics.py(1)

__________________________________________________________________

このモジュールは、数値 (*note Real: 20fb. 型) データを数学的に統計計算す
るための関数を提供します。

このモジュールは、 NumPy(2), SciPy(3) のような third-party ライブラリや
、Minitab、SAS、Matlab のようなプロ統計家向けのフル装備なプロプライエタ
リ統計パッケージと競合することを意図していません。グラフ関数電卓のレベル
を対象としています。

特に明記しない限り、これらの関数は *note int: 238, *note float: 2ce,
*note Decimal: 27d. そして *note Fraction: 1c8. をサポートします。他の型
(算術型及びそれ以外) は現在サポートされていません。型が混ざったコレクシ
ョンも未定義で実装依存です。入力データが複数の型からなる場合、*note
map(): 82f. を使用すると正しい結果が得られるでしょう。 例: ‘map(float,
input_data)’。

あるデータセットでは欠損値を表すために ‘NaN’ (not a number) を使います。
NaNは通常と異なる比較セマンティクスを持つため、ソートやカウントを行う統
計関数では、驚きや未定義の振る舞いを引き起こします。 影響を受ける関数は
‘median()’, ‘median_low()’, ‘median_high()’, ‘median_grouped()’,
‘mode()’, ‘multimode()’, そして ‘quantiles()’ です。 これらの関数を呼ぶ
前に、 ‘NaN’ 値を取り除く必要があります:

     >>> from statistics import median
     >>> from math import isnan
     >>> from itertools import filterfalse

     >>> data = [20.7, float('NaN'),19.2, 18.3, float('NaN'), 14.4]
     >>> sorted(data)  # This has surprising behavior
     [20.7, nan, 14.4, 18.3, 19.2, nan]
     >>> median(data)  # This result is unexpected
     16.35

     >>> sum(map(isnan, data))    # Number of missing values
     2
     >>> clean = list(filterfalse(isnan, data))  # Strip NaN values
     >>> clean
     [20.7, 19.2, 18.3, 14.4]
     >>> sorted(clean)  # Sorting now works as expected
     [14.4, 18.3, 19.2, 20.7]
     >>> median(clean)       # This result is now well defined
     18.75

* Menu:

* 平均及び中心位置の測度::
* 分散の測度::
* 2入力間の関係の統計::
* 関数の詳細::
* 例外: 例外<5>.
* NormalDist オブジェクト::
* 例とレシピ: 例とレシピ<2>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/statistics.py

   (2) https://numpy.org

   (3) https://scipy.org/


File: python.info,  Node: 平均及び中心位置の測度,  Next: 分散の測度,  Up: statistics --- 数学的統計関数

5.9.7.1 平均及び中心位置の測度
..............................

これらの関数は母集団または標本の平均値や標準値を計算します。

*note mean(): 69d.          データの算術平均 (いわゆる「平均」) 。
                            
                            
*note fmean(): a02.         Fast, floating-point arithmetic mean, with optional weighting.
                            
                            
*note geometric_mean(): a03.データの幾何平均。
                            
                            
*note harmonic_mean(): caf. データの調和平均。
                            
                            
*note kde(): 22b.           Estimate the probability density distribution of the data.
                            
                            
*note kde_random(): 22c.    Random sampling from the PDF generated by kde().
                            
                            
*note median(): 2659.       データのメジアン(中央値)。
                            
                            
*note median_low(): 265a.   データの low median。
                            
                            
*note median_high(): 265b.  データの high median。
                            
                            
*note median_grouped(): 265c.Median (50th percentile) of grouped data.
                            
                            
*note mode(): a60.          離散/名義尺度データの最頻値 (single mode) 。
                            
                            
*note multimode(): a04.     離散/名義尺度データの最頻値 (list of modes) 。
                            
                            
*note quantiles(): a05.     データの等確率での分割。
                            


File: python.info,  Node: 分散の測度,  Next: 2入力間の関係の統計,  Prev: 平均及び中心位置の測度,  Up: statistics --- 数学的統計関数

5.9.7.2 分散の測度
..................

これらの関数は母集団または標本が標準値や平均値からどれくらい離れているか
について計算します。

*note pstdev(): 265e.       データの母標準偏差。
                            
                            
*note pvariance(): 265f.    データの母分散。
                            
                            
*note stdev(): 69f.         データの標本標準偏差。
                            
                            
*note variance(): 69e.      データの標本標準分散。
                            


File: python.info,  Node: 2入力間の関係の統計,  Next: 関数の詳細,  Prev: 分散の測度,  Up: statistics --- 数学的統計関数

5.9.7.3 2入力間の関係の統計
...........................

これらの関数は、2つの入力間の関係について統計量を計算します。

*note covariance(): 7fb.      2変数の標本共分散。
                              
                              
*note correlation(): 488.     ピアソンとスピアマンの相関係数。
                              
                              
*note linear_regression(): 7fc.単回帰の傾きと切片。
                              


File: python.info,  Node: 関数の詳細,  Next: 例外<5>,  Prev: 2入力間の関係の統計,  Up: statistics --- 数学的統計関数

5.9.7.4 関数の詳細
..................

註釈: 関数の引数となるデータをソートしておく必要はありません。例の多くが
ソートされているのは見やすさのためです。

 -- の関数: statistics.mean (data)

     シーケンス型またはイテラブルになり得る 'data' の標本算術平均を返し
     ます。

     算術平均はデータの総和をデータ数で除したものです。単に「平均」と呼
     ばれることも多いですが、数学における平均の一種に過ぎません。データ
     の中心位置の測度の一つです。

     'data' が空の場合 *note StatisticsError: 2662. を送出します。

     使用例:

          >>> mean([1, 2, 3, 4, 4])
          2.8
          >>> mean([-1.0, 2.5, 3.25, 5.75])
          2.625

          >>> from fractions import Fraction as F
          >>> mean([F(3, 7), F(1, 21), F(5, 3), F(1, 3)])
          Fraction(13, 21)

          >>> from decimal import Decimal as D
          >>> mean([D("0.5"), D("0.75"), D("0.625"), D("0.375")])
          Decimal('0.5625')

          注釈: mean は 外れ値(1) (outliers(2)) の影響を強く受け、必ずし
          もデータ点の典型例とはなりません。効率が悪いものの、より堅牢な
          、 中心的な傾向 (central tendency(3)) の尺度については、 *note
          median(): 2659. を参照してください。

          標本平均は真の母平均の不偏推定量のため、出来る限り多くの標本か
          ら平均を求めると、‘mean(sample)’ は真の母平均に収束します (訳
          注: 大数の法則)。'data' が標本ではなく母集団全体の場合、
          ‘mean(data)’ は真の母平均 μ を計算することと等価です。

 -- の関数: statistics.fmean (data, weights=None)

     'data' を float に変換し、算術平均を計算します。

     This runs faster than the *note mean(): 69d. function and it always
     returns a *note float: 2ce.  The 'data' may be a sequence or
     iterable.  If the input dataset is empty, raises a *note
     StatisticsError: 2662.

          >>> fmean([3.5, 4.0, 5.25])
          4.25

     Optional weighting is supported.  For example, a professor assigns
     a grade for a course by weighting quizzes at 20%, homework at 20%,
     a midterm exam at 30%, and a final exam at 30%:

          >>> grades = [85, 92, 83, 91]
          >>> weights = [0.20, 0.20, 0.30, 0.30]
          >>> fmean(grades, weights)
          87.6

     If 'weights' is supplied, it must be the same length as the 'data'
     or a *note ValueError: 1e3. will be raised.

     Added in version 3.8.

     バージョン 3.11 で変更: 'weights' のサポートが追加されました。

 -- の関数: statistics.geometric_mean (data)

     Convert 'data' to floats and compute the geometric mean.

     The geometric mean indicates the central tendency or typical value
     of the 'data' using the product of the values (as opposed to the
     arithmetic mean which uses their sum).

     Raises a *note StatisticsError: 2662. if the input dataset is
     empty, if it contains a zero, or if it contains a negative value.
     The 'data' may be a sequence or iterable.

     No special efforts are made to achieve exact results.  (However,
     this may change in the future.)

          >>> round(geometric_mean([54, 24, 36]), 1)
          36.0

     Added in version 3.8.

 -- の関数: statistics.harmonic_mean (data, weights=None)

     Return the harmonic mean of 'data', a sequence or iterable of
     real-valued numbers.  If 'weights' is omitted or ‘None’, then equal
     weighting is assumed.

     調和平均（harmonic mean）は、データの逆数の算術平均 *note mean():
     69d. の逆数です。例えば、3つの値 'a', 'b', 'c' の調和平均は''3/(1/a
     + 1/b + 1/c)'' になります。いずれかの値が0の場合、結果は0になります
     。

     調和平均は平均の一種で、データの中心位置の測度です。速度のような比
     (ratios)や率(rates)を平均するときにしばしば適切です。

     Suppose a car travels 10 km at 40 km/hr, then another 10 km at 60
     km/hr.  What is the average speed?

          >>> harmonic_mean([40, 60])
          48.0

     Suppose a car travels 40 km/hr for 5 km, and when traffic clears,
     speeds-up to 60 km/hr for the remaining 30 km of the journey.  What
     is the average speed?

          >>> harmonic_mean([40, 60], weights=[5, 30])
          56.0

     *note StatisticsError: 2662. is raised if 'data' is empty, any
     element is less than zero, or if the weighted sum isn't positive.

     The current algorithm has an early-out when it encounters a zero in
     the input.  This means that the subsequent inputs are not tested
     for validity.  (This behavior may change in the future.)

     Added in version 3.6.

     バージョン 3.10 で変更: 'weights' のサポートが追加されました。

 -- の関数: statistics.kde (data, h, kernel='normal', *,
          cumulative=False)

     Kernel Density Estimation (KDE)(4): Create a continuous probability
     density function or cumulative distribution function from discrete
     samples.

     The basic idea is to smooth the data using a kernel function(5).
     to help draw inferences about a population from a sample.

     The degree of smoothing is controlled by the scaling parameter 'h'
     which is called the bandwidth.  Smaller values emphasize local
     features while larger values give smoother results.

     The 'kernel' determines the relative weights of the sample data
     points.  Generally, the choice of kernel shape does not matter as
     much as the more influential bandwidth smoothing parameter.

     Kernels that give some weight to every sample point include
     'normal' ('gauss'), 'logistic', and 'sigmoid'.

     Kernels that only give weight to sample points within the bandwidth
     include 'rectangular' ('uniform'), 'triangular', 'parabolic'
     ('epanechnikov'), 'quartic' ('biweight'), 'triweight', and
     'cosine'.

     If 'cumulative' is true, will return a cumulative distribution
     function.

     A *note StatisticsError: 2662. will be raised if the 'data'
     sequence is empty.

     Wikipedia has an example(6) where we can use *note kde(): 22b. to
     generate and plot a probability density function estimated from a
     small sample:

          >>> sample = [-2.1, -1.3, -0.4, 1.9, 5.1, 6.2]
          >>> f_hat = kde(sample, h=1.5)
          >>> xarr = [i/100 for i in range(-750, 1100)]
          >>> yarr = [f_hat(x) for x in xarr]

     The points in ‘xarr’ and ‘yarr’ can be used to make a PDF plot:

[image src="python-figures/kde_example.png" alt="Scatter plot of the estimated probability density function."]


     Added in version 3.13.

 -- の関数: statistics.kde_random (data, h, kernel='normal', *,
          seed=None)

     Return a function that makes a random selection from the estimated
     probability density function produced by ‘kde(data, h, kernel)’.

     Providing a 'seed' allows reproducible selections.  In the future,
     the values may change slightly as more accurate kernel inverse CDF
     estimates are implemented.  The seed may be an integer, float, str,
     or bytes.

     A *note StatisticsError: 2662. will be raised if the 'data'
     sequence is empty.

     Continuing the example for *note kde(): 22b, we can use *note
     kde_random(): 22c. to generate new random selections from an
     estimated probability density function:

          >>> data = [-2.1, -1.3, -0.4, 1.9, 5.1, 6.2]
          >>> rand = kde_random(data, h=1.5, seed=8675309)
          >>> new_selections = [rand() for i in range(10)]
          >>> [round(x, 1) for x in new_selections]
          [0.7, 6.2, 1.2, 6.9, 7.0, 1.8, 2.5, -0.5, -1.8, 5.6]

     Added in version 3.13.

 -- の関数: statistics.median (data)

     一般的な「中央2つの平均をとる」方法を使用して、数値データの中央値（
     中間値）を返します。もし 'data' が空の場合、例外 *note
     StatisticsError: 2662. が送出されます。'data' はシーケンス型または
     イテラブルにもなれます。

     中央値は外れ値の影響を受けにくいため、中心位置のロバストな測度です
     。データ数が奇数の場合は中央の値を返します:

          >>> median([1, 3, 5])
          3

     データ数が偶数の場合は、中央値は中央に最も近い2値の算術平均で補間さ
     れます:

          >>> median([1, 3, 5, 7])
          4.0

     データが離散的で、中央値がデータ点にない値でも構わない場合に適して
     います。

     もしあなたのデータが（注文操作をサポートする）序数で、（追加操作を
     サポートしない）数値でないならば、代わりに *note median_low():
     265a. または *note median_high(): 265b. の使用を検討してください。

 -- の関数: statistics.median_low (data)

     数値データの小さい方の中央値(low median)を返します。もし 'data' が
     空の場合、*note StatisticsError: 2662. が送出されます。'data' はシ
     ーケンス型またはイテラブルにもなれます。

     low median は必ずデータに含まれています。データ数が奇数の場合は中央
     の値を返し、偶数の場合は中央の2値の小さい方を返します。

          >>> median_low([1, 3, 5])
          3
          >>> median_low([1, 3, 5, 7])
          3

     データが離散的で、中央値が補間値よりもデータ点にある値の方が良い場
     合に用いてください。

 -- の関数: statistics.median_high (data)

     データの大きい方の中央値(high median)を返します。もし 'data' が空の
     場合、*note StatisticsError: 2662. が送出されます。 'data' はシーケ
     ンス型やイテラブルにもなれます。

     high median は必ずデータに含まれています。データ数が奇数の場合は中
     央の値を返し、偶数の場合は中央の2値の大きい方を返します。

          >>> median_high([1, 3, 5])
          3
          >>> median_high([1, 3, 5, 7])
          5

     データが離散的で、中央値が補間値よりもデータ点にある値の方が良い場
     合に用いてください。

 -- の関数: statistics.median_grouped (data, interval=1.0)

     Estimates the median for numeric data that has been grouped or
     binned(7) around the midpoints of consecutive, fixed-width
     intervals.

     The 'data' can be any iterable of numeric data with each value
     being exactly the midpoint of a bin.  At least one value must be
     present.

     The 'interval' is the width of each bin.

     For example, demographic information may have been summarized into
     consecutive ten-year age groups with each group being represented
     by the 5-year midpoints of the intervals:

          >>> from collections import Counter
          >>> demographics = Counter({
          ...    25: 172,   # 20 to 30 years old
          ...    35: 484,   # 30 to 40 years old
          ...    45: 387,   # 40 to 50 years old
          ...    55:  22,   # 50 to 60 years old
          ...    65:   6,   # 60 to 70 years old
          ... })
          ...

     The 50th percentile (median) is the 536th person out of the 1071
     member cohort.  That person is in the 30 to 40 year old age group.

     The regular *note median(): 2659. function would assume that
     everyone in the tricenarian age group was exactly 35 years old.  A
     more tenable assumption is that the 484 members of that age group
     are evenly distributed between 30 and 40.  For that, we use *note
     median_grouped(): 265c.:

          >>> data = list(demographics.elements())
          >>> median(data)
          35
          >>> round(median_grouped(data, interval=10), 1)
          37.5

     The caller is responsible for making sure the data points are
     separated by exact multiples of 'interval'.  This is essential for
     getting a correct result.  The function does not check this
     precondition.

     Inputs may be any numeric type that can be coerced to a float
     during the interpolation step.

 -- の関数: statistics.mode (data)

     Return the single most common data point from discrete or nominal
     'data'.  The mode (when it exists) is the most typical value and
     serves as a measure of central location.

     If there are multiple modes with the same frequency, returns the
     first one encountered in the 'data'.  If the smallest or largest of
     those is desired instead, use ‘min(multimode(data))’ or
     ‘max(multimode(data))’.  If the input 'data' is empty, *note
     StatisticsError: 2662. is raised.

     ‘mode’ は離散データであることを想定していて、1つの値を返します。こ
     れは学校で教わるような最頻値の標準的な取扱いです:

          >>> mode([1, 1, 2, 3, 3, 3, 3, 4])
          3

     The mode is unique in that it is the only statistic in this package
     that also applies to nominal (non-numeric) data:

          >>> mode(["red", "blue", "blue", "red", "green", "red", "red"])
          'red'

     Only hashable inputs are supported.  To handle type *note set: 5a3,
     consider casting to *note frozenset: 5a4.  To handle type *note
     list: 5dc, consider casting to *note tuple: 349.  For mixed or
     nested inputs, consider using this slower quadratic algorithm that
     only depends on equality tests: ‘max(data, key=data.count)’.

     バージョン 3.8 で変更: Now handles multimodal datasets by returning
     the first mode encountered.  Formerly, it raised *note
     StatisticsError: 2662. when more than one mode was found.

 -- の関数: statistics.multimode (data)

     Return a list of the most frequently occurring values in the order
     they were first encountered in the 'data'.  Will return more than
     one result if there are multiple modes or an empty list if the
     'data' is empty:

          >>> multimode('aabbbbccddddeeffffgg')
          ['b', 'd', 'f']
          >>> multimode('')
          []

     Added in version 3.8.

 -- の関数: statistics.pstdev (data, mu=None)

     母標準偏差 (母分散の平方根) を返します。引数や詳細は *note
     pvariance(): 265f. を参照してください。

          >>> pstdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75])
          0.986893273527251

 -- の関数: statistics.pvariance (data, mu=None)

     'data' の母分散を返します。'data' は実数の空でないシーケンスまたは
     イテラブルです。分散、すなわち2次の中心化モーメントはデータの散らば
     り具合の測度です。分散が大きいデータはばらつきが大きく、分散が小さ
     いデータは平均値のまわりに固まっています。

     If the optional second argument 'mu' is given, it should be the
     'population' mean of the 'data'.  It can also be used to compute
     the second moment around a point that is not the mean.  If it is
     missing or ‘None’ (the default), the arithmetic mean is
     automatically calculated.

     母集団全体から分散を計算する場合に用いてください。標本から分散を推
     定する場合は *note variance(): 69e. を使いましょう。

     'data' が空の場合 *note StatisticsError: 2662. を送出します。

     例:

          >>> data = [0.0, 0.25, 0.25, 1.25, 1.5, 1.75, 2.75, 3.25]
          >>> pvariance(data)
          1.25

     既にデータの平均値を計算している場合、それを第2引数 'mu' に渡して再
     計算を避けることが出来ます:

          >>> mu = mean(data)
          >>> pvariance(data, mu)
          1.25

     Decimal と Fraction がサポートされています:

          >>> from decimal import Decimal as D
          >>> pvariance([D("27.5"), D("30.25"), D("30.25"), D("34.5"), D("41.75")])
          Decimal('24.815')

          >>> from fractions import Fraction as F
          >>> pvariance([F(1, 4), F(5, 4), F(1, 2)])
          Fraction(13, 72)

          注釈: 母集団全体で呼んだ場合は母分散 σ² を返します。代わりに標
          本で呼んだ場合は biased variance s²、すなわち自由度 N の分散を
          返します。

          If you somehow know the true population mean μ, you may use
          this function to calculate the variance of a sample, giving
          the known population mean as the second argument.  Provided
          the data points are a random sample of the population, the
          result will be an unbiased estimate of the population
          variance.

 -- の関数: statistics.stdev (data, xbar=None)

     標本標準偏差 (標本分散の平方根) を返します。引数や詳細は *note
     variance(): 69e. を参照してください。

          >>> stdev([1.5, 2.5, 2.5, 2.75, 3.25, 4.75])
          1.0810874155219827

 -- の関数: statistics.variance (data, xbar=None)

     'data' の標本分散を返します。'data' は少なくとも2つの実数の
     iterable です。分散、すなわち2次の中心化モーメントはデータの散らば
     り具合の測度です。分散が大きいデータはばらつきが大きく、分散が小さ
     いデータは平均値のまわりに固まっています。

     If the optional second argument 'xbar' is given, it should be the
     'sample' mean of 'data'.  If it is missing or ‘None’ (the default),
     the mean is automatically calculated.

     データが母集団の標本であるときに用いてください。母集団全体から分散
     を計算するには *note pvariance(): 265f. を参照してください。

     'data' の値が2より少ない場合 *note StatisticsError: 2662. を送出し
     ます。

     例:

          >>> data = [2.75, 1.75, 1.25, 0.25, 0.5, 1.25, 3.5]
          >>> variance(data)
          1.3720238095238095

     If you have already calculated the sample mean of your data, you
     can pass it as the optional second argument 'xbar' to avoid
     recalculation:

          >>> m = mean(data)
          >>> variance(data, m)
          1.3720238095238095

     この関数は引数として渡した 'xbar' が実際の平均値かどうかチェックし
     ません。任意の値を 'xbar' に渡すと無効な結果やありえない結果が返る
     ことがあります。

     Decimal と Fraction がサポートされています:

          >>> from decimal import Decimal as D
          >>> variance([D("27.5"), D("30.25"), D("30.25"), D("34.5"), D("41.75")])
          Decimal('31.01875')

          >>> from fractions import Fraction as F
          >>> variance([F(1, 6), F(1, 2), F(5, 3)])
          Fraction(67, 108)

          注釈: Bessel 補正済みの標本分散 s²、すなわち自由度 N-1 の分散
          です。与えられたデータ点が代表的 (たとえば独立で均等に分布) な
          場合、戻り値は母分散の不偏推定量になります。

          何らかの方法で真の母平均 μ を知っている場合、それを *note
          pvariance(): 265f. の引数 'mu' に渡して標本の分散を計算するこ
          とが出来ます。

 -- の関数: statistics.quantiles (data, *, n=4, method='exclusive')

     Divide 'data' into 'n' continuous intervals with equal probability.
     Returns a list of ‘n - 1’ cut points separating the intervals.

     Set 'n' to 4 for quartiles (the default).  Set 'n' to 10 for
     deciles.  Set 'n' to 100 for percentiles which gives the 99 cuts
     points that separate 'data' into 100 equal sized groups.  Raises
     *note StatisticsError: 2662. if 'n' is not least 1.

     The 'data' can be any iterable containing sample data.  For
     meaningful results, the number of data points in 'data' should be
     larger than 'n'.  Raises *note StatisticsError: 2662. if there is
     not at least one data point.

     The cut points are linearly interpolated from the two nearest data
     points.  For example, if a cut point falls one-third of the
     distance between two sample values, ‘100’ and ‘112’, the cut-point
     will evaluate to ‘104’.

     The 'method' for computing quantiles can be varied depending on
     whether the 'data' includes or excludes the lowest and highest
     possible values from the population.

     The default 'method' is "exclusive" and is used for data sampled
     from a population that can have more extreme values than found in
     the samples.  The portion of the population falling below the
     'i-th' of 'm' sorted data points is computed as ‘i / (m + 1)’.
     Given nine sample values, the method sorts them and assigns the
     following percentiles: 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90%.

     Setting the 'method' to "inclusive" is used for describing
     population data or for samples that are known to include the most
     extreme values from the population.  The minimum value in 'data' is
     treated as the 0th percentile and the maximum value is treated as
     the 100th percentile.  The portion of the population falling below
     the 'i-th' of 'm' sorted data points is computed as ‘(i - 1) / (m -
     1)’.  Given 11 sample values, the method sorts them and assigns the
     following percentiles: 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%,
     90%, 100%.

          # Decile cut points for empirically sampled data
          >>> data = [105, 129, 87, 86, 111, 111, 89, 81, 108, 92, 110,
          ...         100, 75, 105, 103, 109, 76, 119, 99, 91, 103, 129,
          ...         106, 101, 84, 111, 74, 87, 86, 103, 103, 106, 86,
          ...         111, 75, 87, 102, 121, 111, 88, 89, 101, 106, 95,
          ...         103, 107, 101, 81, 109, 104]
          >>> [round(q, 1) for q in quantiles(data, n=10)]
          [81.0, 86.2, 89.0, 99.4, 102.5, 103.6, 106.0, 109.8, 111.0]

     Added in version 3.8.

     バージョン 3.13 で変更: No longer raises an exception for an input
     with only a single data point.  This allows quantile estimates to
     be built up one sample point at a time becoming gradually more
     refined with each new data point.

 -- の関数: statistics.covariance (x, y, /)

     Return the sample covariance of two inputs 'x' and 'y'.  Covariance
     is a measure of the joint variability of two inputs.

     Both inputs must be of the same length (no less than two),
     otherwise *note StatisticsError: 2662. is raised.

     例:

          >>> x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
          >>> y = [1, 2, 3, 1, 2, 3, 1, 2, 3]
          >>> covariance(x, y)
          0.75
          >>> z = [9, 8, 7, 6, 5, 4, 3, 2, 1]
          >>> covariance(x, z)
          -7.5
          >>> covariance(z, x)
          -7.5

     Added in version 3.10.

 -- の関数: statistics.correlation (x, y, /, *, method='linear')

     Return the Pearson's correlation coefficient(8) for two inputs.
     Pearson's correlation coefficient 'r' takes values between -1 and
     +1.  It measures the strength and direction of a linear
     relationship.

     If 'method' is "ranked", computes Spearman's rank correlation
     coefficient(9) for two inputs.  The data is replaced by ranks.
     Ties are averaged so that equal values receive the same rank.  The
     resulting coefficient measures the strength of a monotonic
     relationship.

     Spearman's correlation coefficient is appropriate for ordinal data
     or for continuous data that doesn't meet the linear proportion
     requirement for Pearson's correlation coefficient.

     Both inputs must be of the same length (no less than two), and need
     not to be constant, otherwise *note StatisticsError: 2662. is
     raised.

     Example with Kepler's laws of planetary motion(10):

          >>> # Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and  Neptune
          >>> orbital_period = [88, 225, 365, 687, 4331, 10_756, 30_687, 60_190]    # days
          >>> dist_from_sun = [58, 108, 150, 228, 778, 1_400, 2_900, 4_500] # million km

          >>> # Show that a perfect monotonic relationship exists
          >>> correlation(orbital_period, dist_from_sun, method='ranked')
          1.0

          >>> # Observe that a linear relationship is imperfect
          >>> round(correlation(orbital_period, dist_from_sun), 4)
          0.9882

          >>> # Demonstrate Kepler's third law: There is a linear correlation
          >>> # between the square of the orbital period and the cube of the
          >>> # distance from the sun.
          >>> period_squared = [p * p for p in orbital_period]
          >>> dist_cubed = [d * d * d for d in dist_from_sun]
          >>> round(correlation(period_squared, dist_cubed), 4)
          1.0

     Added in version 3.10.

     バージョン 3.12 で変更: Added support for Spearman's rank
     correlation coefficient.

 -- の関数: statistics.linear_regression (x, y, /, *,
          proportional=False)

     Return the slope and intercept of simple linear regression(11)
     parameters estimated using ordinary least squares.  Simple linear
     regression describes the relationship between an independent
     variable 'x' and a dependent variable 'y' in terms of this linear
     function:

          'y = slope * x + intercept + noise'

     where ‘slope’ and ‘intercept’ are the regression parameters that
     are estimated, and ‘noise’ represents the variability of the data
     that was not explained by the linear regression (it is equal to the
     difference between predicted and actual values of the dependent
     variable).

     Both inputs must be of the same length (no less than two), and the
     independent variable 'x' cannot be constant; otherwise a *note
     StatisticsError: 2662. is raised.

     For example, we can use the release dates of the Monty Python
     films(12) to predict the cumulative number of Monty Python films
     that would have been produced by 2019 assuming that they had kept
     the pace.

          >>> year = [1971, 1975, 1979, 1982, 1983]
          >>> films_total = [1, 2, 3, 4, 5]
          >>> slope, intercept = linear_regression(year, films_total)
          >>> round(slope * 2019 + intercept)
          16

     If 'proportional' is true, the independent variable 'x' and the
     dependent variable 'y' are assumed to be directly proportional.
     The data is fit to a line passing through the origin.  Since the
     'intercept' will always be 0.0, the underlying linear function
     simplifies to:

          'y = slope * x + noise'

     Continuing the example from *note correlation(): 488, we look to
     see how well a model based on major planets can predict the orbital
     distances for dwarf planets:

          >>> model = linear_regression(period_squared, dist_cubed, proportional=True)
          >>> slope = model.slope

          >>> # Dwarf planets:   Pluto,  Eris,    Makemake, Haumea, Ceres
          >>> orbital_periods = [90_560, 204_199, 111_845, 103_410, 1_680]  # days
          >>> predicted_dist = [math.cbrt(slope * (p * p)) for p in orbital_periods]
          >>> list(map(round, predicted_dist))
          [5912, 10166, 6806, 6459, 414]

          >>> [5_906, 10_152, 6_796, 6_450, 414]  # actual distance in million km
          [5906, 10152, 6796, 6450, 414]

     Added in version 3.10.

     バージョン 3.11 で変更: Added support for 'proportional'.

   ---------- Footnotes ----------

   (1) https://ja.wikipedia.org/wiki/外れ値

   (2) https://en.wikipedia.org/wiki/Outlier

   (3) https://en.wikipedia.org/wiki/Central_tendency

   (4) 
https://www.itm-conferences.org/articles/itmconf/pdf/2018/08/itmconf_sam2018_00037.pdf

   (5) https://en.wikipedia.org/wiki/Kernel_(statistics)

   (6) https://en.wikipedia.org/wiki/Kernel_density_estimation#Example

   (7) https://en.wikipedia.org/wiki/Data_binning

   (8) https://en.wikipedia.org/wiki/Pearson_correlation_coefficient

   (9) 
https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient

   (10) https://en.wikipedia.org/wiki/Kepler's_laws_of_planetary_motion

   (11) https://en.wikipedia.org/wiki/Simple_linear_regression

   (12) https://en.wikipedia.org/wiki/Monty_Python#Films


File: python.info,  Node: 例外<5>,  Next: NormalDist オブジェクト,  Prev: 関数の詳細,  Up: statistics --- 数学的統計関数

5.9.7.5 例外
............

例外が1つ定義されています:

 -- 例外: statistics.StatisticsError

     統計関係の例外。*note ValueError: 1e3. の派生クラス。


File: python.info,  Node: NormalDist オブジェクト,  Next: 例とレシピ<2>,  Prev: 例外<5>,  Up: statistics --- 数学的統計関数

5.9.7.6 ‘NormalDist’ オブジェクト
.................................

*note NormalDist: a06. is a tool for creating and manipulating normal
distributions of a random variable(1).  It is a class that treats the
mean and standard deviation of data measurements as a single entity.

Normal distributions arise from the Central Limit Theorem(2) and have a
wide range of applications in statistics.

 -- クラス: statistics.NormalDist (mu=0.0, sigma=1.0)

     Returns a new 'NormalDist' object where 'mu' represents the
     arithmetic mean(3) and 'sigma' represents the standard
     deviation(4).

     'sigma' が負の数の場合 *note StatisticsError: 2662. を送出します。

      -- の属性: mean

          A read-only property for the arithmetic mean(5) of a normal
          distribution.

      -- の属性: median

          A read-only property for the median(6) of a normal
          distribution.

      -- の属性: mode

          A read-only property for the mode(7) of a normal distribution.

      -- の属性: stdev

          A read-only property for the standard deviation(8) of a normal
          distribution.

      -- の属性: variance

          A read-only property for the variance(9) of a normal
          distribution.  Equal to the square of the standard deviation.

      -- メソッド: classmethod from_samples (data)

          Makes a normal distribution instance with 'mu' and 'sigma'
          parameters estimated from the 'data' using *note fmean(): a02.
          and *note stdev(): 69f.

          The 'data' can be any *note iterable: 10ad. and should consist
          of values that can be converted to type *note float: 2ce.  If
          'data' does not contain at least two elements, raises *note
          StatisticsError: 2662. because it takes at least one point to
          estimate a central value and at least two points to estimate
          dispersion.

      -- メソッド: samples (n, *, seed=None)

          Generates 'n' random samples for a given mean and standard
          deviation.  Returns a *note list: 5dc. of *note float: 2ce.
          values.

          If 'seed' is given, creates a new instance of the underlying
          random number generator.  This is useful for creating
          reproducible results, even in a multi-threading context.

          バージョン 3.13 で変更.

          Switched to a faster algorithm.  To reproduce samples from
          previous versions, use *note random.seed(): 1245. and *note
          random.gauss(): 17ac.

      -- メソッド: pdf (x)

          Using a probability density function (pdf)(10), compute the
          relative likelihood that a random variable 'X' will be near
          the given value 'x'.  Mathematically, it is the limit of the
          ratio ‘P(x <= X < x+dx) / dx’ as 'dx' approaches zero.

          The relative likelihood is computed as the probability of a
          sample occurring in a narrow range divided by the width of the
          range (hence the word "density").  Since the likelihood is
          relative to other points, its value can be greater than ‘1.0’.

      -- メソッド: cdf (x)

          Using a cumulative distribution function (cdf)(11), compute
          the probability that a random variable 'X' will be less than
          or equal to 'x'.  Mathematically, it is written ‘P(X <= x)’.

      -- メソッド: inv_cdf (p)

          Compute the inverse cumulative distribution function, also
          known as the quantile function(12) or the percent-point(13)
          function.  Mathematically, it is written ‘x : P(X <= x) = p’.

          Finds the value 'x' of the random variable 'X' such that the
          probability of the variable being less than or equal to that
          value equals the given probability 'p'.

      -- メソッド: overlap (other)

          Measures the agreement between two normal probability
          distributions.  Returns a value between 0.0 and 1.0 giving the
          overlapping area for the two probability density
          functions(14).

      -- メソッド: quantiles (n=4)

          Divide the normal distribution into 'n' continuous intervals
          with equal probability.  Returns a list of (n - 1) cut points
          separating the intervals.

          Set 'n' to 4 for quartiles (the default).  Set 'n' to 10 for
          deciles.  Set 'n' to 100 for percentiles which gives the 99
          cuts points that separate the normal distribution into 100
          equal sized groups.

      -- メソッド: zscore (x)

          Compute the Standard Score(15) describing 'x' in terms of the
          number of standard deviations above or below the mean of the
          normal distribution: ‘(x - mean) / stdev’.

          Added in version 3.9.

     Instances of *note NormalDist: a06. support addition, subtraction,
     multiplication and division by a constant.  These operations are
     used for translation and scaling.  For example:

          >>> temperature_february = NormalDist(5, 2.5)             # Celsius
          >>> temperature_february * (9/5) + 32                     # Fahrenheit
          NormalDist(mu=41.0, sigma=4.5)

     Dividing a constant by an instance of *note NormalDist: a06. is not
     supported because the result wouldn't be normally distributed.

     Since normal distributions arise from additive effects of
     independent variables, it is possible to add and subtract two
     independent normally distributed random variables(16) represented
     as instances of *note NormalDist: a06.  For example:

          >>> birth_weights = NormalDist.from_samples([2.5, 3.1, 2.1, 2.4, 2.7, 3.5])
          >>> drug_effects = NormalDist(0.4, 0.15)
          >>> combined = birth_weights + drug_effects
          >>> round(combined.mean, 1)
          3.1
          >>> round(combined.stdev, 1)
          0.5

     Added in version 3.8.

   ---------- Footnotes ----------

   (1) http://www.stat.yale.edu/Courses/1997-98/101/ranvar.htm

   (2) https://en.wikipedia.org/wiki/Central_limit_theorem

   (3) https://en.wikipedia.org/wiki/Arithmetic_mean

   (4) https://en.wikipedia.org/wiki/Standard_deviation

   (5) https://en.wikipedia.org/wiki/Arithmetic_mean

   (6) https://en.wikipedia.org/wiki/Median

   (7) https://en.wikipedia.org/wiki/Mode_(statistics)

   (8) https://en.wikipedia.org/wiki/Standard_deviation

   (9) https://en.wikipedia.org/wiki/Variance

   (10) https://en.wikipedia.org/wiki/Probability_density_function

   (11) https://en.wikipedia.org/wiki/Cumulative_distribution_function

   (12) https://en.wikipedia.org/wiki/Quantile_function

   (13) 
https://web.archive.org/web/20190203145224/https://www.statisticshowto.datasciencecentral.com/inverse-distribution-function/

   (14) https://www.rasch.org/rmt/rmt101r.htm

   (15) 
https://www.statisticshowto.com/probability-and-statistics/z-score/

   (16) 
https://en.wikipedia.org/wiki/Sum_of_normally_distributed_random_variables


File: python.info,  Node: 例とレシピ<2>,  Prev: NormalDist オブジェクト,  Up: statistics --- 数学的統計関数

5.9.7.7 例とレシピ
..................

* Menu:

* Classic probability problems::
* Monte Carlo inputs for simulations::
* Approximating binomial distributions::
* Naive bayesian classifier::


File: python.info,  Node: Classic probability problems,  Next: Monte Carlo inputs for simulations,  Up: 例とレシピ<2>

5.9.7.8 Classic probability problems
....................................

*note NormalDist: a06. readily solves classic probability problems.

For example, given historical data for SAT exams(1) showing that scores
are normally distributed with a mean of 1060 and a standard deviation of
195, determine the percentage of students with test scores between 1100
and 1200, after rounding to the nearest whole number:

     >>> sat = NormalDist(1060, 195)
     >>> fraction = sat.cdf(1200 + 0.5) - sat.cdf(1100 - 0.5)
     >>> round(fraction * 100.0, 1)
     18.4

Find the quartiles(2) and deciles(3) for the SAT scores:

     >>> list(map(round, sat.quantiles()))
     [928, 1060, 1192]
     >>> list(map(round, sat.quantiles(n=10)))
     [810, 896, 958, 1011, 1060, 1109, 1162, 1224, 1310]

   ---------- Footnotes ----------

   (1) https://nces.ed.gov/programs/digest/d17/tables/dt17_226.40.asp

   (2) https://en.wikipedia.org/wiki/Quartile

   (3) https://en.wikipedia.org/wiki/Decile


File: python.info,  Node: Monte Carlo inputs for simulations,  Next: Approximating binomial distributions,  Prev: Classic probability problems,  Up: 例とレシピ<2>

5.9.7.9 Monte Carlo inputs for simulations
..........................................

To estimate the distribution for a model that isn't easy to solve
analytically, *note NormalDist: a06. can generate input samples for a
Monte Carlo simulation(1):

     >>> def model(x, y, z):
     ...     return (3*x + 7*x*y - 5*y) / (11 * z)
     ...
     >>> n = 100_000
     >>> X = NormalDist(10, 2.5).samples(n, seed=3652260728)
     >>> Y = NormalDist(15, 1.75).samples(n, seed=4582495471)
     >>> Z = NormalDist(50, 1.25).samples(n, seed=6582483453)
     >>> quantiles(map(model, X, Y, Z))
     [1.4591308524824727, 1.8035946855390597, 2.175091447274739]

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Monte_Carlo_method


File: python.info,  Node: Approximating binomial distributions,  Next: Naive bayesian classifier,  Prev: Monte Carlo inputs for simulations,  Up: 例とレシピ<2>

5.9.7.10 Approximating binomial distributions
.............................................

Normal distributions can be used to approximate Binomial
distributions(1) when the sample size is large and when the probability
of a successful trial is near 50%.

For example, an open source conference has 750 attendees and two rooms
with a 500 person capacity.  There is a talk about Python and another
about Ruby.  In previous conferences, 65% of the attendees preferred to
listen to Python talks.  Assuming the population preferences haven't
changed, what is the probability that the Python room will stay within
its capacity limits?

     >>> n = 750             # Sample size
     >>> p = 0.65            # Preference for Python
     >>> q = 1.0 - p         # Preference for Ruby
     >>> k = 500             # Room capacity

     >>> # Approximation using the cumulative normal distribution
     >>> from math import sqrt
     >>> round(NormalDist(mu=n*p, sigma=sqrt(n*p*q)).cdf(k + 0.5), 4)
     0.8402

     >>> # Exact solution using the cumulative binomial distribution
     >>> from math import comb, fsum
     >>> round(fsum(comb(n, r) * p**r * q**(n-r) for r in range(k+1)), 4)
     0.8402

     >>> # Approximation using a simulation
     >>> from random import seed, binomialvariate
     >>> seed(8675309)
     >>> mean(binomialvariate(n, p) <= k for i in range(10_000))
     0.8406

   ---------- Footnotes ----------

   (1) https://mathworld.wolfram.com/BinomialDistribution.html


File: python.info,  Node: Naive bayesian classifier,  Prev: Approximating binomial distributions,  Up: 例とレシピ<2>

5.9.7.11 Naive bayesian classifier
..................................

Normal distributions commonly arise in machine learning problems.

Wikipedia has a nice example of a Naive Bayesian Classifier(1).  The
challenge is to predict a person's gender from measurements of normally
distributed features including height, weight, and foot size.

We're given a training dataset with measurements for eight people.  The
measurements are assumed to be normally distributed, so we summarize the
data with *note NormalDist: a06.:

     >>> height_male = NormalDist.from_samples([6, 5.92, 5.58, 5.92])
     >>> height_female = NormalDist.from_samples([5, 5.5, 5.42, 5.75])
     >>> weight_male = NormalDist.from_samples([180, 190, 170, 165])
     >>> weight_female = NormalDist.from_samples([100, 150, 130, 150])
     >>> foot_size_male = NormalDist.from_samples([12, 11, 12, 10])
     >>> foot_size_female = NormalDist.from_samples([6, 8, 7, 9])

Next, we encounter a new person whose feature measurements are known but
whose gender is unknown:

     >>> ht = 6.0        # height
     >>> wt = 130        # weight
     >>> fs = 8          # foot size

Starting with a 50% prior probability(2) of being male or female, we
compute the posterior as the prior times the product of likelihoods for
the feature measurements given the gender:

     >>> prior_male = 0.5
     >>> prior_female = 0.5
     >>> posterior_male = (prior_male * height_male.pdf(ht) *
     ...                   weight_male.pdf(wt) * foot_size_male.pdf(fs))

     >>> posterior_female = (prior_female * height_female.pdf(ht) *
     ...                     weight_female.pdf(wt) * foot_size_female.pdf(fs))

The final prediction goes to the largest posterior.  This is known as
the maximum a posteriori(3) or MAP:

     >>> 'male' if posterior_male > posterior_female else 'female'
     'female'

   ---------- Footnotes ----------

   (1) 
https://en.wikipedia.org/wiki/Naive_Bayes_classifier#Person_classification

   (2) https://en.wikipedia.org/wiki/Prior_probability

   (3) https://en.wikipedia.org/wiki/Maximum_a_posteriori_estimation


File: python.info,  Node: 関数型プログラミング用モジュール,  Next: ファイルとディレクトリへのアクセス,  Prev: 数値と数学モジュール,  Up: Python 標準ライブラリ

5.10 関数型プログラミング用モジュール
=====================================

この章では、関数型プログラミングスタイルをサポートする呼び出し可能で汎用
な操作を実現する関数やクラスについて説明します。

この章では以下のモジュールが記述されています:

* Menu:

* itertools: itertools --- 効率的なループ用のイテレータ生成関数群. 効率的なループ用のイテレータ生成関数群
* functools: functools --- 高階関数と呼び出し可能オブジェクトの操作. 高階関数と呼び出し可能オブジェクトの操作
* operator: operator --- 関数形式の標準演算子. 関数形式の標準演算子


File: python.info,  Node: itertools --- 効率的なループ用のイテレータ生成関数群,  Next: functools --- 高階関数と呼び出し可能オブジェクトの操作,  Up: 関数型プログラミング用モジュール

5.10.1 ‘itertools’ -- 効率的なループ用のイテレータ生成関数群
------------------------------------------------------------

__________________________________________________________________

このモジュールは *note イテレータ: 191. を構築する部品を実装しています。
プログラム言語 APL, Haskell, SML からアイデアを得ていますが、 Python に
適した形に修正されています。

このモジュールは、高速でメモリ効率に優れ、単独でも組合せても使用すること
のできるツールを標準化したものです。同時に、このツール群は "イテレータの
代数" を構成していて、pure Python で簡潔かつ効率的なツールを作れるように
しています。

例えば、SML の作表ツール ‘tabulate(f)’ は ‘f(0), f(1), ...’ のシーケンス
を作成します。同じことを Python では *note map(): 82f. と *note count():
1254. を組合せて ‘map(f, count())’ という形で実現できます。

これらのツールと組み込み関数は *note operator: 8f. モジュール内の高速な
関数とともに使うことで見事に動作します。例えば、乗算演算子を2つのベクト
ルにわたってマップすることで効率的な内積計算を実現できます:
‘sum(starmap(operator.mul, zip(vec1, vec2, strict=True)))’。

'無限イテレータ:'

イテレータ             引数                  結果                                                  使用例
                                                                                                   
-------------------------------------------------------------------------------------------------------------------------------------------------
                                                                                                   
*note count(): 1254.   [start[, step]]       start, start+step, start+2*step, ...                  ‘count(10) → 10 11 12 13 14 ...’
                                                                                                   
                                                                                                   
*note cycle(): 267b.   p                     p0, p1, ...  plast, p0, p1, ...                       ‘cycle('ABCD') → A B C D A B C D ...’
                                                                                                   
                                                                                                   
*note repeat(): 267c.  elem [,n]             elem, elem, elem, ...  無限もしくは n 回              ‘repeat(10, 3) → 10 10 10’
                                                                                                   

'一番短い入力シーケンスで止まるイテレータ:'

イテレータ                       引数                             結果                                                  使用例
                                                                                                                        
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                                                                                                                        
*note accumulate(): 9cb.         p [,func]                        p0, p0+p1, p0+p1+p2, ...                              ‘accumulate([1,2,3,4,5]) → 1 3 6 10 15’
                                                                                                                        
                                                                                                                        
*note batched(): 1e2.            p, n                             (p0, p1, ..., p_n-1), ...                             ‘batched('ABCDEFG', n=3) → ABC DEF G’
                                                                                                                        
                                                                                                                        
*note chain(): 20e4.             p, q, ...                        p0, p1, ...  plast, q0, q1, ...                       ‘chain('ABC', 'DEF') → A B C D E F’
                                                                                                                        
                                                                                                                        
*note chain.from_iterable(): 267d.iterable                        p0, p1, ...  plast, q0, q1, ...                       ‘chain.from_iterable(['ABC', 'DEF']) → A B C D E F’
                                                                                                                        
                                                                                                                        
*note compress(): 1253.          data, selectors                  (d[0] if s[0]), (d[1] if s[1]), ...                   ‘compress('ABCDEF', [1,0,1,0,1,1]) → A C E F’
                                                                                                                        
                                                                                                                        
*note dropwhile(): 267e.         predicate, seq                   seq[n], seq[n+1], starting when predicate fails       ‘dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8’
                                                                                                                        
                                                                                                                        
*note filterfalse(): 20cc.       predicate, seq                   elements of seq where predicate(elem) fails           ‘filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8’
                                                                                                                        
                                                                                                                        
*note groupby(): 267f.           iterable[, key]                  key(v) の値でグループ化したサブイテレータ             ‘groupby(['A','B','DEF'], len) → (1, A B) (3, DEF)’
                                                                                                                        
                                                                                                                        
*note islice(): b1a.             seq, [start,] stop [, step]      seq[start:stop:step]                                  ‘islice('ABCDEFG', 2, None) → C D E F G’
                                                                                                                        
                                                                                                                        
*note pairwise(): 7e0.           iterable                         (p[0], p[1]), (p[1], p[2])                            ‘pairwise('ABCDEFG') → AB BC CD DE EF FG’
                                                                                                                        
                                                                                                                        
*note starmap(): 10b5.           func, seq                        func(*seq[0]), func(*seq[1]), ...                     ‘starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000’
                                                                                                                        
                                                                                                                        
*note takewhile(): 2680.         predicate, seq                   seq[0], seq[1], until predicate fails                 ‘takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4’
                                                                                                                        
                                                                                                                        
*note tee(): 2681.               it, n                            it1, it2 , ...  itn 一つのイテレータを n 個に分ける
                                                                  
                                                                                                                        
*note zip_longest(): 126e.       p, q, ...                        (p[0], q[0]), (p[1], q[1]), ...                       ‘zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-’
                                                                                                                        

'組合せイテレータ:'

イテレータ                                         引数                     結果
                                                                            
----------------------------------------------------------------------------------------------------------------------------------------------
                                                                            
*note product(): 12e2.                             p, q, ...  [repeat=1]    デカルト積、ネストしたforループと等価
                                                                            
                                                                            
*note permutations(): 1885.                        p[, r]                   長さrのタプル列、重複なしのあらゆる並び
                                                                            
                                                                            
*note combinations(): 12e1.                        p, r                     長さrのタプル列、ソートされた順で重複なし
                                                                            
                                                                            
*note combinations_with_replacement(): 1252.       p, r                     長さrのタプル列、ソートされた順で重複あり
                                                                            

使用例                                             結果
                                                   
---------------------------------------------------------------------------------------------------------------------
                                                   
‘product('ABCD', repeat=2)’                        ‘AA AB AC AD BA BB BC BD CA CB CC CD DA DB DC DD’
                                                   
                                                   
‘permutations('ABCD', 2)’                          ‘AB AC AD BA BC BD CA CB CD DA DB DC’
                                                   
                                                   
‘combinations('ABCD', 2)’                          ‘AB AC AD BC BD CD’
                                                   
                                                   
‘combinations_with_replacement('ABCD', 2)’         ‘AA AB AC AD BB BC BD CC CD DD’
                                                   

* Menu:

* Itertool関数::
* Itertools レシピ::


File: python.info,  Node: Itertool関数,  Next: Itertools レシピ,  Up: itertools --- 効率的なループ用のイテレータ生成関数群

5.10.1.1 Itertool関数
.....................

The following functions all construct and return iterators.  Some
provide streams of infinite length, so they should only be accessed by
functions or loops that truncate the stream.

 -- の関数: itertools.accumulate (iterable[, function, *, initial=None])

     Make an iterator that returns accumulated sums or accumulated
     results from other binary functions.

     The 'function' defaults to addition.  The 'function' should accept
     two arguments, an accumulated total and a value from the
     'iterable'.

     If an 'initial' value is provided, the accumulation will start with
     that value and the output will have one more element than the input
     iterable.

     およそ次と等価です:

          def accumulate(iterable, function=operator.add, *, initial=None):
              'Return running totals'
              # accumulate([1,2,3,4,5]) → 1 3 6 10 15
              # accumulate([1,2,3,4,5], initial=100) → 100 101 103 106 110 115
              # accumulate([1,2,3,4,5], operator.mul) → 1 2 6 24 120

              iterator = iter(iterable)
              total = initial
              if initial is None:
                  try:
                      total = next(iterator)
                  except StopIteration:
                      return

              yield total
              for element in iterator:
                  total = function(total, element)
                  yield total

     To compute a running minimum, set 'function' to *note min(): ed3.
     For a running maximum, set 'function' to *note max(): ed4.  Or for
     a running product, set 'function' to *note operator.mul(): 2684.
     To build an amortization table(1), accumulate the interest and
     apply payments:

          >>> data = [3, 4, 6, 2, 1, 9, 0, 7, 5, 8]
          >>> list(accumulate(data, max))              # running maximum
          [3, 4, 6, 6, 6, 9, 9, 9, 9, 9]
          >>> list(accumulate(data, operator.mul))     # running product
          [3, 12, 72, 144, 144, 1296, 0, 0, 0, 0]

          # Amortize a 5% loan of 1000 with 10 annual payments of 90
          >>> update = lambda balance, payment: round(balance * 1.05) - payment
          >>> list(accumulate(repeat(90, 10), update, initial=1_000))
          [1000, 960, 918, 874, 828, 779, 728, 674, 618, 559, 497]

     最終的な累積値だけを返す類似の関数については *note
     functools.reduce(): 12aa. を見てください。

     Added in version 3.2.

     バージョン 3.3 で変更: Added the optional 'function' parameter.

     バージョン 3.8 で変更: オプションの 'initial' パラメータが追加され
     ました。

 -- の関数: itertools.batched (iterable, n, *, strict=False)

     'iterable' から得られるデータを 'n' 個ごとに一つのタプルにまとめま
     す。 一番最後のバッチは 'n' 個より少なくなる可能性があります。

     If 'strict' is true, will raise a *note ValueError: 1e3. if the
     final batch is shorter than 'n'.

     入力の iterable から要素を一つづつ取り出し、サイズが 'n' になるまで
     タプルに溜め込みます。 入力の iterable は遅延評価され、次のタプルを
     作るのに必要なだけ要素が取り出されます。 タプルは、個数が 'n' に到
     達するか、入力の iterable が尽きるとすぐに出力されます:

          >>> flattened_data = ['roses', 'red', 'violets', 'blue', 'sugar', 'sweet']
          >>> unflattened = list(batched(flattened_data, 2))
          >>> unflattened
          [('roses', 'red'), ('violets', 'blue'), ('sugar', 'sweet')]

     およそ次と等価です:

          def batched(iterable, n, *, strict=False):
              # batched('ABCDEFG', 3) → ABC DEF G
              if n < 1:
                  raise ValueError('n must be at least one')
              iterator = iter(iterable)
              while batch := tuple(islice(iterator, n)):
                  if strict and len(batch) != n:
                      raise ValueError('batched(): incomplete batch')
                  yield batch

     Added in version 3.12.

     バージョン 3.13 で変更: Added the 'strict' option.

 -- の関数: itertools.chain (*iterables)

     Make an iterator that returns elements from the first iterable
     until it is exhausted, then proceeds to the next iterable, until
     all of the iterables are exhausted.  This combines multiple data
     sources into a single iterator.  Roughly equivalent to:

          def chain(*iterables):
              # chain('ABC', 'DEF') → A B C D E F
              for iterable in iterables:
                  yield from iterable

 -- メソッド: classmethod chain.from_iterable (iterable)

     *note chain(): 20e4. のためのもう一つのコンストラクタです。遅延評価
     される iterable 引数一つから連鎖した入力を受け取ります。この関数は
     、以下のコードとほぼ等価です:

          def from_iterable(iterables):
              # chain.from_iterable(['ABC', 'DEF']) → A B C D E F
              for iterable in iterables:
                  yield from iterable

 -- の関数: itertools.combinations (iterable, r)

     入力 'iterable' の要素からなる長さ 'r' の部分列を返します。

     The output is a subsequence of *note product(): 12e2. keeping only
     entries that are subsequences of the 'iterable'.  The length of the
     output is given by *note math.comb(): 69b. which computes ‘n! / r!
     / (n - r)!’ when ‘0 ≤ r ≤ n’ or zero when ‘r > n’.

     The combination tuples are emitted in lexicographic order according
     to the order of the input 'iterable'.  If the input 'iterable' is
     sorted, the output tuples will be produced in sorted order.

     Elements are treated as unique based on their position, not on
     their value.  If the input elements are unique, there will be no
     repeated values within each combination.

     およそ次と等価です:

          def combinations(iterable, r):
              # combinations('ABCD', 2) → AB AC AD BC BD CD
              # combinations(range(4), 3) → 012 013 023 123

              pool = tuple(iterable)
              n = len(pool)
              if r > n:
                  return
              indices = list(range(r))

              yield tuple(pool[i] for i in indices)
              while True:
                  for i in reversed(range(r)):
                      if indices[i] != i + n - r:
                          break
                  else:
                      return
                  indices[i] += 1
                  for j in range(i+1, r):
                      indices[j] = indices[j-1] + 1
                  yield tuple(pool[i] for i in indices)

 -- の関数: itertools.combinations_with_replacement (iterable, r)

     入力 'iterable' から、それぞれの要素が複数回現れることを許して、長
     さ 'r' の要素の部分列を返します。

     The output is a subsequence of *note product(): 12e2. that keeps
     only entries that are subsequences (with possible repeated
     elements) of the 'iterable'.  The number of subsequence returned is
     ‘(n + r - 1)! / r! / (n - 1)!’ when ‘n > 0’.

     The combination tuples are emitted in lexicographic order according
     to the order of the input 'iterable'.  if the input 'iterable' is
     sorted, the output tuples will be produced in sorted order.

     Elements are treated as unique based on their position, not on
     their value.  If the input elements are unique, the generated
     combinations will also be unique.

     およそ次と等価です:

          def combinations_with_replacement(iterable, r):
              # combinations_with_replacement('ABC', 2) → AA AB AC BB BC CC

              pool = tuple(iterable)
              n = len(pool)
              if not n and r:
                  return
              indices = [0] * r

              yield tuple(pool[i] for i in indices)
              while True:
                  for i in reversed(range(r)):
                      if indices[i] != n - 1:
                          break
                  else:
                      return
                  indices[i:] = [indices[i] + 1] * (r - i)
                  yield tuple(pool[i] for i in indices)

     Added in version 3.1.

 -- の関数: itertools.compress (data, selectors)

     Make an iterator that returns elements from 'data' where the
     corresponding element in 'selectors' is true.  Stops when either
     the 'data' or 'selectors' iterables have been exhausted.  Roughly
     equivalent to:

          def compress(data, selectors):
              # compress('ABCDEF', [1,0,1,0,1,1]) → A C E F
              return (datum for datum, selector in zip(data, selectors) if selector)

     Added in version 3.1.

 -- の関数: itertools.count (start=0, step=1)

     Make an iterator that returns evenly spaced values beginning with
     'start'.  Can be used with *note map(): 82f. to generate
     consecutive data points or with *note zip(): 79b. to add sequence
     numbers.  Roughly equivalent to:

          def count(start=0, step=1):
              # count(10) → 10 11 12 13 14 ...
              # count(2.5, 0.5) → 2.5 3.0 3.5 ...
              n = start
              while True:
                  yield n
                  n += step

     When counting with floating-point numbers, better accuracy can
     sometimes be achieved by substituting multiplicative code such as:
     ‘(start + step * i for i in count())’.

     バージョン 3.1 で変更: 'step' 引数が追加され、非整数の引数が許され
     るようになりました。

 -- の関数: itertools.cycle (iterable)

     Make an iterator returning elements from the 'iterable' and saving
     a copy of each.  When the iterable is exhausted, return elements
     from the saved copy.  Repeats indefinitely.  Roughly equivalent to:

          def cycle(iterable):
              # cycle('ABCD') → A B C D A B C D A B C D ...

              saved = []
              for element in iterable:
                  yield element
                  saved.append(element)

              while saved:
                  for element in saved:
                      yield element

     This itertool may require significant auxiliary storage (depending
     on the length of the iterable).

 -- の関数: itertools.dropwhile (predicate, iterable)

     Make an iterator that drops elements from the 'iterable' while the
     'predicate' is true and afterwards returns every element.  Roughly
     equivalent to:

          def dropwhile(predicate, iterable):
              # dropwhile(lambda x: x<5, [1,4,6,3,8]) → 6 3 8

              iterator = iter(iterable)
              for x in iterator:
                  if not predicate(x):
                      yield x
                      break

              for x in iterator:
                  yield x

     Note this does not produce 'any' output until the predicate first
     becomes false, so this itertool may have a lengthy start-up time.

 -- の関数: itertools.filterfalse (predicate, iterable)

     Make an iterator that filters elements from the 'iterable'
     returning only those for which the 'predicate' returns a false
     value.  If 'predicate' is ‘None’, returns the items that are false.
     Roughly equivalent to:

          def filterfalse(predicate, iterable):
              # filterfalse(lambda x: x<5, [1,4,6,3,8]) → 6 8

              if predicate is None:
                  predicate = bool

              for x in iterable:
                  if not predicate(x):
                      yield x

 -- の関数: itertools.groupby (iterable, key=None)

     同じキーをもつような要素からなる 'iterable' 中のグループに対して、
     キーとグループを返すようなイテレータを作成します。'key' は各要素に
     対するキー値を計算する関数です。キーを指定しない場合や ‘None’ にし
     た場合、'key' 関数のデフォルトは恒等関数になり要素をそのまま返しま
     す。通常、'iterable' は同じキー関数でソート済みである必要があります
     。

     *note groupby(): 267f. の操作は Unix の ‘uniq’ フィルターと似ていま
     す。 key 関数の値が変わるたびに休止または新しいグループを生成します
     (このために通常同じ key 関数でソートしておく必要があるのです)。この
     動作は SQL の入力順に関係なく共通の要素を集約する GROUP BY とは違い
     ます。

     返されるグループはそれ自体がイテレータで、 *note groupby(): 267f. と
     'iterable' を共有しています。もととなる 'iterable' を共有しているた
     め、 *note groupby(): 267f. オブジェクトの要素取り出しを先に進める
     と、それ以前の要素であるグループは見えなくなってしまいます。従って
     、データが後で必要な場合にはリストの形で保存しておく必要があります:

          groups = []
          uniquekeys = []
          data = sorted(data, key=keyfunc)
          for k, g in groupby(data, keyfunc):
              groups.append(list(g))      # Store group iterator as a list
              uniquekeys.append(k)

     *note groupby(): 267f. はおよそ次と等価です:

          def groupby(iterable, key=None):
              # [k for k, g in groupby('AAAABBBCCDAABBB')] → A B C D A B
              # [list(g) for k, g in groupby('AAAABBBCCD')] → AAAA BBB CC D

              keyfunc = (lambda x: x) if key is None else key
              iterator = iter(iterable)
              exhausted = False

              def _grouper(target_key):
                  nonlocal curr_value, curr_key, exhausted
                  yield curr_value
                  for curr_value in iterator:
                      curr_key = keyfunc(curr_value)
                      if curr_key != target_key:
                          return
                      yield curr_value
                  exhausted = True

              try:
                  curr_value = next(iterator)
              except StopIteration:
                  return
              curr_key = keyfunc(curr_value)

              while not exhausted:
                  target_key = curr_key
                  curr_group = _grouper(target_key)
                  yield curr_key, curr_group
                  if curr_key == target_key:
                      for _ in curr_group:
                          pass

 -- の関数: itertools.islice (iterable, stop)

 -- の関数: itertools.islice (iterable, start, stop[, step])

     Make an iterator that returns selected elements from the iterable.
     Works like sequence slicing but does not support negative values
     for 'start', 'stop', or 'step'.

     If 'start' is zero or ‘None’, iteration starts at zero.  Otherwise,
     elements from the iterable are skipped until 'start' is reached.

     If 'stop' is ‘None’, iteration continues until the input is
     exhausted, if at all.  Otherwise, it stops at the specified
     position.

     If 'step' is ‘None’, the step defaults to one.  Elements are
     returned consecutively unless 'step' is set higher than one which
     results in items being skipped.

     およそ次と等価です:

          def islice(iterable, *args):
              # islice('ABCDEFG', 2) → A B
              # islice('ABCDEFG', 2, 4) → C D
              # islice('ABCDEFG', 2, None) → C D E F G
              # islice('ABCDEFG', 0, None, 2) → A C E G

              s = slice(*args)
              start = 0 if s.start is None else s.start
              stop = s.stop
              step = 1 if s.step is None else s.step
              if start < 0 or (stop is not None and stop < 0) or step <= 0:
                  raise ValueError

              indices = count() if stop is None else range(max(start, stop))
              next_i = start
              for i, element in zip(indices, iterable):
                  if i == next_i:
                      yield element
                      next_i += step

     If the input is an iterator, then fully consuming the 'islice'
     advances the input iterator by ‘max(start, stop)’ steps regardless
     of the 'step' value.

 -- の関数: itertools.pairwise (iterable)

     Return successive overlapping pairs taken from the input
     'iterable'.

     The number of 2-tuples in the output iterator will be one fewer
     than the number of inputs.  It will be empty if the input iterable
     has fewer than two values.

     およそ次と等価です:

          def pairwise(iterable):
              # pairwise('ABCDEFG') → AB BC CD DE EF FG

              iterator = iter(iterable)
              a = next(iterator, None)

              for b in iterator:
                  yield a, b
                  a = b

     Added in version 3.10.

 -- の関数: itertools.permutations (iterable, r=None)

     Return successive 'r' length permutations of elements(2) from the
     'iterable'.

     'r' が指定されない場合や ‘None’ の場合、'r' はデフォルトで
     'iterable' の長さとなり、可能な最長の順列の全てが生成されます。

     The output is a subsequence of *note product(): 12e2. where entries
     with repeated elements have been filtered out.  The length of the
     output is given by *note math.perm(): 69c. which computes ‘n! / (n
     - r)!’ when ‘0 ≤ r ≤ n’ or zero when ‘r > n’.

     The permutation tuples are emitted in lexicographic order according
     to the order of the input 'iterable'.  If the input 'iterable' is
     sorted, the output tuples will be produced in sorted order.

     Elements are treated as unique based on their position, not on
     their value.  If the input elements are unique, there will be no
     repeated values within a permutation.

     およそ次と等価です:

          def permutations(iterable, r=None):
              # permutations('ABCD', 2) → AB AC AD BA BC BD CA CB CD DA DB DC
              # permutations(range(3)) → 012 021 102 120 201 210

              pool = tuple(iterable)
              n = len(pool)
              r = n if r is None else r
              if r > n:
                  return

              indices = list(range(n))
              cycles = list(range(n, n-r, -1))
              yield tuple(pool[i] for i in indices[:r])

              while n:
                  for i in reversed(range(r)):
                      cycles[i] -= 1
                      if cycles[i] == 0:
                          indices[i:] = indices[i+1:] + indices[i:i+1]
                          cycles[i] = n - i
                      else:
                          j = cycles[i]
                          indices[i], indices[-j] = indices[-j], indices[i]
                          yield tuple(pool[i] for i in indices[:r])
                          break
                  else:
                      return

 -- の関数: itertools.product (*iterables, repeat=1)

     Cartesian product(3) of the input iterables.

     ジェネレータ式の入れ子になった for ループとおよそ等価です。たとえば
     ‘product(A, B)’ は ‘((x,y) for x in A for y in B)’ と同じものを返し
     ます。

     入れ子ループは走行距離計と同じように右端の要素がイテレーションごと
     に更新されていきます。このパターンは辞書式順序を作り出し、入力のイ
     テレート可能オブジェクトたちがソートされていれば、直積タプルもソー
     トされた順に出てきます。

     イテラブル自身との直積を計算するためには、オプションの 'repeat' キ
     ーワード引数に繰り返し回数を指定します。たとえば ‘product(A,
     repeat=4)’ は ‘product(A, A, A, A)’ と同じ意味です。

     この関数は以下のコードとおよそ等価ですが、実際の実装ではメモリ中に
     中間結果を作りません:

          def product(*iterables, repeat=1):
              # product('ABCD', 'xy') → Ax Ay Bx By Cx Cy Dx Dy
              # product(range(2), repeat=3) → 000 001 010 011 100 101 110 111

              if repeat < 0:
                  raise ValueError('repeat argument cannot be negative')
              pools = [tuple(pool) for pool in iterables] * repeat

              result = [[]]
              for pool in pools:
                  result = [x+[y] for x in result for y in pool]

              for prod in result:
                  yield tuple(prod)

     *note product(): 12e2. は動作する前に、入力のイテラブルを完全に読み
     取り、直積を生成するためにメモリ内に値を蓄えます。したがって、入力
     が有限の場合に限り有用です。

 -- の関数: itertools.repeat (object[, times])

     Make an iterator that returns 'object' over and over again.  Runs
     indefinitely unless the 'times' argument is specified.

     およそ次と等価です:

          def repeat(object, times=None):
              # repeat(10, 3) → 10 10 10
              if times is None:
                  while True:
                      yield object
              else:
                  for i in range(times):
                      yield object

     'repeat' は 'map' や 'zip' に定数のストリームを与えるためによく利用
     されます:

          >>> list(map(pow, range(10), repeat(2)))
          [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

 -- の関数: itertools.starmap (function, iterable)

     Make an iterator that computes the 'function' using arguments
     obtained from the 'iterable'.  Used instead of *note map(): 82f.
     when argument parameters have already been "pre-zipped" into
     tuples.

     The difference between *note map(): 82f. and *note starmap(): 10b5.
     parallels the distinction between ‘function(a,b)’ and
     ‘function(*c)’.  Roughly equivalent to:

          def starmap(function, iterable):
              # starmap(pow, [(2,5), (3,2), (10,3)]) → 32 9 1000
              for args in iterable:
                  yield function(*args)

 -- の関数: itertools.takewhile (predicate, iterable)

     Make an iterator that returns elements from the 'iterable' as long
     as the 'predicate' is true.  Roughly equivalent to:

          def takewhile(predicate, iterable):
              # takewhile(lambda x: x<5, [1,4,6,3,8]) → 1 4
              for x in iterable:
                  if not predicate(x):
                      break
                  yield x

     Note, the element that first fails the predicate condition is
     consumed from the input iterator and there is no way to access it.
     This could be an issue if an application wants to further consume
     the input iterator after 'takewhile' has been run to exhaustion.
     To work around this problem, consider using more-iterools
     before_and_after()(4) instead.

 -- の関数: itertools.tee (iterable, n=2)

     一つの iterable から 'n' 個の独立したイテレータを返します。

     およそ次と等価です:

          def tee(iterable, n=2):
              if n < 0:
                  raise ValueError
              if n == 0:
                  return ()
              iterator = _tee(iterable)
              result = [iterator]
              for _ in range(n - 1):
                  result.append(_tee(iterator))
              return tuple(result)

          class _tee:

              def __init__(self, iterable):
                  it = iter(iterable)
                  if isinstance(it, _tee):
                      self.iterator = it.iterator
                      self.link = it.link
                  else:
                      self.iterator = it
                      self.link = [None, None]

              def __iter__(self):
                  return self

              def __next__(self):
                  link = self.link
                  if link[1] is None:
                      link[0] = next(self.iterator)
                      link[1] = [None, None]
                  value, self.link = link
                  return value

     When the input 'iterable' is already a tee iterator object, all
     members of the return tuple are constructed as if they had been
     produced by the upstream *note tee(): 2681. call.  This "flattening
     step" allows nested *note tee(): 2681. calls to share the same
     underlying data chain and to have a single update step rather than
     a chain of calls.

     The flattening property makes tee iterators efficiently peekable:

          def lookahead(tee_iterator):
               "Return the next value without moving the input forward"
               [forked_iterator] = tee(tee_iterator, 1)
               return next(forked_iterator)

          >>> iterator = iter('abcdef')
          >>> [iterator] = tee(iterator, 1)   # Make the input peekable
          >>> next(iterator)                  # Move the iterator forward
          'a'
          >>> lookahead(iterator)             # Check next value
          'b'
          >>> next(iterator)                  # Continue moving forward
          'b'

     ‘tee’ iterators are not threadsafe.  A *note RuntimeError: 17a. may
     be raised when simultaneously using iterators returned by the same
     *note tee(): 2681. call, even if the original 'iterable' is
     threadsafe.

     *note tee(): 2681. はかなり大きなメモリ領域を使用するかもしれません
     (使用するメモリ量はiterableの大きさに依存します)。一般には、一つの
     イテレータが他のイテレータよりも先にほとんどまたは全ての要素を消費
     するような場合には、 *note tee(): 2681. よりも *note list(): 5dc. を
     使った方が高速です。

 -- の関数: itertools.zip_longest (*iterables, fillvalue=None)

     Make an iterator that aggregates elements from each of the
     'iterables'.

     If the iterables are of uneven length, missing values are filled-in
     with 'fillvalue'.  If not specified, 'fillvalue' defaults to
     ‘None’.

     Iteration continues until the longest iterable is exhausted.

     およそ次と等価です:

          def zip_longest(*iterables, fillvalue=None):
              # zip_longest('ABCD', 'xy', fillvalue='-') → Ax By C- D-

              iterators = list(map(iter, iterables))
              num_active = len(iterators)
              if not num_active:
                  return

              while True:
                  values = []
                  for i, iterator in enumerate(iterators):
                      try:
                          value = next(iterator)
                      except StopIteration:
                          num_active -= 1
                          if not num_active:
                              return
                          iterators[i] = repeat(fillvalue)
                          value = fillvalue
                      values.append(value)
                  yield tuple(values)

     If one of the iterables is potentially infinite, then the *note
     zip_longest(): 126e. function should be wrapped with something that
     limits the number of calls (for example *note islice(): b1a. or
     *note takewhile(): 2680.).

   ---------- Footnotes ----------

   (1) https://www.ramseysolutions.com/real-estate/amortization-schedule

   (2) https://www.britannica.com/science/permutation

   (3) https://en.wikipedia.org/wiki/Cartesian_product

   (4) 
https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.before_and_after


File: python.info,  Node: Itertools レシピ,  Prev: Itertool関数,  Up: itertools --- 効率的なループ用のイテレータ生成関数群

5.10.1.2 Itertools レシピ
.........................

この節では、既存の itertools を素材としてツールセットを拡張するためのレ
シピを示します。

The primary purpose of the itertools recipes is educational.  The
recipes show various ways of thinking about individual tools — for
example, that ‘chain.from_iterable’ is related to the concept of
flattening.  The recipes also give ideas about ways that the tools can
be combined — for example, how ‘starmap()’ and ‘repeat()’ can work
together.  The recipes also show patterns for using itertools with the
*note operator: 8f. and *note collections: 16. modules as well as with
the built-in itertools such as ‘map()’, ‘filter()’, ‘reversed()’, and
‘enumerate()’.

A secondary purpose of the recipes is to serve as an incubator.  The
‘accumulate()’, ‘compress()’, and ‘pairwise()’ itertools started out as
recipes.  Currently, the ‘sliding_window()’, ‘iter_index()’, and
‘sieve()’ recipes are being tested to see whether they prove their
worth.

Substantially all of these recipes and many, many others can be
installed from the more-itertools(1) project found on the Python Package
Index:

     python -m pip install more-itertools

Many of the recipes offer the same high performance as the underlying
toolset.  Superior memory performance is kept by processing elements one
at a time rather than bringing the whole iterable into memory all at
once.  Code volume is kept small by linking the tools together in a
functional style(2).  High speed is retained by preferring "vectorized"
building blocks over the use of for-loops and *note generators: 1035.
which incur interpreter overhead.

     import collections
     import contextlib
     import functools
     import math
     import operator
     import random

     def take(n, iterable):
         "Return first n items of the iterable as a list."
         return list(islice(iterable, n))

     def prepend(value, iterable):
         "Prepend a single value in front of an iterable."
         # prepend(1, [2, 3, 4]) → 1 2 3 4
         return chain([value], iterable)

     def tabulate(function, start=0):
         "Return function(0), function(1), ..."
         return map(function, count(start))

     def repeatfunc(func, times=None, *args):
         "Repeat calls to func with specified arguments."
         if times is None:
             return starmap(func, repeat(args))
         return starmap(func, repeat(args, times))

     def flatten(list_of_lists):
         "Flatten one level of nesting."
         return chain.from_iterable(list_of_lists)

     def ncycles(iterable, n):
         "Returns the sequence elements n times."
         return chain.from_iterable(repeat(tuple(iterable), n))

     def tail(n, iterable):
         "Return an iterator over the last n items."
         # tail(3, 'ABCDEFG') → E F G
         return iter(collections.deque(iterable, maxlen=n))

     def consume(iterator, n=None):
         "Advance the iterator n-steps ahead. If n is None, consume entirely."
         # Use functions that consume iterators at C speed.
         if n is None:
             collections.deque(iterator, maxlen=0)
         else:
             next(islice(iterator, n, n), None)

     def nth(iterable, n, default=None):
         "Returns the nth item or a default value."
         return next(islice(iterable, n, None), default)

     def quantify(iterable, predicate=bool):
         "Given a predicate that returns True or False, count the True results."
         return sum(map(predicate, iterable))

     def first_true(iterable, default=False, predicate=None):
         "Returns the first true value or the *default* if there is no true value."
         # first_true([a,b,c], x) → a or b or c or x
         # first_true([a,b], x, f) → a if f(a) else b if f(b) else x
         return next(filter(predicate, iterable), default)

     def all_equal(iterable, key=None):
         "Returns True if all the elements are equal to each other."
         # all_equal('4٤௪౪໔', key=int) → True
         return len(take(2, groupby(iterable, key))) <= 1

     def unique_justseen(iterable, key=None):
         "Yield unique elements, preserving order. Remember only the element just seen."
         # unique_justseen('AAAABBBCCDAABBB') → A B C D A B
         # unique_justseen('ABBcCAD', str.casefold) → A B c A D
         if key is None:
             return map(operator.itemgetter(0), groupby(iterable))
         return map(next, map(operator.itemgetter(1), groupby(iterable, key)))

     def unique_everseen(iterable, key=None):
         "Yield unique elements, preserving order. Remember all elements ever seen."
         # unique_everseen('AAAABBBCCDAABBB') → A B C D
         # unique_everseen('ABBcCAD', str.casefold) → A B c D
         seen = set()
         if key is None:
             for element in filterfalse(seen.__contains__, iterable):
                 seen.add(element)
                 yield element
         else:
             for element in iterable:
                 k = key(element)
                 if k not in seen:
                     seen.add(k)
                     yield element

     def unique(iterable, key=None, reverse=False):
        "Yield unique elements in sorted order. Supports unhashable inputs."
        # unique([[1, 2], [3, 4], [1, 2]]) → [1, 2] [3, 4]
        return unique_justseen(sorted(iterable, key=key, reverse=reverse), key=key)

     def sliding_window(iterable, n):
         "Collect data into overlapping fixed-length chunks or blocks."
         # sliding_window('ABCDEFG', 4) → ABCD BCDE CDEF DEFG
         iterator = iter(iterable)
         window = collections.deque(islice(iterator, n - 1), maxlen=n)
         for x in iterator:
             window.append(x)
             yield tuple(window)

     def grouper(iterable, n, *, incomplete='fill', fillvalue=None):
         "Collect data into non-overlapping fixed-length chunks or blocks."
         # grouper('ABCDEFG', 3, fillvalue='x') → ABC DEF Gxx
         # grouper('ABCDEFG', 3, incomplete='strict') → ABC DEF ValueError
         # grouper('ABCDEFG', 3, incomplete='ignore') → ABC DEF
         iterators = [iter(iterable)] * n
         match incomplete:
             case 'fill':
                 return zip_longest(*iterators, fillvalue=fillvalue)
             case 'strict':
                 return zip(*iterators, strict=True)
             case 'ignore':
                 return zip(*iterators)
             case _:
                 raise ValueError('Expected fill, strict, or ignore')

     def roundrobin(*iterables):
         "Visit input iterables in a cycle until each is exhausted."
         # roundrobin('ABC', 'D', 'EF') → A D E B F C
         # Algorithm credited to George Sakkis
         iterators = map(iter, iterables)
         for num_active in range(len(iterables), 0, -1):
             iterators = cycle(islice(iterators, num_active))
             yield from map(next, iterators)

     def subslices(seq):
         "Return all contiguous non-empty subslices of a sequence."
         # subslices('ABCD') → A AB ABC ABCD B BC BCD C CD D
         slices = starmap(slice, combinations(range(len(seq) + 1), 2))
         return map(operator.getitem, repeat(seq), slices)

     def iter_index(iterable, value, start=0, stop=None):
         "Return indices where a value occurs in a sequence or iterable."
         # iter_index('AABCADEAF', 'A') → 0 1 4 7
         seq_index = getattr(iterable, 'index', None)
         if seq_index is None:
             iterator = islice(iterable, start, stop)
             for i, element in enumerate(iterator, start):
                 if element is value or element == value:
                     yield i
         else:
             stop = len(iterable) if stop is None else stop
             i = start
             with contextlib.suppress(ValueError):
                 while True:
                     yield (i := seq_index(value, i, stop))
                     i += 1

     def iter_except(func, exception, first=None):
         "Convert a call-until-exception interface to an iterator interface."
         # iter_except(d.popitem, KeyError) → non-blocking dictionary iterator
         with contextlib.suppress(exception):
             if first is not None:
                 yield first()
             while True:
                 yield func()

The following recipes have a more mathematical flavor:

     def powerset(iterable):
         "powerset([1,2,3]) → () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
         s = list(iterable)
         return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

     def sum_of_squares(iterable):
         "Add up the squares of the input values."
         # sum_of_squares([10, 20, 30]) → 1400
         return math.sumprod(*tee(iterable))

     def reshape(matrix, cols):
         "Reshape a 2-D matrix to have a given number of columns."
         # reshape([(0, 1), (2, 3), (4, 5)], 3) →  (0, 1, 2), (3, 4, 5)
         return batched(chain.from_iterable(matrix), cols, strict=True)

     def transpose(matrix):
         "Swap the rows and columns of a 2-D matrix."
         # transpose([(1, 2, 3), (11, 22, 33)]) → (1, 11) (2, 22) (3, 33)
         return zip(*matrix, strict=True)

     def matmul(m1, m2):
         "Multiply two matrices."
         # matmul([(7, 5), (3, 5)], [(2, 5), (7, 9)]) → (49, 80), (41, 60)
         n = len(m2[0])
         return batched(starmap(math.sumprod, product(m1, transpose(m2))), n)

     def convolve(signal, kernel):
         """Discrete linear convolution of two iterables.
         Equivalent to polynomial multiplication.

         Convolutions are mathematically commutative; however, the inputs are
         evaluated differently.  The signal is consumed lazily and can be
         infinite. The kernel is fully consumed before the calculations begin.

         Article:  https://betterexplained.com/articles/intuitive-convolution/
         Video:    https://www.youtube.com/watch?v=KuXjwB4LzSA
         """
         # convolve([1, -1, -20], [1, -3]) → 1 -4 -17 60
         # convolve(data, [0.25, 0.25, 0.25, 0.25]) → Moving average (blur)
         # convolve(data, [1/2, 0, -1/2]) → 1st derivative estimate
         # convolve(data, [1, -2, 1]) → 2nd derivative estimate
         kernel = tuple(kernel)[::-1]
         n = len(kernel)
         padded_signal = chain(repeat(0, n-1), signal, repeat(0, n-1))
         windowed_signal = sliding_window(padded_signal, n)
         return map(math.sumprod, repeat(kernel), windowed_signal)

     def polynomial_from_roots(roots):
         """Compute a polynomial's coefficients from its roots.

            (x - 5) (x + 4) (x - 3)  expands to:   x³ -4x² -17x + 60
         """
         # polynomial_from_roots([5, -4, 3]) → [1, -4, -17, 60]
         factors = zip(repeat(1), map(operator.neg, roots))
         return list(functools.reduce(convolve, factors, [1]))

     def polynomial_eval(coefficients, x):
         """Evaluate a polynomial at a specific value.

         Computes with better numeric stability than Horner's method.
         """
         # Evaluate x³ -4x² -17x + 60 at x = 5
         # polynomial_eval([1, -4, -17, 60], x=5) → 0
         n = len(coefficients)
         if not n:
             return type(x)(0)
         powers = map(pow, repeat(x), reversed(range(n)))
         return math.sumprod(coefficients, powers)

     def polynomial_derivative(coefficients):
         """Compute the first derivative of a polynomial.

            f(x)  =  x³ -4x² -17x + 60
            f'(x) = 3x² -8x  -17
         """
         # polynomial_derivative([1, -4, -17, 60]) → [3, -8, -17]
         n = len(coefficients)
         powers = reversed(range(1, n))
         return list(map(operator.mul, coefficients, powers))

     def sieve(n):
         "Primes less than n."
         # sieve(30) → 2 3 5 7 11 13 17 19 23 29
         if n > 2:
             yield 2
         data = bytearray((0, 1)) * (n // 2)
         for p in iter_index(data, 1, start=3, stop=math.isqrt(n) + 1):
             data[p*p : n : p+p] = bytes(len(range(p*p, n, p+p)))
         yield from iter_index(data, 1, start=3)

     def factor(n):
         "Prime factors of n."
         # factor(99) → 3 3 11
         # factor(1_000_000_000_000_007) → 47 59 360620266859
         # factor(1_000_000_000_000_403) → 1000000000000403
         for prime in sieve(math.isqrt(n) + 1):
             while not n % prime:
                 yield prime
                 n //= prime
                 if n == 1:
                     return
         if n > 1:
             yield n

     def totient(n):
         "Count of natural numbers up to n that are coprime to n."
         # https://mathworld.wolfram.com/TotientFunction.html
         # totient(12) → 4 because len([1, 5, 7, 11]) == 4
         for prime in set(factor(n)):
             n -= n // prime
         return n

   ---------- Footnotes ----------

   (1) https://pypi.org/project/more-itertools/

   (2) https://www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf


File: python.info,  Node: functools --- 高階関数と呼び出し可能オブジェクトの操作,  Next: operator --- 関数形式の標準演算子,  Prev: itertools --- 効率的なループ用のイテレータ生成関数群,  Up: 関数型プログラミング用モジュール

5.10.2 ‘functools’ -- 高階関数と呼び出し可能オブジェクトの操作
--------------------------------------------------------------

'ソースコード:' Lib/functools.py(1)

__________________________________________________________________

*note functools: 55. モジュールは高階関数、つまり関数に影響を及ぼしたり
他の関数を返したりする関数のためのものです。一般に、どんな呼び出し可能オ
ブジェクトでもこのモジュールの目的には関数として扱えます。

モジュール *note functools: 55. は以下の関数を定義します:

 -- の関数: @functools.cache (user_function)

     簡単で軽量な無制限の関数キャッシュです。 "メモ化 (memoize)"(2) とも
     呼ばれることがあります。

     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 *note lru_cache(): 9bd. with a size limit.

     例えば:

          @cache
          def factorial(n):
              return n * factorial(n-1) if n else 1

          >>> factorial(10)      # no previously cached result, makes 11 recursive calls
          3628800
          >>> factorial(5)       # just looks up cached value result
          120
          >>> factorial(12)      # makes two new recursive calls, the other 10 are cached
          479001600

     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.

     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.

     Added in version 3.9.

 -- の関数: @functools.cached_property (func)

     クラスのメソッドを、値を一度だけ計算して通常の属性としてキャッシュ
     するプロパティに変換します。キャッシュはインスタンスの生存期間にわ
     たって有効です。*note property(): 179. に似ていて、さらにキャッシュ
     を行います。計算コストが高く、一度計算すればその後は不変であるよう
     なインスタンスのプロパティに対して有用です。

     以下はプログラム例です:

          class DataSet:

              def __init__(self, sequence_of_numbers):
                  self._data = tuple(sequence_of_numbers)

              @cached_property
              def stdev(self):
                  return statistics.stdev(self._data)

     *note cached_property(): 50c. のしくみは *note property(): 179. と
     やや異なります。通常のプロパティは、セッター (setter) が定義されな
     い限り書き込みを禁止します。対照的に、 'cached_property' は書き込み
     を許します。

     'cached_property' デコレータはルックアップテーブルで、同名の属性が
     存在しない場合のみ動作します。動作した場合、 'cached_property' は同
     名の属性に書き込みを行います。その後の属性の読み込みと書き込みは
     'cached_property' メソッドより優先され、通常の属性のように働きます
     。

     キャッシュされた値は属性を削除することで取り除くことができます。こ
     れにより 'cached_property' メソッドを再度実行することが可能になりま
     す。

     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 instance, with the latest run setting the cached value.
     If the cached property is idempotent or otherwise not harmful to
     run more than once on an instance, this is fine.  If
     synchronization is needed, implement the necessary locking inside
     the decorated getter function or around the cached property access.

     このデコレータは PEP 412(3) のキー共有辞書のインターフェースを持ち
     ます。これは、インスタンス辞書がより多くのスペースを使う可能性があ
     ることを意味します。

     また、このデコレータは各インスタンスの ‘__dict__’ 属性が可変のマッ
     ピングであることを要求します。すなわち、このデコレータはいくつかの
     型、たとえばメタクラス (型インスタンスの ‘__dict__’ 属性はクラスの
     名前空間に対する読み込み専用のプロキシであるため) や、 ‘__slots__’
     を指定していてその中に ‘__dict__’ を含まない型 (それ自体が
     ‘__dict__’ 属性を提供しないため) に対しては動作しないことを意味しま
     す。

     If a mutable mapping is not available or if space-efficient key
     sharing is desired, an effect similar to *note cached_property():
     50c. can also be achieved by stacking *note property(): 179. on top
     of *note lru_cache(): 9bd.  See *note
     メソッド呼び出しをキャッシュするには どうしたらいいですか？: 2688.
     for more details on how this differs from *note cached_property():
     50c.

     Added in version 3.8.

     バージョン 3.12 で変更: Prior to Python 3.12, ‘cached_property’
     included an undocumented lock to ensure that in multi-threaded
     usage the getter function was guaranteed to run only once per
     instance.  However, the lock was per-property, not per-instance,
     which could result in unacceptably high lock contention.  In Python
     3.12+ this locking is removed.

 -- の関数: functools.cmp_to_key (func)

     古いスタイルの比較関数を *note key function: dd2. に変換します。key
     関数を受け取るツール (*note sorted(): b9c, *note min(): ed3, *note
     max(): ed4, *note heapq.nlargest(): 2488, *note heapq.nsmallest():
     2489, *note itertools.groupby(): 267f. など) と共に使用します。この
     関数は、主に比較関数を使っていた Python 2 からプログラムの移行のた
     めの変換ツールとして使われます。

     比較関数は2つの引数を受け取り、それらを比較し、 "より小さい" 場合は
     負の数を、同値の場合には 0 を、 "より大きい" 場合には正の数を返す、
     あらゆる呼び出し可能オブジェクトです。key 関数は呼び出し可能オブジ
     ェクトで、1つの引数を受け取り、ソートキーとして使われる値を返します
     。

     以下はプログラム例です:

          sorted(iterable, key=cmp_to_key(locale.strcoll))  # locale-aware sort order

     ソートの例と簡単なチュートリアルは *note ソートのテクニック: 11ab.
     を参照して下さい。

     Added in version 3.2.

 -- の関数: @functools.lru_cache (user_function)

 -- の関数: @functools.lru_cache (maxsize=128, typed=False)

     関数をメモ化用の呼び出し可能オブジェクトでラップし、最近の呼び出し
     最大 'maxsize' 回まで保存するするデコレータです。高価な関数や I/O に
     束縛されている関数を定期的に同じ引数で呼び出すときに、時間を節約で
     きます。

     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.

     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.

     結果のキャッシュには辞書が使われるので、関数の位置引数およびキーワ
     ード引数は *note ハッシュ可能: 5db. でなくてはなりません。

     引数のパターンが異なる場合は、異なる呼び出しと見なされ別々のキャッ
     シュエントリーとなります。 例えば、 ‘f(a=1, b=2)’ と ‘f(b=2, a=1)’
     はキーワード引数の順序が異なっているので、2つの別個のキャッシュエン
     トリーになります。

     'user_function' が指定された場合、それは呼び出し可能でなければなり
     ません。これにより 'lru_cache' デコレータがユーザー関数に直接適用で
     きるようになります。このとき 'maxsize' の値はデフォルトの 128 とな
     ります:

          @lru_cache
          def count_vowels(sentence):
              return sum(sentence.count(vowel) for vowel in 'AEIOUaeiou')

     'maxsize' が ‘None’ に設定された場合は、LRU 機能は無効化され、キャ
     ッシュは際限無く大きくなります。

     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.)

     Note, type specificity applies only to the function's immediate
     arguments rather than their contents.  The scalar arguments,
     ‘Decimal(42)’ and ‘Fraction(42)’ are be treated as distinct calls
     with distinct results.  In contrast, the tuple arguments
     ‘('answer', Decimal(42))’ and ‘('answer', Fraction(42))’ are
     treated as equivalent.

     The wrapped function is instrumented with a ‘cache_parameters()’
     function that returns a new *note dict: 237. showing the values for
     'maxsize' and 'typed'.  This is for information purposes only.
     Mutating the values has no effect.

     キャッシュ効率の測定や 'maxsize' パラメータの調整をしやすくするため
     、ラップされた関数には ‘cache_info()’ 関数が追加されます。この関数
     は 'hits', 'misses', 'maxsize', 'currsize' を示す *note named
     tuple: 61a. を返します。

     このデコレータは、キャッシュの削除と無効化のための ‘cache_clear()’
     関数も提供します。

     元々の基底の関数には、 ‘__wrapped__’ 属性を通してアクセスできます。
     これはキャッシュを回避して、または関数を別のキャッシュでラップして
     、内観するのに便利です。

     The cache keeps references to the arguments and return values until
     they age out of the cache or until the cache is cleared.

     If a method is cached, the ‘self’ instance argument is included in
     the cache.  See *note メソッド呼び出しをキャッシュするには
     どうしたらいいですか？: 2688.

     An LRU (least recently used) cache(4) works best when the most
     recent calls are the best predictors of upcoming calls (for
     example, the most popular articles on a news server tend to change
     each day).  The cache's size limit assures that the cache does not
     grow without bound on long-running processes such as web servers.

     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 functions with side-effects, functions that need to
     create distinct mutable objects on each call (such as generators
     and async functions), or impure functions such as time() or
     random().

     静的 web コンテンツ の LRU キャッシュの例:

          @lru_cache(maxsize=32)
          def get_pep(num):
              'Retrieve text of a Python Enhancement Proposal'
              resource = f'https://peps.python.org/pep-{num:04d}'
              try:
                  with urllib.request.urlopen(resource) as s:
                      return s.read()
              except urllib.error.HTTPError:
                  return 'Not Found'

          >>> for n in 8, 290, 308, 320, 8, 218, 320, 279, 289, 320, 9991:
          ...     pep = get_pep(n)
          ...     print(n, len(pep))

          >>> get_pep.cache_info()
          CacheInfo(hits=3, misses=8, maxsize=32, currsize=8)

     キャッシュを使って 動的計画法(5) の技法を実装し、フィボナッチ数(6)
     を効率よく計算する例:

          @lru_cache(maxsize=None)
          def fib(n):
              if n < 2:
                  return n
              return fib(n-1) + fib(n-2)

          >>> [fib(n) for n in range(16)]
          [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]

          >>> fib.cache_info()
          CacheInfo(hits=28, misses=16, maxsize=None, currsize=16)

     Added in version 3.2.

     バージョン 3.3 で変更: 'typed' オプションが追加されました。

     バージョン 3.8 で変更: 'user_function' オプションが追加されました。

     バージョン 3.9 で変更: Added the function ‘cache_parameters()’

 -- の関数: @functools.total_ordering

     ひとつ以上の拡張順序比較メソッド (rich comparison ordering methods)
     を定義したクラスを受け取り、残りを実装するクラスデコレータです。こ
     のデコレータは全ての拡張順序比較演算をサポートするための労力を軽減
     します:

     引数のクラスは、 ‘__lt__()’, ‘__le__()’, ‘__gt__()’, ‘__ge__()’ の
     中からどれか1つと、 ‘__eq__()’ メソッドを定義する必要があります。

     例えば:

          @total_ordering
          class Student:
              def _is_valid_operand(self, other):
                  return (hasattr(other, "lastname") and
                          hasattr(other, "firstname"))
              def __eq__(self, other):
                  if not self._is_valid_operand(other):
                      return NotImplemented
                  return ((self.lastname.lower(), self.firstname.lower()) ==
                          (other.lastname.lower(), other.firstname.lower()))
              def __lt__(self, other):
                  if not self._is_valid_operand(other):
                      return NotImplemented
                  return ((self.lastname.lower(), self.firstname.lower()) <
                          (other.lastname.lower(), other.firstname.lower()))

          注釈: このデコレータにより、完全に順序の付いた振る舞いの良い型
          を簡単に作ることができますが、実行速度は遅くなり、派生した比較
          メソッドのスタックトレースは複雑になります。性能ベンチマークに
          より、これがアプリケーションのボトルネックになっていることがわ
          かった場合は、代わりに 6 つの拡張比較メソッドをすべて実装すれ
          ば、簡単にスピードアップを図れるでしょう。

          注釈: 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.

     Added in version 3.2.

     バージョン 3.4 で変更: Returning ‘NotImplemented’ from the
     underlying comparison function for unrecognised types is now
     supported.

 -- の関数: functools.partial (func, /, *args, **keywords)

     新しい *note partial オブジェクト: 2689. を返します。このオブジェク
     トは呼び出されると位置引数 'args' とキーワード引数 'keywords' 付き
     で呼び出された 'func' のように振る舞います。呼び出しに際してさらな
     る引数が渡された場合、それらは 'args' に付け加えられます。追加のキ
     ーワード引数が渡された場合には、それらで 'keywords' を拡張または上
     書きします。おおよそ次のコードと等価です:

          def partial(func, /, *args, **keywords):
              def newfunc(*fargs, **fkeywords):
                  newkeywords = {**keywords, **fkeywords}
                  return func(*args, *fargs, **newkeywords)
              newfunc.func = func
              newfunc.args = args
              newfunc.keywords = keywords
              return newfunc

     関数 *note partial(): 3ed. は、関数の位置引数・キーワード引数の一部
     を「凍結」した部分適用として使われ、簡素化された引数形式をもった新
     たなオブジェクトを作り出します。例えば、 *note partial(): 3ed. を使
     って 'base' 引数のデフォルトが 2 である *note int(): 238. 関数のよ
     うに振る舞う呼び出し可能オブジェクトを作ることができます:

          >>> from functools import partial
          >>> basetwo = partial(int, base=2)
          >>> basetwo.__doc__ = 'Convert base 2 string to an int.'
          >>> basetwo('10010')
          18

 -- クラス: functools.partialmethod (func, /, *args, **keywords)

     *note partial: 3ed. と似た動作をする新しい *note partialmethod:
     a49. 記述子 (デスクリプタ) を返します。直接呼び出しではなく、メソッ
     ド定義としての使用が目的であることのみが、partial とは異なります。

     'func' は、*note descriptor: 1ed1. または呼び出し可能オブジェクトで
     ある必要があります (通常の関数など、両方の性質を持つオブジェクトは
     記述子として扱われます。)

     'func' が記述子 (Python の通常の関数、 *note classmethod(): 14c.、
     *note staticmethod(): 3ef.、‘abstractmethod()’ または別の *note
     partialmethod: a49. のインスタンスなど) の場合、 ‘__get__’ への呼び
     出しは下層の記述子に委譲され、返り値として適切な *note partial
     オブジェクト: 2689. が返されます。

     'func' が記述子以外の呼び出し可能オブジェクトである場合、適切な束縛
     メソッドが動的に作成されます。この func は、メソッドとして使用され
     た場合、Python の通常の関数と同様に動作します。 *note
     partialmethod: a49. コンストラクタに 'args' と 'keywords' が渡され
     るよりも前に、 'self' 引数が最初の位置引数として挿入されます。

     以下はプログラム例です:

          >>> class Cell:
          ...     def __init__(self):
          ...         self._alive = False
          ...     @property
          ...     def alive(self):
          ...         return self._alive
          ...     def set_state(self, state):
          ...         self._alive = bool(state)
          ...     set_alive = partialmethod(set_state, True)
          ...     set_dead = partialmethod(set_state, False)
          ...
          >>> c = Cell()
          >>> c.alive
          False
          >>> c.set_alive()
          >>> c.alive
          True

     Added in version 3.4.

 -- の関数: functools.reduce (function, iterable[, initial], /)

     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 example, ‘reduce(lambda x, y: x+y, [1, 2, 3, 4,
     5])’ calculates ‘((((1+2)+3)+4)+5)’.  The left argument, 'x', is
     the accumulated value and the right argument, 'y', is the update
     value from the 'iterable'.  If the optional 'initial' is present,
     it is placed before the items of the iterable in the calculation,
     and serves as a default when the iterable is empty.  If 'initial'
     is not given and 'iterable' contains only one item, the first item
     is returned.

     およそ次と等価です:

          initial_missing = object()

          def reduce(function, iterable, initial=initial_missing, /):
              it = iter(iterable)
              if initial is initial_missing:
                  value = next(it)
              else:
                  value = initial
              for element in it:
                  value = function(value, element)
              return value

     全ての中間値を返すイテレータについては *note
     itertools.accumulate(): 9cb. を参照してください。

 -- の関数: @functools.singledispatch

     関数を *note シングルディスパッチ: 9be. *note ジェネリック関数:
     9bf. に変換します。

     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:

          >>> from functools import singledispatch
          >>> @singledispatch
          ... def fun(arg, verbose=False):
          ...     if verbose:
          ...         print("Let me just say,", end=" ")
          ...     print(arg)

     関数にオーバーロード実装を追加するには、デコレータとして使用できる
     、ジェネリック関数の ‘register()’ 属性を使用します。 型アノテーショ
     ンが付いている関数については、このデコレータは1つ目の引数の型を自動
     的に推測します。

          >>> @fun.register
          ... def _(arg: int, verbose=False):
          ...     if verbose:
          ...         print("Strength in numbers, eh?", end=" ")
          ...     print(arg)
          ...
          >>> @fun.register
          ... def _(arg: list, verbose=False):
          ...     if verbose:
          ...         print("Enumerate this:")
          ...     for i, elem in enumerate(arg):
          ...         print(i, elem)

     *note types.UnionType: 606. and *note typing.Union: 607. can also
     be used:

          >>> @fun.register
          ... def _(arg: int | float, verbose=False):
          ...     if verbose:
          ...         print("Strength in numbers, eh?", end=" ")
          ...     print(arg)
          ...
          >>> from typing import Union
          >>> @fun.register
          ... def _(arg: Union[list, set], verbose=False):
          ...     if verbose:
          ...         print("Enumerate this:")
          ...     for i, elem in enumerate(arg):
          ...         print(i, elem)
          ...

     型アノテーションを使っていないコードについては、デコレータに適切な
     型引数を明示的に渡せます:

          >>> @fun.register(complex)
          ... def _(arg, verbose=False):
          ...     if verbose:
          ...         print("Better than complicated.", end=" ")
          ...     print(arg.real, arg.imag)
          ...

     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:

          >>> @fun.register(list)
          ... def _(arg: list[int], verbose=False):
          ...     if verbose:
          ...         print("Enumerate this:")
          ...     for i, elem in enumerate(arg):
          ...         print(i, elem)

          注釈: 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.

     ‘register()’ 属性を関数形式で使用すると、*note lambda: 268a. 関数と
     既存の関数の登録を有効にできます:

          >>> def nothing(arg, verbose=False):
          ...     print("Nothing.")
          ...
          >>> fun.register(type(None), nothing)

     The ‘register()’ attribute returns the undecorated function.  This
     enables decorator stacking, *note pickling: 95, and the creation of
     unit tests for each variant independently:

          >>> @fun.register(float)
          ... @fun.register(Decimal)
          ... def fun_num(arg, verbose=False):
          ...     if verbose:
          ...         print("Half of your number:", end=" ")
          ...     print(arg / 2)
          ...
          >>> fun_num is fun
          False

     汎用関数は、呼び出されると 1 つ目の引数の型でディスパッチします:

          >>> fun("Hello, world.")
          Hello, world.
          >>> fun("test.", verbose=True)
          Let me just say, test.
          >>> fun(42, verbose=True)
          Strength in numbers, eh? 42
          >>> fun(['spam', 'spam', 'eggs', 'spam'], verbose=True)
          Enumerate this:
          0 spam
          1 spam
          2 eggs
          3 spam
          >>> fun(None)
          Nothing.
          >>> fun(1.23)
          0.615

     特定の型について登録された実装が存在しない場合、その型のメソッド解
     決順序が、汎用の実装をさらに検索するために使用されます。
     ‘@singledispatch’ でデコレートされた元の関数は基底の *note object:
     a5a. 型に登録されます。これは、他によりよい実装が見つからないことを
     意味します。

     抽象基底クラス (*note abstract base class: 1186.) に対して実装が登
     録されると、基底クラスの仮想サブクラスに対してもその実装がディスパ
     ッチされます:

          >>> from collections.abc import Mapping
          >>> @fun.register
          ... def _(arg: Mapping, verbose=False):
          ...     if verbose:
          ...         print("Keys & Values")
          ...     for key, value in arg.items():
          ...         print(key, "=>", value)
          ...
          >>> fun({"a": "b"})
          a => b

     指定された型に対して、汎用関数がどの実装を選択するかを確認するには
     、‘dispatch()’ 属性を使用します:

          >>> fun.dispatch(float)
          <function fun_num at 0x1035a2840>
          >>> fun.dispatch(dict)    # note: default implementation
          <function fun at 0x103fe0000>

     登録されたすべての実装にアクセスするには、読み出し専用の ‘registry’
     属性を使用します:

          >>> fun.registry.keys()
          dict_keys([<class 'NoneType'>, <class 'int'>, <class 'object'>,
                    <class 'decimal.Decimal'>, <class 'list'>,
                    <class 'float'>])
          >>> fun.registry[float]
          <function fun_num at 0x1035a2840>
          >>> fun.registry[object]
          <function fun at 0x103fe0000>

     Added in version 3.4.

     バージョン 3.7 で変更: ‘register()’ 属性が型アノテーションの使用を
     サポートするようになりました。

     バージョン 3.11 で変更: The ‘register()’ attribute now supports
     *note types.UnionType: 606. and *note typing.Union: 607. as type
     annotations.

 -- クラス: functools.singledispatchmethod (func)

     メソッドを *note シングルディスパッチ: 9be. *note ジェネリック関数:
     9bf. に変換します。

     To define a generic method, decorate it with the
     ‘@singledispatchmethod’ decorator.  When defining a function using
     ‘@singledispatchmethod’, note that the dispatch happens on the type
     of the first non-'self' or non-'cls' argument:

          class Negator:
              @singledispatchmethod
              def neg(self, arg):
                  raise NotImplementedError("Cannot negate a")

              @neg.register
              def _(self, arg: int):
                  return -arg

              @neg.register
              def _(self, arg: bool):
                  return not arg

     ‘@singledispatchmethod’ は *note @classmethod: 14c. など他のデコレ
     ータとの入れ子構造をサポートします。 ‘dispatcher.register’ を可能に
     するためには、 ‘singledispatchmethod’ は入れ子構造の中で '最も外側'
     のデコレータでなければなりません。この ‘Negator’ クラスの例では、ク
     ラスのインスタンスにではなく、クラスに ‘neg’ メソッドが紐付きます:

          class Negator:
              @singledispatchmethod
              @classmethod
              def neg(cls, arg):
                  raise NotImplementedError("Cannot negate a")

              @neg.register
              @classmethod
              def _(cls, arg: int):
                  return -arg

              @neg.register
              @classmethod
              def _(cls, arg: bool):
                  return not arg

     同様のパターンが他の似たようなデコレータに対しても適用できます:
     *note @staticmethod: 3ef, *note @abstractmethod: 105b. など。

     Added in version 3.8.

 -- の関数: functools.update_wrapper (wrapper, wrapped,
          assigned=WRAPPER_ASSIGNMENTS, updated=WRAPPER_UPDATES)

     Update a 'wrapper' function to look like the 'wrapped' function.
     The optional arguments are tuples to specify which attributes of
     the original function are assigned directly to the matching
     attributes on the wrapper function and which attributes of the
     wrapper function are updated with the corresponding attributes from
     the original function.  The default values for these arguments are
     the module level constants ‘WRAPPER_ASSIGNMENTS’ (which assigns to
     the wrapper function's *note __module__: 1e5d, *note __name__:
     12a2, *note __qualname__: 1e5c, *note __annotations__: 11a8, *note
     __type_params__: 1e5f, and *note __doc__: 11a9, the documentation
     string) and ‘WRAPPER_UPDATES’ (which updates the wrapper function's
     *note __dict__: 12a0, i.e.  the instance dictionary).

     内観や別の目的 (例えば、 *note lru_cache(): 9bd. のようなキャッシュ
     するデコレータの回避) のために元の関数にアクセスできるように、この
     関数はラップされている関数を参照するラッパーに自動的に
     ‘__wrapped__’ 属性を追加します。

     この関数は主に関数を包んでラッパーを返す *note デコレータ: 6fc. 関
     数の中で使われるよう意図されています。もしラッパー関数がアップデー
     トされないとすると、返される関数のメタデータは元の関数の定義ではな
     くラッパー関数の定義を反映してしまい、これは通常あまり有益ではあり
     ません。

     *note update_wrapper(): fec. は、関数以外の呼び出し可能オブジェクト
     にも使えます。 'assigned' または 'updated' で指名され、ラップされる
     オブジェクトに存在しない属性は、すべて無視されます (すなわち、ラッ
     パー関数にそれらの属性を設定しようとは試みられません)。しかし、
     'updated' で指名された属性がラッパー関数自身に存在しないなら *note
     AttributeError: 326. が送出されます。

     バージョン 3.2 で変更: The ‘__wrapped__’ attribute is now
     automatically added.  The *note __annotations__: 11a8. attribute is
     now copied by default.  Missing attributes no longer trigger an
     *note AttributeError: 326.

     バージョン 3.4 で変更: ラップされた関数が ‘__wrapped__’ を定義して
     いない場合でも、 ‘__wrapped__’ が常にラップされた関数を参照するよう
     になりました。(bpo-17482(7) を参照)

     バージョン 3.12 で変更: The *note __type_params__: 1e5f. attribute
     is now copied by default.

 -- の関数: @functools.wraps (wrapped, assigned=WRAPPER_ASSIGNMENTS,
          updated=WRAPPER_UPDATES)

     これはラッパー関数を定義するときに *note update_wrapper(): fec. を
     関数デコレータとして呼び出す便宜関数です。これは
     ‘partial(update_wrapper, wrapped=wrapped, assigned=assigned,
     updated=updated)’ と等価です。例えば:

          >>> from functools import wraps
          >>> def my_decorator(f):
          ...     @wraps(f)
          ...     def wrapper(*args, **kwds):
          ...         print('Calling decorated function')
          ...         return f(*args, **kwds)
          ...     return wrapper
          ...
          >>> @my_decorator
          ... def example():
          ...     """Docstring"""
          ...     print('Called example function')
          ...
          >>> example()
          Calling decorated function
          Called example function
          >>> example.__name__
          'example'
          >>> example.__doc__
          'Docstring'

     このデコレータ・ファクトリを使用しないと、上の例中の関数の名前は
     ‘'wrapper'’ となり、元の ‘example()’ のドキュメンテーション文字列は
     失われてしまいます。

* Menu:

* partial オブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/functools.py

   (2) https://en.wikipedia.org/wiki/Memoization

   (3) https://peps.python.org/pep-0412/

   (4) 
https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_Recently_Used_(LRU)

   (5) https://ja.wikipedia.org/wiki/動的計画法

   (6) https://ja.wikipedia.org/wiki/フィボナッチ数

   (7) https://bugs.python.org/issue?@action=redirect&bpo=17482


File: python.info,  Node: partial オブジェクト,  Up: functools --- 高階関数と呼び出し可能オブジェクトの操作

5.10.2.1 ‘partial’ オブジェクト
...............................

*note partial: 3ed. オブジェクトは、 *note partial(): 3ed. 関数によって
作られる呼び出し可能オブジェクトです。オブジェクトには読み出し専用の属性
が三つあります:

 -- の属性: partial.func

     呼び出し可能オブジェクトまたは関数です。 *note partial: 3ed. オブジ
     ェクトの呼び出しは新しい引数とキーワードと共に *note func: 268c. に
     転送されます。

 -- の属性: partial.args

     最左の位置引数で、 *note partial: 3ed. オブジェクトの呼び出し時にそ
     の呼び出しの際の位置引数の前に追加されます。

 -- の属性: partial.keywords

     *note partial: 3ed. オブジェクトの呼び出し時に渡されるキーワード引
     数です。

*note partial: 3ed. objects are like *note function objects: 279. in
that they are callable, weak referenceable, and can have attributes.
There are some important differences.  For instance, the *note __name__:
12a2. and *note function.__doc__: 11a9. attributes are not created
automatically.  Also, *note partial: 3ed. objects defined in classes
behave like static methods and do not transform into bound methods
during instance attribute look-up.


File: python.info,  Node: operator --- 関数形式の標準演算子,  Prev: functools --- 高階関数と呼び出し可能オブジェクトの操作,  Up: 関数型プログラミング用モジュール

5.10.3 ‘operator’ -- 関数形式の標準演算子
-----------------------------------------

'ソースコード:' Lib/operator.py(1)

__________________________________________________________________

*note operator: 8f. モジュールは、Python の組み込み演算子に対応する効率
的な関数群を提供します。 例えば、 ‘operator.add(x, y)’ は式 ‘x+y’ と等価
です。 多くの関数名は、特殊メソッドに使われている名前から前後の二重アン
ダースコアを除いたものと同じです。 後方互換性のため、ほとんどの関数に二
重アンダースコアを付けたままのバージョンがあります。 簡潔さのために、二
重アンダースコアが無いバージョンの方が好まれます。

これらの関数は、オブジェクト比較、論理演算、数学演算、シーケンス演算をす
るものに分類されます。

オブジェクト比較関数は全てのオブジェクトで有効で、関数の名前はサポートす
る拡張比較演算子からとられています:

 -- の関数: operator.lt (a, b)
 -- の関数: operator.le (a, b)
 -- の関数: operator.eq (a, b)
 -- の関数: operator.ne (a, b)
 -- の関数: operator.ge (a, b)
 -- の関数: operator.gt (a, b)
 -- の関数: operator.__lt__ (a, b)
 -- の関数: operator.__le__ (a, b)
 -- の関数: operator.__eq__ (a, b)
 -- の関数: operator.__ne__ (a, b)
 -- の関数: operator.__ge__ (a, b)
 -- の関数: operator.__gt__ (a, b)

     'a' と 'b' の "拡張比較 (rich comparisons)" を行います。具体的には
     、 ‘lt(a, b)’ は ‘a < b’ 、 ‘le(a, b)’ は ‘a <= b’ 、 ‘eq(a, b)’ は
     ‘a == b’ 、 ‘ne(a, b)’ は ‘a != b’ 、 ‘gt(a, b)’ は ‘a > b’ 、そし
     て ‘ge(a, b)’ は ‘a >= b’ と等価です。これらの関数はどのような値を
     返してもよく、ブール値として解釈できてもできなくてもかまいません。
     拡張比較の詳細については *note 比較: 1fd1. を参照してください。

論理演算もまた全てのオブジェクトに対して適用でき、真理値判定、同一性判定
およびブール演算をサポートします:

 -- の関数: operator.not_ (obj)
 -- の関数: operator.__not__ (obj)

     *note not: 1fdb. 'obj' の結果を返します。(オブジェクトインスタンス
     には ‘__not__()’ メソッドは無いので注意してください; インタープリタ
     ーコアがこの演算を定義しているだけです。結果は *note __bool__():
     12a3. および *note __len__(): 1ec3. メソッドに影響されます。)

 -- の関数: operator.truth (obj)

     'obj' が真の場合 *note True: bdb. を返し、そうでない場合 *note
     False: b05. を返します。この関数は *note bool: 434. のコンストラク
     タ呼び出しと同等です。

 -- の関数: operator.is_ (a, b)

     ‘a is b’ を返します。オブジェクトの同一性を判定します。

 -- の関数: operator.is_not (a, b)

     ‘a is not b’ を返します。オブジェクトの同一性を判定します。

演算子で最も多いのは数学演算およびビット単位の演算です:

 -- の関数: operator.abs (obj)
 -- の関数: operator.__abs__ (obj)

     'obj' の絶対値を返します。

 -- の関数: operator.add (a, b)
 -- の関数: operator.__add__ (a, b)

     数値 'a' および 'b' について ‘a + b’ を返します。

 -- の関数: operator.and_ (a, b)
 -- の関数: operator.__and__ (a, b)

     'a' と 'b' のビット単位論理積を返します。

 -- の関数: operator.floordiv (a, b)
 -- の関数: operator.__floordiv__ (a, b)

     ‘a // b’ を返します。

 -- の関数: operator.index (a)
 -- の関数: operator.__index__ (a)

     整数に変換された 'a' を返します。‘a.__index__()’ と同等です。

     バージョン 3.10 で変更: 結果は常に厳密な *note int: 238. 型です。 以
     前は、結果は ‘int’ のサブクラスのインスタンスのこともありました。

 -- の関数: operator.inv (obj)
 -- の関数: operator.invert (obj)
 -- の関数: operator.__inv__ (obj)
 -- の関数: operator.__invert__ (obj)

     'obj' のビット単位反転を返します。‘~obj’ と同じです。

 -- の関数: operator.lshift (a, b)
 -- の関数: operator.__lshift__ (a, b)

     'a' の 'b' ビット左シフトを返します。

 -- の関数: operator.mod (a, b)
 -- の関数: operator.__mod__ (a, b)

     ‘a % b’ を返します。

 -- の関数: operator.mul (a, b)
 -- の関数: operator.__mul__ (a, b)

     数値 'a' および 'b' について ‘a * b’ を返します。

 -- の関数: operator.matmul (a, b)
 -- の関数: operator.__matmul__ (a, b)

     ‘a @ b’ を返します。

     Added in version 3.5.

 -- の関数: operator.neg (obj)
 -- の関数: operator.__neg__ (obj)

     負の 'obj' (‘-obj’) を返します。

 -- の関数: operator.or_ (a, b)
 -- の関数: operator.__or__ (a, b)

     'a' と 'b' のビット単位論理和を返します。

 -- の関数: operator.pos (obj)
 -- の関数: operator.__pos__ (obj)

     正の 'obj' (‘+obj’) を返します。

 -- の関数: operator.pow (a, b)
 -- の関数: operator.__pow__ (a, b)

     数値 'a' および 'b' について ‘a ** b’ を返します。

 -- の関数: operator.rshift (a, b)
 -- の関数: operator.__rshift__ (a, b)

     'a' の 'b' ビット右シフトを返します。

 -- の関数: operator.sub (a, b)
 -- の関数: operator.__sub__ (a, b)

     ‘a - b’ を返します。

 -- の関数: operator.truediv (a, b)
 -- の関数: operator.__truediv__ (a, b)

     2/3 が 0 ではなく 0.66 となるような ‘a / b’ を返します。 "真の" 除
     算としても知られています。

 -- の関数: operator.xor (a, b)
 -- の関数: operator.__xor__ (a, b)

     'a' および 'b' のビット単位排他的論理和を返します。

シーケンスを扱う演算子（いくつかの演算子はマッピングも扱います）には以下
のようなものがあります:

 -- の関数: operator.concat (a, b)
 -- の関数: operator.__concat__ (a, b)

     シーケンス 'a' および 'b' について ‘a + b’ を返します。

 -- の関数: operator.contains (a, b)
 -- の関数: operator.__contains__ (a, b)

     ‘b in a’ の判定結果を返します。被演算子が左右反転しているので注意し
     てください。

 -- の関数: operator.countOf (a, b)

     'a' の中に 'b' が出現する回数を返します。

 -- の関数: operator.delitem (a, b)
 -- の関数: operator.__delitem__ (a, b)

     'a' でインデクスが 'b' の値を削除します。

 -- の関数: operator.getitem (a, b)
 -- の関数: operator.__getitem__ (a, b)

     'a' でインデクスが 'b' の値を返します。

 -- の関数: operator.indexOf (a, b)

     'a' で最初に 'b' が出現する場所のインデクスを返します。

 -- の関数: operator.setitem (a, b, c)
 -- の関数: operator.__setitem__ (a, b, c)

     'a' でインデクスが 'b' の値を 'c' に設定します。

 -- の関数: operator.length_hint (obj, default=0)

     オブジェクト 'obj' の概算の長さを返します。最初に実際の長さを、次に
     *note object.__length_hint__(): ed7. を使って概算の長さを、そして最
     後にデフォルトの値を返そうとします。

     Added in version 3.4.

次の操作は呼び出し可能オブジェクト (callable) で動作します。

 -- の関数: operator.call (obj, /, *args, **kwargs)
 -- の関数: operator.__call__ (obj, /, *args, **kwargs)

     ‘obj(*args, **kwargs)’ を返します。

     Added in version 3.11.

*note operator: 8f. モジュールは属性とアイテムの汎用的な検索のための道具
も定義しています。 *note map(): 82f, *note sorted(): b9c, *note
itertools.groupby(): 267f, や関数を引数に取るその他の関数に対して高速に
フィールドを抽出する際に引数として使うと便利です。

 -- の関数: operator.attrgetter (attr)

 -- の関数: operator.attrgetter (*attrs)

     演算対象から 'attr' を取得する呼び出し可能なオブジェクトを返します
     。二つ以上の属性を要求された場合には、属性のタプルを返します。属性
     名はドットを含むこともできます。例えば:

        * ‘f = attrgetter('name')’ とした後で、‘f(b)’ を呼び出すと
          ‘b.name’ を返します。

        * ‘f = attrgetter('name', 'date')’ とした後で、‘f(b)’ を呼び出す
          と ‘(b.name, b.date)’ を返します。

        * ‘f = attrgetter('name.first', 'name.last')’ とした後で、‘f(b)’
          を呼び出すと ‘(b.name.first, b.name.last)’ を返します。

     次と等価です:

          def attrgetter(*items):
              if any(not isinstance(item, str) for item in items):
                  raise TypeError('attribute name must be a string')
              if len(items) == 1:
                  attr = items[0]
                  def g(obj):
                      return resolve_attr(obj, attr)
              else:
                  def g(obj):
                      return tuple(resolve_attr(obj, attr) for attr in items)
              return g

          def resolve_attr(obj, attr):
              for name in attr.split("."):
                  obj = getattr(obj, name)
              return obj

 -- の関数: operator.itemgetter (item)

 -- の関数: operator.itemgetter (*items)

     演算対象からその *note __getitem__(): 264. メソッドを使って 'item'
     を取得する呼び出し可能なオブジェクトを返します。 二つ以上のアイテム
     を要求された場合には、アイテムのタプルを返します。例えば:

        * ‘f = itemgetter(2)’ とした後で、‘f(r)’ を呼び出すと ‘r[2]’ を
          返します。

        * ‘g = itemgetter(2, 5, 3)’ とした後で、‘g(r)’ を呼び出すと
          ‘(r[2], r[5], r[3])’ を返します。

     次と等価です:

          def itemgetter(*items):
              if len(items) == 1:
                  item = items[0]
                  def g(obj):
                      return obj[item]
              else:
                  def g(obj):
                      return tuple(obj[item] for item in items)
              return g

     アイテムは被演算子の *note __getitem__(): 264. メソッドが受け付ける
     どんな型でも構いません。辞書ならば任意の *note ハッシュ可能: 5db. な
     値を受け付けます。リスト、タプル、文字列などはインデックスかスライ
     スを受け付けます:

          >>> itemgetter(1)('ABCDEFG')
          'B'
          >>> itemgetter(1, 3, 5)('ABCDEFG')
          ('B', 'D', 'F')
          >>> itemgetter(slice(2, None))('ABCDEFG')
          'CDEFG'
          >>> soldier = dict(rank='captain', name='dotterbart')
          >>> itemgetter('rank')(soldier)
          'captain'

     *note itemgetter(): a30. を使って特定のフィールドをタプルレコードか
     ら取り出す例:

          >>> inventory = [('apple', 3), ('banana', 2), ('pear', 5), ('orange', 1)]
          >>> getcount = itemgetter(1)
          >>> list(map(getcount, inventory))
          [3, 2, 5, 1]
          >>> sorted(inventory, key=getcount)
          [('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)]

 -- の関数: operator.methodcaller (name, /, *args, **kwargs)

     引数の 'name' メソッドを呼び出す呼び出し可能オブジェクトを返します
     。追加の引数および/またはキーワード引数が与えられると、これらもその
     メソッドに引き渡されます。例えば:

        * ‘f = methodcaller('name')’ とした後で、‘f(b)’ を呼び出すと
          ‘b.name()’ を返します。

        * ‘f = methodcaller('name', 'foo', bar=1)’ とした後で、‘f(b)’ を
          呼び出すと ‘b.name('foo', bar=1)’ を返します。

     次と等価です:

          def methodcaller(name, /, *args, **kwargs):
              def caller(obj):
                  return getattr(obj, name)(*args, **kwargs)
              return caller

* Menu:

* 演算子から関数への対応表::
* インプレース (in-place) 演算子: インプレース in-place 演算子.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/operator.py


File: python.info,  Node: 演算子から関数への対応表,  Next: インプレース in-place 演算子,  Up: operator --- 関数形式の標準演算子

5.10.3.1 演算子から関数への対応表
.................................

下のテーブルでは、個々の抽象的な操作が、どのように Python 構文上の各演算
子や *note operator: 8f. モジュールの関数に対応しているかを示しています
。

演算                        操作                          関数
                                                          
------------------------------------------------------------------------------------------------------
                                                          
加算                        ‘a + b’                       ‘add(a, b)’
                                                          
                                                          
結合                        ‘seq1 + seq2’                 ‘concat(seq1, seq2)’
                                                          
                                                          
包含判定                    ‘obj in seq’                  ‘contains(seq, obj)’
                                                          
                                                          
除算                        ‘a / b’                       ‘truediv(a, b)’
                                                          
                                                          
除算                        ‘a // b’                      ‘floordiv(a, b)’
                                                          
                                                          
ビット単位論理積            ‘a & b’                       ‘and_(a, b)’
                                                          
                                                          
ビット単位排他的論理和      ‘a ^ b’                       ‘xor(a, b)’
                                                          
                                                          
ビット単位反転              ‘~ a’                         ‘invert(a)’
                                                          
                                                          
ビット単位論理和            ‘a | b’                       ‘or_(a, b)’
                                                          
                                                          
冪乗                        ‘a ** b’                      ‘pow(a, b)’
                                                          
                                                          
同一性                      ‘a is b’                      ‘is_(a, b)’
                                                          
                                                          
同一性                      ‘a is not b’                  ‘is_not(a, b)’
                                                          
                                                          
インデクス指定の代入        ‘obj[k] = v’                  ‘setitem(obj, k, v)’
                                                          
                                                          
インデクス指定の削除        ‘del obj[k]’                  ‘delitem(obj, k)’
                                                          
                                                          
インデクス指定              ‘obj[k]’                      ‘getitem(obj, k)’
                                                          
                                                          
左シフト                    ‘a << b’                      ‘lshift(a, b)’
                                                          
                                                          
剰余                        ‘a % b’                       ‘mod(a, b)’
                                                          
                                                          
乗算                        ‘a * b’                       ‘mul(a, b)’
                                                          
                                                          
行列の乗算                  ‘a @ b’                       ‘matmul(a, b)’
                                                          
                                                          
(算術) 負                   ‘- a’                         ‘neg(a)’
                                                          
                                                          
(論理) 否                   ‘not a’                       ‘not_(a)’
                                                          
                                                          
正                          ‘+ a’                         ‘pos(a)’
                                                          
                                                          
右シフト                    ‘a >> b’                      ‘rshift(a, b)’
                                                          
                                                          
スライス指定の代入          ‘seq[i:j] = values’           ‘setitem(seq, slice(i, j), values)’
                                                          
                                                          
スライス指定の削除          ‘del seq[i:j]’                ‘delitem(seq, slice(i, j))’
                                                          
                                                          
スライス指定                ‘seq[i:j]’                    ‘getitem(seq, slice(i, j))’
                                                          
                                                          
文字列書式化                ‘s % obj’                     ‘mod(s, obj)’
                                                          
                                                          
減算                        ‘a - b’                       ‘sub(a, b)’
                                                          
                                                          
真理値判定                  ‘obj’                         ‘truth(obj)’
                                                          
                                                          
順序付け                    ‘a < b’                       ‘lt(a, b)’
                                                          
                                                          
順序付け                    ‘a <= b’                      ‘le(a, b)’
                                                          
                                                          
等価性                      ‘a == b’                      ‘eq(a, b)’
                                                          
                                                          
不等性                      ‘a != b’                      ‘ne(a, b)’
                                                          
                                                          
順序付け                    ‘a >= b’                      ‘ge(a, b)’
                                                          
                                                          
順序付け                    ‘a > b’                       ‘gt(a, b)’
                                                          


File: python.info,  Node: インプレース in-place 演算子,  Prev: 演算子から関数への対応表,  Up: operator --- 関数形式の標準演算子

5.10.3.2 インプレース (in-place) 演算子
.......................................

多くの演算に「インプレース」版があります。 以下の関数はそうした演算子の
通常の文法に比べてより素朴な呼び出し方を提供します。たとえば、 *note 文:
26d2. ‘x += y’ は ‘x = operator.iadd(x, y)’ と等価です。別の言い方をする
と、 ‘z = operator.iadd(x, y)’ は複合文 ‘z = x; z += y’ と等価です。

なお、これらの例では、インプレースメソッドが呼び出されたとき、計算と代入
は二段階に分けて行われます。以下に挙げるインプレース関数は、インプレース
メソッドを呼び出してその第一段階だけを行います。第二段階の代入は扱われま
せん。

文字列、数、タプルのようなイミュータブルなターゲットでは、更新された値が
計算されますが、入力変数に代入し返されはしません。

     >>> a = 'hello'
     >>> iadd(a, ' world')
     'hello world'
     >>> a
     'hello'

リストや辞書のようなミュータブルなターゲットでは、インプレースメソッドは
更新を行うので、その後に代入をする必要はありません。

     >>> s = ['h', 'e', 'l', 'l', 'o']
     >>> iadd(s, [' ', 'w', 'o', 'r', 'l', 'd'])
     ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
     >>> s
     ['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']

 -- の関数: operator.iadd (a, b)
 -- の関数: operator.__iadd__ (a, b)

     ‘a = iadd(a, b)’ は ‘a += b’ と等価です。

 -- の関数: operator.iand (a, b)
 -- の関数: operator.__iand__ (a, b)

     ‘a = iand(a, b)’ は ‘a &= b’ と等価です。

 -- の関数: operator.iconcat (a, b)
 -- の関数: operator.__iconcat__ (a, b)

     ‘a = iconcat(a, b)’ は二つのシーケンス 'a' と 'b' に対し ‘a += b’ と
     等価です。

 -- の関数: operator.ifloordiv (a, b)
 -- の関数: operator.__ifloordiv__ (a, b)

     ‘a = ifloordiv(a, b)’ は ‘a //= b’ と等価です。

 -- の関数: operator.ilshift (a, b)
 -- の関数: operator.__ilshift__ (a, b)

     ‘a = ilshift(a, b)’ は ‘a <<= b’ と等価です。

 -- の関数: operator.imod (a, b)
 -- の関数: operator.__imod__ (a, b)

     ‘a = imod(a, b)’ は ‘a %= b’ と等価です。

 -- の関数: operator.imul (a, b)
 -- の関数: operator.__imul__ (a, b)

     ‘a = imul(a, b)’ は ‘a *= b’ と等価です。

 -- の関数: operator.imatmul (a, b)
 -- の関数: operator.__imatmul__ (a, b)

     ‘a = imatmul(a, b)’ は ‘a @= b’ と等価です。

     Added in version 3.5.

 -- の関数: operator.ior (a, b)
 -- の関数: operator.__ior__ (a, b)

     ‘a = ior(a, b)’ は ‘a |= b’ と等価です。

 -- の関数: operator.ipow (a, b)
 -- の関数: operator.__ipow__ (a, b)

     ‘a = ipow(a, b)’ は ‘a **= b’ と等価です。

 -- の関数: operator.irshift (a, b)
 -- の関数: operator.__irshift__ (a, b)

     ‘a = irshift(a, b)’ は ‘a >>= b’ と等価です。

 -- の関数: operator.isub (a, b)
 -- の関数: operator.__isub__ (a, b)

     ‘a = isub(a, b)’ は ‘a -= b’ と等価です。

 -- の関数: operator.itruediv (a, b)
 -- の関数: operator.__itruediv__ (a, b)

     ‘a = itruediv(a, b)’ は ‘a /= b’ と等価です。

 -- の関数: operator.ixor (a, b)
 -- の関数: operator.__ixor__ (a, b)

     ‘a = ixor(a, b)’ は ‘a ^= b’ と等価です。


File: python.info,  Node: ファイルとディレクトリへのアクセス,  Next: データの永続化,  Prev: 関数型プログラミング用モジュール,  Up: Python 標準ライブラリ

5.11 ファイルとディレクトリへのアクセス
=======================================

この章で説明されるモジュールはディスクのファイルやディレクトリを扱います
。たとえば、ファイルの属性を読むためのモジュール、ファイルパスを移植可能
な方式で操作する、テンポラリファイルを作成するためのモジュールです。この
章の完全な一覧は:

* Menu:

* pathlib: pathlib --- オブジェクト指向のファイルシステムパス. オブジェクト指向のファイルシステムパス
* os.path: os path --- 一般的なパス名操作. 一般的なパス名操作
* fileinput: fileinput --- 複数の入力ストリームをまたいだ行を反復する. 複数の入力ストリームをまたいだ行を反復する
* stat: stat --- stat の結果を解釈する. stat() の結果を解釈する
* filecmp: filecmp --- ファイルとディレクトリの比較. ファイルとディレクトリの比較
* tempfile: tempfile --- 一時ファイルやディレクトリの作成. 一時ファイルやディレクトリの作成
* glob: glob --- Unix 形式のパス名のパターン展開. Unix 形式のパス名のパターン展開
* fnmatch: fnmatch --- Unix のファイル名パターンマッチ. Unix のファイル名パターンマッチ
* linecache: linecache --- テキストラインへのランダムアクセス. テキストラインへのランダムアクセス
* shutil: shutil --- 高水準のファイル操作. 高水準のファイル操作


File: python.info,  Node: pathlib --- オブジェクト指向のファイルシステムパス,  Next: os path --- 一般的なパス名操作,  Up: ファイルとディレクトリへのアクセス

5.11.1 ‘pathlib’ -- オブジェクト指向のファイルシステムパス
----------------------------------------------------------

Added in version 3.4.

'ソースコード:' Lib/pathlib/(1)

__________________________________________________________________

このモジュールはファイルシステムのパスを表すクラスを提供していて、様々な
オペレーティングシステムについての適切な意味論をそれらのクラスに持たせて
います。 Path クラスは *note 純粋パス: 26f3. と *note 具象パス: 26f4. か
らなります。 純粋パスは I/O を伴わない純粋な計算操作を提供します。 具象
パスは純粋パスを継承していますが、 I/O 操作も提供しています。

[image src="python-figures/pathlib-inheritance.png" alt="Inheritance diagram showing the classes available in pathlib. The most basic class is PurePath, which has three direct subclasses: PurePosixPath, PureWindowsPath, and Path. Further to these four classes, there are two classes that use multiple inheritance: PosixPath subclasses PurePosixPath and Path, and WindowsPath subclasses PureWindowsPath and Path."]


あなたが今までこのモジュールを使用したことがない場合や、タスクに適してい
るのがどのクラスかわからない場合は、 *note Path: 20a. はきっとあなたに必
要なものでしょう。 *note Path: 20a. はコードが実行されているプラットフォ
ーム用の *note 具象パス: 26f4. のインスタンスを作成します。

純粋パスは、以下のようないくつかの特殊なケースで有用です:

  1. Unix マシン上で Windows のパスを扱いたいとき (またはその逆)。Unix 上
     で実行しているときに *note WindowsPath: 26f5. のインスタンスを作成
     することはできませんが、*note PureWindowsPath: 166a. なら可能になり
     ます。

  2. 実際に OS にアクセスすることなしにパスを操作するだけのコードを確認
     したいとき。この場合、純粋クラスのインスタンスを一つ作成すれば、そ
     れが OS にアクセスすることはないので便利です。

参考
....

PEP 428(2): The pathlib module - オブジェクト指向のファイルシステムパス
。

参考
....

文字列による低水準のパス操作の場合は *note os.path: 92. も使用できます。

* Menu:

* 基本的な使い方::
* 例外: 例外<6>.
* 純粋パス::
* 具象パス::
* Pattern language::
* glob モジュールとの比較::
* os と os.path モジュールの比較: os と os path モジュールの比較.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pathlib/

   (2) https://peps.python.org/pep-0428/


File: python.info,  Node: 基本的な使い方,  Next: 例外<6>,  Up: pathlib --- オブジェクト指向のファイルシステムパス

5.11.1.1 基本的な使い方
.......................

メインクラスをインポートします:

     >>> from pathlib import Path

サブディレクトリの一覧を取得します:

     >>> p = Path('.')
     >>> [x for x in p.iterdir() if x.is_dir()]
     [PosixPath('.hg'), PosixPath('docs'), PosixPath('dist'),
      PosixPath('__pycache__'), PosixPath('build')]

このディレクトリツリー内の Python ソースファイルの一覧を取得します:

     >>> list(p.glob('**/*.py'))
     [PosixPath('test_pathlib.py'), PosixPath('setup.py'),
      PosixPath('pathlib.py'), PosixPath('docs/conf.py'),
      PosixPath('build/lib/pathlib.py')]

ディレクトリツリー内を移動します:

     >>> p = Path('/etc')
     >>> q = p / 'init.d' / 'reboot'
     >>> q
     PosixPath('/etc/init.d/reboot')
     >>> q.resolve()
     PosixPath('/etc/rc.d/init.d/halt')

パスのプロパティを問い合わせます:

     >>> q.exists()
     True
     >>> q.is_dir()
     False

ファイルを開きます:

     >>> with q.open() as f: f.readline()
     ...
     '#!/bin/bash\n'


File: python.info,  Node: 例外<6>,  Next: 純粋パス,  Prev: 基本的な使い方,  Up: pathlib --- オブジェクト指向のファイルシステムパス

5.11.1.2 例外
.............

 -- 例外: pathlib.UnsupportedOperation

     *note NotImplementedError: 209. を継承した例外です。パスオブジェク
     トがサポートしていない操作を行おうとした時に送出されます。

     Added in version 3.13.


File: python.info,  Node: 純粋パス,  Next: 具象パス,  Prev: 例外<6>,  Up: pathlib --- オブジェクト指向のファイルシステムパス

5.11.1.3 純粋パス
.................

純粋パスオブジェクトは実際にファイルシステムにアクセスしないパス操作処理
を提供します。これらのクラスにアクセスするには 3 つの方法があり、それら
を 'フレーバー' と呼んでいます:

 -- クラス: pathlib.PurePath (*pathsegments)

     システムのパスのフレーバーを表すジェネリッククラスです (インスタン
     スを作成することで *note PurePosixPath: 26f9. または *note
     PureWindowsPath: 166a. のどちらかが作成されます):

          >>> PurePath('setup.py')      # Running on a Unix machine
          PurePosixPath('setup.py')

     'pathsegments' の各要素は、パスの構成要素を表す文字列か、パスオブジ
     ェクトなどの、 *note os.PathLike: c1f. インターフェースを実装するオ
     ブジェクトである必要があります。 *note os.PathLike: c1f. インターフ
     ェースでは、 *note __fspath__(): c20. メソッドが文字列を返します:

          >>> PurePath('foo', 'some/path', 'bar')
          PurePosixPath('foo/some/path/bar')
          >>> PurePath(Path('foo'), Path('bar'))
          PurePosixPath('foo/bar')

     'pathsegments' が空のとき、現在のディレクトリとみなされます:

          >>> PurePath()
          PurePosixPath('.')

     あるパス構成要素が絶対パスである場合、それより前の要素はすべて無視
     されます (*note os.path.join(): 1597. と同様):

          >>> PurePath('/etc', '/usr', 'lib64')
          PurePosixPath('/usr/lib64')
          >>> PureWindowsPath('c:/Windows', 'd:bar')
          PureWindowsPath('d:bar')

     Windowsの場合、ルート相対パス (例えば ‘r'\foo'’) があってもドライブ
     名はそのまま変わりません:

          >>> PureWindowsPath('c:/Windows', '/Program Files')
          PureWindowsPath('c:/Program Files')

     単一スラッシュと等価な複数スラッシュやシングルドットは簡略化されま
     すが、ダブルドット (‘'..'’) や先頭に位置するダブルスラッシュ
     (‘'//'’) は簡略化されません。 これは、様々な理由でパスの意味が簡略
     化した場合と異なってしまうからです (例: シンボリックリンク、UNCパス
     ):

          >>> PurePath('foo//bar')
          PurePosixPath('foo/bar')
          >>> PurePath('//foo/bar')
          PurePosixPath('//foo/bar')
          >>> PurePath('foo/./bar')
          PurePosixPath('foo/bar')
          >>> PurePath('foo/../bar')
          PurePosixPath('foo/../bar')

     (通常 ‘PurePosixPath('foo/../bar')’ は ‘PurePosixPath('bar')’ と等
     価になりますが、‘foo’ が他のディレクトリへのシンボリックリンクの場
     合は等価になりません)

     純粋パスオブジェクトは *note os.PathLike: c1f. インターフェースを実
     装しており、そのインターフェースを受理する箇所ならどこでも使用する
     ことができます。

     バージョン 3.6 で変更: *note os.PathLike: c1f. インターフェースがサ
     ポートされました。

 -- クラス: pathlib.PurePosixPath (*pathsegments)

     *note PurePath: 473. のサブクラスです。このパスフレーバーは非
     Windows パスを表します:

          >>> PurePosixPath('/etc/hosts')
          PurePosixPath('/etc/hosts')

     'pathsegments' の指定は *note PurePath: 473. と同じです。

 -- クラス: pathlib.PureWindowsPath (*pathsegments)

     *note PurePath: 473. のサブクラスです。このパスフレーバー UNC
     paths(1) を含む Windows ファイルシステムパスを表します:

          >>> PureWindowsPath('c:/', 'Users', 'Ximénez')
          PureWindowsPath('c:/Users/Ximénez')
          >>> PureWindowsPath('//server/share/file')
          PureWindowsPath('//server/share/file')

     'pathsegments' の指定は *note PurePath: 473. と同じです。

これらクラスはあらゆるシステムコールを行わないため、起動しているシステム
にかかわらずインスタンスを作成できます。

* Menu:

* 全般的な性質::
* 演算子: 演算子<2>.
* 個別の構成要素へのアクセス::
* メソッドとプロパティ::

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Path_(computing)#UNC


File: python.info,  Node: 全般的な性質,  Next: 演算子<2>,  Up: 純粋パス

5.11.1.4 全般的な性質
.....................

パスオブジェクトはイミュータブルで *note ハッシュ可能: 5db. です。同じフ
レーバーのパスオブジェクトは比較ならびに順序付け可能です。これらのプロパ
ティは、フレーバーのケースフォールディング (訳注: 比較のために正規化する
こと、例えば全て大文字にする) のセマンティクスに従います。

     >>> PurePosixPath('foo') == PurePosixPath('FOO')
     False
     >>> PureWindowsPath('foo') == PureWindowsPath('FOO')
     True
     >>> PureWindowsPath('FOO') in { PureWindowsPath('foo') }
     True
     >>> PureWindowsPath('C:') < PureWindowsPath('d:')
     True

異なるフレーバーのパスオブジェクト同士の比較は等価になることはなく、順序
付けもできません:

     >>> PureWindowsPath('foo') == PurePosixPath('foo')
     False
     >>> PureWindowsPath('foo') < PurePosixPath('foo')
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: '<' not supported between instances of 'PureWindowsPath' and 'PurePosixPath'


File: python.info,  Node: 演算子<2>,  Next: 個別の構成要素へのアクセス,  Prev: 全般的な性質,  Up: 純粋パス

5.11.1.5 演算子
...............

スラッシュ演算子を使って、 *note os.path.join(): 1597. のように子パスを
作成することができます。 スラッシュの右側が絶対パスである場合、左側のパ
スは無視されます。 Windows環境で、右側のパスがルート相対パス (例:
‘r'\foo'’) である場合、ドライブ名はリセットされません:

     >>> p = PurePath('/etc')
     >>> p
     PurePosixPath('/etc')
     >>> p / 'init.d' / 'apache2'
     PurePosixPath('/etc/init.d/apache2')
     >>> q = PurePath('bin')
     >>> '/usr' / q
     PurePosixPath('/usr/bin')
     >>> p / '/an_absolute_path'
     PurePosixPath('/an_absolute_path')
     >>> PureWindowsPath('c:/Windows', '/Program Files')
     PureWindowsPath('c:/Program Files')

*note os.PathLike: c1f. を実装したオブジェクトが受理できる箇所ならどこで
も、パスオブジェクトが使用できます:

     >>> import os
     >>> p = PurePath('/etc')
     >>> os.fspath(p)
     '/etc'

パスオブジェクトの文字列表現はそのシステム自身の Raw ファイルシステムパ
ス (ネイティブの形式、例えば Windows では区切り文字がバックスラッシュ) に
なり、文字列としてファイルパスを取るあらゆる関数に渡すことができます:

     >>> p = PurePath('/etc')
     >>> str(p)
     '/etc'
     >>> p = PureWindowsPath('c:/Program Files')
     >>> str(p)
     'c:\\Program Files'

同様に、パスオブジェクトを *note bytes: 1a4. で呼び出すと、Raw ファイル
システムパスを *note os.fsencode(): c23. でエンコードされたバイト列オブ
ジェクトで返します:

     >>> bytes(p)
     b'/etc'

     注釈: *note bytes: 1a4. での呼び出しは Unix 上での使用のみ推奨しま
     す。Windows では Unicode 形式が標準的なファイルシステムパス表現にな
     ります。


File: python.info,  Node: 個別の構成要素へのアクセス,  Next: メソッドとプロパティ,  Prev: 演算子<2>,  Up: 純粋パス

5.11.1.6 個別の構成要素へのアクセス
...................................

パスの個別の "構成要素" へアクセスするには、以下のプロパティを使用します
:

 -- の属性: PurePath.parts

     パスのさまざまな構成要素へのアクセス手段を提供するタプルになります:

          >>> p = PurePath('/usr/bin/python3')
          >>> p.parts
          ('/', 'usr', 'bin', 'python3')

          >>> p = PureWindowsPath('c:/Program Files/PSF')
          >>> p.parts
          ('c:\\', 'Program Files', 'PSF')

     (ドライブ名とローカルルートは単一要素にまとめられます)


File: python.info,  Node: メソッドとプロパティ,  Prev: 個別の構成要素へのアクセス,  Up: 純粋パス

5.11.1.7 メソッドとプロパティ
.............................

純粋パスは以下のメソッドとプロパティを提供します:

 -- の属性: PurePath.parser

     低レベルのパスのパースと結合に使用される *note os.path: 92. モジュ
     ールの実装。‘posixpath’ または ‘ntpath’。

     Added in version 3.13.

 -- の属性: PurePath.drive

     ドライブ文字または名前を表す文字列があればそれになります:

          >>> PureWindowsPath('c:/Program Files/').drive
          'c:'
          >>> PureWindowsPath('/Program Files/').drive
          ''
          >>> PurePosixPath('/etc').drive
          ''

     UNC 共有名もドライブとみなされます:

          >>> PureWindowsPath('//host/share/foo.txt').drive
          '\\\\host\\share'

 -- の属性: PurePath.root

     ローカルまたはグローバルルートを表す文字列があればそれになります:

          >>> PureWindowsPath('c:/Program Files/').root
          '\\'
          >>> PureWindowsPath('c:Program Files/').root
          ''
          >>> PurePosixPath('/etc').root
          '/'

     UNC 共有名は常にルートを持ちます:

          >>> PureWindowsPath('//host/share').root
          '\\'

     *note PurePosixPath: 26f9. でパスの先頭が３つ以上の連続したスラッシ
     ュである場合、 余分なスラッシュは除去されます:

          >>> PurePosixPath('//etc').root
          '//'
          >>> PurePosixPath('///etc').root
          '/'
          >>> PurePosixPath('////etc').root
          '/'

          注釈: この挙動は、以下に示す、 'The Open Group Base
          Specifications Issue 6' の 4.11 Pathname Resolution(1) に沿っ
          たものです:

          '"A pathname that begins with two successive slashes may be
          interpreted in an implementation-defined manner, although more
          than two leading slashes shall be treated as a single slash."'

 -- の属性: PurePath.anchor

     ドライブとルートを結合した文字列になります:

          >>> PureWindowsPath('c:/Program Files/').anchor
          'c:\\'
          >>> PureWindowsPath('c:Program Files/').anchor
          'c:'
          >>> PurePosixPath('/etc').anchor
          '/'
          >>> PureWindowsPath('//host/share').anchor
          '\\\\host\\share\\'

 -- の属性: PurePath.parents

     パスの論理的な上位パスにアクセスできるイミュータブルなシーケンスに
     なります:

          >>> p = PureWindowsPath('c:/foo/bar/setup.py')
          >>> p.parents[0]
          PureWindowsPath('c:/foo/bar')
          >>> p.parents[1]
          PureWindowsPath('c:/foo')
          >>> p.parents[2]
          PureWindowsPath('c:/')

     バージョン 3.10 で変更: parents シーケンスが、*note スライス: 20e3.
     と負のインデックスをサポートするようになりました。

 -- の属性: PurePath.parent

     パスの論理的な上位パスになります:

          >>> p = PurePosixPath('/a/b/c/d')
          >>> p.parent
          PurePosixPath('/a/b/c')

     アンカーの位置を超えることや空のパスになる位置には対応していません:

          >>> p = PurePosixPath('/')
          >>> p.parent
          PurePosixPath('/')
          >>> p = PurePosixPath('.')
          >>> p.parent
          PurePosixPath('.')

          注釈: これは純粋な字句操作であるため、以下のような挙動になりま
          す:

               >>> p = PurePosixPath('foo/..')
               >>> p.parent
               PurePosixPath('foo')

          任意のファイルシステムパスを上位方向に移動したい場合、シンボリ
          ックリンクの解決や ‘".."’ 要素の除去のため、最初に *note
          Path.resolve(): 1661. を呼ぶことを推奨します。

 -- の属性: PurePath.name

     パス要素の末尾を表す文字列があればそれになります。ドライブやルート
     は含まれません:

          >>> PurePosixPath('my/library/setup.py').name
          'setup.py'

     UNC ドライブ名は考慮されません:

          >>> PureWindowsPath('//some/share/setup.py').name
          'setup.py'
          >>> PureWindowsPath('//some/share').name
          ''

 -- の属性: PurePath.suffix

     末尾の要素をドットで分割した最後の部分があれば、それになります:

          >>> PurePosixPath('my/library/setup.py').suffix
          '.py'
          >>> PurePosixPath('my/library.tar.gz').suffix
          '.gz'
          >>> PurePosixPath('my/library').suffix
          ''

     一般的にはファイル拡張子と呼ばれています。

 -- の属性: PurePath.suffixes

     パスのサフィックス(ファイル拡張子)のリストです:

          >>> PurePosixPath('my/library.tar.gar').suffixes
          ['.tar', '.gar']
          >>> PurePosixPath('my/library.tar.gz').suffixes
          ['.tar', '.gz']
          >>> PurePosixPath('my/library').suffixes
          []

 -- の属性: PurePath.stem

     パス要素の末尾から拡張子を除いたものになります:

          >>> PurePosixPath('my/library.tar.gz').stem
          'library.tar'
          >>> PurePosixPath('my/library.tar').stem
          'library'
          >>> PurePosixPath('my/library').stem
          'library'

 -- メソッド: PurePath.as_posix ()

     フォワードスラッシュ (‘/’) を使用したパスを表す文字列を返します:

          >>> p = PureWindowsPath('c:\\windows')
          >>> str(p)
          'c:\\windows'
          >>> p.as_posix()
          'c:/windows'

 -- メソッド: PurePath.is_absolute ()

     パスが絶対パスかどうかを返します。パスが絶対パスとみなされるのは、
     ルートと (フレーバーが許す場合) ドライブとの両方が含まれる場合です:

          >>> PurePosixPath('/a/b').is_absolute()
          True
          >>> PurePosixPath('a/b').is_absolute()
          False

          >>> PureWindowsPath('c:/a/b').is_absolute()
          True
          >>> PureWindowsPath('/a/b').is_absolute()
          False
          >>> PureWindowsPath('c:').is_absolute()
          False
          >>> PureWindowsPath('//some/share').is_absolute()
          True

 -- メソッド: PurePath.is_relative_to (other)

     このパスが 'other' パスに対して相対なのかそうでないのかの結果を返し
     ます。

          >>> p = PurePath('/etc/passwd')
          >>> p.is_relative_to('/etc')
          True
          >>> p.is_relative_to('/usr')
          False

     This method is string-based; it neither accesses the filesystem nor
     treats "‘..’" segments specially.  The following code is
     equivalent:

          >>> u = PurePath('/usr')
          >>> u == p or u in p.parents
          False

     Added in version 3.9.

     Deprecated since version 3.12, will be removed in version 3.14: 追
     加の引数指定は非推奨となりました。指定された場合は 'other' と連結さ
     れます。

 -- メソッド: PurePath.is_reserved ()

     *note PureWindowsPath: 166a. の場合はパスが Windows 上で予約されて
     いれば ‘True’ を返し、そうでなければ ‘False’ を返します。*note
     PurePosixPath: 26f9. の場合は常に ‘False’ を返します。

     バージョン 3.13 で変更: Windows path names that contain a colon, or
     end with a dot or a space, are considered reserved.  UNC paths may
     be reserved.

     Deprecated since version 3.13, will be removed in version 3.15:
     This method is deprecated; use *note os.path.isreserved(): 204. to
     detect reserved paths on Windows.

 -- メソッド: PurePath.joinpath (*pathsegments)

     このメソッドの呼び出しは、与えられた 'pathsegments' のパスを順番に
     結合することと等価です。

          >>> PurePosixPath('/etc').joinpath('passwd')
          PurePosixPath('/etc/passwd')
          >>> PurePosixPath('/etc').joinpath(PurePosixPath('passwd'))
          PurePosixPath('/etc/passwd')
          >>> PurePosixPath('/etc').joinpath('init.d', 'apache2')
          PurePosixPath('/etc/init.d/apache2')
          >>> PureWindowsPath('c:').joinpath('/Program Files')
          PureWindowsPath('c:/Program Files')

 -- メソッド: PurePath.full_match (pattern, *, case_sensitive=None)

     現在のパスが glob 形式で与えられたパターンと一致したら ‘True’ を、
     一致しなければ ‘False’ を返します。例:

          >>> PurePath('a/b.py').full_match('a/*.py')
          True
          >>> PurePath('a/b.py').full_match('*.py')
          False
          >>> PurePath('/a/b/c.py').full_match('/a/**')
          True
          >>> PurePath('/a/b/c.py').full_match('**/*.py')
          True

     参考
     ....

     *note Pattern language: 2708. ドキュメント。

     他のメソッドと同様に、大文字小文字の区別はプラットフォームの設定に
     従います:

          >>> PurePosixPath('b.py').full_match('*.PY')
          False
          >>> PureWindowsPath('b.py').full_match('*.PY')
          True

     Set 'case_sensitive' to ‘True’ or ‘False’ to override this
     behaviour.

     Added in version 3.13.

 -- メソッド: PurePath.match (pattern, *, case_sensitive=None)

     現在のパスが非再帰の glob 形式で与えられたパターンと一致したら
     ‘True’ を、一致しなければ ‘False’ を返します。

     This method is similar to *note full_match(): 20c, but empty
     patterns aren't allowed (*note ValueError: 1e3. is raised), the
     recursive wildcard "‘**’" isn't supported (it acts like
     non-recursive "‘*’"), and if a relative pattern is provided, then
     matching is done from the right:

          >>> PurePath('a/b.py').match('*.py')
          True
          >>> PurePath('/a/b/c.py').match('b/*.py')
          True
          >>> PurePath('/a/b/c.py').match('a/*.py')
          False

     バージョン 3.12 で変更: 'pattern' パラメタが *note path-like
     object: 280. を受け付けるようになりました。

     バージョン 3.12 で変更: 'case_sensitive' 引数が追加されました。

 -- メソッド: PurePath.relative_to (other, walk_up=False)

     'other' で表されたパスから現在のパスへの相対パスを返します。それが
     不可能だった場合は *note ValueError: 1e3. が送出されます:

          >>> p = PurePosixPath('/etc/passwd')
          >>> p.relative_to('/')
          PurePosixPath('etc/passwd')
          >>> p.relative_to('/etc')
          PurePosixPath('passwd')
          >>> p.relative_to('/usr')
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
            File "pathlib.py", line 941, in relative_to
              raise ValueError(error_message.format(str(self), str(formatted)))
          ValueError: '/etc/passwd' is not in the subpath of '/usr' OR one path is relative and the other is absolute.

     'walk_up' がFalseの場合（デフォルト）、パスは 'other' から始まる必
     要があります。引数に True を指定すると ‘..’ を追加して相対パスを作
     成する場合があります。異なるドライブを参照するなど、それ以外のケー
     スでは *note ValueError: 1e3. が送出されます。:

          >>> p.relative_to('/usr', walk_up=True)
          PurePosixPath('../etc/passwd')
          >>> p.relative_to('foo', walk_up=True)
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
            File "pathlib.py", line 941, in relative_to
              raise ValueError(error_message.format(str(self), str(formatted)))
          ValueError: '/etc/passwd' is not on the same drive as 'foo' OR one path is relative and the other is absolute.

          警告: This function is part of *note PurePath: 473. and works
          with strings.  It does not check or access the underlying file
          structure.  This can impact the 'walk_up' option as it assumes
          that no symlinks are present in the path; call *note
          resolve(): 1661. first if necessary to resolve symlinks.

     バージョン 3.12 で変更: 'walk_up' 引数が追加されました（
     ‘walk_up=False’ を指定すると以前の動作と同じになります）。

     Deprecated since version 3.12, will be removed in version 3.14: 追
     加の位置引数の指定は非推奨となりました。指定された場合は 'other' と
     連結されます。

 -- メソッド: PurePath.with_name (name)

     現在のパスの *note name: 2702. 部分を変更したパスを返します。オリジ
     ナルパスに *note name: 2702. 部分がない場合は ValueError が送出され
     ます:

          >>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
          >>> p.with_name('setup.py')
          PureWindowsPath('c:/Downloads/setup.py')
          >>> p = PureWindowsPath('c:/')
          >>> p.with_name('setup.py')
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
            File "/home/antoine/cpython/default/Lib/pathlib.py", line 751, in with_name
              raise ValueError("%r has an empty name" % (self,))
          ValueError: PureWindowsPath('c:/') has an empty name

 -- メソッド: PurePath.with_stem (stem)

     現在のパスの *note stem: 2705. 部分を変更したパスを返します。オリジ
     ナルパスに *note stem: 2705. 部分がない場合は ValueError が送出され
     ます:

          >>> p = PureWindowsPath('c:/Downloads/draft.txt')
          >>> p.with_stem('final')
          PureWindowsPath('c:/Downloads/final.txt')
          >>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
          >>> p.with_stem('lib')
          PureWindowsPath('c:/Downloads/lib.gz')
          >>> p = PureWindowsPath('c:/')
          >>> p.with_stem('')
          Traceback (most recent call last):
            File "<stdin>", line 1, in <module>
            File "/home/antoine/cpython/default/Lib/pathlib.py", line 861, in with_stem
              return self.with_name(stem + self.suffix)
            File "/home/antoine/cpython/default/Lib/pathlib.py", line 851, in with_name
              raise ValueError("%r has an empty name" % (self,))
          ValueError: PureWindowsPath('c:/') has an empty name

     Added in version 3.9.

 -- メソッド: PurePath.with_suffix (suffix)

     *note suffix: 2703. を変更した新しいパスを返します。 元のパスに
     suffix が無かった場合、代わりに新しい 'suffix' が追加されます。
     'suffix' が空文字列だった場合、元の suffix は除去されます:

          >>> p = PureWindowsPath('c:/Downloads/pathlib.tar.gz')
          >>> p.with_suffix('.bz2')
          PureWindowsPath('c:/Downloads/pathlib.tar.bz2')
          >>> p = PureWindowsPath('README')
          >>> p.with_suffix('.txt')
          PureWindowsPath('README.txt')
          >>> p = PureWindowsPath('README.txt')
          >>> p.with_suffix('')
          PureWindowsPath('README')

 -- メソッド: PurePath.with_segments (*pathsegments)

     Create a new path object of the same type by combining the given
     'pathsegments'.  This method is called whenever a derivative path
     is created, such as from *note parent: 1694. and *note
     relative_to(): 2ab.  Subclasses may override this method to pass
     information to derivative paths, for example:

          from pathlib import PurePosixPath

          class MyPath(PurePosixPath):
              def __init__(self, *pathsegments, session_id):
                  super().__init__(*pathsegments)
                  self.session_id = session_id

              def with_segments(self, *pathsegments):
                  return type(self)(*pathsegments, session_id=self.session_id)

          etc = MyPath('/etc', session_id=42)
          hosts = etc / 'hosts'
          print(hosts.session_id)  # 42

     Added in version 3.12.

   ---------- Footnotes ----------

   (1) 
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11


File: python.info,  Node: 具象パス,  Next: Pattern language,  Prev: 純粋パス,  Up: pathlib --- オブジェクト指向のファイルシステムパス

5.11.1.8 具象パス
.................

具象パスは純粋パスクラスのサブクラスです。純粋パスが提供する操作に加え、
パスオブジェクト上でシステムコールを呼ぶメソッドも提供しています。具象パ
スのインスタンスを作成するには 3 つの方法があります:

 -- クラス: pathlib.Path (*pathsegments)

     *note PurePath: 473. のサブクラスであり、システムのパスフレーバーの
     具象パスを表します (このインスタンスの作成で *note PosixPath: 270a.
     か *note WindowsPath: 26f5. のどちらかが作成されます):

          >>> Path('setup.py')
          PosixPath('setup.py')

     'pathsegments' の指定は *note PurePath: 473. と同じです。

 -- クラス: pathlib.PosixPath (*pathsegments)

     *note Path: 20a. および *note PurePosixPath: 26f9. のサブクラスで、
     非 Windows ファイルシステムの具象パスを表します:

          >>> PosixPath('/etc/hosts')
          PosixPath('/etc/hosts')

     'pathsegments' の指定は *note PurePath: 473. と同じです。

     バージョン 3.13 で変更: Windows では *note UnsupportedOperation:
     208. を送出します。以前のバージョンでは代わりに *note
     NotImplementedError: 209. を送出していました。

 -- クラス: pathlib.WindowsPath (*pathsegments)

     *note Path: 20a. および *note PureWindowsPath: 166a. のサブクラスで
     、Windows ファイルシステムの具象パスを表します:

          >>> WindowsPath('c:/', 'Users', 'Ximénez')
          WindowsPath('c:/Users/Ximénez')

     'pathsegments' の指定は *note PurePath: 473. と同じです。

     バージョン 3.13 で変更: Windows 以外のプラットフォームでは *note
     UnsupportedOperation: 208. を送出します。以前のバージョンでは代わり
     に *note NotImplementedError: 209. を送出していました。

インスタンスを作成できるのはシステムと一致するフレーバーのみです (互換性
のないパスフレーバーでのシステムコールの許可はバグやアプリケーションの異
常終了の原因になります):

     >>> import os
     >>> os.name
     'posix'
     >>> Path('setup.py')
     PosixPath('setup.py')
     >>> PosixPath('setup.py')
     PosixPath('setup.py')
     >>> WindowsPath('setup.py')
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "pathlib.py", line 798, in __new__
         % (cls.__name__,))
     UnsupportedOperation: cannot instantiate 'WindowsPath' on your system

Some concrete path methods can raise an *note OSError: 3f0. if a system
call fails (for example because the path doesn't exist).

* Menu:

* URIのパースと生成::
* パスの展開と解決::
* ファイルの種類とステータスを問い合わせる::
* ファイルを読み書きする: ファイルを読み書きする<2>.
* ディレクトリを読む::
* ファイルとディレクトリの作成::
* リネームと削除::
* パーミッションと所有者::


File: python.info,  Node: URIのパースと生成,  Next: パスの展開と解決,  Up: 具象パス

5.11.1.9 URIのパースと生成
..........................

Concrete path objects can be created from, and represented as, 'file'
URIs conforming to RFC 8089(1).

     注釈: File URIs are not portable across machines with different
     *note filesystem encodings: 270c.

 -- メソッド: classmethod Path.from_uri (uri)

     'file' URIをパースして新しいパスオブジェクトを返します。例:

          >>> p = Path.from_uri('file:///etc/hosts')
          PosixPath('/etc/hosts')

     On Windows, DOS device and UNC paths may be parsed from URIs:

          >>> p = Path.from_uri('file:///c:/windows')
          WindowsPath('c:/windows')
          >>> p = Path.from_uri('file://server/share')
          WindowsPath('//server/share')

     Several variant forms are supported:

          >>> p = Path.from_uri('file:////server/share')
          WindowsPath('//server/share')
          >>> p = Path.from_uri('file://///server/share')
          WindowsPath('//server/share')
          >>> p = Path.from_uri('file:c:/windows')
          WindowsPath('c:/windows')
          >>> p = Path.from_uri('file:/c|/windows')
          WindowsPath('c:/windows')

     *note ValueError: 1e3. is raised if the URI does not start with
     ‘file:’, or the parsed path isn't absolute.

     Added in version 3.13.

 -- メソッド: Path.as_uri ()

     Represent the path as a 'file' URI. *note ValueError: 1e3. is
     raised if the path isn't absolute.

          >>> p = PosixPath('/etc/passwd')
          >>> p.as_uri()
          'file:///etc/passwd'
          >>> p = WindowsPath('c:/Windows')
          >>> p.as_uri()
          'file:///c:/Windows'

     For historical reasons, this method is also available from *note
     PurePath: 473. objects.  However, its use of *note os.fsencode():
     c23. makes it strictly impure.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc8089.html


File: python.info,  Node: パスの展開と解決,  Next: ファイルの種類とステータスを問い合わせる,  Prev: URIのパースと生成,  Up: 具象パス

5.11.1.10 パスの展開と解決
..........................

 -- メソッド: classmethod Path.home ()

     ユーザーのホームディレクトリ (*note os.path.expanduser(): 9e2. での
     ‘~’ の返り値) を表す新しいパスオブジェクトを返します。ホームディレ
     クトリが解決できない場合は、 *note RuntimeError: 17a. を送出します
     。

          >>> Path.home()
          PosixPath('/home/antoine')

     Added in version 3.5.

 -- メソッド: Path.expanduser ()

     パス要素 ‘~’ および ‘~user’ を *note os.path.expanduser(): 9e2. が
     返すように展開した新しいパスオブジェクトを返します。ホームディレク
     トリが解決できない場合は、 *note RuntimeError: 17a. を送出します。

          >>> p = PosixPath('~/films/Monty Python')
          >>> p.expanduser()
          PosixPath('/home/eric/films/Monty Python')

     Added in version 3.5.

 -- メソッド: classmethod Path.cwd ()

     (*note os.getcwd(): 1503. が返す) 現在のディレクトリを表す新しいパ
     スオブジェクトを返します:

          >>> Path.cwd()
          PosixPath('/home/antoine/pathlib')

 -- メソッド: Path.absolute ()

     正規化やシンボリックリンクの解決をせずに、パスを絶対パスにします。
     新しいパスオブジェクトを返します:

          >>> p = Path('tests')
          >>> p
          PosixPath('tests')
          >>> p.absolute()
          PosixPath('/home/antoine/pathlib/tests')

 -- メソッド: Path.resolve (strict=False)

     パスを絶対パスにし、あらゆるシンボリックリンクを解決します。新しい
     パスオブジェクトが返されます:

          >>> p = Path()
          >>> p
          PosixPath('.')
          >>> p.resolve()
          PosixPath('/home/antoine/pathlib')

     "‘..’" 要素は除去されます (このような挙動を示すのはこのメソッドだけ
     です):

          >>> p = Path('docs/../setup.py')
          >>> p.resolve()
          PosixPath('/home/antoine/pathlib/setup.py')

     If a path doesn't exist or a symlink loop is encountered, and
     'strict' is ‘True’, *note OSError: 3f0. is raised.  If 'strict' is
     ‘False’, the path is resolved as far as possible and any remainder
     is appended without checking whether it exists.

     バージョン 3.6 で変更: 'strict' 引数を追加しました(3.6以前の挙動は
     strict です)。

     バージョン 3.13 で変更: Symlink loops are treated like other
     errors: *note OSError: 3f0. is raised in strict mode, and no
     exception is raised in non-strict mode.  In previous versions,
     *note RuntimeError: 17a. is raised no matter the value of 'strict'.

 -- メソッド: Path.readlink ()

     ( *note os.readlink(): 8ee. が返す) シンボリックリンクが指すパスを
     返します:

          >>> p = Path('mylink')
          >>> p.symlink_to('setup.py')
          >>> p.readlink()
          PosixPath('setup.py')

     Added in version 3.9.

     バージョン 3.13 で変更: *note os.readlink(): 8ee. が利用できない場
     合 *note UnsupportedOperation: 208. を送出します。以前のバージョン
     では *note NotImplementedError: 209. を送出していました。


File: python.info,  Node: ファイルの種類とステータスを問い合わせる,  Next: ファイルを読み書きする<2>,  Prev: パスの展開と解決,  Up: 具象パス

5.11.1.11 ファイルの種類とステータスを問い合わせる
..................................................

バージョン 3.8 で変更: *note exists(): 9e4, *note is_dir(): 211, *note
is_file(): 210, *note is_mount(): 9e5, *note is_symlink(): 9e6, *note
is_block_device(): 9e7, *note is_char_device(): 9e8, *note is_fifo():
9e9, *note is_socket(): 9ea. now return ‘False’ instead of raising an
exception for paths that contain characters unrepresentable at the OS
level.

 -- メソッド: Path.stat (*, follow_symlinks=True)

     (*note os.stat(): 46d. と同様の) 現在のパスについて *note
     os.stat_result: 1466. オブジェクトが含む情報を返します。値はそれぞ
     れのメソッドを呼び出した時点のものになります。

     このメソッドは通常はシンボリックリンクをたどります。シンボリックリ
     ンクに対して stat したい場合は ‘follow_symlinks=False’ とするか、
     *note lstat(): 2710. を利用してください。

          >>> p = Path('setup.py')
          >>> p.stat().st_size
          956
          >>> p.stat().st_mtime
          1327883547.852554

     バージョン 3.10 で変更: 'follow_symlinks' パラメータが追加されまし
     た。

 -- メソッド: Path.lstat ()

     *note Path.stat(): 7ee. のように振る舞いますが、パスがシンボリック
     リンクを指していた場合、リンク先ではなくシンボリックリンク自身の情
     報を返します。

 -- メソッド: Path.exists (*, follow_symlinks=True)

     パスが存在するファイルかディレクトリを指している場合は ‘True’ を返
     します。

     このメソッドは通常はシンボリックリンクをたどります。シンボリックリ
     ンクが存在するかを確認したい場合は ‘follow_symlinks=False’ 引数を追
     加してください。

          >>> Path('.').exists()
          True
          >>> Path('setup.py').exists()
          True
          >>> Path('/etc').exists()
          True
          >>> Path('nonexistentfile').exists()
          False

     バージョン 3.12 で変更: 'follow_symlinks' パラメータが追加されまし
     た。

 -- メソッド: Path.is_file (*, follow_symlinks=True)

     パスが一般ファイルを指していた場合は ‘True’ を返し、その他の種類の
     ファイルの場合は ‘False’ を返します。

     パスが存在しないか壊れたシンボリックリンクだった場合にも ‘False’ が
     返されます; (パーミッションエラーのような) その他のエラーは伝搬され
     ます。

     このメソッドは通常はシンボリックリンクをたどります。シンボリックリ
     ンクを除外するには ‘follow_symlinks=False’ 引数を追加してください。

     バージョン 3.13 で変更: 'follow_symlinks' パラメータが追加されまし
     た。

 -- メソッド: Path.is_dir (*, follow_symlinks=True)

     パスがディレクトリを指していた場合は ‘True’ を返し、その他の種類の
     ファイルの場合は ‘False’ を返します。

     パスが存在しないか壊れたシンボリックリンクだった場合にも ‘False’ が
     返されます; (パーミッションエラーのような) その他のエラーは伝搬され
     ます。

     このメソッドは通常はシンボリックリンクをたどります。ディレクトリへ
     のシンボリックリンクを除外するには ‘follow_symlinks=False’ 引数を追
     加してください。

     バージョン 3.13 で変更: 'follow_symlinks' パラメータが追加されまし
     た。

 -- メソッド: Path.is_symlink ()

     パスがシンボリックリンクを指していた場合 ‘True’ を返し、その他の場
     合は ‘False’ を返します。

     パスが存在しない場合も ‘False’ を返します; (パーミッションエラーの
     ような) その他のエラーは伝搬されます。

 -- メソッド: Path.is_junction ()

     パスがジャンクションを指している場合は ‘True’ を返し、それ以外の場
     合は ‘False’ を返します。現在はWindowsのみジャンクションをサポート
     しています。

     Added in version 3.12.

 -- メソッド: Path.is_mount ()

     パスがマウントポイント 'mount point' (ファイルシステムの中で異なる
     ファイルシステムがマウントされているところ) なら、 ‘True’ を返しま
     す。POSIX では、この関数は 'path' の親ディレクトリである ‘path/..’
     が 'path' と異なるデバイス上にあるか、あるいは ‘path/..’ と 'path'
     が同じデバイス上の同じ i-node を指しているかをチェックします -- こ
     れによって全ての Unix 系システムと POSIX 標準でマウントポイントが検
     出できます。Windowsでは、マウントポイントはドライブレターを持つルー
     ト(e.g.  ‘c:\’)、共有 UNC(e.g.  ‘\\server\share’)またはマウントされ
     たファイルシステムのディレクトリです。

     Added in version 3.7.

     バージョン 3.12 で変更: Windows のサポートが追加されました。

 -- メソッド: Path.is_socket ()

     パスが Unix ソケット (または Unix ソケットへのシンボリックリンク) を
     指していた場合 ‘True’ を返します。その他の種類のファイルの場合
     ‘False’ を返します。

     パスが存在しないか壊れたシンボリックリンクだった場合にも ‘False’ が
     返されます; (パーミッションエラーのような) その他のエラーは伝搬され
     ます。

 -- メソッド: Path.is_fifo ()

     パスが FIFO (または FIFO へのシンボリックリンク) を指していた場合
     ‘True’ を返します。その他の種類のファイルの場合は ‘False’ を返しま
     す。

     パスが存在しないか壊れたシンボリックリンクだった場合にも ‘False’ が
     返されます; (パーミッションエラーのような) その他のエラーは伝搬され
     ます。

 -- メソッド: Path.is_block_device ()

     パスがブロックデバイス (またはブロックデバイスへのシンボリックリン
     ク) を指していた場合 ‘True’ を返します。その他の種類のファイルの場
     合は ‘False’ を返します。

     パスが存在しないか壊れたシンボリックリンクだった場合にも ‘False’ が
     返されます; (パーミッションエラーのような) その他のエラーは伝搬され
     ます。

 -- メソッド: Path.is_char_device ()

     パスがキャラクターデバイス (またはキャラクターデバイスへのシンボリ
     ックリンク) を指していた場合、‘True’ を返します。その他の種類のファ
     イルの場合 ‘False’ を返します。

     パスが存在しないか壊れたシンボリックリンクだった場合にも ‘False’ が
     返されます; (パーミッションエラーのような) その他のエラーは伝搬され
     ます。

 -- メソッド: Path.samefile (other_path)

     このパスが参照するファイルが 'other_path' (Path オブジェクトか文字
     列) と同じであれば ‘True’ を、異なるファイルであれば ‘False’ を返し
     ます。意味的には *note os.path.samefile(): f3e. および *note
     os.path.samestat(): f3d. と同じです。

     なんらかの理由でどちらかのファイルにアクセスできない場合は *note
     OSError: 3f0. が送出されます。

          >>> p = Path('spam')
          >>> q = Path('eggs')
          >>> p.samefile(q)
          False
          >>> p.samefile('spam')
          True

     Added in version 3.5.


File: python.info,  Node: ファイルを読み書きする<2>,  Next: ディレクトリを読む,  Prev: ファイルの種類とステータスを問い合わせる,  Up: 具象パス

5.11.1.12 ファイルを読み書きする
................................

 -- メソッド: Path.open (mode='r', buffering=-1, encoding=None,
          errors=None, newline=None)

     組み込み関数 *note open(): 4e5. のようにパスが指しているファイルを
     開きます:

          >>> p = Path('setup.py')
          >>> with p.open() as f:
          ...     f.readline()
          ...
          '#!/usr/bin/env python3\n'

 -- メソッド: Path.read_text (encoding=None, errors=None, newline=None)

     指定されたファイルの内容を文字列としてデコードして返します:

          >>> p = Path('my_text_file')
          >>> p.write_text('Text file contents')
          18
          >>> p.read_text()
          'Text file contents'

     ファイルを開いた後に閉じます。 オプションのパラメーターの意味は
     *note open(): 4e5. と同じです。

     Added in version 3.5.

     バージョン 3.13 で変更: 'newline' パラメータが追加されました。

 -- メソッド: Path.read_bytes ()

     指定されたファイルの内容をバイナリオブジェクトで返します:

          >>> p = Path('my_binary_file')
          >>> p.write_bytes(b'Binary file contents')
          20
          >>> p.read_bytes()
          b'Binary file contents'

     Added in version 3.5.

 -- メソッド: Path.write_text (data, encoding=None, errors=None,
          newline=None)

     指定されたファイルをテキストモードで開き、'data' を書き込み、ファイ
     ルを閉じます:

          >>> p = Path('my_text_file')
          >>> p.write_text('Text file contents')
          18
          >>> p.read_text()
          'Text file contents'

     同じ名前のファイルが存在する場合は上書きされます。オプションのパラ
     メーターの意味は *note open(): 4e5. と同じです。

     Added in version 3.5.

     バージョン 3.10 で変更: 'newline' パラメータが追加されました。

 -- メソッド: Path.write_bytes (data)

     指定されたファイルをバイトモードで開き、'data' を書き込み、ファイル
     を閉じます:

          >>> p = Path('my_binary_file')
          >>> p.write_bytes(b'Binary file contents')
          20
          >>> p.read_bytes()
          b'Binary file contents'

     同じ名前のファイルがすでにあれば上書きされます。

     Added in version 3.5.


File: python.info,  Node: ディレクトリを読む,  Next: ファイルとディレクトリの作成,  Prev: ファイルを読み書きする<2>,  Up: 具象パス

5.11.1.13 ディレクトリを読む
............................

 -- メソッド: Path.iterdir ()

     パスがディレクトリを指していた場合、ディレクトリの内容のパスオブジ
     ェクトを yield します:

          >>> p = Path('docs')
          >>> for child in p.iterdir(): child
          ...
          PosixPath('docs/conf.py')
          PosixPath('docs/_templates')
          PosixPath('docs/make.bat')
          PosixPath('docs/index.rst')
          PosixPath('docs/_build')
          PosixPath('docs/_static')
          PosixPath('docs/Makefile')

     子の要素は任意の順番で yield されます。特殊なパスの ‘'.'’ と ‘'..'’
     は含まれません。イテレーターを生成したあとにディレクトリにファイル
     を削除または追加した場合に、そのファイルのパスオブジェクトが含まれ
     るかは定義されていません。

     パスがディレクトリでないかアクセスできない場合は *note OSError:
     3f0. を送出します。

 -- メソッド: Path.glob (pattern, *, case_sensitive=None,
          recurse_symlinks=False)

     現在のパスが表すディレクトリ内で相対 'pattern' に一致する (あらゆる
     種類の) すべてのファイルを yield します:

          >>> sorted(Path('.').glob('*.py'))
          [PosixPath('pathlib.py'), PosixPath('setup.py'), PosixPath('test_pathlib.py')]
          >>> sorted(Path('.').glob('*/*.py'))
          [PosixPath('docs/conf.py')]
          >>> sorted(Path('.').glob('**/*.py'))
          [PosixPath('build/lib/pathlib.py'),
           PosixPath('docs/conf.py'),
           PosixPath('pathlib.py'),
           PosixPath('setup.py'),
           PosixPath('test_pathlib.py')]

     参考
     ....

     *note Pattern language: 2708. ドキュメント。

     デフォルトまたは 'case_sensitive' キーワード専用引数に ‘None’ を指
     定した場合、このメソッドはパスの一致判定にプラットフォームに依存し
     た大文字小文字のルールを使用します。一般的にPOSIXは大文字と小文字を
     区別し、Windowsは区別しません。'case_sensitive' を ‘True’ または
     ‘False’ に設定するとこの動作を上書きします。

     デフォルトまたは 'recurse_symlinks' キーワード専用引数が ‘False’ に
     設定された場合、このメソッドは "‘**’" ワイルドカードの展開時にシン
     ボリックリンクをたどりません。'recurse_symlinks' を ‘True’ に設定す
     ると、つねにシンボリックリンクをたどります。

     引数 ‘self’, ‘pattern’ を指定して *note 監査イベント: 1825.
     ‘pathlib.Path.glob’ を送出します。

     バージョン 3.12 で変更: 'case_sensitive' 引数が追加されました。

     バージョン 3.13 で変更: 'recurse_symlinks' パラメータが追加されまし
     た。

     バージョン 3.13 で変更: 'pattern' パラメタが *note path-like
     object: 280. を受け付けるようになりました。

     バージョン 3.13 で変更: Any *note OSError: 3f0. exceptions raised
     from scanning the filesystem are suppressed.  In previous versions,
     such exceptions are suppressed in many cases, but not all.

 -- メソッド: Path.rglob (pattern, *, case_sensitive=None,
          recurse_symlinks=False)

     与えられた相対 'pattern' で再帰的に Glob します。*note Path.glob():
     20e. で 'pattern' の前に "‘**/’" をつけ呼び出した場合と似ています。

     参考
     ....

     *note Pattern language: 2708. と *note Path.glob(): 20e. のドキュメ
     ント。

     引数 ‘self’, ‘pattern’ を指定して *note 監査イベント: 1825.
     ‘pathlib.Path.rglob’ を送出します。

     バージョン 3.12 で変更: 'case_sensitive' 引数が追加されました。

     バージョン 3.13 で変更: 'recurse_symlinks' パラメータが追加されまし
     た。

     バージョン 3.13 で変更: 'pattern' パラメタが *note path-like
     object: 280. を受け付けるようになりました。

 -- メソッド: Path.walk (top_down=True, on_error=None,
          follow_symlinks=False)

     Generate the file names in a directory tree by walking the tree
     either top-down or bottom-up.

     For each directory in the directory tree rooted at 'self'
     (including 'self' but excluding '.'  and '..'), the method yields a
     3-tuple of ‘(dirpath, dirnames, filenames)’.

     'dirpath' is a *note Path: 20a. to the directory currently being
     walked, 'dirnames' is a list of strings for the names of
     subdirectories in 'dirpath' (excluding ‘'.'’ and ‘'..'’), and
     'filenames' is a list of strings for the names of the non-directory
     files in 'dirpath'.  To get a full path (which begins with 'self')
     to a file or directory in 'dirpath', do ‘dirpath / name’.  Whether
     or not the lists are sorted is file system-dependent.

     If the optional argument 'top_down' is true (which is the default),
     the triple for a directory is generated before the triples for any
     of its subdirectories (directories are walked top-down).  If
     'top_down' is false, the triple for a directory is generated after
     the triples for all of its subdirectories (directories are walked
     bottom-up).  No matter the value of 'top_down', the list of
     subdirectories is retrieved before the triples for the directory
     and its subdirectories are walked.

     When 'top_down' is true, the caller can modify the 'dirnames' list
     in-place (for example, using *note del: 1711. or slice assignment),
     and *note Path.walk(): 475. will only recurse into the
     subdirectories whose names remain in 'dirnames'.  This can be used
     to prune the search, or to impose a specific order of visiting, or
     even to inform *note Path.walk(): 475. about directories the caller
     creates or renames before it resumes *note Path.walk(): 475. again.
     Modifying 'dirnames' when 'top_down' is false has no effect on the
     behavior of *note Path.walk(): 475. since the directories in
     'dirnames' have already been generated by the time 'dirnames' is
     yielded to the caller.

     By default, errors from *note os.scandir(): a2d. are ignored.  If
     the optional argument 'on_error' is specified, it should be a
     callable; it will be called with one argument, an *note OSError:
     3f0. instance.  The callable can handle the error to continue the
     walk or re-raise it to stop the walk.  Note that the filename is
     available as the ‘filename’ attribute of the exception object.

     By default, *note Path.walk(): 475. does not follow symbolic links,
     and instead adds them to the 'filenames' list.  Set
     'follow_symlinks' to true to resolve symlinks and place them in
     'dirnames' and 'filenames' as appropriate for their targets, and
     consequently visit directories pointed to by symlinks (where
     supported).

          注釈: 'follow_symlinks' に True を指定すると、シンボリックリン
          クが親ディレクトリを指していた場合に、無限ループになることに注
          意してください。 *note Path.walk(): 475. はすでにたどったディ
          レクトリを管理したりはしません。

          注釈: *note Path.walk(): 475. assumes the directories it walks
          are not modified during execution.  For example, if a
          directory from 'dirnames' has been replaced with a symlink and
          'follow_symlinks' is false, *note Path.walk(): 475. will still
          try to descend into it.  To prevent such behavior, remove
          directories from 'dirnames' as appropriate.

          注釈: Unlike *note os.walk(): 476, *note Path.walk(): 475.
          lists symlinks to directories in 'filenames' if
          'follow_symlinks' is false.

     This example displays the number of bytes used by all files in each
     directory, while ignoring ‘__pycache__’ directories:

          from pathlib import Path
          for root, dirs, files in Path("cpython/Lib/concurrent").walk(on_error=print):
            print(
                root,
                "consumes",
                sum((root / file).stat().st_size for file in files),
                "bytes in",
                len(files),
                "non-directory files"
            )
            if '__pycache__' in dirs:
                  dirs.remove('__pycache__')

     This next example is a simple implementation of *note
     shutil.rmtree(): 2d8.  Walking the tree bottom-up is essential as
     *note rmdir(): 2714. doesn't allow deleting a directory before it
     is empty:

          # Delete everything reachable from the directory "top".
          # CAUTION:  This is dangerous! For example, if top == Path('/'),
          # it could delete all of your files.
          for root, dirs, files in top.walk(top_down=False):
              for name in files:
                  (root / name).unlink()
              for name in dirs:
                  (root / name).rmdir()

     Added in version 3.12.


File: python.info,  Node: ファイルとディレクトリの作成,  Next: リネームと削除,  Prev: ディレクトリを読む,  Up: 具象パス

5.11.1.14 ファイルとディレクトリの作成
......................................

 -- メソッド: Path.touch (mode=0o666, exist_ok=True)

     与えられたパスにファイルを作成します。'mode' が与えられた場合、プロ
     セスの ‘umask’ 値と組み合わせてファイルのモードとアクセスフラグが決
     定されます。ファイルがすでに存在した場合、'exist_ok' が真ならばこの
     関数は正常に終了します (そしてファイルの更新日付が現在の日時に変更
     されます)。その他の場合は *note FileExistsError: fea. が送出されま
     す。

     参考
     ....

     The *note open(): 2712, *note write_text(): e11. and *note
     write_bytes(): e13. methods are often used to create files.

 -- メソッド: Path.mkdir (mode=0o777, parents=False, exist_ok=False)

     与えられたパスに新しくディレクトリを作成します。'mode' が与えられて
     いた場合、プロセスの ‘umask’ 値と組み合わせてファイルのモードとアク
     セスフラグを決定します。パスがすでに存在していた場合 *note
     FileExistsError: fea. が送出されます。

     'parents' の値が真の場合、このパスの親ディレクトリを必要に応じて作
     成します; それらのアクセス制限はデフォルト値が取られ、'mode' は使用
     されません (POSIX の ‘mkdir -p’ コマンドを真似ています)。

     'parents' の値が偽の場合 (デフォルト)、親ディレクトリがないと *note
     FileNotFoundError: e8f. を送出します。

     'exist_ok' の値が (デフォルトの) 偽の場合、対象のディレクトリがすで
     に存在すると *note FileExistsError: fea. を送出します。

     If 'exist_ok' is true, *note FileExistsError: fea. will not be
     raised unless the given path already exists in the file system and
     is not a directory (same behavior as the POSIX ‘mkdir -p’ command).

     バージョン 3.5 で変更: 'exist_ok' 引数が追加されました。

 -- メソッド: Path.symlink_to (target, target_is_directory=False)

     Make this path a symbolic link pointing to 'target'.

     Windows では、シンボリックリンクはファイルかディレクトリのどちらか
     を表しますが、ターゲットに合わせて動的に変化することはありません。
     ターゲットが存在する場合、シンボリックリンクの種類は対象に合わせて
     作成されます。ターゲットが存在せず 'target_is_directory' が真である
     場合、シンボリックリンクはディレクトリのリンクとして作成され、偽で
     ある場合 (デフォルト) はファイルのリンクになります。Windows 以外の
     プラットフォームでは 'target_is_directory' は無視されます。

          >>> p = Path('mylink')
          >>> p.symlink_to('setup.py')
          >>> p.resolve()
          PosixPath('/home/antoine/pathlib/setup.py')
          >>> p.stat().st_size
          956
          >>> p.lstat().st_size
          8

          注釈: 引数の並び (link, target) は *note os.symlink(): 10c5. と
          は逆です。

     バージョン 3.13 で変更: *note os.symlink(): 10c5. が利用できない場
     合 *note UnsupportedOperation: 208. を送出します。以前のバージョン
     では *note NotImplementedError: 209. を送出していました。

 -- メソッド: Path.hardlink_to (target)

     このパスを 'target' と同じファイルへのハードリンクにします。

          注釈: 引数の並び (link, target) は *note os.link(): 10c0. とは
          逆です。

     Added in version 3.10.

     バージョン 3.13 で変更: Raises *note UnsupportedOperation: 208. if
     *note os.link(): 10c0. is not available.  In previous versions,
     *note NotImplementedError: 209. was raised.


File: python.info,  Node: リネームと削除,  Next: パーミッションと所有者,  Prev: ファイルとディレクトリの作成,  Up: 具象パス

5.11.1.15 リネームと削除
........................

 -- メソッド: Path.rename (target)

     このファイルかディレクトリを与えられた 'target' にリネームし、
     'target' を指す新しい ‘Path’ のインスタンスを返します。 Unix では
     'target' が存在するファイルの場合、ユーザにパーミッションがあれば静
     かに置換されます。 Windows では 'target' が存在する場合、*note
     FileExistsError: fea. が送出されます。 'target' は文字列か別のパス
     オブジェクトです:

          >>> p = Path('foo')
          >>> p.open('w').write('some text')
          9
          >>> target = Path('bar')
          >>> p.rename(target)
          PosixPath('bar')
          >>> target.open().read()
          'some text'

     targetパスは絶対または相対で指定できます。相対パスは現在の作業ディ
     レクトリからの相対パスとして解釈し、‘Path’ オブジェクトのディレクト
     リ 'ではありません'。

     It is implemented in terms of *note os.rename(): 10c2. and gives
     the same guarantees.

     バージョン 3.8 で変更: 戻り値を追加し、新しい ‘Path’ インスタンスを
     返します。

 -- メソッド: Path.replace (target)

     現在のファイルまたはディレクトリの名前を 'target' に変更し、
     'target' を指す新しい ‘Path’ のインスタンスを返します。'target' が
     既存のファイルか空のディレクトリを指していた場合、無条件に置き換え
     られます。

     targetパスは絶対または相対で指定できます。相対パスは現在の作業ディ
     レクトリからの相対パスとして解釈し、‘Path’ オブジェクトのディレクト
     リ 'ではありません'。

     バージョン 3.8 で変更: 戻り値を追加し、新しい ‘Path’ インスタンスを
     返します。

 -- メソッド: Path.unlink (missing_ok=False)

     このファイルまたはシンボリックリンクを削除します。パスがディレクト
     リを指している場合は *note Path.rmdir(): 2714. を使用してください。

     'missing_ok' の値が (デフォルトの) 偽の場合、対象のファイルが存在し
     ないと *note FileNotFoundError: e8f. を送出します。

     'missing_ok' の値が真の場合、 *note FileExistsError: fea. 例外を送
     出しません (POSIX の ‘rm -f’ コマンドの挙動と同じ)。

     バージョン 3.8 で変更: 'missing_ok' 引数が追加されました。

 -- メソッド: Path.rmdir ()

     現在のディレクトリを削除します。ディレクトリは空でなければなりませ
     ん。


File: python.info,  Node: パーミッションと所有者,  Prev: リネームと削除,  Up: 具象パス

5.11.1.16 パーミッションと所有者
................................

 -- メソッド: Path.owner (*, follow_symlinks=True)

     ファイルの所有者のユーザー名を返します。ファイルのユーザーID(UID)が
     システムのデータベースに見つからない場合 *note KeyError: 31d. が送
     出されます。

     このメソッドは通常はシンボリックリンクをたどります。シンボリックリ
     ンクの所有者を取得するには ‘follow_symlinks=False’ 引数を追加してく
     ださい。

     バージョン 3.13 で変更: *note pwd: a0. モジュールが利用できない場合
     *note UnsupportedOperation: 208. を送出します。以前のバージョンでは
     *note NotImplementedError: 209. を送出していました。

     バージョン 3.13 で変更: 'follow_symlinks' パラメータが追加されまし
     た。

 -- メソッド: Path.group (*, follow_symlinks=True)

     ファイルの所有者のグループ名を返します。ファイルのグループID(GID)が
     システムのデータベースに見つからない場合 *note KeyError: 31d. が送
     出されます。

     このメソッドは通常はシンボリックリンクをたどります。シンボリックリ
     ンクのグループを取得するには ‘follow_symlinks=False’ 引数を追加して
     ください。

     バージョン 3.13 で変更: *note grp: 5c. モジュールが利用できない場合
     *note UnsupportedOperation: 208. を送出します。以前のバージョンでは
     *note NotImplementedError: 209. を送出していました。

     バージョン 3.13 で変更: 'follow_symlinks' パラメータが追加されまし
     た。

 -- メソッド: Path.chmod (mode, *, follow_symlinks=True)

     *note os.chmod(): 1fc. のようにファイルのモードとアクセス権限を変更
     します。

     このメソッドは通常シンボリックリンクをたどります。一部のUnixではシ
     ンボリックリンク自体のパーミッション変更をサポートしています。その
     ようなプラットフォームでは引数に''follow_symlinks=False'' を追加す
     るか、*note lchmod(): 271b. を使用してください。

          >>> p = Path('setup.py')
          >>> p.stat().st_mode
          33277
          >>> p.chmod(0o444)
          >>> p.stat().st_mode
          33060

     バージョン 3.10 で変更: 'follow_symlinks' パラメータが追加されまし
     た。

 -- メソッド: Path.lchmod (mode)

     *note Path.chmod(): 7ef. のように振る舞いますが、パスがシンボリック
     リンクを指していた場合、リンク先ではなくシンボリックリンク自身のモ
     ードが変更されます。


File: python.info,  Node: Pattern language,  Next: glob モジュールとの比較,  Prev: 具象パス,  Up: pathlib --- オブジェクト指向のファイルシステムパス

5.11.1.17 Pattern language
..........................

The following wildcards are supported in patterns for *note
full_match(): 20c, *note glob(): 20e. and *note rglob(): 20f.:

‘**’ (entire segment)

     Matches any number of file or directory segments, including zero.

‘*’ (entire segment)

     Matches one file or directory segment.

‘*’ (part of a segment)

     Matches any number of non-separator characters, including zero.

‘?’

     Matches one non-separator character.

‘[seq]’

     Matches one character in 'seq'.

‘[!seq]’

     Matches one character not in 'seq'.

For a literal match, wrap the meta-characters in brackets.  For example,
‘"[?]"’ matches the character ‘"?"’.

The "‘**’" wildcard enables recursive globbing.  A few examples:

Pattern                       意味
                              
--------------------------------------------------------------------------------------------------------
                              
"‘**/*’"                      1つ以上の要素がある任意のパス。
                              
                              
"‘**/*.py’"                   最後の要素が "‘.py’" で終わる任意のパス。
                              
                              
"‘assets/**’"                 "‘assets/’" で始まる任意のパス。
                              
                              
"‘assets/**/*’"               "‘assets/’" で始まる任意のパス("‘assets/’" 自身を除く)。
                              

     注釈: Globbing with the "‘**’" wildcard visits every directory in
     the tree.  Large directory trees may take a long time to search.

バージョン 3.13 で変更: Globbing with a pattern that ends with "‘**’"
returns both files and directories.  In previous versions, only
directories were returned.

In *note Path.glob(): 20e. and *note rglob(): 20f, a trailing slash may
be added to the pattern to match only directories.

バージョン 3.11 で変更: Globbing with a pattern that ends with a
pathname components separator (*note sep: 636. or *note altsep: 637.)
returns only directories.


File: python.info,  Node: glob モジュールとの比較,  Next: os と os path モジュールの比較,  Prev: Pattern language,  Up: pathlib --- オブジェクト指向のファイルシステムパス

5.11.1.18 ‘glob’ モジュールとの比較
...................................

The patterns accepted and results generated by *note Path.glob(): 20e.
and *note Path.rglob(): 20f. differ slightly from those by the *note
glob: 5a. module:

  1. Files beginning with a dot are not special in pathlib.  This is
     like passing ‘include_hidden=True’ to *note glob.glob(): 27f.

  2. "‘**’" pattern components are always recursive in pathlib.  This is
     like passing ‘recursive=True’ to *note glob.glob(): 27f.

  3. "‘**’" pattern components do not follow symlinks by default in
     pathlib.  This behaviour has no equivalent in *note glob.glob():
     27f, but you can pass ‘recurse_symlinks=True’ to *note Path.glob():
     20e. for compatible behaviour.

  4. Like all *note PurePath: 473. and *note Path: 20a. objects, the
     values returned from *note Path.glob(): 20e. and *note
     Path.rglob(): 20f. don't include trailing slashes.

  5. The values returned from pathlib's ‘path.glob()’ and ‘path.rglob()’
     include the 'path' as a prefix, unlike the results of
     ‘glob.glob(root_dir=path)’.

  6. The values returned from pathlib's ‘path.glob()’ and ‘path.rglob()’
     may include 'path' itself, for example when globbing "‘**’",
     whereas the results of ‘glob.glob(root_dir=path)’ never include an
     empty string that would correspond to 'path'.


File: python.info,  Node: os と os path モジュールの比較,  Prev: glob モジュールとの比較,  Up: pathlib --- オブジェクト指向のファイルシステムパス

5.11.1.19 ‘os’ と ‘os.path’ モジュールの比較
............................................

pathlib implements path operations using *note PurePath: 473. and *note
Path: 20a. objects, and so it's said to be 'object-oriented'.  On the
other hand, the *note os: 91. and *note os.path: 92. modules supply
functions that work with low-level ‘str’ and ‘bytes’ objects, which is a
more 'procedural' approach.  Some users consider the object-oriented
style to be more readable.

Many functions in *note os: 91. and *note os.path: 92. support ‘bytes’
paths and *note paths relative to directory descriptors: 10c8.  These
features aren't available in pathlib.

Python's ‘str’ and ‘bytes’ types, and portions of the *note os: 91. and
*note os.path: 92. modules, are written in C and are very speedy.
pathlib is written in pure Python and is often slower, but rarely slow
enough to matter.

pathlib's path normalization is slightly more opinionated and consistent
than *note os.path: 92.  For example, whereas *note os.path.abspath():
12ea. eliminates "‘..’" segments from a path, which may change its
meaning if symlinks are involved, *note Path.absolute(): 1612. preserves
these segments for greater safety.

pathlib's path normalization may render it unsuitable for some
applications:

  1. pathlib normalizes ‘Path("my_folder/")’ to ‘Path("my_folder")’,
     which changes a path's meaning when supplied to various operating
     system APIs and command-line utilities.  Specifically, the absence
     of a trailing separator may allow the path to be resolved as either
     a file or directory, rather than a directory only.

  2. pathlib normalizes ‘Path("./my_program")’ to ‘Path("my_program")’,
     which changes a path's meaning when used as an executable search
     path, such as in a shell or when spawning a child process.
     Specifically, the absence of a separator in the path may force it
     to be looked up in ‘PATH’ rather than the current directory.

As a consequence of these differences, pathlib is not a drop-in
replacement for *note os.path: 92.

* Menu:

* 対応するツール::


File: python.info,  Node: 対応するツール,  Up: os と os path モジュールの比較

5.11.1.20 対応するツール
........................

下にあるのは、様々な *note os: 91. 関数とそれに相当する *note PurePath:
473. あるいは *note Path: 20a. の同等のものとの対応表です。

*note os: 91. と *note os.path: 92.       *note pathlib: 93.
                                          
---------------------------------------------------------------------------------------------
                                          
*note os.path.dirname(): 2720.            *note PurePath.parent: 1694.
                                          
                                          
*note os.path.basename(): 2721.           *note PurePath.name: 2702.
                                          
                                          
*note os.path.splitext(): 2722.           *note PurePath.stem: 2705,
                                          *note PurePath.suffix: 2703.
                                          
                                          
*note os.path.join(): 1597.               *note PurePath.joinpath(): 2707.
                                          
                                          
*note os.path.isabs(): 205.               *note PurePath.is_absolute(): 1692.
                                          
                                          
*note os.path.relpath(): 477.             *note PurePath.relative_to(): 2ab. (1)
                                          
                                          
*note os.path.expanduser(): 9e2.          *note Path.expanduser(): e0f. (2)
                                          
                                          
*note os.path.realpath(): 206.            *note Path.resolve(): 1661.
                                          
                                          
*note os.path.abspath(): 12ea.            *note Path.absolute(): 1612. (3)
                                          
                                          
*note os.path.exists(): 9dc.              *note Path.exists(): 9e4.
                                          
                                          
*note os.path.isfile(): 9df.              *note Path.is_file(): 210.
                                          
                                          
*note os.path.isdir(): 9de.               *note Path.is_dir(): 211.
                                          
                                          
*note os.path.islink(): 9da.              *note Path.is_symlink(): 9e6.
                                          
                                          
*note os.path.isjunction(): 470.          *note Path.is_junction(): 478.
                                          
                                          
*note os.path.ismount(): 9e0.             *note Path.is_mount(): 9e5.
                                          
                                          
*note os.path.samefile(): f3e.            *note Path.samefile(): e0d.
                                          
                                          
*note os.getcwd(): 1503.                  *note Path.cwd(): 1691.
                                          
                                          
*note os.stat(): 46d.                     *note Path.stat(): 7ee.
                                          
                                          
*note os.lstat(): 46e.                    *note Path.lstat(): 2710.
                                          
                                          
*note os.listdir(): 10cd.                 *note Path.iterdir(): 1595.
                                          
                                          
*note os.walk(): 476.                     *note Path.walk(): 475. (4)
                                          
                                          
*note os.mkdir(): 1fe,                    *note Path.mkdir(): e0e.
*note os.makedirs(): 1ff.                 

*note os.link(): 10c0.                    *note Path.hardlink_to(): 7ec.
                                          
                                          
*note os.symlink(): 10c5.                 *note Path.symlink_to(): 7ed.
                                          
                                          
*note os.readlink(): 8ee.                 *note Path.readlink(): 8ed.
                                          
                                          
*note os.rename(): 10c2.                  *note Path.rename(): 2718.
                                          
                                          
*note os.replace(): 10c3.                 *note Path.replace(): 2719.
                                          
                                          
*note os.remove(): 10c1,                  *note Path.unlink(): 195d.
*note os.unlink(): 10c6.                  

*note os.rmdir(): 10c4.                   *note Path.rmdir(): 2714.
                                          
                                          
*note os.chmod(): 1fc.                    *note Path.chmod(): 7ef.
                                          
                                          
*note os.lchmod(): 1fb.                   *note Path.lchmod(): 271b.
                                          

脚注
....

   ---------- Footnotes ----------

   (1) *note os.path.relpath(): 477. calls *note abspath(): 12ea. to
make paths absolute and remove "‘..’" parts, whereas *note
PurePath.relative_to(): 2ab. is a lexical operation that raises *note
ValueError: 1e3. when its inputs' anchors differ (e.g.  if one path is
absolute and the other relative.)

   (2) *note os.path.expanduser(): 9e2. returns the path unchanged if
the home directory can't be resolved, whereas *note Path.expanduser():
e0f. raises *note RuntimeError: 17a.

   (3) *note os.path.abspath(): 12ea. removes "‘..’" components without
resolving symlinks, which may change the meaning of the path, whereas
*note Path.absolute(): 1612. leaves any "‘..’" components in the path.

   (4) *note os.walk(): 476. always follows symlinks when categorizing
paths into 'dirnames' and 'filenames', whereas *note Path.walk(): 475.
categorizes all symlinks into 'filenames' when 'follow_symlinks' is
false (the default.)


File: python.info,  Node: os path --- 一般的なパス名操作,  Next: fileinput --- 複数の入力ストリームをまたいだ行を反復する,  Prev: pathlib --- オブジェクト指向のファイルシステムパス,  Up: ファイルとディレクトリへのアクセス

5.11.2 ‘os.path’ -- 一般的なパス名操作
--------------------------------------

'ソースコード:' Lib/genericpath.py(1), Lib/posixpath.py(2) (POSIX) 、
Lib/ntpath.py(3) (Windows) 。

__________________________________________________________________

This module implements some useful functions on pathnames.  To read or
write files see *note open(): 4e5, and for accessing the filesystem see
the *note os: 91. module.  The path parameters can be passed as strings,
or bytes, or any object implementing the *note os.PathLike: c1f.
protocol.

Unix シェルとは異なり、Python はあらゆるパス展開を '自動的には' 行いませ
ん。アプリケーションがシェルのようなパス展開を必要とした場合は、 *note
expanduser(): 9e2. や *note expandvars(): 1381. といった関数を明示的に呼
び出すことで行えます。(*note glob: 5a. モジュールも参照してください)

参考
....

*note pathlib: 93. モジュールは高水準のパスオブジェクトを提供します。

     注釈: 以下のすべての関数は、そのパラメータにバイト列のみ、あるいは
     文字列のみ受け付けます。パスまたはファイル名を返す場合、返り値は同
     じ型のオブジェクトになります。

     注釈: OS によって異なるパス名の決まりがあるため、標準ライブラリには
     このモジュールのいくつかのバージョンが含まれています。 *note
     os.path: 92. モジュールは常に現在 Python が動作している OS に適した
     パスモジュールであるため、ローカルのパスを扱うのに適しています。各
     々のモジュールをインポートして '常に' 一つのフォーマットを利用する
     ことも可能です。これらはすべて同じインターフェースを持っています:

        * ‘posixpath’ UNIX スタイルのパス用

        * ‘ntpath’ Windows パス用

バージョン 3.8 で変更: *note exists(): 9dc.、 *note lexists(): 9dd.、
*note isdir(): 9de.、 *note isfile(): 9df.、 *note islink(): 9da.、およ
び *note ismount(): 9e0. は、OS レベルで表現できない文字列を含む可能性が
ある例外を送出する代わりに ‘False’ を返すようになりました。

 -- の関数: os.path.abspath (path)

     パス名 'path' の正規化された絶対パスを返します。ほとんどのプラット
     フォームでは、これは関数 *note normpath(): 12e9. を次のように呼び出
     した時と等価です: ‘normpath(join(os.getcwd(), path))’。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.basename (path)

     パス名 'path' の末尾のファイル名部分を返します。これは関数 *note
     split(): 2725. に 'path' を渡した時に返されるペアの 2 番めの要素で
     す。この関数が返すのは Unix の ‘basename’ とは異なります; Unix の
     ‘basename’ は ‘'/foo/bar/'’ に対して ‘'bar'’ を返しますが、関数
     *note basename(): 2721. は空文字列 (‘''’) を返します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.commonpath (paths)

     Return the longest common sub-path of each pathname in the iterable
     'paths'.  Raise *note ValueError: 1e3. if 'paths' contain both
     absolute and relative pathnames, if 'paths' are on different
     drives, or if 'paths' is empty.  Unlike *note commonprefix(): e0b,
     this returns a valid path.

     Added in version 3.5.

     バージョン 3.6 で変更: *note path-like objects: 280. のシーケンスを
     受け入れるようになりました。

     バージョン 3.13 で変更: Any iterable can now be passed, rather than
     just sequences.

 -- の関数: os.path.commonprefix (list)

     'list' 内のすべてのパスに共通する接頭辞のうち、最も長いものを (パス
     名の 1 文字 1 文字を判断して) 返します。'list' が空の場合、空文字列
     (‘''’) を返します。

          注釈: この関数は一度に 1 文字ずつ処理するため、不正なパスを返
          す場合があります。有効なパスを取得するためには、*note
          commonpath(): e0a. を参照してください。

               >>> os.path.commonprefix(['/usr/lib', '/usr/local/lib'])
               '/usr/l'

               >>> os.path.commonpath(['/usr/lib', '/usr/local/lib'])
               '/usr'

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.dirname (path)

     パス名 'path' のディレクトリ名を返します。これは関数 *note split():
     2725. に 'path' を渡した時に返されるペアの 1 番めの要素です。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.exists (path)

     'path' が実在するパスかオープンしているファイル記述子を参照している
     場合 ‘True’ を返します。壊れたシンボリックリンクについては ‘False’
     を返します。一部のプラットフォームでは、たとえ 'path' が物理的に存
     在していたとしても、要求されたファイルに対する *note os.stat():
     46d. の実行権がなければこの関数が ‘False’ を返すことがあります。

     バージョン 3.3 で変更: 'path' は整数でも可能になりました: それがオ
     ープンしているファイル記述子なら ‘True’ が返り、それ以外なら
     ‘False’ が返ります。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.lexists (path)

     Return ‘True’ if 'path' refers to an existing path, including
     broken symbolic links.  Equivalent to *note exists(): 9dc. on
     platforms lacking *note os.lstat(): 46e.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.expanduser (path)

     Unix および Windows では、与えられた引数の先頭のパス要素 ‘~’ 、また
     は ‘~user’ を、 'user' のホームディレクトリのパスに置き換えて返しま
     す。

     Unix では、先頭の ‘~’ は、環境変数 ‘HOME’ が設定されているならその
     値に置き換えられます。設定されていない場合は、現在のユーザのホーム
     ディレクトリをビルトインモジュール *note pwd: a0. を使ってパスワー
     ドディレクトリから探して置き換えます。先頭の ‘~user’ については、直
     接パスワードディレクトリから探します。

     On Windows, ‘USERPROFILE’ will be used if set, otherwise a
     combination of ‘HOMEPATH’ and ‘HOMEDRIVE’ will be used.  An initial
     ‘~user’ is handled by checking that the last directory component of
     the current user's home directory matches ‘USERNAME’, and replacing
     it if so.

     置き換えに失敗したり、引数のパスがチルダで始まっていなかった場合は
     、パスをそのまま返します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.8 で変更: Windowsで ‘HOME’ は参照しなくなりました。

 -- の関数: os.path.expandvars (path)

     引数のパスの環境変数を展開して返します。引数の中の ‘$name’ または
     ‘${name}’ のような形式の文字列は環境変数、 'name' の値に置き換えら
     れます。不正な変数名や存在しない変数名の場合には変換されず、そのま
     ま返します。

     Windows では、 ‘$name’ や ‘${name}’ の形式に加えて、 ‘%name%’ の形
     式もサポートされています。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.getatime (path)

     Return the time of last access of 'path'.  The return value is a
     floating-point number giving the number of seconds since the epoch
     (see the *note time: d7. module).  Raise *note OSError: 3f0. if the
     file does not exist or is inaccessible.

 -- の関数: os.path.getmtime (path)

     Return the time of last modification of 'path'.  The return value
     is a floating-point number giving the number of seconds since the
     epoch (see the *note time: d7. module).  Raise *note OSError: 3f0.
     if the file does not exist or is inaccessible.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.getctime (path)

     システムの ctime、Unix系など一部のシステムでは最後にメタデータが変
     更された時刻、Windows などその他のシステムでは 'path' の作成時刻を
     返します。返り値はエポック (*note time: d7. モジュールを参照) から
     の経過時間を示す秒数になります。ファイルが存在しない、あるいはアク
     セスできなかった場合は *note OSError: 3f0. を送出します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.getsize (path)

     'path' のサイズをバイト数で返します。ファイルが存在しない、あるいは
     アクセスできなかった場合は *note OSError: 3f0. を送出します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.isabs (path)

     Return ‘True’ if 'path' is an absolute pathname.  On Unix, that
     means it begins with a slash, on Windows that it begins with two
     (back)slashes, or a drive letter, colon, and (back)slash together.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.13 で変更: On Windows, returns ‘False’ if the given
     path starts with exactly one (back)slash.

 -- の関数: os.path.isfile (path)

     'path' が *note 存在する: 9dc. 一般ファイルなら ‘True’ を返します。
     この関数はシンボリックリンクの先を辿るので、同じパスに対して *note
     islink(): 9da. と *note isfile(): 9df. の両方が真を返すことがありま
     す。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.isdir (path)

     'path' が *note 存在する: 9dc. ディレクトリなら ‘True’ を返します。
     この関数はシンボリックリンクの先を辿るので、同じパスに対して *note
     islink(): 9da. と *note isdir(): 9de. の両方が真を返すことがありま
     す。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.isjunction (path)

     Return ‘True’ if 'path' refers to an *note existing: 9dd. directory
     entry that is a junction.  Always return ‘False’ if junctions are
     not supported on the current platform.

     Added in version 3.12.

 -- の関数: os.path.islink (path)

     'path' が *note 存在する: 9dc. ディレクトリを指すシンボリックリンク
     なら ‘True’ を返します。 Python ランタイムがシンボリックリンクをサ
     ポートしていないプラットフォームでは、常に ‘False’ を返します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.ismount (path)

     パス名 'path' がマウントポイント 'mount point' (ファイルシステムの
     中で異なるファイルシステムがマウントされているところ) なら、 ‘True’
     を返します。 POSIX では、この関数は 'path' の親ディレクトリである
     ‘`path'/..’ が 'path' と異なるデバイス上にあるか、あるいは
     ‘`path'/..’ と 'path' が同じデバイス上の同じ i-node を指しているか
     をチェックします -- これによって全ての Unix 系システムと POSIX 標準
     でマウントポイントが検出できます。 だたし、同じファイルシステムの
     bind mount の信頼できる検出はできません。 Windows では、ドライブレ
     ターを持つルートと共有 UNC は常にマウントポイントであり、また他のパ
     スでは、入力のパスが異なるデバイスからのものか見るために
     ‘GetVolumePathName’ が呼び出されます。

     バージョン 3.4 で変更: Added support for detecting non-root mount
     points on Windows.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.isdevdrive (path)

     Return ‘True’ if pathname 'path' is located on a Windows Dev Drive.
     A Dev Drive is optimized for developer scenarios, and offers faster
     performance for reading and writing files.  It is recommended for
     use for source code, temporary build directories, package caches,
     and other IO-intensive operations.

     May raise an error for an invalid path, for example, one without a
     recognizable drive, but returns ‘False’ on platforms that do not
     support Dev Drives.  See the Windows documentation(4) for
     information on enabling and creating Dev Drives.

     Added in version 3.12.

     バージョン 3.13 で変更: The function is now available on all
     platforms, and will always return ‘False’ on those that have no
     support for Dev Drives

 -- の関数: os.path.isreserved (path)

     Return ‘True’ if 'path' is a reserved pathname on the current
     system.

     On Windows, reserved filenames include those that end with a space
     or dot; those that contain colons (i.e.  file streams such as
     "name:stream"), wildcard characters (i.e.  ‘'*?"<>'’), pipe, or
     ASCII control characters; as well as DOS device names such as
     "NUL", "CON", "CONIN$", "CONOUT$", "AUX", "PRN", "COM1", and
     "LPT1".

          注釈: This function approximates rules for reserved paths on
          most Windows systems.  These rules change over time in various
          Windows releases.  This function may be updated in future
          Python releases as changes to the rules become broadly
          available.

     *note Availability: 1cbe.: Windows.

     Added in version 3.13.

 -- の関数: os.path.join (path, *paths)

     Join one or more path segments intelligently.  The return value is
     the concatenation of 'path' and all members of '*paths', with
     exactly one directory separator following each non-empty part,
     except the last.  That is, the result will only end in a separator
     if the last part is either empty or ends in a separator.  If a
     segment is an absolute path (which on Windows requires both a drive
     and a root), then all previous segments are ignored and joining
     continues from the absolute path segment.

     On Windows, the drive is not reset when a rooted path segment
     (e.g., ‘r'\foo'’) is encountered.  If a segment is on a different
     drive or is an absolute path, all previous segments are ignored and
     the drive is reset.  Note that since there is a current directory
     for each drive, ‘os.path.join("c:", "foo")’ represents a path
     relative to the current directory on drive ‘C:’ (‘c:foo’), not
     ‘c:\foo’.

     バージョン 3.6 で変更: 'path' と 'paths' が *note path-like object:
     280. を受け付けるようになりました。

 -- の関数: os.path.normcase (path)

     パス名の大文字・小文字を正規化します。 Windowsでは、パス名にある文
     字を全て小文字に、スラッシュをバックスラッシュに変換します。 他のオ
     ペレーティングシステムでは、パスを変更せずに返します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.normpath (path)

     パスを正規化します。余分な区切り文字や上位レベル参照を除去し、
     ‘A//B’、‘A/B/’、‘A/./B’ や ‘A/foo/../B’ などはすべて ‘A/B’ になりま
     す。この文字列操作は、シンボリックリンクを含むパスの意味を変えてし
     まう場合があります。Windows では、スラッシュをバックスラッシュに変
     換します。大文字小文字の正規化には *note normcase(): 272a. を使用し
     てください。

          注釈: On POSIX systems, in accordance with IEEE Std 1003.1
          2013 Edition; 4.13 Pathname Resolution(5), if a pathname
          begins with exactly two slashes, the first component following
          the leading characters may be interpreted in an
          implementation-defined manner, although more than two leading
          characters shall be treated as a single character.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.realpath (path, *, strict=False)

     Return the canonical path of the specified filename, eliminating
     any symbolic links encountered in the path (if they are supported
     by the operating system).  On Windows, this function will also
     resolve MS-DOS (also called 8.3) style names such as ‘C:\\PROGRA~1’
     to ‘C:\\Program Files’.

     If a path doesn't exist or a symlink loop is encountered, and
     'strict' is ‘True’, *note OSError: 3f0. is raised.  If 'strict' is
     ‘False’ these errors are ignored, and so the result might be
     missing or otherwise inaccessible.

          注釈: This function emulates the operating system's procedure
          for making a path canonical, which differs slightly between
          Windows and UNIX with respect to how links and subsequent path
          components interact.

          Operating system APIs make paths canonical as needed, so it's
          not normally necessary to call this function.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.8 で変更: Windows においてシンボリックリンクとジャンク
     ションが解決されるようになりました。

     バージョン 3.10 で変更: 'strict' 引数が追加されました。

 -- の関数: os.path.relpath (path, start=os.curdir)

     カレントディレクトリあるいはオプションの 'start' ディレクトリからの
     'path' への相対パスを返します。これはパス計算で行っており、ファイル
     システムにアクセスして 'path' や 'start' の存在や性質を確認すること
     はありません。Windowsでは、 'path' と 'start' が異なるドライブの場
     合、 *note ValueError: 1e3. を送出します。

     'start' defaults to *note os.curdir: 272b.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.samefile (path1, path2)

     引数の両パス名が同じファイルまたはディレクトリを参照している場合、
     ‘True’ を返します。これは、デバイス番号と i-node 番号で決定されます
     。どちらかのパス名への *note os.stat(): 46d. 呼び出しが失敗した場合
     、例外が送出されます。

     バージョン 3.2 で変更: Windows サポートを追加しました。

     バージョン 3.4 で変更: Windows が他のプラットフォームと同じ実装を使
     用するようになりました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.sameopenfile (fp1, fp2)

     ファイル記述子 'fp1' と 'fp2' が同じファイルを参照していたら ‘True’
     を返します。

     バージョン 3.2 で変更: Windows サポートを追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.samestat (stat1, stat2)

     stat タプル 'stat1' と 'stat2' が同じファイルを参照していれば
     ‘True’ を返します。これらのタプルは *note os.fstat(): d59. 、 *note
     os.lstat(): 46e. あるいは *note os.stat(): 46d. の返り値で構いませ
     ん。この関数は *note samefile(): f3e. と *note sameopenfile():
     272c. を使用した比較に基いて実装しています。

     バージョン 3.4 で変更: Windows サポートを追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.split (path)

     パス名 'path' を ‘(head, tail)’ のペアに分割します。 'tail' はパス
     名の構成要素の末尾で、 'head' はそれより前の部分です。 'tail' はス
     ラッシュを含みません; もし 'path' がスラッシュで終わっていれば
     'tail' は空文字列になります。もし 'path' にスラッシュがなければ、
     'head' は空文字になります。 'path' が空文字なら、 'head' と 'tail'
     の両方が空文字になります。 'head' の末尾のスラッシュは 'head' がル
     ートディレクトリ (または 1 個以上のスラッシュだけ) でない限り取り除
     かれます。 ‘join(head, tail)’ は常に 'path' と同じ場所を返しますが
     、文字列としては異なるかもしれません。関数 *note dirname(): 2720,
     *note basename(): 2721. も参照してください。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.splitdrive (path)

     パス名 'path' を ‘(drive, tail)’ のペアに分割します。'drive' はマウ
     ントポイントか空文字列になります。ドライブ指定をサポートしていない
     システムでは、'drive' は常に空文字になります。どの場合でも、‘drive
     + tail’ は 'path' と等しくなります。

     Windows では、パス名はドライブ名/UNC 共有ポイントと相対パスに分割さ
     れます。

     パスがドライブレターを含む場合、ドライブレターにはコロンまでが含ま
     れます:

          >>> splitdrive("c:/dir")
          ("c:", "/dir")

     If the path contains a UNC path, drive will contain the host name
     and share:

          >>> splitdrive("//host/computer/dir")
          ("//host/computer", "/dir")

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.path.splitroot (path)

     Split the pathname 'path' into a 3-item tuple ‘(drive, root, tail)’
     where 'drive' is a device name or mount point, 'root' is a string
     of separators after the drive, and 'tail' is everything after the
     root.  Any of these items may be the empty string.  In all cases,
     ‘drive + root + tail’ will be the same as 'path'.

     On POSIX systems, 'drive' is always empty.  The 'root' may be empty
     (if 'path' is relative), a single forward slash (if 'path' is
     absolute), or two forward slashes (implementation-defined per IEEE
     Std 1003.1-2017; 4.13 Pathname Resolution(6).)  For example:

          >>> splitroot('/home/sam')
          ('', '/', 'home/sam')
          >>> splitroot('//home/sam')
          ('', '//', 'home/sam')
          >>> splitroot('///home/sam')
          ('', '/', '//home/sam')

     On Windows, 'drive' may be empty, a drive-letter name, a UNC share,
     or a device name.  The 'root' may be empty, a forward slash, or a
     backward slash.  For example:

          >>> splitroot('C:/Users/Sam')
          ('C:', '/', 'Users/Sam')
          >>> splitroot('//Server/Share/Users/Sam')
          ('//Server/Share', '/', 'Users/Sam')

     Added in version 3.12.

 -- の関数: os.path.splitext (path)

     Split the pathname 'path' into a pair ‘(root, ext)’ such that ‘root
     + ext == path’, and the extension, 'ext', is empty or begins with a
     period and contains at most one period.

     If the path contains no extension, 'ext' will be ‘''’:

          >>> splitext('bar')
          ('bar', '')

     If the path contains an extension, then 'ext' will be set to this
     extension, including the leading period.  Note that previous
     periods will be ignored:

          >>> splitext('foo.bar.exe')
          ('foo.bar', '.exe')
          >>> splitext('/foo/bar.exe')
          ('/foo/bar', '.exe')

     Leading periods of the last component of the path are considered to
     be part of the root:

          >>> splitext('.cshrc')
          ('.cshrc', '')
          >>> splitext('/foo/....jpg')
          ('/foo/....jpg', '')

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- データ: os.path.supports_unicode_filenames

     ファイル名に任意の Unicode 文字列を (システムの制限内で) 使用できる
     場合は ‘True’ になります。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/genericpath.py

   (2) https://github.com/python/cpython/tree/3.13/Lib/posixpath.py

   (3) https://github.com/python/cpython/tree/3.13/Lib/ntpath.py

   (4) https://learn.microsoft.com/windows/dev-drive/

   (5) 
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13

   (6) 
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13


File: python.info,  Node: fileinput --- 複数の入力ストリームをまたいだ行を反復する,  Next: stat --- stat の結果を解釈する,  Prev: os path --- 一般的なパス名操作,  Up: ファイルとディレクトリへのアクセス

5.11.3 ‘fileinput’ -- 複数の入力ストリームをまたいだ行を反復する
----------------------------------------------------------------

'ソースコード:' Lib/fileinput.py(1)

__________________________________________________________________

このモジュールは標準入力やファイルの並びにまたがるループを素早く書くため
のヘルパークラスと関数を提供しています。単一のファイルを読み書きしたいだ
けなら、 *note open(): 4e5. を参照してください。

典型的な使い方は以下の通りです:

     import fileinput
     for line in fileinput.input(encoding="utf-8"):
         process(line)

このスクリプトは ‘sys.argv[1:]’ に列挙されている全てのファイルの行に渡っ
て反復処理を行います。もし列挙されているものがなければ、 ‘sys.stdin’ が
デフォルトとして扱われます。 ファイル名として ‘'-'’ が与えられた場合も、
‘sys.stdin’ に置き換えられ、 'mode' と 'openhook' は無視されます。 別の
ファイル名リストを使いたい時には、そのリストを *note input(): 7ca. の最
初の引数に与えます。 ファイル名が 1 つでも受け付けます。

全てのファイルはデフォルトでテキストモードでオープンされます。しかし、
*note input(): 7ca. や *note FileInput: 702. をコールする際に 'mode' パ
ラメータを指定すれば、これをオーバーライドすることができます。オープン中
あるいは読み込み中にI/Oエラーが発生した場合には、 *note OSError: 3f0. が
発生します。

バージョン 3.3 で変更: 以前は *note IOError: 1026. が送出されました; そ
れは現在 *note OSError: 3f0. のエイリアスです。

‘sys.stdin’ が2回以上使われた場合は、2回目以降は行を返しません。ただしイ
ンタラクティブに利用している時や明示的にリセット (‘sys.stdin.seek(0)’ を
使う) を行った場合はその限りではありません。

空のファイルは開いた後すぐ閉じられます。空のファイルはファイル名リストの
最後にある場合にしか外部に影響を与えません。

ファイルの各行は、各種改行文字まで含めて返されます。ファイルの最後が改行
文字で終っていない場合には、改行文字で終わらない行が返されます。

You can control how files are opened by providing an opening hook via
the 'openhook' parameter to *note fileinput.input(): 7ca. or *note
FileInput(): 702.  The hook must be a function that takes two arguments,
'filename' and 'mode', and returns an accordingly opened file-like
object.  If 'encoding' and/or 'errors' are specified, they will be
passed to the hook as additional keyword arguments.  This module
provides a *note hook_compressed(): 7cb. to support compressed files.

以下の関数がこのモジュールの基本的なインターフェースです:

 -- の関数: fileinput.input (files=None, inplace=False, backup='', *,
          mode='r', openhook=None, encoding=None, errors=None)

     *note FileInput: 702. クラスのインスタンスを作ります。生成されたイ
     ンスタンスは、このモジュールの関数群が利用するグローバルな状態とし
     て利用されます。この関数への引数は *note FileInput: 702. クラスのコ
     ンストラクタへ渡されます。

     *note FileInput: 702. のインスタンスは *note with: 59c. 文の中でコ
     ンテキストマネージャーとして使用できます。 次の例では、仮に例外が生
     じたとしても ‘with’ 文から抜けた後で 'input' は閉じられます:

          with fileinput.input(files=('spam.txt', 'eggs.txt'), encoding="utf-8") as f:
              for line in f:
                  process(line)

     バージョン 3.2 で変更: コンテキストマネージャとして使うことができる
     ようになりました。

     バージョン 3.8 で変更: キーワード引数 'mode' と 'openhook' は、キー
     ワード専用引数になりました。

     バージョン 3.10 で変更: The keyword-only parameter 'encoding' and
     'errors' are added.

以下の関数は *note fileinput.input(): 7ca. 関数によって作られたグローバ
ルな状態を利用します。アクティブな状態が無い場合には、 *note
RuntimeError: 17a. が発生します。

 -- の関数: fileinput.filename ()

     現在読み込み中のファイル名を返します。一行目が読み込まれる前は
     ‘None’ を返します。

 -- の関数: fileinput.fileno ()

     現在のファイルの "ファイル記述子" を整数値で返します。ファイルがオ
     ープンされていない場合 (最初の行の前、ファイルとファイルの間) は
     ‘-1’ を返します。

 -- の関数: fileinput.lineno ()

     最後に読み込まれた行の、累積した行番号を返します。1行目が読み込まれ
     る前は ‘0’ を返します。最後のファイルの最終行が読み込まれた後には、
     その行の行番号を返します。

 -- の関数: fileinput.filelineno ()

     現在のファイル中での行番号を返します。1行目が読み込まれる前は ‘0’ を
     返します。最後のファイルの最終行が読み込まれた後には、その行のファ
     イル中での行番号を返します。

 -- の関数: fileinput.isfirstline ()

     最後に読み込まれた行がファイルの1行目なら ‘True’ 、そうでなければ
     ‘False’ を返します。

 -- の関数: fileinput.isstdin ()

     最後に読み込まれた行が ‘sys.stdin’ から読み込まれていれば ‘True’ 、
     そうでなければ ‘False’ を返します。

 -- の関数: fileinput.nextfile ()

     現在のファイルを閉じます。次の繰り返しでは(存在すれば)次のファイル
     の最初の行が読み込まれます。閉じたファイルの読み込まれなかった行は
     、累積の行数にカウントされません。ファイル名は次のファイルの最初の
     行が読み込まれるまで変更されません。最初の行の読み込みが行われるま
     では、この関数は呼び出されても何もしませんので、最初のファイルをス
     キップするために利用することはできません。最後のファイルの最終行が
     読み込まれた後にも、この関数は呼び出されても何もしません。

 -- の関数: fileinput.close ()

     シーケンスを閉じます。

このモジュールのシーケンスの振舞いを実装しているクラスのサブクラスを作る
こともできます:

 -- クラス: fileinput.FileInput (files=None, inplace=False, backup='',
          *, mode='r', openhook=None, encoding=None, errors=None)

     *note FileInput: 702. クラスはモジュールの関数に対応するメソッド
     *note filename(): 272f. 、 *note fileno(): 13d5. 、 *note lineno():
     2730. 、 *note filelineno(): 2731. 、 *note isfirstline(): 2732. 、
     *note isstdin(): 2733. 、 *note nextfile(): 2734. および *note
     close(): 2735. を実装しています。*note イテラブル: 10ad. であること
     に加えて、次の入力行を返す *note readline(): 1c27. メソッドがありま
     す。シーケンスはシーケンシャルに読み込むことしかできません。つまり
     ランダムアクセスと *note readline(): 1c27. を混在させることはできま
     せん。

     'mode' を使用すると、 *note open(): 4e5. に渡すファイルモードを指定
     することができます。これは ‘'r'’ および ‘'rb'’ のうちのいずれかとな
     ります。

     'openhook' を指定する場合は、ふたつの引数 'filename' と 'mode' をと
     る関数でなければなりません。この関数の返り値は、オープンしたファイ
     ルオブジェクトとなります。'inplace' と 'openhook' を同時に使うこと
     はできません。

     You can specify 'encoding' and 'errors' that is passed to *note
     open(): 4e5. or 'openhook'.

     *note FileInput: 702. のインスタンスは *note with: 59c. 文の中でコ
     ンテキストマネージャーとして使用できます。 次の例では、仮に例外が生
     じたとしても ‘with’ 文から抜けた後で 'input' は閉じられます:

          with FileInput(files=('spam.txt', 'eggs.txt')) as input:
              process(input)

     バージョン 3.2 で変更: コンテキストマネージャとして使うことができる
     ようになりました。

     バージョン 3.8 で変更: キーワード引数 'mode' と 'openhook' は、キー
     ワード専用引数になりました。

     バージョン 3.10 で変更: The keyword-only parameter 'encoding' and
     'errors' are added.

     バージョン 3.11 で変更: The ‘'rU'’ and ‘'U'’ modes and the
     ‘__getitem__()’ method have been removed.

'インプレース(in-place)フィルタオプション:' キーワード引数
‘inplace=True’ が *note fileinput.input(): 7ca. か *note FileInput: 702.
クラスのコンストラクタに渡された場合には、入力ファイルはバックアップファ
イルに移動され、標準出力が入力ファイルに設定されます(バックアップファイ
ルと同じ名前のファイルが既に存在していた場合には、警告無しに置き替えられ
ます)。これによって入力ファイルをその場で書き替えるフィルタを書くことが
できます。キーワード引数 'backup' (通常は ‘backup='.<拡張子>'’ という形
で利用します)が与えられていた場合、バックアップファイルの拡張子として利
用され、バックアップファイルは削除されずに残ります。デフォルトでは、拡張
子は ‘'.bak'’ になっていて、出力先のファイルが閉じられればバックアップフ
ァイルも消されます。インプレースフィルタ機能は、標準入力を読み込んでいる
間は無効にされます。

このモジュールには、次のふたつのオープン時フックが用意されています:

 -- の関数: fileinput.hook_compressed (filename, mode, *, encoding=None,
          errors=None)

     gzip や bzip2 で圧縮された (拡張子が ‘'.gz'’ や ‘'.bz2'’ の) ファイ
     ルを、 *note gzip: 5d. モジュールや *note bz2: f. モジュールを使っ
     て透過的にオープンします。ファイルの拡張子が ‘'.gz'’ や ‘'.bz2'’ で
     ない場合は、通常通りファイルをオープンします (つまり、 *note
     open(): 4e5. をコールする際に伸長を行いません)。

     The 'encoding' and 'errors' values are passed to *note
     io.TextIOWrapper: 786. for compressed files and open for normal
     files.

     使用例: ‘fi =
     fileinput.FileInput(openhook=fileinput.hook_compressed,
     encoding="utf-8")’

     バージョン 3.10 で変更: The keyword-only parameter 'encoding' and
     'errors' are added.

 -- の関数: fileinput.hook_encoded (encoding, errors=None)

     各ファイルを *note open(): 4e5. でオープンするフックを返します。指
     定した 'encoding' および 'errors' でファイルを読み込みます。

     使用例: ‘fi =
     fileinput.FileInput(openhook=fileinput.hook_encoded("utf-8",
     "surrogateescape"))’

     バージョン 3.6 で変更: オプションの 'errors' 引数が追加されました。

     バージョン 3.10 で非推奨: This function is deprecated since *note
     fileinput.input(): 7ca. and *note FileInput: 702. now have
     'encoding' and 'errors' parameters.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/fileinput.py


File: python.info,  Node: stat --- stat の結果を解釈する,  Next: filecmp --- ファイルとディレクトリの比較,  Prev: fileinput --- 複数の入力ストリームをまたいだ行を反復する,  Up: ファイルとディレクトリへのアクセス

5.11.4 ‘stat’ -- ‘stat()’ の結果を解釈する
------------------------------------------

'ソースコード:' Lib/stat.py(1)

__________________________________________________________________

*note stat: bc. モジュールでは、 *note os.stat(): 46d. 、 *note
os.lstat(): 46e. 、および *note os.fstat(): d59. が存在する場合に、これ
らの関数が返す内容を解釈するための定数や関数を定義しています。 ‘stat()’
、 ‘fstat()’ 、および ‘lstat()’ の関数呼び出しについての完全な記述はシス
テムのドキュメントを参照してください。

バージョン 3.4 で変更: stat モジュールは、C 実装に裏付けされるようになり
ました。

*note stat: bc. モジュールでは、特殊なファイル型を判別するための以下の関
数を定義しています:

 -- の関数: stat.S_ISDIR (mode)

     ファイルのモードがディレクトリの場合にゼロでない値を返します。

 -- の関数: stat.S_ISCHR (mode)

     ファイルのモードがキャラクタ型の特殊デバイスファイルの場合にゼロで
     ない値を返します。

 -- の関数: stat.S_ISBLK (mode)

     ファイルのモードがブロック型の特殊デバイスファイルの場合にゼロでな
     い値を返します。

 -- の関数: stat.S_ISREG (mode)

     ファイルのモードが通常ファイルの場合にゼロでない値を返します。

 -- の関数: stat.S_ISFIFO (mode)

     ファイルのモードが FIFO (名前つきパイプ) の場合にゼロでない値を返し
     ます。

 -- の関数: stat.S_ISLNK (mode)

     ファイルのモードがシンボリックリンクの場合にゼロでない値を返します
     。

 -- の関数: stat.S_ISSOCK (mode)

     ファイルのモードがソケットの場合にゼロでない値を返します。

 -- の関数: stat.S_ISDOOR (mode)

     ファイルのモードがドアの場合にゼロでない値を返します。

     Added in version 3.4.

 -- の関数: stat.S_ISPORT (mode)

     ファイルのモードがイベントポートの場合にゼロでない値を返します。

     Added in version 3.4.

 -- の関数: stat.S_ISWHT (mode)

     ファイルのモードがホワイトアウトの場合にゼロでない値を返します。

     Added in version 3.4.

より一般的なファイルのモードを操作するための二つの関数が定義されています
:

 -- の関数: stat.S_IMODE (mode)

     *note os.chmod(): 1fc. で設定することのできる一部のファイルモード
     -- すなわち、ファイルの許可ビット (permission bits) に加え、 (サポ
     ートされているシステムでは) スティッキービット (sticky bit)、実行グ
     ループ ID 設定 (set-group-id) および実行ユーザ ID 設定
     (set-user-id) ビット -- を返します。

 -- の関数: stat.S_IFMT (mode)

     Return the portion of the file's mode that describes the file type
     (used by the ‘S_IS*()’ functions above).

Normally, you would use the ‘os.path.is*()’ functions for testing the
type of a file; the functions here are useful when you are doing
multiple tests of the same file and wish to avoid the overhead of the
‘stat()’ system call for each test.  These are also useful when checking
for information about a file that isn't handled by *note os.path: 92,
like the tests for block and character devices.

以下はプログラム例です:

     import os, sys
     from stat import *

     def walktree(top, callback):
         '''recursively descend the directory tree rooted at top,
            calling the callback function for each regular file'''

         for f in os.listdir(top):
             pathname = os.path.join(top, f)
             mode = os.lstat(pathname).st_mode
             if S_ISDIR(mode):
                 # It's a directory, recurse into it
                 walktree(pathname, callback)
             elif S_ISREG(mode):
                 # It's a file, call the callback function
                 callback(pathname)
             else:
                 # Unknown file type, print a message
                 print('Skipping %s' % pathname)

     def visitfile(file):
         print('visiting', file)

     if __name__ == '__main__':
         walktree(sys.argv[1], visitfile)

ファイルのモードを人間が可読な文字列に変換するために、追加のユーティリテ
ィ関数が提供されています。

 -- の関数: stat.filemode (mode)

     ファイルのモードを '-rwxrwxrwx' 形式の文字列に変換します。

     Added in version 3.3.

     バージョン 3.4 で変更: この関数は、*note S_IFDOOR: f87. 、 *note
     S_IFPORT: f88. 、 *note S_IFWHT: f89. をサポートしています。

以下の全ての変数は、 *note os.stat(): 46d. 、 *note os.fstat(): d59. 、
または *note os.lstat(): 46e. が返す 10 要素のタプルにおけるインデクスを
単にシンボル定数化したものです。

 -- データ: stat.ST_MODE

     Iノードの保護モード。

 -- データ: stat.ST_INO

     Iノード番号。

 -- データ: stat.ST_DEV

     Iノードが存在するデバイス。

 -- データ: stat.ST_NLINK

     該当する Iノードへのリンク数。

 -- データ: stat.ST_UID

     ファイルの所持者のユーザ ID。

 -- データ: stat.ST_GID

     ファイルの所持者のグループ ID。

 -- データ: stat.ST_SIZE

     通常ファイルではバイトサイズ; いくつかの特殊ファイルでは処理待ちの
     データ量。

 -- データ: stat.ST_ATIME

     最後にアクセスした時刻。

 -- データ: stat.ST_MTIME

     最後に変更された時刻。

 -- データ: stat.ST_CTIME

     オペレーティングシステムから返される"ctime"。あるOS(Unixなど)では最
     後にメタデータが更新された時間となり、別のOS(Windowsなど)では作成時
     間となります(詳細については各プラットフォームのドキュメントを参照し
     てください)。

"ファイルサイズ" の解釈はファイルの型によって異なります。通常のファイル
の場合、サイズはファイルの大きさをバイトで表したものです。ほとんどの
Unix 系 (特に Linux) における FIFO やソケットの場合、"サイズ" は *note
os.stat(): 46d. 、 *note os.fstat(): d59. 、あるいは *note os.lstat():
46e. を呼び出した時点で読み出し待ちであったデータのバイト数になります; こ
の値は時に有用で、特に上記の特殊なファイルを非ブロックモードで開いた後に
ポーリングを行いたいといった場合に便利です。他のキャラクタ型およびブロッ
ク型デバイスにおけるサイズフィールドの意味はさらに異なっていて、背後のシ
ステムコールの実装によります。

以下の変数は、 *note ST_MODE: f86. フィールドで使用されるフラグを定義し
ています。

最初に挙げる、以下のフラグを使うよりは、上記の関数を使うほうがポータブル
です:

 -- データ: stat.S_IFSOCK

     ソケット。

 -- データ: stat.S_IFLNK

     シンボリックリンク。

 -- データ: stat.S_IFREG

     通常のファイル。

 -- データ: stat.S_IFBLK

     ブロックデバイス。

 -- データ: stat.S_IFDIR

     ディレクトリ。

 -- データ: stat.S_IFCHR

     キャラクターデバイス。

 -- データ: stat.S_IFIFO

     FIFO。

 -- データ: stat.S_IFDOOR

     ドア。

     Added in version 3.4.

 -- データ: stat.S_IFPORT

     イベントポート。

     Added in version 3.4.

 -- データ: stat.S_IFWHT

     ホワイトアウト。

     Added in version 3.4.

     注釈: *note S_IFDOOR: f87. 、 *note S_IFPORT: f88. 、または *note
     S_IFWHT: f89. は、プラットフォームがこれらのファイルタイプをサポー
     トしていない場合、0 として定義されます。

以下のフラグは、 *note os.chmod(): 1fc. の 'mode' 引数に使うこともできま
す:

 -- データ: stat.S_ISUID

     UID ビットを設定する。

 -- データ: stat.S_ISGID

     グループIDビットを設定する。このビットには幾つかの特殊ケースがあり
     ます。ディレクトリに対して設定されていた場合、 BSD のセマンティクス
     が利用される事を示しています。すなわち、そこに作成されるファイルは
     、作成したプロセスの有効グループID (effective group ID) ではなくそ
     のディレクトリのグループIDを継承し、そこに作成されるディレクトリに
     も *note S_ISGID: 2752. ビットが設定されます。グループ実行ビット
     (*note S_IXGRP: 2753.) が設定されていないファイルに対してこのビット
     が設定されていた場合、強制ファイル/レコードロックを意味します
     (*note S_ENFMT: 2754. も参照してください)。

 -- データ: stat.S_ISVTX

     スティッキービット。このビットがディレクトリに対して設定されている
     とき、そのディレクトリ内のファイルは、そのファイルのオーナー、ある
     いはそのディレクトリのオーナーか特権プロセスのみが、リネームや削除
     をすることが出来ることを意味しています。

 -- データ: stat.S_IRWXU

     ファイルオーナーの権限に対するマスク。

 -- データ: stat.S_IRUSR

     オーナーがリード権限を持っている。

 -- データ: stat.S_IWUSR

     オーナーがライト権限を持っている。

 -- データ: stat.S_IXUSR

     オーナーが実行権限を持っている。

 -- データ: stat.S_IRWXG

     グループの権限に対するマスク。

 -- データ: stat.S_IRGRP

     グループがリード権限を持っている。

 -- データ: stat.S_IWGRP

     グループがライト権限を持っている。

 -- データ: stat.S_IXGRP

     グループが実行権限を持っている。

 -- データ: stat.S_IRWXO

     その他 (グループ外) の権限に対するマスク。

 -- データ: stat.S_IROTH

     その他はリード権限を持っている。

 -- データ: stat.S_IWOTH

     その他はライト権限を持っている。

 -- データ: stat.S_IXOTH

     その他は実行権限を持っている。

 -- データ: stat.S_ENFMT

     System V ファイルロック強制。このフラグは *note S_ISGID: 2752. と共
     有されています。グループ実行ビット (*note S_IXGRP: 2753.) が設定さ
     れていないファイルでは、ファイル/レコードのロックが強制されます。

 -- データ: stat.S_IREAD

     *note S_IRUSR: 2757. の、 Unix V7 のシノニム。

 -- データ: stat.S_IWRITE

     *note S_IWUSR: 2758. の、 Unix V7 のシノニム。

 -- データ: stat.S_IEXEC

     *note S_IXUSR: 2759. の、 Unix V7 のシノニム。

以下のフラグを *note os.chflags(): 10be. の 'flags' 引数として利用できま
す:

 -- データ: stat.UF_SETTABLE

     All user settable flags.

     Added in version 3.13.

 -- データ: stat.UF_NODUMP

     ファイルをダンプしない。

 -- データ: stat.UF_IMMUTABLE

     ファイルは変更されない。

 -- データ: stat.UF_APPEND

     ファイルは追記しかされない。

 -- データ: stat.UF_OPAQUE

     ユニオンファイルシステムのスタックを通したとき、このディレクトリは
     不透明です。

 -- データ: stat.UF_NOUNLINK

     ファイルはリネームや削除されない。

 -- データ: stat.UF_COMPRESSED

     ファイルは圧縮して保存される (macOS 10.6+)。

 -- データ: stat.UF_TRACKED

     Used for handling document IDs (macOS)

     Added in version 3.13.

 -- データ: stat.UF_DATAVAULT

     The file needs an entitlement for reading or writing (macOS 10.13+)

     Added in version 3.13.

 -- データ: stat.UF_HIDDEN

     ファイルは GUI で表示されるべきでない (macOS 10.5+)。

 -- データ: stat.SF_SETTABLE

     All super-user changeable flags

     Added in version 3.13.

 -- データ: stat.SF_SUPPORTED

     All super-user supported flags

     *note Availability: 1cbe.: macOS

     Added in version 3.13.

 -- データ: stat.SF_SYNTHETIC

     All super-user read-only synthetic flags

     *note Availability: 1cbe.: macOS

     Added in version 3.13.

 -- データ: stat.SF_ARCHIVED

     ファイルはアーカイブされているかもしれません。

 -- データ: stat.SF_IMMUTABLE

     ファイルは変更されない。

 -- データ: stat.SF_APPEND

     ファイルは追記しかされない。

 -- データ: stat.SF_RESTRICTED

     The file needs an entitlement to write to (macOS 10.13+)

     Added in version 3.13.

 -- データ: stat.SF_NOUNLINK

     ファイルはリネームや削除されない。

 -- データ: stat.SF_SNAPSHOT

     このファイルはスナップショットファイルです。

 -- データ: stat.SF_FIRMLINK

     The file is a firmlink (macOS 10.15+)

     Added in version 3.13.

 -- データ: stat.SF_DATALESS

     The file is a dataless object (macOS 10.15+)

     Added in version 3.13.

詳しい情報は *BSD か macOS システムの man page ‘chflags(2)(2)’ を参照し
てください。

Windows では、*note os.stat(): 46d. が返す ‘st_file_attributes’ メンバー
内のビットを検証する際に、以下のファイル属性定数を使用できます。これらの
定数の意味について詳しくは、Windows API documentation(3) を参照してくだ
さい。

 -- データ: stat.FILE_ATTRIBUTE_ARCHIVE
 -- データ: stat.FILE_ATTRIBUTE_COMPRESSED
 -- データ: stat.FILE_ATTRIBUTE_DEVICE
 -- データ: stat.FILE_ATTRIBUTE_DIRECTORY
 -- データ: stat.FILE_ATTRIBUTE_ENCRYPTED
 -- データ: stat.FILE_ATTRIBUTE_HIDDEN
 -- データ: stat.FILE_ATTRIBUTE_INTEGRITY_STREAM
 -- データ: stat.FILE_ATTRIBUTE_NORMAL
 -- データ: stat.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
 -- データ: stat.FILE_ATTRIBUTE_NO_SCRUB_DATA
 -- データ: stat.FILE_ATTRIBUTE_OFFLINE
 -- データ: stat.FILE_ATTRIBUTE_READONLY
 -- データ: stat.FILE_ATTRIBUTE_REPARSE_POINT
 -- データ: stat.FILE_ATTRIBUTE_SPARSE_FILE
 -- データ: stat.FILE_ATTRIBUTE_SYSTEM
 -- データ: stat.FILE_ATTRIBUTE_TEMPORARY
 -- データ: stat.FILE_ATTRIBUTE_VIRTUAL

     Added in version 3.5.

Windows では、*note os.lstat(): 46e. が返す ‘st_reparse_tag’ メンバーと
の比較に次の定数が 使えます。 これらはよく知られている定数ですが、全てを
網羅したリストではありません。

 -- データ: stat.IO_REPARSE_TAG_SYMLINK
 -- データ: stat.IO_REPARSE_TAG_MOUNT_POINT
 -- データ: stat.IO_REPARSE_TAG_APPEXECLINK

     Added in version 3.8.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/stat.py

   (2) https://manpages.debian.org/chflags(2)

   (3) 
https://msdn.microsoft.com/en-us/library/windows/desktop/gg258117.aspx


File: python.info,  Node: filecmp --- ファイルとディレクトリの比較,  Next: tempfile --- 一時ファイルやディレクトリの作成,  Prev: stat --- stat の結果を解釈する,  Up: ファイルとディレクトリへのアクセス

5.11.5 ‘filecmp’ -- ファイルとディレクトリの比較
------------------------------------------------

'ソースコード:' Lib/filecmp.py(1)

__________________________________________________________________

*note filecmp: 50. モジュールでは、ファイルおよびディレクトリを比較する
ため、様々な時間／正確性のトレードオフに関するオプションを備えた関数を定
義しています。ファイルの比較については、 *note difflib: 2f. モジュールも
参照してください。

*note filecmp: 50. モジュールでは以下の関数を定義しています:

 -- の関数: filecmp.cmp (f1, f2, shallow=True)

     名前が 'f1' および 'f2' のファイルを比較し、二つのファイルが同じら
     しければ ‘True’ を返し、そうでなければ ‘False’ を返します。

     If 'shallow' is true and the *note os.stat(): 46d. signatures (file
     type, size, and modification time) of both files are identical, the
     files are taken to be equal.

     Otherwise, the files are treated as different if their sizes or
     contents differ.

     可搬性と効率のために、この関数は外部プログラムを一切呼び出さないの
     で注意してください。

     この関数は過去の比較と結果のキャッシュを使用します。ファイルの
     *note os.stat(): 46d. 情報が変更された場合、キャッシュの項目は無効
     化されます。*note clear_cache(): f0b. を使用して全キャッシュを削除
     することが出来ます。

 -- の関数: filecmp.cmpfiles (dir1, dir2, common, shallow=True)

     'dir1' と 'dir2' ディレクトリの中の、'common' で指定されたファイル
     を比較します。

     ファイル名からなる3つのリスト: 'match', 'mismatch', 'errors' を返し
     ます。'match' には双方のディレクトリで一致したファイルのリストが含
     まれ、'mismatch' にはそうでないファイル名のリストが入ります。そして
     'errors' は比較されなかったファイルが列挙されます。'errors' になる
     のは、片方あるいは両方のディレクトリに存在しなかった、ユーザーにそ
     のファイルを読む権限がなかった、その他何らかの理由で比較を完了する
     ことができなかった場合です。

     引数 'shallow' はその意味も標準の設定も *note filecmp.cmp(): 15c2.
     と同じです。

     例えば、‘cmpfiles('a', 'b', ['c', 'd/e'])’ は ‘a/c’ を ‘b/c’ と、
     ‘a/d/e’ を ‘b/d/e’ と、それぞれ比較します。‘'c'’ と ‘'d/e'’ はそれ
     ぞれ、返される3つのリストのいずれかに登録されます。

 -- の関数: filecmp.clear_cache ()

     filecmp のキャッシュをクリアします。背後のファイルシステムの mtime
     分解能未満でのファイル変更後にすぐに比較するような場合に有用です。

     Added in version 3.4.

* Menu:

* dircmp クラス::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/filecmp.py


File: python.info,  Node: dircmp クラス,  Up: filecmp --- ファイルとディレクトリの比較

5.11.5.1 ‘dircmp’ クラス
........................

 -- クラス: filecmp.dircmp (a, b, ignore=None, hide=None, *,
          shallow=True)

     Construct a new directory comparison object, to compare the
     directories 'a' and 'b'.  'ignore' is a list of names to ignore,
     and defaults to *note filecmp.DEFAULT_IGNORES: f0c.  'hide' is a
     list of names to hide, and defaults to ‘[os.curdir, os.pardir]’.

     The *note dircmp: f0d. class compares files by doing 'shallow'
     comparisons as described for *note filecmp.cmp(): 15c2. by default
     using the 'shallow' parameter.

     バージョン 3.13 で変更: Added the 'shallow' parameter.

     *note dircmp: f0d. クラスは以下のメソッドを提供しています:

      -- メソッド: report ()

          'a' と 'b' の比較を (*note sys.stdout: aa4. に) 表示します。

      -- メソッド: report_partial_closure ()

          'a' および 'b' およびそれらの直下にある共通のサブディレクトリ
          間での比較結果を出力します。

      -- メソッド: report_full_closure ()

          'a' および 'b' およびそれらの共通のサブディレクトリ間での比較
          結果を (再帰的に比較して) 出力します。

     *note dircmp: f0d. クラスは、比較されているディレクトリ階層に関する
     様々な情報のビットを得るために使用することのできる、興味深い属性を
     数多く提供しています。

     Note that via *note __getattr__(): 49f. hooks, all attributes are
     computed lazily, so there is no speed penalty if only those
     attributes which are lightweight to compute are used.

      -- の属性: left

          ディレクトリ 'a' です。

      -- の属性: right

          ディレクトリ 'b' です。

      -- の属性: left_list

          'a' にあるファイルおよびサブディレクトリです。'hide' および
          'ignore' でフィルタされています。

      -- の属性: right_list

          'b' にあるファイルおよびサブディレクトリです。'hide' および
          'ignore' でフィルタされています。

      -- の属性: common

          'a' および 'b' の両方にあるファイルおよびサブディレクトリです
          。

      -- の属性: left_only

          'a' だけにあるファイルおよびサブディレクトリです。

      -- の属性: right_only

          'b' だけにあるファイルおよびサブディレクトリです。

      -- の属性: common_dirs

          'a' および 'b' の両方にあるサブディレクトリです。

      -- の属性: common_files

          'a' および 'b' の両方にあるファイルです。

      -- の属性: common_funny

          'a' および 'b' の両方にあり、ディレクトリ間でタイプが異なるか
          、 *note os.stat(): 46d. がエラーを報告するような名前です。

      -- の属性: same_files

          クラスのファイル比較オペレータを用いて 'a' と 'b' の両方におい
          て同一のファイルです。

      -- の属性: diff_files

          'a' と 'b' の両方に存在し、クラスのファイル比較オペレータに基
          づいて内容が異なるファイルです。

      -- の属性: funny_files

          'a' および 'b' 両方にあるが、比較されなかったファイルです。

      -- の属性: subdirs

          A dictionary mapping names in *note common_dirs: 279b. to
          *note dircmp: f0d. instances (or MyDirCmp instances if this
          instance is of type MyDirCmp, a subclass of *note dircmp:
          f0d.).

          バージョン 3.10 で変更: Previously entries were always *note
          dircmp: f0d. instances.  Now entries are the same type as
          'self', if 'self' is a subclass of *note dircmp: f0d.

 -- の属性: filecmp.DEFAULT_IGNORES

     Added in version 3.4.

     デフォルトで *note dircmp: f0d. に無視されるディレクトリのリストで
     す。

これは ‘subdirs’ 属性を使用して 2 つのディレクトリを再帰的に探索して、共
通の異なるファイルを示すための単純化された例です:

     >>> from filecmp import dircmp
     >>> def print_diff_files(dcmp):
     ...     for name in dcmp.diff_files:
     ...         print("diff_file %s found in %s and %s" % (name, dcmp.left,
     ...               dcmp.right))
     ...     for sub_dcmp in dcmp.subdirs.values():
     ...         print_diff_files(sub_dcmp)
     ...
     >>> dcmp = dircmp('dir1', 'dir2')
     >>> print_diff_files(dcmp)


File: python.info,  Node: tempfile --- 一時ファイルやディレクトリの作成,  Next: glob --- Unix 形式のパス名のパターン展開,  Prev: filecmp --- ファイルとディレクトリの比較,  Up: ファイルとディレクトリへのアクセス

5.11.6 ‘tempfile’ -- 一時ファイルやディレクトリの作成
-----------------------------------------------------

'ソースコード:' Lib/tempfile.py(1)

__________________________________________________________________

This module creates temporary files and directories.  It works on all
supported platforms.  *note TemporaryFile: 27a3, *note
NamedTemporaryFile: 492, *note TemporaryDirectory: 1205, and *note
SpooledTemporaryFile: 65f. are high-level interfaces which provide
automatic cleanup and can be used as *note context managers: 59e.  *note
mkstemp(): 27a4. and *note mkdtemp(): 200. are lower-level functions
which require manual cleanup.

ユーザが呼び出し可能な全ての関数とコンストラクタは追加の引数を受け取りま
す。 その引数によって一時ファイルやディレクトリの場所と名前を直接操作す
ることが出来ます。 このモジュールに使用されるファイル名はランダムな文字
を含みます。そのためファイルは共有された一時ディレクトリに安全に作成され
ます。 後方互換性を保つために引数の順序は若干奇妙です。 分かりやすさのた
めにキーワード引数を使用してください。

このモジュールではユーザが呼び出し可能な以下の項目を定義しています:

 -- の関数: tempfile.TemporaryFile (mode='w+b', buffering=-1,
          encoding=None, newline=None, suffix=None, prefix=None,
          dir=None, *, errors=None)

     一時的な記憶領域として使うことの出来る *note file-like object:
     24e0. を返します。 ファイルは *note mkstemp(): 27a4. と同じルールに
     より安全に作成されます。 オブジェクトは閉じられる (オブジェクトのガ
     ベージコレクションによる暗黙的なものも含みます) とすぐに破壊されま
     す。 Unix では、そのファイルのディレクトリエントリは全く作成されな
     いか、ファイル作成後すぐに削除されます。 これは他のプラットフォーム
     ではサポートされません。 よって、この関数で作成された一時ファイルが
     ファイルシステムで可視な名前を持つかどうかをコードで当てにすべきで
     はありません。

     The resulting object can be used as a *note context manager: 59e.
     (see *note 使用例: 27a5.).  On completion of the context or
     destruction of the file object the temporary file will be removed
     from the filesystem.

     作成されたファイルを閉じることなく読み書きできるように、 'mode' 引
     数のデフォルトは ‘'w+b'’ です。 保存されるデータに関わらず全てのプ
     ラットフォーム上で一貫して動作するようにバイナリモードが使用されま
     す。 'buffering'、'encoding'、'errors'、'newline' は、 *note
     open(): 4e5. に対する引数として解釈されます。

     'dir'、'prefix'、'suffix' 引数の意味とデフォルトは *note mkstemp():
     27a4. のものと同じです。

     返されたオブジェクトは、POSIXプラットフォームでは本物のファイルオブ
     ジェクトです。 それ以外のプラットフォームでは、‘file’ 属性が下層の
     本物のファイルであるファイル様オブジェクトです。

     The *note os.O_TMPFILE: f40. flag is used if it is available and
     works (Linux-specific, requires Linux kernel 3.11 or later).

     On platforms that are neither Posix nor Cygwin, TemporaryFile is an
     alias for NamedTemporaryFile.

     引数 ‘fullpath’ を指定して *note 監査イベント: 1825.
     ‘tempfile.mkstemp’ を送出します。

     バージョン 3.5 で変更: The *note os.O_TMPFILE: f40. flag is now
     used if available.

     バージョン 3.8 で変更: 'errors' 引数が追加されました。

 -- の関数: tempfile.NamedTemporaryFile (mode='w+b', buffering=-1,
          encoding=None, newline=None, suffix=None, prefix=None,
          dir=None, delete=True, *, errors=None, delete_on_close=True)

     This function operates exactly as *note TemporaryFile(): 27a3.
     does, except the following differences:

        * This function returns a file that is guaranteed to have a
          visible name in the file system.

        * To manage the named file, it extends the parameters of *note
          TemporaryFile(): 27a3. with 'delete' and 'delete_on_close'
          parameters that determine whether and how the named file
          should be automatically deleted.

     The returned object is always a *note file-like object: 24e0. whose
     ‘file’ attribute is the underlying true file object.  This
     file-like object can be used in a *note with: 59c. statement, just
     like a normal file.  The name of the temporary file can be
     retrieved from the ‘name’ attribute of the returned file-like
     object.  On Unix, unlike with the *note TemporaryFile(): 27a3, the
     directory entry does not get unlinked immediately after the file
     creation.

     If 'delete' is true (the default) and 'delete_on_close' is true
     (the default), the file is deleted as soon as it is closed.  If
     'delete' is true and 'delete_on_close' is false, the file is
     deleted on context manager exit only, or else when the *note
     file-like object: 24e0. is finalized.  Deletion is not always
     guaranteed in this case (see *note object.__del__(): 1ec1.).  If
     'delete' is false, the value of 'delete_on_close' is ignored.

     Therefore to use the name of the temporary file to reopen the file
     after closing it, either make sure not to delete the file upon
     closure (set the 'delete' parameter to be false) or, in case the
     temporary file is created in a *note with: 59c. statement, set the
     'delete_on_close' parameter to be false.  The latter approach is
     recommended as it provides assistance in automatic cleaning of the
     temporary file upon the context manager exit.

     Opening the temporary file again by its name while it is still open
     works as follows:

        * On POSIX the file can always be opened again.

        * On Windows, make sure that at least one of the following
          conditions are fulfilled:

             * 'delete' is false

             * additional open shares delete access (e.g.  by calling
               *note os.open(): d5f. with the flag ‘O_TEMPORARY’)

             * 'delete' is true but 'delete_on_close' is false.  Note,
               that in this case the additional opens that do not share
               delete access (e.g.  created via builtin *note open():
               4e5.) must be closed before exiting the context manager,
               else the *note os.unlink(): 10c6. call on context manager
               exit will fail with a *note PermissionError: d10.

     On Windows, if 'delete_on_close' is false, and the file is created
     in a directory for which the user lacks delete access, then the
     *note os.unlink(): 10c6. call on exit of the context manager will
     fail with a *note PermissionError: d10.  This cannot happen when
     'delete_on_close' is true because delete access is requested by the
     open, which fails immediately if the requested access is not
     granted.

     On POSIX (only), a process that is terminated abruptly with SIGKILL
     cannot automatically delete any NamedTemporaryFiles it created.

     引数 ‘fullpath’ を指定して *note 監査イベント: 1825.
     ‘tempfile.mkstemp’ を送出します。

     バージョン 3.8 で変更: 'errors' 引数が追加されました。

     バージョン 3.12 で変更: Added 'delete_on_close' parameter.

 -- クラス: tempfile.SpooledTemporaryFile (max_size=0, mode='w+b',
          buffering=-1, encoding=None, newline=None, suffix=None,
          prefix=None, dir=None, *, errors=None)

     This class operates exactly as *note TemporaryFile(): 27a3. does,
     except that data is spooled in memory until the file size exceeds
     'max_size', or until the file's *note fileno(): 27a6. method is
     called, at which point the contents are written to disk and
     operation proceeds as with *note TemporaryFile(): 27a3.

      -- メソッド: rollover ()

          The resulting file has one additional method, ‘rollover()’,
          which causes the file to roll over to an on-disk file
          regardless of its size.

     The returned object is a file-like object whose ‘_file’ attribute
     is either an *note io.BytesIO: e6d. or *note io.TextIOWrapper: 786.
     object (depending on whether binary or text 'mode' was specified)
     or a true file object, depending on whether *note rollover(): 27a7.
     has been called.  This file-like object can be used in a *note
     with: 59c. statement, just like a normal file.

     バージョン 3.3 で変更: the truncate method now accepts a 'size'
     argument.

     バージョン 3.8 で変更: 'errors' 引数が追加されました。

     バージョン 3.11 で変更: Fully implements the *note
     io.BufferedIOBase: 660. and *note io.TextIOBase: 661. abstract base
     classes (depending on whether binary or text 'mode' was specified).

 -- クラス: tempfile.TemporaryDirectory (suffix=None, prefix=None,
          dir=None, ignore_cleanup_errors=False, *, delete=True)

     This class securely creates a temporary directory using the same
     rules as *note mkdtemp(): 200.  The resulting object can be used as
     a *note context manager: 59e. (see *note 使用例: 27a5.).  On
     completion of the context or destruction of the temporary directory
     object, the newly created temporary directory and all its contents
     are removed from the filesystem.

      -- の属性: name

          The directory name can be retrieved from the ‘name’ attribute
          of the returned object.  When the returned object is used as a
          *note context manager: 59e, the ‘name’ will be assigned to the
          target of the ‘as’ clause in the *note with: 59c. statement,
          if there is one.

      -- メソッド: cleanup ()

          The directory can be explicitly cleaned up by calling the
          ‘cleanup()’ method.  If 'ignore_cleanup_errors' is true, any
          unhandled exceptions during explicit or implicit cleanup (such
          as a *note PermissionError: d10. removing open files on
          Windows) will be ignored, and the remaining removable items
          deleted on a "best-effort" basis.  Otherwise, errors will be
          raised in whatever context cleanup occurs (the ‘cleanup()’
          call, exiting the context manager, when the object is
          garbage-collected or during interpreter shutdown).

     The 'delete' parameter can be used to disable cleanup of the
     directory tree upon exiting the context.  While it may seem unusual
     for a context manager to disable the action taken when exiting the
     context, it can be useful during debugging or when you need your
     cleanup behavior to be conditional based on other logic.

     引数 ‘fullpath’ を指定して *note 監査イベント: 1825.
     ‘tempfile.mkdtemp’ を送出します。

     Added in version 3.2.

     バージョン 3.10 で変更: 'ignore_cleanup_errors' 引数が追加されまし
     た。

     バージョン 3.12 で変更: Added the 'delete' parameter.

 -- の関数: tempfile.mkstemp (suffix=None, prefix=None, dir=None,
          text=False)

     可能な限り最も安全な手段で一時ファイルを生成します。 プラットフォー
     ムが *note os.open(): d5f. の *note os.O_EXCL: 27aa. フラグを正しく
     実装している限り、ファイルの作成で競合が起こることはありません。 作
     成したユーザのユーザ ID からのみファイルを読み書き出来ます。 プラッ
     トフォームがファイルが実行可能かどうかを示す許可ビットを使用してい
     る場合、ファイルは誰からも実行不可です。 このファイルのファイル記述
     子は子プロセスに継承されません。

     *note TemporaryFile(): 27a3. と違って、 *note mkstemp(): 27a4. のユ
     ーザは用済みになった時に一時ファイルを削除しなければなりません。

     'suffix' が ‘None’ でない場合、ファイル名はその接尾辞で終わります。
     そうでない場合、接尾辞はありません。 *note mkstemp(): 27a4. はファ
     イル名と接尾辞の間にドットを追加しません。 必要であれば 'suffix' の
     先頭につけてください。

     'prefix' が ‘None’ でない場合、ファイル名はその接頭辞で始まります。
     そうでない場合、デフォルトの接頭辞が使われます。 必要に応じ、デフォ
     ルトは *note gettempprefix(): 27ab. または *note gettempprefixb():
     27ac. の返り値です。

     'dir' が ‘None’ でない場合、ファイルはそのディレクトリ下に作成され
     ます。 ‘None’ の場合、デフォルトのディレクトリが使われます。デフォ
     ルトのディレクトリはプラットフォームに依存するリストから選ばれます
     が、アプリケーションのユーザは 'TMPDIR'、'TEMP'、または 'TMP' 環境
     変数を設定することでディレクトリの場所を管理することができます。そ
     のため、生成されるファイル名が、‘os.popen()’ で外部コマンドにクォー
     ティング無しで渡すことができるなどといった、扱いやすい性質を持つ保
     証はありません。

     'suffix'、'prefix'、'dir' のいずれかが ‘None’ でない場合、それらは
     同じ型でなければなりません。 bytes の場合、返された名前は str でな
     はく bytes です。 他の挙動はデフォルトで返り値を bytes に強制的にし
     たい場合は ‘suffix=b''’ を渡してください。

     'text' に真を指定した場合は、ファイルはテキストモードで開かれます。
     そうでない場合(デフォルト)は、ファイルはバイナリモードで開かれます
     。

     *note mkstemp(): 27a4. は開かれたファイルを扱うための OS レベルのハ
     ンドル (*note os.open(): d5f. が返すものと同じ) とファイルの絶対パ
     ス名が順番に並んだタプルを返します。

     引数 ‘fullpath’ を指定して *note 監査イベント: 1825.
     ‘tempfile.mkstemp’ を送出します。

     バージョン 3.5 で変更: 'suffix'、'prefix'、'dir' は bytes の返り値
     を得るために bytes で渡すことが出来ます。 それ以前は str のみ許され
     ていました。 適切なデフォルト値を使用するよう、'suffix' と 'prefix'
     は ‘None’ を受け入れ、デフォルトにするようになりました。

     バージョン 3.6 で変更: 'dir' パラメタが *note path-like object:
     280. を受け付けるようになりました。

 -- の関数: tempfile.mkdtemp (suffix=None, prefix=None, dir=None)

     可能な限り安全な方法で一時ディレクトリを作成します。 ディレクトリの
     生成で競合は発生しません。 ディレクトリを作成したユーザ ID だけが、
     このディレクトリに対して内容を読み出したり、書き込んだり、検索した
     りすることができます。

     *note mkdtemp(): 200. のユーザは用済みになった時に一時ディレクトリ
     とその中身を削除しなければなりません。

     'prefix', 'suffix', 'dir' 引数は *note mkstemp(): 27a4. 関数のもの
     と同じです。

     *note mkdtemp(): 200. は新たに生成されたディレクトリの絶対パス名を
     返します。

     引数 ‘fullpath’ を指定して *note 監査イベント: 1825.
     ‘tempfile.mkdtemp’ を送出します。

     バージョン 3.5 で変更: 'suffix'、'prefix'、'dir' は bytes の返り値
     を得るために bytes で渡すことが出来ます。 それ以前は str のみ許され
     ていました。 適切なデフォルト値を使用するよう、'suffix' と 'prefix'
     は ‘None’ を受け入れ、デフォルトにするようになりました。

     バージョン 3.6 で変更: 'dir' パラメタが *note path-like object:
     280. を受け付けるようになりました。

     バージョン 3.12 で変更: *note mkdtemp(): 200. now always returns an
     absolute path, even if 'dir' is relative.

 -- の関数: tempfile.gettempdir ()

     一時ファイルに用いられるディレクトリの名前を返します。 これはモジュ
     ール内の全ての関数の 'dir' 引数のデフォルト値を定義します。

     Python は呼び出したユーザがファイルを作ることの出来るディレクトリを
     検索するのに標準的なリストを使用します。 そのリストは:

       1. 環境変数 ‘TMPDIR’ で与えられているディレクトリ名。

       2. 環境変数 ‘TEMP’ で与えられているディレクトリ名。

       3. 環境変数 ‘TMP’ で与えられているディレクトリ名。

       4. プラットフォーム依存の場所:

             * Windows ではディレクトリ ‘C:\TEMP’ 、 ‘C:\TMP’ 、 ‘\TEMP’
               、および ‘\TMP’ の順。

             * その他の全てのプラットフォームでは、 ‘/tmp’ 、 ‘/var/tmp’
               、および ‘/usr/tmp’ の順。

       5. 最後の手段として、現在の作業ディレクトリ。

     この検索の結果はキャッシュされます。以下の *note tempdir: 1843. の
     記述を参照してください。

     バージョン 3.10 で変更: Always returns a str.  Previously it would
     return any *note tempdir: 1843. value regardless of type so long as
     it was not ‘None’.

 -- の関数: tempfile.gettempdirb ()

     *note gettempdir(): 1844. と同じですが返り値は bytesです。

     Added in version 3.5.

 -- の関数: tempfile.gettempprefix ()

     一時ファイルを生成する際に使われるファイル名の接頭辞を返します。 こ
     れにはディレクトリ部は含まれません。

 -- の関数: tempfile.gettempprefixb ()

     *note gettempprefix(): 27ab. と同じですが返り値は bytes です。

     Added in version 3.5.

The module uses a global variable to store the name of the directory
used for temporary files returned by *note gettempdir(): 1844.  It can
be set directly to override the selection process, but this is
discouraged.  All functions in this module take a 'dir' argument which
can be used to specify the directory.  This is the recommended approach
that does not surprise other unsuspecting code by changing global API
behavior.

 -- データ: tempfile.tempdir

     When set to a value other than ‘None’, this variable defines the
     default value for the 'dir' argument to the functions defined in
     this module, including its type, bytes or str.  It cannot be a
     *note path-like object: 280.

     ‘tempdir’ が (デフォルトの) ‘None’ の場合、 *note gettempprefix():
     27ab. を除く上記のいずれかの関数を呼び出す際は常に *note
     gettempdir(): 1844. で述べられているアルゴリズムによって初期化され
     ます。

          注釈: Beware that if you set ‘tempdir’ to a bytes value, there
          is a nasty side effect: The global default return type of
          *note mkstemp(): 27a4. and *note mkdtemp(): 200. changes to
          bytes when no explicit ‘prefix’, ‘suffix’, or ‘dir’ arguments
          of type str are supplied.  Please do not write code expecting
          or depending on this.  This awkward behavior is maintained for
          compatibility with the historical implementation.

* Menu:

* 使用例: 使用例<8>.
* 非推奨の関数と変数::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tempfile.py


File: python.info,  Node: 使用例<8>,  Next: 非推奨の関数と変数,  Up: tempfile --- 一時ファイルやディレクトリの作成

5.11.6.1 使用例
...............

*note tempfile: c9. モジュールの典型的な使用法のいくつかの例を挙げます:

     >>> import tempfile

     # create a temporary file and write some data to it
     >>> fp = tempfile.TemporaryFile()
     >>> fp.write(b'Hello world!')
     # read data from file
     >>> fp.seek(0)
     >>> fp.read()
     b'Hello world!'
     # close the file, it will be removed
     >>> fp.close()

     # create a temporary file using a context manager
     >>> with tempfile.TemporaryFile() as fp:
     ...     fp.write(b'Hello world!')
     ...     fp.seek(0)
     ...     fp.read()
     b'Hello world!'
     >>>
     # file is now closed and removed

     # create a temporary file using a context manager
     # close the file, use the name to open the file again
     >>> with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:
     ...     fp.write(b'Hello world!')
     ...     fp.close()
     ... # the file is closed, but not removed
     ... # open the file again by using its name
     ...     with open(fp.name, mode='rb') as f:
     ...         f.read()
     b'Hello world!'
     >>>
     # file is now removed

     # create a temporary directory using the context manager
     >>> with tempfile.TemporaryDirectory() as tmpdirname:
     ...     print('created temporary directory', tmpdirname)
     >>>
     # directory and contents have been removed


File: python.info,  Node: 非推奨の関数と変数,  Prev: 使用例<8>,  Up: tempfile --- 一時ファイルやディレクトリの作成

5.11.6.2 非推奨の関数と変数
...........................

一時ファイルを作成する歴史的な手法は、まず *note mktemp(): 17f8. 関数で
ファイル名を作り、その名前を使ってファイルを作成するというものでした。 残
念ながらこの方法は安全ではありません。 なぜなら、*note mktemp(): 17f8. の
呼び出しと最初のプロセスが続いてファイル作成を試みる間に、異なるプロセス
がその名前でファイルを同時に作成するかもしれないからです。 解決策は二つ
のステップを同時に行い、ファイルをすぐに作成するというものです。 この方
法は *note mkstemp(): 27a4. や上述している他の関数で使用されています。

 -- の関数: tempfile.mktemp (suffix='', prefix='tmp', dir=None)

     バージョン 2.3 で非推奨: 代わりに *note mkstemp(): 27a4. を使って下
     さい。

     呼び出し時には存在しなかった、ファイルの絶対パス名を返します。
     'prefix'、'suffix'、'dir' 引数は *note mkstemp(): 27a4. のものと似
     ていますが、bytes のファイル名、‘suffix=None’、そして ‘prefix=None’
     がサポートされていない点で異なります。

          警告: この関数を使うとプログラムのセキュリティホールになる可能
          性があります。この関数がファイル名を返した後、あなたがそのファ
          イル名を使って次に何かをしようとする段階に至る前に、誰か他の人
          間があなたを出し抜くことができてしまいます。 *note mktemp():
          17f8. の利用は、 *note NamedTemporaryFile(): 492. に
          ‘delete=False’ 引数を渡すことで、簡単に置き換えることができま
          す:

               >>> f = NamedTemporaryFile(delete=False)
               >>> f.name
               '/tmp/tmptjujjt'
               >>> f.write(b"Hello World!\n")
               13
               >>> f.close()
               >>> os.unlink(f.name)
               >>> os.path.exists(f.name)
               False


File: python.info,  Node: glob --- Unix 形式のパス名のパターン展開,  Next: fnmatch --- Unix のファイル名パターンマッチ,  Prev: tempfile --- 一時ファイルやディレクトリの作成,  Up: ファイルとディレクトリへのアクセス

5.11.7 ‘glob’ -- Unix 形式のパス名のパターン展開
------------------------------------------------

'ソースコード:' Lib/glob.py(1)

__________________________________________________________________

*note glob: 5a. モジュールは Unix シェルで使われているルールに従い指定さ
れたパターンに一致するすべてのパス名を見つけ出します。返される結果の順序
は不定です。チルダ展開は行われませんが、‘*’, ‘?’, および ‘[]’ で表現され
る文字範囲については正しくマッチされます。これは、関数 *note
os.scandir(): a2d. および *note fnmatch.fnmatch(): 180a. を使用して行わ
れており、実際にサブシェルを呼び出しているわけではありません。

ドット (‘.’) で始まるファイルは、同じくドットで始まるパターンにのみマッ
チします。この動作は *note fnmatch.fnmatch(): 180a. や *note
pathlib.Path.glob(): 20e. とは異なります。 (チルダやシェル変数の展開には
、 *note os.path.expanduser(): 9e2. と *note os.path.expandvars(): 1381.
を使ってください。)

リテラルにマッチさせるには、メタ文字を括弧に入れてください。例えば、
‘'[?]'’ は文字 ‘'?'’ にマッチします。

*note glob: 5a. モジュールは以下の関数を定義しています:

 -- の関数: glob.glob (pathname, *, root_dir=None, dir_fd=None,
          recursive=False, include_hidden=False)

     パスの仕様を含む文字列 'pathname' にマッチするパス名のリストを返し
     ます。戻り値のリストは空になる可能性があります。 'pathname' は
     (‘/usr/src/Python-1.5/Makefile’ のような) 絶対パスも、
     (‘../../Tools/*/*.gif’ のような) 相対パスもどちらも指定可能で、シェ
     ル形式のワイルドカードを含めることもできます。参照先が存在しない、
     壊れたシンボリックリンクも (シェルの場合と同様に) 結果に含まれます
     。結果がソートされているかどうかはファイルシステムによります。条件
     を満たすファイルがこの関数の呼び出し中に追加または削除された場合、
     それらのファイルに対するパス名が結果に含まれるかどうかはの動作は不
     定です。

     'root_dir' が ‘None’ でない場合、その値は検索のルートディレクトリを
     指定する *note path-like オブジェクト: 280. でなければなりません。
     これは *note glob(): 5a. を呼び出す前にカレントディレクトリを変更し
     たのと同じ効果を持ちます。 'pathname' が相対パスの場合、戻り値のリ
     ストは 'root_dir' からの相対パスを含むことになります。

     この関数は 'dir_fd' パラメタで *note
     ディレクトリ記述子への相対パス: 10c8. をサポートしています。

     'recursive' が真の場合、パターン "‘**’" はあらゆるファイルや0個以上
     のディレクトリ、サブディレクトリおよびディレクトリへのシンボリック
     リンクにマッチします。パターンの末尾が *note os.sep: 636. または
     *note os.altsep: 637. の場合、ファイルは一致しません。

     'include_hidden' が真の場合、パターン "‘**’" は隠しディレクトリにマ
     ッチします。

     引数 ‘pathname’, ‘recursive’ を指定して *note 監査イベント: 1825.
     ‘glob.glob’ を送出します。

     引数 ‘pathname’, ‘recursive’, ‘root_dir’, ‘dir_fd’ を指定して *note
     監査イベント: 1825. ‘glob.glob/2’ を送出します。

          注釈: パターン "‘**’" を大きなディレクトリツリーで使用するとと
          てつもなく時間がかかるかもしれません。

          注釈: 'pathname' が複数の "‘**’" パターンを含み、かつ
          'recursive' が真の場合、この関数は同じパスを重複して返す可能性
          があります。

     バージョン 3.5 で変更: "‘**’" を使った再帰的な glob がサポートされ
     ました。

     バージョン 3.10 で変更: 'root_dir' と 'dir_fd' 引数が追加されました
     。

     バージョン 3.11 で変更: 'include_hidden' パラメータが追加されました
     。

 -- の関数: glob.iglob (pathname, *, root_dir=None, dir_fd=None,
          recursive=False, include_hidden=False)

     実際には一度にすべてを格納せずに、*note glob(): 5a. と同じ値を順に
     生成する *note イテレーター: 191. を返します。

     引数 ‘pathname’, ‘recursive’ を指定して *note 監査イベント: 1825.
     ‘glob.glob’ を送出します。

     引数 ‘pathname’, ‘recursive’, ‘root_dir’, ‘dir_fd’ を指定して *note
     監査イベント: 1825. ‘glob.glob/2’ を送出します。

          注釈: 'pathname' が複数の "‘**’" パターンを含み、かつ
          'recursive' が真の場合、この関数は同じパスを重複して返す可能性
          があります。

     バージョン 3.5 で変更: "‘**’" を使った再帰的な glob がサポートされ
     ました。

     バージョン 3.10 で変更: 'root_dir' と 'dir_fd' 引数が追加されました
     。

     バージョン 3.11 で変更: 'include_hidden' パラメータが追加されました
     。

 -- の関数: glob.escape (pathname)

     すべての特殊文字 (‘'?'’ 、 ‘'*'’ 、 ‘'['’) をエスケープします。特殊
     文字を含んでいる可能性のある任意のリテラル文字列をマッチさせたいと
     きに便利です。drive/UNC sharepoints の特殊文字はエスケープされませ
     ん。たとえば Windows では ‘escape('//?/c:/Quo vadis?.txt')’ は
     ‘'//?/c:/Quo vadis[?].txt'’ を返します。

     Added in version 3.4.

 -- の関数: glob.translate (pathname, *, recursive=False,
          include_hidden=False, seps=None)

     与えられたパスの仕様を *note re.match(): 11fe. で利用するための正規
     表現に変換します。シェル形式のワイルドカードを含めることもできます
     。

     例えば:

          >>> import glob, re
          >>>
          >>> regex = glob.translate('**/*.txt', recursive=True, include_hidden=True)
          >>> regex
          '(?s:(?:.+/)?[^/]*\\.txt)\\Z'
          >>> reobj = re.compile(regex)
          >>> reobj.match('foo/bar/baz.txt')
          <re.Match object; span=(0, 15), match='foo/bar/baz.txt'>

     *note fnmatch.translate(): 19b1. と違って、この関数ではパスの要素を
     区切るセパレータとセグメントには意味があります。デフォルトでは、ワ
     イルドカードはパスのセパレータにはマッチしません。また ‘*’ パターン
     のセグメントは厳密に単一のパスのセグメントにマッチします。

     'recursive' が真の場合、パターンセグメント "‘**’" は任意の数のパス
     セグメントにマッチします。

     'include_hidden' が真の場合、ワイルドカードはドット (‘.’) で始まる
     パスセグメントにもマッチします。

     パスの要素を区切るセパレータのシーケンスを 'seps' 引数に渡すことが
     できます。渡さない場合は *note os.sep: 636. と (もしあれば) *note
     altsep: 637. が使われます。

     参考
     ....

     *note pathlib.PurePath.full_match(): 20c. と *note
     pathlib.Path.glob(): 20e. の2つのメソッドは、それぞれパターンマッチ
     と glob 相当の操作を実装するためにこの関数を呼んでいます。

     Added in version 3.13.

* Menu:

* 使用例: 使用例<9>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/glob.py


File: python.info,  Node: 使用例<9>,  Up: glob --- Unix 形式のパス名のパターン展開

5.11.7.1 使用例
...............

次のファイルを含むディレクトリを考えます: ‘1.gif’, ‘2.txt’, ‘card.gif’ お
よび:file:‘3.txt’ だけを含む ‘sub’ サブディレクトリ。このとき、 *note
glob(): 5a. は以下の結果を返します。パスにおける先頭の要素がどのように保
持されるかに注意してください:

     >>> import glob
     >>> glob.glob('./[0-9].*')
     ['./1.gif', './2.txt']
     >>> glob.glob('*.gif')
     ['1.gif', 'card.gif']
     >>> glob.glob('?.gif')
     ['1.gif']
     >>> glob.glob('**/*.txt', recursive=True)
     ['2.txt', 'sub/3.txt']
     >>> glob.glob('./**/', recursive=True)
     ['./', './sub/']

ディレクトリが ‘.’ で始まるファイルを含んでいる場合、デフォルトでそれら
はマッチしません。例えば、 ‘card.gif’ と ‘.card.gif’ を含むディレクトリ
を考えてください:

     >>> import glob
     >>> glob.glob('*.gif')
     ['card.gif']
     >>> glob.glob('.c*')
     ['.card.gif']

参考
....

*note fnmatch: 52. モジュールは、シェル形式の (パスではなく) ファイル名
の展開機能を提供します。

参考
....

*note pathlib: 93. モジュールは高水準のパスオブジェクトを提供します。


File: python.info,  Node: fnmatch --- Unix のファイル名パターンマッチ,  Next: linecache --- テキストラインへのランダムアクセス,  Prev: glob --- Unix 形式のパス名のパターン展開,  Up: ファイルとディレクトリへのアクセス

5.11.8 ‘fnmatch’ -- Unix のファイル名パターンマッチ
---------------------------------------------------

'ソースコード:' Lib/fnmatch.py(1)

__________________________________________________________________

このモジュールは Unix のシェル形式のワイルドカードに対応しています。これ
らは、 (*note re: a7. モジュールでドキュメント化されている) 正規表現とは
'異なります' 。シェル形式のワイルドカードで使われる特殊文字は、次のとお
りです。

Pattern          意味
                 
----------------------------------------------------------
                 
‘*’              すべてにマッチします
                 
                 
‘?’              任意の一文字にマッチします
                 
                 
‘[seq]’          'seq' にある任意の文字にマッチします
                 
                 
‘[!seq]’         'seq' にない任意の文字にマッチします
                 

リテラルにマッチさせるには、メタ文字を括弧に入れてください。例えば、
‘'[?]'’ は文字 ‘'?'’ にマッチします。

ファイル名の区切り文字 (Unixでは ‘'/'’) はこのモジュールに固有なものでは
'ない' ことに注意してください。パス名展開については、 *note glob: 5a. モ
ジュールを参照してください (*note glob: 5a. はパス名の部分にマッチさせる
のに *note filter(): 180c. を使っています)。同様に、ピリオドで始まるファ
イル名はこのモジュールに固有ではなくて、 ‘*’ と ‘?’ のパターンでマッチし
ます。

以下の関数 *note fnmatch(): 52, *note fnmatchcase(): 180b, *note
filter(): 180c. では、 '最大サイズ' 32768の *note functools.lru_cache():
9bd. をコンパイル済みの正規表現パターンのキャッシュに使用していることに
も注意してください。

 -- の関数: fnmatch.fnmatch (name, pat)

     ファイルの文字列 'name' がパターン文字列 'pat' にマッチするかテスト
     して、 ‘True’ または ‘False’ のいずれかを返します。どちらの引数とも
     *note os.path.normcase(): 272a. を使って、大文字、小文字が正規化さ
     れます。オペレーティングシステムが標準でどうなっているかに関係なく
     、大文字、小文字を区別して比較する場合には、 *note fnmatchcase():
     180b. が使用できます。

     次の例では、カレントディレクトリにある、拡張子が ‘.txt’ である全て
     のファイルを表示しています:

          import fnmatch
          import os

          for file in os.listdir('.'):
              if fnmatch.fnmatch(file, '*.txt'):
                  print(file)

 -- の関数: fnmatch.fnmatchcase (name, pat)

     ファイル名の文字列 'name' がパターン文字列 'pat' にマッチするかテス
     トして、 ‘True’ または ‘False’ を返します。比較は大文字、小文字を区
     別し、 *note os.path.normcase(): 272a. は適用しません。

 -- の関数: fnmatch.filter (names, pat)

     パターン 'pat' にマッチする *note iterable: 10ad. の 'names' を要素
     とするリストを構築します。‘[n for n in names if fnmatch(n, pat)]’ と
     同じですが、より効率よく実装されています。

 -- の関数: fnmatch.translate (pat)

     シェルスタイルのパターン 'pat' を、*note re.match(): 11fe. で使用す
     るための正規表現に変換して返します。

     例:

          >>> import fnmatch, re
          >>>
          >>> regex = fnmatch.translate('*.txt')
          >>> regex
          '(?s:.*\\.txt)\\Z'
          >>> reobj = re.compile(regex)
          >>> reobj.match('foobar.txt')
          <re.Match object; span=(0, 10), match='foobar.txt'>

参考
....

*note glob: 5a. モジュール

     Unix シェル形式のパス展開。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/fnmatch.py


File: python.info,  Node: linecache --- テキストラインへのランダムアクセス,  Next: shutil --- 高水準のファイル操作,  Prev: fnmatch --- Unix のファイル名パターンマッチ,  Up: ファイルとディレクトリへのアクセス

5.11.9 ‘linecache’ -- テキストラインへのランダムアクセス
--------------------------------------------------------

'ソースコード:' Lib/linecache.py(1)

__________________________________________________________________

*note linecache: 79. モジュールは、キャッシュ (一つのファイルから何行も
読んでおくのが一般的です) を使って、内部で最適化を図りつつ、Python ソー
スファイルの任意の行を取得するのを可能にします。 *note traceback: e7. モ
ジュールは、整形されたトレースバックにソースコードを含めるためにこのモジ
ュールを利用しています。

*note tokenize.open(): 27b7. 関数は、ファイルを開くために使用されます。
この関数は、 *note tokenize.detect_encoding(): 27b8. を使用してファイル
のエンコーディングを取得します。エンコーディングトークンが存在しない場合
、デフォルトの UTF-8 になります。

*note linecache: 79. モジュールでは次の関数が定義されています:

 -- の関数: linecache.getline (filename, lineno, module_globals=None)

     'filename' という名前のファイルから 'lineno' 行目を取得します。この
     関数は決して例外を発生させません -- エラーの際には ‘''’ を返します
     (行末の改行文字は、見つかった行に含まれます)。

     'filename' という名前のファイルが見付からなかった場合、この関数は最
     初に 'module_globals' にある PEP 302(2) ‘__loader__’ を確認します。
     ローダーが存在していて、 ‘get_source’ メソッドが実装されていた場合
     、ソースコードの行を決定します (‘get_source()’ が ‘None’ を返した場
     合は、 ‘''’ が返ります)。 最後に、 'filename' が相対ファイル名だっ
     た場合、モジュール検索パス ‘sys.path’ のエントリからの相対パスを探
     します。

 -- の関数: linecache.clearcache ()

     キャッシュをクリアします。それまでに *note getline(): df0. を使って
     読み込んだファイルの行が必要でなくなったら、この関数を使ってくださ
     い。

 -- の関数: linecache.checkcache (filename=None)

     キャッシュが有効かどうかを確認します。キャッシュしたファイルがディ
     スク上で変更された可能性があり、更新後のバージョンが必要な場合にこ
     の関数を使用します。 'filename' が与えられない場合、全てのキャッシ
     ュエントリを確認します。

 -- の関数: linecache.lazycache (filename, module_globals)

     後々の呼び出しで 'module_globals' が ‘None’ となっていても、ファイ
     ルの形式でないモジュールの行を後から *note getline(): df0. で取得す
     るのに十分な詳細を把握しておきます。この関数により、モジュールの
     globals を無限に持ち運ぶ必要無しに、実際に必要な行まで I/O を行う必
     要がなくなります。

     Added in version 3.5.

以下はプログラム例です:

     >>> import linecache
     >>> linecache.getline(linecache.__file__, 8)
     'import sys\n'

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/linecache.py

   (2) https://peps.python.org/pep-0302/


File: python.info,  Node: shutil --- 高水準のファイル操作,  Prev: linecache --- テキストラインへのランダムアクセス,  Up: ファイルとディレクトリへのアクセス

5.11.10 ‘shutil’ -- 高水準のファイル操作
----------------------------------------

'ソースコード:' Lib/shutil.py(1)

__________________________________________________________________

*note shutil: b3. モジュールはファイルやファイルの集まりに対する高水準の
操作方法を多数提供します。特にファイルのコピーや削除のための関数が用意さ
れています。個別のファイルに対する操作については、 *note os: 91. モジュ
ールも参照してください。

     警告: 高水準のファイルコピー関数 (*note shutil.copy(): a28, *note
     shutil.copy2(): a29.) でも、ファイルのメタデータの全てをコピーする
     ことはできません。

     POSIXプラットフォームでは、これはACLやファイルのオーナー、グループ
     が失われることを意味しています。 Mac OSでは、リソースフォーク
     (resource fork)やその他のメタデータが利用されません。これは、リソー
     スが失われ、ファイルタイプや生成者コード(creator code)が正しくなく
     なることを意味しています。 Windowsでは、ファイルオーナー、ACL、代替
     データストリームがコピーされません。

* Menu:

* ディレクトリとファイルの操作::
* アーカイブ化操作::
* 出力ターミナルのサイズの取得::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/shutil.py


File: python.info,  Node: ディレクトリとファイルの操作,  Next: アーカイブ化操作,  Up: shutil --- 高水準のファイル操作

5.11.10.1 ディレクトリとファイルの操作
......................................

 -- の関数: shutil.copyfileobj (fsrc, fdst[, length])

     Copy the contents of the *note file-like object: 1193. 'fsrc' to
     the file-like object 'fdst'.  The integer 'length', if given, is
     the buffer size.  In particular, a negative 'length' value means to
     copy the data without looping over the source data in chunks; by
     default the data is read in chunks to avoid uncontrolled memory
     consumption.  Note that if the current file position of the 'fsrc'
     object is not 0, only the contents from the current file position
     to the end of the file will be copied.

 -- の関数: shutil.copyfile (src, dst, *, follow_symlinks=True)

     Copy the contents (no metadata) of the file named 'src' to a file
     named 'dst' and return 'dst' in the most efficient way possible.
     'src' and 'dst' are *note path-like objects: 280. or path names
     given as strings.

     'dst' は完全な対象ファイル名でなければなりません。対象としてディレ
     クトリ名を指定したい場合は *note copy(): a28. を参照してください。
     'src' と 'dst' が同じファイルだった場合、 *note SameFileError: f6a.
     を送出します。

     'dst' は書き込み可能でなければなりません。そうでない場合、 *note
     OSError: 3f0. 例外を送出します。 'dst' がすでに存在する場合、そのフ
     ァイルは置き換えられます。キャラクタデバイスやブロックデバイスなど
     の特殊なファイルとパイプをこの関数でコピーすることはできません。

     'follow_symlinks' が偽で 'src' がシンボリックリンクの場合、 'src' の
     リンク先をコピーする代わりに新しいシンボリックリンクを作成します。

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copyfile’ を送出します。

     バージョン 3.3 で変更: 以前は *note OSError: 3f0. の代わりに *note
     IOError: 1026. が送出されていました。 'follow_symlinks' 引数が追加
     されました。 'dst' を返すようになりました。

     バージョン 3.4 で変更: *note Error: f69. の代わりに *note
     SameFileError: f6a. を送出します。後者は前者のサブクラスなのでこの
     変更は後方互換です。

     バージョン 3.8 で変更: ファイルのコピーをより効率的に行うため、プラ
     ットフォーム特有の高速なコピーを行うシステムコールが利用されること
     があります。 *note プラットフォーム依存の効率的なコピー操作: a2c. を
     参照してください。

 -- 例外: shutil.SameFileError

     *note copyfile(): a27. のコピー元と先が同じファイルの場合送出されま
     す。

     Added in version 3.4.

 -- の関数: shutil.copymode (src, dst, *, follow_symlinks=True)

     Copy the permission bits from 'src' to 'dst'.  The file contents,
     owner, and group are unaffected.  'src' and 'dst' are *note
     path-like objects: 280. or path names given as strings.  If
     'follow_symlinks' is false, and both 'src' and 'dst' are symbolic
     links, *note copymode(): 160f. will attempt to modify the mode of
     'dst' itself (rather than the file it points to).  This
     functionality is not available on every platform; please see *note
     copystat(): 1101. for more information.  If *note copymode(): 160f.
     cannot modify symbolic links on the local platform, and it is asked
     to do so, it will do nothing and return.

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copymode’ を送出します。

     バージョン 3.3 で変更: 'follow_symlinks' 引数が追加されました。

 -- の関数: shutil.copystat (src, dst, *, follow_symlinks=True)

     Copy the permission bits, last access time, last modification time,
     and flags from 'src' to 'dst'.  On Linux, *note copystat(): 1101.
     also copies the "extended attributes" where possible.  The file
     contents, owner, and group are unaffected.  'src' and 'dst' are
     *note path-like objects: 280. or path names given as strings.

     'follow_symlinks' が偽の場合、 'src' と 'dst' の両方がシンボリック
     リンクであれば、 *note copystat(): 1101. はリンク先ではなくてシンボ
     リックリンク自体を操作します。 'src' からシンボリックリンクの情報を
     読み込み、 'dst' のシンボリックリンクにその情報を書き込みます。

          注釈: すべてのプラットフォームでシンボリックリンクの検査と変更
          ができるわけではありません。 Python はその機能が利用かどうかを
          調べる方法を用意しています。

             * ‘os.chmod in os.supports_follow_symlinks’ が ‘True’ の場
               合 *note copystat(): 1101. はシンボリックリンクのパーミッ
               ションを変更できます。

             * ‘os.utime in os.supports_follow_symlinks’ が ‘True’ の場
               合 *note copystat(): 1101. はシンボリックリンクの最終アク
               セス時間と最終変更時間を変更できます。

             * ‘os.chflags in os.supports_follow_symlinks’ が ‘True’ の
               場合 *note copystat(): 1101. はシンボリックリンクのフラグ
               を変更できます。 (‘os.chflags’ がないプラットフォームもあ
               ります。)

          機能の幾つか、もしくは全てが利用できないプラットフォームでシン
          ボリックリンクを変更しようとした場合、 *note copystat(): 1101.
          は可能な限り全てをコピーします。*note copystat(): 1101. が失敗
          を返すことはありません。

          より詳しい情報は *note os.supports_follow_symlinks: 10cb. を参
          照して下さい。

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copystat’ を送出します。

     バージョン 3.3 で変更: 'follow_symlinks' 引数と Linux の拡張属性が
     サポートされました。

 -- の関数: shutil.copy (src, dst, *, follow_symlinks=True)

     ファイル 'src' をファイルまたはディレクトリ 'dst' にコピーします。
     'src' と 'dst' は両方共 *note path-like object: 280. または文字列で
     なければなりません。 'dst' がディレクトリを指定している場合、ファイ
     ルは 'dst' の中に、 'src' のベースファイル名を使ってコピーされます
     。'dst' が既に存在するファイルを指定している場合、それは置き換えら
     れます。新しく作成したファイルのパスを返します。

     'follow_symlinks' が偽で、 'src' がシンボリックリンクの場合、 'dst'
     はシンボリックリンクとして作成されます。 'follow_symlinks' が真で
     'src' がシンボリックリンクの場合、 'dst' には 'src' のリンク先のフ
     ァイルがコピーされます。

     *note copy(): a28. はファイルのデータとパーミッションをコピーします
     。 (*note os.chmod(): 1fc. を参照) その他の、ファイルの作成時間や変
     更時間などのメタデータはコピーしません。 コピー元のファイルのメタデ
     ータを保存したい場合は、 ‘copy2()’ を利用してください。

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copyfile’ を送出します。

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copymode’ を送出します。

     バージョン 3.3 で変更: 'follow_symlinks' 引数が追加されました。新し
     く作成されたファイルのパスを返すようになりました。

     バージョン 3.8 で変更: ファイルのコピーをより効率的に行うため、プラ
     ットフォーム特有の高速なコピーを行うシステムコールが利用されること
     があります。 *note プラットフォーム依存の効率的なコピー操作: a2c. を
     参照してください。

 -- の関数: shutil.copy2 (src, dst, *, follow_symlinks=True)

     *note copy2(): a29. はファイルのメタデータを保持しようとすることを
     除けば *note copy(): a28. と等価です。

     When 'follow_symlinks' is false, and 'src' is a symbolic link,
     *note copy2(): a29. attempts to copy all metadata from the 'src'
     symbolic link to the newly created 'dst' symbolic link.  However,
     this functionality is not available on all platforms.  On platforms
     where some or all of this functionality is unavailable, *note
     copy2(): a29. will preserve all the metadata it can; *note copy2():
     a29. never raises an exception because it cannot preserve file
     metadata.

     *note copy2(): a29. はファイルのメタデータをコピーするために *note
     copystat(): 1101. を利用します。シンボリックリンクのメタデータを変
     更するためのプラットフォームサポートについては *note copystat():
     1101. を参照して下さい。

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copyfile’ を送出します。

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copystat’ を送出します。

     バージョン 3.3 で変更: 'follow_symlinks' 引数が追加されました。 拡
     張ファイルシステム属性もコピーしようと試みます (現在は Linux のみ
     )。新しく作成されたファイルへのパスを返すようになりました。

     バージョン 3.8 で変更: ファイルのコピーをより効率的に行うため、プラ
     ットフォーム特有の高速なコピーを行うシステムコールが利用されること
     があります。 *note プラットフォーム依存の効率的なコピー操作: a2c. を
     参照してください。

 -- の関数: shutil.ignore_patterns (*patterns)

     このファクトリ関数は、 *note copytree(): 9f7. 関数の 'ignore' 引数
     に渡すための呼び出し可能オブジェクトを作成します。 glob形式の
     'patterns' にマッチするファイルやディレクトリが無視されます。下の例
     を参照してください。

 -- の関数: shutil.copytree (src, dst, symlinks=False, ignore=None,
          copy_function=copy2, ignore_dangling_symlinks=False,
          dirs_exist_ok=False)

     Recursively copy an entire directory tree rooted at 'src' to a
     directory named 'dst' and return the destination directory.  All
     intermediate directories needed to contain 'dst' will also be
     created by default.

     各ディレクトリのパーミッション、最終アクセス時間、最終変更時間は
     *note copystat(): 1101. でコピーされます。それぞれのファイルは
     *note copy2(): a29. でコピーされます。

     'symlinks' が真の場合、ソースツリー内のシンボリックリンクは新しいツ
     リーでもシンボリックになり、元のシンボリックリンクのメタデータはプ
     ラットフォームが許す限りコピーされます。偽の場合や省略された場合、
     リンク先のファイルの内容とメタデータが新しいツリーにコピーされます
     。

     When 'symlinks' is false, if the file pointed to by the symlink
     doesn't exist, an exception will be added in the list of errors
     raised in an *note Error: f69. exception at the end of the copy
     process.  You can set the optional 'ignore_dangling_symlinks' flag
     to true if you want to silence this exception.  Notice that this
     option has no effect on platforms that don't support *note
     os.symlink(): 10c5.

     'ignore' は *note copytree(): 9f7. が走査しているディレクトリと
     *note os.listdir(): 10cd. が返すその内容のリストを引数として受け取
     ることのできる呼び出し可能オブジェクトでなければなりません。 *note
     copytree(): 9f7. は再帰的に呼び出されるので、 'ignore' はコピーされ
     る各ディレクトリ毎に呼び出されます。 'ignore' の戻り値はカレントデ
     ィレクトリに相対的なディレクトリ名およびファイル名のシーケンス（す
     なわち第二引数の項目のサブセット）でなければなりません。それらの名
     前はコピー中に無視されます。 *note ignore_patterns(): 27bf. を用い
     て glob 形式のパターンによって無視する呼び出し可能オブジェクトを作
     成することが出来ます。

     例外が発生した場合、理由のリストとともに *note Error: f69. を送出し
     ます。

     'copy_function' は各ファイルをコピーするために利用される呼び出し可
     能オブジェクトでなければなりません。'copy_function' はコピー元のパ
     スとコピー先のパスを引数に呼び出されます。デフォルトでは *note
     copy2(): a29. が利用されますが、同じ特徴を持つ関数 (*note
     shutil.copy(): a28. など) ならどれでも利用可能です。

     If 'dirs_exist_ok' is false (the default) and 'dst' already exists,
     a *note FileExistsError: fea. is raised.  If 'dirs_exist_ok' is
     true, the copying operation will continue if it encounters existing
     directories, and files within the 'dst' tree will be overwritten by
     corresponding files from the 'src' tree.

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.copytree’ を送出します。

     バージョン 3.2 で変更: Added the 'copy_function' argument to be
     able to provide a custom copy function.  Added the
     'ignore_dangling_symlinks' argument to silence dangling symlinks
     errors when 'symlinks' is false.

     バージョン 3.3 で変更: 'symlinks' が偽の場合メタデータをコピーしま
     す。 'dst' を返すようになりました。

     バージョン 3.8 で変更: ファイルのコピーをより効率的に行うため、プラ
     ットフォーム特有の高速なコピーを行うシステムコールが利用されること
     があります。 *note プラットフォーム依存の効率的なコピー操作: a2c. を
     参照してください。

     バージョン 3.8 で変更: Added the 'dirs_exist_ok' parameter.

 -- の関数: shutil.rmtree (path, ignore_errors=False, onerror=None, *,
          onexc=None, dir_fd=None)

     Delete an entire directory tree; 'path' must point to a directory
     (but not a symbolic link to a directory).  If 'ignore_errors' is
     true, errors resulting from failed removals will be ignored; if
     false or omitted, such errors are handled by calling a handler
     specified by 'onexc' or 'onerror' or, if both are omitted,
     exceptions are propagated to the caller.

     この関数は *note ディレクトリ記述子への相対パス: 10c8. をサポートし
     ています。

          注釈: 必要な fd ベースの関数をサポートしているプラットフォーム
          では、 シンボリックリンク攻撃に耐性のあるバージョンの *note
          rmtree(): 2d8. がデフォルトで利用されます。それ以外のプラット
          フォームでは、 *note rmtree(): 2d8. の実装はシンボリックリンク
          攻撃の影響を受けます。適当なタイミングと環境で攻撃者はファイル
          システム上のシンボリックリンクを操作して、それ以外の方法ではア
          クセス不可能なファイルを削除することが出来ます。アプリケーショ
          ンは、どちらのバージョンの *note rmtree(): 2d8. が利用されてい
          るかを知るために関数のデータ属性 *note
          rmtree.avoids_symlink_attacks: 27c0. を利用することができます
          。

     If 'onexc' is provided, it must be a callable that accepts three
     parameters: 'function', 'path', and 'excinfo'.

     The first parameter, 'function', is the function which raised the
     exception; it depends on the platform and implementation.  The
     second parameter, 'path', will be the path name passed to
     'function'.  The third parameter, 'excinfo', is the exception that
     was raised.  Exceptions raised by 'onexc' will not be caught.

     The deprecated 'onerror' is similar to 'onexc', except that the
     third parameter it receives is the tuple returned from *note
     sys.exc_info(): 656.

     引数 ‘path’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘shutil.rmtree’ を送出します。

     バージョン 3.3 で変更: プラットフォームが fd ベースの関数をサポート
     する場合に自動的に使用されるシンボリックリンク攻撃に耐性のあるバー
     ジョンが追加されました。

     バージョン 3.8 で変更: Windows では、ディレクトリへのジャンクション
     を削除する際にリンク先ディレクトリにあるファイルを削除しなくなりま
     した。

     バージョン 3.11 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.12 で変更: Added the 'onexc' parameter, deprecated
     'onerror'.

     バージョン 3.13 で変更: ‘rmtree()’ now ignores *note
     FileNotFoundError: e8f. exceptions for all but the top-level path.
     Exceptions other than *note OSError: 3f0. and subclasses of
     ‘OSError’ are now always propagated to the caller.

      -- の属性: rmtree.avoids_symlink_attacks

          プラットフォームと実装がシンボリックリンク攻撃に耐性のあるバー
          ジョンの *note rmtree(): 2d8. を提供しているかどうかを示します
          。現在のところ、この属性は fd ベースのディレクトリアクセス関数
          をサポートしているプラットフォームでのみ真になります。

          Added in version 3.3.

 -- の関数: shutil.move (src, dst, copy_function=copy2)

     Recursively move a file or directory ('src') to another location
     and return the destination.

     If 'dst' is an existing directory or a symlink to a directory, then
     'src' is moved inside that directory.  The destination path in that
     directory must not already exist.

     If 'dst' already exists but is not a directory, it may be
     overwritten depending on *note os.rename(): 10c2. semantics.

     If the destination is on the current filesystem, then *note
     os.rename(): 10c2. is used.  Otherwise, 'src' is copied to the
     destination using 'copy_function' and then removed.  In case of
     symlinks, a new symlink pointing to the target of 'src' will be
     created as the destination and 'src' will be removed.

     If 'copy_function' is given, it must be a callable that takes two
     arguments, 'src' and the destination, and will be used to copy
     'src' to the destination if *note os.rename(): 10c2. cannot be
     used.  If the source is a directory, *note copytree(): 9f7. is
     called, passing it the 'copy_function'.  The default
     'copy_function' is *note copy2(): a29.  Using *note copy(): a28. as
     the 'copy_function' allows the move to succeed when it is not
     possible to also copy the metadata, at the expense of not copying
     any of the metadata.

     引数 ‘src’, ‘dst’ を指定して *note 監査イベント: 1825.
     ‘shutil.move’ を送出します。

     バージョン 3.3 で変更: 異なるファイルシステムに対する明示的なシンボ
     リックリンク処理が追加されました。これにより GNU ‘mv’ の振る舞いに
     適応するようになります。 'dst' を返すようになりました。

     バージョン 3.5 で変更: キーワード引数 'copy_function' が追加されま
     した。

     バージョン 3.8 で変更: ファイルのコピーをより効率的に行うため、プラ
     ットフォーム特有の高速なコピーを行うシステムコールが利用されること
     があります。 *note プラットフォーム依存の効率的なコピー操作: a2c. を
     参照してください。

     バージョン 3.9 で変更: 'src' と 'dst' が両方とも *note path-like
     object: 280. を受け付けるようになりました。

 -- の関数: shutil.disk_usage (path)

     指定されたパスについて、ディスクの利用状況を、名前付きタプル (*note
     named tuple: 61a.) で返します。このタプルには 'total', 'used',
     'free' という属性があり、それぞれトータル、使用中、空きの容量をバイ
     ト単位で示します。 'path' はファイルまたはディレクトリです。

          注釈: On Unix filesystems, 'path' must point to a path within
          a 'mounted' filesystem partition.  On those platforms, CPython
          doesn't attempt to retrieve disk usage information from
          non-mounted filesystems.

     Added in version 3.3.

     バージョン 3.8 で変更: Windowsにおいても 'path' にディレクトリだけ
     でなくファイルを指定できるようになりました。

     *note Availability: 1cbe.: Unix, Windows.

 -- の関数: shutil.chown (path, user=None, group=None, *, dir_fd=None,
          follow_symlinks=True)

     指定された 'path' のオーナー 'user' と/または 'group' を変更します
     。

     'user' はシステムのユーザー名か uid です。 'group' も同じです。少な
     くともどちらかの引数を指定する必要があります。

     内部で利用している *note os.chown(): 10bf. も参照してください。

     引数 ‘path’, ‘user’, ‘group’ を指定して *note 監査イベント: 1825.
     ‘shutil.chown’ を送出します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

     バージョン 3.13 で変更: Added 'dir_fd' and 'follow_symlinks'
     parameters.

 -- の関数: shutil.which (cmd, mode=os.F_OK | os.X_OK, path=None)

     'cmd' を実行しようとした時に実行される実行ファイルのパスを返します
     。 'cmd' を呼び出せない場合は ‘None’ を返します。

     'mode' is a permission mask passed to *note os.access(): 10bd, by
     default determining if the file exists and is executable.

     'path' is a "‘PATH’ string" specifying the directories to look in,
     delimited by *note os.pathsep: 1cae.  When no 'path' is specified,
     the ‘PATH’ environment variable is read from *note os.environ:
     118a, falling back to *note os.defpath: 196d. if it is not set.

     On Windows, the current directory is prepended to the 'path' if
     'mode' does not include ‘os.X_OK’.  When the 'mode' does include
     ‘os.X_OK’, the Windows API ‘NeedCurrentDirectoryForExePathW’ will
     be consulted to determine if the current directory should be
     prepended to 'path'.  To avoid consulting the current working
     directory for executables: set the environment variable
     ‘NoDefaultCurrentDirectoryInExePath’.

     Also on Windows, the ‘PATHEXT’ environment variable is used to
     resolve commands that may not already include an extension.  For
     example, if you call ‘shutil.which("python")’, *note which(): 480.
     will search ‘PATHEXT’ to know that it should look for ‘python.exe’
     within the 'path' directories.  For example, on Windows:

          >>> shutil.which("python")
          'C:\\Python33\\python.EXE'

     This is also applied when 'cmd' is a path that contains a directory
     component:

          >> shutil.which("C:\\Python33\\python")
          'C:\\Python33\\python.EXE'

     Added in version 3.3.

     バージョン 3.8 で変更: *note bytes: 1a4. 型も使用できるようになりま
     した。 'cmd' が *note bytes: 1a4. 型の場合、戻り値も *note bytes:
     1a4. 型です。

     バージョン 3.12 で変更: On Windows, the current directory is no
     longer prepended to the search path if 'mode' includes ‘os.X_OK’
     and WinAPI ‘NeedCurrentDirectoryForExePathW(cmd)’ is false, else
     the current directory is prepended even if it is already in the
     search path; ‘PATHEXT’ is used now even when 'cmd' includes a
     directory component or ends with an extension that is in ‘PATHEXT’;
     and filenames that have no extension can now be found.

     バージョン 3.12.1 で変更: On Windows, if 'mode' includes ‘os.X_OK’,
     executables with an extension in ‘PATHEXT’ will be preferred over
     executables without a matching extension.  This brings behavior
     closer to that of Python 3.11.

 -- 例外: shutil.Error

     この例外は複数ファイルの操作を行っているときに生じる例外をまとめた
     ものです。 *note copytree(): 9f7. に対しては例外の引数は3つのタプル
     ('srcname', 'dstname', 'exception')からなるリストです。

* Menu:

* プラットフォーム依存の効率的なコピー操作::
* copytree の例::
* rmtree の例::


File: python.info,  Node: プラットフォーム依存の効率的なコピー操作,  Next: copytree の例,  Up: ディレクトリとファイルの操作

5.11.10.2 プラットフォーム依存の効率的なコピー操作
..................................................

Python 3.8 から、ファイルのコピーを伴う全ての関数 (*note copyfile():
a27, *note copy(): a28, *note copy2(): a29, *note copytree(): 9f7, およ
び *note move(): a2a.) はより効率的なファイルのコピーのためにプラットフ
ォーム特有の "高速なコピー" を行うことがあります (bpo-33671(1) を参照し
てください).  ここで "高速なコピー" とは、 "‘outfd.write(infd.read())’"
のようにPython が管理するユーザー空間のバッファを利用することを避け、コ
ピー操作がカーネル空間内で行われることを意味します。

macOS では fcopyfile(2) がファイルの内容（メタデータを除く）をコピーする
ために利用されます。

Linux では *note os.sendfile(): add. が利用されます。

Windows では *note shutil.copyfile(): a27. はより大きなバッファサイズを
デフォルトとして使います (6 KiB の代わりに 1 MiB が使われます)。また、
*note memoryview(): 435. ベースの変形である *note shutil.copyfileobj():
a2b. が使われます。

高速なコピー操作が失敗して出力ファイルにデータが書き込まれなかった場合、
shutil はユーザーへの通知なしでより効率の低い *note copyfileobj(): a2b.
関数にフォールバックします。

バージョン 3.8 で変更.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33671

   (2) http://www.manpagez.com/man/3/copyfile/


File: python.info,  Node: copytree の例,  Next: rmtree の例,  Prev: プラットフォーム依存の効率的なコピー操作,  Up: ディレクトリとファイルの操作

5.11.10.3 copytree の例
.......................

*note ignore_patterns(): 27bf. ヘルパ関数を利用する例です:

     from shutil import copytree, ignore_patterns

     copytree(source, destination, ignore=ignore_patterns('*.pyc', 'tmp*'))

この例では、 ‘.pyc’ ファイルと、 ‘tmp’ で始まる全てのファイルやディレク
トリを除いて、全てをコピーします。

'ignore' 引数にロギングさせる別の例です。

     from shutil import copytree
     import logging

     def _logpath(path, names):
         logging.info('Working in %s', path)
         return []   # nothing will be ignored

     copytree(source, destination, ignore=_logpath)


File: python.info,  Node: rmtree の例,  Prev: copytree の例,  Up: ディレクトリとファイルの操作

5.11.10.4 rmtree の例
.....................

This example shows how to remove a directory tree on Windows where some
of the files have their read-only bit set.  It uses the onexc callback
to clear the readonly bit and reattempt the remove.  Any subsequent
failure will propagate.

     import os, stat
     import shutil

     def remove_readonly(func, path, _):
         "Clear the readonly bit and reattempt the removal"
         os.chmod(path, stat.S_IWRITE)
         func(path)

     shutil.rmtree(directory, onexc=remove_readonly)


File: python.info,  Node: アーカイブ化操作,  Next: 出力ターミナルのサイズの取得,  Prev: ディレクトリとファイルの操作,  Up: shutil --- 高水準のファイル操作

5.11.10.5 アーカイブ化操作
..........................

Added in version 3.2.

バージョン 3.5 で変更: 'xztar' 形式のサポートが追加されました。

圧縮とアーカイブ化されているファイルの読み書きの高水準なユーティリティも
提供されています。これらは *note zipfile: 117. 、 *note tarfile: c8. モ
ジュールに依拠しています。

 -- の関数: shutil.make_archive (base_name, format[, root_dir[,
          base_dir[, verbose[, dry_run[, owner[, group[, logger]]]]]]])

     アーカイブファイル (zip や tar) を作成してその名前を返します。

     'base_name' is the name of the file to create, including the path,
     minus any format-specific extension.

     'format' is the archive format: one of "zip" (if the *note zlib:
     119. module is available), "tar", "gztar" (if the *note zlib: 119.
     module is available), "bztar" (if the *note bz2: f. module is
     available), or "xztar" (if the *note lzma: 7e. module is
     available).

     'root_dir' はアーカイブファイルのルートとなるディレクトリです。アー
     カイブに含まれる全てのパスは 'root_dir' からの相対パスになります。
     これは、アーカイブファイルを生成する前に 'root_dir' へ移動すること
     に相当します。

     'base_dir' はアーカイブを開始するディレクトリです。すなわち、
     'base_dir' アーカイブに含まれるファイルとディレクトリに対する共通の
     プレフィックスになります。 'base_dir' は 'root_dir' からの相対パス
     でなければなりません。 'base_dir' と 'root_dir' を組み合わせて使う
     方法については *note base_dir を使ったアーカイブ化の例: 27c7. を参
     照してください。

     'root_dir' と 'base_dir' のどちらも、デフォルトはカレントディレクト
     リです。

     'dry_run' が真の場合、アーカイブは作成されませんが実行される操作は
     'logger' に記録されます。

     'owner' と 'group' は、tar アーカイブを作成するときに使われます。デ
     フォルトでは、カレントのオーナーとグループを使います。

     'logger' は PEP 282(1) に互換なオブジェクトでなければなりません。こ
     れは普通は *note logging.Logger: b1d. のインスタンスです。

     'verbose' 引数は使用されず、非推奨です。

     引数 ‘base_name'’, ‘format’, ‘root_dir’, ‘base_dir``を指定して
     :ref:`監査イベント <auditing>` ``shutil.make_archive’ を送出します
     。

          注釈: This function is not thread-safe when custom archivers
          registered with *note register_archive_format(): 27c8. do not
          support the 'root_dir' argument.  In this case it temporarily
          changes the current working directory of the process to
          'root_dir' to perform archiving.

     バージョン 3.8 で変更: ‘format="tar"’ で作成されたアーカイブでは、
     レガシーなGNU形式に代わってモダンな pax (POSIX.1-2001) 形式が使われ
     ます。

     バージョン 3.10.6 で変更: This function is now made thread-safe
     during creation of standard ‘.zip’ and tar archives.

 -- の関数: shutil.get_archive_formats ()

     アーカイブ化をサポートしているフォーマットのリストを返します。返さ
     れるシーケンスのそれぞれの要素は、タプル ‘(name, description)’ です
     。

     デフォルトでは、 *note shutil: b3. は次のフォーマットを提供していま
     す。

        - 'zip': ZIP ファイル (*note zlib: 119. モジュールが利用可能な場
          合)。

        - 'tar': 非圧縮の tar ファイル。 POSIX.1-2001 pax 形式が使われま
          す。

        - 'gztar': gzip で圧縮された tar ファイル (*note zlib: 119. モジ
          ュールが利用可能な場合)。

        - 'bztar': bzip2 で圧縮された tar ファイル (*note bz2: f. モジュ
          ールが利用可能な場合)。

        - 'xztar': xz で圧縮された tar ファイル (*note lzma: 7e. モジュ
          ールが利用可能な場合)。

     *note register_archive_format(): 27c8. を使って、新しいフォーマット
     を登録したり、既存のフォーマットに独自のアーカイバを提供したりでき
     ます。

 -- の関数: shutil.register_archive_format (name, function[,
          extra_args[, description]])

     アーカイバをフォーマット 'name' に登録します。

     'function' はアーカイブのアンパックに使用される呼び出し可能オブジェ
     クトです。'funciton' は作成するファイルの 'base_name'、続いてアーカ
     イブを開始する元の 'base_dir' (デフォルトは *note os.curdir: 272b.)
     を受け取ります。さらなる引数は、次のキーワード引数として渡されます:
     'owner', 'group', 'dry_run' ならびに 'logger' (*note
     make_archive(): 47f. に渡されます)。

     If 'function' has the custom attribute ‘function.supports_root_dir’
     set to ‘True’, the 'root_dir' argument is passed as a keyword
     argument.  Otherwise the current working directory of the process
     is temporarily changed to 'root_dir' before calling 'function'.  In
     this case *note make_archive(): 47f. is not thread-safe.

     'extra_args' は、与えられた場合、 ‘(name, value)’ の対のシーケンス
     で、アーカイバ呼び出し可能オブジェクトが使われるときに追加のキーワ
     ード引数として使われます。

     'description' は、アーカイバのリストを返す *note
     get_archive_formats(): 27c9. で使われます。デフォルトでは空の文字列
     です。

     バージョン 3.12 で変更: Added support for functions supporting the
     'root_dir' argument.

 -- の関数: shutil.unregister_archive_format (name)

     アーカイブフォーマット 'name' を、サポートされているフォーマットの
     リストから取り除きます。

 -- の関数: shutil.unpack_archive (filename[, extract_dir[, format[,
          filter]]])

     アーカイブをアンパックします。 'filename' はアーカイブのフルパスで
     す。

     'extract_dir' はアーカイブをアンパックする先のディレクトリ名です。
     指定されなかった場合は現在の作業ディレクトリを利用します。

     'format' はアーカイブフォーマットで、 "zip", "tar", "gztar",
     "bztar", "xztar" あるいは *note register_unpack_format(): 27cb. で
     登録したその他のフォーマットのどれかです。 指定されなかった場合、
     *note unpack_archive(): 438. はアーカイブファイル名の拡張子に対して
     登録されたアンパッカーを利用します。 アンパッカーが見つからなかった
     場合、 *note ValueError: 1e3. を発生させます。

     The keyword-only 'filter' argument is passed to the underlying
     unpacking function.  For zip files, 'filter' is not accepted.  For
     tar files, it is recommended to set it to ‘'data'’, unless using
     features specific to tar and UNIX-like filesystems.  (See *note
     Extraction filters: 439. for details.)  The ‘'data'’ filter will
     become the default for tar files in Python 3.14.

     引数 ‘filename’, ‘extract_dir’, ‘format’ を指定して *note
     監査イベント: 1825. ‘shutil.unpack_archive’ を送出します。

          警告: Never extract archives from untrusted sources without
          prior inspection.  It is possible that files are created
          outside of the path specified in the 'extract_dir' argument,
          e.g.  members that have absolute filenames starting with "/"
          or filenames with two dots "..".

     バージョン 3.7 で変更: 'filename' と 'extract_dir' が *note
     path-like object: 280. を受け付けるようになりました。

     バージョン 3.12 で変更: Added the 'filter' argument.

 -- の関数: shutil.register_unpack_format (name, extensions, function[,
          extra_args[, description]])

     アンパック用のフォーマットを登録します。 'name' はフォーマット名で
     、 'extensions' はそのフォーマットに対応する拡張子 (例えば Zip ファ
     イルに対して ‘.zip’) のリストです。

     'function' is the callable that will be used to unpack archives.
     The callable will receive:

        - the path of the archive, as a positional argument;

        - the directory the archive must be extracted to, as a
          positional argument;

        - possibly a 'filter' keyword argument, if it was given to *note
          unpack_archive(): 438.;

        - additional keyword arguments, specified by 'extra_args' as a
          sequence of ‘(name, value)’ tuples.

     フォーマットの説明として 'description' を指定することができます。こ
     れは *note get_unpack_formats(): 27cc. 関数によって返されます。

 -- の関数: shutil.unregister_unpack_format (name)

     アンパックフォーマットを登録解除します。 'name' はフォーマットの名
     前です。

 -- の関数: shutil.get_unpack_formats ()

     登録されているすべてのアンパックフォーマットをリストで返します。戻
     り値のリストの各要素は ‘(name, extensions, description)’ の形のタプ
     ルです。

     デフォルトでは、 *note shutil: b3. は次のフォーマットを提供していま
     す。

        - 'zip': ZIP ファイル (対応するモジュールが利用可能な場合にのみ
          圧縮ファイルはアンパックされます)。

        - 'tar': 圧縮されていない tar ファイル。

        - 'gztar': gzip で圧縮された tar ファイル (*note zlib: 119. モジ
          ュールが利用可能な場合)。

        - 'bztar': bzip2 で圧縮された tar ファイル (*note bz2: f. モジュ
          ールが利用可能な場合)。

        - 'xztar': xz で圧縮された tar ファイル (*note lzma: 7e. モジュ
          ールが利用可能な場合)。

     *note register_unpack_format(): 27cb. を使って新しいフォーマットや
     既存のフォーマットに対する別のアンパッカーを登録することができます
     。

* Menu:

* アーカイブ化の例::
* base_dir を使ったアーカイブ化の例::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0282/


File: python.info,  Node: アーカイブ化の例,  Next: base_dir を使ったアーカイブ化の例,  Up: アーカイブ化操作

5.11.10.6 アーカイブ化の例
..........................

この例では、ユーザの ‘.ssh’ ディレクトリにあるすべてのファイルを含む、
gzip された tar ファイルアーカイブを作成します:

     >>> from shutil import make_archive
     >>> import os
     >>> archive_name = os.path.expanduser(os.path.join('~', 'myarchive'))
     >>> root_dir = os.path.expanduser(os.path.join('~', '.ssh'))
     >>> make_archive(archive_name, 'gztar', root_dir)
     '/Users/tarek/myarchive.tar.gz'

結果のアーカイブは、以下のものを含みます:

     $ tar -tzvf /Users/tarek/myarchive.tar.gz
     drwx------ tarek/staff       0 2010-02-01 16:23:40 ./
     -rw-r--r-- tarek/staff     609 2008-06-09 13:26:54 ./authorized_keys
     -rwxr-xr-x tarek/staff      65 2008-06-09 13:26:54 ./config
     -rwx------ tarek/staff     668 2008-06-09 13:26:54 ./id_dsa
     -rwxr-xr-x tarek/staff     609 2008-06-09 13:26:54 ./id_dsa.pub
     -rw------- tarek/staff    1675 2008-06-09 13:26:54 ./id_rsa
     -rw-r--r-- tarek/staff     397 2008-06-09 13:26:54 ./id_rsa.pub
     -rw-r--r-- tarek/staff   37192 2010-02-06 18:23:10 ./known_hosts


File: python.info,  Node: base_dir を使ったアーカイブ化の例,  Prev: アーカイブ化の例,  Up: アーカイブ化操作

5.11.10.7 'base_dir' を使ったアーカイブ化の例
.............................................

この例では、 *note 上記の例: 27cf. と同じく *note make_archive(): 47f. の
使い方を示しますが、ここでは特に 'base_dir' の使い方を説明します。以下の
ようなディレクトリ構造があるとします。

     $ tree tmp
     tmp
     └── root
         └── structure
             ├── content
                 └── please_add.txt
             └── do_not_add.txt

作成するアーカイブには ‘please_add.txt’ が含まれますが、いっぽう
‘do_not_add.txt’ は含まないようにします。この場合以下のようにします。

     >>> from shutil import make_archive
     >>> import os
     >>> archive_name = os.path.expanduser(os.path.join('~', 'myarchive'))
     >>> make_archive(
     ...     archive_name,
     ...     'tar',
     ...     root_dir='tmp/root',
     ...     base_dir='structure/content',
     ... )
     '/Users/tarek/my_archive.tar'

アーカイブに含まれるファイルをリストすると、以下のようになります。

     $ python -m tarfile -l /Users/tarek/myarchive.tar
     structure/content/
     structure/content/please_add.txt


File: python.info,  Node: 出力ターミナルのサイズの取得,  Prev: アーカイブ化操作,  Up: shutil --- 高水準のファイル操作

5.11.10.8 出力ターミナルのサイズの取得
......................................

 -- の関数: shutil.get_terminal_size (fallback=(columns, lines))

     ターミナルウィンドウのサイズを取得します。

     幅と高さについて、それぞれ ‘COLUMNS’ と ‘LINES’ という環境変数をチ
     ェックします。その変数が定義されていて値が正の整数であればそれを利
     用します。

     典型的な ‘COLUMNS’ や ‘LINES’ が定義されていない場合には、 *note
     sys.__stdout__: 27d2. に接続されているターミナルに *note
     os.get_terminal_size(): 10d5. を呼び出して問い合わせます。

     システムが対応していない場合やターミナルに接続していないなどの理由
     でターミナルサイズの問い合わせに失敗した場合、 ‘fallback’ 引数に与
     えられた値を利用します。 ‘fallback’ のデフォルト値は ‘(80, 24)’ で
     、これは多くのターミナルエミュレーターが利用しているデフォルトサイ
     ズです。

     戻り値は *note os.terminal_size: 27d3. 型の名前付きタプルです。

     参考: The Single UNIX Specification, Version 2, Other Environment
     Variables(1).

     Added in version 3.3.

     バージョン 3.11 で変更: The ‘fallback’ values are also used if
     *note os.get_terminal_size(): 10d5. returns zeroes.

参考
....

*note os: 91. モジュール

     オペレーティングシステムのインターフェース、Python の *note
     ファイルオブジェクト: 1193. より低レベルでのファイル操作を含みます
     。

*note io: 73. モジュール

     Python 組み込みの I/O ライブラリで、抽象クラスとファイル I/O のよう
     ないくつかの具象クラスを含みます。

*note open(): 4e5. 組み込み関数

     Python で読み書きのためにファイルを開く標準的な方法です。

   ---------- Footnotes ----------

   (1) 
https://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html#tag_002_003


File: python.info,  Node: データの永続化,  Next: データ圧縮とアーカイブ,  Prev: ファイルとディレクトリへのアクセス,  Up: Python 標準ライブラリ

5.12 データの永続化
===================

この章で解説されるモジュール群は Python データをディスクに永続的な形式で
保存します。モジュール *note pickle: 95. とモジュール *note marshal: 80.
は多くの Python データ型をバイト列に変換し、バイト列から再生成します。様
々な DBM 関連モジュールはハッシュを基にした、文字列から他の文字列へのマ
ップを保存するファイルフォーマット群をサポートします。

この章で解説されるモジュールのリスト:

* Menu:

* pickle: pickle --- Python オブジェクトの直列化. Python オブジェクトの直列化
* copyreg: copyreg --- pickle サポート関数を登録する. pickle サポート関数を登録する
* shelve: shelve --- Python オブジェクトの永続化. Python オブジェクトの永続化
* marshal: marshal --- 内部使用向けの Python オブジェクト直列化. 内部使用向けの Python オブジェクト直列化
* dbm: dbm --- Unix "データベース" へのインターフェース. Unix "データベース" へのインターフェース
* sqlite3: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース. SQLite データベース用の DB-API 2.0 インターフェース


File: python.info,  Node: pickle --- Python オブジェクトの直列化,  Next: copyreg --- pickle サポート関数を登録する,  Up: データの永続化

5.12.1 ‘pickle’ -- Python オブジェクトの直列化
----------------------------------------------

'ソースコード:' Lib/pickle.py(1)

__________________________________________________________________

*note pickle: 95. モジュールは Python オブジェクトの直列化および直列化さ
れたオブジェクトの復元のためのバイナリプロトコルを実装しています。
'"Pickle 化"' は Python オブジェクト階層をバイトストリームに変換する処理
、'"非 pickle 化"' は (*note バイナリファイル: 1bf1. または *note
バイトライクオブジェクト: cfb. から) バイトストリームをオブジェクト階層
に復元する処理を意味します。pickle 化 (および非 pickle 化) は "直列化
(serialization)"、"整列化 (marshalling)"、あるいは (2) "平坦化
(flattening)" とも呼ばれますが、混乱を避けるため、ここでは "Pickle 化"、
"非 pickle 化" で統一します。

     警告: ‘pickle’ モジュールは '安全ではありません' 。信頼できるデータ
     のみを非 pickle 化してください。

     '非 pickle 化の過程で任意のコードを実行する' ような、悪意ある
     pickle オブジェクトを生成することが可能です。信頼できない提供元から
     のデータや、改竄された可能性のあるデータの非 pickle 化は絶対に行わ
     ないでください。

     データが改竄されていないことを保証したい場合は、 *note hmac: 60. に
     よる鍵付きハッシュ化を検討してください。

     信頼できないデータを処理する場合 *note json: 76. のようなより安全な
     直列化形式の方が適切でしょう。 *note json との比較: 27d9. を参照し
     てください。

* Menu:

* 他の Python モジュールとの関係::
* データストリームの形式::
* モジュールインターフェース::
* pickle 化、非 pickle 化できるもの::
* クラスインスタンスの pickle 化::
* 型、関数、その他のオブジェクトに対するリダクションのカスタマイズ::
* アウトオブバウンドバッファ::
* グローバル変数を制限する::
* 性能: 性能<2>.
* 使用例: 使用例<11>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pickle.py

   (2) *note marshal: 80. モジュールと間違えないように注意してください。


File: python.info,  Node: 他の Python モジュールとの関係,  Next: データストリームの形式,  Up: pickle --- Python オブジェクトの直列化

5.12.1.1 他の Python モジュールとの関係
.......................................

* Menu:

* marshal との比較::
* json との比較::


File: python.info,  Node: marshal との比較,  Next: json との比較,  Up: 他の Python モジュールとの関係

5.12.1.2 ‘marshal’ との比較
...........................

Python には *note marshal: 80. と呼ばれるより原始的な直列化モジュールが
ありますが、一般的に Python オブジェクトを直列化する方法としては *note
pickle: 95. を選ぶべきです。 *note marshal: 80. は基本的に ‘.pyc’ ファイ
ルをサポートするために存在しています。

*note pickle: 95. モジュールはいくつかの点で *note marshal: 80. と明確に
異なります:

   * *note pickle: 95. モジュールでは、同じオブジェクトが再度直列化され
     ることのないよう、すでに直列化されたオブジェクトについて追跡情報を
     保持します。 *note marshal: 80. はこれを行いません。

     この機能は再帰的オブジェクトと共有オブジェクトの両方に重要な関わり
     をもっています。再帰的オブジェクトとは自分自身に対する参照を持って
     いるオブジェクトです。再帰的オブジェクトは marshal で扱うことができ
     ず、実際、再帰的オブジェクトを marshal 化しようとすると Python イン
     タプリタをクラッシュさせてしまいます。共有オブジェクトは、直列化し
     ようとするオブジェクト階層の異なる複数の場所で同じオブジェクトに対
     する参照が存在する場合に生じます。*note pickle: 95. はそのようなオ
     ブジェクトを一度だけ保存し、その他全ての参照がそのマスターコピーを
     指し示すことを保証します。共有オブジェクトを共有のままにしておくこ
     とは、変更可能なオブジェクトの場合には非常に重要です。

   * *note marshal: 80. はユーザ定義クラスやそのインスタンスを直列化する
     ために使うことができません。 *note pickle: 95. はクラスインスタンス
     を透過的に保存したり復元したりすることができますが、クラス定義をイ
     ンポートすることが可能で、かつオブジェクトが保存された際と同じモジ
     ュールで定義されていなければなりません。

   * *note marshal: 80. の直列化形式は Python のバージョン間での移植性を
     保証していません。 ‘.pyc’ ファイルをサポートすることが主な役割であ
     るため、 Python 開発者は必要があれば直列化形式に非互換な変更を加え
     る権利を有しています。 いっぽう *note pickle: 95. の直列化形式は、
     互換性のあるプロトコルを選ぶという条件のもとで Python リリース間の
     後方互換性が保証されます。また処理すべきデータが Python 2 と Python
     3 の間で非互換な型を含む場合も、 pickle 化および非 pickle 化のコー
     ドはそのような互換性を破る言語の境界を適切に取り扱います。


File: python.info,  Node: json との比較,  Prev: marshal との比較,  Up: 他の Python モジュールとの関係

5.12.1.3 ‘json’ との比較
........................

pickle プロトコルと JSON (JavaScript Object Notation)(1) との基本的な違
いは以下のとおりです:

   * JSON はテキストの直列化フォーマット (大抵の場合 ‘utf-8’ にエンコー
     ドされますが、その出力は Unicode 文字列です) で、pickle はバイナリ
     の直列化フォーマットです;

   * JSON は人間が読める形式ですが、pickle はそうではありません;

   * JSON は相互運用可能で Python 以外でも広く使用されていますが、pickle
     は Python 固有です;

   * JSON は、デフォルトでは Python の組み込み型の一部しか表現することが
     できず、カスタムクラスに対しても行えません; pickle は極めて多くの
     Python 組み込み型を表現できます (その多くは賢い Python 内省機構によ
     って自動的に行われます; 複雑なケースでは *note 固有のオブジェクト
     API: 27dd. によって対応できます)。

   * pickleとは異なり、信頼できないJSONを復元するだけでは、任意のコード
     を実行できる脆弱性は発生しません。

参考
....

*note json: 76. モジュール: JSON への直列化および復元を行うための標準ラ
イブラリモジュール。

   ---------- Footnotes ----------

   (1) https://json.org


File: python.info,  Node: データストリームの形式,  Next: モジュールインターフェース,  Prev: 他の Python モジュールとの関係,  Up: pickle --- Python オブジェクトの直列化

5.12.1.4 データストリームの形式
...............................

The data format used by *note pickle: 95. is Python-specific.  This has
the advantage that there are no restrictions imposed by external
standards such as JSON (which can't represent pointer sharing); however
it means that non-Python programs may not be able to reconstruct pickled
Python objects.

デフォルトでは、*note pickle: 95. データフォーマットは比較的コンパクトな
バイナリ表現を使用します。サイズの抑制目的の最適化が必要なら、pickle さ
れたデータを効率的に *note 圧縮する: 27df. ことができます。

*note pickletools: 96. モジュールには *note pickle: 95. によって生成され
たデータストリームを解析するためのツールが含まれます。*note pickletools:
96. のソースコードには、pickle プロトコルで使用される命令コードに関する
詳細なコメントがあります。

現在 pickle 化には 6 種類のプロトコルを使用できます。より高いプロトコル
を使用するほど、作成された pickle を読み込むためにより高い Python のバー
ジョンが必要になります。

   * プロトコルバージョン 0 はオリジナルの「人間に判読可能な」プロトコル
     で、Python の初期のバージョンとの後方互換性を持ちます。

   * プロトコルバージョン 1 は旧形式のバイナリフォーマットで、これも
     Python の初期バージョンと互換性があります。

   * プロトコルバージョン 2 は Python 2.3 で導入されました。このバージョ
     ンでは *note 新方式のクラス: 27e0. のより効率的な pickle 化を提供し
     ました。プロトコル 2 による改良に関する情報は PEP 307(1) を参照して
     ください。

   * プロトコルバージョン 3 は Python 3 で追加されました。 *note bytes:
     1a4. オブジェクトを明示的にサポートしており、 Python 2.x で
     unpickle することはできません。これは Python 3.0から3.7のデフォルト
     プロトコルでした。

   * プロトコルバージョン 4 は Python 3.4 で追加されました。このバージョ
     ンでは巨大なオブジェクトのサポート、より多くの種類のオブジェクトの
     pickle 化、および一部のデータ形式の最適化が行われました。これは
     Python 3.8からのデフォルトプロトコルです。プロトコル 4 による改良に
     関する情報は PEP 3154(2) を参照してください。

   * プロトコルバージョン 5 は Python 3.8 で追加されました。このバージョ
     ンでは帯域外データのサポートが追加され、また帯域内データに対するパ
     フォーマンスが向上します。プロトコルバージョン 5 によってもたらされ
     る改善についての情報は PEP 574(3) を参照してください。

     注釈: 直列化は永続性より原始的な概念です。 *note pickle: 95. はファ
     イルオブジェクトの読み書きを行いますが、永続オブジェクトの命名に関
     する問題にも、(さらに困難な) 永続オブジェクトへの並列アクセスに関す
     る問題にも対応しません。*note pickle: 95. モジュールは複雑なオブジ
     ェクトをバイトストリームに変換し、バイトストリームから同じ内部構造
     のオブジェクトに復元することができます。これらのバイトストリームは
     ファイルに出力されることが多いでしょうが、ネットワークを介して送信
     したり、データベースに格納することもありえます。*note shelve: b1. モ
     ジュールは、オブジェクトを DBM 方式のデータベースファイル上で
     pickle 化および非 pickle 化するシンプルなインターフェースを提供しま
     す。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0307/

   (2) https://peps.python.org/pep-3154/

   (3) https://peps.python.org/pep-0574/


File: python.info,  Node: モジュールインターフェース,  Next: pickle 化、非 pickle 化できるもの,  Prev: データストリームの形式,  Up: pickle --- Python オブジェクトの直列化

5.12.1.5 モジュールインターフェース
...................................

オブジェクト階層を直列化するには、*note dumps(): 1447. 関数を呼ぶだけで
す。同様に、データストリームを復元するには、*note loads(): cdf. 関数を呼
びます。しかし、直列化および復元に対してより多くのコントロールを行いたい
場合、それぞれ *note Pickler: 9ec. または *note Unpickler: 160b. オブジ
ェクトを作成することができます。

*note pickle: 95. モジュールは以下の定数を提供しています:

 -- データ: pickle.HIGHEST_PROTOCOL

     利用可能なうち最も高い *note プロトコルバージョン: c8f. (整数)。こ
     の値は 'protocol' 値として関数 *note dump(): 27e2. および *note
     dumps(): 1447. と、*note Pickler: 9ec. コンストラクターに渡すことが
     できます。

 -- データ: pickle.DEFAULT_PROTOCOL

     pickle化に使われるデフォルトの *note プロトコルバージョン: c8f. (整
     数)。‘HIGHEST_PROTOCOL’ よりも小さい場合があります。現在のデフォル
     トプロトコルは4です。このプロトコルはPython3.4で初めて導入され、そ
     の前のバージョンとは互換性がありません。

     バージョン 3.0 で変更: デフォルトプロトコルは 3 です。

     バージョン 3.8 で変更: デフォルトプロトコルは 4 です。

この pickle 化の手続きを便利にするために、 *note pickle: 95. モジュール
では以下の関数を提供しています:

 -- の関数: pickle.dump (obj, file, protocol=None, *, fix_imports=True,
          buffer_callback=None)

     オブジェクト 'obj' を pickle 化し、すでにオープンしている *note
     ファイルオブジェクト: 1193. 'file' に書き込みます。‘Pickler(file,
     protocol).dump(obj)’ と等価です。

     引数 'file', 'protocol', 'fix_imports' および 'buffer_callback' は
     *note Pickler: 9ec. のコンストラクタと同じ意味になります。

     バージョン 3.8 で変更: 'buffer_callback' 引数が追加されました。

 -- の関数: pickle.dumps (obj, protocol=None, *, fix_imports=True,
          buffer_callback=None)

     ファイルに書く代わりに、*note bytes: 1a4. オブジェクトとしてオブジ
     ェクト 'obj' の pickle 表現を返します。

     引数 'protocol', 'fix_imports' および 'buffer_callback' は *note
     Pickler: 9ec. のコンストラクタと同じ意味になります。

     バージョン 3.8 で変更: 'buffer_callback' 引数が追加されました。

 -- の関数: pickle.load (file, *, fix_imports=True, encoding='ASCII',
          errors='strict', buffers=None)

     あるオブジェクトの pickle 化表現を、オープンしている *note
     ファイルオブジェクト: 1193. 'file' から読み込み、その中で指定されて
     いるオブジェクト階層に再構成して返します。これは
     ‘Unpickler(file).load()’ と等価です。

     pickle のプロトコルバージョンは自動的に検出されます。したがって
     protocol 引数は必要ありません。pickle 化オブジェクト表現より後のバ
     イト列は無視されます。

     引数 'file', 'fix_imports', 'encoding', 'errors', 'strict' および
     'buffers' は *note Unpickler: 160b. のコンストラクタと同じ意味にな
     ります。

     バージョン 3.8 で変更: 'buffers' 引数が追加されました。

 -- の関数: pickle.loads (data, /, *, fix_imports=True,
          encoding='ASCII', errors='strict', buffers=None)

     オブジェクトのピックル化表現 'data' から再構成されたオブジェクト階
     層を返します。 'data' は バイトライクオブジェクト (*note bytes-like
     object: cfb.) でなければなりません。

     pickle のプロトコルバージョンは自動的に検出されます。したがって
     protocol 引数は必要ありません。pickle 化オブジェクト表現より後のバ
     イト列は無視されます。

     引数 'fix_imports', 'encoding', 'errors', 'strict' および 'buffers'
     は *note Unpickler: 160b. のコンストラクタと同じ意味になります。

     バージョン 3.8 で変更: 'buffers' 引数が追加されました。

*note pickle: 95. モジュールでは 3 つの例外を定義しています:

 -- 例外: pickle.PickleError

     他の pickle 化例外の共通基底クラス。*note Exception: 9a7. を継承し
     ています。

 -- 例外: pickle.PicklingError

     *note Pickler: 9ec. が pickle 化不可能なオブジェクトに遭遇したとき
     に送出されるエラー。*note PickleError: 27e3. を継承しています。

     どんな種類のオブジェクトが pickle 化できるのか確認するには *note
     pickle 化、非 pickle 化できるもの: 27e5. を参照してください。

 -- 例外: pickle.UnpicklingError

     データ破損やセキュリティ違反のような、オブジェクトを非 pickle 化す
     るのに問題がある場合に送出されるエラー。*note PickleError: 27e3. を
     継承します。

     非 picke 化の最中に他の例外が送出されることもあるので注意してくださ
     い。これには AttributeError, EOFError, ImportError, IndexError が含
     まれます (ただし必ずしもこれらに限定されません)。

*note pickle: 95. モジュールでは、3 つのクラス *note Pickler: 9ec, *note
Unpickler: 160b. および *note PickleBuffer: 1763. を提供しています:

 -- クラス: pickle.Pickler (file, protocol=None, *, fix_imports=True,
          buffer_callback=None)

     pickle 化されたオブジェクトのデータストリームを書き込むためのバイナ
     リファイルを引数にとります。

     任意の引数 'protocol' は、整数で、pickle 化で使用するプロトコルを指
     定します; サポートされているプロトコルは 0 から *note
     HIGHEST_PROTOCOL: 1448. までになります。指定されない場合、*note
     DEFAULT_PROTOCOL: 7f9. が使用されます。負数が与えられた場合、*note
     HIGHEST_PROTOCOL: 1448. が使用されます。

     引数 'file' は、1 バイトの引数一つを受け付ける write() メソッドを持
     たなければなりません。すなわち、'file' には、バイナリの書き込み用に
     オープンされたファイルオブジェクト、*note io.BytesIO: e6d. オブジェ
     クト、このインターフェースに適合するその他のカスタムオブジェクトを
     とることができます。

     'fix_imports' が真であり、かつ、'protocol' が 3 未満の場合、pickle
     は新しい Python 3 の名前と Python 2 で使用されていた古いモジュール
     名との対応付けを試みるので、pickle データストリームは Python 2 でも
     読み込み可能です。

     If 'buffer_callback' is ‘None’ (the default), buffer views are
     serialized into 'file' as part of the pickle stream.

     If 'buffer_callback' is not ‘None’, then it can be called any
     number of times with a buffer view.  If the callback returns a
     false value (such as ‘None’), the given buffer is *note
     out-of-band: 27e7.; otherwise the buffer is serialized in-band,
     i.e.  inside the pickle stream.

     It is an error if 'buffer_callback' is not ‘None’ and 'protocol' is
     ‘None’ or smaller than 5.

     バージョン 3.8 で変更: 'buffer_callback' 引数が追加されました。

      -- メソッド: dump (obj)

          'obj' の pickle 化表現を、コンストラクターで与えられた、すでに
          オープンしているファイルオブジェクトに書き込みます。

      -- メソッド: persistent_id (obj)

          デフォルトでは何もしません。このメソッドはサブクラスがオーバー
          ライドできるように存在します。

          *note persistent_id(): 1506. が ‘None’ を返す場合、通常通り
          'obj' が pickle 化されます。それ以外の値を返した場合、*note
          Pickler: 9ec. がその値を 'obj' のために永続的な ID として出力
          するようになります。この永続的な ID の意味は *note
          Unpickler.persistent_load(): 150c. によって定義されています。
          *note persistent_id(): 1506. によって返された値自身は永続的な
          ID を持つことができないことに注意してください。

          詳細および使用例については *note 外部オブジェクトの永続化:
          27e8. を参照してください。

          バージョン 3.13 で変更: Add the default implementation of this
          method in the C implementation of ‘Pickler’.

      -- の属性: dispatch_table

          pickler オブジェクトのディスパッチテーブルは *note
          copyreg.pickle(): 27e9. を使用して宣言できる種類の 'reduction
          functions' のレジストリです。これはキーがクラスでその値が減少
          関数のマッピング型オブジェクトです。減少関数は関連するクラスの
          引数を 1 個とり、*note __reduce__(): 9a1. メソッドと同じインタ
          ーフェースでなければなりません。

          デフォルトでは、pickler オブジェクトは *note dispatch_table:
          10f5. 属性を持たず、代わりに *note copyreg: 1f. モジュールによ
          って管理されるグローバルなディスパッチテーブルを使用します。し
          かし、特定の pickler オブジェクトによる pickle 化をカスタマイ
          ズするために *note dispatch_table: 10f5. 属性に dict-like オブ
          ジェクトを設定することができます。あるいは、*note Pickler:
          9ec. のサブクラスが *note dispatch_table: 10f5. 属性を持てば、
          そのクラスのインスタンスに対するデフォルトのディスパッチテーブ
          ルとして使用されます。

          使用例については *note ディスパッチテーブル: 27ea. を参照して
          ください。

          Added in version 3.3.

      -- メソッド: reducer_override (obj)

          *note Pickler: 9ec. のサブクラスで定義可能な特殊なリデューサ
          (reducer) です。このメソッドは *note dispatch_table: 10f5. 内
          のいかなるリデューサよりも優先されます。このメソッドは *note
          __reduce__(): 9a1. メソッドのインターフェースと適合していなけ
          ればなりません。また、メソッドが *note NotImplemented: 79d. を
          返すことにより、 *note dispatch_table: 10f5. に登録されたリデ
          ューサにフォールバックして ‘obj’ を直列化することもできます。

          詳細な例については、 *note
          型、関数、その他のオブジェクトに対するリダクションのカスタマイズ:
          27eb. を参照してください。

          Added in version 3.8.

      -- の属性: fast

          廃止予定です。真値が設定されれば高速モードを有効にします。高速
          モードは、メモの使用を無効にします。それにより余分な PUT 命令
          コードを生成しなくなるので pickle 化処理が高速化します。自己参
          照オブジェクトに対しては使用すべきではありません。さもなければ
          *note Pickler: 9ec. に無限再帰を起こさせるでしょう。

          よりコンパクトな pickle 化を必要とする場合は、*note
          pickletools.optimize(): 27ed. を使用してください。

 -- クラス: pickle.Unpickler (file, *, fix_imports=True,
          encoding='ASCII', errors='strict', buffers=None)

     これは pickle データストリームの読み込みのためにバイナリファイルを
     とります。

     pickle のプロトコルバージョンは自動的に検出されます。したがって
     protocol 引数は必要ありません。

     引数 'file' は *note io.BufferedIOBase: 660. のインターフェースと同
     様に、整数を引数にとる read() 、バッファを引数にとる readinto() 、
     引数を取らない readline() の3つのメソッドを持たなければなりません。
     したがって、 'file' はバイナリ読み込みモードでオープンされたディス
     ク上のファイル、 *note io.BytesIO: e6d. オブジェクト、または上記イ
     ンターフェース要件を満たす任意のカスタムオブジェクトのいずれかです
     。

     オプション引数 'fix_imports', 'encoding' および 'errors' はPython
     2で生成された pickle ストリームに対する互換性サポートを制御するため
     に使われます。 'fix_imports' が真の場合、 pickle は古い Python 2 の
     名前を Python 3 の新しい名前に対応づけようとします。 'encoding' と
     'errors' は pickle に Python 2 で pickle 化された 8 ビット文字列を
     デコードする方法を指定します; これらの引数のデフォルト値はそれぞれ
     'ASCII' と 'strict' です。 'encoding' は 8 ビット文字列インスタンス
     をバイトオブジェクトとして読み込む場合は 'bytes' を指定します。
     Python 2 で pickle 化された NumPy 配列および *note datetime: 1ae,
     *note date: 1af, *note time: 1b0. の各インスタンスを非 pickle 化す
     るためには ‘encoding='latin1'’ を使う必要があります。

     If 'buffers' is ‘None’ (the default), then all data necessary for
     deserialization must be contained in the pickle stream.  This means
     that the 'buffer_callback' argument was ‘None’ when a *note
     Pickler: 9ec. was instantiated (or when *note dump(): 27e2. or
     *note dumps(): 1447. was called).

     If 'buffers' is not ‘None’, it should be an iterable of
     buffer-enabled objects that is consumed each time the pickle stream
     references an *note out-of-band: 27e7. buffer view.  Such buffers
     have been given in order to the 'buffer_callback' of a Pickler
     object.

     バージョン 3.8 で変更: 'buffers' 引数が追加されました。

      -- メソッド: load ()

          コンストラクターで与えられたオープンしたファイルオブジェクトか
          らオブジェクトの pickle 化表現を読み込み、その中で指定されたオ
          ブジェクト階層に再構成して返します。オブジェクトの pickle 化表
          現より後のバイト列は無視されます。

      -- メソッド: persistent_load (pid)

          デフォルトで *note UnpicklingError: 27e6. を送出します。

          もし定義されていれば、*note persistent_load(): 150c. は永続的
          な ID 'pid' によって指定されたオブジェクトを返す必要があります
          。永続的な ID が無効な場合、*note UnpicklingError: 27e6. を送
          出しなければなりません。

          詳細および使用例については *note 外部オブジェクトの永続化:
          27e8. を参照してください。

          バージョン 3.13 で変更: Add the default implementation of this
          method in the C implementation of ‘Unpickler’.

      -- メソッド: find_class (module, name)

          必要なら 'module' をインポートして、そこから 'name' という名前
          のオブジェクトを返します。ここで 'module' および 'name' 引数は
          *note str: 418. オブジェクトです。その名前が示唆することに反し
          て *note find_class(): 27ef. は関数を探すためにも使われること
          に注意してください。

          サブクラスは、どんな型のオブジェクトを、どのようにロードするか
          (潜在的にはセキュリティリスクの減少) に関する制御を得るために
          これをオーバーライドすることができます。詳細に関しては *note
          グローバル変数を制限する: 27f0. を参照してください。

          引数 ‘modulet’, ‘name’ を指定して *note 監査イベント: 1825.
          ‘pickle.find_class’ を送出します。

 -- クラス: pickle.PickleBuffer (buffer)

     pickle 可能なデータをあらわすバッファのラッパーです。 'buffer' はバ
     ッファライクなオブジェクト (*note bytes-like object: cfb.) や N 次
     元配列のような *note バッファ機能を提供する: 371. オブジェクトでな
     ければなりません。

     *note PickleBuffer: 1763. はそれ自身バッファ機能を提供します。した
     がってこのクラスのインスタンスを、バッファ機能を提供するオブジェク
     トを期待する *note memoryview: 435. など他の API に渡すことが可能で
     す。

     *note PickleBuffer: 1763. オブジェクトはプロトコル 5 以上でのみ直列
     化可能で、 *note アウトオブバウンド (out-of-band) の直列化: 27e7. に
     対応しています。

     Added in version 3.8.

      -- メソッド: raw ()

          このバッファの背後にあるメモリ領域への *note memoryview: 435.
          を返します。戻り値のオブジェクトはフォーマット ‘B’ (符号なしバ
          イト) の C-連続な1次元のメモリビューです。バッファが C-連続で
          も Fortran-連続でもない場合 *note BufferError: 178f. 例外が送
          出されます。

      -- メソッド: release ()

          PickleBuffer オブジェクトを通じてアクセスされる背後のバッファ
          を解放します。


File: python.info,  Node: pickle 化、非 pickle 化できるもの,  Next: クラスインスタンスの pickle 化,  Prev: モジュールインターフェース,  Up: pickle --- Python オブジェクトの直列化

5.12.1.6 pickle 化、非 pickle 化できるもの
..........................................

以下の型は pickle 化できます:

   * 組み込み定数(‘None’, ‘True’, ‘False’, ‘Ellipsis’, と *note
     NotImplemented: 79d.)

   * 整数、浮動小数点数、複素数

   * 文字列、バイト列、バイト配列

   * pickle 化可能なオブジェクトからなるタプル、リスト、集合および辞書

   * モジュールのトップレベルで定義された関数 (*note def: 13ff. で定義さ
     れたもののみで *note lambda: 126d. で定義されたものは含まない)

   * モジュールのトップレベルで定義されているクラス

   * *note __getstate__(): 5a2. メソッドを呼び出した結果が pickle 化可能
     であるようなクラスのインスタンス (詳細は *note クラスインスタンスの
     pickle 化: 27dd. を参照)。

pickle 化できないオブジェクトを pickle 化しようとすると、*note
PicklingError: 27e4. 例外が送出されます。この例外が起きたとき、すでに元
のファイルには未知の長さのバイト列が書き込まれている場合があります。極端
に再帰的なデータ構造を pickle 化しようとした場合には再帰の深さ制限を越え
てしまうかもしれず、この場合には *note RecursionError: d39. が送出されま
す。この制限は、*note sys.setrecursionlimit(): 48f. で慎重に上げていくこ
とは可能です。

関数 (組込みおよびユーザー定義) は、値ではなく、完全 *note 修飾名: 18ab.
で pickle 化されます。(1) これは、関数名のみがそれを含んでいるモジュール
およびクラスの名前をともなって pickle 化されることを意味します。関数のコ
ードやその属性は pickle 化されません。すなわち、非 pickle 化する環境で定
義したモジュールがインポート可能な状態になっており、そのモジュール内に関
数名のオブジェクトが含まれていなければなりません。この条件を満たさなかっ
た場合は例外が送出されます。(2)

クラスも同様に完全修飾名で pickle 化されるので、unpickle 化環境には同じ
制限が課せられます。クラス中のコードやデータは何も pickle 化されないので
、以下の例ではクラス属性 ‘attr’ が unpickle 化環境で復元されないことに注
意してください:

     class Foo:
         attr = 'A class attribute'

     picklestring = pickle.dumps(Foo)

pickle 化可能な関数やクラスがモジュールのトップレベルで定義されていなけ
ればならないのはこれらの制限のためです。

同様に、クラスのインスタンスが pickle 化された際、そのクラスのコードおよ
びデータはオブジェクトと一緒に pickle 化されることはありません。インスタ
ンスのデータのみが pickle 化されます。この仕様は、クラス内のバグを修正し
たりメソッドを追加した後でも、そのクラスの以前のバージョンで作られたオブ
ジェクトを読み出せるように意図的に行われています。あるクラスの多くのバー
ジョンで使われるような長命なオブジェクトを作ろうと計画しているなら、その
クラスの *note __setstate__(): 1449. メソッドによって適切な変換が行われ
るようにオブジェクトのバージョン番号を入れておくとよいかもしれません。

   ---------- Footnotes ----------

   (1) なぜ *note lambda: 126d. 関数を pickle 化できないかというと、すべ
ての ‘lambda’ 関数は同じ名前: ‘<lambda>’ を共有しているからです。

   (2) 送出される例外は *note ImportError: 3f2. や *note AttributeError:
326. になるはずですが、他の例外も起こりえます。


File: python.info,  Node: クラスインスタンスの pickle 化,  Next: 型、関数、その他のオブジェクトに対するリダクションのカスタマイズ,  Prev: pickle 化、非 pickle 化できるもの,  Up: pickle --- Python オブジェクトの直列化

5.12.1.7 クラスインスタンスの pickle 化
.......................................

この節では、クラスインスタンスがどのように pickle 化または非 pickle 化さ
れるのかを定義したり、カスタマイズしたり、コントロールしたりするのに利用
可能な一般的機構について説明します。

ほとんどの場合、インスタンスを pickle 化できるようにするために追加のコー
ドは必要ありません。デフォルトで、pickle はインスタンスのクラスと属性を
内省によって検索します。クラスインスタンスが非 pickle 化される場合、通常
その *note __init__(): 67c. メソッドは実行 'されません' 。デフォルトの振
る舞いは、最初に初期化されていないインスタンスを作成して、次に保存された
属性を復元します。次のコードはこの振る舞いの実装を示しています:

     def save(obj):
         return (obj.__class__, obj.__dict__)

     def restore(cls, attributes):
         obj = cls.__new__(cls)
         obj.__dict__.update(attributes)
         return obj

クラスは、いくつかの特殊メソッドを提供することによって、デフォルトの振る
舞いを変更することができます:

 -- メソッド: object.__getnewargs_ex__ ()

     プロトコル 2 以上の場合、 *note __getnewargs_ex__(): 27f5. メソッド
     を実装したクラスは *note __new__(): 54c. メソッドに渡された値の非
     pickle 化の方法を指示することができます。このメソッドは、オブジェク
     トの生成に必要な位置引数のタプル 'args' と名前付き引数の辞書
     'kwargs' のペア ‘(args, kwargs)’ を返さなければなりません。これらは
     非 pickle 化に際して *note __new__(): 54c. メソッドに渡されます。

     クラスの *note __new__(): 54c. メソッドがキーワード専用引数を求める
     場合はこのメソッドを実装すべきです。 そうしない場合、互換性のため
     *note __getnewargs__(): 144a. メソッドの実装を推奨します。

     バージョン 3.6 で変更: *note __getnewargs_ex__(): 27f5. がプロトコ
     ル 2 と 3 でも使われるようになりました。

 -- メソッド: object.__getnewargs__ ()

     このメソッドは *note __getnewargs_ex__(): 27f5. と同じような機能を
     提供しますが、位置引数のみをサポートします。このメソッドは引数のタ
     プル ‘args’ を返さなければならず、戻り値は非 pickle 化に際して
     *note __new__(): 54c. メソッドに渡されます。

     *note __getnewargs_ex__(): 27f5. が定義されていると *note
     __getnewargs__(): 144a. は呼び出しません。

     バージョン 3.6 で変更: Python 3.6以前のプロトコル 2 と 3 では、
     *note __getnewargs_ex__(): 27f5. の代わりに *note __getnewargs__():
     144a. が呼び出されていました。

 -- メソッド: object.__getstate__ ()

     Classes can further influence how their instances are pickled by
     overriding the method *note __getstate__(): 5a2.  It is called and
     the returned object is pickled as the contents for the instance,
     instead of a default state.  There are several cases:

        * For a class that has no instance *note __dict__: 526. and no
          *note __slots__: 1493, the default state is ‘None’.

        * For a class that has an instance *note __dict__: 526. and no
          *note __slots__: 1493, the default state is ‘self.__dict__’.

        * For a class that has an instance *note __dict__: 526. and
          *note __slots__: 1493, the default state is a tuple consisting
          of two dictionaries: ‘self.__dict__’, and a dictionary mapping
          slot names to slot values.  Only slots that have a value are
          included in the latter.

        * For a class that has *note __slots__: 1493. and no instance
          *note __dict__: 526, the default state is a tuple whose first
          item is ‘None’ and whose second item is a dictionary mapping
          slot names to slot values described in the previous bullet.

     バージョン 3.11 で変更: Added the default implementation of the
     ‘__getstate__()’ method in the *note object: a5a. class.

 -- メソッド: object.__setstate__ (state)

     非 pickle 化に際して、クラスが *note __setstate__(): 1449. を定義し
     ている場合、それは非 pickle 化された状態とともに呼び出されます。そ
     の場合、状態オブジェクトが辞書でなければならないという要求はありま
     せん。そうでなければ、 pickle された状態は辞書で、その要素は新しい
     インスタンスの辞書に割り当てられます。

          注釈: If *note __reduce__(): 9a1. returns a state with value
          ‘None’ at pickling, the *note __setstate__(): 1449. method
          will not be called upon unpickling.

*note __getstate__(): 5a2. および *note __setstate__(): 1449. メソッドの
使い方に関する詳細な情報については *note 状態を持つオブジェクトの扱い:
27f6. 節を参照してください。

     注釈: 非 pickle 化に際しては、 *note __getattr__(): 49f, *note
     __getattribute__(): ba0, または *note __setattr__(): 1e8d. といった
     メソッドがインスタンスに対して呼ばれることがあります。これらのメソ
     ッドが何らかの内部の不変な条件が真であることを必要とする場合、その
     型は *note __new__(): 54c. メソッドを実装してそのような不変な条件を
     構築すべきです。なぜならばインスタンスの非 pickle 化においては
     *note __init__(): 67c. メソッドは呼ばれないからです。

これらから見るように、pickle は上記のメソッドを直接使用しません。実際に
は、これらのメソッドは *note __reduce__(): 9a1. 特殊メソッドを実装するコ
ピープロトコルの一部です。コピープロトコルは、pickle 化とオブジェクトの
コピーに必要な、データを取得するための統一されたインターフェースを提供し
ます。 (1)

強力ですが、クラスに *note __reduce__(): 9a1. メソッドを直接実装すること
はエラーを起こしやすくなります。この理由のため、クラスの設計者は可能なか
ぎり高レベルインターフェース (*note __getnewargs_ex__(): 27f5.、*note
__getstate__(): 5a2. および *note __setstate__(): 1449.) を使用するべき
です。公開はしているものの、‘__reduce__()’ の使用は、あくまでオプション
として、より効果的な pickle 化につながる場合、あるいはその両方の場合のみ
にしてください。

 -- メソッド: object.__reduce__ ()

     このインターフェースは現在、以下のように定義されています。 *note
     __reduce__(): 9a1. メソッドは引数を取らず、文字列あるいは (こちらの
     方が好まれますが) タプルのいずれかを返すべきです (返されたオブジェ
     クトは、しばしば "reduce value" と呼ばれます)。

     文字列が返された場合、その文字列はグローバル変数の名前として解釈さ
     れます。それはオブジェクトのモジュールから見たローカル名であるべき
     です; pickle モジュールは、オブジェクトのモジュールを決定するために
     モジュールの名前空間を検索します。この振る舞いは、典型的にシングル
     トンで便利です。

     タプルが返された場合、それは 2〜6 要素長でなければなりません。オプ
     ションのアイテムは省略することができます。あるいはそれらの値として
     ‘None’ を渡すことができます。各要素の意味は順に:

        * オブジェクトの初期バージョンを作成するために呼ばれる呼び出し可
          能オブジェクト。

        * 呼出し可能オブジェクトに対する引数のタプル。呼出し可能オブジェ
          クトが引数を受け取らない場合、空のタプルが与えられなければなり
          ません。

        * 任意で、前述のオブジェクトの *note __setstate__(): 1449. メソ
          ッドに渡されるオブジェクトの状態。オブジェクトがそのようなメソ
          ッドを持たない場合、値は辞書でなければならず、それはオブジェク
          トの *note __dict__: 526. 属性に追加されます。

        * 任意で、連続した要素を yield する (シーケンスではなく) イテレ
          ーター。これらの要素は ‘obj.append(item)’ を使用して、あるいは
          バッチでは ‘obj.extend(list_of_items)’ を使用して、オブジェク
          トに追加されます。これは主としてリストのサブクラスに対して使用
          されますが、適切なシグネチャを持つ *note append と extend
          メソッド: 210e. があるかぎり、他のクラスで使用することもできま
          す。 (‘append()’ または ‘extend()’ のどちらが使用されるかは、
          どの pickle プロトコルバージョンが使われるかに加えて追加される
          アイテムの数にも依存します。したがって、両方をサポートする必要
          があります)

        * 任意で、連続する key-value ペアを yield する (シーケンスでなく
          ) イテレーター。これらの要素は ‘obj[key] = value’ を使用して、
          オブジェクトに格納されます。これは主として辞書のサブクラスに対
          して使用されますが、*note __setitem__(): 146e. を実装している
          かぎり他のクラスで使用することもできます。

        * 任意で、シグネチャが ‘(obj, state)’ である呼び出し可能オブジェ
          クト。このオブジェクトは、 ‘obj’ のスタティックな *note
          __setstate__(): 1449. メソッドの代わりに、ユーザーがオブジェク
          トの状態を更新する方法をプログラム的に制御することを許します。
          ‘None’ 以外の場合、この呼び出し可能オブジェクトは ‘obj’ の
          *note __setstate__(): 1449. メソッドに優先します。

          Added in version 3.8: 任意の6番目のタプル要素 ‘(obj, state)’ が
          追加されました。

 -- メソッド: object.__reduce_ex__ (protocol)

     別の方法として、*note __reduce_ex__(): 151b. メソッドを定義すること
     もできます。唯一の違いは、このメソッドは単一の整数引数、プロトコル
     バージョンを取る必要があるということです。もし定義された場合、
     pickle は *note __reduce__(): 9a1. メソッドよりもこのメソッドを優先
     します。さらに、*note __reduce__(): 9a1. は自動的に拡張版の同義語に
     なります。このメソッドの主な用途は、古い Python リリースに対して後
     方互換性のある reduce value を提供することです。

* Menu:

* 外部オブジェクトの永続化::
* ディスパッチテーブル::
* 状態を持つオブジェクトの扱い::

   ---------- Footnotes ----------

   (1) *note copy: 1e. モジュールは、浅いコピーと深いコピーの操作にこの
プロトコルを使用します。


File: python.info,  Node: 外部オブジェクトの永続化,  Next: ディスパッチテーブル,  Up: クラスインスタンスの pickle 化

5.12.1.8 外部オブジェクトの永続化
.................................

オブジェクトの永続化のために、*note pickle: 95. モジュールは、pickle デ
ータストリーム外のオブジェクトに対する参照の概念をサポートしています。そ
のようなオブジェクトは永続的 ID によって参照されます。それは、英数文字の
文字列 (プロトコル 0 に対して) (1) あるいは単に任意のオブジェクト (より
新しい任意のプロトコルに対して) のいずれかです。

そのような永続的 ID の分解能は *note pickle: 95. モジュールでは定義され
ていません; これはこの分解能を pickler および unpickler のそれぞれ *note
persistent_id(): 1506. および *note persistent_load(): 150c. 上でのユー
ザー定義メソッドに移譲します。

外部の永続的 ID を持つ pickle オブジェクトの pickler は、引数にオブジェ
クトを取り、‘None’ かオブジェクトの永続的 ID を返すカスタム *note
persistent_id(): 1506. メソッドを持たなくてはなりません。‘None’ を返す場
合、pickler は通常通りマーカーとともにオブジェクトを pickle 化するため、
unpickler はそれを永続的 ID として認識します。

外部オブジェクトを非 pickle 化するには、unpickler は永続的 ID オブジェク
トを取り被参照オブジェクトを返すカスタム *note persistent_load(): 150c.
メソッドを持たなくてはなりません。

これは、外部のオブジェクトを参照によって pickle 化するために永続的 ID を
どのように使用するかを示す包括的な例です。

     # Simple example presenting how persistent ID can be used to pickle
     # external objects by reference.

     import pickle
     import sqlite3
     from collections import namedtuple

     # Simple class representing a record in our database.
     MemoRecord = namedtuple("MemoRecord", "key, task")

     class DBPickler(pickle.Pickler):

         def persistent_id(self, obj):
             # Instead of pickling MemoRecord as a regular class instance, we emit a
             # persistent ID.
             if isinstance(obj, MemoRecord):
                 # Here, our persistent ID is simply a tuple, containing a tag and a
                 # key, which refers to a specific record in the database.
                 return ("MemoRecord", obj.key)
             else:
                 # If obj does not have a persistent ID, return None. This means obj
                 # needs to be pickled as usual.
                 return None


     class DBUnpickler(pickle.Unpickler):

         def __init__(self, file, connection):
             super().__init__(file)
             self.connection = connection

         def persistent_load(self, pid):
             # This method is invoked whenever a persistent ID is encountered.
             # Here, pid is the tuple returned by DBPickler.
             cursor = self.connection.cursor()
             type_tag, key_id = pid
             if type_tag == "MemoRecord":
                 # Fetch the referenced record from the database and return it.
                 cursor.execute("SELECT * FROM memos WHERE key=?", (str(key_id),))
                 key, task = cursor.fetchone()
                 return MemoRecord(key, task)
             else:
                 # Always raises an error if you cannot return the correct object.
                 # Otherwise, the unpickler will think None is the object referenced
                 # by the persistent ID.
                 raise pickle.UnpicklingError("unsupported persistent object")


     def main():
         import io
         import pprint

         # Initialize and populate our database.
         conn = sqlite3.connect(":memory:")
         cursor = conn.cursor()
         cursor.execute("CREATE TABLE memos(key INTEGER PRIMARY KEY, task TEXT)")
         tasks = (
             'give food to fish',
             'prepare group meeting',
             'fight with a zebra',
             )
         for task in tasks:
             cursor.execute("INSERT INTO memos VALUES(NULL, ?)", (task,))

         # Fetch the records to be pickled.
         cursor.execute("SELECT * FROM memos")
         memos = [MemoRecord(key, task) for key, task in cursor]
         # Save the records using our custom DBPickler.
         file = io.BytesIO()
         DBPickler(file).dump(memos)

         print("Pickled records:")
         pprint.pprint(memos)

         # Update a record, just for good measure.
         cursor.execute("UPDATE memos SET task='learn italian' WHERE key=1")

         # Load the records from the pickle data stream.
         file.seek(0)
         memos = DBUnpickler(file, conn).load()

         print("Unpickled records:")
         pprint.pprint(memos)


     if __name__ == '__main__':
         main()

   ---------- Footnotes ----------

   (1) 英数文字に関する制限は、プロトコル 0 では永続的な ID が改行文字に
よって区切られるという事実によります。そのため、永続的な ID に何らかの改
行文字が含まれると、結果として生じる pickle 化されたデータは判読不能にな
ります。


File: python.info,  Node: ディスパッチテーブル,  Next: 状態を持つオブジェクトの扱い,  Prev: 外部オブジェクトの永続化,  Up: クラスインスタンスの pickle 化

5.12.1.9 ディスパッチテーブル
.............................

pickle 化に依存する他のコードの邪魔をせずに、一部のクラスの pickle 化だ
けをカスタマイズしたい場合、プライベートのディスパッチテーブルを持つ
pickler を作成することができます。

*note copyreg: 1f. モジュールによって管理されるグローバルなディスパッチ
テーブルは ‘copyreg.dispatch_table’ として利用可能です。したがって、
‘copyreg.dispatch_table’ の修正済のコピーをプライベートのディスパッチテ
ーブルとして使用することを選択できます。

例えば

     f = io.BytesIO()
     p = pickle.Pickler(f)
     p.dispatch_table = copyreg.dispatch_table.copy()
     p.dispatch_table[SomeClass] = reduce_SomeClass

これは ‘SomeClass’ クラスを特別に扱うプライベートのディスパッチテーブル
を持つ *note pickle.Pickler: 9ec. のインスタンスを作成します。あるいは、
次のコード

     class MyPickler(pickle.Pickler):
         dispatch_table = copyreg.dispatch_table.copy()
         dispatch_table[SomeClass] = reduce_SomeClass
     f = io.BytesIO()
     p = MyPickler(f)

does the same but all instances of ‘MyPickler’ will by default share the
private dispatch table.  On the other hand, the code

     copyreg.pickle(SomeClass, reduce_SomeClass)
     f = io.BytesIO()
     p = pickle.Pickler(f)

modifies the global dispatch table shared by all users of the *note
copyreg: 1f. module.


File: python.info,  Node: 状態を持つオブジェクトの扱い,  Prev: ディスパッチテーブル,  Up: クラスインスタンスの pickle 化

5.12.1.10 状態を持つオブジェクトの扱い
......................................

Here's an example that shows how to modify pickling behavior for a
class.  The ‘TextReader’ class below opens a text file, and returns the
line number and line contents each time its ‘readline()’ method is
called.  If a ‘TextReader’ instance is pickled, all attributes 'except'
the file object member are saved.  When the instance is unpickled, the
file is reopened, and reading resumes from the last location.  The
‘__setstate__()’ and ‘__getstate__()’ methods are used to implement this
behavior.

     class TextReader:
         """Print and number lines in a text file."""

         def __init__(self, filename):
             self.filename = filename
             self.file = open(filename)
             self.lineno = 0

         def readline(self):
             self.lineno += 1
             line = self.file.readline()
             if not line:
                 return None
             if line.endswith('\n'):
                 line = line[:-1]
             return "%i: %s" % (self.lineno, line)

         def __getstate__(self):
             # Copy the object's state from self.__dict__ which contains
             # all our instance attributes. Always use the dict.copy()
             # method to avoid modifying the original state.
             state = self.__dict__.copy()
             # Remove the unpicklable entries.
             del state['file']
             return state

         def __setstate__(self, state):
             # Restore instance attributes (i.e., filename and lineno).
             self.__dict__.update(state)
             # Restore the previously opened file's state. To do so, we need to
             # reopen it and read from it until the line count is restored.
             file = open(self.filename)
             for _ in range(self.lineno):
                 file.readline()
             # Finally, save the file.
             self.file = file

使用例は以下のようになるでしょう:

     >>> reader = TextReader("hello.txt")
     >>> reader.readline()
     '1: Hello world!'
     >>> reader.readline()
     '2: I am line number two.'
     >>> new_reader = pickle.loads(pickle.dumps(reader))
     >>> new_reader.readline()
     '3: Goodbye!'


File: python.info,  Node: 型、関数、その他のオブジェクトに対するリダクションのカスタマイズ,  Next: アウトオブバウンドバッファ,  Prev: クラスインスタンスの pickle 化,  Up: pickle --- Python オブジェクトの直列化

5.12.1.11 型、関数、その他のオブジェクトに対するリダクションのカスタマイズ
..........................................................................

Added in version 3.8.

*note dispatch_table: 10f5. は、ときにその柔軟性が十分でないがことありま
す。特に、オブジェクトの型以外の別の条件で pickle 化をカスタマイズしたい
場合や、関数やクラスを使って pickle 化をカスタマイズしたい場合などです。

そのような場合、 *note Pickler: 9ec. クラスから派生したサブクラスで
*note reducer_override(): 9ed. メソッドを実装することができます。このメ
ソッドは任意のリダクション用タプルを返すことができます (*note
__reduce__(): 9a1. を参照してください)。もしくは、従来の振る舞いにフォー
ルバックするために *note NotImplemented: 79d. を返すこともできます。

*note dispatch_table: 10f5. と *note reducer_override(): 9ed. の両方が定
義されている場合、 *note reducer_override(): 9ed. メソッドが優先されます
。

     注釈: パフォーマンス上の理由により、次に挙げるオブジェクトに対して
     は *note reducer_override(): 9ed. が呼ばれないことがあります:
     ‘None’, ‘True’, ‘False’, および *note int: 238, *note float: 2ce,
     *note bytes: 1a4, *note str: 418, *note dict: 237, *note set: 5a3,
     *note frozenset: 5a4, *note list: 5dc, *note tuple: 349. の厳密なイ
     ンスタンス。

以下は特定のクラスを pickle 化して再構成する単純な例です:

     import io
     import pickle

     class MyClass:
         my_attribute = 1

     class MyPickler(pickle.Pickler):
         def reducer_override(self, obj):
             """Custom reducer for MyClass."""
             if getattr(obj, "__name__", None) == "MyClass":
                 return type, (obj.__name__, obj.__bases__,
                               {'my_attribute': obj.my_attribute})
             else:
                 # For any other object, fallback to usual reduction
                 return NotImplemented

     f = io.BytesIO()
     p = MyPickler(f)
     p.dump(MyClass)

     del MyClass

     unpickled_class = pickle.loads(f.getvalue())

     assert isinstance(unpickled_class, type)
     assert unpickled_class.__name__ == "MyClass"
     assert unpickled_class.my_attribute == 1


File: python.info,  Node: アウトオブバウンドバッファ,  Next: グローバル変数を制限する,  Prev: 型、関数、その他のオブジェクトに対するリダクションのカスタマイズ,  Up: pickle --- Python オブジェクトの直列化

5.12.1.12 アウトオブバウンドバッファ
....................................

Added in version 3.8.

ある状況では、 *note pickle: 95. モジュールは大量のデータを転送するため
に使われます。 そのため、メモリのコピーを最小限に抑えてパフォーマンスと
リソースの消費を良好な状態に保つことが重要になることがあります。 しかし
、オブジェクトのグラフ的構造をシーケンシャルなバイトストリームに変換する
*note pickle: 95. モジュールの通常の処理は、本質的に pickle ストリームへ
の、または pickle ストリームからのデータのコピーを伴います。

この制約は、生産者 'provider' (変換されるオブジェクトの型の実装) と消費
者 'consumer' (通信システムの実装) が pickle プロトコル5以上で提供される
アウトオブバウンドのデータ転送機能をサポートしていれば回避できます。

* Menu:

* 生産者 API::
* 消費者 API::
* 使用例: 使用例<10>.


File: python.info,  Node: 生産者 API,  Next: 消費者 API,  Up: アウトオブバウンドバッファ

5.12.1.13 生産者 API
....................

pickle 化される大きなサイズのデータオブジェクトは、プロトコル5以上でサポ
ートされた *note __reduce_ex__(): 151b. メソッドを実装しなければなりませ
ん。このメソッドは大きなデータに対して (*note bytes: 1a4. オブジェクトな
どの代わりに) *note PickleBuffer: 1763. インスタンスを返します。

*note PickleBuffer: 1763. オブジェクトは背後にあるバッファがアウトオブバ
ウンドのデータ転送に適合していることを '知らせます' 。これらのオブジェク
トは *note pickle: 95. モジュールの通常の使い方との互換性を保っています
。しかし、消費者側で *note pickle: 95. モジュールに対してそれらのバッフ
ァを自身で処理することを事前に知らせることもできます。


File: python.info,  Node: 消費者 API,  Next: 使用例<10>,  Prev: 生産者 API,  Up: アウトオブバウンドバッファ

5.12.1.14 消費者 API
....................

通信システムは、オブジェクトグラフを直列化するときに生成された *note
PickleBuffer: 1763. オブジェクトのカスタマイズされた処理を有効化すること
ができます。

送信側は 'buffer_callback' 引数を *note Pickler: 9ec. (または *note
dump(): 27e2. や *note dumps(): 1447. 関数) に渡す必要があります。この関
数はオブジェクトグラフを pickle 化するときに生成されるそれぞれの *note
PickleBuffer: 1763. を引数として呼ばれます。 'buffer_callback' によって
蓄積されたバッファは、それが保持するデータのコピーを pickle ストリームに
送らず、軽量なマーカーが挿入されるだけです。

受信側は 'buffers' 引数を *note Unpickler: 160b. (または *note load():
cde. や *note loads(): cdf. 関数) に渡す必要があります。これは
'buffer_callback' に渡されたバッファのイテラブルです。このイテラブルは
'buffer_callback' に渡されたのと同じ順番でバッファを返さなければなりませ
ん。これらのバッファは、pickle 化処理によって *note PickleBuffer: 1763.
オブジェクトを生成したオブジェクトの再構築処理で期待されるデータを提供し
ます。

送信側と受信側の間で、通信システムはアウトオブバウンドバッファの独自の転
送メカニズムを自由に実装することができます。見込みのある最適化としては、
共有メモリの利用や、データタイプ依存のデータ圧縮などが考えられます。


File: python.info,  Node: 使用例<10>,  Prev: 消費者 API,  Up: アウトオブバウンドバッファ

5.12.1.15 使用例
................

以下は、アウトオブバウンドのバッファを使った pickle 処理に関与することが
できるサブクラス *note bytearray: 508. を実装したささいな例です:

     class ZeroCopyByteArray(bytearray):

         def __reduce_ex__(self, protocol):
             if protocol >= 5:
                 return type(self)._reconstruct, (PickleBuffer(self),), None
             else:
                 # PickleBuffer is forbidden with pickle protocols <= 4.
                 return type(self)._reconstruct, (bytearray(self),)

         @classmethod
         def _reconstruct(cls, obj):
             with memoryview(obj) as m:
                 # Get a handle over the original buffer object
                 obj = m.obj
                 if type(obj) is cls:
                     # Original buffer object is a ZeroCopyByteArray, return it
                     # as-is.
                     return obj
                 else:
                     return cls(obj)

再構成関数 (‘_reconstruct’ クラスメソッド) は、受け取ったバッファが持っ
ているオブジェクトを、それが正しい型であれば、そのまま返します。これは、
このおもちゃのような例において、ゼロコピーの挙動を模擬的に行う簡単な方法
です。

消費者側では、これらのオブジェクトを通常の方法で pickle 化することができ
ます。この場合非直列化処理は元のオブジェクトのコピーを返します:

     b = ZeroCopyByteArray(b"abc")
     data = pickle.dumps(b, protocol=5)
     new_b = pickle.loads(data)
     print(b == new_b)  # True
     print(b is new_b)  # False: a copy was made

いっぽう直列化において 'buffer_callback' を設定し、非直列化において蓄積
されたバッファを渡した場合、コピーではなく元のオブジェクトを得ることがで
きます:

     b = ZeroCopyByteArray(b"abc")
     buffers = []
     data = pickle.dumps(b, protocol=5, buffer_callback=buffers.append)
     new_b = pickle.loads(data, buffers=buffers)
     print(b == new_b)  # True
     print(b is new_b)  # True: no copy was made

この例では *note bytearray: 508. がそれ自身メモリを割り当てるという性質
による制限があります: すなわち、他のオブジェクトのメモリを参照する *note
bytearray: 508. を生成することはできません。しかし、 NumPy 配列のような
サードパーティのデータ型ではそのような制限はなく、異なるプロセス間または
異なるシステム間で、ゼロコピー (または最小限のコピー) でのpickle 処理の
利用が可能です。

参考
....

PEP 574(1) - Pickle プロトコルバージョン 5 による帯域外データ

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0574/


File: python.info,  Node: グローバル変数を制限する,  Next: 性能<2>,  Prev: アウトオブバウンドバッファ,  Up: pickle --- Python オブジェクトの直列化

5.12.1.16 グローバル変数を制限する
..................................

デフォルトで、非 pickle 化は pickle データ内で見つけたあらゆるクラスや関
数をインポートします。多くのアプリケーションでは、この振る舞いは受け入れ
られません。なぜなら、それによって unpickler が任意のコードをインポート
して実行することが可能になるからです。この手の巧妙に作られた pickle デー
タストリームがロードされたときに何を行うかをちょっと考えてみてください:

     >>> import pickle
     >>> pickle.loads(b"cos\nsystem\n(S'echo hello world'\ntR.")
     hello world
     0

この例において、unpickler は *note os.system(): 1402. 関数をインポートし
て、次に文字列の引数 "echo hello world" を適用しています。この例は無害で
すが、システムを破壊する例を想像するのは難しくありません。

この理由のため、*note Unpickler.find_class(): 27ef. をカスタマイズするこ
とで非 pickle 化で何を得るかを制御したくなるかもしれません。その名前が示
唆するのと異なり、*note Unpickler.find_class(): 27ef. はグローバル (クラ
スや関数) が必要とした時にはいつでも呼びだされます。したがって、グローバ
ルを完全に禁止することも安全なサブセットに制限することも可能です。

これは、一部の安全なクラスについてのみ *note builtins: e. モジュールから
ロードすることを許可する unpickler の例です:

     import builtins
     import io
     import pickle

     safe_builtins = {
         'range',
         'complex',
         'set',
         'frozenset',
         'slice',
     }

     class RestrictedUnpickler(pickle.Unpickler):

         def find_class(self, module, name):
             # Only allow safe classes from builtins.
             if module == "builtins" and name in safe_builtins:
                 return getattr(builtins, name)
             # Forbid everything else.
             raise pickle.UnpicklingError("global '%s.%s' is forbidden" %
                                          (module, name))

     def restricted_loads(s):
         """Helper function analogous to pickle.loads()."""
         return RestrictedUnpickler(io.BytesIO(s)).load()

この unpickler が働く使用例は次のように意図されます:

     >>> restricted_loads(pickle.dumps([1, 2, range(15)]))
     [1, 2, range(0, 15)]
     >>> restricted_loads(b"cos\nsystem\n(S'echo hello world'\ntR.")
     Traceback (most recent call last):
       ...
     pickle.UnpicklingError: global 'os.system' is forbidden
     >>> restricted_loads(b'cbuiltins\neval\n'
     ...                  b'(S\'getattr(__import__("os"), "system")'
     ...                  b'("echo hello world")\'\ntR.')
     Traceback (most recent call last):
       ...
     pickle.UnpicklingError: global 'builtins.eval' is forbidden

この例が示すように、非 pickle 化を認めるものに注意しなければなりません。
したがって、セキュリティが重要な場合は *note xmlrpc.client: 114. の
marshal API や、サードパーティのソリューションのような別の選択肢を考慮し
た方がよいでしょう。


File: python.info,  Node: 性能<2>,  Next: 使用例<11>,  Prev: グローバル変数を制限する,  Up: pickle --- Python オブジェクトの直列化

5.12.1.17 性能
..............

pickle プロトコルの最近のバージョン (プロトコル 2 以降) は一部の一般的な
機能と組み込みデータ型を効率的にバイナリにエンコードするよう考慮されてい
ます。また、*note pickle: 95. モジュールは C 言語で書かれた透過的オプテ
ィマイザーを持っています。


File: python.info,  Node: 使用例<11>,  Prev: 性能<2>,  Up: pickle --- Python オブジェクトの直列化

5.12.1.18 使用例
................

最も単純なコードでは、*note dump(): 27e2. および *note load(): cde. 関数
を使用してください。

     import pickle

     # An arbitrary collection of objects supported by pickle.
     data = {
         'a': [1, 2.0, 3+4j],
         'b': ("character string", b"byte string"),
         'c': {None, True, False}
     }

     with open('data.pickle', 'wb') as f:
         # Pickle the 'data' dictionary using the highest protocol available.
         pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)

次の例は、pickle 化されたデータを読み込みます。

     import pickle

     with open('data.pickle', 'rb') as f:
         # The protocol version used is detected automatically, so we do not
         # have to specify it.
         data = pickle.load(f)

参考
....

*note copyreg: 1f. モジュール

     拡張型を登録するための Pickle インターフェース構成機構。

*note pickletools: 96. モジュール

     pickle データの処理や分析を行うためのツール。

*note shelve: b1. モジュール

     オブジェクトのインデクス付きデータベース; *note pickle: 95. を使い
     ます。

*note copy: 1e. モジュール

     オブジェクトの浅いコピーおよび深いコピー。

*note marshal: 80. モジュール

     組み込み型の高性能な直列化。

脚注
....


File: python.info,  Node: copyreg --- pickle サポート関数を登録する,  Next: shelve --- Python オブジェクトの永続化,  Prev: pickle --- Python オブジェクトの直列化,  Up: データの永続化

5.12.2 ‘copyreg’ -- ‘pickle’ サポート関数を登録する
---------------------------------------------------

'ソースコード:' Lib/copyreg.py(1)

__________________________________________________________________

*note copyreg: 1f. モジュールは、特定のオブジェクトを pickle する際に使
われる関数を定義する手段を提供します。 *note pickle: 95. モジュールと
*note copy: 1e. モジュールは、オブジェクトを pickle/コピーする場合にそれ
らの関数を使用します。このモジュールは、クラスでないオブジェクトコンスト
ラクタに関する設定情報を提供します。そのようなコンストラクタは、ファクト
リ関数か、クラスインスタンスかもしれません。

 -- の関数: copyreg.constructor (object)

     'object' を有効なコンストラクタであると宣言します。 'object' が呼び
     出し可能でなければ(したがってコンストラクタとして有効でなければ)、
     *note TypeError: 502. を発生します。

 -- の関数: copyreg.pickle (type, function, constructor_ob=None)

     'function' が型 'type' のオブジェクトに対する"リダクション"関数とし
     て使われるように宣言します。 'function' は文字列か、2要素から6要素
     を含んだタプルを返さなければなりません。 'function' のインターフェ
     ースについての詳細は *note dispatch_table: 10f5. を参照してください
     。

     'constructor_ob' は古い機能で、現在は無視されますが、値を渡す場合は
     呼び出し可能 (callable) でなければなりません。

     pickler オブジェクトまたは *note pickle.Pickler: 9ec. のサブクラス
     の *note dispatch_table: 10f5. 属性を、リダクション関数の宣言のため
     に使うこともできるということは覚えておいてください。

* Menu:

* 使用例: 使用例<12>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/copyreg.py


File: python.info,  Node: 使用例<12>,  Up: copyreg --- pickle サポート関数を登録する

5.12.2.1 使用例
...............

下記の例は、pickle 関数を登録する方法と、それがどのように使用されるかを
示そうとしています:

     >>> import copyreg, copy, pickle
     >>> class C:
     ...     def __init__(self, a):
     ...         self.a = a
     ...
     >>> def pickle_c(c):
     ...     print("pickling a C instance...")
     ...     return C, (c.a,)
     ...
     >>> copyreg.pickle(C, pickle_c)
     >>> c = C(1)
     >>> d = copy.copy(c)
     pickling a C instance...
     >>> p = pickle.dumps(c)
     pickling a C instance...


File: python.info,  Node: shelve --- Python オブジェクトの永続化,  Next: marshal --- 内部使用向けの Python オブジェクト直列化,  Prev: copyreg --- pickle サポート関数を登録する,  Up: データの永続化

5.12.3 ‘shelve’ -- Python オブジェクトの永続化
----------------------------------------------

'ソースコード:' Lib/shelve.py(1)

__________________________________________________________________

"シェルフ (shelf, 棚)" は辞書に似た永続性を持つオブジェクトです。 "dbm"
データベースとの違いは、シェルフの値 (キーではありません！) は実質上どん
な Python オブジェクトにも -- *note pickle: 95. モジュールが扱えるなら何
でも -- できるということです。これにはほとんどのクラスインスタンス、再帰
的なデータ型、沢山の共有されたサブオブジェクトを含むオブジェクトが含まれ
ます。キーは通常の文字列です。

 -- の関数: shelve.open (filename, flag='c', protocol=None,
          writeback=False)

     永続的な辞書を開きます。指定された 'filename' は、根底にあるデータ
     ベースの基本ファイル名となります。副作用として、 'filename' には拡
     張子がつけられる場合があり、ひとつ以上のファイルが生成される可能性
     もあります。デフォルトでは、根底にあるデータベースファイルは読み書
     き可能なように開かれます。オプションの 'flag' パラメータは *note
     dbm.open(): ef6. における 'flag' パラメータと同様に解釈されます。

     By default, pickles created with *note pickle.DEFAULT_PROTOCOL:
     7f9. are used to serialize values.  The version of the pickle
     protocol can be specified with the 'protocol' parameter.

     Python の意味論により、シェルフには永続的な辞書の可変エントリがいつ
     変更されたかを知る術がありません。 デフォルトでは、変更されたオブジ
     ェクトはシェルフに代入されたとき 'だけ' 書き込まれます (*note
     使用例: 2809. 参照)。 オプションの 'writeback' パラメータが ‘True’
     に設定されている場合は、アクセスされたすべてのエントリはメモリ上に
     キャッシュされ、 *note sync(): 280a. および *note close(): 280b. を
     呼び出した際に書き戻されます; この機能は永続的な辞書上の可変の要素
     に対する変更を容易にしますが、多数のエントリがアクセスされた場合、
     膨大な量のメモリがキャッシュのために消費され、アクセスされた全ての
     エントリを書き戻す (アクセスされたエントリが可変であるか、あるいは
     実際に変更されたかを決定する方法は存在しないのです) ために、ファイ
     ルを閉じる操作が非常に低速になります。

     バージョン 3.10 で変更: *note pickle.DEFAULT_PROTOCOL: 7f9. is now
     used as the default pickle protocol.

     バージョン 3.11 で変更: Accepts *note path-like object: 280. for
     filename.

          注釈: シェルフが自動的に閉じることに依存しないでください; それ
          がもう必要ない場合は常に *note close(): 280b. を明示的に呼ぶか
          、 *note shelve.open(): 1666. をコンテキストマネージャとして使
          用してください:

               with shelve.open('spam') as db:
                   db['eggs'] = 'eggs'
     警告: *note shelve: b1. モジュールは裏で *note pickle: 95. を使って
     いるので、信頼できないソースからシェルフを読み込むのは危険です。
     pickle と同じく、 shelf の読み込みでも任意のコードを実行できるから
     です。

Shelf objects support most of methods and operations supported by
dictionaries (except copying, constructors and operators ‘|’ and ‘|=’).
This eases the transition from dictionary based scripts to those
requiring persistent storage.

追加でサポートされるメソッドが二つあります:

 -- メソッド: Shelf.sync ()

     シェルフが 'writeback' を *note True: bdb. にセットして開かれている
     場合に、キャッシュ中の全てのエントリを書き戻します。また可能な場合
     は、キャッシュを空にしてディスク上の永続的な辞書を同期します。この
     メソッドはシェルフを *note close(): 280b. によって閉じるとき自動的
     に呼び出されます。

 -- メソッド: Shelf.close ()

     永続的な '辞書' オブジェクトを同期して閉じます。既に閉じられている
     シェルフに対して呼び出すと *note ValueError: 1e3. を出し失敗します
     。

参考
....

Persistent dictionary recipe(2) with widely supported storage formats
and having the speed of native dictionaries.

* Menu:

* 制限事項::
* 使用例: 使用例<13>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/shelve.py

   (2) 
https://code.activestate.com/recipes/576642-persistent-dict-with-multiple-standard-file-format/


File: python.info,  Node: 制限事項,  Next: 使用例<13>,  Up: shelve --- Python オブジェクトの永続化

5.12.3.1 制限事項
.................

   * どのデータベースパッケージが使われるか (例えば *note dbm.ndbm: 2c.
     、 *note dbm.gnu: 2b.) は、どのインターフェースが利用可能かに依存し
     ます。従って、データベースを *note dbm: 29. を使って直接開く方法は
     安全ではありません。データベースはまた、 *note dbm: 29. が使われた
     場合 (不幸なことに) その制約に縛られます -- これはデータベースに記
     録されたオブジェクト (の pickle 化された表現) はかなり小さくなけれ
     ばならず、キー衝突が生じた場合に、稀にデータベースを更新することが
     できなくなることを意味します。

   * *note shelve: b1. モジュールは、シェルフに置かれたオブジェクトの '並
     列した' 読み出し/書き込みアクセスをサポートしません (複数の同時読み
     出しアクセスは安全です)。あるプログラムが書き込みのために開かれたシ
     ェルフを持っているとき、他のプログラムはそのシェルフを読み書きのた
     めに開いてはいけません。この問題を解決するために Unix のファイルロ
     ック機構を使うことができますが、この機構は Unix のバージョン間で異
     なり、使われているデータベースの実装について知識が必要となります。

   * On macOS *note dbm.ndbm: 2c. can silently corrupt the database file
     on updates, which can cause hard crashes when trying to read from
     the database.

 -- クラス: shelve.Shelf (dict, protocol=None, writeback=False,
          keyencoding='utf-8')

     *note collections.abc.MutableMapping: 107e. のサブクラスで、 'dict'
     オブジェクト内にpickle化された値を保持します。

     By default, pickles created with *note pickle.DEFAULT_PROTOCOL:
     7f9. are used to serialize values.  The version of the pickle
     protocol can be specified with the 'protocol' parameter.  See the
     *note pickle: 95. documentation for a discussion of the pickle
     protocols.

     'writeback' パラメータが ‘True’ に設定されていれば、アクセスされた
     すべてのエントリはメモリ上にキャッシュされ、ファイルを閉じる際に
     'dict' に書き戻されます; この機能により、可変のエントリに対して自然
     な操作が可能になりますが、さらに多くのメモリを消費し、辞書をファイ
     ルと同期して閉じる際に長い時間がかかるようになります。

     'keyencoding' パラメータは、shelf の背後にある dict に対して使われ
     る前にキーをエンコードするのに使用されるエンコーディングです。

     *note Shelf: f67. オブジェクトは、コンテキストマネージャとしても使
     用できます。この場合、 *note with: 59c. ブロックが終了する際に、自
     動的に閉じられます。

     バージョン 3.2 で変更: 'keyencoding' パラメータを追加; 以前はキーは
     常に UTF-8 でエンコードされていました。

     バージョン 3.4 で変更: コンテキストマネージャーサポートが追加されま
     した。

     バージョン 3.10 で変更: *note pickle.DEFAULT_PROTOCOL: 7f9. is now
     used as the default pickle protocol.

 -- クラス: shelve.BsdDbShelf (dict, protocol=None, writeback=False,
          keyencoding='utf-8')

     A subclass of *note Shelf: f67. which exposes ‘first()’, ‘next()’,
     ‘previous()’, ‘last()’ and ‘set_location()’ methods.  These are
     available in the third-party ‘bsddb’ module from pybsddb(1) but not
     in other database modules.  The 'dict' object passed to the
     constructor must support those methods.  This is generally
     accomplished by calling one of ‘bsddb.hashopen()’, ‘bsddb.btopen()’
     or ‘bsddb.rnopen()’.  The optional 'protocol', 'writeback', and
     'keyencoding' parameters have the same interpretation as for the
     *note Shelf: f67. class.

 -- クラス: shelve.DbfilenameShelf (filename, flag='c', protocol=None,
          writeback=False)

     *note Shelf: f67. のサブクラスで、辞書に似たオブジェクトの代わりに
     'filename' を受理します。根底にあるファイルは *note dbm.open():
     ef6. を使って開かれます。デフォルトでは、ファイルは読み書き可能な状
     態で開かれます。オプションの 'flag' パラメータは *note open():
     1666. 関数におけるパラメータと同様に解釈されます。オプションの
     'protocol' および 'writeback' パラメータは *note Shelf: f67. クラス
     におけるパラメータと同様に解釈されます。

   ---------- Footnotes ----------

   (1) https://www.jcea.es/programacion/pybsddb.htm


File: python.info,  Node: 使用例<13>,  Prev: 制限事項,  Up: shelve --- Python オブジェクトの永続化

5.12.3.2 使用例
...............

インターフェースは以下のコードに集約されています (‘key’ は文字列で、
‘data’ は任意のオブジェクトです):

     import shelve

     d = shelve.open(filename)  # open -- file may get suffix added by low-level
                                # library

     d[key] = data              # store data at key (overwrites old data if
                                # using an existing key)
     data = d[key]              # retrieve a COPY of data at key (raise KeyError
                                # if no such key)
     del d[key]                 # delete data stored at key (raises KeyError
                                # if no such key)

     flag = key in d            # true if the key exists
     klist = list(d.keys())     # a list of all existing keys (slow!)

     # as d was opened WITHOUT writeback=True, beware:
     d['xx'] = [0, 1, 2]        # this works as expected, but...
     d['xx'].append(3)          # *this doesn't!* -- d['xx'] is STILL [0, 1, 2]!

     # having opened d without writeback=True, you need to code carefully:
     temp = d['xx']             # extracts the copy
     temp.append(5)             # mutates the copy
     d['xx'] = temp             # stores the copy right back, to persist it

     # or, d=shelve.open(filename,writeback=True) would let you just code
     # d['xx'].append(5) and have it work as expected, BUT it would also
     # consume more memory and make the d.close() operation slower.

     d.close()                  # close it

参考
....

*note dbm: 29. モジュール

     ‘dbm’ スタイルのデータベースに対する共通インターフェース。

*note pickle: 95. モジュール

     *note shelve: b1. によって使われるオブジェクト整列化機構。


File: python.info,  Node: marshal --- 内部使用向けの Python オブジェクト直列化,  Next: dbm --- Unix "データベース" へのインターフェース,  Prev: shelve --- Python オブジェクトの永続化,  Up: データの永続化

5.12.4 ‘marshal’ -- 内部使用向けの Python オブジェクト直列化
------------------------------------------------------------

__________________________________________________________________

This module contains functions that can read and write Python values in
a binary format.  The format is specific to Python, but independent of
machine architecture issues (e.g., you can write a Python value to a
file on a PC, transport the file to a Mac, and read it back there).
Details of the format are undocumented on purpose; it may change between
Python versions (although it rarely does).  (1)

This is not a general "persistence" module.  For general persistence and
transfer of Python objects through RPC calls, see the modules *note
pickle: 95. and *note shelve: b1.  The *note marshal: 80. module exists
mainly to support reading and writing the "pseudo-compiled" code for
Python modules of ‘.pyc’ files.  Therefore, the Python maintainers
reserve the right to modify the marshal format in backward incompatible
ways should the need arise.  The format of code objects is not
compatible between Python versions, even if the version of the format is
the same.  De-serializing a code object in the incorrect Python version
has undefined behavior.  If you're serializing and de-serializing Python
objects, use the *note pickle: 95. module instead - the performance is
comparable, version independence is guaranteed, and pickle supports a
substantially wider range of objects than marshal.

     警告: *note marshal: 80. モジュールは、誤ったデータや悪意を持って作
     成されたデータに対する安全性を考慮していません。信頼できない、もし
     くは認証されていない出所からのデータを非整列化してはなりません。

Not all Python object types are supported; in general, only objects
whose value is independent from a particular invocation of Python can be
written and read by this module.  The following types are supported:
booleans, integers, floating-point numbers, complex numbers, strings,
bytes, bytearrays, tuples, lists, sets, frozensets, dictionaries, and
code objects (if 'allow_code' is true), where it should be understood
that tuples, lists, sets, frozensets and dictionaries are only supported
as long as the values contained therein are themselves supported.  The
singletons *note None: 641, *note Ellipsis: 20ea. and *note
StopIteration: bc8. can also be marshalled and unmarshalled.  For format
'version' lower than 3, recursive lists, sets and dictionaries cannot be
written (see below).

bytes-like オブジェクトを操作する関数と同様に、ファイルの読み書きを行う
関数が提供されています。

このモジュールでは、以下の関数が定義されています。

 -- の関数: marshal.dump (value, file, version=version, /, *,
          allow_code=True)

     開かれたファイルに値を書き込みます。値はサポートされている型でなく
     てはなりません。file は書き込み可能な *note バイナリファイル: 1bf1.
     である必要があります。

     If the value has (or contains an object that has) an unsupported
     type, a *note ValueError: 1e3. exception is raised -- but garbage
     data will also be written to the file.  The object will not be
     properly read back by *note load(): 197e.  *note Code objects: 1b4.
     are only supported if 'allow_code' is true.

     'version' 引数は ‘dump’ が使用するデータフォーマットを指定します (下
     記を参照してください)。

     引数 ‘value’, ‘version’ を指定して *note 監査イベント: 1825.
     ‘marshal.dumps’ を送出します。

     バージョン 3.13 で変更: Added the 'allow_code' parameter.

 -- の関数: marshal.load (file, /, *, allow_code=True)

     Read one value from the open file and return it.  If no valid value
     is read (e.g.  because the data has a different Python version's
     incompatible marshal format), raise *note EOFError: 12a7, *note
     ValueError: 1e3. or *note TypeError: 502.  *note Code objects: 1b4.
     are only supported if 'allow_code' is true.  The file must be a
     readable *note binary file: 1bf1.

     引数無しで *note 監査イベント: 1825. ‘marshal.load’ を送出します。

          注釈: サポートされていない型を含むオブジェクトが *note dump():
          2811. で整列化されている場合、 *note load(): 197e. は整列化不
          能な値を ‘None’ で置き換えます。

     バージョン 3.10 で変更: This call used to raise a ‘code.__new__’
     audit event for each code object.  Now it raises a single
     ‘marshal.load’ event for the entire load operation.

     バージョン 3.13 で変更: Added the 'allow_code' parameter.

 -- の関数: marshal.dumps (value, version=version, /, *,
          allow_code=True)

     Return the bytes object that would be written to a file by
     ‘dump(value, file)’.  The value must be a supported type.  Raise a
     *note ValueError: 1e3. exception if value has (or contains an
     object that has) an unsupported type.  *note Code objects: 1b4. are
     only supported if 'allow_code' is true.

     'version' 引数は ‘dumps’ が使用するデータフォーマットを指定します
     (下記を参照してください)。

     引数 ‘value’, ‘version’ を指定して *note 監査イベント: 1825.
     ‘marshal.dumps’ を送出します。

     バージョン 3.13 で変更: Added the 'allow_code' parameter.

 -- の関数: marshal.loads (bytes, /, *, allow_code=True)

     Convert the *note bytes-like object: cfb. to a value.  If no valid
     value is found, raise *note EOFError: 12a7, *note ValueError: 1e3.
     or *note TypeError: 502.  *note Code objects: 1b4. are only
     supported if 'allow_code' is true.  Extra bytes in the input are
     ignored.

     引数 ‘bytes’ を指定して *note 監査イベント: 1825. ‘marshal.loads’ を
     送出します。

     バージョン 3.10 で変更: This call used to raise a ‘code.__new__’
     audit event for each code object.  Now it raises a single
     ‘marshal.loads’ event for the entire load operation.

     バージョン 3.13 で変更: Added the 'allow_code' parameter.

これに加えて、以下の定数が定義されています:

 -- データ: marshal.version

     Indicates the format that the module uses.  Version 0 is the
     historical format, version 1 shares interned strings and version 2
     uses a binary format for floating-point numbers.  Version 3 adds
     support for object instancing and recursion.  The current version
     is 4.

脚注
....

   ---------- Footnotes ----------

   (1) このモジュールの名前は (特に) Modula-3 の設計者の間で使われていた
用語の一つに由来しています。彼らはデータを自己充足的な形式で輸送する操作
に "整列化 (marshalling)" という用語を使いました。厳密に言えば、"整列さ
せる (to marshal)" とは、あるデータを (例えば RPC バッファのように) 内部
表現形式から外部表現形式に変換することを意味し、"非整列化
(unmarshalling)" とはその逆を意味します。


File: python.info,  Node: dbm --- Unix "データベース" へのインターフェース,  Next: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース,  Prev: marshal --- 内部使用向けの Python オブジェクト直列化,  Up: データの永続化

5.12.5 ‘dbm’ -- Unix "データベース" へのインターフェース
--------------------------------------------------------

'ソースコード:' Lib/dbm/__init__.py(1)

__________________________________________________________________

*note dbm: 29. is a generic interface to variants of the DBM database:

   * *note dbm.sqlite3: 2d.

   * *note dbm.gnu: 2b.

   * *note dbm.ndbm: 2c.

If none of these modules are installed, the slow-but-simple
implementation in module *note dbm.dumb: 2a. will be used.  There is a
third party interface(2) to the Oracle Berkeley DB.

 -- 例外: dbm.error

     サポートされているモジュールそれぞれによって送出される可能性のある
     例外を含むタプル。これにはユニークな例外があり、最初の要素として同
     じく *note dbm.error: 2816. という名前の例外が含まれます -- *note
     dbm.error: 2816. が送出される場合、後者(訳注:タプルの ‘dbm.error’ で
     はなく例外 *note dbm.error: 2816.)が使用されます。

 -- の関数: dbm.whichdb (filename)

     This function attempts to guess which of the several simple
     database modules available -- *note dbm.sqlite3: 2d, *note dbm.gnu:
     2b, *note dbm.ndbm: 2c, or *note dbm.dumb: 2a. -- should be used to
     open a given file.

     Return one of the following values:

        * ‘None’ if the file can't be opened because it's unreadable or
          doesn't exist

        * the empty string (‘''’) if the file's format can't be guessed

        * a string containing the required module name, such as
          ‘'dbm.ndbm'’ or ‘'dbm.gnu'’

     バージョン 3.11 で変更: 'filename' accepts a *note path-like
     object: 280.

 -- の関数: dbm.open (file, flag='r', mode=0o666)

     Open a database and return the corresponding database object.


     パラメータ:

        * ‘file’ (*note path-like object: 280.) - The database file to
          open.

          If the database file already exists, the *note whichdb():
          2817. 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.

        * ‘flag’ (*note str: 418.) -

             * ‘'r'’ (default): Open existing database for reading only.

             * ‘'w'’: Open existing database for reading and writing.

             * ‘'c'’: Open database for reading and writing, creating it
               if it doesn't exist.

             * ‘'n'’: Always create a new, empty database, open for
               reading and writing.

        * ‘mode’ (*note int: 238.) - The Unix file access mode of the
          file (default: octal ‘0o666’), used only when the database has
          to be created.

     バージョン 3.11 で変更: 'file' accepts a *note path-like object:
     280.

The object returned by *note open(): ef6. supports the same basic
functionality as a *note dict: 237.; keys and their corresponding values
can be stored, retrieved, and deleted, and the *note in: 2cb. operator
and the ‘keys()’ method are available, as well as ‘get()’ and
‘setdefault()’ methods.

Key and values are always stored as *note bytes: 1a4.  This means that
when strings are used they are implicitly converted to the default
encoding before being stored.

これらのオブジェクトは、 *note with: 59c. 文での使用にも対応しています。
with 文を使用した場合、終了時に自動的に閉じられます。

バージョン 3.2 で変更: ‘get()’ and ‘setdefault()’ methods are now
available for all *note dbm: 29. backends.

バージョン 3.4 で変更: Added native support for the context management
protocol to the objects returned by *note open(): ef6.

バージョン 3.8 で変更: Deleting a key from a read-only database raises a
database module specific exception instead of *note KeyError: 31d.

以下の例ではホスト名と対応するタイトルをいくつか記録し、データベースの内
容を出力します:

     import dbm

     # Open database, creating it if necessary.
     with dbm.open('cache', 'c') as db:

         # Record some values
         db[b'hello'] = b'there'
         db['www.python.org'] = 'Python Website'
         db['www.cnn.com'] = 'Cable News Network'

         # Note that the keys are considered bytes now.
         assert db[b'www.python.org'] == b'Python Website'
         # Notice how the value is now in bytes.
         assert db['www.cnn.com'] == b'Cable News Network'

         # Often-used methods of the dict interface work too.
         print(db.get('python.org', b'not present'))

         # Storing a non-string key or value will raise an exception (most
         # likely a TypeError).
         db['www.yahoo.com'] = 4

     # db is automatically closed when leaving the with statement.

参考
....

*note shelve: b1. モジュール

     非文字列データを記録する永続化モジュール。

個々のサブモジュールは以降の節で説明されます。

* Menu:

* dbm.sqlite3: dbm sqlite3 --- SQLite backend for dbm. SQLite backend for dbm
* dbm.gnu: dbm gnu --- GNU database manager. GNU database manager
* dbm.ndbm: dbm ndbm --- New Database Manager. New Database Manager
* dbm.dumb: dbm dumb --- 可搬性のある DBM 実装. 可搬性のある DBM 実装

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/dbm/__init__.py

   (2) https://www.jcea.es/programacion/pybsddb.htm


File: python.info,  Node: dbm sqlite3 --- SQLite backend for dbm,  Next: dbm gnu --- GNU database manager,  Up: dbm --- Unix "データベース" へのインターフェース

5.12.5.1 ‘dbm.sqlite3’ -- SQLite backend for dbm
................................................

Added in version 3.13.

'Source code:' Lib/dbm/sqlite3.py(1)

__________________________________________________________________

This module uses the standard library *note sqlite3: ba. module to
provide an SQLite backend for the *note dbm: 29. module.  The files
created by *note dbm.sqlite3: 2d. can thus be opened by *note sqlite3:
ba, or any other SQLite browser, including the SQLite CLI.

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

 -- の関数: dbm.sqlite3.open (filename, /, flag='r', mode=0o666)

     Open an SQLite database.  The returned object behaves like a *note
     mapping: 118c, implements a ‘close()’ method, and supports a
     "closing" context manager via the *note with: 59c. keyword.


     パラメータ:

        * ‘filename’ (*note path-like object: 280.) - The path to the
          database to be opened.

        * ‘flag’ (*note str: 418.) -

             * ‘'r'’ (default): Open existing database for reading only.

             * ‘'w'’: Open existing database for reading and writing.

             * ‘'c'’: Open database for reading and writing, creating it
               if it doesn't exist.

             * ‘'n'’: Always create a new, empty database, open for
               reading and writing.

        * ‘mode’ - The Unix file access mode of the file (default: octal
          ‘0o666’), used only when the database has to be created.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/dbm/sqlite3.py


File: python.info,  Node: dbm gnu --- GNU database manager,  Next: dbm ndbm --- New Database Manager,  Prev: dbm sqlite3 --- SQLite backend for dbm,  Up: dbm --- Unix "データベース" へのインターフェース

5.12.5.2 ‘dbm.gnu’ -- GNU database manager
..........................................

'ソースコード:' Lib/dbm/gnu.py(1)

__________________________________________________________________

The *note dbm.gnu: 2b. module provides an interface to the GDBM (GNU
dbm) library, similar to the *note dbm.ndbm: 2c. module, but with
additional functionality like crash tolerance.

     注釈: The file formats created by *note dbm.gnu: 2b. and *note
     dbm.ndbm: 2c. are incompatible and can not be used interchangeably.

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

 -- 例外: dbm.gnu.error

     I/O エラーのような *note dbm.gnu: 2b. 特有のエラーで送出されます。
     誤ったキーの指定のように、一般的なマップ型のエラーに対しては *note
     KeyError: 31d. が送出されます。

 -- の関数: dbm.gnu.open (filename, flag='r', mode=0o666, /)

     Open a GDBM database and return a ‘gdbm’ object.


     パラメータ:

        * ‘filename’ (*note path-like object: 280.) - The database file
          to open.

        * ‘flag’ (*note str: 418.) -

             * ‘'r'’ (default): Open existing database for reading only.

             * ‘'w'’: Open existing database for reading and writing.

             * ‘'c'’: Open database for reading and writing, creating it
               if it doesn't exist.

             * ‘'n'’: Always create a new, empty database, open for
               reading and writing.

          The following additional characters may be appended to control
          how the database is opened:

             * ‘'f'’: Open the database in fast mode.  Writes to the
               database will not be synchronized.

             * ‘'s'’: Synchronized mode.  Changes to the database will
               be written immediately to the file.

             * ‘'u'’: Do not lock database.

          Not all flags are valid for all versions of GDBM. See the
          *note open_flags: 281b. member for a list of supported flag
          characters.

        * ‘mode’ (*note int: 238.) - The Unix file access mode of the
          file (default: octal ‘0o666’), used only when the database has
          to be created.


     例外: *note error: a68. - If an invalid 'flag' argument is passed.

     バージョン 3.11 で変更: 'filename' accepts a *note path-like
     object: 280.

      -- データ: dbm.gnu.open_flags

          A string of characters the 'flag' parameter of *note open():
          19aa. supports.

     ‘gdbm’ objects behave similar to *note mappings: 118c, but
     ‘items()’ and ‘values()’ methods are not supported.  The following
     methods are also provided:

      -- メソッド: gdbm.firstkey ()

          It's possible to loop over every key in the database using
          this method and the *note nextkey(): 281d. 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.

      -- メソッド: gdbm.nextkey (key)

          データベースの順方向探索において、'key' よりも後に来るキーを返
          します。以下のコードはデータベース ‘db’ について、キー全てを含
          むリストをメモリ上に生成することなく全てのキーを出力します:

               k = db.firstkey()
               while k is not None:
                   print(k)
                   k = db.nextkey(k)

      -- メソッド: gdbm.reorganize ()

          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.  ‘gdbm’ objects will not shorten the
          length of a database file except by using this reorganization;
          otherwise, deleted file space will be kept and reused as new
          (key, value) pairs are added.

      -- メソッド: gdbm.sync ()

          データベースが高速モードで開かれていた場合、このメソッドはディ
          スクにまだ書き込まれていないデータを全て書き込ませます。

      -- メソッド: gdbm.close ()

          Close the GDBM database.

      -- メソッド: gdbm.clear ()

          Remove all items from the GDBM database.

          Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/dbm/gnu.py


File: python.info,  Node: dbm ndbm --- New Database Manager,  Next: dbm dumb --- 可搬性のある DBM 実装,  Prev: dbm gnu --- GNU database manager,  Up: dbm --- Unix "データベース" へのインターフェース

5.12.5.3 ‘dbm.ndbm’ -- New Database Manager
...........................................

'ソースコード:' Lib/dbm/ndbm.py(1)

__________________________________________________________________

The *note dbm.ndbm: 2c. module provides an interface to the NDBM (New
Database Manager) library.  This module can be used with the "classic"
NDBM interface or the GDBM compatibility interface.

     注釈: The file formats created by *note dbm.gnu: 2b. and *note
     dbm.ndbm: 2c. are incompatible and can not be used interchangeably.

     警告: 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).

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

 -- 例外: dbm.ndbm.error

     I/O エラーのような *note dbm.ndbm: 2c. 特有のエラーで送出されます。
     誤ったキーの指定のように、一般的なマップ型のエラーに対しては *note
     KeyError: 31d. が送出されます。

 -- データ: dbm.ndbm.library

     Name of the NDBM implementation library used.

 -- の関数: dbm.ndbm.open (filename, flag='r', mode=0o666, /)

     Open an NDBM database and return an ‘ndbm’ object.


     パラメータ:

        * ‘filename’ (*note path-like object: 280.) - The basename of
          the database file (without the ‘.dir’ or ‘.pag’ extensions).

        * ‘flag’ (*note str: 418.) -

             * ‘'r'’ (default): Open existing database for reading only.

             * ‘'w'’: Open existing database for reading and writing.

             * ‘'c'’: Open database for reading and writing, creating it
               if it doesn't exist.

             * ‘'n'’: Always create a new, empty database, open for
               reading and writing.

        * ‘mode’ (*note int: 238.) - The Unix file access mode of the
          file (default: octal ‘0o666’), used only when the database has
          to be created.

     ‘ndbm’ objects behave similar to *note mappings: 118c, but
     ‘items()’ and ‘values()’ methods are not supported.  The following
     methods are also provided:

     バージョン 3.11 で変更: Accepts *note path-like object: 280. for
     filename.

      -- メソッド: ndbm.close ()

          Close the NDBM database.

      -- メソッド: ndbm.clear ()

          Remove all items from the NDBM database.

          Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/dbm/ndbm.py


File: python.info,  Node: dbm dumb --- 可搬性のある DBM 実装,  Prev: dbm ndbm --- New Database Manager,  Up: dbm --- Unix "データベース" へのインターフェース

5.12.5.4 ‘dbm.dumb’ -- 可搬性のある DBM 実装
............................................

'ソースコード:' Lib/dbm/dumb.py(1)

     注釈: *note dbm.dumb: 2a. モジュールは、 *note dbm: 29. が頑健なモ
     ジュールを他に見つけることができなかった際の最後の手段とされていま
     す。 *note dbm.dumb: 2a. モジュールは速度を重視して書かれているわけ
     ではなく、他のデータベースモジュールのように重い使い方をするための
     ものではありません。

__________________________________________________________________

The *note dbm.dumb: 2a. module provides a persistent *note dict:
237.-like interface which is written entirely in Python.  Unlike other
*note dbm: 29. backends, such as *note dbm.gnu: 2b, no external library
is required.

The ‘dbm.dumb’ module defines the following:

 -- 例外: dbm.dumb.error

     I/O エラーのような *note dbm.dumb: 2a. 特有のエラーの際に送出されま
     す。不正なキーを指定したときのような、一般的な対応付けエラーの際に
     は *note KeyError: 31d. が送出されます。

 -- の関数: dbm.dumb.open (filename, flag='c', mode=0o666)

     Open a ‘dbm.dumb’ database.  The returned database object behaves
     similar to a *note mapping: 118c, in addition to providing *note
     sync(): 2825. and *note close(): 2826. methods.


     パラメータ:

        * ‘filename’ - The basename of the database file (without
          extensions).  A new database creates the following files:

             - ‘`filename'.dat’

             - ‘`filename'.dir’

        * ‘flag’ (*note str: 418.) -

             * ‘'r'’: Open existing database for reading only.

             * ‘'w'’: Open existing database for reading and writing.

             * ‘'c'’ (default): Open database for reading and writing,
               creating it if it doesn't exist.

             * ‘'n'’: Always create a new, empty database, open for
               reading and writing.

        * ‘mode’ (*note int: 238.) - The Unix file access mode of the
          file (default: octal ‘0o666’), used only when the database has
          to be created.

          警告: 十分に大きかったり複雑だったりするエントリーのあるデータ
          ベースを読み込んでいるときに、 Python の抽象構文木コンパイラの
          スタックの深さの限界を越えるせいで、 Python インタプリタをクラ
          ッシュさせることができます。

     バージョン 3.5 で変更: *note open(): a64. always creates a new
     database when 'flag' is ‘'n'’.

     バージョン 3.8 で変更: 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'’.

     バージョン 3.11 で変更: 'filename' accepts a *note path-like
     object: 280.

     In addition to the methods provided by the *note
     collections.abc.MutableMapping: 107e. class, the following methods
     are provided:

      -- メソッド: dumbdbm.sync ()

          ディスク上の辞書とデータファイルを同期します。このメソッドは
          ‘Shelve.sync()’ メソッドから呼び出されます。

      -- メソッド: dumbdbm.close ()

          Close the database.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/dbm/dumb.py


File: python.info,  Node: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース,  Prev: dbm --- Unix "データベース" へのインターフェース,  Up: データの永続化

5.12.6 ‘sqlite3’ -- SQLite データベース用の DB-API 2.0 インターフェース
-----------------------------------------------------------------------

'ソースコード:' Lib/sqlite3/(1)

SQLite は、軽量なディスク上のデータベースを提供する C ライブラリです。別
のサーバプロセスを用意する必要なく、 SQL クエリー言語の非標準的な一種を
使用してデータベースにアクセスできます。一部のアプリケーションは内部デー
タ保存に SQLite を使えます。また、SQLite を使ってアプリケーションのプロ
トタイプを作り、その後そのコードを PostgreSQL や Oracle のような大規模デ
ータベースに移植するということも可能です。

The ‘sqlite3’ module was written by Gerhard Häring.  It provides an SQL
interface compliant with the DB-API 2.0 specification described by PEP
249(2), and requires SQLite 3.15.2 or newer.

この文書には大きく分けて 4 つの節があります:

   * *note チュートリアル: 282a. ‘sqlite3’ モジュールの使い方を学びます
     。

   * *note リファレンス: 282b. このモジュールが定義するクラスと関数につ
     いて説明します。

   * *note ハウツー・ガイド: 282c. 特定のタスクの処理方法について詳しく
     説明します。

   * *note 説明: 282d. トランザクション制御の背景をより深く掘り下げて説
     明します。

参考
....

‘https://www.sqlite.org’

     SQLite のウェブページ。ここの文書ではサポートされる SQL 方言の文法
     と使えるデータ型を説明しています。

‘https://www.w3schools.com/sql/’

     SQL 学習に効くチュートリアル、リファレンス、実例集。

PEP 249(3) - Database API Specification 2.0

     Marc-Andre Lemburg により書かれた PEP。

* Menu:

* チュートリアル::
* リファレンス::
* ハウツー・ガイド::
* 説明::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/sqlite3/

   (2) https://peps.python.org/pep-0249/

   (3) https://peps.python.org/pep-0249/


File: python.info,  Node: チュートリアル,  Next: リファレンス,  Up: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース

5.12.6.1 チュートリアル
.......................

このチュートリアルでは、あなたは基本的な ‘sqlite3’ 機能を使用して、 例と
してモンティ・パイソンの映画のデータベースを作成します。 あなたがカーソ
ル(cursors(1))やトランザクション(transactions(2))を含むデータベースの基
本概念を理解していることを前提としています。

最初に、新しいデータベースを作成し、データベース接続(connection)を開いて
‘sqlite3’ が動作できるようにする必要があります。 *note
sqlite3.connect(): 288. を呼び出して、データベース ‘tutorial.db’ への接
続を現在の作業ディレクトリに作成します。存在しない場合は暗黙的に作成しま
す。

     import sqlite3
     con = sqlite3.connect("tutorial.db")

返された *note Connection: 226. オブジェクト ‘con’ は、ディスク上のデー
タベースへの接続を表します。

SQL 文を実行し、SQL クエリから結果を取得するには、データベース・カーソル
を使用する必要があります。 *note con.cursor(): 282f. を呼び出して *note
Cursor: 2830. を作成してください:

     cur = con.cursor()

さて、今やデータベース接続とカーソルを取得したので、タイトル(title)とリ
リース年(year)と、レビュー・スコア(score)の列(columns)を持つデータベース
・テーブル ‘movie’ を作成できます。 簡単にするために、テーブル宣言では列
名だけを使用できます。SQLite の 柔軟な型付け(flexible typing(3))機能のお
かげで、データ型の指定はオプションになっています。 *note
cur.execute(...): 2b2. を呼び出して ‘CREATE TABLE’ 文を実行してください:

     cur.execute("CREATE TABLE movie(title, year, score)")

SQLite に組み込みの ‘sqlite_master’ テーブルに対してクエリを実行すること
で、新しいテーブルが作成されたことを確認できます。このテーブルには、
‘movie’ テーブル定義のエントリが含まれているはずです(詳細は The Schema
Table(4) 参照)。 *note cur.execute(...): 2b2. を呼び出してクエリを実行し
て、その結果を ‘res’ に代入し、結果の行(row)を取得するために *note
res.fetchone(): 2831. を呼び出します:

     >>> res = cur.execute("SELECT name FROM sqlite_master")
     >>> res.fetchone()
     ('movie',)

We can see that the table has been created, as the query returns a *note
tuple: 349. containing the table's name.  If we query ‘sqlite_master’
for a non-existent table ‘spam’, ‘res.fetchone()’ will return ‘None’:

     >>> res = cur.execute("SELECT name FROM sqlite_master WHERE name='spam'")
     >>> res.fetchone() is None
     True

ここで、 INSERT 文を実行して SQL のリテラルとして提供された 2 行のデータ
を追加し、 再度 *note cur.execute(...): 2b2. を呼び出して追加します:

     cur.execute("""
         INSERT INTO movie VALUES
             ('Monty Python and the Holy Grail', 1975, 8.2),
             ('And Now for Something Completely Different', 1971, 7.5)
     """)

‘INSERT’ 文は、変更がデータベースに保存される前にコミットする必要がある
、トランザクションを暗黙的に開きます(詳細は、 *note
トランザクション制御: 2832. 参照)。 トランザクションをコミットするために
接続オブジェクト(connection object)の *note con.commit(): 2833. を呼び出
して下さい:

     con.commit()

‘SELECT’ クエリを実行することで、データが正しく挿入されたことを確認でき
ます。 結果のすべての行を返すには、おなじみの *note cur.execute(...):
2b2. を使用して結果を ‘res’ に代入し、 *note res.fetchall(): 2834. を呼
び出して下さい:

     >>> res = cur.execute("SELECT score FROM movie")
     >>> res.fetchall()
     [(8.2,), (7.5,)]

結果は、2 つの ‘タプル’ の *note リスト: 5dc. で、 それぞれのタプルにそ
の行の ‘score’ 値が含まれています。

ここで、 *note cur.executemany(...): 2b3. を呼び出して、さらに 3 行挿入
します:

     data = [
         ("Monty Python Live at the Hollywood Bowl", 1982, 7.9),
         ("Monty Python's The Meaning of Life", 1983, 7.5),
         ("Monty Python's Life of Brian", 1979, 8.0),
     ]
     cur.executemany("INSERT INTO movie VALUES(?, ?, ?)", data)
     con.commit()  # Remember to commit the transaction after executing INSERT.

‘data’ をクエリに結び付け(bind)するために ‘?’ プレースホルダが使用されて
いることに注意してください。 SQL インジェクション攻撃(SQL injection
attacks(5))を避けるために、Python の値を SQL 文に結び付けするには、常に
*note 文字列フォーマット: 1bdd. の代わりにプレースホルダを使用してくださ
い(詳細は *note プレースホルダを使用して SQL クエリに値を結び付ける方法:
2b4. 参照)。

‘SELECT’ クエリを実行することで、新しい行が挿入されたことを確認できます
。今回は、クエリの結果を反復処理します:

     >>> for row in cur.execute("SELECT year, title FROM movie ORDER BY year"):
     ...     print(row)
     (1971, 'And Now for Something Completely Different')
     (1975, 'Monty Python and the Holy Grail')
     (1979, "Monty Python's Life of Brian")
     (1982, 'Monty Python Live at the Hollywood Bowl')
     (1983, "Monty Python's The Meaning of Life")

各行(row)は *note タプル: 349. の ‘(year, title)’ の 2 つの項目であり、
クエリで選択された列(columns)にマッチします。

最後に、 *note con.close(): 227. を呼び出して既存の接続(connection)を閉
じ、新しい接続を開き、新しいカーソルを作成してから、データベースに対して
クエリを実行して、データベースがディスクに書き込まれたことを確認します:

     >>> con.close()
     >>> new_con = sqlite3.connect("tutorial.db")
     >>> new_cur = new_con.cursor()
     >>> res = new_cur.execute("SELECT title, year FROM movie ORDER BY score DESC")
     >>> title, year = res.fetchone()
     >>> print(f'The highest scoring Monty Python movie is {title!r}, released in {year}')
     The highest scoring Monty Python movie is 'Monty Python and the Holy Grail', released in 1975
     >>> new_con.close()

これで、あなたは、 ‘sqlite3’ モジュールを使用して SQLite データベースを
作成し、複数の方法でデータを挿入し、そこから値を取得することができるよう
になりました。

参考
....

   * *note ハウツー・ガイド: 282c. も参考にしてください:

        * *note プレースホルダを使用して SQL クエリに値を結び付ける方法:
          2b4.

        * *note カスタム Python 型を SQLite 値に適合させる方法: 2835.

        * *note SQLite 値をカスタム Python 型に変換する方法: 2836.

        * *note 接続(connection)コンテキストマネージャの使い方: 174e.

        * *note 行工場(row factories)の作成方法と使用方法: 2837.

   * *note トランザクション制御: 282d. トランザクション制御の背景につい
     てより深く掘り下げた説明。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Cursor_(databases)

   (2) https://en.wikipedia.org/wiki/Database_transaction

   (3) https://www.sqlite.org/flextypegood.html

   (4) https://www.sqlite.org/schematab.html

   (5) https://en.wikipedia.org/wiki/SQL_injection


File: python.info,  Node: リファレンス,  Next: ハウツー・ガイド,  Prev: チュートリアル,  Up: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース

5.12.6.2 リファレンス
.....................

* Menu:

* モジュール関数::
* モジュール定数::
* Connection オブジェクト::
* Cursor オブジェクト::
* Row オブジェクト::
* Blob オブジェクト::
* PrepareProtocol オブジェクト::
* 例外: 例外<7>.
* SQLite と Python の型::
* デフォルトの適合関数(adapters)とデフォルトの変換関数(converters)(非推奨): デフォルトの適合関数 adapters とデフォルトの変換関数 converters 非推奨.
* コマンドライン・インターフェース::


File: python.info,  Node: モジュール関数,  Next: モジュール定数,  Up: リファレンス

5.12.6.3 モジュール関数
.......................

 -- の関数: sqlite3.connect (database, timeout=5.0, detect_types=0,
          isolation_level='DEFERRED', check_same_thread=True,
          factory=sqlite3.Connection, cached_statements=128, uri=False,
          *, autocommit=sqlite3.LEGACY_TRANSACTION_CONTROL)

     SQLite データベースとの接続(connection)を開きます。


     パラメータ:

        * ‘database’ (*note path-like object: 280.) - The path to the
          database file to be opened.  You can pass ‘":memory:"’ to
          create an SQLite database existing only in memory(1), and open
          a connection to it.

        * ‘timeout’ (*note float: 2ce.) - テーブルがロックされている場合
          、 *note OperationalError: 1808. を送出する前に接続を待機する
          秒数。 別の接続がテーブルを変更するためにトランザクションを開
          くと、そのテーブルはトランザクションがコミットされるまでロック
          されます。 デフォルトは 5 秒です。

        * ‘detect_types’ (*note int: 238.) - *note register_converter():
          283c. で登録された変換関数を使用して、 *note SQLite
          でネイティブにサポートされている型: 283d. 以外のデータ型を検出
          して、 Python 型に変換するかどうか、そして、その変換方法を制御
          します。 これは、 *note PARSE_DECLTYPES: 283e. と *note
          PARSE_COLNAMES: 283f. を(ビット論理和 ‘|’ を使用して)任意の組
          み合わせで設定することで有効になります。 両方のフラグが設定さ
          れている場合、宣言された型よりも列名が優先されます。
          'detect_types' パラメータが設定されている場合でも、 生成された
          フィールド(たとえば ‘max(data)’)の型は検出できず、代わりに
          *note str: 418. が返されます。デフォルト (‘0’) では、データ型
          検出は無効になっています。

        * ‘isolation_level’ (*note str: 418.‘ | ’‘None’) - Control
          legacy transaction handling behaviour.  See *note
          Connection.isolation_level: 2840. and *note isolation_level
          属性に依るトランザクション制御: 2841. for more information.
          Can be ‘"DEFERRED"’ (default), ‘"EXCLUSIVE"’ or ‘"IMMEDIATE"’;
          or ‘None’ to disable opening transactions implicitly.  Has no
          effect unless *note Connection.autocommit: 482. is set to
          *note LEGACY_TRANSACTION_CONTROL: 2842. (the default).

        * ‘check_same_thread’ (*note bool: 434.) - ‘True’ (これがデフォ
          ルトです)なら、データベース接続を作成したスレッド以外のスレッ
          ドがデータベース接続を使用すると、 *note ProgrammingError:
          4bf. が送出されます。 ‘False’ なら、接続は複数のスレッドからア
          クセスできます。ただし、データの破損を避けるために、ユーザーに
          よる書き込み操作の直列化が必要になることがあります。詳細は
          *note threadsafety: 648. を参照してください。

        * ‘factory’ (*note Connection: 226.) - デフォルトの *note
          Connection: 226. クラスでない場合に接続(connection)を作成する
          *note Connection: 226. のカスタム・サブクラスです。

        * ‘cached_statements’ (*note int: 238.) - ‘sqlite3’ がこの接続
          (connection)のために内部的にキャッシュするSQL文(statements)の
          数で、 パース時のオーバーヘッドを回避します。 デフォルトでは、
          128 文(statements)です。

        * ‘uri’ (*note bool: 434.) - ‘True’ に設定すると、 'database' は
          、ファイル・パス(path)とオプションのクエリ文字列を含む URI
          (Uniform Resource Identifier) として解釈されます。 スキームの
          部分は ‘"file:"’ でなければならず、パス(path)は相対パスまたは
          絶対パスにすることができます。 クエリ文字列により、 パラメータ
          ーを SQLite に渡すことができ、さまざまな *note SQLite URI
          の操作方法: 2843. が有効になります。

        * ‘autocommit’ (*note bool: 434.) - Control PEP 249(2)
          transaction handling behaviour.  See *note
          Connection.autocommit: 482. and *note autocommit
          属性に依るトランザクション制御: 483. for more information.
          'autocommit' currently defaults to *note
          LEGACY_TRANSACTION_CONTROL: 2842.  The default will change to
          ‘False’ in a future Python release.


     戻り値の型: *note Connection: 226.

     引数 ‘database’ を指定して *note 監査イベント: 1825.
     ‘sqlite3.connect’ を送出します。

     引数 ‘connection_handle’ を指定して *note 監査イベント: 1825.
     ‘sqlite3.connect/handle’ を送出します。

     バージョン 3.4 で変更: ‘uri’ パラメータが追加されました。

     バージョン 3.7 で変更: 'database' は、文字列だけでなく、 *note
     path-like object: 280. にすることもできるようになりました。

     バージョン 3.10 で変更: Added the ‘sqlite3.connect/handle’ auditing
     event.

     バージョン 3.12 で変更: Added the 'autocommit' parameter.

     バージョン 3.13 で変更: Positional use of the parameters 'timeout',
     'detect_types', 'isolation_level', 'check_same_thread', 'factory',
     'cached_statements', and 'uri' is deprecated.  They will become
     keyword-only parameters in Python 3.15.

 -- の関数: sqlite3.complete_statement (statement)

     文字列 'statement' が 1 つ以上の完全な SQL 文を含んでいるように見え
     る場合、 ‘True’ を返します。 閉じられていない文字列リテラルがないこ
     とと、文がセミコロンで終了していることを確認する以外の、構文の検証
     やパースは行われません。

     例えば:

          >>> sqlite3.complete_statement("SELECT foo FROM bar;")
          True
          >>> sqlite3.complete_statement("SELECT foo")
          False

     この関数は、コマンドライン入力時に便利で、入力されたテキストが完全
     な SQL 文を形成しているように見えるかどうか、または *note
     execute(): 2b2. を呼び出す前に追加の入力が必要かどうかを判断するの
     に使えます。

     実際の使用例については、 Lib/sqlite3/__main__.py(3) の
     ‘runsource()’ を参照してください。

 -- の関数: sqlite3.enable_callback_tracebacks (flag, /)

     コールバックのトレースバックを有効または無効にします。 デフォルトで
     は、ユーザー定義関数や集計関数や変換関数や authorizer コールバック
     などではトレースバックを取得しません。それらをデバッグしたい場合は
     、 'flag' を ‘True’ に設定してこの関数を呼び出し。その後、 *note
     sys.stderr: 907. のコールバックからトレースバックを取得します。 機
     能を再び無効にするには ‘False’ を使用します。

          注釈: Errors in user-defined function callbacks are logged as
          unraisable exceptions.  Use an *note unraisable hook handler:
          1d8. for introspection of the failed callback.

 -- の関数: sqlite3.register_adapter (type, adapter, /)

     'adapter' *note 呼び出し可能オブジェクト: 2847. を登録して、 Python
     型の 'type' を SQLite の型に適合させます。適合関数(adapter)アダプタ
     ーは、 Python 型 'type' の Python オブジェクトを唯一の引数として使
     用して呼び出され、 *note SQLite がネイティブに理解する型: 283d. の
     値を返す必要があります。

 -- の関数: sqlite3.register_converter (typename, converter, /)

     'converter' *note 呼び出し可能オブジェクト: 2847. を登録して、
     'typename' 型の SQLite オブジェクトを指定の型の Python オブジェクト
     に変換します。変換関数(converter)、 'typename' 型のすべての SQLite
     値に対して呼び出されます。 変換関数には *note bytes: 1a4. オブジェ
     クトが渡され、目的の Python 型のオブジェクトを返す必要があります。
     型検出の仕組みについては、 *note connect(): 288. のパラメーター
     'detect_types' を参照してください。

     注釈: 'typename' とクエリ内の型の名前は、大文字小文字を区別せずにマ
     ッチングされます。

   ---------- Footnotes ----------

   (1) https://sqlite.org/inmemorydb.html

   (2) https://peps.python.org/pep-0249/

   (3) 
https://github.com/python/cpython/tree/3.13/Lib/sqlite3/__main__.py


File: python.info,  Node: モジュール定数,  Next: Connection オブジェクト,  Prev: モジュール関数,  Up: リファレンス

5.12.6.4 モジュール定数
.......................

 -- データ: sqlite3.LEGACY_TRANSACTION_CONTROL

     古いスタイル (Python 3.12 より前) のトランザクション制御の振る舞い
     を選択するには、 *note autocommit: 482. に、この定数を設定します。
     詳細については *note isolation_level
     属性に依るトランザクション制御: 2841. を参照してください。

 -- データ: sqlite3.PARSE_COLNAMES

     このフラグ値を *note connect(): 288. の 'detect_types' パラメーター
     に渡し、クエリの列(column)名からパースされた型名を変換関数辞書
     (converter dictionary)のキーとして使用して変換関数を探します。型名
     は角括弧(‘[]’)で囲む必要があります。

          SELECT p as "p [point]" FROM test;  ! will look up converter "point"

     このフラグは ‘|’ (ビット論理和)演算子を使用して *note
     PARSE_DECLTYPES: 283e. と組み合わせることができます。

 -- データ: sqlite3.PARSE_DECLTYPES

     このフラグ値を *note connect(): 288. の 'detect_types' パラメーター
     に渡して、各列(column)で宣言した型を使用して変換関数を探します。型
     は、データベース・テーブルの作成時に宣言します。 ‘sqlite3’ は、宣言
     された型の、最初の単語を、変換関数辞書(converter dictionary)のキー
     として使用して、変換関数を探します。例えば:

          CREATE TABLE test(
             i integer primary key,  ! will look up a converter named "integer"
             p point,                ! will look up a converter named "point"
             n number(10)            ! will look up a converter named "number"
           )

     このフラグは ‘|’ (ビット論理和)演算子を使用して *note
     PARSE_COLNAMES: 283f. と組み合わせることができます。

 -- データ: sqlite3.SQLITE_OK
 -- データ: sqlite3.SQLITE_DENY
 -- データ: sqlite3.SQLITE_IGNORE

     *note Connection.set_authorizer(): 28b. に渡す *note
     呼び出し可能オブジェクト: 2847. が返す必要のあるフラグ。これらは以
     下の意味です:

        * アクセスは許可されました(‘SQLITE_OK’)

        * 当該SQL文全体の実行をエラーで中止(abort)する必要があります
          (‘SQLITE_DENY’)

        * 列(column)は ‘NULL’ 値として扱う必要がありますが、当該SQL文の
          実行は続行する必要があります(‘SQLITE_IGNORE’)

 -- データ: sqlite3.apilevel

     サポートされている DB-API レベルを示す文字列定数。 DB-API で必要で
     す。 ‘"2.0"’ とハードコーディングされています。

 -- データ: sqlite3.paramstyle

     ‘sqlite3’ モジュールが期待するパラメータ・マーカーのフォーマットの
     種類をあらわす文字列定数です。 DB-API で必要です。 ‘"qmark"’ とハー
     ドコーディングされています。

          注釈: ‘named’ DB-API パラメータ・スタイルもサポートされていま
          す。

 -- データ: sqlite3.sqlite_version

     *note 文字列: 418. としての、ランタイム SQLite ライブラリのバージョ
     ン番号。

 -- データ: sqlite3.sqlite_version_info

     *note 整数: 238. の *note タプル: 349. としての、ランタイム SQLite
     ライブラリのバージョン番号。

 -- データ: sqlite3.threadsafety

     ‘sqlite3’ モジュールがサポートするスレッドセーフのレベルを示す、
     DB-API 2.0 で必要な整数定数。 この属性は、背後の SQLite ライブラリ
     のコンパイル時のデフォルトの SQLite スレッド・モード (threading
     mode(1))に基づいて設定されます。 SQLite のスレッド・モードは以下の
     とおりです:

       1. 'シングル・スレッド': このモードでは、すべてのミューテックスが
          無効になり、一度に複数のスレッドで SQLite を使用するのは安全で
          はありません。

       2. 'マルチ・スレッド': このモードでは、 1 つのデータベース接続が
          2 つ以上のスレッドで同時に使用されない限り、複数のスレッドで
          SQLite を安全に使用できます。

       3. '直列化': 直列化(serialized)モードでは、 SQLite を複数のスレッ
          ドで制限なく安全に使用できます。

     SQLite スレッド・モードと、 DB-API 2.0 のスレッドセーフ・レベルとの
     対応は以下のとおりです:

     SQLite スレッド・モ    threadsafety(2)            SQLITE_THREADSAFE(3)       DB-API 2.0 での意味
     ード                                                                         

     -----------------------------------------------------------------------------------------------------------------
                                                                                  
     シングル・スレッド     0                          0                          スレッドはモジュールを共有できま
                                                                                  せん
                                                                                  
                                                                                  
     マルチ・スレッド       1                          2                          スレッドはモジュールを共有できま
                                                                                  すが、接続は共有できません
                                                                                  
                                                                                  
     直列化                 3                          1                          スレッドは、モジュールや接続やカ
                                                                                  ーソルを共有できます
                                                                                  

     バージョン 3.11 で変更: ‘1’ とハード・コーディングする代わりに
     'threadsafety' を動的に設定します。

 -- データ: sqlite3.version

     *note 文字列: 418. としての、このモジュールのバージョン番号。これは
     SQLite ライブラリのバージョン番号ではありません。

     Deprecated since version 3.12, will be removed in version 3.14: こ
     の定数は、 ‘sqlite3’ へのアップストリーム変更に使用されていたサード
     パーティ・ライブラリである、 ‘pysqlite’ パッケージのバージョン番号
     を反映していました。今やこれには何の意味も無いし実用的な価値もあり
     ません。

 -- データ: sqlite3.version_info

     *note 整数: 238. の *note タプル: 349. としての、このモジュールのバ
     ージョン番号。これは SQLite ライブラリのバージョン番号ではありませ
     ん。

     Deprecated since version 3.12, will be removed in version 3.14: こ
     の定数は、 ‘sqlite3’ へのアップストリーム変更に使用されていたサード
     パーティ・ライブラリである、 ‘pysqlite’ パッケージのバージョン番号
     を反映していました。今やこれには何の意味も無いし実用的な価値もあり
     ません。

 -- データ: sqlite3.SQLITE_DBCONFIG_DEFENSIVE
 -- データ: sqlite3.SQLITE_DBCONFIG_DQS_DDL
 -- データ: sqlite3.SQLITE_DBCONFIG_DQS_DML
 -- データ: sqlite3.SQLITE_DBCONFIG_ENABLE_FKEY
 -- データ: sqlite3.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER
 -- データ: sqlite3.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION
 -- データ: sqlite3.SQLITE_DBCONFIG_ENABLE_QPSG
 -- データ: sqlite3.SQLITE_DBCONFIG_ENABLE_TRIGGER
 -- データ: sqlite3.SQLITE_DBCONFIG_ENABLE_VIEW
 -- データ: sqlite3.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE
 -- データ: sqlite3.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT
 -- データ: sqlite3.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE
 -- データ: sqlite3.SQLITE_DBCONFIG_RESET_DATABASE
 -- データ: sqlite3.SQLITE_DBCONFIG_TRIGGER_EQP
 -- データ: sqlite3.SQLITE_DBCONFIG_TRUSTED_SCHEMA
 -- データ: sqlite3.SQLITE_DBCONFIG_WRITABLE_SCHEMA

     これらの定数は、 *note Connection.setconfig(): 486. メソッド や
     *note getconfig(): 485. メソッドで使用されます。

     これらの定数が利用できるかどうかは、 Python にコンパイルされた
     SQLite のバージョンによって異なります。

     Added in version 3.12.

     参考
     ....

     ‘https://www.sqlite.org/c3ref/c_dbconfig_defensive.html’

          SQLite docs: Database Connection Configuration Options

   ---------- Footnotes ----------

   (1) https://sqlite.org/threadsafe.html

   (2) https://peps.python.org/pep-0249/#threadsafety

   (3) https://sqlite.org/compile.html#threadsafe


File: python.info,  Node: Connection オブジェクト,  Next: Cursor オブジェクト,  Prev: モジュール定数,  Up: リファレンス

5.12.6.5 Connection オブジェクト
................................

 -- クラス: sqlite3.Connection

     開いた SQLite データベースの各々は、 *note sqlite3.connect(): 288.
     を使用して作成される ‘Connection’ オブジェクトによって表されます。
     ‘Connection’ オブジェクトの主な目的は *note Cursor: 2830. オブジェ
     クトの作成と *note トランザクション制御: 2832. です。

     参考
     ....

        * *note 接続(connection)ショートカット・メソッドの使い方: 2864.

        * *note 接続(connection)コンテキストマネージャの使い方: 174e.

     バージョン 3.13 で変更: A *note ResourceWarning: 225. is emitted if
     *note close(): 227. is not called before a ‘Connection’ object is
     deleted.

     SQLite データベース接続(connection)には、以下の属性とメソッドがあり
     ます:

      -- メソッド: cursor (factory=Cursor)

          *note Cursor: 2830. オブジェクトを作成して返します。 cursor メ
          ソッドは、単一のオプション・パラメーター 'factory' を受け入れ
          ます。 'factory' を指定する場合、これは *note Cursor: 2830. ま
          たはそのサブクラスのインスタンスを返す *note
          呼び出し可能オブジェクト: 2847. である必要があります。

      -- メソッド: blobopen (table, column, row, /, *, readonly=False,
               name='main')

          既存の BLOB (Binary Large OBject) への *note Blob: 64e. ハンド
          ルを開きます。


          パラメータ:

             * ‘table’ (*note str: 418.) - 当該 BLOB が配置されているテ
               ーブルの名前。

             * ‘column’ (*note str: 418.) - 当該 BLOB が配置されている列
               (column)の名前。

             * ‘row’ (*note str: 418.) - 当該 BLOB が配置されている行
               (row)の名前。

             * ‘readonly’ (*note bool: 434.) - 書き込み権限なしで BLOB を
               開く必要がある場合は、 ‘True’ に設定します。 デフォルトは
               ‘False’ です。

             * ‘name’ (*note str: 418.) - 当該 BLOB が配置されているデー
               タベース名。 デフォルトは ‘"main"’ です。


          例外: *note OperationalError: 1808. - ‘WITHOUT ROWID’ テーブル
          で BLOB を開こうとしたとき。


          戻り値の型: *note Blob: 64e.

               注釈: *note Blob: 64e. クラスを使用して BLOB のサイズを変
               更することはできません。 SQL 関数 ‘zeroblob’ を使用すると
               、固定サイズのブロブを作成します。

          Added in version 3.11.

      -- メソッド: commit ()

          保留中のトランザクションをデータベースにコミットします。 *note
          autocommit: 482. が ‘True’ または開いているトランザクションが
          ない場合、このメソッドは何も行いません。 ‘autocommit’ が
          ‘False’ の場合に保留中のトランザクションがこのメソッドによって
          コミットされた場合、新しいトランザクションが暗黙に開かれます。

      -- メソッド: rollback ()

          保留中のトランザクションの先頭にロールバックします。 *note
          autocommit: 482. が ‘True’ または開いているトランザクションが
          ない場合、このメソッドは何も行いません。 ‘autocommit’ が
          ‘False’ の場合に保留中のトランザクションがこのメソッドによって
          ロールバックされた場合、新しいトランザクションが暗黙に開かれま
          す。

      -- メソッド: close ()

          データベース接続を閉じます。 *note autocommit: 482. が ‘False’
          の場合、保留中のトランザクションは暗黙にロールバックされます。
          ‘autocommit’ が ‘True’ または *note
          LEGACY_TRANSACTION_CONTROL: 2842. の場合、暗黙のトランザクショ
          ン制御は実行されませんので、保留中の変更が失われないように、デ
          ータベース接続を閉じる前に必ず *note commit(): 2833. を行って
          ください。

      -- メソッド: execute (sql, parameters=(), /)

          新しい *note Cursor: 2830. オブジェクトを作成し、指定の 'sql'
          と 'parameters' で *note execute(): 2b2. を呼び出します。新し
          いカーソル・オブジェクトを返します。

      -- メソッド: executemany (sql, parameters, /)

          新しい *note Cursor: 2830. オブジェクトを作成し、与えられた
          'sql' と 'parameters' で *note executemany(): 2b3. を呼び出し
          ます。新しいカーソル・オブジェクトを返します。

      -- メソッド: executescript (sql_script, /)

          新しい *note Cursor: 2830. オブジェクトを作成し、指定された
          'sql_script' で *note executescript(): 2869. を呼び出します。
          新しいカーソル・オブジェクトを返します。

      -- メソッド: create_function (name, narg, func, *,
               deterministic=False)

          ユーザ定義 SQL 関数を作成または削除します。


          パラメータ:

             * ‘name’ (*note str: 418.) - SQL 関数の名前。

             * ‘narg’ (*note int: 238.) - SQL 関数が受け入れることができ
               る引数の数。 ‘-1’ を指定すると、任意の数の引数を取ること
               ができます。

             * ‘func’ (*note callback: 286a. | None) - この SQL 関数が呼
               び出されたときに起動される *note
               呼び出し可能オブジェクト: 2847. 。 この呼び出し可能オブジ
               ェクトは、 *note SQLite
               によってネイティブにサポートされる型: 283d. を返すす必要
               があります。 既存の SQL 関数を削除するには、 ‘None’ に設
               定します。

             * ‘deterministic’ (*note bool: 434.) - ‘True’ の場合、作成
               された SQL 関数は決定論的(deterministic(1) : 入力が同一な
               ら常に同一の答えを返す)としてマークされ、SQLite が追加の
               最適化を実行できるようになります。

          バージョン 3.8 で変更: Added the 'deterministic' parameter.

          例:

               >>> import hashlib
               >>> def md5sum(t):
               ...     return hashlib.md5(t).hexdigest()
               >>> con = sqlite3.connect(":memory:")
               >>> con.create_function("md5", 1, md5sum)
               >>> for row in con.execute("SELECT md5(?)", (b"foo",)):
               ...     print(row)
               ('acbd18db4cc2f85cedef654fccc4a4d8',)
               >>> con.close()

          バージョン 3.13 で変更: Passing 'name', 'narg', and 'func' as
          keyword arguments is deprecated.  These parameters will become
          positional-only in Python 3.15.

      -- メソッド: create_aggregate (name, n_arg, aggregate_class)

          ユーザ定義集計関数を作成または削除します。


          パラメータ:

             * ‘name’ (*note str: 418.) - SQL 集計関数の名前。

             * ‘n_arg’ (*note int: 238.) - SQL 集計関数が受け入れること
               ができる引数の数。 ‘-1’ を指定すると、任意の数の引数を取
               ることができます。

             * ‘aggregate_class’ (*note class: 189c. | None) - クラスは
               以下のメソッドを実装する必要があります:

                  * ‘step()’: 集計に行(row)を足し込みます。

                  * ‘finalize()’: 集計の最終結果を *note SQLite
                    でネイティブにサポートされている型: 283d. として返し
                    ます。

               ‘step()’ メソッドが受け入れなければならない引数の数は
               'n_arg' によって制御されます。

               既存の SQL 集計関数を削除するには、 ‘None’ に設定します。

          例:

               class MySum:
                   def __init__(self):
                       self.count = 0

                   def step(self, value):
                       self.count += value

                   def finalize(self):
                       return self.count

               con = sqlite3.connect(":memory:")
               con.create_aggregate("mysum", 1, MySum)
               cur = con.execute("CREATE TABLE test(i)")
               cur.execute("INSERT INTO test(i) VALUES(1)")
               cur.execute("INSERT INTO test(i) VALUES(2)")
               cur.execute("SELECT mysum(i) FROM test")
               print(cur.fetchone()[0])

               con.close()

          バージョン 3.13 で変更: Passing 'name', 'n_arg', and
          'aggregate_class' as keyword arguments is deprecated.  These
          parameters will become positional-only in Python 3.15.

      -- メソッド: create_window_function (name, num_params,
               aggregate_class, /)

          ユーザー定義の集計ウインドウ関数を作成または削除します。


          パラメータ:

             * ‘name’ (*note str: 418.) - 作成または削除する SQL 集計ウ
               インドウ関数の名前。

             * ‘num_params’ (*note int: 238.) - SQL 集計ウィンドウ関数が
               受け入れることができる引数の数。 ‘-1’ を指定した場合、任
               意の数の引数を取ることができます。

             * ‘aggregate_class’ (*note class: 189c. | None) - クラスは
               以下のメソッドを実装する必要があります:

                  * ‘step()’: 現在のウィンドウに行を足し込みます。

                  * ‘value()’: 集計の現在の値を返します。

                  * ‘inverse()’: 現在のウインドウから指定の行(row)の分を
                    削除します。

                  * ‘finalize()’: 集計の最終結果を *note SQLite
                    でネイティブにサポートされている型: 283d. として返し
                    ます。

               ‘step()’ メソッドと ‘value()’ メソッドが受け入れなければ
               ならない引数の数は 'num_params' によって制御されます。

               ‘None’ に設定すると、既存の SQL 集計ウィンドウ関数が削除
               されます。


          例外: *note NotSupportedError: 286b. - 集計ウィンドウ関数をサ
          ポートしていない 3.25.0 より古いバージョンの SQLite で使用した
          場合に送出されます。

          Added in version 3.11.

          例:

               # Example taken from https://www.sqlite.org/windowfunctions.html#udfwinfunc
               class WindowSumInt:
                   def __init__(self):
                       self.count = 0

                   def step(self, value):
                       """Add a row to the current window."""
                       self.count += value

                   def value(self):
                       """Return the current value of the aggregate."""
                       return self.count

                   def inverse(self, value):
                       """Remove a row from the current window."""
                       self.count -= value

                   def finalize(self):
                       """Return the final value of the aggregate.

                       Any clean-up actions should be placed here.
                       """
                       return self.count


               con = sqlite3.connect(":memory:")
               cur = con.execute("CREATE TABLE test(x, y)")
               values = [
                   ("a", 4),
                   ("b", 5),
                   ("c", 3),
                   ("d", 8),
                   ("e", 1),
               ]
               cur.executemany("INSERT INTO test VALUES(?, ?)", values)
               con.create_window_function("sumint", 1, WindowSumInt)
               cur.execute("""
                   SELECT x, sumint(y) OVER (
                       ORDER BY x ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
                   ) AS sum_y
                   FROM test ORDER BY x
               """)
               print(cur.fetchall())
               con.close()

      -- メソッド: create_collation (name, callable, /)

          照合関数(collating function) 'callable' を使用して 'name' とい
          う名前の照合(collation)を作成します。 'callable' には 2 つの
          *note 文字列: 418. 引数が渡され、*note 整数: 238. を返す必要が
          あります:

             * 1 番目の文字列が 2 番目の文字列よりも高い順位ならば ‘1’ を
               返す

             * 1 番目の文字列が 2 番目の文字列よりも低い順位ならば ‘-1’
               を返す

             * 1 番目の文字列と 2 番目の文字列が同じ順位ならば ‘0’ を返
               す

          以下は逆順での照合例です:

               def collate_reverse(string1, string2):
                   if string1 == string2:
                       return 0
                   elif string1 < string2:
                       return 1
                   else:
                       return -1

               con = sqlite3.connect(":memory:")
               con.create_collation("reverse", collate_reverse)

               cur = con.execute("CREATE TABLE test(x)")
               cur.executemany("INSERT INTO test(x) VALUES(?)", [("a",), ("b",)])
               cur.execute("SELECT x FROM test ORDER BY x COLLATE reverse")
               for row in cur:
                   print(row)
               con.close()

          照合関数を削除するには 'callable' を ‘None’ に設定します。

          バージョン 3.11 で変更: 照合の名前には任意のユニコード文字を含
          めることができます。 以前は ASCII 文字のみが許可されていました
          。

      -- メソッド: interrupt ()

          このメソッドを別のスレッドから呼び出して、この接続
          (connection)で、実行中のすべてのクエリを中止(abort)させます。
          中止(abort)させられたクエリは *note OperationalError: 1808. を
          送出します。

      -- メソッド: set_authorizer (authorizer_callback)

          データベース内のテーブルの列(column)にアクセスしようとするたび
          に起動される *note 呼び出し可能オブジェクト: 2847.
          'authorizer_callback' を登録します。 このコールバックは背後の
          SQLite ライブラリによって列(column)へのアクセスがどのように処
          理されるかを通知するために、 *note SQLITE_OK: 284a. または
          *note SQLITE_DENY: 284b. または *note SQLITE_IGNORE: 284c. の
          いずれかを返さなければなりません。

          コールバックの最初の引数は、承認(authorize)される操作の種類を
          示します。 2 番目と 3 番目の引数は、最初の引数に応じて、引数ま
          たは ‘None’ になります。 4 番目の引数は、該当する場合、データ
          ベースの名前("main" や "temp" 等)です。 5 番目の引数は、 アク
          セス試行を担当する最も内側のトリガーまたはビューの名前です。こ
          のアクセス試行が入力 SQL コードから直接行われた場合は ‘None’ で
          す。

          最初の引数に指定可能な値と、 最初の引数に応じた 2 番目と 3 番
          目の引数の意味については、 SQLite のドキュメントを参照してくだ
          さい。 必要なすべての定数は ‘sqlite3’ モジュールで利用できます
          。

          'authorizer_callback' として ‘None’ を渡すと、承認機構
          (authorizer)が無効になります。

          バージョン 3.11 で変更: ‘None’ を使用して承認機構
          (authorizer)を無効にするサポートが追加されました。

          バージョン 3.13 で変更: Passing 'authorizer_callback' as a
          keyword argument is deprecated.  The parameter will become
          positional-only in Python 3.15.

      -- メソッド: set_progress_handler (progress_handler, n)

          SQLite 仮想マシンの命令を 'n' 個実行するごとに呼び出されるよう
          に、 *note 呼び出し可能オブジェクト: 2847. 'progress_handler'
          を登録します。これは、 GUI の更新など、長時間実行される操作中
          に SQLite から呼び出されるようにしたい場合に便利です。

          以前にインストールした progress ハンドラーをクリアしたい場合は
          、 'progress_handler' に ‘None’ を指定してメソッドを呼び出しま
          す。

          ハンドラー関数からゼロ以外の値を返すと、現在実行中のクエリを終
          了(terminate)し、 *note DatabaseError: 286d. 例外を送出します
          。

          バージョン 3.13 で変更: Passing 'progress_handler' as a
          keyword argument is deprecated.  The parameter will become
          positional-only in Python 3.15.

      -- メソッド: set_trace_callback (trace_callback)

          SQLite バックエンドによって実際に実行される SQL 文ごとに起動さ
          れる *note 呼び出し可能オブジェクト: 2847. 'trace_callback' を
          登録します。

          コールバックに渡される唯一の引数は、(*note str: 418. として渡
          される)実行中のSQL文です。 コールバックの戻り値は無視されます
          。 バックエンドは、 *note Cursor.execute(): 2b2. メソッドに渡
          されたSQL文を実行するだけではないことに注意してください。
          ‘sqlite3’ モジュールの *note トランザクション管理: 2832. や、
          現在のデータベース内で定義されたトリガーの実行その他も行います
          。

          'trace_callback' として ‘None’ を渡すと、トレース・コールバッ
          クが無効になります。

               注釈: トレース・コールバックで送出した例外は伝播されませ
               ん。 開発およびデバッグの補助として、 *note
               enable_callback_tracebacks(): 2845. を使用して、トレース
               ・コールバックで送出した例外からのトレースバックの出力を
               有効にします。

          Added in version 3.3.

          バージョン 3.13 で変更: Passing 'trace_callback' as a keyword
          argument is deprecated.  The parameter will become
          positional-only in Python 3.15.

      -- メソッド: enable_load_extension (enabled, /)

          'enabled' が ‘True’ の場合、 SQLite エンジンが共有ライブラリか
          ら SQLite 拡張機能をロードできるようにします。 ‘True’ 以外の場
          合は、 SQLite 拡張機能の読み込みを許可しません。 SQLite 拡張機
          能では、新しい関数の定義、または集計の定義、またはまったく新し
          い仮想テーブルの実装を定義できます。 よく知られている拡張機能
          の 1 つは、SQLite と共に配布される全文検索拡張機能です。

               注釈: ‘sqlite3’ モジュールは、デフォルトではロード可能な
               拡張機能をサポートするようにビルドされていません。一部の
               プラットフォーム(特に macOS)には、この機能なしでコンパイ
               ルされた SQLite ライブラリがあるためです。 ロード可能な拡
               張機能のサポートを得るには、 ‘configure’ に *note
               -enable-loadable-sqlite-extensions: 1cd6. オプションを渡
               す必要があります。

          引数 ‘connection’, ‘enabled’ を指定して *note 監査イベント:
          1825. ‘sqlite3.enable_load_extension’ を送出します。

          Added in version 3.2.

          バージョン 3.10 で変更: ‘sqlite3.enable_load_extension’ 監査イ
          ベントを追加しました。

               con.enable_load_extension(True)

               # Load the fulltext search extension
               con.execute("select load_extension('./fts3.so')")

               # alternatively you can load the extension using an API call:
               # con.load_extension("./fts3.so")

               # disable extension loading again
               con.enable_load_extension(False)

               # example from SQLite wiki
               con.execute("CREATE VIRTUAL TABLE recipe USING fts3(name, ingredients)")
               con.executescript("""
                   INSERT INTO recipe (name, ingredients) VALUES('broccoli stew', 'broccoli peppers cheese tomatoes');
                   INSERT INTO recipe (name, ingredients) VALUES('pumpkin stew', 'pumpkin onions garlic celery');
                   INSERT INTO recipe (name, ingredients) VALUES('broccoli pie', 'broccoli cheese onions flour');
                   INSERT INTO recipe (name, ingredients) VALUES('pumpkin pie', 'pumpkin sugar flour butter');
                   """)
               for row in con.execute("SELECT rowid, name, ingredients FROM recipe WHERE name MATCH 'pie'"):
                   print(row)

      -- メソッド: load_extension (path, /, *, entrypoint=None)

          共有ライブラリから SQLite 拡張機能(extension)をロードします。
          このメソッドを呼び出す前に *note enable_load_extension(): 809.
          で拡張機能の読み込みを有効にしてください。


          パラメータ:

             * ‘path’ (*note str: 418.) - SQLite 拡張機能(extension)への
               パス(path)。

             * ‘entrypoint’ (*note str: 418.‘ | ’‘None’) - エントリ・ポ
               イント名。 ‘None’ (デフォルト) の場合、 SQLite は自分自身
               でエントリ・ポイント名を推測します。 詳細については、
               SQLite ドキュメント Loading an Extension(2) を参照してく
               ださい。

          引数 ‘connection’, ‘path’ を指定して *note 監査イベント: 1825.
          ‘sqlite3.load_extension’ を送出します。

          Added in version 3.2.

          バージョン 3.10 で変更: ‘sqlite3.load_extension’ 監査イベント
          を追加しました。

          バージョン 3.12 で変更: Added the 'entrypoint' parameter.

      -- メソッド: iterdump (*, filter=None)

          データベースを SQL ソース・コードとしてダンプする *note
          iterator: 191. を返します。 後で復元するためにメモリ内データベ
          ースを保存する場合に便利です。 ‘sqlite3’ シェルの ‘.dump’ コマ
          ンドに似ています。


          パラメータ: ‘filter’ (*note str: 418.‘ | ’‘None’) - An
          optional ‘LIKE’ pattern for database objects to dump, e.g.
          ‘prefix_%’.  If ‘None’ (the default), all database objects
          will be included.

          例:

               # Convert file example.db to SQL dump file dump.sql
               con = sqlite3.connect('example.db')
               with open('dump.sql', 'w') as f:
                   for line in con.iterdump():
                       f.write('%s\n' % line)
               con.close()

          参考
          ....

          *note How to handle non-UTF-8 text encodings: 286e.

          バージョン 3.13 で変更: 'filter' パラメータが追加されました。

      -- メソッド: backup (target, *, pages=-1, progress=None,
               name='main', sleep=0.250)

          SQLite データベースのバックアップを作成します。

          データベースが他のクライアントによってアクセスされている場合、
          または同一の接続によって並行にアクセスされている場合でも機能し
          ます。


          パラメータ:

             * ‘target’ (*note Connection: 226.) - バックアップ先のデー
               タベース接続(connection)。

             * ‘pages’ (*note int: 238.) - 一度にコピーするページ数。
               ‘0’ 以下の場合、データベース全体がワンステップでコピーさ
               れます。 デフォルトは ‘-1’ です。

             * ‘progress’ (*note callback: 286a. | None) - *note
               呼び出し可能オブジェクト: 2847. を設定すると、バックアッ
               プの指定ページ数単位の反復ごとに 3 つの整数引数で呼び出さ
               れます。 'status' は、最後の反復時のステータスで、
               'remaining' はまだコピーされていない残りのページ数で、
               'total' はコピーされるページの合計です。 デフォルトは
               ‘None’ です。

             * ‘name’ (*note str: 418.) - バックアップするデータベース名
               。 ‘"main"’ (メイン・データベース。これがデフォルトです
               )、または ‘"temp"’ (一時データベース)、 または ‘ATTACH
               DATABASE’ SQL文を使用して取り付けられたカスタム・データベ
               ース名の、いずれかです。

             * ‘sleep’ (*note float: 2ce.) - バックアップの指定ページ数
               単位の反復ごとにスリープする秒数。

          例 1.  既存のデータベースを別のデータベースにコピーします:

               def progress(status, remaining, total):
                   print(f'Copied {total-remaining} of {total} pages...')

               src = sqlite3.connect('example.db')
               dst = sqlite3.connect('backup.db')
               with dst:
                   src.backup(dst, pages=1, progress=progress)
               dst.close()
               src.close()

          例 2.  既存のデータベースを臨時コピー(transient copy)にコピー
          します。

               src = sqlite3.connect('example.db')
               dst = sqlite3.connect(':memory:')
               src.backup(dst)
               dst.close()
               src.close()

          Added in version 3.7.

          参考
          ....

          *note How to handle non-UTF-8 text encodings: 286e.

      -- メソッド: getlimit (category, /)

          接続(connection)の実行時制限を取得します。


          パラメータ: ‘category’ (*note int: 238.) - 問い合わせを行う実
          行時制限カテゴリー(SQLite limit category(3))。


          戻り値の型: *note int: 238.


          例外: *note ProgrammingError: 4bf. - 'category' に、 背後の
          SQLite ライブラリが認識できないカテゴリーを指定した場合に送出
          されます。

          例: *note Connection: 226. の ‘con’ の SQL 文の最大長を照会し
          ます (デフォルトは 1000000000 です):

               >>> con.getlimit(sqlite3.SQLITE_LIMIT_SQL_LENGTH)
               1000000000

          Added in version 3.11.

      -- メソッド: setlimit (category, limit, /)

          接続の実行時制限を設定します。 コンパイル時上限を超えて制限を
          増やそうとすると、 暗黙のうちにコンパイル時上限に切り捨てられ
          ます。 制限が変更されたかどうかに関係なく、 制限の以前の値が返
          されます。


          パラメータ:

             * ‘category’ (*note int: 238.) - SQLite limit category(4) を
               設定する。

             * ‘limit’ (*note int: 238.) - 新しい制限の値。 負数の場合、
               現在の制限は変更されません。


          戻り値の型: *note int: 238.


          例外: *note ProgrammingError: 4bf. - 'category' に、 背後の
          SQLite ライブラリが認識できないカテゴリーを指定した場合に送出
          されます。

          *note Connection: 226. の ‘con’ に対して、取り付けられるデータ
          ベース(attached databases)の数を 1 に制限します (デフォルトの
          制限は 10 です):

               >>> con.setlimit(sqlite3.SQLITE_LIMIT_ATTACHED, 1)
               10
               >>> con.getlimit(sqlite3.SQLITE_LIMIT_ATTACHED)
               1

          Added in version 3.11.

      -- メソッド: getconfig (op, /)

          ブール値の接続構成オプションを問い合わせます。


          パラメータ: ‘op’ (*note int: 238.) - *note SQLITE_DBCONFIG
          code: 2851. を指定します。


          戻り値の型: *note bool: 434.

          Added in version 3.12.

      -- メソッド: setconfig (op, enable=True, /)

          ブール値の接続構成オプションを設定します。


          パラメータ:

             * ‘op’ (*note int: 238.) - *note SQLITE_DBCONFIG code:
               2851. を指定します。

             * ‘enable’ (*note bool: 434.) - 設定オプションを有効にする
               必要がある場合は ‘True’ (デフォルト)。 無効にする場合は
               ‘False’ を指定します。

          Added in version 3.12.

      -- メソッド: serialize (*, name='main')

          データベースを *note bytes: 1a4. オブジェクトに直列化
          (serialize)します。 通常のディスク上のデータベース・ファイルの
          場合、 直列化はディスク・ファイルの単なるコピーです。 インメモ
          リ・データベースまたは "temp" データベースの場合、 直列化は、
          そのデータベースがディスクにバックアップされた場合にディスクに
          書き込まれるバイト・シーケンスと同じです。


          パラメータ: ‘name’ (*note str: 418.) - 直列化するデータベース
          名。 デフォルトは ‘"main"’ です。


          戻り値の型: *note bytes: 1a4.

               注釈: このメソッドは、 背後の SQLite ライブラリに直列化
               API がある場合にのみ使用できます。

          Added in version 3.11.

      -- メソッド: deserialize (data, /, *, name='main')

          *note 直列化: 64a. されたデータベースを *note Connection: 226.
          に、 脱直列化(deserialize)します。 このメソッドにより、 データ
          ベース接続はデータベース 'name' から切断され、そして、 'data'
          に含まれる直列化データに基づいて、 データベース 'name' がイン
          メモリ・データベースとして再度開かれます。


          パラメータ:

             * ‘data’ (*note bytes: 1a4.) - 直列化されたデータベース。

             * ‘name’ (*note str: 418.) - 脱直列化(deserialize)したデー
               タを入れるデータベース名。 デフォルトは ‘"main"’ です。


          例外:

             * *note OperationalError: 1808. - データベース接続が読み取
               りトランザクションやバックアップ操作中の場合。

             * *note DatabaseError: 286d. - 'data' に有効な SQLite デー
               タベースが含まれていない場合。

             * *note OverflowError: 84e. - *note len(data): 5fa. が
               ‘2**63 - 1’ より大きい場合。

               注釈: このメソッドは、 背後の SQLite ライブラリに脱直列化
               API がある場合にのみ使用できます。

          Added in version 3.11.

      -- の属性: autocommit

          この属性は、 PEP 249(5) 対応のトランザクションの振る舞いを制御
          します。 ‘auto​​commit’ には以下の 3 つの値が指定できます:

             * ‘False’: PEP 249(6) 対応のトランザクションの振る舞いを選
               びます。 これは、 ‘sqlite3’ が、 トランザクションが常に開
               いていることを保証することを意味します。トランザクション
               を閉じるには、 *note commit(): 2833. や *note rollback():
               2865. を使用します。

               これが ‘auto​​commit’ の推奨値です。

             * ‘True’: SQLite の autocommit mode(7) を使用します。このモ
               ードでは *note commit(): 2833. や *note rollback(): 2865.
               は効果がありません。

             * *note LEGACY_TRANSACTION_CONTROL: 2842.: Python 3.12 より
               前( PEP 249(8) 非対応)のトランザクション制御。 詳細につい
               ては *note isolation_level: 2840. を参照してください。

               これが、今のところは、 ‘auto​​commit’ のデフォルト値です。

          ‘auto​​commit’ を ‘False’ に変更すると新しいトランザクションが開
          き、 ‘True’ に変更すると保留中のトランザクションがコミットされ
          ます。

          詳細は *note autocommit 属性に依るトランザクション制御: 483. を
          参照してください。

               注釈: *note isolation_level: 2840. 属性は、 *note
               autocommit: 482. の値が *note LEGACY_TRANSACTION_CONTROL:
               2842. でない限り、効果がありません。

          Added in version 3.12.

      -- の属性: in_transaction

          この読み取り専用属性は、低レベルの SQLite autocommit mode(9) に
          対応します。

          トランザクションがアクティブな場合 (コミットされていない変更が
          ある場合) は ‘True’ 、それ以外の場合は ‘False’ です。

          Added in version 3.2.

      -- の属性: isolation_level

          ‘sqlite3’ の *note 旧来のトランザクション処理モード: 2841. を
          制御します。 ‘None’ に設定すると、トランザクションは暗黙に開か
          れることはありません。背後の SQLite の SQLite transaction
          behaviour(10) に対応する ‘"DEFERRED"’ または ‘"IMMEDIATE"’ ま
          たは ‘"EXCLUSIVE"’ のいずれかに設定すると、 *note
          暗黙のトランザクション管理: 2841. が実行されます。

          *note connect(): 288. の 'isolation_level' パラメーターでオー
          バーライドされない場合、 デフォルトは ‘""’ で、 これは
          ‘"DEFERRED"’ の別名です。

               注釈: トランザクション処理を制御するには、
               ‘isolation_level’ を使用するよりも *note autocommit: 482.
               を使用することをお勧めします。 *note autocommit: 482. が
               *note LEGACY_TRANSACTION_CONTROL: 2842. (これがデフォルト
               です)に設定されていない限り、 ‘isolation_level’ は効果が
               ありません。

      -- の属性: row_factory

          この接続から作成された *note Cursor: 2830. オブジェクトの初期
          *note row_factory: 2870. 。この属性に割り当てを行っても、 この
          接続に属する、すでに存在するカーソルの ‘row_factory’ には影響
          せず、 この属性に割り当てを行った後に作成する新しいカーソルの
          みに影響します。 デフォルトでは ‘None’ です。つまり、各行は
          *note タプル: 349. として返されます。

          詳細は *note 行工場(row factories)の作成方法と使用方法: 2837.
          をご覧下さい。

      -- の属性: text_factory

          *note bytes: 1a4. のパラメータを受け取り、そのテキスト表現を返
          す *note 呼び出し可能オブジェクト: 2847. です。呼び出し可能オ
          ブジェクトは ‘TEXT’ データ型である SQLite 値に対して呼び出され
          ます。 デフォルトでは、 この属性は *note str: 418. に設定され
          ています。

          See *note How to handle non-UTF-8 text encodings: 286e. for
          more details.

      -- の属性: total_changes

          データベース接続が開かれてから、変更または挿入または削除された
          データベース行の総数を返します。

   ---------- Footnotes ----------

   (1) https://sqlite.org/deterministic.html

   (2) https://www.sqlite.org/loadext.html#loading_an_extension

   (3) https://www.sqlite.org/c3ref/c_limit_attached.html

   (4) https://www.sqlite.org/c3ref/c_limit_attached.html

   (5) https://peps.python.org/pep-0249/

   (6) https://peps.python.org/pep-0249/

   (7) 
https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions

   (8) https://peps.python.org/pep-0249/

   (9) 
https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions

   (10) 
https://www.sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions


File: python.info,  Node: Cursor オブジェクト,  Next: Row オブジェクト,  Prev: Connection オブジェクト,  Up: リファレンス

5.12.6.6 Cursor オブジェクト
............................

     ‘Cursor’ オブジェクトは、 SQL 文を実行し、 取得操作(fetch
     operation)のコンテキストを管理するために使用されるデータベース・カ
     ーソル(database cursor(1))を表します。カーソルは、 *note
     Connection.cursor(): 282f. または *note
     接続(connection)ショートカット・メソッド: 2864. の、いずれかを使用
     して作成されます。

     カーソル・オブジェクトは *note イテレータ: 191. です。つまり、
     ‘SELECT’ クエリに対して *note execute(): 2b2. した場合、結果の行
     (rows)を取得するためには、カーソルを単純に反復(iterate)できます:

          for row in cur.execute("SELECT t FROM data"):
              print(row)

 -- クラス: sqlite3.Cursor

     *note Cursor: 2830. インスタンスは以下の属性やメソッドを持ちます。

      -- メソッド: execute (sql, parameters=(), /)

          Execute a single SQL statement, optionally binding Python
          values using *note placeholders: 2b4.


          パラメータ:

             * ‘sql’ (*note str: 418.) - 単一の SQL 文。

             * ‘parameters’ (*note dict: 237. | *note sequence: 4be.) -
               'sql' のプレースホルダに結び付け(bind)する Python 値。 名
               前付きプレースホルダが使用されている場合は ‘dict’ です。
               名前のないプレースホルダが使用されている場合は sequence で
               す。 *note プレースホルダを使用して SQL
               クエリに値を結び付ける方法: 2b4. を参照してください。


          例外: *note ProgrammingError: 4bf. - 'sql' に複数の SQL 文が含
          まれている場合。

          *note autocommit: 482. が *note LEGACY_TRANSACTION_CONTROL:
          2842. で、かつ、 *note isolation_level: 2840. が ‘None’ で無く
          、 かつ、 'sql' が ‘INSERT’ または ‘UPDATE’ または ‘DELETE’ ま
          たは ‘REPLACE’ 文で、かつ、開いているトランザクションがない場
          合、 'sql' を実行する前にトランザクションが暗黙に開かれます。

          Deprecated since version 3.12, will be removed in version
          3.14: *note 名前付きプレースホルダー: 2b4. が使用され、かつ、
          パラメーターが *note dict: 237. ではなくシーケンスである場合、
          *note DeprecationWarning: 18a. を送出します。 Python 3.14 以降
          では、代わりに *note ProgrammingError: 4bf. を送出します。

          複数の SQL 文を実行するには *note executescript(): 2869. を使
          用します。

      -- メソッド: executemany (sql, parameters, /)

          'parameters' のすべての item に対して、 *note パラメーター化:
          2b4. された DML (Data Manipulation Language) SQL 文である
          'sql' を繰り返し実行します。

          *note execute(): 2b2. と同一の暗黙のトランザクション処理を使用
          します。


          パラメータ:

             * ‘sql’ (*note str: 418.) - 単一の DML 文。

             * ‘parameters’ (*note iterable: 10ad.) - 'sql' のプレースホ
               ルダに結び付け(bind)するためのパラメータの iterable 。
               *note プレースホルダを使用して SQL
               クエリに値を結び付ける方法: 2b4. 参照。


          例外: *note ProgrammingError: 4bf. - If 'sql' contains more
          than one SQL statement, or is not a DML statement.

          例:

               rows = [
                   ("row1",),
                   ("row2",),
               ]
               # cur is an sqlite3.Cursor object
               cur.executemany("INSERT INTO data VALUES(?)", rows)

               注釈: RETURNING 句(RETURNING clauses(2))を含むDML文を含め
               、結果の行はすべて破棄されます。

          Deprecated since version 3.12, will be removed in version
          3.14: *note 名前付きプレースホルダー: 2b4. が使用され、かつ、
          パラメーターが *note dict: 237. ではなくシーケンスである場合、
          *note DeprecationWarning: 18a. を送出します。 Python 3.14 以降
          では、代わりに *note ProgrammingError: 4bf. を送出します。

      -- メソッド: executescript (sql_script, /)

          'sql_script' 内の複数のSQL文を実行します。 *note autocommit:
          482. が *note LEGACY_TRANSACTION_CONTROL: 2842. で、かつ、保留
          中のトランザクションがある場合、暗黙の ‘COMMIT’ 文が最初に実行
          されます。その他の暗黙のトランザクション制御は実行されませんの
          で、トランザクション制御を 'sql_script' に追加しなければなりま
          せん。

          'sql_script' は *note 文字列: 418. でなければなりません。

          例:

               # cur is an sqlite3.Cursor object
               cur.executescript("""
                   BEGIN;
                   CREATE TABLE person(firstname, lastname, age);
                   CREATE TABLE book(title, author, published);
                   CREATE TABLE publisher(name, address);
                   COMMIT;
               """)

      -- メソッド: fetchone ()

          *note row_factory: 2870. が ‘None’ の場合、 次の行のクエリ結果
          セットを *note タプル: 349. として返します。それ以外の場合は、
          それを行工場(row factory)に渡し、 その結果を返します。 これ以
          上データが無い場合は ‘None’ を返します。

      -- メソッド: fetchmany (size=cursor.arraysize)

          クエリ結果の次の行セットを *note list: 5dc. として返します。行
          がそれ以上ない場合は、空のリストを返します。

          呼び出しごとに取得する行数は、'size' パラメーターで指定されま
          す。 'size' が指定されていない場合、 *note arraysize: 2876. が
          取得する行数を決定します。有効な行の数が 'size' 未満の場合は、
          有効な数の行が返されます。

          'size' 引数とパフォーマンスの関係についての注意です。パフォー
          マンスを最適化するためには、大抵、 arraysize 属性を利用するの
          がベストです。 'size' 引数を利用したのであれば、次回の *note
          fetchmany(): 2875. の呼び出しでも 'size' 引数に同一の値を指定
          するのがのがベストです。

      -- メソッド: fetchall ()

          クエリ結果の(残りの)すべての行を *note list: 5dc. として返しま
          す。 有効な行がない場合は、空のリストを返します。 *note
          arraysize: 2876. 属性は、この操作のパフォーマンスに影響を与え
          る可能性があることに注意してください。

      -- メソッド: close ()

          (‘__del__’ が呼び出される時ではなく、) 今すぐカーソルを閉じま
          す。

          この時点から、このカーソルは使用できなくなります。今後、このカ
          ーソルで何らかの操作を試みると、 *note ProgrammingError: 4bf.
          例外が送出されます。

      -- メソッド: setinputsizes (sizes, /)

          DB-API で必要です。 ‘sqlite3’ では何もしません。

      -- メソッド: setoutputsize (size, column=None, /)

          DB-API で必要です。 ‘sqlite3’ では何もしません。

      -- の属性: arraysize

          *note fetchmany(): 2875. によって返される行(row)数を制御する、
          読み取りと書き込みが可能な属性。 デフォルト値は 1 で、これは呼
          び出しごとに 1 行が取得されることを意味します。

      -- の属性: connection

          カーソルが属する SQLite データベース *note Connection: 226. を
          提供する読み取り専用属性。 *note con.cursor(): 282f. と呼び出
          して作成した *note Cursor: 2830. オブジェクトには、'con' を参
          照する *note connection: 287a. 属性があります:

               >>> con = sqlite3.connect(":memory:")
               >>> cur = con.cursor()
               >>> cur.connection == con
               True
               >>> con.close()

      -- の属性: description

          最後のクエリの列(column)名を提供する読み取り専用属性。 Python
          DB API との互換性を維持するために、各列ごとに 7 項目のタプルで
          、先頭の項目が列名、残りの6項目が ‘None’ です。

          この属性は ‘SELECT’ 文にマッチする行(row)が1つもなかった場合で
          もセットされます。

      -- の属性: lastrowid

          最後に挿入された行の行 ID (row id) を提供する読み取り専用属性
          。 *note execute(): 2b2. で ‘INSERT’ または ‘REPLACE’ 文が成功
          した後にのみ更新されます。他のSQL文や、 *note executemany():
          2b3. の後や、 *note executescript(): 2869. の後や、 挿入が失敗
          した場合、 ‘lastrowid’ の値は変更されません。‘lastrowid’ の初
          期値は ‘None’ です。

               注釈: ‘WITHOUT ROWID’ テーブルへの挿入(insert)は記録され
               ません。

          バージョン 3.6 で変更: ‘REPLACE’ 文のサポートが追加されました
          。

      -- の属性: rowcount

          ‘INSERT’ や ‘UPDATE’ や ‘DELETE’ や ‘REPLACE’ 文で変更された行
          数を提供する読み取り専用属性。 CTE (共通テーブル式) クエリを含
          む他のSQL文は ‘-1’ です。 *note execute(): 2b2. と *note
          executemany(): 2b3. メソッドのみにおいて、 SQL文(statement)実
          行の完了後に更新されます。 なぜなら ‘rowcount’ を更新するため
          には、結果の行を取得(fetch)しなければならないからです。

      -- の属性: row_factory

          この ‘カーソル’ から取得された行の表現方法を制御します。
          ‘None’ の場合、行は *note タプル: 349. として表されます。
          *note sqlite3.Row: e3a. に設定することもできます。 そしてまた
          、 *note Cursor: 2830. オブジェクトと、 行の値の ‘タプル’ の、
          2 つの引数を受け取り、 SQLite の行(row)を表すカスタム・オブジ
          ェクトを返す、 *note 呼び出し可能オブジェクト: 2847. に設定す
          ることもできます。

          ‘カーソル・オブジェクト’ の作成時に *note
          Connection.row_factory: 1592. の値をこの属性のデフォルト値とし
          て設定します。この属性に割り当てても、親接続(parent
          connection)の *note Connection.row_factory: 1592. には影響しま
          せん。

          詳細は *note 行工場(row factories)の作成方法と使用方法: 2837.
          をご覧下さい。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Cursor_(databases)

   (2) https://www.sqlite.org/lang_returning.html


File: python.info,  Node: Row オブジェクト,  Next: Blob オブジェクト,  Prev: Cursor オブジェクト,  Up: リファレンス

5.12.6.7 Row オブジェクト
.........................

 -- クラス: sqlite3.Row

     ‘Row’ インスタンスは、 *note Connection: 226. オブジェクトの、高度
     に最適化された *note row_factory: 1592. の役割をします。 反復
     (iteration)や、等しいかどうかのテスト(equality testing)や、 *note
     len(): 5fa. 関数や 、 列名(column name)とインデックスによる *note
     マッピング: 118c. のアクセスを、サポートします。

     列名(column names)と値(values)が全く同一である 2 つの ‘Row’ オブジ
     ェクトを比較すると、等しいと見なされます。

     詳細は *note 行工場(row factories)の作成方法と使用方法: 2837. をご
     覧下さい。

      -- メソッド: keys ()

          列名(column names)の *note リスト: 5dc. を *note 文字列: 418.
          として返します。 クエリの直後であれば、それは *note
          Cursor.description: 287b. の各タプルの最初のメンバーです。

     バージョン 3.5 で変更: スライスがサポートされました。


File: python.info,  Node: Blob オブジェクト,  Next: PrepareProtocol オブジェクト,  Prev: Row オブジェクト,  Up: リファレンス

5.12.6.8 Blob オブジェクト
..........................

 -- クラス: sqlite3.Blob

     Added in version 3.11.

     *note Blob: 64e. インスタンスは、 SQLite の BLOB とデータを読み書き
     できる *note file-like object: 24e0. です。 *note len(blob): 5fa. を
     呼び出して、 Blob のサイズ (バイト数) を取得します。 Blob データに
     直接アクセスするには、インデックスと *note スライス: 20e3. を使用し
     ます。

     *note Blob: 64e. を *note コンテキストマネージャ: 59e. として使用し
     て、 使用後に Blob ハンドルが確実に閉じられるようにします。

          con = sqlite3.connect(":memory:")
          con.execute("CREATE TABLE test(blob_col blob)")
          con.execute("INSERT INTO test(blob_col) VALUES(zeroblob(13))")

          # Write to our blob, using two write operations:
          with con.blobopen("test", "blob_col", 1) as blob:
              blob.write(b"hello, ")
              blob.write(b"world.")
              # Modify the first and last bytes of our blob
              blob[0] = ord("H")
              blob[-1] = ord("!")

          # Read the contents of our blob
          with con.blobopen("test", "blob_col", 1) as blob:
              greeting = blob.read()

          print(greeting)  # outputs "b'Hello, world!'"
          con.close()

      -- メソッド: close ()

          Blob を閉じます。

          この時点から、 BLOB は使用できなくなります。 BLOB に対してさら
          に操作を試みると、 *note Error: 17eb. (またはそのサブクラスの)
          例外を送出します。

      -- メソッド: read (length=-1, /)

          BLOB の現在のオフセット位置から 'length' バイトのデータを読み
          取り返ます。 BLOB の現在のオフセット位置から末尾までの残りが
          'length' バイトよりも少ない場合、末尾までのデータを読み取りま
          す。 'length' が指定されていない場合、 または負数の場合、
          *note read(): 2883. は BLOB の現在のオフセット位置から末尾まで
          のデータを読み取ります。

      -- メソッド: write (data, /)

          BLOB の現在のオフセット位置から 'data' を書き込みます。 この関
          数では BLOB の長さを変更できません。 BLOB の末尾を超えて書き込
          もうとすると *note ValueError: 1e3. を送出します。

      -- メソッド: tell ()

          BLOBの現在のオフセット位置(current access position)を返します
          。

      -- メソッド: seek (offset, origin=os.SEEK_SET, /)

          Set the current access position of the blob to 'offset'.  The
          'origin' argument defaults to *note os.SEEK_SET: 125e.
          (absolute blob positioning).  Other values for 'origin' are
          *note os.SEEK_CUR: 125f. (seek relative to the current
          position) and *note os.SEEK_END: 1260. (seek relative to the
          blob’s end).


File: python.info,  Node: PrepareProtocol オブジェクト,  Next: 例外<7>,  Prev: Blob オブジェクト,  Up: リファレンス

5.12.6.9 PrepareProtocol オブジェクト
.....................................

 -- クラス: sqlite3.PrepareProtocol

     PrepareProtocol 型の唯一の目的は、 *note SQLite
     でネイティブにサポートされている型: 283d. に *note
     オブジェクト自身で適合(adapt): 2888. できるオブジェクトの PEP
     246(1) スタイルの適合プロトコルとして機能することです。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0246/


File: python.info,  Node: 例外<7>,  Next: SQLite と Python の型,  Prev: PrepareProtocol オブジェクト,  Up: リファレンス

5.12.6.10 例外
..............

例外の階層は DB-API 2.0 ( PEP 249(1)) で定義されています。

 -- 例外: sqlite3.Warning

     この例外は、現在 ‘sqlite3’ モジュールでは送出しませんが、ユーザー定
     義関数が挿入処理中にデータを切り捨てる場合など、‘sqlite3’ を使用す
     るアプリケーションによって送出されるる可能性があります。 ‘Warning’
     は *note Exception: 9a7. のサブクラスです。

 -- 例外: sqlite3.Error

     このモジュールの他の例外の基底となるクラス。 これを使用すると、1 つ
     の *note except: 170. 文ですべてのエラーをキャッチできます。
     ‘Error’ は *note Exception: 9a7. のサブクラスです。

     例外が SQLite ライブラリ内で発生した場合、 以下の 2 つの属性が例外
     に追加されます:

      -- の属性: sqlite_errorcode

          SQLite API(2) からの数値エラー・コード

          Added in version 3.11.

      -- の属性: sqlite_errorname

          SQLite API(3) からの数値エラー・コードの記号名

          Added in version 3.11.

 -- 例外: sqlite3.InterfaceError

     低レベルの SQLite C API の誤用により送出される例外。 つまり、この例
     外が送出された場合、おそらく ‘sqlite3’ モジュールのバグを示していま
     す。 ‘InterfaceError’ は *note Error: 17eb. のサブクラスです。

 -- 例外: sqlite3.DatabaseError

     データベースに関連するエラーに対して送出される例外。 これは、いくつ
     かの種類のデータベース・エラーの基底の例外として機能します。 これを
     特殊化(specialise)したサブクラスを介して暗黙的にのみ送出されます。
     ‘DatabaseError’ は *note Error: 17eb. のサブクラスです。

 -- 例外: sqlite3.DataError

     範囲外の数値や長すぎる文字列など、処理されたデータの問題によって発
     生したエラーに対して送出される例外。 ‘DataError’ は *note
     DatabaseError: 286d. のサブクラスです。

 -- 例外: sqlite3.OperationalError

     データベースの操作に関連し、必ずしもプログラマの制御下にないエラー
     に対して発生する例外。 たとえば、データベース・パスが見つからないと
     か、トランザクションを処理できませんでした等。 ‘OperationalError’ は
     *note DatabaseError: 286d. のサブクラスです。

 -- 例外: sqlite3.IntegrityError

     データベースの参照整合性が影響を受ける場合に発生する例外。 たとえば
     外部キーのチェック(foreign key check)が失敗したとき。 *note
     DatabaseError: 286d. のサブクラスです。

 -- 例外: sqlite3.InternalError

     SQLite が内部エラーに遭遇したときに発生する例外。 これが送出された
     場合、ランタイム SQLite ライブラリに問題があることを示している可能
     性があります。 ‘InternalError’ は *note DatabaseError: 286d. のサブ
     クラスです。

 -- 例外: sqlite3.ProgrammingError

     ‘sqlite3’ API プログラミング・エラーに対して送出される例外。たとえ
     ば、クエリに間違った数のバインディング(結び付け)を指定したり、閉じ
     た後の *note Connection: 226. を操作しようとしたりしたとき。
     ‘ProgrammingError’ は *note DatabaseError: 286d. のサブクラスです。

 -- 例外: sqlite3.NotSupportedError

     メソッドまたはデータベース API が 背後の SQLite ライブラリでサポー
     トしていない場合に送出される例外。たとえば、背後の SQLite ライブラ
     リが決定論的関数(deterministic functions)をサポートしていない場合に
     、*note create_function(): 289. で 'deterministic' を ‘True’ に設定
     したとき。 ‘NotSupportedError’ は *note DatabaseError: 286d. のサブ
     クラスです。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0249/

   (2) https://sqlite.org/rescode.html

   (3) https://sqlite.org/rescode.html


File: python.info,  Node: SQLite と Python の型,  Next: デフォルトの適合関数 adapters とデフォルトの変換関数 converters 非推奨,  Prev: 例外<7>,  Up: リファレンス

5.12.6.11 SQLite と Python の型
...............................

SQLite は以下の型をネイティブにサポートします: ‘NULL’, ‘INTEGER’,
‘REAL’, ‘TEXT’, ‘BLOB’。

したがって、次の Python の型は問題なく SQLite に送り込めます:

Python の型                         SQLite の型
                                    
------------------------------------------------------
                                    
‘None’                              ‘NULL’
                                    
                                    
*note int: 238.                     ‘INTEGER’
                                    
                                    
*note float: 2ce.                   ‘REAL’
                                    
                                    
*note str: 418.                     ‘TEXT’
                                    
                                    
*note bytes: 1a4.                   ‘BLOB’
                                    

SQLite の型から Python の型へのデフォルトでの変換は以下の通りです:

SQLite の型       Python の型
                  
---------------------------------------------------------------------
                  
‘NULL’            ‘None’
                  
                  
‘INTEGER’         *note int: 238.
                  
                  
‘REAL’            *note float: 2ce.
                  
                  
‘TEXT’            *note text_factory: 2871. に依存する。デフォルト
                  では *note str: 418. 。
                  
                  
‘BLOB’            *note bytes: 1a4.
                  

‘sqlite3’ モジュールの型システムは 2 つの方法で拡張可能です。 *note
オブジェクト適合関数(adapter): 2835. を介して SQLite データベースに追加
の Python 型を格納できます。 または、 *note 変換関数(converter): 2836. を
介して ‘sqlite3’ モジュールが SQLite 型を Python 型に変換できます。


File: python.info,  Node: デフォルトの適合関数 adapters とデフォルトの変換関数 converters 非推奨,  Next: コマンドライン・インターフェース,  Prev: SQLite と Python の型,  Up: リファレンス

5.12.6.12 デフォルトの適合関数(adapters)とデフォルトの変換関数(converters)(非推奨)
..................................................................................

     注釈: デフォルトの適合関数(adapters)とデフォルトの変換関数
     (converters)は、 Python 3.12 以降非推奨になりました。代わりに、
     *note 適合関数と変換関数のレシピ集: 4bd. を利用して、あなたのニーズ
     に合わせて仕立てて下さい。

非推奨の、デフォルトの適合関数(adapters)とデフォルトの変換関数
(converters)は以下のもので構成されています:

   * *note datetime.date: 1af. オブジェクトを ISO 8601(1) 形式の *note
     文字列: 418. にする適合関数(adapter)。

   * *note datetime.datetime: 1ae. オブジェクトを ISO 8601 形式の文字列
     にする適合関数(adapter)。

   * "date" と *note 宣言された: 2836. 型を *note datetime.date: 1af. オ
     ブジェクトにする変換関数(converter)。

   * "timestamp" と宣言された型を *note datetime.datetime: 1ae. オブジェ
     クトにする変換関数(converter)。小数部分は 6 桁 (マイクロ秒の精度) に
     切り捨てられます。

     注釈: デフォルトの "timestamp" 変換関数は、データベース内の UTC オ
     フセットを無視し、常に素朴(naive)な *note datetime.datetime: 1ae. オ
     ブジェクトを返します。 timestamp で UTC オフセットを保持するには、
     変換関数を無効のままにするか、あるいは、オフセット対応の変換関数を
     *note register_converter(): 283c. に登録します。

バージョン 3.12 で非推奨.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/ISO_8601


File: python.info,  Node: コマンドライン・インターフェース,  Prev: デフォルトの適合関数 adapters とデフォルトの変換関数 converters 非推奨,  Up: リファレンス

5.12.6.13 コマンドライン・インターフェース
..........................................

‘sqlite3’ モジュールは、単純な SQLite シェルを提供するために、インタプリ
タで *note -m: 5ab. スイッチを使用してスクリプトとして呼び出すことができ
ます。引数は以下のとおりです:

     python -m sqlite3 [-h] [-v] [filename] [sql]

‘.quit’ または CTRL-D を入力するとシェルを終了(exit)します。

 -- Option: -h, --help

     CLI ヘルプを表示。

 -- Option: -v, --version

     背後の SQLite ライブラリのバージョンを出力します。

Added in version 3.12.


File: python.info,  Node: ハウツー・ガイド,  Next: 説明,  Prev: リファレンス,  Up: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース

5.12.6.14 ハウツー・ガイド
..........................

* Menu:

* プレースホルダを使用して SQL クエリに値を結び付ける方法::
* カスタム Python 型を SQLite 値に適合させる方法::
* SQLite 値をカスタム Python 型に変換する方法::
* 適合関数と変換関数のレシピ集::
* 接続(connection)ショートカット・メソッドの使い方: 接続 connection ショートカット・メソッドの使い方.
* 接続(connection)コンテキストマネージャの使い方: 接続 connection コンテキストマネージャの使い方.
* SQLite URI の操作方法::
* 行工場(row factories)の作成方法と使用方法: 行工場 row factories の作成方法と使用方法.
* How to handle non-UTF-8 text encodings::


File: python.info,  Node: プレースホルダを使用して SQL クエリに値を結び付ける方法,  Next: カスタム Python 型を SQLite 値に適合させる方法,  Up: ハウツー・ガイド

5.12.6.15 プレースホルダを使用して SQL クエリに値を結び付ける方法
.................................................................

たいてい、SQL 操作は Python 変数の値を使う必要があります。しかし、
Python の文字列操作を使用してクエリを組み立てるのはSQLインジェクション攻
撃(SQL injection attacks(1))に対して脆弱なので注意が必要です。たとえば、
攻撃者は以下のように単純にシングルクォートを閉じて ‘OR TRUE’ を挿入して
すべての行を選択できます:

     >>> # Never do this -- insecure!
     >>> symbol = input()
     ' OR TRUE; --
     >>> sql = "SELECT * FROM stocks WHERE symbol = '%s'" % symbol
     >>> print(sql)
     SELECT * FROM stocks WHERE symbol = '' OR TRUE; --'
     >>> cur.execute(sql)

代わりに、DB-API のパラメータ割り当てを使います。クエリ文字列にPythonの
変数を挿入するには、クエリ文字列中でプレースホルダを使用し、 かつ、 カー
ソルの *note execute(): 2b2. メソッドの 2 番目の引数にPythonの変数を値の
*note タプル: 349. として指定することにより、 実際の値をクエリに割り当て
ます。

SQL 文では、疑問符 (qmark スタイル) または名前付きプレースホルダー (名前
付きスタイル) の 2 種類のプレースホルダーのいずれかを使用できます。
qmark スタイルの場合、'parameters' は、 *note シーケンス: 4be. でなけれ
ばならず、シーケンスの長さがプレースホルダーの数と一致する必要があります
。そうでなければ、 *note ProgrammingError: 4bf. を送出します。名前付きス
タイルの場合、 'parameters' は *note dict: 237. (またはそのサブクラス) の
インスタンスである必要があり、すべての名前付きパラメーターのキーが含まれ
ている必要があります。余分な項目は無視されます。両方のスタイルの例を以下
に示します。

     con = sqlite3.connect(":memory:")
     cur = con.execute("CREATE TABLE lang(name, first_appeared)")

     # This is the named style used with executemany():
     data = (
         {"name": "C", "year": 1972},
         {"name": "Fortran", "year": 1957},
         {"name": "Python", "year": 1991},
         {"name": "Go", "year": 2009},
     )
     cur.executemany("INSERT INTO lang VALUES(:name, :year)", data)

     # This is the qmark style used in a SELECT query:
     params = (1972,)
     cur.execute("SELECT * FROM lang WHERE first_appeared = ?", params)
     print(cur.fetchall())
     con.close()

     注釈: PEP 249(2) numeric プレースホルダは 'サポートされていません'
     。 使用すると、名前付きプレースホルダとして解釈されます。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/SQL_injection

   (2) https://peps.python.org/pep-0249/


File: python.info,  Node: カスタム Python 型を SQLite 値に適合させる方法,  Next: SQLite 値をカスタム Python 型に変換する方法,  Prev: プレースホルダを使用して SQL クエリに値を結び付ける方法,  Up: ハウツー・ガイド

5.12.6.16 カスタム Python 型を SQLite 値に適合させる方法
........................................................

SQLite は、 限られたデータ型のみをネイティブにサポートします。 カスタム
Python 型を SQLite データベースに保存するには、 *note SQLite
がネイティブに理解できる Python 型: 283d. のいずれかに '適合' (adapt)さ
せます。

Python オブジェクトを SQLite の型に適合させる方法は 2 つあります。それは
、オブジェクト自体を適合させる方法と、 'adapter callable' を使用する方法
です。 後者は前者よりも優先されます。 カスタム型をエクスポートするライブ
ラリの場合、 その型がそれ自体を適合させる事ができるようにすることが理に
かなっている場合があります。 アプリケーション開発者としては、カスタム適
合関数を登録して直接制御する方が理にかなっている場合もあります。

* Menu:

* 適合可能オブジェクトの書き方::
* 適合用呼び出し可能オブジェクト(adapter callables)の登録方法: 適合用呼び出し可能オブジェクト adapter callables の登録方法.


File: python.info,  Node: 適合可能オブジェクトの書き方,  Next: 適合用呼び出し可能オブジェクト adapter callables の登録方法,  Up: カスタム Python 型を SQLite 値に適合させる方法

5.12.6.17 適合可能オブジェクトの書き方
......................................

直交座標系(Cartesian coordinate system)で ‘x’ と ‘y’ のペアで座標を表す
、 ‘Point’ クラスがあるとします。 この ‘x’ と ‘y’ のペアはセミコロンで区
切られたテキスト文字列としてデータベースに保存されます。 これは、適合し
た値を返す ‘__conform__(self, protocol)’ メソッドを追加することで実装で
きます。 'protocol' に渡されるオブジェクトは、 *note PrepareProtocol:
174d. 型になります。

     class Point:
         def __init__(self, x, y):
             self.x, self.y = x, y

         def __conform__(self, protocol):
             if protocol is sqlite3.PrepareProtocol:
                 return f"{self.x};{self.y}"

     con = sqlite3.connect(":memory:")
     cur = con.cursor()

     cur.execute("SELECT ?", (Point(4.0, -3.2),))
     print(cur.fetchone()[0])
     con.close()


File: python.info,  Node: 適合用呼び出し可能オブジェクト adapter callables の登録方法,  Prev: 適合可能オブジェクトの書き方,  Up: カスタム Python 型を SQLite 値に適合させる方法

5.12.6.18 適合用呼び出し可能オブジェクト(adapter callables)の登録方法
.....................................................................

別の策としては、Python オブジェクトを SQLite 互換の型に変換する関数を作
成することが挙げられます。 この関数は、 *note register_adapter(): 2846.
を使用して登録できます。

     class Point:
         def __init__(self, x, y):
             self.x, self.y = x, y

     def adapt_point(point):
         return f"{point.x};{point.y}"

     sqlite3.register_adapter(Point, adapt_point)

     con = sqlite3.connect(":memory:")
     cur = con.cursor()

     cur.execute("SELECT ?", (Point(1.0, 2.5),))
     print(cur.fetchone()[0])
     con.close()


File: python.info,  Node: SQLite 値をカスタム Python 型に変換する方法,  Next: 適合関数と変換関数のレシピ集,  Prev: カスタム Python 型を SQLite 値に適合させる方法,  Up: ハウツー・ガイド

5.12.6.19 SQLite 値をカスタム Python 型に変換する方法
.....................................................

適合関数(adapter)を使用すると、カスタム Python 型から SQLite 値に変換で
きます。SQLite 値 から カスタム Python 型に変換できるようにするためには
、 '変換関数' (converters)を使用します。

それでは ‘Point’ クラスの話に戻るとしましょう。 先程は x 座標と y 座標を
セミコロンで区切られた文字列として SQLite に格納しました。

まず、 文字列をパラメーターとして受け取り、そこから ‘Point’ オブジェクト
を構築する変換関数を定義します。

     注釈: 変換関数には、基になる SQLite データ型に関係なく、 '常に'
     *note bytes: 1a4. オブジェクトで渡されます。

     def convert_point(s):
         x, y = map(float, s.split(b";"))
         return Point(x, y)

与えられた SQLite 値をどの時点で変換すべきかを ‘sqlite3’ に伝える必要が
あります。これは、 *note connect(): 288. の 'detect_types' パラメータを
使用して、データベースに接続する際に行います。 以下の 3 つの選択肢があり
ます:

   * 暗黙的: 'detect_types' に *note PARSE_DECLTYPES: 283e. と設定。

   * 明示的: 'detect_types' に *note PARSE_COLNAMES: 283f. と設定。

   * 両方: 'detect_types' に ‘sqlite3.PARSE_DECLTYPES |
     sqlite3.PARSE_COLNAMES’ を設定。列名での指定は、宣言時の型よりも優
     先されます。

以下の例では、暗黙的なアプローチと明示的なアプローチについて表しています
:

     class Point:
         def __init__(self, x, y):
             self.x, self.y = x, y

         def __repr__(self):
             return f"Point({self.x}, {self.y})"

     def adapt_point(point):
         return f"{point.x};{point.y}"

     def convert_point(s):
         x, y = list(map(float, s.split(b";")))
         return Point(x, y)

     # Register the adapter and converter
     sqlite3.register_adapter(Point, adapt_point)
     sqlite3.register_converter("point", convert_point)

     # 1) Parse using declared types
     p = Point(4.0, -3.2)
     con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES)
     cur = con.execute("CREATE TABLE test(p point)")

     cur.execute("INSERT INTO test(p) VALUES(?)", (p,))
     cur.execute("SELECT p FROM test")
     print("with declared types:", cur.fetchone()[0])
     cur.close()
     con.close()

     # 2) Parse using column names
     con = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_COLNAMES)
     cur = con.execute("CREATE TABLE test(p)")

     cur.execute("INSERT INTO test(p) VALUES(?)", (p,))
     cur.execute('SELECT p AS "p [point]" FROM test')
     print("with column names:", cur.fetchone()[0])
     cur.close()
     con.close()


File: python.info,  Node: 適合関数と変換関数のレシピ集,  Next: 接続 connection ショートカット・メソッドの使い方,  Prev: SQLite 値をカスタム Python 型に変換する方法,  Up: ハウツー・ガイド

5.12.6.20 適合関数と変換関数のレシピ集
......................................

この節では一般的な適合関数と変換関数のレシピを紹介します。

     import datetime
     import sqlite3

     def adapt_date_iso(val):
         """Adapt datetime.date to ISO 8601 date."""
         return val.isoformat()

     def adapt_datetime_iso(val):
         """Adapt datetime.datetime to timezone-naive ISO 8601 date."""
         return val.isoformat()

     def adapt_datetime_epoch(val):
         """Adapt datetime.datetime to Unix timestamp."""
         return int(val.timestamp())

     sqlite3.register_adapter(datetime.date, adapt_date_iso)
     sqlite3.register_adapter(datetime.datetime, adapt_datetime_iso)
     sqlite3.register_adapter(datetime.datetime, adapt_datetime_epoch)

     def convert_date(val):
         """Convert ISO 8601 date to datetime.date object."""
         return datetime.date.fromisoformat(val.decode())

     def convert_datetime(val):
         """Convert ISO 8601 datetime to datetime.datetime object."""
         return datetime.datetime.fromisoformat(val.decode())

     def convert_timestamp(val):
         """Convert Unix epoch timestamp to datetime.datetime object."""
         return datetime.datetime.fromtimestamp(int(val))

     sqlite3.register_converter("date", convert_date)
     sqlite3.register_converter("datetime", convert_datetime)
     sqlite3.register_converter("timestamp", convert_timestamp)


File: python.info,  Node: 接続 connection ショートカット・メソッドの使い方,  Next: 接続 connection コンテキストマネージャの使い方,  Prev: 適合関数と変換関数のレシピ集,  Up: ハウツー・ガイド

5.12.6.21 接続(connection)ショートカット・メソッドの使い方
..........................................................

*note Connection: 226. クラスのメソッド *note execute(): 2866. と *note
executemany(): 2867. と *note executescript(): 2868. を使うことで、 (し
ばしば余計な) *note Cursor: 2830. オブジェクトをわざわざ作り出さずに済む
ので、コードをより簡潔に書くことができます。 *note Cursor: 2830. オブジ
ェクトは暗黙裡に生成され、ショートカット・メソッドの戻り値として受け取る
ことができます。この方法を使えば、 ‘SELECT’ 文を実行してその結果について
反復することが、 *note Connection: 226. オブジェクトに対する呼び出し一つ
で行なえます。

     # Create and fill the table.
     con = sqlite3.connect(":memory:")
     con.execute("CREATE TABLE lang(name, first_appeared)")
     data = [
         ("C++", 1985),
         ("Objective-C", 1984),
     ]
     con.executemany("INSERT INTO lang(name, first_appeared) VALUES(?, ?)", data)

     # Print the table contents
     for row in con.execute("SELECT name, first_appeared FROM lang"):
         print(row)

     print("I just deleted", con.execute("DELETE FROM lang").rowcount, "rows")

     # close() is not a shortcut method and it's not called automatically;
     # the connection object should be closed manually
     con.close()


File: python.info,  Node: 接続 connection コンテキストマネージャの使い方,  Next: SQLite URI の操作方法,  Prev: 接続 connection ショートカット・メソッドの使い方,  Up: ハウツー・ガイド

5.12.6.22 接続(connection)コンテキストマネージャの使い方
........................................................

*note Connection: 226. オブジェクトは、コンテキスト・マネージャーとして
使用でき、コンテキスト・マネージャーとして使用すると、 *note with: 59c.
ブロックを離れるときに、開いているトランザクションを自動的にコミットまた
はロールバックします。 *note with: 59c. 文のブロックが例外なく終了すると
、トランザクションはコミットされます。このコミットが失敗した、または、
‘with’ 文のブロックでキャッチされなかった例外が発生した場合、トランザク
ションはロールバックされます。 *note autocommit: 482. が ‘False’ の場合
、コミット後またはロールバック後に新しいトランザクションが暗黙に開かれま
す。

‘with’ 文のブロックを離れるときに開いているトランザクションがない、また
は、 *note autocommit: 482. が ‘True’ の場合、コンテキスト・マネージャは
何も行いません。

     注釈: The context manager neither implicitly opens a new
     transaction nor closes the connection.  If you need a closing
     context manager, consider using *note contextlib.closing(): 289d.

     con = sqlite3.connect(":memory:")
     con.execute("CREATE TABLE lang(id INTEGER PRIMARY KEY, name VARCHAR UNIQUE)")

     # Successful, con.commit() is called automatically afterwards
     with con:
         con.execute("INSERT INTO lang(name) VALUES(?)", ("Python",))

     # con.rollback() is called after the with block finishes with an exception,
     # the exception is still raised and must be caught
     try:
         with con:
             con.execute("INSERT INTO lang(name) VALUES(?)", ("Python",))
     except sqlite3.IntegrityError:
         print("couldn't add Python twice")

     # Connection object used as context manager only commits or rollbacks transactions,
     # so the connection object should be closed manually
     con.close()


File: python.info,  Node: SQLite URI の操作方法,  Next: 行工場 row factories の作成方法と使用方法,  Prev: 接続 connection コンテキストマネージャの使い方,  Up: ハウツー・ガイド

5.12.6.23 SQLite URI の操作方法
...............................

URI の小技をいくつか紹介します:

   * データベースを読み取り専用で開きます:

     >>> con = sqlite3.connect("file:tutorial.db?mode=ro", uri=True)
     >>> con.execute("CREATE TABLE readonly(data)")
     Traceback (most recent call last):
     OperationalError: attempt to write a readonly database
     >>> con.close()

   * まだ存在しない場合、新しいデータベース・ファイルを暗黙に作成しませ
     ん。なお、新しいファイルが作成できない場合には *note
     OperationalError: 1808. が送出されます:

     >>> con = sqlite3.connect("file:nosuchdb.db?mode=rw", uri=True)
     Traceback (most recent call last):
     OperationalError: unable to open database file

   * 共有の名前付きインメモリ・データベースを作成します:

     db = "file:mem1?mode=memory&cache=shared"
     con1 = sqlite3.connect(db, uri=True)
     con2 = sqlite3.connect(db, uri=True)
     with con1:
         con1.execute("CREATE TABLE shared(data)")
         con1.execute("INSERT INTO shared VALUES(28)")
     res = con2.execute("SELECT data FROM shared")
     assert res.fetchone() == (28,)

     con1.close()
     con2.close()

パラメータのリストを含む、この機能の詳細については、 SQLite URI
documentation(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://www.sqlite.org/uri.html


File: python.info,  Node: 行工場 row factories の作成方法と使用方法,  Next: How to handle non-UTF-8 text encodings,  Prev: SQLite URI の操作方法,  Up: ハウツー・ガイド

5.12.6.24 行工場(row factories)の作成方法と使用方法
...................................................

デフォルトでは、 ‘sqlite3’ は各行(row)を *note タプル: 349. として表しま
す。 ‘タプル’ があなたのニーズと合わない場合は、 *note sqlite3.Row: e3a.
クラスまたはカスタム *note row_factory: 2870. を使用できます。

‘row_factory’ は *note Cursor: 2830. と *note Connection: 226. の両方に
属性として存在しますが、 その接続(connection)から作成されたすべてのカー
ソルが同一の行工場(row factory)を使用するようにするために、 *note
Connection.row_factory: 1592. を設定することをお勧めします。

‘Row’ は、 ‘タプル’ に対してメモリ・オーバーヘッドとパフォーマンスへの影
響を最小限に抑えながら、列(row)へのインデックスによるアクセスと、列への
(大文字と小文字を区別しない)名前によるアクセスを提供します。 ‘Row’ を行
工場(row factory)として使用するには、 ‘row_factory’ 属性に割り当てます:

     >>> con = sqlite3.connect(":memory:")
     >>> con.row_factory = sqlite3.Row

このように設定すると、クエリは ‘Row’ オブジェクトを返すようになります:

     >>> res = con.execute("SELECT 'Earth' AS name, 6378 AS radius")
     >>> row = res.fetchone()
     >>> row.keys()
     ['name', 'radius']
     >>> row[0]         # Access by index.
     'Earth'
     >>> row["name"]    # Access by name.
     'Earth'
     >>> row["RADIUS"]  # Column names are case-insensitive.
     6378
     >>> con.close()

     注釈: The ‘FROM’ clause can be omitted in the ‘SELECT’ statement,
     as in the above example.  In such cases, SQLite returns a single
     row with columns defined by expressions, e.g.  literals, with the
     given aliases ‘expr AS alias’.

各列名が各値にマップされた *note dict: 237. として行を返す、カスタム
*note row_factory: 2870. を作成することもできます:

     def dict_factory(cursor, row):
         fields = [column[0] for column in cursor.description]
         return {key: value for key, value in zip(fields, row)}

これを使うと、クエリは ‘タプル’ の代わりに ‘dict’ を返すようになります:

     >>> con = sqlite3.connect(":memory:")
     >>> con.row_factory = dict_factory
     >>> for row in con.execute("SELECT 1 AS a, 2 AS b"):
     ...     print(row)
     {'a': 1, 'b': 2}
     >>> con.close()

以下の行工場(row factory)は *note 名前付きタプル: 61a. を返します:

     from collections import namedtuple

     def namedtuple_factory(cursor, row):
         fields = [column[0] for column in cursor.description]
         cls = namedtuple("Row", fields)
         return cls._make(row)

‘namedtuple_factory()’ は以下のようにして使う事ができます:

     >>> con = sqlite3.connect(":memory:")
     >>> con.row_factory = namedtuple_factory
     >>> cur = con.execute("SELECT 1 AS a, 2 AS b")
     >>> row = cur.fetchone()
     >>> row
     Row(a=1, b=2)
     >>> row[0]  # Indexed access.
     1
     >>> row.b   # Attribute access.
     2
     >>> con.close()

上記レシピをチューニングすれば、 *note namedtuple: 1ac. の代わりに *note
dataclass: 1ad. または、その他のカスタム・クラスを使用するように適合
(adapt)させることができます。


File: python.info,  Node: How to handle non-UTF-8 text encodings,  Prev: 行工場 row factories の作成方法と使用方法,  Up: ハウツー・ガイド

5.12.6.25 How to handle non-UTF-8 text encodings
................................................

By default, ‘sqlite3’ uses *note str: 418. to adapt SQLite values with
the ‘TEXT’ data type.  This works well for UTF-8 encoded text, but it
might fail for other encodings and invalid UTF-8.  You can use a custom
*note text_factory: 2871. to handle such cases.

Because of SQLite's flexible typing(1), it is not uncommon to encounter
table columns with the ‘TEXT’ data type containing non-UTF-8 encodings,
or even arbitrary data.  To demonstrate, let's assume we have a database
with ISO-8859-2 (Latin-2) encoded text, for example a table of
Czech-English dictionary entries.  Assuming we now have a *note
Connection: 226. instance ‘con’ connected to this database, we can
decode the Latin-2 encoded text using this *note text_factory: 2871.:

     con.text_factory = lambda data: str(data, encoding="latin2")

For invalid UTF-8 or arbitrary data in stored in ‘TEXT’ table columns,
you can use the following technique, borrowed from the *note Unicode
HOWTO: 1276.:

     con.text_factory = lambda data: str(data, errors="surrogateescape")

     注釈: The ‘sqlite3’ module API does not support strings containing
     surrogates.

参考
....

*note Unicode HOWTO: 1276.

   ---------- Footnotes ----------

   (1) https://www.sqlite.org/flextypegood.html


File: python.info,  Node: 説明,  Prev: ハウツー・ガイド,  Up: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース

5.12.6.26 説明
..............

* Menu:

* トランザクション制御::


File: python.info,  Node: トランザクション制御,  Up: 説明

5.12.6.27 トランザクション制御
..............................

‘sqlite3’ は、データベース・トランザクションを開くかどうか、いつ、どのよ
うに開くかを制御する複数の方法を提供します。 *note autocommit
属性に依るトランザクション制御: 483. が推奨されますが、*note
isolation_level 属性に依るトランザクション制御: 2841. は Python 3.12 よ
り前の動作を保持します。

* Menu:

* autocommit 属性に依るトランザクション制御::
* isolation_level 属性に依るトランザクション制御::


File: python.info,  Node: autocommit 属性に依るトランザクション制御,  Next: isolation_level 属性に依るトランザクション制御,  Up: トランザクション制御

5.12.6.28 ‘autocommit’ 属性に依るトランザクション制御
.....................................................

トランザクションの動作を制御する推奨方法は、 *note
Connection.autocommit: 482. 属性を使用することです。 この属性は *note
connect(): 288. の 'autocommit' パラメータを使用して設定して頂けるとあり
がたいです。

'autocommit' を ‘False’ に設定することをお勧めします。そうすると PEP
249(1) 対応のトランザクション制御を行います。これは以下のことを意味しま
す:

   * ‘sqlite3’ はトランザクションが常に開いていることを保証します。その
     ため、 *note connect(): 288. や *note Connection.commit(): 2833. や
     *note Connection.rollback(): 2865. は暗黙に新しいトランザクションを
     開きます(1つ目については保留中のトランザクションを閉じた直後で、後
     の2つについてはその直後に、です)。 ‘sqlite3’ はトランザクションを開
     くときに ‘BEGIN DEFERRED’ 文を使用します。

   * トランザクションは、 ‘commit()’ を使用して明示的にコミットする必要
     があります。

   * トランザクションは、 ‘rollback()’ を使用して明示的にロールバックす
     る必要があります。

   * データベースの保留中に行った変更は *note close(): 227. された場合、
     暗黙のロールバックが実行されます。

'autocommit' を ‘True’ に設定して、SQLite の autocommit mode(2) を有効に
します。このモードでは、 *note Connection.commit(): 2833. と *note
Connection.rollback(): 2865. は効果がありません。 SQLite の自動コミット
・モード(autocommit mode)は、 PEP 249(3) 対応の *note
Connection.autocommit: 482. 属性とは異なることに注意してください。 *note
Connection.in_transaction: 286f. を使用して、低レベル SQLite 自動コミッ
ト・モードを問い合わせします。

'autocommit' を *note LEGACY_TRANSACTION_CONTROL: 2842. に設定して、トラ
ンザクション制御の振る舞いを *note Connection.isolation_level: 2840. 属
性に任せます。詳細については *note isolation_level
属性に依るトランザクション制御: 2841. を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0249/

   (2) 
https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions

   (3) https://peps.python.org/pep-0249/


File: python.info,  Node: isolation_level 属性に依るトランザクション制御,  Prev: autocommit 属性に依るトランザクション制御,  Up: トランザクション制御

5.12.6.29 ‘isolation_level’ 属性に依るトランザクション制御
..........................................................

     注釈: 推奨のトランザクション制御方法は、 *note autocommit: 482. 属
     性を使用することです。 *note autocommit
     属性に依るトランザクション制御: 483. を参照してください。

*note Connection.autocommit: 482. が *note LEGACY_TRANSACTION_CONTROL:
2842. (これがデフォルトです)に設定されている場合、トランザクションの振る
舞いは *note Connection.isolation_level: 2840. 属性を使用して制御されま
す。 *note LEGACY_TRANSACTION_CONTROL: 2842. 以外の場合、
‘isolation_level’ は効果がありません。

接続属性 *note isolation_level: 2840. が ‘None’ で無いのなら、 *note
execute(): 2b2. や *note executemany(): 2b3. が ‘INSERT’ または ‘UPDATE’
または ‘DELETE’ または ‘REPLACE’ 文を実行する前に新しいトランザクション
が暗黙に開かれます。それ以外のSQL文では暗黙のトランザクション処理は行わ
れません。 *note commit(): 2833. メソッドや *note rollback(): 2865. メソ
ッドを使用して、 保留中のトランザクションをそれぞれコミットおよびロール
バックします。あなたは、背後にある SQLite ライブラリのトランザクションの
振る舞い(SQLite transaction behaviour(1)) — つまり、 sqlite3 が暗黙に実
行する ‘BEGIN’ 文の有無とその種類 – を、 *note isolation_level: 2840. 属
性を介して選択できます。

*note isolation_level: 2840. が ‘None’ に設定されていると、トランザクシ
ョンは暗黙に開かれません。これにより、背後にある SQLite ライブラリを自動
コミット・モード(autocommit mode(2))にしたまま、 明示的な SQL 文を使用し
て、 ユーザが独自のトランザクション処理を行えるようにします。背後にある
SQLite ライブラリの自動コミット・モードは、 *note in_transaction: 286f.
属性を使用して問い合わせできます。

*note executescript(): 2869. メソッドは、 *note isolation_level: 2840. の
値に関係なく、与えられた SQL スクリプトの実行前に、保留中のトランザクシ
ョンを暗黙にコミットします。

バージョン 3.6 で変更: ‘sqlite3’ は、 DDL文の前に、開いているトランザク
ションを暗黙にコミットしていました。これはもはや当てはまりません。

バージョン 3.12 で変更: 推奨のトランザクションを制御方法は、 *note
autocommit: 482. 属性を使用することです。

   ---------- Footnotes ----------

   (1) 
https://www.sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions

   (2) 
https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions


File: python.info,  Node: データ圧縮とアーカイブ,  Next: ファイルフォーマット,  Prev: データの永続化,  Up: Python 標準ライブラリ

5.13 データ圧縮とアーカイブ
===========================

この章で説明されるモジュールは zlib, gzip, bzip2, lzma アルゴリズムによ
るデータの圧縮と、 ZIP, tar フォーマットのアーカイブ作成をサポートします
。 *note shutil: b3. モジュールで提供される *note アーカイブ化操作:
11ea. も参照してください。

* Menu:

* zlib: zlib --- gzip 互換の圧縮. gzip 互換の圧縮
* gzip: gzip --- gzip ファイルのサポート. gzip ファイルのサポート
* bz2: bz2 --- bzip2 圧縮のサポート. bzip2 圧縮のサポート
* lzma: lzma --- LZMA アルゴリズムを使用した圧縮. LZMA アルゴリズムを使用した圧縮
* zipfile: zipfile --- ZIP アーカイブの処理. ZIP アーカイブの処理
* tarfile: tarfile --- tar アーカイブファイルの読み書き. tar アーカイブファイルの読み書き


File: python.info,  Node: zlib --- gzip 互換の圧縮,  Next: gzip --- gzip ファイルのサポート,  Up: データ圧縮とアーカイブ

5.13.1 ‘zlib’ -- ‘gzip’ 互換の圧縮
----------------------------------

__________________________________________________________________

このモジュールは、データ圧縮を必要とするアプリケーションが zlib ライブラ
リを使って圧縮および展開を行えるようにします。zlib ライブラリ自身の Webペ
ージは ‘https://www.zlib.net’ です。Python モジュールと zlib ライブラリ
の 1.1.3 より前のバージョンには互換性のない部分があることが知られていま
す。1.1.3 には セキュリティホール(1) が存在するため、1.1.4 以降のバージ
ョンを利用することを推奨します。

zlib の関数にはたくさんのオプションがあり、場合によっては特定の順番で使
わなければなりません。このドキュメントではそれら順番についてすべてを説明
しようとはしていません。詳細は公式サイト
‘http://www.zlib.net/manual.html’ にある zlib のマニュアルを参照してくだ
さい。

‘.gz’ ファイルの読み書きのためには、 *note gzip: 5d. モジュールを参照し
てください。

このモジュールで利用可能な例外と関数を以下に示します:

 -- 例外: zlib.error

     圧縮および展開時のエラーによって送出される例外です。

 -- の関数: zlib.adler32 (data[, value])

     'data' の Adler-32 チェックサムを計算します (Adler-32 チェックサム
     は、おおむね CRC32 と同等の信頼性を持ちながら、はるかに高速に計算で
     きます)。結果は、符号のない 32 ビットの整数です。 'value' が与えら
     れている場合、チェックサム計算の初期値として使われます。与えられて
     いない場合、デフォルト値の 1 が使われます。 'value' を与えることで
     、複数の入力を結合したデータ全体にわたり、通しのチェックサムを計算
     できます。このアルゴリズムは暗号論的には強力ではなく、認証やデジタ
     ル署名などに用いるべきではありません。また、チェックサムアルゴリズ
     ムとして設計されているため、汎用のハッシュアルゴリズムには向きませ
     ん。

     バージョン 3.0 で変更: The result is always unsigned.

 -- の関数: zlib.compress (data, /, level=-1, wbits=MAX_WBITS)

     Compresses the bytes in 'data', returning a bytes object containing
     compressed data.  'level' is an integer from ‘0’ to ‘9’ or ‘-1’
     controlling the level of compression; ‘1’ (Z_BEST_SPEED) is fastest
     and produces the least compression, ‘9’ (Z_BEST_COMPRESSION) is
     slowest and produces the most.  ‘0’ (Z_NO_COMPRESSION) is no
     compression.  The default value is ‘-1’ (Z_DEFAULT_COMPRESSION).
     Z_DEFAULT_COMPRESSION represents a default compromise between speed
     and compression (currently equivalent to level 6).  The 'wbits'
     argument controls the size of the history buffer (or the "window
     size") used when compressing data, and whether a header and trailer
     is included in the output.  It can take several ranges of values,
     defaulting to ‘15’ (MAX_WBITS):

        * +9 to +15: The base-two logarithm of the window size, which
          therefore ranges between 512 and 32768.  Larger values produce
          better compression at the expense of greater memory usage.
          The resulting output will include a zlib-specific header and
          trailer.

        * −9 to −15: Uses the absolute value of 'wbits' as the window
          size logarithm, while producing a raw output stream with no
          header or trailing checksum.

        * +25 to +31 = 16 + (9 to 15): Uses the low 4 bits of the value
          as the window size logarithm, while including a basic ‘gzip’
          header and trailing checksum in the output.

     Raises the *note error: 28aa. exception if any error occurs.

     バージョン 3.6 で変更: 'level' can now be used as a keyword
     parameter.

     バージョン 3.11 で変更: The 'wbits' parameter is now available to
     set window bits and compression type.

 -- の関数: zlib.compressobj (level=-1, method=DEFLATED,
          wbits=MAX_WBITS, memLevel=DEF_MEM_LEVEL,
          strategy=Z_DEFAULT_STRATEGY[, zdict])

     一度にメモリ上に置くことができないようなデータストリームを圧縮する
     ための圧縮オブジェクトを返します。

     'level' は圧縮レベルです。‘0’ から ‘9’ 、または ‘-1’ の整数を取り、
     ‘1’ (Z_BEST_SPEED) は最も高速で最小限の圧縮を行い、‘9’
     (Z_BEST_COMPRESSION) は最も低速で最大限の圧縮を行います。‘0’
     (Z_NO_COMPRESSION) は圧縮しません。デフォルトは ‘-1’ です
     (Z_DEFAULT_COMPRESSION)。Z_DEFAULT_COMPRESSION は、速度と圧縮の間の
     デフォルトの妥協点 (現在、レベル 6 に対応します) を表します。

     'method' は圧縮アルゴリズムです。現在、 ‘DEFLATED’ のみサポートされ
     ています。

     The 'wbits' parameter controls the size of the history buffer (or
     the "window size"), and what header and trailer format will be
     used.  It has the same meaning as *note described for compress():
     28ab.

     'memLevel' 引数は内部圧縮状態用に使用されるメモリ量を制御します。有
     効な値は ‘1’ から ‘9’ です。大きい値ほど多くのメモリを消費しますが
     、より速く、より小さな出力を作成します。

     'strategy' は圧縮アルゴリズムの調整に使用されます。指定可能な値は、
     ‘Z_DEFAULT_STRATEGY’, ‘Z_FILTERED’, ‘Z_HUFFMAN_ONLY’, ‘Z_RLE’ (zlib
     1.2.0.1) および ‘Z_FIXED’ (zlib 1.2.2.2) です。

     'zdict' は定義済み圧縮辞書です。これは圧縮されるデータ内で繰り返し
     現れると予想されるサブシーケンスを含む (*note bytes: 1a4. オブジェ
     クトのような) バイト列のシーケンスです。最も一般的と思われるサブシ
     ーケンスは辞書の末尾に来なければなりません。

     バージョン 3.3 で変更: 'zdict' パラメータとキーワード引数のサポート
     が追加されました。

 -- の関数: zlib.crc32 (data[, value])

     'data' の CRC (Cyclic Redundancy Check, 巡回冗長検査) チェックサム
     を計算します。結果は、符号のない 32 ビットの整数です。 'value' が与
     えられている場合、チェックサム計算の初期値として使われます。与えら
     れていない場合、デフォルト値の 0 が使われます。 'value' を与えるこ
     とで、複数の入力を結合したデータ全体にわたり、通しのチェックサムを
     計算できます。このアルゴリズムは暗号論的には強力ではなく、認証やデ
     ジタル署名などに用いるべきではありません。また、チェックサムアルゴ
     リズムとして設計されているため、汎用のハッシュアルゴリズムには向き
     ません。

     バージョン 3.0 で変更: The result is always unsigned.

 -- の関数: zlib.decompress (data, /, wbits=MAX_WBITS,
          bufsize=DEF_BUF_SIZE)

     Decompresses the bytes in 'data', returning a bytes object
     containing the uncompressed data.  The 'wbits' parameter depends on
     the format of 'data', and is discussed further below.  If 'bufsize'
     is given, it is used as the initial size of the output buffer.
     Raises the *note error: 28aa. exception if any error occurs.  The
     'wbits' parameter controls the size of the history buffer (or
     "window size"), and what header and trailer format is expected.  It
     is similar to the parameter for *note compressobj(): 28ac, but
     accepts more ranges of values:

        * +8 to +15: The base-two logarithm of the window size.  The
          input must include a zlib header and trailer.

        * 0: Automatically determine the window size from the zlib
          header.  Only supported since zlib 1.2.3.5.

        * −8 to −15: Uses the absolute value of 'wbits' as the window
          size logarithm.  The input must be a raw stream with no header
          or trailer.

        * +24 to +31 = 16 + (8 to 15): Uses the low 4 bits of the value
          as the window size logarithm.  The input must include a gzip
          header and trailer.

        * +40 to +47 = 32 + (8 to 15): Uses the low 4 bits of the value
          as the window size logarithm, and automatically accepts either
          the zlib or gzip format.

     When decompressing a stream, the window size must not be smaller
     than the size originally used to compress the stream; using a
     too-small value may result in an *note error: 28aa. exception.  The
     default 'wbits' value corresponds to the largest window size and
     requires a zlib header and trailer to be included.

     'bufsize' は展開されたデータを保持するためのバッファサイズの初期値
     です。バッファの空きは必要に応じて必要なだけ増加するので、必ずしも
     正確な値を指定する必要はありません。この値のチューニングでできるこ
     とは、‘malloc()’ が呼ばれる回数を数回減らすことぐらいです。

     バージョン 3.6 で変更: 'wbits' and 'bufsize' can be used as keyword
     arguments.

 -- の関数: zlib.decompressobj (wbits=MAX_WBITS[, zdict])

     一度にメモリ上に置くことができないようなデータストリームを展開する
     ための展開オブジェクトを返します。

     The 'wbits' parameter controls the size of the history buffer (or
     the "window size"), and what header and trailer format is expected.
     It has the same meaning as *note described for decompress(): 28ad.

     'zdict' パラメータには定義済み圧縮辞書を指定します。このパラメータ
     を指定する場合、展開するデータを圧縮した際に使用した辞書と同じもの
     でなければなりません。

          注釈: 'zdict' が (*note bytearray: 508. のような) 変更可能オブ
          ジェクトの場合、*note decompressobj(): 28ae. の呼び出しとデコ
          ンプレッサの ‘decompress()’ メソッドの最初の呼び出しの間に辞書
          の内容を変更してはいけません。

     バージョン 3.3 で変更: パラメータに 'zdict' を追加しました。

圧縮オブジェクトは以下のメソッドをサポートしています:

 -- メソッド: Compress.compress (data)

     'data' を圧縮し、圧縮されたデータを含むバイト列オブジェクトを返しま
     す。この文字列は少なくとも 'data' の一部分のデータに対する圧縮デー
     タを含みます。このデータは以前に呼んだ *note compress(): 60b. が返
     した出力と結合することができます。入力の一部は以後の処理のために内
     部バッファに保存されることもあります。

 -- メソッド: Compress.flush ([mode])

     未処理の全入力データが処理され、この未処理部分を圧縮したデータを含
     むバイト列オブジェクトが返されます。'mode' は定数 ‘Z_NO_FLUSH’、
     ‘Z_PARTIAL_FLUSH’、‘Z_SYNC_FLUSH’、‘Z_FULL_FLUSH’、‘Z_BLOCK’ (zlib
     1.2.3.4)、または ‘Z_FINISH’ のいずれかをとり、デフォルト値は
     ‘Z_FINISH’ です。‘Z_FINISH’ を除く全ての定数はこれ以後にもデータバ
     イト文字列を圧縮できるモードです。一方、‘Z_FINISH’ は圧縮ストリーム
     を閉じ、これ以後のデータの圧縮を停止します。'mode' に ‘Z_FINISH’ を
     指定して *note flush(): 28b0. メソッドを呼び出した後は、*note
     compress(): 60b. メソッドを再び呼ぶべきではありません。唯一の現実的
     な操作はこのオブジェクトを削除することだけです。

 -- メソッド: Compress.copy ()

     圧縮オブジェクトのコピーを返します。これを使うと先頭部分が共通して
     いる複数のデータを効率的に圧縮することができます。

バージョン 3.8 で変更: Added *note copy.copy(): 4fd. and *note
copy.deepcopy(): b3c. support to compression objects.

展開オブジェクトは以下のメソッドと属性をサポートしています:

 -- の属性: Decompress.unused_data

     圧縮データの末尾より後のバイト列が入ったバイト列オブジェクトです。
     すなわち、この値は圧縮データの入っているバイト列の最後の文字が利用
     可能になるまでは ‘b""’ のままとなります。入力バイト文字列すべてが圧
     縮データを含んでいた場合、この属性は ‘b""’ 、すなわち空バイト列にな
     ります。

 -- の属性: Decompress.unconsumed_tail

     展開されたデータを収めるバッファの長さ制限を超えたために、直近の
     *note decompress(): cdb. 呼び出しで処理しきれなかったデータを含むバ
     イト列オブジェクトです。このデータはまだ zlib 側からは見えていない
     ので、正しい展開出力を得るには以降の *note decompress(): cdb. メソ
     ッド呼び出しに (場合によっては後続のデータが追加された) データを差
     し戻さなければなりません。

 -- の属性: Decompress.eof

     圧縮データストリームの終了に達したかどうかを示すブール値です。

     これは、正常な形式の圧縮ストリームと、不完全あるいは切り詰められた
     ストリームとを区別することを可能にします。

     Added in version 3.3.

 -- メソッド: Decompress.decompress (data, max_length=0)

     'data' を展開し、少なくとも 'string' の一部分に対応する展開されたデ
     ータを含むバイト列オブジェクトを返します。このデータは以前に *note
     decompress(): cdb. メソッドを呼んだ時に返された出力と結合することが
     できます。入力データの一部分が以後の処理のために内部バッファに保存
     されることもあります。

     オプションパラメータ 'max_length' が非ゼロの場合、返される展開デー
     タの長さが 'max_length' 以下に制限されます。このことは入力した圧縮
     データの全てが処理されるとは限らないことを意味し、処理されなかった
     データは *note unconsumed_tail: 28b3. 属性に保存されます。展開処理
     を継続する場合、この保存されたバイト文字列を以降の *note
     decompress(): cdb. 呼び出しに渡さなくてはなりません。 'max_length'
     が 0 の場合、全ての入力が展開され、 *note unconsumed_tail: 28b3. 属
     性は空になります。

     バージョン 3.6 で変更: 'max_length' can be used as a keyword
     argument.

 -- メソッド: Decompress.flush ([length])

     未処理の入力データをすべて処理し、最終的に圧縮されなかった残りの出
     力バイト列オブジェクトを返します。*note flush(): 28b5. を呼んだ後、
     *note decompress(): cdb. を再度呼ぶべきではありません。このときでき
     る唯一の現実的な操作はオブジェクトの削除だけです。

     オプション引数 'length' には出力バッファの初期サイズを指定します。

 -- メソッド: Decompress.copy ()

     展開オブジェクトのコピーを返します。これを使うとデータストリームの
     途中にある展開オブジェクトの状態を保存でき、未来のある時点で行なわ
     れるストリームのランダムなシークをスピードアップするのに利用できま
     す。

バージョン 3.8 で変更: Added *note copy.copy(): 4fd. and *note
copy.deepcopy(): b3c. support to decompression objects.

使用している zlib ライブラリのバージョン情報を以下の定数で確認できます:

 -- データ: zlib.ZLIB_VERSION

     モジュールのビルド時に使用された zlib ライブラリのバージョン文字列
     です。これは *note ZLIB_RUNTIME_VERSION: 1141. で確認できる、実行時
     に使用している実際の zlib ライブラリのバージョンとは異なる場合があ
     ります。

 -- データ: zlib.ZLIB_RUNTIME_VERSION

     インタプリタが読み込んだ実際の zlib ライブラリのバージョン文字列で
     す。

     Added in version 3.3.

参考
....

*note gzip: 5d. モジュール

     ‘gzip’ 形式ファイルへの読み書きを行うモジュール。

‘http://www.zlib.net’

     zlib ライブラリホームページ。

‘http://www.zlib.net/manual.html’

     zlib ライブラリの多くの関数の意味と使い方を解説したマニュアル。

   ---------- Footnotes ----------

   (1) https://zlib.net/zlib_faq.html#faq33


File: python.info,  Node: gzip --- gzip ファイルのサポート,  Next: bz2 --- bzip2 圧縮のサポート,  Prev: zlib --- gzip 互換の圧縮,  Up: データ圧縮とアーカイブ

5.13.2 ‘gzip’ -- ‘gzip’ ファイルのサポート
------------------------------------------

'ソースコード:' Lib/gzip.py(1)

__________________________________________________________________

このモジュールは、GNU の ‘gzip’ や ‘gunzip’ のようにファイルを圧縮、展開
するシンプルなインターフェイスを提供しています。

データ圧縮は *note zlib: 119. モジュールで提供されています。

*note gzip: 5d. は *note GzipFile: 3f3. クラスと、簡易関数 *note open():
28ba.、*note compress(): 60a.、および *note decompress(): 11de. を提供し
ています。*note GzipFile: 3f3. クラスは通常の *note
ファイルオブジェクト: 1193. と同様に ‘gzip’ 形式のファイルを読み書きし、
データを自動的に圧縮または展開します。

‘compress’ や ‘pack’ 等によって作成され、‘gzip’ や ‘gunzip’ が展開できる
他のファイル形式についてはこのモジュールは対応していないので注意してくだ
さい。

このモジュールは以下の項目を定義しています:

 -- の関数: gzip.open (filename, mode='rb', compresslevel=9,
          encoding=None, errors=None, newline=None)

     gzip 圧縮ファイルをバイナリまたはテキストモードで開き、*note
     ファイルオブジェクト: 1193. を返します。

     引数 'filename' には実際のファイル名 (*note str: 418. または *note
     bytes: 1a4. オブジェクト) か、既存のファイルオブジェクトを指定しま
     す。

     引数 'mode' には、バイナリモード用に ‘'r'’、‘'rb'’、‘'a'’、‘'ab'’、
     ‘'w'’、‘'wb'’、‘'x'’、または ‘'xb'’、テキストモード用に ‘'rt'’、
     ‘'at'’、‘'wt'’、または ‘'xt'’ を指定できます。デフォルトは ‘'rb'’ で
     す。

     引数 'compresslevel' は *note GzipFile: 3f3. コンストラクタと同様に
     0 から 9 の整数を取ります。

     バイナリモードでは、この関数は *note GzipFile: 3f3. コンストラクタ
     ‘GzipFile(filename, mode, compresslevel)’ と等価です。この時、引数
     'encoding'、'errors'、および 'newline' を指定してはいけません。

     テキストモードでは、*note GzipFile: 3f3. オブジェクトが作成され、指
     定されたエンコーディング、エラーハンドラの挙動、および改行文字で
     *note io.TextIOWrapper: 786. インスタンスにラップされます。

     バージョン 3.3 で変更: 'filename' にファイルオブジェクト指定のサポ
     ート、テキストモードのサポート、および引数に 'encoding'、'errors'、
     および 'newline' を追加しました。

     バージョン 3.4 で変更: Added support for the ‘'x'’, ‘'xb'’ and
     ‘'xt'’ modes.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- 例外: gzip.BadGzipFile

     An exception raised for invalid gzip files.  It inherits from *note
     OSError: 3f0.  *note EOFError: 12a7. and *note zlib.error: 28aa.
     can also be raised for invalid gzip files.

     Added in version 3.8.

 -- クラス: gzip.GzipFile (filename=None, mode=None, compresslevel=9,
          fileobj=None, mtime=None)

     Constructor for the *note GzipFile: 3f3. class, which simulates
     most of the methods of a *note file object: 1193, with the
     exception of the *note truncate(): 12e0. method.  At least one of
     'fileobj' and 'filename' must be given a non-trivial value.

     クラスの新しいインスタンスは、 'fileobj' に基づいて作成されます。
     'fileobj' は通常のファイル、 *note io.BytesIO: e6d. オブジェクト、
     そしてその他ファイルをシミュレートできるオブジェクトでかまいません
     。 値はデフォルトでは 'None' で、その場合ファイルオブジェクトを生成
     するために 'filename' を開きます。

     'fileobj' が ‘None’ でない場合、'filename' 引数は ‘gzip’ ファイルヘ
     ッダにインクルードされることのみに使用されます。‘gzip’ ファイルヘッ
     ダは圧縮されていないファイルの元の名前をインクルードするかもしれま
     せん。認識可能な場合、規定値は 'fileobj' のファイル名です。そうでな
     い場合、規定値は空の文字列で、元のファイル名はヘッダにはインクルー
     ドされません。

     The 'mode' argument can be any of ‘'r'’, ‘'rb'’, ‘'a'’, ‘'ab'’,
     ‘'w'’, ‘'wb'’, ‘'x'’, or ‘'xb'’, depending on whether the file will
     be read or written.  The default is the mode of 'fileobj' if
     discernible; otherwise, the default is ‘'rb'’.  In future Python
     releases the mode of 'fileobj' will not be used.  It is better to
     always specify 'mode' for writing.

     ファイルは常にバイナリモードで開かれることに注意してください。圧縮
     ファイルをテキストモードで開く場合、*note open(): 28ba. (または
     *note GzipFile: 3f3. を *note io.TextIOWrapper: 786. でラップしたオ
     ブジェクト) を使ってください。

     引数 'compresslevel' は ‘0’ から ‘9’ の整数を取り、圧縮レベルを制御
     します; ‘1’ は最も高速で最小限の圧縮を行い、‘9’ は最も低速ですが最
     大限の圧縮を行います。‘0’ は圧縮しません。デフォルトは ‘9’ です。

     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.  If 'mtime' is omitted or ‘None’, the current time
     is used.  Use 'mtime' = 0 to generate a compressed stream that does
     not depend on creation time.

     See below for the *note mtime: 28bb. attribute that is set when
     decompressing.

     Calling a *note GzipFile: 3f3. object's ‘close()’ method does not
     close 'fileobj', since you might wish to append more material after
     the compressed data.  This also allows you to pass an *note
     io.BytesIO: e6d. object opened for writing as 'fileobj', and
     retrieve the resulting memory buffer using the *note io.BytesIO:
     e6d. object's *note getvalue(): 28bc. method.

     *note GzipFile: 3f3. supports the *note io.BufferedIOBase: 660.
     interface, including iteration and the *note with: 59c. statement.
     Only the *note truncate(): 12e0. method isn't implemented.

     *note GzipFile: 3f3. は以下のメソッドと属性も提供しています:

      -- メソッド: peek (n)

          ファイル内の位置を移動せずに展開した 'n' バイトを読み込みます
          。呼び出し要求を満たすために、圧縮ストリームに対して最大 1 回
          の単一読み込みが行われます。返されるバイト数はほぼ要求した値に
          なります。

               注釈: *note peek(): 11dd. の呼び出しでは *note GzipFile:
               3f3. のファイル位置は変わりませんが、下層のファイルオブジ
               ェクトの位置が変わる惧れがあります。(e.g.  *note
               GzipFile: 3f3. が 'fileobj' 引数で作成された場合)

          Added in version 3.2.

      -- の属性: mode

          ‘'rb'’ は読み込み用、 ‘'wb'’ は書き込み用です。

          バージョン 3.13 で変更: In previous versions it was an integer
          ‘1’ or ‘2’.

      -- の属性: mtime

          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’.

      -- の属性: name

          The path to the gzip file on disk, as a *note str: 418. or
          *note bytes: 1a4.  Equivalent to the output of *note
          os.fspath(): c21. on the original input path, with no other
          normalization, resolution or expansion.

     バージョン 3.1 で変更: *note with: 59c. 文がサポートされました。
     'mtime' コンストラクタ引数と *note mtime: 28bb. 属性が追加されまし
     た。

     バージョン 3.2 で変更: ゼロパディングされたファイルやシーク出来ない
     ファイルがサポートされました。

     バージョン 3.3 で変更: *note io.BufferedIOBase.read1(): 28be. メソ
     ッドを実装しました。

     バージョン 3.4 で変更: ‘'x'’ ならびに ‘'xb'’ モードがサポートされま
     した。

     バージョン 3.5 で変更: 任意の *note バイトライクオブジェクト: cfb.
     の書き込みがサポートされました。 *note read(): 12f7. メソッドが
     ‘None’ を引数として受け取るようになりました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.9 で非推奨: Opening *note GzipFile: 3f3. for writing
     without specifying the 'mode' argument is deprecated.

     バージョン 3.12 で変更: Remove the ‘filename’ attribute, use the
     *note name: 4d7. attribute instead.

 -- の関数: gzip.compress (data, compresslevel=9, *, mtime=None)

     'data' を圧縮し、圧縮データを含む *note bytes: 1a4. オブジェクトを
     返します。'compresslevel' と 'mtime' の意味は上記 *note GzipFile:
     3f3. コンストラクタと同じです。

     Added in version 3.2.

     バージョン 3.8 で変更: Added the 'mtime' parameter for reproducible
     output.

     バージョン 3.11 で変更: Speed is improved by compressing all data
     at once instead of in a streamed fashion.  Calls with 'mtime' set
     to ‘0’ are delegated to *note zlib.compress(): 60b. for better
     speed.  In this situation the output may contain a gzip header "OS"
     byte value other than 255 "unknown" as supplied by the underlying
     zlib implementation.

     バージョン 3.13 で変更: 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.

 -- の関数: gzip.decompress (data)

     Decompress the 'data', returning a *note bytes: 1a4. object
     containing the uncompressed data.  This function is capable of
     decompressing multi-member gzip data (multiple gzip blocks
     concatenated together).  When the data is certain to contain only
     one member the *note zlib.decompress(): cdb. function with 'wbits'
     set to 31 is faster.

     Added in version 3.2.

     バージョン 3.11 で変更: Speed is improved by decompressing members
     at once in memory instead of in a streamed fashion.

* Menu:

* 使い方の例::
* コマンドラインインターフェイス::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/gzip.py


File: python.info,  Node: 使い方の例,  Next: コマンドラインインターフェイス,  Up: gzip --- gzip ファイルのサポート

5.13.2.1 使い方の例
...................

圧縮されたファイルを読み込む例:

     import gzip
     with gzip.open('/home/joe/file.txt.gz', 'rb') as f:
         file_content = f.read()

GZIP 圧縮されたファイルを作成する例:

     import gzip
     content = b"Lots of content here"
     with gzip.open('/home/joe/file.txt.gz', 'wb') as f:
         f.write(content)

既存のファイルを GZIP 圧縮する例:

     import gzip
     import shutil
     with open('/home/joe/file.txt', 'rb') as f_in:
         with gzip.open('/home/joe/file.txt.gz', 'wb') as f_out:
             shutil.copyfileobj(f_in, f_out)

バイナリ文字列を GZIP 圧縮する例:

     import gzip
     s_in = b"Lots of content here"
     s_out = gzip.compress(s_in)

参考
....

*note zlib: 119. モジュール

     ‘gzip’ ファイル形式のサポートを行うために必要な基本ライブラリモジュ
     ール。


File: python.info,  Node: コマンドラインインターフェイス,  Prev: 使い方の例,  Up: gzip --- gzip ファイルのサポート

5.13.2.2 コマンドラインインターフェイス
.......................................

*note gzip: 5d. モジュールは、 ファイルを圧縮、展開するための簡単なコマ
ンドラインインターフェースを提供しています。

Once executed the *note gzip: 5d. module keeps the input file(s).

バージョン 3.8 で変更: Add a new command line interface with a usage.
By default, when you will execute the CLI, the default compression level
is 6.

* Menu:

* コマンドラインオプション::


File: python.info,  Node: コマンドラインオプション,  Up: コマンドラインインターフェイス

5.13.2.3 コマンドラインオプション
.................................

 -- Option: file

     If 'file' is not specified, read from *note sys.stdin: 507.

 -- Option: --fast

     Indicates the fastest compression method (less compression).

 -- Option: --best

     Indicates the slowest compression method (best compression).

 -- Option: -d, --decompress

     Decompress the given file.

 -- Option: -h, --help

     ヘルプメッセージを出力します


File: python.info,  Node: bz2 --- bzip2 圧縮のサポート,  Next: lzma --- LZMA アルゴリズムを使用した圧縮,  Prev: gzip --- gzip ファイルのサポート,  Up: データ圧縮とアーカイブ

5.13.3 ‘bz2’ -- ‘bzip2’ 圧縮のサポート
--------------------------------------

'ソースコード:' Lib/bz2.py(1)

__________________________________________________________________

このモジュールは、bzip2 アルゴリズムを用いて圧縮・展開を行う包括的なイン
ターフェイスを提供します。

*note bz2: f. モジュールには以下のクラスや関数があります:

   * 圧縮ファイルを読み書きするための *note open(): 1063. 関数と *note
     BZ2File: 832. クラス。

   * インクリメンタルにデータを圧縮・展開するための *note BZ2Compressor:
     16c8. および *note BZ2Decompressor: 16c6. クラス。

   * 一度に圧縮・展開を行う *note compress(): 236c. および *note
     decompress(): 1064. 関数。

* Menu:

* ファイルの圧縮/解凍::
* 逐次圧縮および展開::
* 一括圧縮/解凍::
* 使い方の例: 使い方の例<2>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/bz2.py


File: python.info,  Node: ファイルの圧縮/解凍,  Next: 逐次圧縮および展開,  Up: bz2 --- bzip2 圧縮のサポート

5.13.3.1 ファイルの圧縮/解凍
............................

 -- の関数: bz2.open (filename, mode='rb', compresslevel=9,
          encoding=None, errors=None, newline=None)

     bzip2 圧縮されたファイルを、バイナリモードかテキストモードでオープ
     ンし、*note ファイルオブジェクト: 1193. を返します。

     *note BZ2File: 832. のコンストラクタと同様に、引数 'filename' には
     実際のファイル名 (*note str: 418. または *note bytes: 1a4. オブジェ
     クト) か、読み書きする既存のファイルオブジェクトを指定します。

     引数 'mode' には、バイナリモード用に ‘'r'’、‘'rb'’、‘'w'’、‘'wb'’、
     ‘'x'’、‘'xb'’、‘'a'’、あるいは ‘'ab'’、テキストモード用に ‘'rt'’、
     ‘'wt'’、‘'xt'’、あるいは ‘'at'’ を指定できます。デフォルトは ‘'rb'’
     です。

     引数 'compresslevel' には *note BZ2File: 832. コンストラクタと同様
     に 1 から 9 の整数を指定します。

     バイナリモードでは、この関数は *note BZ2File: 832. コンストラクタ
     ‘BZ2File(filename, mode, compresslevel=compresslevel)’ と等価です。
     この時、引数 'encoding'、'errors'、および 'newline' を指定してはい
     けません。

     テキストモードでは、*note BZ2File: 832. オブジェクトが作成され、指
     定されたエンコーディング、エラーハンドラの挙動、および改行文字で
     *note io.TextIOWrapper: 786. にラップされます。

     Added in version 3.3.

     バージョン 3.4 で変更: ‘'x'’ (排他的作成) モードが追加されました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- クラス: bz2.BZ2File (filename, mode='r', *, compresslevel=9)

     bzip2 圧縮ファイルをバイナリモードでオープンします。

     'filename' が *note str: 418. あるいは *note bytes: 1a4. オブジェク
     トの場合、それを名前とするファイルを直接開きます。そうでない場合、
     'filename' は圧縮データを読み書きする *note ファイルオブジェクト:
     1193. でなくてはなりません。

     引数 'mode' は読み込みモードの ‘'r'’ (デフォルト)、上書きモードの
     ‘'w'’、排他的作成モードの ‘'x'’、あるいは追記モードの ‘'a'’ のいず
     れかを指定できます。これらはそれぞれ ‘'rb'’、‘'wb'’、‘'xb'’ および
     ‘'ab'’ と等価です。

     'filename' が (実際のファイル名でなく) ファイルオブジェクトの場合、
     ‘'w'’ はファイルを上書きせず、‘'a'’ と等価になります。

     'mode' が ‘'w'’ あるいは ‘'a'’ の場合、'compresslevel' に圧縮レベル
     を ‘1’ から ‘9’ の整数で指定できます。 圧縮率は ‘1’ が最低で、‘9’
     (デフォルト値) が最高です。

     'mode' の値が ‘'r'’ の場合、入力ファイルは複数の圧縮ストリームでも
     構いません。

     *note BZ2File: 832. には、 *note io.BufferedIOBase: 660. で規定され
     ているメソッドや属性のうち、 *note detach(): 28ce. と *note
     truncate(): 12e0. を除くすべてが備わっています。イテレーションと
     *note with: 59c. 文をサポートしています。

     *note BZ2File: 832. also provides the following methods and
     attributes:

      -- メソッド: peek ([n])

          ファイル上の現在位置を変更せずにバッファのデータを返します。こ
          のメソッドは少なくとも 1 バイトのデータを返します (EOF の場合
          を除く)。返される正確なバイト数は規定されていません。

               注釈: *note peek(): 28cf. の呼び出しでは *note BZ2File:
               832. のファイル位置は変わりませんが、下層のファイルオブジ
               ェクトの位置が変わる惧れがあります(e.g.  *note BZ2File:
               832. を 'filename' にファイルオブジェクトを渡して作成した
               場合)。

          Added in version 3.3.

      -- メソッド: fileno ()

          Return the file descriptor for the underlying file.

          Added in version 3.3.

      -- メソッド: readable ()

          Return whether the file was opened for reading.

          Added in version 3.3.

      -- メソッド: seekable ()

          Return whether the file supports seeking.

          Added in version 3.3.

      -- メソッド: writable ()

          Return whether the file was opened for writing.

          Added in version 3.3.

      -- メソッド: read1 (size=-1)

          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.

          Returns ‘b''’ if the file is at EOF.

          Added in version 3.3.

      -- メソッド: readinto (b)

          Read bytes into 'b'.

          Returns the number of bytes read (0 for EOF).

          Added in version 3.3.

      -- の属性: mode

          ‘'rb'’ は読み込み用、 ‘'wb'’ は書き込み用です。

          Added in version 3.13.

      -- の属性: name

          The bzip2 file name.  Equivalent to the *note name: 28d8.
          attribute of the underlying *note file object: 1193.

          Added in version 3.13.

     バージョン 3.1 で変更: *note with: 59c. 構文のサポートが追加されま
     した。

     バージョン 3.3 で変更: 'filename' が実際のファイル名でなく *note
     ファイルオブジェクト: 1193. だった場合のサポートが追加されました。

     ‘'a'’ (追記) モードが追加され、複数のストリームの読み込みがサポート
     されました。

     バージョン 3.4 で変更: ‘'x'’ (排他的作成) モードが追加されました。

     バージョン 3.5 で変更: *note read(): 12f7. メソッドが ‘None’ を引数
     として受け取るようになりました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.9 で変更: 'buffering' パラメータは削除されました。
     Python 3.0 からは無視され非推奨となっています。開かれたファイルオブ
     ジェクトを渡し、ファイルの開きかたを制御します。

     'compresslevel' パラメータはキーワード専用になりました。

     バージョン 3.10 で変更: このクラスは、複数の同時読み出しや書き込み
     においては、既存の *note gzip: 5d. や *note lzma: 7e. などの同等の
     クラスのように、スレッド安全ではありません。


File: python.info,  Node: 逐次圧縮および展開,  Next: 一括圧縮/解凍,  Prev: ファイルの圧縮/解凍,  Up: bz2 --- bzip2 圧縮のサポート

5.13.3.2 逐次圧縮および展開
...........................

 -- クラス: bz2.BZ2Compressor (compresslevel=9)

     新しくコンプレッサオブジェクトを作成します。このオブジェクトはデー
     タの逐次的な圧縮に使用できます。一度に圧縮したい場合は、*note
     compress(): 236c. 関数を使ってください。

     引数 'compresslevel' を指定する場合は、‘1’ から ‘9’ までの整数を与
     えてください。 デフォルト値は ‘9’ です。

      -- メソッド: compress (data)

          データをコンプレッサオブジェクトに渡します。戻り値は圧縮された
          データですが、圧縮データを返すことができない場合は空のバイト文
          字列を返します。

          コンプレッサオブジェクトにデータをすべて渡し終えたら、*note
          flush(): 28db. メソッドを呼び出し、圧縮プロセスを完了させてく
          ださい。

      -- メソッド: flush ()

          圧縮プロセスを完了させ、内部バッファに残っている圧縮済みデータ
          を返します。

          このメソッドを呼び出すと、それ以後コンプレッサオブジェクトは使
          用できなくなります。

 -- クラス: bz2.BZ2Decompressor

     新しくデコンプレッサオブジェクトを作成します。このオブジェクトは逐
     次的なデータ展開に使用できます。一度に展開したい場合は、*note
     decompress(): 1064. 関数を使ってください。

          注釈: このクラスは、*note decompress(): 1064. や *note
          BZ2File: 832. とは異なり、複数の圧縮レベルが混在しているデータ
          を透過的に扱うことができません。 *note BZ2Decompressor: 16c6.
          クラスを用いて、複数のストリームからなるデータを展開する場合は
          、それぞれのストリームについてデコンプレッサオブジェクトを用意
          してください。

      -- メソッド: decompress (data, max_length=-1)

          'data' (*note bytes-like object: cfb.) を展開し、未圧縮のデー
          タを bytes で返します。 'data' の一部は、後で *note
          decompress(): 1064. の呼び出しに使用するため内部でバッファされ
          ている場合があります。 返されたデータは、以前の *note
          decompress(): 1064. の呼び出しの出力に連結する必要があります。

          'max_length' が非負の場合、最大 'max_length' バイトの展開デー
          タを返します。この制限に達して、出力がさらに生成できる場合、
          *note needs_input: 28dc. が ‘False’ に設定されます。この場合、
          *note decompress(): d99. を次に呼び出すと、'data' を ‘b''’ と
          して提供し、出力をさらに取得することができます。

          入力データの全てが圧縮され返された ('max_length' バイトより少
          ないためか 'max_length' が負のため) 場合、 *note needs_input:
          28dc. 属性は ‘True’ になります。

          ストリームの終端に到達した後にデータを展開しようとすると *note
          EOFError: 12a7. が送出されます。 ストリームの終端の後ろの全て
          のデータは無視され、その部分は *note unused_data: 28dd. 属性に
          保存されます。

          バージョン 3.5 で変更: ‘max_length’ パラメータが追加されました
          。

      -- の属性: eof

          ストリーム終端記号に到達した場合 ‘True’ を返します。

          Added in version 3.3.

      -- の属性: unused_data

          圧縮ストリームの末尾以降に存在したデータを表します。

          ストリームの末尾に達する前には、この属性には ‘b''’ という値が
          収められています。

      -- の属性: needs_input

          *note decompress(): d99. メソッドが、新しい非圧縮入力を必要と
          せずにさらに展開データを提供できる場合、 ‘False’ です。

          Added in version 3.5.


File: python.info,  Node: 一括圧縮/解凍,  Next: 使い方の例<2>,  Prev: 逐次圧縮および展開,  Up: bz2 --- bzip2 圧縮のサポート

5.13.3.3 一括圧縮/解凍
......................

 -- の関数: bz2.compress (data, compresslevel=9)

     *note バイト類オブジェクト: cfb. の 'data' を圧縮します。

     引数 'compresslevel' を指定する場合は、‘1’ から ‘9’ までの整数を与
     えてください。 デフォルト値は ‘9’ です。

     逐次的にデータを圧縮したい場合は、*note BZ2Compressor: 16c8. を使っ
     てください。

 -- の関数: bz2.decompress (data)

     *note バイト類オブジェクト: cfb. の 'data' を展開します。

     'data' が複数の圧縮ストリームから成る場合、そのすべてを展開します。

     逐次的に展開を行う場合は、*note BZ2Decompressor: 16c6. を使ってくだ
     さい。

     バージョン 3.3 で変更: 複数ストリームの入力をサポートしました。


File: python.info,  Node: 使い方の例<2>,  Prev: 一括圧縮/解凍,  Up: bz2 --- bzip2 圧縮のサポート

5.13.3.4 使い方の例
...................

以下は、典型的な *note bz2: f. モジュールの利用方法です。

*note compress(): 236c. と *note decompress(): 1064. を使い、圧縮して展
開する実演をしています:

     >>> import bz2
     >>> data = b"""\
     ... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
     ... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
     ... sit amet cursus ante. In interdum laoreet mi, sit amet ultrices purus
     ... pulvinar a. Nam gravida euismod magna, non varius justo tincidunt feugiat.
     ... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
     ... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
     ... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
     >>> c = bz2.compress(data)
     >>> len(data) / len(c)  # Data compression ratio
     1.513595166163142
     >>> d = bz2.decompress(c)
     >>> data == d  # Check equality to original object after round-trip
     True

*note BZ2Compressor: 16c8. を使い、逐次圧縮をしています:

     >>> import bz2
     >>> def gen_data(chunks=10, chunksize=1000):
     ...     """Yield incremental blocks of chunksize bytes."""
     ...     for _ in range(chunks):
     ...         yield b"z" * chunksize
     ...
     >>> comp = bz2.BZ2Compressor()
     >>> out = b""
     >>> for chunk in gen_data():
     ...     # Provide data to the compressor object
     ...     out = out + comp.compress(chunk)
     ...
     >>> # Finish the compression process.  Call this once you have
     >>> # finished providing data to the compressor.
     >>> out = out + comp.flush()

上の例は、非常に "ランダムでない" データストリーム (チャンク ‘b"z"’ のス
トリーム) です。 ランダムなデータは圧縮率が低い傾向にある一方、揃ってい
て、繰り返しのあるデータは通常は高い圧縮率を叩き出します。

bzip2 圧縮されたファイルをバイナリモードで読み書きしています:

     >>> import bz2
     >>> data = b"""\
     ... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
     ... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
     ... sit amet cursus ante. In interdum laoreet mi, sit amet ultrices purus
     ... pulvinar a. Nam gravida euismod magna, non varius justo tincidunt feugiat.
     ... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
     ... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
     ... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
     >>> with bz2.open("myfile.bz2", "wb") as f:
     ...     # Write compressed data to file
     ...     unused = f.write(data)
     ...
     >>> with bz2.open("myfile.bz2", "rb") as f:
     ...     # Decompress data from file
     ...     content = f.read()
     ...
     >>> content == data  # Check equality to original object after round-trip
     True


File: python.info,  Node: lzma --- LZMA アルゴリズムを使用した圧縮,  Next: zipfile --- ZIP アーカイブの処理,  Prev: bz2 --- bzip2 圧縮のサポート,  Up: データ圧縮とアーカイブ

5.13.4 ‘lzma’ -- LZMA アルゴリズムを使用した圧縮
------------------------------------------------

Added in version 3.3.

'ソースコード:' Lib/lzma.py(1)

__________________________________________________________________

このモジュールは LZMA 圧縮アルゴリズムを使用したデータ圧縮および展開のた
めのクラスや便利な関数を提供しています。また、‘xz’ ユーティリティを使用
した ‘.xz’ およびレガシーな ‘.lzma’ ファイル形式へのファイルインターフェ
イスの他、RAW 圧縮ストリームもサポートしています。

このモジュールが提供するインターフェイスは *note bz2: f. モジュールと非
常によく似ています。 *note LZMAFile: fd7. と *note bz2.BZ2File: 832. は
スレッドセーフでは 'ない' 点に注意してください。 そのため、単一の *note
LZMAFile: fd7. インスタンスを複数スレッドから使用する場合は、ロックで保
護する必要があります。

 -- 例外: lzma.LZMAError

     この例外は圧縮あるいは展開中にエラーが発生した場合、または圧縮/展開
     状態の初期化中に送出されます。

* Menu:

* 圧縮ファイルへの読み書き::
* メモリ上での圧縮と展開::
* その他: その他<2>.
* カスタムフィルタチェインの指定::
* 使用例: 使用例<14>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/lzma.py


File: python.info,  Node: 圧縮ファイルへの読み書き,  Next: メモリ上での圧縮と展開,  Up: lzma --- LZMA アルゴリズムを使用した圧縮

5.13.4.1 圧縮ファイルへの読み書き
.................................

 -- の関数: lzma.open (filename, mode='rb', *, format=None, check=-1,
          preset=None, filters=None, encoding=None, errors=None,
          newline=None)

     LZMA 圧縮ファイルをバイナリまたはテキストモードでオープンし、*note
     ファイルオブジェクト: 1193. を返します。

     'filename' 引数には、ファイルをオープンする際には実際のファイル名
     (*note str: 418.、 *note bytes: 1a4.、または *note path-like: 280.
     オブジェクトとして指定します)か、読み込みまたは書き込むためであれば
     、すでに存在するファイルオブジェクトを指定できます。

     引数 'mode' は、バイナリモードでは ‘"r"’、‘"rb"’、‘"w"’、‘"wb"’、
     ‘"x"’、‘"xb"’、‘"a"’、あるいは ‘"ab"’ の、テキストモードでは
     ‘"rt"’、‘"wt"’、‘"xt"’、あるいは ‘"at"’ のいずれかになります。デフ
     ォルトは ‘"rb"’ です。

     読み込み用にファイルをオープンした場合、引数 'format' および
     'filters' は *note LZMADecompressor: 16c5. と同じ意味になります。こ
     の時、引数 'check' および 'preset' は使用しないでください。

     書き出し用にオープンした場合、引数 'format'、'check'、'preset'、お
     よび 'filters' は *note LZMACompressor: 16c7. と同じ意味になります
     。

     バイナリモードでは、この関数は *note LZMAFile: fd7. コンストラクタ
     と等価になります (‘LZMAFile(filename, mode, ...)’)。この場合、引数
     'encoding'、'errors'、および 'newline' を指定しなければなりません。

     テキストモードでは、*note LZMAFile: fd7. オブジェクトが生成され、指
     定したエンコーディング、エラーハンドラの挙動、および改行コードで
     *note io.TextIOWrapper: 786. にラップされます。

     バージョン 3.4 で変更: ‘"x"’, ‘"xb"’, ‘"xt"’ モードのサポートが追加
     されました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- クラス: lzma.LZMAFile (filename=None, mode='r', *, format=None,
          check=-1, preset=None, filters=None)

     LZMA 圧縮ファイルをバイナリモードで開きます。

     *note LZMAFile: fd7. はすでにオープンしている *note file object:
     1193. をラップ、または名前付きファイルを直接操作できます。引数
     'filename' にはラップするファイルオブジェクトかオープンするファイル
     名 (*note str: 418. オブジェクトま、*note bytes: 1a4. オブジェクト
     、または *note path-like: 280. オブジェクト) を指定します。既存のフ
     ァイルオブジェクトをラップした場合、*note LZMAFile: fd7. をクローズ
     してもラップしたファイルはクローズされません。

     引数 'mode' は読み込みモードの ‘"r"’ (デフォルト)、上書きモードの
     ‘"w"’、排他的生成モードの ‘"x"’、あるいは追記モードの ‘"a"’ のいず
     れかを指定できます。これらはそれぞれ ‘"rb"’、‘"wb"’、‘"xb"’、および
     ‘"ab"’ と等価です。

     'filename' が (実際のファイル名でなく) ファイルオブジェクトの場合、
     ‘"w"’ モードはファイルを上書きせず、‘"a"’ と等価になります。

     読み込みモードでファイルをオープンした時、入力ファイルは複数に分割
     された圧縮ストリームを連結したものでもかまいません。これらは透過的
     に単一論理ストリームとしてデコードされます。

     読み込み用にファイルをオープンした場合、引数 'format' および
     'filters' は *note LZMADecompressor: 16c5. と同じ意味になります。こ
     の時、引数 'check' および 'preset' は使用しないでください。

     書き出し用にオープンした場合、引数 'format'、'check'、'preset'、お
     よび 'filters' は *note LZMACompressor: 16c7. と同じ意味になります
     。

     *note LZMAFile: fd7. には、 *note io.BufferedIOBase: 660. で規定さ
     れているメソッドや属性のうち、 *note detach(): 28ce. と *note
     truncate(): 12e0. を除くすべてが備わっています。イテレーションと
     *note with: 59c. 文をサポートしています。

     以下のメソッドと属性も提供されています:

      -- メソッド: peek (size=-1)

          ファイル上の現在位置を変更せずにバッファのデータを返します。
          EOF に達しない限り、少なくとも 1 バイトが返されます。返される
          正確なバイト数は規定されていません (引数 'size' は無視されます
          )。

               注釈: *note peek(): 28e7. の呼び出しでは *note LZMAFile:
               fd7. のファイル位置は変わりませんが、下層のファイルオブジ
               ェクトの位置が変わる惧れがあります。(e.g.  *note
               LZMAFile: fd7. を 'filename' にファイルオブジェクトを渡し
               て作成した場合)

      -- の属性: mode

          ‘'rb'’ は読み込み用、 ‘'wb'’ は書き込み用です。

          Added in version 3.13.

      -- の属性: name

          lzma ファイルの名前。基礎である *note file object: 1193. の
          *note name: 28d8. 属性と同様です。

          Added in version 3.13.

     バージョン 3.4 で変更: ‘'x'’, ‘'xb'’ モードがサポートが追加されまし
     た。

     バージョン 3.5 で変更: *note read(): 12f7. メソッドが ‘None’ を引数
     として受け取るようになりました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。


File: python.info,  Node: メモリ上での圧縮と展開,  Next: その他<2>,  Prev: 圧縮ファイルへの読み書き,  Up: lzma --- LZMA アルゴリズムを使用した圧縮

5.13.4.2 メモリ上での圧縮と展開
...............................

 -- クラス: lzma.LZMACompressor (format=FORMAT_XZ, check=-1,
          preset=None, filters=None)

     データをインクリメンタルに圧縮する圧縮オブジェクトを作成します。

     大量の単一データを圧縮する、より便利な方法については *note
     compress(): 28eb. を参照してください。

     引数 'format' には使用するコンテナフォーマットを指定します。以下の
     値が指定できます:

        * 
          ‘FORMAT_XZ’: The ‘.xz’ コンテナフォーマット。

               デフォルトのフォーマットです。

        * 
          ‘FORMAT_ALONE’: レガシーな ‘.lzma’ コンテナフォーマット。

               このフォーマットは ‘.xz’ より制限があります - インテグリ
               ティチェックや複数フィルタをサポートしていません。

        * 
          ‘FORMAT_RAW’: 特定のコンテナフォーマットを使わない、生のデータストリーム。

               このフォーマット指定子はインテグリティチェックをサポート
               しておらず、(圧縮および展開双方のために) 常にカスタムフィ
               ルタチェインを指定する必要があります。さらに、この方法で
               圧縮されたデータは ‘FORMAT_AUTO’ を使っても展開できません
               (*note LZMADecompressor: 16c5. を参照)。

     引数 'check' には圧縮データに組み込むインテグリティチェックのタイプ
     を指定します。このチェックは展開時に使用され、データが破損していな
     いことを保証します。以下の値が指定できます:

        * ‘CHECK_NONE’: インテグリティチェックなし。‘FORMAT_ALONE’ およ
          び ‘FORMAT_RAW’ のデフォルト (かつ唯一指定可能な値) です。

        * ‘CHECK_CRC32’: 32-bit 巡回冗長検査。

        * ‘CHECK_CRC64’: 64-bit 巡回冗長検査。‘FORMAT_XZ’ のデフォルトで
          す。

        * ‘CHECK_SHA256’: 256-bit セキュアハッシュアルゴリズム (SHA)。

     指定したチェック方法がサポートされていない場合、*note LZMAError:
     28e4. が送出されます。

     圧縮設定はプリセット圧縮レベル (引数 'preset' で指定) またはカスタ
     ムフィルタチェイン (引数 'filters' で指定) のどちらかを指定します。

     引数 'preset' を指定する場合、‘0’ から ‘9’ までの整数値でなければな
     らず、オプションで定数 ‘PRESET_EXTREME’ を論理和指定できます。
     'preset' も 'filters' も指定されなかった場合、デフォルトの挙動とし
     て ‘PRESET_DEFAULT’ (プリセットレベル ‘6’) が使用されます。高いプリ
     セット値を指定すると圧縮率が上がりますが、圧縮にかかる時間が長くな
     ります。

          注釈: CPU の使用量が多いのに加えて、高いプリセットで圧縮を行う
          には、メモリをずっと多く必要とします (さらに、生成される出力も
          展開により多くのメモリを必要とします)。例えば、プリセットが
          ‘9’ の場合、*note LZMACompressor: 16c7. オブジェクトのオーバー
          ヘッドは 800 MiB にまで高くなる場合があります。このため、通常
          はデフォルトのプリセットを使用するのがよいでしょう。

     引数 'filters' を指定する場合、フィルタチェイン指定子でなければなり
     ません。詳しくは *note カスタムフィルタチェインの指定: 28ec. を参照
     してください。

      -- メソッド: compress (data)

          'data' (*note bytes: 1a4. オブジェクト) を圧縮し、少なくともそ
          の一部が圧縮されたデータを格納する *note bytes: 1a4. オブジェ
          クトを返します。'data' の一部は、後で *note compress(): 28eb.
          および *note flush(): 28ee. の呼び出しに使用するため内部でバッ
          ファされている場合があります。返すデータは以前の *note
          compress(): 28eb. 呼び出しの出力を連結したものです。

      -- メソッド: flush ()

          圧縮処理を終了し、コンプレッサの内部バッファにあるあらゆるデー
          タを格納する *note bytes: 1a4. オブジェクトを返します。

          コンプレッサはこのメソッドが呼び出された後は使用できません。

 -- クラス: lzma.LZMADecompressor (format=FORMAT_AUTO, memlimit=None,
          filters=None)

     データをインクリメンタルに展開するために使用できる展開オブジェクト
     を作成します。

     圧縮されたストリーム全体を一度に展開にする、より便利な方法について
     は、*note decompress(): 28ef. を参照してください。

     引数 'format' には使用するコンテナフォーマットを指定します。デフォ
     ルトは ‘FORMAT_AUTO’ で、‘.xz’ および ‘.lzma’ ファイルを展開できま
     す。その他に指定できる値は、‘FORMAT_XZ’、‘FORMAT_ALONE’、および
     ‘FORMAT_RAW’ です。

     引数 'memlimit' にはデコンプレッサが使用できるメモリ量をバイトで指
     定します。この引数を指定した場合、そのメモリ量で展開ができないと
     *note LZMAError: 28e4. を送出します。

     引数 'filters' には展開されるストリームの作成に使用するフィルタチェ
     インを指定します。この引数を使用する際は、引数 'format' に
     ‘FORMAT_RAW’ を指定しなければなりません。フィルタチェインについての
     詳細は *note カスタムフィルタチェインの指定: 28ec. を参照してくださ
     い。

          注釈: このクラスは *note decompress(): 28ef. および *note
          LZMAFile: fd7. と異なり、複数の圧縮ストリームを含む入力を透過
          的に扱いません。 *note LZMADecompressor: 16c5. で複数ストリー
          ム入力を展開するには、各ストリームごとに新しいデコンプレッサを
          作成しなければなりません。

      -- メソッド: decompress (data, max_length=-1)

          'data' (*note bytes-like object: cfb.) を展開し、未圧縮のデー
          タを bytes で返します。 'data' の一部は、後で *note
          decompress(): 28ef. の呼び出しに使用するため内部でバッファされ
          ている場合があります。 返されたデータは、以前の *note
          decompress(): 28ef. の呼び出しの出力に連結する必要があります。

          'max_length' が非負の場合、最大 'max_length' バイトの展開デー
          タを返します。この制限に達して、出力がさらに生成できる場合、
          *note needs_input: 28f0. が ‘False’ に設定されます。この場合、
          *note decompress(): dfb. を次に呼び出すと、'data' を ‘b''’ と
          して提供し、出力をさらに取得することができます。

          入力データの全てが圧縮され返された ('max_length' バイトより少
          ないためか 'max_length' が負のため) 場合、 *note needs_input:
          28f0. 属性は ‘True’ になります。

          ストリームの終端に到達した後にデータを展開しようとすると *note
          EOFError: 12a7. が送出されます。 ストリームの終端の後ろの全て
          のデータは無視され、その部分は *note unused_data: 28f1. 属性に
          保存されます。

          バージョン 3.5 で変更: ‘max_length’ パラメータが追加されました
          。

      -- の属性: check

          入力ストリームに使用されるインテグリティチェックの ID です。こ
          れは何のインテグリティチェックが使用されているか決定するために
          十分な入力がデコードされるまでは ‘CHECK_UNKNOWN’ になることが
          あります。

      -- の属性: eof

          ストリーム終端記号に到達した場合 ‘True’ を返します。

      -- の属性: unused_data

          圧縮ストリームの末尾以降に存在したデータを表します。

          ストリームの末尾に達する前は、これは ‘b""’ になります。

      -- の属性: needs_input

          *note decompress(): dfb. メソッドが、新しい非圧縮入力を必要と
          せずにさらに展開データを提供できる場合、 ‘False’ です。

          Added in version 3.5.

 -- の関数: lzma.compress (data, format=FORMAT_XZ, check=-1,
          preset=None, filters=None)

     'data' (*note bytes: 1a4. オブジェクト) を圧縮し、圧縮データを
     *note bytes: 1a4. オブジェクトとして返します。

     引数 'format'、'check'、'preset'、および 'filters' についての説明は
     上記の *note LZMACompressor: 16c7. を参照してください。

 -- の関数: lzma.decompress (data, format=FORMAT_AUTO, memlimit=None,
          filters=None)

     'data' (*note bytes: 1a4. オブジェクト) を展開し、展開データを
     *note bytes: 1a4. オブジェクトとして返します。

     'data' が複数の明確な圧縮ストリームの連結だった場合、すべてのストリ
     ームを展開し、結果の連結を返します。

     引数 'format'、'memlimit'、および 'filters' の説明は、上記 *note
     LZMADecompressor: 16c5. を参照してください。


File: python.info,  Node: その他<2>,  Next: カスタムフィルタチェインの指定,  Prev: メモリ上での圧縮と展開,  Up: lzma --- LZMA アルゴリズムを使用した圧縮

5.13.4.3 その他
...............

 -- の関数: lzma.is_check_supported (check)

     指定したインテグリティチェックがシステムでサポートされていれば
     ‘True’ を返します。

     ‘CHECK_NONE’ および ‘CHECK_CRC32’ は常にサポートされています。
     ‘CHECK_CRC64’ および ‘CHECK_SHA256’ は ‘liblzma’ が機能制限セットで
     コンパイルされている場合利用できないことがあります。


File: python.info,  Node: カスタムフィルタチェインの指定,  Next: 使用例<14>,  Prev: その他<2>,  Up: lzma --- LZMA アルゴリズムを使用した圧縮

5.13.4.4 カスタムフィルタチェインの指定
.......................................

フィルタチェイン指定子は、辞書のシーケンスで、各辞書は ID と単一フィルタ
のオプションからなります。各辞書はキー ‘"id"’ を持たなければならず、フィ
ルタ依存のオプションを指定する追加キーを持つ場合もあります。有効なフィル
タ ID は以下のとおりです:

   * 圧縮フィルタ:

        * ‘FILTER_LZMA1’ (‘FORMAT_ALONE’ と共に使用)

        * ‘FILTER_LZMA2’ (‘FORMAT_XZ’ および ‘FORMAT_RAW’ と共に使用)

   * デルタフィルター:

        * ‘FILTER_DELTA’

   * ブランチコールジャンプ (BCJ) フィルター:

        * ‘FILTER_X86’

        * ‘FILTER_IA64’

        * ‘FILTER_ARM’

        * ‘FILTER_ARMTHUMB’

        * ‘FILTER_POWERPC’

        * ‘FILTER_SPARC’

一つのフィルタチェインは 4 個までのフィルタを定義することができ、空には
できません。チェインの最後は圧縮フィルタでなくてはならず、その他のフィル
タはデルタまたは BCJ フィルタでなければなりません。

圧縮フィルタは以下のオプション (追加エントリとしてフィルタを表す辞書に指
定) をサポートしています:

   * ‘preset’: 明示されていないオプションのデフォルト値のソースとして使
     用する圧縮プリセット。

   * ‘dict_size’: 辞書のサイズのバイト数。これは、 4 KiB から 1.5 GiB の
     間にしてください (両端を含みます)。

   * ‘lc’: リテラルコンテキストビットの数。

   * ‘lp’: リテラル位置ビットの数。‘lc + lp’ で最大 4 までです。

   * ‘pb’: 位置ビットの数。最大で 4 までです。

   * ‘mode’: ‘MODE_FAST’ または ‘MODE_NORMAL’。

   * ‘nice_len’: マッチに "良い" とみなす長さ。273 以下でなければなりま
     せん。

   * ‘mf’: 使用するマッチファインダ - ‘MF_HC3’、‘MF_HC4’、‘MF_BT2’、
     ‘MF_BT3’、または ‘MF_BT4’。

   * ‘depth’: マッチファインダが使用する検索の最大深度。0 (デフォルト) で
     は他のフィルタオプションをベースに自動選択します。

デルタフィルターは、バイト間の差異を保存し、特定の状況で、コンプレッサー
に対してさらに反復的な入力を生成します。 デルタフィルターは、1 つのオプ
ション ‘dist’ のみをサポートします。 これは差し引くバイトどうしの距離を
示します。 デフォルトは 1 で、隣接するバイトの差異を扱います。

The BCJ filters are intended to be applied to machine code.  They
convert relative branches, calls and jumps in the code to use absolute
addressing, with the aim of increasing the redundancy that can be
exploited by the compressor.  These filters support one option,
‘start_offset’.  This specifies the address that should be mapped to the
beginning of the input data.  The default is 0.


File: python.info,  Node: 使用例<14>,  Prev: カスタムフィルタチェインの指定,  Up: lzma --- LZMA アルゴリズムを使用した圧縮

5.13.4.5 使用例
...............

圧縮ファイルからの読み込み:

     import lzma
     with lzma.open("file.xz") as f:
         file_content = f.read()

圧縮ファイルの作成:

     import lzma
     data = b"Insert Data Here"
     with lzma.open("file.xz", "w") as f:
         f.write(data)

メモリ上でデータを圧縮:

     import lzma
     data_in = b"Insert Data Here"
     data_out = lzma.compress(data_in)

逐次圧縮:

     import lzma
     lzc = lzma.LZMACompressor()
     out1 = lzc.compress(b"Some data\n")
     out2 = lzc.compress(b"Another piece of data\n")
     out3 = lzc.compress(b"Even more data\n")
     out4 = lzc.flush()
     # Concatenate all the partial results:
     result = b"".join([out1, out2, out3, out4])

すでにオープンしているファイルへの圧縮データの書き出し:

     import lzma
     with open("file.xz", "wb") as f:
         f.write(b"This data will not be compressed\n")
         with lzma.open(f, "w") as lzf:
             lzf.write(b"This *will* be compressed\n")
         f.write(b"Not compressed\n")

カスタムフィルタチェインを使った圧縮ファイルの作成:

     import lzma
     my_filters = [
         {"id": lzma.FILTER_DELTA, "dist": 5},
         {"id": lzma.FILTER_LZMA2, "preset": 7 | lzma.PRESET_EXTREME},
     ]
     with lzma.open("file.xz", "w", filters=my_filters) as f:
         f.write(b"blah blah blah")


File: python.info,  Node: zipfile --- ZIP アーカイブの処理,  Next: tarfile --- tar アーカイブファイルの読み書き,  Prev: lzma --- LZMA アルゴリズムを使用した圧縮,  Up: データ圧縮とアーカイブ

5.13.5 ‘zipfile’ -- ZIP アーカイブの処理
----------------------------------------

'Source code:' Lib/zipfile/(1)

__________________________________________________________________

ZIP は一般によく知られているアーカイブ (書庫化) および圧縮の標準ファイル
フォーマットです。このモジュールでは ZIP 形式のファイルの作成、読み書き
、追記、書庫内のファイル一覧の作成を行うためのツールを提供します。より高
度な使い方でこのモジュールを利用したいのであれば、 PKZIP Application
Note(2) に定義されている ZIP ファイルフォーマットの理解が必要になるでし
ょう。

このモジュールは現在マルチディスク ZIP ファイルを扱うことはできません。
ZIP64 拡張を利用する ZIP ファイル (サイズが 4 GiB を超えるような ZIP フ
ァイル) は扱えます。このモジュールは暗号化されたアーカイブの復号をサポー
トしますが、現在暗号化ファイルを作成することはできません。C 言語ではなく
、Python で実装されているため、復号は非常に遅くなっています。

このモジュールは以下の項目を定義しています:

 -- 例外: zipfile.BadZipFile

     正常ではない ZIP ファイルに対して送出されるエラーです。

     Added in version 3.2.

 -- 例外: zipfile.BadZipfile

     *note BadZipFile: 1749. の別名です。過去のバージョンの Python との
     互換性のために用意されています。

     バージョン 3.2 で非推奨.

 -- 例外: zipfile.LargeZipFile

     ZIP ファイルが ZIP64 の機能を必要としているが、その機能が有効化され
     ていない場合に送出されるエラーです。

 -- クラス: zipfile.ZipFile

     ZIP ファイルの読み書きのためのクラスです。コンストラクタの詳細につ
     いては、*note ZipFile オブジェクト: 28fc. 節を参照してください。

 -- クラス: zipfile.Path

     *note pathlib.Path: 20a. インターフェースの一部を実装したクラスです
     。 *note importlib.resources.abc.Traversable: 1d4. インターフェース
     は完全に実装しています。

     Added in version 3.8.

 -- クラス: zipfile.PyZipFile

     Python ライブラリを含む、ZIP アーカイブを作成するためのクラスです。

 -- クラス: zipfile.ZipInfo (filename='NoName', date_time=(1980, 1, 1,
          0, 0, 0))

     アーカイブ内の 1 個のメンバの情報を取得するために使うクラスです。こ
     のクラスのインスタンスは *note ZipFile: 690. オブジェクトの *note
     getinfo(): 28fd. および *note infolist(): 28fe. メソッドによって返
     されます。ほとんどの *note zipfile: 117. モジュールの利用者はこのク
     ラスのインスタンスを作成する必要はなく、このモジュールによって作成
     されたものを使用できます。'filename' はアーカイブメンバのフルネーム
     でなければならず、'date_time' はファイルが最後に変更された日時を表
     す 6 個のフィールドのタプルでなければなりません; フィールドは *note
     ZipInfo オブジェクト: 28ff. 節で説明されています。

     バージョン 3.13 で変更: A public ‘compress_level’ attribute has
     been added to expose the formerly protected ‘_compresslevel’.  The
     older protected name continues to work as a property for backwards
     compatibility.

 -- の関数: zipfile.is_zipfile (filename)

     'filename' が正しいマジックナンバをもつ ZIP ファイルの時に ‘True’ を
     返し、そうでない場合 ‘False’ を返します。'filename' にはファイルや
     ファイルライクオブジェクトを渡すこともできます。

     バージョン 3.1 で変更: ファイルおよびファイルライクオブジェクトをサ
     ポートしました。

 -- データ: zipfile.ZIP_STORED

     アーカイブメンバを圧縮しない (複数ファイルを一つにまとめるだけ) こ
     とを表す数値定数です。

 -- データ: zipfile.ZIP_DEFLATED

     通常の ZIP 圧縮方法を表す数値定数です。これには *note zlib: 119. モ
     ジュールが必要です。

 -- データ: zipfile.ZIP_BZIP2

     BZIP2 圧縮方法を表す数値定数です。これには *note bz2: f. モジュール
     が必要です。

     Added in version 3.3.

 -- データ: zipfile.ZIP_LZMA

     LZMA 圧縮方法を表す数値定数です。これには *note lzma: 7e. モジュー
     ルが必要です。

     Added in version 3.3.

          注釈: ZIP ファイルフォーマット仕様は 2001 年より bzip2 圧縮を
          、2006 年より LZMA 圧縮をサポートしていますが、(過去の Python
          リリースを含む) 一部のツールはこれら圧縮方式をサポートしていな
          いため、ZIP ファイルの処理を全く受け付けないか、あるいは個々の
          ファイルの抽出に失敗する場合があります。

参考
....

PKZIP Application Note(3)

     ZIP ファイルフォーマットおよびアルゴリズムを作成した Phil Katz によ
     るドキュメント。

Info-ZIP Home Page(4)

     Info-ZIP プロジェクトによる ZIP アーカイブプログラムおよびプログラ
     ム開発ライブラリに関する情報。

* Menu:

* ZipFile オブジェクト::
* Path オブジェクト::
* PyZipFile オブジェクト::
* ZipInfo オブジェクト::
* コマンドラインインターフェイス: コマンドラインインターフェイス<2>.
* Decompression pitfalls::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/zipfile/

   (2) https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

   (3) https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

   (4) https://infozip.sourceforge.net/


File: python.info,  Node: ZipFile オブジェクト,  Next: Path オブジェクト,  Up: zipfile --- ZIP アーカイブの処理

5.13.5.1 ZipFile オブジェクト
.............................

 -- クラス: zipfile.ZipFile (file, mode='r', compression=ZIP_STORED,
          allowZip64=True, compresslevel=None, *,
          strict_timestamps=True, metadata_encoding=None)

     ZIP ファイルを開きます。 'file' はファイルのパス (文字列) か、ファ
     イルライクオブジェクト、 *note path-like object: 280. のいずれかで
     す。

     'mode' パラメータには、既存のファイルを読み込む場合は ‘'r'’ 、内容
     を消去して新しいファイルに書き込む場合は ‘'w'’ 、既存のファイルの末
     尾に追加する場合は ‘'a'’ 、ファイルが存在しない場合にのみファイルを
     作成して書き込む場合は ‘'x'’ を指定します。 'mode' が ‘'x'’ で
     'file' が既存のファイルを指している場合、 *note FileExistsError:
     fea. が発生します。 'mode' が ‘'a'’ で 'file' が既存の ZIP ファイル
     を指している場合、新しい ZIP アーカイブがそのファイルに追加されます
     。 'file' が ZIP ファイルでない場合は、ファイルの末尾にあたらしい
     ZIP アーカイブが追加されます。 これは、既存のファイル (例えば
     ‘python.exe’) に ZIP アーカイブを付け加える用途を想定したものです。
     'mode' が ‘'a'’ で 'file' が存在しない場合は、ファイルが作成されま
     す。 'mode' が ‘'r'’ か ‘'a'’ の場合、ファイルはシーク可能である必
     要があります。

     'compression' is the ZIP compression method to use when writing the
     archive, and should be *note ZIP_STORED: 2900, *note ZIP_DEFLATED:
     2901, *note ZIP_BZIP2: 2902. or *note ZIP_LZMA: 2903.; unrecognized
     values will cause *note NotImplementedError: 209. to be raised.  If
     *note ZIP_DEFLATED: 2901, *note ZIP_BZIP2: 2902. or *note ZIP_LZMA:
     2903. is specified but the corresponding module (*note zlib: 119,
     *note bz2: f. or *note lzma: 7e.) is not available, *note
     RuntimeError: 17a. is raised.  The default is *note ZIP_STORED:
     2900.

     If 'allowZip64' is ‘True’ (the default) zipfile will create ZIP
     files that use the ZIP64 extensions when the zipfile is larger than
     4 GiB. If it is ‘false’ *note zipfile: 117. will raise an exception
     when the ZIP file would require ZIP64 extensions.

     The 'compresslevel' parameter controls the compression level to use
     when writing files to the archive.  When using *note ZIP_STORED:
     2900. or *note ZIP_LZMA: 2903. it has no effect.  When using *note
     ZIP_DEFLATED: 2901. integers ‘0’ through ‘9’ are accepted (see
     *note zlib: 28ac. for more information).  When using *note
     ZIP_BZIP2: 2902. integers ‘1’ through ‘9’ are accepted (see *note
     bz2: 832. for more information).

     The 'strict_timestamps' argument, when set to ‘False’, allows to
     zip files older than 1980-01-01 at the cost of setting the
     timestamp to 1980-01-01.  Similar behavior occurs with files newer
     than 2107-12-31, the timestamp is also set to the limit.

     When mode is ‘'r'’, 'metadata_encoding' may be set to the name of a
     codec, which will be used to decode metadata such as the names of
     members and ZIP comments.

     ファイルがモード ‘'w'’、 ‘'x'’ または ‘'a'’ で作成され、その後その
     アーカイブにファイルを追加することなく *note クローズ: 2905. された
     場合、空のアーカイブのための適切な ZIP 構造がファイルに書き込まれま
     す。

     ZipFile はコンテキストマネージャにもなっているので、*note with:
     59c. 文をサポートしています。次の例では、'myzip' は ‘with’ 文のブロ
     ックが終了したときに、(たとえ例外が発生したとしても) クローズされま
     す:

          with ZipFile('spam.zip', 'w') as myzip:
              myzip.write('eggs.txt')

          注釈: 'metadata_encoding' is an instance-wide setting for the
          ZipFile.  It is not currently possible to set this on a
          per-member basis.

          This attribute is a workaround for legacy implementations
          which produce archives with names in the current locale
          encoding or code page (mostly on Windows).  According to the
          .ZIP standard, the encoding of metadata may be specified to be
          either IBM code page (default) or UTF-8 by a flag in the
          archive header.  That flag takes precedence over
          'metadata_encoding', which is a Python-specific extension.

     バージョン 3.2 で変更: *note ZipFile: 690. をコンテキストマネージャ
     として使用できるようになりました。

     バージョン 3.3 で変更: *note bzip2: f. および *note lzma: 7e. 圧縮
     をサポートしました。

     バージョン 3.4 で変更: ZIP64 拡張がデフォルトで有効になりました。

     バージョン 3.5 で変更: seek 出来ないストリームのサポートが追加され
     ました。‘'x'’ モードのサポートが追加されました。

     バージョン 3.6 で変更: Previously, a plain *note RuntimeError: 17a.
     was raised for unrecognized compression values.

     バージョン 3.6.2 で変更: 'file' 引数が *note path-like object: 280.
     を受け入れるようになりました。

     バージョン 3.7 で変更: 'compresslevel' パラメータが追加されました。

     バージョン 3.8 で変更: The 'strict_timestamps' keyword-only
     parameter.

     バージョン 3.11 で変更: Added support for specifying member name
     encoding for reading metadata in the zipfile's directory and file
     headers.

 -- メソッド: ZipFile.close ()

     アーカイブファイルをクローズします。*note close(): 2905. はプログラ
     ムを終了する前に必ず呼び出さなければなりません。さもないとアーカイ
     ブ上の重要なレコードが書き込まれません。

 -- メソッド: ZipFile.getinfo (name)

     アーカイブメンバ 'name' に関する情報を持つ *note ZipInfo: cd8. オブ
     ジェクトを返します。アーカイブに含まれないファイル名に対して *note
     getinfo(): 28fd. を呼び出すと、*note KeyError: 31d. が送出されます
     。

 -- メソッド: ZipFile.infolist ()

     アーカイブに含まれる各メンバの *note ZipInfo: cd8. オブジェクトから
     なるリストを返します。既存のアーカイブファイルを開いている場合、リ
     ストの順番は実際の ZIP ファイル中のメンバの順番と同じになります。

 -- メソッド: ZipFile.namelist ()

     アーカイブメンバの名前のリストを返します。

 -- メソッド: ZipFile.open (name, mode='r', pwd=None, *,
          force_zip64=False)

     Access a member of the archive as a binary file-like object.
     'name' can be either the name of a file within the archive or a
     *note ZipInfo: cd8. object.  The 'mode' parameter, if included,
     must be ‘'r'’ (the default) or ‘'w'’.  'pwd' is the password used
     to decrypt encrypted ZIP files as a *note bytes: 1a4. object.

     *note open(): 3f4. はコンテキストマネージャでもあるので *note with:
     59c. 文をサポートしています:

          with ZipFile('spam.zip') as myzip:
              with myzip.open('eggs.txt') as myfile:
                  print(myfile.read())

     With 'mode' ‘'r'’ the file-like object (‘ZipExtFile’) is read-only
     and provides the following methods: *note read(): 12f7, *note
     readline(): 12f8, *note readlines(): 228f, *note seek(): 125d,
     *note tell(): 2907, *note __iter__(): 1c2b, *note __next__(): 129b.
     These objects can operate independently of the ZipFile.

     With ‘mode='w'’, a writable file handle is returned, which supports
     the *note write(): ca9. method.  While a writable file handle is
     open, attempting to read or write other files in the ZIP file will
     raise a *note ValueError: 1e3.

     In both cases the file-like object has also attributes ‘name’,
     which is equivalent to the name of a file within the archive, and
     ‘mode’, which is ‘'rb'’ or ‘'wb'’ depending on the input mode.

     When writing a file, if the file size is not known in advance but
     may exceed 2 GiB, pass ‘force_zip64=True’ to ensure that the header
     format is capable of supporting large files.  If the file size is
     known in advance, construct a *note ZipInfo: cd8. object with *note
     file_size: 2908. set, and use that as the 'name' parameter.

          注釈: *note open(): 3f4.、*note read(): 2909.、および *note
          extract(): 290a. メソッドには、ファイル名または *note ZipInfo:
          cd8. オブジェクトを指定できます。これは重複する名前のメンバを
          含む ZIP ファイルを読み込むときにそのメリットを享受できるでし
          ょう。

     バージョン 3.6 で変更: Removed support of ‘mode='U'’.  Use *note
     io.TextIOWrapper: 786. for reading compressed text files in *note
     universal newlines: d08. mode.

     バージョン 3.6 で変更: *note ZipFile.open(): 3f4. can now be used
     to write files into the archive with the ‘mode='w'’ option.

     バージョン 3.6 で変更: Calling *note open(): 3f4. on a closed
     ZipFile will raise a *note ValueError: 1e3.  Previously, a *note
     RuntimeError: 17a. was raised.

     バージョン 3.13 で変更: Added attributes ‘name’ and ‘mode’ for the
     writeable file-like object.  The value of the ‘mode’ attribute for
     the readable file-like object was changed from ‘'r'’ to ‘'rb'’.

 -- メソッド: ZipFile.extract (member, path=None, pwd=None)

     Extract a member from the archive to the current working directory;
     'member' must be its full name or a *note ZipInfo: cd8. object.
     Its file information is extracted as accurately as possible.
     'path' specifies a different directory to extract to.  'member' can
     be a filename or a *note ZipInfo: cd8. object.  'pwd' is the
     password used for encrypted files as a *note bytes: 1a4. object.

     作成された (ディレクトリか新ファイルの) 正規化されたパスを返します
     。

          注釈: メンバのファイル名が絶対パスなら、ドライブ/UNC
          sharepoint および先頭の (バック) スラッシュは取り除かれます。
          例えば、Unix で ‘///foo/bar’ は ‘foo/bar’ となり、Window で
          ‘C:\foo\bar’ は ‘foo\bar’ となります。また、メンバのファイル名
          に含まれる全ての ‘".."’ は取り除かれます。例えば、
          ‘../../foo../../ba..r’ は ‘foo../ba..r’ となります。Windows で
          は、不正な文字 (‘:’, ‘<’, ‘>’, ‘|’, ‘"’, ‘?’, および ‘*’) はア
          ンダースコア (‘_’) で置き換えられます。

     バージョン 3.6 で変更: Calling *note extract(): 290a. on a closed
     ZipFile will raise a *note ValueError: 1e3.  Previously, a *note
     RuntimeError: 17a. was raised.

     バージョン 3.6.2 で変更: 'path' パラメタが *note path-like object:
     280. を受け付けるようになりました。

 -- メソッド: ZipFile.extractall (path=None, members=None, pwd=None)

     Extract all members from the archive to the current working
     directory.  'path' specifies a different directory to extract to.
     'members' is optional and must be a subset of the list returned by
     *note namelist(): 2906.  'pwd' is the password used for encrypted
     files as a *note bytes: 1a4. object.

          警告: 信頼できないソースからきた Zip ファイルを、事前に中身を
          チェックせずに展開してはいけません。ファイルを 'path' の外側に
          作成することができるからです。例えば、 ‘"/"’ で始まる絶対パス
          を持ったメンバーや、 2 つのドット ‘".."’ を持つファイル名など
          の場合です。このモジュールはそれを避けようとします。 *note
          extract(): 290a. の注釈を参照してください。

     バージョン 3.6 で変更: Calling *note extractall(): 290b. on a
     closed ZipFile will raise a *note ValueError: 1e3.  Previously, a
     *note RuntimeError: 17a. was raised.

     バージョン 3.6.2 で変更: 'path' パラメタが *note path-like object:
     280. を受け付けるようになりました。

 -- メソッド: ZipFile.printdir ()

     アーカイブの内容の一覧を ‘sys.stdout’ に出力します。

 -- メソッド: ZipFile.setpassword (pwd)

     Set 'pwd' (a *note bytes: 1a4. object) as default password to
     extract encrypted files.

 -- メソッド: ZipFile.read (name, pwd=None)

     Return the bytes of the file 'name' in the archive.  'name' is the
     name of the file in the archive, or a *note ZipInfo: cd8. object.
     The archive must be open for read or append.  'pwd' is the password
     used for encrypted files as a *note bytes: 1a4. object and, if
     specified, overrides the default password set with *note
     setpassword(): 290d.  Calling *note read(): 2909. on a ZipFile that
     uses a compression method other than *note ZIP_STORED: 2900, *note
     ZIP_DEFLATED: 2901, *note ZIP_BZIP2: 2902. or *note ZIP_LZMA: 2903.
     will raise a *note NotImplementedError: 209.  An error will also be
     raised if the corresponding compression module is not available.

     バージョン 3.6 で変更: Calling *note read(): 2909. on a closed
     ZipFile will raise a *note ValueError: 1e3.  Previously, a *note
     RuntimeError: 17a. was raised.

 -- メソッド: ZipFile.testzip ()

     Read all the files in the archive and check their CRC's and file
     headers.  Return the name of the first bad file, or else return
     ‘None’.

     バージョン 3.6 で変更: Calling *note testzip(): 290e. on a closed
     ZipFile will raise a *note ValueError: 1e3.  Previously, a *note
     RuntimeError: 17a. was raised.

 -- メソッド: ZipFile.write (filename, arcname=None, compress_type=None,
          compresslevel=None)

     Write the file named 'filename' to the archive, giving it the
     archive name 'arcname' (by default, this will be the same as
     'filename', but without a drive letter and with leading path
     separators removed).  If given, 'compress_type' overrides the value
     given for the 'compression' parameter to the constructor for the
     new entry.  Similarly, 'compresslevel' will override the
     constructor if given.  The archive must be open with mode ‘'w'’,
     ‘'x'’ or ‘'a'’.

          注釈: The ZIP file standard historically did not specify a
          metadata encoding, but strongly recommended CP437 (the
          original IBM PC encoding) for interoperability.  Recent
          versions allow use of UTF-8 (only).  In this module, UTF-8
          will automatically be used to write the member names if they
          contain any non-ASCII characters.  It is not possible to write
          member names in any encoding other than ASCII or UTF-8.

          注釈: アーカイブ名はアーカイブルートに対する相対パスでなければ
          なりません。言い換えると、アーカイブ名はパスセパレータで始まっ
          てはいけません。

          注釈: もし、‘arcname’ (‘arcname’ が与えられない場合は、
          ‘filename’) が null byte を含むなら、アーカイブ中のファイルの
          ファイル名は、null byte までで切り詰められます。

          注釈: A leading slash in the filename may lead to the archive
          being impossible to open in some zip programs on Windows
          systems.

     バージョン 3.6 で変更: Calling *note write(): d1a. on a ZipFile
     created with mode ‘'r'’ or a closed ZipFile will raise a *note
     ValueError: 1e3.  Previously, a *note RuntimeError: 17a. was
     raised.

 -- メソッド: ZipFile.writestr (zinfo_or_arcname, data,
          compress_type=None, compresslevel=None)

     Write a file into the archive.  The contents is 'data', which may
     be either a *note str: 418. or a *note bytes: 1a4. instance; if it
     is a *note str: 418, it is encoded as UTF-8 first.
     'zinfo_or_arcname' is either the file name it will be given in the
     archive, or a *note ZipInfo: cd8. instance.  If it's an instance,
     at least the filename, date, and time must be given.  If it's a
     name, the date and time is set to the current date and time.  The
     archive must be opened with mode ‘'w'’, ‘'x'’ or ‘'a'’.

     If given, 'compress_type' overrides the value given for the
     'compression' parameter to the constructor for the new entry, or in
     the 'zinfo_or_arcname' (if that is a *note ZipInfo: cd8. instance).
     Similarly, 'compresslevel' will override the constructor if given.

          注釈: *note ZipInfo: cd8. インスタンスを引数
          'zinfo_or_arcname' として与えた場合、与えられた *note ZipInfo:
          cd8. インスタンスのメンバーである 'compress_type' で指定された
          圧縮方法が使われます。デフォルトでは、*note ZipInfo: cd8. コン
          ストラクターが、このメンバーを *note ZIP_STORED: 2900. に設定
          します。

     バージョン 3.2 で変更: 引数 'compress_type' を追加しました。

     バージョン 3.6 で変更: Calling *note writestr(): 12fa. on a ZipFile
     created with mode ‘'r'’ or a closed ZipFile will raise a *note
     ValueError: 1e3.  Previously, a *note RuntimeError: 17a. was
     raised.

 -- メソッド: ZipFile.mkdir (zinfo_or_directory, mode=511)

     Create a directory inside the archive.  If 'zinfo_or_directory' is
     a string, a directory is created inside the archive with the mode
     that is specified in the 'mode' argument.  If, however,
     'zinfo_or_directory' is a *note ZipInfo: cd8. instance then the
     'mode' argument is ignored.

     The archive must be opened with mode ‘'w'’, ‘'x'’ or ‘'a'’.

     Added in version 3.11.

以下のデータ属性も利用することができます:

 -- の属性: ZipFile.filename

     ZIP ファイルの名前です。

 -- の属性: ZipFile.debug

     使用するデバッグ出力レベルです。この属性は ‘0’ (デフォルト、何も出
     力しない) から ‘3’ (最も多く出力する) までの値に設定することができ
     ます。デバッグ情報は ‘sys.stdout’ に出力されます。

 -- の属性: ZipFile.comment

     ZIP ファイルに *note bytes: 1a4. オブジェクトとして関連付けられたコ
     メントです。モード ‘'w'’ 、 ‘'x'’ または ‘'a'’ で作成された *note
     ZipFile: 690. インスタンスへコメントを割り当てる場合、文字列長は
     65535 バイトまでにしてください。その長さを超えたコメントは切り捨て
     られます。


File: python.info,  Node: Path オブジェクト,  Next: PyZipFile オブジェクト,  Prev: ZipFile オブジェクト,  Up: zipfile --- ZIP アーカイブの処理

5.13.5.2 Path オブジェクト
..........................

 -- クラス: zipfile.Path (root, at='')

     Construct a Path object from a ‘root’ zipfile (which may be a *note
     ZipFile: 690. instance or ‘file’ suitable for passing to the *note
     ZipFile: 690. constructor).

     ‘at’ specifies the location of this Path within the zipfile, e.g.
     'dir/file.txt', 'dir/', or ''.  Defaults to the empty string,
     indicating the root.

Path objects expose the following features of *note pathlib.Path: 20a.
objects:

Path objects are traversable using the ‘/’ operator or ‘joinpath’.

 -- の属性: Path.name

     The final path component.

 -- メソッド: Path.open (mode='r', *, pwd, **)

     Invoke *note ZipFile.open(): 3f4. on the current path.  Allows
     opening for read or write, text or binary through supported modes:
     'r', 'w', 'rb', 'wb'.  Positional and keyword arguments are passed
     through to *note io.TextIOWrapper: 786. when opened as text and
     ignored otherwise.  ‘pwd’ is the ‘pwd’ parameter to *note
     ZipFile.open(): 3f4.

     バージョン 3.9 で変更: Added support for text and binary modes for
     open.  Default mode is now text.

     バージョン 3.11.2 で変更: The ‘encoding’ parameter can be supplied
     as a positional argument without causing a *note TypeError: 502.
     As it could in 3.9.  Code needing to be compatible with unpatched
     3.10 and 3.11 versions must pass all *note io.TextIOWrapper: 786.
     arguments, ‘encoding’ included, as keywords.

 -- メソッド: Path.iterdir ()

     Enumerate the children of the current directory.

 -- メソッド: Path.is_dir ()

     Return ‘True’ if the current context references a directory.

 -- メソッド: Path.is_file ()

     Return ‘True’ if the current context references a file.

 -- メソッド: Path.is_symlink ()

     Return ‘True’ if the current context references a symbolic link.

     Added in version 3.12.

     バージョン 3.13 で変更: Previously, ‘is_symlink’ would
     unconditionally return ‘False’.

 -- メソッド: Path.exists ()

     Return ‘True’ if the current context references a file or directory
     in the zip file.

 -- データ: Path.suffix

     The last dot-separated portion of the final component, if any.
     This is commonly called the file extension.

     Added in version 3.11: Added *note Path.suffix: 693. property.

 -- データ: Path.stem

     The final path component, without its suffix.

     Added in version 3.11: Added *note Path.stem: 692. property.

 -- データ: Path.suffixes

     A list of the path’s suffixes, commonly called file extensions.

     Added in version 3.11: Added *note Path.suffixes: 694. property.

 -- メソッド: Path.read_text (*, **)

     Read the current file as unicode text.  Positional and keyword
     arguments are passed through to *note io.TextIOWrapper: 786.
     (except ‘buffer’, which is implied by the context).

     バージョン 3.11.2 で変更: The ‘encoding’ parameter can be supplied
     as a positional argument without causing a *note TypeError: 502.
     As it could in 3.9.  Code needing to be compatible with unpatched
     3.10 and 3.11 versions must pass all *note io.TextIOWrapper: 786.
     arguments, ‘encoding’ included, as keywords.

 -- メソッド: Path.read_bytes ()

     Read the current file as bytes.

 -- メソッド: Path.joinpath (*other)

     Return a new Path object with each of the 'other' arguments joined.
     The following are equivalent:

          >>> Path(...).joinpath('child').joinpath('grandchild')
          >>> Path(...).joinpath('child', 'grandchild')
          >>> Path(...) / 'child' / 'grandchild'

     バージョン 3.10 で変更: Prior to 3.10, ‘joinpath’ was undocumented
     and accepted exactly one parameter.

The zipp(1) project provides backports of the latest path object
functionality to older Pythons.  Use ‘zipp.Path’ in place of
‘zipfile.Path’ for early access to changes.

   ---------- Footnotes ----------

   (1) https://pypi.org/project/zipp/


File: python.info,  Node: PyZipFile オブジェクト,  Next: ZipInfo オブジェクト,  Prev: Path オブジェクト,  Up: zipfile --- ZIP アーカイブの処理

5.13.5.3 PyZipFile オブジェクト
...............................

*note PyZipFile: fc4. コンストラクタは *note ZipFile: 690. コンストラク
タと同じパラメータに加え、'optimize' パラメータをとります。

 -- クラス: zipfile.PyZipFile (file, mode='r', compression=ZIP_STORED,
          allowZip64=True, optimize=-1)

     バージョン 3.2 で変更: Added the 'optimize' parameter.

     バージョン 3.4 で変更: ZIP64 拡張がデフォルトで有効になりました。

     インスタンスは *note ZipFile: 690. オブジェクトのメソッドの他に、追
     加のメソッドを 1 個持ちます:

      -- メソッド: writepy (pathname, basename='', filterfunc=None)

          ‘*.py’ ファイルを探し、一致するファイルをアーカイブに追加しま
          す。

          *note PyZipFile: fc4. に 'optimize' 引数が与えられない場合、あ
          るいは ‘-1’ が指定された場合、対応するファイルは ‘*.pyc’ ファ
          イルで、必要に応じてコンパイルします。

          *note PyZipFile: fc4. の 'optimize' パラメータが ‘0’、‘1’、あ
          るいは ‘2’ の場合、それを最適化レベル (*note compile(): 177. 参
          照) とするファイルのみが、必要に応じてコンパイルされアーカイブ
          に追加されます。

          If 'pathname' is a file, the filename must end with ‘.py’, and
          just the (corresponding ‘*.pyc’) file is added at the top
          level (no path information).  If 'pathname' is a file that
          does not end with ‘.py’, a *note RuntimeError: 17a. will be
          raised.  If it is a directory, and the directory is not a
          package directory, then all the files ‘*.pyc’ are added at the
          top level.  If the directory is a package directory, then all
          ‘*.pyc’ are added under the package name as a file path, and
          if any subdirectories are package directories, all of these
          are added recursively in sorted order.

          'basename' は内部が使用するためだけのものです。

          'filterfunc' を与える場合、単一の文字列引数を取る関数を渡して
          ください。これには(個々のフルパスを含む)それぞれのパスがアーカ
          イブに加えられる前に渡されます。 'filterfunc' が偽を返せば、そ
          のパスはアーカイブに追加されず、ディレクトリだった場合はその中
          身が無視されます。例として、私たちのテストファイルが全て
          ‘test’ ディレクトリの中にあるか、 ‘test’ 文字列で始まるとしま
          しょう。 'filterfunc' を使ってそれらを除外出来ます:

               >>> zf = PyZipFile('myprog.zip')
               >>> def notests(s):
               ...     fn = os.path.basename(s)
               ...     return (not (fn == 'test' or fn.startswith('test_')))
               ...
               >>> zf.writepy('myprog', filterfunc=notests)

          *note writepy(): fc5. メソッドは以下のようなファイル名でアーカ
          イブを作成します:

               string.pyc                   # Top level name
               test/__init__.pyc            # Package directory
               test/testall.pyc             # Module test.testall
               test/bogus/__init__.pyc      # Subpackage directory
               test/bogus/myfile.pyc        # Submodule test.bogus.myfile

          バージョン 3.4 で変更: Added the 'filterfunc' parameter.

          バージョン 3.6.2 で変更: 'pathname' 引数が *note path-like
          object: 280. を受け付けるようになりました。

          バージョン 3.7 で変更: Recursion sorts directory entries.


File: python.info,  Node: ZipInfo オブジェクト,  Next: コマンドラインインターフェイス<2>,  Prev: PyZipFile オブジェクト,  Up: zipfile --- ZIP アーカイブの処理

5.13.5.4 ZipInfo オブジェクト
.............................

*note ZipInfo: cd8. クラスのインスタンスは、*note ZipFile: 690. オブジェ
クトの *note getinfo(): 28fd. および *note infolist(): 28fe. メソッドに
よって返されます。各オブジェクトは ZIP アーカイブ内の 1 個のメンバに関す
る情報を格納します。

There is one classmethod to make a *note ZipInfo: cd8. instance for a
filesystem file:

 -- メソッド: classmethod ZipInfo.from_file (filename, arcname=None, *,
          strict_timestamps=True)

     Construct a *note ZipInfo: cd8. instance for a file on the
     filesystem, in preparation for adding it to a zip file.

     'filename' should be the path to a file or directory on the
     filesystem.

     If 'arcname' is specified, it is used as the name within the
     archive.  If 'arcname' is not specified, the name will be the same
     as 'filename', but with any drive letter and leading path
     separators removed.

     The 'strict_timestamps' argument, when set to ‘False’, allows to
     zip files older than 1980-01-01 at the cost of setting the
     timestamp to 1980-01-01.  Similar behavior occurs with files newer
     than 2107-12-31, the timestamp is also set to the limit.

     Added in version 3.6.

     バージョン 3.6.2 で変更: 'filename' 引数が *note path-like object:
     280. を受け入れるようになりました。

     バージョン 3.8 で変更: Added the 'strict_timestamps' keyword-only
     parameter.

インスタンスは以下のメソッドと属性を持ちます:

 -- メソッド: ZipInfo.is_dir ()

     アーカイブのメンバーがディレクトリの場合に ‘True’ を返します。

     This uses the entry's name: directories should always end with ‘/’.

     Added in version 3.6.

 -- の属性: ZipInfo.filename

     アーカイブ中のファイル名。

 -- の属性: ZipInfo.date_time

     アーカイブメンバの最終更新日時。6 つの値からなるタプルになります:

     インデッ    値
     クス        

     -------------------------------------------
                 
     ‘0’         西暦年 (>= 1980)
                 
                 
     ‘1’         月 (1 から始まる)
                 
                 
     ‘2’         日 (1 から始まる)
                 
                 
     ‘3’         時 (0 から始まる)
                 
                 
     ‘4’         分 (0 から始まる)
                 
                 
     ‘5’         秒 (0 から始まる)
                 

          注釈: ZIP ファイルフォーマットは 1980 年より前のタイムスタンプ
          をサポートしていません。

 -- の属性: ZipInfo.compress_type

     アーカイブメンバの圧縮形式。

 -- の属性: ZipInfo.comment

     Comment for the individual archive member as a *note bytes: 1a4.
     object.

 -- の属性: ZipInfo.extra

     拡張フィールドデータ。この *note bytes: 1a4. オブジェクトに含まれて
     いるデータの内部構成については、PKZIP Application Note(1) でコメン
     トされています。

 -- の属性: ZipInfo.create_system

     ZIP アーカイブを作成したシステムを記述する文字列。

 -- の属性: ZipInfo.create_version

     このアーカイブを作成した PKZIP のバージョン。

 -- の属性: ZipInfo.extract_version

     このアーカイブを展開する際に必要な PKZIP のバージョン。

 -- の属性: ZipInfo.reserved

     予約領域。ゼロでなくてはなりません。

 -- の属性: ZipInfo.flag_bits

     ZIP フラグビット列。

 -- の属性: ZipInfo.volume

     ファイルヘッダのボリューム番号。

 -- の属性: ZipInfo.internal_attr

     内部属性。

 -- の属性: ZipInfo.external_attr

     外部ファイル属性。

 -- の属性: ZipInfo.header_offset

     ファイルヘッダへのバイトオフセット。

 -- の属性: ZipInfo.CRC

     圧縮前のファイルの CRC-32 チェックサム。

 -- の属性: ZipInfo.compress_size

     圧縮後のデータのサイズ。

 -- の属性: ZipInfo.file_size

     圧縮前のファイルのサイズ。

   ---------- Footnotes ----------

   (1) https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT


File: python.info,  Node: コマンドラインインターフェイス<2>,  Next: Decompression pitfalls,  Prev: ZipInfo オブジェクト,  Up: zipfile --- ZIP アーカイブの処理

5.13.5.5 コマンドラインインターフェイス
.......................................

*note zipfile: 117. モジュールは、 ZIP アーカイブを操作するための簡単な
コマンドラインインターフェースを提供しています。

ZIP アーカイブを新規に作成したい場合、*note -c: 2931. オプションの後にま
とめたいファイルを列挙してください:

     $ python -m zipfile -c monty.zip spam.txt eggs.txt

ディレクトリを渡すこともできます:

     $ python -m zipfile -c monty.zip life-of-brian_1979/

ZIP アーカイブを特定のディレクトリに展開したい場合、*note -e: 2932. オプ
ションを使用してください:

     $ python -m zipfile -e monty.zip target-dir/

ZIP アーカイブ内のファイル一覧を表示するには *note -l: 2933. を使用して
ください:

     $ python -m zipfile -l monty.zip

* Menu:

* コマンドラインオプション: コマンドラインオプション<2>.


File: python.info,  Node: コマンドラインオプション<2>,  Up: コマンドラインインターフェイス<2>

5.13.5.6 コマンドラインオプション
.................................

 -- Option: -l <zipfile>
 -- Option: --list <zipfile>

     zipfile 内のファイル一覧を表示します。

 -- Option: -c <zipfile> <source1> ... <sourceN>
 -- Option: --create <zipfile> <source1> ... <sourceN>

     ソースファイルから zipfile を作成します。

 -- Option: -e <zipfile> <output_dir>
 -- Option: --extract <zipfile> <output_dir>

     zipfile を対象となるディレクトリに展開します。

 -- Option: -t <zipfile>
 -- Option: --test <zipfile>

     zipfile が有効かどうか調べます。

 -- Option: --metadata-encoding <encoding>

     Specify encoding of member names for *note -l: 2933, *note -e:
     2932. and *note -t: 2938.

     Added in version 3.11.


File: python.info,  Node: Decompression pitfalls,  Prev: コマンドラインインターフェイス<2>,  Up: zipfile --- ZIP アーカイブの処理

5.13.5.7 Decompression pitfalls
...............................

The extraction in zipfile module might fail due to some pitfalls listed
below.

* Menu:

* From file itself::
* File System limitations::
* Resources limitations::
* Interruption::
* Default behaviors of extraction::


File: python.info,  Node: From file itself,  Next: File System limitations,  Up: Decompression pitfalls

5.13.5.8 From file itself
.........................

Decompression may fail due to incorrect password / CRC checksum / ZIP
format or unsupported compression method / decryption.


File: python.info,  Node: File System limitations,  Next: Resources limitations,  Prev: From file itself,  Up: Decompression pitfalls

5.13.5.9 File System limitations
................................

Exceeding limitations on different file systems can cause decompression
failed.  Such as allowable characters in the directory entries, length
of the file name, length of the pathname, size of a single file, and
number of files, etc.


File: python.info,  Node: Resources limitations,  Next: Interruption,  Prev: File System limitations,  Up: Decompression pitfalls

5.13.5.10 Resources limitations
...............................

The lack of memory or disk volume would lead to decompression failed.
For example, decompression bombs (aka ZIP bomb(1)) apply to zipfile
library that can cause disk volume exhaustion.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Zip_bomb


File: python.info,  Node: Interruption,  Next: Default behaviors of extraction,  Prev: Resources limitations,  Up: Decompression pitfalls

5.13.5.11 Interruption
......................

Interruption during the decompression, such as pressing control-C or
killing the decompression process may result in incomplete decompression
of the archive.


File: python.info,  Node: Default behaviors of extraction,  Prev: Interruption,  Up: Decompression pitfalls

5.13.5.12 Default behaviors of extraction
.........................................

Not knowing the default extraction behaviors can cause unexpected
decompression results.  For example, when extracting the same archive
twice, it overwrites files without asking.


File: python.info,  Node: tarfile --- tar アーカイブファイルの読み書き,  Prev: zipfile --- ZIP アーカイブの処理,  Up: データ圧縮とアーカイブ

5.13.6 ‘tarfile’ -- tar アーカイブファイルの読み書き
----------------------------------------------------

'ソースコード:' Lib/tarfile.py(1)

__________________________________________________________________

*note tarfile: c8. モジュールは、gzip、bz2、および lzma 圧縮されたものを
含む、tar アーカイブを読み書きできます。‘.zip’ ファイルの読み書きには
*note zipfile: 117. モジュールか、あるいは *note shutil: 11ea. の高水準
関数を使用してください。

いくつかの事実と形態:

   * モジュールが利用可能な場合、*note gzip: 5d.、*note bz2: f. ならびに
     *note lzma: 7e. で圧縮されたアーカイブを読み書きします。

   * POSIX.1-1988 (ustar) フォーマットの読み書きをサポートしています。

   * 'longname' および 'longlink' 拡張を含む GNU tar フォーマットの読み
     書きをサポートしています。スパースファイルの復元を含む 'sparse' 拡
     張は読み込みのみサポートしています。

   * POSIX.1-2001 (pax) フォーマットの読み書きをサポートしています。

   * ディレクトリ、一般ファイル、ハードリンク、シンボリックリンク、
     fifo、キャラクターデバイスおよびブロックデバイスを処理します。また
     、タイムスタンプ、アクセス許可や所有者のようなファイル情報の取得お
     よび保存が可能です。

バージョン 3.3 で変更: *note lzma: 7e. 圧縮をサポートしました。

バージョン 3.12 で変更: Archives are extracted using a *note filter:
439, which makes it possible to either limit surprising/dangerous
features, or to acknowledge that they are expected and the archive is
fully trusted.  By default, archives are fully trusted, but this default
is deprecated and slated to change in Python 3.14.

 -- の関数: tarfile.open (name=None, mode='r', fileobj=None,
          bufsize=10240, **kwargs)

     パス名 'name' の *note TarFile: 11e1. オブジェクトを返します。*note
     TarFile: 11e1. オブジェクトと、利用できるキーワード引数に関する詳細
     な情報については、*note TarFile オブジェクト: 2944. 節を参照してく
     ださい。

     'mode' は ‘'filemode[:compression]'’ の形式をとる文字列でなければな
     りません。デフォルトの値は ‘'r'’ です。以下に 'mode' のとりうる組み
     合わせすべてを示します:

     mode                   action
                            
     -------------------------------------------------------------------------
                            
     ‘'r' または 'r:*'’     圧縮方法に関して透過的に、読み込み用にオープン
                            します (推奨)。
                            
                            
     ‘'r:'’                 非圧縮で読み込み用に排他的にオープンします。
                            
                            
     ‘'r:gz'’               gzip 圧縮で読み込み用にオープンします。
                            
                            
     ‘'r:bz2'’              bzip2 圧縮で読み込み用にオープンします。
                            
                            
     ‘'r:xz'’               lzma 圧縮で読み込み用にオープンします。
                            
                            
     ‘'x'’ or ‘'x:'’        圧縮せずに tarfile を排他的に作成します。
                            tarfile が既存の場合
                            *note FileExistsError: fea. 例外を送出します。
                            
                            
     ‘'x:gz'’               gzip 圧縮で tarfile を作成します。tarfile が既
                            存の場合 *note FileExistsError: fea. 例外を送出
                            します。
                            
                            
     ‘'x:bz2'’              bzip2 圧縮で tarfile を作成します。tarfile が既
                            存の場合 *note FileExistsError: fea. 例外を送出
                            します。
                            
                            
     ‘'x:xz'’               lzma 圧縮で tarfile を作成します。tarfile が既
                            存の場合 *note FileExistsError: fea. 例外を送出
                            します。
                            
                            
     ‘'a' または 'a:'’      非圧縮で追記用にオープンします。ファイルが存在
                            しない場合は新たに作成されます。
                            
                            
     ‘'w' または 'w:'’      非圧縮で書き込み用にオープンします。
                            
                            
     ‘'w:gz'’               gzip 圧縮で書き込み用にオープンします。
                            
                            
     ‘'w:bz2'’              bzip2 圧縮で書き込み用にオープンします。
                            
                            
     ‘'w:xz'’               lzma 圧縮で書き込み用にオープンします。
                            

     ‘'a:gz'’、‘'a:bz2'’、‘'a:xz'’ は利用できないことに注意して下さい。
     もし 'mode' が、ある (圧縮した) ファイルを読み込み用にオープンする
     のに適していないなら、*note ReadError: 1805. が送出されます。これを
     防ぐには 'mode' ‘'r'’ を使って下さい。もし圧縮方式がサポートされて
     いなければ、*note CompressionError: 2945. が送出されます。

     もし 'fileobj' が指定されていれば、それは 'name' でバイナリモードで
     オープンされた *note ファイルオブジェクト: 1193. の代替として使うこ
     とができます。そのファイルオブジェクトの位置が 0 であることを前提に
     動作します。

     For modes ‘'w:gz'’, ‘'x:gz'’, ‘'w|gz'’, ‘'w:bz2'’, ‘'x:bz2'’,
     ‘'w|bz2'’, *note tarfile.open(): e40. accepts the keyword argument
     'compresslevel' (default ‘9’) to specify the compression level of
     the file.

     ‘'w:xz'’ および ‘'x:xz'’ モードの場合、*note tarfile.open(): e40. は
     ファイルの圧縮レベルを指定するキーワード引数 'preset' を受け付けま
     す。

     For special purposes, there is a second format for 'mode':
     ‘'filemode|[compression]'’.  *note tarfile.open(): e40. will return
     a *note TarFile: 11e1. object that processes its data as a stream
     of blocks.  No random seeking will be done on the file.  If given,
     'fileobj' may be any object that has a *note read(): de9. or *note
     write(): 2946. method (depending on the 'mode') that works with
     bytes.  'bufsize' specifies the blocksize and defaults to ‘20 *
     512’ bytes.  Use this variant in combination with e.g.
     ‘sys.stdin.buffer’, a socket *note file object: 1193. or a tape
     device.  However, such a *note TarFile: 11e1. object is limited in
     that it does not allow random access, see *note 使用例: 2947.  The
     currently possible modes:

     モード            動作
                       
     -------------------------------------------------------------------
                       
     ‘'r|*'’           tar ブロックの 'stream' を圧縮方法に関して透過
                       的に読み込み用にオープンします。
                       
                       
     ‘'r|'’            非圧縮 tar ブロックの 'stream' を読み込み用に
                       オープンします。
                       
                       
     ‘'r|gz'’          gzip 圧縮の 'stream' を読み込み用にオープンし
                       ます。
                       
                       
     ‘'r|bz2'’         bzip2 圧縮の 'stream' を読み込み用にオープンし
                       ます。
                       
                       
     ‘'r|xz'’          lzma 圧縮の 'stream' を読み込み用にオープンし
                       ます。
                       
                       
     ‘'w|'’            非圧縮の 'stream' を書き込み用にオープンします
                       。
                       
                       
     ‘'w|gz'’          gzip 圧縮の 'stream' を書き込み用にオープンし
                       ます。
                       
                       
     ‘'w|bz2'’         bzip2 圧縮の 'stream' を書き込み用にオープンし
                       ます。
                       
                       
     ‘'w|xz'’          lzma 圧縮の 'stream' を書き込み用にオープンし
                       ます。
                       

     バージョン 3.5 で変更: ‘'x'’ (排他的作成) モードが追加されました。

     バージョン 3.6 で変更: 'name' パラメタが *note path-like object:
     280. を受け付けるようになりました。

     バージョン 3.12 で変更: The 'compresslevel' keyword argument also
     works for streams.

 -- クラス: tarfile.TarFile

     tar アーカイブを読み書きするためのクラスです。このクラスを直接使わ
     ないこと: 代わりに *note tarfile.open(): e40. を使ってください。
     *note TarFile オブジェクト: 2944. を参照してください。

 -- の関数: tarfile.is_tarfile (name)

     もし 'name' が tar アーカイブファイルであり、*note tarfile: c8. モ
     ジュールで読み込める場合に *note True: bdb. を返します。 'name' は
     *note str: 418.、ファイルまたは file-like オブジェクトです。

     バージョン 3.9 で変更: ファイルおよびファイルライクオブジェクトをサ
     ポートしました。

*note tarfile: c8. モジュールは以下の例外を定義しています:

 -- 例外: tarfile.TarError

     すべての *note tarfile: c8. 例外のための基本クラスです。

 -- 例外: tarfile.ReadError

     tar アーカイブがオープンされた時、*note tarfile: c8. モジュールで操
     作できないか、あるいは何か無効であるとき送出されます。

 -- 例外: tarfile.CompressionError

     圧縮方法がサポートされていないか、あるいはデータを正しくデコードで
     きない時に送出されます。

 -- 例外: tarfile.StreamError

     ストリームのような *note TarFile: 11e1. オブジェクトで典型的な制限
     のために送出されます。

 -- 例外: tarfile.ExtractError

     *note TarFile.extract(): e42. を使った時に '致命的でない' エラーに
     対して送出されます。ただし *note TarFile.errorlevel: 294b.‘== 2’ の
     場合に限ります。

 -- 例外: tarfile.HeaderError

     *note TarInfo.frombuf(): 294d. メソッドが取得したバッファーが不正だ
     ったときに送出されます。

 -- 例外: tarfile.FilterError

     Base class for members *note refused: 294f. by filters.

      -- の属性: tarinfo

          Information about the member that the filter refused to
          extract, as *note TarInfo: 2951.

 -- 例外: tarfile.AbsolutePathError

     Raised to refuse extracting a member with an absolute path.

 -- 例外: tarfile.OutsideDestinationError

     Raised to refuse extracting a member outside the destination
     directory.

 -- 例外: tarfile.SpecialFileError

     Raised to refuse extracting a special file (e.g.  a device or
     pipe).

 -- 例外: tarfile.AbsoluteLinkError

     Raised to refuse extracting a symbolic link with an absolute path.

 -- 例外: tarfile.LinkOutsideDestinationError

     Raised to refuse extracting a symbolic link pointing outside the
     destination directory.

モジュールレベルで以下の定数が利用できます。

 -- データ: tarfile.ENCODING

     既定の文字エンコーディング。Windows では ‘'utf-8'’ 、それ以外では
     *note sys.getfilesystemencoding(): c27. の返り値です。

 -- データ: tarfile.REGTYPE
 -- データ: tarfile.AREGTYPE

     A regular file *note type: 295a.

 -- データ: tarfile.LNKTYPE

     A link (inside tarfile) *note type: 295a.

 -- データ: tarfile.SYMTYPE

     A symbolic link *note type: 295a.

 -- データ: tarfile.CHRTYPE

     A character special device *note type: 295a.

 -- データ: tarfile.BLKTYPE

     A block special device *note type: 295a.

 -- データ: tarfile.DIRTYPE

     A directory *note type: 295a.

 -- データ: tarfile.FIFOTYPE

     A FIFO special device *note type: 295a.

 -- データ: tarfile.CONTTYPE

     A contiguous file *note type: 295a.

 -- データ: tarfile.GNUTYPE_LONGNAME

     A GNU tar longname *note type: 295a.

 -- データ: tarfile.GNUTYPE_LONGLINK

     A GNU tar longlink *note type: 295a.

 -- データ: tarfile.GNUTYPE_SPARSE

     A GNU tar sparse file *note type: 295a.

以下の各定数は、*note tarfile: c8. モジュールが作成できる tar アーカイブ
フォーマットを定義しています。詳細は、*note サポートしている tar
フォーマット: 2965. を参照してください。

 -- データ: tarfile.USTAR_FORMAT

     POSIX.1-1988 (ustar) フォーマット。

 -- データ: tarfile.GNU_FORMAT

     GNU tar フォーマット。

 -- データ: tarfile.PAX_FORMAT

     POSIX.1-2001 (pax) フォーマット。

 -- データ: tarfile.DEFAULT_FORMAT

     アーカイブを作成する際のデフォルトのフォーマット。現在は *note
     PAX_FORMAT: 2968. です。

     バージョン 3.8 で変更: 新しいアーカイブのデフォルトフォーマットが
     *note GNU_FORMAT: 2967. から *note PAX_FORMAT: 2968. に変更されまし
     た。

参考
....

*note zipfile: 117. モジュール

     *note zipfile: 117. 標準モジュールのドキュメント。

*note アーカイブ化操作: 11ea.

     *note shutil: b3. が提供するより高水準のアーカイブ機能についてのド
     キュメント。

GNU tar manual, Basic Tar Format(2)

     GNU tar 拡張機能を含む、tar アーカイブファイルのためのドキュメント
     。

* Menu:

* TarFile オブジェクト::
* TarInfo オブジェクト::
* Extraction filters::
* コマンドラインインターフェイス: コマンドラインインターフェイス<3>.
* 使用例: 使用例<15>.
* サポートしている tar フォーマット::
* Unicode に関する問題::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tarfile.py

   (2) https://www.gnu.org/software/tar/manual/html_node/Standard.html


File: python.info,  Node: TarFile オブジェクト,  Next: TarInfo オブジェクト,  Up: tarfile --- tar アーカイブファイルの読み書き

5.13.6.1 TarFile オブジェクト
.............................

*note TarFile: 11e1. オブジェクトは、tar アーカイブへのインターフェース
を提供します。tar アーカイブは一連のブロックです。アーカイブメンバー (保
存されたファイル) は、ヘッダーブロックとそれに続くデータブロックで構成さ
れています。一つの tar アーカイブにファイルを何回も保存することができま
す。各アーカイブメンバーは、*note TarInfo: 11e2. オブジェクトで確認でき
ます。詳細については *note TarInfo オブジェクト: 2951. を参照してくださ
い。

*note TarFile: 11e1. オブジェクトは *note with: 59c. 文のコンテキストマ
ネージャーとして利用できます。with ブロックが終了したときにオブジェクト
はクローズされます。例外が発生した時、内部で利用されているファイルオブジ
ェクトのみがクローズされ、書き込み用にオープンされたアーカイブのファイナ
ライズは行われないことに注意してください。*note 使用例: 2947. 節のユース
ケースを参照してください。

Added in version 3.2: コンテキスト管理のプロトコルがサポートされました。

 -- クラス: tarfile.TarFile (name=None, mode='r', fileobj=None,
          format=DEFAULT_FORMAT, tarinfo=TarInfo, dereference=False,
          ignore_zeros=False, encoding=ENCODING,
          errors='surrogateescape', pax_headers=None, debug=0,
          errorlevel=1, stream=False)

     以下のすべての引数はオプションで、インスタンス属性としてもアクセス
     できます。

     'name' is the pathname of the archive.  'name' may be a *note
     path-like object: 280.  It can be omitted if 'fileobj' is given.
     In this case, the file object's ‘name’ attribute is used if it
     exists.

     'mode' は、既存のアーカイブから読み込むための ‘'r'’、既存のアーカイ
     ブに追記するための ‘'a'’、既存のファイルがあれば上書きして新しいフ
     ァイルを作成する ‘'w'’ 、あるいは存在しない場合にのみ新しいファイル
     を作成する ‘'x'’ のいずれかです。

     'fileobj' が与えられていれば、それを使ってデータを読み書きします。
     もしそれが決定できれば、'mode' は 'fileobj' のモードで上書きされま
     す。'fileobj' は位置 0 から利用されます。

          注釈: *note TarFile: 11e1. をクローズした時、'fileobj' はクロ
          ーズされません。

     'format' はアーカイブの書き込みフォーマットを制御します。モジュール
     レベルで定義されている、*note USTAR_FORMAT: 2966.、*note
     GNU_FORMAT: 2967.、あるいは *note PAX_FORMAT: 2968. のいずれかであ
     る必要があります。 読み出しのときは、1 つのアーカイブに異なるフォー
     マットが混在していたとしても、フォーマットは自動的に検知されます。

     'tarinfo' 引数を利用して、デフォルトの *note TarInfo: 11e2. クラス
     を別のクラスで置き換えることができます。

     'dereference' が *note False: b05. だった場合、シンボリックリンクや
     ハードリンクがアーカイブに追加されます。*note True: bdb. だった場合
     、リンクのターゲットとなるファイルの内容がアーカイブに追加されます
     。シンボリックリンクをサポートしていないシステムでは効果がありませ
     ん。

     'ignore_zeros' が *note False: b05. だった場合、空ブロックをアーカ
     イブの終端として扱います。*note True: bdb. だった場合、空の (無効な
     ) ブロックをスキップして、可能な限り多くのメンバーを取得しようとし
     ます。このオプションは、連結されたり、壊れたアーカイブファイルを扱
     うときにのみ、意味があります。

     'debug' は ‘0’ (デバッグメッセージ無し) から ‘3’ (全デバッグメッセ
     ージ) まで設定できます。このメッセージは ‘sys.stderr’ に書き込まれ
     ます。

     'errorlevel' controls how extraction errors are handled, see *note
     the corresponding attribute: 294b.

     引数 'encoding' および 'errors' にはアーカイブの読み書きやエラー文
     字列の変換に使用する文字エンコーディングを指定します。ほとんどのユ
     ーザーはデフォルト設定のままで動作します。詳細に関しては *note
     Unicode に関する問題: 296b. 節を参照してください。

     引数 'pax_headers' は、オプションの文字列辞書で、'format' が *note
     PAX_FORMAT: 2968. だった場合に pax グローバルヘッダーに追加されます
     。

     If 'stream' is set to *note True: bdb. then while reading the
     archive info about files in the archive are not cached, saving
     memory.

     バージョン 3.2 で変更: 引数 'errors' のデフォルトが
     ‘'surrogateescape'’ になりました。

     バージョン 3.5 で変更: ‘'x'’ (排他的作成) モードが追加されました。

     バージョン 3.6 で変更: 'name' パラメタが *note path-like object:
     280. を受け付けるようになりました。

     バージョン 3.13 で変更: Add the 'stream' parameter.

 -- メソッド: classmethod TarFile.open (...)

     代替コンストラクターです。モジュールレベルでの *note
     tarfile.open(): e40. 関数は、実際はこのクラスメソッドへのショートカ
     ットです。

 -- メソッド: TarFile.getmember (name)

     メンバー 'name' に対する *note TarInfo: 11e2. オブジェクトを返しま
     す。'name' がアーカイブに見つからなければ、*note KeyError: 31d. が
     送出されます。

          注釈: アーカイブ内にメンバーが複数ある場合は、最後に出現するも
          のが最新のバージョンとみなされます。

 -- メソッド: TarFile.getmembers ()

     *note TarInfo: 11e2. アーカイブのメンバーをオブジェクトのリストとし
     て返します。このリストはアーカイブ内のメンバーと同じ順番です。

 -- メソッド: TarFile.getnames ()

     メンバーをその名前のリストを返します。これは *note getmembers():
     e44. で返されるリストと同じ順番です。

 -- メソッド: TarFile.list (verbose=True, *, members=None)

     内容の一覧を ‘sys.stdout’ に出力します。'verbose' が *note False:
     b05. の場合、メンバー名のみ表示します。*note True: bdb. の場合、
     ‘ls -l’ に似た出力を生成します。オプションの 'members' を与える場合
     、 *note getmembers(): e44. が返すリストのサブセットである必要があ
     ります。

     バージョン 3.5 で変更: 'members' 引数が追加されました。.

 -- メソッド: TarFile.next ()

     *note TarFile: 11e1. が読み込み用にオープンされている時、アーカイブ
     の次のメンバーを *note TarInfo: 11e2. オブジェクトとして返します。
     もしそれ以上利用可能なものがなければ、*note None: 641. を返します。

 -- メソッド: TarFile.extractall (path='.', members=None, *,
          numeric_owner=False, filter=None)

     すべてのメンバーをアーカイブから現在の作業ディレクトリまたは 'path'
     に抽出します。オプションの 'members' が与えられるときには、*note
     getmembers(): e44. で返されるリストの一部でなければなりません。所有
     者、変更時刻、アクセス権限のようなディレクトリ情報はすべてのメンバ
     ーが抽出された後にセットされます。これは二つの問題を回避するためで
     す。一つはディレクトリの変更時刻はその中にファイルが作成されるたび
     にリセットされるということ、もう一つはディレクトリに書き込み許可が
     なければその中のファイル抽出は失敗してしまうということです。

     'numeric_owner' が *note True: bdb. の場合、tarfile の uid と gid 数
     値が抽出されたファイルのオーナー/グループを設定するために使用されま
     す。False の場合、tarfile の名前付きの値が使用されます。

     The 'filter' argument specifies how ‘members’ are modified or
     rejected before extraction.  See *note Extraction filters: 439. for
     details.  It is recommended to set this explicitly depending on
     which 'tar' features you need to support.

          警告: 内容を信頼できない tar アーカイブを、事前の内部チェック
          前に展開してはいけません。ファイルが 'path' の外側に作られる可
          能性があります。例えば、‘"/"’ で始まる絶対パスのファイル名や、
          2 重ドット ‘".."’ で始まるパスのファイル名です。

          Set ‘filter='data'’ to prevent the most dangerous security
          issues, and read the *note Extraction filters: 439. section
          for details.

     バージョン 3.5 で変更: 'numeric_owner' 引数が追加されました。

     バージョン 3.6 で変更: 'path' パラメタが *note path-like object:
     280. を受け付けるようになりました。

     バージョン 3.12 で変更: 'filter' パラメータが追加されました。

 -- メソッド: TarFile.extract (member, path='', set_attrs=True, *,
          numeric_owner=False, filter=None)

     アーカイブからメンバーの完全な名前を使って、現在のディレクトリに展
     開します。ファイル情報はできる限り正確に展開されます。 'member' は
     ファイル名もしくは *note TarInfo: 11e2. オブジェクトです。 'path' を
     使って別のディレクトリを指定することもできます。 'path' は　*note
     path-like object: 280. でも構いません。'set_attrs' が false でない
     限り、ファイルの属性 (所有者、最終更新時刻、モード) は設定されます
     。

     The 'numeric_owner' and 'filter' arguments are the same as for
     *note extractall(): e41.

          注釈: *note extract(): e42. メソッドはいくつかの展開に関する問
          題を扱いません。ほとんどの場合、*note extractall(): e41. メソ
          ッドの利用を考慮するべきです。

          警告: *note extractall(): e41. の警告を参してください。

          Set ‘filter='data'’ to prevent the most dangerous security
          issues, and read the *note Extraction filters: 439. section
          for details.

     バージョン 3.2 で変更: パラメーターに 'set_attrs' を追加しました。

     バージョン 3.5 で変更: 'numeric_owner' 引数が追加されました。

     バージョン 3.6 で変更: 'path' パラメタが *note path-like object:
     280. を受け付けるようになりました。

     バージョン 3.12 で変更: 'filter' パラメータが追加されました。

 -- メソッド: TarFile.extractfile (member)

     アーカイブからメンバーをファイルオブジェクトとして抽出します。
     'member' はファイル名でも *note TarInfo: 11e2. オブジェクトでも構い
     ません。'member' が一般ファイルまたはリンクの場合、*note
     io.BufferedReader: 11df. オブジェクトが返されます。 存在するそれ以
     外のメンバーでは、 *note None: 641. が返されます。 それ以外の場合、
     *note None: 641. が返されます。 アーカイブに 'member' が存在しない
     場合は *note KeyError: 31d. が送出されます。

     バージョン 3.3 で変更: 戻り値が *note io.BufferedReader: 11df. オブ
     ジェクトになりました。

     バージョン 3.13 で変更: The returned *note io.BufferedReader: 11df.
     object has the ‘mode’ attribute which is always equal to ‘'rb'’.

 -- の属性: TarFile.errorlevel: *note int: 238.

     If 'errorlevel' is ‘0’, errors are ignored when using *note
     TarFile.extract(): e42. and *note TarFile.extractall(): e41.
     Nevertheless, they appear as error messages in the debug output
     when 'debug' is greater than 0.  If ‘1’ (the default), all 'fatal'
     errors are raised as *note OSError: 3f0. or *note FilterError:
     294e. exceptions.  If ‘2’, all 'non-fatal' errors are raised as
     *note TarError: 2948. exceptions as well.

     Some exceptions, e.g.  ones caused by wrong argument types or data
     corruption, are always raised.

     Custom *note extraction filters: 439. should raise *note
     FilterError: 294e. for 'fatal' errors and *note ExtractError: 294a.
     for 'non-fatal' ones.

     Note that when an exception is raised, the archive may be partially
     extracted.  It is the user’s responsibility to clean up.

 -- の属性: TarFile.extraction_filter

     Added in version 3.12.

     The *note extraction filter: 439. used as a default for the
     'filter' argument of *note extract(): e42. and *note extractall():
     e41.

     The attribute may be ‘None’ or a callable.  String names are not
     allowed for this attribute, unlike the 'filter' argument to *note
     extract(): e42.

     If ‘extraction_filter’ is ‘None’ (the default), calling an
     extraction method without a 'filter' argument will raise a
     ‘DeprecationWarning’, and fall back to the *note fully_trusted:
     2970. filter, whose dangerous behavior matches previous versions of
     Python.

     In Python 3.14+, leaving ‘extraction_filter=None’ will cause
     extraction methods to use the *note data: 1662. filter by default.

     The attribute may be set on instances or overridden in subclasses.
     It also is possible to set it on the ‘TarFile’ class itself to set
     a global default, although, since it affects all uses of 'tarfile',
     it is best practice to only do so in top-level applications or
     *note site configuration: b5.  To set a global default this way, a
     filter function needs to be wrapped in *note staticmethod(): 3ef.
     to prevent injection of a ‘self’ argument.

 -- メソッド: TarFile.add (name, arcname=None, recursive=True, *,
          filter=None)

     ファイル 'name' をアーカイブに追加します。 'name' は、任意のファイ
     ルタイプ (ディレクトリ、fifo、シンボリックリンク等)です。 'arcname'
     が与えられている場合は、それはアーカイブ内のファイルの代替名を指定
     します。 デフォルトではディレクトリは再帰的に追加されます。 これは
     、 'recursive' を *note False: b05. に設定すると避けられます。 再帰
     処理はソートされた順序でエントリーを追加します。 'filter' が与えら
     れた場合、それは *note TarInfo: 11e2. オブジェクトを引数として受け
     取り、操作した *note TarInfo: 11e2. オブジェクトを返す関数でなけれ
     ばなりません。 代わりに *note None: 641. を返した場合、 *note
     TarInfo: 11e2. オブジェクトはアーカイブから除外されます。 *note
     使用例: 2947. にある例を参照してください。

     バージョン 3.2 で変更: 'filter' パラメータが追加されました。

     バージョン 3.7 で変更: 再帰処理はソートされた順序でエントリーを追加
     するようになりました。

 -- メソッド: TarFile.addfile (tarinfo, fileobj=None)

     Add the *note TarInfo: 11e2. object 'tarinfo' to the archive.  If
     'tarinfo' represents a non zero-size regular file, the 'fileobj'
     argument should be a *note binary file: 1bf1, and ‘tarinfo.size’
     bytes are read from it and added to the archive.  You can create
     *note TarInfo: 11e2. objects directly, or by using *note
     gettarinfo(): 2971.

     バージョン 3.13 で変更: 'fileobj' must be given for non-zero-sized
     regular files.

 -- メソッド: TarFile.gettarinfo (name=None, arcname=None, fileobj=None)

     *note os.stat(): 46d. の結果か、既存のファイルに相当するものから、
     *note TarInfo: 11e2. オブジェクトを作成します。このファイルは、
     'name' で名付けられるか、ファイル記述子を持つ *note file object:
     1193. 'fileobj' として指定されます。'name' は *note path-like
     object: 280. でも構いません。 'arcname' が与えられた場合、アーカイ
     ブ内のファイルに対して代替名を指定します。与えられない場合、名前は
     'fileobj' の *note name: 28d8. 属性 'name' 属性から取られます。名前
     はテキスト文字列にしてください。

     *note TarInfo: 11e2. の属性の一部は、*note addfile(): 1594. を使用
     して追加する前に修正できます。ファイルオブジェクトが、ファイルの先
     頭にある通常のファイルオブジェクトでない場合、 *note size: 2972. な
     どの属性は修正が必要かもしれません。これは、 *note GzipFile: 3f3. な
     どの属性に当てはまります。*note name: 2973. も修正できるかもしれず
     、この場合、'arcname' はダミーの文字列にすることができます。

     バージョン 3.6 で変更: 'name' パラメタが *note path-like object:
     280. を受け付けるようになりました。

 -- メソッド: TarFile.close ()

     *note TarFile: 11e1. をクローズします。書き込みモードでは、完了ゼロ
     ブロックが 2 個アーカイブに追加されます。

 -- の属性: TarFile.pax_headers: *note dict: 237.

     pax グローバルヘッダーに含まれる key-value ペアの辞書です。


File: python.info,  Node: TarInfo オブジェクト,  Next: Extraction filters,  Prev: TarFile オブジェクト,  Up: tarfile --- tar アーカイブファイルの読み書き

5.13.6.2 TarInfo オブジェクト
.............................

*note TarInfo: 11e2. オブジェクトは *note TarFile: 11e1. の一つのメンバ
ーを表します。ファイルに必要なすべての属性 (ファイルタイプ、ファイルサイ
ズ、時刻、アクセス権限、所有者等のような) を保存する他に、そのタイプを決
定するのに役に立ついくつかのメソッドを提供します。これにはファイルのデー
タそのものは '含まれません' 。

*note TarInfo: 11e2. objects are returned by *note TarFile: 11e1.'s
methods *note getmember(): 17be, *note getmembers(): e44. and *note
gettarinfo(): 2971.

Modifying the objects returned by *note getmember(): 17be. or *note
getmembers(): e44. will affect all subsequent operations on the archive.
For cases where this is unwanted, you can use *note copy.copy(): 1e. or
call the *note replace(): 2977. method to create a modified copy in one
step.

Several attributes can be set to ‘None’ to indicate that a piece of
metadata is unused or unknown.  Different *note TarInfo: 11e2. methods
handle ‘None’ differently:

   - The *note extract(): e42. or *note extractall(): e41. methods will
     ignore the corresponding metadata, leaving it set to a default.

   - *note addfile(): 1594. will fail.

   - *note list(): e43. will print a placeholder string.

 -- クラス: tarfile.TarInfo (name='')

     *note TarInfo: 11e2. オブジェクトを作成します。

 -- メソッド: classmethod TarInfo.frombuf (buf, encoding, errors)

     *note TarInfo: 11e2. オブジェクトを文字列バッファー 'buf' から作成
     して返します。

     バッファーが不正な場合 *note HeaderError: 294c. を送出します。

 -- メソッド: classmethod TarInfo.fromtarfile (tarfile)

     *note TarFile: 11e1. オブジェクトの 'tarfile' から、次のメンバーを
     読み込んで、それを *note TarInfo: 11e2. オブジェクトとして返します
     。

 -- メソッド: TarInfo.tobuf (format=DEFAULT_FORMAT, encoding=ENCODING,
          errors='surrogateescape')

     *note TarInfo: 11e2. オブジェクトから文字列バッファーを作成します。
     引数についての情報は、*note TarFile: 11e1. クラスのコンストラクター
     を参照してください。

     バージョン 3.2 で変更: 引数 'errors' のデフォルトが
     ‘'surrogateescape'’ になりました。

‘TarInfo’ オブジェクトには以下のデータ属性があります:

 -- の属性: TarInfo.name: *note str: 418.

     アーカイブメンバーの名前。

 -- の属性: TarInfo.size: *note int: 238.

     バイト単位でのサイズ。

 -- の属性: TarInfo.mtime: *note int: 238. | *note float: 2ce.

     Time of last modification in seconds since the *note epoch: 297b,
     as in *note os.stat_result.st_mtime: 297c.

     バージョン 3.12 で変更: Can be set to ‘None’ for *note extract():
     e42. and *note extractall(): e41, causing extraction to skip
     applying this attribute.

 -- の属性: TarInfo.mode: *note int: 238.

     Permission bits, as for *note os.chmod(): 1fc.

     バージョン 3.12 で変更: Can be set to ‘None’ for *note extract():
     e42. and *note extractall(): e41, causing extraction to skip
     applying this attribute.

 -- の属性: TarInfo.type

     ファイルタイプ。'type' は通常、定数 *note REGTYPE: 2958.、*note
     AREGTYPE: 2959.、*note LNKTYPE: 295b.、*note SYMTYPE: 295c.、*note
     DIRTYPE: 295f.、*note FIFOTYPE: 2960.、*note CONTTYPE: 2961.、*note
     CHRTYPE: 295d.、*note BLKTYPE: 295e.、あるいは *note
     GNUTYPE_SPARSE: 2964. のいずれかです。*note TarInfo: 11e2. オブジェ
     クトのタイプをもっと簡単に解決するには、下記の ‘is*()’ メソッドを使
     って下さい。

 -- の属性: TarInfo.linkname: *note str: 418.

     リンク先ファイルの名前。これはタイプ *note LNKTYPE: 295b. と *note
     SYMTYPE: 295c. の *note TarInfo: 11e2. オブジェクトにだけ存在します
     。

     For symbolic links (‘SYMTYPE’), the 'linkname' is relative to the
     directory that contains the link.  For hard links (‘LNKTYPE’), the
     'linkname' is relative to the root of the archive.

 -- の属性: TarInfo.uid: *note int: 238.

     ファイルメンバーを保存した元のユーザーのユーザー ID。

     バージョン 3.12 で変更: Can be set to ‘None’ for *note extract():
     e42. and *note extractall(): e41, causing extraction to skip
     applying this attribute.

 -- の属性: TarInfo.gid: *note int: 238.

     ファイルメンバーを保存した元のユーザーのグループ ID。

     バージョン 3.12 で変更: Can be set to ‘None’ for *note extract():
     e42. and *note extractall(): e41, causing extraction to skip
     applying this attribute.

 -- の属性: TarInfo.uname: *note str: 418.

     ファイルメンバーを保存した元のユーザーのユーザー名。

     バージョン 3.12 で変更: Can be set to ‘None’ for *note extract():
     e42. and *note extractall(): e41, causing extraction to skip
     applying this attribute.

 -- の属性: TarInfo.gname: *note str: 418.

     ファイルメンバーを保存した元のユーザーのグループ名。

     バージョン 3.12 で変更: Can be set to ‘None’ for *note extract():
     e42. and *note extractall(): e41, causing extraction to skip
     applying this attribute.

 -- の属性: TarInfo.chksum: *note int: 238.

     Header checksum.

 -- の属性: TarInfo.devmajor: *note int: 238.

     Device major number.

 -- の属性: TarInfo.devminor: *note int: 238.

     Device minor number.

 -- の属性: TarInfo.offset: *note int: 238.

     The tar header starts here.

 -- の属性: TarInfo.offset_data: *note int: 238.

     The file's data starts here.

 -- の属性: TarInfo.sparse

     Sparse member information.

 -- の属性: TarInfo.pax_headers: *note dict: 237.

     pax 拡張ヘッダーに関連付けられた、key-value ペアの辞書。

 -- メソッド: TarInfo.replace (name=..., mtime=..., mode=...,
          linkname=..., uid=..., gid=..., uname=..., gname=...,
          deep=True)

     Added in version 3.12.

     Return a 'new' copy of the ‘TarInfo’ object with the given
     attributes changed.  For example, to return a ‘TarInfo’ with the
     group name set to ‘'staff'’, use:

          new_tarinfo = old_tarinfo.replace(gname='staff')

     By default, a deep copy is made.  If 'deep' is false, the copy is
     shallow, i.e.  ‘pax_headers’ and any custom attributes are shared
     with the original ‘TarInfo’ object.

*note TarInfo: 11e2. オブジェクトは便利な照会用のメソッドもいくつか提供
しています:

 -- メソッド: TarInfo.isfile ()

     Return *note True: bdb. if the *note TarInfo: 11e2. object is a
     regular file.

 -- メソッド: TarInfo.isreg ()

     *note isfile(): 298a. と同じです。

 -- メソッド: TarInfo.isdir ()

     ディレクトリの場合に *note True: bdb. を返します。

 -- メソッド: TarInfo.issym ()

     シンボリックリンクの場合に *note True: bdb. を返します。

 -- メソッド: TarInfo.islnk ()

     ハードリンクの場合に *note True: bdb. を返します。

 -- メソッド: TarInfo.ischr ()

     キャラクターデバイスの場合に *note True: bdb. を返します。

 -- メソッド: TarInfo.isblk ()

     ブロックデバイスの場合に *note True: bdb. を返します。

 -- メソッド: TarInfo.isfifo ()

     FIFO の場合に *note True: bdb. を返します。

 -- メソッド: TarInfo.isdev ()

     キャラクターデバイス、ブロックデバイスあるいは FIFO のいずれかの場
     合に *note True: bdb. を返します。


File: python.info,  Node: Extraction filters,  Next: コマンドラインインターフェイス<3>,  Prev: TarInfo オブジェクト,  Up: tarfile --- tar アーカイブファイルの読み書き

5.13.6.3 Extraction filters
...........................

Added in version 3.12.

The 'tar' format is designed to capture all details of a UNIX-like
filesystem, which makes it very powerful.  Unfortunately, the features
make it easy to create tar files that have unintended - and possibly
malicious - effects when extracted.  For example, extracting a tar file
can overwrite arbitrary files in various ways (e.g.  by using absolute
paths, ‘..’ path components, or symlinks that affect later members).

In most cases, the full functionality is not needed.  Therefore,
'tarfile' supports extraction filters: a mechanism to limit
functionality, and thus mitigate some of the security issues.

参考
....

PEP 706(1)

     Contains further motivation and rationale behind the design.

The 'filter' argument to *note TarFile.extract(): e42. or *note
extractall(): e41. can be:

   * the string ‘'fully_trusted'’: Honor all metadata as specified in
     the archive.  Should be used if the user trusts the archive
     completely, or implements their own complex verification.

   * the string ‘'tar'’: Honor most 'tar'-specific features (i.e.
     features of UNIX-like filesystems), but block features that are
     very likely to be surprising or malicious.  See *note tar_filter():
     2994. for details.

   * the string ‘'data'’: Ignore or block most features specific to
     UNIX-like filesystems.  Intended for extracting cross-platform data
     archives.  See *note data_filter(): 1662. for details.

   * ‘None’ (default): Use *note TarFile.extraction_filter: 296f.

     If that is also ‘None’ (the default), raise a ‘DeprecationWarning’,
     and fall back to the ‘'fully_trusted'’ filter, whose dangerous
     behavior matches previous versions of Python.

     In Python 3.14, the ‘'data'’ filter will become the default
     instead.  It's possible to switch earlier; see *note
     TarFile.extraction_filter: 296f.

   * A callable which will be called for each extracted member with a
     *note TarInfo: 2951. describing the member and the destination path
     to where the archive is extracted (i.e.  the same path is used for
     all members):

          filter(member: TarInfo, path: str, /) -> TarInfo | None

     The callable is called just before each member is extracted, so it
     can take the current state of the disk into account.  It can:

        - return a *note TarInfo: 11e2. object which will be used
          instead of the metadata in the archive, or

        - return ‘None’, in which case the member will be skipped, or

        - raise an exception to abort the operation or skip the member,
          depending on *note errorlevel: 294b.  Note that when
          extraction is aborted, *note extractall(): e41. may leave the
          archive partially extracted.  It does not attempt to clean up.

* Menu:

* Default named filters::
* Filter errors::
* Hints for further verification::
* Supporting older Python versions::
* Stateful extraction filter example::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0706/


File: python.info,  Node: Default named filters,  Next: Filter errors,  Up: Extraction filters

5.13.6.4 Default named filters
..............................

The pre-defined, named filters are available as functions, so they can
be reused in custom filters:

 -- の関数: tarfile.fully_trusted_filter (member, path)

     Return 'member' unchanged.

     This implements the ‘'fully_trusted'’ filter.

 -- の関数: tarfile.tar_filter (member, path)

     Implements the ‘'tar'’ filter.

        - Strip leading slashes (‘/’ and *note os.sep: 636.) from
          filenames.

        - *note Refuse: 294f. to extract files with absolute paths (in
          case the name is absolute even after stripping slashes, e.g.
          ‘C:/foo’ on Windows).  This raises *note AbsolutePathError:
          2952.

        - *note Refuse: 294f. to extract files whose absolute path
          (after following symlinks) would end up outside the
          destination.  This raises *note OutsideDestinationError: 2953.

        - Clear high mode bits (setuid, setgid, sticky) and group/other
          write bits (*note S_IWGRP: 275c. | *note S_IWOTH: 275f.).

     Return the modified ‘TarInfo’ member.

 -- の関数: tarfile.data_filter (member, path)

     Implements the ‘'data'’ filter.  In addition to what ‘tar_filter’
     does:

        - *note Refuse: 294f. to extract links (hard or soft) that link
          to absolute paths, or ones that link outside the destination.

          This raises *note AbsoluteLinkError: 2955. or *note
          LinkOutsideDestinationError: 2956.

          Note that such files are refused even on platforms that do not
          support symbolic links.

        - *note Refuse: 294f. to extract device files (including pipes).
          This raises *note SpecialFileError: 2954.

        - For regular files, including hard links:

             - Set the owner read and write permissions (*note S_IRUSR:
               2757. | *note S_IWUSR: 2758.).

             - Remove the group & other executable permission (*note
               S_IXGRP: 2753. | *note S_IXOTH: 2760.) if the owner
               doesn’t have it (*note S_IXUSR: 2759.).

        - For other files (directories), set ‘mode’ to ‘None’, so that
          extraction methods skip applying permission bits.

        - Set user and group info (‘uid’, ‘gid’, ‘uname’, ‘gname’) to
          ‘None’, so that extraction methods skip setting it.

     Return the modified ‘TarInfo’ member.


File: python.info,  Node: Filter errors,  Next: Hints for further verification,  Prev: Default named filters,  Up: Extraction filters

5.13.6.5 Filter errors
......................

When a filter refuses to extract a file, it will raise an appropriate
exception, a subclass of *note FilterError: 294e.  This will abort the
extraction if *note TarFile.errorlevel: 294b. is 1 or more.  With
‘errorlevel=0’ the error will be logged and the member will be skipped,
but extraction will continue.


File: python.info,  Node: Hints for further verification,  Next: Supporting older Python versions,  Prev: Filter errors,  Up: Extraction filters

5.13.6.6 Hints for further verification
.......................................

Even with ‘filter='data'’, 'tarfile' is not suited for extracting
untrusted files without prior inspection.  Among other issues, the
pre-defined filters do not prevent denial-of-service attacks.  Users
should do additional checks.

Here is an incomplete list of things to consider:

   * Extract to a *note new temporary directory: 200. to prevent e.g.
     exploiting pre-existing links, and to make it easier to clean up
     after a failed extraction.

   * When working with untrusted data, use external (e.g.  OS-level)
     limits on disk, memory and CPU usage.

   * Check filenames against an allow-list of characters (to filter out
     control characters, confusables, foreign path separators, etc.).

   * Check that filenames have expected extensions (discouraging files
     that execute when you “click on them”, or extension-less files like
     Windows special device names).

   * Limit the number of extracted files, total size of extracted data,
     filename length (including symlink length), and size of individual
     files.

   * Check for files that would be shadowed on case-insensitive
     filesystems.

Also note that:

   * Tar files may contain multiple versions of the same file.  Later
     ones are expected to overwrite any earlier ones.  This feature is
     crucial to allow updating tape archives, but can be abused
     maliciously.

   * 'tarfile' does not protect against issues with “live” data, e.g.
     an attacker tinkering with the destination (or source) directory
     while extraction (or archiving) is in progress.


File: python.info,  Node: Supporting older Python versions,  Next: Stateful extraction filter example,  Prev: Hints for further verification,  Up: Extraction filters

5.13.6.7 Supporting older Python versions
.........................................

Extraction filters were added to Python 3.12, but may be backported to
older versions as security updates.  To check whether the feature is
available, use e.g.  ‘hasattr(tarfile, 'data_filter')’ rather than
checking the Python version.

The following examples show how to support Python versions with and
without the feature.  Note that setting ‘extraction_filter’ will affect
any subsequent operations.

   * Fully trusted archive:

          my_tarfile.extraction_filter = (lambda member, path: member)
          my_tarfile.extractall()

   * Use the ‘'data'’ filter if available, but revert to Python 3.11
     behavior (‘'fully_trusted'’) if this feature is not available:

          my_tarfile.extraction_filter = getattr(tarfile, 'data_filter',
                                                 (lambda member, path: member))
          my_tarfile.extractall()

   * Use the ‘'data'’ filter; 'fail' if it is not available:

          my_tarfile.extractall(filter=tarfile.data_filter)

     もしくは:

          my_tarfile.extraction_filter = tarfile.data_filter
          my_tarfile.extractall()

   * Use the ‘'data'’ filter; 'warn' if it is not available:

          if hasattr(tarfile, 'data_filter'):
              my_tarfile.extractall(filter='data')
          else:
              # remove this when no longer needed
              warn_the_user('Extracting may be unsafe; consider updating Python')
              my_tarfile.extractall()


File: python.info,  Node: Stateful extraction filter example,  Prev: Supporting older Python versions,  Up: Extraction filters

5.13.6.8 Stateful extraction filter example
...........................................

While 'tarfile"s extraction methods take a simple 'filter' callable,
custom filters may be more complex objects with an internal state.  It
may be useful to write these as context managers, to be used like this:

     with StatefulFilter() as filter_func:
         tar.extractall(path, filter=filter_func)

Such a filter can be written as, for example:

     class StatefulFilter:
         def __init__(self):
             self.file_count = 0

         def __enter__(self):
             return self

         def __call__(self, member, path):
             self.file_count += 1
             return member

         def __exit__(self, *exc_info):
             print(f'{self.file_count} files extracted')


File: python.info,  Node: コマンドラインインターフェイス<3>,  Next: 使用例<15>,  Prev: Extraction filters,  Up: tarfile --- tar アーカイブファイルの読み書き

5.13.6.9 コマンドラインインターフェイス
.......................................

Added in version 3.4.

*note tarfile: c8. モジュールは、 tar アーカイブを操作するための簡単なコ
マンドラインインターフェースを提供しています。

tar アーカイブを新規に作成したい場合、*note -c: 299b. オプションの後にま
とめたいファイル名のリストを指定してください:

     $ python -m tarfile -c monty.tar  spam.txt eggs.txt

ディレクトリを渡すこともできます:

     $ python -m tarfile -c monty.tar life-of-brian_1979/

tar アーカイブをカレントディレクトリに展開したい場合、*note -e: 299c. オ
プションを使用してください:

     $ python -m tarfile -e monty.tar

ディレクトリ名を渡すことで tar アーカイブを別のディレクトリに取り出すこ
ともできます:

     $ python -m tarfile -e monty.tar  other-dir/

tar アーカイブ内のファイル一覧を表示するには *note -l: 299d. を使用して
ください:

     $ python -m tarfile -l monty.tar

* Menu:

* コマンドラインオプション: コマンドラインオプション<3>.


File: python.info,  Node: コマンドラインオプション<3>,  Up: コマンドラインインターフェイス<3>

5.13.6.10 コマンドラインオプション
..................................

 -- Option: -l <tarfile>
 -- Option: --list <tarfile>

     tarfile 内のファイル一覧を表示します。

 -- Option: -c <tarfile> <source1> ... <sourceN>
 -- Option: --create <tarfile> <source1> ... <sourceN>

     ソースファイルから tarfile を作成します。

 -- Option: -e <tarfile> [<output_dir>]
 -- Option: --extract <tarfile> [<output_dir>]

     'output_dir' が指定されていない場合、カレントディレクトリに tarfile
     を展開します。

 -- Option: -t <tarfile>
 -- Option: --test <tarfile>

     tarfile が有効かどうか調べます。

 -- Option: -v, --verbose

     詳細も出力します。

 -- Option: --filter <filtername>

     Specifies the 'filter' for ‘--extract’.  See *note Extraction
     filters: 439. for details.  Only string names are accepted (that
     is, ‘fully_trusted’, ‘tar’, and ‘data’).


File: python.info,  Node: 使用例<15>,  Next: サポートしている tar フォーマット,  Prev: コマンドラインインターフェイス<3>,  Up: tarfile --- tar アーカイブファイルの読み書き

5.13.6.11 使用例
................

tar アーカイブから現在のディレクトリにすべて抽出する方法:

     import tarfile
     tar = tarfile.open("sample.tar.gz")
     tar.extractall(filter='data')
     tar.close()

tar アーカイブの一部を、リストの代わりにジェネレーター関数を利用して
*note TarFile.extractall(): e41. で展開する方法:

     import os
     import tarfile

     def py_files(members):
         for tarinfo in members:
             if os.path.splitext(tarinfo.name)[1] == ".py":
                 yield tarinfo

     tar = tarfile.open("sample.tar.gz")
     tar.extractall(members=py_files(tar))
     tar.close()

非圧縮 tar アーカイブをファイル名のリストから作成する方法:

     import tarfile
     tar = tarfile.open("sample.tar", "w")
     for name in ["foo", "bar", "quux"]:
         tar.add(name)
     tar.close()

*note with: 59c. 文を利用した同じ例:

     import tarfile
     with tarfile.open("sample.tar", "w") as tar:
         for name in ["foo", "bar", "quux"]:
             tar.add(name)

gzip 圧縮 tar アーカイブを作成してメンバー情報のいくつかを表示する方法:

     import tarfile
     tar = tarfile.open("sample.tar.gz", "r:gz")
     for tarinfo in tar:
         print(tarinfo.name, "is", tarinfo.size, "bytes in size and is ", end="")
         if tarinfo.isreg():
             print("a regular file.")
         elif tarinfo.isdir():
             print("a directory.")
         else:
             print("something else.")
     tar.close()

*note TarFile.add(): bc1. 関数の 'filter' 引数を利用してユーザー情報をリ
セットしながらアーカイブを作成する方法:

     import tarfile
     def reset(tarinfo):
         tarinfo.uid = tarinfo.gid = 0
         tarinfo.uname = tarinfo.gname = "root"
         return tarinfo
     tar = tarfile.open("sample.tar.gz", "w:gz")
     tar.add("foo", filter=reset)
     tar.close()


File: python.info,  Node: サポートしている tar フォーマット,  Next: Unicode に関する問題,  Prev: 使用例<15>,  Up: tarfile --- tar アーカイブファイルの読み書き

5.13.6.12 サポートしている tar フォーマット
...........................................

*note tarfile: c8. モジュールは 3 種類の tar フォーマットを作成すること
ができます:

   * POSIX.1-1988 ustar format (*note USTAR_FORMAT: 2966.).  ファイル名
     の長さは256文字までで、リンク名の長さは100文字までです。最大のファ
     イルサイズは8GiBです。このフォーマットは古くて制限が多いですが、広
     くサポートされています。

   * GNU tar format (*note GNU_FORMAT: 2967.).  長いファイル名とリンク名
     、8GiBを超えるファイルやスパース(sparse)ファイルをサポートしていま
     す。これは GNU/Linux システムにおいてデファクト・スタンダードになっ
     ています。 *note tarfile: c8. モジュールは長いファイル名を完全にサ
     ポートしています。 スパースファイルは読み込みのみサポートしています
     。

   * The POSIX.1-2001 pax format (*note PAX_FORMAT: 2968.).  It is the
     most flexible format with virtually no limits.  It supports long
     filenames and linknames, large files and stores pathnames in a
     portable way.  Modern tar implementations, including GNU tar,
     bsdtar/libarchive and star, fully support extended 'pax' features;
     some old or unmaintained libraries may not, but should treat 'pax'
     archives as if they were in the universally supported 'ustar'
     format.  It is the current default format for new archives.

     It extends the existing 'ustar' format with extra headers for
     information that cannot be stored otherwise.  There are two
     flavours of pax headers: Extended headers only affect the
     subsequent file header, global headers are valid for the complete
     archive and affect all following files.  All the data in a pax
     header is encoded in 'UTF-8' for portability reasons.

他にも、読み込みのみサポートしている tar フォーマットがいくつかあります:

   * ancient V7 フォーマット。これは Unix 7th Edition から存在する、最初
     の tar フォーマットです。通常のファイルとディレクトリのみ保存します
     。名前は 100 文字を超えてはならず、ユーザー/グループ名に関する情報
     は保存されません。いくつかのアーカイブは、フィールドが ASCII でない
     文字を含む場合に、ヘッダーのチェックサムの計算を誤ります。

   * SunOS tar 拡張フォーマット。POSIX.1-2001 pax フォーマットの亜流です
     が、互換性がありません。


File: python.info,  Node: Unicode に関する問題,  Prev: サポートしている tar フォーマット,  Up: tarfile --- tar アーカイブファイルの読み書き

5.13.6.13 Unicode に関する問題
..............................

tar フォーマットは、もともとテープドライブにファイルシステムのバックアッ
プをとる目的で設計されました。現在、tarアーカイブはファイルを配布する際
に一般的に用いられ、ネットワーク上で交換されています。オリジナルフォーマ
ットが抱える一つの問題は (他の多くのフォーマットでも同じですが)、様々な
文字エンコーディングのサポートについて考慮していないことです。例えば、
'UTF-8' システム上で作成された通常の tar アーカイブは、非 'ASCII' 文字を
含んでいた場合、'Latin-1' システムでは正しく読み取ることができません。テ
キストのメタデータ (ファイル名、リンク名、ユーザー/グループ名など) は破
壊されます。残念なことに、アーカイブのエンコーディングを自動検出する方法
はありません。pax フォーマットはこの問題を解決するために設計されました。
これは非 ASCII メタデータをユニバーサル文字エンコーディング 'UTF-8' を使
用して格納します。

*note tarfile: c8. における文字変換処理の詳細は *note TarFile: 11e1. ク
ラスのキーワード引数 'encoding' および 'errors' によって制御されます。

'encoding' はアーカイブのメタデータに使用する文字エンコーディングを指定
します。デフォルト値は *note sys.getfilesystemencoding(): c27. で、フォ
ールバックとして ‘'ascii'’ が使用されます。アーカイブの読み書き時に、メ
タデータはそれぞれデコードまたはエンコードしなければなりません。
'encoding' に適切な値が設定されていない場合、その変換は失敗することがあ
ります。

引数 'errors' は文字を変換できない時の扱いを指定します。指定できる値は
*note エラーハンドラ: 1751. 節を参照してください。デフォルトのスキームは
‘'surrogateescape'’ で、Python はそのファイルシステムの呼び出しも使用し
ます。*note ファイル名、コマンドライン引数、および環境変数: 29aa. を参照
してください。

デフォルトの *note PAX_FORMAT: 2968. アーカイブでは、メタデータはすべて
'UTF-8' で格納されるため、'encoding' は通常指定する必要はありません。
'encoding' は、まれにある、バイナリの pax ヘッダーがデコードされた場合、
あるいはサロゲート文字を含む文字列が格納されていた場合に使用されます。


File: python.info,  Node: ファイルフォーマット,  Next: 暗号関連のサービス,  Prev: データ圧縮とアーカイブ,  Up: Python 標準ライブラリ

5.14 ファイルフォーマット
=========================

この章で説明されるモジュールはマークアップやEメールでない様々なファイル
フォーマットを構文解析します。

* Menu:

* csv: csv --- CSV ファイルの読み書き. CSV ファイルの読み書き
* configparser: configparser --- 設定ファイルのパーサー. 設定ファイルのパーサー
* tomllib: tomllib --- TOML ファイルの解析. TOML ファイルの解析
* netrc: netrc --- netrc ファイルの処理. netrc ファイルの処理
* plistlib: plistlib --- Apple plist ファイルを生成・解析する. Apple .plist ファイルを生成・解析する


File: python.info,  Node: csv --- CSV ファイルの読み書き,  Next: configparser --- 設定ファイルのパーサー,  Up: ファイルフォーマット

5.14.1 ‘csv’ -- CSV ファイルの読み書き
--------------------------------------

'ソースコード:' Lib/csv.py(1)

__________________________________________________________________

CSV (Comma Separated Values、カンマ区切り値列) と呼ばれる形式は、 スプレ
ッドシートやデータベース間でのデータのインポートやエクスポートにおける最
も一般的な形式です。 CSVフォーマットは、 RFC 4180(2) によって標準的な方
法でフォーマットを記述する試みが行われる以前から長年使用されました。明確
に定義された標準がないということは、異なるアプリケーション によって生成
されたり取り込まれたりするデータ間では、しばしば微妙な違いが発生するとい
うことを意味します。こうした違いのために、複数のデータ源から得られた CSV
ファイルを処理する作業が鬱陶しいものになることがあります。とはいえ、デリ
ミタ (delimiter) やクオート文字の 相違はあっても、全体的な形式は十分似通
っているため、こうしたデータを効率的に操作し、データの読み書きにおける細
々としたことをプログラマ から隠蔽するような単一のモジュールを書くことは
可能です。

*note csv: 21. モジュールでは、CSV 形式で書かれたテーブル状のデータを読
み書きするためのクラスを実装しています。このモジュールを使うことで、プロ
グラマは Excel で使われている CSV 形式に関して詳しい知識をもっていなくて
も、 "このデータを Excel で推奨されている形式で書いてください" とか、 "デ
ータを Excel で作成されたこのファイルから読み出してください" と言うこと
ができます。プログラマはまた、他のアプリケーションが解釈できる CSV 形式
を記述したり、独自の特殊な目的をもった CSV 形式を定義することができます
。

*note csv: 21. モジュールの *note reader: 453. および *note writer: 454.
オブジェクトはシーケンス型を読み書きします。プログラマは *note
DictReader: 9b3. や *note DictWriter: 11cf. クラスを使うことで、データを
辞書形式で読み書きすることもできます。

参考
....

PEP 305(3) - CSV File API

     Python へのこのモジュールの追加を提案している Python 改良案 (PEP:
     Python Enhancement Proposal)。

* Menu:

* モジュールコンテンツ: モジュールコンテンツ<3>.
* Dialect クラスと書式化パラメータ::
* reader オブジェクト::
* writer オブジェクト::
* 使用例: 使用例<16>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/csv.py

   (2) https://datatracker.ietf.org/doc/html/rfc4180.html

   (3) https://peps.python.org/pep-0305/


File: python.info,  Node: モジュールコンテンツ<3>,  Next: Dialect クラスと書式化パラメータ,  Up: csv --- CSV ファイルの読み書き

5.14.1.1 モジュールコンテンツ
.............................

*note csv: 21. モジュールでは以下の関数を定義しています:

 -- の関数: csv.reader (csvfile, dialect='excel', **fmtparams)

     Return a *note reader object: 29b2. that will process lines from
     the given 'csvfile'.  A csvfile must be an iterable of strings,
     each in the reader's defined csv format.  A csvfile is most
     commonly a file-like object or list.  If 'csvfile' is a file
     object, it should be opened with ‘newline=''’.  (1)  An optional
     'dialect' parameter can be given which is used to define a set of
     parameters specific to a particular CSV dialect.  It may be an
     instance of a subclass of the *note Dialect: 15df. class or one of
     the strings returned by the *note list_dialects(): 1774. function.
     The other optional 'fmtparams' keyword arguments can be given to
     override individual formatting parameters in the current dialect.
     For full details about the dialect and formatting parameters, see
     section *note Dialect クラスと書式化パラメータ: 29b3.

     csv ファイルから読み込まれた各行は、文字列のリストとして返されます
     。‘QUOTE_NONNUMERIC’ フォーマットオプションが指定された場合を除き、
     データ型の変換が自動的に行われることはありません (このオプションが
     指定された場合、クォートされていないフィールドは浮動小数点数に変換
     されます)。

     短い利用例:

          >>> import csv
          >>> with open('eggs.csv', newline='') as csvfile:
          ...     spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')
          ...     for row in spamreader:
          ...         print(', '.join(row))
          Spam, Spam, Spam, Spam, Spam, Baked Beans
          Spam, Lovely Spam, Wonderful Spam

 -- の関数: csv.writer (csvfile, dialect='excel', **fmtparams)

     ユーザが与えたデータをデリミタで区切られた文字列に変換し、与えられ
     たファイルオブジェクトに書き込むための writer オブジェクトを返しま
     す。 'csvfile' は *note write(): 1bde. メソッドを持つ任意のオブジェ
     クトです。 'csvfile' がファイルオブジェクトの場合、 ‘newline=''’ と
     して開くべきです (2) 。オプションとして 'dialect' 引数を与えること
     ができ、利用するCSV表現形式(dialect)を指定することができます。
     'dialect' パラメータは *note Dialect: 15df. クラスのサブクラスのイ
     ンスタンスか、 *note list_dialects(): 1774. 関数が返す文字列の1つに
     することができます。別のオプション引数である 'fmtparams' キーワード
     引数は、現在の表現形式における個々の書式パラメータを上書きするため
     に与えることができます。dialect と書式パラメータについての詳細は、
     *note Dialect クラスと書式化パラメータ: 29b3. 節を参照してください
     。 DB API を実装するモジュールとのインターフェースを可能な限り容易
     にするために、 *note None: 641. は空文字列として書き込まれます。こ
     の処理は可逆な変換ではありませんが、SQL で NULL データ値を CSV にダ
     ンプする処理を、 ‘cursor.fetch*’ 呼び出しによって返されたデータを前
     処理することなく簡単に行うことができます。他の非文字列データは、書
     き出される前に *note str(): 418. を使って文字列に変換されます。

     短い利用例:

          import csv
          with open('eggs.csv', 'w', newline='') as csvfile:
              spamwriter = csv.writer(csvfile, delimiter=' ',
                                      quotechar='|', quoting=csv.QUOTE_MINIMAL)
              spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
              spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])

 -- の関数: csv.register_dialect (name[, dialect[, **fmtparams]])

     'dialect' を 'name' と関連付けます。 'name' は文字列でなければなり
     ません。表現形式(dialect)は *note Dialect: 15df. のサブクラスを渡す
     か、またはキーワード引数 'fmtparams' 、もしくは両方で指定できますが
     、キーワード引数の方が優先されます。表現形式と書式化パラメータにつ
     いての詳細は、 *note Dialect クラスと書式化パラメータ: 29b3. 節を参
     照してください。

 -- の関数: csv.unregister_dialect (name)

     'name' に関連づけられた表現形式を表現形式レジストリから削除します。
     'name' が表現形式名でない場合には *note Error: 29b5. を送出します。

 -- の関数: csv.get_dialect (name)

     'name' に関連づけられた表現形式を返します。 'name' が表現形式名でな
     い場合には *note Error: 29b5. を送出します。この関数は不変の *note
     Dialect: 15df. を返します。

 -- の関数: csv.list_dialects ()

     登録されている全ての表現形式を返します。

 -- の関数: csv.field_size_limit ([new_limit])

     パーサが許容する現在の最大フィールドサイズを返します。 'new_limit'
     が渡されたときは、その値が新しい上限になります。

*note csv: 21. モジュールでは以下のクラスを定義しています:

 -- クラス: csv.DictReader (f, fieldnames=None, restkey=None,
          restval=None, dialect='excel', *args, **kwds)

     通常の reader のように動作しますが、個々の行の情報を *note dict:
     237. にマップするオブジェクトを生成します。マップのキーは省略可能な
     'fieldnames' パラメータで与えられます。

     The 'fieldnames' parameter is a *note sequence: 4be.  If
     'fieldnames' is omitted, the values in the first row of file 'f'
     will be used as the fieldnames and will be omitted from the
     results.  If 'fieldnames' is provided, they will be used and the
     first row will be included in the results.  Regardless of how the
     fieldnames are determined, the dictionary preserves their original
     ordering.

     行がフィールド名より多くのフィールドを持っていた場合、残りのデータ
     はリストに入れられて、 'restkey' により指定されたフィールド名 (デフ
     ォルトでは ‘None’) で保存されます。空白でない行がフィールド名よりも
     少ないフィールドしか持たない場合、足りない値は 'restval' の値 (デフ
     ォルトは ‘None’ ) によって埋められます。

     その他の省略可能またはキーワード形式のパラメータは、ベースになって
     いる *note reader: 453. インスタンスに渡されます。

     'fieldnames' に渡された引数がイテレータの場合、 *note list: 5dc. に
     変換されます。

     バージョン 3.6 で変更: 返される行の型は ‘OrderedDict’ になりました
     。

     バージョン 3.8 で変更: 返される行の型は *note dict: 237. になりまし
     た。

     短い利用例:

          >>> import csv
          >>> with open('names.csv', newline='') as csvfile:
          ...     reader = csv.DictReader(csvfile)
          ...     for row in reader:
          ...         print(row['first_name'], row['last_name'])
          ...
          Eric Idle
          John Cleese

          >>> print(row)
          {'first_name': 'John', 'last_name': 'Cleese'}

 -- クラス: csv.DictWriter (f, fieldnames, restval='',
          extrasaction='raise', dialect='excel', *args, **kwds)

     通常の writer のように動作しますが、辞書を出力行にマップするオブジ
     ェクトを生成します。 'fieldnames' パラメータは、*note writerow():
     db7. メソッドに渡された辞書の値がどのような順番でファイル 'f' に書
     かれるかを指定するキーの *note sequence: 17. です。 *note
     writerow(): db7. メソッドに渡された辞書に 'fieldnames' には存在しな
     いキーが含まれている場合、オプションの 'extrasaction' パラメータに
     よってどんな動作を行うかが指定されます。この値がデフォルト値である
     ‘'raise'’ に設定されている場合、 *note ValueError: 1e3. が送出され
     ます。 ‘'ignore'’ に設定されている場合、辞書の余分な値は無視されま
     す。その他のパラメータはベースになっている *note writer: 454. イン
     スタンスに渡されます。

     *note DictReader: 9b3. クラスとは異なり、 *note DictWriter: 11cf. の
     'fieldnames' パラメータは省略可能ではありません。

     'fieldnames' に渡された引数がイテレータの場合、 *note list: 5dc. に
     変換されます。

     短い利用例:

          import csv

          with open('names.csv', 'w', newline='') as csvfile:
              fieldnames = ['first_name', 'last_name']
              writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

              writer.writeheader()
              writer.writerow({'first_name': 'Baked', 'last_name': 'Beans'})
              writer.writerow({'first_name': 'Lovely', 'last_name': 'Spam'})
              writer.writerow({'first_name': 'Wonderful', 'last_name': 'Spam'})

 -- クラス: csv.Dialect

     *note Dialect: 15df. クラスはコンテナクラスです。その属性に、ダブル
     クォート、空白文字、デリミタなどの扱い方に関する情報を含みます。CSV
     には厳密な規格がないため、アプリケーションによって生成される CSV デ
     ータはそれぞれ僅かに異なります。 *note Dialect: 15df. クラスのイン
     スタンスは *note reader: 453. と *note writer: 454. のインスタンス
     の挙動を定義します。

     All available *note Dialect: 15df. names are returned by *note
     list_dialects(): 1774, and they can be registered with specific
     *note reader: 453. and *note writer: 454. classes through their
     initializer (‘__init__’) functions like this:

          import csv

          with open('students.csv', 'w', newline='') as csvfile:
              writer = csv.writer(csvfile, dialect='unix')

 -- クラス: csv.excel

     *note excel: 29b6. クラスは Excel で生成される CSV ファイルの通常の
     プロパティを定義します。これは ‘'excel'’ という名前の dialect とし
     て登録されています。

 -- クラス: csv.excel_tab

     *note excel_tab: 29b7. クラスは Excel で生成されるタブ分割ファイル
     の通常のプロパティを定義します。これは ‘'excel-tab'’ という名前の
     dialect として登録されています。

 -- クラス: csv.unix_dialect

     *note unix_dialect: 11ce. クラスは UNIX システムで生成される CSV フ
     ァイルの通常のプロパティ (行終端記号として ‘'\n'’ を用い全てのフィ
     ールドをクォートするもの) を定義します。これは ‘'unix'’ という名前
     の dialect として登録されています。

     Added in version 3.2.

 -- クラス: csv.Sniffer

     *note Sniffer: 29b8. クラスは CSV ファイルの書式を推理するために用
     いられるクラスです。

     *note Sniffer: 29b8. クラスではメソッドを二つ提供しています:

      -- メソッド: sniff (sample, delimiters=None)

          与えられた 'sample' を解析し、発見されたパラメータを反映した
          *note Dialect: 15df. サブクラスを返します。オプションの
          'delimiters' パラメータを与えた場合、有効なデリミタ文字を含ん
          でいるはずの文字列として解釈されます。

      -- メソッド: has_header (sample)

          Analyze the sample text (presumed to be in CSV format) and
          return *note True: bdb. 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:

             - 2番目からn番目の行は数値を含みます。

             - the second through n-th rows contain strings where at
               least one value's length differs from that of the
               putative header of that column.

          1 行目の後の 20 行がサンプリングされます。半分以上の行 + 列が
          条件を満たす場合、 *note True: bdb. が返されます。

          注釈: このメソッドは大雑把なヒューリスティックであり、結果が偽
          陽性や偽陰性である可能性があります。

*note Sniffer: 29b8. の利用例:

     with open('example.csv', newline='') as csvfile:
         dialect = csv.Sniffer().sniff(csvfile.read(1024))
         csvfile.seek(0)
         reader = csv.reader(csvfile, dialect)
         # ... process CSV file contents here ...
*note csv: 21. モジュールでは以下の定数を定義しています:

 -- データ: csv.QUOTE_ALL

     *note writer: 454. オブジェクトに対し、全てのフィールドをクオートす
     るように指示します。

 -- データ: csv.QUOTE_MINIMAL

     *note writer: 454. オブジェクトに対し、 'delimiter' 、 'quotechar'
     または 'lineterminator' に含まれる任意の文字のような特別な文字を含
     むフィールドだけをクオートするように指示します。

 -- データ: csv.QUOTE_NONNUMERIC

     *note writer: 454. オブジェクトに対し、全ての非数値フィールドをクオ
     ートするように指示します。

     *note reader: 453. オブジェクトに、クォーテーションで囲まれていない
     すべてのフィールドを 'float' 型に変換するよう指示します。

 -- データ: csv.QUOTE_NONE

     *note writer: 454. オブジェクトに対し、フィールドを決してクオートし
     ないように指示します。現在の 'delimiter' が出力データ中に現れた場合
     、現在設定されている 'escapechar' 文字が前に付けられます。
     'escapechar' がセットされていない場合、エスケープが必要な文字に遭遇
     した writer は *note Error: 29b5. を送出します。

     *note reader: 453. オブジェクトに、クオート文字に対する特殊処理を行
     わないよう指示します。

 -- データ: csv.QUOTE_NOTNULL

     Instructs *note writer: 454. objects to quote all fields which are
     not ‘None’.  This is similar to *note QUOTE_ALL: 29bb, except that
     if a field value is ‘None’ an empty (unquoted) string is written.

     Instructs *note reader: 453. objects to interpret an empty
     (unquoted) field as ‘None’ and to otherwise behave as *note
     QUOTE_ALL: 29bb.

     Added in version 3.12.

 -- データ: csv.QUOTE_STRINGS

     Instructs *note writer: 454. objects to always place quotes around
     fields which are strings.  This is similar to *note
     QUOTE_NONNUMERIC: 154f, except that if a field value is ‘None’ an
     empty (unquoted) string is written.

     Instructs *note reader: 453. objects to interpret an empty
     (unquoted) string as ‘None’ and to otherwise behave as *note
     QUOTE_NONNUMERIC: 154f.

     Added in version 3.12.

*note csv: 21. モジュールでは以下の例外を定義しています:

 -- 例外: csv.Error

     全ての関数において、エラーが検出された際に送出される例外です。

   ---------- Footnotes ----------

   (1) ‘newline=''’ が指定されない場合、クォートされたフィールド内の改行
は適切に解釈されず、書き込み時に ‘\r\n’ を行末に用いる処理系では余分な
‘\r’ が追加されてしまいます。csv モジュールは独自 (*note universal:
d08.) の改行処理を行うため、‘newline=''’ を指定することは常に安全です。

   (2) ‘newline=''’ が指定されない場合、クォートされたフィールド内の改行
は適切に解釈されず、書き込み時に ‘\r\n’ を行末に用いる処理系では余分な
‘\r’ が追加されてしまいます。csv モジュールは独自 (*note universal:
d08.) の改行処理を行うため、‘newline=''’ を指定することは常に安全です。


File: python.info,  Node: Dialect クラスと書式化パラメータ,  Next: reader オブジェクト,  Prev: モジュールコンテンツ<3>,  Up: csv --- CSV ファイルの読み書き

5.14.1.2 Dialect クラスと書式化パラメータ
.........................................

To make it easier to specify the format of input and output records,
specific formatting parameters are grouped together into dialects.  A
dialect is a subclass of the *note Dialect: 15df. class containing
various attributes describing the format of the CSV file.  When creating
*note reader: 453. or *note writer: 454. objects, the programmer can
specify a string or a subclass of the *note Dialect: 15df. class as the
dialect parameter.  In addition to, or instead of, the 'dialect'
parameter, the programmer can also specify individual formatting
parameters, which have the same names as the attributes defined below
for the *note Dialect: 15df. class.

Dialect は以下の属性をサポートしています:

 -- の属性: Dialect.delimiter

     フィールド間を分割するのに用いられる 1 文字からなる文字列です。デフ
     ォルトでは ‘','’ です。

 -- の属性: Dialect.doublequote

     フィールド内に現れた 'quotechar' のインスタンスで、クオートではない
     その文字自身でなければならない文字をどのようにクオートするかを制御
     します。 *note True: bdb. の場合、この文字は二重化されます。 *note
     False: b05. の場合、 'escapechar' は 'quotechar' の前に置かれます。
     デフォルトでは *note True: bdb. です。

     出力においては、 'doublequote' が *note False: b05. で 'escapechar'
     がセットされていない場合、フィールド内に 'quotechar' が現れると
     *note Error: 29b5. が送出されます。

 -- の属性: Dialect.escapechar

     writer が、 'quoting' が *note QUOTE_NONE: 29bd. に設定されている場
     合に 'delimiter' をエスケープするため、および、 'doublequote' が
     *note False: b05. の場合に 'quotechar' をエスケープするために用いら
     れる、 1 文字からなる文字列です。読み込み時には 'escapechar' はそれ
     に引き続く文字の特別な意味を取り除きます。デフォルトでは *note
     None: 641. で、エスケープを行ないません。

     バージョン 3.11 で変更: 空の 'escapechar' は許可されていません。

 -- の属性: Dialect.lineterminator

     *note writer: 454. が作り出す各行を終端する際に用いられる文字列です
     。デフォルトでは ‘'\r\n'’ です。

          注釈: *note reader: 453. は ‘'\r'’ または ‘'\n'’ のどちらかを
          行末と認識するようにハードコードされており、 'lineterminator'
          を無視します。この振る舞いは将来変更されるかもしれません。

 -- の属性: Dialect.quotechar

     'delimiter' や 'quotechar' といった特殊文字を含むか、改行文字を含む
     フィールドをクオートする際に用いられる 1 文字からなる文字列です。デ
     フォルトでは ‘'"'’ です。

     バージョン 3.11 で変更: 空の 'quotechar' は許可されていません。

 -- の属性: Dialect.quoting

     クオートがいつ writer によって生成されるか、また reader によって認
     識されるかを制御します。*note QUOTE_* constants: 29ba. のいずれかを
     とることができ、デフォルトでは *note QUOTE_MINIMAL: 29bc. です。

 -- の属性: Dialect.skipinitialspace

     *note True: bdb. の場合、 'delimiter' の直後に続く空白は無視されま
     す。デフォルトでは *note False: b05. です。

 -- の属性: Dialect.strict

     ‘True’ の場合、 不正な CSV 入力に対して *note Error: 29b5. を送出し
     ます。デフォルトでは ‘False’ です。


File: python.info,  Node: reader オブジェクト,  Next: writer オブジェクト,  Prev: Dialect クラスと書式化パラメータ,  Up: csv --- CSV ファイルの読み書き

5.14.1.3 reader オブジェクト
............................

reader オブジェクト(*note DictReader: 9b3. インスタンス、および *note
reader(): 453. 関数によって返されたオブジェクト) は、以下の public なメ
ソッドを持っています:

 -- メソッド: csvreader.__next__ ()

     reader の反復可能なオブジェクトから、現在の表現形式 (*note Dialect:
     15df.) に基づいて次の行を解析してリスト（オブジェクトが *note
     reader(): 453. から返された場合）または辞書 （ *note DictReader:
     9b3. のインスタンスの場合）として返します。通常は ‘next(reader)’ の
     ようにして呼び出すことになります。

reader オブジェクトには以下の公開属性があります:

 -- の属性: csvreader.dialect

     パーサで使われる表現形式の読み出し専用の記述です。

 -- の属性: csvreader.line_num

     ソースイテレータから読んだ行数です。この数は返されるレコードの数と
     は、レコードが複数行に亘ることがあるので、一致しません。

DictReader オブジェクトは、以下の public な属性を持っています:

 -- の属性: DictReader.fieldnames

     オブジェクトを生成するときに渡されなかった場合、この属性は最初のア
     クセス時か、ファイルから最初のレコードを読み出したときに初期化され
     ます。


File: python.info,  Node: writer オブジェクト,  Next: 使用例<16>,  Prev: reader オブジェクト,  Up: csv --- CSV ファイルの読み書き

5.14.1.4 writer オブジェクト
............................

*note writer: 454. オブジェクト(*note DictWriter: 11cf. インスタンス、お
よび *note writer(): 454. 関数によって返されたオブジェクト) は、以下の
public なメソッドを持っています: 'row' には、 *note writer: 454. オブジ
ェクトの場合には文字列か数値のイテラブルを指定し、 *note DictWriter:
11cf. オブジェクトの場合はフィールド名をキーとして対応する文字列か数値を
格納した辞書オブジェクトを指定します(数値は *note str(): 418. で変換され
ます)。複素数を出力する場合、値をかっこで囲んで出力します。このため、CSV
ファイルを読み込むアプリケーションで（そのアプリケーションが複素数をサポ
ートしていたとしても）問題が発生する場合があります。

 -- メソッド: csvwriter.writerow (row)

     現在の表現形式 (*note Dialect: 15df.)に沿ってフォーマットされた
     'row' パラメータを writer のファイルオブジェクトに書き込みます。フ
     ァイルオブジェクトの 'write' メソッドを呼び出した際の戻り値を返しま
     す。

     バージョン 3.5 で変更: 任意のイテラブルのサポートの追加。

 -- メソッド: csvwriter.writerows (rows)

     'rows' 引数 (上で解説した 'row' オブジェクトのイテラブル) の全ての
     要素を現在の表現形式に基づいて書式化し、writer のファイルオブジェク
     トに書き込みます。

writer オブジェクトには以下の公開属性があります:

 -- の属性: csvwriter.dialect

     writer で使われる表現形式の読み出し専用の記述です。

DictWriter のオブジェクトは以下の public メソッドを持っています:

 -- メソッド: DictWriter.writeheader ()

     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 *note
     csvwriter.writerow(): db7. call used internally.

     Added in version 3.2.

     バージョン 3.8 で変更: *note writeheader(): 11d0. は内部的に利用し
     ている *note csvwriter.writerow(): db7. メソッドの返り値を返すよう
     になりました。


File: python.info,  Node: 使用例<16>,  Prev: writer オブジェクト,  Up: csv --- CSV ファイルの読み書き

5.14.1.5 使用例
...............

最も簡単な CSV ファイル読み込みの例です:

     import csv
     with open('some.csv', newline='') as f:
         reader = csv.reader(f)
         for row in reader:
             print(row)

別の書式での読み込み:

     import csv
     with open('passwd', newline='') as f:
         reader = csv.reader(f, delimiter=':', quoting=csv.QUOTE_NONE)
         for row in reader:
             print(row)

上に対して、単純な書き込みのプログラム例は以下のようになります。

     import csv
     with open('some.csv', 'w', newline='') as f:
         writer = csv.writer(f)
         writer.writerows(someiterable)

*note open(): 4e5. が CSV ファイルの読み込みに使われるため、ファイルはデ
フォルトではシステムのデフォルトエンコーディングでユニコード文字列にデコ
ードされます (*note locale.getencoding(): 2be. を参照)。他のエンコーディ
ングを用いてデコードするには、open の引数 ‘encoding’ を設定して、以下の
ようにします:

     import csv
     with open('some.csv', newline='', encoding='utf-8') as f:
         reader = csv.reader(f)
         for row in reader:
             print(row)

システムのデフォルトエンコーディング以外で書き込む場合も同様です。出力フ
ァイルを開く際に引数 ‘encoding’ を明示してください。

新しい表現形式の登録:

     import csv
     csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)
     with open('passwd', newline='') as f:
         reader = csv.reader(f, 'unixpwd')

もう少し手の込んだ reader の使い方 -- エラーを捉えてレポートします。

     import csv, sys
     filename = 'some.csv'
     with open(filename, newline='') as f:
         reader = csv.reader(f)
         try:
             for row in reader:
                 print(row)
         except csv.Error as e:
             sys.exit('file {}, line {}: {}'.format(filename, reader.line_num, e))

このモジュールは文字列の解析は直接サポートしませんが、簡単にできます。

     import csv
     for row in csv.reader(['one,two,three']):
         print(row)

脚注
....


File: python.info,  Node: configparser --- 設定ファイルのパーサー,  Next: tomllib --- TOML ファイルの解析,  Prev: csv --- CSV ファイルの読み書き,  Up: ファイルフォーマット

5.14.2 ‘configparser’ -- 設定ファイルのパーサー
-----------------------------------------------

'ソースコード:' Lib/configparser.py(1)

__________________________________________________________________

このモジュールは、 Microsoft Windows の INI ファイルに似た構造を持ったベ
ーシックな設定用言語を実装した *note ConfigParser: 1aa. クラスを提供しま
す。このクラスを使ってユーザーが簡単にカスタマイズできる Python プログラ
ムを作ることができます。

     注釈: このライブラリでは、Windowsのレジストリ用に拡張された INI 文
     法はサポート 'していません' 。

参考
....

モジュール *note tomllib: e5.

     TOML is a well-specified format for application configuration
     files.  It is specifically designed to be an improved version of
     INI.

*note shlex: b2. モジュール

     アプリケーション設定ファイルにも使える、Unix シェルに似たミニ言語の
     作成を支援します。

*note json: 76. モジュール

     The ‘json’ module implements a subset of JavaScript syntax which is
     sometimes used for configuration, but does not support comments.

* Menu:

* クイックスタート::
* サポートされるデータ型::
* 代替値::
* サポートするINI ファイルの構造::
* Unnamed Sections::
* 値の補間::
* マップ型プロトコルアクセス::
* パーサーの振る舞いをカスタマイズする::
* レガシーな API の例::
* ConfigParser オブジェクト::
* RawConfigParser オブジェクト::
* 例外: 例外<8>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/configparser.py


File: python.info,  Node: クイックスタート,  Next: サポートされるデータ型,  Up: configparser --- 設定ファイルのパーサー

5.14.2.1 クイックスタート
.........................

次のような、非常に簡単な設定ファイルを例に考えましょう:

     [DEFAULT]
     ServerAliveInterval = 45
     Compression = yes
     CompressionLevel = 9
     ForwardX11 = yes

     [forge.example]
     User = hg

     [topsecret.server.example]
     Port = 50022
     ForwardX11 = no

INI ファイルの構造は *note 下のセクション: 29d4. で解説します。 基本的に
、ファイルは複数のセクションからなり、各セクションは複数のキーと値を持ち
ます。 *note configparser: 1b. のクラス群はそれらのファイルを読み書きで
きます。 まずは上のような設定ファイルをプログラムから作成してみましょう
。

     >>> import configparser
     >>> config = configparser.ConfigParser()
     >>> config['DEFAULT'] = {'ServerAliveInterval': '45',
     ...                      'Compression': 'yes',
     ...                      'CompressionLevel': '9'}
     >>> config['forge.example'] = {}
     >>> config['forge.example']['User'] = 'hg'
     >>> config['topsecret.server.example'] = {}
     >>> topsecret = config['topsecret.server.example']
     >>> topsecret['Port'] = '50022'     # mutates the parser
     >>> topsecret['ForwardX11'] = 'no'  # same here
     >>> config['DEFAULT']['ForwardX11'] = 'yes'
     >>> with open('example.ini', 'w') as configfile:
     ...   config.write(configfile)
     ...

この例でわかるように、config parser は辞書のように扱うことができます。辞
書との違いは *note 後に: 29d5. 説明しますが、このインターフェイスは辞書
に対して期待するのととても近い動作をします。

これで設定ファイルを作成して保存できました。次はこれを読み込み直して、中
のデータを取り出してみましょう。

     >>> config = configparser.ConfigParser()
     >>> config.sections()
     []
     >>> config.read('example.ini')
     ['example.ini']
     >>> config.sections()
     ['forge.example', 'topsecret.server.example']
     >>> 'forge.example' in config
     True
     >>> 'python.org' in config
     False
     >>> config['forge.example']['User']
     'hg'
     >>> config['DEFAULT']['Compression']
     'yes'
     >>> topsecret = config['topsecret.server.example']
     >>> topsecret['ForwardX11']
     'no'
     >>> topsecret['Port']
     '50022'
     >>> for key in config['forge.example']:
     ...     print(key)
     user
     compressionlevel
     serveraliveinterval
     compression
     forwardx11
     >>> config['forge.example']['ForwardX11']
     'yes'

上の例からわかるように、API はとても直感的です。唯一の魔術は、‘DEFAULT’
セクションが他の全てのセクションのためのデフォルト値を提供していることで
す (1)。 また、セクション内の各キーは大文字小文字を区別せず、全て小文字
で保存されていることにも注意してください (2)。

It is possible to read several configurations into a single *note
ConfigParser: 1aa, where the most recently added configuration has the
highest priority.  Any conflicting keys are taken from the more recent
configuration while the previously existing keys are retained.  The
example below reads in an ‘override.ini’ file, which will override any
conflicting keys from the ‘example.ini’ file.

     [DEFAULT]
     ServerAliveInterval = -1

     >>> config_override = configparser.ConfigParser()
     >>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}
     >>> with open('override.ini', 'w') as configfile:
     ...     config_override.write(configfile)
     ...
     >>> config_override = configparser.ConfigParser()
     >>> config_override.read(['example.ini', 'override.ini'])
     ['example.ini', 'override.ini']
     >>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))
     -1

This behaviour is equivalent to a *note ConfigParser.read(): 140d. call
with several files passed to the 'filenames' parameter.

   ---------- Footnotes ----------

   (1) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。

   (2) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。


File: python.info,  Node: サポートされるデータ型,  Next: 代替値,  Prev: クイックスタート,  Up: configparser --- 設定ファイルのパーサー

5.14.2.2 サポートされるデータ型
...............................

Config parser は値のデータ型について何も推論せず、常に文字列のまま内部に
保存します。他のデータ型が必要な場合は自分で変換する必要があります:

     >>> int(topsecret['Port'])
     50022
     >>> float(topsecret['CompressionLevel'])
     9.0

このタスクはとても一般的なため、設定パーサーでは整数、浮動小数点数、真偽
値を扱うための手頃なゲッターメソッドが提供されています。真偽値の扱いは一
筋縄ではいきません。文字列を ‘bool()’ に渡しても、 ‘bool('False')’ が
‘True’ になってしまいます。そこで config parser は *note getboolean():
29d8. を提供しています。このメソッドは大文字小文字を区別せず、
‘'yes'’/‘'no'’、‘'on'’/‘'off'’、‘'true'’/‘'false'’、‘'1'’/‘'0'’ を真偽値
として認識します (1)。例えば:

     >>> topsecret.getboolean('ForwardX11')
     False
     >>> config['forge.example'].getboolean('ForwardX11')
     True
     >>> config.getboolean('forge.example', 'Compression')
     True

config parser では、 *note getboolean(): 29d8. 以外に *note getint():
29d9. と *note getfloat(): 29da. メソッドも提供されています。独自のコン
バーターの登録、提供されたメソッドのカスタマイズもできます。 (2)

   ---------- Footnotes ----------

   (1) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。

   (2) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。


File: python.info,  Node: 代替値,  Next: サポートするINI ファイルの構造,  Prev: サポートされるデータ型,  Up: configparser --- 設定ファイルのパーサー

5.14.2.3 代替値
...............

As with a dictionary, you can use a section's *note get(): 123d. method
to provide fallback values:

     >>> topsecret.get('Port')
     '50022'
     >>> topsecret.get('CompressionLevel')
     '9'
     >>> topsecret.get('Cipher')
     >>> topsecret.get('Cipher', '3des-cbc')
     '3des-cbc'

デフォルト値は代替値よりも優先されることに注意してください。例えば上の例
では、‘'CompressionLevel'’ キーは ‘'DEFAULT'’ セクションにしか存在しませ
ん。その値を ‘'topsecret.server.example'’ から取得しようとした場合、代替
値を指定しても常にデフォルト値を返します:

     >>> topsecret.get('CompressionLevel', '3')
     '9'

One more thing to be aware of is that the parser-level *note get():
123d. 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:

     >>> config.get('forge.example', 'monster',
     ...            fallback='No such things as monsters')
     'No such things as monsters'

同様の ‘fallback’ 引数を、*note getint(): 29d9. 、 *note getfloat():
29da. と *note getboolean(): 29d8. メソッドでも使えます。例えば:

     >>> 'BatchMode' in topsecret
     False
     >>> topsecret.getboolean('BatchMode', fallback=True)
     True
     >>> config['DEFAULT']['BatchMode'] = 'no'
     >>> topsecret.getboolean('BatchMode', fallback=True)
     False


File: python.info,  Node: サポートするINI ファイルの構造,  Next: Unnamed Sections,  Prev: 代替値,  Up: configparser --- 設定ファイルのパーサー

5.14.2.4 サポートするINI ファイルの構造
.......................................

A configuration file consists of sections, each led by a ‘[section]’
header, followed by key/value entries separated by a specific string
(‘=’ or ‘:’ by default (1)).  By default, section names are case
sensitive but keys are not (2).  Leading and trailing whitespace is
removed from keys and values.  Values can be omitted if the parser is
configured to allow it (3), in which case the key/value delimiter may
also be left out.  Values can also span multiple lines, as long as they
are indented deeper than the first line of the value.  Depending on the
parser's mode, blank lines may be treated as parts of multiline values
or ignored.

By default, a valid section name can be any string that does not contain
'\n'.  To change this, see *note ConfigParser.SECTCRE: 29dc.

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 *note UNNAMED_SECTION:
29dd. as in ‘config[UNNAMED_SECTION]’.

設定ファイルには先頭に特定の文字 (デフォルトでは ‘#’ および ‘;’ (4)) を
つけてコメントをつけることができます。コメントは、他の内容がない行に置く
ことができ、インデントされていても構いません。(5)

例えば:

     [Simple Values]
     key=value
     spaces in keys=allowed
     spaces in values=allowed as well
     spaces around the delimiter = obviously
     you can also use : to delimit keys from values

     [All Values Are Strings]
     values like this: 1000000
     or this: 3.14159265359
     are they treated as numbers? : no
     integers, floats and booleans are held as: strings
     can use the API to get converted values directly: true

     [Multiline Values]
     chorus: I'm a lumberjack, and I'm okay
         I sleep all night and I work all day

     [No Values]
     key_without_value
     empty string value here =

     [You can use comments]
     # like this
     ; or this

     # By default only in an empty line.
     # Inline comments can be harmful because they prevent users
     # from using the delimiting characters as parts of values.
     # That being said, this can be customized.

         [Sections Can Be Indented]
             can_values_be_as_well = True
             does_that_mean_anything_special = False
             purpose = formatting for readability
             multiline_values = are
                 handled just fine as
                 long as they are indented
                 deeper than the first line
                 of a value
             # Did I mention we can indent comments, too?

   ---------- Footnotes ----------

   (1) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。

   (2) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。

   (3) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。

   (4) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。

   (5) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。


File: python.info,  Node: Unnamed Sections,  Next: 値の補間,  Prev: サポートするINI ファイルの構造,  Up: configparser --- 設定ファイルのパーサー

5.14.2.5 Unnamed Sections
.........................

The name of the first section (or unique) may be omitted and values
retrieved by the *note UNNAMED_SECTION: 29dd. attribute.

     >>> config = """
     ... option = value
     ...
     ... [  Section 2  ]
     ... another = val
     ... """
     >>> unnamed = configparser.ConfigParser(allow_unnamed_section=True)
     >>> unnamed.read_string(config)
     >>> unnamed.get(configparser.UNNAMED_SECTION, 'option')
     'value'


File: python.info,  Node: 値の補間,  Next: マップ型プロトコルアクセス,  Prev: Unnamed Sections,  Up: configparser --- 設定ファイルのパーサー

5.14.2.6 値の補間
.................

コア機能に加えて、 *note ConfigParser: 1aa. は補間(interpolation, 内挿と
も)をサポートします。これは ‘get()’ コールが値を返す前に、その値に対して
前処理を行えることを意味します。

 -- クラス: configparser.BasicInterpolation

     *note ConfigParser: 1aa. が使用するデフォルト実装です。値に、同じセ
     クションか特別なデフォルトセクション中 (1) の他の値を参照するフォー
     マット文字列を含めることができます。追加のデフォルト値を初期化時に
     提供できます。

     例えば:

          [Paths]
          home_dir: /Users
          my_dir: %(home_dir)s/lumberjack
          my_pictures: %(my_dir)s/Pictures

          [Escape]
          # use a %% to escape the % sign (% is the only character that needs to be escaped):
          gain: 80%%

     上の例では、 'interpolation' に ‘BasicInterpolation()’ を設定した
     *note ConfigParser: 1aa. が ‘%(home_dir)s’ を ‘home_dir’ の値(この
     ケースでは ‘/Users’ )として解決しています、その結果 ‘%(my_dir)s’ は
     ‘/Users/lumberjack’ になります。全ての補間は必要に応じて実行される
     ため、設定ファイル中で参照の連鎖をもつキーを特定の順序で記述する必
     要はありません。

     ‘interpolation’ に ‘None’ を設定すれば、パーサーは単に
     ‘my_pictures’ の値として ‘%(my_dir)s/Pictures’ を返し、‘my_dir’ の
     値として ‘%(home_dir)s/lumberjack’ を返します。

 -- クラス: configparser.ExtendedInterpolation

     ‘zc.buildout’ で使用されるような、より高度な文法を実装した補間ハン
     ドラの別の選択肢です。拡張された補間は、他のセクション中の値を示す
     のに ‘${section:option}’ と書けます。補間は複数のレベルに及べます、
     利便性のために、もし ‘section:’ の部分が省略されると、現在のセクシ
     ョンがデフォルト値となります(スペシャルセクション中のデフォルト値を
     使用することもできます)。

     たとえば、上記の basic interpolation で指定した設定は、extended
     interpolation を使うと下記のようになります:

          [Paths]
          home_dir: /Users
          my_dir: ${home_dir}/lumberjack
          my_pictures: ${my_dir}/Pictures

          [Escape]
          # use a $$ to escape the $ sign ($ is the only character that needs to be escaped):
          cost: $$80

     他のセクションから値を持ってくることもできます:

          [Common]
          home_dir: /Users
          library_dir: /Library
          system_dir: /System
          macports_dir: /opt/local

          [Frameworks]
          Python: 3.2
          path: ${Common:system_dir}/Library/Frameworks/

          [Arthur]
          nickname: Two Sheds
          last_name: Jackson
          my_dir: ${Common:home_dir}/twosheds
          my_pictures: ${my_dir}/Pictures
          python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}

   ---------- Footnotes ----------

   (1) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。


File: python.info,  Node: マップ型プロトコルアクセス,  Next: パーサーの振る舞いをカスタマイズする,  Prev: 値の補間,  Up: configparser --- 設定ファイルのパーサー

5.14.2.7 マップ型プロトコルアクセス
...................................

Added in version 3.2.

マップ型プロトコルアクセスは、カスタムオブジェクトを辞書であるかのように
使うための機能の総称です。 *note configparser: 1b. の場合、マップ型イン
ターフェースの実装は ‘parser['section']['option']’ 表記を使います。

とくに、‘parser['section']’ はパーサー内のそのセクションのデータへのプロ
キシを返します。つまり、値はコピーされるのではなく必要に応じてオリジナル
のパーサーから取られます。さらに重要なことに、セクションのプロキシの値が
変更されると、オリジナルのパーサー中の値が実際に変更されます。

*note configparser: 1b. は可能な限り実際の辞書と近い振る舞いをします。マ
ップ型インターフェースは *note MutableMapping: 107e. を矛盾なく完成しま
す。しかし、考慮するべき違いがいくつかあります:

   * デフォルトでは、セクション内の全てのキーは大文字小文字の区別なくア
     クセスできます (1)。例えば、‘for option in parser["section"]’ は
     ‘optionxform’ されたオプションキー名のみを yield します。つまり小文
     字のキーがデフォルトです。同時に、キー ‘'a'’ を含むセクションにおい
     て、どちらの式も ‘True’ を返します:

          "a" in parser["section"]
          "A" in parser["section"]

   * 全てのセクションは ‘DEFAULTSECT’ 値を持ち、すなわちセクションで
     ‘.clear()’ してもセクションは見た目上空になりません。これは、デフォ
     ルト値は (技術的にはそこにないので) セクションから削除できないため
     です。デフォルト値が上書きされた場合、それが削除されるとデフォルト
     値が再び見えるようになります。デフォルト値を削除しようとすると
     *note KeyError: 31d. が発生します。

   * ‘DEFAULTSECT’ はパーサーから取り除けません:

        * 削除しようとすると *note ValueError: 1e3. が発生します。

        * ‘parser.clear()’ はこれをそのまま残し、

        * ‘parser.popitem()’ がこれを返すことはありません。

   * ‘parser.get(section, option, **kwargs)’ - 第二引数は代替値では 'あ
     りません'。ただし、セクションごとの ‘get()’ メソッドはマップ型プロ
     トコルと旧式の configparser API の両方に互換です。

   * ‘parser.items()’ はマップ型プロトコルと互換です (DEFAULTSECT を含む
     'section_name', 'section_proxy' 対のリストを返します)。ただし、この
     メソッドは ‘parser.items(section, raw, vars)’ のようにして引数を与
     えることでも呼び出せます。後者の呼び出しは指定された ‘section’ の
     'option', 'value' 対のリストを、(‘raw=True’ が与えられない限り) 全
     ての補間を展開して返します。

マップ型プロトコルは、既存のレガシーな API の上に実装されているので、オ
リジナルのインターフェースを上書きする派生クラスもまたは期待どおりにはた
らきます。

   ---------- Footnotes ----------

   (1) 設定パーサーは大々的にカスタマイズできます。脚注の参照で概説され
た挙動の変更に関心がある場合、*note Customizing Parser Behaviour: 29d6.
セクションを参照してください。


File: python.info,  Node: パーサーの振る舞いをカスタマイズする,  Next: レガシーな API の例,  Prev: マップ型プロトコルアクセス,  Up: configparser --- 設定ファイルのパーサー

5.14.2.8 パーサーの振る舞いをカスタマイズする
.............................................

INI フォーマットの変種は、それを使うアプリケーションの数と同じくらい多く
存在します。 *note configparser: 1b. は、可能な限り広い範囲の INI スタイ
ルを集めた集合をサポートするために、非常に役立ちます。デフォルトの機能は
主に歴史的背景によって決められたので、機能によってはカスタマイズしてお使
いください。

The most common way to change the way a specific config parser works is
to use the ‘__init__()’ options:

   * 'defaults', デフォルト値: ‘None’

     このオプションは最初に ‘DEFAULT’ セクションに加えられるキー-値の対
     の辞書を受け付けます。

     Hint: if you want to specify default values for a specific section,
     use *note read_dict(): 29e1. before you read the actual file.

   * 'dict_type', デフォルト値: *note dict: 237.

     このオプションはマップ型プロトコルの振る舞い方や書き込まれる設定フ
     ァイルの見た目に大きく影響します。標準の辞書では、全てのセクション
     はパーサーに加えられた順に並びます。同じことがセクション内のオプシ
     ョンにも言えます。

     セクションとオプションをライトバック時にソートするためなどに、別の
     辞書型も使えます。

     注意: 一度の操作でキー-値の対を複数追加する方法もあります。そのよう
     な操作に普通の辞書を使うと、キーの並びは挿入順になります。例えば:

          >>> parser = configparser.ConfigParser()
          >>> parser.read_dict({'section1': {'key1': 'value1',
          ...                                'key2': 'value2',
          ...                                'key3': 'value3'},
          ...                   'section2': {'keyA': 'valueA',
          ...                                'keyB': 'valueB',
          ...                                'keyC': 'valueC'},
          ...                   'section3': {'foo': 'x',
          ...                                'bar': 'y',
          ...                                'baz': 'z'}
          ... })
          >>> parser.sections()
          ['section1', 'section2', 'section3']
          >>> [option for option in parser['section3']]
          ['foo', 'bar', 'baz']

   * 'allow_no_value', デフォルト値: ‘False’

     一部の設定ファイルには値のない設定項目がありますが、それ以外は
     ‘ConfigParser’ がサポートする文法に従います。コンストラクタの
     'allow_no_value' 引数で、そのような値を許可することができます。

          >>> import configparser

          >>> sample_config = """
          ... [mysqld]
          ...   user = mysql
          ...   pid-file = /var/run/mysqld/mysqld.pid
          ...   skip-external-locking
          ...   old_passwords = 1
          ...   skip-bdb
          ...   # we don't need ACID today
          ...   skip-innodb
          ... """
          >>> config = configparser.ConfigParser(allow_no_value=True)
          >>> config.read_string(sample_config)

          >>> # Settings with values are treated as before:
          >>> config["mysqld"]["user"]
          'mysql'

          >>> # Settings without values provide None:
          >>> config["mysqld"]["skip-bdb"]

          >>> # Settings which aren't specified still raise an error:
          >>> config["mysqld"]["does-not-exist"]
          Traceback (most recent call last):
            ...
          KeyError: 'does-not-exist'

   * 'delimiters', デフォルト値: ‘('=', ':')’

     デリミタはセクション内でキーを値から区切る部分文字列です。行中で最
     初に現れた区切り部分文字列がデリミタと見なされます。つまり値にはデ
     リミタを含めることができます (キーには含めることができません)。

     *note ConfigParser.write(): 29e2. の 'space_around_delimiters' 引数
     も参照してください。

   * 'comment_prefixes', デフォルト値: ‘('#', ';')’

   * 'inline_comment_prefixes', デフォルト値: ‘None’

     コメント接頭辞は設定ファイル中で有効なコメントの開始を示す文字列で
     す。'comment_prefixes' は他の内容がない行 (インデントは自由) にのみ
     使用でき、'inline_comment_prefixes' は任意の有効な値 (例えば、セク
     ション名、オプション、空行も可能) の後に使えます。デフォルトではイ
     ンラインコメントは無効化されていて、‘'#'’ と ‘';'’ を行全体のコメン
     トに使用します。

     バージョン 3.2 で変更: 以前のバージョンの *note configparser: 1b. の
     振る舞いは ‘comment_prefixes=('#',';')’ および
     ‘inline_comment_prefixes=(';',)’ に該当します。

     設定パーサーはコメント接頭辞のエスケープをサポートしないので、
     'inline_comment_prefixes' はユーザーがコメント接頭辞として使われる
     文字を含むオプション値を指定するのを妨げる可能性があります。疑わし
     い場合には、'inline_comment_prefixes' を設定しないようにしてくださ
     い。どのような状況でも、複数行にわたる値で、行の先頭にコメント接頭
     辞文字を保存する唯一の方法は、次の例のように接頭辞を補間することで
     す:

          >>> from configparser import ConfigParser, ExtendedInterpolation
          >>> parser = ConfigParser(interpolation=ExtendedInterpolation())
          >>> # the default BasicInterpolation could be used as well
          >>> parser.read_string("""
          ... [DEFAULT]
          ... hash = #
          ...
          ... [hashes]
          ... shebang =
          ...   ${hash}!/usr/bin/env python
          ...   ${hash} -*- coding: utf-8 -*-
          ...
          ... extensions =
          ...   enabled_extension
          ...   another_extension
          ...   #disabled_by_comment
          ...   yet_another_extension
          ...
          ... interpolation not necessary = if # is not at line start
          ... even in multiline values = line #1
          ...   line #2
          ...   line #3
          ... """)
          >>> print(parser['hashes']['shebang'])

          #!/usr/bin/env python
          # -*- coding: utf-8 -*-
          >>> print(parser['hashes']['extensions'])

          enabled_extension
          another_extension
          yet_another_extension
          >>> print(parser['hashes']['interpolation not necessary'])
          if # is not at line start
          >>> print(parser['hashes']['even in multiline values'])
          line #1
          line #2
          line #3

   * 'strict', デフォルト値: ‘True’

     When set to ‘True’, the parser will not allow for any section or
     option duplicates while reading from a single source (using *note
     read_file(): 4d1, *note read_string(): 29e3. or *note read_dict():
     29e1.).  It is recommended to use strict parsers in new
     applications.

     バージョン 3.2 で変更: 以前のバージョンの *note configparser: 1b. の
     振る舞いは ‘strict=False’ に該当します。

   * 'empty_lines_in_values', デフォルト値: ‘True’

     設定パーサーでは、キーよりもその値を深くインデントするかぎり、複数
     行にまたがる値を使えます。デフォルトのパーサーはさらにその値の間に
     空行を置けます。同時に、キーは読みやすくするため任意にインデントで
     きます。結果として、設定ファイルが大きく複雑になったとき、ユーザー
     がファイル構造を見失いやすいです。この例をご覧ください:

          [Section]
          key = multiline
            value with a gotcha

           this = is still a part of the multiline value of 'key'

     これは特にプロポーショナルフォントを使ってファイルを編集しているユ
     ーザーにとって問題になることがあります。だから、アプリケーションの
     値に空行が必要ないなら、空行を認めないべきです。これによって空行で
     必ずキーが分かれます。上の例では、2 つのキー、‘key’ および ‘this’ が
     作られます。

   * 'default_section', デフォルト値: ‘configparser.DEFAULTSECT’ (すなわ
     ち: ‘"DEFAULT"’)

     他のセクションのデフォルト値や補間目的での特別なセクションを認める
     慣行はこのライブラリの明確なコンセプトの一つで、ユーザーは複雑で宣
     言的な設定を作成できます。このセクションは通常 ‘"DEFAULT"’ と呼ばれ
     ますが、任意の有効なセクション名を指すようにカスタマイズできます。
     典型的な値には ‘"general"’ や ‘"common"’ があります。与えられた名前
     はソースを読み込む際にデフォルトセクションを認識するのに使われ、設
     定をファイルに書き戻すときにも使われます。現在の値は
     ‘parser_instance.default_section’ 属性から取り出すことができ、実行
     時 (すなわちファイルを別のフォーマットに変換するとき) に変更するこ
     ともできます。

   * 'interpolation', デフォルト値: ‘configparser.BasicInterpolation’

     補間の振る舞いは、 'interpolation' 引数を通してカスタムハンドラを与
     えることでカスタマイズできます。 ‘None’ 引数を使うと補間を完全に無
     効にできます。 ‘ExtendedInterpolation()’ は、 ‘zc.buildout’ に影響
     を受けたより高度な補間を提供します。この話題に *note
     特化したドキュメントのセクション: 29e0. をご覧ください。 *note
     RawConfigParser: f31. のデフォルト値は ‘None’ です。

   * 'converters', デフォルト値: 未設定

     Config parsers provide option value getters that perform type
     conversion.  By default *note getint(): 29d9, *note getfloat():
     29da, and *note getboolean(): 29d8. are implemented.  Should other
     getters be desirable, users may define them in a subclass or pass a
     dictionary where each key is a name of the converter and each value
     is a callable implementing said conversion.  For instance, passing
     ‘{'decimal': decimal.Decimal}’ would add ‘getdecimal()’ on both the
     parser object and all section proxies.  In other words, it will be
     possible to write both ‘parser_instance.getdecimal('section',
     'key', fallback=0)’ and
     ‘parser_instance['section'].getdecimal('key', 0)’.

     コンバーターがパーサーの状態にアクセスする必要がある場合、設定パー
     サーサブクラスでメソッドとして実装することができます。このメソッド
     の名前が ‘get’ から始まる場合、すべてのセクションプロキシで、辞書と
     互換性のある形式で利用できます (上記の ‘getdecimal()’ の例を参照)。

これらのパーサー引数のデフォルト値を上書きすれば、さらに進んだカスタマイ
ズができます。デフォルトはクラスで定義されているので、派生クラスや属性の
代入で上書きできます。

 -- の属性: ConfigParser.BOOLEAN_STATES

     デフォルトでは、 *note getboolean(): 29d8. を使うことで、設定パーサ
     ーは以下の値を ‘True’ と見なします: ‘'1'’, ‘'yes'’, ‘'true'’,
     ‘'on'’ 。以下の値を ‘False’ と見なします: ‘'0'’, ‘'no'’, ‘'false'’,
     ‘'off'’ 。文字列と対応するブール値のカスタム辞書を指定することでこ
     れを上書きできます。たとえば:

          >>> custom = configparser.ConfigParser()
          >>> custom['section1'] = {'funky': 'nope'}
          >>> custom['section1'].getboolean('funky')
          Traceback (most recent call last):
          ...
          ValueError: Not a boolean: nope
          >>> custom.BOOLEAN_STATES = {'sure': True, 'nope': False}
          >>> custom['section1'].getboolean('funky')
          False

     ほかの典型的なブール値ペアには ‘accept’/‘reject’ や
     ‘enabled’/‘disabled’ などがあります。

 -- メソッド: ConfigParser.optionxform (option)

     このメソッドは読み込み、取得、設定操作のたびにオプション名を変換し
     ます。デフォルトでは名前を小文字に変換します。従って設定ファイルが
     書き込まれるとき、すべてのキーは小文字になります。それがふさわしく
     なければ、このメソッドを上書きしてください。例えば:

          >>> config = """
          ... [Section1]
          ... Key = Value
          ...
          ... [Section2]
          ... AnotherKey = Value
          ... """
          >>> typical = configparser.ConfigParser()
          >>> typical.read_string(config)
          >>> list(typical['Section1'].keys())
          ['key']
          >>> list(typical['Section2'].keys())
          ['anotherkey']
          >>> custom = configparser.RawConfigParser()
          >>> custom.optionxform = lambda option: option
          >>> custom.read_string(config)
          >>> list(custom['Section1'].keys())
          ['Key']
          >>> list(custom['Section2'].keys())
          ['AnotherKey']

          注釈: 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.

 -- の属性: ConfigParser.SECTCRE

     セクションヘッダを解析するのに使われる、コンパイルされた正規表現で
     す。デフォルトでは ‘[section]’ が ‘"section"’ という名前にマッチし
     ます。空白はセクション名の一部と見なされるので、‘[ larch ]’ は ‘"
     larch "’ という名のセクションとして読み込まれます。これがふさわしく
     ない場合、このメソッドを上書きしてください。例えば:

          >>> import re
          >>> config = """
          ... [Section 1]
          ... option = value
          ...
          ... [  Section 2  ]
          ... another = val
          ... """
          >>> typical = configparser.ConfigParser()
          >>> typical.read_string(config)
          >>> typical.sections()
          ['Section 1', '  Section 2  ']
          >>> custom = configparser.ConfigParser()
          >>> custom.SECTCRE = re.compile(r"\[ *(?P<header>[^]]+?) *\]")
          >>> custom.read_string(config)
          >>> custom.sections()
          ['Section 1', 'Section 2']

          注釈: ConfigParser オブジェクトはオプション行の認識に ‘OPTCRE’
          属性も使いますが、これを上書きすることは推奨されません。上書き
          するとコンストラクタオプション 'allow_no_value' および
          'delimiters' に干渉します。


File: python.info,  Node: レガシーな API の例,  Next: ConfigParser オブジェクト,  Prev: パーサーの振る舞いをカスタマイズする,  Up: configparser --- 設定ファイルのパーサー

5.14.2.9 レガシーな API の例
............................

主に後方互換性問題の理由から、 *note configparser: 1b. は ‘get’/‘set’ メ
ソッドを明示するレガシーな API も提供します。メソッドを以下に示すように
使うこともできますが、新しいプロジェクトではマップ型プロトコルでアクセス
するのが望ましいです。レガシーな API は時折高度で、低レベルで、まったく
直感的ではありません。

設定ファイルを書き出す例:

     import configparser

     config = configparser.RawConfigParser()

     # Please note that using RawConfigParser's set functions, you can assign
     # non-string values to keys internally, but will receive an error when
     # attempting to write to a file or when you get it in non-raw mode. Setting
     # values using the mapping protocol or ConfigParser's set() does not allow
     # such assignments to take place.
     config.add_section('Section1')
     config.set('Section1', 'an_int', '15')
     config.set('Section1', 'a_bool', 'true')
     config.set('Section1', 'a_float', '3.1415')
     config.set('Section1', 'baz', 'fun')
     config.set('Section1', 'bar', 'Python')
     config.set('Section1', 'foo', '%(bar)s is %(baz)s!')

     # Writing our configuration file to 'example.cfg'
     with open('example.cfg', 'w') as configfile:
         config.write(configfile)

設定ファイルを読み込む例:

     import configparser

     config = configparser.RawConfigParser()
     config.read('example.cfg')

     # getfloat() raises an exception if the value is not a float
     # getint() and getboolean() also do this for their respective types
     a_float = config.getfloat('Section1', 'a_float')
     an_int = config.getint('Section1', 'an_int')
     print(a_float + an_int)

     # Notice that the next output does not interpolate '%(bar)s' or '%(baz)s'.
     # This is because we are using a RawConfigParser().
     if config.getboolean('Section1', 'a_bool'):
         print(config.get('Section1', 'foo'))

補間するには、 *note ConfigParser: 1aa. を使ってください:

     import configparser

     cfg = configparser.ConfigParser()
     cfg.read('example.cfg')

     # Set the optional *raw* argument of get() to True if you wish to disable
     # interpolation in a single get operation.
     print(cfg.get('Section1', 'foo', raw=False))  # -> "Python is fun!"
     print(cfg.get('Section1', 'foo', raw=True))   # -> "%(bar)s is %(baz)s!"

     # The optional *vars* argument is a dict with members that will take
     # precedence in interpolation.
     print(cfg.get('Section1', 'foo', vars={'bar': 'Documentation',
                                            'baz': 'evil'}))

     # The optional *fallback* argument can be used to provide a fallback value
     print(cfg.get('Section1', 'foo'))
           # -> "Python is fun!"

     print(cfg.get('Section1', 'foo', fallback='Monty is not.'))
           # -> "Python is fun!"

     print(cfg.get('Section1', 'monster', fallback='No such things as monsters.'))
           # -> "No such things as monsters."

     # A bare print(cfg.get('Section1', 'monster')) would raise NoOptionError
     # but we can also use:

     print(cfg.get('Section1', 'monster', fallback=None))
           # -> None

どちらの型の ConfigParsers でもデフォルト値が利用できます。使われている
オプションがどこにも定義されていなければ、そのデフォルト値が補間に使われ
ます。

     import configparser

     # New instance with 'bar' and 'baz' defaulting to 'Life' and 'hard' each
     config = configparser.ConfigParser({'bar': 'Life', 'baz': 'hard'})
     config.read('example.cfg')

     print(config.get('Section1', 'foo'))     # -> "Python is fun!"
     config.remove_option('Section1', 'bar')
     config.remove_option('Section1', 'baz')
     print(config.get('Section1', 'foo'))     # -> "Life is hard!"


File: python.info,  Node: ConfigParser オブジェクト,  Next: RawConfigParser オブジェクト,  Prev: レガシーな API の例,  Up: configparser --- 設定ファイルのパーサー

5.14.2.10 ConfigParser オブジェクト
...................................

 -- クラス: configparser.ConfigParser (defaults=None, dict_type=dict,
          allow_no_value=False, *, delimiters=('=', ':'),
          comment_prefixes=('#', ';'), inline_comment_prefixes=None,
          strict=True, empty_lines_in_values=True,
          default_section=configparser.DEFAULTSECT,
          interpolation=BasicInterpolation(), converters={},
          allow_unnamed_section=False)

     主要な設定パーサーです。'defaults' が与えられれば、その辞書の持つ初
     期値で初期化されます。'dict_type' が与えられれば、それがセクション
     の一覧、セクション中のオプション、およびデフォルト値の辞書オブジェ
     クトを作成するのに使われます。

     'delimiters' が与えられた場合、キーと値を分割する部分文字列の組み合
     わせとして使われます。'comment_prefixes' が与えられた場合、他の内容
     がない行のコメントに接頭する部分文字列の組み合わせとして使われます
     。コメントはインデントできます。'inline_comment_prefixes' が与えら
     れた場合、非空行のコメントに接頭する部分文字列としての組み合わせと
     して使われます。

     'strict' が ‘True’ (デフォルト) であれば、パーサーは単一のソース (フ
     ァイル、文字列、辞書) 中にセクションやオプションの重複を認めず、
     *note DuplicateSectionError: 1240. や *note DuplicateOptionError:
     1241. を送出します。 'empty_lines_in_values' が ‘False’ (デフォルト
     : ‘True’) なら、空行はそれぞれオプションの終わりを示します。
     'allow_no_value' が ‘True’ (デフォルト: ‘False’) なら、値のないオプ
     ションが受け付けられます。そのオプションの値は ‘None’ となり、後端
     のデリミタを除いてシリアル化されます。

     When 'default_section' is given, it specifies the name for the
     special section holding default values for other sections and
     interpolation purposes (normally named ‘"DEFAULT"’).  This value
     can be retrieved and changed at runtime using the ‘default_section’
     instance attribute.  This won't re-evaluate an already parsed
     config file, but will be used when writing parsed settings to a new
     config file.

     補間の動作は、 'interpolation' 引数を通してカスタムハンドラを与える
     ことでカスタマイズできます。 ‘None’ 引数を使うと補間を完全に無効に
     できます。 ‘ExtendedInterpolation()’ は、 ‘zc.buildout’ に影響を受
     けたより高度な補間を提供します。この件に *note
     特化したドキュメントのセクション: 29e0. を参照してください。

     補間に使われるすべてのオプション名は、他のオプション名参照と同様に
     、 *note optionxform(): 29e8. メソッドを通して渡されます。例えば、
     *note optionxform(): 29e8. のデフォルトの実装を使うと、値 ‘foo
     %(bar)s’ と ‘foo %(BAR)s’ は等しくなります。

     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 implementing the conversion from string to the desired
     datatype.  Every converter gets its own corresponding ‘get*()’
     method on the parser object and section proxies.

     When 'allow_unnamed_section' is ‘True’ (default: ‘False’), the
     first section name can be omitted.  See the *note "Unnamed
     Sections" section: 29df.

     It is possible to read several configurations into a single *note
     ConfigParser: 1aa, where the most recently added configuration has
     the highest priority.  Any conflicting keys are taken from the more
     recent configuration while the previously existing keys are
     retained.  The example below reads in an ‘override.ini’ file, which
     will override any conflicting keys from the ‘example.ini’ file.

          [DEFAULT]
          ServerAliveInterval = -1

          >>> config_override = configparser.ConfigParser()
          >>> config_override['DEFAULT'] = {'ServerAliveInterval': '-1'}
          >>> with open('override.ini', 'w') as configfile:
          ...     config_override.write(configfile)
          ...
          >>> config_override = configparser.ConfigParser()
          >>> config_override.read(['example.ini', 'override.ini'])
          ['example.ini', 'override.ini']
          >>> print(config_override.get('DEFAULT', 'ServerAliveInterval'))
          -1

     バージョン 3.1 で変更: デフォルトの 'dict_type' は *note
     collections.OrderedDict: 5a5. です。

     バージョン 3.2 で変更: 'allow_no_value', 'delimiters',
     'comment_prefixes', 'strict', 'empty_lines_in_values',
     'default_section' および 'interpolation' が追加されました。

     バージョン 3.5 で変更: 'converters' 引数が追加されました。

     バージョン 3.7 で変更: The 'defaults' argument is read with *note
     read_dict(): 29e1, providing consistent behavior across the parser:
     non-string keys and values are implicitly converted to strings.

     バージョン 3.8 で変更: The default 'dict_type' is *note dict: 237,
     since it now preserves insertion order.

     バージョン 3.13 で変更: Raise a *note MultilineContinuationError:
     29e9. when 'allow_no_value' is ‘True’, and a key without a value is
     continued with an indented line.

     バージョン 3.13 で変更: The 'allow_unnamed_section' argument was
     added.

      -- メソッド: defaults ()

          インスタンス全体で使われるデフォルト値の辞書を返します。

      -- メソッド: sections ()

          利用できるセクションのリストを返します。'default section' はリ
          ストに含まれません。

      -- メソッド: add_section (section)

          'section' という名のセクションをインスタンスに追加します。与え
          られた名前のセクション名がすでに存在したら、 *note
          DuplicateSectionError: 1240. が送出されます。 'default
          section' 名が渡されたら、 *note ValueError: 1e3. が送出されま
          す。セクションの名前は文字列でなければなりません。そうでなけれ
          ば、 *note TypeError: 502. が送出されます。

          バージョン 3.2 で変更: 文字列でないセクション名は *note
          TypeError: 502. を送出します。

      -- メソッド: has_section (section)

          指名された 'section' が設定中に存在するかを示します。'default
          section' は認識されません。

      -- メソッド: options (section)

          指定された 'section' 中で利用できるオプションのリストを返しま
          す。

      -- メソッド: has_option (section, option)

          与えられた 'section' が存在し、与えられた 'option' を含む場合
          、 *note True: bdb. を返します。それ以外の場合には、 *note
          False: b05. を返します。指定された 'section' が *note None:
          641. または空文字列の場合、 DEFAULT が仮定されます。

      -- メソッド: read (filenames, encoding=None)

          ファイル名の iterable を読み込んでパースしようと試みます。正常
          にパースできたファイル名のリストを返します。

          もし 'filenames' が文字列か *note bytes: 1a4. オブジェクトか
          *note path-like object: 280. なら、この引数は1つのファイル名と
          して扱われます。 'filenames' 中に開けないファイルがある場合、
          そのファイルは無視されます。この挙動は、設定ファイルが置かれる
          可能性のある場所(例えば、 カレントディレクトリ、ホームディレク
          トリ、システム全体の設定を行うディレクトリ)のイテラブルを指定
          して、イテラブルの中で存在する全ての設定ファイルを読むことを想
          定して設計されています。

          どの設定ファイルも存在しなかった場合、 *note ConfigParser:
          1aa. のインスタンスは 空のデータセットを持ちます。初期値の設定
          ファイルを先に読み込んでおく必要があるアプリケーションでは、 オ
          プションのファイルを読み込むために *note read(): 140d. を呼ぶ
          前に 、まず *note read_file(): 4d1. を用いて必要なファイルを読
          み込んでください:

               import configparser, os

               config = configparser.ConfigParser()
               config.read_file(open('defaults.cfg'))
               config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')],
                           encoding='cp1250')

          バージョン 3.2 で変更: Added the 'encoding' parameter.
          Previously, all files were read using the default encoding for
          *note open(): 4e5.

          バージョン 3.6.1 で変更: 'filenames' 引数が *note path-like
          object: 280. を受け入れるようになりました。

          バージョン 3.7 で変更: 'filenames' 引数が *note bytes: 1a4. オ
          ブジェクトを受け入れるようになりました。

      -- メソッド: read_file (f, source=None)

          設定データを 'f' から読み込んで解析します。'f' は Unicode 文字
          列を yield するイテラブル (例えばテキストモードで開かれたファ
          イル) です。

          Optional argument 'source' specifies the name of the file
          being read.  If not given and 'f' has a ‘name’ attribute, that
          is used for 'source'; the default is ‘'<???>'’.

          Added in version 3.2: ‘readfp()’ を置き換えます。

      -- メソッド: read_string (string, source='<string>')

          設定データを文字列から解析します。

          オプションの引数 'source' はコンテキストにおける渡された文字列
          の名前を指定します。与えられなければ、‘'<string>'’ が使われま
          す。これは一般にファイルシステムパスや URL にします。

          Added in version 3.2.

      -- メソッド: read_dict (dictionary, source='<dict>')

          辞書的な ‘items()’ メソッドを提供する任意のオブジェクトから設
          定を読み込みます。キーはセクション名で、値はそのセクションに現
          れるキーと値をもつ辞書です。使われた辞書型が順序を保存するなら
          、セクションおよびそのキーは順に加えられます。値は自動で文字列
          に変換されます。

          オプションの引数 'source' はコンテキストにおける渡された辞書の
          名前を指定します。与えられなければ、‘<dict>’ が使われます。

          このメソッドを使ってパーサー間で状態をコピーできます。

          Added in version 3.2.

      -- メソッド: get (section, option, *, raw=False, vars=None[,
               fallback])

          指名された 'section' の 'option' の値を取得します。'vars' が提
          供されるなら、それは辞書でなければならず、(与えられたなら)
          'vars', 'section', 'DEFAULTSECT' 内からこの順で 'option' が探
          索されます。'fallback' の値として ‘None’ を与えられます。

          'raw' が真でない時には、全ての ‘'%'’ 置換は展開されてから返さ
          れます。置換後の値はオプションと同じ順序で探されます。

          バージョン 3.2 で変更: 引数 'raw', 'vars' および 'fallback' は
          、(特にマッピングプロトコルを使用するときに) ユーザーが第 3 引
          数を 'fallback' フォールバックとして使おうとしないように、キー
          ワード専用となりました。

      -- メソッド: getint (section, option, *, raw=False, vars=None[,
               fallback])

          指定された 'section' 中の 'option' を整数に型強制する補助メソ
          ッドです。 'raw', 'vars' および 'fallback' の説明は *note
          get(): 123d. を参照してください。

      -- メソッド: getfloat (section, option, *, raw=False, vars=None[,
               fallback])

          A convenience method which coerces the 'option' in the
          specified 'section' to a floating-point number.  See *note
          get(): 123d. for explanation of 'raw', 'vars' and 'fallback'.

      -- メソッド: getboolean (section, option, *, raw=False,
               vars=None[, fallback])

          指定された 'section' 中の 'option' をブール値に型強制する補助
          メソッドです。なお、このオプションで受け付けられる値はこのメソ
          ッドが ‘True’ を返す ‘'1'’, ‘'yes'’, ‘'true'’, および ‘'on'’,と
          、このメソッドが ‘False’ を返す ‘'0'’, ‘'no'’, ‘'false'’, and
          ‘'off'’ です。その他のいかなる値も *note ValueError: 1e3. を送
          出します。 'raw', 'vars' および 'fallback' の説明は *note
          get(): 123d. を参照してください。

      -- メソッド: items (raw=False, vars=None)

      -- メソッド: items (section, raw=False, vars=None)

          'section' が与えられなければ、DEFAULTSECT を含めた
          'section_name', 'section_proxy' の対のリストを返します。

          与えられれば、与えられた 'section' 中のオプションの 'name',
          'value' の対のリストを返します。オプションの引数は *note
          get(): 123d. メソッドに与えるものと同じ意味を持ちます。

          バージョン 3.8 で変更: 'vars' に現れる項目は結果に表れなくなり
          ました。以前の挙動は、実際のパーサーオプションを補間のために与
          えられた変数と混合していました。

      -- メソッド: set (section, option, value)

          与えられたセクションが存在すれば、与えられたオプションを指定さ
          れた値に設定します。そうでなければ *note NoSectionError: 29f0.
          を送出します。 'option' および 'value' は文字列でなければなり
          ません。そうでなければ *note TypeError: 502. が送出されます。

      -- メソッド: write (fileobject, space_around_delimiters=True)

          設定の表現を指定された *note file object: 1193. に書き込みます
          。 'fileobject' は (文字列を受け付ける) テキストモードで開かれ
          ていなければなりません。この表現は後で *note read(): 140d. を
          呼び出すことでパースできます。 'space_around_delimiters' が真
          なら、キーと値の間のデリミタはスペースで囲まれます。

          注釈: Comments in the original configuration file are not
          preserved when writing the configuration back.  What is
          considered a comment, depends on the given values for
          'comment_prefix' and 'inline_comment_prefix'.

      -- メソッド: remove_option (section, option)

          指定された 'option' を指定された 'section' から削除します。セ
          クションが存在しなければ、 *note NoSectionError: 29f0. を送出
          します。オプションが存在して削除されれば、 *note True: bdb. を
          返します。そうでなければ *note False: b05. を返します。

      -- メソッド: remove_section (section)

          指定された 'section' を設定から削除します。セクションが実際に
          存在すれば、‘True’ を返します。そうでなければ ‘False’ を返しま
          す。

      -- メソッド: optionxform (option)

          入力ファイルに現れた、またはクライアントコードで渡されたオプシ
          ョン名 'option' を内部構造で実際に使われる形式に変換します。デ
          フォルトの実装では 'option' の小文字版を返します。派生クラスで
          これを上書きするか、クライアントコードでインスタンス上のこの名
          前の属性を設定して、この動作に影響を与えることができます。

          このメソッドを使うためにパーサーを派生クラス化させる必要はなく
          、インスタンス上で、これを文字列引数をとって文字列を返す関数に
          設定できます。例えば、これを ‘str’ に設定すると、オプション名
          に大文字小文字の区別をつけられます:

               cfgparser = ConfigParser()
               cfgparser.optionxform = str

          なお、設定ファイルを読み込むとき、オプション名の周りの空白は
          *note optionxform(): 29e8. が呼び出される前に取り除かれます。

 -- データ: configparser.UNNAMED_SECTION

     A special object representing a section name used to reference the
     unnamed section (see *note Unnamed Sections: 29df.).

 -- データ: configparser.MAX_INTERPOLATION_DEPTH

     The maximum depth for recursive interpolation for *note get():
     123d. when the 'raw' parameter is false.  This is relevant only
     when the default 'interpolation' is used.


File: python.info,  Node: RawConfigParser オブジェクト,  Next: 例外<8>,  Prev: ConfigParser オブジェクト,  Up: configparser --- 設定ファイルのパーサー

5.14.2.11 RawConfigParser オブジェクト
......................................

 -- クラス: configparser.RawConfigParser (defaults=None, dict_type=dict,
          allow_no_value=False, *, delimiters=('=', ':'),
          comment_prefixes=('#', ';'), inline_comment_prefixes=None,
          strict=True, empty_lines_in_values=True,
          default_section=configparser.DEFAULTSECT,
          interpolation=BasicInterpolation(), converters={},
          allow_unnamed_section=False)

     Legacy variant of the *note ConfigParser: 1aa.  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.

     バージョン 3.2 で変更: 'allow_no_value', 'delimiters',
     'comment_prefixes', 'strict', 'empty_lines_in_values',
     'default_section' および 'interpolation' が追加されました。

     バージョン 3.5 で変更: 'converters' 引数が追加されました。

     バージョン 3.8 で変更: The default 'dict_type' is *note dict: 237,
     since it now preserves insertion order.

     バージョン 3.13 で変更: The 'allow_unnamed_section' argument was
     added.

          注釈: 代わりに内部に保存する値の型を検査する *note
          ConfigParser: 1aa. を使うことを検討してください。補間を望まな
          い場合、 ‘ConfigParser(interpolation=None)’ を使用できます。

      -- メソッド: add_section (section)

          インスタンスに 'section' という名のセクションを追加します。与
          えられた名前のセクションがすでに存在すれば、 *note
          DuplicateSectionError: 1240. が送出されます。 'default
          section' 名が渡されると、 *note ValueError: 1e3. が送出されま
          す。

          'section' の型は検査されないため、ユーザーは非文字列の名前付き
          セクションを作ることができます。この振る舞いはサポートされてお
          らず、内部エラーを起こす可能性があります。

      -- メソッド: set (section, option, value)

          与えられたセクションが存在していれば、オプションを指定された値
          に設定します。セクションが存在しなければ *note NoSectionError:
          29f0. を発生させます。 *note RawConfigParser: f31. (あるいは
          'raw' パラメータをセットした *note ConfigParser: 1aa.) を文字
          列型でない値の '内部的な' 格納場所として使うことは可能ですが、
          すべての機能 (置換やファイルへの出力を含む) がサポートされるの
          は文字列を値として使った場合だけです。

          ユーザーは、このメソッドを使って非文字列の値をキーに代入できま
          す。この振る舞いはサポートされておらず、非rawモードでの値の取
          得や、ファイルへの書き出しを試みた際にエラーの原因となりえます
          。このような代入を許さない 'マッピングプロトコルAPIを使用して
          ください'。


File: python.info,  Node: 例外<8>,  Prev: RawConfigParser オブジェクト,  Up: configparser --- 設定ファイルのパーサー

5.14.2.12 例外
..............

 -- 例外: configparser.Error

     他の全ての *note configparser: 1b. 例外の基底クラスです。

 -- 例外: configparser.NoSectionError

     指定したセクションが見つからなかった時に起きる例外です。

 -- 例外: configparser.DuplicateSectionError

     Exception raised if *note add_section(): 123f. 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.

     バージョン 3.2 で変更: Added the optional 'source' and 'lineno'
     attributes and parameters to ‘__init__()’.

 -- 例外: configparser.DuplicateOptionError

     strict なパーサーで、単一の入力ファイル、文字列、辞書中に同じオプシ
     ョンが複数回現れたときに送出される例外です。これはミススペルや大文
     字小文字の区別に関係するエラー、例えば辞書の二つのキーが同じ大文字
     小文字の区別のない設定キーを表すこと、を捕捉します。

 -- 例外: configparser.NoOptionError

     指定されたオプションが指定されたセクションに見つからないときに送出
     される例外です。

 -- 例外: configparser.InterpolationError

     文字列の補間中に問題が起きた時に発生する例外の基底クラスです。

 -- 例外: configparser.InterpolationDepthError

     繰り返しの回数が *note MAX_INTERPOLATION_DEPTH: 29f3. を超えたため
     に文字列補間が完了しなかったときに送出される例外です。 *note
     InterpolationError: 29fb. の派生クラスです。

 -- 例外: configparser.InterpolationMissingOptionError

     *note InterpolationError: 29fb. の派生クラスで、値が参照しているオ
     プションが見つからない場合に発生する例外です。

 -- 例外: configparser.InterpolationSyntaxError

     置換がなされるソーステキストが要求された文法を満たさないときに送出
     される例外です。 *note InterpolationError: 29fb. の派生クラスです。

 -- 例外: configparser.MissingSectionHeaderError

     セクションヘッダを持たないファイルを構文解析しようとした時に起きる
     例外です。

 -- 例外: configparser.ParsingError

     ファイルの構文解析中にエラーが起きた場合に発生する例外です。

     バージョン 3.12 で変更: The ‘filename’ attribute and ‘__init__()’
     constructor argument were removed.  They have been available using
     the name ‘source’ since 3.2.

 -- 例外: configparser.MultilineContinuationError

     Exception raised when a key without a corresponding value is
     continued with an indented line.

     Added in version 3.13.

脚注
....


File: python.info,  Node: tomllib --- TOML ファイルの解析,  Next: netrc --- netrc ファイルの処理,  Prev: configparser --- 設定ファイルのパーサー,  Up: ファイルフォーマット

5.14.3 ‘tomllib’ -- TOML ファイルの解析
---------------------------------------

Added in version 3.11.

'ソースコード:' Lib/tomllib(1)

__________________________________________________________________

This module provides an interface for parsing TOML 1.0.0 (Tom's Obvious
Minimal Language, https://toml.io(2)).  This module does not support
writing TOML.

参考
....

Tomli-W パッケージ(3) はTOMLの書き込み用にこのモジュールと組み合わせて使
用でき、標準ライブラリの *note marshal: 80. や *note pickle: 95. モジュ
ールなどでユーザーによく知られている書き込みAPIを提供します。

参考
....

TOML Kit パッケージ(4) は、スタイルを保持した読み書きに対応したTOMLライ
ブラリです。存在するTOMLファイルを編集するときにこのモジュールの代わりに
使用することを推奨します。

このモジュールは以下の関数を定義しています:

 -- の関数: tomllib.load (fp, /, *, parse_float=float)

     TOMLファイルを読み込みます。第1引数には読み込み可能なバイナリのファ
     イルオブジェクトを指定します。戻り値は *note dict: 237. です。
     TOMLの型は *note conversion table: 2a03. を使用してPythonのデータ型
     に変換されます。

     'parse_float' は、全てのデコードされる TOML の浮動小数点数文字列に
     対して呼ばれます。デフォルトでは、 ‘float(num_str)’ と等価です。こ
     れは TOML 浮動小数点数に対して他のデータ型やパーサ (たとえば *note
     decimal.Decimal: 27d.) を使うのに使えます。呼び出し可能オブジェクト
     は *note dict: 237. や *note list: 5dc. 以外を返す必要があり、そう
     でない場合は *note ValueError: 1e3. が送出されます。

     無効なTOMLドキュメントの場合は *note TOMLDecodeError: 2a04. が送出
     されます。

 -- の関数: tomllib.loads (s, /, *, parse_float=float)

     *note str: 418. からTOMLを読み込みます。戻り値は *note dict: 237. で
     す。TOMLの型は *note conversion table: 2a03. を使用してPythonのデー
     タ型に変換されます。'parse_float'  引数は *note load(): 2a02. と同
     じ意味を持ちます。

     無効なTOMLドキュメントの場合は *note TOMLDecodeError: 2a04. が送出
     されます。

次の例外がサポートされています:

 -- 例外: tomllib.TOMLDecodeError

     *note ValueError: 1e3. のサブクラスです。

* Menu:

* 使用例: 使用例<17>.
* 変換表::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tomllib

   (2) https://toml.io/en/

   (3) https://pypi.org/project/tomli-w/

   (4) https://pypi.org/project/tomlkit/


File: python.info,  Node: 使用例<17>,  Next: 変換表,  Up: tomllib --- TOML ファイルの解析

5.14.3.1 使用例
...............

TOMLファイルを解析します:

     import tomllib

     with open("pyproject.toml", "rb") as f:
         data = tomllib.load(f)

TOMLの文字列を解析します:

     import tomllib

     toml_str = """
     python-version = "3.11.0"
     python-implementation = "CPython"
     """

     data = tomllib.loads(toml_str)


File: python.info,  Node: 変換表,  Prev: 使用例<17>,  Up: tomllib --- TOML ファイルの解析

5.14.3.2 変換表
...............

TOML                   Python
                       
------------------------------------------------------------------------------------------------------------------
                       
TOMLドキュメント       辞書
                       
                       
string                 str
                       
                       
整数                   int
                       
                       
浮動小数点数           float （'parse_float' で設定可能）
                       
                       
boolean                真偽値型(bool)
                       
                       
オフセット付きの日時   datetime.datetime（‘tzinfo’ 属性は ‘datetime.timezone’ のインスタンスが設定される）
に日地                 

ローカルの日時         datetime.datetime（‘tzinfo’ 属性は ‘None’ に設定される）
                       
                       
ローカルの日付         datetime.date
                       
                       
ローカルの時刻         datetime.time
                       
                       
配列                   リスト
                       
                       
テーブル               辞書
                       
                       
インラインテーブル     辞書
                       
                       
テーブルの配列         辞書のリスト
                       


File: python.info,  Node: netrc --- netrc ファイルの処理,  Next: plistlib --- Apple plist ファイルを生成・解析する,  Prev: tomllib --- TOML ファイルの解析,  Up: ファイルフォーマット

5.14.4 ‘netrc’ -- netrc ファイルの処理
--------------------------------------

'ソースコード:' Lib/netrc.py(1)

__________________________________________________________________

*note netrc: 182c. クラスは、Unix ‘ftp’ プログラムや他の FTP クライアン
トで用いられる netrc ファイル形式を解析し、カプセル化 (encapsulate) しま
す。

 -- クラス: netrc.netrc ([file])

     *note netrc: 182c. のインスタンスやサブクラスのインスタンスは netrc
     ファイルのデータをカプセル化します。 初期化の際の引数が存在する場合
     、解析対象となるファイルの指定になります。 引数がない場合、 (*note
     os.path.expanduser(): 9e2. で特定される) ユーザのホームディレクトリ
     下にある ‘.netrc’ が読み出されます。ファイルが見付からなかった場合
     は *note FileNotFoundError: e8f. 例外が送出されます。 解析エラーが
     発生した場合、ファイル名、行番号、解析を中断したトークンに関する情
     報の入った *note NetrcParseError: 2a0a. を送出します。 POSIX システ
     ムにおいて引数を指定しない場合、ファイルのオーナシップやパーミッシ
     ョンが安全でない (プロセスを実行しているユーザ以外が所有者であるか
     、誰にでも読み書き出来てしまう) のに ‘.netrc’ ファイル内にパスワー
     ドが含まれていると、 *note NetrcParseError: 2a0a. を送出します。 こ
     のセキュリティ的な振る舞いは、 ftp などの ‘.netrc’ を使うプログラム
     と同じものです。

     バージョン 3.4 で変更: POSIX パーミッションのチェックが追加されまし
     た。

     バージョン 3.7 で変更: 引数で 'file' が渡されなかったときは、
     ‘.netrc’ ファイルの場所を探すのに *note os.path.expanduser(): 9e2.
     が使われるようになりました。

     バージョン 3.10 で変更: *note netrc: 8d. は、ロケール固有のエンコー
     ディングを使用する前に、 UTF-8 でのエンコーディングを試みます。
     netrc ファイルのエントリがすべてのトークンを含む必要はなくなりまし
     た。欠落したトークンのデフォルト値は空文字列です。すべてのトークン
     とその値は空白や非 ASCII 文字のような任意の文字を使用できるようにな
     りました。ログイン名が匿名の場合、セキュリティチェックはトリガーし
     ません。

 -- 例外: netrc.NetrcParseError

     ソーステキストに構文上のエラーがある場合に、 *note netrc: 182c. ク
     ラスで発生する例外。この例外のインスタンスは3つの興味深い属性を提供
     します:

      -- の属性: msg

          エラーのテキストによる説明。

      -- の属性: filename

          ソースファイルの名前。

      -- の属性: lineno

          エラーが見つかった行番号。

* Menu:

* netrc オブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/netrc.py


File: python.info,  Node: netrc オブジェクト,  Up: netrc --- netrc ファイルの処理

5.14.4.1 netrc オブジェクト
...........................

*note netrc: 182c. インスタンスは以下のメソッドを持っています:

 -- メソッド: netrc.authenticators (host)

     'host' の認証情報として、三要素のタプル ‘(login, account,
     password)’ を返します。与えられた host に対するエントリが netrc フ
     ァイルにない場合、'default' エントリに関連付けられたタプルが返され
     ます。host に対応するエントリがなく、default エントリもない場合、
     ‘None’ を返します。

 -- メソッド: netrc.__repr__ ()

     クラスの持っているデータを netrc ファイルの書式に従った文字列で出力
     します。(コメントは無視され、エントリが並べ替えられる可能性がありま
     す。)

*note netrc: 182c. のインスタンスは以下の public なインスタンス変数を持
っています:

 -- の属性: netrc.hosts

     ホスト名を ‘(login, account, password)’ からなるタプルに対応づけて
     いる辞書です。'default' エントリがある場合、その名前の擬似ホスト名
     として表現されます。

 -- の属性: netrc.macros

     マクロ名を文字列のリストに対応付けている辞書です。


File: python.info,  Node: plistlib --- Apple plist ファイルを生成・解析する,  Prev: netrc --- netrc ファイルの処理,  Up: ファイルフォーマット

5.14.5 ‘plistlib’ -- Apple ‘.plist’ ファイルを生成・解析する
------------------------------------------------------------

'ソースコード:' Lib/plistlib.py(1)

__________________________________________________________________

このモジュールは Apple (主に macOS と iOS) で使われる「プロパティーリス
ト」ファイルを読み書きするインターフェイスを提供します。このモジュールは
バイナリと XML の plist ファイルの両方をサポートします。

プロパティーリスト (‘.plist’) ファイル形式は基本的型のオブジェクト、たと
えば辞書やリスト、数、文字列など、に対する単純な直列化です。たいてい、ト
ップレベルのオブジェクトは辞書です。

plist ファイルを書き出したり解析したりするには *note dump(): 91f. や
*note load(): 91d. 関数を利用します。

バイトオブジェクトや文字列オブジェクトの plist データを扱うためには
*note dumps(): 920. や *note loads(): 91e. を利用します。

値は文字列、整数、浮動小数点数、ブール型、タプル、リスト、辞書 (ただし文
字列だけがキーになれます)、 *note bytes: 1a4.、*note bytearray: 508. ま
たは *note datetime.datetime: 1ae. のオブジェクトです。

バージョン 3.4 で変更: 新しい API となり、古い API は非推奨となりました
。バイナリ形式の plist がサポートされました。

バージョン 3.8 で変更: バイナリの plist で NSKeyedArchiver や
NSKeyedUnarchiver によって使用される *note UID: 9ef. トークンの読み込み
・書き込みのサポートが追加されました。

バージョン 3.9 で変更: 古い API が削除されました。

参考
....

PList マニュアルページ(2)

     このファイル形式の Apple の文書。

このモジュールは以下の関数を定義しています:

 -- の関数: plistlib.load (fp, *, fmt=None, dict_type=dict,
          aware_datetime=False)

     plist ファイルを読み込みます。'fp' は読み込み可能かつバイナリのファ
     イルオブジェクトです。展開されたルートオブジェクト (通常は辞書です)
     を返します。

     'fmt' はファイルの形式で、次の値が有効です。

        * *note None: 641.: ファイル形式を自動検出します

        * *note FMT_XML: f46.: XML ファイル形式です

        * *note FMT_BINARY: f47.: バイナリの plist 形式です

     'dict_type' は、 plist ファイルから読み出された辞書に使われる型です
     。

     'aware_datetime' が true の場合、 ‘datetime.datetime’ 型によるフィ
     ールドは、 *note datetime.UTC: 4bb. の ‘tzinfo’ 付きで *note aware
     オブジェクト: 237f. として作成されます。

     *note FMT_XML: f46. 形式の XML データは *note xml.parsers.expat:
     10d. にある Expat パーサーを使って解析されます。不正な形式の XML に
     対して送出される可能性のある例外については、そちらの文書を参照して
     ください。plist 解析器では、未知の要素は単純に無視されます。

     バイナリ形式のパーサーは、ファイルを解析できない場合に
     ‘InvalidFileException’ を送出します。

     Added in version 3.4.

     バージョン 3.13 で変更: キーワード専用引数 'aware_datetime' が追加
     されました。

 -- の関数: plistlib.loads (data, *, fmt=None, dict_type=dict,
          aware_datetime=False)

     バイナリまたは文字列オブジェクトから plist をロードします。キーワー
     ド引数の説明については、 *note load(): 91d. を参照してください。

     Added in version 3.4.

     バージョン 3.13 で変更: 'fmt' が *note FMT_XML: f46. の場合、
     'data' は文字列たり得ます。

 -- の関数: plistlib.dump (value, fp, *, fmt=FMT_XML, sort_keys=True,
          skipkeys=False, aware_datetime=False)

     plist ファイルに 'value' を書き込みます。'Fp' は、書き込み可能なバ
     イナリファイルオブジェクトにしてください。

     'fmt' 引数は plist ファイルの形式を指定し、次のいずれかの値をとるこ
     とができます。

        * *note FMT_XML: f46.: XML 形式の plist ファイルです

        * *note FMT_BINARY: f47.: バイナリ形式の plist ファイルです

     'sort_keys' が真 (デフォルト) の場合、辞書内のキーは、plist にソー
     トされた順序で書き込まれます。偽の場合、ディクショナリのイテレート
     の順序で書き込まれます。

     'skipkeys' が偽 (デフォルト) の場合、この関数は辞書のキーが文字列で
     ない場合に *note TypeError: 502. を送出します。真の場合、そのような
     キーは読み飛ばされます。

     When 'aware_datetime' is true and any field with type
     ‘datetime.datetime’ is set as an *note aware object: 237f, it will
     convert to UTC timezone before writing it.

     *note TypeError: 502. が、オブジェクトがサポート外の型のものであっ
     たりサポート外の型のオブジェクトを含むコンテナだった場合に、送出さ
     れます。

     (バイナリの) plist ファイル内で表現できない整数値に対しては、 *note
     OverflowError: 84e. が送出されます。

     Added in version 3.4.

     バージョン 3.13 で変更: キーワード専用引数 'aware_datetime' が追加
     されました。

 -- の関数: plistlib.dumps (value, *, fmt=FMT_XML, sort_keys=True,
          skipkeys=False, aware_datetime=False)

     'value' を plist 形式のバイトオブジェクトとして返します。この関数の
     キーワード引数の説明については、 *note dump(): 91f. を参照してくだ
     さい。

     Added in version 3.4.

以下のクラスが使用可能です:

 -- クラス: plistlib.UID (data)

     *note int: 238. をラップします。これは NSKeyedArchiver でエンコード
     された UID を含むデータ、の読み込みや書き込みに使用されます (PList
     マニュアルを参照) 。

     これは一つ、 ‘data’ 属性を持ち、これにより UID の int 値を取得する
     ことができます。 ‘data’ は ‘0 <= data < 2**64’ の範囲内でなければな
     りません。

     Added in version 3.8.

以下の定数が利用可能です:

 -- データ: plistlib.FMT_XML

     plist ファイルの XML 形式です

     Added in version 3.4.

 -- データ: plistlib.FMT_BINARY

     plist ファイルのバイナリ形式です

     Added in version 3.4.

* Menu:

* 使用例: 使用例<18>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/plistlib.py

   (2) 
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/PropertyLists/


File: python.info,  Node: 使用例<18>,  Up: plistlib --- Apple plist ファイルを生成・解析する

5.14.5.1 使用例
...............

plist を作ります:

     import datetime
     import plistlib

     pl = dict(
         aString = "Doodah",
         aList = ["A", "B", 12, 32.1, [1, 2, 3]],
         aFloat = 0.1,
         anInt = 728,
         aDict = dict(
             anotherString = "<hello & hi there!>",
             aThirdString = "M\xe4ssig, Ma\xdf",
             aTrueValue = True,
             aFalseValue = False,
         ),
         someData = b"<binary gunk>",
         someMoreData = b"<lots of binary gunk>" * 10,
         aDate = datetime.datetime.now()
     )
     print(plistlib.dumps(pl).decode())

plist を解析します:

     import plistlib

     plist = b"""<plist version="1.0">
     <dict>
         <key>foo</key>
         <string>bar</string>
     </dict>
     </plist>"""
     pl = plistlib.loads(plist)
     print(pl["foo"])


File: python.info,  Node: 暗号関連のサービス,  Next: 汎用オペレーティングシステムサービス,  Prev: ファイルフォーマット,  Up: Python 標準ライブラリ

5.15 暗号関連のサービス
=======================

この章で記述されているモジュールでは、暗号の本質に関わる様々なアルゴリズ
ムを実装しています。 これらは必要に応じてインストールすることで使用でき
ます。概要を以下に示します:

* Menu:

* hashlib: hashlib --- セキュアハッシュとメッセージダイジェスト. セキュアハッシュとメッセージダイジェスト
* hmac: hmac --- メッセージ認証のための鍵付きハッシュ化. メッセージ認証のための鍵付きハッシュ化
* secrets: secrets --- 機密を扱うために安全な乱数を生成する. 機密を扱うために安全な乱数を生成する


File: python.info,  Node: hashlib --- セキュアハッシュとメッセージダイジェスト,  Next: hmac --- メッセージ認証のための鍵付きハッシュ化,  Up: 暗号関連のサービス

5.15.1 ‘hashlib’ -- セキュアハッシュとメッセージダイジェスト
------------------------------------------------------------

'ソースコード:' Lib/hashlib.py(1)

__________________________________________________________________

This module implements a common interface to many different secure hash
and message digest algorithms.  Included are the FIPS secure hash
algorithms SHA1, SHA224, SHA256, SHA384, SHA512, (defined in the FIPS
180-4 standard(2)), the SHA-3 series (defined in the FIPS 202
standard(3)) as well as RSA's MD5 algorithm (defined in internet RFC
1321(4)).  The terms "secure hash" and "message digest" are
interchangeable.  Older algorithms were called message digests.  The
modern term is secure hash.

     注釈: adler32 や crc32 ハッシュ関数は *note zlib: 119. モジュールで
     提供されています。

* Menu:

* ハッシュアルゴリズム::
* 使用法::
* Constructors::
* 属性::
* Hash Objects::
* SHAKE 可変長ダイジェスト::
* File hashing::
* 鍵導出::
* BLAKE2::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/hashlib.py

   (2) https://csrc.nist.gov/pubs/fips/180-4/upd1/final

   (3) https://csrc.nist.gov/pubs/fips/202/final

   (4) https://datatracker.ietf.org/doc/html/rfc1321.html


File: python.info,  Node: ハッシュアルゴリズム,  Next: 使用法,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.1 ハッシュアルゴリズム
.............................

There is one constructor method named for each type of 'hash'.  All
return a hash object with the same simple interface.  For example: use
*note sha256(): 2a1e. to create a SHA-256 hash object.  You can now feed
this object with *note bytes-like objects: cfb. (normally *note bytes:
1a4.) using the *note update: 2a1f. method.  At any point you can ask it
for the 'digest' of the concatenation of the data fed to it so far using
the *note digest(): 2a20. or *note hexdigest(): 2a21. methods.

To allow multithreading, the Python *note GIL: 13f. is released while
computing a hash supplied more than 2047 bytes of data at once in its
constructor or *note .update: 2a1f. method.

Constructors for hash algorithms that are always present in this module
are *note sha1(): 2a22, *note sha224(): 2a23, *note sha256(): 2a1e,
*note sha384(): 2a24, *note sha512(): 2a25, *note sha3_224(): c70, *note
sha3_256(): c71, *note sha3_384(): c72, *note sha3_512(): c73, *note
shake_128(): c74, *note shake_256(): c75, *note blake2b(): 60e, and
*note blake2s(): 60f.  *note md5(): 2a26. is normally available as well,
though it may be missing or blocked if you are using a rare "FIPS
compliant" build of Python.  These correspond to *note
algorithms_guaranteed: 133b.

Additional algorithms may also be available if your Python
distribution's *note hashlib: 5e. 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 *note new(): 18b1.
See *note algorithms_available: 133c.

     警告: Some algorithms have known hash collision weaknesses
     (including MD5 and SHA1).  Refer to Attacks on cryptographic hash
     algorithms(1) and the *note hashlib-seealso: 2a27. section at the
     end of this document.

Added in version 3.6: SHA3 (Keccak) and SHAKE constructors *note
sha3_224(): c70, *note sha3_256(): c71, *note sha3_384(): c72, *note
sha3_512(): c73, *note shake_128(): c74, *note shake_256(): c75. were
added.  *note blake2b(): 60e. and *note blake2s(): 60f. were added.

バージョン 3.9 で変更: All hashlib constructors take a keyword-only
argument 'usedforsecurity' with default value ‘True’.  A false value
allows the use of insecure and blocked hashing algorithms in restricted
environments.  ‘False’ indicates that the hashing algorithm is not used
in a security context, e.g.  as a non-cryptographic one-way compression
function.

バージョン 3.9 で変更: Hashlib now uses SHA3 and SHAKE from OpenSSL if
it provides it.

バージョン 3.12 で変更: 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(2).

   ---------- Footnotes ----------

   (1) 
https://en.wikipedia.org/wiki/Cryptographic_hash_function#Attacks_on_cryptographic_hash_algorithms

   (2) https://github.com/hacl-star/hacl-star


File: python.info,  Node: 使用法,  Next: Constructors,  Prev: ハッシュアルゴリズム,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.2 使用法
...............

To obtain the digest of the byte string ‘b"Nobody inspects the spammish
repetition"’:

     >>> import hashlib
     >>> m = hashlib.sha256()
     >>> m.update(b"Nobody inspects")
     >>> m.update(b" the spammish repetition")
     >>> m.digest()
     b'\x03\x1e\xdd}Ae\x15\x93\xc5\xfe\\\x00o\xa5u+7\xfd\xdf\xf7\xbcN\x84:\xa6\xaf\x0c\x95\x0fK\x94\x06'
     >>> m.hexdigest()
     '031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'

もっと簡潔に書くと、このようになります:

     >>> hashlib.sha256(b"Nobody inspects the spammish repetition").hexdigest()
     '031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'


File: python.info,  Node: Constructors,  Next: 属性,  Prev: 使用法,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.3 Constructors
.....................

 -- の関数: hashlib.new (name[, data], *, usedforsecurity=True)

     Is a generic constructor that takes the string 'name' of the
     desired algorithm as its first parameter.  It also exists to allow
     access to the above listed hashes as well as any other algorithms
     that your OpenSSL library may offer.

Using *note new(): 18b1. with an algorithm name:

     >>> h = hashlib.new('sha256')
     >>> h.update(b"Nobody inspects the spammish repetition")
     >>> h.hexdigest()
     '031edd7d41651593c5fe5c006fa5752b37fddff7bc4e843aa6af0c950f4b9406'

 -- の関数: hashlib.md5 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha1 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha224 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha256 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha384 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha512 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha3_224 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha3_256 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha3_384 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.sha3_512 ([data], *, usedforsecurity=True)

Named constructors such as these are faster than passing an algorithm
name to *note new(): 18b1.


File: python.info,  Node: 属性,  Next: Hash Objects,  Prev: Constructors,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.4 属性
.............

Hashlib provides the following constant module attributes:

 -- データ: hashlib.algorithms_guaranteed

     このモジュールによってすべてのプラットフォームでサポートされている
     ことが保証されるハッシュアルゴリズムの名前を含む集合です。一部のア
     ップストリームのベンダーが提供する奇妙な "FIPS準拠の" Pythonビルド
     ではmd5のサポートを除外していますが、その場合であっても 'md5' がリ
     ストに含まれることに注意してください。

     Added in version 3.2.

 -- データ: hashlib.algorithms_available

     実行中の Python インタープリタで利用可能なハッシュアルゴリズム名の
     set です。これらの名前は *note new(): 18b1. に渡すことができます。
     *note algorithms_guaranteed: 133b. は常にサブセットです。この set の
     中に同じアルゴリズムが違う名前で複数回現れることがあります (OpenSSL
     由来)。

     Added in version 3.2.


File: python.info,  Node: Hash Objects,  Next: SHAKE 可変長ダイジェスト,  Prev: 属性,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.5 Hash Objects
.....................

コンストラクタが返すハッシュオブジェクトには、次のような定数属性が用意さ
れています:

 -- データ: hash.digest_size

     生成されたハッシュのバイト数。

 -- データ: hash.block_size

     内部で使われるハッシュアルゴリズムのブロックのバイト数。

ハッシュオブジェクトには次のような属性があります:

 -- の属性: hash.name

     このハッシュの正規名です。常に小文字で、*note new(): 18b1. の引数と
     して渡してこのタイプの別のハッシュを生成することができます。

     バージョン 3.4 で変更: name 属性は CPython には最初からありましたが
     、Python 3.4 までは正式に明記されていませんでした。そのため、プラッ
     トフォームによっては存在しないかもしれません。

ハッシュオブジェクトには次のようなメソッドがあります:

 -- メソッド: hash.update (data)

     hash オブジェクトを *note bytes-like object: cfb. で更新します。こ
     のメソッドの呼出しの繰り返しは、それらの引数を全て結合した引数で単
     一の呼び出しをした際と同じになります。すなわち ‘m.update(a);
     m.update(b)’ は ‘m.update(a + b)’ と等価です。

 -- メソッド: hash.digest ()

     これまで *note update(): 2a1f. メソッドに渡されたデータのダイジェス
     ト値を返します。これは *note digest_size: 2a2d. と同じ長さの、0 か
     ら 255 の範囲全てを含み得るバイトの列です。

 -- メソッド: hash.hexdigest ()

     *note digest(): 2a20. と似ていますが、倍の長さの、16進形式文字列を
     返します。これは、電子メールなどの非バイナリ環境で値を交換する場合
     に便利です。

 -- メソッド: hash.copy ()

     ハッシュオブジェクトのコピー ("クローン") を返します。これは、最初
     の部分文字列が共通なデータのダイジェストを効率的に計算するために使
     用します。


File: python.info,  Node: SHAKE 可変長ダイジェスト,  Next: File hashing,  Prev: Hash Objects,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.6 SHAKE 可変長ダイジェスト
.................................

 -- の関数: hashlib.shake_128 ([data], *, usedforsecurity=True)

 -- の関数: hashlib.shake_256 ([data], *, usedforsecurity=True)

The *note shake_128(): c74. and *note shake_256(): c75. 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.

 -- メソッド: shake.digest (length)

     Return the digest of the data passed to the *note update(): 2a1f.
     method so far.  This is a bytes object of size 'length' which may
     contain bytes in the whole range from 0 to 255.

 -- メソッド: shake.hexdigest (length)

     Like *note digest(): 19a4. except the digest is returned as a
     string object of double length, containing only hexadecimal digits.
     This may be used to exchange the value in email or other non-binary
     environments.

Example use:

     >>> h = hashlib.shake_256(b'Nobody inspects the spammish repetition')
     >>> h.hexdigest(20)
     '44709d6fcb83d92a76dcb0b668c98e1b1d3dafe7'


File: python.info,  Node: File hashing,  Next: 鍵導出,  Prev: SHAKE 可変長ダイジェスト,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.7 File hashing
.....................

The hashlib module provides a helper function for efficient hashing of a
file or file-like object.

 -- の関数: hashlib.file_digest (fileobj, digest, /)

     Return a digest object that has been updated with contents of file
     object.

     'fileobj' must be a file-like object opened for reading in binary
     mode.  It accepts file objects from builtin *note open(): 4e5,
     *note BytesIO: e6d. instances, SocketIO objects from *note
     socket.socket.makefile(): 1170, and similar.  The function may
     bypass Python's I/O and use the file descriptor from *note
     fileno(): 27a6. 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'.

     'digest' must either be a hash algorithm name as a 'str', a hash
     constructor, or a callable that returns a hash object.

     例:

          >>> import io, hashlib, hmac
          >>> with open(hashlib.__file__, "rb") as f:
          ...     digest = hashlib.file_digest(f, "sha256")
          ...
          >>> digest.hexdigest()
          '...'

          >>> buf = io.BytesIO(b"somedata")
          >>> mac1 = hmac.HMAC(b"key", digestmod=hashlib.sha512)
          >>> digest = hashlib.file_digest(buf, lambda: mac1)

          >>> digest is mac1
          True
          >>> mac2 = hmac.HMAC(b"key", b"somedata", digestmod=hashlib.sha512)
          >>> mac1.digest() == mac2.digest()
          True

     Added in version 3.11.


File: python.info,  Node: 鍵導出,  Next: BLAKE2,  Prev: File hashing,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.8 鍵導出
...............

鍵の導出 (derivation) と引き伸ばし (stretching) のアルゴリズムはセキュア
なパスワードのハッシュ化のために設計されました。 ‘sha1(password)’ のよう
な甘いアルゴリズムは、ブルートフォース攻撃に抵抗できません。良いパスワー
ドハッシュ化は調節可能で、遅くて、 salt(1) を含まなければなりません。

 -- の関数: hashlib.pbkdf2_hmac (hash_name, password, salt, iterations,
          dklen=None)

     この関数は PKCS#5 のパスワードに基づいた鍵導出関数 2 を提供していま
     す。疑似乱数関数として HMAC を使用しています。

     文字列 'hash_name' は、HMAC のハッシュダイジェストアルゴリズムの望
     ましい名前で、例えば 'sha1' や 'sha256' です。 'password' と 'salt'
     はバイト列のバッファとして解釈されます。アプリケーションとライブラ
     リは、 'password' を適切な長さ (例えば 1024) に制限すべきです。
     'salt' は *note os.urandom(): 4ec. のような適切なソースからの、およ
     そ 16 バイトかそれ以上のバイト列にするべきです。

     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 are suggested.  For rationale as to why
     and how to choose what is best for your application, read 'Appendix
     A.2.2' of NIST-SP-800-132(2).  The answers on the stackexchange
     pbkdf2 iterations question(3) explain in detail.

     'dklen' is the length of the derived key in bytes.  If 'dklen' is
     ‘None’ then the digest size of the hash algorithm 'hash_name' is
     used, e.g.  64 for SHA-512.

          >>> from hashlib import pbkdf2_hmac
          >>> our_app_iters = 500_000  # Application specific, read above.
          >>> dk = pbkdf2_hmac('sha256', b'password', b'bad salt' * 2, our_app_iters)
          >>> dk.hex()
          '15530bba69924174860db778f2c6f8104d3aaf9d26241840c8c4a641c8d000a9'

     Function only available when Python is compiled with OpenSSL.

     Added in version 3.4.

     バージョン 3.12 で変更: Function now only available when Python is
     built with OpenSSL. The slow pure Python implementation has been
     removed.

 -- の関数: hashlib.scrypt (password, *, salt, n, r, p, maxmem=0,
          dklen=64)

     この関数は、 RFC 7914(4) で定義されるscrypt のパスワードに基づいた
     鍵導出関数を提供します。

     'password' と 'salt' は *note bytes-like object: cfb. でなければな
     りません。アプリケーションとライブラリは、 'password' を適切な長さ
     (例えば 1024) に制限すべきです。 'salt' は *note os.urandom(): 4ec.
     のような適切なソースからの、およそ 16 バイトかそれ以上のバイト列に
     するべきです。

     '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.

     Added in version 3.6.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Salt_%28cryptography%29

   (2) 
https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf

   (3) 
https://security.stackexchange.com/questions/3959/recommended-of-iterations-when-using-pbkdf2-sha256/

   (4) https://datatracker.ietf.org/doc/html/rfc7914.html


File: python.info,  Node: BLAKE2,  Prev: 鍵導出,  Up: hashlib --- セキュアハッシュとメッセージダイジェスト

5.15.1.9 BLAKE2
...............

BLAKE2(1) is a cryptographic hash function defined in RFC 7693(2) that
comes in two flavors:

   * 'BLAKE2b', optimized for 64-bit platforms and produces digests of
     any size between 1 and 64 bytes,

   * 'BLAKE2s', optimized for 8- to 32-bit platforms and produces
     digests of any size between 1 and 32 bytes.

BLAKE2 supports 'keyed mode' (a faster and simpler replacement for
HMAC(3)), 'salted hashing', 'personalization', and 'tree hashing'.

このモジュールのハッシュオブジェクトは標準ライブラリーの *note hashlib:
5e. オブジェクトの API に従います。

* Menu:

* ハッシュオブジェクトの作成::
* 定数: 定数<5>.
* 使用例: 使用例<19>.
* クレジット;: クレジット.

   ---------- Footnotes ----------

   (1) https://www.blake2.net

   (2) https://datatracker.ietf.org/doc/html/rfc7693.html

   (3) 
https://en.wikipedia.org/wiki/Hash-based_message_authentication_code


File: python.info,  Node: ハッシュオブジェクトの作成,  Next: 定数<5>,  Up: BLAKE2

5.15.1.10 ハッシュオブジェクトの作成
....................................

新しいハッシュオブジェクトは、コンストラクタ関数を呼び出すことで生成され
ます:

 -- の関数: hashlib.blake2b (data=b'', *, digest_size=64, key=b'',
          salt=b'', person=b'', fanout=1, depth=1, leaf_size=0,
          node_offset=0, node_depth=0, inner_size=0, last_node=False,
          usedforsecurity=True)

 -- の関数: hashlib.blake2s (data=b'', *, digest_size=32, key=b'',
          salt=b'', person=b'', fanout=1, depth=1, leaf_size=0,
          node_offset=0, node_depth=0, inner_size=0, last_node=False,
          usedforsecurity=True)

These functions return the corresponding hash objects for calculating
BLAKE2b or BLAKE2s.  They optionally take these general parameters:

   * 'data': initial chunk of data to hash, which must be *note
     bytes-like object: cfb.  It can be passed only as positional
     argument.

   * 'digest_size': 出力するダイジェストのバイト数。

   * 'key': key for keyed hashing (up to 64 bytes for BLAKE2b, up to 32
     bytes for BLAKE2s).

   * 'salt': salt for randomized hashing (up to 16 bytes for BLAKE2b, up
     to 8 bytes for BLAKE2s).

   * 'person': personalization string (up to 16 bytes for BLAKE2b, up to
     8 bytes for BLAKE2s).

下の表は一般的なパラメータの上限 (バイト単位) です:

Hash        digest_size     len(key)     len(salt)     len(person)
                                                       
-----------------------------------------------------------------------
                                                       
BLAKE2b     64              64           16            16
                                                       
                                                       
BLAKE2s     32              32           8             8
                                                       

     注釈: BLAKE2 specification defines constant lengths for salt and
     personalization parameters, however, for convenience, this
     implementation accepts byte strings of any size up to the specified
     length.  If the length of the parameter is less than specified, it
     is padded with zeros, thus, for example, ‘b'salt'’ and
     ‘b'salt\x00'’ is the same value.  (This is not the case for 'key'.)

これらのサイズは以下に述べるモジュール *note constants: 2a35. で利用でき
ます。

コンストラクタ関数は以下のツリーハッシングパラメタを受け付けます:

   * 'fanout': fanout (0 to 255, 0 if unlimited, 1 in sequential mode).

   * 'depth': ツリーの深さの最大値（1から255までの値で、無制限であれば
     255、シーケンスモードでは1）。

   * 'leaf_size': maximal byte length of leaf (0 to ‘2**32-1’, 0 if
     unlimited or in sequential mode).

   * '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).

   * 'node_depth': node depth (0 to 255, 0 for leaves, or in sequential
     mode).

   * 'inner_size': inner digest size (0 to 64 for BLAKE2b, 0 to 32 for
     BLAKE2s, 0 in sequential mode).

   * 'last_node': boolean indicating whether the processed node is the
     last one (‘False’ for sequential mode).

[image src="python-figures/hashlib-blake2-tree.png" alt="Explanation of tree mode parameters."]


Figure
See section 2.10 in BLAKE2 specification(1) for comprehensive review of
tree hashing.

   ---------- Footnotes ----------

   (1) https://www.blake2.net/blake2_20130129.pdf


File: python.info,  Node: 定数<5>,  Next: 使用例<19>,  Prev: ハッシュオブジェクトの作成,  Up: BLAKE2

5.15.1.11 定数
..............

 -- データ: blake2b.SALT_SIZE

 -- データ: blake2s.SALT_SIZE

ソルト長（コンストラクタが受け付けれる最大長）

 -- データ: blake2b.PERSON_SIZE

 -- データ: blake2s.PERSON_SIZE

Personalization string length (maximum length accepted by constructors).

 -- データ: blake2b.MAX_KEY_SIZE

 -- データ: blake2s.MAX_KEY_SIZE

最大キー長

 -- データ: blake2b.MAX_DIGEST_SIZE

 -- データ: blake2s.MAX_DIGEST_SIZE

ハッシュ関数が出力しうるダイジェストの最大長


File: python.info,  Node: 使用例<19>,  Next: クレジット,  Prev: 定数<5>,  Up: BLAKE2

5.15.1.12 使用例
................

* Menu:

* 簡単なハッシュ化::
* Using different digest sizes::
* Keyed hashing::
* Randomized hashing::
* Personalization::
* ツリーモード::


File: python.info,  Node: 簡単なハッシュ化,  Next: Using different digest sizes,  Up: 使用例<19>

5.15.1.13 簡単なハッシュ化
..........................

To calculate hash of some data, you should first construct a hash object
by calling the appropriate constructor function (*note blake2b(): 60e.
or *note blake2s(): 60f.), then update it with the data by calling *note
update(): 2a1f. on the object, and, finally, get the digest out of the
object by calling *note digest(): 2a20. (or *note hexdigest(): 2a21. for
hex-encoded string).

     >>> from hashlib import blake2b
     >>> h = blake2b()
     >>> h.update(b'Hello world')
     >>> h.hexdigest()
     '6ff843ba685842aa82031d3f53c48b66326df7639a63d128974c5c14f31a0f33343a8c65551134ed1ae0f2b0dd2bb495dc81039e3eeb0aa1bb0388bbeac29183'

As a shortcut, you can pass the first chunk of data to update directly
to the constructor as the positional argument:

     >>> from hashlib import blake2b
     >>> blake2b(b'Hello world').hexdigest()
     '6ff843ba685842aa82031d3f53c48b66326df7639a63d128974c5c14f31a0f33343a8c65551134ed1ae0f2b0dd2bb495dc81039e3eeb0aa1bb0388bbeac29183'

You can call *note hash.update(): 2a1f. as many times as you need to
iteratively update the hash:

     >>> from hashlib import blake2b
     >>> items = [b'Hello', b' ', b'world']
     >>> h = blake2b()
     >>> for item in items:
     ...     h.update(item)
     ...
     >>> h.hexdigest()
     '6ff843ba685842aa82031d3f53c48b66326df7639a63d128974c5c14f31a0f33343a8c65551134ed1ae0f2b0dd2bb495dc81039e3eeb0aa1bb0388bbeac29183'


File: python.info,  Node: Using different digest sizes,  Next: Keyed hashing,  Prev: 簡単なハッシュ化,  Up: 使用例<19>

5.15.1.14 Using different digest sizes
......................................

BLAKE2 はダイジェストの長さを、BLAKE2bでは64バイトまで、BLAKE2sでは32バ
イトまでのダイジェスト長を指定できます。例えばSHA-1を、出力を同じ長さの
ままでBLAKE2bで置き換えるには、BLAKE2bに20バイトのダイジェストを生成する
ように指示できます:

     >>> from hashlib import blake2b
     >>> h = blake2b(digest_size=20)
     >>> h.update(b'Replacing SHA1 with the more secure function')
     >>> h.hexdigest()
     'd24f26cf8de66472d58d4e1b1774b4c9158b1f4c'
     >>> h.digest_size
     20
     >>> len(h.digest())
     20

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:

     >>> from hashlib import blake2b, blake2s
     >>> blake2b(digest_size=10).hexdigest()
     '6fa1d8fcfd719046d762'
     >>> blake2b(digest_size=11).hexdigest()
     'eb6ec15daf9546254f0809'
     >>> blake2s(digest_size=10).hexdigest()
     '1bf21a98c78a1c376ae9'
     >>> blake2s(digest_size=11).hexdigest()
     '567004bf96e4a25773ebf4'


File: python.info,  Node: Keyed hashing,  Next: Randomized hashing,  Prev: Using different digest sizes,  Up: 使用例<19>

5.15.1.15 Keyed hashing
.......................

Keyed hashing can be used for authentication as a faster and simpler
replacement for Hash-based message authentication code(1) (HMAC). BLAKE2
can be securely used in prefix-MAC mode thanks to the
indifferentiability property inherited from BLAKE.

This example shows how to get a (hex-encoded) 128-bit authentication
code for message ‘b'message data'’ with key ‘b'pseudorandom key'’:

     >>> from hashlib import blake2b
     >>> h = blake2b(key=b'pseudorandom key', digest_size=16)
     >>> h.update(b'message data')
     >>> h.hexdigest()
     '3d363ff7401e02026f4a4687d4863ced'

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:

     >>> from hashlib import blake2b
     >>> from hmac import compare_digest
     >>>
     >>> SECRET_KEY = b'pseudorandomly generated server secret key'
     >>> AUTH_SIZE = 16
     >>>
     >>> def sign(cookie):
     ...     h = blake2b(digest_size=AUTH_SIZE, key=SECRET_KEY)
     ...     h.update(cookie)
     ...     return h.hexdigest().encode('utf-8')
     >>>
     >>> def verify(cookie, sig):
     ...     good_sig = sign(cookie)
     ...     return compare_digest(good_sig, sig)
     >>>
     >>> cookie = b'user-alice'
     >>> sig = sign(cookie)
     >>> print("{0},{1}".format(cookie.decode('utf-8'), sig))
     user-alice,b'43b3c982cf697e0c5ab22172d1ca7421'
     >>> verify(cookie, sig)
     True
     >>> verify(b'user-bob', sig)
     False
     >>> verify(cookie, b'0102030405060708090a0b0c0d0e0f00')
     False

Even though there's a native keyed hashing mode, BLAKE2 can, of course,
be used in HMAC construction with *note hmac: 60. module:

     >>> import hmac, hashlib
     >>> m = hmac.new(b'secret key', digestmod=hashlib.blake2s)
     >>> m.update(b'message')
     >>> m.hexdigest()
     'e3c8102868d28b5ff85fc35dda07329970d1a01e273c37481326fe0c861c8142'

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/HMAC


File: python.info,  Node: Randomized hashing,  Next: Personalization,  Prev: Keyed hashing,  Up: 使用例<19>

5.15.1.16 Randomized hashing
............................

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.

     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, the message signer.  If the message preparer is
     able to find cryptographic hash function collisions (i.e., two
     messages producing the same hash value), then they might prepare
     meaningful versions of the message that would produce the same hash
     value and digital signature, but with different results (e.g.,
     transferring $1,000,000 to an account, rather than $10).
     Cryptographic hash functions have been designed with collision
     resistance as a major goal, but the current concentration on
     attacking cryptographic hash functions may result in a given
     cryptographic hash function providing less collision resistance
     than expected.  Randomized hashing offers the signer additional
     protection by reducing the likelihood that a preparer can generate
     two or more messages that ultimately yield the same hash value
     during the digital signature generation process -- even if it is
     practical to find collisions for the hash function.  However, the
     use of randomized hashing may reduce the amount of security
     provided by a digital signature when all portions of the message
     are prepared by the signer.

     (NIST SP-800-106 "Randomized Hashing for Digital Signatures"(1))

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.

     警告: '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(2) for more
     information.

     >>> import os
     >>> from hashlib import blake2b
     >>> msg = b'some message'
     >>> # Calculate the first hash with a random salt.
     >>> salt1 = os.urandom(blake2b.SALT_SIZE)
     >>> h1 = blake2b(salt=salt1)
     >>> h1.update(msg)
     >>> # Calculate the second hash with a different random salt.
     >>> salt2 = os.urandom(blake2b.SALT_SIZE)
     >>> h2 = blake2b(salt=salt2)
     >>> h2.update(msg)
     >>> # The digests are different.
     >>> h1.digest() != h2.digest()
     True

   ---------- Footnotes ----------

   (1) https://csrc.nist.gov/pubs/sp/800/106/final

   (2) https://www.blake2.net/#qa


File: python.info,  Node: Personalization,  Next: ツリーモード,  Prev: Randomized hashing,  Up: 使用例<19>

5.15.1.17 Personalization
.........................

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:

     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 protocol can be used in an entirely
     different part because two hash computations were done on similar
     or related data, and the attacker can force the application to make
     the hash inputs the same.  Personalizing each hash function used in
     the protocol summarily stops this type of attack.

     (The Skein Hash Function Family(1), p.  21)

BLAKE2は 'person' 引数にバイト列を渡すことでパーソナライズできます:

     >>> from hashlib import blake2b
     >>> FILES_HASH_PERSON = b'MyApp Files Hash'
     >>> BLOCK_HASH_PERSON = b'MyApp Block Hash'
     >>> h = blake2b(digest_size=32, person=FILES_HASH_PERSON)
     >>> h.update(b'the same content')
     >>> h.hexdigest()
     '20d9cd024d4fb086aae819a1432dd2466de12947831b75c5a30cf2676095d3b4'
     >>> h = blake2b(digest_size=32, person=BLOCK_HASH_PERSON)
     >>> h.update(b'the same content')
     >>> h.hexdigest()
     'cf68fb5761b9c44e7878bfb2c4c9aea52264a80b75005e65619778de59f383a3'

Personalization together with the keyed mode can also be used to derive
different keys from a single one.

     >>> from hashlib import blake2s
     >>> from base64 import b64decode, b64encode
     >>> orig_key = b64decode(b'Rm5EPJai72qcK3RGBpW3vPNfZy5OZothY+kHY6h21KM=')
     >>> enc_key = blake2s(key=orig_key, person=b'kEncrypt').digest()
     >>> mac_key = blake2s(key=orig_key, person=b'kMAC').digest()
     >>> print(b64encode(enc_key).decode('utf-8'))
     rbPb15S/Z9t+agffno5wuhB77VbRi6F9Iv2qIxU7WHw=
     >>> print(b64encode(mac_key).decode('utf-8'))
     G9GtHFE1YluXY1zWPlYk1e/nWfu0WSEb0KRcjhDeP/o=

   ---------- Footnotes ----------

   (1) https://www.schneier.com/wp-content/uploads/2016/02/skein.pdf


File: python.info,  Node: ツリーモード,  Prev: Personalization,  Up: 使用例<19>

5.15.1.18 ツリーモード
......................

これが二つの葉ノードからなる最小の木をハッシュする例です:

       10
      /  \
     00  01

次の例では、64バイトの内部桁が使われ、32バイトの最終的なダイジェストを返
しています:

     >>> from hashlib import blake2b
     >>>
     >>> FANOUT = 2
     >>> DEPTH = 2
     >>> LEAF_SIZE = 4096
     >>> INNER_SIZE = 64
     >>>
     >>> buf = bytearray(6000)
     >>>
     >>> # Left leaf
     ... h00 = blake2b(buf[0:LEAF_SIZE], fanout=FANOUT, depth=DEPTH,
     ...               leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,
     ...               node_offset=0, node_depth=0, last_node=False)
     >>> # Right leaf
     ... h01 = blake2b(buf[LEAF_SIZE:], fanout=FANOUT, depth=DEPTH,
     ...               leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,
     ...               node_offset=1, node_depth=0, last_node=True)
     >>> # Root node
     ... h10 = blake2b(digest_size=32, fanout=FANOUT, depth=DEPTH,
     ...               leaf_size=LEAF_SIZE, inner_size=INNER_SIZE,
     ...               node_offset=0, node_depth=1, last_node=True)
     >>> h10.update(h00.digest())
     >>> h10.update(h01.digest())
     >>> h10.hexdigest()
     '3ad2a9b37c6070e374c7a8c508fe20ca86b6ed54e286e93a0318e95e881db5aa'


File: python.info,  Node: クレジット,  Prev: 使用例<19>,  Up: BLAKE2

5.15.1.19 クレジット:
.....................

BLAKE2(1) は*Jean-Philippe Aumasson*、 'Luca Henzen'、 'Willi Meier' そ
して 'Raphael C.-W. Phan' によって作成された SHA-3(2) の最終候補である
BLAKE(3) を元に、'Jean-Philippe Aumasson'、 'Samuel Neves'、 'Zooko
Wilcox-O'Hearn', そして 'Christian Winnerlein' によって設計されました。

それは、 'Daniel J. Bernstein' によって設計されたChaCha(4) 暗号由来のア
ルゴリズムを用いています。

標準ライブラリは pyblake2(5) モジュールを基礎として実装されています。 こ
のモジュールは 'Dmitry Chestnykh' によって、'Samuel Neves' が作成した C実
装を元に書かれました。 このドキュメントは、pyblake2(6) からコピーされ、
'Dmitry Chestnykh' によって書かれました。

'Christian Heimes' によって、一部のCコードがPython向けに書き直されました
。

以下の public domain dedicationが、Cのハッシュ関数実装と、拡張コードと、
このドキュメントに適用されます:

     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.

     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/’.

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:

   * 'Alexandr Sokolovskiy'

参考
....

*note hmac: 60. モジュール

     ハッシュを用いてメッセージ認証コードを生成するモジュールです。

*note base64: a. モジュール

     バイナリハッシュを非バイナリ環境用にエンコードするもうひとつの方法
     です。

‘https://nvlpubs.nist.gov/nistpubs/fips/nist.fips.180-4.pdf’

     The FIPS 180-4 publication on Secure Hash Algorithms.

‘https://csrc.nist.gov/pubs/fips/202/final’

     The FIPS 202 publication on the SHA-3 Standard.

‘https://www.blake2.net/’

     BLAKE2 の公式ウェブサイト

‘https://en.wikipedia.org/wiki/Cryptographic_hash_function’

     どのアルゴリズムにどんな既知の問題があって、それが実際に利用する際
     にどう影響するかについての Wikipedia の記事。

‘https://www.ietf.org/rfc/rfc8018.txt’

     PKCS #5: Password-Based Cryptography Specification Version 2.1

‘https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf’

     NIST Recommendation for Password-Based Key Derivation.

   ---------- Footnotes ----------

   (1) https://www.blake2.net

   (2) https://en.wikipedia.org/wiki/Secure_Hash_Algorithms

   (3) 
https://web.archive.org/web/20200918190133/https://131002.net/blake/

   (4) https://cr.yp.to/chacha.html

   (5) https://pythonhosted.org/pyblake2/

   (6) https://pythonhosted.org/pyblake2/


File: python.info,  Node: hmac --- メッセージ認証のための鍵付きハッシュ化,  Next: secrets --- 機密を扱うために安全な乱数を生成する,  Prev: hashlib --- セキュアハッシュとメッセージダイジェスト,  Up: 暗号関連のサービス

5.15.2 ‘hmac’ -- メッセージ認証のための鍵付きハッシュ化
-------------------------------------------------------

'ソースコード:' Lib/hmac.py(1)

__________________________________________________________________

このモジュールでは RFC 2104(2) で記述されている HMAC アルゴリズムを実装
しています。

 -- の関数: hmac.new (key, msg=None, digestmod)

     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.  'digestmod' is the digest name, digest
     constructor or module for the HMAC object to use.  It may be any
     name suitable to *note hashlib.new(): 18b1.  Despite its argument
     position, it is required.

     バージョン 3.4 で変更: 引数 'key' に bytes または bytearray オブジ
     ェクトを渡せるようになりました。引数 'msg' に *note hashlib: 5e. が
     サポートする全てのタイプを渡せるようになりました。引数 'digestmod'
     にハッシュアルゴリズム名を渡せるようになりました。

     バージョン 3.8 で変更: The 'digestmod' argument is now required.
     Pass it as a keyword argument to avoid awkwardness when you do not
     have an initial 'msg'.

 -- の関数: hmac.digest (key, msg, digest)

     与えられたsecret 'key' と 'digest' の 'msg' のダイジェストを返しま
     す。この関数は ‘HMAC(key, msg, digest).digest()’ に似ていますが、最
     適化されたCやインラインの実装を使用しており、メモリに収まるメッセー
     ジに対しては高速です。パラメータ 'key' 、 'msg' 、および 'digest' は
     、 *note new(): a6d. と同じ意味を持ちます。

     CPython実装の詳細、最適化されたC実装は、OpenSSLがサポートするダイジ
     ェストアルゴリズムの文字列と名前が 'digest' の場合にのみ使用されま
     す。

     Added in version 3.7.

HMAC オブジェクトは以下のメソッドを持っています:

 -- メソッド: HMAC.update (msg)

     hmac オブジェクトを 'msg' で更新します。このメソッドの呼出の繰り返
     しは、それらの引数を全て結合した引数で単一の呼び出しをした際と同じ
     になります。すなわち ‘m.update(a); m.update(b)’ は ‘m.update(a +
     b)’ と等価です。

     バージョン 3.4 で変更: 引数 'msg' は *note hashlib: 5e. がサポート
     しているあらゆる型のいずれかです。

 -- メソッド: HMAC.digest ()

     これまで *note update(): f17. メソッドに渡されたバイト列のダイジェ
     スト値を返します。これはコンストラクタに与えられた 'digest_size' と
     同じ長さのバイト列で、 NUL バイトを含む非 ASCII 文字が含まれること
     があります。

          警告: When comparing the output of *note digest(): b0c. to an
          externally supplied digest during a verification routine, it
          is recommended to use the *note compare_digest(): 109c.
          function instead of the ‘==’ operator to reduce the
          vulnerability to timing attacks.

 -- メソッド: HMAC.hexdigest ()

     *note digest(): b0c. と似ていますが、返される文字列は倍の長さとなり
     、16進形式となります。これは、電子メールなどの非バイナリ環境で値を
     交換する場合に便利です。

          警告: When comparing the output of *note hexdigest(): 2a49. to
          an externally supplied digest during a verification routine,
          it is recommended to use the *note compare_digest(): 109c.
          function instead of the ‘==’ operator to reduce the
          vulnerability to timing attacks.

 -- メソッド: HMAC.copy ()

     hmac オブジェクトのコピー ("クローン") を返します。このコピーは最初
     の部分文字列が共通になっている文字列のダイジェスト値を効率よく計算
     するために使うことができます。

ハッシュオブジェクトには次のような属性があります:

 -- の属性: HMAC.digest_size

     生成された HMAC ダイジェストのバイト数。

 -- の属性: HMAC.block_size

     内部で使われるハッシュアルゴリズムのブロックのバイト数。

     Added in version 3.4.

 -- の属性: HMAC.name

     このHMAC の正規名で、例えば ‘hmac-md5’ のように常に小文字です。

     Added in version 3.4.

バージョン 3.10 で変更: Removed the undocumented attributes
‘HMAC.digest_cons’, ‘HMAC.inner’, and ‘HMAC.outer’.

このモジュールは以下のヘルパ関数も提供しています:

 -- の関数: hmac.compare_digest (a, b)

     ‘a == b’ を返します。この関数は、内容ベースの短絡的な振る舞いを避け
     ることによってタイミング分析を防ぐよう設計されたアプローチを用い、
     暗号化に用いるのに相応しいものとしています。 'a' と 'b' は両方が同
     じ型でなければなりません: (例えば *note HMAC.hexdigest(): 2a49. が
     返したような ASCII のみの) *note str: 418. または *note bytes-like
     object: cfb. のどちらか一方。

          注釈: 'a' と 'b' が異なる長さであったりエラーが発生した場合に
          は、タイミング攻撃で理論上 'a' と 'b' の型と長さについての情報
          が暴露されますが、その値は明らかになりません。

     Added in version 3.3.

     バージョン 3.10 で変更: The function uses OpenSSL's
     ‘CRYPTO_memcmp()’ internally when available.

参考
....

*note hashlib: 5e. モジュール

     セキュアハッシュ関数を提供する Python モジュールです。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/hmac.py

   (2) https://datatracker.ietf.org/doc/html/rfc2104.html


File: python.info,  Node: secrets --- 機密を扱うために安全な乱数を生成する,  Prev: hmac --- メッセージ認証のための鍵付きハッシュ化,  Up: 暗号関連のサービス

5.15.3 ‘secrets’ -- 機密を扱うために安全な乱数を生成する
--------------------------------------------------------

Added in version 3.6.

'ソースコード:' Lib/secrets.py(1)

__________________________________________________________________

*note secrets: ae. モジュールを使って、パスワードやアカウント認証、セキ
ュリティトークンなどの機密を扱うのに適した、暗号学的に強い乱数を生成する
ことができます。

特に、 *note random: a6. モジュールのデフォルトの擬似乱数ジェネレータよ
りも *note secrets: ae. を使用するべきです。 *note random: a6. モジュー
ルはモデル化やシミュレーション向けで、セキュリティや暗号学的に設計されて
はいません。

参考
....

PEP 506(2)

* Menu:

* 乱数::
* トークンの生成::
* その他の関数::
* レシピとベストプラクティス::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/secrets.py

   (2) https://peps.python.org/pep-0506/


File: python.info,  Node: 乱数,  Next: トークンの生成,  Up: secrets --- 機密を扱うために安全な乱数を生成する

5.15.3.1 乱数
.............

*note secrets: ae. モジュールは OS が提供する最も安全な乱雑性のソースへ
のアクセスを提供します。

 -- クラス: secrets.SystemRandom

     OS が提供する最も高品質なソースを用いて乱数を生成するためのクラスで
     す。更に詳しいことについては *note random.SystemRandom: 2630. を参
     照してください。

 -- の関数: secrets.choice (seq)

     空でないシーケンスから要素をランダムに選択して返します。

 -- の関数: secrets.randbelow (exclusive_upper_bound)

     [0, 'exclusive_upper_bound') の範囲のランダムな整数を返します。

 -- の関数: secrets.randbits (k)

     Return a non-negative int with 'k' random bits.


File: python.info,  Node: トークンの生成,  Next: その他の関数,  Prev: 乱数,  Up: secrets --- 機密を扱うために安全な乱数を生成する

5.15.3.2 トークンの生成
.......................

*note secrets: ae. モジュールはパスワードのリセットや想像しにくい URL な
どの用途に適した、安全なトークンを生成するための関数を提供します。

 -- の関数: secrets.token_bytes ([nbytes=None])

     'nbytes' バイトを含むバイト文字列を返します。'nbytes' が ‘None’ の
     場合や与えられなかった場合は妥当なデフォルト値が使われます。

          >>> token_bytes(16)
          b'\xebr\x17D*t\xae\xd4\xe3S\xb6\xe2\xebP1\x8b'

 -- の関数: secrets.token_hex ([nbytes=None])

     十六進数のランダムなテキスト文字列を返します。文字列は 'nbytes' の
     ランダムなバイトを持ち、各バイトは二つの十六進数に変換されます。
     'nbytes' が ‘None’ の場合や与えられなかった場合は妥当なデフォルト値
     が使われます。

          >>> token_hex(16)
          'f9bf78b9a18ce6d46a0cd2b0b86df9da'

 -- の関数: secrets.token_urlsafe ([nbytes=None])

     'nbytes' のランダムなバイトを持つ URL 安全なテキスト文字列を返しま
     す。テキストは Base64 でエンコードされていて、平均的に各バイトは約
     1.3 文字になります。 'nbytes' が ‘None’ の場合や与えられなかった場
     合は妥当なデフォルト値が使われます。

          >>> token_urlsafe(16)
          'Drmhze6EPcv0fN_81Bj-nA'

* Menu:

* トークンは何バイト使うべきか？::


File: python.info,  Node: トークンは何バイト使うべきか？,  Up: トークンの生成

5.15.3.3 トークンは何バイト使うべきか？
.......................................

総当たり攻撃(1) に耐えるには、トークンは十分にランダムでなければなりませ
ん。残念なことに、コンピュータの性能が向上し、より短時間により多くの推測
ができるようになるにつれ、十分とされるランダムさというのは必然的に増えま
す。2015 年の時点で、*note secrets: ae. モジュールに想定される通常の用途
では、32 バイト (256 ビット) のランダムさは十分と考えられています。

独自の長さのトークンを扱いたい場合、様々な ‘token_*’ 関数に *note int:
238. 引数で渡すことで、トークンに使用するランダムさを明示的に指定するこ
とができます。引数はランダムさのバイト数として使用されます。

それ以外の場合、すなわち引数がない場合や ‘None’ の場合、‘token_*’ 関数は
妥当なデフォルト値を代わりに使います。

     注釈: デフォルトはメンテナンスリリースの間を含め、いつでも変更され
     る可能性があります。

   ---------- Footnotes ----------

   (1) https://ja.wikipedia.org/wiki/総当たり攻撃


File: python.info,  Node: その他の関数,  Next: レシピとベストプラクティス,  Prev: トークンの生成,  Up: secrets --- 機密を扱うために安全な乱数を生成する

5.15.3.4 その他の関数
.....................

 -- の関数: secrets.compare_digest (a, b)

     文字列または *note bytes-like オブジェクト: cfb. 'a' と 'b' が等し
     ければ ‘True’ を、そうでなければ ‘False’ を返します。比較は タイミ
     ング攻撃(1) のリスクを減らす "定数時間比較" の方法で行われます。詳
     細については *note hmac.compare_digest(): 109c. を参照してください
     。

   ---------- Footnotes ----------

   (1) https://codahale.com/a-lesson-in-timing-attacks/


File: python.info,  Node: レシピとベストプラクティス,  Prev: その他の関数,  Up: secrets --- 機密を扱うために安全な乱数を生成する

5.15.3.5 レシピとベストプラクティス
...................................

この節では *note secrets: ae. を使用してセキュリティの基礎的なレベルを扱
う際のレシピとベストプラクティスを説明します。

8文字のアルファベットと数字を含むパスワードを生成するには:

     import string
     import secrets
     alphabet = string.ascii_letters + string.digits
     password = ''.join(secrets.choice(alphabet) for i in range(8))

     注釈: アプリケーションは、平文であろうと暗号化されていようと、 復元
     可能な形式でパスワードを保存(1) してはいけません。パスワードは暗号
     学的に強い一方向 (非可逆) ハッシュ関数を用いてソルトしハッシュしな
     ければなりません。

アルファべットと数字からなり、小文字を少なくとも1つと数字を少なくとも3つ
含む、10文字のパスワードを生成するには:

     import string
     import secrets
     alphabet = string.ascii_letters + string.digits
     while True:
         password = ''.join(secrets.choice(alphabet) for i in range(10))
         if (any(c.islower() for c in password)
                 and any(c.isupper() for c in password)
                 and sum(c.isdigit() for c in password) >= 3):
             break

XKCD スタイルのパスフレーズ(2) を生成するには:

     import secrets
     # On standard Linux systems, use a convenient dictionary file.
     # Other platforms may need to provide their own word-list.
     with open('/usr/share/dict/words') as f:
         words = [word.strip() for word in f]
         password = ' '.join(secrets.choice(words) for i in range(4))

パスワードの復元用途に適したセキュリティトークンを含む、推測しにくい一時
URL を生成するには:

     import secrets
     url = 'https://example.com/reset=' + secrets.token_urlsafe()

   ---------- Footnotes ----------

   (1) https://cwe.mitre.org/data/definitions/257.html

   (2) https://xkcd.com/936/


File: python.info,  Node: 汎用オペレーティングシステムサービス,  Next: 並行実行,  Prev: 暗号関連のサービス,  Up: Python 標準ライブラリ

5.16 汎用オペレーティングシステムサービス
=========================================

本章に記述されたモジュールは、ファイルの取り扱いや時間計測のような (ほぼ
)すべてのオペレーティングシステムで利用可能な機能にインターフェースを提
供します。これらのインターフェースは、Unix もしくは C のインターフェース
を基に作られますが、ほとんどの他のシステムで同様に利用可能です。概要を以
下に記述します:

* Menu:

* os: os --- 雑多なオペレーティングシステムインターフェース. 雑多なオペレーティングシステムインターフェース
* io: io --- ストリームを扱うコアツール. ストリームを扱うコアツール
* time: time --- 時刻データへのアクセスと変換. 時刻データへのアクセスと変換
* argparse: argparse --- Parser for command-line options arguments and subcommands. Parser for command-line options, arguments and
                        subcommands
* logging: logging --- Python 用のログ記録手段. Python 用のログ記録手段
* logging.config: logging config --- ログ記録の環境設定. ログ記録の環境設定
* logging.handlers: logging handlers --- ログ記録ハンドラー. ログ記録ハンドラー
* getpass: getpass --- 可搬性のあるパスワード入力機構. 可搬性のあるパスワード入力機構
* curses: curses --- 文字セル表示のターミナル処理. 文字セル表示のターミナル処理
* curses.textpad: curses textpad --- curses プログラムのためのテキスト入力ウィジェット. curses プログラムのためのテキスト入力ウィジェット
* curses.ascii: curses ascii --- ASCII 文字のユーティリティー. ASCII 文字のユーティリティー
* curses.panel: curses panel --- curses のためのパネルスタック拡張. curses のためのパネルスタック拡張
* platform: platform --- 実行中プラットフォームの固有情報を参照する. 実行中プラットフォームの固有情報を参照する
* errno: errno --- 標準の errno システムシンボル. 標準の errno システムシンボル
* ctypes: ctypes --- Python 用の外部関数ライブラリ. Python 用の外部関数ライブラリ


File: python.info,  Node: os --- 雑多なオペレーティングシステムインターフェース,  Next: io --- ストリームを扱うコアツール,  Up: 汎用オペレーティングシステムサービス

5.16.1 ‘os’ -- 雑多なオペレーティングシステムインターフェース
-------------------------------------------------------------

'ソースコード:' Lib/os.py(1)

__________________________________________________________________

このモジュールは、 OS 依存の機能を利用するポータブルな方法を提供します。
単純なファイルの読み書きについては、 *note open(): 4e5. を参照してくださ
い。パス操作については、 *note os.path: 92. モジュールを参照してください
。コマンドラインに与えられたすべてのファイルから行を読み込んでいくには、
*note fileinput: 51. モジュールを参照してください。一時ファイルや一時デ
ィレクトリの作成については、 *note tempfile: c9. モジュールを参照してく
ださい。高水準のファイルとディレクトリの操作については、 *note shutil:
b3. モジュールを参照してください。

利用可能性に関する注意 :

   * Python の、すべての OS 依存モジュールの設計方針は、可能な限り同一の
     インターフェースで同一の機能を利用できるようにする、というものです
     。例えば、 ‘os.stat(path)’ は 'path' に関する stat 情報を、 (POSIX
     を元にした ) 同じフォーマットで返します。

   * 特定のオペレーティングシステム固有の拡張も *note os: 91. を介して利
     用することができますが、これらの利用はもちろん、可搬性を脅かします
     。

   * パスやファイル名を受け付けるすべての関数は、バイト列型および文字列
     型両方のオブジェクトを受け付け、パスやファイル名を返す時は、同じ型
     のオブジェクトを返します。

   * VxWorks では、os.popen, os.fork, os.execv および os.spawn*p* はサポ
     ートされていません。

   * On WebAssembly platforms, Android and iOS, large parts of the *note
     os: 91. module are not available or behave differently.  APIs
     related to processes (e.g.  *note fork(): 17c, *note execve():
     10cc.) and resources (e.g.  *note nice(): 10d4.) are not available.
     Others like *note getuid(): 2a5d. and *note getpid(): 2a5e. are
     emulated or stubs.  WebAssembly platforms also lack support for
     signals (e.g.  *note kill(): 132f, *note wait(): d65.).

     注釈: このモジュール内のすべての関数は、間違った、あるいはアクセス
     出来ないファイル名やファイルパス、その他型が合っていても OS が受理
     しない引数に対して、 *note OSError: 3f0. (またはそのサブクラス)を送
     出します。

 -- 例外: os.error

     組み込みの *note OSError: 3f0. 例外に対するエイリアスです。

 -- データ: os.name

     import されているオペレーティングシステムに依存するモジュールの名前
     です。現在次の名前が登録されています: ‘'posix'’, ‘'nt'’, ‘'java'’。

     参考
     ....

     *note sys.platform: a5b. はより細かな粒度を持っています。 *note
     os.uname(): 10e9. はシステム依存のバージョン情報を提供します。

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

* Menu:

* ファイル名、コマンドライン引数、および環境変数::
* Python UTF-8 Mode::
* プロセスのパラメーター::
* ファイルオブジェクトの生成::
* ファイル記述子の操作::
* ファイルとディレクトリ::
* プロセス管理::
* スケジューラーへのインターフェイス::
* 雑多なシステム情報::
* 乱数: 乱数<2>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/os.py


File: python.info,  Node: ファイル名、コマンドライン引数、および環境変数,  Next: Python UTF-8 Mode,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.1 ファイル名、コマンドライン引数、および環境変数
.......................................................

Python では、ファイル名、コマンドライン引数、および環境変数を表すのに文
字列型を使用します。一部のシステムでは、これらをオペレーティングシステム
に渡す前に、文字列からバイト列へ、またはその逆のデコードが必要です。
Python はこの変換を行うために *note filesystem encoding and error
handler: 505. を使用します (*note sys.getfilesystemencoding(): c27. 参照
)。

The *note filesystem encoding and error handler: 505. are configured at
Python startup by the *note PyConfig_Read(): 75b. function: see *note
filesystem_encoding: 3c2. and *note filesystem_errors: 3c3. members of
*note PyConfig: 380.

バージョン 3.1 で変更: 一部のシステムでは、ファイルシステムのエンコーデ
ィングを使用して変換すると失敗する場合があります。この場合、Python は
*note surrogateescape エンコーディングエラーハンドラー: 233f. を使用しま
す。これは、デコード時にデコードできないバイト列は Unicode 文字 U+DC'xx'
に置き換えられ、それらはエンコード時に再び元のバイト列に変換されることを
意味します。

*note file system encoding: 505. では、すべてが 128 バイト以下に正常にデ
コードされることが保証されなくてはなりません。ファイルシステムのエンコー
ディングでこれが保証されなかった場合は、API 関数が *note UnicodeError:
1275. を送出します。

See also the *note locale encoding: 223.


File: python.info,  Node: Python UTF-8 Mode,  Next: プロセスのパラメーター,  Prev: ファイル名、コマンドライン引数、および環境変数,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.2 Python UTF-8 Mode
..........................

Added in version 3.7: より詳しくは PEP 540(1) を参照してください。

The Python UTF-8 Mode ignores the *note locale encoding: 223. and forces
the usage of the UTF-8 encoding:

   * Use UTF-8 as the *note filesystem encoding: 505.

   * *note sys.getfilesystemencoding(): c27. returns ‘'utf-8'’.

   * *note locale.getpreferredencoding(): 504. returns ‘'utf-8'’ (the
     'do_setlocale' argument has no effect).

   * *note sys.stdin: 507, *note sys.stdout: aa4, and *note sys.stderr:
     907. all use UTF-8 as their text encoding, with the
     ‘surrogateescape’ *note error handler: 1751. being enabled for
     *note sys.stdin: 507. and *note sys.stdout: aa4. (*note sys.stderr:
     907. continues to use ‘backslashreplace’ as it does in the default
     locale-aware mode)

   * On Unix, *note os.device_encoding(): 17fc. returns ‘'utf-8'’ rather
     than the device encoding.

Note that the standard stream settings in UTF-8 mode can be overridden
by *note PYTHONIOENCODING: fd5. (just as they can be in the default
locale-aware mode).

As a consequence of the changes in those lower level APIs, other higher
level APIs also exhibit different default behaviours:

   * Command line arguments, environment variables and filenames are
     decoded to text using the UTF-8 encoding.

   * *note os.fsdecode(): c22. and *note os.fsencode(): c23. use the
     UTF-8 encoding.

   * *note open(): 4e5, *note io.open(): 4e6, and *note codecs.open():
     70b. use the UTF-8 encoding by default.  However, they still use
     the strict error handler by default so that attempting to open a
     binary file in text mode is likely to raise an exception rather
     than producing nonsense data.

The *note Python UTF-8 Mode: 622. is enabled if the LC_CTYPE locale is
‘C’ or ‘POSIX’ at Python startup (see the *note PyConfig_Read(): 75b.
function).

It can be enabled or disabled using the *note -X utf8: 15c. command line
option and the *note PYTHONUTF8: aa6. environment variable.

If the *note PYTHONUTF8: aa6. environment variable is not set at all,
then the interpreter defaults to using the current locale settings,
'unless' the current locale is identified as a legacy ASCII-based locale
(as described for *note PYTHONCOERCECLOCALE: aa3.), and locale coercion
is either disabled or fails.  In such legacy locales, the interpreter
will default to enabling UTF-8 mode unless explicitly instructed not to
do so.

The Python UTF-8 Mode can only be enabled at the Python startup.  Its
value can be read from *note sys.flags.utf8_mode: 658.

See also the *note UTF-8 mode on Windows: 1d89. and the *note filesystem
encoding and error handler: 505.

参考
....

PEP 686(2)

     Python 3.15 will make *note Python UTF-8 Mode: 622. default.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0540/

   (2) https://peps.python.org/pep-0686/


File: python.info,  Node: プロセスのパラメーター,  Next: ファイルオブジェクトの生成,  Prev: Python UTF-8 Mode,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.3 プロセスのパラメーター
...............................

これらの関数とデータアイテムは、現在のプロセスおよびユーザーに対する情報
提供および操作のための機能を提供しています。

 -- の関数: os.ctermid ()

     プロセスの制御端末に対応するファイル名を返します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.environ

     A *note mapping: 118c. object where keys and values are strings
     that represent the process environment.  For example,
     ‘environ['HOME']’ is the pathname of your home directory (on some
     platforms), and is equivalent to ‘getenv("HOME")’ in C.

     このマップ型の内容は、 *note os: 91. モジュールの最初の import の時
     点、通常は Python の起動時に ‘site.py’ が処理される中で取り込まれま
     す。それ以後に変更された環境変数は *note os.environ: 118a. を直接変
     更しない限り *note os.environ: 118a. には反映されません。

     このマップ型オブジェクトは環境変数に対する変更に使うこともできます
     。 *note putenv(): 8ea. はマップ型オブジェクトが修正される時に、自
     動的に呼ばれることになります。

     Unix では、キーと値に *note sys.getfilesystemencoding(): c27.、エラ
     ーハンドラーに ‘'surrogateescape'’ を使用します。異なるエンコーディ
     ングを使用したい場合は *note environb: 11e8. を使用します。

     On Windows, the keys are converted to uppercase.  This also applies
     when getting, setting, or deleting an item.  For example,
     ‘environ['monty'] = 'python'’ maps the key ‘'MONTY'’ to the value
     ‘'python'’.

          注釈: *note putenv(): 8ea. を直接呼び出しても *note
          os.environ: 118a. の内容は変わらないので、 *note os.environ:
          118a. を直接変更する方が良いです。

          注釈: FreeBSD や macOS など一部のプラットフォームでは
          ‘environ’ の値を変更するとメモリリークが発生する可能性がありま
          す。各システムのドキュメントで ‘putenv()’ の項目を参照してくだ
          さい。

     このマップ型オブジェクトからアイテムを削除することで環境変数を消す
     ことができます。 *note unsetenv(): 8e9. は *note os.environ: 118a.
     からアイテムが取り除かれた時に自動的に呼ばれます。 ‘pop()’ または
     ‘clear()’ が呼ばれた時も同様です。

     バージョン 3.9 で変更: 更新され PEP 584(1) の合成演算子 (‘|’) と更
     新演算子 (‘|=’) がサポートされました。

 -- データ: os.environb

     Bytes version of *note environ: 118a.: a *note mapping: 118c.
     object where both keys and values are *note bytes: 1a4. objects
     representing the process environment.  *note environ: 118a. and
     *note environb: 11e8. are synchronized (modifying *note environb:
     11e8. updates *note environ: 118a, and vice versa).

     *note environb: 11e8. は *note supports_bytes_environ: 11e6. が
     ‘True’ の場合のみ利用可能です。

     Added in version 3.2.

     バージョン 3.9 で変更: 更新され PEP 584(2) の合成演算子 (‘|’) と更
     新演算子 (‘|=’) がサポートされました。

 -- の関数: os.chdir (path)

 -- の関数: os.fchdir (fd)

 -- の関数: os.getcwd ()

     これらの関数は、 *note ファイルとディレクトリ: 2a66. 節で説明されて
     います。

 -- の関数: os.fsencode (filename)

     *note path-like: 280. な 'filename' を *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. にエンコー
     ドします。未変更の *note bytes: 1a4. オブジェクトを返します。

     *note fsdecode(): c22. はこの逆変換を行う関数です。

     Added in version 3.2.

     バージョン 3.6 で変更: *note os.PathLike: c1f. インターフェースを実
     装したオブジェクトを受け入れるようになりました。

 -- の関数: os.fsdecode (filename)

     *note path-like: 280. な 'filename' を *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. からデコー
     ドします。未変更の *note str: 418. オブジェクトを返します。

     *note fsencode(): c23. はこの逆変換を行う関数です。

     Added in version 3.2.

     バージョン 3.6 で変更: *note os.PathLike: c1f. インターフェースを実
     装したオブジェクトを受け入れるようになりました。

 -- の関数: os.fspath (path)

     path のファイルシステム表現を返します。

     もし *note str: 418. か ‘bytes:’ のオブジェクトが渡された場合は、変
     更せずにそのまま返します。さもなければ、 *note __fspath__(): c20. が
     呼び出され、その戻り値が *note str: 418. か *note bytes: 1a4. のオ
     ブジェクトであれば、その値を返します。他のすべてのケースでは *note
     TypeError: 502. が送出されます。

     Added in version 3.6.

 -- クラス: os.PathLike

     ファイルシステムパスを表すオブジェクト(例: *note pathlib.PurePath:
     473.) 向けの *note abstract base class: 1186. です。

     Added in version 3.6.

      -- メソッド: abstractmethod __fspath__ ()

          このオブジェクトが表現するファイルシステムパスを返します。

          このメソッドは *note str: 418. か *note bytes: 1a4. のオブジェ
          クトのみを返す必要があります(*note str: 418. が好まれます)。

 -- の関数: os.getenv (key, default=None)

     環境変数 'key' が存在する場合はその値を文字列として返し、存在しなけ
     れば 'default' を返します。'key' は文字列です。注意すべき点として、
     *note getenv(): 2a67. は内部的に *note os.environ: 118a. を使用する
     ため、*note getenv(): 2a67. のマップ型オブジェクトはインポート時に
     取得されます。そのため、それ以降に環境変数が変更されても、この関数
     の値にそれが反映されない可能性があります。

     Unix では、キーと値は *note sys.getfilesystemencoding(): c27.、エラ
     ーハンドラー ‘'surrogateescape'’ でデコードされます。異なるエンコー
     ディングを使用したい場合は *note os.getenvb(): 11e7. を使用します。

     *note Availability: 1cbe.: Unix, Windows.

 -- の関数: os.getenvb (key, default=None)

     環境変数 'key' が存在する場合はその値を bytes として返し、存在しな
     ければ 'default' を返します。'key' はbytes である必要があります。注
     意すべき点として、*note getenvb(): 11e7. は内部的に *note
     os.environb: 11e8. を使用するため、*note getenvb(): 11e7. のマップ
     型オブジェクトはインポート時に取得されます。そのため、それ以降に環
     境変数が変更されても、この関数の値にそれが反映されない可能性があり
     ます。

     *note getenvb(): 11e7. は *note supports_bytes_environ: 11e6. が
     ‘True’ の場合のみ利用可能です。

     *note Availability: 1cbe.: Unix.

     Added in version 3.2.

 -- の関数: os.get_exec_path (env=None)

     プロセスを起動する時に名前付き実行ファイルを検索するディレクトリの
     リストを返します。 'env' が指定されると、それを環境変数の辞書とみな
     し、その辞書からキー PATH の値を探します。 デフォルトでは 'env' は
     ‘None’ であり、*note environ: 118a. が使用されます。

     Added in version 3.2.

 -- の関数: os.getegid ()

     現在のプロセスの実効グループ id を返します。この id は現在のプロセ
     スで実行されているファイルの "set id" ビットに対応します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.geteuid ()

     現在のプロセスの実効ユーザー id を返します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.getgid ()

     現在のプロセスの実グループ id を返します。

     *note Availability: 1cbe.: Unix.

     The function is a stub on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

 -- の関数: os.getgrouplist (user, group, /)

     Return list of group ids that 'user' belongs to.  If 'group' is not
     in the list, it is included; typically, 'group' is specified as the
     group ID field from the password record for 'user', because that
     group ID will otherwise be potentially omitted.

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.3.

 -- の関数: os.getgroups ()

     現在のプロセスに関連付けられた従属グループ id のリストを返します。

     *note Availability: 1cbe.: Unix, not WASI.

          注釈: macOS では *note getgroups(): 2a6b. の挙動は他の Unix プ
          ラットフォームとはいくぶん異なります。 Python のインタープリタ
          が ‘10.5’ 以前の Deployment Target でビルドされている場合、
          *note getgroups(): 2a6b. は現在のユーザープロセスに関連付けら
          れている実効グループ id を返します。このリストはシステムで定義
          されたエントリ数 ( 通常は 16) に制限され、適切な特権があれば
          *note setgroups(): 2a6c. の呼び出しによって変更することができ
          ます。 ‘10.5’ より新しい Deployment Target でビルドされている
          場合、 *note getgroups(): 2a6b. はプロセスの実効ユーザー id に
          関連付けられたユーザーの現在のグループアクセスリストを返します
          。このグループアクセスリストは、プロセスのライフタイムで変更さ
          れる可能性があり、 *note setgroups(): 2a6c. の呼び出しの影響を
          受けず、長さ 16 の制限を受けません。 Deployment Target の値
          ‘MACOSX_DEPLOYMENT_TARGET’ は、 *note
          sysconfig.get_config_var(): ff5. で取得することができます。

 -- の関数: os.getlogin ()

     プロセスの制御端末にログインしているユーザー名を返します。ほとんど
     の場合、*note getpass.getuser(): 3f1. を使う方が便利です。なぜなら
     、*note getpass.getuser(): 3f1. は、ユーザーを見つけるために、環境
     変数 ‘LOGNAME’ や ‘USERNAME’ を調べ、さらには
     ‘pwd.getpwuid(os.getuid())[0]’ まで調べに行くからです。

     *note Availability: 1cbe.: Unix, Windows, not WASI.

 -- の関数: os.getpgid (pid)

     プロセス id 'pid' のプロセスのプロセスグループ id を返します。
     'pid' が 0 の場合、現在のプロセスのプロセスグループ id を返します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.getpgrp ()

     現在のプロセスグループの id を返します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.getpid ()

     現在のプロセス id を返します。

     The function is a stub on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

 -- の関数: os.getppid ()

     親プロセスのプロセス id を返します。親プロセスが終了していた場合、
     Unix では init プロセスの id (1) が返され、Windows では親のプロセス
     id だったもの (別のプロセスで再利用されているかもしれない) がそのま
     ま返されます。

     *note Availability: 1cbe.: Unix, Windows, not WASI.

     バージョン 3.2 で変更: Windows サポートが追加されました。

 -- の関数: os.getpriority (which, who)

     プログラムのスケジューリング優先度を取得します。'which' の値は
     *note PRIO_PROCESS: 2a70.、*note PRIO_PGRP: 2a71.、あるいは *note
     PRIO_USER: 2a72. のいずれか一つで、'who' の値は 'which' に応じて解
     釈されます (*note PRIO_PROCESS: 2a70. であればプロセス識別子、*note
     PRIO_PGRP: 2a71. であればプロセスグループ識別子、そして *note
     PRIO_USER: 2a72. であればユーザー ID)。'who' の値がゼロの場合、呼び
     出したプロセス、呼び出したプロセスのプロセスグループ、および呼び出
     したプロセスの実ユーザー id を (それぞれ) 意味します。

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.3.

 -- データ: os.PRIO_PROCESS
 -- データ: os.PRIO_PGRP
 -- データ: os.PRIO_USER

     *note getpriority(): 10d2. と *note setpriority(): 10d3. 用のパラメ
     ータです。

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.3.

 -- データ: os.PRIO_DARWIN_THREAD
 -- データ: os.PRIO_DARWIN_PROCESS
 -- データ: os.PRIO_DARWIN_BG
 -- データ: os.PRIO_DARWIN_NONUI

     *note getpriority(): 10d2. と *note setpriority(): 10d3. 用のパラメ
     ータです。

     *note Availability: 1cbe.: macOS

     Added in version 3.12.

 -- の関数: os.getresuid ()

     現在のプロセスの実ユーザー id 、実効ユーザー id 、および保存ユーザ
     ー id を示す、 (ruid, euid, suid) のタプルを返します。

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.2.

 -- の関数: os.getresgid ()

     現在のプロセスの実グループ id 、実効グループ id 、および保存グルー
     プ id を示す、 (rgid, egid, sgid) のタプルを返します。

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.2.

 -- の関数: os.getuid ()

     現在のプロセスの実ユーザー id を返します。

     *note Availability: 1cbe.: Unix.

     The function is a stub on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

 -- の関数: os.initgroups (username, gid, /)

     システムの initgroups() を呼び出し、指定された 'username' がメンバ
     ーである全グループと 'gid' で指定されたグループでグループアクセスリ
     ストを初期化します。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

     Added in version 3.2.

 -- の関数: os.putenv (key, value, /)

     'key' という名前の環境変数に文字列 'value' を設定します。このような
     環境変数の変更は、*note os.system(): 1402.、*note popen(): a55.、ま
     たは *note fork(): 17c. と *note execv(): 2a77. で起動されたサブプ
     ロセスに影響を与えます。

     *note os.environ: 118a. の要素に代入すると、それは *note putenv():
     8ea. の呼び出しに自動変換されます。 しかし、直接 *note putenv():
     8ea. を呼び出しても *note os.environ: 118a. には反映されないため、
     *note os.environ: 118a. の要素に代入する方がベターです。 *note
     getenv(): 2a67. と *note getenvb(): 11e7. についても、実装上それぞ
     れ *note os.environ: 118a. と *note os.environb: 11e8. を使用するの
     で、同様に注意が必要です。

          注釈: FreeBSD や macOS など一部のプラットフォームでは
          ‘environ’ の値を変更するとメモリリークが発生する可能性がありま
          す。 各システムのドキュメントで ‘putenv()’ の項目を参照してく
          ださい。

     引数 ‘key’, ‘value’ を指定して *note 監査イベント: 1825.
     ‘os.putenv’ を送出します。

     バージョン 3.9 で変更: 常に利用出来るようになりました。

 -- の関数: os.setegid (egid, /)

     現在のプロセスに実効グループ id をセットします。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

 -- の関数: os.seteuid (euid, /)

     現在のプロセスに実効ユーザー id をセットします。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

 -- の関数: os.setgid (gid, /)

     現在のプロセスにグループ id をセットします。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

 -- の関数: os.setgroups (groups, /)

     現在のグループに関連付けられた従属グループ id のリストを 'groups' に
     設定します。 'groups' はシーケンス型でなくてはならず、各要素はグル
     ープを特定する整数でなくてはなりません。通常、この操作はスーパユー
     ザーしか利用できません。

     *note Availability: 1cbe.: Unix, not WASI.

          注釈: macOS では、 'groups' の長さはシステムで定義された実効グ
          ループ id の最大数 ( 通常は 16) を超えない場合があります。
          setgroups() 呼び出しで設定されたものと同じグループリストが返さ
          れないケースについては、 *note getgroups(): 2a6b. のドキュメン
          トを参照してください。

 -- の関数: os.setns (fd, nstype=0)

     Reassociate the current thread with a Linux namespace.  See the
     ‘setns(2)(3)’ and ‘namespaces(7)(4)’ man pages for more details.

     If 'fd' refers to a ‘/proc/`pid'/ns/’ link, ‘setns()’ reassociates
     the calling thread with the namespace associated with that link,
     and 'nstype' may be set to one of the *note CLONE_NEW* constants:
     2a7b. to impose constraints on the operation (‘0’ means no
     constraints).

     Since Linux 5.8, 'fd' may refer to a PID file descriptor obtained
     from *note pidfd_open(): 447.  In this case, ‘setns()’ reassociates
     the calling thread into one or more of the same namespaces as the
     thread referred to by 'fd'.  This is subject to any constraints
     imposed by 'nstype', which is a bit mask combining one or more of
     the *note CLONE_NEW* constants: 2a7b, e.g.  ‘setns(fd,
     os.CLONE_NEWUTS | os.CLONE_NEWPID)’.  The caller's memberships in
     unspecified namespaces are left unchanged.

     'fd' can be any object with a *note fileno(): 27a6. method, or a
     raw file descriptor.

     This example reassociates the thread with the ‘init’ process's
     network namespace:

          fd = os.open("/proc/1/ns/net", os.O_RDONLY)
          os.setns(fd, os.CLONE_NEWNET)
          os.close(fd)

     *note Availability: 1cbe.: Linux >= 3.0 with glibc >= 2.14.

     Added in version 3.12.

     参考
     ....

     The *note unshare(): 172c. function.

 -- の関数: os.setpgrp ()

     システムコール ‘setpgrp()’ か ‘setpgrp(0, 0)’ のどちらか(実装されて
     いるもの)を呼び出します。機能については UNIX マニュアルを参照して下
     さい。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.setpgid (pid, pgrp, /)

     システムコール ‘setpgid()’ を呼び出してプロセス id 'pid' のプロセス
     のプロセスグループ id を 'pgrp' に設定します。この動作に関しては
     Unix のマニュアルを参照してください。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.setpriority (which, who, priority)

     プログラムのスケジューリング優先度を設定します。'which' は *note
     PRIO_PROCESS: 2a70.、*note PRIO_PGRP: 2a71.、あるいは *note
     PRIO_USER: 2a72. のいずれか一つで、'who' の値は 'which' に応じて解
     釈されます (*note PRIO_PROCESS: 2a70. であればプロセス識別子、*note
     PRIO_PGRP: 2a71. であればプロセスグループ識別子、そして *note
     PRIO_USER: 2a72. であればユーザー ID)。'who' の値がゼロの場合、呼び
     出したプロセス、呼び出したプロセスのプロセスグループ、および呼び出
     したプロセスの実ユーザー id を (それぞれ) 意味します。'priority' は
     -20 から 19 の整数値で、デフォルトの優先度は 0 です。小さい数値ほど
     優先されるスケジューリングとなります。

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.3.

 -- の関数: os.setregid (rgid, egid, /)

     現在のプロセスの実グループ id および実効グループ id を設定します。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

 -- の関数: os.setresgid (rgid, egid, sgid, /)

     現在のプロセスの、実グループ id 、実効グループ id 、および保存グル
     ープ id を設定します。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

     Added in version 3.2.

 -- の関数: os.setresuid (ruid, euid, suid, /)

     現在のプロセスの実ユーザー id 、実効ユーザー id 、および保存ユーザ
     ー id を設定します。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

     Added in version 3.2.

 -- の関数: os.setreuid (ruid, euid, /)

     現在のプロセスの実ユーザー id および実効ユーザー id を設定します。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

 -- の関数: os.getsid (pid, /)

     ‘getsid()’ システムコールを呼び出します。機能については Unix のマニ
     ュアルを参照してください。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.setsid ()

     ‘setsid()’ システムコールを呼び出します。機能については Unix のマニ
     ュアルを参照してください。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.setuid (uid, /)

     現在のプロセスのユーザー id を設定します。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

 -- の関数: os.strerror (code, /)

     エラーコード 'code' に対応するエラーメッセージを返します。未知のエ
     ラーコードの対して ‘strerror()’ が ‘NULL’ を返すプラットフォームで
     は、 *note ValueError: 1e3. が送出されます。

 -- データ: os.supports_bytes_environ

     環境のネイティブ OS タイプがバイト型の場合、 ‘True’ です (例:
     Windows では、 ‘False’ です)。

     Added in version 3.2.

 -- の関数: os.umask (mask, /)

     現在の数値 umask を設定し、以前の umask 値を返します。

     The function is a stub on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

 -- の関数: os.uname ()

     現在のオペレーティングシステムを識別する情報を返します。返り値は 5
     個の属性を持つオブジェクトです:

        * ‘sysname’ - OS の名前

        * ‘nodename’ - (実装時に定義された) ネットワーク上でのマシン名

        * ‘release’ - OS のリリース

        * ‘version’ - OS のバージョン

        * ‘machine’ - ハードウェア識別子

     後方互換性のため、このオブジェクトはイテラブルでもあり、‘sysname’、
     ‘nodename’、‘release’、‘version’、および ‘machine’ の 5 個の要素を
     この順序で持つタプルのように振る舞います。

     一部のシステムでは、‘nodename’ はコンポーネントを読み込むために 8 文
     字または先頭の要素だけに切り詰められます; ホスト名を取得する方法と
     しては、*note socket.gethostname(): 2a84. を使う方がよいでしょう。
     あるいは ‘socket.gethostbyaddr(socket.gethostname())’ でもかまいま
     せん。

     On macOS, iOS and Android, this returns the 'kernel' name and
     version (i.e., ‘'Darwin'’ on macOS and iOS; ‘'Linux'’ on Android).
     *note platform.uname(): 199d. can be used to get the user-facing
     operating system name and version on iOS and Android.

     *note Availability: 1cbe.: Unix.

     バージョン 3.3 で変更: 返り値の型が、タプルから属性名のついたタプル
     ライクオブジェクトに変更されました。

 -- の関数: os.unsetenv (key, /)

     'key' という名前の環境変数を unset (削除) します。このような環境変
     数の変更は、*note os.system(): 1402.、*note popen(): a55.、または
     *note fork(): 17c. と *note execv(): 2a77. で起動されたサブプロセス
     に影響を与えます。

     *note os.environ: 118a. のアイテムの削除を行うと、自動的に *note
     unsetenv(): 8e9. の対応する呼び出しに変換されます。直接 *note
     unsetenv(): 8e9. を呼び出した場合 *note os.environ: 118a. は更新さ
     れないため、実際には *note os.environ: 118a. のアイテムを削除する方
     が望ましい操作です。

     引数 ‘key’ を指定して *note 監査イベント: 1825. ‘os.unsetenv’ を送
     出します。

     バージョン 3.9 で変更: 常に関数は利用出来るようになりました。

 -- の関数: os.unshare (flags)

     Disassociate parts of the process execution context, and move them
     into a newly created namespace.  See the ‘unshare(2)(5)’ man page
     for more details.  The 'flags' argument is a bit mask, combining
     zero or more of the *note CLONE_* constants: 2a7b, that specifies
     which parts of the execution context should be unshared from their
     existing associations and moved to a new namespace.  If the 'flags'
     argument is ‘0’, no changes are made to the calling process's
     execution context.

     *note Availability: 1cbe.: Linux >= 2.6.16.

     Added in version 3.12.

     参考
     ....

     *note setns(): 172b. 関数。

Flags to the *note unshare(): 172c. function, if the implementation
supports them.  See ‘unshare(2)(6)’ in the Linux manual for their exact
effect and availability.

 -- データ: os.CLONE_FILES
 -- データ: os.CLONE_FS
 -- データ: os.CLONE_NEWCGROUP
 -- データ: os.CLONE_NEWIPC
 -- データ: os.CLONE_NEWNET
 -- データ: os.CLONE_NEWNS
 -- データ: os.CLONE_NEWPID
 -- データ: os.CLONE_NEWTIME
 -- データ: os.CLONE_NEWUSER
 -- データ: os.CLONE_NEWUTS
 -- データ: os.CLONE_SIGHAND
 -- データ: os.CLONE_SYSVSEM
 -- データ: os.CLONE_THREAD
 -- データ: os.CLONE_VM

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0584/

   (2) https://peps.python.org/pep-0584/

   (3) https://manpages.debian.org/setns(2)

   (4) https://manpages.debian.org/namespaces(7)

   (5) https://manpages.debian.org/unshare(2)

   (6) https://manpages.debian.org/unshare(2)


File: python.info,  Node: ファイルオブジェクトの生成,  Next: ファイル記述子の操作,  Prev: プロセスのパラメーター,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.4 ファイルオブジェクトの生成
...................................

以下の関数は新しい *note ファイルオブジェクト: 1193. を作成します。(ファ
イル記述子のオープンについては *note open(): d5f. も参照してください)

 -- の関数: os.fdopen (fd, *args, **kwargs)

     ファイル記述子 'fd' に接続し、オープンしたファイルオブジェクトを返
     します。これは組み込み関数 *note open(): 4e5. の別名であり、同じ引
     数を受け取ります。唯一の違いは *note fdopen(): 1e92. の第一引数が常
     に整数でなければならないことです。


File: python.info,  Node: ファイル記述子の操作,  Next: ファイルとディレクトリ,  Prev: ファイルオブジェクトの生成,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.5 ファイル記述子の操作
.............................

これらの関数は、ファイル記述子を使って参照されている I/O ストリームを操
作します。

ファイル記述子とは現在のプロセスで開かれたファイルに対応する小さな整数で
す。例えば、標準入力のファイル記述子は通常 0 で、標準出力は 1 、標準エラ
ーは 2 です。プロセスから開かれたその他のファイルには 3 、 4 、 5 と割り
振られていきます。「ファイル記述子」という名称は少し誤解を与えるものかも
しれません。Unix プラットフォームでは、ソケットやパイプもファイル記述子
によって参照されます。

*note fileno(): 27a6. メソッドを使用して、必要な場合に *note file
object: 1193. に関連付けられているファイル記述子を取得することができます
。ファイル記述子を直接使用すると、ファイルオブジェクトのメソッドが使用さ
れないため、データの内部バッファなどの性質は無視されることに注意してくだ
さい。

 -- の関数: os.close (fd)

     ファイル記述子 'fd' をクローズします。

          注釈: この関数は低水準の I/O 向けのもので、 *note os.open():
          d5f. や *note pipe(): 1745. が返すファイル記述子に対して使用し
          なければなりません。 組み込み関数 *note open(): 4e5. や *note
          popen(): a55. 、 *note fdopen(): 1e92. が返す "ファイルオブジ
          ェクト" を閉じるには、オブジェクトの *note close(): 1d7. メソ
          ッドを使用してください。

 -- の関数: os.closerange (fd_low, fd_high, /)

     'fd_low' 以上 'fd_high' 未満のすべてのファイル記述子をエラーを無視
     してクローズします。以下のコードと等価です:

          for fd in range(fd_low, fd_high):
              try:
                  os.close(fd)
              except OSError:
                  pass

 -- の関数: os.copy_file_range (src, dst, count, offset_src=None,
          offset_dst=None)

     Copy 'count' bytes from file descriptor 'src', starting from offset
     'offset_src', to file descriptor 'dst', starting from offset
     'offset_dst'.  If 'offset_src' is ‘None’, then 'src' is read from
     the current position; respectively for 'offset_dst'.

     In Linux kernel older than 5.3, the files pointed to by 'src' and
     'dst' must reside in the same filesystem, otherwise an *note
     OSError: 3f0. is raised with *note errno: 21e9. set to *note
     errno.EXDEV: 2a99.

     This copy is done without the additional cost of transferring data
     from the kernel to user space and then back into the kernel.
     Additionally, some filesystems could implement extra optimizations,
     such as the use of reflinks (i.e., two or more inodes that share
     pointers to the same copy-on-write disk blocks; supported file
     systems include btrfs and XFS) and server-side copy (in the case of
     NFS).

     The function copies bytes between two file descriptors.  Text
     options, like the encoding and the line ending, are ignored.

     返り値はコピーされたバイトの量です。 この値は、要求した量より少なく
     なることもあります。

          注釈: On Linux, *note os.copy_file_range(): 2a98. should not
          be used for copying a range of a pseudo file from a special
          filesystem like procfs and sysfs.  It will always copy no
          bytes and return 0 as if the file was empty because of a known
          Linux kernel issue.

     *note Availability: 1cbe.: Linux >= 4.5 with glibc >= 2.27.

     Added in version 3.8.

 -- の関数: os.device_encoding (fd)

     'fd' に関連付けられたデバイスが端末 (ターミナル) に接続されている場
     合に、そのデバイスのエンコーディングを表す文字列を返します。端末に
     接続されていない場合、 *note None: 641. を返します。

     On Unix, if the *note Python UTF-8 Mode: 622. is enabled, return
     ‘'UTF-8'’ rather than the device encoding.

     バージョン 3.10 で変更: On Unix, the function now implements the
     Python UTF-8 Mode.

 -- の関数: os.dup (fd, /)

     ファイル記述子 'fd' の複製を返します。新しいファイル記述子は *note
     継承不可: ec4. です。

     Windows では、標準ストリーム (0: 標準入力、1: 標準出力、2: 標準エラ
     ー出力) を複製する場合、新しいファイル記述子は *note 継承可能: ec4.
     です。

     *note Availability: 1cbe.: not WASI.

     バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

 -- の関数: os.dup2 (fd, fd2, inheritable=True)

     ファイル記述子 'fd' を 'fd2' に複製し、必要な場合には後者を先に閉じ
     ます。 'fd2' が返ります。 新しいファイル記述子はデフォルトでは
     *note 継承可能: ec4. で、'inheritable' が ‘False’ の場合は継承不可
     です。

     *note Availability: 1cbe.: not WASI.

     バージョン 3.4 で変更: オプションの 'inheritable' 引数が追加されま
     した。

     バージョン 3.7 で変更: 成功したときは 'fd2' が返ります。 以前は常に
     ‘None’ が返っていました。

 -- の関数: os.fchmod (fd, mode)

     'fd' で指定されたファイルのモードを 'mode' に変更します。'mode' に
     指定できる値については、*note chmod(): 1fc. のドキュメントを参照し
     てください。Python 3.3 以降では ‘os.chmod(fd, mode)’ と等価です。

     引数 ‘path’, ‘mode’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.chmod’ を送出します。

     *note Availability: 1cbe.: Unix, Windows.

     The function is limited on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

     バージョン 3.13 で変更: Added support on Windows.

 -- の関数: os.fchown (fd, uid, gid)

     'fd' で指定されたファイルの所有者 id およびグループ id を数値 'uid'
     および 'gid' に変更します。いずれかの id を変更せずにおくにはその値
     として -1 を指定します。*note chown(): 10bf. を参照してください。
     Python 3.3 以降では ‘os.chown(fd, uid, gid)’ と等価です。

     引数 ‘path’, ‘uid’, ‘gid’, ‘dir_fd’ を指定して *note 監査イベント:
     1825. ‘os.chown’ を送出します。

     *note Availability: 1cbe.: Unix.

     The function is limited on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

 -- の関数: os.fdatasync (fd)

     ファイル記述子 'fd' を持つファイルのディスクへの書き込みを強制しま
     す。メタデータの更新は強制しません。

     *note Availability: 1cbe.: Unix.

          注釈: この関数は MacOS では利用できません。

 -- の関数: os.fpathconf (fd, name, /)

     開いているファイルに関連するシステム設定情報を返します。 'name' は
     取得する設定名を指定します。これは、いくつかの標準 (POSIX.1 、 Unix
     95 、 Unix 98 その他 ) で定義された定義済みのシステム値名の文字列で
     ある場合があります。プラットフォームによっては別の名前も定義されて
     います。ホストオペレーティングシステムの関知する名前は
     ‘pathconf_names’ 辞書で与えられています。このマップ型オブジェクトに
     含まれていない構成変数については、 'name' に整数を渡してもかまいま
     せん。

     'name' が不明の文字列である場合、 *note ValueError: 1e3. を送出しま
     す。 'name' の特定の値がホストシステムでサポートされていない場合、
     ‘pathconf_names’ に含まれていたとしても、 *note errno.EINVAL: 195a.
     をエラー番号として *note OSError: 3f0. を送出します。

     Python 3.3 以降では ‘os.pathconf(fd, name)’ と等価です。

     *note Availability: 1cbe.: Unix.

 -- の関数: os.fstat (fd)

     ファイル記述子 'fd' の状態を取得します。*note stat_result: 1466. オ
     ブジェクトを返します。

     Python 3.3 以降では ‘os.stat(fd)’ と等価です。

     参考
     ....

     *note stat(): 46d. 関数。

 -- の関数: os.fstatvfs (fd, /)

     *note statvfs(): 10cf. と同様に、ファイル記述子 'fd' に関連付けられ
     たファイルが格納されているファイルシステムに関する情報を返します。
     Python 3.3 以降では ‘os.statvfs(fd)’ と等価です。

     *note Availability: 1cbe.: Unix.

 -- の関数: os.fsync (fd)

     ファイル記述子 'fd' を持つファイルのディスクへの書き込みを強制しま
     す。 Unix では、ネイティブの ‘fsync()’ 関数を、 Windows では
     ‘_commit()’ 関数を呼び出します。

     Python の *note ファイルオブジェクト: 1193. 'f' を使う場合、'f' の
     内部バッファを確実にディスクに書き込むために、まず ‘f.flush()’ を、
     その後 ‘os.fsync(f.fileno())’ を実行してください。

     *note Availability: 1cbe.: Unix, Windows.

 -- の関数: os.ftruncate (fd, length, /)

     ファイル記述子 'fd' に対応するファイルを、サイズが最長で 'length' バ
     イトになるように切り詰めます。Python 3.3 以降では ‘os.truncate(fd,
     length)’ と等価です。

     引数 ‘fd’, ‘length’ を指定して *note 監査イベント: 1825.
     ‘os.truncate’ を送出します。

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.5 で変更: Windows サポートを追加しました。

 -- の関数: os.get_blocking (fd, /)

     記述子のブロッキングモードを取得します。 *note O_NONBLOCK: e08. フ
     ラグが設定されている場合は ‘False’ で、フラグがクリアされている場合
     は ‘True’ です。

     *note set_blocking(): e07. および *note
     socket.socket.setblocking(): 2a9b. も参照してください。

     *note Availability: 1cbe.: Unix, Windows.

     The function is limited on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

     On Windows, this function is limited to pipes.

     Added in version 3.5.

     バージョン 3.12 で変更: Added support for pipes on Windows.

 -- の関数: os.grantpt (fd, /)

     Grant access to the slave pseudo-terminal device associated with
     the master pseudo-terminal device to which the file descriptor 'fd'
     refers.  The file descriptor 'fd' is not closed upon failure.

     Calls the C standard library function ‘grantpt()’.

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.13.

 -- の関数: os.isatty (fd, /)

     ファイル記述子 'fd' がオープンされていて、 tty (のような) デバイス
     に接続されている場合、 ‘True’ を返します。そうでない場合は ‘False’
     を返します。

 -- の関数: os.lockf (fd, cmd, len, /)

     オープンされたファイル記述子に対して、POSIX ロックの適用、テスト、
     解除を行います。'fd' はオープンされたファイル記述子です。'cmd' には
     使用するコマンド (*note F_LOCK: 2a9c.、*note F_TLOCK: 2a9d.、*note
     F_ULOCK: 2a9e.、あるいは *note F_TEST: 2a9f. のいずれか一つ) を指定
     します。'len' にはロックするファイルのセクションを指定します。

     引数 ‘fd’, ‘cmd’, ‘len’ を指定して *note 監査イベント: 1825.
     ‘os.lockf’ を送出します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- データ: os.F_LOCK
 -- データ: os.F_TLOCK
 -- データ: os.F_ULOCK
 -- データ: os.F_TEST

     *note lockf(): 10e6. がとる動作を指定するフラグです。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: os.login_tty (fd, /)

     Prepare the tty of which fd is a file descriptor for a new login
     session.  Make the calling process a session leader; make the tty
     the controlling tty, the stdin, the stdout, and the stderr of the
     calling process; close fd.

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.11.

 -- の関数: os.lseek (fd, pos, whence, /)

     Set the current position of file descriptor 'fd' to position 'pos',
     modified by 'whence', and return the new position in bytes relative
     to the start of the file.  Valid values for 'whence' are:

        * *note SEEK_SET: 125e. or ‘0’ - set 'pos' relative to the
          beginning of the file

        * *note SEEK_CUR: 125f. or ‘1’ - set 'pos' relative to the
          current file position

        * *note SEEK_END: 1260. or ‘2’ - set 'pos' relative to the end
          of the file

        * *note SEEK_HOLE: 2aa0. - set 'pos' to the next data location,
          relative to 'pos'

        * *note SEEK_DATA: 2aa1. - set 'pos' to the next data hole,
          relative to 'pos'

     バージョン 3.3 で変更: Add support for ‘SEEK_HOLE’ and ‘SEEK_DATA’.

 -- データ: os.SEEK_SET
 -- データ: os.SEEK_CUR
 -- データ: os.SEEK_END

     Parameters to the *note lseek(): 10ea. function and the *note
     seek(): 125d. method on *note file-like objects: 1193, for whence
     to adjust the file position indicator.

     *note SEEK_SET: 125e.

          Adjust the file position relative to the beginning of the
          file.

     *note SEEK_CUR: 125f.

          Adjust the file position relative to the current file
          position.

     *note SEEK_END: 1260.

          Adjust the file position relative to the end of the file.

     Their values are 0, 1, and 2, respectively.

 -- データ: os.SEEK_HOLE
 -- データ: os.SEEK_DATA

     Parameters to the *note lseek(): 10ea. function and the *note
     seek(): 125d. method on *note file-like objects: 1193, for seeking
     file data and holes on sparsely allocated files.

     ‘SEEK_DATA’

          Adjust the file offset to the next location containing data,
          relative to the seek position.

     ‘SEEK_HOLE’

          Adjust the file offset to the next location containing a hole,
          relative to the seek position.  A hole is defined as a
          sequence of zeros.

          注釈: These operations only make sense for filesystems that
          support them.

     *note Availability: 1cbe.: Linux >= 3.1, macOS, Unix

     Added in version 3.3.

 -- の関数: os.open (path, flags, mode=0o777, *, dir_fd=None)

     ファイル 'path' を開き、'flag' に従って様々なフラグを設定し、可能な
     ら 'mode' に従ってファイルモードを設定します。'mode' を計算する際、
     まず現在の umask 値でマスクされます。新たに開いたファイルのファイル
     記述子を返します。新しいファイル記述子は *note 継承不可: ec4. です
     。

     フラグとファイルモードの値についての詳細は C ランタイムのドキュメン
     トを参照してください; (*note O_RDONLY: 2aa2. や *note O_WRONLY:
     2aa3. のような) フラグ定数は *note os: 91. モジュールでも定義されて
     います。特に、Windows ではバイナリモードでファイルを開く時に *note
     O_BINARY: 2aa4. を加える必要があります。

     この関数は 'dir_fd' パラメタで *note
     ディレクトリ記述子への相対パス: 10c8. をサポートしています。

     引数 ‘path’, ‘mode’, ‘flags’ を指定して *note 監査イベント: 1825.
     ‘open’ を送出します。

     バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

          注釈: この関数は低水準の I/O 向けのものです。 通常の利用では、
          組み込み関数 *note open(): 4e5. を使用してください。 *note
          open(): 4e5. は ‘read()’ や ‘write()’ (そしてさらに多くの) メ
          ソッドを持つ *note ファイルオブジェクト: 1193. を返します。 フ
          ァイル記述子をファイルオブジェクトでラップするには *note
          fdopen(): 1e92. を使用してください。

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、この関数は *note InterruptedError: d55. 例
     外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(1) を参照してください)。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

以下の定数は *note open(): d5f. 関数の 'flags' 引数に利用します。これら
の定数は、ビット単位に OR 演算子 ‘|’ で組み合わせることができます。一部
、すべてのプラットフォームでは使用できない定数があります。利用可能かどう
かや使い方については、Unix では ‘open(2)(2)’、Windows では MSDN(3) を参
照してください。

 -- データ: os.O_RDONLY
 -- データ: os.O_WRONLY
 -- データ: os.O_RDWR
 -- データ: os.O_APPEND
 -- データ: os.O_CREAT
 -- データ: os.O_EXCL
 -- データ: os.O_TRUNC

     上記の定数は Unix および Windows で利用可能です。

 -- データ: os.O_DSYNC
 -- データ: os.O_RSYNC
 -- データ: os.O_SYNC
 -- データ: os.O_NDELAY
 -- データ: os.O_NONBLOCK
 -- データ: os.O_NOCTTY
 -- データ: os.O_CLOEXEC

     上記の定数は Unix でのみ利用可能です。

     バージョン 3.3 で変更: 定数 *note O_CLOEXEC: 1051. が追加されました
     。

 -- データ: os.O_BINARY
 -- データ: os.O_NOINHERIT
 -- データ: os.O_SHORT_LIVED
 -- データ: os.O_TEMPORARY
 -- データ: os.O_RANDOM
 -- データ: os.O_SEQUENTIAL
 -- データ: os.O_TEXT

     上記の定数は Windows でのみ利用可能です。

 -- データ: os.O_EVTONLY
 -- データ: os.O_FSYNC
 -- データ: os.O_SYMLINK
 -- データ: os.O_NOFOLLOW_ANY

     上記の定数は macOS でのみ利用可能です。

     バージョン 3.10 で変更: Add *note O_EVTONLY: 7e5, *note O_FSYNC:
     7e6, *note O_SYMLINK: 7e7. and *note O_NOFOLLOW_ANY: 7e8.
     constants.

 -- データ: os.O_ASYNC
 -- データ: os.O_DIRECT
 -- データ: os.O_DIRECTORY
 -- データ: os.O_NOFOLLOW
 -- データ: os.O_NOATIME
 -- データ: os.O_PATH
 -- データ: os.O_TMPFILE
 -- データ: os.O_SHLOCK
 -- データ: os.O_EXLOCK

     上記の定数は拡張仕様であり、Cライブラリで定義されていない場合は利用
     できません。

     バージョン 3.4 で変更: *note O_PATH: f3f. を、それをサポートするシ
     ステムで追加しました。また、 *note O_TMPFILE: f40. を追加しました
     (Linux Kernel 3.11 以降でのみ利用可能です)。

 -- の関数: os.openpty ()

     新しい擬似端末のペアを開きます。pty および tty を表すファイル記述子
     のペア ‘(master, slave)’ を返します。新しいファイル記述子は *note
     継承不可: ec4. です。(若干) 可搬性の高いアプローチには *note pty:
     9f. を使用してください。

     *note Availability: 1cbe.: Unix, not WASI.

     バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

 -- の関数: os.pipe ()

     パイプを作成します。読み込み、書き込みに使うことの出来るファイル記
     述子のペア ‘(r, w)’ を返します。新しいファイル記述子は *note
     継承不可: ec4. です。

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

 -- の関数: os.pipe2 (flags, /)

     'flags' を設定したパイプをアトミックに作成します。'flags' には値
     *note O_NONBLOCK: e08. と *note O_CLOEXEC: 1051. を一つ以上論理和指
     定できます。読み込み、書き込みに使うことの出来るファイル記述子のペ
     ア ‘(r, w)’ を返します。

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.3.

 -- の関数: os.posix_fallocate (fd, offset, len, /)

     'fd' で指定されたファイルに対し、開始位置 'offset' から 'len' バイ
     ト分割り当てるに十分なディスクスペースを確保します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: os.posix_fadvise (fd, offset, len, advice, /)

     データへアクセスする意思を、パターンを指定して宣言します。これによ
     りカーネルが最適化を行えるようになります。'advice' は 'fd' で指定さ
     れたファイルに対し、開始位置 'offset' から 'len' バイト分の領域に適
     用されます。'advice' には *note POSIX_FADV_NORMAL: 2aba.、*note
     POSIX_FADV_SEQUENTIAL: 2abb.、*note POSIX_FADV_RANDOM: 2abc.、*note
     POSIX_FADV_NOREUSE: 2abd.、*note POSIX_FADV_WILLNEED: 2abe.、または
     *note POSIX_FADV_DONTNEED: 2abf. のいずれか一つを指定します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- データ: os.POSIX_FADV_NORMAL
 -- データ: os.POSIX_FADV_SEQUENTIAL
 -- データ: os.POSIX_FADV_RANDOM
 -- データ: os.POSIX_FADV_NOREUSE
 -- データ: os.POSIX_FADV_WILLNEED
 -- データ: os.POSIX_FADV_DONTNEED

     *note posix_fadvise(): d60. において、使われるであろうアクセスパタ
     ーンを指定する 'advice' に使用できるフラグです。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: os.pread (fd, n, offset, /)

     ファイル記述子の位置 'offset' から最大で 'n' バイトを読み出します。
     ファイルオフセットは変化しません。

     読み込んだバイト分のバイト列を返します。 'fd' が参照しているファイ
     ルの終端に達した場合、空のバイト列が返されます。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: os.posix_openpt (oflag, /)

     Open and return a file descriptor for a master pseudo-terminal
     device.

     Calls the C standard library function ‘posix_openpt()’.  The
     'oflag' argument is used to set file status flags and file access
     modes as specified in the manual page of ‘posix_openpt()’ of your
     system.

     The returned file descriptor is *note non-inheritable: ec4.  If the
     value *note O_CLOEXEC: 1051. is available on the system, it is
     added to 'oflag'.

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.13.

 -- の関数: os.preadv (fd, buffers, offset, flags=0, /)

     ファイル記述子 'fd' の 'offset' の位置から、可変な *note bytes-like
     オブジェクト: cfb. 'buffers' にオフセットを変更せずに読み込みます。
     データをそれぞれのバッファがいっぱいになるまで移し、いっぱいになっ
     たらシーケンスの次のバッファに処理を移し、残りのデータを読み込ませ
     ます。

     flags 引数にはゼロあるいは次のフラグのバイトごとの OR を取った結果
     が保持されています。

        - *note RWF_HIPRI: 2ac0.

        - *note RWF_NOWAIT: 2ac1.

     実際に読み込んだ合計バイト数を返します。この値は、すべてのオブジェ
     クトの容量の総量よりも小さくなることがあります。

     オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
     (*note sysconf(): 2ac2. の ‘'SC_IOV_MAX'’ の値) を設定することがあ
     ります。

     *note os.readv(): b2c. と *note os.pread(): b2d. の機能を統合します
     。

     *note Availability: 1cbe.: Linux >= 2.6.30, FreeBSD >= 6.0, OpenBSD
     >= 2.7, AIX >= 7.1.

     Using flags requires Linux >= 4.6.

     Added in version 3.7.

 -- データ: os.RWF_NOWAIT

     即座に利用できないデータを待ちません。このフラグを指定すると、バッ
     クエンドのストレージからデータを読む必要があるか、ロックを待機する
     場合、システムコールは即座にリターンします。

     If some data was successfully read, it will return the number of
     bytes read.  If no bytes were read, it will return ‘-1’ and set
     errno to *note errno.EAGAIN: 21fa.

     *note Availability: 1cbe.: Linux >= 4.14.

     Added in version 3.7.

 -- データ: os.RWF_HIPRI

     優先度の高い読み込み・書き込み (read/write) フラグです。ブロックス
     トレージに対して、追加のリソースを必要とする一方で低レイテンシなデ
     バイスのポーリングを使うことを許可します。

     現状、Linuxでは、ファイル記述子を *note O_DIRECT: 2ab5. フラグを指
     定したオープンした場合でのみ、この機能を利用できます。

     *note Availability: 1cbe.: Linux >= 4.6.

     Added in version 3.7.

 -- の関数: os.ptsname (fd, /)

     Return the name of the slave pseudo-terminal device associated with
     the master pseudo-terminal device to which the file descriptor 'fd'
     refers.  The file descriptor 'fd' is not closed upon failure.

     Calls the reentrant C standard library function ‘ptsname_r()’ if it
     is available; otherwise, the C standard library function
     ‘ptsname()’, which is not guaranteed to be thread-safe, is called.

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.13.

 -- の関数: os.pwrite (fd, str, offset, /)

     'str' 中のバイト文字列をファイル記述子 'fd' の 'offset' の位置に書
     き込みます。ファイルオフセットを変化しません。

     実際に書き込まれたバイト数を返します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: os.pwritev (fd, buffers, offset, flags=0, /)

     Write the 'buffers' contents to file descriptor 'fd' at an offset
     'offset', leaving the file offset unchanged.  'buffers' must be a
     sequence of *note bytes-like objects: cfb.  Buffers are processed
     in array order.  Entire contents of the first buffer is written
     before proceeding to the second, and so on.

     flags 引数にはゼロあるいは次のフラグのバイトごとの OR を取った結果
     が保持されています。

        - *note RWF_DSYNC: 2ac3.

        - *note RWF_SYNC: 2ac4.

        - *note RWF_APPEND: 18b0.

     実際に書き込まれた合計バイト数を返します。

     オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
     (*note sysconf(): 2ac2. の ‘'SC_IOV_MAX'’ の値) を設定することがあ
     ります。

     *note os.writev(): b2f. と *note os.pwrite(): b30. の機能を統合しま
     す。

     *note Availability: 1cbe.: Linux >= 2.6.30, FreeBSD >= 6.0, OpenBSD
     >= 2.7, AIX >= 7.1.

     Using flags requires Linux >= 4.6.

     Added in version 3.7.

 -- データ: os.RWF_DSYNC

     書き込みごとに *note os.open(): d5f. の *note O_DSYNC: 2aa9. と同等
     の効果を提供するフラグです。このフラグはシステムコールによって書き
     込まれたデータ範囲に対してのみ適用されます。

     *note Availability: 1cbe.: Linux >= 4.7.

     Added in version 3.7.

 -- データ: os.RWF_SYNC

     書き込みごとに *note os.open(): d5f. の *note O_SYNC: 2aab. と同等
     の効果を提供するフラグです。このフラグはシステムコールによって書き
     込まれたデータ範囲に対してのみ適用されます。

     *note Availability: 1cbe.: Linux >= 4.7.

     Added in version 3.7.

 -- データ: os.RWF_APPEND

     Provide a per-write equivalent of the *note O_APPEND: 2aa6. *note
     os.open(): d5f. flag.  This flag is meaningful only for *note
     os.pwritev(): b2e, and its effect applies only to the data range
     written by the system call.  The 'offset' argument does not affect
     the write operation; the data is always appended to the end of the
     file.  However, if the 'offset' argument is ‘-1’, the current file
     'offset' is updated.

     *note Availability: 1cbe.: Linux >= 4.16.

     Added in version 3.10.

 -- の関数: os.read (fd, n, /)

     ファイル記述子 'fd' から 最大 'n' バイトを読み込みます。

     読み込んだバイト分のバイト列を返します。 'fd' が参照しているファイ
     ルの終端に達した場合、空のバイト列が返されます。

          注釈: この関数は低水準の I/O 向けのもので、 *note os.open():
          d5f. や *note pipe(): 1745. が返すファイル記述子に対して使用さ
          れなければなりません。 組み込み関数 *note open(): 4e5. や
          *note popen(): a55. 、 *note fdopen(): 1e92. 、あるいは *note
          sys.stdin: 507. が返す "ファイルオブジェクト" を読み込むには、
          オブジェクトの ‘read()’ か ‘readline()’ メソッドを使用してくだ
          さい。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、この関数は *note InterruptedError: d55. 例
     外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(4) を参照してください)。

 -- の関数: os.sendfile (out_fd, in_fd, offset, count)

 -- の関数: os.sendfile (out_fd, in_fd, offset, count, headers=(),
          trailers=(), flags=0)

     ファイル記述子 'in_fd' からファイル記述子 'out_fd' への開始位置
     'offset' へ 'count' バイトコピーします。 送信バイト数を返します。
     EOF に達した場合は ‘0’ を返します。

     前者の関数表記は *note sendfile(): add. が定義されているすべてのプ
     ラットフォームでサポートされています。

     Linux では、'offset' に ‘None’ が与えられると、バイト列は 'in_fd' の
     現在の位置から読み込まれ、'in_fd' の位置は更新されます。

     後者は macOS および FreeBSD で使用される場合があります。'headers' お
     よび 'trailers' は任意のバッファのシーケンス型オブジェクトで、
     'in_fd' からのデータが書き出される前と後に書き出されます。返り値は
     前者と同じです。

     macOS と FreeBSD では、'count' の値に ‘0’ を指定すると、 'in_fd' の
     末尾に達するまで送信します。

     全てのプラットフォームはソケットをファイル記述子 'out_fd' としてサ
     ポートし、あるプラットフォームは他の種類 (例えば、通常のファイル、
     パイプ) も同様にサポートします。

     クロスプラットフォームのアプリケーションは 'headers'、'trailers' な
     らびに 'flags' 引数を使用するべきではありません。

     *note Availability: 1cbe.: Unix, not WASI.

          注釈: *note sendfile(): add. のより高水準のラッパについては
          *note socket.socket.sendfile(): e26. を参照してください。

     Added in version 3.3.

     バージョン 3.9 で変更: 引数 'out' と 'in' は 'out_fd' と 'in_fd' に
     名前が変更されました。

 -- データ: os.SF_NODISKIO
 -- データ: os.SF_MNOWAIT
 -- データ: os.SF_SYNC

     実装がサポートしている場合 *note sendfile(): add. 関数に渡すパラメ
     ーターです。

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.3.

 -- データ: os.SF_NOCACHE

     Parameter to the *note sendfile(): add. function, if the
     implementation supports it.  The data won't be cached in the
     virtual memory and will be freed afterwards.

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.11.

 -- の関数: os.set_blocking (fd, blocking, /)

     指定されたファイル記述子のブロッキングモードを設定します。 ブロッキ
     ングが ‘False’ の場合 *note O_NONBLOCK: e08. フラグを設定し、そうで
     ない場合はクリアします。

     *note get_blocking(): e06. および *note
     socket.socket.setblocking(): 2a9b. も参照してください。

     *note Availability: 1cbe.: Unix, Windows.

     The function is limited on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

     On Windows, this function is limited to pipes.

     Added in version 3.5.

     バージョン 3.12 で変更: Added support for pipes on Windows.

 -- の関数: os.splice (src, dst, count, offset_src=None,
          offset_dst=None)

     Transfer 'count' bytes from file descriptor 'src', starting from
     offset 'offset_src', to file descriptor 'dst', starting from offset
     'offset_dst'.  At least one of the file descriptors must refer to a
     pipe.  If 'offset_src' is ‘None’, then 'src' is read from the
     current position; respectively for 'offset_dst'.  The offset
     associated to the file descriptor that refers to a pipe must be
     ‘None’.  The files pointed to by 'src' and 'dst' must reside in the
     same filesystem, otherwise an *note OSError: 3f0. is raised with
     *note errno: 21e9. set to *note errno.EXDEV: 2a99.

     このコピーは、カーネルからユーザースペースにデータを転送した後カー
     ネルに戻すという追加のコスト無しに完了します。 加えて、追加の最適化
     ができるファイルシステムもあります。 このコピーはファイルが両方とも
     バイナリファイルとして開かれたかのように行われます。

     Upon successful completion, returns the number of bytes spliced to
     or from the pipe.  A return value of 0 means end of input.  If
     'src' refers to a pipe, then this means that there was no data to
     transfer, and it would not make sense to block because there are no
     writers connected to the write end of the pipe.

     *note Availability: 1cbe.: Linux >= 2.6.17 with glibc >= 2.5

     Added in version 3.10.

 -- データ: os.SPLICE_F_MOVE
 -- データ: os.SPLICE_F_NONBLOCK
 -- データ: os.SPLICE_F_MORE

     Added in version 3.10.

 -- の関数: os.readv (fd, buffers, /)

     Read from a file descriptor 'fd' into a number of mutable *note
     bytes-like objects: cfb. 'buffers'.  Transfer data into each buffer
     until it is full and then move on to the next buffer in the
     sequence to hold the rest of the data.

     実際に読み込んだ合計バイト数を返します。この値は、すべてのオブジェ
     クトの容量の総量よりも小さくなることがあります。

     オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
     (*note sysconf(): 2ac2. の ‘'SC_IOV_MAX'’ の値) を設定することがあ
     ります。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: os.tcgetpgrp (fd, /)

     'fd' (*note os.open(): d5f. が返すオープンしたファイル記述子 ) で与
     えられる端末に関連付けられたプロセスグループを返します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.tcsetpgrp (fd, pg, /)

     'fd' (*note os.open(): d5f. が返すオープンしたファイル記述子 ) で与
     えられる端末に関連付けられたプロセスグループを 'pg' に設定します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.ttyname (fd, /)

     ファイル記述子 'fd' に関連付けられている端末デバイスを特定する文字
     列を返します。 'fd' が端末に関連付けられていない場合、例外が送出さ
     れます。

     *note Availability: 1cbe.: Unix.

 -- の関数: os.unlockpt (fd, /)

     Unlock the slave pseudo-terminal device associated with the master
     pseudo-terminal device to which the file descriptor 'fd' refers.
     The file descriptor 'fd' is not closed upon failure.

     Calls the C standard library function ‘unlockpt()’.

     *note Availability: 1cbe.: Unix, not WASI.

     Added in version 3.13.

 -- の関数: os.write (fd, str, /)

     'str' のバイト列をファイル記述子 'fd' に書き出します。

     実際に書き込まれたバイト数を返します。

          注釈: この関数は低水準の I/O 向けのもので、 *note os.open():
          d5f. や *note pipe(): 1745. が返すファイル記述子に対して使用し
          なければなりません。 組み込み関数 *note open(): 4e5. や *note
          popen(): a55. 、 *note fdopen(): 1e92. 、あるいは *note
          sys.stdout: aa4. や *note sys.stderr: 907. が返す "ファイルオ
          ブジェクト" に書き込むには、オブジェクトの ‘write()’ メソッド
          を使用してください。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、この関数は *note InterruptedError: d55. 例
     外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(5) を参照してください)。

 -- の関数: os.writev (fd, buffers, /)

     'buffers' の内容をファイル記述子 'fd' へ書き出します。 'buffers' は
     *note bytes-like オブジェクト: cfb. のシーケンスでなければなりませ
     ん。バッファは配列の順番で処理されます。最初のバッファの内容全体は
     2 番目のバッファに進む前に書き込まれ、その次も同様です。

     実際に書き込まれた合計バイト数を返します。

     オペレーティングシステムは、使用可能なバッファの個数に基づいて上限
     (*note sysconf(): 2ac2. の ‘'SC_IOV_MAX'’ の値) を設定することがあ
     ります。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

* Menu:

* ターミナルのサイズの問い合わせ::
* ファイル記述子の継承::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/

   (2) https://manpages.debian.org/open(2)

   (3) https://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx

   (4) https://peps.python.org/pep-0475/

   (5) https://peps.python.org/pep-0475/


File: python.info,  Node: ターミナルのサイズの問い合わせ,  Next: ファイル記述子の継承,  Up: ファイル記述子の操作

5.16.1.6 ターミナルのサイズの問い合わせ
.......................................

Added in version 3.3.

 -- の関数: os.get_terminal_size (fd=STDOUT_FILENO, /)

     ターミナル (端末) のサイズ ‘(columns, lines)’ を、*note
     terminal_size: 27d3. 型のタプルで返します。

     オプションの引数 ‘fd’ には問い合わせるファイル記述子を指定します (デ
     フォルトは ‘STDOUT_FILENO’、または標準出力)。

     ファイル記述子が接続されていなかった場合、 *note OSError: 3f0. が送
     出されます。

     通常は高水準関数である *note shutil.get_terminal_size(): 10d6. を使
     用してください。‘os.get_terminal_size’ は低水準の実装です。

     *note Availability: 1cbe.: Unix, Windows.

 -- クラス: os.terminal_size

     ターミナルウィンドウのサイズ ‘(columns, lines)’ を保持するタプルの
     サブクラスです。

      -- の属性: columns

          ターミナルウィンドウの横幅 (文字数) です。

      -- の属性: lines

          ターミナルウィンドウの高さ (文字数) です。


File: python.info,  Node: ファイル記述子の継承,  Prev: ターミナルのサイズの問い合わせ,  Up: ファイル記述子の操作

5.16.1.7 ファイル記述子の継承
.............................

Added in version 3.4.

ファイル記述子には「継承可能 (inheritable)」フラグというものがあって、こ
れにより子プロセスにファイル記述子が引き継がれるかどうかが決定されます。
Python 3.4 より、 Python によって作成されるファイル記述子はデフォルトで
継承不可 (non-inheritable) となりました。

UNIX の場合、継承不可のファイル記述子は新規プロセス実行時にクローズされ
、そうでないファイル記述子は引き継がれます。

Windows の場合は、標準ストリームを除き、継承不可のハンドルと継承不可のフ
ァイル記述子は子プロセスでクローズされます。標準ストリーム (ファイル記述
子の 0, 1, 2: 標準入力, 標準出力, 標準エラー出力) は常に引き継がれます。
*note spawn*: 1699. 関数を使う場合、全ての継承可能なハンドルと全ての継承
可能なファイル記述子は引き継がれます。 *note subprocess: c1. モジュール
を使う場合、標準ストリームを除く全てのファイル記述子はクローズされ、継承
可能なハンドルは 'close_fds' 引数が ‘False’ の場合にのみ引き継がれます。

On WebAssembly platforms, the file descriptor cannot be modified.

 -- の関数: os.get_inheritable (fd, /)

     指定したファイル記述子の「継承可能 (inheritable)」フラグを取得しま
     す (boolean)。

 -- の関数: os.set_inheritable (fd, inheritable, /)

     指定したファイル記述子の「継承可能 (inheritable)」フラグをセットし
     ます。

 -- の関数: os.get_handle_inheritable (handle, /)

     指定したハンドルの「継承可能 (inheritable)」フラグを取得します
     (boolean)。

     *note Availability: 1cbe.: Windows.

 -- の関数: os.set_handle_inheritable (handle, inheritable, /)

     指定したハンドルの「継承可能 (inheritable)」フラグをセットします。

     *note Availability: 1cbe.: Windows.


File: python.info,  Node: ファイルとディレクトリ,  Next: プロセス管理,  Prev: ファイル記述子の操作,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.8 ファイルとディレクトリ
...............................

一部の Unix プラットフォームでは、このセクションの関数の多くが以下の機能
を一つ以上サポートしています。

   * 'ファイル記述子の指定:' *note os: 91. モジュールの関数で 'path' 引
     数に渡される値はファイルパスでなければなりません。しかしながら、い
     くつかの関数では 'path' 引数にファイルパスではなく、そのファイルを
     オープンしたファイル記述子を指定できるようになりました。この場合そ
     れらの関数はファイル記述子が参照するファイルに対して操作を行います
     。 (POSIX システムの場合、 Python はプレフィックス ‘f’ の付いた関数
     の亜種 (たとえば ‘chdir``の代わりに ``fchdir’) を呼び出します。)

     *note os.supports_fd: 10d0. を使うことで、そのプラットフォーム上で
     'path' にファイル記述子を指定できるかどうかを確認することができます
     。この機能が利用可能でない場合、 *note os.supports_fd: 10d0. の利用
     は *note NotImplementedError: 209. 例外を送出します。

     その関数が引数に 'dir_fd' または 'follow_symlinks' もサポートしてい
     る場合、'path' にファイル記述子を指定した時にそれらのいずれかを指定
     するとエラーになります。

   * 'ディレクトリ記述子からの相対パス:' 'dir_fd' が ‘None’ でない場合、
     その値はディレクトリを参照するファイル記述子である必要があり、また
     操作対象のファイルパスは相対パスである必要があります; このときパス
     はファイル記述子が指すディレクトリからの相対パスと解釈されます。パ
     スが絶対パスの場合、 'dir_fd' は無視されます。 (POSIX システムでは
     、 Python はサフィックス ‘at’ が付いた関数の亜種、もしくはさらにプ
     レフィックス ‘f’ が付いたもの (たとえば ‘access’ の代わりに
     ‘faccessat’) を呼び出します。

     そのプラットフォーム上で特別な関数に 'dir_fd' がサポートされている
     かどうかは、*note os.supports_dir_fd: 10ca. で確認できます。利用で
     きない場合 *note NotImplementedError: 209. が送出されます。

   * 'シンボリックリンクをたどらない:' 'follow_symlinks' が ‘False’ で、
     かつパスの末尾の要素がシンボリックリンクの場合、関数はシンボリック
     リンクが指すファイルではなくシンボリックリンク自身を操作対象としま
     す。 (POSIX システムの場合、 Python はプレフィックス ‘l...’ 付きの
     関数の亜種を呼び出します。)

     そのプラットフォーム上で特別な関数に 'follow_symlinks' がサポートさ
     れているかどうかは、*note os.supports_follow_symlinks: 10cb. で確認
     できます。利用できない場合 *note NotImplementedError: 209. が送出さ
     れます。

 -- の関数: os.access (path, mode, *, dir_fd=None, effective_ids=False,
          follow_symlinks=True)

     実 uid/gid を使って 'path' に対するアクセスが可能か調べます。ほとん
     どのオペレーティングシステムは実効 uid/gid を使うため、このルーチン
     は suid/sgid 環境において、プログラムを起動したユーザーが 'path' に
     対するアクセス権をもっているかを調べるために使われます。 'path' が
     存在するかどうかを調べるには 'mode' を *note F_OK: 2ad5. にします。
     ファイルアクセス権限 ( パーミッション ) を調べるには、 *note R_OK:
     2ad6, *note W_OK: 2ad7, *note X_OK: 2ad8. から一つまたはそれ以上の
     フラグを論理和指定でとることもできます。アクセスが許可されている場
     合 *note True: bdb. を、そうでない場合 *note False: b05. を返します
     。詳細は ‘access(2)(1)’ の Unix マニュアルページを参照してください
     。

     この関数は *note ディレクトリ記述子への相対パス: 10c8. および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     'effective_ids' が ‘True’ の場合、*note access(): 10bd. は実
     uid/gid ではなく実効 uid/gid を使用してアクセス権を調べます。プラッ
     トフォームによっては 'effective_ids' がサポートされていない場合があ
     ります; サポートされているかどうかは *note
     os.supports_effective_ids: 10d1. で確認できます。利用できない場合
     *note NotImplementedError: 209. が送出されます。

          注釈: ユーザーが、例えばファイルを開く権限を持っているかどうか
          を調べるために実際に *note open(): 4e5. を行う前に *note
          access(): 10bd. を使用することはセキュリティホールの原因になり
          ます。なぜなら、調べた時点とオープンした時点との時間差を利用し
          てそのユーザーがファイルを不当に操作してしまうかもしれないから
          です。その場合は *note EAFP: 2ad9. テクニックを利用するのが望
          ましいやり方です。例えば

               if os.access("myfile", os.R_OK):
                   with open("myfile") as fp:
                       return fp.read()
               return "some default data"

          このコードは次のように書いたほうが良いです

               try:
                   fp = open("myfile")
               except PermissionError:
                   return "some default data"
               else:
                   with fp:
                       return fp.read()

          注釈: I/O 操作は *note access(): 10bd. が成功を示した時でも失
          敗することがあります。特にネットワークファイルシステムが通常の
          POSIX のパーミッションビットモデルをはみ出すアクセス権限操作を
          備える場合にはそのようなことが起こりえます。

     バージョン 3.3 で変更: 引数 'dir_fd'、'effective_ids'、および
     'follow_symlinks' が追加されました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- データ: os.F_OK
 -- データ: os.R_OK
 -- データ: os.W_OK
 -- データ: os.X_OK

     *note access(): 10bd. で 'path' をテストする時に 'mode' 引数に渡す
     値です。上からそれぞれ、ファイルの存在、読み込み許可、書き込み許可
     、および実行許可になります。

 -- の関数: os.chdir (path)

     現在の作業ディレクトリを 'path' に設定します。

     この関数は *note ファイル記述子の指定: b2a. をサポートしています。
     記述子は、オープンしているファイルではなく、オープンしているディレ
     クトリを参照していなければなりません。

     この関数は *note OSError: 3f0. やそのサブクラスである *note
     FileNotFoundError: e8f, *note PermissionError: d10, *note
     NotADirectoryError: 102e. などの例外を送出することがあります。

     引数 ‘path’ を指定して *note 監査イベント: 1825. ‘os.chdir’ を送出
     します。

     バージョン 3.3 で変更: 一部のプラットフォームで、'path' にファイル
     記述子の指定をサポートしました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.chflags (path, flags, *, follow_symlinks=True)

     'path' のフラグを 'flags' に変更します。 'flags' は、以下の値
     (*note stat: bc. モジュールで定義されているもの ) をビット単位の論
     理和で組み合わせることができます :

        * *note stat.UF_NODUMP: 2765.

        * *note stat.UF_IMMUTABLE: 2766.

        * *note stat.UF_APPEND: 2767.

        * *note stat.UF_OPAQUE: 2768.

        * *note stat.UF_NOUNLINK: 2769.

        * *note stat.UF_COMPRESSED: 276a.

        * *note stat.UF_HIDDEN: 276d.

        * *note stat.SF_ARCHIVED: 2771.

        * *note stat.SF_IMMUTABLE: 2772.

        * *note stat.SF_APPEND: 2773.

        * *note stat.SF_NOUNLINK: 2775.

        * *note stat.SF_SNAPSHOT: 2776.

     この関数は *note シンボリックリンクをたどらない: 10c9. をサポートし
     ています。

     引数 ‘path’, ‘flags’ を指定して *note 監査イベント: 1825.
     ‘os.chflags’ を送出します。

     *note Availability: 1cbe.: Unix, not WASI.

     バージョン 3.3 で変更: Added the 'follow_symlinks' parameter.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.chmod (path, mode, *, dir_fd=None, follow_symlinks=True)

     'path' のモードを数値 'mode' に変更します。 'mode' は、 (*note
     stat: bc. モジュールで定義されている ) 以下の値のいずれかまたはビッ
     ト単位の論理和で組み合わせた値を取り得ます :

        * *note stat.S_ISUID: 2751.

        * *note stat.S_ISGID: 2752.

        * *note stat.S_ENFMT: 2754.

        * *note stat.S_ISVTX: 2755.

        * *note stat.S_IREAD: 2761.

        * *note stat.S_IWRITE: 2762.

        * *note stat.S_IEXEC: 2763.

        * *note stat.S_IRWXU: 2756.

        * *note stat.S_IRUSR: 2757.

        * *note stat.S_IWUSR: 2758.

        * *note stat.S_IXUSR: 2759.

        * *note stat.S_IRWXG: 275a.

        * *note stat.S_IRGRP: 275b.

        * *note stat.S_IWGRP: 275c.

        * *note stat.S_IXGRP: 2753.

        * *note stat.S_IRWXO: 275d.

        * *note stat.S_IROTH: 275e.

        * *note stat.S_IWOTH: 275f.

        * *note stat.S_IXOTH: 2760.

     この関数は *note ファイル記述子の指定: b2a. 、 *note
     ディレクトリ記述子への相対パス: 10c8. 、および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

          注釈: Although Windows supports *note chmod(): 1fc, you can
          only set the file's read-only flag with it (via the
          ‘stat.S_IWRITE’ and ‘stat.S_IREAD’ constants or a
          corresponding integer value).  All other bits are ignored.
          The default value of 'follow_symlinks' is ‘False’ on Windows.

          The function is limited on WASI, see *note WebAssembly
          プラットフォーム: 174c. for more information.

     引数 ‘path’, ‘mode’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.chmod’ を送出します。

     バージョン 3.3 で変更: 'path' にオープンしているファイル記述子の指
     定のサポート、および引数 'dir_fd' と 'follow_symlinks' を追加しまし
     た。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.13 で変更: Added support for a file descriptor and the
     'follow_symlinks' argument on Windows.

 -- の関数: os.chown (path, uid, gid, *, dir_fd=None,
          follow_symlinks=True)

     'path' の所有者 id およびグループ id を、数値 'uid' および 'gid' に
     変更します。いずれかの id を変更せずにおくには、その値として -1 を
     指定します。

     この関数は *note ファイル記述子の指定: b2a. 、 *note
     ディレクトリ記述子への相対パス: 10c8. 、および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     数値 id の他に名前でも受け取る高水準関数の *note shutil.chown():
     221. を参照してください。

     引数 ‘path’, ‘uid’, ‘gid’, ‘dir_fd’ を指定して *note 監査イベント:
     1825. ‘os.chown’ を送出します。

     *note Availability: 1cbe.: Unix.

     The function is limited on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

     バージョン 3.3 で変更: 'path' にオープンしているファイル記述子の指
     定のサポート、および引数 'dir_fd' と 'follow_symlinks' を追加しまし
     た。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.chroot (path)

     現在のプロセスのルートディレクトリを 'path' に変更します。

     *note Availability: 1cbe.: Unix, not WASI, not Android.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.fchdir (fd)

     現在の作業ディレクトリをファイル記述子 'fd' が表すディレクトリに変
     更します。記述子はオープンしているファイルではなく、オープンしたデ
     ィレクトリを参照していなければなりません。Python 3.3 以降では
     ‘os.chdir(fd)’ と等価です。

     引数 ‘path’ を指定して *note 監査イベント: 1825. ‘os.chdir’ を送出
     します。

     *note Availability: 1cbe.: Unix.

 -- の関数: os.getcwd ()

     現在の作業ディレクトリを表す文字列を返します。

 -- の関数: os.getcwdb ()

     現在の作業ディレクトリを表すバイト列を返します。

     バージョン 3.8 で変更: この関数は Windows において ANSI コードペー
     ジ ではなく UTF-8 エンコーディングを使うようになりました: 変更の背
     景については PEP 529(2) をご覧ください。この関数は Windows において
     非推奨になりません。

 -- の関数: os.lchflags (path, flags)

     'path' のフラグを数値 'flags' に設定します。*note chflags(): 10be.
     に似ていますが、シンボリックリンクをたどりません。Python 3.3 以降で
     は ‘os.chflags(path, flags, follow_symlinks=False)’ と等価です。

     引数 ‘path’, ‘flags’ を指定して *note 監査イベント: 1825.
     ‘os.chflags’ を送出します。

     *note Availability: 1cbe.: Unix, not WASI.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.lchmod (path, mode)

     'path' のモードを数値 'mode' に変更します。パスがシンボリックリンク
     の場合はそのリンク先ではなくシンボリックリンクそのものに対して作用
     します。'mode' に指定できる値については *note chmod(): 1fc. のドキ
     ュメントを参照してください。Python 3.3 以降では ‘os.chmod(path,
     mode, follow_symlinks=False)’ と等価です。

     ‘lchmod()’ is not part of POSIX, but Unix implementations may have
     it if changing the mode of symbolic links is supported.

     引数 ‘path’, ‘mode’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.chmod’ を送出します。

     *note Availability: 1cbe.: Unix, Windows, not Linux, FreeBSD >=
     1.3, NetBSD >= 1.3, not OpenBSD

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.13 で変更: Added support on Windows.

 -- の関数: os.lchown (path, uid, gid)

     'path' の所有者 id およびグループ id を、数値 'uid' および 'gid' に
     変更します。この関数はシンボリックリンクをたどりません。Python 3.3
     以降では ‘os.chown(path, uid, gid, follow_symlinks=False)’ と等価で
     す。

     引数 ‘path’, ‘uid’, ‘gid’, ‘dir_fd’ を指定して *note 監査イベント:
     1825. ‘os.chown’ を送出します。

     *note Availability: 1cbe.: Unix.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.link (src, dst, *, src_dir_fd=None, dst_dir_fd=None,
          follow_symlinks=True)

     'src' を指し示すハードリンク 'dst' を作成します。

     この関数は 'src_dir_fd' と 'dst_dir_fd' の両方またはどちらかに対し
     *note ディレクトリ記述子への相対パス: 10c8. および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     引数 ‘src’, ‘dst’, ‘src_dir_fd’, ‘dst_dir_fd’ を指定して *note
     監査イベント: 1825. ‘os.link’ を送出します。

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.2 で変更: Windows サポートを追加しました。

     バージョン 3.3 で変更: Added the 'src_dir_fd', 'dst_dir_fd', and
     'follow_symlinks' parameters.

     バージョン 3.6 で変更: 'src' と 'dst' が *note path-like object:
     280. を受け付けるようになりました。

 -- の関数: os.listdir (path='.')

     'path' に指定したディレクトリに含まれるエントリ名のリストを返します
     。リストの順番は不定です。特別なエントリ ‘'.'’ と ‘'..'’ はリストに
     含まれません。この関数の呼び出し中にディレクトリからファイルが削除
     されたり、ディレクトリにファイルが追加されたりした場合、それらのフ
     ァイルがリストに含まれるかどうかは不定です。

     'path' に *note path-like オブジェクト: 280. を指定することもできま
     す。 'path' が (直接的または間接的に *note PathLike: c1f. インター
     フェースを介した) ‘bytes’ 型の場合、戻り値のファイル名も ‘bytes’ 型
     になります; それ以外の場合、ファイル名は ‘str’ 型です。

     この関数は *note ファイル記述子の指定: b2a. もサポートしています; フ
     ァイル記述子はディレクトリを参照していなくてはなりません。

     引数 ‘path’ を指定して *note 監査イベント: 1825. ‘os.listdir’ を送
     出します。

          注釈: ‘文字列型’ のファイル名を ‘バイト列型’ にエンコードする
          には、*note fsencode(): c23. を使用します。

     参考
     ....

     ディレクトリエントリに加えてファイル属性情報も返す *note scandir():
     a2d. 関数の方が、多くの一般的な用途では使い勝手が良くなります。

     バージョン 3.2 で変更: 引数 'path' は任意になりました。

     バージョン 3.3 で変更: 'path' へのオープン・ファイル記述子の指定を
     サポートしました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.listdrives ()

     Return a list containing the names of drives on a Windows system.

     A drive name typically looks like ‘'C:\\'’.  Not every drive name
     will be associated with a volume, and some may be inaccessible for
     a variety of reasons, including permissions, network connectivity
     or missing media.  This function does not test for access.

     May raise *note OSError: 3f0. if an error occurs collecting the
     drive names.

     Raises an *note auditing event: 1825. ‘os.listdrives’ with no
     arguments.

     *note Availability: 1cbe.: Windows

     Added in version 3.12.

 -- の関数: os.listmounts (volume)

     Return a list containing the mount points for a volume on a Windows
     system.

     'volume' must be represented as a GUID path, like those returned by
     *note os.listvolumes(): 46b.  Volumes may be mounted in multiple
     locations or not at all.  In the latter case, the list will be
     empty.  Mount points that are not associated with a volume will not
     be returned by this function.

     The mount points return by this function will be absolute paths,
     and may be longer than the drive name.

     Raises *note OSError: 3f0. if the volume is not recognized or if an
     error occurs collecting the paths.

     Raises an *note auditing event: 1825. ‘os.listmounts’ with argument
     ‘volume’.

     *note Availability: 1cbe.: Windows

     Added in version 3.12.

 -- の関数: os.listvolumes ()

     Return a list containing the volumes in the system.

     Volumes are typically represented as a GUID path that looks like
     ‘\\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\’.  Files can
     usually be accessed through a GUID path, permissions allowing.
     However, users are generally not familiar with them, and so the
     recommended use of this function is to retrieve mount points using
     *note os.listmounts(): 46c.

     May raise *note OSError: 3f0. if an error occurs collecting the
     volumes.

     Raises an *note auditing event: 1825. ‘os.listvolumes’ with no
     arguments.

     *note Availability: 1cbe.: Windows

     Added in version 3.12.

 -- の関数: os.lstat (path, *, dir_fd=None)

     Perform the equivalent of an ‘lstat()’ system call on the given
     path.  Similar to *note stat(): 46d, but does not follow symbolic
     links.  Return a *note stat_result: 1466. object.

     シンボリックリンクをサポートしていないプラットフォームでは *note
     stat(): 46d. の別名です。

     Python 3.3 以降では ‘os.stat(path, dir_fd=dir_fd,
     follow_symlinks=False)’ と等価です。

     この関数は *note ディレクトリ記述子への相対パス: 10c8. もサポートす
     ることができます。

     参考
     ....

     *note stat(): 46d. 関数。

     バージョン 3.2 で変更: Windows 6.0 (Vista) のシンボリックリンクをサ
     ポートしました。

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.8 で変更: On Windows, now opens reparse points that
     represent another path (name surrogates), including symbolic links
     and directory junctions.  Other kinds of reparse points are
     resolved by the operating system as for *note stat(): 46d.

 -- の関数: os.mkdir (path, mode=0o777, *, dir_fd=None)

     ディレクトリ 'path' を数値モード 'mode' で作成します。

     If the directory already exists, *note FileExistsError: fea. is
     raised.  If a parent directory in the path does not exist, *note
     FileNotFoundError: e8f. is raised.  いくつかのシステムにおいては
     'mode' は無視されます。それが使われる時には、最初に現在の umask 値
     でマスクされます。もし最後の 9 ビット (つまり 'mode' の8進法表記の
     最後の3桁) を除いたビットが設定されていたら、それらの意味はプラット
     フォームに依存します。いくつかのプラットフォームではそれらは無視さ
     れ、それらを設定するためには明示的に *note chmod(): 1fc. を呼ぶ必要
     があるでしょう。

     On Windows, a 'mode' of ‘0o700’ is specifically handled to apply
     access control to the new directory such that only the current user
     and administrators have access.  Other values of 'mode' are
     ignored.

     この関数は *note ディレクトリ記述子への相対パス: 10c8. もサポートす
     ることができます。

     一時ディレクトリを作成することもできます : *note tempfile: c9. モジ
     ュールの *note tempfile.mkdtemp(): 200. 関数を参照してください。

     引数 ‘path’, ‘mode’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.mkdir’ を送出します。

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.13 で変更: Windows now handles a 'mode' of ‘0o700’.

 -- の関数: os.makedirs (name, mode=0o777, exist_ok=False)

     再帰的にディレクトリを作成する関数です。*note mkdir(): 1fe. と似て
     いますが、末端ディレクトリを作成するために必要なすべての中間ディレ
     クトリも作成します。

     The 'mode' parameter is passed to *note mkdir(): 1fe. for creating
     the leaf directory; see *note the mkdir() description: 2adc. for
     how it is interpreted.  To set the file permission bits of any
     newly created parent directories you can set the umask before
     invoking *note makedirs(): 1ff.  The file permission bits of
     existing parent directories are not changed.

     'exist_ok' の値が ‘False’ の場合 (デフォルト)、対象のディレクトリが
     すでに存在すると *note FileExistsError: fea. を送出します。

          注釈: 作成するパス要素に *note pardir: 2add. (UNIX では "..")
          が含まれる場合、*note makedirs(): 1ff. は混乱します。

     この関数は UNC パスを正しく扱えるようになりました。

     引数 ‘path’, ‘mode’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.mkdir’ を送出します。

     バージョン 3.2 で変更: Added the 'exist_ok' parameter.

     バージョン 3.4.1 で変更: Python 3.4.1 より前、 'exist_ok' が ‘True’
     でそのディレクトリが既存の場合でも、 *note makedirs(): 1ff. は
     'mode' が既存ディレクトリのモードと合わない場合にはエラーにしようと
     していました。このモードチェックの振る舞いを安全に実装することが出
     来なかったため、 Python 3.4.1 でこのチェックは削除されました。
     bpo-21082(3) を参照してください。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.7 で変更: The 'mode' argument no longer affects the
     file permission bits of newly created intermediate-level
     directories.

 -- の関数: os.mkfifo (path, mode=0o666, *, dir_fd=None)

     FIFO (名前付きパイプ) 'path' を数値モード 'mode' で作成します。先に
     現在の umask 値でマスクされます。

     この関数は *note ディレクトリ記述子への相対パス: 10c8. もサポートす
     ることができます。

     FIFO は通常のファイルのようにアクセスできるパイプです。 FIFO は ( 例
     えば *note os.unlink(): 10c6. を使って ) 削除されるまで存在しつづけ
     ます。一般的に、 FIFO は " クライアント " と " サーバー " 形式のプ
     ロセス間でランデブーを行うために使われます : この時、サーバーは
     FIFO を読み込み用に、クライアントは書き出し用にオープンします。
     *note mkfifo(): d5d. は FIFO をオープンしない -- 単にランデブーポイ
     ントを作成するだけ -- なので注意してください。

     *note Availability: 1cbe.: Unix, not WASI.

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.mknod (path, mode=0o600, device=0, *, dir_fd=None)

     'path' という名前で、ファイルシステムノード (ファイル、デバイス特殊
     ファイル、または名前つきパイプ) を作成します。'mode' は、作成するノ
     ードのアクセス権限とタイプの両方を ‘stat.S_IFREG’、‘stat.S_IFCHR’、
     ‘stat.S_IFBLK’、および ‘stat.S_IFIFO’ の組み合わせ (ビット単位の論
     理和) で指定します (これらの定数は *note stat: bc. で利用可能です
     )。‘stat.S_IFCHR’ と ‘stat.S_IFBLK’ を指定した場合、'devide' は新し
     く作成されたデバイス特殊ファイルを (おそらく *note os.makedev():
     1580. を使って) 定義し、それ以外の定数を指定した場合は無視されます
     。

     この関数は *note ディレクトリ記述子への相対パス: 10c8. もサポートす
     ることができます。

     *note Availability: 1cbe.: Unix, not WASI.

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.major (device, /)

     Extract the device major number from a raw device number (usually
     the ‘st_dev’ or ‘st_rdev’ field from ‘stat’).

 -- の関数: os.minor (device, /)

     Extract the device minor number from a raw device number (usually
     the ‘st_dev’ or ‘st_rdev’ field from ‘stat’).

 -- の関数: os.makedev (major, minor, /)

     メジャーおよびマイナーデバイス番号から、新しく RAW デバイス番号を作
     成します。

 -- の関数: os.pathconf (path, name)

     名前付きファイルに関連するシステム設定情報を返します。 'name' には
     取得したい設定名を指定します ; これは定義済みのシステム値名の文字列
     で、多くの標準 (POSIX.1 、 Unix 95 、 Unix 98 その他 ) で定義されて
     います。プラットフォームによっては別の名前も定義しています。ホスト
     オペレーティングシステムの関知する名前は ‘pathconf_names’ 辞書で与
     えられています。このマップ型オブジェクトに入っていない設定変数につ
     いては、 'name' に整数を渡してもかまいません。

     'name' が不明の文字列である場合、 *note ValueError: 1e3. を送出しま
     す。 'name' の特定の値がホストシステムでサポートされていない場合、
     ‘pathconf_names’ に含まれていたとしても、 *note errno.EINVAL: 195a.
     をエラー番号として *note OSError: 3f0. を送出します。

     この関数は *note ファイル記述子の指定: b2a. をサポートしています。

     *note Availability: 1cbe.: Unix.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- データ: os.pathconf_names

     *note pathconf(): 10ce. および *note fpathconf(): 2a9a. が受理する
     システム設定名を、ホストオペレーティングシステムで定義されている整
     数値に対応付けている辞書です。この辞書はシステムでどの設定名が定義
     されているかを知るために利用できます。

     *note Availability: 1cbe.: Unix.

 -- の関数: os.readlink (path, *, dir_fd=None)

     シンボリックリンクが指しているパスを表す文字列を返します。返される
     値は絶対パスにも、相対パスにもなり得ます ; 相対パスの場合、
     ‘os.path.join(os.path.dirname(path), result)’ を使って絶対パスに変
     換することができます。

     If the 'path' is a string object (directly or indirectly through a
     *note PathLike: c1f. interface), the result will also be a string
     object, and the call may raise a UnicodeDecodeError.  If the 'path'
     is a bytes object (direct or indirectly), the result will be a
     bytes object.

     この関数は *note ディレクトリ記述子への相対パス: 10c8. もサポートす
     ることができます。

     When trying to resolve a path that may contain links, use *note
     realpath(): 206. to properly handle recursion and platform
     differences.

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.2 で変更: Windows 6.0 (Vista) のシンボリックリンクをサ
     ポートしました。

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: Unixで、 *note path-like object: 280. を受け
     入れるようになりました。

     バージョン 3.8 で変更: Windowsで、 *note path-like object: 280. と
     bytes オブジェクトを受け入れるようになりました。

     Added support for directory junctions, and changed to return the
     substitution path (which typically includes ‘\\?\’ prefix) rather
     than the optional "print name" field that was previously returned.

 -- の関数: os.remove (path, *, dir_fd=None)

     Remove (delete) the file 'path'.  If 'path' is a directory, an
     *note OSError: 3f0. is raised.  Use *note rmdir(): 10c4. to remove
     directories.  If the file does not exist, a *note
     FileNotFoundError: e8f. is raised.

     この関数は *note ディレクトリ記述子への相対パス: 10c8. をサポートし
     ています。

     Windows では、使用中のファイルを削除しようとすると例外を送出します;
     Unixでは、ディレクトリエントリは削除されますが、記憶装置上に割り当
     てられたファイル領域は元のファイルが使われなくなるまで残されます。

     この関数は意味論的に *note unlink(): 10c6. と同一です。

     引数 ‘path’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.remove’ を送出します。

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.removedirs (name)

     再帰的なディレクトリ削除関数です。 *note rmdir(): 10c4. と同じよう
     に動作しますが、末端ディレクトリがうまく削除できるかぎり、 *note
     removedirs(): 2adf. は 'path' に現れる親ディレクトリをエラーが送出
     されるまで ( このエラーは通常、指定したディレクトリの親ディレクトリ
     が空でないことを意味するだけなので無視されます ) 順に削除することを
     試みます。例えば、 ‘os.removedirs('foo/bar/baz')’ では最初にディレ
     クトリ ‘'foo/bar/baz'’ を削除し、次に ‘'foo/bar'’ さらに ‘'foo'’ を
     それらが空ならば削除します。末端のディレクトリが削除できなかった場
     合には *note OSError: 3f0. が送出されます。

     引数 ‘path’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.remove’ を送出します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.rename (src, dst, *, src_dir_fd=None, dst_dir_fd=None)

     Rename the file or directory 'src' to 'dst'.  If 'dst' exists, the
     operation will fail with an *note OSError: 3f0. subclass in a
     number of cases:

     On Windows, if 'dst' exists a *note FileExistsError: fea. is always
     raised.  The operation may fail if 'src' and 'dst' are on different
     filesystems.  Use *note shutil.move(): a2a. to support moves to a
     different filesystem.

     On Unix, if 'src' is a file and 'dst' is a directory or vice-versa,
     an *note IsADirectoryError: 102d. or a *note NotADirectoryError:
     102e. will be raised respectively.  If both are directories and
     'dst' is empty, 'dst' will be silently replaced.  If 'dst' is a
     non-empty directory, an *note OSError: 3f0. is raised.  If both are
     files, 'dst' will be replaced silently if the user has permission.
     The operation may fail on some Unix flavors if 'src' and 'dst' are
     on different filesystems.  If successful, the renaming will be an
     atomic operation (this is a POSIX requirement).

     この関数は 'src_dir_fd' と 'dst_dir_fd' のどちらかまたは両方の指定
     に *note ディレクトリ記述子への相対パス: 10c8. をサポートしています
     。

     対象の上書きがクロスプラットフォームになる場合は *note replace():
     10c3. を使用してください。

     引数 ‘src’, ‘dst’, ‘src_dir_fd’, ‘dst_dir_fd’ を指定して *note
     監査イベント: 1825. ‘os.rename’ を送出します。

     バージョン 3.3 で変更: Added the 'src_dir_fd' and 'dst_dir_fd'
     parameters.

     バージョン 3.6 で変更: 'src' と 'dst' が *note path-like object:
     280. を受け付けるようになりました。

 -- の関数: os.renames (old, new)

     再帰的にディレクトリやファイル名を変更する関数です。 *note
     rename(): 10c2. のように動作しますが、新たなパス名を持つファイルを
     配置するために必要な途中のディレクトリ構造をまず作成しようと試みま
     す。名前変更の後、元のファイル名のパス要素は *note removedirs():
     2adf. を使って右側から順に削除されます。

          注釈: この関数はコピー元の末端のディレクトリまたはファイルを削
          除する権限がない場合には失敗します。

     引数 ‘src’, ‘dst’, ‘src_dir_fd’, ‘dst_dir_fd’ を指定して *note
     監査イベント: 1825. ‘os.rename’ を送出します。

     バージョン 3.6 で変更: 'old' と 'new' が *note path-like object:
     280. を受け付けるようになりました。

 -- の関数: os.replace (src, dst, *, src_dir_fd=None, dst_dir_fd=None)

     ファイルまたはディレクトリ 'src' の名前を 'dst' へ変更します。'dst'
     が空でないディレクトリの場合 *note OSError: 3f0. が送出されます。
     'dst' が存在し、かつファイルの場合、ユーザーの権限がある限り暗黙の
     うちに置き換えられます。'src' と 'dst' が異なるファイルシステム上に
     あると失敗することがあります。ファイル名の変更が成功する場合はアト
     ミック操作となります (これは POSIX 要求仕様です)。

     この関数は 'src_dir_fd' と 'dst_dir_fd' のどちらかまたは両方の指定
     に *note ディレクトリ記述子への相対パス: 10c8. をサポートしています
     。

     引数 ‘src’, ‘dst’, ‘src_dir_fd’, ‘dst_dir_fd’ を指定して *note
     監査イベント: 1825. ‘os.rename’ を送出します。

     Added in version 3.3.

     バージョン 3.6 で変更: 'src' と 'dst' が *note path-like object:
     280. を受け付けるようになりました。

 -- の関数: os.rmdir (path, *, dir_fd=None)

     Remove (delete) the directory 'path'.  If the directory does not
     exist or is not empty, a *note FileNotFoundError: e8f. or an *note
     OSError: 3f0. is raised respectively.  In order to remove whole
     directory trees, *note shutil.rmtree(): 2d8. can be used.

     この関数は *note ディレクトリ記述子への相対パス: 10c8. をサポートし
     ています。

     引数 ‘path’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.rmdir’ を送出します。

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.scandir (path='.')

     Return an iterator of *note os.DirEntry: 468. objects corresponding
     to the entries in the directory given by 'path'.  The entries are
     yielded in arbitrary order, and the special entries ‘'.'’ and
     ‘'..'’ are not included.  If a file is removed from or added to the
     directory after creating the iterator, whether an entry for that
     file be included is unspecified.

     *note listdir(): 10cd. の代わりに *note scandir(): a2d. を使用する
     と、ファイルタイプや属性情報も必要とするコードのパフォーマンスが大
     幅に向上します。これは、オペレーティングシステムがディレクトリのス
     キャン中にこの情報を提供した場合、*note os.DirEntry: 468. オブジェ
     クトがその情報を公開するからです。すべての *note os.DirEntry: 468.
     メソッドはシステムコールを実行する場合がありますが、*note is_dir():
     2ae1. と *note is_file(): d51. は、通常はシンボリックリンクにしかシ
     ステムコールを必要としません。*note os.DirEntry.stat(): 165f. は、
     Unix 上では常にシステムコールを必要としますが、Windows ではシンボリ
     ックリンク用にシステムコールを一つ必要とするだけです。

     'path' may be a *note path-like object: 280.  If 'path' is of type
     ‘bytes’ (directly or indirectly through the *note PathLike: c1f.
     interface), the type of the *note name: 2ae2. and *note path: 15e0.
     attributes of each *note os.DirEntry: 468. will be ‘bytes’; in all
     other circumstances, they will be of type ‘str’.

     この関数は *note ファイル記述子の指定: b2a. もサポートしています; フ
     ァイル記述子はディレクトリを参照していなくてはなりません。

     引数 ‘path’ を指定して *note 監査イベント: 1825. ‘os.scandir’ を送
     出します。

     *note scandir(): a2d. イテレータは、 *note コンテキストマネージャ:
     59e. プロトコルをサポートし、次のメソッドを持ちます。

      -- メソッド: scandir.close ()

          イテレータを閉じ、獲得した資源を開放します。

          この関数は、イテレータがすべて消費されるか、ガーベージコレクト
          された、もしくはイテレート中にエラーが発生した際に自動的に呼び
          出されます。しかし、 *note with: 59c. 文を用いるか、明示的に呼
          び出すことを推奨します。

          Added in version 3.6.

     次の単純な例では、*note scandir(): a2d. を使用して、指定した 'path'
     内の先頭が ‘'.'’ でないすべてのファイル (ディレクトリを除く) をすべ
     て表示します。‘entry.is_file()’ を呼び出しても、通常は追加のシステ
     ムコールは行われません:

          with os.scandir(path) as it:
              for entry in it:
                  if not entry.name.startswith('.') and entry.is_file():
                      print(entry.name)

          注釈: On Unix-based systems, *note scandir(): a2d. uses the
          system's opendir()(4) and readdir()(5) functions.  On Windows,
          it uses the Win32 FindFirstFileW(6) and FindNextFileW(7)
          functions.

     Added in version 3.5.

     バージョン 3.6 で変更: Added support for the *note context manager:
     59e. protocol and the *note close(): c8a. method.  If a *note
     scandir(): a2d. iterator is neither exhausted nor explicitly closed
     a *note ResourceWarning: 225. will be emitted in its destructor.

     関数が *note path-like object: 280. を受け入れるようになりました。

     バージョン 3.7 で変更: Unix で *note ファイル記述子の指定: b2a. の
     サポートが追加されました。

 -- クラス: os.DirEntry

     ディレクトリエントリのファイルパスとその他のファイル属性を公開する
     ために、*note scandir(): a2d. が yield するオブジェクトです。

     *note scandir(): a2d. は、追加のシステムコールを実行することなく、
     この情報をできるだけ多く提供します。‘stat()’ または ‘lstat()’ シス
     テムコールが実行された場合、‘os.DirEntry’ オブジェクトは結果をキャ
     ッシュします。

     ‘os.DirEntry’ インスタンスは、寿命の長いデータ構造に保存されること
     は想定されていません。ファイルメタデータが変更された場合や、 *note
     scandir(): a2d. が呼び出されてから長時間が経過した場合は、
     ‘os.stat(entry.path)’ を呼び出して最新の情報を取得してください。

     ‘os.DirEntry’ のメソッドはオペレーティングシステムコールを実行する
     場合があるため、それらは *note OSError: 3f0. も送出する場合がありま
     す。エラーを細かく制御する必要がある場合、 ‘os.DirEntry’ のメソッド
     の一つの呼び出し時に *note OSError: 3f0. を捕捉して、適切な処理を行
     うことができます。

     To be directly usable as a *note path-like object: 280,
     ‘os.DirEntry’ implements the *note PathLike: c1f. interface.

     ‘os.DirEntry’ インスタンスの属性とメソッドは以下の通りです:

      -- の属性: name

          *note scandir(): a2d. の 'path' 引数に対して相対的な、エントリ
          のベースファイル名です。

          The *note name: 2a60. attribute will be ‘bytes’ if the *note
          scandir(): a2d. 'path' argument is of type ‘bytes’ and ‘str’
          otherwise.  Use *note fsdecode(): c22. to decode byte
          filenames.

      -- の属性: path

          The entry's full path name: equivalent to
          ‘os.path.join(scandir_path, entry.name)’ where 'scandir_path'
          is the *note scandir(): a2d. 'path' argument.  The path is
          only absolute if the *note scandir(): a2d. 'path' argument was
          absolute.  If the *note scandir(): a2d. 'path' argument was a
          *note file descriptor: b2a, the *note path: 92. attribute is
          the same as the *note name: 2a60. attribute.

          The *note path: 92. attribute will be ‘bytes’ if the *note
          scandir(): a2d. 'path' argument is of type ‘bytes’ and ‘str’
          otherwise.  Use *note fsdecode(): c22. to decode byte
          filenames.

      -- メソッド: inode ()

          項目の inode 番号を返します。

          結果は ‘os.DirEntry’ オブジェクトにキャッシュされます。最新の
          情報を取得するには ‘os.stat(entry.path,
          follow_symlinks=False).st_ino’ を使用してください。

          Windows 上では、最初のキャッシュされていない呼び出しでシステム
          コールが必要ですが、 Unix 上では必要ありません。

      -- メソッド: is_dir (*, follow_symlinks=True)

          この項目がディレクトリまたはディレクトリへのシンボリックリンク
          である場合、 ‘True’ を返します。項目がそれ以外のファイルやそれ
          以外のファイルへのシンボリックリンクである場合や、もはや存在し
          ない場合は ‘False’ を返します。

          'follow_symlinks' が ‘False’ の場合、項目がディレクトリ (シン
          ボリックリンクはたどりません) の場合にのみ ‘True’ を返します。
          項目がディレクトリ以外のファイルである場合や、項目がもはや存在
          しない場合は ‘False’ を返します。

          結果は ‘os.DirEntry’ オブジェクトにキャッシュされます。
          'follow_symlinks' が ‘True’ の場合と ‘False’ の場合とでは、別
          のオブジェクトにキャッシュされます。最新の情報を取得するには
          *note stat.S_ISDIR(): 2738. と共に *note os.stat(): 46d. を呼
          び出してください。

          多くの場合、最初のキャッシュされない呼び出しでは、システムコー
          ルは必要とされません。具体的には、シンボリックリンク以外では、
          Windows も Unix もシステムコールを必要としません。ただし、
          ‘dirent.d_type == DT_UNKNOWN’ を返す、ネットワークファイルシス
          テムなどの特定の Unix ファイルシステムは例外です。項目がシンボ
          リックリンクの場合、'follow_symlinks' が ‘False’ の場合を除き
          、シンボリックリンクをたどるためにシステムコールが必要となりま
          す。

          このメソッドは *note PermissionError: d10. のような *note
          OSError: 3f0. を送出することがありますが、 *note
          FileNotFoundError: e8f. は捕捉され送出されません。

      -- メソッド: is_file (*, follow_symlinks=True)

          この項目がファイルまたはファイルへのシンボリックリンクである場
          合、 ‘True’ を返します。項目がディレクトリやファイル以外の項目
          へのシンボリックリンクである場合や、もはや存在しない場合は
          ‘False’ を返します。

          'follow_symlinks' が ‘False’ の場合、項目がファイル (シンボリ
          ックリンクはたどりません) の場合にのみ ‘True’ を返します。項目
          がディレクトリやその他のファイル以外の項目である場合や、項目が
          もはや存在しない場合は ‘False’ を返します。

          結果は ‘os.DirEntry’ オブジェクトにキャッシュされます。キャッ
          シュ、システムコール、例外は、*note is_dir(): 2ae1. と同様に行
          われます。

      -- メソッド: is_symlink ()

          この項目がシンボリックリンクの場合 (たとえ破損していても)、
          ‘True’ を返します。項目がディレクトリやあらゆる種類のファイル
          の場合、またはもはや存在しない場合は ‘False’ を返します。

          結果は ‘os.DirEntry’ オブジェクトにキャッシュされます。 最新の
          情報をフェッチするには *note os.path.islink(): 9da. を呼び出し
          てください。

          多くの場合、最初のキャッシュされない呼び出しでは、システムコー
          ルは必要とされません。具体的には、Windows も Unix もシステムコ
          ールを必要としません。ただし、‘dirent.d_type == DT_UNKNOWN’ を
          返す、ネットワークファイルシステムなどの特定の Unix ファイルシ
          ステムは例外です。

          このメソッドは *note PermissionError: d10. のような *note
          OSError: 3f0. を送出することがありますが、 *note
          FileNotFoundError: e8f. は捕捉され送出されません。

      -- メソッド: is_junction ()

          Return ‘True’ if this entry is a junction (even if broken);
          return ‘False’ if the entry points to a regular directory, any
          kind of file, a symlink, or if it doesn't exist anymore.

          The result is cached on the ‘os.DirEntry’ object.  Call *note
          os.path.isjunction(): 470. to fetch up-to-date information.

          Added in version 3.12.

      -- メソッド: stat (*, follow_symlinks=True)

          この項目の *note stat_result: 1466. オブジェクトを返します。こ
          のメソッドは、デフォルトでシンボリックリンクをたどります。シン
          ボリックリンクを開始するには、 ‘follow_symlinks=False’ 引数を
          追加します。

          On Unix, this method always requires a system call.  On
          Windows, it only requires a system call if 'follow_symlinks'
          is ‘True’ and the entry is a reparse point (for example, a
          symbolic link or directory junction).

          Windows では、*note stat_result: 1466. の ‘st_ino’ 、 ‘st_dev’
          、 ‘st_nlink’ 属性は常にゼロに設定されます。これらの属性を取得
          するには、 *note os.stat(): 46d. を呼び出します。

          結果は ‘os.DirEntry’ オブジェクトにキャッシュされます。
          'follow_symlinks' が ‘True’ の場合と ‘False’ の場合とでは、別
          のオブジェクトにキャッシュされます。最新の情報を取得するには、
          *note os.stat(): 46d. を呼び出してください。

     Note that there is a nice correspondence between several attributes
     and methods of ‘os.DirEntry’ and of *note pathlib.Path: 20a.  In
     particular, the ‘name’ attribute has the same meaning, as do the
     ‘is_dir()’, ‘is_file()’, ‘is_symlink()’, ‘is_junction()’, and
     ‘stat()’ methods.

     Added in version 3.5.

     バージョン 3.6 で変更: *note PathLike: c1f. インターフェースをサポ
     ートしました。Windowsで *note bytes: 1a4. パスをサポートしました。

     バージョン 3.12 で変更: The ‘st_ctime’ attribute of a stat result
     is deprecated on Windows.  The file creation time is properly
     available as ‘st_birthtime’, and in the future ‘st_ctime’ may be
     changed to return zero or the metadata change time, if available.

 -- の関数: os.stat (path, *, dir_fd=None, follow_symlinks=True)

     Get the status of a file or a file descriptor.  Perform the
     equivalent of a ‘stat()’ system call on the given path.  'path' may
     be specified as either a string or bytes - directly or indirectly
     through the *note PathLike: c1f. interface - or as an open file
     descriptor.  Return a *note stat_result: 1466. object.

     この関数は通常はシンボリックリンクをたどります。シンボリックリンク
     に対して stat したい場合は ‘follow_symlinks=False’ とするか、 *note
     lstat(): 46e. を利用してください。

     この関数は *note ファイル記述子の指定: b2a. および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     On Windows, passing ‘follow_symlinks=False’ will disable following
     all name-surrogate reparse points, which includes symlinks and
     directory junctions.  Other types of reparse points that do not
     resemble links or that the operating system is unable to follow
     will be opened directly.  When following a chain of multiple links,
     this may result in the original link being returned instead of the
     non-link that prevented full traversal.  To obtain stat results for
     the final path in this case, use the *note os.path.realpath(): 206.
     function to resolve the path name as far as possible and call *note
     lstat(): 46e. on the result.  This does not apply to dangling
     symlinks or junction points, which will raise the usual exceptions.

     以下はプログラム例です:

          >>> import os
          >>> statinfo = os.stat('somefile.txt')
          >>> statinfo
          os.stat_result(st_mode=33188, st_ino=7876932, st_dev=234881026,
          st_nlink=1, st_uid=501, st_gid=501, st_size=264, st_atime=1297230295,
          st_mtime=1297230027, st_ctime=1297230027)
          >>> statinfo.st_size
          264

     参考
     ....

     *note fstat(): d59. と *note lstat(): 46e.。

     バージョン 3.3 で変更: Added the 'dir_fd' and 'follow_symlinks'
     parameters, specifying a file descriptor instead of a path.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.8 で変更: On Windows, all reparse points that can be
     resolved by the operating system are now followed, and passing
     ‘follow_symlinks=False’ disables following all name surrogate
     reparse points.  If the operating system reaches a reparse point
     that it is not able to follow, 'stat' now returns the information
     for the original path as if ‘follow_symlinks=False’ had been
     specified instead of raising an error.

 -- クラス: os.stat_result

     Object whose attributes correspond roughly to the members of the
     ‘stat’ structure.  It is used for the result of *note os.stat():
     46d, *note os.fstat(): d59. and *note os.lstat(): 46e.

     属性:

      -- の属性: st_mode

          ファイルモード。ファイルタイプとファイルモードのビット （権限
          ）。

      -- の属性: st_ino

          Platform dependent, but if non-zero, uniquely identifies the
          file for a given value of ‘st_dev’.  Typically:

             * the inode number on Unix,

             * the file index(8) on Windows

      -- の属性: st_dev

          このファイルが存在するデバイスの識別子。

      -- の属性: st_nlink

          ハードリンクの数。

      -- の属性: st_uid

          ファイル所有者のユーザ識別子。

      -- の属性: st_gid

          ファイル所有者のグループ識別子。

      -- の属性: st_size

          ファイルが通常のファイルまたはシンボリックリンクの場合、そのフ
          ァイルのバイト単位でのサイズです。シンボリックリンクのサイズは
          、含まれるパス名の長さで、null バイトで終わることはありません
          。

     タイムスタンプ:

      -- の属性: st_atime

          秒で表した最終アクセス時刻。

      -- の属性: st_mtime

          秒で表した最終内容更新時刻。

      -- の属性: st_ctime

          Time of most recent metadata change expressed in seconds.

          バージョン 3.12 で変更: ‘st_ctime’ is deprecated on Windows.
          Use ‘st_birthtime’ for the file creation time.  In the future,
          ‘st_ctime’ will contain the time of the most recent metadata
          change, as for other platforms.

      -- の属性: st_atime_ns

          ナノ秒 (整数) で表した最終アクセス時刻。

          Added in version 3.3.

      -- の属性: st_mtime_ns

          ナノ秒 (整数) で表した最終内容更新時刻。

          Added in version 3.3.

      -- の属性: st_ctime_ns

          Time of most recent metadata change expressed in nanoseconds
          as an integer.

          Added in version 3.3.

          バージョン 3.12 で変更: ‘st_ctime_ns’ is deprecated on
          Windows.  Use ‘st_birthtime_ns’ for the file creation time.
          In the future, ‘st_ctime’ will contain the time of the most
          recent metadata change, as for other platforms.

      -- の属性: st_birthtime

          Time of file creation expressed in seconds.  This attribute is
          not always available, and may raise *note AttributeError: 326.

          バージョン 3.12 で変更: ‘st_birthtime’ is now available on
          Windows.

      -- の属性: st_birthtime_ns

          Time of file creation expressed in nanoseconds as an integer.
          This attribute is not always available, and may raise *note
          AttributeError: 326.

          Added in version 3.12.

          注釈: The exact meaning and resolution of the *note st_atime:
          2aeb, *note st_mtime: 297c, *note st_ctime: 2aec. and *note
          st_birthtime: 2af0. attributes depend on the operating system
          and the file system.  For example, on Windows systems using
          the FAT32 file systems, *note st_mtime: 297c. has 2-second
          resolution, and *note st_atime: 2aeb. has only 1-day
          resolution.  See your operating system documentation for
          details.

          Similarly, although *note st_atime_ns: 2aed, *note
          st_mtime_ns: 2aee, *note st_ctime_ns: 2aef. and *note
          st_birthtime_ns: 2af1. are always expressed in nanoseconds,
          many systems do not provide nanosecond precision.  On systems
          that do provide nanosecond precision, the floating-point
          object used to store *note st_atime: 2aeb, *note st_mtime:
          297c, *note st_ctime: 2aec. and *note st_birthtime: 2af0.
          cannot preserve all of it, and as such will be slightly
          inexact.  If you need the exact timestamps you should always
          use *note st_atime_ns: 2aed, *note st_mtime_ns: 2aee, *note
          st_ctime_ns: 2aef. and *note st_birthtime_ns: 2af1.

     (Linux のような ) 一部の Unix システムでは、以下の属性が利用できる
     場合があります :

      -- の属性: st_blocks

          ファイルに対して割り当てられている 512 バイトのブロックの数で
          す。ファイルにホール (hole) が含まれている場合、*note st_size:
          2aea./512 より小さくなる場合があります。

      -- の属性: st_blksize

          効率的なファイルシステム I/O のための「推奨される」ブロックサ
          イズです。ファイルに、これより小さいチャンクで書き込むと、非効
          率的な読み込み、編集、再書き込みが起こる場合があります。

      -- の属性: st_rdev

          inode デバイスの場合デバイスタイプ

      -- の属性: st_flags

          ファイルのユーザ定義フラグ

     他の (FreeBSD のような ) Unix システムでは、以下の属性が利用できる
     場合があります ( ただし root ユーザ以外が使うと値が入っていない場合
     があります ):

      -- の属性: st_gen

          ファイル生成番号

     On Solaris and derivatives, the following attributes may also be
     available:

      -- の属性: st_fstype

          String that uniquely identifies the type of the filesystem
          that contains the file.

     On macOS systems, the following attributes may also be available:

      -- の属性: st_rsize

          ファイルの実際のサイズ

      -- の属性: st_creator

          ファイルの作成者

      -- の属性: st_type

          ファイルタイプ

     On Windows systems, the following attributes are also available:

      -- の属性: st_file_attributes

          Windows file attributes: ‘dwFileAttributes’ member of the
          ‘BY_HANDLE_FILE_INFORMATION’ structure returned by
          ‘GetFileInformationByHandle()’.  See the ‘FILE_ATTRIBUTE_*
          <stat.FILE_ATTRIBUTE_ARCHIVE>’ constants in the *note stat:
          bc. module.

          Added in version 3.5.

      -- の属性: st_reparse_tag

          When *note st_file_attributes: e05. has the *note
          FILE_ATTRIBUTE_REPARSE_POINT: 2785. set, this field contains
          the tag identifying the type of reparse point.  See the *note
          IO_REPARSE_TAG_*: 278a. constants in the *note stat: bc.
          module.

     The standard module *note stat: bc. defines functions and constants
     that are useful for extracting information from a ‘stat’ structure.
     (On Windows, some items are filled with dummy values.)

     For backward compatibility, a *note stat_result: 1466. instance is
     also accessible as a tuple of at least 10 integers giving the most
     important (and portable) members of the ‘stat’ structure, in the
     order *note st_mode: 2ae4, *note st_ino: 2ae5, *note st_dev: 2ae6,
     *note st_nlink: 2ae7, *note st_uid: 2ae8, *note st_gid: 2ae9, *note
     st_size: 2aea, *note st_atime: 2aeb, *note st_mtime: 297c, *note
     st_ctime: 2aec.  More items may be added at the end by some
     implementations.  For compatibility with older Python versions,
     accessing *note stat_result: 1466. as a tuple always returns
     integers.

     バージョン 3.5 で変更: Windows now returns the file index as *note
     st_ino: 2ae5. when available.

     バージョン 3.7 で変更: Added the *note st_fstype: b32. member to
     Solaris/derivatives.

     バージョン 3.8 で変更: Added the *note st_reparse_tag: 2afa. member
     on Windows.

     バージョン 3.8 で変更: On Windows, the *note st_mode: 2ae4. member
     now identifies special files as ‘S_IFCHR’, ‘S_IFIFO’ or ‘S_IFBLK’
     as appropriate.

     バージョン 3.12 で変更: On Windows, *note st_ctime: 2aec. is
     deprecated.  Eventually, it will contain the last metadata change
     time, for consistency with other platforms, but for now still
     contains creation time.  Use *note st_birthtime: 2af0. for the
     creation time.

     On Windows, *note st_ino: 2ae5. may now be up to 128 bits,
     depending on the file system.  Previously it would not be above 64
     bits, and larger file identifiers would be arbitrarily packed.

     On Windows, *note st_rdev: 2af4. no longer returns a value.
     Previously it would contain the same as *note st_dev: 2ae6, which
     was incorrect.

     Added the *note st_birthtime: 2af0. member on Windows.

 -- の関数: os.statvfs (path)

     Perform a ‘statvfs()’ system call on the given path.  The return
     value is an object whose attributes describe the filesystem on the
     given path, and correspond to the members of the ‘statvfs’
     structure, namely: ‘f_bsize’, ‘f_frsize’, ‘f_blocks’, ‘f_bfree’,
     ‘f_bavail’, ‘f_files’, ‘f_ffree’, ‘f_favail’, ‘f_flag’,
     ‘f_namemax’, ‘f_fsid’.

     ‘f_flag’ 属性のビットフラグ用に 2 つのモジュールレベル定数が定義さ
     れています: ‘ST_RDONLY’ が設定されるとファイルシステムは読み出し専
     用でマウントされ、‘ST_NOSUID’ が設定されると setuid/setgid ビットの
     動作は無効になるか、サポートされません。

     GNU/glibc ベースのシステム用に、追加のモジュールレベルの定数が次の
     ように定義されています。 ‘ST_NODEV’ (デバイス特殊ファイルへのアクセ
     スを許可しない) 、 ‘ST_NOEXEC’ (プログラムの実行を許可しない) 、
     ‘ST_SYNCHRONOUS’ (書き込みが一度に同期される) 、‘ST_MANDLOCK’ (ファ
     イルシステムで強制的なロックを許可する) 、 ‘ST_WRITE’ (ファイル/デ
     ィレクトリ/シンボリックリンクに書き込む) 、 ‘ST_APPEND’ (追記のみの
     ファイル) 、‘ST_IMMUTABLE’ (変更不能なファイル) 、 ‘ST_NOATIME’ (ア
     クセス時刻を更新しない) 、‘ST_NODIRATIME’ (ディレクトリアクセス時刻
     を更新しない) 、‘ST_RELATIME’ (mtime/ctimeに対して相対的に atime を
     更新する)。

     この関数は *note ファイル記述子の指定: b2a. をサポートしています。

     *note Availability: 1cbe.: Unix.

     バージョン 3.2 で変更: 定数 ‘ST_RDONLY’ および ‘ST_NOSUID’ が追加さ
     れました。

     バージョン 3.3 で変更: 'path' へのオープン・ファイル記述子の指定を
     サポートしました。

     バージョン 3.4 で変更: ‘ST_NODEV’, ‘ST_NOEXEC’, ‘ST_SYNCHRONOUS’,
     ‘ST_MANDLOCK’, ‘ST_WRITE’, ‘ST_APPEND’, ‘ST_IMMUTABLE’,
     ‘ST_NOATIME’, ‘ST_NODIRATIME’, ‘ST_RELATIME’ 定数が追加されました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.7 で変更: Added the ‘f_fsid’ attribute.

 -- データ: os.supports_dir_fd

     A *note set: 5a3. object indicating which functions in the *note
     os: 91. module accept an open file descriptor for their 'dir_fd'
     parameter.  Different platforms provide different features, and the
     underlying functionality Python uses to implement the 'dir_fd'
     parameter is not available on all platforms Python supports.  For
     consistency's sake, functions that may support 'dir_fd' always
     allow specifying the parameter, but will throw an exception if the
     functionality is used when it's not locally available.  (Specifying
     ‘None’ for 'dir_fd' is always supported on all platforms.)

     To check whether a particular function accepts an open file
     descriptor for its 'dir_fd' parameter, use the ‘in’ operator on
     ‘supports_dir_fd’.  As an example, this expression evaluates to
     ‘True’ if *note os.stat(): 46d. accepts open file descriptors for
     'dir_fd' on the local platform:

          os.stat in os.supports_dir_fd

     現在 'dir_fd' 引数は Unix プラットフォームでのみ動作します。Windows
     で動作する関数はありません。

     Added in version 3.3.

 -- データ: os.supports_effective_ids

     A *note set: 5a3. object indicating whether *note os.access():
     10bd. permits specifying ‘True’ for its 'effective_ids' parameter
     on the local platform.  (Specifying ‘False’ for 'effective_ids' is
     always supported on all platforms.)  If the local platform supports
     it, the collection will contain *note os.access(): 10bd.; otherwise
     it will be empty.

     This expression evaluates to ‘True’ if *note os.access(): 10bd.
     supports ‘effective_ids=True’ on the local platform:

          os.access in os.supports_effective_ids

     現在 'effective_ids' は Unix プラットフォームでのみサポートされてい
     ます。Windows では動作しません。

     Added in version 3.3.

 -- データ: os.supports_fd

     A *note set: 5a3. object indicating which functions in the *note
     os: 91. module permit specifying their 'path' parameter as an open
     file descriptor on the local platform.  Different platforms provide
     different features, and the underlying functionality Python uses to
     accept open file descriptors as 'path' arguments is not available
     on all platforms Python supports.

     To determine whether a particular function permits specifying an
     open file descriptor for its 'path' parameter, use the ‘in’
     operator on ‘supports_fd’.  As an example, this expression
     evaluates to ‘True’ if *note os.chdir(): 5d8. accepts open file
     descriptors for 'path' on your local platform:

          os.chdir in os.supports_fd

     Added in version 3.3.

 -- データ: os.supports_follow_symlinks

     A *note set: 5a3. object indicating which functions in the *note
     os: 91. module accept ‘False’ for their 'follow_symlinks' parameter
     on the local platform.  Different platforms provide different
     features, and the underlying functionality Python uses to implement
     'follow_symlinks' is not available on all platforms Python
     supports.  For consistency's sake, functions that may support
     'follow_symlinks' always allow specifying the parameter, but will
     throw an exception if the functionality is used when it's not
     locally available.  (Specifying ‘True’ for 'follow_symlinks' is
     always supported on all platforms.)

     To check whether a particular function accepts ‘False’ for its
     'follow_symlinks' parameter, use the ‘in’ operator on
     ‘supports_follow_symlinks’.  As an example, this expression
     evaluates to ‘True’ if you may specify ‘follow_symlinks=False’ when
     calling *note os.stat(): 46d. on the local platform:

          os.stat in os.supports_follow_symlinks

     Added in version 3.3.

 -- の関数: os.symlink (src, dst, target_is_directory=False, *,
          dir_fd=None)

     'src' を指し示すシンボリックリンク 'dst' を作成します。

     Windows では、シンボリックリンクはファイルかディレクトリのどちらか
     を表しますが、ターゲットに合わせて動的に変化することはありません。
     ターゲットが存在する場合、シンボリックリンクの種類は対象に合わせて
     作成されます。ターゲットが存在せず 'target_is_directory' に ‘True’
     が設定された場合、シンボリックリンクはディレクトリのリンクとして作
     成され、‘False’ に設定された場合 (デフォルト) はファイルのリンクに
     なります。Windows 以外のプラットフォームでは 'target_is_directory'
     は無視されます。

     この関数は *note ディレクトリ記述子への相対パス: 10c8. をサポートし
     ています。

          注釈: On newer versions of Windows 10, unprivileged accounts
          can create symlinks if Developer Mode is enabled.  When
          Developer Mode is not available/enabled, the
          'SeCreateSymbolicLinkPrivilege' privilege is required, or the
          process must be run as an administrator.

          この関数が特権を持たないユーザーに呼び出されると、*note
          OSError: 3f0. が送出されます。

     引数 ‘src’, ‘dst’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.symlink’ を送出します。

     *note Availability: 1cbe.: Unix, Windows.

     The function is limited on WASI, see *note WebAssembly
     プラットフォーム: 174c. for more information.

     バージョン 3.2 で変更: Windows 6.0 (Vista) のシンボリックリンクをサ
     ポートしました。

     バージョン 3.3 で変更: Added the 'dir_fd' parameter, and now allow
     'target_is_directory' on non-Windows platforms.

     バージョン 3.6 で変更: 'src' と 'dst' が *note path-like object:
     280. を受け付けるようになりました。

     バージョン 3.8 で変更: Added support for unelevated symlinks on
     Windows with Developer Mode.

 -- の関数: os.sync ()

     ディスクキャッシュのディスクへの書き出しを強制します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: os.truncate (path, length)

     'path' に対応するファイルを、サイズが最大で 'length' バイトになるよ
     う切り詰めます。

     この関数は *note ファイル記述子の指定: b2a. をサポートしています。

     引数 ‘path’, ‘length’ を指定して *note 監査イベント: 1825.
     ‘os.truncate’ を送出します。

     *note Availability: 1cbe.: Unix, Windows.

     Added in version 3.3.

     バージョン 3.5 で変更: Windows サポートを追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.unlink (path, *, dir_fd=None)

     ファイル 'path' を削除します。意味上は *note remove(): 10c1. と等価
     です。 ‘unlink’ の名前は伝統的な Unix の関数名です。詳細は *note
     remove(): 10c1. のドキュメントを参照してください。

     引数 ‘path’, ‘dir_fd’ を指定して *note 監査イベント: 1825.
     ‘os.remove’ を送出します。

     バージョン 3.3 で変更: 引数 'dir_fd' を追加しました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.utime (path, times=None, *[, ns], dir_fd=None,
          follow_symlinks=True)

     'path' で指定されたファイルに最終アクセス時刻および最終修正時刻を設
     定します。

     *note utime(): 10c7. は 2 つの任意引数 'times' と 'ns' をとります。
     これらは 'path' に設定する時刻を指定し、以下のように使用されます:

        - 'ns' を指定する場合、ナノ秒を表す整数値をメンバーとして使用し
          て、 ‘(atime_ns, mtime_ns)’ の形式の 2 要素タプルを指定する必
          要があります。

        - 'times' が ‘None’ ではない場合、‘(atime, mtime)’ の形式で各メ
          ンバーは単位を秒で表す整数か浮動小数点値のタプルを指定しなけれ
          ばなりません。

        - 'times' が ‘None’ で、 'ns' が指定されていない場合、これは両方
          の時間を現在時刻として ‘ns=(atime_ns, mtime_ns)’ を指定するこ
          とと等価です。

     'times' と 'ns' の両方にタプルが指定されるとエラーになります。

     ここで設定した時刻が、後に *note stat(): 46d. の呼び出し時正確に返
     されない場合があります。これはオペレーティングシステムが記録するア
     クセスおよび修正時刻の精度に依存しています; *note stat(): 46d. を参
     照してください。正確な時刻を保持する最善の方法は、*note utime():
     10c7. で 'ns' 引数を指定し、*note os.stat(): 46d. の返り値オブジェ
     クトから 'st_atime_ns' および 'st_mtime_ns' フィールドを使用するこ
     とです。

     この関数は *note ファイル記述子の指定: b2a. 、 *note
     ディレクトリ記述子への相対パス: 10c8. 、および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     引数 ‘path’, ‘times’, ‘ns’, ‘dir_fd’ を指定して *note 監査イベント:
     1825. ‘os.utime’ を送出します。

     バージョン 3.3 で変更: 'path' にオープンしているファイル記述子の指
     定のサポート、および引数 'dir_fd', 'follow_symlinks', 'ns' を追加し
     ました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.walk (top, topdown=True, onerror=None, followlinks=False)

     ディレクトリツリー以下のファイル名を、ツリーをトップダウンもしくは
     ボトムアップに走査することで作成します。ディレクトリ 'top' を根に持
     つディレクトリツリーに含まれる、各ディレクトリ ('top' 自身を含む )
     ごとに、タプル ‘(dirpath, dirnames, filenames)’ を yield します。

     'dirpath' is a string, the path to the directory.  'dirnames' is a
     list of the names of the subdirectories in 'dirpath' (including
     symlinks to directories, and excluding ‘'.'’ and ‘'..'’).
     'filenames' is a list of the names of the non-directory files in
     'dirpath'.  Note that the names in the lists contain no path
     components.  To get a full path (which begins with 'top') to a file
     or directory in 'dirpath', do ‘os.path.join(dirpath, name)’.
     Whether or not the lists are sorted depends on the file system.  If
     a file is removed from or added to the 'dirpath' directory during
     generating the lists, whether a name for that file be included is
     unspecified.

     オプション引数 'topdown' が ‘True’ であるか、指定されなかった場合、
     各ディレクトリからタプルを生成した後で、サブディレクトリからタプル
     を生成します。 ( ディレクトリはトップダウンで生成 ) 。 'topdown' が
     ‘False’ の場合、ディレクトリに対応するタプルは、そのディレクトリ以
     下の全てのサブディレクトリに対応するタプルの後で ( ボトムアップで )
     生成されます。 'topdown' の値によらず、サブディレクトリのリストは、
     ディレクトリとそのサブディレクトリのタプルを生成する前に取り出され
     ます。

     'topdown' が ‘True’ のとき、呼び出し側は 'dirnames' リストを、イン
     プレースで ( たとえば、 *note del: 1711. やスライスを使った代入で )
     変更でき、 *note walk(): 476. は 'dirnames' に残っているサブディレ
     クトリ内のみを再帰します。これにより、検索を省略したり、特定の訪問
     順序を強制したり、呼び出し側が *note walk(): 476. を再開する前に、
     呼び出し側が作った、または名前を変更したディレクトリを、 *note
     walk(): 476. に知らせたりすることができます。 'topdown' が ‘False’
     のときに 'dirnames' を変更しても効果はありません。ボトムアップモー
     ドでは 'dirpath' 自身が生成される前に 'dirnames' 内のディレクトリの
     情報が生成されるからです。

     デフォルトでは、 *note scandir(): a2d. 呼び出しからのエラーは無視さ
     れます。オプション引数の 'onerror' を指定する場合は関数でなければな
     りません ; この関数は単一の引数として *note OSError: 3f0. インスタ
     ンスを伴って呼び出されます。この関数でエラーを報告して走査を継続し
     たり、例外を送出して走査を中止したりできます。ファイル名は例外オブ
     ジェクトの ‘filename’ 属性として利用できます。

     デフォルトでは、 *note walk(): 476. はディレクトリへのシンボリック
     リンクをたどりません。 'followlinks' に ‘True’ を指定すると、ディレ
     クトリへのシンボリックリンクをサポートしているシステムでは、シンボ
     リックリンクの指しているディレクトリを走査します。

          注釈: 'followlinks' に ‘True’ を指定すると、シンボリックリンク
          が親ディレクトリを指していた場合に、無限ループになることに注意
          してください。 *note walk(): 476. はすでにたどったディレクトリ
          を管理したりはしません。

          注釈: 相対パスを渡した場合、 *note walk(): 476. が再開されるま
          での間に現在の作業ディレクトリを変更しないでください。 *note
          walk(): 476. はカレントディレクトリを変更しませんし、呼び出し
          側もカレントディレクトリを変更しないと仮定しています。

     以下の例では、最初のディレクトリ以下にある各ディレクトリに含まれる
     、非ディレクトリファイルのバイト数を表示します。ただし、 CVS サブデ
     ィレクトリ以下は見に行きません

          import os
          from os.path import join, getsize
          for root, dirs, files in os.walk('python/Lib/email'):
              print(root, "consumes", end=" ")
              print(sum(getsize(join(root, name)) for name in files), end=" ")
              print("bytes in", len(files), "non-directory files")
              if 'CVS' in dirs:
                  dirs.remove('CVS')  # don't visit CVS directories

     次の例 (*note shutil.rmtree(): 2d8. の単純な実装) では、ツリーをボ
     トムアップで走査することが不可欠になります; *note rmdir(): 10c4. は
     ディレクトリが空になるまで削除を許さないからです:

          # Delete everything reachable from the directory named in "top",
          # assuming there are no symbolic links.
          # CAUTION:  This is dangerous!  For example, if top == '/', it
          # could delete all your disk files.
          import os
          for root, dirs, files in os.walk(top, topdown=False):
              for name in files:
                  os.remove(os.path.join(root, name))
              for name in dirs:
                  os.rmdir(os.path.join(root, name))
          os.rmdir(top)

     引数 ‘top’, ‘topdown’, ‘onerror’, ‘followlinks’ を指定して *note
     監査イベント: 1825. ‘os.walk’ を送出します。

     バージョン 3.5 で変更: この関数は、今では *note os.listdir(): 10cd.
     ではなく *note os.scandir(): a2d. を呼び出します。これにより、
     *note os.stat(): 46d. の呼び出し回数を削減でき、動作が高速化します
     。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.fwalk (top='.', topdown=True, onerror=None, *,
          follow_symlinks=False, dir_fd=None)

     挙動は *note walk(): 476. と同じですが、‘dir_fd’ をサポートし、タプ
     ル ‘(dirpath, dirnames, filenames, dirfd)’ を yield します。

     'dirpath'、'dirnames'、および 'filenames' は *note walk(): 476. の
     出力と同じで、'dirfd' は 'dirpath' を参照するファイル記述子です。

     この関数は常に *note ディレクトリ記述子への相対パス: 10c8. および
     *note シンボリックリンクをたどらない: 10c9. をサポートしています。
     ただし、他の関数と異なり、*note fwalk(): b29. での
     'follow_symlinks' のデフォルト値は ‘False’ になることに注意してくだ
     さい。

          注釈: *note fwalk(): b29. はファイル記述子を yield するため、
          それらが有効なのは次のイテレートステップまでです。それ以後も保
          持したい場合は *note dup(): 1948. などを使って複製して使用して
          ください。

     以下の例では、最初のディレクトリ以下にある各ディレクトリに含まれる
     、非ディレクトリファイルのバイト数を表示します。ただし、 CVS サブデ
     ィレクトリ以下は見に行きません

          import os
          for root, dirs, files, rootfd in os.fwalk('python/Lib/email'):
              print(root, "consumes", end="")
              print(sum([os.stat(name, dir_fd=rootfd).st_size for name in files]),
                    end="")
              print("bytes in", len(files), "non-directory files")
              if 'CVS' in dirs:
                  dirs.remove('CVS')  # don't visit CVS directories

     次の例では、ツリーをボトムアップで走査することが不可欠になります ;
     *note rmdir(): 10c4. はディレクトリが空になるまで削除を許さないから
     です

          # Delete everything reachable from the directory named in "top",
          # assuming there are no symbolic links.
          # CAUTION:  This is dangerous!  For example, if top == '/', it
          # could delete all your disk files.
          import os
          for root, dirs, files, rootfd in os.fwalk(top, topdown=False):
              for name in files:
                  os.unlink(name, dir_fd=rootfd)
              for name in dirs:
                  os.rmdir(name, dir_fd=rootfd)

     引数 ‘top’, ‘topdown’, ‘onerror’, ‘follow_symlinks’ を指定して
     *note 監査イベント: 1825. ‘os.fwalk’ を送出します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.7 で変更: Added support for *note bytes: 1a4. paths.

 -- の関数: os.memfd_create (name[, flags=os.MFD_CLOEXEC])

     Create an anonymous file and return a file descriptor that refers
     to it.  'flags' must be one of the ‘os.MFD_*’ constants available
     on the system (or a bitwise ORed combination of them).  By default,
     the new file descriptor is *note non-inheritable: ec4.

     The name supplied in 'name' is used as a filename and will be
     displayed as the target of the corresponding symbolic link in the
     directory ‘/proc/self/fd/’.  The displayed name is always prefixed
     with ‘memfd:’ and serves only for debugging purposes.  Names do not
     affect the behavior of the file descriptor, and as such multiple
     files can have the same name without any side effects.

     *note Availability: 1cbe.: Linux >= 3.17 with glibc >= 2.27.

     Added in version 3.8.

 -- データ: os.MFD_CLOEXEC
 -- データ: os.MFD_ALLOW_SEALING
 -- データ: os.MFD_HUGETLB
 -- データ: os.MFD_HUGE_SHIFT
 -- データ: os.MFD_HUGE_MASK
 -- データ: os.MFD_HUGE_64KB
 -- データ: os.MFD_HUGE_512KB
 -- データ: os.MFD_HUGE_1MB
 -- データ: os.MFD_HUGE_2MB
 -- データ: os.MFD_HUGE_8MB
 -- データ: os.MFD_HUGE_16MB
 -- データ: os.MFD_HUGE_32MB
 -- データ: os.MFD_HUGE_256MB
 -- データ: os.MFD_HUGE_512MB
 -- データ: os.MFD_HUGE_1GB
 -- データ: os.MFD_HUGE_2GB
 -- データ: os.MFD_HUGE_16GB

     These flags can be passed to *note memfd_create(): 9d9.

     *note Availability: 1cbe.: Linux >= 3.17 with glibc >= 2.27

     The ‘MFD_HUGE*’ flags are only available since Linux 4.14.

     Added in version 3.8.

 -- の関数: os.eventfd (initval[, flags=os.EFD_CLOEXEC])

     Create and return an event file descriptor.  The file descriptors
     supports raw *note read(): d62. and *note write(): d68. with a
     buffer size of 8, *note select(): d6d, *note poll(): 2b0c. and
     similar.  See man page ‘eventfd(2)(9)’ for more information.  By
     default, the new file descriptor is *note non-inheritable: ec4.

     'initval' is the initial value of the event counter.  The initial
     value must be a 32 bit unsigned integer.  Please note that the
     initial value is limited to a 32 bit unsigned int although the
     event counter is an unsigned 64 bit integer with a maximum value of
     2^64-2.

     'flags' can be constructed from *note EFD_CLOEXEC: 1739, *note
     EFD_NONBLOCK: 173a, and *note EFD_SEMAPHORE: 173b.

     If *note EFD_SEMAPHORE: 173b. is specified and the event counter is
     non-zero, *note eventfd_read(): 2b0d. returns 1 and decrements the
     counter by one.

     If *note EFD_SEMAPHORE: 173b. is not specified and the event
     counter is non-zero, *note eventfd_read(): 2b0d. returns the
     current event counter value and resets the counter to zero.

     If the event counter is zero and *note EFD_NONBLOCK: 173a. is not
     specified, *note eventfd_read(): 2b0d. blocks.

     *note eventfd_write(): 2b0e. increments the event counter.  Write
     blocks if the write operation would increment the counter to a
     value larger than 2^64-2.

     以下はプログラム例です:

          import os

          # semaphore with start value '1'
          fd = os.eventfd(1, os.EFD_SEMAPHORE | os.EFC_CLOEXEC)
          try:
              # acquire semaphore
              v = os.eventfd_read(fd)
              try:
                  do_work()
              finally:
                  # release semaphore
                  os.eventfd_write(fd, v)
          finally:
              os.close(fd)

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.10.

 -- の関数: os.eventfd_read (fd)

     Read value from an *note eventfd(): 7e3. file descriptor and return
     a 64 bit unsigned int.  The function does not verify that 'fd' is
     an *note eventfd(): 7e3.

     *note Availability: 1cbe.: Linux >= 2.6.27

     Added in version 3.10.

 -- の関数: os.eventfd_write (fd, value)

     Add value to an *note eventfd(): 7e3. file descriptor.  'value'
     must be a 64 bit unsigned int.  The function does not verify that
     'fd' is an *note eventfd(): 7e3.

     *note Availability: 1cbe.: Linux >= 2.6.27

     Added in version 3.10.

 -- データ: os.EFD_CLOEXEC

     Set close-on-exec flag for new *note eventfd(): 7e3. file
     descriptor.

     *note Availability: 1cbe.: Linux >= 2.6.27

     Added in version 3.10.

 -- データ: os.EFD_NONBLOCK

     Set *note O_NONBLOCK: e08. status flag for new *note eventfd():
     7e3. file descriptor.

     *note Availability: 1cbe.: Linux >= 2.6.27

     Added in version 3.10.

 -- データ: os.EFD_SEMAPHORE

     Provide semaphore-like semantics for reads from an *note eventfd():
     7e3. file descriptor.  On read the internal counter is decremented
     by one.

     *note Availability: 1cbe.: Linux >= 2.6.30

     Added in version 3.10.

* Menu:

* Timer File Descriptors::
* Linux 拡張属性::

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/access(2)

   (2) https://peps.python.org/pep-0529/

   (3) https://bugs.python.org/issue?@action=redirect&bpo=21082

   (4) 
https://pubs.opengroup.org/onlinepubs/009695399/functions/opendir.html

   (5) 
https://pubs.opengroup.org/onlinepubs/009695399/functions/readdir_r.html

   (6) 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364418(v=vs.85).aspx

   (7) 
https://msdn.microsoft.com/en-us/library/windows/desktop/aa364428(v=vs.85).aspx

   (8) https://msdn.microsoft.com/en-us/library/aa363788

   (9) https://manpages.debian.org/eventfd(2)


File: python.info,  Node: Timer File Descriptors,  Next: Linux 拡張属性,  Up: ファイルとディレクトリ

5.16.1.9 Timer File Descriptors
...............................

Added in version 3.13.

These functions provide support for Linux's 'timer file descriptor' API.
Naturally, they are all only available on Linux.

 -- の関数: os.timerfd_create (clockid, /, *, flags=0)

     Create and return a timer file descriptor ('timerfd').

     The file descriptor returned by *note timerfd_create(): 1f2.
     supports:

        - *note read(): d62.

        - *note select(): d6d.

        - *note poll(): 2b0c.

     The file descriptor's *note read(): d62. method can be called with
     a buffer size of 8.  If the timer has already expired one or more
     times, *note read(): d62. returns the number of expirations with
     the host's endianness, which may be converted to an *note int: 238.
     by ‘int.from_bytes(x, byteorder=sys.byteorder)’.

     *note select(): d6d. and *note poll(): 2b0c. can be used to wait
     until timer expires and the file descriptor is readable.

     'clockid' must be a valid *note clock ID: 2b10, as defined in the
     *note time: d7. module:

        - *note time.CLOCK_REALTIME: 666.

        - *note time.CLOCK_MONOTONIC: 665.

        - *note time.CLOCK_BOOTTIME: b5c. (Since Linux 3.15 for
          timerfd_create)

     If 'clockid' is *note time.CLOCK_REALTIME: 666, a settable
     system-wide real-time clock is used.  If system clock is changed,
     timer setting need to be updated.  To cancel timer when system
     clock is changed, see *note TFD_TIMER_CANCEL_ON_SET: 1fa.

     If 'clockid' is *note time.CLOCK_MONOTONIC: 665, a non-settable
     monotonically increasing clock is used.  Even if the system clock
     is changed, the timer setting will not be affected.

     If 'clockid' is *note time.CLOCK_BOOTTIME: b5c, same as *note
     time.CLOCK_MONOTONIC: 665. except it includes any time that the
     system is suspended.

     The file descriptor's behaviour can be modified by specifying a
     'flags' value.  Any of the following variables may used, combined
     using bitwise OR (the ‘|’ operator):

        - *note TFD_NONBLOCK: 1f7.

        - *note TFD_CLOEXEC: 1f8.

     If *note TFD_NONBLOCK: 1f7. is not set as a flag, *note read():
     d62. blocks until the timer expires.  If it is set as a flag, *note
     read(): d62. doesn't block, but If there hasn't been an expiration
     since the last call to read, *note read(): d62. raises *note
     OSError: 3f0. with ‘errno’ is set to *note errno.EAGAIN: 21fa.

     *note TFD_CLOEXEC: 1f8. is always set by Python automatically.

     The file descriptor must be closed with *note os.close(): b42. when
     it is no longer needed, or else the file descriptor will be leaked.

     参考
     ....

     The ‘timerfd_create(2)(1)’ man page.

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- の関数: os.timerfd_settime (fd, /, *, flags=flags, initial=0.0,
          interval=0.0)

     Alter a timer file descriptor's internal timer.  This function
     operates the same interval timer as *note timerfd_settime_ns():
     1f4.

     'fd' must be a valid timer file descriptor.

     The timer's behaviour can be modified by specifying a 'flags'
     value.  Any of the following variables may used, combined using
     bitwise OR (the ‘|’ operator):

        - *note TFD_TIMER_ABSTIME: 1f9.

        - *note TFD_TIMER_CANCEL_ON_SET: 1fa.

     The timer is disabled by setting 'initial' to zero (‘0’).  If
     'initial' is equal to or greater than zero, the timer is enabled.
     If 'initial' is less than zero, it raises an *note OSError: 3f0.
     exception with ‘errno’ set to *note errno.EINVAL: 195a.

     By default the timer will fire when 'initial' seconds have elapsed.
     (If 'initial' is zero, timer will fire immediately.)

     However, if the *note TFD_TIMER_ABSTIME: 1f9. flag is set, the
     timer will fire when the timer's clock (set by 'clockid' in *note
     timerfd_create(): 1f2.) reaches 'initial' seconds.

     The timer's interval is set by the 'interval' *note float: 2ce.  If
     'interval' is zero, the timer only fires once, on the initial
     expiration.  If 'interval' is greater than zero, the timer fires
     every time 'interval' seconds have elapsed since the previous
     expiration.  If 'interval' is less than zero, it raises *note
     OSError: 3f0. with ‘errno’ set to *note errno.EINVAL: 195a.

     If the *note TFD_TIMER_CANCEL_ON_SET: 1fa. flag is set along with
     *note TFD_TIMER_ABSTIME: 1f9. and the clock for this timer is *note
     time.CLOCK_REALTIME: 666, the timer is marked as cancelable if the
     real-time clock is changed discontinuously.  Reading the descriptor
     is aborted with the error ECANCELED.

     Linux manages system clock as UTC. A daylight-savings time
     transition is done by changing time offset only and doesn't cause
     discontinuous system clock change.

     Discontinuous system clock change will be caused by the following
     events:

        - ‘settimeofday’

        - ‘clock_settime’

        - set the system date and time by ‘date’ command

     Return a two-item tuple of (‘next_expiration’, ‘interval’) from the
     previous timer state, before this function executed.

     参考
     ....

     ‘timerfd_create(2)(2)’, ‘timerfd_settime(2)(3)’,
     ‘settimeofday(2)(4)’, ‘clock_settime(2)(5)’, and ‘date(1)(6)’.

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- の関数: os.timerfd_settime_ns (fd, /, *, flags=0, initial=0,
          interval=0)

     Similar to *note timerfd_settime(): 1f3, but use time as
     nanoseconds.  This function operates the same interval timer as
     *note timerfd_settime(): 1f3.

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- の関数: os.timerfd_gettime (fd, /)

     Return a two-item tuple of floats (‘next_expiration’, ‘interval’).

     ‘next_expiration’ denotes the relative time until next the timer
     next fires, regardless of if the *note TFD_TIMER_ABSTIME: 1f9. flag
     is set.

     ‘interval’ denotes the timer's interval.  If zero, the timer will
     only fire once, after ‘next_expiration’ seconds have elapsed.

     参考
     ....

     ‘timerfd_gettime(2)(7)’

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- の関数: os.timerfd_gettime_ns (fd, /)

     Similar to *note timerfd_gettime(): 1f5, but return time as
     nanoseconds.

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- データ: os.TFD_NONBLOCK

     A flag for the *note timerfd_create(): 1f2. function, which sets
     the *note O_NONBLOCK: e08. status flag for the new timer file
     descriptor.  If *note TFD_NONBLOCK: 1f7. is not set as a flag,
     *note read(): d62. blocks.

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- データ: os.TFD_CLOEXEC

     A flag for the *note timerfd_create(): 1f2. function, If *note
     TFD_CLOEXEC: 1f8. is set as a flag, set close-on-exec flag for new
     file descriptor.

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- データ: os.TFD_TIMER_ABSTIME

     A flag for the *note timerfd_settime(): 1f3. and *note
     timerfd_settime_ns(): 1f4. functions.  If this flag is set,
     'initial' is interpreted as an absolute value on the timer's clock
     (in UTC seconds or nanoseconds since the Unix Epoch).

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

 -- データ: os.TFD_TIMER_CANCEL_ON_SET

     A flag for the *note timerfd_settime(): 1f3. and *note
     timerfd_settime_ns(): 1f4. functions along with *note
     TFD_TIMER_ABSTIME: 1f9.  The timer is cancelled when the time of
     the underlying clock changes discontinuously.

     *note Availability: 1cbe.: Linux >= 2.6.27 with glibc >= 2.8

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/timerfd_create(2)

   (2) https://manpages.debian.org/timerfd_create(2)

   (3) https://manpages.debian.org/timerfd_settime(2)

   (4) https://manpages.debian.org/settimeofday(2)

   (5) https://manpages.debian.org/clock_settime(2)

   (6) https://manpages.debian.org/date(1)

   (7) https://manpages.debian.org/timerfd_gettime(2)


File: python.info,  Node: Linux 拡張属性,  Prev: Timer File Descriptors,  Up: ファイルとディレクトリ

5.16.1.10 Linux 拡張属性
........................

Added in version 3.3.

以下の関数はすべて Linux でのみ使用可能です。

 -- の関数: os.getxattr (path, attribute, *, follow_symlinks=True)

     Return the value of the extended filesystem attribute 'attribute'
     for 'path'.  'attribute' can be bytes or str (directly or
     indirectly through the *note PathLike: c1f. interface).  If it is
     str, it is encoded with the filesystem encoding.

     この関数は *note ファイル記述子の指定: b2a. および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     引数 ‘path’, ‘attribute’ を指定して *note 監査イベント: 1825.
     ‘os.getxattr’ を送出します。

     バージョン 3.6 で変更: 'path' と 'attribute' が *note path-like
     object: 280. を受け付けるようになりました。

 -- の関数: os.listxattr (path=None, *, follow_symlinks=True)

     'path' の拡張ファイルシステム属性のリストを返します。リスト内の属性
     はファイルシステムのエンコーディングでデコードされた文字列で表され
     ます。'path' が ‘None’ の場合、*note listxattr(): 10d8. はカレント
     ディレクトリを調べます。

     この関数は *note ファイル記述子の指定: b2a. および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     引数 ‘path’ を指定して *note 監査イベント: 1825. ‘os.listxattr’ を
     送出します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os.removexattr (path, attribute, *, follow_symlinks=True)

     Removes the extended filesystem attribute 'attribute' from 'path'.
     'attribute' should be bytes or str (directly or indirectly through
     the *note PathLike: c1f. interface).  If it is a string, it is
     encoded with the *note filesystem encoding and error handler: 505.

     この関数は *note ファイル記述子の指定: b2a. および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

     引数 ‘path’, ‘attribute’ を指定して *note 監査イベント: 1825.
     ‘os.removexattr’ を送出します。

     バージョン 3.6 で変更: 'path' と 'attribute' が *note path-like
     object: 280. を受け付けるようになりました。

 -- の関数: os.setxattr (path, attribute, value, flags=0, *,
          follow_symlinks=True)

     Set the extended filesystem attribute 'attribute' on 'path' to
     'value'.  'attribute' must be a bytes or str with no embedded NULs
     (directly or indirectly through the *note PathLike: c1f.
     interface).  If it is a str, it is encoded with the *note
     filesystem encoding and error handler: 505.  'flags' may be *note
     XATTR_REPLACE: 2b12. or *note XATTR_CREATE: 2b13.  If *note
     XATTR_REPLACE: 2b12. is given and the attribute does not exist,
     ‘ENODATA’ will be raised.  If *note XATTR_CREATE: 2b13. is given
     and the attribute already exists, the attribute will not be created
     and ‘EEXISTS’ will be raised.

     この関数は *note ファイル記述子の指定: b2a. および *note
     シンボリックリンクをたどらない: 10c9. をサポートしています。

          注釈: Linux カーネル 2.6.39 以前では、バグのため一部のファイル
          システムで引数 flags が無視されます。

     引数 ‘path’, ‘attribute’, ‘value’, ‘flags’ を指定して *note
     監査イベント: 1825. ‘os.setxattr’ を送出します。

     バージョン 3.6 で変更: 'path' と 'attribute' が *note path-like
     object: 280. を受け付けるようになりました。

 -- データ: os.XATTR_SIZE_MAX

     拡張属性の値にできる最大サイズです。現在、Linux では 64 キロバイト
     です。

 -- データ: os.XATTR_CREATE

     *note setxattr(): 10da. の引数 flags に指定できる値です。その操作で
     属性を作成しなければならないことを意味します。

 -- データ: os.XATTR_REPLACE

     *note setxattr(): 10da. の引数 flags に指定できる値です。その操作で
     既存の属性を置き換えなければならないことを意味します。


File: python.info,  Node: プロセス管理,  Next: スケジューラーへのインターフェイス,  Prev: ファイルとディレクトリ,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.11 プロセス管理
......................

以下の関数はプロセスの生成や管理に利用できます。

さまざまな *note exec*: 2b17. 関数は、プロセス内にロードされる新しいプロ
グラムに与えるための、引数のリストを取ります。どの関数の場合でも、新しい
プログラムに渡されるリストの最初の引数は、ユーザがコマンドラインで入力す
る引数ではなく、そのプログラム自体の名前です。 C プログラマならば、プロ
グラムの ‘main()’ に渡される ‘argv[0]’ だと考えれば良いでしょう。たとえ
ば、 ‘os.execv('/bin/echo', ['foo', 'bar'])’ が標準出力に出力するのは
‘bar’ だけで、 ‘foo’ は無視されたかのように見えることになります。

 -- の関数: os.abort ()

     ‘SIGABRT’ シグナルを現在のプロセスに対して生成します。 Unix では、
     デフォルトの動作はコアダンプの生成です ; Windows では、プロセスは即
     座に終了コード ‘3’ を返します。この関数の呼び出しは *note
     signal.signal(): 1107. を使って ‘SIGABRT’ に対し登録された Python シ
     グナルハンドラーを呼び出さないことに注意してください。

 -- の関数: os.add_dll_directory (path)

     Add a path to the DLL search path.

     This search path is used when resolving dependencies for imported
     extension modules (the module itself is resolved through *note
     sys.path: 38e.), and also by *note ctypes: 22.

     Remove the directory by calling 'close()' on the returned object or
     using it in a *note with: 59c. statement.

     See the Microsoft documentation(1) for more information about how
     DLLs are loaded.

     引数 ‘path’ を指定して *note 監査イベント: 1825.
     ‘os.add_dll_directory’ を送出します。

     *note Availability: 1cbe.: Windows.

     Added in version 3.8: Previous versions of CPython would resolve
     DLLs using the default behavior for the current process.  This led
     to inconsistencies, such as only sometimes searching ‘PATH’ or the
     current working directory, and OS functions such as
     ‘AddDllDirectory’ having no effect.

     In 3.8, the two primary ways DLLs are loaded now explicitly
     override the process-wide behavior to ensure consistency.  See the
     *note porting notes: a6c. for information on updating libraries.

 -- の関数: os.execl (path, arg0, arg1, ...)
 -- の関数: os.execle (path, arg0, arg1, ..., env)
 -- の関数: os.execlp (file, arg0, arg1, ...)
 -- の関数: os.execlpe (file, arg0, arg1, ..., env)
 -- の関数: os.execv (path, args)
 -- の関数: os.execve (path, args, env)
 -- の関数: os.execvp (file, args)
 -- の関数: os.execvpe (file, args, env)

     これらの関数はすべて、現在のプロセスを置き換える形で新たなプログラ
     ムを実行します ; 現在のプロセスは返り値を返しません。 Unix では、新
     たに実行される実行コードは現在のプロセス内に読み込まれ、呼び出し側
     と同じプロセス ID を持つことになります。エラーは *note OSError:
     3f0. 例外として報告されます。

     現在のプロセスは瞬時に置き換えられます。開かれているファイルオブジ
     ェクトやファイル記述子はフラッシュされません。そのため、バッファ内
     にデータが残っているかもしれない場合、 *note exec*: 2b17. 関数を実
     行する前に ‘sys.stdout.flush()’ か *note os.fsync(): d5b. を利用し
     てバッファをフラッシュしておく必要があります。

     The "l" and "v" variants of the *note exec*: 2b17. functions differ
     in how command-line arguments are passed.  The "l" variants are
     perhaps the easiest to work with if the number of parameters is
     fixed when the code is written; the individual parameters simply
     become additional parameters to the ‘execl*()’ functions.  The "v"
     variants are good when the number of parameters is variable, with
     the arguments being passed in a list or tuple as the 'args'
     parameter.  In either case, the arguments to the child process
     should start with the name of the command being run, but this is
     not enforced.

     The variants which include a "p" near the end (*note execlp():
     2b1a, *note execlpe(): 2b1b, *note execvp(): 2b1c, and *note
     execvpe(): 2b1d.) will use the ‘PATH’ environment variable to
     locate the program 'file'.  When the environment is being replaced
     (using one of the *note exec*e: 2b17. variants, discussed in the
     next paragraph), the new environment is used as the source of the
     ‘PATH’ variable.  The other variants, *note execl(): 2b17, *note
     execle(): 2b19, *note execv(): 2a77, and *note execve(): 10cc, will
     not use the ‘PATH’ variable to locate the executable; 'path' must
     contain an appropriate absolute or relative path.  Relative paths
     must include at least one slash, even on Windows, as plain names
     will not be resolved.

     *note execle(): 2b19. 、 *note execlpe(): 2b1b. 、 *note execve():
     10cc. 、および *note execvpe(): 2b1d. (すべて末尾に "e" がついてい
     ます) では、 'env' 引数は新たなプロセスで利用される環境変数を定義す
     るためのマップ型でなくてはなりません ( 現在のプロセスの環境変数の代
     わりに利用されます ); *note execl(): 2b17. 、 *note execlp(): 2b1a.
     、 *note execv(): 2a77. 、および *note execvp(): 2b1c. では、すべて
     新たなプロセスは現在のプロセスの環境を引き継ぎます。

     一部のプラットフォームの *note execve(): 10cc. では、'path' はオー
     プンしているファイル記述子で指定することもできます。この機能をサポ
     ートしていないプラットフォームもあります; *note os.supports_fd:
     10d0. を使うことで利用可能かどうか調べることができます。利用できな
     い場合、*note NotImplementedError: 209. が送出されます。

     引数 ‘path’, ‘args’, ‘env’ を指定して *note 監査イベント: 1825.
     ‘os.exec’ を送出します。

     *note Availability: 1cbe.: Unix, Windows, not WASI, not Android,
     not iOS.

     バージョン 3.3 で変更: Added support for specifying 'path' as an
     open file descriptor for *note execve(): 10cc.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: os._exit (n)

     終了ステータス 'n' でプロセスを終了します。この時クリーンアップハン
     ドラーの呼び出しや、標準入出力バッファのフラッシュなどは行いません
     。

          注釈: The standard way to exit is *note sys.exit(n): 1318.
          ‘_exit()’ should normally only be used in the child process
          after a *note fork(): 17c.

以下の終了コードは必須ではありませんが *note _exit(): 21f4. で使うことが
できます。一般に、メールサーバーの外部コマンド配送プログラムのような、
Python で書かれたシステムプログラムに使います。

     注釈: いくつかのバリエーションがあって、これらのすべてがすべての
     Unix プラットフォームで使えるわけではありません。以下の定数は下層の
     プラットフォームで定義されていれば定義されます。

 -- データ: os.EX_OK

     Exit code that means no error occurred.  May be taken from the
     defined value of ‘EXIT_SUCCESS’ on some platforms.  Generally has a
     value of zero.

     *note Availability: 1cbe.: Unix, Windows.

 -- データ: os.EX_USAGE

     誤った個数の引数が渡された時など、コマンドが間違って使われたことを
     表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_DATAERR

     入力データが誤っていたことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_NOINPUT

     入力ファイルが存在しなかった、または、読み込み不可だったことを表す
     終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_NOUSER

     指定されたユーザーが存在しなかったことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_NOHOST

     指定されたホストが存在しなかったことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_UNAVAILABLE

     要求されたサービスが利用できないことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_SOFTWARE

     内部ソフトウェアエラーが検出されたことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_OSERR

     fork できない、 pipe の作成ができないなど、オペレーティングシステム
     のエラーが検出されたことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_OSFILE

     システムファイルが存在しなかった、開けなかった、あるいはその他のエ
     ラーが起きたことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_CANTCREAT

     ユーザーには作成できない出力ファイルを指定したことを表す終了コード
     。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_IOERR

     ファイルの I/O を行っている途中にエラーが発生した時の終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_TEMPFAIL

     一時的な失敗が発生したことを表す終了コード。これは、再試行可能な操
     作の途中に、ネットワークに接続できないというような、実際にはエラー
     ではないかも知れないことを意味します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_PROTOCOL

     プロトコル交換が不正、不適切、または理解不能なことを表す終了コード
     。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_NOPERM

     操作を行うために十分な許可がなかった（ファイルシステムの問題を除く
     ）ことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_CONFIG

     設定エラーが起こったことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- データ: os.EX_NOTFOUND

     "an entry was not found" のようなことを表す終了コード。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.fork ()

     子プロセスを fork します。子プロセスでは ‘0’ が返り、親プロセスでは
     子プロセスの id が返ります。エラーが発生した場合は、 *note OSError:
     3f0. を送出します。

     FreeBSD 6.3 以下、Cygwinを含む一部のプラットフォームにおいて、
     ‘fork()’ をスレッド内から利用した場合に既知の問題があることに注意し
     てください。

     引数無しで *note 監査イベント: 1825. ‘os.fork’ を送出します。

          警告: If you use TLS sockets in an application calling
          ‘fork()’, see the warning in the *note ssl: bb. documentation.

          警告: On macOS the use of this function is unsafe when mixed
          with using higher-level system APIs, and that includes using
          *note urllib.request: f4.

     バージョン 3.8 で変更: Calling ‘fork()’ in a subinterpreter is no
     longer supported (*note RuntimeError: 17a. is raised).

     バージョン 3.12 で変更: If Python is able to detect that your
     process has multiple threads, *note os.fork(): 17c. now raises a
     *note DeprecationWarning: 18a.

     We chose to surface this as a warning, when detectable, to better
     inform developers of a design problem that the POSIX platform
     specifically notes as not supported.  Even in code that 'appears'
     to work, it has never been safe to mix threading with *note
     os.fork(): 17c. on POSIX platforms.  The CPython runtime itself has
     always made API calls that are not safe for use in the child
     process when threads existed in the parent (such as ‘malloc’ and
     ‘free’).

     Users of macOS or users of libc or malloc implementations other
     than those typically found in glibc to date are among those already
     more likely to experience deadlocks running such code.

     See this discussion on fork being incompatible with threads(2) for
     technical details of why we're surfacing this longstanding platform
     compatibility problem to developers.

     *note Availability: 1cbe.: POSIX, not WASI, not Android, not iOS.

 -- の関数: os.forkpty ()

     子プロセスを fork します。この時新しい擬似端末を子プロセスの制御端
     末として使います。親プロセスでは ‘(pid, fd)’ からなるペアが返り、
     'fd' は擬似端末のマスター側のファイル記述子となります。可搬性のある
     アプローチを取るには、 *note pty: 9f. モジュールを利用してください
     。エラーが発生した場合は、 *note OSError: 3f0. を送出します。

     引数無しで *note 監査イベント: 1825. ‘os.forkpty’ を送出します。

          警告: On macOS the use of this function is unsafe when mixed
          with using higher-level system APIs, and that includes using
          *note urllib.request: f4.

     バージョン 3.8 で変更: Calling ‘forkpty()’ in a subinterpreter is
     no longer supported (*note RuntimeError: 17a. is raised).

     バージョン 3.12 で変更: If Python is able to detect that your
     process has multiple threads, this now raises a *note
     DeprecationWarning: 18a.  See the longer explanation on *note
     os.fork(): 17c.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.kill (pid, sig, /)

     プロセス 'pid' にシグナル 'sig' を送ります。ホストプラットフォーム
     で利用可能なシグナルを特定する定数は *note signal: b4. モジュールで
     定義されています。

     Windows: The *note signal.CTRL_C_EVENT: 1330. and *note
     signal.CTRL_BREAK_EVENT: 1331. signals are special signals which
     can only be sent to console processes which share a common console
     window, e.g., some subprocesses.  Any other value for 'sig' will
     cause the process to be unconditionally killed by the
     TerminateProcess API, and the exit code will be set to 'sig'.

     *note signal.pthread_kill(): 1104. も参照してください。

     引数 ‘pid’, ‘sig’ を指定して *note 監査イベント: 1825. ‘os.kill’ を
     送出します。

     *note Availability: 1cbe.: Unix, Windows, not WASI, not iOS.

     バージョン 3.2 で変更: Windows サポートを追加しました。

 -- の関数: os.killpg (pgid, sig, /)

     プロセスグループ 'pgid' にシグナル 'sig' を送ります。

     引数 ‘pgid’, ‘sig’ を指定して *note 監査イベント: 1825. ‘os.killpg’
     を送出します。

     *note Availability: 1cbe.: Unix, not WASI, not iOS.

 -- の関数: os.nice (increment, /)

     プロセスの "nice 値 " に 'increment' を加えます。新たな nice 値を返
     します。

     *note Availability: 1cbe.: Unix, not WASI.

 -- の関数: os.pidfd_open (pid, flags=0)

     Return a file descriptor referring to the process 'pid' with
     'flags' set.  This descriptor can be used to perform process
     management without races and signals.

     See the ‘pidfd_open(2)(3)’ man page for more details.

     *note Availability: 1cbe.: Linux >= 5.3, Android >= *note
     build-time: b58. API level 31

     Added in version 3.9.

      -- データ: os.PIDFD_NONBLOCK

          This flag indicates that the file descriptor will be
          non-blocking.  If the process referred to by the file
          descriptor has not yet terminated, then an attempt to wait on
          the file descriptor using ‘waitid(2)(4)’ will immediately
          return the error *note EAGAIN: 21fa. rather than blocking.

     *note Availability: 1cbe.: Linux >= 5.10

     Added in version 3.12.

 -- の関数: os.plock (op, /)

     プログラムのセグメントをメモリ内にロックします。 'op'
     (‘<sys/lock.h>’ で定義されています ) にはどのセグメントをロックする
     かを指定します。

     *note Availability: 1cbe.: Unix, not WASI, not iOS.

 -- の関数: os.popen (cmd, mode='r', buffering=-1)

     コマンド 'cmd' への、または 'cmd' からのパイプ入出力を開きます。戻
     り値はパイプに接続されている開かれたファイルオブジェクトで、 'mode'
     が ‘'r'’ (デフォルト) または ‘'w'’ かによって読み出しまたは書き込み
     を行うことができます。引数 'bufsize' は、組み込み関数 *note open():
     4e5. における対応する引数と同じ意味を持ちます。 返されるファイルオ
     ブジェクトは、バイトではなくテキスト文字列を読み書きします。

     ‘close’ メソッドは、サブプロセスが正常に終了した場合は *note None:
     641. を返し、エラーが発生した場合にはサブプロセスの返りコードを返し
     ます。POSIX システムでは、返りコードが正の場合、そのコードは1バイト
     左にシフトしてプロセスが終了したことを示します。返りコードが負の場
     合、プロセスは返りコードの符号を変えた信号により終了します 。 (例え
     ば、サブプロセスが kill された場合、返り値は ‘- signal.SIGKILL’ と
     なる場合があります。) Windows システムでは、返り値には子プロセスか
     らの符号のついた整数の返りコードを含まれます。

     On Unix, *note waitstatus_to_exitcode(): 8eb. can be used to
     convert the ‘close’ method result (exit status) into an exit code
     if it is not ‘None’.  On Windows, the ‘close’ method result is
     directly the exit code (or ‘None’).

     これは、*note subprocess.Popen: 17e. を使用して実装されています。サ
     ブプロセスを管理し、サブプロセスと通信を行うためのより強力な方法に
     ついては、クラスのドキュメンテーションを参照してください。

     *note Availability: 1cbe.: not WASI, not Android, not iOS.

          注釈: The *note Python UTF-8 Mode: 622. affects encodings used
          for 'cmd' and pipe contents.

          *note popen(): a55. is a simple wrapper around *note
          subprocess.Popen: 17e.  Use *note subprocess.Popen: 17e. or
          *note subprocess.run(): b54. to control options like
          encodings.

 -- の関数: os.posix_spawn (path, argv, env, *, file_actions=None,
          setpgroup=None, resetids=False, setsid=False, setsigmask=(),
          setsigdef=(), scheduler=None)

     Wraps the ‘posix_spawn()’ C library API for use from Python.

     大部分のユーザーは *note posix_spawn(): 201. ではなく、 *note
     subprocess.run(): b54. を使うべきです。

     The positional-only arguments 'path', 'args', and 'env' are similar
     to *note execve(): 10cc.  'env' is allowed to be ‘None’, in which
     case current process' environment is used.

     'path' には実行ファイルへのパスを指定します。 'path' はディレクトリ
     を含む形（実行ファイルへの絶対パスまたは相対パス）で指定する必要が
     あります。実行ファイル名のみを指定したい場合は *note
     posix_spawnp(): 199a. を使ってください。

     'file_actions' 引数はCライブラリ実装の ‘fork()’ と ‘exec()’ の間で
     子プロセスが持つファイルデスクリプタに対して行うアクションを記述す
     るタプルのシーケンスです。各タプルの最初の要素は、残りのタプル要素
     の解釈方法を指定する以下の3つの型指定子のうちのひとつでなければなり
     ません。

      -- データ: os.POSIX_SPAWN_OPEN

          (‘os.POSIX_SPAWN_OPEN’, 'fd', 'path', 'flags', 'mode')

          ‘os.dup2(os.open(path, flags, mode), fd)’ を実行します。

      -- データ: os.POSIX_SPAWN_CLOSE

          (‘os.POSIX_SPAWN_CLOSE’, 'fd')

          ‘os.close(fd)’ を実行します。

      -- データ: os.POSIX_SPAWN_DUP2

          (‘os.POSIX_SPAWN_DUP2’, 'fd', 'new_fd')

          ‘os.dup2(fd, new_fd)’ を実行します。

      -- データ: os.POSIX_SPAWN_CLOSEFROM

          (‘os.POSIX_SPAWN_CLOSEFROM’, 'fd')

          Performs ‘os.closerange(fd, INF)’.

     These tuples correspond to the C library
     ‘posix_spawn_file_actions_addopen()’,
     ‘posix_spawn_file_actions_addclose()’,
     ‘posix_spawn_file_actions_adddup2()’, and
     ‘posix_spawn_file_actions_addclosefrom_np()’ API calls used to
     prepare for the ‘posix_spawn()’ call itself.

     The 'setpgroup' argument will set the process group of the child to
     the value specified.  If the value specified is 0, the child's
     process group ID will be made the same as its process ID. If the
     value of 'setpgroup' is not set, the child will inherit the
     parent's process group ID. This argument corresponds to the C
     library ‘POSIX_SPAWN_SETPGROUP’ flag.

     If the 'resetids' argument is ‘True’ it will reset the effective
     UID and GID of the child to the real UID and GID of the parent
     process.  If the argument is ‘False’, then the child retains the
     effective UID and GID of the parent.  In either case, if the
     set-user-ID and set-group-ID permission bits are enabled on the
     executable file, their effect will override the setting of the
     effective UID and GID. This argument corresponds to the C library
     ‘POSIX_SPAWN_RESETIDS’ flag.

     If the 'setsid' argument is ‘True’, it will create a new session ID
     for ‘posix_spawn’.  'setsid' requires ‘POSIX_SPAWN_SETSID’ or
     ‘POSIX_SPAWN_SETSID_NP’ flag.  Otherwise, *note
     NotImplementedError: 209. is raised.

     The 'setsigmask' argument will set the signal mask to the signal
     set specified.  If the parameter is not used, then the child
     inherits the parent's signal mask.  This argument corresponds to
     the C library ‘POSIX_SPAWN_SETSIGMASK’ flag.

     The 'sigdef' argument will reset the disposition of all signals in
     the set specified.  This argument corresponds to the C library
     ‘POSIX_SPAWN_SETSIGDEF’ flag.

     The 'scheduler' argument must be a tuple containing the (optional)
     scheduler policy and an instance of *note sched_param: 1509. with
     the scheduler parameters.  A value of ‘None’ in the place of the
     scheduler policy indicates that is not being provided.  This
     argument is a combination of the C library
     ‘POSIX_SPAWN_SETSCHEDPARAM’ and ‘POSIX_SPAWN_SETSCHEDULER’ flags.

     引数 ‘path’, ‘argv’, ‘env’ を指定して *note 監査イベント: 1825.
     ‘os.posix_spawn’ を送出します。

     Added in version 3.8.

     バージョン 3.13 で変更: 'env' parameter accepts ‘None’.
     ‘os.POSIX_SPAWN_CLOSEFROM’ is available on platforms where
     ‘posix_spawn_file_actions_addclosefrom_np()’ exists.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.posix_spawnp (path, argv, env, *, file_actions=None,
          setpgroup=None, resetids=False, setsid=False, setsigmask=(),
          setsigdef=(), scheduler=None)

     Wraps the ‘posix_spawnp()’ C library API for use from Python.

     Similar to *note posix_spawn(): 201. except that the system
     searches for the 'executable' file in the list of directories
     specified by the ‘PATH’ environment variable (in the same way as
     for ‘execvp(3)’).

     引数 ‘path’, ‘argv’, ‘env’ を指定して *note 監査イベント: 1825.
     ‘os.posix_spawn’ を送出します。

     Added in version 3.8.

     *note Availability: 1cbe.: POSIX, not WASI, not Android, not iOS.

     See *note posix_spawn(): 201. documentation.

 -- の関数: os.register_at_fork (*, before=None, after_in_parent=None,
          after_in_child=None)

     Register callables to be executed when a new child process is
     forked using *note os.fork(): 17c. or similar process cloning APIs.
     The parameters are optional and keyword-only.  Each specifies a
     different call point.

        * 'before' is a function called before forking a child process.

        * 'after_in_parent' is a function called from the parent process
          after forking a child process.

        * 'after_in_child' is a function called from the child process.

     These calls are only made if control is expected to return to the
     Python interpreter.  A typical *note subprocess: c1. launch will
     not trigger them as the child is not going to re-enter the
     interpreter.

     Functions registered for execution before forking are called in
     reverse registration order.  Functions registered for execution
     after forking (either in the parent or in the child) are called in
     registration order.

     Note that ‘fork()’ calls made by third-party C code may not call
     those functions, unless it explicitly calls *note
     PyOS_BeforeFork(): b8d, *note PyOS_AfterFork_Parent(): b8e. and
     *note PyOS_AfterFork_Child(): 3d4.

     There is no way to unregister a function.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

     Added in version 3.7.

 -- の関数: os.spawnl (mode, path, ...)
 -- の関数: os.spawnle (mode, path, ..., env)
 -- の関数: os.spawnlp (mode, file, ...)
 -- の関数: os.spawnlpe (mode, file, ..., env)
 -- の関数: os.spawnv (mode, path, args)
 -- の関数: os.spawnve (mode, path, args, env)
 -- の関数: os.spawnvp (mode, file, args)
 -- の関数: os.spawnvpe (mode, file, args, env)

     新たなプロセス内でプログラム 'path' を実行します。

     (*note subprocess: c1. モジュールが、新しいプロセスを実行して結果を
     取得するための、より強力な機能を提供しています。この関数の代わりに
     *note subprocess: c1. モジュールを利用することが推奨されています。
     *note subprocess: c1. モジュールのドキュメントの、 *note 古い関数を
     subprocess モジュールで置き換える: 115b. セクションを参照してくださ
     い )

     'mode' が *note P_NOWAIT: 2b3a. の場合、この関数は新たなプロセスの
     プロセス ID を返します ; 'mode' が *note P_WAIT: 2b3b. の場合、子プ
     ロセスが正常に終了するとその終了コードが返ります。そうでない場合に
     はプロセスを kill したシグナル 'signal' に対して ‘-signal’ が返りま
     す。 Windows では、プロセス ID は実際にはプロセスハンドル値になるの
     で、 *note waitpid(): d67. 関数で使えます。

     Note on VxWorks, this function doesn't return ‘-signal’ when the
     new process is killed.  Instead it raises OSError exception.

     The "l" and "v" variants of the *note spawn*: 1699. functions
     differ in how command-line arguments are passed.  The "l" variants
     are perhaps the easiest to work with if the number of parameters is
     fixed when the code is written; the individual parameters simply
     become additional parameters to the ‘spawnl*()’ functions.  The "v"
     variants are good when the number of parameters is variable, with
     the arguments being passed in a list or tuple as the 'args'
     parameter.  In either case, the arguments to the child process must
     start with the name of the command being run.

     末尾近くに "p" をもつ型 (*note spawnlp(): 2b34, *note spawnlpe():
     2b35, *note spawnvp(): 2b38, *note spawnvpe(): 2b39.) は、プログラ
     ム 'file' を探すために環境変数 ‘PATH’ を利用します。環境変数が ( 次
     の段で述べる *note spawn*e: 1699. 型関数で ) 置き換えられる場合、環
     境変数は ‘PATH’ を決定する上の情報源として使われます。その他の型、
     *note spawnl(): 1699, *note spawnle(): 2b33, *note spawnv(): 2b36,
     および *note spawnve(): 2b37. では、実行コードを探すために ‘PATH’ を
     使いません。 'path' には適切に設定された絶対パスまたは相対パスが入
     っていなくてはなりません。

     *note spawnle(): 2b33, *note spawnlpe(): 2b35, *note spawnve():
     2b37, および *note spawnvpe(): 2b39. (すべて末尾に "e" がついていま
     す) では、 'env' 引数は新たなプロセスで利用される環境変数を定義する
     ためのマップ型でなくてはなりません ; *note spawnl(): 1699. 、 *note
     spawnlp(): 2b34. 、 *note spawnv(): 2b36. 、および *note spawnvp():
     2b38. では、すべて新たなプロセスは現在のプロセスの環境を引き継ぎま
     す。 'env' 辞書のキーと値はすべて文字列である必要があります。不正な
     キーや値を与えると関数が失敗し、 ‘127’ を返します。

     例えば、以下の *note spawnlp(): 2b34. および *note spawnvpe():
     2b39. 呼び出しは等価です

          import os
          os.spawnlp(os.P_WAIT, 'cp', 'cp', 'index.html', '/dev/null')

          L = ['cp', 'index.html', '/dev/null']
          os.spawnvpe(os.P_WAIT, 'cp', L, os.environ)

     引数 ‘mode’, ‘path’, ‘args’, ‘env’ を指定して *note 監査イベント:
     1825. ‘os.spawn’ を送出します。

     *note Availability: 1cbe.: Unix, Windows, not WASI, not Android,
     not iOS.

     *note spawnlp(): 2b34. 、 *note spawnlpe(): 2b35. 、 *note
     spawnvp(): 2b38. 、および *note spawnvpe(): 2b39. は Windows では利
     用できません。 *note spawnle(): 2b33. および *note spawnve(): 2b37.
     は Windows においてスレッドセーフではありません ; 代わりに *note
     subprocess: c1. モジュールの利用を推奨します。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- データ: os.P_NOWAIT
 -- データ: os.P_NOWAITO

     Possible values for the 'mode' parameter to the *note spawn*: 1699.
     family of functions.  If either of these values is given, the *note
     spawn*: 1699. functions will return as soon as the new process has
     been created, with the process id as the return value.

     *note Availability: 1cbe.: Unix, Windows.

 -- データ: os.P_WAIT

     Possible value for the 'mode' parameter to the *note spawn*: 1699.
     family of functions.  If this is given as 'mode', the *note spawn*:
     1699. functions will not return until the new process has run to
     completion and will return the exit code of the process the run is
     successful, or ‘-signal’ if a signal kills the process.

     *note Availability: 1cbe.: Unix, Windows.

 -- データ: os.P_DETACH
 -- データ: os.P_OVERLAY

     *note spawn*: 1699. 関数ファミリに対する 'mode' パラメタとして取れ
     る値です。これらの値は上の値よりもやや可搬性において劣っています。
     *note P_DETACH: 2b3d. は *note P_NOWAIT: 2b3a. に似ていますが、新た
     なプロセスは呼び出しプロセスのコンソールから切り離され (detach) ま
     す。 *note P_OVERLAY: 2b3e. が使われた場合、現在のプロセスは置き換
     えられます。したがって *note spawn*: 1699. は返りません。

     *note Availability: 1cbe.: Windows.

 -- の関数: os.startfile (path[, operation][, arguments][, cwd][,
          show_cmd])

     ファイルを関連付けられたアプリケーションを使ってスタートします。

     When 'operation' is not specified, this acts like double-clicking
     the file in Windows Explorer, or giving the file name as an
     argument to the ‘start’ command from the interactive command shell:
     the file is opened with whatever application (if any) its extension
     is associated.

     When another 'operation' is given, it must be a "command verb" that
     specifies what should be done with the file.  Common verbs
     documented by Microsoft are ‘'open'’, ‘'print'’ and ‘'edit'’ (to be
     used on files) as well as ‘'explore'’ and ‘'find'’ (to be used on
     directories).

     When launching an application, specify 'arguments' to be passed as
     a single string.  This argument may have no effect when using this
     function to launch a document.

     The default working directory is inherited, but may be overridden
     by the 'cwd' argument.  This should be an absolute path.  A
     relative 'path' will be resolved against this argument.

     Use 'show_cmd' to override the default window style.  Whether this
     has any effect will depend on the application being launched.
     Values are integers as supported by the Win32 ‘ShellExecute()’
     function.

     *note startfile(): 1836. returns as soon as the associated
     application is launched.  There is no option to wait for the
     application to close, and no way to retrieve the application's exit
     status.  The 'path' parameter is relative to the current directory
     or 'cwd'.  If you want to use an absolute path, make sure the first
     character is not a slash (‘'/'’) Use *note pathlib: 93. or the
     *note os.path.normpath(): 12e9. function to ensure that paths are
     properly encoded for Win32.

     To reduce interpreter startup overhead, the Win32 ‘ShellExecute()’
     function is not resolved until this function is first called.  If
     the function cannot be resolved, *note NotImplementedError: 209.
     will be raised.

     引数 ‘path’, ‘operation’ を指定して *note 監査イベント: 1825.
     ‘os.startfile’ を送出します。

     Raises an *note auditing event: 1825. ‘os.startfile/2’ with
     arguments ‘path’, ‘operation’, ‘arguments’, ‘cwd’, ‘show_cmd’.

     *note Availability: 1cbe.: Windows.

     バージョン 3.10 で変更: Added the 'arguments', 'cwd' and 'show_cmd'
     arguments, and the ‘os.startfile/2’ audit event.

 -- の関数: os.system (command)

     Execute the command (a string) in a subshell.  This is implemented
     by calling the Standard C function ‘system()’, and has the same
     limitations.  Changes to *note sys.stdin: 507, etc.  are not
     reflected in the environment of the executed command.  If 'command'
     generates any output, it will be sent to the interpreter standard
     output stream.  The C standard does not specify the meaning of the
     return value of the C function, so the return value of the Python
     function is system-dependent.

     On Unix, the return value is the exit status of the process encoded
     in the format specified for *note wait(): d65.

     Windows では、返り値は 'command' を実行した後にシステムシェルから返
     される値です。シェルは通常 ‘cmd.exe’ であり、返す値は実行したコマン
     ドの終了ステータスになります。シェルの種類は Windows の環境変数
     ‘COMSPEC’: に指定されています。ネイティブでないシェルを使用している
     場合は、そのドキュメントを参照してください。

     *note subprocess: c1. モジュールは、新しいプロセスを実行して結果を
     取得するためのより強力な機能を提供しています。この関数の代わりに
     *note subprocess: c1. モジュールを利用することが推奨されています。
     *note subprocess: c1. モジュールのドキュメントの *note 古い関数を
     subprocess モジュールで置き換える: 115b. 節のレシピを参考にして下さ
     い。

     On Unix, *note waitstatus_to_exitcode(): 8eb. can be used to
     convert the result (exit status) into an exit code.  On Windows,
     the result is directly the exit code.

     引数 ‘command’ を指定して *note 監査イベント: 1825. ‘os.system’ を
     送出します。

     *note Availability: 1cbe.: Unix, Windows, not WASI, not Android,
     not iOS.

 -- の関数: os.times ()

     現在の全体的なプロセス時間を返します。返り値は 5 個の属性を持つオブ
     ジェクトになります:

        * ‘user’ - user time

        * ‘system’ - system time

        * ‘children_user’ - user time of all child processes

        * ‘children_system’ - system time of all child processes

        * ‘elapsed’ - elapsed real time since a fixed point in the past

     後方互換性のため、このオブジェクトは 5 個のアイテム ‘user’ 、
     ‘system’ 、 ‘children_user’ 、 ‘children_system’ 、および ‘elapsed’
     を持つタプルのようにも振る舞います。

     See the Unix manual page ‘times(2)(5)’ and times(3)(6) manual page
     on Unix or the GetProcessTimes MSDN(7) on Windows.  On Windows,
     only ‘user’ and ‘system’ are known; the other attributes are zero.

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.3 で変更: 返り値の型が、タプルから属性名のついたタプル
     ライクオブジェクトに変更されました。

 -- の関数: os.wait ()

     子プロセスの実行完了を待機し、子プロセスの pid と終了コードインジケ
     ーター -- 16 ビットの数値で、下位バイトがプロセスを kill したシグナ
     ル番号、上位バイトが終了ステータス ( シグナル番号がゼロの場合 ) --
     の入ったタプルを返します ; コアダンプファイルが生成された場合、下位
     バイトの最上桁ビットが立てられます。

     If there are no children that could be waited for, *note
     ChildProcessError: 102c. is raised.

     戻り値の終了ステータスを終了コードに変換するために *note
     waitstatus_to_exitcode(): 8eb. を使うことができます。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

     参考
     ....

     The other ‘wait*()’ functions documented below can be used to wait
     for the completion of a specific child process and have more
     options.  *note waitpid(): d67. is the only one also available on
     Windows.

 -- の関数: os.waitid (idtype, id, options, /)

     Wait for the completion of a child process.

     'idtype' can be *note P_PID: 2b3f, *note P_PGID: 2b40, *note P_ALL:
     2b41, or (on Linux) *note P_PIDFD: 8e8.  The interpretation of 'id'
     depends on it; see their individual descriptions.

     'options' is an OR combination of flags.  At least one of *note
     WEXITED: 2b42, *note WSTOPPED: 2b43. or *note WCONTINUED: 2b44. is
     required; *note WNOHANG: 2b45. and *note WNOWAIT: 2b46. are
     additional optional flags.

     The return value is an object representing the data contained in
     the ‘siginfo_t’ structure with the following attributes:

        * ‘si_pid’ (process ID)

        * ‘si_uid’ (real user ID of the child)

        * ‘si_signo’ (always *note SIGCHLD: 2b47.)

        * ‘si_status’ (the exit status or signal number, depending on
          ‘si_code’)

        * ‘si_code’ (see *note CLD_EXITED: 2b48. for possible values)

     If *note WNOHANG: 2b45. is specified and there are no matching
     children in the requested state, ‘None’ is returned.  Otherwise, if
     there are no matching children that could be waited for, *note
     ChildProcessError: 102c. is raised.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

     Added in version 3.3.

     バージョン 3.13 で変更: This function is now available on macOS as
     well.

 -- の関数: os.waitpid (pid, options, /)

     この関数の詳細は Unix と Windows で異なります。

     Unix の場合 : プロセス id 'pid' で与えられた子プロセスの完了を待機
     し、子プロセスのプロセス id と (*note wait(): d65. と同様にコード化
     された ) 終了ステータスインジケーターからなるタプルを返します。この
     関数の動作は 'options' によって変わります。通常の操作では ‘0’ にし
     ます。

     'pid' が ‘0’ よりも大きい場合、 *note waitpid(): d67. は特定のプロ
     セスのステータス情報を要求します。 'pid' が ‘0’ の場合、現在のプロ
     セスグループ内の任意の子プロセスの状態に対する要求です。 'pid' が
     ‘-1’ の場合、現在のプロセスの任意の子プロセスに対する要求です。
     'pid' が ‘-1’ よりも小さい場合、プロセスグループ ‘-pid’ ( すなわち
     'pid' の絶対値 ) 内の任意のプロセスに対する要求です。

     'options' is an OR combination of flags.  If it contains *note
     WNOHANG: 2b45. and there are no matching children in the requested
     state, ‘(0, 0)’ is returned.  Otherwise, if there are no matching
     children that could be waited for, *note ChildProcessError: 102c.
     is raised.  Other options that can be used are *note WUNTRACED:
     2b49. and *note WCONTINUED: 2b44.

     Windows では、プロセスハンドル 'pid' を指定してプロセスの終了を待っ
     て、 'pid' と、終了ステータスを 8bit 左シフトした値のタプルを返しま
     す。 ( シフトは、この関数をクロスプラットフォームで利用しやすくする
     ために行われます ) ‘0’ 以下の 'pid' は Windows では特別な意味を持っ
     ておらず、例外を発生させます。 'options' の値は効果がありません。
     'pid' は、子プロセスで無くても、プロセス ID を知っているどんなプロ
     セスでも参照することが可能です。 *note spawn*: 1699. 関数を *note
     P_NOWAIT: 2b3a. と共に呼び出した場合、適切なプロセスハンドルが返さ
     れます。

     戻り値の終了ステータスを終了コードに変換するために *note
     waitstatus_to_exitcode(): 8eb. を使うことができます。

     *note Availability: 1cbe.: Unix, Windows, not WASI, not Android,
     not iOS.

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、この関数は *note InterruptedError: d55. 例
     外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(8) を参照してください)。

 -- の関数: os.wait3 (options)

     *note waitpid(): d67. に似ていますが、プロセス id を引数に取らず、
     子プロセス id 、終了ステータスインジケータ、リソース使用情報の 3 要
     素からなるタプルを返します。リソース使用情報の詳しい情報は *note
     resource.getrusage(): 13d8. を参照してください。'options' 引数は
     *note waitpid(): d67. および *note wait4(): d64. に渡されるものと同
     じです。

     戻り値の終了ステータスを終了コードに変換するために *note
     waitstatus_to_exitcode(): 8eb. を使うことができます。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.wait4 (pid, options)

     *note waitpid(): d67. に似ていますが、子プロセス id 、終了ステータ
     スインジケータ、リソース使用情報の 3 要素からなるタプルを返します。
     リソース使用情報の詳しい情報は *note resource.getrusage(): 13d8. を
     参照してください。 *note wait4(): d64. の引数は *note waitpid():
     d67. に与えられるものと同じです。

     戻り値の終了ステータスを終了コードに変換するために *note
     waitstatus_to_exitcode(): 8eb. を使うことができます。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- データ: os.P_PID
 -- データ: os.P_PGID
 -- データ: os.P_ALL
 -- データ: os.P_PIDFD

     *note waitid(): d66. の 'idtype' に指定できる値です。これらは 'id'
     がどう解釈されるかに影響します:

        * ‘P_PID’ - wait for the child whose PID is 'id'.

        * ‘P_PGID’ - wait for any child whose progress group ID is 'id'.

        * ‘P_ALL’ - wait for any child; 'id' is ignored.

        * ‘P_PIDFD’ - wait for the child identified by the file
          descriptor 'id' (a process file descriptor created with *note
          pidfd_open(): 447.).

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

          注釈: ‘P_PIDFD’ is only available on Linux >= 5.4.

     Added in version 3.3.

     Added in version 3.9: The ‘P_PIDFD’ constant.

 -- データ: os.WCONTINUED

     This 'options' flag for *note waitpid(): d67, *note wait3(): d63,
     *note wait4(): d64, and *note waitid(): d66. causes child processes
     to be reported if they have been continued from a job control stop
     since they were last reported.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- データ: os.WEXITED

     This 'options' flag for *note waitid(): d66. causes child processes
     that have terminated to be reported.

     The other ‘wait*’ functions always report children that have
     terminated, so this option is not available for them.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

     Added in version 3.3.

 -- データ: os.WSTOPPED

     This 'options' flag for *note waitid(): d66. causes child processes
     that have been stopped by the delivery of a signal to be reported.

     This option is not available for the other ‘wait*’ functions.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

     Added in version 3.3.

 -- データ: os.WUNTRACED

     This 'options' flag for *note waitpid(): d67, *note wait3(): d63,
     and *note wait4(): d64. causes child processes to also be reported
     if they have been stopped but their current state has not been
     reported since they were stopped.

     This option is not available for *note waitid(): d66.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- データ: os.WNOHANG

     This 'options' flag causes *note waitpid(): d67, *note wait3():
     d63, *note wait4(): d64, and *note waitid(): d66. to return right
     away if no child process status is available immediately.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- データ: os.WNOWAIT

     This 'options' flag causes *note waitid(): d66. to leave the child
     in a waitable state, so that a later ‘wait*()’ call can be used to
     retrieve the child status information again.

     This option is not available for the other ‘wait*’ functions.

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- データ: os.CLD_EXITED
 -- データ: os.CLD_KILLED
 -- データ: os.CLD_DUMPED
 -- データ: os.CLD_TRAPPED
 -- データ: os.CLD_STOPPED
 -- データ: os.CLD_CONTINUED

     *note waitid(): d66. の返り値の ‘si_code’ に設定され得る値です。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

     Added in version 3.3.

     バージョン 3.9 で変更: *note CLD_KILLED: 8e6. と *note CLD_STOPPED:
     8e7. が追加されました。

 -- の関数: os.waitstatus_to_exitcode (status)

     待機ステータスを終了コードに変換します。

     Unix の場合:

        * 子プロセスが正常終了した場合 (‘WIFEXITED(status)``が真の場合
          )、子プロセスの終了ステータス (``WEXITSTATUS(status)’) を返し
          ます: 戻り値は0または正の整数です。

        * 子プロセスがシグナルによって終了した場合
          (‘WIFSIGNALED(status)``が真の場合)、子プロセスを終了したシグナ
          ルの番号に負符号をつけた ``-signum’ (‘-WTERMSIG(status)’) を返
          します: 戻り値は負の整数です。

        * それ以外の場合、 *note ValueError: 1e3. 例外を送出します。

     Windows の場合、 'status' を8ビット右にシフトした値を返します。

     Unix の場合、プロセスがトレースされているか *note waitpid(): d67. が
     *note WUNTRACED: 2b49. オプションをつけて実行されている場合、呼び出
     しもとは最初に ‘WIFSTOPPED(status)’ が真であるかを確認しなければな
     りません。この関数は ‘WIFSTOPPED(status)’ が真の場合呼び出してはい
     けません。

     参考
     ....

     *note WIFEXITED(): 2b4d, *note WEXITSTATUS(): 2b4e, *note
     WIFSIGNALED(): 2b4f, *note WTERMSIG(): 2b50, *note WIFSTOPPED():
     2b51, *note WSTOPSIG(): 2b52. 関数。

     *note Availability: 1cbe.: Unix, Windows, not WASI, not Android,
     not iOS.

     Added in version 3.9.

以下の関数は *note system(): 1402. 、 *note wait(): d65. 、あるいは
*note waitpid(): d67. が返すプロセス状態コードを引数にとります。これらの
関数はプロセスの配置を決めるために利用できます。

 -- の関数: os.WCOREDUMP (status, /)

     プロセスに対してコアダンプが生成されていた場合には ‘True’ を、それ
     以外の場合は ‘False’ を返します。

     この関数は *note WIFSIGNALED(): 2b4f. が真である場合のみ使用される
     べきです。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.WIFCONTINUED (status)

     Return ‘True’ if a stopped child has been resumed by delivery of
     *note SIGCONT: 2b55. (if the process has been continued from a job
     control stop), otherwise return ‘False’.

     *note WCONTINUED: 2b44. オプションを参照してください。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.WIFSTOPPED (status)

     プロセスがシグナルの送信によって中断させられた場合に ‘True’ を返し
     ます。それ以外の場合は ‘False’ を返します。

     *note WIFSTOPPED(): 2b51. は *note waitpid(): d67. が *note
     WUNTRACED: 2b49. オプションを使って実行されたか、もしくはプロセスが
     トレースされている場合 (‘ptrace(2)(9)’ を参照してください) にのみ
     ‘True’ を返します。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.WIFSIGNALED (status)

     プロセスがシグナルによって終了させられた場合に ‘True’ を返します。
     そうでない場合は ‘False’ を返します。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.WIFEXITED (status)

     プロセスが正常終了した場合、すなわち ‘exit()’ や ‘_exit()’ を呼び出
     したか、もしくは ‘main()’ から戻ることにより終了した場合に ‘True’ を
     返します。それ以外は ‘False’ を返します。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.WEXITSTATUS (status)

     プロセスの終了ステータスを返します。

     この関数は *note WIFEXITED(): 2b4d. が真である場合のみ使用されるべ
     きです。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.WSTOPSIG (status)

     プロセスを停止させたシグナル番号を返します。

     この関数は *note WIFSTOPPED(): 2b51. が真である場合のみ使用されるべ
     きです。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

 -- の関数: os.WTERMSIG (status)

     プロセスを終了させたシグナルの番号を返します。

     この関数は *note WIFSIGNALED(): 2b4f. が真である場合のみ使用される
     べきです。

     *note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

   ---------- Footnotes ----------

   (1) https://msdn.microsoft.com/44228cf2-6306-466c-8f16-f513cd3ba8b5

   (2) https://discuss.python.org/t/33555

   (3) https://manpages.debian.org/pidfd_open(2)

   (4) https://manpages.debian.org/waitid(2)

   (5) https://manpages.debian.org/times(2)

   (6) https://man.freebsd.org/cgi/man.cgi?time(3)

   (7) 
https://docs.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-getprocesstimes

   (8) https://peps.python.org/pep-0475/

   (9) https://manpages.debian.org/ptrace(2)


File: python.info,  Node: スケジューラーへのインターフェイス,  Next: 雑多なシステム情報,  Prev: プロセス管理,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.12 スケジューラーへのインターフェイス
............................................

以下の関数は、オペレーティングシステムがプロセスに CPU 時間を割り当てる
方法を制御します。これらは一部の Unix プラットフォームでのみ利用可能です
。詳しくは Unix マニュアルページを参照してください。

Added in version 3.3.

次のスケジューリングポリシーは、オペレーティングシステムでサポートされて
いれば公開されます。

 -- データ: os.SCHED_OTHER

     デフォルトのスケジューリングポリシーです。

 -- データ: os.SCHED_BATCH

     常にCPUに負荷のかかる (CPU-intensive) プロセス用のポリシーです。他
     の対話式プロセスなどの応答性を維持するよう試みます。

 -- データ: os.SCHED_IDLE

     非常に優先度の低いバックグラウンドタスク用のスケジューリングポリシ
     ーです。

 -- データ: os.SCHED_SPORADIC

     散発的なサーバープログラム用のスケジューリングポリシーです。

 -- データ: os.SCHED_FIFO

     FIFO (First In, First Out) 型のスケジューリングポリシーです。

 -- データ: os.SCHED_RR

     ラウンドロビン型のスケジューリングポリシーです。

 -- データ: os.SCHED_RESET_ON_FORK

     このフラグは他のスケジューリングポリシーとともに論理和指定できます
     。このフラグが与えられたプロセスが fork されると、その子プロセスの
     スケジューリングポリシーおよび優先度はデフォルトにリセットされます
     。

 -- クラス: os.sched_param (sched_priority)

     このクラスは、*note sched_setparam(): 10e2.、*note
     sched_setscheduler(): 10e3.、および *note sched_getparam(): 10de. で
     使用される、調節可能なスケジューリングパラメーターを表します。これ
     はイミュータブルです。

     現在、一つの引数のみ指定できます:

      -- の属性: sched_priority

          スケジューリングポリシーのスケジューリング優先度です。

 -- の関数: os.sched_get_priority_min (policy)

     'policy' の最小優先度値を取得します。'policy' には上記のスケジュー
     リングポリシー定数の一つを指定します。

 -- の関数: os.sched_get_priority_max (policy)

     'policy' の最大優先度値を取得します。'policy' には上記のスケジュー
     リングポリシー定数の一つを指定します。

 -- の関数: os.sched_setscheduler (pid, policy, param, /)

     PID 'pid' のプロセスのスケジューリングポリシーを設定します。'pid' が
     0 の場合、呼び出しプロセスを意味します。'policy' には上記のスケジュ
     ーリングポリシー定数の一つを指定します。'param' は *note
     sched_param: 1509. のインスタンスです。

 -- の関数: os.sched_getscheduler (pid, /)

     PID 'pid' のプロセスのスケジューリングポリシーを返します。'pid' が
     0 の場合、呼び出しプロセスを意味します。返り値は上記のスケジューリ
     ングポリシー定数の一つになります。

 -- の関数: os.sched_setparam (pid, param, /)

     PID 'pid' を持つプロセスのスケジューリングパラメータを設定します。
     'pid' を 0 とした場合呼び出しプロセスを意味します。 'param' は
     *note sched_param: 1509. インスタンスです。

 -- の関数: os.sched_getparam (pid, /)

     PID 'pid' のプロセスのスケジューリングパラメーターを *note
     sched_param: 1509. のインスタンスとして返します。'pid' が 0 の場合
     、呼び出しプロセスを意味します。

 -- の関数: os.sched_rr_get_interval (pid, /)

     PID 'pid' のプロセスのラウンドロビンクォンタム (秒) を返します。
     'pid' が 0 の場合、呼び出しプロセスを意味します。

 -- の関数: os.sched_yield ()

     自発的に CPU を解放します。

 -- の関数: os.sched_setaffinity (pid, mask, /)

     PID 'pid' のプロセス (0 であれば現在のプロセス) を CPU の集合に制限
     します。'mask' はプロセスを制限する CPU の集合を表す整数のイテラブ
     ルなオブジェクトです。

 -- の関数: os.sched_getaffinity (pid, /)

     Return the set of CPUs the process with PID 'pid' is restricted to.

     If 'pid' is zero, return the set of CPUs the calling thread of the
     current process is restricted to.

     See also the *note process_cpu_count(): 1a6. function.


File: python.info,  Node: 雑多なシステム情報,  Next: 乱数<2>,  Prev: スケジューラーへのインターフェイス,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.13 雑多なシステム情報
............................

 -- の関数: os.confstr (name, /)

     システム設定値を文字列で返します。 'name' には取得したい設定名を指
     定します ; この値は定義済みのシステム値名を表す文字列にすることがで
     きます ; 名前は多くの標準 (POSIX.1 、 Unix 95 、 Unix 98 その他 ) で
     定義されています。ホストオペレーティングシステムの関知する名前は
     ‘confstr_names’ 辞書のキーとして与えられています。このマップ型オブ
     ジェクトに入っていない設定変数については、 'name' に整数を渡しても
     かまいません。

     'name' に指定された設定値が定義されていない場合、 ‘None’ を返します
     。

     'name' が文字列で、かつ不明の場合、 *note ValueError: 1e3. を送出し
     ます。 'name' の指定値がホストシステムでサポートされておらず、
     ‘confstr_names’ にも入っていない場合、 *note errno.EINVAL: 195a. を
     エラー番号として *note OSError: 3f0. を送出します。

     *note Availability: 1cbe.: Unix.

 -- データ: os.confstr_names

     *note confstr(): 2b61. が受理する名前を、ホストオペレーティングシス
     テムで定義されている整数値に対応付けている辞書です。この辞書はシス
     テムでどの設定名が定義されているかを決定するために利用できます。

     *note Availability: 1cbe.: Unix.

 -- の関数: os.cpu_count ()

     Return the number of logical CPUs in the 'system'.  Returns ‘None’
     if undetermined.

     The *note process_cpu_count(): 1a6. function can be used to get the
     number of logical CPUs usable by the calling thread of the 'current
     process'.

     Added in version 3.4.

     バージョン 3.13 で変更: If *note -X cpu_count: 15c. is given or
     *note PYTHON_CPU_COUNT: 1f1. is set, *note cpu_count(): 1a7.
     returns the overridden value 'n'.

 -- の関数: os.getloadavg ()

     過去 1 分、 5 分、および 15 分間の、システムの実行キューの平均プロ
     セス数を返します。平均負荷が得られない場合には *note OSError: 3f0.
     を送出します。

     *note Availability: 1cbe.: Unix.

 -- の関数: os.process_cpu_count ()

     Get the number of logical CPUs usable by the calling thread of the
     'current process'.  Returns ‘None’ if undetermined.  It can be less
     than *note cpu_count(): 1a7. depending on the CPU affinity.

     The *note cpu_count(): 1a7. function can be used to get the number
     of logical CPUs in the 'system'.

     If *note -X cpu_count: 15c. is given or *note PYTHON_CPU_COUNT:
     1f1. is set, *note process_cpu_count(): 1a6. returns the overridden
     value 'n'.

     See also the *note sched_getaffinity(): 10dd. function.

     Added in version 3.13.

 -- の関数: os.sysconf (name, /)

     整数値のシステム設定値を返します。 'name' で指定された設定値が定義
     されていない場合、 ‘-1’ が返されます。 'name' に関するコメントとし
     ては、 *note confstr(): 2b61. で述べた内容が同様に当てはまります ;
     既知の設定名についての情報を与える辞書は ‘sysconf_names’ で与えられ
     ています。

     *note Availability: 1cbe.: Unix.

 -- データ: os.sysconf_names

     *note sysconf(): 2ac2. が受理する名前を、ホストオペレーティングシス
     テムで定義されている整数値に対応付けている辞書です。この辞書はシス
     テムでどの設定名が定義されているかを決定するために利用できます。

     *note Availability: 1cbe.: Unix.

     バージョン 3.11 で変更: Add ‘'SC_MINSIGSTKSZ'’ name.

以下のデータ値はパス名編集操作をサポートするために利用されます。これらの
値はすべてのプラットフォームで定義されています。

パス名に対する高水準の操作は *note os.path: 92. モジュールで定義されてい
ます。

 -- データ: os.curdir

     現在のディレクトリ参照するためにオペレーティングシステムで使われる
     文字列定数です。 POSIX と Windows では ‘'.'’ になります。 *note
     os.path: 92. からも利用できます。

 -- データ: os.pardir

     親ディレクトリを参照するためにオペレーティングシステムで使われる文
     字列定数です。 POSIX と Windows では ‘'..'’ になります。 *note
     os.path: 92. からも利用できます。

 -- データ: os.sep

     パス名を要素に分割するためにオペレーティングシステムで利用されてい
     る文字です。例えば POSIX では ‘'/'’ で、 Windows では ‘'\\'’ です。
     しかし、このことを知っているだけではパス名を解析したり、パス名同士
     を結合したりするには不十分です -- こうした操作には *note
     os.path.split(): 2725. や *note os.path.join(): 1597. を使用してく
     ださい -- が、たまに便利なこともあります。 *note os.path: 92. から
     も利用できます。

 -- データ: os.altsep

     文字パス名を要素に分割する際にオペレーティングシステムで利用される
     もう一つの文字で、分割文字が一つしかない場合には ‘None’ になります
     。この値は ‘sep’ がバックスラッシュとなっている DOS や Windows シス
     テムでは ‘'/'’ に設定されています。 *note os.path: 92. からも利用で
     きます。

 -- データ: os.extsep

     ベースのファイル名と拡張子を分ける文字です。例えば、 ‘os.py’ であれ
     ば ‘'.'’ です。 *note os.path: 92. からも利用できます。

 -- データ: os.pathsep

     ( ‘PATH’ のような ) サーチパス内の要素を分割するためにオペレーティ
     ングシステムが慣習的に用いる文字で、 POSIX における ‘':'’ や DOS お
     よび Windows における ‘';'’ に相当します。 *note os.path: 92. から
     も利用できます。

 -- データ: os.defpath

     *note exec*p*: 2b17. や *note spawn*p*: 1699. において、環境変数辞
     書内に ‘'PATH'’ キーがない場合に使われる標準設定のサーチパスです。
     *note os.path: 92. からも利用できます。

 -- データ: os.linesep

     現在のプラットフォーム上で行を分割 ( あるいは終端 ) するために用い
     られている文字列です。この値は例えば POSIX での ‘'\n'’ や Mac OS で
     の ‘'\r'’ のように、単一の文字にもなりますし、例えば Windows での
     ‘'\r\n'’ のように複数の文字列にもなります。テキストモードで開いたフ
     ァイルに書き込む時には、 'os.linesep' を利用しないでください。すべ
     てのプラットフォームで、単一の ‘'\n'’ を使用してください。

 -- データ: os.devnull

     ヌルデバイスのファイルパスです。例えば POSIX では ‘'/dev/null'’ で
     、 Windows では ‘'nul'’ です。この値は *note os.path: 92. からも利
     用できます。

 -- データ: os.RTLD_LAZY
 -- データ: os.RTLD_NOW
 -- データ: os.RTLD_GLOBAL
 -- データ: os.RTLD_LOCAL
 -- データ: os.RTLD_NODELETE
 -- データ: os.RTLD_NOLOAD
 -- データ: os.RTLD_DEEPBIND

     *note setdlopenflags(): 10f2. 関数と *note getdlopenflags(): 14b9.
     関数と一緒に使用するフラグ。それぞれのフラグの意味については、Unix
     マニュアルの ‘dlopen(3)(1)’ ページを参照してください。

     Added in version 3.3.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/dlopen(3)


File: python.info,  Node: 乱数<2>,  Prev: 雑多なシステム情報,  Up: os --- 雑多なオペレーティングシステムインターフェース

5.16.1.14 乱数
..............

 -- の関数: os.getrandom (size, flags=0)

     最大で 'size' バイトからなるランダムなバイト列を返します。この関数
     は要求されたバイト数よりも少ないバイト数を返すことがあります。

     バイト列は、ユーザー空間の乱数生成器や暗号目的ののシードとして利用
     できます。

     ‘getrandom()’ はデバイスドライバや他の環境ノイズ源から収集されたエ
     ントロピーに頼っています。不必要な大量のデータの読出しは、
     ‘/dev/random’ と ‘/dev/urandom’ デバイスの他のユーザーに負の影響を
     与えるでしょう。

     The flags argument is a bit mask that can contain zero or more of
     the following values ORed together: *note os.GRND_RANDOM: 2b66. and
     *note GRND_NONBLOCK: 2b67.

     Linux getrandom() manual page(1) も参照してください。

     *note Availability: 1cbe.: Linux >= 3.17.

     Added in version 3.6.

 -- の関数: os.urandom (size, /)

     暗号に関する用途に適した 'size' バイトからなるランダムなバイト文字
     列を返します。

     この関数は OS 固有の乱数発生源からランダムなバイト列を生成して返し
     ます。この関数の返すデータは暗号を用いたアプリケーションで十分利用
     できる程度に予測不能ですが、実際のクオリティは OS の実装によって異
     なります。

     Linux では、 ‘getrandom()’ システムコールが利用可能ならブロッキング
     モードで呼び出されます: すなわちシステムの urandom エントロピープー
     ルが初期化されるまで (128 ビットのエントロピーがカーネルにより収集
     されるまで) 処理がブロックされます。論拠については PEP 524(2) を参
     照してください。 Linux では、 (*note GRND_NONBLOCK: 2b67. フラグを
     使って) 非ブロッキングモードでランダムなバイトを取得したり、システ
     ムの urandom エントロピープールが初期化されるまでポーリングするため
     に *note getrandom(): c8b. 関数を利用することができます。

     Unix ライクなシステムでは、ランダムなバイトは ‘/dev/urandom’ デバイ
     スから読み込みます。 ‘/dev/urandom’ デバイスが利用できないか、もし
     くは読み取り不可のときは、 *note NotImplementedError: 209. 例外が送
     出されます。

     Windowsで、 ‘BCryptGenRandom()’ を使用します。

     参考
     ....

     *note secrets: ae. モジュールは高レベルの乱数生成機能を提供します。
     プラットフォームが提供する乱数生成器に対する簡便なインターフェース
     については、 *note random.SystemRandom: 2630. を参照してください。

     バージョン 3.5 で変更: Linux 3.17 以降では、使用可能な場合に
     ‘getrandom()’ システムコールが使用されるようになりました。OpenBSD
     5.6 以降では、C ‘getentropy()’ 関数が使用されるようになりました。こ
     れらの関数は、内部ファイル記述子を使用しません。

     バージョン 3.5.2 で変更: Linux において、 ‘getrandom()’ システムコ
     ールがブロックするなら (urandom エントロピープールが初期化されてい
     なければ) 、 ‘/dev/urandom’ を読む方法にフォールバックします。

     バージョン 3.6 で変更: Linuxで、 セキュリティを高めるために、
     ‘getrandom()’ をブロッキングモードで使用するようになりました。

     バージョン 3.11 で変更: On Windows, ‘BCryptGenRandom()’ is used
     instead of ‘CryptGenRandom()’ which is deprecated.

 -- データ: os.GRND_NONBLOCK

     デフォルトでは、*note getrandom(): c8b. は ‘/dev/random’ から読み込
     んだときにランダムなバイトが存在しない場合や、 ‘/dev/urandom’ から
     読み込んだときにエントロピープールが初期化されていない場合に処理を
     ブロックします。

     *note GRND_NONBLOCK: 2b67. フラグがセットされると、 *note
     getrandom(): c8b. はこれらの場合に処理をブロックせず、ただちに
     *note BlockingIOError: 102b. 例外を送出します。

     Added in version 3.6.

 -- データ: os.GRND_RANDOM

     このビットがセットされた場合、 ランダムバイトは ‘/dev/urandom’ プー
     ルの代わりに ‘/dev/random’ プールから取り出されます。

     Added in version 3.6.

   ---------- Footnotes ----------

   (1) https://man7.org/linux/man-pages/man2/getrandom.2.html

   (2) https://peps.python.org/pep-0524/


File: python.info,  Node: io --- ストリームを扱うコアツール,  Next: time --- 時刻データへのアクセスと変換,  Prev: os --- 雑多なオペレーティングシステムインターフェース,  Up: 汎用オペレーティングシステムサービス

5.16.2 ‘io’ -- ストリームを扱うコアツール
-----------------------------------------

'ソースコード:' Lib/io.py(1)

__________________________________________________________________

* Menu:

* 概要: 概要<2>.
* Text Encoding::
* 高水準のモジュールインターフェイス::
* クラス階層::
* 性能: 性能<3>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/io.py


File: python.info,  Node: 概要<2>,  Next: Text Encoding,  Up: io --- ストリームを扱うコアツール

5.16.2.1 概要
.............

*note io: 73. モジュールは様々な種類の I/O を扱う Python の主要な機能を
提供しています。 I/O には主に3つの種類があります; 'テキスト I/O', 'バイ
ナリ I/O', 'raw I/O' です。これらは汎用的なカテゴリで、各カテゴリには様
々なストレージが利用されます。これらのいずれかのカテゴリに属する具象オブ
ジェクトは全て *note file object: 1193. と呼ばれます。他によく使われる用
語として 'ストリーム' と 'file-like オブジェクト' があります。

それぞれの具象ストリームオブジェクトは、カテゴリに応じた機能を持ちます。
ストリームは読み込み専用、書き込み専用、読み書き可能のいずかになります。
任意のランダムアクセス（前方、後方の任意の場所にシークする）が可能かもし
れませんし、シーケンシャルアクセスしかできないかもしれません（例えばソケ
ットやパイプなど）。

All streams are careful about the type of data you give to them.  For
example giving a *note str: 418. object to the ‘write()’ method of a
binary stream will raise a *note TypeError: 502.  So will giving a *note
bytes: 1a4. object to the ‘write()’ method of a text stream.

バージョン 3.3 で変更: 以前 *note IOError: 1026. を送出していた操作が
*note OSError: 3f0. を送出するようになりました。 *note IOError: 1026. は
今は *note OSError: 3f0. の別名です。

* Menu:

* テキスト I/O::
* バイナリ I/O::
* Raw I/O::


File: python.info,  Node: テキスト I/O,  Next: バイナリ I/O,  Up: 概要<2>

5.16.2.2 テキスト I/O
.....................

テキスト I/O は、 *note str: 418. オブジェクトを受け取り、生成します。す
なわち、背後にあるストレージがバイト列 (例えばファイルなど) を格納すると
きは常に、透過的にデータのエンコード・デコードを行ない、オプションでプラ
ットフォーム依存の改行文字変換を行います。

The easiest way to create a text stream is with *note open(): 4e5,
optionally specifying an encoding:

     f = open("myfile.txt", "r", encoding="utf-8")

*note StringIO: ef3. オブジェクトはインメモリーのテキストストリームです:

     f = io.StringIO("some initial text data")

テキストストリームの API は *note TextIOBase: 661. のドキュメントで詳し
く解説します。


File: python.info,  Node: バイナリ I/O,  Next: Raw I/O,  Prev: テキスト I/O,  Up: 概要<2>

5.16.2.3 バイナリ I/O
.....................

バイナリー I/O ('buffered I/O' とも呼ばれます) は *note bytes-like
オブジェクト: cfb. を受け取り *note bytes: 1a4. オブジェクトを生成します
。エンコード、デコード、改行文字変換は一切行いません。このカテゴリのスト
リームは全ての非テキストデータや、テキストデータの扱いを手動で管理したい
場合に利用することができます。

The easiest way to create a binary stream is with *note open(): 4e5.
with ‘'b'’ in the mode string:

     f = open("myfile.jpg", "rb")

*note BytesIO: e6d. はインメモリーのバイナリストリームです:

     f = io.BytesIO(b"some initial binary data: \x00\x01")

バイナリーストリーム API は *note BufferedIOBase: 660. のドキュメントで
詳しく解説します。

他のライブラリモジュールが、別のテキスト・バイナリーストリームを生成する
方法を提供しています。例えば *note socket.socket.makefile(): 1170. など
です。


File: python.info,  Node: Raw I/O,  Prev: バイナリ I/O,  Up: 概要<2>

5.16.2.4 Raw I/O
................

Raw I/O ('unbuffered I/O' とも呼ばれます) は、バイナリーストリームやテキ
ストストリームの低水準の部品としてよく利用されます。ユーザーコードで直接
raw ストリームを扱うべき場面は滅多にありません。とはいえ、バッファリング
を無効にしてファイルをバイナリーモードで開くことで raw ストリームを作る
ことができます:

     f = open("myfile.jpg", "rb", buffering=0)

raw ストリーム API は *note RawIOBase: 10a3. のドキュメントで詳しく解説
します。


File: python.info,  Node: Text Encoding,  Next: 高水準のモジュールインターフェイス,  Prev: 概要<2>,  Up: io --- ストリームを扱うコアツール

5.16.2.5 Text Encoding
......................

The default encoding of *note TextIOWrapper: 786. and *note open(): 4e5.
is locale-specific (*note locale.getencoding(): 2be.).

However, many developers forget to specify the encoding when opening
text files encoded in UTF-8 (e.g.  JSON, TOML, Markdown, etc...)  since
most Unix platforms use UTF-8 locale by default.  This causes bugs
because the locale encoding is not UTF-8 for most Windows users.  For
example:

     # May not work on Windows when non-ASCII characters in the file.
     with open("README.md") as f:
         long_description = f.read()

Accordingly, it is highly recommended that you specify the encoding
explicitly when opening text files.  If you want to use UTF-8, pass
‘encoding="utf-8"’.  To use the current locale encoding,
‘encoding="locale"’ is supported since Python 3.10.

参考
....

*note Python UTF-8 Mode: 622.

     Python UTF-8 Mode can be used to change the default encoding to
     UTF-8 from locale-specific encoding.

PEP 686(1)

     Python 3.15 will make *note Python UTF-8 Mode: 622. default.

* Menu:

* Opt-in EncodingWarning::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0686/


File: python.info,  Node: Opt-in EncodingWarning,  Up: Text Encoding

5.16.2.6 Opt-in EncodingWarning
...............................

Added in version 3.10: See PEP 597(1) for more details.

To find where the default locale encoding is used, you can enable the
*note -X warn_default_encoding: 15c. command line option or set the
*note PYTHONWARNDEFAULTENCODING: 787. environment variable, which will
emit an *note EncodingWarning: 1ca7. when the default encoding is used.

If you are providing an API that uses *note open(): 4e5. or *note
TextIOWrapper: 786. and passes ‘encoding=None’ as a parameter, you can
use *note text_encoding(): 162c. so that callers of the API will emit an
*note EncodingWarning: 1ca7. if they don't pass an ‘encoding’.  However,
please consider using UTF-8 by default (i.e.  ‘encoding="utf-8"’) for
new APIs.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0597/


File: python.info,  Node: 高水準のモジュールインターフェイス,  Next: クラス階層,  Prev: Text Encoding,  Up: io --- ストリームを扱うコアツール

5.16.2.7 高水準のモジュールインターフェイス
...........................................

 -- データ: io.DEFAULT_BUFFER_SIZE

     このモジュールの buffered I/O クラスで利用されるデフォルトのバッフ
     ァーサイズを表す整数です。可能であれば、*note open(): 4e5. は file
     の blksize (*note os.stat(): 46d. で取得される) を利用します。

 -- の関数: io.open (file, mode='r', buffering=-1, encoding=None,
          errors=None, newline=None, closefd=True, opener=None)

     組み込みの *note open(): 4e5. 関数のエイリアスです。

     This function raises an *note auditing event: 1825. ‘open’ with
     arguments 'path', 'mode' and 'flags'.  The 'mode' and 'flags'
     arguments may have been modified or inferred from the original
     call.

 -- の関数: io.open_code (path)

     ‘'rb'’ モードでファイルを開きます。この関数はファイルの中身を実行可
     能なコードとして扱いたい場合にのみ使用します。

     'path' should be a *note str: 418. and an absolute path.

     The behavior of this function may be overridden by an earlier call
     to the *note PyFile_SetOpenCodeHook(): 1690.  However, assuming
     that 'path' is a *note str: 418. and an absolute path,
     ‘open_code(path)’ should always behave the same as ‘open(path,
     'rb')’.  Overriding the behavior is intended for additional
     validation or preprocessing of the file.

     Added in version 3.8.

 -- の関数: io.text_encoding (encoding, stacklevel=2, /)

     This is a helper function for callables that use *note open(): 4e5.
     or *note TextIOWrapper: 786. and have an ‘encoding=None’ parameter.

     This function returns 'encoding' if it is not ‘None’.  Otherwise,
     it returns ‘"locale"’ or ‘"utf-8"’ depending on *note UTF-8 Mode:
     622.

     This function emits an *note EncodingWarning: 1ca7. if *note
     sys.flags.warn_default_encoding: 658. is true and 'encoding' is
     ‘None’.  'stacklevel' specifies where the warning is emitted.  For
     example:

          def read_text(path, encoding=None):
              encoding = io.text_encoding(encoding)  # stacklevel=2
              with open(path, encoding) as f:
                  return f.read()

     In this example, an *note EncodingWarning: 1ca7. is emitted for the
     caller of ‘read_text()’.

     See *note Text Encoding: 788. for more information.

     Added in version 3.10.

     バージョン 3.11 で変更: *note text_encoding(): 162c. returns
     "utf-8" when UTF-8 mode is enabled and 'encoding' is ‘None’.

 -- 例外: io.BlockingIOError

     互換性のための、組み込みの *note BlockingIOError: 102b. 例外のエイ
     リアスです。

 -- 例外: io.UnsupportedOperation

     *note OSError: 3f0. と *note ValueError: 1e3. を継承した例外です。
     ストリームがサポートしていない操作を行おうとした時に送出されます。

参考
....

*note sys: c3.

     標準 IO ストリームを持っています: *note sys.stdin: 507, *note
     sys.stdout: aa4, *note sys.stderr: 907.。


File: python.info,  Node: クラス階層,  Next: 性能<3>,  Prev: 高水準のモジュールインターフェイス,  Up: io --- ストリームを扱うコアツール

5.16.2.8 クラス階層
...................

I/O ストリームの実装はクラス階層に分けて整理されています。まずストリーム
のカテゴリを分類するための *note 抽象基底クラス: 1186. (ABC) があり、続
いて標準のストリーム実装を行う具象クラス群があります。

     注釈: The abstract base classes also provide default
     implementations of some methods in order to help implementation of
     concrete stream classes.  For example, *note BufferedIOBase: 660.
     provides unoptimized implementations of ‘readinto()’ and
     ‘readline()’.

I/O 階層の最上位には抽象基底クラスの *note IOBase: 1d6. があります。
*note IOBase: 1d6. ではストリームに対して基本的なインターフェースを定義
しています。 しかしながら、ストリームに対する読み込みと書き込みが分離さ
れていないことに注意してください。 実装においては与えられた操作をサポー
トしない場合は *note UnsupportedOperation: 1901. を送出することが許され
ています。

*note RawIOBase: 10a3. ABC は *note IOBase: 1d6. を拡張します。このクラ
スはストリームからの bytes の読み書きを扱います。 *note FileIO: 12df. は
、 *note RawIOBase: 10a3. を継承してマシンのファイルシステム中のファイル
へのインターフェースを提供します。

The *note BufferedIOBase: 660. ABC extends *note IOBase: 1d6.  It deals
with buffering on a raw binary stream (*note RawIOBase: 10a3.).  Its
subclasses, *note BufferedWriter: 20e0, *note BufferedReader: 11df, and
*note BufferedRWPair: 2b73. buffer raw binary streams that are writable,
readable, and both readable and writable, respectively.  *note
BufferedRandom: 20e1. provides a buffered interface to seekable streams.
Another *note BufferedIOBase: 660. subclass, *note BytesIO: e6d, is a
stream of in-memory bytes.

*note TextIOBase: 661. ABC は *note IOBase: 1d6. を拡張します。このクラ
スはテキストをあらわすバイトストリームを対象とし、バイトデータと文字列の
間のエンコーディングやデコーディングを適切に行います。 *note
TextIOWrapper: 786. は *note TextIOBase: 661. を拡張し、バッファリングさ
れた生のストリーム (*note BufferedIOBase: 660.) に対するバッファリングさ
れたテキストのインターフェースです。最後に、 *note StringIO: ef3. はメモ
リ上のテキストデータに対するストリームです。

引数名は規約に含まれていません。 そして *note open(): 4e5. の引数だけが
キーワード引数として用いられることが意図されています。

次のテーブルは *note io: 73. モジュールが提供する ABC の概要です:

ABC                           継承元                 スタブメソッド               Mixin するメソッドとプロパティ
                                                                                  
-----------------------------------------------------------------------------------------------------------------------------------------
                                                                                  
*note IOBase: 1d6.                                   ‘fileno’, ‘seek’,            ‘close’, ‘closed’, ‘__enter__’, ‘__exit__’, ‘flush’,
                                                     ‘truncate’                   ‘isatty’, ‘__iter__’, ‘__next__’, ‘readable’,
                                                                                  ‘readline’, ‘readlines’, ‘seekable’, ‘tell’,
                                                                                  ‘writable’, ‘writelines’
                                                                                  
                                                                                  
*note RawIOBase: 10a3.        *note IOBase: 1d6.     ‘readinto’, ‘write’          *note IOBase: 1d6. から継承したメソッド、 ‘read’,
                                                                                  ‘readall’
                                                                                  
                                                                                  
*note BufferedIOBase: 660.    *note IOBase: 1d6.     ‘detach’, ‘read’, ‘read1’,   *note IOBase: 1d6. から継承したメソッド、
                                                     ‘write’                      ‘readinto’, ‘readinto1’
                                                                                  
                                                                                  
*note TextIOBase: 661.        *note IOBase: 1d6.     ‘detach’, ‘read’,            *note IOBase: 1d6. から継承したメソッド、
                                                     ‘readline’, ‘write’          ‘encoding’, ‘errors’, ‘newlines’
                                                                                  

* Menu:

* I/O 基底クラス::
* 生ファイルI/O::
* バッファ付きストリーム::
* テキスト I/O: テキスト I/O<2>.


File: python.info,  Node: I/O 基底クラス,  Next: 生ファイルI/O,  Up: クラス階層

5.16.2.9 I/O 基底クラス
.......................

 -- クラス: io.IOBase

     The abstract base class for all I/O classes.

     継承先のクラスが選択的にオーバライドできるように、このクラスは多く
     のメソッドに空の抽象実装をしています。デフォルトの実装では、読み込
     み、書き込み、シークができないファイルを表現します。

     Even though *note IOBase: 1d6. does not declare ‘read()’ or
     ‘write()’ because their signatures will vary, implementations and
     clients should consider those methods part of the interface.  Also,
     implementations may raise a *note ValueError: 1e3. (or *note
     UnsupportedOperation: 1901.) when operations they do not support
     are called.

     ファイルへのバイナリデータの読み書きに用いられる基本型は *note
     bytes: 1a4. です。 他の *note bytes-like オブジェクト: cfb. もメソ
     ッドの引数として受け付けられます。 テキスト I/O クラスは *note str:
     418. データを扱います。

     閉じられたストリームに対するメソッド呼び出しは (問い合わせであって
     も) 未定義です。この場合、実装は *note ValueError: 1e3. を送出する
     ことがあります。

     *note IOBase: 1d6. (とそのサブクラス) はイテレータプロトコルをサポ
     ートします。 *note IOBase: 1d6. オブジェクトをイテレートすると、ス
     トリーム内の行が yield されます。ストリーム内の行の定義は、そのスト
     リームが (バイト列を yield する) バイナリストリームか (文字列を
     yield する) テキストストリームかによって、 少し異なります。下の
     *note readline(): 12f8. を参照してください。

     *note IOBase: 1d6. はコンテキストマネージャでもあります。そのため
     *note with: 59c. 構文をサポートします。 次の例では、 ‘with’ 構文が
     終わった後で--たとえ例外が発生した場合でも、 'file' は閉じられます
     。

          with open('spam.txt', 'w') as file:
              file.write('Spam and eggs!')

     *note IOBase: 1d6. は以下のデータ属性とメソッドを提供します:

      -- メソッド: close ()

          このストリームをフラッシュして閉じます。このメソッドはファイル
          が既に閉じられていた場合は特に何の効果もありません。いったんフ
          ァイルが閉じられると、すべてのファイルに対する操作 (例えば読み
          込みや書き込み) で *note ValueError: 1e3. が発生します。

          利便性のためにこのメソッドを複数回呼ぶことは許されています。し
          かし、効果があるのは最初の1回だけです。

      -- の属性: closed

          ストリームが閉じられていた場合 ‘True’ になります。

      -- メソッド: fileno ()

          ストリームが保持しているファイル記述子 (整数値) が存在する場合
          はそれを返します。もし IO オブジェクトがファイル記述子を使って
          いない場合は *note OSError: 3f0. が発生します。

      -- メソッド: flush ()

          適用可能であればストリームの書き込みバッファをフラッシュします
          。読み出し専用や非ブロッキングストリームでは何もしません。

      -- メソッド: isatty ()

          ストリームが対話的であれば (つまりターミナルや tty デバイスに
          つながっている場合) ‘True’ を返します。

      -- メソッド: readable ()

          Return ‘True’ if the stream can be read from.  If ‘False’,
          ‘read()’ will raise *note OSError: 3f0.

      -- メソッド: readline (size=-1, /)

          ストリームから 1 行読み込んで返します。もし 'size' が指定され
          た場合、最大で 'size' バイトが読み込まれます。

          バイナリファイルでは行末文字は常に ‘b'\n'’ となります。テキス
          トファイルでは、認識される行末文字を選択するために *note
          open(): 4e5. に対する 'newline' 引数が使われます。

      -- メソッド: readlines (hint=-1, /)

          ストリームから行のリストを読み込んで返します。 'hint' を指定す
          ることで、読み込む行数を制御できます。もし読み込んだすべての行
          のサイズ (バイト数、もしくは文字数) が 'hint' の値を超えた場合
          、それ以上の行は読み込まれません。

          引数 'hint' の値が ‘0’ 以下、および ‘None’ の場合は、ヒントが
          ないものとして取り扱われます。

          Note that it's already possible to iterate on file objects
          using ‘for line in file: ...’ without calling
          ‘file.readlines()’.

      -- メソッド: seek (offset, whence=os.SEEK_SET, /)

          Change the stream position to the given byte 'offset',
          interpreted relative to the position indicated by 'whence',
          and return the new absolute position.  Values for 'whence'
          are:

             * *note os.SEEK_SET: 125e. or ‘0’ - start of the stream
               (the default); 'offset' should be zero or positive

             * *note os.SEEK_CUR: 125f. or ‘1’ - current stream
               position; 'offset' may be negative

             * *note os.SEEK_END: 1260. or ‘2’ - end of the stream;
               'offset' is usually negative

          Added in version 3.1: The ‘SEEK_*’ constants.

          Added in version 3.3: Some operating systems could support
          additional values, like *note os.SEEK_HOLE: 2aa0. or *note
          os.SEEK_DATA: 2aa1.  The valid values for a file could depend
          on it being open in text or binary mode.

      -- メソッド: seekable ()

          ストリームがランダムアクセスをサポートしている場合、 ‘True’ を
          返します。 ‘False’ の場合、 *note seek(): 125d.、 *note
          tell(): 2907.、 *note truncate(): 12e0. を使用すると *note
          OSError: 3f0. を発生させます。

      -- メソッド: tell ()

          現在のストリーム位置を返します。

      -- メソッド: truncate (size=None, /)

          ストリームのサイズを、指定された 'size' バイト (または 'size'
          が指定されていない場合、現在位置) に変更します。現在のストリー
          ム位置は変更されません。このサイズ変更により、現在のファイルサ
          イズを拡大または縮小させることができます。拡大の場合には、新し
          いファイル領域の内容はプラットホームによって異なります (ほとん
          どのシステムでは、追加のバイトが 0 で埋められます)。新しいファ
          イルサイズが返されます。

          バージョン 3.5 で変更: Windows で、拡大時に追加領域を 0 で埋め
          るようになりました。

      -- メソッド: writable ()

          Return ‘True’ if the stream supports writing.  If ‘False’,
          ‘write()’ and *note truncate(): 12e0. will raise *note
          OSError: 3f0.

      -- メソッド: writelines (lines, /)

          ストリームに行のリストを書き込みます。行区切り文字は追加されな
          いので、書き込む各行の行末に行区切り文字を含ませるのが一般的で
          す。

      -- メソッド: __del__ ()

          オブジェクトの破壊の用意をします。このメソッドはインスタンスの
          *note close(): 1d7. メソッドを呼びます。 *note IOBase: 1d6. は
          このメソッドのデフォルトの実装を提供します

 -- クラス: io.RawIOBase

     Base class for raw binary streams.  It inherits from *note IOBase:
     1d6.

     生のバイナリストリームは典型的に、背後にある OS デバイスや API への
     低水準なアクセスを提供し、それらを高水準の基本要素へカプセル化しよ
     うとはしません (そのような機能は後述するバッファされたバイナリスト
     リームやテキストストリームのような高水準のクラスで行われます)。

     *note RawIOBase: 10a3. は *note IOBase: 1d6. が提供するメソッドに加
     えて、以下のメソッドを提供します:

      -- メソッド: read (size=-1, /)

          オブジェクトを 'size' バイトまで読み込み、それを返します。 簡
          単のため、 'size' が指定されていないか -1 の場合は、 EOF まで
          の全てのバイトを返します。 そうでない場合は、システムコール呼
          び出しが一度だけ行われます。 オペレーティングシステムコールか
          ら返ってきたものが 'size' バイトより少なければ、 'size' バイト
          より少ない返り値になることがあります。

          'size' が 0 でないのに 0 バイトが返った場合、それはファイルの
          終端を表します。オブジェクトがノンブロッキングモードで、1 バイ
          トも読み込めなければ、‘None’ が返されます。

          デフォルトの実装は *note readall(): 2b7a. と *note readinto():
          dea. に従います。

      -- メソッド: readall ()

          EOF までストリームからすべてのバイトを読み込みます。必要な場合
          はストリームに対して複数の呼び出しをします。

      -- メソッド: readinto (b, /)

          あらかじめ確保された書き込み可能な *note bytes 類オブジェクト:
          cfb. 'b' にバイト列を読み込み、読み込んだバイト数を返します。
          例えば、 'b' は *note bytearray: 508. です。 オブジェクトがノ
          ンブロッキングモードで、 1 バイトも読み込めなければ、 ‘None’ が
          返されます。

      -- メソッド: write (b, /)

          与えられた *note bytes-like オブジェクト: cfb. 'b' を生ストリ
          ームに書き込み、書き込んだバイト数を返します。これは、根底の生
          ストリームの性質や、特にノンブロッキングである場合に、 'b' の
          バイト数より小さくなることがあります。生ストリームがブロックさ
          れないように設定されていて、かつ1バイトも即座に書き込むことが
          できなければ、 ‘None’ が返されます。このメソッドから返った後で
          呼び出し元は 'b' を解放したり変更したりするかもしれないので、
          実装はメソッド呼び出しの間だけ 'b' にアクセスすべきです。

 -- クラス: io.BufferedIOBase

     Base class for binary streams that support some kind of buffering.
     It inherits from *note IOBase: 1d6.

     *note RawIOBase: 10a3. との主な違いは、メソッド *note read():
     12f7.、 *note readinto(): 2b7b. および *note write(): ca9. は 、こ
     とによると複数回のシステムコールを行って、(それぞれ) 要求されただけ
     の入力を読み込もうとしたり与えられた出力の全てを消費しようとしたり
     する点です。

     加えて、元になる生ストリームが非ブロッキングモードでかつ準備ができ
     ていない場合に、これらのメソッドは、 *note BlockingIOError: 102b. を
     送出するかもしれません。対応する *note RawIOBase: 10a3. バージョン
     と違って、 ‘None’ を返すことはありません。

     さらに、 *note read(): 12f7. メソッドは、 *note readinto(): 2b7b. に
     従うデフォルト実装を持ちません。

     通常の *note BufferedIOBase: 660. 実装は *note RawIOBase: 10a3. 実
     装を継承せずに、 *note BufferedWriter: 20e0. と *note
     BufferedReader: 11df. がするようにこれをラップすべきです。

     *note BufferedIOBase: 660. は *note IOBase: 1d6. から継承した属性と
     メソッドに加えて、以下のデータ属性とメソッドを提供またはオーバーラ
     イドします:

      -- の属性: raw

          *note BufferedIOBase: 660. が扱う根底の生ストリーム (*note
          RawIOBase: 10a3. インスタンス) を返します。これは *note
          BufferedIOBase: 660. API には含まれず、よって実装に含まれない
          ことがあります。

      -- メソッド: detach ()

          根底の生ストリームをバッファから分離して返します。

          生ストリームが取り外された後、バッファは使用不能状態になります
          。

          バッファには、 *note BytesIO: e6d. など、このメソッドで返され
          る単体のストリームという概念を持たないものがあります。これらは
          *note UnsupportedOperation: 1901. を送出します。

          Added in version 3.1.

      -- メソッド: read (size=-1, /)

          最大で 'size' バイト読み込んで返します。 引数が省略されるか、
          ‘None’ か、または負の値であった場合、 データは EOF に到達する
          まで読み込まれます。 ストリームが既に EOF に到達していた場合は
          空の *note bytes: 1a4. オブジェクトが返されます。

          引数が正で、元になる生ストリームが対話的でなければ、必要なバイ
          ト数を満たすように複数回の生 read が発行されるかもしれません
          (先に EOF に到達しない限りは)。対話的な場合は、最大で一回の
          raw read しか発行されず、短い結果でも EOF に達したことを意味し
          ません。

          元になる生ストリームがノンブロッキングモードで、呼び出された時
          点でデータを持っていなければ、 *note BlockingIOError: 102b. が
          送出されます。

      -- メソッド: read1 (size=-1, /)

          根底の raw ストリームの *note read(): de9. (または *note
          readinto(): dea. ) メソッドを高々 1 回呼び出し、最大で 'size'
          バイト読み込み、返します。これは、 *note BufferedIOBase: 660.
          オブジェクトの上に独自のバッファリングを実装するときに便利です
          。

          'size' に ‘-1’ （デフォルト値)を指定すると任意バイト長を返しま
          す（EOFに到達していなければ返されるバイト数は 0 より大きくなり
          ます）

      -- メソッド: readinto (b, /)

          あらかじめ確保された書き込み可能な *note bytes 類オブジェクト:
          cfb. 'b' にバイト列を読み込み、読み込んだバイト数を返します。
          例えば、 'b' は *note bytearray: 508. です。

          *note read(): 12f7. と同様に、下層の raw ストリームが対話的で
          ない限り、複数の読み込みは下層の raw ストリームに与えられるか
          もしれません。

          元になる生ストリームがノンブロッキングモードで、呼び出された時
          点でデータを持っていなければ、 *note BlockingIOError: 102b. が
          送出されます。

      -- メソッド: readinto1 (b, /)

          根底の raw ストリームの *note read(): de9. (または *note
          readinto(): dea.) メソッドを高々 1 回呼び出し、あらかじめ確保
          された書き込み可能な *note bytes-like オブジェクト: cfb. 'b' に
          バイト列を読み込みます。読み込んだバイト数を返します。

          元になる生ストリームがノンブロッキングモードで、呼び出された時
          点でデータを持っていなければ、 *note BlockingIOError: 102b. が
          送出されます。

          Added in version 3.5.

      -- メソッド: write (b, /)

          与えられた *note bytes-like オブジェクト: cfb. 'b' を書き込み
          、書き込んだバイト数を返します (これは常に 'b' のバイト数と等
          しくなります。なぜなら、もし書き込みに失敗した場合は *note
          OSError: 3f0. が発生するからです)。実際の実装に依存して、これ
          らのバイト列は根底のストリームに即座に書き込まれることもあれば
          、パフォーマンスやレイテンシの関係でバッファに保持されることも
          あります。

          ノンブロッキングモードであるとき、バッファが満杯で根底の生スト
          リームが書き込み時点でさらなるデータを受け付けられない場合
          *note BlockingIOError: 102b. が送出されます。

          このメソッドが戻った後で、呼び出し元は 'b' を解放、または変更
          するかもしれないので、実装はメソッド呼び出しの間だけ 'b' にア
          クセスすべきです。


File: python.info,  Node: 生ファイルI/O,  Next: バッファ付きストリーム,  Prev: I/O 基底クラス,  Up: クラス階層

5.16.2.10 生ファイルI/O
.......................

 -- クラス: io.FileIO (name, mode='r', closefd=True, opener=None)

     A raw binary stream representing an OS-level file containing bytes
     data.  It inherits from *note RawIOBase: 10a3.

     'name' は、次の 2 つのいずれかです。

        * 開くファイルへのパスを表す文字列または *note bytes: 1a4. オブ
          ジェクト。 この場合、closefd は ‘True’ (デフォルト) でなければ
          なりません。 ‘True’ でない場合、エラーが送出されます。

        * 結果の *note FileIO: 12df. オブジェクトがアクセスを与える、既
          存の OS レベルファイル記述子の数を表す整数。FileIO オブジェク
          トが閉じられると、'closefd' が ‘False’ に設定されていない場合
          、この fd も閉じられます。

     'mode' は 読み込み（デフォルト）、書き込み、排他的作成、追記に対し
     ‘'r'’ 、 ‘'w'’ 、 ‘'x'’ 、 ‘'a'’ です。ファイルは書き込みや追記で開
     かれたときに存在しない場合作成されます。書き込みのときにファイルの
     内容は破棄されます。作成時に既に存在する場合は *note
     FileExistsError: fea. が送出されます。作成のためにファイルを開くの
     は暗黙的に書き込みなので、このモードは ‘'w'’ と同じように振る舞いま
     す。読み込みと書き込みを同時に許可するにはモードに ‘'+'’ を加えてく
     ださい。

     The *note read(): de9. (when called with a positive argument),
     *note readinto(): dea. and *note write(): 2946. methods on this
     class will only make one system call.

     呼び出し可能オブジェクトを 'opener' として与えることで、カスタムの
     オープナーが使えます。そしてファイルオブジェクトの基底のファイルデ
     ィスクリプタは、'opener' を ('name', 'flags') で呼び出して得られま
     す。'opener' は開いたファイルディスクリプタを返さなければなりません
     。 (*note os.open: d5f. を 'opener' として渡すと、‘None’ を渡したの
     と同様の機能になります。)

     新たに作成されたファイルは *note 継承不可: ec4. です。

     'opener' 引数を使う例については *note open(): 4e5. 組み込み関数を参
     照してください。

     バージョン 3.3 で変更: 'opener' 引数が追加されました。‘'x'’ モード
     が追加されました。

     バージョン 3.4 で変更: ファイルが継承不可になりました。

     *note FileIO: 12df. は *note RawIOBase: 10a3. と *note IOBase: 1d6.
     から継承したデータ属性に加えて以下のデータ属性を提供します:

      -- の属性: mode

          コンストラクタに渡されたモードです。

      -- の属性: name

          ファイル名。コンストラクタに名前が渡されなかったときはファイル
          記述子になります。


File: python.info,  Node: バッファ付きストリーム,  Next: テキスト I/O<2>,  Prev: 生ファイルI/O,  Up: クラス階層

5.16.2.11 バッファ付きストリーム
................................

バッファ付き I/O ストリームは、I/O デバイスに生 I/O より高レベルなインタ
ーフェースを提供します。

 -- クラス: io.BytesIO (initial_bytes=b'')

     A binary stream using an in-memory bytes buffer.  It inherits from
     *note BufferedIOBase: 660.  The buffer is discarded when the *note
     close(): 1d7. method is called.

     省略可能な引数 'initial_bytes' は、初期データを含んだ *note
     bytes-like オブジェクト: cfb. です。

     *note BytesIO: e6d. は *note BufferedIOBase: 660. または *note
     IOBase: 1d6. からのメソッドに加えて、以下のメソッドを提供もしくはオ
     ーバーライドします:

      -- メソッド: getbuffer ()

          バッファの内容をコピーすることなく、その内容の上に、読み込み及
          び書き込みが可能なビューを返します。また、このビューを変更する
          と、バッファの内容は透過的に更新されます:

               >>> b = io.BytesIO(b"abcdef")
               >>> view = b.getbuffer()
               >>> view[2:4] = b"56"
               >>> b.getvalue()
               b'ab56ef'

               注釈: ビューが存在する限り、*note BytesIO: e6d. オブジェ
               クトはリサイズやクローズされません。

          Added in version 3.2.

      -- メソッド: getvalue ()

          バッファの全内容を含む *note bytes: 1a4. を返します。

      -- メソッド: read1 (size=-1, /)

          *note BytesIO: e6d. においては、このメソッドは *note read():
          12f7. と同じです。

          バージョン 3.7 で変更: 'size' 引数が任意になりました。

      -- メソッド: readinto1 (b, /)

          *note BytesIO: e6d. においては、このメソッドは *note
          readinto(): 2b7b. と同じです。

          Added in version 3.5.

 -- クラス: io.BufferedReader (raw, buffer_size=DEFAULT_BUFFER_SIZE)

     A buffered binary stream providing higher-level access to a
     readable, non seekable *note RawIOBase: 10a3. raw binary stream.
     It inherits from *note BufferedIOBase: 660.

     このオブジェクトからデータを読み出した時、背後にある生のストリーム
     からはより大きな量のデータの読み出しがリクエストされ、内部バッファ
     に読み出したデータが保持されることがあります。バッファされたデータ
     はその後の読み出し処理で直接返すことができます。

     このコンストラクタは与えられた 'raw' ストリームと 'buffer_size' に
     対し *note BufferedReader: 11df. を生成します。 'buffer_size' が省
     略された場合、代わりに *note DEFAULT_BUFFER_SIZE: 162d. が使われま
     す。

     *note BufferedReader: 11df. は *note BufferedIOBase: 660. または
     *note IOBase: 1d6. からのメソッドに加えて、以下のメソッドを提供もし
     くはオーバーライドします:

      -- メソッド: peek (size=0, /)

          位置を進めずにストリームからバイト列を返します。これを果たすた
          めに生ストリームに対して行われる read は高々一度だけです。返さ
          れるバイト数は、要求より少ないかもしれませんし、多いかもしれま
          せん。

      -- メソッド: read (size=-1, /)

          'size' バイトを読み込んで返します。'size' が与えられないか負の
          値ならば、EOF まで、または非ブロッキングモード中で read 呼び出
          しがブロックされるまでを返します。

      -- メソッド: read1 (size=-1, /)

          raw ストリームに対しただ一度の呼び出しで最大 'size' バイトを読
          み込んで返します。少なくとも 1 バイトがバッファされていれば、
          バッファされているバイト列だけが返されます。それ以外の場合は
          raw ストリームの読み込みが一回呼び出されます。

          バージョン 3.7 で変更: 'size' 引数が任意になりました。

 -- クラス: io.BufferedWriter (raw, buffer_size=DEFAULT_BUFFER_SIZE)

     A buffered binary stream providing higher-level access to a
     writeable, non seekable *note RawIOBase: 10a3. raw binary stream.
     It inherits from *note BufferedIOBase: 660.

     このオブジェクトに対して書き込みを行なったとき、データは通常内部バ
     ッファに配置されます。バッファは以下に示すさまざまな条件で背後にあ
     る *note RawIOBase: 10a3. オブジェクトに書き込まれます:

        * 保留中の全データに対してバッファが足りなくなったとき;

        * when *note flush(): 2b85. is called;

        * when a *note seek(): 125d. is requested (for *note
          BufferedRandom: 20e1. objects);

        * *note BufferedWriter: 20e0. オブジェクトが閉じられたり破棄され
          たりしたとき。

     このコンストラクタは与えられた書き込み可能な 'raw' ストリームに対し
     *note BufferedWriter: 20e0. を生成します。 'buffer_size' が省略され
     た場合、 *note DEFAULT_BUFFER_SIZE: 162d. がデフォルトになります。

     *note BufferedWriter: 20e0. は *note BufferedIOBase: 660. または
     *note IOBase: 1d6. からのメソッドに加えて、以下のメソッドを提供もし
     くはオーバーライドします:

      -- メソッド: flush ()

          バッファに保持されたバイト列を生ストリームに強制的に流し込みま
          す。生ストリームがブロックした場合 *note BlockingIOError:
          102b. が送出されます。

      -- メソッド: write (b, /)

          *note bytes-like オブジェクト: cfb. 'b' を書き込み、書き込んだ
          バイト数を返します。ノンブロッキング時、バッファが書き込まれる
          べきなのに生ストリームがブロックした場合 *note
          BlockingIOError: 102b. が送出されます。

 -- クラス: io.BufferedRandom (raw, buffer_size=DEFAULT_BUFFER_SIZE)

     A buffered binary stream providing higher-level access to a
     seekable *note RawIOBase: 10a3. raw binary stream.  It inherits
     from *note BufferedReader: 11df. and *note BufferedWriter: 20e0.

     このコンストラクタは第一引数として与えられるシーク可能な生ストリー
     ムに対し、リーダーおよびライターを作成します。 'buffer_size' が省略
     された場合、 *note DEFAULT_BUFFER_SIZE: 162d. がデフォルトになりま
     す。

     *note BufferedRandom: 20e1. is capable of anything *note
     BufferedReader: 11df. or *note BufferedWriter: 20e0. can do.  In
     addition, *note seek(): 125d. and *note tell(): 2907. are
     guaranteed to be implemented.

 -- クラス: io.BufferedRWPair (reader, writer,
          buffer_size=DEFAULT_BUFFER_SIZE, /)

     A buffered binary stream providing higher-level access to two non
     seekable *note RawIOBase: 10a3. raw binary streams--one readable,
     the other writeable.  It inherits from *note BufferedIOBase: 660.

     'reader' と 'writer' はそれぞれ読み込み可能、書き込み可能な *note
     RawIOBase: 10a3. オブジェクトです。 'buffer_size' が省略された場合
     *note DEFAULT_BUFFER_SIZE: 162d. がデフォルトになります。

     *note BufferedRWPair: 2b73. は、 *note UnsupportedOperation: 1901.
     を送出する *note detach(): 28ce. を除く、 *note BufferedIOBase:
     660. の全てのメソッドを実装します。

          警告: *note BufferedRWPair: 2b73. は下層の生ストリームのアクセ
          スを同期しようとはしません。同じオブジェクトをリーダとライタと
          して渡してはいけません。その場合は代わりに *note
          BufferedRandom: 20e1. を使用してください。


File: python.info,  Node: テキスト I/O<2>,  Prev: バッファ付きストリーム,  Up: クラス階層

5.16.2.12 テキスト I/O
......................

 -- クラス: io.TextIOBase

     Base class for text streams.  This class provides a character and
     line based interface to stream I/O. It inherits from *note IOBase:
     1d6.

     *note IOBase: 1d6. から継承した属性とメソッドに加えて、 *note
     TextIOBase: 661. は以下のデータ属性とメソッドを提供しています:

      -- の属性: encoding

          エンコーディング名で、ストリームのバイト列を文字列にデコードす
          るとき、また文字列をバイト列にエンコードするときに使われます。

      -- の属性: errors

          このエンコーダやデコーダのエラー設定です。

      -- の属性: newlines

          文字列、文字列のタプル、または ‘None’ で、改行がどのように読み
          換えられるかを指定します。実装や内部コンストラクタのフラグに依
          って、これは利用できないことがあります。

      -- の属性: buffer

          *note TextIOBase: 661. が扱う根底のバイナリバッファ (*note
          BufferedIOBase: 660. インスタンス) です。これは *note
          TextIOBase: 661. API には含まれず、よって実装に含まれない場合
          があります。

      -- メソッド: detach ()

          根底のバイナリバッファを *note TextIOBase: 661. から分離して返
          します。

          根底のバッファが取り外された後、 *note TextIOBase: 661. は使用
          不能状態になります。

          *note TextIOBase: 661. 実装には、 *note StringIO: ef3. など、
          根底のバッファという概念を持たないものがあります。これらを呼び
          出すと *note UnsupportedOperation: 1901. を送出します。

          Added in version 3.1.

      -- メソッド: read (size=-1, /)

          最大 'size' 文字をストリームから読み込み、一つの *note str:
          418. にして返します。 'size' が負の値または ‘None’ ならば、
          EOF まで読みます。

      -- メソッド: readline (size=-1, /)

          Read until newline or EOF and return a single *note str: 418.
          If the stream is already at EOF, an empty string is returned.

          'size' が指定された場合、最大 'size' 文字が読み込まれます。

      -- メソッド: seek (offset, whence=SEEK_SET, /)

          Change the stream position to the given 'offset'.  Behaviour
          depends on the 'whence' parameter.  The default value for
          'whence' is ‘SEEK_SET’.

             * ‘SEEK_SET’ or ‘0’: seek from the start of the stream (the
               default); 'offset' must either be a number returned by
               *note TextIOBase.tell(): 2b8c, or zero.  Any other
               'offset' value produces undefined behaviour.

             * ‘SEEK_CUR’ or ‘1’: "seek" to the current position;
               'offset' must be zero, which is a no-operation (all other
               values are unsupported).

             * ‘SEEK_END’ or ‘2’: seek to the end of the stream;
               'offset' must be zero (all other values are unsupported).

          新しい絶対位置を、不透明な数値で返します。

          Added in version 3.1: The ‘SEEK_*’ constants.

      -- メソッド: tell ()

          ストリームの現在位置を不透明な数値で返します。この値は根底のバ
          イナリストレージ内でのバイト数を表すとは限りません。

      -- メソッド: write (s, /)

          文字列 's' をストリームに書き出し、書き出された文字数を返しま
          す。

 -- クラス: io.TextIOWrapper (buffer, encoding=None, errors=None,
          newline=None, line_buffering=False, write_through=False)

     A buffered text stream providing higher-level access to a *note
     BufferedIOBase: 660. buffered binary stream.  It inherits from
     *note TextIOBase: 661.

     'encoding' gives the name of the encoding that the stream will be
     decoded or encoded with.  It defaults to *note
     locale.getencoding(): 2be.  ‘encoding="locale"’ can be used to
     specify the current locale's encoding explicitly.  See *note Text
     Encoding: 788. for more information.

     'errors' はオプションの文字列で、エンコードやデコードの際のエラーを
     どのように扱うかを指定します。エンコードエラーがあったときに *note
     ValueError: 1e3. 例外を送出させるには ‘'strict'’ を渡します (デフォ
     ルトの ‘None’ でも同じです)。エラーを無視させるには ‘'ignore'’ を渡
     します。 (エンコーディングエラーを無視するとデータを喪失する可能性
     があることに注意してください。) ‘'replace'’ は不正な形式の文字の代
     わりにマーカ (たとえば ‘'?'’) を挿入させます。‘'backslashreplace'’
     を指定すると、不正な形式のデータをバックスラッシュ付きのエスケープ
     シーケンスに置換します。書き込み時には ‘'xmlcharrefreplace'’ (適切
     な XML 文字参照に置換) や ‘'namereplace'’ (‘\N{...}’ エスケープシー
     ケンスに置換) も使えます。他にも *note codecs.register_error():
     143e. で登録されたエラー処理名が有効です。

     'newline' は行末をどのように処理するかを制御します 。‘None’, ‘''’,
     ‘'\n'’, ‘'\r'’, ‘'\r\n'’ のいずれかです。これは以下のように動作しま
     す:

        * ストリームからの入力を読み込んでいるとき、もし 'newline' が
          ‘None’ ならば *note universal newlines: d08. モードが有効にな
          ります。入力中の行は ‘'\n'’, ‘'\r'’, または ‘'\r\n'’ のいずれ
          で終わってもよく、それらは呼び出し元に返される前に'''n''' に変
          換されます。 'newline' が ‘''’ の場合、 universal newlines モ
          ードは有効になりますが、行末のコードは変換されずに呼び出し元に
          返されます。 'newline' がその他の有効な値の場合は、入力行は与
          えられた文字列のみで終端され、行末は変換されずに呼び出し元に返
          されます。

        * ストリームへの出力の書き込み時、'newline' が ‘None’ の場合、全
          ての ‘'\n'’ 文字はシステムのデフォルトの行セパレータ *note
          os.linesep: 20df. に変換されます。 'newline' が ‘''’ または
          ‘'\n'’ の場合は変換されません。'newline' がその他の正当な値の
          場合、全ての ‘'\n'’ 文字は与えられた文字列に変換されます。

     If 'line_buffering' is ‘True’, *note flush(): 2b75. is implied when
     a call to write contains a newline character or a carriage return.

     If 'write_through' is ‘True’, calls to *note write(): ca9. are
     guaranteed not to be buffered: any data written on the *note
     TextIOWrapper: 786. object is immediately handled to its underlying
     binary 'buffer'.

     バージョン 3.3 で変更: 'write_through' 引数が追加されました。

     バージョン 3.3 で変更: 'encoding' の規定値が
     ‘locale.getpreferredencoding()’ から
     ‘locale.getpreferredencoding(False)’ になりました。 *note
     locale.setlocale(): 2bd. を用いてロケールのエンコーディングを一時的
     に変更してはいけません。ユーザが望むエンコーディングではなく現在の
     ロケールのエンコーディングを使用してください。

     バージョン 3.10 で変更: The 'encoding' argument now supports the
     ‘"locale"’ dummy encoding name.

     *note TextIOWrapper: 786. は *note TextIOBase: 661. と *note
     IOBase: 1d6. から継承したものに加えて以下のデータ属性をメソッドを提
     供します:

      -- の属性: line_buffering

          行バッファリングが有効かどうか。

      -- の属性: write_through

          書き込みが、根柢のバイナリバッファに即座に渡されるかどうか。

          Added in version 3.7.

      -- メソッド: reconfigure (*, encoding=None, errors=None,
               newline=None, line_buffering=None, write_through=None)

          このテキストストリームを 'encoding', 'errors', 'newline',
          'line_buffering' と 'write_through' を新しい設定として再設定し
          ます。

          'encoding' が指定されており、'errors' が指定されていないときに
          、 ‘errors='strict'’ が使われている場合を除き、指定されなかっ
          たパラメータは現在の設定が保持されます。

          ストリームからすでにデータが読み出されていた場合、encodingと
          newlineは変更できません。一方で、書き込み後にencodingを変更す
          ることはできます。

          このメソッドは、新しい設定を適用するまえにストリームをフラッシ
          ュします。

          Added in version 3.7.

          バージョン 3.11 で変更: The method supports
          ‘encoding="locale"’ option.

      -- メソッド: seek (cookie, whence=os.SEEK_SET, /)

          Set the stream position.  Return the new stream position as an
          *note int: 238.

          Four operations are supported, given by the following argument
          combinations:

             * ‘seek(0, SEEK_SET)’: Rewind to the start of the stream.

             * ‘seek(cookie, SEEK_SET)’: Restore a previous position;
               'cookie' 'must be' a number returned by *note tell():
               2b90.

             * ‘seek(0, SEEK_END)’: Fast-forward to the end of the
               stream.

             * ‘seek(0, SEEK_CUR)’: Leave the current stream position
               unchanged.

          Any other argument combinations are invalid, and may raise
          exceptions.

          参考
          ....

          *note os.SEEK_SET: 125e, *note os.SEEK_CUR: 125f, and *note
          os.SEEK_END: 1260.

      -- メソッド: tell ()

          Return the stream position as an opaque number.  The return
          value of ‘tell()’ can be given as input to *note seek(): 2b8f,
          to restore a previous stream position.

 -- クラス: io.StringIO (initial_value='', newline='\n')

     A text stream using an in-memory text buffer.  It inherits from
     *note TextIOBase: 661.

     テキストバッファは *note close(): 1d7. メソッドが呼び出されたときに
     破棄されます。

     The initial value of the buffer can be set by providing
     'initial_value'.  If newline translation is enabled, newlines will
     be encoded as if by *note write(): 1bde.  The stream is positioned
     at the start of the buffer which emulates opening an existing file
     in a ‘w+’ mode, making it ready for an immediate write from the
     beginning or for a write that would overwrite the initial value.
     To emulate opening a file in an ‘a+’ mode ready for appending, use
     ‘f.seek(0, io.SEEK_END)’ to reposition the stream at the end of the
     buffer.

     'newline' 引数は *note TextIOWrapper: 786. の同名の引数と同じように
     働きます。ただし、出力をストリームに書き込む時に 'newline' が
     ‘None’ の場合には、改行は全てのプラットフォームで ‘\n’ になります。

     *note TextIOBase: 661. と *note IOBase: 1d6. から継承したメソッドに
     加えて *note StringIO: ef3. は以下のメソッドを提供しています:

      -- メソッド: getvalue ()

          Return a *note str: 418. containing the entire contents of the
          buffer.  Newlines are decoded as if by *note read(): 1bef,
          although the stream position is not changed.

     使用例:

          import io

          output = io.StringIO()
          output.write('First line.\n')
          print('Second line.', file=output)

          # Retrieve file contents -- this will be
          # 'First line.\nSecond line.\n'
          contents = output.getvalue()

          # Close object and discard memory buffer --
          # .getvalue() will now raise an exception.
          output.close()

 -- クラス: io.IncrementalNewlineDecoder

     A helper codec that decodes newlines for *note universal newlines:
     d08. mode.  It inherits from *note codecs.IncrementalDecoder: 2324.


File: python.info,  Node: 性能<3>,  Prev: クラス階層,  Up: io --- ストリームを扱うコアツール

5.16.2.13 性能
..............

このセクションでは与えられた具体的な I/O 実装の性能について議論します。

* Menu:

* バイナリ I/O: バイナリ I/O<2>.
* テキスト I/O: テキスト I/O<3>.
* マルチスレッディング: マルチスレッディング<3>.
* リエントラント性::


File: python.info,  Node: バイナリ I/O<2>,  Next: テキスト I/O<3>,  Up: 性能<3>

5.16.2.14 バイナリ I/O
......................

バッファ付き I/O は、ユーザが 1 バイトだけ要求した場合でさえ、データを大
きな塊でのみ読み書きします。これにより、オペレーティングシステムのバッフ
ァ無し I/O ルーチンを呼び出して実行する非効率性はすべて隠されます。その
成果は、OS と、実行される I/O の種類によって異なります。例えば、Linux の
ような現行の OS では、バッファ無しディスク I/O がバッファ付き I/O と同じ
くらい早いことがあります。しかし、どのプラットフォームとデバイスにおいて
も、バッファ付き I/O は最低でも予測可能なパフォーマンスを提供します。で
すから、バイナリデータに対しては、バッファ無し I/O を使用するより、バッ
ファ付きの I/O を使用するほうが望ましい場合がほとんどです。


File: python.info,  Node: テキスト I/O<3>,  Next: マルチスレッディング<3>,  Prev: バイナリ I/O<2>,  Up: 性能<3>

5.16.2.15 テキスト I/O
......................

Text I/O over a binary storage (such as a file) is significantly slower
than binary I/O over the same storage, because it requires conversions
between unicode and binary data using a character codec.  This can
become noticeable handling huge amounts of text data like large log
files.  Also, *note tell(): 2b8c. and *note seek(): 2b8b. are both quite
slow due to the reconstruction algorithm used.

しかし *note StringIO: ef3. は、ネイティブなインメモリ Unicode コンテナ
で、 *note BytesIO: e6d. と同程度の速度を示します。


File: python.info,  Node: マルチスレッディング<3>,  Next: リエントラント性,  Prev: テキスト I/O<3>,  Up: 性能<3>

5.16.2.16 マルチスレッディング
..............................

*note FileIO: 12df. objects are thread-safe to the extent that the
operating system calls (such as ‘read(2)(1)’ under Unix) they wrap are
thread-safe too.

バイナリバッファ付きオブジェクト (*note BufferedReader: 11df, *note
BufferedWriter: 20e0, *note BufferedRandom: 20e1. および *note
BufferedRWPair: 2b73. のインスタンス) は、その内部構造をロックを使って保
護します。このため、これらを複数のスレッドから同時に呼び出しても安全です
。

*note TextIOWrapper: 786. オブジェクトはスレッドセーフではありません。

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/read(2)


File: python.info,  Node: リエントラント性,  Prev: マルチスレッディング<3>,  Up: 性能<3>

5.16.2.17 リエントラント性
..........................

バイナリバッファ付きオブジェクト (*note BufferedReader: 11df, *note
BufferedWriter: 20e0, *note BufferedRandom: 20e1. および *note
BufferedRWPair: 2b73. のインスタンス) は、リエントラント (再入可能) では
ありません。リエントラントな呼び出しは普通の状況では起こりませんが、 I/O
を *note signal: b4. ハンドラで行なっているときに起こりえます。スレッド
が、すでにアクセスしているバッファ付きオブジェクトに再び入ろうとすると
*note RuntimeError: 17a. が送出されます。これは、バッファ付きオブジェク
トに複数のスレッドから入ることを禁止するわけではありません。

The above implicitly extends to text files, since the *note open(): 4e5.
function will wrap a buffered object inside a *note TextIOWrapper: 786.
This includes standard streams and therefore affects the built-in *note
print(): f42. function as well.


File: python.info,  Node: time --- 時刻データへのアクセスと変換,  Next: argparse --- Parser for command-line options arguments and subcommands,  Prev: io --- ストリームを扱うコアツール,  Up: 汎用オペレーティングシステムサービス

5.16.3 ‘time’ -- 時刻データへのアクセスと変換
---------------------------------------------

__________________________________________________________________

このモジュールでは、時刻に関するさまざまな関数を提供します。関連した機能
について、*note datetime: 28, *note calendar: 10. モジュールも参照してく
ださい。

このモジュールは常に利用可能ですが、すべての関数がすべてのプラットフォー
ムで利用可能なわけではありません。このモジュールで定義されているほとんど
の関数は、プラットフォーム上の同名の C ライブラリ関数を呼び出します。こ
れらの関数に対する意味付けはプラットフォーム間で異なるため、プラットフォ
ーム提供のドキュメントを読んでおくと便利でしょう。

まずいくつかの用語の説明と慣習について整理します。

   * The 'epoch' is the point where the time starts, the return value of
     ‘time.gmtime(0)’.  It is January 1, 1970, 00:00:00 (UTC) on all
     platforms.

   * 'エポック秒' ('seconds since the epoch') は、エポックからの総経過秒
     数を示していますが、たいていはうるう秒 (leap seconds(1)) は含まれて
     いません。 全ての POSIX 互換のプラットフォームで、うるう秒はこの総
     秒数には含まれません。

   * このモジュールの中の関数は、エポック (*note epoch: 297b.) 以前ある
     いは遠い未来の日付や時刻を扱うことができません。将来カットオフ（関
     数が正しく日付や時刻を扱えなくなる）が起きる時点は、C ライブラリに
     よって決まります。32-bit システムではカットオフは通常 2038 年です。

   * 関数 *note strptime(): 13d4. は ‘%y’ 書式コードが与えられた時に 2 桁
     の年表記を解析できます。2 桁の年を解析する場合、それらは POSIX およ
     び ISO C 標準に従って変換されます: 69-99 の西暦年は 1969-1999 とな
     り、0–68 の西暦年は 2000–2068 になります。

   * UTC は協定世界時 (Coordinated Universal Time) のことです (以前はグ
     リニッジ標準時または GMT として知られていました)。UTC の頭文字の並
     びは誤りではなく、英仏の妥協によるものです。

   * DST は夏時間 (Daylight Saving Time) のことで、一年のうちの一定期間
     に 1 時間タイムゾーンを修正することです。DST のルールは不可思議で
     (地域ごとに法律で定められています)、年ごとに変わることもあります。C
     ライブラリはローカルルールを記したテーブルを持っており (柔軟に対応
     するため、たいていはシステムファイルから読み込まれます)、この点に関
     しては唯一の真実の知識の源です。

   * 多くの現時刻を返す関数 (real-time functions) の精度は、値や引数を表
     現するために使う単位から想像されるよりも低いかも知れません。例えば
     、ほとんどの Unix システムにおいて、クロックの 1 ティックの精度は
     50 から 100 分の 1 秒に過ぎません。

   * On the other hand, the precision of *note time(): 235. and *note
     sleep(): 669. is better than their Unix equivalents: times are
     expressed as floating-point numbers, *note time(): 235. returns the
     most accurate time available (using Unix ‘gettimeofday()’ where
     available), and *note sleep(): 669. will accept a time with a
     nonzero fraction (Unix ‘select()’ is used to implement this, where
     available).

   * *note gmtime(): 1190, *note localtime(): 14a2, *note strptime():
     13d4. が返す時刻値、および *note asctime(): 11b8, *note mktime():
     11b9, *note strftime(): 11ba. がとる時刻値は 9 個の整数からなるシー
     ケンスです。*note gmtime(): 1190, *note localtime(): 14a2, *note
     strptime(): 13d4. の戻り値は個々の値を属性名で取得することもできま
     す。

     これらのオブジェクトについての解説は *note struct_time: cb8. を参照
     してください。

     バージョン 3.3 で変更: The *note struct_time: cb8. type was
     extended to provide the *note tm_gmtoff: 2b99. and *note tm_zone:
     2b9a. attributes when platform supports corresponding ‘struct tm’
     members.

     バージョン 3.6 で変更: The *note struct_time: cb8. attributes *note
     tm_gmtoff: 2b99. and *note tm_zone: 2b9a. are now available on all
     platforms.

   * 時間の表現を変換するには、以下の関数を利用してください:

     対象                          変換先                        関数
                                                                 
     ------------------------------------------------------------------------------------------
                                                                 
     エポックからの秒数            UTC の                        *note gmtime(): 1190.
                                   *note struct_time: cb8.       
                                   
                                                                 
     エポックからの秒数            ローカル時間の                *note localtime(): 14a2.
                                   *note struct_time: cb8.       
                                   
                                                                 
     UTC の                        エポックからの秒数            *note calendar.timegm(): 242b.
     *note struct_time: cb8.                                     

     ローカル時間の                エポックからの秒数            *note mktime(): 11b9.
     *note struct_time: cb8.                                     

* Menu:

* 関数: 関数<5>.
* Clock ID Constants::
* Timezone Constants::

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Leap_second


File: python.info,  Node: 関数<5>,  Next: Clock ID Constants,  Up: time --- 時刻データへのアクセスと変換

5.16.3.1 関数
.............

 -- の関数: time.asctime ([t])

     Convert a tuple or *note struct_time: cb8. representing a time as
     returned by *note gmtime(): 1190. or *note localtime(): 14a2. to a
     string of the following form: ‘'Sun Jun 20 23:21:05 1993'’.  The
     day field is two characters long and is space padded if the day is
     a single digit, e.g.: ‘'Wed Jun 9 04:26:40 1993'’.

     If 't' is not provided, the current time as returned by *note
     localtime(): 14a2. is used.  Locale information is not used by
     *note asctime(): 11b8.

          注釈: 同名の C の関数と違って、*note asctime(): 11b8. は末尾に
          改行文字を加えません。

 -- の関数: time.pthread_getcpuclockid (thread_id)

     Return the 'clk_id' of the thread-specific CPU-time clock for the
     specified 'thread_id'.

     Use *note threading.get_ident(): 112d. or the *note ident: 2b9d.
     attribute of *note threading.Thread: 91a. objects to get a suitable
     value for 'thread_id'.

          警告: Passing an invalid or expired 'thread_id' may result in
          undefined behavior, such as segmentation fault.

     *note Availability: 1cbe.: Unix

     更なる情報については ‘pthread_getcpuclockid(3)(1)’ の man を参照し
     てください。

     Added in version 3.7.

 -- の関数: time.clock_getres (clk_id)

     指定された 'clk_id' クロックの分解能(精度)を返します。 'clk_id' と
     して受け付けられる値の一覧は *note Clock ID Constants: 2b10. を参照
     してください。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: time.clock_gettime (clk_id) -> float

     指定された 'clk_id' クロックの時刻を返します。 'clk_id' として受け
     付けられる値の一覧は *note Clock ID Constants: 2b10. を参照してくだ
     さい。

     Use *note clock_gettime_ns(): ab0. to avoid the precision loss
     caused by the *note float: 2ce. type.

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- の関数: time.clock_gettime_ns (clk_id) -> int

     *note clock_gettime(): 1131. に似ていますが、ナノ秒単位の時刻を返し
     ます。

     *note Availability: 1cbe.: Unix.

     Added in version 3.7.

 -- の関数: time.clock_settime (clk_id, time: float)

     指定された 'clk_id' クロックの時刻を設定します。 現在、 *note
     CLOCK_REALTIME: 666. は 'clk_id' が受け付ける唯一の値です。

     Use *note clock_settime_ns(): ab1. to avoid the precision loss
     caused by the *note float: 2ce. type.

     *note Availability: 1cbe.: Unix, not Android, not iOS.

     Added in version 3.3.

 -- の関数: time.clock_settime_ns (clk_id, time: int)

     *note clock_settime(): 1132. に似ていますが、ナノ秒単位の時刻を設定
     します。

     *note Availability: 1cbe.: Unix, not Android, not iOS.

     Added in version 3.7.

 -- の関数: time.ctime ([secs])

     Convert a time expressed in seconds since the *note epoch: 297b. to
     a string of a form: ‘'Sun Jun 20 23:21:05 1993'’ representing local
     time.  The day field is two characters long and is space padded if
     the day is a single digit, e.g.: ‘'Wed Jun 9 04:26:40 1993'’.

     'secs' を指定しないか *note None: 641. を指定した場合、*note
     time(): 235. が返す値を現在の時刻として使用します。‘ctime(secs)’ は
     ‘asctime(localtime(secs))’ と等価です。ローカル情報は *note
     ctime(): 23ac. には使用されません。

 -- の関数: time.get_clock_info (name)

     指定されたクロックの情報を名前空間オブジェクトとして取得します。サ
     ポートされているクロック名およびそれらの値を取得する関数は以下の通
     りです:

        * ‘'monotonic'’: *note time.monotonic(): 234.

        * ‘'perf_counter'’: *note time.perf_counter(): a56.

        * ‘'process_time'’: *note time.process_time(): a57.

        * ‘'thread_time'’: *note time.thread_time(): 904.

        * ‘'time'’: *note time.time(): 235.

     結果は以下の属性をもちます:

        - 'adjustable': 自動 (NTP デーモンによるなど) またはシステム管理
          者による手動で変更できる場合は ‘True’、それ以外の場合は
          ‘False’ になります。

        - 'implementation': クロック値を取得するために内部で使用している
          C 関数の名前です。 使える値については *note Clock ID
          Constants: 2b10. を参照してください。

        - 'monotonic': クロック値が後戻りすることがない場合 ‘True’ が、
          そうでない場合は ‘False’ になります。

        - 'resolution': クロックの分解能を秒 (*note float: 2ce.) で表し
          ます。

     Added in version 3.3.

 -- の関数: time.gmtime ([secs])

     エポック (*note epoch: 297b.) からの経過時間で表現された時刻を、UTC
     で *note struct_time: cb8. に変換します。このとき dst フラグは常に
     ゼロとして扱われます。'secs' を指定しないか *note None: 641. を指定
     した場合、*note time(): 235. が返す値を現在の時刻として使用します。
     秒の端数は無視されます。*note struct_time: cb8. オブジェクトについ
     ては前述の説明を参照してください。*note calendar.timegm(): 242b. は
     この関数と逆の変換を行います。

 -- の関数: time.localtime ([secs])

     *note gmtime(): 1190. に似ていますが、ローカル時間に変換します。
     'secs' を指定しないか *note None: 641. を指定した場合、*note
     time(): 235. が返す値を現在の時刻として使用します。DST が適用されて
     いる場合は dst フラグには ‘1’ が設定されます。

     *note localtime(): 14a2. may raise *note OverflowError: 84e, if the
     timestamp is outside the range of values supported by the platform
     C ‘localtime()’ or ‘gmtime()’ functions, and *note OSError: 3f0. on
     ‘localtime()’ or ‘gmtime()’ failure.  It's common for this to be
     restricted to years between 1970 and 2038.

 -- の関数: time.mktime (t)

     This is the inverse function of *note localtime(): 14a2.  Its
     argument is the *note struct_time: cb8. or full 9-tuple (since the
     dst flag is needed; use ‘-1’ as the dst flag if it is unknown)
     which expresses the time in 'local' time, not UTC. It returns a
     floating-point number, for compatibility with *note time(): 235.
     If the input value cannot be represented as a valid time, either
     *note OverflowError: 84e. or *note ValueError: 1e3. will be raised
     (which depends on whether the invalid value is caught by Python or
     the underlying C libraries).  The earliest date for which it can
     generate a time is platform-dependent.

 -- の関数: time.monotonic () -> float

     モノトニッククロック、すなわち後戻りしないクロックの値を (小数秒で)
     返します。このクロックはシステムクロックの更新の影響を受けません。
     戻り値の基準点は定義されていないので、二回の呼び出しの結果の差だけ
     が有効です。

     Clock:

        * On Windows, call ‘QueryPerformanceCounter()’ and
          ‘QueryPerformanceFrequency()’.

        * On macOS, call ‘mach_absolute_time()’ and
          ‘mach_timebase_info()’.

        * On HP-UX, call ‘gethrtime()’.

        * Call ‘clock_gettime(CLOCK_HIGHRES)’ if available.

        * Otherwise, call ‘clock_gettime(CLOCK_MONOTONIC)’.

     Use *note monotonic_ns(): ab2. to avoid the precision loss caused
     by the *note float: 2ce. type.

     Added in version 3.3.

     バージョン 3.5 で変更: この関数は、常に利用でき、常にシステム全域で
     使えるようになりました。

     バージョン 3.10 で変更: On macOS, the function is now system-wide.

 -- の関数: time.monotonic_ns () -> int

     *note monotonic(): 234. に似ていますが、ナノ秒単位の時刻を返します
     。

     Added in version 3.7.

 -- の関数: time.perf_counter () -> float

     パフォーマンスカウンター、すなわち短い時間を計測するための可能な限
     り高い分解能を持つクロックの値を (小数秒で) 返します。これはスリー
     プ中の経過時間を含み、システムワイドです。戻り値の基準点は定義され
     ていないので、二回の呼び出しの結果の差だけが有効です。

     'CPython 実装の詳細:' On CPython, use the same clock as *note
     time.monotonic(): 234. and is a monotonic clock, i.e.  a clock that
     cannot go backwards.

     Use *note perf_counter_ns(): ab3. to avoid the precision loss
     caused by the *note float: 2ce. type.

     Added in version 3.3.

     バージョン 3.10 で変更: On Windows, the function is now
     system-wide.

     バージョン 3.13 で変更: Use the same clock as *note
     time.monotonic(): 234.

 -- の関数: time.perf_counter_ns () -> int

     *note perf_counter(): a56. に似ていますが、ナノ秒単位の時刻を返しま
     す。

     Added in version 3.7.

 -- の関数: time.process_time () -> float

     現在のプロセスのシステムおよびユーザー CPU 時間の値を (小数秒で) 返
     します。これはスリープ中の経過時間を含みません。これは定義上プロセ
     スワイドです。戻り値の基準点は定義されていないので、二回の呼び出し
     の結果の差だけが有効です。

     Use *note process_time_ns(): ab4. to avoid the precision loss
     caused by the *note float: 2ce. type.

     Added in version 3.3.

 -- の関数: time.process_time_ns () -> int

     *note process_time(): a57. に似ていますが、ナノ秒単位の時刻を返しま
     す。

     Added in version 3.7.

 -- の関数: time.sleep (secs)

     Suspend execution of the calling thread for the given number of
     seconds.  The argument may be a floating-point number to indicate a
     more precise sleep time.

     If the sleep is interrupted by a signal and no exception is raised
     by the signal handler, the sleep is restarted with a recomputed
     timeout.

     The suspension time may be longer than requested by an arbitrary
     amount, because of the scheduling of other activity in the system.

     On Windows, if 'secs' is zero, the thread relinquishes the
     remainder of its time slice to any other thread that is ready to
     run.  If there are no other threads ready to run, the function
     returns immediately, and the thread continues execution.  On
     Windows 8.1 and newer the implementation uses a high-resolution
     timer(2) which provides resolution of 100 nanoseconds.  If 'secs'
     is zero, ‘Sleep(0)’ is used.

     Unix implementation:

        * Use ‘clock_nanosleep()’ if available (resolution: 1
          nanosecond);

        * Or use ‘nanosleep()’ if available (resolution: 1 nanosecond);

        * Or use ‘select()’ (resolution: 1 microsecond).

     Raises an *note auditing event: 1825. ‘time.sleep’ with argument
     ‘secs’.

     バージョン 3.5 で変更: スリープがシグナルに中断されてもシグナルハン
     ドラが例外を送出しない限り、少なくとも 'secs' だけスリープするよう
     になりました (論拠については PEP 475(3) を参照してください)。

     バージョン 3.11 で変更: On Unix, the ‘clock_nanosleep()’ and
     ‘nanosleep()’ functions are now used if available.  On Windows, a
     waitable timer is now used.

     バージョン 3.13 で変更: Raises an auditing event.

 -- の関数: time.strftime (format[, t])

     *note gmtime(): 1190. や *note localtime(): 14a2. が返す時刻値タプ
     ルまたは *note struct_time: cb8. を、'format' で指定した文字列形式
     に変換します。't' が与えられていない場合、*note localtime(): 14a2.
     が返す値を現在の時刻として使用します。'format' は文字列でなくてはな
     りません。't' のいずれかのフィールドが許容範囲外の数値であった場合
     、*note ValueError: 1e3. を送出します。

     0 は時刻タプル内のいずれの位置の引数にも使用できます; それが一般に
     不正な値であれば、正しい値に強制的に置き換えられます。

     'format' 文字列には以下のディレクティブ (指示語) を埋め込むことがで
     きます。これらはフィールド長や精度のオプションを付けずに表され、
     *note strftime(): 11ba. の結果の対応する文字列に置き換えられます:

     ディレクティ    意味                                                 注釈
     ブ                                                                   

     ---------------------------------------------------------------------------------
                                                                          
     ‘%a’            ロケールの短縮された曜日名になります。
                     
                                                                          
     ‘%A’            ロケールの曜日名になります。
                     
                                                                          
     ‘%b’            ロケールの短縮された月名になります。
                     
                                                                          
     ‘%B’            ロケールの月名になります。
                     
                                                                          
     ‘%c’            ロケールの日時を適切な形式で表します。
                     
                                                                          
     ‘%d’            月中の日にちの 10 進表記になります [01,31]。
                     
                                                                          
     ‘%f’            Microseconds as a decimal number                     (1)
                                                                          
                          [000000,999999].
                     
                                                                          
     ‘%H’            時 (24 時間表記) の 10 進表記になります [00,23]。
                     
                                                                          
     ‘%I’            時 (12 時間表記) の 10 進表記になります [01,12]。
                     
                                                                          
     ‘%j’            年中の日にちの 10 進表記になります [001,366]。
                     
                                                                          
     ‘%m’            月の 10 進表記になります [01,12]。
                     
                                                                          
     ‘%M’            分の 10 進表記になります [00,59]。
                     
                                                                          
     ‘%p’            ロケールの AM もしくは PM と等価な文字列になります   (2)
                     。                                                   
                     
                                                                          
     ‘%S’            秒の 10 進表記になります [00,61]。                   (3)
                                                                          
                                                                          
     ‘%U’            年の初めから何週目か (日曜を週の始まりとします) を   (4)
                     表す 10 進数になります [00,53]。年が明けてから最初   
                     の日曜日までのすべての曜日は 0 週目に属すると見な
                     されます。
                     
                                                                          
     ‘%u’            Day of the week (Monday is 1; Sunday is 7) as a
                     decimal number [1, 7].
                     
                                                                          
     ‘%w’            曜日の 10 進表記になります [0 (日曜日),6]。
                     
                                                                          
     ‘%W’            年の初めから何週目か (月曜を週の始まりとします) を   (4)
                     表す 10 進数になります [00,53]。年が明けてから最初   
                     の月曜日までの全ての曜日は 0 週目に属すると見なさ
                     れます。
                     
                                                                          
     ‘%x’            ロケールの日付を適切な形式で表します。
                     
                                                                          
     ‘%X’            ロケールの時間を適切な形式で表します。
                     
                                                                          
     ‘%y’            西暦の下 2 桁の 10 進表記になります [00,99]。
                     
                                                                          
     ‘%Y’            西暦 ( 4桁) の 10 進表記を表します。
                     
                                                                          
     ‘%z’            タイムゾーンと UTC/GMT との時差を表す正または負の
                     時間を +HHMM、-HHMM で表します。H は時間の、M は分
                     の 10 進表記になります [-23:59, +23:59]。 (4)
                     
                                                                          
     ‘%Z’            タイムゾーンの名前を表します (タイムゾーンがない場
                     合には空文字列)。非推奨です。 (5)
                     
                                                                          
     ‘%G’            ISO 8601 year (similar to ‘%Y’ but follows the
                     rules for the ISO 8601 calendar year).  The year
                     starts with the week that contains the first
                     Thursday of the calendar year.
                     
                                                                          
     ‘%V’            ISO 8601 week number (as a decimal number
                     [01,53]).  The first week of the year is the one
                     that contains the first Thursday of the year.
                     Weeks start on Monday.
                     
                                                                          
     ‘%%’            文字 ‘'%'’ を表します。
                     

     注釈:

       1. The ‘%f’ format directive only applies to *note strptime():
          13d4, not to *note strftime(): 11ba.  However, see also *note
          datetime.datetime.strptime(): 156e. and *note
          datetime.datetime.strftime(): c5e. where the ‘%f’ format
          directive *note applies to microseconds: 237d.

       2. *note strptime(): 13d4. 関数で使う場合、‘%p’ ディレクティブが
          出力結果の時刻フィールドに影響を及ぼすのは、時刻を解釈するため
          に ‘%I’ を使ったときのみです。

       3. 値の幅は実際に ‘0’ から ‘61’ です; ‘60’ は うるう秒<leap
          seconds>(6) を表し、 ‘61’ は歴史的理由によりサポートされていま
          す。

       4. *note strptime(): 13d4. 関数で使う場合、‘%U’ および ‘%W’ を計
          算に使うのは曜日と年を指定したときだけです。

     以下に RFC 2822(7) インターネット電子メール標準で定義されている日付
     表現と互換の書式の例を示します。 (8)

          >>> from time import gmtime, strftime
          >>> strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
          'Thu, 28 Jun 2001 14:17:15 +0000'

     一部のプラットフォームではさらにいくつかのディレクティブがサポート
     されていますが、標準 ANSI C で意味のある値はここで列挙したものだけ
     です。あなたのプラットフォームでサポートされている書式コードの全一
     覧については、‘strftime(3)(9)’ のドキュメントを参照してください。

     一部のプラットフォームでは、フィールドの幅や精度を指定するオプショ
     ンがディレクティブの先頭の文字 ‘'%'’ の直後に付けられるようになって
     いました; この機能も移植性はありません。フィールドの幅は通常 2 です
     が、‘%j’ は例外で 3 です。

 -- の関数: time.strptime (string[, format])

     時刻を表現する文字列を書式に従って解釈します。返される値は *note
     gmtime(): 1190. や *note localtime(): 14a2. が返すような *note
     struct_time: cb8. です。

     'format' パラメーターは *note strftime(): 11ba. で使うものと同じデ
     ィレクティブを使います; このパラメーターの値はデフォルトでは ‘"%a
     %b %d %H:%M:%S %Y"’ で、*note ctime(): 23ac. が返すフォーマットに一
     致します。'string' が 'format' に従って解釈できなかった場合、例外
     *note ValueError: 1e3. が送出されます。解析しようとする 'string' が
     解析後に余分なデータを持っていた場合、*note ValueError: 1e3. が送出
     されます。欠落したデータについて、適切な値を推測できない場合はデフ
     ォルトの値で埋められ、その値は ‘(1900, 1, 1, 0, 0, 0, 0, 1, -1)’ で
     す。'string' も 'format' も文字列でなければなりません。

     例えば:

          >>> import time
          >>> time.strptime("30 Nov 00", "%d %b %y")
          time.struct_time(tm_year=2000, tm_mon=11, tm_mday=30, tm_hour=0, tm_min=0,
                           tm_sec=0, tm_wday=3, tm_yday=335, tm_isdst=-1)

     ‘%Z’ ディレクティブへのサポートは ‘tzname’ に収められている値と
     ‘daylight’ が真かどうかで決められます。このため、常に既知の (かつ夏
     時間でないと考えられている) UTC や GMT を認識する時以外はプラットフ
     ォーム固有の動作になります。

     ドキュメント内で説明されているディレクティブだけがサポートされてい
     ます。‘strftime()’ はプラットフォームごとに実装されているので、説明
     されていないディレクティブも利用できるかもしれません。しかし、
     ‘strptime()’ はプラットフォーム非依存なので、ドキュメント内でサポー
     トされているとされているディレクティブ以外は利用できません。

 -- クラス: time.struct_time

     *note gmtime(): 1190, *note localtime(): 14a2. および *note
     strptime(): 13d4. が返す時刻値シーケンスの型です。これは *note
     名前付きタプル: 61a. のインターフェースをもったオブジェクトです。値
     はインデックスでも属性名でもアクセス可能です。以下の値があります:

     インデックス                          属性                                  値
                                                                                 
                                                                                 
     0                                      -- の属性: tm_year                   (例えば 1993)
                                                                                 
                                                                                 
     1                                      -- の属性: tm_mon                    [1,12] の間の数
                                                                                 
                                                                                 
     2                                      -- の属性: tm_mday                   [1,31] の間の数
                                                                                 
                                                                                 
     3                                      -- の属性: tm_hour                   [0,23] の間の数
                                                                                 
                                                                                 
     4                                      -- の属性: tm_min                    [0,59] の間の数
                                                                                 
                                                                                 
     5                                      -- の属性: tm_sec                    range [0, 61]; see
                                                                                 *note Note (2): 2b9e. in
                                                                                 *note strftime(): 11ba.
                                                                                 
                                                                                 
     6                                      -- の属性: tm_wday                   range [0, 6]; Monday is 0
                                                                                 
                                                                                 
     7                                      -- の属性: tm_yday                   [1,366] の間の数
                                                                                 
                                                                                 
     8                                      -- の属性: tm_isdst                  0, 1 または -1; 以下を参照してくだ
                                                                                 さい
                                                                                 
                                                                                 
     N/A                                    -- の属性: tm_zone                   タイムゾーンの短縮名
                                                                                 
                                                                                 
     N/A                                    -- の属性: tm_gmtoff                 UTC から東方向へのオフセット (秒)
                                                                                 

     C の構造体とは異なり、月の値は [0, 11] ではなく [1, 12] であること
     に注意してください。

     *note mktime(): 11b9. の呼び出し時に、*note tm_isdst: 23bd. は夏時
     間が有効な場合は 1、そうでない場合は 0 に設定されることがあります。
     値が -1 の場合は夏時間について不明なことを表していて、普通 *note
     tm_isdst: 23bd. は正しい状態に設定されます。

     *note struct_time: cb8. を引数とする関数に正しくない長さの *note
     struct_time: cb8. や要素の型が正しくない *note struct_time: cb8. を
     与えた場合には、 *note TypeError: 502. が送出されます。

 -- の関数: time.time () -> float

     Return the time in seconds since the *note epoch: 297b. as a
     floating-point number.  The handling of leap seconds(10) is
     platform dependent.  On Windows and most Unix systems, the leap
     seconds are not counted towards the time in seconds since the *note
     epoch: 297b.  This is commonly referred to as Unix time(11).

     Note that even though the time is always returned as a
     floating-point number, not all systems provide time with a better
     precision than 1 second.  While this function normally returns
     non-decreasing values, it can return a lower value than a previous
     call if the system clock has been set back between the two calls.

     *note time(): 235. が返す数値は、 *note gmtime(): 1190. 関数に渡さ
     れて UTC の、あるいは *note localtime(): 14a2. 関数に渡されて現地時
     間の、より一般的な時間のフォーマット (つまり、年、月、日、時間など)
     に変換されているかもしれません。 どちらの場合でも *note
     struct_time: cb8. オブジェクトが返され、このオブジェクトの属性とし
     てカレンダー日付の構成要素へアクセスできます。

     Clock:

        * On Windows, call ‘GetSystemTimeAsFileTime()’.

        * Call ‘clock_gettime(CLOCK_REALTIME)’ if available.

        * Otherwise, call ‘gettimeofday()’.

     Use *note time_ns(): ab5. to avoid the precision loss caused by the
     *note float: 2ce. type.

 -- の関数: time.time_ns () -> int

     *note time(): 235. に似ていますが、時刻を *note epoch: 297b. を基点
     としたナノ秒単位の整数で返します。

     Added in version 3.7.

 -- の関数: time.thread_time () -> float

     現在のスレッドのシステムおよびユーザー CPU 時間の値を (小数秒で) 返
     します。これはスリープ中の経過時間を含みません。これは定義上スレッ
     ド固有です。戻り値の基準点は定義されていないので、同一スレッドにお
     ける二回の呼び出しの結果の差だけが有効です。

     Use *note thread_time_ns(): b5f. to avoid the precision loss caused
     by the *note float: 2ce. type.

     *note Availability: 1cbe.: Linux, Unix, Windows.

     Unix systems supporting ‘CLOCK_THREAD_CPUTIME_ID’.

     Added in version 3.7.

 -- の関数: time.thread_time_ns () -> int

     *note thread_time(): 904. に似ていますが、ナノ秒単位の時刻を返しま
     す。

     Added in version 3.7.

 -- の関数: time.tzset ()

     Reset the time conversion rules used by the library routines.  The
     environment variable ‘TZ’ specifies how this is done.  It will also
     set the variables ‘tzname’ (from the ‘TZ’ environment variable),
     ‘timezone’ (non-DST seconds West of UTC), ‘altzone’ (DST seconds
     west of UTC) and ‘daylight’ (to 0 if this timezone does not have
     any daylight saving time rules, or to nonzero if there is a time,
     past, present or future when daylight saving time applies).

     *note Availability: 1cbe.: Unix.

          注釈: 多くの場合、環境変数 ‘TZ’ を変更すると、 *note tzset():
          2ba6. を呼ばない限り *note localtime(): 14a2. のような関数の出
          力に影響を及ぼすため、値が信頼できなくなってしまいます。

          ‘TZ’ 環境変数には空白文字を含めてはなりません。

     環境変数 ‘TZ’ の標準的な書式は以下の通りです (分かりやすいように空
     白を入れています):

          std offset [dst [offset [,start[/time], end[/time]]]]

     各値は以下のようになっています:

     ‘std’ と ‘dst’

          三文字またはそれ以上の英数字で、タイムゾーンの略称を与えます。
          この値は time.tzname になります。

     ‘offset’

          オフセットは形式: ‘± hh[:mm[:ss]]’ をとります。この表現は、UTC
          時刻にするためにローカルな時間に加算する必要のある時間値を示し
          ます。'-' が先頭につく場合、そのタイムゾーンは本初子午線
          (Prime Meridian) より東側にあります。それ以外の場合は本初子午
          線の西側です。オフセットが dst の後ろに続かない場合、夏時間は
          標準時より一時間先行しているものと仮定します。

     ‘start[/time], end[/time]’

          いつ DST に移動し、DST から戻ってくるかを示します。開始および
          終了日時の形式は以下のいずれかです:

          ‘JN’

               ユリウス日 (Julian day) 'n' (1 <= 'n' <= 365) を表します
               。うるう日は計算に含められないため、2 月 28 日は常に 59 で
               、3 月 1 日は 60 になります。

          ‘N’

               ゼロから始まるユリウス日 (0 <= 'n' <= 365) です。うるう日
               は計算に含められるため、2 月 29 日を参照することができま
               す。

          ‘MM.N.D’

               'm' 月の週 'n' における 'd' 番目の日 (0 <= 'd' <= 6, 1 <=
               'n' <= 5, 1 <= 'm' <= 12) を表します。週 5 は月 'm' にお
               ける最終週の 'd' 番目の日を表し、第 4 週か第 5 週のどちら
               かになります。週 1 は日 'd' が最初に現れる日を指します。
               日 0 は日曜日です。

          ‘time’ は ‘offset’ とほぼ同じで、先頭に符号 ('-' や '+') を付
          けてはいけないところだけが違います。時刻が指定されていなければ
          、デフォルトの値 02:00:00 になります。

          >>> os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
          >>> time.tzset()
          >>> time.strftime('%X %x %Z')
          '02:07:36 05/08/03 EDT'
          >>> os.environ['TZ'] = 'AEST-10AEDT-11,M10.5.0,M3.5.0'
          >>> time.tzset()
          >>> time.strftime('%X %x %Z')
          '16:08:12 05/08/03 AEST'

     多くの Unix システム (*BSD, Linux, Solaris, および Darwin を含む) で
     は、システムの zoneinfo (‘tzfile(5)(12)’) データベースを使ったほう
     が、タイムゾーンごとの規則を指定する上で便利です。これを行うには、
     必要なタイムゾーンデータファイルへのパスをシステムの 'zoneinfo' タ
     イムゾーンデータベースからの相対で表した値を環境変数 ‘TZ’ に設定し
     ます。システムの 'zoneinfo' は通常 ‘/usr/share/zoneinfo’ にあります
     。例えば、 ‘'US/Eastern'’ 、 ‘'Australia/Melbourne'’ 、 ‘'Egypt'’ な
     いし ‘'Europe/Amsterdam'’ と指定します。

          >>> os.environ['TZ'] = 'US/Eastern'
          >>> time.tzset()
          >>> time.tzname
          ('EST', 'EDT')
          >>> os.environ['TZ'] = 'Egypt'
          >>> time.tzset()
          >>> time.tzname
          ('EET', 'EEST')

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/pthread_getcpuclockid(3)

   (2) 
https://learn.microsoft.com/windows-hardware/drivers/kernel/high-resolution-timers

   (3) https://peps.python.org/pep-0475/

   (4) ‘%Z’ の使用は現在非推奨です。ただし、ここで実現したい時間および分
オフセットへの展開を行ってくれる ‘%z’ エスケープはすべての ANSI C ライブ
ラリでサポートされているわけではありません。また、1982 年に提出されたオ
リジナルの RFC 822 (https://datatracker.ietf.org/doc/html/rfc822.html) 標
準では西暦の表現を 2 桁とするよう要求している (‘%Y’ でなく ‘%y’) ものの
、実際には 2000 年になるだいぶ以前から 4 桁の西暦表現に移行しています。
その後 RFC 822 (https://datatracker.ietf.org/doc/html/rfc822.html) は撤
廃され、4 桁の西暦表現は RFC 1123
(https://datatracker.ietf.org/doc/html/rfc1123.html) で初めて勧告され、
RFC 2822 (https://datatracker.ietf.org/doc/html/rfc2822.html) において義
務付けられました。

   (5) ‘%Z’ の使用は現在非推奨です。ただし、ここで実現したい時間および分
オフセットへの展開を行ってくれる ‘%z’ エスケープはすべての ANSI C ライブ
ラリでサポートされているわけではありません。また、1982 年に提出されたオ
リジナルの RFC 822 (https://datatracker.ietf.org/doc/html/rfc822.html) 標
準では西暦の表現を 2 桁とするよう要求している (‘%Y’ でなく ‘%y’) ものの
、実際には 2000 年になるだいぶ以前から 4 桁の西暦表現に移行しています。
その後 RFC 822 (https://datatracker.ietf.org/doc/html/rfc822.html) は撤
廃され、4 桁の西暦表現は RFC 1123
(https://datatracker.ietf.org/doc/html/rfc1123.html) で初めて勧告され、
RFC 2822 (https://datatracker.ietf.org/doc/html/rfc2822.html) において義
務付けられました。

   (6) https://en.wikipedia.org/wiki/Leap_second

   (7) https://datatracker.ietf.org/doc/html/rfc2822.html

   (8) ‘%Z’ の使用は現在非推奨です。ただし、ここで実現したい時間および分
オフセットへの展開を行ってくれる ‘%z’ エスケープはすべての ANSI C ライブ
ラリでサポートされているわけではありません。また、1982 年に提出されたオ
リジナルの RFC 822 (https://datatracker.ietf.org/doc/html/rfc822.html) 標
準では西暦の表現を 2 桁とするよう要求している (‘%Y’ でなく ‘%y’) ものの
、実際には 2000 年になるだいぶ以前から 4 桁の西暦表現に移行しています。
その後 RFC 822 (https://datatracker.ietf.org/doc/html/rfc822.html) は撤
廃され、4 桁の西暦表現は RFC 1123
(https://datatracker.ietf.org/doc/html/rfc1123.html) で初めて勧告され、
RFC 2822 (https://datatracker.ietf.org/doc/html/rfc2822.html) において義
務付けられました。

   (9) https://manpages.debian.org/strftime(3)

   (10) https://en.wikipedia.org/wiki/Leap_second

   (11) https://en.wikipedia.org/wiki/Unix_time

   (12) https://manpages.debian.org/tzfile(5)


File: python.info,  Node: Clock ID Constants,  Next: Timezone Constants,  Prev: 関数<5>,  Up: time --- 時刻データへのアクセスと変換

5.16.3.2 Clock ID Constants
...........................

These constants are used as parameters for *note clock_getres(): 1130.
and *note clock_gettime(): 1131.

 -- データ: time.CLOCK_BOOTTIME

     Identical to *note CLOCK_MONOTONIC: 665, except it also includes
     any time that the system is suspended.

     This allows applications to get a suspend-aware monotonic clock
     without having to deal with the complications of *note
     CLOCK_REALTIME: 666, which may have discontinuities if the time is
     changed using ‘settimeofday()’ or similar.

     *note Availability: 1cbe.: Linux >= 2.6.39.

     Added in version 3.7.

 -- データ: time.CLOCK_HIGHRES

     Solaris OS は任意のハードウェアソースの使用を試み、ナノ秒レベルの分
     解能を提供する ‘CLOCK_HIGHRES’ タイマーを具備しています。
     ‘CLOCK_HIGHRES’ は変更不可で、高分解能のクロックです。

     *note Availability: 1cbe.: Solaris.

     Added in version 3.3.

 -- データ: time.CLOCK_MONOTONIC

     設定不可で、モノトニック時刻 (不特定のエポックからの単調増加な時刻)
     を表します。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- データ: time.CLOCK_MONOTONIC_RAW

     *note CLOCK_MONOTONIC: 665. と似ていますが、NTP の影響を受けていな
     い、ハードウェアベースの時刻へのアクセスを提供します。

     *note Availability: 1cbe.: Linux >= 2.6.28, macOS >= 10.12.

     Added in version 3.3.

 -- データ: time.CLOCK_MONOTONIC_RAW_APPROX

     Similar to *note CLOCK_MONOTONIC_RAW: 2ba9, but reads a value
     cached by the system at context switch and hence has less accuracy.

     *note Availability: 1cbe.: macOS >= 10.12.

     Added in version 3.13.

 -- データ: time.CLOCK_PROCESS_CPUTIME_ID

     CPU による高分解能のプロセスごとのタイマーです。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- データ: time.CLOCK_PROF

     CPU による高分解能のプロセスごとのタイマーです。

     *note Availability: 1cbe.: FreeBSD, NetBSD >= 7, OpenBSD.

     Added in version 3.7.

 -- データ: time.CLOCK_TAI

     International Atomic Time(1)

     The system must have a current leap second table in order for this
     to give the correct answer.  PTP or NTP software can maintain a
     leap second table.

     *note Availability: 1cbe.: Linux.

     Added in version 3.9.

 -- データ: time.CLOCK_THREAD_CPUTIME_ID

     スレッド固有の CPU タイムクロックです。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

 -- データ: time.CLOCK_UPTIME

     Time whose absolute value is the time the system has been running
     and not suspended, providing accurate uptime measurement, both
     absolute and interval.

     *note Availability: 1cbe.: FreeBSD, OpenBSD >= 5.5.

     Added in version 3.7.

 -- データ: time.CLOCK_UPTIME_RAW

     Clock that increments monotonically, tracking the time since an
     arbitrary point, unaffected by frequency or time adjustments and
     not incremented while the system is asleep.

     *note Availability: 1cbe.: macOS >= 10.12.

     Added in version 3.8.

 -- データ: time.CLOCK_UPTIME_RAW_APPROX

     Like *note CLOCK_UPTIME_RAW: a11, but the value is cached by the
     system at context switches and therefore has less accuracy.

     *note Availability: 1cbe.: macOS >= 10.12.

     Added in version 3.13.

The following constant is the only parameter that can be sent to *note
clock_settime(): 1132.

 -- データ: time.CLOCK_REALTIME

     システム全体のリアルタイムクロックです。このクロックを設定するには
     適切な権限が必要です。

     *note Availability: 1cbe.: Unix.

     Added in version 3.3.

   ---------- Footnotes ----------

   (1) 
https://www.nist.gov/pml/time-and-frequency-division/nist-time-frequently-asked-questions-faq#tai


File: python.info,  Node: Timezone Constants,  Prev: Clock ID Constants,  Up: time --- 時刻データへのアクセスと変換

5.16.3.3 Timezone Constants
...........................

 -- データ: time.altzone

     ローカルの夏時間タイムゾーンにおける UTC からの時刻オフセットで、西
     に行くほど増加する、秒で表した値です (ほとんどの西ヨーロッパでは負
     になり、アメリカでは正、イギリスではゼロになります)。‘daylight’ が
     ゼロでないときのみ使用してください。以下の注釈を参照してください。

 -- データ: time.daylight

     DST タイムゾーンが定義されている場合ゼロでない値になります。以下の
     注釈を参照してください。

 -- データ: time.timezone

     (DST でない) ローカルタイムゾーンの UTC からの時刻オフセットで、西
     に行くほど増加する秒で表した値です (ほとんどの西ヨーロッパでは負に
     なり、アメリカでは正、イギリスではゼロになります)。以下の注釈を参照
     してください。

 -- データ: time.tzname

     二つの文字列からなるタプルです。最初の要素は DST でないローカルのタ
     イムゾーン名です。ふたつめの要素は DST のタイムゾーンです。DST のタ
     イムゾーンが定義されていない場合。二つ目の文字列を使うべきではあり
     ません。以下の注釈を参照してください。

     注釈: For the above Timezone constants (*note altzone: 2bb0, *note
     daylight: 2bb1, *note timezone: 2bb2, and *note tzname: 2bb3.), the
     value is determined by the timezone rules in effect at module load
     time or the last time *note tzset(): 2ba6. is called and may be
     incorrect for times in the past.  It is recommended to use the
     *note tm_gmtoff: 2b99. and *note tm_zone: 2b9a. results from *note
     localtime(): 14a2. to obtain timezone information.

参考
....

*note datetime: 28. モジュール

     日付と時刻に対する、よりオブジェクト指向のインターフェースです。

*note locale: 7a. モジュール

     国際化サービスです。ロケールの設定は *note strftime(): 11ba. および
     *note strptime(): 13d4. の多くの書式指定子の解釈に影響を及ぼします
     。

*note calendar: 10. モジュール

     一般的なカレンダーに関する関数群です。*note timegm(): 242b. はこの
     モジュールの *note gmtime(): 1190. の逆を行う関数です。

脚注
....


File: python.info,  Node: argparse --- Parser for command-line options arguments and subcommands,  Next: logging --- Python 用のログ記録手段,  Prev: time --- 時刻データへのアクセスと変換,  Up: 汎用オペレーティングシステムサービス

5.16.4 ‘argparse’ -- Parser for command-line options, arguments and subcommands
-------------------------------------------------------------------------------

Added in version 3.2.

'ソースコード:' Lib/argparse.py(1)

__________________________________________________________________

チュートリアル
..............

このページは API のリファレンス情報が記載しています。*note argparse
チュートリアル: 2bb6. では、コマンドラインの解析についてより優しく説明し
ています。

The ‘argparse’ module makes it easy to write user-friendly command-line
interfaces.  The program defines what arguments it requires, and
‘argparse’ will figure out how to parse those out of *note sys.argv:
1236.  The ‘argparse’ module also automatically generates help and usage
messages.  The module will also issue errors when users give the program
invalid arguments.

The ‘argparse’ module's support for command-line interfaces is built
around an instance of *note argparse.ArgumentParser: 503.  It is a
container for argument specifications and has options that apply to the
parser as whole:

     parser = argparse.ArgumentParser(
                         prog='ProgramName',
                         description='What the program does',
                         epilog='Text at the bottom of help')

*note ArgumentParser.add_argument(): 183. メソッドは各引数の仕様をパーサ
ーに付属させます。このメソッドは位置引数、値を受け取るオプション、機能の
オン／オフを切り替えるフラグをサポートします:

     parser.add_argument('filename')           # positional argument
     parser.add_argument('-c', '--count')      # option that takes a value
     parser.add_argument('-v', '--verbose',
                         action='store_true')  # on/off flag

*note ArgumentParser.parse_args(): 2bb7. メソッドはパーサーを実行し、抽
出したデータを *note argparse.Namespace: 2bb8. オブジェクト内に配置しま
す:

     args = parser.parse_args()
     print(args.filename, args.count, args.verbose)

     注釈: If you're looking for a guide about how to upgrade *note
     optparse: 90. code to ‘argparse’, see *note Upgrading Optparse
     Code: 117e.

* Menu:

* ArgumentParser オブジェクト::
* add_argument() メソッド: add_argument メソッド.
* parse_args() メソッド: parse_args メソッド.
* その他のユーティリティ::
* 例外: 例外<9>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/argparse.py


File: python.info,  Node: ArgumentParser オブジェクト,  Next: add_argument メソッド,  Up: argparse --- Parser for command-line options arguments and subcommands

5.16.4.1 ArgumentParser オブジェクト
....................................

 -- クラス: argparse.ArgumentParser (prog=None, usage=None,
          description=None, epilog=None, parents=[],
          formatter_class=argparse.HelpFormatter, prefix_chars='-',
          fromfile_prefix_chars=None, argument_default=None,
          conflict_handler='error', add_help=True, allow_abbrev=True,
          exit_on_error=True)

     新しい *note ArgumentParser: 503. オブジェクトを生成します。すべて
     の引数はキーワード引数として渡すべきです。各引数についてはあとで詳
     しく説明しますが、簡単に言うと:

        * *note prog: 2bba. - プログラム名(デフォルト:
          ‘os.path.basename(sys.argv[0])’)

        * *note usage: 2bbb. - プログラムの利用方法を記述する文字列 (デ
          フォルト: パーサーに追加された引数から生成されます)

        * *note description: 2bbc. - 引数のヘルプの前に表示されるテキス
          ト (デフォルトはテキストなしです)

        * *note epilog: 2bbd. - 引数のヘルプの後に表示されるテキスト (デ
          フォルトはテキストなしです)

        * *note parents: 2bbe. - *note ArgumentParser: 503. オブジェクト
          のリストで、このオブジェクトの引数が追加されます

        * *note formatter_class: 2bbf. - ヘルプ出力をカスタマイズするた
          めのクラス

        * *note prefix_chars: 2bc0. - オプションの引数の prefix になる文
          字集合 (デフォルト: '-')

        * *note fromfile_prefix_chars: 2bc1. - 追加の引数を読み込むファ
          イルの prefix になる文字集合 (デフォルト: ‘None’)

        * *note argument_default: 2bc2. - 引数のグローバルなデフォルト値
          (デフォルト: ‘None’)

        * *note conflict_handler: 2bc3. - 衝突するオプションを解決する方
          法 (通常は不要)

        * *note add_help: 2bc4. - ‘-h/--help’ オプションをパーサーに追加
          する (デフォルト: ‘True’)

        * *note allow_abbrev: d8c. - 長いオプションが先頭文字列に短縮可
          能 (先頭の文字が一意) である場合に短縮指定を許可する。(デフォ
          ルト: ‘True’)

        * *note exit_on_error: 2bc5. - Determines whether or not
          ‘ArgumentParser’ exits with error info when an error occurs.
          (default: ‘True’)

     バージョン 3.5 で変更: 'allow_abbrev' 引数が追加されました。

     バージョン 3.8 で変更: 以前のバージョンでは、 'allow_abbrev' は、
     ‘-vv’ が ‘-v -v’ と等価になるような、短いフラグのグループ化を無効に
     していました。

     バージョン 3.9 で変更: 'exit_on_error' 引数が追加されました。

以下の節では各オプションの利用方法を説明します。

* Menu:

* prog::
* usage::
* description::
* epilog::
* parents::
* formatter_class::
* prefix_chars::
* fromfile_prefix_chars::
* argument_default::
* allow_abbrev::
* conflict_handler::
* add_help::
* exit_on_error::


File: python.info,  Node: prog,  Next: usage,  Up: ArgumentParser オブジェクト

5.16.4.2 ‘prog’
...............

By default, *note ArgumentParser: 503. calculates the name of the
program to display in help messages depending on the way the Python
interpreter was run:

   * The *note base name: 2721. of ‘sys.argv[0]’ if a file was passed as
     argument.

   * The Python interpreter name followed by ‘sys.argv[0]’ if a
     directory or a zipfile was passed as argument.

   * The Python interpreter name followed by ‘-m’ followed by the module
     or package name if the *note -m: 5ab. option was used.

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 *note ArgumentParser:
503.:

     >>> parser = argparse.ArgumentParser(prog='myprogram')
     >>> parser.print_help()
     usage: myprogram [-h]

     options:
      -h, --help  show this help message and exit

プログラム名は、‘sys.argv[0]’ から取られた場合でも ‘prog=’ 引数で与えら
れた場合でも、ヘルプメッセージ中では ‘%(prog)s’ フォーマット指定子で利用
できます。

     >>> parser = argparse.ArgumentParser(prog='myprogram')
     >>> parser.add_argument('--foo', help='foo of the %(prog)s program')
     >>> parser.print_help()
     usage: myprogram [-h] [--foo FOO]

     options:
      -h, --help  show this help message and exit
      --foo FOO   foo of the myprogram program


File: python.info,  Node: usage,  Next: description,  Prev: prog,  Up: ArgumentParser オブジェクト

5.16.4.3 usage
..............

By default, *note ArgumentParser: 503. calculates the usage message from
the arguments it contains.  The default message can be overridden with
the ‘usage=’ keyword argument:

     >>> parser = argparse.ArgumentParser(prog='PROG', usage='%(prog)s [options]')
     >>> parser.add_argument('--foo', nargs='?', help='foo help')
     >>> parser.add_argument('bar', nargs='+', help='bar help')
     >>> parser.print_help()
     usage: PROG [options]

     positional arguments:
      bar          bar help

     options:
      -h, --help   show this help message and exit
      --foo [FOO]  foo help

‘%(prog)s’ フォーマット指定子を、使用法メッセージ内でプログラム名として
利用できます。


File: python.info,  Node: description,  Next: epilog,  Prev: usage,  Up: ArgumentParser オブジェクト

5.16.4.4 description
....................

Most calls to the *note ArgumentParser: 503. constructor will use the
‘description=’ keyword argument.  This argument gives a brief
description of what the program does and how it works.  In help
messages, the description is displayed between the command-line usage
string and the help messages for the various arguments.

デフォルトでは、説明は与えられたスペースに合わせて折り返されます。この挙
動を変更するには、*note formatter_class: 2bbf. 引数を参照してください。


File: python.info,  Node: epilog,  Next: parents,  Prev: description,  Up: ArgumentParser オブジェクト

5.16.4.5 epilog
...............

いくつかのプログラムは、プログラムについての追加の説明を引数の説明の後に
表示します。このテキストは *note ArgumentParser: 503. の ‘epilog=’ 引数
に指定できます:

     >>> parser = argparse.ArgumentParser(
     ...     description='A foo that bars',
     ...     epilog="And that's how you'd foo a bar")
     >>> parser.print_help()
     usage: argparse.py [-h]

     A foo that bars

     options:
      -h, --help  show this help message and exit

     And that's how you'd foo a bar

*note description: 2bbc. 引数と同じく、‘epilog=’ テキストもデフォルトで
折り返され、*note ArgumentParser: 503. の *note formatter_class: 2bbf. 引
数で動作を調整できます。


File: python.info,  Node: parents,  Next: formatter_class,  Prev: epilog,  Up: ArgumentParser オブジェクト

5.16.4.6 parents
................

ときどき、いくつかのパーサーが共通の引数セットを共有することがあります。
それらの引数を繰り返し定義する代わりに、すべての共通引数を持ったパーサー
を *note ArgumentParser: 503. の ‘parents=’ 引数に渡すことができます。
‘parents=’ 引数は *note ArgumentParser: 503. オブジェクトのリストを受け
取り、すべての位置アクションとオプションのアクションをそれらから集め、そ
のアクションを構築中の *note ArgumentParser: 503. オブジェクトに追加しま
す:

     >>> parent_parser = argparse.ArgumentParser(add_help=False)
     >>> parent_parser.add_argument('--parent', type=int)

     >>> foo_parser = argparse.ArgumentParser(parents=[parent_parser])
     >>> foo_parser.add_argument('foo')
     >>> foo_parser.parse_args(['--parent', '2', 'XXX'])
     Namespace(foo='XXX', parent=2)

     >>> bar_parser = argparse.ArgumentParser(parents=[parent_parser])
     >>> bar_parser.add_argument('--bar')
     >>> bar_parser.parse_args(['--bar', 'YYY'])
     Namespace(bar='YYY', parent=None)

一番親になるパーサーに ‘add_help=False’ を指定していることに注目してくだ
さい。こうしないと、*note ArgumentParser: 503. は2つの ‘-h/--help’ オプ
ションを与えられる (1つは親から、もうひとつは子から) ことになり、エラー
を発生します。

     注釈: ‘parents=’ に渡す前にパーサーを完全に初期化する必要があります
     。子パーサーを作成してから親パーサーを変更した場合、その変更は子パ
     ーサーに反映されません。


File: python.info,  Node: formatter_class,  Next: prefix_chars,  Prev: parents,  Up: ArgumentParser オブジェクト

5.16.4.7 formatter_class
........................

*note ArgumentParser: 503. オブジェクトは代わりのフォーマットクラスを指
定することでヘルプのフォーマットをカスタマイズできます。現在、4つのフォ
ーマットクラスがあります:

 -- クラス: argparse.RawDescriptionHelpFormatter
 -- クラス: argparse.RawTextHelpFormatter
 -- クラス: argparse.ArgumentDefaultsHelpFormatter
 -- クラス: argparse.MetavarTypeHelpFormatter

*note RawDescriptionHelpFormatter: 2bc9. と *note RawTextHelpFormatter:
2bca. はどのようにテキストの説明を表示するかを指定できます。デフォルトで
は *note ArgumentParser: 503. オブジェクトはコマンドラインヘルプの中の
*note description: 2bbc. と *note epilog: 2bbd. を折り返して表示します:

     >>> parser = argparse.ArgumentParser(
     ...     prog='PROG',
     ...     description='''this description
     ...         was indented weird
     ...             but that is okay''',
     ...     epilog='''
     ...             likewise for this epilog whose whitespace will
     ...         be cleaned up and whose words will be wrapped
     ...         across a couple lines''')
     >>> parser.print_help()
     usage: PROG [-h]

     this description was indented weird but that is okay

     options:
      -h, --help  show this help message and exit

     likewise for this epilog whose whitespace will be cleaned up and whose words
     will be wrapped across a couple lines

‘formatter_class=’ に *note RawDescriptionHelpFormatter: 2bc9. を渡した
場合、 *note description: 2bbc. と *note epilog: 2bbd. は整形済みとされ
改行されません:

     >>> parser = argparse.ArgumentParser(
     ...     prog='PROG',
     ...     formatter_class=argparse.RawDescriptionHelpFormatter,
     ...     description=textwrap.dedent('''\
     ...         Please do not mess up this text!
     ...         --------------------------------
     ...             I have indented it
     ...             exactly the way
     ...             I want it
     ...         '''))
     >>> parser.print_help()
     usage: PROG [-h]

     Please do not mess up this text!
     --------------------------------
        I have indented it
        exactly the way
        I want it

     options:
      -h, --help  show this help message and exit

*note RawTextHelpFormatter: 2bca. 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.

*note ArgumentDefaultsHelpFormatter: 1806. は各引数のデフォルト値を自動
的にヘルプに追加します:

     >>> parser = argparse.ArgumentParser(
     ...     prog='PROG',
     ...     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
     >>> parser.add_argument('--foo', type=int, default=42, help='FOO!')
     >>> parser.add_argument('bar', nargs='*', default=[1, 2, 3], help='BAR!')
     >>> parser.print_help()
     usage: PROG [-h] [--foo FOO] [bar ...]

     positional arguments:
      bar         BAR! (default: [1, 2, 3])

     options:
      -h, --help  show this help message and exit
      --foo FOO   FOO! (default: 42)

*note MetavarTypeHelpFormatter: 2bcb. は、各引数の値の表示名に *note
type: 2bcc. 引数の値を使用します (通常は *note dest: 2bcd. の値が使用さ
れます):

     >>> parser = argparse.ArgumentParser(
     ...     prog='PROG',
     ...     formatter_class=argparse.MetavarTypeHelpFormatter)
     >>> parser.add_argument('--foo', type=int)
     >>> parser.add_argument('bar', type=float)
     >>> parser.print_help()
     usage: PROG [-h] [--foo int] float

     positional arguments:
       float

     options:
       -h, --help  show this help message and exit
       --foo int


File: python.info,  Node: prefix_chars,  Next: fromfile_prefix_chars,  Prev: formatter_class,  Up: ArgumentParser オブジェクト

5.16.4.8 prefix_chars
.....................

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 *note ArgumentParser: 503. constructor:

     >>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='-+')
     >>> parser.add_argument('+f')
     >>> parser.add_argument('++bar')
     >>> parser.parse_args('+f X ++bar Y'.split())
     Namespace(bar='Y', f='X')

‘prefix_chars=’ 引数のデフォルトは ‘'-'’ です。‘-’ を含まない文字セット
を指定すると、‘-f/--foo’ オプションが使用できなくなります。


File: python.info,  Node: fromfile_prefix_chars,  Next: argument_default,  Prev: prefix_chars,  Up: ArgumentParser オブジェクト

5.16.4.9 fromfile_prefix_chars
..............................

ときどき、非常に長い引数リストを扱う場合に、その引数リストを毎回コマンド
ラインにタイプする代わりにファイルに置いておきたい場合があります。*note
ArgumentParser: 503. のコンストラクターに ‘fromfile_prefix_chars=’ 引数
が渡された場合、指定された文字のいずれかで始まる引数はファイルとして扱わ
れ、そのファイルに含まれる引数リストに置換されます。例えば:

     >>> with open('args.txt', 'w', encoding=sys.getfilesystemencoding()) as fp:
     ...     fp.write('-f\nbar')
     ...
     >>> parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
     >>> parser.add_argument('-f')
     >>> parser.parse_args(['-f', 'foo', '@args.txt'])
     Namespace(f='bar')

ファイルから読み込まれる引数は、デフォルトでは1行に1つ (ただし、*note
convert_arg_line_to_args(): 2bce. も参照してください) で、コマンドライン
上でファイルを参照する引数があった場所にその引数があったものとして扱われ
ます。このため、上の例では、‘['-f', 'foo', '@args.txt']’ は ‘['-f',
'foo', '-f', 'bar']’ と等価になります。

*note ArgumentParser: 503. uses *note filesystem encoding and error
handler: 505. to read the file containing arguments.

‘fromfile_prefix_chars=’ 引数のデフォルト値は ‘None’ で、引数がファイル
参照として扱われることがないことを意味しています。

バージョン 3.12 で変更: *note ArgumentParser: 503. changed encoding and
errors to read arguments files from default (e.g.  *note
locale.getpreferredencoding(False): 504. and ‘"strict"’) to the *note
filesystem encoding and error handler: 505.  Arguments file should be
encoded in UTF-8 instead of ANSI Codepage on Windows.


File: python.info,  Node: argument_default,  Next: allow_abbrev,  Prev: fromfile_prefix_chars,  Up: ArgumentParser オブジェクト

5.16.4.10 argument_default
..........................

一般的には、引数のデフォルト値は *note add_argument(): 183. メソッドにデ
フォルト値を渡すか、*note set_defaults(): 2bcf. メソッドに名前と値のペア
を渡すことで指定します。しかしまれに、1つのパーサー全体に適用されるデフ
ォルト引数が便利なことがあります。これを行うには、 *note ArgumentParser:
503. に ‘argument_default=’ キーワード引数を渡します。例えば、全体で
*note parse_args(): 2bb7. メソッド呼び出しの属性の生成を抑制するには、
‘argument_default=SUPPRESS’ を指定します:

     >>> parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)
     >>> parser.add_argument('--foo')
     >>> parser.add_argument('bar', nargs='?')
     >>> parser.parse_args(['--foo', '1', 'BAR'])
     Namespace(bar='BAR', foo='1')
     >>> parser.parse_args([])
     Namespace()


File: python.info,  Node: allow_abbrev,  Next: conflict_handler,  Prev: argument_default,  Up: ArgumentParser オブジェクト

5.16.4.11 allow_abbrev
......................

通常、*note ArgumentParser: 503. の *note parse_args(): 2bb7. に引数のリ
ストを渡すとき、長いオプションは *note 短縮しても認識されます: d8d.。

この機能は、‘allow_abbrev’ に ‘False’ を指定することで無効にできます:

     >>> parser = argparse.ArgumentParser(prog='PROG', allow_abbrev=False)
     >>> parser.add_argument('--foobar', action='store_true')
     >>> parser.add_argument('--foonley', action='store_false')
     >>> parser.parse_args(['--foon'])
     usage: PROG [-h] [--foobar] [--foonley]
     PROG: error: unrecognized arguments: --foon

Added in version 3.5.


File: python.info,  Node: conflict_handler,  Next: add_help,  Prev: allow_abbrev,  Up: ArgumentParser オブジェクト

5.16.4.12 conflict_handler
..........................

*note ArgumentParser: 503. オブジェクトは同じオプション文字列に対して複
数のアクションを許可していません。 デフォルトでは、*note ArgumentParser:
503. オブジェクトは、すでに利用されているオプション文字列を使って新しい
引数をつくろうとしたときに例外を送出します:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-f', '--foo', help='old foo help')
     >>> parser.add_argument('--foo', help='new foo help')
     Traceback (most recent call last):
      ..
     ArgumentError: argument --foo: conflicting option string(s): --foo

ときどき (例えば *note parents: 2bbe. を利用する場合など)、古い引数を同
じオプション文字列で上書きするほうが便利な場合があります。この動作をする
には、*note ArgumentParser: 503. の ‘conflict_handler=’ 引数に
‘'resolve'’ を渡します:

     >>> parser = argparse.ArgumentParser(prog='PROG', conflict_handler='resolve')
     >>> parser.add_argument('-f', '--foo', help='old foo help')
     >>> parser.add_argument('--foo', help='new foo help')
     >>> parser.print_help()
     usage: PROG [-h] [-f FOO] [--foo FOO]

     options:
      -h, --help  show this help message and exit
      -f FOO      old foo help
      --foo FOO   new foo help

*note ArgumentParser: 503. オブジェクトは、すべてのオプション文字列が上
書きされた場合にだけアクションを削除することに注目してください。上の例で
は、 ‘--foo’ オプション文字列だけが上書きされているので、古い ‘-f/--foo’
アクションは ‘-f’ アクションとして残っています。


File: python.info,  Node: add_help,  Next: exit_on_error,  Prev: conflict_handler,  Up: ArgumentParser オブジェクト

5.16.4.13 add_help
..................

By default, *note ArgumentParser: 503. objects add an option which
simply displays the parser's help message.  If ‘-h’ or ‘--help’ is
supplied at the command line, the ‘ArgumentParser’ help will be printed.

必要に応じて、この help オプションを無効にする場合があります。これは
*note ArgumentParser: 503. の ‘add_help=’ 引数に ‘False’ を渡すことで可
能です:

     >>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)
     >>> parser.add_argument('--foo', help='foo help')
     >>> parser.print_help()
     usage: PROG [--foo FOO]

     options:
      --foo FOO  foo help

ヘルプオプションは通常 ‘-h/--help’ です。例外は ‘prefix_chars=’ が指定さ
れてその中に ‘-’ が無かった場合で、その場合は ‘-h’ と ‘--help’ は有効な
オプションではありません。この場合、‘prefix_chars’ の最初の文字がヘルプ
オプションの接頭辞として利用されます:

     >>> parser = argparse.ArgumentParser(prog='PROG', prefix_chars='+/')
     >>> parser.print_help()
     usage: PROG [+h]

     options:
       +h, ++help  show this help message and exit


File: python.info,  Node: exit_on_error,  Prev: add_help,  Up: ArgumentParser オブジェクト

5.16.4.14 exit_on_error
.......................

Normally, when you pass an invalid argument list to the *note
parse_args(): 2bb7. method of an *note ArgumentParser: 503, it will
print a 'message' to *note sys.stderr: 907. and exit with a status code
of 2.

もしエラーを例外としてプログラム内でキャッチしたい場合は、
‘exit_on_error’ を ‘False’ に設定してください:

     >>> parser = argparse.ArgumentParser(exit_on_error=False)
     >>> parser.add_argument('--integers', type=int)
     _StoreAction(option_strings=['--integers'], dest='integers', nargs=None, const=None, default=None, type=<class 'int'>, choices=None, help=None, metavar=None)
     >>> try:
     ...     parser.parse_args('--integers a'.split())
     ... except argparse.ArgumentError:
     ...     print('Catching an argumentError')
     ...
     Catching an argumentError

Added in version 3.9.


File: python.info,  Node: add_argument メソッド,  Next: parse_args メソッド,  Prev: ArgumentParser オブジェクト,  Up: argparse --- Parser for command-line options arguments and subcommands

5.16.4.15 add_argument() メソッド
.................................

 -- メソッド: ArgumentParser.add_argument (name or flags..., *[,
          action][, nargs][, const][, default][, type][, choices][,
          required][, help][, metavar][, dest][, deprecated])

     1つのコマンドライン引数がどう解析されるかを定義します。各引数につい
     ての詳細は後述しますが、簡単に言うと:

        * *note name or flags: 2bd2. - Either a name or a list of option
          strings, e.g.  ‘'foo'’ or ‘'-f', '--foo'’.

        * *note action: 2bd3. - コマンドラインにこの引数があったときのア
          クション。

        * *note nargs: 1511. - 受け取るべきコマンドライン引数の数。

        * *note const: 2bd4. - 一部の *note action: 2bd3. と *note
          nargs: 1511. の組み合わせで利用される定数。

        * *note default: 2bd5. - コマンドラインに対応する引数が存在せず
          、さらに namespace オブジェクトにも存在しない場合に利用される
          値。

        * *note type: 2bcc. - コマンドライン引数が変換されるべき型。

        * *note choices: 150e. - 引数として許される値のシーケンス。

        * *note required: 2bd6. - コマンドラインオプションが省略可能かど
          うか (オプション引数のみ)。

        * *note help: 2bd7. - 引数が何なのかを示す簡潔な説明。

        * *note metavar: 2bd8. - 使用法メッセージの中で使われる引数の名
          前。

        * *note dest: 2bcd. - *note parse_args(): 2bb7. が返すオブジェク
          トに追加される属性名。

        * *note deprecated: 2bd9. - Whether or not use of the argument
          is deprecated.

以下の節では各オプションの利用方法を説明します。

* Menu:

* name または flags::
* action::
* nargs::
* const::
* default::
* type::
* choices::
* required::
* help::
* metavar::
* dest::
* deprecated::
* Action クラス::


File: python.info,  Node: name または flags,  Next: action,  Up: add_argument メソッド

5.16.4.16 name または flags
...........................

*note add_argument(): 183. メソッドは、指定されている引数が ‘-f’ や
‘--foo’ のようなオプション引数なのか、ファイル名リストなどの位置引数なの
かを知る必要があります。 そのため、 *note add_argument(): 183. に初めに
渡される引数は、一連のフラグか、単一の引数名のどちらかになります。

たとえば、オプション引数は次のように作成します:

     >>> parser.add_argument('-f', '--foo')

一方、位置引数は次のように作成します:

     >>> parser.add_argument('bar')

*note parse_args(): 2bb7. が呼ばれたとき、オプション引数は接頭辞 ‘-’ に
より識別され、それ以外の引数は位置引数として扱われます:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-f', '--foo')
     >>> parser.add_argument('bar')
     >>> parser.parse_args(['BAR'])
     Namespace(bar='BAR', foo=None)
     >>> parser.parse_args(['BAR', '--foo', 'FOO'])
     Namespace(bar='BAR', foo='FOO')
     >>> parser.parse_args(['--foo', 'FOO'])
     usage: PROG [-h] [-f FOO] bar
     PROG: error: the following arguments are required: bar


File: python.info,  Node: action,  Next: nargs,  Prev: name または flags,  Up: add_argument メソッド

5.16.4.17 action
................

*note ArgumentParser: 503. オブジェクトはコマンドライン引数にアクション
を割り当てます。このアクションは、割り当てられたコマンドライン引数に関し
てどんな処理でもできますが、ほとんどのアクションは単に *note
parse_args(): 2bb7. が返すオブジェクトに属性を追加するだけです。‘action’
キーワード引数は、コマンドライン引数がどう処理されるかを指定します。提供
されているアクションは:

   * ‘'store'’ - This just stores the argument's value.  This is the
     default action.

   * ‘'store_const'’ - このアクションは *note const: 2bd4. キーワード引
     数で指定された値を格納します。*note const: 2bd4. キーワード引数のデ
     フォルト値は ‘None’ であることに注意してください。‘'store_const'’ ア
     クションは、何かの種類のフラグを指定するオプション引数によく使われ
     ます。例えば:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', action='store_const', const=42)
          >>> parser.parse_args(['--foo'])
          Namespace(foo=42)

   * ‘'store_true'’ and ‘'store_false'’ - These are special cases of
     ‘'store_const'’ used for storing the values ‘True’ and ‘False’
     respectively.  In addition, they create default values of ‘False’
     and ‘True’ respectively:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', action='store_true')
          >>> parser.add_argument('--bar', action='store_false')
          >>> parser.add_argument('--baz', action='store_false')
          >>> parser.parse_args('--foo --bar'.split())
          Namespace(foo=True, bar=False, baz=True)

   * ‘'append'’ - このアクションはリストを格納し、それぞれの引数として与
     えられた値をリストに追加します。これは複数回指定可能なオプション引
     数に対して有用です。デフォルト値が空でない場合、デフォルト値は常に
     パースされたリストに含まれ、コマンドラインで指定した値はデフォルト
     値の後に追加されます。使用例:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', action='append')
          >>> parser.parse_args('--foo 1 --foo 2'.split())
          Namespace(foo=['1', '2'])

   * ‘'append_const'’ - このアクションはリストを格納して、*note const:
     2bd4. キーワード引数に与えられた値をそのリストに追加します。*note
     const: 2bd4. キーワード引数のデフォルト値は ‘None’ であることに注意
     してください。‘'append_const'’ アクションは、定数を同じリストに複数
     回格納する場合に便利です。例えば:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--str', dest='types', action='append_const', const=str)
          >>> parser.add_argument('--int', dest='types', action='append_const', const=int)
          >>> parser.parse_args('--str --int'.split())
          Namespace(types=[<class 'str'>, <class 'int'>])

   * ‘'extend'’ - This stores a list and appends each item from the
     multi-value argument list to it.  The ‘'extend'’ action is
     typically used with the *note nargs: 1511. keyword argument value
     ‘'+'’ or ‘'*'’.  Note that when *note nargs: 1511. is ‘None’ (the
     default) or ‘'?'’, each character of the argument string will be
     appended to the list.  Example usage:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument("--foo", action="extend", nargs="+", type=str)
          >>> parser.parse_args(["--foo", "f1", "--foo", "f2", "f3", "f4"])
          Namespace(foo=['f1', 'f2', 'f3', 'f4'])

     Added in version 3.8.

   * ‘'count'’ - このアクションはキーワード引数の数を数えます。例えば、
     verboseレベルを上げるのに役立ちます:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--verbose', '-v', action='count', default=0)
          >>> parser.parse_args(['-vvv'])
          Namespace(verbose=3)

     'default' は明示的に '0' と指定されない場合は ‘None’ であることに注
     意してください。

   * ‘'help'’ - このアクションは現在のパーサー中のすべてのオプションのヘ
     ルプメッセージを表示し、終了します。出力の生成方法の詳細については
     *note ArgumentParser: 503. を参照してください。

   * ‘'version'’ - このアクションは *note add_argument(): 183. の呼び出
     しに ‘version=’ キーワード引数を期待します。指定されたときはバージ
     ョン情報を表示して終了します:

          >>> import argparse
          >>> parser = argparse.ArgumentParser(prog='PROG')
          >>> parser.add_argument('--version', action='version', version='%(prog)s 2.0')
          >>> parser.parse_args(['--version'])
          PROG 2.0

Only actions that consume command-line arguments (e.g.  ‘'store'’,
‘'append'’ or ‘'extend'’) can be used with positional arguments.

 -- クラス: argparse.BooleanOptionalAction

     You may also specify an arbitrary action by passing an *note
     Action: 176a. subclass or other object that implements the same
     interface.  The ‘BooleanOptionalAction’ is available in ‘argparse’
     and adds support for boolean actions such as ‘--foo’ and
     ‘--no-foo’:

          >>> import argparse
          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', action=argparse.BooleanOptionalAction)
          >>> parser.parse_args(['--no-foo'])
          Namespace(foo=False)

     Added in version 3.9.

The recommended way to create a custom action is to extend *note Action:
176a, overriding the ‘__call__()’ method and optionally the ‘__init__()’
and ‘format_usage()’ methods.

カスタムアクションの例です:

     >>> class FooAction(argparse.Action):
     ...     def __init__(self, option_strings, dest, nargs=None, **kwargs):
     ...         if nargs is not None:
     ...             raise ValueError("nargs not allowed")
     ...         super().__init__(option_strings, dest, **kwargs)
     ...     def __call__(self, parser, namespace, values, option_string=None):
     ...         print('%r %r %r' % (namespace, values, option_string))
     ...         setattr(namespace, self.dest, values)
     ...
     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo', action=FooAction)
     >>> parser.add_argument('bar', action=FooAction)
     >>> args = parser.parse_args('1 --foo 2'.split())
     Namespace(bar=None, foo=None) '1' None
     Namespace(bar='1', foo=None) '2' '--foo'
     >>> args
     Namespace(bar='1', foo='2')

詳細は *note Action: 176a. を参照してください。


File: python.info,  Node: nargs,  Next: const,  Prev: action,  Up: add_argument メソッド

5.16.4.18 nargs
...............

*note ArgumentParser: 503. objects usually associate a single
command-line argument with a single action to be taken.  The ‘nargs’
keyword argument associates a different number of command-line arguments
with a single action.  See also *note 多義性のある引数の指定: 2bdd.  The
supported values are:

   * ‘N’ (整数) - ‘N’ 個の引数がコマンドラインから集められ、リストに格納
     されます。例えば:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', nargs=2)
          >>> parser.add_argument('bar', nargs=1)
          >>> parser.parse_args('c --foo a b'.split())
          Namespace(bar=['c'], foo=['a', 'b'])

     ‘nargs=1’ は1要素のリストを作ることに注意してください。これはデフォ
     ルトの、要素がそのまま属性になる動作とは異なります。

   * ‘'?'’ - 可能なら1つの引数がコマンドラインから取られ、1つのアイテム
     を作ります。コマンドライン引数が存在しない場合、*note default:
     2bd5. の値が生成されます。オプション引数の場合、さらにオプション引
     数が指定され、その後にコマンドライン引数がないというケースもありえ
     ます。この場合は *note const: 2bd4. の値が生成されます。この動作の
     例です:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', nargs='?', const='c', default='d')
          >>> parser.add_argument('bar', nargs='?', default='d')
          >>> parser.parse_args(['XX', '--foo', 'YY'])
          Namespace(bar='XX', foo='YY')
          >>> parser.parse_args(['XX', '--foo'])
          Namespace(bar='XX', foo='c')
          >>> parser.parse_args([])
          Namespace(bar='d', foo='d')

     ‘nargs='?'’ のよくある利用例の1つは、入出力ファイルの指定オプション
     です:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),
          ...                     default=sys.stdin)
          >>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
          ...                     default=sys.stdout)
          >>> parser.parse_args(['input.txt', 'output.txt'])
          Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,
                    outfile=<_io.TextIOWrapper name='output.txt' encoding='UTF-8'>)
          >>> parser.parse_args([])
          Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
                    outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)

   * ‘'*'’ - すべてのコマンドライン引数がリストに集められます。複数の位
     置引数が ‘nargs='*'’ を持つことにあまり意味はありませんが、複数のオ
     プション引数が ‘nargs='*'’ を持つことはありえます。例えば:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', nargs='*')
          >>> parser.add_argument('--bar', nargs='*')
          >>> parser.add_argument('baz', nargs='*')
          >>> parser.parse_args('a b --foo x y --bar 1 2'.split())
          Namespace(bar=['1', '2'], baz=['a', 'b'], foo=['x', 'y'])

   * ‘'+'’ - ‘'*'’ と同じように、すべてのコマンドライン引数をリストに集
     めます。加えて、最低でも1つのコマンドライン引数が存在しない場合にエ
     ラーメッセージを生成します。例えば:

          >>> parser = argparse.ArgumentParser(prog='PROG')
          >>> parser.add_argument('foo', nargs='+')
          >>> parser.parse_args(['a', 'b'])
          Namespace(foo=['a', 'b'])
          >>> parser.parse_args([])
          usage: PROG [-h] foo [foo ...]
          PROG: error: the following arguments are required: foo

If the ‘nargs’ keyword argument is not provided, the number of arguments
consumed is determined by the *note action: 2bd3.  Generally this means
a single command-line argument will be consumed and a single item (not a
list) will be produced.  Actions that do not consume command-line
arguments (e.g.  ‘'store_const'’) set ‘nargs=0’.


File: python.info,  Node: const,  Next: default,  Prev: nargs,  Up: add_argument メソッド

5.16.4.19 const
...............

*note add_argument(): 183. の ‘const’ 引数は、コマンドライン引数から読み
込まれないけれども *note ArgumentParser: 503. のいくつかのアクションで必
要とされる値のために使われます。この引数のよくある2つの使用法は:

   * *note add_argument(): 183. が ‘action='store_const'’ か
     ‘action='append_const'’ で呼び出されたとき、これらのアクションは
     ‘const’ の値を *note parse_args(): 2bb7. が返すオブジェクトの属性に
     追加します。サンプルは *note action: 2bd3. の説明を参照してください
     。‘const’ が *note add_argument(): 183. に与えられなければ、‘None’
     のデフォルト値を受け取ります。

   * *note add_argument(): 183. がオプション文字列 (‘-f’ や ‘--foo’) と
     ‘nargs='?'’ で呼び出された場合。この場合0個か1つのコマンドライン引
     数を取るオプション引数が作られます。オプション引数にコマンドライン
     引数が続かなかった場合、代わりに ‘const’ の値が ‘None’ であると見な
     されます。サンプルは *note nargs: 1511. の説明を参照してください。

バージョン 3.11 で変更: ‘action='append_const'’ や
‘action='store_const'’ の場合も含め、デフォルトでは ‘const=None’ です。


File: python.info,  Node: default,  Next: type,  Prev: const,  Up: add_argument メソッド

5.16.4.20 default
.................

すべてのオプション引数といくつかの位置引数はコマンドライン上で省略される
ことがあります。 *note add_argument(): 183. の ‘default’ キーワード引数
(デフォルト: ‘None’) は、コマンドライン引数が存在しなかった場合に利用す
る値を指定します。オプション引数では、オプション文字列がコマンドライン上
に存在しなかったときに ‘default’ の値が利用されます:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo', default=42)
     >>> parser.parse_args(['--foo', '2'])
     Namespace(foo='2')
     >>> parser.parse_args([])
     Namespace(foo=42)

If the target namespace already has an attribute set, the action
'default' will not overwrite it:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo', default=42)
     >>> parser.parse_args([], namespace=argparse.Namespace(foo=101))
     Namespace(foo=101)

‘default’ の値が文字列の場合、パーサーは値をコマンドライン引数のように解
析します。具体的には、パーサーは返り値 *note Namespace: 2bb8. の属性を設
定する前に、*note type: 2bcc. 変換引数が与えられていればそれらを適用しま
す。そうでない場合、パーサーは値をそのまま使用します:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--length', default='10', type=int)
     >>> parser.add_argument('--width', default=10.5, type=int)
     >>> parser.parse_args()
     Namespace(length=10, width=10.5)

*note nargs: 1511. が ‘?’ か ‘*’ である位置引数では、コマンドライン引数
が指定されなかった場合 ‘default’ の値が使われます。例えば:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('foo', nargs='?', default=42)
     >>> parser.parse_args(['a'])
     Namespace(foo='a')
     >>> parser.parse_args([])
     Namespace(foo=42)

For *note required: 2bd6. arguments, the ‘default’ value is ignored.
For example, this applies to positional arguments with *note nargs:
1511. values other than ‘?’ or ‘*’, or optional arguments marked as
‘required=True’.

‘default=argparse.SUPPRESS’ を渡すと、コマンドライン引数が存在しないとき
に属性の追加をしなくなります:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo', default=argparse.SUPPRESS)
     >>> parser.parse_args([])
     Namespace()
     >>> parser.parse_args(['--foo', '1'])
     Namespace(foo='1')


File: python.info,  Node: type,  Next: choices,  Prev: default,  Up: add_argument メソッド

5.16.4.21 type
..............

デフォルトでは、パーサーはコマンドライン引数を単なる文字列として読み込み
ます。しかし、それらの文字列を *note float: 2ce, *note int: 238. など別
の型として扱うべき事がよくあります。*note add_argument(): 183. の ‘type’
キーワード引数に指定する type converter により、必要な型チェックと型変換
を行うことができます。

もし *note type: 2bcc. キーワードが *note default: 2bd5. キーワードとと
もに使用された場合、*note default: 2bd5. の値が文字列のときのみ、type
converter による変換などが行われます。

‘type’ キーワードの引数として、単一の文字列を受け取るような任意の呼び出
しオブジェクト (callable) が使用できます。もし呼び出しが *note
ArgumentTypeError: 2be1, *note TypeError: 502, または *note ValueError:
1e3. 型の例外を送出した場合は、parser がそれをキャッチして適切なエラーメ
ッセージが表示されます。それ以外の型の例外は処理されません。

一般的なビルトインデータ型や関数を ‘type’ 引数の値として直接指定できます
:

     import argparse
     import pathlib

     parser = argparse.ArgumentParser()
     parser.add_argument('count', type=int)
     parser.add_argument('distance', type=float)
     parser.add_argument('street', type=ascii)
     parser.add_argument('code_point', type=ord)
     parser.add_argument('dest_file', type=argparse.FileType('w', encoding='latin-1'))
     parser.add_argument('datapath', type=pathlib.Path)

ユーザが定義した関数も使用できます:

     >>> def hyphenated(string):
     ...     return '-'.join([word[:4] for word in string.casefold().split()])
     ...
     >>> parser = argparse.ArgumentParser()
     >>> _ = parser.add_argument('short_title', type=hyphenated)
     >>> parser.parse_args(['"The Tale of Two Cities"'])
     Namespace(short_title='"the-tale-of-two-citi')

Type converter として *note bool(): 434. 関数を使用することは推奨されま
せん。なぜなら、これは空文字列を ‘False’ に、それ以外の全てを ‘True’ に
変換しますが、これはおそらく望まれる動作ではないからです (訳注: 文字列
‘'false'’ を ‘False’ に変換してくれたりはしません)。

一般論として、‘type’ キーワードに指定するものは、せいぜい上記の3種類の例
外を発生するくらいの、お手軽な変換に限るべきです。より複雑な
(interesting) エラー処理、またはリソース管理を伴うものは、引数を解析した
あとに別個の処理として行うべきです。

たとえば、JSON または YAML からの変換は複雑なエラーケースを持つので、
‘type’ がサポートする以上のエラー表示を必要とするでしょう。(JSON デコー
ダが発生しうる) *note JSONDecodeError: ded. は適切に整形されて表示されま
せん。また、*note FileNotFoundError: e8f. が発生しても parser は何も処理
しません。

Even *note FileType: ee7. has its limitations for use with the ‘type’
keyword.  If one argument uses *note FileType: ee7. and then a
subsequent argument fails, an error is reported but the file is not
automatically closed.  In this case, it would be better to wait until
after the parser has run and then use the *note with: 59c.-statement to
manage the files.

なお、引数が、あらかじめ決められた値の候補のいずれかに一致するかをチェッ
クしたいだけの場合には、代わりに *note choices: 150e. キーワードの使用を
検討してください。


File: python.info,  Node: choices,  Next: required,  Prev: type,  Up: add_argument メソッド

5.16.4.22 choices
.................

コマンドライン引数をいくつかの選択肢の中から選ばせたい場合があります。 こ
れは *note add_argument(): 183. に シーケンスオブジェクトを 'choices' キ
ーワード引数として渡すことで可能です。コマンドラインを解析するとき、引数
の値がチェックされ、その値が選択肢の中に含まれていない場合はエラーメッセ
ージを表示します:

     >>> parser = argparse.ArgumentParser(prog='game.py')
     >>> parser.add_argument('move', choices=['rock', 'paper', 'scissors'])
     >>> parser.parse_args(['rock'])
     Namespace(move='rock')
     >>> parser.parse_args(['fire'])
     usage: game.py [-h] {rock,paper,scissors}
     game.py: error: argument move: invalid choice: 'fire' (choose from 'rock',
     'paper', 'scissors')

Note that inclusion in the 'choices' sequence is checked after any *note
type: 2bcc. conversions have been performed, so the type of the objects
in the 'choices' sequence should match the *note type: 2bcc. specified.

任意のシーケンスを 'choices' に渡すことができます。すなわち、*note list:
5dc. オブジェクト、 *note tuple: 349. オブジェクト、カスタムシーケンスは
すべてサポートされています。

ただし、*note enum.Enum: 5fc. を渡すことは推奨されません。使用方法、ヘル
プ、エラーメッセージなどでどのように表示されるかを制御することが難いから
です。

ヘルプテキストにおいて整形された choices の値は、通常 'dest' から生成さ
れるデフォルトの 'metavar' に優先します。ユーザーは 'dest' パラメータを
目にすることがないため、この振る舞いは基本的には望ましいものです。もしこ
の表示方法が望ましくない場合 (おそらく多くの選択肢がある場合など) は、
*note metavar: 2bd8. を明示的に指定してください。


File: python.info,  Node: required,  Next: help,  Prev: choices,  Up: add_argument メソッド

5.16.4.23 required
..................

In general, the ‘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 *note add_argument(): 183.:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo', required=True)
     >>> parser.parse_args(['--foo', 'BAR'])
     Namespace(foo='BAR')
     >>> parser.parse_args([])
     usage: [-h] --foo FOO
     : error: the following arguments are required: --foo

上の例のように、引数が ‘required’ と指定されると、*note parse_args():
2bb7. はそのフラグがコマンドラインに存在しないときにエラーを表示します。

     注釈: ユーザーは、通常 'フラグ' の指定は '任意' であると認識してい
     るため、必須にするのは一般的には悪いやり方で、できる限り避けるべき
     です。


File: python.info,  Node: help,  Next: metavar,  Prev: required,  Up: add_argument メソッド

5.16.4.24 help
..............

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.

‘help’ 文字列には、プログラム名や引数の *note default: 2bd5. などを繰り
返し記述するのを避けるためのフォーマット指定子を含めることができます。利
用できる指定子には、プログラム名 ‘%(prog)s’ と、 ‘%(default)s’ や
‘%(type)s’ など *note add_argument(): 183. のキーワード引数の多くが含ま
れます:

     >>> parser = argparse.ArgumentParser(prog='frobble')
     >>> parser.add_argument('bar', nargs='?', type=int, default=42,
     ...                     help='the bar to %(prog)s (default: %(default)s)')
     >>> parser.print_help()
     usage: frobble [-h] [bar]

     positional arguments:
      bar     the bar to frobble (default: 42)

     options:
      -h, --help  show this help message and exit

ヘルプ文字列は %-フォーマットをサポートしているので、ヘルプ文字列内にリ
テラル ‘%’ を表示したい場合は ‘%%’ のようにエスケープしなければなりませ
ん。

‘argparse’ supports silencing the help entry for certain options, by
setting the ‘help’ value to ‘argparse.SUPPRESS’:

     >>> parser = argparse.ArgumentParser(prog='frobble')
     >>> parser.add_argument('--foo', help=argparse.SUPPRESS)
     >>> parser.print_help()
     usage: frobble [-h]

     options:
       -h, --help  show this help message and exit


File: python.info,  Node: metavar,  Next: dest,  Prev: help,  Up: add_argument メソッド

5.16.4.25 metavar
.................

When *note ArgumentParser: 503. generates help messages, it needs some
way to refer to each expected argument.  By default, ‘ArgumentParser’
objects use the *note dest: 2bcd. value as the "name" of each object.
By default, for positional argument actions, the *note dest: 2bcd. value
is used directly, and for optional argument actions, the *note dest:
2bcd. value is uppercased.  So, a single positional argument with
‘dest='bar'’ will be referred to as ‘bar’.  A single optional argument
‘--foo’ that should be followed by a single command-line argument will
be referred to as ‘FOO’.  An example:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo')
     >>> parser.add_argument('bar')
     >>> parser.parse_args('X --foo Y'.split())
     Namespace(bar='X', foo='Y')
     >>> parser.print_help()
     usage:  [-h] [--foo FOO] bar

     positional arguments:
      bar

     options:
      -h, --help  show this help message and exit
      --foo FOO

代わりの名前を、‘metavar’ として指定できます:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo', metavar='YYY')
     >>> parser.add_argument('bar', metavar='XXX')
     >>> parser.parse_args('X --foo Y'.split())
     Namespace(bar='X', foo='Y')
     >>> parser.print_help()
     usage:  [-h] [--foo YYY] XXX

     positional arguments:
      XXX

     options:
      -h, --help  show this help message and exit
      --foo YYY

‘metavar’ は '表示される' 名前だけを変更することに注意してください。
*note parse_args(): 2bb7. の返すオブジェクトの属性名は *note dest: 2bcd.
の値のままです。

‘nargs’ を指定した場合、metavar が複数回利用されるかもしれません。
‘metavar’ にタプルを渡すと、各引数に対して異なる名前を指定できます:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-x', nargs=2)
     >>> parser.add_argument('--foo', nargs=2, metavar=('bar', 'baz'))
     >>> parser.print_help()
     usage: PROG [-h] [-x X X] [--foo bar baz]

     options:
      -h, --help     show this help message and exit
      -x X X
      --foo bar baz


File: python.info,  Node: dest,  Next: deprecated,  Prev: metavar,  Up: add_argument メソッド

5.16.4.26 dest
..............

ほとんどの *note ArgumentParser: 503. のアクションは *note parse_args():
2bb7. が返すオブジェクトに対する属性として値を追加します。この属性の名前
は *note add_argument(): 183. の ‘dest’ キーワード引数によって決定されま
す。位置引数のアクションについては、 ‘dest’ は通常 *note add_argument():
183. の第一引数として渡します:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('bar')
     >>> parser.parse_args(['XXX'])
     Namespace(bar='XXX')

オプション引数のアクションについては、 ‘dest’ の値は通常オプション文字列
から生成されます。 *note ArgumentParser: 503. は最初の長いオプション文字
列を選択し、先頭の ‘--’ を除去することで ‘dest’ の値を生成します。長いオ
プション文字列が指定されていない場合、最初の短いオプション文字列から先頭
の ‘-’ 文字を除去することで ‘dest’ を生成します。先頭以外のすべての ‘-’
文字は、妥当な属性名になるように ‘_’ 文字へ変換されます。次の例はこの動
作を示しています:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('-f', '--foo-bar', '--foo')
     >>> parser.add_argument('-x', '-y')
     >>> parser.parse_args('-f 1 -x 2'.split())
     Namespace(foo_bar='1', x='2')
     >>> parser.parse_args('--foo 1 -y 2'.split())
     Namespace(foo_bar='1', x='2')

‘dest’ にカスタムの属性名を与えることも可能です:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument('--foo', dest='bar')
     >>> parser.parse_args('--foo XXX'.split())
     Namespace(bar='XXX')


File: python.info,  Node: deprecated,  Next: Action クラス,  Prev: dest,  Up: add_argument メソッド

5.16.4.27 deprecated
....................

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 arguments are deprecated and will be removed.  The ‘deprecated’
keyword argument of *note add_argument(): 183, which defaults to
‘False’, specifies if the argument is deprecated and will be removed in
the future.  For arguments, if ‘deprecated’ is ‘True’, then a warning
will be printed to *note sys.stderr: 907. when the argument is used:

     >>> import argparse
     >>> parser = argparse.ArgumentParser(prog='snake.py')
     >>> parser.add_argument('--legs', default=0, type=int, deprecated=True)
     >>> parser.parse_args([])
     Namespace(legs=0)
     >>> parser.parse_args(['--legs', '4'])
     snake.py: warning: option '--legs' is deprecated
     Namespace(legs=4)

Added in version 3.13.


File: python.info,  Node: Action クラス,  Prev: deprecated,  Up: add_argument メソッド

5.16.4.28 Action クラス
.......................

‘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 *note
add_argument(): 183.

 -- クラス: argparse.Action (option_strings, dest, nargs=None,
          const=None, default=None, type=None, choices=None,
          required=False, help=None, metavar=None)

     ‘Action’ objects are used by an *note ArgumentParser: 503. to
     represent the information needed to parse a single argument from
     one or more strings from the command line.  The ‘Action’ class must
     accept the two positional arguments plus any keyword arguments
     passed to *note ArgumentParser.add_argument(): 183. except for the
     ‘action’ itself.

     Instances of ‘Action’ (or return value of any callable to the
     ‘action’ parameter) should have attributes ‘dest’,
     ‘option_strings’, ‘default’, ‘type’, ‘required’, ‘help’, etc.
     defined.  The easiest way to ensure these attributes are defined is
     to call ‘Action.__init__()’.

      -- メソッド: __call__ (parser, namespace, values,
               option_string=None)

          ‘Action’ instances should be callable, so subclasses must
          override the ‘__call__()’ method, which should accept four
          parameters:

             * 'parser' - The *note ArgumentParser: 503. object which
               contains this action.

             * 'namespace' - The *note Namespace: 2bb8. object that will
               be returned by *note parse_args(): 2bb7.  Most actions
               add an attribute to this object using *note setattr():
               20bd.

             * 'values' - The associated command-line arguments, with
               any type conversions applied.  Type conversions are
               specified with the *note type: 2bcc. keyword argument to
               *note add_argument(): 183.

             * '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.

          The ‘__call__()’ method may perform arbitrary actions, but
          will typically set attributes on the ‘namespace’ based on
          ‘dest’ and ‘values’.

      -- メソッド: format_usage ()

          ‘Action’ subclasses can define a ‘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.


File: python.info,  Node: parse_args メソッド,  Next: その他のユーティリティ,  Prev: add_argument メソッド,  Up: argparse --- Parser for command-line options arguments and subcommands

5.16.4.29 parse_args() メソッド
...............................

 -- メソッド: ArgumentParser.parse_args (args=None, namespace=None)

     引数の文字列をオブジェクトに変換し、namespace オブジェクトの属性に
     代入します。結果の namespace オブジェクトを返します。

     Previous calls to *note add_argument(): 183. determine exactly what
     objects are created and how they are assigned.  See the
     documentation for ‘add_argument()’ for details.

        * *note args: 2bec. - 解析する文字列のリスト。デフォルトでは
          *note sys.argv: 1236. から取得されます。

        * *note namespace: 2bed. - 属性を代入するオブジェクト。デフォル
          トでは、新しい空の *note Namespace: 2bb8. オブジェクトです。

* Menu:

* オプション値の文法::
* 不正な引数::
* - を含む引数::
* 引数の短縮形 (先頭文字でのマッチング): 引数の短縮形 先頭文字でのマッチング.
* sys.argv 以外: sys argv 以外.
* Namespace オブジェクト::


File: python.info,  Node: オプション値の文法,  Next: 不正な引数,  Up: parse_args メソッド

5.16.4.30 オプション値の文法
............................

*note parse_args(): 2bb7. メソッドは、オプションの値がある場合、そのオプ
ションの値の指定に複数の方法をサポートしています。もっとも単純な場合には
、オプションとその値は次のように2つの別々の引数として渡されます:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-x')
     >>> parser.add_argument('--foo')
     >>> parser.parse_args(['-x', 'X'])
     Namespace(foo=None, x='X')
     >>> parser.parse_args(['--foo', 'FOO'])
     Namespace(foo='FOO', x=None)

長いオプション (1文字よりも長い名前を持ったオプション) では、オプション
とその値は次のように ‘=’ で区切られた1つのコマンドライン引数として渡すこ
ともできます:

     >>> parser.parse_args(['--foo=FOO'])
     Namespace(foo='FOO', x=None)

短いオプション (1文字のオプション) では、オプションとその値は次のように
連結して渡すことができます:

     >>> parser.parse_args(['-xX'])
     Namespace(foo=None, x='X')

最後の1つのオプションだけが値を要求する場合、または値を要求するオプショ
ンがない場合、複数の短いオプションは次のように1つの接頭辞 ‘-’ だけで連結
できます:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-x', action='store_true')
     >>> parser.add_argument('-y', action='store_true')
     >>> parser.add_argument('-z')
     >>> parser.parse_args(['-xyzZ'])
     Namespace(x=True, y=True, z='Z')


File: python.info,  Node: 不正な引数,  Next: - を含む引数,  Prev: オプション値の文法,  Up: parse_args メソッド

5.16.4.31 不正な引数
....................

*note parse_args(): 2bb7. は、コマンドラインの解析中に、曖昧なオプション
、不正な型、不正なオプション、位置引数の数の不一致などのエラーを検証しま
す。それらのエラーが発生した場合、エラーメッセージと使用法メッセージを表
示して終了します:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('--foo', type=int)
     >>> parser.add_argument('bar', nargs='?')

     >>> # invalid type
     >>> parser.parse_args(['--foo', 'spam'])
     usage: PROG [-h] [--foo FOO] [bar]
     PROG: error: argument --foo: invalid int value: 'spam'

     >>> # invalid option
     >>> parser.parse_args(['--bar'])
     usage: PROG [-h] [--foo FOO] [bar]
     PROG: error: no such option: --bar

     >>> # wrong number of arguments
     >>> parser.parse_args(['spam', 'badger'])
     usage: PROG [-h] [--foo FOO] [bar]
     PROG: error: extra arguments found: badger


File: python.info,  Node: - を含む引数,  Next: 引数の短縮形 先頭文字でのマッチング,  Prev: 不正な引数,  Up: parse_args メソッド

5.16.4.32 ‘-’ を含む引数
........................

*note parse_args(): 2bb7. メソッドは、ユーザーが明らかなミスをした場合は
エラーを表示しますが、いくつか本質的に曖昧な場面があります。例えば、コマ
ンドライン引数 ‘-1’ は、オプションの指定かもしれませんし位置引数かもしれ
ません。*note parse_args(): 2bb7. メソッドはこれを次のように扱います: 負
の数として解釈でき、パーサーに負の数のように解釈できるオプションが存在し
ない場合にのみ、‘-’ で始まる位置引数になりえます:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-x')
     >>> parser.add_argument('foo', nargs='?')

     >>> # no negative number options, so -1 is a positional argument
     >>> parser.parse_args(['-x', '-1'])
     Namespace(foo=None, x='-1')

     >>> # no negative number options, so -1 and -5 are positional arguments
     >>> parser.parse_args(['-x', '-1', '-5'])
     Namespace(foo='-5', x='-1')

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-1', dest='one')
     >>> parser.add_argument('foo', nargs='?')

     >>> # negative number options present, so -1 is an option
     >>> parser.parse_args(['-1', 'X'])
     Namespace(foo=None, one='X')

     >>> # negative number options present, so -2 is an option
     >>> parser.parse_args(['-2'])
     usage: PROG [-h] [-1 ONE] [foo]
     PROG: error: no such option: -2

     >>> # negative number options present, so both -1s are options
     >>> parser.parse_args(['-1', '-1'])
     usage: PROG [-h] [-1 ONE] [foo]
     PROG: error: argument -1: expected one argument

‘-’ で始まる位置引数があって、それが負の数として解釈できない場合、ダミー
の引数 ‘'--'’ を挿入して、*note parse_args(): 2bb7. にそれ以降のすべてが
位置引数だと教えることができます:

     >>> parser.parse_args(['--', '-f'])
     Namespace(foo='-f', one=None)

See also *note the argparse howto on ambiguous arguments: 2bdd. for more
details.


File: python.info,  Node: 引数の短縮形 先頭文字でのマッチング,  Next: sys argv 以外,  Prev: - を含む引数,  Up: parse_args メソッド

5.16.4.33 引数の短縮形 (先頭文字でのマッチング)
...............................................

*note parse_args(): 2bb7. メソッドは、*note デフォルトで: d8c.、長いオプ
ションに曖昧さがない (先頭文字列が一意である) かぎり、先頭文字列に短縮し
て指定できます:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-bacon')
     >>> parser.add_argument('-badger')
     >>> parser.parse_args('-bac MMM'.split())
     Namespace(bacon='MMM', badger=None)
     >>> parser.parse_args('-bad WOOD'.split())
     Namespace(bacon=None, badger='WOOD')
     >>> parser.parse_args('-ba BA'.split())
     usage: PROG [-h] [-bacon BACON] [-badger BADGER]
     PROG: error: ambiguous option: -ba could match -badger, -bacon

先頭の文字が同じ引数が複数ある場合に短縮指定を行うとエラーを発生させます
。この機能は *note allow_abbrev: d8c. に ‘False’ を指定することで無効に
できます。


File: python.info,  Node: sys argv 以外,  Next: Namespace オブジェクト,  Prev: 引数の短縮形 先頭文字でのマッチング,  Up: parse_args メソッド

5.16.4.34 ‘sys.argv’ 以外
.........................

Sometimes it may be useful to have an *note ArgumentParser: 503. parse
arguments other than those of *note sys.argv: 1236.  This can be
accomplished by passing a list of strings to *note parse_args(): 2bb7.
This is useful for testing at the interactive prompt:

     >>> parser = argparse.ArgumentParser()
     >>> parser.add_argument(
     ...     'integers', metavar='int', type=int, choices=range(10),
     ...     nargs='+', help='an integer in the range 0..9')
     >>> parser.add_argument(
     ...     '--sum', dest='accumulate', action='store_const', const=sum,
     ...     default=max, help='sum the integers (default: find the max)')
     >>> parser.parse_args(['1', '2', '3', '4'])
     Namespace(accumulate=<built-in function max>, integers=[1, 2, 3, 4])
     >>> parser.parse_args(['1', '2', '3', '4', '--sum'])
     Namespace(accumulate=<built-in function sum>, integers=[1, 2, 3, 4])


File: python.info,  Node: Namespace オブジェクト,  Prev: sys argv 以外,  Up: parse_args メソッド

5.16.4.35 Namespace オブジェクト
................................

 -- クラス: argparse.Namespace

     *note parse_args(): 2bb7. が属性を格納して返すためのオブジェクトに
     デフォルトで使用されるシンプルなクラスです。

     このクラスはシンプルに設計されており、単に読みやすい文字列表現を持
     った *note object: a5a. のサブクラスです。もし属性を辞書のように扱
     える方が良ければ、標準的な Python のイディオム *note vars(): 19ad.
     を利用できます:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo')
          >>> args = parser.parse_args(['--foo', 'BAR'])
          >>> vars(args)
          {'foo': 'BAR'}

     *note ArgumentParser: 503. が、新しい *note Namespace: 2bb8. オブジ
     ェクトではなく、既存のオブジェクトに属性を設定する方が良い場合があ
     ります。これは ‘namespace=’ キーワード引数を指定することで可能です:

          >>> class C:
          ...     pass
          ...
          >>> c = C()
          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo')
          >>> parser.parse_args(args=['--foo', 'BAR'], namespace=c)
          >>> c.foo
          'BAR'


File: python.info,  Node: その他のユーティリティ,  Next: 例外<9>,  Prev: parse_args メソッド,  Up: argparse --- Parser for command-line options arguments and subcommands

5.16.4.36 その他のユーティリティ
................................

* Menu:

* サブコマンド::
* FileType オブジェクト::
* 引数グループ::
* 相互排他::
* パーサーのデフォルト値::
* ヘルプの表示::
* 部分解析::
* ファイル解析のカスタマイズ::
* 終了メソッド::
* 混在した引数の解析::


File: python.info,  Node: サブコマンド,  Next: FileType オブジェクト,  Up: その他のユーティリティ

5.16.4.37 サブコマンド
......................

 -- メソッド: ArgumentParser.add_subparsers (*[, title][, description][,
          prog][, parser_class][, action][, dest][, required][, help][,
          metavar])

     Many programs split up their functionality into a number of
     subcommands, for example, the ‘svn’ program can invoke subcommands
     like ‘svn checkout’, ‘svn update’, and ‘svn commit’.  Splitting up
     functionality this way can be a particularly good idea when a
     program performs several different functions which require
     different kinds of command-line arguments.  *note ArgumentParser:
     503. supports the creation of such subcommands with the
     ‘add_subparsers()’ method.  The ‘add_subparsers()’ method is
     normally called with no arguments and returns a special action
     object.  This object has a single method, ‘add_parser()’, which
     takes a command name and any ‘ArgumentParser’ constructor
     arguments, and returns an ‘ArgumentParser’ object that can be
     modified as usual.

     引数の説明:

        * 'title' - title for the sub-parser group in help output; by
          default "subcommands" if description is provided, otherwise
          uses title for positional arguments

        * 'description' - description for the sub-parser group in help
          output, by default ‘None’

        * 'prog' - usage information that will be displayed with
          sub-command help, by default the name of the program and any
          positional arguments before the subparser argument

        * 'parser_class' - class which will be used to create sub-parser
          instances, by default the class of the current parser (e.g.
          *note ArgumentParser: 503.)

        * *note action: 2bd3. - コマンドラインにこの引数があったときの基
          本のアクション。

        * *note dest: 2bcd. - サブコマンド名を格納する属性の名前です。デ
          フォルトは ‘None’ で値は格納されません

        * *note required: 2bd6. - サブコマンドが必須であるかどうかを指定
          し、デフォルトは ‘False’ です。(3.7 より追加)

        * *note help: 2bd7. - ヘルプ出力に表示されるサブパーサーグループ
          のヘルプです。デフォルトは ‘None’ です

        * *note metavar: 2bd8. - string presenting available subcommands
          in help; by default it is ‘None’ and presents subcommands in
          form {cmd1, cmd2, ..}

     いくつかの使用例:

          >>> # create the top-level parser
          >>> parser = argparse.ArgumentParser(prog='PROG')
          >>> parser.add_argument('--foo', action='store_true', help='foo help')
          >>> subparsers = parser.add_subparsers(help='subcommand help')
          >>>
          >>> # create the parser for the "a" command
          >>> parser_a = subparsers.add_parser('a', help='a help')
          >>> parser_a.add_argument('bar', type=int, help='bar help')
          >>>
          >>> # create the parser for the "b" command
          >>> parser_b = subparsers.add_parser('b', help='b help')
          >>> parser_b.add_argument('--baz', choices=('X', 'Y', 'Z'), help='baz help')
          >>>
          >>> # parse some argument lists
          >>> parser.parse_args(['a', '12'])
          Namespace(bar=12, foo=False)
          >>> parser.parse_args(['--foo', 'b', '--baz', 'Z'])
          Namespace(baz='Z', foo=True)

     *note parse_args(): 2bb7. が返すオブジェクトにはメインパーサーとコ
     マンドラインで選択されたサブパーサーによる属性だけが設定されており
     、選択されなかったサブコマンドのパーサーの属性が設定されていないこ
     とに注意してください。このため、上の例では、‘a’ コマンドが指定され
     たときは ‘foo’, ‘bar’ 属性だけが存在し、‘b’ コマンドが指定されたと
     きは ‘foo’, ‘baz’ 属性だけが存在しています。

     同じように、サブパーサーにヘルプメッセージが要求された場合は、その
     パーサーに対するヘルプだけが表示されます。ヘルプメッセージには親パ
     ーサーや兄弟パーサーのヘルプメッセージを表示しません。 (ただし、各
     サブパーサーコマンドのヘルプメッセージは、上の例にもあるように
     ‘add_parser()’ の ‘help=’ 引数によって指定できます)

          >>> parser.parse_args(['--help'])
          usage: PROG [-h] [--foo] {a,b} ...

          positional arguments:
            {a,b}   subcommand help
              a     a help
              b     b help

          options:
            -h, --help  show this help message and exit
            --foo   foo help

          >>> parser.parse_args(['a', '--help'])
          usage: PROG a [-h] bar

          positional arguments:
            bar     bar help

          options:
            -h, --help  show this help message and exit

          >>> parser.parse_args(['b', '--help'])
          usage: PROG b [-h] [--baz {X,Y,Z}]

          options:
            -h, --help     show this help message and exit
            --baz {X,Y,Z}  baz help

     *note add_subparsers(): be5. メソッドは ‘title’ と ‘description’ キ
     ーワード引数もサポートしています。どちらかが存在する場合、サブパー
     サーのコマンドはヘルプ出力でそれぞれのグループの中に表示されます。
     例えば:

          >>> parser = argparse.ArgumentParser()
          >>> subparsers = parser.add_subparsers(title='subcommands',
          ...                                    description='valid subcommands',
          ...                                    help='additional help')
          >>> subparsers.add_parser('foo')
          >>> subparsers.add_parser('bar')
          >>> parser.parse_args(['-h'])
          usage:  [-h] {foo,bar} ...

          options:
            -h, --help  show this help message and exit

          subcommands:
            valid subcommands

            {foo,bar}   additional help

     Furthermore, ‘add_parser()’ supports an additional 'aliases'
     argument, which allows multiple strings to refer to the same
     subparser.  This example, like ‘svn’, aliases ‘co’ as a shorthand
     for ‘checkout’:

          >>> parser = argparse.ArgumentParser()
          >>> subparsers = parser.add_subparsers()
          >>> checkout = subparsers.add_parser('checkout', aliases=['co'])
          >>> checkout.add_argument('foo')
          >>> parser.parse_args(['co', 'bar'])
          Namespace(foo='bar')

     ‘add_parser()’ supports also an additional 'deprecated' argument,
     which allows to deprecate the subparser.

          >>> import argparse
          >>> parser = argparse.ArgumentParser(prog='chicken.py')
          >>> subparsers = parser.add_subparsers()
          >>> run = subparsers.add_parser('run')
          >>> fly = subparsers.add_parser('fly', deprecated=True)
          >>> parser.parse_args(['fly'])
          chicken.py: warning: command 'fly' is deprecated
          Namespace()

     Added in version 3.13.

     One particularly effective way of handling subcommands is to
     combine the use of the *note add_subparsers(): be5. method with
     calls to *note set_defaults(): 2bcf. so that each subparser knows
     which Python function it should execute.  For example:

          >>> # subcommand functions
          >>> def foo(args):
          ...     print(args.x * args.y)
          ...
          >>> def bar(args):
          ...     print('((%s))' % args.z)
          ...
          >>> # create the top-level parser
          >>> parser = argparse.ArgumentParser()
          >>> subparsers = parser.add_subparsers(required=True)
          >>>
          >>> # create the parser for the "foo" command
          >>> parser_foo = subparsers.add_parser('foo')
          >>> parser_foo.add_argument('-x', type=int, default=1)
          >>> parser_foo.add_argument('y', type=float)
          >>> parser_foo.set_defaults(func=foo)
          >>>
          >>> # create the parser for the "bar" command
          >>> parser_bar = subparsers.add_parser('bar')
          >>> parser_bar.add_argument('z')
          >>> parser_bar.set_defaults(func=bar)
          >>>
          >>> # parse the args and call whatever function was selected
          >>> args = parser.parse_args('foo 1 -x 2'.split())
          >>> args.func(args)
          2.0
          >>>
          >>> # parse the args and call whatever function was selected
          >>> args = parser.parse_args('bar XYZYX'.split())
          >>> args.func(args)
          ((XYZYX))

     こうすると、*note parse_args(): 2bb7. が引数の解析が終わってから適
     切な関数を呼び出すようになります。このように関数をアクションに関連
     付けるのは一般的にサブパーサーごとに異なるアクションを扱うもっとも
     簡単な方法です。ただし、実行されたサブパーサーの名前を確認する必要
     がある場合は、*note add_subparsers(): be5. を呼び出すときに ‘dest’
     キーワードを指定できます:

          >>> parser = argparse.ArgumentParser()
          >>> subparsers = parser.add_subparsers(dest='subparser_name')
          >>> subparser1 = subparsers.add_parser('1')
          >>> subparser1.add_argument('-x')
          >>> subparser2 = subparsers.add_parser('2')
          >>> subparser2.add_argument('y')
          >>> parser.parse_args(['2', 'frobble'])
          Namespace(subparser_name='2', y='frobble')

     バージョン 3.7 で変更: New 'required' keyword-only parameter.


File: python.info,  Node: FileType オブジェクト,  Next: 引数グループ,  Prev: サブコマンド,  Up: その他のユーティリティ

5.16.4.38 FileType オブジェクト
...............................

 -- クラス: argparse.FileType (mode='r', bufsize=-1, encoding=None,
          errors=None)

     *note FileType: ee7. ファクトリは *note
     ArgumentParser.add_argument(): 183. の type 引数に渡すことができる
     オブジェクトを生成します。 type が *note FileType: ee7. オブジェク
     トである引数はコマンドライン引数を、指定されたモード、バッファーサ
     イズ、エンコーディング、エラー処理でファイルとして開きます (詳細は
     *note open(): 4e5. 関数を参照してください。):

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--raw', type=argparse.FileType('wb', 0))
          >>> parser.add_argument('out', type=argparse.FileType('w', encoding='UTF-8'))
          >>> parser.parse_args(['--raw', 'raw.dat', 'file.txt'])
          Namespace(out=<_io.TextIOWrapper name='file.txt' mode='w' encoding='UTF-8'>, raw=<_io.FileIO name='raw.dat' mode='wb'>)

     FileType オブジェクトは擬似引数 ‘'-'’ を識別し、読み込み用の *note
     FileType: ee7. であれば *note sys.stdin: 507. を、書き込み用の
     *note FileType: ee7. であれば *note sys.stdout: aa4. に変換します:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('infile', type=argparse.FileType('r'))
          >>> parser.parse_args(['-'])
          Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>)

     バージョン 3.4 で変更: 'encodings' と 'errors' がパラメータに追加さ
     れました。


File: python.info,  Node: 引数グループ,  Next: 相互排他,  Prev: FileType オブジェクト,  Up: その他のユーティリティ

5.16.4.39 引数グループ
......................

 -- メソッド: ArgumentParser.add_argument_group (title=None,
          description=None, *[, argument_default][, conflict_handler])

     By default, *note ArgumentParser: 503. groups command-line
     arguments into "positional arguments" and "options" when displaying
     help messages.  When there is a better conceptual grouping of
     arguments than this default one, appropriate groups can be created
     using the ‘add_argument_group()’ method:

          >>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)
          >>> group = parser.add_argument_group('group')
          >>> group.add_argument('--foo', help='foo help')
          >>> group.add_argument('bar', help='bar help')
          >>> parser.print_help()
          usage: PROG [--foo FOO] bar

          group:
            bar    bar help
            --foo FOO  foo help

     The *note add_argument_group(): 2bf8. method returns an argument
     group object which has an *note add_argument(): 183. method just
     like a regular *note ArgumentParser: 503.  When an argument is
     added to the group, the parser treats it just like a normal
     argument, but displays the argument in a separate group for help
     messages.  The ‘add_argument_group()’ method accepts 'title' and
     'description' arguments which can be used to customize this
     display:

          >>> parser = argparse.ArgumentParser(prog='PROG', add_help=False)
          >>> group1 = parser.add_argument_group('group1', 'group1 description')
          >>> group1.add_argument('foo', help='foo help')
          >>> group2 = parser.add_argument_group('group2', 'group2 description')
          >>> group2.add_argument('--bar', help='bar help')
          >>> parser.print_help()
          usage: PROG [--bar BAR] foo

          group1:
            group1 description

            foo    foo help

          group2:
            group2 description

            --bar BAR  bar help

     The optional, keyword-only parameters *note argument_default: 2bc2.
     and *note conflict_handler: 2bc3. allow for finer-grained control
     of the behavior of the argument group.  These parameters have the
     same meaning as in the *note ArgumentParser: 503. constructor, but
     apply specifically to the argument group rather than the entire
     parser.

     ユーザー定義グループにないすべての引数は通常の "位置引数" と "オプ
     ション引数" セクションに表示されます。

     バージョン 3.11 で変更: 引数グループについて *note
     add_argument_group(): 2bf8. を呼び出すことは非推奨です。この機能は
     これまでサポートされたことはなく、常に正しく動作するとは限りません
     。この関数は継承を通じて思いがけず API に存在することになったもので
     、将来削除される予定です。


File: python.info,  Node: 相互排他,  Next: パーサーのデフォルト値,  Prev: 引数グループ,  Up: その他のユーティリティ

5.16.4.40 相互排他
..................

 -- メソッド: ArgumentParser.add_mutually_exclusive_group
          (required=False)

     Create a mutually exclusive group.  ‘argparse’ will make sure that
     only one of the arguments in the mutually exclusive group was
     present on the command line:

          >>> parser = argparse.ArgumentParser(prog='PROG')
          >>> group = parser.add_mutually_exclusive_group()
          >>> group.add_argument('--foo', action='store_true')
          >>> group.add_argument('--bar', action='store_false')
          >>> parser.parse_args(['--foo'])
          Namespace(bar=True, foo=True)
          >>> parser.parse_args(['--bar'])
          Namespace(bar=False, foo=False)
          >>> parser.parse_args(['--foo', '--bar'])
          usage: PROG [-h] [--foo | --bar]
          PROG: error: argument --bar: not allowed with argument --foo

     *note add_mutually_exclusive_group(): 2bfa. メソッドの引数
     'required' に True 値を指定すると、その相互排他引数のどれか1つを選
     ぶことが要求されます:

          >>> parser = argparse.ArgumentParser(prog='PROG')
          >>> group = parser.add_mutually_exclusive_group(required=True)
          >>> group.add_argument('--foo', action='store_true')
          >>> group.add_argument('--bar', action='store_false')
          >>> parser.parse_args([])
          usage: PROG [-h] (--foo | --bar)
          PROG: error: one of the arguments --foo --bar is required

     Note that currently mutually exclusive argument groups do not
     support the 'title' and 'description' arguments of *note
     add_argument_group(): 2bf8.  However, a mutually exclusive group
     can be added to an argument group that has a title and description.
     For example:

          >>> parser = argparse.ArgumentParser(prog='PROG')
          >>> group = parser.add_argument_group('Group title', 'Group description')
          >>> exclusive_group = group.add_mutually_exclusive_group(required=True)
          >>> exclusive_group.add_argument('--foo', help='foo help')
          >>> exclusive_group.add_argument('--bar', help='bar help')
          >>> parser.print_help()
          usage: PROG [-h] (--foo FOO | --bar BAR)

          options:
            -h, --help  show this help message and exit

          Group title:
            Group description

            --foo FOO   foo help
            --bar BAR   bar help

     バージョン 3.11 で変更: 相互排他グループについて *note
     add_argument_group(): 2bf8. や *note
     add_mutually_exclusive_group(): 2bfa. を呼び出すことは非推奨です。
     これらの機能はこれまで一度もサポートされたことがなく、常に正しく動
     作するとは限りません。これらの関数は継承により偶然 API に存在するこ
     とになったもので、将来削除される予定です。


File: python.info,  Node: パーサーのデフォルト値,  Next: ヘルプの表示,  Prev: 相互排他,  Up: その他のユーティリティ

5.16.4.41 パーサーのデフォルト値
................................

 -- メソッド: ArgumentParser.set_defaults (**kwargs)

     ほとんどの場合、 *note parse_args(): 2bb7. が返すオブジェクトの属性
     はコマンドライン引数の内容と引数のアクションによってのみ決定されま
     す。 *note set_defaults(): 2bcf. を使うと与えられたコマンドライン引
     数の内容によらず追加の属性を決定することが可能です:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('foo', type=int)
          >>> parser.set_defaults(bar=42, baz='badger')
          >>> parser.parse_args(['736'])
          Namespace(bar=42, baz='badger', foo=736)

     パーサーレベルのデフォルト値は常に引数レベルのデフォルト値を上書き
     します:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', default='bar')
          >>> parser.set_defaults(foo='spam')
          >>> parser.parse_args([])
          Namespace(foo='spam')

     パーサーレベルの default は、複数のパーサーを扱うときに特に便利です
     。このタイプの例については *note add_subparsers(): be5. メソッドを
     参照してください。

 -- メソッド: ArgumentParser.get_default (dest)

     *note add_argument(): 183. か *note set_defaults(): 2bcf. によって
     指定された、 namespace の属性のデフォルト値を取得します:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', default='badger')
          >>> parser.get_default('foo')
          'badger'


File: python.info,  Node: ヘルプの表示,  Next: 部分解析,  Prev: パーサーのデフォルト値,  Up: その他のユーティリティ

5.16.4.42 ヘルプの表示
......................

ほとんどの典型的なアプリケーションでは、*note parse_args(): 2bb7. が使用
法やエラーメッセージのフォーマットと表示について面倒を見ます。しかし、い
くつかのフォーマットメソッドが利用できます:

 -- メソッド: ArgumentParser.print_usage (file=None)

     *note ArgumentParser: 503. がコマンドラインからどう実行されるべきか
     の短い説明を表示します。 'file' が ‘None’ の時は、 *note
     sys.stdout: aa4. に出力されます。

 -- メソッド: ArgumentParser.print_help (file=None)

     プログラムの使用法と *note ArgumentParser: 503. に登録された引数に
     ついての情報を含むヘルプメッセージを表示します。 'file' が ‘None’ の
     時は、 *note sys.stdout: aa4. に出力されます。

これらのメソッドの、表示する代わりにシンプルに文字列を返すバージョンもあ
ります:

 -- メソッド: ArgumentParser.format_usage ()

     *note ArgumentParser: 503. がコマンドラインからどう実行されるべきか
     の短い説明を格納した文字列を返します。

 -- メソッド: ArgumentParser.format_help ()

     プログラムの使用法と *note ArgumentParser: 503. に登録された引数に
     ついての情報を含むヘルプメッセージを格納した文字列を返します。


File: python.info,  Node: 部分解析,  Next: ファイル解析のカスタマイズ,  Prev: ヘルプの表示,  Up: その他のユーティリティ

5.16.4.43 部分解析
..................

 -- メソッド: ArgumentParser.parse_known_args (args=None,
          namespace=None)

     ときどき、スクリプトがコマンドライン引数のいくつかだけを解析し、残
     りの引数は別のスクリプトやプログラムに渡すことがあります。こういっ
     た場合、 *note parse_known_args(): 2c02. メソッドが便利です。これは
     *note parse_args(): 2bb7. と同じように動作しますが、余分な引数が存
     在してもエラーを生成しません。代わりに、評価された namespace オブジ
     ェクトと、残りの引数文字列のリストからなる2要素タプルを返します。

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo', action='store_true')
          >>> parser.add_argument('bar')
          >>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])
          (Namespace(bar='BAR', foo=True), ['--badger', 'spam'])

     警告: *note 先頭文字でのマッチング: d8d. ルールは *note
     parse_known_args(): 2c02. にも適用されます。たとえ既知のオプション
     の先頭文字に過ぎない場合でも、パーサは引数リストに残さずに、オプシ
     ョンを受け取る場合があります。


File: python.info,  Node: ファイル解析のカスタマイズ,  Next: 終了メソッド,  Prev: 部分解析,  Up: その他のユーティリティ

5.16.4.44 ファイル解析のカスタマイズ
....................................

 -- メソッド: ArgumentParser.convert_arg_line_to_args (arg_line)

     ファイルから引数を読み込む場合 (*note ArgumentParser: 503. コンスト
     ラクターの 'fromfile_prefix_chars' キーワード引数を参照)、1行につき
     1つの引数を読み込みます。 *note convert_arg_line_to_args(): 2bce. を
     変更することでこの動作をカスタマイズできます。

     このメソッドは、引数ファイルから読まれた文字列である1つの引数
     'arg_line' を受け取ります。そしてその文字列を解析した結果の引数のリ
     ストを返します。このメソッドはファイルから1行読みこむごとに、順番に
     呼ばれます。

     このメソッドをオーバーライドすると便利なこととして、スペースで区切
     られた行の単語1つ1つを別々の引数として扱えます。次の例でその方法を
     示します:

          class MyArgumentParser(argparse.ArgumentParser):
              def convert_arg_line_to_args(self, arg_line):
                  return arg_line.split()


File: python.info,  Node: 終了メソッド,  Next: 混在した引数の解析,  Prev: ファイル解析のカスタマイズ,  Up: その他のユーティリティ

5.16.4.45 終了メソッド
......................

 -- メソッド: ArgumentParser.exit (status=0, message=None)

     This method terminates the program, exiting with the specified
     'status' and, if given, it prints a 'message' to *note sys.stderr:
     907. before that.  The user can override this method to handle
     these steps differently:

          class ErrorCatchingArgumentParser(argparse.ArgumentParser):
              def exit(self, status=0, message=None):
                  if status:
                      raise Exception(f'Exiting because of an error: {message}')
                  exit(status)

 -- メソッド: ArgumentParser.error (message)

     This method prints a usage message, including the 'message', to
     *note sys.stderr: 907. and terminates the program with a status
     code of 2.


File: python.info,  Node: 混在した引数の解析,  Prev: 終了メソッド,  Up: その他のユーティリティ

5.16.4.46 混在した引数の解析
............................

 -- メソッド: ArgumentParser.parse_intermixed_args (args=None,
          namespace=None)

 -- メソッド: ArgumentParser.parse_known_intermixed_args (args=None,
          namespace=None)

     多くの Unix コマンドは、オプション引数と位置引数を混在させることを
     許しています。 *note parse_intermixed_args(): ace. と *note
     parse_known_intermixed_args(): 2c08. メソッドは、このような方法での
     解析をサポートしています。

     These parsers do not support all the ‘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.

     この例は、*note parse_known_args(): 2c02. と *note
     parse_intermixed_args(): ace. の違いを表しています: 前者は ‘['2',
     '3']’ を、解析されない引数として返し、後者は全ての位置引数を ‘rest’
     に入れて返しています:

          >>> parser = argparse.ArgumentParser()
          >>> parser.add_argument('--foo')
          >>> parser.add_argument('cmd')
          >>> parser.add_argument('rest', nargs='*', type=int)
          >>> parser.parse_known_args('doit 1 --foo bar 2 3'.split())
          (Namespace(cmd='doit', foo='bar', rest=[1]), ['2', '3'])
          >>> parser.parse_intermixed_args('doit 1 --foo bar 2 3'.split())
          Namespace(cmd='doit', foo='bar', rest=[1, 2, 3])

     *note parse_known_intermixed_args(): 2c08. は、解析した内容を含む名
     前空間と、残りの引数を含んだリストの、2つの要素を持つタプルを返しま
     す。 *note parse_intermixed_args(): ace. は、解析されない引数が残さ
     れた場合にはエラーを送出します。

     Added in version 3.7.


File: python.info,  Node: 例外<9>,  Prev: その他のユーティリティ,  Up: argparse --- Parser for command-line options arguments and subcommands

5.16.4.47 例外
..............

 -- 例外: argparse.ArgumentError

     引数 (オプション引数または位置引数) の生成時または利用時のエラーで
     す。

     この例外の文字列表現は、エラーの原因となった引数についての情報を補
     足するメッセージです。

 -- 例外: argparse.ArgumentTypeError

     コマンドラインの文字列を、指定された型に変換するのに失敗した時に送
     出されます。

ガイドとチュートリアル
......................

* Menu:

* Argparse チュートリアル::
* Upgrading optparse code::


File: python.info,  Node: Argparse チュートリアル,  Next: Upgrading optparse code,  Up: 例外<9>

5.16.4.48 Argparse チュートリアル
.................................


author: Tshepang Mbambo

このチュートリアルでは、*note argparse: 5. を丁寧に説明します。*note
argparse: 5. は、Python 標準ライブラリの一部であり、おすすめのコマンドラ
イン引数の解析モジュールです。

     注釈: 同じ機能を実現するモジュールが他に2つあります。 *note getopt:
     57. (C 言語の ‘getopt()’ に相当するもの) と非推奨の *note optparse:
     90. です。なお *note argparse: 5. は *note optparse: 90. をもとにし
     ており、従ってその使い方は非常によく似ています。

* Menu:

* コンセプト::
* 基礎::
* 位置引数の入門::
* Optional引数の導入::
* 位置引数とOptional引数の併用::
* もうちょっとだけ学ぶ::
* argparse の出力を翻訳するには::
* Custom type converters::
* 結び::


File: python.info,  Node: コンセプト,  Next: 基礎,  Up: Argparse チュートリアル

5.16.4.49 コンセプト
....................

‘ls’ コマンドを使って、このチュートリアルで私たちが学ぶ機能をいくつか見
てみましょう:

     $ ls
     cpython  devguide  prog.py  pypy  rm-unused-function.patch
     $ ls pypy
     ctypes_configure  demo  dotviewer  include  lib_pypy  lib-python ...
     $ ls -l
     total 20
     drwxr-xr-x 19 wena wena 4096 Feb 18 18:51 cpython
     drwxr-xr-x  4 wena wena 4096 Feb  8 12:04 devguide
     -rwxr-xr-x  1 wena wena  535 Feb 19 00:05 prog.py
     drwxr-xr-x 14 wena wena 4096 Feb  7 00:59 pypy
     -rw-r--r--  1 wena wena  741 Feb 18 01:01 rm-unused-function.patch
     $ ls --help
     Usage: ls [OPTION]... [FILE]...
     List information about the FILEs (the current directory by default).
     Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
     ...

上の４つの実行結果から、以下のことが分かります:

   * ‘ls’ コマンドは、まったくオプションを指定せずに実行したとしても役に
     立ちます。デフォルトの動作は、カレントディレクトリの内容を表示する
     ことです。

   * デフォルトの動作で提供される以上のことをしたい場合、すこしだけオプ
     ションを指定する必要があります。別のディレクトリ ‘pypy’ を表示した
     い場合、私たちがしたことは、位置引数として知られる引数を指定するこ
     とです。これは、引数がコマンドラインのどの位置に現れたかということ
     だけを基に、プログラムがその値について何をするのか分かるべきなので
     、このように名づけられています。このコンセプトは ‘cp’ のようなコマ
     ンドで重要な意味があります。 ‘cp’ コマンドのもっとも基本的な使い方
     は、 ‘cp SRC DEST’ です。最初の引数は '何をコピーしたいか' であり、
     二つ目の引数は 'どこにコピーしたいか' を意味します。

   * プログラムの振る舞いを変えましょう。例では、単にファイル名を表示す
     る代わりにそれぞれのファイルに関する多くの情報を表示します。このケ
     ースでは、‘-l’ はoptional引数として知られます。

   * ヘルプテキストの抜粋です。この実行の仕方は、まだ使用したことがない
     プログラムにたいして行うと有用で、ヘルプテキストを読むことで、プロ
     グラムがどのように動作するかわかります。


File: python.info,  Node: 基礎,  Next: 位置引数の入門,  Prev: コンセプト,  Up: Argparse チュートリアル

5.16.4.50 基礎
..............

（ほとんど）何もしない、とても簡単な例から始めましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.parse_args()

下記がこのコードを実行した結果です:

     $ python prog.py
     $ python prog.py --help
     usage: prog.py [-h]

     options:
       -h, --help  show this help message and exit
     $ python prog.py --verbose
     usage: prog.py [-h]
     prog.py: error: unrecognized arguments: --verbose
     $ python prog.py foo
     usage: prog.py [-h]
     prog.py: error: unrecognized arguments: foo

こんなことが起こりました:

   * オプションなしでスクリプトを実行した結果、なにも標準出力に表示され
     ませんでした。それほど便利ではありませんね。

   * 二つ目の実行結果から *note argparse: 5. モジュールの有用性がわかり
     ます。ほとんど何もしていないのに、すてきなヘルプメッセージが手に入
     りました。

   * ‘--help’ （これは ‘-h’ と短縮できます）だけが無料のオプションです（
     つまりプログラムで指示する必要はありません）。他のオプションを指定
     するとエラーになります。エラー時の有用な用法メッセージも、プログラ
     ムで指示することなく出力できます。


File: python.info,  Node: 位置引数の入門,  Next: Optional引数の導入,  Prev: 基礎,  Up: Argparse チュートリアル

5.16.4.51 位置引数の入門
........................

以下に例を示します:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("echo")
     args = parser.parse_args()
     print(args.echo)

このコードを実行してみましょう:

     $ python prog.py
     usage: prog.py [-h] echo
     prog.py: error: the following arguments are required: echo
     $ python prog.py --help
     usage: prog.py [-h] echo

     positional arguments:
       echo

     options:
       -h, --help  show this help message and exit
     $ python prog.py foo
     foo

こんなことが起こりました:

   * プログラムが受け付けるコマンドラインオプションを指定するメソッドで
     ある *note add_argument(): 183. を追加しました。ここでは、その機能
     にあわせて引数名を ‘echo’ としました。

   * プログラムを実行すると、オプションを指定するように要求されます。

   * *note parse_args(): 2bb7. メソッドは指定されたオプションを、この場
     合は ‘echo’ として、返します。

   * この変数は *note argparse: 5. が自動的に行うある種の魔法です（つま
     り、値を格納する変数を指定する必要がありません）。変数の名前がメソ
     ッドに与えた文字列引数 ‘echo’ と同じことに気付いたでしょう。

ヘルプメッセージは十分なように見えますが、それほど分かりやすくもありませ
ん。たとえば、‘echo’ は位置引数であることがわかりますが、それが何である
かを知るためには推測するかソースコードを見なけれなりません。もうすこしヘ
ルプメッセージ分かりやすくしてみましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("echo", help="echo the string you use here")
     args = parser.parse_args()
     print(args.echo)

修正した結果は以下のようになります:

     $ python prog.py -h
     usage: prog.py [-h] echo

     positional arguments:
       echo        echo the string you use here

     options:
       -h, --help  show this help message and exit

次は、もっと有益なことをしてみませんか？:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", help="display a square of a given number")
     args = parser.parse_args()
     print(args.square**2)

下記がこのコードを実行した結果です:

     $ python prog.py 4
     Traceback (most recent call last):
       File "prog.py", line 5, in <module>
         print(args.square**2)
     TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

上手くいきませんでした。 何も伝えなければ、*note argparse: 5. は与えられ
たオプションを文字列として扱います。 *note argparse: 5. にオプションの値
を整数として扱うように伝えましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", help="display a square of a given number",
                         type=int)
     args = parser.parse_args()
     print(args.square**2)

下記がこのコードを実行した結果です:

     $ python prog.py 4
     16
     $ python prog.py four
     usage: prog.py [-h] square
     prog.py: error: argument square: invalid int value: 'four'

今度は上手くいきました。このプログラムは不正な入力が与えられるとそれを処
理せずに、より親切なメッセージを表示して実行を終了します。


File: python.info,  Node: Optional引数の導入,  Next: 位置引数とOptional引数の併用,  Prev: 位置引数の入門,  Up: Argparse チュートリアル

5.16.4.52 Optional引数の導入
............................

ここまで位置引数を扱ってきました。optional引数を追加する方法についても見
ていきましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("--verbosity", help="increase output verbosity")
     args = parser.parse_args()
     if args.verbosity:
         print("verbosity turned on")

実行してみましょう:

     $ python prog.py --verbosity 1
     verbosity turned on
     $ python prog.py
     $ python prog.py --help
     usage: prog.py [-h] [--verbosity VERBOSITY]

     options:
       -h, --help            show this help message and exit
       --verbosity VERBOSITY
                             increase output verbosity
     $ python prog.py --verbosity
     usage: prog.py [-h] [--verbosity VERBOSITY]
     prog.py: error: argument --verbosity: expected one argument

こんなことが起こりました:

   * プログラムは、‘--verbosity’ が指定された場合はなにかしらを表示し、
     指定されなければ何も表示をしないように書かれています。

   * オプションの指定が実際に任意であることを示すために、プログラムをオ
     プション指定なしで実行してもエラーにはなっていません。オプション引
     数が指定されなかった場合、関連する変数、この例では ‘args.verbosity’
     、の値にはデフォルトで ‘None’ がセットされます。これが *note if:
     2ca. 文による真偽テストに失敗した理由です。

   * ヘルプメッセージが少し変わりました。

   * ‘--verbosity’ オプションを使うには、そのオプションにひとつの値を指
     定しなければなりません。

上記の例では、‘--verbosity’ に任意の整数を取れます。この簡単なプログラム
では、実際には ‘True’ または ‘False’ の二つの値だけが有効です。そうなる
ようにコードを修正してみましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("--verbose", help="increase output verbosity",
                         action="store_true")
     args = parser.parse_args()
     if args.verbose:
         print("verbosity turned on")

実行してみましょう:

     $ python prog.py --verbose
     verbosity turned on
     $ python prog.py --verbose 1
     usage: prog.py [-h] [--verbose]
     prog.py: error: unrecognized arguments: 1
     $ python prog.py --help
     usage: prog.py [-h] [--verbose]

     options:
       -h, --help  show this help message and exit
       --verbose   increase output verbosity

こんなことが起こりました:

   * オプションは値を必要とするのではなく、単なるフラグになりました。こ
     の考え方に沿うようにオプションの名前も変更しています。ここで新しい
     キーワード ‘action’ を指定し、値として ‘"store_true"’ を設定してい
     ることに注意してください。これは、オプションが指定された場合に値と
     して ‘True’ を ‘args.verbose’ に設定するということを意味します。オ
     プションの指定がない場合の値は ‘False’ となることを意味します。

   * フラグは値を取るべきではないので、値を指定するとプログラムはエラー
     になります。

   * ヘルプテキストが変わっています。

* Menu:

* 短いオプション::


File: python.info,  Node: 短いオプション,  Up: Optional引数の導入

5.16.4.53 短いオプション
........................

コマンドラインになれていれば、オプションの短いバージョンの話題に触れてい
ないことに気付いたでしょう。それはとても簡単です:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("-v", "--verbose", help="increase output verbosity",
                         action="store_true")
     args = parser.parse_args()
     if args.verbose:
         print("verbosity turned on")

上記のプログラムを実行するとこうなります:

     $ python prog.py -v
     verbosity turned on
     $ python prog.py --help
     usage: prog.py [-h] [-v]

     options:
       -h, --help     show this help message and exit
       -v, --verbose  increase output verbosity

新しい機能がヘルプテキストにも反映されている点に気付いたでしょう。


File: python.info,  Node: 位置引数とOptional引数の併用,  Next: もうちょっとだけ学ぶ,  Prev: Optional引数の導入,  Up: Argparse チュートリアル

5.16.4.54 位置引数とOptional引数の併用
......................................

プログラムが複雑になってきました:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", type=int,
                         help="display a square of a given number")
     parser.add_argument("-v", "--verbose", action="store_true",
                         help="increase output verbosity")
     args = parser.parse_args()
     answer = args.square**2
     if args.verbose:
         print(f"the square of {args.square} equals {answer}")
     else:
         print(answer)

出力は以下のようになります:

     $ python prog.py
     usage: prog.py [-h] [-v] square
     prog.py: error: the following arguments are required: square
     $ python prog.py 4
     16
     $ python prog.py 4 --verbose
     the square of 4 equals 16
     $ python prog.py --verbose 4
     the square of 4 equals 16

   * 位置引数を元に戻したので、引数を指定しないとエラーになりました。

   * ２つのオプションの順序を考慮しないことに注意してください。

複数の詳細レベルを値にとれるようにプログラムを元に戻して、指定された値を
使ってみましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", type=int,
                         help="display a square of a given number")
     parser.add_argument("-v", "--verbosity", type=int,
                         help="increase output verbosity")
     args = parser.parse_args()
     answer = args.square**2
     if args.verbosity == 2:
         print(f"the square of {args.square} equals {answer}")
     elif args.verbosity == 1:
         print(f"{args.square}^2 == {answer}")
     else:
         print(answer)

実行してみましょう:

     $ python prog.py 4
     16
     $ python prog.py 4 -v
     usage: prog.py [-h] [-v VERBOSITY] square
     prog.py: error: argument -v/--verbosity: expected one argument
     $ python prog.py 4 -v 1
     4^2 == 16
     $ python prog.py 4 -v 2
     the square of 4 equals 16
     $ python prog.py 4 -v 3
     16

プログラムのバグである最後の結果を除いて、上手く行っているようです。この
バグを、‘--verbosity’ オプションが取れる値を制限することで修正しましょう
:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", type=int,
                         help="display a square of a given number")
     parser.add_argument("-v", "--verbosity", type=int, choices=[0, 1, 2],
                         help="increase output verbosity")
     args = parser.parse_args()
     answer = args.square**2
     if args.verbosity == 2:
         print(f"the square of {args.square} equals {answer}")
     elif args.verbosity == 1:
         print(f"{args.square}^2 == {answer}")
     else:
         print(answer)

実行してみましょう:

     $ python prog.py 4 -v 3
     usage: prog.py [-h] [-v {0,1,2}] square
     prog.py: error: argument -v/--verbosity: invalid choice: 3 (choose from 0, 1, 2)
     $ python prog.py 4 -h
     usage: prog.py [-h] [-v {0,1,2}] square

     positional arguments:
       square                display a square of a given number

     options:
       -h, --help            show this help message and exit
       -v, --verbosity {0,1,2}
                             increase output verbosity

変更がエラーメッセージとヘルプメッセージの両方に反映されていることに注意
してください。

詳細レベルついて、違ったアプローチを試してみましょう。これは CPython 実
行可能ファイルがその詳細レベル引数を扱う方法と同じです。（ ‘python
--help’ の出力を確認してください）:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", type=int,
                         help="display the square of a given number")
     parser.add_argument("-v", "--verbosity", action="count",
                         help="increase output verbosity")
     args = parser.parse_args()
     answer = args.square**2
     if args.verbosity == 2:
         print(f"the square of {args.square} equals {answer}")
     elif args.verbosity == 1:
         print(f"{args.square}^2 == {answer}")
     else:
         print(answer)

もう一つの action である "count" を紹介します。これは指定されたオプショ
ンの出現回数を数えます:

     $ python prog.py 4
     16
     $ python prog.py 4 -v
     4^2 == 16
     $ python prog.py 4 -vv
     the square of 4 equals 16
     $ python prog.py 4 --verbosity --verbosity
     the square of 4 equals 16
     $ python prog.py 4 -v 1
     usage: prog.py [-h] [-v] square
     prog.py: error: unrecognized arguments: 1
     $ python prog.py 4 -h
     usage: prog.py [-h] [-v] square

     positional arguments:
       square           display a square of a given number

     options:
       -h, --help       show this help message and exit
       -v, --verbosity  increase output verbosity
     $ python prog.py 4 -vvv
     16

   * 前のバージョンのスクリプトのようにフラグ (‘action="store_true"’ に
     似ています）になりました。エラーとなる理由がわかります。（訳注: ５
     つ目の例では ‘-v’ オプションに引数を与えたため、エラーとなっていま
     す。）

   * これは"store_true" アクションによく似た動作をします。

   * では "count" アクションが何をもたらすかデモンストレーションをします
     。おそらくこのような使用方法を前に見たことがあるでしょう。

   * ‘-v’ フラグを指定しなければ、フラグの値は ‘None’ とみなされます。

   * 期待通り、長い形式のフラグを指定しても同じ結果になります。

   * 残念ながら、このヘルプ出力はプログラムが新しく得た機能についてそこ
     まで有益ではありません。しかし、スクリプトのドキュメンテーションを
     改善することでいつでも修正することができます（例えば、‘help’ キーワ
     ード引数を使用することで）。

   * 最後の出力はプログラムにバグがあることを示します。

修正しましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", type=int,
                         help="display a square of a given number")
     parser.add_argument("-v", "--verbosity", action="count",
                         help="increase output verbosity")
     args = parser.parse_args()
     answer = args.square**2

     # bugfix: replace == with >=
     if args.verbosity >= 2:
         print(f"the square of {args.square} equals {answer}")
     elif args.verbosity >= 1:
         print(f"{args.square}^2 == {answer}")
     else:
         print(answer)

これが結果です:

     $ python prog.py 4 -vvv
     the square of 4 equals 16
     $ python prog.py 4 -vvvv
     the square of 4 equals 16
     $ python prog.py 4
     Traceback (most recent call last):
       File "prog.py", line 11, in <module>
         if args.verbosity >= 2:
     TypeError: '>=' not supported between instances of 'NoneType' and 'int'

   * 最初の出力は上手くいっていますし、以前のバグが修正されています。最
     も詳細な出力を得るには、2 以上の値が必要です。

   * 三番目の結果は、よくありません。

このバグを修正しましょう:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("square", type=int,
                         help="display a square of a given number")
     parser.add_argument("-v", "--verbosity", action="count", default=0,
                         help="increase output verbosity")
     args = parser.parse_args()
     answer = args.square**2
     if args.verbosity >= 2:
         print(f"the square of {args.square} equals {answer}")
     elif args.verbosity >= 1:
         print(f"{args.square}^2 == {answer}")
     else:
         print(answer)

もう一つのキーワード引数である ‘default’ を導入しました。整数値と比較で
きるように、その値に ‘0’ を設定しました。デフォルトでは、optional 引数が
指定されていない場合 ‘None’ となること、‘None’ が整数値と比較できない（
よって *note TypeError: 502. 例外となる）ことを思い出してください。

こうなりました:

     $ python prog.py 4
     16

ここまで学んできたことだけで、さまざまな事が実現できます。しかしまだ表面
をなぞっただけです。 *note argparse: 5. モジュールはとても強力ですので、
チュートリアルを終える前にもう少しだけ探検してみましょう.


File: python.info,  Node: もうちょっとだけ学ぶ,  Next: argparse の出力を翻訳するには,  Prev: 位置引数とOptional引数の併用,  Up: Argparse チュートリアル

5.16.4.55 もうちょっとだけ学ぶ
..............................

もし、この小さなプログラムを二乗以外の累乗が行えるように拡張するとどうな
るでしょうか:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("x", type=int, help="the base")
     parser.add_argument("y", type=int, help="the exponent")
     parser.add_argument("-v", "--verbosity", action="count", default=0)
     args = parser.parse_args()
     answer = args.x**args.y
     if args.verbosity >= 2:
         print(f"{args.x} to the power {args.y} equals {answer}")
     elif args.verbosity >= 1:
         print(f"{args.x}^{args.y} == {answer}")
     else:
         print(answer)

出力:

     $ python prog.py
     usage: prog.py [-h] [-v] x y
     prog.py: error: the following arguments are required: x, y
     $ python prog.py -h
     usage: prog.py [-h] [-v] x y

     positional arguments:
       x                the base
       y                the exponent

     options:
       -h, --help       show this help message and exit
       -v, --verbosity
     $ python prog.py 4 2 -v
     4^2 == 16

これまで、出力されるテキストを '変更する' ために詳細レベルを使ってきまし
た。かわりに下記の例では、'追加の' テキストを出力するのに詳細レベルを使
用します:

     import argparse
     parser = argparse.ArgumentParser()
     parser.add_argument("x", type=int, help="the base")
     parser.add_argument("y", type=int, help="the exponent")
     parser.add_argument("-v", "--verbosity", action="count", default=0)
     args = parser.parse_args()
     answer = args.x**args.y
     if args.verbosity >= 2:
         print(f"Running '{__file__}'")
     if args.verbosity >= 1:
         print(f"{args.x}^{args.y} == ", end="")
     print(answer)

出力:

     $ python prog.py 4 2
     16
     $ python prog.py 4 2 -v
     4^2 == 16
     $ python prog.py 4 2 -vv
     Running 'prog.py'
     4^2 == 16

* Menu:

* 多義性のある引数の指定::
* 競合するオプション::


File: python.info,  Node: 多義性のある引数の指定,  Next: 競合するオプション,  Up: もうちょっとだけ学ぶ

5.16.4.56 多義性のある引数の指定
................................

ある引数の解釈について、位置引数なのか、ある引数に対する追加の引数なのか
、あいまいさがあるときは、 ‘--’ を使うことで *note parse_args(): 2bb7. に
対してこれ以降は位置引数であることを伝えることができます:

     >>> parser = argparse.ArgumentParser(prog='PROG')
     >>> parser.add_argument('-n', nargs='+')
     >>> parser.add_argument('args', nargs='*')

     >>> # ambiguous, so parse_args assumes it's an option
     >>> parser.parse_args(['-f'])
     usage: PROG [-h] [-n N [N ...]] [args ...]
     PROG: error: unrecognized arguments: -f

     >>> parser.parse_args(['--', '-f'])
     Namespace(args=['-f'], n=None)

     >>> # ambiguous, so the -n option greedily accepts arguments
     >>> parser.parse_args(['-n', '1', '2', '3'])
     Namespace(args=[], n=['1', '2', '3'])

     >>> parser.parse_args(['-n', '1', '--', '2', '3'])
     Namespace(args=['2', '3'], n=['1'])


File: python.info,  Node: 競合するオプション,  Prev: 多義性のある引数の指定,  Up: もうちょっとだけ学ぶ

5.16.4.57 競合するオプション
............................

これまでのところ、 *note argparse.ArgumentParser: 503. インスタンスの2つ
のメソッドについて学んできました。ここで3つめのメソッドとして *note
add_mutually_exclusive_group(): 2bfa. を導入しましょう。このメソッドは互
いに対立する引数の指定を可能にします。また、新しい機能として理解しやすい
ように、プログラムの残りの部分を変更しましょう: 以下では ‘--quiet’ オプ
ションを ‘--verbose’ と反対のオプションとして導入します:

     import argparse

     parser = argparse.ArgumentParser()
     group = parser.add_mutually_exclusive_group()
     group.add_argument("-v", "--verbose", action="store_true")
     group.add_argument("-q", "--quiet", action="store_true")
     parser.add_argument("x", type=int, help="the base")
     parser.add_argument("y", type=int, help="the exponent")
     args = parser.parse_args()
     answer = args.x**args.y

     if args.quiet:
         print(answer)
     elif args.verbose:
         print(f"{args.x} to the power {args.y} equals {answer}")
     else:
         print(f"{args.x}^{args.y} == {answer}")

プログラムはより簡潔になりましたが、デモのための機能が失われました。とも
かく下記が実行結果です:

     $ python prog.py 4 2
     4^2 == 16
     $ python prog.py 4 2 -q
     16
     $ python prog.py 4 2 -v
     4 to the power 2 equals 16
     $ python prog.py 4 2 -vq
     usage: prog.py [-h] [-v | -q] x y
     prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose
     $ python prog.py 4 2 -v --quiet
     usage: prog.py [-h] [-v | -q] x y
     prog.py: error: argument -q/--quiet: not allowed with argument -v/--verbose

これは分かりやすいでしょう。ここで得たちょっとした柔軟性を示すために最後
の出力を追加しました、つまり長い形式のオプションと短い形式のオプションの
混在です。

結びの前に、恐らくあなたはプログラムの主な目的をユーザに伝えたいでしょう
。万が一、彼らがそれを知らないときに備えて:

     import argparse

     parser = argparse.ArgumentParser(description="calculate X to the power of Y")
     group = parser.add_mutually_exclusive_group()
     group.add_argument("-v", "--verbose", action="store_true")
     group.add_argument("-q", "--quiet", action="store_true")
     parser.add_argument("x", type=int, help="the base")
     parser.add_argument("y", type=int, help="the exponent")
     args = parser.parse_args()
     answer = args.x**args.y

     if args.quiet:
         print(answer)
     elif args.verbose:
         print(f"{args.x} to the power {args.y} equals {answer}")
     else:
         print(f"{args.x}^{args.y} == {answer}")

使用方法のテキストが少し変化しました。‘[-v | -q]’ は ‘-v’ または ‘-q’ の
どちらかを使用できるが、同時に両方を使用できないことを意味します:

     $ python prog.py --help
     usage: prog.py [-h] [-v | -q] x y

     calculate X to the power of Y

     positional arguments:
       x              the base
       y              the exponent

     options:
       -h, --help     show this help message and exit
       -v, --verbose
       -q, --quiet


File: python.info,  Node: argparse の出力を翻訳するには,  Next: Custom type converters,  Prev: もうちょっとだけ学ぶ,  Up: Argparse チュートリアル

5.16.4.58 argparse の出力を翻訳するには
.......................................

ヘルプテキストやエラーメッセージなどの *note argparse: 5. モジュールの出
力は、すべて *note gettext: 59. モジュールを使って訳せるように作られてい
ます。これにより、 *note argparse: 5. によって生成されたメッセージを簡単
にローカライズできます。 *note プログラムやモジュールを国際化する: 2c17.
も参照してください。

たとえば、この *note argparse: 5. の出力では:

     $ python prog.py --help
     usage: prog.py [-h] [-v | -q] x y

     calculate X to the power of Y

     positional arguments:
       x              the base
       y              the exponent

     options:
       -h, --help     show this help message and exit
       -v, --verbose
       -q, --quiet

文字列 ‘usage:’, ‘positional arguments:’, ‘options:’ と ‘show this help
message and exit’ はすべて訳せます。

これらの文字列を訳すには、それらをまず ‘.po’ ファイルに抽出する必要があ
ります。たとえば、 Babel(1) を使い、次のコマンドを実行します。

     $ pybabel extract -o messages.po /usr/lib/python3.12/argparse.py

このコマンドは *note argparse: 5. モジュールからすべての翻訳可能な文字列
を抽出し、それらを ‘messages.po’ という名前のファイルに出力します。この
コマンドは Python のインストールが ‘/usr/lib’ にあることを前提としていま
す。

システム上の *note argparse: 5. モジュールの場所は、次のスクリプトで調べ
られます:

     import argparse
     print(argparse.__file__)

‘.po’ ファイル内のメッセージが訳され、その訳が *note gettext: 59. を用い
てインストールされると、 *note argparse: 5. は翻訳されたメッセージを表示
できるようになります。

*note argparse: 5. 出力内のあなたの文字列を翻訳するには、 *note gettext:
59. を使います。

   ---------- Footnotes ----------

   (1) https://babel.pocoo.org/


File: python.info,  Node: Custom type converters,  Next: 結び,  Prev: argparse の出力を翻訳するには,  Up: Argparse チュートリアル

5.16.4.59 Custom type converters
................................

The *note argparse: 5. 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 *note argparse.Namespace: 2bb8.
This can be useful when you need to pre-process the input before it is
used in your program.

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.

For example, let's say you want to handle arguments with different
prefixes and process them accordingly:

     import argparse

     parser = argparse.ArgumentParser(prefix_chars='-+')

     parser.add_argument('-a', metavar='<value>', action='append',
                         type=lambda x: ('-', x))
     parser.add_argument('+a', metavar='<value>', action='append',
                         type=lambda x: ('+', x))

     args = parser.parse_args()
     print(args)

出力:

     $ python prog.py -a value1 +a value2
     Namespace(a=[('-', 'value1'), ('+', 'value2')])

In this example, we:

   * Created a parser with custom prefix characters using the
     ‘prefix_chars’ parameter.

   * 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.

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.


File: python.info,  Node: 結び,  Prev: Custom type converters,  Up: Argparse チュートリアル

5.16.4.60 結び
..............

*note argparse: 5. モジュールはここで学んだことより多くの機能を提供しま
す。モジュールのドキュメントはとても詳細で、綿密で、そしてたくさんの例が
あります。このチュートリアルの体験したことで、気がめいることなくそれらの
他の機能を会得できるに違いありません。


File: python.info,  Node: Upgrading optparse code,  Prev: Argparse チュートリアル,  Up: 例外<9>

5.16.4.61 Upgrading optparse code
.................................

Originally, the *note argparse: 5. module had attempted to maintain
compatibility with *note optparse: 90.  However, *note optparse: 90. was
difficult to extend transparently, particularly with the changes
required to support ‘nargs=’ specifiers and better usage messages.  When
most everything in *note optparse: 90. had either been copy-pasted over
or monkey-patched, it no longer seemed practical to try to maintain the
backwards compatibility.

The *note argparse: 5. module improves on the *note optparse: 90. module
in a number of ways including:

   * Handling positional arguments.

   * Supporting subcommands.

   * Allowing alternative option prefixes like ‘+’ and ‘/’.

   * Handling zero-or-more and one-or-more style arguments.

   * Producing more informative usage messages.

   * Providing a much simpler interface for custom ‘type’ and ‘action’.

A partial upgrade path from *note optparse: 90. to *note argparse: 5.:

   * Replace all *note optparse.OptionParser.add_option(): 2c1c. calls
     with *note ArgumentParser.add_argument(): 183. calls.

   * Replace ‘(options, args) = parser.parse_args()’ with ‘args =
     parser.parse_args()’ and add additional *note
     ArgumentParser.add_argument(): 183. calls for the positional
     arguments.  Keep in mind that what was previously called ‘options’,
     now in the *note argparse: 5. context is called ‘args’.

   * Replace *note optparse.OptionParser.disable_interspersed_args():
     2c1d. by using *note parse_intermixed_args(): ace. instead of *note
     parse_args(): 2bb7.

   * Replace callback actions and the ‘callback_*’ keyword arguments
     with ‘type’ or ‘action’ arguments.

   * Replace string names for ‘type’ keyword arguments with the
     corresponding type objects (e.g.  int, float, complex, etc).

   * Replace *note optparse.Values: 2c1e. with *note Namespace: 2bb8.
     and *note optparse.OptionError: 2c1f. and *note
     optparse.OptionValueError: 2c20. with *note ArgumentError: 2c0a.

   * Replace strings with implicit arguments such as ‘%default’ or
     ‘%prog’ with the standard Python syntax to use dictionaries to
     format strings, that is, ‘%(default)s’ and ‘%(prog)s’.

   * Replace the OptionParser constructor ‘version’ argument with a call
     to ‘parser.add_argument('--version', action='version',
     version='<the version>')’.


File: python.info,  Node: logging --- Python 用のログ記録手段,  Next: logging config --- ログ記録の環境設定,  Prev: argparse --- Parser for command-line options arguments and subcommands,  Up: 汎用オペレーティングシステムサービス

5.16.5 ‘logging’ -- Python 用のログ記録手段
-------------------------------------------

'ソースコード:' Lib/logging/__init__.py(1)

Important
.........

このページには、リファレンス情報だけが含まれています。チュートリアルは、
以下のページを参照してください

   * *note 基本チュートリアル: 11c6.

   * *note 上級チュートリアル: 11c7.

   * *note ロギングクックブック: 11c8.

__________________________________________________________________

このモジュールは、アプリケーションやライブラリのための柔軟なエラーログ記
録 (logging) システムを実装するための関数やクラスを定義しています。

標準ライブラリモジュールとしてログ記録 API が提供される利点は、すべての
Python モジュールがログ記録に参加できることであり、これによってあなたが
書くアプリケーションのログにサードパーティーのモジュールが出力するメッセ
ージを含ませることができます。

以下は慣用的な使い方の単純な例です:

     # myapp.py
     import logging
     import mylib
     logger = logging.getLogger(__name__)

     def main():
         logging.basicConfig(filename='myapp.log', level=logging.INFO)
         logger.info('Started')
         mylib.do_something()
         logger.info('Finished')

     if __name__ == '__main__':
         main()

     # mylib.py
     import logging
     logger = logging.getLogger(__name__)

     def do_something():
         logger.info('Doing something')

'myapp.py' を実行すれば、'myapp.log' でログが確認できます:

     INFO:__main__:Started
     INFO:mylib:Doing something
     INFO:__main__:Finished

この慣用的な使い方における重要な特色は、大部分のコードは
‘getLogger(__name__)’ で単にモジュールレベルのロガーを作るだけで、そのロ
ガーを必要なロギングに使えるということです。これは簡潔であると同時に、下
位のコードにおいて、必要に応じてきめ細やかな制御を可能にしています。モジ
ュールレベルのロガーに対するログメッセージは、最終的にルートロガーとして
知られる最上位のロガーに達するまで順次転送されます。ロギングに対するこの
ようなアプローチは、階層的ロギングとして知られています。

ロギングを有用なものとするためには、用途に応じて構成する必要があります:
ログレベルの設定や各ロガーの出力先から、潜在的には特定のモジュールに対す
る振る舞いの変更などを、しばしばコマンドライン引数かアプリケーションの構
成の一部として。上記の例を含めて、ほとんどの場合ではルートロガーのみを構
成するだけで十分です。なぜならモジュールレベルの全ての下位のロガーは、全
てのメッセージを最終的にルートロガーのハンドラに転送するからです。 *note
basicConfig(): 9ce. は、多くのユースケースを上手に扱うことのできる簡便な
ルートロガーの構成方法を提供します。

このモジュールは、多くの機能性と柔軟性を提供します。ロギングに慣れていな
いなら、使い方を理解する最良の方法はチュートリアルを読むことです ('右上
のリンクを参照してください')。

モジュールで定義されている基本的なクラスと、その属性およびメソッドを以下
に列挙します。

   * ロガーは、アプリケーションコードが直接使うインターフェースを公開し
     ます。

   * ハンドラは、(ロガーによって生成された) ログ記録を適切な送信先に送り
     ます。

   * フィルタは、どのログ記録を出力するかを決定する、きめ細かい機能を提
     供します。

   * フォーマッタは、ログ記録が最終的に出力されるレイアウトを指定します
     。

* Menu:

* ロガーオブジェクト::
* ロギングレベル::
* ハンドラオブジェクト::
* フォーマッタオブジェクト::
* フィルタオブジェクト::
* LogRecord オブジェクト::
* LogRecord 属性::
* LoggerAdapter オブジェクト::
* スレッドセーフ性::
* モジュールレベルの関数::
* モジュールレベル属性::
* warnings モジュールとの統合::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/logging/__init__.py


File: python.info,  Node: ロガーオブジェクト,  Next: ロギングレベル,  Up: logging --- Python 用のログ記録手段

5.16.5.1 ロガーオブジェクト
...........................

ロガーには以下のような属性とメソッドがあります。 ロガーを直接インスタン
ス化することは '絶対に' してはならず、常にモジュール関数
‘logging.getLogger(name)’ を介してインスタンス化することに注意してくださ
い。 同じ name で *note getLogger(): 92e. を複数回呼び出すと、常に同じロ
ガー・オブジェクトへの参照が返されます。

‘name’ は、潜在的に ‘foo.bar.baz’ のようなピリオドで区切られた階層的な値
です (ただし、たとえば ‘foo’ のような単純な値も可能です)。階層構造の下位
にあるロガーは、上位のロガーの子になります。たとえば ‘foo’ という名前の
ロガーに対して、 ‘foo.bar’、 ‘foo.bar.baz’、 ‘foo.bam’ という名前のロガ
ーは全て ‘foo’ の子孫です。さらに、全てのロガーはルートロガーの子孫です
。ロガー名の階層構造は Python パッケージの階層構造に類似しています。また
、推奨される構築方法である ‘logging.getLogger(__name__)’ を使ってモジュ
ール単位でロガーを構築すれば、パッケージの階層構造とロガーの階層構造は同
一になります。なぜなら、モジュールの中で、 ‘__name__’ は Python パッケー
ジの名前空間におけるモジュール名だからです。

 -- クラス: logging.Logger

      -- の属性: name

          ロガーの名前です。また、ロガーを取得するために *note
          getLogger(): 92e. を呼び出すときに渡された値です。

               注釈: この属性は読み出し専用として扱われるべきです。

      -- の属性: level

          *note setLevel(): 1436. メソッドで設定された、このロガーのしき
          い値です。

               注釈: この属性を直接設定しないでください - *note
               setLevel(): 1436. は渡されたレベルをチェックする機能を持
               っていますので、常にこのメソッドを使うようにしてください
               。

      -- の属性: parent

          このロガーの親にあたるロガーです。名前空間の階層構造で上位にあ
          たるロガーのインスタンス化により、親ロガーは変わる可能性があり
          ます。

               注釈: この値は読み出し専用として取り扱われるべきです。

      -- の属性: propagate

          この属性が真と評価された場合、このロガーに記録されたイベントは
          、このロガーに取り付けられた全てのハンドラに加え、上位 (祖先)
          ロガーのハンドラにも渡されます。 メッセージは、祖先ロガーのハ
          ンドラに直接渡されます - 今問題にしている祖先ロガーのレベルも
          フィルタも、どちらも考慮されません。

          この値の評価結果が偽になる場合、ロギングメッセージは祖先ロガー
          のハンドラに渡されません。

          具体的な例で説明します: ‘A.B.C’ という名前のロガーの propagate
          属性が真と評価された場合、
          ‘logging.getLogger('A.B.C').error(...)’ のようなメソッドの呼び
          出しを通じて ‘A.B.C’ に記録された全てのイベントは、 [ログレベ
          ルとフィルタの設定を満たした場合に限り] 最初に ‘A.B.C’ に接続
          されたハンドラに渡され、その後 ‘A.B’, ‘A’ という名前のロガー、
          そしてルートロガーという順番で各ロガーに接続されたハンドラに渡
          されます。この連鎖構造において ‘A.B.C’, ‘A.B’, ‘A’ のいずれか
          の ‘propagate’ 属性が偽に設定された場合、そのロガーがイベント
          を処理する最後のロガーとなり、その時点でイベントの伝播は止まり
          ます。

          コンストラクタはこの属性を ‘True’ に設定します。

               注釈: ハンドラを、あるロガー 'と' その祖先のロガーに接続
               した場合、同一レコードが複数回発行される場合があります。
               一般的に、ハンドラを複数のロガーに接続する必要はありませ
               ん。propagate 設定が ‘True’ のままになっていれば、ロガー
               の階層において最上位にある適切なロガーにハンドラを接続す
               るだけで、そのハンドラは全ての子孫ロガーが記録する全ての
               イベントを確認することができます。一般的なシナリオでは、
               ハンドラをルートロガーに対してのみ接続し、残りは
               propagate にすべて委ねます。

      -- の属性: handlers

          このロガーインスタンスに直接接続されているハンドラのリストです
          。

               注釈: この属性は読み出し専用として取り扱われるべきです; 通
               常この属性は *note addHandler(): 2c29. と *note
               removeHandler(): 2c2a. の2つのメソッドを介して変更されま
               す。これらのメソッドはスレッドセーフな処理を保証するため
               にロックを活用します。

      -- の属性: disabled

          この属性は、いかなるイベントの処理も作動しないようにします。イ
          ニシャライザはこの属性に ‘False’ を設定します。また、この属性
          はロギングを設定するコードによってのみ変更されます。

               注釈: この属性は読み出し専用として扱われるべきです。

      -- メソッド: setLevel (level)

          このロガーの閾値を 'level' に設定します。 'level' よりも深刻で
          ないログメッセージは無視されます; 深刻さが 'level' 以上のログ
          メッセージは、ハンドラのレベルが 'level' より上に設定されてい
          ない限り、このロガーに取り付けられているハンドラによって投げら
          れます。

          ロガーが生成された際、レベルは *note NOTSET: 2c2c. (これにより
          すべてのメッセージについて、ロガーがルートロガーであれば処理さ
          れる、そうでなくてロガーが非ルートロガーの場合には親ロガーに委
          譲させる) に設定されます。 ルートロガーは *note WARNING: 1c5f.
          レベルで生成されることに注意してください。

          「親ロガーに委譲」という用語の意味は、もしロガーのレベルが
          NOTSET ならば、祖先ロガーの系列の中を NOTSET 以外のレベルの祖
          先を見つけるかルートに到達するまで辿っていく、ということです。

          もし NOTSET 以外のレベルの祖先が見つかったなら、その祖先のレベ
          ルが探索を開始したロガーの実効レベルとして扱われ、ログイベント
          がどのように処理されるかを決めるのに使われます。

          ルートに到達した場合、ルートのレベルが NOTSET ならばすべてのメ
          ッセージは処理されます。そうでなければルートのレベルが実効レベ
          ルとして使われます。

          レベルの一覧については *note ロギングレベル: 626. を参照してく
          ださい。

          バージョン 3.2 で変更: 'level' パラメータは、 *note INFO:
          1c5e. のような整数定数の代わりに 'INFO' のようなレベルの文字列
          表現も受け付けるようになりました。ただし、レベルは内部で整数と
          して保存されますし、 *note getEffectiveLevel(): 2c2d. や *note
          isEnabledFor(): 12c4. といったメソッドは、整数を返し、また渡さ
          れるものと期待します。

      -- メソッド: isEnabledFor (level)

          深刻度が 'lvl' のメッセージが、このロガーで処理されることにな
          っているかどうかを示します。このメソッドはまず、
          ‘logging.disable(level)’ で設定されるモジュールレベルの深刻度
          レベルを調べ、次にロガーの実効レベルを *note
          getEffectiveLevel(): 2c2d. で調べます。

      -- メソッド: getEffectiveLevel ()

          このロガーの実効レベルを示します。 *note NOTSET: 2c2c. 以外の
          値が *note setLevel(): 1436. で設定されていた場合、その値が返
          されます。そうでない場合、 *note NOTSET: 2c2c. 以外の値が見つ
          かるまでロガーの階層をルートロガーの方向に追跡します。見つかっ
          た場合、その値が返されます。返される値は整数で、典型的には
          *note logging.DEBUG: 1c5d, *note logging.INFO: 1c5e. 等のうち
          一つです。

      -- メソッド: getChild (suffix)

          このロガーの子であるロガーを、接頭辞によって決定し、返します。
          従って、‘logging.getLogger('abc').getChild('def.ghi')’ は、
          ‘logging.getLogger('abc.def.ghi')’ によって返されるのと同じロ
          ガーを返すことになります。これは簡便なメソッドで、親ロガーがリ
          テラルでなく ‘__name__’ などを使って名付けられているときに便利
          です。

          Added in version 3.2.

      -- メソッド: getChildren ()

          このロガーの直接の子であるロガーの集合を返します。したがって、
          たとえば ‘logging.getLogger().getChildren()’ は ‘foo’ や ‘bar’
          といった名前のロガーを含む集合を返すかもしれませんが、
          ‘foo.bar’ という名前のロガーは戻り値の集合には含まれません。同
          様に、 ‘logging.getLogger('foo').getChildren()’ は ‘foo.bar’ と
          いう名前のロガーを含む集合を返すかもしれませんが、
          ‘foo.bar.baz’ のような名前のロガーは戻り値の集合には含まれませ
          ん。

          Added in version 3.12.

      -- メソッド: debug (msg, *args, **kwargs)

          レベル *note DEBUG: 1c5d. のメッセージをこのロガーで記録します
          。 'msg' はメッセージの書式文字列で、 'args' は 'msg' に文字列
          書式化演算子を使って取り込むための引数です。 (これは、書式化文
          字列の中でキーワードを使い、引数として単一の辞書を渡すことがで
          きる、ということを意味します。) 'args' が提供されない場合は
          'msg' の%フォーマットは実行されません。

          'kwargs' のうち、 'exc_info', 'stack_info', 'stacklevel',
          'extra' という4つのキーワード引数の中身を調べます。

          'exc_info' は、この値の評価値が false でない場合、例外情報がロ
          ギングメッセージに追加されます。もし例外情報をあらわすタプル
          (*note sys.exc_info(): 656. 関数によって戻されるフォーマットに
          おいて)、または、例外情報をあらわすインスタンスが与えられてい
          れば、それが使用されることになります。それ以外の場合には、
          *note sys.exc_info(): 656. を呼び出して例外情報を取得します。

          2つ目の省略可能なキーワード引数は 'stack_info' で、デフォルト
          は ‘False’ です。真の場合、実際のロギング呼び出しを含むスタッ
          ク情報がロギングメッセージに追加されます。これは 'exc_info' 指
          定によって表示されるスタック情報と同じものではないことに注意し
          てください: 前者はカレントスレッド内での、一番下からロギング呼
          び出しまでのスタックフレームですが、後者は例外に呼応して、例外
          ハンドラが見つかるところまで巻き戻されたスタックフレームの情報
          です。

          'exc_info' とは独立に 'stack_info' を指定することもできます (例
          えば、例外が上げられなかった場合でも、コード中のある地点にどの
          ように到着したかを単に示すために)。スタックフレームは、次のよ
          うなヘッダー行に続いて表示されます:

               Stack (most recent call last):

          これは、例外フレームを表示する場合に使用される ‘Traceback
          (most recent call last):’ を模倣します。

          3番目のオプションキーワード引数は 'stacklevel' で、デフォルト
          は ‘1’ です。もしこれが1よりも大きい場合は、 *note LogRecord:
          fb3. 内で行番号と関数名を算出する時に、指定されたスタックフレ
          ームの数をスキップします。これはログヘルパー内部で使われる場合
          、関数名、ファイル名、行番号はそのヘルパーの情報ではなく、その
          ヘルパーを呼び出した呼び出し元のものになります。このパラメータ
          の名前は *note warnings: fa. モジュールと同じものになります。

          4番目のキーワード引数は 'extra' で、ロギングイベントの際に作ら
          れる *note LogRecord: fb3. の *note __dict__: 526. 属性に、ユ
          ーザー定義の属性を追加するための辞書を渡すのに使うことができま
          す。これら追加の属性は、好きなように使うことができます。たとえ
          ば、それらをログメッセージに埋め込むことができます。使用例:

               FORMAT = '%(asctime)s %(clientip)-15s %(user)-8s %(message)s'
               logging.basicConfig(format=FORMAT)
               d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
               logger = logging.getLogger('tcpserver')
               logger.warning('Protocol problem: %s', 'connection reset', extra=d)

          これは以下のような出力を行います

               2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset

          'extra' に渡される辞書のキーはロギングシステムで使われているも
          のと衝突してはいけません。 (ロギングシステムが使うキーの詳細に
          ついては *note LogRecord 属性: 2c2e. の節を参照してください。)

          これらの属性をログメッセージに使うことにしたなら、少し注意が必
          要です。上の例では、 'clientip' と 'user' が *note LogRecord:
          fb3. の属性辞書に含まれていることを期待した書式文字列で *note
          Formatter: 143a. がセットアップされています。もしこれらが欠け
          ていると、書式化例外が発生してしまうためメッセージはログに残り
          ません。したがってこの場合、常にこれらのキーを含む 'extra' 辞
          書を渡す必要があります。

          このようなことは煩わしいかもしれませんが、この機能は限定された
          場面で使われるように意図しているものなのです。たとえば同じコー
          ドがいくつものコンテキストで実行されるマルチスレッドのサーバで
          、興味のある条件が現れるのがそのコンテキストに依存している (上
          の例で言えば、リモートのクライアント IP アドレスや認証されたユ
          ーザ名など)、というような場合です。そういった場面では、それ用
          の *note Formatter: 143a. が特定の *note Handler: 1439. と共に
          使われるというのはよくあることです。

          このロガー (および *note Logger.propagate: 1438. 属性を考慮し
          た上で実効的にイベントが伝播する祖先のロガー) にハンドラが接続
          されていない場合、メッセージは *note lastResort: 11cb. に設定
          されたハンドラーに送られます。

          バージョン 3.2 で変更: 'stack_info' パラメータが追加されました
          。

          バージョン 3.5 で変更: 'exc_info' パラメータは例外インスタンス
          を受け入れることが可能です。

          バージョン 3.8 で変更: 'stacklevel' 引数が追加されました。

      -- メソッド: info (msg, *args, **kwargs)

          レベル *note INFO: 1c5e. のメッセージをこのロガーで記録します
          。引数は *note debug(): 2c2f. と同じように解釈されます。

      -- メソッド: warning (msg, *args, **kwargs)

          レベル *note WARNING: 1c5f. のメッセージをこのロガーで記録しま
          す。引数は *note debug(): 2c2f. と同じように解釈されます。

               注釈: ‘warning’ と機能的に等価な古いメソッド ‘warn’ があ
               ります。‘warn’ は廃止予定なので使わないでください - 代わ
               りに ‘warning’ を使ってください。

      -- メソッド: error (msg, *args, **kwargs)

          レベル *note ERROR: 1c60. のメッセージをこのロガーで記録します
          。引数は *note debug(): 2c2f. と同じように解釈されます。

      -- メソッド: critical (msg, *args, **kwargs)

          レベル *note CRITICAL: 1c61. のメッセージをこのロガーで記録し
          ます。引数は *note debug(): 2c2f. と同じように解釈されます。

      -- メソッド: log (level, msg, *args, **kwargs)

          整数で表したレベル 'level' のメッセージをこのロガーで記録しま
          す。その他の引数は *note debug(): 2c2f. と同じように解釈されま
          す。

      -- メソッド: exception (msg, *args, **kwargs)

          レベル *note ERROR: 1c60. のメッセージをこのロガーで記録します
          。引数は *note debug(): 2c2f. と同じように解釈されます。例外情
          報がログメッセージに追加されます。このメソッドは例外ハンドラか
          らのみ呼び出されるべきです。

      -- メソッド: addFilter (filter)

          指定されたフィルタ 'filter' をこのロガーに追加します。

      -- メソッド: removeFilter (filter)

          指定されたフィルタ 'filter' をこのロガーから取り除きます。

      -- メソッド: filter (record)

          レコードに対してこのロガーのフィルタを適用し、レコードが処理さ
          れるべき場合に ‘True’ を返します。フィルタのいずれかの値が偽を
          返すまで、それらは順番に試されていきます。いずれも偽を返さなけ
          れば、レコードは処理される(ハンドラに渡される)ことになります。
          ひとつでも偽を返せば、発生したレコードはもはや処理されることは
          ありません。

      -- メソッド: addHandler (hdlr)

          指定されたハンドラ 'hdlr' をこのロガーに追加します。

      -- メソッド: removeHandler (hdlr)

          指定されたハンドラ 'hdlr' をこのロガーから取り除きます。

      -- メソッド: findCaller (stack_info=False, stacklevel=1)

          呼び出し元のソースファイル名と行番号を調べます。ファイル名と行
          番号、関数名、スタック情報を 4 要素のタプルで返します。
          'stack_info' が ‘True’ でなければ、スタック情報は ‘None’ が返
          されます。

          'stacklevel' パラメータは *note debug(): 2c2f. や他のAPIを呼び
          出すコードから渡されます。もしこれが1よりも大きい場合は、その
          超過分は返す値を決定する前にスタックフレームをスキップする数と
          して利用されます。これは通常、ログAPIをヘルパーやラッパー経由
          で呼び出す場合に便利です。こうすることで、イベントログに記録さ
          れる情報はヘルパーやラッパーのコードではなく、それらを呼び出し
          ているコードのものとなります。

      -- メソッド: handle (record)

          レコードを、このロガーおよびその上位ロガー (ただし 'propagate'
          の値が false になったところまで) に関連付けられているすべての
          ハンドラに渡して処理します。このメソッドは、ローカルで生成され
          たレコードだけでなく、ソケットから受信した unpickle されたレコ
          ードに対しても同様に用いられます。 *note filter(): 2c33. によ
          って、ロガーレベルでのフィルタが適用されます。

      -- メソッド: makeRecord (name, level, fn, lno, msg, args,
               exc_info, func=None, extra=None, sinfo=None)

          このメソッドは、特殊な *note LogRecord: fb3. インスタンスを生
          成するためにサブクラスでオーバライドできるファクトリメソッドで
          す。

      -- メソッド: hasHandlers ()

          このロガーにハンドラが設定されているかどうかを調べます。 その
          ために、このロガーとロガー階層における祖先からハンドラを探しま
          す。 ハンドラが見つかれば ‘True’ 、そうでなければ ‘False’ を返
          します。 このメソッドは、'propagate' 属性が偽に設定されたロガ
          ーを見つけると、さらに上位の探索をやめます。そのロガーが、ハン
          ドラが存在するかどうかチェックされる最後のロガーになります。

          Added in version 3.2.

     バージョン 3.7 で変更: ロガーの pickle 化と unpickle 化ができるよう
     になりました。


File: python.info,  Node: ロギングレベル,  Next: ハンドラオブジェクト,  Prev: ロガーオブジェクト,  Up: logging --- Python 用のログ記録手段

5.16.5.2 ロギングレベル
.......................

ログレベルの数値は以下の表のように与えられています。これらは基本的に自分
でレベルを定義したい人のためのもので、定義するレベルを既存のレベルの間に
位置づけるためには具体的な値が必要になります。もし数値が他のレベルと同じ
だったら、既存の値は上書きされその名前は失われます。

レベル                      数値                どういう意味か / いつ使用するべきか
                                                
------------------------------------------------------------------------------------------
                                                
 -- データ:                 0                   ロガーに対してこのレベルが設定された場
          logging.NOTSET                        合、実際のログレベルは祖先のロガーを参
                                                照して決めることを意味します。実効ログ
                                                レベルも ‘NOTSET’ となった場合は、全て
                                                のイベントが記録されます。ハンドラーに
                                                対してこのレベルが設定された場合、全て
                                                のイベントが処理されます。
                                                
                                                
 -- データ: logging.DEBUG   10                  詳細情報。典型的には、問題が発生した際
                                                に原因を突き止めようとする開発者向けの
                                                情報。
                                                
                                                
 -- データ: logging.INFO    20                  想定された通りのことが起こったことの確
                                                認。
                                                
                                                
 -- データ:                 30                  想定外の事象、または近い将来に問題が起
          logging.WARNING                       きる可能性 (たとえば 'disk space low' す
                                                なわちディスク空き容量の低下) の表示。
                                                ソフトウエアは引き続き期待通りに動作し
                                                ている状態。
                                                
                                                
 -- データ: logging.ERROR   40                  より重大な問題により、ソフトウェアがあ
                                                る機能を実行できないこと。
                                                
                                                
 -- データ:                 50                  プログラム自体が実行を続けられないこと
          logging.CRITICAL                      を表す、重大なエラー。
                                                


File: python.info,  Node: ハンドラオブジェクト,  Next: フォーマッタオブジェクト,  Prev: ロギングレベル,  Up: logging --- Python 用のログ記録手段

5.16.5.3 ハンドラオブジェクト
.............................

ハンドラ (Handler) は以下の属性とメソッドを持ちます。 *note Handler:
1439. は直接インスタンス化されることはありません; このクラスはより便利な
サブクラスの基底クラスとして働きます。しかしながら、サブクラスにおける
‘__init__()’ メソッドでは、 *note Handler.__init__(): 2c3b. を呼び出す必
要があります。

 -- クラス: logging.Handler

      -- メソッド: __init__ (level=NOTSET)

          レベルを設定して、 *note Handler: 1439. インスタンスを初期化し
          ます。空のリストを使ってフィルタを設定し、 I/O 機構へのアクセ
          スを直列化するために (*note createLock(): 2c3c. を使って) ロッ
          クを生成します。

      -- メソッド: createLock ()

          スレッドセーフでない背後の I/O 機能に対するアクセスを直列化す
          るために用いられるスレッドロック (thread lock) を初期化します
          。

      -- メソッド: acquire ()

          *note createLock(): 2c3c. で生成されたスレッドロックを獲得しま
          す。

      -- メソッド: release ()

          *note acquire(): 2c3d. で獲得したスレッドロックを解放します。

      -- メソッド: setLevel (level)

          このハンドラに対する閾値を 'level' に設定します。 'level' より
          も深刻でないログメッセージは無視されます。 ハンドラが生成され
          た際、レベルは *note NOTSET: 2c2c. (すべてのメッセージが処理さ
          れる) に設定されます。

          レベルの一覧については *note ロギングレベル: 626. を参照してく
          ださい。

          バージョン 3.2 で変更: 'level' パラメータは、 *note INFO:
          1c5e. のような整数定数の代わりに 'INFO' のようなレベルの文字列
          表現も受け付けるようになりました。

      -- メソッド: setFormatter (fmt)

          このハンドラの *note Formatter: 143a. を 'fmt' に設定します。

      -- メソッド: addFilter (filter)

          指定されたフィルタ 'filter' をこのハンドラに追加します。

      -- メソッド: removeFilter (filter)

          指定されたフィルタ 'filter' をこのハンドラから除去します。

      -- メソッド: filter (record)

          レコードに対してこのハンドラのフィルタを適用し、レコードが処理
          されるべき場合に ‘True’ を返します。フィルタのいずれかの値が偽
          を返すまで、それらは順番に試されていきます。いずれも偽を返さな
          ければ、レコードは発行されることになります。ひとつでも偽を返せ
          ば、ハンドラはレコードを発行しません。

      -- メソッド: flush ()

          すべてのログ出力がフラッシュされるようにします。このクラスのバ
          ージョンではなにも行わず、サブクラスで実装するためのものです。

      -- メソッド: close ()

          ハンドラで使われているすべてのリソースの後始末を行います。この
          バージョンでは何も出力せず、 *note shutdown(): 2c46. が呼ばれ
          たときに閉じられたハンドラを内部リストから削除します。サブクラ
          スではオーバライドされた *note close(): 2c45. メソッドからこの
          メソッドが必ず呼ばれるようにしてください。

      -- メソッド: handle (record)

          ハンドラに追加されたフィルタの条件に応じて、指定されたログレコ
          ードを出力します。このメソッドは I/O スレッドロックの獲得/解放
          を伴う実際のログ出力をラップします。

      -- メソッド: handleError (record)

          このメソッドは、 *note emit(): 2c49. の呼び出し中に例外に遭遇
          した際にハンドラから呼び出されることを想定しています。モジュー
          ルレベルの属性 *note raiseExceptions: 11ca. が ‘False’ の場合
          、例外は静かに無視されます。これは、ほとんどの場合でロギングシ
          ステムに期待される挙動です - なぜなら、ほとんどのユーザーはロ
          ギングシステムの中で起こったエラーなどに興味はなく、アプリケー
          ションエラーの方により関心があるからです。しかし、必要ならばこ
          の挙動を自作のハンドラで置き換えることができます。引数に指定さ
          れたレコードは例外発生時に処理されるものです。 (*note
          raiseExceptions: 11ca. のデフォルト値は、開発中にはその方が便
          利なので、 ‘True’ です)。

      -- メソッド: format (record)

          レコードに対する書式化を行います - フォーマッタが設定されてい
          れば、それを使います。そうでない場合、モジュールにデフォルト指
          定されたフォーマッタを使います。

      -- メソッド: emit (record)

          指定されたログ記録レコードを実際にログ記録する際のすべての処理
          を行います。このメソッドはサブクラスで実装されることを意図して
          おり、そのためこのクラスのバージョンは *note
          NotImplementedError: 209. を送出します。

               警告: このメソッドはハンドラレベルのロックを取得した後で
               呼び出されます。また、ロックはこのメソッドがリターンした
               後で解放されます。このメソッドをオーバーライドする場合、
               ロックを取得する可能性のある logging API の他の関数やメソ
               ッドの呼び出しに注意してください。そのような実装はデッド
               ロックを引き起こす可能性があります。特に以下の点に注意し
               てください:

                  * ロギングを構成するための API はモジュールレベルのロ
                    ックを取得し、その後ハンドラを構成する際に個々のハン
                    ドラに対してハンドラレベルのロックを取得します。

                  * 多くのロギング API はモジュールレベルのロックを取得
                    します。そのような API がこのメソッドから呼ばれた場
                    合、他のスレッドからロギングを構成するための API 呼
                    び出しが行われたときにデッドロックに陥る可能性があり
                    ます。これは他のスレッドがハンドラレベルのロックを取
                    得する '前に' モジュールレベルのロックを取得しようと
                    する一方で、 (このメソッドはハンドラレベルのロックが
                    既に取得された状態で呼び出されているため) このメソッ
                    ドを呼び出したスレッドはハンドラレベルのロックを取得
                    した '後で' モジュールレベルのロックを取得しようとす
                    るためです。

標準として含まれているハンドラについては、 *note logging.handlers: 7d. を
参照してください。


File: python.info,  Node: フォーマッタオブジェクト,  Next: フィルタオブジェクト,  Prev: ハンドラオブジェクト,  Up: logging --- Python 用のログ記録手段

5.16.5.4 フォーマッタオブジェクト
.................................

 -- クラス: logging.Formatter (fmt=None, datefmt=None, style='%',
          validate=True, *, defaults=None)

     *note LogRecord: fb3. を、人間または外部のシステムが解釈可能な出力
     文字列に変換する責任を持ちます。


     パラメータ:

        * ‘fmt’ (*note str: 418.) - 'style' で指定された書式にもとづく、
          出力ログ全体に対する書式文字列です。マッピングのキーは *note
          LogRecord: fb3. オブジェクトの *note LogRecord 属性: 2c2e. か
          ら取り出されます。特に指定がない場合は、ログメッセージをあらわ
          す ‘'%(message)s'’ が使われます。

        * ‘datefmt’ (*note str: 418.) - 'style' で指定された書式にもとづ
          く、出力ログの日時を示す部分に対する書式文字列です。特に指定が
          ない場合、 *note formatTime(): 2c4d. で記述されているデフォル
          トが使われます。

        * ‘style’ (*note str: 418.) - ‘'%'’, または ‘'$'’ のいずれかで、
          書式文字列がログデータとどのようにマージされるかを決めます:
          *note printf 形式の文字列書式化: 698. (‘%’), *note
          str.format(): 5ed. (‘{’) または *note string.Template: 653. ()
          のいずれかを使います。この引数は 'fmt' と 'datefmt' だけに適用
          されます (たとえば ‘'%(message)s'’ に対して ‘'{message}'’) が
          、ロギングメソッドに渡された実際のログメッセージには適用されま
          せん。いっぽう、 ‘'{'’ や ‘$’ を使ってログメッセージをフォーマ
          ットする *note 他の方法: 2c4e. も存在します。

        * ‘validate’ (*note bool: 434.) - ‘True’ が指定されると (デフォ
          ルト) 、 'fmt' と 'style' が不正な場合や、それらが不適切な組み
          合わせだった場合に *note ValueError: 1e3. 例外を送出します; た
          とえば ‘logging.Formatter('%(asctime)s - %(message)s',
          style='{')’ は例外となります。

        * ‘defaults’ (*note dict: 237.‘[’*note str: 418.‘, ’‘Any’‘]’) -
          カスタムフィールドに使用されるデフォルト値を指定する辞書です。
          例えば ‘logging.Formatter('%(ip)s %(message)s',
          defaults={"ip": None})’ のように使います。

     バージョン 3.2 で変更: 'style' パラメータが追加されました。

     バージョン 3.8 で変更: 'validate' パラメータが追加されました。

     バージョン 3.10 で変更: 'defaults' パラメータが追加されました。

      -- メソッド: format (record)

          レコードの属性辞書が、文字列を書式化する演算で被演算子として使
          われます。書式化された結果の文字列を返します。辞書を書式化する
          前に、二つの準備段階を経ます。レコードの 'message' 属性が
          'msg' % 'args' を使って処理されます。書式化された文字列が
          ‘'(asctime)'’ を含むなら、 *note formatTime(): 2c4d. が呼び出
          され、イベントの発生時刻を書式化します。例外情報が存在する場合
          、 *note formatException(): 2c50. を使って書式化され、メッセー
          ジに追加されます。ここで注意していただきたいのは、書式化された
          例外情報は 'exc_text' にキャッシュされるという点です。これが有
          用なのは例外情報がピックル化されて回線上を送ることができるから
          ですが、しかし二つ以上の *note Formatter: 143a. サブクラスで例
          外情報の書式化をカスタマイズしている場合には注意が必要になりま
          す。この場合、フォーマッタが書式化を終えるごとにキャッシュをク
          リアして（ 'ext_text' 属性に ‘None’ を設定して）、次のフォーマ
          ッタがキャッシュされた値を使わずに新鮮な状態で再計算するように
          しなければならないことになります。

          スタック情報が利用可能な場合、(必要ならば *note formatStack():
          2c51. を使って整形した上で) スタック情報が例外情報の後に追加さ
          れます。

      -- メソッド: formatTime (record, datefmt=None)

          このメソッドは、フォーマッタが書式化された時間を利用したい際に
          、 *note format(): 5eb. から呼び出されます。 このメソッドは特
          定の要求を提供するためにフォーマッタで上書きすることができます
          が、基本的な振る舞いは以下のようになります: 'datefmt' (文字列)
          が指定された場合、レコードが生成された時刻を書式化するために
          *note time.strftime(): 11ba. で使われます。 そうでない場合、
          '%Y-%m-%d %H:%M:%S,uuu' というフォーマットが使われます。 uuu 部
          分はミリ秒値で、それ以外の文字は *note time.strftime(): 11ba.
          ドキュメントに従います。 このフォーマットの時刻の例は
          ‘2003-01-23 00:29:50,411’ です。 結果の文字列が返されます。

          この関数は、ユーザが設定できる関数を使って、生成時刻をタプルに
          変換します。デフォルトでは、 *note time.localtime(): 14a2. が
          使われます。特定のフォーマッタインスタンスに対してこれを変更す
          るには、 ‘converter’ 属性を *note time.localtime(): 14a2. や
          *note time.gmtime(): 1190. と同じ署名をもつ関数に設定してくだ
          さい。すべてのフォーマッタインスタンスに対してこれを変更するに
          は、例えば全てのロギング時刻を GMT で表示するには、
          ‘Formatter’ クラスの ‘converter’ 属性を設定してください。

          バージョン 3.3 で変更: 以前は、デフォルトのフォーマットがこの
          例のようにハードコーディングされていました: ‘2010-09-06
          22:38:15,292’ ここで、コンマの前の部分は strptime フォーマット
          文字列 (‘'%Y-%m-%d %H:%M:%S'’) によって扱われる部分で、コンマ
          の後の部分はミリ秒値です。strptime にミリ秒のフォーマットプレ
          ースホルダーがないので、ミリ秒値は別のフォーマット文字列
          ‘'%s,%03d'’ を使用して追加されます。そして、これらのフォーマッ
          ト文字列は両方ともこのメソッドでハードコーディングされていまし
          た。変更後は、これらの文字列はクラスレベル属性として定義され、
          必要ならインスタンスレベルでオーバーライドすることができます。
          属性の名前は ‘default_time_format’ (strptime 書式文字列用) と
          ‘default_msec_format’ (ミリ秒値の追加用) です。

          バージョン 3.9 で変更: ‘default_msec_format’ 引数が ‘None’ で
          あることを許容します。

      -- メソッド: formatException (exc_info)

          指定された例外情報 (*note sys.exc_info(): 656. が返すような標
          準例外のタプル) を文字列として書式化します。デフォルトの実装は
          単に *note traceback.print_exception(): 81a. を使います。結果
          の文字列が返されます。

      -- メソッド: formatStack (stack_info)

          指定されたスタック情報を文字列としてフォーマットします (*note
          traceback.print_stack(): e51. によって返される文字列ですが、最
          後の改行が取り除かれています)。このデフォルト実装は、単に入力
          値をそのまま返します。

 -- クラス: logging.BufferingFormatter (linefmt=None)

     複数のレコードをまとめてフォーマットしたい場合のクラス定義に適した
     基底クラスです。各行 (単一のレコードに相当します) をフォーマットす
     るために使う *note Formatter: 143a. インスタンスを渡すことができま
     す。特に指定がない場合はデフォルトのフォーマッタ (イベントのメッセ
     ージだけを出力するフォーマッタ) が使われます。

      -- メソッド: formatHeader (records)

          '複数のレコード' のリストに対するヘッダを返します。基底クラス
          の実装は単に空の文字列を返すだけです。レコード数やタイトルを表
          示したり、あるいはセパレータ行したいなど、ヘッダに対して特別な
          振る舞いが必要な場合はこのメソッドをオーバーライドする必要があ
          ります。

      -- メソッド: formatFooter (records)

          '複数のレコード' のリストに対するフッタを返します。基底クラス
          の実装は単に空の文字列を返すだけです。レコード数やセパレータ行
          の表示など、フッタに対して特別な振る舞いが必要な場合はこのメソ
          ッドをオーバーライドする必要があります。

      -- メソッド: format (records)

          '複数のレコード' のリストに対するフォーマット済みテキストを返
          します。基底クラスの実装は、レコードがなければ空の文字列を返し
          、レコードがある場合はヘッダ、単一のレコードをフォーマットする
          ためのラインフォーマッタで各レコードをフォーマットした文字列、
          そしてフッタを全て連結したものを返します。


File: python.info,  Node: フィルタオブジェクト,  Next: LogRecord オブジェクト,  Prev: フォーマッタオブジェクト,  Up: logging --- Python 用のログ記録手段

5.16.5.5 フィルタオブジェクト
.............................

‘フィルタ (Filter)’ は、‘ハンドラ’ や ‘ロガー’ によって使われ、レベルに
よって提供されるのよりも洗練されたフィルタリングを実現します。基底のフィ
ルタクラスは、ロガー階層構造内の特定地点の配下にあるイベントだけを許可し
ます。例えば、'A.B' で初期化されたフィルタは、ロガー 'A.B', 'A.B.C',
'A.B.C.D', 'A.B.D' 等によって記録されたイベントは許可しますが、'A.BB',
'B.A.B' などは許可しません。空の文字列で初期化された場合、すべてのイベン
トを通過させます。

 -- クラス: logging.Filter (name='')

     *note Filter: 11cc. クラスのインスタンスを返します。 'name' が指定
     されていれば、 'name' はロガーの名前を表します。指定されたロガーと
     その子ロガーのイベントがフィルタを通過できるようになります。 'name'
     が指定されなければ、すべてのイベントを通過させます。

      -- メソッド: filter (record)

          指定されたログレコードは記録されるでしょうか？答えが「いいえ」
          なら false を、「はい」なら true を返します。フィルタは受け取
          ったログレコードそのものを編集したり、その後のイベント処理にお
          いて元のログレコードに取って代わる、まったく異なるログレコード
          インスタンスを返す可能性があります。

ハンドラに対するフィルタはハンドラがイベントを発行する前に試され、一方で
はロガーに対するフィルタは、イベントが(*note debug(): 2c2f, *note
info(): 2c59. などによって)ロギングされる際には、ハンドラにイベントが送
信される前にはいつでも試されることに注意してください。そのフィルタがそれ
ら子孫ロガーにも適用されていない限り、子孫ロガーによって生成されたイベン
トはロガーのフィルタ設定によってフィルタされることはありません。

実際には、‘Filter’ をサブクラス化する必要はありません。同じ意味の
‘filter’ メソッドを持つ、すべてのインスタンスを通せます。

バージョン 3.2 で変更: 特殊な ‘Filter’ クラスを作ったり、 ‘filter’ メソ
ッドを持つ他のクラスを使う必要はありません: 関数 (あるいは他の callable)
をフィルタとして使用することができます。フィルタロジックは、フィルタオブ
ジェクトが ‘filter’ 属性を持っているかどうかチェックします: もし
‘filter’ 属性を持っていたら、それは ‘Filter’ であると仮定され、その
*note filter(): 2c58. メソッドが呼び出されます。そうでなければ、それは
callable であると仮定され、レコードを単一のパラメータとして呼び出されま
す。返される値は *note filter(): 2c58. によって返されるものと一致すべき
です。

バージョン 3.12 で変更: 受け取ったログレコード自体を編集する代わりに、元
のログレコードに取って代わる別の *note LogRecord: fb3. インスタンスを返
すことができるようになりました。これにより、 *note Handler: 1439. にアタ
ッチされたフィルタが、他のハンドラへの副作用を伴うことなく、発行前にログ
レコードを編集することが可能になります。

フィルタは本来、レコードをレベルよりも洗練された基準に基づいてフィルタす
るために使われますが、それが取り付けられたハンドラやロガーによって処理さ
れるレコードをすべて監視します。これは、特定のロガーやハンドラに処理され
たレコードの数を数えたり、処理されている *note LogRecord: fb3. の属性を
追加、変更、削除したりするときに便利です。もちろん、LogRecord を変更する
には注意が必要ですが、これにより、ログにコンテキスト情報を注入できます
(*note Filter を使ったコンテキスト情報の伝達: 2c5a. を参照してください
)。


File: python.info,  Node: LogRecord オブジェクト,  Next: LogRecord 属性,  Prev: フィルタオブジェクト,  Up: logging --- Python 用のログ記録手段

5.16.5.6 LogRecord オブジェクト
...............................

*note LogRecord: fb3. インスタンスは、何かをログ記録するたびに *note
Logger: b1d. によって生成されます。また、 *note makeLogRecord(): 2c5d. を
通して (例えば、ワイヤを通して受け取られた pickle 化されたイベントから)
手動で生成することも出来ます。

 -- クラス: logging.LogRecord (name, level, pathname, lineno, msg, args,
          exc_info, func=None, sinfo=None)

     ロギングされているイベントに適切なすべての情報を含みます。

     もっとも重要な情報は 'msg' と 'args' に渡され、 ‘msg % args’ で結合
     されてレコードの ‘message’ 属性を生成します。


     パラメータ:

        * ‘name’ (*note str: 418.) - この ‘LogRecord’ であらわされるイベ
          ントを記録したロガーの名前です。 ‘LogRecord’ が持つロガーの名
          前は、たとえ異なる (祖先の) ロガーに接続されたハンドラから出力
          されたとしても、常に同じ値を持つことに注意してください。

        * ‘level’ (*note int: 238.) - 記録されたイベントの *note
          数値であらわしたロギングレベル: 626. (‘10’ が ‘DEBUG’, ‘20’ が
          ‘INFO’ など) です。このパラメータは LogRecord の '2つの' 属性
          に変換されることに注意してください: 数値は ‘levelno’ に、また
          対応するログレベルの名前は ‘levelname’ に保持されます。

        * ‘pathname’ (*note str: 418.) - ロギングの呼び出しが行われたソ
          ースファイルへの完全なパス名をあらわす文字列です。

        * ‘lineno’ (*note int: 238.) - ロギングの呼び出しが発せられたソ
          ース行番号。

        * ‘msg’ (*note Any: 678.) - イベントの説明メッセージ。様々なデー
          タのプレースホルダを含んだ %フォーマット文字列か、任意のオブジ
          ェクト (*note 任意のオブジェクトをメッセージに使用する: 2c5e.
          を参照)。

        * ‘args’ (*note tuple: 349.‘ | ’*note dict: 237.‘[’*note str:
          418.‘, ’*note Any: 678.‘]’) - 'msg' 引数と組み合わせてイベント
          記述を得るための変数データです。

        * ‘exc_info’ (*note tuple: 349.‘[’*note type: d16.‘[’*note
          BaseException: 584.‘]’‘, ’*note BaseException: 584.‘, ’*note
          types.TracebackType: ac0.‘] ’‘| ’‘None’) - *note
          sys.exc_info(): 656. によって返される現在の例外情報を含む例外
          タプルです。例外情報がない場合は ‘None’ です。

        * ‘func’ (*note str: 418.‘ | ’‘None’) - ロギングの呼び出しを行っ
          た関数またはメソッドの名前です。

        * ‘sinfo’ (*note str: 418.‘ | ’‘None’) - 現在のスレッドのスタッ
          クベースからログ呼び出しまでの間のスタック情報を表わすテキスト
          文字列。

      -- メソッド: getMessage ()

          ユーザが提供した引数をメッセージに交ぜた後、この *note
          LogRecord: fb3. インスタンスへのメッセージを返します。ユーザが
          ロギングの呼び出しに与えた引数が文字列でなければ、その引数に
          *note str(): 418. が呼ばれ、文字列に変換されます。これにより、
          ‘__str__’ メソッドが実際のフォーマット文字列を返せるようなユー
          ザ定義のクラスをメッセージとして使えます。

     バージョン 3.2 で変更: *note LogRecord: fb3. の生成は、レコードを生
     成するために使用されるファクトリを提供することにより、さらに設定可
     能になりました。ファクトリは *note getLogRecordFactory(): 2c60. と
     *note setLogRecordFactory(): 2c61. を使用して設定することができます
     (ファクトリのシグネチャに関しては *note setLogRecordFactory():
     2c61. を参照)。

     この機能を使うと *note LogRecord: fb3. の生成時に独自の値を注入する
     ことができます。次のパターンが使えます:

          old_factory = logging.getLogRecordFactory()

          def record_factory(*args, **kwargs):
              record = old_factory(*args, **kwargs)
              record.custom_attribute = 0xdecafbad
              return record

          logging.setLogRecordFactory(record_factory)

     このパターンでは複数のファクトリをつなぐこともできます。それらが互
     いの属性を上書きしたりせず、また上にリストされた標準属性を意図せず
     上書きしたりしない限り、驚くようなことは何も起こりません (there
     should be no surprises)。


File: python.info,  Node: LogRecord 属性,  Next: LoggerAdapter オブジェクト,  Prev: LogRecord オブジェクト,  Up: logging --- Python 用のログ記録手段

5.16.5.7 LogRecord 属性
.......................

LogRecord には幾つかの属性があり、そのほとんどはコンストラクタの引数から
得られます。(なお、LogRecord コンストラクタの引数と LogRecord 属性が常に
厳密に対応するわけではありません。) これらの属性は、レコードからのデータ
をフォーマット文字列に統合するのに使えます。以下のテーブルに、属性名、意
味、そして % 形式フォーマット文字列における対応するプレースホルダを (ア
ルファベット順に) 列挙します。

{}-フォーマット (*note str.format(): 5ed.) を使用していれば、書式文字列
の中でプレースホールダーとして ‘{attrname}’ を使うことができます。 $-フ
ォーマット (*note string.Template: 653.) を使用している場合は、
‘${attrname}’ 形式にしてください。もちろん、両方の場合で ‘attrname’ は使
用したい実際の属性名に置き換えてください。

{}-フォーマットの場合には、属性名の後にフォーマットフラグを指定すること
ができます。属性名とフォーマットフラグの間はコロンで分割します。例: プレ
ースホールダー ‘{msecs:03.0f}’ は、ミリセカンド値 ‘4’ を ‘004’ としてフ
ォーマットします。利用可能なオプション上の全詳細に関しては *note
str.format(): 5ed. ドキュメンテーションを参照してください。

属性名               フォーマット                  説明
                                                   
-------------------------------------------------------------------------------------------------------
                                                   
‘args’               このフォーマットを自分で使    ‘msg’ に組み合わせて ‘message’ を生成するための引
                     う必要はないでしょう。        数のタプル、または、マージに用いられる辞書(引数が
                                                   一つしかなく、かつそれが辞書の場合)。
                                                   
                                                   
asctime              ‘%(asctime)s’                 *note LogRecord: fb3. が生成された時刻を人間が読
                                                   める書式で表したもの。デフォルトでは "2003-07-08
                                                   16:49:45,896" 形式 (コンマ以降の数字は時刻のミリ
                                                   秒部分) です。
                                                   
                                                   
created              ‘%(created)f’                 *note LogRecord: fb3. が生成された時刻です
                                                   (*note time.time_ns(): ab5. / 1e9 で返される形式
                                                   で)。
                                                   
                                                   
exc_info             このフォーマットを自分で使    (‘sys.exc_info’ 風の) 例外タプルか、例外が起こっ
                     う必要はないでしょう。        ていない場合は ‘None’。
                                                   
                                                   
ファイル名           ‘%(filename)s’                ‘pathname’ のファイル名部分。
                                                   
                                                   
funcName             ‘%(funcName)s’                ロギングの呼び出しを含む関数の名前。
                                                   
                                                   
levelname            ‘%(levelname)s’               メッセージのための文字のロギングレベル
                                                   (‘'DEBUG'’, ‘'INFO'’, ‘'WARNING'’, ‘'ERROR'’,
                                                   ‘'CRITICAL'’)。
                                                   
                                                   
levelno              ‘%(levelno)s’                 メッセージのための数値のロギングレベル
                                                   (*note DEBUG: 1c5d, *note INFO: 1c5e,
                                                   *note WARNING: 1c5f, *note ERROR: 1c60,
                                                   *note CRITICAL: 1c61.)。
                                                   
                                                   
lineno               ‘%(lineno)d’                  ロギングの呼び出しが発せられたソース行番号 (利用
                                                   できる場合のみ)。
                                                   
                                                   
message              ‘%(message)s’                 ‘msg % args’ として求められた、ログメッセージ。
                                                   *note Formatter.format(): 2c4f. が呼び出されたと
                                                   きに設定されます。
                                                   
                                                   
module               ‘%(module)s’                  モジュール (‘filename’ の名前部分)。
                                                   
                                                   
msecs                ‘%(msecs)d’                   *note LogRecord: fb3. が生成された時刻のミリ秒部
                                                   分。
                                                   
                                                   
msg                  このフォーマットを自分で使    元のロギングの呼び出しで渡されたフォーマット文字
                     う必要はないでしょう。        列。 ‘args’ と合わせて、 ‘message’ 、または任意の
                                                   オブジェクトを生成します
                                                   (*note 任意のオブジェクトをメッセージに使用する: 2c5e.
                                                   参照)。
                                                   
                                                   
name                 ‘%(name)s’                    ロギングに使われたロガーの名前。
                                                   
                                                   
pathname             ‘%(pathname)s’                ロギングの呼び出しが発せられたファイルの完全なパ
                                                   ス名 (利用できる場合のみ)。
                                                   
                                                   
process              ‘%(process)d’                 プロセス ID (利用可能な場合のみ)。
                                                   
                                                   
processName          ‘%(processName)s’             プロセス名 (利用可能な場合のみ)。
                                                   
                                                   
relativeCreated      ‘%(relativeCreated)d’         logging モジュールが読み込まれた時刻に対する、
                                                   LogRecord が生成された時刻を、ミリ秒で表したもの
                                                   。
                                                   
                                                   
stack_info           このフォーマットを自分で使    現在のスレッドでのスタックの底からこのレコードの
                     う必要はないでしょう。        生成に帰着したログ呼び出しまでのスタックフレーム
                                                   情報 (利用可能な場合)。
                                                   
                                                   
thread               ‘%(thread)d’                  スレッド ID (利用可能な場合のみ)。
                                                   
                                                   
threadName           ‘%(threadName)s’              スレッド名 (利用可能な場合のみ)。
                                                   
                                                   
taskName             ‘%(taskName)s’                *note asyncio.Task: 4a5. 名 (利用可能な場合のみ
                                                   )。
                                                   

バージョン 3.1 で変更: 'processName' が追加されました。

バージョン 3.12 で変更: 'taskName' が追加されました。


File: python.info,  Node: LoggerAdapter オブジェクト,  Next: スレッドセーフ性,  Prev: LogRecord 属性,  Up: logging --- Python 用のログ記録手段

5.16.5.8 LoggerAdapter オブジェクト
...................................

*note LoggerAdapter: 12c3. インスタンスは文脈情報をログ記録呼び出しに渡
すのを簡単にするために使われます。使い方の例は *note
コンテキスト情報をログ記録出力に付加する: 2c65. を参照してください。

 -- クラス: logging.LoggerAdapter (logger, extra, merge_extra=False)

     次に示す引数により初期化される *note LoggerAdapter: 12c3. インスタ
     ンスを返します: 元になる *note Logger: b1d. インスタンス、辞書ライ
     ク (dict-like) なオブジェクト ('extra')、そして各ログ呼び出しにおけ
     る 'extra' 引数を *note LoggerAdapter: 12c3. の 'extra' とマージす
     るかどうかを指定する真偽値 ('merge_extra')。デフォルトの振る舞いで
     は、各ログ呼び出しの 'extra' 引数を無視して *note LoggerAdapter:
     12c3. インスタンスの 'extra' だけを使います。

      -- メソッド: process (msg, kwargs)

          文脈情報を挿入するために、ログ記録呼び出しに渡されたメッセージ
          および/またはキーワード引数に変更を加えます。ここでの実装は
          'extra' としてコンストラクタに渡されたオブジェクトを取り、
          'extra' キーを使って 'kwargs' に加えます。返り値は ('msg',
          'kwargs') というタプルで、(変更されているはずの) 渡された引数
          を含みます。

      -- の属性: manager

          背後にある 'logger' の ‘manager’ メソッドを代理で呼び出します
          。

      -- の属性: _log

          背後にある 'logger' の ‘_log()’ メソッドを代理で呼び出します。

     *note LoggerAdapter: 12c3. は上記に加え *note Logger: b1d. のメソッ
     ド *note debug(): df7, *note info(): 1c5c, *note warning(): 1669,
     *note error(): 2c30, *note exception(): df5, *note critical(): df6,
     *note log(): df4, *note isEnabledFor(): 12c4, *note
     getEffectiveLevel(): 2c2d, *note setLevel(): 1436, *note
     hasHandlers(): 2c37. をサポートします。これらは *note Logger: b1d.
     の対応するメソッドと同じシグニチャを持つため、2つのインスタンスは区
     別せずに利用出来ます。

     バージョン 3.2 で変更: *note isEnabledFor(): 12c4, *note
     getEffectiveLevel(): 2c2d, *note setLevel(): 1436, *note
     hasHandlers(): 2c37. が *note LoggerAdapter: 12c3. に追加されました
     。これらメソッドは元のロガーに処理を委譲します。

     バージョン 3.6 で変更: 基底のロガーに移譲し、アダプターをネストでき
     るようにするために ‘manager’ 属性と ‘_log()’ メソッドが追加されまし
     た。

     バージョン 3.13 で変更: 'merge_extra' 引数が追加されました。


File: python.info,  Node: スレッドセーフ性,  Next: モジュールレベルの関数,  Prev: LoggerAdapter オブジェクト,  Up: logging --- Python 用のログ記録手段

5.16.5.9 スレッドセーフ性
.........................

logging モジュールは、クライアントで特殊な作業を必要としない限りスレッド
セーフになっています。このスレッドセーフ性はスレッドロックによって達成さ
れています; モジュールの共有データへのアクセスを直列化するためのロックが
一つ存在し、各ハンドラでも背後にある I/O へのアクセスを直列化するために
ロックを生成します。

*note signal: b4. モジュールを使用して非同期シグナルハンドラを実装してい
る場合、そのようなハンドラからはログ記録を使用できないかもしれません。こ
れは、 *note threading: d6. モジュールにおけるロック実装が常にリエントラ
ントではなく、そのようなシグナルハンドラから呼び出すことができないからで
す。


File: python.info,  Node: モジュールレベルの関数,  Next: モジュールレベル属性,  Prev: スレッドセーフ性,  Up: logging --- Python 用のログ記録手段

5.16.5.10 モジュールレベルの関数
................................

上で述べたクラスに加えて、いくつかのモジュールレベルの関数が存在します。

 -- の関数: logging.getLogger (name=None)

     Return a logger with the specified name or, if name is ‘None’,
     return the root logger of the hierarchy.  If specified, the name is
     typically a dot-separated hierarchical name like ''a", ''a.b" or
     ''a.b.c.d".  Choice of these names is entirely up to the developer
     who is using logging, though it is recommended that ‘__name__’ be
     used unless you have a specific reason for not doing that, as
     mentioned in *note ロガーオブジェクト: 2c23.

     与えられた名前に対して、この関数はどの呼び出しでも同じロガーインス
     タンスを返します。したがって、ロガーインスタンスをアプリケーション
     の各部でやりとりする必要はありません。

 -- の関数: logging.getLoggerClass ()

     標準の *note Logger: b1d. クラスか、最後に *note setLoggerClass():
     2c6c. に渡したクラスを返します。この関数は、新たなクラス定義の中で
     呼び出して、カスタマイズした *note Logger: b1d. クラスのインストー
     ルが既に他のコードで適用したカスタマイズを取り消さないことを保証す
     るために使われることがあります。例えば以下のようにします:

          class MyLogger(logging.getLoggerClass()):
              # ... override behaviour here

 -- の関数: logging.getLogRecordFactory ()

     *note LogRecord: fb3. を生成するのに使われる callable を返します。

     Added in version 3.2: この関数は、ログイベントを表現する *note
     LogRecord: fb3. の構築方法に関して開発者により多くのコントロールを
     与えるため、 *note setLogRecordFactory(): 2c61. とともに提供されま
     した。

     このファクトリがどのように呼ばれるかに関する詳細は *note
     setLogRecordFactory(): 2c61. を参照してください。

 -- の関数: logging.debug (msg, *args, **kwargs)

     This is a convenience function that calls *note Logger.debug():
     df7, on the root logger.  The handling of the arguments is in every
     way identical to what is described in that method.

     The only difference is that if the root logger has no handlers,
     then *note basicConfig(): 9ce. is called, prior to calling ‘debug’
     on the root logger.

     For very short scripts or quick demonstrations of ‘logging’
     facilities, ‘debug’ and the other module-level functions may be
     convenient.  However, most programs will want to carefully and
     explicitly control the logging configuration, and should therefore
     prefer creating a module-level logger and calling *note
     Logger.debug(): df7. (or other level-specific methods) on it, as
     described at the beginnning of this documentation.

 -- の関数: logging.info (msg, *args, **kwargs)

     Logs a message with level *note INFO: 1c5e. on the root logger.
     The arguments and behavior are otherwise the same as for *note
     debug(): 2c2f.

 -- の関数: logging.warning (msg, *args, **kwargs)

     Logs a message with level *note WARNING: 1c5f. on the root logger.
     The arguments and behavior are otherwise the same as for *note
     debug(): 2c2f.

          注釈: ‘warning’ と機能的に等価な古い関数 ‘warn’ があります。
          ‘warn’ は廃止予定なので使わないでください - 代わりに ‘warning’
          を使ってください。

 -- の関数: logging.error (msg, *args, **kwargs)

     Logs a message with level *note ERROR: 1c60. on the root logger.
     The arguments and behavior are otherwise the same as for *note
     debug(): 2c2f.

 -- の関数: logging.critical (msg, *args, **kwargs)

     Logs a message with level *note CRITICAL: 1c61. on the root logger.
     The arguments and behavior are otherwise the same as for *note
     debug(): 2c2f.

 -- の関数: logging.exception (msg, *args, **kwargs)

     Logs a message with level *note ERROR: 1c60. on the root logger.
     The arguments and behavior are otherwise the same as for *note
     debug(): 2c2f.  Exception info is added to the logging message.
     This function should only be called from an exception handler.

 -- の関数: logging.log (level, msg, *args, **kwargs)

     Logs a message with level 'level' on the root logger.  The
     arguments and behavior are otherwise the same as for *note debug():
     2c2f.

 -- の関数: logging.disable (level=CRITICAL)

     全てのロガーのレベル 'level' を上書きし、これはロガー自身の出力レベ
     ルよりも優先されます。アプリケーション全体を横断するログ出力を一時
     的に調整する必要が生じたら、この関数は便利でしょう。これの効果は重
     大度 'level' 以下の全てのロギング呼び出しを無効にすることですので、
     INFO で呼び出しをすれば、INFO と DEBUG イベントが捨てられる一方で、
     重大度 WARNING 以上のものは、ロガーの有効レベルに基いて処理されます
     。 ‘logging.disable(logging.NOTSET)’ が呼び出されると、この上書きレ
     ベルは削除され、ログ出力は再び個々のロガーの有効レベルに依存するよ
     うになります。

     ‘CRITICAL’ より高い独自のログレベル (これは推奨されません) を定義し
     た場合は、 'level' 引数のデフォルト値を当てにできなくなり、適切な値
     を明示的に与える必要があります。

     バージョン 3.7 で変更: 'level' 引数のデフォルトが ‘CRITICAL’ レベル
     になりました。この変更についてのより詳しいことは bpo-28524(1) を参
     照してください。

 -- の関数: logging.addLevelName (level, levelName)

     内部的な辞書の中でレベル 'level' をテキスト 'levelName' に関連付け
     ます。これは例えば *note Formatter: 143a. でメッセージを書式化する
     際のように、数字のレベルをテキスト表現に対応付ける際に用いられます
     。この関数は自作のレベルを定義するために使うこともできます。使われ
     るレベルに対する唯一の制限は、レベルは正の整数でなくてはならず、メ
     ッセージの深刻度が上がるに従ってレベルの数も上がらなくてはならない
     ということです。

          注釈: 独自のレベルを定義したい場合、 *note カスタムレベル:
          2c72. のセクションを参照してください。

 -- の関数: logging.getLevelNamesMapping ()

     ログレベルの名前と対応するログレベルのマッピングを返します。例えば
     、文字列 "CRITICAL" は *note CRITICAL: 1c61. にマップされます。この
     関数が返すマッピングオブジェクトは、関数呼び出しのたびに内部のマッ
     ピングをコピーしたものです。

     Added in version 3.11.

 -- の関数: logging.getLevelName (level)

     テキストまたは数値表現でログレベル 'level' を返してください。

     'level' が定義済みのレベル *note CRITICAL: 1c61, *note ERROR: 1c60,
     *note WARNING: 1c5f, *note INFO: 1c5e, *note DEBUG: 1c5d. のいずれ
     かである場合、対応する文字列が返されます。 *note addLevelName():
     2c71. を使ってレベルに名前を関連付けていた場合、 'level' に関連付け
     られた名前が返されます。定義済みのレベルに対応する数値を指定した場
     合、レベルに対応した文字列表現を返します。

     'level' パラメータは、 *note INFO: 1c5e. のような整数定数の代わりに
     'INFO' のようなレベルの文字列表現も受け付けます。この場合、この関数
     は関連するレベルの数値表現を返します。

     もし渡された数値や文字列がマッチしなければ、 'Level %s' % level が
     返されます。

          注釈: レベルは内部的には整数です(これはロギングのロジックが大
          小比較をする必要があるからです)。この関数は、数値のレベルを、
          書式記述子 ‘%(levelname)s’ (*note LogRecord 属性: 2c2e. 参照
          )によって書式化されるログ出力の表示用レベル名に変換するなどの
          用途に使用されます。

     バージョン 3.4 で変更: Python 3.4以前のバージョンでは、この関数には
     テキストのレベルも渡すことが出来、これは対応する数字レベルに読み替
     えられていました。このドキュメントされていなかった振る舞いは誤りで
     あると判断され、Python 3.4 で一度削除されました。ただし後方互換性の
     ために、これは 3.4.2 で元に戻されました。

 -- の関数: logging.getHandlerByName (name)

     Returns a handler with the specified 'name', or ‘None’ if there is
     no handler with that name.

     Added in version 3.12.

 -- の関数: logging.getHandlerNames ()

     Returns an immutable set of all known handler names.

     Added in version 3.12.

 -- の関数: logging.makeLogRecord (attrdict)

     属性が 'attrdict' で定義された、新しい *note LogRecord: fb3. インス
     タンスを生成して返します。この関数は、 pickle された *note
     LogRecord: fb3. 属性の辞書をソケットを介して送信し、受信端で *note
     LogRecord: fb3. インスタンスとして再構成する場合に便利です。

 -- の関数: logging.basicConfig (**kwargs)

     デフォルトの *note Formatter: 143a. を持つ *note StreamHandler:
     11c9. を生成してルートロガーに追加し、ロギングシステムの基本的な環
     境設定を行います。関数 *note debug(): 2c2f, *note info(): 2c59,
     *note warning(): 2d6, *note error(): 2c6d, *note critical(): 2c6e.
     は、ルートロガーにハンドラが定義されていない場合に自動的に *note
     basicConfig(): 9ce. を呼び出します。

     この関数は 'force' キーワード引数に ‘True’ が設定されない限り、ルー
     トロガーに設定されたハンドラがあれば何もしません。

          注釈: この関数は、他のスレッドが開始される前にメインスレッドか
          ら呼び出されるべきです。Python の 2.7.1 や 3.2 以前のバージョ
          ンでは、この関数が複数のスレッドから呼ばれると(珍しい状況下と
          はいえ)ハンドラがルートロガーに複数回加えられることがあり、ロ
          グ内のメッセージが重複するという予期しない結果をもたらすことが
          あります。

     以下のキーワード引数がサポートされます。

     フォーマット       説明
                        
     ---------------------------------------------------------------------
                        
     'filename'         *note StreamHandler: 11c9. ではなく指定された名
                        前で *note FileHandler: 1809. が作られます。
                        
                        
     'filemode'         'filename' が指定された場合、この
                        *note モード: 20dc. でファイルが開かれます。 デ
                        フォルトは ‘'a'’ です。
                        
                        
     'format'           ハンドラーで指定されたフォーマット文字列を使い
                        ます。デフォルトは ‘levelname’, ‘name’,
                        ‘message’ 属性をコロン区切りにしたものです。
                        
                        
     'datefmt'          指定された日時の書式で
                        *note time.strftime(): 11ba. が受け付けるものを
                        使います。
                        
                        
     'style'            'format' が指定された場合、書式文字列にこのスタ
                        イルを仕様します。 ‘'%'’, ‘'{'’, ‘'$'’ のうち
                        1つで、それぞれ *note printf-style: 698,
                        *note str.format(): 5ed,
                        *note string.Template: 653. に対応します。 デフ
                        ォルトは ‘'%'’ です。
                        
                        
     'level'            ルートロガーのレベルを指定された
                        *note レベル: 626. に設定します。
                        
                        
     'stream'           指定されたストリームを
                        *note StreamHandler: 11c9. の初期化に使います。
                        この引数は 'filename' と同時には使えないことに
                        注意してください。 両方が指定されたときには
                        ‘ValueError’ が送出されます。
                        
                        
     'handlers'         もし指定されれば、 これは root ロガーに追加され
                        る既に作られたハンドラのイテラブルになります。
                        まだフォーマッタがセットされていないすべてのハ
                        ンドラは、この関数で作られたデフォルトフォーマ
                        ッタが割り当てられることになります。この引数は
                        'filename' や 'stream' と互換性がないことに注意
                        してください。両方が存在する場合 ‘ValueError’ が
                        上げられます。
                        
                        
     'force'            このキーワード引数が真に設定されている場合、ル
                        ートのロガーに取り付けられたハンドラは全て取り
                        除かれ、他の引数によって指定された設定が有効に
                        なる前に閉じられます。
                        
                        
     'encoding'         もしこのキーワード引数が 'filename' とともに指
                        定された場合、 *note FileHandler: 1809. が作成
                        されるときにこの値が利用され、出力ファイルを開
                        く時に使用されます。
                        
                        
     'errors'           もしこのキーワード引数が 'filename' とともに指
                        定された場合、 *note FileHandler: 1809. が作成
                        されるときのこの値が使用され、出力ファイルを開
                        く時に使われます。もし指定されなかった場合、
                        'backslashreplace' が使用されます。もし ‘None’
                        が指定されると *note open(): 4e5. のように渡さ
                        れ、'errors' を渡したのと同じように扱われます。
                        

     バージョン 3.2 で変更: 'style' 引数が追加されました。

     バージョン 3.3 で変更: 互換性のない引数が指定された状況 (例えば
     'handlers' が 'stream' や 'filename' と一緒に指定されたり、'stream'
     が 'filename' と一緒に指定された場合) を捕捉するために、追加のチェ
     ックが加えられました。

     バージョン 3.8 で変更: 'force' 引数が追加されました。

     バージョン 3.9 で変更: 'encoding' と 'errors' 引数が追加されました
     。

 -- の関数: logging.shutdown ()

     ロギングシステムに対して、バッファのフラッシュを行い、すべてのハン
     ドラを閉じることで順次シャットダウンを行うように告知します。この関
     数はアプリケーションの終了時に呼ばれるべきであり、また呼び出し以降
     はそれ以上ロギングシステムを使ってはなりません。

     loggingモジュールがインポートされると、この関数が終了ハンドラーとし
     て登録されます（ *note atexit: 9. 参照）。そのため、通常はこれを手
     動で行う必要はありません。

 -- の関数: logging.setLoggerClass (klass)

     ロギングシステムに対して、ロガーをインスタンス化する際にクラス
     'klass' を使うように指示します。 指定するクラスは引数として名前だけ
     をとるようなメソッド ‘__init__()’ を定義していなければならず、
     ‘__init__()’ では ‘Logger.__init__()’ を呼び出さなければなりません
     。 この関数が呼び出されるのはたいてい、独自の振る舞いをするロガーを
     使う必要のあるアプリケーションでロガーがインスタンス化される前です
     。 呼び出された後は、いつでもそのサブクラスを使ってロガーのインスタ
     ンス化をしてはいけません: 引き続き *note logging.getLogger(): 92e.
     API を使用してロガーを取得してください。

 -- の関数: logging.setLogRecordFactory (factory)

     *note LogRecord: fb3. を生成するのに使われる callable をセットしま
     す。


     パラメータ: ‘factory’ - ログレコードを生成するファクトリとして振舞
     う callable。

     Added in version 3.2: この関数は、ログイベントを表現する *note
     LogRecord: fb3. の構築方法に関して開発者により多くのコントロールを
     与えるため、 *note getLogRecordFactory(): 2c60. とともに提供されま
     した。

     ファクトリは以下のようなシグネチャを持っています:

     ‘factory(name, level, fn, lno, msg, args, exc_info, func=None,
     sinfo=None, **kwargs)’


          name: ロガーの名前。


          level: ログレベル (数値)。


          fn: ログ呼び出しが行われたファイルのフルパス名。


          lno: ログ呼び出しが行われたファイルの行数。


          msg: ログメッセージ。


          ‘args’: ログメッセージに対する引数。


          exc_info: 例外タプルまたは ‘None’。


          func: ログ呼び出しを起動した関数またはメソッドの名前。


          sinfo: *note traceback.print_stack(): e51. で提供されるような
          、呼び出し階層を示すスタックトレースバック。


          ‘kwargs’: 追加のキーワード引数。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=28524


File: python.info,  Node: モジュールレベル属性,  Next: warnings モジュールとの統合,  Prev: モジュールレベルの関数,  Up: logging --- Python 用のログ記録手段

5.16.5.11 モジュールレベル属性
..............................

 -- の属性: logging.lastResort

     「最後の手段のハンドラ」が、この属性で利用可能です。これは *note
     StreamHandler: 11c9. が ‘sys.stderr’ に ‘WARNING’ レベルで書き出し
     ているのがそうですし、ロギングの設定がなにか不在のロギングイベント
     を扱う場合に使われます。最終的な結果は、メッセージを単に
     ‘sys.stderr’ に出力することです。これはかつて「logger XYZ について
     のハンドラが見つかりません」と言っていたエラーメッセージを置き換え
     ています。もしも何らかの理由でその昔の振る舞いが必要な場合は、
     ‘lastResort’ に ‘None’ をセットすれば良いです。

     Added in version 3.2.

 -- の属性: logging.raiseExceptions

     Used to see if exceptions during handling should be propagated.

     Default: ‘True’.

     If *note raiseExceptions: 11ca. is ‘False’, exceptions get silently
     ignored.  This is what is mostly wanted for a logging system - most
     users will not care about errors in the logging system, they are
     more interested in application errors.


File: python.info,  Node: warnings モジュールとの統合,  Prev: モジュールレベル属性,  Up: logging --- Python 用のログ記録手段

5.16.5.12 warnings モジュールとの統合
.....................................

*note captureWarnings(): 2c76. 関数を使って、 *note logging: 7b. を
*note warnings: fa. モジュールと統合できます。

 -- の関数: logging.captureWarnings (capture)

     この関数は、logging による警告の補足を、有効にまたは無効にします。

     'capture' が ‘True’ なら、 *note warnings: fa. モジュールに発せられ
     た警告は、ロギングシステムにリダイレクトされるようになります。具体
     的には、警告が *note warnings.formatwarning(): 1980. でフォーマット
     化され、結果の文字列が ‘'py.warnings'’ という名のロガーに、 *note
     WARNING: 1c5f. の重大度でロギングされるようになります。

     'capture' が ‘False’ なら、警告のロギングシステムに対するリダイレク
     トは止められ、警告は元の (すなわち、‘captureWarnings(True)’ が呼び
     出される前に有効だった) 送信先にリダイレクトされるようになります。

参考
....

*note logging.config: 7c. モジュール

     logging モジュールの環境設定 API です。

*note logging.handlers: 7d. モジュール

     logging モジュールに含まれる、便利なハンドラです。

PEP 282(1) - ログシステム

     この機能を Python 標準ライブラリに含めることを述べた提案です。

Python の最初のロギングパッケージ(2)

     これは、 *note logging: 7b. パッケージのオリジナルのソースです。こ
     のサイトから利用できるバージョンのパッケージは、 *note logging: 7b.
     パッケージを標準ライブラリに含まない、 Python 1.5.2, 2.1.x および
     2.2.x で使うのに適しています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0282/

   (2) https://old.red-dove.com/python_logging.html


File: python.info,  Node: logging config --- ログ記録の環境設定,  Next: logging handlers --- ログ記録ハンドラー,  Prev: logging --- Python 用のログ記録手段,  Up: 汎用オペレーティングシステムサービス

5.16.6 ‘logging.config’ -- ログ記録の環境設定
---------------------------------------------

'ソースコード:' Lib/logging/config.py(1)

Important
.........

このページには、リファレンス情報だけが含まれています。チュートリアルは、
以下のページを参照してください

   * *note 基本チュートリアル: 11c6.

   * *note 上級チュートリアル: 11c7.

   * *note ロギングクックブック: 11c8.

__________________________________________________________________

この節は、logging モジュールを設定するための API を解説します。

* Menu:

* 環境設定のための関数::
* セキュリティで考慮すべき点::
* 環境設定辞書スキーマ::
* 環境設定ファイルの書式::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/logging/config.py


File: python.info,  Node: 環境設定のための関数,  Next: セキュリティで考慮すべき点,  Up: logging config --- ログ記録の環境設定

5.16.6.1 環境設定のための関数
.............................

以下の関数は logging モジュールの環境設定をします。これらの関数は、
*note logging.config: 7c. にあります。これらの関数の使用はオプションです
-- *note logging: 7b. モジュールはこれらの関数を使うか、 (*note logging:
7b. 自体で定義されている) 主要な API を呼び出し、 *note logging: 7b. か
*note logging.handlers: 7d. で宣言されているハンドラを定義することで設定
できます。

 -- の関数: logging.config.dictConfig (config)

     辞書からロギング環境設定を取得します。この辞書の内容は、以下の
     *note 環境設定辞書スキーマ: 2c7a. で記述されています。

     環境設定中にエラーに遭遇すると、この関数は適宜メッセージを記述しつ
     つ *note ValueError: 1e3, *note TypeError: 502, *note
     AttributeError: 326. または *note ImportError: 3f2. を送出します。
     例外を送出する条件を (不完全かもしれませんが) 以下に列挙します:

        * 文字列でなかったり、実際のロギングレベルと関係ない文字列であっ
          たりする ‘level’。

        * ブール値でない ‘propagate’ の値。

        * 対応する行き先を持たない id。

        * インクリメンタルな呼び出しの中で見つかった存在しないハンドラ
          id。

        * 無効なロガー名。

        * 内部や外部のオブジェクトに関わる不可能性。

     解析は ‘DictConfigurator’ クラスによって行われます。このクラスのコ
     ンストラクタは環境設定に使われる辞書に渡され、このクラスは
     ‘configure()’ メソッドを持ちます。 *note logging.config: 7c. モジュ
     ールは、呼び出し可能属性 ‘dictConfigClass’ を持ち、これはまず
     ‘DictConfigurator’ に設定されます。 ‘dictConfigClass’ の値は適切な
     独自の実装で置き換えられます。

     *note dictConfig(): 1180. は ‘dictConfigClass’ を、指定された辞書を
     渡して呼び出し、それから返されたオブジェクトの ‘configure()’ メソッ
     ドを呼び出して、環境設定を作用させます:

          def dictConfig(config):
              dictConfigClass(config).configure()

     For example, a subclass of ‘DictConfigurator’ could call
     ‘DictConfigurator.__init__()’ in its own ‘__init__()’, then set up
     custom prefixes which would be usable in the subsequent
     ‘configure()’ call.  ‘dictConfigClass’ would be bound to this new
     subclass, and then *note dictConfig(): 1180. could be called
     exactly as in the default, uncustomized state.

     Added in version 3.2.

 -- の関数: logging.config.fileConfig (fname, defaults=None,
          disable_existing_loggers=True, encoding=None)

     ログ記録の環境設定を *note configparser: 1b. 形式ファイルから読み出
     します。そのファイルの形式は *note 環境設定ファイルの書式: 2c7b. で
     記述されているとおりにしなければなりません。この関数はアプリケーシ
     ョンから何度も呼び出すことができ、これによって、 (設定を選択し、選
     択された設定を読み出す機構をデベロッパが提供していれば) 複数の準備
     済みの設定からエンドユーザが選択するようにできます。

     It will raise *note FileNotFoundError: e8f. if the file doesn't
     exist and *note RuntimeError: 17a. if the file is invalid or empty.


     パラメータ:

        * ‘fname’ - A filename, or a file-like object, or an instance
          derived from *note RawConfigParser: f31.  If a
          ‘RawConfigParser’-derived instance is passed, it is used as
          is.  Otherwise, a *note ConfigParser: 1aa. is instantiated,
          and the configuration read by it from the object passed in
          ‘fname’.  If that has a *note readline(): a8. method, it is
          assumed to be a file-like object and read using *note
          read_file(): 4d1.; otherwise, it is assumed to be a filename
          and passed to *note read(): 140d.

        * ‘defaults’ - Defaults to be passed to the ‘ConfigParser’ can
          be specified in this argument.

        * ‘disable_existing_loggers’ - ‘False’ が指定された場合は、この
          呼び出しが行われたときに存在するロガーは有効のまま残されます。
          後方互換性のあるやり方で古い振る舞いを保つので、デフォルト値は
          ‘True’ になっています。そのような振る舞いでは、既存の非ルート
          ロガーまたはそれらのロガーの先祖がロギング設定の中で明示的に名
          付けられていない限り、既存のロガーを無効にします。

        * ‘encoding’ - 'fname' がファイル名の場合に、ファイルをオープン
          する時のエンコーディングです。

     バージョン 3.4 で変更: ‘fname’ として *note RawConfigParser: f31. の
     サブクラスのインスタンスが渡せ得るようになっています。これによって
     このようなことが容易になります:

             * ロギングの設定が、アプリケーション全体の設定における単な
               る一部であるような設定ファイルの使用。

             * ファイルから設定を読み込み、 ‘fileConfig’ に通す前に(例え
               ばコマンドラインパラメータやランタイム環境の他のなにかで
               )アプリケーションによって修正するようなこと。

     バージョン 3.10 で変更: Added the 'encoding' parameter.

     バージョン 3.12 で変更: An exception will be thrown if the provided
     file doesn't exist or is invalid or empty.

 -- の関数: logging.config.listen (port=DEFAULT_LOGGING_CONFIG_PORT,
          verify=None)

     指定されたポートでソケットサーバを起動し、新しい設定を待ち受けます
     。ポートが指定されなかった場合は、モジュールのデフォルトの
     ‘DEFAULT_LOGGING_CONFIG_PORT’ が使用されます。ロギング設定は *note
     dictConfig(): 1180. あるいは *note fileConfig(): b1f. で処理できる
     ファイルとして送信されます。 *note Thread: 91a. インスタンスを返し
     、このインスタンスの *note start(): 2c7c. を呼び出してサーバを起動
     し、適切なところで *note join(): 11b5. を呼び出すことができます。サ
     ーバを停止するには、 *note stopListening(): 2c7d. を呼び出します。

     ‘verify’ 引数を指定する場合は、これはソケットを通して受け取ったバイ
     ト文字列が妥当であるか、処理すべきであるかどうかを検査する callable
     である必要があります。ソケットを通じて、暗号化または署名あるいはそ
     の両方を受け取ることがあります。そのような場合に、 ‘verify’
     callable が署名の正当性検査または暗号化の復号あるいはその両方を実施
     することが出来ます。 ‘verify’ callable は単一引数で呼び出されます -
     ソケットを通じて受け取ったバイト文字列です - そして処理すべきバイト
     文字列、または捨て去られるべきであることを示すための ‘None’ を返す
     必要があります。返却されるバイト文字列は(たとえば正当性検査だけが行
     われて)渡されたものと同じかもしれませんし、あるいは(おそらく暗号化
     の復号が行われて)まったく異なるものかもしれません。

     ソケットに設定を送るには、まず設定ファイルを読み、それを
     ‘struct.pack('>L', n)’ を使って長さ 4 バイトのバイナリにパックした
     ものを前に付けたバイト列としてソケットに送ります。
          注釈: 設定の一部は *note eval(): 165. を通じて渡されるため、こ
          の関数を利用することはユーザーをセキュリティ上のリスクにさらす
          可能性があります。この関数は ‘localhost’ のソケットだけにバイ
          ンドされており、リモートマシンからの接続を受け付けませんが、そ
          れでも *note listen(): f32. を呼び出したプロセスのアカウントの
          もとで信頼できないコードが実行されうるシナリオが存在します。特
          に、 *note listen(): f32. を呼び出したプロセスが複数のユーザー
          が利用するマシン上で実行されており、ユーザー同士が互いに信頼で
          きない場合、悪意あるユーザーが被害者ユーザーのプロセス上で本質
          的に任意のコードを実行するように計画する可能性があります。攻撃
          は、単に被害者ユーザーの *note listen(): f32. ソケットに接続し
          て、被害者ユーザーのプロセス上で攻撃者が実行したいコードが実行
          されるような設定を送り込むだけです。この攻撃はデフォルトのポー
          トが使われている場合きわめて容易であり、異なるポートが使われて
          いる場合でもそれほど難しくはありません。このような事象が発生す
          るリスクを回避するためには、 *note listen(): f32. の ‘verify’
          引数を使って不正な設定が適用されるのを防ぐようにしてください。

     バージョン 3.4 で変更: ‘verify’ 引数が追加されました。

          注釈: 既存のロガーを無効にしない構成をリスナーに送信する場合は
          、設定にはJSONフォーマットを使用する必要があります。これは、設
          定に *note dictConfig(): 1180. を使用します。 このメソッドを使
          用すると、 ‘disable_existing_loggers’ に ‘False’ を指定した設
          定を送信できます。

 -- の関数: logging.config.stopListening ()

     *note listen(): f32. を呼び出して作成された、待ち受け中のサーバを停
     止します。通常 *note listen(): f32. の戻り値に対して ‘join()’ が呼
     ばれる前に呼び出します。


File: python.info,  Node: セキュリティで考慮すべき点,  Next: 環境設定辞書スキーマ,  Prev: 環境設定のための関数,  Up: logging config --- ログ記録の環境設定

5.16.6.2 セキュリティで考慮すべき点
...................................

logging の設定機能は便利さを提供します。その便利さの一部は設定ファイル内
のテキストを logging の設定に使われる Python オブジェクトに変換する機能
を提供することによって実現されています - たとえば、 *note
ユーザ定義オブジェクト: 2c80. で説明されているような機能です。しかし、ま
さにこのメカニズム (実行可能オブジェクトをユーザー定義モジュールからイン
ポートし、設定ファイルから読み込んだパラメータを使ってそれらを呼び出すこ
と) が任意のコードを呼び出すことに利用できる可能性があります。そして、こ
の理由により、信頼できない情報源から取得した設定ファイルは '細心の注意'
を払って取り扱わなければなりません。そのようなファイルをロードする場合、
そのファイルがいかなる問題も起こさないと確認した上で実際にファイルをロー
ドしてください。


File: python.info,  Node: 環境設定辞書スキーマ,  Next: 環境設定ファイルの書式,  Prev: セキュリティで考慮すべき点,  Up: logging config --- ログ記録の環境設定

5.16.6.3 環境設定辞書スキーマ
.............................

ロギング設定を記述するには、生成するさまざまなオブジェクトと、それらのつ
ながりを列挙しなければなりません。例えば、 'console' という名前のハンド
ラを生成し、'startup' という名前のロガーがメッセージを 'console' ハンド
ラに送るというようなことを記述します。これらのオブジェクトは、 *note
logging: 7b. モジュールによって提供されるものに限らず、独自のフォーマッ
タやハンドラクラスを書くことも出来ます。このクラスへのパラメータは、
‘sys.stderr’ のような外部オブジェクトを必要とすることもあります。これら
のオブジェクトとつながりを記述する構文は、以下の *note
オブジェクトの接続: 2c82. で定義されています。

* Menu:

* 辞書スキーマの詳細::
* 増分設定::
* オブジェクトの接続::
* ユーザ定義オブジェクト::
* ハンドラの設定順序::
* 外部オブジェクトへのアクセス::
* 内部オブジェクトへのアクセス::
* インポート解決とカスタムインポーター::
* Configuring QueueHandler and QueueListener::


File: python.info,  Node: 辞書スキーマの詳細,  Next: 増分設定,  Up: 環境設定辞書スキーマ

5.16.6.4 辞書スキーマの詳細
...........................

*note dictConfig(): 1180. に渡される辞書は、以下のキーを含んでいなければ
なりません:

   * 'version' - スキーマのバージョンを表す整数値に設定されます。現在有
     効な値は 1 だけですが、このキーがあることで、このスキーマは後方互換
     性を保ちながら発展できます。

その他すべてのキーは省略可能ですが、与えられたなら以下に記述するように解
釈されます。以下のすべての場合において、 '環境設定辞書' と記載されている
所では、その辞書に特殊な ‘'()'’ キーがあるかを調べることで、カスタムのイ
ンスタント化が必要であるか判断されます。その場合は、以下の *note
ユーザ定義オブジェクト: 2c80. で記述されている機構がインスタンス生成に使
われます。そうでなければ、インスタンス化するべきものを決定するのにコンテ
キストが使われます。

   * 'formatters' - 対応する値は辞書で、そのそれぞれのキーがフォーマッタ
     id になり、それぞれの値が対応する *note Formatter: 143a. インスタン
     スをどのように環境設定するかを記述する辞書になります。

     設定辞書は *note Formatter: 143a. オブジェクトを作成するときの引数
     に対応する、次のようなオプションキーがないか探索されます。

        * ‘format’

        * ‘datefmt’

        * ‘style’

        * ‘validate’ (バージョン3.8以降)

        * ‘defaults’ (since version >=3.12)

     オプションの ‘class’ キーはフォーマッタークラスの名前を表します（モ
     ジュールとクラス名をドットで繋げる）。インスタンス化時の引数は
     *note Formatter: 143a. と同じであるため、このキーは *note
     Formatter: 143a. をカスタマイズしたサブクラスのインスタンス化に使う
     のがもっとも便利です。例えばトレースバックにさらに情報を付加したり
     、情報を要約代替クラスを実装するといったことが想定されます。もし、
     自作のフォーマッターが異なる引数や追加の設定引数を持つ場合は、
     *note ユーザ定義オブジェクト: 2c80. を使うべきです。

   * 'filters' - 対応する値は辞書で、そのそれぞれのキーがフィルタ id に
     なり、それぞれの値が対応する Filter インスタンスをどのように環境設
     定するかを記述する辞書になります。

     環境設定辞書は、(デフォルトが空文字列の) キー ‘name’ を検索され、そ
     れらが *note logging.Filter: 11cc. インスタンスを構成するのに使われ
     ます。

   * 'handlers' - 対応する値は辞書で、そのそれぞれのキーがハンドラ id に
     なり、それぞれの値が対応する Handler インスタンスをどのように環境設
     定するかを記述する辞書になります。

     環境設定辞書は、以下のキーを検索されます:

        * ‘class’ (必須)。これはハンドラクラスの完全に修飾された名前です
          。

        * ‘level’ (任意)。ハンドラのレベルです。

        * ‘formatter’ (任意)。このハンドラへのフォーマッタの id です。

        * ‘filters’ (任意)。このハンドラへのフィルタの id のリストです。

          バージョン 3.11 で変更: ‘filters’ は id に加えてフィルタのイン
          スタンスを受け取ることができるようになりました。

     その他の 'すべての' キーは、ハンドラのコンストラクタにキーワード引
     数として渡されます。例えば、以下のコード片が与えられたとすると:

          handlers:
            console:
              class : logging.StreamHandler
              formatter: brief
              level   : INFO
              filters: [allow_foo]
              stream  : ext://sys.stdout
            file:
              class : logging.handlers.RotatingFileHandler
              formatter: precise
              filename: logconfig.log
              maxBytes: 1024
              backupCount: 3

     id が ‘console’ であるハンドラが、 ‘sys.stdout’ を根底のストリーム
     にして、 *note logging.StreamHandler: 11c9. としてインスタンス化さ
     れます。id が ‘file’ であるハンドラが、 ‘filename='logconfig.log',
     maxBytes=1024, backupCount=3’ をキーワード引数にして、 *note
     logging.handlers.RotatingFileHandler: 153b. としてインスタンス化さ
     れます。

   * 'loggers' - 対応する値は辞書で、そのそれぞれのキーがロガー名になり
     、それぞれの値が対応する Logger インスタンスをどのように環境設定す
     るかを記述する辞書になります。

     環境設定辞書は、以下のキーを検索されます:

        * ‘level’ (任意)。ロガーのレベルです。

        * ‘propagate’ (任意)。ロガーの伝播の設定です。

        * ‘filters’ (任意)。このロガーへのフィルタの id のリストです。

          バージョン 3.11 で変更: ‘filters’ は id に加えてフィルタのイン
          スタンスを受け取ることができるようになりました。

        * ‘handlers’ (任意)。このロガーへのハンドラの id のリストです。

     指定されたロガーは、指定されたレベル、伝播、ハンドラに従って環境設
     定されます。

   * 'root' - これは、ルートロガーへの設定になります。この環境設定の進行
     は、‘propagate’ 設定が適用されないことを除き、他のロガーと同じです
     。

   * 'incremental' - この環境設定が既存の環境設定に対する増分として解釈
     されるかどうかです。この値のデフォルトは ‘False’ で、指定された環境
     設定は、既存の *note fileConfig(): b1f. API によって使われているの
     と同じ意味上で、既存の環境設定を置き換えます。

     指定された値が ‘True’ なら、環境設定は *note 増分設定: 2c85. の節で
     記述されているように進行します。

   * 'disable_existing_loggers' - 既存の非ルートロガーをすべて無効にする
     べきかどうかです。この設定は、 *note fileConfig(): b1f. における同
     じ名前のパラメータと同じです。設定されていなければ、このパラメータ
     のデフォルトは ‘True’ です。この値は、 'incremental' が ‘True’ なら
     無視されます。


File: python.info,  Node: 増分設定,  Next: オブジェクトの接続,  Prev: 辞書スキーマの詳細,  Up: 環境設定辞書スキーマ

5.16.6.5 増分設定
.................

増分設定に完全な柔軟性を提供するのは難しいです。例えば、フィルタやフォー
マッタのようなオブジェクトは匿名なので、一旦環境設定がなされると、設定を
拡張するときにそのような匿名オブジェクトを参照することができません。

さらに、一旦環境設定がなされた後、実行時にロガー、ハンドラ、フィルタ、フ
ォーマッタのオブジェクトグラフを任意に変えなければならない例もありません
。ロガーとハンドラの冗長性は、レベル (または、ロガーの場合には、伝播フラ
グ) を設定することによってのみ制御できます。安全な方法でオブジェクトグラ
フを任意に変えることは、マルチスレッド環境で問題となります。不可能ではな
いですが、その効用は実装に加えられる複雑さに見合いません。

従って、環境設定辞書の ‘incremental’ キーが与えられ、これが ‘True’ であ
るとき、システムは ‘formatters’ と ‘filters’ の項目を完全に無視し、
‘handlers’ の項目の ‘level’ 設定と、‘loggers’ と ‘root’ の項目の ‘level’
と ‘propagate’ 設定のみを処理します。

環境設定辞書の値を使うことで、設定は pickle 化された辞書としてネットワー
クを通してソケットリスナに送ることができます。これにより、長時間起動する
アプリケーションのロギングの冗長性を、アプリケーションを止めて再起動する
必要なしに、いつでも変更することができます。


File: python.info,  Node: オブジェクトの接続,  Next: ユーザ定義オブジェクト,  Prev: 増分設定,  Up: 環境設定辞書スキーマ

5.16.6.6 オブジェクトの接続
...........................

このスキーマは、ロギングオブジェクトの一揃い - ロガー、ハンドラ、フォー
マッタ、フィルタ - について記述します。これらは、オブジェクトグラフ上で
お互い接続されます。従って、このスキーマは、オブジェクト間の接続を表現し
なければなりません。例えば、環境設定で、特定のロガーが特定のハンドラに取
り付けられたとします。この議論では、ロガーとハンドラが、これら 2 つの接
続のそれぞれ送信元と送信先であるといえます。もちろん、この設定オブジェク
ト中では、これはハンドラへの参照を保持しているロガーで表されます。設定辞
書中で、これは次のようになされます。まず、送信先オブジェクトを曖昧さなく
指定する id を与えます。そして、その id を送信元オブジェクトの環境設定で
使い、送信元とその id をもつ送信先が接続されていることを示します。

ですから、例えば、以下の YAML のコード片を例にとると:

     formatters:
       brief:
         # configuration for formatter with id 'brief' goes here
       precise:
         # configuration for formatter with id 'precise' goes here
     handlers:
       h1: #This is an id
        # configuration of handler with id 'h1' goes here
        formatter: brief
       h2: #This is another id
        # configuration of handler with id 'h2' goes here
        formatter: precise
     loggers:
       foo.bar.baz:
         # other configuration for logger 'foo.bar.baz'
         handlers: [h1, h2]

(注釈: YAML がここで使われているのは、辞書の等価な Python 形式よりもこち
らのほうが少し読みやすいからです。)

ロガーの id は、プログラム上でロガーへの参照を得るために使われるロガー名
で、たとえば ‘foo.bar.baz’ です。フォーマッタとフィルタの id は、(上の
‘brief’, ‘precise’ のような) 任意の文字列値にできます。これらは一時的な
もので、環境設定辞書の処理にのみ意味があり、オブジェクト間の接続を決定す
るのに使われます。また、これらは設定の呼び出しが完了したとき、どこにも残
りません。

上記のコード片は、‘foo.bar.baz’ というの名ロガーに、ハンドラ id ‘h1’ と
‘h2’ で表される 2 つのハンドラを接続することを示します。‘h1’ のフォーマ
ッタは id ‘brief’ で記述されるもので、‘h2’ のフォーマッタは id ‘precise’
で記述されるものです。


File: python.info,  Node: ユーザ定義オブジェクト,  Next: ハンドラの設定順序,  Prev: オブジェクトの接続,  Up: 環境設定辞書スキーマ

5.16.6.7 ユーザ定義オブジェクト
...............................

このスキーマは、ハンドラ、フィルタ、フォーマッタのための、ユーザ定義オブ
ジェクトをサポートします。(ロガーは、異なるインスタンスに対して異なる型
を持つ必要はないので、この環境設定スキーマは、ユーザ定義ロガークラスをサ
ポートしていません。)

設定されるオブジェクトは、それらの設定を詳述する辞書によって記述されます
。場所によっては、あるオブジェクトがどのようにインスタンス化されるかとい
うコンテキストを、ロギングシステムが推測できます。しかし、ユーザ定義オブ
ジェクトがインスタンス化されるとき、システムはどのようにこれを行うかを知
りません。ユーザ定義オブジェクトのインスタンス化を完全に柔軟なものにする
ため、ユーザは 'ファクトリ' - 設定辞書を引数として呼ばれ、インスタンス化
されたオブジェクトを返す呼び出し可能オブジェクト - を提供する必要があり
ます。これは特殊キー ‘'()'’ で利用できる、ファクトリへの絶対インポートパ
スによって合図されます。ここに具体的な例を挙げます:

     formatters:
       brief:
         format: '%(message)s'
       default:
         format: '%(asctime)s %(levelname)-8s %(name)-15s %(message)s'
         datefmt: '%Y-%m-%d %H:%M:%S'
       custom:
           (): my.package.customFormatterFactory
           bar: baz
           spam: 99.9
           answer: 42

上記の YAML コード片は 3 つのフォーマッタを定義します。 1 つ目は、id が
‘brief’ で、指定されたフォーマット文字列をもつ、標準 *note
logging.Formatter: 143a. インスタンスです。 2 つ目は、id が ‘default’ で
、長いフォーマットを持ち、時間フォーマットも定義していて、結果はその 2 つ
のフォーマット文字列で初期化された *note logging.Formatter: 143a. になり
ます。Python ソース形式で見ると、 ‘brief’ と ‘default’ フォーマッタは、
それぞれ設定の部分辞書:

     {
       'format' : '%(message)s'
     }

および:

     {
       'format' : '%(asctime)s %(levelname)-8s %(name)-15s %(message)s',
       'datefmt' : '%Y-%m-%d %H:%M:%S'
     }

を持ち、これらの辞書が特殊キー ‘'()'’ を持たないので、インスタンス化はコ
ンテキストから推測され、結果として標準の *note logging.Formatter: 143a.
インスタンスが生成されます。id が ‘custom’ である、3 つ目のフォーマッタ
の設定をする部分辞書は:

     {
       '()' : 'my.package.customFormatterFactory',
       'bar' : 'baz',
       'spam' : 99.9,
       'answer' : 42
     }

で、ユーザ定義のインスタンス化が望まれることを示す特殊キー ‘'()'’ を含み
ます。この場合、指定された呼び出し可能ファクトリオブジェクトが使われます
。これが実際の呼び出し可能オブジェクトであれば、それが直接使われます - そ
うではなく、(この例でのように) 文字列を指定したなら、実際の呼び出し可能
オブジェクトは、通常のインポート機構を使って検索されます。その呼び出し可
能オブジェクトは、環境設定の部分辞書の、'残りの' 要素をキーワード引数と
して呼ばれます。上記の例では、id が ‘custom’ のフォーマッタは、以下の呼
び出しによって返されるものとみなされます:

     my.package.customFormatterFactory(bar='baz', spam=99.9, answer=42)

     警告: 上記の例で ‘bar’, ‘spam’ または ‘answer’ のようなキーワード引
     数に指定する値は、設定作業の途中で処理されることなくそのまま呼び出
     し可能オブジェクトに渡されるため、 ‘cfg://foo’ や ‘ext://bar’ のよ
     うな設定用の辞書や参照であってはいけません。

キー ‘'()'’ が特殊キーとして使われるのは、キーワードパラメータ名として不
正で、呼び出しに使われるキーワード引数と衝突し得ないからです。‘'()'’ は
また、対応する値が呼び出し可能オブジェクトであると覚えやすくします。

バージョン 3.11 で変更: ‘handlers’ と ‘loggers’ の ‘filters’ メンバーは
id に加えてフィルタのインスタンスを受け取ることができるようになりました
。

特殊なキーワード ‘'.'’ を指定することもできます。この場合その値には属性
名とその値のマッピングをあらわす辞書を指定します。指定された属性は、もし
それが見つかった場合、戻り値のユーザー定義オブジェクトに設定されます。し
たがって、以下のように設定すると:

     {
       '()' : 'my.package.customFormatterFactory',
       'bar' : 'baz',
       'spam' : 99.9,
       'answer' : 42,
       '.' {
         'foo': 'bar',
         'baz': 'bozz'
       }
     }

戻り値のフォーマッタは属性 ‘foo’ と''baz'' をもち、それぞれの値は
‘'bar'’ と ‘'bozz'’ に設定されます。

     警告: 上記の例で ‘foo’ や ‘baz’ のような属性に設定する値は、フォー
     マッタの設定作業の途中で処理されることなくそのまま属性値として設定
     されるため、 ‘cfg://foo’ や ‘ext://bar’ のような設定用の辞書や参照
     であってはいけません。


File: python.info,  Node: ハンドラの設定順序,  Next: 外部オブジェクトへのアクセス,  Prev: ユーザ定義オブジェクト,  Up: 環境設定辞書スキーマ

5.16.6.8 ハンドラの設定順序
...........................

ハンドラは対応するキーのアルファベット順に設定され、設定されたハンドラは
スキーマ中の環境設定辞書における ‘handlers’ 辞書 (の作業コピー) を差し替
えます。たとえば ‘cfg://handlers.foo’ という設定において、最初に
‘handlers['foo']``が ``foo’ という名前のハンドラに対する環境設定辞書を指
しているとき、以後 (いったんハンドラが設定されると) 設定されたハンドラの
インスタンスを指すようになります。その結果、 ‘cfg://handlers.foo’ は辞書
かハンドラのインスタンスのいずれかに解決される可能性があります。一般に、
ハンドラは、依存するハンドラが全て設定された _あとに_ それらに依存するハ
ンドラが設定されるように名前をつける方が賢明です; これにより、 ‘foo’ と
いう名前のハンドラに依存するハンドラを設定する際に ‘cfg://handlers.foo’
で依存するハンドラを参照できるようになります。もし依存するハンドラの名前
が ‘bar’ であった場合、アルファベット順の規則から ‘bar’ の設定が ‘foo’ の
設定よりも先に試みられることにより ‘foo’ がまだ設定されていないかもしれ
ないことから、問題が起こる可能性があります。一方、依存するハンドラの名前
が ‘foobar’ であった場合は、その設定は ‘foo’ の後に行われることとなり、
‘cfg://handlers.foo’ は環境設定辞書ではなく設定済みのハンドラ ‘foo’ のイ
ンスタンスに解決されます。


File: python.info,  Node: 外部オブジェクトへのアクセス,  Next: 内部オブジェクトへのアクセス,  Prev: ハンドラの設定順序,  Up: 環境設定辞書スキーマ

5.16.6.9 外部オブジェクトへのアクセス
.....................................

環境設定が、例えば ‘sys.stderr’ のような、設定の外部のオブジェクトへの参
照を必要とすることがあります。設定辞書が Python コードで構成されていれば
話は簡単ですが、これがテキストファイル (JSON, YAML 等) を通して提供され
ていると問題となります。テキストファイルでは、‘sys.stderr’ をリテラル文
字列 ‘'sys.stderr'’ と区別する標準の方法がありません。この区別を容易にす
るため、環境設定システムは、文字列中の特定の特殊接頭辞を見つけ、それらを
特殊に扱います。例えば、リテラル文字列 ‘'ext://sys.stderr'’ が設定中の値
として与えられたら、この ‘ext://’ は剥ぎ取られ、この値の残りが普通のイン
ポート機構で処理されます。

このような接頭辞の処理は、プロトコルの処理と同じようになされます。どちら
の機構も、正規表現 ‘^(?P<prefix>[a-z]+)://(?P<suffix>.*)$’ にマッチする
接頭辞を検索し、それによって ‘prefix’ が認識されたなら、接頭辞に応じたや
り方で ‘suffix’ が処理され、その処理の結果によって文字列値が置き換えられ
ます。接頭辞が認識されなければ、その文字列値はそのまま残されます。


File: python.info,  Node: 内部オブジェクトへのアクセス,  Next: インポート解決とカスタムインポーター,  Prev: 外部オブジェクトへのアクセス,  Up: 環境設定辞書スキーマ

5.16.6.10 内部オブジェクトへのアクセス
......................................

外部オブジェクトと同様、環境設定内部のオブジェクトへのアクセスを必要とす
ることもあります。これは、その各オブジェクトを司る環境設定システムによっ
て暗黙に行われます。例えば、ロガーやハンドラの ‘level’ に対する文字列値
‘'DEBUG'’ は、自動的に値 ‘logging.DEBUG’ に変換されますし、‘handlers’,
‘filters’ および ‘formatter’ の項目は、オブジェクト id を取って、適切な
送信先オブジェクトを決定します。

しかし、ユーザ定義モジュールには、 *note logging: 7b. モジュールには分か
らないような、より一般的な機構が必要です。例えば、 *note
logging.handlers.MemoryHandler: 2c8f. があって、委譲する先の別のハンドラ
である ‘target’ 引数を取るとします。システムはこのクラスをすでに知ってい
ますから、設定中で、与えられた ‘target’ は関連するターゲットハンドラのオ
ブジェクト id でさえあればよく、システムはその id からハンドラを決定しま
す。しかし、ユーザが ‘my.package.MyHandler’ を定義して、それが
‘alternate’ ハンドラを持つなら、設定システムは ‘alternate’ がハンドラを
参照していることを知りません。これを知らせるのに、一般的な解析システムで
、ユーザはこのように指定できます:

     handlers:
       file:
         # configuration of file handler goes here

       custom:
         (): my.package.MyHandler
         alternate: cfg://handlers.file

リテラル文字列 ‘'cfg://handlers.file'’ は、‘ext://’ 接頭辞が付いた文字列
と同じように分析されますが、インポート名前空間ではなく、環境設定自体が検
索されます。この機構は ‘str.format’ でできるのと同じようにドットやインデ
ックスのアクセスができます。従って、環境設定において以下のコード片が与え
られれば:

     handlers:
       email:
         class: logging.handlers.SMTPHandler
         mailhost: localhost
         fromaddr: my_app@domain.tld
         toaddrs:
           - support_team@domain.tld
           - dev_team@domain.tld
         subject: Houston, we have a problem.

in the configuration, the string ‘'cfg://handlers'’ would resolve to the
dict with key ‘handlers’, the string ‘'cfg://handlers.email’ would
resolve to the dict with key ‘email’ in the ‘handlers’ dict, and so on.
The string ‘'cfg://handlers.email.toaddrs[1]’ would resolve to
‘'dev_team@domain.tld'’ and the string
‘'cfg://handlers.email.toaddrs[0]'’ would resolve to the value
‘'support_team@domain.tld'’.  The ‘subject’ value could be accessed
using either ‘'cfg://handlers.email.subject'’ or, equivalently,
‘'cfg://handlers.email[subject]'’.  The latter form only needs to be
used if the key contains spaces or non-alphanumeric characters.  Please
note that the characters ‘[’ and ‘]’ are not allowed in the keys.  If an
index value consists only of decimal digits, access will be attempted
using the corresponding integer value, falling back to the string value
if needed.

文字列 ‘cfg://handlers.myhandler.mykey.123’ が与えられると、これは
‘config_dict['handlers']['myhandler']['mykey']['123']’ と分析されます。
文字列が ‘cfg://handlers.myhandler.mykey[123]’ と指定されたら、システム
は ‘config_dict['handlers']['myhandler']['mykey'][123]’ から値を引き出そ
うとし、失敗したら
‘config_dict['handlers']['myhandler']['mykey']['123']’ で代替します。


File: python.info,  Node: インポート解決とカスタムインポーター,  Next: Configuring QueueHandler and QueueListener,  Prev: 内部オブジェクトへのアクセス,  Up: 環境設定辞書スキーマ

5.16.6.11 インポート解決とカスタムインポーター
..............................................

インポート解決は、デフォルトではインポートを行うために *note
__import__(): 8a2. 組み込み関数を使用します。これを独自のインポートメカ
ニズムに置き換えたいと思うかもしれません: もしそうなら、
‘DictConfigurator’ あるいはその上位クラスである ‘BaseConfigurator’ クラ
スの ‘importer’ 属性を置換することができます。ただし、この関数はクラスか
らディスクリプタ経由でアクセスされる点に注意する必要があります。インポー
トを行うために Python callable を使用していて、それをインスタンスレベル
ではなくクラスレベルで定義したければ、 *note staticmethod(): 3ef. でそれ
をラップする必要があります。例えば:

     from importlib import import_module
     from logging.config import BaseConfigurator

     BaseConfigurator.importer = staticmethod(import_module)

configurator 'インスタンス' に対してインポート callable をセットする場合
は、 *note staticmethod(): 3ef. でラップする必要はありません。


File: python.info,  Node: Configuring QueueHandler and QueueListener,  Prev: インポート解決とカスタムインポーター,  Up: 環境設定辞書スキーマ

5.16.6.12 Configuring QueueHandler and QueueListener
....................................................

If you want to configure a *note QueueHandler: 1742, noting that this is
normally used in conjunction with a *note QueueListener: df9, you can
configure both together.  After the configuration, the ‘QueueListener’
instance will be available as the *note listener: 2c93. attribute of the
created handler, and that in turn will be available to you using *note
getHandlerByName(): 1743. and passing the name you have used for the
‘QueueHandler’ in your configuration.  The dictionary schema for
configuring the pair is shown in the example YAML snippet below.

     handlers:
       qhand:
         class: logging.handlers.QueueHandler
         queue: my.module.queue_factory
         listener: my.package.CustomListener
         handlers:
           - hand_name_1
           - hand_name_2
           ...

The ‘queue’ and ‘listener’ keys are optional.

If the ‘queue’ key is present, the corresponding value can be one of the
following:

   * An object implementing the *note Queue.put_nowait: 2c94. and *note
     Queue.get: 2c95. public API. For instance, this may be an actual
     instance of *note queue.Queue: 1356. or a subclass thereof, or a
     proxy obtained by *note
     multiprocessing.managers.SyncManager.Queue(): 2c96.

     This is of course only possible if you are constructing or
     modifying the configuration dictionary in code.

   * A string that resolves to a callable which, when called with no
     arguments, returns the queue instance to use.  That callable could
     be a *note queue.Queue: 1356. subclass or a function which returns
     a suitable queue instance, such as ‘my.module.queue_factory()’.

   * A dict with a ‘'()'’ key which is constructed in the usual way as
     discussed in *note ユーザ定義オブジェクト: 2c80.  The result of
     this construction should be a *note queue.Queue: 1356. instance.

If the ‘queue’ key is absent, a standard unbounded *note queue.Queue:
1356. instance is created and used.

If the ‘listener’ key is present, the corresponding value can be one of
the following:

   * A subclass of *note logging.handlers.QueueListener: df9.  This is
     of course only possible if you are constructing or modifying the
     configuration dictionary in code.

   * A string which resolves to a class which is a subclass of
     ‘QueueListener’, such as ‘'my.package.CustomListener'’.

   * A dict with a ‘'()'’ key which is constructed in the usual way as
     discussed in *note ユーザ定義オブジェクト: 2c80.  The result of
     this construction should be a callable with the same signature as
     the ‘QueueListener’ initializer.

If the ‘listener’ key is absent, *note logging.handlers.QueueListener:
df9. is used.

The values under the ‘handlers’ key are the names of other handlers in
the configuration (not shown in the above snippet) which will be passed
to the queue listener.

Any custom queue handler and listener classes will need to be defined
with the same initialization signatures as *note QueueHandler: 1742. and
*note QueueListener: df9.

Added in version 3.12.


File: python.info,  Node: 環境設定ファイルの書式,  Prev: 環境設定辞書スキーマ,  Up: logging config --- ログ記録の環境設定

5.16.6.13 環境設定ファイルの書式
................................

*note fileConfig(): b1f. が解釈できる環境設定ファイルの形式は、 *note
configparser: 1b. の機能に基づいています。ファイルには、 ‘[loggers]’,
‘[handlers]’, ‘[formatters]’ といったセクションが入っていなければならず
、各セクションではファイル中で定義されている各タイプのエンティティを名前
で指定しています。こうしたエンティティの各々について、そのエンティティを
どう設定するかを示した個別のセクションがあります。すなわち、 ‘log01’ と
いう名前の ‘[loggers]’ セクションにあるロガーに対しては、対応する詳細設
定がセクション ‘[logger_log01]’ に収められています。同様に、 ‘hand01’ と
いう名前の ‘[handlers]’ セクションにあるハンドラは ‘[handler_hand01]’ と
呼ばれるセクションに設定をもつことになり、 ‘[formatters]’ セクションにあ
る ‘form01’ は ‘[formatter_form01]’ というセクションで設定が指定されてい
ます。ルートロガーの設定は ‘[logger_root]’ と呼ばれるセクションで指定さ
れていなければなりません。

     注釈: *note fileConfig(): b1f. API は *note dictConfig(): 1180. API
     よりも古く、ロギングのある種の側面についてカバーする機能に欠けてい
     ます。たとえば *note fileConfig(): b1f. では数値レベルを超えたメッ
     セージを単に拾うフィルタリングを行う *note Filter: 11cc. オブジェク
     トを構成出来ません。 *note Filter: 11cc. のインスタンスをロギングの
     設定において持つ必要があるならば、 *note dictConfig(): 1180. を使う
     必要があるでしょう。設定の機能における将来の拡張は *note
     dictConfig(): 1180. に対して行われることに注意してください。ですか
     ら、そうするのが便利であるときに新しい API に乗り換えるのは良い考え
     です。

ファイルにおけるこれらのセクションの例を以下に示します。

     [loggers]
     keys=root,log02,log03,log04,log05,log06,log07

     [handlers]
     keys=hand01,hand02,hand03,hand04,hand05,hand06,hand07,hand08,hand09

     [formatters]
     keys=form01,form02,form03,form04,form05,form06,form07,form08,form09

ルートロガーでは、レベルとハンドラのリストを指定しなければなりません。ル
ートロガーのセクションの例を以下に示します。

     [logger_root]
     level=NOTSET
     handlers=hand01

‘level’ エントリは ‘DEBUG, INFO, WARNING, ERROR, CRITICAL’ または
‘NOTSET’ のいずれかの値を取ることができます。ルートロガーでのみ、
‘NOTSET’ は全てのメッセージがログとして記録されることを意味します。レベ
ルの値は ‘logging’ パッケージの名前空間のコンテキストで *note 評価:
20cb. されます。

‘handlers’ エントリはコンマで区切られたハンドラ名からなるリストで、
‘[handlers]’ セクションになくてはなりません。また、これらの各ハンドラの
名前に対応するセクションが設定ファイルに存在しなければなりません。

ルートロガー以外のロガーでは、いくつか追加の情報が必要になります。これは
以下の例のように表されます。

     [logger_parser]
     level=DEBUG
     handlers=hand01
     propagate=1
     qualname=compiler.parser

‘level’ および ‘handlers’ エントリはルートロガーのエントリと同様に解釈さ
れますが、非ルートロガーのレベルが ‘NOTSET’ に指定された場合、ロギングシ
ステムはロガー階層のより上位のロガーにロガーの実効レベルを問い合わせると
ころが違います。‘propagate’ エントリは、メッセージをロガー階層におけるこ
のロガーの上位のハンドラに伝播させることを示す 1 に設定されるか、メッセ
ージを階層の上位に伝播 'しない' ことを示す 0 に設定されます。‘qualname’
エントリはロガーのチャネル名を階層的に表したもの、すなわちアプリケーショ
ンがこのロガーを取得する際に使う名前になります。

ハンドラの環境設定を指定しているセクションは以下の例のようになります。

     [handler_hand01]
     class=StreamHandler
     level=NOTSET
     formatter=form01
     args=(sys.stdout,)

‘class’ エントリはハンドラのクラス (‘logging’ パッケージの名前空間におい
て *note eval(): 165. で決定されます) を示します。 ‘level’ はロガーの場
合と同じように解釈され、 ‘NOTSET’ は "すべてを記録する (log everything)"
と解釈されます。

‘formatter’ エントリはこのハンドラのフォーマッタに対するキー名を表します
。空文字列の場合、デフォルトのフォーマッタ (‘logging._defaultFormatter’)
が使われます。名前が指定されている場合、その名前は ‘[formatters]’ セクシ
ョンになくてはならず、対応するセクションが設定ファイル中になければなりま
せん。

‘args’ は、 ‘logging’ パッケージの名前空間のコンテキストで *note 評価:
20cb. される時点では、ハンドラークラスのコンストラクタのための引数のリス
トです。典型的なコンストラクタの引数が生成される方法については、各ハンド
ラのコンストラクタまたは下記の例を参照してください。指定されなければデフ
ォルトは ‘()’ になります。

オプションの ‘kwargs’ は、 ‘logging’ パッケージの名前空間のコンテキスト
で *note 評価: 20cb. される時点では、ハンドラークラスのコンストラクタの
ためのキーワード引数の辞書です。指定されなければデフォルトは ‘{}’ になり
ます。

     [handler_hand02]
     class=FileHandler
     level=DEBUG
     formatter=form02
     args=('python.log', 'w')

     [handler_hand03]
     class=handlers.SocketHandler
     level=INFO
     formatter=form03
     args=('localhost', handlers.DEFAULT_TCP_LOGGING_PORT)

     [handler_hand04]
     class=handlers.DatagramHandler
     level=WARN
     formatter=form04
     args=('localhost', handlers.DEFAULT_UDP_LOGGING_PORT)

     [handler_hand05]
     class=handlers.SysLogHandler
     level=ERROR
     formatter=form05
     args=(('localhost', handlers.SYSLOG_UDP_PORT), handlers.SysLogHandler.LOG_USER)

     [handler_hand06]
     class=handlers.NTEventLogHandler
     level=CRITICAL
     formatter=form06
     args=('Python Application', '', 'Application')

     [handler_hand07]
     class=handlers.SMTPHandler
     level=WARN
     formatter=form07
     args=('localhost', 'from@abc', ['user1@abc', 'user2@xyz'], 'Logger Subject')
     kwargs={'timeout': 10.0}

     [handler_hand08]
     class=handlers.MemoryHandler
     level=NOTSET
     formatter=form08
     target=
     args=(10, ERROR)

     [handler_hand09]
     class=handlers.HTTPHandler
     level=NOTSET
     formatter=form09
     args=('localhost:9022', '/log', 'GET')
     kwargs={'secure': True}

フォーマッタの環境設定を指定しているセクションは以下のような形式です。

     [formatter_form01]
     format=F1 %(asctime)s %(levelname)s %(message)s %(customfield)s
     datefmt=
     style=%
     validate=True
     defaults={'customfield': 'defaultvalue'}
     class=logging.Formatter

*note フォーマッターのセクション: 2c84. の辞書スキーマと同じキーを持つ、
フォーマッター設定の引数です。

The ‘defaults’ entry, when *note evaluated: 20cb. in the context of the
‘logging’ package's namespace, is a dictionary of default values for
custom formatting fields.  If not provided, it defaults to ‘None’.

     注釈: *note eval(): 165. を使用していることで、上述のようにソケット
     経由で設定を送受信するために *note listen(): f32. を使用しているこ
     とに起因する潜在的なセキュリティリスクがあります。そのリスクは、相
     互に信頼できない多数のユーザが同じマシン上でコードを実行する場合に
     制限されています; 詳細は *note listen(): f32. ドキュメンテーション
     を参照してください。

参考
....

*note logging: 7b. モジュール

     logging モジュールの API リファレンス。

*note logging.handlers: 7d. モジュール

     logging モジュールに含まれる、便利なハンドラです。


File: python.info,  Node: logging handlers --- ログ記録ハンドラー,  Next: getpass --- 可搬性のあるパスワード入力機構,  Prev: logging config --- ログ記録の環境設定,  Up: 汎用オペレーティングシステムサービス

5.16.7 ‘logging.handlers’ -- ログ記録ハンドラー
-----------------------------------------------

'ソースコード:' Lib/logging/handlers.py(1)

Important
.........

このページには、リファレンス情報だけが含まれています。チュートリアルは、
以下のページを参照してください

   * *note 基本チュートリアル: 11c6.

   * *note 上級チュートリアル: 11c7.

   * *note ロギングクックブック: 11c8.

__________________________________________________________________

このパッケージでは、以下の便利なハンドラが提供されています。なお、これら
のハンドラのうち、3 つ (*note StreamHandler: 11c9, *note FileHandler:
1809. および *note NullHandler: 1255.) は、実際には *note logging: 7b. モ
ジュール自身で定義されていますが、他のハンドラと一緒にここでドキュメント
化します。

* Menu:

* StreamHandler::
* FileHandler::
* NullHandler::
* WatchedFileHandler::
* BaseRotatingHandler::
* RotatingFileHandler::
* TimedRotatingFileHandler::
* SocketHandler::
* DatagramHandler::
* SysLogHandler::
* NTEventLogHandler::
* SMTPHandler::
* MemoryHandler::
* HTTPHandler::
* QueueHandler::
* QueueListener::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/logging/handlers.py


File: python.info,  Node: StreamHandler,  Next: FileHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.1 StreamHandler
......................

*note logging: 7b. コアパッケージに含まれる *note StreamHandler: 11c9. ク
ラスは、ログ出力を 'sys.stdout', 'sys.stderr' あるいは何らかのファイル風
(file-like) オブジェクト (あるいは、より正確に言えば ‘write()’ および
‘flush()’ メソッドをサポートする何らかのオブジェクト) といったストリーム
に送信します。

 -- クラス: logging.StreamHandler (stream=None)

     *note StreamHandler: 11c9. クラスの新たなインスタンスを返します。
     'stream' が指定された場合、インスタンスはログ出力先として指定された
     ストリームを使います; そうでない場合、 'sys.stderr' が使われます。

      -- メソッド: emit (record)

          フォーマッタが指定されていれば、フォーマッタを使ってレコードを
          書式化します。 次に、レコードが *note terminator: 2c9d. ととも
          にストリームに書き込まれます。 例外情報が存在する場合、 *note
          traceback.print_exception(): 81a. を使って書式化され、 ストリ
          ームの末尾につけられます。

      -- メソッド: flush ()

          ストリームの *note flush(): 2c9e. メソッドを呼び出してバッファ
          をフラッシュします。 ‘close()’ メソッドは *note Handler: 1439.
          から継承しているため何も出力を行わないので、 *note flush():
          2c9e. 呼び出しを明示的に行う必要があるかもしれません。

      -- メソッド: setStream (stream)

          このインスタンスの stream と指定された値が異なる場合、指定され
          た値に設定します。 新しい stream を設定する前に、古い stream は
          フラッシュされます。


          パラメータ: ‘stream’ - ハンドラがこれから使う stream 。


          戻り値: the old stream, if the stream was changed, or ‘None’
          if it wasn't.

          Added in version 3.7.

      -- の属性: terminator

          フォーマット済みのレコードをストリームに出力するときの終端とし
          て使われる文字列です。デフォルト値は ‘'\n'’ です。

          もし改行区切りにしたくない場合はハンドラーインスタンスの
          ‘terminator’ 属性に空文字列を設定してください。

          以前のバージョンでは、区切り文字は ‘'\n'’ にハードコードされて
          いました。

          Added in version 3.2.


File: python.info,  Node: FileHandler,  Next: NullHandler,  Prev: StreamHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.2 FileHandler
....................

*note logging: 7b. コアパッケージに含まれる *note FileHandler: 1809. ク
ラスは、ログ出力をディスク上のファイルに送信します。このクラスは出力機能
を *note StreamHandler: 11c9. から継承しています。

 -- クラス: logging.FileHandler (filename, mode='a', encoding=None,
          delay=False, errors=None)

     Returns a new instance of the *note FileHandler: 1809. class.  The
     specified file is opened and used as the stream for logging.  If
     'mode' is not specified, ‘'a'’ is used.  If 'encoding' is not
     ‘None’, it is used to open the file with that encoding.  If 'delay'
     is true, then file opening is deferred until the first call to
     *note emit(): 2ca1.  By default, the file grows indefinitely.  If
     'errors' is specified, it's used to determine how encoding errors
     are handled.

     バージョン 3.6 で変更: 文字列値に加え、 *note Path: 20a. オブジェク
     トも 'filename' 引数が受け取るようになりました。

     バージョン 3.9 で変更: 'errors' 引数が追加されました。

      -- メソッド: close ()

          ファイルを閉じます。

      -- メソッド: emit (record)

          'record' をファイルに出力します。

          終了時、ロギングがシャットダウンされたためにファイルがクローズ
          されており、ファイルのモードが 'w' である場合、 record は出力
          されません (bpo-42378(1) を参照してください)。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=42378


File: python.info,  Node: NullHandler,  Next: WatchedFileHandler,  Prev: FileHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.3 NullHandler
....................

Added in version 3.1.

*note logging: 7b. コアパッケージに含まれる *note NullHandler: 1255. ク
ラスは、いかなる書式化も出力も行いません。これは本質的には、ライブラリ開
発者に使われる 'no-op' ハンドラです。

 -- クラス: logging.NullHandler

     *note NullHandler: 1255. クラスの新しいインスタンスを返します。

      -- メソッド: emit (record)

          このメソッドは何もしません。

      -- メソッド: handle (record)

          このメソッドは何もしません。

      -- メソッド: createLock ()

          アクセスが特殊化される必要がある I/O が下にないので、このメソ
          ッドはロックに対して ‘None’ を返します。

*note NullHandler: 1255. の使い方の詳しい情報は、 *note
ライブラリのためのロギングの設定: 2ca8. を参照してください。


File: python.info,  Node: WatchedFileHandler,  Next: BaseRotatingHandler,  Prev: NullHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.4 WatchedFileHandler
...........................

*note logging.handlers: 7d. モジュールに含まれる *note
WatchedFileHandler: 2cab. クラスは、ログ記録先のファイルを監視する
‘FileHandler’ の一種です。ファイルが変更された場合、ファイルを閉じてから
ファイル名を使って開き直します。

ファイルはログファイルをローテーションさせる 'newsyslog' や 'logrotate'
のようなプログラムを使うことで変更されることがあります。このハンドラは、
Unix/Linux で使われることを意図していますが、ファイルが最後にログを出力
してから変わったかどうかを監視します。 (ファイルはデバイスや inode が変
わることで変わったと判断します。) ファイルが変わったら古いファイルのスト
リームは閉じて、現在のファイルを新しいストリームを取得するために開きます
。

このハンドラを Windows で使うことは適切ではありません。というのも
Windows では開いているログファイルを移動したり削除したりできないからです
- logging はファイルを排他的ロックを掛けて開きます - そのためこうしたハ
ンドラは必要ないのです。さらに、 Windows では 'ST_INO' がサポートされて
いません; *note stat(): 46d. はこの値として常に 0 を返します。

 -- クラス: logging.handlers.WatchedFileHandler (filename, mode='a',
          encoding=None, delay=False, errors=None)

     Returns a new instance of the *note WatchedFileHandler: 2cab.
     class.  The specified file is opened and used as the stream for
     logging.  If 'mode' is not specified, ‘'a'’ is used.  If 'encoding'
     is not ‘None’, it is used to open the file with that encoding.  If
     'delay' is true, then file opening is deferred until the first call
     to *note emit(): 2cac.  By default, the file grows indefinitely.
     If 'errors' is provided, it determines how encoding errors are
     handled.

     バージョン 3.6 で変更: 文字列値に加え、 *note Path: 20a. オブジェク
     トも 'filename' 引数が受け取るようになりました。

     バージョン 3.9 で変更: 'errors' 引数が追加されました。

      -- メソッド: reopenIfNeeded ()

          ファイルが変更されていないかチェックします。 もし変更されてい
          れば、手始めにレコードをファイルに出力し、既存のストリームはフ
          ラッシュして閉じられ、ファイルが再度開かれます。

          Added in version 3.6.

      -- メソッド: emit (record)

          レコードをファイルに出力しますが、最初に *note
          reopenIfNeeded(): c84. を呼び出して、変更があった場合はファイ
          ルを再度開きます。


File: python.info,  Node: BaseRotatingHandler,  Next: RotatingFileHandler,  Prev: WatchedFileHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.5 BaseRotatingHandler
............................

*note logging.handlers: 7d. モジュールに存在する *note
BaseRotatingHandler: 2caf. クラスは、ローテートを行うファイルハンドラ
*note RotatingFileHandler: 153b. と *note TimedRotatingFileHandler: f2e.
のベースクラスです。このクラスをインスタンス化する必要はありませんが、オ
ーバーライドすることになるかもしれない属性とメソッドを持っています。

 -- クラス: logging.handlers.BaseRotatingHandler (filename, mode,
          encoding=None, delay=False, errors=None)

     パラメータは ‘FileHandler’ と同じです。属性は次の通りです:

      -- の属性: namer

          この属性に callable がセットされた場合、 *note
          rotation_filename(): 2cb1. メソッドはこの callable に委譲され
          ます。 callable に渡されるパラメータは *note
          rotation_filename(): 2cb1. に渡されたものです。

               注釈: namer 関数はロールオーバー中にかなりの回数呼ばれま
               す。そのため、できるだけ単純で、速くあるべきです。さらに
               、それは与えられた入力に対しては常に同じ出力を返すべきで
               す。そうでなければ、ロールオーバーの振る舞いは期待通りに
               動かないかもしれません。

               namer 属性にローテーションの際に使われるファイル名に埋め
               込むための特定の属性を保持しようとする場合に注意が必要な
               ことは、注意喚起しておくべきでしょう。たとえば *note
               RotatingFileHandler: 153b. は、ローテーションが期待通りに
               動作するために、名前に連続した番号を含むようなファイル名
               のリストを持つことを期待します。また *note
               TimedRotatingFileHandler: f2e. は (ハンドラの初期化時に渡
               された ‘backupCount’ にもとづいて) 削除すべき古いファイル
               を決定しながら、古いログファイルを削除します。この仕組み
               が動作するためには、ファイル名は名前に含まれる日付や時刻
               でソート可能である必要があり、 namer はそれを尊重しなけれ
               ばなりません (namer がこの規則を尊重したくない場合、その
               ような namer は *note getFilesToDelete(): 2cb2. メソッド
               が特定の命名規則に適合するようにオーバーライドされた
               *note TimedRotatingFileHandler: f2e. の派生クラス内で使う
               必要があるでしょう)。

          Added in version 3.3.

      -- の属性: rotator

          この属性に callable がセットされた場合、 *note rotate(): 2cb4.
          メソッドはこの callable に委譲されます。 callable に渡されるパ
          ラメータは *note rotate(): 2cb4. に渡されたものです。

          Added in version 3.3.

      -- メソッド: rotation_filename (default_name)

          ローテートを行う際にログファイルのファイル名を変更します。

          このメソッドは、ファイル名をカスタマイズするために提供されます
          。

          デフォルト実装は、ハンドラの 'namer' 属性が callable だった場
          合、その callable を呼んでデフォルト名を渡します。属性が
          callable でない場合 (デフォルトは ‘None’ です)、名前は変更せず
          に返されます。


          パラメータ: ‘default_name’ - ログファイルのデフォルトのファイ
          ル名。

          Added in version 3.3.

      -- メソッド: rotate (source, dest)

          ローテートが行われる時、現在のログをローテートします。

          デフォルト実装は、 ハンドラの 'rotator' 属性が callable だった
          場合、その callable を呼んで source と dest 引数を渡します。属
          性が callable でない場合 (デフォルトは ‘None’ です)、単に
          source が destination に改名されます。


          パラメータ:

             * ‘source’ - ソースファイル名。これは通常ベースファイル名 、
               例えば 'test.log' となります。

             * ‘dest’ - 変更先ファイル名。これは通常ソースファイルをロー
               テートしたもの (例えば 'test.log.1') です。

          Added in version 3.3.

これらの属性が存在する理由は、サブクラス化を省略できるようにするためです
。 *note RotatingFileHandler: 153b. と *note TimedRotatingFileHandler:
f2e. のインスタンスに対して同じ callable が使えます。もし namer や
rotator callable が例外を上げれば、 ‘emit()’ 呼び出しで発生した他の例外
と同じ方法で、つまりハンドラの ‘handleError()’ メソッドによって扱われま
す。

ローテート処理に大幅な変更を加える必要があれば、メソッドをオーバーライド
することができます。

例えば、 *note rotator と namer
を使ってログローテートをカスタマイズする: 2cb5. を参照してください。


File: python.info,  Node: RotatingFileHandler,  Next: TimedRotatingFileHandler,  Prev: BaseRotatingHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.6 RotatingFileHandler
............................

*note logging.handlers: 7d. モジュールに含まれる *note
RotatingFileHandler: 153b. クラスは、ディスク上のログファイルに対するロ
ーテーション処理をサポートします。

 -- クラス: logging.handlers.RotatingFileHandler (filename, mode='a',
          maxBytes=0, backupCount=0, encoding=None, delay=False,
          errors=None)

     *note RotatingFileHandler: 153b. クラスの新たなインスタンスを返しま
     す。 指定されたファイルが開かれ、ログ記録のためのストリームとして使
     われます。 'mode' が指定されなかった場合、 ‘'a'’ が使われます。
     'encoding' が ‘None’ でない場合、その値はファイルを開くときのエンコ
     ーディングとして使われます。 'delay' が真ならば、ファイルを開くのは
     最初の *note emit(): 2cb8. 呼び出しまで遅らせられます。 デフォルト
     では、ファイルは無制限に大きくなりつづけます。 'errors' が提供され
     ると、エンコーディングエラーの処理方法を決定します。

     'maxBytes' および 'backupCount' 値を指定することで、あらかじめ決め
     られたサイズでファイルをロールオーバ ('rollover') させることができ
     ます。 指定サイズを超えそうになると、ファイルは閉じられ、暗黙のうち
     に新たなファイルが開かれます。 ロールオーバは現在のログファイルの長
     さが 'maxBytes' に近くなると常に起きますが、 'maxBytes' または
     'backupCount' がゼロならロールオーバは起きなくなってしまうので、一
     般的には 'backupCount' を少なくとも 1 に設定し 'maxBytes' を非ゼロ
     にするのが良いでしょう。 'backupCount' が非ゼロのとき、システムは古
     いログファイルをファイル名に ".1", ".2" といった拡張子を追加して保
     存します。 例えば、 'backupCount' が 5 で、基本のファイル名が
     ‘app.log’ なら、 ‘app.log’, ‘app.log.1’, ‘app.log.2’ ...  と続き、
     ‘app.log.5’ までを得ることになります。 ログの書き込み対象になるファ
     イルは常に ‘app.log’ です。このファイルが満杯になると、ファイルは閉
     じられ、 ‘app.log.1’ に名前が変更されます。 ‘app.log.1’,
     ‘app.log.2’ などが存在する場合、それらのファイルはそれぞれ
     ‘app.log.2’, ‘app.log.3’ といった具合に名前が変更されます。

     バージョン 3.6 で変更: 文字列値に加え、 *note Path: 20a. オブジェク
     トも 'filename' 引数が受け取るようになりました。

     バージョン 3.9 で変更: 'errors' 引数が追加されました。

      -- メソッド: doRollover ()

          上述のような方法でロールオーバを行います。

      -- メソッド: emit (record)

          上述のようなロールオーバを行いながら、レコードをファイルに出力
          します。


File: python.info,  Node: TimedRotatingFileHandler,  Next: SocketHandler,  Prev: RotatingFileHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.7 TimedRotatingFileHandler
.................................

*note logging.handlers: 7d. モジュールに含まれる *note
TimedRotatingFileHandler: f2e. クラスは、特定の時間間隔でのログローテー
ションをサポートしています。

 -- クラス: logging.handlers.TimedRotatingFileHandler (filename,
          when='h', interval=1, backupCount=0, encoding=None,
          delay=False, utc=False, atTime=None, errors=None)

     *note TimedRotatingFileHandler: f2e. クラスの新たなインスタンスを返
     します。 'filename' に指定したファイルを開き、ログ出力先のストリー
     ムとして使います。ログファイルのローテーション時には、ファイル名に
     拡張子 (suffix) をつけます。ログファイルのローテーションは 'when' お
     よび 'interval' の積に基づいて行います。

     'when' は 'interval' の単位を指定するために使います。使える値は下表
     の通りです。大小文字の区別は行いません。

     値                   'interval' の単位                'atTime' の使用有無/使用方
                                                           法
                                                           
     ------------------------------------------------------------------------------------
                                                           
     ‘'S'’                秒                               無視
                                                           
                                                           
     ‘'M'’                分                               無視
                                                           
                                                           
     ‘'H'’                時間                             無視
                                                           
                                                           
     ‘'D'’                日                               無視
                                                           
                                                           
     ‘'W0'-'W6'’          曜日 (0=月曜)                    初期のロールオーバー時刻の
                                                           算出に使用
                                                           
                                                           
     ‘'midnight'’         'atTime' が指定されなかった場    初期のロールオーバー時刻の
                          合は深夜に、そうでない場合は     算出に使用
                          'atTime' の時刻にロールオーバ    
                          ーされます
                          

     曜日ベースのローテーションを使う場合は、月曜として 'W0' を、火曜と
     して 'W1' を、…、日曜として 'W6' を指定します。このケースの場合は、
     'interval' は使われません。

     古いログファイルの保存時、ロギングシステムによりファイル名に拡張子
     が付けられます。 ロールオーバ間隔によって、strftime の
     ‘%Y-%m-%d_%H-%M-%S’ 形式またはその前方の一部を使って、日付と時間に
     基づいた拡張子が付けられます。

     最初に次のロールオーバー時間を計算するとき (ハンドラが生成されると
     き)、次のローテーションがいつ起こるかを計算するために、既存のログフ
     ァイルの最終変更時刻または現在の時間が使用されます。

     'utc' 引数が true の場合時刻は UTC になり、それ以外では現地時間が使
     われます。

     'backupCount' がゼロでない場合、保存されるファイル数は高々
     'backupCount' 個で、それ以上のファイルがロールオーバされる時に作ら
     れるならば、一番古いものが削除されます。削除のロジックは interval で
     決まるファイルを削除するので、 interval を変えると古いファイルが残
     ったままになることもあります。

     'delay' が true なら、ファイルを開くのは *note emit(): 2cbc. の最初
     の呼び出しまで延期されます。

     'atTime' が ‘None’ でない場合、それは ‘datetime.time’ インスタンス
     でなければなりません。ロールオーバーが「夜中」「特定の曜日」に設定
     されていて、ロールが発生する時刻を指定します。 'atTime' の値は '初
     期' のロールオーバーの計算に使われますが、後続のロールオーバーは通
     常の間隔の計算で算出されます。

     'errors' が指定されると、エンコーディングエラーの取り扱い方法を決定
     します。

          注釈: 最初のロールオーバーの計算はハンドラーが初期化されたとき
          に行われます。後続のロールオーバーは、ロールオーバーが発生し、
          ロールオーバーが出力した時にのみ行われます。これを念頭に置いて
          おかないと混乱する可能性があります。例えば、インターバルが '毎
          分' に設定されていて、1分ごとにログファイルが常に生成されると
          は限りません。アプリケーションが実行されている間、1分に1回以上
          のログ出力されて 'いるとすると' 毎分、分割されたログファイルが
          出力されますが、そうでなく、5分ごとに出力される場合は、出力さ
          れずにロールオーバーが実行されなかった時間分のギャップが生じま
          す。

     バージョン 3.4 で変更: 'atTime' パラメータが追加されました。

     バージョン 3.6 で変更: 文字列値に加え、 *note Path: 20a. オブジェク
     トも 'filename' 引数が受け取るようになりました。

     バージョン 3.9 で変更: 'errors' 引数が追加されました。

      -- メソッド: doRollover ()

          上述のような方法でロールオーバを行います。

      -- メソッド: emit (record)

          上で説明した方法でロールオーバを行いながら、レコードをファイル
          に出力します。

      -- メソッド: getFilesToDelete ()

          ロールオーバーの一環として削除されるファイル名のリストを返しま
          す。それらのファイルは、ハンドラによって書き込まれた最も古いバ
          ックアップログファイルの絶対パスです。


File: python.info,  Node: SocketHandler,  Next: DatagramHandler,  Prev: TimedRotatingFileHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.8 SocketHandler
......................

*note logging.handlers: 7d. モジュールに含まれる *note SocketHandler:
f2f. クラスは、ログ出力をネットワークソケットに送信します。基底クラスで
は TCP ソケットを用います。

 -- クラス: logging.handlers.SocketHandler (host, port)

     アドレスが 'host' および 'port' で与えられた遠隔のマシンと通信する
     ようにした *note SocketHandler: f2f. クラスのインスタンスを生成して
     返します。

     バージョン 3.4 で変更: ‘port’ に ‘None’ を指定すると、Unix ドメイン
     ソケットが ‘host’ 値を用いて作られます - そうでない場合は TCP ソケ
     ットが作られます。

      -- メソッド: close ()

          ソケットを閉じます。

      -- メソッド: emit ()

          レコードの属性辞書を pickle して、バイナリ形式でソケットに書き
          込みます。ソケット操作でエラーが生じた場合、暗黙のうちにパケッ
          トは捨てられます。事前に接続が失われていた場合、接続を再度確立
          します。受信端でレコードを unpickle して *note LogRecord: fb3.
          にするには、 *note makeLogRecord(): 2c5d. 関数を使ってください
          。

      -- メソッド: handleError ()

          *note emit(): 2cc1. の処理中に発生したエラーを処理します。よく
          ある原因は接続の消失です。次のイベント発生時に再試行できるよう
          にソケットを閉じます。

      -- メソッド: makeSocket ()

          サブクラスで必要なソケット形式を詳細に定義できるようにするため
          のファクトリメソッドです。デフォルトの実装では、 TCP ソケット
          (*note socket.SOCK_STREAM: 12c1.) を生成します。

      -- メソッド: makePickle (record)

          レコードの属性辞書をバイナリ形式に pickle したものの先頭に長さ
          情報を付け、ソケットを介して送信できるようにして返します。 こ
          の操作の詳細は次のコードと同等です:

               data = pickle.dumps(record_attr_dict, 1)
               datalen = struct.pack('>L', len(data))
               return datalen + data

          pickle が完全に安全というわけではないことに注意してください。
          セキュリティに関して心配なら、より安全なメカニズムを実装するた
          めにこのメソッドをオーバーライドすると良いでしょう。例えば、
          HMAC を使って pickle に署名して、受け取る側ではそれを検証する
          ことができます。あるいはまた、受け取る側でグローバルなオブジェ
          クトの unpickle を無効にすることができます。

      -- メソッド: send (packet)

          pickle したバイト文字列 'packet' をソケットに送信します。 送信
          するバイト文字列のフォーマットは、 *note makePickle(): 2cc4. の
          ドキュメントで解説されています。

          この関数はネットワークがビジーの時に発生する部分的送信に対応し
          ています。

      -- メソッド: createSocket ()

          ソケットの生成を試みます。失敗時には、指数的な減速アルゴリズム
          を使います。最初の失敗時には、ハンドラは送ろうとしていたメッセ
          ージを落とします。続くメッセージが同じインスタンスで扱われたと
          き、幾らかの時間が経過するまで接続を試みません。デフォルトのパ
          ラメタは、最初の遅延時間が 1 秒で、その遅延時間の後でそれでも
          接続が確保できないなら、遅延時間は 2 倍づつになり、最大で 30 秒
          になります。

          この働きは、以下のハンドラ属性で制御されます:

             * ‘retryStart’ (最初の遅延時間、デフォルトは 1.0 秒)。

             * ‘retryFactor’ (乗数、デフォルトは 2.0)。

             * ‘retryMax’ (最大遅延時間、デフォルトは 30.0 秒)。

          つまり、ハンドラが使われた '後に' リモートリスナが起動した場合
          、メッセージが失われてしまうことがあります (ハンドラは、遅延時
          間が経過するまで接続を試みようとさえせず、その遅延時間中に通知
          なくメッセージを捨てるので)。


File: python.info,  Node: DatagramHandler,  Next: SysLogHandler,  Prev: SocketHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.9 DatagramHandler
........................

*note logging.handlers: 7d. モジュールに含まれる *note DatagramHandler:
f30. クラスは、 *note SocketHandler: f2f. を継承しており、 UDP ソケット
を介したログ記録メッセージの送信をサポートしています。

 -- クラス: logging.handlers.DatagramHandler (host, port)

     アドレスが 'host' および 'port' で与えられた遠隔のマシンと通信する
     ようにした *note DatagramHandler: f30. クラスのインスタンスを生成し
     て返します。

          注釈: UDP はストリーミングプロトコルではないため、このハンドラ
          のインスタンスと 'host' に指定したホストとの間に持続的なコネク
          ションはありません。この理由から、ネットワークソケットを使う場
          合、イベントがログされるごとに DNS のルックアップを行わなけれ
          ばならないかもしれず、それによりシステムにある程度の待ち時間を
          もたらす可能性があります。この待ち時間が問題になる場合、自身で
          ルックアップを行い、ホスト名の代わりにルックアップの結果得られ
          た IP アドレスを使ってハンドラを初期化することができます。

     バージョン 3.4 で変更: ‘port’ に ‘None’ を指定すると、Unix ドメイン
     ソケットが ‘host’ 値を用いて作られます - そうでない場合は UDP ソケ
     ットが作られます。

      -- メソッド: emit ()

          レコードの属性辞書を pickle して、バイナリ形式でソケットに書き
          込みます。ソケット操作でエラーが生じた場合、暗黙のうちにパケッ
          トは捨てられます。事前に接続が失われていた場合、接続を再度確立
          します。受信端でレコードを unpickle して *note LogRecord: fb3.
          にするには、 *note makeLogRecord(): 2c5d. 関数を使ってください
          。

      -- メソッド: makeSocket ()

          ここで *note SocketHandler: f2f. のファクトリメソッドをオーバ
          ライドして、 UDP ソケット (*note socket.SOCK_DGRAM: 12c0.) を
          生成しています。

      -- メソッド: send (s)

          pickle したバイト文字列をソケットに送信します。 送信するバイト
          文字列のフォーマットは、 *note SocketHandler.makePickle():
          2cc4. のドキュメントで解説されています。


File: python.info,  Node: SysLogHandler,  Next: NTEventLogHandler,  Prev: DatagramHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.10 SysLogHandler
.......................

*note logging.handlers: 7d. モジュールに含まれる *note SysLogHandler:
628. クラスは、ログ記録メッセージを遠隔またはローカルの Unix syslog に送
信する機能をサポートしています。

 -- クラス: logging.handlers.SysLogHandler (address=('localhost',
          SYSLOG_UDP_PORT), facility=LOG_USER,
          socktype=socket.SOCK_DGRAM)

     遠隔の Unix マシンと通信するための、 *note SysLogHandler: 628. クラ
     スの新たなインスタンスを返します。マシンのアドレスは ‘(host, port)’
     のタプル形式をとる 'address' で与えられます。 'address' が指定され
     ない場合、 ‘('localhost', 514)’ が使われます。アドレスは UDP ソケッ
     トを使って開かれます。 ‘(host, port)’ のタプル形式の代わりに文字列
     で "/dev/log" のように与えることもできます。この場合、 Unix ドメイ
     ンソケットが syslog にメッセージを送るのに使われます。 'facility' が
     指定されない場合、 ‘LOG_USER’ が使われます。開かれるソケットの型は
     、 'socktype' 引数に依り、デフォルトは *note socket.SOCK_DGRAM:
     12c0. で、UDP ソケットを開きます。 (rsyslog のような新しい syslog デ
     ーモンと使うために) TCP ソケットを開くには、 *note
     socket.SOCK_STREAM: 12c1. の値を指定してください。

     使用中のサーバが UDP ポート 514 を待機していない場合、 *note
     SysLogHandler: 628. が正常に動作していないように見える場合がありま
     す。その場合、ドメインソケットに使うべきアドレスを調べてください。
     そのアドレスはシステムによって異なります。例えば、Linux システムで
     は通常 '/dev/log' ですが、 OS X では '/var/run/syslog' です。プラッ
     トフォームを確認し、適切なアドレスを使う必要があります (アプリケー
     ションを複数のプラットフォーム上で動作させる必要がある場合、実行時
     に確認する必要があるかもしれません)。Windows では、多くの場合、UDP
     オプションを使用する必要があります。

          注釈: macOS 12.x (Monterey) において、 Apple 社は syslog デー
          モンの振る舞いを変更しました - デーモンはドメインソケットをの
          待ち受けを行いません。したがって、このシステム上では *note
          SysLogHandler: 628. が動作することは期待できません。

          より詳細な情報は gh-91070(1) を参照して下さい。

     バージョン 3.2 で変更: 'socktype' が追加されました。

      -- メソッド: close ()

          遠隔ホストへのソケットを閉じます。

      -- メソッド: createSocket ()

          Tries to create a socket and, if it's not a datagram socket,
          connect it to the other end.  This method is called during
          handler initialization, but it's not regarded as an error if
          the other end isn't listening at this point - the method will
          be called again when emitting an event, if there is no socket
          at that point.

          Added in version 3.11.

      -- メソッド: emit (record)

          レコードは書式化された後、 syslog サーバに送信されます。例外情
          報が存在しても、サーバには '送信されません' 。

          バージョン 3.2.1 で変更: (参照: bpo-12168(2)) 初期のバージョン
          では、 syslog デーモンに送られるメッセージは常に NUL バイトで
          終端していました。初期のバージョンの syslog デーモンが NUL 終
          端されたメッセージを期待していたからです - たとえ、それが適切
          な仕様 ( RFC 5424(3)) にはなかったとしても。 syslog デーモンの
          新しいバージョンは NUL バイトを期待せず、代わりにもしそれがあ
          る場合は削除します。さらに、より最近のデーモン (RFC 5424 によ
          り忠実なバージョン) は、メッセージの一部として NUL バイトを通
          します。

          このような異なるデーモンの振る舞いすべてに対して syslog メッセ
          ージの取り扱いをより容易にするため、 NUL バイトの追加はクラス
          レベル属性 ‘append_nul’ を使用して設定できるようになりました。
          これはデフォルトで ‘True’ (既存の振る舞いを保持) ですが、
          ‘SysLogHandler’ インスタンスが NUL 終端文字を追加 'しない' よ
          うに ‘False’ にセットすることができます。

          バージョン 3.3 で変更: (参照: bpo-12419(4)) 以前のバージョンで
          は、メッセージソースを識別するための "ident" あるいは "tag" プ
          リフィックス機能はありませんでした。これは、今ではクラスレベル
          属性を使用して指定することができるようになりました。デフォルト
          では既存の振る舞いを保持するために ‘""’ ですが、特定の
          ‘SysLogHandler’ インスタンスが扱うすべてのメッセージに識別子を
          前置するようにそれをオーバーライドすることができます。識別子は
          バイトではなくテキストでなければならず、正確にそのままメッセー
          ジに前置されることに注意してください。

      -- メソッド: encodePriority (facility, priority)

          ファシリティおよび優先度を整数に符号化します。値は文字列でも整
          数でも渡すことができます。文字列が渡された場合、内部の対応付け
          辞書が使われ、整数に変換されます。

          シンボリックな ‘LOG_’ 値は *note SysLogHandler: 628. で定義さ
          れています。これは ‘sys/syslog.h’ ヘッダーファイルで定義された
          値を反映しています。

          '優先度'

          名前 (文字列)                  シンボル値
                                         
          ---------------------------------------------------
                                         
          ‘alert’                        LOG_ALERT
                                         
                                         
          ‘crit’ or ‘critical’           LOG_CRIT
                                         
                                         
          ‘debug’                        LOG_DEBUG
                                         
                                         
          ‘emerg’ or ‘panic’             LOG_EMERG
                                         
                                         
          ‘err’ or ‘error’               LOG_ERR
                                         
                                         
          ‘info’                         LOG_INFO
                                         
                                         
          ‘notice’                       LOG_NOTICE
                                         
                                         
          ‘warn’ or ‘warning’            LOG_WARNING
                                         

          'ファシリティ'

          名前 (文字列)       シンボル値
                              
          ----------------------------------------
                              
          ‘auth’              LOG_AUTH
                              
                              
          ‘authpriv’          LOG_AUTHPRIV
                              
                              
          ‘cron’              LOG_CRON
                              
                              
          ‘daemon’            LOG_DAEMON
                              
                              
          ‘ftp’               LOG_FTP
                              
                              
          ‘kern’              LOG_KERN
                              
                              
          ‘lpr’               LOG_LPR
                              
                              
          ‘mail’              LOG_MAIL
                              
                              
          ‘news’              LOG_NEWS
                              
                              
          ‘syslog’            LOG_SYSLOG
                              
                              
          ‘user’              LOG_USER
                              
                              
          ‘uucp’              LOG_UUCP
                              
                              
          ‘local0’            LOG_LOCAL0
                              
                              
          ‘local1’            LOG_LOCAL1
                              
                              
          ‘local2’            LOG_LOCAL2
                              
                              
          ‘local3’            LOG_LOCAL3
                              
                              
          ‘local4’            LOG_LOCAL4
                              
                              
          ‘local5’            LOG_LOCAL5
                              
                              
          ‘local6’            LOG_LOCAL6
                              
                              
          ‘local7’            LOG_LOCAL7
                              

      -- メソッド: mapPriority (levelname)

          ログレベル名を syslog 優先度名に対応付けます。カスタムレベルを
          使用している場合や、デフォルトアルゴリズムがニーズに適していな
          い場合には、このメソッドをオーバーライドする必要があるかもしれ
          ません。デフォルトアルゴリズムは、 ‘DEBUG’, ‘INFO’, ‘WARNING’,
          ‘ERROR’, ‘CRITICAL’ を等価な syslog 名に、他のすべてのレベル名
          を "warning" に対応付けます。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/91070

   (2) https://bugs.python.org/issue?@action=redirect&bpo=12168

   (3) https://datatracker.ietf.org/doc/html/rfc5424.html

   (4) https://bugs.python.org/issue?@action=redirect&bpo=12419


File: python.info,  Node: NTEventLogHandler,  Next: SMTPHandler,  Prev: SysLogHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.11 NTEventLogHandler
...........................

*note logging.handlers: 7d. モジュールに含まれる *note
NTEventLogHandler: 2cd3. クラスは、ログ記録メッセージをローカルな
Windows NT, Windows 2000, または Windows XP のイベントログに送信する機能
をサポートします。この機能を使えるようにするには、 Mark Hammond による
Python 用 Win32 拡張パッケージをインストールする必要があります。

 -- クラス: logging.handlers.NTEventLogHandler (appname, dllname=None,
          logtype='Application')

     *note NTEventLogHandler: 2cd3. クラスの新たなインスタンスを返します
     。 'appname' はイベントログに表示する際のアプリケーション名を定義す
     るために使われます。この名前を使って適切なレジストリエントリが生成
     されます。 'dllname' はログに保存するメッセージ定義の入った .dll ま
     たは .exe ファイルへの完全修飾パス名を与えなければなりません (指定
     されない場合、 ‘'win32service.pyd'’ が使われます - このライブラリは
     Win32 拡張とともにインストールされ、いくつかのプレースホルダとなる
     メッセージ定義を含んでいます)。これらのプレースホルダを利用すると、
     メッセージの発信源全体がログに記録されるため、イベントログは巨大に
     なるので注意してください。 'logtype' は ‘'Application'’,
     ‘'System'’, ‘'Security'’ のいずれかで、デフォルトは ‘'Application'’
     です。

      -- メソッド: close ()

          現時点では、イベントログエントリの発信源としてのアプリケーショ
          ン名をレジストリから除去することはできます。しかしこれを行うと
          、イベントログビューアで意図した通りにログが見えなくなるでしょ
          う - これはイベントログが .dll 名を取得するためにレジストリに
          アクセスできなければならないからです。現在のバージョンではこの
          操作を行いません。

      -- メソッド: emit (record)

          メッセージ ID、イベントカテゴリ、イベント型を決定し、メッセー
          ジを NT イベントログに記録します。

      -- メソッド: getEventCategory (record)

          レコードに対するイベントカテゴリを返します。自作のカテゴリを指
          定したい場合、このメソッドをオーバライドしてください。このクラ
          スのバージョンのメソッドは 0 を返します。

      -- メソッド: getEventType (record)

          レコードのイベント型を返します。自作の型を指定したい場合、この
          メソッドをオーバライドしてください。このクラスのバージョンのメ
          ソッドは、ハンドラの 'typemap' 属性を使って対応付けを行います
          。この属性は ‘__init__()’ で初期化され、 ‘DEBUG’, ‘INFO’,
          ‘WARNING’, ‘ERROR’, ‘CRITICAL’ が入っています。自作のレベルを
          使っているのなら、このメソッドをオーバライドするか、ハンドラの
          'typemap' 属性に適切な辞書を配置する必要があるでしょう。

      -- メソッド: getMessageID (record)

          レコードのメッセージ ID を返します。自作のメッセージを使ってい
          るのなら、ロガーに渡される 'msg' を書式化文字列ではなく ID に
          します。その上で、辞書参照を行ってメッセージ ID を得ます。この
          クラスのバージョンでは 1 を返します。この値は
          ‘win32service.pyd’ における基本メッセージ ID です。


File: python.info,  Node: SMTPHandler,  Next: MemoryHandler,  Prev: NTEventLogHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.12 SMTPHandler
.....................

*note logging.handlers: 7d. モジュールに含まれる *note SMTPHandler:
2cdb. クラスは、 SMTP を介したログ記録メッセージの送信機能をサポートしま
す。

 -- クラス: logging.handlers.SMTPHandler (mailhost, fromaddr, toaddrs,
          subject, credentials=None, secure=None, timeout=1.0)

     新たな *note SMTPHandler: 2cdb. クラスのインスタンスを返します。イ
     ンスタンスは email の from および to アドレス行、および subject 行
     とともに初期化されます。 'toaddrs' は文字列からなるリストでなければ
     なりません。非標準の SMTP ポートを指定するには、 'mailhost' 引数に
     (host, port) のタプル形式を指定します。文字列を使った場合、標準の
     SMTP ポートが使われます。もし SMTP サーバが認証を必要とするならば、
     (username, password) のタプル形式を 'credentials' 引数に指定するこ
     とができます。

     セキュアプロトコル (TLS) の使用を指定するには 'secure' 引数にタプル
     を渡してください。これは認証情報が渡された場合のみ使用されます。タ
     プルは、空のタプルか、キーファイルの名前を持つ1要素のタプルか、また
     はキーファイルと証明書ファイルの名前を持つ2要素のタプルのいずれかで
     なければなりません。 (このタプルは *note smtplib.SMTP.starttls():
     110b. メソッドに渡されます。)

     SMTP サーバとのコミュニケーションのために、 'timeout' 引数を使用し
     てタイムアウトを指定することができます。

     バージョン 3.3 で変更: Added the 'timeout' parameter.

      -- メソッド: emit (record)

          レコードを書式化し、指定されたアドレスに送信します。

      -- メソッド: getSubject (record)

          レコードに応じたサブジェクト行を指定したいなら、このメソッドを
          オーバライドしてください。


File: python.info,  Node: MemoryHandler,  Next: HTTPHandler,  Prev: SMTPHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.13 MemoryHandler
.......................

*note logging.handlers: 7d. モジュールに含まれる *note MemoryHandler:
2c8f. は、ログ記録するレコードをメモリ上にバッファリングし、定期的にその
内容をターゲット ('target') となるハンドラにフラッシュする機能をサポート
しています。フラッシュ処理はバッファが一杯になるか、ある深刻度かそれ以上
のレベルを持つイベントが観測された際に行われます。

*note MemoryHandler: 2c8f. はより一般的な抽象クラス、 *note
BufferingHandler: 2ce0. のサブクラスです。この抽象クラスでは、ログ記録す
るレコードをメモリ上にバッファリングします。各レコードがバッファに追加さ
れる毎に、 ‘shouldFlush()’ を呼び出してバッファをフラッシュすべきかどう
か調べます。フラッシュする必要がある場合、 ‘flush()’ がフラッシュ処理を
行うものと想定されます。

 -- クラス: logging.handlers.BufferingHandler (capacity)

     容量つきのバッファーを設定してハンドラーが初期化されます。
     'capacity' はバッファ可能なログレコード数を意味します。

      -- メソッド: emit (record)

          レコードをバッファに追加します。 *note shouldFlush(): 2ce2. が
          true を返す場合、バッファを処理するために *note flush(): 2ce3.
          を呼び出します。

      -- メソッド: flush ()

          For a *note BufferingHandler: 2ce0. instance, flushing means
          that it sets the buffer to an empty list.  This method can be
          overwritten to implement more useful flushing behavior.

      -- メソッド: shouldFlush (record)

          バッファが許容量に達している場合に ‘True’ を返します。このメソ
          ッドは自作のフラッシュ処理方針を実装するためにオーバライドする
          ことができます。

 -- クラス: logging.handlers.MemoryHandler (capacity, flushLevel=ERROR,
          target=None, flushOnClose=True)

     *note MemoryHandler: 2c8f. クラスの新たなインスタンスを返します。 イ
     ンスタンスはサイズ 'capacity' （バッファされるレコード数）のバッフ
     ァとともに初期化されます。 'flushLevel' が指定されていない場合、
     ‘ERROR’ が使われます。 'target' が指定されていない場合、ハンドラが
     何らかの意味のある処理を行う前に *note setTarget(): 2ce4. でターゲ
     ットを指定する必要があります。 'flushOnClose' が ‘False’ に指定され
     ていた場合、ハンドラが閉じられるときにバッファはフラッシュ 'されま
     せん' 。 'flushOnClose' が指定されていないか ‘True’ に指定されてい
     た場合、ハンドラが閉じられるときのバッファのフラッシュは以前の挙動
     になります。

     バージョン 3.6 で変更: 'flushOnClose' パラメータが追加されました。

      -- メソッド: close ()

          *note flush(): 2ce6. を呼び出し、ターゲットを ‘None’ に設定し
          てバッファを消去します。

      -- メソッド: flush ()

          For a *note MemoryHandler: 2c8f. instance, flushing means just
          sending the buffered records to the target, if there is one.
          The buffer is also cleared when buffered records are sent to
          the target.  Override if you want different behavior.

      -- メソッド: setTarget (target)

          ターゲットハンドラをこのハンドラに設定します。

      -- メソッド: shouldFlush (record)

          バッファが一杯になっているか、 'flushLevel' またはそれ以上のレ
          コードでないかを調べます。


File: python.info,  Node: HTTPHandler,  Next: QueueHandler,  Prev: MemoryHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.14 HTTPHandler
.....................

*note logging.handlers: 7d. モジュールに含まれる *note HTTPHandler: df8.
クラスは、ログ記録メッセージを ‘GET’ または ‘POST’ セマンティクスを使っ
て Web サーバに送信する機能をサポートしています。

 -- クラス: logging.handlers.HTTPHandler (host, url, method='GET',
          secure=False, credentials=None, context=None)

     *note HTTPHandler: df8. クラスの新たなインスタンスを返します。特別
     なポートを使う必要がある場合、'host' は ‘host:port’ の形式で使うこ
     とができます。 'method' が指定されない場合、 ‘GET’ が使われます。
     'secure' が真の場合、HTTPS 接続が使われます。 HTTPS 接続で使用する
     SSL 設定のために 'context' 引数を *note ssl.SSLContext: 274. のイン
     スタンスに設定することができます。 'credentials' を指定する場合、
     BASIC 認証の際の HTTP 'Authorization' ヘッダに使われるユーザIDとパ
     スワードからなる 2要素タプルを渡してください。 credentials を指定す
     る場合、ユーザIDとパスワードが通信中に平文として剥き出しにならない
     よう、secure=True も指定すべきです。

     バージョン 3.5 で変更: 'context' パラメータが追加されました。

      -- メソッド: mapLogRecord (record)

          URL エンコードされて Web サーバに送信することになる、 ‘record’
          に基づく辞書を供給します。デフォルトの実装では単に
          ‘record.__dict__’ を返します。例えば *note LogRecord: fb3. の
          サブセットのみを Web サーバに送信する場合や、 サーバーに送信す
          る内容を特別にカスタマイズする必要がある場合には、このメソッド
          をオーバライドできます。

      -- メソッド: emit (record)

          レコードを URL エンコードされた辞書形式で Web サーバに送信しま
          す。レコードを送信のために辞書に変換するために *note
          mapLogRecord(): 2cea. が呼び出されます。

          注釈: Web server に送信するためのレコードを準備することは一般
          的な書式化操作とは同じではありませんので、 *note
          setFormatter(): 2c40. を使って *note Formatter: 143a. を指定す
          ることは、 *note HTTPHandler: df8. には効果はありません。
          *note format(): 2c4a. を呼び出す代わりに、このハンドラは *note
          mapLogRecord(): 2cea. を呼び出し、その後その返却辞書を Web
          server に送信するのに適した様式にエンコードするために *note
          urllib.parse.urlencode(): e5e. を呼び出します。


File: python.info,  Node: QueueHandler,  Next: QueueListener,  Prev: HTTPHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.15 QueueHandler
......................

Added in version 3.2.

*note logging.handlers: 7d. モジュールに含まれる *note QueueHandler:
1742. クラスは、 *note queue: a4. モジュールや *note multiprocessing:
86. のモジュールで実装されるようなキューにログメッセージを送信する機能を
サポートしています。

*note QueueListener: df9. クラスとともに *note QueueHandler: 1742. を使
うと、ロギングを行うスレッドから分離されたスレッド上でハンドラを動かすこ
とができます。これは、クライアントに対してサービスするスレッドができるだ
け速く応答する必要がある一方、別のスレッド上で (*note SMTPHandler: 2cdb.
によって電子メールを送信するような) 潜在的に遅い操作が行われるような、ウ
ェブアプリケーションおよびその他のサービスアプリケーションにおいて重要で
す。

 -- クラス: logging.handlers.QueueHandler (queue)

     *note QueueHandler: 1742. クラスの新しいインスタンスを返します。イ
     ンスタンスは、キューにメッセージを送るように初期化されます。キュー
     は任意のキューのようなオブジェクトが可能です; それはそのまま *note
     enqueue(): 2cee. メソッドによって使用されます。そのメソッドはメッセ
     ージを送る方法を知っている必要があります。もしタスクのトラッキング
     APIにキューが必要でない場合はキューとして *note SimpleQueue: b38. の
     インスタンスが使用できます。

          注釈: *note multiprocessing: 86. を使っている場合、 *note
          SimpleQueue: b38. を使うことは避けてください。代わりに *note
          multiprocessing.Queue: 1767. を使ってください。

      -- メソッド: emit (record)

          Enqueues the result of preparing the LogRecord.  Should an
          exception occur (e.g.  because a bounded queue has filled up),
          the *note handleError(): 2c48. method is called to handle the
          error.  This can result in the record silently being dropped
          (if *note logging.raiseExceptions: 11ca. is ‘False’) or a
          message printed to ‘sys.stderr’ (if *note
          logging.raiseExceptions: 11ca. is ‘True’).

      -- メソッド: prepare (record)

          キューに追加するためレコードを準備します。このメソッドが返した
          オブジェクトがキューに追加されます。

          基底の実装はレコードがメッセージや引数と、またもし存在すれば、
          発生した例外およびスタック情報と統合されるようにフォーマットし
          ます。またこの実装では非 pickle 化不可能な要素をレコードから削
          除します。特に、この実装はレコードの ‘msg’ と ‘message’ 属性を
          (ハンドラの *note format(): 5eb. メソッドを呼び出すことによっ
          て得られる) 統合されたメッセージで上書きし、同時に ‘args’,
          ‘exc_info’, ‘exc_text’ の3つの属性値をすべて ‘None’ に設定しま
          す。

          レコードを dict や JSON 文字列に変換したい場合や、オリジナルの
          レコードを変更せずに修正済のコピーを送りたい場合は、このメソッ
          ドをオーバーライドすると良いでしょう。

               注釈: 基底の実装は、レコードを pickle 化可能にしつつ、さ
               らなるフォーマット処理を防ぐために、メッセージを引数でフ
               ォーマットしてフォーマットされたメッセージを ‘message’ と
               ‘msg’ 属性に設定し、同時に ‘args’ と ‘exc_text’ 属性を
               ‘None’ に設定します。このことは、 *note QueueListener:
               df9. 側のハンドラが必要なフォーマット処理を行う、たとえば
               例外のフォーマット処理を行う、ための必要な情報が得られな
               いかもしれないことを意味します。そのため、 ‘QueueHandler’
               の派生クラスにおいてこのメソッドを、たとえば ‘exc_text’ 属
               性が ‘None’ に設定されないように、オーバーライドしたいと
               考えるかもしれません。この場合、 ‘message’ / ‘msg’ /
               ‘args’ といった属性の変更はレコードが pickle 化可能である
               ことを保証することと関係しており、元の ‘args’ の値が
               pickle 化可能かどうかによって、これらの属性の変更が避けら
               れないかもしれないということに注意してください (この点に
               ついては、自分のコードだけでなく依存するライブラリのコー
               ドも考慮しなければならないことにも注意してください)

      -- メソッド: enqueue (record)

          キューにレコードを ‘put_nowait()’ を使ってエンキューします; ブ
          ロッキングやタイムアウト、あるいはなにか特別なキューの実装を使
          いたければ、これをオーバライドしてみてください。

      -- の属性: listener

          When created via configuration using *note dictConfig(): 1180,
          this attribute will contain a *note QueueListener: df9.
          instance for use with this handler.  Otherwise, it will be
          ‘None’.

          Added in version 3.12.


File: python.info,  Node: QueueListener,  Prev: QueueHandler,  Up: logging handlers --- ログ記録ハンドラー

5.16.7.16 QueueListener
.......................

Added in version 3.2.

*note logging.handlers: 7d. モジュールに含まれる *note QueueListener:
df9. クラスは、 *note queue: a4. モジュールや *note multiprocessing: 86.
のモジュールで実装されるようなキューからログメッセージを受信する機能をサ
ポートしています。メッセージは内部スレッドのキューから受信され、同じスレ
ッド上の複数のハンドラに渡されて処理されます。 *note QueueListener: df9.
それ自体はハンドラではありませんが、 *note QueueHandler: 1742. と連携し
て動作するのでここで文書化されています。

*note QueueHandler: 1742. クラスとともに *note QueueListener: df9. を使
うと、ロギングを行うスレッドから分離されたスレッド上でハンドラを動かすこ
とができます。これは、クライアントに対してサービスするスレッドができるだ
け速く応答する必要がある一方、別のスレッド上で (*note SMTPHandler: 2cdb.
によって電子メールを送信するような) 潜在的に遅い操作が行われるような、ウ
ェブアプリケーションおよびその他のサービスアプリケーションにおいて重要で
す。

 -- クラス: logging.handlers.QueueListener (queue, *handlers,
          respect_handler_level=False)

     *note QueueListener: df9. クラスの新しいインスタンスを返します。イ
     ンスタンスは、メッセージを送るためのキューと、キューに格納されたエ
     ントリーを処理するハンドラーのリストが設定されて初期化されます。キ
     ューは任意のキューのようなオブジェクトが可能です; それはそのまま
     *note dequeue(): 2cf3. メソッドによって使用されます。そのメソッドは
     メッセージを送る方法を知っている必要があります。もしタスクのトラッ
     キングAPIにキューが必要でない場合はキューとして *note SimpleQueue:
     b38. のインスタンスが使用できます（トラッキングAPIが使用可能な場合
     は使用されます）。

          注釈: *note multiprocessing: 86. を使っている場合、 *note
          SimpleQueue: b38. を使うことは避けてください。代わりに *note
          multiprocessing.Queue: 1767. を使ってください。

     もし ‘respect_handler_level’ が ‘True’ なら、メッセージをハンドラー
     に渡すか決める時に（メッセージのレベルに比べて）ハンドラーのレベル
     が尊重されます。そうでない場合は依然のPythonバージョンと同様にすべ
     てのメッセージは常にハンドラーに渡されます。

     バージョン 3.5 で変更: The ‘respect_handler_level’ argument was
     added.

      -- メソッド: dequeue (block)

          キューからレコードを取り除き、それを返します。ブロッキングする
          ことがあります。

          ベース実装は ‘get()’ を使用します。タイムアウトを有効にしたい
          場合や、カスタムのキュー実装を使いたい場合は、このメソッドをオ
          ーバーライドすると良いでしょう。

      -- メソッド: prepare (record)

          レコードを扱うための準備をします。

          この実装は渡されたレコードをそのまま返します。その値をハンドラ
          に渡す前に何らかのカスタムな整列化 (marshalling) あるいはレコ
          ードに対する操作を行う必要があれば、このメソッドをオーバーライ
          ドすると良いでしょう。

      -- メソッド: handle (record)

          レコードを処理します。

          これは、ハンドラをループしてそれらに処理すべきレコードを渡しま
          す。ハンドラに渡される実際のオブジェクトは、 *note prepare():
          2cf4. から返されたものです。

      -- メソッド: start ()

          リスナーを開始します。

          これは、 LogRecord を処理するキューを監視するために、バックグ
          ラウンドスレッドを開始します。

      -- メソッド: stop ()

          リスナーを停止します。

          スレッドに終了するように依頼し、終了するまで待ちます。アプリケ
          ーションの終了前にこのメソッドを呼ばないと、いくつかのレコード
          がキューに残り、処理されなくなるかもしれないことに注意してくだ
          さい。

      -- メソッド: enqueue_sentinel ()

          リスナーに停止するように指示するためキューに番兵を書き込みます
          。この実装は ‘put_nowait()’ を使用します。タイムアウトを有効に
          したい場合や、カスタムのキュー実装を使いたい場合は、このメソッ
          ドをオーバーライドすると良いでしょう。

          Added in version 3.3.

参考
....

*note logging: 7b. モジュール

     logging モジュールの API リファレンス。

*note logging.config: 7c. モジュール

     logging モジュールの環境設定 API です。


File: python.info,  Node: getpass --- 可搬性のあるパスワード入力機構,  Next: curses --- 文字セル表示のターミナル処理,  Prev: logging handlers --- ログ記録ハンドラー,  Up: 汎用オペレーティングシステムサービス

5.16.8 ‘getpass’ -- 可搬性のあるパスワード入力機構
--------------------------------------------------

'ソースコード:' Lib/getpass.py(1)

__________________________________________________________________

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

*note getpass: 58. モジュールは二つの関数を提供します:

 -- の関数: getpass.getpass (prompt='Password: ', stream=None)

     エコーなしでユーザーにパスワードを入力させるプロンプト。ユーザーは
     'prompt' の文字列をプロンプトに使え、デフォルトは ‘'Password: '’ で
     す。 Unixではプロンプトはファイルに似たオブジェクト 'stream' へ、必
     要なら置き換えられたエラーハンドラを使って出力されます。 'stream' の
     デフォルトは、制御端末(‘/dev/tty’)か、それが利用できない場合は
     ‘sys.stderr’ です (この引数は Windowsでは無視されます)。

     もしエコーなしで入力が利用できない場合は、 ‘getpass()’ は 'stream'
     に警告メッセージを出力し、 ‘sys.stdin’ から読み込み、 *note
     GetPassWarning: 2cfc. 警告を発生させます。

          注釈: IDLE から getpass を呼び出した場合、入力はIDLEのウィンド
          ウではなく、IDLE を起動したターミナルから行われます。

 -- 例外: getpass.GetPassWarning

     *note UserWarning: 2210. のサブクラスで、入力がエコーされてしまった
     場合に発生します。

 -- の関数: getpass.getuser ()

     ユーザーの "ログイン名"を返します。

     この関数は環境変数 ‘LOGNAME’ ‘USER’ ‘LNAME’ ‘USERNAME’ の順序でチェ
     ックして、最初の空ではない文字列が設定された値を返します。もし、な
     にも設定されていない場合は *note pwd: a0. モジュールが提供するシス
     テム上のパスワードデータベースから返します。それ以外の場合は、
     *note OSError: 3f0. が送出されます。

     In general, this function should be preferred over *note
     os.getlogin(): 2a6d.

     バージョン 3.13 で変更: 以前は *note OSError: 3f0. だけでなく、様々
     な例外が送出されていました。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/getpass.py


File: python.info,  Node: curses --- 文字セル表示のターミナル処理,  Next: curses textpad --- curses プログラムのためのテキスト入力ウィジェット,  Prev: getpass --- 可搬性のあるパスワード入力機構,  Up: 汎用オペレーティングシステムサービス

5.16.9 ‘curses’ -- 文字セル表示のターミナル処理
-----------------------------------------------

'ソースコード:' Lib/curses(1)

__________________________________________________________________

*note curses: 23. モジュールは、可搬性のある高度な端末操作のデファクトス
タンダードである、curses ライブラリへのインターフェースを提供します。

curses が最も広く用いられているのは Unix 環境ですが、Windows、DOS で利用
できるバージョンもあり、おそらく他のシステムで利用できるバージョンもあり
ます。この拡張モジュールは Linux および BSD 系の Unixで動作するオープン
ソースの curses ライブラリである ncurses の API に合致するように設計され
ています。

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

     注釈: Whenever the documentation mentions a 'character' it can be
     specified as an integer, a one-character Unicode string or a
     one-byte byte string.

     Whenever the documentation mentions a 'character string' it can be
     specified as a Unicode string or a byte string.

参考
....

*note curses.ascii: 24. モジュール

     ロケール設定に関わらず ASCII 文字を扱うためのユーティリティ。

*note curses.panel: 25. モジュール

     curses ウィンドウにデプス機能を追加するパネルスタック拡張。

*note curses.textpad: 26. モジュール

     ‘Emacs’ ライクなキーバインディングをサポートする編集可能な curses 用
     テキストウィジェット。

*note Python で Curses プログラミング: 2cff.

     Andrew Kuchling および Eric Raymond によって書かれた、curses を
     Python で使うためのチュートリアルです。

* Menu:

* 関数: 関数<6>.
* Window オブジェクト::
* 定数: 定数<6>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/curses


File: python.info,  Node: 関数<6>,  Next: Window オブジェクト,  Up: curses --- 文字セル表示のターミナル処理

5.16.9.1 関数
.............

*note curses: 23. モジュールでは以下の例外を定義しています:

 -- 例外: curses.error

     curses ライブラリ関数がエラーを返した際に送出される例外です。

     注釈: 関数やメソッドにおけるオプションの引数 'x' および 'y' がある
     場合、デフォルト値は常に現在のカーソルになります。オプションの
     'attr' がある場合、デフォルト値は *note A_NORMAL: 2d03. です。

*note curses: 23. では以下の関数を定義しています:

 -- の関数: curses.baudrate ()

     端末の出力速度をビット/秒で返します。ソフトウェア端末エミュレータの
     場合、これは固定の高い値を持つことになります。この関数は歴史的な理
     由で入れられています; かつては、この関数は時間遅延を生成するための
     出力ループを書くために用いられたり、行速度に応じてインターフェース
     を切り替えたりするために用いられたりしていました。

 -- の関数: curses.beep ()

     注意を促す短い音を鳴らします。

 -- の関数: curses.can_change_color ()

     端末に表示される色をプログラマが変更できるか否かによって、‘True’ ま
     たは ‘False’ を返します。

 -- の関数: curses.cbreak ()

     cbreak モードに入ります。cbreak モード ("rare" モードと呼ばれること
     もあります) では、通常の tty 行バッファリングはオフにされ、文字を一
     文字一文字読むことができます。ただし、raw モードとは異なり、特殊文
     字 (割り込み:interrupt、終了:quit、一時停止:suspend、およびフロー制
     御) については、tty ドライバおよび呼び出し側のプログラムに対する通
     常の効果をもっています。まず *note raw(): 2d08. を呼び出し、次いで
     *note cbreak(): 2d07. を呼び出すと、端末を cbreak モードにします。

 -- の関数: curses.color_content (color_number)

     色 'color_number' の赤、緑、および青 (RGB) 要素の強度を返します。
     'color_number' は ‘0’ から ‘COLORS - 1’ の間でなければなりません。
     与えられた色の R、G、B、の値からなる三要素のタプルが返されます。こ
     の値は ‘0’ (その成分はない) から ‘1000’ (その成分の最大強度) の範囲
     をとります。

 -- の関数: curses.color_pair (pair_number)

     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 combined with *note A_STANDOUT: 2d0a, *note
     A_REVERSE: 2d0b, and the other ‘A_*’ attributes.  *note
     pair_number(): 2d0c. is the counterpart to this function.

 -- の関数: curses.curs_set (visibility)

     カーソルの状態を設定します。'visibility' は ‘0’ 、 ‘1``または ``2’
     に設定され、それぞれ不可視、通常、または非常に可視、を意味します。
     要求された可視属性を端末がサポートしている場合、以前のカーソル状態
     が返されます; そうでなければ例外が送出されます。多くの端末では、"可
     視 (通常)" モードは下線カーソルで、"非常に可視" モードはブロックカ
     ーソルです。

 -- の関数: curses.def_prog_mode ()

     現在の端末属性を、稼動中のプログラムが curses を使う際のモードであ
     る "プログラム" モードとして保存します。(このモードの反対は、プログ
     ラムが curses を使わない "シェル" モードです。) その後 *note
     reset_prog_mode(): 2d0f. を呼ぶとこのモードを復旧します。

 -- の関数: curses.def_shell_mode ()

     現在の端末属性を、稼動中のプログラムが curses を使っていないときの
     モードである "シェル" モードとして保存します。(このモードの反対は、
     プログラムが curses 機能を利用している "プログラム" モードです。) そ
     の後 *note reset_shell_mode(): 2d11. を呼ぶとこのモードを復旧します
     。

 -- の関数: curses.delay_output (ms)

     出力に 'ms' ミリ秒の一時停止を入れます。

 -- の関数: curses.doupdate ()

     物理スクリーンを更新します。curses ライブラリは、現在の物理スクリー
     ンの内容と、次の状態として要求されている仮想スクリーンをそれぞれ表
     す、2 つのデータ構造を保持しています。*note doupdate(): 2d13. は更
     新を適用し、物理スクリーンを仮想スクリーンに一致させます。

     仮想スクリーンは *note addstr(): 2d14. のような書き込み操作をウィン
     ドウに行った後に *note noutrefresh(): 2d15. を呼び出して更新するこ
     とができます。通常の:meth:‘~window.refresh’ 呼び出しは、単に
     ‘noutrefresh()’ を呼んだ後に ‘doupdate`を呼ぶだけです; 複数のウィン
     ドウを更新しなければならない場合、すべてのウィンドウに対して
     :meth:()’!noutrefresh' を呼び出した後、一度だけ ‘doupdate()’ を呼ぶ
     ことで、パフォーマンスを向上させることができ、おそらくスクリーンの
     ちらつきも押さえることができます。

 -- の関数: curses.echo ()

     echo モードに入ります。echo モードでは、各文字入力はスクリーン上に
     入力された通りにエコーバックされます。

 -- の関数: curses.endwin ()

     ライブラリの非初期化を行い、端末を通常の状態に戻します。

 -- の関数: curses.erasechar ()

     ユーザの現在の消去文字 (erase character) を1バイトの bytes オブジェ
     クトで返します。Unix オペレーティングシステムでは、この値は curses
     プログラムが制御している端末の属性であり、curses ライブラリ自体では
     設定されません。

 -- の関数: curses.filter ()

     *note filter(): 2d19. ルーチンを使う場合、*note initscr(): 1508. を
     呼ぶ前に呼び出さなくてはなりません。この手順のもたらす効果は以下の
     通りです: まず二つの関数の呼び出しの間は、 ‘LINES’ は ‘1’ に設定さ
     れます; ‘clear’, ‘cup’, ‘cud’, ‘cud1’, ‘cuu1’, ‘cuu’, ‘vpa’ は無効
     化されます; ‘home’ 文字列は ‘cr’ の値に設定されます。これにより、カ
     ーソルは現在の行に制限されるので、スクリーンの更新も同様に制限され
     ます。この関数は、スクリーンの他の部分に影響を及ぼさずに文字単位の
     行編集を行う場合に利用できます。

 -- の関数: curses.flash ()

     スクリーンを点滅します。すなわち、画面を色反転して、短時間でもとに
     もどします。人によっては、*note beep(): 2d05. で生成される注意音よ
     りも、このような "目に見えるベル" を好みます。

 -- の関数: curses.flushinp ()

     すべての入力バッファをフラッシュします。この関数は、ユーザによって
     すでに入力されているが、まだプログラムによって処理されていないすべ
     ての先行入力文字を破棄します。

 -- の関数: curses.getmouse ()

     *note getch(): 2d1d. が *note KEY_MOUSE: 2d1e. を返してマウスイベン
     トを通知した後、この関数を呼んで待ち行列上に置かれているマウスイベ
     ントを取得しなければなりません。イベントは ‘(id, x, y, z, bstate)’
     の 5 要素のタプルで表現されています。'id' は複数のデバイスを区別す
     るための ID 値で、'x', 'y', 'z' はイベントの座標値です。(現在 'z' は
     使われていません) 'bstate' は整数値で、その各ビットはイベントのタイ
     プを示す値に設定されています。この値は以下に示す定数のうち一つまた
     はそれ以上のビット単位 OR になっています。以下の定数の 'n' は 1 か
     ら 5 のボタン番号を示します: *note BUTTONn_PRESSED: 2d1f, *note
     BUTTONn_RELEASED: 2d20, *note BUTTONn_CLICKED: 2d21, *note
     BUTTONn_DOUBLE_CLICKED: 2d22, *note BUTTONn_TRIPLE_CLICKED: 2d23,
     *note BUTTON_SHIFT: 2d24, *note BUTTON_CTRL: 2d25, *note
     BUTTON_ALT: 2d26.。

     バージョン 3.10 で変更: The ‘BUTTON5_*’ constants are now exposed
     if they are provided by the underlying curses library.

 -- の関数: curses.getsyx ()

     仮想スクリーンにおける現在のカーソル位置をタプル ‘(y, x)’ で返しま
     す。 ‘leaveok()’ が ‘True’ に設定されていれば、 ‘(-1, -1)’ が返され
     ます。

 -- の関数: curses.getwin (file)

     Read window related data stored in the file by an earlier *note
     window.putwin(): 2d29. call.  The routine then creates and
     initializes a new window using that data, returning the new window
     object.

 -- の関数: curses.has_colors ()

     端末が色表示を行える場合には ‘True’ を返します。そうでない場合には
     ‘False’ を返します。

 -- の関数: curses.has_extended_color_support ()

     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 (e.g.
     xterm-256color).

     Extended color support requires ncurses version 6.1 or later.

     Added in version 3.10.

 -- の関数: curses.has_ic ()

     端末が文字の挿入/削除機能を持つ場合に ‘True’ を返します。最近の端末
     エミュレータはどれもこの機能を持っており、この関数は歴史的な理由の
     ためだけに存在しています。

 -- の関数: curses.has_il ()

     端末が行の挿入/削除機能を持つ場合に ‘True’ を返します。最近の端末エ
     ミュレータはどれもこの機能を持っていて、この関数は歴史的な理由のた
     めだけに存在しています。

 -- の関数: curses.has_key (ch)

     キー値 'ch' をとり、現在の端末タイプがその値のキーを認識できる場合
     に ‘True’ を返します。

 -- の関数: curses.halfdelay (tenths)

     半遅延モード、すなわち cbreak モードに似た、ユーザが打鍵した文字が
     すぐにプログラムで利用できるようになるモードで使われます。しかしな
     がら、何も入力されなかった場合、十分の 'tenths' 秒後に例外が送出さ
     れます。'tenths' の値は ‘1’ から ‘255’ の間でなければなりません。半
     遅延モードから抜けるには *note nocbreak(): 2d2f. を使います。

 -- の関数: curses.init_color (color_number, r, g, b)

     色の定義を変更します。変更したい色番号と、その後に 3 つ組みの RGB 値
     (赤、緑、青の成分の大きさ) をとります。'color_number' の値は ‘0’ か
     ら ‘COLORS - 1’ の間でなければなりません。'r', 'g', 'b' の値は ‘0’
     から ‘1000’ の間でなければなりません。*note init_color(): 7bd. を使
     うと、スクリーン上でカラーが使用されている部分はすべて新しい設定に
     即時変更されます。この関数はほとんどの端末で何も行いません; *note
     can_change_color(): 2d06. が ‘True’ を返す場合にのみ動作します。

 -- の関数: curses.init_pair (pair_number, fg, bg)

     色ペアの定義を変更します。3 つの引数: 変更したい色ペア、前景色の色
     番号、背景色の色番号、をとります。'pair_number' は ‘1’ から
     ‘COLOR_PAIRS - 1’ の間でなければなりません (‘0’ 色ペアは黒色背景に
     白色前景となるように設定されており、変更することができません)。'fg'
     および 'bg' 引数は ‘0’ と ‘COLORS - 1’ の間、または、*note
     use_default_colors(): 2d30. を呼び出した後では ‘-1’ でなければなり
     ません。色ペアが以前に初期化されていれば、スクリーンを更新して、指
     定された色ペアの部分を新たな設定に変更します。

 -- の関数: curses.initscr ()

     ライブラリを初期化します。スクリーン全体をあらわす *note
     ウィンドウ: 2d31. オブジェクトを返します。

          注釈: 端末のオープン時にエラーが発生した場合、curses ライブラ
          リによってインタープリタが終了される場合があります。

 -- の関数: curses.is_term_resized (nlines, ncols)

     *note resize_term(): 1510. によってウィンドウ構造が変更されている場
     合に ‘True’ を、そうでない場合は ‘False’ を返します。

 -- の関数: curses.isendwin ()

     *note endwin(): 2d17. がすでに呼び出されている (すなわち、curses ラ
     イブラリが非初期化されてしまっている) 場合に ‘True’ を返します。

 -- の関数: curses.keyname (k)

     bytes オブジェクト 'k' に番号付けされているキーの名前を返します。 印
     字可能な ASCII 文字を生成するキーの名前はそのキーの文字自体になりま
     す。 コントロールキーと組み合わせたキーの名前は、キャレット
     (‘b'^'’)の後に対応する ASCII 文字が続く 2 バイトの bytes オブジェク
     トになります。 Alt キーと組み合わせたキー (128-255) の名前は、先頭
     に ‘b'M-'’ が付き、その後に対応する ASCII 文字が続く bytes オブジェ
     クトになります。

 -- の関数: curses.killchar ()

     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.

 -- の関数: curses.longname ()

     現在の端末について記述している terminfo の長形式 name フィールドが
     入った bytes オブジェクトを返します。verbose 形式記述の最大長は 128
     文字です。この値は *note initscr(): 1508. 呼び出しの後でのみ定義さ
     れています。

 -- の関数: curses.meta (flag)

     'flag' が ‘True’ の場合、8 ビット文字の入力を許可します。'flag' が
     ‘False’ の場合、7 ビット文字だけを許可します。

 -- の関数: curses.mouseinterval (interval)

     ボタンが押されてから離されるまでの時間をマウスクリック一回として認
     識する最大の時間間隔をミリ秒で設定します。返り値は以前の内部設定値
     になります。デフォルトは 200 ミリ秒 (5 分の 1 秒) です。

 -- の関数: curses.mousemask (mousemask)

     報告すべきマウスイベントを設定し、‘(availmask, oldmask)’ の組からな
     るタプルを返します。'availmask' はどの指定されたマウスイベントのど
     れが報告されるかを示します; どのイベント指定も完全に失敗した場合に
     は ‘0’ が返ります。'oldmask' は与えられたウィンドウの以前のマウスイ
     ベントマスクです。この関数が呼ばれない限り、マウスイベントは何も報
     告されません。

 -- の関数: curses.napms (ms)

     'ms' ミリ秒間スリープします。

 -- の関数: curses.newpad (nlines, ncols)

     与えられた行とカラム数を持つパッド (pad) データ構造を生成し、そのポ
     インタを返します。パッドはウィンドウオブジェクトとして返されます。

     パッドはウィンドウと同じようなものですが、スクリーンのサイズによる
     制限をうけず、スクリーンの特定の部分に関連付けられていなくてもかま
     いません。大きなウィンドウが必要であり、スクリーンにはそのウィンド
     ウの一部しか一度に表示しない場合に使えます。(スクロールや入力エコー
     などによる) パッドに対する再描画は起こりません。パッドに対する
     *note refresh(): 2d3b. および *note noutrefresh(): 2d15. メソッドは
     、パッド中の表示する部分と表示するために利用するスクリーン上の位置
     を指定する 6 つの引数が必要です。これらの引数は 'pminrow'、
     'pmincol'、'sminrow'、'smincol'、'smaxrow'、'smaxcol' です; 'p' で
     始まる引数はパッド中の表示領域の左上位置で、's' で始まる引数はパッ
     ド領域を表示するスクリーン上のクリップ矩形を指定します。

 -- の関数: curses.newwin (nlines, ncols)

 -- の関数: curses.newwin (nlines, ncols, begin_y, begin_x)

     左上の角が ‘(begin_y, begin_x)’ で、高さ/幅が 'nlines' / 'ncols' の
     新規 *note ウィンドウ: 2d31. を返します。

     デフォルトでは、ウィンドウは指定された位置からスクリーンの右下まで
     広がります。

 -- の関数: curses.nl ()

     newlime モードに入ります。このモードはリターンキーを入力中の改行と
     して変換し、出力時に改行文字を復帰 (return) と改行 (line-feed) に変
     換します。newline モードは初期化時にはオンになっています。

 -- の関数: curses.nocbreak ()

     cbreak モードを終了します。行バッファリングを行う通常の "cooked" モ
     ードに戻ります。

 -- の関数: curses.noecho ()

     echo モードを終了します。入力のエコーバックはオフにされます。

 -- の関数: curses.nonl ()

     newline モードを終了します。入力時のリターンキーから改行への変換、
     および出力時の改行から復帰/改行への低レベル変換を無効化します (ただ
     し、‘addch('\n')’ の振る舞いは変更せず、仮想スクリーン上では常に復
     帰と改行に等しくなります)。変換をオフにすることで、curses は水平方
     向の動きを少しだけ高速化できることがあります; また、入力中のリター
     ンキーの検出ができるようになります。

 -- の関数: curses.noqiflush ()

     ‘noqiflush()’ ルーチンを使うと、通常行われている ‘INTR’ 、 ‘QUIT’ お
     よび ‘SUSP’ 文字による入力および出力キューのフラッシュが行われなく
     なります。シグナルハンドラが終了した際、割り込みが発生しなかったか
     のように出力を続たい場合、ハンドラ中で ‘noqiflush()’ を呼び出すこと
     ができます。

 -- の関数: curses.noraw ()

     raw モードから離れます。行バッファリングを行う通常の "cooked" モー
     ドに戻ります。

 -- の関数: curses.pair_content (pair_number)

     要求された色ペアの色を含むタプル ‘(fg, bg)’ を返します。
     'pair_number' は ‘0’ から ‘COLOR_PAIRS - 1’ の間でなければなりませ
     ん。

 -- の関数: curses.pair_number (attr)

     'attr' に対する色ペアセットの番号を返します。*note color_pair():
     2d09. はこの関数の逆に相当します。

 -- の関数: curses.putp (str)

     ‘tputs(str, 1, putchar)’ と等価です; 現在の端末における、指定された
     terminfo 機能の値を出力します。*note putp(): 2d42. の出力は常に標準
     出力に送られるので注意して下さい。

 -- の関数: curses.qiflush ([flag])

     'flag' が ‘False’ なら、*note noqiflush(): 2d40. を呼ぶのとと同じ効
     果です。'flag' が ‘True’ か、引数が与えられていない場合、制御文字が
     読み出された最にキューはフラッシュされます。

 -- の関数: curses.raw ()

     raw モードに入ります。raw モードでは、通常の行バッファリングと割り
     込み (interrupt)、終了 (quit)、一時停止 (suspend)、およびフロー制御
     キーはオフになります; 文字は curses 入力関数に一文字づつ渡されます
     。

 -- の関数: curses.reset_prog_mode ()

     端末を "program" モードに復旧し、あらかじめ *note def_prog_mode():
     2d0e. で保存した内容に戻します。

 -- の関数: curses.reset_shell_mode ()

     端末を "shell" モードに復旧し、あらかじめ *note def_shell_mode():
     2d10. で保存した内容に戻します。

 -- の関数: curses.resetty ()

     端末モードの状態を最後に *note savetty(): 2d45. を呼び出した時の状
     態に戻します。

 -- の関数: curses.resize_term (nlines, ncols)

     *note resizeterm(): 150f. で使用されるバックエンド関数で、ウィンド
     ウサイズを変更する時、*note resize_term(): 1510. は拡張された領域を
     埋めます。呼び出したアプリケーションはそれらの領域を適切なデータで
     埋めなくてはなりません。‘resize_term()’ 関数はすべてのウィンドウの
     サイズ変更を試みます。ただし、パッド呼び出しの慣例により、アプリケ
     ーションとの追加のやり取りを行わないサイズ変更は行えません。

 -- の関数: curses.resizeterm (nlines, ncols)

     現在の標準ウィンドウのサイズを指定された寸法に変更し、curses ライブ
     ラリが使用する、その他のウィンドウサイズを記憶しているデータ (特に
     SIGWINCH ハンドラ) を調整します。

 -- の関数: curses.savetty ()

     *note resetty(): 2d44. で使用される、バッファ内の端末モードの現在の
     状態を保存します。

 -- の関数: curses.get_escdelay ()

     Retrieves the value set by *note set_escdelay(): 8bf.

     Added in version 3.9.

 -- の関数: curses.set_escdelay (ms)

     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.

     Added in version 3.9.

 -- の関数: curses.get_tabsize ()

     Retrieves the value set by *note set_tabsize(): 8c1.

     Added in version 3.9.

 -- の関数: curses.set_tabsize (size)

     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.

     Added in version 3.9.

 -- の関数: curses.setsyx (y, x)

     仮想スクリーンのカーソルを 'y', 'x' に設定します。'y' および 'x' が
     どちらも ‘-1’ の場合、 ‘leaveok()’ が に''True''に設定されます。

 -- の関数: curses.setupterm (term=None, fd=-1)

     端末を初期化します。'term' は端末名となる文字列または ‘None’ です。
     省略または ‘None’ の場合、環境変数 ‘TERM’ の値が使用されます。'fd'
     は送信される初期化シーケンスへのファイル記述子です。指定されないま
     たは ‘-1’ の場合、‘sys.stdout’ のファイル記述子が使用されます。

 -- の関数: curses.start_color ()

     プログラマがカラーを利用したい場合で、かつ他の何らかのカラー操作ル
     ーチンを呼び出す前に呼び出さなくてはなりません。この関数は *note
     initscr(): 1508. を呼んだ直後に呼ぶようにしておくとよいでしょう。

     *note start_color(): 2d48. は 8 つの基本色 (黒、赤、緑、黄、青、マ
     ゼンタ、シアン、および白) と、色数の最大値と端末がサポートする色ペ
     アの最大数が入っている、*note curses: 23. モジュールにおける二つの
     グローバル変数、*note COLORS: 2d49. および *note COLOR_PAIRS: 2d4a.
     を初期化します。この関数はまた、色設定を端末のスイッチが入れられた
     ときの状態に戻します。

 -- の関数: curses.termattrs ()

     端末がサポートするすべてのビデオ属性を論理和した値を返します。この
     情報は、curses プログラムがスクリーンの見え方を完全に制御する必要が
     ある場合に便利です。

 -- の関数: curses.termname ()

     14 文字以下になるように切り詰められた環境変数 ‘TERM’ の値を bytes オ
     ブジェクトで返します。

 -- の関数: curses.tigetflag (capname)

     terminfo 機能名 'capname' に対応する真偽値の機能値を整数で返します
     。'capname' が真偽値で表せる機能値でない場合 ‘-1’ を返し、機能がキ
     ャンセルされているか、端末記述上に見つからない場合 ‘0’ を返します。

 -- の関数: curses.tigetnum (capname)

     terminfo 機能名 'capname' に対応する数値の機能値を整数で返します。
     'capname' が数値で表せる機能値でない場合 ‘-2’ を返し、機能がキャン
     セルされているか、端末記述上に見つからない場合 ‘-1’ を返します。

 -- の関数: curses.tigetstr (capname)

     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.

 -- の関数: curses.tparm (str[, ...])

     'str' を与えられたパラメタを使って bytes オブジェクトにインスタンス
     化します。'str' は terminfo データベースから得られたパラメタを持つ
     文字列でなければなりません。例えば、‘tparm(tigetstr("cup"), 5, 3)’
     は ‘b'\033[6;4H'’ のようになります。厳密には端末の形式によって異な
     る結果となります。

 -- の関数: curses.typeahead (fd)

     先読みチェックに使うためのファイル記述子 'fd' を指定します。'fd' が
     ‘-1’ の場合、先読みチェックは行われません。

     curses ライブラリはスクリーンを更新する間、先読み文字列を定期的に検
     索することで "行はみ出し最適化 (line-breakout optimization)" を行い
     ます。入力が得られ、かつ入力は端末からのものである場合、現在行おう
     としている更新は refresh や doupdate を再度呼び出すまで先送りにしま
     す。この関数は異なるファイル記述子で先読みチェックを行うように指定
     することができます。

 -- の関数: curses.unctrl (ch)

     Return a bytes object which is a printable representation of the
     character 'ch'.  Control characters are represented as a caret
     followed by the character, for example as ‘b'^C'’.  Printing
     characters are left as they are.

 -- の関数: curses.ungetch (ch)

     'ch' をプッシュし、次に *note getch(): 2d1d. を呼び出した時にその値
     が返るようにします。

          注釈: ‘getch()’ を呼び出すまでは 'ch' は一つしかプッシュできま
          せん。

 -- の関数: curses.update_lines_cols ()

     Update the *note LINES: 1671. and *note COLS: 1672. module
     variables.  Useful for detecting manual screen resize.

     Added in version 3.5.

 -- の関数: curses.unget_wch (ch)

     'ch' をプッシュし、次に *note get_wch(): 106c. を呼び出した時にその
     値が返るようにします。

          注釈: ‘get_wch()’ を呼び出すまでは 'ch' は一つしかプッシュでき
          ません。

     Added in version 3.3.

 -- の関数: curses.ungetmouse (id, x, y, z, bstate)

     与えられた状態データが関連付けられた *note KEY_MOUSE: 2d1e. イベン
     トを入力キューにプッシュします。

 -- の関数: curses.use_env (flag)

     この関数を使う場合、*note initscr(): 1508. または newterm を呼ぶ前
     に呼び出さなくてはなりません。'flag' が ‘False’ の場合、環境変数
     ‘LINES’ および ‘COLUMNS’ の値 (デフォルトで使用されます) の値が設定
     されていたり、curses がウィンドウ内で動作して (この場合 ‘LINES’ や
     ‘COLUMNS’ が設定されていないとウィンドウのサイズを使います) いても
     、terminfo データベースに指定された lines および columns の値を使い
     ます。

 -- の関数: curses.use_default_colors ()

     この機能をサポートしている端末上で、色の値としてデフォルト値を使う
     設定をします。あなたのアプリケーションで透過性とサポートするために
     この関数を使ってください。デフォルトの色は色番号 ‘-1’ に割り当てら
     れます。この関数を呼んだ後、たとえば ‘init_pair(x,
     curses.COLOR_RED, -1)’ は色ペア 'x' を赤い前景色とデフォルトの背景
     色に初期化します。

 -- の関数: curses.wrapper (func, /, *args, **kwargs)

     curses を初期化し、呼び出し可能なオブジェクト 'func' (その他の
     curses を使用するアプリケーション) を呼び出します。アプリケーション
     が例外を送出した場合、この関数は端末を例外を再送出する前に正常な状
     態に戻し、トレースバックを作成します。その後、呼び出し可能オブジェ
     クト 'func' には、第一引数としてメインウィンドウ 'stdscr' が、続い
     て ‘wrapper()’ に渡されたその他の引数が渡されます。'func' を呼び出
     す前、‘wrapper()’ は cbreak モードをオンに、エコーをオフに、端末キ
     ーパッドを有効にし、端末が色表示をサポートしている場合は色を初期化
     します。終了時 (通常終了、例外による終了のどちらでも)、cooked モー
     ドに戻し、エコーをオンにし、端末キーパッドを無効にします。


File: python.info,  Node: Window オブジェクト,  Next: 定数<6>,  Prev: 関数<6>,  Up: curses --- 文字セル表示のターミナル処理

5.16.9.2 Window オブジェクト
............................

上記の *note initscr(): 1508. や *note newwin(): 2d3c. が返すウィンドウ
は、以下のメソッドと属性を持ちます:

 -- メソッド: window.addch (ch[, attr])

 -- メソッド: window.addch (y, x, ch[, attr])

     ‘(y, x)’ にある文字 'ch' を属性 'attr' で描画します。このときその場
     所に以前描画された文字は上書きされます。デフォルトでは、文字の位置
     および属性はウィンドウオブジェクトにおける現在の設定になります。

          注釈: Writing outside the window, subwindow, or pad raises a
          *note curses.error: 2d02.  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.

 -- メソッド: window.addnstr (str, n[, attr])

 -- メソッド: window.addnstr (y, x, str, n[, attr])

     文字列 'str' から最大で 'n' 文字を ‘(y, x)’ に属性 'attr' で描画し
     ます。以前ディスプレイにあった内容はすべて上書きされます。

 -- メソッド: window.addstr (str[, attr])

 -- メソッド: window.addstr (y, x, str[, attr])

     ‘(y, x)’ に文字列 'str' を属性 'attr' で描画します。以前ディスプレ
     イにあった内容はすべて上書きされます。

          注釈: 
             * Writing outside the window, subwindow, or pad raises
               *note curses.error: 2d02.  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.

             * A bug in ncurses(1), the backend for this Python module,
               can cause SegFaults when resizing windows.  This is fixed
               in ncurses-6.1-20190511.  If you are stuck with an
               earlier ncurses, you can avoid triggering this if you do
               not call *note addstr(): 2d14. with a 'str' that has
               embedded newlines.  Instead, call *note addstr(): 2d14.
               separately for each line.

 -- メソッド: window.attroff (attr)

     現在のウィンドウに書き込まれたすべての内容に対し "バックグラウンド"
     に設定された属性 'attr' を除去します。

 -- メソッド: window.attron (attr)

     現在のウィンドウに書き込まれたすべての内容に対し "バックグラウンド"
     に属性 'attr' を追加します。

 -- メソッド: window.attrset (attr)

     "バックグラウンド" の属性セットを 'attr' に設定します。初期値は ‘0’
     (属性なし) です。

 -- メソッド: window.bkgd (ch[, attr])

     ウィンドウ上の背景プロパティを、'attr' を属性とする文字 'ch' に設定
     します。変更はそのウィンドウ中のすべての文字に以下のようにして適用
     されます:

        * ウィンドウ中のすべての文字の属性が新たな背景属性に変更されます
          。

        * 以前の背景文字が出現すると、常に新たな背景文字に変更されます。

 -- メソッド: window.bkgdset (ch[, attr])

     ウィンドウの背景を設定します。ウィンドウの背景は、文字と何らかの属
     性の組み合わせから成り立ちます。背景情報の属性の部分は、ウィンドウ
     上に描画されている空白でないすべての文字と組み合わされ (OR され) ま
     す。空白文字には文字部分と属性部分の両方が組み合わされます。背景は
     文字のプロパティとなり、スクロールや行/文字の挿入/削除操作の際には
     文字と一緒に移動します。

 -- メソッド: window.border ([ls[, rs[, ts[, bs[, tl[, tr[, bl[,
          br]]]]]]]])

     ウィンドウの縁に境界線を描画します。各引数には境界の特定部分を表現
     するために使われる文字を指定します; 詳細は以下のテーブルを参照して
     ください。

          注釈: どの引数も、‘0’ を指定した場合デフォルトの文字が使われる
          ようになります。キーワード引数は使うことが 'できません'。デフ
          ォルトはテーブル内で示しています:

     引数            説明                      デフォルト値
                                               
     ----------------------------------------------------------------------
                                               
     'ls'            左側                      *note ACS_VLINE: 2d5f.
                                               
                                               
     'rs'            右側                      *note ACS_VLINE: 2d5f.
                                               
                                               
     'ts'            上側                      *note ACS_HLINE: 2d60.
                                               
                                               
     'bs'            下側                      *note ACS_HLINE: 2d60.
                                               
                                               
     'tl'            左上の角                  *note ACS_ULCORNER: 2d61.
                                               
                                               
     'tr'            右上の角                  *note ACS_URCORNER: 2d62.
                                               
                                               
     'bl'            左下の角                  *note ACS_LLCORNER: 2d63.
                                               
                                               
     'br'            右下の角                  *note ACS_LRCORNER: 2d64.
                                               

 -- メソッド: window.box ([vertch, horch])

     *note border(): 2d5e. と同様ですが、'ls' および 'rs' は共に
     'vertch' で、'ts' および 'bs' は共に 'horch' です。この関数では、角
     に使われるデフォルト文字が常に使用されます。

 -- メソッド: window.chgat (attr)

 -- メソッド: window.chgat (num, attr)

 -- メソッド: window.chgat (y, x, attr)

 -- メソッド: window.chgat (y, x, num, attr)

     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 attribute will be set on all the characters
     to the end of the line.  This function moves cursor to position
     ‘(y, x)’ if supplied.  The changed line will be touched using the
     *note touchline(): 2d67. method so that the contents will be
     redisplayed by the next window refresh.

 -- メソッド: window.clear ()

     *note erase(): 2d69. に似ていますが、次に *note refresh(): 2d3b. が
     呼び出された際にすべてのウィンドウを再描画するようにします。

 -- メソッド: window.clearok (flag)

     'flag' が ‘True’ ならば、次の *note refresh(): 2d3b. はウィンドウを
     完全に消去します。

 -- メソッド: window.clrtobot ()

     カーソルの位置からウィンドウの端までを消去します: カーソル以降のす
     べての行が削除されるため、*note clrtoeol(): 2d6c. と等価です。

 -- メソッド: window.clrtoeol ()

     カーソル位置から行末までを消去します。

 -- メソッド: window.cursyncup ()

     ウィンドウのすべての親ウィンドウについて、現在のカーソル位置を反映
     するよう更新します。

 -- メソッド: window.delch ([y, x])

     ‘(y, x)’ にある文字を削除します。

 -- メソッド: window.deleteln ()

     カーソルの下にある行を削除します。後続の行はすべて 1 行上に移動しま
     す。

 -- メソッド: window.derwin (begin_y, begin_x)

 -- メソッド: window.derwin (nlines, ncols, begin_y, begin_x)

     "derive window (ウィンドウを派生する)" の短縮形です。*note
     derwin(): 2d70. は *note subwin(): 2d71. と同じですが、'begin_y' お
     よび 'begin_x' はスクリーン全体の原点ではなく、ウィンドウの原点から
     の相対位置です。派生したウィンドウオブジェクトが返されます。

 -- メソッド: window.echochar (ch[, attr])

     文字 'ch' に属性 'attr' を付与し、即座に *note refresh(): 2d3b. を
     ウィンドウに対して呼び出します。

 -- メソッド: window.enclose (y, x)

     与えられた文字セル座標をスクリーン原点から相対的なものとし、ウィン
     ドウの中に含まれるかを調べて、‘True’ または ‘False’ を返します。ス
     クリーン上のウィンドウの一部がマウスイベントの発生場所を含むかどう
     かを調べる上で便利です。

     バージョン 3.10 で変更: Previously it returned ‘1’ or ‘0’ instead
     of ‘True’ or ‘False’.

 -- の属性: window.encoding

     encode メソッドの引数 (Unicode 文字列および文字) で使用されるエンコ
     ーディングです。例えば *note window.subwin(): 2d71. などでサブウィ
     ンドウを生成した時、エンコーディング属性は親ウィンドウから継承しま
     す。デフォルトでは、現在のロケールのエンコーディングが使用されます
     (*note locale.getencoding(): 2be. 参照)。

     Added in version 3.3.

 -- メソッド: window.erase ()

     ウィンドウをクリアします。

 -- メソッド: window.getbegyx ()

     Return a tuple ‘(y, x)’ of coordinates of upper-left corner.

 -- メソッド: window.getbkgd ()

     与えられたウィンドウの現在の背景文字と属性のペアを返します。

 -- メソッド: window.getch ([y, x])

     文字を 1 個取得します。返される整数は ASCII の範囲の値となる 'とは
     限らない' ので注意してください。ファンクションキー、キーパッドのキ
     ー等は 256 よりも大きな数字で表されます。無遅延 (no-delay) モードで
     は、入力がない場合 -1 を返し、そうでなければキーが押されるまで待ち
     ます。

 -- メソッド: window.get_wch ([y, x])

     ワイド文字を 1 個取得します。ほとんどのキー、ファンクションキーの数
     値、キーパッドのキー、およびその他の特殊キーの文字を返します。無遅
     延モードでは、入力がない場合例外を送出します。

     Added in version 3.3.

 -- メソッド: window.getkey ([y, x])

     文字を 1 個取得し、 *note getch(): 2d1d. が返すような整数ではなく文
     字列を返します。ファンクションキー、キーパッドのキー、およびその他
     特殊キーはキー名を含む複数文字を返します。無遅延モードでは、入力が
     ない場合例外を送出します。

 -- メソッド: window.getmaxyx ()

     ウィンドウの高さおよび幅を表すタプル ‘(y, x)’ を返します。

 -- メソッド: window.getparyx ()

     親ウィンドウ中におけるウィンドウの開始位置をタプル ‘(y, x)’ で返し
     ます。ウィンドウに親ウィンドウがない場合 ‘(-1, -1)’ を返します。

 -- メソッド: window.getstr ()

 -- メソッド: window.getstr (n)

 -- メソッド: window.getstr (y, x)

 -- メソッド: window.getstr (y, x, n)

     原始的な文字編集機能つきで、ユーザの入力した byte オブヘクトを読み
     取ります。

 -- メソッド: window.getyx ()

     ウィンドウの左上角からの相対で表した現在のカーソル位置をタプル ‘(y,
     x)’ で返します。

 -- メソッド: window.hline (ch, n)

 -- メソッド: window.hline (y, x, ch, n)

     ‘(y, x)’ から始まり、'n' の長さを持つ、文字 'ch' で作られる水平線を
     表示します。

 -- メソッド: window.idcok (flag)

     'flag' が ‘False’ の場合、curses は端末のハードウェアによる文字挿入
     /削除機能を使おうとしなくなります; 'flag' が ‘True’ ならば、文字挿
     入/削除は有効にされます。curses が最初に初期化された際には文字挿入
     /削除はデフォルトで有効になっています。

 -- メソッド: window.idlok (flag)

     'flag' が ‘True’ であれば、*note curses: 23. はハードウェアの行編集
     機能の利用を試みます。行挿入/削除は無効化されます。

 -- メソッド: window.immedok (flag)

     'flag' が ‘True’ ならば、ウィンドウイメージ内における何らかの変更が
     あるとウィンドウを更新するようになります; すなわち、*note
     refresh(): 2d3b. を自分で呼ばなくても良くなります。とはいえ、
     wrefresh を繰り返し呼び出すことになるため、この操作はかなりパフォー
     マンスを低下させます。デフォルトでは無効になっています。

 -- メソッド: window.inch ([y, x])

     ウィンドウの指定の位置の文字を返します。下位 8 ビットが本来の文字で
     、それより上のビットは属性です。

 -- メソッド: window.insch (ch[, attr])

 -- メソッド: window.insch (y, x, ch[, attr])

     ‘(y, x)’ に文字 'ch' を属性 'attr' で描画し、行の 'x' からの内容を
     1 文字分右にずらします。

 -- メソッド: window.insdelln (nlines)

     'nlines' 行を指定されたウィンドウの現在の行の上に挿入します。その下
     にある 'nlines' 行は失われます。負の 'nlines' を指定すると、カーソ
     ルのある行以降の 'nlines' を削除し、削除された行の後ろに続く内容が
     上に来ます。その下にある 'nlines' は消去されます。現在のカーソル位
     置はそのままです。

 -- メソッド: window.insertln ()

     カーソルの下に空行を 1 行入れます。それ以降の行は 1 行づつ下に移動
     します。

 -- メソッド: window.insnstr (str, n[, attr])

 -- メソッド: window.insnstr (y, x, str, n[, attr])

     文字列をカーソルの下にある文字の前に (一行に収まるだけ) 最大 'n' 文
     字挿入します。'n' がゼロまたは負の値の場合、文字列全体が挿入されま
     す。カーソルの右にあるすべての文字は右に移動し、行の左端にある文字
     は失われます。カーソル位置は ('y', 'x' が指定されていた場合はそこに
     移動しますが、その後は) 変化しません。

 -- メソッド: window.insstr (str[, attr])

 -- メソッド: window.insstr (y, x, str[, attr])

     キャラクタ文字列を (行に収まるだけ) カーソルより前に挿入します。カ
     ーソルの右側にある文字はすべて右にシフトし、行の右端の文字は失われ
     ます。カーソル位置は ('y', 'x' が指定されていた場合はそこに移動しま
     すが、その後は) 変化しません。

 -- メソッド: window.instr ([n])

 -- メソッド: window.instr (y, x[, n])

     現在のカーソル位置、または 'y', 'x' が指定されている場合にはその場
     所から始まるキャラクタの bytes オブジェクトをウィンドウから抽出して
     返します。属性は文字から剥ぎ取られます。'n' が指定された場合、*note
     instr(): 2d84. は (末尾の NUL 文字を除いて) 最大で 'n' 文字までの長
     さからなる文字列を返します。

 -- メソッド: window.is_linetouched (line)

     指定した行が、最後に *note refresh(): 2d3b. を呼んだ時から変更され
     ている場合に ‘True’ を返します; そうでない場合には ‘False’ を返しま
     す。'line' が現在のウィンドウ上の有効な行でない場合、*note
     curses.error: 2d02. 例外を送出します。

 -- メソッド: window.is_wintouched ()

     指定したウィンドウが、最後に *note refresh(): 2d3b. を呼んだ時から
     変更されている場合に ‘True’ を返します; そうでない場合には ‘False’
     を返します。

 -- メソッド: window.keypad (flag)

     'flag' が ‘True’ の場合、ある種のキー (キーパッドやファンクションキ
     ー) によって生成されたエスケープシーケンスは *note curses: 23. で解
     釈されます。'flag' が ‘False’ の場合、エスケープシーケンスは入力ス
     トリームにそのままの状態で残されます。

 -- メソッド: window.leaveok (flag)

     'flag' が ‘True’ の場合、カーソルは "カーソル位置" に移動せず現在の
     場所にとどめます。これにより、カーソルの移動を減らせる可能性があり
     ます。この場合、カーソルは不可視にされます。

     'flag' が ‘False’ の場合、カーソルは更新の際に常に "カーソル位置" に
     移動します。

 -- メソッド: window.move (new_y, new_x)

     カーソルを ‘(new_y, new_x)’ に移動します。

 -- メソッド: window.mvderwin (y, x)

     ウィンドウを親ウィンドウの中で移動します。ウィンドウのスクリーン相
     対となるパラメタ群は変化しません。このルーチンは親ウィンドウの一部
     をスクリーン上の同じ物理位置に表示する際に用いられます。

 -- メソッド: window.mvwin (new_y, new_x)

     ウィンドウの左上角が ‘(new_y, new_x)’ になるように移動します。

 -- メソッド: window.nodelay (flag)

     'flag' が ‘True’ の場合、*note getch(): 2d1d. は非ブロックで動作し
     ます。

 -- メソッド: window.notimeout (flag)

     'flag' が ‘True’ の場合、エスケープシーケンスはタイムアウトしなくな
     ります。

     'flag' が ‘False’ の場合、数ミリ秒間の間エスケープシーケンスは解釈
     されず、入力ストリーム中にそのままの状態で残されます。

 -- メソッド: window.noutrefresh ()

     更新をマークはしますが待機します。この関数はウィンドウのデータ構造
     を表現したい内容を反映するように更新しますが、物理スクリーン上に反
     映させるための強制更新を行いません。更新を行うためには *note
     doupdate(): 2d13. を呼び出します。

 -- メソッド: window.overlay (destwin[, sminrow, smincol, dminrow,
          dmincol, dmaxrow, dmaxcol])

     ウィンドウを 'destwin' の上に重ね書き (overlay) します。ウィンドウ
     は同じサイズである必要はなく、重なっている領域だけが複写されます。
     この複写は非破壊的です。これは現在の背景文字が 'destwin' の内容を上
     書きしないことを意味します。

     複写領域をきめ細かく制御するために、*note overlay(): 2d8e. の第二形
     式を使うことができます。'sminrow' および 'smincol' は元のウィンドウ
     の左上の座標で、他の変数は 'destwin' 内の矩形を表します。

 -- メソッド: window.overwrite (destwin[, sminrow, smincol, dminrow,
          dmincol, dmaxrow, dmaxcol])

     'destwin' の上にウィンドウの内容を上書き (overwrite) します。ウィン
     ドウは同じサイズである必要はなく、重なっている領域だけが複写されま
     す。この複写は破壊的です。これは現在の背景文字が 'destwin' の内容を
     上書きすることを意味します。

     複写領域をきめ細かく制御するために、*note overwrite(): 2d8f. の第二
     形式を使うことができます。'sminrow' および 'smincol' は元のウィンド
     ウの左上の座標で、他の変数は 'destwin' 内の矩形を表します。

 -- メソッド: window.putwin (file)

     ウィンドウに関連付けられているすべてのデータを与えられたファイルオ
     ブジェクトに書き込みます。この情報は後に *note getwin(): 2d28. 関数
     を使って取得することができます。

 -- メソッド: window.redrawln (beg, num)

     'beg' 行から始まる 'num' スクリーン行の表示内容が壊れており、次の
     *note refresh(): 2d3b. 呼び出しで完全に再描画されなければならないこ
     とを通知します。

 -- メソッド: window.redrawwin ()

     ウィンドウ全体を更新 (touch) し、次の *note refresh(): 2d3b. 呼び出
     しで完全に再描画されるようにします。

 -- メソッド: window.refresh ([pminrow, pmincol, sminrow, smincol,
          smaxrow, smaxcol])

     ディスプレイを即時更新し (実際のウィンドウとこれまでの描画/削除メソ
     ッドの内容とを同期し) ます。

     6 つのオプション引数はウィンドウが *note newpad(): 2d3a. で生成され
     た場合にのみ指定することができます。追加の引数はパッドやスクリーン
     のどの部分が含まれるのかを示すために必要です。'pminrow' および
     'pmincol' にはパッドが表示されている矩形の左上角を指定します。
     'sminrow', 'smincol', 'smaxrow', および 'smaxcol' には、スクリーン
     上に表示される矩形の縁を指定します。パッド内に表示される矩形の右下
     角はスクリーン座標から計算されるので、矩形は同じサイズでなければな
     りません。矩形は両方とも、それぞれのウィンドウ構造内に完全に含まれ
     ていなければなりません。'pminrow', 'pmincol', 'sminrow', または
     'smincol' に負の値を指定すると、ゼロを指定したものとして扱われます
     。

 -- メソッド: window.resize (nlines, ncols)

     curses ウィンドウの記憶域を、指定値のサイズに調整するため再割当てし
     ます。サイズが現在の値より大きい場合、ウィンドウのデータは現在の背
     景設定 (*note bkgdset(): 2d5d. で設定) で埋められマージされます。

 -- メソッド: window.scroll ([lines=1])

     スクリーンまたはスクロール領域を上に 'lines' 行スクロールします。

 -- メソッド: window.scrollok (flag)

     ウィンドウのカーソルが、最下行で改行を行ったり最後の文字を入力した
     りした結果、ウィンドウやスクロール領域の縁からはみ出して移動した際
     の動作を制御します。'flag' が ‘False’ の場合、カーソルは最下行にそ
     のままにしておかれます。'flag' が ‘True’ の場合、ウィンドウは 1 行
     上にスクロールします。端末の物理スクロール効果を得るためには *note
     idlok(): 2d7c. も呼び出す必要があるので注意してください。

 -- メソッド: window.setscrreg (top, bottom)

     スクロール領域を 'top' から 'bottom' に設定します。スクロール動作は
     すべてこの領域で行われます。

 -- メソッド: window.standend ()

     'A_STANDOUT' 属性をオフにします。端末によっては、この操作ですべての
     属性をオフにする副作用が発生します。

 -- メソッド: window.standout ()

     'A_STANDOUT' 属性をオンにします。

 -- メソッド: window.subpad (begin_y, begin_x)

 -- メソッド: window.subpad (nlines, ncols, begin_y, begin_x)

     左上の角が ‘(begin_y, begin_x)’ にあり、幅/高さがそれぞれ 'ncols' /
     'nlines' であるようなサブウィンドウを返します。

 -- メソッド: window.subwin (begin_y, begin_x)

 -- メソッド: window.subwin (nlines, ncols, begin_y, begin_x)

     左上の角が ‘(begin_y, begin_x)’ にあり、幅/高さがそれぞれ 'ncols' /
     'nlines' であるようなサブウィンドウを返します。

     デフォルトでは、サブウィンドウは指定された場所からウィンドウの右下
     角まで広がります。

 -- メソッド: window.syncdown ()

     このウィンドウの上位のウィンドウのいずれかで更新(touch)された各場所
     をこのウィンドウ内でも更新します。このルーチンは *note refresh():
     2d3b. から呼び出されるので、手動で呼び出す必要はほとんどないはずで
     す。

 -- メソッド: window.syncok (flag)

     'flag' が ‘True’ の場合、ウィンドウが変更された際は常に *note
     syncup(): 2d9b. を自動的に呼ぶようになります。

 -- メソッド: window.syncup ()

     ウィンドウ内で更新 (touch) した場所を、上位のすべてのウィンドウ内で
     も更新します。

 -- メソッド: window.timeout (delay)

     ウィンドウのブロックまたは非ブロック読み込み動作を設定します。
     'delay' が負の場合、ブロック読み出しが使われ、入力を無期限で待ち受
     けます。'delay' がゼロの場合、非ブロック読み出しが使われ、入力待ち
     の文字がない場合 *note getch(): 2d1d. は ‘-1’ を返します。'delay' が
     正の値であれば、*note getch(): 2d1d. は 'delay' ミリ秒間ブロックし
     、ブロック後の時点で入力がない場合には ‘-1’ を返します。

 -- メソッド: window.touchline (start, count[, changed])

     'start' から始まる 'count' 行が変更されたかのように振舞わせます。も
     し 'changed' が与えられた場合、その引数は指定された行が変更された
     ('changed'‘=True’)か、変更されていないか('changed')を指定します。

 -- メソッド: window.touchwin ()

     描画を最適化するために、すべてのウィンドウが変更されたかのように振
     舞わせます。

 -- メソッド: window.untouchwin ()

     ウィンドウ内のすべての行を、最後に *note refresh(): 2d3b. を呼んだ
     際から変更されていないものとしてマークします。

 -- メソッド: window.vline (ch, n[, attr])

 -- メソッド: window.vline (y, x, ch, n[, attr])

     Display a vertical line starting at ‘(y, x)’ with length 'n'
     consisting of the character 'ch' with attributes 'attr'.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue35924


File: python.info,  Node: 定数<6>,  Prev: Window オブジェクト,  Up: curses --- 文字セル表示のターミナル処理

5.16.9.3 定数
.............

*note curses: 23. モジュールでは以下のデータメンバを定義しています:

 -- データ: curses.ERR

     *note getch(): 2d1d. のような整数を返す curses ルーチンのいくつかは
     、失敗した際に *note ERR: 2da0. を返します。

 -- データ: curses.OK

     *note napms(): 1507. のような整数を返す curses ルーチンのいくつかは
     、成功した際に *note OK: 2da1. を返します。

 -- データ: curses.version

 -- データ: curses.__version__

     A bytes object representing the current version of the module.

 -- データ: curses.ncurses_version

     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.

     Availability: if the ncurses library is used.

     Added in version 3.8.

 -- データ: curses.COLORS

     The maximum number of colors the terminal can support.  It is
     defined only after the call to *note start_color(): 2d48.

 -- データ: curses.COLOR_PAIRS

     The maximum number of color pairs the terminal can support.  It is
     defined only after the call to *note start_color(): 2d48.

 -- データ: curses.COLS

     The width of the screen, i.e., the number of columns.  It is
     defined only after the call to *note initscr(): 1508.  Updated by
     *note update_lines_cols(): db9, *note resizeterm(): 150f. and *note
     resize_term(): 1510.

 -- データ: curses.LINES

     The height of the screen, i.e., the number of lines.  It is defined
     only after the call to *note initscr(): 1508.  Updated by *note
     update_lines_cols(): db9, *note resizeterm(): 150f. and *note
     resize_term(): 1510.

Some constants are available to specify character cell attributes.  The
exact constants available are system dependent.

属性                         意味
                             
-----------------------------------------------------------------
                             
 -- データ:                  代替文字セットモード
          curses.A_ALTCHARSET

 -- データ: curses.A_BLINK   点滅モード
                             
                             
 -- データ: curses.A_BOLD    太字モード
                             
                             
 -- データ: curses.A_DIM     低輝度モード
                             
                             
 -- データ: curses.A_INVIS   Invisible or blank mode
                             
                             
 -- データ:                  イタリックモード
          curses.A_ITALIC    

 -- データ:                  通常の属性
          curses.A_NORMAL    

 -- データ:                  Protected mode
          curses.A_PROTECT   

 -- データ:                  Reverse background and foreground
          curses.A_REVERSE   colors
                             
                             
 -- データ:                  強調モード
          curses.A_STANDOUT  

 -- データ:                  下線モード
          curses.A_UNDERLINE 

 -- データ:                  Horizontal highlight
          curses.A_HORIZONTAL

 -- データ: curses.A_LEFT    Left highlight
                             
                             
 -- データ: curses.A_LOW     Low highlight
                             
                             
 -- データ: curses.A_RIGHT   Right highlight
                             
                             
 -- データ: curses.A_TOP     Top highlight
                             
                             
 -- データ:                  Vertical highlight
          curses.A_VERTICAL  

Added in version 3.7: ‘A_ITALIC’ が追加されました。

Several constants are available to extract corresponding attributes
returned by some methods.

Bit-mask                      意味
                              
------------------------------------------------------------------
                              
 -- データ:                   Bit-mask to extract attributes
          curses.A_ATTRIBUTES 

 -- データ:                   Bit-mask to extract a character
          curses.A_CHARTEXT   

 -- データ: curses.A_COLOR    Bit-mask to extract color-pair
                              field information
                              

キーは ‘KEY_’ で始まる名前をもつ整数定数です。利用可能なキーキャップはシ
ステムに依存します。

キー定数                      キー
                              
-------------------------------------------------------------------------------
                              
 -- データ: curses.KEY_MIN    最小のキー値
                              
                              
 -- データ:                   ブレークキー (Break, 信頼できません)
          curses.KEY_BREAK    

 -- データ: curses.KEY_DOWN   下矢印
                              
                              
 -- データ: curses.KEY_UP     上矢印
                              
                              
 -- データ: curses.KEY_LEFT   左矢印
                              
                              
 -- データ:                   右矢印
          curses.KEY_RIGHT    

 -- データ: curses.KEY_HOME   ホームキー (Home, または上左矢印)
                              
                              
 -- データ:                   バックスペース (Backspace, 信頼できません)
          curses.KEY_BACKSPACE

 -- データ: curses.KEY_F0     ファンクションキー。64 個までサポートされてい
                              ます。
                              
                              
 -- データ: curses.KEY_Fn     ファンクションキー 'n' の値
                              
                              
 -- データ: curses.KEY_DL     行削除 (Delete line)
                              
                              
 -- データ: curses.KEY_IL     行挿入 (Insert line)
                              
                              
 -- データ: curses.KEY_DC     文字削除 (Delete char)
                              
                              
 -- データ: curses.KEY_IC     文字挿入、または文字挿入モードへ入る
                              
                              
 -- データ: curses.KEY_EIC    文字挿入モードから抜ける
                              
                              
 -- データ:                   画面消去
          curses.KEY_CLEAR    

 -- データ: curses.KEY_EOS    画面の末端まで消去
                              
                              
 -- データ: curses.KEY_EOL    行末端まで消去
                              
                              
 -- データ: curses.KEY_SF     前に 1 行スクロール
                              
                              
 -- データ: curses.KEY_SR     後ろ (逆方向) に 1 行スクロール
                              
                              
 -- データ:                   次のページ (Page Next)
          curses.KEY_NPAGE    

 -- データ:                   前のページ (Page Prev)
          curses.KEY_PPAGE    

 -- データ: curses.KEY_STAB   タブ設定
                              
                              
 -- データ: curses.KEY_CTAB   タブリセット
                              
                              
 -- データ:                   すべてのタブをリセット
          curses.KEY_CATAB    

 -- データ:                   入力または送信 (信頼できません)
          curses.KEY_ENTER    

 -- データ:                   ソフトウェア (部分的) リセット (信頼できません
          curses.KEY_SRESET   )
                              
                              
 -- データ:                   リセットまたはハードリセット (信頼できません)
          curses.KEY_RESET    

 -- データ:                   印刷 (Print)
          curses.KEY_PRINT    

 -- データ: curses.KEY_LL     下ホーム (Home down) または最下行 (左下)
                              
                              
 -- データ: curses.KEY_A1     キーパッドの左上キー
                              
                              
 -- データ: curses.KEY_A3     キーパッドの右上キー
                              
                              
 -- データ: curses.KEY_B2     キーパッドの中央キー
                              
                              
 -- データ: curses.KEY_C1     キーパッドの左下キー
                              
                              
 -- データ: curses.KEY_C3     キーパッドの右下キー
                              
                              
 -- データ: curses.KEY_BTAB   Back tab
                              
                              
 -- データ: curses.KEY_BEG    開始 (Beg)
                              
                              
 -- データ:                   キャンセル (Cancel)
          curses.KEY_CANCEL   

 -- データ:                   Close [閉じる]
          curses.KEY_CLOSE    

 -- データ:                   コマンド (Cmd)
          curses.KEY_COMMAND  

 -- データ: curses.KEY_COPY   Copy [コピー]
                              
                              
 -- データ:                   生成 (Create)
          curses.KEY_CREATE   

 -- データ: curses.KEY_END    終了 (End)
                              
                              
 -- データ: curses.KEY_EXIT   Exit [終了]
                              
                              
 -- データ: curses.KEY_FIND   検索 (Find)
                              
                              
 -- データ: curses.KEY_HELP   ヘルプ (Help)
                              
                              
 -- データ: curses.KEY_MARK   マーク (Mark)
                              
                              
 -- データ:                   メッセージ (Message)
          curses.KEY_MESSAGE  

 -- データ: curses.KEY_MOVE   移動 (Move)
                              
                              
 -- データ: curses.KEY_NEXT   次へ (Next)
                              
                              
 -- データ: curses.KEY_OPEN   開く (Open)
                              
                              
 -- データ:                   オプション
          curses.KEY_OPTIONS  

 -- データ:                   前へ (Prev)
          curses.KEY_PREVIOUS 

 -- データ: curses.KEY_REDO   Redo [やり直し]
                              
                              
 -- データ:                   参照 (Ref)
          curses.KEY_REFERENCE

 -- データ:                   更新 (Refresh)
          curses.KEY_REFRESH  

 -- データ:                   置換 (Replace)
          curses.KEY_REPLACE  

 -- データ:                   再起動 (Restart)
          curses.KEY_RESTART  

 -- データ:                   再開 (Resume)
          curses.KEY_RESUME   

 -- データ: curses.KEY_SAVE   Save [保存]
                              
                              
 -- データ: curses.KEY_SBEG   シフト付き Beg
                              
                              
 -- データ:                   シフト付き Cancel
          curses.KEY_SCANCEL  

 -- データ:                   シフト付き Command
          curses.KEY_SCOMMAND 

 -- データ:                   シフト付き Copy
          curses.KEY_SCOPY    

 -- データ:                   シフト付き Create
          curses.KEY_SCREATE  

 -- データ: curses.KEY_SDC    シフト付き Delete char
                              
                              
 -- データ: curses.KEY_SDL    シフト付き Delete line
                              
                              
 -- データ:                   選択 (Select)
          curses.KEY_SELECT   

 -- データ: curses.KEY_SEND   シフト付き End
                              
                              
 -- データ: curses.KEY_SEOL   シフト付き Clear line
                              
                              
 -- データ:                   シフト付き Exit
          curses.KEY_SEXIT    

 -- データ:                   シフト付き Find
          curses.KEY_SFIND    

 -- データ:                   シフト付き Help
          curses.KEY_SHELP    

 -- データ:                   シフト付き Home
          curses.KEY_SHOME    

 -- データ: curses.KEY_SIC    シフト付き Input
                              
                              
 -- データ:                   シフト付き Left arrow
          curses.KEY_SLEFT    

 -- データ:                   シフト付き Message
          curses.KEY_SMESSAGE 

 -- データ:                   シフト付き Move
          curses.KEY_SMOVE    

 -- データ:                   シフト付き Next
          curses.KEY_SNEXT    

 -- データ:                   シフト付き Options
          curses.KEY_SOPTIONS 

 -- データ:                   シフト付き Prev
          curses.KEY_SPREVIOUS

 -- データ:                   シフト付き Print
          curses.KEY_SPRINT   

 -- データ:                   シフト付き Redo
          curses.KEY_SREDO    

 -- データ:                   シフト付き Replace
          curses.KEY_SREPLACE 

 -- データ:                   シフト付き Right arrow
          curses.KEY_SRIGHT   

 -- データ:                   シフト付き Resume
          curses.KEY_SRSUME   

 -- データ:                   シフト付き Save
          curses.KEY_SSAVE    

 -- データ:                   シフト付き Suspend
          curses.KEY_SSUSPEND 

 -- データ:                   シフト付き Undo
          curses.KEY_SUNDO    

 -- データ:                   一時停止 (Suspend)
          curses.KEY_SUSPEND  

 -- データ: curses.KEY_UNDO   Undo [元に戻す]
                              
                              
 -- データ:                   マウスイベント通知
          curses.KEY_MOUSE    

 -- データ:                   端末リサイズイベント
          curses.KEY_RESIZE   

 -- データ: curses.KEY_MAX    最大キー値
                              

On VT100s and their software emulations, such as X terminal emulators,
there are normally at least four function keys (*note KEY_F1: 2dbe,
*note KEY_F2: 2dbe, *note KEY_F3: 2dbe, *note KEY_F4: 2dbe.) available,
and the arrow keys mapped to *note KEY_UP: 2db8, *note KEY_DOWN: 2db7,
*note KEY_LEFT: 2db9. and *note KEY_RIGHT: 2dba. in the obvious way.  If
your machine has a PC keyboard, it is safe to expect arrow keys and
twelve function keys (older PC keyboards may have only ten function
keys); also, the following keypad mappings are standard:

キーキャップ           定数
                       
---------------------------------------
                       
‘Insert’               KEY_IC
                       
                       
‘Delete’               KEY_DC
                       
                       
‘Home’                 KEY_HOME
                       
                       
‘End’                  KEY_END
                       
                       
‘Page Up’              KEY_PPAGE
                       
                       
‘Page Down’            KEY_NPAGE
                       

代替文字セットを以下の表に列挙します。これらは VT100 端末から継承したも
のであり、X 端末のようなソフトウェアエミュレーション上で一般に利用可能な
ものです。グラフィックが利用できない場合、curses は印字可能 ASCII文字に
よる粗雑な近似出力を行います。

     注釈: これらは *note initscr(): 1508. が呼び出された後でしか利用で
     きません。

ACS コード                   意味
                             
----------------------------------------------------------------------------
                             
 -- データ:                  右上角の別名
          curses.ACS_BBSS    

 -- データ:                  黒四角ブロック
          curses.ACS_BLOCK   

 -- データ:                  白四角ブロック
          curses.ACS_BOARD   

 -- データ:                  水平線の別名
          curses.ACS_BSBS    

 -- データ:                  左上角の別名
          curses.ACS_BSSB    

 -- データ:                  上向き T 字罫線の別名
          curses.ACS_BSSS    

 -- データ:                  下向き T 字罫線
          curses.ACS_BTEE    

 -- データ:                  黒丸(bullet)
          curses.ACS_BULLET  

 -- データ:                  チェッカーボードパタン (点描)
          curses.ACS_CKBOARD 

 -- データ:                  下向き矢印
          curses.ACS_DARROW  

 -- データ:                  度記号
          curses.ACS_DEGREE  

 -- データ:                  ダイアモンド
          curses.ACS_DIAMOND 

 -- データ:                  大なりイコール
          curses.ACS_GEQUAL  

 -- データ:                  水平線
          curses.ACS_HLINE   

 -- データ:                  ランタン(lantern) シンボル
          curses.ACS_LANTERN 

 -- データ:                  左向き矢印
          curses.ACS_LARROW  

 -- データ:                  小なりイコール
          curses.ACS_LEQUAL  

 -- データ:                  左下角
          curses.ACS_LLCORNER

 -- データ:                  右下角
          curses.ACS_LRCORNER

 -- データ:                  左向き T 字罫線
          curses.ACS_LTEE    

 -- データ:                  不等号
          curses.ACS_NEQUAL  

 -- データ: curses.ACS_PI    パイ記号
                             
                             
 -- データ:                  プラスマイナス記号
          curses.ACS_PLMINUS 

 -- データ:                  大プラス記号
          curses.ACS_PLUS    

 -- データ:                  右向き矢印
          curses.ACS_RARROW  

 -- データ:                  右向き T 字罫線
          curses.ACS_RTEE    

 -- データ: curses.ACS_S1    スキャンライン 1
                             
                             
 -- データ: curses.ACS_S3    スキャンライン 3
                             
                             
 -- データ: curses.ACS_S7    スキャンライン 7
                             
                             
 -- データ: curses.ACS_S9    スキャンライン 9
                             
                             
 -- データ:                  右下角の別名
          curses.ACS_SBBS    

 -- データ:                  垂直線の別名
          curses.ACS_SBSB    

 -- データ:                  右向き T 字罫線の別名
          curses.ACS_SBSS    

 -- データ:                  左下角の別名
          curses.ACS_SSBB    

 -- データ:                  下向き T 字罫線の別名
          curses.ACS_SSBS    

 -- データ:                  左向き T 字罫線の別名
          curses.ACS_SSSB    

 -- データ:                  交差罫線または大プラス記号の別名
          curses.ACS_SSSS    

 -- データ:                  ポンドスターリング記号
          curses.ACS_STERLING

 -- データ:                  上向き T 字罫線
          curses.ACS_TTEE    

 -- データ:                  上向き矢印
          curses.ACS_UARROW  

 -- データ:                  左上角
          curses.ACS_ULCORNER

 -- データ:                  右上角
          curses.ACS_URCORNER

 -- データ:                  垂直線
          curses.ACS_VLINE   

The following table lists mouse button constants used by *note
getmouse(): 2d1c.:

Mouse button constant                  意味
                                       
-----------------------------------------------------------------------------------------
                                       
 -- データ: curses.BUTTONn_PRESSED     Mouse button 'n' pressed
                                       
                                       
 -- データ: curses.BUTTONn_RELEASED    Mouse button 'n' released
                                       
                                       
 -- データ: curses.BUTTONn_CLICKED     Mouse button 'n' clicked
                                       
                                       
 -- データ:                            Mouse button 'n' double clicked
          curses.BUTTONn_DOUBLE_CLICKED

 -- データ:                            Mouse button 'n' triple clicked
          curses.BUTTONn_TRIPLE_CLICKED

 -- データ: curses.BUTTON_SHIFT        Shift was down during button state change
                                       
                                       
 -- データ: curses.BUTTON_CTRL         Control was down during button state change
                                       
                                       
 -- データ: curses.BUTTON_ALT          Control was down during button state change
                                       

バージョン 3.10 で変更: The ‘BUTTON5_*’ constants are now exposed if
they are provided by the underlying curses library.

以下のテーブルは定義済みの色を列挙したものです:

定数                          色
                              
---------------------------------------------------------------
                              
 -- データ:                   黒
          curses.COLOR_BLACK  

 -- データ:                   青
          curses.COLOR_BLUE   

 -- データ:                   シアン (薄く緑がかった青)
          curses.COLOR_CYAN   

 -- データ:                   緑
          curses.COLOR_GREEN  

 -- データ:                   マゼンタ (紫がかった赤)
          curses.COLOR_MAGENTA

 -- データ:                   赤
          curses.COLOR_RED    

 -- データ:                   白
          curses.COLOR_WHITE  

 -- データ:                   黄色
          curses.COLOR_YELLOW 


File: python.info,  Node: curses textpad --- curses プログラムのためのテキスト入力ウィジェット,  Next: curses ascii --- ASCII 文字のユーティリティー,  Prev: curses --- 文字セル表示のターミナル処理,  Up: 汎用オペレーティングシステムサービス

5.16.10 ‘curses.textpad’ -- curses プログラムのためのテキスト入力ウィジェット
-----------------------------------------------------------------------------

*note curses.textpad: 26. モジュールでは、curses ウィンドウ内での基本的
なテキスト編集を処理し、Emacs に似た (すなわち Netscape Navigator,
BBedit 6.x, FrameMaker, その他諸々のプログラムとも似た) キーバインドをサ
ポートしている *note Textbox: 2e41. クラスを提供します。このモジュールで
はまた、テキストボックスを枠で囲むなどの目的のために有用な、矩形描画関数
を提供しています。

*note curses.textpad: 26. モジュールでは以下の関数を定義しています:

 -- の関数: curses.textpad.rectangle (win, uly, ulx, lry, lrx)

     矩形を描画します。最初の引数はウィンドウオブジェクトでなければなり
     ません; 残りの引数はそのウィンドウからの相対座標になります。2 番目
     および 3 番目の引数は描画すべき矩形の左上角の y および x 座標です;
     4 番目および 5 番目の引数は右下角の y および x 座標です。矩形は、
     VT100/IBM PC におけるフォーム文字を利用できる端末 (xterm やその他の
     ほとんどのソフトウェア端末エミュレータを含む) ではそれを使って描画
     されます。そうでなければ ASCII 文字のダッシュ、垂直バー、およびプラ
     ス記号で描画されます。

* Menu:

* Textbox オブジェクト::


File: python.info,  Node: Textbox オブジェクト,  Up: curses textpad --- curses プログラムのためのテキスト入力ウィジェット

5.16.10.1 Textbox オブジェクト
..............................

以下のような *note Textbox: 2e41. オブジェクトをインスタンス生成すること
ができます:

 -- クラス: curses.textpad.Textbox (win)

     テキストボックスウィジェットオブジェクトを返します。'win' 引数は、
     テキストボックスを入れるための *note ウィンドウ: 2d31. オブジェクト
     でなければなりません。テキストボックスの編集カーソルは、最初はテキ
     ストボックスが入っているウィンドウの左上角に配置され、その座標は
     ‘(0, 0)’ です。インスタンスの *note stripspaces: 2e45. フラグの初期
     値はオンに設定されます。

     *note Textbox: 2e41. オブジェクトは以下のメソッドを持ちます:

      -- メソッド: edit ([validator])

          普段使うことになるエントリポイントです。終了キーストロークの一
          つが入力されるまで編集キーストロークを受け付けます。
          'validator' を与える場合、関数でなければなりません。
          'validator' はキーストロークが入力されるたびにそのキーストロー
          クが引数となって呼び出されます; 返された値に対して、コマンドキ
          ーストロークとして解釈が行われます。このメソッドはウィンドウの
          内容を文字列として返します; ウィンドウ内の空白が含められるかど
          うかは *note stripspaces: 2e45. 属性で決められます。

      -- メソッド: do_command (ch)

          単一のコマンドキーストロークを処理します。以下にサポートされて
          いる特殊キーストロークを示します:

          キーストローク         動作
                                 
          -----------------------------------------------------------------------
                                 
          ‘Control-A’            ウィンドウの左端に移動します。
                                 
                                 
          ‘Control-B’            カーソルを左へ移動し、必要なら前の行に折り返
                                 します。
                                 
                                 
          ‘Control-D’            カーソル下の文字を削除します。
                                 
                                 
          ‘Control-E’            右端 (stripspaces がオフのとき) または行末
                                 (stripspaces がオンのとき) に移動します。
                                 
                                 
          ‘Control-F’            カーソルを右に移動し、必要なら次の行に折り返
                                 します。
                                 
                                 
          ‘Control-G’            ウィンドウを終了し、その内容を返します。
                                 
                                 
          ‘Control-H’            逆方向に文字を削除します。
                                 
                                 
          ‘Control-J’            ウィンドウが 1 行であれば終了し、そうでなけれ
                                 ば新しい行を挿入します。
                                 
                                 
          ‘Control-K’            行が空白行ならその行全体を削除し、そうでなけ
                                 ればカーソル以降行末までを消去します。
                                 
                                 
          ‘Control-L’            スクリーンを更新します。
                                 
                                 
          ‘Control-N’            カーソルを下に移動します; 1 行下に移動します
                                 。
                                 
                                 
          ‘Control-O’            カーソルの場所に空行を 1 行挿入します。
                                 
                                 
          ‘Control-P’            カーソルを上に移動します; 1 行上に移動します
                                 。
                                 

          移動操作は、カーソルがウィンドウの縁にあって移動ができない場合
          には何も行いません。場合によっては、以下のような同義のキースト
          ロークがサポートされています:

          定数                                 キーストローク
                                               
          ------------------------------------------------------------
                                               
          *note KEY_LEFT: 2db9.                ‘Control-B’
                                               
                                               
          *note KEY_RIGHT: 2dba.               ‘Control-F’
                                               
                                               
          *note KEY_UP: 2db8.                  ‘Control-P’
                                               
                                               
          *note KEY_DOWN: 2db7.                ‘Control-N’
                                               
                                               
          *note KEY_BACKSPACE: 2dbc.           ‘Control-h’
                                               

          他のキーストロークは、与えられた文字を挿入し、(行折り返し付き
          で) 右に移動するコマンドとして扱われます。

      -- メソッド: gather ()

          ウィンドウの内容を文字列として返します; ウィンドウ内の空白が含
          められるかどうかは *note stripspaces: 2e45. メンバ変数で決めら
          れます。

      -- の属性: stripspaces

          この属性はウィンドウ内の空白領域の解釈方法を制御するためのフラ
          グです。フラグがオンに設定されている場合、各行の末端にある空白
          領域は無視されます; すなわち、末端空白領域にカーソルが入ると、
          その場所の代わりに行の末尾にカーソルが移動します。また、末端の
          空白領域はウィンドウの内容を取得する際に剥ぎ取られます。


File: python.info,  Node: curses ascii --- ASCII 文字のユーティリティー,  Next: curses panel --- curses のためのパネルスタック拡張,  Prev: curses textpad --- curses プログラムのためのテキスト入力ウィジェット,  Up: 汎用オペレーティングシステムサービス

5.16.11 ‘curses.ascii’ -- ASCII 文字のユーティリティー
------------------------------------------------------

'ソースコード:' Lib/curses/ascii.py(1)

__________________________________________________________________

*note curses.ascii: 24. モジュールでは、 ASCII 文字を指す名前定数と、様
々な ASCII 文字区分についてある文字が帰属するかどうかを調べる関数を提供
します。このモジュールで提供されている定数は以下の制御文字の名前です:

名前                意味
                    
-----------------------------------------------------------------------
                    
 -- データ:
          curses.ascii.NUL

 -- データ:         ヘディング開始、コンソール割り込み
          curses.ascii.SOH

 -- データ:         テキスト開始
          curses.ascii.STX

 -- データ:         テキスト終了
          curses.ascii.ETX

 -- データ:         テキスト伝送終了
          curses.ascii.EOT

 -- データ:         問い合わせ、 *note ACK: 2e51. フロー制御時に使用
          curses.ascii.ENQ

 -- データ:         肯定応答
          curses.ascii.ACK

 -- データ:         ベル
          curses.ascii.BEL

 -- データ:         一文字後退
          curses.ascii.BS

 -- データ:         タブ
          curses.ascii.TAB

 -- データ:         *note TAB: 2e54. の別名: "水平タブ"
          curses.ascii.HT

 -- データ:         改行
          curses.ascii.LF

 -- データ:         *note LF: 2e56. の別名: "改行"
          curses.ascii.NL

 -- データ:         垂直タブ
          curses.ascii.VT

 -- データ:         改頁
          curses.ascii.FF

 -- データ:         復帰
          curses.ascii.CR

 -- データ:         シフトアウト、他の文字セットの開始
          curses.ascii.SO

 -- データ:         シフトイン、標準の文字セットに復帰
          curses.ascii.SI

 -- データ:         データリンクでのエスケープ
          curses.ascii.DLE

 -- データ:         装置制御 1、フロー制御のための XON
          curses.ascii.DC1

 -- データ:         装置制御 2、ブロックモードフロー制御
          curses.ascii.DC2

 -- データ:         装置制御 3、フロー制御のための XOFF
          curses.ascii.DC3

 -- データ:         装置制御 4
          curses.ascii.DC4

 -- データ:         否定応答
          curses.ascii.NAK

 -- データ:         同期信号
          curses.ascii.SYN

 -- データ:         ブロック転送終了
          curses.ascii.ETB

 -- データ:         キャンセル (Cancel)
          curses.ascii.CAN

 -- データ:         媒体終端
          curses.ascii.EM

 -- データ:         代入文字
          curses.ascii.SUB

 -- データ:         エスケープ文字
          curses.ascii.ESC

 -- データ:         ファイル区切り文字
          curses.ascii.FS

 -- データ:         グループ区切り文字
          curses.ascii.GS

 -- データ:         レコード区切り文字、ブロックモード終了子
          curses.ascii.RS

 -- データ:         単位区切り文字
          curses.ascii.US

 -- データ:         空白文字
          curses.ascii.SP

 -- データ:         削除
          curses.ascii.DEL

これらの大部分は、最近は実際に定数の意味通りに使われることがほとんどない
ので注意してください。これらのニーモニック符号はデジタル計算機より前のテ
レプリンタにおける慣習から付けられたものです。

このモジュールでは、標準 C ライブラリの関数を雛型とする以下の関数をサポ
ートしています:

 -- の関数: curses.ascii.isalnum (c)

     ASCII 英数文字かどうかを調べます; ‘isalpha(c) or isdigit(c)’ と等価
     です。

 -- の関数: curses.ascii.isalpha (c)

     ASCII アルファベット文字かどうかを調べます; ‘isupper(c) or
     islower(c)’ と等価です。

 -- の関数: curses.ascii.isascii (c)

     文字が 7 ビット ASCII 文字に合致するかどうかを調べます。

 -- の関数: curses.ascii.isblank (c)

     ASCII 余白文字、すなわち空白または水平タブかどうかを調べます。

 -- の関数: curses.ascii.iscntrl (c)

     ASCII 制御文字 (0x00 から 0x1f の範囲または 0x7f) かどうかを調べま
     す。

 -- の関数: curses.ascii.isdigit (c)

     ASCII 10 進数字、すなわち ‘'0'’ から ‘'9'’ までの文字かどうかを調べ
     ます。‘c in string.digits’ と等価です。

 -- の関数: curses.ascii.isgraph (c)

     空白以外の ASCII 印字可能文字かどうかを調べます。

 -- の関数: curses.ascii.islower (c)

     ASCII 小文字かどうかを調べます。

 -- の関数: curses.ascii.isprint (c)

     空白文字を含め、ASCII 印字可能文字かどうかを調べます。

 -- の関数: curses.ascii.ispunct (c)

     空白または英数字以外の ASCII 印字可能文字かどうかを調べます。

 -- の関数: curses.ascii.isspace (c)

     ASCII 余白文字、すなわち空白、改行、復帰、改頁、水平タブ、垂直タブ
     かどうかを調べます。

 -- の関数: curses.ascii.isupper (c)

     ASCII 大文字かどうかを調べます。

 -- の関数: curses.ascii.isxdigit (c)

     ASCII 16 進数字かどうかを調べます。‘c in string.hexdigits’ と等価で
     す。

 -- の関数: curses.ascii.isctrl (c)

     ASCII 制御文字 (0 から 31 までの値) かどうかを調べます。

 -- の関数: curses.ascii.ismeta (c)

     非 ASCII 文字 (0x80 またはそれ以上の値) かどうかを調べます。

これらの関数は数字も 1 文字の文字列も使えます; 引数を文字列にした場合、
組み込み関数 *note ord(): 1e51. を使って変換されます。

これらの関数は全て、関数に渡した文字列の文字から得られたビット値を調べる
ので注意してください; 関数はホスト計算機で使われている文字列エンコーディ
ングについて何ら関知しません。

以下の 2 つの関数は、引数として 1 文字の文字列または整数で表したバイト値
のどちらでもとり得ます; これらの関数は引数と同じ型で値を返します。

 -- の関数: curses.ascii.ascii (c)

     ASCII 値を返します。'c' の下位 7 ビットに対応します。

 -- の関数: curses.ascii.ctrl (c)

     与えた文字に対応する制御文字を返します (0x1f とビット単位で論理積を
     取ります)。

 -- の関数: curses.ascii.alt (c)

     与えた文字に対応する 8 ビット文字を返します (0x80 とビット単位で論
     理和を取ります)。

以下の関数は 1 文字からなる文字列値または整数値を引数に取り、文字列を返
します。

 -- の関数: curses.ascii.unctrl (c)

     ASCII 文字 'c' の文字列表現を返します。 もし 'c' が印字可能文字であ
     れば、返される文字列は 'c' そのものになります。 もし 'c' が制御文字
     (0x00-0x1f) であれば、キャレット (‘'^'’) と、その後ろに続く 'c' に
     対応した大文字からなる文字列になります。 'c' が ASCII 削除文字
     (0x7f) であれば、文字列は ‘'^?'’ になります。 'c' のメタビット
     (0x80) がセットされていれば、メタビットは取り去られ、前述のルールが
     適用され、‘'!'’ が前につけられます。

 -- データ: curses.ascii.controlnames

     0 (NUL) から 0x1f (US) までの 32 の ASCII 制御文字と、空白文字 ‘SP’
     のニーモニック符号名からなる 33 要素の文字列によるシーケンスです。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/curses/ascii.py


File: python.info,  Node: curses panel --- curses のためのパネルスタック拡張,  Next: platform --- 実行中プラットフォームの固有情報を参照する,  Prev: curses ascii --- ASCII 文字のユーティリティー,  Up: 汎用オペレーティングシステムサービス

5.16.12 ‘curses.panel’ -- curses のためのパネルスタック拡張
-----------------------------------------------------------

__________________________________________________________________

パネルは深さ (depth) の機能が追加されたウィンドウです。これにより、ウィ
ンドウをお互いに重ね合わせることができ、各ウィンドウの可視部分だけが表示
されます。パネルはスタック中に追加したり、スタック内で上下移動させたり、
スタックから除去することができます。

* Menu:

* 関数: 関数<7>.
* Panel オブジェクト::


File: python.info,  Node: 関数<7>,  Next: Panel オブジェクト,  Up: curses panel --- curses のためのパネルスタック拡張

5.16.12.1 関数
..............

*note curses.panel: 25. では以下の関数を定義しています:

 -- の関数: curses.panel.bottom_panel ()

     パネルスタックの最下層のパネルを返します。

 -- の関数: curses.panel.new_panel (win)

     与えられたウィンドウ 'win' に関連付けられたパネルオブジェクトを返し
     ます。返されたパネルオブジェクトを参照しておく必要があることに注意
     してください。もし参照しなければ、パネルオブジェクトはガベージコレ
     クションされてパネルスタックから削除されます。

 -- の関数: curses.panel.top_panel ()

     パネルスタックの最上層のパネルを返します。

 -- の関数: curses.panel.update_panels ()

     仮想スクリーンをパネルスタック変更後の状態に更新します。この関数で
     は *note curses.doupdate(): 2d13. を呼ばないので、ユーザは自分で呼
     び出す必要があります。


File: python.info,  Node: Panel オブジェクト,  Prev: 関数<7>,  Up: curses panel --- curses のためのパネルスタック拡張

5.16.12.2 Panel オブジェクト
............................

上記の *note new_panel(): 2e88. が返す Panel オブジェクトはスタック順の
概念を持つウィンドウです。ウィンドウはパネルに関連付けられており、表示す
る内容を決定している一方、パネルのメソッドはパネルスタック中のウィンドウ
の深さ管理を担います。

Panel オブジェクトは以下のメソッドを持っています:

 -- メソッド: Panel.above ()

     現在のパネルの上にあるパネルを返します。

 -- メソッド: Panel.below ()

     現在のパネルの下にあるパネルを返します。

 -- メソッド: Panel.bottom ()

     パネルをスタックの最下層にプッシュします。

 -- メソッド: Panel.hidden ()

     パネルが隠れている (不可視である) 場合に ‘True’ を返し、そうでない
     場合 ‘False’ を返します。

 -- メソッド: Panel.hide ()

     パネルを隠します。この操作ではオブジェクトは消去されず、スクリーン
     上のウィンドウを不可視にするだけです。

 -- メソッド: Panel.move (y, x)

     パネルをスクリーン座標 ‘(y, x)’ に移動します。

 -- メソッド: Panel.replace (win)

     パネルに関連付けられたウィンドウを 'win' に変更します。

 -- メソッド: Panel.set_userptr (obj)

     パネルのユーザポインタを 'obj' に設定します。このメソッドは任意のデ
     ータをパネルに関連付けるために使われ、任意の Python オブジェクトに
     することができます。

 -- メソッド: Panel.show ()

     (隠れているはずの) パネルを表示します。

 -- メソッド: Panel.top ()

     パネルをスタックの最上層にプッシュします。

 -- メソッド: Panel.userptr ()

     パネルのユーザポインタを返します。任意の Python オブジェクトです。

 -- メソッド: Panel.window ()

     パネルに関連付けられているウィンドウオブジェクトを返します。


File: python.info,  Node: platform --- 実行中プラットフォームの固有情報を参照する,  Next: errno --- 標準の errno システムシンボル,  Prev: curses panel --- curses のためのパネルスタック拡張,  Up: 汎用オペレーティングシステムサービス

5.16.13 ‘platform’ -- 実行中プラットフォームの固有情報を参照する
----------------------------------------------------------------

'ソースコード:' Lib/platform.py(1)

__________________________________________________________________

     注釈: プラットフォーム毎にアルファベット順に並べています。Linuxにつ
     いては Unixセクションを参照してください。

* Menu:

* クロスプラットフォーム::
* Java プラットフォーム::
* Windows プラットフォーム::
* macOS プラットフォーム::
* iOS プラットフォーム::
* Unix プラットフォーム::
* Linux プラットフォーム::
* Android プラットフォーム::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/platform.py


File: python.info,  Node: クロスプラットフォーム,  Next: Java プラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.1 クロスプラットフォーム
................................

 -- の関数: platform.architecture (executable=sys.executable, bits='',
          linkage='')

     'executable' で指定した実行可能ファイル（省略時はPythonインタープリ
     タのバイナリ）の各種アーキテクチャ情報を調べます。

     戻り値はタプル ‘(bits, linkage)’ で、アーキテクチャのビット数と実行
     可能ファイルのリンク形式を示します。どちらの値も文字列で返ります。

     値を決定できない場合はパラメータプリセットから与えられる値を返しま
     す。bits に ‘''’ を与えた場合、サポートされているポインタサイズを知
     るために ‘sizeof(pointer)’ (Python バージョン < 1.5.2 では
     ‘sizeof(long)’) が使用されます。

     この関数は、システムの ‘file’ コマンドを使用します。 ‘file’ はほと
     んどのUnixプラットフォームと一部の非Unixプラットフォームで利用可能
     ですが、 ‘file’ コマンドが利用できず、かつ 'executable' が Pythonイ
     ンタープリタでない場合には適切なデフォルト値が返ります。

          注釈: macOS (とひょっとすると他のプラットフォーム) では、実行
          可能ファイルは複数のアーキテクチャを含んだユニバーサル形式かも
          しれません。

          現在のインタープリターが "64-bit" であるかどうかを調べるには、
          *note sys.maxsize: 1195. の方が信頼できます:

               is_64bits = sys.maxsize > 2**32

 -- の関数: platform.machine ()

     ‘'AMD64'’ のような、機種を返します。不明な場合は空文字列を返します
     。

 -- の関数: platform.node ()

     コンピュータのネットワーク名を返します。ネットワーク名は完全修飾名
     とは限りません。不明な場合は空文字列を返します。

 -- の関数: platform.platform (aliased=False, terse=False)

     実行中プラットフォームを識別する文字列を返します。この文字列には、
     有益な情報をできるだけ多く付加しています。

     戻り値は機械で処理しやすい形式ではなく、'人間にとって読みやすい' 形
     式となっています。異なったプラットフォームでは異なった戻り値となる
     ようになっています。

     'aliased' が真なら、システムの名称として一般的な名称ではなく、別名
     を使用して結果を返します。たとえば、SunOS は Solaris となります。こ
     の機能は *note system_alias(): 2e9e. で実装されています。

     'terse' が真なら、プラットフォームを特定するために最低限必要な情報
     だけを返します。

     バージョン 3.8 で変更: macOSでは、 *note mac_ver(): 199f. が空でな
     いリリース文字列を返すとき、darwin のバージョンではなく macOS のバ
     ージョンを取得するために、この関数は *note mac_ver(): 199f. を使う
     ようになりました。

 -- の関数: platform.processor ()

     ‘'amdk6'’ のような、（現実の）プロセッサ名を返します。

     不明な場合は空文字列を返します。NetBSDのようにこの情報を提供しない
     、または *note machine(): 2e9c. と同じ値しか返さないプラットフォー
     ムも多く存在しますので、注意してください。

 -- の関数: platform.python_build ()

     Pythonのビルド番号と日付を、‘(buildno, builddate)’ のタプルで返しま
     す。

 -- の関数: platform.python_compiler ()

     Pythonをコンパイルする際に使用したコンパイラを示す文字列を返します
     。

 -- の関数: platform.python_branch ()

     Python実装のバージョン管理システム上のブランチを特定する文字列を返
     します。

 -- の関数: platform.python_implementation ()

     Python実装を指定する文字列を返します。戻り値は: 'CPython',
     'IronPython', 'Jython', 'PyPy' のいずれかです。

 -- の関数: platform.python_revision ()

     Python実装のバージョン管理システム上のリビジョンを特定する文字列を
     返します。

 -- の関数: platform.python_version ()

     Python のバージョンを、‘'major.minor.patchlevel'’ 形式の文字列で返
     します。

     ‘sys.version’ と異なり、patchlevel（デフォルトでは0)も必ず含まれて
     います。

 -- の関数: platform.python_version_tuple ()

     Pythonのバージョンを、文字列のタプル ‘(major, minor, patchlevel)’ で
     返します。

     ‘sys.version’ と異なり、patchlevel（デフォルトでは ‘'0'’)も必ず含ま
     れています。

 -- の関数: platform.release ()

     ‘'2.2.0'’ や ‘'NT'’ のような、システムのリリース情報を返します。不
     明な場合は空文字列を返します。

 -- の関数: platform.system ()

     ‘'Linux'’ 、 ‘'Darwin'’ 、 ‘'Java'’ 、 ‘'Windows'’ のような、システ
     ム/OS 名を返します。不明な場合は空文字列を返します。

     On iOS and Android, this returns the user-facing OS name (i.e,
     ‘'iOS’, ‘'iPadOS'’ or ‘'Android'’).  To obtain the kernel name
     (‘'Darwin'’ or ‘'Linux'’), use *note os.uname(): 10e9.

 -- の関数: platform.system_alias (system, release, version)

     マーケティング目的で使われる一般的な別名に変換して ‘(system,
     release, version)’ を返します。混乱を避けるために、情報を並べなおす
     場合があります。

 -- の関数: platform.version ()

     ‘'#3 on degas'’ のような、システムのリリース情報を返します。不明な
     場合は空文字列を返します。

     On iOS and Android, this is the user-facing OS version.  To obtain
     the Darwin or Linux kernel version, use *note os.uname(): 10e9.

 -- の関数: platform.uname ()

     極めて可搬性の高い uname インターフェースです。 *note system: 1dc6,
     *note node: 2e9d, *note release: 2ea7, *note version: 2ea8, *note
     machine: 2e9c, *note processor: 2e9f. の6つの属性を持った *note
     namedtuple(): 1ac. を返します。

     *note processor: 2e9f. is resolved late, on demand.

     Note: the first two attribute names differ from the names presented
     by *note os.uname(): 10e9, where they are named ‘sysname’ and
     ‘nodename’.

     不明な項目は ‘''’ となります。

     バージョン 3.3 で変更: 結果が タプル から *note namedtuple(): 1ac.
     へ変更されました。

     バージョン 3.9 で変更: *note processor: 2e9f. is resolved late
     instead of immediately.


File: python.info,  Node: Java プラットフォーム,  Next: Windows プラットフォーム,  Prev: クロスプラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.2 Java プラットフォーム
...............................

 -- の関数: platform.java_ver (release='', vendor='', vminfo=('', '',
          ''), osinfo=('', '', ''))

     Jython用のバージョンインターフェースです。

     タプル ‘(release, vendor, vminfo, osinfo)’ を返します。'vminfo' は
     タプル ‘(vm_name, vm_release, vm_vendor)’、'osinfo' はタプル
     ‘(os_name, os_version, os_arch)’ です。不明な項目は引数で指定した値
     (デフォルトは ‘''’) となります。

     Deprecated since version 3.13, will be removed in version 3.15: It
     was largely untested, had a confusing API, and was only useful for
     Jython support.


File: python.info,  Node: Windows プラットフォーム,  Next: macOS プラットフォーム,  Prev: Java プラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.3 Windows プラットフォーム
..................................

 -- の関数: platform.win32_ver (release='', version='', csd='',
          ptype='')

     Get additional version information from the Windows Registry and
     return a tuple ‘(release, version, csd, ptype)’ referring to OS
     release, version number, CSD level (service pack) and OS type
     (multi/single processor).  Values which cannot be determined are
     set to the defaults given as parameters (which all default to an
     empty string).

     As a hint: 'ptype' is ‘'Uniprocessor Free'’ on single processor NT
     machines and ‘'Multiprocessor Free'’ on multi processor machines.
     The ‘'Free'’ refers to the OS version being free of debugging code.
     It could also state ‘'Checked'’ which means the OS version uses
     debugging code, i.e.  code that checks arguments, ranges, etc.

 -- の関数: platform.win32_edition ()

     Returns a string representing the current Windows edition, or
     ‘None’ if the value cannot be determined.  Possible values include
     but are not limited to ‘'Enterprise'’, ‘'IoTUAP'’,
     ‘'ServerStandard'’, and ‘'nanoserver'’.

     Added in version 3.8.

 -- の関数: platform.win32_is_iot ()

     *note win32_edition(): 2eab. によって返された Windows のエディショ
     ンが IoT エディションの時 ‘True’ を返します。

     Added in version 3.8.


File: python.info,  Node: macOS プラットフォーム,  Next: iOS プラットフォーム,  Prev: Windows プラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.4 macOS プラットフォーム
................................

 -- の関数: platform.mac_ver (release='', versioninfo=('', '', ''),
          machine='')

     macOS のバージョン情報を、タプル ‘(release, versioninfo, machine)’
     で返します。'versioninfo' は、タプル ‘(version, dev_stage,
     non_release_version)’ です。

     不明な項目は ‘''’ となります。タプルの要素は全て文字列です。


File: python.info,  Node: iOS プラットフォーム,  Next: Unix プラットフォーム,  Prev: macOS プラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.5 iOS プラットフォーム
..............................

 -- の関数: platform.ios_ver (system='', release='', model='',
          is_simulator=False)

     iOS のバージョン情報を取得し、次の属性付きで *note namedtuple():
     1ac. として返します。

        * ‘system’ は OS 名です。 ‘'iOS'’ または ‘'iPadOS'’ となります。

        * ‘release’ は、 iOS のバージョン番号の文字列です。 (‘'17.2'’ な
          ど)

        * ‘model’ はデバイスモデルの識別子です。これは物理デバイスでは
          ‘'iPhone13,2'’ 、シミュレーターでは ‘'iPhone'’ のような文字列
          になります。

        * ‘is_simulator’ は、アプリがシミュレーター上で実行されているの
          か、物理デバイス上で実行されているのかを示す真偽値です。

     決定不能な項目は、引数として指定されたデフォルトに設定されます。


File: python.info,  Node: Unix プラットフォーム,  Next: Linux プラットフォーム,  Prev: iOS プラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.6 Unix プラットフォーム
...............................

 -- の関数: platform.libc_ver (executable=sys.executable, lib='',
          version='', chunksize=16384)

     executableで指定したファイル（省略時はPythonインタープリタ）がリン
     クしているlibcバージョンの取得を試みます。戻り値は文字列のタプル
     ‘(lib, version)’ で、不明な項目は引数で指定した値となります。

     この関数は、実行形式に追加されるシンボルの細かな違いによって、
     libcのバージョンを特定します。この違いは ‘gcc’ でコンパイルされた実
     行可能ファイルでのみ有効だと思われます。

     'chunksize' にはファイルから情報を取得するために読み込むバイト数を
     指定します。


File: python.info,  Node: Linux プラットフォーム,  Next: Android プラットフォーム,  Prev: Unix プラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.7 Linux プラットフォーム
................................

 -- の関数: platform.freedesktop_os_release ()

     Get operating system identification from ‘os-release’ file and
     return it as a dict.  The ‘os-release’ file is a freedesktop.org
     standard(1) and is available in most Linux distributions.  A
     noticeable exception is Android and Android-based distributions.

     Raises *note OSError: 3f0. or subclass when neither
     ‘/etc/os-release’ nor ‘/usr/lib/os-release’ can be read.

     On success, the function returns a dictionary where keys and values
     are strings.  Values have their special characters like ‘"’ and ‘$’
     unquoted.  The fields ‘NAME’, ‘ID’, and ‘PRETTY_NAME’ are always
     defined according to the standard.  All other fields are optional.
     Vendors may include additional fields.

     Note that fields like ‘NAME’, ‘VERSION’, and ‘VARIANT’ are strings
     suitable for presentation to users.  Programs should use fields
     like ‘ID’, ‘ID_LIKE’, ‘VERSION_ID’, or ‘VARIANT_ID’ to identify
     Linux distributions.

     以下はプログラム例です:

          def get_like_distro():
              info = platform.freedesktop_os_release()
              ids = [info["ID"]]
              if "ID_LIKE" in info:
                  # ids are space separated and ordered by precedence
                  ids.extend(info["ID_LIKE"].split())
              return ids

     Added in version 3.10.

   ---------- Footnotes ----------

   (1) https://www.freedesktop.org/software/systemd/man/os-release.html


File: python.info,  Node: Android プラットフォーム,  Prev: Linux プラットフォーム,  Up: platform --- 実行中プラットフォームの固有情報を参照する

5.16.13.8 Android プラットフォーム
..................................

 -- の関数: platform.android_ver (release='', api_level=0,
          manufacturer='', model='', device='', is_emulator=False)

     Android のデバイス情報を取得し、次の属性付きで *note namedtuple():
     1ac. として返します。決定不能な値は、引数として指定されたデフォルト
     に設定されます。

        * ‘release’ - Android バージョンの文字列 (‘"14"’ など) 。

        * ‘api_level’ - API level of the running device, as an integer
          (e.g.  ‘34’ for Android 14).  To get the API level which
          Python was built against, see *note sys.getandroidapilevel():
          b58.

        * ‘manufacturer’ - Manufacturer name(1).

        * ‘model’ - Model name(2) – typically the marketing name or
          model number.

        * ‘device’ - Device name(3) – typically the model number or a
          codename.

        * ‘is_emulator’ - ‘True’ if the device is an emulator; ‘False’
          if it's a physical device.

     Google maintains a list of known model and device names(4).

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) 
https://developer.android.com/reference/android/os/Build#MANUFACTURER

   (2) https://developer.android.com/reference/android/os/Build#MODEL

   (3) https://developer.android.com/reference/android/os/Build#DEVICE

   (4) https://storage.googleapis.com/play_public/supported_devices.html


File: python.info,  Node: errno --- 標準の errno システムシンボル,  Next: ctypes --- Python 用の外部関数ライブラリ,  Prev: platform --- 実行中プラットフォームの固有情報を参照する,  Up: 汎用オペレーティングシステムサービス

5.16.14 ‘errno’ -- 標準の errno システムシンボル
------------------------------------------------

__________________________________________________________________

このモジュールから標準の ‘errno’ システムシンボルを取得することができま
す。個々のシンボルの値は ‘errno’ に対応する整数値です。これらのシンボル
の名前は、 ‘linux/include/errno.h’ から借用されており、網羅的なはずです
。

 -- データ: errno.errorcode

     errno 値を背後のシステムにおける文字列表現に対応付ける辞書です。例
     えば、‘errno.errorcode[errno.EPERM]’ は ‘'EPERM'’ に対応付けられま
     す。

数値のエラーコードをエラーメッセージに変換するには、 *note
os.strerror(): 2a82. を使ってください。

以下のリストの内、現在のプラットフォームで使われていないシンボルはモジュ
ール上で定義されていません。定義されているシンボルだけを挙げたリストは
‘errno.errorcode.keys()’ として取得することができます。取得できるシンボ
ルには以下のようなものがあります:

 -- データ: errno.EPERM

     Operation not permitted.  This error is mapped to the exception
     *note PermissionError: d10.

 -- データ: errno.ENOENT

     No such file or directory.  This error is mapped to the exception
     *note FileNotFoundError: e8f.

 -- データ: errno.ESRCH

     No such process.  This error is mapped to the exception *note
     ProcessLookupError: 102f.

 -- データ: errno.EINTR

     Interrupted system call.  This error is mapped to the exception
     *note InterruptedError: d55.

 -- データ: errno.EIO

     I/O エラーです (I/O error)

 -- データ: errno.ENXIO

     そのようなデバイスまたはアドレスは存在しません (No such device or
     address)

 -- データ: errno.E2BIG

     引数リストが長すぎます (Arg list too long)

 -- データ: errno.ENOEXEC

     実行形式にエラーがあります (Exec format error)

 -- データ: errno.EBADF

     ファイル番号が間違っています (Bad file number)

 -- データ: errno.ECHILD

     No child processes.  This error is mapped to the exception *note
     ChildProcessError: 102c.

 -- データ: errno.EAGAIN

     Try again.  This error is mapped to the exception *note
     BlockingIOError: 102b.

 -- データ: errno.ENOMEM

     空きメモリがありません (Out of memory)

 -- データ: errno.EACCES

     Permission denied.  This error is mapped to the exception *note
     PermissionError: d10.

 -- データ: errno.EFAULT

     不正なアドレスです (Bad address)

 -- データ: errno.ENOTBLK

     ブロックデバイスが必要です (Block device required)

 -- データ: errno.EBUSY

     そのデバイスまたはリソースは使用中です (Device or resource busy)

 -- データ: errno.EEXIST

     File exists.  This error is mapped to the exception *note
     FileExistsError: fea.

 -- データ: errno.EXDEV

     デバイスをまたいだリンクです (Cross-device link)

 -- データ: errno.ENODEV

     そのようなデバイスはありません (No such device)

 -- データ: errno.ENOTDIR

     Not a directory.  This error is mapped to the exception *note
     NotADirectoryError: 102e.

 -- データ: errno.EISDIR

     Is a directory.  This error is mapped to the exception *note
     IsADirectoryError: 102d.

 -- データ: errno.EINVAL

     無効な引数です (Invalid argument)

 -- データ: errno.ENFILE

     ファイルテーブルがオーバフローしています (File table overflow)

 -- データ: errno.EMFILE

     開かれたファイルが多すぎます (Too many open files)

 -- データ: errno.ENOTTY

     タイプライタではありません (Not a typewriter)

 -- データ: errno.ETXTBSY

     テキストファイルが使用中です (Text file busy)

 -- データ: errno.EFBIG

     ファイルが大きすぎます (File too large)

 -- データ: errno.ENOSPC

     デバイス上に空きがありません (No space left on device)

 -- データ: errno.ESPIPE

     不正なシークです (Illegal seek)

 -- データ: errno.EROFS

     リードオンリーのファイルシステムです (Read-only file system)

 -- データ: errno.EMLINK

     リンクが多すぎます (Too many links)

 -- データ: errno.EPIPE

     Broken pipe.  This error is mapped to the exception *note
     BrokenPipeError: 1030.

 -- データ: errno.EDOM

     数学引数が関数の定義域を越えています (Math argument out of domain
     of func)

 -- データ: errno.ERANGE

     表現できない数学演算結果になりました (Math result not
     representable)

 -- データ: errno.EDEADLK

     リソースのデッドロックが起きます (Resource deadlock would occur)

 -- データ: errno.ENAMETOOLONG

     ファイル名が長すぎます (File name too long)

 -- データ: errno.ENOLCK

     レコードロッキングが利用できません (No record locks available)

 -- データ: errno.ENOSYS

     実装されていない機能です (Function not implemented)

 -- データ: errno.ENOTEMPTY

     ディレクトリが空ではありません (Directory not empty)

 -- データ: errno.ELOOP

     これ以上シンボリックリンクを追跡できません (Too many symbolic links
     encountered)

 -- データ: errno.EWOULDBLOCK

     Operation would block.  This error is mapped to the exception *note
     BlockingIOError: 102b.

 -- データ: errno.ENOMSG

     指定された型のメッセージはありません (No message of desired type)

 -- データ: errno.EIDRM

     識別子が除去されました (Identifier removed)

 -- データ: errno.ECHRNG

     チャネル番号が範囲を超えました (Channel number out of range)

 -- データ: errno.EL2NSYNC

     レベル 2 で同期がとれていません (Level 2 not synchronized)

 -- データ: errno.EL3HLT

     レベル 3 で終了しました (Level 3 halted)

 -- データ: errno.EL3RST

     レベル 3 でリセットしました (Level 3 reset)

 -- データ: errno.ELNRNG

     リンク番号が範囲を超えています (Link number out of range)

 -- データ: errno.EUNATCH

     プロトコルドライバが接続されていません (Protocol driver not
     attached)

 -- データ: errno.ENOCSI

     CSI 構造体がありません (No CSI structure available)

 -- データ: errno.EL2HLT

     レベル 2 で終了しました (Level 2 halted)

 -- データ: errno.EBADE

     無効な変換です (Invalid exchange)

 -- データ: errno.EBADR

     無効な要求記述子です (Invalid request descriptor)

 -- データ: errno.EXFULL

     変換テーブルが一杯です (Exchange full)

 -- データ: errno.ENOANO

     陰極がありません (No anode)

 -- データ: errno.EBADRQC

     無効なリクエストコードです (Invalid request code)

 -- データ: errno.EBADSLT

     無効なスロットです (Invalid slot)

 -- データ: errno.EDEADLOCK

     ファイルロックにおけるデッドロックエラーです (File locking deadlock
     error)

 -- データ: errno.EBFONT

     フォントファイル形式が間違っています (Bad font file format)

 -- データ: errno.ENOSTR

     ストリーム型でないデバイスです (Device not a stream)

 -- データ: errno.ENODATA

     利用可能なデータがありません (No data available)

 -- データ: errno.ETIME

     時間切れです (Timer expired)

 -- データ: errno.ENOSR

     ストリームリソースを使い切りました (Out of streams resources)

 -- データ: errno.ENONET

     計算機はネットワーク上にありません (Machine is not on the network)

 -- データ: errno.ENOPKG

     パッケージがインストールされていません (Package not installed)

 -- データ: errno.EREMOTE

     対象物は遠隔にあります (Object is remote)

 -- データ: errno.ENOLINK

     リンクが切られました (Link has been severed)

 -- データ: errno.EADV

     Advertise エラーです (Advertise error)

 -- データ: errno.ESRMNT

     Srmount エラーです (Srmount error)

 -- データ: errno.ECOMM

     送信時の通信エラーです (Communication error on send)

 -- データ: errno.EPROTO

     プロトコルエラーです (Protocol error)

 -- データ: errno.EMULTIHOP

     多重ホップを試みました (Multihop attempted)

 -- データ: errno.EDOTDOT

     RFS 特有のエラーです (RFS specific error)

 -- データ: errno.EBADMSG

     データメッセージではありません (Not a data message)

 -- データ: errno.EOVERFLOW

     定義されたデータ型にとって大きすぎる値です (Value too large for
     defined data type)

 -- データ: errno.ENOTUNIQ

     名前がネットワーク上で一意でありません (Name not unique on network)

 -- データ: errno.EBADFD

     ファイル記述子の状態が不正です (File descriptor in bad state)

 -- データ: errno.EREMCHG

     遠隔のアドレスが変更されました (Remote address changed)

 -- データ: errno.ELIBACC

     必要な共有ライブラリにアクセスできません (Can not access a needed
     shared library)

 -- データ: errno.ELIBBAD

     壊れた共有ライブラリにアクセスしています (Accessing a corrupted
     shared library)

 -- データ: errno.ELIBSCN

     a.out の .lib セクションが壊れています (.lib section in a.out
     corrupted)

 -- データ: errno.ELIBMAX

     リンクを試みる共有ライブラリが多すぎます (Attempting to link in too
     many shared libraries)

 -- データ: errno.ELIBEXEC

     共有ライブラリを直接実行することができません (Cannot exec a shared
     library directly)

 -- データ: errno.EILSEQ

     不正なバイト列です (Illegal byte sequence)

 -- データ: errno.ERESTART

     割り込みシステムコールを復帰しなければなりません (Interrupted
     system call should be restarted)

 -- データ: errno.ESTRPIPE

     ストリームパイプのエラーです (Streams pipe error)

 -- データ: errno.EUSERS

     ユーザが多すぎます (Too many users)

 -- データ: errno.ENOTSOCK

     非ソケットに対するソケット操作です (Socket operation on non-socket)

 -- データ: errno.EDESTADDRREQ

     目的アドレスが必要です (Destination address required)

 -- データ: errno.EMSGSIZE

     メッセージが長すぎます (Message too long)

 -- データ: errno.EPROTOTYPE

     ソケットに対して不正なプロトコル型です (Protocol wrong type for
     socket)

 -- データ: errno.ENOPROTOOPT

     利用できないプロトコルです (Protocol not available)

 -- データ: errno.EPROTONOSUPPORT

     サポートされていないプロトコルです (Protocol not supported)

 -- データ: errno.ESOCKTNOSUPPORT

     サポートされていないソケット型です (Socket type not supported)

 -- データ: errno.EOPNOTSUPP

     通信端点に対してサポートされていない操作です (Operation not
     supported on transport endpoint)

 -- データ: errno.ENOTSUP

     Operation not supported

     Added in version 3.2.

 -- データ: errno.EPFNOSUPPORT

     サポートされていないプロトコルファミリです (Protocol family not
     supported)

 -- データ: errno.EAFNOSUPPORT

     プロトコルでサポートされていないアドレスファミリです (Address
     family not supported by protocol)

 -- データ: errno.EADDRINUSE

     アドレスは使用中です (Address already in use)

 -- データ: errno.EADDRNOTAVAIL

     要求されたアドレスを割り当てできません (Cannot assign requested
     address)

 -- データ: errno.ENETDOWN

     ネットワークがダウンしています (Network is down)

 -- データ: errno.ENETUNREACH

     ネットワークに到達できません (Network is unreachable)

 -- データ: errno.ENETRESET

     リセットによってネットワーク接続が切られました (Network dropped
     connection because of reset)

 -- データ: errno.ECONNABORTED

     Software caused connection abort.  This error is mapped to the
     exception *note ConnectionAbortedError: 1031.

 -- データ: errno.ECONNRESET

     Connection reset by peer.  This error is mapped to the exception
     *note ConnectionResetError: 1033.

 -- データ: errno.ENOBUFS

     バッファに空きがありません (No buffer space available)

 -- データ: errno.EISCONN

     通信端点がすでに接続されています (Transport endpoint is already
     connected)

 -- データ: errno.ENOTCONN

     通信端点が接続されていません (Transport endpoint is not connected)

 -- データ: errno.ESHUTDOWN

     Cannot send after transport endpoint shutdown.  This error is
     mapped to the exception *note BrokenPipeError: 1030.

 -- データ: errno.ETOOMANYREFS

     参照が多すぎます: 接続できません (Too many references: cannot
     splice)

 -- データ: errno.ETIMEDOUT

     Connection timed out.  This error is mapped to the exception *note
     TimeoutError: 800.

 -- データ: errno.ECONNREFUSED

     Connection refused.  This error is mapped to the exception *note
     ConnectionRefusedError: 1032.

 -- データ: errno.EHOSTDOWN

     ホストはシステムダウンしています (Host is down)

 -- データ: errno.EHOSTUNREACH

     ホストへの経路がありません (No route to host)

 -- データ: errno.EALREADY

     Operation already in progress.  This error is mapped to the
     exception *note BlockingIOError: 102b.

 -- データ: errno.EINPROGRESS

     Operation now in progress.  This error is mapped to the exception
     *note BlockingIOError: 102b.

 -- データ: errno.ESTALE

     無効な NFS ファイルハンドルです (Stale NFS file handle)

 -- データ: errno.EUCLEAN

     構造のクリーニングが必要です (Structure needs cleaning)

 -- データ: errno.ENOTNAM

     XENIX 名前付きファイルではありません (Not a XENIX named type file)

 -- データ: errno.ENAVAIL

     XENIX セマフォは利用できません (No XENIX semaphores available)

 -- データ: errno.EISNAM

     名前付きファイルです (Is a named type file)

 -- データ: errno.EREMOTEIO

     遠隔側の I/O エラーです (Remote I/O error)

 -- データ: errno.EDQUOT

     ディスククオータを超えました (Quota exceeded)

 -- データ: errno.EQFULL

     Interface output queue is full

     Added in version 3.11.

 -- データ: errno.ENOTCAPABLE

     Capabilities insufficient.  This error is mapped to the exception
     *note PermissionError: d10.

     *note Availability: 1cbe.: WASI, FreeBSD

     Added in version 3.11.1.

 -- データ: errno.ECANCELED

     Operation canceled

     Added in version 3.2.

 -- データ: errno.EOWNERDEAD

     Owner died

     Added in version 3.2.

 -- データ: errno.ENOTRECOVERABLE

     State not recoverable

     Added in version 3.2.


File: python.info,  Node: ctypes --- Python 用の外部関数ライブラリ,  Prev: errno --- 標準の errno システムシンボル,  Up: 汎用オペレーティングシステムサービス

5.16.15 ‘ctypes’ -- Python 用の外部関数ライブラリ
-------------------------------------------------

'ソースコード:' Lib/ctypes(1)

__________________________________________________________________

*note ctypes: 22. は Python のための外部関数ライブラリです。このライブラ
リは C と互換性のあるデータ型を提供し、動的リンク/共有ライブラリ内の関数
呼び出しを可能にします。動的リンク/共有ライブラリを純粋な Python でラッ
プするために使うことができます。

* Menu:

* ctypes チュートリアル::
* ctypesリファレンス::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/ctypes


File: python.info,  Node: ctypes チュートリアル,  Next: ctypesリファレンス,  Up: ctypes --- Python 用の外部関数ライブラリ

5.16.15.1 ctypes チュートリアル
...............................

注意: このチュートリアルのコードサンプルは動作確認のために *note
doctest: 31. を使います。コードサンプルの中には Linux、 Windows、あるい
は macOS 上で異なる動作をするものがあるため、サンプルのコメントに
doctest 命令を入れてあります。

注意: いくつかのコードサンプルで ctypes の *note c_int: 2f1f. 型を参照し
ています。 ‘sizeof(long) == sizeof(int)’ であるようなプラットフォームで
は、この型は *note c_long: 2f20. のエイリアスです。そのため、 *note
c_int: 2f1f. 型を想定しているときに *note c_long: 2f20. が表示されたとし
ても、混乱しないようにしてください -- 実際には同じ型なのです。

* Menu:

* 動的リンクライブラリをロードする::
* ロードしたdllから関数にアクセスする::
* 関数を呼び出す::
* 基本データ型::
* 続・関数を呼び出す::
* Calling variadic functions::
* 自作のデータ型とともに関数を呼び出す::
* 要求される引数の型を指定する (関数プロトタイプ): 要求される引数の型を指定する 関数プロトタイプ.
* 戻り値の型::
* ポインタを渡す(または、パラメータの参照渡し): ポインタを渡す または、パラメータの参照渡し.
* 構造体と共用体::
* 構造体/共用体アライメントとバイトオーダー::
* 構造体と共用体におけるビットフィールド::
* 配列::
* ポインタ::
* 型変換::
* 不完全型::
* コールバック関数::
* dllからエクスポートされた値へアクセスする::
* びっくり仰天::
* 可変サイズのデータ型::


File: python.info,  Node: 動的リンクライブラリをロードする,  Next: ロードしたdllから関数にアクセスする,  Up: ctypes チュートリアル

5.16.15.2 動的リンクライブラリをロードする
..........................................

動的リンクライブラリをロードするために、 *note ctypes: 22. は 'cdll' を
エクスポートします。 Windows では 'windll' と 'oledll' オブジェクトをエ
クスポートします。

You load libraries by accessing them as attributes of these objects.
'cdll' loads libraries which export functions using the standard ‘cdecl’
calling convention, while 'windll' libraries call functions using the
‘stdcall’ calling convention.  'oledll' also uses the ‘stdcall’ calling
convention, and assumes the functions return a Windows ‘HRESULT’ error
code.  The error code is used to automatically raise an *note OSError:
3f0. exception when the function call fails.

バージョン 3.3 で変更: Windows エラーは以前は *note WindowsError: 1028.
を送出していましたが、これは現在では *note OSError: 3f0. の別名になって
います。

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:

     >>> from ctypes import *
     >>> print(windll.kernel32)
     <WinDLL 'kernel32', handle ... at ...>
     >>> print(cdll.msvcrt)
     <CDLL 'msvcrt', handle ... at ...>
     >>> libc = cdll.msvcrt
     >>>

Windows では通常の ‘.dll’ ファイル拡張子を自動的に追加します。

     注釈: ‘cdll.msvcrt’ 経由で標準 C ライブラリにアクセスすると、Python
     が使用しているライブラリとは互換性のない可能性のある、古いバージョ
     ンのライブラリが使用されます。可能な場合には、ネイティブ Python の
     機能を使用するか、‘msvcrt’ モジュールをインポートして使用してくださ
     い。

On Linux, it is required to specify the filename 'including' the
extension to load a library, so attribute access can not be used to load
libraries.  Either the *note LoadLibrary(): 2f23. method of the dll
loaders should be used, or you should load the library by creating an
instance of CDLL by calling the constructor:

     >>> cdll.LoadLibrary("libc.so.6")
     <CDLL 'libc.so.6', handle ... at ...>
     >>> libc = CDLL("libc.so.6")
     >>> libc
     <CDLL 'libc.so.6', handle ... at ...>
     >>>


File: python.info,  Node: ロードしたdllから関数にアクセスする,  Next: 関数を呼び出す,  Prev: 動的リンクライブラリをロードする,  Up: ctypes チュートリアル

5.16.15.3 ロードしたdllから関数にアクセスする
.............................................

dll オブジェクトの属性として関数にアクセスします:

     >>> libc.printf
     <_FuncPtr object at 0x...>
     >>> print(windll.kernel32.GetModuleHandleA)
     <_FuncPtr object at 0x...>
     >>> print(windll.kernel32.MyOwnFunction)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "ctypes.py", line 239, in __getattr__
         func = _StdcallFuncPtr(name, self)
     AttributeError: function 'MyOwnFunction' not found
     >>>

Note that win32 system dlls like ‘kernel32’ and ‘user32’ often export
ANSI as well as UNICODE versions of a function.  The UNICODE version is
exported with a ‘W’ appended to the name, while the ANSI version is
exported with an ‘A’ appended to the name.  The win32 ‘GetModuleHandle’
function, which returns a 'module handle' for a given module name, has
the following C prototype, and a macro is used to expose one of them as
‘GetModuleHandle’ depending on whether UNICODE is defined or not:

     /* ANSI version */
     HMODULE GetModuleHandleA(LPCSTR lpModuleName);
     /* UNICODE version */
     HMODULE GetModuleHandleW(LPCWSTR lpModuleName);

'windll' は魔法を使ってどちらか一つを選ぶようなことはしません。
‘GetModuleHandleA’ もしくは ‘GetModuleHandleW’ を明示的に指定して必要と
するバージョンにアクセスし、バイト列か文字列を使ってそれぞれ呼び出さなけ
ればなりません。

時には、 dll が関数を ‘"??2@YAPAXI@Z"’ のような Python 識別子として有効
でない名前でエクスポートすることがあります。このような場合に関数を取り出
すには、 *note getattr(): b9f. を使わなければなりません。:

     >>> getattr(cdll.msvcrt, "??2@YAPAXI@Z")
     <_FuncPtr object at 0x...>
     >>>

Windows では、名前ではなく序数によって関数をエクスポートする dll もあり
ます。こうした関数には序数を使って dll オブジェクトにインデックス指定す
ることでアクセスします:

     >>> cdll.kernel32[1]
     <_FuncPtr object at 0x...>
     >>> cdll.kernel32[0]
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "ctypes.py", line 310, in __getitem__
         func = _StdcallFuncPtr(name, self)
     AttributeError: function ordinal 0 not found
     >>>


File: python.info,  Node: 関数を呼び出す,  Next: 基本データ型,  Prev: ロードしたdllから関数にアクセスする,  Up: ctypes チュートリアル

5.16.15.4 関数を呼び出す
........................

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:

     >>> print(libc.rand())
     1804289383

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):

     >>> print(hex(windll.kernel32.GetModuleHandleA(None)))
     0x1d000000
     >>>

‘cdecl’ 呼び出し規約を使って ‘stdcall’ 関数を呼び出したときには、 *note
ValueError: 1e3. が送出されます。逆の場合も同様です:

     >>> cdll.kernel32.GetModuleHandleA(None)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ValueError: Procedure probably called with not enough arguments (4 bytes missing)
     >>>

     >>> windll.msvcrt.printf(b"spam")
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ValueError: Procedure probably called with too many arguments (4 bytes in excess)
     >>>

正しい呼び出し規約を知るためには、呼び出したい関数についての C ヘッダフ
ァイルもしくはドキュメントを見なければなりません。

Windows では、関数が無効な引数とともに呼び出された場合の一般保護例外によ
るクラッシュを防ぐために、 *note ctypes: 22. は win32 構造化例外処理を使
います:

     >>> windll.kernel32.GetModuleHandleA(32)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     OSError: exception: access violation reading 0x00000020
     >>>

しかしそれでも他に *note ctypes: 22. で Python がクラッシュする状況はあ
るので、どちらにせよ気を配るべきです。クラッシュのデバッグには、 *note
faulthandler: 4e. モジュールが役に立つ場合があります (例えば、誤った C ラ
イブラリ呼び出しによって引き起こされたセグメンテーション違反) 。

‘None’, integers, bytes objects and (unicode) strings are the only
native Python objects that can directly be used as parameters in these
function calls.  ‘None’ is passed as a C ‘NULL’ pointer, bytes objects
and strings are passed as pointer to the memory block that contains
their data (char* or wchar_t*).  Python integers are passed as the
platform's default C int type, their value is masked to fit into the C
type.

他のパラメータ型をもつ関数呼び出しに移る前に、 *note ctypes: 22. データ
型についてさらに学ぶ必要があります。


File: python.info,  Node: 基本データ型,  Next: 続・関数を呼び出す,  Prev: 関数を呼び出す,  Up: ctypes チュートリアル

5.16.15.5 基本データ型
......................

*note ctypes: 22. ではいくつもの C 互換のプリミティブなデータ型を定義し
ています:

ctypes の型                C の型                                         Python の型
                                                                          
-----------------------------------------------------------------------------------------------------------
                                                                          
*note c_bool: 2f2a.        _Bool                                          bool (1)
                                                                          
                                                                          
*note c_char: 2f2b.        char                                           1文字のバイト列オブジェクト
                                                                          
                                                                          
*note c_wchar: 2f2c.       ‘wchar_t’                                      1文字の文字列
                                                                          
                                                                          
*note c_byte: 16db.        char                                           int
                                                                          
                                                                          
*note c_ubyte: 16dc.       unsigned char                                  int
                                                                          
                                                                          
*note c_short: 2f2d.       short                                          int
                                                                          
                                                                          
*note c_ushort: 2f2e.      unsigned short                                 int
                                                                          
                                                                          
*note c_int: 2f1f.         int                                            int
                                                                          
                                                                          
*note c_uint: 2f2f.        unsigned int                                   int
                                                                          
                                                                          
*note c_long: 2f20.        long                                           int
                                                                          
                                                                          
*note c_ulong: 2f30.       unsigned long                                  int
                                                                          
                                                                          
*note c_longlong: 2f31.    __int64 または long long                       int
                                                                          
                                                                          
*note c_ulonglong: 2f32.   unsigned __int64 または unsigned long long     int
                                                                          
                                                                          
*note c_size_t: 2f33.      ‘size_t’                                       int
                                                                          
                                                                          
*note c_ssize_t: 120d.     ‘ssize_t’ or *note Py_ssize_t: a2e.            int
                                                                          
                                                                          
*note c_time_t: 1744.      ‘time_t’                                       int
                                                                          
                                                                          
*note c_float: 2f34.       float                                          浮動小数点数
                                                                          
                                                                          
*note c_double: 1865.      double                                         浮動小数点数
                                                                          
                                                                          
*note c_longdouble: 1866.  long double                                    浮動小数点数
                                                                          
                                                                          
*note c_char_p: 164c.      char* (NUL 終端)                               バイト列オブジェクトまたは
                                                                          ‘None’
                                                                          
                                                                          
*note c_wchar_p: 164d.     wchar_t* (NUL 終端)                            文字列または ‘None’
                                                                          
                                                                          
*note c_void_p: 164e.      void*                                          整数または ‘None’
                                                                          

  1. コンストラクタは任意のオブジェクトをその真偽値として受け取ります。

これら全ての型はその型を呼び出すことによって作成でき、オプションとして型
と値が合っている初期化子を指定することができます:

     >>> c_int()
     c_long(0)
     >>> c_wchar_p("Hello, World")
     c_wchar_p(140018365411392)
     >>> c_ushort(-3)
     c_ushort(65533)
     >>>

これらの型は変更可能であり、値を後で変更することもできます:

     >>> i = c_int(42)
     >>> print(i)
     c_long(42)
     >>> print(i.value)
     42
     >>> i.value = -99
     >>> print(i.value)
     -99
     >>>

新しい値をポインタ型 *note c_char_p: 164c, *note c_wchar_p: 164d. および
*note c_void_p: 164e. のインスタンスへ代入すると、変わるのは指している
'メモリ位置' であって、メモリブロックの '内容ではありません' (これは当然
で、なぜなら、 Python バイト列オブジェクトは変更不可能だからです):

     >>> s = "Hello, World"
     >>> c_s = c_wchar_p(s)
     >>> print(c_s)
     c_wchar_p(139966785747344)
     >>> print(c_s.value)
     Hello World
     >>> c_s.value = "Hi, there"
     >>> print(c_s)              # the memory location has changed
     c_wchar_p(139966783348904)
     >>> print(c_s.value)
     Hi, there
     >>> print(s)                # first object is unchanged
     Hello, World
     >>>

しかし、変更可能なメモリを指すポインタであることを想定している関数へそれ
らを渡さないように注意すべきです。もし変更可能なメモリブロックが必要なら
、 ctypes には *note create_string_buffer(): 2f35. 関数があり、いろいろ
な方法で作成することできます。現在のメモリブロックの内容は ‘raw’ プロパ
ティを使ってアクセス (あるいは変更) することができます。もし現在のメモリ
ブロックに NUL 終端文字列としてアクセスしたいなら、 ‘value’ プロパティを
使ってください:

     >>> from ctypes import *
     >>> p = create_string_buffer(3)            # create a 3 byte buffer, initialized to NUL bytes
     >>> print(sizeof(p), repr(p.raw))
     3 b'\x00\x00\x00'
     >>> p = create_string_buffer(b"Hello")     # create a buffer containing a NUL terminated string
     >>> print(sizeof(p), repr(p.raw))
     6 b'Hello\x00'
     >>> print(repr(p.value))
     b'Hello'
     >>> p = create_string_buffer(b"Hello", 10) # create a 10 byte buffer
     >>> print(sizeof(p), repr(p.raw))
     10 b'Hello\x00\x00\x00\x00\x00'
     >>> p.value = b"Hi"
     >>> print(sizeof(p), repr(p.raw))
     10 b'Hi\x00lo\x00\x00\x00\x00\x00'
     >>>

The *note create_string_buffer(): 2f35. function replaces the old
‘c_buffer()’ function (which is still available as an alias).  To create
a mutable memory block containing unicode characters of the C type
‘wchar_t’, use the *note create_unicode_buffer(): 193a. function.


File: python.info,  Node: 続・関数を呼び出す,  Next: Calling variadic functions,  Prev: 基本データ型,  Up: ctypes チュートリアル

5.16.15.6 続・関数を呼び出す
............................

printf は *note sys.stdout: aa4. では 'なく' 、本物の標準出力チャンネル
へプリントすることに注意してください。したがって、これらの例はコンソール
プロンプトでのみ動作し、 'IDLE' や 'PythonWin' では動作しません。:

     >>> printf = libc.printf
     >>> printf(b"Hello, %s\n", b"World!")
     Hello, World!
     14
     >>> printf(b"Hello, %S\n", "World!")
     Hello, World!
     14
     >>> printf(b"%d bottles of beer\n", 42)
     42 bottles of beer
     19
     >>> printf(b"%f bottles of beer\n", 42.5)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ctypes.ArgumentError: argument 2: TypeError: Don't know how to convert parameter 2
     >>>

前に述べたように、必要な C のデータ型へ変換できるようにするためには、整
数、文字列およびバイト列オブジェクトを除くすべての Python 型を対応する
*note ctypes: 22. 型でラップしなければなりません:

     >>> printf(b"An int %d, a double %f\n", 1234, c_double(3.14))
     An int 1234, a double 3.140000
     31
     >>>


File: python.info,  Node: Calling variadic functions,  Next: 自作のデータ型とともに関数を呼び出す,  Prev: 続・関数を呼び出す,  Up: ctypes チュートリアル

5.16.15.7 Calling variadic functions
....................................

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 platforms, and in particular ARM64 for Apple Platforms, the
calling convention for variadic functions is different than that for
regular functions.

On those platforms it is required to specify the *note argtypes: 2f3a.
attribute for the regular, non-variadic, function arguments:

     libc.printf.argtypes = [ctypes.c_char_p]

Because specifying the attribute does not inhibit portability it is
advised to always specify *note argtypes: 2f3a. for all variadic
functions.


File: python.info,  Node: 自作のデータ型とともに関数を呼び出す,  Next: 要求される引数の型を指定する 関数プロトタイプ,  Prev: Calling variadic functions,  Up: ctypes チュートリアル

5.16.15.8 自作のデータ型とともに関数を呼び出す
..............................................

You can also customize *note ctypes: 22. argument conversion to allow
instances of your own classes be used as function arguments.  *note
ctypes: 22. looks for an ‘_as_parameter_’ attribute and uses this as the
function argument.  The attribute must be an integer, string, bytes, a
*note ctypes: 22. instance, or an object with an ‘_as_parameter_’
attribute:

     >>> class Bottles:
     ...     def __init__(self, number):
     ...         self._as_parameter_ = number
     ...
     >>> bottles = Bottles(42)
     >>> printf(b"%d bottles of beer\n", bottles)
     42 bottles of beer
     19
     >>>

If you don't want to store the instance's data in the ‘_as_parameter_’
instance variable, you could define a *note property: 179. which makes
the attribute available on request.


File: python.info,  Node: 要求される引数の型を指定する 関数プロトタイプ,  Next: 戻り値の型,  Prev: 自作のデータ型とともに関数を呼び出す,  Up: ctypes チュートリアル

5.16.15.9 要求される引数の型を指定する (関数プロトタイプ)
.........................................................

It is possible to specify the required argument types of functions
exported from DLLs by setting the *note argtypes: 2f3a. attribute.

*note argtypes: 2f3a. must be a sequence of C data types (the ‘printf()’
function is probably not a good example here, because it takes a
variable number and different types of parameters depending on the
format string, on the other hand this is quite handy to experiment with
this feature):

     >>> printf.argtypes = [c_char_p, c_char_p, c_int, c_double]
     >>> printf(b"String '%s', Int %d, Double %f\n", b"Hi", 10, 2.2)
     String 'Hi', Int 10, Double 2.200000
     37
     >>>

(C の関数のプロトタイプのように) 書式を指定すると互換性のない引数型にな
るのを防ぎ、引数を有効な型へ変換しようとします。:

     >>> printf(b"%d %d %d", 1, 2, 3)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ctypes.ArgumentError: argument 2: TypeError: 'int' object cannot be interpreted as ctypes.c_char_p
     >>> printf(b"%s %d %f\n", b"X", 2, 3)
     X 2 3.000000
     13
     >>>

If you have defined your own classes which you pass to function calls,
you have to implement a *note from_param(): 2f3f. class method for them
to be able to use them in the *note argtypes: 2f3a. sequence.  The *note
from_param(): 2f3f. class method receives the Python object passed to
the function call, it should do a typecheck or whatever is needed to
make sure this object is acceptable, and then return the object itself,
its ‘_as_parameter_’ attribute, or whatever you want to pass as the C
function argument in this case.  Again, the result should be an integer,
string, bytes, a *note ctypes: 22. instance, or an object with an
‘_as_parameter_’ attribute.


File: python.info,  Node: 戻り値の型,  Next: ポインタを渡す または、パラメータの参照渡し,  Prev: 要求される引数の型を指定する 関数プロトタイプ,  Up: ctypes チュートリアル

5.16.15.10 戻り値の型
.....................

By default functions are assumed to return the C int type.  Other return
types can be specified by setting the *note restype: 2f42. attribute of
the function object.

The C prototype of ‘time()’ is ‘time_t time(time_t *)’.  Because
‘time_t’ might be of a different type than the default return type int,
you should specify the ‘restype’ attribute:

     >>> libc.time.restype = c_time_t

The argument types can be specified using *note argtypes: 2f3a.:

     >>> libc.time.argtypes = (POINTER(c_time_t),)

To call the function with a ‘NULL’ pointer as first argument, use
‘None’:

     >>> print(libc.time(None))
     1150640792

Here is a more advanced example, it uses the ‘strchr()’ function, which
expects a string pointer and a char, and returns a pointer to a string:

     >>> strchr = libc.strchr
     >>> strchr(b"abcdef", ord("d"))
     8059983
     >>> strchr.restype = c_char_p    # c_char_p is a pointer to a string
     >>> strchr(b"abcdef", ord("d"))
     b'def'
     >>> print(strchr(b"abcdef", ord("x")))
     None
     >>>

If you want to avoid the *note ord("x"): 1e51. calls above, you can set
the *note argtypes: 2f3a. attribute, and the second argument will be
converted from a single character Python bytes object into a C char:

     >>> strchr.restype = c_char_p
     >>> strchr.argtypes = [c_char_p, c_char]
     >>> strchr(b"abcdef", b"d")
     b'def'
     >>> strchr(b"abcdef", b"def")
     Traceback (most recent call last):
     ctypes.ArgumentError: argument 2: TypeError: one character bytes, bytearray or integer expected
     >>> print(strchr(b"abcdef", b"x"))
     None
     >>> strchr(b"abcdef", b"d")
     b'def'
     >>>

You can also use a callable Python object (a function or a class for
example) as the *note restype: 2f42. attribute, if the foreign function
returns an integer.  The callable will be called with the 'integer' the
C function returns, and the result of this call will be used as the
result of your function call.  This is useful to check for error return
values and automatically raise an exception:

     >>> GetModuleHandle = windll.kernel32.GetModuleHandleA
     >>> def ValidHandle(value):
     ...     if value == 0:
     ...         raise WinError()
     ...     return value
     ...
     >>>
     >>> GetModuleHandle.restype = ValidHandle
     >>> GetModuleHandle(None)
     486539264
     >>> GetModuleHandle("something silly")
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 3, in ValidHandle
     OSError: [Errno 126] The specified module could not be found.
     >>>

‘WinError’ はエラーコードの文字列表現を得るために Windows の
‘FormatMessage()’ api を呼び出し、例外を '返す' 関数です。 ‘WinError’ は
オプションでエラーコードパラメータを取ります。このパラメータが使われない
場合は、エラーコードを取り出すために *note GetLastError(): 2f43. を呼び
出します。

Please note that a much more powerful error checking mechanism is
available through the *note errcheck: 2f44. attribute; see the reference
manual for details.


File: python.info,  Node: ポインタを渡す または、パラメータの参照渡し,  Next: 構造体と共用体,  Prev: 戻り値の型,  Up: ctypes チュートリアル

5.16.15.11 ポインタを渡す(または、パラメータの参照渡し)
.......................................................

時には、 C api 関数がパラメータのデータ型として 'ポインタ' を想定してい
ることがあります。おそらくパラメータと同一の場所に書き込むためか、もしく
はそのデータが大きすぎて値渡しできない場合です。これは 'パラメータの参照
渡し' としても知られています。

*note ctypes: 22. は *note byref(): 2f47. 関数をエクスポートしており、パ
ラメータを参照渡しするために使用します。 *note pointer(): 164a. 関数を使
っても同じ効果が得られます。しかし、 *note pointer(): 164a. は本当のポイ
ンタオブジェクトを構築するためより多くの処理を行うことから、 Python 側で
ポインタオブジェクト自体を必要としないならば *note byref(): 2f47. を使う
方がより高速です。:

     >>> i = c_int()
     >>> f = c_float()
     >>> s = create_string_buffer(b'\000' * 32)
     >>> print(i.value, f.value, repr(s.value))
     0 0.0 b''
     >>> libc.sscanf(b"1 3.14 Hello", b"%d %f %s",
     ...             byref(i), byref(f), s)
     3
     >>> print(i.value, f.value, repr(s.value))
     1 3.1400001049 b'Hello'
     >>>


File: python.info,  Node: 構造体と共用体,  Next: 構造体/共用体アライメントとバイトオーダー,  Prev: ポインタを渡す または、パラメータの参照渡し,  Up: ctypes チュートリアル

5.16.15.12 構造体と共用体
.........................

Structures and unions must derive from the *note Structure: 1b6. and
*note Union: 15e5. base classes which are defined in the *note ctypes:
22. module.  Each subclass must define a *note _fields_: 2f4a.
attribute.  ‘_fields_’ must be a list of '2-tuples', containing a 'field
name' and a 'field type'.

フィールド型は *note c_int: 2f1f. か他の *note ctypes: 22. 型 (構造体、
共用体、配列、ポインタ) から派生した *note ctypes: 22. 型である必要があ
ります。

以下は、 'x' と 'y' という名前の二つの整数からなる簡単な POINT 構造体の
例です。コンストラクタで構造体を初期化する方法も説明しています:

     >>> from ctypes import *
     >>> class POINT(Structure):
     ...     _fields_ = [("x", c_int),
     ...                 ("y", c_int)]
     ...
     >>> point = POINT(10, 20)
     >>> print(point.x, point.y)
     10 20
     >>> point = POINT(y=5)
     >>> print(point.x, point.y)
     0 5
     >>> POINT(1, 2, 3)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: too many initializers
     >>>

しかし、もっと複雑な構造体を構築することもできます。ある構造体は、他の構
造体をフィールド型として使うことで、他の構造体を含むことができます。

'upperleft' と 'lowerright' という名前の二つの POINT を持つ RECT 構造体
です。:

     >>> class RECT(Structure):
     ...     _fields_ = [("upperleft", POINT),
     ...                 ("lowerright", POINT)]
     ...
     >>> rc = RECT(point)
     >>> print(rc.upperleft.x, rc.upperleft.y)
     0 5
     >>> print(rc.lowerright.x, rc.lowerright.y)
     0 0
     >>>

入れ子になった構造体はいくつかの方法を用いてコンストラクタで初期化するこ
とができます。:

     >>> r = RECT(POINT(1, 2), POINT(3, 4))
     >>> r = RECT((1, 2), (3, 4))

フィールド *note descriptor: 1ed1. (記述子)は 'クラス' から取り出せます
。デバッグするときに役に立つ情報を得ることができます:

     >>> print(POINT.x)
     <Field type=c_long, ofs=0, size=4>
     >>> print(POINT.y)
     <Field type=c_long, ofs=4, size=4>
     >>>
     警告: *note ctypes: 22. では、ビットフィールドのある共用体や構造体
     の関数への値渡しはサポートしていません。これは 32-bit の x86 環境で
     は動くかもしれませんが、このライブラリでは一般の場合に動作すること
     は保証していません。


File: python.info,  Node: 構造体/共用体アライメントとバイトオーダー,  Next: 構造体と共用体におけるビットフィールド,  Prev: 構造体と共用体,  Up: ctypes チュートリアル

5.16.15.13 構造体/共用体アライメントとバイトオーダー
....................................................

By default, Structure and Union fields are aligned in the same way the C
compiler does it.  It is possible to override this behavior by
specifying a *note _pack_: 2f4d. class attribute in the subclass
definition.  This must be set to a positive integer and specifies the
maximum alignment for the fields.  This is what ‘#pragma pack(n)’ also
does in MSVC. It is also possible to set a minimum alignment for how the
subclass itself is packed in the same way ‘#pragma align(n)’ works in
MSVC. This can be achieved by specifying a :*note _align_: 1b7. class
attribute in the subclass definition.

*note ctypes: 22. は Structure と Union に対してネイティブのバイトオーダ
ーを使います。ネイティブではないバイトオーダーの構造体を作成するには、
*note BigEndianStructure: 2f4e, *note LittleEndianStructure: 2f4f, *note
BigEndianUnion: 1791. および *note LittleEndianUnion: 1792. ベースクラス
の中の一つを使います。これらのクラスにポインタフィールドを持たせることは
できません。


File: python.info,  Node: 構造体と共用体におけるビットフィールド,  Next: 配列,  Prev: 構造体/共用体アライメントとバイトオーダー,  Up: ctypes チュートリアル

5.16.15.14 構造体と共用体におけるビットフィールド
.................................................

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 *note _fields_: 2f4a. tuples:

     >>> class Int(Structure):
     ...     _fields_ = [("first_16", c_int, 16),
     ...                 ("second_16", c_int, 16)]
     ...
     >>> print(Int.first_16)
     <Field type=c_long, ofs=0:0, bits=16>
     >>> print(Int.second_16)
     <Field type=c_long, ofs=0:16, bits=16>
     >>>


File: python.info,  Node: 配列,  Next: ポインタ,  Prev: 構造体と共用体におけるビットフィールド,  Up: ctypes チュートリアル

5.16.15.15 配列
...............

配列 (Array) はシーケンスであり、決まった数の同じ型のインスタンスを持ち
ます。

推奨されている配列の作成方法はデータ型に正の整数を掛けることです。:

     TenPointsArrayType = POINT * 10

ややわざとらしいデータ型の例になりますが、他のものに混ざって 4 個の
POINT がある構造体です:

     >>> from ctypes import *
     >>> class POINT(Structure):
     ...     _fields_ = ("x", c_int), ("y", c_int)
     ...
     >>> class MyStruct(Structure):
     ...     _fields_ = [("a", c_int),
     ...                 ("b", c_float),
     ...                 ("point_array", POINT * 4)]
     >>>
     >>> print(len(MyStruct().point_array))
     4
     >>>

インスタンスはクラスを呼び出す通常の方法で作成します。:

     arr = TenPointsArrayType()
     for pt in arr:
         print(pt.x, pt.y)

上記のコードは ‘0 0’ という行が並んだものを表示します。配列の要素がゼロ
で初期化されているためです。

正しい型の初期化子を指定することもできます。:

     >>> from ctypes import *
     >>> TenIntegers = c_int * 10
     >>> ii = TenIntegers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     >>> print(ii)
     <c_long_Array_10 object at 0x...>
     >>> for i in ii: print(i, end=" ")
     ...
     1 2 3 4 5 6 7 8 9 10
     >>>


File: python.info,  Node: ポインタ,  Next: 型変換,  Prev: 配列,  Up: ctypes チュートリアル

5.16.15.16 ポインタ
...................

ポインタのインスタンスは *note ctypes: 22. 型に対して *note pointer():
164a. 関数を呼び出して作成します。:

     >>> from ctypes import *
     >>> i = c_int(42)
     >>> pi = pointer(i)
     >>>

次のように、ポインタインスタンスは、ポインタが指すオブジェクト (上の例で
は ‘i’) を返す *note contents: 2f56. 属性を持ちます:

     >>> pi.contents
     c_long(42)
     >>>

*note ctypes: 22. は OOR (original object return 、元のオブジェクトを返
すこと) ではないことに注意してください。属性を取り出す度に、新しい同等の
オブジェクトを作成しているのです。:

     >>> pi.contents is i
     False
     >>> pi.contents is pi.contents
     False
     >>>

別の *note c_int: 2f1f. インスタンスがポインタの contents 属性に代入され
ると、これが記憶されているメモリ位置を指すポインタに変化します。:

     >>> i = c_int(99)
     >>> pi.contents = i
     >>> pi.contents
     c_long(99)
     >>>

ポインタインスタンスは整数でインデックス指定することもできます。:

     >>> pi[0]
     99
     >>>

整数インデックスへ代入するとポインタが指す値が変更されます。:

     >>> print(i)
     c_long(99)
     >>> pi[0] = 22
     >>> print(i)
     c_long(22)
     >>>

0 ではないインデックスを使うこともできますが、 C の場合と同じように自分
が何をしているかを理解している必要があります。任意のメモリ位置にアクセス
もしくは変更できるのです。一般的にこの機能を使うのは、 C 関数からポイン
タを受け取り、そのポインタが単一の要素ではなく実際に配列を指していると
'分かっている' 場合だけです。

舞台裏では、 *note pointer(): 164a. 関数は単にポインタインスタンスを作成
するという以上のことを行っています。はじめにポインタ '型' を作成する必要
があります。これは任意の *note ctypes: 22. 型を受け取る *note POINTER():
164b. 関数を使って行われ、新しい型を返します:

     >>> PI = POINTER(c_int)
     >>> PI
     <class 'ctypes.LP_c_long'>
     >>> PI(42)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: expected c_long instead of int
     >>> PI(c_int(42))
     <ctypes.LP_c_long object at 0x...>
     >>>

ポインタ型を引数なしで呼び出すと ‘NULL’ ポインタを作成します。 ‘NULL’ ポ
インタは ‘False’ ブール値を持っています。:

     >>> null_ptr = POINTER(c_int)()
     >>> print(bool(null_ptr))
     False
     >>>

*note ctypes: 22. はポインタの指す値を取り出すときに ‘NULL’ かどうかを調
べます(しかし、 ‘NULL’ でない不正なポインタの指す値の取り出す行為は
Python をクラッシュさせるでしょう)。:

     >>> null_ptr[0]
     Traceback (most recent call last):
         ....
     ValueError: NULL pointer access
     >>>

     >>> null_ptr[0] = 1234
     Traceback (most recent call last):
         ....
     ValueError: NULL pointer access
     >>>


File: python.info,  Node: 型変換,  Next: 不完全型,  Prev: ポインタ,  Up: ctypes チュートリアル

5.16.15.17 型変換
.................

Usually, ctypes does strict type checking.  This means, if you have
‘POINTER(c_int)’ in the *note argtypes: 2f3a. list of a function or as
the type of a member field in a structure definition, only instances of
exactly the same type are accepted.  There are some exceptions to this
rule, where ctypes accepts other objects.  For example, you can pass
compatible array instances instead of pointer types.  So, for
‘POINTER(c_int)’, ctypes accepts an array of c_int:

     >>> class Bar(Structure):
     ...     _fields_ = [("count", c_int), ("values", POINTER(c_int))]
     ...
     >>> bar = Bar()
     >>> bar.values = (c_int * 3)(1, 2, 3)
     >>> bar.count = 3
     >>> for i in range(bar.count):
     ...     print(bar.values[i])
     ...
     1
     2
     3
     >>>

In addition, if a function argument is explicitly declared to be a
pointer type (such as ‘POINTER(c_int)’) in *note argtypes: 2f3a, an
object of the pointed type (‘c_int’ in this case) can be passed to the
function.  ctypes will apply the required *note byref(): 2f47.
conversion in this case automatically.

POINTER型フィールドを ‘NULL’ に設定するために、 ‘None’ を代入してもかま
いません。:

     >>> bar.values = None
     >>>

時には、非互換な型のインスタンスであることもあります。 C では、ある型を
他の型へキャストすることができます。 *note ctypes: 22. は同じやり方で使
える *note cast(): 2f59. 関数を提供しています。上で定義した ‘Bar’ 構造体
は ‘POINTER(c_int)’ ポインタまたは *note c_int: 2f1f. 配列を ‘values’ フ
ィールドに対して受け取り、他の型のインスタンスは受け取りません:

     >>> bar.values = (c_byte * 4)()
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: incompatible types, c_byte_Array_4 instance instead of LP_c_long instance
     >>>

このような場合には、 *note cast(): 2f59. 関数が便利です。

*note cast(): 2f59. 関数は ctypes インスタンスを異なる ctypes データ型を
指すポインタへキャストするために使えます。 *note cast(): 2f59. は二つの
パラメータ、ある種のポインタかそのポインタへ変換できる ctypes オブジェク
トと、 ctypes ポインタ型を取ります。そして、第二引数のインスタンスを返し
ます。このインスタンスは第一引数と同じメモリブロックを参照しています:

     >>> a = (c_byte * 4)()
     >>> cast(a, POINTER(c_int))
     <ctypes.LP_c_long object at ...>
     >>>

したがって、 *note cast(): 2f59. を ‘Bar’ 構造体の ‘values’ フィールドへ
代入するために使うことができます:

     >>> bar = Bar()
     >>> bar.values = cast((c_byte * 4)(), POINTER(c_int))
     >>> print(bar.values[0])
     0
     >>>


File: python.info,  Node: 不完全型,  Next: コールバック関数,  Prev: 型変換,  Up: ctypes チュートリアル

5.16.15.18 不完全型
...................

'不完全型' はメンバーがまだ指定されていない構造体、共用体もしくは配列で
す。 C では、前方宣言により指定され、後で定義されます。:

     struct cell; /* forward declaration */

     struct cell {
         char *name;
         struct cell *next;
     };

ctypes コードへの直接的な変換ではこうなるでしょう。しかし、動作しません:

     >>> class cell(Structure):
     ...     _fields_ = [("name", c_char_p),
     ...                 ("next", POINTER(cell))]
     ...
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 2, in cell
     NameError: name 'cell' is not defined
     >>>

because the new ‘class cell’ is not available in the class statement
itself.  In *note ctypes: 22, we can define the ‘cell’ class and set the
*note _fields_: 2f4a. attribute later, after the class statement:

     >>> from ctypes import *
     >>> class cell(Structure):
     ...     pass
     ...
     >>> cell._fields_ = [("name", c_char_p),
     ...                  ("next", POINTER(cell))]
     >>>

試してみましょう。 ‘cell’ のインスタンスを二つ作り、互いに参照し合うよう
にします。最後に、つながったポインタを何度かたどります。:

     >>> c1 = cell()
     >>> c1.name = b"foo"
     >>> c2 = cell()
     >>> c2.name = b"bar"
     >>> c1.next = pointer(c2)
     >>> c2.next = pointer(c1)
     >>> p = c1
     >>> for i in range(8):
     ...     print(p.name, end=" ")
     ...     p = p.next[0]
     ...
     foo bar foo bar foo bar foo bar
     >>>


File: python.info,  Node: コールバック関数,  Next: dllからエクスポートされた値へアクセスする,  Prev: 不完全型,  Up: ctypes チュートリアル

5.16.15.19 コールバック関数
...........................

*note ctypes: 22. は C の呼び出し可能な関数ポインタを Python 呼び出し可
能オブジェクトから作成できるようにします。これらは 'コールバック関数' と
呼ばれることがあります。

最初に、コールバック関数のためのクラスを作る必要があります。そのクラスに
は呼び出し規約、戻り値の型およびこの関数が受け取る引数の数と型についての
情報があります。

*note CFUNCTYPE(): 2f5e. ファクトリ関数は通常の ‘cdecl’ 呼び出し規約を用
いてコールバック関数のための型を作成します。 Windows では、 *note
WINFUNCTYPE(): 2f5f. ファクトリ関数が ‘stdcall’ 呼び出し規約を用いてコー
ルバック関数の型を作成します。

これらのファクトリ関数はともに最初の引数に戻り値の型、残りの引数としてコ
ールバック関数が想定する引数の型を渡して呼び出されます。

I will present an example here which uses the standard C library's
‘qsort()’ function, that is used to sort items with the help of a
callback function.  ‘qsort()’ will be used to sort an array of integers:

     >>> IntArray5 = c_int * 5
     >>> ia = IntArray5(5, 1, 7, 33, 99)
     >>> qsort = libc.qsort
     >>> qsort.restype = None
     >>>

‘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
comparison function, the callback.  The callback will then be called
with two pointers to items, and it must return a negative integer if the
first item is smaller than the second, a zero if they are equal, and a
positive integer otherwise.

コールバック関数は整数へのポインタを受け取り、整数を返す必要があります。
まず、コールバック関数のための ‘type’ を作成します。:

     >>> CMPFUNC = CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
     >>>

まず初めに、これが受け取った変数を表示するだけのシンプルなコールバックで
す:

     >>> def py_cmp_func(a, b):
     ...     print("py_cmp_func", a[0], b[0])
     ...     return 0
     ...
     >>> cmp_func = CMPFUNC(py_cmp_func)
     >>>

結果は以下の通りです:

     >>> qsort(ia, len(ia), sizeof(c_int), cmp_func)
     py_cmp_func 5 1
     py_cmp_func 33 99
     py_cmp_func 7 33
     py_cmp_func 5 7
     py_cmp_func 1 7
     >>>

ここで 2 つの要素を実際に比較し、役に立つ結果を返します:

     >>> def py_cmp_func(a, b):
     ...     print("py_cmp_func", a[0], b[0])
     ...     return a[0] - b[0]
     ...
     >>>
     >>> qsort(ia, len(ia), sizeof(c_int), CMPFUNC(py_cmp_func))
     py_cmp_func 5 1
     py_cmp_func 33 99
     py_cmp_func 7 33
     py_cmp_func 1 7
     py_cmp_func 5 7
     >>>

簡単に確認できるように、配列を次のようにソートしました:

     >>> for i in ia: print(i, end=" ")
     ...
     1 5 7 33 99
     >>>

関数ファクトリはデコレータファクトリとしても使えるので、次のようにも書け
ます:

     >>> @CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
     ... def py_cmp_func(a, b):
     ...     print("py_cmp_func", a[0], b[0])
     ...     return a[0] - b[0]
     ...
     >>> qsort(ia, len(ia), sizeof(c_int), py_cmp_func)
     py_cmp_func 5 1
     py_cmp_func 33 99
     py_cmp_func 7 33
     py_cmp_func 1 7
     py_cmp_func 5 7
     >>>

     注釈: C コードから *note CFUNCTYPE(): 2f5e. オブジェクトが使用され
     る限り、そのオブジェクトへの参照を確実に保持してください。 *note
     ctypes: 22. は参照を保持しないため、あなたが参照を保持しないと、オ
     ブジェクトはガベージコレクションの対象となり、コールバックが行われ
     たときにプログラムをクラッシュさせる場合があります。

     同様に、コールバック関数が Python の管理外 (例えば、コールバックを
     呼び出す外部のコード) で作られたスレッドで呼び出された場合、 ctypes
     は全ての呼び出しごとに新しいダミーの Python スレッドを作成すること
     に注意してください。 この動作はほとんどの目的に対して正しいものです
     が、同じ C スレッドからの呼び出しだったとしても、 *note
     threading.local: 16d6. で格納された値は異なるコールバックをまたいで
     生存は 'しません' 。


File: python.info,  Node: dllからエクスポートされた値へアクセスする,  Next: びっくり仰天,  Prev: コールバック関数,  Up: ctypes チュートリアル

5.16.15.20 dllからエクスポートされた値へアクセスする
....................................................

Some shared libraries not only export functions, they also export
variables.  An example in the Python library itself is the *note
Py_Version: 721, Python runtime version number encoded in a single
constant integer.

*note ctypes: 22. can access values like this with the *note in_dll():
2f62. class methods of the type.  'pythonapi' is a predefined symbol
giving access to the Python C api:

     >>> version = ctypes.c_int.in_dll(ctypes.pythonapi, "Py_Version")
     >>> print(hex(version.value))
     0x30c00a0

ポインタの使い方を説明する拡張例では、 Python がエクスポートする *note
PyImport_FrozenModules: 2f63. ポインタにアクセスします。

この値のドキュメントから引用すると:

     このポインタは *note _frozen: 740. のレコードからなり、終端の要素の
     メンバが ‘NULL’ かゼロになっているような配列を指すよう初期化されま
     す。 フリーズされたモジュールをインポートするとき、このテーブルを検
     索します。 サードパーティ製のコードからこのポインタに仕掛けを講じて
     、動的に生成されたフリーズ化モジュールの集合を提供するようにできま
     す。

これで、このポインタを操作することが役に立つことを証明できるでしょう。例
の大きさを制限するために、このテーブルを *note ctypes: 22. を使って読む
方法だけを示します。:

     >>> from ctypes import *
     >>>
     >>> class struct_frozen(Structure):
     ...     _fields_ = [("name", c_char_p),
     ...                 ("code", POINTER(c_ubyte)),
     ...                 ("size", c_int),
     ...                 ("get_code", POINTER(c_ubyte)),  # Function pointer
     ...                ]
     ...
     >>>

私たちは *note _frozen: 740. データ型を定義済みなので、このテーブルを指
すポインタを得ることができます。:

     >>> FrozenTable = POINTER(struct_frozen)
     >>> table = FrozenTable.in_dll(pythonapi, "_PyImport_FrozenBootstrap")
     >>>

‘table’ が ‘struct_frozen’ レコードの配列への ‘pointer’ なので、その配列
に対して反復処理を行えます。しかし、ループが確実に終了するようにする必要
があります。なぜなら、ポインタに大きさの情報がないからです。遅かれ早かれ
、アクセス違反か何かでクラッシュすることになるでしょう。 ‘NULL’ エントリ
に達したときはループを抜ける方が良いです:

     >>> for item in table:
     ...     if item.name is None:
     ...         break
     ...     print(item.name.decode("ascii"), item.size)
     ...
     _frozen_importlib 31764
     _frozen_importlib_external 41499
     zipimport 12345
     >>>

標準 Python はフローズンモジュールとフローズンパッケージ (負の ‘size’ メ
ンバーで表されています) を持っているという事実はあまり知られておらず、テ
ストにだけ使われています。例えば、 ‘import __hello__’ を試してみてくださ
い。


File: python.info,  Node: びっくり仰天,  Next: 可変サイズのデータ型,  Prev: dllからエクスポートされた値へアクセスする,  Up: ctypes チュートリアル

5.16.15.21 びっくり仰天
.......................

There are some edges in *note ctypes: 22. where you might expect
something other than what actually happens.

次に示す例について考えてみてください。:

     >>> from ctypes import *
     >>> class POINT(Structure):
     ...     _fields_ = ("x", c_int), ("y", c_int)
     ...
     >>> class RECT(Structure):
     ...     _fields_ = ("a", POINT), ("b", POINT)
     ...
     >>> p1 = POINT(1, 2)
     >>> p2 = POINT(3, 4)
     >>> rc = RECT(p1, p2)
     >>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)
     1 2 3 4
     >>> # now swap the two points
     >>> rc.a, rc.b = rc.b, rc.a
     >>> print(rc.a.x, rc.a.y, rc.b.x, rc.b.y)
     3 4 3 4
     >>>

うーん、最後の文に ‘3 4 1 2’ と表示されることを期待していたはずです。何
が起きたのでしょうか?  上の行の ‘rc.a, rc.b = rc.b, rc.a’ の各段階はこの
ようになります。:

     >>> temp0, temp1 = rc.b, rc.a
     >>> rc.a = temp0
     >>> rc.b = temp1
     >>>

‘temp0’ と ‘temp1’ は前記の ‘rc’ オブジェクトの内部バッファでまだ使われ
ているオブジェクトです。したがって、 ‘rc.a = temp0’ を実行すると ‘temp0’
のバッファ内容が ‘rc’ のバッファへコピーされます。さらに、これは ‘temp1’
の内容を変更します。そのため、最後の代入 ‘rc.b = temp1’ は、期待する結果
にはならないのです。

Structure 、 Union および Array のサブオブジェクトを取り出しても、そのサ
ブオブジェクトが 'コピー' されるわけではなく、ルートオブジェクトの内部バ
ッファにアクセスするラッパーオブジェクトを取り出すことを覚えておいてくだ
さい。

期待とは違う振る舞いをする別の例はこれです:

     >>> s = c_char_p()
     >>> s.value = b"abc def ghi"
     >>> s.value
     b'abc def ghi'
     >>> s.value is s.value
     False
     >>>

     注釈: *note c_char_p: 164c. からインスタンス化されたオブジェクトは
     、bytes または整数に設定された値しか持てません。

なぜ ‘False’ と表示されるのでしょうか?  ctypes インスタンスはメモリと、
メモリの内容にアクセスするいくつかの *note descriptor: 1ed1. (記述子)を
含むオブジェクトです。メモリブロックに Python オブジェクトを保存してもオ
ブジェクト自身が保存される訳ではなく、オブジェクトの ‘contents’ が保存さ
れます。その contents に再アクセスすると新しい Python オブジェクトがその
度に作られます。


File: python.info,  Node: 可変サイズのデータ型,  Prev: びっくり仰天,  Up: ctypes チュートリアル

5.16.15.22 可変サイズのデータ型
...............................

*note ctypes: 22. は可変サイズの配列と構造体をサポートしています。

*note resize(): 2f68. 関数は既存の ctypes オブジェクトのメモリバッファの
サイズを変更したい場合に使えます。この関数は第一引数にオブジェクト、第二
引数に要求されたサイズをバイト単位で指定します。メモリブロックはオブジェ
クト型で指定される通常のメモリブロックより小さくすることはできません。こ
れをやろうとすると、 *note ValueError: 1e3. が送出されます。:

     >>> short_array = (c_short * 4)()
     >>> print(sizeof(short_array))
     8
     >>> resize(short_array, 4)
     Traceback (most recent call last):
         ...
     ValueError: minimum size is 8
     >>> resize(short_array, 32)
     >>> sizeof(short_array)
     32
     >>> sizeof(type(short_array))
     8
     >>>

これはこれで上手くいっていますが、この配列の追加した要素へどうやってアク
セスするのでしょうか?  この型は要素の数が 4 個であるとまだ認識しているの
で、他の要素にアクセスするとエラーになります。:

     >>> short_array[:]
     [0, 0, 0, 0]
     >>> short_array[7]
     Traceback (most recent call last):
         ...
     IndexError: invalid index
     >>>

*note ctypes: 22. で可変サイズのデータ型を使うもう一つの方法は、必要なサ
イズが分かった後に Python の動的性質を使って一つ一つデータ型を(再)定義す
ることです。


File: python.info,  Node: ctypesリファレンス,  Prev: ctypes チュートリアル,  Up: ctypes --- Python 用の外部関数ライブラリ

5.16.15.23 ctypesリファレンス
.............................

* Menu:

* 共有ライブラリを見つける::
* 共有ライブラリをロードする::
* 外部関数::
* 関数プロトタイプ::
* ユーティリティー関数::
* データ型: データ型<3>.
* 基本データ型: 基本データ型<2>.
* 構造化データ型::
* 配列とポインタ::


File: python.info,  Node: 共有ライブラリを見つける,  Next: 共有ライブラリをロードする,  Up: ctypesリファレンス

5.16.15.24 共有ライブラリを見つける
...................................

コンパイルされる言語でプログラミングしている場合、共有ライブラリはプログ
ラムをコンパイル/リンクしているときと、そのプログラムが動作しているとき
にアクセスされます。

The purpose of the *note find_library(): d17. function is to locate a
library in a way similar to what the compiler or runtime loader does (on
platforms with several versions of a shared library the most recent
should be loaded), while the ctypes library loaders act like when a
program is run, and call the runtime loader directly.

The ‘ctypes.util’ module provides a function which can help to determine
the library to load.

 -- データ: ctypes.util.find_library (name)

     ライブラリを見つけてパス名を返そうと試みます。 'name' は ‘lib’ のよ
     うな接頭辞、 ‘.so’, ‘.dylib’ のような接尾辞、あるいは、バージョン番
     号が何も付いていないライブラリの名前です (これは posix リンカのオプ
     ション ‘-l’ に使われている形式です)。 ライブラリが見つからないとき
     は ‘None’ を返します。

厳密な機能はシステムに依存します。

On Linux, *note find_library(): d17. tries to run external programs
(‘/sbin/ldconfig’, ‘gcc’, ‘objdump’ and ‘ld’) to find the library file.
It returns the filename of the library file.

バージョン 3.6 で変更: Linux では、ライブラリを検索する際に、他の方法で
ライブラリが見つけられない場合は、 ‘LD_LIBRARY_PATH’ 環境変数の値が使わ
れます

ここに例があります:

     >>> from ctypes.util import find_library
     >>> find_library("m")
     'libm.so.6'
     >>> find_library("c")
     'libc.so.6'
     >>> find_library("bz2")
     'libbz2.so.1.0'
     >>>

On macOS and Android, *note find_library(): d17. uses the system's
standard naming schemes and paths to locate the library, and returns a
full pathname if successful:

     >>> from ctypes.util import find_library
     >>> find_library("c")
     '/usr/lib/libc.dylib'
     >>> find_library("m")
     '/usr/lib/libm.dylib'
     >>> find_library("bz2")
     '/usr/lib/libbz2.dylib'
     >>> find_library("AGL")
     '/System/Library/Frameworks/AGL.framework/AGL'
     >>>

On Windows, *note find_library(): d17. 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’.

If wrapping a shared library with *note ctypes: 22, it 'may' be better
to determine the shared library name at development time, and hardcode
that into the wrapper module instead of using *note find_library(): d17.
to locate the library at runtime.


File: python.info,  Node: 共有ライブラリをロードする,  Next: 外部関数,  Prev: 共有ライブラリを見つける,  Up: ctypesリファレンス

5.16.15.25 共有ライブラリをロードする
.....................................

共有ライブラリを Python プロセスへロードする方法はいくつかあります。一つ
の方法は下記のクラスの一つをインスタンス化することです:

 -- クラス: ctypes.CDLL (name, mode=DEFAULT_MODE, handle=None,
          use_errno=False, use_last_error=False, winmode=None)

     このクラスのインスタンスはロードされた共有ライブラリをあらわします
     。これらのライブラリの関数は標準 C 呼び出し規約を使用し、 int を返
     すと仮定されます。

     On Windows creating a *note CDLL: 9b7. instance may fail even if
     the DLL name exists.  When a dependent DLL of the loaded DLL is not
     found, a *note OSError: 3f0. error is raised with the message
     '"[WinError 126] The specified module could not be found".'  This
     error message does not contain the name of the missing DLL because
     the Windows API does not return this information making this error
     hard to diagnose.  To resolve this error and determine 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.

     バージョン 3.12 で変更: The 'name' parameter can now be a *note
     path-like object: 280.

参考
....

Microsoft DUMPBIN tool(1) - A tool to find DLL dependents.

 -- クラス: ctypes.OleDLL (name, mode=DEFAULT_MODE, handle=None,
          use_errno=False, use_last_error=False, winmode=None)

     Windows 用: このクラスのインスタンスはロードされた共有ライブラリを
     あらわします。これらのライブラリの関数は ‘stdcall’ 呼び出し規約を使
     用し、 windows 固有の *note HRESULT: 2f6f. コードを返すと仮定されま
     す。 *note HRESULT: 2f6f. 値には関数呼び出しが失敗したのか成功した
     のかを特定する情報とともに、補足のエラーコードが含まれます。戻り値
     が失敗を知らせたならば、 *note OSError: 3f0. が自動的に送出されます
     。

     バージョン 3.3 で変更: *note WindowsError: 1028. used to be raised,
     which is now an alias of *note OSError: 3f0.

     バージョン 3.12 で変更: The 'name' parameter can now be a *note
     path-like object: 280.

 -- クラス: ctypes.WinDLL (name, mode=DEFAULT_MODE, handle=None,
          use_errno=False, use_last_error=False, winmode=None)

     Windows 用: このクラスのインスタンスはロードされた共有ライブラリを
     あらわします。これらのライブラリの関数は ‘stdcall’ 呼び出し規約を使
     用し、デフォルトでは int を返すと仮定されます。

     バージョン 3.12 で変更: The 'name' parameter can now be a *note
     path-like object: 280.

これらのライブラリがエクスポートするどの関数でも呼び出す前に Python
*note global interpreter lock: 12e. は解放され、後でまた獲得されます。

 -- クラス: ctypes.PyDLL (name, mode=DEFAULT_MODE, handle=None)

     Python GIL が関数呼び出しの間解放 'されず' 、関数実行の後に Python
     エラーフラグがチェックされるということを除けば、このクラスのインス
     タンスは *note CDLL: 9b7. インスタンスのように振る舞います。エラー
     フラグがセットされた場合、 Python 例外が送出されます。

     要するに、これは Python C api 関数を直接呼び出すのに便利だというだ
     けです。

     バージョン 3.12 で変更: The 'name' parameter can now be a *note
     path-like object: 280.

All these classes can be instantiated by calling them with at least one
argument, the pathname of the shared library.  If you have an existing
handle to an already loaded shared library, it can be passed as the
‘handle’ named parameter, otherwise the underlying platform's ‘dlopen()’
or ‘LoadLibrary()’ function is used to load the library into the
process, and to get a handle to it.

'mode' パラメータを使うと、ライブラリがどうやってロードされたかを特定で
きます。 詳細は ‘dlopen(3)(2)’ マニュアルページを参考にしてください。
Windows では 'mode' は無視されます。 POSIX システムでは RTLD_NOW が常に
追加され、設定変更はできません。

The 'use_errno' parameter, when set to true, enables a ctypes mechanism
that allows accessing the system *note errno: 4d. error number in a safe
way.  *note ctypes: 22. maintains a thread-local copy of the system's
*note errno: 4d. variable; if you call foreign functions created with
‘use_errno=True’ then the *note errno: 4d. value before the function
call is swapped with the ctypes private copy, the same happens
immediately after the function call.

*note ctypes.get_errno(): 2f70. 関数は ctypes のプライベートコピーの値を
返します。そして、 *note ctypes.set_errno(): 2f71. 関数は ctypes のプラ
イベートコピーを置き換え、以前の値を返します。

The 'use_last_error' parameter, when set to true, enables the same
mechanism for the Windows error code which is managed by the *note
GetLastError(): 2f43. and ‘SetLastError()’ Windows API functions; *note
ctypes.get_last_error(): 2f72. and *note ctypes.set_last_error(): 2f73.
are used to request and change the ctypes private copy of the windows
error code.

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 Win32 API ‘LoadLibraryEx’ flags parameter.  When omitted, the
default is to use the flags that result in the most secure DLL load,
which avoids issues such as DLL hijacking.  Passing the full path to the
DLL is the safest way to ensure the correct library and dependencies are
loaded.

バージョン 3.8 で変更: 'winmode' 引数が追加されました。

 -- データ: ctypes.RTLD_GLOBAL

     'mode' パラメータとして使うフラグ。このフラグが利用できないプラット
     フォームでは、整数のゼロと定義されています。

 -- データ: ctypes.RTLD_LOCAL

     'mode' パラメータとして使うフラグ。これが利用できないプラットフォー
     ムでは、 'RTLD_GLOBAL' と同様です。

 -- データ: ctypes.DEFAULT_MODE

     共有ライブラリをロードするために使われるデフォルトモード。 OSX 10.3
     では 'RTLD_GLOBAL' であり、そうでなければ 'RTLD_LOCAL' と同じです。

これらのクラスのインスタンスには公開メソッドはありません。 共有ライブラ
リからエクスポートされた関数は、属性として、もしくは添字でアクセスできま
す。 属性を通した関数へのアクセスは結果がキャッシュされ、従って繰り返し
アクセスされると毎回同じオブジェクトを返すことに注意してください。 それ
とは反対に、添字を通したアクセスは毎回新しいオブジェクトを返します:

     >>> from ctypes import CDLL
     >>> libc = CDLL("libc.so.6")  # On Linux
     >>> libc.time == libc.time
     True
     >>> libc['time'] == libc['time']
     False

次に述べる公開属性が利用できます。それらの名前はエクスポートされた関数名
に衝突しないように下線で始まります。:

 -- の属性: PyDLL._handle

     ライブラリへのアクセスに用いられるシステムハンドル。

 -- の属性: PyDLL._name

     コンストラクタに渡されたライブラリの名前。

Shared libraries can also be loaded by using one of the prefabricated
objects, which are instances of the *note LibraryLoader: 2f76. class,
either by calling the *note LoadLibrary(): 2f23. method, or by
retrieving the library as attribute of the loader instance.

 -- クラス: ctypes.LibraryLoader (dlltype)

     共有ライブラリをロードするクラス。 'dlltype' は *note CDLL: 9b7. 、
     *note PyDLL: 16df. 、 *note WinDLL: 16de. もしくは *note OleDLL:
     16dd. 型の一つであるべきです。

     ‘__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.

      -- メソッド: LoadLibrary (name)

          共有ライブラリをプロセスへロードし、それを返します。このメソッ
          ドはライブラリの新しいインスタンスを常に返します。

これらの前もって作られたライブラリローダーを利用することができます。:

 -- データ: ctypes.cdll

     *note CDLL: 9b7. インスタンスを作ります。

 -- データ: ctypes.windll

     Windows 用: *note WinDLL: 16de. インスタンスを作ります。

 -- データ: ctypes.oledll

     Windows 用: *note OleDLL: 16dd. インスタンスを作ります。

 -- データ: ctypes.pydll

     *note PyDLL: 16df. インスタンスを作ります。

C Python api に直接アクセスするために、すぐに使用できる Python 共有ライ
ブラリオブジェクトが次のように用意されています。

 -- データ: ctypes.pythonapi

     An instance of *note PyDLL: 16df. that exposes Python C API
     functions as attributes.  Note that all these functions are assumed
     to return C int, which is of course not always the truth, so you
     have to assign the correct ‘restype’ attribute to use these
     functions.

Loading a library through any of these objects raises an *note auditing
event: 1825. ‘ctypes.dlopen’ with string argument ‘name’, the name used
to load the library.

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).

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’.

   ---------- Footnotes ----------

   (1) https://docs.microsoft.com/cpp/build/reference/dependents

   (2) https://manpages.debian.org/dlopen(3)


File: python.info,  Node: 外部関数,  Next: 関数プロトタイプ,  Prev: 共有ライブラリをロードする,  Up: ctypesリファレンス

5.16.15.26 外部関数
...................

As explained in the previous section, foreign functions can be accessed
as attributes of loaded shared libraries.  The function objects created
in this way by default accept any number of arguments, accept any ctypes
data instances as arguments, and return the default result type
specified by the library loader.

They are instances of a private local class ‘_FuncPtr’ (not exposed in
‘ctypes’) which inherits from the private *note _CFuncPtr: 2f79. class:

     >>> import ctypes
     >>> lib = ctypes.CDLL(None)
     >>> issubclass(lib._FuncPtr, ctypes._CFuncPtr)
     True
     >>> lib._FuncPtr is ctypes._CFuncPtr
     False

 -- クラス: ctypes._CFuncPtr

     C の呼び出し可能外部関数のためのベースクラス。

     外部関数のインスタンスも C 互換データ型です。それらは C の関数ポイ
     ンタを表しています。

     この振る舞いは外部関数オブジェクトの特別な属性に代入することによっ
     て、カスタマイズすることができます。

      -- の属性: restype

          外部関数の結果の型を指定するために ctypes 型を代入する。何も返
          さない関数を表す void に対しては ‘None’ を使います。

          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 int, and the callable will be called with this integer,
          allowing further processing or error checking.  Using this is
          deprecated, for more flexible post processing or error
          checking use a ctypes data type as ‘restype’ and assign a
          callable to the *note errcheck: 2f44. attribute.

      -- の属性: argtypes

          関数が受け取る引数の型を指定するために ctypes 型のタプルを代入
          します。‘stdcall’ 呼び出し規約を使う関数はこのタプルの長さと同
          じ数の引数で呼び出されます。C 呼び出し規約を使う関数は、追加の
          不特定の引数も取ります。

          When a foreign function is called, each actual argument is
          passed to the *note from_param(): 2f3f. class method of the
          items in the *note argtypes: 2f3a. tuple, this method allows
          adapting the actual argument to an object that the foreign
          function accepts.  For example, a *note c_char_p: 164c. item
          in the *note argtypes: 2f3a. tuple will convert a string
          passed as argument into a bytes object using ctypes conversion
          rules.

          New: It is now possible to put items in argtypes which are not
          ctypes types, but each item must have a *note from_param():
          2f3f. method which returns a value usable as argument
          (integer, string, ctypes instance).  This allows defining
          adapters that can adapt custom objects as function parameters.

      -- の属性: errcheck

          Python 関数または他の呼び出し可能オブジェクトをこの属性に代入
          します。呼び出し可能オブジェクトは三つ以上の引数とともに呼び出
          されます。

           -- の関数: callable (result, func, arguments)

               'result' is what the foreign function returns, as
               specified by the ‘restype’ attribute.

               'func' は外部関数オブジェクト自身で、これにより複数の関数
               の処理結果をチェックまたは後処理するために、同じ呼び出し
               可能オブジェクトを再利用できるようになります。

               'arguments' は関数呼び出しに最初に渡されたパラメータが入
               ったタプルです。これにより使われた引数に基づいた特別な振
               る舞いをさせることができるようになります。

          この関数が返すオブジェクトは外部関数呼び出しから返された値でし
          ょう。しかし、戻り値をチェックして、外部関数呼び出しが失敗して
          いるなら例外を送出させることもできます。

 -- 例外: ctypes.ArgumentError

     この例外は外部関数呼び出しが渡された引数を変換できなかったときに送
     出されます。

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 a suitable Python exception.  Further, an auditing event
‘ctypes.set_exception’ with argument ‘code’ will be raised, allowing an
audit hook to replace the exception with its own.

Some ways to invoke foreign function calls may raise an auditing event
‘ctypes.call_function’ with arguments ‘function pointer’ and
‘arguments’.


File: python.info,  Node: 関数プロトタイプ,  Next: ユーティリティー関数,  Prev: 外部関数,  Up: ctypesリファレンス

5.16.15.27 関数プロトタイプ
...........................

外部関数は関数プロトタイプをインスタンス化することによって作成されます。
関数プロトタイプは C の関数プロトタイプと似ています。実装は定義せずに、
関数 (返り値の型、引数の型、呼び出し規約) を記述します。 ファクトリ関数
は、その関数に要求される返り値の型と引数の型とともに呼び出されます。そし
てこの関数はデコレータファクトリとしても使え、 ‘@wrapper’ 構文で他の関数
に適用できます。 例については *note コールバック関数: 2f5d. を参照してく
ださい。

 -- の関数: ctypes.CFUNCTYPE (restype, *argtypes, use_errno=False,
          use_last_error=False)

     返された関数プロトタイプは標準 C 呼び出し規約をつかう関数を作成しま
     す。関数は呼び出されている間 GIL を解放します。 'use_errno' が真に
     設定されれば、呼び出しの前後で System 変数 *note errno: 4d. の
     ctypesプライベートコピーは本当の *note errno: 4d. の値と交換されま
     す。 'use_last_error' も Windows エラーコードに対するのと同様です。

 -- の関数: ctypes.WINFUNCTYPE (restype, *argtypes, use_errno=False,
          use_last_error=False)

     Windows のみ: 返された関数プロトタイプは ‘stdcall’ 呼び出し規約を使
     う関数を作成します。関数は呼び出されている間 GIL を解放します。
     'use_errno' と 'use_last_error' は前述と同じ意味を持ちます。

 -- の関数: ctypes.PYFUNCTYPE (restype, *argtypes)

     返された関数プロトタイプは Python 呼び出し規約を使う関数を作成しま
     す。関数は呼び出されている間 GIL を解放 'しません'。

ファクトリ関数によって作られた関数プロトタイプは呼び出しのパラメータの型
と数に依存した別の方法でインスタンス化することができます。 :

 -- の関数: prototype (address)

     指定されたアドレス(整数でなくてはなりません)の外部関数を返します。

 -- の関数: prototype (callable)

     Python の 'callable' から C の呼び出し可能関数(コールバック関数) を
     作成します。

 -- の関数: prototype (func_spec[, paramflags])

     共有ライブラリがエクスポートしている外部関数を返します。
     'func_spec' は 2 要素タプル ‘(name_or_ordinal, library)’ でなければ
     なりません。第一要素はエクスポートされた関数の名前である文字列、ま
     たはエクスポートされた関数の序数である小さい整数です。第二要素は共
     有ライブラリインスタンスです。

 -- の関数: prototype (vtbl_index, name[, paramflags[, iid]])

     COM メソッドを呼び出す外部関数を返します。 'vtbl_index' は仮想関数
     テーブルのインデックスで、非負の小さい整数です。 'name' は COM メソ
     ッドの名前です。 'iid' はオプションのインターフェイス識別子へのポイ
     ンタで、拡張されたエラー情報の提供のために使われます。

     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 ‘argtypes’ tuple.

オプションの 'paramflags' パラメータは上述した機能より多機能な外部関数ラ
ッパーを作成します。

'paramflags' must be a tuple of the same length as *note argtypes: 2f3a.

このタプルの個々の要素はパラメータについてのより詳細な情報を持ち、 1 、
2 もしくは 3 要素を含むタプルでなければなりません。

第一要素はパラメータについてのフラグの組み合わせを含んだ整数です。

     1

          入力パラメータを関数に指定します。

     2

          出力パラメータ。外部関数が値を書き込みます。

     4

          デフォルトで整数ゼロになる入力パラメータ。

オプションの第二要素はパラメータ名の文字列です。これが指定された場合は、
外部関数を名前付きパラメータで呼び出すことができます。

オプションの第三要素はこのパラメータのデフォルト値です。

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:

     WINUSERAPI int WINAPI
     MessageBoxW(
         HWND hWnd,
         LPCWSTR lpText,
         LPCWSTR lpCaption,
         UINT uType);

*note ctypes: 22. を使ってラップします。:

     >>> from ctypes import c_int, WINFUNCTYPE, windll
     >>> from ctypes.wintypes import HWND, LPCWSTR, UINT
     >>> prototype = WINFUNCTYPE(c_int, HWND, LPCWSTR, LPCWSTR, UINT)
     >>> paramflags = (1, "hwnd", 0), (1, "text", "Hi"), (1, "caption", "Hello from ctypes"), (1, "flags", 0)
     >>> MessageBox = prototype(("MessageBoxW", windll.user32), paramflags)

これで外部関数の ‘MessageBox’ を次のような方法で呼び出すことができるよう
になりました:

     >>> MessageBox()
     >>> MessageBox(text="Spam, spam, spam")
     >>> MessageBox(flags=2, text="foo bar")

二番目の例は出力パラメータについて説明します。 win32 の ‘GetWindowRect’
関数は、指定されたウィンドウの大きさを呼び出し側が与える ‘RECT’ 構造体へ
コピーすることで取り出します。 C の宣言はこうです。:

     WINUSERAPI BOOL WINAPI
     GetWindowRect(
          HWND hWnd,
          LPRECT lpRect);

*note ctypes: 22. を使ってラップします。:

     >>> from ctypes import POINTER, WINFUNCTYPE, windll, WinError
     >>> from ctypes.wintypes import BOOL, HWND, RECT
     >>> prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
     >>> paramflags = (1, "hwnd"), (2, "lprect")
     >>> GetWindowRect = prototype(("GetWindowRect", windll.user32), paramflags)
     >>>

出力パラメータを持つ関数は、単一のパラメータがある場合にはその出力パラメ
ータ値を、複数のパラメータがある場合には出力パラメータ値が入ったタプルを
、それぞれ自動的に返します。そのため、GetWindowRect 関数は呼び出されると
RECT インスタンスを返します。

Output parameters can be combined with the *note errcheck: 2f44.
protocol to do further output processing and error checking.  The win32
‘GetWindowRect’ api function returns a ‘BOOL’ to signal success or
failure, so this function could do the error checking, and raises an
exception when the api call failed:

     >>> def errcheck(result, func, args):
     ...     if not result:
     ...         raise WinError()
     ...     return args
     ...
     >>> GetWindowRect.errcheck = errcheck
     >>>

If the *note errcheck: 2f44. function returns the argument tuple it
receives unchanged, *note ctypes: 22. continues the normal processing it
does on the output parameters.  If you want to return a tuple of window
coordinates instead of a ‘RECT’ instance, you can retrieve the fields in
the function and return them instead, the normal processing will no
longer take place:

     >>> def errcheck(result, func, args):
     ...     if not result:
     ...         raise WinError()
     ...     rc = args[1]
     ...     return rc.left, rc.top, rc.bottom, rc.right
     ...
     >>> GetWindowRect.errcheck = errcheck
     >>>


File: python.info,  Node: ユーティリティー関数,  Next: データ型<3>,  Prev: 関数プロトタイプ,  Up: ctypesリファレンス

5.16.15.28 ユーティリティー関数
...............................

 -- の関数: ctypes.addressof (obj)

     メモリバッファのアドレスを示す整数を返します。 'obj' は ctypes 型の
     インスタンスでなければなりません。

     引数 ‘obj’ を指定して *note 監査イベント: 1825. ‘ctypes.addressof’
     を送出します。

 -- の関数: ctypes.alignment (obj_or_type)

     ctypes 型のアライメントの必要条件を返します。 'obj_or_type' は
     ctypes 型またはインスタンスでなければなりません。

 -- の関数: ctypes.byref (obj[, offset])

     'obj' (ctypes 型のインスタンスでなければならない) への軽量ポインタ
     を返します。 'offset' はデフォルトでは 0 で、内部ポインターへ加算さ
     れる整数です。

     ‘byref(obj, offset)’ は、 C コードとしては、以下のようにみなされま
     す。:

          (((char *)&obj) + offset)

     返されるオブジェクトは外部関数呼び出しのパラメータとしてのみ使用で
     きます。‘pointer(obj)’ と似たふるまいをしますが、作成が非常に速く行
     えます。

 -- の関数: ctypes.cast (obj, type)

     この関数は C のキャスト演算子に似ています。'obj' と同じメモリブロッ
     クを指している 'type' の新しいインスタンスを返します。'type' はポイ
     ンタ型でなければならず、'obj' はポインタとして解釈できるオブジェク
     トでなければなりません。

 -- の関数: ctypes.create_string_buffer (init_or_size, size=None)

     この関数は変更可能な文字バッファを作成します。返されるオブジェクト
     は *note c_char: 2f2b. の ctypes 配列です。

     'init_or_size' は配列のサイズを指定する整数もしくは配列要素を初期化
     するために使われるバイト列オブジェクトである必要があります。

     バイト列オブジェクトが第一引数として指定されていた場合、配列の最後
     の要素が NUL 終端文字となるように、バイト列オブジェクトの長さより 1
     つ長いバッファを作成します。バイト列の長さを使うべきではない場合は
     、第二引数として整数を渡して、配列の長さを指定することができます。

     引数 ‘init’, ‘size’ を指定して *note 監査イベント: 1825.
     ‘ctypes.create_string_buffer’ を送出します。

 -- の関数: ctypes.create_unicode_buffer (init_or_size, size=None)

     この関数は変更可能な Unicode 文字バッファを作成します。返されるオブ
     ジェクトは *note c_wchar: 2f2c. の ctypes 配列です。

     'init_or_size' は配列のサイズを指定する整数もしくは配列要素を初期化
     するために使われる文字列である必要があります。

     第一引数として文字列が指定された場合は、バッファが文字列の長さより
     一要素分大きく作られます。配列の最後の要素が NUL 終端文字であるため
     です。文字列の長さを使うべきでない場合は、配列のサイズを指定するた
     めに整数を第二引数として渡すことができます。

     引数 ‘init’, ‘size’ を指定して *note 監査イベント: 1825.
     ‘ctypes.create_unicode_buffer’ を送出します。

 -- の関数: ctypes.DllCanUnloadNow ()

     Windows 用: この関数は ctypes をつかってインプロセス COM サーバーを
     実装できるようにするためのフックです。_ctypes 拡張 dll がエクスポー
     トしている DllCanUnloadNow 関数から呼び出されます。

 -- の関数: ctypes.DllGetClassObject ()

     Windows 用: この関数は ctypes をつかってインプロセス COM サーバーを
     実装できるようにするためのフックです。‘_ctypes’ 拡張 dll がエクスポ
     ートしている DllGetClassObject 関数から呼び出されます。

 -- の関数: ctypes.util.find_library (name)

     ライブラリを検索し、パス名を返します。 'name' は ‘lib’ のような接頭
     辞、 ‘.so’ や ‘.dylib’ のような接尾辞、そして、バージョンナンバーを
     除くライブラリ名です (これは posix のリンカーオプション ‘-l’ で使わ
     れる書式です) 。もしライブラリが見つからなければ、 ‘None’ を返しま
     す。

     厳密な機能はシステムに依存します。

 -- の関数: ctypes.util.find_msvcrt ()

     Windows 用: Python と拡張モジュールで使われる VC ランタイムライブラ
     リのファイル名を返します。もしライブラリ名が同定できなければ、
     ‘None’ を返します。

     もし、例えば拡張モジュールにより割り付けられたメモリを ‘free(void
     *)’ で解放する必要があるなら、メモリ割り付けを行ったのと同じライブ
     ラリの関数を使うことが重要です。

 -- の関数: ctypes.FormatError ([code])

     Windows 用: エラーコード 'code' の説明文を返します。エラーコードが
     指定されない場合は、 Windows api 関数 GetLastError を呼び出して、も
     っとも新しいエラーコードが使われます。

 -- の関数: ctypes.GetLastError ()

     Windows 用: 呼び出し側のスレッド内で Windows によって設定された最新
     のエラーコードを返します。この関数は Windows の ‘GetLastError()’ 関
     数を直接実行します。 ctypes のプライベートなエラーコードのコピーを
     返したりはしません。

 -- の関数: ctypes.get_errno ()

     システムの *note errno: 4d. 変数の、スレッドローカルなプライベート
     コピーを返します。

     引数無しで *note 監査イベント: 1825. ‘ctypes.get_errno’ を送出しま
     す。

 -- の関数: ctypes.get_last_error ()

     Windows only: returns the current value of the ctypes-private copy
     of the system ‘LastError’ variable in the calling thread.

     引数無しで *note 監査イベント: 1825. ‘ctypes.get_last_error’ を送出
     します。

 -- の関数: ctypes.memmove (dst, src, count)

     標準 C の memmove ライブラリ関数と同じものです。: 'count' バイトを
     'src' から 'dst' へコピーします。 'dst' と 'src' はポインタへ変換可
     能な整数または ctypes インスタンスでなければなりません。

 -- の関数: ctypes.memset (dst, c, count)

     標準 C の memset ライブラリ関数と同じものです。: アドレス 'dst' の
     メモリブロックを値 'c' を 'count' バイト分書き込みます。 'dst' はア
     ドレスを指定する整数または ctypes インスタンスである必要があります
     。

 -- の関数: ctypes.POINTER (type, /)

     Create and return a new ctypes pointer type.  Pointer types are
     cached and reused internally, so calling this function repeatedly
     is cheap.  'type' must be a ctypes type.

 -- の関数: ctypes.pointer (obj, /)

     Create a new pointer instance, pointing to 'obj'.  The returned
     object is of the type ‘POINTER(type(obj))’.

     注意: 外部関数呼び出しへオブジェクトへのポインタを渡したいだけなら
     、はるかに高速な ‘byref(obj)’ を使うべきです。

 -- の関数: ctypes.resize (obj, size)

     この関数は 'obj' の内部メモリバッファのサイズを変更します。 'obj' は
     ctypes 型のインスタンスでなければなりません。バッファを
     ‘sizeof(type(obj))’ で与えられるオブジェクト型の本来のサイズより小
     さくすることはできませんが、バッファを拡大することはできます。

 -- の関数: ctypes.set_errno (value)

     システム変数 *note errno: 4d. の、呼び出し元スレッドでの ctypes の
     プライベートコピーの現在値を 'value' に設定し、前の値を返します。

     引数 ‘errno’ を指定して *note 監査イベント: 1825.
     ‘ctypes.set_errno’ を送出します。

 -- の関数: ctypes.set_last_error (value)

     Windows only: set the current value of the ctypes-private copy of
     the system ‘LastError’ variable in the calling thread to 'value'
     and return the previous value.

     引数 ‘error’ を指定して *note 監査イベント: 1825.
     ‘ctypes.set_last_error’ を送出します。

 -- の関数: ctypes.sizeof (obj_or_type)

     ctypes の型やインスタンスのメモリバッファのサイズをバイト数で返しま
     す。C の ‘sizeof’ 演算子と同様の動きをします。

 -- の関数: ctypes.string_at (ptr, size=-1)

     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.

     Raises an *note auditing event: 1825. ‘ctypes.string_at’ with
     arguments ‘ptr’, ‘size’.

 -- の関数: ctypes.WinError (code=None, descr=None)

     Windows only: this function is probably the worst-named thing in
     ctypes.  It creates an instance of *note OSError: 3f0.  If 'code'
     is not specified, ‘GetLastError’ is called to determine the error
     code.  If 'descr' is not specified, *note FormatError(): 2f85. is
     called to get a textual description of the error.

     バージョン 3.3 で変更: An instance of *note WindowsError: 1028.
     used to be created, which is now an alias of *note OSError: 3f0.

 -- の関数: ctypes.wstring_at (ptr, size=-1)

     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.

     Raises an *note auditing event: 1825. ‘ctypes.wstring_at’ with
     arguments ‘ptr’, ‘size’.


File: python.info,  Node: データ型<3>,  Next: 基本データ型<2>,  Prev: ユーティリティー関数,  Up: ctypesリファレンス

5.16.15.29 データ型
...................

 -- クラス: ctypes._CData

     この非公開クラスはすべての ctypes データ型の共通のベースクラスです
     。他のことはさておき、すべての ctypes 型インスタンスは C 互換データ
     を保持するメモリブロックを内部に持ちます。このメモリブロックのアド
     レスは *note addressof(): 2f80. ヘルパー関数が返します。別のインス
     タンス変数が *note _objects: 2f8f. として公開されます。これはメモリ
     ブロックがポインタを含む場合に存続し続ける必要のある他の Python オ
     ブジェクトを含んでいます。

     ctypes データ型の共通メソッド、すべてのクラスメソッドが存在します
     (正確には、 *note メタクラス: 1ee7. のメソッドです):

      -- メソッド: from_buffer (source[, offset])

          このメソッドは 'source' オブジェクトのバッファを共有する
          ctypes のインスタンスを返します。 'source' オブジェクトは書き
          込み可能バッファインターフェースをサポートしている必要がありま
          す。オプションの 'offset' 引数では 'source' バッファのオフセッ
          トをバイト単位で指定します。デフォルトではゼロです。もし
          'source' バッファが十分に大きくなければ、 *note ValueError:
          1e3. が送出されます。

          引数 ‘pointer’, ‘size’, ‘offset’ を指定して *note
          監査イベント: 1825. ‘ctypes.cdata/buffer’ を送出します。

      -- メソッド: from_buffer_copy (source[, offset])

          このメソッドは 'source' オブジェクトの読み出し可能バッファをコ
          ピーすることで、ctypes のインスタンスを生成します。オプション
          の 'offset' 引数では 'source' バッファのオフセットをバイト単位
          で指定します。デフォルトではゼロです。もし 'source' バッファが
          十分に大きくなければ、 *note ValueError: 1e3. が送出されます。

          引数 ‘pointer’, ‘size’, ‘offset’ を指定して *note
          監査イベント: 1825. ‘ctypes.cdata/buffer’ を送出します。

      -- メソッド: from_address (address)

          このメソッドは 'address' で指定されたメモリを使って ctypes 型
          のインスタンスを返します。 'address' は整数でなければなりませ
          ん。

          This method, and others that indirectly call this method,
          raises an *note auditing event: 1825. ‘ctypes.cdata’ with
          argument ‘address’.

      -- メソッド: from_param (obj)

          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 *note argtypes:
          2f3a. tuple; it must return an object that can be used as a
          function call parameter.

          すべての ctypes のデータ型は、それが型のインスタンスであれば、
          'obj' を返すこのクラスメソッドのデフォルトの実装を持ちます。い
          くつかの型は、別のオブジェクトも受け付けます。

      -- メソッド: in_dll (library, name)

          このメソッドは、共有ライブラリによってエクスポートされた
          ctypes 型のインスタンスを返します。 'name' はエクスポートされ
          たデータの名前で、 'library' はロードされた共有ライブラリです
          。

     ctypes データ型共通のインスタンス変数:

      -- の属性: _b_base_

          ctypes 型データのインスタンスは、それ自身のメモリブロックを持
          たず、基底オブジェクトのメモリブロックの一部を共有することがあ
          ります。 *note _b_base_: 2f93. 読み出し専用属性は、メモリブロ
          ックを保持する ctypes の基底オブジェクトです。

      -- の属性: _b_needsfree_

          この読み出し専用の変数は、 ctypes データインスタンスが、それ自
          身に割り当てられたメモリブロックを持つとき true になります。そ
          れ以外の場合は false になります。

      -- の属性: _objects

          このメンバは ‘None’ 、または、メモリブロックの内容が正しく保つ
          ために、生存させておかなくてはならない Python オブジェクトを持
          つディクショナリです。このオブジェクトはデバッグでのみ使われま
          す。決してディクショナリの内容を変更しないで下さい。


File: python.info,  Node: 基本データ型<2>,  Next: 構造化データ型,  Prev: データ型<3>,  Up: ctypesリファレンス

5.16.15.30 基本データ型
.......................

 -- クラス: ctypes._SimpleCData

     この非公開クラスは、全ての基本的な ctypes データ型の基底クラスです
     。これは基本的な ctypes データ型に共通の属性を持っているので、ここ
     で触れておきます。 *note _SimpleCData: 2f97. は *note _CData: 2f8e.
     の子クラスなので、そのメソッドと属性を継承しています。ポインタでな
     いかポインタを含まない ctypes データ型は、現在は pickle 化できます
     。

     インスタンスは一つだけ属性を持ちます:

      -- の属性: value

          この属性は、インスタンスの実際の値を持ちます。整数型とポインタ
          型に対しては整数型、文字型に対しては一文字のバイト列オブジェク
          ト、文字へのポインタに対しては Python のバイト列オブジェクトも
          しくは文字列となります。

          ‘value’ 属性が ctypes インスタンスより参照されたとき、大抵の場
          合はそれぞれに対し新しいオブジェクトを返します。 *note ctypes:
          22. はオリジナルのオブジェクトを返す実装にはなって 'おらず' 新
          しいオブジェクトを構築します。同じことが他の ctypes オブジェク
          トインスタンスに対しても言えます。

Fundamental data types, when returned as foreign function call results,
or, for example, by retrieving structure field members or array items,
are transparently converted to native Python types.  In other words, if
a foreign function has a *note restype: 2f42. of *note c_char_p: 164c,
you will always receive a Python bytes object, 'not' a *note c_char_p:
164c. instance.

Subclasses of fundamental data types do 'not' inherit this behavior.
So, if a foreign functions ‘restype’ is a subclass of *note c_void_p:
164e, 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.

これらが基本 ctypes データ型です:

 -- クラス: ctypes.c_byte

     C の signed char データ型を表し、小整数として値を解釈します。コンス
     トラクタはオプションの整数初期化子を受け取ります。オーバーフローの
     チェックは行われません。

 -- クラス: ctypes.c_char

     C char データ型を表し、単一の文字として値を解釈します。コンストラク
     タはオプションの文字列初期化子を受け取り、その文字列の長さちょうど
     一文字である必要があります。

 -- クラス: ctypes.c_char_p

     C char* データ型を表し、ゼロ終端文字列へのポインタでなければなりま
     せん。バイナリデータを指す可能性のある一般的なポインタに対しては
     ‘POINTER(c_char)’ を使わなければなりません。コンストラクタは整数の
     アドレスもしくはバイト列オブジェクトを受け取ります。

 -- クラス: ctypes.c_double

     C double データ型を表します。コンストラクタはオプションの浮動小数点
     数初期化子を受け取ります。

 -- クラス: ctypes.c_longdouble

     C long double データ型を表します。コンストラクタはオプションで浮動
     小数点数初期化子を受け取ります。 ‘sizeof(long double) ==
     sizeof(double)’ であるプラットフォームでは *note c_double: 1865. の
     別名です。

 -- クラス: ctypes.c_float

     C float データ型を表します。コンストラクタはオプションの浮動小数点
     数初期化子を受け取ります。

 -- クラス: ctypes.c_int

     C signed int データ型を表します。コンストラクタはオプションの整数初
     期化子を受け取ります。オーバーフローのチェックは行われません。
     ‘sizeof(int) == sizeof(long)’ であるプラットフォームでは、 *note
     c_long: 2f20. の別名です。

 -- クラス: ctypes.c_int8

     C 8-bit signed int データ型を表します。たいていは、 *note c_byte:
     16db. の別名です。

 -- クラス: ctypes.c_int16

     C 16-bit signed int データ型を表します。たいていは、 *note c_short:
     2f2d. の別名です。

 -- クラス: ctypes.c_int32

     C 32-bit signed int データ型を表します。たいていは、 *note c_int:
     2f1f. の別名です。

 -- クラス: ctypes.c_int64

     C 64-bit signed int データ型を表します。たいていは、 *note
     c_longlong: 2f31. の別名です。

 -- クラス: ctypes.c_long

     C signed long データ型を表します。コンストラクタはオプションの整数
     初期化子を受け取ります。オーバーフローのチェックは行われません。

 -- クラス: ctypes.c_longlong

     C signed long long データ型を表します。コンストラクタはオプションの
     整数初期化子を受け取ります。オーバーフローのチェックは行われません
     。

 -- クラス: ctypes.c_short

     C signed short データ型を表します。コンストラクタはオプションの整数
     初期化子を受け取ります。オーバーフローのチェックは行われません。

 -- クラス: ctypes.c_size_t

     C ‘size_t’ データ型を表します。

 -- クラス: ctypes.c_ssize_t

     C ‘ssize_t’ データ型を表します。

     Added in version 3.2.

 -- クラス: ctypes.c_time_t

     Represents the C ‘time_t’ datatype.

     Added in version 3.12.

 -- クラス: ctypes.c_ubyte

     C の unsigned char データ型を表し、小さな整数として値を解釈します。
     コンストラクタはオプションの整数初期化子を受け取ります; オーバーフ
     ローのチェックは行われません。

 -- クラス: ctypes.c_uint

     C の unsigned int データ型を表します。コンストラクタはオプションの
     整数初期化子を受け取ります; オーバーフローのチェックは行われません
     。これは、 ‘sizeof(int) == sizeof(long)’ であるプラットフォームでは
     *note c_ulong: 2f30. の別名です。

 -- クラス: ctypes.c_uint8

     C 8-bit unsigned int データ型を表します。たいていは、 *note
     c_ubyte: 16dc. の別名です。

 -- クラス: ctypes.c_uint16

     C 16-bit unsigned int データ型を表します。たいていは、 *note
     c_ushort: 2f2e. の別名です。

 -- クラス: ctypes.c_uint32

     C 32-bit unsigned int データ型を表します。たいていは、 *note
     c_uint: 2f2f. の別名です。

 -- クラス: ctypes.c_uint64

     C 64-bit unsigned int データ型を表します。たいていは、 *note
     c_ulonglong: 2f32. の別名です。

 -- クラス: ctypes.c_ulong

     C unsigned long データ型を表します。コンストラクタはオプションの整
     数初期化子を受け取ります。オーバーフローのチェックは行われません。

 -- クラス: ctypes.c_ulonglong

     C unsigned long long データ型を表します。コンストラクタはオプション
     の整数初期化子を受け取ります。オーバーフローのチェックは行われませ
     ん。

 -- クラス: ctypes.c_ushort

     C unsigned short データ型を表します。コンストラクタはオプションの整
     数初期化子を受け取ります。オーバーフローのチェックは行われません。

 -- クラス: ctypes.c_void_p

     C void* データ型を表します。値は整数として表されます。コンストラク
     タはオプションの整数初期化子を受け取ります。

 -- クラス: ctypes.c_wchar

     C ‘wchar_t’ データ型を表し、値は Unicode 文字列の単一の文字として解
     釈されます。コンストラクタはオプションの文字列初期化子を受け取り、
     その文字列の長さはちょうど一文字である必要があります。

 -- クラス: ctypes.c_wchar_p

     C wchar_t* データ型を表し、ゼロ終端ワイド文字列へのポインタでなけれ
     ばなりません。コンストラクタは整数のアドレスもしくは文字列を受け取
     ります。

 -- クラス: ctypes.c_bool

     C の bool データ型 (より正確には、 C99 以降の _Bool) を表します。
     ‘True’ または ‘False’ の値を持ち、コンストラクタは真偽値と解釈でき
     るオブジェクトを受け取ります。

 -- クラス: ctypes.HRESULT

     Windows only: Represents a ‘HRESULT’ value, which contains success
     or error information for a function or method call.

 -- クラス: ctypes.py_object

     C *note PyObject: 312.* データ型を表します。引数なしでこれを呼び出
     すと ‘NULL’ *note PyObject: 312.* ポインタを作成します。

The ‘ctypes.wintypes’ module provides quite some other Windows specific
data types, for example ‘HWND’, ‘WPARAM’, or ‘DWORD’.  Some useful
structures like ‘MSG’ or ‘RECT’ are also defined.


File: python.info,  Node: 構造化データ型,  Next: 配列とポインタ,  Prev: 基本データ型<2>,  Up: ctypesリファレンス

5.16.15.31 構造化データ型
.........................

 -- クラス: ctypes.Union (*args, **kw)

     ネイティブのバイトオーダーでの共用体のための抽象ベースクラス。

 -- クラス: ctypes.BigEndianUnion (*args, **kw)

     'ビックエンディアン' バイトオーダーでの共用体のための抽象ベースクラ
     ス。

     Added in version 3.11.

 -- クラス: ctypes.LittleEndianUnion (*args, **kw)

     'リトルエンディアン' バイトオーダーでの共用体のための抽象ベースクラ
     ス。

     Added in version 3.11.

 -- クラス: ctypes.BigEndianStructure (*args, **kw)

     'ビックエンディアン' バイトオーダーでの構造体のための抽象ベースクラ
     ス。

 -- クラス: ctypes.LittleEndianStructure (*args, **kw)

     'リトルエンディアン' バイトオーダーでの構造体のための抽象ベースクラ
     ス。

ネイティブではないバイトオーダーを持つ構造体および共用体にポインタ型フィ
ールドあるいはポインタ型フィールドを含む他のどんなデータ型をも入れること
はできません。

 -- クラス: ctypes.Structure (*args, **kw)

     'ネイティブ' のバイトオーダーでの構造体のための抽象ベースクラス。

     具象構造体型と具象共用体型はこれらの型の一つをサブクラス化すること
     で作らなければなりません。少なくとも、 *note _fields_: 2f4a. クラス
     変数を定義する必要があります。 *note ctypes: 22. は、属性に直接アク
     セスしてフィールドを読み書きできるようにする *note デスクリプタ:
     1ed1. を作成するでしょう。これらは、

      -- の属性: _fields_

          構造体のフィールドを定義するシーケンス。要素は2要素タプルか3要
          素タプルでなければなりません。第一要素はフィールドの名前です。
          第二要素はフィールドの型を指定します。それはどんな ctypes デー
          タ型でも構いません。

          *note c_int: 2f1f. のような整数型のために、オプションの第三要
          素を与えることができます。フィールドのビット幅を定義する正の小
          整数である必要があります。

          一つの構造体と共用体の中で、フィールド名はただ一つである必要が
          あります。これはチェックされません。名前が繰り返しでてきたとき
          にアクセスできるのは一つのフィールドだけです。

          Structure サブクラスを定義するクラス文の '後で' 、 *note
          _fields_: 2f4a. クラス変数を定義することができます。これにより
          、次のように自身を直接または間接的に参照するデータ型を作成でき
          るようになります:

               class List(Structure):
                   pass
               List._fields_ = [("pnext", POINTER(List)),
                                ...
                               ]

          しかし、 *note _fields_: 2f4a. クラス変数はその型が最初に使わ
          れる (インスタンスが作成される、それに対して *note sizeof():
          2f88. が呼び出されるなど) より前に定義されていなければなりませ
          ん。その後 *note _fields_: 2f4a. クラス変数へ代入すると
          AttributeError が送出されます。

          構造体型のサブクラスのサブクラスを定義することもでき、もしある
          ならサブクラスのサブクラス内で定義された *note _fields_: 2f4a.
          に加えて、基底クラスのフィールドも継承します。

      -- の属性: _pack_

          An optional small integer that allows overriding the alignment
          of structure fields in the instance.  *note _pack_: 2f4d. must
          already be defined when *note _fields_: 2f4a. is assigned,
          otherwise it will have no effect.  Setting this attribute to 0
          is the same as not setting it at all.

      -- の属性: _align_

          An optional small integer that allows overriding the alignment
          of the structure when being packed or unpacked to/from memory.
          Setting this attribute to 0 is the same as not setting it at
          all.

          Added in version 3.13.

      -- の属性: _anonymous_

          無名 (匿名) フィールドの名前が並べあげられたオプションのシーケ
          ンス。 *note _fields_: 2f4a. が代入されたとき、 *note
          _anonymous_: 2fa3. がすでに定義されていなければなりません。そ
          うでなければ、何ら影響はありません。

          この変数に並べあげられたフィールドは構造体型もしくは共用体型フ
          ィールドである必要があります。構造体フィールドまたは共用体フィ
          ールドを作る必要なく、入れ子になったフィールドに直接アクセスで
          きるようにするために、 *note ctypes: 22. は構造体型の中に記述
          子を作成します。

          型の例です (Windows):

               class _U(Union):
                   _fields_ = [("lptdesc", POINTER(TYPEDESC)),
                               ("lpadesc", POINTER(ARRAYDESC)),
                               ("hreftype", HREFTYPE)]

               class TYPEDESC(Structure):
                   _anonymous_ = ("u",)
                   _fields_ = [("u", _U),
                               ("vt", VARTYPE)]

          ‘TYPEDESC’ 構造体はCOMデータ型を表現しており、 ‘vt’ フィールド
          は共用体フィールドのどれが有効であるかを指定します。 ‘u’ フィ
          ールドは匿名フィールドとして定義されているため、 TYPEDESC イン
          スタンスから取り除かれてそのメンバーへ直接アクセスできます。
          ‘td.lptdesc’ と ‘td.u.lptdesc’ は同等ですが、前者がより高速で
          す。なぜなら一時的な共用体インスタンスを作る必要がないためです
          。:

               td = TYPEDESC()
               td.vt = VT_PTR
               td.lptdesc = POINTER(some_type)
               td.u.lptdesc = POINTER(some_type)

     構造体のサブクラスのサブクラスを定義することができ、基底クラスのフ
     ィールドを継承します。 サブクラス定義に別の *note _fields_: 2f4a. 変
     数がある場合は、この中で指定されたフィールドは基底クラスのフィール
     ドへ追加されます。

     構造体と共用体のコンストラクタは位置引数とキーワード引数の両方を受
     け取ります。位置引数は *note _fields_: 2f4a. の中に現れたのと同じ順
     番でメンバーフィールドを初期化するために使われます。コンストラクタ
     のキーワード引数は属性代入として解釈され、そのため、同じ名前をもつ
     *note _fields_: 2f4a. を初期化するか、 *note _fields_: 2f4a. に存在
     しない名前に対しては新しい属性を作ります。


File: python.info,  Node: 配列とポインタ,  Prev: 構造化データ型,  Up: ctypesリファレンス

5.16.15.32 配列とポインタ
.........................

 -- クラス: ctypes.Array (*args)

     配列のための抽象基底クラスです。

     具象配列型を作成するための推奨される方法は、任意の *note ctypes:
     22. データ型に非負の整数を乗算することです。代わりに、この型のサブ
     クラスを作成し、 *note _length_: 2fa6. と *note _type_: 2fa7. のク
     ラス変数を定義することもできます。配列の要素は、標準の添え字とスラ
     イスによるアクセスを使用して読み書きを行うことができます。スライス
     の読み込みでは、結果のオブジェクト自体は *note Array: 1995. ではあ
     りません。

      -- の属性: _length_

          配列の要素数を指定する正の整数。範囲外の添え字を指定すると、
          *note IndexError: 14de. が送出されます。*note len(): 5fa. がこ
          の整数を返します。

      -- の属性: _type_

          配列内の各要素の型を指定します。

     配列のサブクラスのコンストラクタは、位置引数を受け付けて、配列を順
     番に初期化するために使用します。

 -- の関数: ctypes.ARRAY (type, length)

     Create an array.  Equivalent to ‘type * length’, where 'type' is a
     *note ctypes: 22. data type and 'length' an integer.

     This function is *note soft deprecated: 1ea. in favor of
     multiplication.  There are no plans to remove it.

 -- クラス: ctypes._Pointer

     ポインタのためのプライベートな抽象基底クラスです。

     具象ポインタ型は、ポイント先の型を持つ *note POINTER(): 164b. を呼
     び出すことで、作成できます。これは、 *note pointer(): 164a. により
     自動的に行われます。

     ポインタが配列を指す場合、その配列の要素は、標準の添え字とスライス
     によるアクセスを使用して読み書きが行えます。ポインタオブジェクトに
     は、サイズがないため、 *note len(): 5fa. 関数は *note TypeError:
     502. を送出します。負の添え字は、(C と同様に) ポインタの '前' のメ
     モリから読み込み、範囲外の添え字はおそらく (幸運な場合でも) アクセ
     ス違反によりクラッシュを起こします。

      -- の属性: _type_

          ポイント先の型を指定します。

      -- の属性: contents

          ポインタが指すオブジェクトを返します。この属性に割り当てると、
          ポインタが割り当てられたオブジェクトを指すようになります。


File: python.info,  Node: 並行実行,  Next: ネットワーク通信とプロセス間通信,  Prev: 汎用オペレーティングシステムサービス,  Up: Python 標準ライブラリ

5.17 並行実行
=============

この章で記述されているモジュールは、コードの並行実行のサポートを提供しま
す。ツールの適切な選択は、実行されるタスク(IO bound vs CPU bound) や推奨
される開発スタイル (イベントドリブンな協調的マルチタスク vs プリエンプテ
ィブマルチタスク) に依存します。ここに概観を示します:

* Menu:

* threading: threading --- スレッドベースの並列処理. スレッドベースの並列処理
* multiprocessing: multiprocessing --- プロセスベースの並列処理. プロセスベースの並列処理
* multiprocessing.shared_memory: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ. プロセス間で直接アクセス可能な共有メモリ
* concurrent パッケージ::
* concurrent.futures: concurrent futures --- 並列タスク実行. 並列タスク実行
* subprocess: subprocess --- サブプロセス管理. サブプロセス管理
* sched: sched --- イベントスケジューラー. イベントスケジューラー
* queue: queue --- 同期キュークラス. 同期キュークラス
* contextvars: contextvars --- コンテキスト変数. コンテキスト変数
* _thread: _thread --- 低水準なスレッド API. 低水準なスレッド API


File: python.info,  Node: threading --- スレッドベースの並列処理,  Next: multiprocessing --- プロセスベースの並列処理,  Up: 並行実行

5.17.1 ‘threading’ -- スレッドベースの並列処理
----------------------------------------------

'ソースコード:' Lib/threading.py(1)

__________________________________________________________________

このモジュールでは、高水準のスレッドインターフェースをより低水準 な
*note _thread: 2. モジュールの上に構築しています。

バージョン 3.7 で変更: このモジュールは以前はオプションでしたが、常に利
用可能なモジュールとなりました。

参考
....

*note concurrent.futures.ThreadPoolExecutor: 70d. offers a higher level
interface to push tasks to a background thread without blocking
execution of the calling thread, while still being able to retrieve
their results when needed.

*note queue: a4. provides a thread-safe interface for exchanging data
between running threads.

*note asyncio: 8. offers an alternative approach to achieving task level
concurrency without requiring the use of multiple operating system
threads.

     注釈: In the Python 2.x series, this module contained ‘camelCase’
     names for some methods and functions.  These are deprecated as of
     Python 3.10, but they are still supported for compatibility with
     Python 2.5 and lower.

'CPython 実装の詳細:' CPython は *note Global Interpreter Lock: 12e. の
ため、ある時点で Python コードを実行できるスレッドは1つに限られます (た
だし、いくつかのパフォーマンスが強く求められるライブラリはこの制限を克服
しています)。アプリケーションにマルチコアマシンの計算能力をより良く利用
させたい場合は、 *note multiprocessing: 86. モジュールや *note
concurrent.futures.ProcessPoolExecutor: 8bc. の利用をお勧めします。 ただ
し、I/Oバウンドなタスクを並行して複数走らせたい場合においては、 マルチス
レッドは正しい選択肢です。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

このモジュールは以下の関数を定義しています:

 -- の関数: threading.active_count ()

     生存中の *note Thread: 91a. オブジェクトの数を返します。この数は
     *note enumerate(): 1810. の返すリストの長さと同じです。

     関数''activeCount''はこの関数の非推奨エイリアスです。

 -- の関数: threading.current_thread ()

     関数を呼び出している処理のスレッドに対応する *note Thread: 91a. オ
     ブジェクトを返します。関数を呼び出している処理のスレッドが *note
     threading: d6. モジュールで生成したものでない場合、限定的な機能しか
     もたないダミースレッドオブジェクトを返します。

     関数''currentThread''はこの関数の非推奨エイリアスです。

 -- の関数: threading.excepthook (args, /)

     *note Thread.run(): a0b. で発生したキャッチされない例外を処理する。

     (実) 引数*args*は以下の属性をもちます:

        * 'exc_type': 例外の型

        * 'exc_value': 例外の値、‘None’ の可能性がある。

        * 'exc_traceback': Exception traceback, can be ‘None’.

        * 'thread': Thread which raised the exception, can be ‘None’.

     If 'exc_type' is *note SystemExit: d0e, the exception is silently
     ignored.  Otherwise, the exception is printed out on *note
     sys.stderr: 907.

     If this function raises an exception, *note sys.excepthook(): 7d6.
     is called to handle it.

     *note threading.excepthook(): 816. can be overridden to control how
     uncaught exceptions raised by *note Thread.run(): a0b. 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 'thread' using a custom hook can resurrect it if it is set
     to an object which is being finalized.  Avoid storing 'thread'
     after the custom hook completes to avoid resurrecting objects.

     参考
     ....

     *note sys.excepthook(): 7d6. handles uncaught exceptions.

     Added in version 3.8.

 -- データ: threading.__excepthook__

     Holds the original value of *note threading.excepthook(): 816.  It
     is saved so that the original value can be restored in case they
     happen to get replaced with broken or alternative objects.

     Added in version 3.10.

 -- の関数: threading.get_ident ()

     現在のスレッドの 'スレッドID' を返します。非ゼロの整数です。この値
     は直接の意味を持っていません; 例えばスレッド特有のデータの辞書に索
     引をつけるためのような、マジッククッキーとして意図されています。ス
     レッドが終了し、他のスレッドが作られたとき、スレッド ID は再利用さ
     れるかもしれません。

     Added in version 3.3.

 -- の関数: threading.get_native_id ()

     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).

     *note Availability: 1cbe.: Windows, FreeBSD, Linux, macOS, OpenBSD,
     NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD.

     Added in version 3.8.

     バージョン 3.13 で変更: Added support for GNU/kFreeBSD.

 -- の関数: threading.enumerate ()

     現在、アクティブな *note Thread: 91a. オブジェクト全てのリストを返
     します。リストには、デーモンスレッド (daemonic thread)、 *note
     current_thread(): 2e1. の生成するダミースレッドオブジェクトが入りま
     す。終了したスレッドとまだ開始していないスレッドは入りません。しか
     し、主スレッドは、たとえ終了しても、常に結果に含まれます。

 -- の関数: threading.main_thread ()

     main *note Thread: 91a. オブジェクトを返します。通常の条件では、メ
     インスレッドはPythonインタプリタが起動したスレッドを指します。

     Added in version 3.4.

 -- の関数: threading.settrace (func)

     *note threading: d6. モジュールを使って開始した全てのスレッドにトレ
     ース関数を設定します。 'func' は各スレッドの *note run(): a0b. を呼
     び出す前にスレッドの *note sys.settrace(): 14a9. に渡されます。

 -- の関数: threading.settrace_all_threads (func)

     Set a trace function for all threads started from the *note
     threading: d6. module and all Python threads that are currently
     executing.

     The 'func' will be passed to *note sys.settrace(): 14a9. for each
     thread, before its *note run(): a0b. method is called.

     Added in version 3.12.

 -- の関数: threading.gettrace ()

     *note settrace(): 813. 関数で設定したトレース関数を取得します。

     Added in version 3.10.

 -- の関数: threading.setprofile (func)

     *note threading: d6. モジュールを使って開始した全てのスレッドにプロ
     ファイル関数を設定します。 'func' は各スレッドの *note run(): a0b.
     を呼び出す前にスレッドの *note sys.setprofile(): 14a8. に渡されます
     。

 -- の関数: threading.setprofile_all_threads (func)

     Set a profile function for all threads started from the *note
     threading: d6. module and all Python threads that are currently
     executing.

     The 'func' will be passed to *note sys.setprofile(): 14a8. for each
     thread, before its *note run(): a0b. method is called.

     Added in version 3.12.

 -- の関数: threading.getprofile ()

     *note setprofile(): 814. 関数で設定したプロファイラ関数を取得します
     。

     Added in version 3.10.

 -- の関数: threading.stack_size ([size])

     新しいスレッドを作るときのスレッドスタックサイズを返します。オプシ
     ョンの 'size' 引数にはこれ以降に作成するスレッドのスタックサイズを
     指定し、0 (プラットフォームのデフォルト値または設定されたデフォルト
     値) か、 32,768 (32 KiB) 以上の正の整数でなければなりません。'size'
     が指定されない場合 0 が使われます。スレッドのスタックサイズの変更が
     サポートされていない場合、 *note RuntimeError: 17a. を送出します。
     不正なスタックサイズが指定された場合、 *note ValueError: 1e3. を送
     出して、スタックサイズは変更されません。32 KiB は現在のインタープリ
     タ自身のために十分であると保証された最小のスタックサイズです。いく
     つかのプラットフォームではスタックサイズに対して制限があることに注
     意してください。例えば最小のスタックサイズが 32 KiB より大きかった
     り、システムのメモリページサイズ の整数倍の必要があるなどです。この
     制限についてはプラットフォームのドキュメントを参照してください (一
     般的なページサイズは 4 KiB なので、プラットフォームに関する情報がな
     い場合は 4096 の整数倍のスタックサイズを選ぶといいかもしれません)。

     *note Availability: 1cbe.: Windows, pthreads.

     Unix platforms with POSIX threads support.

このモジュールでは以下の定数も定義しています:

 -- データ: threading.TIMEOUT_MAX

     ブロックする関数 (*note Lock.acquire(): 664, *note RLock.acquire():
     e46, *note Condition.wait(): 181c. など) の 'timeout' 引数に許され
     る最大値。これ以上の値を timeout に指定すると *note OverflowError:
     84e. が発生します。

     Added in version 3.2.

このモジュールは多くのクラスを定義しています。それらは下記のセクションで
詳しく説明されます。

このモジュールのおおまかな設計は Java のスレッドモデルに基づいています。
とはいえ、 Java がロックと条件変数を全てのオブジェクトの基本的な挙動にし
ているのに対し、 Python ではこれらを別個のオブジェクトに分けています。
Python の *note Thread: 91a. クラスがサポートしているのは Java の Thread
クラスの挙動のサブセットにすぎません; 現状では、優先度 (priority)やスレ
ッドグループがなく、スレッドの破壊 (destroy)、中断 (stop)、一時停止
(suspend)、復帰 (resume)、割り込み (interrupt) は行えません。 Java の
Thread クラスにおける静的メソッドに対応する機能が実装されている場合には
モジュールレベルの関数になっています。

以下に説明するメソッドは全て原子的 (atomic) に実行されます。

* Menu:

* スレッドローカルデータ::
* Thread オブジェクト::
* Lock オブジェクト::
* RLock オブジェクト::
* Condition オブジェクト::
* Semaphore オブジェクト::
* Event オブジェクト::
* Timer オブジェクト::
* バリアオブジェクト::
* with 文でのロック・条件変数・セマフォの使い方::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/threading.py


File: python.info,  Node: スレッドローカルデータ,  Next: Thread オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.1 スレッドローカルデータ
...............................

スレッドローカルデータは、その値がスレッド固有のデータです。スレッドロー
カルデータを管理するには、単に *note local: 16d6. (あるいはそのサブクラ
ス) のインスタンスを作成して、その属性に値を設定してください:

     mydata = threading.local()
     mydata.x = 1

インスタンスの値はスレッドごとに違った値になります。

 -- クラス: threading.local

     スレッドローカルデータを表現するクラス。

     For more details and extensive examples, see the documentation
     string of the ‘_threading_local’ module:
     Lib/_threading_local.py(1).

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/_threading_local.py


File: python.info,  Node: Thread オブジェクト,  Next: Lock オブジェクト,  Prev: スレッドローカルデータ,  Up: threading --- スレッドベースの並列処理

5.17.1.2 Thread オブジェクト
............................

The *note Thread: 91a. class represents an activity that is run in a
separate thread of control.  There are two ways to specify the activity:
by passing a callable object to the constructor, or by overriding the
*note run(): a0b. method in a subclass.  No other methods (except for
the constructor) should be overridden in a subclass.  In other words,
'only' override the ‘__init__()’ and *note run(): a0b. methods of this
class.

ひとたびスレッドオブジェクトを生成すると、スレッドの *note start():
2c7c. メソッドを呼び出して活動を開始しなければなりません。 ‘start()’ メ
ソッド はそれぞれのスレッドの *note run(): a0b. メソッドを起動します。

スレッドの活動が始まると、スレッドは '生存中 (alive)' とみなされます。 ス
レッドは、通常 *note run(): a0b. メソッドが終了するまで、もしくは捕捉さ
れない例外が送出されるまで生存中となります。 *note is_alive(): 91b. メソ
ッドは、スレッドが生存中であるかどうか調べます。

スレッドは他のスレッドの *note join(): 11b5. メソッドを呼び出すことがで
きます。このメソッドは、 *note join(): 11b5. メソッドを呼ばれたスレッド
が終了するまでメソッドの呼び出し元のスレッドをブロックします。

スレッドは名前を持っています。名前はコンストラクタに渡すことができ、
*note name: 2e0. 属性を通して読み出したり変更したりできます。

*note run(): a0b. メソッドが例外を発生させた場合、*note
threading.excepthook(): 816. が呼び出され、例外を処理します。デフォルト
では、*note threading.excepthook(): 816. は *note SystemExit: d0e. を黙
殺します。

スレッドには "デーモンスレッド (daemon thread)" であるというフラグを立て
られます。 このフラグには、残っているスレッドがデーモンスレッドだけにな
った時に Python プログラム全体を終了させるという意味があります。フラグの
初期値はスレッドを生成したスレッドから継承します。フラグの値は *note
daemon: 2de. プロパティまたは 'daemon' コンストラクタ引数を通して設定で
きます。

     注釈: デーモンスレッドは終了時にいきなり停止されます。デーモンスレ
     ッドで使われたリソース (開いているファイル、データベースのトランザ
     クションなど) は適切に解放されないかもしれません。きちんと
     (gracefully) スレッドを停止したい場合は、スレッドを非デーモンスレッ
     ドにして、*note Event: 112b. のような適切なシグナル送信機構を使用し
     てください。

スレッドには "主スレッド (main thread)" オブジェクトがあります。主スレッ
ドは Python プログラムを最初に制御していたスレッドです。主スレッドはデー
モンスレッドではありません。

"ダミースレッドオブジェクト (dummy thread objects)" が作成される場合があ
ります。ダミースレッドは、 "外来スレッド (alien thread)" に相当するスレ
ッドオブジェクトです。ダミースレッドは、C コードから直接生成されたスレッ
ドのような、 *note threading: d6. モジュールの外で開始された処理スレッド
です。ダミースレッドオブジェクトには限られた機能しかなく、常に生存中、か
つデーモンスレッドであるとみなされ、 *note join: 2fb4. できません。また
、外来スレッドの終了を検出するのは不可能なので、ダミースレッドは削除でき
ません。

 -- クラス: threading.Thread (group=None, target=None, name=None,
          args=(), kwargs={}, *, daemon=None)

     コンストラクタは常にキーワード引数を使って呼び出さなければなりませ
     ん。各引数は以下の通りです:

     'group' should be ‘None’; reserved for future extension when a
     ‘ThreadGroup’ class is implemented.

     'target' は *note run(): a0b. メソッドによって起動される呼び出し可
     能オブジェクトです。デフォルトでは何も呼び出さないことを示す ‘None’
     になっています。

     'name*はスレッド名です。デフォルトでは、"Thread-*N'"('N*は小さな
     10進数)、または*target*引数が指定された場合"Thread-*N'
     (target)"("target"は''target.__name__'')という形式でユニークな名前
     が構成される。

     'args' は 'target' を呼び出すときの引数のリストかタプルです。デフォ
     ルトは ‘()’ です。

     'kwargs' は 'target' を呼び出すときのキーワード引数の辞書です。デフ
     ォルトは ‘{}’ です。

     ‘None’ でない場合、'daemon' はスレッドがデーモンかどうかを明示的に
     設定します。‘None’ の場合 (デフォルト)、デーモン属性は現在のスレッ
     ドから継承されます。

     サブクラスでコンストラクタをオーバライドした場合、必ずスレッドが何
     かを始める前に基底クラスのコンストラクタ (‘Thread.__init__()’) を呼
     び出しておかなくてはなりません。

     バージョン 3.3 で変更: Added the 'daemon' parameter.

     バージョン 3.10 で変更: 'name' 引数が省略された場合、'target' 名を
     使用します。

      -- メソッド: start ()

          スレッドの活動を開始します。

          このメソッドは、スレッドオブジェクトあたり一度しか呼び出しては
          なりません。 *note start(): 2c7c. は、オブジェクトの *note
          run(): a0b. メソッドが個別の処理スレッド中で呼び出されるように
          調整します。

          同じスレッドオブジェクトに対し、このメソッドを2回以上呼び出し
          た場合、 *note RuntimeError: 17a. を送出します。

      -- メソッド: run ()

          スレッドの活動をもたらすメソッドです。

          このメソッドはサブクラスでオーバライドできます。標準の *note
          run(): a0b. メソッドでは、オブジェクトのコンストラクタの
          'target' 引数に呼び出し可能オブジェクトを指定した場合、 'args'
          および 'kwargs' の位置引数およびキーワード引数とともに呼び出し
          ます。

          *note Thread: 91a. に渡される 'args' の引数にリストやタプルを
          使っても、同じ効果が得られます。

          以下はプログラム例です:

               >>> from threading import Thread
               >>> t = Thread(target=print, args=[1])
               >>> t.run()
               1
               >>> t = Thread(target=print, args=(1,))
               >>> t.run()
               1

      -- メソッド: join (timeout=None)

          スレッドが終了するまで待機します。 このメソッドは、 *note
          join(): 11b5. を呼ばれたスレッドが正常終了あるいは処理されない
          例外によって終了するか、オプションのタイムアウトが発生するまで
          、メソッドの呼び出し元のスレッドをブロックします。

          When the 'timeout' argument is present and not ‘None’, it
          should be a floating-point number specifying a timeout for the
          operation in seconds (or fractions thereof).  As *note join():
          11b5. always returns ‘None’, you must call *note is_alive():
          91b. after *note join(): 11b5. to decide whether a timeout
          happened - if the thread is still alive, the *note join():
          11b5. call timed out.

          'timeout' が指定されないかまたは ‘None’ であるときは、この操作
          はスレッドが終了するまでブロックします。

          1つのスレッドは何回も join されることができます。

          現在のスレッドに対して *note join(): 11b5. を呼び出そうとする
          と、デッドロックを引き起こすため *note RuntimeError: 17a. が送
          出されます。 スレッドが開始される前に *note join(): 11b5. を呼
          び出すことも同様のエラーのため、同じ例外が送出されます。

      -- の属性: name

          識別のためにのみ用いられる文字列です。名前には機能上の意味づけ
          (semantics) はありません。複数のスレッドに同じ名前をつけてもか
          まいません。名前の初期値はコンストラクタで設定されます。

      -- メソッド: getName ()
      -- メソッド: setName ()

          *note name: 2e0. に対する非推奨 getter/setter API; 代わりにプ
          ロパティを直接使用してください。

          バージョン 3.10 で非推奨.

      -- の属性: ident

          'スレッド識別子' 、または、スレッドが開始されていなければ
          ‘None’ です。非ゼロの整数です。 *note get_ident(): 112d. 関数
          を参照下さい。スレッド識別子は、スレッドが終了した後、新たなス
          レッドが生成された場合、再利用され得ます。スレッド識別子は、ス
          レッドが終了した後でも利用できます。

      -- の属性: native_id

          The Thread ID (‘TID’) of this thread, as assigned by the OS
          (kernel).  This is a non-negative integer, or ‘None’ if the
          thread has not been started.  See the *note get_native_id():
          a0c. function.  This 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).

               注釈: Similar to Process IDs, Thread IDs are only valid
               (guaranteed unique system-wide) from the time the thread
               is created until the thread has been terminated.

          *note Availability: 1cbe.: Windows, FreeBSD, Linux, macOS,
          OpenBSD, NetBSD, AIX, DragonFlyBSD.

          Added in version 3.8.

      -- メソッド: is_alive ()

          スレッドが生存中かどうかを返します。

          このメソッドは、 *note run(): a0b. メソッドが起動する直前から
          *note run(): a0b. メソッドが終了する直後までの間 ‘True’ を返し
          ます。モジュール関数 *note enumerate(): 1810. は、全ての生存中
          のスレッドのリストを返します。

      -- の属性: daemon

          このスレッドがデーモンスレッドか (‘True’) か否か (‘False’) を
          示すブール値。この値は *note start(): 2c7c. の呼び出し前に設定
          されなければなりません。さもなければ *note RuntimeError: 17a.
          が送出されます。初期値は生成側のスレッドから継承されます; メイ
          ンスレッドはデーモンスレッドではないので、メインスレッドで作成
          されたすべてのスレッドは、デフォルトで *note daemon: 2de. =
          ‘False’ になります。

          デーモンでない生存中のスレッドが全てなくなると、 Python プログ
          ラム全体が終了します。

      -- メソッド: isDaemon ()
      -- メソッド: setDaemon ()

          *note daemon: 2de. に対する非推奨 getter/setter API; 代わりに
          プロパティを直接使用してください。

          バージョン 3.10 で非推奨.


File: python.info,  Node: Lock オブジェクト,  Next: RLock オブジェクト,  Prev: Thread オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.3 Lock オブジェクト
..........................

プリミティブロックとは、ロックが生じた際に特定のスレッドによって所有され
ない同期プリミティブです。 Python では現在のところ拡張モジュール *note
_thread: 2. で直接実装されている最も低水準の同期プリミティブを使えます。

プリミティブロックは2つの状態、 "ロック" または "アンロック" があります
。ロックはアンロック状態で作成されます。ロックには基本となる二つのメソッ
ド、 *note acquire(): 664. と *note release(): 1292. があります。ロック
の状態がアンロックである場合、 *note acquire(): 664. は状態をロックに変
更して即座に処理を戻します。 状態がロックの場合、 *note acquire(): 664.
は他のスレッドが *note release(): 1292. を呼び出してロックの状態をアンロ
ックに変更するまでブロックします。その後、 *note acquire(): 664. 呼び出
しは状態を再度ロックに設定してから処理を戻します。 *note release():
1292. メソッドを呼び出すのはロック状態のときでなければなりません; このメ
ソッドはロックの状態をアンロックに変更して、即座に処理を戻します。 アン
ロックの状態のロックを解放しようとすると *note RuntimeError: 17a. が送出
されます。

ロックは *note コンテキストマネージメントプロトコル: 2fb9. もサポートし
ます。

複数のスレッドにおいて *note acquire(): 664. がアンロック状態への遷移を
待っているためにブロックが起きている時に *note release(): 1292. を呼び出
してロックの状態をアンロックにすると、一つのスレッドだけが処理を進行でき
ます。 どのスレッドが処理を進行できるのかは定義されておらず、実装によっ
て異なるかもしれません。

全てのメソッドはアトミックに実行されます。

 -- クラス: threading.Lock

     プリミティブロック (primitive lock) オブジェクトを実装しているクラ
     スです。スレッドが一度ロックを獲得すると、それ以後のロック獲得の試
     みはロックが解放されるまでブロックします。どのスレッドでもロックを
     解放できます。

     バージョン 3.13 で変更: ‘Lock’ is now a class.  In earlier Pythons,
     ‘Lock’ was a factory function which returned an instance of the
     underlying private lock type.

      -- メソッド: acquire (blocking=True, timeout=-1)

          ブロックあり、またはブロックなしでロックを獲得します。

          引数 'blocking' を ‘True’ (デフォルト) に設定して呼び出した場
          合、ロックがアンロック状態になるまでブロックします。そしてそれ
          をロック状態にしてから ‘True’ を返します。

          引数 'blocking' の値を ‘False’ にして呼び出すとブロックしませ
          ん。'blocking' を ‘True’ にして呼び出した場合にブロックするよ
          うな状況では、直ちに ‘False’ を返します。それ以外の場合には、
          ロックをロック状態にして ‘True’ を返します。

          正の値に設定された浮動小数点の 'timeout' 引数とともに起動され
          た場合、ロックを得られなければ最大で 'timeout' によって指定さ
          れた秒数だけブロックします。'timeout' 引数の ‘-1’ は無制限の待
          機を指定します。'blocking' が ‘False’ の場合に 'timeout' を指
          定することは禁止されています。

          ロックを獲得すると ‘True’ を、ロックを獲得できなかったとき (例
          えば 'timeout' が過ぎた場合) には ‘False’ を返します。

          バージョン 3.2 で変更: 新しい 'timeout' 引数。

          バージョン 3.2 で変更: Lock acquisition can now be interrupted
          by signals on POSIX if the underlying threading implementation
          supports it.

      -- メソッド: release ()

          ロックを解放します。これはロックを獲得したスレッドだけでなく、
          任意のスレッドから呼ぶことができます。

          ロックの状態がロックのとき、状態をアンロックにリセットして処理
          を戻します。他のスレッドがロックがアンロック状態になるのを待っ
          てブロックしている場合、ただ一つのスレッドだけが処理を継続でき
          るようにします。

          アンロック状態のロックに対して呼び出された場合、*note
          RuntimeError: 17a. が送出されます。

          戻り値はありません。

      -- メソッド: locked ()

          ロック状態のとき ‘True’ を返します。


File: python.info,  Node: RLock オブジェクト,  Next: Condition オブジェクト,  Prev: Lock オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.4 RLock オブジェクト
...........................

再入可能ロック (reentrant lock) とは、同じスレッドが複数回獲得できるよう
な同期プリミティブです。再入可能ロックの内部では、プリミティブロックの使
うロック／アンロック状態に加え、 "所有スレッド (owning thread)" と "再帰
レベル (recursion level)" という概念を用いています。ロック状態では何らか
のスレッドがロックを所有しており、アンロック状態ではいかなるスレッドもロ
ックを所有していません。

Threads call a lock's *note acquire(): e46. method to lock it, and its
*note release(): 1292. method to unlock it.

     注釈: Reentrant locks support the *note context management
     protocol: 2fb9, so it is recommended to use *note with: 59c.
     instead of manually calling *note acquire(): e46. and *note
     release(): 2fbd. to handle acquiring and releasing the lock for a
     block of code.

RLock's *note acquire(): e46./*note release(): 2fbd. call pairs may be
nested, unlike Lock's *note acquire(): 664./*note release(): 1292.  Only
the final *note release(): 2fbd. (the *note release(): 1292. of the
outermost pair) resets the lock to an unlocked state and allows another
thread blocked in *note acquire(): e46. to proceed.

*note acquire(): e46./*note release(): 2fbd. must be used in pairs: each
acquire must have a release in the thread that has acquired the lock.
Failing to call release as many times the lock has been acquired can
lead to deadlock.

 -- クラス: threading.RLock

     このクラスは再入可能ロックオブジェクトを実装します。再入可能ロック
     はそれを獲得したスレッドによって解放されなければなりません。いった
     んスレッドが再入可能ロックを獲得すると、同じスレッドはブロックされ
     ずにもう一度それを獲得できます ; そのスレッドは獲得した回数だけ解放
     しなければいけません。

     ‘RLock’ は実際にはファクトリ関数で、プラットフォームでサポートされ
     る最も効率的なバージョンの具体的な RLock クラスのインスタンスを返す
     ことに注意してください。

      -- メソッド: acquire (blocking=True, timeout=-1)

          ブロックあり、またはブロックなしでロックを獲得します。

          参考
          ....

          *note Using RLock as a context manager: 2fb9.

               Recommended over manual ‘acquire()’ and *note release():
               2fbd. calls whenever practical.

          When invoked with the 'blocking' argument set to ‘True’ (the
          default):

                  * If no thread owns the lock, acquire the lock and
                    return immediately.

                  * If another thread owns the lock, block until we are
                    able to acquire lock, or 'timeout', if set to a
                    positive float value.

                  * If the same thread owns the lock, acquire the lock
                    again, and return immediately.  This is the
                    difference between *note Lock: 15db. and ‘RLock’;
                    *note Lock: 15db. handles this case the same as the
                    previous, blocking until the lock can be acquired.

          When invoked with the 'blocking' argument set to ‘False’:

                  * If no thread owns the lock, acquire the lock and
                    return immediately.

                  * If another thread owns the lock, return immediately.

                  * If the same thread owns the lock, acquire the lock
                    again and return immediately.

          In all cases, if the thread was able to acquire the lock,
          return ‘True’.  If the thread was unable to acquire the lock
          (i.e.  if not blocking or the timeout was reached) return
          ‘False’.

          If called multiple times, failing to call *note release():
          2fbd. as many times may lead to deadlock.  Consider using
          ‘RLock’ as a context manager rather than calling
          acquire/release directly.

          バージョン 3.2 で変更: 新しい 'timeout' 引数。

      -- メソッド: release ()

          再帰レベルをデクリメントしてロックを解放します。デクリメント後
          に再帰レベルがゼロになった場合、ロックの状態をアンロック (いか
          なるスレッドにも所有されていない状態) にリセットし、ロックの状
          態がアンロックになるのを待ってブロックしているスレッドがある場
          合にはその中のただ一つだけが処理を進行できるようにします。デク
          リメント後も再帰レベルがゼロでない場合、ロックの状態はロックの
          ままで、呼び出し側のスレッドに所有されたままになります。

          Only call this method when the calling thread owns the lock.
          A *note RuntimeError: 17a. is raised if this method is called
          when the lock is not acquired.

          戻り値はありません。


File: python.info,  Node: Condition オブジェクト,  Next: Semaphore オブジェクト,  Prev: RLock オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.5 Condition オブジェクト
...............................

条件変数 (condition variable) は、常にある種のロックに関連付けられていま
す; このロックは明示的に渡すことも、デフォルトで生成させることもできます
。複数の条件変数で同じロックを共有しなければならない場合には、引渡しによ
る関連付けが便利です。ロックは条件オブジェクトの一部です: それを別々に扱
う必要はありません。

条件変数は *note コンテキスト管理プロトコル: 2fb9. に従います: ‘with’ 文
を使って囲まれたブロックの間だけ関連付けられたロックを獲得することができ
ます。 *note acquire(): 2fc0. メソッドと *note release(): 2fc1. メソッド
は、さらに関連付けられたロックの対応するメソッドを呼び出します。

他のメソッドは、関連付けられたロックを保持した状態で呼び出さなければなり
ません。 *note wait(): 181c. メソッドはロックを解放します。そして別のス
レッドが *note notify(): 1747. または *note notify_all(): 2db. を呼ぶこ
とによってスレッドを起こすまでブロックします。一旦起こされたなら、 *note
wait(): 181c. は再びロックを得て戻ります。タイムアウトを指定することも可
能です。

*note notify(): 1747. メソッドは条件変数待ちのスレッドを1つ起こします。
*note notify_all(): 2db. メソッドは条件変数待ちの全てのスレッドを起こし
ます。

注意: *note notify(): 1747. と *note notify_all(): 2db. はロックを解放し
ません; 従って、スレッドが起こされたとき、 *note wait(): 181c. の呼び出
しは即座に処理を戻すわけではなく、 *note notify(): 1747. または *note
notify_all(): 2db. を呼び出したスレッドが最終的にロックの所有権を放棄し
たときに初めて処理を返すのです。

条件変数を使う典型的なプログラミングスタイルでは、何らかの共有された状態
変数へのアクセスを同期させるためにロックを使います; 状態変数が特定の状態
に変化したことを知りたいスレッドは、自分の望む状態になるまで繰り返し
*note wait(): 181c. を呼び出します。その一方で、状態変更を行うスレッドは
、前者のスレッドが待ち望んでいる状態であるかもしれないような状態へ変更を
行ったときに *note notify(): 1747. や *note notify_all(): 2db. を呼び出
します。例えば、以下のコードは無制限のバッファ容量のときの一般的な生産者
-消費者問題です:

     # Consume one item
     with cv:
         while not an_item_is_available():
             cv.wait()
         get_an_available_item()

     # Produce one item
     with cv:
         make_an_item_available()
         cv.notify()

アプリケーションの条件をチェックする ‘while’ ループは必須です。なぜなら
、 *note wait(): 181c. が任意の長時間の後で返り、 *note notify(): 1747.
呼び出しを促した条件がもはや真でないことがありえるからです。これはマルチ
スレッドプログラミングに固有です。条件チェックを自動化するために *note
wait_for(): 2fc2. メソッドを使うことができ、それはタイムアウトの計算を簡
略化します:

     # Consume an item
     with cv:
         cv.wait_for(an_item_is_available)
         get_an_available_item()

*note notify(): 1747. と *note notify_all(): 2db. のどちらを使うかは、そ
の状態の変化に興味を持っている待ちスレッドが一つだけなのか、あるいは複数
なのかで考えます。例えば、典型的な生産者-消費者問題では、バッファに1つの
要素を加えた場合には消費者スレッドを 1 つしか起こさなくてかまいません。

 -- クラス: threading.Condition (lock=None)

     このクラスは条件変数 (condition variable) オブジェクトを実装します
     。条件変数を使うと、1つ以上のスレッドを別のスレッドの通知があるまで
     待機させておけます。

     'lock' に ‘None’ でない値を指定した場合、その値は *note Lock: 15db.
     または *note RLock: 2bf. オブジェクトでなければなりません。 この場
     合、 'lock' は根底にあるロックオブジェクトとして使われます。 それ以
     外の場合には、 *note RLock: 2bf. オブジェクトを新しく作成して使いま
     す。

     バージョン 3.3 で変更: ファクトリ関数からクラスに変更されました。

      -- メソッド: acquire (*args)

          根底にあるロックを獲得します。このメソッドは根底にあるロックの
          対応するメソッドを呼び出します。そのメソッドの戻り値を返します
          。

      -- メソッド: release ()

          根底にあるロックを解放します。このメソッドは根底にあるロックの
          対応するメソッドを呼び出します。戻り値はありません。

      -- メソッド: wait (timeout=None)

          通知 (notify) を受けるか、タイムアウトするまで待機します。呼び
          出し側のスレッドがロックを獲得していないときにこのメソッドを呼
          び出すと *note RuntimeError: 17a. が送出されます。

          このメソッドは根底にあるロックを解放し、他のスレッドが同じ条件
          変数に対して *note notify(): 1747. または *note notify_all():
          2db. を呼び出して現在のスレッドを起こすか、オプションのタイム
          アウトが発生するまでブロックします。一度スレッドが起こされると
          、再度ロックを獲得して処理を戻します。

          When the 'timeout' argument is present and not ‘None’, it
          should be a floating-point number specifying a timeout for the
          operation in seconds (or fractions thereof).

          根底にあるロックが *note RLock: 2bf. である場合、 *note
          release(): 2fc1. メソッドではロックは解放されません。というの
          も、ロックが再帰的に複数回獲得されている場合には、 *note
          release(): 2fc1. によって実際にアンロックが行われないかもしれ
          ないからです。その代わり、ロックが再帰的に複数回獲得されていて
          も確実にアンロックを行える *note RLock: 2bf. クラスの内部イン
          ターフェースを使います。その後ロックを再獲得する時に、もう一つ
          の内部インターフェースを使ってロックの再帰レベルを復帰します。

          与えられた 'timeout' が過ぎていなければ返り値は ‘True’ です。
          タイムアウトした場合には ‘False’ が返ります。

          バージョン 3.2 で変更: 以前は、このメソッドは常に ‘None’ を返
          していました。

      -- メソッド: wait_for (predicate, timeout=None)

          条件が真と判定されるまで待ちます。 'predicate' は呼び出し可能
          オブジェクトでなければならず、その結果はブール値として解釈され
          ます。 最大の待ち時間を指定する 'timeout' を与えることができま
          す。

          このユーティリティメソッドは、述語が満たされるかタイムアウトが
          発生するまで *note wait(): 181c. を繰り返し呼び出す場合があり
          ます。戻り値は述語の最後の戻り値で、もしメソッドがタイムアウト
          すれば、 ‘False’ と評価されます。

          タイムアウト機能を無視すれば、このメソッドの呼び出しは以下のよ
          うに書くのとほぼ等価です:

               while not predicate():
                   cv.wait()

          したがって、 *note wait(): 181c. と同じルールが適用されます: 呼
          び出された時にロックを保持していなければならず、戻るときにロッ
          クが再度獲得されます。述語はロックを保持した状態で評価されます
          。

          Added in version 3.2.

      -- メソッド: notify (n=1)

          デフォルトで、この条件変数を待っている1つのスレッドを起こしま
          す。 呼び出し側のスレッドがロックを獲得していないときにこのメ
          ソッドを呼び出すと *note RuntimeError: 17a. が送出されます。

          何らかの待機中スレッドがある場合、そのうち 'n' スレッドを起こ
          します。待機中のスレッドがなければ何もしません。

          現在の実装では、少なくとも 'n' スレッドが待機中であれば、ちょ
          うど 'n' スレッドを起こします。とはいえ、この挙動に依存するの
          は安全ではありません。将来、実装の最適化によって、複数のスレッ
          ドを起こすようになるかもしれないからです。

          注意: 起こされたスレッドは実際にロックを再獲得できるまで *note
          wait(): 181c. 呼び出しから戻りません。 *note notify(): 1747. は
          ロックを解放しないので、 *note notify(): 1747. 呼び出し側は明
          示的にロックを解放しなければなりません。

      -- メソッド: notify_all ()

          この条件を待っているすべてのスレッドを起こします。このメソッド
          は *note notify(): 1747. のように動作しますが、 1 つではなくす
          べての待ちスレッドを起こします。呼び出し側のスレッドがロックを
          獲得していない場合、 *note RuntimeError: 17a. が送出されます。

          関数''notifyAll''はこの関数の非推奨エイリアスです。


File: python.info,  Node: Semaphore オブジェクト,  Next: Event オブジェクト,  Prev: Condition オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.6 Semaphore オブジェクト
...............................

セマフォ (semaphore) は、計算機科学史上最も古い同期プリミティブの一つ で
、草創期のオランダ計算機科学者 Edsger W. Dijkstra によって発明されました
(彼は *note acquire(): 1225. と *note release(): 2fc5. の代わりに ‘P()’
と ‘V()’ を使いました)。

セマフォは *note acquire(): 1225. でデクリメントされ *note release():
2fc5. でインクリメントされるような内部カウンタを管理します。 カウンタは
決してゼロより小さくはなりません; *note acquire(): 1225. は、カウンタが
ゼロになっている場合、他のスレッドが *note release(): 2fc5. を呼び出すま
でブロックします。

セマフォは *note コンテキストマネージメントプロトコル: 2fb9. もサポート
します。

 -- クラス: threading.Semaphore (value=1)

     このクラスはセマフォ (semaphore) オブジェクトを実装します。セマフォ
     は、 *note release(): 2fc5. を呼び出した数から *note acquire():
     1225. を呼び出した数を引き、初期値を足した値を表す極小のカウンタを
     管理します。 *note acquire(): 1225. メソッドは、カウンタの値を負に
     せずに処理を戻せるまで必要ならば処理をブロックします。 'value' を指
     定しない場合、デフォルトの値は 1 になります。

     オプションの引数には、内部カウンタの初期値を指定します。デフォルト
     は ‘1’ です。与えられた 'value' が 0 より小さい場合、 *note
     ValueError: 1e3. が送出されます。

     バージョン 3.3 で変更: ファクトリ関数からクラスに変更されました。

      -- メソッド: acquire (blocking=True, timeout=None)

          セマフォを獲得します。

          When invoked without arguments:

             * If the internal counter is larger than zero on entry,
               decrement it by one and return ‘True’ immediately.

             * If the internal counter is zero on entry, block until
               awoken by a call to *note release(): 2fc5.  Once awoken
               (and the counter is greater than 0), decrement the
               counter by 1 and return ‘True’.  Exactly one thread will
               be awoken by each call to *note release(): 2fc5.  The
               order in which threads are awoken should not be relied
               on.

          'blocking' を ‘False’ にして呼び出すとブロックしません。引数な
          しで呼び出した場合にブロックするような状況であった場合には直ち
          に ‘False’ を返します。それ以外の場合には、引数なしで呼び出し
          たときと同じ処理を行い ‘True’ を返します。

          ‘None’ 以外の 'timeout' で起動された場合、最大で 'timeout' 秒
          ブロックします。 acquire が その間隔の間で完了しなかった場合は
          ‘False’ が返ります。そうでなければ ‘True’ が返ります。

          バージョン 3.2 で変更: 新しい 'timeout' 引数。

      -- メソッド: release (n=1)

          内部カウンタを 'n' インクリメントして、セマフォを解放します。
          ‘release()’ 処理に入ったときにカウンタがゼロであり、カウンタの
          値がゼロより大きくなるのを待っている別のスレッドがあった場合、
          それらのスレッドから 'n' 個を起こします。

          バージョン 3.9 で変更: 複数の待機中のスレッドを一度に解放する
          'n' パラメータを追加しました。

 -- クラス: threading.BoundedSemaphore (value=1)

     有限セマフォ (bounded semaphore) オブジェクトを実装しているクラスで
     す。有限セマフォは、現在の値が初期値を超過しないようチェックを行い
     ます。超過を起こした場合、 *note ValueError: 1e3. を送出します。た
     いていの場合、セマフォは限られた容量のリソースを保護するために使わ
     れるものです。従って、あまりにも頻繁なセマフォの解放はバグが生じて
     いるしるしです。 'value' を指定しない場合、デフォルトの値は 1 にな
     ります。

     バージョン 3.3 で変更: ファクトリ関数からクラスに変更されました。

* Menu:

* Semaphore の例::


File: python.info,  Node: Semaphore の例,  Up: Semaphore オブジェクト

5.17.1.7 ‘Semaphore’ の例
.........................

セマフォはしばしば、容量に限りのある資源、例えばデータベースサーバなどを
保護するために使われます。リソースが固定の状況では、常に有限セマフォを使
わなければなりません。主スレッドは、作業スレッドを立ち上げる前にセマフォ
を初期化します:

     maxconnections = 5
     # ...
     pool_sema = BoundedSemaphore(value=maxconnections)

作業スレッドは、ひとたび立ち上がると、サーバへ接続する必要が生じたときに
セマフォの ‘acquire()’ および ‘release()’ メソッドを呼び出します:

     with pool_sema:
         conn = connectdb()
         try:
             # ... use connection ...
         finally:
             conn.close()

有限セマフォを使うと、セマフォを獲得回数以上に解放してしまうというプログ
ラム上の間違いを見逃しにくくします。


File: python.info,  Node: Event オブジェクト,  Next: Timer オブジェクト,  Prev: Semaphore オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.8 Event オブジェクト
...........................

イベントは、あるスレッドがイベントを発信し、他のスレッドはそれを待つとい
う、スレッド間で通信を行うための最も単純なメカニズムの一つです。

イベントオブジェクトは内部フラグを管理します。このフラグは *note set():
2fca. メソッドで値を true に、 *note clear(): 2fcb. メソッドで値を false
にリセットします。 *note wait(): 12f5. メソッドはフラグが true になるま
でブロックします。

 -- クラス: threading.Event

     イベントオブジェクトを実装しているクラスです。イベントは *note
     set(): 2fca. メソッドを使うと *note True: bdb. に、 *note clear():
     2fcb. メソッドを使うと *note False: b05. にセットされるようなフラグ
     を管理します。 *note wait(): 12f5. メソッドは、全てのフラグが true
     になるまでブロックするようになっています。フラグの初期値は false で
     す。

     バージョン 3.3 で変更: ファクトリ関数からクラスに変更されました。

      -- メソッド: is_set ()

          内部フラグが真のとき ‘True’ を返します。

          メソッド ‘isSet’ はこのメソッドの非推奨エイリアスです。

      -- メソッド: set ()

          内部フラグの値を true にセットします。フラグの値が true になる
          のを待っている全てのスレッドを起こします。一旦フラグが true に
          なると、スレッドが *note wait(): 12f5. を呼び出しても全くブロ
          ックしなくなります。

      -- メソッド: clear ()

          内部フラグの値を false にリセットします。以降は、 *note set():
          2fca. を呼び出して再び内部フラグの値を true にセットするまで、
          *note wait(): 12f5. を呼び出したスレッドはブロックするようにな
          ります。

      -- メソッド: wait (timeout=None)

          Block as long as the internal flag is false and the timeout,
          if given, has not expired.  The return value represents the
          reason that this blocking method returned; ‘True’ if returning
          because the internal flag is set to true, or ‘False’ if a
          timeout is given and the internal flag did not become true
          within the given wait time.

          When the timeout argument is present and not ‘None’, it should
          be a floating-point number specifying a timeout for the
          operation in seconds, or fractions thereof.

          バージョン 3.1 で変更: 以前は、このメソッドは常に ‘None’ を返
          していました。


File: python.info,  Node: Timer オブジェクト,  Next: バリアオブジェクト,  Prev: Event オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.9 Timer オブジェクト
...........................

このクラスは、一定時間経過後に実行される活動、すなわちタイマ活動を表現し
ます。 *note Timer: 112c. は *note Thread: 91a. のサブクラスであり、自作
のスレッドを構築した一例でもあります。

Timers are started, as with threads, by calling their *note Timer.start:
2c7c. method.  The timer can be stopped (before its action has begun) by
calling the *note cancel(): 2fce. method.  The interval the timer will
wait before executing its action may not be exactly the same as the
interval specified by the user.

例えば:

     def hello():
         print("hello, world")

     t = Timer(30.0, hello)
     t.start()  # after 30 seconds, "hello, world" will be printed

 -- クラス: threading.Timer (interval, function, args=None, kwargs=None)

     'interval' 秒後に引数 'args' キーワード引数 'kwargs' で 'function'
     を実行するようなタイマを生成します。'args*が ''None'' (デフォルト)
     なら空のリストが使用されます。*kwargs' が ‘None’ (デフォルト) なら
     空の辞書が使用されます。

     バージョン 3.3 で変更: ファクトリ関数からクラスに変更されました。

      -- メソッド: cancel ()

          タイマをストップして、その動作の実行をキャンセルします。このメ
          ソッドはタイマがまだ活動待ち状態にある場合にのみ動作します。


File: python.info,  Node: バリアオブジェクト,  Next: with 文でのロック・条件変数・セマフォの使い方,  Prev: Timer オブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.10 バリアオブジェクト
............................

Added in version 3.2.

このクラスは、互いを待つ必要のある固定の数のスレッドで使用するための単純
な同期プリミティブを提供します。それぞれのスレッドは *note wait(): 2fd0.
メソッドを呼ぶことによりバリアを通ろうとしてブロックします。すべてのスレ
ッドがそれぞれの *note wait(): 2fd0. メソッドを呼び出した時点で、すべて
のスレッドが同時に解放されます。

バリアは同じ数のスレッドに対して何度でも再利用することができます。

例として、クライアントとサーバの間でスレッドを同期させる単純な方法を紹介
します:

     b = Barrier(2, timeout=5)

     def server():
         start_server()
         b.wait()
         while True:
             connection = accept_connection()
             process_server_connection(connection)

     def client():
         b.wait()
         while True:
             connection = make_connection()
             process_client_connection(connection)

 -- クラス: threading.Barrier (parties, action=None, timeout=None)

     'parties' 個のスレッドのためのバリアオブジェクトを作成します。
     'action' は、もし提供されるなら呼び出し可能オブジェクトで、スレッド
     が解放される時にそのうちの1つによって呼ばれます。 'timeout' は、
     *note wait(): 2fd0. メソッドに対して none が指定された場合のデフォ
     ルトのタイムアウト値です。

      -- メソッド: wait (timeout=None)

          バリアを通ります。バリアに対するすべてのスレッドがこの関数を呼
          んだ時に、それらは同時にすべて解放されます。'timeout' が提供さ
          れる場合、それはクラスコンストラクタに渡された値に優先して使用
          されます。

          返り値は 0 から 'parties' - 1 の範囲の整数で、それぞれのスレッ
          ドに対して異なります。これは、特別な後始末 (housekeeping) を行
          うスレッドを選択するために使用することができます。例えば:

               i = barrier.wait()
               if i == 0:
                   # Only one thread needs to print this
                   print("passed the barrier")

          'action' がコンストラクタに渡されていれば、スレッドのうちの1つ
          が解放される前にそれを呼び出します。万一この呼び出しでエラーが
          発生した場合、バリアは broken な状態に陥ります。

          この呼び出しがタイムアウトする場合、バリアは broken な状態に陥
          ります。

          スレッドが待っている間にバリアが broken になるかリセットされた
          場合、このメソッドは *note BrokenBarrierError: 11b6. 例外を送
          出するかもしれません。

      -- メソッド: reset ()

          バリアをデフォルトの空の状態に戻します。そのバリアの上で待って
          いるすべてのスレッドは *note BrokenBarrierError: 11b6. 例外を
          受け取ります。

          状態が未知の他のスレッドがある場合、この関数を使用するのに何ら
          かの外部同期を必要とするかもしれないことに注意してください。バ
          リアが broken な場合、単にそれをそのままにして新しいものを作成
          する方がよいでしょう。

      -- メソッド: abort ()

          バリアを broken な状態にします。これによって、現在または将来の
          *note wait(): 2fd0. 呼び出しが *note BrokenBarrierError: 11b6.
          とともに失敗するようになります。これを使うと、例えばスレッドが
          異常終了する必要がある場合にアプリケーションがデッドロックする
          のを避けることができます。

          スレッドのうちの1つが返ってこないことに対して自動的に保護する
          ように、単純に常識的な 'timeout' 値でバリアを作成することは望
          ましいかもしれません。

      -- の属性: parties

          バリアを通るために要求されるスレッドの数。

      -- の属性: n_waiting

          現在バリアの中で待っているスレッドの数。

      -- の属性: broken

          バリアが broken な状態である場合に ‘True’ となるブール値。

 -- 例外: threading.BrokenBarrierError

     *note Barrier: 11b4. オブジェクトがリセットされるか broken な場合に
     、この例外 (*note RuntimeError: 17a. のサブクラス) が送出されます。


File: python.info,  Node: with 文でのロック・条件変数・セマフォの使い方,  Prev: バリアオブジェクト,  Up: threading --- スレッドベースの並列処理

5.17.1.11 ‘with’ 文でのロック・条件変数・セマフォの使い方
.........................................................

All of the objects provided by this module that have ‘acquire’ and
‘release’ methods can be used as context managers for a *note with: 59c.
statement.  The ‘acquire’ method will be called when the block is
entered, and ‘release’ will be called when the block is exited.  Hence,
the following snippet:

     with some_lock:
         # do something...

は、以下と同じです

     some_lock.acquire()
     try:
         # do something...
     finally:
         some_lock.release()

現在のところ、 *note Lock: 15db. 、 *note RLock: 2bf. 、 *note
Condition: 1128. 、 *note Semaphore: 1129. 、 *note BoundedSemaphore:
112a. を *note with: 59c. 文のコンテキストマネージャとして使うことができ
ます。


File: python.info,  Node: multiprocessing --- プロセスベースの並列処理,  Next: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ,  Prev: threading --- スレッドベースの並列処理,  Up: 並行実行

5.17.2 ‘multiprocessing’ -- プロセスベースの並列処理
----------------------------------------------------

'ソースコード:' Lib/multiprocessing/(1)

__________________________________________________________________

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

* Menu:

* はじめに: はじめに<7>.
* リファレンス: リファレンス<2>.
* プログラミングガイドライン::
* 使用例: 使用例<20>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/multiprocessing/


File: python.info,  Node: はじめに<7>,  Next: リファレンス<2>,  Up: multiprocessing --- プロセスベースの並列処理

5.17.2.1 はじめに
.................

*note multiprocessing: 86. is a package that supports spawning processes
using an API similar to the *note threading: d6. module.  The *note
multiprocessing: 86. package offers both local and remote concurrency,
effectively side-stepping the *note Global Interpreter Lock: 12e. by
using subprocesses instead of threads.  Due to this, the *note
multiprocessing: 86. module allows the programmer to fully leverage
multiple processors on a given machine.  It runs on both POSIX and
Windows.

*note multiprocessing: 86. モジュールでは、*note threading: d6. モジュー
ルには似たものが存在しない API も導入されています。その最たるものが
*note Pool: f38. オブジェクトです。これは複数の入力データに対して、サブ
プロセス群に入力データを分配 (データ並列) して関数を並列実行するのに便利
な手段を提供します。以下の例では、モジュール内で関数を定義して、子プロセ
スがそのモジュールを正常にインポートできるようにする一般的な方法を示しま
す。 *note Pool: f38. を用いたデータ並列の基礎的な例は次の通りです:

     from multiprocessing import Pool

     def f(x):
         return x*x

     if __name__ == '__main__':
         with Pool(5) as p:
             print(p.map(f, [1, 2, 3]))

標準出力に以下が出力されます:

     [1, 4, 9]

参考
....

*note concurrent.futures.ProcessPoolExecutor: 8bc. offers a higher level
interface to push tasks to a background process without blocking
execution of the calling process.  Compared to using the *note Pool:
f38. interface directly, the *note concurrent.futures: 1a. API more
readily allows the submission of work to the underlying process pool to
be separated from waiting for the results.

* Menu:

* Process クラス::
* コンテキストと開始方式::
* プロセス間でのオブジェクト交換::
* プロセス間の同期::
* プロセス間での状態の共有::
* ワーカープロセスのプールを使用::


File: python.info,  Node: Process クラス,  Next: コンテキストと開始方式,  Up: はじめに<7>

5.17.2.2 ‘Process’ クラス
.........................

*note multiprocessing: 86. モジュールでは、プロセスは以下の手順によって
生成されます。はじめに *note Process: b27. のオブジェクトを作成し、続い
て *note start(): 2fdb. メソッドを呼び出します。この *note Process: b27.
クラスは *note threading.Thread: 91a. クラスと同様の API を持っています
。まずは、簡単な例をもとにマルチプロセスを使用したプログラムについてみて
いきましょう

     from multiprocessing import Process

     def f(name):
         print('hello', name)

     if __name__ == '__main__':
         p = Process(target=f, args=('bob',))
         p.start()
         p.join()

実行された個々のプロセス ID を表示するために拡張したサンプルコードを以下
に示します:

     from multiprocessing import Process
     import os

     def info(title):
         print(title)
         print('module name:', __name__)
         print('parent process:', os.getppid())
         print('process id:', os.getpid())

     def f(name):
         info('function f')
         print('hello', name)

     if __name__ == '__main__':
         info('main line')
         p = Process(target=f, args=('bob',))
         p.start()
         p.join()

なぜ ‘if __name__ == '__main__'’ という記述が必要かは *note
プログラミングガイドライン: 2fdc. を参照してください。


File: python.info,  Node: コンテキストと開始方式,  Next: プロセス間でのオブジェクト交換,  Prev: Process クラス,  Up: はじめに<7>

5.17.2.3 コンテキストと開始方式
...............................

プラットフォームにもよりますが、*note multiprocessing: 86. はプロセスを
開始するために 3 つの方法をサポートしています。それら '開始方式' は以下
のとおりです

     'spawn'

          親プロセスは新たに Python インタープリタープロセスを開始します
          。子プロセスはプロセスオブジェクトの *note run(): 2fde. メソッ
          ドの実行に必要なリソースのみ継承します。特に、親プロセスからの
          不要なファイル記述子とハンドルは継承されません。この方式を使用
          したプロセスの開始は 'fork' や 'forkserver' に比べ遅くなります
          。

          Available on POSIX and Windows platforms.  The default on
          Windows and macOS.

     'fork'

          親プロセスは *note os.fork(): 17c. を使用して Python インター
          プリターをフォークします。子プロセスはそれが開始されるとき、事
          実上親プロセスと同一になります。親プロセスのリソースはすべて子
          プロセスに継承されます。マルチスレッドプロセスのフォークは安全
          性に問題があることに注意してください。

          Available on POSIX systems.  Currently the default on POSIX
          except macOS.

               注釈: The default start method will change away from
               'fork' in Python 3.14.  Code that requires 'fork' should
               explicitly specify that via *note get_context(): 2a7. or
               *note set_start_method(): 2a8.

          バージョン 3.12 で変更: If Python is able to detect that your
          process has multiple threads, the *note os.fork(): 17c.
          function that this start method calls internally will raise a
          *note DeprecationWarning: 18a.  Use a different start method.
          See the *note os.fork(): 17c. documentation for further
          explanation.

     'forkserver'

          When the program starts and selects the 'forkserver' start
          method, a server process is spawned.  From then on, whenever a
          new process is needed, the parent process connects to the
          server and requests that it fork a new process.  The fork
          server process is single threaded unless system libraries or
          preloaded imports spawn threads as a side-effect so it is
          generally safe for it to use *note os.fork(): 17c.  No
          unnecessary resources are inherited.

          Available on POSIX platforms which support passing file
          descriptors over Unix pipes such as Linux.

バージョン 3.4 で変更: 'spawn' added on all POSIX platforms, and
'forkserver' added for some POSIX platforms.  Child processes no longer
inherit all of the parents inheritable handles on Windows.

バージョン 3.8 で変更: On macOS, the 'spawn' start method is now the
default.  The 'fork' start method should be considered unsafe as it can
lead to crashes of the subprocess as macOS system libraries may start
threads.  See bpo-33725(1).

On POSIX using the 'spawn' or 'forkserver' start methods will also start
a 'resource tracker' process which tracks the unlinked named system
resources (such as named semaphores or *note SharedMemory: 15bd.
objects) created by processes of the program.  When all processes have
exited the resource tracker unlinks any remaining tracked object.
Usually there should be none, but if a process was killed by a signal
there may be some "leaked" resources.  (Neither leaked semaphores nor
shared memory segments will be automatically unlinked until the next
reboot.  This is problematic for both objects because the system allows
only a limited number of named semaphores, and shared memory segments
occupy some space in the main memory.)

開始方式はメインモジュールの ‘if __name__ == '__main__'’ 節内で、関数
*note set_start_method(): 2a8. によって指定します。以下に例を示します:

     import multiprocessing as mp

     def foo(q):
         q.put('hello')

     if __name__ == '__main__':
         mp.set_start_method('spawn')
         q = mp.Queue()
         p = mp.Process(target=foo, args=(q,))
         p.start()
         print(q.get())
         p.join()

関数 *note set_start_method(): 2a8. はプログラム内で複数回使用してはいけ
ません。

もうひとつの方法として、*note get_context(): 2a7. を使用してコンテキスト
オブジェクトを取得することができます。コンテキストオブジェクトは
multiprocessing モジュールと同じ API を持ち、同じプログラム内で複数の開
始方式を使用できます。

     import multiprocessing as mp

     def foo(q):
         q.put('hello')

     if __name__ == '__main__':
         ctx = mp.get_context('spawn')
         q = ctx.Queue()
         p = ctx.Process(target=foo, args=(q,))
         p.start()
         print(q.get())
         p.join()

あるコンテキストに関連したオブジェクトは、異なるコンテキストのプロセスと
は互換性がない場合があることに注意してください。特に、'fork' コンテキス
トを使用して作成されたロックは、'spawn' あるいは 'forkserver' を使用して
開始されたプロセスに渡すことはできません。

特定の開始方式の使用を要求するライブラリは *note get_context(): 2a7. を
使用してライブラリ利用者の選択を阻害しないようにするべきです。

     警告: The ‘'spawn'’ and ‘'forkserver'’ start methods generally
     cannot be used with "frozen" executables (i.e., binaries produced
     by packages like 'PyInstaller' and 'cx_Freeze') on POSIX systems.
     The ‘'fork'’ start method may work if code does not use threads.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33725


File: python.info,  Node: プロセス間でのオブジェクト交換,  Next: プロセス間の同期,  Prev: コンテキストと開始方式,  Up: はじめに<7>

5.17.2.4 プロセス間でのオブジェクト交換
.......................................

*note multiprocessing: 86. モジュールでは、プロセス間通信の手段が2つ用意
されています。それぞれ以下に詳細を示します:

'キュー (Queue)'

     *note Queue: 1767. クラスは *note queue.Queue: 1356. クラスとほとん
     ど同じように使うことができます。以下に例を示します:

          from multiprocessing import Process, Queue

          def f(q):
              q.put([42, None, 'hello'])

          if __name__ == '__main__':
              q = Queue()
              p = Process(target=f, args=(q,))
              p.start()
              print(q.get())    # prints "[42, None, 'hello']"
              p.join()

     Queues are thread and process safe.  Any object put into a *note
     multiprocessing: 86. queue will be serialized.

'パイプ (Pipe)'

     *note Pipe(): 2fe0. 関数はパイプで繋がれたコネクションオブジェクト
     のペアを返します。デフォルトでは双方向性パイプを返します。以下に例
     を示します:

          from multiprocessing import Process, Pipe

          def f(conn):
              conn.send([42, None, 'hello'])
              conn.close()

          if __name__ == '__main__':
              parent_conn, child_conn = Pipe()
              p = Process(target=f, args=(child_conn,))
              p.start()
              print(parent_conn.recv())   # prints "[42, None, 'hello']"
              p.join()

     パイプのそれぞれの端を表す2つのコネクションオブジェクトが *note
     Pipe(): 2fe0. 関数から返されます。各コネクションオブジェクトには、
     ‘send()’、 ‘recv()’、その他のメソッドがあります。2つのプロセス (ま
     たはスレッド) がパイプの '同じ' 端で同時に読み込みや書き込みを行う
     と、パイプ内のデータが破損してしまうかもしれないことに注意してくだ
     さい。もちろん、各プロセスがパイプの別々の端を同時に使用するならば
     、データが破壊される危険性はありません。

     The ‘send()’ method serializes the the object and ‘recv()’
     re-creates the object.


File: python.info,  Node: プロセス間の同期,  Next: プロセス間での状態の共有,  Prev: プロセス間でのオブジェクト交換,  Up: はじめに<7>

5.17.2.5 プロセス間の同期
.........................

*note multiprocessing: 86. は *note threading: d6. モジュールと等価な同
期プリミティブを備えています。以下の例では、ロックを使用して、一度に1つ
のプロセスしか標準出力に書き込まないようにしています:

     from multiprocessing import Process, Lock

     def f(l, i):
         l.acquire()
         try:
             print('hello world', i)
         finally:
             l.release()

     if __name__ == '__main__':
         lock = Lock()

         for num in range(10):
             Process(target=f, args=(lock, num)).start()

ロックを使用しないで標準出力に書き込んだ場合は、各プロセスからの出力がご
ちゃまぜになってしまいます。


File: python.info,  Node: プロセス間での状態の共有,  Next: ワーカープロセスのプールを使用,  Prev: プロセス間の同期,  Up: はじめに<7>

5.17.2.6 プロセス間での状態の共有
.................................

これまでの話の流れで触れたとおり、並行プログラミングを行うときには、でき
るかぎり状態を共有しないのが定石です。複数のプロセスを使用するときは特に
そうでしょう。

しかし、どうしてもプロセス間のデータ共有が必要な場合のために *note
multiprocessing: 86. モジュールには2つの方法が用意されています。

'共有メモリ (Shared memory)'

     データを共有メモリ上に保持するために *note Value: 2fe3. クラス、も
     しくは *note Array: 2fe4. クラスを使用することができます。以下のサ
     ンプルコードを使って、この機能についてみていきましょう

          from multiprocessing import Process, Value, Array

          def f(n, a):
              n.value = 3.1415927
              for i in range(len(a)):
                  a[i] = -a[i]

          if __name__ == '__main__':
              num = Value('d', 0.0)
              arr = Array('i', range(10))

              p = Process(target=f, args=(num, arr))
              p.start()
              p.join()

              print(num.value)
              print(arr[:])

     このサンプルコードを実行すると以下のように表示されます

          3.1415927
          [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]

     ‘num’ と ‘arr’ を生成するときに使用されている、引数 ‘'d'’ と ‘'i'’
     は *note array: 6. モジュールにより使用される種別の型コードです。こ
     こで使用されている ‘'d'’ は倍精度浮動小数、 ‘'i'’ は符号付整数を表
     します。これらの共有オブジェクトは、プロセスセーフでありスレッドセ
     ーフです。

     共有メモリを使用して、さらに柔軟なプログラミングを行うには *note
     multiprocessing.sharedctypes: 8c. モジュールを使用します。このモジ
     ュールは共有メモリから割り当てられた任意の ctypes オブジェクトの生
     成をサポートします。

'サーバープロセス (Server process)'

     *note Manager(): c88. 関数により生成されたマネージャーオブジェクト
     はサーバープロセスを管理します。マネージャーオブジェクトは Python の
     オブジェクトを保持して、他のプロセスがプロキシ経由でその Python オ
     ブジェクトを操作することができます。

     *note Manager(): c88. 関数が返すマネージャは *note list: 5dc, *note
     dict: 237, *note Namespace: 2fe5, *note Lock: 1504, *note RLock:
     1505, *note Semaphore: 2fe6, *note BoundedSemaphore: 2fe7, *note
     Condition: 2fe8, *note Event: 17ce, *note Barrier: 2fe9, *note
     Queue: 1767, *note Value: 2fe3, *note Array: 2fe4. をサポートします
     。 以下にサンプルコードを示します。

          from multiprocessing import Process, Manager

          def f(d, l):
              d[1] = '1'
              d['2'] = 2
              d[0.25] = None
              l.reverse()

          if __name__ == '__main__':
              with Manager() as manager:
                  d = manager.dict()
                  l = manager.list(range(10))

                  p = Process(target=f, args=(d, l))
                  p.start()
                  p.join()

                  print(d)
                  print(l)

     このサンプルコードを実行すると以下のように表示されます

          {0.25: None, 1: '1', '2': 2}
          [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]

     サーバープロセスのマネージャーオブジェクトは共有メモリのオブジェク
     トよりも柔軟であるといえます。それは、どのような型のオブジェクトで
     も使えるからです。また、1つのマネージャーオブジェクトはネットワーク
     経由で他のコンピューター上のプロセスによって共有することもできます
     。しかし、共有メモリより動作が遅いという欠点があります。


File: python.info,  Node: ワーカープロセスのプールを使用,  Prev: プロセス間での状態の共有,  Up: はじめに<7>

5.17.2.7 ワーカープロセスのプールを使用
.......................................

*note Pool: f38. クラスは、ワーカープロセスをプールする機能を備えていま
す。このクラスには、異なる方法でワーカープロセスへタスクを割り当てるいく
つかのメソッドがあります。

例えば:

     from multiprocessing import Pool, TimeoutError
     import time
     import os

     def f(x):
         return x*x

     if __name__ == '__main__':
         # start 4 worker processes
         with Pool(processes=4) as pool:

             # print "[0, 1, 4,..., 81]"
             print(pool.map(f, range(10)))

             # print same numbers in arbitrary order
             for i in pool.imap_unordered(f, range(10)):
                 print(i)

             # evaluate "f(20)" asynchronously
             res = pool.apply_async(f, (20,))      # runs in *only* one process
             print(res.get(timeout=1))             # prints "400"

             # evaluate "os.getpid()" asynchronously
             res = pool.apply_async(os.getpid, ()) # runs in *only* one process
             print(res.get(timeout=1))             # prints the PID of that process

             # launching multiple evaluations asynchronously *may* use more processes
             multiple_results = [pool.apply_async(os.getpid, ()) for i in range(4)]
             print([res.get(timeout=1) for res in multiple_results])

             # make a single worker sleep for 10 seconds
             res = pool.apply_async(time.sleep, (10,))
             try:
                 print(res.get(timeout=1))
             except TimeoutError:
                 print("We lacked patience and got a multiprocessing.TimeoutError")

             print("For the moment, the pool remains available for more work")

         # exiting the 'with'-block has stopped the pool
         print("Now the pool is closed and no longer available")

プールオブジェクトのメソッドは、そのプールを作成したプロセスのみが呼び出
すべきです。

     注釈: このパッケージに含まれる機能を使用するためには、子プロセスか
     ら ‘__main__’ モジュールをインポートできる必要があります。このこと
     については *note プログラミングガイドライン: 2fdc. で触れていますが
     、ここであらためて強調しておきます。なぜかというと、いくつかのサン
     プルコード、例えば *note multiprocessing.pool.Pool: f38. のサンプル
     はインタラクティブシェル上では動作しないからです。以下に例を示しま
     す:

          >>> from multiprocessing import Pool
          >>> p = Pool(5)
          >>> def f(x):
          ...     return x*x
          ...
          >>> with p:
          ...     p.map(f, [1,2,3])
          Process PoolWorker-1:
          Process PoolWorker-2:
          Process PoolWorker-3:
          Traceback (most recent call last):
          Traceback (most recent call last):
          Traceback (most recent call last):
          AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
          AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>
          AttributeError: Can't get attribute 'f' on <module '__main__' (<class '_frozen_importlib.BuiltinImporter'>)>

     (もしこのコードを試すなら、実際には3つの完全なトレースバックがばら
     ばらの順番で出力されますし、親プロセスを何らかの方法で止める必要が
     あります。)


File: python.info,  Node: リファレンス<2>,  Next: プログラミングガイドライン,  Prev: はじめに<7>,  Up: multiprocessing --- プロセスベースの並列処理

5.17.2.8 リファレンス
.....................

*note multiprocessing: 86. パッケージは *note threading: d6. モジュール
の API とほとんど同じです。

* Menu:

* Process クラスと例外::
* パイプ (Pipe) とキュー (Queue): パイプ Pipe とキュー Queue.
* その他: その他<3>.
* Connection オブジェクト: Connection オブジェクト<2>.
* 同期プリミティブ::
* 共有 ctypes オブジェクト::
* マネージャー::
* Proxy オブジェクト::
* プロセスプール::
* リスナーとクライアント::
* 認証キー::
* ログ記録: ログ記録<2>.
* multiprocessing.dummy モジュール: multiprocessing dummy モジュール.


File: python.info,  Node: Process クラスと例外,  Next: パイプ Pipe とキュー Queue,  Up: リファレンス<2>

5.17.2.9 ‘Process’ クラスと例外
...............................

 -- クラス: multiprocessing.Process (group=None, target=None, name=None,
          args=(), kwargs={}, *, daemon=None)

     Process オブジェクトは各プロセスの処理を表します。 *note Process:
     b27. クラスは *note threading.Thread: 91a. クラスのすべてのメソッド
     と同じインターフェースを提供します。

     The constructor should always be called with keyword arguments.
     'group' should always be ‘None’; it exists solely for compatibility
     with *note threading.Thread: 91a.  'target' is the callable object
     to be invoked by the *note run(): 2fde. method.  It defaults to
     ‘None’, meaning nothing is called.  'name' is the process name (see
     *note name: 2fed. for more details).  'args' is the argument tuple
     for the target invocation.  'kwargs' is a dictionary of keyword
     arguments for the target invocation.  If provided, the keyword-only
     'daemon' argument sets the process *note daemon: 2fee. flag to
     ‘True’ or ‘False’.  If ‘None’ (the default), this flag will be
     inherited from the creating process.

     デフォルトでは、'target' に何の引数も与えられません。(実) 引数
     'args' (デフォルトは''()'')は、'target' に渡す引数のリストまたはタ
     プルを指定するために使用されます。

     サブクラスがコンストラクターをオーバーライドする場合は、そのプロセ
     スに対する処理を行う前に基底クラスのコンストラクター
     (‘Process.__init__()’) を実行しなければなりません。

     バージョン 3.3 で変更: Added the 'daemon' parameter.

      -- メソッド: run ()

          プロセスが実行する処理を表すメソッドです。

          このメソッドはサブクラスでオーバーライドすることができます。標
          準の *note run(): 2fde. メソッドは、コンストラクターの target
          引数として渡された呼び出し可能オブジェクトを呼び出します。もし
          コンストラクターに 'args' もしくは 'kwargs' 引数が渡されていれ
          ば、呼び出すオブジェクトにこれらの引数を渡します。

          *note Process: b27. に渡される 'args' の引数にリストやタプルを
          使っても、同じ効果が得られます。

          以下はプログラム例です:

               >>> from multiprocessing import Process
               >>> p = Process(target=print, args=[1])
               >>> p.run()
               1
               >>> p = Process(target=print, args=(1,))
               >>> p.run()
               1

      -- メソッド: start ()

          プロセスの処理を開始するためのメソッドです。

          各 Process オブジェクトに対し、このメソッドが2回以上呼び出され
          てはいけません。各プロセスでオブジェクトの *note run(): 2fde.
          メソッドを呼び出す準備を行います。

      -- メソッド: join ([timeout])

          オプションの引数 'timeout' が ‘None’ (デフォルト) の場合、
          *note join(): 2fef. メソッドが呼ばれたプロセスは処理が終了する
          までブロックします。 'timeout' が正の数である場合、最大
          'timeout' 秒ブロックします。 プロセスが終了あるいはタイムアウ
          トした場合、メソッドは ‘None’ を返すことに注意してください。 プ
          ロセスの *note exitcode: 2ff0. を確認し終了したかどうかを判断
          してください。

          1つのプロセスは何回も join されることができます。

          プロセスは自分自身を join することはできません。それはデッドロ
          ックを引き起こすことがあるからです。プロセスが start される前
          に join しようとするとエラーが発生します。

      -- の属性: name

          プロセスの名前。名前は識別のためだけに使用される文字列です。そ
          れ自体には特別な意味はありません。複数のプロセスに同じ名前が与
          えられても構いません。

          最初の名前はコンストラクターによってセットされます。コンストラ
          クターに明示的な名前が渡されない場合、
          'Process-N[1]:N[2]:...:N[k]' 形式の名前が構築されます。ここで
          それぞれの N[k] はその親のN番目の子供です。

      -- メソッド: is_alive ()

          プロセスが実行中かを判別します。

          おおまかに言って、プロセスオブジェクトは *note start(): 2fdb.
          メソッドを呼び出してから子プロセス終了までの期間が実行中となり
          ます。

      -- の属性: daemon

          デーモンプロセスであるかのフラグであり、ブール値です。この属性
          は *note start(): 2fdb. が呼び出される前に設定されている必要が
          あります。

          初期値は作成するプロセスから継承します。

          あるプロセスが終了するとき、そのプロセスはその子プロセスである
          デーモンプロセスすべてを終了させようとします。

          デーモンプロセスは子プロセスを作成できないことに注意してくださ
          い。もし作成できてしまうと、そのデーモンプロセスの親プロセスが
          終了したときにデーモンプロセスの子プロセスが孤児になってしまう
          場合があるからです。さらに言えば、デーモンプロセスはUnix デー
          モンやサービスでは 'なく' 通常のプロセスであり、非デーモンプロ
          セスが終了すると終了されます (そして join されません)。

     *note threading.Thread: 91a. クラスの API に加えて *note Process:
     b27. クラスのオブジェクトには以下の属性およびメソッドがあります:

      -- の属性: pid

          プロセスIDを返します。プロセスの生成前は ‘None’ が設定されてい
          ます。

      -- の属性: exitcode

          The child's exit code.  This will be ‘None’ if the process has
          not yet terminated.

          If the child's *note run(): 2fde. method returned normally,
          the exit code will be 0.  If it terminated via *note
          sys.exit(): 1318. with an integer argument 'N', the exit code
          will be 'N'.

          If the child terminated due to an exception not caught within
          *note run(): 2fde, the exit code will be 1.  If it was
          terminated by signal 'N', the exit code will be the negative
          value '-N'.

      -- の属性: authkey

          プロセスの認証キーです (バイト文字列です)。

          *note multiprocessing: 86. モジュールがメインプロセスにより初
          期化される場合には、 *note os.urandom(): 4ec. 関数を使用してラ
          ンダムな値が設定されます。

          *note Process: b27. クラスのオブジェクトの作成時にその親プロセ
          スから認証キーを継承します。もしくは *note authkey: 2ff3. に別
          のバイト文字列を設定することもできます。

          詳細は *note 認証キー: 2ff4. を参照してください。

      -- の属性: sentinel

          プロセスが終了するときに "ready" となるシステムオブジェクトの
          数値ハンドル。

          You can use this value if you want to wait on several events
          at once using *note multiprocessing.connection.wait(): 10b3.
          Otherwise calling *note join(): 2fef. is simpler.

          On Windows, this is an OS handle usable with the
          ‘WaitForSingleObject’ and ‘WaitForMultipleObjects’ family of
          API calls.  On POSIX, this is a file descriptor usable with
          primitives from the *note select: af. module.

          Added in version 3.3.

      -- メソッド: terminate ()

          Terminate the process.  On POSIX this is done using the *note
          SIGTERM: 1387. signal; on Windows ‘TerminateProcess()’ is
          used.  Note that exit handlers and finally clauses, etc., will
          not be executed.

          このメソッドにより終了するプロセスの子孫プロセスは、終了 'しま
          せん' 。そういった子孫プロセスは単純に孤児になります。

               警告: このメソッドの使用時に、関連付けられたプロセスがパ
               イプやキューを使用している場合には、使用中のパイプやキュ
               ーが破損して他のプロセスから使用できなくなる可能性があり
               ます。同様に、プロセスがロックやセマフォなどを取得してい
               る場合には、このプロセスが終了してしまうと他のプロセスの
               デッドロックの原因になるでしょう。

      -- メソッド: kill ()

          Same as *note terminate(): 2ff5. but using the ‘SIGKILL’
          signal on POSIX.

          Added in version 3.7.

      -- メソッド: close ()

          *note Process: b27. オブジェクトを閉じ、関連付けられていたすべ
          てのリソースを開放します。中のプロセスが実行中であった場合、
          *note ValueError: 1e3. を送出します。*note close(): b25. が成
          功した場合、*note Process: b27. オブジェクトの他のメソッドや属
          性は、ほとんどが *note ValueError: 1e3. を送出します。

          Added in version 3.7.

     プロセスオブジェクトが作成したプロセスのみが *note start(): 2fdb,
     *note join(): 2fef, *note is_alive(): 2ff1, *note terminate():
     2ff5. と *note exitcode: 2ff0. のメソッドを呼び出すべきです。

     以下の例では *note Process: b27. のメソッドの使い方を示しています:

          >>> import multiprocessing, time, signal
          >>> mp_context = multiprocessing.get_context('spawn')
          >>> p = mp_context.Process(target=time.sleep, args=(1000,))
          >>> print(p, p.is_alive())
          <...Process ... initial> False
          >>> p.start()
          >>> print(p, p.is_alive())
          <...Process ... started> True
          >>> p.terminate()
          >>> time.sleep(0.1)
          >>> print(p, p.is_alive())
          <...Process ... stopped exitcode=-SIGTERM> False
          >>> p.exitcode == -signal.SIGTERM
          True

 -- 例外: multiprocessing.ProcessError

     すべての *note multiprocessing: 86. 例外の基底クラスです。

 -- 例外: multiprocessing.BufferTooShort

     Exception raised by ‘Connection.recv_bytes_into()’ when the
     supplied buffer object is too small for the message read.

     ‘e’ が *note BufferTooShort: 2ff7. のインスタンスであるとすると、
     ‘e.args[0]’ はそのメッセージをバイト文字列で与えるものです。

 -- 例外: multiprocessing.AuthenticationError

     認証エラーがあった場合に送出されます。

 -- 例外: multiprocessing.TimeoutError

     タイムアウトをサポートするメソッドでタイムアウトが過ぎたときに送出
     されます。


File: python.info,  Node: パイプ Pipe とキュー Queue,  Next: その他<3>,  Prev: Process クラスと例外,  Up: リファレンス<2>

5.17.2.10 パイプ (Pipe) とキュー (Queue)
........................................

複数のプロセスを使う場合、一般的にはメッセージパッシングをプロセス間通信
に使用し、ロックのような同期プリミティブを使用しないようにします。

メッセージのやりとりのために *note Pipe(): 2fe0. (2つのプロセス間の通信
用)、もしくはキュー (複数のメッセージ生成プロセス (producer)、消費プロセ
ス (consumer) の実現用) を使うことができます。

*note Queue: 1767, *note SimpleQueue: 8e2. と *note JoinableQueue: 2ffb.
型は複数プロセスから生成/消費を行う FIFO キューです。これらのキューは標
準ライブラリの *note queue.Queue: 1356. を模倣しています。 *note Queue:
1767. には Python 2.5 の *note queue.Queue: 1356. クラスで導入された
*note task_done(): 2ffc. と *note join(): 2ffd. メソッドがないことが違う
点です。

もし *note JoinableQueue: 2ffb. を使用するなら、キューから削除される各タ
スクのために *note JoinableQueue.task_done(): 2ffe. を呼び出さなければ
'なりません' 。さもないと、いつか完了していないタスクを数えるためのセマ
フォがオーバーフローし、例外を発生させるでしょう。

One difference from other Python queue implementations, is that *note
multiprocessing: 86. queues serializes all objects that are put into
them using *note pickle: 95.  The object return by the get method is a
re-created object that does not share memory with the original object.

管理オブジェクトを使用することで共有キューを作成できることも覚えておいて
ください。詳細は *note マネージャー: 2fff. を参照してください。

     注釈: *note multiprocessing: 86. は、タイムアウトを伝えるために、通
     常の *note queue.Empty: 3000. と *note queue.Full: 3001. 例外を使用
     します。それらは *note multiprocessing: 86. の名前空間では利用でき
     ないため、*note queue: a4. からインポートする必要があります。

     注釈: オブジェクトがキューに追加される際、そのオブジェクトは pickle
     化されています。そのため、バックグラウンドのスレッドが後になって下
     位層のパイプに pickle 化されたデータをフラッシュすることがあります
     。これにより、少し驚くような結果になりますが、実際に問題になること
     はないはずです。これが問題になるような状況では、かわりに *note
     manager: 2fff. を使ってキューを作成することができるからです。

       1. 空のキューの中にオブジェクトを追加した後、キューの *note
          empty(): 155e. メソッドが *note False: b05. を返すまでの間にご
          くわずかな遅延が起きることがあり、*note get_nowait(): 3002. が
          *note queue.Empty: 3000. を発生させることなく制御が呼び出し元
          に返ってしまうことがあります。

       2. 複数のプロセスがオブジェクトをキューに詰めている場合、キューの
          反対側ではオブジェクトが詰められたのとは違う順序で取得される可
          能性があります。ただし、同一のプロセスから詰め込まれたオブジェ
          クトは、それらのオブジェクト間では、必ず期待どおりの順序になり
          ます。

     警告: *note Queue: 1767. を利用しようとしている最中にプロセスを
     *note Process.terminate(): 2ff5. や *note os.kill(): 132f. で終了さ
     せる場合、キューにあるデータは破損し易くなります。終了した後で他の
     プロセスがキューを利用しようとすると、例外を発生させる可能性があり
     ます。

     警告: 上述したように、もし子プロセスがキューへ要素を追加するなら (か
     つ *note JoinableQueue.cancel_join_thread: 3003. を使用しないなら)
     そのプロセスはバッファーされたすべての要素がパイプへフラッシュされ
     るまで終了しません。

     これは、そのプロセスを join しようとする場合、キューに追加されたす
     べての要素が消費されたことが確実でないかぎり、デッドロックを発生さ
     せる可能性があることを意味します。似たような現象で、子プロセスが非
     デーモンプロセスの場合、親プロセスは終了時に非デーモンのすべての子
     プロセスを join しようとしてハングアップする可能性があります。

     マネージャーを使用して作成されたキューではこの問題はありません。詳
     細は *note プログラミングガイドライン: 2fdc. を参照してください。

プロセス間通信におけるキューの使用例を知りたいなら *note 使用例: 3004. を
参照してください。

 -- の関数: multiprocessing.Pipe ([duplex])

     パイプの両端を表す *note Connection: 160e. オブジェクトのペア
     ‘(conn1, conn2)’ を返します。

     'duplex' が ‘True’ (デフォルト) ならパイプは双方向性です。'duplex'
     が ‘False’ ならパイプは一方向性で、‘conn1’ はメッセージの受信専用、
     ‘conn2’ はメッセージの送信専用になります。

     The ‘send()’ method serializes the the object using *note pickle:
     95. and the ‘recv()’ re-creates the object.

 -- クラス: multiprocessing.Queue ([maxsize])

     パイプや2～3個のロック/セマフォを使用して実装されたプロセス共有キュ
     ーを返します。あるプロセスが最初に要素をキューへ追加するとき、バッ
     ファーからパイプの中へオブジェクトを転送する供給スレッドが開始され
     ます。

     標準ライブラリの *note queue: a4. モジュールの通常の *note
     queue.Empty: 3000. や *note queue.Full: 3001. 例外がタイムアウトを
     伝えるために送出されます。

     *note Queue: 1767. は *note task_done(): 2ffc. や *note join():
     2ffd. を除く *note queue.Queue: 1356. のすべてのメソッドを実装しま
     す。

      -- メソッド: qsize ()

          おおよそのキューのサイズを返します。マルチスレッディング/マル
          チプロセスの特性上、この数値は信用できません。

          Note that this may raise *note NotImplementedError: 209. on
          platforms like macOS where ‘sem_getvalue()’ is not
          implemented.

      -- メソッド: empty ()

          キューが空っぽなら ‘True’ を、そうでなければ ‘False’ を返しま
          す。マルチスレッディング/マルチプロセシングの特性上、これは信
          用できません。

          May raise an *note OSError: 3f0. on closed queues.  (not
          guaranteed)

      -- メソッド: full ()

          キューがいっぱいなら ‘True’ を、そうでなければ ‘False’ を返し
          ます。マルチスレッディング/マルチプロセシングの特性上、これは
          信用できません。

      -- メソッド: put (obj[, block[, timeout]])

          キューの中へ obj を追加します。オプションの引数 'block' が
          ‘True’ (デフォルト) 且つ 'timeout' が ‘None’ (デフォルト) なら
          、空きスロットが利用可能になるまで必要であればブロックします。
          'timeout' が正の数なら、最大 'timeout' 秒ブロックして、その時
          間内に空きスロットが利用できなかったら *note queue.Full: 3001.
          例外を発生させます。それ以外 ('block' が ‘False’) で、空きスロ
          ットがすぐに利用可能な場合はキューに要素を追加します。そうでな
          ければ *note queue.Full: 3001. 例外が発生します(その場合
          'timeout' は無視されます)。

          バージョン 3.8 で変更: If the queue is closed, *note
          ValueError: 1e3. is raised instead of *note AssertionError:
          675.

      -- メソッド: put_nowait (obj)

          ‘put(obj, False)’ と等価です。

      -- メソッド: get ([block[, timeout]])

          キューから要素を取り出して削除します。オプションの引数 'block'
          が ‘True’ (デフォルト) 且つ 'timeout' が ‘None’ (デフォルト) な
          ら、要素が取り出せるまで必要であればブロックします。 'timeout'
          が正の数なら、最大 'timeout' 秒ブロックして、その時間内に要素
          が取り出せなかったら *note queue.Empty: 3000. 例外を発生させま
          す。それ以外 ('block' が ‘False’) で、要素がすぐに取り出せる場
          合は要素を返します。そうでなければ *note queue.Empty: 3000. 例
          外が発生します(その場合 'timeout' は無視されます)。

          バージョン 3.8 で変更: If the queue is closed, *note
          ValueError: 1e3. is raised instead of *note OSError: 3f0.

      -- メソッド: get_nowait ()

          ‘get(False)’ と等価です。

     *note multiprocessing.Queue: 1767. は *note queue.Queue: 1356. には
     ない追加メソッドがあります。 これらのメソッドは通常、ほとんどのコー
     ドに必要ありません:

      -- メソッド: close ()

          カレントプロセスからこのキューへそれ以上データが追加されないこ
          とを表します。バックグラウンドスレッドはパイプへバッファーされ
          たすべてのデータをフラッシュするとすぐに終了します。これはキュ
          ーがガベージコレクトされるときに自動的に呼び出されます。

      -- メソッド: join_thread ()

          バックグラウンドスレッドを join します。このメソッドは *note
          close(): 1768. が呼び出された後でのみ使用されます。バッファー
          されたすべてのデータがパイプへフラッシュされるのを保証するため
          、バックグラウンドスレッドが終了するまでブロックします。

          デフォルトでは、あるプロセスがキューを作成していない場合、終了
          時にキューのバックグラウンドスレッドを join しようとします。そ
          のプロセスは *note join_thread(): 3008. が何もしないように
          *note cancel_join_thread(): 3003. を呼び出すことができます。

      -- メソッド: cancel_join_thread ()

          *note join_thread(): 3008. がブロッキングするのを防ぎます。特
          にこれはバックグラウンドスレッドがそのプロセスの終了時に自動的
          に join されるのを防ぎます。詳細は *note join_thread(): 3008.
          を参照してください。

          このメソッドは ‘allow_exit_without_flush()’ という名前のほうが
          よかったかもしれません。キューに追加されたデータが失われてしま
          いがちなため、このメソッドを使う必要はほぼ確実にないでしょう。
          本当にこれが必要になるのは、キューに追加されたデータを下位層の
          パイプにフラッシュすることなくカレントプロセスを直ちに終了する
          必要があり、かつ失われるデータに関心がない場合です。

          注釈: このクラスに含まれる機能には、ホストとなるオペレーティン
          グシステム上で動作している共有セマフォ (shared semaphore) を使
          用しているものがあります。これが使用できない場合には、このクラ
          スが無効になり、 *note Queue: 1767. をインスタンス化する時に
          *note ImportError: 3f2. が発生します。詳細は bpo-3770(1) を参
          照してください。同様のことが、以下に列挙されている特殊なキュー
          でも成り立ちます。

 -- クラス: multiprocessing.SimpleQueue

     単純化された *note Queue: 1767. 型です。ロックされた *note Pipe:
     2fe0. と非常に似ています。

      -- メソッド: close ()

          Close the queue: release internal resources.

          A queue must not be used anymore after it is closed.  For
          example, *note get(): 3009, *note put(): 300a. and *note
          empty(): 155f. methods must no longer be called.

          Added in version 3.9.

      -- メソッド: empty ()

          キューが空ならば ‘True’ を、そうでなければ ‘False’ を返します
          。

          Always raises an *note OSError: 3f0. if the SimpleQueue is
          closed.

      -- メソッド: get ()

          キューから要素を削除して返します。

      -- メソッド: put (item)

          'item' をキューに追加します。

 -- クラス: multiprocessing.JoinableQueue ([maxsize])

     *note JoinableQueue: 2ffb. は *note Queue: 1767. のサブクラスであり
     、 *note task_done(): 2ffe. や *note join(): 300b. メソッドが追加さ
     れているキューです。

      -- メソッド: task_done ()

          以前にキューへ追加されたタスクが完了したことを表します。キュー
          のコンシューマによって使用されます。 タスクをフェッチするため
          に使用されるそれぞれの *note get(): 19a8. に対して、 後続の
          *note task_done(): 2ffe. 呼び出しはタスクの処理が完了したこと
          をキューへ伝えます。

          もし *note join(): 2ffd. がブロッキング状態なら、 すべての要素
          が処理されたときに復帰します( *note task_done(): 2ffe. 呼び出
          しが すべての要素からキュー内へ *note put(): 19a7. されたと受
          け取ったことを意味します)。

          キューにある要素より多く呼び出された場合 *note ValueError:
          1e3. が発生します。

      -- メソッド: join ()

          キューにあるすべてのアイテムが取り出されて処理されるまでブロッ
          クします。

          キューに要素が追加されると未完了タスク数が増えます。コンシュー
          マがキューの要素が取り出されてすべての処理が完了したことを表す
          *note task_done(): 2ffe. を呼び出すと数が減ります。 未完了タス
          ク数がゼロになると *note join(): 2ffd. はブロッキングを解除し
          ます。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3770


File: python.info,  Node: その他<3>,  Next: Connection オブジェクト<2>,  Prev: パイプ Pipe とキュー Queue,  Up: リファレンス<2>

5.17.2.11 その他
................

 -- の関数: multiprocessing.active_children ()

     カレントプロセスのすべてのアクティブな子プロセスのリストを返します
     。

     これを呼び出すと "join" してすでに終了しているプロセスには副作用が
     あります。

 -- の関数: multiprocessing.cpu_count ()

     システムの CPU 数を返します。

     This number is not equivalent to the number of CPUs the current
     process can use.  The number of usable CPUs can be obtained with
     *note os.process_cpu_count(): 1a6. (or
     ‘len(os.sched_getaffinity(0))’).

     When the number of CPUs cannot be determined a *note
     NotImplementedError: 209. is raised.

     参考
     ....

     *note os.cpu_count(): 1a7. *note os.process_cpu_count(): 1a6.

     バージョン 3.13 で変更: The return value can also be overridden
     using the *note -X cpu_count: 15c. flag or *note PYTHON_CPU_COUNT:
     1f1. as this is merely a wrapper around the *note os: 91. cpu count
     APIs.

 -- の関数: multiprocessing.current_process ()

     カレントプロセスに対応する *note Process: b27. オブジェクトを返しま
     す。

     *note threading.current_thread(): 2e1. とよく似た関数です。

 -- の関数: multiprocessing.parent_process ()

     Return the *note Process: b27. object corresponding to the parent
     process of the *note current_process(): 300e.  For the main
     process, ‘parent_process’ will be ‘None’.

     Added in version 3.8.

 -- の関数: multiprocessing.freeze_support ()

     *note multiprocessing: 86. を使用しているプログラムをフリーズして
     Windows の実行可能形式を生成するためのサポートを追加します。
     ('py2exe' , 'PyInstaller' や 'cx_Freeze' でテストされています。)

     メインモジュールの ‘if __name__ == '__main__'’ の直後にこの関数を呼
     び出す必要があります。以下に例を示します:

          from multiprocessing import Process, freeze_support

          def f():
              print('hello world!')

          if __name__ == '__main__':
              freeze_support()
              Process(target=f).start()

     もし ‘freeze_support()’ の行がない場合、フリーズされた実行可能形式
     を実行しようとすると *note RuntimeError: 17a. を発生させます。

     ‘freeze_support()’ の呼び出しは Windows 以外の OS では効果がありま
     せん。さらに、もしモジュールが Windows の通常の Python インタプリタ
     によって実行されているならば（プログラムがフリーズされていなければ
     ） ‘freeze_support()’ は効果がありません。

 -- の関数: multiprocessing.get_all_start_methods ()

     Returns a list of the supported start methods, the first of which
     is the default.  The possible start methods are ‘'fork'’, ‘'spawn'’
     and ‘'forkserver'’.  Not all platforms support all methods.  See
     *note コンテキストと開始方式: 2a9.

     Added in version 3.4.

 -- の関数: multiprocessing.get_context (method=None)

     *note multiprocessing: 86. モジュールと同じ属性を持つコンテキストオ
     ブジェクトを返します。

     If 'method' is ‘None’ then the default context is returned.
     Otherwise 'method' should be ‘'fork'’, ‘'spawn'’, ‘'forkserver'’.
     *note ValueError: 1e3. is raised if the specified start method is
     not available.  See *note コンテキストと開始方式: 2a9.

     Added in version 3.4.

 -- の関数: multiprocessing.get_start_method (allow_none=False)

     開始するプロセスで使用する開始方式名を返します。

     開始方式がまだ確定しておらず、'allow_none' の値が偽の場合、開始方式
     はデフォルトに確定され、その名前が返されます。開始方式が確定してお
     らず、'allow_none' の値が真の場合、 ‘None’ が返されます。

     The return value can be ‘'fork'’, ‘'spawn'’, ‘'forkserver'’ or
     ‘None’.  See *note コンテキストと開始方式: 2a9.

     Added in version 3.4.

     バージョン 3.8 で変更: macOS では、 'spawn' 開始方式がデフォルトに
     なりました。 'fork' 開始方法は、サブプロセスのクラッシュを引き起こ
     す可能性があるため、安全ではありません。 bpo-33725(1) を参照。

 -- の関数: multiprocessing.set_executable (executable)

     子プロセスを開始するときに、使用する Python インタープリターのパス
     を設定します。(デフォルトでは *note sys.executable: 392. が使用され
     ます)。コードに組み込むときは、おそらく次のようにする必要があります

          set_executable(os.path.join(sys.exec_prefix, 'pythonw.exe'))

     子プロセスを作成する前に行ってください。

     バージョン 3.4 で変更: Now supported on POSIX when the ‘'spawn'’
     start method is used.

     バージョン 3.11 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: multiprocessing.set_forkserver_preload (module_names)

     Set a list of module names for the forkserver main process to
     attempt to import so that their already imported state is inherited
     by forked processes.  Any *note ImportError: 3f2. when doing so is
     silently ignored.  This can be used as a performance enhancement to
     avoid repeated work in every process.

     For this to work, it must be called before the forkserver process
     has been launched (before creating a ‘Pool’ or starting a *note
     Process: b27.).

     Only meaningful when using the ‘'forkserver'’ start method.  See
     *note コンテキストと開始方式: 2a9.

     Added in version 3.4.

 -- の関数: multiprocessing.set_start_method (method, force=False)

     Set the method which should be used to start child processes.  The
     'method' argument can be ‘'fork'’, ‘'spawn'’ or ‘'forkserver'’.
     Raises *note RuntimeError: 17a. if the start method has already
     been set and 'force' is not ‘True’.  If 'method' is ‘None’ and
     'force' is ‘True’ then the start method is set to ‘None’.  If
     'method' is ‘None’ and 'force' is ‘False’ then the context is set
     to the default context.

     これは一度しか呼び出すことができず、その場所もメインモジュールの
     ‘if __name__ == '__main__'’ 節内で保護された状態でなければなりませ
     ん。

     See *note コンテキストと開始方式: 2a9.

     Added in version 3.4.

     注釈: *note multiprocessing: 86. には *note
     threading.active_count(): 2e2, *note threading.enumerate(): 1810,
     *note threading.settrace(): 813, *note threading.setprofile(): 814,
     *note threading.Timer: 112c. や *note threading.local: 16d6. のよう
     な関数はありません。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33725


File: python.info,  Node: Connection オブジェクト<2>,  Next: 同期プリミティブ,  Prev: その他<3>,  Up: リファレンス<2>

5.17.2.12 Connection オブジェクト
.................................

Connection オブジェクトは pickle でシリアライズ可能なオブジェクトか文字
列を送ったり、受け取ったりします。そういったオブジェクトはメッセージ指向
の接続ソケットと考えられます。

Connection オブジェクトは通常は *note Pipe: 2fe0. を使用して作成されます
。 詳細は *note リスナーとクライアント: 3012. も参照してください。

 -- クラス: multiprocessing.connection.Connection

      -- メソッド: send (obj)

          コネクションの相手側へ *note recv(): 3014. を使用して読み込む
          オブジェクトを送ります。

          オブジェクトは pickle でシリアライズ可能でなければなりません。
          pickle が極端に大きすぎる (OS にも依りますが、およそ 32 MiB+)
          と、 *note ValueError: 1e3. 例外が送出されることがあります。

      -- メソッド: recv ()

          コネクションの相手側から *note send(): 3013. を使用して送られ
          たオブジェクトを返します。 何か受け取るまでブロックします。何
          も受け取らずにコネクションの相手側でクローズされた場合 *note
          EOFError: 12a7. が発生します。

      -- メソッド: fileno ()

          コネクションが使用するハンドラーか、ファイル記述子を返します。

      -- メソッド: close ()

          コネクションをクローズします。

          コネクションがガベージコレクトされるときに自動的に呼び出されま
          す。

      -- メソッド: poll ([timeout])

          読み込み可能なデータがあるかどうかを返します。

          'timeout' が指定されていなければすぐに返します。 'timeout' に
          数値を指定すると、最大指定した秒数をブロッキングします。
          'timeout' に ‘None’ を指定するとタイムアウトせずにずっとブロッ
          キングします。

          *note multiprocessing.connection.wait(): 10b3. を使って複数の
          コネクションオブジェクトを同時にポーリングできることに注意して
          ください。

      -- メソッド: send_bytes (buffer[, offset[, size]])

          *note bytes-like object: cfb. から完全なメッセージとしてバイト
          データを送ります。

          'offset' が指定されると 'buffer' のその位置からデータが読み込
          まれます。 'size' が指定されるとバッファーからその量のデータが
          読み込まれます。非常に大きなバッファー (OS に依存しますが、お
          よそ 32MiB+) を指定すると、 *note ValueError: 1e3. 例外が発生
          するかもしれません。

      -- メソッド: recv_bytes ([maxlength])

          コネクションの相手側から送られたバイトデータの完全なメッセージ
          を文字列として返します。何か受け取るまでブロックします。受け取
          るデータが何も残っておらず、相手側がコネクションを閉じていた場
          合、 *note EOFError: 12a7. が送出されます。

          'maxlength' を指定していて、かつメッセージが 'maxlength' より
          長い場合、 *note OSError: 3f0. が発生してコネクションからそれ
          以上読めなくなります。

          バージョン 3.3 で変更: この関数は以前は *note IOError: 1026. を
          送出していました。今では *note OSError: 3f0. の別名です。

      -- メソッド: recv_bytes_into (buffer[, offset])

          コネクションの相手側から送られたバイトデータを 'buffer' に読み
          込み、メッセージのバイト数を返します。 何か受け取るまでブロッ
          クします。何も受け取らずにコネクションの相手側でクローズされた
          場合 *note EOFError: 12a7. が発生します。

          'buffer' は書き込み可能な *note bytes-like object: cfb. でなけ
          ればなりません。 'offset' が与えられたら、その位置からバッファ
          ーへメッセージが書き込まれます。 オフセットは 'buffer' バイト
          よりも小さい正の数でなければなりません。

          バッファーがあまりに小さいと ‘BufferTooShort’ 例外が発生します
          。 ‘e’ が例外インスタンスとすると完全なメッセージは
          ‘e.args[0]’ で確認できます。

     バージョン 3.3 で変更: *note Connection.send(): 3013. と *note
     Connection.recv(): 3014. を使用して Connection オブジェクト自体をプ
     ロセス間で転送できるようになりました。

     Connection objects also now support the context management protocol
     - see *note コンテキストマネージャ型: 1f20.  *note __enter__():
     21a5. returns the connection object, and *note __exit__(): 21a6.
     calls *note close(): 3016.

例えば:

     >>> from multiprocessing import Pipe
     >>> a, b = Pipe()
     >>> a.send([1, 'hello', None])
     >>> b.recv()
     [1, 'hello', None]
     >>> b.send_bytes(b'thank you')
     >>> a.recv_bytes()
     b'thank you'
     >>> import array
     >>> arr1 = array.array('i', range(5))
     >>> arr2 = array.array('i', [0] * 10)
     >>> a.send_bytes(arr1)
     >>> count = b.recv_bytes_into(arr2)
     >>> assert count == len(arr1) * arr1.itemsize
     >>> arr2
     array('i', [0, 1, 2, 3, 4, 0, 0, 0, 0, 0])
     警告: *note Connection.recv(): 3014. メソッドは受信したデータを自動
     的に unpickle 化します。それはメッセージを送ったプロセスが信頼でき
     る場合を除いてセキュリティリスクになります。

     そのため ‘Pipe()’ を使用してコネクションオブジェクトを生成する場合
     を除いて、何らかの認証処理を実行した後で *note recv(): 3014. や
     *note send(): 3013. メソッドのみを使用すべきです。詳細は *note
     認証キー: 2ff4. を参照してください。

     警告: もしプロセスがパイプの読み込みまたは書き込み中に kill される
     と、メッセージの境界がどこなのか分からなくなってしまうので、そのパ
     イプ内のデータは破損してしまいがちです。


File: python.info,  Node: 同期プリミティブ,  Next: 共有 ctypes オブジェクト,  Prev: Connection オブジェクト<2>,  Up: リファレンス<2>

5.17.2.13 同期プリミティブ
..........................

一般的にマルチプロセスプログラムは、マルチスレッドプログラムほどは同期プ
リミティブを必要としません。詳細は *note threading: d6. モジュールのドキ
ュメントを参照してください。

マネージャーオブジェクトを使用して同期プリミティブを作成できることも覚え
ておいてください。詳細は *note マネージャー: 2fff. を参照してください。

 -- クラス: multiprocessing.Barrier (parties[, action[, timeout]])

     バリアーオブジェクト: *note threading.Barrier: 11b4. のクローンです
     。

     Added in version 3.3.

 -- クラス: multiprocessing.BoundedSemaphore ([value])

     有限セマフォオブジェクト: *note threading.BoundedSemaphore: 112a. の
     類似物です。

     よく似た *note threading.BoundedSemaphore: 112a. とは、次の一点だけ
     異なります。 ‘acquire’ メソッドの第一引数名は 'block' で、*note
     Lock.acquire(): 301d. と一致しています。

          注釈: macOS では ‘sem_getvalue()’ が実装されていないので *note
          Semaphore: 2fe6. と区別がつきません。

 -- クラス: multiprocessing.Condition ([lock])

     状態変数: *note threading.Condition: 1128. の別名です。

     'lock' を指定するなら *note multiprocessing: 86. の *note Lock:
     1504. か *note RLock: 1505. オブジェクトにすべきです。

     バージョン 3.3 で変更: *note wait_for(): 2fc2. メソッドが追加されま
     した。

 -- クラス: multiprocessing.Event

     *note threading.Event: 112b. のクローンです。

 -- クラス: multiprocessing.Lock

     再帰しないロックオブジェクトで、 *note threading.Lock: 15db. 相当の
     ものです。プロセスやスレッドがロックをいったん獲得 (acquire) すると
     、それに続くほかのプロセスやスレッドが獲得しようとする際、それが解
     放 (release) されるまではブロックされます。解放はどのプロセス、スレ
     ッドからも行えます。スレッドに対して適用される *note
     threading.Lock: 15db. のコンセプトと振る舞いは、特筆すべきものがな
     い限り、プロセスとスレッドに適用される *note multiprocessing.Lock:
     1504. に引き継がれています。

     *note Lock: 1504. は実際にはファクトリ関数で、デフォルトコンテキス
     トで初期化された ‘multiprocessing.synchronize.Lock’ のインスタンス
     を返すことに注意してください。

     *note Lock: 1504. は *note context manager: 59e. プロトコルをサポー
     トしています。つまり *note with: 59c. 文で使うことができます。

      -- メソッド: acquire (block=True, timeout=None)

          ブロックあり、またはブロックなしでロックを獲得します。

          引数 'block' を ‘True’ (デフォルト) に設定して呼び出した場合、
          ロックがアンロック状態になるまでブロックします。ブロックから抜
          けるとそれをロック状態にしてから ‘True’ を返します。 *note
          threading.Lock.acquire(): 664. の最初の引数とは名前が違ってい
          るので注意してください。

          引数 'block' の値を ‘False’ にして呼び出すとブロックしません。
          現在ロック状態であれば、直ちに ‘False’ を返します。それ以外の
          場合には、ロックをロック状態にして ‘True’ を返します。

          'timeout' として正の浮動小数点数を与えて呼び出すと、ロックが獲
          得できない限り、指定された秒数だけブロックします。 'timeout' 値
          に負数を与えると、ゼロを与えた場合と同じになります。 'timeout'
          値の ‘None’ (デフォルト) を与えると、無限にブロックします。
          'timeout' 引数の負数と ‘None’ の扱いは、 *note
          threading.Lock.acquire(): 664. に実装された動作と異なるので注
          意してください。 'block' が ‘False’ の場合、 'timeout' は実際
          的な意味を持たなくなるので無視されます。ロックを獲得した場合は
          ‘True’ 、タイムアウトした場合は ‘False’ で戻ります。

      -- メソッド: release ()

          ロックを解放します。これはロックを獲得したプロセスやスレッドだ
          けでなく、任意のプロセスやスレッドから呼ぶことができます。

          *note threading.Lock.release(): 1292. と同じように振舞いますが
          、ロックされていない場合に呼び出すと *note ValueError: 1e3. と
          なる点だけが違います。

 -- クラス: multiprocessing.RLock

     再帰ロックオブジェクトで、 *note threading.RLock: 2bf. 相当のもので
     す。再帰ロックオブジェクトはそれを獲得 (acquire) したプロセスやスレ
     ッドが解放 (release) しなければなりません。プロセスやスレッドがロッ
     クをいったん獲得すると、同じプロセスやスレッドはブロックされずに再
     度獲得出来ます。そのプロセスやスレッドは獲得した回数ぶん解放しなけ
     ればなりません。

     *note RLock: 1505. は実際にはファクトリ関数で、デフォルトコンテキス
     トで初期化された ‘multiprocessing.synchronize.Lock’ のインスタンス
     を返すことに注意してください。

     *note RLock: 1505. は *note context manager: 59e. プロトコルをサポ
     ートしています。つまり *note with: 59c. 文で使うことができます。

      -- メソッド: acquire (block=True, timeout=None)

          ブロックあり、またはブロックなしでロックを獲得します。

          'block' 引数を ‘True’ にして呼び出した場合、ロックが既にカレン
          トプロセスもしくはカレントスレッドが既に所有していない限りは、
          アンロック状態 (どのプロセス、スレッドも所有していない状態) に
          なるまでブロックします。ブロックから抜けるとカレントプロセスも
          しくはカレントスレッドが (既に持っていなければ) 所有権を得て、
          再帰レベルをインクリメントし、 ‘True’ で戻ります。 *note
          threading.RLock.acquire(): e46. の実装とはこの最初の引数の振る
          舞いが、その名前自身を始めとしていくつか違うので注意してくださ
          い。

          'block' 引数を ‘False’ にして呼び出した場合、ブロックしません
          。ロックが他のプロセスもしくはスレッドにより獲得済み (つまり所
          有されている) であれば、カレントプロセスまたはカレントスレッド
          は所有権を得ず、再帰レベルも変更せずに、 ‘False’ で戻ります。
          ロックがアンロック状態の場合、カレントプロセスもしくはカレント
          スレッドは所有権を得て再帰レベルがインクリメントされ、 ‘True’
          で戻ります。(--訳注: 'block' の True/False 関係なくここでの説
          明では「所有権を持っている場合の2度目以降の aquire」の説明が欠
          けています。2度目以降の acquire では再帰レベルがインクリメント
          されて即座に返ります。全体読めばわかるとは思いますが一応。--)

          'timeout' 引数の使い方と振る舞いは *note Lock.acquire(): 301d.
          と同じです。 'timeout' 引数の振る舞いがいくつかの点で *note
          threading.RLock.acquire(): e46. と異なるので注意してください。

      -- メソッド: release ()

          再帰レベルをデクリメントしてロックを解放します。デクリメント後
          に再帰レベルがゼロになった場合、ロックの状態をアンロック (いか
          なるプロセス、いかなるスレッドにも所有されていない状態) にリセ
          ットし、ロックの状態がアンロックになるのを待ってブロックしてい
          るプロセスもしくはスレッドがある場合にはその中のただ一つだけが
          処理を進行できるようにします。デクリメント後も再帰レベルがゼロ
          でない場合、ロックの状態はロックのままで、呼び出し側のプロセス
          もしくはスレッドに所有されたままになります。

          このメソッドは呼び出しプロセスあるいはスレッドがロックを所有し
          ている場合に限り呼び出してください。所有者でないプロセスもしく
          はスレッドによって呼ばれるか、あるいはアンロック (未所有) 状態
          で呼ばれた場合、 *note AssertionError: 675. が送出されます。同
          じ状況での *note threading.RLock.release(): 2fbd. 実装とは例外
          の型が異なるので注意してください。

 -- クラス: multiprocessing.Semaphore ([value])

     セマフォオブジェクト: *note threading.Semaphore: 1129. のクローンで
     す。

     よく似た *note threading.BoundedSemaphore: 112a. とは、次の一点だけ
     異なります。 ‘acquire’ メソッドの第一引数名は 'block' で、*note
     Lock.acquire(): 301d. と一致しています。

     注釈: macOS では ‘sem_timedwait’ がサポートされていないので、
     ‘acquire()’ にタイムアウトを与えて呼ぶと、ループ内でスリープするこ
     とでこの関数がエミュレートされます。

     注釈: このパッケージに含まれる機能には、ホストとなるオペレーティン
     グシステム上で動作している共有セマフォを使用しているものがあります
     。これが使用できない場合には、‘multiprocessing.synchronize’ モジュ
     ールが無効になり、このモジュールのインポート時に *note ImportError:
     3f2. が発生します。詳細は bpo-3770(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=3770


File: python.info,  Node: 共有 ctypes オブジェクト,  Next: マネージャー,  Prev: 同期プリミティブ,  Up: リファレンス<2>

5.17.2.14 共有 ‘ctypes’ オブジェクト
....................................

子プロセスにより継承される共有メモリを使用する共有オブジェクトを作成する
ことができます。

 -- の関数: multiprocessing.Value (typecode_or_type, *args, lock=True)

     共有メモリから割り当てられた *note ctypes: 22. オブジェクトを返しま
     す。 デフォルトでは、返り値は実際のオブジェクトの同期ラッパーです。
     オブジェクトそれ自身は、 *note Value: 2fe3. の 'value' 属性によって
     アクセスできます。

     'typecode_or_type' は返されるオブジェクトの型を決めます。それは
     ctypes の型か *note array: 6. モジュールで使用されるような1文字の型
     コードかのどちらか一方です。 '*args' は型のコンストラクターへ渡され
     ます。

     'lock' が ‘True’ (デフォルト) なら、値へ同期アクセスするために新た
     に再帰的なロックオブジェクトが作成されます。 'lock' が *note Lock:
     1504. か *note RLock: 1505. なら値への同期アクセスに使用されます。
     'lock' が ‘False’ なら、返されたオブジェクトへのアクセスはロックに
     より自動的に保護されません。そのため、必ずしも "プロセスセーフ" で
     はありません。

     ‘+=’ のような演算は、読み込みと書き込みを含むためアトミックでありま
     せん。このため、たとえば自動的に共有の値を増加させたい場合、以下の
     ようにするのでは不十分です

          counter.value += 1

     関連するロックが再帰的 (それがデフォルトです) なら、かわりに次のよ
     うにします

          with counter.get_lock():
              counter.value += 1

     'lock' はキーワード専用引数であることに注意してください。

 -- の関数: multiprocessing.Array (typecode_or_type,
          size_or_initializer, *, lock=True)

     共有メモリから割り当てられた ctypes 配列を返します。デフォルトでは
     、返り値は実際の配列の同期ラッパーです。

     'typecode_or_type' は返される配列の要素の型を決めます。それは
     ctypes の型か *note array: 6. モジュールで使用されるような1文字の型
     コードかのどちらか一方です。 'size_or_initializer' が整数なら、配列
     の長さを決定し、その配列はゼロで初期化されます。別の使用方法として
     'size_or_initializer' は配列の初期化に使用されるシーケンスになり、
     そのシーケンス長が配列の長さを決定します。

     'lock' が ‘True’ (デフォルト) なら、値へ同期アクセスするために新た
     なロックオブジェクトが作成されます。 'lock' が *note Lock: 1504. か
     *note RLock: 1505. なら値への同期アクセスに使用されます。 'lock' が
     ‘False’ なら、返されたオブジェクトへのアクセスはロックにより自動的
     に保護されません。そのため、必ずしも "プロセスセーフ" ではありませ
     ん。

     'lock' はキーワード引数としてのみ利用可能なことに注意してください。

     *note ctypes.c_char: 2f2b. の配列は文字列を格納して取り出せる
     'value' と 'raw' 属性を持っていることを覚えておいてください。

* Menu:

* multiprocessing.sharedctypes モジュール: multiprocessing sharedctypes モジュール.


File: python.info,  Node: multiprocessing sharedctypes モジュール,  Up: 共有 ctypes オブジェクト

5.17.2.15 ‘multiprocessing.sharedctypes’ モジュール
...................................................

*note multiprocessing.sharedctypes: 8c. モジュールは子プロセスに継承され
る共有メモリの *note ctypes: 22. オブジェクトを割り当てる関数を提供しま
す。

     注釈: 共有メモリのポインターを格納することは可能ではありますが、特
     定プロセスのアドレス空間の位置を参照するということを覚えておいてく
     ださい。しかし、そのポインターは別のプロセスのコンテキストにおいて
     無効になる確率が高いです。そして、別のプロセスからそのポインターを
     逆参照しようとするとクラッシュを引き起こす可能性があります。

 -- の関数: multiprocessing.sharedctypes.RawArray (typecode_or_type,
          size_or_initializer)

     共有メモリから割り当てられた ctypes 配列を返します。

     'typecode_or_type' は返される配列の要素の型を決めます。それは
     ctypes の型か *note array: 6. モジュールで使用されるような1文字の型
     コードのどちらか一方です。 'size_or_initializer' が整数なら、それが
     配列の長さになり、その配列はゼロで初期化されます。別の使用方法とし
     て 'size_or_initializer' には配列の初期化に使用されるシーケンスを設
     定することもでき、その場合はシーケンスの長さが配列の長さになります
     。

     要素を取得したり設定したりすることは潜在的に非アトミックであること
     に注意してください。ロックを使用して自動的に同期化されたアクセスを
     保証するには *note Array(): 3024. を使用してください。

 -- の関数: multiprocessing.sharedctypes.RawValue (typecode_or_type,
          *args)

     共有メモリから割り当てられた ctypes オブジェクトを返します。

     'typecode_or_type' は返されるオブジェクトの型を決めます。それは
     ctypes の型か *note array: 6. モジュールで使用されるような1文字の型
     コードかのどちらか一方です。 '*args' は型のコンストラクターへ渡され
     ます。

     値を取得したり設定したりすることは潜在的に非アトミックであることに
     注意してください。ロックを使用して自動的に同期化されたアクセスを保
     証するには *note Value(): 3026. を使用してください。

     *note ctypes.c_char: 2f2b. の配列は文字列を格納して取り出せる
     ‘value’ と ‘raw’ 属性を持っていることを覚えておいてください。詳細は
     *note ctypes: 22. を参照してください。

 -- の関数: multiprocessing.sharedctypes.Array (typecode_or_type,
          size_or_initializer, *, lock=True)

     *note RawArray(): 3023. と同様ですが、 'lock' の値によっては ctypes
     配列をそのまま返す代わりに、プロセスセーフな同期ラッパーが返されま
     す。

     'lock' が ‘True’ (デフォルト) なら、値へ同期アクセスするために新た
     な ロックオブジェクトが作成されます。 'lock' が *note Lock: 1504. か
     *note RLock: 1505. なら値への同期アクセスに使用されます。 'lock' が
     ‘False’ なら、返された オブジェクトへのアクセスはロックにより自動的
     に保護されません。 そのため、必ずしも "プロセスセーフ" ではありませ
     ん。

     'lock' はキーワード専用引数であることに注意してください。

 -- の関数: multiprocessing.sharedctypes.Value (typecode_or_type, *args,
          lock=True)

     *note RawValue(): 3025. と同様ですが、 'lock' の値によっては ctypes
     オブジェクトをそのまま返す代わりに、プロセスセーフな同期ラッパーが
     返されます。

     'lock' が ‘True’ (デフォルト) なら、値へ同期アクセスするために新た
     な ロックオブジェクトが作成されます。 'lock' が *note Lock: 1504. か
     *note RLock: 1505. なら値への同期アクセスに使用されます。 'lock' が
     ‘False’ なら、返された オブジェクトへのアクセスはロックにより自動的
     に保護されません。 そのため、必ずしも "プロセスセーフ" ではありませ
     ん。

     'lock' はキーワード専用引数であることに注意してください。

 -- の関数: multiprocessing.sharedctypes.copy (obj)

     共有メモリから割り当てられた ctypes オブジェクト 'obj' をコピーした
     オブジェクトを返します。

 -- の関数: multiprocessing.sharedctypes.synchronized (obj[, lock])

     同期アクセスに 'lock' を使用する ctypes オブジェクトのためにプロセ
     スセーフなラッパーオブジェクトを返します。 'lock' が ‘None’ (デフォ
     ルト) なら、 *note multiprocessing.RLock: 1505. オブジェクトが自動
     的に作成されます。

     同期ラッパーがラップするオブジェクトに加えて2つのメソッドがあります
     。 ‘get_obj()’ はラップされたオブジェクトを返します。 ‘get_lock()’
     は同期のために使用されるロックオブジェクトを返します。

     ラッパー経由で ctypes オブジェクトにアクセスすることは raw ctypes オ
     ブジェクトへアクセスするよりずっと遅くなることに注意してください。

     バージョン 3.5 で変更: synchronized オブジェクトは *note
     コンテキストマネージャ: 59e. プロトコルをサポートしています。

次の表は通常の ctypes 構文で共有メモリから共有 ctypes オブジェクトを作成
するための構文を比較します。 (‘MyStruct’ テーブル内には *note
ctypes.Structure: 1b6. のサブクラスがあります。)

ctypes                   type を使用する sharedctypes   typecode を使用する
                                                        sharedctypes
                                                        
----------------------------------------------------------------------------------------
                                                        
c_double(2.4)            RawValue(c_double, 2.4)        RawValue('d', 2.4)
                                                        
                                                        
MyStruct(4, 6)           RawValue(MyStruct, 4, 6)
                         
                                                        
(c_short * 7)()          RawArray(c_short, 7)           RawArray('h', 7)
                                                        
                                                        
(c_int * 3)(9, 2, 8)     RawArray(c_int, (9, 2, 8))     RawArray('i', (9, 2, 8))
                                                        

以下に子プロセスが多くの ctypes オブジェクトを変更する例を紹介します:

     from multiprocessing import Process, Lock
     from multiprocessing.sharedctypes import Value, Array
     from ctypes import Structure, c_double

     class Point(Structure):
         _fields_ = [('x', c_double), ('y', c_double)]

     def modify(n, x, s, A):
         n.value **= 2
         x.value **= 2
         s.value = s.value.upper()
         for a in A:
             a.x **= 2
             a.y **= 2

     if __name__ == '__main__':
         lock = Lock()

         n = Value('i', 7)
         x = Value(c_double, 1.0/3.0, lock=False)
         s = Array('c', b'hello world', lock=lock)
         A = Array(Point, [(1.875,-6.25), (-5.75,2.0), (2.375,9.5)], lock=lock)

         p = Process(target=modify, args=(n, x, s, A))
         p.start()
         p.join()

         print(n.value)
         print(x.value)
         print(s.value)
         print([(a.x, a.y) for a in A])

結果は以下のように表示されます

     49
     0.1111111111111111
     HELLO WORLD
     [(3.515625, 39.0625), (33.0625, 4.0), (5.640625, 90.25)]


File: python.info,  Node: マネージャー,  Next: Proxy オブジェクト,  Prev: 共有 ctypes オブジェクト,  Up: リファレンス<2>

5.17.2.16 マネージャー
......................

マネージャーは異なるプロセス間で共有されるデータの作成方法を提供します。
これには別のマシン上で走るプロセス間のネットワーク越しの共有も含まれます
。マネージャーオブジェクトは '共有オブジェクト' を管理するサーバープロセ
スを制御します。他のプロセスはプロキシ経由で共有オブジェクトへアクセスす
ることができます。

 -- の関数: multiprocessing.Manager ()

     プロセス間でオブジェクトを共有するために使用される *note
     SyncManager: 3029. オブジェクトを返します。返されたマネージャーオブ
     ジェクトは生成される子プロセスに対応付けられ、共有オブジェクトを作
     成するメソッドや、共有オブジェクトに対応するプロキシを返すメソッド
     を持ちます。

マネージャープロセスは親プロセスが終了するか、ガベージコレクトされると停
止します。マネージャークラスは *note multiprocessing.managers: 89. モジ
ュールで定義されています:

 -- クラス: multiprocessing.managers.BaseManager (address=None,
          authkey=None, serializer='pickle', ctx=None, *,
          shutdown_timeout=1.0)

     BaseManager オブジェクトを作成します。

     作成後、*note start(): 302b. または ‘get_server().serve_forever()’
     を呼び出して、マネージャーオブジェクトが、開始されたマネージャープ
     ロセスを確実に参照するようにしてください。

     'address' はマネージャープロセスが新たなコネクションを待ち受けるア
     ドレスです。'address' が ‘None’ の場合、任意のアドレスが設定されま
     す。

     'authkey' はサーバープロセスへ接続しようとするコネクションの正当性
     を検証するために 使用される認証キーです。'authkey' が ‘None’ の場合
     ‘current_process().authkey’ が使用されます。'authkey' を使用する場
     合はバイト文字列でなければなりません。

     'serializer' must be ‘'pickle'’ (use *note pickle: 95.
     serialization) or ‘'xmlrpclib'’ (use *note xmlrpc.client: 114.
     serialization).

     'ctx' is a context object, or ‘None’ (use the current context).
     See the ‘get_context()’ function.

     'shutdown_timeout' is a timeout in seconds used to wait until the
     process used by the manager completes in the *note shutdown():
     302c. method.  If the shutdown times out, the process is
     terminated.  If terminating the process also times out, the process
     is killed.

     バージョン 3.11 で変更: 'shutdown_timeout' パラメータを追加しました
     。

      -- メソッド: start ([initializer[, initargs]])

          マネージャーを開始するためにサブプロセスを開始します。
          'initializer' が ‘None’ でなければ、サブプロセスは開始時に
          ‘initializer(*initargs)’ を呼び出します。

      -- メソッド: get_server ()

          マネージャーの制御下にある実際のサーバーを表す ‘Server’ オブジ
          ェクトを返します。 ‘Server’ オブジェクトは ‘serve_forever()’ メ
          ソッドをサポートします:

               >>> from multiprocessing.managers import BaseManager
               >>> manager = BaseManager(address=('', 50000), authkey=b'abc')
               >>> server = manager.get_server()
               >>> server.serve_forever()

          ‘Server’ はさらに *note address: 302e. 属性も持っています。

      -- メソッド: connect ()

          ローカルからリモートのマネージャーオブジェクトへ接続します:

               >>> from multiprocessing.managers import BaseManager
               >>> m = BaseManager(address=('127.0.0.1', 50000), authkey=b'abc')
               >>> m.connect()

      -- メソッド: shutdown ()

          マネージャーが使用するプロセスを停止します。これはサーバープロ
          セスを開始するために *note start(): 302b. が使用された場合のみ
          有効です。

          これは複数回呼び出すことができます。

      -- メソッド: register (typeid[, callable[, proxytype[, exposed[,
               method_to_typeid[, create_method]]]]])

          マネージャークラスで呼び出し可能オブジェクト(callable)や型を登
          録するために使用されるクラスメソッドです。

          'typeid' は特に共有オブジェクトの型を識別するために使用される
          "型識別子" です。これは文字列でなければなりません。

          'callable' はこの型識別子のオブジェクトを作成するために使用さ
          れる呼び出し可能オブジェクトです。マネージャーインスタンスが
          *note connect(): 302f. メソッドを使ってサーバーに接続されてい
          るか、 'create_method' 引数が ‘False’ の場合は、 ‘None’ でも構
          いません。

          'proxytype' はこの 'typeid' で共有オブジェクトのプロキシを作成
          するために使用される *note BaseProxy: 3031. のサブクラスです。
          ‘None’ の場合、プロキシクラスは自動的に作成されます。

          'exposed' は *note BaseProxy._callmethod(): 3032. を使用したア
          クセスが許されるべき typeid をプロキシするメソッド名のシーケン
          スを指定するために使用されます ('exposed' が ‘None’ の場合
          ‘proxytype._exposed_’ が存在すればそれが代わりに使用されます
          )。'exposed' リストが指定されない場合、共有オブジェクトのすべ
          ての "パブリックメソッド" がアクセス可能になります。 (ここでい
          う "パブリックメソッド" とは *note __call__(): 523. メソッドを
          持つものと名前が ‘'_'’ で始まらないあらゆる属性を意味します。)

          'method_to_typeid' はプロキシが返す exposed メソッドの返り値の
          型を指定するために使用されるマッピングで、メソッド名を typeid
          文字列にマップします。 ('method_to_typeid' が ‘None’ の場合
          ‘proxytype._method_to_typeid_’ が存在すれば、それが代わりに使
          用されます。) メソッド名がこのマッピングのキーではないか、マッ
          ピングが ‘None’ の場合、そのメソッドによって返されるオブジェク
          トが値として (by value) コピーされます。

          'create_method' は、共有オブジェクトを作成し、それに対するプロ
          キシを返すようサーバープロセスに伝える、名前 'typeid' のメソッ
          ドを作成するかを決定します。デフォルトでは ‘True’ です。

     *note BaseManager: 302a. インスタンスも読み出し専用属性を1つ持って
     います:

      -- の属性: address

          マネージャーが使用するアドレスです。

     バージョン 3.3 で変更: マネージャーオブジェクトはコンテキストマネー
     ジメント・プロトコルをサポートします - *note
     コンテキストマネージャ型: 1f20. を参照してください。 *note
     __enter__(): 21a5. は (まだ開始していない場合) サーバープロセスを開
     始してから、マネージャーオブジェクトを返します。 *note __exit__():
     21a6. は *note shutdown(): 302c. を呼び出します。

     旧バージョンでは、 *note __enter__(): 21a5. はマネージャーのサーバ
     ープロセスがまだ開始していなかった場合でもプロセスを開始しませんで
     した。

 -- クラス: multiprocessing.managers.SyncManager

     プロセス間の同期のために使用される *note BaseManager: 302a. のサブ
     クラスです。 *note multiprocessing.Manager(): c88. はこの型のオブジ
     ェクトを返します。

     Its methods create and return *note Proxy オブジェクト: c87. for a
     number of commonly used data types to be synchronized across
     processes.  This notably includes shared lists and dictionaries.

      -- メソッド: Barrier (parties[, action[, timeout]])

          共有 *note threading.Barrier: 11b4. オブジェクトを作成して、そ
          のプロキシを返します。

          Added in version 3.3.

      -- メソッド: BoundedSemaphore ([value])

          共有 *note threading.BoundedSemaphore: 112a. オブジェクトを作
          成して、そのプロキシを返します。

      -- メソッド: Condition ([lock])

          共有 *note threading.Condition: 1128. オブジェクトを作成して、
          そのプロキシを返します。

          'lock' が提供される場合 *note threading.Lock: 15db. か *note
          threading.RLock: 2bf. オブジェクトのためのプロキシになります。

          バージョン 3.3 で変更: *note wait_for(): 2fc2. メソッドが追加
          されました。

      -- メソッド: Event ()

          共有 *note threading.Event: 112b. オブジェクトを作成して、その
          プロキシを返します。

      -- メソッド: Lock ()

          共有 *note threading.Lock: 15db. オブジェクトを作成して、その
          プロキシを返します。

      -- メソッド: Namespace ()

          共有 *note Namespace: 2fe5. オブジェクトを作成して、そのプロキ
          シを返します。

      -- メソッド: Queue ([maxsize])

          共有 *note queue.Queue: 1356. オブジェクトを作成して、そのプロ
          キシを返します。

      -- メソッド: RLock ()

          共有 *note threading.RLock: 2bf. オブジェクトを作成して、その
          プロキシを返します。

      -- メソッド: Semaphore ([value])

          共有 *note threading.Semaphore: 1129. オブジェクトを作成して、
          そのプロキシを返します。

      -- メソッド: Array (typecode, sequence)

          配列を作成して、そのプロキシを返します。

      -- メソッド: Value (typecode, value)

          書き込み可能な ‘value’ 属性を作成して、そのプロキシを返します
          。

      -- メソッド: dict ()

      -- メソッド: dict (mapping)

      -- メソッド: dict (sequence)

          共有 *note dict: 237. オブジェクトを作成して、そのプロキシを返
          します。

      -- メソッド: list ()

      -- メソッド: list (sequence)

          共有 *note list: 5dc. オブジェクトを作成して、そのプロキシを返
          します。

     バージョン 3.6 で変更: 共有オブジェクトは入れ子もできます。 例えば
     、共有リストのような共有コンテナオブジェクトは、 *note SyncManager:
     3029. がまとめて管理し同期を取っている他の共有オブジェクトを保持で
     きます。

 -- クラス: multiprocessing.managers.Namespace

     *note SyncManager: 3029. に登録することのできる型です。

     Namespace オブジェクトにはパブリックなメソッドはありませんが、書き
     込み可能な属性を持ちます。そのオブジェクト表現はその属性の値を表示
     します。

     しかし、Namespace オブジェクトのためにプロキシを使用するとき ‘'_'’
     が先頭に付く属性はプロキシの属性になり、参照対象の属性にはなりませ
     ん:

          >>> mp_context = multiprocessing.get_context('spawn')
          >>> manager = mp_context.Manager()
          >>> Global = manager.Namespace()
          >>> Global.x = 10
          >>> Global.y = 'hello'
          >>> Global._z = 12.3    # this is an attribute of the proxy
          >>> print(Global)
          Namespace(x=10, y='hello')

* Menu:

* カスタマイズされたマネージャー::
* リモートマネージャーを使用する::


File: python.info,  Node: カスタマイズされたマネージャー,  Next: リモートマネージャーを使用する,  Up: マネージャー

5.17.2.17 カスタマイズされたマネージャー
........................................

独自のマネージャーを作成するには、*note BaseManager: 302a. のサブクラス
を作成して、 マネージャークラスで呼び出し可能なオブジェクトか新たな型を
登録するために *note register(): 3030. クラスメソッドを使用します。例え
ば:

     from multiprocessing.managers import BaseManager

     class MathsClass:
         def add(self, x, y):
             return x + y
         def mul(self, x, y):
             return x * y

     class MyManager(BaseManager):
         pass

     MyManager.register('Maths', MathsClass)

     if __name__ == '__main__':
         with MyManager() as manager:
             maths = manager.Maths()
             print(maths.add(4, 3))         # prints 7
             print(maths.mul(7, 8))         # prints 56


File: python.info,  Node: リモートマネージャーを使用する,  Prev: カスタマイズされたマネージャー,  Up: マネージャー

5.17.2.18 リモートマネージャーを使用する
........................................

あるマシン上でマネージャーサーバーを実行して、他のマシンからそのサーバー
を使用するクライアントを持つことができます(ファイアウォールを通過できる
ことが前提)。

次のコマンドを実行することでリモートクライアントからアクセスを受け付ける
1つの共有キューのためにサーバーを作成します:

     >>> from multiprocessing.managers import BaseManager
     >>> from queue import Queue
     >>> queue = Queue()
     >>> class QueueManager(BaseManager): pass
     >>> QueueManager.register('get_queue', callable=lambda:queue)
     >>> m = QueueManager(address=('', 50000), authkey=b'abracadabra')
     >>> s = m.get_server()
     >>> s.serve_forever()

あるクライアントからサーバーへのアクセスは次のようになります:

     >>> from multiprocessing.managers import BaseManager
     >>> class QueueManager(BaseManager): pass
     >>> QueueManager.register('get_queue')
     >>> m = QueueManager(address=('foo.bar.org', 50000), authkey=b'abracadabra')
     >>> m.connect()
     >>> queue = m.get_queue()
     >>> queue.put('hello')

別のクライアントもそれを使用することができます:

     >>> from multiprocessing.managers import BaseManager
     >>> class QueueManager(BaseManager): pass
     >>> QueueManager.register('get_queue')
     >>> m = QueueManager(address=('foo.bar.org', 50000), authkey=b'abracadabra')
     >>> m.connect()
     >>> queue = m.get_queue()
     >>> queue.get()
     'hello'

ローカルプロセスもそのキューへアクセスすることができます。クライアント上
で上述のコードを使用してアクセスします:

     >>> from multiprocessing import Process, Queue
     >>> from multiprocessing.managers import BaseManager
     >>> class Worker(Process):
     ...     def __init__(self, q):
     ...         self.q = q
     ...         super().__init__()
     ...     def run(self):
     ...         self.q.put('local hello')
     ...
     >>> queue = Queue()
     >>> w = Worker(queue)
     >>> w.start()
     >>> class QueueManager(BaseManager): pass
     ...
     >>> QueueManager.register('get_queue', callable=lambda: queue)
     >>> m = QueueManager(address=('', 50000), authkey=b'abracadabra')
     >>> s = m.get_server()
     >>> s.serve_forever()


File: python.info,  Node: Proxy オブジェクト,  Next: プロセスプール,  Prev: マネージャー,  Up: リファレンス<2>

5.17.2.19 Proxy オブジェクト
............................

プロキシは別のプロセスで(おそらく)有効な共有オブジェクトを '参照する' オ
ブジェクトです。共有オブジェクトはプロキシの '参照対象' になるということ
ができます。複数のプロキシオブジェクトが同じ参照対象を持つ可能性もありま
す。

プロキシオブジェクトはその参照対象の対応するメソッドを呼び出すメソッドを
持ちます (そうは言っても、参照対象のすべてのメソッドが必ずしもプロキシ経
由で利用可能なわけではありません)。 この方法で、プロキシオブジェクトはま
るでその参照先と同じように使えます:

     >>> mp_context = multiprocessing.get_context('spawn')
     >>> manager = mp_context.Manager()
     >>> l = manager.list([i*i for i in range(10)])
     >>> print(l)
     [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
     >>> print(repr(l))
     <ListProxy object, typeid 'list' at 0x...>
     >>> l[4]
     16
     >>> l[2:5]
     [4, 9, 16]

プロキシに *note str(): 418. を適用すると参照対象のオブジェクト表現を返
すのに対して、 *note repr(): 7c8. を適用するとプロキシのオブジェクト表現
を返すことに注意してください。

プロキシオブジェクトの重要な機能は pickle 化ができることで、これによりプ
ロセス間での受け渡しができます。 そのため、参照対象が *note Proxy
オブジェクト: c87. を持てます。 これによって管理されたリスト、辞書、その
他 *note Proxy オブジェクト: c87. をネストできます:

     >>> a = manager.list()
     >>> b = manager.list()
     >>> a.append(b)         # referent of a now contains referent of b
     >>> print(a, b)
     [<ListProxy object, typeid 'list' at ...>] []
     >>> b.append('hello')
     >>> print(a[0], b)
     ['hello'] ['hello']

同様に、辞書とリストのプロキシも他のプロキシの内部に入れてネストできます
:

     >>> l_outer = manager.list([ manager.dict() for i in range(2) ])
     >>> d_first_inner = l_outer[0]
     >>> d_first_inner['a'] = 1
     >>> d_first_inner['b'] = 2
     >>> l_outer[1]['c'] = 3
     >>> l_outer[1]['z'] = 26
     >>> print(l_outer[0])
     {'a': 1, 'b': 2}
     >>> print(l_outer[1])
     {'c': 3, 'z': 26}

(プロキシでない) 標準の *note list: 5dc. オブジェクトや *note dict: 237.
オブジェクトが参照対象に含まれていた場合、それらの可変な値の変更はマネー
ジャーからは伝搬されません。 というのも、プロキシには参照対象の中に含ま
れる値がいつ変更されたかを知る術が無いのです。 しかし、コンテナプロキシ
に値を保存する (これはプロキシオブジェクトの ‘__setitem__’ を起動します)
場合はマネージャーを通して変更が伝搬され、その要素を実際に変更するために
、コンテナプロキシに変更後の値が再代入されます:

     # create a list proxy and append a mutable object (a dictionary)
     lproxy = manager.list()
     lproxy.append({})
     # now mutate the dictionary
     d = lproxy[0]
     d['a'] = 1
     d['b'] = 2
     # at this point, the changes to d are not yet synced, but by
     # updating the dictionary, the proxy is notified of the change
     lproxy[0] = d

This approach is perhaps less convenient than employing nested *note
Proxy オブジェクト: c87. for most use cases but also demonstrates a
level of control over the synchronization.

     注釈: *note multiprocessing: 86. のプロキシ型は値による比較に対して
     何もサポートしません。そのため、例えば以下のようになります:

          >>> manager.list([1,2,3]) == [1,2,3]
          False

     比較を行いたいときは参照対象のコピーを使用してください。

 -- クラス: multiprocessing.managers.BaseProxy

     プロキシオブジェクトは *note BaseProxy: 3031. のサブクラスのインス
     タンスです。

      -- メソッド: _callmethod (methodname[, args[, kwds]])

          プロキシの参照対象のメソッドの実行結果を返します。

          ‘proxy’ がプロキシで、プロキシ内の参照対象が ‘obj’ ならこの式

               proxy._callmethod(methodname, args, kwds)

          はこの式を評価します

               getattr(obj, methodname)(*args, **kwds)

          (マネージャープロセス内の)。

          返される値はその呼び出し結果のコピーか、新たな共有オブジェクト
          に対するプロキシになります。詳細は *note
          BaseManager.register(): 3030. の 'method_to_typeid' 引数のドキ
          ュメントを参照してください。

          その呼び出しによって例外が発生した場合、*note _callmethod():
          3032. によってその例外は再送出されます。他の例外がマネージャー
          プロセスで発生したなら、‘RemoteError’ 例外に変換されたものが
          *note _callmethod(): 3032. によって送出されます。

          特に 'methodname' が '公開' されていない場合は例外が発生するこ
          とに注意してください。

          *note _callmethod(): 3032. の使用例になります:

               >>> l = manager.list(range(10))
               >>> l._callmethod('__len__')
               10
               >>> l._callmethod('__getitem__', (slice(2, 7),)) # equivalent to l[2:7]
               [2, 3, 4, 5, 6]
               >>> l._callmethod('__getitem__', (20,))          # equivalent to l[20]
               Traceback (most recent call last):
               ...
               IndexError: list index out of range

      -- メソッド: _getvalue ()

          参照対象のコピーを返します。

          参照対象が unpickle 化できるなら例外を発生します。

      -- メソッド: __repr__ ()

          プロキシオブジェクトのオブジェクト表現を返します。

      -- メソッド: __str__ ()

          参照対象のオブジェクト表現を返します。

* Menu:

* クリーンアップ::


File: python.info,  Node: クリーンアップ,  Up: Proxy オブジェクト

5.17.2.20 クリーンアップ
........................

プロキシオブジェクトは弱参照(weakref)コールバックを使用します。プロキシ
オブジェクトがガベージコレクトされるときにその参照対象が所有するマネージ
ャーからその登録を取り消せるようにするためです。

共有オブジェクトはプロキシが参照しなくなったときにマネージャープロセスか
ら削除されます。


File: python.info,  Node: プロセスプール,  Next: リスナーとクライアント,  Prev: Proxy オブジェクト,  Up: リファレンス<2>

5.17.2.21 プロセスプール
........................

*note Pool: f38. クラスでタスクを実行するプロセスのプールを作成すること
ができます。

 -- クラス: multiprocessing.pool.Pool ([processes[, initializer[,
          initargs[, maxtasksperchild[, context]]]]])

     プロセスプールオブジェクトは、ジョブを送り込めるワーカープロセスの
     プールを制御します。タイムアウトやコールバックのある非同期の実行を
     サポートし、並列 map 実装を持ちます。

     'processes' is the number of worker processes to use.  If
     'processes' is ‘None’ then the number returned by *note
     os.process_cpu_count(): 1a6. is used.

     'initializer' が ‘None’ ではない場合、各ワーカープロセスは開始時に
     ‘initializer(*initargs)’ を呼び出します。

     'maxtasksperchild' は、ワーカープロセスが exit して新たなワーカープ
     ロセスと置き替えられるまでの間に、ワーカープロセスが完了することの
     できるタスクの数です。この設定により未利用のリソースが解放されるよ
     うなります。デフォルトの 'maxtasksperchild' は ‘None’ で、これはワ
     ーカープロセスがプールと同じ期間だけ生き続けるということを意味しま
     す。

     'context' はワーカープロセスを開始するために使用されるコンテキスト
     の指定に使用できます。通常プールは関数 ‘multiprocessing.Pool()’ か
     コンテキストオブジェクトの *note Pool(): f38. メソッドを使用して作
     成されます。どちらの場合でも 'context' は適切に設定されます。

     プールオブジェクトのメソッドは、そのプールを作成したプロセスのみが
     呼び出すべきです。

          警告: *note multiprocessing.pool: 8a. objects have internal
          resources that need to be properly managed (like any other
          resource) by using the pool as a context manager or by calling
          *note close(): 3047. and *note terminate(): 3048. manually.
          Failure to do this can lead to the process hanging on
          finalization.

          Note that it is 'not correct' to rely on the garbage collector
          to destroy the pool as CPython does not assure that the
          finalizer of the pool will be called (see *note
          object.__del__(): 1ec1. for more information).

     バージョン 3.2 で変更: Added the 'maxtasksperchild' parameter.

     バージョン 3.4 で変更: 'context' パラメータを追加しました。

     バージョン 3.13 で変更: 'processes' uses *note
     os.process_cpu_count(): 1a6. by default, instead of *note
     os.cpu_count(): 1a7.

          注釈: *note Pool: f38. 中のワーカープロセスは、典型的にはプー
          ルのワークキューの存続期間とちょうど同じだけ生き続けます。ワー
          カーに確保されたリソースを解放するために (Apache, mod_wsgi, な
          どのような) 他のシステムによく見られるパターンは、プール内のワ
          ーカーが設定された量だけの仕事を完了したら exit とクリーンアッ
          プを行い、古いプロセスを置き換えるために新しいプロセスを生成す
          るというものです。 *note Pool: f38. の 'maxtasksperchild' 引数
          は、この能力をエンドユーザーに提供します。

      -- メソッド: apply (func[, args[, kwds]])

          引数 'args' とキーワード引数 'kwds' を伴って 'func' を呼びます
          。結果が準備できるまでブロックします。このブロックがあるため、
          *note apply_async(): 304a. の方が並行作業により適しています。
          加えて、 'func' は、プール内の1つのワーカーだけで実行されます
          。

      -- メソッド: apply_async (func[, args[, kwds[, callback[,
               error_callback]]]])

          *note apply(): 3049. メソッドの派生版で *note AsyncResult:
          304b. オブジェクトを返します。

          'callback' が指定された場合、それは単一の引数を受け取る呼び出
          し可能オブジェクトでなければなりません。結果を返せるようになっ
          たときに 'callback' が結果オブジェクトに対して適用されます。た
          だし呼び出しが失敗した場合は、代わりに 'error_callback' が適用
          されます。

          'error_callback' が指定された場合、それは単一の引数を受け取る
          呼び出し可能オブジェクトでなければなりません。対象の関数が失敗
          した場合、例外インスタンスを伴って 'error_callback' が呼ばれま
          す。

          コールバックは直ちに完了すべきです。なぜなら、そうしなければ、
          結果を扱うスレッドがブロックするからです。

      -- メソッド: map (func, iterable[, chunksize])

          *note map(): 82f. 組み込み関数の並列版です ('iterable' な引数
          を1つだけサポートするという違いはあります。もしも複数のイテラ
          ブルを使いたいのならば *note starmap(): 10b8. を参照)。結果が
          出るまでブロックします。

          このメソッドはイテラブルをいくつものチャンクに分割し、プロセス
          プールにそれぞれ独立したタスクとして送ります。(概算の) チャン
          クサイズは 'chunksize' を正の整数に設定することで指定できます
          。

          Note that it may cause high memory usage for very long
          iterables.  Consider using *note imap(): 304c. or *note
          imap_unordered(): 304d. with explicit 'chunksize' option for
          better efficiency.

      -- メソッド: map_async (func, iterable[, chunksize[, callback[,
               error_callback]]])

          *note map(): 10b6. メソッドの派生版で *note AsyncResult: 304b.
          オブジェクトを返します。

          'callback' が指定された場合、それは単一の引数を受け取る呼び出
          し可能オブジェクトでなければなりません。結果を返せるようになっ
          たときに 'callback' が結果オブジェクトに対して適用されます。た
          だし呼び出しが失敗した場合は、代わりに 'error_callback' が適用
          されます。

          'error_callback' が指定された場合、それは単一の引数を受け取る
          呼び出し可能オブジェクトでなければなりません。対象の関数が失敗
          した場合、例外インスタンスを伴って 'error_callback' が呼ばれま
          す。

          コールバックは直ちに完了すべきです。なぜなら、そうしなければ、
          結果を扱うスレッドがブロックするからです。

      -- メソッド: imap (func, iterable[, chunksize])

          *note map(): 10b6. の遅延評価版です。

          'chunksize' 引数は *note map(): 10b6. メソッドで使用されるもの
          と同じです。 引数 iterable がとても長いなら 'chunksize' に大き
          な値を指定して使用する方がデフォルト値の ‘1’ を使用するよりも
          ジョブの完了が 'かなり' 速くなります。

          また 'chunksize' が ‘1’ の場合 *note imap(): 304c. メソッドが
          返すイテレーターの ‘next()’ メソッドはオプションで 'timeout' パ
          ラメーターを持ちます。 ‘next(timeout)’ は、その結果が
          'timeout' 秒以内に返されないときに *note
          multiprocessing.TimeoutError: 2ff9. を発生させます。

      -- メソッド: imap_unordered (func, iterable[, chunksize])

          イテレーターが返す結果の順番が任意の順番で良いと見なされること
          を除けば *note imap(): 304c. と同じです。 (ワーカープロセスが
          1つしかない場合のみ "正しい" 順番になることが保証されます。)

      -- メソッド: starmap (func, iterable[, chunksize])

          'iterable' の要素が、引数として unpack されるイテレート可能オ
          ブジェクトであると期待される以外は、 *note map(): 10b6. と似て
          います。

          そのため、'iterable' が ‘[(1,2), (3, 4)]’ なら、結果は
          ‘[func(1,2), func(3,4)]’ になります。

          Added in version 3.3.

      -- メソッド: starmap_async (func, iterable[, chunksize[,
               callback[, error_callback]]])

          *note starmap(): 10b8. と *note map_async(): 10b7. の組み合わ
          せです。 イテレート可能オブジェクトの 'iterable' をイテレート
          して、 unpack したイテレート可能オブジェクトを伴って 'func' を
          呼び出します。結果オブジェクトを返します。

          Added in version 3.3.

      -- メソッド: close ()

          これ以上プールでタスクが実行されないようにします。すべてのタス
          クが完了した後でワーカープロセスが終了します。

      -- メソッド: terminate ()

          実行中の処理を完了させずにワーカープロセスをすぐに停止します。
          プールオブジェクトがガベージコレクトされるときに *note
          terminate(): 3048. が呼び出されます。

      -- メソッド: join ()

          ワーカープロセスが終了するのを待ちます。 *note join(): 304e. を
          使用する前に *note close(): 3047. か *note terminate(): 3048.
          を呼び出さなければなりません。

     バージョン 3.3 で変更: Pool オブジェクトがコンテキストマネージメン
     ト・プロトコルをサポートするようになりました。 - *note
     コンテキストマネージャ型: 1f20. を参照してください。 *note
     __enter__(): 21a5. は Pool オブジェクトを返します。また *note
     __exit__(): 21a6. は *note terminate(): 3048. を呼び出します。

 -- クラス: multiprocessing.pool.AsyncResult

     *note Pool.apply_async(): 304a. や *note Pool.map_async(): 10b7. で
     返される結果のクラスです。

      -- メソッド: get ([timeout])

          結果を受け取ったときに返します。 'timeout' が ‘None’ ではなく
          て、その結果が 'timeout' 秒以内に受け取れない場合 *note
          multiprocessing.TimeoutError: 2ff9. が発生します。リモートの呼
          び出しが例外を発生させる場合、その例外は *note get(): 304f. が
          再発生させます。

      -- メソッド: wait ([timeout])

          その結果が有効になるか 'timeout' 秒経つまで待ちます。

      -- メソッド: ready ()

          その呼び出しが完了しているかどうかを返します。

      -- メソッド: successful ()

          その呼び出しが例外を発生させることなく完了したかどうかを返しま
          す。その結果が返せる状態でない場合 *note ValueError: 1e3. が発
          生します。

          バージョン 3.7 で変更: If the result is not ready, *note
          ValueError: 1e3. is raised instead of *note AssertionError:
          675.

次の例はプールの使用例を紹介します:

     from multiprocessing import Pool
     import time

     def f(x):
         return x*x

     if __name__ == '__main__':
         with Pool(processes=4) as pool:         # start 4 worker processes
             result = pool.apply_async(f, (10,)) # evaluate "f(10)" asynchronously in a single process
             print(result.get(timeout=1))        # prints "100" unless your computer is *very* slow

             print(pool.map(f, range(10)))       # prints "[0, 1, 4,..., 81]"

             it = pool.imap(f, range(10))
             print(next(it))                     # prints "0"
             print(next(it))                     # prints "1"
             print(it.next(timeout=1))           # prints "4" unless your computer is *very* slow

             result = pool.apply_async(time.sleep, (10,))
             print(result.get(timeout=1))        # raises multiprocessing.TimeoutError


File: python.info,  Node: リスナーとクライアント,  Next: 認証キー,  Prev: プロセスプール,  Up: リファレンス<2>

5.17.2.22 リスナーとクライアント
................................

通常、プロセス間でメッセージを渡すにはキューを使用するか *note Pipe():
2fe0. が返す *note Connection: 160e. オブジェクトを使用します。

しかし *note multiprocessing.connection: 87. モジュールにはさらに柔軟な
仕組みがあります。 このモジュールは、基本的にはソケットもしくは Windows
の名前付きパイプを扱う高レベルのメッセージ指向 API を提供します。また、
*note hmac: 60. モジュールを使用した 'ダイジェスト認証' や同時の複数接続
のポーリングもサポートします。

 -- の関数: multiprocessing.connection.deliver_challenge (connection,
          authkey)

     ランダム生成したメッセージをコネクションの相手側へ送信して応答を待
     ちます。

     その応答がキーとして 'authkey' を使用するメッセージのダイジェストと
     一致する場合、 コネクションの相手側へ歓迎メッセージを送信します。 そ
     うでなければ *note AuthenticationError: 2ff8. を発生させます。

 -- の関数: multiprocessing.connection.answer_challenge (connection,
          authkey)

     メッセージを受信して、そのキーとして 'authkey' を使用するメッセージ
     のダイジェストを計算し、ダイジェストを送り返します。

     歓迎メッセージを受け取れない場合 *note AuthenticationError: 2ff8. が
     発生します。

 -- の関数: multiprocessing.connection.Client (address[, family[,
          authkey]])

     'address' で渡したアドレスを使用するリスナーに対してコネクションを
     確立しようとして *note Connection: 160e. を返します。

     コネクション種別は 'family' 引数で決定しますが、一般的には
     'address' のフォーマットから推測できるので、これは指定されません。
     (*note アドレスフォーマット: 3057. を参照してください)

     If 'authkey' is given and not ‘None’, it should be a byte string
     and will be used as the secret key for an HMAC-based authentication
     challenge.  No authentication is done if 'authkey' is ‘None’.
     *note AuthenticationError: 2ff8. is raised if authentication fails.
     See *note 認証キー: 2ff4.

 -- クラス: multiprocessing.connection.Listener ([address[, family[,
          backlog[, authkey]]]])

     コネクションを '待ち受ける' 束縛されたソケットか Windows の名前付き
     パイプのラッパーです。

     'address' はリスナーオブジェクトの束縛されたソケットか名前付きパイ
     プが使用するアドレスです。

          注釈: '0.0.0.0' のアドレスを使用する場合、Windows 上の終点へ接
          続することができません。終点へ接続したい場合は '127.0.0.1' を
          使用すべきです。

     'family' は使用するソケット(名前付きパイプ)の種別です。これは
     ‘'AF_INET'’ (TCP ソケット), ‘'AF_UNIX'’ (Unix ドメインソケット) ま
     たは ‘'AF_PIPE'’ (Windows 名前付きパイプ) という文字列のどれか1つに
     なります。これらのうち ‘'AF_INET'’ のみが利用可能であることが保証さ
     れています。 'family' が ‘None’ の場合 'address' のフォーマットから
     推測されたものが使用されます。 'address' も ‘None’ の場合はデフォル
     トが選択されます。詳細は *note アドレスフォーマット: 3057. を参照し
     てください。 'family' が ‘'AF_UNIX'’ で 'address' が ‘None’ の場合
     *note tempfile.mkstemp(): 27a4. を使用して作成されたプライベートな
     一時ディレクトリにソケットが作成されます。

     リスナーオブジェクトがソケットを使用する場合、ソケットに束縛される
     ときに 'backlog' (デフォルトでは1つ) がソケットの *note listen():
     e27. メソッドに対して渡されます。

     If 'authkey' is given and not ‘None’, it should be a byte string
     and will be used as the secret key for an HMAC-based authentication
     challenge.  No authentication is done if 'authkey' is ‘None’.
     *note AuthenticationError: 2ff8. is raised if authentication fails.
     See *note 認証キー: 2ff4.

      -- メソッド: accept ()

          リスナーオブジェクトの名前付きパイプか束縛されたソケット上でコ
          ネクションを 受け付けて *note Connection: 160e. オブジェクトを
          返します。 認証が失敗した場合 *note AuthenticationError: 2ff8.
          が発生します。

      -- メソッド: close ()

          リスナーオブジェクトの名前付きパイプか束縛されたソケットをクロ
          ーズします。これはリスナーがガベージコレクトされるときに自動的
          に呼ばれます。そうは言っても、明示的に close() を呼び出す方が
          望ましいです。

     リスナーオブジェクトは次の読み出し専用属性を持っています:

      -- の属性: address

          リスナーオブジェクトが使用中のアドレスです。

      -- の属性: last_accepted

          最後にコネクションを受け付けたアドレスです。有効なアドレスがな
          い場合は ‘None’ になります。

     バージョン 3.3 で変更: Listener オブジェクトがコンテキストマネージ
     メント・プロトコルをサポートするようになりました。 - *note
     コンテキストマネージャ型: 1f20. を参照してください。 *note
     __enter__(): 21a5. はリスナーオブジェクトを返します。また *note
     __exit__(): 21a6. は *note close(): 3058. を呼び出します。

 -- の関数: multiprocessing.connection.wait (object_list, timeout=None)

     'object_list' 中のオブジェクトが準備ができるまで待機します。準備が
     できた 'object_list' 中のオブジェクトのリストを返します。'timeout'
     が浮動小数点なら、最大でその秒数だけ呼び出しがブロックします。
     'timeout' が ‘None’ の場合、無制限の期間ブロックします。負のタイム
     アウトは0と等価です。

     For both POSIX and Windows, an object can appear in 'object_list'
     if it is

        * 読み取り可能な *note Connection: 160e. オブジェクト;

        * 接続された読み取り可能な *note socket.socket: d6e. オブジェク
          ト; または

        * *note Process: b27. オブジェクトの *note sentinel: 10b4. 属性
          。

     読み取ることのできるデータがある場合、あるいは相手側の端が閉じられ
     ている場合、コネクションまたはソケットオブジェクトは準備ができてい
     ます。

     'POSIX': ‘wait(object_list, timeout)’ almost equivalent
     ‘select.select(object_list, [], [], timeout)’.  The difference is
     that, if *note select.select(): d6d. is interrupted by a signal, it
     can raise *note OSError: 3f0. with an error number of ‘EINTR’,
     whereas *note wait(): 10b3. will not.

     'Windows': An item in 'object_list' must either be an integer
     handle which is waitable (according to the definition used by the
     documentation of the Win32 function ‘WaitForMultipleObjects()’) or
     it can be an object with a *note fileno(): 27a6. method which
     returns a socket handle or pipe handle.  (Note that pipe handles
     and socket handles are 'not' waitable handles.)

     Added in version 3.3.

'例'

次のサーバーコードは認証キーとして ‘'secret password'’ を使用するリスナ
ーを作成します。このサーバーはコネクションを待ってクライアントへデータを
送信します:

     from multiprocessing.connection import Listener
     from array import array

     address = ('localhost', 6000)     # family is deduced to be 'AF_INET'

     with Listener(address, authkey=b'secret password') as listener:
         with listener.accept() as conn:
             print('connection accepted from', listener.last_accepted)

             conn.send([2.25, None, 'junk', float])

             conn.send_bytes(b'hello')

             conn.send_bytes(array('i', [42, 1729]))

次のコードはサーバーへ接続して、サーバーからデータを受信します:

     from multiprocessing.connection import Client
     from array import array

     address = ('localhost', 6000)

     with Client(address, authkey=b'secret password') as conn:
         print(conn.recv())                  # => [2.25, None, 'junk', float]

         print(conn.recv_bytes())            # => 'hello'

         arr = array('i', [0, 0, 0, 0, 0])
         print(conn.recv_bytes_into(arr))    # => 8
         print(arr)                          # => array('i', [42, 1729, 0, 0, 0])

次のコードは *note wait(): 10b3. を使って複数のプロセスからのメッセージ
を同時に待ちます:

     from multiprocessing import Process, Pipe, current_process
     from multiprocessing.connection import wait

     def foo(w):
         for i in range(10):
             w.send((i, current_process().name))
         w.close()

     if __name__ == '__main__':
         readers = []

         for i in range(4):
             r, w = Pipe(duplex=False)
             readers.append(r)
             p = Process(target=foo, args=(w,))
             p.start()
             # We close the writable end of the pipe now to be sure that
             # p is the only process which owns a handle for it.  This
             # ensures that when p closes its handle for the writable end,
             # wait() will promptly report the readable end as being ready.
             w.close()

         while readers:
             for r in wait(readers):
                 try:
                     msg = r.recv()
                 except EOFError:
                     readers.remove(r)
                 else:
                     print(msg)

* Menu:

* アドレスフォーマット::


File: python.info,  Node: アドレスフォーマット,  Up: リスナーとクライアント

5.17.2.23 アドレスフォーマット
..............................

   * ‘'AF_INET'’ アドレスは ‘(hostname, port)’ のタプルになります。
     'hostname' は文字列で 'port' は整数です。

   * ‘'AF_UNIX'’ アドレスはファイルシステム上のファイル名の文字列です。

   * ‘'AF_PIPE'’ アドレスは ‘r'\\.\pipe\PIPENAME'’ という形式の文字列で
     す。 'ServerName' という名前のリモートコンピューター上の名前付きパ
     イプに接続するために *note Client(): 3056. を使用するには、代わりに
     ‘r'\\SERVERNAME\pipe\PIPENAME'’ 形式のアドレスを使用する必要があり
     ます。

デフォルトでは、2つのバックスラッシュで始まる文字列は ‘'AF_UNIX'’ よりも
‘'AF_PIPE'’ として推測されることに注意してください。


File: python.info,  Node: 認証キー,  Next: ログ記録<2>,  Prev: リスナーとクライアント,  Up: リファレンス<2>

5.17.2.24 認証キー
..................

‘Connection.recv’ を使用するとき、データは自動的に unpickle されて受信し
ます。 信頼できない接続元からのデータを unpickle することはセキュリティ
リスクがあります。 そのため *note Listener: 160d. や *note Client():
3056. はダイジェスト認証を提供するために *note hmac: 60. モジュールを使
用します。

認証キーはパスワードとして見なされるバイト文字列です。コネクションが確立
すると、双方の終点で正しい接続先であることを証明するために 知っているお
互いの認証キーを要求します。(双方の終点が同じキーを使用して通信しようと
しても、コネクション上でそのキーを送信することは 'できません'。)

認証が要求されているにもかかわらず認証キーが指定されていない場合
‘current_process().authkey’ の返す値が使用されます。 (詳細は *note
Process: b27. を参照してください。) この値はカレントプロセスを作成する
*note Process: b27. オブジェクトによって自動的に継承されます。 これは(デ
フォルトでは)複数プロセスのプログラムの全プロセスが相互にコネクションを
確立するときに使用される1つの認証キーを共有することを意味します。

適当な認証キーを *note os.urandom(): 4ec. を使用して生成することもできま
す。


File: python.info,  Node: ログ記録<2>,  Next: multiprocessing dummy モジュール,  Prev: 認証キー,  Up: リファレンス<2>

5.17.2.25 ログ記録
..................

ロギングのためにいくつかの機能が利用可能です。しかし *note logging: 7b.
パッケージは、 (ハンドラー種別に依存して)違うプロセスからのメッセージが
ごちゃ混ぜになるので、プロセスの共有ロックを使用しないことに注意してくだ
さい。

 -- の関数: multiprocessing.get_logger ()

     *note multiprocessing: 86. が使用するロガーを返します。必要に応じて
     新たなロガーを作成します。

     When first created the logger has level *note logging.NOTSET: 2c2c.
     and no default handler.  Messages sent to this logger will not by
     default propagate to the root logger.

     Windows 上では子プロセスが親プロセスのロガーレベルを継承しないこと
     に注意してください。さらにその他のロガーのカスタマイズ内容もすべて
     継承されません。

 -- の関数: multiprocessing.log_to_stderr (level=None)

     この関数は *note get_logger(): 305e. に対する呼び出しを実行しますが
     、 get_logger によって作成されるロガーを返すことに加えて、
     ‘'[%(levelname)s/%(processName)s] %(message)s'’ のフォーマットを使
     用して *note sys.stderr: 907. へ出力を送るハンドラーを追加します。
     ‘level’ 引数を渡すことによってロガーの ‘levelname’ を変更できます。

以下にロギングを有効にした例を紹介します:

     >>> import multiprocessing, logging
     >>> logger = multiprocessing.log_to_stderr()
     >>> logger.setLevel(logging.INFO)
     >>> logger.warning('doomed')
     [WARNING/MainProcess] doomed
     >>> m = multiprocessing.Manager()
     [INFO/SyncManager-...] child process calling self.run()
     [INFO/SyncManager-...] created temp directory /.../pymp-...
     [INFO/SyncManager-...] manager serving at '/.../listener-...'
     >>> del m
     [INFO/MainProcess] sending shutdown message to manager
     [INFO/SyncManager-...] manager exiting with exitcode 0

完全なロギングレベルの表については *note logging: 7b. モジュールを参照し
てください。


File: python.info,  Node: multiprocessing dummy モジュール,  Prev: ログ記録<2>,  Up: リファレンス<2>

5.17.2.26 ‘multiprocessing.dummy’ モジュール
............................................

*note multiprocessing.dummy: 88. は *note multiprocessing: 86. の API を
複製しますが *note threading: d6. モジュールのラッパーでしかありません。

In particular, the ‘Pool’ function provided by *note
multiprocessing.dummy: 88. returns an instance of *note ThreadPool:
187b, which is a subclass of *note Pool: f38. that supports all the same
method calls but uses a pool of worker threads rather than worker
processes.

 -- クラス: multiprocessing.pool.ThreadPool ([processes[, initializer[,
          initargs]]])

     A thread pool object which controls a pool of worker threads to
     which jobs can be submitted.  *note ThreadPool: 187b. instances are
     fully interface compatible with *note Pool: f38. instances, and
     their resources must also be properly managed, either by using the
     pool as a context manager or by calling *note close(): 3047. and
     *note terminate(): 3048. manually.

     'processes' is the number of worker threads to use.  If 'processes'
     is ‘None’ then the number returned by *note os.process_cpu_count():
     1a6. is used.

     'initializer' が ‘None’ ではない場合、各ワーカープロセスは開始時に
     ‘initializer(*initargs)’ を呼び出します。

     Unlike *note Pool: f38, 'maxtasksperchild' and 'context' cannot be
     provided.

          注釈: A *note ThreadPool: 187b. shares the same interface as
          *note Pool: f38, which is designed around a pool of processes
          and predates the introduction of the *note concurrent.futures:
          1a. module.  As such, it inherits some operations that don't
          make sense for a pool backed by threads, and it has its own
          type for representing the status of asynchronous jobs, *note
          AsyncResult: 304b, that is not understood by any other
          libraries.

          Users should generally prefer to use *note
          concurrent.futures.ThreadPoolExecutor: 70d, which has a
          simpler interface that was designed around threads from the
          start, and which returns *note concurrent.futures.Future:
          1182. instances that are compatible with many other libraries,
          including *note asyncio: 8.


File: python.info,  Node: プログラミングガイドライン,  Next: 使用例<20>,  Prev: リファレンス<2>,  Up: multiprocessing --- プロセスベースの並列処理

5.17.2.27 プログラミングガイドライン
....................................

*note multiprocessing: 86. を使用するときに守るべき一定のガイドラインと
イディオムを挙げます。

* Menu:

* すべての開始方式について::
* 開始方式が spawn および forkserver の場合::


File: python.info,  Node: すべての開始方式について,  Next: 開始方式が spawn および forkserver の場合,  Up: プログラミングガイドライン

5.17.2.28 すべての開始方式について
..................................

以下はすべての開始方式に当てはまります。

共有状態を避ける

     できるだけプロセス間で巨大なデータを移動することは避けるようにすべ
     きです。

     プロセス間の通信には、*note threading: d6. モジュールの低レベルな同
     期プリミティブを使うのではなく、キューやパイプを使うのが良いでしょ
     う。

pickle 化の可能性

     プロキシのメソッドへの引数は、 pickle 化できるものにしてください。

プロキシのスレッドセーフ性

     1 つのプロキシオブジェクトは、ロックで保護しないかぎり、2 つ以上の
     スレッドから使用してはいけません。

     (異なるプロセスで '同じ' プロキシを使用することは問題ではありません
     。)

ゾンビプロセスを join する

     On POSIX when a process finishes but has not been joined it becomes
     a zombie.  There should never be very many because each time a new
     process starts (or *note active_children(): 300d. is called) all
     completed processes which have not yet been joined will be joined.
     Also calling a finished process's *note Process.is_alive: 2ff1.
     will join the process.  Even so it is probably good practice to
     explicitly join all the processes that you start.

pickle/unpickle より継承する方が良い

     開始方式に 'spawn' あるいは 'forkserver' を使用している場合、*note
     multiprocessing: 86. から多くの型を pickle 化する必要があるため子プ
     ロセスはそれらを使うことができます。しかし、一般にパイプやキューを
     使用して共有オブジェクトを他のプロセスに送信することは避けるべきで
     す。代わりに、共有リソースにアクセスする必要のあるプロセスは上位プ
     ロセスからそれらを継承するようにすべきです。

プロセスの強制終了を避ける

     あるプロセスを停止するために *note Process.terminate: 2ff5. メソッ
     ドを使用すると、そのプロセスが現在使用されている (ロック、セマフォ
     、パイプやキューのような) 共有リソースを破壊したり他のプロセスから
     利用できない状態を引き起こし易いです。

     そのため、共有リソースを使用しないプロセスでのみ *note
     Process.terminate: 2ff5. を使用することを考慮することがおそらく最善
     の方法です。

キューを使用するプロセスを join する

     キューに要素を追加するプロセスは、すべてのバッファーされた要素が
     "feeder" スレッドによって下位層のパイプに対してフィードされるまで終
     了を待つということを覚えておいてください。 (子プロセスはこの動作を
     避けるためにキューの *note Queue.cancel_join_thread: 3003. メソッド
     を呼ぶことができます。)

     これはキューを使用するときに、キューに追加されたすべての要素が最終
     的にそのプロセスが join される前に削除されていることを確認する必要
     があることを意味します。そうしないと、そのキューに要素が追加したプ
     ロセスの終了を保証できません。デーモンではないプロセスは自動的に
     join されることも覚えておいてください。

     次の例はデッドロックを引き起こします:

          from multiprocessing import Process, Queue

          def f(q):
              q.put('X' * 1000000)

          if __name__ == '__main__':
              queue = Queue()
              p = Process(target=f, args=(queue,))
              p.start()
              p.join()                    # this deadlocks
              obj = queue.get()

     修正するには最後の2行を入れ替えます(または単純に ‘p.join()’ の行を
     削除します)。

明示的に子プロセスへリソースを渡す

     On POSIX using the 'fork' start method, a child process can make
     use of a shared resource created in a parent process using a global
     resource.  However, it is better to pass the object as an argument
     to the constructor for the child process.

     Windows や他の開始方式と (将来的にでも) 互換性のあるコードを書く場
     合は別として、これは子プロセスが実行中である限りは親プロセス内でオ
     ブジェクトがガベージコレクトされないことも保証します。これは親プロ
     セス内でオブジェクトがガベージコレクトされたときに一部のリソースが
     開放されてしまう場合に重要かもしれません。

     そのため、例えば

          from multiprocessing import Process, Lock

          def f():
              ... do something using "lock" ...

          if __name__ == '__main__':
              lock = Lock()
              for i in range(10):
                  Process(target=f).start()

     は、次のように書き直すべきです

          from multiprocessing import Process, Lock

          def f(l):
              ... do something using "l" ...

          if __name__ == '__main__':
              lock = Lock()
              for i in range(10):
                  Process(target=f, args=(lock,)).start()

*note sys.stdin: 507. を file-like オブジェクトに置き換えることに注意す
る

     *note multiprocessing: 86. は元々無条件に:

          os.close(sys.stdin.fileno())

     を ‘multiprocessing.Process._bootstrap()’ メソッドの中で呼び出して
     いました -- これはプロセス内プロセス (processes-in-processes) で問
     題が起こしてしまいます。そこで、これは以下のように変更されました:

          sys.stdin.close()
          sys.stdin = open(os.open(os.devnull, os.O_RDONLY), closefd=False)

     Which solves the fundamental issue of processes colliding with each
     other resulting in a bad file descriptor error, but introduces a
     potential danger to applications which replace *note sys.stdin():
     507. with a "file-like object" with output buffering.  This danger
     is that if multiple processes call *note close(): 1d7. on this
     file-like object, it could result in the same data being flushed to
     the object multiple times, resulting in corruption.

     もし file-like オブジェクトを書いて独自のキャッシュを実装するなら、
     キャッシュするときに常に pid を記録しておき、pid が変わったらキュッ
     シュを捨てることで、フォークセーフにできます。例:

          @property
          def cache(self):
              pid = os.getpid()
              if pid != self._pid:
                  self._pid = pid
                  self._cache = []
              return self._cache

     より詳しい情報は bpo-5155(1) 、 bpo-5313(2) 、 bpo-5331(3) を見てく
     ださい

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=5155

   (2) https://bugs.python.org/issue?@action=redirect&bpo=5313

   (3) https://bugs.python.org/issue?@action=redirect&bpo=5331


File: python.info,  Node: 開始方式が spawn および forkserver の場合,  Prev: すべての開始方式について,  Up: プログラミングガイドライン

5.17.2.29 開始方式が 'spawn' および 'forkserver' の場合
.......................................................

There are a few extra restrictions which don't apply to the 'fork' start
method.

さらなる pickle 化の可能性

     ‘Process.__init__()’ へのすべての引数は pickle 化できることを確認し
     てください。また *note Process: b27. をサブクラス化する場合、そのイ
     ンスタンスが *note Process.start: 2fdb. メソッドが呼ばれたときに
     pickle 化できるようにしてください。

グローバル変数

     子プロセスで実行されるコードがグローバル変数にアクセスしようとする
     場合、子プロセスが見るその値は *note Process.start: 2fdb. が呼ばれ
     たときの親プロセスの値と同じではない可能性があります。

     しかし、単にモジュールレベルの定数であるグローバル変数なら問題には
     なりません。
メインモジュールの安全なインポート

     Make sure that the main module can be safely imported by a new
     Python interpreter without causing unintended side effects (such as
     starting a new process).

     例えば、開始方式に 'spawn' あるいは 'forkserver' を使用した場合に以
     下のモジュールを実行すると *note RuntimeError: 17a. で失敗します:

          from multiprocessing import Process

          def foo():
              print('hello')

          p = Process(target=foo)
          p.start()

     代わりに、次のように ‘if __name__ == '__main__':’ を使用してプログ
     ラムの "エントリポイント" を保護すべきです:

          from multiprocessing import Process, freeze_support, set_start_method

          def foo():
              print('hello')

          if __name__ == '__main__':
              freeze_support()
              set_start_method('spawn')
              p = Process(target=foo)
              p.start()

     (プログラムをフリーズせずに通常通り実行するなら ‘freeze_support()’
     行は取り除けます。)

     これは新たに生成された Python インタープリターがそのモジュールを安
     全にインポートして、モジュールの ‘foo()’ 関数を実行します。

     プールまたはマネージャーがメインモジュールで作成される場合に似たよ
     うな制限が適用されます。


File: python.info,  Node: 使用例<20>,  Prev: プログラミングガイドライン,  Up: multiprocessing --- プロセスベースの並列処理

5.17.2.30 使用例
................

カスタマイズされたマネージャーやプロキシの作成方法と使用方法を紹介します
:

     from multiprocessing import freeze_support
     from multiprocessing.managers import BaseManager, BaseProxy
     import operator

     ##

     class Foo:
         def f(self):
             print('you called Foo.f()')
         def g(self):
             print('you called Foo.g()')
         def _h(self):
             print('you called Foo._h()')

     # A simple generator function
     def baz():
         for i in range(10):
             yield i*i

     # Proxy type for generator objects
     class GeneratorProxy(BaseProxy):
         _exposed_ = ['__next__']
         def __iter__(self):
             return self
         def __next__(self):
             return self._callmethod('__next__')

     # Function to return the operator module
     def get_operator_module():
         return operator

     ##

     class MyManager(BaseManager):
         pass

     # register the Foo class; make `f()` and `g()` accessible via proxy
     MyManager.register('Foo1', Foo)

     # register the Foo class; make `g()` and `_h()` accessible via proxy
     MyManager.register('Foo2', Foo, exposed=('g', '_h'))

     # register the generator function baz; use `GeneratorProxy` to make proxies
     MyManager.register('baz', baz, proxytype=GeneratorProxy)

     # register get_operator_module(); make public functions accessible via proxy
     MyManager.register('operator', get_operator_module)

     ##

     def test():
         manager = MyManager()
         manager.start()

         print('-' * 20)

         f1 = manager.Foo1()
         f1.f()
         f1.g()
         assert not hasattr(f1, '_h')
         assert sorted(f1._exposed_) == sorted(['f', 'g'])

         print('-' * 20)

         f2 = manager.Foo2()
         f2.g()
         f2._h()
         assert not hasattr(f2, 'f')
         assert sorted(f2._exposed_) == sorted(['g', '_h'])

         print('-' * 20)

         it = manager.baz()
         for i in it:
             print('<%d>' % i, end=' ')
         print()

         print('-' * 20)

         op = manager.operator()
         print('op.add(23, 45) =', op.add(23, 45))
         print('op.pow(2, 94) =', op.pow(2, 94))
         print('op._exposed_ =', op._exposed_)

     ##

     if __name__ == '__main__':
         freeze_support()
         test()

*note Pool: f38. を使用する例です:

     import multiprocessing
     import time
     import random
     import sys

     #
     # Functions used by test code
     #

     def calculate(func, args):
         result = func(*args)
         return '%s says that %s%s = %s' % (
             multiprocessing.current_process().name,
             func.__name__, args, result
             )

     def calculatestar(args):
         return calculate(*args)

     def mul(a, b):
         time.sleep(0.5 * random.random())
         return a * b

     def plus(a, b):
         time.sleep(0.5 * random.random())
         return a + b

     def f(x):
         return 1.0 / (x - 5.0)

     def pow3(x):
         return x ** 3

     def noop(x):
         pass

     #
     # Test code
     #

     def test():
         PROCESSES = 4
         print('Creating pool with %d processes\n' % PROCESSES)

         with multiprocessing.Pool(PROCESSES) as pool:
             #
             # Tests
             #

             TASKS = [(mul, (i, 7)) for i in range(10)] + \
                     [(plus, (i, 8)) for i in range(10)]

             results = [pool.apply_async(calculate, t) for t in TASKS]
             imap_it = pool.imap(calculatestar, TASKS)
             imap_unordered_it = pool.imap_unordered(calculatestar, TASKS)

             print('Ordered results using pool.apply_async():')
             for r in results:
                 print('\t', r.get())
             print()

             print('Ordered results using pool.imap():')
             for x in imap_it:
                 print('\t', x)
             print()

             print('Unordered results using pool.imap_unordered():')
             for x in imap_unordered_it:
                 print('\t', x)
             print()

             print('Ordered results using pool.map() --- will block till complete:')
             for x in pool.map(calculatestar, TASKS):
                 print('\t', x)
             print()

             #
             # Test error handling
             #

             print('Testing error handling:')

             try:
                 print(pool.apply(f, (5,)))
             except ZeroDivisionError:
                 print('\tGot ZeroDivisionError as expected from pool.apply()')
             else:
                 raise AssertionError('expected ZeroDivisionError')

             try:
                 print(pool.map(f, list(range(10))))
             except ZeroDivisionError:
                 print('\tGot ZeroDivisionError as expected from pool.map()')
             else:
                 raise AssertionError('expected ZeroDivisionError')

             try:
                 print(list(pool.imap(f, list(range(10)))))
             except ZeroDivisionError:
                 print('\tGot ZeroDivisionError as expected from list(pool.imap())')
             else:
                 raise AssertionError('expected ZeroDivisionError')

             it = pool.imap(f, list(range(10)))
             for i in range(10):
                 try:
                     x = next(it)
                 except ZeroDivisionError:
                     if i == 5:
                         pass
                 except StopIteration:
                     break
                 else:
                     if i == 5:
                         raise AssertionError('expected ZeroDivisionError')

             assert i == 9
             print('\tGot ZeroDivisionError as expected from IMapIterator.next()')
             print()

             #
             # Testing timeouts
             #

             print('Testing ApplyResult.get() with timeout:', end=' ')
             res = pool.apply_async(calculate, TASKS[0])
             while 1:
                 sys.stdout.flush()
                 try:
                     sys.stdout.write('\n\t%s' % res.get(0.02))
                     break
                 except multiprocessing.TimeoutError:
                     sys.stdout.write('.')
             print()
             print()

             print('Testing IMapIterator.next() with timeout:', end=' ')
             it = pool.imap(calculatestar, TASKS)
             while 1:
                 sys.stdout.flush()
                 try:
                     sys.stdout.write('\n\t%s' % it.next(0.02))
                 except StopIteration:
                     break
                 except multiprocessing.TimeoutError:
                     sys.stdout.write('.')
             print()
             print()


     if __name__ == '__main__':
         multiprocessing.freeze_support()
         test()

ワーカープロセスのコレクションに対してタスクをフィードしてその結果をまと
めるキューの使い方の例を紹介します:

     import time
     import random

     from multiprocessing import Process, Queue, current_process, freeze_support

     #
     # Function run by worker processes
     #

     def worker(input, output):
         for func, args in iter(input.get, 'STOP'):
             result = calculate(func, args)
             output.put(result)

     #
     # Function used to calculate result
     #

     def calculate(func, args):
         result = func(*args)
         return '%s says that %s%s = %s' % \
             (current_process().name, func.__name__, args, result)

     #
     # Functions referenced by tasks
     #

     def mul(a, b):
         time.sleep(0.5*random.random())
         return a * b

     def plus(a, b):
         time.sleep(0.5*random.random())
         return a + b

     #
     #
     #

     def test():
         NUMBER_OF_PROCESSES = 4
         TASKS1 = [(mul, (i, 7)) for i in range(20)]
         TASKS2 = [(plus, (i, 8)) for i in range(10)]

         # Create queues
         task_queue = Queue()
         done_queue = Queue()

         # Submit tasks
         for task in TASKS1:
             task_queue.put(task)

         # Start worker processes
         for i in range(NUMBER_OF_PROCESSES):
             Process(target=worker, args=(task_queue, done_queue)).start()

         # Get and print results
         print('Unordered results:')
         for i in range(len(TASKS1)):
             print('\t', done_queue.get())

         # Add more tasks using `put()`
         for task in TASKS2:
             task_queue.put(task)

         # Get and print some more results
         for i in range(len(TASKS2)):
             print('\t', done_queue.get())

         # Tell child processes to stop
         for i in range(NUMBER_OF_PROCESSES):
             task_queue.put('STOP')


     if __name__ == '__main__':
         freeze_support()
         test()


File: python.info,  Node: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ,  Next: concurrent パッケージ,  Prev: multiprocessing --- プロセスベースの並列処理,  Up: 並行実行

5.17.3 ‘multiprocessing.shared_memory’ -- プロセス間で直接アクセス可能な共有メモリ
----------------------------------------------------------------------------------

'ソースコード' Lib/multiprocessing/shared_memory.py(1)

Added in version 3.8.

__________________________________________________________________

このモジュールは、マルチコアもしくは対称型マルチプロセッサ(SMP) を持つマ
シン上で実行される、ひとつ以上のプロセスから参照される共有メモリの確保、
管理を行うための *note SharedMemory: 15bd. クラスを提供します。共有メモ
リのライフサイクル管理、とりわけ複数のプロセスにわたる場合のために、
*note multiprocessing.managers: 89. モジュールでは *note BaseManager:
302a. のサブクラス *note SharedMemoryManager: 3068. も提供されます。

In this module, shared memory refers to "POSIX style" shared memory
blocks (though is not necessarily implemented explicitly as such) and
does not refer to "distributed shared memory".  This style of shared
memory permits distinct processes to potentially read and write to a
common (or shared) region of volatile memory.  Processes are
conventionally limited to only have access to their own process memory
space but shared memory permits the sharing of data between processes,
avoiding the need to instead send messages between processes containing
that data.  Sharing data directly via memory can provide significant
performance benefits compared to sharing data via disk or socket or
other communications requiring the serialization/deserialization and
copying of data.

 -- クラス: multiprocessing.shared_memory.SharedMemory (name=None,
          create=False, size=0, *, track=True)

     Create an instance of the ‘SharedMemory’ class for either creating
     a new shared memory block or attaching to an existing shared memory
     block.  Each shared memory block is assigned a unique name.  In
     this way, one process can create a shared memory block with a
     particular name and a different process can attach to that same
     shared memory block using that same name.

     As a resource for sharing data across processes, shared memory
     blocks may outlive the original process that created them.  When
     one process no longer needs access to a shared memory block that
     might still be needed by other processes, the *note close(): 3069.
     method should be called.  When a shared memory block is no longer
     needed by any process, the *note unlink(): 306a. method should be
     called to ensure proper cleanup.


     パラメータ:

        * ‘name’ (*note str: 418.‘ | ’‘None’) - The unique name for the
          requested shared memory, specified as a string.  When creating
          a new shared memory block, if ‘None’ (the default) is supplied
          for the name, a novel name will be generated.

        * ‘create’ (*note bool: 434.) - Control whether a new shared
          memory block is created (‘True’) or an existing shared memory
          block is attached (‘False’).

        * ‘size’ (*note int: 238.) - The requested number of bytes when
          creating a new shared memory block.  Because some platforms
          choose to allocate chunks of memory based upon that platform's
          memory page size, the exact size of the shared memory block
          may be larger or equal to the size requested.  When attaching
          to an existing shared memory block, the 'size' parameter is
          ignored.

        * ‘track’ (*note bool: 434.) - When ‘True’, register the shared
          memory block with a resource tracker process on platforms
          where the OS does not do this automatically.  The resource
          tracker ensures proper cleanup of the shared memory even if
          all other processes with access to the memory exit without
          doing so.  Python processes created from a common ancestor
          using *note multiprocessing: 86. facilities share a single
          resource tracker process, and the lifetime of shared memory
          segments is handled automatically among these processes.
          Python processes created in any other way will receive their
          own resource tracker when accessing shared memory with 'track'
          enabled.  This will cause the shared memory to be deleted by
          the resource tracker of the first process that terminates.  To
          avoid this issue, users of *note subprocess: c1. or standalone
          Python processes should set 'track' to ‘False’ when there is
          already another process in place that does the bookkeeping.
          'track' is ignored on Windows, which has its own tracking and
          automatically deletes shared memory when all handles to it
          have been closed.

     バージョン 3.13 で変更: Added the 'track' parameter.

      -- メソッド: close ()

          Close the file descriptor/handle to the shared memory from
          this instance.  *note close(): 3069. should be called once
          access to the shared memory block from this instance is no
          longer needed.  Depending on operating system, the underlying
          memory may or may not be freed even if all handles to it have
          been closed.  To ensure proper cleanup, use the *note
          unlink(): 306a. method.

      -- メソッド: unlink ()

          Delete the underlying shared memory block.  This should be
          called only once per shared memory block regardless of the
          number of handles to it, even in other processes.  *note
          unlink(): 306a. and *note close(): 3069. can be called in any
          order, but trying to access data inside a shared memory block
          after *note unlink(): 306a. may result in memory access
          errors, depending on platform.

          This method has no effect on Windows, where the only way to
          delete a shared memory block is to close all handles.

      -- の属性: buf

          A memoryview of contents of the shared memory block.

      -- の属性: name

          Read-only access to the unique name of the shared memory
          block.

      -- の属性: size

          Read-only access to size in bytes of the shared memory block.

The following example demonstrates low-level use of *note SharedMemory:
15bd. instances:

     >>> from multiprocessing import shared_memory
     >>> shm_a = shared_memory.SharedMemory(create=True, size=10)
     >>> type(shm_a.buf)
     <class 'memoryview'>
     >>> buffer = shm_a.buf
     >>> len(buffer)
     10
     >>> buffer[:4] = bytearray([22, 33, 44, 55])  # Modify multiple at once
     >>> buffer[4] = 100                           # Modify single byte at a time
     >>> # Attach to an existing shared memory block
     >>> shm_b = shared_memory.SharedMemory(shm_a.name)
     >>> import array
     >>> array.array('b', shm_b.buf[:5])  # Copy the data into a new array.array
     array('b', [22, 33, 44, 55, 100])
     >>> shm_b.buf[:5] = b'howdy'  # Modify via shm_b using bytes
     >>> bytes(shm_a.buf[:5])      # Access via shm_a
     b'howdy'
     >>> shm_b.close()   # Close each SharedMemory instance
     >>> shm_a.close()
     >>> shm_a.unlink()  # Call unlink only once to release the shared memory

The following example demonstrates a practical use of the *note
SharedMemory: 15bd. class with NumPy arrays(2), accessing the same
‘numpy.ndarray’ from two distinct Python shells:

     >>> # In the first Python interactive shell
     >>> import numpy as np
     >>> a = np.array([1, 1, 2, 3, 5, 8])  # Start with an existing NumPy array
     >>> from multiprocessing import shared_memory
     >>> shm = shared_memory.SharedMemory(create=True, size=a.nbytes)
     >>> # Now create a NumPy array backed by shared memory
     >>> b = np.ndarray(a.shape, dtype=a.dtype, buffer=shm.buf)
     >>> b[:] = a[:]  # Copy the original data into shared memory
     >>> b
     array([1, 1, 2, 3, 5, 8])
     >>> type(b)
     <class 'numpy.ndarray'>
     >>> type(a)
     <class 'numpy.ndarray'>
     >>> shm.name  # We did not specify a name so one was chosen for us
     'psm_21467_46075'

     >>> # In either the same shell or a new Python shell on the same machine
     >>> import numpy as np
     >>> from multiprocessing import shared_memory
     >>> # Attach to the existing shared memory block
     >>> existing_shm = shared_memory.SharedMemory(name='psm_21467_46075')
     >>> # Note that a.shape is (6,) and a.dtype is np.int64 in this example
     >>> c = np.ndarray((6,), dtype=np.int64, buffer=existing_shm.buf)
     >>> c
     array([1, 1, 2, 3, 5, 8])
     >>> c[-1] = 888
     >>> c
     array([  1,   1,   2,   3,   5, 888])

     >>> # Back in the first Python interactive shell, b reflects this change
     >>> b
     array([  1,   1,   2,   3,   5, 888])

     >>> # Clean up from within the second Python shell
     >>> del c  # Unnecessary; merely emphasizing the array is no longer used
     >>> existing_shm.close()

     >>> # Clean up from within the first Python shell
     >>> del b  # Unnecessary; merely emphasizing the array is no longer used
     >>> shm.close()
     >>> shm.unlink()  # Free and release the shared memory block at the very end

 -- クラス: multiprocessing.managers.SharedMemoryManager ([address[,
          authkey]])

     A subclass of *note multiprocessing.managers.BaseManager: 302a.
     which can be used for the management of shared memory blocks across
     processes.

     A call to *note start(): 302b. on a ‘SharedMemoryManager’ instance
     causes a new process to be started.  This new process's sole
     purpose is to manage the life cycle of all shared memory blocks
     created through it.  To trigger the release of all shared memory
     blocks managed by that process, call *note shutdown(): 302c. on the
     instance.  This triggers a *note unlink(): 306a. call on all of the
     *note SharedMemory: 306e. objects managed by that process and then
     stops the process itself.  By creating ‘SharedMemory’ instances
     through a ‘SharedMemoryManager’, we avoid the need to manually
     track and trigger the freeing of shared memory resources.

     This class provides methods for creating and returning *note
     SharedMemory: 306e. instances and for creating a list-like object
     (*note ShareableList: 306f.) backed by shared memory.

     Refer to *note BaseManager: 302a. for a description of the
     inherited 'address' and 'authkey' optional input arguments and how
     they may be used to connect to an existing ‘SharedMemoryManager’
     service from other processes.

      -- メソッド: SharedMemory (size)

          Create and return a new *note SharedMemory: 306e. object with
          the specified 'size' in bytes.

      -- メソッド: ShareableList (sequence)

          Create and return a new *note ShareableList: 306f. object,
          initialized by the values from the input 'sequence'.

The following example demonstrates the basic mechanisms of a *note
SharedMemoryManager: 3068.:

     >>> from multiprocessing.managers import SharedMemoryManager
     >>> smm = SharedMemoryManager()
     >>> smm.start()  # Start the process that manages the shared memory blocks
     >>> sl = smm.ShareableList(range(4))
     >>> sl
     ShareableList([0, 1, 2, 3], name='psm_6572_7512')
     >>> raw_shm = smm.SharedMemory(size=128)
     >>> another_sl = smm.ShareableList('alpha')
     >>> another_sl
     ShareableList(['a', 'l', 'p', 'h', 'a'], name='psm_6572_12221')
     >>> smm.shutdown()  # Calls unlink() on sl, raw_shm, and another_sl

The following example depicts a potentially more convenient pattern for
using *note SharedMemoryManager: 3068. objects via the *note with: 59c.
statement to ensure that all shared memory blocks are released after
they are no longer needed:

     >>> with SharedMemoryManager() as smm:
     ...     sl = smm.ShareableList(range(2000))
     ...     # Divide the work among two processes, storing partial results in sl
     ...     p1 = Process(target=do_work, args=(sl, 0, 1000))
     ...     p2 = Process(target=do_work, args=(sl, 1000, 2000))
     ...     p1.start()
     ...     p2.start()  # A multiprocessing.Pool might be more efficient
     ...     p1.join()
     ...     p2.join()   # Wait for all work to complete in both processes
     ...     total_result = sum(sl)  # Consolidate the partial results now in sl

When using a *note SharedMemoryManager: 3068. in a *note with: 59c.
statement, the shared memory blocks created using that manager are all
released when the ‘with’ statement's code block finishes execution.

 -- クラス: multiprocessing.shared_memory.ShareableList (sequence=None,
          *, name=None)

     Provide a mutable list-like object where all values stored within
     are stored in a shared memory block.  This constrains storable
     values to the following built-in data types:

        * *note int: 238. (signed 64-bit)

        * *note float: 2ce.

        * *note bool: 434.

        * *note str: 418. (less than 10M bytes each when encoded as
          UTF-8)

        * *note bytes: 1a4. (less than 10M bytes each)

        * ‘None’

     It also notably differs from the built-in *note list: 5dc. type in
     that these lists can not change their overall length (i.e.  no
     ‘append()’, ‘insert()’, etc.)  and do not support the dynamic
     creation of new ‘ShareableList’ instances via slicing.

     'sequence' is used in populating a new ‘ShareableList’ full of
     values.  Set to ‘None’ to instead attach to an already existing
     ‘ShareableList’ by its unique shared memory name.

     'name' is the unique name for the requested shared memory, as
     described in the definition for *note SharedMemory: 15bd.  When
     attaching to an existing ‘ShareableList’, specify its shared memory
     block's unique name while leaving 'sequence' set to ‘None’.

          注釈: A known issue exists for *note bytes: 1a4. and *note
          str: 418. values.  If they end with ‘\x00’ nul bytes or
          characters, those may be 'silently stripped' when fetching
          them by index from the ‘ShareableList’.  This
          ‘.rstrip(b'\x00')’ behavior is considered a bug and may go
          away in the future.  See gh-106939(3).

     For applications where rstripping of trailing nulls is a problem,
     work around it by always unconditionally appending an extra non-0
     byte to the end of such values when storing and unconditionally
     removing it when fetching:

          >>> from multiprocessing import shared_memory
          >>> nul_bug_demo = shared_memory.ShareableList(['?\x00', b'\x03\x02\x01\x00\x00\x00'])
          >>> nul_bug_demo[0]
          '?'
          >>> nul_bug_demo[1]
          b'\x03\x02\x01'
          >>> nul_bug_demo.shm.unlink()
          >>> padded = shared_memory.ShareableList(['?\x00\x07', b'\x03\x02\x01\x00\x00\x00\x07'])
          >>> padded[0][:-1]
          '?\x00'
          >>> padded[1][:-1]
          b'\x03\x02\x01\x00\x00\x00'
          >>> padded.shm.unlink()

      -- メソッド: count (value)

          Return the number of occurrences of 'value'.

      -- メソッド: index (value)

          Return first index position of 'value'.  Raise *note
          ValueError: 1e3. if 'value' is not present.

      -- の属性: format

          Read-only attribute containing the *note struct: c0. packing
          format used by all currently stored values.

      -- の属性: shm

          The *note SharedMemory: 15bd. instance where the values are
          stored.

以下に *note ShareableList: 18da. インスタンスの利用例を示します。

     >>> from multiprocessing import shared_memory
     >>> a = shared_memory.ShareableList(['howdy', b'HoWdY', -273.154, 100, None, True, 42])
     >>> [ type(entry) for entry in a ]
     [<class 'str'>, <class 'bytes'>, <class 'float'>, <class 'int'>, <class 'NoneType'>, <class 'bool'>, <class 'int'>]
     >>> a[2]
     -273.154
     >>> a[2] = -78.5
     >>> a[2]
     -78.5
     >>> a[2] = 'dry ice'  # Changing data types is supported as well
     >>> a[2]
     'dry ice'
     >>> a[2] = 'larger than previously allocated storage space'
     Traceback (most recent call last):
       ...
     ValueError: exceeds available storage for existing str
     >>> a[2]
     'dry ice'
     >>> len(a)
     7
     >>> a.index(42)
     6
     >>> a.count(b'howdy')
     0
     >>> a.count(b'HoWdY')
     1
     >>> a.shm.close()
     >>> a.shm.unlink()
     >>> del a  # Use of a ShareableList after call to unlink() is unsupported

The following example depicts how one, two, or many processes may access
the same *note ShareableList: 18da. by supplying the name of the shared
memory block behind it:

     >>> b = shared_memory.ShareableList(range(5))         # In a first process
     >>> c = shared_memory.ShareableList(name=b.shm.name)  # In a second process
     >>> c
     ShareableList([0, 1, 2, 3, 4], name='...')
     >>> c[-1] = -999
     >>> b[-1]
     -999
     >>> b.shm.close()
     >>> c.shm.close()
     >>> c.shm.unlink()

The following examples demonstrates that *note ShareableList: 18da. (and
underlying *note SharedMemory: 15bd.) objects can be pickled and
unpickled if needed.  Note, that it will still be the same shared
object.  This happens, because the deserialized object has the same
unique name and is just attached to an existing object with the same
name (if the object is still alive):

     >>> import pickle
     >>> from multiprocessing import shared_memory
     >>> sl = shared_memory.ShareableList(range(10))
     >>> list(sl)
     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

     >>> deserialized_sl = pickle.loads(pickle.dumps(sl))
     >>> list(deserialized_sl)
     [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

     >>> sl[0] = -1
     >>> deserialized_sl[1] = -2
     >>> list(sl)
     [-1, -2, 2, 3, 4, 5, 6, 7, 8, 9]
     >>> list(deserialized_sl)
     [-1, -2, 2, 3, 4, 5, 6, 7, 8, 9]

     >>> sl.shm.close()
     >>> sl.shm.unlink()

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/multiprocessing/shared_memory.py

   (2) https://numpy.org/

   (3) https://github.com/python/cpython/issues/106939


File: python.info,  Node: concurrent パッケージ,  Next: concurrent futures --- 並列タスク実行,  Prev: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ,  Up: 並行実行

5.17.4 ‘concurrent’ パッケージ
------------------------------

現在のところ、このパッケージにはモジュールが1つだけあります:

   * *note concurrent.futures: 1a. - 並列タスク実行


File: python.info,  Node: concurrent futures --- 並列タスク実行,  Next: subprocess --- サブプロセス管理,  Prev: concurrent パッケージ,  Up: 並行実行

5.17.5 ‘concurrent.futures’ -- 並列タスク実行
---------------------------------------------

Added in version 3.2.

'ソースコード:' Lib/concurrent/futures/thread.py(1) および
Lib/concurrent/futures/process.py(2)

__________________________________________________________________

*note concurrent.futures: 1a. モジュールは、非同期に実行できる呼び出し可
能オブジェクトの高水準のインターフェースを提供します。

非同期実行は *note ThreadPoolExecutor: 70d. を用いてスレッドで実行するこ
とも、 *note ProcessPoolExecutor: 8bc. を用いて別々のプロセスで実行する
こともできます.  どちらも *note Executor: 3078. 抽象クラスで定義された同
じインターフェースを実装します。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

* Menu:

* Executor オブジェクト::
* ThreadPoolExecutor::
* ProcessPoolExecutor::
* Future オブジェクト::
* モジュール関数: モジュール関数<2>.
* 例外クラス::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/concurrent/futures/thread.py

   (2) 
https://github.com/python/cpython/tree/3.13/Lib/concurrent/futures/process.py


File: python.info,  Node: Executor オブジェクト,  Next: ThreadPoolExecutor,  Up: concurrent futures --- 並列タスク実行

5.17.5.1 Executor オブジェクト
..............................

 -- クラス: concurrent.futures.Executor

     非同期呼び出しを実行するためのメソッドを提供する抽象クラスです。こ
     のクラスを直接使ってはならず、具象サブクラスを介して使います。

      -- メソッド: submit (fn, /, *args, **kwargs)

          呼び出し可能オブジェクト 'fn' を、 ‘fn(*args, **kwargs)’ とし
          て実行するようにスケジュールし、呼び出し可能オブジェクトの実行
          を表現する *note Future: 1182. オブジェクトを返します。

               with ThreadPoolExecutor(max_workers=1) as executor:
                   future = executor.submit(pow, 323, 1235)
                   print(future.result())

      -- メソッド: map (fn, *iterables, timeout=None, chunksize=1)

          Similar to *note map(fn, *iterables): 82f. except:

             * the 'iterables' are collected immediately rather than
               lazily;

             * 'fn' is executed asynchronously and several calls to 'fn'
               may be made concurrently.

          もし *note __next__(): 129b. が呼ばれその結果が元々の *note
          Executor.map(): db1. の呼び出しから 'timeout' 秒経った後も利用
          できない場合、返されるイテレータは *note TimeoutError: 800. を
          送出します。'timeout' は整数または浮動小数点数です。もし
          'timeout' が指定されないか の場合、待ち時間に制限はありません
          。

          If a 'fn' call raises an exception, then that exception will
          be raised when its value is retrieved from the iterator.

          When using *note ProcessPoolExecutor: 8bc, this method chops
          'iterables' into a number of chunks which it submits to the
          pool as separate tasks.  The (approximate) size of these
          chunks can be specified by setting 'chunksize' to a positive
          integer.  For very long iterables, using a large value for
          'chunksize' can significantly improve performance compared to
          the default size of 1.  With *note ThreadPoolExecutor: 70d,
          'chunksize' has no effect.

          バージョン 3.5 で変更: 'chunksize' 引数が追加されました。

      -- メソッド: shutdown (wait=True, *, cancel_futures=False)

          executor に対して、現在保留中のフューチャーが実行された後で、
          使用中のすべての資源を解放するように伝えます。シャットダウンに
          より後に *note Executor.submit(): a50. と *note
          Executor.map(): db1. を呼び出すと *note RuntimeError: 17a. が
          送出されます。

          'wait' が ‘True’ の場合、すべての未完了のフューチャの実行が完
          了して Executor に関連付けられたリソースが解放されるまで、この
          メソッドは返りません。 'wait' が ‘False’ の場合、このメソッド
          はすぐに返り、すべての未完了のフューチャの実行が完了したときに
          、 Executor に関連付けられたリソースが解放されます。 'wait' の
          値に関係なく、すべての未完了のフューチャの実行が完了するまで
          Python プログラム全体は終了しません。

          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'.

          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.

          *note with: 59c. 文を使用することで、このメソッドを明示的に呼
          ばないようにできます。 *note with: 59c. 文は *note Executor:
          3078. をシャットダウンします ('wait' を ‘True’ にセットして
          *note Executor.shutdown(): 8bb. が呼ばれたかのように待ちます
          )。

               import shutil
               with ThreadPoolExecutor(max_workers=4) as e:
                   e.submit(shutil.copy, 'src1.txt', 'dest1.txt')
                   e.submit(shutil.copy, 'src2.txt', 'dest2.txt')
                   e.submit(shutil.copy, 'src3.txt', 'dest3.txt')
                   e.submit(shutil.copy, 'src4.txt', 'dest4.txt')

          バージョン 3.9 で変更: 'cancel_futures' が追加されました。


File: python.info,  Node: ThreadPoolExecutor,  Next: ProcessPoolExecutor,  Prev: Executor オブジェクト,  Up: concurrent futures --- 並列タスク実行

5.17.5.2 ThreadPoolExecutor
...........................

*note ThreadPoolExecutor: 70d. はスレッドのプールを使用して非同期に呼び
出しを行う、 *note Executor: 3078. のサブクラスです。

*note Future: 1182. に関連づけられた呼び出し可能オブジェクトが、別の
*note Future: 1182. の結果を待つ時にデッドロックすることがあります。例:

     import time
     def wait_on_b():
         time.sleep(5)
         print(b.result())  # b will never complete because it is waiting on a.
         return 5

     def wait_on_a():
         time.sleep(5)
         print(a.result())  # a will never complete because it is waiting on b.
         return 6


     executor = ThreadPoolExecutor(max_workers=2)
     a = executor.submit(wait_on_b)
     b = executor.submit(wait_on_a)

以下でも同様です:

     def wait_on_future():
         f = executor.submit(pow, 5, 2)
         # This will never complete because there is only one worker thread and
         # it is executing this function.
         print(f.result())

     executor = ThreadPoolExecutor(max_workers=1)
     executor.submit(wait_on_future)

 -- クラス: concurrent.futures.ThreadPoolExecutor (max_workers=None,
          thread_name_prefix='', initializer=None, initargs=())

     最大で 'max_workers' 個のスレッドを非同期実行に使う *note Executor:
     3078. のサブクラスです。

     All threads enqueued to ‘ThreadPoolExecutor’ will be joined before
     the interpreter can exit.  Note that the exit handler which does
     this is executed 'before' any exit handlers added using ‘atexit’.
     This means exceptions in the main thread must be caught and handled
     in order to signal threads to exit gracefully.  For this reason, it
     is recommended that ‘ThreadPoolExecutor’ not be used for
     long-running tasks.

     'initializer' is an optional callable that is called at the start
     of each worker thread; 'initargs' is a tuple of arguments passed to
     the initializer.  Should 'initializer' raise an exception, all
     currently pending jobs will raise a *note BrokenThreadPool: 307b,
     as well as any attempt to submit more jobs to the pool.

     バージョン 3.5 で変更: 'max_workers' が ‘None’ か指定されない場合の
     デフォルト値はマシンのプロセッサの数に 5 を掛けたものになります。こ
     れは、 *note ThreadPoolExecutor: 70d. は CPU の処理ではなく I/O を
     オーバーラップするのによく使用されるため、 *note
     ProcessPoolExecutor: 8bc. のワーカーの数よりもこのワーカーの数を増
     やすべきであるという想定に基づいています。

     バージョン 3.6 で変更: Added the 'thread_name_prefix' parameter to
     allow users to control the *note threading.Thread: 91a. names for
     worker threads created by the pool for easier debugging.

     バージョン 3.7 で変更: 'initializer' と 'initargs' 引数が追加されま
     した。

     バージョン 3.8 で変更: 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.

     ThreadPoolExecutor now reuses idle worker threads before starting
     'max_workers' worker threads too.

     バージョン 3.13 で変更: Default value of 'max_workers' is changed
     to ‘min(32, (os.process_cpu_count() or 1) + 4)’.

* Menu:

* ThreadPoolExecutor の例::


File: python.info,  Node: ThreadPoolExecutor の例,  Up: ThreadPoolExecutor

5.17.5.3 ThreadPoolExecutor の例
................................

     import concurrent.futures
     import urllib.request

     URLS = ['http://www.foxnews.com/',
             'http://www.cnn.com/',
             'http://europe.wsj.com/',
             'http://www.bbc.co.uk/',
             'http://nonexistent-subdomain.python.org/']

     # Retrieve a single page and report the URL and contents
     def load_url(url, timeout):
         with urllib.request.urlopen(url, timeout=timeout) as conn:
             return conn.read()

     # We can use a with statement to ensure threads are cleaned up promptly
     with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
         # Start the load operations and mark each future with its URL
         future_to_url = {executor.submit(load_url, url, 60): url for url in URLS}
         for future in concurrent.futures.as_completed(future_to_url):
             url = future_to_url[future]
             try:
                 data = future.result()
             except Exception as exc:
                 print('%r generated an exception: %s' % (url, exc))
             else:
                 print('%r page is %d bytes' % (url, len(data)))


File: python.info,  Node: ProcessPoolExecutor,  Next: Future オブジェクト,  Prev: ThreadPoolExecutor,  Up: concurrent futures --- 並列タスク実行

5.17.5.4 ProcessPoolExecutor
............................

*note ProcessPoolExecutor: 8bc. はプロセスプールを使って非同期呼び出しを
実施する *note Executor: 3078. のサブクラスです。*note
ProcessPoolExecutor: 8bc. は *note multiprocessing: 86. モジュールを利用
します。このため *note Global Interpreter Lock: 12e. を回避することがで
きますが、pickle 化できるオブジェクトしか実行したり返したりすることがで
きません。

‘__main__’ モジュールはワーカサブプロセスでインポート可能でなければなり
ません。 すなわち、 *note ProcessPoolExecutor: 8bc. は対話的インタープリ
タでは動きません。

*note ProcessPoolExecutor: 8bc. に渡された呼び出し可能オブジェクトから
*note Executor: 3078. や *note Future: 1182. メソッドを呼ぶとデッドロッ
クに陥ります。

 -- クラス: concurrent.futures.ProcessPoolExecutor (max_workers=None,
          mp_context=None, initializer=None, initargs=(),
          max_tasks_per_child=None)

     An *note Executor: 3078. subclass that executes calls
     asynchronously using a pool of at most 'max_workers' processes.  If
     'max_workers' is ‘None’ or not given, it will default to *note
     os.process_cpu_count(): 1a6.  If 'max_workers' is less than or
     equal to ‘0’, then a *note ValueError: 1e3. will be raised.  On
     Windows, 'max_workers' must be less than or equal to ‘61’.  If it
     is not then *note ValueError: 1e3. will be raised.  If
     'max_workers' is ‘None’, then the default chosen will be at most
     ‘61’, even if more processors are available.  'mp_context' can be a
     *note multiprocessing: 86. context or ‘None’.  It will be used to
     launch the workers.  If 'mp_context' is ‘None’ or not given, the
     default *note multiprocessing: 86. context is used.  See *note
     コンテキストと開始方式: 2a9.

     'initializer' is an optional callable that is called at the start
     of each worker process; 'initargs' is a tuple of arguments passed
     to the initializer.  Should 'initializer' raise an exception, all
     currently pending jobs will raise a *note BrokenProcessPool: 307e,
     as well as any attempt to submit more jobs to the pool.

     '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 replaced with a fresh worker process.  By default
     'max_tasks_per_child' is ‘None’ which means worker processes will
     live as long as the pool.  When a max is specified, the "spawn"
     multiprocessing start method will be used by default in absence of
     a 'mp_context' parameter.  This feature is incompatible with the
     "fork" start method.

     バージョン 3.3 で変更: When one of the worker processes terminates
     abruptly, a *note BrokenProcessPool: 307e. error is now raised.
     Previously, behaviour was undefined but operations on the executor
     or its futures would often freeze or deadlock.

     バージョン 3.7 で変更: The 'mp_context' argument was added to allow
     users to control the start_method for worker processes created by
     the pool.

     'initializer' と 'initargs' 引数が追加されました。

          注釈: The default *note multiprocessing: 86. start method (see
          *note コンテキストと開始方式: 2a9.) will change away from
          'fork' in Python 3.14.  Code that requires 'fork' be used for
          their *note ProcessPoolExecutor: 8bc. should explicitly
          specify that by passing a
          ‘mp_context=multiprocessing.get_context("fork")’ parameter.

     バージョン 3.11 で変更: The 'max_tasks_per_child' argument was
     added to allow users to control the lifetime of workers in the
     pool.

     バージョン 3.12 で変更: On POSIX systems, if your application has
     multiple threads and the *note multiprocessing: 86. context uses
     the ‘"fork"’ start method: The *note os.fork(): 17c. function
     called internally to spawn workers may raise a *note
     DeprecationWarning: 18a.  Pass a 'mp_context' configured to use a
     different start method.  See the *note os.fork(): 17c.
     documentation for further explanation.

     バージョン 3.13 で変更: 'max_workers' uses *note
     os.process_cpu_count(): 1a6. by default, instead of *note
     os.cpu_count(): 1a7.

* Menu:

* ProcessPoolExecutor の例::


File: python.info,  Node: ProcessPoolExecutor の例,  Up: ProcessPoolExecutor

5.17.5.5 ProcessPoolExecutor の例
.................................

     import concurrent.futures
     import math

     PRIMES = [
         112272535095293,
         112582705942171,
         112272535095293,
         115280095190773,
         115797848077099,
         1099726899285419]

     def is_prime(n):
         if n < 2:
             return False
         if n == 2:
             return True
         if n % 2 == 0:
             return False

         sqrt_n = int(math.floor(math.sqrt(n)))
         for i in range(3, sqrt_n + 1, 2):
             if n % i == 0:
                 return False
         return True

     def main():
         with concurrent.futures.ProcessPoolExecutor() as executor:
             for number, prime in zip(PRIMES, executor.map(is_prime, PRIMES)):
                 print('%d is prime: %s' % (number, prime))

     if __name__ == '__main__':
         main()


File: python.info,  Node: Future オブジェクト,  Next: モジュール関数<2>,  Prev: ProcessPoolExecutor,  Up: concurrent futures --- 並列タスク実行

5.17.5.6 Future オブジェクト
............................

*note Future: 1182. クラスは呼び出し可能オブジェクトの非同期実行をカプセ
ル化します。 *note Future: 1182. のインスタンスは *note
Executor.submit(): a50. によって生成されます。

 -- クラス: concurrent.futures.Future

     呼び出し可能オブジェクトの非同期実行をカプセル化します。 *note
     Future: 1182. インスタンスは *note Executor.submit(): a50. で生成さ
     れ、テストを除いて直接生成すべきではありません。

      -- メソッド: cancel ()

          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’.

      -- メソッド: cancelled ()

          呼び出しが正常にキャンセルされた場合 ‘True’ を返します。

      -- メソッド: running ()

          現在呼び出しが実行中でキャンセルできない場合 ‘True’ を返します
          。

      -- メソッド: done ()

          呼び出しが正常にキャンセルされたか終了した場合 ‘True’ を返しま
          す。

      -- メソッド: result (timeout=None)

          呼び出しによって返された値を返します。もし呼び出しがまだ完了し
          ていなければ、このメソッドは 'timeout' 秒の間、待機します。も
          し呼び出しが 'timeout' 秒間の間に完了しなければ、 *note
          TimeoutError: 800. が送出されます。 'timeout' はintかfloatを指
          定できます。もし 'timeout' が指定されていないか、 ‘None’ であ
          れば、待機時間に制限はありません。

          future が完了する前にキャンセルされた場合 *note
          CancelledError: 9a8. が送出されます。

          If the call raised an exception, this method will raise the
          same exception.

      -- メソッド: exception (timeout=None)

          呼び出しによって送出された例外を返します。もし呼び出しがまだ完
          了されていなければ、このメソッドは 'timeout' 秒だけ待機します
          。もし呼び出しが 'timeout' 秒の間に完了しなければ、 *note
          TimeoutError: 800. が送出されます。 'timeout' にはintかfloatを
          指定できます。 'timeout' が指定されていないか、 ‘None’ であれ
          ば、待機時間に制限はありません。

          future が完了する前にキャンセルされた場合 *note
          CancelledError: 9a8. が送出されます。

          呼び出しが例外を送出することなく完了した場合、‘None’ を返しま
          す。

      -- メソッド: add_done_callback (fn)

          呼び出し可能な 'fn' オブジェクトを future にアタッチします。
          futureがキャンセルされたか、実行を終了した際に、future をその
          ただ一つの引数として 'fn' が呼び出されます。

          追加された呼び出し可能オブジェクトは、追加された順番で呼びださ
          れ、追加を行ったプロセスに属するスレッド中で呼び出されます。も
          し呼び出し可能オブジェクトが *note Exception: 9a7. のサブクラ
          スを送出した場合、それはログに記録され無視されます。呼び出し可
          能オブジェクトが *note BaseException: 584. のサブクラスを送出
          した場合の動作は未定義です。

          もしfutureがすでに完了しているか、キャンセル済みであれば、'fn'
          は即座に実行されます。

     以下の *note Future: 1182. メソッドは、ユニットテストでの使用と
     *note Executor: 3078. を実装することを意図しています。

      -- メソッド: set_running_or_notify_cancel ()

          このメソッドは、*note Future: 1182. に関連付けられたワークやユ
          ニットテストによるワークの実行前に、 *note Executor: 3078. の
          実装によってのみ呼び出してください。

          このメソッドが ‘False’ を返す場合、 *note Future: 1182. はキャ
          ンセルされています。つまり、 *note Future.cancel(): 3081. が呼
          び出されて ‘True’ が返っています。*note Future: 1182. の完了を
          (*note as_completed(): 15b1. または *note wait(): 17cd. により
          ) 待機するすべてのスレッドが起動します。

          このメソッドが ‘True’ を返す場合、 *note Future: 1182. はキャ
          ンセルされて、実行状態に移行されています。つまり、 *note
          Future.running(): 3083. を呼び出すと ‘True’ が返ります。

          このメソッドは、一度だけ呼び出すことができ、*note
          Future.set_result(): 3089. または *note
          Future.set_exception(): 308a. がキャンセルされた後には呼び出す
          ことができません。

      -- メソッド: set_result (result)

          *note Future: 1182. に関連付けられたワークの結果を 'result' に
          設定します。

          このメソッドは、 *note Executor: 3078. の実装またはユニットテ
          ストによってのみ使用してください。

          バージョン 3.8 で変更: This method raises *note
          concurrent.futures.InvalidStateError: 156f. if the *note
          Future: 1182. is already done.

      -- メソッド: set_exception (exception)

          *note Future: 1182. に関連付けられたワークの結果を *note
          Exception: 9a7. 'exception' に設定します。

          このメソッドは、 *note Executor: 3078. の実装またはユニットテ
          ストによってのみ使用してください。

          バージョン 3.8 で変更: This method raises *note
          concurrent.futures.InvalidStateError: 156f. if the *note
          Future: 1182. is already done.


File: python.info,  Node: モジュール関数<2>,  Next: 例外クラス,  Prev: Future オブジェクト,  Up: concurrent futures --- 並列タスク実行

5.17.5.7 モジュール関数
.......................

 -- の関数: concurrent.futures.wait (fs, timeout=None,
          return_when=ALL_COMPLETED)

     Wait for the *note Future: 1182. instances (possibly created by
     different *note Executor: 3078. instances) given by 'fs' to
     complete.  Duplicate futures given to 'fs' are removed and will be
     returned only once.  Returns a named 2-tuple of sets.  The first
     set, named ‘done’, contains the futures that completed (finished or
     cancelled futures) before the wait completed.  The second set,
     named ‘not_done’, contains the futures that did not complete
     (pending or running futures).

     'timeout' で結果を返すまで待機する最大秒数を指定できます。'timeout'
     は整数か浮動小数点数をとります。'timeout' が指定されないか ‘None’ の
     場合、無期限に待機します。

     'return_when' でこの関数がいつ結果を返すか指定します。指定できる値
     は以下の 定数のどれか一つです:

     定数                                                   説明
                                                            
     --------------------------------------------------------------------------------------------------------------
                                                            
      -- データ: concurrent.futures.FIRST_COMPLETED         いずれかのフューチャが終了したかキャンセルされたとき
                                                            に返します。
                                                            
                                                            
      -- データ: concurrent.futures.FIRST_EXCEPTION         The function will return when any future finishes by
                                                            raising an exception.  If no future raises an
                                                            exception then it is equivalent to
                                                            *note ALL_COMPLETED: 308e.
                                                            
                                                            
      -- データ: concurrent.futures.ALL_COMPLETED           すべてのフューチャが終了したかキャンセルされたときに
                                                            返します。
                                                            

 -- の関数: concurrent.futures.as_completed (fs, timeout=None)

     Returns an iterator over the *note Future: 1182. instances
     (possibly created by different *note Executor: 3078. instances)
     given by 'fs' that yields futures as they complete (finished or
     cancelled futures).  Any futures given by 'fs' that are duplicated
     will be returned once.  Any futures that completed before *note
     as_completed(): 15b1. is called will be yielded first.  The
     returned iterator raises a *note TimeoutError: 800. if *note
     __next__(): 129b. is called and the result isn't available after
     'timeout' seconds from the original call to *note as_completed():
     15b1.  'timeout' can be an int or float.  If 'timeout' is not
     specified or ‘None’, there is no limit to the wait time.

参考
....

PEP 3148(1) - futures - execute computations asynchronously

     この機能を Python 標準ライブラリに含めることを述べた提案です。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3148/


File: python.info,  Node: 例外クラス,  Prev: モジュール関数<2>,  Up: concurrent futures --- 並列タスク実行

5.17.5.8 例外クラス
...................

 -- 例外: concurrent.futures.CancelledError

     future がキャンセルされたときに送出されます。

 -- 例外: concurrent.futures.TimeoutError

     A deprecated alias of *note TimeoutError: 800, raised when a future
     operation exceeds the given timeout.

     バージョン 3.11 で変更: このクラスは *note TimeoutError: 800. のエ
     イリアスになりました。

 -- 例外: concurrent.futures.BrokenExecutor

     Derived from *note RuntimeError: 17a, this exception class is
     raised when an executor is broken for some reason, and cannot be
     used to submit or execute new tasks.

     Added in version 3.7.

 -- 例外: concurrent.futures.InvalidStateError

     Raised when an operation is performed on a future that is not
     allowed in the current state.

     Added in version 3.8.

 -- 例外: concurrent.futures.thread.BrokenThreadPool

     Derived from *note BrokenExecutor: 3091, this exception class is
     raised when one of the workers of a *note ThreadPoolExecutor: 70d.
     has failed initializing.

     Added in version 3.7.

 -- 例外: concurrent.futures.process.BrokenProcessPool

     Derived from *note BrokenExecutor: 3091. (formerly *note
     RuntimeError: 17a.), this exception class is raised when one of the
     workers of a *note ProcessPoolExecutor: 8bc. has terminated in a
     non-clean fashion (for example, if it was killed from the outside).

     Added in version 3.3.


File: python.info,  Node: subprocess --- サブプロセス管理,  Next: sched --- イベントスケジューラー,  Prev: concurrent futures --- 並列タスク実行,  Up: 並行実行

5.17.6 ‘subprocess’ -- サブプロセス管理
---------------------------------------

'ソースコード:' Lib/subprocess.py(1)

__________________________________________________________________

*note subprocess: c1. モジュールは新しいプロセスの開始、入力/出力/エラー
パイプの接続、リターンコードの取得を可能とします。このモジュールは以下の
古いモジュールや関数を置き換えることを目的としています：

     os.system
     os.spawn*

これらのモジュールや関数の代わりに、*note subprocess: c1. モジュールをど
のように使うかについてを以下の節で説明します。

参考
....

PEP 324(2) - subprocess モジュールを提案している PEP

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

* Menu:

* subprocess モジュールを使う::
* セキュリティで考慮すべき点: セキュリティで考慮すべき点<2>.
* Popen オブジェクト::
* Windows Popen ヘルパー::
* 古い高水準 API::
* 古い関数を subprocess モジュールで置き換える::
* レガシーなシェル呼び出し関数::
* 注釈: 注釈<2>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/subprocess.py

   (2) https://peps.python.org/pep-0324/


File: python.info,  Node: subprocess モジュールを使う,  Next: セキュリティで考慮すべき点<2>,  Up: subprocess --- サブプロセス管理

5.17.6.1 ‘subprocess’ モジュールを使う
......................................

サブプロセスを起動するために推奨される方法は、すべての用法を扱える *note
run(): b54. 関数を使用することです。より高度な用法では下層の *note
Popen: 17e. インターフェースを直接使用することもできます。

 -- の関数: subprocess.run (args, *, stdin=None, input=None,
          stdout=None, stderr=None, capture_output=False, shell=False,
          cwd=None, timeout=None, check=False, encoding=None,
          errors=None, text=None, env=None, universal_newlines=None,
          **other_popen_kwargs)

     'args' で指定されたコマンドを実行します。コマンドの完了を待って、
     *note CompletedProcess: e3c. インスタンスを返します。

     上記の引数は、もっともよく使われるものだけ示しており、後述の *note
     よく使われる引数: 3095. で説明されています (そのためここではキーワ
     ード専用引数の表記に省略されています)。関数の完全な使用法を説明して
     も大部分が *note Popen: 17e. コンストラクターの内容と同じになります
     - この関数のほとんどの引数は *note Popen: 17e. インターフェイスに渡
     されます。('timeout'、'input' および 'check' は除く。)

     If 'capture_output' is true, stdout and stderr will be captured.
     When used, the internal *note Popen: 17e. object is automatically
     created with 'stdout' and 'stderr' both set to *note PIPE: b55.
     The 'stdout' and 'stderr' arguments may not be supplied at the same
     time as 'capture_output'.  If you wish to capture and combine both
     streams into one, set 'stdout' to *note PIPE: b55. and 'stderr' to
     *note STDOUT: 3096, instead of using 'capture_output'.

     A 'timeout' may be specified in seconds, it is internally passed on
     to *note Popen.communicate(): 3097.  If the timeout expires, the
     child process will be killed and waited for.  The *note
     TimeoutExpired: 3098. exception will be re-raised after the child
     process has terminated.  The initial process creation itself cannot
     be interrupted on many platform APIs so you are not guaranteed to
     see a timeout exception until at least after however long process
     creation takes.

     The 'input' argument is passed to *note Popen.communicate(): 3097.
     and thus to the subprocess's stdin.  If used it must be a byte
     sequence, or a string if 'encoding' or 'errors' is specified or
     'text' is true.  When used, the internal *note Popen: 17e. object
     is automatically created with 'stdin' set to *note PIPE: b55, and
     the 'stdin' argument may not be used as well.

     'check' に真を指定した場合、プロセスが非ゼロの終了コードで終了する
     と *note CalledProcessError: 12f3. 例外が送出されます。 この例外の
     属性には、引数、終了コード、標準出力および標準エラー出力が捕捉でき
     た場合に格納されます。

     'encoding' または 'errors' 引数が指定されるか、'text' 引数が true で
     ある場合、stdin, stdout および stderr のためのファイルオブジェクト
     はテキストモードでオープンされます。 その際には指定された
     'encoding' および 'errors' が使われるか、デフォルトの *note
     io.TextIOWrapper: 786. になります。'universal_newlines' 引数は
     'text' 引数と等価であり、後方互換性のために提供されています。そうで
     ない場合、デフォルトでこれらのファイルオブジェクトはバイナリモード
     でオープンされます。

     'env' が ‘None’ 以外の場合、これは新しいプロセスでの環境変数を定義
     します。デフォルトでは、子プロセスは現在のプロセスの環境変数を引き
     継ぎます。 *note Popen: 17e. に直接渡されます。あらゆるプラットフォ
     ームで *note os.environ: 118a. のように文字列から文字列へ、また
     POSIX プラットフォームにおいては *note os.environb: 11e8. のように
     バイトからバイトへも、定義すること出来ます。

     例:

          >>> subprocess.run(["ls", "-l"])  # doesn't capture output
          CompletedProcess(args=['ls', '-l'], returncode=0)

          >>> subprocess.run("exit 1", shell=True, check=True)
          Traceback (most recent call last):
            ...
          subprocess.CalledProcessError: Command 'exit 1' returned non-zero exit status 1

          >>> subprocess.run(["ls", "-l", "/dev/null"], capture_output=True)
          CompletedProcess(args=['ls', '-l', '/dev/null'], returncode=0,
          stdout=b'crw-rw-rw- 1 root root 1, 3 Jan 23 16:23 /dev/null\n', stderr=b'')

     Added in version 3.5.

     バージョン 3.6 で変更: 'encoding' と 'error' が引数に追加されました
     。

     バージョン 3.7 で変更: 'universal_newlines' 引数のよりわかりやすい
     名前として、'text' 引数が追加されました。'capture_output' 引数が追
     加されました。

     バージョン 3.12 で変更: ‘shell=True’ のときのWindowsシェル検索順序
     を変更しました。カレントディレクトリと ‘%PATH%’ は、 ‘%COMSPEC%’ と
     ‘%SystemRoot%\System32\cmd.exe’ に置き換えられました。これにより、
     ‘cmd.exe’ という名前の悪意のあるプログラムをカレントディレクトリに
     ドロップしても、動作しなくなりました。

 -- クラス: subprocess.CompletedProcess

     *note run(): b54. の戻り値。プロセスが終了したことを表します。

      -- の属性: args

          プロセスを起動するときに使用された引数。1 個のリストか 1 個の
          文字列になります。

      -- の属性: returncode

          子プロセスの終了コード。一般に、終了ステータス 0 はプロセスが
          正常に終了したことを示します。

          負の値 ‘-N’ は子プロセスがシグナル ‘N’ により中止させられたこ
          とを示します (POSIX のみ)。

      -- の属性: stdout

          子プロセスから補足された標準出力です。バイト列、もしくは *note
          run(): b54. でエンコーディングが指定された場合、エラーの場合、
          text=True が指定された場合は文字列です。標準出力が補足できなか
          ったら ‘None’ になります。

          プロセスが ‘stderr=subprocess.STDOUT’ で実行された場合、標準出
          力と標準エラー出力が混合されたものがこの属性に格納され、*note
          stderr: 309c. は ‘None’ になります。

      -- の属性: stderr

          子プロセスから補足された標準エラー出力です。バイト列、もしくは
          *note run(): b54. でエンコーディングが指定された場合、エラーの
          場合、text=True が指定された場合は文字列です。標準エラー出力が
          補足できなかったら ‘None’ になります。

      -- メソッド: check_returncode ()

          *note returncode: 309a. が非ゼロの場合、*note
          CalledProcessError: 12f3. が送出されます。

     Added in version 3.5.

 -- データ: subprocess.DEVNULL

     *note Popen: 17e. の 'stdin', 'stdout', 'stderr' 引数に渡して、標準
     入出力を *note os.devnull: 199e. から入出力するように指定するための
     特殊値です。

     Added in version 3.3.

 -- データ: subprocess.PIPE

     *note Popen: 17e. の 'stdin', 'stdout', 'stderr' 引数に渡して、標準
     ストリームに対するパイプを開くことを指定するための特殊値です。*note
     Popen.communicate(): 3097. に非常に有用です。

 -- データ: subprocess.STDOUT

     *note Popen: 17e. の 'stderr' 引数に渡して、標準エラー出力が標準出
     力と同じハンドルに出力されるように指定するための特殊値です。

 -- 例外: subprocess.SubprocessError

     このモジュールの他のすべての例外のための基底クラスです。

     Added in version 3.3.

 -- 例外: subprocess.TimeoutExpired

     *note SubprocessError: 309e. のサブクラスです。子プロセスの終了を待
     機している間にタイムアウトが発生した場合に送出されます。

      -- の属性: cmd

          子プロセスの生成に使用されるコマンド本文。

      -- の属性: timeout

          タイムアウト秒数。

      -- の属性: output

          *note run(): b54. にまたは *note check_output(): f8e. によって
          捕捉された場合は、子プロセスの出力となり、それ以外の場合は
          ‘None’ となります。‘text=True’ の設定に関係なく、出力が捕捉さ
          れた場合は常に *note bytes: 1a4. となります。出力がない場合は
          ‘b''’ の代わりに''None'' のままになることがあります。

      -- の属性: stdout

          output の別名。*note stderr: 30a3. と対になります。

      -- の属性: stderr

          *note run(): b54. によって捕捉された場合、子プロセスの標準エラ
          ー出力が表示され、それ以外の場合は ‘None’ となります。
          ‘text=True’ の設定に関係なく、標準エラー出力を捕捉した場合は常
          に *note bytes: 1a4. となります。標準エラー出力がない場合は、
          ‘b''’ の代わりに ‘None’ のままになることがあります。

     Added in version 3.3.

     バージョン 3.5 で変更: 属性 'stdout' および 'stderr' が追加されまし
     た。

 -- 例外: subprocess.CalledProcessError

     *note SubprocessError: 309e. のサブクラスです。*note check_call():
     30a4. または *note check_output(): f8e. 、 ‘check=True’ であるとき
     の *note run(): b54. 、によって実行されたプロセスが非ゼロの終了ステ
     ータスを返した場合に送出されます。

      -- の属性: returncode

          子プロセスの終了ステータスです。もしプロセスがシグナルによって
          終了したなら、これは負のシグナル番号になります。

      -- の属性: cmd

          子プロセスの生成に使用されるコマンド本文。

      -- の属性: output

          *note run(): b54. または *note check_output(): f8e. によって捕
          捉された子プロセスの出力。捕捉されなかったら ‘None’ になります
          。

      -- の属性: stdout

          output の別名。*note stderr: 30a9. と対になります。

      -- の属性: stderr

          *note run(): b54. によって捕捉された子プロセスの標準エラー出力
          。捕捉されなかったら ‘None’ になります。

     バージョン 3.5 で変更: 属性 'stdout' および 'stderr' が追加されまし
     た。

* Menu:

* よく使われる引数::
* Popen コンストラクター::
* 例外: 例外<10>.


File: python.info,  Node: よく使われる引数,  Next: Popen コンストラクター,  Up: subprocess モジュールを使う

5.17.6.2 よく使われる引数
.........................

幅広い使用例をサポートするために、*note Popen: 17e. コンストラクター (と
その他の簡易関数) は、多くのオプション引数を受け付けます。一般的な用法に
ついては、これらの引数の多くはデフォルト値のままで問題ありません。通常必
要とされる引数は以下の通りです:

     'args' はすべての呼び出しに必要で、文字列あるいはプログラム引数のシ
     ーケンスでなければなりません。一般に、引数のシーケンスを渡す方が望
     ましいです。なぜなら、モジュールが必要な引数のエスケープやクオート
     (例えばファイル名中のスペースを許すこと) の面倒を見ることができるた
     めです。単一の文字列を渡す場合、'shell' は *note True: bdb. でなけ
     ればなりません (以下を参照)。もしくは、その文字列は引数を指定せずに
     実行される単なるプログラムの名前でなければなりません。

     'stdin', 'stdout' and 'stderr' specify the executed program's
     standard input, standard output and standard error file handles,
     respectively.  Valid values are ‘None’, *note PIPE: b55, *note
     DEVNULL: 1121, an existing file descriptor (a positive integer),
     and an existing *note file object: 1193. with a valid file
     descriptor.  With the default settings of ‘None’, no redirection
     will occur.  *note PIPE: b55. indicates that a new pipe to the
     child should be created.  *note DEVNULL: 1121. indicates that the
     special file *note os.devnull: 199e. will be used.  Additionally,
     'stderr' can be *note STDOUT: 3096, which indicates that the stderr
     data from the child process should be captured into the same file
     handle as for 'stdout'.

     If 'encoding' or 'errors' are specified, or 'text' (also known as
     'universal_newlines') is true, the file objects 'stdin', 'stdout'
     and 'stderr' will be opened in text mode using the 'encoding' and
     'errors' specified in the call or the defaults for *note
     io.TextIOWrapper: 786.

     'stdin' については、入力での行末文字 ‘'\n'’ はデフォルトの行セパレ
     ーター *note os.linesep: 20df. に変換されます。'stdout' と 'stderr'
     については、出力での行末はすべて ‘'\n'’ に変換されます。詳細は
     *note io.TextIOWrapper: 786. クラスのドキュメントでコンストラクター
     の引数 'newline' が ‘None’ である場合を参照してください。

     If text mode is not used, 'stdin', 'stdout' and 'stderr' will be
     opened as binary streams.  No encoding or line ending conversion is
     performed.

     バージョン 3.6 で変更: Added the 'encoding' and 'errors'
     parameters.

     バージョン 3.7 で変更: 'universal_newlines' の別名として、'text' 引
     数が追加されました。

          注釈: ファイルオブジェクト *note Popen.stdin: 30ab.、*note
          Popen.stdout: 30ac. ならびに *note Popen.stderr: 30ad. の改行
          属性は *note Popen.communicate(): 3097. メソッドで更新されませ
          ん。

     'shell' が ‘True’ なら、指定されたコマンドはシェルによって実行され
     ます。あなたが Python を主として (ほとんどのシステムシェル以上の) 強
     化された制御フローのために使用していて、さらにシェルパイプ、ファイ
     ル名ワイルドカード、環境変数展開、‘~’ のユーザーホームディレクトリ
     への展開のような他のシェル機能への簡単なアクセスを望むなら、これは
     有用かもしれません。しかしながら、Python 自身が多くのシェル的な機能
     の実装を提供していることに注意してください (特に *note glob: 5a,
     *note fnmatch: 52, *note os.walk(): 476, *note
     os.path.expandvars(): 1381, *note os.path.expanduser(): 9e2, *note
     shutil: b3.)。

     バージョン 3.3 で変更: 'universal_newlines' が ‘True’ の場合、クラ
     スはエンコーディング ‘locale.getpreferredencoding()’ の代わりに
     *note locale.getpreferredencoding(False): 504. を使用します。この変
     更についての詳細は、 *note io.TextIOWrapper: 786. クラスを参照して
     ください。

          注釈: ‘shell=True’ を使う前に *note
          セキュリティで考慮すべき点: 30ae. を読んでください。

これらのオプションは、他のすべてのオプションとともに *note Popen: 17e. コ
ンストラクターのドキュメントの中でより詳細に説明されています。


File: python.info,  Node: Popen コンストラクター,  Next: 例外<10>,  Prev: よく使われる引数,  Up: subprocess モジュールを使う

5.17.6.3 Popen コンストラクター
...............................

このモジュールの中で、根底のプロセス生成と管理は *note Popen: 17e. クラ
スによって扱われます。簡易関数によってカバーされないあまり一般的でないケ
ースを開発者が扱えるように、*note Popen: 17e. クラスは多くの柔軟性を提供
しています。

 -- クラス: subprocess.Popen (args, bufsize=-1, executable=None,
          stdin=None, stdout=None, stderr=None, preexec_fn=None,
          close_fds=True, shell=False, cwd=None, env=None,
          universal_newlines=None, startupinfo=None, creationflags=0,
          restore_signals=True, start_new_session=False, pass_fds=(), *,
          group=None, extra_groups=None, user=None, umask=-1,
          encoding=None, errors=None, text=None, pipesize=-1,
          process_group=None)

     新しいプロセスで子のプログラムを実行します。POSIX においては、子の
     プログラムを実行するために、このクラスは *note os.execvpe(): 2b1d.
     のような挙動を使用します。Windows においては、このクラスは Windows
     の ‘CreateProcess()’ 関数を使用します。*note Popen: 17e. への引数は
     以下の通りです。

     'args' はプログラム引数のシーケンスか、単一の文字列または *note
     path-like object: 280. でなければなりません。デフォルトでは、'args'
     がシーケンスの場合に実行されるプログラムは 'args' の最初の要素です
     。'args' が文字列の場合、解釈はプラットフォーム依存であり、下記に説
     明されます。デフォルトの挙動からの追加の違いについては 'shell' およ
     び 'executable' 引数を参照してください。特に明記されない限り、
     'args' をシーケンスとして渡すことが推奨されます。

          警告: For maximum reliability, use a fully qualified path for
          the executable.  To search for an unqualified name on ‘PATH’,
          use *note shutil.which(): 480.  On all platforms, passing
          *note sys.executable: 392. is the recommended way to launch
          the current Python interpreter again, and use the ‘-m’
          command-line format to launch an installed module.

          Resolving the path of 'executable' (or the first item of
          'args') is platform dependent.  For POSIX, see *note
          os.execvpe(): 2b1d, and note that when resolving or searching
          for the executable path, 'cwd' overrides the current working
          directory and 'env' can override the ‘PATH’ environment
          variable.  For Windows, see the documentation of the
          ‘lpApplicationName’ and ‘lpCommandLine’ parameters of WinAPI
          ‘CreateProcess’, and note that when resolving or searching for
          the executable path with ‘shell=False’, 'cwd' does not
          override the current working directory and 'env' cannot
          override the ‘PATH’ environment variable.  Using a full path
          avoids all of these variations.

     An example of passing some arguments to an external program as a
     sequence is:

          Popen(["/usr/bin/git", "commit", "-m", "Fixes a bug."])

     POSIX 上では、'args' が文字列の場合、その文字列は実行すべきプログラ
     ムの名前またはパスとして解釈されます。しかし、これはプログラムに引
     数を渡さない場合にのみ可能です。

          注釈: It may not be obvious how to break a shell command into
          a sequence of arguments, especially in complex cases.  *note
          shlex.split(): 506. can illustrate how to determine the
          correct tokenization for 'args':

               >>> import shlex, subprocess
               >>> command_line = input()
               /bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'"
               >>> args = shlex.split(command_line)
               >>> print(args)
               ['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"]
               >>> p = subprocess.Popen(args) # Success!

          特に注意すべき点は、シェル内でスペースで区切られたオプション
          ('-input' など) と引数 ('eggs.txt' など) はリストの別々の要素
          になるのに対し、シェル内で (上記のスペースを含むファイル名や
          'echo' コマンドのように) クォーティングやバックスラッシュエス
          ケープが必要なものは単一のリスト要素であることです。

     Windows 上では、'args' がシーケンスなら *note Windows
     における引数シーケンスから文字列への変換: 30b0. に記述された方法で
     文字列に変換されます。これは根底の ‘CreateProcess()’ が文字列上で動
     作するからです。

     バージョン 3.6 で変更: 'args' parameter accepts a *note path-like
     object: 280. if 'shell' is ‘False’ and a sequence containing
     path-like objects on POSIX.

     バージョン 3.8 で変更: 'args' parameter accepts a *note path-like
     object: 280. if 'shell' is ‘False’ and a sequence containing bytes
     and path-like objects on Windows.

     'shell' 引数 (デフォルトでは ‘False’) は、実行するプログラムとして
     シェルを使用するかどうかを指定します。 'shell' が ‘True’ の場合、
     'args' をシーケンスとしてではなく文字列として渡すことが推奨されます
     。

     POSIX で ‘shell=True’ の場合、シェルのデフォルトは ‘/bin/sh’ になり
     ます。'args' が文字列の場合、この文字列はシェルを介して実行されるコ
     マンドを指定します。したがって、文字列は厳密にシェルプロンプトで打
     つ形式と一致しなければなりません。例えば、文字列の中にスペースを含
     むファイル名がある場合は、クォーティングやバックスラッシュエスケー
     プが必要です。'args' がシーケンスの場合には、最初の要素はコマンド名
     を表わす文字列として、残りの要素は追加の引数としてシェルに渡されま
     す。つまり、以下の *note Popen: 17e. と等価ということです:

          Popen(['/bin/sh', '-c', args[0], args[1], ...])

     Windows で ‘shell=True’ とすると、 ‘COMSPEC’ 環境変数がデフォルトシ
     ェルを指定します。Windows で ‘shell=True’ を指定する必要があるのは
     、実行したいコマンドがシェルに組み込みの場合だけです (例えば ‘dir’
     や ‘copy’)。バッチファイルやコンソールベースの実行ファイルを実行す
     るために ‘shell=True’ は必要ありません。

          注釈: ‘shell=True’ を使う前に *note
          セキュリティで考慮すべき点: 30ae. を読んでください。

     'bufsize' は標準入力/標準出力/標準エラー出力パイプファイルオブジェ
     クトを生成するときに *note open(): 4e5. 関数の対応する引数に渡され
     ます:

        - ‘0’ means unbuffered (read and write are one system call and
          can return short)

        - ‘1’ means line buffered (only usable if ‘text=True’ or
          ‘universal_newlines=True’)

        - それ以外の正の整数はバッファーのおよそのサイズになることを意味
          します。

        - 負のサイズ (デフォルト) は io.DEFAULT_BUFFER_SIZE のシステムデ
          フォルトが使用されることを意味します。

     バージョン 3.3.1 で変更: 'bufsize' now defaults to -1 to enable
     buffering by default to match the behavior that most code expects.
     In versions prior to Python 3.2.4 and 3.3.1 it incorrectly
     defaulted to ‘0’ which was unbuffered and allowed short reads.
     This was unintentional and did not match the behavior of Python 2
     as most code expected.

     'executable' 引数は、実行する置換プログラムを指定します。これが必要
     になるのは極めて稀です。‘shell=False’ のときは、'executable' は
     'args' で指定されている実行プログラムを置換します。しかし、オリジナ
     ルの 'args' は依然としてプログラムに渡されます。ほとんどのプログラ
     ムは、'args' で指定されたプログラムをコマンド名として扱います。そし
     て、それは実際に実行されたプログラムとは異なる可能性があります。
     POSIX において、‘ps’ のようなユーティリティの中では、'args' 名が実
     行ファイルの表示名になります。‘shell=True’ の場合、POSIX において
     'executable' 引数はデフォルトの ‘/bin/sh’ に対する置換シェルを指定
     します。

     バージョン 3.6 で変更: 'executable' 引数が POSIX で *note path-like
     object: 280. を受け付けるようになりました。

     バージョン 3.8 で変更: 'executable' 引数が Windows で *note
     path-like object: 280. を受け付けるようになりました。

     バージョン 3.12 で変更: ‘shell=True’ のときのWindowsシェル検索順序
     を変更しました。カレントディレクトリと ‘%PATH%’ は、 ‘%COMSPEC%’ と
     ‘%SystemRoot%\System32\cmd.exe’ に置き換えられました。これにより、
     ‘cmd.exe’ という名前の悪意のあるプログラムをカレントディレクトリに
     ドロップしても、動作しなくなりました。

     'stdin', 'stdout' and 'stderr' specify the executed program's
     standard input, standard output and standard error file handles,
     respectively.  Valid values are ‘None’, *note PIPE: b55, *note
     DEVNULL: 1121, an existing file descriptor (a positive integer),
     and an existing *note file object: 1193. with a valid file
     descriptor.  With the default settings of ‘None’, no redirection
     will occur.  *note PIPE: b55. indicates that a new pipe to the
     child should be created.  *note DEVNULL: 1121. indicates that the
     special file *note os.devnull: 199e. will be used.  Additionally,
     'stderr' can be *note STDOUT: 3096, which indicates that the stderr
     data from the applications should be captured into the same file
     handle as for 'stdout'.

     'preexec_fn' に呼び出し可能オブジェクトが指定されている場合、このオ
     ブジェクトは子プロセスが実行される直前 (fork されたあと、exec され
     る直前) に子プロセス内で呼ばれます。(POSIXのみ)

          警告: アプリケーション中に複数のスレッドが存在する状態で
          'preexec_fn' 引数を使用するのは**安全ではありません**。exec が
          呼ばれる前に子プロセスがデッドロックを起こすことがあります。

          注釈: If you need to modify the environment for the child use
          the 'env' parameter rather than doing it in a 'preexec_fn'.
          The 'start_new_session' and 'process_group' parameters should
          take the place of code using 'preexec_fn' to call *note
          os.setsid(): 1940. or *note os.setpgid(): 2a7d. in the child.

     バージョン 3.8 で変更: The 'preexec_fn' parameter is no longer
     supported in subinterpreters.  The use of the parameter in a
     subinterpreter raises *note RuntimeError: 17a.  The new restriction
     may affect applications that are deployed in mod_wsgi, uWSGI, and
     other embedded environments.

     If 'close_fds' is true, all file descriptors except ‘0’, ‘1’ and
     ‘2’ will be closed before the child process is executed.  Otherwise
     when 'close_fds' is false, file descriptors obey their inheritable
     flag as described in *note ファイル記述子の継承: ec4.

     On Windows, if 'close_fds' is true then no handles will be
     inherited by the child process unless explicitly passed in the
     ‘handle_list’ element of *note STARTUPINFO.lpAttributeList: bdc, or
     by standard handle redirection.

     バージョン 3.2 で変更: 'close_fds' のデフォルトは、*note False:
     b05. から上記のものに変更されました。

     バージョン 3.7 で変更: On Windows the default for 'close_fds' was
     changed from *note False: b05. to *note True: bdb. when redirecting
     the standard handles.  It's now possible to set 'close_fds' to
     *note True: bdb. when redirecting the standard handles.

     'pass_fds' はオプションで、親と子の間で開いたままにしておくファイル
     記述子のシーケンスを指定します。何らかの 'pass_fds' を渡した場合、
     'close_fds' は強制的に *note True: bdb. になります。(POSIXのみ)

     バージョン 3.2 で変更: 'pass_fds' 引数が追加されました。

     If 'cwd' is not ‘None’, the function changes the working directory
     to 'cwd' before executing the child.  'cwd' can be a string, bytes
     or *note path-like: 280. object.  On POSIX, the function looks for
     'executable' (or for the first item in 'args') relative to 'cwd' if
     the executable path is a relative path.

     バージョン 3.6 で変更: 'cwd' 引数が POSIX で *note path-like
     object: 280. を受け付けるようになりました。

     バージョン 3.7 で変更: 'cwd' 引数が Windows で *note path-like
     object: 280. を受け付けるようになりました。

     バージョン 3.8 で変更: 'cwd' 引数が Windows で bytes オブジェクトを
     受け付けるようになりました。

     'restore_signals' が真の場合 (デフォルト)、Python が SIG_IGN に設定
     したすべてのシグナルは子プロセスが exec される前に子プロセスの
     SIG_DFL に格納されます。現在これには SIGPIPE, SIGXFZ および SIGXFSZ
     シグナルが含まれています。(POSIX のみ)

     バージョン 3.2 で変更: 'restore_signals' が追加されました。

     If 'start_new_session' is true the ‘setsid()’ system call will be
     made in the child process prior to the execution of the subprocess.

     *note Availability: 1cbe.: POSIX

     バージョン 3.2 で変更: 'start_new_session' が追加されました。

     If 'process_group' is a non-negative integer, the ‘setpgid(0,
     value)’ system call will be made in the child process prior to the
     execution of the subprocess.

     *note Availability: 1cbe.: POSIX

     バージョン 3.11 で変更: 'process_group' was added.

     If 'group' is not ‘None’, the setregid() system call will be made
     in the child process prior to the execution of the subprocess.  If
     the provided value is a string, it will be looked up via *note
     grp.getgrnam(): 30b1. and the value in ‘gr_gid’ will be used.  If
     the value is an integer, it will be passed verbatim.  (POSIX only)

     *note Availability: 1cbe.: POSIX

     Added in version 3.9.

     If 'extra_groups' is not ‘None’, the setgroups() system call will
     be made in the child process prior to the execution of the
     subprocess.  Strings provided in 'extra_groups' will be looked up
     via *note grp.getgrnam(): 30b1. and the values in ‘gr_gid’ will be
     used.  Integer values will be passed verbatim.  (POSIX only)

     *note Availability: 1cbe.: POSIX

     Added in version 3.9.

     If 'user' is not ‘None’, the setreuid() system call will be made in
     the child process prior to the execution of the subprocess.  If the
     provided value is a string, it will be looked up via *note
     pwd.getpwnam(): 30b2. and the value in ‘pw_uid’ will be used.  If
     the value is an integer, it will be passed verbatim.  (POSIX only)

     *note Availability: 1cbe.: POSIX

     Added in version 3.9.

     If 'umask' is not negative, the umask() system call will be made in
     the child process prior to the execution of the subprocess.

     *note Availability: 1cbe.: POSIX

     Added in version 3.9.

     'env' が ‘None’ 以外の場合、これは新しいプロセスでの環境変数を定義
     します。デフォルトでは、子プロセスは現在のプロセスの環境変数を引き
     継ぎます。あらゆるプラットフォームで *note os.environ: 118a. のよう
     に文字列から文字列へ、またPOSIX プラットフォームにおいては *note
     os.environb: 11e8. のようにバイトからバイトへも、定義すること出来ま
     す。

          注釈: 'env' を指定する場合、プログラムを実行するのに必要な変数
          すべてを与えなければなりません。Windows で Side-by-Side アセン
          ブリ(1) を実行するためには、'env' は正しい ‘SystemRoot’ を '含
          まなければなりません' 。

     If 'encoding' or 'errors' are specified, or 'text' is true, the
     file objects 'stdin', 'stdout' and 'stderr' are opened in text mode
     with the specified 'encoding' and 'errors', as described above in
     *note よく使われる引数: 3095.  The 'universal_newlines' argument is
     equivalent to 'text' and is provided for backwards compatibility.
     By default, file objects are opened in binary mode.

     Added in version 3.6: 'encoding' と 'errors' が追加されました。

     Added in version 3.7: 'text' が、'universal_newlines' のより読みや
     すい別名として追加されました。

     If given, 'startupinfo' will be a *note STARTUPINFO: 30b3. object,
     which is passed to the underlying ‘CreateProcess’ function.

     If given, 'creationflags', can be one or more of the following
     flags:

        * *note CREATE_NEW_CONSOLE: 30b4.

        * *note CREATE_NEW_PROCESS_GROUP: 30b5.

        * *note ABOVE_NORMAL_PRIORITY_CLASS: 30b6.

        * *note BELOW_NORMAL_PRIORITY_CLASS: 30b7.

        * *note HIGH_PRIORITY_CLASS: 30b8.

        * *note IDLE_PRIORITY_CLASS: 30b9.

        * *note NORMAL_PRIORITY_CLASS: 30ba.

        * *note REALTIME_PRIORITY_CLASS: 30bb.

        * *note CREATE_NO_WINDOW: 30bc.

        * *note DETACHED_PROCESS: 30bd.

        * *note CREATE_DEFAULT_ERROR_MODE: 30be.

        * *note CREATE_BREAKAWAY_FROM_JOB: 30bf.

     'pipesize' can be used to change the size of the pipe when *note
     PIPE: b55. is used for 'stdin', 'stdout' or 'stderr'.  The size of
     the pipe is only changed on platforms that support this (only Linux
     at this time of writing).  Other platforms will ignore this
     parameter.

     バージョン 3.10 で変更: Added the 'pipesize' parameter.

     Popen オブジェクトは *note with: 59c. 文によってコンテキストマネー
     ジャーとしてサポートされます: 終了時には標準ファイル記述子が閉じら
     れ、プロセスを待機します:

          with Popen(["ifconfig"], stdout=PIPE) as proc:
              log.write(proc.stdout.read())

     Popen and the other functions in this module that use it raise an
     *note auditing event: 1825. ‘subprocess.Popen’ with arguments
     ‘executable’, ‘args’, ‘cwd’, and ‘env’.  The value for ‘args’ may
     be a single string or a list of strings, depending on platform.

     バージョン 3.2 で変更: コンテキストマネージャーサポートが追加されま
     した。

     バージョン 3.6 で変更: Popen destructor now emits a *note
     ResourceWarning: 225. warning if the child process is still
     running.

     バージョン 3.8 で変更: Popen can use *note os.posix_spawn(): 201.
     in some cases for better performance.  On Windows Subsystem for
     Linux and QEMU User Emulation, Popen constructor using *note
     os.posix_spawn(): 201. no longer raise an exception on errors like
     missing program, but the child process fails with a non-zero *note
     returncode: 1913.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Side-by-Side_Assembly


File: python.info,  Node: 例外<10>,  Prev: Popen コンストラクター,  Up: subprocess モジュールを使う

5.17.6.4 例外
.............

Exceptions raised in the child process, before the new program has
started to execute, will be re-raised in the parent.

The most common exception raised is *note OSError: 3f0.  This occurs,
for example, when trying to execute a non-existent file.  Applications
should prepare for *note OSError: 3f0. exceptions.  Note that, when
‘shell=True’, *note OSError: 3f0. will be raised by the child only if
the selected shell itself was not found.  To determine if the shell
failed to find the requested application, it is necessary to check the
return code or output from the subprocess.

不正な引数で *note Popen: 17e. が呼ばれた場合は *note ValueError: 1e3. が
発生します。

呼び出されたプロセスが非ゼロのリターンコードを返した場合 *note
check_call(): 30a4. や *note check_output(): f8e. は *note
CalledProcessError: 12f3. を送出します。

All of the functions and methods that accept a 'timeout' parameter, such
as *note run(): b54. and *note Popen.communicate(): 3097. will raise
*note TimeoutExpired: 3098. if the timeout expires before the process
exits.

このモジュールで定義されたすべての例外は *note SubprocessError: 309e. を
継承しています。

Added in version 3.3: *note SubprocessError: 309e. 基底クラスが追加され
ました。


File: python.info,  Node: セキュリティで考慮すべき点<2>,  Next: Popen オブジェクト,  Prev: subprocess モジュールを使う,  Up: subprocess --- サブプロセス管理

5.17.6.5 セキュリティで考慮すべき点
...................................

Unlike some other popen functions, this library will not implicitly
choose to call a system shell.  This means that all characters,
including shell metacharacters, can safely be passed to child processes.
If the shell is invoked explicitly, via ‘shell=True’, it is the
application's responsibility to ensure that all whitespace and
metacharacters are quoted appropriately to avoid shell injection(1)
vulnerabilities.  On *note some platforms: 30c2, it is possible to use
*note shlex.quote(): 25e. for this escaping.

On Windows, batch files (‘*.bat’ or ‘*.cmd’) may be launched by the
operating system in a system shell regardless of the arguments passed to
this library.  This could result in arguments being parsed according to
shell rules, but without any escaping added by Python.  If you are
intentionally launching a batch file with arguments from untrusted
sources, consider passing ‘shell=True’ to allow Python to escape special
characters.  See gh-114539(2) for additional discussion.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Shell_injection#Shell_injection

   (2) https://github.com/python/cpython/issues/114539


File: python.info,  Node: Popen オブジェクト,  Next: Windows Popen ヘルパー,  Prev: セキュリティで考慮すべき点<2>,  Up: subprocess --- サブプロセス管理

5.17.6.6 Popen オブジェクト
...........................

*note Popen: 17e. クラスのインスタンスには、以下のようなメソッドがありま
す:

 -- メソッド: Popen.poll ()

     子プロセスが終了しているかどうかを調べます。 *note returncode:
     1913. 属性を設定して返します。そうでなければ ‘None’ を返します。

 -- メソッド: Popen.wait (timeout=None)

     子プロセスが終了するまで待ちます。*note returncode: 1913. 属性を設
     定して返します。

     プロセスが 'timeout' 秒後に終了してない場合、*note TimeoutExpired:
     3098. 例外を送出します。この例外を捕捉して wait を再試行するのは安
     全です。

          注釈: ‘stdout=PIPE’ や ‘stderr=PIPE’ を使っていて、より多くの
          データを受け入れるために OS のパイプバッファーをブロックしてい
          るパイプに子プロセスが十分な出力を生成した場合、デッドロックが
          発生します。これを避けるには *note Popen.communicate(): 3097.
          を使用してください。

          注釈: When the ‘timeout’ parameter is not ‘None’, then (on
          POSIX) the function is implemented using a busy loop
          (non-blocking call and short sleeps).  Use the *note asyncio:
          8. module for an asynchronous wait: see *note
          asyncio.create_subprocess_exec: a45.

     バージョン 3.3 で変更: 'timeout' が追加されました

 -- メソッド: Popen.communicate (input=None, timeout=None)

     Interact with process: Send data to stdin.  Read data from stdout
     and stderr, until end-of-file is reached.  Wait for process to
     terminate and set the *note returncode: 1913. attribute.  The
     optional 'input' argument should be data to be sent to the child
     process, or ‘None’, if no data should be sent to the child.  If
     streams were opened in text mode, 'input' must be a string.
     Otherwise, it must be bytes.

     *note communicate(): 3097. returns a tuple ‘(stdout_data,
     stderr_data)’.  The data will be strings if streams were opened in
     text mode; otherwise, bytes.

     子プロセスの標準入力にデータを送りたい場合は、 Popen オブジェクトを
     ‘stdin=PIPE’ と指定して作成しなければなりません。同じく、戻り値のタ
     プルから ‘None’ ではない値を取得するためには、 ‘stdout=PIPE’ かつ
     /または ‘stderr=PIPE’ を指定しなければなりません。

     プロセスが 'timeout' 秒後に終了してない場合、*note TimeoutExpired:
     3098. 例外が送出されます。この例外を捕捉して通信を再試行しても出力
     データは失われません。

     タイムアウトが発生した場合子プロセスは kill されません。したがって
     、適切にクリーンアップを行うために、正常に動作するアプリケーション
     は子プロセスを kill して通信を終了すべきです:

          proc = subprocess.Popen(...)
          try:
              outs, errs = proc.communicate(timeout=15)
          except TimeoutExpired:
              proc.kill()
              outs, errs = proc.communicate()

          注釈: 受信したデータはメモリにバッファーされます。そのため、返
          されるデータが大きいかあるいは制限がないような場合はこのメソッ
          ドを使うべきではありません。

     バージョン 3.3 で変更: 'timeout' が追加されました

 -- メソッド: Popen.send_signal (signal)

     'signal' シグナルを子プロセスに送ります。

     Do nothing if the process completed.

          注釈: Windows では、SIGTERM は *note terminate(): 1384. の別名
          です。CTRL_C_EVENT と CTRL_BREAK_EVENT を、
          ‘CREATE_NEW_PROCESS_GROUP’ を含む 'creationflags' で始まった、
          プロセスに送れます。

 -- メソッド: Popen.terminate ()

     Stop the child.  On POSIX OSs the method sends *note SIGTERM: 1387.
     to the child.  On Windows the Win32 API function
     ‘TerminateProcess()’ is called to stop the child.

 -- メソッド: Popen.kill ()

     子プロセスを kill します。POSIX OS では SIGKILL シグナルを子プロセ
     スに送ります。Windows では、*note kill(): 1385. は *note
     terminate(): 1384. の別名です。

The following attributes are also set by the class for you to access.
Reassigning them to new values is unsupported:

 -- の属性: Popen.args

     *note Popen: 17e. に渡された引数 'args' です - プログラム引数のシー
     ケンスまたは 1 個の文字列になります。

     Added in version 3.3.

 -- の属性: Popen.stdin

     If the 'stdin' argument was *note PIPE: b55, this attribute is a
     writeable stream object as returned by *note open(): 4e5.  If the
     'encoding' or 'errors' arguments were specified or the 'text' or
     'universal_newlines' argument was ‘True’, the stream is a text
     stream, otherwise it is a byte stream.  If the 'stdin' argument was
     not *note PIPE: b55, this attribute is ‘None’.

 -- の属性: Popen.stdout

     If the 'stdout' argument was *note PIPE: b55, this attribute is a
     readable stream object as returned by *note open(): 4e5.  Reading
     from the stream provides output from the child process.  If the
     'encoding' or 'errors' arguments were specified or the 'text' or
     'universal_newlines' argument was ‘True’, the stream is a text
     stream, otherwise it is a byte stream.  If the 'stdout' argument
     was not *note PIPE: b55, this attribute is ‘None’.

 -- の属性: Popen.stderr

     If the 'stderr' argument was *note PIPE: b55, this attribute is a
     readable stream object as returned by *note open(): 4e5.  Reading
     from the stream provides error output from the child process.  If
     the 'encoding' or 'errors' arguments were specified or the 'text'
     or 'universal_newlines' argument was ‘True’, the stream is a text
     stream, otherwise it is a byte stream.  If the 'stderr' argument
     was not *note PIPE: b55, this attribute is ‘None’.

     警告: *note .stdin.write: 30ab, *note .stdout.read: 30ac, *note
     .stderr.read: 30ad. を利用すると、別のパイプの OS パイプバッファー
     がいっぱいになってデッドロックが発生する恐れがあります。これを避け
     るためには *note communicate(): 3097. を利用してください。

 -- の属性: Popen.pid

     子プロセスのプロセス ID が入ります。

     'shell' 引数を ‘True’ に設定した場合は、生成されたシェルのプロセス
     ID になります。

 -- の属性: Popen.returncode

     The child return code.  Initially ‘None’, *note returncode: 1913.
     is set by a call to the *note poll(): 30c4, *note wait(): cb2, or
     *note communicate(): 3097. methods if they detect that the process
     has terminated.

     A ‘None’ value indicates that the process hadn't yet terminated at
     the time of the last method call.

     負の値 ‘-N’ は子プロセスがシグナル ‘N’ により中止させられたことを示
     します (POSIX のみ)。


File: python.info,  Node: Windows Popen ヘルパー,  Next: 古い高水準 API,  Prev: Popen オブジェクト,  Up: subprocess --- サブプロセス管理

5.17.6.7 Windows Popen ヘルパー
...............................

*note STARTUPINFO: 30b3. クラスと以下の定数は、Windows のみで利用できま
す。

 -- クラス: subprocess.STARTUPINFO (*, dwFlags=0, hStdInput=None,
          hStdOutput=None, hStdError=None, wShowWindow=0,
          lpAttributeList=None)

     Partial support of the Windows STARTUPINFO(1) structure is used for
     *note Popen: 17e. creation.  The following attributes can be set by
     passing them as keyword-only arguments.

     バージョン 3.7 で変更: キーワード専用引数のサポートが追加されました
     。

      -- の属性: dwFlags

          特定の *note STARTUPINFO: 30b3. の属性が、プロセスがウィンドウ
          を生成するときに使われるかを決定するビットフィールドです:

               si = subprocess.STARTUPINFO()
               si.dwFlags = subprocess.STARTF_USESTDHANDLES | subprocess.STARTF_USESHOWWINDOW

      -- の属性: hStdInput

          *note dwFlags: 30c8. が *note STARTF_USESTDHANDLES: 30ca. を指
          定すれば、この属性がプロセスの標準入力処理です。*note
          STARTF_USESTDHANDLES: 30ca. が指定されなければ、標準入力のデフ
          ォルトはキーボードバッファーです。

      -- の属性: hStdOutput

          *note dwFlags: 30c8. が *note STARTF_USESTDHANDLES: 30ca. を指
          定すれば、この属性がプロセスの標準出力処理です。そうでなければ
          、この属性は無視され、標準出力のデフォルトはコンソールウィンド
          ウのバッファーです。

      -- の属性: hStdError

          *note dwFlags: 30c8. が *note STARTF_USESTDHANDLES: 30ca. を指
          定すれば、この属性がプロセスの標準エラー処理です。そうでなけれ
          ば、この属性は無視され、標準エラー出力のデフォルトはコンソール
          ウィンドウのバッファーです。

      -- の属性: wShowWindow

          *note dwFlags: 30c8. が *note STARTF_USESHOWWINDOW: 30ce. を指
          定すれば、この属性は ShowWindow(2) 関数の ‘nCmdShow’ 引数で指
          定された値なら、 ‘SW_SHOWDEFAULT’ 以外の任意のものにできます。
          しかし、この属性は無視されます。

          この属性には *note SW_HIDE: 30cf. が提供されています。これは、
          *note Popen: 17e. が ‘shell=True’ として呼び出されたときに使わ
          れます。

      -- の属性: lpAttributeList

          A dictionary of additional attributes for process creation as
          given in ‘STARTUPINFOEX’, see UpdateProcThreadAttribute(3).

          Supported attributes:

          'handle_list'

               Sequence of handles that will be inherited.  'close_fds'
               must be true if non-empty.

               The handles must be temporarily made inheritable by *note
               os.set_handle_inheritable(): ec8. when passed to the
               *note Popen: 17e. constructor, else *note OSError: 3f0.
               will be raised with Windows error
               ‘ERROR_INVALID_PARAMETER’ (87).

                    警告: In a multithreaded process, use caution to
                    avoid leaking handles that are marked inheritable
                    when combining this feature with concurrent calls to
                    other process creation functions that inherit all
                    handles such as *note os.system(): 1402.  This also
                    applies to standard handle redirection, which
                    temporarily creates inheritable handles.

          Added in version 3.7.

* Menu:

* Windows Constants::

   ---------- Footnotes ----------

   (1) https://msdn.microsoft.com/en-us/library/ms686331(v=vs.85).aspx

   (2) https://msdn.microsoft.com/en-us/library/ms633548(v=vs.85).aspx

   (3) 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686880(v=vs.85).aspx


File: python.info,  Node: Windows Constants,  Up: Windows Popen ヘルパー

5.17.6.8 Windows Constants
..........................

*note subprocess: c1. モジュールは、以下の定数を公開しています。

 -- データ: subprocess.STD_INPUT_HANDLE

     標準入力デバイスです。この初期値は、コンソール入力バッファ、
     ‘CONIN$’ です。

 -- データ: subprocess.STD_OUTPUT_HANDLE

     標準出力デバイスです。この初期値は、アクティブコンソールスクリーン
     、 ‘CONOUT$’ です。

 -- データ: subprocess.STD_ERROR_HANDLE

     標準エラーデバイスです。この初期値は、アクティブコンソールスクリー
     ン、 ‘CONOUT$’ です。

 -- データ: subprocess.SW_HIDE

     ウィンドウを隠します。別のウィンドウがアクティブになります。

 -- データ: subprocess.STARTF_USESTDHANDLES

     追加情報を保持する、*note STARTUPINFO.hStdInput: 30c9, *note
     STARTUPINFO.hStdOutput: 30cb, および *note STARTUPINFO.hStdError:
     30cc. 属性を指定します。

 -- データ: subprocess.STARTF_USESHOWWINDOW

     追加情報を保持する、 *note STARTUPINFO.wShowWindow: 30cd. 属性を指
     定します。

 -- データ: subprocess.STARTF_FORCEONFEEDBACK

     A *note STARTUPINFO.dwFlags: 30c8. parameter to specify that the
     'Working in Background' mouse cursor will be displayed while a
     process is launching.  This is the default behavior for GUI
     processes.

     Added in version 3.13.

 -- データ: subprocess.STARTF_FORCEOFFFEEDBACK

     A *note STARTUPINFO.dwFlags: 30c8. parameter to specify that the
     mouse cursor will not be changed when launching a process.

     Added in version 3.13.

 -- データ: subprocess.CREATE_NEW_CONSOLE

     新しいプロセスが、親プロセスのコンソールを継承する (デフォルト) の
     ではなく、新しいコンソールを持ちます。

 -- データ: subprocess.CREATE_NEW_PROCESS_GROUP

     新しいプロセスグループが生成されることを指定する *note Popen: 17e.
     ‘creationflags’ パラメーターです。このフラグは、サブプロセスで
     *note os.kill(): 132f. を使うのに必要です。

     *note CREATE_NEW_CONSOLE: 30b4. が指定されていたら、このフラグは無
     視されます。

 -- データ: subprocess.ABOVE_NORMAL_PRIORITY_CLASS

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will have an above average priority.

     Added in version 3.7.

 -- データ: subprocess.BELOW_NORMAL_PRIORITY_CLASS

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will have a below average priority.

     Added in version 3.7.

 -- データ: subprocess.HIGH_PRIORITY_CLASS

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will have a high priority.

     Added in version 3.7.

 -- データ: subprocess.IDLE_PRIORITY_CLASS

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will have an idle (lowest) priority.

     Added in version 3.7.

 -- データ: subprocess.NORMAL_PRIORITY_CLASS

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will have a normal priority.  (default)

     Added in version 3.7.

 -- データ: subprocess.REALTIME_PRIORITY_CLASS

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will have realtime priority.  You should almost never use
     REALTIME_PRIORITY_CLASS, because this interrupts system threads
     that manage mouse input, keyboard input, and background disk
     flushing.  This class can be appropriate for applications that
     "talk" directly to hardware or that perform brief tasks that should
     have limited interruptions.

     Added in version 3.7.

 -- データ: subprocess.CREATE_NO_WINDOW

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will not create a window.

     Added in version 3.7.

 -- データ: subprocess.DETACHED_PROCESS

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process will not inherit its parent's console.  This value cannot
     be used with CREATE_NEW_CONSOLE.

     Added in version 3.7.

 -- データ: subprocess.CREATE_DEFAULT_ERROR_MODE

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process does not inherit the error mode of the calling process.
     Instead, the new process gets the default error mode.  This feature
     is particularly useful for multithreaded shell applications that
     run with hard errors disabled.

     Added in version 3.7.

 -- データ: subprocess.CREATE_BREAKAWAY_FROM_JOB

     A *note Popen: 17e. ‘creationflags’ parameter to specify that a new
     process is not associated with the job.

     Added in version 3.7.


File: python.info,  Node: 古い高水準 API,  Next: 古い関数を subprocess モジュールで置き換える,  Prev: Windows Popen ヘルパー,  Up: subprocess --- サブプロセス管理

5.17.6.9 古い高水準 API
.......................

Python 3.5 より前のバージョンでは、サブプロセスに対して以下の 3 つの関数
からなる高水準 API が用意されていました。現在多くの場合 *note run():
b54. の使用で済みますが、既存の多くのコードではこれらの関数が使用されて
います。

 -- の関数: subprocess.call (args, *, stdin=None, stdout=None,
          stderr=None, shell=False, cwd=None, timeout=None,
          **other_popen_kwargs)

     'args' で指定されたコマンドを実行します。コマンドの終了を待ち、
     *note returncode: 1913. 属性を返します。

     Code needing to capture stdout or stderr should use *note run():
     b54. instead:

          run(...).returncode

     To suppress stdout or stderr, supply a value of *note DEVNULL:
     1121.

     上記の引数は、よく使われるものだけ示しています。関数の全使用法は
     *note Popen: 17e. コンストラクターの内容と同じになります - この関数
     は、このインターフェースに直接指定される 'timeout' 以外は与えられた
     全引数を渡します。

          注釈: この関数を使用する際は ‘stdout=PIPE’ および
          ‘stderr=PIPE’ を使用しないでください。子プロセスが OS のパイプ
          バッファーを埋めてしまうほどの出力データを生成した場合、パイプ
          からは読み込まれないので、子プロセスがブロックされることがあり
          ます。

     バージョン 3.3 で変更: 'timeout' が追加されました

     バージョン 3.12 で変更: ‘shell=True’ のときのWindowsシェル検索順序
     を変更しました。カレントディレクトリと ‘%PATH%’ は、 ‘%COMSPEC%’ と
     ‘%SystemRoot%\System32\cmd.exe’ に置き換えられました。これにより、
     ‘cmd.exe’ という名前の悪意のあるプログラムをカレントディレクトリに
     ドロップしても、動作しなくなりました。

 -- の関数: subprocess.check_call (args, *, stdin=None, stdout=None,
          stderr=None, shell=False, cwd=None, timeout=None,
          **other_popen_kwargs)

     Run command with arguments.  Wait for command to complete.  If the
     return code was zero then return, otherwise raise *note
     CalledProcessError: 12f3.  The *note CalledProcessError: 12f3.
     object will have the return code in the *note returncode: 30a5.
     attribute.  If *note check_call(): 30a4. was unable to start the
     process it will propagate the exception that was raised.

     Code needing to capture stdout or stderr should use *note run():
     b54. instead:

          run(..., check=True)

     To suppress stdout or stderr, supply a value of *note DEVNULL:
     1121.

     上記の引数は、よく使われるものだけ示しています。関数の全使用法は
     *note Popen: 17e. コンストラクターの内容と同じになります - この関数
     は、このインターフェースに直接指定される 'timeout' 以外は与えられた
     全引数を渡します。

          注釈: この関数を使用する際は ‘stdout=PIPE’ および
          ‘stderr=PIPE’ を使用しないでください。子プロセスが OS のパイプ
          バッファーを埋めてしまうほどの出力データを生成した場合、パイプ
          からは読み込まれないので、子プロセスがブロックされることがあり
          ます。

     バージョン 3.3 で変更: 'timeout' が追加されました

     バージョン 3.12 で変更: ‘shell=True’ のときのWindowsシェル検索順序
     を変更しました。カレントディレクトリと ‘%PATH%’ は、 ‘%COMSPEC%’ と
     ‘%SystemRoot%\System32\cmd.exe’ に置き換えられました。これにより、
     ‘cmd.exe’ という名前の悪意のあるプログラムをカレントディレクトリに
     ドロップしても、動作しなくなりました。

 -- の関数: subprocess.check_output (args, *, stdin=None, stderr=None,
          shell=False, cwd=None, encoding=None, errors=None,
          universal_newlines=None, timeout=None, text=None,
          **other_popen_kwargs)

     引数でコマンドを実行し、その出力を返します。

     コマンドのリターンコードが非ゼロならば *note CalledProcessError:
     12f3. 例外が送出されます。*note CalledProcessError: 12f3. オブジェ
     クトには、リターンコードが *note returncode: 30a5. 属性に、コマンド
     からの出力が *note output: 30a7. 属性に、それぞれ格納されています。

     これは次と等価です:

          run(..., check=True, stdout=PIPE).stdout

     The arguments shown above are merely some common ones.  The full
     function signature is largely the same as that of *note run(): b54.
     - most arguments are passed directly through to that interface.
     One API deviation from *note run(): b54. behavior exists: passing
     ‘input=None’ will behave the same as ‘input=b''’ (or ‘input=''’,
     depending on other arguments) rather than using the parent's
     standard input file handle.

     デフォルトで、この関数はデータをエンコードされたバイトとして返しま
     す。出力されたデータの実際のエンコードは起動されているコマンドに依
     存するため、テキストへのデコードは通常アプリケーションレベルで扱う
     必要があります。

     This behaviour may be overridden by setting 'text', 'encoding',
     'errors', or 'universal_newlines' to ‘True’ as described in *note
     よく使われる引数: 3095. and *note run(): b54.

     標準エラー出力も結果に含めるには、‘stderr=subprocess.STDOUT’ を使い
     ます:

          >>> subprocess.check_output(
          ...     "ls non_existent_file; exit 0",
          ...     stderr=subprocess.STDOUT,
          ...     shell=True)
          'ls: non_existent_file: No such file or directory\n'

     Added in version 3.1.

     バージョン 3.3 で変更: 'timeout' が追加されました

     バージョン 3.4 で変更: キーワード引数 'input' が追加されました。

     バージョン 3.6 で変更: 'encoding' and 'errors' were added.  See
     *note run(): b54. for details.

     Added in version 3.7: 'text' が、'universal_newlines' のより読みや
     すい別名として追加されました。

     バージョン 3.12 で変更: ‘shell=True’ のときのWindowsシェル検索順序
     を変更しました。カレントディレクトリと ‘%PATH%’ は、 ‘%COMSPEC%’ と
     ‘%SystemRoot%\System32\cmd.exe’ に置き換えられました。これにより、
     ‘cmd.exe’ という名前の悪意のあるプログラムをカレントディレクトリに
     ドロップしても、動作しなくなりました。


File: python.info,  Node: 古い関数を subprocess モジュールで置き換える,  Next: レガシーなシェル呼び出し関数,  Prev: 古い高水準 API,  Up: subprocess --- サブプロセス管理

5.17.6.10 古い関数を ‘subprocess’ モジュールで置き換える
........................................................

この節では、 "a becomes b" と書かれているものは a の代替として b が使え
るということを表します。

     注釈: この節で紹介されている "a" 関数は全て、実行するプログラムが見
     つからないときは (おおむね) 静かに終了します。それに対して "b" 代替
     手段は *note OSError: 3f0. 例外を送出します。

     また、要求された操作が非ゼロの終了コードを返した場合、*note
     check_output(): f8e. を使用した置き換えは *note CalledProcessError:
     12f3. で失敗します。その出力は、送出された例外の *note output:
     30a7. 属性として利用可能です。

以下の例では、適切な関数が *note subprocess: c1. モジュールからすでにイ
ンポートされていることを前提としています。

* Menu:

* Replacing /bin/sh shell command substitution::
* シェルのパイプラインを置き換える::
* os.system() を置き換える: os system を置き換える.
* os.spawn 関数群を置き換える: os spawn 関数群を置き換える.
* os.popen(), os.popen2(), os.popen3() を置き換える: os popen os popen2 os popen3 を置き換える.
* Replacing functions from the popen2 module::


File: python.info,  Node: Replacing /bin/sh shell command substitution,  Next: シェルのパイプラインを置き換える,  Up: 古い関数を subprocess モジュールで置き換える

5.17.6.11 Replacing ‘/bin/sh’ shell command substitution
........................................................

     output=$(mycmd myarg)

これは以下のようになります:

     output = check_output(["mycmd", "myarg"])


File: python.info,  Node: シェルのパイプラインを置き換える,  Next: os system を置き換える,  Prev: Replacing /bin/sh shell command substitution,  Up: 古い関数を subprocess モジュールで置き換える

5.17.6.12 シェルのパイプラインを置き換える
..........................................

     output=$(dmesg | grep hda)

これは以下のようになります:

     p1 = Popen(["dmesg"], stdout=PIPE)
     p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
     p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits.
     output = p2.communicate()[0]

p2 を開始した後の ‘p1.stdout.close()’ の呼び出しは、p1 が p2 の前に存在
した場合に、p1 が SIGPIPE を受け取るために重要です。

あるいは、信頼された入力に対しては、シェル自身のパイプラインサポートを直
接使用することもできます:

     output=$(dmesg | grep hda)

これは以下のようになります:

     output = check_output("dmesg | grep hda", shell=True)


File: python.info,  Node: os system を置き換える,  Next: os spawn 関数群を置き換える,  Prev: シェルのパイプラインを置き換える,  Up: 古い関数を subprocess モジュールで置き換える

5.17.6.13 ‘os.system()’ を置き換える
....................................

     sts = os.system("mycmd" + " myarg")
     # becomes
     retcode = call("mycmd" + " myarg", shell=True)

注釈:

   * このプログラムは普通シェル経由で呼び出す必要はありません。

   * The *note call(): b56. return value is encoded differently to that
     of *note os.system(): 1402.

   * The *note os.system(): 1402. function ignores SIGINT and SIGQUIT
     signals while the command is running, but the caller must do this
     separately when using the *note subprocess: c1. module.

より現実的な例ではこうなるでしょう:

     try:
         retcode = call("mycmd" + " myarg", shell=True)
         if retcode < 0:
             print("Child was terminated by signal", -retcode, file=sys.stderr)
         else:
             print("Child returned", retcode, file=sys.stderr)
     except OSError as e:
         print("Execution failed:", e, file=sys.stderr)


File: python.info,  Node: os spawn 関数群を置き換える,  Next: os popen os popen2 os popen3 を置き換える,  Prev: os system を置き換える,  Up: 古い関数を subprocess モジュールで置き換える

5.17.6.14 ‘os.spawn’ 関数群を置き換える
.......................................

P_NOWAIT の例:

     pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg")
     ==>
     pid = Popen(["/bin/mycmd", "myarg"]).pid

P_WAIT の例:

     retcode = os.spawnlp(os.P_WAIT, "/bin/mycmd", "mycmd", "myarg")
     ==>
     retcode = call(["/bin/mycmd", "myarg"])

シーケンスを使った例:

     os.spawnvp(os.P_NOWAIT, path, args)
     ==>
     Popen([path] + args[1:])

環境変数を使った例:

     os.spawnlpe(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env)
     ==>
     Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})


File: python.info,  Node: os popen os popen2 os popen3 を置き換える,  Next: Replacing functions from the popen2 module,  Prev: os spawn 関数群を置き換える,  Up: 古い関数を subprocess モジュールで置き換える

5.17.6.15 ‘os.popen()’, ‘os.popen2()’, ‘os.popen3()’ を置き換える
.................................................................

     (child_stdin, child_stdout) = os.popen2(cmd, mode, bufsize)
     ==>
     p = Popen(cmd, shell=True, bufsize=bufsize,
               stdin=PIPE, stdout=PIPE, close_fds=True)
     (child_stdin, child_stdout) = (p.stdin, p.stdout)

     (child_stdin,
      child_stdout,
      child_stderr) = os.popen3(cmd, mode, bufsize)
     ==>
     p = Popen(cmd, shell=True, bufsize=bufsize,
               stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
     (child_stdin,
      child_stdout,
      child_stderr) = (p.stdin, p.stdout, p.stderr)

     (child_stdin, child_stdout_and_stderr) = os.popen4(cmd, mode, bufsize)
     ==>
     p = Popen(cmd, shell=True, bufsize=bufsize,
               stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
     (child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)

終了コードハンドリングは以下のように解釈します:

     pipe = os.popen(cmd, 'w')
     ...
     rc = pipe.close()
     if rc is not None and rc >> 8:
         print("There were some errors")
     ==>
     process = Popen(cmd, stdin=PIPE)
     ...
     process.stdin.close()
     if process.wait() != 0:
         print("There were some errors")


File: python.info,  Node: Replacing functions from the popen2 module,  Prev: os popen os popen2 os popen3 を置き換える,  Up: 古い関数を subprocess モジュールで置き換える

5.17.6.16 Replacing functions from the ‘popen2’ module
......................................................

     注釈: popen2 関数の cmd 引数が文字列の場合、コマンドは /bin/sh によ
     って実行されます。リストの場合、コマンドは直接実行されます。

     (child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode)
     ==>
     p = Popen("somestring", shell=True, bufsize=bufsize,
               stdin=PIPE, stdout=PIPE, close_fds=True)
     (child_stdout, child_stdin) = (p.stdout, p.stdin)

     (child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize, mode)
     ==>
     p = Popen(["mycmd", "myarg"], bufsize=bufsize,
               stdin=PIPE, stdout=PIPE, close_fds=True)
     (child_stdout, child_stdin) = (p.stdout, p.stdin)

‘popen2.Popen3’ および ‘popen2.Popen4’ は以下の点を除けば、基本的に
*note subprocess.Popen: 17e. と同じです:

   * *note Popen: 17e. は実行が失敗した場合に例外を送出します。

   * 'capturestderr' 引数は 'stderr' 引数に代わりました。

   * ‘stdin=PIPE’ および ‘stdout=PIPE’ を指定する必要があります。

   * popen2 はデフォルトですべてのファイル記述子を閉じます。しかし、全て
     のプラットフォーム上で、あるいは過去の Python バージョンでこの挙動
     を保証するためには、 *note Popen: 17e. に対して ‘close_fds=True’ を
     指定しなければなりません。


File: python.info,  Node: レガシーなシェル呼び出し関数,  Next: 注釈<2>,  Prev: 古い関数を subprocess モジュールで置き換える,  Up: subprocess --- サブプロセス管理

5.17.6.17 レガシーなシェル呼び出し関数
......................................

このモジュールでは、以下のような 2.x ‘commands’ モジュールからのレガシー
関数も提供しています。これらの操作は、暗黙的にシステムシェルを起動します
。また、セキュリティに関して上述した保証や例外処理一貫性は、これらの関数
では有効ではありません。

 -- の関数: subprocess.getstatusoutput (cmd, *, encoding=None,
          errors=None)

     シェル中の 'cmd' を実行して ‘(exitcode, output)’ を返します。

     Execute the string 'cmd' in a shell with ‘Popen.check_output()’ and
     return a 2-tuple ‘(exitcode, output)’.  'encoding' and 'errors' are
     used to decode output; see the notes on *note よく使われる引数:
     3095. for more details.

     A trailing newline is stripped from the output.  The exit code for
     the command can be interpreted as the return code of subprocess.
     Example:

          >>> subprocess.getstatusoutput('ls /bin/ls')
          (0, '/bin/ls')
          >>> subprocess.getstatusoutput('cat /bin/junk')
          (1, 'cat: /bin/junk: No such file or directory')
          >>> subprocess.getstatusoutput('/bin/junk')
          (127, 'sh: /bin/junk: not found')
          >>> subprocess.getstatusoutput('/bin/kill $$')
          (-15, '')

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.3.4 で変更: Windows のサポートが追加されました。

     The function now returns (exitcode, output) instead of (status,
     output) as it did in Python 3.3.3 and earlier.  exitcode has the
     same value as *note returncode: 1913.

     バージョン 3.11 で変更: Added the 'encoding' and 'errors'
     parameters.

 -- の関数: subprocess.getoutput (cmd, *, encoding=None, errors=None)

     シェル中の 'cmd' を実行して出力 (stdout と stderr) を返します。

     *note getstatusoutput(): f8f. に似ていますが、終了コードは無視され
     、コマンドの出力のみを返します。例えば:

          >>> subprocess.getoutput('ls /bin/ls')
          '/bin/ls'

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.3.4 で変更: Windowsで利用可能になりました

     バージョン 3.11 で変更: Added the 'encoding' and 'errors'
     parameters.


File: python.info,  Node: 注釈<2>,  Prev: レガシーなシェル呼び出し関数,  Up: subprocess --- サブプロセス管理

5.17.6.18 注釈
..............

* Menu:

* Windows における引数シーケンスから文字列への変換::
* Disabling use of vfork() or posix_spawn(): Disabling use of vfork or posix_spawn.


File: python.info,  Node: Windows における引数シーケンスから文字列への変換,  Next: Disabling use of vfork or posix_spawn,  Up: 注釈<2>

5.17.6.19 Windows における引数シーケンスから文字列への変換
..........................................................

Windows では、 'args' シーケンスは以下の (MS C ランタイムで使われる規則
に対応する) 規則を使って解析できる文字列に変換されます:

  1. 引数は、スペースかタブのどちらかの空白で分けられます。

  2. ダブルクオーテーションマークで囲まれた文字列は、空白が含まれていた
     としても 1 つの引数として解釈されます。クオートされた文字列は引数に
     埋め込めます。

  3. バックスラッシュに続くダブルクオーテーションマークは、リテラルのダ
     ブルクオーテーションマークと解釈されます。

  4. バックスラッシュは、ダブルクオーテーションが続かない限り、リテラル
     として解釈されます。

  5. 複数のバックスラッシュにダブルクオーテーションマークが続くなら、バ
     ックスラッシュ 2 つで 1 つのバックスラッシュ文字と解釈されます。バ
     ックスラッシュの数が奇数なら、最後のバックスラッシュは規則 3 に従っ
     て続くダブルクオーテーションマークをエスケープします。

参考
....

*note shlex: b2.

     コマンドラインを解析したりエスケープしたりする関数を提供するモジュ
     ール。


File: python.info,  Node: Disabling use of vfork or posix_spawn,  Prev: Windows における引数シーケンスから文字列への変換,  Up: 注釈<2>

5.17.6.20 Disabling use of ‘vfork()’ or ‘posix_spawn()’
.......................................................

On Linux, *note subprocess: c1. defaults to using the ‘vfork()’ system
call internally when it is safe to do so rather than ‘fork()’.  This
greatly improves performance.

If you ever encounter a presumed highly unusual situation where you need
to prevent ‘vfork()’ from being used by Python, you can set the
‘subprocess._USE_VFORK’ attribute to a false value.

     subprocess._USE_VFORK = False  # See CPython issue gh-NNNNNN.

Setting this has no impact on use of ‘posix_spawn()’ which could use
‘vfork()’ internally within its libc implementation.  There is a similar
‘subprocess._USE_POSIX_SPAWN’ attribute if you need to prevent use of
that.

     subprocess._USE_POSIX_SPAWN = False  # See CPython issue gh-NNNNNN.

It is safe to set these to false on any Python version.  They will have
no effect on older versions when unsupported.  Do not assume the
attributes are available to read.  Despite their names, a true value
does not indicate that the corresponding function will be used, only
that it may be.

Please file issues any time you have to use these private knobs with a
way to reproduce the issue you were seeing.  Link to that issue from a
comment in your code.

Added in version 3.8: ‘_USE_POSIX_SPAWN’

Added in version 3.11: ‘_USE_VFORK’


File: python.info,  Node: sched --- イベントスケジューラー,  Next: queue --- 同期キュークラス,  Prev: subprocess --- サブプロセス管理,  Up: 並行実行

5.17.7 ‘sched’ -- イベントスケジューラー
----------------------------------------

'ソースコード:' Lib/sched.py(1)

__________________________________________________________________

*note sched: ad. モジュールは一般的な目的のためのイベントスケジューラを
実装するクラスを定義します:

 -- クラス: sched.scheduler (timefunc=time.monotonic,
          delayfunc=time.sleep)

     *note scheduler: 10fa. クラスはイベントをスケジュールするための一般
     的なインターフェースを定義します。それは "外の世界" を実際に扱うた
     めの2つの関数を必要とします -- 'timefunc' は引数なしで呼ばれて 1 つ
     の数値を返す callable オブジェクトでなければなりません (戻り値は任
     意の単位で「時間」を表します)。 'delayfunc' は 1 つの引数を持つ
     callable オブジェクトでなければならず、その時間だけ遅延する必要があ
     ります (引数は 'timefunc' の出力と互換)。 'delayfunc' は、各々のイ
     ベントが実行された後に引数 ‘0’ で呼ばれることがあります。これは、マ
     ルチスレッドアプリケーションの中で他のスレッドが実行する機会を与え
     るためです。

     バージョン 3.3 で変更: 'timefunc' と 'delayfunc' がオプション引数に
     なりました。

     バージョン 3.3 で変更: *note scheduler: 10fa. クラスをマルチスレッ
     ド環境で安全に使用出来るようになりました。

以下はプログラム例です:

     >>> import sched, time
     >>> s = sched.scheduler(time.time, time.sleep)
     >>> def print_time(a='default'):
     ...     print("From print_time", time.time(), a)
     ...
     >>> def print_some_times():
     ...     print(time.time())
     ...     s.enter(10, 1, print_time)
     ...     s.enter(5, 2, print_time, argument=('positional',))
     ...     # despite having higher priority, 'keyword' runs after 'positional' as enter() is relative
     ...     s.enter(5, 1, print_time, kwargs={'a': 'keyword'})
     ...     s.enterabs(1_650_000_000, 10, print_time, argument=("first enterabs",))
     ...     s.enterabs(1_650_000_000, 5, print_time, argument=("second enterabs",))
     ...     s.run()
     ...     print(time.time())
     ...
     >>> print_some_times()
     1652342830.3640375
     From print_time 1652342830.3642538 second enterabs
     From print_time 1652342830.3643398 first enterabs
     From print_time 1652342835.3694863 positional
     From print_time 1652342835.3696074 keyword
     From print_time 1652342840.369612 default
     1652342840.3697174

* Menu:

* スケジューラオブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/sched.py


File: python.info,  Node: スケジューラオブジェクト,  Up: sched --- イベントスケジューラー

5.17.7.1 スケジューラオブジェクト
.................................

*note scheduler: 10fa. インスタンスは以下のメソッドと属性を持っています:

 -- メソッド: scheduler.enterabs (time, priority, action, argument=(),
          kwargs={})

     新しいイベントをスケジュールします。 引数 'time' は、コンストラクタ
     へ渡された 'timefunc' の戻り値と互換な数値型でなければいけません。
     同じ 'time' によってスケジュールされたイベントは、それらの
     'priority' によって実行されます。 数値の小さい方が高い優先度となり
     ます。

     イベントを実行することは、 ‘action(*argument, **kwargs)’ を実行する
     ことを意味します。 'argument' は 'action' のための位置引数を保持す
     るシーケンスでなければいけません。 'kwargs' は 'action' のためのキ
     ーワード引数を保持する辞書でなければいけません。

     戻り値は、後にイベントをキャンセルする時に使われる可能性のあるイベ
     ントです (*note cancel(): 189a. を参照)。

     バージョン 3.3 で変更: 'argument' 引数が任意になりました。

     バージョン 3.3 で変更: 'kwargs' 引数が追加されました。

 -- メソッド: scheduler.enter (delay, priority, action, argument=(),
          kwargs={})

     時間単位以上の 'delay' でイベントをスケジュールします。相対的時間以
     外の、引数、効果、戻り値は、 *note enterabs(): 10fc. に対するものと
     同じです。

     バージョン 3.3 で変更: 'argument' 引数が任意になりました。

     バージョン 3.3 で変更: 'kwargs' 引数が追加されました。

 -- メソッド: scheduler.cancel (event)

     キューからイベントを消去します。もし 'event' がキューにある現在のイ
     ベントでないならば、このメソッドは *note ValueError: 1e3. を送出し
     ます。

 -- メソッド: scheduler.empty ()

     もしイベントキューが空ならば、 ‘True’ を返します。

 -- メソッド: scheduler.run (blocking=True)

     すべてのスケジュールされたイベントを実行します。このメソッドは次の
     イベントを待ち、それを実行し、スケジュールされたイベントがなくなる
     まで同じことを繰り返します。(イベントの待機は、 コンストラクタへ渡
     された関数 'delayfunc' を使うことで行います。)

     'blocking' が False の場合、最も早く期限が来るスケジュールされたイ
     ベントを (存在する場合) 実行し、スケジューラ内で次にスケジュールさ
     れた呼び出しの期限を (存在する場合) 返します。

     'action' あるいは 'delayfunc' は例外を投げることができます。いずれ
     の場合も、スケジューラは一貫した状態を維持し、例外を伝播するでしょ
     う。例外が 'action' によって投げられる場合、イベントは *note run():
     10f9. への呼出しを未来に行なわないでしょう。

     イベントのシーケンスが、次イベントの前に、利用可能時間より実行時間
     が長いと、スケジューラは単に遅れることになるでしょう。イベントが落
     ちることはありません; 呼出しコードはもはや適切でないキャンセルイベ
     ントに対して責任があります。

     バージョン 3.3 で変更: 'blocking' 引数が追加されました。

 -- の属性: scheduler.queue

     読み出し専用の属性で、これから起こるイベントが実行される順序で格納
     されたリストを返します。各イベントは、次の属性 time, priority,
     action, argument, kwargs を持った *note named tuple: 61a. の形式に
     なります。


File: python.info,  Node: queue --- 同期キュークラス,  Next: contextvars --- コンテキスト変数,  Prev: sched --- イベントスケジューラー,  Up: 並行実行

5.17.8 ‘queue’ -- 同期キュークラス
----------------------------------

'ソースコード:' Lib/queue.py(1)

__________________________________________________________________

*note queue: a4. モジュールは、複数プロデューサ-複数コンシューマ
(multi-producer, multi-consumer)キューを実装します。これは、複数のスレッ
ドの間で情報を安全に交換しなければならないときのマルチスレッドプログラミ
ングで特に有益です。このモジュールの *note Queue: 1356. クラスは、必要な
すべてのロックセマンティクスを実装しています。

このモジュールでは3種類のキューが実装されています。それらはキューから取
り出されるエントリの順番だけが違います。 FIFO キューでは、最初に追加され
たエントリが最初に取り出されます。 LIFO キューでは、最後に追加されたエン
トリが最初に取り出されます(スタックのように振る舞います)。 優先順位付き
キュー(priority queue)では、エントリは(*note heapq: 5f. モジュールを利用
して)ソートされ、 最も低い値のエントリが最初に取り出されます。

内部的には、これらの3種類のキューは競争スレッドを一時的にブロックするた
めにロックを使っています; しかし、スレッド内での再入を扱うようには設計さ
れていません。

In addition, the module implements a "simple" FIFO queue type, *note
SimpleQueue: b38, whose specific implementation provides additional
guarantees in exchange for the smaller functionality.

*note queue: a4. モジュールは以下のクラスと例外を定義します:

 -- クラス: queue.Queue (maxsize=0)

     FIFO キューのコンストラクタです。 'maxsize' はキューに入れられる要
     素数の上限を設定する整数です。 いったんこの大きさに達したら、挿入処
     理はキューの要素が消費されるまでブロックされます。 'maxsize' が0以
     下の場合は、キューの大きさは無限です。

 -- クラス: queue.LifoQueue (maxsize=0)

     LIFO キューのコンストラクタです。 'maxsize' はキューに入れられる要
     素数の上限を設定する整数です。 いったんこの大きさに達したら、挿入処
     理はキューの要素が消費されるまでブロックされます。 'maxsize' が0以
     下の場合は、キューの大きさは無限です。

 -- クラス: queue.PriorityQueue (maxsize=0)

     優先順位付きキューのコンストラクタです。'maxsize' はキューに置くこ
     とのできる要素数の上限を設定する整数です。いったんこの大きさに達し
     たら、挿入はキューの要素が消費されるまでブロックされます。もし
     'maxsize' が0以下であるならば、キューの大きさは無限です。

     最小の値を持つ要素が最初に検索されます (最小の値を持つ値は、
     ‘min(entries)’ によって返されるものです)。典型的な要素のパターンは
     、‘(priority_number, data)’ 形式のタプルです。

     If the 'data' elements are not comparable, the data can be wrapped
     in a class that ignores the data item and only compares the
     priority number:

          from dataclasses import dataclass, field
          from typing import Any

          @dataclass(order=True)
          class PrioritizedItem:
              priority: int
              item: Any=field(compare=False)

 -- クラス: queue.SimpleQueue

     Constructor for an unbounded FIFO queue.  Simple queues lack
     advanced functionality such as task tracking.

     Added in version 3.7.

 -- 例外: queue.Empty

     空の *note Queue: 1356. オブジェクトで、非ブロックメソッド *note
     get(): 2c95. (または *note get_nowait(): 30ed.) が呼ばれたとき、送
     出される例外です。

 -- 例外: queue.Full

     満杯の *note Queue: 1356. オブジェクトで、非ブロックメソッド *note
     put(): 30ee. (または *note put_nowait(): 2c94.) が呼ばれたとき、送
     出される例外です。

 -- 例外: queue.ShutDown

     Exception raised when *note put(): 30ee. or *note get(): 2c95. is
     called on a *note Queue: 1356. object which has been shut down.

     Added in version 3.13.

* Menu:

* キューオブジェクト::
* SimpleQueue オブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/queue.py


File: python.info,  Node: キューオブジェクト,  Next: SimpleQueue オブジェクト,  Up: queue --- 同期キュークラス

5.17.8.1 キューオブジェクト
...........................

キューオブジェクト(*note Queue: 1356, *note LifoQueue: 21b4, *note
PriorityQueue: 21b5.)は、以下のpublicメソッドを提供しています。

 -- メソッド: Queue.qsize ()

     キューの近似サイズを返します。ここで、qsize() > 0 は後続の get() が
     ブロックしないことを保証しないこと、また qsize() < maxsize が put()
     がブロックしないことを保証しないことに注意してください。

 -- メソッド: Queue.empty ()

     キューが空の場合は ‘True’ を返し、そうでなければ ‘False’ を返します
     。empty() が ‘True’ を返しても、後続の put() の呼び出しがブロックし
     ないことは保証されません。同様に、empty() が ‘False’ を返しても、後
     続の get() の呼び出しがブロックしないことは保証されません。

 -- メソッド: Queue.full ()

     キューが一杯の場合は ‘True’ を返し、そうでなければ ‘False’ を返しま
     す。full() が ‘True’ を返しても、後続の get() の呼び出しがブロック
     しないことは保証されません。同様に、full() が ‘False’ を返しても、
     後続の put() の呼び出しがブロックしないことは保証されません。

 -- メソッド: Queue.put (item, block=True, timeout=None)

     'item' をキューに入れます。 もしオプション引数 'block' が真で
     'timeout' が ‘None’ (デフォルト) の場合は、必要であればフリースロッ
     トが利用可能になるまでブロックします。 'timeout' が正の数の場合は、
     最大で 'timeout' 秒間ブロックし、その時間内に空きスロットが利用可能
     にならなければ、例外 *note Full: 3001. を送出します。 そうでない場
     合 ('block' が偽) は、空きスロットが直ちに利用できるならば、キュー
     にアイテムを置きます。 できないならば、例外 *note Full: 3001. を送
     出します (この場合 'timeout' は無視されます)。

     Raises *note ShutDown: 21c. if the queue has been shut down.

 -- メソッド: Queue.put_nowait (item)

     ‘put(item, block=False)’ と等価です。

 -- メソッド: Queue.get (block=True, timeout=None)

     キューからアイテムを取り除き、それを返します。 オプション引数
     'block' が真で 'timeout' が ‘None’ (デフォルト) の場合は、必要であ
     ればアイテムが取り出せるようになるまでブロックします。 もし
     'timeout' が正の数の場合は、最大で 'timeout' 秒間ブロックし、その時
     間内でアイテムが取り出せるようにならなければ、例外 *note Empty:
     3000. を送出します。 そうでない場合 ('block' が偽) は、直ちにアイテ
     ムが取り出せるならば、それを返します。 できないならば、例外 *note
     Empty: 3000. を送出します (この場合 'timeout' は無視されます)。

     Prior to 3.0 on POSIX systems, and for all versions on Windows, if
     'block' is true and 'timeout' is ‘None’, this operation goes into
     an uninterruptible wait on an underlying lock.  This means that no
     exceptions can occur, and in particular a SIGINT will not trigger a
     *note KeyboardInterrupt: 99f.

     Raises *note ShutDown: 21c. if the queue has been shut down and is
     empty, or if the queue has been shut down immediately.

 -- メソッド: Queue.get_nowait ()

     ‘get(False)’ と等価です。

キューに入れられたタスクが全てコンシューマスレッドに処理されたかどうかを
追跡するために 2つのメソッドが提供されます。

 -- メソッド: Queue.task_done ()

     過去にキューに入れられたタスクが完了した事を示します。キューのコン
     シューマスレッドに利用されます。タスクの取り出しに使われた各 *note
     get(): 2c95. の後に *note task_done(): 2ffc. を呼び出すと、取り出し
     たタスクに対する処理が完了した事をキューに教えます。

     *note join(): 2ffd. がブロックされていた場合、全itemが処理された (キ
     ューに *note put(): 30ee. された全てのitemに対して *note
     task_done(): 2ffc. が呼び出されたことを意味します) 時に復帰します。

     ‘shutdown(immediate=True)’ calls *note task_done(): 2ffc. for each
     remaining item in the queue.

     キューにある要素より多く呼び出された場合 *note ValueError: 1e3. が
     発生します。

 -- メソッド: Queue.join ()

     キューにあるすべてのアイテムが取り出されて処理されるまでブロックし
     ます。

     未完了のタスクのカウント値はキューにアイテムが追加されるときは常に
     加算され、コンシューマースレッドが *note task_done(): 2ffc. を呼び
     出してアイテムの回収とその全処理の完了が示されるときは常に減算され
     ます。未完了のタスクのカウント値がゼロになった場合、*note join():
     2ffd. のブロックが解除されます。

キューに入れたタスクが完了するのを待つ例:

     import threading
     import queue

     q = queue.Queue()

     def worker():
         while True:
             item = q.get()
             print(f'Working on {item}')
             print(f'Finished {item}')
             q.task_done()

     # Turn-on the worker thread.
     threading.Thread(target=worker, daemon=True).start()

     # Send thirty task requests to the worker.
     for item in range(30):
         q.put(item)

     # Block until all tasks are done.
     q.join()
     print('All work completed')

* Menu:

* Terminating queues::


File: python.info,  Node: Terminating queues,  Up: キューオブジェクト

5.17.8.2 Terminating queues
...........................

*note Queue: 1356. objects can be made to prevent further interaction by
shutting them down.

 -- メソッド: Queue.shutdown (immediate=False)

     Shut down the queue, making *note get(): 2c95. and *note put():
     30ee. raise *note ShutDown: 21c.

     By default, *note get(): 2c95. on a shut down queue will only raise
     once the queue is empty.  Set 'immediate' to true to make *note
     get(): 2c95. raise immediately instead.

     All blocked callers of *note put(): 30ee. and *note get(): 2c95.
     will be unblocked.  If 'immediate' is true, a task will be marked
     as done for each remaining item in the queue, which may unblock
     callers of *note join(): 2ffd.

     Added in version 3.13.


File: python.info,  Node: SimpleQueue オブジェクト,  Prev: キューオブジェクト,  Up: queue --- 同期キュークラス

5.17.8.3 SimpleQueue オブジェクト
.................................

*note SimpleQueue: b38. オブジェクトは以下のpublicメソッドを提供していま
す。

 -- メソッド: SimpleQueue.qsize ()

     キューの近似サイズを返します。ここで、qsize() > 0 であるからといっ
     て、後続の get() の呼び出しがブロックしないことが保証されないことに
     注意してください。

 -- メソッド: SimpleQueue.empty ()

     キューが空の場合は ‘True’ を返し、そうでなければ ‘False’ を返します
     。 empty() が ‘False’ を返しても、後続の get() の呼び出しがブロック
     しないことは保証されません。

 -- メソッド: SimpleQueue.put (item, block=True, timeout=None)

     Put 'item' into the queue.  The method never blocks and always
     succeeds (except for potential low-level errors such as failure to
     allocate memory).  The optional args 'block' and 'timeout' are
     ignored and only provided for compatibility with *note Queue.put():
     30ee.

     'CPython 実装の詳細:' This method has a C implementation which is
     reentrant.  That is, a ‘put()’ or ‘get()’ call can be interrupted
     by another ‘put()’ call in the same thread without deadlocking or
     corrupting internal state inside the queue.  This makes it
     appropriate for use in destructors such as ‘__del__’ methods or
     *note weakref: fc. callbacks.

 -- メソッド: SimpleQueue.put_nowait (item)

     ‘put(item, block=False)’ と等価です。*note Queue.put_nowait():
     2c94. との互換性のためのメソッドです。

 -- メソッド: SimpleQueue.get (block=True, timeout=None)

     キューからアイテムを取り除き、それを返します。 オプション引数
     'block' が真で 'timeout' が ‘None’ (デフォルト) の場合は、必要であ
     ればアイテムが取り出せるようになるまでブロックします。 もし
     'timeout' が正の数の場合は、最大で 'timeout' 秒間ブロックし、その時
     間内でアイテムが取り出せるようにならなければ、例外 *note Empty:
     3000. を送出します。 そうでない場合 ('block' が偽) は、直ちにアイテ
     ムが取り出せるならば、それを返します。 できないならば、例外 *note
     Empty: 3000. を送出します (この場合 'timeout' は無視されます)。

 -- メソッド: SimpleQueue.get_nowait ()

     ‘get(False)’ と等価です。

参考
....

*note multiprocessing.Queue: 1767. クラス

     (マルチスレッドではなく) マルチプロセスの文脈で使用されるキュークラ
     ス。

*note collections.deque: 5a6. is an alternative implementation of
unbounded queues with fast atomic *note append(): 2461. and *note
popleft(): 2467. operations that do not require locking and also support
indexing.


File: python.info,  Node: contextvars --- コンテキスト変数,  Next: _thread --- 低水準なスレッド API,  Prev: queue --- 同期キュークラス,  Up: 並行実行

5.17.9 ‘contextvars’ -- コンテキスト変数
----------------------------------------

__________________________________________________________________

このモジュールは、コンテキストローカルな状態を管理し、保持し、アクセスす
るための API を提供します。 *note ContextVar: 30fe. クラスは 'コンテキス
ト変数' を宣言し、取り扱うために使われます。 非同期フレームワークで現時
点のコンテキストを管理するのには、 *note copy_context(): 30ff. 関数と
*note Context: 150d. クラスを使うべきです。

Context managers that have state should use Context Variables instead of
*note threading.local(): 16d6. to prevent their state from bleeding to
other code unexpectedly, when used in concurrent code.

より詳しくは PEP 567(1) を参照をしてください。

Added in version 3.7.

* Menu:

* コンテキスト変数::
* マニュアルでのコンテキスト管理::
* asyncio サポート::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0567/


File: python.info,  Node: コンテキスト変数,  Next: マニュアルでのコンテキスト管理,  Up: contextvars --- コンテキスト変数

5.17.9.1 コンテキスト変数
.........................

 -- クラス: contextvars.ContextVar (name[, *, default])

     このクラスは新しいコンテキスト変数を宣言するのに使われます。例えば
     、次の通りです:

          var: ContextVar[int] = ContextVar('var', default=42)

     必須のパラメータの 'name' は内観やデバッグの目的で使われます。

     オプションのキーワード専用引数 'default' は、現在のコンテキストにそ
     の変数の値が見付からなかったときに *note ContextVar.get(): 3101. か
     ら返されます。

     '重要:' コンテキスト変数は、モジュールのトップレベルで生成する必要
     があり、クロージャの中で作成すべきではありません。*note Context:
     150d. オブジェクトはコンテキスト変数への強参照を持っており、コンテ
     キスト変数がガーベジコレクトされるのを防ぎます。

      -- の属性: name

          変数の名前。読み出し専用のプロパティです。

          Added in version 3.7.1.

      -- メソッド: get ([default])

          現在のコンテキストのコンテキスト変数の値を返します。

          現在のコンテキストのコンテキスト変数に値がなければ、メソッドは
          :

             * メソッドの 'default' 引数に値が指定されていればその値を返
               します。さもなければ

             * コンテキスト変数が生成された時にデフォルト値が渡されてい
               れば、その値を返します。さもなければ

             * *note LookupError: 2131. を送出します。

      -- メソッド: set (value)

          現在のコンテキストのコンテキスト変数に新しい値を設定する際に呼
          び出します。

          'value' は必須の引数で、コンテキスト変数の新しい値を指定します
          。

          *note Token: 3104. オブジェクトを返します。このオブジェクトを
          *note ContextVar.reset(): 3105. メソッドに渡すことで、以前の値
          に戻すことができます。

      -- メソッド: reset (token)

          コンテキスト変数の値を、 'token' を生成した *note
          ContextVar.set(): 3103. が呼び出される前の値にリセットします。

          例えば:

               var = ContextVar('var')

               token = var.set('new value')
               # code that uses 'var'; var.get() returns 'new value'.
               var.reset(token)

               # After the reset call the var has no value again, so
               # var.get() would raise a LookupError.

 -- クラス: contextvars.Token

     'Token' オブジェクトは、*note ContextVar.set(): 3103. メソッドによ
     って返されるオブジェクトです。このオブジェクトを *note
     ContextVar.reset(): 3105. メソッドに渡すことで、対応する 'set' を呼
     び出す前のコンテキスト変数の値に戻せます。

      -- の属性: var

          読み出し専用のプロパティです。トークンを生成した *note
          ContextVar: 30fe. オブジェクトを指します。

      -- の属性: old_value

          読み出し専用のプロパティです。このトークンを作成した *note
          ContextVar.set(): 3103. メソッドの呼び出しの前に持っていた値に
          設定されています。もし呼び出しの前に値が設定されていなければ
          *note Token.MISSING: 3108. を指します。

      -- の属性: MISSING

          *note Token.old_value: 3107. で利用されるマーカーオブジェクト
          です。


File: python.info,  Node: マニュアルでのコンテキスト管理,  Next: asyncio サポート,  Prev: コンテキスト変数,  Up: contextvars --- コンテキスト変数

5.17.9.2 マニュアルでのコンテキスト管理
.......................................

 -- の関数: contextvars.copy_context ()

     現在の *note Context: 150d. オブジェクトのコピーを返します。

     次のスニペットは、現在のコンテキストのコピーを取得し、コンテキスト
     に設定されているすべての変数とその値を表示します:

          ctx: Context = copy_context()
          print(list(ctx.items()))

     この関数の複雑性は 'O'(1) です。つまり、少数のコンテキスト変数を持
     つコンテキストと多くの変数を持つコンテキストで同程度の速度で動作し
     ます。

 -- クラス: contextvars.Context

     ‘ContextVars’ とその値の対応付け。

     ‘Context()’ は、値を持たない空のコンテキストを生成します。現在のコ
     ンテキストのコピーを得るには、*note copy_context(): 30ff. 関数を利
     用します。

     Each thread has its own effective stack of ‘Context’ objects.  The
     *note current context: 1516. is the ‘Context’ object at the top of
     the current thread's stack.  All ‘Context’ objects in the stacks
     are considered to be 'entered'.

     'Entering' a context, which can be done by calling its *note run():
     156a. method, makes the context the current context by pushing it
     onto the top of the current thread's context stack.

     'Exiting' from the current context, which can be done by returning
     from the callback passed to the *note run(): 156a. 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.

     Since each thread has its own context stack, *note ContextVar:
     30fe. objects behave in a similar fashion to *note
     threading.local(): 16d6. when values are assigned in different
     threads.

     Attempting to enter an already entered context, including contexts
     entered in other threads, raises a *note RuntimeError: 17a.

     After exiting a context, it can later be re-entered (from any
     thread).

     Any changes to *note ContextVar: 30fe. values via the *note
     ContextVar.set(): 3103. method are recorded in the current context.
     The *note ContextVar.get(): 3101. method returns the value
     associated with the current context.  Exiting a context effectively
     reverts any changes made to context variables while the context was
     entered (if needed, the values can be restored by re-entering the
     context).

     Context は、 *note collections.abc.Mapping: 898. インターフェースを
     実装します。

      -- メソッド: run (callable, *args, **kwargs)

          Enters the Context, executes ‘callable(*args, **kwargs)’, then
          exits the Context.  Returns 'callable"s return value, or
          propagates an exception if one occurred.

          例:

               import contextvars

               var = contextvars.ContextVar('var')
               var.set('spam')
               print(var.get())  # 'spam'

               ctx = contextvars.copy_context()

               def main():
                   # 'var' was set to 'spam' before
                   # calling 'copy_context()' and 'ctx.run(main)', so:
                   print(var.get())  # 'spam'
                   print(ctx[var])  # 'spam'

                   var.set('ham')

                   # Now, after setting 'var' to 'ham':
                   print(var.get())  # 'ham'
                   print(ctx[var])  # 'ham'

               # Any changes that the 'main' function makes to 'var'
               # will be contained in 'ctx'.
               ctx.run(main)

               # The 'main()' function was run in the 'ctx' context,
               # so changes to 'var' are contained in it:
               print(ctx[var])  # 'ham'

               # However, outside of 'ctx', 'var' is still set to 'spam':
               print(var.get())  # 'spam'

      -- メソッド: copy ()

          コンテキストオブジェクトの浅いコピーを返します。

      -- Describe: var in context

          'context' に 'var' の値が設定されていた場合 ‘True’ を返します;
          そうでない場合は ‘False’ を返します。

      -- Describe: context[var]

          *note ContextVar: 30fe. 'var' の値を返します。コンテキストオブ
          ジェクト内で変数が設定されていない場合は、*note KeyError: 31d.
          を送出します。

      -- メソッド: get (var[, default])

          'var' がコンテキストオブジェクトの中に値を持てば、その値を返し
          ます。さもなければ、'default' を返します。'default' を指定して
          いなければ、‘None’ を返します。

      -- Describe: iter(context)

          コンテキストオブジェクトに格納されている変数群のイテレータを返
          します。

      -- Describe: len(proxy)

          コンテキストオブジェクトに格納されている変数の数を返します。

      -- メソッド: keys ()

          コンテキストオブジェクト中のすべての変数のリストを返します。

      -- メソッド: values ()

          コンテキストオブジェクト中のすべての変数の値のリストを返します
          。

      -- メソッド: items ()

          コンテキストオブジェクト中のすべての変数について、変数とその値
          からなる2要素のタプルのリストを返します。


File: python.info,  Node: asyncio サポート,  Prev: マニュアルでのコンテキスト管理,  Up: contextvars --- コンテキスト変数

5.17.9.3 asyncio サポート
.........................

コンテキスト変数は、追加の設定なしに *note asyncio: 8. をサポートします
。例えば、次の単純なechoサーバーは、クライアントを扱う Task の中でリモー
トクライアントのアドレスが利用できるように、コンテキスト変数を利用します
:

     import asyncio
     import contextvars

     client_addr_var = contextvars.ContextVar('client_addr')

     def render_goodbye():
         # The address of the currently handled client can be accessed
         # without passing it explicitly to this function.

         client_addr = client_addr_var.get()
         return f'Good bye, client @ {client_addr}\r\n'.encode()

     async def handle_request(reader, writer):
         addr = writer.transport.get_extra_info('socket').getpeername()
         client_addr_var.set(addr)

         # In any code that we call is now possible to get
         # client's address by calling 'client_addr_var.get()'.

         while True:
             line = await reader.readline()
             print(line)
             if not line.strip():
                 break

         writer.write(b'HTTP/1.1 200 OK\r\n')  # status line
         writer.write(b'\r\n')  # headers
         writer.write(render_goodbye())  # body
         writer.close()

     async def main():
         srv = await asyncio.start_server(
             handle_request, '127.0.0.1', 8081)

         async with srv:
             await srv.serve_forever()

     asyncio.run(main())

     # To test it you can use telnet or curl:
     #     telnet 127.0.0.1 8081
     #     curl 127.0.0.1:8081

以下のモジュールは上記のサービスの一部で使われるサポートモジュールです:


File: python.info,  Node: _thread --- 低水準なスレッド API,  Prev: contextvars --- コンテキスト変数,  Up: 並行実行

5.17.10 ‘_thread’ -- 低水準なスレッド API
-----------------------------------------

__________________________________________________________________

このモジュールはマルチスレッド (別名 '軽量プロセス' ('light-weight
processes')または 'タスク' ('tasks')) に用いられる低水準プリミティブを提
供します -- グローバルデータ空間を共有するマルチスレッドを制御します。同
期のための単純なロック (別名 'mutexes' またはバイナリセマフォ ('binary
semaphores'))が提供されています。 *note threading: d6. モジュールは、こ
のモジュール上で、より使い易く高級なスレッディングの API を提供します。

バージョン 3.7 で変更: このモジュールは以前はオプションでしたが、常に利
用可能なモジュールとなりました。

このモジュールでは以下の定数および関数を定義しています:

 -- 例外: _thread.error

     スレッド固有の例外です。

     バージョン 3.3 で変更: 現在は組み込みの *note RuntimeError: 17a. の
     別名です。

 -- データ: _thread.LockType

     これはロックオブジェクトのタイプです。

 -- の関数: _thread.start_new_thread (function, args[, kwargs])

     新しいスレッドを開始して、そのIDを返します。スレッドは引数リスト
     'args' (タプルでなければなりません)の関数 'function' を実行します。
     オプション引数 'kwargs' はキーワード引数の辞書を指定します。

     関数が戻るとき、スレッドは静かに終了します。

     When the function terminates with an unhandled exception, *note
     sys.unraisablehook(): 1d8. 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).

     When the function raises a *note SystemExit: d0e. exception, it is
     silently ignored.

     Raises an *note auditing event: 1825. ‘_thread.start_new_thread’
     with arguments ‘function’, ‘args’, ‘kwargs’.

     バージョン 3.8 で変更: *note sys.unraisablehook(): 1d8. is now used
     to handle unhandled exceptions.

 -- の関数: _thread.interrupt_main (signum=signal.SIGINT, /)

     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.

     If given, 'signum' is the number of the signal to simulate.  If
     'signum' is not given, *note signal.SIGINT: 80f. is simulated.

     If the given signal isn't handled by Python (it was set to *note
     signal.SIG_DFL: 178c. or *note signal.SIG_IGN: 178b.), this
     function does nothing.

     バージョン 3.10 で変更: The 'signum' argument is added to customize
     the signal number.

          注釈: 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 *note
          signal.raise_signal(): 176d.

 -- の関数: _thread.exit ()

     *note SystemExit: d0e. を送出します。それが捕えられないときは、静か
     にスレッドを終了させます。

 -- の関数: _thread.allocate_lock ()

     新しいロックオブジェクトを返します。ロックのメソッドはこの後に記述
     されます。ロックは初期状態としてアンロック状態です。

 -- の関数: _thread.get_ident ()

     現在のスレッドの 'スレッドID' を返します。非ゼロの整数です。この値
     は直接の意味を持っていません; 例えばスレッド特有のデータの辞書に索
     引をつけるためのような、マジッククッキーとして意図されています。ス
     レッドが終了し、他のスレッドが作られたとき、スレッド ID は再利用さ
     れるかもしれません。

 -- の関数: _thread.get_native_id ()

     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).

     *note Availability: 1cbe.: Windows, FreeBSD, Linux, macOS, OpenBSD,
     NetBSD, AIX, DragonFlyBSD, GNU/kFreeBSD.

     Added in version 3.8.

     バージョン 3.13 で変更: Added support for GNU/kFreeBSD.

 -- の関数: _thread.stack_size ([size])

     新しいスレッドを作るときのスレッドスタックサイズを返します。オプシ
     ョンの 'size' 引数にはこれ以降に作成するスレッドのスタックサイズを
     指定し、0 (プラットフォームのデフォルト値または設定されたデフォルト
     値) か、 32,768 (32 KiB) 以上の正の整数でなければなりません。'size'
     が指定されない場合 0 が使われます。スレッドのスタックサイズの変更が
     サポートされていない場合、 *note RuntimeError: 17a. を送出します。
     不正なスタックサイズが指定された場合、 *note ValueError: 1e3. を送
     出して、スタックサイズは変更されません。32 KiB は現在のインタープリ
     タ自身のために十分であると保証された最小のスタックサイズです。いく
     つかのプラットフォームではスタックサイズに対して制限があることに注
     意してください。例えば最小のスタックサイズが 32 KiB より大きかった
     り、システムのメモリページサイズ の整数倍の必要があるなどです。この
     制限についてはプラットフォームのドキュメントを参照してください (一
     般的なページサイズは 4 KiB なので、プラットフォームに関する情報がな
     い場合は 4096 の整数倍のスタックサイズを選ぶといいかもしれません)。

     *note Availability: 1cbe.: Windows, pthreads.

     Unix platforms with POSIX threads support.

 -- データ: _thread.TIMEOUT_MAX

     The maximum value allowed for the 'timeout' parameter of *note
     Lock.acquire: 664.  Specifying a timeout greater than this value
     will raise an *note OverflowError: 84e.

     Added in version 3.2.

ロックオブジェクトは次のようなメソッドを持っています:

 -- メソッド: lock.acquire (blocking=True, timeout=-1)

     オプションの引数なしで使用すると、このメソッドは他のスレッドがロッ
     クしているかどうかにかかわらずロックを獲得します。ただし、他のスレ
     ッドがすでにロックしている場合には解除されるまで待ってからロックを
     獲得します (同時にロックを獲得できるスレッドはひとつだけであり、こ
     れこそがロックの存在理由です)。

     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.

     If the floating-point 'timeout' argument is present and positive,
     it specifies the maximum wait time in seconds before returning.  A
     negative 'timeout' argument specifies an unbounded wait.  You
     cannot specify a 'timeout' if 'blocking' is false.

     なお、ロックを獲得できた場合は ‘True’、できなかった場合は ‘False’ を
     返します。

     バージョン 3.2 で変更: 新しい 'timeout' 引数。

     バージョン 3.2 で変更: POSIX ではロックの取得がシグナルに割り込まれ
     るようになりました。

 -- メソッド: lock.release ()

     ロックを解放します。そのロックは既に獲得されたものでなければなりま
     せんが、しかし同じスレッドによって獲得されたものである必要はありま
     せん。

 -- メソッド: lock.locked ()

     ロックの状態を返します: 同じスレッドによって獲得されたものなら
     ‘True’ 、違うのなら ‘False’ を返します。

これらのメソッドに加えて、ロックオブジェクトは *note with: 59c. 文を通じ
て以下の例のように使うこともできます。

     import _thread

     a_lock = _thread.allocate_lock()

     with a_lock:
         print("a_lock is locked while this executes")

'警告:'

   * Interrupts always go to the main thread (the *note
     KeyboardInterrupt: 99f. exception will be received by that thread.)

   * *note sys.exit(): 1318. を呼び出す、あるいは *note SystemExit: d0e.
     例外を送出することは、 *note _thread.exit(): 3114. を呼び出すことと
     同じです。

   * It is platform-dependent whether the *note acquire(): 664. method
     on a lock can be interrupted (so that the *note KeyboardInterrupt:
     99f. exception will happen immediately, rather than only after the
     lock has been acquired or the operation has timed out).  It can be
     interrupted on POSIX, but not on Windows.

   * メインスレッドが終了したとき、他のスレッドが生き残るかどうかは、シ
     ステムに依存します。多くのシステムでは、 *note try: 6b4. ...  *note
     finally: 997. 節や、オブジェクトデストラクタを実行せずに終了されま
     す。


File: python.info,  Node: ネットワーク通信とプロセス間通信,  Next: インターネット上のデータの操作,  Prev: 並行実行,  Up: Python 標準ライブラリ

5.18 ネットワーク通信とプロセス間通信
=====================================

この章で解説しているモジュールはネットワーク通信とプロセス間通信の仕組み
を提供しています。

例えば *note signal: b4. や *note mmap: 83. のように、同じマシン上の 2 つ
のプロセスでしか使えないモジュールがあります。その他のモジュールは 2 つ
以上のプロセスを使ってマシン間で通信できるネットワークプロトコルをサポー
トします。

この章で解説されるモジュールのリスト:

* Menu:

* asyncio: asyncio --- 非同期 I/O. 非同期 I/O
* socket: socket --- 低水準ネットワークインターフェース. 低水準ネットワークインターフェース
* ssl: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー. ソケットオブジェクト用の TLS/SSL ラッパー
* select: select --- I/O 完了の待機. I/O 完了の待機
* selectors: selectors --- 高水準の I/O 多重化. 高水準の I/O 多重化
* signal: signal --- 非同期イベントにハンドラーを設定する. 非同期イベントにハンドラーを設定する
* mmap: mmap --- メモリマップファイルのサポート. メモリマップファイルのサポート


File: python.info,  Node: asyncio --- 非同期 I/O,  Next: socket --- 低水準ネットワークインターフェース,  Up: ネットワーク通信とプロセス間通信

5.18.1 ‘asyncio’ -- 非同期 I/O
------------------------------

__________________________________________________________________

Hello World!
............

     import asyncio

     async def main():
         print('Hello ...')
         await asyncio.sleep(1)
         print('... World!')

     asyncio.run(main())

asyncio は 'async/await' 構文を使い '並行処理の' コードを書くためのライ
ブラリです。

asyncio は、高性能なネットワークとウェブサーバ、データベース接続ライブラ
リ、分散タスクキューなどの複数の非同期 Python フレームワークの基盤として
使われています。

asyncio は多くの場合、 IOバウンドだったり高レベルの '構造化された' ネッ
トワークコードに完璧に適しています。

asyncio は次の目的で '高レベル' API を提供しています:

   * 並行に *note Python コルーチンを起動: 3122. し、実行全体を管理する

   * *note ネットワーク IO と IPC: 3123. を執り行う

   * *note subprocesses: 3124. を管理する

   * *note キュー: 3125. を使ってタスクを分散する

   * 並列処理のコードを *note 同期: 3126. させる

これに加えて、 'ライブラリやフレームワークの開発者' が次のことをするため
の '低レベル' API があります:

   * *note ネットワーク通信: 3127. 、 *note サブプロセス: 3128. の実行、
     *note OS シグナル: 3129. の取り扱いなどのための非同期 API を提供す
     る *note イベントループ: d46. の作成と管理を行う

   * *note Transport: 312a. を使った効率的な protocol を実装します

   * コールバックを用いたライブラリと async/await 構文を使ったコードの
     *note 橋渡し: 312b.

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

asyncio REPL
............

You can experiment with an ‘asyncio’ concurrent context in the *note
REPL: 150.:

     $ python -m asyncio
     asyncio REPL ...
     Use "await" directly instead of "asyncio.run()".
     Type "help", "copyright", "credits" or "license" for more information.
     >>> import asyncio
     >>> await asyncio.sleep(10, result='hello')
     'hello'

引数無しで *note 監査イベント: 1825. ‘cpython.run_stdin’ を送出します。

バージョン 3.12.5 で変更: (also 3.11.10, 3.10.15, 3.9.20, and 3.8.20)
Emits audit events.

バージョン 3.13 で変更: Uses PyREPL if possible, in which case *note
PYTHONSTARTUP: f95. is also executed.  Emits audit events.

リファレンス
............

* Menu:

* Runners::
* コルーチンと Task::
* ストリーム::
* 同期プリミティブ: 同期プリミティブ<2>.
* サブプロセス::
* キュー::
* 例外: 例外<12>.
* イベントループ::
* Future::
* トランスポートとプロトコル::
* ポリシー::
* プラットフォームでのサポート::
* Extending::
* 高水準の API インデックス::
* 低水準の API インデックス::
* asyncio での開発::


File: python.info,  Node: Runners,  Next: コルーチンと Task,  Up: asyncio --- 非同期 I/O

5.18.1.1 Runners
................

'Source code:' Lib/asyncio/runners.py(1)

この節では、asyncio のコードを実行するための高レベルの asyncio のプリミ
ティブの概略を解説します。

これらは *note イベントループ: d46. の上に構築されており、一般的な広く普
及しているシナリオでの非同期コードの使用を簡素化することを目的としていま
す。

* Menu:

* 非同期プログラムの実行::
* Runner context manager::
* Handling Keyboard Interruption::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/runners.py


File: python.info,  Node: 非同期プログラムの実行,  Next: Runner context manager,  Up: Runners

5.18.1.2 非同期プログラムの実行
...............................

 -- の関数: asyncio.run (coro, *, debug=None, loop_factory=None)

     *note coroutine: 45e. 'coro' を実行し、結果を返します。

     This function runs the passed coroutine, taking care of managing
     the asyncio event loop, 'finalizing asynchronous generators', and
     closing the executor.

     この関数は、同じスレッドで他の非同期イベントループが実行中のときは
     呼び出せません。

     'debug' が ‘True’ の場合、イベントループはデバッグモードで実行され
     ます。‘False’ は明示的にデバッグモードを無効化します。 グローバルな
     *note デバッグモード: 1cb9. 設定を尊重するために ‘None’ が使用され
     ます。

     If 'loop_factory' is not ‘None’, it is used to create a new event
     loop; otherwise *note asyncio.new_event_loop(): 3130. is used.  The
     loop is closed at the end.  This function should be used as a main
     entry point for asyncio programs, and should ideally only be called
     once.  It is recommended to use 'loop_factory' to configure the
     event loop instead of policies.  Passing *note asyncio.EventLoop:
     165b. allows running asyncio without the policy system.

     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.

     以下はプログラム例です:

          async def main():
              await asyncio.sleep(1)
              print('hello')

          asyncio.run(main())

     Added in version 3.7.

     バージョン 3.9 で変更: *note loop.shutdown_default_executor(): 8b5.
     メソッドを使うように更新されました。

     バージョン 3.10 で変更: 'debug' はグローバルなデバッグモード設定を
     尊重するためにデフォルトで ‘None’ です。

     バージョン 3.12 で変更: Added 'loop_factory' parameter.


File: python.info,  Node: Runner context manager,  Next: Handling Keyboard Interruption,  Prev: 非同期プログラムの実行,  Up: Runners

5.18.1.3 Runner context manager
...............................

 -- クラス: asyncio.Runner (*, debug=None, loop_factory=None)

     同じコンテキスト上での '複数' の非同期関数呼び出しをシンプルにする
     コンテキストマネージャ。

     Sometimes several top-level async functions should be called in the
     same *note event loop: d46. and *note contextvars.Context: 150d.

     'debug' が ‘True’ の場合、イベントループはデバッグモードで実行され
     ます。‘False’ は明示的にデバッグモードを無効化します。 グローバルな
     *note デバッグモード: 1cb9. 設定を尊重するために ‘None’ が使用され
     ます。

     '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 *note asyncio.new_event_loop():
     3130. is used and set as current event loop with *note
     asyncio.set_event_loop(): 1735. if 'loop_factory' is ‘None’.

     Basically, *note asyncio.run(): 449. example can be rewritten with
     the runner usage:

          async def main():
              await asyncio.sleep(1)
              print('hello')

          with asyncio.Runner() as runner:
              runner.run(main())

     Added in version 3.11.

      -- メソッド: run (coro, *, context=None)

          Run a *note coroutine: 45e. 'coro' in the embedded loop.

          Return the coroutine's result or raise its exception.

          An optional keyword-only 'context' argument allows specifying
          a custom *note contextvars.Context: 150d. for the 'coro' to
          run in.  The runner's default context is used if ‘None’.

          この関数は、同じスレッドで他の非同期イベントループが実行中のと
          きは呼び出せません。

      -- メソッド: close ()

          Close the runner.

          Finalize asynchronous generators, shutdown default executor,
          close the event loop and release embedded *note
          contextvars.Context: 150d.

      -- メソッド: get_loop ()

          Return the event loop associated with the runner instance.

          注釈: *note Runner: 5cb. uses the lazy initialization
          strategy, its constructor doesn't initialize underlying
          low-level structures.

          Embedded 'loop' and 'context' are created at the *note with:
          59c. body entering or the first call of *note run(): 449. or
          *note get_loop(): 3133.


File: python.info,  Node: Handling Keyboard Interruption,  Prev: Runner context manager,  Up: Runners

5.18.1.4 Handling Keyboard Interruption
.......................................

Added in version 3.11.

When *note signal.SIGINT: 80f. is raised by ‘Ctrl-C’, *note
KeyboardInterrupt: 99f. exception is raised in the main thread by
default.  However this doesn't work with *note asyncio: 8. because it
can interrupt asyncio internals and can hang the program from exiting.

To mitigate this issue, *note asyncio: 8. handles *note signal.SIGINT:
80f. as follows:

  1. *note asyncio.Runner.run(): 1611. installs a custom *note
     signal.SIGINT: 80f. handler before any user code is executed and
     removes it when exiting from the function.

  2. The *note Runner: 5cb. creates the main task for the passed
     coroutine for its execution.

  3. When *note signal.SIGINT: 80f. is raised by ‘Ctrl-C’, the custom
     signal handler cancels the main task by calling *note
     asyncio.Task.cancel(): 19c. which raises *note
     asyncio.CancelledError: 19d. inside the main task.  This causes the
     Python stack to unwind, ‘try/except’ and ‘try/finally’ blocks can
     be used for resource cleanup.  After the main task is cancelled,
     *note asyncio.Runner.run(): 1611. raises *note KeyboardInterrupt:
     99f.

  4. A user could write a tight loop which cannot be interrupted by
     *note asyncio.Task.cancel(): 19c, in which case the second
     following ‘Ctrl-C’ immediately raises the *note KeyboardInterrupt:
     99f. without cancelling the main task.


File: python.info,  Node: コルーチンと Task,  Next: ストリーム,  Prev: Runners,  Up: asyncio --- 非同期 I/O

5.18.1.5 コルーチンと Task
..........................

この節では、コルーチンと Task を利用する高レベルの asyncio の API の概略
を解説します。

* Menu:

* コルーチン: コルーチン<3>.
* Awaitable::
* Task の作成::
* タスクのキャンセル::
* Task Groups::
* スリープ::
* 並行な Task 実行::
* Eager Task Factory::
* キャンセルからの保護::
* タイムアウト::
* 要素の終了待機::
* スレッド内での実行::
* 外部スレッドからのスケジュール::
* イントロスペクション::
* Task オブジェクト::


File: python.info,  Node: コルーチン<3>,  Next: Awaitable,  Up: コルーチンと Task

5.18.1.6 コルーチン
...................

'Source code:' Lib/asyncio/coroutines.py(1)

__________________________________________________________________

async/await 構文で宣言された *note コルーチン: 45e. は、 asyncio を使っ
たアプリケーションを書くのに推奨される方法です。例えば、次のコードスニペ
ットは "hello" を出力し、そこから 1 秒待って "world" を出力します:

     >>> import asyncio

     >>> async def main():
     ...     print('hello')
     ...     await asyncio.sleep(1)
     ...     print('world')

     >>> asyncio.run(main())
     hello
     world

単にコルーチンを呼び出しただけでは、コルーチンの実行スケジュールは予約さ
れていないことに注意してください:

     >>> main()
     <coroutine object main at 0x1053bb7c8>

実際にコルーチンを実行するために、asyncio は以下のメカニズムを提供してい
ます:

   * 最上位のエントリーポイントである "main()" 関数を実行する *note
     asyncio.run(): 449. 関数 (上の例を参照してください。)

   * コルーチンを await すること。次のコード片は 1 秒間待機した後に
     "hello" と出力し、 '更に' 2 秒間待機してから "world" と出力します:

          import asyncio
          import time

          async def say_after(delay, what):
              await asyncio.sleep(delay)
              print(what)

          async def main():
              print(f"started at {time.strftime('%X')}")

              await say_after(1, 'hello')
              await say_after(2, 'world')

              print(f"finished at {time.strftime('%X')}")

          asyncio.run(main())

     予想される出力:

          started at 17:13:52
          hello
          world
          finished at 17:13:55

   * asyncio の *note Tasks: 4a5. としてコルーチンを並行して走らせる
     *note asyncio.create_task(): 5c7. 関数。

     上のコード例を編集して、ふたつの ‘say_after’ コルーチンを '並行して
     ' 走らせてみましょう:

          async def main():
              task1 = asyncio.create_task(
                  say_after(1, 'hello'))

              task2 = asyncio.create_task(
                  say_after(2, 'world'))

              print(f"started at {time.strftime('%X')}")

              # Wait until both tasks are completed (should take
              # around 2 seconds.)
              await task1
              await task2

              print(f"finished at {time.strftime('%X')}")

     予想される出力が、スニペットの実行が前回よりも 1 秒早いことを示して
     いることに注意してください:

          started at 17:14:32
          hello
          world
          finished at 17:14:34

   * The *note asyncio.TaskGroup: 19a. class provides a more modern
     alternative to *note create_task(): 5c7.  Using this API, the last
     example becomes:

          async def main():
              async with asyncio.TaskGroup() as tg:
                  task1 = tg.create_task(
                      say_after(1, 'hello'))

                  task2 = tg.create_task(
                      say_after(2, 'world'))

                  print(f"started at {time.strftime('%X')}")

              # The await is implicit when the context manager exits.

              print(f"finished at {time.strftime('%X')}")

     The timing and output should be the same as for the previous
     version.

     Added in version 3.11: *note asyncio.TaskGroup: 19a.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/coroutines.py


File: python.info,  Node: Awaitable,  Next: Task の作成,  Prev: コルーチン<3>,  Up: コルーチンと Task

5.18.1.7 Awaitable
..................

あるオブジェクトを *note await: 19e. 式の中で使うことができる場合、その
オブジェクトを 'awaitable' オブジェクトと言います。多くの asyncio API は
awaitable を受け取るように設計されています。

'awaitable' オブジェクトには主に3つの種類があります: 'コルーチン',
'Task', そして 'Future' です

コルーチン
..........

Python のコルーチンは 'awaitable' であり、他のコルーチンから待機されるこ
とができます:

     import asyncio

     async def nested():
         return 42

     async def main():
         # Nothing happens if we just call "nested()".
         # A coroutine object is created but not awaited,
         # so it *won't run at all*.
         nested()  # will raise a "RuntimeWarning".

         # Let's do it differently now and await it:
         print(await nested())  # will print "42".

     asyncio.run(main())

     重要: このドキュメントにおいて「コルーチン」という用語は以下2つの密
     接に関連した概念に対して使用できます:

        * 'コルーチン関数': *note async def: 59b. 関数;

        * 'コルーチンオブジェクト': 'コルーチン関数' を呼び出すと返って
          くるオブジェクト.

Task
....

'Task' は、コルーチンを '並行に' スケジュールするのに使います。

*note asyncio.create_task(): 5c7. のような関数で、コルーチンが 'Task' に
ラップされているとき、自動的にコルーチンは即時実行されるようにスケジュー
ルされます:

     import asyncio

     async def nested():
         return 42

     async def main():
         # Schedule nested() to run soon concurrently
         # with "main()".
         task = asyncio.create_task(nested())

         # "task" can now be used to cancel "nested()", or
         # can simply be awaited to wait until it is complete:
         await task

     asyncio.run(main())

Future
......

*note Future: b9b. は、非同期処理の '最終結果' を表現する特別な '低レベ
ルの' awaitable オブジェクトです。

Future オブジェクトが '待機 (await) されている' とは、Future がどこか他
の場所で解決されるまでコルーチンが待機するということです。

asyncioのFutureオブジェクトを使うと、async/awaitとコールバック形式のコー
ドを併用できます。

通常、アプリケーション水準のコードで Future オブジェクトを作る '必要はあ
りません' 。

Future オブジェクトはライブラリや asyncio のAPIで外部に提供されることも
あり、await （待機）されることができます:

     async def main():
         await function_that_returns_a_future_object()

         # this is also valid:
         await asyncio.gather(
             function_that_returns_a_future_object(),
             some_python_coroutine()
         )

Future オブジェクトを返す低レベル関数の良い例は *note
loop.run_in_executor(): 8b7. です。


File: python.info,  Node: Task の作成,  Next: タスクのキャンセル,  Prev: Awaitable,  Up: コルーチンと Task

5.18.1.8 Task の作成
....................

'ソースコード:' Lib/asyncio/tasks.py(1)

__________________________________________________________________

 -- の関数: asyncio.create_task (coro, *, name=None, context=None)

     'coro' *note coroutine: 3122. を *note Task: 4a5. でラップし、その
     実行をスケジュールします。 Task オブジェクトを返します。

     もし 'name' が ‘None’ でない場合、*note Task.set_name(): 9ab. を使
     用し、'name' がタスクの名前として設定されます。

     省略可能なキーワード引数 'context' によって、'coro' を実行するため
     のカスタムの *note contextvars.Context: 150d. を指定できます。
     'context' が省略された場合、現在のコンテキストのコピーが作成されま
     す。

     その Task オブジェクトは *note get_running_loop(): ad9. から返され
     たループの中で実行されます。現在のスレッドに実行中のループが無い場
     合は、 *note RuntimeError: 17a. が送出されます。

          注釈: *note asyncio.TaskGroup.create_task(): 1a1. is a new
          alternative leveraging structural concurrency; it allows for
          waiting for a group of related tasks with strong safety
          guarantees.

          重要: タスクが実行中に消えないように、この関数の結果の参照を保
          存してください。イベントループは弱い参照のみを保持します。ほか
          に参照元のないタスクは、完了していなくてもガーベジコレクション
          される可能性があります。信頼性のある "fire-and-forget" バック
          グラウンドタスクが必要な場合、コレクションを使ってください。

               background_tasks = set()

               for i in range(10):
                   task = asyncio.create_task(some_coro(param=i))

                   # Add task to the set. This creates a strong reference.
                   background_tasks.add(task)

                   # To prevent keeping references to finished tasks forever,
                   # make each task remove its own reference from the set after
                   # completion:
                   task.add_done_callback(background_tasks.discard)

     Added in version 3.7.

     バージョン 3.8 で変更: 'name' パラメータを追加しました。

     バージョン 3.11 で変更: 'context' パラメータを追加しました。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/asyncio/tasks.py


File: python.info,  Node: タスクのキャンセル,  Next: Task Groups,  Prev: Task の作成,  Up: コルーチンと Task

5.18.1.9 タスクのキャンセル
...........................

タスクは簡単に、そして安全にキャンセルできます。タスクがキャンセルされた
場合、*note asyncio.CancelledError: 19d. が次の機会に送出されます。

It is recommended that coroutines use ‘try/finally’ blocks to robustly
perform clean-up logic.  In case *note asyncio.CancelledError: 19d. is
explicitly caught, it should generally be propagated when clean-up is
complete.  *note asyncio.CancelledError: 19d. directly subclasses *note
BaseException: 584. so most code will not need to be aware of it.

The asyncio components that enable structured concurrency, like *note
asyncio.TaskGroup: 19a. and *note asyncio.timeout(): 5c9, are
implemented using cancellation internally and might misbehave if a
coroutine swallows *note asyncio.CancelledError: 19d.  Similarly, user
code should not generally call *note uncancel: 1a0.  However, in cases
when suppressing *note asyncio.CancelledError: 19d. is truly desired, it
is necessary to also call ‘uncancel()’ to completely remove the
cancellation state.


File: python.info,  Node: Task Groups,  Next: スリープ,  Prev: タスクのキャンセル,  Up: コルーチンと Task

5.18.1.10 Task Groups
.....................

Task groups combine a task creation API with a convenient and reliable
way to wait for all tasks in the group to finish.

 -- クラス: asyncio.TaskGroup

     An *note asynchronous context manager: 5c6. holding a group of
     tasks.  Tasks can be added to the group using *note create_task():
     5c7.  All tasks are awaited when the context manager exits.

     Added in version 3.11.

      -- メソッド: create_task (coro, *, name=None, context=None)

          Create a task in this task group.  The signature matches that
          of *note asyncio.create_task(): 5c7.  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’.

          バージョン 3.13 で変更: Close the given coroutine if the task
          group is not active.

以下はプログラム例です:

     async def main():
         async with asyncio.TaskGroup() as tg:
             task1 = tg.create_task(some_coro(...))
             task2 = tg.create_task(another_coro(...))
         print(f"Both tasks have completed now: {task1.result()}, {task2.result()}")

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 passing ‘tg’ into one of the coroutines and calling
‘tg.create_task()’ in that coroutine).  Once the last task has finished
and the ‘async with’ block is exited, no new tasks may be added to the
group.

The first time any of the tasks belonging to the group fails with an
exception other than *note asyncio.CancelledError: 19d, the remaining
tasks in the group are cancelled.  No further tasks can then be added to
the group.  At this point, if the body of the ‘async with’ statement is
still active (i.e., *note __aexit__(): 158e. hasn't been called yet),
the task directly containing the ‘async with’ statement is also
cancelled.  The resulting *note asyncio.CancelledError: 19d. will
interrupt an ‘await’, but it will not bubble out of the containing
‘async with’ statement.

Once all tasks have finished, if any tasks have failed with an exception
other than *note asyncio.CancelledError: 19d, those exceptions are
combined in an *note ExceptionGroup: 19b. or *note BaseExceptionGroup:
240. (as appropriate; see their documentation) which is then raised.

Two base exceptions are treated specially: If any task fails with *note
KeyboardInterrupt: 99f. or *note SystemExit: d0e, the task group still
cancels the remaining tasks and waits for them, but then the initial
*note KeyboardInterrupt: 99f. or *note SystemExit: d0e. is re-raised
instead of *note ExceptionGroup: 19b. or *note BaseExceptionGroup: 240.

If the body of the ‘async with’ statement exits with an exception (so
*note __aexit__(): 158e. is called with an exception set), this is
treated the same as if one of the tasks failed: the remaining tasks are
cancelled and then waited for, and non-cancellation exceptions are
grouped into an exception group and raised.  The exception passed into
*note __aexit__(): 158e, unless it is *note asyncio.CancelledError: 19d,
is also included in the exception group.  The same special case is made
for *note KeyboardInterrupt: 99f. and *note SystemExit: d0e. as in the
previous paragraph.

Task groups are careful not to mix up the internal cancellation used to
"wake up" their *note __aexit__(): 158e. with cancellation requests for
the task in which they are running made by other parties.  In
particular, when one task group is syntactically nested in another, and
both experience an exception in one of their child tasks simultaneously,
the inner task group will process its exceptions, and then the outer
task group will receive another cancellation and process its own
exceptions.

In the case where a task group is cancelled externally and also must
raise an *note ExceptionGroup: 19b, it will call the parent task's *note
cancel(): 19c. method.  This ensures that a *note
asyncio.CancelledError: 19d. will be raised at the next *note await:
19e, so the cancellation is not lost.

Task groups preserve the cancellation count reported by *note
asyncio.Task.cancelling(): 19f.

バージョン 3.13 で変更: Improved handling of simultaneous internal and
external cancellations and correct preservation of cancellation counts.

* Menu:

* Terminating a Task Group::


File: python.info,  Node: Terminating a Task Group,  Up: Task Groups

5.18.1.11 Terminating a Task Group
..................................

While terminating a task group is not natively supported by the standard
library, termination can be achieved by adding an exception-raising task
to the task group and ignoring the raised exception:

     import asyncio
     from asyncio import TaskGroup

     class TerminateTaskGroup(Exception):
         """Exception raised to terminate a task group."""

     async def force_terminate_task_group():
         """Used to force termination of a task group."""
         raise TerminateTaskGroup()

     async def job(task_id, sleep_time):
         print(f'Task {task_id}: start')
         await asyncio.sleep(sleep_time)
         print(f'Task {task_id}: done')

     async def main():
         try:
             async with TaskGroup() as group:
                 # spawn some tasks
                 group.create_task(job(1, 0.5))
                 group.create_task(job(2, 1.5))
                 # sleep for 1 second
                 await asyncio.sleep(1)
                 # add an exception-raising task to force the group to terminate
                 group.create_task(force_terminate_task_group())
         except* TerminateTaskGroup:
             pass

     asyncio.run(main())

予想される出力:

     Task 1: start
     Task 2: start
     Task 1: done


File: python.info,  Node: スリープ,  Next: 並行な Task 実行,  Prev: Task Groups,  Up: コルーチンと Task

5.18.1.12 スリープ
..................

 -- の関数: coroutine asyncio.sleep (delay, result=None)

     'delay' 秒だけ停止します。

     'result' が提供されている場合は、コルーチン完了時にそれが呼び出し元
     に返されます。

     ‘sleep()’ は常に現在の Task を一時中断し、他の Task が実行されるの
     を許可します。

     delay を 0 に設定することで、他のタスクを実行可能にする最適な方針を
     提供します。この方法は、実行時間の長い関数が、その実行時間全体にわ
     たってイベントループをブロックしないようにするために利用できます。
     現在の時刻を5秒間、毎秒表示するコルーチンの例:

          import asyncio
          import datetime

          async def display_date():
              loop = asyncio.get_running_loop()
              end_time = loop.time() + 5.0
              while True:
                  print(datetime.datetime.now())
                  if (loop.time() + 1.0) >= end_time:
                      break
                  await asyncio.sleep(1)

          asyncio.run(display_date())

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.13 で変更: Raises *note ValueError: 1e3. if 'delay' is
     *note nan: 62f.


File: python.info,  Node: 並行な Task 実行,  Next: Eager Task Factory,  Prev: スリープ,  Up: コルーチンと Task

5.18.1.13 並行な Task 実行
..........................

 -- の関数: awaitable asyncio.gather (*aws, return_exceptions=False)

     'aws' シーケンスにある *note awaitable オブジェクト: 3138. を '並行
     ' 実行します。

     'aws' にある awaitable がコルーチンである場合、自動的に Task として
     スケジュールされます。

     全ての awaitable が正常終了した場合、その結果は返り値を集めたリスト
     になります。 返り値の順序は、 'aws' での awaitable の順序に相当しま
     す。

     'return_exceptions' が ‘False’ である場合(デフォルト)、‘gather()’ で
     await しているタスクに対して、最初の例外が直接伝えられます。'aws' に
     並んでいる他の awaitable は、'キャンセルされずに' 引き続いて実行さ
     れます。

     'return_exceptions' が ‘True’ だった場合、例外は成功した結果と同じ
     ように取り扱われ、結果リストに集められます。

     ‘gather()’ が 'キャンセル' された場合、起動された全ての (未完了の)
     awaitable も 'キャンセル' されます。

     'aws' シーケンスにある Task あるいは Future が 'キャンセル' された
     場合、 *note CancelledError: 19d. を送出したかのうように扱われます
     。つまり、この場合 ‘gather()’ 呼び出しはキャンセル 'されません'。 こ
     れは、起動された 1 つの Task あるいは Future のキャンセルが、他の
     Task あるいは Future のキャンセルを引き起こすのを避けるためです。

          注釈: A new alternative to create and run tasks concurrently
          and wait for their completion is *note asyncio.TaskGroup: 19a.
          'TaskGroup' provides stronger safety guarantees than 'gather'
          for scheduling a nesting of subtasks: if a task (or a subtask,
          a task scheduled by a task) raises an exception, 'TaskGroup'
          will, while 'gather' will not, cancel the remaining scheduled
          tasks).
     以下はプログラム例です:

          import asyncio

          async def factorial(name, number):
              f = 1
              for i in range(2, number + 1):
                  print(f"Task {name}: Compute factorial({number}), currently i={i}...")
                  await asyncio.sleep(1)
                  f *= i
              print(f"Task {name}: factorial({number}) = {f}")
              return f

          async def main():
              # Schedule three calls *concurrently*:
              L = await asyncio.gather(
                  factorial("A", 2),
                  factorial("B", 3),
                  factorial("C", 4),
              )
              print(L)

          asyncio.run(main())

          # Expected output:
          #
          #     Task A: Compute factorial(2), currently i=2...
          #     Task B: Compute factorial(3), currently i=2...
          #     Task C: Compute factorial(4), currently i=2...
          #     Task A: factorial(2) = 2
          #     Task B: Compute factorial(3), currently i=3...
          #     Task C: Compute factorial(4), currently i=3...
          #     Task B: factorial(3) = 6
          #     Task C: Compute factorial(4), currently i=4...
          #     Task C: factorial(4) = 24
          #     [2, 6, 24]

          注釈: If 'return_exceptions' is false, cancelling gather()
          after it has been marked done won't cancel any submitted
          awaitables.  For instance, gather can be marked done after
          propagating an exception to the caller, therefore, calling
          ‘gather.cancel()’ after catching an exception (raised by one
          of the awaitables) from gather won't cancel any other
          awaitables.

     バージョン 3.7 で変更: 'gather' 自身がキャンセルされた場合は、
     'return_exceptions' の値に関わらずキャンセルが伝搬されます。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.10 で非推奨: 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.


File: python.info,  Node: Eager Task Factory,  Next: キャンセルからの保護,  Prev: 並行な Task 実行,  Up: コルーチンと Task

5.18.1.14 Eager Task Factory
............................

 -- の関数: asyncio.eager_task_factory (loop, coro, *, name=None,
          context=None)

     A task factory for eager task execution.

     When using this factory (via *note
     loop.set_task_factory(asyncio.eager_task_factory): d93.),
     coroutines begin execution synchronously during *note Task: 4a5.
     construction.  Tasks are only scheduled on the event loop if they
     block.  This can be a performance improvement as the overhead of
     loop scheduling is avoided for coroutines that complete
     synchronously.

     A common example where this is beneficial is coroutines which
     employ caching or memoization to avoid actual I/O when possible.

          注釈: 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 coroutine execution
          blocks, the task is scheduled to the event loop.  This change
          may introduce behavior changes to existing applications.  For
          example, the application's task execution order is likely to
          change.

     Added in version 3.12.

 -- の関数: asyncio.create_eager_task_factory (custom_task_constructor)

     Create an eager task factory, similar to *note
     eager_task_factory(): 444, using the provided
     'custom_task_constructor' when creating a new task instead of the
     default *note Task: 4a5.

     'custom_task_constructor' must be a 'callable' with the signature
     matching the signature of *note Task.__init__: 4a5.  The callable
     must return a *note asyncio.Task: 4a5.-compatible object.

     This function returns a 'callable' intended to be used as a task
     factory of an event loop via *note loop.set_task_factory(factory):
     d93.).

     Added in version 3.12.


File: python.info,  Node: キャンセルからの保護,  Next: タイムアウト,  Prev: Eager Task Factory,  Up: コルーチンと Task

5.18.1.15 キャンセルからの保護
..............................

 -- の関数: awaitable asyncio.shield (aw)

     *note キャンセル: 19c. から *note awaitable オブジェクト: 3138. を
     保護します。

     'aw' がコルーチンだった場合、自動的に Task としてスケジュールされま
     す。

     文:

          task = asyncio.create_task(something())
          res = await shield(task)

     は、以下と同じです

          res = await something()

     それを含むコルーチンがキャンセルされた場合を '除き'、‘something()’
     内で動作している Task はキャンセルされません。 ‘something()’ 側から
     見るとキャンセルは発生しません。 呼び出し元がキャンセルされた場合で
     も、 "await" 式は *note CancelledError: 19d. を送出します。

     注意: ‘something()’ が他の理由 (例えば、原因が自分自身) でキャンセ
     ルされた場合は ‘shield()’ でも保護できません。

     完全にキャンセルを無視したい場合 (推奨はしません) は、 ‘shield()’ 関
     数は次のように try/except 節と組み合わせることになるでしょう:

          task = asyncio.create_task(something())
          try:
              res = await shield(task)
          except CancelledError:
              res = None

          重要: 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.

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.10 で非推奨: Deprecation warning is emitted if 'aw' is
     not Future-like object and there is no running event loop.


File: python.info,  Node: タイムアウト,  Next: 要素の終了待機,  Prev: キャンセルからの保護,  Up: コルーチンと Task

5.18.1.16 タイムアウト
......................

 -- の関数: asyncio.timeout (delay)

     Return an *note asynchronous context manager: 5c6. that can be used
     to limit the amount of time spent waiting on something.

     '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.

     In either case, the context manager can be rescheduled after
     creation using *note Timeout.reschedule(): 3147.

     以下はプログラム例です:

          async def main():
              async with asyncio.timeout(10):
                  await long_running_task()

     If ‘long_running_task’ takes more than 10 seconds to complete, the
     context manager will cancel the current task and handle the
     resulting *note asyncio.CancelledError: 19d. internally,
     transforming it into a *note TimeoutError: 800. which can be caught
     and handled.

          注釈: The *note asyncio.timeout(): 5c9. context manager is
          what transforms the *note asyncio.CancelledError: 19d. into a
          *note TimeoutError: 800, which means the *note TimeoutError:
          800. can only be caught 'outside' of the context manager.

     Example of catching *note TimeoutError: 800.:

          async def main():
              try:
                  async with asyncio.timeout(10):
                      await long_running_task()
              except TimeoutError:
                  print("The long operation timed out, but we've handled it.")

              print("This statement will run regardless.")

     The context manager produced by *note asyncio.timeout(): 5c9. can
     be rescheduled to a different deadline and inspected.

      -- クラス: asyncio.Timeout (when)

          An *note asynchronous context manager: 5c6. for cancelling
          overdue coroutines.

          ‘when’ should be an absolute time at which the context should
          time out, as measured by the event loop's clock:

             - If ‘when’ is ‘None’, the timeout will never trigger.

             - If ‘when < loop.time()’, the timeout will trigger on the
               next iteration of the event loop.

                -- メソッド: when () -> float | None

                    Return the current deadline, or ‘None’ if the
                    current deadline is not set.

                -- メソッド: reschedule (when: float | None)

                    Reschedule the timeout.

                -- メソッド: expired () -> bool

                    Return whether the context manager has exceeded its
                    deadline (expired).

     以下はプログラム例です:

          async def main():
              try:
                  # We do not know the timeout when starting, so we pass ``None``.
                  async with asyncio.timeout(None) as cm:
                      # We know the timeout now, so we reschedule it.
                      new_deadline = get_running_loop().time() + 10
                      cm.reschedule(new_deadline)

                      await long_running_task()
              except TimeoutError:
                  pass

              if cm.expired():
                  print("Looks like we haven't finished on time.")

     Timeout context managers can be safely nested.

     Added in version 3.11.

 -- の関数: asyncio.timeout_at (when)

     Similar to *note asyncio.timeout(): 5c9, except 'when' is the
     absolute time to stop waiting, or ‘None’.

     以下はプログラム例です:

          async def main():
              loop = get_running_loop()
              deadline = loop.time() + 20
              try:
                  async with asyncio.timeout_at(deadline):
                      await long_running_task()
              except TimeoutError:
                  print("The long operation timed out, but we've handled it.")

              print("This statement will run regardless.")

     Added in version 3.11.

 -- の関数: coroutine asyncio.wait_for (aw, timeout)

     'aw' *note awaitable: 3138. が、完了するかタイムアウトになるのを待
     ちます。

     'aw' がコルーチンだった場合、自動的に Task としてスケジュールされま
     す。

     'timeout' には ‘None’ もしくは待つ秒数の浮動小数点数か整数を指定で
     きます。 'timeout' が ‘None’ の場合、 Future が完了するまで待ちます
     。

     If a timeout occurs, it cancels the task and raises *note
     TimeoutError: 800.

     Task の *note キャンセル: 19c. を避けるためには、 *note shield():
     a3e. の中にラップしてください。

     この関数は future が実際にキャンセルされるまで待つため、待ち時間の
     合計は 'timeout' を超えることがあります。キャンセル中に例外が発生し
     た場合は、その例外は伝達されます。

     待機が中止された場合 'aw' も中止されます。 以下はプログラム例です:

          async def eternity():
              # Sleep for one hour
              await asyncio.sleep(3600)
              print('yay!')

          async def main():
              # Wait for at most 1 second
              try:
                  await asyncio.wait_for(eternity(), timeout=1.0)
              except TimeoutError:
                  print('timeout!')

          asyncio.run(main())

          # Expected output:
          #
          #     timeout!

     バージョン 3.7 で変更: When 'aw' is cancelled due to a timeout,
     ‘wait_for’ waits for 'aw' to be cancelled.  Previously, it raised
     *note TimeoutError: 800. immediately.

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.11 で変更: Raises *note TimeoutError: 800. instead of
     *note asyncio.TimeoutError: 16ab.


File: python.info,  Node: 要素の終了待機,  Next: スレッド内での実行,  Prev: タイムアウト,  Up: コルーチンと Task

5.18.1.17 要素の終了待機
........................

 -- の関数: coroutine asyncio.wait (aws, *, timeout=None,
          return_when=ALL_COMPLETED)

     Run *note Future: b9b. and *note Task: 4a5. instances in the 'aws'
     iterable concurrently and block until the condition specified by
     'return_when'.

     イテラブル 'aws' は空であってはなりません。

     Task/Future からなる 2 つの集合 ‘(done, pending)’ を返します。

     使い方:

          done, pending = await asyncio.wait(aws)

     'timeout' (浮動小数点数または整数) が指定されていたら、処理を返すの
     を待つ最大秒数を制御するのに使われます。

     Note that this function does not raise *note TimeoutError: 800.
     Futures or Tasks that aren't done when the timeout occurs are
     simply returned in the second set.

     'return_when' でこの関数がいつ結果を返すか指定します。指定できる値
     は以下の 定数のどれか一つです:

     定数                                                   説明
                                                            
     --------------------------------------------------------------------------------------------------------------
                                                            
      -- データ: asyncio.FIRST_COMPLETED                    いずれかのフューチャが終了したかキャンセルされたとき
                                                            に返します。
                                                            
                                                            
      -- データ: asyncio.FIRST_EXCEPTION                    The function will return when any future finishes by
                                                            raising an exception.  If no future raises an
                                                            exception then it is equivalent to
                                                            *note ALL_COMPLETED: 314e.
                                                            
                                                            
      -- データ: asyncio.ALL_COMPLETED                      すべてのフューチャが終了したかキャンセルされたときに
                                                            返します。
                                                            

     *note wait_for(): 5ca. と異なり、 ‘wait()’ はタイムアウトが起きたと
     きに Future をキャンセルしません。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.11 で変更: Passing coroutine objects to ‘wait()’
     directly is forbidden.

     バージョン 3.12 で変更: Added support for generators yielding
     tasks.

 -- の関数: asyncio.as_completed (aws, *, timeout=None)

     Run *note awaitable objects: 3138. in the 'aws' iterable
     concurrently.  The returned object can be iterated to obtain the
     results of the awaitables as they finish.

     The object returned by ‘as_completed()’ can be iterated as an *note
     asynchronous iterator: 190. or a plain *note iterator: 191.  When
     asynchronous iteration is used, the originally-supplied awaitables
     are yielded if they are tasks or futures.  This makes it easy to
     correlate previously-scheduled tasks with their results.  Example:

          ipv4_connect = create_task(open_connection("127.0.0.1", 80))
          ipv6_connect = create_task(open_connection("::1", 80))
          tasks = [ipv4_connect, ipv6_connect]

          async for earliest_connect in as_completed(tasks):
              # earliest_connect is done. The result can be obtained by
              # awaiting it or calling earliest_connect.result()
              reader, writer = await earliest_connect

              if earliest_connect is ipv6_connect:
                  print("IPv6 connection established.")
              else:
                  print("IPv4 connection established.")

     During asynchronous iteration, implicitly-created tasks will be
     yielded for supplied awaitables that aren't tasks or futures.

     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:

          ipv4_connect = create_task(open_connection("127.0.0.1", 80))
          ipv6_connect = create_task(open_connection("::1", 80))
          tasks = [ipv4_connect, ipv6_connect]

          for next_connect in as_completed(tasks):
              # next_connect is not one of the original task objects. It must be
              # awaited to obtain the result value or raise the exception of the
              # awaitable that finishes next.
              reader, writer = await next_connect

     A *note TimeoutError: 800. 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.

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.10 で非推奨: Deprecation warning is emitted if not all
     awaitable objects in the 'aws' iterable are Future-like objects and
     there is no running event loop.

     バージョン 3.12 で変更: Added support for generators yielding
     tasks.

     バージョン 3.13 で変更: The result can now be used as either an
     *note asynchronous iterator: 190. or as a plain *note iterator:
     191. (previously it was only a plain iterator).


File: python.info,  Node: スレッド内での実行,  Next: 外部スレッドからのスケジュール,  Prev: 要素の終了待機,  Up: コルーチンと Task

5.18.1.18 スレッド内での実行
............................

 -- の関数: coroutine asyncio.to_thread (func, /, *args, **kwargs)

     別のスレッドで非同期的に関数 'func' を実行します。

     この関数に渡された *args と **kwargs は関数 'func' に直接渡されます
     。また、イベントループスレッドのコンテキスト変数に関数を実行するス
     レッドからアクセスできるように、現在の *note contextvars.Context:
     150d. も伝播されます。

     関数 'func' の最終結果を待ち受けできるコルーチンを返します。

     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:

          def blocking_io():
              print(f"start blocking_io at {time.strftime('%X')}")
              # Note that time.sleep() can be replaced with any blocking
              # IO-bound operation, such as file operations.
              time.sleep(1)
              print(f"blocking_io complete at {time.strftime('%X')}")

          async def main():
              print(f"started main at {time.strftime('%X')}")

              await asyncio.gather(
                  asyncio.to_thread(blocking_io),
                  asyncio.sleep(1))

              print(f"finished main at {time.strftime('%X')}")


          asyncio.run(main())

          # Expected output:
          #
          # started main at 19:50:53
          # start blocking_io at 19:50:53
          # blocking_io complete at 19:50:54
          # finished main at 19:50:54

     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.

          注釈: Due to the *note GIL: 13f, ‘asyncio.to_thread()’ can
          typically only be used to make IO-bound functions
          non-blocking.  However, for extension modules that release the
          GIL or alternative Python implementations that don't have one,
          ‘asyncio.to_thread()’ can also be used for CPU-bound
          functions.

     Added in version 3.9.


File: python.info,  Node: 外部スレッドからのスケジュール,  Next: イントロスペクション,  Prev: スレッド内での実行,  Up: コルーチンと Task

5.18.1.19 外部スレッドからのスケジュール
........................................

 -- の関数: asyncio.run_coroutine_threadsafe (coro, loop)

     与えられたイベントループにコルーチンを送ります。 この処理は、スレッ
     ドセーフです。

     他の OS スレッドから結果を待つための *note
     concurrent.futures.Future: 1182. を返します。

     この関数は、イベントループが動作しているスレッドとは異なる OS スレ
     ッドから呼び出すためのものです。 例えば次のように使います:

          # Create a coroutine
          coro = asyncio.sleep(1, result=3)

          # Submit the coroutine to a given loop
          future = asyncio.run_coroutine_threadsafe(coro, loop)

          # Wait for the result with an optional timeout argument
          assert future.result(timeout) == 3

     コルーチンから例外が送出された場合、返された Future に通知されます
     。 これはイベントループの Task をキャンセルするのにも使えます:

          try:
              result = future.result(timeout)
          except TimeoutError:
              print('The coroutine took too long, cancelling the task...')
              future.cancel()
          except Exception as exc:
              print(f'The coroutine raised an exception: {exc!r}')
          else:
              print(f'The coroutine returned: {result!r}')

     このドキュメントの *note 並行処理とマルチスレッド処理: 3151. 節を参
     照してください。

     他の asyncio 関数とは異なり、この関数は明示的に渡される 'loop' 引数
     を必要とします。

     Added in version 3.5.1.


File: python.info,  Node: イントロスペクション,  Next: Task オブジェクト,  Prev: 外部スレッドからのスケジュール,  Up: コルーチンと Task

5.18.1.20 イントロスペクション
..............................

 -- の関数: asyncio.current_task (loop=None)

     現在実行中の *note Task: 4a5. インスタンスを返します。実行中の Task
     が無い場合は ‘None’ を返します。

     'loop' が ‘None’ の場合、 *note get_running_loop(): ad9. が現在のル
     ープを取得するのに使われます。

     Added in version 3.7.

 -- の関数: asyncio.all_tasks (loop=None)

     ループで実行された *note Task: 4a5. オブジェクトでまだ完了していな
     いものの集合を返します。

     'loop' が ‘None’ の場合、 *note get_running_loop(): ad9. は現在のル
     ープを取得するのに使われます。

     Added in version 3.7.

 -- の関数: asyncio.iscoroutine (obj)

     Return ‘True’ if 'obj' is a coroutine object.

     Added in version 3.4.


File: python.info,  Node: Task オブジェクト,  Prev: イントロスペクション,  Up: コルーチンと Task

5.18.1.21 Task オブジェクト
...........................

 -- クラス: asyncio.Task (coro, *, loop=None, name=None, context=None,
          eager_start=False)

     Python *note コルーチン: 3122. を実行する *note Future 類: b9b. オ
     ブジェクトです。 スレッドセーフではありません。

     Task はイベントループのコルーチンを実行するのに使われます。 Future
     でコルーチンが待機している場合、 Task は自身のコルーチンの実行を一
     時停止させ、 Future の完了を待ちます。 Future が '完了' したら、
     Task が内包しているコルーチンの実行を再開します。

     イベントループは協調スケジューリングを使用します。つまり、イベント
     ループは同時に 1 つの Task のみ実行します。 Task が Future の完了を
     待っているときは、イベントループは他の Task やコールバックを動作さ
     せるか、 IO 処理を実行します。

     Task を作成するには高レベルの *note asyncio.create_task(): 5c7. 関
     数、あるいは低レベルの *note loop.create_task(): 9aa. 関数や *note
     ensure_future(): c44. 関数を使用してください。 手作業での Task の実
     装は推奨されません。

     実行中のタスクをキャンセルするためには、*note cancel(): 19c. メソッ
     ドを使用します。このメソッドを呼ぶと、タスクはそれを内包するコルー
     チンに対して *note CancelledError: 19d. 例外を送出します。キャンセ
     ルの際にコルーチンが Future オブジェクトを待っていた場合、その
     Future オブジェクトはキャンセルされます。

     *note cancelled(): 3154. は、タスクがキャンセルされたかを調べるのに
     使用できます。タスクを内包するコルーチンで *note CancelledError:
     19d. 例外が抑制されておらず、かつタスクが実際にキャンセルされている
     場合に、このメソッドは ‘True’ を変えます。

     *note asyncio.Task: 4a5. は、*note Future.set_result(): 3155. と
     *note Future.set_exception(): 3156. を除いて、*note Future: b9b. の
     API をすべて継承しています。

     An optional keyword-only 'context' argument allows specifying a
     custom *note contextvars.Context: 150d. 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.

     An optional keyword-only 'eager_start' argument allows eagerly
     starting the execution of the *note asyncio.Task: 4a5. at task
     creation time.  If set to ‘True’ and the event loop is running, the
     task will start executing the coroutine immediately, until the
     first time the coroutine blocks.  If the coroutine returns or
     raises without blocking, the task will be finished eagerly and will
     skip scheduling to the event loop.

     バージョン 3.7 で変更: *note contextvars: 1d. モジュールのサポート
     を追加。

     バージョン 3.8 で変更: 'name' パラメータを追加しました。

     バージョン 3.10 で非推奨: Deprecation warning is emitted if 'loop'
     is not specified and there is no running event loop.

     バージョン 3.11 で変更: 'context' パラメータを追加しました。

     バージョン 3.12 で変更: Added the 'eager_start' parameter.

      -- メソッド: done ()

          Task が '完了' しているなら ‘True’ を返します。

          Task がラップしているコルーチンが値を返すか、例外を送出するか
          、または Task がキャンセルされたとき、 Task は '完了' します。

      -- メソッド: result ()

          Task の結果を返します。

          Task が '完了' している場合、ラップしているコルーチンの結果が
          返されます (コルーチンが例外を送出された場合、その例外が例外が
          再送出されます)

          Task が 'キャンセル' されている場合、このメソッドは *note
          CancelledError: 19d. 例外を送出します。

          If the Task's result isn't yet available, this method raises
          an *note InvalidStateError: 3159. exception.

      -- メソッド: exception ()

          Task の例外を返します。

          ラップされたコルーチンが例外を送出した場合、その例外が返されま
          す。ラップされたコルーチンが正常終了した場合、このメソッドは
          ‘None’ を返します。

          Task が 'キャンセル' されている場合、このメソッドは *note
          CancelledError: 19d. 例外を送出します。

          Task がまだ '完了' していない場合、このメソッドは *note
          InvalidStateError: 3159. 例外を送出します。

      -- メソッド: add_done_callback (callback, *, context=None)

          Task が '完了' したときに実行されるコールバックを追加します。

          このメソッドは低水準のコールバックベースのコードでのみ使うべき
          です。

          詳細については *note Future.add_done_callback(): ad6. のドキュ
          メントを参照してください。

      -- メソッド: remove_done_callback (callback)

          コールバックリストから 'callback' を削除します。

          このメソッドは低水準のコールバックベースのコードでのみ使うべき
          です。

          詳細については *note Future.remove_done_callback(): 150b. のド
          キュメントを参照してください。

      -- メソッド: get_stack (*, limit=None)

          このタスクのスタックフレームのリストを返します。

          コルーチンが完了していない場合、これはサスペンドされた時点での
          スタックを返します。コルーチンが正常に処理を完了したか、キャン
          セルされていた場合は空のリストを返します。コルーチンが例外で終
          了した場合はトレースバックフレームのリストを返します。

          フレームは常に古いものから新しい物へ並んでいます。

          サスペンドされているコルーチンの場合スタックフレームが 1 個だ
          け返されます。

          オプション引数 'limit' は返すフレームの最大数を指定します; デ
          フォルトでは取得可能な全てのフレームを返します。返されるリスト
          の順番は、スタックが返されるか、トレースバックが返されるかによ
          って変わります: スタックでは新しい順に並んだリストが返されます
          が、トレースバックでは古い順に並んだリストが返されます（これは
          traceback モジュールの振る舞いと一致します）。

      -- メソッド: print_stack (*, limit=None, file=None)

          このタスクのスタックまたはトレースバックを出力します。

          このメソッドは *note get_stack(): 315d. によって取得されるフレ
          ームに対し、 traceback モジュールと同じような出力を生成します
          。

          引数 'limit' は *note get_stack(): 315d. にそのまま渡されます
          。

          The 'file' argument is an I/O stream to which the output is
          written; by default output is written to *note sys.stdout:
          aa4.

      -- メソッド: get_coro ()

          *note Task: 4a5. がラップしているコルーチンオブジェクトを返し
          ます。

               注釈: This will return ‘None’ for Tasks which have
               already completed eagerly.  See the *note Eager Task
               Factory: 3143.

          Added in version 3.8.

          バージョン 3.12 で変更: Newly added eager task execution means
          result may be ‘None’.

      -- メソッド: get_context ()

          Return the *note contextvars.Context: 150d. object associated
          with the task.

          Added in version 3.12.

      -- メソッド: get_name ()

          Task の名前を返します。

          Task に対して明示的に名前が設定されていない場合, デフォルトの
          asyncio Task 実装はタスクをインスタンス化する際にデフォルトの
          名前を生成します。

          Added in version 3.8.

      -- メソッド: set_name (value)

          Task に名前を設定します。

          引数 'value' は文字列に変換可能なオブジェクトであれば何でもか
          まいません。

          Task のデフォルト実装では、名前はオブジェクトの *note repr():
          7c8. メソッドの出力で確認できます。

          Added in version 3.8.

      -- メソッド: cancel (msg=None)

          このタスクに、自身のキャンセルを要求します。

          このメソッドは、イベントループの次のステップにおいて、タスクが
          ラップしているコルーチン内で *note CancelledError: 19d. 例外が
          送出されるように準備します。

          The coroutine then has a chance to clean up or even deny the
          request by suppressing the exception with a *note try: 6b4.
          ...  ...  ‘except CancelledError’ ...  *note finally: 997.
          block.  Therefore, unlike *note Future.cancel(): 1785, *note
          Task.cancel(): 19c. does not guarantee that the Task will be
          cancelled, although suppressing cancellation completely is not
          common and is actively discouraged.  Should the coroutine
          nevertheless decide to suppress the cancellation, it needs to
          call *note Task.uncancel(): 1a0. in addition to catching the
          exception.

          バージョン 3.9 で変更: Added the 'msg' parameter.

          バージョン 3.11 で変更: The ‘msg’ parameter is propagated from
          cancelled task to its awaiter.

          以下の例は、コルーチンがどのようにしてキャンセルのリクエストを
          阻止するかを示しています:

               async def cancel_me():
                   print('cancel_me(): before sleep')

                   try:
                       # Wait for 1 hour
                       await asyncio.sleep(3600)
                   except asyncio.CancelledError:
                       print('cancel_me(): cancel sleep')
                       raise
                   finally:
                       print('cancel_me(): after sleep')

               async def main():
                   # Create a "cancel_me" Task
                   task = asyncio.create_task(cancel_me())

                   # Wait for 1 second
                   await asyncio.sleep(1)

                   task.cancel()
                   try:
                       await task
                   except asyncio.CancelledError:
                       print("main(): cancel_me is cancelled now")

               asyncio.run(main())

               # Expected output:
               #
               #     cancel_me(): before sleep
               #     cancel_me(): cancel sleep
               #     cancel_me(): after sleep
               #     main(): cancel_me is cancelled now

      -- メソッド: cancelled ()

          Task が 'キャンセルされた' 場合に ‘True’ を返します。

          *note cancel(): 19c. メソッドによりキャンセルがリクエストされ
          、かつ Task がラップしているコルーチンが内部で送出された *note
          CancelledError: 19d. 例外を伝達したとき、 Task は実際に 'キャ
          ンセル' されます。

      -- メソッド: uncancel ()

          Decrement the count of cancellation requests to this Task.

          Returns the remaining number of cancellation requests.

          Note that once execution of a cancelled task completed,
          further calls to *note uncancel(): 1a0. are ineffective.

          Added in version 3.11.

          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 allows for elements of
          structured concurrency like *note Task Groups: 313d. and *note
          asyncio.timeout(): 5c9. to continue running, isolating
          cancellation to the respective structured block.  For example:

               async def make_request_with_timeout():
                   try:
                       async with asyncio.timeout(1):
                           # Structured block affected by the timeout:
                           await make_request()
                           await make_another_request()
                   except TimeoutError:
                       log("There was a timeout")
                   # Outer code not affected by the timeout:
                   await unrelated_code()

          While the block with ‘make_request()’ and
          ‘make_another_request()’ might get cancelled due to the
          timeout, ‘unrelated_code()’ should continue running even in
          case of the timeout.  This is implemented with *note
          uncancel(): 1a0.  *note TaskGroup: 19a. context managers use
          *note uncancel(): 1a0. in a similar fashion.

          If end-user code is, for some reason, suppressing cancellation
          by catching *note CancelledError: 19d, it needs to call this
          method to remove the cancellation state.

          When this method decrements the cancellation count to zero,
          the method checks if a previous *note cancel(): 19c. call had
          arranged for *note CancelledError: 19d. to be thrown into the
          task.  If it hasn't been thrown yet, that arrangement will be
          rescinded (by resetting the internal ‘_must_cancel’ flag).

     バージョン 3.13 で変更: Changed to rescind pending cancellation
     requests upon reaching zero.

      -- メソッド: cancelling ()

          Return the number of pending cancellation requests to this
          Task, i.e., the number of calls to *note cancel(): 19c. less
          the number of *note uncancel(): 1a0. calls.

          Note that if this number is greater than zero but the Task is
          still executing, *note cancelled(): 3154. will still return
          ‘False’.  This is because this number can be lowered by
          calling *note uncancel(): 1a0, which can lead to the task not
          being cancelled after all if the cancellation requests go down
          to zero.

          This method is used by asyncio's internals and isn't expected
          to be used by end-user code.  See *note uncancel(): 1a0. for
          more details.

          Added in version 3.11.


File: python.info,  Node: ストリーム,  Next: 同期プリミティブ<2>,  Prev: コルーチンと Task,  Up: asyncio --- 非同期 I/O

5.18.1.22 ストリーム
....................

'ソースコード:' Lib/asyncio/streams.py(1)

__________________________________________________________________

ストリームはネットワークコネクションと合わせて動作する高水準の
async/await 可能な基本要素です。ストリームはコールバックや低水準のプロト
コルやトランスポートを使うことなくデータを送受信することを可能にします。
以下は asyncio ストリームを使って書いた TCP エコークライアントの例です:

     import asyncio

     async def tcp_echo_client(message):
         reader, writer = await asyncio.open_connection(
             '127.0.0.1', 8888)

         print(f'Send: {message!r}')
         writer.write(message.encode())
         await writer.drain()

         data = await reader.read(100)
         print(f'Received: {data.decode()!r}')

         print('Close the connection')
         writer.close()
         await writer.wait_closed()

     asyncio.run(tcp_echo_client('Hello World!'))

下記の *note 使用例: 3163. 節も参照してください。

ストリーム関数
..............

以下の asyncio のトップレベル関数はストリームの作成や操作を行うことがで
きます:

 -- の関数: coroutine asyncio.open_connection (host=None, port=None, *,
          limit=None, ssl=None, family=0, proto=0, flags=0, sock=None,
          local_addr=None, server_hostname=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None,
          happy_eyeballs_delay=None, interleave=None)

     ネットワークコネクションを確立し、 ‘(reader, writer)’ のオブジェク
     トのペアを返します。

     戻り値の 'reader' と 'writer' はそれぞれ *note StreamReader: 1830.
     と *note StreamWriter: 1665. クラスのインスタンスです。

     'limit' は戻り値の *note StreamReader: 1830. インスタンスが利用する
     バッファのサイズの上限値を設定します。デフォルトでは 'limit' は 64
     KiB に設定されます。

     残りの引数は直接 *note loop.create_connection(): 5ce. に渡されます
     。

          注釈: The 'sock' argument transfers ownership of the socket to
          the *note StreamWriter: 1665. created.  To close the socket,
          call its *note close(): 3164. method.

     バージョン 3.7 で変更: Added the 'ssl_handshake_timeout' parameter.

     バージョン 3.8 で変更: 'happy_eyeballs_delay' と 'interleave' が追
     加されました。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

 -- の関数: coroutine asyncio.start_server (client_connected_cb,
          host=None, port=None, *, limit=None, family=socket.AF_UNSPEC,
          flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None,
          reuse_address=None, reuse_port=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None,
          start_serving=True)

     ソケットサーバーを起動します。

     'client_connected_cb' コールバックは新しいクライアントコネクション
     が確立されるたびに呼び出されます。このコールバックは *note
     StreamReader: 1830. と *note StreamWriter: 1665. クラスのインスタン
     スのペア ‘(reader, writer)’ を2つの引数として受け取ります。

     'client_connected_cb' には単純な呼び出し可能オブジェクトか、または
     *note コルーチン関数: 3122. を指定します; コルーチン関数が指定され
     た場合、コールバックの呼び出しは自動的に *note Task: 4a5. としてス
     ケジュールされます。

     'limit' は戻り値の *note StreamReader: 1830. インスタンスが利用する
     バッファのサイズの上限値を設定します。デフォルトでは 'limit' は 64
     KiB に設定されます。

     残りの引数は直接 *note loop.create_server(): ae1. に渡されます。

          注釈: The 'sock' argument transfers ownership of the socket to
          the server created.  To close the socket, call the server's
          *note close(): 3165. method.

     バージョン 3.7 で変更: 'ssl_handshake_timeout' と 'start_serving' パ
     ラメータが追加されました。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

Unix ソケット
.............

 -- の関数: coroutine asyncio.open_unix_connection (path=None, *,
          limit=None, ssl=None, sock=None, server_hostname=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None)

     Unix ソケットコネクションを確立し、 ‘(reader, writer)’ のオブジェク
     トのペアを返します。

     この関数は *note open_connection(): ae6. と似ていますが Unix ソケッ
     トに対して動作します。

     *note loop.create_unix_connection(): 3167. のドキュメントも参照して
     ください。

          注釈: The 'sock' argument transfers ownership of the socket to
          the *note StreamWriter: 1665. created.  To close the socket,
          call its *note close(): 3164. method.

     *note Availability: 1cbe.: Unix.

     バージョン 3.7 で変更: Added the 'ssl_handshake_timeout' parameter.
     The 'path' parameter can now be a *note path-like object: 280.

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

 -- の関数: coroutine asyncio.start_unix_server (client_connected_cb,
          path=None, *, limit=None, sock=None, backlog=100, ssl=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None,
          start_serving=True)

     Unix のソケットサーバーを起動します。

     *note start_server(): ae7. と似ていますが Unix ソケットに対して動作
     します。

     *note loop.create_unix_server(): 193. のドキュメントも参照してくだ
     さい。

          注釈: The 'sock' argument transfers ownership of the socket to
          the server created.  To close the socket, call the server's
          *note close(): 3165. method.

     *note Availability: 1cbe.: Unix.

     バージョン 3.7 で変更: Added the 'ssl_handshake_timeout' and
     'start_serving' parameters.  The 'path' parameter can now be a
     *note path-like object: 280.

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

* Menu:

* StreamReader::
* StreamWriter::
* 使用例: 使用例<21>.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/streams.py


File: python.info,  Node: StreamReader,  Next: StreamWriter,  Up: ストリーム

5.18.1.23 StreamReader
......................

 -- クラス: asyncio.StreamReader

     Represents a reader object that provides APIs to read data from the
     IO stream.  As an *note asynchronous iterable: d45, the object
     supports the *note async for: a79. statement.

     'StreamReader' オブジェクトを直接インスタンス化することは推奨されま
     せん; 代わりに *note open_connection(): ae6. や *note
     start_server(): ae7. を使ってください。

      -- メソッド: feed_eof ()

          EOF の肯定応答を行います。

      -- メソッド: coroutine read (n=-1)

          ストリームから最大 'n' バイト読み込みます。

          'n' が指定されないか ‘-1’ が指定されていた場合 EOF になるまで
          読み込み、読み込まれた全ての *note bytes: 1a4. を返します。EOF
          を受信し、かつ内部バッファーが空の場合、空の ‘bytes’ オブジェ
          クトを返します。

          'n' が ‘0’ なら、ただちに空の ‘bytes’ オブジェクトを返します。

          'n' が正なら、内部バッファで最低でも 1 バイトが利用可能になり
          次第、利用可能な最大 'n' ‘bytes’ を返します。1 バイトも読み込
          まないうちに EOF を受信したなら、空の ‘bytes’ オブジェクトを返
          します。

      -- メソッド: coroutine readline ()

          1 行読み込みます。 "行" とは、‘\n’ で終了するバイト列のシーケ
          ンスです。

          EOF を受信し、かつ ‘\n’ が見つからない場合、このメソッドは部分
          的に読み込んだデータを返します。

          EOF を受信し、かつ内部バッファーが空の場合、空の ‘bytes’ オブ
          ジェクトを返します。

      -- メソッド: coroutine readexactly (n)

          厳密に 'n' バイトのデータを読み出します。

          'n' バイトを読み出す前に EOF に達した場合 *note
          IncompleteReadError: 188a. を送出します。部分的に読み出したデ
          ータを取得するには *note IncompleteReadError.partial: 316d. 属
          性を使ってください。

      -- メソッド: coroutine readuntil (separator=b'\n')

          'separator' が見つかるまでストリームからデータを読み出します。

          成功時には、データと区切り文字は内部バッファから削除されます
          (消費されます)。返されるデータの最後には区切り文字が含まれます
          。

          読み出したデータの量が設定したストリームの上限を超えると *note
          LimitOverrunError: 316e. 例外が送出されます。このときデータは
          内部バッファーに残され、再度読み出すことができます。

          完全な区切り文字が見つかる前に EOF に達すると *note
          IncompleteReadError: 188a. 例外が送出され、内部バッファーがリ
          セットされます。このとき *note IncompleteReadError.partial:
          316d. 属性は区切り文字の一部を含むかもしれません。

          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 *note
          LimitOverrunError: 316e, the shortest possible separator is
          considered to be the one that matched.

          Added in version 3.5.2.

          バージョン 3.13 で変更: The 'separator' parameter may now be a
          *note tuple: 349. of separators.

      -- メソッド: at_eof ()

          バッファーが空で *note feed_eof(): 316a. が呼ばれていた場合
          ‘True’ を返します。


File: python.info,  Node: StreamWriter,  Next: 使用例<21>,  Prev: StreamReader,  Up: ストリーム

5.18.1.24 StreamWriter
......................

 -- クラス: asyncio.StreamWriter

     IO ストリームにデータを書き込むための API を提供するライターオブジ
     ェクトを表します。

     'StreamWriter' オブジェクトを直接インスタンス化することは推奨されま
     せん; 代わりに *note open_connection(): ae6. や *note
     start_server(): ae7. を使ってください。

      -- メソッド: write (data)

          このメソッドは、背後にあるソケットにデータ 'data' を即座に書き
          込みます。書き込みに失敗した場合、データは送信可能になるまで内
          部の書き込みバッファーに格納されて待機します。

          このメソッドは ‘drain()’ メソッドと組み合わせて使うべきです:

               stream.write(data)
               await stream.drain()

      -- メソッド: writelines (data)

          このメソッドは、背後にあるソケットにバイトデータのリスト (また
          はイテラブル) を即座に書き込みます。書き込みに失敗した場合、デ
          ータは送信可能になるまで内部の書き込みバッファーに格納されて待
          機します。

          このメソッドは ‘drain()’ メソッドと組み合わせて使うべきです:

               stream.writelines(lines)
               await stream.drain()

      -- メソッド: close ()

          このメソッドはストリームと背後にあるソケットをクローズします。

          The method should be used, though not mandatory, along with
          the ‘wait_closed()’ method:

               stream.close()
               await stream.wait_closed()

      -- メソッド: can_write_eof ()

          背後にあるトランスポートが *note write_eof(): 3174. メソッドを
          サポートしている場合 ‘True’ を返し、そうでない場合は ‘False’ を
          返します。

      -- メソッド: write_eof ()

          バッファーされた書き込みデータを全て書き込んでから、ストリーム
          の書き込み側終端をクローズします。

      -- の属性: transport

          背後にある asyncio トランスポートを返します。

      -- メソッド: get_extra_info (name, default=None)

          オプションのトランスポート情報にアクセスします。詳細は *note
          BaseTransport.get_extra_info(): a6a. を参照してください。

      -- メソッド: coroutine drain ()

          ストリームへの書き込み再開に適切な状態になるまで待ちます。使用
          例:

               writer.write(data)
               await writer.drain()

          このメソッドは背後にある IO 書き込みバッファーとやりとりを行う
          フロー制御メソッドです。バッファーのサイズが最高水位点に達した
          場合、'drain()' はバッファのサイズが最低水位点を下回るまで減量
          され、書き込み再開可能になるまで書き込みをブロックします。待ち
          受けの必要がない場合、 *note drain(): 1719. は即座にリターンし
          ます。

      -- メソッド: coroutine start_tls (sslcontext, *,
               server_hostname=None, ssl_handshake_timeout=None,
               ssl_shutdown_timeout=None)

          Upgrade an existing stream-based connection to TLS.

          引数:

             * 'sslcontext': 構成済みの *note SSLContext: 274. インスタ
               ンスです。

             * 'server_hostname': 対象のサーバーの証明書との照合に使われ
               るホスト名を設定または上書きします。

             * '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).

             * '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).

          Added in version 3.11.

          バージョン 3.12 で変更: 'ssl_shutdown_timeout' パラメータが追
          加されました。

      -- メソッド: is_closing ()

          ストリームがクローズされたか、またはクローズ処理中の場合に
          ‘True’ を返します。

          Added in version 3.7.

      -- メソッド: coroutine wait_closed ()

          ストリームがクローズされるまで待機します。

          Should be called after *note close(): 3164. to wait until the
          underlying connection is closed, ensuring that all data has
          been flushed before e.g.  exiting the program.

          Added in version 3.7.


File: python.info,  Node: 使用例<21>,  Prev: StreamWriter,  Up: ストリーム

5.18.1.25 使用例
................

* Menu:

* ストリームを使った TCP Echo クライアント::
* ストリームを使った TCP Echo サーバー::
* HTTP ヘッダーの取得::
* ストリームを使ってデータを待つオープンソケットの登録::


File: python.info,  Node: ストリームを使った TCP Echo クライアント,  Next: ストリームを使った TCP Echo サーバー,  Up: 使用例<21>

5.18.1.26 ストリームを使った TCP Echo クライアント
..................................................

*note asyncio.open_connection(): ae6. 関数を使った TCP Echo クライアント
です:

     import asyncio

     async def tcp_echo_client(message):
         reader, writer = await asyncio.open_connection(
             '127.0.0.1', 8888)

         print(f'Send: {message!r}')
         writer.write(message.encode())
         await writer.drain()

         data = await reader.read(100)
         print(f'Received: {data.decode()!r}')

         print('Close the connection')
         writer.close()
         await writer.wait_closed()

     asyncio.run(tcp_echo_client('Hello World!'))

参考
....

*note TCP エコークライアントプロトコル: 3179. の例は低水準の *note
loop.create_connection(): 5ce. メソッドを使っています。


File: python.info,  Node: ストリームを使った TCP Echo サーバー,  Next: HTTP ヘッダーの取得,  Prev: ストリームを使った TCP Echo クライアント,  Up: 使用例<21>

5.18.1.27 ストリームを使った TCP Echo サーバー
..............................................

*note asyncio.start_server(): ae7. 関数を使った TCP Echo サーバーです:

     import asyncio

     async def handle_echo(reader, writer):
         data = await reader.read(100)
         message = data.decode()
         addr = writer.get_extra_info('peername')

         print(f"Received {message!r} from {addr!r}")

         print(f"Send: {message!r}")
         writer.write(data)
         await writer.drain()

         print("Close the connection")
         writer.close()
         await writer.wait_closed()

     async def main():
         server = await asyncio.start_server(
             handle_echo, '127.0.0.1', 8888)

         addrs = ', '.join(str(sock.getsockname()) for sock in server.sockets)
         print(f'Serving on {addrs}')

         async with server:
             await server.serve_forever()

     asyncio.run(main())

参考
....

*note TCP エコーサーバープロトコル: 317c. の例は *note
loop.create_server(): ae1. メソッドを使っています。


File: python.info,  Node: HTTP ヘッダーの取得,  Next: ストリームを使ってデータを待つオープンソケットの登録,  Prev: ストリームを使った TCP Echo サーバー,  Up: 使用例<21>

5.18.1.28 HTTP ヘッダーの取得
.............................

コマンドラインから渡された URL の HTTP ヘッダーを問い合わせる簡単な例で
す:

     import asyncio
     import urllib.parse
     import sys

     async def print_http_headers(url):
         url = urllib.parse.urlsplit(url)
         if url.scheme == 'https':
             reader, writer = await asyncio.open_connection(
                 url.hostname, 443, ssl=True)
         else:
             reader, writer = await asyncio.open_connection(
                 url.hostname, 80)

         query = (
             f"HEAD {url.path or '/'} HTTP/1.0\r\n"
             f"Host: {url.hostname}\r\n"
             f"\r\n"
         )

         writer.write(query.encode('latin-1'))
         while True:
             line = await reader.readline()
             if not line:
                 break

             line = line.decode('latin1').rstrip()
             if line:
                 print(f'HTTP header> {line}')

         # Ignore the body, close the socket
         writer.close()
         await writer.wait_closed()

     url = sys.argv[1]
     asyncio.run(print_http_headers(url))

使い方:

     python example.py http://example.com/path/page.html

または HTTPS を使用:

     python example.py https://example.com/path/page.html


File: python.info,  Node: ストリームを使ってデータを待つオープンソケットの登録,  Prev: HTTP ヘッダーの取得,  Up: 使用例<21>

5.18.1.29 ストリームを使ってデータを待つオープンソケットの登録
..............................................................

*note open_connection(): ae6. 関数を使ってソケットがデータを受信するまで
待つコルーチンです:

     import asyncio
     import socket

     async def wait_for_data():
         # Get a reference to the current event loop because
         # we want to access low-level APIs.
         loop = asyncio.get_running_loop()

         # Create a pair of connected sockets.
         rsock, wsock = socket.socketpair()

         # Register the open socket to wait for data.
         reader, writer = await asyncio.open_connection(sock=rsock)

         # Simulate the reception of data from the network
         loop.call_soon(wsock.send, 'abc'.encode())

         # Wait for data
         data = await reader.read(100)

         # Got data, we are done: close the socket
         print("Received:", data.decode())
         writer.close()
         await writer.wait_closed()

         # Close the second socket
         wsock.close()

     asyncio.run(wait_for_data())

参考
....

*note
プロトコルを使ってオープンしたソケットをデータ待ち受けのために登録する:
3180. 例では、低水準のプロトコルと *note loop.create_connection(): 5ce.
メソッドを使っています。

*note ファイル記述子の読み出しイベントを監視する: 3181. 例では、低水準の
*note loop.add_reader(): 3182. メソッドを使ってファイル記述子を監視して
います。


File: python.info,  Node: 同期プリミティブ<2>,  Next: サブプロセス,  Prev: ストリーム,  Up: asyncio --- 非同期 I/O

5.18.1.30 同期プリミティブ
..........................

'ソースコード:' Lib/asyncio/locks.py(1)

__________________________________________________________________

asyncio の同期プリミティブは *note threading: d6. モジュールのそれと類似
するようにデザインされていますが、2つの重要な注意事項があります:

   * asyncio の同期プリミティブはスレッドセーフではありません。従って OS
     スレッドの同期に使うべきではありません (代わりに *note threading:
     d6. を使ってください);

   * 同期プリミティブのメソッドは 'timeout' 引数を受け付けません; タイム
     アウトを伴う操作を実行するには *note asyncio.wait_for(): 5ca. 関数
     を使ってください。

asyncio モジュールは以下の基本的な同期プリミティブを持っています:

   * *note Lock: a3f.

   * *note Event: a40.

   * *note Condition: a41.

   * *note Semaphore: a42.

   * *note BoundedSemaphore: a43.

   * *note Barrier: 5cc.

__________________________________________________________________

* Menu:

* Lock::
* Event::
* Condition::
* Semaphore::
* BoundedSemaphore::
* Barrier::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/asyncio/locks.py


File: python.info,  Node: Lock,  Next: Event,  Up: 同期プリミティブ<2>

5.18.1.31 Lock
..............

 -- クラス: asyncio.Lock

     asyncio タスクのためのミューテックスロックを実装しています。スレッ
     ドセーフではありません。

     asyncio ロックは、共有リソースに対する排他的なアクセスを保証するた
     めに使うことができます。

     Lock の望ましい使用方法は、 *note async with: 59f. 文と組み合わせて
     使うことです:

          lock = asyncio.Lock()

          # ... later
          async with lock:
              # access shared state

     これは以下のコードと等価です:

          lock = asyncio.Lock()

          # ... later
          await lock.acquire()
          try:
              # access shared state
          finally:
              lock.release()

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

      -- メソッド: coroutine acquire ()

          ロックを獲得します。

          このメソッドはロックが '解除される' まで待機し、ロックを 'ロッ
          ク状態' に変更して ‘True’ を返します。

          複数のコルーチンが *note acquire(): 3186. メソッドによりロック
          の解除を待ち受けている場合、最終的にただひとつのコルーチンが実
          行されます。

          ロックの獲得は '公平' です: すなわちロックを獲得して実行される
          コルーチンは、最初にロックの待ち受けを開始したコルーチンです。

      -- メソッド: release ()

          ロックを解放します。

          ロックが 'ロック状態' の場合、 ロックを '解除状態' にしてリタ
          ーンします。

          ロックが '解除状態' の場合、 *note RuntimeError: 17a. 例外が送
          出されます。

      -- メソッド: locked ()

          'ロック状態' の場合に ‘True’ を返します。


File: python.info,  Node: Event,  Next: Condition,  Prev: Lock,  Up: 同期プリミティブ<2>

5.18.1.32 Event
...............

 -- クラス: asyncio.Event

     イベントオブジェクトです。スレッドセーフではありません。

     asyncio イベントは、複数の asyncio タスクに対して何らかのイベントが
     発生したことを通知するために使うことができます。

     Event オブジェクトは内部フラグを管理します。フラグの値は *note
     set(): 318a. メソッドにより 'true' に、また *note clear(): 318b. メ
     ソッドにより 'false' に設定することができます。 *note wait(): 318c.
     メソッドはフラグが 'true' になるまで処理をブロックします。フラグの
     初期値は 'false' です。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     以下はプログラム例です:

          async def waiter(event):
              print('waiting for it ...')
              await event.wait()
              print('... got it!')

          async def main():
              # Create an Event object.
              event = asyncio.Event()

              # Spawn a Task to wait until 'event' is set.
              waiter_task = asyncio.create_task(waiter(event))

              # Sleep for 1 second and set the event.
              await asyncio.sleep(1)
              event.set()

              # Wait until the waiter task is finished.
              await waiter_task

          asyncio.run(main())

      -- メソッド: coroutine wait ()

          イベントがセットされるまで待機します。

          イベントがセットされると、即座に ‘True’ を返します。 そうでな
          ければ、他のタスクが *note set(): 318a. メソッドを呼び出すまで
          処理をブロックします。

      -- メソッド: set ()

          イベントをセットします。

          イベントがセットされるまで待機している全てのタスクは、即座に通
          知を受けて実行を再開します。

      -- メソッド: clear ()

          イベントをクリア (アンセット) します

          *note wait(): 318c. メソッドで待ち受けを行うタスクは *note
          set(): 318a. メソッドが再度呼び出されるまで処理をブロックしま
          す。

      -- メソッド: is_set ()

          イベントがセットされている場合 ‘True’ を返します。


File: python.info,  Node: Condition,  Next: Semaphore,  Prev: Event,  Up: 同期プリミティブ<2>

5.18.1.33 Condition
...................

 -- クラス: asyncio.Condition (lock=None)

     条件変数オブジェクトです。スレッドセーフではありません。

     asyncio 条件プリミティブは何らかのイベントが発生するのを待ち受け、
     そのイベントを契機として共有リソースへの排他的なアクセスを得るため
     に利用することができます。

     本質的に、 Condition オブジェクトは *note Event: a40. と a *note
     Lock: a3f. の2つのクラスの機能を組み合わせたものです。複数の
     Condition オブジェクトが単一の Lock を共有することでができます。こ
     れにより、共有リソースのそれぞれの状態に関連する異なるタスクの間で
     、そのリソースへの排他的アクセスを調整することが可能になります。

     オプション引数 'lock' は *note Lock: a3f. または ‘None’ でなければ
     なりません。後者の場合自動的に新しい Lock オブジェクトが生成されま
     す。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     Condition の望ましい使用方法は *note async with: 59f. 文と組み合わ
     せて使うことです:

          cond = asyncio.Condition()

          # ... later
          async with cond:
              await cond.wait()

     これは以下のコードと等価です:

          cond = asyncio.Condition()

          # ... later
          await cond.acquire()
          try:
              await cond.wait()
          finally:
              cond.release()

      -- メソッド: coroutine acquire ()

          下層でのロックを獲得します。

          このメソッドは下層のロックが '解除される' まで待機し、ロックを
          'ロック状態' に変更して ‘True’ を返します。

      -- メソッド: notify (n=1)

          Wake up 'n' tasks (1 by default) waiting on this condition.
          If fewer than 'n' tasks are waiting they are all awakened.

          このメソッドが呼び出される前にロックを獲得しておかなければなり
          ません。また、メソッド呼び出し後速やかにロックを解除しなければ
          なりません。 '解除された' ロックとと共に呼び出された場合、
          *note RuntimeError: 17a. 例外が送出されます。

      -- メソッド: locked ()

          下層のロックを獲得していれば ‘True’ を返します。

      -- メソッド: notify_all ()

          この条件を待ち受けている全てのタスクを起動します。

          このメソッドは *note notify(): 15de. と同じように振る舞います
          が、待ち受けている全てのタスクを起動します。

          このメソッドが呼び出される前にロックを獲得しておかなければなり
          ません。また、メソッド呼び出し後速やかにロックを解除しなければ
          なりません。 '解除された' ロックとと共に呼び出された場合、
          *note RuntimeError: 17a. 例外が送出されます。

      -- メソッド: release ()

          下層のロックを解除します。

          アンロック状態のロックに対して呼び出された場合、*note
          RuntimeError: 17a. が送出されます。

      -- メソッド: coroutine wait ()

          通知を受けるまで待機します。

          このメソッドが呼び出された時点で呼び出し元のタスクがロックを獲
          得していない場合、 *note RuntimeError: 17a. 例外が送出されます
          。

          このメソッドは下層のロックを解除し、その後 *note notify():
          15de. または *note notify_all(): 3192. の呼び出しによって起動
          されるまで処理をブロックします。いったん起動されると、
          Condition は再びロックを獲得し、メソッドは ‘True’ を返します。

          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 *note wait(): 44c. again.  For this reason, you
          may prefer to use *note wait_for(): 5ca. instead.

      -- メソッド: coroutine wait_for (predicate)

          引数 predicate の条件が '真' になるまで待機します。

          The predicate must be a callable which result will be
          interpreted as a boolean value.  The method will repeatedly
          *note wait(): 44c. until the predicate evaluates to 'true'.
          The final value is the return value.


File: python.info,  Node: Semaphore,  Next: BoundedSemaphore,  Prev: Condition,  Up: 同期プリミティブ<2>

5.18.1.34 Semaphore
...................

 -- クラス: asyncio.Semaphore (value=1)

     セマフォオブジェクトです。スレッドセーフではありません。

     セマフォは内部のカウンターを管理しています。カウンターは *note
     acquire(): 160a. メソッドの呼び出しによって減算され、 *note
     release(): 3196. メソッドの呼び出しによって加算されます。カウンター
     がゼロを下回ることはありません。 *note acquire(): 160a. メソッドが
     呼び出された時にカウンターがゼロになっていると、セマフォは処理をブ
     ロックし、他のタスクが *note release(): 3196. メソッドを呼び出すま
     で待機します。

     オプション引数 'value' は内部カウンターの初期値を与えます (デフォル
     トは ‘1’ です)。 指定された値が ‘0’ より小さい場合、 *note
     ValueError: 1e3. 例外が送出されます。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     セマフォの望ましい使用方法は、 *note async with: 59f. 文と組み合わ
     せて使うことです:

          sem = asyncio.Semaphore(10)

          # ... later
          async with sem:
              # work with shared resource

     これは以下のコードと等価です:

          sem = asyncio.Semaphore(10)

          # ... later
          await sem.acquire()
          try:
              # work with shared resource
          finally:
              sem.release()

      -- メソッド: coroutine acquire ()

          セマフォを獲得します。

          内部カウンターがゼロより大きい場合、カウンターを1つ減算して即
          座に ‘True’ を返します。内部カウンターがゼロの場合、 *note
          release(): 3196. が呼び出されるまで待機してから ‘True’ を返し
          ます。

      -- メソッド: locked ()

          セマフォを直ちに獲得できない場合 ‘True’ を返します。

      -- メソッド: release ()

          セマフォを解放し、内部カウンターを1つ加算します。セマフォ待ち
          をしているタスクを起動する可能性があります。

          *note BoundedSemaphore: a43. と異なり、 *note Semaphore: a42.
          は ‘release()’ を ‘acquire()’ よりも多く呼び出すことを許容しま
          す。


File: python.info,  Node: BoundedSemaphore,  Next: Barrier,  Prev: Semaphore,  Up: 同期プリミティブ<2>

5.18.1.35 BoundedSemaphore
..........................

 -- クラス: asyncio.BoundedSemaphore (value=1)

     有限セマフォオブジェクトです。スレッドセーフではありません。

     有限セマフォは *note Semaphore: a42. の一種で、 *note release():
     3196. メソッドの呼び出しにより内部カウンターが '初期値' よりも増加
     してしまう場合は *note ValueError: 1e3. 例外を送出します。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。


File: python.info,  Node: Barrier,  Prev: BoundedSemaphore,  Up: 同期プリミティブ<2>

5.18.1.36 Barrier
.................

 -- クラス: asyncio.Barrier (parties)

     A barrier object.  Not thread-safe.

     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 *note wait(): 319a. method and would be blocked until
     the specified number of tasks end up waiting on *note wait(): 319a.
     At that point all of the waiting tasks would unblock
     simultaneously.

     *note async with: 59f. can be used as an alternative to awaiting on
     *note wait(): 319a.

     The barrier can be reused any number of times.  以下はプログラム例
     です:

          async def example_barrier():
             # barrier with 3 parties
             b = asyncio.Barrier(3)

             # create 2 new waiting tasks
             asyncio.create_task(b.wait())
             asyncio.create_task(b.wait())

             await asyncio.sleep(0)
             print(b)

             # The third .wait() call passes the barrier
             await b.wait()
             print(b)
             print("barrier passed")

             await asyncio.sleep(0)
             print(b)

          asyncio.run(example_barrier())

     Result of this example is:

          <asyncio.locks.Barrier object at 0x... [filling, waiters:2/3]>
          <asyncio.locks.Barrier object at 0x... [draining, waiters:0/3]>
          barrier passed
          <asyncio.locks.Barrier object at 0x... [filling, waiters:0/3]>

     Added in version 3.11.

      -- メソッド: coroutine wait ()

          Pass the barrier.  When all the tasks party to the barrier
          have called this function, they are all unblocked
          simultaneously.

          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.

          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.:

               ...
               async with barrier as position:
                  if position == 0:
                     # Only one task prints this
                     print('End of *draining phase*')

          This method may raise a *note BrokenBarrierError: 5cd.
          exception if the barrier is broken or reset while a task is
          waiting.  It could raise a *note CancelledError: 19d. if a
          task is cancelled.

      -- メソッド: coroutine reset ()

          Return the barrier to the default, empty state.  Any tasks
          waiting on it will receive the *note BrokenBarrierError: 5cd.
          exception.

          If a barrier is broken it may be better to just leave it and
          create a new one.

      -- メソッド: coroutine abort ()

          Put the barrier into a broken state.  This causes any active
          or future calls to *note wait(): 44c. to fail with the *note
          BrokenBarrierError: 5cd.  Use this for example if one of the
          tasks needs to abort, to avoid infinite waiting tasks.

      -- の属性: parties

          The number of tasks required to pass the barrier.

      -- の属性: n_waiting

          The number of tasks currently waiting in the barrier while
          filling.

      -- の属性: broken

          バリアが broken な状態である場合に ‘True’ となるブール値。

 -- 例外: asyncio.BrokenBarrierError

     *note Barrier: 5cc. オブジェクトがリセットされるか broken な場合に
     、この例外 (*note RuntimeError: 17a. のサブクラス) が送出されます。

__________________________________________________________________

バージョン 3.9 で変更: ‘await lock’ や ‘yield from lock’ およびそれらと
*note with: 59c. 文との組み合わせ (すなわち ‘with await lock’ や ‘with
(yield from lock)’) によるロックの獲得は削除されました。代わりに ‘async
with lock’ を使ってください。


File: python.info,  Node: サブプロセス,  Next: キュー,  Prev: 同期プリミティブ<2>,  Up: asyncio --- 非同期 I/O

5.18.1.37 サブプロセス
......................

'ソースコード:' Lib/asyncio/subprocess.py(1),
Lib/asyncio/base_subprocess.py(2)

__________________________________________________________________

このセクションはサブプロセスの生成と管理を行う高水準の async/await
asyncio API について説明します。 以下は、 asyncio モジュールがどのように
シェルコマンドを実行し、結果を取得できるかを示す例です:

     import asyncio

     async def run(cmd):
         proc = await asyncio.create_subprocess_shell(
             cmd,
             stdout=asyncio.subprocess.PIPE,
             stderr=asyncio.subprocess.PIPE)

         stdout, stderr = await proc.communicate()

         print(f'[{cmd!r} exited with {proc.returncode}]')
         if stdout:
             print(f'[stdout]\n{stdout.decode()}')
         if stderr:
             print(f'[stderr]\n{stderr.decode()}')

     asyncio.run(run('ls /zzz'))

このサンプルコードは以下を出力します:

     ['ls /zzz' exited with 1]
     [stderr]
     ls: /zzz: No such file or directory

全ての asyncio のサブプロセス関数は非同期ですが、 asyncio モジュールはこ
れらの非同期関数と協調するための多くのツールを提供しているので、複数のサ
ブプロセスを並列に実行して監視することは簡単です。実際、上記のサンプルコ
ードを複数のコマンドを同時に実行するように修正するのはきわめて単純です:

     async def main():
         await asyncio.gather(
             run('ls /zzz'),
             run('sleep 1; echo "hello"'))

     asyncio.run(main())

*note 使用例: 31a4. 節も参照してください。

* Menu:

* サブプロセスの生成::
* 定数: 定数<7>.
* サブプロセスとやりとりする::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/subprocess.py

   (2) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/base_subprocess.py


File: python.info,  Node: サブプロセスの生成,  Next: 定数<7>,  Up: サブプロセス

5.18.1.38 サブプロセスの生成
............................

 -- の関数: coroutine asyncio.create_subprocess_exec (program, *args,
          stdin=None, stdout=None, stderr=None, limit=None, **kwds)

     サブプロセスを作成します。

     The 'limit' argument sets the buffer limit for *note StreamReader:
     1830. wrappers for ‘Process.stdout’ and ‘Process.stderr’ (if *note
     subprocess.PIPE: b55. is passed to 'stdout' and 'stderr'
     arguments).

     *note Process: 31a6. のインスタンスを返します。

     他のパラメータについては *note loop.subprocess_exec(): 31a7. を参照
     してください。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

 -- の関数: coroutine asyncio.create_subprocess_shell (cmd, stdin=None,
          stdout=None, stderr=None, limit=None, **kwds)

     シェルコマンド 'cmd' を実行します。

     The 'limit' argument sets the buffer limit for *note StreamReader:
     1830. wrappers for ‘Process.stdout’ and ‘Process.stderr’ (if *note
     subprocess.PIPE: b55. is passed to 'stdout' and 'stderr'
     arguments).

     *note Process: 31a6. のインスタンスを返します。

     他のパラメータについては *note loop.subprocess_shell(): 31a8. のド
     キュメントを参照してください。

          重要: シェルインジェクション(1) の脆弱性を回避するために全ての
          空白文字および特殊文字を適切にクオートすることは、アプリケーシ
          ョン側の責任で確実に行ってください。シェルコマンドを構成する文
          字列内の空白文字と特殊文字のエスケープは、 *note
          shlex.quote(): 25e. 関数を使うと適切に行うことができます。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     注釈: サブプロセスは、 *note ProactorEventLoop: 5d4. を使えば
     Windows でも利用可能です。詳しくは *note Windows
     におけるサブプロセスのサポート: 31a9. を参照してください。

参考
....

asyncio は以下に挙げるサブプロセスと協調するための '低水準の' API も持っ
ています: *note loop.subprocess_exec(): 31a7, *note
loop.subprocess_shell(): 31a8, *note loop.connect_read_pipe(): 31aa,
*note loop.connect_write_pipe(): 31ab. および *note Subprocess
Transports: 31ac. と *note Subprocess Protocols: 31ad.。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Shell_injection#Shell_injection


File: python.info,  Node: 定数<7>,  Next: サブプロセスとやりとりする,  Prev: サブプロセスの生成,  Up: サブプロセス

5.18.1.39 定数
..............

 -- データ: asyncio.subprocess.PIPE

     'stdin', 'stdout' または 'stderr' に渡すことができます。

     'PIPE' が 'stdin' 引数に渡された場合、 *note Process.stdin: 31b0. 属
     性は ‘StreamWriter’ インスタンスを指します。

     'PIPE' が 'stdout' や 'stderr' 引数に渡された場合、 *note
     Process.stdout: 31b1. と *note Process.stderr: 31b2. 属性は
     ‘StreamReader’ インスタンスを指します。

 -- データ: asyncio.subprocess.STDOUT

     'stderr' 引数に対して利用できる特殊な値で、標準エラー出力が標準出力
     にリダイレクトされることを意味します。

 -- データ: asyncio.subprocess.DEVNULL

     プロセスを生成する関数の 'stdin', 'stdout' または 'stderr' 引数に利
     用できる特殊な値です。対応するサブプロセスのストリームに特殊なファ
     イル *note os.devnull: 199e. が使われることを意味します。


File: python.info,  Node: サブプロセスとやりとりする,  Prev: 定数<7>,  Up: サブプロセス

5.18.1.40 サブプロセスとやりとりする
....................................

*note create_subprocess_exec(): a45. と *note create_subprocess_shell():
a46. の2つの関数はどちらも 'Process' クラスのインスタンスを返します。
'Process' クラスはサブプロセスと通信したり、サブプロセスの完了を監視した
りするための高水準のラッパーです。

 -- クラス: asyncio.subprocess.Process

     関数 ‘create_subprocess_exec()’ や ‘create_subprocess_shell()’ によ
     って生成された OS のプロセスをラップするオブジェクトです。

     このクラスは *note subprocess.Popen: 17e. クラスと同様の API を持つ
     ように設計されていますが、いくつかの注意すべき違いがあります:

        * Popen と異なり、 Process インスタンスは *note poll(): 30c4. メ
          ソッドに相当するメソッドを持っていません;

        * the *note communicate(): 1696. and *note wait(): 31b6. methods
          don't have a 'timeout' parameter: use the *note wait_for():
          5ca. function;

        * *note subprocess.Popen.wait(): cb2. メソッドが同期処理のビジー
          ループとして実装されているのに対して、 *note Process.wait():
          31b6. メソッドは非同期処理です;

        * 'universal_newlines' パラメータはサポートされていません。

     このクラスは *note スレッド安全ではありません: 3151.。

     *note サブプロセスとスレッド: 31b7. 節も参照してください。

      -- メソッド: coroutine wait ()

          子プロセスが終了するのを待ち受けます。

          *note returncode: 31b8. 属性を設定し、その値を返します。

               注釈: ‘stdout=PIPE’ または ‘stderr=PIPE’ を使っており、OS
               パイプバッファがさらなるデータを受け付けるようになるまで
               子プロセスをブロックするほど大量の出力を生成場合、このメ
               ソッドはデッドロックする可能性があります。この条件を避け
               るため、パイプを使用する場合は *note communicate(): 1696.
               メソッドを使ってください。

      -- メソッド: coroutine communicate (input=None)

          プロセスとのやりとりを行います:

            1. 'stdin' にデータを送信します ('input' が ‘None’ でない場
               合);

            2. 'stdin' を閉じます;

            3. EOF に達するまで 'stdout' および 'stderr' からデータを読
               み出します;

            4. プロセスが終了するまで待ち受けます。

          'input' オプション引数は子プロセスに送信されるデータ (*note
          bytes: 1a4. オブジェクト) です。

          ‘(stdout_data, stderr_data)’ のタプルを返します。

          'input' を標準入力 'stdin' nに書き込んでいる時に *note
          BrokenPipeError: 1030. または *note ConnectionResetError:
          1033. 例外が送出された場合、例外は無視されます。このような条件
          は、全てのデータが 'stdin' に書き込まれる前にプロセスが終了し
          た場合に起こります。

          子プロセスの標準入力 'stdin' にデータを送りたい場合、プロセス
          は ‘stdin=PIPE’ を設定して生成する必要があります。同様に、
          ‘None’ 以外の何らかのデータを戻り値のタプルで受け取りたい場合
          、プロセスは ‘stdout=PIPE’ と ‘stderr=PIPE’ のいずれかまたは両
          方を指定して生成しなければなりません。

          プロセスから受信したデータはメモリ上にバッファーされることに注
          意してください。そのため、返されるデータのサイズが大きいかまた
          は無制限の場合はこのメソッドを使わないようにしてください。

          バージョン 3.12 で変更: ‘input=None’ のときも 'stdin' は閉じら
          れます。

      -- メソッド: send_signal (signal)

          子プロセスにシグナル 'signal' を送信します。

               注釈: On Windows, *note SIGTERM: 1387. is an alias for
               *note terminate(): 31b9.  ‘CTRL_C_EVENT’ and
               ‘CTRL_BREAK_EVENT’ can be sent to processes started with
               a 'creationflags' parameter which includes
               ‘CREATE_NEW_PROCESS_GROUP’.

      -- メソッド: terminate ()

          子プロセスを停止します。

          On POSIX systems this method sends *note SIGTERM: 1387. to the
          child process.

          On Windows the Win32 API function ‘TerminateProcess()’ is
          called to stop the child process.

      -- メソッド: kill ()

          子プロセスを強制終了 (kill) します。

          POSIX システムの場合、このメソッドは子プロセスに ‘SIGKILL’ シ
          グナルを送信します。

          Windows では、このメソッドは *note terminate(): 31b9. のエイリ
          アスです。

      -- の属性: stdin

          標準入力ストリーム (‘StreamWriter’) です。プロセスが
          ‘stdin=None’ で生成された場合は ‘None’ になります。

      -- の属性: stdout

          標準出力ストリーム (‘StreamReader’) です。プロセスが
          ‘stdout=None’ で生成された場合は ‘None’ になります。

      -- の属性: stderr

          標準エラー出力ストリーム (‘StreamReader’) です。プロセスが
          ‘stderr=None’ で生成された場合は ‘None’ になります。

          警告: Use the *note communicate(): 1696. method rather than
          *note process.stdin.write(): 31b0, *note await
          process.stdout.read(): 31b1. or *note await
          process.stderr.read(): 31b2.  This avoids deadlocks due to
          streams pausing reading or writing and blocking the child
          process.

      -- の属性: pid

          子プロセスのプロセス番号 (PID) です。

          ‘create_subprocess_shell()’ 関数によって生成されたプロセスの場
          合、この属性は生成されたシェルの PID になることに注意してくだ
          さい。

      -- の属性: returncode

          プロセスが終了した時の終了ステータスを返します。

          この属性が ‘None’ であることは、プロセスがまだ終了していないこ
          とを示しています。

          負の値 ‘-N’ は子プロセスがシグナル ‘N’ により中止させられたこ
          とを示します (POSIX のみ)。

* Menu:

* サブプロセスとスレッド::
* 使用例: 使用例<22>.


File: python.info,  Node: サブプロセスとスレッド,  Next: 使用例<22>,  Up: サブプロセスとやりとりする

5.18.1.41 サブプロセスとスレッド
................................

標準的な asyncio のイベントループは、異なるスレッドからサブプロセスを実
行するのをデフォルトでサポートしています。

Windows のサブプロセスは *note ProactorEventLoop: 5d4. (デフォルト) のみ
提供され、 *note SelectorEventLoop: 5d3. はサブプロセスをサポートしてい
ません。

UNIX の 'child watchers' はサブプロセスの終了を待ち受けるために使われま
す。より詳しい情報については *note プロセスのウオッチャー: 31bd. を参照
してください。

バージョン 3.8 で変更: UNIX では、異なるスレッドから何らの制限なくサブプ
ロセスを生成するために *note ThreadedChildWatcher: 448. を使うようになり
ました。

現在の子プロセスのウオッチャーが 'アクティブでない' 場合にサブプロセスを
生成すると *note RuntimeError: 17a. 例外が送出されます。

標準で提供されない別のイベントループ実装の場合、固有の制限がある可能性が
あります; それぞれの実装のドキュメントを参照してください。

参考
....

*note 並行処理とマルチスレッド処理: 3151.


File: python.info,  Node: 使用例<22>,  Prev: サブプロセスとスレッド,  Up: サブプロセスとやりとりする

5.18.1.42 使用例
................

サブプロセスの制御のために *note Process: 31a6. クラスを使い、サブプロセ
スの標準出力を読み出すために *note StreamReader: 1830. を使う例です。 サ
ブプロセスは *note create_subprocess_exec(): a45. 関数により生成されます
:

     import asyncio
     import sys

     async def get_date():
         code = 'import datetime; print(datetime.datetime.now())'

         # Create the subprocess; redirect the standard output
         # into a pipe.
         proc = await asyncio.create_subprocess_exec(
             sys.executable, '-c', code,
             stdout=asyncio.subprocess.PIPE)

         # Read one line of output.
         data = await proc.stdout.readline()
         line = data.decode('ascii').rstrip()

         # Wait for the subprocess exit.
         await proc.wait()
         return line

     date = asyncio.run(get_date())
     print(f"Current date: {date}")

低水準の API を使って書かれた *note 同様の例: 31bf. も参照してください。


File: python.info,  Node: キュー,  Next: 例外<12>,  Prev: サブプロセス,  Up: asyncio --- 非同期 I/O

5.18.1.43 キュー
................

'ソースコード:' Lib/asyncio/queues.py(1)

__________________________________________________________________

asyncio キューは *note queue: a4. モジュールのクラス群と同じ形になるよう
に設計されています。 asyncio キューはスレッドセーフではありませんが、そ
れらは async/await コードから使われるために特別に設計されています。

asyncio キューのメソッドは 'timeout' パラメータを持たないことに注意して
ください; タイムアウトを伴うキューを使った処理を行うには *note
asyncio.wait_for(): 5ca. 関数を使ってください。

下記の *note 使用例: 31c2. 節も参照してください。

* Menu:

* Queue::
* 優先度付きのキュー::
* LIFO キュー::
* 例外: 例外<11>.
* 使用例: 使用例<23>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/asyncio/queues.py


File: python.info,  Node: Queue,  Next: 優先度付きのキュー,  Up: キュー

5.18.1.44 Queue
...............

 -- クラス: asyncio.Queue (maxsize=0)

     先入れ先出し (FIFO) キューです。

     'maxsize' がゼロ以下の場合、キューは無限長になります。 ‘0’ より大き
     い整数の場合、キューが 'maxsize' に達すると ‘await put()’ は *note
     get(): 31c4. によってキューの要素が除去されるまでブロックします。

     標準ライブラリにおけるスレッドベースの *note queue: a4. モジュール
     と異なり、キューのサイズは常に既知であり、 *note qsize(): 31c5. メ
     ソッドを呼び出すことによって取得することができます。

     バージョン 3.10 で変更: 'loop' パラメータが削除されました。

     このクラスは *note スレッド安全ではありません: 3151.。

      -- の属性: maxsize

          キューに追加できるアイテム数です。

      -- メソッド: empty ()

          キューが空ならば ‘True’ を、そうでなければ ‘False’ を返します
          。

      -- メソッド: full ()

          キューに要素が *note maxsize: 31c6. 個あれば ‘True’ を返します
          。

          If the queue was initialized with ‘maxsize=0’ (the default),
          then *note full(): 31c8. never returns ‘True’.

      -- メソッド: coroutine get ()

          キューから要素を削除して返します。キューが空の場合項目が利用可
          能になるまで待機します。

          Raises *note QueueShutDown: 196. if the queue has been shut
          down and is empty, or if the queue has been shut down
          immediately.

      -- メソッド: get_nowait ()

          直ちに利用できるアイテムがあるときはそれを、そうでなければ
          *note QueueEmpty: 31ca. を返します。

      -- メソッド: coroutine join ()

          キューにある全ての要素が取得され、処理されるまでブロックします
          。

          未完了のタスクのカウント値は、キューにアイテムが追加されるとき
          は常に加算され、キューの要素を消費するコルーチンが要素を取り出
          し、処理を完了したことを通知するために *note task_done(): d96.
          を呼び出すと減算されます。未完了のタスクのカウント値がゼロにな
          ると、 *note join(): d95. のブロックは解除されます。

      -- メソッド: coroutine put (item)

          要素をキューに入力します。キューが満杯の場合、要素を追加する前
          に空きスロットが利用できるようになるまで待機します。

          Raises *note QueueShutDown: 196. if the queue has been shut
          down.

      -- メソッド: put_nowait (item)

          ブロックせずにアイテムをキューに追加します。

          直ちに利用できるスロットがない場合、*note QueueFull: 31cd. を
          送出します。

      -- メソッド: qsize ()

          キュー内の要素数を返します。

      -- メソッド: shutdown (immediate=False)

          Shut down the queue, making *note get(): 31c4. and *note
          put(): 31cb. raise *note QueueShutDown: 196.

          By default, *note get(): 31c4. on a shut down queue will only
          raise once the queue is empty.  Set 'immediate' to true to
          make *note get(): 31c4. raise immediately instead.

          All blocked callers of *note put(): 31cb. and *note get():
          31c4. will be unblocked.  If 'immediate' is true, a task will
          be marked as done for each remaining item in the queue, which
          may unblock callers of *note join(): d95.

          Added in version 3.13.

      -- メソッド: task_done ()

          キューに入っていたタスクが完了したことを示します。

          キューコンシューマーによって使用されます。タスクの取得に *note
          get(): 31c4. を使用し、その後の *note task_done(): d96. の呼び
          出しでタスクの処理が完了したことをキューに通知します。

          *note join(): d95. が現在ブロック中だった場合、全アイテムが処
          理されたとき (*note put(): 31cb. でキューに追加された全アイテ
          ムの *note task_done(): d96. の呼び出しを受信したとき) に再開
          します。

          ‘shutdown(immediate=True)’ calls *note task_done(): d96. for
          each remaining item in the queue.

          キューに追加されているアイテム数以上の呼び出しが行われたときに
          *note ValueError: 1e3. を送出します。


File: python.info,  Node: 優先度付きのキュー,  Next: LIFO キュー,  Prev: Queue,  Up: キュー

5.18.1.45 優先度付きのキュー
............................

 -- クラス: asyncio.PriorityQueue

     *note Queue: a44. の変種です; 優先順位にしたがって要素を取り出しま
     す (最低順位が最初に取り出されます)。

     項目は典型的には ‘(priority_number, data)’ 形式のタプルです。


File: python.info,  Node: LIFO キュー,  Next: 例外<11>,  Prev: 優先度付きのキュー,  Up: キュー

5.18.1.46 LIFO キュー
.....................

 -- クラス: asyncio.LifoQueue

     *note Queue: a44. の変種で、最後に追加された項目を最初に取り出しま
     す (後入れ先出し、またはスタック)。


File: python.info,  Node: 例外<11>,  Next: 使用例<23>,  Prev: LIFO キュー,  Up: キュー

5.18.1.47 例外
..............

 -- 例外: asyncio.QueueEmpty

     この例外は *note get_nowait(): 31c9. メソッドが空のキューに対して呼
     ばれたときに送出されます。

 -- 例外: asyncio.QueueFull

     サイズが 'maxsize' に達したキューに対して *note put_nowait(): 31cc.
     メソッドが 呼ばれたときに送出される例外です。

 -- 例外: asyncio.QueueShutDown

     Exception raised when *note put(): 31cb. or *note get(): 31c4. is
     called on a queue which has been shut down.

     Added in version 3.13.


File: python.info,  Node: 使用例<23>,  Prev: 例外<11>,  Up: キュー

5.18.1.48 使用例
................

キューを使って、並行処理を行う複数のタスクにワークロードを分散させること
ができます:

     import asyncio
     import random
     import time


     async def worker(name, queue):
         while True:
             # Get a "work item" out of the queue.
             sleep_for = await queue.get()

             # Sleep for the "sleep_for" seconds.
             await asyncio.sleep(sleep_for)

             # Notify the queue that the "work item" has been processed.
             queue.task_done()

             print(f'{name} has slept for {sleep_for:.2f} seconds')


     async def main():
         # Create a queue that we will use to store our "workload".
         queue = asyncio.Queue()

         # Generate random timings and put them into the queue.
         total_sleep_time = 0
         for _ in range(20):
             sleep_for = random.uniform(0.05, 1.0)
             total_sleep_time += sleep_for
             queue.put_nowait(sleep_for)

         # Create three worker tasks to process the queue concurrently.
         tasks = []
         for i in range(3):
             task = asyncio.create_task(worker(f'worker-{i}', queue))
             tasks.append(task)

         # Wait until the queue is fully processed.
         started_at = time.monotonic()
         await queue.join()
         total_slept_for = time.monotonic() - started_at

         # Cancel our worker tasks.
         for task in tasks:
             task.cancel()
         # Wait until all worker tasks are cancelled.
         await asyncio.gather(*tasks, return_exceptions=True)

         print('====')
         print(f'3 workers slept in parallel for {total_slept_for:.2f} seconds')
         print(f'total expected sleep time: {total_sleep_time:.2f} seconds')


     asyncio.run(main())


File: python.info,  Node: 例外<12>,  Next: イベントループ,  Prev: キュー,  Up: asyncio --- 非同期 I/O

5.18.1.49 例外
..............

'ソースコード:' Lib/asyncio/exceptions.py(1)

__________________________________________________________________

 -- 例外: asyncio.TimeoutError

     操作が指定された期限を超えたときに送出される、非推奨な *note
     TimeoutError: 800. のエイリアス。

     バージョン 3.11 で変更: このクラスは *note TimeoutError: 800. のエ
     イリアスになりました。

 -- 例外: asyncio.CancelledError

     処理がキャンセルされました。

     asyncio タスクがキャンセルされた場合の処理をカスタマイズするために
     、この例外を一旦キャッチすることができます。 ほとんどの場合、キャッ
     チした例外は再度送出しなければなりません。

     バージョン 3.8 で変更: *note CancelledError: 19d. は *note
     Exception: 9a7. ではなく *note BaseException: 584. のサブクラスにな
     りました。

 -- 例外: asyncio.InvalidStateError

     *note Task: 4a5. または *note Future: b9b. の内部状態が不正になりま
     した。

     すでに結果の値が設定されている 'Future' オブジェクトに対してさらに
     結果の値を再び設定しようとする場合などに送出されることがあります。

 -- 例外: asyncio.SendfileNotAvailableError

     与えられたソケットまたはファイルタイプに対して "sendfile" システム
     コールが利用可能ではありません。

     *note RuntimeError: 17a. の派生クラスです。

 -- 例外: asyncio.IncompleteReadError

     要求された読み込み処理が完了できませんでした。

     *note asyncio ストリーム API: 3123. から送出されます。

     この例外は *note EOFError: 12a7. の派生クラスです。

      -- の属性: expected

          期待される総バイト数 (*note int: 238.) です。

      -- の属性: partial

          ストリームの終端に達するまでに読み込んだ *note bytes: 1a4. 文
          字列です。

 -- 例外: asyncio.LimitOverrunError

     区切り文字を探している間にバッファサイズの上限に到達しました。

     *note asyncio ストリーム API: 3123. から送出されます。

      -- の属性: consumed

          未消費のバイトの合計数です。

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/exceptions.py


File: python.info,  Node: イベントループ,  Next: Future,  Prev: 例外<12>,  Up: asyncio --- 非同期 I/O

5.18.1.50 イベントループ
........................

'ソースコード:' Lib/asyncio/profile.py(1) と Lib/asyncio/pstats.py(2)

__________________________________________________________________

まえがき
........

イベントループは全ての asyncio アプリケーションの中核をなす存在です。イ
ベントループは非同期タスクやコールバックを実行し、ネットワーク I/O を処
理し、サブプロセスを実行します。

アプリケーション開発者は通常 *note asyncio.run(): 449. のような高水準の
ayncio 関数だけを利用し、ループオブジェクトを参照したり、ループオブジェ
クトのメソッドを呼び出したりすることはほとんどありません。この節は、イベ
ントループの振る舞いに対して細かい調整が必要な、低水準のコード、ライブラ
リ、フレームワークの開発者向けです。

イベントループの取得
....................

以下の低水準関数はイベントループの取得、設定、生成するために使います:

 -- の関数: asyncio.get_running_loop ()

     現在の OS スレッドで実行中のイベントループを取得します。

     Raise a *note RuntimeError: 17a. if there is no running event loop.

     This function can only be called from a coroutine or a callback.

     Added in version 3.7.

 -- の関数: asyncio.get_event_loop ()

     現在のイベントループを取得します。

     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.

     If there is no running event loop set, the function will return the
     result of the ‘get_event_loop_policy().get_event_loop()’ call.

     この関数の振る舞いは (特にイベントループポリシーをカスタマイズした
     場合) 複雑なため、コルーチンやコールバックでは *note
     get_event_loop(): 2a2. よりも *note get_running_loop(): ad9. を使う
     ほうが好ましいと考えられます。

     As noted above, consider using the higher-level *note
     asyncio.run(): 449. function, instead of using these lower level
     functions to manually create and close an event loop.

     バージョン 3.12 で非推奨: Deprecation warning is emitted if there
     is no current event loop.  In some future Python release this will
     become an error.

 -- の関数: asyncio.set_event_loop (loop)

     Set 'loop' as the current event loop for the current OS thread.

 -- の関数: asyncio.new_event_loop ()

     新しいイベントループオブジェクトを生成して返します。

*note get_event_loop(): 2a2, *note set_event_loop(): 1735, および *note
new_event_loop(): 3130. 関数の振る舞いは、 *note
カスタムイベントループポリシーを設定する: 31dc. ことにより変更することが
できます。

内容
....

このページは以下の節から構成されます:

   * *note イベントループのメソッド: 31dd. 節は、イベントループ API のリ
     ファレンスです。

   * *note コールバックハンドル: 31de. 節は *note loop.call_soon(): ad2.
     や *note loop.call_later(): ad4. などのスケジューリングメソッドが返
     す *note Handle: 1a0e. や *note TimerHandle: 16d8. インスタンスにつ
     いて解説しています。

   * *note サーバーオブジェクト: 31df. 節は *note loop.create_server():
     ae1. のようなメソッドが返す型について解説しています。

   * *note イベントループの実装: 31e0. 節は *note SelectorEventLoop:
     5d3. と *note ProactorEventLoop: 5d4. の2つのクラスについて解説して
     います。

   * *note 使用例: 31e1. 節ではイベントループ API の具体的な使い方を紹介
     しています。

* Menu:

* イベントループのメソッド::
* コールバックのハンドル::
* Serverオブジェクト::
* イベントループの実装::
* 使用例: 使用例<24>.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/profile.py

   (2) https://github.com/python/cpython/tree/3.13/Lib/asyncio/pstats.py


File: python.info,  Node: イベントループのメソッド,  Next: コールバックのハンドル,  Up: イベントループ

5.18.1.51 イベントループのメソッド
..................................

イベントループは以下の '低水準な' API を持っています:

* Menu:

* ループの開始と停止::
* コールバックのスケジューリング::
* 遅延コールバックのスケジューリング::
* フューチャーとタスクの生成::
* ネットワーク接続の確立::
* ネットワークサーバの生成::
* ファイルの転送::
* TLS へのアップグレード::
* ファイル記述子の監視::
* ソケットオブジェクトと直接やりとりする::
* DNS::
* パイプとやりとりする::
* Unix シグナル::
* スレッドまたはプロセスプールでコードを実行する::
* エラーハンドリング API::
* デバッグモードの有効化::
* サブプロセスの実行::


File: python.info,  Node: ループの開始と停止,  Next: コールバックのスケジューリング,  Up: イベントループのメソッド

5.18.1.52 ループの開始と停止
............................

 -- メソッド: loop.run_until_complete (future)

     'フューチャー' (*note Future: b9b. インスタンス) が完了するまで実行
     します。

     引数が *note コルーチンオブジェクト: 3122. の場合、暗黙のうちに
     *note asyncio.Task: 4a5. として実行されるようにスケジュールされます
     。

     Future の結果を返すか、例外を送出します。

 -- メソッド: loop.run_forever ()

     *note stop(): c4a. が呼び出されるまでイベントループを実行します。

     If *note stop(): c4a. is called before *note run_forever(): 31e4.
     is called, the loop will poll the I/O selector once with a timeout
     of zero, run all callbacks scheduled in response to I/O events (and
     those that were already scheduled), and then exit.

     *note run_forever(): 31e4. メソッドを実行中に *note stop(): c4a. メ
     ソッドが呼び出された場合、イベントループは現在処理されているすべて
     のコールバックを実行してから終了します。 この場合、コールバックによ
     り新たにスケジュールされるコールバックは実行されないことに注意して
     ください; これら新たにスケジュールされたコールバックは、次に *note
     run_forever(): 31e4. または *note run_until_complete(): c45. が呼び
     出されたときに実行されます。

 -- メソッド: loop.stop ()

     イベントループを停止します。

 -- メソッド: loop.is_running ()

     イベントループが現在実行中の場合 ‘True’ を返します。

 -- メソッド: loop.is_closed ()

     イベントループが閉じられていた場合 ‘True’ を返します。

 -- メソッド: loop.close ()

     イベントループをクローズします。

     この関数が呼び出される時点で、イベントループが実行中であってはいけ
     ません。保留中のコールバックはすべて破棄されます。

     このメソッドは全てのキューをクリアし、エグゼキューターが実行完了す
     るのを待たずにシャットダウンします。

     このメソッドはべき等 (何回実行しても結果は同じ) であり取り消せませ
     ん。イベントループがクローズされた後、他のいかなるメソッドも呼び出
     すべきではありません。

 -- メソッド: coroutine loop.shutdown_asyncgens ()

     Schedule all currently open *note asynchronous generator: 1f99.
     objects to close with an *note aclose(): 8a6. call.  After calling
     this method, the event loop will issue a warning if a new
     asynchronous generator is iterated.  This should be used to
     reliably finalize all scheduled asynchronous generators.

     *note asyncio.run(): 449. を使った場合はこの関数を呼び出す必要はあ
     りません。

     以下はプログラム例です:

          try:
              loop.run_forever()
          finally:
              loop.run_until_complete(loop.shutdown_asyncgens())
              loop.close()

     Added in version 3.6.

 -- メソッド: coroutine loop.shutdown_default_executor (timeout=None)

     Schedule the closure of the default executor and wait for it to
     join all of the threads in the *note ThreadPoolExecutor: 70d.  Once
     this method has been called, using the default executor with *note
     loop.run_in_executor(): 8b7. will raise a *note RuntimeError: 17a.

     The 'timeout' parameter specifies the amount of time (in *note
     float: 2ce. seconds) the executor will be given to finish joining.
     With the default, ‘None’, the executor is allowed an unlimited
     amount of time.

     If the 'timeout' is reached, a *note RuntimeWarning: 1a2. is
     emitted and the default executor is terminated without waiting for
     its threads to finish joining.

          注釈: Do not call this method when using *note asyncio.run():
          449, as the latter handles default executor shutdown
          automatically.

     Added in version 3.9.

     バージョン 3.12 で変更: Added the 'timeout' parameter.


File: python.info,  Node: コールバックのスケジューリング,  Next: 遅延コールバックのスケジューリング,  Prev: ループの開始と停止,  Up: イベントループのメソッド

5.18.1.53 コールバックのスケジューリング
........................................

 -- メソッド: loop.call_soon (callback, *args, context=None)

     イベントループの次のイテレーションで 'callback' に指定したコールバ
     ック (*note callback: 286a.) を 'args' 引数で呼び出すようにスケジュ
     ールします。

     Return an instance of *note asyncio.Handle: 1a0e, which can be used
     later to cancel the callback.

     コールバックは登録された順に呼び出されます。各コールバックは厳密に
     1回だけ呼び出されます。

     The optional keyword-only 'context' argument specifies a custom
     *note contextvars.Context: 150d. for the 'callback' to run in.
     Callbacks use the current context when no 'context' is provided.

     Unlike *note call_soon_threadsafe(): ad3, this method is not
     thread-safe.

 -- メソッド: loop.call_soon_threadsafe (callback, *args, context=None)

     A thread-safe variant of *note call_soon(): ad2.  When scheduling
     callbacks from another thread, this function 'must' be used, since
     *note call_soon(): ad2. is not thread-safe.

     すでにクローズされたイベントループに対してこのメソッドが呼び出され
     た場合 *note RuntimeError: 17a. 例外を送出します。これはメインアプ
     リケーションが終了しているにもかかわらずセカンダリスレッドでメソッ
     ドが呼び出されるといった場合に起こりえます。

     このドキュメントの *note 並行処理とマルチスレッド処理: 3151. 節を参
     照してください。

     バージョン 3.7 で変更: キーワード引数 'context' が追加されました。
     詳細は PEP 567(1) を参照してください。

     注釈: ほとんどの *note asyncio: 8. モジュールのスケジューリング関数
     は、キーワード引数をコールバックに渡すことを許していません。キーワ
     ード引数を渡すためには *note functools.partial(): 3ed. を使ってくだ
     さい:

          # will schedule "print("Hello", flush=True)"
          loop.call_soon(
              functools.partial(print, "Hello", flush=True))

     asyncio は partial オブジェクトのデバッグメッセージやエラーメッセー
     ジをよりよく可視化することができるため、通常はラムダ式よりも
     partial オブジェクトを使う方が便利です。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0567/


File: python.info,  Node: 遅延コールバックのスケジューリング,  Next: フューチャーとタスクの生成,  Prev: コールバックのスケジューリング,  Up: イベントループのメソッド

5.18.1.54 遅延コールバックのスケジューリング
............................................

イベントループは、コールバック関数を未来のある時点で呼び出されるようにス
ケジュールする仕組みを提供します。イベントループは時刻が戻らない単調な時
計 (monotonic clock) を使って時刻を追跡します。

 -- メソッド: loop.call_later (delay, callback, *args, context=None)

     'delay' 秒経過後にコールバック関数 'callback' を呼び出すようにスケ
     ジュールします。 'delay' には整数または浮動小数点数を指定します。

     *note asyncio.TimerHandle: 16d8. のインスタンスを返します。このイン
     スタンスを使ってスケジュールしたコールバックをキャンセルすることが
     できます。

     'callback' は厳密に一度だけ呼び出されます。2つのコールバックが完全
     に同じ時間にスケジュールされた場合、呼び出しの順序は未定義です。

     オプションの位置引数 'args' はコールバックが呼び出されるときに位置
     引数として渡されます。キーワード引数を指定してコールバックを呼び出
     したい場合は *note functools.partial(): 3ed. を使用してください。

     オプションのキーワード引数 'context' を使って、コールバック
     *callback* を実行する際のコンテキスト *note contextvars.Context:
     150d. を設定することができます。コンテキスト 'context' が指定されな
     い場合は現在のコンテキストが使われます。

     バージョン 3.7 で変更: キーワード引数 'context' が追加されました。
     詳細は PEP 567(1) を参照してください。

     バージョン 3.8 で変更: Python 3.7 またはそれ以前のバージョンでは、
     デフォルトイベントループの実装を利用した場合に遅延時間 'delay' が
     1日を超えることができませんでした。この問題は Python 3.8 で修正され
     ました。

 -- メソッド: loop.call_at (when, callback, *args, context=None)

     絶対値の時刻 'when' (整数または浮動小数点数) にコールバックを呼び出
     すようにスケジュールします。 *note loop.time(): 31eb. と同じ参照時
     刻を使用します。

     このメソッドの振る舞いは *note call_later(): ad4. と同じです。

     *note asyncio.TimerHandle: 16d8. のインスタンスを返します。このイン
     スタンスを使ってスケジュールしたコールバックをキャンセルすることが
     できます。

     バージョン 3.7 で変更: キーワード引数 'context' が追加されました。
     詳細は PEP 567(2) を参照してください。

     バージョン 3.8 で変更: Python 3.7 またはそれ以前のバージョンでは、
     デフォルトイベントループの実装を利用した場合に現在の時刻と 'when' と
     の差が1日を超えることができませんでした。この問題は Python 3.8 で修
     正されました。

 -- メソッド: loop.time ()

     現在の時刻を *note float: 2ce. 値で返します。時刻はイベントループが
     内部で参照している時刻が戻らない単調な時計 (monotonic clock) に従い
     ます。

     注釈: 
     バージョン 3.8 で変更: Python 3.7 またはそれ以前のバージョンでは、
     タイムアウト (相対値 'delay' もしくは絶対値 'when') は1日を超えるこ
     とができませんでした。この問題は Python 3.8 で修正されました。

参考
....

関数 *note asyncio.sleep(): a3d.。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0567/

   (2) https://peps.python.org/pep-0567/


File: python.info,  Node: フューチャーとタスクの生成,  Next: ネットワーク接続の確立,  Prev: 遅延コールバックのスケジューリング,  Up: イベントループのメソッド

5.18.1.55 フューチャーとタスクの生成
....................................

 -- メソッド: loop.create_future ()

     イベントループに接続した *note asyncio.Future: b9b. オブジェクトを
     生成します。

     asyncio でフューチャーオブジェクトを作成するために推奨される方法で
     す。このメソッドにより、サードパーティ製のイベントループがFutures ク
     ラスの(パフォーマンスや計測方法が優れた) 代替実装を提供することを可
     能にします。

     Added in version 3.5.2.

 -- メソッド: loop.create_task (coro, *, name=None, context=None)

     Schedule the execution of *note coroutine: 3122. 'coro'.  Return a
     *note Task: 4a5. object.

     サードパーティのイベントループは相互運用のための自身の *note Task:
     4a5. のサブクラスを使用できます。この場合、結果は *note Task: 4a5.
     のサブクラスになります。

     'name' 引数が指定され、値が ‘None’ でない場合、 *note
     Task.set_name(): 9ab. メソッドにより 'name' がタスクの名前として設
     定されます。

     省略可能なキーワード引数 'context' によって、'coro' を実行するため
     のカスタムの *note contextvars.Context: 150d. を指定できます。
     'context' が省略された場合、現在のコンテキストのコピーが作成されま
     す。

     バージョン 3.8 で変更: 'name' パラメータを追加しました。

     バージョン 3.11 で変更: 'context' パラメータを追加しました。

 -- メソッド: loop.set_task_factory (factory)

     *note loop.create_task(): 9aa. が使用するタスクファクトリーを設定し
     ます。

     If 'factory' is ‘None’ the default task factory will be set.
     Otherwise, 'factory' must be a 'callable' with the signature
     matching ‘(loop, coro, context=None)’, where 'loop' is a reference
     to the active event loop, and 'coro' is a coroutine object.  The
     callable must return a *note asyncio.Future: b9b.-compatible
     object.

 -- メソッド: loop.get_task_factory ()

     タスクファクトリを返します。デフォルトのタスクファクトリを使用中の
     場合は ‘None’ を返します。


File: python.info,  Node: ネットワーク接続の確立,  Next: ネットワークサーバの生成,  Prev: フューチャーとタスクの生成,  Up: イベントループのメソッド

5.18.1.56 ネットワーク接続の確立
................................

 -- メソッド: coroutine loop.create_connection (protocol_factory,
          host=None, port=None, *, ssl=None, family=0, proto=0, flags=0,
          sock=None, local_addr=None, server_hostname=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None,
          happy_eyeballs_delay=None, interleave=None, all_errors=False)

     'host' と 'port' で指定されたアドレスとのストリーミングトランスポー
     ト接続をオープンします。

     The socket family can be either *note AF_INET: 1788. or *note
     AF_INET6: 1789. depending on 'host' (or the 'family' argument, if
     provided).

     The socket type will be *note SOCK_STREAM: 12c1.

     'protocol_factory' は *note asyncio プロトコル: 31ee. の実装を返す
     呼び出し可能オブジェクトでなければなりません。

     このメソッドはバックグラウンドで接続の確立を試みます。成功した場合
     、メソッドは ‘(transport, protocol)’ のペアを返します。

     時系列での下層処理の概要は以下のとおりです:

       1. 接続を確立し、その接続に対する *note トランスポート: 31ef. が
          生成されます。

       2. 'protocol_factory' が引数なしで呼び出され、ファクトリが *note
          プロトコル: 31ee. インスタンスを返すよう要求します。

       3. プロトコルインスタンスが *note connection_made(): 31f0. メソッ
          ドを呼び出すことにより、トランスポートと紐付けられます。

       4. 成功すると ‘(transport, protocol)’ タプルが返されます。

     作成されたトランスポートは実装依存の双方向ストリームです。

     その他の引数:

        * 'ssl': 偽値以外が与えられた場合、SSL/TLS トランスポートが作成
          されます (デフォルトでは暗号化なしの TCP トランスポートが作成
          されます)。 'ssl' が *note ssl.SSLContext: 274. オブジェクトの
          場合、このコンテキストがトランスポートを作成するために使用され
          ます; 'ssl' が *note True: bdb. の場合、 *note
          ssl.create_default_context(): 13b. が返すデフォルトのコンテキ
          ストが使われます。

          参考
          ....

          *note SSL/TLS セキュリティについての考察: 31f1.

        * 'server_hostname' は対象サーバーの証明書との一致を確認するため
          のホスト名を設定または上書きします。この引数は 'ssl' が ‘None’
          でない場合のみ設定すべきです。デフォルトでは 'host' に指定した
          サーバー名が使用されます。 'host' が空の文字列の場合のデフォル
          ト値は設定されていません。その場合、 'server_hostname' を必ず
          指定してください。 'server_hostname' も空の文字列の場合は、ホ
          スト名の一致確認は行われません (これは深刻なセキュリティリスク
          であり、中間者攻撃を受ける可能性があります)。

        * 'family', 'proto', 'flags' は任意のアドレスファミリであり、
          'host' 解決のための getaddrinfo() 経由で渡されるプロトコルおよ
          びフラグになります。このオプションが与えられた場合、これらはす
          べて *note socket: b8. モジュール定数に従った整数でなければな
          りません。

        * 'happy_eyeballs_delay' が設定されると、この接続に対して Happy
          Eyeballs が有効化されます。設定する値は浮動小数点数であり、次
          の接続試行を開始する前に、現在の接続試行が完了するのを待つ時間
          を秒単位で表現します。この値は RFC 8305(1) で定義されている "接
          続試行遅延" に相当します。RFC で推奨されている実用的なデフォル
          ト値は ‘0.25’ (250 ミリ秒) です。

        * 'interleave' はホスト名が複数の IP アドレスに名前解決される場
          合のアドレスの並べ替えを制御します。 ‘0’ または未指定の場合並
          べ替えは行われず、 *note getaddrinfo(): be2. が返す順番にした
          がってアドレスへの接続を試行します。正の整数が指定されると、ア
          ドレスはアドレスファミリに応じてインターリーブされます。このと
          き、与えられた整数は RFC 8305(2) で定義される "最初のアドレス
          ファミリカウント (First Address Family Count)" として解釈され
          ます。デフォルト値は、 'happy_eyeballs_delay' が指定されない場
          合は ‘0’ であり、指定された場合は ‘1’ です。

        * 'sock' を与える場合、トランスポートに使用される、既存の、かつ
          接続済の *note socket.socket: d6e. オブジェクトを指定します。
          'sock' を指定する場合、'host'、 'port'、 'family'、 'proto'、
          'flags'、 'happy_eyeballs_delay'、 'interleave' および
          'local_addr' のいずれも指定してはいけません。

               注釈: The 'sock' argument transfers ownership of the
               socket to the transport created.  To close the socket,
               call the transport's *note close(): 31f2. method.

        * 'local_addr' を与える場合、ソケットをローカルにバインドするた
          めに使用する ‘(local_host, local_port)’ タプルを指定します。
          'local_host' と 'local_port' は、 'host' および 'port' と同じ
          く ‘getaddrinfo()’ を使ってルックアップされます。

        * 'ssl_handshake_timeout' は TLS ハンドシェイクが完了するまでの
          (TLS 接続のための) 待ち時間を秒単位で指定します。指定した待ち
          時間を超えると接続は中断します。 ‘None’ が与えられた場合はデフ
          ォルト値 ‘60.0’ が使われます。

        * '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).

        * 'all_errors' determines what exceptions are raised when a
          connection cannot be created.  By default, only a single
          ‘Exception’ is raised: the first exception if there is only
          one or all errors have same message, or a single ‘OSError’
          with the error messages combined.  When ‘all_errors’ is
          ‘True’, an ‘ExceptionGroup’ will be raised containing all
          exceptions (even if there is only one).

     バージョン 3.5 で変更: *note ProactorEventLoop: 5d4. において
     SSL/TLS のサポートが追加されました。

     バージョン 3.6 で変更: The socket option *note socket.TCP_NODELAY:
     31f3. is set by default for all TCP connections.

     バージョン 3.7 で変更: Added the 'ssl_handshake_timeout' parameter.

     バージョン 3.8 で変更: 'happy_eyeballs_delay' と 'interleave' が追
     加されました。

     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 are not working, a dual-stack client application
     experiences significant connection delay compared to an IPv4-only
     client.  This is undesirable because it causes the dual-stack
     client to have a worse user experience.  This document specifies
     requirements for algorithms that reduce this user-visible delay and
     provides an algorithm.

     For more information:
     ‘https://datatracker.ietf.org/doc/html/rfc6555’

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

     バージョン 3.12 で変更: 'all_errors' が追加されました

     参考
     ....

     *note open_connection(): ae6. 関数は高水準の代替 API です。この関数
     は(*note StreamReader: 1830, *note StreamWriter: 1665.) のペアを返
     し、 async/await コードから直接使うことができます。

 -- メソッド: coroutine loop.create_datagram_endpoint (protocol_factory,
          local_addr=None, remote_addr=None, *, family=0, proto=0,
          flags=0, reuse_port=None, allow_broadcast=None, sock=None)

     データグラム接続 (UDP) を生成します。

     The socket family can be either *note AF_INET: 1788, *note
     AF_INET6: 1789, or *note AF_UNIX: 178a, depending on 'host' (or the
     'family' argument, if provided).

     The socket type will be *note SOCK_DGRAM: 12c0.

     'protocol_factory' は *note asyncio プロトコル: 31ee. の実装を返す
     呼び出し可能オブジェクトでなければなりません。

     成功すると ‘(transport, protocol)’ タプルが返されます。

     その他の引数:

        * 'local_addr' が指定される場合、ソケットをローカルにバインドす
          るための ‘(local_host, local_port)’ のタプルを指定します。
          'local_host' と 'local_port' は *note getaddrinfo(): be2. メソ
          ッドを使用して検索されます。

        * 'remote_addr' が指定される場合、‘(remote_host, remote_por)’ の
          タプルで、ソケットをリモートアドレスに束縛するために使用されま
          す。'remote_host' と 'remote_port' は *note getaddrinfo():
          be2. を使用して検索されます。

        * 'family', 'proto', 'flags' は任意のアドレスファミリです。これ
          らのファミリ、プロトコル、フラグは、'host' 解決のため *note
          getaddrinfo(): be2. 経由でオプションで渡されます。これらのオプ
          ションを指定する場合、すべて *note socket: b8. モジュール定数
          に従った整数でなければなりません。

        * 'reuse_port' tells the kernel to allow this endpoint to be
          bound to the same port as other existing endpoints are bound
          to, so long as they all set this flag when being created.
          This option is not supported on Windows and some Unixes.  If
          the *note socket.SO_REUSEPORT: 31f3. constant is not defined
          then this capability is unsupported.

        * 'allow_broadcast' は、カーネルに、このエンドポイントがブロード
          キャストアドレスにメッセージを送信することを許可するように指示
          します。

        * オプションの 'sock' を指定することで、既存の、すでに接続されて
          いる *note socket.socket: d6e. をトランスポートで使用すること
          ができます。このオプションを使用する場合、'local_addr' と
          'remote_addr' は省略してください (*note None: 641. でなければ
          なりません)。

               注釈: The 'sock' argument transfers ownership of the
               socket to the transport created.  To close the socket,
               call the transport's *note close(): 31f2. method.

     *note UDP echo クライアントプロトコル: 31f4. および *note UDP echo
     サーバープロトコル: 31f5. の例を参照してください。

     バージョン 3.4.4 で変更: The 'family', 'proto', 'flags',
     'reuse_address', 'reuse_port', 'allow_broadcast', and 'sock'
     parameters were added.

     バージョン 3.8 で変更: Windows サポートが追加されました。

     バージョン 3.8.1 で変更: The 'reuse_address' parameter is no longer
     supported, as using *note socket.SO_REUSEADDR: 31f3. poses a
     significant security concern for UDP. Explicitly passing
     ‘reuse_address=True’ will raise an exception.

     ‘SO_REUSEADDR’ を使って、同一の UDP ソケットアドレスに対して複数の
     プロセスが異なる UID でソケットを割り当てている場合、受信パケットは
     複数のソケット間にランダムに分散する可能性があります。

     For supported platforms, 'reuse_port' can be used as a replacement
     for similar functionality.  With 'reuse_port', *note
     socket.SO_REUSEPORT: 31f3. is used instead, which specifically
     prevents processes with differing UIDs from assigning sockets to
     the same socket address.

     バージョン 3.11 で変更: The 'reuse_address' parameter, disabled
     since Python 3.8.1, 3.7.6 and 3.6.10, has been entirely removed.

 -- メソッド: coroutine loop.create_unix_connection (protocol_factory,
          path=None, *, ssl=None, sock=None, server_hostname=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None)

     Unix 接続を生成します。

     The socket family will be *note AF_UNIX: 178a.; socket type will be
     *note SOCK_STREAM: 12c1.

     成功すると ‘(transport, protocol)’ タプルが返されます。

     'path' は Unix ドメインソケット名で、 'sock' パラメータが指定されな
     い場合は必須です。 抽象 Unix ソケット、 *note str: 418.、 *note
     bytes: 1a4.、 and *note Path: 20a. 形式でのパスがサポートされていま
     す。

     このメソッドの引数についての詳細は *note loop.create_connection():
     5ce. メソッドのドキュメントを参照してください。

     *note Availability: 1cbe.: Unix.

     バージョン 3.7 で変更: Added the 'ssl_handshake_timeout' parameter.
     The 'path' parameter can now be a *note path-like object: 280.

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc8305.html

   (2) https://datatracker.ietf.org/doc/html/rfc8305.html


File: python.info,  Node: ネットワークサーバの生成,  Next: ファイルの転送,  Prev: ネットワーク接続の確立,  Up: イベントループのメソッド

5.18.1.57 ネットワークサーバの生成
..................................

 -- メソッド: coroutine loop.create_server (protocol_factory, host=None,
          port=None, *, family=socket.AF_UNSPEC,
          flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None,
          reuse_address=None, reuse_port=None, keep_alive=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None,
          start_serving=True)

     Create a TCP server (socket type *note SOCK_STREAM: 12c1.)
     listening on 'port' of the 'host' address.

     *note Server: ae0. オブジェクトを返します。

     引数:

        * 'protocol_factory' は *note asyncio プロトコル: 31ee. の実装を
          返す呼び出し可能オブジェクトでなければなりません。

        * 'host' パラメータはいくつかの方法で指定することができ、その値
          によってサーバーがどこをリッスンするかが決まります。

             - 'host' が文字列の場合、 TCP サーバーは 'host' で指定した
               単一のネットワークインターフェースに束縛されます。

             - 'host' が文字列のシーケンスである場合、 TCP サーバーはそ
               のシーケンスで指定された全てのネットワークインターフェー
               スに束縛されます。

             - 'host' が空の文字列か ‘None’ の場合、すべてのインターフェ
               ースが想定され、複合的なソケットのリスト (通常は一つが
               IPv4、もう一つが IPv6) が返されます。

        * 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).

        * 'family' can be set to either *note socket.AF_INET: 1788. or
          *note AF_INET6: 1789. to force the socket to use IPv4 or IPv6.
          If not set, the 'family' will be determined from host name
          (defaults to *note AF_UNSPEC: 31f7.).

        * 'flags' は *note getaddrinfo(): be2. のためのビットマスクにな
          ります。

        * サーバーで既存のソケットオブジェクトを使用するために、オプショ
          ンの引数 'sock' にソケットオブジェクトを設定することができます
          。指定した場合、 'host' と 'port' を指定してはいけません。

               注釈: The 'sock' argument transfers ownership of the
               socket to the server created.  To close the socket, call
               the server's *note close(): 3165. method.

        * 'backlog' は *note listen(): e27. に渡される、キューに入るコネ
          クションの最大数になります (デフォルトは 100)。

        * 確立した接続の上で TLS を有効化するために、 'ssl' に *note
          SSLContext: 274. のインスタンスを指定することができます。

        * 'reuse_address' は、‘TIME_WAIT’ 状態にあるローカルソケットを、
          その状態が自然にタイムアウトするのを待つことなく再利用するよう
          カーネルに指示します（訳註: ソケットのオプション SO_REUSEADDR
          を使用します）。指定しない場合、UNIX では自動的に ‘True’ が設
          定されます。

        * 'reuse_port' は、同じポートにバインドされた既存の端点すべてが
          このフラグを設定して生成されている場合に限り、この端点を既存の
          端点と同じポートにバインドすることを許可するよう、カーネルに指
          示します（訳註: ソケットのオプション SO_REUSEPORT を使用します
          ）。このオプションは、Windows ではサポートされていません。

        * 'keep_alive' set to ‘True’ keeps connections active by
          enabling the periodic transmission of messages.

     バージョン 3.13 で変更: Added the 'keep_alive' parameter.

        * 'ssl_handshake_timeout' は TLS ハンドシェイクが完了するまでの
          (TLS サーバーのための) 待ち時間を秒単位で指定します。指定した
          待ち時間を超えると接続は中断します。 ‘None’ が与えられた場合は
          デフォルト値 ‘60.0’ が使われます。

        * '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).

        * 'start_serving' が ‘True’ に設定された場合 (これがデフォルトで
          す)、 生成されたサーバーは即座に接続の受け付けを開始します。
          ‘False’ が指定された場合、ユーザーは接続の受け付けを開始するた
          めに *note Server.start_serving(): ae2. または *note
          Server.serve_forever(): ae3. を待ち受け (await) る必要がありま
          す。

     バージョン 3.5 で変更: *note ProactorEventLoop: 5d4. において
     SSL/TLS のサポートが追加されました。

     バージョン 3.5.1 で変更: 'host' パラメータに文字列のシーケンスを指
     定できるようになりました。

     バージョン 3.6 で変更: Added 'ssl_handshake_timeout' and
     'start_serving' parameters.  The socket option *note
     socket.TCP_NODELAY: 31f3. is set by default for all TCP
     connections.

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

     参考
     ....

     *note start_server(): ae7. 関数は高水準の代替 API です。この関数は
     *note StreamReader: 1830. と *note StreamWriter: 1665. のペアを返し
     、async/await コードから使うことができます。

 -- メソッド: coroutine loop.create_unix_server (protocol_factory,
          path=None, *, sock=None, backlog=100, ssl=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None,
          start_serving=True, cleanup_socket=True)

     Similar to *note loop.create_server(): ae1. but works with the
     *note AF_UNIX: 178a. socket family.

     'path' は Unix ドメインソケット名で、 'sock' パラメータが指定されな
     い場合は必須です。 抽象 Unix ソケット、 *note str: 418.、 *note
     bytes: 1a4.、 and *note Path: 20a. 形式でのパスがサポートされていま
     す。

     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.

     このメソッドの引数についての詳細は *note loop.create_server(): ae1.
     メソッドのドキュメントを参照してください。

     *note Availability: 1cbe.: Unix.

     バージョン 3.7 で変更: Added the 'ssl_handshake_timeout' and
     'start_serving' parameters.  The 'path' parameter can now be a
     *note Path: 20a. object.

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。

     バージョン 3.13 で変更: Added the 'cleanup_socket' parameter.

 -- メソッド: coroutine loop.connect_accepted_socket (protocol_factory,
          sock, *, ssl=None, ssl_handshake_timeout=None,
          ssl_shutdown_timeout=None)

     すでに確立した接続を transport と protocol のペアでラップします。

     このメソッドは asyncio の範囲外で確立された接続を使うサーバーに対し
     ても使えますが、その場合でも接続は asyncio を使って処理されます。

     引数:

        * 'protocol_factory' は *note asyncio プロトコル: 31ee. の実装を
          返す呼び出し可能オブジェクトでなければなりません。

        * 'sock' は *note socket.accept: d6f. メソッドが返す既存のソケッ
          トオブジェクトです。

               注釈: The 'sock' argument transfers ownership of the
               socket to the transport created.  To close the socket,
               call the transport's *note close(): 31f2. method.

        * 'ssl' には *note SSLContext: 274. を指定できます。指定すると、
          受け付けたコネクション上での SSL を有効にします。

        * 'ssl_handshake_timeout' は SSL ハンドシェイクが完了するまでの
          (SSL 接続のための) 待ち時間を秒単位で指定します。 ‘None’ が与
          えられた場合はデフォルト値 ‘60.0’ が使われます。

        * '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).

     ‘(transport, protocol)’ のペアを返します。

     Added in version 3.5.3.

     バージョン 3.7 で変更: Added the 'ssl_handshake_timeout' parameter.

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。


File: python.info,  Node: ファイルの転送,  Next: TLS へのアップグレード,  Prev: ネットワークサーバの生成,  Up: イベントループのメソッド

5.18.1.58 ファイルの転送
........................

 -- メソッド: coroutine loop.sendfile (transport, file, offset=0,
          count=None, *, fallback=True)

     'transport' を通じて 'file' を送信します。送信したデータの総バイト
     数を返します。

     このメソッドは、もし利用可能であれば高性能な *note os.sendfile():
     add. を利用します。

     'file' はバイナリモードでオープンされた通常のファイルオブジェクトで
     なければなりません。

     'offset' はファイルの読み込み開始位置を指定します。 'count' が指定
     された場合、ファイルの EOF までファイルを送信する代わりに、 'count'
     で指定された総バイト数の分だけ送信します。ファイルオブジェクトが指
     し示す位置は、メソッドがエラーを送出した場合でも更新されます。この
     場合実際に送信されたバイト数は *note file.tell(): 2907. メソッドで
     取得することができます。

     'fallback' を ‘True’ に指定することで、 asyncio がプラットフォーム
     が sendfile システムコールをサポートしていない場合 (たとえば
     Windows や Unix の SSL ソケットなど) に別の方法でファイルの読み込み
     と送信を行うようにすることができます。

     システムが 'sendfile' システムコールをサポートしておらず、かつ
     'fallback' が ‘False’ の場合、 *note SendfileNotAvailableError:
     31d7. 例外を送出します。

     Added in version 3.7.


File: python.info,  Node: TLS へのアップグレード,  Next: ファイル記述子の監視,  Prev: ファイルの転送,  Up: イベントループのメソッド

5.18.1.59 TLS へのアップグレード
................................

 -- メソッド: coroutine loop.start_tls (transport, protocol, sslcontext,
          *, server_side=False, server_hostname=None,
          ssl_handshake_timeout=None, ssl_shutdown_timeout=None)

     既存のトランスポートベースの接続を TLS にアップグレードします。

     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.

     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'.

     In some situations (e.g.  when the passed transport is already
     closing) this may return ‘None’.

     引数:

        * 'transport' と 'protocol' には、 *note create_server(): ae1. や
          *note create_connection(): 5ce. が返すものと同等のインスタンス
          を指定します。

        * 'sslcontext': 構成済みの *note SSLContext: 274. インスタンスで
          す。

        * (*note create_server(): ae1. で生成されたような) サーバーサイ
          ドの接続をアップグレードする場合は 'server_side' に ‘True’ を
          渡します。

        * 'server_hostname': 対象のサーバーの証明書との照合に使われるホ
          スト名を設定または上書きします。

        * 'ssl_handshake_timeout' は TLS ハンドシェイクが完了するまでの
          (TLS 接続のための) 待ち時間を秒単位で指定します。指定した待ち
          時間を超えると接続は中断します。 ‘None’ が与えられた場合はデフ
          ォルト値 ‘60.0’ が使われます。

        * '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).

     Added in version 3.7.

     バージョン 3.11 で変更: 'ssl_shutdown_timeout' パラメータが追加され
     ました。


File: python.info,  Node: ファイル記述子の監視,  Next: ソケットオブジェクトと直接やりとりする,  Prev: TLS へのアップグレード,  Up: イベントループのメソッド

5.18.1.60 ファイル記述子の監視
..............................

 -- メソッド: loop.add_reader (fd, callback, *args)

     ファイル記述子 'fd' に対する読み込みが可能かどうかの監視を開始し、
     'fd' が読み込み可能になると、指定した引数でコールバック 'callback'
     を呼び出します。

 -- メソッド: loop.remove_reader (fd)

     Stop monitoring the 'fd' file descriptor for read availability.
     Returns ‘True’ if 'fd' was previously being monitored for reads.

 -- メソッド: loop.add_writer (fd, callback, *args)

     ファイル記述子 'fd' に対する書き込みが可能かどうかの監視を開始し、
     'fd' が書き込み可能になると、指定した引数でコールバック 'callback'
     を呼び出します。

     コールバック 'callback' に *note キーワード引数を渡す: 31e8. 場合は
     *note functools.partial(): 3ed. を使ってください。

 -- メソッド: loop.remove_writer (fd)

     Stop monitoring the 'fd' file descriptor for write availability.
     Returns ‘True’ if 'fd' was previously being monitored for writes.

これらのメソッドに対する制限事項については *note
プラットフォームのサポート状況: 31ff. 節も参照してください。


File: python.info,  Node: ソケットオブジェクトと直接やりとりする,  Next: DNS,  Prev: ファイル記述子の監視,  Up: イベントループのメソッド

5.18.1.61 ソケットオブジェクトと直接やりとりする
................................................

一般に、 *note loop.create_connection(): 5ce. や *note
loop.create_server(): ae1. のようなトランスポートベースの API を使ったプ
ロトコルの実装はソケットと直接やり取りする実装に比べて高速です。しかしな
がら、パフォーマンスが重要でなく、直接 *note socket: d6e. オブジェクトと
やりとりした方が便利なユースケースがいくつかあります。

 -- メソッド: coroutine loop.sock_recv (sock, nbytes)

     'nbytes' で指定したバイト数までのデータをソケット 'sock' から受信し
     ます。 このメソッドは *note socket.recv(): d71. の非同期版です。

     受信したデータをバイトオブジェクトとして返します。

     'sock' はノンブロッキングソケットでなければなりません。

     バージョン 3.7 で変更: このメソッドは常にコルーチンメソッドとしてド
     キュメントに記載されてきましたが、 Python 3.7 以前のリリースでは
     *note Future: b9b. オブジェクトを返していました。 Python 3.7 からは
     ‘async def’ メソッドになりました。

 -- メソッド: coroutine loop.sock_recv_into (sock, buf)

     ソケット 'sock' からデータを受信してバッファ 'buf' に格納します。ブ
     ロッキングコードの *note socket.recv_into(): 12ec. メソッドをモデル
     としています。

     バッファに書き込んだデータのバイト数を返します。

     'sock' はノンブロッキングソケットでなければなりません。

     Added in version 3.7.

 -- メソッド: coroutine loop.sock_recvfrom (sock, bufsize)

     Receive a datagram of up to 'bufsize' from 'sock'.  Asynchronous
     version of *note socket.recvfrom(): d72.

     Return a tuple of (received data, remote address).

     'sock' はノンブロッキングソケットでなければなりません。

     Added in version 3.11.

 -- メソッド: coroutine loop.sock_recvfrom_into (sock, buf, nbytes=0)

     Receive a datagram of up to 'nbytes' from 'sock' into 'buf'.
     Asynchronous version of *note socket.recvfrom_into(): 12ed.

     Return a tuple of (number of bytes received, remote address).

     'sock' はノンブロッキングソケットでなければなりません。

     Added in version 3.11.

 -- メソッド: coroutine loop.sock_sendall (sock, data)

     データ 'data' をソケット 'sock' に送信します。 *note
     socket.sendall(): d75. メソッドの非同期版です。

     このメソッドは 'data' をすべて送信し終えるか、またはエラーが起きる
     までデータをソケットに送信し続けます。送信に成功した場合 ‘None’ を
     返します。エラーの場合は例外が送出されます。エラーとなった場合、接
     続の受信側で正しく処理されたデータの総量を特定する方法はありません
     。

     'sock' はノンブロッキングソケットでなければなりません。

     バージョン 3.7 で変更: このメソッドは常にコルーチンメソッドとしてド
     キュメントに記載されてきましたが、 Python 3.7 以前のリリースでは
     *note Future: b9b. オブジェクトを返していました。 Python 3.7 からは
     ‘async def’ メソッドになりました。

 -- メソッド: coroutine loop.sock_sendto (sock, data, address)

     Send a datagram from 'sock' to 'address'.  Asynchronous version of
     *note socket.sendto(): d76.

     Return the number of bytes sent.

     'sock' はノンブロッキングソケットでなければなりません。

     Added in version 3.11.

 -- メソッド: coroutine loop.sock_connect (sock, address)

     ソケット 'sock' をアドレス 'address' のリモートソケットに接続します
     。

     *note socket.connect(): d70. の非同期版です。

     'sock' はノンブロッキングソケットでなければなりません。

     バージョン 3.5.2 で変更: ‘address’ を名前解決する必要はなくなりまし
     た。 ‘sock_connect’ は *note socket.inet_pton(): 930. を呼び出して
     'address' が解決済みかどうかを確認します。未解決の場合、 'address'
     の名前解決には *note loop.getaddrinfo(): be2. メソッドが使われます
     。

     参考
     ....

     *note loop.create_connection(): 5ce. および *note
     asyncio.open_connection(): ae6.。

 -- メソッド: coroutine loop.sock_accept (sock)

     接続を受け付けます。ブロッキングコールの *note socket.accept():
     d6f. メソッドをモデルとしています。

     ソケットはアドレスに束縛済みで、接続を listen 中である必要がありま
     す。戻り値は ‘(conn, address)’ のペアで、'conn' は接続を通じてデー
     タの送受信を行うための '新しい' ソケットオブジェクト、'address' は
     接続先の端点でソケットに束縛されているアドレスを示します。

     'sock' はノンブロッキングソケットでなければなりません。

     バージョン 3.7 で変更: このメソッドは常にコルーチンメソッドとしてド
     キュメントに記載されてきましたが、 Python 3.7 以前のリリースでは
     *note Future: b9b. オブジェクトを返していました。 Python 3.7 からは
     ‘async def’ メソッドになりました。

     参考
     ....

     *note loop.create_server(): ae1. および *note start_server(): ae7.。

 -- メソッド: coroutine loop.sock_sendfile (sock, file, offset=0,
          count=None, *, fallback=True)

     ファイルを送信します。利用可能なら高性能な *note os.sendfile: add.
     を使います。送信したデータの総バイト数を返します。

     *note socket.sendfile(): e26. メソッドの非同期版です。

     'sock' は *note socket.SOCK_STREAM: 12c1. タイプのノンブロッキング
     な *note socket: d6e. でなければなりません。

     'file' はバイナリモードでオープンされた通常のファイルオブジェクトで
     なければなりません。

     'offset' はファイルの読み込み開始位置を指定します。 'count' が指定
     された場合、ファイルの EOF までファイルを送信する代わりに、 'count'
     で指定された総バイト数の分だけ送信します。ファイルオブジェクトが指
     し示す位置は、メソッドがエラーを送出した場合でも更新されます。この
     場合実際に送信されたバイト数は *note file.tell(): 2907. メソッドで
     取得することができます。

     'fallback' が ‘True’ に設定された場合、 プラットフォームが sendfile
     システムコールをサポートしていない場合 (たとえば Windows や Unix の
     SSL ソケットなど) に asyncio が別の方法でファイルの読み込みと送信を
     行うようにすることができます。

     システムが 'sendfile' システムコールをサポートしておらず、かつ
     'fallback' が ‘False’ の場合、 *note SendfileNotAvailableError:
     31d7. 例外を送出します。

     'sock' はノンブロッキングソケットでなければなりません。

     Added in version 3.7.


File: python.info,  Node: DNS,  Next: パイプとやりとりする,  Prev: ソケットオブジェクトと直接やりとりする,  Up: イベントループのメソッド

5.18.1.62 DNS
.............

 -- メソッド: coroutine loop.getaddrinfo (host, port, *, family=0,
          type=0, proto=0, flags=0)

     *note socket.getaddrinfo(): 16bd. の非同期版です。

 -- メソッド: coroutine loop.getnameinfo (sockaddr, flags=0)

     *note socket.getnameinfo(): 1629. の非同期版です。

     注釈: Both 'getaddrinfo' and 'getnameinfo' internally utilize their
     synchronous versions through the loop's default thread pool
     executor.  When this executor is saturated, these methods may
     experience delays, which higher-level networking libraries may
     report as increased timeouts.  To mitigate this, consider using a
     custom executor for other user tasks, or setting a default executor
     with a larger number of workers.

バージョン 3.7 で変更: 'getaddrinfo' と 'getnameinfo' の2つのメソッドは
、いずれも常にコルーチンメソッドとしてドキュメントに記載されてきましたが
、 Python 3.7 以前のリリースでは、実際には *note asyncio.Future: b9b. オ
ブジェクトを返していました。 Python 3.7 からはどちらのメソッドもコルーチ
ンになりました。


File: python.info,  Node: パイプとやりとりする,  Next: Unix シグナル,  Prev: DNS,  Up: イベントループのメソッド

5.18.1.63 パイプとやりとりする
..............................

 -- メソッド: coroutine loop.connect_read_pipe (protocol_factory, pipe)

     イベントループの読み込み側終端に 'pipe' を登録します。

     'protocol_factory' は *note asyncio プロトコル: 31ee. の実装を返す
     呼び出し可能オブジェクトでなければなりません。

     'pipe' には *note file-like オブジェクト: 1193. を指定します。

     ‘(transport, protocol)’ のペアを返します。ここで 'transport' は
     *note ReadTransport: 3203. のインターフェースをサポートし、
     'protocol' は 'protocol_factory' ファクトリでインスタンス化されたオ
     ブジェクトです。

     *note SelectorEventLoop: 5d3. イベントループの場合、'pipe' は非ブロ
     ックモードに設定されていなければなりません。

 -- メソッド: coroutine loop.connect_write_pipe (protocol_factory, pipe)

     'pipe' の書き込み側終端をイベントループに登録します。

     'protocol_factory' は *note asyncio プロトコル: 31ee. の実装を返す
     呼び出し可能オブジェクトでなければなりません。

     'pipe' は *note file-like オブジェクト: 1193. です。

     ‘(transport, protocol)’ のペアを返します。ここで 'transport' は
     *note WriteTransport: 3204. のインスタンスであり、 'protocol' は
     'protocol_factory' ファクトリでインスタンス化されたオブジェクトです
     。

     *note SelectorEventLoop: 5d3. イベントループの場合、'pipe' は非ブロ
     ックモードに設定されていなければなりません。

     注釈: *note SelectorEventLoop: 5d3. は Windows 上で上記のメソッドを
     サポートしていません。 Windowsでは代わりに *note ProactorEventLoop:
     5d4. を使ってください。

参考
....

*note loop.subprocess_exec(): 31a7. および *note
loop.subprocess_shell(): 31a8. メソッド。


File: python.info,  Node: Unix シグナル,  Next: スレッドまたはプロセスプールでコードを実行する,  Prev: パイプとやりとりする,  Up: イベントループのメソッド

5.18.1.64 Unix シグナル
.......................

 -- メソッド: loop.add_signal_handler (signum, callback, *args)

     コールバック 'callback' をシグナル 'signum' に対するハンドラに設定
     します。

     コールバックは 'loop'、登録された他のコールバック、およびイベントル
     ープの実行可能なコルーチンから呼び出されます。 *note
     signal.signal(): 1107. を使って登録されたシグナルハンドラと異なり、
     この関数で登録されたコールバックはイベントループと相互作用すること
     が可能です。

     シグナルナンバーが誤っているか捕捉不可能な場合 *note ValueError:
     1e3. が送出されます。ハンドラーの設定に問題があった場合 *note
     RuntimeError: 17a. が送出されます。

     コールバック 'callback' に *note キーワード引数を渡す: 31e8. 場合は
     *note functools.partial(): 3ed. を使ってください。

     *note signal.signal(): 1107. と同じく、この関数はメインスレッドから
     呼び出されなければなりません。

 -- メソッド: loop.remove_signal_handler (sig)

     シグナル 'sig' に対するハンドラを削除します。

     シグナルハンドラが削除された場合 ‘True’ を返します。シグナルに対し
     てハンドラが設定されていない場合には ‘False’ を返します。

     *note Availability: 1cbe.: Unix.

参考
....

*note signal: b4. モジュール。


File: python.info,  Node: スレッドまたはプロセスプールでコードを実行する,  Next: エラーハンドリング API,  Prev: Unix シグナル,  Up: イベントループのメソッド

5.18.1.65 スレッドまたはプロセスプールでコードを実行する
........................................................

 -- メソッド: awaitable loop.run_in_executor (executor, func, *args)

     指定したエグゼキュータで関数 'func' が実行されるように準備します。

     The 'executor' argument should be an *note
     concurrent.futures.Executor: 3078. instance.  The default executor
     is used if 'executor' is ‘None’.  The default executor can be set
     by *note loop.set_default_executor(): 70e, otherwise, a *note
     concurrent.futures.ThreadPoolExecutor: 70d. will be
     lazy-initialized and used by *note run_in_executor(): 8b7. if
     needed.

     以下はプログラム例です:

          import asyncio
          import concurrent.futures

          def blocking_io():
              # File operations (such as logging) can block the
              # event loop: run them in a thread pool.
              with open('/dev/urandom', 'rb') as f:
                  return f.read(100)

          def cpu_bound():
              # CPU-bound operations will block the event loop:
              # in general it is preferable to run them in a
              # process pool.
              return sum(i * i for i in range(10 ** 7))

          async def main():
              loop = asyncio.get_running_loop()

              ## Options:

              # 1. Run in the default loop's executor:
              result = await loop.run_in_executor(
                  None, blocking_io)
              print('default thread pool', result)

              # 2. Run in a custom thread pool:
              with concurrent.futures.ThreadPoolExecutor() as pool:
                  result = await loop.run_in_executor(
                      pool, blocking_io)
                  print('custom thread pool', result)

              # 3. Run in a custom process pool:
              with concurrent.futures.ProcessPoolExecutor() as pool:
                  result = await loop.run_in_executor(
                      pool, cpu_bound)
                  print('custom process pool', result)

          if __name__ == '__main__':
              asyncio.run(main())

     Note that the entry point guard (‘if __name__ == '__main__'’) is
     required for option 3 due to the peculiarities of *note
     multiprocessing: 86, which is used by *note ProcessPoolExecutor:
     8bc.  See *note Safe importing of main module: 3064.

     このメソッドは *note asyncio.Future: b9b. オブジェクトを返します。

     関数 'func' に *note キーワード引数を渡す: 31e8. 場合は *note
     functools.partial(): 3ed. を使ってください。

     バージョン 3.5.3 で変更: *note loop.run_in_executor(): 8b7. は内部
     で生成するスレッドプールエグゼキュータの ‘max_workers’ を設定せず、
     代わりにスレッドプールエグゼキュータ (*note ThreadPoolExecutor:
     70d.) にデフォルト値を設定させるようになりました。

 -- メソッド: loop.set_default_executor (executor)

     Set 'executor' as the default executor used by *note
     run_in_executor(): 8b7.  'executor' must be an instance of *note
     ThreadPoolExecutor: 70d.

     バージョン 3.11 で変更: 'executor' must be an instance of *note
     ThreadPoolExecutor: 70d.


File: python.info,  Node: エラーハンドリング API,  Next: デバッグモードの有効化,  Prev: スレッドまたはプロセスプールでコードを実行する,  Up: イベントループのメソッド

5.18.1.66 エラーハンドリング API
................................

イベントループ内での例外の扱い方をカスタマイズできます。

 -- メソッド: loop.set_exception_handler (handler)

     'handler' を新しいイベントループ例外ハンドラーとして設定します。

     'handler' が ‘None’ の場合、デフォルトの例外ハンドラが設定されます
     。そうでなければ、 'handler' は ‘(loop, context)’ に一致する関数シ
     グネチャを持った呼び出し可能オブジェクトでなければなりません。ここ
     で ‘loop’ はアクティブなイベントループへの参照であり、 ‘context’ は
     例外の詳細な記述からなる ‘dict’ オブジェクトです ('context' につい
     ての詳細は *note call_exception_handler(): 320b. メソッドのドキュメ
     ントを参照してください)。

     If the handler is called on behalf of a *note Task: 4a5. or *note
     Handle: 1a0e, it is run in the *note contextvars.Context: 150d. of
     that task or callback handle.

     バージョン 3.12 で変更: The handler may be called in the *note
     Context: 150d. of the task or handle where the exception
     originated.

 -- メソッド: loop.get_exception_handler ()

     現在の例外ハンドラを返します。カスタム例外ハンドラが設定されていな
     い場合は ‘None’ を返します。

     Added in version 3.5.2.

 -- メソッド: loop.default_exception_handler (context)

     デフォルトの例外ハンドラーです。

     デフォルト例外ハンドラは、例外ハンドラが未設定の場合、例外が発生し
     た時に呼び出されます。デフォルト例外ハンドラの挙動を受け入れるため
     に、カスタム例外ハンドラから呼び出すことも可能です。

     引数 'context' の意味は *note call_exception_handler(): 320b. と同
     じです。

 -- メソッド: loop.call_exception_handler (context)

     現在のイベントループ例外ハンドラーを呼び出します。

     'context' は以下のキーを含む ‘dict’ オブジェクトです (将来の Python
     バージョンで新しいキーが追加される可能性があります):

        * 'message': エラーメッセージ;

        * 'exception' (任意): 例外オブジェクト;

        * 'future' (任意): *note asyncio.Future: b9b. インスタンス;

        * 'task' (optional): *note asyncio.Task: 4a5. instance;

        * 'handle' (任意): *note asyncio.Handle: 1a0e. インスタンス;

        * 'protocol' (任意): *note プロトコル: 31ee. インスタンス;

        * 'transport' (任意): *note トランスポート: 31ef. インスタンス;

        * 'socket' (optional): *note socket.socket: d6e. instance;

        * 
          'asyncgen' (optional): Asynchronous generator that caused

               the exception.

          注釈: This method should not be overloaded in subclassed event
          loops.  For custom exception handling, use the *note
          set_exception_handler(): 320a. method.


File: python.info,  Node: デバッグモードの有効化,  Next: サブプロセスの実行,  Prev: エラーハンドリング API,  Up: イベントループのメソッド

5.18.1.67 デバッグモードの有効化
................................

 -- メソッド: loop.get_debug ()

     イベントループのデバッグモード (*note bool: 434.) を取得します。

     環境変数 *note PYTHONASYNCIODEBUG: 1cb8. に空でない文字列が設定され
     ている場合のデフォルト値は ‘True’、そうでない場合は ‘False’ になり
     ます。

 -- メソッド: loop.set_debug (enabled: bool)

     イベントループのデバッグモードを設定します。

     バージョン 3.7 で変更: 新しい *note Python 開発モード: 1d9. を使っ
     てデバッグモードを有効化することができるようになりました。

 -- の属性: loop.slow_callback_duration

     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.

     Default value is 100 milliseconds.

参考
....

*note asyncio のデバッグモード: 1cb9.。


File: python.info,  Node: サブプロセスの実行,  Prev: デバッグモードの有効化,  Up: イベントループのメソッド

5.18.1.68 サブプロセスの実行
............................

この節で解説しているのは低水準のメソッドです。通常の async/await コード
では、高水準の関数である *note asyncio.create_subprocess_shell(): a46. や
*note asyncio.create_subprocess_exec(): a45. を代わりに使うことを検討し
てください。

     注釈: On Windows, the default event loop *note ProactorEventLoop:
     5d4. supports subprocesses, whereas *note SelectorEventLoop: 5d3.
     does not.  See *note Subprocess Support on Windows: 31a9. for
     details.

 -- メソッド: coroutine loop.subprocess_exec (protocol_factory, *args,
          stdin=subprocess.PIPE, stdout=subprocess.PIPE,
          stderr=subprocess.PIPE, **kwargs)

     'args' で指定されたひとつの、または複数の文字列引数からサブプロセス
     を生成します。

     'args' は下記のいずれかに当てはまる文字列のリストでなければなりませ
     ん:

        * *note str: 418.;

        * または *note ファイルシステムのエンコーディング: 270c. にエン
          コードされた *note bytes: 1a4.

     引数の最初の文字列はプログラムの実行ファイルを指定します。それに続
     く残りの文字列は引数を指定し、そのプログラムに対する ‘argv’ を構成
     します。

     このメソッドは標準ライブラリの *note subprocess.Popen: 17e. クラス
     を、 ‘shell=False’ かつ最初の引数に文字列のリストを渡して呼び出した
     場合に似ています。しかし、 *note Popen: 17e. クラスは文字列のリスト
     を引数としてひとつだけ取るのに対して、 'subprocess_exec' は複数の文
     字列引数をとることができます。

     'protocol_factory' は *note asyncio.SubprocessProtocol: 3210. クラ
     スの派生クラスを返す呼び出し可能オブジェクトでなければなりません。

     その他の引数:

        * 'stdin' は下記のいずれかをとることができます:

             * a file-like object

             * an existing file descriptor (a positive integer), for
               example those created with *note os.pipe(): 1745.

             * デフォルト値は *note subprocess.PIPE: b55. 定数で、この場
               合新規にパイプを生成して接続します。

             * ‘None’ が設定された場合、サブプロセスは元のプロセスのファ
               イルデスクリプタを引き継ぎます。

             * *note subprocess.DEVNULL: 1121. 定数を設定すると、特別な
               ファイル *note os.devnull: 199e. を使います。

        * 'stdout' は下記のいずれかをとることができます:

             * a file-like object

             * デフォルト値は *note subprocess.PIPE: b55. 定数で、この場
               合新規にパイプを生成して接続します。

             * ‘None’ が設定された場合、サブプロセスは元のプロセスのファ
               イルデスクリプタを引き継ぎます。

             * *note subprocess.DEVNULL: 1121. 定数を設定すると、特別な
               ファイル *note os.devnull: 199e. を使います。

        * 'stderr' は下記のいずれかをとることができます:

             * a file-like object

             * デフォルト値は *note subprocess.PIPE: b55. 定数で、この場
               合新規にパイプを生成して接続します。

             * ‘None’ が設定された場合、サブプロセスは元のプロセスのファ
               イルデスクリプタを引き継ぎます。

             * *note subprocess.DEVNULL: 1121. 定数を設定すると、特別な
               ファイル *note os.devnull: 199e. を使います。

             * *note subprocess.STDOUT: 3096. 定数を設定すると、標準エラ
               ー出力ストリームをプロセスの標準出力ストリームに接続しま
               す。

        * その他のすべてのキーワード引数は解釈されずにそのまま *note
          subprocess.Popen: 17e. に渡されます。ただし、 'bufsize'、
          'universal_newlines'、 'shell'、 'text'、 'encoding' および
          'errors' は指定してはいけません。

          ‘asyncio’ のサブプロセス API はストリームからテキストへのデコ
          ードをサポートしていません。ストリームからテキストに変換するに
          は *note bytes.decode(): 8a4. 関数を使ってください。

     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 *note connect_write_pipe(): 31ab. or *note
     connect_read_pipe(): 31aa. for use with the event loop.

     他の引数についての詳細は *note subprocess.Popen: 17e. クラスのコン
     ストラクタを参照してください。

     ‘(transport, protocol)’ のペアを返します。ここで 'transport' は
     *note asyncio.SubprocessTransport: 3211. 基底クラスに適合するオブジ
     ェクトで、 'protocol' は 'protocol_factory' によりインスタンス化さ
     れたオブジェクトです。

 -- メソッド: coroutine loop.subprocess_shell (protocol_factory, cmd, *,
          stdin=subprocess.PIPE, stdout=subprocess.PIPE,
          stderr=subprocess.PIPE, **kwargs)

     コマンド 'cmd' からプラットフォームの "シェル" シンタックスを使って
     サブプロセスを生成します。 'cmd' は *note str: 418. 文字列もしくは
     *note ファイルシステムのエンコーディング: 270c. でエンコードされた
     *note bytes: 1a4. 文字列です。

     これは標準ライブラリの *note subprocess.Popen: 17e. クラスを
     ‘shell=True’ で呼び出した場合と似ています。

     'protocol_factory' は *note SubprocessProtocol: 3210. の派生クラス
     を返す呼び出し可能オブジェクトでなければなりません。

     その他の引数についての詳細は *note subprocess_exec(): 31a7. メソッ
     ドを参照してください。

     ‘(transport, protocol)’ のペアを返します。ここで 'transport' は
     *note SubprocessTransport: 3211. 基底クラスに適合するオブジェクトで
     、 'protocol' は 'protocol_factory' によりインスタンス化されたオブ
     ジェクトです。

     注釈: シェルインジェクション(1) の脆弱性を回避するために全ての空白
     文字および特殊文字を適切にクオートすることは、アプリケーション側の
     責任で確実に行ってください。シェルコマンドを構成する文字列内の空白
     文字と特殊文字のエスケープは、 *note shlex.quote(): 25e. 関数を使う
     と適切に行うことができます。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Shell_injection#Shell_injection


File: python.info,  Node: コールバックのハンドル,  Next: Serverオブジェクト,  Prev: イベントループのメソッド,  Up: イベントループ

5.18.1.69 コールバックのハンドル
................................

 -- クラス: asyncio.Handle

     *note loop.call_soon(): ad2. や *note loop.call_soon_threadsafe():
     ad3. が返すコールバックのラッパーです。

      -- メソッド: get_context ()

          Return the *note contextvars.Context: 150d. object associated
          with the handle.

          Added in version 3.12.

      -- メソッド: cancel ()

          コールバックをキャンセルします。コールバックがキャンセル済みま
          たは実行済みの場合、このメソッドは何の影響もありません。

      -- メソッド: cancelled ()

          コールバックがキャンセルされた場合 ‘True’ を返します。

          Added in version 3.7.

 -- クラス: asyncio.TimerHandle

     A callback wrapper object returned by *note loop.call_later(): ad4,
     and *note loop.call_at(): ad5.

     このクラスは *note Handle: 1a0e. の派生クラスです。

      -- メソッド: when ()

          コールバックのスケジュール時刻を秒単位の *note float: 2ce. で
          返します。

          戻り値の時刻は絶対値で、 *note loop.time(): 31eb. と同じ参照時
          刻を使って定義されています。

          Added in version 3.7.


File: python.info,  Node: Serverオブジェクト,  Next: イベントループの実装,  Prev: コールバックのハンドル,  Up: イベントループ

5.18.1.70 Serverオブジェクト
............................

Server オブジェクトは *note loop.create_server(): ae1.、 *note
loop.create_unix_server(): 193.、 *note start_server(): ae7. および
*note start_unix_server(): 3168. 関数により生成されます。

Do not instantiate the *note Server: ae0. class directly.

 -- クラス: asyncio.Server

     'Server' オブジェクトは非同期のコンテキストマネージャです。 ‘async
     with’ 文の中で使われた場合、 ‘async with’ 文が完了した時に Server オ
     ブジェクトがクローズされること、およびそれ以降に接続を受け付けない
     ことが保証されます。

          srv = await loop.create_server(...)

          async with srv:
              # some code

          # At this point, srv is closed and no longer accepts new connections.

     バージョン 3.7 で変更: Python 3.7 から、 Server オブジェクトは非同
     期のコンテキストマネージャになりました。

     バージョン 3.11 で変更: This class was exposed publicly as
     ‘asyncio.Server’ in Python 3.9.11, 3.10.3 and 3.11.

      -- メソッド: close ()

          サーバーを停止します: 待機しているソケットをクローズし *note
          sockets: be4. 属性に ‘None’ を設定します。

          既存の受信中のクライアントとの接続を表すソケットはオープンのま
          まです。

          The server is closed asynchronously; use the *note
          wait_closed(): 162f. coroutine to wait until the server is
          closed (and no more connections are active).

      -- メソッド: close_clients ()

          Close all existing incoming client connections.

          Calls *note close(): 31f2. on all associated transports.

          *note close(): 3165. should be called before *note
          close_clients(): 197. when closing the server to avoid races
          with new clients connecting.

          Added in version 3.13.

      -- メソッド: abort_clients ()

          Close all existing incoming client connections immediately,
          without waiting for pending operations to complete.

          Calls *note abort(): 3214. on all associated transports.

          *note close(): 3165. should be called before *note
          abort_clients(): 198. when closing the server to avoid races
          with new clients connecting.

          Added in version 3.13.

      -- メソッド: get_loop ()

          サーバオブジェクトに付随するイベントループを返します。

          Added in version 3.7.

      -- メソッド: coroutine start_serving ()

          接続の受け付けを開始します。

          This method is idempotent, so it can be called when the server
          is already serving.

          キーワード専用のパラメータ 'start_serving' を *note
          loop.create_server(): ae1. や *note asyncio.start_server():
          ae7. メソッドに対して使用することにより、初期に接続を受け付け
          ない Server オブジェクトを生成することができます。この場合
          ‘Server.start_serving()’ または *note Server.serve_forever():
          ae3. メソッドを使ってオブジェクトが接続の受け付けを開始するよ
          うにすることができます。

          Added in version 3.7.

      -- メソッド: coroutine serve_forever ()

          接続の受け入れを開始し、コルーチンがキャンセルされるまで継続し
          ます。 ‘serve_forever’ タスクのキャンセルによりサーバーもクロ
          ーズされます。

          このメソッドはサーバーがすでに接続の受け入れを開始していても呼
          び出し可能です。ひとつの 'Server' オブジェクトにつき
          ‘serve_forever’ タスクはひとつだけ存在できます。

          以下はプログラム例です:

               async def client_connected(reader, writer):
                   # Communicate with the client with
                   # reader/writer streams.  For example:
                   await reader.readline()

               async def main(host, port):
                   srv = await asyncio.start_server(
                       client_connected, host, port)
                   await srv.serve_forever()

               asyncio.run(main('127.0.0.1', 0))

          Added in version 3.7.

      -- メソッド: is_serving ()

          サーバーが新規に接続の受け入れを開始した場合 ‘True’ を返します
          。

          Added in version 3.7.

      -- メソッド: coroutine wait_closed ()

          Wait until the *note close(): 3165. method completes and all
          active connections have finished.

      -- の属性: sockets

          List of socket-like objects, ‘asyncio.trsock.TransportSocket’,
          which the server is listening on.

          バージョン 3.7 で変更: Python 3.7 より前のバージョンでは、
          ‘Server.sockets’ は内部に持っているサーバーソケットのリストを
          直接返していました。 Python 3.7 ではリストのコピーが返されるよ
          うになりました。


File: python.info,  Node: イベントループの実装,  Next: 使用例<24>,  Prev: Serverオブジェクト,  Up: イベントループ

5.18.1.71 イベントループの実装
..............................

asyncio は2つの異なるイベントループの実装、 *note SelectorEventLoop:
5d3. と *note ProactorEventLoop: 5d4.、 を提供します:

By default asyncio is configured to use *note EventLoop: 165b.

 -- クラス: asyncio.SelectorEventLoop

     A subclass of *note AbstractEventLoop: 92d. based on the *note
     selectors: b0. module.

     プラットフォーム上で利用可能な最も効率の良い 'selector' を使います
     。特定のセレクタ実装を使うように手動で構成することも可能です:

          import asyncio
          import selectors

          class MyPolicy(asyncio.DefaultEventLoopPolicy):
             def new_event_loop(self):
                selector = selectors.SelectSelector()
                return asyncio.SelectorEventLoop(selector)

          asyncio.set_event_loop_policy(MyPolicy())

     *note Availability: 1cbe.: Unix, Windows.

 -- クラス: asyncio.ProactorEventLoop

     A subclass of *note AbstractEventLoop: 92d. for Windows that uses
     "I/O Completion Ports" (IOCP).

     *note Availability: 1cbe.: Windows.

     参考
     ....

     MSDN documentation on I/O Completion Ports(1).

 -- クラス: asyncio.EventLoop

          An alias to the most efficient available subclass of *note
          AbstractEventLoop: 92d. for the given platform.

          It is an alias to *note SelectorEventLoop: 5d3. on Unix and
          *note ProactorEventLoop: 5d4. on Windows.

     Added in version 3.13.

 -- クラス: asyncio.AbstractEventLoop

     asyncio に適合するイベントループの抽象基底クラスです。

     The *note イベントループのメソッド: 31e2. section lists all methods
     that an alternative implementation of ‘AbstractEventLoop’ should
     have defined.

   ---------- Footnotes ----------

   (1) 
https://learn.microsoft.com/windows/win32/fileio/i-o-completion-ports


File: python.info,  Node: 使用例<24>,  Prev: イベントループの実装,  Up: イベントループ

5.18.1.72 使用例
................

この節の全ての使用例は '意図的に' *note loop.run_forever(): 31e4. や
*note loop.call_soon(): ad2. のような 低水準のイベントループ API の使用
法を示しています。一方で現代的な asyncio アプリケーションはここに示すよ
うな方法をほとんど必要としません。 *note asyncio.run(): 449. のような高
水準の関数の使用を検討してください。

* Menu:

* call_soon() を使った Hello World: call_soon を使った Hello World.
* call_later() で現在の日時を表示する: call_later で現在の日時を表示する.
* 読み込みイベント用ファイル記述子の監視::
* SIGINT および SIGTERM 用のシグナルハンドラーの設定::


File: python.info,  Node: call_soon を使った Hello World,  Next: call_later で現在の日時を表示する,  Up: 使用例<24>

5.18.1.73 call_soon() を使った Hello World
..........................................

*note loop.call_soon(): ad2. メソッドを使ってコールバックをスケジュール
する例です。コールバックは ‘"Hello World"’ を出力しイベントループを停止
します:

     import asyncio

     def hello_world(loop):
         """A callback to print 'Hello World' and stop the event loop"""
         print('Hello World')
         loop.stop()

     loop = asyncio.new_event_loop()

     # Schedule a call to hello_world()
     loop.call_soon(hello_world, loop)

     # Blocking call interrupted by loop.stop()
     try:
         loop.run_forever()
     finally:
         loop.close()

参考
....

コルーチンと *note run(): 449. 関数を使用した同じような *note Hello
World: 3122. の例。


File: python.info,  Node: call_later で現在の日時を表示する,  Next: 読み込みイベント用ファイル記述子の監視,  Prev: call_soon を使った Hello World,  Up: 使用例<24>

5.18.1.74 call_later() で現在の日時を表示する
.............................................

毎秒現在時刻を表示するコールバックの例です。コールバックは *note
loop.call_later(): ad4. メソッドを使って自身を5秒後に実行するよう再スケ
ジュールし、イベントループを停止します:

     import asyncio
     import datetime

     def display_date(end_time, loop):
         print(datetime.datetime.now())
         if (loop.time() + 1.0) < end_time:
             loop.call_later(1, display_date, end_time, loop)
         else:
             loop.stop()

     loop = asyncio.new_event_loop()

     # Schedule the first call to display_date()
     end_time = loop.time() + 5.0
     loop.call_soon(display_date, end_time, loop)

     # Blocking call interrupted by loop.stop()
     try:
         loop.run_forever()
     finally:
         loop.close()

参考
....

コルーチンと *note run(): 449. 関数を使用した同じような *note
現在時刻出力: 3140. の例。


File: python.info,  Node: 読み込みイベント用ファイル記述子の監視,  Next: SIGINT および SIGTERM 用のシグナルハンドラーの設定,  Prev: call_later で現在の日時を表示する,  Up: 使用例<24>

5.18.1.75 読み込みイベント用ファイル記述子の監視
................................................

ファイル記述子が *note loop.add_reader(): 3182. メソッドを使って何らかの
データを受信するまで待機し、その後イベントループをクローズします:

     import asyncio
     from socket import socketpair

     # Create a pair of connected file descriptors
     rsock, wsock = socketpair()

     loop = asyncio.new_event_loop()

     def reader():
         data = rsock.recv(100)
         print("Received:", data.decode())

         # We are done: unregister the file descriptor
         loop.remove_reader(rsock)

         # Stop the event loop
         loop.stop()

     # Register the file descriptor for read event
     loop.add_reader(rsock, reader)

     # Simulate the reception of data from the network
     loop.call_soon(wsock.send, 'abc'.encode())

     try:
         # Run the event loop
         loop.run_forever()
     finally:
         # We are done. Close sockets and the event loop.
         rsock.close()
         wsock.close()
         loop.close()

参考
....

   * トランスポート、プロトコル、および *note loop.create_connection():
     5ce. メソッドを使用した同じような *note 例: 3180.。

   * 高水準の *note asyncio.open_connection(): ae6. 関数とストリームを使
     用したもうひとつの *note 実装例: 317e.。


File: python.info,  Node: SIGINT および SIGTERM 用のシグナルハンドラーの設定,  Prev: 読み込みイベント用ファイル記述子の監視,  Up: 使用例<24>

5.18.1.76 SIGINT および SIGTERM 用のシグナルハンドラーの設定
............................................................

(ここに挙げる ‘signals’ の例は Unix でのみ動きます。)

Register handlers for signals *note SIGINT: 80f. and *note SIGTERM:
1387. using the *note loop.add_signal_handler(): 3206. method:

     import asyncio
     import functools
     import os
     import signal

     def ask_exit(signame, loop):
         print("got signal %s: exit" % signame)
         loop.stop()

     async def main():
         loop = asyncio.get_running_loop()

         for signame in {'SIGINT', 'SIGTERM'}:
             loop.add_signal_handler(
                 getattr(signal, signame),
                 functools.partial(ask_exit, signame, loop))

         await asyncio.sleep(3600)

     print("Event loop running for 1 hour, press Ctrl+C to interrupt.")
     print(f"pid {os.getpid()}: send SIGINT or SIGTERM to exit.")

     asyncio.run(main())


File: python.info,  Node: Future,  Next: トランスポートとプロトコル,  Prev: イベントループ,  Up: asyncio --- 非同期 I/O

5.18.1.77 Future
................

'ソースコード:' Lib/asyncio/futures.py(1),
Lib/asyncio/base_futures.py(2)

__________________________________________________________________

'Future' オブジェクトは '低水準のコールバックベースのコード' と高水準の
async/await コードとの間を橋渡しします。

* Menu:

* Future の関数::
* Future オブジェクト: Future オブジェクト<2>.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/futures.py

   (2) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/base_futures.py


File: python.info,  Node: Future の関数,  Next: Future オブジェクト<2>,  Up: Future

5.18.1.78 Future の関数
.......................

 -- の関数: asyncio.isfuture (obj)

     オブジェクト 'obj' が下記のいずれかであれば ‘True’ を返します:

        * *note asyncio.Future: b9b. クラスのインスタンス

        * *note asyncio.Task: 4a5. クラスのインスタンス

        * ‘_asyncio_future_blocking’ 属性を持った Future 的なオブジェク
          ト

     Added in version 3.5.

 -- の関数: asyncio.ensure_future (obj, *, loop=None)

     下記のいずれかを返します:

        * 'obj' が *note Future: b9b. オブジェクト、 *note Task: 4a5. オ
          ブジェクト、または Future 的なオブジェクト (*note isfuture():
          3221. 関数を使って検査します) である場合には 'obj' そのもの

        * 引数 'obj' がコルーチンである (*note iscoroutine(): 44b. 関数
          を使って検査します) 場合には 'obj' をラップした *note Task:
          4a5. オブジェクト; この場合コルーチンは ‘ensure_future()’ によ
          りスケジュールされます。

        * 引数 'obj' が awaitable である (*note inspect.isawaitable():
          de4. 関数を使って検査します) 場合には 'obj' を await する
          *note Task: 4a5. オブジェクト

     引数 'obj' が上記のいずれにもあてはまらない場合は *note TypeError:
     502. 例外を送出します。

          重要: Task を生成するより好ましい方法である *note
          create_task(): 5c7. 関数も参照してください。

          Save a reference to the result of this function, to avoid a
          task disappearing mid-execution.

     バージョン 3.5.1 で変更: この関数はどんな *note awaitable: 192. な
     オブジェクトでも受け入れるようになりました。

     バージョン 3.10 で非推奨: Deprecation warning is emitted if 'obj'
     is not a Future-like object and 'loop' is not specified and there
     is no running event loop.

 -- の関数: asyncio.wrap_future (future, *, loop=None)

     *note concurrent.futures.Future: 1182. オブジェクトを *note
     asyncio.Future: b9b. オブジェクトでラップします。

     バージョン 3.10 で非推奨: Deprecation warning is emitted if
     'future' is not a Future-like object and 'loop' is not specified
     and there is no running event loop.


File: python.info,  Node: Future オブジェクト<2>,  Prev: Future の関数,  Up: Future

5.18.1.79 Future オブジェクト
.............................

 -- クラス: asyncio.Future (*, loop=None)

     Future は非同期処理の最終結果を表すクラスです。スレッドセーフではあ
     りません。

     Future is an *note awaitable: 192. 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.

     典型的には、 Future は低水準のコールバックベースのコード (たとえば
     asyncio の *note transports: 312a. を使って実装されたプロトコル) が
     高水準の async/await と相互運用することを可能にするために利用されま
     す。

     経験則は Future オブジェクトをユーザー向けの API であらわに利用しな
     いことです。推奨される Future オブジェクトの生成方法は *note
     loop.create_future(): c47. を呼び出すことです。これによりイベントル
     ープの代替実装は、自身に最適化された Future オブジェクトの実装を合
     わせて提供することができます。

     バージョン 3.7 で変更: *note contextvars: 1d. モジュールのサポート
     を追加。

     バージョン 3.10 で非推奨: Deprecation warning is emitted if 'loop'
     is not specified and there is no running event loop.

      -- メソッド: result ()

          Future の結果を返します。

          Future が '完了' していて、 *note set_result(): 3155. メソッド
          により設定された結果を持っている場合は結果の値を返します。

          Future が '完了' していて、 *note set_exception(): 3156. メソ
          ッドにより設定された例外を持っている場合はその例外を送出します
          。

          Future が 'キャンセルされた' 場合、このメソッドは *note
          CancelledError: 19d. 例外を送出します。

          If the Future's result isn't yet available, this method raises
          an *note InvalidStateError: 3159. exception.

      -- メソッド: set_result (result)

          Future を '完了' とマークし、結果を設定します。

          Raises an *note InvalidStateError: 3159. error if the Future
          is already 'done'.

      -- メソッド: set_exception (exception)

          Future を '完了' とマークし、例外を設定します。

          Raises an *note InvalidStateError: 3159. error if the Future
          is already 'done'.

      -- メソッド: done ()

          Future が '完了' しているなら ‘True’ を返します。

          Future は 'キャンセルされた' か、または *note set_result():
          3155. メソッドや *note set_exception(): 3156. メソッドの呼び出
          しにより結果や例外が設定された場合に '完了' とみなされます。

      -- メソッド: cancelled ()

          Future が 'キャンセルされた' 場合に ‘True’ を返します。

          通常の場合、このメソッドは Future に処理結果や例外を設定する前
          に Future が 'キャンセルされていない' ことを確認するために使用
          されます:

               if not fut.cancelled():
                   fut.set_result(42)

      -- メソッド: add_done_callback (callback, *, context=None)

          Future が '完了' したときに実行されるコールバックを追加します
          。

          'callback' は Future オブジェクトだけを引数にとって呼び出され
          ます。

          このメソッドが呼び出される時点ですでに Future が '完了' してい
          る場合、コールバックは *note loop.call_soon(): ad2. メソッドに
          よりスケジュールされます。

          オプションのキーワード引数 'context' を使って、コールバック
          *callback* を実行する際のコンテキスト *note
          contextvars.Context: 150d. を設定することができます。コンテキ
          スト 'context' が指定されない場合は現在のコンテキストが使われ
          ます。

          コールバックにパラメータを渡すには、次の例のように *note
          functools.partial(): 3ed. を使うことができます:

               # Call 'print("Future:", fut)' when "fut" is done.
               fut.add_done_callback(
                   functools.partial(print, "Future:"))

          バージョン 3.7 で変更: キーワード引数 'context' が追加されまし
          た。詳細は PEP 567(1) を参照してください。

      -- メソッド: remove_done_callback (callback)

          コールバックリストから 'callback' を削除します。

          削除されたコールバックの数を返します。コールバックが複数回追加
          されていない限り、通常は1が返ります。

      -- メソッド: cancel (msg=None)

          Future をキャンセルし、コールバックをスケジュールします。

          Future がすでに '完了' または 'キャンセル' された場合、
          ‘False’ を返します。そうでない場合 Future の状態を 'キャンセル
          ' に変更した上でコールバックをスケジュールし、 ‘True’ を返しま
          す。

          バージョン 3.9 で変更: Added the 'msg' parameter.

      -- メソッド: exception ()

          この Future オブジェクトに設定された例外を返します。

          例外 (または例外が設定されていないときは ‘None’) は Future が
          '完了' している場合のみ返されます。

          Future が 'キャンセルされた' 場合、このメソッドは *note
          CancelledError: 19d. 例外を送出します。

          Future が '未完了' の場合、このメソッドは *note
          InvalidStateError: 3159. 例外を送出します。

      -- メソッド: get_loop ()

          Future オブジェクトが束縛されているイベントループを返します。

          Added in version 3.7.

この例は Future オブジェクトを生成し、Future に結果を設定するための非同
期タスクを生成してスケジュールし、そして Future に結果が設定されるまで待
機します:

     async def set_after(fut, delay, value):
         # Sleep for *delay* seconds.
         await asyncio.sleep(delay)

         # Set *value* as a result of *fut* Future.
         fut.set_result(value)

     async def main():
         # Get the current event loop.
         loop = asyncio.get_running_loop()

         # Create a new Future object.
         fut = loop.create_future()

         # Run "set_after()" coroutine in a parallel Task.
         # We are using the low-level "loop.create_task()" API here because
         # we already have a reference to the event loop at hand.
         # Otherwise we could have just used "asyncio.create_task()".
         loop.create_task(
             set_after(fut, 1, '... world'))

         print('hello ...')

         # Wait until *fut* has a result (1 second) and print it.
         print(await fut)

     asyncio.run(main())

     重要: Future オブジェクトは *note concurrent.futures.Future: 1182.
     を模倣してデザインされました。両者の重要な違いは以下の通りです:

        - asyncio の Futures と異なり、 *note concurrent.futures.Future:
          1182. インスタンスは待ち受けできません。

        - *note asyncio.Future.result(): 3223. と *note
          asyncio.Future.exception(): 3226. は 'timeout' 引数を取りませ
          ん。

        - *note asyncio.Future.result(): 3223. と *note
          asyncio.Future.exception(): 3226. は Future が '未完了' の場合
          に *note InvalidStateError: 3159. 例外を送出します。

        - *note asyncio.Future.add_done_callback(): ad6. メソッドによっ
          て登録されたコールバックは、即座に呼び出されません。代わりにコ
          ールバックは *note loop.call_soon(): ad2. によりスケジュールさ
          れます。

        - asyncio の Future は *note concurrent.futures.wait(): 17cd. お
          よび *note concurrent.futures.as_completed(): 15b1. との互換性
          がありません。

        - *note asyncio.Future.cancel(): 1785. accepts an optional ‘msg’
          argument, but *note concurrent.futures.Future.cancel(): 3081.
          does not.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0567/


File: python.info,  Node: トランスポートとプロトコル,  Next: ポリシー,  Prev: Future,  Up: asyncio --- 非同期 I/O

5.18.1.80 トランスポートとプロトコル
....................................

まえがき
........

トランスポートとプロトコルは *note loop.create_connection(): 5ce. のよう
な '低水準の' イベントループ API から使われます。これらはコールバックに
基づくプログラミングスタイルを使うことでネットワークや IPC プロトコル
(HTTP など) の高性能な実装を可能にします。

基本的にトランスポートとプロトコルはライブラリやフレームワークからのみ使
われるべきであり、高水準の asyncio アプリケーションから使われるものでは
ありません。

このドキュメントは *note Transports: 322a. と *note Protocols: 322b. を
扱います。

はじめに
........

最上位の観点からは、トランスポートは 'どのように' バイトデータを送信する
かに影響を与え、いっぽうプロトコルは 'どの' バイトデータを送信するかを決
定します (また、ある程度は 'いつ' も決定します) 。

同じことを違う言い方で表現します: トランスポートはソケット (または同様の
I/O 端点) の抽象化であり、プロトコルはトランスポートから見たときのアプリ
ケーションの抽象化です。

さらにもう一つの見方として、トランスポートとプロトコルの2つのインターフ
ェースは、協調してネットワーク I/O やプロセス間 I/O の抽象インターフェー
スを定義しています。

トランスポートオブジェクトとプロトコルオブジェクトの間には常に1対1の関係
があります: プロトコルはデータを送信するためにトランスポートのメソッドを
呼び出し、トランスポートは受信したデータを渡すためにプロトコルのメソッド
を呼び出します。

ほとんどの接続に基づくイベントループメソッド (*note
loop.create_connection(): 5ce. など) は通常 'protocol_factory' 引数を受
け取り、 'Transport' オブジェクトで表現される確立した接続に対する
'Protocol' オブジェクトを生成するために使います。そのようなメソッドは通
常 ‘(transport, protocol)’ タプルを返します。

内容
....

このページは以下の節から構成されます:

   * *note Transports: 322a. 節は asyncio の *note BaseTransport: 322c,
     *note ReadTransport: 3203, *note WriteTransport: 3204, *note
     Transport: 322d, *note DatagramTransport: 1717, および *note
     SubprocessTransport: 3211. クラスについて記述しています。

   * *note Protocols: 322b. 節は asyncio の *note BaseProtocol: 322e,
     *note Protocol: 322f, *note BufferedProtocol: a6b, *note
     DatagramProtocol: 69a, および *note SubprocessProtocol: 3210. クラ
     スについて記述しています。

   * *note Examples: 3230. 節はトランスポート、プロトコル、および低水準
     のイベントループ API の利用方法を紹介しています。

* Menu:

* トランスポート::
* プロトコル::
* 使用例: 使用例<25>.


File: python.info,  Node: トランスポート,  Next: プロトコル,  Up: トランスポートとプロトコル

5.18.1.81 トランスポート
........................

'ソースコード:' Lib/asyncio/transports.py(1)

__________________________________________________________________

トランスポートはさまざまな通信方法を抽象化するために *note asyncio: 8. が
提供するクラス群です。

トランスポートオブジェクトは常に *note asyncio イベントループ: d46. によ
ってインスタンス化されます。

asyncio は TCP, UDP, SSL, およびサブプロセスパイプのトランスポートを実装
しています。利用可能なトランスポートのメソッドはトランスポートの種類に依
存します。

トランスポートクラスは *note スレッド安全ではありません: 3151.。

* Menu:

* トランスポートのクラス階層構造::
* 基底トランスポート::
* 読み出し専用のトランスポート::
* 書き込み専用のトランスポート::
* データグラムトランスポート::
* サブプロセス化されたトランスポート::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/transports.py


File: python.info,  Node: トランスポートのクラス階層構造,  Next: 基底トランスポート,  Up: トランスポート

5.18.1.82 トランスポートのクラス階層構造
........................................

 -- クラス: asyncio.BaseTransport

     全てのトランスポートの基底クラスです。すべての asyncio トランスポー
     トが共有するメソッドを含んでいます。

 -- クラス: asyncio.WriteTransport (BaseTransport)

     書き込み専用の接続に対する基底トランスポートクラスです。

     'WriteTransport' クラスのインスタンスは *note
     loop.connect_write_pipe(): 31ab. イベントループメソッドから返され、
     *note loop.subprocess_exec(): 31a7. のようなサブプロセスに関連する
     メソッドから利用されます。

 -- クラス: asyncio.ReadTransport (BaseTransport)

     読み込み専用の接続に対する基底トランスポートクラスです。

     Instances of the 'ReadTransport' class are returned from the *note
     loop.connect_read_pipe(): 31aa. event loop method and are also used
     by subprocess-related methods like *note loop.subprocess_exec():
     31a7.

 -- クラス: asyncio.Transport (WriteTransport, ReadTransport)

     TCP 接続のような、読み出しと書き込みの双方向のトランスポートを表現
     するインターフェースです。

     ユーザーはトランスポートを直接インスタンス化することはありません; ユ
     ーザーは、ユーティリティ関数にプロトコルファクトリとその他トランス
     ポートとプロトコルを作成するために必要な情報を渡して呼び出します。

     'Transport' クラスのインスタンスは、*note loop.create_connection():
     5ce, *note loop.create_unix_connection(): 3167, *note
     loop.create_server(): ae1, *note loop.sendfile(): 31f9. などのイベ
     ントループメソッドから返されたり、これらのメソッドから利用されたり
     します。

 -- クラス: asyncio.DatagramTransport (BaseTransport)

     データグラム (UDP) 接続のためのトランスポートです。

     'DatagramTransport' クラスのインスタンスは *note
     loop.create_datagram_endpoint(): 6fe. イベントループメソッドから返
     されます。

 -- クラス: asyncio.SubprocessTransport (BaseTransport)

     親プロセスとその子プロセスの間の接続を表現する抽象クラスです。

     'SubprocessTransport' クラスのインスタンスは *note
     loop.subprocess_shell(): 31a8. と *note loop.subprocess_exec():
     31a7. の2つのイベントループメソッドから返されます。


File: python.info,  Node: 基底トランスポート,  Next: 読み出し専用のトランスポート,  Prev: トランスポートのクラス階層構造,  Up: トランスポート

5.18.1.83 基底トランスポート
............................

 -- メソッド: BaseTransport.close ()

     トランスポートをクローズします。

     トランスポートが発信データのバッファーを持っていた場合、バッファー
     されたデータは非同期にフラッシュされます。それ以降データは受信され
     ません。バッファーされていたデータがすべてフラッシュされた後、その
     プロトコルの *note protocol.connection_lost(): 3233. メソッドが引数
     *note None: 641. で呼び出されます。一度閉じたトランスポートは、使用
     されるべきではありません。

 -- メソッド: BaseTransport.is_closing ()

     トランスポートを閉じている最中か閉じていた場合 ‘True’ を返します。

 -- メソッド: BaseTransport.get_extra_info (name, default=None)

     トランスポートまたはそれが背後で利用しているリソースの情報を返しま
     す。

     'name' は取得するトランスポート特有の情報を表す文字列です。

     'default' は、取得したい情報が取得可能でなかったり、サードパーティ
     のイベントループ実装や現在のプラットフォームがその情報の問い合わせ
     をサポートしていない場合に返される値です。

     例えば、以下のコードはトランスポート内のソケットオブジェクトを取得
     しようとします:

          sock = transport.get_extra_info('socket')
          if sock is not None:
              print(sock.getsockopt(...))

     いくつかのトランスポートで問い合わせ可能な情報のカテゴリを示します:

        * ソケット:

             - ‘'peername'’: ソケットが接続されているリモートアドレスで
               、*note socket.socket.getpeername(): 3234. の結果になりま
               す (エラーのときは ‘None’)

             - ‘'socket'’: *note socket.socket: d6e. のインスタンスにな
               ります

             - ‘'sockname'’: ソケット自身のアドレスで、*note
               socket.socket.getsockname(): 3235. の結果になります

        * SSL ソケット:

             - ‘'compression'’: 圧縮アルゴリズムで、*note
               ssl.SSLSocket.compression(): 1118. の結果になります。圧縮
               されていないときは ‘None’ になります

             - ‘'cipher'’: 3 個の値 (使用されている暗号アルゴリズムの名
               称、使用が定義されている SSL プロトコルのバージョン、およ
               び使用されている秘密鍵のビット数) からなるタプルで、*note
               ssl.SSLSocket.cipher(): 3236. の結果になります

             - ‘'peercert'’: ピアの証明書で、*note
               ssl.SSLSocket.getpeercert(): f84. の結果になります

             - ‘'sslcontext'’: *note ssl.SSLContext: 274. のインスタンス
               になります

             - ‘'ssl_object'’: *note ssl.SSLObject: b4f. または *note
               ssl.SSLSocket: 8b8. インスタンス

        * パイプ:

             - ‘'pipe'’: パイプオブジェクトです

        * サブプロセス:

             - ‘'subprocess'’: *note subprocess.Popen: 17e. のインスタン
               スになります

 -- メソッド: BaseTransport.set_protocol (protocol)

     トランスポートに新しいプロトコルを設定します。

     プロトコルの切り替えは、両方のプロトコルのドキュメントで切り替えが
     サポートされている場合にのみ行うべきです。

 -- メソッド: BaseTransport.get_protocol ()

     現在のプロトコルを返します。


File: python.info,  Node: 読み出し専用のトランスポート,  Next: 書き込み専用のトランスポート,  Prev: 基底トランスポート,  Up: トランスポート

5.18.1.84 読み出し専用のトランスポート
......................................

 -- メソッド: ReadTransport.is_reading ()

     トランスポートが新しいデータを受信中の場合 ‘True’ を返します。

     Added in version 3.7.

 -- メソッド: ReadTransport.pause_reading ()

     トランスポートの受信側を一時停止します。 *note resume_reading():
     aeb. メソッドが呼び出されるまでプロトコルの *note
     protocol.data_received(): 16f8. メソッドにデータは渡されません。

     バージョン 3.7 で変更: このメソッドはべき等です。すなわちトランスポ
     ートがすでに停止していたりクローズしていても呼び出すことができます
     。

 -- メソッド: ReadTransport.resume_reading ()

     受信を再開します。データが読み込み可能になるとプロトコルの *note
     protocol.data_received(): 16f8. メソッドが再び呼び出されるようにな
     ります。

     バージョン 3.7 で変更: このメソッドはべき等です。すなわちトランスポ
     ートがすでにデータを読み込み中であっても呼び出すことができます。


File: python.info,  Node: 書き込み専用のトランスポート,  Next: データグラムトランスポート,  Prev: 読み出し専用のトランスポート,  Up: トランスポート

5.18.1.85 書き込み専用のトランスポート
......................................

 -- メソッド: WriteTransport.abort ()

     未完了の処理が完了するのを待たず、即座にトランスポートをクローズし
     ます。バッファーされているデータは失われます。このメソッドの呼び出
     し以降データは受信されません。最終的にプロトコルの *note
     protocol.connection_lost(): 3233. メソッドが引数 *note None: 641. で
     呼び出されます。

 -- メソッド: WriteTransport.can_write_eof ()

     トランスポートが *note write_eof(): 323c. メソッドをサポートしてい
     る場合 *note True: bdb. を返し、そうでない場合は *note False: b05.
     を返します。

 -- メソッド: WriteTransport.get_write_buffer_size ()

     トランスポートで使用されている出力バッファーの現在のサイズを返しま
     す。

 -- メソッド: WriteTransport.get_write_buffer_limits ()

     書き込みフロー制御の '最高' および '最低' 水位点を取得します。
     ‘(low, high)’ タプルを返します。ここで 'low' と 'high' はバイト数を
     あらわす正の整数です。

     水位点の設定は *note set_write_buffer_limits(): 323e. で行います。

     Added in version 3.4.2.

 -- メソッド: WriteTransport.set_write_buffer_limits (high=None,
          low=None)

     書き込みフロー制御の '最高' および '最低' 水位点を設定します。

     (バイト数をあらわす) これら2つの値はプロトコルの *note
     protocol.pause_writing(): 323f. と *note protocol.resume_writing():
     3240. の2つのメソッドがいつ呼ばれるかを制御します。指定する場合、
     'low' は 'high' と等しいかまたは 'high' より小さくなければなりませ
     ん。また、 'high' も 'low' も負の値を指定することはできません。

     *note pause_writing(): 323f. はバッファーサイズが 'high' の値以上に
     なった場合に呼び出されます。書き込みが一時停止している場合、バッフ
     ァーサイズが 'low' の値以下になると *note resume_writing(): 3240. メ
     ソッドが呼び出されます。

     デフォルト値は実装固有になります。 'high' のみ与えられた場合、
     'low' は 'high' 以下の実装固有のデフォルト値になります。 'high' を
     ゼロに設定すると 'low' も強制的にゼロになり、バッファーが空でなくな
     るとすぐに *note pause_writing(): 323f. メソッドが呼び出されるよう
     になります。 'low' をゼロに設定すると、バッファーが空にな *note
     resume_writing(): 3240. が呼び出されるようになります。どちらかにゼ
     ロを設定することは I/O と計算を並行に実行する機会を減少させるため、
     一般に最適ではありません。

     上限値と下限値を取得するには *note get_write_buffer_limits(): d92.
     メソッドを使ってください。

 -- メソッド: WriteTransport.write (data)

     トランスポートにバイト列 'data' を書き込みます。

     このメソッドはブロックしません; データをバッファーし、非同期に送信
     する準備を行います。

 -- メソッド: WriteTransport.writelines (list_of_data)

     バイト列のデータのリスト (またはイテラブル) をトランスポートに書き
     込みます。この振る舞いはイテラブルを yield して各要素で *note
     write(): 3241. を呼び出すことと等価ですが、より効率的な実装となる場
     合があります。

 -- メソッド: WriteTransport.write_eof ()

     バッファーされた全てのデータをフラッシュした後トランスポートの送信
     側をクローズします。送信側をクローズした後もデータを受信することは
     可能です。

     このメソッドはトランスポート (例えば SSL) がハーフクローズドな接続
     をサポートしていない場合 *note NotImplementedError: 209. を送出しま
     す。


File: python.info,  Node: データグラムトランスポート,  Next: サブプロセス化されたトランスポート,  Prev: 書き込み専用のトランスポート,  Up: トランスポート

5.18.1.86 データグラムトランスポート
....................................

 -- メソッド: DatagramTransport.sendto (data, addr=None)

     リモートピア 'addr' (トランスポート依存の対象アドレス) にバイト列
     'data' を送信します。'addr' が *note None: 641. の場合、データはト
     ランスポートの作成時に指定された送信先に送られます。

     このメソッドはブロックしません; データをバッファーし、非同期に送信
     する準備を行います。

     バージョン 3.13 で変更: このメソッドは、長さがゼロのデータグラムを
     送信するために、空のバイトオブジェクトで呼び出すこともできます。フ
     ロー制御に使用されるバッファサイズ計算も、データグラムヘッダーを考
     慮するように更新されました。

 -- メソッド: DatagramTransport.abort ()

     未完了の処理が完了するのを待たず、即座にトランスポートをクローズし
     ます。バッファーされているデータは失われます。このメソッドの呼び出
     し以降データは受信されません。最終的にプロトコルの *note
     protocol.connection_lost(): 3233. メソッドが引数 *note None: 641. で
     呼び出されます。


File: python.info,  Node: サブプロセス化されたトランスポート,  Prev: データグラムトランスポート,  Up: トランスポート

5.18.1.87 サブプロセス化されたトランスポート
............................................

 -- メソッド: SubprocessTransport.get_pid ()

     サブプロセスのプロセス ID (整数) を返します。

 -- メソッド: SubprocessTransport.get_pipe_transport (fd)

     整数のファイル記述子 'fd' に該当する通信パイプのトランスポートを返
     します:

        * ‘0’: 標準入力 ('stdin') の読み込み可能ストリーミングトランスポ
          ート。サブプロセスが ‘stdin=PIPE’ で作成されていない場合は
          *note None: 641.

        * ‘1’: 標準出力 ('stdout') の書き込み可能ストリーミングトランス
          ポート。サブプロセスが ‘stdout=PIPE’ で作成されていない場合は
          *note None: 641.

        * ‘2’: 標準エラー出力 ('stderr') の書き込み可能ストリーミングト
          ランスポート。サブプロセスが ‘stderr=PIPE’ で作成されていない
          場合は *note None: 641.

        * その他の 'fd': *note None: 641.

 -- メソッド: SubprocessTransport.get_returncode ()

     サブプロセスのリターンコードを整数で返します。サブプロセスがリター
     ンしなかった場合は *note None: 641. を返します。 *note
     subprocess.Popen.returncode: 1913. 属性と同じです。

 -- メソッド: SubprocessTransport.kill ()

     サブプロセスを強制終了 (kill) します。

     POSIX システムでは、この関数はサブプロセスに SIGKILL を送信します。
     Windows では、このメソッドは *note terminate(): 3249. の別名です。

     *note subprocess.Popen.kill(): 1385. も参照してください。

 -- メソッド: SubprocessTransport.send_signal (signal)

     サブプロセスにシグナル 'signal' を送信します。*note
     subprocess.Popen.send_signal(): 1386. と同じです。

 -- メソッド: SubprocessTransport.terminate ()

     サブプロセスを停止します。

     POSIX システムでは、このメソッドはサブプロセスに *note SIGTERM:
     1387. を送信します。Windows では、Windows API 関数
     ‘TerminateProcess()’ がサブプロセスを停止するために呼び出されます。

     *note subprocess.Popen.terminate(): 1384. も参照してください。

 -- メソッド: SubprocessTransport.close ()

     *note kill(): 3248. メソッドを呼び出すことでサブプロセスを強制終了
     します。

     サブプロセスがまだリターンしていない場合、 'stdin', 'stdout', およ
     び 'stderr' の各パイプのトランスポートをクローズします。


File: python.info,  Node: プロトコル,  Next: 使用例<25>,  Prev: トランスポート,  Up: トランスポートとプロトコル

5.18.1.88 プロトコル
....................

'ソースコード:' Lib/asyncio/protocols.py(1)

__________________________________________________________________

asyncio はネットワークプロトコルを実装するために使う抽象基底クラス群を提
供します。これらのクラスは *note トランスポート: 31ef. と組み合わせて使
うことが想定されています。

抽象基底プロトコルクラスの派生クラスはメソッドの一部または全てを実装する
ことができます。これらのメソッドは全てコールバックです: それらは、データ
を受信した、などの決まったイベントに対してトランスポートから呼び出されま
す。基底プロトコルメソッドは対応するトランスポートから呼び出されるべきで
す。

* Menu:

* 基底プロトコル::
* 基底プロトコル: 基底プロトコル<2>.
* ストリーミングプロトコル::
* バッファリングされたストリーミングプロトコル::
* データグラムプロトコル::
* サブプロセスプロトコル::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/protocols.py


File: python.info,  Node: 基底プロトコル,  Next: 基底プロトコル<2>,  Up: プロトコル

5.18.1.89 基底プロトコル
........................

 -- クラス: asyncio.BaseProtocol

     全てのプロトコルクラスが共有する全てのメソッドを持った基底プロトコ
     ルクラスです。

 -- クラス: asyncio.Protocol (BaseProtocol)

     ストリーミングプロトコル (TCP, Unix ソケットなど) を実装するための
     基底クラスです。

 -- クラス: asyncio.BufferedProtocol (BaseProtocol)

     受信バッファーを手動で制御するストリーミングプロトコルを実装するた
     めの基底クラスです。

 -- クラス: asyncio.DatagramProtocol (BaseProtocol)

     データグラム (UDP) プロトコルを実装するための基底クラスです。

 -- クラス: asyncio.SubprocessProtocol (BaseProtocol)

     子プロセスと (一方向パイプを通じて) 通信するプロトコルを実装するた
     めの基底クラスです。


File: python.info,  Node: 基底プロトコル<2>,  Next: ストリーミングプロトコル,  Prev: 基底プロトコル,  Up: プロトコル

5.18.1.90 基底プロトコル
........................

全ての asyncio プロトコルは基底プロトコルのコールバックを実装することが
できます。

通信のコールバック
..................

コネクションコールバックは全てのプロトコルから、成功したコネクションそれ
ぞれにつきただ一度だけ呼び出されます。その他の全てのプロトコルコールバッ
クはこれら2つのメソッドの間に呼び出すことができます。

 -- メソッド: BaseProtocol.connection_made (transport)

     コネクションが作成されたときに呼び出されます。

     引数 'transport' はコネクションをあらわすトランスポートです。プロト
     コルはトランスポートへの参照を保存する責任を負います。

 -- メソッド: BaseProtocol.connection_lost (exc)

     コネクションが失われた、あるいはクローズされたときに呼び出されます
     。

     引数は例外オブジェクトまたは *note None: 641. になります。*note
     None: 641. のとき、通常の EOF が受信されたか、あるいはコネクション
     がこちら側から中止またはクローズされたことを意味します。

フロー制御コールバック
......................

フロー制御コールバックは、プロトコルによって実行される書き込み処理を停止
または再開するためにトランスポートから呼び出されます。

詳しくは *note set_write_buffer_limits(): 323e. メソッドのドキュメントを
参照してください。

 -- メソッド: BaseProtocol.pause_writing ()

     トランスポートのバッファーサイズが最高水位点 (high watermark) を超
     えたときに呼び出されます。

 -- メソッド: BaseProtocol.resume_writing ()

     トランスポートのバッファーサイズが最低水位点 (low watermark) に達し
     たきに呼び出されます。

バッファーサイズが最高水位点と等しい場合、 *note pause_writing(): 323f.
は呼び出されません: バッファーサイズは必ず制限値を超えなければなりません
。

それに対して、 *note resume_writing(): 3240. はバッファーサイズが最低水
位点と等しいかそれよりも小さい場合に呼び出されます。これらの境界条件は、
どちらの基準値もゼロである場合の処理が期待通りとなることを保証するために
重要です。


File: python.info,  Node: ストリーミングプロトコル,  Next: バッファリングされたストリーミングプロトコル,  Prev: 基底プロトコル<2>,  Up: プロトコル

5.18.1.91 ストリーミングプロトコル
..................................

*note loop.create_server(): ae1, *note loop.create_unix_server(): 193,
*note loop.create_connection(): 5ce, *note
loop.create_unix_connection(): 3167, *note
loop.connect_accepted_socket(): ae8, *note loop.connect_read_pipe():
31aa, そして *note loop.connect_write_pipe(): 31ab. などのイベントメソッ
ドはストリーミングプロトコルを返すファクトリを受け付けます。

 -- メソッド: Protocol.data_received (data)

     データを受信したときに呼び出されます。'data' は受信したデータを含む
     空ではないバイト列オブジェクトになります。

     データがバッファーされるか、チャンキングされるか、または再構築され
     るかはトランスポートに依存します。一般には、特定のセマンティクスを
     信頼するべきではなく、代わりにデータのパースを全般的かつ柔軟に行う
     べきです。ただし、データは常に正しい順序で受信されます。

     このメソッドは、コネクションがオープンである間は何度でも呼び出すこ
     とができます。

     いっぽうで、 *note protocol.eof_received(): 324f. メソッドは最大で
     も一度だけ呼び出されます。いったん ‘eof_received()’ が呼び出される
     と、それ以降 ‘data_received()’ は呼び出されません。

 -- メソッド: Protocol.eof_received ()

     コネクションの相手方がこれ以上データを送信しないことを伝えてきたと
     き (例えば相手方が asyncio を使用しており、 *note
     transport.write_eof(): 323c. を呼び出した場合) に呼び出されます。

     このメソッドは (‘None’ を含む) 偽値 を返すことがあり、その場合トラ
     ンスポートは自身をクローズします。一方メソッドが真値を返す場合は、
     利用しているプロトコルがトランスポートをクローズするかどうかを決め
     ます。デフォルトの実装は ‘None’ を返すため、コネクションは暗黙のう
     ちにクローズされます。

     SSL を含む一部のトランスポートはハーフクローズ接続をサポートしませ
     ん。そのような場合このメソッドが真値を返すとコネクションはクローズ
     されます。

ステートマシン:

     start -> connection_made
         [-> data_received]*
         [-> eof_received]?
     -> connection_lost -> end


File: python.info,  Node: バッファリングされたストリーミングプロトコル,  Next: データグラムプロトコル,  Prev: ストリーミングプロトコル,  Up: プロトコル

5.18.1.92 バッファリングされたストリーミングプロトコル
......................................................

Added in version 3.7.

バッファー付きプロトコルは *note ストリーミングプロトコル: 324e. をサポ
ートするイベントループメソッドで利用することができます。

‘BufferedProtocol’ 実装は受信バッファーの手動での明示的な割り当てや制御
を可能にします。イベントループはプロトコルにより提供されるバッファを利用
することにより不要なデータのコピーを避けることができます。これにより大量
のデータを受信するプロトコルにおいて顕著なパフォーマンスの向上をもたらし
ます。精巧なプロトコル実装によりバッファー割り当ての数を劇的に減少させる
ことができます。

以下に示すコールバックは *note BufferedProtocol: a6b. インスタンスに対し
て呼び出されます:

 -- メソッド: BufferedProtocol.get_buffer (sizehint)

     新しい受信バッファを割り当てるために呼び出します。

     'sizehint' は返されるバッファーの推奨される最小サイズです。
     'sizehint' によって推奨された値より小さい、または大きいサイズのバッ
     ファーを返すことは容認されています。 -1 がセットされた場合、バッフ
     ァーサイズは任意となります。サイズがゼロのバッファーを返すとエラー
     になります。

     ‘get_buffer()’ は *note バッファープロトコル: 371. を実装したオブジ
     ェクトを返さなければなりません。

 -- メソッド: BufferedProtocol.buffer_updated (nbytes)

     受信データによりバッファが更新された場合に呼び出されます。

     'nbytes' はバッファに書き込まれた総バイト数です。

 -- メソッド: BufferedProtocol.eof_received ()

     *note protocol.eof_received(): 324f. メソッドのドキュメントを参照し
     てください。

コネクションの間、 *note get_buffer(): 3251. は何度でも呼び出すことがで
きます。しかし *note protocol.eof_received(): 324f. が呼び出されるのは最
大でも1回で、もし呼び出されると、それ以降 *note get_buffer(): 3251. と
*note buffer_updated(): 3252. が呼び出されることはありません。

ステートマシン:

     start -> connection_made
         [-> get_buffer
             [-> buffer_updated]?
         ]*
         [-> eof_received]?
     -> connection_lost -> end


File: python.info,  Node: データグラムプロトコル,  Next: サブプロセスプロトコル,  Prev: バッファリングされたストリーミングプロトコル,  Up: プロトコル

5.18.1.93 データグラムプロトコル
................................

データグラムプロトコルのインスタンスは *note
loop.create_datagram_endpoint(): 6fe. メソッドに渡されたプロトコルファク
トリによって生成されるべきです。

 -- メソッド: DatagramProtocol.datagram_received (data, addr)

     データグラムを受信したときに呼び出されます。'data' は受信データを含
     むバイトオブジェクトです。'addr' はデータを送信するピアのアドレスで
     す; 正確な形式はトランスポートに依存します。

 -- メソッド: DatagramProtocol.error_received (exc)

     直前の送信あるいは受信が *note OSError: 3f0. を送出したときに呼び出
     されます。'exc' は *note OSError: 3f0. のインスタンスになります。

     このメソッドが呼ばれるのは、トランスポート (UDP など) がデータグラ
     ムを受信側に配信できなかったことが検出されたなどの、まれな場合にお
     いてのみです。ほとんどの場合、データグラムが配信できなければそのま
     ま通知されることなく破棄されます。

     注釈: BSD システム (macOS, FreeBSD など) ではフロー制御はサポートさ
     れていません。これは非常に多くのパケットを書き込もうとしたことによ
     る送信の失敗を検出する信頼できる方法が存在しないためです。

     ソケットは常に '準備ができた状態' のように振る舞いますが、超過した
     パケットは破棄されます。この場合 ‘errno’ を *note errno.ENOBUFS:
     1753. に設定した *note OSError: 3f0. 例外が送出されることがあります
     。もし例外が送出された場合は *note
     DatagramProtocol.error_received(): 3256. に通知されますが、送出され
     ない場合は単に無視されます。


File: python.info,  Node: サブプロセスプロトコル,  Prev: データグラムプロトコル,  Up: プロトコル

5.18.1.94 サブプロセスプロトコル
................................

サブプロセスプロトコルのインスタンスは *note loop.subprocess_exec():
31a7. と *note loop.subprocess_shell(): 31a8. メソッドに渡されたプロトコ
ルファクトリにより生成されるべきです。

 -- メソッド: SubprocessProtocol.pipe_data_received (fd, data)

     子プロセスが標準出力または標準エラー出力のパイプにデータを書き込ん
     だ時に呼び出されます。

     'fd' はパイプのファイル記述子を表す整数です。

     'data' は受信データを含む空でないバイトオブジェクトです。

 -- メソッド: SubprocessProtocol.pipe_connection_lost (fd, exc)

     子プロセスと通信するパイプのいずれかがクローズされたときに呼び出さ
     れます。

     'fd' はクローズされたファイル記述子を表す整数です。

 -- メソッド: SubprocessProtocol.process_exited ()

     子プロセスが終了したときに呼び出されます。

     これは、 *note pipe_data_received(): 172f. と *note
     pipe_connection_lost(): 3258. メソッドの前に呼び出すことができます
     。


File: python.info,  Node: 使用例<25>,  Prev: プロトコル,  Up: トランスポートとプロトコル

5.18.1.95 使用例
................

* Menu:

* TCP エコーサーバー::
* TCP エコークライアント::
* UDP エコーサーバー::
* UDP エコークライアント::
* 既存のソケットへの接続::
* loop.subprocess_exec() と SubprocessProtocol: loop subprocess_exec と SubprocessProtocol.


File: python.info,  Node: TCP エコーサーバー,  Next: TCP エコークライアント,  Up: 使用例<25>

5.18.1.96 TCP エコーサーバー
............................

*note loop.create_server(): ae1. メソッドを使って TCP エコーサーバーを生
成し、受信したデータをそのまま送り返して、最後にコネクションをクローズし
ます:

     import asyncio


     class EchoServerProtocol(asyncio.Protocol):
         def connection_made(self, transport):
             peername = transport.get_extra_info('peername')
             print('Connection from {}'.format(peername))
             self.transport = transport

         def data_received(self, data):
             message = data.decode()
             print('Data received: {!r}'.format(message))

             print('Send: {!r}'.format(message))
             self.transport.write(data)

             print('Close the client socket')
             self.transport.close()


     async def main():
         # Get a reference to the event loop as we plan to use
         # low-level APIs.
         loop = asyncio.get_running_loop()

         server = await loop.create_server(
             EchoServerProtocol,
             '127.0.0.1', 8888)

         async with server:
             await server.serve_forever()


     asyncio.run(main())

参考
....

*note ストリームを使った TCP エコーサーバー: 317a. の例では高水準の
*note asyncio.start_server(): ae7. 関数を使っています。


File: python.info,  Node: TCP エコークライアント,  Next: UDP エコーサーバー,  Prev: TCP エコーサーバー,  Up: 使用例<25>

5.18.1.97 TCP エコークライアント
................................

*note loop.create_connection(): 5ce. メソッドを使った TCP エコークライア
ントは、データを送信したあとコネクションがクローズされるまで待機します:

     import asyncio


     class EchoClientProtocol(asyncio.Protocol):
         def __init__(self, message, on_con_lost):
             self.message = message
             self.on_con_lost = on_con_lost

         def connection_made(self, transport):
             transport.write(self.message.encode())
             print('Data sent: {!r}'.format(self.message))

         def data_received(self, data):
             print('Data received: {!r}'.format(data.decode()))

         def connection_lost(self, exc):
             print('The server closed the connection')
             self.on_con_lost.set_result(True)


     async def main():
         # Get a reference to the event loop as we plan to use
         # low-level APIs.
         loop = asyncio.get_running_loop()

         on_con_lost = loop.create_future()
         message = 'Hello World!'

         transport, protocol = await loop.create_connection(
             lambda: EchoClientProtocol(message, on_con_lost),
             '127.0.0.1', 8888)

         # Wait until the protocol signals that the connection
         # is lost and close the transport.
         try:
             await on_con_lost
         finally:
             transport.close()


     asyncio.run(main())

参考
....

*note ストリームを使った TCP エコークライアント: 3177. の例では高水準の
*note asyncio.open_connection(): ae6. 関数を使っています。


File: python.info,  Node: UDP エコーサーバー,  Next: UDP エコークライアント,  Prev: TCP エコークライアント,  Up: 使用例<25>

5.18.1.98 UDP エコーサーバー
............................

*note loop.create_datagram_endpoint(): 6fe. メソッドを使った UDP エコー
サーバーは受信したデータをそのまま送り返します:

     import asyncio


     class EchoServerProtocol:
         def connection_made(self, transport):
             self.transport = transport

         def datagram_received(self, data, addr):
             message = data.decode()
             print('Received %r from %s' % (message, addr))
             print('Send %r to %s' % (message, addr))
             self.transport.sendto(data, addr)


     async def main():
         print("Starting UDP server")

         # Get a reference to the event loop as we plan to use
         # low-level APIs.
         loop = asyncio.get_running_loop()

         # One protocol instance will be created to serve all
         # client requests.
         transport, protocol = await loop.create_datagram_endpoint(
             EchoServerProtocol,
             local_addr=('127.0.0.1', 9999))

         try:
             await asyncio.sleep(3600)  # Serve for 1 hour.
         finally:
             transport.close()


     asyncio.run(main())


File: python.info,  Node: UDP エコークライアント,  Next: 既存のソケットへの接続,  Prev: UDP エコーサーバー,  Up: 使用例<25>

5.18.1.99 UDP エコークライアント
................................

*note loop.create_datagram_endpoint(): 6fe. メソッドを使った UDP エコー
クライアントはデータを送信し、応答を受信するとトランスポートをクローズし
ます:

     import asyncio


     class EchoClientProtocol:
         def __init__(self, message, on_con_lost):
             self.message = message
             self.on_con_lost = on_con_lost
             self.transport = None

         def connection_made(self, transport):
             self.transport = transport
             print('Send:', self.message)
             self.transport.sendto(self.message.encode())

         def datagram_received(self, data, addr):
             print("Received:", data.decode())

             print("Close the socket")
             self.transport.close()

         def error_received(self, exc):
             print('Error received:', exc)

         def connection_lost(self, exc):
             print("Connection closed")
             self.on_con_lost.set_result(True)


     async def main():
         # Get a reference to the event loop as we plan to use
         # low-level APIs.
         loop = asyncio.get_running_loop()

         on_con_lost = loop.create_future()
         message = "Hello World!"

         transport, protocol = await loop.create_datagram_endpoint(
             lambda: EchoClientProtocol(message, on_con_lost),
             remote_addr=('127.0.0.1', 9999))

         try:
             await on_con_lost
         finally:
             transport.close()


     asyncio.run(main())


File: python.info,  Node: 既存のソケットへの接続,  Next: loop subprocess_exec と SubprocessProtocol,  Prev: UDP エコークライアント,  Up: 使用例<25>

5.18.1.100 既存のソケットへの接続
.................................

プロトコルを設定した *note loop.create_connection(): 5ce. メソッドを使っ
てソケットがデータを受信するまで待機します:

     import asyncio
     import socket


     class MyProtocol(asyncio.Protocol):

         def __init__(self, on_con_lost):
             self.transport = None
             self.on_con_lost = on_con_lost

         def connection_made(self, transport):
             self.transport = transport

         def data_received(self, data):
             print("Received:", data.decode())

             # We are done: close the transport;
             # connection_lost() will be called automatically.
             self.transport.close()

         def connection_lost(self, exc):
             # The socket has been closed
             self.on_con_lost.set_result(True)


     async def main():
         # Get a reference to the event loop as we plan to use
         # low-level APIs.
         loop = asyncio.get_running_loop()
         on_con_lost = loop.create_future()

         # Create a pair of connected sockets
         rsock, wsock = socket.socketpair()

         # Register the socket to wait for data.
         transport, protocol = await loop.create_connection(
             lambda: MyProtocol(on_con_lost), sock=rsock)

         # Simulate the reception of data from the network.
         loop.call_soon(wsock.send, 'abc'.encode())

         try:
             await protocol.on_con_lost
         finally:
             transport.close()
             wsock.close()

     asyncio.run(main())

参考
....

*note ファイル記述子の読み込みイベントを監視する: 3181. 例では低レベルの
*note loop.add_reader(): 3182. メソッドを使ってファイル記述子 (FD) を登
録しています。

*note ストリームを使ってデータを待ち受けるオープンなソケットを登録する:
317e. 例ではコルーチン内で *note open_connection(): ae6. 関数によって生
成されたストリームを使っています。


File: python.info,  Node: loop subprocess_exec と SubprocessProtocol,  Prev: 既存のソケットへの接続,  Up: 使用例<25>

5.18.1.101 loop.subprocess_exec() と SubprocessProtocol
.......................................................

サブプロセスからの出力を受け取り、サブプロセスが終了するまで待機するため
に使われるサブプロセスプロトコルの例です。

サブプロセスは *note loop.subprocess_exec(): 31a7. メソッドにより生成さ
れます:

     import asyncio
     import sys

     class DateProtocol(asyncio.SubprocessProtocol):
         def __init__(self, exit_future):
             self.exit_future = exit_future
             self.output = bytearray()
             self.pipe_closed = False
             self.exited = False

         def pipe_connection_lost(self, fd, exc):
             self.pipe_closed = True
             self.check_for_exit()

         def pipe_data_received(self, fd, data):
             self.output.extend(data)

         def process_exited(self):
             self.exited = True
             # process_exited() method can be called before
             # pipe_connection_lost() method: wait until both methods are
             # called.
             self.check_for_exit()

         def check_for_exit(self):
             if self.pipe_closed and self.exited:
                 self.exit_future.set_result(True)

     async def get_date():
         # Get a reference to the event loop as we plan to use
         # low-level APIs.
         loop = asyncio.get_running_loop()

         code = 'import datetime; print(datetime.datetime.now())'
         exit_future = asyncio.Future(loop=loop)

         # Create the subprocess controlled by DateProtocol;
         # redirect the standard output into a pipe.
         transport, protocol = await loop.subprocess_exec(
             lambda: DateProtocol(exit_future),
             sys.executable, '-c', code,
             stdin=None, stderr=None)

         # Wait for the subprocess exit using the process_exited()
         # method of the protocol.
         await exit_future

         # Close the stdout pipe.
         transport.close()

         # Read the output which was collected by the
         # pipe_data_received() method of the protocol.
         data = bytes(protocol.output)
         return data.decode('ascii').rstrip()

     date = asyncio.run(get_date())
     print(f"Current date: {date}")

高水準の API を使って書かれた *note 同様の例: 31be. も参照してください。


File: python.info,  Node: ポリシー,  Next: プラットフォームでのサポート,  Prev: トランスポートとプロトコル,  Up: asyncio --- 非同期 I/O

5.18.1.102 ポリシー
...................

An event loop policy is a global object used to get and set the current
*note event loop: d46, as well as create new event loops.  The default
policy can be *note replaced: 3261. with *note built-in alternatives:
3262. to use different event loop implementations, or substituted by a
*note custom policy: 3263. that can override these behaviors.

The *note policy object: 3264. gets and sets a separate event loop per
'context'.  This is per-thread by default, though custom policies could
define 'context' differently.

Custom event loop policies can control the behavior of *note
get_event_loop(): 2a2, *note set_event_loop(): 1735, and *note
new_event_loop(): 3130.

ポリシーオブジェクトは *note AbstractEventLoopPolicy: 3265. 抽象基底クラ
スで定義された API を実装しなければなりません。

* Menu:

* ポリシーの取得と設定::
* ポリシーオブジェクト::
* プロセスのウオッチャー::
* ポリシーのカスタマイズ::


File: python.info,  Node: ポリシーの取得と設定,  Next: ポリシーオブジェクト,  Up: ポリシー

5.18.1.103 ポリシーの取得と設定
...............................

以下の関数は現在のプロセスに対するポリシーの取得や設定をするために使われ
ます:

 -- の関数: asyncio.get_event_loop_policy ()

     プロセス全体にわたる現在のポリシーを返します。

 -- の関数: asyncio.set_event_loop_policy (policy)

     プロセス全体にわたる現在のポリシーを 'policy' に設定します。

     'policy' が ‘None’ の場合、デフォルトポリシーが現在のポリシーに戻さ
     れます。


File: python.info,  Node: ポリシーオブジェクト,  Next: プロセスのウオッチャー,  Prev: ポリシーの取得と設定,  Up: ポリシー

5.18.1.104 ポリシーオブジェクト
...............................

イベントループポリシーの抽象基底クラスは以下のように定義されています:

 -- クラス: asyncio.AbstractEventLoopPolicy

     asyncio ポリシーの抽象基底クラスです。

      -- メソッド: get_event_loop ()

          現在のコンテキストのイベントループを取得します。

          *note AbstractEventLoop: 92d. のインターフェースを実装したイベ
          ントループオブジェクトを返します。

          このメソッドは ‘None’ を返してはいけません。

          バージョン 3.6 で変更.

      -- メソッド: set_event_loop (loop)

          現在のコンテキストにイベントループ 'loop' を設定します。

      -- メソッド: new_event_loop ()

          新しいイベントループオブジェクトを生成して返します。

          このメソッドは ‘None’ を返してはいけません。

      -- メソッド: get_child_watcher ()

          子プロセスを監視するウオッチャーオブジェクトを返します。

          *note AbstractChildWatcher: 29c. のインターフェースを実装した
          ウオッチャーオブジェクトを返します。

          この関数は Unix 特有です。

          バージョン 3.12 で非推奨.

      -- メソッド: set_child_watcher (watcher)

          子プロセスに対する現在のウオッチャーオブジェクトを 'watcher' に
          設定します。

          この関数は Unix 特有です。

          バージョン 3.12 で非推奨.

asyncio は以下の組み込みポリシーを提供します:

 -- クラス: asyncio.DefaultEventLoopPolicy

     デフォルトの asyncio ポリシーです。Unix では *note
     SelectorEventLoop: 5d3. 、Windows では *note ProactorEventLoop:
     5d4. を使います。

     デフォルトのポリシーを手動でインストールする必要はありません。
     asyncio はデフォルトポリシーを使うように自動的に構成されます。

     バージョン 3.8 で変更: Windows では *note ProactorEventLoop: 5d4. が
     デフォルトで使われるようになりました。

     バージョン 3.12 で非推奨: The *note get_event_loop(): 2a2. method
     of the default asyncio policy now emits a *note DeprecationWarning:
     18a. if there is no current event loop set and it decides to create
     one.  In some future Python release this will become an error.

 -- クラス: asyncio.WindowsSelectorEventLoopPolicy

     *note SelectorEventLoop: 5d3. イベントループ実装を使った別のイベン
     トループポリシーです。

     *note Availability: 1cbe.: Windows.

 -- クラス: asyncio.WindowsProactorEventLoopPolicy

     *note ProactorEventLoop: 5d4. イベントループ実装を使った別のイベン
     トループポリシーです。

     *note Availability: 1cbe.: Windows.


File: python.info,  Node: プロセスのウオッチャー,  Next: ポリシーのカスタマイズ,  Prev: ポリシーオブジェクト,  Up: ポリシー

5.18.1.105 プロセスのウオッチャー
.................................

プロセスのウオッチャーは Unix 上でイベントループが子プロセスを監視する方
法をカスタマイズすることを可能にします。特に、子プロセスがいつ終了したか
をイベントループは知る必要があります。

asyncio では、子プロセスは *note create_subprocess_exec(): a45. や *note
loop.subprocess_exec(): 31a7. 関数により生成されます。

asyncio は、子プロセスのウオッチャーが実装すべき *note
AbstractChildWatcher: 29c. 抽象基底クラスを定義しており、さらに異なる4つ
の実装クラスを提供しています: *note ThreadedChildWatcher: 448. (デフォル
トでこのクラスが使われるように構成されます), *note
MultiLoopChildWatcher: 29a, *note SafeChildWatcher: 29d, そして *note
FastChildWatcher: 29b. です。

*note サブプロセスとスレッド: 31b7. 節も参照してください。

以下の2つの関数は asyncio のイベントループが使う子プロセスのウオッチャー
の実装をカスタマイズするために使うことができます:

 -- の関数: asyncio.get_child_watcher ()

     現在のポリシーにおける子プロセスのウオッチャーを返します。

     バージョン 3.12 で非推奨.

 -- の関数: asyncio.set_child_watcher (watcher)

     現在ポリシーにおける子プロセスのウオッチャーを 'watcher' に設定しま
     す。 'watcher' は *note AbstractChildWatcher: 29c. 基底クラスで定義
     されたメソッドを実装していなければなりません。

     バージョン 3.12 で非推奨.

     注釈: サードパーティのイベントループ実装は子プロセスのウオッチャー
     のカスタマイズをサポートしていない可能性があります。そのようなイベ
     ントループでは、 *note set_child_watcher(): 29e. 関数の利用は禁止さ
     れているか、または何の効果もありません。

 -- クラス: asyncio.AbstractChildWatcher

      -- メソッド: add_child_handler (pid, callback, *args)

          新しい子プロセスのハンドラを登録します。

          プロセス ID (PID) が 'pid' であるプロセスが終了した時に
          ‘callback(pid, returncode, *args)’ コールバック関数が呼び出さ
          れるように手配します。同じプロセスに対して別のコールバックを登
          録した場合、以前登録したハンドラを置き換えます。

          'callback' はスレッドセーフな呼び出し可能オブジェクトでなけれ
          ばなりません。

      -- メソッド: remove_child_handler (pid)

          プロセス ID (PID) が 'pid' であるプロセスに対して登録されたハ
          ンドラを削除します。

          ハンドラが正しく削除された場合 ‘True’ を返します。削除するハン
          ドラがない場合は ‘False’ を返します。

      -- メソッド: attach_loop (loop)

          ウオッチャーをイベントループに接続します。

          ウオッチャーがイベントループに接続されている場合、新しいイベン
          トループに接続される前に接続済みのイベントループから切り離され
          ます。

          注: 引数は ‘None’ をとることができます。

      -- メソッド: is_active ()

          ウオッチャーが利用可能な状態なら ‘True’ を返します。

          現在の子プロセスのウオッチャーが 'アクティブでない' 場合にサブ
          プロセスを生成すると *note RuntimeError: 17a. 例外が送出されま
          す。

          Added in version 3.8.

      -- メソッド: close ()

          ウオッチャーをクローズします。

          このメソッドは、ウオッチャーの背後にあるリソースを確実にクリー
          ンアップするために必ず呼び出さなければなりません。

     バージョン 3.12 で非推奨.

 -- クラス: asyncio.ThreadedChildWatcher

     この実装は、各サブプロセスの生成時に新しい待ち受けスレッドを開始し
     ます。

     このクラスは asyncio イベントループがメインでない OS スレッド上で実
     行されていても期待通りに動きます。

     There is no noticeable overhead when handling a big number of
     children ('O'(1) each time a child terminates), but starting a
     thread per process requires extra memory.

     このウオッチャーはデフォルトで使われます。

     Added in version 3.8.

 -- クラス: asyncio.MultiLoopChildWatcher

     この実装はインスタンス化の際に ‘SIGCHLD’ シグナルハンドラを登録しま
     す。これにより、独自の ‘SIGCHLD’ シグナルハンドラをインストールする
     ようなサードパーティのコードを壊す可能性があります。

     このウオッチャーは、各プロセスに明示的に ‘SIGCHLD’ シグナルをポーリ
     ングさせることにより、プロセスを生成する他のコードを中断させないよ
     うにします。

     いったんウオッチャーがインストールされると、異なるスレッドからのサ
     ブプロセスの実行について特に制限はありません。

     The solution is safe but it has a significant overhead when
     handling a big number of processes ('O'('n') each time a ‘SIGCHLD’
     is received).

     Added in version 3.8.

     バージョン 3.12 で非推奨.

 -- クラス: asyncio.SafeChildWatcher

     この実装はメインスレッドでアクティブなイベントループを使って
     ‘SIGCHLD’ シグナルを処理します。メインスレッドでイベントループが実
     行中でない場合、別のスレッドからサブプロセスを生成することはできま
     せん (*note RuntimeError: 17a. 例外が送出されます)。

     このウオッチャーは、各プロセスに明示的に ‘SIGCHLD’ シグナルをポーリ
     ングさせることにより、プロセスを生成する他のコードを中断させないよ
     うにします。

     This solution is as safe as *note MultiLoopChildWatcher: 29a. and
     has the same 'O'('n') complexity but requires a running event loop
     in the main thread to work.

     バージョン 3.12 で非推奨.

 -- クラス: asyncio.FastChildWatcher

     この実装は終了した子プロセスを得るために直接 ‘os.waitpid(-1)’ を呼
     び出します。これにより、プロセスを生成してその終了を待ち受ける別の
     コードを壊す可能性があります。

     There is no noticeable overhead when handling a big number of
     children ('O'(1) each time a child terminates).

     このソリューションは、 *note SafeChildWatcher: 29d. と同様にメイン
     スレッドで実行中のイベントループが必要です。

     バージョン 3.12 で非推奨.

 -- クラス: asyncio.PidfdChildWatcher

     この実装は子プロセスの終了を待ち受けるためにプロセスのファイル記述
     子 (pidfds) をポーリングします。いくつかの点で、 *note
     PidfdChildWatcher: 446. は "Goldilocks" 的な子プロセスのウオッチャ
     ー実装です。この実装はシグナルもスレッドも必要とせず、イベントルー
     プの外で生成されたいかなるプロセスとも干渉せず、しかもイベントルー
     プから生成されたサブプロセスの数に対して線形にスケールします。主な
     欠点は pidfds が Linux 特有であり、最近のカーネル (5.3+) でしか動か
     ないことです。

     Added in version 3.9.


File: python.info,  Node: ポリシーのカスタマイズ,  Prev: プロセスのウオッチャー,  Up: ポリシー

5.18.1.106 ポリシーのカスタマイズ
.................................

新しいイベントループのポリシーを実装するためには、以下に示すように *note
DefaultEventLoopPolicy: 326d. を継承して振る舞いを変更したいメソッドをオ
ーバーライドすることが推奨されます。:

     class MyEventLoopPolicy(asyncio.DefaultEventLoopPolicy):

         def get_event_loop(self):
             """Get the event loop.

             This may be None or an instance of EventLoop.
             """
             loop = super().get_event_loop()
             # Do something with loop ...
             return loop

     asyncio.set_event_loop_policy(MyEventLoopPolicy())


File: python.info,  Node: プラットフォームでのサポート,  Next: Extending,  Prev: ポリシー,  Up: asyncio --- 非同期 I/O

5.18.1.107 プラットフォームでのサポート
.......................................

*note asyncio: 8. モジュールは可搬的であるようにデザインされていますが、
いくつかのプラットフォームでは、その根底にあるアーキテクチャや性能による
微妙な動作の違いや制限があります。

* Menu:

* 全てのプラットホーム::
* Windows: Windows<74>.
* macOS: macOS<47>.


File: python.info,  Node: 全てのプラットホーム,  Next: Windows<74>,  Up: プラットフォームでのサポート

5.18.1.108 全てのプラットホーム
...............................

   * *note loop.add_reader(): 3182. と *note loop.add_writer(): 31fd. を
     ファイル I/O を監視するためには使えません。


File: python.info,  Node: Windows<74>,  Next: macOS<47>,  Prev: 全てのプラットホーム,  Up: プラットフォームでのサポート

5.18.1.109 Windows
..................

'ソースコード:' Lib/asyncio/proactor_events.py(1),
Lib/asyncio/windows_events.py(2), Lib/asyncio/windows_utils.py(3)

__________________________________________________________________

バージョン 3.8 で変更: Windows では *note ProactorEventLoop: 5d4. がデフ
ォルトのイベントループになりました。

全ての Windows 上のイベントループは以下のメソッドをサポートしません:

   * *note loop.create_unix_connection(): 3167. と *note
     loop.create_unix_server(): 193. はサポートされません。 *note
     socket.AF_UNIX: 178a. ソケットファミリーは Unix 固有です。

   * *note loop.add_signal_handler(): 3206. と *note
     loop.remove_signal_handler(): 3207. はサポートされていません。

*note SelectorEventLoop: 5d3. は以下の制限があります:

   * *note SelectSelector: 327a. はソケットイベントの待ち受けに使われま
     す: このクラスはソケットをサポートしますが 512 ソケットまでに制限さ
     れています。

   * *note loop.add_reader(): 3182. と *note loop.add_writer(): 31fd. は
     ソケットハンドルのみを受け付けます (たとえばパイプファイル記述子は
     サポートされていません)。

   * パイプはサポートされていません。従って *note
     loop.connect_read_pipe(): 31aa. と *note loop.connect_write_pipe():
     31ab. の2つのメソッドは未実装です。

   * *note Subprocesses: 3124. はサポートされていません。すなわち *note
     loop.subprocess_exec(): 31a7. と *note loop.subprocess_shell():
     31a8. の2つのメソッドは未実装です。

*note ProactorEventLoop: 5d4. は以下の制限があります:

   * *note loop.add_reader(): 3182. と *note loop.add_writer(): 31fd. は
     サポートされていません。

Windows のモノトニッククロックの時間分解能は、通常約15.6ミリ秒です。最高
分解能は0.5ミリ秒です。分解能はハードウエア (HPET(4) が利用可能かどうか)
および WIndows の設定に依存します。

* Menu:

* Windows におけるサブプロセスのサポート::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/proactor_events.py

   (2) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/windows_events.py

   (3) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/windows_utils.py

   (4) https://en.wikipedia.org/wiki/High_Precision_Event_Timer


File: python.info,  Node: Windows におけるサブプロセスのサポート,  Up: Windows<74>

5.18.1.110 Windows におけるサブプロセスのサポート
.................................................

Windows において、デフォルトのイベントループ *note ProactorEventLoop:
5d4. はサブプロセスをサポートしますが、 *note SelectorEventLoop: 5d3. は
サポートしません。

*note policy.set_child_watcher(): 2a0. 関数もサポートされません。 *note
ProactorEventLoop: 5d4. は子プロセスを監視するための異なる仕組みを持って
います。


File: python.info,  Node: macOS<47>,  Prev: Windows<74>,  Up: プラットフォームでのサポート

5.18.1.111 macOS
................

最近の macOS バージョンは完全にサポートされています。

10.8 以前の macOS
.................

macOS 10.6, 10.7 および 10.8 では、デフォルトイベントループは *note
selectors.KqueueSelector: 327d. をしていますが、このクラスはこれらの
macOS バージョンのキャラクターデバイスをサポートしていません。これらの
macOS バージョンでキャラクターデバイスをサポートするためには *note
SelectorEventLoop: 5d3. で *note SelectSelector: 327a. または *note
PollSelector: ba4. を使うように手動で設定します。以下はその例です:

     import asyncio
     import selectors

     selector = selectors.SelectSelector()
     loop = asyncio.SelectorEventLoop(selector)
     asyncio.set_event_loop(loop)


File: python.info,  Node: Extending,  Next: 高水準の API インデックス,  Prev: プラットフォームでのサポート,  Up: asyncio --- 非同期 I/O

5.18.1.112 Extending
....................

The main direction for *note asyncio: 8. extending is writing custom
'event loop' classes.  Asyncio has helpers that could be used to
simplify this task.

     注釈: Third-parties should reuse existing asyncio code with
     caution, a new Python version is free to break backward
     compatibility in 'internal' part of API.

* Menu:

* Writing a Custom Event Loop::
* Future and Task private constructors::
* Task lifetime support::


File: python.info,  Node: Writing a Custom Event Loop,  Next: Future and Task private constructors,  Up: Extending

5.18.1.113 Writing a Custom Event Loop
......................................

*note asyncio.AbstractEventLoop: 92d. declares very many methods.
Implementing all them from scratch is a tedious job.

A loop can get many common methods implementation for free by inheriting
from ‘asyncio.BaseEventLoop’.

In turn, the successor should implement a bunch of 'private' methods
declared but not implemented in ‘asyncio.BaseEventLoop’.

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.


File: python.info,  Node: Future and Task private constructors,  Next: Task lifetime support,  Prev: Writing a Custom Event Loop,  Up: Extending

5.18.1.114 Future and Task private constructors
...............................................

*note asyncio.Future: b9b. and *note asyncio.Task: 4a5. should be never
created directly, please use corresponding *note loop.create_future():
c47. and *note loop.create_task(): 9aa, or *note asyncio.create_task():
5c7. factories instead.

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.

For this purpose the following, 'private' constructors are listed:

 -- メソッド: Future.__init__ (*, loop=None)

     Create a built-in future instance.

     'loop' is an optional event loop instance.

 -- メソッド: Task.__init__ (coro, *, loop=None, name=None,
          context=None)

     Create a built-in task instance.

     'loop' is an optional event loop instance.  The rest of arguments
     are described in *note loop.create_task(): 9aa. description.

     バージョン 3.11 で変更: 'context' argument is added.


File: python.info,  Node: Task lifetime support,  Prev: Future and Task private constructors,  Up: Extending

5.18.1.115 Task lifetime support
................................

A third party task implementation should call the following functions to
keep a task visible by *note asyncio.all_tasks(): 924. and *note
asyncio.current_task(): 44a.:

 -- の関数: asyncio._register_task (task)

     Register a new 'task' as managed by 'asyncio'.

     Call the function from a task constructor.

 -- の関数: asyncio._unregister_task (task)

     Unregister a 'task' from 'asyncio' internal structures.

     The function should be called when a task is about to finish.

 -- の関数: asyncio._enter_task (loop, task)

     Switch the current task to the 'task' argument.

     Call the function just before executing a portion of embedded
     'coroutine' (*note coroutine.send(): 1f2c. or *note
     coroutine.throw(): 4c4.).

 -- の関数: asyncio._leave_task (loop, task)

     Switch the current task back from 'task' to ‘None’.

     Call the function just after *note coroutine.send(): 1f2c. or *note
     coroutine.throw(): 4c4. execution.


File: python.info,  Node: 高水準の API インデックス,  Next: 低水準の API インデックス,  Prev: Extending,  Up: asyncio --- 非同期 I/O

5.18.1.116 高水準の API インデックス
....................................

このページには、すべての高水準の 非同期/待機 可能な asyncio API が一覧に
なっています。

* Menu:

* Task::
* キュー: キュー<2>.
* サブプロセス: サブプロセス<2>.
* ストリーム: ストリーム<2>.
* 同期::
* 例外: 例外<13>.


File: python.info,  Node: Task,  Next: キュー<2>,  Up: 高水準の API インデックス

5.18.1.117 Task
...............

ユーティリティは asyncio プログラムを実行し、タスクを作成し、タイムアウ
トのある複数の機能を待っています。

*note run(): 449.                                      イベントループを作成し、コルーチンを実行し、ループを
                                                       閉じます。
                                                       
                                                       
*note Runner: 5cb.                                     複数の非同期関数呼び出しをシンプルにするコンテキスト
                                                       マネージャ。
                                                       
                                                       
*note Task: 4a5.                                       Task オブジェクト
                                                       
                                                       
*note TaskGroup: 19a.                                  タスクのグループを保持するコンテキストマネージャ。グ
                                                       ループに属するすべてのタスクが完了するのを待つのに便
                                                       利で信頼性のある方法を提供します。
                                                       
                                                       
*note create_task(): 5c7.                              asyncio タスクを開始し、それを返します。
                                                       
                                                       
*note current_task(): 44a.                             現在のタスクを返します。
                                                       
                                                       
*note all_tasks(): 924.                                イベントループのまだ終了していないすべてのタスクを返
                                                       します。
                                                       
                                                       
‘await’ *note sleep(): a3d.                            数秒間スリープします。
                                                       
                                                       
‘await’ *note gather(): 5c8.                           並行してスケジュールして、待ちます。
                                                       
                                                       
‘await’ *note wait_for(): 5ca.                         タイムアウトで実行します。
                                                       
                                                       
‘await’ *note shield(): a3e.                           取り消しから保護します。
                                                       
                                                       
‘await’ *note wait(): 44c.                             完了かどうかを監視します。
                                                       
                                                       
*note timeout(): 5c9.                                  タイムアウト付きで実行します。 ‘wait_for’ が適してい
                                                       ない場合に有用です。
                                                       
                                                       
*note to_thread(): 8b6.                                別の OS スレッドで非同期的に関数を実行します。
                                                       
                                                       
*note run_coroutine_threadsafe(): 84f.                 別の OS スレッドからコルーチンの実行をスケジュールし
                                                       ます。
                                                       
                                                       
‘for in’ *note as_completed(): 18f.                    ‘for’ ループ向けにコルーチンの完了を監視します。
                                                       

使用例
......

   * *note asyncio.gather() を使って複数の処理を並列に実行する: 3142. 。

   * *note asyncio.wait_for() を使って強制的にタイムアウトする: 314a. 。

   * *note 非同期処理をキャンセルする: 315f. 。

   * *note asyncio.sleep() を使う: 3140. 。

   * *note Tasks のドキュメント: 3122. も参照してください。


File: python.info,  Node: キュー<2>,  Next: サブプロセス<2>,  Prev: Task,  Up: 高水準の API インデックス

5.18.1.118 キュー
.................

キューは複数の非同期タスクの分散処理、コネクションプールやpub/subパター
ンの実装に適しています。

*note Queue: a44.                                      FIFO キューです。
                                                       
                                                       
*note PriorityQueue: 31cf.                             優先度付きのキューです。
                                                       
                                                       
*note LifoQueue: 31d1.                                 LIFO キュー (スタック) です。
                                                       

使用例
......

   * *note asyncio.Queue を使って複数のタスクを分散処理する: 31d3.

   * *note Queue のドキュメント: 3125. も参照してください。


File: python.info,  Node: サブプロセス<2>,  Next: ストリーム<2>,  Prev: キュー<2>,  Up: 高水準の API インデックス

5.18.1.119 サブプロセス
.......................

サブプロセスを生成したり、シェルコマンドを実行するためのユーティリティで
す。

‘await’ *note create_subprocess_exec(): a45.           サブプロセスを作成します。
                                                       
                                                       
‘await’ *note create_subprocess_shell(): a46.          シェルコマンドを実行します。
                                                       

使用例
......

   * *note シェルコマンドを実行する: 31a3.。

   * *note サブプロセス API: 3124. のドキュメントも参照してください。


File: python.info,  Node: ストリーム<2>,  Next: 同期,  Prev: サブプロセス<2>,  Up: 高水準の API インデックス

5.18.1.120 ストリーム
.....................

ネットワーク IO を利用するための高水準の APIs です。

‘await’ *note open_connection(): ae6.                  TCP コネクションを確立します。
                                                       
                                                       
‘await’ *note open_unix_connection(): 3166.            Unix のソケット接続を確立します。
                                                       
                                                       
‘await’ *note start_server(): ae7.                     TCP サーバーを起動します。
                                                       
                                                       
‘await’ *note start_unix_server(): 3168.               Unix のソケットサーバーを起動します。
                                                       
                                                       
*note StreamReader: 1830.                              ネットワークからデータを受信するための高水準の
                                                       async/await オブジェクトです。
                                                       
                                                       
*note StreamWriter: 1665.                              ネットワークにデータを送信するための高水準の
                                                       async/await オブジェクトです。
                                                       

使用例
......

   * *note TCPクライアントの例: 3162.

   * *note ストリーム API: 3123. のドキュメントも参照してください。


File: python.info,  Node: 同期,  Next: 例外<13>,  Prev: ストリーム<2>,  Up: 高水準の API インデックス

5.18.1.121 同期
...............

タスク内で利用できるスレッド並列処理に似た同期プリミティブです。

*note Lock: a3f.                                       ミューテックスロックです。
                                                       
                                                       
*note Event: a40.                                      イベントオブジェクトです。
                                                       
                                                       
*note Condition: a41.                                  条件変数オブジェクトです。
                                                       
                                                       
*note Semaphore: a42.                                  セマフォ (semaphore) です。
                                                       
                                                       
*note BoundedSemaphore: a43.                           有限セマフォ (bounded semaphore) です。
                                                       
                                                       
*note Barrier: 5cc.                                    バリアーオブジェクト。
                                                       

使用例
......

   * *note asyncio.Event の使用例: 318d. 。

   * *note asyncio.Barrier を使う: 319b.。

   * asyncio の *note 同期プリミティブ: 3126. についてのドキュメントも参
     照してください。


File: python.info,  Node: 例外<13>,  Prev: 同期,  Up: 高水準の API インデックス

5.18.1.122 例外
...............

*note asyncio.CancelledError: 19d.                     タスクがキャンセルされた場合に送出されます。
                                                       *note Task.cancel(): 19c. も参照してください。
                                                       
                                                       
*note asyncio.BrokenBarrierError: 5cd.                 バリアーが破壊された場合に送出されます。
                                                       *note Barrier.wait(): 319a. も参照してください。
                                                       

使用例
......

   * *note CancelledError
     を処理してキャンセル要求に対応するコードを実行する: 315f.

   * *note asyncio に特有な例外の完全なリスト: 31d5. も参照してください
     。


File: python.info,  Node: 低水準の API インデックス,  Next: asyncio での開発,  Prev: 高水準の API インデックス,  Up: asyncio --- 非同期 I/O

5.18.1.123 低水準の API インデックス
....................................

このページでは低水準の asyncio API を全てリストしています。

* Menu:

* イベントループの取得::
* イベントループのメソッド: イベントループのメソッド<2>.
* トランスポート: トランスポート<2>.
* プロトコル: プロトコル<2>.
* イベントループのポリシー::


File: python.info,  Node: イベントループの取得,  Next: イベントループのメソッド<2>,  Up: 低水準の API インデックス

5.18.1.124 イベントループの取得
...............................

*note asyncio.get_running_loop(): ad9.                 実行中のイベントループを取得するために '利用が推奨さ
                                                       れる' 関数です。
                                                       
                                                       
*note asyncio.get_event_loop(): 2a2.                   Get an event loop instance (running or current via
                                                       the current policy).
                                                       
                                                       
*note asyncio.set_event_loop(): 1735.                  ポリシーに基づいて引数のイベントループを "カレント"
                                                       (current event loop) に設定します。
                                                       
                                                       
*note asyncio.new_event_loop(): 3130.                  新しいイベントループのインスタンスを生成します。
                                                       

使用例
......

   * *note asyncio.get_running_loop() を使う: 3227.。


File: python.info,  Node: イベントループのメソッド<2>,  Next: トランスポート<2>,  Prev: イベントループの取得,  Up: 低水準の API インデックス

5.18.1.125 イベントループのメソッド
...................................

See also the main documentation section about the *note
イベントループのメソッド: 31e2.

ライフサイクル
..............

*note loop.run_until_complete(): c45.                  Future/Task/awaitable が完了するまで実行します。
                                                       
                                                       
*note loop.run_forever(): 31e4.                        イベントループを永久に実行します。
                                                       
                                                       
*note loop.stop(): c4a.                                イベントループを停止します。
                                                       
                                                       
*note loop.close(): 31e6.                              イベントループをクローズします。
                                                       
                                                       
*note loop.is_running(): 31e5.                         イベントループが実行中の場合 ‘True’ を返します。
                                                       
                                                       
*note loop.is_closed(): d91.                           イベントループがクローズされている場合 ‘True’ を返し
                                                       ます。
                                                       
                                                       
‘await’ *note loop.shutdown_asyncgens(): c4b.          非同期ジェネレータをクローズします。
                                                       

デバッグ
........

*note loop.set_debug(): d8f.                           デバッグモードを有効化または無効化します。
                                                       
                                                       
*note loop.get_debug(): d90.                           現在のデバッグモードを取得します。
                                                       

コールバックのスケジューリング
..............................

*note loop.call_soon(): ad2.                           コールバックを即座に実行します。
                                                       
                                                       
*note loop.call_soon_threadsafe(): ad3.                *note loop.call_soon(): ad2. のスレッドセーフ版です
                                                       。
                                                       
                                                       
*note loop.call_later(): ad4.                          与えられた遅延時間の '経過後' にコールバックを実行し
                                                       ます。
                                                       
                                                       
*note loop.call_at(): ad5.                             '与えられた時刻に' コールバックを実行します。
                                                       

スレッドプール／プロセスプール
..............................

‘await’ *note loop.run_in_executor(): 8b7.             CPUバウンドなブロッキング関数、またはその他のブロッ
                                                       キング関数を *note concurrent.futures: 1a. 実行オブ
                                                       ジェクト (executor) 上で実行します。
                                                       
                                                       
*note loop.set_default_executor(): 70e.                *note loop.run_in_executor(): 8b7. のデフォルト実行
                                                       オブジェクト (executor) を設定します。
                                                       

タスクとフューチャー
....................

*note loop.create_future(): c47.                       *note Future: b9b. オブジェクトを生成します。
                                                       
                                                       
*note loop.create_task(): 9aa.                         コルーチンを *note Task: 4a5. としてスケジュールしま
                                                       す。
                                                       
                                                       
*note loop.set_task_factory(): d93.                    *note loop.create_task(): 9aa. が *note Tasks: 4a5.
                                                       を生成する際に使われるファクトリを設定します。
                                                       
                                                       
*note loop.get_task_factory(): d94.                    *note loop.create_task(): 9aa. が *note Tasks: 4a5.
                                                       を生成するファクトリを取得します。
                                                       

DNS
...

‘await’ *note loop.getaddrinfo(): be2.                 *note socket.getaddrinfo(): 16bd. の非同期版です。
                                                       
                                                       
‘await’ *note loop.getnameinfo(): be3.                 *note socket.getnameinfo(): 1629. の非同期版です。
                                                       

ネットワークとプロセス間通信 (IPC)
..................................

‘await’ *note loop.create_connection(): 5ce.           TCP接続を確立します。
                                                       
                                                       
‘await’ *note loop.create_server(): ae1.               TCPサーバーを起動します。
                                                       
                                                       
‘await’ *note loop.create_unix_connection(): 3167.     Unix のソケット接続を確立します。
                                                       
                                                       
‘await’ *note loop.create_unix_server(): 193.          Create a Unix socket server.
                                                       
                                                       
‘await’ *note loop.connect_accepted_socket(): ae8.     *note socket: d6e. を ‘(transport, protocol)’ のペア
                                                       でラップします。
                                                       
                                                       
‘await’ *note loop.create_datagram_endpoint(): 6fe.    データグラム (UDP) 接続を確立します。
                                                       
                                                       
‘await’ *note loop.sendfile(): 31f9.                   確立した接続 (transport) を通じてファイルを送信しま
                                                       す。
                                                       
                                                       
‘await’ *note loop.start_tls(): ad7.                   既存の接続を TLS にアップグレードします。
                                                       
                                                       
‘await’ *note loop.connect_read_pipe(): 31aa.          パイプの読み出し側を ‘(transport, protocol)’ のペア
                                                       でラップします。
                                                       
                                                       
‘await’ *note loop.connect_write_pipe(): 31ab.         パイプの書き込み側を ‘(transport, protocol)’ のペア
                                                       でラップします。
                                                       

ソケット
........

‘await’ *note loop.sock_recv(): bdf.                   *note socket: d6e. からデータを受信します。
                                                       
                                                       
‘await’ *note loop.sock_recv_into(): ad8.              *note socket: d6e. からデータを受信し、バッファに送
                                                       信します。
                                                       
                                                       
‘await’ *note loop.sock_recvfrom(): 5d1.               Receive a datagram from the *note socket: d6e.
                                                       
                                                       
‘await’ *note loop.sock_recvfrom_into(): 5d2.          Receive a datagram from the *note socket: d6e. into
                                                       a buffer.
                                                       
                                                       
‘await’ *note loop.sock_sendall(): be0.                *note socket: d6e. にデータを送信します。
                                                       
                                                       
‘await’ *note loop.sock_sendto(): 5d0.                 Send a datagram via the *note socket: d6e. to the
                                                       given address.
                                                       
                                                       
‘await’ *note loop.sock_connect(): d97.                *note socket: d6e. を接続します。
                                                       
                                                       
‘await’ *note loop.sock_accept(): be1.                 *note socket: d6e. の接続を受け入れます。
                                                       
                                                       
‘await’ *note loop.sock_sendfile(): adc.               Send a file over the *note socket: d6e.
                                                       
                                                       
*note loop.add_reader(): 3182.                         ファイル記述子が読み込み可能かどうかの監視を開始しま
                                                       す。
                                                       
                                                       
*note loop.remove_reader(): 31fc.                      ファイル記述子が読み込み可能かどうかの監視を停止しま
                                                       す。
                                                       
                                                       
*note loop.add_writer(): 31fd.                         ファイル記述子が書き込み可能かどうかの監視を開始しま
                                                       す。
                                                       
                                                       
*note loop.remove_writer(): 31fe.                      ファイル記述子が書き込み可能かどうかの監視を停止しま
                                                       す。
                                                       

Unix シグナル
.............

*note loop.add_signal_handler(): 3206.                 *note signal: b4. 用のハンドラーを追加します。
                                                       
                                                       
*note loop.remove_signal_handler(): 3207.              *note signal: b4. 用のハンドラーを削除します。
                                                       

サブプロセス
............

*note loop.subprocess_exec(): 31a7.                    サブプロセスを生成します。
                                                       
                                                       
*note loop.subprocess_shell(): 31a8.                   シェルコマンドからサブプロセスを生成します。
                                                       

エラー処理
..........

*note loop.call_exception_handler(): 320b.             例外ハンドラを呼び出します。
                                                       
                                                       
*note loop.set_exception_handler(): 320a.              新しい例外ハンドラーを設定します。
                                                       
                                                       
*note loop.get_exception_handler(): c48.               現在の例外ハンドラーを取得します。
                                                       
                                                       
*note loop.default_exception_handler(): 320c.          デフォルトの例外ハンドラー実装です。
                                                       

使用例
......

   * *note Using asyncio.new_event_loop() and loop.run_forever(): 3217.

   * *note loop.call_later() を使う: 3219.。

   * ‘loop.create_connection()’ を使って *note an echo-client: 3179. を
     実装する。

   * ‘loop.create_connection()’ を使って *note ソケットに接続する:
     3180.。

   * *note add_reader()
     を使ってファイルデスクリプタの読み込みイベントを監視する: 3181.。

   * *note loop.add_signal_handler() を使う: 321c.。

   * *note loop.subprocess_exec() を使う: 31bf.。


File: python.info,  Node: トランスポート<2>,  Next: プロトコル<2>,  Prev: イベントループのメソッド<2>,  Up: 低水準の API インデックス

5.18.1.126 トランスポート
.........................

全てのトランスポートは以下のメソッドを実装します:

*note transport.close(): 31f2.                         トランスポートをクローズします。
                                                       
                                                       
*note transport.is_closing(): c46.                     トランスポートを閉じている最中か閉じていた場合
                                                       ‘True’ を返します。
                                                       
                                                       
*note transport.get_extra_info(): a6a.                 トランスポートについての情報をリクエストします。
                                                       
                                                       
*note transport.set_protocol(): 3237.                  トランスポートに新しいプロトコルを設定します。
                                                       
                                                       
*note transport.get_protocol(): 3238.                  現在のプロトコルを返します。
                                                       

データを受信できるトランスポート (TCP 接続、 Unix 接続、パイプなど) のメ
ソッドです。該当するトランスポートは *note loop.create_connection():
5ce, *note loop.create_unix_connection(): 3167, *note
loop.connect_read_pipe(): 31aa. などの戻り値です:

読み込みトランスポート
......................

*note transport.is_reading(): aea.                     トランスポートがデータを受信中の場合 ‘True’ を返しま
                                                       す。
                                                       
                                                       
*note transport.pause_reading(): aec.                  データの受信を停止します。
                                                       
                                                       
*note transport.resume_reading(): aeb.                 データの受信を再開します。
                                                       

データを送信できるトランスポート (TCP 接続、 Unix 接続、パイプなど) のメ
ソッドです。該当するトランスポートは *note loop.create_connection():
5ce, *note loop.create_unix_connection(): 3167, *note
loop.connect_write_pipe(): 31ab. などの戻り値です:

トランスポートにデータを書き込みます。
......................................

*note transport.write(): 3241.                         トランスポートにデータを書き込みます。
                                                       
                                                       
*note transport.writelines(): 1693.                    トランスポートにバッファの内容を書き込みます。
                                                       
                                                       
*note transport.can_write_eof(): 323b.                 トランスポートが 終端 (EOF) の送信をサポートしている
                                                       場合 *note True: bdb. を返します。
                                                       
                                                       
*note transport.write_eof(): 323c.                     バッファに残っているデータをフラッシュしてから終端
                                                       (EOF) を送信して、トランスポートをクローズします。
                                                       
                                                       
*note transport.abort(): 3214.                         トランスポートを即座にクローズします。
                                                       
                                                       
*note transport.get_write_buffer_size(): 323d.         Return the current size of the output buffer.
                                                       
                                                       
*note transport.get_write_buffer_limits(): d92.        書き込みフロー制御の高水位点と低水位点を取得します。
                                                       
                                                       
*note transport.set_write_buffer_limits(): 323e.       書き込みフロー制御の高水位点と低水位点を設定します。
                                                       

*note loop.create_datagram_endpoint(): 6fe. が返すトランスポート:

データグラムトランスポート
..........................

*note transport.sendto(): 194.                         リモートピアにデータを送信します。
                                                       
                                                       
*note transport.abort(): 3243.                         トランスポートを即座にクローズします。
                                                       

サブプロセスに対するトランスポートの低レベルな抽象化です。 *note
loop.subprocess_exec(): 31a7. や *note loop.subprocess_shell(): 31a8. の
戻り値です:

サブプロセス化されたトランスポート
..................................

*note transport.get_pid(): 3245.                       サブプロセスのプロセス ID を返します。
                                                       
                                                       
*note transport.get_pipe_transport(): 3246.            リクエストされた通信パイプ (標準入力 'stdin', 標準出
                                                       力 'stdout', または標準エラー出力 'stderr') のための
                                                       トランスポートを返します。
                                                       
                                                       
*note transport.get_returncode(): 3247.                サブプロセスの終了ステータスを返します。
                                                       
                                                       
*note transport.kill(): 3248.                          サブプロセスを強制終了 (kill) します。
                                                       
                                                       
*note transport.send_signal(): 324a.                   サブプロセスにシグナルを送信します。
                                                       
                                                       
*note transport.terminate(): 3249.                     サブプロセスを停止します。
                                                       
                                                       
*note transport.close(): 324b.                         サブプロセスを強制終了 (kill) し、全てのパイプをクロ
                                                       ーズします。
                                                       


File: python.info,  Node: プロトコル<2>,  Next: イベントループのポリシー,  Prev: トランスポート<2>,  Up: 低水準の API インデックス

5.18.1.127 プロトコル
.....................

プロトコルクラスは以下の 'コールバックメソッド' を実装することができます
:

‘callback’ *note connection_made(): 31f0.              コネクションが作成されたときに呼び出されます。
                                                       
                                                       
‘callback’ *note connection_lost(): 3233.              コネクションが失われた、あるいはクローズされたときに
                                                       呼び出されます。
                                                       
                                                       
‘callback’ *note pause_writing(): 323f.                トランスポートのバッファーサイズが最高水位点
                                                       (High-Water Mark) を超えたときに呼び出されます。
                                                       
                                                       
‘callback’ *note resume_writing(): 3240.               トランスポートのバッファーサイズが最低水位点
                                                       (Low-Water Mark) に達したきに呼び出されます。
                                                       

ストリーミングプロトコル (TCP, Unix ソケット, パイプ)
.....................................................

‘callback’ *note data_received(): 16f8.                データを受信したときに呼び出されます。
                                                       
                                                       
‘callback’ *note eof_received(): 324f.                 終端 (EOF) を受信したときに呼び出されます。
                                                       

バッファリングされたストリーミングプロトコル
............................................

‘callback’ *note get_buffer(): 3251.                   新しい受信バッファを割り当てるために呼び出します。
                                                       
                                                       
‘callback’ *note buffer_updated(): 3252.               受信データによりバッファが更新された場合に呼び出され
                                                       ます。
                                                       
                                                       
‘callback’ *note eof_received(): 3253.                 終端 (EOF) を受信したときに呼び出されます。
                                                       

データグラムプロトコル
......................

‘callback’ *note datagram_received(): 3255.            データグラムを受信したときに呼び出されます。
                                                       
                                                       
‘callback’ *note error_received(): 3256.               直前の送信あるいは受信が *note OSError: 3f0. を送出
                                                       したときに呼び出されます。
                                                       

サブプロセスプロトコル
......................

‘callback’ *note pipe_data_received(): 172f.           子プロセスが標準出力 ('stdout') または標準エラー出力
                                                       ('stderr') のパイプにデータを書き込んだときに呼び出
                                                       されます。
                                                       
                                                       
‘callback’ *note pipe_connection_lost(): 3258.         子プロセスと通信するパイプのいずれかがクローズされた
                                                       ときに呼び出されます。
                                                       
                                                       
‘callback’ *note process_exited(): 172e.               Called when the child process has exited.  It can be
                                                       called before *note pipe_data_received(): 172f. and
                                                       *note pipe_connection_lost(): 3258. methods.
                                                       


File: python.info,  Node: イベントループのポリシー,  Prev: プロトコル<2>,  Up: 低水準の API インデックス

5.18.1.128 イベントループのポリシー
...................................

ポリシーは *note asyncio.get_event_loop(): 2a2. などの関数の振る舞いを変
更する低レベルなメカニズムです。詳細は *note
ポリシーについてのセクション: 31dc. を参照してください。

ポリシーへのアクセス
....................

*note asyncio.get_event_loop_policy(): 3267.           プロセス全体にわたる現在のポリシーを返します。
                                                       
                                                       
*note asyncio.set_event_loop_policy(): 3268.           新たなプロセス全体にわたるポリシーを設定します。
                                                       
                                                       
*note AbstractEventLoopPolicy: 3265.                   ポリシーオブジェクトの基底クラスです。
                                                       


File: python.info,  Node: asyncio での開発,  Prev: 低水準の API インデックス,  Up: asyncio --- 非同期 I/O

5.18.1.129 asyncio での開発
...........................

非同期プログラミングは伝統的な "同期的" プログラミングとは異なります。

このページはよくある間違いや落とし穴を列挙し、それらを回避する方法を説明
します。

* Menu:

* デバッグモード::
* 並行処理とマルチスレッド処理::
* ブロッキングコードの実行::
* ログ記録: ログ記録<3>.
* 待ち受け処理を伴わないコルーチンの検出::
* 回収されない例外の検出::


File: python.info,  Node: デバッグモード,  Next: 並行処理とマルチスレッド処理,  Up: asyncio での開発

5.18.1.130 デバッグモード
.........................

asyncio はデフォルトで本運用モードで実行されます。いっぽう、開発を容易に
するために asyncio は "デバッグモード" を持っています。

asyncio のデバッグモードを有効化する方法はいくつかあります:

   * *note PYTHONASYNCIODEBUG: 1cb8. 環境変数の値を ‘1’ に設定する。

   * *note Python 開発モード: 1d9. を使う。

   * *note asyncio.run(): 449. 実行時に ‘debug=True’ を設定する。

   * *note loop.set_debug(): d8f. を呼び出す。

デバッグモードを有効化することに加え、以下も検討してください:

   * *note asyncio ロガー: 329b. のログレベルを *note logging.DEBUG:
     1c5d. に設定します。例えばアプリケーションの起動時に以下を実行しま
     す:

          logging.basicConfig(level=logging.DEBUG)

   * *note warnings: fa. モジュールが *note ResourceWarning: 225. 警告を
     表示するように設定します。やり方のひとつは *note -W: 896. ‘default’
     コマンドラインオプションを使うことです。

デバッグモードが有効化されたときの動作:

   * asyncio は *note 待ち受け処理 (await) を伴わないコルーチン: 329c. が
     ないかをチェックし、それらを記録します; これにより "待ち受け忘れ" の
     落とし穴にはまる可能性を軽減します。

   * スレッドセーフでない asyncio APIs の多く (*note loop.call_soon():
     ad2. や *note loop.call_at(): ad5. など) は、誤ったスレッドから呼び
     出されたときに例外を送出します。

   * I/O セレクタが I/O 処理を実行する時間が長すぎる場合、その実行時間が
     記録されます。

   * 実行時間が100ミリ秒を超えるコールバックは記録されます。 "遅い" の判
     断基準となる実行時間の最小値は *note loop.slow_callback_duration:
     320e. 属性で設定できます。


File: python.info,  Node: 並行処理とマルチスレッド処理,  Next: ブロッキングコードの実行,  Prev: デバッグモード,  Up: asyncio での開発

5.18.1.131 並行処理とマルチスレッド処理
.......................................

イベントループはスレッド（典型的にはメインスレッド）内で動作し、すべての
コールバックとタスクをそのスレッド内で実行します。ひとつのタスクがイベン
トループ内で実行される間、他のタスクを同じスレッド内で実行することはでき
ません。タスクが ‘await’ 式を実行すると、実行中のタスクはサスペンドされ
、イベントループは次のタスクを実行します。

別の OS スレッドからのコールバック (*note callback: 286a.) をスケジュー
ルする場合、 *note loop.call_soon_threadsafe(): ad3. メソッドを使ってく
ださい。例:

     loop.call_soon_threadsafe(callback, *args)

ほぼ全ての非同期オブジェクトはスレッドセーフではありませんが、タスクやコ
ールバックの外側で非同期オブジェクトを使うコードが存在しない限り、それが
問題にはなることはほとんどありません。もしそのような目的で低レベルの
asyncio API を呼び出すようなコードを書く必要がある場合、 *note
loop.call_soon_threadsafe(): ad3. メソッドを使ってください。例:

     loop.call_soon_threadsafe(fut.cancel)

別の OS スレッドからコルーチンオブジェクトをスケジュールする場合は、
*note run_coroutine_threadsafe(): 84f. メソッドを使ってください。 *note
run_coroutine_threadsafe(): 84f. は結果にアクセスするための *note
concurrent.futures.Future: 1182. オブジェクトを返します:

     async def coro_func():
          return await asyncio.sleep(1, 42)

     # Later in another OS thread:

     future = asyncio.run_coroutine_threadsafe(coro_func(), loop)
     # Wait for the result:
     result = future.result()

シグナルの処理を行うには、イベントループはメインスレッド内で実行しなけれ
ばなりません。

The *note loop.run_in_executor(): 8b7. メソッドを *note
concurrent.futures.ThreadPoolExecutor: 70d. とともに使用することで、イベ
ントループの OS スレッドをブロックすることなく、別の OS スレッド内でブロ
ッキングコードを実行することができます。

現在のところ、 (たとえば *note multiprocessing: 86. で開始したような) 別
のプロセスからコルーチンやコールバックを直接スケジュールすることはできま
せん。 *note イベントループのメソッド: 31e2. 節では、イベントループをブ
ロックすることなくパイプからの読み込みやファイルデスクリプタの監視ができ
る API のリストを掲載しています。さらに、 asyncio の *note サブプロセス:
3124. API はイベントループからプロセスを開始したりプロセスと通信したりす
る方法を提供します。 最後に、前述の *note loop.run_in_executor(): 8b7. メ
ソッドは *note concurrent.futures.ProcessPoolExecutor: 8bc. とともに使用
することで、別のプロセス内でコードを実行することもできます。


File: python.info,  Node: ブロッキングコードの実行,  Next: ログ記録<3>,  Prev: 並行処理とマルチスレッド処理,  Up: asyncio での開発

5.18.1.132 ブロッキングコードの実行
...................................

ブロッキングコード (CPU バウンドなコード) を直接呼び出すべきではありませ
ん。たとえば、 CPU 負荷の高い関数を1秒実行したとすると、並行に処理されて
いる全ての非同期タスクと I/O 処理は1秒遅れる可能性があります。

エグゼキューターを使用することにより、イベントループの OS スレッドをブロ
ックすることなく、別のスレッドや別のプロセス上でタスクを実行することがで
きます。詳しくは *note loop.run_in_executor(): 8b7. メソッドを参照してく
ださい。


File: python.info,  Node: ログ記録<3>,  Next: 待ち受け処理を伴わないコルーチンの検出,  Prev: ブロッキングコードの実行,  Up: asyncio での開発

5.18.1.133 ログ記録
...................

asyncio は *note logging: 7b. モジュールを利用し、 全てのログ記録は
‘"asyncio"’ ロガーを通じて行われます。

デフォルトのログレベルは *note logging.INFO: 1c5e. ですが、これは簡単に
調節できます:

     logging.getLogger("asyncio").setLevel(logging.WARNING)

ネットワークログ記録は、イベントループをブロックし得ます。ログ処理のスレ
ッドを分離するか、ノンブロッキング IO を使用することを推奨します。例えば
、 *note ブロックする handler を扱う: 32a1. を見てください。


File: python.info,  Node: 待ち受け処理を伴わないコルーチンの検出,  Next: 回収されない例外の検出,  Prev: ログ記録<3>,  Up: asyncio での開発

5.18.1.134 待ち受け処理を伴わないコルーチンの検出
.................................................

コルーチンが呼び出されただけで、待ち受け処理がない場合 (たとえば ‘await
coro()’ のかわりに ‘coro()’ と書いてしまった場合) 、またはコルーチンが
*note asyncio.create_task(): 5c7. を使わずにスケジュールされた場合、
asyncio は *note RuntimeWarning: 1a2. 警告を送出します:

     import asyncio

     async def test():
         print("never scheduled")

     async def main():
         test()

     asyncio.run(main())

出力:

     test.py:7: RuntimeWarning: coroutine 'test' was never awaited
       test()

デバッグモードの出力:

     test.py:7: RuntimeWarning: coroutine 'test' was never awaited
     Coroutine created at (most recent call last)
       File "../t.py", line 9, in <module>
         asyncio.run(main(), debug=True)

       < .. >

       File "../t.py", line 7, in main
         test()
       test()

通常の修正方法はコルーチンを待ち受ける (await) か、 *note
asyncio.create_task(): 5c7. 関数を呼び出すことです:

     async def main():
         await test()


File: python.info,  Node: 回収されない例外の検出,  Prev: 待ち受け処理を伴わないコルーチンの検出,  Up: asyncio での開発

5.18.1.135 回収されない例外の検出
.................................

もし *note Future.set_exception(): 3156. メソッドが呼び出されても、その
Future オブジェクトを待ち受けていなければ、例外は決してユーザーコードま
で伝播しません。この場合 asyncio は、 Future オブジェクトがガベージコレ
クションの対象となったときにログメッセージを送出することがあります。

処理されない例外の例:

     import asyncio

     async def bug():
         raise Exception("not consumed")

     async def main():
         asyncio.create_task(bug())

     asyncio.run(main())

出力:

     Task exception was never retrieved
     future: <Task finished coro=<bug() done, defined at test.py:3>
       exception=Exception('not consumed')>

     Traceback (most recent call last):
       File "test.py", line 4, in bug
         raise Exception("not consumed")
     Exception: not consumed

タスクが生成された箇所を特定するには、 *note デバッグモードを有効化して:
1cb9. トレースバックを取得してください:

     asyncio.run(main(), debug=True)

デバッグモードの出力:

     Task exception was never retrieved
     future: <Task finished coro=<bug() done, defined at test.py:3>
         exception=Exception('not consumed') created at asyncio/tasks.py:321>

     source_traceback: Object created at (most recent call last):
       File "../t.py", line 9, in <module>
         asyncio.run(main(), debug=True)

     < .. >

     Traceback (most recent call last):
       File "../t.py", line 4, in bug
         raise Exception("not consumed")
     Exception: not consumed

     注釈: asyncio のソースコードは Lib/asyncio/(1) にあります。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/asyncio/


File: python.info,  Node: socket --- 低水準ネットワークインターフェース,  Next: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー,  Prev: asyncio --- 非同期 I/O,  Up: ネットワーク通信とプロセス間通信

5.18.2 ‘socket’ -- 低水準ネットワークインターフェース
-----------------------------------------------------

'ソースコード:' Lib/socket.py(1)

__________________________________________________________________

このモジュールはBSDの 'ソケット(socket)' インターフェイスへのアクセスを
提供します。これは、近代的なUnixシステム、Windows、MacOS、その他多くのプ
ラットフォームで動作します。

     注釈: いくつかの挙動はプラットフォームに依存します。オペレーティン
     グシステムのソケットAPIを呼び出しているためです。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

Pythonインターフェースは、Unixのソケット用システムコールとライブラリイン
ターフェースを、そのままPythonのオブジェクト指向スタイルに変換したもので
す。各種ソケット関連のシステムコールは、 *note socket(): d6e. 関数で生成
される 'socket オブジェクト' のメソッドとして実装されています。 メソッド
の引数は C のインターフェイスよりも多少高水準で、例えばファイルに対する
‘read()’ や ‘write()’ メソッドと同様に、 受信時のバッファ確保は自動的に
処理され、送信時のバッファ長は暗黙的に決まります。

参考
....

Module *note socketserver: b9.

     ネットワークサーバの開発を省力化するためのクラス群。

Module *note ssl: bb.

     ソケットオブジェクトに対する TLS/SSL ラッパー.

* Menu:

* ソケットファミリー::
* モジュールの内容::
* socket オブジェクト::
* ソケットタイムアウトの注意事項::
* 使用例: 使用例<26>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/socket.py


File: python.info,  Node: ソケットファミリー,  Next: モジュールの内容,  Up: socket --- 低水準ネットワークインターフェース

5.18.2.1 ソケットファミリー
...........................

どのシステムで実行するかとビルドオプションに依存しますが、このモジュール
によって多様なソケットファミリーをサポートします。

特定のソケットオブジェクトによって必要とされるアドレスフォーマットは、ソ
ケットオブジェクトが生成されたときに指定されたアドレスファミリーを元に自
動的に選択されます。ソケットアドレスは次の通りです。

   - ファイルシステム上のノードに束縛された *note AF_UNIX: 178a. ソケッ
     トのアドレスは、ファイルシステムエンコーディングと
     ‘'surrogateescape'’ エラーハンドラ ( PEP 383(1) を参照) を使って文
     字列として表現されます。 Linux の抽象名前空間のアドレスは、先頭が
     null バイトとなる *note bytes-like object: cfb. として返されます。
     この名前空間のソケットは通常のファイルシステム上のソケットと通信で
     きるので、 Linux 上で動作することを意図したプログラムは両方のアドレ
     スを扱う必要がある可能性があります。文字列と bytes-like オブジェク
     トはどちらのタイプのアドレスにも引数として渡すことができます。

     バージョン 3.3 で変更: これまでは *note AF_UNIX: 178a. ソケットパス
     は UTF-8 エンコーディングを使用するものとされていました。

     バージョン 3.5 で変更: 書き込み可能な *note bytes-like object: cfb.
     を使用できるようになりました。

   - *note AF_INET: 1788. アドレスファミリーには、 ‘(host, port)’ ペアが
     アドレスとして利用されます。 'host' はホスト名か ‘'daring.cwi.nl'’
     のようなインターネットドメインか、 ‘'100.50.200.5'’ のような IPv4 ア
     ドレスで、 'port' は整数です。

        - IPv4ではホストアドレスのほかに2つの特別な形式が使用できます。
          ‘''’ はすべてのインターフェイスにバインドされるために使われる
          ‘INADDR_ANY’ を表し、‘'<broadcast>'’ は ‘INADDR_BROADCAST’ を
          表します。これらの動作はIPv6と互換性がありません。そのためもし
          もあなたがPythonプログラムでIPv6をサポートする予定があるのなら
          ばこれらを避けたほうが良いでしょう。

   - *note AF_INET6: 1789. アドレスファミリーでは、 ‘(host, port,
     flowinfo, scope_id)’ の4 要素のタプルが利用されます。 'flowinfo' と
     'scopeid' はそれぞれC言語の ‘struct sockaddr_in6’ の
     ‘sin6_flowinfo’ と ‘sin6_scope_id’ メンバーを表します。 *note
     socket: b8. モジュールのメソッドでは、後方互換性のために 'flowinfo'
     と 'scope_id' の省略を許しています。しかし、 'scope_id' を省略する
     と scope された IPv6 アドレスを操作するときに問題が起こる場合がある
     ことに注意してください。

     バージョン 3.7 で変更: For multicast addresses (with 'scope_id'
     meaningful) 'address' may not contain ‘%scope_id’ (or ‘zone id’)
     part.  This information is superfluous and may be safely omitted
     (recommended).

   - ‘AF_NETLINK’ ソケットのアドレスは ‘(pid, groups)’ のペアで表されま
     す。

   - Linux 限定で、 ‘AF_TIPC’ アドレスファミリーを用いて TIPC がサポート
     されます。 TIPC は、クラスタコンピューティング環境のために設計され
     た、IP ベースではないオープンなネットワークプロトコルです。アドレス
     はタプルで表現され、フィールドはアドレスタイプに依存します。一般的
     なタプルの形式は ‘(addr_type, v1, v2, v3 [, scope])’ で、それぞれは
     次の通りです:

        - 'addr_type' は ‘TIPC_ADDR_NAMESEQ’, ‘TIPC_ADDR_NAME’,
          ‘TIPC_ADDR_ID’ の1つ。

        - 'scope' は ‘TIPC_ZONE_SCOPE’, ‘TIPC_CLUSTER_SCOPE’,
          ‘TIPC_NODE_SCOPE’ の1つ。

        - 'addr_type' が ‘TIPC_ADDR_NAME’ の場合、 'v1' はサーバータイプ
          、 'v2' はポートID (the port identifier)、そして 'v3' は 0 で
          あるべきです。

          'addr_type' が ‘TIPC_ADDR_NAMESEQ’ の場合、 'v1' はサーバータ
          イプ、 'v2' はポート番号下位(lower port number)、 'v3' はポー
          ト番号上位(upper port number) です。

          'addr_type' が ‘TIPC_ADDR_ID’ の場合、 'v1' はノード、 'v2' は
          参照、 'v3' は0であるべきです。

   - *note AF_CAN: 32a8. アドレスファミリーには ‘(interface, )’ というタ
     プルを利用します。 'interface' は ‘'can0'’ のようなネットワークイン
     ターフェース名を表す文字列です。このファミリーの全てのネットワーク
     インターフェースからパケットを受信するために、ネットワークインター
     フェース名 ‘''’ を利用できます。

        - *note CAN_ISOTP: 32a9. protocol require a tuple ‘(interface,
          rx_addr, tx_addr)’ where both additional parameters are
          unsigned long integer that represent a CAN identifier
          (standard or extended).

        - *note CAN_J1939: 900. protocol require a tuple ‘(interface,
          name, pgn, addr)’ where additional parameters are 64-bit
          unsigned integer representing the ECU name, a 32-bit unsigned
          integer representing the Parameter Group Number (PGN), and an
          8-bit integer representing the address.

   - 文字列またはタプル ‘(id, unit)’ は ‘PF_SYSTEM’ ファミリーの
     ‘SYSPROTO_CONTROL’ プロトコルのために使用されます。この文字列は、動
     的に割り当てられたIDによるカーネルコントロールの名前です。このタプ
     ルは、カーネルコントロールのIDとユニット番号が既知の場合、または登
     録済みIDが使用中の場合に使用することができます。

     Added in version 3.3.

   - ‘AF_BLUETOOTH’ は以下のプロトコルとアドレスフォーマットをサポートし
     ています。

        - ‘BTPROTO_L2CAP’ は ‘(bdaddr, psm)’ を受け取ります。 ‘bdaddr’ は
          Bluetooth アドレスを表す文字列で、 ‘psm’ は整数です。

        - ‘BTPROTO_RFCOMM’ は ‘(bdaddr, channel)’ を受け取ります。
          ‘bdaddr’ は Bluetooth アドレスを表す文字列で、 ‘channel’ は整
          数です。

        - ‘BTPROTO_HCI’ は ‘(device_id,)’ を受け取ります。 ‘device_id’ は
          、数値またはインターフェイスの Bluetooth アドレスを表す文字列
          です。(OS に依存します。NetBSD と DragonFlyBSD は Bluetooth ア
          ドレスを期待しますが、その他すべての OS は、数値を期待します。
          )

          バージョン 3.2 で変更: NetBSD と DragonFlyBSD のサポートが追加
          されました。

        - ‘BTPROTO_SCO’ は ‘bdaddr’ を受け取ります。ここで、 ‘bdaddr’ は
          Bluetooth アドレスを文字列形式で持つ *note bytes: 1a4. オブジ
          ェクトです (例: ‘b'12:23:34:45:56:67'’)。このプロトコルは、
          FreeBSD ではサポートされていません。

   - *note AF_ALG: ca5. はカーネル暗号へのソケットベースのインターフェイ
     スで、Linux でのみ使用できます。アルゴリズムソケットは、2 つから 4
     つの要素を持つタプル ‘(type, name [, feat [, mask]])’ で構成されま
     す。各要素の意味は、以下の通りです。

        - 'type' はアルゴリズムタイプを示す文字列です。例: ‘aead’,
          ‘hash’, ‘skcipher’ または ‘rng’。

        - 'name' はアルゴリズム名及び操作モードを示す文字列です。例:
          ‘sha256’, ‘hmac(sha256)’, ‘cbc(aes)’ または
          ‘drbg_nopr_ctr_aes256’。

        - 'feat' と 'mask' は、符号を持たない 32 ビットの整数です。

     *note Availability: 1cbe.: Linux >= 2.6.38.

     一部のアルゴリズムタイプでは、さらに新しいカーネルが必要です。

     Added in version 3.6.

   - *note AF_VSOCK: b43. allows communication between virtual machines
     and their hosts.  The sockets are represented as a ‘(CID, port)’
     tuple where the context ID or CID and port are integers.

     *note Availability: 1cbe.: Linux >= 3.9

     See ‘vsock(7)(2)’

     Added in version 3.7.

   - *note AF_PACKET: 32aa. is a low-level interface directly to network
     devices.  The addresses are represented by the tuple ‘(ifname,
     proto[, pkttype[, hatype[, addr]]])’ where:

        - 'ifname' - デバイス名を指定する文字列。

        - 'proto' - The Ethernet protocol number.  May be *note
          ETH_P_ALL: 1713. to capture all protocols, one of the *note
          ETHERTYPE_* constants: 1714. or any other Ethernet protocol
          number.

        - 'pkttype' - パケットタイプを指定するオプションの整数:

             - ‘PACKET_HOST’ (the default) - Packet addressed to the
               local host.

             - ‘PACKET_BROADCAST’ - Physical-layer broadcast packet.

             - ‘PACKET_MULTICAST’ - Packet sent to a physical-layer
               multicast address.

             - ‘PACKET_OTHERHOST’ - Packet to some other host that has
               been caught by a device driver in promiscuous mode.

             - ‘PACKET_OUTGOING’ - Packet originating from the local
               host that is looped back to a packet socket.

        - 'hatype' - Optional integer specifying the ARP hardware
          address type.

        - 'addr' - Optional bytes-like object specifying the hardware
          physical address, whose interpretation depends on the device.

     *note Availability: 1cbe.: Linux >= 2.2.

   - *note AF_QIPCRTR: 32ab. is a Linux-only socket based interface for
     communicating with services running on co-processors in Qualcomm
     platforms.  The address family is represented as a ‘(node, port)’
     tuple where the 'node' and 'port' are non-negative integers.

     *note Availability: 1cbe.: Linux >= 4.7.

     Added in version 3.8.

   - ‘IPPROTO_UDPLITE’ is a variant of UDP which allows you to specify
     what portion of a packet is covered with the checksum.  It adds two
     socket options that you can change.
     ‘self.setsockopt(IPPROTO_UDPLITE, UDPLITE_SEND_CSCOV, length)’ will
     change what portion of outgoing packets are covered by the checksum
     and ‘self.setsockopt(IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV, length)’
     will filter out packets which cover too little of their data.  In
     both cases ‘length’ should be in ‘range(8, 2**16, 8)’.

     Such a socket should be constructed with ‘socket(AF_INET,
     SOCK_DGRAM, IPPROTO_UDPLITE)’ for IPv4 or ‘socket(AF_INET6,
     SOCK_DGRAM, IPPROTO_UDPLITE)’ for IPv6.

     *note Availability: 1cbe.: Linux >= 2.6.20, FreeBSD >= 10.1

     Added in version 3.9.

   - *note AF_HYPERV: 32ac. is a Windows-only socket based interface for
     communicating with Hyper-V hosts and guests.  The address family is
     represented as a ‘(vm_id, service_id)’ tuple where the ‘vm_id’ and
     ‘service_id’ are UUID strings.

     The ‘vm_id’ is the virtual machine identifier or a set of known
     VMID values if the target is not a specific virtual machine.  Known
     VMID constants defined on ‘socket’ are:

        - ‘HV_GUID_ZERO’

        - ‘HV_GUID_BROADCAST’

        - ‘HV_GUID_WILDCARD’ - Used to bind on itself and accept
          connections from all partitions.

        - ‘HV_GUID_CHILDREN’ - Used to bind on itself and accept
          connection from child partitions.

        - ‘HV_GUID_LOOPBACK’ - Used as a target to itself.

        - ‘HV_GUID_PARENT’ - When used as a bind accepts connection from
          the parent partition.  When used as an address target it will
          connect to the parent partition.

     The ‘service_id’ is the service identifier of the registered
     service.

     Added in version 3.12.

IPv4/v6ソケットの 'host' 部にホスト名を指定すると、処理結果が一定ではな
い場合があります。これはPythonはDNSから取得したアドレスのうち最初のアド
レスを使用するので、 DNSの処理やホストの設定によって異なるIPv4/6アドレス
を取得する場合があるためです。常に同じ結果が必要であれば、 'host' に数値
のアドレスを指定してください。

エラー時には例外が発生します。引数型のエラーやメモリ不足の場合には通常の
例外が発生し、ソケットやアドレス関連のエラーの場合は *note OSError: 3f0.
またはそのサブクラスが発生します。

*note setblocking(): 2a9b. メソッドで、非ブロッキングモードを使用するこ
とができます。また、より汎用的に *note settimeout(): 32ad. メソッドでタ
イムアウトを指定する事ができます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0383/

   (2) https://manpages.debian.org/vsock(7)


File: python.info,  Node: モジュールの内容,  Next: socket オブジェクト,  Prev: ソケットファミリー,  Up: socket --- 低水準ネットワークインターフェース

5.18.2.2 モジュールの内容
.........................

*note socket: b8. モジュールは以下の要素を公開しています。

* Menu:

* 例外: 例外<14>.
* 定数: 定数<8>.
* 関数: 関数<8>.


File: python.info,  Node: 例外<14>,  Next: 定数<8>,  Up: モジュールの内容

5.18.2.3 例外
.............

 -- 例外: socket.error

     *note OSError: 3f0. の非推奨のエイリアスです。

     バージョン 3.3 で変更: PEP 3151(1) に基づき、このクラスは *note
     OSError: 3f0. のエイリアスになりました。

 -- 例外: socket.herror

     *note OSError: 3f0. のサブクラス。この例外はアドレス関連のエラー、
     つまり *note gethostbyname_ex(): 1838. と *note gethostbyaddr():
     1837. などの、 POSIX C API の 'h_errno' を利用する関数のために利用
     されます。例外に付随する ‘(h_errno, string)’ ペアはライブラリの呼び
     出しによって返されたエラーを表します。 'h_errno' は数値で、
     'string' は、 ‘hstrerror()’ C関数によって返される 'h_errno' を説明
     する文字列です。

     バージョン 3.3 で変更: このクラスは *note OSError: 3f0. のサブクラ
     スになりました。

 -- 例外: socket.gaierror

     A subclass of *note OSError: 3f0, this exception is raised for
     address-related errors by *note getaddrinfo(): 16bd. and *note
     getnameinfo(): 1629.  The accompanying value is a pair ‘(error,
     string)’ representing an error returned by a library call.
     'string' represents the description of 'error', as returned by the
     ‘gai_strerror()’ C function.  The numeric 'error' value will match
     one of the ‘EAI_*’ constants defined in this module.

     バージョン 3.3 で変更: このクラスは *note OSError: 3f0. のサブクラ
     スになりました。

 -- 例外: socket.timeout

     *note TimeoutError: 800. の非推奨のエイリアスです。

     *note OSError: 3f0. のサブクラスです。この例外は、あらかじめ *note
     settimeout(): 32ad. を呼び出して (あるいは *note
     setdefaulttimeout(): 32b1. を利用して暗黙に) タイムアウトを有効にし
     てあるソケットでタイムアウトが生じた際に送出されます。 例外に付属す
     る値は文字列で、その内容は現状では常に "timed out" となります。

     バージョン 3.3 で変更: このクラスは *note OSError: 3f0. のサブクラ
     スになりました。

     バージョン 3.10 で変更: このクラスは *note TimeoutError: 800. のエ
     イリアスになりました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3151/


File: python.info,  Node: 定数<8>,  Next: 関数<8>,  Prev: 例外<14>,  Up: モジュールの内容

5.18.2.4 定数
.............

     AF_* 定数と SOCK_* 定数は、 ‘AddressFamily’ と ‘SocketKind’ *note
     IntEnum: cad. collection になりました。

     Added in version 3.4.

 -- データ: socket.AF_UNIX
 -- データ: socket.AF_INET
 -- データ: socket.AF_INET6

     These constants represent the address (and protocol) families, used
     for the first argument to *note socket(): d6e.  If the *note
     AF_UNIX: 178a. constant is not defined then this protocol is
     unsupported.  More constants may be available depending on the
     system.

 -- データ: socket.AF_UNSPEC

     *note AF_UNSPEC: 31f7. means that *note getaddrinfo(): 16bd. should
     return socket addresses for any address family (either IPv4, IPv6,
     or any other) that can be used.

 -- データ: socket.SOCK_STREAM
 -- データ: socket.SOCK_DGRAM
 -- データ: socket.SOCK_RAW
 -- データ: socket.SOCK_RDM
 -- データ: socket.SOCK_SEQPACKET

     These constants represent the socket types, used for the second
     argument to *note socket(): d6e.  More constants may be available
     depending on the system.  (Only *note SOCK_STREAM: 12c1. and *note
     SOCK_DGRAM: 12c0. appear to be generally useful.)

 -- データ: socket.SOCK_CLOEXEC
 -- データ: socket.SOCK_NONBLOCK

     この2つの定数が定義されていた場合、ソケットタイプと組み合わせていく
     つかの flags をアトミックに設定することができます (別の呼び出しを不
     要にして競合状態を避ける事ができます)。

     参考
     ....

     より完全な説明は Secure File Descriptor Handling(1) を参照してくだ
     さい。

     *note Availability: 1cbe.: Linux >= 2.6.27.

     Added in version 3.2.

 -- データ: SO_*
 -- データ: socket.SOMAXCONN

 -- データ: MSG_*

 -- データ: SOL_*

 -- データ: SCM_*

 -- データ: IPPROTO_*

 -- データ: IPPORT_*

 -- データ: INADDR_*

 -- データ: IP_*

 -- データ: IPV6_*

 -- データ: EAI_*

 -- データ: AI_*

 -- データ: NI_*

 -- データ: TCP_*

     Many constants of these forms, documented in the Unix documentation
     on sockets and/or the IP protocol, are also defined in the socket
     module.  They are generally used in arguments to the *note
     setsockopt(): ca4. and *note getsockopt(): ca3. methods of socket
     objects.  In most cases, only those symbols that are defined in the
     Unix header files are defined; for a few symbols, default values
     are provided.

     バージョン 3.6 で変更: ‘SO_DOMAIN’, ‘SO_PROTOCOL’, ‘SO_PEERSEC’,
     ‘SO_PASSSEC’, ‘TCP_USER_TIMEOUT’, ‘TCP_CONGESTION’ が追加されました
     。

     バージョン 3.6.5 で変更: Windowsでは、実行時のWindowsがサポートして
     いるならば ‘TCP_FASTOPEN’、 ‘TCP_KEEPCNT’ が表示されます。

     バージョン 3.7 で変更: ‘TCP_NOTSENT_LOWAT’ が追加されました。

     Windowsでは、実行時のWindowsがサポートしているならば
     ‘TCP_KEEPIDLE’, ‘TCP_KEEPINTVL’ が表示されます。

     バージョン 3.10 で変更: ‘IP_RECVTOS’ was added.  Added
     ‘TCP_KEEPALIVE’.  On MacOS this constant can be used in the same
     way that ‘TCP_KEEPIDLE’ is used on Linux.

     バージョン 3.11 で変更: Added ‘TCP_CONNECTION_INFO’.  On MacOS this
     constant can be used in the same way that ‘TCP_INFO’ is used on
     Linux and BSD.

     バージョン 3.12 で変更: Added ‘SO_RTABLE’ and ‘SO_USER_COOKIE’.  On
     OpenBSD and FreeBSD respectively those constants can be used in the
     same way that ‘SO_MARK’ is used on Linux.  Also added missing TCP
     socket options from Linux: ‘TCP_MD5SIG’,
     ‘TCP_THIN_LINEAR_TIMEOUTS’, ‘TCP_THIN_DUPACK’, ‘TCP_REPAIR’,
     ‘TCP_REPAIR_QUEUE’, ‘TCP_QUEUE_SEQ’, ‘TCP_REPAIR_OPTIONS’,
     ‘TCP_TIMESTAMP’, ‘TCP_CC_INFO’, ‘TCP_SAVE_SYN’, ‘TCP_SAVED_SYN’,
     ‘TCP_REPAIR_WINDOW’, ‘TCP_FASTOPEN_CONNECT’, ‘TCP_ULP’,
     ‘TCP_MD5SIG_EXT’, ‘TCP_FASTOPEN_KEY’, ‘TCP_FASTOPEN_NO_COOKIE’,
     ‘TCP_ZEROCOPY_RECEIVE’, ‘TCP_INQ’, ‘TCP_TX_DELAY’.  Added
     ‘IP_PKTINFO’, ‘IP_UNBLOCK_SOURCE’, ‘IP_BLOCK_SOURCE’,
     ‘IP_ADD_SOURCE_MEMBERSHIP’, ‘IP_DROP_SOURCE_MEMBERSHIP’.

     バージョン 3.13 で変更: Added ‘SO_BINDTOIFINDEX’.  On Linux this
     constant can be used in the same way that ‘SO_BINDTODEVICE’ is
     used, but with the index of a network interface instead of its
     name.

 -- データ: socket.AF_CAN
 -- データ: socket.PF_CAN

 -- データ: SOL_CAN_*

 -- データ: CAN_*

     Linux ドキュメントにあるこの形式の定数は socket モジュールでも定義
     されています。

     *note Availability: 1cbe.: Linux >= 2.6.25, NetBSD >= 8.

     Added in version 3.3.

     バージョン 3.11 で変更: NetBSD サポートが追加されました。

 -- データ: socket.CAN_BCM

 -- データ: CAN_BCM_*

     CANプロトコルファミリーのCAN_BCMは、ブロードキャストマネージャー
     (BCM)プロトコルです。Linuxドキュメントにあるこの形式の定数は、
     socketモジュールでも定義されています。

     *note Availability: 1cbe.: Linux >= 2.6.25.

          注釈: The ‘CAN_BCM_CAN_FD_FRAME’ flag is only available on
          Linux >= 4.8.

     Added in version 3.4.

 -- データ: socket.CAN_RAW_FD_FRAMES

     CAN_RAW ソケットで CAN FD をサポートします。これはデフォルトで無効
     になっています。これにより、アプリケーションが CAN フレームと CAN
     FD フレームを送信できるようになります。ただし、ソケットからの読み出
     し時に、CAN と CAN FD の両方のフレームを受け入れなければなりません
     。

     この定数は、 Linux のドキュメンテーションで説明されています。

     *note Availability: 1cbe.: Linux >= 3.6.

     Added in version 3.5.

 -- データ: socket.CAN_RAW_JOIN_FILTERS

     Joins the applied CAN filters such that only CAN frames that match
     all given CAN filters are passed to user space.

     この定数は、 Linux のドキュメンテーションで説明されています。

     *note Availability: 1cbe.: Linux >= 4.1.

     Added in version 3.9.

 -- データ: socket.CAN_ISOTP

     CAN_ISOTP, in the CAN protocol family, is the ISO-TP (ISO 15765-2)
     protocol.  ISO-TP constants, documented in the Linux documentation.

     *note Availability: 1cbe.: Linux >= 2.6.25.

     Added in version 3.7.

 -- データ: socket.CAN_J1939

     CAN_J1939, in the CAN protocol family, is the SAE J1939 protocol.
     J1939 constants, documented in the Linux documentation.

     *note Availability: 1cbe.: Linux >= 5.4.

     Added in version 3.9.

 -- データ: socket.AF_DIVERT
 -- データ: socket.PF_DIVERT

     These two constants, documented in the FreeBSD divert(4) manual
     page, are also defined in the socket module.

     *note Availability: 1cbe.: FreeBSD >= 14.0.

     Added in version 3.12.

 -- データ: socket.AF_PACKET
 -- データ: socket.PF_PACKET

 -- データ: PACKET_*

     Linux ドキュメントにあるこの形式の定数は socket モジュールでも定義
     されています。

     *note Availability: 1cbe.: Linux >= 2.2.

 -- データ: socket.ETH_P_ALL

     ‘ETH_P_ALL’ can be used in the *note socket: d6e. constructor as
     'proto' for the *note AF_PACKET: 32aa. family in order to capture
     every packet, regardless of protocol.

     For more information, see the ‘packet(7)(2)’ manpage.

     *note Availability: 1cbe.: Linux.

     Added in version 3.12.

 -- データ: socket.AF_RDS
 -- データ: socket.PF_RDS
 -- データ: socket.SOL_RDS

 -- データ: RDS_*

     Linux ドキュメントにあるこの形式の定数は socket モジュールでも定義
     されています。

     *note Availability: 1cbe.: Linux >= 2.6.30.

     Added in version 3.3.

 -- データ: socket.SIO_RCVALL
 -- データ: socket.SIO_KEEPALIVE_VALS
 -- データ: socket.SIO_LOOPBACK_FAST_PATH

 -- データ: RCVALL_*

     Windows の WSAIoctl() のための定数です。この定数はソケットオブジェ
     クトの *note ioctl(): ca1. メソッドに引数として渡されます。

     バージョン 3.6 で変更: ‘SIO_LOOPBACK_FAST_PATH’ が追加されました。

 -- データ: TIPC_*

     TIPC 関連の定数で、C のソケットAPIが公開しているものにマッチします
     。詳しい情報は TIPC のドキュメントを参照してください。

 -- データ: socket.AF_ALG
 -- データ: socket.SOL_ALG

 -- データ: ALG_*

     Linux カーネル暗号用の定数です。

     *note Availability: 1cbe.: Linux >= 2.6.38.

     Added in version 3.6.

 -- データ: socket.AF_VSOCK
 -- データ: socket.IOCTL_VM_SOCKETS_GET_LOCAL_CID

 -- データ: VMADDR*

 -- データ: SO_VM*

     Constants for Linux host/guest communication.

     *note Availability: 1cbe.: Linux >= 4.8.

     Added in version 3.7.

 -- データ: socket.AF_LINK

     *note Availability: 1cbe.: BSD, macOS.

     Added in version 3.4.

 -- データ: socket.has_ipv6

     現在のプラットフォームでIPv6がサポートされているか否かを示す真偽値
     。

 -- データ: socket.BDADDR_ANY
 -- データ: socket.BDADDR_LOCAL

     これらは、特別な意味を持つ Bluetooth アドレスを含む文字列定数です。
     例えば、*note BDADDR_ANY: 32c2. を使用すると、 ‘BTPROTO_RFCOMM’ で
     束縛ソケットを指定する際に、任意のアドレスを指し示すことができます
     。

 -- データ: socket.HCI_FILTER
 -- データ: socket.HCI_TIME_STAMP
 -- データ: socket.HCI_DATA_DIR

     ‘BTPROTO_HCI’ で使用します。 *note HCI_FILTER: 32c4. は NetBSD また
     は DragonFlyBSD では使用できません。 *note HCI_TIME_STAMP: 32c5. と
     *note HCI_DATA_DIR: 32c6. は FreeBSD, NetBSD, DragonFlyBSD では使用
     できません。

 -- データ: socket.AF_QIPCRTR

     Constant for Qualcomm's IPC router protocol, used to communicate
     with service providing remote processors.

     *note Availability: 1cbe.: Linux >= 4.7.

 -- データ: socket.SCM_CREDS2
 -- データ: socket.LOCAL_CREDS
 -- データ: socket.LOCAL_CREDS_PERSISTENT

     LOCAL_CREDS and LOCAL_CREDS_PERSISTENT can be used with SOCK_DGRAM,
     SOCK_STREAM sockets, equivalent to Linux/DragonFlyBSD SO_PASSCRED,
     while LOCAL_CREDS sends the credentials at first read,
     LOCAL_CREDS_PERSISTENT sends for each read, SCM_CREDS2 must be then
     used for the latter for the message type.

     Added in version 3.11.

     *note Availability: 1cbe.: FreeBSD.

 -- データ: socket.SO_INCOMING_CPU

          Constant to optimize CPU locality, to be used in conjunction
          with ‘SO_REUSEPORT’.

     Added in version 3.11.

     *note Availability: 1cbe.: Linux >= 3.9

 -- データ: socket.AF_HYPERV
 -- データ: socket.HV_PROTOCOL_RAW
 -- データ: socket.HVSOCKET_CONNECT_TIMEOUT
 -- データ: socket.HVSOCKET_CONNECT_TIMEOUT_MAX
 -- データ: socket.HVSOCKET_CONNECTED_SUSPEND
 -- データ: socket.HVSOCKET_ADDRESS_FLAG_PASSTHRU
 -- データ: socket.HV_GUID_ZERO
 -- データ: socket.HV_GUID_WILDCARD
 -- データ: socket.HV_GUID_BROADCAST
 -- データ: socket.HV_GUID_CHILDREN
 -- データ: socket.HV_GUID_LOOPBACK
 -- データ: socket.HV_GUID_PARENT

     Constants for Windows Hyper-V sockets for host/guest
     communications.

     *note Availability: 1cbe.: Windows.

     Added in version 3.12.

 -- データ: socket.ETHERTYPE_ARP
 -- データ: socket.ETHERTYPE_IP
 -- データ: socket.ETHERTYPE_IPV6
 -- データ: socket.ETHERTYPE_VLAN

     IEEE 802.3 protocol number(3).  constants.

     *note Availability: 1cbe.: Linux, FreeBSD, macOS.

     Added in version 3.12.

 -- データ: socket.SHUT_RD
 -- データ: socket.SHUT_WR
 -- データ: socket.SHUT_RDWR

     These constants are used by the *note shutdown(): 32dd. method of
     socket objects.

     *note Availability: 1cbe.: not WASI.

   ---------- Footnotes ----------

   (1) https://udrepper.livejournal.com/20407.html

   (2) https://manpages.debian.org/packet(7)

   (3) 
https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.txt


File: python.info,  Node: 関数<8>,  Prev: 定数<8>,  Up: モジュールの内容

5.18.2.5 関数
.............

* Menu:

* ソケットの作成::
* その他の関数: その他の関数<2>.


File: python.info,  Node: ソケットの作成,  Next: その他の関数<2>,  Up: 関数<8>

5.18.2.6 ソケットの作成
.......................

以下の関数は全て *note socket object: 32e0. を生成します。

 -- クラス: socket.socket (family=AF_INET, type=SOCK_STREAM, proto=0,
          fileno=None)

     アドレスファミリー、ソケットタイプ、プロトコル番号を指定してソケッ
     トを作成します。アドレスファミリーには *note AF_INET: 1788. (デフォ
     ルト値), *note AF_INET6: 1789, *note AF_UNIX: 178a, *note AF_CAN:
     32a8, *note AF_PACKET: 32aa, *note AF_RDS: 32ba. を指定することがで
     きます。ソケットタイプには *note SOCK_STREAM: 12c1. (デフォルト値),
     *note SOCK_DGRAM: 12c0, *note SOCK_RAW: 32b3. または他の ‘SOCK_’ 定
     数の何れかを指定します。プロトコル番号は通常省略するか、または0を指
     定しますが、アドレスファミリーに *note AF_CAN: 32a8. を指定した場合
     は、プロトコル番号には const:‘CAN_RAW’, *note CAN_BCM: f6f, *note
     CAN_ISOTP: 32a9, *note CAN_J1939: 900. のいずれかを指定すべきです。

     If 'fileno' is specified, the values for 'family', 'type', and
     'proto' are auto-detected from the specified file descriptor.
     Auto-detection can be overruled by calling the function with
     explicit 'family', 'type', or 'proto' arguments.  This only affects
     how Python represents e.g.  the return value of *note
     socket.getpeername(): 3234. but not the actual OS resource.  Unlike
     *note socket.fromfd(): 32e1, 'fileno' will return the same socket
     and not a duplicate.  This may help close a detached socket using
     *note socket.close(): b41.

     新たに作成されたソケットは *note 継承不可: ec4. です。

     引数 ‘self’, ‘family’, ‘type’, ‘protocol’ 付きで *note
     監査イベント: 1825. ‘socket.__new__’ を送出します。

     バージョン 3.3 で変更: AF_CAN, AF_RDS ファミリーが追加されました。

     バージョン 3.4 で変更: CAN_BCMプロトコルが追加されました。

     バージョン 3.4 で変更: 返されるソケットは継承不可になりました。

     バージョン 3.7 で変更: CAN_ISOTP プロトコルが追加されました。

     バージョン 3.7 で変更: When *note SOCK_NONBLOCK: bd8. or *note
     SOCK_CLOEXEC: bd9. bit flags are applied to 'type' they are
     cleared, and *note socket.type: bda. will not reflect them.  They
     are still passed to the underlying system ‘socket()’ call.
     Therefore,

          sock = socket.socket(
              socket.AF_INET,
              socket.SOCK_STREAM | socket.SOCK_NONBLOCK)

     will still create a non-blocking socket on OSes that support
     ‘SOCK_NONBLOCK’, but ‘sock.type’ will be set to
     ‘socket.SOCK_STREAM’.

     バージョン 3.9 で変更: CAN_J1939 プロトコルが追加されました。

     バージョン 3.10 で変更: IPPROTO_MPTCP プロトコルが追加されました。

 -- の関数: socket.socketpair ([family[, type[, proto]]])

     Build a pair of connected socket objects using the given address
     family, socket type, and protocol number.  Address family, socket
     type, and protocol number are as for the *note socket(): d6e.
     function above.  The default family is *note AF_UNIX: 178a. if
     defined on the platform; otherwise, the default is *note AF_INET:
     1788.

     新たに作成されたソケットは *note 継承不可: ec4. です。

     バージョン 3.2 で変更: 返されるソケットオブジェクトが、サブセットで
     はなく完全なソケットAPIを提供するようになりました。

     バージョン 3.4 で変更: 返されるソケットの組は、どちらも継承不可にな
     りました。

     バージョン 3.5 で変更: Windows のサポートが追加されました。

 -- の関数: socket.create_connection (address, timeout=GLOBAL_DEFAULT,
          source_address=None, *, all_errors=False)

     インターネット 'address' (‘(host, port)’ ペア) で listen している
     TCPサービスに接続し、ソケットオブジェクトを返します。これは *note
     socket.connect(): d70. を高級にした関数です。 'host' が数値でないホ
     スト名の場合、 *note AF_INET: 1788. と *note AF_INET6: 1789. の両方
     で名前解決を試み、得られた全てのアドレスに対して成功するまで接続を
     試みます。この関数を使って IPv4 と IPv6 に両対応したクライアントを
     簡単に書くことができます。

     オプションの 'timeout' 引数を指定すると、接続を試みる前にソケットオ
     ブジェクトのタイムアウトを設定します。 'timeout' が指定されない場合
     、 *note getdefaulttimeout(): 32e2. が返すデフォルトのタイムアウト
     設定値を利用します。

     'source_address' は接続する前にバインドするソースアドレスを指定する
     オプション引数で、指定する場合は ‘(host, port)’ の2要素タプルでなけ
     ればなりません。 host や port が '' か 0 だった場合は、OSのデフォル
     トの動作になります。

     When a connection cannot be created, an exception is raised.  By
     default, it is the exception from the last address in the list.  If
     'all_errors' is ‘True’, it is an *note ExceptionGroup: 19b.
     containing the errors of all attempts.

     バージョン 3.2 で変更: 'source_address' が追加されました。

     バージョン 3.11 で変更: 'all_errors' が追加されました

 -- の関数: socket.create_server (address, *, family=AF_INET,
          backlog=None, reuse_port=False, dualstack_ipv6=False)

     Convenience function which creates a TCP socket bound to 'address'
     (a 2-tuple ‘(host, port)’) and returns the socket object.

     'family' should be either *note AF_INET: 1788. or *note AF_INET6:
     1789.  'backlog' is the queue size passed to *note socket.listen():
     e27.; if not specified , a default reasonable value is chosen.
     'reuse_port' dictates whether to set the ‘SO_REUSEPORT’ socket
     option.

     If 'dualstack_ipv6' is true and the platform supports it the socket
     will be able to accept both IPv4 and IPv6 connections, else it will
     raise *note ValueError: 1e3.  Most POSIX platforms and Windows are
     supposed to support this functionality.  When this functionality is
     enabled the address returned by *note socket.getpeername(): 3234.
     when an IPv4 connection occurs will be an IPv6 address represented
     as an IPv4-mapped IPv6 address.  If 'dualstack_ipv6' is false it
     will explicitly disable this functionality on platforms that enable
     it by default (e.g.  Linux).  This parameter can be used in
     conjunction with *note has_dualstack_ipv6(): 9fa.:

          import socket

          addr = ("", 8080)  # all interfaces, port 8080
          if socket.has_dualstack_ipv6():
              s = socket.create_server(addr, family=socket.AF_INET6, dualstack_ipv6=True)
          else:
              s = socket.create_server(addr)

          注釈: On POSIX platforms the ‘SO_REUSEADDR’ socket option is
          set in order to immediately reuse previous sockets which were
          bound on the same 'address' and remained in TIME_WAIT state.

     Added in version 3.8.

 -- の関数: socket.has_dualstack_ipv6 ()

     Return ‘True’ if the platform supports creating a TCP socket which
     can handle both IPv4 and IPv6 connections.

     Added in version 3.8.

 -- の関数: socket.fromfd (fd, family, type, proto=0)

     Duplicate the file descriptor 'fd' (an integer as returned by a
     file object's *note fileno(): 27a6. method) and build a socket
     object from the result.  Address family, socket type and protocol
     number are as for the *note socket(): d6e. function above.  The
     file descriptor should refer to a socket, but this is not checked
     -- subsequent operations on the object may fail if the file
     descriptor is invalid.  This function is rarely needed, but can be
     used to get or set socket options on a socket passed to a program
     as standard input or output (such as a server started by the Unix
     inet daemon).  The socket is assumed to be in blocking mode.

     新たに作成されたソケットは *note 継承不可: ec4. です。

     バージョン 3.4 で変更: 返されるソケットは継承不可になりました。

 -- の関数: socket.fromshare (data)

     *note socket.share(): bd6. メソッドから取得した data からソケットオ
     ブジェクトを生成します。ソケットはブロッキングモードだと仮定されま
     す。

     *note Availability: 1cbe.: Windows.

     Added in version 3.3.

 -- データ: socket.SocketType

     ソケットオブジェクトの型を示す型オブジェクト。 ‘type(socket(...))’
     と同じです。


File: python.info,  Node: その他の関数<2>,  Prev: ソケットの作成,  Up: 関数<8>

5.18.2.7 その他の関数
.....................

*note socket: b8. モジュールはネットワーク関連のサービスを提供しています
:

 -- の関数: socket.close (fd)

     Close a socket file descriptor.  This is like *note os.close():
     b42, but for sockets.  On some platforms (most noticeable Windows)
     *note os.close(): b42. does not work for socket file descriptors.

     Added in version 3.7.

 -- の関数: socket.getaddrinfo (host, port, family=AF_UNSPEC, type=0,
          proto=0, flags=0)

     This function wraps the C function ‘getaddrinfo’ of the underlying
     system.

     'host' / 'port' 引数の指すアドレス情報を、そのサービスに接続された
     ソケットを作成するために必要な全ての引数が入った 5 要素のタプルに変
     換します。 'host' はドメイン名、IPv4/v6アドレスの文字列、または
     ‘None’ です。 'port' は ‘'http'’ のようなサービス名文字列、ポート番
     号を表す数値、または ‘None’ です。 'host' と 'port' に ‘None’ を指
     定すると C APIに ‘NULL’ を渡せます。

     The 'family', 'type' and 'proto' arguments can be optionally
     specified in order to provide options and limit the list of
     addresses returned.  Pass their default values (*note AF_UNSPEC:
     31f7, 0, and 0, respectively) to not limit the results.  See the
     note below for details.

     The 'flags' argument can be one or several of the ‘AI_*’ constants,
     and will influence how results are computed and returned.  For
     example, ‘AI_NUMERICHOST’ will disable domain name resolution and
     will raise an error if 'host' is a domain name.

     この関数は以下の構造をとる 5 要素のタプルのリストを返します:

     ‘(family, type, proto, canonname, sockaddr)’

     In these tuples, 'family', 'type', 'proto' are all integers and are
     meant to be passed to the *note socket(): d6e. function.
     'canonname' will be a string representing the canonical name of the
     'host' if ‘AI_CANONNAME’ is part of the 'flags' argument; else
     'canonname' will be empty.  'sockaddr' is a tuple describing a
     socket address, whose format depends on the returned 'family' (a
     ‘(address, port)’ 2-tuple for *note AF_INET: 1788, a ‘(address,
     port, flowinfo, scope_id)’ 4-tuple for *note AF_INET6: 1789.), and
     is meant to be passed to the *note socket.connect(): d70. method.

          注釈: If you intend to use results from ‘getaddrinfo()’ to
          create a socket (rather than, for example, retrieve
          'canonname'), consider limiting the results by 'type' (e.g.
          *note SOCK_STREAM: 12c1. or *note SOCK_DGRAM: 12c0.) and/or
          'proto' (e.g.  ‘IPPROTO_TCP’ or ‘IPPROTO_UDP’) that your
          application can handle.

          The behavior with default values of 'family', 'type', 'proto'
          and 'flags' is system-specific.

          Many systems (for example, most Linux configurations) will
          return a sorted list of all matching addresses.  These
          addresses should generally be tried in order until a
          connection succeeds (possibly tried in parallel, for example,
          using a Happy Eyeballs(1) algorithm).  In these cases,
          limiting the 'type' and/or 'proto' can help eliminate
          unsuccessful or unusable connecton attempts.

          Some systems will, however, only return a single address.
          (For example, this was reported on Solaris and AIX
          configurations.)  On these systems, limiting the 'type' and/or
          'proto' helps ensure that this address is usable.

     引数 ‘host’, ‘port’, ‘family’, ‘type’, ‘protocol’ 付きで *note
     監査イベント: 1825. ‘socket.getaddrinfo’ を送出します。

     次の例では ‘example.org’ の 80 番ポートポートへの TCP 接続を得るた
     めのアドレス情報を取得しようとしています。 (結果は IPv6 をサポート
     しているかどうかで変わります):

          >>> socket.getaddrinfo("example.org", 80, proto=socket.IPPROTO_TCP)
          [(socket.AF_INET6, socket.SOCK_STREAM,
           6, '', ('2606:2800:220:1:248:1893:25c8:1946', 80, 0, 0)),
           (socket.AF_INET, socket.SOCK_STREAM,
           6, '', ('93.184.216.34', 80))]

     バージョン 3.2 で変更: パラメータをキーワード引数で渡すことができる
     ようになりました。

     バージョン 3.7 で変更: for IPv6 multicast addresses, string
     representing an address will not contain ‘%scope_id’ part.

 -- の関数: socket.getfqdn ([name])

     Return a fully qualified domain name for 'name'.  If 'name' is
     omitted or empty, it is interpreted as the local host.  To find the
     fully qualified name, the hostname returned by *note
     gethostbyaddr(): 1837. is checked, followed by aliases for the
     host, if available.  The first name which includes a period is
     selected.  In case no fully qualified domain name is available and
     'name' was provided, it is returned unchanged.  If 'name' was empty
     or equal to ‘'0.0.0.0'’, the hostname from *note gethostname():
     2a84. is returned.

 -- の関数: socket.gethostbyname (hostname)

     ホスト名を ‘'100.50.200.5'’ のようなIPv4形式のアドレスに変換します
     。ホスト名としてIPv4アドレスを指定した場合、その値は変換せずにその
     まま返ります。 *note gethostbyname(): 32e5. APIへのより完全なインタ
     ーフェイスが必要であれば、 *note gethostbyname_ex(): 1838. を参照し
     てください。 *note gethostbyname(): 32e5. は、IPv6名前解決をサポー
     トしていません。IPv4/ v6のデュアルスタックをサポートする場合は
     *note getaddrinfo(): 16bd. を使用します。

     引数 ‘hostname’ を指定して *note 監査イベント: 1825.
     ‘socket.gethostbyname’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.gethostbyname_ex (hostname)

     Translate a host name to IPv4 address format, extended interface.
     Return a 3-tuple ‘(hostname, aliaslist, ipaddrlist)’ where
     'hostname' is the host's primary host name, 'aliaslist' is a
     (possibly empty) list of alternative host names for the same
     address, and 'ipaddrlist' is a list of IPv4 addresses for the same
     interface on the same host (often but not always a single address).
     *note gethostbyname_ex(): 1838. does not support IPv6 name
     resolution, and *note getaddrinfo(): 16bd. should be used instead
     for IPv4/v6 dual stack support.

     引数 ‘hostname’ を指定して *note 監査イベント: 1825.
     ‘socket.gethostbyname’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.gethostname ()

     Pythonインタープリタを現在実行しているマシンのホスト名を含む文字列
     を返します。

     引数無しで *note 監査イベント: 1825. ‘socket.gethostname’ を送出し
     ます。

     注意: *note gethostname(): 2a84. は完全修飾ドメイン名を返すとは限り
     ません。完全修飾ドメイン名が必要であれば、*note getfqdn(): 16e7. を
     使用してください。

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.gethostbyaddr (ip_address)

     Return a 3-tuple ‘(hostname, aliaslist, ipaddrlist)’ where
     'hostname' is the primary host name responding to the given
     'ip_address', 'aliaslist' is a (possibly empty) list of alternative
     host names for the same address, and 'ipaddrlist' is a list of
     IPv4/v6 addresses for the same interface on the same host (most
     likely containing only a single address).  To find the fully
     qualified domain name, use the function *note getfqdn(): 16e7.
     *note gethostbyaddr(): 1837. supports both IPv4 and IPv6.

     引数 ‘ip_address’ を指定して *note 監査イベント: 1825.
     ‘socket.gethostbyaddr’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.getnameinfo (sockaddr, flags)

     Translate a socket address 'sockaddr' into a 2-tuple ‘(host,
     port)’.  Depending on the settings of 'flags', the result can
     contain a fully qualified domain name or numeric address
     representation in 'host'.  Similarly, 'port' can contain a string
     port name or a numeric port number.

     For IPv6 addresses, ‘%scope_id’ is appended to the host part if
     'sockaddr' contains meaningful 'scope_id'.  Usually this happens
     for multicast addresses.

     For more information about 'flags' you can consult
     ‘getnameinfo(3)(2)’.

     引数 ‘sockaddr’ を指定して *note 監査イベント: 1825.
     ‘socket.getnameinfo’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.getprotobyname (protocolname)

     Translate an internet protocol name (for example, ‘'icmp'’) to a
     constant suitable for passing as the (optional) third argument to
     the *note socket(): d6e. function.  This is usually only needed for
     sockets opened in "raw" mode (*note SOCK_RAW: 32b3.); for the
     normal socket modes, the correct protocol is chosen automatically
     if the protocol is omitted or zero.

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.getservbyname (servicename[, protocolname])

     インターネットサービス名とプロトコルから、そのサービスのポート番号
     を取得します。省略可能なプロトコル名として、 ‘'tcp'’ か ‘'udp'’ の
     どちらかを指定することができます。指定がなければどちらのプロトコル
     にもマッチします。

     引数 ‘servicename’, ‘protocolname’ を指定して *note 監査イベント:
     1825. ‘socket.getservbyname’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.getservbyport (port[, protocolname])

     インターネットポート番号とプロトコル名から、サービス名を取得します
     。省略可能なプロトコル名として、 ‘'tcp'’ か ‘'udp'’ のどちらかを指
     定することができます。指定がなければどちらのプロトコルにもマッチし
     ます。

     引数 ‘port’, ‘protocolname’ を指定して *note 監査イベント: 1825.
     ‘socket.getservbyport’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- の関数: socket.ntohl (x)

     32ビットの正の整数のバイトオーダを、ネットワークバイトオーダからホ
     ストバイトオーダに変換します。ホストバイトオーダとネットワークバイ
     トオーダが一致するマシンでは、この関数は何もしません。それ以外の場
     合は4バイトのスワップを行います。

 -- の関数: socket.ntohs (x)

     16ビットの正の整数のバイトオーダを、ネットワークバイトオーダからホ
     ストバイトオーダに変換します。ホストバイトオーダとネットワークバイ
     トオーダが一致するマシンでは、この関数は何もしません。それ以外の場
     合は2バイトのスワップを行います。

     バージョン 3.10 で変更: Raises *note OverflowError: 84e. if 'x'
     does not fit in a 16-bit unsigned integer.

 -- の関数: socket.htonl (x)

     32ビットの正の整数のバイトオーダを、ホストバイトオーダからネットワ
     ークバイトオーダに変換します。ホストバイトオーダとネットワークバイ
     トオーダが一致するマシンでは、この関数は何もしません。それ以外の場
     合は4バイトのスワップを行います。

 -- の関数: socket.htons (x)

     16ビットの正の整数のバイトオーダを、ホストバイトオーダからネットワ
     ークバイトオーダに変換します。ホストバイトオーダとネットワークバイ
     トオーダが一致するマシンでは、この関数は何もしません。それ以外の場
     合は2バイトのスワップを行います。

     バージョン 3.10 で変更: Raises *note OverflowError: 84e. if 'x'
     does not fit in a 16-bit unsigned integer.

 -- の関数: socket.inet_aton (ip_string)

     ドット記法によるIPv4アドレス(‘'123.45.67.89'’ など)を32ビットにパッ
     クしたバイナリ形式に変換し、長さ4のバイト列オブジェクトとして返しま
     す。この関数が返す値は、標準Cライブラリの ‘in_addr’ 型を使用する関
     数に渡す事ができます。

     *note inet_aton(): 92f. はドットが 3 個以下の文字列も受け取ります;
     詳細については Unix のマニュアル ‘inet(3)(3)’ を参照してください。

     IPv4アドレス文字列が不正であれば、 *note OSError: 3f0. が発生します
     。このチェックは、この関数で使用しているCの実装 ‘inet_aton()’ で行
     われます。

     *note inet_aton(): 92f. は、IPv6をサポートしません。IPv4/v6のデュア
     ルスタックをサポートする場合は *note inet_pton(): 930. を使用します
     。

 -- の関数: socket.inet_ntoa (packed_ip)

     32 ビットにパックされた IPv4 アドレス (長さ 4 バイトの *note
     bytes-like object: cfb.) を、標準的なドット記法による 4 桁の文字列
     ('123.45.67.89' など) に変換します。この関数は、‘in_addr’ 型、つま
     りこの関数が引数として受け取る 32 ビットにパックされたバイナリデー
     タに対する C の型、を使用する標準 C ライブラリのプログラムとやりと
     りする場合に便利です。

     この関数に渡すバイトシーケンスの長さが4バイト以外であれば、 *note
     OSError: 3f0. が発生します。 *note inet_ntoa(): 32eb. は、IPv6をサ
     ポートしません。IPv4/v6のデュアルスタックをサポートする場合は *note
     inet_ntop(): f71. を使用します。

     バージョン 3.5 で変更: 書き込み可能な *note bytes-like object: cfb.
     を使用できるようになりました。

 -- の関数: socket.inet_pton (address_family, ip_string)

     IPアドレスを、アドレスファミリ固有の文字列からパックしたバイナリ形
     式に変換します。 *note inet_pton(): 930. は、 ‘in_addr’ 型 (*note
     inet_aton(): 92f. と同様)や ‘in6_addr’ を使用するライブラリやネット
     ワークプロトコルを呼び出す際に使用することができます。

     現在サポートされている 'address_family' は、 *note AF_INET: 1788. と
     *note AF_INET6: 1789. です。 'ip_string' に不正なIPアドレス文字列を
     指定すると、 *note OSError: 3f0. が発生します。有効な 'ip_string' は
     、 'address_family' と ‘inet_pton()’ の実装によって異なります。

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.4 で変更: Windowsで利用可能になりました

 -- の関数: socket.inet_ntop (address_family, packed_ip)

     パックしたIPアドレス (数バイトからなる *note bytes-like
     オブジェクト: cfb. ) を、 ‘'7.10.0.5'’ や ‘'5aef:2b::8'’ などの標準
     的な、アドレスファミリ固有の文字列形式に変換します。 *note
     inet_ntop(): f71. は (*note inet_ntoa(): 32eb. と同様に)、
     ‘in_addr’ 型や ‘in6_addr’ 型のオブジェクトを返すライブラリやネット
     ワークプロトコル等で使用することができます。

     現在サポートされている 'address_family' の値は、 *note AF_INET:
     1788. と *note AF_INET6: 1789. です。バイトオブジェクトの
     'packed_ip' の長さが、指定したアドレスファミリで適切な長さでない場
     合、 *note ValueError: 1e3. が発生します。 *note inet_ntop(): f71.
     の呼び出しでエラーが起こると、 *note OSError: 3f0. が発生します。

     *note Availability: 1cbe.: Unix, Windows.

     バージョン 3.4 で変更: Windowsで利用可能になりました

     バージョン 3.5 で変更: 書き込み可能な *note bytes-like object: cfb.
     を使用できるようになりました。

 -- の関数: socket.CMSG_LEN (length)

     指定された 'length' にある制御メッセージ（CMSG）から、末尾のパディ
     ングを除いた全体の長さを返します。この値は多くの場合、 *note
     recvmsg(): d73. が制御メッセージの一連の要素を受信するためのバッフ
     ァサイズとして使用できますが、バッファの末尾が要素である場合であっ
     てもパディングは含まれるので、バッファサイズを取得するには RFC
     3542(4) で求められているように、 *note CMSG_SPACE(): 19a1. を使用し
     た移植可能なアプリケーションが必要です。通常 'length' は定数であり
     、許容範囲外の値が指定された場合は *note OverflowError: 84e. 例外が
     送出されます。

     *note Availability: 1cbe.: Unix, not WASI.

     Unix プラットフォーム。

     Added in version 3.3.

 -- の関数: socket.CMSG_SPACE (length)

     指定された 'length' の制御メッセージ（CMSG）の要素を *note
     recvmsg(): d73. が受信するために必要な、パディングを含めたバッファ
     サイズを返します。複数の項目を受信するために必要なバッファスペース
     は、 *note CMSG_SPACE(): 19a1. が返すそれぞれの要素の長さの合計です
     。通常 'length' は定数であり、許容範囲外の値が指定された場合は
     *note OverflowError: 84e. 例外が送出されます。

     一部のシステムではこの関数を提供せずに制御メッセージをサポートする
     可能性があることに注意してください。また、この関数の返り値を使用し
     て設定するバッファサイズは、受信する制御メッセージの量を正確に規定
     しないことがあり、その後に受信するデータがパディング領域に合う場合
     があることに注意してください。

     *note Availability: 1cbe.: Unix, not WASI.

     most Unix platforms.

     Added in version 3.3.

 -- の関数: socket.getdefaulttimeout ()

     新規に生成されたソケットオブジェクトの、デフォルトのタイムアウト値
     を浮動小数点形式の秒数で返します。タイムアウトを使用しない場合には
     ‘None’ を返します。最初に socket モジュールがインポートされた時の初
     期値は ‘None’ です。

 -- の関数: socket.setdefaulttimeout (timeout)

     新規に生成されるソケットオブジェクトの、デフォルトのタイムアウト値
     を秒数 (float 型) で設定します。最初に socket モジュールがインポー
     トされた時の初期値は ‘None’ です。指定可能な値とその意味については
     *note settimeout(): 32ad. メソッドを参照してください。

 -- の関数: socket.sethostname (name)

     マシンのホスト名を 'name' に設定します。必要な権限がない場合は
     *note OSError: 3f0. を送出します。

     引数 ‘name’ を指定して *note 監査イベント: 1825.
     ‘socket.sethostname’ を送出します。

     *note Availability: 1cbe.: Unix, not Android.

     Added in version 3.3.

 -- の関数: socket.if_nameindex ()

     ネットワークインターフェース情報 (index int, name string)のタプルを
     返します。システムコールが失敗した場合、 *note OSError: 3f0. 例外を
     送出します。

     *note Availability: 1cbe.: Unix, Windows, not WASI.

     Added in version 3.3.

     バージョン 3.8 で変更: Windows のサポートが追加されました。

          注釈: On Windows network interfaces have different names in
          different contexts (all names are examples):

             * UUID: ‘{FB605B73-AAC2-49A6-9A2F-25416AEA0573}’

             * name: ‘ethernet_32770’

             * friendly name: ‘vEthernet (nat)’

             * description: ‘Hyper-V Virtual Ethernet Adapter’

          This function returns names of the second form from the list,
          ‘ethernet_32770’ in this example case.

 -- の関数: socket.if_nametoindex (if_name)

     インターフェース名 'if_name' に対応するネットワークインターフェース
     のインデックス番号を返します。対応するインターフェースが存在しない
     場合は *note OSError: 3f0. 例外を送出します。

     *note Availability: 1cbe.: Unix, Windows, not WASI.

     Added in version 3.3.

     バージョン 3.8 で変更: Windows のサポートが追加されました。

     参考
     ....

     "Interface name" is a name as documented in *note if_nameindex():
     9fb.

 -- の関数: socket.if_indextoname (if_index)

     インターフェースインデックス番号 'if_index' に対応するネットワーク
     インターフェース名を返します。対応するインターフェースが存在しない
     場合は *note OSError: 3f0. 例外を送出します。

     *note Availability: 1cbe.: Unix, Windows, not WASI.

     Added in version 3.3.

     バージョン 3.8 で変更: Windows のサポートが追加されました。

     参考
     ....

     "Interface name" is a name as documented in *note if_nameindex():
     9fb.

 -- の関数: socket.send_fds (sock, buffers, fds[, flags[, address]])

     Send the list of file descriptors 'fds' over an *note AF_UNIX:
     178a. socket 'sock'.  The 'fds' parameter is a sequence of file
     descriptors.  Consult *note sendmsg(): 443. for the documentation
     of these parameters.

     *note Availability: 1cbe.: Unix, Windows, not WASI.

     Unix platforms supporting *note sendmsg(): 443. and ‘SCM_RIGHTS’
     mechanism.

     Added in version 3.9.

 -- の関数: socket.recv_fds (sock, bufsize, maxfds[, flags])

     Receive up to 'maxfds' file descriptors from an *note AF_UNIX:
     178a. socket 'sock'.  Return ‘(msg, list(fds), flags, addr)’.
     Consult *note recvmsg(): d73. for the documentation of these
     parameters.

     *note Availability: 1cbe.: Unix, Windows, not WASI.

     Unix platforms supporting *note sendmsg(): 443. and ‘SCM_RIGHTS’
     mechanism.

     Added in version 3.9.

          注釈: Any truncated integers at the end of the list of file
          descriptors.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Happy_Eyeballs

   (2) https://manpages.debian.org/getnameinfo(3)

   (3) https://manpages.debian.org/inet(3)

   (4) https://datatracker.ietf.org/doc/html/rfc3542.html


File: python.info,  Node: socket オブジェクト,  Next: ソケットタイムアウトの注意事項,  Prev: モジュールの内容,  Up: socket --- 低水準ネットワークインターフェース

5.18.2.8 socket オブジェクト
............................

ソケットオブジェクトは以下のメソッドを持ちます。 *note makefile(): 1170.
以外のメソッドは、Unixのソケット用システムコールに対応しています。

バージョン 3.2 で変更: *note context manager: 59e. プロトコルのサポート
が追加されました。コンテキストマネージャを終了することは、 *note
close(): b41. を呼ぶことと同一です。

 -- メソッド: socket.accept ()

     接続を受け付けます。ソケットはアドレスにbind済みで、listen中である
     必要があります。戻り値は ‘(conn, address)’ のペアで、 'conn' は接続
     を通じてデータの送受信を行うための '新しい' ソケットオブジェクト、
     'address' は接続先でソケットにbindしているアドレスを示します。

     新たに作成されたソケットは *note 継承不可: ec4. です。

     バージョン 3.4 で変更: ソケットが *note 継承不可: ec4. になりました
     。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(1) を参照してください)。

 -- メソッド: socket.bind (address)

     ソケットを 'address' にbindします。bind済みのソケットを再バインドす
     る事はできません。('address' のフォーマットはアドレスファミリによっ
     て異なります - 前述。)

     引数 ‘self’, ‘address’ を指定して *note 監査イベント: 1825.
     ‘socket.bind’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- メソッド: socket.close ()

     Mark the socket closed.  The underlying system resource (e.g.  a
     file descriptor) is also closed when all file objects from *note
     makefile(): 1170. are closed.  Once that happens, all future
     operations on the socket object will fail.  The remote end will
     receive no more data (after queued data is flushed).

     ソケットはガベージコレクション時に自動的にクローズされます。しかし
     、明示的に *note close(): b41. するか、 *note with: 59c. 文の中でソ
     ケットを使うことを推奨します。

     バージョン 3.6 で変更: 下層の ‘close()’ が呼び出される時、*note
     OSError: 3f0. が送出されるようになりました。

          注釈: *note close(): b41. releases the resource associated
          with a connection but does not necessarily close the
          connection immediately.  If you want to close the connection
          in a timely fashion, call *note shutdown(): 32dd. before *note
          close(): b41.

 -- メソッド: socket.connect (address)

     'address' で示されるリモートソケットに接続します。('address' のフォ
     ーマットはアドレスファミリによって異なります -- 前述。)

     接続が信号によって中断された場合、このメソッドは接続が完了するまで
     待機するか、タイムアウト時に *note TimeoutError: 800. を送出します
     。タイムアウトは、信号ハンドラが例外を送出せず、ソケットがブロック
     するかタイムアウトが設定されている場合に起こります。非ブロックソケ
     ットでは、接続が信号によって中断された場合 (あるいは信号ハンドラに
     より例外が送出された場合)、このメソッドは *note InterruptedError:
     d55. 例外を送出します。

     引数 ‘self’, ‘address’ を指定して *note 監査イベント: 1825.
     ‘socket.connect’ を送出します。

     バージョン 3.5 で変更: このメソッドは、接続が信号によって中断され、
     信号ハンドラが例外を送出せず、ソケットがブロックであるかタイムアウ
     トが設定されている場合、*note InterruptedError: d55. 例外を送出する
     代わりに、接続を完了するまで待機するようになりました (論拠について
     は PEP 475(2) を参照してください)。

     *note Availability: 1cbe.: not WASI.

 -- メソッド: socket.connect_ex (address)

     ‘connect(address)’ と同様ですが、C言語の ‘connect()’ 関数の呼び出し
     でエラーが発生した場合には例外を送出せずにエラーを戻り値として返し
     ます。(これ以外の、"host not found,"等のエラーの場合には例外が発生
     します。)処理が正常に終了した場合には ‘0’ を返し、エラー時には
     ‘errno’ の値を返します。この関数は、非同期接続をサポートする場合な
     どに使用することができます。

     引数 ‘self’, ‘address’ を指定して *note 監査イベント: 1825.
     ‘socket.connect’ を送出します。

     *note Availability: 1cbe.: not WASI.

 -- メソッド: socket.detach ()

     実際にファイル記述子を閉じることなく、ソケットオブジェクトを閉じた
     状態にします。ファイル記述子は返却され、他の目的に再利用することが
     できます。

     Added in version 3.2.

 -- メソッド: socket.dup ()

     ソケットを複製します。

     新たに作成されたソケットは *note 継承不可: ec4. です。

     バージョン 3.4 で変更: ソケットが *note 継承不可: ec4. になりました
     。

     *note Availability: 1cbe.: not WASI.

 -- メソッド: socket.fileno ()

     ソケットのファイル記述子を短い整数型で返します。失敗時には、-1 を返
     します。ファイル記述子は、 *note select.select(): d6d. などで使用し
     ます。

     Windowsではこのメソッドで返された小整数をファイル記述子を扱う箇所
     (*note os.fdopen(): 1e92. など) で利用できません。 Unix にはこの制
     限はありません。

 -- メソッド: socket.get_inheritable ()

     ソケットのファイル記述子またはソケットのハンドルの *note
     継承可能フラグ: ec4. を取得します。ソケットが子プロセスへ継承可能な
     ら ‘True’ 、継承不可なら ‘False’ を返します。

     Added in version 3.4.

 -- メソッド: socket.getpeername ()

     ソケットが接続しているリモートアドレスを返します。この関数は、リモ
     ート IPv4/v6ソケットのポート番号を調べる場合などに使用します。
     'address' のフォーマットはアドレスファミリによって異なります(前述
     )。この関数をサポートしていないシステムも存在します。

 -- メソッド: socket.getsockname ()

     ソケット自身のアドレスを返します。この関数は、IPv4/v6ソケットのポー
     ト番号を調べる場合などに使用します。('address' のフォーマットはアド
     レスファミリによって異なります -- 前述。)

 -- メソッド: socket.getsockopt (level, optname[, buflen])

     Return the value of the given socket option (see the Unix man page
     ‘getsockopt(2)(3)’).  The needed symbolic constants (*note SO_*
     etc.: 31f3.) are defined in this module.  If 'buflen' is absent, an
     integer option is assumed and its integer value is returned by the
     function.  If 'buflen' is present, it specifies the maximum length
     of the buffer used to receive the option in, and this buffer is
     returned as a bytes object.  It is up to the caller to decode the
     contents of the buffer (see the optional built-in module *note
     struct: c0. for a way to decode C structures encoded as byte
     strings).

     *note Availability: 1cbe.: not WASI.

 -- メソッド: socket.getblocking ()

     Return ‘True’ if socket is in blocking mode, ‘False’ if in
     non-blocking.

     This is equivalent to checking ‘socket.gettimeout() != 0’.

     Added in version 3.7.

 -- メソッド: socket.gettimeout ()

     ソケットに指定されたタイムアウト値を取得します。タイムアウト値が設
     定されている場合には浮動小数点型で秒数が、設定されていなければ
     ‘None’ が返ります。この値は、最後に呼び出された *note
     setblocking(): 2a9b. または *note settimeout(): 32ad. によって設定
     されます。

 -- メソッド: socket.ioctl (control, option)


     プラットフォーム: Windows

     *note ioctl(): ca1. メソッドは WSAIoctl システムインターフェースへ
     の制限されたインターフェースです。詳しい情報については、 Win32
     documentation(4) を参照してください。

     他のプラットフォームでは一般的な *note fcntl.fcntl(): 32f0. と
     *note fcntl.ioctl(): 141f. が使われるでしょう; これらの関数は第 1 引
     数としてソケットオブジェクトを取ります。

     現在、以下のコントロールコードのみがサポートされています。
     ‘SIO_RCVALL’, ‘SIO_KEEPALIVE_VALS’, ‘SIO_LOOPBACK_FAST_PATH’。

     バージョン 3.6 で変更: ‘SIO_LOOPBACK_FAST_PATH’ が追加されました。

 -- メソッド: socket.listen ([backlog])

     サーバーを有効にして、接続を受け付けるようにします。'backlog' が指
     定されている場合、少なくとも 0 以上でなければなりません (それより低
     い場合、0 に設定されます)。システムが新しい接続を拒否するまでに許可
     する未受付の接続の数を指定します。指定しない場合、デフォルトの妥当
     な値が選択されます。

     *note Availability: 1cbe.: not WASI.

     バージョン 3.5 で変更: 'backlog' 引数が任意になりました。

 -- メソッド: socket.makefile (mode='r', buffering=None, *,
          encoding=None, errors=None, newline=None)

     Return a *note file object: 1193. associated with the socket.  The
     exact returned type depends on the arguments given to *note
     makefile(): 1170.  These arguments are interpreted the same way as
     by the built-in *note open(): 4e5. function, except the only
     supported 'mode' values are ‘'r'’ (default), ‘'w'’, ‘'b'’, or a
     combination of those.

     ソケットはブロッキングモードでなければなりません。タイムアウトを設
     定することはできますが、タイムアウトが発生すると、ファイルオブジェ
     クトの内部バッファが矛盾した状態になることがあります。

     *note makefile(): 1170. でファイルオブジェクトにソケットを関連づけ
     た場合、ソケットを閉じるには、関連づけられたすべてのファイルオブジ
     ェクトを閉じたあとで、元のソケットの *note socket.close(): b41. を
     呼び出さなければなりません。

          注釈: Windows では *note subprocess.Popen(): 17e. の stream 引
          数などファイルディスクリプタつき file オブジェクトが期待されて
          いる場所では、 *note makefile(): 1170. によって作成される
          file-like オブジェクトは使用できません。

 -- メソッド: socket.recv (bufsize[, flags])

     Receive data from the socket.  The return value is a bytes object
     representing the data received.  The maximum amount of data to be
     received at once is specified by 'bufsize'.  A returned empty bytes
     object indicates that the client has disconnected.  See the Unix
     manual page ‘recv(2)(5)’ for the meaning of the optional argument
     'flags'; it defaults to zero.

          注釈: ハードウェアおよびネットワークの現実に最大限マッチするよ
          うに、 'bufsize' の値は比較的小さい2の累乗、たとえば 4096、に
          すべきです。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(6) を参照してください)。

 -- メソッド: socket.recvfrom (bufsize[, flags])

     ソケットからデータを受信し、結果をタプル ‘(bytes, address)’ として
     返します。 'bytes' は受信データの bytes オブジェクトで、 'address'
     は送信元のアドレスを示します。オプション引数 'flags' については、
     Unix のマニュアルページ ‘recv(2)(7)’ を参照してください。デフォルト
     は0です。 ('address' のフォーマットはアドレスファミリによって異なり
     ます(前述))

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(8) を参照してください)。

     バージョン 3.7 で変更: For multicast IPv6 address, first item of
     'address' does not contain ‘%scope_id’ part anymore.  In order to
     get full IPv6 address use *note getnameinfo(): 1629.

 -- メソッド: socket.recvmsg (bufsize[, ancbufsize[, flags]])

     ソケットから通常のデータ (最大 'bufsize' バイト) と補助的なデータを
     受信します。'ancbufsize' 引数により、補助的なデータの受信に使用され
     る内部バッファのバイト数として、サイズが設定されます。このデフォル
     トは 0 で、補助的なデータを受信しないことを意味します。*note
     CMSG_SPACE(): 19a1. または *note CMSG_LEN(): 19a2. を使用して、補助
     的なデータの適切なサイズを計算することができ、バッファ内に収まらな
     いアイテムは、短縮されるか破棄されます。'flags' 引数はデフォルトで
     は 0 で、*note recv(): d71. での意味と同じ意味を持ちます。

     戻り値は 4 要素のタプル ‘(data, ancdata, msg_flags, address)’ です
     。'data' アイテムは、受信した非付属的データを保持する *note bytes:
     1a4. オブジェクトです。'ancdata' アイテムは、ゼロ以上のタプル
     ‘(cmsg_level, cmsg_type, cmsg_data)’ からなるリストで、受信する付属
     的なデータ (制御メッセージ) を表します。'cmsg_level' と 'cmsg_type'
     はそれぞれ、プロトコルレベルとプロトコル固有のタイプを指定する整数
     で、'cmsg_data' は関連するデータを保持する *note bytes: 1a4. オブジ
     ェクトです。'msg_flags' アイテムは、受信したメッセージの条件を示す
     様々なフラグのビット OR です。詳細は、システムのドキュメントを参照
     してください。受信ソケットが接続されていない場合、'address' は、送
     信ソケットが利用できる場合にはそのアドレスで、利用できない場合、そ
     の値は未指定になります。

     一部のシステムでは、*note sendmsg(): 443. と *note recvmsg(): d73.
     を使用して、プロセス間で *note AF_UNIX: 178a. ソケットを経由してフ
     ァイル記述子を渡すことができます。この機能を使用する場合 (しばしば
     *note SOCK_STREAM: 12c1. ソケットに限定されます)、*note recvmsg():
     d73. は、付属的なデータ中に、‘(socket.SOL_SOCKET,
     socket.SCM_RIGHTS, fds)’ という形式のアイテムを返します。ここで、
     'fds' は、新しいファイル記述子をネイティブ C の int 型のバイナリ配
     列として表す *note bytes: 1a4. オブジェクトです。システムコールが返
     った後 *note recvmsg(): d73. が例外を送出する場合、まずこのメカニズ
     ムを経由して受信したファイル記述子を全て閉じようと試みます。

     一部のシステムでは、部分的に受信した付属的なデータアイテムの短縮さ
     れた長さが示されません。アイテムがバッファの末尾を超えているようで
     ある場合、*note recvmsg(): d73. は *note RuntimeWarning: 1a2. を送
     出し、関連するデータの開始位置より前で途切れていない場合、バッファ
     内の付属的なデータの一部を返します。

     ‘SCM_RIGHTS’ メカニズムをサポートするシステム上では、次の関数が最大
     'maxfds' のファイル記述子を受信し、メッセージデータと記述子を含むリ
     ストを返しま(無関係な制御メッセージを受信した場合など、予期しない条
     件は無視します)。 *note sendmsg(): 443. も参照してください。

          import socket, array

          def recv_fds(sock, msglen, maxfds):
              fds = array.array("i")   # Array of ints
              msg, ancdata, flags, addr = sock.recvmsg(msglen, socket.CMSG_LEN(maxfds * fds.itemsize))
              for cmsg_level, cmsg_type, cmsg_data in ancdata:
                  if cmsg_level == socket.SOL_SOCKET and cmsg_type == socket.SCM_RIGHTS:
                      # Append data, ignoring any truncated integers at the end.
                      fds.frombytes(cmsg_data[:len(cmsg_data) - (len(cmsg_data) % fds.itemsize)])
              return msg, list(fds)

     *note Availability: 1cbe.: Unix.

     Unix プラットフォーム。

     Added in version 3.3.

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(9) を参照してください)。

 -- メソッド: socket.recvmsg_into (buffers[, ancbufsize[, flags]])

     *note recvmsg(): d73. と同様に動作してソケットから通常のデータと付
     属的なデータを受信しますが、非付属的データは新しいバイトオブジェク
     トとして返すのではなく、一連のバッファとして返します。'buffers' 引
     数は書き込み可能なバッファをエクスポートするオブジェクトのイテラブ
     ルでなければなりません (例: *note bytearray: 508. オブジェクト)。こ
     れらは、全てに書き込まれるか、残りバッファがなくなるまで、非付属的
     データの連続チャンクで埋められます。オペレーティングシステムによっ
     て、使用できるバッファの数が制限 (*note sysconf(): 2ac2. 値
     ‘SC_IOV_MAX’) されている場合があります。'ancbufsize' 引数と 'flags'
     引数は、*note recvmsg(): d73. での意味と同じ意味を持ちます。

     戻り値は 4 要素のタプル ‘(nbytes, ancdata, msg_flags, address)’ で
     す。ここで、'nbytes' はバッファに書き込まれた非付属的データの総数で
     、'ancdata'、'msg_flags'、'address' は *note recvmsg(): d73. と同様
     です。

     以下はプログラム例です:

          >>> import socket
          >>> s1, s2 = socket.socketpair()
          >>> b1 = bytearray(b'----')
          >>> b2 = bytearray(b'0123456789')
          >>> b3 = bytearray(b'--------------')
          >>> s1.send(b'Mary had a little lamb')
          22
          >>> s2.recvmsg_into([b1, memoryview(b2)[2:9], b3])
          (22, [], 0, None)
          >>> [b1, b2, b3]
          [bytearray(b'Mary'), bytearray(b'01 had a 9'), bytearray(b'little lamb---')]

     *note Availability: 1cbe.: Unix.

     Unix プラットフォーム。

     Added in version 3.3.

 -- メソッド: socket.recvfrom_into (buffer[, nbytes[, flags]])

     ソケットからデータを受信し、そのデータを新しいバイト文字列として返
     す代わりに 'buffer' に書きます。戻り値は ‘(nbytes, address)’ のペア
     で、 'nbytes' は受信したデータのバイト数を、 'address' はデータを送
     信したソケットのアドレスです。オプション引数 'flags' (デフォルト:0)
     の意味については、 Unix マニュアルページ ‘recv(2)(10)’ を参照してく
     ださい。('address' のフォーマットは前述のとおりアドレスファミリーに
     依存します。)

 -- メソッド: socket.recv_into (buffer[, nbytes[, flags]])

     'nbytes' バイトまでのデータをソケットから受信して、そのデータを新し
     いバイト文字列にするのではなく 'buffer' に保存します。 'nbytes' が
     指定されない(あるいは0が指定された)場合、 'buffer' の利用可能なサイ
     ズまで受信します。受信したバイト数を返り値として返します。オプショ
     ン引数 'flags' (デフォルト:0) の意味については、 Unix マニュアルペ
     ージ ‘recv(2)(11)’ を参照してください。

 -- メソッド: socket.send (bytes[, flags])

     ソケットにデータを送信します。ソケットはリモートソケットに接続済み
     でなければなりません。オプション引数 'flags' の意味は、上記 *note
     recv(): d71. と同じです。戻り値として、送信したバイト数を返します。
     アプリケーションでは、必ず戻り値をチェックし、全てのデータが送られ
     た事を確認する必要があります。データの一部だけが送信された場合、ア
     プリケーションで残りのデータを再送信してください。 *note
     ソケットプログラミングHOWTO: 32f1. に、さらに詳しい情報があります。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(12) を参照してください)。

 -- メソッド: socket.sendall (bytes[, flags])

     ソケットにデータを送信します。ソケットはリモートソケットに接続済み
     でなければなりません。オプション引数 'flags' の意味は、上記 *note
     recv(): d71. と同じです。 *note send(): d74. と異なり、このメソッド
     は 'bytes' の全データを送信するか、エラーが発生するまで処理を継続し
     ます。正常終了の場合は ‘None’ を返し、エラー発生時には例外が発生し
     ます。エラー発生時、送信されたバイト数を調べる事はできません。

     バージョン 3.5 で変更: ソケットのタイムアウトは、データが正常に送信
     される度にリセットされなくなりました。ソケットのタイムアウトは、す
     べてのデータを送る最大の合計時間となります。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(13) を参照してください)。

 -- メソッド: socket.sendto (bytes, address)

 -- メソッド: socket.sendto (bytes, flags, address)

     ソケットにデータを送信します。このメソッドでは接続先を 'address' で
     指定するので、接続済みではいけません。オプション引数 'flags' の意味
     は、上記 *note recv(): d71. と同じです。戻り値として、送信したバイ
     ト数を返します。('address' のフォーマットはアドレスファミリによって
     異なります -- 前述。)

     引数 ‘self’, ‘address’ を指定して *note 監査イベント: 1825.
     ‘socket.sendto’ を送出します。

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(14) を参照してください)。

 -- メソッド: socket.sendmsg (buffers[, ancdata[, flags[, address]]])

     非付属的なデータを一連のバッファから集め、単一のメッセージにまとめ
     ることで、通常のデータと付属的なデータをソケットに送信します。
     'buffers' 引数は、非付属的なデータを *note bytes-like objects: cfb.
     (例: *note bytes: 1a4. オブジェクト) のイテラブルとして指定します。
     オペレーティングシステムによって、使用できるバッファの数が制限
     (*note sysconf(): 2ac2. 値 ‘SC_IOV_MAX’) されている場合があります。
     'ancdata' 引数は付属的なデータ (制御メッセージ) をゼロ以上のタプル
     ‘(cmsg_level, cmsg_type, cmsg_data)’ のイテラブルとして指定します。
     ここで、'cmsg_level' と 'cmsg_type' はそれぞれプロトコルレベルとプ
     ロトコル固有のタイプを指定する整数で、'cmsg_data' は関連データを保
     持するバイトライクオブジェクトです。一部のシステム (特に *note
     CMSG_SPACE(): 19a1. を持たないシステム) では、一度の呼び出しで一つ
     の制御メッセージの送信しかサポートされていない場合があります。
     'flags' 引数のデフォルトは 0 であり、*note send(): d74. での意味と
     同じ意味を持ちます。‘None’ 以外の 'address' が渡された場合、メッセ
     ージの目的地のアドレスを設定します。戻り値は、送信された非付属的デ
     ータのバイト数です。

     以下の関数は、‘SCM_RIGHTS’ メカニズムをサポートするシステムで、ファ
     イル記述子 'fds' を *note AF_UNIX: 178a. ソケット経由で送信します。
     *note recvmsg(): d73. も参照してください。

          import socket, array

          def send_fds(sock, msg, fds):
              return sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", fds))])

     *note Availability: 1cbe.: Unix, not WASI.

     Unix プラットフォーム。

     引数 ‘self’, ‘address’ を指定して *note 監査イベント: 1825.
     ‘socket.sendmsg’ を送出します。

     Added in version 3.3.

     バージョン 3.5 で変更: システムコールが中断されシグナルハンドラが例
     外を送出しなかった場合、このメソッドは *note InterruptedError: d55.
     例外を送出する代わりにシステムコールを再試行するようになりました (論
     拠については PEP 475(15) を参照してください)。

 -- メソッド: socket.sendmsg_afalg ([msg], *, op[, iv[, assoclen[,
          flags]]])

     *note sendmsg(): 443. の *note AF_ALG: ca5. ソケット用に特化したバ
     ージョンです。*note AF_ALG: ca5. ソケットの、モード、IV、AEAD に関
     連づけられたデータ長、フラグを設定します。

     *note Availability: 1cbe.: Linux >= 2.6.38.

     Added in version 3.6.

 -- メソッド: socket.sendfile (file, offset=0, count=None)

     高性能の *note os.sendfile: add. を使用して、ファイルを EOF まで送
     信し、送信されたバイトの総数を返します。'file' は、バイナリモードで
     開かれた標準的なファイルオブジェクトです。*note os.sendfile: add. が
     使用できない場合 (例: Windows)、または 'file' が標準的なファイルで
     ない場合、代わりに *note send(): d74. が使用されます。'offset' は、
     ファイルの読み出し開始位置を指定します。'count' が指定されている場
     合、ファイルを EOF まで送信するのではなく、転送するバイトの総数を指
     定します。ファイルの位置は、返る時に更新されます。あるいは、エラー
     時には *note file.tell(): 2907.  を使用して送信されたバイトの数を確
     認することができます。ソケットは *note SOCK_STREAM: 12c1. タイプで
     なければなりません。非ブロックソケットはサポートされていません。

     Added in version 3.5.

 -- メソッド: socket.set_inheritable (inheritable)

     ソケットのファイル記述子、またはソケットのハンドルの、 *note
     継承可能フラグ: ec4. を立てます。

     Added in version 3.4.

 -- メソッド: socket.setblocking (flag)

     ソケットをブロッキングモード、または非ブロッキングモードに設定しま
     す。'flag' が False の場合にはソケットは非ブロッキングモードになり
     、True の場合にはブロッキングモードになります。

     このメソッドは、次の *note settimeout(): 32ad. 呼び出しの省略表記で
     す:

        * ‘sock.setblocking(True)’ は ‘sock.settimeout(None)’ と等価です

        * ‘sock.setblocking(False)’ は ‘sock.settimeout(0.0)’ と等価です

     バージョン 3.7 で変更: The method no longer applies *note
     SOCK_NONBLOCK: bd8. flag on *note socket.type: bda.

 -- メソッド: socket.settimeout (value)

     Set a timeout on blocking socket operations.  The 'value' argument
     can be a nonnegative floating-point number expressing seconds, or
     ‘None’.  If a non-zero value is given, subsequent socket operations
     will raise a *note timeout: 7ff. exception if the timeout period
     'value' has elapsed before the operation has completed.  If zero is
     given, the socket is put in non-blocking mode.  If ‘None’ is given,
     the socket is put in blocking mode.

     詳しくは *note ソケットタイムアウトの注意事項: 32f2. を参照してくだ
     さい。

     バージョン 3.7 で変更: The method no longer toggles *note
     SOCK_NONBLOCK: bd8. flag on *note socket.type: bda.

 -- メソッド: socket.setsockopt (level, optname, value: int)

 -- メソッド: socket.setsockopt (level, optname, value: buffer)

 -- メソッド: socket.setsockopt (level, optname, None, optlen: int)

     Set the value of the given socket option (see the Unix manual page
     ‘setsockopt(2)(16)’).  The needed symbolic constants are defined in
     this module (SO_* etc.  <socket-unix-constants>).  The value can be
     an integer, ‘None’ or a *note bytes-like object: cfb. representing
     a buffer.  In the later case it is up to the caller to ensure that
     the bytestring contains the proper bits (see the optional built-in
     module *note struct: c0. for a way to encode C structures as
     bytestrings).  When 'value' is set to ‘None’, 'optlen' argument is
     required.  It's equivalent to call ‘setsockopt()’ C function with
     ‘optval=NULL’ and ‘optlen=optlen’.

     バージョン 3.5 で変更: 書き込み可能な *note bytes-like object: cfb.
     を使用できるようになりました。

     バージョン 3.6 で変更: setsockopt(level, optname, None, optlen:
     int) の形式が追加されました。

     *note Availability: 1cbe.: not WASI.

 -- メソッド: socket.shutdown (how)

     接続の片方向、または両方向を切断します。 'how' が *note SHUT_RD:
     32da. の場合、以降は受信を行えません。 'how' が *note SHUT_WR:
     32db. の場合、以降は送信を行えません。 'how' が *note SHUT_RDWR:
     32dc. の場合、以降は送受信を行えません。

     *note Availability: 1cbe.: not WASI.

 -- メソッド: socket.share (process_id)

     ソケットを複製し、対象のプロセスと共有するための bytes オブジェクト
     を返します。対象のプロセスを 'process_id' で指定しなければなりませ
     ん。戻り値の bytes オブジェクトは、何らかのプロセス間通信を使って対
     象のプロセスに伝えます。対象のプロセス側では、 *note fromshare():
     bd5. を使って複製されたソケットをとらえます。オペレーティング・シス
     テムは対象のプロセスに対してソケットを複製するため、このメソッドを
     呼び出した後であれば、元のソケットをクローズしても、対象のプロセス
     に渡ったソケットには影響がありません。

     *note Availability: 1cbe.: Windows.

     Added in version 3.3.

‘read()’ メソッドと ‘write()’ メソッドは存在しませんので注意してください
。代わりに 'flags' を省略した *note recv(): d71. と *note send(): d74. を
使うことができます。

ソケットオブジェクトには以下の *note socket: d6e. コンストラクタに渡され
た値に対応した (読み出し専用) 属性があります。

 -- の属性: socket.family

     ソケットファミリー。

 -- の属性: socket.type

     ソケットタイプ。

 -- の属性: socket.proto

     ソケットプロトコル。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/

   (2) https://peps.python.org/pep-0475/

   (3) https://manpages.debian.org/getsockopt(2)

   (4) https://msdn.microsoft.com/en-us/library/ms741621%28VS.85%29.aspx

   (5) https://manpages.debian.org/recv(2)

   (6) https://peps.python.org/pep-0475/

   (7) https://manpages.debian.org/recv(2)

   (8) https://peps.python.org/pep-0475/

   (9) https://peps.python.org/pep-0475/

   (10) https://manpages.debian.org/recv(2)

   (11) https://manpages.debian.org/recv(2)

   (12) https://peps.python.org/pep-0475/

   (13) https://peps.python.org/pep-0475/

   (14) https://peps.python.org/pep-0475/

   (15) https://peps.python.org/pep-0475/

   (16) https://manpages.debian.org/setsockopt(2)


File: python.info,  Node: ソケットタイムアウトの注意事項,  Next: 使用例<26>,  Prev: socket オブジェクト,  Up: socket --- 低水準ネットワークインターフェース

5.18.2.9 ソケットタイムアウトの注意事項
.......................................

ソケットオブジェクトは、ブロッキングモード、非ブロッキングモード、タイム
アウトモードのうち、いずれか1つのモードをとります。デフォルトでは、ソケ
ットは常にブロッキングモードで作成されますが、 *note
setdefaulttimeout(): 32b1. で標準のモードを変更することができます。

   * 'ブロッキングモード' での操作は、完了するか、または（接続がタイムア
     ウトするなどして）システムがエラーを返すまで、ブロックされます。

   * '非ブロッキングモード' での操作は、ただちに完了できない場合、例外を
     送出して失敗します。この場合の例外の種類は、システムに依存するため
     、ここに記すことができません。 *note select: af. モジュールの関数を
     使って、ソケットの読み書きが利用可能かどうか、可能な場合はいつ利用
     できるかを調べることができます。

   * 'タイムアウトモード' での操作は、指定されたタイムアウトの時間内に完
     了しなければ、 *note timeout: 7ff. 例外を送出します。タイムアウトの
     時間内にシステムがエラーを返した場合は、そのエラーを返します。

     注釈: At the operating system level, sockets in 'timeout mode' are
     internally set in non-blocking mode.  Also, the blocking and
     timeout modes are shared between file descriptors and socket
     objects that refer to the same network endpoint.  This
     implementation detail can have visible consequences if e.g.  you
     decide to use the *note fileno(): 32ee. of a socket.

* Menu:

* タイムアウトと connect メソッド::
* タイムアウトと accept メソッド::


File: python.info,  Node: タイムアウトと connect メソッド,  Next: タイムアウトと accept メソッド,  Up: ソケットタイムアウトの注意事項

5.18.2.10 タイムアウトと ‘connect’ メソッド
...........................................

*note connect(): d70. もタイムアウト設定に従います。一般的に、 *note
settimeout(): 32ad. を *note connect(): d70. の前に呼ぶか、 *note
create_connection(): 63e. にタイムアウト引数を渡すことが推奨されます。た
だし、システムのネットワークスタックが Python のソケットタイムアウトの設
定を無視して、自身の接続タイムアウトエラーを返すこともあります。


File: python.info,  Node: タイムアウトと accept メソッド,  Prev: タイムアウトと connect メソッド,  Up: ソケットタイムアウトの注意事項

5.18.2.11 タイムアウトと ‘accept’ メソッド
..........................................

*note getdefaulttimeout(): 32e2. が *note None: 641. でない場合、 *note
accept(): d6f. メソッドが返すソケットでは、そのタイムアウトが継承されま
す。 *note None: 641. である場合、待機中のソケットの設定によって動作は異
なります。

   * 待機中のソケットが 'ブロッキングモード' または 'タイムアウトモード'
     である場合、*note accept(): d6f. が返すソケットは、'ブロッキングモ
     ード' になります。

   * 待機中のソケットが '非ブロッキングモード' である場合、*note
     accept(): d6f. が返すソケットは、オペレーティングシステムによってブ
     ロッキングモードまたは非ブロッキングモードになります。クロスプラッ
     トフォームの動作を確保したい場合、この設定を手動でオーバーライドす
     ることをお勧めします。


File: python.info,  Node: 使用例<26>,  Prev: ソケットタイムアウトの注意事項,  Up: socket --- 低水準ネットワークインターフェース

5.18.2.12 使用例
................

Here are four minimal example programs using the TCP/IP protocol: a
server that echoes all data that it receives back (servicing only one
client), and a client using it.  Note that a server must perform the
sequence *note socket(): d6e, *note bind(): 1093, *note listen(): e27,
*note accept(): d6f. (possibly repeating the *note accept(): d6f. to
service more than one client), while a client only needs the sequence
*note socket(): d6e, *note connect(): d70.  Also note that the server
does not *note sendall(): d75./*note recv(): d71. on the socket it is
listening on but on the new socket returned by *note accept(): d6f.

次のクライアントとサーバは、IPv4 のみをサポートしています。

     # Echo server program
     import socket

     HOST = ''                 # Symbolic name meaning all available interfaces
     PORT = 50007              # Arbitrary non-privileged port
     with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
         s.bind((HOST, PORT))
         s.listen(1)
         conn, addr = s.accept()
         with conn:
             print('Connected by', addr)
             while True:
                 data = conn.recv(1024)
                 if not data: break
                 conn.sendall(data)

     # Echo client program
     import socket

     HOST = 'daring.cwi.nl'    # The remote host
     PORT = 50007              # The same port as used by the server
     with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
         s.connect((HOST, PORT))
         s.sendall(b'Hello, world')
         data = s.recv(1024)
     print('Received', repr(data))

The next two examples are identical to the above two, but support both
IPv4 and IPv6.  The server side will listen to the first address family
available (it should listen to both instead).  On most of IPv6-ready
systems, IPv6 will take precedence and the server may not accept IPv4
traffic.  The client side will try to connect to all the addresses
returned as a result of the name resolution, and sends traffic to the
first one connected successfully.

     # Echo server program
     import socket
     import sys

     HOST = None               # Symbolic name meaning all available interfaces
     PORT = 50007              # Arbitrary non-privileged port
     s = None
     for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC,
                                   socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
         af, socktype, proto, canonname, sa = res
         try:
             s = socket.socket(af, socktype, proto)
         except OSError as msg:
             s = None
             continue
         try:
             s.bind(sa)
             s.listen(1)
         except OSError as msg:
             s.close()
             s = None
             continue
         break
     if s is None:
         print('could not open socket')
         sys.exit(1)
     conn, addr = s.accept()
     with conn:
         print('Connected by', addr)
         while True:
             data = conn.recv(1024)
             if not data: break
             conn.send(data)

     # Echo client program
     import socket
     import sys

     HOST = 'daring.cwi.nl'    # The remote host
     PORT = 50007              # The same port as used by the server
     s = None
     for res in socket.getaddrinfo(HOST, PORT, socket.AF_UNSPEC, socket.SOCK_STREAM):
         af, socktype, proto, canonname, sa = res
         try:
             s = socket.socket(af, socktype, proto)
         except OSError as msg:
             s = None
             continue
         try:
             s.connect(sa)
         except OSError as msg:
             s.close()
             s = None
             continue
         break
     if s is None:
         print('could not open socket')
         sys.exit(1)
     with s:
         s.sendall(b'Hello, world')
         data = s.recv(1024)
     print('Received', repr(data))

次の例は、Windowsで raw socket を利用して非常にシンプルなネットワークス
ニファーを書きます。このサンプルを実行するには、インターフェースを操作す
るための管理者権限が必要です:

     import socket

     # the public network interface
     HOST = socket.gethostbyname(socket.gethostname())

     # create a raw socket and bind it to the public interface
     s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
     s.bind((HOST, 0))

     # Include IP headers
     s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)

     # receive all packets
     s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON)

     # receive a packet
     print(s.recvfrom(65565))

     # disabled promiscuous mode
     s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF)

次の例では、ソケットインターフェースを使用してローソケットプロトコルを使
用する CAN ネットワークと通信する方法を説明します。ブロードキャストマネ
ージャプロトコロルで CAN を使用するには、以下でソケットを開きます。

     socket.socket(socket.AF_CAN, socket.SOCK_DGRAM, socket.CAN_BCM)

ソケットの束縛 (‘CAN_RAW’) または (*note CAN_BCM: f6f.) 接続を行ったあと
、ソケットオブジェクトで *note socket.send(): d74. と *note
socket.recv(): d71. 操作 (とそのカウンターパート) を通常通りに使用するこ
とができます。

最後の例では、特権が必要になるかもしれません:

     import socket
     import struct


     # CAN frame packing/unpacking (see 'struct can_frame' in <linux/can.h>)

     can_frame_fmt = "=IB3x8s"
     can_frame_size = struct.calcsize(can_frame_fmt)

     def build_can_frame(can_id, data):
         can_dlc = len(data)
         data = data.ljust(8, b'\x00')
         return struct.pack(can_frame_fmt, can_id, can_dlc, data)

     def dissect_can_frame(frame):
         can_id, can_dlc, data = struct.unpack(can_frame_fmt, frame)
         return (can_id, can_dlc, data[:can_dlc])


     # create a raw socket and bind it to the 'vcan0' interface
     s = socket.socket(socket.AF_CAN, socket.SOCK_RAW, socket.CAN_RAW)
     s.bind(('vcan0',))

     while True:
         cf, addr = s.recvfrom(can_frame_size)

         print('Received: can_id=%x, can_dlc=%x, data=%s' % dissect_can_frame(cf))

         try:
             s.send(cf)
         except OSError:
             print('Error sending CAN frame')

         try:
             s.send(build_can_frame(0x01, b'\x01\x02\x03'))
         except OSError:
             print('Error sending CAN frame')

この例を、ほとんど間を空けずに複数回実行すると、以下のエラーが発生する場
合があります:

     OSError: [Errno 98] Address already in use

これは以前の実行がソケットを ‘TIME_WAIT’ 状態のままにし、すぐには再利用
できないことで起こります。

There is a *note socket: b8. flag to set, in order to prevent this,
‘socket.SO_REUSEADDR’:

     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     s.bind((HOST, PORT))

‘SO_REUSEADDR’ フラグは、 ‘TIME_WAIT’ 状態にあるローカルソケットをそのタ
イムアウト期限が自然に切れるのを待つことなく再利用することをカーネルに伝
えます。

参考
....

C 言語によるソケットプログラミングの基礎については、以下の資料を参照して
ください。

   - 'An Introductory 4.3BSD Interprocess Communication Tutorial', by
     Stuart Sechrest

   - 'An Advanced 4.3BSD Interprocess Communication Tutorial', by Samuel
     J. Leffler et al,

両書とも UNIX Programmer's Manual, Supplementary Documents 1 (PS1:7章
PS1:8章)。ソケットの詳細については、各プラットフォームのソケット関連シス
テムコールに関するドキュメントも参照してください。Unix ではマニュアルペ
ージ、WindowsではWinSock (または WinSock2) 仕様書をご覧ください。IPv6 対
応の API については、 RFC 3493(1) "Basic Socket Interface Extensions for
IPv6" を参照してください。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3493.html


File: python.info,  Node: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー,  Next: select --- I/O 完了の待機,  Prev: socket --- 低水準ネットワークインターフェース,  Up: ネットワーク通信とプロセス間通信

5.18.3 ‘ssl’ -- ソケットオブジェクト用の TLS/SSL ラッパー
---------------------------------------------------------

'Source code:' Lib/ssl.py(1)

__________________________________________________________________

このモジュールは Transport Layer Security ( "Secure Sockets Layer" とい
う名前でよく知られています) 暗号化と、クライアントサイド、サーバサイド両
方のネットワークソケットのためのピア認証の仕組みを提供しています。このモ
ジュールは OpenSSL ライブラリを利用しています。 OpenSSL は、すべてのモダ
ンな Unix システム、 Windows 、 macOS 、その他幾つかの OpenSSL がインス
トールされているプラットフォームで利用できます。

     注釈: Some behavior may be platform dependent, since calls are made
     to the operating system socket APIs.  The installed version of
     OpenSSL may also cause variations in behavior.  For example,
     TLSv1.3 comes with OpenSSL version 1.1.1.

     警告: *note セキュリティで考慮すべき点: 31f1. を読まずにこのモジュ
     ールを使用しないでください。SSL のデフォルト設定はアプリケーション
     に十分ではないので、読まない場合はセキュリティに誤った意識を持って
     しまうかもしれません。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

このセクションでは、 ‘ssl’ モジュールのオブジェクトと関数を解説します。
TLS, SSL, 証明書に関するより一般的な情報は、末尾にある "See Also" のセク
ションを参照してください。

This module provides a class, *note ssl.SSLSocket: 8b8, which is derived
from the *note socket.socket: d6e. type, and provides a socket-like
wrapper that also encrypts and decrypts the data going over the socket
with SSL. It supports additional methods such as ‘getpeercert()’, which
retrieves the certificate of the other side of the connection,
‘cipher()’, which retrieves the cipher being used for the secure
connection or ‘get_verified_chain()’, ‘get_unverified_chain()’ which
retrieves certificate chain.

より洗練されたアプリケーションのために、 *note ssl.SSLContext: 274. クラ
スが設定と証明書の管理の助けとなるでしょう。それは *note
SSLContext.wrap_socket(): 4ee. メソッドを通して SSL ソケットを作成するこ
とで引き継がれます。

バージョン 3.5.3 で変更: Updated to support linking with OpenSSL 1.1.0

バージョン 3.6 で変更: OpenSSL 0.9.8, 1.0.0, 1.0.1 は廃止されており、も
はやサポートされていません。ssl モジュールは、将来的に OpenSSL 1.0.2 ま
たは 1.1.0 を必要とするようになります。

バージョン 3.10 で変更: PEP 644(2) has been implemented.  The ssl module
requires OpenSSL 1.1.1 or newer.

Use of deprecated constants and functions result in deprecation
warnings.

* Menu:

* 関数、定数、例外::
* SSL ソケット::
* SSL コンテキスト::
* 証明書::
* 使用例: 使用例<27>.
* ノンブロッキングソケットについての注意事項::
* メモリ BIO サポート: メモリ BIO サポート<2>.
* SSL セッション::
* セキュリティで考慮すべき点: セキュリティで考慮すべき点<3>.
* TLS 1.3: TLS 1 3.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/ssl.py

   (2) https://peps.python.org/pep-0644/


File: python.info,  Node: 関数、定数、例外,  Next: SSL ソケット,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.1 関数、定数、例外
.........................

* Menu:

* ソケットの作成: ソケットの作成<2>.
* コンテキストの作成::
* 例外: 例外<15>.
* 乱数生成::
* 証明書の取り扱い::
* 定数: 定数<9>.


File: python.info,  Node: ソケットの作成<2>,  Next: コンテキストの作成,  Up: 関数、定数、例外

5.18.3.2 ソケットの作成
.......................

Instances of *note SSLSocket: 8b8. must be created using the *note
SSLContext.wrap_socket(): 4ee. method.  The helper function *note
create_default_context(): 13b. returns a new context with secure default
settings.

Client socket example with default context and IPv4/IPv6 dual stack:

     import socket
     import ssl

     hostname = 'www.python.org'
     context = ssl.create_default_context()

     with socket.create_connection((hostname, 443)) as sock:
         with context.wrap_socket(sock, server_hostname=hostname) as ssock:
             print(ssock.version())

Client socket example with custom context and IPv4:

     hostname = 'www.python.org'
     # PROTOCOL_TLS_CLIENT requires valid cert chain and hostname
     context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
     context.load_verify_locations('path/to/cabundle.pem')

     with socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) as sock:
         with context.wrap_socket(sock, server_hostname=hostname) as ssock:
             print(ssock.version())

Server socket example listening on localhost IPv4:

     context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
     context.load_cert_chain('/path/to/certchain.pem', '/path/to/private.key')

     with socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0) as sock:
         sock.bind(('127.0.0.1', 8443))
         sock.listen(5)
         with context.wrap_socket(sock, server_side=True) as ssock:
             conn, addr = ssock.accept()
             ...


File: python.info,  Node: コンテキストの作成,  Next: 例外<15>,  Prev: ソケットの作成<2>,  Up: 関数、定数、例外

5.18.3.3 コンテキストの作成
...........................

コンビニエンス関数が、共通の目的で使用される *note SSLContext: 274. オブ
ジェクトを作成するのに役立ちます。

 -- の関数: ssl.create_default_context (purpose=Purpose.SERVER_AUTH,
          cafile=None, capath=None, cadata=None)

     新規の *note SSLContext: 274. オブジェクトを、与えられた 'purpose'
     のデフォルト設定で返します。設定は *note ssl: bb. モジュールで選択
     され、通常は *note SSLContext: 274. のコンストラクタを直接呼び出す
     よりも高いセキュリティレベルを表現します。

     'cafile', 'capath', 'cadata' は証明書の検証で信用するオプションの
     CA 証明書で、 *note SSLContext.load_verify_locations(): eb6. のもの
     と同じです。これら 3 つすべてが *note None: 641. であれば、この関数
     は代わりにシステムのデフォルトの CA 証明書を信用して選択することが
     できます。

     The settings are: *note PROTOCOL_TLS_CLIENT: 83e. or *note
     PROTOCOL_TLS_SERVER: 83f, *note OP_NO_SSLv2: 804, and *note
     OP_NO_SSLv3: 805. with high encryption cipher suites without RC4
     and without unauthenticated cipher suites.  Passing *note
     SERVER_AUTH: f7f. as 'purpose' sets *note verify_mode: 32ff. to
     *note CERT_REQUIRED: 3300. and either loads CA certificates (when
     at least one of 'cafile', 'capath' or 'cadata' is given) or uses
     *note SSLContext.load_default_certs(): f7e. to load default CA
     certificates.

     When *note keylog_filename: 3301. is supported and the environment
     variable ‘SSLKEYLOGFILE’ is set, *note create_default_context():
     13b. enables key logging.

     The default settings for this context include *note
     VERIFY_X509_PARTIAL_CHAIN: 13c. and *note VERIFY_X509_STRICT: 13d.
     These make the underlying OpenSSL implementation behave more like a
     conforming implementation of RFC 5280(1), in exchange for a small
     amount of incompatibility with older X.509 certificates.

          注釈: プロトコル、オプション、暗号方式その他の設定は、事前に非
          推奨の状態にすることなく、もっと制限の強い値に変更される場合が
          あります。これらの値は、互換性と安全性との妥当なバランスをとっ
          て決められます。

          もしもあなたのアプリケーションが特定の設定を必要とする場合、
          *note SSLContext: 274. を作って自分自身で設定を適用すべきです
          。

          注釈: ある種の古いクライアントやサーバが接続しようと試みてきた
          場合に、この関数で作られた *note SSLContext: 274. が "Protocol
          or cipher suite mismatch" で始まるエラーを起こすのを目撃したら
          それは、この関数が *note OP_NO_SSLv3: 805. を使って除外してい
          る SSL 3.0 しかサポートしていないのでしょう。SSL 3.0 は 完璧に
          ぶっ壊れている(2) ことが広く知られています。それでもまだこの関
          数を使って、ただし SSL 3.0 接続を許可したいと望むならば、これ
          をこのように再有効化できます:

               ctx = ssl.create_default_context(Purpose.CLIENT_AUTH)
               ctx.options &= ~ssl.OP_NO_SSLv3

          注釈: This context enables *note VERIFY_X509_STRICT: 13d. by
          default, which may reject pre- RFC 5280(3) or malformed
          certificates that the underlying OpenSSL implementation
          otherwise would accept.  While disabling this is not
          recommended, you can do so using:

               ctx = ssl.create_default_context()
               ctx.verify_flags &= ~ssl.VERIFY_X509_STRICT

     Added in version 3.4.

     バージョン 3.4.4 で変更: デフォルトの暗号設定から RC4 が除かれまし
     た。

     バージョン 3.6 で変更: デフォルトの暗号化文字列に ChaCha20/Poly1305
     が追加されました。

     デフォルトの暗号化文字列から 3DES が除かれました。

     バージョン 3.8 で変更: Support for key logging to ‘SSLKEYLOGFILE’
     was added.

     バージョン 3.10 で変更: The context now uses *note
     PROTOCOL_TLS_CLIENT: 83e. or *note PROTOCOL_TLS_SERVER: 83f.
     protocol instead of generic *note PROTOCOL_TLS: 3302.

     バージョン 3.13 で変更: The context now uses *note
     VERIFY_X509_PARTIAL_CHAIN: 13c. and *note VERIFY_X509_STRICT: 13d.
     in its default verify flags.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5280.html

   (2) https://en.wikipedia.org/wiki/POODLE

   (3) https://datatracker.ietf.org/doc/html/rfc5280.html


File: python.info,  Node: 例外<15>,  Next: 乱数生成,  Prev: コンテキストの作成,  Up: 関数、定数、例外

5.18.3.4 例外
.............

 -- 例外: ssl.SSLError

     (現在のところ OpenSSL ライブラリによって提供されている)下層の SSL 実
     装からのエラーを伝えるための例外です。このエラーは、低レベルなネッ
     トワークの上に載っている、高レベルな暗号化と認証レイヤーでの問題を
     通知します。このエラーは *note OSError: 3f0. のサブタイプです。
     *note SSLError: 124b. インスタンスのエラーコードとメッセージは
     OpenSSL ライブラリによるものです。

     バージョン 3.3 で変更: *note SSLError: 124b. は以前は *note
     socket.error: 1029. のサブタイプでした。

      -- の属性: library

          エラーが起こった OpenSSL サブモジュールを示すニーモニック文字
          列で、 ‘SSL’, ‘PEM’, ‘X509’ などです。取り得る値は OpenSSL の
          バージョンに依存します。

          Added in version 3.3.

      -- の属性: reason

          エラーが起こった原因を示すニーモニック文字列で、
          ‘CERTIFICATE_VERIFY_FAILED’ などです。取り得る値は OpenSSL の
          バージョンに依存します。

          Added in version 3.3.

 -- 例外: ssl.SSLZeroReturnError

     読み出しあるいは書き込みを試みようとした際に SSL コネクションが行儀
     よく閉じられてしまった場合に送出される *note SSLError: 124b. サブク
     ラス例外です。これは下層の転送(read TCP)が閉じたことは意味しないこ
     とに注意してください。

     Added in version 3.3.

 -- 例外: ssl.SSLWantReadError

     読み出しあるいは書き込みを試みようとした際に、リクエストが遂行され
     る前に下層の TCP 転送で受け取る必要があるデータが不足した場合に
     *note non-blocking SSL socket: 3305. によって送出される *note
     SSLError: 124b. サブクラス例外です。

     Added in version 3.3.

 -- 例外: ssl.SSLWantWriteError

     読み出しあるいは書き込みを試みようとした際に、リクエストが遂行され
     る前に下層の TCP 転送が送信する必要があるデータが不足した場合に
     *note non-blocking SSL socket: 3305. によって送出される *note
     SSLError: 124b. サブクラス例外です。

     Added in version 3.3.

 -- 例外: ssl.SSLSyscallError

     SSL ソケット上で操作を遂行しようとしていてシステムエラーが起こった
     場合に送出される *note SSLError: 124b. サブクラス例外です。残念なが
     ら元となった errno 番号を調べる簡単な方法はありません。

     Added in version 3.3.

 -- 例外: ssl.SSLEOFError

     SSL コネクションが唐突に打ち切られた際に送出される *note SSLError:
     124b. サブクラス例外です。一般的に、このエラーが起こったら下層の転
     送を再利用しようと試みるべきではありません。

     Added in version 3.3.

 -- 例外: ssl.SSLCertVerificationError

     A subclass of *note SSLError: 124b. raised when certificate
     validation has failed.

     Added in version 3.7.

      -- の属性: verify_code

          A numeric error number that denotes the verification error.

      -- の属性: verify_message

          A human readable string of the verification error.

 -- 例外: ssl.CertificateError

     *note SSLCertVerificationError: b4a. の別名です。

     バージョン 3.7 で変更: 例外は *note SSLCertVerificationError: b4a.
     の別名になりました。


File: python.info,  Node: 乱数生成,  Next: 証明書の取り扱い,  Prev: 例外<15>,  Up: 関数、定数、例外

5.18.3.5 乱数生成
.................

 -- の関数: ssl.RAND_bytes (num)

     暗号学的に強固な擬似乱数の 'num' バイトを返します。擬似乱数生成器に
     十分なデータでシードが与えられていない場合や、現在の RANDOM メソッ
     ドに操作がサポートされていない場合は *note SSLError: 124b. を送出し
     ます。 *note RAND_status(): 1831. を使って擬似乱数生成器の状態をチ
     ェックできます。 *note RAND_add(): 330b. を使って擬似乱数生成器にシ
     ードを与えることができます。

     ほとんどすべてのアプリケーションでは *note os.urandom(): 4ec. が望
     ましいです。

     暗号論的に強い擬似乱数生成器に要求されることについては Wikipedia の
     記事 Cryptographically secure pseudorandom number generator
     (CSPRNG)(1) (日本語版: 暗号論的擬似乱数生成器(2)) を参照してくださ
     い。

     Added in version 3.3.

 -- の関数: ssl.RAND_status ()

     SSL 擬似乱数生成器が十分なランダム性(randomness)を受け取っている時
     に ‘True’ を、それ以外の場合は ‘False’ を返します。
     ‘ssl.RAND_egd()’ と *note ssl.RAND_add(): 330b. を使って擬似乱数生
     成機にランダム性を加えることができます。

 -- の関数: ssl.RAND_add (bytes, entropy)

     Mix the given 'bytes' into the SSL pseudo-random number generator.
     The parameter 'entropy' (a float) is a lower bound on the entropy
     contained in string (so you can always use ‘0.0’).  See RFC 1750(3)
     for more information on sources of entropy.

     バージョン 3.5 で変更: 書き込み可能な *note bytes-like object: cfb.
     を使用できるようになりました。

   ---------- Footnotes ----------

   (1) 
https://en.wikipedia.org/wiki/Cryptographically_secure_pseudorandom_number_generator

   (2) 
http://ja.wikipedia.org/wiki/%E6%9A%97%E5%8F%B7%E8%AB%96%E7%9A%84%E6%93%AC%E4%BC%BC%E4%B9%B1%E6%95%B0%E7%94%9F%E6%88%90%E5%99%A8

   (3) https://datatracker.ietf.org/doc/html/rfc1750.html


File: python.info,  Node: 証明書の取り扱い,  Next: 定数<9>,  Prev: 乱数生成,  Up: 関数、定数、例外

5.18.3.6 証明書の取り扱い
.........................

 -- の関数: ssl.cert_time_to_seconds (cert_time)

     ‘cert_time’ として証明書内の "notBefore" や "notAfter" の ‘"%b %d
     %H:%M:%S %Y %Z"’ strptime フォーマット (C locale) 日付を渡すと、エ
     ポックからの積算秒を返します。

     例です。 :

          >>> import ssl
          >>> timestamp = ssl.cert_time_to_seconds("Jan  5 09:34:43 2018 GMT")
          >>> timestamp
          1515144883
          >>> from datetime import datetime
          >>> print(datetime.utcfromtimestamp(timestamp))
          2018-01-05 09:34:43

     "notBefore" や "notAfter" の日付には GMT を使わなければなりません(
     RFC 5280(1))。

     バージョン 3.5 で変更: 入力文字列に指定された 'GMT' タイムゾーンを
     UTC として解釈するようになりました。以前はローカルタイムで解釈して
     いました。また、整数を返すようになりました(入力に含まれる秒の端数を
     含まない)。

 -- の関数: ssl.get_server_certificate (addr,
          ssl_version=PROTOCOL_TLS_CLIENT, ca_certs=None[, timeout])

     Given the address ‘addr’ of an SSL-protected server, as a
     ('hostname', 'port-number') pair, fetches the server's certificate,
     and returns it as a PEM-encoded string.  If ‘ssl_version’ is
     specified, uses that version of the SSL protocol to attempt to
     connect to the server.  If 'ca_certs' is specified, it should be a
     file containing a list of root certificates, the same format as
     used for the 'cafile' parameter in *note
     SSLContext.load_verify_locations(): eb6.  The call will attempt to
     validate the server certificate against that set of root
     certificates, and will fail if the validation attempt fails.  A
     timeout can be specified with the ‘timeout’ parameter.

     バージョン 3.3 で変更: この関数はIPv6互換になりました。

     バージョン 3.5 で変更: 'ssl_version' のデフォルトが、最近のサーバへ
     の最大限の互換性のために *note PROTOCOL_SSLv3: 330d. から *note
     PROTOCOL_TLS: 3302. に変更されました。

     バージョン 3.10 で変更: 'timeout' 引数が追加されました。

 -- の関数: ssl.DER_cert_to_PEM_cert (DER_cert_bytes)

     DERエンコードされたバイト列として与えられた証明書から、 PEMエンコー
     ドされたバージョンの同じ証明書を返します。

 -- の関数: ssl.PEM_cert_to_DER_cert (PEM_cert_string)

     PEM 形式のASCII文字列として与えられた証明書から、同じ証明書をDERエ
     ンコードしたバイト列を返します。

 -- の関数: ssl.get_default_verify_paths ()

     OpenSSL デフォルトの cafile, capath を指すパスを名前付きタプルで返
     します。パスは *note SSLContext.set_default_verify_paths(): f77. で
     使われるものと同じです。戻り値は *note named tuple: 61a.
     ‘DefaultVerifyPaths’ です:

        * ‘cafile’ - cafile の解決済みパス、またはファイルが存在しない場
          合は ‘None’

        * ‘capath’ - capath の解決済みパス、またはディレクトリが存在しな
          い場合は ‘None’

        * ‘openssl_cafile_env’ - cafile を指す OpenSSL の環境変数

        * ‘openssl_cafile’ - OpenSSL にハードコードされた cafile のパス

        * ‘openssl_capath_env’ - capath を指す OpenSSL の環境変数

        * ‘openssl_capath’ - OpenSSL にハードコードされた capath のパス

     Added in version 3.4.

 -- の関数: ssl.enum_certificates (store_name)

     Windows のシステム証明書ストアより証明書を抽出します。 'store_name'
     は ‘CA’, ‘ROOT’, ‘MY’ のうちどれか一つでしょう。Windows は追加の証
     明書ストアを提供しているかもしれません。

     この関数はタプル (cert_bytes, encoding_type, trust) のリストで返し
     ます。encoding_type は cert_bytes のエンコーディングを表します。
     X.509 ASN.1 に対する ‘x509_asn’ か PKCS#7 ASN.1 データに対する
     ‘pkcs_7_asn’ のいずれかです。trust は、証明書の目的を、OIDS を内容
     に持つ set として表すか、または証明書がすべての目的で信頼できるなら
     ば ‘True’ です。

     以下はプログラム例です:

          >>> ssl.enum_certificates("CA")
          [(b'data...', 'x509_asn', {'1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2'}),
           (b'data...', 'x509_asn', True)]

     *note Availability: 1cbe.: Windows.

     Added in version 3.4.

 -- の関数: ssl.enum_crls (store_name)

     Windows のシステム証明書ストアより CRLs を抽出します。 'store_name'
     は ‘CA’, ‘ROOT’, ‘MY’ のうちどれか一つでしょう。Windows は追加の証
     明書ストアを提供しているかもしれません。

     この関数はタプル (cert_bytes, encoding_type, trust) のリストで返し
     ます。encoding_type は cert_bytes のエンコーディングを表します。
     X.509 ASN.1 に対する ‘x509_asn’ か PKCS#7 ASN.1 データに対する
     ‘pkcs_7_asn’ のいずれかです。

     *note Availability: 1cbe.: Windows.

     Added in version 3.4.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5280.html


File: python.info,  Node: 定数<9>,  Prev: 証明書の取り扱い,  Up: 関数、定数、例外

5.18.3.7 定数
.............

     すべての定数が *note enum.IntEnum: cad. コレクションまたは *note
     enum.IntFlag: 2255. コレクションになりました。

     Added in version 3.6.

 -- データ: ssl.CERT_NONE

     Possible value for *note SSLContext.verify_mode: 32ff.  Except for
     *note PROTOCOL_TLS_CLIENT: 83e, it is the default mode.  With
     client-side sockets, just about any cert is accepted.  Validation
     errors, such as untrusted or expired cert, are ignored and do not
     abort the TLS/SSL handshake.

     In server mode, no certificate is requested from the client, so the
     client does not send any for client cert authentication.

     このドキュメントの下の方の、 *note セキュリティで考慮すべき点:
     31f1. に関する議論を参照してください。

 -- データ: ssl.CERT_OPTIONAL

     Possible value for *note SSLContext.verify_mode: 32ff.  In client
     mode, *note CERT_OPTIONAL: 3312. has the same meaning as *note
     CERT_REQUIRED: 3300.  It is recommended to use *note CERT_REQUIRED:
     3300. for client-side sockets instead.

     In server mode, a client certificate request is sent to the client.
     The client may either ignore the request or send a certificate in
     order perform TLS client cert authentication.  If the client
     chooses to send a certificate, it is verified.  Any verification
     error immediately aborts the TLS handshake.

     Use of this setting requires a valid set of CA certificates to be
     passed to *note SSLContext.load_verify_locations(): eb6.

 -- データ: ssl.CERT_REQUIRED

     Possible value for *note SSLContext.verify_mode: 32ff.  In this
     mode, certificates are required from the other side of the socket
     connection; an *note SSLError: 124b. will be raised if no
     certificate is provided, or if its validation fails.  This mode is
     'not' sufficient to verify a certificate in client mode as it does
     not match hostnames.  *note check_hostname: 3313. must be enabled
     as well to verify the authenticity of a cert.  *note
     PROTOCOL_TLS_CLIENT: 83e. uses *note CERT_REQUIRED: 3300. and
     enables *note check_hostname: 3313. by default.

     With server socket, this mode provides mandatory TLS client cert
     authentication.  A client certificate request is sent to the client
     and the client must provide a valid and trusted certificate.

     Use of this setting requires a valid set of CA certificates to be
     passed to *note SSLContext.load_verify_locations(): eb6.

 -- クラス: ssl.VerifyMode

     CERT_* 定数の *note enum.IntEnum: cad. コレクションです。

     Added in version 3.6.

 -- データ: ssl.VERIFY_DEFAULT

     *note SSLContext.verify_flags: f7a. に渡せる値です。このモードでは
     、証明書失効リスト(CRLs)はチェックされません。デフォルトでは
     OpenSSL は CRLs を必要ともしませんし検証にも使いません。

     Added in version 3.4.

 -- データ: ssl.VERIFY_CRL_CHECK_LEAF

     *note SSLContext.verify_flags: f7a. に渡せる値です。このモードでは
     、接続先の証明書のみがチェックされ、仲介の CA 証明書はチェックされ
     ません。接続先証明書の発行者(その CA の直接の祖先)によって署名され
     た妥当な CRL が必要です。 *note SSLContext.load_verify_locations:
     eb6. で相応しい CRL をロードしていなければ、検証は失敗します。

     Added in version 3.4.

 -- データ: ssl.VERIFY_CRL_CHECK_CHAIN

     *note SSLContext.verify_flags: f7a. に渡せる値です。このモードでは
     、接続先の証明書チェイン内のすべての証明書についての CRLs がチェッ
     クされます。

     Added in version 3.4.

 -- データ: ssl.VERIFY_X509_STRICT

     *note SSLContext.verify_flags: f7a. に渡せる値で、壊れた X.509 証明
     書に対するワークアラウンドを無効にします。

     Added in version 3.4.

 -- データ: ssl.VERIFY_ALLOW_PROXY_CERTS

     Possible value for *note SSLContext.verify_flags: f7a. to enables
     proxy certificate verification.

     Added in version 3.10.

 -- データ: ssl.VERIFY_X509_TRUSTED_FIRST

     *note SSLContext.verify_flags: f7a. に渡せる値です。OpenSSL に対し
     、証明書検証のために信頼チェインを構築する際、信頼できる証明書を選
     ぶように指示します。これはデフォルトで有効にされています。

     Added in version 3.4.4.

 -- データ: ssl.VERIFY_X509_PARTIAL_CHAIN

     Possible value for *note SSLContext.verify_flags: f7a.  It
     instructs OpenSSL to accept intermediate CAs in the trust store to
     be treated as trust-anchors, in the same way as the self-signed
     root CA certificates.  This makes it possible to trust certificates
     issued by an intermediate CA without having to trust its ancestor
     root CA.

     Added in version 3.10.

 -- クラス: ssl.VerifyFlags

     VERIFY_* 定数の *note enum.IntFlag: 2255. コレクションです。

     Added in version 3.6.

 -- データ: ssl.PROTOCOL_TLS

     クライアントとサーバの両方がサポートするプロトコルバージョンのうち
     、最も大きなものを選択します。名前に反して、このオプションは "SSL"
     と "TLS" プロトコルのいずれも選択できます。

     Added in version 3.6.

     バージョン 3.10 で非推奨: TLS clients and servers require different
     default settings for secure communication.  The generic TLS
     protocol constant is deprecated in favor of *note
     PROTOCOL_TLS_CLIENT: 83e. and *note PROTOCOL_TLS_SERVER: 83f.

 -- データ: ssl.PROTOCOL_TLS_CLIENT

     Auto-negotiate the highest protocol version that both the client
     and server support, and configure the context client-side
     connections.  The protocol enables *note CERT_REQUIRED: 3300. and
     *note check_hostname: 3313. by default.

     Added in version 3.6.

 -- データ: ssl.PROTOCOL_TLS_SERVER

     Auto-negotiate the highest protocol version that both the client
     and server support, and configure the context server-side
     connections.

     Added in version 3.6.

 -- データ: ssl.PROTOCOL_SSLv23

     *note PROTOCOL_TLS: 3302. のエイリアスです。

     バージョン 3.6 で非推奨: 代わりに *note PROTOCOL_TLS: 3302. を使用
     してください。

 -- データ: ssl.PROTOCOL_SSLv3

     チャンネル暗号化プロトコルとしてSSLバージョン3を選択します。

     このプロトコルは、 OpenSSL が ‘no-ssl3’ オプションをつけてコンパイ
     ルされている場合には利用できません。

          警告: SSL version 3 は非セキュアです。このプロトコルは強く非推
          奨です。

     バージョン 3.6 で非推奨: OpenSSL has deprecated all version
     specific protocols.  Use the default protocol *note
     PROTOCOL_TLS_SERVER: 83f. or *note PROTOCOL_TLS_CLIENT: 83e. with
     *note SSLContext.minimum_version: 83c. and *note
     SSLContext.maximum_version: 83d. instead.

 -- データ: ssl.PROTOCOL_TLSv1

     チャンネル暗号化プロトコルとしてTLSバージョン1.0を選択します。

     バージョン 3.6 で非推奨: OpenSSL has deprecated all version
     specific protocols.

 -- データ: ssl.PROTOCOL_TLSv1_1

     チャンネル暗号化プロトコルとしてTLSバージョン1.1を選択します。
     openssl version 1.0.1+ のみで利用可能です。

     Added in version 3.4.

     バージョン 3.6 で非推奨: OpenSSL has deprecated all version
     specific protocols.

 -- データ: ssl.PROTOCOL_TLSv1_2

     チャンネル暗号化プロトコルとしてTLSバージョン 1.2 を選択します。
     openssl version 1.0.1+ のみで利用可能です。

     Added in version 3.4.

     バージョン 3.6 で非推奨: OpenSSL has deprecated all version
     specific protocols.

 -- データ: ssl.OP_ALL

     相手にする SSL 実装のさまざまなバグを回避するためのワークアラウンド
     を有効にします。このオプションはデフォルトで有効です。これを有効に
     する場合 OpenSSL 用の同じ意味のフラグ ‘SSL_OP_ALL’ をセットする必要
     はありません。

     Added in version 3.2.

 -- データ: ssl.OP_NO_SSLv2

     SSLv2 接続が行われないようにします。このオプションは *note
     PROTOCOL_TLS: 3302. と組み合わされている場合にのみ適用されます。ピ
     アがプロトコルバージョンとして SSLv2 を選択しないようにします。

     Added in version 3.2.

     バージョン 3.6 で非推奨: SSLv2 は非推奨です

 -- データ: ssl.OP_NO_SSLv3

     SSLv3 接続が行われないようにします。このオプションは *note
     PROTOCOL_TLS: 3302. と組み合わされている場合にのみ適用されます。ピ
     アがプロトコルバージョンとして SSLv3 を選択しないようにします。

     Added in version 3.2.

     バージョン 3.6 で非推奨: SSLv3 は非推奨です

 -- データ: ssl.OP_NO_TLSv1

     TLSv1 接続が行われないようにします。このオプションは *note
     PROTOCOL_TLS: 3302. と組み合わされている場合にのみ適用されます。ピ
     アがプロトコルバージョンとして TLSv1 を選択しないようにします。

     Added in version 3.2.

     バージョン 3.7 で非推奨: The option is deprecated since OpenSSL
     1.1.0, use the new *note SSLContext.minimum_version: 83c. and *note
     SSLContext.maximum_version: 83d. instead.

 -- データ: ssl.OP_NO_TLSv1_1

     TLSv1.1 接続が行われないようにします。このオプションは *note
     PROTOCOL_TLS: 3302. と組み合わされている場合にのみ適用されます。ピ
     アがプロトコルバージョンとして TLSv1.1 を選択しないようにします。
     openssl バージョン 1.0.1 以降でのみ利用できます。

     Added in version 3.4.

     バージョン 3.7 で非推奨: The option is deprecated since OpenSSL
     1.1.0.

 -- データ: ssl.OP_NO_TLSv1_2

     TLSv1.2 接続が行われないようにします。このオプションは *note
     PROTOCOL_TLS: 3302. と組み合わされている場合にのみ適用されます。ピ
     アがプロトコルバージョンとして TLSv1.2 を選択しないようにします。
     openssl バージョン 1.0.1 以降でのみ利用できます。

     Added in version 3.4.

     バージョン 3.7 で非推奨: The option is deprecated since OpenSSL
     1.1.0.

 -- データ: ssl.OP_NO_TLSv1_3

     Prevents a TLSv1.3 connection.  This option is only applicable in
     conjunction with *note PROTOCOL_TLS: 3302.  It prevents the peers
     from choosing TLSv1.3 as the protocol version.  TLS 1.3 is
     available with OpenSSL 1.1.1 or later.  When Python has been
     compiled against an older version of OpenSSL, the flag defaults to
     '0'.

     Added in version 3.6.3.

     バージョン 3.7 で非推奨: The option is deprecated since OpenSSL
     1.1.0.  It was added to 2.7.15 and 3.6.3 for backwards
     compatibility with OpenSSL 1.0.2.

 -- データ: ssl.OP_NO_RENEGOTIATION

     Disable all renegotiation in TLSv1.2 and earlier.  Do not send
     HelloRequest messages, and ignore renegotiation requests via
     ClientHello.

     このオプションは OpenSSL 1.1.0h 以降のみで使用できます。

     Added in version 3.7.

 -- データ: ssl.OP_CIPHER_SERVER_PREFERENCE

     暗号の優先順位として、クライアントのものではなくサーバのものを使い
     ます。このオプションはクライアントソケットと SSLv2 のサーバソケット
     では効果はありません。

     Added in version 3.3.

 -- データ: ssl.OP_SINGLE_DH_USE

     Prevents reuse of the same DH key for distinct SSL sessions.  This
     improves forward secrecy but requires more computational resources.
     This option only applies to server sockets.

     Added in version 3.3.

 -- データ: ssl.OP_SINGLE_ECDH_USE

     Prevents reuse of the same ECDH key for distinct SSL sessions.
     This improves forward secrecy but requires more computational
     resources.  This option only applies to server sockets.

     Added in version 3.3.

 -- データ: ssl.OP_ENABLE_MIDDLEBOX_COMPAT

     Send dummy Change Cipher Spec (CCS) messages in TLS 1.3 handshake
     to make a TLS 1.3 connection look more like a TLS 1.2 connection.

     このオプションは OpenSSL 1.1.1 以降のみで使用できます。

     Added in version 3.8.

 -- データ: ssl.OP_NO_COMPRESSION

     SSL チャネルでの圧縮を無効にします。これはアプリケーションのプロト
     コルが自身の圧縮方法をサポートする場合に有用です。

     Added in version 3.3.

 -- クラス: ssl.Options

     OP_* 定数の *note enum.IntFlag: 2255. コレクションです。

 -- データ: ssl.OP_NO_TICKET

     クライアントサイドがセッションチケットをリクエストしないようにしま
     す。

     Added in version 3.6.

 -- データ: ssl.OP_IGNORE_UNEXPECTED_EOF

     Ignore unexpected shutdown of TLS connections.

     このオプションは OpenSSL 3.0.0以降のみで使用できます。

     Added in version 3.10.

 -- データ: ssl.OP_ENABLE_KTLS

     Enable the use of the kernel TLS. To benefit from the feature,
     OpenSSL must have been compiled with support for it, and the
     negotiated cipher suites and extensions must be supported by it (a
     list of supported ones may vary by platform and kernel version).

     Note that with enabled kernel TLS some cryptographic operations are
     performed by the kernel directly and not via any available OpenSSL
     Providers.  This might be undesirable if, for example, the
     application requires all cryptographic operations to be performed
     by the FIPS provider.

     このオプションは OpenSSL 3.0.0以降のみで使用できます。

     Added in version 3.12.

 -- データ: ssl.OP_LEGACY_SERVER_CONNECT

     Allow legacy insecure renegotiation between OpenSSL and unpatched
     servers only.

     Added in version 3.12.

 -- データ: ssl.HAS_ALPN

     OpenSSL ライブラリが、組み込みで RFC 7301(1) で記述されている
     'Application-Layer Protocol Negotiation' TLS 拡張をサポートしている
     かどうか。

     Added in version 3.5.

 -- データ: ssl.HAS_NEVER_CHECK_COMMON_NAME

     Whether the OpenSSL library has built-in support not checking
     subject common name and *note
     SSLContext.hostname_checks_common_name: b4b. is writeable.

     Added in version 3.7.

 -- データ: ssl.HAS_ECDH

     OpenSSL ライブラリが、組み込みの楕円曲線ディフィー・ヘルマン鍵共有
     をサポートしているかどうか。これは、ディストリビュータが明示的に無
     効にしていない限りは、真であるはずです。

     Added in version 3.3.

 -- データ: ssl.HAS_SNI

     OpenSSL ライブラリが、組み込みで ( RFC 6066(2) で記述されている)
     'Server Name Indication' 拡張をサポートしているかどうか。

     Added in version 3.2.

 -- データ: ssl.HAS_NPN

     OpenSSL ライブラリが、組み込みで、Application Layer Protocol
     Negotiation(3) で記述されている 'Next Protocol Negotiation' をサポ
     ートしているかどうか。 true であれば、サポートしたいプロトコルを
     *note SSLContext.set_npn_protocols(): 2d9. メソッドで提示することが
     できます。

     Added in version 3.3.

 -- データ: ssl.HAS_SSLv2

     OpenSSL ライブラリが、組み込みで SSL 2.0 プロトコルをサポートしてい
     るかどうか。

     Added in version 3.7.

 -- データ: ssl.HAS_SSLv3

     OpenSSL ライブラリが、組み込みで SSL 3.0 プロトコルをサポートしてい
     るかどうか。

     Added in version 3.7.

 -- データ: ssl.HAS_TLSv1

     OpenSSL ライブラリが、組み込みで TLS 1.0 プロトコルをサポートしてい
     るかどうか。

     Added in version 3.7.

 -- データ: ssl.HAS_TLSv1_1

     OpenSSL ライブラリが、組み込みで TLS 1.1 プロトコルをサポートしてい
     るかどうか。

     Added in version 3.7.

 -- データ: ssl.HAS_TLSv1_2

     OpenSSL ライブラリが、組み込みで TLS 1.2 プロトコルをサポートしてい
     るかどうか。

     Added in version 3.7.

 -- データ: ssl.HAS_TLSv1_3

     OpenSSL ライブラリが、組み込みで TLS 1.3 プロトコルをサポートしてい
     るかどうか。

     Added in version 3.7.

 -- データ: ssl.HAS_PSK

     Whether the OpenSSL library has built-in support for TLS-PSK.

     Added in version 3.13.

 -- データ: ssl.CHANNEL_BINDING_TYPES

     サポートされている TLS のチャネルバインディングのタイプのリスト。リ
     スト内の文字列は *note SSLSocket.get_channel_binding(): 1117. の引
     数に渡せます。

     Added in version 3.3.

 -- データ: ssl.OPENSSL_VERSION

     インタプリタによってロードされた OpenSSL ライブラリのバージョン文字
     列:

          >>> ssl.OPENSSL_VERSION
          'OpenSSL 1.0.2k  26 Jan 2017'

     Added in version 3.2.

 -- データ: ssl.OPENSSL_VERSION_INFO

     OpenSSL ライブラリのバージョン情報を表す5つの整数のタプル:

          >>> ssl.OPENSSL_VERSION_INFO
          (1, 0, 2, 11, 15)

     Added in version 3.2.

 -- データ: ssl.OPENSSL_VERSION_NUMBER

     1つの整数の形式の、 OpenSSL ライブラリの生のバージョン番号:

          >>> ssl.OPENSSL_VERSION_NUMBER
          268443839
          >>> hex(ssl.OPENSSL_VERSION_NUMBER)
          '0x100020bf'

     Added in version 3.2.

 -- データ: ssl.ALERT_DESCRIPTION_HANDSHAKE_FAILURE
 -- データ: ssl.ALERT_DESCRIPTION_INTERNAL_ERROR

 -- データ: ALERT_DESCRIPTION_*

     RFC 5246(4) その他からのアラートの種類です。 IANA TLS Alert
     Registry(5) にはこのリストとその意味が定義された RFC へのリファレン
     スが含まれています。

     *note SSLContext.set_servername_callback(): f83. でのコールバック関
     数の戻り値として使われます。

     Added in version 3.4.

 -- クラス: ssl.AlertDescription

     ALERT_DESCRIPTION_* 定数の *note enum.IntEnum: cad. コレクションで
     す。

     Added in version 3.6.

 -- データ: Purpose.SERVER_AUTH

     *note create_default_context(): 13b. と *note
     SSLContext.load_default_certs(): f7e. に渡すオプションです。この値
     はコンテキストが web サーバの認証に使われることを示します (ですので
     、クライアントサイドのソケットを作るのに使うことになるでしょう)。

     Added in version 3.4.

 -- データ: Purpose.CLIENT_AUTH

     *note create_default_context(): 13b. と *note
     SSLContext.load_default_certs(): f7e. に渡すオプションです。この値
     はコンテキストが web クライアントの認証に使われることを示します (で
     すので、サーバサイドのソケットを作るのに使うことになるでしょう)。

     Added in version 3.4.

 -- クラス: ssl.SSLErrorNumber

     SSL_ERROR_* 定数の *note enum.IntEnum: cad. コレクションです。

     Added in version 3.6.

 -- クラス: ssl.TLSVersion

     *note enum.IntEnum: cad. collection of SSL and TLS versions for
     *note SSLContext.maximum_version: 83d. and *note
     SSLContext.minimum_version: 83c.

     Added in version 3.7.

 -- の属性: TLSVersion.MINIMUM_SUPPORTED

 -- の属性: TLSVersion.MAXIMUM_SUPPORTED

     The minimum or maximum supported SSL or TLS version.  These are
     magic constants.  Their values don't reflect the lowest and highest
     available TLS/SSL versions.

 -- の属性: TLSVersion.SSLv3

 -- の属性: TLSVersion.TLSv1

 -- の属性: TLSVersion.TLSv1_1

 -- の属性: TLSVersion.TLSv1_2

 -- の属性: TLSVersion.TLSv1_3

     SSL 3.0 to TLS 1.3.

     バージョン 3.10 で非推奨: All *note TLSVersion: 3332. members
     except *note TLSVersion.TLSv1_2: 3338. and *note
     TLSVersion.TLSv1_3: 3339. are deprecated.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc7301.html

   (2) https://datatracker.ietf.org/doc/html/rfc6066.html

   (3) 
https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation

   (4) https://datatracker.ietf.org/doc/html/rfc5246.html

   (5) 
https://www.iana.org/assignments/tls-parameters/tls-parameters.xml#tls-parameters-6


File: python.info,  Node: SSL ソケット,  Next: SSL コンテキスト,  Prev: 関数、定数、例外,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.8 SSL ソケット
.....................

 -- クラス: ssl.SSLSocket (socket.socket)

     SSL ソケットは *note socket オブジェクト: 32e0. の以下のメソッドを
     提供します:

        - *note accept(): d6f.

        - *note bind(): 1093.

        - *note close(): d11.

        - *note connect(): d70.

        - *note detach(): 11ee.

        - *note fileno(): 32ee.

        - *note getpeername(): 3234, *note getsockname(): 3235.

        - *note getsockopt(): ca3, *note setsockopt(): ca4.

        - *note gettimeout(): 32ef, *note settimeout(): 32ad, *note
          setblocking(): 2a9b.

        - *note listen(): e27.

        - *note makefile(): 1170.

        - *note recv(): d71, *note recv_into(): 12ec. (but passing a
          non-zero ‘flags’ argument is not allowed)

        - *note send(): d74, *note sendall(): d75. (with the same
          limitation)

        - *note sendfile(): e26. (but *note os.sendfile: add. will be
          used for plain-text sockets only, else *note send(): d74. will
          be used)

        - *note shutdown(): 32dd.

     SSL(およびTLS)プロトコルは TCP の上に独自の枠組みを持っているので、
     SSLソケットの抽象化は、いくつかの点で通常の OSレベルのソケットの仕
     様から逸脱することがあります。特に *note
     ノンブロッキングソケットについての注釈: 3305. を参照してください。

     *note SSLSocket: 8b8. のインスタンスは *note
     SSLContext.wrap_socket(): 4ee. メソッドを使用して作成されなければな
     りません。

     バージョン 3.5 で変更: ‘sendfile()’ メソッドが追加されました。

     バージョン 3.5 で変更: ‘shutdown()’ は、バイトが送受信されるたびに
     ソケットのタイムアウトをリセットしません。ソケットのタイムアウトは
     、シャットダウンの最大合計時間になりました。

     バージョン 3.6 で非推奨: *note SSLSocket: 8b8. インスタンスを直接作
     成することは非推奨です。ソケットをラップするために *note
     SSLContext.wrap_socket(): 4ee. を使用してください。

     バージョン 3.7 で変更: *note SSLSocket: 8b8. instances must to
     created with *note wrap_socket(): 4ee.  In earlier versions, it was
     possible to create instances directly.  This was never documented
     or officially supported.

     バージョン 3.10 で変更: Python now uses ‘SSL_read_ex’ and
     ‘SSL_write_ex’ internally.  The functions support reading and
     writing of data larger than 2 GB. Writing zero-length data no
     longer fails with a protocol violation error.

SSL ソケットには、以下に示す追加のメソッドと属性もあります:

 -- メソッド: SSLSocket.read (len=1024, buffer=None)

     SSL ソケットからデータの 'len' バイトまでを読み出し、読み出した結果
     を ‘bytes’ インスタンスで返します。 'buffer' を指定すると、結果は代
     わりに buffer に読み込まれ、読み込んだバイト数を返します。

     ソケットが *note non-blocking: 3305. で読み出しがブロックすると、
     *note SSLWantReadError: e32. もしくは *note SSLWantWriteError: e33.
     が送出されます。

     再ネゴシエーションがいつでも可能なので、 *note read(): e37. の呼び
     出しは書き込み操作も引き起こしえます。

     バージョン 3.5 で変更: ソケットのタイムアウトは、バイトが送受信され
     るたびにリセットされなくなりました。ソケットのタイムアウトは、最大
     'len' バイトを読むのにかかる最大合計時間になりました。

     バージョン 3.6 で非推奨: *note read(): e37. の代わりに ‘recv()’ を
     使用してください。

 -- メソッド: SSLSocket.write (buf)

     'buf' を SSL ソケットに書き込み、書き込んだバイト数を返します。
     'buf' 引数はバッファインターフェイスをサポートするオブジェクトでな
     ければなりません。

     ソケットが *note non-blocking: 3305. で書き込みがブロックすると、
     *note SSLWantReadError: e32. もしくは *note SSLWantWriteError: e33.
     が送出されます。

     再ネゴシエーションがいつでも可能なので、 *note write(): e38. の呼び
     出しは読み出し操作も引き起こしえます。

     バージョン 3.5 で変更: ソケットのタイムアウトは、バイトが送受信され
     るたびにリセットされなくなりました。ソケットのタイムアウトは、'buf'
     を書き込むのにかかる最大合計時間になりました。

     バージョン 3.6 で非推奨: *note write(): e38. の代わりに ‘send()’ を
     使用してください。

     注釈: *note read(): e37, *note write(): e38. メソッドは下位レベルの
     メソッドであり、暗号化されていないアプリケーションレベルのデータを
     読み書きし、それを復号/暗号化して暗号化された書き込みレベルのデータ
     にします。これらのメソッドはアクティブな SSL 接続つまり、ハンドシェ
     イクが完了していて、 *note SSLSocket.unwrap(): 333b. が呼ばれていな
     いことを必要とします。

     通常はこれらのメソッドの代わりに *note recv(): d71. や *note
     send(): d74. のようなソケット API メソッドを使うべきです。

 -- メソッド: SSLSocket.do_handshake ()

     SSL セットアップのハンドシェイクを実行します。

     バージョン 3.4 で変更: ソケットの *note context: 333c. の属性 *note
     check_hostname: 3313. が真の場合に、ハンドシェイクメソッドが
     ‘match_hostname()’ を実行するようになりました。

     バージョン 3.5 で変更: ソケットのタイムアウトは、バイトが送受信され
     るたびにリセットされなくなりました。ソケットのタイムアウトは、ハン
     ドシェイクにかかる最大合計時間になりました。

     バージョン 3.7 で変更: Hostname or IP address is matched by OpenSSL
     during handshake.  The function ‘match_hostname()’ is no longer
     used.  In case OpenSSL refuses a hostname or IP address, the
     handshake is aborted early and a TLS alert message is sent to the
     peer.

 -- メソッド: SSLSocket.getpeercert (binary_form=False)

     接続先に証明書が無い場合、 ‘None’ を返します。SSL ハンドシェイクが
     まだ行われていない場合は、 *note ValueError: 1e3. が送出されます。

     ‘binary_form’ が *note False: b05. で接続先から証明書を取得した場合
     、このメソッドは *note dict: 237. のインスタンスを返します。証明書
     が認証されていない場合、辞書は空です。証明書が認証されていた場合い
     くつかのキーを持った辞書を返し、 ‘subject’ (証明書が発行された
     principal), ‘issuer’ (証明書を発行した principal) を含みます。証明
     書が 'Subject Alternative Name' 拡張( RFC 3280(1) を参照)のインスタ
     ンスを格納していた場合、 ‘subjectAltName’ キーも辞書に含まれます。

     ‘subject’, ‘issuer’ フィールドは、証明書のそれぞれのフィールドにつ
     いてのデータ構造で与えられる RDN (relative distinguishued name) の
     シーケンスを格納したタプルで、各 RDN は name-value ペアのシーケンス
     です。現実世界での例をお見せします:

          {'issuer': ((('countryName', 'IL'),),
                      (('organizationName', 'StartCom Ltd.'),),
                      (('organizationalUnitName',
                        'Secure Digital Certificate Signing'),),
                      (('commonName',
                        'StartCom Class 2 Primary Intermediate Server CA'),)),
           'notAfter': 'Nov 22 08:15:19 2013 GMT',
           'notBefore': 'Nov 21 03:09:52 2011 GMT',
           'serialNumber': '95F0',
           'subject': ((('description', '571208-SLe257oHY9fVQ07Z'),),
                       (('countryName', 'US'),),
                       (('stateOrProvinceName', 'California'),),
                       (('localityName', 'San Francisco'),),
                       (('organizationName', 'Electronic Frontier Foundation, Inc.'),),
                       (('commonName', '*.eff.org'),),
                       (('emailAddress', 'hostmaster@eff.org'),)),
           'subjectAltName': (('DNS', '*.eff.org'), ('DNS', 'eff.org')),
           'version': 3}

     ‘binary_form’ 引数が *note True: bdb. だった場合、証明書が渡されて
     いればこのメソッドはDERエンコードされた証明書全体をバイト列として返
     し、接続先が証明書を提示しなかった場合は *note None: 641. を返しま
     す。接続先が証明書を提供するかどうかは SSL ソケットの役割に依存しま
     す:

        * クライアント SSL ソケットでは、認証が要求されているかどうかに
          関わらず、サーバは常に証明書を提供します。

        * サーバ SSL ソケットでは、クライアントはサーバによって認証が要
          求されている場合にのみ証明書を提供します。したがって、 (*note
          CERT_OPTIONAL: 3312. や *note CERT_REQUIRED: 3300. ではなく)
          *note CERT_NONE: 3311. を使用した場合 *note getpeercert():
          f84. は *note None: 641. を返します。

     See also *note SSLContext.check_hostname: 3313.

     バージョン 3.2 で変更: 返される辞書に ‘issuer’, ‘notBefore’ のよう
     な追加アイテムを含むようになりました。

     バージョン 3.4 で変更: ハンドシェイクが済んでいなければ *note
     ValueError: 1e3. を投げるようになりました。返される辞書に
     ‘crlDistributionPoints’, ‘caIssuers’, ‘OCSP’ URI のような X509v3 拡
     張アイテムを含むようになりました。

     バージョン 3.9 で変更: IPv6 address strings no longer have a
     trailing new line.

 -- メソッド: SSLSocket.get_verified_chain ()

     Returns verified certificate chain provided by the other end of the
     SSL channel as a list of DER-encoded bytes.  If certificate
     verification was disabled method acts the same as *note
     get_unverified_chain(): 1540.

     Added in version 3.13.

 -- メソッド: SSLSocket.get_unverified_chain ()

     Returns raw certificate chain provided by the other end of the SSL
     channel as a list of DER-encoded bytes.

     Added in version 3.13.

 -- メソッド: SSLSocket.cipher ()

     利用されている暗号の名前、その暗号の利用を定義しているSSLプロトコル
     のバージョン、利用されている鍵のbit長の3つの値を含むタプルを返しま
     す。もし接続が確立されていない場合、 ‘None’ を返します。

 -- メソッド: SSLSocket.shared_ciphers ()

     クライアントとサーバーの両方で利用できる暗号方式のリストを返します
     。返されるリストの各要素は 3つの値を含むタプルで、その値はそれぞれ
     、暗号方式の名前、その暗号の利用を定義している SSL プロトコルのバー
     ジョン、暗号で使用される秘密鍵のビット長です。接続が確立されていな
     いか、ソケットがクライアントソケットである場合、*note
     shared_ciphers(): e35. は ‘None’ を返します。

     Added in version 3.5.

 -- メソッド: SSLSocket.compression ()

     使われている圧縮アルゴリズムを文字列で返します。接続が圧縮されてい
     なければ ‘None’ を返します。

     上位レベルのプロトコルが自身で圧縮メカニズムをサポートする場合、SSL
     レベルでの圧縮を *note OP_NO_COMPRESSION: 1119. を使って無効にでき
     ます。

     Added in version 3.3.

 -- メソッド: SSLSocket.get_channel_binding (cb_type='tls-unique')

     現在の接続におけるチャネルバインディングのデータを取得します。未接
     続あるいはハンドシェイクが完了していなければ ‘None’ を返します。

     'cb_type' パラメータにより、望みのチャネルバインディングのタイプを
     選択できます。チャネルバインディングのタイプの妥当なものは *note
     CHANNEL_BINDING_TYPES: 332d. でリストされています。現在のところは
     RFC 5929(2) で定義されている 'tls-unique' のみがサポートされていま
     す。未サポートのチャネルバインディングのタイプが要求された場合、
     *note ValueError: 1e3. を送出します。

     Added in version 3.3.

 -- メソッド: SSLSocket.selected_alpn_protocol ()

     TLS ハンドシェイクで選択されたプロトコルを返します。 *note
     SSLContext.set_alpn_protocols(): e2d. が呼ばれていない場合、相手側
     が ALPN をサポートしていない場合、クライアントが提案したプロトコル
     のどれもソケットがサポートしない場合、あるいはハンドシェイクがまだ
     行われていない場合には、 ‘None’ が返されます。

     Added in version 3.5.

 -- メソッド: SSLSocket.selected_npn_protocol ()

     TLS/SSL ハンドシェイクで選択された上位レベルのプロトコルを返します
     。 *note SSLContext.set_npn_protocols(): 2d9. が呼ばれていない場合
     、相手側が NPN をサポートしていない場合、あるいはハンドシェイクがま
     だ行われていない場合には、 ‘None’ が返されます。

     Added in version 3.3.

     バージョン 3.10 で非推奨: NPN has been superseded by ALPN

 -- メソッド: SSLSocket.unwrap ()

     SSLシャットダウンハンドシェイクを実行します。これは下位レイヤーのソ
     ケットからTLSレイヤーを取り除き、下位レイヤーのソケットオブジェクト
     を返します。これは暗号化されたオペレーションから暗号化されていない
     接続に移行するときに利用されます。以降の通信には、オリジナルのソケ
     ットではなくこのメソッドが返したソケットのみを利用するべきです。

 -- メソッド: SSLSocket.verify_client_post_handshake ()

     Requests post-handshake authentication (PHA) from a TLS 1.3 client.
     PHA can only be initiated for a TLS 1.3 connection from a
     server-side socket, after the initial TLS handshake and with PHA
     enabled on both sides, see *note SSLContext.post_handshake_auth:
     9ff.

     The method does not perform a cert exchange immediately.  The
     server-side sends a CertificateRequest during the next write event
     and expects the client to respond with a certificate on the next
     read event.

     If any precondition isn't met (e.g.  not TLS 1.3, PHA not enabled),
     an *note SSLError: 124b. is raised.

          注釈: Only available with OpenSSL 1.1.1 and TLS 1.3 enabled.
          Without TLS 1.3 support, the method raises *note
          NotImplementedError: 209.

     Added in version 3.8.

 -- メソッド: SSLSocket.version ()

     コネクションによって実際にネゴシエイトされた SSL プロトコルバージョ
     ンを文字列で、または、セキュアなコネクションが確立していなければ
     ‘None’ を返します。これを書いている時点では、 ‘"SSLv2"’, ‘"SSLv3"’,
     ‘"TLSv1"’, ‘"TLSv1.1"’, ‘"TLSv1.2"’ などが返ります。最新の OpenSSL
     はもっと色々な値を定義しているかもしれません。

     Added in version 3.5.

 -- メソッド: SSLSocket.pending ()

     接続において既に復号済みで読み出し可能で保留になっているバイト列の
     数を返します。

 -- の属性: SSLSocket.context

     The *note SSLContext: 274. object this SSL socket is tied to.

     Added in version 3.2.

 -- の属性: SSLSocket.server_side

     サーバサイドのソケットに対して ‘True’ 、クライアントサイドのソケッ
     トに対して ‘False’ となる真偽値です。

     Added in version 3.2.

 -- の属性: SSLSocket.server_hostname

     サーバのホスト名: *note str: 418. 型、またはサーバサイドのソケット
     の場合とコンストラクタで hostname が指定されなかった場合は ‘None’

     Added in version 3.2.

     バージョン 3.7 で変更: The attribute is now always ASCII text.
     When ‘server_hostname’ is an internationalized domain name (IDN),
     this attribute now stores the A-label form (‘"xn--pythn-mua.org"’),
     rather than the U-label form (‘"pythön.org"’).

 -- の属性: SSLSocket.session

     この SSL 接続に対する *note SSLSession: cab. です。このセッションは
     、TLS ハンドシェイクの実行後、クライアントサイドとサーバサイドのソ
     ケットで使用できます。クライアントソケットでは、このセッションを
     *note do_handshake(): e36. が呼ばれる前に設定して、セッションを再利
     用できます。

     Added in version 3.6.

 -- の属性: SSLSocket.session_reused

     Added in version 3.6.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3280.html

   (2) https://datatracker.ietf.org/doc/html/rfc5929.html


File: python.info,  Node: SSL コンテキスト,  Next: 証明書,  Prev: SSL ソケット,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.9 SSL コンテキスト
.........................

Added in version 3.2.

SSL コンテキストは、SSL 構成オプション、証明書(群)や秘密鍵(群)などのよう
な、一回の SSL 接続よりも長生きするさまざまなデータを保持します。これは
サーバサイドソケットの SSL セッションのキャッシュも管理し、同じクライア
ントからの繰り返しの接続時の速度向上に一役買います。

 -- クラス: ssl.SSLContext (protocol=None)

     Create a new SSL context.  You may pass 'protocol' which must be
     one of the ‘PROTOCOL_*’ constants defined in this module.  The
     parameter specifies which version of the SSL protocol to use.
     Typically, the server chooses a particular protocol version, and
     the client must adapt to the server's choice.  Most of the versions
     are not interoperable with the other versions.  If not specified,
     the default is *note PROTOCOL_TLS: 3302.; it provides the most
     compatibility with other versions.

     次のテーブルは、どのクライアントのバージョンがどのサーバのバージョ
     ンに接続できるかを示しています:

     'client' / 'server'          'SSLv2'          'SSLv3'          'TLS' (1)         'TLSv1'       'TLSv1.1'       'TLSv1.2'
                                                                                                                    
                                                                                                                    
     'SSLv2'                      yes              no               no (2)            no            no              no
                                                                                                                    
                                                                                                                    
     'SSLv3'                      no               yes              no (3)            no            no              no
                                                                                                                    
                                                                                                                    
     'TLS' ('SSLv23') (4)         no (5)           no (6)           yes               yes           yes             yes
                                                                                                                    
                                                                                                                    
     'TLSv1'                      no               no               yes               yes           no              no
                                                                                                                    
                                                                                                                    
     'TLSv1.1'                    no               no               yes               no            yes             no
                                                                                                                    
                                                                                                                    
     'TLSv1.2'                    no               no               yes               no            no              yes
                                                                                                                    

     脚注
     ....

     参考
     ....

     *note create_default_context(): 13b. は *note ssl: bb. モジュールに
     、目的に合ったセキュリティ設定を選ばせます。

     バージョン 3.6 で変更: The context is created with secure default
     values.  The options *note OP_NO_COMPRESSION: 1119, *note
     OP_CIPHER_SERVER_PREFERENCE: 111c, *note OP_SINGLE_DH_USE: 331e,
     *note OP_SINGLE_ECDH_USE: 331f, *note OP_NO_SSLv2: 804, and *note
     OP_NO_SSLv3: 805. (except for *note PROTOCOL_SSLv3: 330d.) are set
     by default.  The initial cipher suite list contains only ‘HIGH’
     ciphers, no ‘NULL’ ciphers and no ‘MD5’ ciphers.

     バージョン 3.10 で非推奨: *note SSLContext: 274. without protocol
     argument is deprecated.  The context class will either require
     *note PROTOCOL_TLS_CLIENT: 83e. or *note PROTOCOL_TLS_SERVER: 83f.
     protocol in the future.

     バージョン 3.10 で変更: The default cipher suites now include only
     secure AES and ChaCha20 ciphers with forward secrecy and security
     level 2.  RSA and DH keys with less than 2048 bits and ECC keys
     with less than 224 bits are prohibited.  *note PROTOCOL_TLS: 3302,
     *note PROTOCOL_TLS_CLIENT: 83e, and *note PROTOCOL_TLS_SERVER: 83f.
     use TLS 1.2 as minimum TLS version.

          注釈: *note SSLContext: 274. only supports limited mutation
          once it has been used by a connection.  Adding new
          certificates to the internal trust store is allowed, but
          changing ciphers, verification settings, or mTLS certificates
          may result in surprising behavior.

          注釈: *note SSLContext: 274. is designed to be shared and used
          by multiple connections.  Thus, it is thread-safe as long as
          it is not reconfigured after being used by a connection.

*note SSLContext: 274. オブジェクトは以下のメソッドと属性を持っています:

 -- メソッド: SSLContext.cert_store_stats ()

     ロードされた X.509 証明書の数、CA 証明書で活性の X.509 証明書の数、
     証明書失効リストの数、についての統計情報を辞書として取得します。

     一つの CA と他の一つの証明書を持ったコンテキストでの例です:

          >>> context.cert_store_stats()
          {'crl': 0, 'x509_ca': 1, 'x509': 2}

     Added in version 3.4.

 -- メソッド: SSLContext.load_cert_chain (certfile, keyfile=None,
          password=None)

     秘密鍵と対応する証明書をロードします。 'certfile' は、証明書と、証
     明書認証で必要とされる任意の数の CA 証明書を含む、PEM フォーマット
     の単一ファイルへのパスでなければなりません。 'keyfile' 文字列を指定
     する場合、秘密鍵が含まれるファイルを指すものでなければなりません。
     指定しない場合、秘密鍵も 'certfile' から取得されます。 'certfile' へ
     の証明書の格納についての詳細は、 *note 証明書: 3341. の議論を参照し
     てください。

     'password' 引数に、秘密鍵を復号するためのパスワードを返す関数を与え
     ることができます。その関数は秘密鍵が暗号化されていて、なおかつパス
     ワードが必要な場合にのみ呼び出されます。その関数は引数なしで呼び出
     され、string, bytes, または bytearray を返さなければなりません。戻
     り値が string の場合は鍵を復号化するのに使う前に UTF-8 でエンコード
     されます。string の代わりに bytes や bytearray を返した場合は
     'password' 引数に直接供給されます。秘密鍵が暗号化されていなかったり
     パスワードを必要としない場合は、指定は無視されます。

     'password' が与えられず、そしてパスワードが必要な場合には、OpenSSL
     組み込みのパスワード問い合わせメカニズムが、ユーザに対話的にパスワ
     ードを問い合わせます。

     秘密鍵が証明書に合致しなければ、 *note SSLError: 124b. が送出されま
     す。

     バージョン 3.3 で変更: 新しいオプション引数 'password'。

 -- メソッド: SSLContext.load_default_certs
          (purpose=Purpose.SERVER_AUTH)

     デフォルトの場所から "認証局" (CA=certification authority) 証明書フ
     ァイル一式をロードします。Windows では、CA 証明書はシステム記憶域の
     ‘CA’ と ‘ROOT’ からロードします。全てのシステムでは、この関数は
     *note SSLContext.set_default_verify_paths(): f77. を呼び出します。
     将来的にはこのメソッドは、他の場所からも CA 証明書をロードするかも
     しれません。

     The 'purpose' flag specifies what kind of CA certificates are
     loaded.  The default settings *note Purpose.SERVER_AUTH: f7f. loads
     certificates, that are flagged and trusted for TLS web server
     authentication (client side sockets).  *note Purpose.CLIENT_AUTH:
     f80. loads CA certificates for client certificate verification on
     the server side.

     Added in version 3.4.

 -- メソッド: SSLContext.load_verify_locations (cafile=None,
          capath=None, cadata=None)

     *note verify_mode: 32ff. が *note CERT_NONE: 3311. でない場合に接続
     先の証明書ファイルの正当性検証に使われる "認証局" (CA=certification
     authority) 証明書ファイル一式をロードします。少なくとも 'cafile' か
     'capath' のどちらかは指定しなければなりません。

     このメソッドは PEM または DER フォーマットの証明書失効リスト
     (CRLs=certification revocation lists)もロードできます。CRLs のため
     に使うには、 *note SSLContext.verify_flags: f7a. を適切に設定しなけ
     ればなりません。

     'cafile' を指定する場合は、PEM フォーマットで CA 証明書が結合された
     ファイルへのパスを指定してください。このファイル内で証明書をどのよ
     うに編成すれば良いのかについての詳しい情報については、 *note
     証明書: 3341. の議論を参照してください。

     The 'capath' string, if present, is the path to a directory
     containing several CA certificates in PEM format, following an
     OpenSSL specific layout(7).

     'cadata' オブジェクトを指定する場合は、PEM エンコードの証明書一つ以
     上の ASCII 文字列か、DER エンコードの証明書の *note bytes-like
     object: cfb. オブジェクトのどちらかを指定してください。PEM エンコー
     ドの証明書の周囲の余分な行は無視されますが、少なくとも一つの証明書
     が含まれている必要があります。

     バージョン 3.4 で変更: 新しいオプション引数 'cadata' 。

 -- メソッド: SSLContext.get_ca_certs (binary_form=False)

     ロードされた "認証局" (CA=certification authority) 証明書のリストを
     取得します。 ‘binary_form’ 引数が *note False: b05. である場合、リ
     ストのそれぞれのエントリは *note SSLSocket.getpeercert(): f84. が出
     力するような辞書になります。True である場合、このメソッドは、DER エ
     ンコード形式の証明書のリストを返します。返却されるリストには、 SSL
     接続によって証明書がリクエストおよびロードされない限り、 'capath' か
     らの証明書は含まれません。

          注釈: capath ディレクトリ内の証明書は一度でも使われない限りは
          ロードされません。

     Added in version 3.4.

 -- メソッド: SSLContext.get_ciphers ()

     有効な暗号化のリストを取得します。リストは暗号化優先度順に並びます
     。*note SSLContext.set_ciphers(): 3342. を参照してください。

     以下はプログラム例です:

          >>> ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
          >>> ctx.set_ciphers('ECDHE+AESGCM:!ECDSA')
          >>> ctx.get_ciphers()
          [{'aead': True,
            'alg_bits': 256,
            'auth': 'auth-rsa',
            'description': 'ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH     Au=RSA  '
                           'Enc=AESGCM(256) Mac=AEAD',
            'digest': None,
            'id': 50380848,
            'kea': 'kx-ecdhe',
            'name': 'ECDHE-RSA-AES256-GCM-SHA384',
            'protocol': 'TLSv1.2',
            'strength_bits': 256,
            'symmetric': 'aes-256-gcm'},
           {'aead': True,
            'alg_bits': 128,
            'auth': 'auth-rsa',
            'description': 'ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 Kx=ECDH     Au=RSA  '
                           'Enc=AESGCM(128) Mac=AEAD',
            'digest': None,
            'id': 50380847,
            'kea': 'kx-ecdhe',
            'name': 'ECDHE-RSA-AES128-GCM-SHA256',
            'protocol': 'TLSv1.2',
            'strength_bits': 128,
            'symmetric': 'aes-128-gcm'}]

     Added in version 3.6.

 -- メソッド: SSLContext.set_default_verify_paths ()

     デフォルトの "認証局" (CA=certification authority) 証明書を、
     OpenSSL ライブラリがビルドされた際に定義されたファイルシステム上の
     パスからロードします。残念ながらこのメソッドが成功したかどうかを知
     るための簡単な方法はありません: 証明書が見つからなくてもエラーは返
     りません。OpenSSL ライブラリがオペレーティングシステムの一部として
     提供されている際にはどうやら適切に構成できるようですが。

 -- メソッド: SSLContext.set_ciphers (ciphers)

     Set the available ciphers for sockets created with this context.
     It should be a string in the OpenSSL cipher list format(8).  If no
     cipher can be selected (because compile-time options or other
     configuration forbids use of all the specified ciphers), an *note
     SSLError: 124b. will be raised.

          注釈: 接続時に SSL ソケットの *note SSLSocket.cipher(): 3236.
          メソッドが、現在選択されているその暗号を使います。

          TLS 1.3 cipher suites cannot be disabled with *note
          set_ciphers(): 3342.

 -- メソッド: SSLContext.set_alpn_protocols (protocols)

     SSL/TLS ハンドシェイク時にソケットが提示すべきプロトコルを指定しま
     す。 ‘['http/1.1', 'spdy/2']’ のような推奨順に並べた ASCII 文字列の
     リストでなければなりません。プロトコルの選択は RFC 7301(9) に従いハ
     ンドシェイク中に行われます。ハンドシェイクが正常に終了した後、
     *note SSLSocket.selected_alpn_protocol(): e2e. メソッドは合意された
     プロトコルを返します。

     このメソッドは *note HAS_ALPN: e2f. が ‘False’ の場合 *note
     NotImplementedError: 209. を送出します。

     Added in version 3.5.

 -- メソッド: SSLContext.set_npn_protocols (protocols)

     SSL/TLS ハンドシェイク時にソケットが提示すべきプロトコルを指定しま
     す。 ‘['http/1.1', 'spdy/2']’ のような推奨順に並べた文字列のリスト
     でなければなりません。プロトコルの選択は Application Layer Protocol
     Negotiation(10) に従いハンドシェイク中に行われます。ハンドシェイク
     が正常に終了した後、 *note SSLSocket.selected_alpn_protocol(): e2e.
     メソッドは合意されたプロトコルを返します。

     このメソッドは *note HAS_NPN: 3326. が ‘False’ の場合 *note
     NotImplementedError: 209. を送出します。

     Added in version 3.3.

     バージョン 3.10 で非推奨: NPN has been superseded by ALPN

 -- の属性: SSLContext.sni_callback

     TLS クライアントがサーバ名表示を指定した際の、SSL/TLS サーバによっ
     て TLS Client Hello ハンドシェイクメッセージが受け取られたあとで呼
     び出されるコールバック関数を登録します。サーバ名表示メカニズムは
     RFC 6066(11) セクション 3 - Server Name Indication で述べられていま
     す。

     ‘SSLContext’ ごとに一つだけコールバックをセットできます。
     'sni_callback' を ‘None’ にすればコールバックは無効になります。この
     関数を続けて呼ぶと、以前に登録されたコールバックを上書きします。

     The callback function will be called with three arguments; the
     first being the *note ssl.SSLSocket: 8b8, the second is a string
     that represents the server name that the client is intending to
     communicate (or *note None: 641. if the TLS Client Hello does not
     contain a server name) and the third argument is the original *note
     SSLContext: 274.  The server name argument is text.  For
     internationalized domain name, the server name is an IDN A-label
     (‘"xn--pythn-mua.org"’).

     このコールバックの典型的な利用方法は、 *note ssl.SSLSocket: 8b8. の
     *note SSLSocket.context: 333c. 属性を、サーバ名に合致する証明書チェ
     インを持つ新しい *note SSLContext: 274. オブジェクトに変更すること
     です。

     Due to the early negotiation phase of the TLS connection, only
     limited methods and attributes are usable like *note
     SSLSocket.selected_alpn_protocol(): e2e. and *note
     SSLSocket.context: 333c.  The *note SSLSocket.getpeercert(): f84,
     *note SSLSocket.get_verified_chain(): 153f, *note
     SSLSocket.get_unverified_chain(): 1540. *note SSLSocket.cipher():
     3236. and *note SSLSocket.compression(): 1118. methods require that
     the TLS connection has progressed beyond the TLS Client Hello and
     therefore will not return meaningful values nor can they be called
     safely.

     TLS ネゴシエーションを継続させるならば、 'sni_callback' 関数は
     ‘None’ を返さなければなりません。TLS が失敗することを必要とするなら
     、 constant *note ALERT_DESCRIPTION_*: 332f. を返してください。ここ
     にない値を返すと、致命エラー *note
     ALERT_DESCRIPTION_INTERNAL_ERROR: 332f. を引き起こします。

     'sni_callback' 関数が例外を送出した場合、TLS 接続は TLS の致命的ア
     ラートメッセージ *note ALERT_DESCRIPTION_HANDSHAKE_FAILURE: 332e. と
     ともに終了します。

     このメソッドは OpenSSL ライブラリが OPENSSL_NO_TLSEXT を定義してビ
     ルドされている場合、 *note NotImplementedError: 209. を送出します。

     Added in version 3.7.

 -- の属性: SSLContext.set_servername_callback (server_name_callback)

     This is a legacy API retained for backwards compatibility.  When
     possible, you should use *note sni_callback: 1840. instead.  The
     given 'server_name_callback' is similar to 'sni_callback', except
     that when the server hostname is an IDN-encoded internationalized
     domain name, the 'server_name_callback' receives a decoded U-label
     (‘"pythön.org"’).

     If there is a decoding error on the server name, the TLS connection
     will terminate with an *note ALERT_DESCRIPTION_INTERNAL_ERROR:
     332f. fatal TLS alert message to the client.

     Added in version 3.4.

 -- メソッド: SSLContext.load_dh_params (dhfile)

     ディフィー・ヘルマン(DH)鍵交換のための鍵生成パラメータをロードしま
     す。DH 鍵交換を用いることは、(サーバ、クライアントともに)計算機リソ
     ースに高い処理負荷をかけますがセキュリティを向上させます。 'dhfile'
     パラメータは PEM フォーマットの DH パラメータを含んだファイルへのパ
     スでなければなりません。

     この設定はクライアントソケットには適用されません。さらにセキュリテ
     ィを改善するのに *note OP_SINGLE_DH_USE: 331e. オプションも利用でき
     ます。

     Added in version 3.3.

 -- メソッド: SSLContext.set_ecdh_curve (curve_name)

     楕円曲線ディフィー・ヘルマン(ECDH)鍵交換の曲線名を指定します。ECDH
     はもとの DH に較べて、ほぼ間違いなく同程度に安全である一方で、顕著
     に高速です。 'curve_name' パラメータは既知の楕円曲線を表す文字列で
     なければなりません。例えば ‘prime256v1’ が広くサポートされている曲
     線です。

     この設定はクライアントソケットには適用されません。さらにセキュリテ
     ィを改善するのに *note OP_SINGLE_ECDH_USE: 331f. オプションも利用で
     きます。

     このメソッドは *note HAS_ECDH: 3324. が ‘False’ の場合は利用できま
     せん。

     Added in version 3.3.

     参考
     ....

     SSL/TLS & Perfect Forward Secrecy(12)

          Vincent Bernat.

 -- メソッド: SSLContext.wrap_socket (sock, server_side=False,
          do_handshake_on_connect=True, suppress_ragged_eofs=True,
          server_hostname=None, session=None)

     Wrap an existing Python socket 'sock' and return an instance of
     *note SSLContext.sslsocket_class: 3343. (default *note SSLSocket:
     8b8.).  The returned SSL socket is tied to the context, its
     settings and certificates.  'sock' must be a *note SOCK_STREAM:
     12c1. socket; other socket types are unsupported.

     ‘server_side’ 引数は真偽値で、このソケットがサーバサイドとクライア
     ントサイドのどちらの動作をするのかを指定します。

     クライアントサイドソケットにおいて、コンテキストの生成は遅延されま
     す。つまり、低レイヤのソケットがまだ接続されていない場合、コンテキ
     ストの生成はそのソケットの ‘connect()’ メソッドが呼ばれた後に行われ
     ます。サーバサイドソケットの場合、そのソケットに接続先が居なければ
     それは listen 用ソケットだと判断されます。 ‘accept()’ メソッドで生
     成されるクライアント接続に対してのサーバサイド SSLラップは自動的に
     行われます。メソッドは *note SSLError: 124b. を送出することがありま
     す。

     クライアントからの接続では、 'server_hostname' で接続先サービスのホ
     スト名を指定できます。これは HTTP バーチャルホストにかなり似て、シ
     ングルサーバで複数の SSL ベースのサービスを別々の証明書でホストして
     いるようなサーバに対して使えます。 'server_side' が True の場合に
     'server_hostname' を指定すると *note ValueError: 1e3. を送出します
     。

     ‘do_handshake_on_connect’ 引数は、 ‘socket.connect()’ の後に自動的
     に SSLハンドシェイクを行うか、それともアプリケーションが明示的に
     *note SSLSocket.do_handshake(): e36. メソッドを実行するかを指定しま
     す。 *note SSLSocket.do_handshake(): e36. を明示的に呼びだすことで
     、ハンドシェイクによるソケットI/Oのブロッキング動作を制御できます。

     ‘suppress_ragged_eofs’ 引数は、 ‘SSLSocket.recv()’ メソッドが、接続
     先から予期しないEOF を受け取った時に通知する方法を指定します。
     *note True: bdb. (デフォルト) の場合、下位のソケットレイヤーから予
     期せぬEOFエラーが来た場合、通常のEOF (空のバイト列オブジェクト)を返
     します。 *note False: b05. の場合、呼び出し元に例外を投げて通知しま
     す。

     'session', *note session: 1512. を参照してください。

     To wrap an *note SSLSocket: 8b8. in another *note SSLSocket: 8b8,
     use *note SSLContext.wrap_bio(): b50.

     バージョン 3.5 で変更: OpenSSL が SNI をサポートしなくても
     server_hostname を許容するようになりました。

     バージョン 3.6 で変更: 'session' 引数が追加されました。

     バージョン 3.7 で変更: The method returns an instance of *note
     SSLContext.sslsocket_class: 3343. instead of hard-coded *note
     SSLSocket: 8b8.

 -- の属性: SSLContext.sslsocket_class

     The return type of *note SSLContext.wrap_socket(): 4ee, defaults to
     *note SSLSocket: 8b8.  The attribute can be overridden on instance
     of class in order to return a custom subclass of *note SSLSocket:
     8b8.

     Added in version 3.7.

 -- メソッド: SSLContext.wrap_bio (incoming, outgoing,
          server_side=False, server_hostname=None, session=None)

     Wrap the BIO objects 'incoming' and 'outgoing' and return an
     instance of *note SSLContext.sslobject_class: 3344. (default *note
     SSLObject: b4f.).  The SSL routines will read input data from the
     incoming BIO and write data to the outgoing BIO.

     'server_side'、 'server_hostname' 、 'session' 引数は、 *note
     SSLContext.wrap_socket(): 4ee. での意味と同じ意味を持ちます。

     バージョン 3.6 で変更: 'session' 引数が追加されました。

     バージョン 3.7 で変更: The method returns an instance of *note
     SSLContext.sslobject_class: 3344. instead of hard-coded *note
     SSLObject: b4f.

 -- の属性: SSLContext.sslobject_class

     The return type of *note SSLContext.wrap_bio(): b50, defaults to
     *note SSLObject: b4f.  The attribute can be overridden on instance
     of class in order to return a custom subclass of *note SSLObject:
     b4f.

     Added in version 3.7.

 -- メソッド: SSLContext.session_stats ()

     Get statistics about the SSL sessions created or managed by this
     context.  A dictionary is returned which maps the names of each
     piece of information(13) to their numeric values.  For example,
     here is the total number of hits and misses in the session cache
     since the context was created:

          >>> stats = context.session_stats()
          >>> stats['hits'], stats['misses']
          (0, 0)

 -- の属性: SSLContext.check_hostname

     Whether to match the peer cert's hostname in *note
     SSLSocket.do_handshake(): e36.  The context's *note verify_mode:
     32ff. must be set to *note CERT_OPTIONAL: 3312. or *note
     CERT_REQUIRED: 3300, and you must pass 'server_hostname' to *note
     wrap_socket(): 4ee. in order to match the hostname.  Enabling
     hostname checking automatically sets *note verify_mode: 32ff. from
     *note CERT_NONE: 3311. to *note CERT_REQUIRED: 3300.  It cannot be
     set back to *note CERT_NONE: 3311. as long as hostname checking is
     enabled.  The *note PROTOCOL_TLS_CLIENT: 83e. protocol enables
     hostname checking by default.  With other protocols, hostname
     checking must be enabled explicitly.

     以下はプログラム例です:

          import socket, ssl

          context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
          context.verify_mode = ssl.CERT_REQUIRED
          context.check_hostname = True
          context.load_default_certs()

          s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          ssl_sock = context.wrap_socket(s, server_hostname='www.verisign.com')
          ssl_sock.connect(('www.verisign.com', 443))

     Added in version 3.4.

     バージョン 3.7 で変更: *note verify_mode: 32ff. is now
     automatically changed to *note CERT_REQUIRED: 3300. when hostname
     checking is enabled and *note verify_mode: 32ff. is *note
     CERT_NONE: 3311.  Previously the same operation would have failed
     with a *note ValueError: 1e3.

 -- の属性: SSLContext.keylog_filename

     Write TLS keys to a keylog file, whenever key material is generated
     or received.  The keylog file is designed for debugging purposes
     only.  The file format is specified by NSS and used by many traffic
     analyzers such as Wireshark.  The log file is opened in append-only
     mode.  Writes are synchronized between threads, but not between
     processes.

     Added in version 3.8.

 -- の属性: SSLContext.maximum_version

     A *note TLSVersion: 3332. enum member representing the highest
     supported TLS version.  The value defaults to *note
     TLSVersion.MAXIMUM_SUPPORTED: 3334.  The attribute is read-only for
     protocols other than *note PROTOCOL_TLS: 3302, *note
     PROTOCOL_TLS_CLIENT: 83e, and *note PROTOCOL_TLS_SERVER: 83f.

     The attributes *note maximum_version: 83d, *note minimum_version:
     83c. and *note SSLContext.options: 803. all affect the supported
     SSL and TLS versions of the context.  The implementation does not
     prevent invalid combination.  For example a context with *note
     OP_NO_TLSv1_2: 331c. in *note options: 803. and *note
     maximum_version: 83d. set to *note TLSVersion.TLSv1_2: 3338. will
     not be able to establish a TLS 1.2 connection.

     Added in version 3.7.

 -- の属性: SSLContext.minimum_version

     Like *note SSLContext.maximum_version: 83d. except it is the lowest
     supported version or *note TLSVersion.MINIMUM_SUPPORTED: 3333.

     Added in version 3.7.

 -- の属性: SSLContext.num_tickets

     Control the number of TLS 1.3 session tickets of a *note
     PROTOCOL_TLS_SERVER: 83f. context.  The setting has no impact on
     TLS 1.0 to 1.2 connections.

     Added in version 3.8.

 -- の属性: SSLContext.options

     このコンテキストで有効になっている SSL オプションを表す整数。デフォ
     ルトの値は *note OP_ALL: 3319. ですが、 *note OP_NO_SSLv2: 804. の
     ような他の値をビット OR 演算で指定できます。

     バージョン 3.6 で変更: *note SSLContext.options: 803. は次のように
     *note Options: 3321. のフラグを返します。

          >>> ssl.create_default_context().options
          <Options.OP_ALL|OP_NO_SSLv3|OP_NO_SSLv2|OP_NO_COMPRESSION: 2197947391>

     バージョン 3.7 で非推奨: All ‘OP_NO_SSL*’ and ‘OP_NO_TLS*’ options
     have been deprecated since Python 3.7.  Use *note
     SSLContext.minimum_version: 83c. and *note
     SSLContext.maximum_version: 83d. instead.

 -- の属性: SSLContext.post_handshake_auth

     Enable TLS 1.3 post-handshake client authentication.
     Post-handshake auth is disabled by default and a server can only
     request a TLS client certificate during the initial handshake.
     When enabled, a server may request a TLS client certificate at any
     time after the handshake.

     When enabled on client-side sockets, the client signals the server
     that it supports post-handshake authentication.

     When enabled on server-side sockets, *note SSLContext.verify_mode:
     32ff. must be set to *note CERT_OPTIONAL: 3312. or *note
     CERT_REQUIRED: 3300, too.  The actual client cert exchange is
     delayed until *note SSLSocket.verify_client_post_handshake(): a00.
     is called and some I/O is performed.

     Added in version 3.8.

 -- の属性: SSLContext.protocol

     コンテキストの構築時に選択されたプロトコルバージョン。この属性は読
     み出し専用です。

 -- の属性: SSLContext.hostname_checks_common_name

     Whether *note check_hostname: 3313. falls back to verify the cert's
     subject common name in the absence of a subject alternative name
     extension (default: true).

     Added in version 3.7.

     バージョン 3.10 で変更: The flag had no effect with OpenSSL before
     version 1.1.1l.  Python 3.8.9, 3.9.3, and 3.10 include workarounds
     for previous versions.

 -- の属性: SSLContext.security_level

     An integer representing the security level(14) for the context.
     This attribute is read-only.

     Added in version 3.10.

 -- の属性: SSLContext.verify_flags

     証明書の検証操作のためのフラグです。 *note VERIFY_CRL_CHECK_LEAF:
     f7c. などのフラグをビット OR 演算でセットできます。デフォルトでは
     OpenSSL は証明書失効リスト (CRLs) を必要としませんし検証にも使いま
     せん。

     Added in version 3.4.

     バージョン 3.6 で変更: *note SSLContext.verify_flags: f7a. は次のよ
     うに *note VerifyFlags: 3316. のフラグを返します。

          >>> ssl.create_default_context().verify_flags
          <VerifyFlags.VERIFY_X509_TRUSTED_FIRST: 32768>

 -- の属性: SSLContext.verify_mode

     接続先の証明書の検証を試みるかどうか、また、検証が失敗した場合にど
     のように振舞うべきかを制御します。この属性は *note CERT_NONE: 3311,
     *note CERT_OPTIONAL: 3312, *note CERT_REQUIRED: 3300. のうちどれか
     一つでなければなりません。

     バージョン 3.6 で変更: *note SSLContext.verify_mode: 32ff. は次のよ
     うに *note VerifyMode: 3314. enum (列挙) を返します。

          >>> ssl.create_default_context().verify_mode
          <VerifyMode.CERT_REQUIRED: 2>

 -- メソッド: SSLContext.set_psk_client_callback (callback)

     Enables TLS-PSK (pre-shared key) authentication on a client-side
     connection.

     In general, certificate based authentication should be preferred
     over this method.

     The parameter ‘callback’ is a callable object with the signature:
     ‘def callback(hint: str | None) -> tuple[str | None, bytes]’.  The
     ‘hint’ parameter is an optional identity hint sent by the server.
     The return value is a tuple in the form (client-identity, psk).
     Client-identity is an optional string which may be used by the
     server to select a corresponding PSK for the client.  The string
     must be less than or equal to ‘256’ octets when UTF-8 encoded.  PSK
     is a *note bytes-like object: cfb. representing the pre-shared key.
     Return a zero length PSK to reject the connection.

     Setting ‘callback’ to *note None: 641. removes any existing
     callback.

          注釈: When using TLS 1.3:

             - the ‘hint’ parameter is always *note None: 641.

             - client-identity must be a non-empty string.

     使用例:

          context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
          context.check_hostname = False
          context.verify_mode = ssl.CERT_NONE
          context.maximum_version = ssl.TLSVersion.TLSv1_2
          context.set_ciphers('PSK')

          # A simple lambda:
          psk = bytes.fromhex('c0ffee')
          context.set_psk_client_callback(lambda hint: (None, psk))

          # A table using the hint from the server:
          psk_table = { 'ServerId_1': bytes.fromhex('c0ffee'),
                        'ServerId_2': bytes.fromhex('facade')
          }
          def callback(hint):
              return 'ClientId_1', psk_table.get(hint, b'')
          context.set_psk_client_callback(callback)

     This method will raise *note NotImplementedError: 209. if *note
     HAS_PSK: 332c. is ‘False’.

     Added in version 3.13.

 -- メソッド: SSLContext.set_psk_server_callback (callback,
          identity_hint=None)

     Enables TLS-PSK (pre-shared key) authentication on a server-side
     connection.

     In general, certificate based authentication should be preferred
     over this method.

     The parameter ‘callback’ is a callable object with the signature:
     ‘def callback(identity: str | None) -> bytes’.  The ‘identity’
     parameter is an optional identity sent by the client which can be
     used to select a corresponding PSK. The return value is a *note
     bytes-like object: cfb. representing the pre-shared key.  Return a
     zero length PSK to reject the connection.

     Setting ‘callback’ to *note None: 641. removes any existing
     callback.

     The parameter ‘identity_hint’ is an optional identity hint string
     sent to the client.  The string must be less than or equal to ‘256’
     octets when UTF-8 encoded.

          注釈: When using TLS 1.3 the ‘identity_hint’ parameter is not
          sent to the client.

     使用例:

          context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
          context.maximum_version = ssl.TLSVersion.TLSv1_2
          context.set_ciphers('PSK')

          # A simple lambda:
          psk = bytes.fromhex('c0ffee')
          context.set_psk_server_callback(lambda identity: psk)

          # A table using the identity of the client:
          psk_table = { 'ClientId_1': bytes.fromhex('c0ffee'),
                        'ClientId_2': bytes.fromhex('facade')
          }
          def callback(identity):
              return psk_table.get(identity, b'')
          context.set_psk_server_callback(callback, 'ServerId_1')

     This method will raise *note NotImplementedError: 209. if *note
     HAS_PSK: 332c. is ‘False’.

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) TLS 1.3 protocol will be available with *note PROTOCOL_TLS: 3302.
in OpenSSL >= 1.1.1.  There is no dedicated PROTOCOL constant for just
TLS 1.3.

   (2) *note SSLContext: 274. では、デフォルトで *note OP_NO_SSLv2: 804.
によりSSLv2 が無効になっています。

   (3) *note SSLContext: 274. では、デフォルトで *note OP_NO_SSLv3: 805.
により SSLv3 が無効になっています。

   (4) TLS 1.3 protocol will be available with *note PROTOCOL_TLS: 3302.
in OpenSSL >= 1.1.1.  There is no dedicated PROTOCOL constant for just
TLS 1.3.

   (5) *note SSLContext: 274. では、デフォルトで *note OP_NO_SSLv2: 804.
によりSSLv2 が無効になっています。

   (6) *note SSLContext: 274. では、デフォルトで *note OP_NO_SSLv3: 805.
により SSLv3 が無効になっています。

   (7) 
https://docs.openssl.org/master/man3/SSL_CTX_load_verify_locations/

   (8) https://docs.openssl.org/master/man1/ciphers/

   (9) https://datatracker.ietf.org/doc/html/rfc7301.html

   (10) 
https://en.wikipedia.org/wiki/Application-Layer_Protocol_Negotiation

   (11) https://datatracker.ietf.org/doc/html/rfc6066.html

   (12) 
https://vincent.bernat.ch/en/blog/2011-ssl-perfect-forward-secrecy

   (13) https://docs.openssl.org/1.1.1/man3/SSL_CTX_sess_number/

   (14) https://docs.openssl.org/master/man3/SSL_CTX_get_security_level/


File: python.info,  Node: 証明書,  Next: 使用例<27>,  Prev: SSL コンテキスト,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.10 証明書
................

証明書を大まかに説明すると、公開鍵/秘密鍵システムの一種です。このシステ
ムでは、各 'principal' (これはマシン、人、組織などです) は、ユニークな
2つの暗号鍵を割り当てられます。1つは公開され、 '公開鍵(public key)' と呼
ばれます。もう一方は秘密にされ、 '秘密鍵(private key)' と呼ばれます。 2つ
の鍵は関連しており、片方の鍵で暗号化したメッセージは、もう片方の鍵 'のみ
' で復号できます。

証明書は2つの principal の情報を含んでいます。証明書は 'subject' 名とそ
の公開鍵を含んでいます。また、もう一つの principal である '発行者
(issuer)' からの、 subject が本人であることと、その公開鍵が正しいことの
宣言(statement)を含んでいます。発行者からの宣言は、その発行者の秘密鍵で
署名されています。発行者の秘密鍵は発行者しか知りませんが、誰もがその発行
者の公開鍵を利用して宣言を復号し、証明書内の別の情報と比較することで認証
することができます。証明書はまた、その証明書が有効である期限に関する情報
も含んでいます。この期限は "notBefore" と "notAfter" と呼ばれる2つのフィ
ールドで表現されています。

Python において証明書を利用する場合、クライアントもサーバーも自分を証明
するために証明書を利用することができます。ネットワーク接続の相手側に証明
書の提示を要求する事ができ、そのクライアントやサーバーが認証を必要とする
ならその証明書を認証することができます。認証が失敗した場合、接続は例外を
発生させます。認証は下位層のOpenSSLフレームワークが自動的に行います。ア
プリケーションは認証機構について意識する必要はありません。しかし、アプリ
ケーションは認証プロセスのために幾つかの証明書を提供する必要があるかもし
れません。

Python は証明書を格納したファイルを利用します。そのファイルは "PEM" (
RFC 1422(1) 参照) フォーマットという、ヘッダー行とフッター行の間に
base-64エンコードされた形をとっている必要があります。

     -----BEGIN CERTIFICATE-----
     ... (certificate in base64 PEM encoding) ...
     -----END CERTIFICATE-----

* Menu:

* 証明書チェイン::
* CA 証明書::
* 秘密鍵と証明書の組み合わせ::
* 自己署名証明書::

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc1422.html


File: python.info,  Node: 証明書チェイン,  Next: CA 証明書,  Up: 証明書

5.18.3.11 証明書チェイン
........................

Pythonが利用する証明書を格納したファイルは、ときには '証明書チェイン
(certificate chain)' と呼ばれる証明書のシーケンスを格納します。このチェ
インの先頭には、まずクライアントやサーバーである principal の証明書を置
き、それ以降には、その証明書の発行者(issuer)の証明書などを続け、最後に証
明対象(subject)と発行者が同じ '自己署名(self-signed)' 証明書で終わります
。この最後の証明書は 'ルート証明書(root certificate' と呼ばれます。これ
らの証明書チェインは単純に1つの証明書ファイルに結合してください。例えば
、3つの証明書からなる証明書チェインがある場合、私たちのサーバーの証明書
から、私たちのサーバーに署名した認証局の証明書、そして認証局の証明書を発
行した機関のルート証明書と続きます:

     -----BEGIN CERTIFICATE-----
     ... (certificate for your server)...
     -----END CERTIFICATE-----
     -----BEGIN CERTIFICATE-----
     ... (the certificate for the CA)...
     -----END CERTIFICATE-----
     -----BEGIN CERTIFICATE-----
     ... (the root certificate for the CA's issuer)...
     -----END CERTIFICATE-----


File: python.info,  Node: CA 証明書,  Next: 秘密鍵と証明書の組み合わせ,  Prev: 証明書チェイン,  Up: 証明書

5.18.3.12 CA 証明書
...................

もし相手から送られてきた証明書の認証をしたい場合、信頼している各発行者の
証明書チェインが入った "CA certs" ファイルを提供する必要があります。繰り
返しますが、このファイルは単純に、各チェインを結合しただけのものです。認
証のために、Pythonはそのファイルの中の最初にマッチしたチェインを利用しま
す。*note SSLContext.load_default_certs(): f7e. を呼び出すことでプラット
フォームの証明書ファイルも使われますが、これは *note
create_default_context(): 13b. によって自動的に行われます。


File: python.info,  Node: 秘密鍵と証明書の組み合わせ,  Next: 自己署名証明書,  Prev: CA 証明書,  Up: 証明書

5.18.3.13 秘密鍵と証明書の組み合わせ
....................................

Often the private key is stored in the same file as the certificate; in
this case, only the ‘certfile’ parameter to *note
SSLContext.load_cert_chain(): 275. needs to be passed.  If the private
key is stored with the certificate, it should come before the first
certificate in the certificate chain:

     -----BEGIN RSA PRIVATE KEY-----
     ... (private key in base64 encoding) ...
     -----END RSA PRIVATE KEY-----
     -----BEGIN CERTIFICATE-----
     ... (certificate in base64 PEM encoding) ...
     -----END CERTIFICATE-----


File: python.info,  Node: 自己署名証明書,  Prev: 秘密鍵と証明書の組み合わせ,  Up: 証明書

5.18.3.14 自己署名証明書
........................

SSL暗号化接続サービスを提供するサーバーを建てる場合、適切な証明書を取得
するには、認証局から買うなどの幾つかの方法があります。また、自己署名証明
書を作るケースもあります。 OpenSSLを使って自己署名証明書を作るには、次の
ようにします。

     % openssl req -new -x509 -days 365 -nodes -out cert.pem -keyout cert.pem
     Generating a 1024 bit RSA private key
     .......++++++
     .............................++++++
     writing new private key to 'cert.pem'
     -----
     You are about to be asked to enter information that will be incorporated
     into your certificate request.
     What you are about to enter is what is called a Distinguished Name or a DN.
     There are quite a few fields but you can leave some blank
     For some fields there will be a default value,
     If you enter '.', the field will be left blank.
     -----
     Country Name (2 letter code) [AU]:US
     State or Province Name (full name) [Some-State]:MyState
     Locality Name (eg, city) []:Some City
     Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Organization, Inc.
     Organizational Unit Name (eg, section) []:My Group
     Common Name (eg, YOUR name) []:myserver.mygroup.myorganization.com
     Email Address []:ops@myserver.mygroup.myorganization.com
     %

自己署名証明書の欠点は、それ自身がルート証明書であり、他の人はその証明書
を持っていない (そして信頼しない)ことです。


File: python.info,  Node: 使用例<27>,  Next: ノンブロッキングソケットについての注意事項,  Prev: 証明書,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.15 使用例
................

* Menu:

* SSLサポートをテストする::
* クライアントサイドの処理::
* サーバサイドの処理::


File: python.info,  Node: SSLサポートをテストする,  Next: クライアントサイドの処理,  Up: 使用例<27>

5.18.3.16 SSLサポートをテストする
.................................

インストールされているPythonがSSLをサポートしているかどうかをテストする
ために、ユーザーコードは次のイディオムを利用することができます。

     try:
         import ssl
     except ImportError:
         pass
     else:
         ...  # do something that requires SSL support


File: python.info,  Node: クライアントサイドの処理,  Next: サーバサイドの処理,  Prev: SSLサポートをテストする,  Up: 使用例<27>

5.18.3.17 クライアントサイドの処理
..................................

この例では、自動的に証明書の検証を行うことを含む望ましいセキュリティ設定
でクライアントソケットの SSL コンテキストを作ります:

     >>> context = ssl.create_default_context()

自分自身でセキュリティ設定を調整したい場合、コンテキストを一から作ること
はできます (ただし、正しくない設定をしてしまいがちなことに注意してくださ
い):

     >>> context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
     >>> context.load_verify_locations("/etc/ssl/certs/ca-bundle.crt")

(このスニペットはすべての CA 証明書が ‘/etc/ssl/certs/ca-bundle.crt’ に
バンドルされていることを仮定しています; もし違っていればエラーになります
ので、適宜修正してください)

The *note PROTOCOL_TLS_CLIENT: 83e. protocol configures the context for
cert validation and hostname verification.  *note verify_mode: 32ff. is
set to *note CERT_REQUIRED: 3300. and *note check_hostname: 3313. is set
to ‘True’.  All other protocols create SSL contexts with insecure
defaults.

When you use the context to connect to a server, *note CERT_REQUIRED:
3300. and *note check_hostname: 3313. validate the server certificate:
it ensures that the server certificate was signed with one of the CA
certificates, checks the signature for correctness, and verifies other
properties like validity and identity of the hostname:

     >>> conn = context.wrap_socket(socket.socket(socket.AF_INET),
     ...                            server_hostname="www.python.org")
     >>> conn.connect(("www.python.org", 443))

そして証明書を持ってくることができます:

     >>> cert = conn.getpeercert()

証明書が、期待しているサービス (つまり、 HTTPS ホスト ‘www.python.org’)
の身元を特定していることを視覚的に点検してみましょう:

     >>> pprint.pprint(cert)
     {'OCSP': ('http://ocsp.digicert.com',),
      'caIssuers': ('http://cacerts.digicert.com/DigiCertSHA2ExtendedValidationServerCA.crt',),
      'crlDistributionPoints': ('http://crl3.digicert.com/sha2-ev-server-g1.crl',
                                'http://crl4.digicert.com/sha2-ev-server-g1.crl'),
      'issuer': ((('countryName', 'US'),),
                 (('organizationName', 'DigiCert Inc'),),
                 (('organizationalUnitName', 'www.digicert.com'),),
                 (('commonName', 'DigiCert SHA2 Extended Validation Server CA'),)),
      'notAfter': 'Sep  9 12:00:00 2016 GMT',
      'notBefore': 'Sep  5 00:00:00 2014 GMT',
      'serialNumber': '01BB6F00122B177F36CAB49CEA8B6B26',
      'subject': ((('businessCategory', 'Private Organization'),),
                  (('1.3.6.1.4.1.311.60.2.1.3', 'US'),),
                  (('1.3.6.1.4.1.311.60.2.1.2', 'Delaware'),),
                  (('serialNumber', '3359300'),),
                  (('streetAddress', '16 Allen Rd'),),
                  (('postalCode', '03894-4801'),),
                  (('countryName', 'US'),),
                  (('stateOrProvinceName', 'NH'),),
                  (('localityName', 'Wolfeboro'),),
                  (('organizationName', 'Python Software Foundation'),),
                  (('commonName', 'www.python.org'),)),
      'subjectAltName': (('DNS', 'www.python.org'),
                         ('DNS', 'python.org'),
                         ('DNS', 'pypi.org'),
                         ('DNS', 'docs.python.org'),
                         ('DNS', 'testpypi.org'),
                         ('DNS', 'bugs.python.org'),
                         ('DNS', 'wiki.python.org'),
                         ('DNS', 'hg.python.org'),
                         ('DNS', 'mail.python.org'),
                         ('DNS', 'packaging.python.org'),
                         ('DNS', 'pythonhosted.org'),
                         ('DNS', 'www.pythonhosted.org'),
                         ('DNS', 'test.pythonhosted.org'),
                         ('DNS', 'us.pycon.org'),
                         ('DNS', 'id.python.org')),
      'version': 3}

SSL チャネルは今や確立されて証明書が検証されているので、サーバとのお喋り
を続けることができます:

     >>> conn.sendall(b"HEAD / HTTP/1.0\r\nHost: linuxfr.org\r\n\r\n")
     >>> pprint.pprint(conn.recv(1024).split(b"\r\n"))
     [b'HTTP/1.1 200 OK',
      b'Date: Sat, 18 Oct 2014 18:27:20 GMT',
      b'Server: nginx',
      b'Content-Type: text/html; charset=utf-8',
      b'X-Frame-Options: SAMEORIGIN',
      b'Content-Length: 45679',
      b'Accept-Ranges: bytes',
      b'Via: 1.1 varnish',
      b'Age: 2188',
      b'X-Served-By: cache-lcy1134-LCY',
      b'X-Cache: HIT',
      b'X-Cache-Hits: 11',
      b'Vary: Cookie',
      b'Strict-Transport-Security: max-age=63072000; includeSubDomains',
      b'Connection: close',
      b'',
      b'']

このドキュメントの下の方の、 *note セキュリティで考慮すべき点: 31f1. に
関する議論を参照してください。


File: python.info,  Node: サーバサイドの処理,  Prev: クライアントサイドの処理,  Up: 使用例<27>

5.18.3.18 サーバサイドの処理
............................

サーバサイドの処理では、通常、サーバー証明書と秘密鍵がそれぞれファイルに
格納された形で必要です。最初に秘密鍵と証明書が保持されたコンテキストを作
成し、クライアントがあなたの信憑性をチェックできるようにします。そののち
にソケットを開き、ポートにバインドし、そのソケットの ‘listen()’ を呼び、
クライアントからの接続を待ちます。

     import socket, ssl

     context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
     context.load_cert_chain(certfile="mycertfile", keyfile="mykeyfile")

     bindsocket = socket.socket()
     bindsocket.bind(('myaddr.example.com', 10023))
     bindsocket.listen(5)

クライアントが接続してきた場合、 ‘accept()’ を呼んで新しいソケットを作成
し、接続のためにサーバサイドの SSL ソケットを、コンテキストの *note
SSLContext.wrap_socket(): 4ee. メソッドで作ります:

     while True:
         newsocket, fromaddr = bindsocket.accept()
         connstream = context.wrap_socket(newsocket, server_side=True)
         try:
             deal_with_client(connstream)
         finally:
             connstream.shutdown(socket.SHUT_RDWR)
             connstream.close()

そして、 ‘connstream’ からデータを読み、クライアントと切断する(あるいは
クライアントが切断してくる)まで何か処理をします。

     def deal_with_client(connstream):
         data = connstream.recv(1024)
         # empty data means the client is finished with us
         while data:
             if not do_something(connstream, data):
                 # we'll assume do_something returns False
                 # when we're finished with client
                 break
             data = connstream.recv(1024)
         # finished with client

そして新しいクライアント接続のために listen に戻ります。 (もちろん現実の
サーバは、おそらく個々のクライアント接続ごとに別のスレッドで処理するか、
ソケットを *note ノンブロッキングモード: 3305. にし、イベントループを使
うでしょう。)


File: python.info,  Node: ノンブロッキングソケットについての注意事項,  Next: メモリ BIO サポート<2>,  Prev: 使用例<27>,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.19 ノンブロッキングソケットについての注意事項
....................................................

SSL ソケットはノンブロッキングモードにおいては、普通のソケットとは少し違
った振る舞いをします。ですのでノンブロッキングソケットとともに使う場合、
いくつか気をつけなければならない事項があります:

   - ほとんどの *note SSLSocket: 8b8. のメソッドは I/O 操作がブロックす
     ると *note BlockingIOError: 102b. ではなく *note SSLWantWriteError:
     e33. か *note SSLWantReadError: e32. のどちらかを送出します。 *note
     SSLWantReadError: e32. は下層のソケットで読み出しが必要な場合に送出
     され、 *note SSLWantWriteError: e33. は下層のソケットで書き込みが必
     要な場合に送出されます。SSL ソケットに対して '書き込み' を試みると
     下層のソケットから最初に '読み出す' 必要があるかもしれず、SSL ソケ
     ットに対して '読み出し' を試みると下層のソケットに先に '書き込む' 必
     要があるかもしれないことに注意してください。

     バージョン 3.5 で変更: 以前の Python バージョンでは、
     ‘SSLSocket.send()’ メソッドは *note SSLWantWriteError: e33. または
     *note SSLWantReadError: e32. を送出するのではなく、ゼロを返していま
     した。

   - *note select(): d6d. 呼び出しは OS レベルでのソケットが読み出し可能
     (または書き込み可能)になったことを教えてくれますが、上位の SSL レイ
     ヤーでの十分なデータがあることを意味するわけではありません。例えば
     、SSL フレームの一部が届いただけかもしれません。ですから、
     ‘SSLSocket.recv()’ と ‘SSLSocket.send()’ の失敗を処理することに備え
     、ほかの *note select(): d6d. 呼び出し後にリトライしなければなりま
     せん。

   - 反対に、SSL レイヤーは独自の枠組みを持っているため、*note select():
     d6d. が気付かない読み出し可能なデータを SSL ソケットが持っている場
     合があります。したがって、入手可能な可能性のあるデータをすべて引き
     出すために最初に ‘SSLSocket.recv()’ を呼び出し、次にそれでもまだ必
     要な場合にだけ *note select(): d6d. 呼び出しでブロックすべきです。

     (当然のことながら、ほかのプリミティブ、例えば *note poll(): 2b0c. や
     *note selectors: b0. モジュール内のものを使う際にも似た但し書きが付
     きます)

   - SSL ハンドシェイクそのものがノンブロッキングになります: *note
     SSLSocket.do_handshake(): e36. メソッドは成功するまでリトライしなけ
     ればなりません。 *note select(): d6d. を用いてソケットの準備が整う
     のを待つためには、およそ以下のようにします:

          while True:
              try:
                  sock.do_handshake()
                  break
              except ssl.SSLWantReadError:
                  select.select([sock], [], [])
              except ssl.SSLWantWriteError:
                  select.select([], [sock], [])

参考
....

*note asyncio: 8. モジュールは *note ノンブロッキング SSL ソケット:
3305. をサポートし、より高いレベルの API を提供しています。 *note
selectors: b0. モジュールを使ってイベントを poll し、 *note
SSLWantWriteError: e33, *note SSLWantReadError: e32, *note
BlockingIOError: 102b. 例外を処理します。SSL ハンドシェイクも非同期に実
行します。


File: python.info,  Node: メモリ BIO サポート<2>,  Next: SSL セッション,  Prev: ノンブロッキングソケットについての注意事項,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.20 メモリ BIO サポート
.............................

Added in version 3.5.

Python 2.6 で SSL モジュールが導入されて以降、*note SSLSocket: 8b8. クラ
スは、以下の互いに関連するが別々の機能を提供してきました。

   - SSL プロトコル処理

   - ネットワーク IO

ネットワーク IO API は、*note socket.socket: d6e. が提供するものと同じで
す。*note SSLSocket: 8b8. も、そのクラスから継承しています。これにより、
SSL ソケットは標準のソケットをそっくりそのまま置き換えるものとして使用で
きるため、既存のアプリケーションを SSL に対応させるのが非常に簡単になり
ます。

SSL プロトコルの処理とネットワーク IO を組み合わせた場合、通常は問題なく
動作しますが、問題が発生する場合があります。一例を挙げると、非同期 IO フ
レームワークが別の多重化モデルを使用する場合、これは *note
socket.socket: d6e. と内部 OpenSSL ソケット IO ルーティンが想定する「フ
ァイル記述子上の select/poll」モデル（準備状態ベース）とは異なります。こ
れは、このモデルが非効率的になる Windows などのプラットフォームに主に該
当します。そのため、スコープを限定した *note SSLSocket: 8b8. の変種、
*note SSLObject: b4f. が提供されています。

 -- クラス: ssl.SSLObject

     ネットワーク IO メソッドを含まない SSL プロトコルインスタンスを表す
     、スコープを限定した *note SSLSocket: 8b8. の変種です。一般的にこ、
     のクラスを使用するのは、メモリバッファを通じて SSL のための非同期
     IO を実装するフレームワーク作成者です。

     このクラスは、OpenSSL が実装する低水準 SSL オブジェクトの上にインタ
     ーフェースを実装します。このオブジェクトは SSL 接続の状態をキャプチ
     ャしますが、ネットワーク IO 自体は提供しません。IO は、OpenSSL の
     IO 抽象レイヤである別の「BIO」オブジェクトを通じて実行する必要があ
     ります。

     このクラスには公開されたコンストラクタがありません。*note
     SSLObject: b4f. インスタンスは、 *note wrap_bio(): b50. メソッドを
     使用して作成しなければなりません。このメソッドは、*note SSLObject:
     b4f. インスタンスを作成し、2 つの BIO に束縛します。'incoming' BIO
     は、Python から SSL プロトコルインスタンスにデータを渡すために使用
     され、'outgoing' BIO は、データを反対向きに渡すために使用されます。

     次のメソッドがサポートされています:

        - *note context: 333c.

        - *note server_side: 333e.

        - *note server_hostname: b4d.

        - *note session: 1512.

        - *note session_reused: 333f.

        - *note read(): e37.

        - *note write(): e38.

        - *note getpeercert(): f84.

        - *note get_verified_chain(): 153f.

        - *note get_unverified_chain(): 1540.

        - *note selected_alpn_protocol(): e2e.

        - *note selected_npn_protocol(): 840.

        - *note cipher(): 3236.

        - *note shared_ciphers(): e35.

        - *note compression(): 1118.

        - *note pending(): 333d.

        - *note do_handshake(): e36.

        - *note verify_client_post_handshake(): a00.

        - *note unwrap(): 333b.

        - *note get_channel_binding(): 1117.

        - *note version(): e31.

     *note SSLSocket: 8b8. と比較すると、このオブジェクトでは以下の機能
     が不足しています。

        - Any form of network IO; ‘recv()’ and ‘send()’ read and write
          only to the underlying *note MemoryBIO: e2b. buffers.

        - 'do_handshake_on_connect' 機構はありません。必ず手動で *note
          do_handshake(): e36. を呼んで、ハンドシェイクを開始する必要が
          あります。

        - 'suppress_ragged_eofs' は処理されません。プロトコルに違反する
          ファイル末尾状態は、 *note SSLEOFError: 16af. 例外を通じて報告
          されます。

        - *note unwrap(): 333b. メソッドの呼び出しは、下層のソケットを返
          す SSL ソケットとは異なり、何も返しません。

        - *note SSLContext.set_servername_callback(): f83. に渡される
          'server_name_callback' コールバックは、1 つ目の引数として
          *note SSLSocket: 8b8. インスタンスではなく *note SSLObject:
          b4f. インスタンスを受け取ります。

     *note SSLObject: b4f. の使用に関する注意:

        - *note SSLObject: b4f. 上のすべての IO は *note non-blocking:
          3305. です。例えば、*note read(): e37. は入力 BIO が持つデータ
          よりも多くのデータを必要とする場合、*note SSLWantReadError:
          e32. を送出します。

     バージョン 3.7 で変更: *note SSLObject: b4f. instances must be
     created with *note wrap_bio(): b50.  In earlier versions, it was
     possible to create instances directly.  This was never documented
     or officially supported.

SSLObject は、メモリバッファを使用して外界と通信します。*note MemoryBIO:
e2b. クラスは、以下のように OpenSSL メモリ BIO (Basic IO) オブジェクトを
ラップし、この目的に使用できるメモリバッファを提供します。

 -- クラス: ssl.MemoryBIO

     Python と SSL プロトコルインスタンス間でデータをやり取りするために
     使用できるメモリバッファ。

      -- の属性: pending

          現在メモリバッファ中にあるバイト数を返します。

      -- の属性: eof

          メモリ BIOが現在ファイルの末尾にあるかを表す真偽値です。

      -- メソッド: read (n=-1)

          メモリバッファから最大 'n' 読み取ります。'n' が指定されていな
          いか、負値の場合、すべてのバイトが返されます。

      -- メソッド: write (buf)

          'buf' からメモリ BIO にバイトを書き込みます。'buf' 引数は、バ
          ッファプロトコルをサポートするオブジェクトでなければなりません
          。

          戻り値は、書き込まれるバイト数であり、常に 'buf' の長さと等し
          くなります。

      -- メソッド: write_eof ()

          EOF マーカーをメモリ BIO に書き込みます。このメソッドが呼び出
          された後に *note write(): 3359. を呼ぶことはできません。*note
          eof: 3357. 属性は、バッファ内のすべてのデータが読み出された後
          に True になります。


File: python.info,  Node: SSL セッション,  Next: セキュリティで考慮すべき点<3>,  Prev: メモリ BIO サポート<2>,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.21 SSL セッション
........................

Added in version 3.6.

 -- クラス: ssl.SSLSession

     *note session: 1512. が使用するセッションオブジェクトです。

      -- の属性: id

      -- の属性: time

      -- の属性: timeout

      -- の属性: ticket_lifetime_hint

      -- の属性: has_ticket


File: python.info,  Node: セキュリティで考慮すべき点<3>,  Next: TLS 1 3,  Prev: SSL セッション,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.22 セキュリティで考慮すべき点
....................................

* Menu:

* 最善のデフォルト値::
* 手動での設定::
* マルチプロセス化::


File: python.info,  Node: 最善のデフォルト値,  Next: 手動での設定,  Up: セキュリティで考慮すべき点<3>

5.18.3.23 最善のデフォルト値
............................

'クライアントでの使用' では、セキュリティポリシーによる特殊な要件がない
限りは、 *note create_default_context(): 13b. 関数を使用して SSL コンテ
キストを作成することを強くお勧めします。この関数は、システムの信頼済み
CA 証明書をロードし、証明書の検証とホスト名のチェックを有効化し、十分に
セキュアなプロトコルと暗号を選択しようとします。

例として、 *note smtplib.SMTP: 8fb. クラスを使用して SMTP サーバーに対し
て信頼できるセキュアな接続を行う方法を以下に示します:

     >>> import ssl, smtplib
     >>> smtp = smtplib.SMTP("mail.python.org", port=587)
     >>> context = ssl.create_default_context()
     >>> smtp.starttls(context=context)
     (220, b'2.0.0 Ready to start TLS')

接続にクライアントの証明書が必要な場合、 *note
SSLContext.load_cert_chain(): 275. によって追加できます。

対照的に、自分自身で *note SSLContext: 274. クラスのコンストラクタを呼び
出すことによって SSL コンテキストを作ると、デフォルトでは証明書検証もホ
スト名チェックも有効になりません。自分で設定を行う場合は、十分なセキュリ
ティレベルを達成するために、以下のパラグラフをお読みください。


File: python.info,  Node: 手動での設定,  Next: マルチプロセス化,  Prev: 最善のデフォルト値,  Up: セキュリティで考慮すべき点<3>

5.18.3.24 手動での設定
......................

* Menu:

* 証明書の検証::
* プロトコルのバージョン::
* 暗号の選択::


File: python.info,  Node: 証明書の検証,  Next: プロトコルのバージョン,  Up: 手動での設定

5.18.3.25 証明書の検証
......................

When calling the *note SSLContext: 274. constructor directly, *note
CERT_NONE: 3311. is the default.  Since it does not authenticate the
other peer, it can be insecure, especially in client mode where most of
the time you would like to ensure the authenticity of the server you're
talking to.  Therefore, when in client mode, it is highly recommended to
use *note CERT_REQUIRED: 3300.  However, it is in itself not sufficient;
you also have to check that the server certificate, which can be
obtained by calling *note SSLSocket.getpeercert(): f84, matches the
desired service.  For many protocols and applications, the service can
be identified by the hostname.  This common check is automatically
performed when *note SSLContext.check_hostname: 3313. is enabled.

バージョン 3.7 で変更: Hostname matchings is now performed by OpenSSL.
Python no longer uses ‘match_hostname()’.

サーバモードにおいて、(より上位のレベルでの認証メカニズムではなく) SSL レ
イヤーを使ってあなたのクライアントを認証したいならば、 *note
CERT_REQUIRED: 3300. を指定して同じようにクライアントの証明書を検証すべ
きでしょう。


File: python.info,  Node: プロトコルのバージョン,  Next: 暗号の選択,  Prev: 証明書の検証,  Up: 手動での設定

5.18.3.26 プロトコルのバージョン
................................

SSL バージョン 2 と 3 は安全性に欠けると考えられており、使用するのは危険
です。クライアントとサーバ間の互換性を最大限に確保したい場合、プロトコル
バージョンとして *note PROTOCOL_TLS_CLIENT: 83e. または *note
PROTOCOL_TLS_SERVER: 83f. を使用してください。 SSLv2 と SSLv3 はデフォル
トで無効になっています。

     >>> client_context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
     >>> client_context.minimum_version = ssl.TLSVersion.TLSv1_3
     >>> client_context.maximum_version = ssl.TLSVersion.TLSv1_3

The SSL context created above will only allow TLSv1.3 and later (if
supported by your system) connections to a server.  *note
PROTOCOL_TLS_CLIENT: 83e. implies certificate validation and hostname
checks by default.  You have to load certificates into the context.


File: python.info,  Node: 暗号の選択,  Prev: プロトコルのバージョン,  Up: 手動での設定

5.18.3.27 暗号の選択
....................

If you have advanced security requirements, fine-tuning of the ciphers
enabled when negotiating a SSL session is possible through the *note
SSLContext.set_ciphers(): 3342. method.  Starting from Python 3.2.3, the
ssl module disables certain weak ciphers by default, but you may want to
further restrict the cipher choice.  Be sure to read OpenSSL's
documentation about the cipher list format(1).  If you want to check
which ciphers are enabled by a given cipher list, use *note
SSLContext.get_ciphers(): cac. or the ‘openssl ciphers’ command on your
system.

   ---------- Footnotes ----------

   (1) https://docs.openssl.org/1.1.1/man1/ciphers/#cipher-list-format


File: python.info,  Node: マルチプロセス化,  Prev: 手動での設定,  Up: セキュリティで考慮すべき点<3>

5.18.3.28 マルチプロセス化
..........................

If using this module as part of a multi-processed application (using,
for example the *note multiprocessing: 86. or *note concurrent.futures:
1a. modules), be aware that OpenSSL's internal random number generator
does not properly handle forked processes.  Applications must change the
PRNG state of the parent process if they use any SSL feature with *note
os.fork(): 17c.  Any successful call of *note RAND_add(): 330b. or *note
RAND_bytes(): 4ed. is sufficient.


File: python.info,  Node: TLS 1 3,  Prev: セキュリティで考慮すべき点<3>,  Up: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー

5.18.3.29 TLS 1.3
.................

Added in version 3.7.

The TLS 1.3 protocol behaves slightly differently than previous version
of TLS/SSL. Some new TLS 1.3 features are not yet available.

   - TLS 1.3 uses a disjunct set of cipher suites.  All AES-GCM and
     ChaCha20 cipher suites are enabled by default.  The method *note
     SSLContext.set_ciphers(): 3342. cannot enable or disable any TLS
     1.3 ciphers yet, but *note SSLContext.get_ciphers(): cac. returns
     them.

   - Session tickets are no longer sent as part of the initial handshake
     and are handled differently.  *note SSLSocket.session: 1512. and
     *note SSLSession: cab. are not compatible with TLS 1.3.

   - Client-side certificates are also no longer verified during the
     initial handshake.  A server can request a certificate at any time.
     Clients process certificate requests while they send or receive
     application data from the server.

   - TLS 1.3 features like early data, deferred TLS client cert request,
     signature algorithm configuration, and rekeying are not supported
     yet.

参考
....

*note socket.socket: d6e. クラス

     下位レイヤーの *note socket: b8. クラスのドキュメント

SSL/TLS Strong Encryption: An Introduction(1)

     Apache HTTPサーバのドキュメンテーションのイントロ

RFC 1422: Privacy Enhancement for Internet Electronic Mail: Part II: Certificate-Based Key Management(2)

     Steve Kent

RFC 4086: Randomness Requirements for Security(3)

     Donald E., Jeffrey I. Schiller

RFC 5280: Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile(4)

     D. Cooper

RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2(5)

     T. Dierks et.  al.

RFC 6066: Transport Layer Security (TLS) Extensions(6)

     D. Eastlake

IANA TLS: Transport Layer Security (TLS) Parameters(7)

     IANA

RFC 7525: Recommendations for Secure Use of Transport Layer Security (TLS) and Datagram Transport Layer Security (DTLS)(8)

     IETF

Mozilla's Server Side TLS recommendations(9)

     Mozilla

   ---------- Footnotes ----------

   (1) https://httpd.apache.org/docs/trunk/en/ssl/ssl_intro.html

   (2) https://datatracker.ietf.org/doc/html/rfc1422.html

   (3) https://datatracker.ietf.org/doc/html/rfc4086.html

   (4) https://datatracker.ietf.org/doc/html/rfc5280.html

   (5) https://datatracker.ietf.org/doc/html/rfc5246.html

   (6) https://datatracker.ietf.org/doc/html/rfc6066.html

   (7) 
https://www.iana.org/assignments/tls-parameters/tls-parameters.xml

   (8) https://datatracker.ietf.org/doc/html/rfc7525.html

   (9) https://wiki.mozilla.org/Security/Server_Side_TLS


File: python.info,  Node: select --- I/O 完了の待機,  Next: selectors --- 高水準の I/O 多重化,  Prev: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー,  Up: ネットワーク通信とプロセス間通信

5.18.4 ‘select’ -- I/O 完了の待機
---------------------------------

__________________________________________________________________

このモジュールでは、ほとんどのオペレーティングシステムで利用可能な
‘select()’ および ‘poll()’ 関数、Solaris やその派生で利用可能な
‘devpoll()’ 、Linux 2.5+ で利用可能な ‘epoll()’ 、多くのBSDで利用可能な
‘kqueue()’ 関数に対するアクセスを提供しています。 Windows 上ではソケット
に対してしか動作しないので注意してください; その他のオペレーティングシス
テムでは、他のファイル形式でも (特に Unixではパイプにも) 動作します。通
常のファイルに対して適用し、最後にファイルを読み出した時から内容が増えて
いるかを決定するために使うことはできません。

     注釈: *note selectors: b0. モジュールにより、*note select: af. モジ
     ュールプリミティブに基づく高水準かつ効率的な I/O の多重化が行うこと
     が出来ます。 OS レベルプリミティブを使用した正確な制御を求めない限
     り、代わりに *note selectors: b0. を使用することが推奨されます。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

このモジュールは以下を定義します:

 -- 例外: select.error

     *note OSError: 3f0. の非推奨のエイリアスです。

     バージョン 3.3 で変更: PEP 3151(1) に基づき、このクラスは *note
     OSError: 3f0. のエイリアスになりました。

 -- の関数: select.devpoll ()

     (Solaris およびその派生でのみサポートされています) ‘/dev/poll’ ポー
     リングオブジェクトを返します。 ポーリングオブジェクトが提供している
     メソッドについては *note ポーリングオブジェクト: 336b. 節を参照して
     ください。

     ‘devpoll()’ オブジェクトはインスタンス化時に許されるファイル記述子
     の数にリンクされます。プログラムがこの値を減らす場合 ‘devpoll()’ は
     失敗します。プログラムがこの値を増やす場合 ‘devpoll()’ は有効なファ
     イル記述子の不完全なリストを返すことがあります。

     新しいファイル記述子は *note 継承不可: ec4. です。

     Added in version 3.3.

     バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

 -- の関数: select.epoll (sizehint=-1, flags=0)

     (Linux 2.5.44 以降でのみサポート) エッジポーリング (edge polling) オ
     ブジェクトを返します。 このオブジェクトは、 I/O イベントのエッジト
     リガもしくはレベルトリガインターフェースとして使えます。

     'sizehint' informs epoll about the expected number of events to be
     registered.  It must be positive, or ‘-1’ to use the default.  It
     is only used on older systems where ‘epoll_create1()’ is not
     available; otherwise it has no effect (though its value is still
     checked).

     'flags' is deprecated and completely ignored.  However, when
     supplied, its value must be ‘0’ or ‘select.EPOLL_CLOEXEC’,
     otherwise ‘OSError’ is raised.

     エッジポーリングオブジェクトが提供しているメソッドについては *note
     エッジおよびレベルトリガポーリング (epoll) オブジェクト: 336c. 節を
     参照してください。

     ‘epoll’ オブジェクトはコンテキストマネジメントプロトコルをサポート
     しています。 *note with: 59c. 文内で使用された場合、新たなファイル
     記述子はブロックの最後で自動的に閉じられます。

     新しいファイル記述子は *note 継承不可: ec4. です。

     バージョン 3.3 で変更: 'flags' 引数が追加されました。

     バージョン 3.4 で変更: *note with: 59c. 文のサポートが追加されまし
     た。新しいファイル記述子が継承不可になりました。

     バージョン 3.4 で非推奨: 'flags' パラメータ。 現在ではデフォルトで
     ‘select.EPOLL_CLOEXEC’ が使われます。 ファイルディスクリプタを継承
     可能にするには *note os.set_inheritable(): ec6. を使ってください。

 -- の関数: select.poll ()

     (全てのオペレーティングシステムでサポートされているわけではありませ
     ん) ポーリングオブジェクトを返します。このオブジェクトはファイル記
     述子を登録したり登録解除したりすることができ、ファイル記述子に対す
     る I/O イベント発生をポーリングすることができます; ポーリングオブジ
     ェクトが提供しているメソッドについては *note
     ポーリングオブジェクト: 336b. 節を参照してください。

 -- の関数: select.kqueue ()

     (BSD でのみサポート) カーネルキュー(kernel queue)オブジェクトを返し
     ます。カーネルキューオブジェクトが提供しているメソッドについては、
     *note kqueue オブジェクト: 336d. 節を参照してください。

     新しいファイル記述子は *note 継承不可: ec4. です。

     バージョン 3.4 で変更: 新しいファイル記述子が継承不可になりました。

 -- の関数: select.kevent (ident, filter=KQ_FILTER_READ,
          flags=KQ_EV_ADD, fflags=0, data=0, udata=0)

     (BSD でのみサポート) カーネルイベント(kernel event)オブジェクトを返
     します。カーネルイベントオブジェクトが提供しているメソッドについて
     は、 *note kevent オブジェクト: 336f. 節を参照してください。

 -- の関数: select.select (rlist, wlist, xlist[, timeout])

     This is a straightforward interface to the Unix ‘select()’ system
     call.  The first three arguments are iterables of 'waitable
     objects': either integers representing file descriptors or objects
     with a parameterless method named *note fileno(): 27a6. returning
     such an integer:

        * 'rlist': 読み込み可能になるまで待機

        * 'wlist': 書き込み可能になるまで待機

        * 'xlist': "例外状態 (exceptional condition)" になるまで待機 ("例
          外状態" については、システムのマニュアルページを参照してくださ
          い)

     Empty iterables are allowed, but acceptance of three empty
     iterables is platform-dependent.  (It is known to work on Unix but
     not on Windows.)  The optional 'timeout' argument specifies a
     time-out as a floating-point number in seconds.  When the 'timeout'
     argument is omitted the function blocks until at least one file
     descriptor is ready.  A time-out value of zero specifies a poll and
     never blocks.

     戻り値は準備完了状態のオブジェクトからなる 3 つのリストです: したが
     ってこのリストはそれぞれ関数の最初の 3 つの引数のサブセットになりま
     す。ファイル記述子のいずれも準備完了にならないままタイムアウトした
     場合、3 つの空のリストが返されます。

     イテラブルの中に含めることのできるオブジェクトは Python *note
     ファイルオブジェクト: 1193. (例えば ‘sys.stdin’ や、 *note open():
     4e5. または *note os.popen(): a55. が返すオブジェクト)、 *note
     socket.socket(): d6e. が返すソケットオブジェクトです。 'ラッパー
     <wrapper>' クラスを自分で定義することもできます。この場合、適切な
     (まったくデタラメな数ではなく本物のファイル記述子を返す) *note
     fileno(): 27a6. メソッドを持つ必要があります。

          注釈: 
          File objects on Windows are not acceptable, but sockets are.
          On Windows, the underlying ‘select()’ function is provided by
          the WinSock library, and does not handle file descriptors that
          don't originate from WinSock.

     バージョン 3.5 で変更: この関数は、シグナルによって中断された時に、
     *note InterruptedError: d55. を上げる代わりに再計算されたタイムアウ
     トによってリトライするようになりました。ただし、シグナルハンドラが
     例外を起こした場合を除きます (この論理的根拠については PEP 475(2) を
     見てください)。

 -- の属性: select.PIPE_BUF

     The minimum number of bytes which can be written without blocking
     to a pipe when the pipe has been reported as ready for writing by
     *note select(): d6d, ‘poll()’ or another interface in this module.
     This doesn't apply to other kind of file-like objects such as
     sockets.

     この値は POSIX により少なくとも512であることが保証されています。

     *note Availability: 1cbe.: Unix

     Added in version 3.2.

* Menu:

* /dev/poll ポーリングオブジェクト::
* エッジおよびレベルトリガポーリング (epoll) オブジェクト: エッジおよびレベルトリガポーリング epoll オブジェクト.
* ポーリングオブジェクト::
* kqueue オブジェクト::
* kevent オブジェクト::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3151/

   (2) https://peps.python.org/pep-0475/


File: python.info,  Node: /dev/poll ポーリングオブジェクト,  Next: エッジおよびレベルトリガポーリング epoll オブジェクト,  Up: select --- I/O 完了の待機

5.18.4.1 ‘/dev/poll’ ポーリングオブジェクト
...........................................

Solaris and derivatives have ‘/dev/poll’.  While ‘select()’ is
'O'('highest file descriptor') and ‘poll()’ is 'O'('number of file
descriptors'), ‘/dev/poll’ is 'O'('active file descriptors').

‘/dev/poll’ behaviour is very close to the standard ‘poll()’ object.

 -- メソッド: devpoll.close ()

     ポーリングオブジェクトのファイル記述子を閉じます。

     Added in version 3.4.

 -- の属性: devpoll.closed

     ポーリングオブジェクトが閉じている場合 ‘True’ です。

     Added in version 3.4.

 -- メソッド: devpoll.fileno ()

     ポーリングオブジェクトのファイル記述子番号を返します。

     Added in version 3.4.

 -- メソッド: devpoll.register (fd[, eventmask])

     ファイル記述子をポーリングオブジェクトに登録します。これ以降の
     *note poll(): 2b0c. メソッド呼び出しでは、そのファイル記述子に処理
     待ち中の I/O イベントがあるかどうかを監視します。 'fd' は整数か、整
     数値を返す *note fileno(): 27a6. メソッドを持つオブジェクトを取りま
     す。ファイルオブジェクトも ‘fileno()’ を実装しているので、引数とし
     て使うことができます。

     'eventmask' is an optional bitmask describing the type of events
     you want to check for.  The constants are the same that with
     ‘poll()’ object.  The default value is a combination of the
     constants ‘POLLIN’, ‘POLLPRI’, and ‘POLLOUT’.

          警告: Registering a file descriptor that's already registered
          is not an error, but the result is undefined.  The appropriate
          action is to unregister or modify it first.  This is an
          important difference compared with ‘poll()’.

 -- メソッド: devpoll.modify (fd[, eventmask])

     このメソッドは *note unregister(): 3374. に続いて *note register():
     3372. を行います。 同じことを明示的に行うよりも (少し) 効率的です。

 -- メソッド: devpoll.unregister (fd)

     ポーリングオブジェクトによって追跡中のファイル記述子を登録解除しま
     す。 *note register(): 3372. メソッドと同様に、 'fd' は整数か、整数
     値を返す *note fileno(): 27a6. メソッドを持つオブジェクトを取ります
     。

     登録されていないファイル記述子の削除を試みるのは安全に無視されます
     。

 -- メソッド: devpoll.poll ([timeout])

     登録されたファイル記述子に対してポーリングを行い、報告すべき I/O イ
     ベントまたはエラーの発生したファイル記述子毎に 2 要素のタプル ‘(fd,
     event)’ からなるリストを返します。リストは空になることもあります。
     'fd' はファイル記述子で、 'event' は該当するファイル記述子について
     報告されたイベントを表すビットマスクです -- 例えば ‘POLLIN’ は入力
     待ちを示し、 ‘POLLOUT’ はファイル記述子に対する書き込みが可能を示す
     、などです。空のリストは呼び出しがタイムアウトしたか、報告すべきイ
     ベントがどのファイル記述子でも発生しなかったことを示します。
     'timeout' が与えられた場合、処理を戻すまで待機する時間の長さをミリ
     秒単位で指定します。 'timeout' が省略されたり、 -1 であったり、ある
     いは *note None: 641. の場合、そのポーリングオブジェクトが監視して
     いる何らかのイベントが発生するまでブロックします。

     バージョン 3.5 で変更: この関数は、シグナルによって中断された時に、
     *note InterruptedError: d55. を上げる代わりに再計算されたタイムアウ
     トによってリトライするようになりました。ただし、シグナルハンドラが
     例外を起こした場合を除きます (この論理的根拠については PEP 475(1) を
     見てください)。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/


File: python.info,  Node: エッジおよびレベルトリガポーリング epoll オブジェクト,  Next: ポーリングオブジェクト,  Prev: /dev/poll ポーリングオブジェクト,  Up: select --- I/O 完了の待機

5.18.4.2 エッジおよびレベルトリガポーリング (epoll) オブジェクト
................................................................

     ‘https://linux.die.net/man/4/epoll’

     'eventmask'

     定数                          意味
                                   
     ----------------------------------------------------------------------------------
                                   
     ‘EPOLLIN’                     読み込み可能
                                   
                                   
     ‘EPOLLOUT’                    書き込み可能
                                   
                                   
     ‘EPOLLPRI’                    緊急の読み出しデータ
                                   
                                   
     ‘EPOLLERR’                    設定された fd にエラー状態が発生した
                                   
                                   
     ‘EPOLLHUP’                    設定された fd がハングアップした
                                   
                                   
     ‘EPOLLET’                     エッジトリガ動作に設定する。デフォルトではレベル
                                   トリガ動作
                                   
                                   
     ‘EPOLLONESHOT’                1ショット動作に設定する。1回イベントが取り出され
                                   たら、その fd が内部で無効になる
                                   
                                   
     ‘EPOLLEXCLUSIVE’              関連づけられた fd にイベントがある場合、1 つの
                                   epoll オブジェクトのみを起こします。デフォルトで
                                   は (このフラグが設定されていない場合には)、fd に
                                   対してポーリングするすべての epoll オブジェクトを
                                   起こします。
                                   
                                   
     ‘EPOLLRDHUP’                  ストリームソケットの他端が接続を切断したか、接続
                                   の書き込み側のシャットダウンを行った。
                                   
                                   
     ‘EPOLLRDNORM’                 ‘EPOLLIN’ と同じ
                                   
                                   
     ‘EPOLLRDBAND’                 優先データバンドを読み込める。
                                   
                                   
     ‘EPOLLWRNORM’                 ‘EPOLLOUT’ と同じ
                                   
                                   
     ‘EPOLLWRBAND’                 優先データに書き込みできる。
                                   
                                   
     ‘EPOLLMSG’                    無視される。
                                   

     Added in version 3.6: ‘EPOLLEXCLUSIVE’ was added.  It's only
     supported by Linux Kernel 4.5 or later.

 -- メソッド: epoll.close ()

     epoll オブジェクトの制御用ファイル記述子を閉じます。

 -- の属性: epoll.closed

     epoll オブジェクトが閉じている場合 True です。

 -- メソッド: epoll.fileno ()

     制御用ファイル記述子の番号を返します。

 -- メソッド: epoll.fromfd (fd)

     'fd' から epoll オブジェクトを作成します。

 -- メソッド: epoll.register (fd[, eventmask])

     epoll オブジェクトにファイル記述子 'fd' を登録します。

 -- メソッド: epoll.modify (fd, eventmask)

     登録されたファイル記述子変更します。

 -- メソッド: epoll.unregister (fd)

     epoll オブジェクトから登録されたファイル記述子 'fd' を削除します。

     バージョン 3.9 で変更: The method no longer ignores the *note
     EBADF: 929. error.

 -- メソッド: epoll.poll (timeout=None, maxevents=-1)

     イベントを待機します。'timeout' はタイムアウト時間で、単位は秒
     (float型) です。

     バージョン 3.5 で変更: この関数は、シグナルによって中断された時に、
     *note InterruptedError: d55. を上げる代わりに再計算されたタイムアウ
     トによってリトライするようになりました。ただし、シグナルハンドラが
     例外を起こした場合を除きます (この論理的根拠については PEP 475(1) を
     見てください)。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/


File: python.info,  Node: ポーリングオブジェクト,  Next: kqueue オブジェクト,  Prev: エッジおよびレベルトリガポーリング epoll オブジェクト,  Up: select --- I/O 完了の待機

5.18.4.3 ポーリングオブジェクト
...............................

The ‘poll()’ system call, supported on most Unix systems, provides
better scalability for network servers that service many, many clients
at the same time.  ‘poll()’ scales better because the system call only
requires listing the file descriptors of interest, while ‘select()’
builds a bitmap, turns on bits for the fds of interest, and then
afterward the whole bitmap has to be linearly scanned again.  ‘select()’
is 'O'('highest file descriptor'), while ‘poll()’ is 'O'('number of file
descriptors').

 -- メソッド: poll.register (fd[, eventmask])

     ファイル記述子をポーリングオブジェクトに登録します。これ以降の
     *note poll(): 2b0c. メソッド呼び出しでは、そのファイル記述子に処理
     待ち中の I/O イベントがあるかどうかを監視します。 'fd' は整数か、整
     数値を返す *note fileno(): 27a6. メソッドを持つオブジェクトを取りま
     す。ファイルオブジェクトも ‘fileno()’ を実装しているので、引数とし
     て使うことができます。

     'eventmask' はオプションのビットマスクで、どの種類の I/O イベントを
     監視したいかを記述します。この値は以下の表で述べる定数 ‘POLLIN’ 、
     ‘POLLPRI’ 、および ‘POLLOUT’ の組み合わせにすることができます。ビッ
     トマスクを指定しない場合、標準の値が使われ、 3 種類のイベント全てに
     対して監視が行われます。

     定数                    意味
                             
     -----------------------------------------------------------------------
                             
     ‘POLLIN’                読み出し可能なデータが存在する
                             
                             
     ‘POLLPRI’               緊急の読み出し可能なデータが存在する
                             
                             
     ‘POLLOUT’               書き出しの準備ができている: 書き出し処理がブ
                             ロックしない
                             
                             
     ‘POLLERR’               何らかのエラー状態
                             
                             
     ‘POLLHUP’               ハングアップ
                             
                             
     ‘POLLRDHUP’             ストリームソケットの他端が接続を切断したか、
                             接続の書き込み側のシャットダウンを行った。
                             
                             
     ‘POLLNVAL’              無効な要求: 記述子が開かれていない
                             

     登録済みのファイル記述子を登録してもエラーにはならず、一度だけ登録
     した場合と同じ効果になります。

 -- メソッド: poll.modify (fd, eventmask)

     登録されているファイル記述子 'fd' を変更する。これは、
     ‘register(fd, eventmask)’ と同じ効果を持ちます。登録されていないフ
     ァイル記述子に対してこのメソッドを呼び出すと、 errno ‘ENOENT’ で
     *note OSError: 3f0. 例外が発生します。

 -- メソッド: poll.unregister (fd)

     ポーリングオブジェクトによって追跡中のファイル記述子を登録解除しま
     す。 *note register(): 337c. メソッドと同様に、 'fd' は整数か、整数
     値を返す *note fileno(): 27a6. メソッドを持つオブジェクトを取ります
     。

     登録されていないファイル記述子を登録解除しようとすると *note
     KeyError: 31d. 例外が送出されます。

 -- メソッド: poll.poll ([timeout])

     登録されたファイル記述子に対してポーリングを行い、報告すべき I/O イ
     ベントまたはエラーの発生したファイル記述子毎に 2 要素のタプル ‘(fd,
     event)’ からなるリストを返します。リストは空になることもあります。
     'fd' はファイル記述子で、 'event' は該当するファイル記述子について
     報告されたイベントを表すビットマスクです -- 例えば ‘POLLIN’ は入力
     待ちを示し、 ‘POLLOUT’ はファイル記述子に対する書き込みが可能を示す
     、などです。空のリストは呼び出しがタイムアウトしたか、報告すべきイ
     ベントがどのファイル記述子でも発生しなかったことを示します。
     'timeout' が与えられた場合、処理を戻すまで待機する時間の長さをミリ
     秒単位で指定します。 'timeout' が省略されたり、負の値であったり、あ
     るいは *note None: 641. の場合、そのポーリングオブジェクトが監視し
     ている何らかのイベントが発生するまでブロックします。

     バージョン 3.5 で変更: この関数は、シグナルによって中断された時に、
     *note InterruptedError: d55. を上げる代わりに再計算されたタイムアウ
     トによってリトライするようになりました。ただし、シグナルハンドラが
     例外を起こした場合を除きます (この論理的根拠については PEP 475(1) を
     見てください)。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/


File: python.info,  Node: kqueue オブジェクト,  Next: kevent オブジェクト,  Prev: ポーリングオブジェクト,  Up: select --- I/O 完了の待機

5.18.4.4 kqueue オブジェクト
............................

 -- メソッド: kqueue.close ()

     kqueue オブジェクトの制御用ファイル記述子を閉じる。

 -- の属性: kqueue.closed

     kqueue オブジェクトが閉じている場合 ‘True’ です。

 -- メソッド: kqueue.fileno ()

     制御用ファイル記述子の番号を返します。

 -- メソッド: kqueue.fromfd (fd)

     与えられたファイル記述子から、kqueue オブジェクトを作成する。

 -- メソッド: kqueue.control (changelist, max_events[, timeout]) ->
          eventlist

     kevent に対する低水準のインターフェース

        - 'changelist' は kevent オブジェクトのイテラブルまたは ‘None’

        - 'max_events' は 0 または正の整数

        - timeout in seconds (floats possible); the default is ‘None’,
          to wait forever

     バージョン 3.5 で変更: この関数は、シグナルによって中断された時に、
     *note InterruptedError: d55. を上げる代わりに再計算されたタイムアウ
     トによってリトライするようになりました。ただし、シグナルハンドラが
     例外を起こした場合を除きます (この論理的根拠については PEP 475(1) を
     見てください)。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/


File: python.info,  Node: kevent オブジェクト,  Prev: kqueue オブジェクト,  Up: select --- I/O 完了の待機

5.18.4.5 kevent オブジェクト
............................

‘https://man.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2’

 -- の属性: kevent.ident

     イベントを特定するための値。この値は、フィルタにもよりますが、大抵
     の場合はファイル記述子です。コンストラクタでは、 ident として、整数
     値か *note fileno(): 27a6. メソッドを持ったオブジェクトを渡せます。
     kevent は内部で整数値を保存します。

 -- の属性: kevent.filter

     カーネルフィルタの名前。

     定数                            意味
                                     
     ----------------------------------------------------------------------------------
                                     
     ‘KQ_FILTER_READ’                記述子を受け取り、読み込めるデータが存在する時
                                     に戻る
                                     
                                     
     ‘KQ_FILTER_WRITE’               記述子を受け取り、書き込み可能な時に戻る
                                     
                                     
     ‘KQ_FILTER_AIO’                 AIO リクエスト
                                     
                                     
     ‘KQ_FILTER_VNODE’               'fflag' で監視されたイベントが1つ以上発生したと
                                     きに戻る
                                     
                                     
     ‘KQ_FILTER_PROC’                プロセスID上のイベントを監視する
                                     
                                     
     ‘KQ_FILTER_NETDEV’              ネットワークデバイス上のイベントを監視する
                                     (macOS では利用不可)
                                     
                                     
     ‘KQ_FILTER_SIGNAL’              監視しているシグナルがプロセスに届いたときに戻
                                     る
                                     
                                     
     ‘KQ_FILTER_TIMER’               任意のタイマを設定する
                                     

 -- の属性: kevent.flags

     フィルタアクション。

     定数                            意味
                                     
     ----------------------------------------------------------------------------------
                                     
     ‘KQ_EV_ADD’                     イベントを追加または修正する
                                     
                                     
     ‘KQ_EV_DELETE’                  キューからイベントを取り除く
                                     
                                     
     ‘KQ_EV_ENABLE’                  control() がイベントを返すのを許可する
                                     
                                     
     ‘KQ_EV_DISABLE’                 イベントを無効にする
                                     
                                     
     ‘KQ_EV_ONESHOT’                 イベントを最初の発生後無効にする
                                     
                                     
     ‘KQ_EV_CLEAR’                   イベントを受け取った後で状態をリセットする
                                     
                                     
     ‘KQ_EV_SYSFLAGS’                内部イベント
                                     
                                     
     ‘KQ_EV_FLAG1’                   内部イベント
                                     
                                     
     ‘KQ_EV_EOF’                     フィルタ依存のEOF状態
                                     
                                     
     ‘KQ_EV_ERROR’                   戻り値を参照
                                     

 -- の属性: kevent.fflags

     フィルタ依存のフラグ。

     ‘KQ_FILTER_READ’ と ‘KQ_FILTER_WRITE’ フィルタのフラグ:

     定数                             意味
                                      
     ----------------------------------------------------------------------------------
                                      
     ‘KQ_NOTE_LOWAT’                  ソケットバッファの最低基準値
                                      

     ‘KQ_FILTER_VNODE’ フィルタのフラグ:

     定数                             意味
                                      
     ----------------------------------------------------------------------------------
                                      
     ‘KQ_NOTE_DELETE’                 'unlink()' が呼ばれた
                                      
                                      
     ‘KQ_NOTE_WRITE’                  書き込みが発生した
                                      
                                      
     ‘KQ_NOTE_EXTEND’                 ファイルのサイズが拡張された
                                      
                                      
     ‘KQ_NOTE_ATTRIB’                 属性が変更された
                                      
                                      
     ‘KQ_NOTE_LINK’                   リンクカウントが変更された
                                      
                                      
     ‘KQ_NOTE_RENAME’                 ファイル名が変更された
                                      
                                      
     ‘KQ_NOTE_REVOKE’                 ファイルアクセスが破棄された
                                      

     ‘KQ_FILTER_PROC’ フィルタフラグ:

     定数                             意味
                                      
     ----------------------------------------------------------------------------------
                                      
     ‘KQ_NOTE_EXIT’                   プロセスが終了した
                                      
                                      
     ‘KQ_NOTE_FORK’                   プロセスが 'fork()' を呼び出した
                                      
                                      
     ‘KQ_NOTE_EXEC’                   プロセスが新しいプロセスを実行した
                                      
                                      
     ‘KQ_NOTE_PCTRLMASK’              内部フィルタフラグ
                                      
                                      
     ‘KQ_NOTE_PDATAMASK’              内部フィルタフラグ
                                      
                                      
     ‘KQ_NOTE_TRACK’                  'fork()' の呼び出しを超えてプロセスを監視する
                                      
                                      
     ‘KQ_NOTE_CHILD’                  'NOTE_TRACK' に対して子プロセスに渡される
                                      
                                      
     ‘KQ_NOTE_TRACKERR’               子プロセスにアタッチできなかった
                                      

     ‘KQ_FILTER_NETDEV’ フィルタフラグ (macOS では利用不可):

     定数                             意味
                                      
     ----------------------------------------------------------------------------------
                                      
     ‘KQ_NOTE_LINKUP’                 リンクアップしている
                                      
                                      
     ‘KQ_NOTE_LINKDOWN’               リンクダウンしている
                                      
                                      
     ‘KQ_NOTE_LINKINV’                リンク状態が不正
                                      

 -- の属性: kevent.data

     フィルタ固有のデータ。

 -- の属性: kevent.udata

     ユーザー定義値。


File: python.info,  Node: selectors --- 高水準の I/O 多重化,  Next: signal --- 非同期イベントにハンドラーを設定する,  Prev: select --- I/O 完了の待機,  Up: ネットワーク通信とプロセス間通信

5.18.5 ‘selectors’ -- 高水準の I/O 多重化
-----------------------------------------

Added in version 3.4.

'ソースコード:' Lib/selectors.py(1)

__________________________________________________________________

* Menu:

* はじめに: はじめに<8>.
* クラス: クラス<4>.
* 使用例: 使用例<28>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/selectors.py


File: python.info,  Node: はじめに<8>,  Next: クラス<4>,  Up: selectors --- 高水準の I/O 多重化

5.18.5.1 はじめに
.................

このモジュールにより、*note select: af. モジュールプリミティブに基づく高
水準かつ効率的な I/O の多重化が行えます。OS 水準のプリミティブを使用した
正確な制御を求めない限り、このモジュールの使用が推奨されます。

このモジュールは *note BaseSelector: 338e. 抽象基底クラスと、いくつかの
具象実装 (*note KqueueSelector: 327d, *note EpollSelector: ba3...)  を定
義しており、これらは複数のファイルオブジェクトの I/O の準備状況の通知の
待機に使用できます。以下では、 "ファイルオブジェクト" は、*note
fileno(): 27a6. メソッドを持つあらゆるオブジェクトか、あるいは Raw ファ
イル記述子を意味します。*note ファイルオブジェクト: 1193. を参照してくだ
さい。

*note DefaultSelector: 338f. は、現在のプラットフォームで利用できる、も
っとも効率的な実装の別名になります: これはほとんどのユーザーにとってのデ
フォルトの選択になるはずです。

     注釈: プラットフォームごとにサポートされているファイルオブジェクト
     のタイプは異なります: Windows ではソケットはサポートされますが、パ
     イプはされません。Unix では両方がサポートされます (その他の fifo や
     スペシャルファイルデバイスなどのタイプもサポートされます)。

参考
....

*note select: af.

     低水準の I/O 多重化モジュールです。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。


File: python.info,  Node: クラス<4>,  Next: 使用例<28>,  Prev: はじめに<8>,  Up: selectors --- 高水準の I/O 多重化

5.18.5.2 クラス
...............

クラス階層:

     BaseSelector
     +-- SelectSelector
     +-- PollSelector
     +-- EpollSelector
     +-- DevpollSelector
     +-- KqueueSelector

以下では、'events' は与えられたファイルオブジェクトを待機すべき I/O イベ
ントを示すビット単位のマスクになります。これには以下のモジュール定数の組
み合わせを設定できます:

     定数                        意味
                                 
     --------------------------------------------------------------------------------
                                 
      -- データ:                 読み込み可能
               selectors.EVENT_READ

      -- データ:                 書き込み可能
               selectors.EVENT_WRITE

 -- クラス: selectors.SelectorKey

     *note SelectorKey: 3393. はそれの下層のファイルディスクリプタ、選択
     したイベントマスク、および付属データへのファイルオブジェクトの関連
     付けに使用される *note namedtuple: 1ac. です。いくつかの *note
     BaseSelector: 338e. メソッドを返します。

      -- の属性: fileobj

          登録されたファイルオブジェクトです。

      -- の属性: fd

          下層のファイル記述子です。

      -- の属性: events

          このファイルオブジェクトで待機しなければならないイベントです。

      -- の属性: data

          このファイルオブジェクトに関連付けられたオプションの不透明型
          (Opaque) データです。例えば、これはクライアントごとのセッショ
          ン ID を格納するために使用できます。

 -- クラス: selectors.BaseSelector

     *note BaseSelector: 338e. は複数のファイルオブジェクトの I/O イベン
     トの準備状況の待機に使用されます。これはファイルストリームを登録、
     登録解除、およびこれらのストリームでの I/O イベントを待機 (オプショ
     ンでタイムアウト) するメソッドをサポートします。これは抽象基底クラ
     スであるため、インスタンスを作成できません。使用する実装を明示的に
     指定したい、そしてプラットフォームがそれをサポートしている場合は、
     代わりに *note DefaultSelector: 338f. を使用するか、*note
     SelectSelector: 327a. や *note KqueueSelector: 327d. などの一つを使
     用します。*note BaseSelector: 338e. とその具象実装は *note
     コンテキストマネージャー: 59e. プロトコルをサポートしています。

      -- メソッド: abstractmethod register (fileobj, events, data=None)

          I/O イベントを監視するファイルオブジェクトをセレクションに登録
          します。

          'fileobj' は監視するファイルオブジェクトです。これは整数のファ
          イル記述子か、‘fileno()’ メソッドを持つオブジェクトのどちらか
          になります。'events' は監視するイベントのビット幅マスクになり
          ます。'data' は不透明型 (Opaque) オブジェクトです。

          これは新しい *note SelectorKey: 3393. インスタンスを返します。
          不正なイベントマスク化ファイル記述子のときは *note ValueError:
          1e3. が、ファイルオブジェクトがすでに登録済みのときは *note
          KeyError: 31d. が送出されます。

      -- メソッド: abstractmethod unregister (fileobj)

          ファイルオブジェクトのセレクション登録を解除し、監視対象から外
          します。ファイルオブジェクトの登録解除はそのクローズより前に行
          われます。

          'fileobj' は登録済みのファイルオブジェクトでなければなりません
          。

          関連付けられた *note SelectorKey: 3393. インスタンスを返します
          。'fileobj' が登録されていない場合 *note KeyError: 31d. を送出
          します。'fileobj' が不正な場合 (例えば 'fileobj' に ‘fileno()’
          メソッドが無い場合や ‘fileno()’ メソッドの戻り値が不正な場合)
          *note ValueError: 1e3. を送出します。

      -- メソッド: modify (fileobj, events, data=None)

          登録されたファイルオブジェクトの監視されたイベントや付属データ
          を変更します。

          より効率的に実装できる点を除けば、
          ‘BaseSelector.unregister(fileobj)’ に続けて
          ‘BaseSelector.register(fileobj, events, data)’ を行うのと等価
          です。

          新たな *note SelectorKey: 3393. インスタンスを返します。 イベ
          ントマスクやファイル記述子が不正な場合は *note ValueError:
          1e3. を、ファイルオブジェクトが登録されていない場合は *note
          KeyError: 31d. を送出します。

      -- メソッド: abstractmethod select (timeout=None)

          登録されたいくつかのファイルオブジェクトが準備できたか、タイム
          アウトするまで待機します。

          ‘timeout > 0’ の場合、最大待機時間を秒で指定します。 ‘timeout
          <= 0’ の場合、この関数の呼び出しはブロックせず、 現在準備でき
          ているファイルオブジェクトを報告します。 'timeout' が ‘None’ の
          場合、監視しているファイルオブジェクトの一つが準備できるまでブ
          ロックします。

          この関数は ‘(key, events)’ タプルのリストを返します。準備でき
          たファイルオブジェクトにつき1タプルです。

          'key' は準備状態のファイルオブジェクトに対応する *note
          SelectorKey: 3393. インスタンスです。 'events' はそのファイル
          オブジェクトで準備が完了したイベントのビットマスクです。

               注釈: このメソッドは、現在のプロセスで信号を受信した場合
               、どのファイルオブジェクトも準備完了にならないうちに、ま
               たはタイムアウトが経過する前に返ることがあります。その場
               合、空のリストが返されます。

          バージョン 3.5 で変更: このセレクタは、シグナルによって中断さ
          れた時に、シグナルハンドラが例外を起こさなかった場合、空のイベ
          ントリストを返すのではなく、再計算されたタイムアウトによってリ
          トライするようになりました (この論拠については PEP 475(1) を参
          照してください)。

      -- メソッド: close ()

          セレクタを閉じます。

          下層のリソースがすべて解放されたことを確かめるために呼ばれなけ
          ればなりません。一旦閉じられたセレクタは使ってはいけません。

      -- メソッド: get_key (fileobj)

          登録されたファイルオブジェクトに関連付けられたキーを返します。

          そのファイルオブジェクトに関連付けられた *note SelectorKey:
          3393. インスタンスを返します。そのファイルオブジェクトが登録さ
          れていない場合 *note KeyError: 31d. を送出します。

      -- メソッド: abstractmethod get_map ()

          ファイルオブジェクトからセレクタキーへのマッピングを返します。

          これは、登録済みのファイルオブジェクトを、それらに関連づけられ
          た *note SelectorKey: 3393. インスタンスにマッピングする *note
          Mapping: 898. のインスタンスを返します。

 -- クラス: selectors.DefaultSelector

     デフォルトの selector クラスで、現在のプラットフォームで利用できる
     最も効率的な実装を使用しています。大半のユーザはこれをデフォルトに
     すべきです。

 -- クラス: selectors.SelectSelector

     *note select.select(): d6d. を基底とするセレクタです。

 -- クラス: selectors.PollSelector

     *note select.poll(): 2b0c. を基底とするセレクタです。

 -- クラス: selectors.EpollSelector

     *note select.epoll(): f60. を基底とするセレクタです。

      -- メソッド: fileno ()

          下層の *note select.epoll(): f60. オブジェクトが使用しているフ
          ァイル記述子を返します。

 -- クラス: selectors.DevpollSelector

     *note select.devpoll(): f62. を基底とするセレクタです。

      -- メソッド: fileno ()

          下層の *note select.devpoll(): f62. オブジェクトが使用している
          ファイル記述子を返します。

     Added in version 3.5.

 -- クラス: selectors.KqueueSelector

     *note select.kqueue(): 1633. を基底とするセレクタです。

      -- メソッド: fileno ()

          下層の *note select.kqueue(): 1633. オブジェクトが使用している
          ファイル記述子を返します。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0475/


File: python.info,  Node: 使用例<28>,  Prev: クラス<4>,  Up: selectors --- 高水準の I/O 多重化

5.18.5.3 使用例
...............

簡単なエコーサーバの実装です:

     import selectors
     import socket

     sel = selectors.DefaultSelector()

     def accept(sock, mask):
         conn, addr = sock.accept()  # Should be ready
         print('accepted', conn, 'from', addr)
         conn.setblocking(False)
         sel.register(conn, selectors.EVENT_READ, read)

     def read(conn, mask):
         data = conn.recv(1000)  # Should be ready
         if data:
             print('echoing', repr(data), 'to', conn)
             conn.send(data)  # Hope it won't block
         else:
             print('closing', conn)
             sel.unregister(conn)
             conn.close()

     sock = socket.socket()
     sock.bind(('localhost', 1234))
     sock.listen(100)
     sock.setblocking(False)
     sel.register(sock, selectors.EVENT_READ, accept)

     while True:
         events = sel.select()
         for key, mask in events:
             callback = key.data
             callback(key.fileobj, mask)


File: python.info,  Node: signal --- 非同期イベントにハンドラーを設定する,  Next: mmap --- メモリマップファイルのサポート,  Prev: selectors --- 高水準の I/O 多重化,  Up: ネットワーク通信とプロセス間通信

5.18.6 ‘signal’ -- 非同期イベントにハンドラーを設定する
-------------------------------------------------------

'ソースコード:' Lib/signal.py(1)

__________________________________________________________________

このモジュールでは Python でシグナルハンドラを使うための機構を提供します
。

* Menu:

* 一般的なルール::
* モジュールの内容: モジュールの内容<2>.
* 使用例: 使用例<29>.
* Note on SIGPIPE::
* Note on Signal Handlers and Exceptions::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/signal.py


File: python.info,  Node: 一般的なルール,  Next: モジュールの内容<2>,  Up: signal --- 非同期イベントにハンドラーを設定する

5.18.6.1 一般的なルール
.......................

*note signal.signal(): 1107. 関数を使って、シグナルを受信した時に実行さ
れるハンドラを定義することができます。 Python は標準でごく少数のシグナル
ハンドラをインストールしています: *note SIGPIPE: 33a5. は無視され (した
がって、 pipe や socket に対する書き込みで生じたエラーは通常の Python 例
外として報告されます)、 *note SIGINT: 80f. は *note KeyboardInterrupt:
99f. 例外に変換されます。親プロセスが変更していない場合は、これらはどれ
も上書きすることができます。

特定のシグナルに対するハンドラが一度設定されると、明示的にリセットしない
かぎり設定されたままになります (Python は背後の実装系に関係なく BSD 形式
のインターフェースをエミュレートします)。例外は *note SIGCHLD: 2b47. の
ハンドラで、この場合は背後の実装系の仕様に従います。

On WebAssembly platforms, signals are emulated and therefore behave
differently.  Several functions and signals are not available on these
platforms.

* Menu:

* Python のシグナルハンドラの実行::
* シグナルとスレッド::


File: python.info,  Node: Python のシグナルハンドラの実行,  Next: シグナルとスレッド,  Up: 一般的なルール

5.18.6.2 Python のシグナルハンドラの実行
........................................

Python のシグナルハンドラは、低水準 (C言語) のシグナルハンドラ内で実行さ
れるわけではありません。代わりに、低水準のシグナルハンドラが *note
virtual machine: 33a7. が対応する Python のシグナルハンドラを後から (例
えば次の *note bytecode: 16c. 命令時に) 実行するようにフラグを立てます:

   * It makes little sense to catch synchronous errors like *note
     SIGFPE: 1cb4. or *note SIGSEGV: 1cb3. that are caused by an invalid
     operation in C code.  Python will return from the signal handler to
     the C code, which is likely to raise the same signal again, causing
     Python to apparently hang.  From Python 3.3 onwards, you can use
     the *note faulthandler: 4e. module to report on synchronous errors.

   * 完全にCで実装された長時間かかる計算 (大きいテキストに対する正規表現
     のマッチなど) は、どのシグナルを受信しても中断されないまま長時間実
     行され続ける可能性があります。Python のシグナルハンドラはその計算が
     終了してから呼び出されます。

   * If the handler raises an exception, it will be raised "out of thin
     air" in the main thread.  See the *note note below: 21e7. for a
     discussion.


File: python.info,  Node: シグナルとスレッド,  Prev: Python のシグナルハンドラの実行,  Up: 一般的なルール

5.18.6.3 シグナルとスレッド
...........................

Python のシグナルハンドラは、もしシグナルを受け取ったのが別のスレッドだ
ったとしても、常にメインインタープリターの Python のメインスレッドで実行
されます。このためシグナルをスレッド間通信に使うことはできません。代わり
に *note threading: d6. モジュールが提供している同期プリミティブを利用で
きます。

また、メインインタープリターのメインスレッドだけが新しいシグナルハンドラ
を登録できます。


File: python.info,  Node: モジュールの内容<2>,  Next: 使用例<29>,  Prev: 一般的なルール,  Up: signal --- 非同期イベントにハンドラーを設定する

5.18.6.4 モジュールの内容
.........................

バージョン 3.5 で変更: signal (SIG*), handler (*note SIG_DFL: 178c,
*note SIG_IGN: 178b.) and sigmask (*note SIG_BLOCK: 33ab, *note
SIG_UNBLOCK: 33ac, *note SIG_SETMASK: 33ad.) related constants listed
below were turned into *note enums: cad. (*note Signals: 33ae, *note
Handlers: 33af. and *note Sigmasks: 33b0. respectively).  *note
getsignal(): 1610, *note pthread_sigmask(): 1103, *note sigpending():
1105. and *note sigwait(): 1106. functions return human-readable *note
enums: cad. as *note Signals: 33ae. objects.

The signal module defines three enums:

 -- クラス: signal.Signals

     *note enum.IntEnum: cad. collection of SIG* constants and the
     CTRL_* constants.

     Added in version 3.5.

 -- クラス: signal.Handlers

     *note enum.IntEnum: cad. collection the constants *note SIG_DFL:
     178c. and *note SIG_IGN: 178b.

     Added in version 3.5.

 -- クラス: signal.Sigmasks

     *note enum.IntEnum: cad. collection the constants *note SIG_BLOCK:
     33ab, *note SIG_UNBLOCK: 33ac. and *note SIG_SETMASK: 33ad.

     *note Availability: 1cbe.: Unix.

     See the man page ‘sigprocmask(2)(1)’ and ‘pthread_sigmask(3)(2)’
     for further information.

     Added in version 3.5.

以下に *note signal: b4. モジュールで定義されている変数を示します:

 -- データ: signal.SIG_DFL

     二つある標準シグナル処理オプションのうちの一つです; 単純にシグナル
     に対する標準の関数を実行します。例えば、ほとんどのシステムでは、
     ‘SIGQUIT’ に対する標準の動作はコアダンプと終了で、 *note SIGCHLD:
     2b47. に対する標準の動作は単にシグナルの無視です。

 -- データ: signal.SIG_IGN

     もう一つの標準シグナル処理オプションで、受け取ったシグナルを単に無
     視します。

 -- データ: signal.SIGABRT

     Abort signal from ‘abort(3)(3)’.

 -- データ: signal.SIGALRM

     Timer signal from ‘alarm(2)(4)’.

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGBREAK

     Interrupt from keyboard (CTRL + BREAK).

     *note Availability: 1cbe.: Windows.

 -- データ: signal.SIGBUS

     Bus error (bad memory access).

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGCHLD

     Child process stopped or terminated.

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGCLD

     *note SIGCHLD: 2b47. のエイリアスです。

     *note Availability: 1cbe.: not macOS.

 -- データ: signal.SIGCONT

     Continue the process if it is currently stopped

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGFPE

     Floating-point exception.  For example, division by zero.

     参考
     ....

     *note ZeroDivisionError: 913. is raised when the second argument of
     a division or modulo operation is zero.

 -- データ: signal.SIGHUP

     Hangup detected on controlling terminal or death of controlling
     process.

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGILL

     Illegal instruction.

 -- データ: signal.SIGINT

     Interrupt from keyboard (CTRL + C).

     Default action is to raise *note KeyboardInterrupt: 99f.

 -- データ: signal.SIGKILL

     Kill signal.

     It cannot be caught, blocked, or ignored.

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGPIPE

     Broken pipe: write to pipe with no readers.

     Default action is to ignore the signal.

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGSEGV

     Segmentation fault: invalid memory reference.

 -- データ: signal.SIGSTKFLT

          Stack fault on coprocessor.  The Linux kernel does not raise
          this signal: it can only be raised in user space.

     *note Availability: 1cbe.: Linux.

     On architectures where the signal is available.  See the man page
     ‘signal(7)(5)’ for further information.

     Added in version 3.11.

 -- データ: signal.SIGTERM

     Termination signal.

 -- データ: signal.SIGUSR1

     User-defined signal 1.

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGUSR2

     User-defined signal 2.

     *note Availability: 1cbe.: Unix.

 -- データ: signal.SIGWINCH

     Window resize signal.

     *note Availability: 1cbe.: Unix.

 -- データ: SIG*

     全てのシグナル番号はシンボル定義されています。例えば、ハングアップ
     シグナルは *note signal.SIGHUP: 33b4. で定義されています; 変数名は
     C 言語のプログラムで使われているのと同じ名前で、 ‘<signal.h>’ にあ
     ります。 '‘signal()’' に関する Unix マニュアルページでは、システム
     で定義されているシグナルを列挙しています (あるシステムではリストは
     ‘signal(2)(6)’ に、別のシステムでは ‘signal(7)(7)’ に列挙されていま
     す)。全てのシステムで同じシグナル名のセットを定義しているわけではな
     いので注意してください; このモジュールでは、システムで定義されてい
     るシグナル名だけを定義しています。

 -- データ: signal.CTRL_C_EVENT

     ‘CTRL+C’ キーストロークに該当するシグナル。このシグナルは *note
     os.kill(): 132f. でだけ利用できます。

     *note Availability: 1cbe.: Windows.

     Added in version 3.2.

 -- データ: signal.CTRL_BREAK_EVENT

     ‘CTRL+BREAK’ キーストロークに該当するシグナル。このシグナルは *note
     os.kill(): 132f. でだけ利用できます。

     *note Availability: 1cbe.: Windows.

     Added in version 3.2.

 -- データ: signal.NSIG

     One more than the number of the highest signal number.  Use *note
     valid_signals(): 33b9. to get valid signal numbers.

 -- データ: signal.ITIMER_REAL

     実時間でデクリメントするインターバルタイマーです。タイマーが発火し
     たときに *note SIGALRM: 33b1. を送ります。

 -- データ: signal.ITIMER_VIRTUAL

     プロセスの実行時間だけデクリメントするインターバルタイマーです。タ
     イマーが発火したときに ‘SIGVTALRM’ を送ります。

 -- データ: signal.ITIMER_PROF

     プロセスの実行中と、システムがそのプロセスのために実行している時間
     だけデクリメントするインターバルタイマーです。ITIMER_VIRTUAL と組み
     合わせて、このタイマーはよくアプリケーションがユーザー空間とカーネ
     ル空間で消費した時間のプロファイリングに利用されます。タイマーが発
     火したときに ‘SIGPROF’ を送ります。

 -- データ: signal.SIG_BLOCK

     *note pthread_sigmask(): 1103. の 'how' 引数に渡せる値で、シグナル
     がブロックされることを意味します。

     Added in version 3.3.

 -- データ: signal.SIG_UNBLOCK

     *note pthread_sigmask(): 1103. の 'how' 引数に渡せる値で、シグナル
     がブロック解除されることを意味します。

     Added in version 3.3.

 -- データ: signal.SIG_SETMASK

     *note pthread_sigmask(): 1103. の 'how' 引数に渡せる値で、シグナル
     が置換されることを意味します。

     Added in version 3.3.

*note signal: b4. モジュールは1つの例外を定義しています:

 -- 例外: signal.ItimerError

     背後の *note setitimer(): 33be. または *note getitimer(): 33bf. 実
     装からエラーを通知するために送出されます。無効なインタバルタイマー
     や負の時間が *note setitimer(): 33be. に渡された場合、このエラーを
     予期してください。このエラーは *note OSError: 3f0. を継承しています
     。

     Added in version 3.3: このエラーは以前は *note IOError: 1026. のサ
     ブタイプでしたが、 *note OSError: 3f0. のエイリアスになりました。

*note signal: b4. モジュールでは以下の関数を定義しています:

 -- の関数: signal.alarm (time)

     'time' がゼロでない値の場合、この関数は 'time' 秒後頃に *note
     SIGALRM: 33b1. をプロセスに送るように要求します。それ以前にスケジュ
     ールしたアラームはキャンセルされます (常に一つのアラームしかスケジ
     ュールできません)。この場合、戻り値は以前に設定されたアラームシグナ
     ルが通知されるまであと何秒だったかを示す値です。 'time' がゼロの場
     合、アラームは一切スケジュールされず、現在スケジュールされているア
     ラームがキャンセルされます。戻り値がゼロの場合、現在アラームがスケ
     ジュールされていないことを示します。

     *note Availability: 1cbe.: Unix.

     See the man page ‘alarm(2)(8)’ for further information.

 -- の関数: signal.getsignal (signalnum)

     シグナル 'signalnum' に対する現在のシグナルハンドラを返します。戻り
     値は呼び出し可能な Python オブジェクトか、 *note signal.SIG_IGN:
     178b.、 *note signal.SIG_DFL: 178c.、および *note None: 641. といっ
     た特殊な値のいずれかです。ここで *note signal.SIG_IGN: 178b. は以前
     そのシグナルが無視されていたことを示し、 *note signal.SIG_DFL:
     178c. は以前そのシグナルの標準の処理方法が使われていたことを示し、
     ‘None’ はシグナルハンドラがまだ Python によってインストールされてい
     ないことを示します。

 -- の関数: signal.strsignal (signalnum)

     Returns the description of signal 'signalnum', such as "Interrupt"
     for *note SIGINT: 80f.  Returns *note None: 641. if 'signalnum' has
     no description.  Raises *note ValueError: 1e3. if 'signalnum' is
     invalid.

     Added in version 3.8.

 -- の関数: signal.valid_signals ()

     Return the set of valid signal numbers on this platform.  This can
     be less than ‘range(1, NSIG)’ if some signals are reserved by the
     system for internal use.

     Added in version 3.8.

 -- の関数: signal.pause ()

     シグナルを受け取るまでプロセスを一時停止します; その後、適切なハン
     ドラが呼び出されます。戻り値はありません。

     *note Availability: 1cbe.: Unix.

     See the man page ‘signal(2)(9)’ for further information.

     *note sigwait(): 1106, *note sigwaitinfo(): d78, *note
     sigtimedwait(): d77. *note sigpending(): 1105. も参照してください。

 -- の関数: signal.raise_signal (signum)

     Sends a signal to the calling process.  Returns nothing.

     Added in version 3.8.

 -- の関数: signal.pidfd_send_signal (pidfd, sig, siginfo=None, flags=0)

     Send signal 'sig' to the process referred to by file descriptor
     'pidfd'.  Python does not currently support the 'siginfo'
     parameter; it must be ‘None’.  The 'flags' argument is provided for
     future extensions; no flag values are currently defined.

     さらに詳しい情報についてはオンラインマニュアルページ
     ‘pidfd_send_signal(2)(10)’ を参照してください。

     *note Availability: 1cbe.: Linux >= 5.1, Android >= *note
     build-time: b58. API level 31

     Added in version 3.9.

 -- の関数: signal.pthread_kill (thread_id, signalnum)

     Send the signal 'signalnum' to the thread 'thread_id', another
     thread in the same process as the caller.  The target thread can be
     executing any code (Python or not).  However, if the target thread
     is executing the Python interpreter, the Python signal handlers
     will be *note executed by the main thread of the main interpreter:
     33a9.  Therefore, the only point of sending a signal to a
     particular Python thread would be to force a running system call to
     fail with *note InterruptedError: d55.

     Use *note threading.get_ident(): 112d. or the *note ident: 2b9d.
     attribute of *note threading.Thread: 91a. objects to get a suitable
     value for 'thread_id'.

     If 'signalnum' is 0, then no signal is sent, but error checking is
     still performed; this can be used to check if the target thread is
     still running.

     引数 ‘thread_id’, ‘signalnum’ を指定して *note 監査イベント: 1825.
     ‘signal.pthread_kill’ を送出します。

     *note Availability: 1cbe.: Unix.

     See the man page ‘pthread_kill(3)(11)’ for further information.

     *note os.kill(): 132f. を参照してください。

     Added in version 3.3.

 -- の関数: signal.pthread_sigmask (how, mask)

     これを呼び出すスレッドにセットされているシグナルマスクを取り出した
     り変更したりします。シグナルマスクは、呼び出し側のために現在どのシ
     グナルの配送がブロックされているかを示す集合 (set) です。呼び出し前
     のもとのシグナルマスクを集合として返却します。

     この関数の振る舞いは 'how' に依存して以下のようになります。

        * *note SIG_BLOCK: 33ab.: 'mask' で指定されるシグナルが現時点の
          シグナルマスクに追加されます。

        * *note SIG_UNBLOCK: 33ac.: 'mask' で指定されるシグナルが現時点
          のシグナルマスクから取り除かれます。もともとブロックされていな
          いシグナルをブロック解除しようとしても問題ありません。

        * *note SIG_SETMASK: 33ad.: シグナルマスク全体を 'mask' としてセ
          ットします。

     'mask' はシグナル番号の集合です (例えば {*note signal.SIGINT: 80f,
     *note signal.SIGTERM: 1387.})。全てのシグナルを含む全集合として
     *note valid_signals(): 33b9. を使うことが出来ます。

     呼び出しスレッドにセットされたシグナルマスクを問い合わせるには例え
     ば ‘signal.pthread_sigmask(signal.SIG_BLOCK, [])’ とします。

     *note SIGKILL: 33b5. and ‘SIGSTOP’ cannot be blocked.

     *note Availability: 1cbe.: Unix.

     See the man page ‘sigprocmask(2)(12)’ and ‘pthread_sigmask(3)(13)’
     for further information.

     *note pause(): 33c1, *note sigpending(): 1105, *note sigwait():
     1106. も参照して下さい。

     Added in version 3.3.

 -- の関数: signal.setitimer (which, seconds, interval=0.0)

     'which' で指定されたタイマー (*note signal.ITIMER_REAL: 33ba, *note
     signal.ITIMER_VIRTUAL: 33bb, *note signal.ITIMER_PROF: 33bc. のどれ
     か) を、 'seconds' 秒後と (*note alarm(): 33c0. と異なり、floatを指
     定できます)、それから ('interval' が0でなければ) 'interval' 秒間隔
     で起動するように設定します。 'seconds' に0を指定すると、'which' で
     指定されたタイマーをクリアすることができます。

     インターバルタイマーが起動したとき、シグナルがプロセスに送られます
     。送られるシグナルは利用されたタイマーの種類に依存します。 *note
     signal.ITIMER_REAL: 33ba. の場合は *note SIGALRM: 33b1. が、 *note
     signal.ITIMER_VIRTUAL: 33bb. の場合は ‘SIGVTALRM’ が、 *note
     signal.ITIMER_PROF: 33bc. の場合は ‘SIGPROF’ が送られます。

     以前の値が (delay, interval) のタプルとして返されます。

     無効なインターバルタイマーを渡すと *note ItimerError: 33bd. 例外が
     発生します。

     *note Availability: 1cbe.: Unix.

 -- の関数: signal.getitimer (which)

     'which' で指定されたインターバルタイマーの現在の値を返します。

     *note Availability: 1cbe.: Unix.

 -- の関数: signal.set_wakeup_fd (fd, *, warn_on_full_buffer=True)

     Set the wakeup file descriptor to 'fd'.  When a signal is received,
     the signal number is written as a single byte into the fd.  This
     can be used by a library to wakeup a poll or select call, allowing
     the signal to be fully processed.

     The old wakeup fd is returned (or -1 if file descriptor wakeup was
     not enabled).  If 'fd' is -1, file descriptor wakeup is disabled.
     If not -1, 'fd' must be non-blocking.  It is up to the library to
     remove any bytes from 'fd' before calling poll or select again.

     スレッドが有効な場合、この関数は *note
     メインインタープリターのメインスレッド: 33a9. からしか実行できませ
     ん。それ以外のスレッドからこの関数を実行しようとすると *note
     ValueError: 1e3. 例外が発生します。

     There are two common ways to use this function.  In both
     approaches, you use the fd to wake up when a signal arrives, but
     then they differ in how they determine 'which' signal or signals
     have arrived.

     In the first approach, we read the data out of the fd's buffer, and
     the byte values give you the signal numbers.  This is simple, but
     in rare cases it can run into a problem: generally the fd will have
     a limited amount of buffer space, and if too many signals arrive
     too quickly, then the buffer may become full, and some signals may
     be lost.  If you use this approach, then you should set
     ‘warn_on_full_buffer=True’, which will at least cause a warning to
     be printed to stderr when signals are lost.

     In the second approach, we use the wakeup fd 'only' for wakeups,
     and ignore the actual byte values.  In this case, all we care about
     is whether the fd's buffer is empty or non-empty; a full buffer
     doesn't indicate a problem at all.  If you use this approach, then
     you should set ‘warn_on_full_buffer=False’, so that your users are
     not confused by spurious warning messages.

     バージョン 3.5 で変更: Windowsで、この関数はソケットハンドルをサポ
     ートするようになりました。

     バージョン 3.7 で変更: ‘warn_on_full_buffer’ 引数が追加されました。

 -- の関数: signal.siginterrupt (signalnum, flag)

     システムコールのリスタートの動作を変更します。 'flag' が *note
     False: b05. の場合、 'signalnum' シグナルに中断されたシステムコール
     は再実行されます。それ以外の場合、システムコールは中断されます。戻
     り値はありません。

     *note Availability: 1cbe.: Unix.

     See the man page ‘siginterrupt(3)(14)’ for further information.

     Note that installing a signal handler with *note signal(): b4. will
     reset the restart behaviour to interruptible by implicitly calling
     ‘siginterrupt()’ with a true 'flag' value for the given signal.

 -- の関数: signal.signal (signalnum, handler)

     シグナル 'signalnum' に対するハンドラを関数 'handler' にします。
     'handler' は二つの引数 (下記参照) を取る呼び出し可能な Python オブ
     ジェクトか、 *note signal.SIG_IGN: 178b. あるいは *note
     signal.SIG_DFL: 178c. といった特殊な値にすることができます。以前に
     使われていたシグナルハンドラが返されます (上記の *note getsignal():
     1610. の記述を参照してください)。 (さらに詳しい情報については Unix
     マニュアルページ ‘signal(2)(15)’ を参照してください。)

     スレッドが有効な場合、この関数は *note
     メインインタープリターのメインスレッド: 33a9. からしか実行できませ
     ん。それ以外のスレッドからこの関数を実行しようとすると *note
     ValueError: 1e3. 例外が発生します。

     'handler' は二つの引数とともに呼び出されます: シグナル番号、および
     現在のスタックフレーム (‘None’ またはフレームオブジェクト; フレーム
     オブジェクトについての記述は *note 標準型の階層における説明: 6ab. か
     、 *note inspect: 72. モジュールの属性の説明を参照してください)。

     On Windows, *note signal(): b4. can only be called with *note
     SIGABRT: 1cb5, *note SIGFPE: 1cb4, *note SIGILL: 1cb7, *note
     SIGINT: 80f, *note SIGSEGV: 1cb3, *note SIGTERM: 1387, or *note
     SIGBREAK: 33b2.  A *note ValueError: 1e3. will be raised in any
     other case.  Note that not all systems define the same set of
     signal names; an *note AttributeError: 326. will be raised if a
     signal name is not defined as ‘SIG*’ module level constant.

 -- の関数: signal.sigpending ()

     呼び出しスレッドで配送が保留されているシグナル (つまり配送がブロッ
     クされている間に発生したシグナル) の集合を調べます。保留中のシグナ
     ルの集合を返します。

     *note Availability: 1cbe.: Unix.

     See the man page ‘sigpending(2)(16)’ for further information.

     *note pause(): 33c1, *note pthread_sigmask(): 1103, *note
     sigwait(): 1106. も参照して下さい。

     Added in version 3.3.

 -- の関数: signal.sigwait (sigset)

     'sigset' 集合で指定されたシグナルのうちどれか一つが届くまで呼び出し
     スレッドを一時停止します。この関数はそのシグナルを受け取ると (それ
     を保留シグナルリストから取り除いて) そのシグナル番号を返します。

     *note Availability: 1cbe.: Unix.

     See the man page ‘sigwait(3)(17)’ for further information.

     *note pause(): 33c1, *note pthread_sigmask(): 1103, *note
     sigpending(): 1105, *note sigwaitinfo(): d78, *note sigtimedwait():
     d77. も参照して下さい。

     Added in version 3.3.

 -- の関数: signal.sigwaitinfo (sigset)

     Suspend execution of the calling thread until the delivery of one
     of the signals specified in the signal set 'sigset'.  The function
     accepts the signal and removes it from the pending list of signals.
     If one of the signals in 'sigset' is already pending for the
     calling thread, the function will return immediately with
     information about that signal.  The signal handler is not called
     for the delivered signal.  The function raises an *note
     InterruptedError: d55. if it is interrupted by a signal that is not
     in 'sigset'.

     The return value is an object representing the data contained in
     the ‘siginfo_t’ structure, namely: ‘si_signo’, ‘si_code’,
     ‘si_errno’, ‘si_pid’, ‘si_uid’, ‘si_status’, ‘si_band’.

     *note Availability: 1cbe.: Unix.

     See the man page ‘sigwaitinfo(2)(18)’ for further information.

     *note pause(): 33c1, *note sigwait(): 1106, *note sigtimedwait():
     d77. も参照して下さい。

     Added in version 3.3.

     バージョン 3.5 で変更: The function is now retried if interrupted
     by a signal not in 'sigset' and the signal handler does not raise
     an exception (see PEP 475(19) for the rationale).

 -- の関数: signal.sigtimedwait (sigset, timeout)

     Like *note sigwaitinfo(): d78, but takes an additional 'timeout'
     argument specifying a timeout.  If 'timeout' is specified as ‘0’, a
     poll is performed.  Returns *note None: 641. if a timeout occurs.

     *note Availability: 1cbe.: Unix.

     See the man page ‘sigtimedwait(2)(20)’ for further information.

     *note pause(): 33c1, *note sigwait(): 1106, *note sigwaitinfo():
     d78. も参照して下さい。

     Added in version 3.3.

     バージョン 3.5 で変更: The function is now retried with the
     recomputed 'timeout' if interrupted by a signal not in 'sigset' and
     the signal handler does not raise an exception (see PEP 475(21) for
     the rationale).

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/sigprocmask(2)

   (2) https://manpages.debian.org/pthread_sigmask(3)

   (3) https://manpages.debian.org/abort(3)

   (4) https://manpages.debian.org/alarm(2)

   (5) https://manpages.debian.org/signal(7)

   (6) https://manpages.debian.org/signal(2)

   (7) https://manpages.debian.org/signal(7)

   (8) https://manpages.debian.org/alarm(2)

   (9) https://manpages.debian.org/signal(2)

   (10) https://manpages.debian.org/pidfd_send_signal(2)

   (11) https://manpages.debian.org/pthread_kill(3)

   (12) https://manpages.debian.org/sigprocmask(2)

   (13) https://manpages.debian.org/pthread_sigmask(3)

   (14) https://manpages.debian.org/siginterrupt(3)

   (15) https://manpages.debian.org/signal(2)

   (16) https://manpages.debian.org/sigpending(2)

   (17) https://manpages.debian.org/sigwait(3)

   (18) https://manpages.debian.org/sigwaitinfo(2)

   (19) https://peps.python.org/pep-0475/

   (20) https://manpages.debian.org/sigtimedwait(2)

   (21) https://peps.python.org/pep-0475/


File: python.info,  Node: 使用例<29>,  Next: Note on SIGPIPE,  Prev: モジュールの内容<2>,  Up: signal --- 非同期イベントにハンドラーを設定する

5.18.6.5 使用例
...............

以下は最小限のプログラム例です。この例では *note alarm(): 33c0. を使って
ファイルを開く処理を待つのに費やす時間を制限します; 例えば、電源の入って
いないシリアルデバイスを開こうとすると、通常 *note os.open(): d5f. は未
定義の期間ハングアップしてしまいますが、この方法はそうした場合に便利です
。ここではファイルを開くまで 5 秒間のアラームを設定することで解決してい
ます; ファイルを開く処理が長くかかりすぎると、アラームシグナルが送信され
、ハンドラが例外を送出するようになっています。

     import signal, os

     def handler(signum, frame):
         signame = signal.Signals(signum).name
         print(f'Signal handler called with signal {signame} ({signum})')
         raise OSError("Couldn't open device!")

     # Set the signal handler and a 5-second alarm
     signal.signal(signal.SIGALRM, handler)
     signal.alarm(5)

     # This open() may hang indefinitely
     fd = os.open('/dev/ttyS0', os.O_RDWR)

     signal.alarm(0)          # Disable the alarm


File: python.info,  Node: Note on SIGPIPE,  Next: Note on Signal Handlers and Exceptions,  Prev: 使用例<29>,  Up: signal --- 非同期イベントにハンドラーを設定する

5.18.6.6 Note on SIGPIPE
........................

Piping output of your program to tools like ‘head(1)(1)’ will cause a
*note SIGPIPE: 33a5. signal to be sent to your process when the receiver
of its standard output closes early.  This results in an exception like
‘BrokenPipeError: [Errno 32] Broken pipe’.  To handle this case, wrap
your entry point to catch this exception as follows:

     import os
     import sys

     def main():
         try:
             # simulate large output (your code replaces this loop)
             for x in range(10000):
                 print("y")
             # flush output here to force SIGPIPE to be triggered
             # while inside this try block.
             sys.stdout.flush()
         except BrokenPipeError:
             # Python flushes standard streams on exit; redirect remaining output
             # to devnull to avoid another BrokenPipeError at shutdown
             devnull = os.open(os.devnull, os.O_WRONLY)
             os.dup2(devnull, sys.stdout.fileno())
             sys.exit(1)  # Python exits with error code 1 on EPIPE

     if __name__ == '__main__':
         main()

Do not set *note SIGPIPE: 33a5.'s disposition to *note SIG_DFL: 178c. in
order to avoid *note BrokenPipeError: 1030.  Doing that would cause your
program to exit unexpectedly whenever any socket connection is
interrupted while your program is still writing to it.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/head(1)


File: python.info,  Node: Note on Signal Handlers and Exceptions,  Prev: Note on SIGPIPE,  Up: signal --- 非同期イベントにハンドラーを設定する

5.18.6.7 Note on Signal Handlers and Exceptions
...............................................

If a signal handler raises an exception, the exception will be
propagated to the main thread and may be raised after any *note
bytecode: 16c. instruction.  Most notably, a *note KeyboardInterrupt:
99f. may appear at any point during execution.  Most Python code,
including the standard library, cannot be made robust against this, and
so a *note KeyboardInterrupt: 99f. (or any other exception resulting
from a signal handler) may on rare occasions put the program in an
unexpected state.

To illustrate this issue, consider the following code:

     class SpamContext:
         def __init__(self):
             self.lock = threading.Lock()

         def __enter__(self):
             # If KeyboardInterrupt occurs here, everything is fine
             self.lock.acquire()
             # If KeyboardInterrupt occurs here, __exit__ will not be called
             ...
             # KeyboardInterrupt could occur just before the function returns

         def __exit__(self, exc_type, exc_val, exc_tb):
             ...
             self.lock.release()

For many programs, especially those that merely want to exit on *note
KeyboardInterrupt: 99f, this is not a problem, but applications that are
complex or require high reliability should avoid raising exceptions from
signal handlers.  They should also avoid catching *note
KeyboardInterrupt: 99f. as a means of gracefully shutting down.
Instead, they should install their own *note SIGINT: 80f. handler.
Below is an example of an HTTP server that avoids *note
KeyboardInterrupt: 99f.:

     import signal
     import socket
     from selectors import DefaultSelector, EVENT_READ
     from http.server import HTTPServer, SimpleHTTPRequestHandler

     interrupt_read, interrupt_write = socket.socketpair()

     def handler(signum, frame):
         print('Signal handler called with signal', signum)
         interrupt_write.send(b'\0')
     signal.signal(signal.SIGINT, handler)

     def serve_forever(httpd):
         sel = DefaultSelector()
         sel.register(interrupt_read, EVENT_READ)
         sel.register(httpd, EVENT_READ)

         while True:
             for key, _ in sel.select():
                 if key.fileobj == interrupt_read:
                     interrupt_read.recv(1)
                     return
                 if key.fileobj == httpd:
                     httpd.handle_request()

     print("Serving on port 8000")
     httpd = HTTPServer(('', 8000), SimpleHTTPRequestHandler)
     serve_forever(httpd)
     print("Shutdown...")


File: python.info,  Node: mmap --- メモリマップファイルのサポート,  Prev: signal --- 非同期イベントにハンドラーを設定する,  Up: ネットワーク通信とプロセス間通信

5.18.7 ‘mmap’ -- メモリマップファイルのサポート
-----------------------------------------------

__________________________________________________________________

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

メモリにマップされたファイルオブジェクトは、 *note bytearray: 508. と
*note ファイルオブジェクト: 1193. の両方のように振舞います。しかし通常の
文字列オブジェクトとは異なり、これらは可変です。 *note bytearray: 508. が
期待されるほとんどの場所で mmap オブジェクトを利用できます。例えば、メモ
リマップファイルを探索するために *note re: a7. モジュールを使うことがで
きます。それらは可変なので、 ‘obj[index] = 97’ のように文字を変換できま
すし、スライスを使うことで ‘obj[i1:i2] = b'...'’ のように部分文字列を変
換することができます。現在のファイル位置をデータの始めとする読込みや書込
み、ファイルの異なる位置へ ‘seek()’ することもできます。

メモリマップドファイルは Unix と Windows で異なる *note mmap: 1ec. コン
ストラクタで生成されます。どちらの場合も、更新用に開かれたファイル記述子
を渡さなければなりません。既存の Python ファイルオブジェクトをマップした
ければ、 *note fileno(): 27a6. メソッドを使って 'fileno' パラメータの正
しい値を取得してください。そうでなければ、 *note os.open(): d5f. 関数を
使ってファイルを開けます。この関数はファイルディスクリプタを直接返します
(処理が終わったら、やはりファイルを閉じる必要があります)。

     注釈: 書き込み可能でバッファされたファイルへのメモリマップファイル
     を作りたいのであれば、まず最初にファイルの *note flush(): 2b75. を
     呼び出すべきです。これはバッファへのローカルな修正がマッピングで実
     際に利用可能になることを保障するために必要です。

Unix バージョンと Windows バージョンのどちらのコンストラクタについても、
オプションのキーワード・パラメータとして 'access' を指定できます。
'access' は4つの値の内の1つを受け入れます。 ‘ACCESS_READ’ は読み出し専用
、 ‘ACCESS_WRITE’ は書き込み可能、 ‘ACCESS_COPY’ はコピーした上での書き
込み、‘ACCESS_DEFAULT’ は 'prot' に従います。 'access' は Unix と
Windows の両方で使用することができます。 'access' が指定されない場合、
Windows の mmap は書き込み可能マップを返します。 3つのアクセス型すべてに
対する初期メモリ値は、指定されたファイルから得られます。 ‘ACCESS_READ’ 型
のメモリマップに対して書き込むと *note TypeError: 502. 例外を送出します
。 ‘ACCESS_WRITE’ 型のメモリマップへの書き込みはメモリと元のファイルの両
方に影響を与えます。 ‘ACCESS_COPY’ 型のメモリマップへの書き込みはメモリ
に影響を与えますが、元のファイルを更新することはありません。

バージョン 3.7 で変更: 定数 ‘ACCESS_DEFAULT’ が追加されました。

無名メモリ(anonymous memory)にマップするためには fileno として -1 を渡し
、length を与えてください。

 -- クラス: mmap.mmap (fileno, length, tagname=None,
          access=ACCESS_DEFAULT, offset=0)

     '(Windows バージョン)' ファイルハンドル 'fileno' によって指定された
     ファイルから 'length' バイトをマップして、 mmap オブジェクトを生成
     します。 'length' が現在のファイルサイズより大きな場合、ファイルサ
     イズは 'length' を含む大きさにまで拡張されます。 'length' が ‘0’ の
     場合、マップの最大の長さは現在のファイルサイズになります。ただし、
     ファイル自体が空のときは Windows が例外を送出します (Windows では空
     のマップを作成することができません)。

     'tagname' は、 ‘None’ 以外で指定された場合、マップのタグ名を与える
     文字列となります。 Windows は同じファイルに対する様々なマップを持つ
     ことを可能にします。既存のタグの名前を指定すればそのタグがオープン
     され、そうでなければこの名前の新しいタグが作成されます。もしこのパ
     ラメータを省略したり ‘None’ を与えたりしたならば、マップは名前なし
     で作成されます。 "tagname" パラメータの使用の回避は、あなたのコード
     を Unix と Windows の間で移植可能にしておくのを助けてくれるでしょう
     。

     'offset' は非負整数のオフセットとして指定できます。mmap の参照はフ
     ァイルの先頭からのオフセットに相対的になります。'offset' のデフォル
     トは 0 です。'offset' は ‘ALLOCATIONGRANULARITY’ の倍数でなければな
     りません。

     引数 ‘fileno’, ‘length’, ‘access’, ‘offset’ 付きで *note
     監査イベント: 1825. ‘mmap.__new__’ を送出します。

 -- クラス: mmap.mmap (fileno, length, flags=MAP_SHARED, prot=PROT_WRITE
          | PROT_READ, access=ACCESS_DEFAULT, offset=0, *, trackfd=True)

     '(Unix バージョン)' ファイルディスクリプタ 'fileno' で指定されたフ
     ァイルから 'length' バイトをマップし、mmap オブジェクトを返します。
     'length' が ‘0’ の場合、マップの最大の長さは *note mmap: 1ec. が呼
     ばれた時点でのファイルサイズになります。

     'flags' specifies the nature of the mapping.  *note MAP_PRIVATE:
     33c8. creates a private copy-on-write mapping, so changes to the
     contents of the mmap object will be private to this process, and
     *note MAP_SHARED: 33c9. creates a mapping that's shared with all
     other processes mapping the same areas of the file.  The default
     value is *note MAP_SHARED: 33c9.  Some systems have additional
     possible flags with the full list specified in *note MAP_*
     constants: 33ca.

     'prot' が指定された場合、希望のメモリ保護を与えます。 2つの最も有用
     な値は、 ‘PROT_READ’ と ‘PROT_WRITE’ です。これは、読込み可能または
     書込み可能を指定するものです。 'prot' のデフォルトは ‘PROT_READ |
     PROT_WRITE’ です。

     'access' はオプションのキーワード・パラメータとして、 'flags' と
     'prot' の代わりに指定してもかまいません。 'flags', 'prot' と
     'access' の両方を指定することは間違っています。このパラメータの使用
     法についての情報は、先に述べた 'access' の記述を参照してください。

     'offset' may be specified as a non-negative integer offset.  mmap
     references will be relative to the offset from the beginning of the
     file.  'offset' defaults to 0.  'offset' must be a multiple of
     ‘ALLOCATIONGRANULARITY’ which is equal to ‘PAGESIZE’ on Unix
     systems.

     If 'trackfd' is ‘False’, the file descriptor specified by 'fileno'
     will not be duplicated, and the resulting ‘mmap’ object will not be
     associated with the map's underlying file.  This means that the
     *note size(): 33cb. and *note resize(): 33cc. methods will fail.
     This mode is useful to limit the number of open file descriptors.

     macOS において、作成された memory mapping の正当性を確実にするため
     に 'fileno' で指定されたファイルディスクリプタは内部で自動的に物理
     的なストレージ (physical backing store) と同期されます。

     バージョン 3.13 で変更: 'trackfd' パラメータが追加されました。

     この例は *note mmap: 1ec. の簡潔な使い方を示すものです:

          import mmap

          # write a simple example file
          with open("hello.txt", "wb") as f:
              f.write(b"Hello Python!\n")

          with open("hello.txt", "r+b") as f:
              # memory-map the file, size 0 means whole file
              mm = mmap.mmap(f.fileno(), 0)
              # read content via standard file methods
              print(mm.readline())  # prints b"Hello Python!\n"
              # read content via slice notation
              print(mm[:5])  # prints b"Hello"
              # update content using slice notation;
              # note that new content must have same size
              mm[6:] = b" world!\n"
              # ... and read again using standard file methods
              mm.seek(0)
              print(mm.readline())  # prints b"Hello  world!\n"
              # close the map
              mm.close()

     *note mmap: 1ec. は *note with: 59c. 文の中でコンテキストマネージャ
     としても使えます:

          import mmap

          with mmap.mmap(-1, 13) as mm:
              mm.write(b"Hello world!")

     Added in version 3.2: コンテキストマネージャのサポート。

     次の例では無名マップを作り親プロセスと子プロセスの間でデータのやり
     とりをしてみせます:

          import mmap
          import os

          mm = mmap.mmap(-1, 13)
          mm.write(b"Hello world!")

          pid = os.fork()

          if pid == 0:  # In a child process
              mm.seek(0)
              print(mm.readline())

              mm.close()

     引数 ‘fileno’, ‘length’, ‘access’, ‘offset’ 付きで *note
     監査イベント: 1825. ‘mmap.__new__’ を送出します。

     メモリマップファイルオブジェクトは以下のメソッドをサポートしていま
     す:

      -- メソッド: close ()

          メモリマップファイルを閉じます。この呼出しの後にオブジェクトの
          他のメソッドの呼出すことは、 *note ValueError: 1e3. 例外の送出
          を引き起こします。このメソッドは開いたファイルのクローズはしま
          せん。

      -- の属性: closed

          ファイルが閉じている場合 ‘True’ となります。

          Added in version 3.2.

      -- メソッド: find (sub[, start[, end]])

          オブジェクト内の ['start', 'end'] の範囲に含まれている部分シー
          ケンス 'sub' が見つかった場所の最も小さいインデックスを返しま
          す。オプションの引数 'start' と 'end' はスライスに使われるとき
          のように解釈されます。失敗したときには ‘-1’ を返します。

          バージョン 3.5 で変更: 書き込み可能な *note bytes-like object:
          cfb. を使用できるようになりました。

      -- メソッド: flush ([offset[, size]])

          Flushes changes made to the in-memory copy of a file back to
          disk.  Without use of this call there is no guarantee that
          changes are written back before the object is destroyed.  If
          'offset' and 'size' are specified, only changes to the given
          range of bytes will be flushed to disk; otherwise, the whole
          extent of the mapping is flushed.  'offset' must be a multiple
          of the ‘PAGESIZE’ or ‘ALLOCATIONGRANULARITY’.

          ‘None’ が返されたら成功を意味します。呼び出しが失敗すると例外
          が送出されます。

          バージョン 3.8 で変更: Previously, a nonzero value was
          returned on success; zero was returned on error under Windows.
          A zero value was returned on success; an exception was raised
          on error under Unix.

      -- メソッド: madvise (option[, start[, length]])

          Send advice 'option' to the kernel about the memory region
          beginning at 'start' and extending 'length' bytes.  'option'
          must be one of the *note MADV_* constants: 33d0. available on
          the system.  If 'start' and 'length' are omitted, the entire
          mapping is spanned.  On some systems (including Linux),
          'start' must be a multiple of the ‘PAGESIZE’.

          Availability: Systems with the ‘madvise()’ system call.

          Added in version 3.8.

      -- メソッド: move (dest, src, count)

          オフセット 'src' から始まる 'count' バイトをインデックス
          'dest' の位置へコピーします。もし mmap が ‘ACCESS_READ’ で作成
          されていた場合、 *note TypeError: 502. 例外を発生させます。

      -- メソッド: read ([n])

          現在のファイル位置からの最大 'n' バイトを含む *note bytes:
          1a4. を返します。引数が省略されるか、 ‘None’ もしくは負の値が
          指定された場合、現在のファイル位置からマップ終端までの全てのバ
          イト列を返します。ファイル位置は返されたバイト列の直後を指すよ
          うに更新されます。

          バージョン 3.3 で変更: 引数が省略可能になり、 ‘None’ も受け付
          けるようになりました。

      -- メソッド: read_byte ()

          現在のファイル位置のバイトを整数値として返し、ファイル位置を 1
          進めます。

      -- メソッド: readline ()

          Returns a single line, starting at the current file position
          and up to the next newline.  The file position is updated to
          point after the bytes that were returned.

      -- メソッド: resize (newsize)

          Resizes the map and the underlying file, if any.

          Resizing a map created with 'access' of ‘ACCESS_READ’ or
          ‘ACCESS_COPY’, will raise a *note TypeError: 502. exception.
          Resizing a map created with with 'trackfd' set to ‘False’,
          will raise a *note ValueError: 1e3. exception.

          'On Windows': Resizing the map will raise an *note OSError:
          3f0. if there are other maps against the same named file.
          Resizing an anonymous map (ie against the pagefile) will
          silently create a new map with the original data copied over
          up to the length of the new size.

          バージョン 3.11 で変更: Correctly fails if attempting to
          resize when another map is held Allows resize against an
          anonymous map on Windows

      -- メソッド: rfind (sub[, start[, end]])

          オブジェクト内の ['start', 'end'] の範囲に含まれている部分シー
          ケンス 'sub' が見つかった場所の最も大きいインデックスを返しま
          す。オプションの引数 'start' と 'end' はスライスに使われるとき
          のように解釈されます。失敗したときには ‘-1’ を返します。

          バージョン 3.5 で変更: 書き込み可能な *note bytes-like object:
          cfb. を使用できるようになりました。

      -- メソッド: seek (pos[, whence])

          ファイルの現在位置をセットします。 'whence' 引数はオプションで
          あり、デフォルトは ‘os.SEEK_SET’ つまり ‘0’ (絶対位置)です。そ
          の他の値として、 ‘os.SEEK_CUR’ つまり ‘1’ (現在位置からの相対
          位置)と ‘os.SEEK_END’ つまり ‘2’ (ファイルの終わりからの相対位
          置)があります。

          バージョン 3.13 で変更: ‘None’ ではなく新しい絶対位置を返しま
          す。

      -- メソッド: seekable ()

          Return whether the file supports seeking, and the return value
          is always ‘True’.

          Added in version 3.13.

      -- メソッド: size ()

          ファイルの長さを返します。メモリマップ領域のサイズより大きいか
          もしれません。

      -- メソッド: tell ()

          ファイルポインタの現在位置を返します。

      -- メソッド: write (bytes)

          メモリ内のファイルポイントの現在位置に 'bytes' のバイト列を書
          き込み、書き込まれたバイト数を返します(もし書き込みが失敗した
          ら *note ValueError: 1e3. が送出されるため、‘len(bytes)’ より
          少なくなりません)。ファイル位置はバイト列が書き込まれた位置に
          更新されます。もしmmapが ‘ACCESS_READ’ とともに作成されていた
          場合は、書き込みは *note TypeError: 502. 例外を送出するでしょ
          う。

          バージョン 3.5 で変更: 書き込み可能な *note bytes-like object:
          cfb. を使用できるようになりました。

          バージョン 3.6 で変更: 書きこまれたバイト数を返すようになりま
          した。

      -- メソッド: write_byte (byte)

          メモリ内のファイル・ポインタの現在位置に整数 'byte' を書き込み
          ます。ファイル位置は ‘1’ だけ進みます。もし mmap が
          ‘ACCESS_READ’ で作成されていた場合、書き込み時に *note
          TypeError: 502. 例外を発生させるでしょう。

* Menu:

* MADV_* 定数::
* MAP_* 定数::


File: python.info,  Node: MADV_* 定数,  Next: MAP_* 定数,  Up: mmap --- メモリマップファイルのサポート

5.18.7.1 MADV_* 定数
....................

 -- データ: mmap.MADV_NORMAL
 -- データ: mmap.MADV_RANDOM
 -- データ: mmap.MADV_SEQUENTIAL
 -- データ: mmap.MADV_WILLNEED
 -- データ: mmap.MADV_DONTNEED
 -- データ: mmap.MADV_REMOVE
 -- データ: mmap.MADV_DONTFORK
 -- データ: mmap.MADV_DOFORK
 -- データ: mmap.MADV_HWPOISON
 -- データ: mmap.MADV_MERGEABLE
 -- データ: mmap.MADV_UNMERGEABLE
 -- データ: mmap.MADV_SOFT_OFFLINE
 -- データ: mmap.MADV_HUGEPAGE
 -- データ: mmap.MADV_NOHUGEPAGE
 -- データ: mmap.MADV_DONTDUMP
 -- データ: mmap.MADV_DODUMP
 -- データ: mmap.MADV_FREE
 -- データ: mmap.MADV_NOSYNC
 -- データ: mmap.MADV_AUTOSYNC
 -- データ: mmap.MADV_NOCORE
 -- データ: mmap.MADV_CORE
 -- データ: mmap.MADV_PROTECT
 -- データ: mmap.MADV_FREE_REUSABLE
 -- データ: mmap.MADV_FREE_REUSE

     These options can be passed to *note mmap.madvise(): 9d6.  Not
     every option will be present on every system.

     Availability: Systems with the madvise() system call.

     Added in version 3.8.


File: python.info,  Node: MAP_* 定数,  Prev: MADV_* 定数,  Up: mmap --- メモリマップファイルのサポート

5.18.7.2 MAP_* 定数
...................

 -- データ: mmap.MAP_SHARED
 -- データ: mmap.MAP_PRIVATE
 -- データ: mmap.MAP_32BIT
 -- データ: mmap.MAP_ALIGNED_SUPER
 -- データ: mmap.MAP_ANON
 -- データ: mmap.MAP_ANONYMOUS
 -- データ: mmap.MAP_CONCEAL
 -- データ: mmap.MAP_DENYWRITE
 -- データ: mmap.MAP_EXECUTABLE
 -- データ: mmap.MAP_HASSEMAPHORE
 -- データ: mmap.MAP_JIT
 -- データ: mmap.MAP_NOCACHE
 -- データ: mmap.MAP_NOEXTEND
 -- データ: mmap.MAP_NORESERVE
 -- データ: mmap.MAP_POPULATE
 -- データ: mmap.MAP_RESILIENT_CODESIGN
 -- データ: mmap.MAP_RESILIENT_MEDIA
 -- データ: mmap.MAP_STACK
 -- データ: mmap.MAP_TPRO
 -- データ: mmap.MAP_TRANSLATED_ALLOW_EXECUTE
 -- データ: mmap.MAP_UNIX03

     These are the various flags that can be passed to *note
     mmap.mmap(): 1ec.  *note MAP_ALIGNED_SUPER: 16c1. is only available
     at FreeBSD and *note MAP_CONCEAL: 16c2. is only available at
     OpenBSD. Note that some options might not be present on some
     systems.

     バージョン 3.10 で変更: Added *note MAP_POPULATE: 18b2. constant.

     Added in version 3.11: Added *note MAP_STACK: 33f6. constant.

     Added in version 3.12: Added *note MAP_ALIGNED_SUPER: 16c1. and
     *note MAP_CONCEAL: 16c2. constants.

     Added in version 3.13: Added *note MAP_32BIT: 1605, *note
     MAP_HASSEMAPHORE: 1600, *note MAP_JIT: 1602, *note MAP_NOCACHE:
     1601, *note MAP_NOEXTEND: 15ff, *note MAP_NORESERVE: 15fe, *note
     MAP_RESILIENT_CODESIGN: 1603, *note MAP_RESILIENT_MEDIA: 1604,
     *note MAP_TPRO: 1608, *note MAP_TRANSLATED_ALLOW_EXECUTE: 1606, and
     *note MAP_UNIX03: 1607. constants.


File: python.info,  Node: インターネット上のデータの操作,  Next: 構造化マークアップツール,  Prev: ネットワーク通信とプロセス間通信,  Up: Python 標準ライブラリ

5.19 インターネット上のデータの操作
===================================

この章ではインターネット上で一般的に利用されているデータ形式の操作をサポ
ートするモジュール群について記述します。

* Menu:

* email: email --- 電子メールと MIME 処理のためのパッケージ. 電子メールと MIME 処理のためのパッケージ
* json: json --- JSON エンコーダーとデコーダー. JSON エンコーダーとデコーダー
* mailbox: mailbox --- 様々な形式のメールボックスを操作する. 様々な形式のメールボックスを操作する
* mimetypes: mimetypes --- ファイル名を MIME タイプへマップする. ファイル名を MIME タイプへマップする
* base64: base64 --- Base16 Base32 Base64 Base85 データのエンコード. Base16, Base32, Base64, Base85 データのエンコード
* binascii: binascii --- バイナリ と ASCII 間の変換. バイナリ と ASCII 間の変換
* quopri: quopri --- MIME quoted-printable データのエンコードとデコード. MIME quoted-printable データのエンコードとデコード


File: python.info,  Node: email --- 電子メールと MIME 処理のためのパッケージ,  Next: json --- JSON エンコーダーとデコーダー,  Up: インターネット上のデータの操作

5.19.1 ‘email’ -- 電子メールと MIME 処理のためのパッケージ
----------------------------------------------------------

'ソースコード:' Lib/email/__init__.py(1)

__________________________________________________________________

*note email: 32. パッケージは、電子メールメッセージを管理するライブラリ
です。 特に、SMTP（ RFC 2821(2))、NNTP、またはその他のサーバーに電子メー
ルメッセージを送信するようには設計されていません。これらは、*note
smtplib: b7. などのモジュールの関数群です。 *note email: 32. パッケージ
は、可能な限りRFCに準拠するよう試みています。 RFC 5322(3) や RFC 6532(4)
のほか、 RFC 2045(5)、 RFC 2046(6)、 RFC 2047(7)、 RFC 2183(8)、 RFC
2231(9) などのMIME関連のRFCに対応しています。

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.

The central component of the package is an "object model" that
represents email messages.  An application interacts with the package
primarily through the object model interface defined in the *note
message: 3b. sub-module.  The application can use this API to ask
questions about an existing email, to construct a new email, or to add
or remove email subcomponents that themselves use the same object model
interface.  That is, following the nature of email messages and their
MIME subcomponents, the email object model is a tree structure of
objects that all provide the *note EmailMessage: 25c. API.

The other two major components of the package are the *note parser: 45.
and the *note generator: 37.  The parser takes the serialized version of
an email message (a stream of bytes) and converts it into a tree of
*note EmailMessage: 25c. objects.  The generator takes an *note
EmailMessage: 25c. and turns it back into a serialized byte stream.
(The parser and generator also handle streams of text characters, but
this usage is discouraged as it is too easy to end up with messages that
are not valid in one way or another.)

The control component is the *note policy: 46. module.  Every *note
EmailMessage: 25c, every *note generator: 37, and every *note parser:
45. has an associated *note policy: 46. object that controls its
behavior.  Usually an application only needs to specify the policy when
an *note EmailMessage: 25c. is created, either by directly instantiating
an *note EmailMessage: 25c. to create a new email, or by parsing an
input stream using a *note parser: 45.  But the policy can be changed
when the message is serialized using a *note generator: 37.  This
allows, for example, a generic email message to be parsed from disk, but
to serialize it using standard SMTP settings when sending it to an email
server.

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 treat the email message as a structured tree of
unicode text and binary attachments, without having to worry about how
these are represented when serialized.  In practice, however, it is
often necessary to be aware of at least some of the rules governing MIME
messages and their structure, specifically the names and nature of the
MIME "content types" and how they identify multipart documents.  For the
most part this knowledge should only be required for more complex
applications, and even then it should only be the high level structure
in question, and not the details of how those structures are
represented.  Since MIME content types are used widely in modern
internet software (not just email), this will be a familiar concept to
many programmers.

The following sections describe the functionality of the *note email:
32. package.  We start with the *note message: 3b. object model, which
is the primary interface an application will use, and follow that with
the *note parser: 45. and *note generator: 37. components.  Then we
cover the *note policy: 46. controls, which completes the treatment of
the main components of the library.

The next three sections cover the exceptions the package may raise and
the defects (non-compliance with the RFCs) that the *note parser: 45.
may detect.  Then we cover the *note headerregistry: 39. and the *note
contentmanager: 34. sub-components, which provide tools for doing more
detailed manipulation of headers and payloads, respectively.  Both of
these components contain features relevant to consuming and producing
non-trivial messages, but also document their extensibility APIs, which
will be of interest to advanced applications.

Following those is a set of examples of using the fundamental parts of
the APIs covered in the preceding sections.

The foregoing represent the modern (unicode friendly) API of the email
package.  The remaining sections, starting with the *note Message: 25d.
class, cover the legacy *note compat32: c67. API that deals much more
directly with the details of how email messages are represented.  The
*note compat32: c67. API does 'not' hide the details of the RFCs from
the application, but for applications that need to operate at that
level, they can be useful tools.  This documentation is also relevant
for applications that are still using the *note compat32: c67. API for
backward compatibility reasons.

バージョン 3.6 で変更: Docs reorganized and rewritten to promote the new
*note EmailMessage: 25c./*note EmailPolicy: 1087. API.

*note email: 32. パッケージ文書の内容

* Menu:

* email.message; Representing an email message: email message Representing an email message.
* email.parser; Parsing email messages: email parser Parsing email messages.
* email.generator; Generating MIME documents: email generator Generating MIME documents.
* email.policy; Policy Objects: email policy Policy Objects.
* email.errors; Exception and Defect classes: email errors Exception and Defect classes.
* email.headerregistry; Custom Header Objects: email headerregistry Custom Header Objects.
* email.contentmanager; Managing MIME Content: email contentmanager Managing MIME Content.
* email; 使用例: email 使用例.
* email.message.Message; compat32 API を使用した電子メールメッセージの表現: email message Message compat32 API を使用した電子メールメッセージの表現.
* email.mime; Creating email and MIME objects from scratch: email mime Creating email and MIME objects from scratch.
* email.header; 国際化されたヘッダー: email header 国際化されたヘッダー.
* email.charset; 文字集合の表現: email charset 文字集合の表現.
* email.encoders; エンコーダー: email encoders エンコーダー.
* email.utils; Miscellaneous utilities: email utils Miscellaneous utilities.
* email.iterators; イテレータ: email iterators イテレータ.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/__init__.py

   (2) https://datatracker.ietf.org/doc/html/rfc2821.html

   (3) https://datatracker.ietf.org/doc/html/rfc5322.html

   (4) https://datatracker.ietf.org/doc/html/rfc6532.html

   (5) https://datatracker.ietf.org/doc/html/rfc2045.html

   (6) https://datatracker.ietf.org/doc/html/rfc2046.html

   (7) https://datatracker.ietf.org/doc/html/rfc2047.html

   (8) https://datatracker.ietf.org/doc/html/rfc2183.html

   (9) https://datatracker.ietf.org/doc/html/rfc2231.html


File: python.info,  Node: email message Representing an email message,  Next: email parser Parsing email messages,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.1 ‘email.message’: Representing an email message
.......................................................

'ソースコード:' Lib/email/message.py(1)

__________________________________________________________________

Added in version 3.6: (2)

The central class in the *note email: 32. package is the *note
EmailMessage: 25c. class, imported from the *note email.message: 3b.
module.  It is the base class for the *note email: 32. object model.
*note EmailMessage: 25c. provides the core functionality for setting and
querying header fields, for accessing message bodies, and for creating
or modifying structured messages.

An email message consists of 'headers' and a 'payload' (which is also
referred to as the 'content').  Headers are RFC 5322(3) or RFC 6532(4)
style field names and values, where the field name and value are
separated by a colon.  The colon is not part of either the field name or
the field value.  The payload may be a simple text message, or a binary
object, or a structured sequence of sub-messages each with their own set
of headers and their own payload.  The latter type of payload is
indicated by the message having a MIME type such as ‘multipart/*’ or
‘message/rfc822’.

The conceptual model provided by an *note EmailMessage: 25c. object is
that of an ordered dictionary of headers coupled with a 'payload' that
represents the RFC 5322(5) body of the message, which might be a list of
sub-‘EmailMessage’ objects.  In addition to the normal dictionary
methods for accessing the header names and values, there are methods for
accessing specialized information from the headers (for example the MIME
content type), for operating on the payload, for generating a serialized
version of the message, and for recursively walking over the object
tree.

The *note EmailMessage: 25c. dictionary-like interface is indexed by the
header names, which must be ASCII values.  The values of the dictionary
are strings with some extra methods.  Headers are stored and returned in
case-preserving form, but field names are matched case-insensitively.
The keys are ordered, but unlike a real dict, there can be duplicates.
Additional methods are provided for working with headers that have
duplicate keys.

The 'payload' is either a string or bytes object, in the case of simple
message objects, or a list of *note EmailMessage: 25c. objects, for MIME
container documents such as ‘multipart/*’ and ‘message/rfc822’ message
objects.

 -- クラス: email.message.EmailMessage (policy=default)

     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 *note default: 1088. policy, which follows the rules
     of the email RFCs except for line endings (instead of the RFC
     mandated ‘\r\n’, it uses the Python standard ‘\n’ line endings).
     For more information see the *note policy: 46. documentation.

      -- メソッド: as_string (unixfrom=False, maxheaderlen=None,
               policy=None)

          Return the entire message flattened as a string.  When
          optional 'unixfrom' is true, the envelope header is included
          in the returned string.  'unixfrom' defaults to ‘False’.  For
          backward compatibility with the base *note Message: 25d. class
          'maxheaderlen' is accepted, but defaults to ‘None’, which
          means that by default the line length is controlled by the
          *note max_line_length: 3400. of the policy.  The 'policy'
          argument may be used to override the default policy obtained
          from the message instance.  This can be used to control some
          of the formatting produced by the method, since the specified
          'policy' will be passed to the *note Generator: 119e.

          もし、文字列への変換を完全に行うためにデフォルト値を埋める必要
          がある場合、メッセージのフラット化は *note EmailMessage: 25c.
          の変更を引き起こす可能性があります (例えば、MIME の境界が生成
          される、変更される等)。

          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 *note email.generator.Generator: 119e. for a
          more flexible API for serializing messages.  Note also that
          this method is restricted to producing messages serialized as
          "7 bit clean" when *note utf8: dc5. is ‘False’, which is the
          default.

          バージョン 3.6 で変更: 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.

      -- メソッド: __str__ ()

          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.

          バージョン 3.4 で変更: the method was changed to use
          ‘utf8=True’, thus producing an RFC 6531(6)-like message
          representation, instead of being a direct alias for *note
          as_string(): 33ff.

      -- メソッド: as_bytes (unixfrom=False, policy=None)

          Return the entire message flattened as a bytes object.  When
          optional 'unixfrom' is true, the envelope header is included
          in the returned string.  'unixfrom' defaults to ‘False’.  The
          'policy' argument may be used to override the default policy
          obtained from the message instance.  This can be used to
          control some of the formatting produced by the method, since
          the specified 'policy' will be passed to the *note
          BytesGenerator: 119f.

          もし、文字列への変換を完全に行うためにデフォルト値を埋める必要
          がある場合、メッセージのフラット化は *note EmailMessage: 25c.
          の変更を引き起こす可能性があります (例えば、MIME の境界が生成
          される、変更される等)。

          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 *note email.generator.BytesGenerator: 119f. for
          a more flexible API for serializing messages.

      -- メソッド: __bytes__ ()

          Equivalent to *note as_bytes(): 3402.  Allows ‘bytes(msg)’ to
          produce a bytes object containing the serialized message.

      -- メソッド: is_multipart ()

          Return ‘True’ if the message's payload is a list of sub-*note
          EmailMessage: 25c. objects, otherwise return ‘False’.  When
          *note is_multipart(): 3404. returns ‘False’, the payload
          should be a string object (which might be a CTE encoded binary
          payload).  Note that *note is_multipart(): 3404. returning
          ‘True’ does not necessarily mean that
          "msg.get_content_maintype() == 'multipart'" will return the
          ‘True’.  For example, ‘is_multipart’ will return ‘True’ when
          the *note EmailMessage: 25c. is of type ‘message/rfc822’.

      -- メソッド: set_unixfrom (unixfrom)

          Set the message's envelope header to 'unixfrom', which should
          be a string.  (See *note mboxMessage: 3406. for a brief
          description of this header.)

      -- メソッド: get_unixfrom ()

          メッセージのエンベロープヘッダを返します。エンベロープヘッダが
          設定されていない場合は ‘None’ が返されます。

     The following methods implement the mapping-like interface for
     accessing the message's headers.  Note that there are some semantic
     differences between these methods and a normal mapping (i.e.
     dictionary) interface.  For example, in a dictionary there are no
     duplicate keys, but here there may be duplicate message headers.
     Also, in dictionaries there is no guaranteed order to the keys
     returned by *note keys(): 3408, but in an *note EmailMessage: 25c.
     object, headers are always returned in the order they appeared in
     the original message, or in which they were added to the message
     later.  Any header deleted and then re-added is always appended to
     the end of the header list.

     These semantic differences are intentional and are biased toward
     convenience in the most common use cases.

     注意: どんな場合も、メッセージ中のエンベロープヘッダはこのマップ形
     式のインタフェイスには含まれません。

      -- メソッド: __len__ ()

          複製されたものもふくめてヘッダ数の合計を返します。

      -- メソッド: __contains__ (name)

          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:

               if 'message-id' in myMessage:
                  print('Message-ID:', myMessage['message-id'])

      -- メソッド: __getitem__ (name)

          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 *note KeyError: 31d. is never raised.

          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 *note get_all(): 340c. method
          to get the values of all the extant headers named 'name'.

          Using the standard (non-‘compat32’) policies, the returned
          value is an instance of a subclass of *note
          email.headerregistry.BaseHeader: 340d.

      -- メソッド: __setitem__ (name, val)

          メッセージヘッダに 'name' という名前の 'val' という値をもつフ
          ィールドをあらたに追加します。このフィールドは現在メッセージに
          存在するヘッダーのいちばん後に追加されます。

          注意: このメソッドでは、すでに同一の名前で存在するフィールドは
          上書き 'されません'。もしメッセージが名前 'name' をもつフィー
          ルドをひとつしか持たないようにしたければ、最初にそれを除去して
          ください。たとえば:

               del msg['subject']
               msg['subject'] = 'Python roolz!'

          If the *note policy: 46. defines certain headers to be unique
          (as the standard policies do), this method may raise a *note
          ValueError: 1e3. when an attempt is made to assign a value to
          such a header when one already exists.  This behavior is
          intentional for consistency's sake, but do not depend on it as
          we may choose to make such assignments do an automatic
          deletion of the existing header in the future.

      -- メソッド: __delitem__ (name)

          メッセージのヘッダから、'name' という名前をもつフィールドをす
          べて除去します。たとえこの名前をもつヘッダが存在していなくても
          例外は発生しません。

      -- メソッド: keys ()

          メッセージ中にあるすべてのヘッダのフィールド名のリストを返しま
          す。

      -- メソッド: values ()

          メッセージ中にあるすべてのフィールドの値のリストを返します。

      -- メソッド: items ()

          メッセージ中にあるすべてのヘッダのフィールド名とその値を 2-タ
          プルのリストとして返します。

      -- メソッド: get (name, failobj=None)

          Return the value of the named header field.  This is identical
          to *note __getitem__(): 264. except that optional 'failobj' is
          returned if the named header is missing ('failobj' defaults to
          ‘None’).

     Here are some additional useful header related methods:

      -- メソッド: get_all (name, failobj=None)

          'name' の名前をもつフィールドのすべての値からなるリストを返し
          ます。該当する名前のヘッダがメッセージ中に含まれていない場合は
          'failobj' (デフォルトでは ‘None’) が返されます。

      -- メソッド: add_header (_name, _value, **_params)

          拡張ヘッダ設定。このメソッドは *note __setitem__(): 340e. と似
          ていますが、追加のヘッダ・パラメータをキーワード引数で指定でき
          るところが違っています。 '_name' に追加するヘッダフィールドを
          、 '_value' にそのヘッダの '最初の' 値を渡します。

          For each item in the keyword argument dictionary '_params',
          the key is taken as the parameter name, with underscores
          converted to dashes (since dashes are illegal in Python
          identifiers).  Normally, the parameter will be added as
          ‘key="value"’ unless the value is ‘None’, in which case only
          the key will be added.

          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 ‘(CHARSET, LANGUAGE, VALUE)’,
          where ‘CHARSET’ is a string naming the charset to be used to
          encode the value, ‘LANGUAGE’ can usually be set to ‘None’ or
          the empty string (see RFC 2231(7) for other possibilities),
          and ‘VALUE’ is the string value containing non-ASCII code
          points.  If a three tuple is not passed and the value contains
          non-ASCII characters, it is automatically encoded in RFC
          2231(8) format using a ‘CHARSET’ of ‘utf-8’ and a ‘LANGUAGE’
          of ‘None’.

          以下に例を示します。:

               msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')

          こうするとヘッダには以下のように追加されます

               Content-Disposition: attachment; filename="bud.gif"

          An example of the extended interface with non-ASCII
          characters:

               msg.add_header('Content-Disposition', 'attachment',
                              filename=('iso-8859-1', '', 'Fußballer.ppt'))

      -- メソッド: replace_header (_name, _value)

          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 *note KeyError: 31d.

      -- メソッド: get_content_type ()

          Return the message's content type, coerced to lower case of
          the form ‘maintype/subtype’.  If there is no ‘Content-Type’
          header in the message return the value returned by *note
          get_default_type(): 3416.  If the ‘Content-Type’ header is
          invalid, return ‘text/plain’.

          (According to RFC 2045(9), messages always have a default
          type, *note get_content_type(): 3415. will always return a
          value.  RFC 2045(10) defines a message's default type to be
          ‘text/plain’ unless it appears inside a ‘multipart/digest’
          container, in which case it would be ‘message/rfc822’.  If the
          ‘Content-Type’ header has an invalid type specification, RFC
          2045(11) mandates that the default type be ‘text/plain’.)

      -- メソッド: get_content_maintype ()

          そのメッセージの主 content-type を返します。これは *note
          get_content_type(): 3415. によって返される文字列の ‘maintype’
          部分です。

      -- メソッド: get_content_subtype ()

          そのメッセージの副 content-type (sub content-type、subtype) を
          返します。これは *note get_content_type(): 3415. によって返さ
          れる文字列の ‘subtype’ 部分です。

      -- メソッド: get_default_type ()

          デフォルトの content-type を返します。ほどんどのメッセージでは
          デフォルトの content-type は ‘text/plain’ ですが、メッセージが
          ‘multipart/digest’ コンテナに含まれているときだけ例外的に
          ‘message/rfc822’ になります。

      -- メソッド: set_default_type (ctype)

          Set the default content type.  'ctype' should either be
          ‘text/plain’ or ‘message/rfc822’, although this is not
          enforced.  The default content type is not stored in the
          ‘Content-Type’ header, so it only affects the return value of
          the ‘get_content_type’ methods when no ‘Content-Type’ header
          is present in the message.

      -- メソッド: set_param (param, value, header='Content-Type',
               requote=True, charset=None, language='', replace=False)

          Set a parameter in the ‘Content-Type’ header.  If the
          parameter already exists in the header, replace its value with
          'value'.  When 'header' is ‘Content-Type’ (the default) and
          the header does not yet exist in the message, add it, set its
          value to ‘text/plain’, and append the new parameter value.
          Optional 'header' specifies an alternative header to
          ‘Content-Type’.

          If the value contains non-ASCII characters, the charset and
          language may be explicitly specified using the optional
          'charset' and 'language' parameters.  Optional 'language'
          specifies the RFC 2231(12) language, defaulting to the empty
          string.  Both 'charset' and 'language' should be strings.  The
          default is to use the ‘utf8’ 'charset' and ‘None’ for the
          'language'.

          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.

          Use of the 'requote' parameter with *note EmailMessage: 25c.
          objects is deprecated.

          Note that existing parameter values of headers may be accessed
          through the *note params: 341b. attribute of the header value
          (for example, ‘msg['Content-Type'].params['charset']’).

          バージョン 3.4 で変更: ‘replace’ キーワードが追加されました。

      -- メソッド: del_param (param, header='content-type',
               requote=True)

          指定されたパラメータを ‘Content-Type’ ヘッダ中から完全にとりの
          ぞきます。ヘッダはそのパラメータと値がない状態に書き換えられま
          す。オプション変数 'header' が与えられた場合、 ‘Content-Type’
          のかわりにそのヘッダが使用されます。

          Use of the 'requote' parameter with *note EmailMessage: 25c.
          objects is deprecated.

      -- メソッド: get_filename (failobj=None)

          そのメッセージ中の ‘Content-Disposition’ ヘッダにある、
          ‘filename’ パラメータの値を返します。目的のヘッダに ‘filename’
          パラメータがない場合には ‘Content-Type’ ヘッダにある ‘name’ パ
          ラメータを探します。それも無い場合またはヘッダが無い場合には
          'failobj' が返されます。返される文字列はつねに *note
          email.utils.unquote(): 341e. によって unquote されます。

      -- メソッド: get_boundary (failobj=None)

          そのメッセージ中の ‘Content-Type’ ヘッダにある、 ‘boundary’ パ
          ラメータの値を返します。目的のヘッダが欠けていたり、
          ‘boundary’ パラメータがない場合には 'failobj' が返されます。返
          される文字列はつねに *note email.utils.unquote(): 341e. によっ
          て unquote されます。

      -- メソッド: set_boundary (boundary)

          メッセージ中の ‘Content-Type’ ヘッダにある、 ‘boundary’ パラメ
          ータに値を設定します。 *note set_boundary(): 3420. は必要に応
          じて 'boundary' を quote します。そのメッセージが
          ‘Content-Type’ ヘッダを含んでいない場合、 *note
          HeaderParseError: 3421. が発生します。

          Note that using this method is subtly different from deleting
          the old ‘Content-Type’ header and adding a new one with the
          new boundary via *note add_header(): 3413, because *note
          set_boundary(): 3420. preserves the order of the
          ‘Content-Type’ header in the list of headers.

      -- メソッド: get_content_charset (failobj=None)

          そのメッセージ中の ‘Content-Type’ ヘッダにある、 ‘charset’ パ
          ラメータの値を返します。値はすべて小文字に変換されます。メッセ
          ージ中に ‘Content-Type’ がなかったり、このヘッダ中に
          ‘charaset’ パラメータがない場合には 'failobj' が返されます。

      -- メソッド: get_charsets (failobj=None)

          メッセージ中に含まれる文字セットの名前をすべてリストにして返し
          ます。そのメッセージが ‘multipart’ である場合、返されるリスト
          の各要素がそれぞれの subpart のペイロードに対応します。それ以
          外の場合、これは長さ 1 のリストを返します。

          リスト中の各要素は文字列であり、これは対応する subpart 中のそ
          れぞれの ‘Content-Type’ ヘッダにある ‘charset’ の値です。その
          subpart が ‘Content-Type’ をもってないか、 ‘charset’ がないか
          、あるいは MIME maintype が ‘text’ でないいずれかの場合には、
          リストの要素として 'failobj' が返されます。

      -- メソッド: is_attachment ()

          ‘Content-Disposition’ ヘッダが存在し、その (大文字小文字を区別
          しない) 値が ‘attachment’ の場合、 ‘True’ を返します。 それ以
          外の場合は ‘False’ を返します。

          バージョン 3.4.2 で変更: *note is_multipart(): 3425. との一貫
          性のために、is_attachment が属性からメソッドになりました。

      -- メソッド: get_content_disposition ()

          Return the lowercased value (without parameters) of the
          message's ‘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(13).

          Added in version 3.5.

     The following methods relate to interrogating and manipulating the
     content (payload) of the message.

      -- メソッド: walk ()

          *note walk(): 3427. メソッドは多目的のジェネレータで、これはあ
          るメッセージオブジェクトツリー中のすべての part および subpart
          をわたり歩くのに使えます。順序は深さ優先です。おそらく典型的な
          用法は、 *note walk(): 3427. を ‘for’ ループ中でのイテレータと
          して使うことでしょう。ループを一回まわるごとに、次の subpart が
          返されるのです。

          以下の例は、 multipart メッセージのすべての part において、そ
          の MIME タイプを表示していくものです。 :

               >>> for part in msg.walk():
               ...     print(part.get_content_type())
               multipart/report
               text/plain
               message/delivery-status
               text/plain
               text/plain
               message/rfc822
               text/plain

          ‘walk’ iterates over the subparts of any part where *note
          is_multipart(): 3404. 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:

               >>> from email.iterators import _structure
               >>> for part in msg.walk():
               ...     print(part.get_content_maintype() == 'multipart',
               ...           part.is_multipart())
               True True
               False False
               False True
               False False
               False False
               False True
               False False
               >>> _structure(msg)
               multipart/report
                   text/plain
                   message/delivery-status
                       text/plain
                       text/plain
                   message/rfc822
                       text/plain

          Here the ‘message’ parts are not ‘multiparts’, but they do
          contain subparts.  ‘is_multipart()’ returns ‘True’ and ‘walk’
          descends into the subparts.

      -- メソッド: get_body (preferencelist=('related', 'html',
               'plain'))

          メッセージの "本体" の最有力候補となる MIME 部を返します。

          '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.

          Start looking for candidate matches with the object on which
          the ‘get_body’ method is called.

          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.

          When encountering a ‘multipart/related’, check the ‘start’
          parameter and if a part with a matching ‘Content-ID’ is found,
          consider only it when looking for candidate matches.
          Otherwise consider only the first (default root) part of the
          ‘multipart/related’.

          If a part has a ‘Content-Disposition’ header, only consider
          the part a candidate match if the value of the header is
          ‘inline’.

          If none of the candidates matches any of the preferences in
          'preferencelist', return ‘None’.

          Notes: (1) For most applications the only 'preferencelist'
          combinations that really make sense are ‘('plain',)’,
          ‘('html', 'plain')’, and the default ‘('related', 'html',
          'plain')’.  (2) Because matching starts with the object on
          which ‘get_body’ is called, calling ‘get_body’ on a
          ‘multipart/related’ will return the object itself unless
          'preferencelist' has a non-default value.  (3) Messages (or
          message parts) that do not specify a ‘Content-Type’ or whose
          ‘Content-Type’ header is invalid will be treated as if they
          are of type ‘text/plain’, which may occasionally cause
          ‘get_body’ to return unexpected results.

      -- メソッド: iter_attachments ()

          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 each of ‘text/plain’, ‘text/html’,
          ‘multipart/related’, or ‘multipart/alternative’ (unless they
          are explicitly marked as attachments via ‘Content-Disposition:
          attachment’), and return all remaining parts.  When applied
          directly to a ‘multipart/related’, return an iterator over the
          all the related parts except the root part (ie: the part
          pointed to by the ‘start’ parameter, or the first part if
          there is no ‘start’ parameter or the ‘start’ parameter doesn't
          match the ‘Content-ID’ of any of the parts).  When applied
          directly to a ‘multipart/alternative’ or a non-‘multipart’,
          return an empty iterator.

      -- メソッド: iter_parts ()

          Return an iterator over all of the immediate sub-parts of the
          message, which will be empty for a non-‘multipart’.  (See also
          *note walk(): 3427.)

      -- メソッド: get_content (*args, content_manager=None, **kw)

          Call the *note get_content(): 342c. method of the
          'content_manager', passing self as the message object, and
          passing along any other arguments or keywords as additional
          arguments.  If 'content_manager' is not specified, use the
          ‘content_manager’ specified by the current *note policy: 46.

      -- メソッド: set_content (*args, content_manager=None, **kw)

          Call the *note set_content(): 342d. method of the
          'content_manager', passing self as the message object, and
          passing along any other arguments or keywords as additional
          arguments.  If 'content_manager' is not specified, use the
          ‘content_manager’ specified by the current *note policy: 46.

      -- メソッド: make_related (boundary=None)

          Convert a non-‘multipart’ message into a ‘multipart/related’
          message, moving any existing ‘Content-’ headers and payload
          into a (new) first part of the ‘multipart’.  If 'boundary' is
          specified, use it as the boundary string in the multipart,
          otherwise leave the boundary to be automatically created when
          it is needed (for example, when the message is serialized).

      -- メソッド: make_alternative (boundary=None)

          Convert a non-‘multipart’ or a ‘multipart/related’ into a
          ‘multipart/alternative’, moving any existing ‘Content-’
          headers and payload into a (new) first part of the
          ‘multipart’.  If 'boundary' is specified, use it as the
          boundary string in the multipart, otherwise leave the boundary
          to be automatically created when it is needed (for example,
          when the message is serialized).

      -- メソッド: make_mixed (boundary=None)

          Convert a non-‘multipart’, a ‘multipart/related’, or a
          ‘multipart-alternative’ into a ‘multipart/mixed’, moving any
          existing ‘Content-’ headers and payload into a (new) first
          part of the ‘multipart’.  If 'boundary' is specified, use it
          as the boundary string in the multipart, otherwise leave the
          boundary to be automatically created when it is needed (for
          example, when the message is serialized).

      -- メソッド: add_related (*args, content_manager=None, **kw)

          If the message is a ‘multipart/related’, create a new message
          object, pass all of the arguments to its *note set_content():
          1813. method, and *note attach(): 3432. it to the ‘multipart’.
          If the message is a non-‘multipart’, call *note
          make_related(): 342e. and then proceed as above.  If the
          message is any other type of ‘multipart’, raise a *note
          TypeError: 502.  If 'content_manager' is not specified, use
          the ‘content_manager’ specified by the current *note policy:
          46.  If the added part has no ‘Content-Disposition’ header,
          add one with the value ‘inline’.

      -- メソッド: add_alternative (*args, content_manager=None, **kw)

          If the message is a ‘multipart/alternative’, create a new
          message object, pass all of the arguments to its *note
          set_content(): 1813. method, and *note attach(): 3432. it to
          the ‘multipart’.  If the message is a non-‘multipart’ or
          ‘multipart/related’, call *note make_alternative(): 342f. and
          then proceed as above.  If the message is any other type of
          ‘multipart’, raise a *note TypeError: 502.  If
          'content_manager' is not specified, use the ‘content_manager’
          specified by the current *note policy: 46.

      -- メソッド: add_attachment (*args, content_manager=None, **kw)

          If the message is a ‘multipart/mixed’, create a new message
          object, pass all of the arguments to its *note set_content():
          1813. method, and *note attach(): 3432. it to the ‘multipart’.
          If the message is a non-‘multipart’, ‘multipart/related’, or
          ‘multipart/alternative’, call *note make_mixed(): 3430. and
          then proceed as above.  If 'content_manager' is not specified,
          use the ‘content_manager’ specified by the current *note
          policy: 46.  If the added part has no ‘Content-Disposition’
          header, add one with the value ‘attachment’.  This method can
          be used both for explicit attachments (‘Content-Disposition:
          attachment’) and ‘inline’ attachments (‘Content-Disposition:
          inline’), by passing appropriate options to the
          ‘content_manager’.

      -- メソッド: clear ()

          ペイロードとヘッダの全てを削除します。

      -- メソッド: clear_content ()

          Remove the payload and all of the ‘!Content-’ headers, leaving
          all other headers intact and in their original order.

     *note EmailMessage: 25c. オブジェクトは次のようなインスタンス属性を
     持ちます:

      -- の属性: preamble

          MIME ドキュメントの形式では、ヘッダ直後にくる空行と最初の
          multipart 境界をあらわす文字列のあいだにいくらかのテキスト (訳
          注: preamble, 序文) を埋めこむことを許しています。このテキスト
          は標準的な MIME の範疇からはみ出しているので、MIME 形式を認識
          するメールソフトからこれらは通常まったく見えません。しかしメッ
          セージのテキストを生で見る場合、あるいはメッセージを MIME 対応
          していないメールソフトで見る場合、このテキストは目に見えること
          になります。

          'preamble' 属性は MIME ドキュメントに加えるこの最初の MIME 範
          囲外テキストを含んでいます。 *note Parser: 116f. があるテキス
          トをヘッダ以降に発見したが、それはまだ最初の MIME 境界文字列が
          現れる前だった場合、パーザはそのテキストをメッセージの
          'preamble' 属性に格納します。 *note Generator: 119e. がある
          MIME メッセージからプレーンテキスト形式を生成するときメッセー
          ジが 'preamble' 属性を持つことが発見されれば、これはそのテキス
          トをヘッダと最初の MIME 境界の間に挿入します。詳細は *note
          email.parser: 45. および *note email.generator: 37. を参照して
          ください。

          注意: そのメッセージに preamble がない場合、'preamble' 属性に
          は ‘None’ が格納されます。

      -- の属性: epilogue

          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
          *note preamble: 3437, if there is no epilog text this
          attribute will be ‘None’.

      -- の属性: defects

          'defects' 属性はメッセージを解析する途中で検出されたすべての問
          題点 (defect、障害) のリストを保持しています。解析中に発見され
          うる障害についてのより詳細な説明は *note email.errors: 36. を
          参照してください。

 -- クラス: email.message.MIMEPart (policy=default)

     This class represents a subpart of a MIME message.  It is identical
     to *note EmailMessage: 25c, except that no ‘MIME-Version’ headers
     are added when *note set_content(): 1813. is called, since
     sub-parts do not need their own ‘MIME-Version’ headers.

脚注
....

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/message.py

   (2) Originally added in 3.4 as a *note provisional module: 100b.
Docs for legacy message class moved to *note email.message.Message;
compat32 API を使用した電子メールメッセージの表現: 33fe.

   (3) https://datatracker.ietf.org/doc/html/rfc5322.html

   (4) https://datatracker.ietf.org/doc/html/rfc6532.html

   (5) https://datatracker.ietf.org/doc/html/rfc5322.html

   (6) https://datatracker.ietf.org/doc/html/rfc6531.html

   (7) https://datatracker.ietf.org/doc/html/rfc2231.html

   (8) https://datatracker.ietf.org/doc/html/rfc2231.html

   (9) https://datatracker.ietf.org/doc/html/rfc2045.html

   (10) https://datatracker.ietf.org/doc/html/rfc2045.html

   (11) https://datatracker.ietf.org/doc/html/rfc2045.html

   (12) https://datatracker.ietf.org/doc/html/rfc2231.html

   (13) https://datatracker.ietf.org/doc/html/rfc2183.html


File: python.info,  Node: email parser Parsing email messages,  Next: email generator Generating MIME documents,  Prev: email message Representing an email message,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.2 ‘email.parser’: Parsing email messages
...............................................

'ソースコード:' Lib/email/parser.py(1)

__________________________________________________________________

Message object structures can be created in one of two ways: they can be
created from whole cloth by creating an *note EmailMessage: 25c. object,
adding headers using the dictionary interface, and adding payload(s)
using *note set_content(): 1813. and related methods, or they can be
created by parsing a serialized representation of the email message.

The *note email: 32. package provides a standard parser that understands
most email document structures, including MIME documents.  You can pass
the parser a bytes, string or file object, and the parser will return to
you the root *note EmailMessage: 25c. instance of the object structure.
For simple, non-MIME messages the payload of this root object will
likely be a string containing the text of the message.  For MIME
messages, the root object will return ‘True’ from its *note
is_multipart(): 3404. method, and the subparts can be accessed via the
payload manipulation methods, such as *note get_body(): 3428, *note
iter_parts(): 342a, and *note walk(): 3427.

There are actually two parser interfaces available for use, the *note
Parser: 116f. API and the incremental *note FeedParser: 343c. API. The
*note Parser: 116f. API is most useful if you have the entire text of
the message in memory, or if the entire message lives in a file on the
file system.  *note FeedParser: 343c. is more appropriate when you are
reading the message from a stream which might block waiting for more
input (such as reading an email message from a socket).  The *note
FeedParser: 343c. can consume and parse the message incrementally, and
only returns the root object when you close the parser.

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 connects the *note email: 32. package's bundled parser and the
*note EmailMessage: 25c. class is embodied in the *note Policy: 1083.
class, so a custom parser can create message object trees any way it
finds necessary by implementing custom versions of the appropriate
‘Policy’ methods.

* Menu:

* FeedParser API::
* Parser API::
* 追記事項::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/parser.py


File: python.info,  Node: FeedParser API,  Next: Parser API,  Up: email parser Parsing email messages

5.19.1.3 FeedParser API
.......................

The *note BytesFeedParser: 119b, imported from the ‘email.feedparser’
module, provides an API that is conducive to incremental parsing of
email messages, such as would be necessary when reading the text of an
email message from a source that can block (such as a socket).  The
*note BytesFeedParser: 119b. can of course be used to parse an email
message fully contained in a *note bytes-like object: cfb, string, or
file, but the *note BytesParser: 119c. API may be more convenient for
such use cases.  The semantics and results of the two parser APIs are
identical.

*note BytesFeedParser: 119b. API は簡単です。まずインスタンスをつくり、
それに bytes を (それ以上 bytes が必要なくなるまで) 流しこみます。その後
パーザを close すると根っこ (root) のメッセージオブジェクトが返されます
。標準に従ったメッセージを解析する場合、 *note BytesFeedParser: 119b. は
非常に正確であり、標準に従っていないメッセージでもちゃんと動きます。その
さい、これはメッセージがどのように壊れていると認識されたかについての情報
を残します。これはメッセージオブジェクトの *note defects: 3439. 属性にリ
ストとして現れ、メッセージ中に発見された問題が記録されます。パーザが検出
できる障害 (defect) については *note email.errors: 36. モジュールを参照
してください。

以下は *note BytesFeedParser: 119b. の API です:

 -- クラス: email.parser.BytesFeedParser (_factory=None, *,
          policy=policy.compat32)

     Create a *note BytesFeedParser: 119b. instance.  Optional
     '_factory' is a no-argument callable; if not specified use the
     *note message_factory: c66. from the 'policy'.  Call '_factory'
     whenever a new message object is needed.

     If 'policy' is specified use the rules it specifies to update the
     representation of the message.  If 'policy' is not set, use the
     *note compat32: 1084. policy, which maintains backward
     compatibility with the Python 3.2 version of the email package and
     provides *note Message: 25d. as the default factory.  All other
     policies provide *note EmailMessage: 25c. as the default
     '_factory'.  For more information on what else 'policy' controls,
     see the *note policy: 46. documentation.

     Note: 'The policy keyword should always be specified'; The default
     will change to *note email.policy.default: 1088. in a future
     version of Python.

     Added in version 3.2.

     バージョン 3.3 で変更: キーワード引数 'policy' が追加されました。

     バージョン 3.6 で変更: '_factory' defaults to the policy
     ‘message_factory’.

      -- メソッド: feed (data)

          パーサーにデータを供給します。 'data' は 1行または複数行からな
          る *note bytes-like object: cfb. を渡します。渡される行は完結
          していなくてもよく、その場合パーサーは部分的な行を適切につなぎ
          合わせます。各行は3種類の標準的な行末文字 (復帰 CR、改行 LF、
          または CR+LF) どれかの組み合わせでよく、これらが混在してもかま
          いません。

      -- メソッド: close ()

          Complete the parsing of all previously fed data and return the
          root message object.  It is undefined what happens if *note
          feed(): 343e. is called after this method has been called.

 -- クラス: email.parser.FeedParser (_factory=None, *,
          policy=policy.compat32)

     Works like *note BytesFeedParser: 119b. except that the input to
     the *note feed(): 343e. method must be a string.  This is of
     limited utility, since the only way for such a message to be valid
     is for it to contain only ASCII text or, if ‘utf8’ is ‘True’, no
     binary attachments.

     バージョン 3.3 で変更: キーワード引数 'policy' が追加されました。


File: python.info,  Node: Parser API,  Next: 追記事項,  Prev: FeedParser API,  Up: email parser Parsing email messages

5.19.1.4 Parser API
...................

The *note BytesParser: 119c. class, imported from the *note
email.parser: 45. module, provides an API that can be used to parse a
message when the complete contents of the message are available in a
*note bytes-like object: cfb. or file.  The *note email.parser: 45.
module also provides *note Parser: 116f. for parsing strings, and
header-only parsers, *note BytesHeaderParser: 108d. and *note
HeaderParser: 108e, which can be used if you're only interested in the
headers of the message.  *note BytesHeaderParser: 108d. and *note
HeaderParser: 108e. can be much faster in these situations, since they
do not attempt to parse the message body, instead setting the payload to
the raw body.

 -- クラス: email.parser.BytesParser (_class=None, *,
          policy=policy.compat32)

     Create a *note BytesParser: 119c. instance.  The '_class' and
     'policy' arguments have the same meaning and semantics as the
     '_factory' and 'policy' arguments of *note BytesFeedParser: 119b.

     Note: 'The policy keyword should always be specified'; The default
     will change to *note email.policy.default: 1088. in a future
     version of Python.

     バージョン 3.3 で変更: 2.4 で非推奨になった 'strict' 引数の削除。キ
     ーワード引数 'policy' の追加。

     バージョン 3.6 で変更: '_class' defaults to the policy
     ‘message_factory’.

      -- メソッド: parse (fp, headersonly=False)

          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 *note readline(): 12f8. and the ‘read()’
          methods.

          The bytes contained in 'fp' must be formatted as a block of
          RFC 5322(1) (or, if ‘utf8’ is ‘True’, RFC 6532(2)) style
          headers and header continuation lines, optionally preceded by
          an envelope header.  The header block is terminated either by
          the end of the data or by a blank line.  Following the header
          block is the body of the message (which may contain
          MIME-encoded subparts, including subparts with a
          ‘Content-Transfer-Encoding’ of ‘8bit’).

          オプション引数 'headersonly' はヘッダを読み終えた後にパースを
          止めるかを指定するフラグです。デフォルトは ‘False’ で、ファイ
          ルの内容全体をパースします。

      -- メソッド: parsebytes (bytes, headersonly=False)

          Similar to the *note parse(): 3441. method, except it takes a
          *note bytes-like object: cfb. instead of a file-like object.
          Calling this method on a *note bytes-like object: cfb. is
          equivalent to wrapping 'bytes' in a *note BytesIO: e6d.
          instance first and calling *note parse(): 3441.

          オプション引数 'headersonly' は *note parse(): 3441. メソッド
          と同じです。

     Added in version 3.2.

 -- クラス: email.parser.BytesHeaderParser (_class=None, *,
          policy=policy.compat32)

     Exactly like *note BytesParser: 119c, except that 'headersonly'
     defaults to ‘True’.

     Added in version 3.3.

 -- クラス: email.parser.Parser (_class=None, *, policy=policy.compat32)

     This class is parallel to *note BytesParser: 119c, but handles
     string input.

     バージョン 3.3 で変更: 'strict' 引数の削除。キーワード引数 'policy'
     の追加。

     バージョン 3.6 で変更: '_class' defaults to the policy
     ‘message_factory’.

      -- メソッド: parse (fp, headersonly=False)

          ファイルなどテキストモードのストリーム形式 (file-like) のオブ
          ジェクト 'fp' からすべてのデータを読み込み、得られたテキストを
          解析して基底 (root) メッセージオブジェクト構造を返します。
          'fp' はストリーム形式のオブジェクトで *note readline(): 1c27.
          および *note read(): 1bef. 両方のメソッドをサポートしている必
          要があります。

          Other than the text mode requirement, this method operates
          like *note BytesParser.parse(): 3441.

      -- メソッド: parsestr (text, headersonly=False)

          *note parse(): 3443. メソッドに似ていますが、ファイルなどのス
          トリーム形式のかわりに文字列を引数としてとるところが違います。
          文字列に対してこのメソッドを呼ぶことは、 'text' を *note
          StringIO: ef3. インスタンスとして作成して *note parse(): 3443.
          を適用するのと同じです。

          オプション引数 'headersonly' は *note parse(): 3443. メソッド
          と同じです。

 -- クラス: email.parser.HeaderParser (_class=None, *,
          policy=policy.compat32)

     Exactly like *note Parser: 116f, except that 'headersonly' defaults
     to ‘True’.

ファイルや文字列からメッセージオブジェクト構造を作成するのはかなりよくお
こなわれる作業なので、便宜上次のような 4つの関数が提供されています。これ
らは *note email: 32. パッケージのトップレベルの名前空間で使用できます。

 -- の関数: email.message_from_bytes (s, _class=None, *,
          policy=policy.compat32)

     *note bytes-like オブジェクト: cfb. からメッセージオブジェクト構造
     を作成して返します。これは ‘BytesParser().parsebytes(s)’ と同じです
     。オプション引数 '_class' および 'policy' は *note BytesParser:
     119c. クラスのコンストラクタと同様に解釈されます。

     Added in version 3.2.

     バージョン 3.3 で変更: 'strict' 引数の削除。キーワード引数 'policy'
     の追加。

 -- の関数: email.message_from_binary_file (fp, _class=None, *,
          policy=policy.compat32)

     オープンされたバイナリ *note file object: 1193. からメッセージオブ
     ジェクト構造を作成して返します。これは ‘BytesParser().parse(fp)’ と
     同じです。 '_class' および 'policy' は *note BytesParser: 119c. ク
     ラスのコンストラクタと同様に解釈されます。

     Added in version 3.2.

     バージョン 3.3 で変更: 'strict' 引数の削除。キーワード引数 'policy'
     の追加。

 -- の関数: email.message_from_string (s, _class=None, *,
          policy=policy.compat32)

     文字列からメッセージオブジェクト構造を作成して返します。これは
     ‘Parser().parsestr(s)’ と同じです。 '_class' および 'policy' は
     *note Parser: 116f. クラスのコンストラクタと同様に解釈されます。

     バージョン 3.3 で変更: 'strict' 引数の削除。キーワード引数 'policy'
     の追加。

 -- の関数: email.message_from_file (fp, _class=None, *,
          policy=policy.compat32)

     オープンされた *note file object: 1193. からメッセージオブジェクト
     構造を作成して返します。これは ‘Parser().parse(fp)’ と同じです。
     '_class' および 'policy' は *note Parser: 116f. クラスのコンストラ
     クタと同様に解釈されます。

     バージョン 3.3 で変更: 'strict' 引数の削除。キーワード引数 'policy'
     の追加。

     バージョン 3.6 で変更: '_class' defaults to the policy
     ‘message_factory’.

対話的な Python プロンプトで *note message_from_bytes(): 1199. を使用す
るとすれば、このようになります:

     >>> import email
     >>> msg = email.message_from_bytes(myBytes)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5322.html

   (2) https://datatracker.ietf.org/doc/html/rfc6532.html


File: python.info,  Node: 追記事項,  Prev: Parser API,  Up: email parser Parsing email messages

5.19.1.5 追記事項
.................

以下はテキスト解析の際に適用されるいくつかの規約です:

   * Most non-‘multipart’ type messages are parsed as a single message
     object with a string payload.  These objects will return ‘False’
     for *note is_multipart(): 3404, and *note iter_parts(): 342a. will
     yield an empty list.

   * All ‘multipart’ type messages will be parsed as a container message
     object with a list of sub-message objects for their payload.  The
     outer container message will return ‘True’ for *note
     is_multipart(): 3404, and *note iter_parts(): 342a. will yield a
     list of subparts.

   * Most messages with a content type of ‘message/*’ (such as
     ‘message/delivery-status’ and ‘message/rfc822’) will also be parsed
     as container object containing a list payload of length 1.  Their
     *note is_multipart(): 3404. method will return ‘True’.  The single
     element yielded by *note iter_parts(): 342a. will be a sub-message
     object.

   * いくつかの標準的でないメッセージは、 ‘multipart’ の使い方に統一がと
     れていない場合があります。このようなメッセージは ‘Content-Type’ ヘ
     ッダに ‘multipart’ を指定しているものの、その *note is_multipart():
     3404. メソッドは ‘False’ を返すことがあります。もしこのようなメッセ
     ージが *note FeedParser: 343c. によって解析されると、その 'defects'
     属性のリスト中には ‘MultipartInvariantViolationDefect’ クラスのイン
     スタンスが現れます。詳しい情報については *note email.errors: 36. を
     参照してください。


File: python.info,  Node: email generator Generating MIME documents,  Next: email policy Policy Objects,  Prev: email parser Parsing email messages,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.6 ‘email.generator’: Generating MIME documents
.....................................................

'ソースコード:' Lib/email/generator.py(1)

__________________________________________________________________

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 to do this if you want to send your message via *note
smtplib.SMTP.sendmail(): e22, or print the message on the console.
Taking a message object structure and producing a serialized
representation is the job of the generator classes.

As with the *note email.parser: 45. module, you aren't limited to the
functionality of the bundled generator; you could write one from scratch
yourself.  However the bundled generator knows how to generate most
email in a standards-compliant way, should handle MIME and non-MIME
email messages just fine, and is designed so that the bytes-oriented
parsing and generation operations are inverses, assuming the same
non-transforming *note policy: 46. is used for both.  That is, parsing
the serialized byte stream via the *note BytesParser: 119c. class and
then regenerating the serialized byte stream using *note BytesGenerator:
119f. should produce output identical to the input (2).  (On the other
hand, using the generator on an *note EmailMessage: 25c. constructed by
program may result in changes to the *note EmailMessage: 25c. object as
defaults are filled in.)

The *note Generator: 119e. class can be used to flatten a message into a
text (as opposed to binary) serialized representation, but since Unicode
cannot represent binary data directly, the message is of necessity
transformed into something that contains only ASCII characters, using
the standard email RFC Content Transfer Encoding techniques for encoding
email messages for transport over channels that are not "8 bit clean".

To accommodate reproducible processing of SMIME-signed messages *note
Generator: 119e. disables header folding for message parts of type
‘multipart/signed’ and all subparts.

 -- クラス: email.generator.BytesGenerator (outfp, mangle_from_=None,
          maxheaderlen=None, *, policy=None)

     Return a *note BytesGenerator: 119f. object that will write any
     message provided to the *note flatten(): 344b. method, or any
     surrogateescape encoded text provided to the *note write(): 344c.
     method, to the *note file-like object: 24e0. 'outfp'.  'outfp' must
     support a ‘write’ method that accepts binary data.

     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 is ‘From’ followed by a space at the beginning of a line.
     'mangle_from_' defaults to the value of the *note mangle_from_:
     dc3. setting of the 'policy' (which is ‘True’ for the *note
     compat32: c67. policy and ‘False’ for all others).  'mangle_from_'
     is intended for use when messages are stored in Unix mbox format
     (see *note mailbox: 7f. and WHY THE CONTENT-LENGTH FORMAT IS
     BAD(3)).

     If 'maxheaderlen' is not ‘None’, refold any header lines that are
     longer than 'maxheaderlen', or if ‘0’, do not rewrap any headers.
     If 'manheaderlen' is ‘None’ (the default), wrap headers and other
     message lines according to the 'policy' settings.

     If 'policy' is specified, use that policy to control message
     generation.  If 'policy' is ‘None’ (the default), use the policy
     associated with the *note Message: 25d. or *note EmailMessage: 25c.
     object passed to ‘flatten’ to control the message generation.  See
     *note email.policy: 46. for details on what 'policy' controls.

     Added in version 3.2.

     バージョン 3.3 で変更: キーワード引数 'policy' が追加されました。

     バージョン 3.6 で変更: The default behavior of the 'mangle_from_'
     and 'maxheaderlen' parameters is to follow the policy.

      -- メソッド: flatten (msg, unixfrom=False, linesep=None)

          'msg' を基点とするメッセージオブジェクト構造体の文字表現を出力
          します。出力先のファイルにはこの *note BytesGenerator: 119f. イ
          ンスタンスが作成されたときに指定されたものが使われます。

          If the *note policy: 46. option *note cte_type: 344d. is
          ‘8bit’ (the default), copy any headers in the original parsed
          message that have not been modified to the output with any
          bytes with the high bit set reproduced as in the original, and
          preserve the non-ASCII ‘Content-Transfer-Encoding’ of any body
          parts that have them.  If ‘cte_type’ is ‘7bit’, convert the
          bytes with the high bit set as needed using an
          ASCII-compatible ‘Content-Transfer-Encoding’.  That is,
          transform parts with non-ASCII ‘Content-Transfer-Encoding’
          (‘Content-Transfer-Encoding: 8bit’) to an ASCII compatible
          ‘Content-Transfer-Encoding’, and encode RFC-invalid non-ASCII
          bytes in headers using the MIME ‘unknown-8bit’ character set,
          thus rendering them RFC-compliant.

          If 'unixfrom' is ‘True’, print the envelope header delimiter
          used by the Unix mailbox format (see *note mailbox: 7f.)
          before the first of the RFC 5322(4) headers of the root
          message object.  If the root object has no envelope header,
          craft a standard one.  The default is ‘False’.  Note that for
          subparts, no envelope header is ever printed.

          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'.

      -- メソッド: clone (fp)

          Return an independent clone of this *note BytesGenerator:
          119f. instance with the exact same option settings, and 'fp'
          as the new 'outfp'.

      -- メソッド: write (s)

          Encode 's' using the ‘ASCII’ codec and the ‘surrogateescape’
          error handler, and pass it to the 'write' method of the
          'outfp' passed to the *note BytesGenerator: 119f.'s
          constructor.

As a convenience, *note EmailMessage: 25c. provides the methods *note
as_bytes(): 3402. and ‘bytes(aMessage)’ (a.k.a.  *note __bytes__():
3403.), which simplify the generation of a serialized binary
representation of a message object.  For more detail, see *note
email.message: 3b.

Because strings cannot represent binary data, the *note Generator: 119e.
class must convert any binary data in any message it flattens to an
ASCII compatible format, by converting them to an ASCII compatible
‘Content-Transfer_Encoding’.  Using the terminology of the email RFCs,
you can think of this as *note Generator: 119e. serializing to an I/O
stream that is not "8 bit clean".  In other words, most applications
will want to be using *note BytesGenerator: 119f, and not *note
Generator: 119e.

 -- クラス: email.generator.Generator (outfp, mangle_from_=None,
          maxheaderlen=None, *, policy=None)

     Return a *note Generator: 119e. object that will write any message
     provided to the *note flatten(): 344f. method, or any text provided
     to the *note write(): 3450. method, to the *note file-like object:
     24e0. 'outfp'.  'outfp' must support a ‘write’ method that accepts
     string data.

     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 is ‘From’ followed by a space at the beginning of a line.
     'mangle_from_' defaults to the value of the *note mangle_from_:
     dc3. setting of the 'policy' (which is ‘True’ for the *note
     compat32: c67. policy and ‘False’ for all others).  'mangle_from_'
     is intended for use when messages are stored in Unix mbox format
     (see *note mailbox: 7f. and WHY THE CONTENT-LENGTH FORMAT IS
     BAD(5)).

     If 'maxheaderlen' is not ‘None’, refold any header lines that are
     longer than 'maxheaderlen', or if ‘0’, do not rewrap any headers.
     If 'manheaderlen' is ‘None’ (the default), wrap headers and other
     message lines according to the 'policy' settings.

     If 'policy' is specified, use that policy to control message
     generation.  If 'policy' is ‘None’ (the default), use the policy
     associated with the *note Message: 25d. or *note EmailMessage: 25c.
     object passed to ‘flatten’ to control the message generation.  See
     *note email.policy: 46. for details on what 'policy' controls.

     バージョン 3.3 で変更: キーワード引数 'policy' が追加されました。

     バージョン 3.6 で変更: The default behavior of the 'mangle_from_'
     and 'maxheaderlen' parameters is to follow the policy.

      -- メソッド: flatten (msg, unixfrom=False, linesep=None)

          'msg' を基点とするメッセージオブジェクト構造体の文字表現を出力
          します。出力先のファイルにはこの *note Generator: 119e. インス
          タンスが作成されたときに指定されたものが使われます。

          If the *note policy: 46. option *note cte_type: 344d. is
          ‘8bit’, generate the message as if the option were set to
          ‘7bit’.  (This is required because strings cannot represent
          non-ASCII bytes.)  Convert any bytes with the high bit set as
          needed using an ASCII-compatible ‘Content-Transfer-Encoding’.
          That is, transform parts with non-ASCII
          ‘Content-Transfer-Encoding’ (‘Content-Transfer-Encoding:
          8bit’) to an ASCII compatible ‘Content-Transfer-Encoding’, and
          encode RFC-invalid non-ASCII bytes in headers using the MIME
          ‘unknown-8bit’ character set, thus rendering them
          RFC-compliant.

          If 'unixfrom' is ‘True’, print the envelope header delimiter
          used by the Unix mailbox format (see *note mailbox: 7f.)
          before the first of the RFC 5322(6) headers of the root
          message object.  If the root object has no envelope header,
          craft a standard one.  The default is ‘False’.  Note that for
          subparts, no envelope header is ever printed.

          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'.

          バージョン 3.2 で変更: ‘8bit’ メッセージ本体の再エンコードがサ
          ポートされました。'linesep' 引数が追加されました。

      -- メソッド: clone (fp)

          Return an independent clone of this *note Generator: 119e.
          instance with the exact same options, and 'fp' as the new
          'outfp'.

      -- メソッド: write (s)

          Write 's' to the 'write' method of the 'outfp' passed to the
          *note Generator: 119e.'s constructor.  This provides just
          enough file-like API for *note Generator: 119e. instances to
          be used in the *note print(): f42. function.

As a convenience, *note EmailMessage: 25c. provides the methods *note
as_string(): 33ff. and ‘str(aMessage)’ (a.k.a.  *note __str__(): 3401.),
which simplify the generation of a formatted string representation of a
message object.  For more detail, see *note email.message: 3b.

The *note email.generator: 37. module also provides a derived class,
*note DecodedGenerator: c65, which is like the *note Generator: 119e.
base class, except that non-‘text’ parts are not serialized, but are
instead represented in the output stream by a string derived from a
template filled in with information about the part.

 -- クラス: email.generator.DecodedGenerator (outfp, mangle_from_=None,
          maxheaderlen=None, fmt=None, *, policy=None)

     Act like *note Generator: 119e, except that for any subpart of the
     message passed to *note Generator.flatten(): 344f, if the subpart
     is of main type ‘text’, print the decoded payload of the subpart,
     and if the main type is not ‘text’, instead of printing it fill in
     the string 'fmt' using information from the part and print the
     resulting filled-in string.

     To fill in 'fmt', execute ‘fmt % part_info’, where ‘part_info’ is a
     dictionary composed of the following keys and values:

        * ‘type’ - 非 ‘text’ 型 subpart の MIME 形式

        * ‘maintype’ - 非 ‘text’ 型 subpart の MIME 主形式 (maintype)

        * ‘subtype’ - 非 ‘text’ 型 subpart の MIME 副形式 (subtype)

        * ‘filename’ - 非 ‘text’ 型 subpart のファイル名

        * ‘description’ - 非 ‘text’ 型 subpart につけられた説明文字列

        * ‘encoding’ - 非 ‘text’ 型 subpart の Content-transfer-encoding

     If 'fmt' is ‘None’, use the following default 'fmt':

          "[Non-text (%(type)s) part of message omitted, filename
          %(filename)s]"

     Optional '_mangle_from_' and 'maxheaderlen' are as with the *note
     Generator: 119e. base class.

脚注
....

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/email/generator.py

   (2) This statement assumes that you use the appropriate setting for
‘unixfrom’, and that there are no *note email.policy: 46. settings
calling for automatic adjustments (for example, *note refold_source:
344a. must be ‘none’, which is 'not' the default).  It is also not 100%
true, since if the message does not conform to the RFC standards
occasionally information about the exact original text is lost during
parsing error recovery.  It is a goal to fix these latter edge cases
when possible.

   (3) https://www.jwz.org/doc/content-length.html

   (4) https://datatracker.ietf.org/doc/html/rfc5322.html

   (5) https://www.jwz.org/doc/content-length.html

   (6) https://datatracker.ietf.org/doc/html/rfc5322.html


File: python.info,  Node: email policy Policy Objects,  Next: email errors Exception and Defect classes,  Prev: email generator Generating MIME documents,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.7 ‘email.policy’: Policy Objects
.......................................

Added in version 3.3.

'ソースコード:' Lib/email/policy.py(1)

__________________________________________________________________

*note email: 32. パッケージの主要な目的は様々なEメールやMIMEのRFCで記述
されたEメールメッセージを取り扱うことにあります。しかし、Eメールメッセー
ジの一般的なフォーマット(名前の後にコロンが続き、コロンの後に値が続くと
いう構成の複数のヘッダーフィールドのブロック、空白行、任意の 'body')は
Eメールの分野外での用途が見いだされたフォーマットです。これらの用途には
主となるEメールのRFCに厳密に従っているものもあれば、そうでないものもあり
ます。Eメールを使ったworkingのときでさえも、厳密なRFC準拠にしないのが望
ましいことがあります。たとえば、基準に従わないEメールサーバーと相互運用
するEメールを作成するときや、基準に違反する方法で使用したい拡張機能を実
装するEメールを作成するときです。

これらのばらばらな用途に対応するためPolicyオブジェクトはEメールパッケー
ジに対して柔軟性を提供します。

A *note Policy: 1083. object encapsulates a set of attributes and
methods that control the behavior of various components of the email
package during use.  *note Policy: 1083. instances can be passed to
various classes and methods in the email package to alter the default
behavior.  The settable values and their defaults are described below.

There is a default policy used by all classes in the email package.  For
all of the *note parser: 45. classes and the related convenience
functions, and for the *note Message: 25d. class, this is the *note
Compat32: 1084. policy, via its corresponding pre-defined instance *note
compat32: c67.  This policy provides for complete backward compatibility
(in some cases, including bug compatibility) with the pre-Python3.3
version of the email package.

This default value for the 'policy' keyword to *note EmailMessage: 25c.
is the *note EmailPolicy: 1087. policy, via its pre-defined instance
*note default: 1088.

When a *note Message: 25d. or *note EmailMessage: 25c. object is
created, it acquires a policy.  If the message is created by a *note
parser: 45, a policy passed to the parser will be the policy used by the
message it creates.  If the message is created by the program, then the
policy can be specified when it is created.  When a message is passed to
a *note generator: 37, the generator uses the 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.

The default value for the 'policy' keyword for the *note email.parser:
45. classes and the parser convenience functions 'will be changing' in a
future version of Python.  Therefore you should 'always specify
explicitly which policy you want to use' when calling any of the classes
and functions described in the *note parser: 45. module.

The first part of this documentation covers the features of *note
Policy: 1083, an *note abstract base class: 1186. that defines the
features that are common to all policy objects, including *note
compat32: c67.  This includes certain hook methods that are called
internally by the email package, which a custom policy could override to
obtain different behavior.  The second part describes the concrete
classes *note EmailPolicy: 1087. and *note Compat32: 1084, which
implement the hooks that provide the standard behavior and the backward
compatible behavior and features, respectively.

*note Policy: 1083. instances are immutable, but they can be cloned,
accepting the same keyword arguments as the class constructor and
returning a new *note Policy: 1083. instance that is a copy of the
original but with the specified attributes values changed.

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:

     >>> from email import message_from_binary_file
     >>> from email.generator import BytesGenerator
     >>> from email import policy
     >>> from subprocess import Popen, PIPE
     >>> with open('mymsg.txt', 'rb') as f:
     ...     msg = message_from_binary_file(f, policy=policy.default)
     ...
     >>> p = Popen(['sendmail', msg['To'].addresses[0]], stdin=PIPE)
     >>> g = BytesGenerator(p.stdin, policy=msg.policy.clone(linesep='\r\n'))
     >>> g.flatten(msg)
     >>> p.stdin.close()
     >>> rc = p.wait()

Here we are telling *note BytesGenerator: 119f. 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.

Some email package methods accept a 'policy' keyword argument, allowing
the policy to be overridden for that method.  For example, the following
code uses the *note as_bytes(): f04. method of the 'msg' object from the
previous example and writes the message to a file using the native line
separators for the platform on which it is running:

     >>> import os
     >>> with open('converted.txt', 'wb') as f:
     ...     f.write(msg.as_bytes(policy=msg.policy.clone(linesep=os.linesep)))
     17

Policyオブジェクトは加算オペレータを使用して組み合わせることも可能で、そ
れらのオブジェクトの非デフォルト値を組み合わせた設定を持つPolicyオブジェ
クトを生成します:

     >>> compat_SMTP = policy.compat32.clone(linesep='\r\n')
     >>> compat_strict = policy.compat32.clone(raise_on_defect=True)
     >>> compat_strict_SMTP = compat_SMTP + compat_strict

この操作には交換法則が成り立ちません。つまり、オブジェクトを加える順番に
結果が依存します。次のように説明できます:

     >>> policy100 = policy.compat32.clone(max_line_length=100)
     >>> policy80 = policy.compat32.clone(max_line_length=80)
     >>> apolicy = policy100 + policy80
     >>> apolicy.max_line_length
     80
     >>> apolicy = policy80 + policy100
     >>> apolicy.max_line_length
     100

 -- クラス: email.policy.Policy (**kw)

     This is the *note abstract base class: 1186. for all policy
     classes.  It provides default implementations for a couple of
     trivial methods, as well as the implementation of the immutability
     property, the *note clone(): 1085. method, and the constructor
     semantics.

     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 class, plus any additional non-method properties
     on the concrete class.  A value specified in the constructor will
     override the default value for the corresponding attribute.

     This class defines the following properties, and thus values for
     the following may be passed in the constructor of any policy class:

      -- の属性: max_line_length

          行の終端文字を数に含まない、シリアライズした出力の任意の行の最
          大長。デフォルトは RFC 5322(2) に従い78となっています。値が
          ‘0’ または *note None: 641. の場合は行の折り返しを全くしないべ
          きであるということを示します。

      -- の属性: linesep

          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.

      -- の属性: cte_type

          Controls the type of Content Transfer Encodings that may be or
          are required to be used.  The possible values are:

          ‘7bit’       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.
                       
                       
          ‘8bit’       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
                       *note fold_binary(): 3455. and *note utf8: dc5. below for
                       exceptions), but body parts may use the ‘8bit’ CTE.
                       

          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’.

      -- の属性: raise_on_defect

          If *note True: bdb, any defects encountered will be raised as
          errors.  If *note False: b05. (the default), defects will be
          passed to the *note register_defect(): 3457. method.

      -- の属性: mangle_from_

          If *note True: bdb, 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: *note False: b05.

          Added in version 3.5.

      -- の属性: message_factory

          A factory function for constructing a new empty message
          object.  Used by the parser when building messages.  Defaults
          to ‘None’, in which case *note Message: 25d. is used.

          Added in version 3.6.

      -- の属性: verify_generated_headers

          If ‘True’ (the default), the generator will raise *note
          HeaderWriteError: 3458. instead of writing a header that is
          improperly folded or delimited, such that it would be parsed
          as multiple headers or joined with adjacent data.  Such
          headers can be generated by custom header classes or bugs in
          the ‘email’ module.

          As it's a security feature, this defaults to ‘True’ even in
          the *note Compat32: 1084. policy.  For backwards compatible,
          but unsafe, behavior, it must be set to ‘False’ explicitly.

          Added in version 3.13.

     The following *note Policy: 1083. method is intended to be called
     by code using the email library to create policy instances with
     custom settings:

      -- メソッド: clone (**kw)

          Return a new *note Policy: 1083. instance whose attributes
          have the same values as the current instance, except where
          those attributes are given new values by the keyword
          arguments.

     The remaining *note Policy: 1083. 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.

      -- メソッド: handle_defect (obj, defect)

          Handle a 'defect' found on 'obj'.  When the email package
          calls this method, 'defect' will always be a subclass of
          ‘Defect’.

          The default implementation checks the *note raise_on_defect:
          3456. flag.  If it is ‘True’, 'defect' is raised as an
          exception.  If it is ‘False’ (the default), 'obj' and 'defect'
          are passed to *note register_defect(): 3457.

      -- メソッド: register_defect (obj, defect)

          'defect' を 'obj' に登録します。email パッケージでは、'defect'
          は常に ‘Defect’ の派生クラスです。

          The default implementation calls the ‘append’ method of the
          ‘defects’ attribute of 'obj'.  When the email package calls
          *note handle_defect: 3459, 'obj' will normally have a
          ‘defects’ attribute that has an ‘append’ method.  Custom
          object types used with the email package (for example, custom
          ‘Message’ objects) should also provide such an attribute,
          otherwise defects in parsed messages will raise unexpected
          errors.

      -- メソッド: header_max_count (name)

          'name' というヘッダに許される最大の数を返します。

          Called when a header is added to an *note EmailMessage: 25c.
          or *note Message: 25d. 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
          *note ValueError: 1e3. is raised.

          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 realizing it.  This method allows
          certain headers to be limited in the number of instances of
          that header that may be added to a ‘Message’ programmatically.
          (The limit is not observed by the parser, which will
          faithfully produce as many headers as exist in the message
          being parsed.)

          デフォルトの実装は全てのヘッダ名に ‘None’ を返します。

      -- メソッド: header_source_parse (sourcelines)

          The email package calls this method with a list of strings,
          each string ending with the line separation characters found
          in the source being parsed.  The first line includes the field
          header name and separator.  All whitespace in the source is
          preserved.  The method should return the ‘(name, value)’ tuple
          that is to be stored in the ‘Message’ to represent the parsed
          header.

          If an implementation wishes to retain compatibility with the
          existing email package policies, 'name' should be the case
          preserved name (all characters up to the '‘:’' separator),
          while 'value' should be the unfolded value (all line separator
          characters removed, but whitespace kept intact), stripped of
          leading whitespace.

          'sourcelines' はサロゲートエスケープされたバイナリーデータを持
          つことがあります。

          デフォルトの実装はありません。

      -- メソッド: header_store_parse (name, value)

          The email package calls this method with the name and value
          provided by the application program when the application
          program is modifying a ‘Message’ programmatically (as opposed
          to a ‘Message’ created by a parser).  The method should return
          the ‘(name, value)’ tuple that is to be stored in the
          ‘Message’ to represent the header.

          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.

          デフォルトの実装はありません。

      -- メソッド: header_fetch_parse (name, value)

          The email package calls this method with the 'name' and
          'value' currently stored in the ‘Message’ when that header is
          requested by the application program, and whatever the method
          returns is what is passed back to the application as the value
          of the header being retrieved.  Note that there may be more
          than one header with the same name stored in the ‘Message’;
          the method is passed the specific name and value of the header
          destined to be returned to the application.

          'value' はサロゲートエスケープされたバイナリーデータを持つこと
          があります。このメソッドの返り値にはサロゲートエスケープされた
          バイナリーデータはありません。

          デフォルトの実装はありません。

      -- メソッド: fold (name, value)

          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 string that represents that header
          "folded" correctly (according to the policy settings) by
          composing the 'name' with the 'value' and inserting *note
          linesep: 3454. characters at the appropriate places.  See RFC
          5322(3) for a discussion of the rules for folding email
          headers.

          'value' はサロゲートエスケープされたバイナリーデータを持つこと
          があります。このメソッドが返す文字列にはサロゲートエスケープさ
          れたバイナリーデータはありません。

      -- メソッド: fold_binary (name, value)

          返り値が文字列でなく bytes オブジェクトである点を除けば、*note
          fold(): 345e. と同じです。

          'value' はサロゲートエスケープされたバイナリデータを持つことが
          あります。これらは返されたbytesオブジェクト内でバイナリデータ
          に変換されることがあります。

 -- クラス: email.policy.EmailPolicy (**kw)

     This concrete *note Policy: 1083. provides behavior that is
     intended to be fully compliant with the current email RFCs.  These
     include (but are not limited to) RFC 5322(4), RFC 2047(5), and the
     current MIME RFCs.

     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(6) and RFC 5322(7).

     The default value for the *note message_factory: c66. attribute is
     *note EmailMessage: 25c.

     In addition to the settable attributes listed above that apply to
     all policies, this policy adds the following additional attributes:

     Added in version 3.6: (8)

      -- の属性: utf8

          If ‘False’, follow RFC 5322(9), supporting non-ASCII
          characters in headers by encoding them as "encoded words".  If
          ‘True’, follow RFC 6532(10) and use ‘utf-8’ encoding for
          headers.  Messages formatted in this way may be passed to SMTP
          servers that support the ‘SMTPUTF8’ extension ( RFC 6531(11)).

      -- の属性: refold_source

          If the value for a header in the ‘Message’ object originated
          from a *note parser: 45. (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:

          ‘none’       all source values use original folding
                       
                       
          ‘long’       source values that have any line that is longer than
                       ‘max_line_length’ will be refolded
                       
                       
          ‘all’        all values are refolded.
                       

          デフォルトは ‘long’ です。

      -- の属性: header_factory

          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 returns a string subclass that
          represents that header.  A default ‘header_factory’ (see *note
          headerregistry: 39.) is provided that supports custom parsing
          for the various address and date RFC 5322(12) header field
          types, and the major MIME header field stypes.  Support for
          additional custom parsing will be added in the future.

      -- の属性: content_manager

          An object with at least two methods: get_content and
          set_content.  When the *note get_content(): 342b. or *note
          set_content(): 1813. method of an *note EmailMessage: 25c.
          object is called, it calls the corresponding method of this
          object, passing it the message object as its first argument,
          and any arguments or keywords that were passed to it as
          additional arguments.  By default ‘content_manager’ is set to
          *note raw_data_manager: 3460.

          Added in version 3.4.

     このクラスは *note Policy: 1083. の抽象メソッドの具象実装を提供しま
     す:

      -- メソッド: header_max_count (name)

          Returns the value of the *note max_count: 3462. attribute of
          the specialized class used to represent the header with the
          given name.

      -- メソッド: header_source_parse (sourcelines)

          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.

      -- メソッド: header_store_parse (name, value)

          The name is returned unchanged.  If the input value has a
          ‘name’ attribute and it matches 'name' ignoring case, the
          value is returned unchanged.  Otherwise the 'name' and 'value'
          are passed to ‘header_factory’, and the resulting header
          object is returned as the value.  In this case a ‘ValueError’
          is raised if the input value contains CR or LF characters.

      -- メソッド: header_fetch_parse (name, value)

          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, are passed to the ‘header_factory’,
          and the resulting header object is returned.  Any
          surrogateescaped bytes get turned into the unicode
          unknown-character glyph.

      -- メソッド: fold (name, value)

          Header folding is controlled by the *note refold_source: 344a.
          policy setting.  A value is considered to be a 'source value'
          if and only if it does not have a ‘name’ attribute (having a
          ‘name’ attribute means it is a header object of some sort).
          If a source value needs to be refolded according to the
          policy, it is converted into a header object by passing the
          'name' and the 'value' with any CR and LF characters removed
          to the ‘header_factory’.  Folding of a header object is done
          by calling its ‘fold’ method with the current policy.

          Source values are split into lines using *note splitlines():
          1228.  If the value is not to be refolded, the lines are
          rejoined using the ‘linesep’ from the policy and returned.
          The exception is lines containing non-ascii binary data.  In
          that case the value is refolded regardless of the
          ‘refold_source’ setting, which causes the binary data to be
          CTE encoded using the ‘unknown-8bit’ charset.

      -- メソッド: fold_binary (name, value)

          返り値が bytes である点を除いて、*note cte_type: 344d. が
          ‘7bit’ の場合は *note fold(): 15d9. と同じです。

          If *note cte_type: 344d. is ‘8bit’, non-ASCII binary data is
          converted back into bytes.  Headers with binary data are not
          refolded, regardless of the ‘refold_header’ setting, since
          there is no way to know whether the binary data consists of
          single byte characters or multibyte characters.

The following instances of *note EmailPolicy: 1087. 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.

 -- データ: email.policy.default

     デフォルト値を変更していない ‘EmailPolicy’ のインスタンスです。この
     ポリシーの行末は、 RFC で正しい ‘\r\n’ ではなく Python の標準の
     ‘\n’ です。

 -- データ: email.policy.SMTP

     Suitable for serializing messages in conformance with the email
     RFCs.  Like ‘default’, but with ‘linesep’ set to ‘\r\n’, which is
     RFC compliant.

 -- データ: email.policy.SMTPUTF8

     The same as ‘SMTP’ except that *note utf8: dc5. is ‘True’.  Useful
     for serializing messages to a message store without using encoded
     words in the headers.  Should only be used for SMTP transmission if
     the sender or recipient addresses have non-ASCII characters (the
     *note smtplib.SMTP.send_message(): e23. method handles this
     automatically).

 -- データ: email.policy.HTTP

     Suitable for serializing headers with for use in HTTP traffic.
     Like ‘SMTP’ except that ‘max_line_length’ is set to ‘None’
     (unlimited).

 -- データ: email.policy.strict

     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:

          somepolicy + policy.strict

With all of these *note EmailPolicies: 1087, the effective API of the
email package is changed from the Python 3.2 API in the following ways:

   * Setting a header on a *note Message: 25d. results in that header
     being parsed and a header object created.

   * Fetching a header value from a *note Message: 25d. results in that
     header being parsed and a header object created and returned.

   * 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.

From the application view, this means that any header obtained through
the *note EmailMessage: 25c. is a header object with extra attributes,
whose string value is the fully decoded unicode value of the header.
Likewise, a header may be assigned a new value, or a new header created,
using a unicode string, and the policy will take care of converting the
unicode string into the correct RFC encoded form.

ヘッダオブジェクトとその属性は *note headerregistry: 39. で述べられてい
ます。

 -- クラス: email.policy.Compat32 (**kw)

     This concrete *note Policy: 1083. is the backward compatibility
     policy.  It replicates the behavior of the email package in Python
     3.2.  The *note policy: 46. module also defines an instance of this
     class, *note compat32: c67, that is used as the default policy.
     Thus the default behavior of the email package is to maintain
     compatibility with Python 3.2.

     以下の属性は *note Policy: 1083. デフォルトとは異なる値を持ちます:

      -- の属性: mangle_from_

          デフォルトは ‘True’ です。

     このクラスは *note Policy: 1083. の抽象メソッドの具象実装を提供しま
     す:

      -- メソッド: header_source_parse (sourcelines)

          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.

      -- メソッド: header_store_parse (name, value)

          名前と値は変更されずに返されます。

      -- メソッド: header_fetch_parse (name, value)

          If the value contains binary data, it is converted into a
          *note Header: 1814. object using the ‘unknown-8bit’ charset.
          Otherwise it is returned unmodified.

      -- メソッド: fold (name, value)

          Headers are folded using the *note Header: 1814. 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.

      -- メソッド: fold_binary (name, value)

          Headers are folded using the *note Header: 1814. folding
          algorithm, which preserves existing line breaks in the value,
          and wraps each resulting line to the ‘max_line_length’.  If
          ‘cte_type’ is ‘7bit’, non-ascii binary data is CTE encoded
          using the ‘unknown-8bit’ charset.  Otherwise the original
          source header is used, with its existing line breaks and any
          (RFC invalid) binary data it may contain.

 -- データ: email.policy.compat32

     *note Compat32: 1084. のインスタンスで、Python 3.2 の email パッケ
     ージの挙動との後方互換性を提供します。

脚注
....

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/policy.py

   (2) https://datatracker.ietf.org/doc/html/rfc5322.html

   (3) https://datatracker.ietf.org/doc/html/rfc5322.html

   (4) https://datatracker.ietf.org/doc/html/rfc5322.html

   (5) https://datatracker.ietf.org/doc/html/rfc2047.html

   (6) https://datatracker.ietf.org/doc/html/rfc2047.html

   (7) https://datatracker.ietf.org/doc/html/rfc5322.html

   (8) Originally added in 3.3 as a *note provisional feature: 100b.

   (9) https://datatracker.ietf.org/doc/html/rfc5322.html

   (10) https://datatracker.ietf.org/doc/html/rfc6532.html

   (11) https://datatracker.ietf.org/doc/html/rfc6531.html

   (12) https://datatracker.ietf.org/doc/html/rfc5322.html


File: python.info,  Node: email errors Exception and Defect classes,  Next: email headerregistry Custom Header Objects,  Prev: email policy Policy Objects,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.8 ‘email.errors’: Exception and Defect classes
.....................................................

'ソースコード:' Lib/email/errors.py(1)

__________________________________________________________________

*note email.errors: 36. モジュールでは、以下の例外クラスが定義されていま
す:

 -- 例外: email.errors.MessageError

     これは *note email: 32. パッケージが送出しうるすべての例外の基底ク
     ラスです。これは標準の *note Exception: 9a7. クラスから派生しており
     、追加のメソッドは定義されていません。

 -- 例外: email.errors.MessageParseError

     This is the base class for exceptions raised by the *note Parser:
     116f. class.  It is derived from *note MessageError: 3472.  This
     class is also used internally by the parser used by *note
     headerregistry: 39.

 -- 例外: email.errors.HeaderParseError

     Raised under some error conditions when parsing the RFC 5322(2)
     headers of a message, this class is derived from *note
     MessageParseError: 3473.  The *note set_boundary(): 3420. method
     will raise this error if the content type is unknown when the
     method is called.  *note Header: 1814. may raise this error for
     certain base64 decoding errors, and when an attempt is made to
     create a header that appears to contain an embedded header (that
     is, there is what is supposed to be a continuation line that has no
     leading whitespace and looks like a header).

 -- 例外: email.errors.BoundaryError

     Deprecated and no longer used.

 -- 例外: email.errors.MultipartConversionError

     この例外は、 *note Message: 25d. オブジェクトに ‘add_payload()’ メ
     ソッドでペイロードを追加したが、そのペイロードがすでにスカラー値で
     、メッセージの ‘Content-Type’ メインタイプが ‘multipart’ でないか見
     付からない場合に送出されます。 *note MultipartConversionError:
     3475. は *note MessageError: 3472. と組み込みの *note TypeError:
     502. を多重継承しています。

     ‘Message.add_payload()’ は非推奨なので、実際のところこの例外が送出
     されることはほとんどありません。 しかしながら、 *note attach():
     3432. メソッドを *note MIMENonMultipart: 3476. から派生したインスタ
     ンス (たとえば *note MIMEImage: 3477.) に対して呼んだ場合にも送出さ
     れることがあります。

 -- 例外: email.errors.HeaderWriteError

     Raised when an error occurs when the *note generator: 37. outputs
     headers.

 -- 例外: email.errors.MessageDefect

     This is the base class for all defects found when parsing email
     messages.  It is derived from *note ValueError: 1e3.

 -- 例外: email.errors.HeaderDefect

     This is the base class for all defects found when parsing email
     headers.  It is derived from *note MessageDefect: 3478.

以下は *note FeedParser: 343c. がメッセージの解析中に検出する障害
(defect) の一覧です。これらの障害は、問題が見つかったメッセージに追加さ
れるため、たとえば ‘multipart/alternative’ 内にあるネストしたメッセージ
が異常なヘッダをもっていた場合には、そのネストしたメッセージが障害を持っ
ているが、その親メッセージには障害はないとみなされることに注意してくださ
い。

すべての障害クラスは *note email.errors.MessageDefect: 3478. のサブクラ
スです。

   * ‘NoBoundaryInMultipartDefect’ - メッセージが multipart だと宣言され
     ているのに、 ‘boundary’ パラメータがありません。

   * ‘StartBoundaryNotFoundDefect’ - ‘Content-Type’ ヘッダで宣言された開
     始境界がありません。

   * ‘CloseBoundaryNotFoundDefect’ - 開始境界はあるが対応する終了境界が
     ありません。

     Added in version 3.3.

   * ‘FirstHeaderLineIsContinuationDefect’ - メッセージの最初のヘッダ行
     が継続行です。

   * ‘MisplacedEnvelopeHeaderDefect’ - ヘッダブロックの途中に "Unix
     From" ヘッダがあります。

   * ‘MissingHeaderBodySeparatorDefect’ - 先頭に空白はないが ':' がない
     ヘッダの解析中に行が見付かりました。その行を本体の最初の行とみなし
     て解析を続けます。

     Added in version 3.3.

   * ‘MalformedHeaderDefect’ - ヘッダにコロンがありません、あるいはそれ
     以外の不正な形式です。

     バージョン 3.3 で非推奨: この欠陥が使われていないPythonバージョンが
     いくつかあります。

   * ‘MultipartInvariantViolationDefect’ - メッセージが ‘multipart’ だと
     宣言されているのに、サブパートが存在しません。 メッセージがこの欠陥
     を持つ場合、内容の型が ‘multipart’ と宣言されていても *note
     is_multipart(): 3425. メソッドは ‘False’ を返すことがあるので注意し
     てください。

   * ‘InvalidBase64PaddingDefect’ - 一連の base64 でエンコードされた
     bytes をデコードしているときにパディングが誤っていました。 デコード
     するのに十分なパディングがなされますが、デコードされた bytes は不正
     かもしれません。

   * ‘InvalidBase64CharactersDefect’ - 一連の base64 でエンコードされた
     bytes をデコードしているときに base64 アルファベット外の文字があり
     ました。 その文字は無視されますが、デコードされた bytes は不正かも
     しれません。

   * ‘InvalidBase64LengthDefect’ - 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.

   * ‘InvalidDateDefect’ - When decoding an invalid or unparsable date
     field.  The original value is kept as-is.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/errors.py

   (2) https://datatracker.ietf.org/doc/html/rfc5322.html


File: python.info,  Node: email headerregistry Custom Header Objects,  Next: email contentmanager Managing MIME Content,  Prev: email errors Exception and Defect classes,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.9 ‘email.headerregistry’: Custom Header Objects
......................................................

'ソースコード:' Lib/email/headerregistry.py(1)

__________________________________________________________________

Added in version 3.6: (2)

ヘッダーは *note str: 418. のカスタマイズされたサブクラスで表現されます
。 与えられたヘッダーを表現するために使用される特定のクラスは、ヘッダー
が作成されるときに有効な *note policy: 46. の *note header_factory:
345f. で決定されます。 このセクションでは、email ライブラリが RFC
5322(3) に準拠したメールメッセージを扱うために実装している、特定の
‘header_factory’ について説明します。このヘッダーは、様々なヘッダータイ
プに対してカスタマイズされたヘッダーオブジェクトを提供するだけでなく、ア
プリケーションが独自のカスタムヘッダータイプを追加できるような拡張メカニ
ズムも備えています。

*note EmailPolicy: 1087. から派生したポリシーオブジェクトのいずれかを使
用する場合、すべてのヘッダーは *note HeaderRegistry: 347c. によって生成
され、最終的な基底クラスとして *note BaseHeader: 340d. を有します。 各ヘ
ッダクラスには、ヘッダの種類によって決まる追加のベースクラスがあります。
例えば、多くのヘッダーは *note UnstructuredHeader: 347d. というクラスを
もうひとつの基底クラスとして持っています。 ヘッダーに特化した第二のクラ
スは、ヘッダーの名前によって決定され、 *note HeaderRegistry: 347c. に格
納されたルックアップテーブルを使用します。 これらすべては、典型的なアプ
リケーションプログラムに対しては透過的に管理されますが、より複雑なアプリ
ケーションで使用するためにデフォルトの動作を変更するためのインタフェース
が提供されています。

以下のセクションでは、まずヘッダーの基本クラスとその属性を説明し、次に
*note HeaderRegistry: 347c. の動作を変更するための API、そして最後に構造
化ヘッダーからパースされたデータを表現するためのサポートクラスについて説
明します。

 -- クラス: email.headerregistry.BaseHeader (name, value)

     'name' と 'value' は *note header_factory: 345f. 呼び出しから
     ‘BaseHeader’ に渡されます。 どのヘッダーオブジェクトの文字列値も、
     完全にユニコードにデコードされた 'value' です。

     基底クラスは以下の読み出し専用属性を定義しています:

      -- の属性: name

          ヘッダーの名前(フィールドの':'の前の部分)。これは *note
          header_factory: 345f. の 'name' の呼び出しで渡された値と全く同
          じです; つまり、大文字・小文字が保持されます。

      -- の属性: defects

          パース中に見つかったRFCのコンプライアンス問題を報告する *note
          HeaderDefect: 3479. インスタンスのタプルです。 email パッケー
          ジはコンプライアンスに関する問題を完全に検出するように努めてい
          ます。 報告されるかもしれない欠陥の種類の議論については、
          *note errors: 36. モジュールを参照してください。

      -- の属性: max_count

          このタイプのヘッダーで、同じ ‘name’ を持つことができる最大数。
          値として ‘None’ を指定すると、無制限になります。 この属性の
          ‘BaseHeader’ の値は ‘None’ です; 特殊な header クラスでは、必
          要に応じてこの値をオーバーライドすることが期待されます。

     ‘BaseHeader’ は以下のメソッドも提供します。このメソッドはemail ライ
     ブラリのコードから呼び出され、一般にアプリケーションプログラムから
     は呼び出されません：

      -- メソッド: fold (*, policy)

          ヘッダを 'policy' に従って正しく折りたたむために必要な *note
          linesep: 3454. 文字を含む文字列を返します。 ヘッダには任意のバ
          イナリデータを含めることができないため、 *note cte_type: 344d.
          が ‘8bit’ の場合は ‘7bit’ と同じように扱われます。 もし *note
          utf8: dc5. が ‘False’ であれば、非ASCIIデータは RFC 2047(4) で
          エンコードされます。

     ‘BaseHeader’ 自身はヘッダーオブジェクトを生成するために使用すること
     はできません。このクラスは、それぞれの特殊化ヘッダーがヘッダーオブ
     ジェクトを生成するために協力するプロトコルを定義しています。 具体的
     には、 ‘BaseHeader’ は ‘parse’ という名前の *note classmethod():
     14c. を特殊化されたクラスが提供することを要求しています。このメソッ
     ドは以下のように呼び出されます:

          parse(string, kwds)

     ‘kwds’ は、初期化されたキー ‘defects’ を含む辞書です。‘defects’ は
     空のリストです。 解析メソッドは、検出された不具合をこのリストに追加
     するべきです。 returnの際には、 ‘kwds’ 辞書に少なくとも ‘decoded’ と
     ''defects'' のキーを含む必要があります。 ‘decoded’ はヘッダの文字列
     値 (つまり、ヘッダを Unicode に完全にデコードした値) でなければなり
     ません。 parseメソッドは、 'string' がcontent-transfer-encodedな部
     分を含む可能性があると仮定すべきですが、エンコードされていないヘッ
     ダ値をパースできるように、すべての有効なUnicode文字も正しく処理する
     必要があります。

     その後、 ‘BaseHeader’ の ‘__new__’ がヘッダのインスタンスを生成し、
     ‘init’ メソッドを呼び出します。 特殊クラスは、 ‘BaseHeader’ が提供
     しない属性を設定したい場合にのみ ‘init’ メソッドを提供する必要があ
     ります。 このような''init'' メソッドは以下のようなものです：

          def init(self, /, *args, **kw):
              self._myattr = kw.pop('myattr')
              super().init(*args, **kw)

     つまり、特殊クラスが ‘kwds’ の辞書に追加したものはすべて削除して処
     理し、 ‘kw``の残りの内容 (と ``args’) は''BaseHeader'' の''init'' メ
     ソッドに渡す必要があるのです。

 -- クラス: email.headerregistry.UnstructuredHeader

     "unstructured" ヘッダは RFC 5322(5) におけるデフォルトのヘッダのタ
     イプです。指定された構文を持たないすべてのヘッダは、unstructuredと
     して扱われます。 構造化されていないヘッダの典型的な例は ‘Subject’ ヘ
     ッダです。

     RFC 5322(6) では、非構造化ヘッダは ASCII 文字セットの任意のテキスト
     の集まりです。しかし、 RFC 2047(7) にはヘッダ値の中で非 ASCII テキ
     ストを ASCII 文字としてエンコードするための RFC 5322(8) と互換性の
     あるメカニズムが備わっています。 エンコードされた単語を含む 'value'
     がコンストラクタに渡されると、 ‘UnstructuredHeader’ パーサは非構造
     化テキストに対する RFC 2047(9) 規則に従って、エンコードされた単語を
     unicode に変換します。 パーサは特定の非適合なエンコードされた単語の
     デコードを試みるためにヒューリスティックを使用します。 このような場
     合、欠陥が登録されます。また、エンコードされた単語やエンコードされ
     ていないテキスト内の無効な文字などの問題に対しても欠陥が登録されま
     す。

     このヘッダ型には追加の属性はありません。

 -- クラス: email.headerregistry.DateHeader

     RFC 5322(10) 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".

     このヘッダ型は以下の属性も提供しています:

      -- の属性: datetime

          If the header value can be recognized as a valid date of one
          form or another, this attribute will contain a *note datetime:
          1ae. instance representing that date.  If the timezone of the
          input date is specified as ‘-0000’ (indicating it is in UTC
          but contains no information about the source timezone), then
          *note datetime: 3482. will be a naive *note datetime: 1ae.  If
          a specific timezone offset is found (including ‘+0000’), then
          *note datetime: 3482. will contain an aware ‘datetime’ that
          uses *note datetime.timezone: 1091. to record the timezone
          offset.

     ヘッダーの ‘decoded’ 値は、 ‘datetime’ を RFC 5322(11) のルールに従
     ってフォーマットすることで決定されます。

          email.utils.format_datetime(self.datetime)

     ‘DateHeader’ を作成する際に、 'value' は *note datetime: 1ae. イン
     スタンスである可能性があります。 これは、例えば、次のようなコードは
     有効であり、期待通りの動作をすることを意味します:

          msg['Date'] = datetime(2011, 7, 15, 21)

     これは単純な ‘datetime’ であるため、UTC タイムスタンプとして解釈さ
     れ、結果として ‘-0000’ というタイムゾーンを持つ値になります。 もっ
     と便利なのは *note utils: 47. モジュールの *note localtime(): 2a5.
     関数を使用することです:

          msg['Date'] = utils.localtime()

     この例では、現在のタイムゾーンオフセットを使用して、日付ヘッダーを
     現在の時刻と日付に設定します。

 -- クラス: email.headerregistry.AddressHeader

     アドレスヘッダは最も複雑な構造のヘッダタイプの1つです。
     ‘AddressHeader’ クラスは、あらゆるアドレスヘッダに対する汎用的なイ
     ンターフェースを提供します。

     このヘッダ型は以下の属性も提供しています:

      -- の属性: groups

          ヘッダー値に含まれるアドレスとグループをエンコードした *note
          Group: 3485. オブジェクトのタプルです。 グループに属さないアド
          レスは、このリストでは *note display_name: 3486. が ‘None’ で
          あるシングルアドレスの ‘Groups’ として表現されます。

      -- の属性: addresses

          ヘッダー値に含まれる全ての個別アドレスをエンコードした *note
          Address: 3488. オブジェクトのタプルです。 ヘッダ値にグループが
          含まれている場合、そのグループに含まれる個々のアドレスは、ヘッ
          ダ値でグループが出現した時点でリストに含まれます (つまり、アド
          レスのリストは一次元のリストに「フラット化」されます)。

     The ‘decoded’ value of the header will have all encoded words
     decoded to unicode.  *note idna: 48. encoded domain names are also
     decoded to unicode.  The ‘decoded’ value is set by *note joining:
     212c. the *note str: 418. value of the elements of the ‘groups’
     attribute with ‘', '’.

     A list of *note Address: 3488. and *note Group: 3485. objects in
     any combination may be used to set the value of an address header.
     ‘Group’ objects whose ‘display_name’ is ‘None’ will be interpreted
     as single addresses, which allows an address list to be copied with
     groups intact by using the list obtained from the ‘groups’
     attribute of the source header.

 -- クラス: email.headerregistry.SingleAddressHeader

     追加の属性を 1 つ持つ、*note AddressHeader: 3483. の派生クラスです:

      -- の属性: address

          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 *note policy: 46.),
          accessing this attribute will result in a *note ValueError:
          1e3.

Many of the above classes also have a ‘Unique’ variant (for example,
‘UniqueUnstructuredHeader’).  The only difference is that in the
‘Unique’ variant, *note max_count: 3462. is set to 1.

 -- クラス: email.headerregistry.MIMEVersionHeader

     There is really only one valid value for the ‘MIME-Version’ header,
     and that is ‘1.0’.  For future proofing, this header class supports
     other valid version numbers.  If a version number has a valid value
     per RFC 2045(12), then the header object will have non-‘None’
     values for the following attributes:

      -- の属性: version

          バージョン番号 (文字列)、空白やコメントは除かれます。

      -- の属性: major

          メジャーバージョン番号 (整数)

      -- の属性: minor

          マイナーバージョン番号 (整数)

 -- クラス: email.headerregistry.ParameterizedMIMEHeader

     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.

      -- の属性: params

          A dictionary mapping parameter names to parameter values.

 -- クラス: email.headerregistry.ContentTypeHeader

     ‘Content-Type’ ヘッダを扱う *note ParameterizedMIMEHeader: 348f. ク
     ラスです。

      -- の属性: content_type

          The content type string, in the form ‘maintype/subtype’.

      -- の属性: maintype

      -- の属性: subtype

 -- クラス: email.headerregistry.ContentDispositionHeader

     ‘Content-Disposition’ ヘッダを扱う *note ParameterizedMIMEHeader:
     348f. クラスです。

      -- の属性: content_disposition

          ‘inline’ and ‘attachment’ are the only valid values in common
          use.

 -- クラス: email.headerregistry.ContentTransferEncoding

     ‘Content-Transfer-Encoding’ ヘッダを扱います。

      -- の属性: cte

          有効な値は ‘7bit’、‘8bit’、‘base64’、‘quoted-printable’ です。
          詳細については RFC 2045(13) を参照してください。

 -- クラス: email.headerregistry.HeaderRegistry (base_class=BaseHeader,
          default_class=UnstructuredHeader, use_default_map=True)

     This is the factory used by *note EmailPolicy: 1087. by default.
     ‘HeaderRegistry’ builds the class used to create a header instance
     dynamically, using 'base_class' and a specialized class retrieved
     from a registry that it holds.  When a given header name does not
     appear in the registry, the class specified by 'default_class' is
     used as the specialized class.  When 'use_default_map' is ‘True’
     (the default), the standard mapping of header names to classes is
     copied in to the registry during initialization.  'base_class' is
     always the last class in the generated class's *note __bases__:
     1451. list.

     デフォルトのマッピング:


          subject: UniqueUnstructuredHeader


          date: UniqueDateHeader


          resent-date: DateHeader


          orig-date: UniqueDateHeader


          sender: UniqueSingleAddressHeader


          resent-sender: SingleAddressHeader


          to: UniqueAddressHeader


          resent-to: AddressHeader


          cc: UniqueAddressHeader


          resent-cc: AddressHeader


          bcc: UniqueAddressHeader


          resent-bcc: AddressHeader


          from: UniqueAddressHeader


          resent-from: AddressHeader


          reply-to: UniqueAddressHeader


          mime-version: MIMEVersionHeader


          content-type: ContentTypeHeader


          content-disposition: ContentDispositionHeader


          content-transfer-encoding: ContentTransferEncodingHeader


          message-id: MessageIDHeader

     ‘HeaderRegistry’ には以下のメソッドがあります:

      -- メソッド: map_to_type (self, name, cls)

          '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'.

      -- メソッド: __getitem__ (name)

          Construct and return a class to handle creating a 'name'
          header.

      -- メソッド: __call__ (name, value)

          Retrieves the specialized header associated with 'name' from
          the registry (using 'default_class' if 'name' does not appear
          in the registry) and composes it with 'base_class' to produce
          a class, calls the constructed class's constructor, passing it
          the same argument list, and finally returns the class instance
          created thereby.

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.

 -- クラス: email.headerregistry.Address (display_name='', username='',
          domain='', addr_spec=None)

     このクラスは電子メールのアドレスを表すのに使われます。アドレスの一
     般的な形式は:

          [display_name] <username@domain>

     もしくは:

          username@domain

     where each part must conform to specific syntax rules spelled out
     in RFC 5322(14).

     As a convenience 'addr_spec' can be specified instead of 'username'
     and 'domain', in which case 'username' and 'domain' will be parsed
     from the 'addr_spec'.  An 'addr_spec' must be a properly RFC quoted
     string; if it is not ‘Address’ will raise an error.  Unicode
     characters are allowed and will be property encoded when
     serialized.  However, per the RFCs, unicode is 'not' allowed in the
     username portion of the address.

      -- の属性: display_name

          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.

      -- の属性: username

          アドレスの ‘username’ 部分、クォートは取り除かれます。

      -- の属性: domain

          アドレスの ‘domain’ 部分。

      -- の属性: addr_spec

          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.

      -- メソッド: __str__ ()

          The ‘str’ value of the object is the address quoted according
          to RFC 5322(15) rules, but with no Content Transfer Encoding
          of any non-ASCII characters.

     To support SMTP ( RFC 5321(16)), ‘Address’ handles one special
     case: if ‘username’ and ‘domain’ are both the empty string (or
     ‘None’), then the string value of the ‘Address’ is ‘<>’.

 -- クラス: email.headerregistry.Group (display_name=None,
          addresses=None)

     このクラスはアドレスグループを表すのに使われます。アドレスグループ
     の一般的な形式は:

          display_name: [address-list];

     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'.

      -- の属性: display_name

          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.

      -- の属性: addresses

          A possibly empty tuple of *note Address: 3488. objects
          representing the addresses in the group.

      -- メソッド: __str__ ()

          The ‘str’ value of a ‘Group’ is formatted according to RFC
          5322(17), but with no Content Transfer Encoding of any
          non-ASCII characters.  If ‘display_name’ is none and there is
          a single ‘Address’ in the ‘addresses’ list, the ‘str’ value
          will be the same as the ‘str’ of that single ‘Address’.

脚注
....

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/email/headerregistry.py

   (2) Originally added in 3.3 as a *note provisional module: 100b.

   (3) https://datatracker.ietf.org/doc/html/rfc5322.html

   (4) https://datatracker.ietf.org/doc/html/rfc2047.html

   (5) https://datatracker.ietf.org/doc/html/rfc5322.html

   (6) https://datatracker.ietf.org/doc/html/rfc5322.html

   (7) https://datatracker.ietf.org/doc/html/rfc2047.html

   (8) https://datatracker.ietf.org/doc/html/rfc5322.html

   (9) https://datatracker.ietf.org/doc/html/rfc2047.html

   (10) https://datatracker.ietf.org/doc/html/rfc5322.html

   (11) https://datatracker.ietf.org/doc/html/rfc5322.html

   (12) https://datatracker.ietf.org/doc/html/rfc2045.html

   (13) https://datatracker.ietf.org/doc/html/rfc2045.html

   (14) https://datatracker.ietf.org/doc/html/rfc5322.html

   (15) https://datatracker.ietf.org/doc/html/rfc5322.html

   (16) https://datatracker.ietf.org/doc/html/rfc5321.html

   (17) https://datatracker.ietf.org/doc/html/rfc5322.html


File: python.info,  Node: email contentmanager Managing MIME Content,  Next: email 使用例,  Prev: email headerregistry Custom Header Objects,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.10 ‘email.contentmanager’: Managing MIME Content
.......................................................

'ソースコード:' Lib/email/contentmanager.py(1)

__________________________________________________________________

Added in version 3.6: (2)

 -- クラス: email.contentmanager.ContentManager

     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.

      -- メソッド: get_content (msg, *args, **kw)

          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.

          To find the handler, look for the following keys in the
          registry, stopping with the first one found:

             * 完全な MIME 型を表す文字列 (‘maintype/subtype’)

             * ‘maintype’ を表す文字列

             * 空の文字列

          If none of these keys produce a handler, raise a *note
          KeyError: 31d. for the full MIME type.

      -- メソッド: set_content (msg, obj, *args, **kw)

          If the ‘maintype’ is ‘multipart’, raise a *note TypeError:
          502.; otherwise look up a handler function based on the type
          of 'obj' (see next paragraph), call *note clear_content():
          3436. on the 'msg', and call the handler function, passing
          through all arguments.  The expectation is that the handler
          will transform and store 'obj' into 'msg', possibly making
          other changes to 'msg' as well, such as adding various MIME
          headers to encode information needed to interpret the stored
          data.

          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:

             * 型自身 (‘typ’)

             * 型の完全修飾名 (‘typ.__module__ + '.' +
               typ.__qualname__’).

             * the type's *note qualname: 1e86. (‘typ.__qualname__’)

             * the type's *note name: 1450. (‘typ.__name__’).

          If none of the above match, repeat all of the checks above for
          each of the types in the *note MRO: 34a5. (*note typ.__mro__:
          1e89.).  Finally, if no other key yields a handler, check for
          a handler for the key ‘None’.  If there is no handler for
          ‘None’, raise a *note KeyError: 31d. for the fully qualified
          name of the type.

          Also add a ‘MIME-Version’ header if one is not present (see
          also *note MIMEPart: f08.).

      -- メソッド: add_get_handler (key, handler)

          Record the function 'handler' as the handler for 'key'.  For
          the possible values of 'key', see *note get_content(): 34a7.

      -- メソッド: add_set_handler (typekey, handler)

          Record 'handler' as the function to call when an object of a
          type matching 'typekey' is passed to *note set_content():
          34a9.  For the possible values of 'typekey', see *note
          set_content(): 34a9.

* Menu:

* Content Manager Instances::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/email/contentmanager.py

   (2) Originally added in 3.4 as a *note provisional module: 100b.


File: python.info,  Node: Content Manager Instances,  Up: email contentmanager Managing MIME Content

5.19.1.11 Content Manager Instances
...................................

Currently the email package provides only one concrete content manager,
*note raw_data_manager: 3460, although more may be added in the future.
*note raw_data_manager: 3460. is the *note content_manager: f07.
provided by *note EmailPolicy: 1087. and its derivatives.

 -- データ: email.contentmanager.raw_data_manager

     This content manager provides only a minimum interface beyond that
     provided by *note Message: 25d. itself: it deals only with text,
     raw byte strings, and *note Message: 25d. objects.  Nevertheless,
     it provides significant advantages compared to the base API:
     ‘get_content’ on a text part will return a unicode string without
     the application needing to manually decode it, ‘set_content’
     provides a rich set of options for controlling the headers added to
     a part and controlling the content transfer encoding, and it
     enables the use of the various ‘add_’ methods, thereby simplifying
     the creation of multipart messages.

      -- メソッド: email.contentmanager.get_content (msg,
               errors='replace')

          Return the payload of the part as either a string (for ‘text’
          parts), an *note EmailMessage: 25c. object (for
          ‘message/rfc822’ parts), or a ‘bytes’ object (for all other
          non-multipart types).  Raise a *note KeyError: 31d. if called
          on a ‘multipart’.  If the part is a ‘text’ part and 'errors'
          is specified, use it as the error handler when decoding the
          payload to unicode.  The default error handler is ‘replace’.

      -- メソッド: email.contentmanager.set_content (msg, <'str'>,
               subtype="plain", charset='utf-8', cte=None,
               disposition=None, filename=None, cid=None, params=None,
               headers=None)

      -- メソッド: email.contentmanager.set_content (msg, <'bytes'>,
               maintype, subtype, cte="base64", disposition=None,
               filename=None, cid=None, params=None, headers=None)

      -- メソッド: email.contentmanager.set_content (msg,
               <'EmailMessage'>, cte=None, disposition=None,
               filename=None, cid=None, params=None, headers=None)

          Add headers and payload to 'msg':

          Add a ‘Content-Type’ header with a ‘maintype/subtype’ value.

             * For ‘str’, set the MIME ‘maintype’ to ‘text’, and set the
               subtype to 'subtype' if it is specified, or ‘plain’ if it
               is not.

             * For ‘bytes’, use the specified 'maintype' and 'subtype',
               or raise a *note TypeError: 502. if they are not
               specified.

             * For *note EmailMessage: 25c. 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).

          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.

          If 'cte' is set, encode the payload using the specified
          content transfer encoding, and set the
          ‘Content-Transfer-Encoding’ header to that value.  Possible
          values for 'cte' are ‘quoted-printable’, ‘base64’, ‘7bit’,
          ‘8bit’, and ‘binary’.  If the input cannot be encoded in the
          specified encoding (for example, specifying a 'cte' of ‘7bit’
          for an input that contains non-ASCII values), raise a *note
          ValueError: 1e3.

             * For ‘str’ objects, if 'cte' is not set use heuristics to
               determine the most compact encoding.

             * For *note EmailMessage: 25c, per RFC 2046(1), raise an
               error if a 'cte' of ‘quoted-printable’ or ‘base64’ is
               requested for 'subtype' ‘rfc822’, and for any 'cte' other
               than ‘7bit’ for 'subtype' ‘external-body’.  For
               ‘message/rfc822’, use ‘8bit’ if 'cte' is not specified.
               For all other values of 'subtype', use ‘7bit’.

               注釈: A 'cte' of ‘binary’ does not actually work
               correctly yet.  The ‘EmailMessage’ object as modified by
               ‘set_content’ is correct, but *note BytesGenerator: 119f.
               does not serialize it correctly.

          If 'disposition' is set, use it as the value of the
          ‘Content-Disposition’ header.  If not specified, and
          'filename' is specified, add the header with the value
          ‘attachment’.  If 'disposition' is not specified and
          'filename' is also not specified, do not add the header.  The
          only valid values for 'disposition' are ‘attachment’ and
          ‘inline’.

          If 'filename' is specified, use it as the value of the
          ‘filename’ parameter of the ‘Content-Disposition’ header.

          If 'cid' is specified, add a ‘Content-ID’ header with 'cid' as
          its value.

          If 'params' is specified, iterate its ‘items’ method and use
          the resulting ‘(key, value)’ pairs to set additional
          parameters on the ‘Content-Type’ header.

          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'.

脚注
....

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2046.html


File: python.info,  Node: email 使用例,  Next: email message Message compat32 API を使用した電子メールメッセージの表現,  Prev: email contentmanager Managing MIME Content,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.12 ‘email’: 使用例
.........................

ここでは *note email: 32. パッケージを使って電子メールメッセージを読む・
書く・送信するいくつかの例を紹介します。より複雑な MIME メッセージについ
ても扱います。

最初に、シンプルなテキストメッセージ (テキストコンテンツとアドレスの両方
がユニコード文字を含み得る) を作成・送信する方法を見てみましょう:

     # Import smtplib for the actual sending function
     import smtplib

     # Import the email modules we'll need
     from email.message import EmailMessage

     # Open the plain text file whose name is in textfile for reading.
     with open(textfile) as fp:
         # Create a text/plain message
         msg = EmailMessage()
         msg.set_content(fp.read())

     # me == the sender's email address
     # you == the recipient's email address
     msg['Subject'] = f'The contents of {textfile}'
     msg['From'] = me
     msg['To'] = you

     # Send the message via our own SMTP server.
     s = smtplib.SMTP('localhost')
     s.send_message(msg)
     s.quit()

RFC 822(1) ヘッダーの解析は、 *note parser: 45. モジュールにあるクラスを
使用することにより、簡単に実現できます:

     # Import the email modules we'll need
     #from email.parser import BytesParser
     from email.parser import Parser
     from email.policy import default

     # If the e-mail headers are in a file, uncomment these two lines:
     # with open(messagefile, 'rb') as fp:
     #     headers = BytesParser(policy=default).parse(fp)

     #  Or for parsing headers in a string (this is an uncommon operation), use:
     headers = Parser(policy=default).parsestr(
             'From: Foo Bar <user@example.com>\n'
             'To: <someone_else@example.com>\n'
             'Subject: Test message\n'
             '\n'
             'Body would go here\n')

     #  Now the header items can be accessed as a dictionary:
     print('To: {}'.format(headers['to']))
     print('From: {}'.format(headers['from']))
     print('Subject: {}'.format(headers['subject']))

     # You can also access the parts of the addresses:
     print('Recipient username: {}'.format(headers['to'].addresses[0].username))
     print('Sender name: {}'.format(headers['from'].addresses[0].display_name))

つぎに、あるディレクトリ内にある何枚かの家族写真をひとつの MIME メッセー
ジに収めて送信する例です:

     # Import smtplib for the actual sending function.
     import smtplib

     # Here are the email package modules we'll need.
     from email.message import EmailMessage

     # Create the container email message.
     msg = EmailMessage()
     msg['Subject'] = 'Our family reunion'
     # me == the sender's email address
     # family = the list of all recipients' email addresses
     msg['From'] = me
     msg['To'] = ', '.join(family)
     msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'

     # Open the files in binary mode.  You can also omit the subtype
     # if you want MIMEImage to guess it.
     for file in pngfiles:
         with open(file, 'rb') as fp:
             img_data = fp.read()
         msg.add_attachment(img_data, maintype='image',
                                      subtype='png')

     # Send the email via our own SMTP server.
     with smtplib.SMTP('localhost') as s:
         s.send_message(msg)

つぎはあるディレクトリに含まれている内容全体をひとつの電子メールメッセー
ジとして送信するやり方です: (2)

     #!/usr/bin/env python3

     """Send the contents of a directory as a MIME message."""

     import os
     import smtplib
     # For guessing MIME type based on file name extension
     import mimetypes

     from argparse import ArgumentParser

     from email.message import EmailMessage
     from email.policy import SMTP


     def main():
         parser = ArgumentParser(description="""\
     Send the contents of a directory as a MIME message.
     Unless the -o option is given, the email is sent by forwarding to your local
     SMTP server, which then does the normal delivery process.  Your local machine
     must be running an SMTP server.
     """)
         parser.add_argument('-d', '--directory',
                             help="""Mail the contents of the specified directory,
                             otherwise use the current directory.  Only the regular
                             files in the directory are sent, and we don't recurse to
                             subdirectories.""")
         parser.add_argument('-o', '--output',
                             metavar='FILE',
                             help="""Print the composed message to FILE instead of
                             sending the message to the SMTP server.""")
         parser.add_argument('-s', '--sender', required=True,
                             help='The value of the From: header (required)')
         parser.add_argument('-r', '--recipient', required=True,
                             action='append', metavar='RECIPIENT',
                             default=[], dest='recipients',
                             help='A To: header value (at least one required)')
         args = parser.parse_args()
         directory = args.directory
         if not directory:
             directory = '.'
         # Create the message
         msg = EmailMessage()
         msg['Subject'] = f'Contents of directory {os.path.abspath(directory)}'
         msg['To'] = ', '.join(args.recipients)
         msg['From'] = args.sender
         msg.preamble = 'You will not see this in a MIME-aware mail reader.\n'

         for filename in os.listdir(directory):
             path = os.path.join(directory, filename)
             if not os.path.isfile(path):
                 continue
             # Guess the content type based on the file's extension.  Encoding
             # will be ignored, although we should check for simple things like
             # gzip'd or compressed files.
             ctype, encoding = mimetypes.guess_file_type(path)
             if ctype is None or encoding is not None:
                 # No guess could be made, or the file is encoded (compressed), so
                 # use a generic bag-of-bits type.
                 ctype = 'application/octet-stream'
             maintype, subtype = ctype.split('/', 1)
             with open(path, 'rb') as fp:
                 msg.add_attachment(fp.read(),
                                    maintype=maintype,
                                    subtype=subtype,
                                    filename=filename)
         # Now send or store the message
         if args.output:
             with open(args.output, 'wb') as fp:
                 fp.write(msg.as_bytes(policy=SMTP))
         else:
             with smtplib.SMTP('localhost') as s:
                 s.send_message(msg)


     if __name__ == '__main__':
         main()

つぎに、上のような MIME メッセージをどうやって展開してひとつのディレクト
リ上の複数ファイルにするかを示します:

     #!/usr/bin/env python3

     """Unpack a MIME message into a directory of files."""

     import os
     import email
     import mimetypes

     from email.policy import default

     from argparse import ArgumentParser


     def main():
         parser = ArgumentParser(description="""\
     Unpack a MIME message into a directory of files.
     """)
         parser.add_argument('-d', '--directory', required=True,
                             help="""Unpack the MIME message into the named
                             directory, which will be created if it doesn't already
                             exist.""")
         parser.add_argument('msgfile')
         args = parser.parse_args()

         with open(args.msgfile, 'rb') as fp:
             msg = email.message_from_binary_file(fp, policy=default)

         try:
             os.mkdir(args.directory)
         except FileExistsError:
             pass

         counter = 1
         for part in msg.walk():
             # multipart/* are just containers
             if part.get_content_maintype() == 'multipart':
                 continue
             # Applications should really sanitize the given filename so that an
             # email message can't be used to overwrite important files
             filename = part.get_filename()
             if not filename:
                 ext = mimetypes.guess_extension(part.get_content_type())
                 if not ext:
                     # Use a generic bag-of-bits extension
                     ext = '.bin'
                 filename = f'part-{counter:03d}{ext}'
             counter += 1
             with open(os.path.join(args.directory, filename), 'wb') as fp:
                 fp.write(part.get_payload(decode=True))


     if __name__ == '__main__':
         main()

代替のプレーンテキストバージョン付きの HTML メッセージを作成する方法の例
です。もう少し面白くするために、 HTML 部分に関連する画像を追加し、さらに
送信だけでなく、送信しようとしているもののコピーをディスクにも保存してみ
ます。

     #!/usr/bin/env python3

     import smtplib

     from email.message import EmailMessage
     from email.headerregistry import Address
     from email.utils import make_msgid

     # Create the base text message.
     msg = EmailMessage()
     msg['Subject'] = "Pourquoi pas des asperges pour ce midi ?"
     msg['From'] = Address("Pepé Le Pew", "pepe", "example.com")
     msg['To'] = (Address("Penelope Pussycat", "penelope", "example.com"),
                  Address("Fabrette Pussycat", "fabrette", "example.com"))
     msg.set_content("""\
     Salut!

     Cette recette [1] sera sûrement un très bon repas.

     [1] http://www.yummly.com/recipe/Roasted-Asparagus-Epicurious-203718

     --Pepé
     """)

     # Add the html version.  This converts the message into a multipart/alternative
     # container, with the original text message as the first part and the new html
     # message as the second part.
     asparagus_cid = make_msgid()
     msg.add_alternative("""\
     <html>
       <head></head>
       <body>
         <p>Salut!</p>
         <p>Cette
             <a href="http://www.yummly.com/recipe/Roasted-Asparagus-Epicurious-203718">
                 recette
             </a> sera sûrement un très bon repas.
         </p>
         <img src="cid:{asparagus_cid}" />
       </body>
     </html>
     """.format(asparagus_cid=asparagus_cid[1:-1]), subtype='html')
     # note that we needed to peel the <> off the msgid for use in the html.

     # Now add the related image to the html part.
     with open("roasted-asparagus.jpg", 'rb') as img:
         msg.get_payload()[1].add_related(img.read(), 'image', 'jpeg',
                                          cid=asparagus_cid)

     # Make a local copy of what we are going to send.
     with open('outgoing.msg', 'wb') as f:
         f.write(bytes(msg))

     # Send the message via local SMTP server.
     with smtplib.SMTP('localhost') as s:
         s.send_message(msg)

前の例のメッセージが送信されてきたら、これを処理する方法の一つは次のよう
なものです:

     import os
     import sys
     import tempfile
     import mimetypes
     import webbrowser

     # Import the email modules we'll need
     from email import policy
     from email.parser import BytesParser


     def magic_html_parser(html_text, partfiles):
         """Return safety-sanitized html linked to partfiles.

         Rewrite the href="cid:...." attributes to point to the filenames in partfiles.
         Though not trivial, this should be possible using html.parser.
         """
         raise NotImplementedError("Add the magic needed")


     # In a real program you'd get the filename from the arguments.
     with open('outgoing.msg', 'rb') as fp:
         msg = BytesParser(policy=policy.default).parse(fp)

     # Now the header items can be accessed as a dictionary, and any non-ASCII will
     # be converted to unicode:
     print('To:', msg['to'])
     print('From:', msg['from'])
     print('Subject:', msg['subject'])

     # If we want to print a preview of the message content, we can extract whatever
     # the least formatted payload is and print the first three lines.  Of course,
     # if the message has no plain text part printing the first three lines of html
     # is probably useless, but this is just a conceptual example.
     simplest = msg.get_body(preferencelist=('plain', 'html'))
     print()
     print(''.join(simplest.get_content().splitlines(keepends=True)[:3]))

     ans = input("View full message?")
     if ans.lower()[0] == 'n':
         sys.exit()

     # We can extract the richest alternative in order to display it:
     richest = msg.get_body()
     partfiles = {}
     if richest['content-type'].maintype == 'text':
         if richest['content-type'].subtype == 'plain':
             for line in richest.get_content().splitlines():
                 print(line)
             sys.exit()
         elif richest['content-type'].subtype == 'html':
             body = richest
         else:
             print("Don't know how to display {}".format(richest.get_content_type()))
             sys.exit()
     elif richest['content-type'].content_type == 'multipart/related':
         body = richest.get_body(preferencelist=('html'))
         for part in richest.iter_attachments():
             fn = part.get_filename()
             if fn:
                 extension = os.path.splitext(part.get_filename())[1]
             else:
                 extension = mimetypes.guess_extension(part.get_content_type())
             with tempfile.NamedTemporaryFile(suffix=extension, delete=False) as f:
                 f.write(part.get_content())
                 # again strip the <> to go from email form of cid to html form.
                 partfiles[part['content-id'][1:-1]] = f.name
     else:
         print("Don't know how to display {}".format(richest.get_content_type()))
         sys.exit()
     with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
         f.write(magic_html_parser(body.get_content(), partfiles))
     webbrowser.open(f.name)
     os.remove(f.name)
     for fn in partfiles.values():
         os.remove(fn)

     # Of course, there are lots of email messages that could break this simple
     # minded program, but it will handle the most common ones.

プロンプトまでの、上記のプログラムの出力はこうなります:

     To: Penelope Pussycat <penelope@example.com>, Fabrette Pussycat <fabrette@example.com>
     From: Pepé Le Pew <pepe@example.com>
     Subject: Pourquoi pas des asperges pour ce midi ?

     Salut!

     Cette recette [1] sera sûrement un très bon repas.

脚注
....

レガシーAPI:

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc822.html

   (2) 最初の思いつきと用例は Matthew Dixon Cowles のおかげです。


File: python.info,  Node: email message Message compat32 API を使用した電子メールメッセージの表現,  Next: email mime Creating email and MIME objects from scratch,  Prev: email 使用例,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.13 ‘email.message.Message’: ‘compat32’ API を使用した電子メールメッセージの表現
......................................................................................

The *note Message: 25d. class is very similar to the *note EmailMessage:
25c. class, without the methods added by that class, and with the
default behavior of certain other methods being slightly different.  We
also document here some methods that, while supported by the *note
EmailMessage: 25c. class, are not recommended unless you are dealing
with legacy code.

The philosophy and structure of the two classes is otherwise the same.

This document describes the behavior under the default (for *note
Message: 25d.) policy *note Compat32: 1084.  If you are going to use
another policy, you should be using the *note EmailMessage: 25c. class
instead.

An email message consists of 'headers' and a 'payload'.  Headers must be
RFC 5322(1) style names and values, where the field name and value are
separated by a colon.  The colon is not part of either the field name or
the field value.  The payload may be a simple text message, or a binary
object, or a structured sequence of sub-messages each with their own set
of headers and their own payload.  The latter type of payload is
indicated by the message having a MIME type such as ‘multipart/*’ or
‘message/rfc822’.

The conceptual model provided by a *note Message: 25d. object is that of
an ordered dictionary of headers with additional methods for accessing
both specialized information from the headers, for accessing the
payload, for generating a serialized version of the message, and for
recursively walking over the object tree.  Note that duplicate headers
are supported but special methods must be used to access them.

The *note Message: 25d. pseudo-dictionary is indexed by the header
names, which must be ASCII values.  The values of the dictionary are
strings that are supposed to contain only ASCII characters; there is
some special handling for non-ASCII input, but it doesn't always produce
the correct results.  Headers are stored and returned in case-preserving
form, but field names are matched case-insensitively.  There may also be
a single envelope header, also known as the 'Unix-From' header or the
‘From_’ header.  The 'payload' is either a string or bytes, in the case
of simple message objects, or a list of *note Message: 25d. objects, for
MIME container documents (e.g.  ‘multipart/*’ and ‘message/rfc822’).

*note Message: 25d. クラスのメソッドは以下のとおりです:

 -- クラス: email.message.Message (policy=compat32)

     If 'policy' is specified (it must be an instance of a *note policy:
     46. class) use the rules it specifies to update and serialize the
     representation of the message.  If 'policy' is not set, use the
     *note compat32: 1084. policy, which maintains backward
     compatibility with the Python 3.2 version of the email package.
     For more information see the *note policy: 46. documentation.

     バージョン 3.3 で変更: キーワード引数 'policy' が追加されました。

      -- メソッド: as_string (unixfrom=False, maxheaderlen=0,
               policy=None)

          Return the entire message flattened as a string.  When
          optional 'unixfrom' is true, the envelope header is included
          in the returned string.  'unixfrom' defaults to ‘False’.  For
          backward compatibility reasons, 'maxheaderlen' defaults to
          ‘0’, so if you want a different value you must override it
          explicitly (the value specified for 'max_line_length' in the
          policy will be ignored by this method).  The 'policy' argument
          may be used to override the default policy obtained from the
          message instance.  This can be used to control some of the
          formatting produced by the method, since the specified
          'policy' will be passed to the ‘Generator’.

          もし、文字列への変換を完全に行うためにデフォルト値を埋める必要
          がある場合、メッセージのフラット化は *note Message: 25d. の変
          更を引き起こす可能性があります (例えば、MIME の境界が生成され
          る、変更される等)。

          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 mangling of lines that begin with
          ‘From’ that is required by the Unix mbox format.  For more
          flexibility, instantiate a *note Generator: 119e. instance and
          use its *note flatten(): 344f. method directly.  For example:

               from io import StringIO
               from email.generator import Generator
               fp = StringIO()
               g = Generator(fp, mangle_from_=True, maxheaderlen=60)
               g.flatten(msg)
               text = fp.getvalue()

          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 *note as_bytes(): f04. and *note BytesGenerator: 119f.)

          バージョン 3.4 で変更: 'policy' キーワード引数が追加されました
          。

      -- メソッド: __str__ ()

          Equivalent to *note as_string(): f03.  Allows ‘str(msg)’ to
          produce a string containing the formatted message.

      -- メソッド: as_bytes (unixfrom=False, policy=None)

          Return the entire message flattened as a bytes object.  When
          optional 'unixfrom' is true, the envelope header is included
          in the returned string.  'unixfrom' defaults to ‘False’.  The
          'policy' argument may be used to override the default policy
          obtained from the message instance.  This can be used to
          control some of the formatting produced by the method, since
          the specified 'policy' will be passed to the ‘BytesGenerator’.

          もし、文字列への変換を完全に行うためにデフォルト値を埋める必要
          がある場合、メッセージのフラット化は *note Message: 25d. の変
          更を引き起こす可能性があります (例えば、MIME の境界が生成され
          る、変更される等)。

          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 mangling of lines that begin with
          ‘From’ that is required by the Unix mbox format.  For more
          flexibility, instantiate a *note BytesGenerator: 119f.
          instance and use its *note flatten(): 344b. method directly.
          For example:

               from io import BytesIO
               from email.generator import BytesGenerator
               fp = BytesIO()
               g = BytesGenerator(fp, mangle_from_=True, maxheaderlen=60)
               g.flatten(msg)
               text = fp.getvalue()

          Added in version 3.4.

      -- メソッド: __bytes__ ()

          Equivalent to *note as_bytes(): f04.  Allows ‘bytes(msg)’ to
          produce a bytes object containing the formatted message.

          Added in version 3.4.

      -- メソッド: is_multipart ()

          Return ‘True’ if the message's payload is a list of sub-*note
          Message: 25d. objects, otherwise return ‘False’.  When *note
          is_multipart(): 3425. returns ‘False’, the payload should be a
          string object (which might be a CTE encoded binary payload).
          (Note that *note is_multipart(): 3425. returning ‘True’ does
          not necessarily mean that "msg.get_content_maintype() ==
          'multipart'" will return the ‘True’.  For example,
          ‘is_multipart’ will return ‘True’ when the *note Message: 25d.
          is of type ‘message/rfc822’.)

      -- メソッド: set_unixfrom (unixfrom)

          メッセージのエンベロープヘッダを 'unixfrom' に設定します。これ
          は文字列でなければなりません。

      -- メソッド: get_unixfrom ()

          メッセージのエンベロープヘッダを返します。エンベロープヘッダが
          設定されていない場合は ‘None’ が返されます。

      -- メソッド: attach (payload)

          与えられた 'payload' を現在のペイロードに追加します。この時点
          でのペイロードは ‘None’ か、あるいは *note Message: 25d. オブ
          ジェクトのリストである必要があります。このメソッドの実行後、ペ
          イロードは必ず *note Message: 25d. オブジェクトのリストになり
          ます。ペイロードにスカラーオブジェクト (文字列など) を格納した
          い場合は、かわりに *note set_payload(): 34b2. を使ってください
          。

          This is a legacy method.  On the ‘EmailMessage’ class its
          functionality is replaced by *note set_content(): 1813. and
          the related ‘make’ and ‘add’ methods.

      -- メソッド: get_payload (i=None, decode=False)

          現在のペイロードへの参照を返します。これは *note
          is_multipart(): 3425. が ‘True’ の場合 *note Message: 25d. オ
          ブジェクトのリストになり、 *note is_multipart(): 3425. が
          ‘False’ の場合は文字列になります。ペイロードがリストの場合、リ
          ストを変更することはそのメッセージのペイロードを変更することに
          なります。

          オプション引数の 'i' がある場合、 *note is_multipart(): 3425.
          が ‘True’ ならば *note get_payload(): 119d. はペイロード中で 0
          から数えて 'i' 番目の要素を返します。 'i' が 0 より小さい場合
          、あるいはペイロードの個数以上の場合は *note IndexError: 14de.
          が発生します。ペイロードが文字列 (つまり *note is_multipart():
          3425. が ‘False’) にもかかわらず 'i' が与えられたときは *note
          TypeError: 502. が発生します。

          Optional 'decode' is a flag indicating whether the payload
          should be decoded or not, according to the
          ‘Content-Transfer-Encoding’ header.  When ‘True’ and the
          message is not a multipart, the payload will be decoded if
          this header's value is ‘quoted-printable’ or ‘base64’.  If
          some other encoding is used, or ‘Content-Transfer-Encoding’
          header is missing, the payload is returned as-is (undecoded).
          In all cases the returned value is binary data.  If the
          message is a multipart and the 'decode' flag is ‘True’, then
          ‘None’ is returned.  If the payload is base64 and it was not
          perfectly formed (missing padding, characters outside the
          base64 alphabet), then an appropriate defect will be added to
          the message's defect property (‘InvalidBase64PaddingDefect’ or
          ‘InvalidBase64CharactersDefect’, respectively).

          When 'decode' is ‘False’ (the default) the body is returned as
          a string without decoding the ‘Content-Transfer-Encoding’.
          However, for a ‘Content-Transfer-Encoding’ of 8bit, an attempt
          is made to decode the original bytes using the ‘charset’
          specified by the ‘Content-Type’ header, using the ‘replace’
          error handler.  If no ‘charset’ is specified, or if the
          ‘charset’ given is not recognized by the email package, the
          body is decoded using the default ASCII charset.

          This is a legacy method.  On the ‘EmailMessage’ class its
          functionality is replaced by *note get_content(): 342b. and
          *note iter_parts(): 342a.

      -- メソッド: set_payload (payload, charset=None)

          メッセージオブジェクト全体のペイロードを 'payload' に設定しま
          す。クライアントはペイロードを変更してはいけません。オプション
          の 'charset' はメッセージのデフォルト文字セットを設定します。
          詳しくは *note set_charset(): 34b3. を参照してください。

          This is a legacy method.  On the ‘EmailMessage’ class its
          functionality is replaced by *note set_content(): 1813.

      -- メソッド: set_charset (charset)

          ペイロードの文字セットを 'charset' に変更します。これは *note
          Charset: dc7. インスタンス (*note email.charset: 33. 参照)、文
          字セット名を表す文字列、あるいは ‘None’ のいずれかです。文字列
          を指定した場合は *note Charset: dc7. インスタンスに変換されま
          す。 'charset' が ‘None’ の場合、 ‘charset’ 引数は
          ‘Content-Type’ ヘッダから除去されます (それ以外にメッセージは
          変更されません)。これら以外のものを文字セットとして指定した場
          合、 *note TypeError: 502. を送出します。

          ‘MIME-Version’ ヘッダが存在しなければ、追加されます。
          ‘Content-Type’ ヘッダが存在しなければ、 ‘text/plain’ を値とし
          て追加されます。 ‘Content-Type’ が存在していてもいなくても、
          ‘charset’ パラメタは 'charset.output_charset' に設定されます。
          'charset.input_charset' と 'charset.output_charset' が異なるな
          ら、ペイロードは 'output_charset' に再エンコードされます。
          ‘Content-Transfer-Encoding’ ヘッダが存在しなければ、ペイロード
          は、必要なら指定された *note Charset: dc7. を使って transfer エ
          ンコードされ、適切な値のヘッダが追加されます。
          ‘Content-Transfer-Encoding’ ヘッダがすでに存在すれば、ペイロー
          ドはすでにその ‘Content-Transfer-Encoding’ によって正しくエン
          コードされたものと見なされ、変形されません。

          This is a legacy method.  On the ‘EmailMessage’ class its
          functionality is replaced by the 'charset' parameter of the
          ‘email.emailmessage.EmailMessage.set_content()’ method.

      -- メソッド: get_charset ()

          そのメッセージ中のペイロードの *note Charset: dc7. インスタン
          スを返します。

          This is a legacy method.  On the ‘EmailMessage’ class it
          always returns ‘None’.

     以下のメソッドは、メッセージの RFC 2822(2) ヘッダにアクセスするため
     のマップ (辞書) 形式のインタフェイスを実装したものです。これらのメ
     ソッドと、通常のマップ (辞書) 型はまったく同じ意味をもつわけではな
     いことに注意してください。たとえば辞書型では、同じキーが複数あるこ
     とは許されていませんが、ここでは同じメッセージヘッダが複数ある場合
     があります。また、辞書型では *note keys(): 34b5. で返されるキーの順
     序は保証されていませんが、 *note Message: 25d. オブジェクト内のヘッ
     ダはつねに元のメッセージ中に現れた順序、あるいはそのあとに追加され
     た順序で返されます。削除され、その後ふたたび追加されたヘッダはリス
     トの一番最後に現れます。

     こういった意味のちがいは意図的なもので、最大の利便性をもつようにつ
     くられています。

     注意: どんな場合も、メッセージ中のエンベロープヘッダはこのマップ形
     式のインタフェイスには含まれません。

     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 *note Header:
     1814. objects with a charset of ‘unknown-8bit’.

      -- メソッド: __len__ ()

          複製されたものもふくめてヘッダ数の合計を返します。

      -- メソッド: __contains__ (name)

          メッセージオブジェクトが 'name' という名前のフィールドを持って
          いれば ‘True’ を返します。この検査では名前の大文字小文字は区別
          されません。'name' は最後にコロンをふくんでいてはいけません。
          このメソッドは以下のように ‘in’ 演算子で使われます:

               if 'message-id' in myMessage:
                  print('Message-ID:', myMessage['message-id'])

      -- メソッド: __getitem__ (name)

          指定された名前のヘッダフィールドの値を返します。 'name' は最後
          にコロンをふくんでいてはいけません。そのヘッダがない場合は
          ‘None’ が返され、 *note KeyError: 31d. 例外は発生しません。

          注意: 指定された名前のフィールドがメッセージのヘッダに2回以上
          現れている場合、どちらの値が返されるかは未定義です。ヘッダに存
          在するフィールドの値をすべて取り出したい場合は *note
          get_all(): 34b8. メソッドを使ってください。

      -- メソッド: __setitem__ (name, val)

          メッセージヘッダに 'name' という名前の 'val' という値をもつフ
          ィールドをあらたに追加します。このフィールドは現在メッセージに
          存在するフィールドのいちばん後に追加されます。

          注意: このメソッドでは、すでに同一の名前で存在するフィールドは
          上書き 'されません'。もしメッセージが名前 'name' をもつフィー
          ルドをひとつしか持たないようにしたければ、最初にそれを除去して
          ください。たとえば:

               del msg['subject']
               msg['subject'] = 'Python roolz!'

      -- メソッド: __delitem__ (name)

          メッセージのヘッダから、'name' という名前をもつフィールドをす
          べて除去します。たとえこの名前をもつヘッダが存在していなくても
          例外は発生しません。

      -- メソッド: keys ()

          メッセージ中にあるすべてのヘッダのフィールド名のリストを返しま
          す。

      -- メソッド: values ()

          メッセージ中にあるすべてのフィールドの値のリストを返します。

      -- メソッド: items ()

          メッセージ中にあるすべてのヘッダのフィールド名とその値を 2-タ
          プルのリストとして返します。

      -- メソッド: get (name, failobj=None)

          Return the value of the named header field.  This is identical
          to *note __getitem__(): 264. except that optional 'failobj' is
          returned if the named header is missing (defaults to ‘None’).

     さらに、役に立つメソッドをいくつか紹介します:

      -- メソッド: get_all (name, failobj=None)

          'name' の名前をもつフィールドのすべての値からなるリストを返し
          ます。該当する名前のヘッダがメッセージ中に含まれていない場合は
          'failobj' (デフォルトでは ‘None’) が返されます。

      -- メソッド: add_header (_name, _value, **_params)

          拡張ヘッダ設定。このメソッドは *note __setitem__(): 34b9. と似
          ていますが、追加のヘッダ・パラメータをキーワード引数で指定でき
          るところが違っています。 '_name' に追加するヘッダフィールドを
          、 '_value' にそのヘッダの '最初の' 値を渡します。

          キーワード引数辞書 '_params' の各項目ごとに、そのキーがパラメ
          ータ名として扱われ、キー名にふくまれるアンダースコアはハイフン
          に置換されます (アンダースコアは、Python 識別子としてハイフン
          を使えないための代替です)。ふつう、パラメータの値が ‘None’ 以
          外のときは、 ‘key="value"’ の形で追加されます。パラメータの値
          が ‘None’ のときはキーのみが追加されます。値が非 ASCII 文字を
          含むなら、それは ‘(CHARSET, LANGUAGE, VALUE)’ の形式の 3 タプ
          ルにすることが出来ます。ここで ‘CHARSET’ はその値をエンコード
          するのに使われる文字セットを指示する文字列で、 ‘LANGUAGE’ は通
          常 ‘None’ か空文字列にでき (これら以外で指定出来るものについて
          は RFC 2231(3) を参照してください)、 ‘VALUE’ は非 ASCII コード
          ポイントを含む文字列値です。この 3 タプルではなく非 ASCII 文字
          を含む値が渡された場合は、 ‘CHARSET’ に ‘utf-8’ 、 ‘LANGUAGE’
          に ‘None’ を使って RFC 2231(4) 形式に自動的にエンコードされま
          す。

          以下はこの使用例です:

               msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')

          こうするとヘッダには以下のように追加されます

               Content-Disposition: attachment; filename="bud.gif"

          非 ASCII 文字を使った例:

               msg.add_header('Content-Disposition', 'attachment',
                              filename=('iso-8859-1', '', 'Fußballer.ppt'))

          は、以下のようになります

               Content-Disposition: attachment; filename*="iso-8859-1''Fu%DFballer.ppt"

      -- メソッド: replace_header (_name, _value)

          ヘッダの置換。 '_name' と一致するヘッダで最初に見つかったもの
          を置き換えます。このときヘッダの順序とフィールド名の大文字小文
          字は保存されます。一致するヘッダがない場合、 *note KeyError:
          31d. が発生します。

      -- メソッド: get_content_type ()

          そのメッセージの content-type を返します。返された文字列は強制
          的に小文字で ‘maintype/subtype’ の形式に変換されます。メッセー
          ジ中に ‘Content-Type’ ヘッダがない場合、デフォルトの
          content-type は *note get_default_type(): 34c1. が返す値によっ
          て与えられます。 RFC 2045(5) によればメッセージはつねにデフォ
          ルトの content-type をもっているので、 *note
          get_content_type(): 34c0. はつねになんらかの値を返すはずです。

          RFC 2045(6) はメッセージのデフォルト content-type を、それが
          ‘multipart/digest’ コンテナに現れているとき以外は ‘text/plain’
          に規定しています。あるメッセージが ‘multipart/digest’ コンテナ
          中にある場合、その content-type は ‘message/rfc822’ になります
          。もし ‘Content-Type’ ヘッダが適切でない content-type 書式だっ
          た場合、 RFC 2045(7) はそれのデフォルトを ‘text/plain’ として
          扱うよう定めています。

      -- メソッド: get_content_maintype ()

          そのメッセージの主 content-type を返します。これは *note
          get_content_type(): 34c0. によって返される文字列の ‘maintype’
          部分です。

      -- メソッド: get_content_subtype ()

          そのメッセージの副 content-type (sub content-type、subtype) を
          返します。これは *note get_content_type(): 34c0. によって返さ
          れる文字列の ‘subtype’ 部分です。

      -- メソッド: get_default_type ()

          デフォルトの content-type を返します。ほどんどのメッセージでは
          デフォルトの content-type は ‘text/plain’ ですが、メッセージが
          ‘multipart/digest’ コンテナに含まれているときだけ例外的に
          ‘message/rfc822’ になります。

      -- メソッド: set_default_type (ctype)

          デフォルトの content-type を設定します。 'ctype' は
          ‘text/plain’ あるいは ‘message/rfc822’ である必要がありますが
          、強制ではありません。デフォルトの content-type はヘッダの
          ‘Content-Type’ には格納されません。

      -- メソッド: get_params (failobj=None, header='content-type',
               unquote=True)

          メッセージの ‘Content-Type’ パラメータをリストとして返します。
          返されるリストはキー/値の組からなる2要素タプルが連なったもので
          あり、これらは ‘'='’ 記号で分離されています。 ‘'='’ の左側はキ
          ーになり、右側は値になります。パラメータ中に ‘'='’ がなかった
          場合、値の部分は空文字列になり、そうでなければその値は *note
          get_param(): 34c6. で説明されている形式になります。また、オプ
          ション引数 'unquote' が ‘True’ (デフォルト) である場合、この値
          は unquote されます。

          オプション引数 'failobj' は、 ‘Content-Type’ ヘッダが存在しな
          かった場合に返すオブジェクトです。オプション引数 'header' には
          ‘Content-Type’ のかわりに検索すべきヘッダを指定します。

          This is a legacy method.  On the ‘EmailMessage’ class its
          functionality is replaced by the 'params' property of the
          individual header objects returned by the header access
          methods.

      -- メソッド: get_param (param, failobj=None,
               header='content-type', unquote=True)

          メッセージの ‘Content-Type’ ヘッダ中のパラメータ 'param' を文
          字列として返します。そのメッセージ中に ‘Content-Type’ ヘッダが
          存在しなかった場合、 'failobj' (デフォルトは ‘None’) が返され
          ます。

          オプション引数 'header' が与えられた場合、 ‘Content-Type’ のか
          わりにそのヘッダが使用されます。

          パラメータのキー比較は常に大文字小文字を区別しません。返り値は
          文字列か 3 要素のタプルで、タプルになるのはパラメータが RFC
          2231(8) エンコードされている場合です。3 要素タプルの場合、各要
          素の値は ‘(CHARSET, LANGUAGE, VALUE)’ の形式になっています。
          ‘CHARSET’ と ‘LAGUAGE’ は ‘None’ になることがあり、その場合
          ‘VALUE’ は ‘us-ascii’ 文字セットでエンコードされているとみなさ
          なければならないので注意してください。普段は ‘LANGUAGE’ を無視
          できます。

          この関数を使うアプリケーションが、パラメータが RFC 2231(9) 形
          式でエンコードされているかどうかを気にしないのであれば、 *note
          email.utils.collapse_rfc2231_value(): 34c7. に *note
          get_param(): 34c6. の返り値を渡して呼び出すことで、このパラメ
          ータをひとつにまとめることができます。この値がタプルならばこの
          関数は適切にデコードされた Unicode 文字列を返し、そうでない場
          合は unquote された元の文字列を返します。たとえば:

               rawparam = msg.get_param('foo')
               param = email.utils.collapse_rfc2231_value(rawparam)

          いずれの場合もパラメータの値は (文字列であれ3要素タプルの
          ‘VALUE’ 項目であれ) つねに unquote されます。ただし、'unquote'
          が ‘False’ に指定されている場合は unquote されません。

          This is a legacy method.  On the ‘EmailMessage’ class its
          functionality is replaced by the 'params' property of the
          individual header objects returned by the header access
          methods.

      -- メソッド: set_param (param, value, header='Content-Type',
               requote=True, charset=None, language='', replace=False)

          ‘Content-Type’ ヘッダ中のパラメータを設定します。指定されたパ
          ラメータがヘッダ中にすでに存在する場合、その値は 'value' に置
          き換えられます。 ‘Content-Type’ ヘッダがまだこのメッセージ中に
          存在していない場合、 RFC 2045(10) にしたがいこの値には
          ‘text/plain’ が設定され、新しいパラメータ値が末尾に追加されま
          す。

          オプション引数 'header' が与えられた場合、 ‘Content-Type’ のか
          わりにそのヘッダが使用されます。オプション引数 'requote' が
          ‘False’ でない限り、この値は quote されます (デフォルトは
          ‘True’)。

          オプション引数 'charset' が与えられると、そのパラメータは RFC
          2231(11) に従ってエンコードされます。オプション引数 'language'
          は RFC 2231 の言語を指定しますが、デフォルトではこれは空文字列
          となります。 'charset' と 'language' はどちらも文字列である必
          要があります。

          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.

          バージョン 3.4 で変更: ‘replace’ キーワードが追加されました。

      -- メソッド: del_param (param, header='content-type',
               requote=True)

          指定されたパラメータを ‘Content-Type’ ヘッダ中から完全にとりの
          ぞきます。ヘッダはそのパラメータと値がない状態に書き換えられま
          す。 'requote' が ‘False’ でない限り (デフォルトでは ‘True’ で
          す)、すべての値は必要に応じて quote されます。オプション変数
          'header' が与えられた場合、 ‘Content-Type’ のかわりにそのヘッ
          ダが使用されます。

      -- メソッド: set_type (type, header='Content-Type', requote=True)

          ‘Content-Type’ ヘッダの maintype と subtype を設定します。
          'type' は ‘maintype/subtype’ という形の文字列でなければなりま
          せん。それ以外の場合は *note ValueError: 1e3. が発生します。

          このメソッドは ‘Content-Type’ ヘッダを置き換えますが、すべての
          パラメータはそのままにします。 'requote' が ‘False’ の場合、こ
          れはすでに存在するヘッダを quote せず放置しますが、そうでない
          場合は自動的に quote します (デフォルト動作)。

          オプション変数 'header' が与えられた場合、 ‘Content-Type’ のか
          わりにそのヘッダが使用されます。 ‘Content-Type’ ヘッダが設定さ
          れる場合には、 ‘MIME-Version’ ヘッダも同時に付加されます。

          This is a legacy method.  On the ‘EmailMessage’ class its
          functionality is replaced by the ‘make_’ and ‘add_’ methods.

      -- メソッド: get_filename (failobj=None)

          そのメッセージ中の ‘Content-Disposition’ ヘッダにある、
          ‘filename’ パラメータの値を返します。目的のヘッダに ‘filename’
          パラメータがない場合には ‘Content-Type’ ヘッダにある ‘name’ パ
          ラメータを探します。それも無い場合またはヘッダが無い場合には
          'failobj' が返されます。返される文字列はつねに *note
          email.utils.unquote(): 341e. によって unquote されます。

      -- メソッド: get_boundary (failobj=None)

          そのメッセージ中の ‘Content-Type’ ヘッダにある、 ‘boundary’ パ
          ラメータの値を返します。目的のヘッダが欠けていたり、
          ‘boundary’ パラメータがない場合には 'failobj' が返されます。返
          される文字列はつねに *note email.utils.unquote(): 341e. によっ
          て unquote されます。

      -- メソッド: set_boundary (boundary)

          メッセージ中の ‘Content-Type’ ヘッダにある、 ‘boundary’ パラメ
          ータに値を設定します。 *note set_boundary(): 34cc. は必要に応
          じて 'boundary' を quote します。そのメッセージが
          ‘Content-Type’ ヘッダを含んでいない場合、 *note
          HeaderParseError: 3421. が発生します。

          注意: このメソッドを使うのは、古い ‘Content-Type’ ヘッダを削除
          して新しい boundary をもったヘッダを *note add_header(): 34be.
          で足すのとは少し違います。 *note set_boundary(): 34cc. は一連
          のヘッダ中での ‘Content-Type’ ヘッダの位置を保つからです。しか
          し、これは元の ‘Content-Type’ ヘッダ中に存在していた連続する行
          の順番までは '保ちません' 。

      -- メソッド: get_content_charset (failobj=None)

          そのメッセージ中の ‘Content-Type’ ヘッダにある、 ‘charset’ パ
          ラメータの値を返します。値はすべて小文字に変換されます。メッセ
          ージ中に ‘Content-Type’ がなかったり、このヘッダ中に
          ‘charaset’ パラメータがない場合には 'failobj' が返されます。

          注意: これは *note get_charset(): 34b4. メソッドとは異なります
          。こちらのほうは文字列のかわりに、そのメッセージボディのデフォ
          ルトエンコーディングの *note Charset: dc7. インスタンスを返し
          ます。

      -- メソッド: get_charsets (failobj=None)

          メッセージ中に含まれる文字セットの名前をすべてリストにして返し
          ます。そのメッセージが ‘multipart’ である場合、返されるリスト
          の各要素がそれぞれの subpart のペイロードに対応します。それ以
          外の場合、これは長さ 1 のリストを返します。

          リスト中の各要素は文字列であり、これは対応する subpart 中のそ
          れぞれの ‘Content-Type’ ヘッダにある ‘charset’ の値です。しか
          し、その subpart が ‘Content-Type’ をもってないか、 ‘charset’
          がないか、あるいは MIME maintype が ‘text’ でないいずれかの場
          合には、リストの要素として 'failobj' が返されます。

      -- メソッド: get_content_disposition ()

          Return the lowercased value (without parameters) of the
          message's ‘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(12).

          Added in version 3.5.

      -- メソッド: walk ()

          *note walk(): 34cf. メソッドは多目的のジェネレータで、これはあ
          るメッセージオブジェクトツリー中のすべての part および subpart
          をわたり歩くのに使えます。順序は深さ優先です。おそらく典型的な
          用法は、 *note walk(): 34cf. を ‘for’ ループ中でのイテレータと
          して使うことでしょう。ループを一回まわるごとに、次の subpart が
          返されるのです。

          以下の例は、 multipart メッセージのすべての part において、そ
          の MIME タイプを表示していくものです。 :

               >>> for part in msg.walk():
               ...     print(part.get_content_type())
               multipart/report
               text/plain
               message/delivery-status
               text/plain
               text/plain
               message/rfc822
               text/plain

          ‘walk’ iterates over the subparts of any part where *note
          is_multipart(): 3425. 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:

               >>> for part in msg.walk():
               ...     print(part.get_content_maintype() == 'multipart',
               ...           part.is_multipart())
               True True
               False False
               False True
               False False
               False False
               False True
               False False
               >>> _structure(msg)
               multipart/report
                   text/plain
                   message/delivery-status
                       text/plain
                       text/plain
                   message/rfc822
                       text/plain

          Here the ‘message’ parts are not ‘multiparts’, but they do
          contain subparts.  ‘is_multipart()’ returns ‘True’ and ‘walk’
          descends into the subparts.

     *note Message: 25d. オブジェクトはオプションとして 2つのインスタン
     ス属性をとることができます。これはある MIME メッセージからプレーン
     テキストを生成するのに使うことができます。

      -- の属性: preamble

          MIME ドキュメントの形式では、ヘッダ直後にくる空行と最初の
          multipart 境界をあらわす文字列のあいだにいくらかのテキスト (訳
          注: preamble, 序文) を埋めこむことを許しています。このテキスト
          は標準的な MIME の範疇からはみ出しているので、MIME 形式を認識
          するメールソフトからこれらは通常まったく見えません。しかしメッ
          セージのテキストを生で見る場合、あるいはメッセージを MIME 対応
          していないメールソフトで見る場合、このテキストは目に見えること
          になります。

          'preamble' 属性は MIME ドキュメントに加えるこの最初の MIME 範
          囲外テキストを含んでいます。 *note Parser: 116f. があるテキス
          トをヘッダ以降に発見したが、それはまだ最初の MIME 境界文字列が
          現れる前だった場合、パーザはそのテキストをメッセージの
          'preamble' 属性に格納します。 *note Generator: 119e. がある
          MIME メッセージからプレーンテキスト形式を生成するときメッセー
          ジが 'preamble' 属性を持つことが発見されれば、これはそのテキス
          トをヘッダと最初の MIME 境界の間に挿入します。詳細は *note
          email.parser: 45. および *note email.generator: 37. を参照して
          ください。

          注意: そのメッセージに preamble がない場合、'preamble' 属性に
          は ‘None’ が格納されます。

      -- の属性: epilogue

          'epilogue' 属性はメッセージの最後の MIME 境界文字列からメッセ
          ージ末尾までのテキストを含むもので、それ以外は 'preamble' 属性
          と同じです。

          *note Generator: 119e. でファイル終端に改行を出力するため、
          epilogue に空文字列を設定する必要はなくなりました。

      -- の属性: defects

          'defects' 属性はメッセージを解析する途中で検出されたすべての問
          題点 (defect、障害) のリストを保持しています。解析中に発見され
          うる障害についてのより詳細な説明は *note email.errors: 36. を
          参照してください。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5322.html

   (2) https://datatracker.ietf.org/doc/html/rfc2822.html

   (3) https://datatracker.ietf.org/doc/html/rfc2231.html

   (4) https://datatracker.ietf.org/doc/html/rfc2231.html

   (5) https://datatracker.ietf.org/doc/html/rfc2045.html

   (6) https://datatracker.ietf.org/doc/html/rfc2045.html

   (7) https://datatracker.ietf.org/doc/html/rfc2045.html

   (8) https://datatracker.ietf.org/doc/html/rfc2231.html

   (9) https://datatracker.ietf.org/doc/html/rfc2231.html

   (10) https://datatracker.ietf.org/doc/html/rfc2045.html

   (11) https://datatracker.ietf.org/doc/html/rfc2231.html

   (12) https://datatracker.ietf.org/doc/html/rfc2183.html


File: python.info,  Node: email mime Creating email and MIME objects from scratch,  Next: email header 国際化されたヘッダー,  Prev: email message Message compat32 API を使用した電子メールメッセージの表現,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.14 ‘email.mime’: Creating email and MIME objects from scratch
....................................................................

'ソースコード:' Lib/email/mime/(1)

__________________________________________________________________

This module is part of the legacy (‘Compat32’) email API. Its
functionality is partially replaced by the *note contentmanager: 34. in
the new API, but in certain applications these classes may still be
useful, even in non-legacy code.

ふつう、メッセージオブジェクト構造はファイルまたは何がしかのテキストをパ
ーザに通すことで得られます。パーザは与えられたテキストを解析し、基底とな
る root のメッセージオブジェクトを返します。しかし、完全なメッセージオブ
ジェクト構造を何もないところから作成することもまた可能です。個別の *note
Message: 25d. を手で作成することさえできます。実際には、すでに存在するメ
ッセージオブジェクト構造をとってきて、そこに新たな *note Message: 25d. オ
ブジェクトを追加したり、あるものを別のところへ移動させたりできます。これ
は MIME メッセージを切ったりおろしたりするために非常に便利なインターフェ
イスを提供します。

新しいメッセージオブジェクト構造は *note Message: 25d. インスタンスを作
成することにより作れます。ここに添付ファイルやその他適切なものをすべて手
で加えてやればよいのです。MIME メッセージの場合、 *note email: 32. パッ
ケージはこれらを簡単におこなえるようにするためにいくつかの便利なサブクラ
スを提供しています。

以下がそのサブクラスです:

 -- クラス: email.mime.base.MIMEBase (_maintype, _subtype, *,
          policy=compat32, **_params)

     モジュール: *note email.mime.base: 3f.

     これはすべての *note Message: 25d. の MIME 用サブクラスの基底となる
     クラスです。とくに *note MIMEBase: 34d5. のインスタンスを直接作成す
     ることは (可能ではありますが) ふつうはしないでしょう。 *note
     MIMEBase: 34d5. は単により特化された MIME 用サブクラスのための便宜
     的な基底クラスとして提供されています。

     '_maintype' は ‘Content-Type’ の主形式 (maintype) であり (‘text’ や
     ‘image’ など)、 '_subtype' は ‘Content-Type’ の副形式 (subtype) で
     す (‘plain’ や ‘gif’ など)。 '_params' は各パラメータのキーと値を格
     納した辞書であり、これは直接 *note Message.add_header: 34be. に渡さ
     れます。

     If 'policy' is specified, (defaults to the *note compat32: 1084.
     policy) it will be passed to *note Message: 25d.

     *note MIMEBase: 34d5. クラスはつねに ('_maintype' 、 '_subtype' 、
     および '_params' にもとづいた) ‘Content-Type’ ヘッダと、
     ‘MIME-Version’ ヘッダ (必ず ‘1.0’ に設定される) を追加します。

     バージョン 3.6 で変更: キーワード専用引数 'policy' が追加されました
     。

 -- クラス: email.mime.nonmultipart.MIMENonMultipart

     モジュール: *note email.mime.nonmultipart: 43.

     *note MIMEBase: 34d5. のサブクラスで、これは ‘multipart’ 形式でない
     MIME メッセージのための中間的な基底クラスです。このクラスのおもな目
     的は、通常 ‘multipart’ 形式のメッセージに対してのみ意味をなす *note
     attach(): 3432. メソッドの使用をふせぐことです。もし *note
     attach(): 3432. メソッドが呼ばれた場合、これは *note
     MultipartConversionError: 3475. 例外を発生します。

 -- クラス: email.mime.multipart.MIMEMultipart (_subtype='mixed',
          boundary=None, _subparts=None, *, policy=compat32, **_params)

     モジュール: *note email.mime.multipart: 42.

     *note MIMEBase: 34d5. のサブクラスで、これは ‘multipart’ 形式の
     MIME メッセージのための中間的な基底クラスです。オプション引数
     '_subtype' はデフォルトでは ‘mixed’ になっていますが、そのメッセー
     ジの副形式 (subtype) を指定するのに使うことができます。メッセージオ
     ブジェクトには ‘multipart/_subtype’ という値をもつ ‘Content-Type’ ヘ
     ッダとともに、 ‘MIME-Version’ ヘッダが追加されるでしょう。

     オプション引数 'boundary' は multipart の境界文字列です。これが
     ‘None’ の場合 (デフォルト)、境界は必要に応じて計算されます（例えば
     メッセージがシリアライズされるときなど）。

     '_subparts' はそのペイロードの subpart の初期値からなるシーケンスで
     す。このシーケンスはリストに変換できるようになっている必要がありま
     す。新しい subpart はつねに *note Message.attach: 3432. メソッドを
     使ってそのメッセージに追加できるようになっています。

     Optional 'policy' argument defaults to *note compat32: 1084.

     ‘Content-Type’ ヘッダに対する追加のパラメータはキーワード引数
     '_params' を介して取得あるいは設定されます。これはキーワード辞書に
     なっています。

     バージョン 3.6 で変更: キーワード専用引数 'policy' が追加されました
     。

 -- クラス: email.mime.application.MIMEApplication (_data,
          _subtype='octet-stream',
          _encoder=email.encoders.encode_base64, *, policy=compat32,
          **_params)

     モジュール: *note email.mime.application: 3d.

     A subclass of *note MIMENonMultipart: 3476, the *note
     MIMEApplication: 34d7. class is used to represent MIME message
     objects of major type ‘application’.  '_data' contains the bytes
     for the raw application data.  Optional '_subtype' specifies the
     MIME subtype and defaults to ‘octet-stream’.

     オプション引数の '_encoder' は呼び出し可能なオブジェクト (関数など)
     で、データの転送に使う実際のエンコード処理を行います。この呼び出し
     可能なオブジェクトは引数を 1 つ取り、それは *note MIMEApplication:
     34d7. のインスタンスです。ペイロードをエンコードされた形式に変更す
     るために *note get_payload(): 119d. と *note set_payload(): 34b2. を
     使い、必要に応じて ‘Content-Transfer-Encoding’ やその他のヘッダをメ
     ッセージオブジェクトに追加するべきです。デフォルトのエンコードは
     base64 です。組み込みのエンコーダの一覧は *note email.encoders: 35.
     モジュールを見てください。

     Optional 'policy' argument defaults to *note compat32: 1084.

     '_params' は基底クラスのコンストラクタにそのまま渡されます。

     バージョン 3.6 で変更: キーワード専用引数 'policy' が追加されました
     。

 -- クラス: email.mime.audio.MIMEAudio (_audiodata, _subtype=None,
          _encoder=email.encoders.encode_base64, *, policy=compat32,
          **_params)

     モジュール: *note email.mime.audio: 3e.

     A subclass of *note MIMENonMultipart: 3476, the *note MIMEAudio:
     34d8. class is used to create MIME message objects of major type
     ‘audio’.  '_audiodata' contains the bytes for the raw audio data.
     If this data can be decoded as au, wav, aiff, or aifc, then the
     subtype will be automatically included in the ‘Content-Type’
     header.  Otherwise you can explicitly specify the audio subtype via
     the '_subtype' argument.  If the minor type could not be guessed
     and '_subtype' was not given, then *note TypeError: 502. is raised.

     オプション引数の '_encoder' は呼び出し可能なオブジェクト (関数など)
     で、オーディオデータの転送に使う実際のエンコード処理を行います。こ
     の呼び出し可能なオブジェクトは引数を 1 つ取り、それは *note
     MIMEAudio: 34d8. のインスタンスです。ペイロードをエンコードされた形
     式に変更するために *note get_payload(): 119d. と *note
     set_payload(): 34b2. を使い、必要に応じて
     ‘Content-Transfer-Encoding’ やその他のヘッダをメッセージオブジェク
     トに追加するべきです。デフォルトのエンコードは base64 です。組み込
     みのエンコーダの一覧は *note email.encoders: 35. モジュールを見てく
     ださい。

     Optional 'policy' argument defaults to *note compat32: 1084.

     '_params' は基底クラスのコンストラクタにそのまま渡されます。

     バージョン 3.6 で変更: キーワード専用引数 'policy' が追加されました
     。

 -- クラス: email.mime.image.MIMEImage (_imagedata, _subtype=None,
          _encoder=email.encoders.encode_base64, *, policy=compat32,
          **_params)

     モジュール: *note email.mime.image: 40.

     A subclass of *note MIMENonMultipart: 3476, the *note MIMEImage:
     3477. class is used to create MIME message objects of major type
     ‘image’.  '_imagedata' contains the bytes for the raw image data.
     If this data type can be detected (jpeg, png, gif, tiff, rgb, pbm,
     pgm, ppm, rast, xbm, bmp, webp, and exr attempted), then the
     subtype will be automatically included in the ‘Content-Type’
     header.  Otherwise you can explicitly specify the image subtype via
     the '_subtype' argument.  If the minor type could not be guessed
     and '_subtype' was not given, then *note TypeError: 502. is raised.

     オプション引数の '_encoder' は呼び出し可能なオブジェクト (関数など)
     で、画像データの転送に使う実際のエンコード処理を行います。この呼び
     出し可能なオブジェクトは引数を 1 つ取り、それは *note MIMEImage:
     3477. のインスタンスです。ペイロードをエンコードされた形式に変更す
     るために *note get_payload(): 119d. と *note set_payload(): 34b2. を
     使い、必要に応じて ‘Content-Transfer-Encoding’ やその他のヘッダをメ
     ッセージオブジェクトに追加するべきです。デフォルトのエンコードは
     base64 です。組み込みのエンコーダの一覧は *note email.encoders: 35.
     モジュールを見てください。

     Optional 'policy' argument defaults to *note compat32: 1084.

     '_params' は *note MIMEBase: 34d5. コンストラクタに直接渡されます。

     バージョン 3.6 で変更: キーワード専用引数 'policy' が追加されました
     。

 -- クラス: email.mime.message.MIMEMessage (_msg, _subtype='rfc822', *,
          policy=compat32)

     モジュール: *note email.mime.message: 41.

     *note MIMEMessage: 34d9. クラスは *note MIMENonMultipart: 3476. の
     サブクラスで、主形式 (maintype) が ‘message’ の MIME オブジェクトを
     作成するのに使われます。ペイロードとして使われるメッセージは '_msg'
     になります。これは *note Message: 25d. クラス (あるいはそのサブクラ
     ス) のインスタンスでなければいけません。そうでない場合、この関数は
     *note TypeError: 502. を発生します。

     オプション引数 '_subtype' はそのメッセージの副形式 (subtype) を設定
     します。デフォルトではこれは ‘rfc822’ になっています。

     Optional 'policy' argument defaults to *note compat32: 1084.

     バージョン 3.6 で変更: キーワード専用引数 'policy' が追加されました
     。

 -- クラス: email.mime.text.MIMEText (_text, _subtype='plain',
          _charset=None, *, policy=compat32)

     モジュール: *note email.mime.text: 44.

     *note MIMEText: dc6. クラスは *note MIMENonMultipart: 3476. のサブ
     クラスで、主形式 (maintype) が ‘text’ の MIME オブジェクトを作成す
     るのに使われます。ペイロードの文字列は '_text' になります。
     '_subtype' には副形式 (subtype) を指定し、デフォルトは ‘plain’ です
     。 '_charset' はテキストの文字セットで、 *note MIMENonMultipart:
     3476. コンストラクタに引数として渡されます。この値は、文字列が
     ‘ascii’ コードポイントのみを含む場合 ‘us-ascii’ 、それ以外は
     ‘utf-8’ がデフォルトになっています。 '_charset' パラメータは、文字
     列と *note Charset: dc7. インスタンスの両方を受け付けます。

     ‘_charset’ 引数に明示的に ‘None’ をセットしない限りは、作成される
     MIMEText オブジェクトは ‘charset’ の付いた ‘Content-Type’ ヘッダと
     ‘Content-Transfer-Endcoding’ ヘッダの両方を持ちます。これは後続の
     ‘set_payload’ 呼び出しが、 ‘set_payload’ コマンドに charset が渡し
     たとしてもエンコードされたペイロードにはならないことを意味します。
     ‘Content-Transfer-Encoding’ ヘッダを削除することでこの振る舞いを「
     リセット」出来ます。これにより ‘set_payload’ 呼び出しが新たなペイロ
     ードを自動的にエンコード (そして新たな ‘Content-Transfer-Encoding’
     ヘッダを追加) します。

     Optional 'policy' argument defaults to *note compat32: 1084.

     バージョン 3.5 で変更: '_charset' は *note Charset: dc7. インスタン
     スも受け取ります。

     バージョン 3.6 で変更: キーワード専用引数 'policy' が追加されました
     。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/mime/


File: python.info,  Node: email header 国際化されたヘッダー,  Next: email charset 文字集合の表現,  Prev: email mime Creating email and MIME objects from scratch,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.15 ‘email.header’: 国際化されたヘッダー
..............................................

'ソースコード:' Lib/email/header.py(1)

__________________________________________________________________

このモジュールはレガシー(‘Compat32’)な電子メールAPIの一部です。現在の
APIではヘッダのエンコードとデコードは *note EmailMessage: 25c. クラスの
辞書的なAPIによって透過的に処理されます。レガシーコードでの使用に加えて
、このモジュールは、ヘッダーをエンコードする際に使用される文字セットを完
全に制御する必要があるアプリケーションで役立ちます

この節の以降のテキストはモジュールの元々のドキュメントです。

RFC 2822(2) は電子メールメッセージの形式を規定する基本規格です。これはほ
とんどの電子メールが ASCII 文字のみで構成されていたころ普及した RFC
822(3) 標準から発展したものです。 RFC 2822(4) は電子メールがすべて 7-bit
ASCII 文字のみから構成されていると仮定して作られた仕様です。

もちろん、電子メールが世界的に普及するにつれ、この仕様は国際化されてきま
した。今では電子メールに言語依存の文字集合を使うことができます。基本規格
では、まだ電子メールメッセージを 7-bit ASCII 文字のみを使って転送するよ
う要求していますので、多くの RFC でどうやって非ASCII の電子メールを RFC
2822(5) 準拠な形式にエンコードするかが記述されています。これらの RFC は
以下のものを含みます: RFC 2045(6) 、 RFC 2046(7) 、 RFC 2047(8) 、および
RFC 2231(9) 。 *note email: 32. パッケージは、 *note email.header: 38. お
よび *note email.charset: 33. モジュールでこれらの規格をサポートしていま
す。

ご自分の電子メールヘッダ、たとえば ‘Subject’ や ‘To’ などのフィールドに
非ASCII文字を入れたい場合、 *note Header: 1814. クラスを使う必要がありま
す。 *note Message: 25d. オブジェクトの該当フィールドに文字列ではなく、
*note Header: 1814. インスタンスを使うのです。 *note Header: 1814. クラ
スは *note email.header: 38. モジュールからインポートしてください。たと
えば:

     >>> from email.message import Message
     >>> from email.header import Header
     >>> msg = Message()
     >>> h = Header('p\xf6stal', 'iso-8859-1')
     >>> msg['Subject'] = h
     >>> msg.as_string()
     'Subject: =?iso-8859-1?q?p=F6stal?=\n\n'

‘Subject’ フィールドに非ASCII文字を含めていることに注目してください。こ
こでは、含めたいバイト列がエンコードされている文字集合を指定して *note
Header: 1814. インスタンスを作成することによって実現しています。のちにこ
の *note Message: 25d. インスタンスからフラットなテキストを生成する際に
、この ‘Subject’ フィールドは RFC 2047(10) 準拠の適切な形式にエンコード
されます。MIME 機能のあるメーラなら、このヘッダに埋めこまれた ISO-8859-1
文字を正しく表示するでしょう。

以下は *note Header: 1814. クラスの説明です:

 -- クラス: email.header.Header (s=None, charset=None, maxlinelen=None,
          header_name=None, continuation_ws=' ', errors='strict')

     別の文字集合の文字列を含む MIME 準拠なヘッダを作成します。

     オプション引数 's' はヘッダの値の初期値です。これが ‘None’ の場合
     (デフォルト)、ヘッダの初期値は設定されません。この値はあとから
     *note append(): 34dc. メソッドを呼びだすことによって追加することが
     できます。 's' は *note bytes: 1a4. または *note str: 418. のインス
     タンスにできます。このセマンティクスについては *note append():
     34dc. の項を参照してください。

     オプション引数 'charset' には 2 つの目的があります。ひとつは *note
     append(): 34dc. メソッドにおける 'charset' 引数と同じものです。もう
     ひとつは、これ以降 'charset' 引数を省略した *note append(): 34dc. メ
     ソッド呼び出しすべてにおける、デフォルト文字集合を決定するものです
     。コンストラクタに 'charset' が与えられない場合 (デフォルト)、初期
     値の 's' および以後の *note append(): 34dc. 呼び出しにおける文字集
     合として ‘us-ascii’ が使われます。

     行の最大長は 'maxlinelen' によって明示的に指定できます。最初の行を
     (‘Subject’ などの 's' に含まれないフィールドヘッダの責任をとるため)
     短く切りとる場合、 'header_name' にそのフィールド名を指定してくださ
     い。 'maxlinelen' のデフォルト値は 78 であり、 'header_name' のデフ
     ォルト値は ‘None’ です。これはその最初の行を長い、切りとられたヘッ
     ダとして扱わないことを意味します。

     オプション引数 'continuation_ws' は RFC 2822(11) 準拠の折り返し用余
     白文字で、ふつうこれは空白か、ハードタブ文字 (hard tab) である必要
     があります。ここで指定された文字は複数にわたる行の行頭に挿入されま
     す。 'continuation_ws' のデフォルト値は 1 つのスペース文字です。

     オプション引数 'errors' は、 *note append(): 34dc. メソッドにそのま
     ま渡されます。

      -- メソッド: append (s, charset=None, errors='strict')

          この MIME ヘッダに文字列 's' を追加します。

          オプション引数 'charset' がもし与えられた場合、これは *note
          Charset: dc7. インスタンス (*note email.charset: 33. を参照) か
          、あるいは文字集合の名前でなければなりません。この場合は *note
          Charset: dc7. インスタンスに変換されます。この値が ‘None’ の場
          合 (デフォルト)、コンストラクタで与えられた 'charset' が使われ
          ます。

          's' は *note bytes: 1a4. または *note str: 418. のインスタンス
          です。 *note bytes: 1a4. のインスタンスの場合、 'charset' はそ
          の文字列のエンコーディングであり、この文字セットでデコードでき
          ないときは *note UnicodeError: 1275. が発生します。

          's' が *note str: 418. のインスタンスの場合、 'charset' はその
          文字列の文字セットを決定するためのヒントとして使われます。

          いずれの場合でも、 RFC 2822(12) 準拠のヘッダを RFC 2047(13) の
          規則を用いて生成する際、文字列は指定された文字セットの出力コー
          デックを用いてエンコードされます。出力コーデックを用いて文字列
          がエンコードできないときは *note UnicodeError: 1275. が発生し
          ます。

          オプションの 'errors' は、 's' がバイト文字列だった場合のデコ
          ード呼び出しに errors 引数として渡されます。

      -- メソッド: encode (splitchars=';, \t', maxlinelen=None,
               linesep='\n')

          メッセージヘッダを RFC に沿ったやり方でエンコードします。おそ
          らく長い行は折り返され、非 ASCII 部分は base64 または
          quoted-printable エンコーディングで包含されるでしょう。

          オプション引数 'splitchars' は、通常のヘッダーの折り返し処理の
          間に分割アルゴリズムによって特別な重みが与えられるべき文字を含
          む文字列です。これは、 RFC 2822(14) の 'higher level syntactic
          breaks' の非常に荒いサポートです: splitchar の後の分割点は、行
          分割において優先されます。 分割文字は文字列中での出現順に優先
          されます。スペースとタブは、分割しようとする行に他の分割文字が
          出現しない時に、分割点として他の文字と比べてどのような優先順位
          が与えられるべきかを示すために、文字列に含めることができます。
          Splitchars は RFC 2047(15) エンコードされた行には影響しません
          。

          与えられた場合、'maxlinelen' はインスタンスの最大行長の値を上
          書きします。

          'linesep' は、折り返しヘッダの行を区切る文字を指定します。デフ
          ォルトではPythonアプリケーションコードに最も有用な値(‘\n’)にな
          りますが、RFC準拠の行区切り文字でヘッダを生成するために
          ''rn''を指定することができます。

          バージョン 3.2 で変更: 'linesep' 引数が追加されました。

     *note Header: 1814. クラスは、標準の演算子や組み込み関数をサポート
     するためのメソッドもいくつか提供しています。

      -- メソッド: __str__ ()

          *note Header: 1814. の概要を文字列として返します。無制限の行長
          を使用します。すべての箇所は、指定されたエンコーディングを使用
          してUnicodeに変換され、適切に結合されます。文字セット
          ‘'unknown-8bit'’ を持つ箇所は、 ‘'replace'’ エラーハンドラを使
          ってASCIIとしてデコードされます。

          バージョン 3.2 で変更: ‘'unknown-8bit'’ 文字集合の処理が追加さ
          れました。

      -- メソッド: __eq__ (other)

          このメソッドは、ふたつの *note Header: 1814. インスタンスどう
          しが等しいかどうか判定するのに使えます。

      -- メソッド: __ne__ (other)

          このメソッドは、ふたつの *note Header: 1814. インスタンスどう
          しが異なっているかどうかを判定するのに使えます。

さらに、 *note email.header: 38. モジュールは以下のような簡易関数も提供
しています。

 -- の関数: email.header.decode_header (header)

     文字集合を変換せずにメッセージのヘッダをデコードします。ヘッダの値
     は 'header' にあります。

     この関数はヘッダのそれぞれのデコードされた部分ごとに、
     ‘(decoded_string, charset)’ という形式の 2要素タプルからなるリスト
     を返します。'charset' はヘッダのエンコードされていない部分に対して
     は ‘None’ を、それ以外の場合はエンコードされた文字列が指定している
     文字集合の名前を小文字からなる文字列で返します。

     以下はこの使用例です:

          >>> from email.header import decode_header
          >>> decode_header('=?iso-8859-1?q?p=F6stal?=')
          [(b'p\xf6stal', 'iso-8859-1')]

 -- の関数: email.header.make_header (decoded_seq, maxlinelen=None,
          header_name=None, continuation_ws=' ')

     *note decode_header(): 108a. によって返される 2要素タプルのリストか
     ら *note Header: 1814. インスタンスを作成します。

     *note decode_header(): 108a. はヘッダの値をとってきて、
     ‘(decoded_string, charset)’ という形式の 2要素タプルからなるリスト
     を返します。ここで 'decoded_string' はデコードされた文字列、
     'charset' はその文字集合です。

     この関数はこれらのリストの項目から、 *note Header: 1814. インスタン
     スを返します。オプション引数 'maxlinelen' 、 'header_name' および
     'continuation_ws' は *note Header: 1814. コンストラクタに与えるもの
     と同じです。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/header.py

   (2) https://datatracker.ietf.org/doc/html/rfc2822.html

   (3) https://datatracker.ietf.org/doc/html/rfc822.html

   (4) https://datatracker.ietf.org/doc/html/rfc2822.html

   (5) https://datatracker.ietf.org/doc/html/rfc2822.html

   (6) https://datatracker.ietf.org/doc/html/rfc2045.html

   (7) https://datatracker.ietf.org/doc/html/rfc2046.html

   (8) https://datatracker.ietf.org/doc/html/rfc2047.html

   (9) https://datatracker.ietf.org/doc/html/rfc2231.html

   (10) https://datatracker.ietf.org/doc/html/rfc2047.html

   (11) https://datatracker.ietf.org/doc/html/rfc2822.html

   (12) https://datatracker.ietf.org/doc/html/rfc2822.html

   (13) https://datatracker.ietf.org/doc/html/rfc2047.html

   (14) https://datatracker.ietf.org/doc/html/rfc2822.html

   (15) https://datatracker.ietf.org/doc/html/rfc2047.html


File: python.info,  Node: email charset 文字集合の表現,  Next: email encoders エンコーダー,  Prev: email header 国際化されたヘッダー,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.16 ‘email.charset’: 文字集合の表現
.........................................

'ソースコード:' Lib/email/charset.py(1)

__________________________________________________________________

このモジュールは、レガシーな (‘Compat32’) email API の一部分です。 新し
い API では別名の表のみ使われています。

この節の以降のテキストはモジュールの元々のドキュメントです。

このモジュールは文字集合の表現および電子メールメッセージの文字集合の変換
を行う *note Charset: dc7. クラスに加え、文字集合のレジストリとそれを操
作する簡易メソッドを提供しています。 *note Charset: dc7. インスタンスは
*note email: 32. パッケージ中にある他のいくつかのモジュールで使用されま
す。

このクラスは *note email.charset: 33. モジュールからインポートしてくださ
い。

 -- クラス: email.charset.Charset (input_charset=DEFAULT_CHARSET)

     文字集合を電子メールのプロパティに写像します。

     このクラスは、ある特定の文字集合に対し電子メールに課される条件につ
     いての情報を提供します。 また、適用可能なコーデックスが利用出来れば
     、文字集合間の変換を行う簡易ルーチンを提供します。 文字集合について
     、この関数は電子メールメッセージ内での RFC に準拠した文字集合の使い
     方に関する情報を提供するのに最善を尽くします。

     文字集合によっては、電子メールのヘッダや本体で使う場合に
     quoted-printable や base64 形式でエンコードされなければなりません。
     また、文字集合によっては完全に変換する必要があり、電子メールの中で
     は使用できません。

     以下ではオプション引数 'input_charset' について説明します。この値は
     常に小文字に強制的に変換されます。そして文字集合の別名が正規化され
     たあと、この値は文字集合のレジストリ内を検索し、ヘッダのエンコーデ
     ィングとメッセージ本体のエンコーディング、および出力時の変換に使わ
     れるコーデックを見付けるのに使われます。たとえば 'input_charset' が
     ‘iso-8859-1’ の場合、ヘッダおよびメッセージ本体は quoted-printable
     でエンコードされ、出力時の変換用コーデックは必要ありません。もし
     'input_charset' が ‘euc-jp’ ならば、ヘッダは base64 でエンコードさ
     れ、メッセージ本体はエンコードされませんが、出力されるテキストは
     ‘euc-jp’ 文字集合から ‘iso-2022-jp’ 文字集合に変換されます。

     *note Charset: dc7. インスタンスは以下のようなデータ属性をもってい
     ます:

      -- の属性: input_charset

          最初に指定される文字集合です。一般的な別名は、'正式な' 電子メ
          ール用の名前に変換されます (たとえば、‘latin_1’ は
          ‘iso-8859-1’ に変換されます)。デフォルトは 7-bit の ‘us-ascii’
          です。

      -- の属性: header_encoding

          この文字集合が電子メールヘッダに使われる前にエンコードされなけ
          ればならない場合、この属性は ‘charset.QP’ (quoted-printable エ
          ンコーディング)、‘charset.BASE64’ (base64 エンコーディング)、
          あるいは最短の QP または BASE64 エンコーディングである
          ‘charset.SHORTEST’ に設定されます。そうでない場合、この値は
          ‘None’ になります。

      -- の属性: body_encoding

          'header_encoding' と同じですが、この値はメッセージ本体のための
          エンコーディングを記述します。これはヘッダ用のエンコーディング
          とは違うかもしれません。'body_encoding' では、
          ‘charset.SHORTEST’ を使うことはできません。

      -- の属性: output_charset

          文字集合によっては、電子メールのヘッダあるいはメッセージ本体に
          使う前に変換しなければなりません。もし 'input_charset' がそれ
          らの文字集合のどれかをさしていたら、この 'output_charset' 属性
          はそれが出力時に変換される文字集合の名前を表しています。それ以
          外の場合、この値は ‘None’ になります。

      -- の属性: input_codec

          'input_charset' を Unicode に変換するための Python 用コーデッ
          ク名です。変換用のコーデックが必要ないときは、この値は ‘None’
          になります。

      -- の属性: output_codec

          Unicode を 'output_charset' に変換するための Python 用コーデッ
          ク名です。変換用のコーデックが必要ないときは、この値は ‘None’
          になります。この属性は 'input_codec' と同じ値を持つことになる
          でしょう。

     *note Charset: dc7. インスタンスは、以下のメソッドも持っています:

      -- メソッド: get_body_encoding ()

          メッセージ本体のエンコードに使われる content-transfer-encoding
          の値を返します。

          この値は使用しているエンコーディングの文字列
          ‘quoted-printable’ または ‘base64’ か、あるいは関数のいずれか
          です。後者の場合、これはエンコードされる Message オブジェクト
          を単一の引数として取るような関数である必要があります。この関数
          は変換後 ‘Content-Transfer-Encoding’ ヘッダ自体を、なんであれ
          適切な値に設定する必要があります。

          このメソッドは 'body_encoding' が ‘QP’ の場合
          ‘quoted-printable’ を返し、'body_encoding' が ‘BASE64’ の場合
          ‘base64’ を返します。それ以外の場合は文字列 ‘7bit’ を返します
          。

      -- メソッド: get_output_charset ()

          出力用の文字集合を返します。

          これは 'output_charset' 属性が ‘None’ でなければその値になりま
          す。それ以外の場合、この値は 'input_charset' と同じです。

      -- メソッド: header_encode (string)

          文字列 'string' をヘッダ用にエンコードします。

          エンコーディングの形式 (base64 または quoted-printable) は、
          'header_encoding' 属性に基づきます。

      -- メソッド: header_encode_lines (string, maxlengths)

          'string' を最初にバイト列に変換し、ヘッダ用にエンコードします
          。

          これは *note header_encode(): 34eb. と似ていますが、与えられた
          引数 'maxlengths' に従って、行の最大長に合うように文字列が調整
          されるところが異なります。 'maxlengths' はイテレータでなければ
          なりません: このイテレータが返す要素は次の行の最大長を表します
          。

      -- メソッド: body_encode (string)

          文字列 'string' をメッセージ本体用にエンコードします。

          エンコーディングの形式 (base64 または quoted-printable) は、
          'body_encoding' 属性に基づきます。

     *note Charset: dc7. クラスには、標準的な演算と組み込み関数をサポー
     トするいくつかのメソッドがあります。

      -- メソッド: __str__ ()

          'input_charset' を小文字に変換された文字列型として返します。
          ‘__repr__()’ は、 ‘__str__()’ の別名となっています。

      -- メソッド: __eq__ (other)

          このメソッドは、2つの *note Charset: dc7. インスタンスが同じか
          どうかをチェックするのに使います。

      -- メソッド: __ne__ (other)

          このメソッドは、2つの *note Charset: dc7. インスタンスが異なる
          かどうかをチェックするのに使います。

また、 *note email.charset: 33. モジュールには、グローバルな文字集合、文
字集合の別名およびコーデック用のレジストリに新しいエントリを追加する以下
の関数も含まれています:

 -- の関数: email.charset.add_charset (charset, header_enc=None,
          body_enc=None, output_charset=None)

     文字の属性をグローバルなレジストリに追加します。

     'charset' は入力用の文字集合で、その文字集合の正式名称を指定する必
     要があります。

     オプション引数 'header_enc' および 'body_enc' は quoted-printable エ
     ンコーディングを表す ‘charset.QP’ か、base64 エンコーディングを表す
     ‘charset.BASE64’、最短の quoted-printable または base64 エンコーデ
     ィングを表す ‘charset.SHORTEST’、あるいはエンコーディングなしの
     ‘None’ のいずれかになります。‘SHORTEST’ が使えるのは 'header_enc' だ
     けです。デフォルトの値はエンコーディングなしの ‘None’ になっていま
     す。

     オプション引数 'output_charset' には出力用の文字集合が入ります。
     ‘Charset.convert()’ が呼ばれたときの変換はまず入力用の文字集合を
     Unicode に変換し、それから出力用の文字集合に変換されます。デフォル
     トでは、出力は入力と同じ文字集合になっています。

     'input_charset' および 'output_charset' はこのモジュール中の文字集
     合-コーデック対応表にある Unicode コーデックエントリである必要があ
     ります。モジュールがまだ対応していないコーデックを追加するには、
     *note add_codec(): 34f2. を使ってください。より詳しい情報については
     *note codecs: 14. モジュールの文書を参照してください。

     グローバルな文字集合用のレジストリは、モジュールのグローバル辞書
     ‘CHARSETS’ 内に保持されています。

 -- の関数: email.charset.add_alias (alias, canonical)

     文字集合の別名を追加します。'alias' はその別名で、たとえば
     ‘latin-1’ のように指定します。'canonical' はその文字集合の正式名称
     で、たとえば ‘iso-8859-1’ のように指定します。

     文字集合のグローバルな別名用レジストリは、モジュールのグローバル辞
     書 ‘ALIASES’ 内に保持されています。

 -- の関数: email.charset.add_codec (charset, codecname)

     与えられた文字集合の文字と Unicode との変換を行うコーデックを追加し
     ます。

     'charset' は文字集合の正式な名前です。 'codecname' は、 *note str:
     418. の *note encode(): 8a3. メソッドの第 2 引数で使える Python コ
     ーデックの名前です。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/charset.py


File: python.info,  Node: email encoders エンコーダー,  Next: email utils Miscellaneous utilities,  Prev: email charset 文字集合の表現,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.17 ‘email.encoders’: エンコーダー
........................................

'ソースコード:' Lib/email/encoders.py(1)

__________________________________________________________________

このモジュールは、レガシーな (‘Compat32’) email APIの一部です。新しい
APIでは、この機能は *note set_content(): 1813. メソッドの*cte*パラメータ
によって提供されます。

このモジュールはPython3で非推奨になりました。 *note MIMEText: dc6. クラ
スはクラスのインスタンス化中に渡された '_subtype' と '_charset' の値を使
ってcontent typeとCTEヘッダを設定するので、ここで提供されている関数は明
示的に呼び出すべきではありません。

この節の以降のテキストはモジュールの元々のドキュメントです。

何もないところから *note Message: 25d. を作成するときしばしば必要になる
のが、ペイロードをメールサーバに通すためにエンコードすることです。これは
とくにバイナリデータを含んだ ‘image/*’ や ‘text/*’ タイプのメッセージで
必要です。

*note email: 32. パッケージでは、 *note encoders: 35. モジュールにおいて
いくかの便宜的なエンコーダをサポートしています。実際にはこれらのエンコー
ダは *note MIMEAudio: 34d8. および *note MIMEImage: 3477. クラスのコンス
トラクタでデフォルトエンコーダとして使われています。すべてのエンコーディ
ング関数は、エンコードするメッセージオブジェクトひとつだけを引数にとりま
す。これらはふつうペイロードを取りだし、それをエンコードして、ペイロード
をエンコードされたものにセットしなおします。これらはまた
‘Content-Transfer-Encoding’ ヘッダを適切な値に設定します。

マルチパートメッセージにこれら関数を使うことは全く無意味です。それらは各
々のサブパートごとに適用されるべきものです。メッセージがマルチパートのも
のを渡すと *note TypeError: 502. が発生します。

提供されているエンコーディング関数は以下のとおりです:

 -- の関数: email.encoders.encode_quopri (msg)

     ペイロードを quoted-printable 形式にエンコードし、
     ‘Content-Transfer-Encoding’ ヘッダを ‘quoted-printable’ (2) に設定
     します。これはそのペイロードのほとんどが通常の印刷可能な文字からな
     っているが、印刷不可能な文字がすこしだけあるときのエンコード方法と
     して適しています。

 -- の関数: email.encoders.encode_base64 (msg)

     ペイロードを base64 形式でエンコードし、
     ‘Content-Transfer-Encoding’ ヘッダを ‘base64’ に変更します。これは
     ペイロード中のデータのほとんどが印刷不可能な文字である場合に適して
     います。 quoted-printable 形式よりも結果としてはコンパクトなサイズ
     になるからです。 base64 形式の欠点は、これが人間にはまったく読めな
     いテキストになってしまうことです。

 -- の関数: email.encoders.encode_7or8bit (msg)

     これは実際にはペイロードを変更はしませんが、ペイロードの形式に応じ
     て ‘Content-Transfer-Encoding’ ヘッダを ‘7bit’ あるいは ‘8bit’ に適
     した形に設定します。

 -- の関数: email.encoders.encode_noop (msg)

     これは何もしないエンコーダです。 ‘Content-Transfer-Encoding’ ヘッダ
     を設定さえしません。

脚注
....

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/encoders.py

   (2) 注意: *note encode_quopri(): 34f6. を使ってエンコードすると、デー
タ中のタブ文字や空白文字もエンコードされます。


File: python.info,  Node: email utils Miscellaneous utilities,  Next: email iterators イテレータ,  Prev: email encoders エンコーダー,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.18 ‘email.utils’: Miscellaneous utilities
................................................

'ソースコード:' Lib/email/utils.py(1)

__________________________________________________________________

*note email.utils: 47. モジュールではいくつかの便利なユーティリティを提
供しています:

 -- の関数: email.utils.localtime (dt=None)

     Return local time as an aware datetime object.  If called without
     arguments, return current time.  Otherwise 'dt' argument should be
     a *note datetime: 1ae. instance, and it is converted to the local
     time zone according to the system time zone database.  If 'dt' is
     naive (that is, ‘dt.tzinfo’ is ‘None’), it is assumed to be in
     local time.  The 'isdst' parameter is ignored.

     Added in version 3.3.

     Deprecated since version 3.12, will be removed in version 3.14: The
     'isdst' parameter.

 -- の関数: email.utils.make_msgid (idstring=None, domain=None)

     Returns a string suitable for an RFC 2822(2)-compliant ‘Message-ID’
     header.  Optional 'idstring' if given, is a string used to
     strengthen the uniqueness of the message id.  Optional 'domain' if
     given provides the portion of the msgid after the '@'.  The default
     is the local hostname.  It is not normally necessary to override
     this default, but may be useful certain cases, such as a
     constructing distributed system that uses a consistent domain name
     across multiple hosts.

     バージョン 3.2 で変更: 'domain' キーワードが追加されました。

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.

 -- の関数: email.utils.quote (str)

     文字列 'str' 内のバックスラッシュをバックスラッシュ2つに置換した新
     しい文字列を返します。また、ダブルクォートはバックスラッシュ + ダブ
     ルクォートに置換されます。

 -- の関数: email.utils.unquote (str)

     文字列 'str' の 'クォートを外した' 新しい文字列を返します。'str' の
     先頭と末尾がダブルクォートだった場合、それらは取り除かれます。同様
     に 'str' の先頭と末尾が角ブラケット (<、>) だった場合もそれらは取り
     除かれます。

 -- の関数: email.utils.parseaddr (address, *, strict=True)

     ‘To’ や ‘Cc’ のようなフィールドを持つアドレスをパースして、構成要素
     の '実名' と '電子メールアドレス' を取り出します。 パースに成功した
     場合、これらの情報持つタプルを返します。失敗した場合は 2 要素のタプ
     ル ‘('', '')’ を返します。

     If 'strict' is true, use a strict parser which rejects malformed
     inputs.

     バージョン 3.13 で変更: Add 'strict' optional parameter and reject
     malformed inputs by default.

 -- の関数: email.utils.formataddr (pair, charset='utf-8')

     *note parseaddr(): 1c6. の逆で、2 要素のタプル ‘(realname,
     email_address)’ を取って ‘To’ や ‘Cc’ ヘッダに適した文字列を返しま
     す。タプル 'pair' の第1要素が偽である場合、第2要素の値をそのまま返
     します。

     任意の 'charset' は、 ‘realname’ が非 ASCII 文字を含んでいる場合に
     その RFC 2047(3) エンコーディングに使われる文字集合です。*note str:
     418. か *note Charset: dc7. のインスタンスで、デフォルトは ‘utf-8’
     です。

     バージョン 3.3 で変更: 'charset' オプションが追加されました。

 -- の関数: email.utils.getaddresses (fieldvalues, *, strict=True)

     This method returns a list of 2-tuples of the form returned by
     ‘parseaddr()’.  'fieldvalues' is a sequence of header field values
     as might be returned by *note Message.get_all: 34b8.

     If 'strict' is true, use a strict parser which rejects malformed
     inputs.

     Here's a simple example that gets all the recipients of a message:

          from email.utils import getaddresses

          tos = msg.get_all('to', [])
          ccs = msg.get_all('cc', [])
          resent_tos = msg.get_all('resent-to', [])
          resent_ccs = msg.get_all('resent-cc', [])
          all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)

     バージョン 3.13 で変更: Add 'strict' optional parameter and reject
     malformed inputs by default.

 -- の関数: email.utils.parsedate (date)

     RFC 2822(4) の規則に基づいて日付の解析を試みます。 しかしながらメイ
     ラーによっては指定された形式に従っていないものがあるので、その場合
     *note parsedate(): 34fe. は正しく推測しようとします。 'date' は
     ‘"Mon, 20 Nov 1995 19:12:08 -0500"’ のような RFC 2822(5) 形式の日付
     を含む文字列です。 日付の解析に成功した場合、 *note parsedate():
     34fe. は関数 *note time.mktime(): 11b9. に直接渡せる形式の 9 要素か
     らなるタプルを返します。 失敗した場合は ‘None’ を返します。 返され
     るタプルの 6、7、8番目の添字は使用不可なので注意してください。

 -- の関数: email.utils.parsedate_tz (date)

     Performs the same function as *note parsedate(): 34fe, but returns
     either ‘None’ or a 10-tuple; the first 9 elements make up a tuple
     that can be passed directly to *note time.mktime(): 11b9, and the
     tenth is the offset of the date's timezone from UTC (which is the
     official term for Greenwich Mean Time) (6).  If the input string
     has no timezone, the last element of the tuple returned is ‘0’,
     which represents UTC. Note that indexes 6, 7, and 8 of the result
     tuple are not usable.

 -- の関数: email.utils.parsedate_to_datetime (date)

     The inverse of *note format_datetime(): 108f.  Performs the same
     function as *note parsedate(): 34fe, but on success returns a *note
     datetime: 1ae.; otherwise ‘ValueError’ is raised if 'date' contains
     an invalid value such as an hour greater than 23 or a timezone
     offset not between -24 and 24 hours.  If the input date has a
     timezone of ‘-0000’, the ‘datetime’ will be a naive ‘datetime’, and
     if the date is conforming to the RFCs it will represent a time in
     UTC but with no indication of the actual source timezone of the
     message the date comes from.  If the input date has any other valid
     timezone offset, the ‘datetime’ will be an aware ‘datetime’ with
     the corresponding a *note timezone: 1091. *note tzinfo: 5a8.

     Added in version 3.3.

 -- の関数: email.utils.mktime_tz (tuple)

     *note parsedate_tz(): 17e9. が返す 10 要素のタプルを UTC のタイムス
     タンプ (エポックからの秒数) に変換します。与えられた時間帯が ‘None’
     である場合、時間帯として現地時間 (localtime) が仮定されます。

 -- の関数: email.utils.formatdate (timeval=None, localtime=False,
          usegmt=False)

     日付を RFC 2822(7) 形式の文字列で返します。例:

          Fri, 09 Nov 2001 01:08:47 -0000

     Optional 'timeval' if given is a floating-point time value as
     accepted by *note time.gmtime(): 1190. and *note time.localtime():
     14a2, otherwise the current time is used.

     オプション引数 'localtime' はフラグです。‘True’ の場合、この関数は
     'timeval' を解析して UTC の代わりに現地のタイムゾーンに対する日付を
     返します。おそらく夏時間も考慮するでしょう。デフォルトは ‘False’ で
     、UTC が使われます。

     オプション引数 'usegmt' はフラグです。‘True’ の場合、この関数はタイ
     ムゾーンを数値の ‘-0000’ ではなく ascii 文字列 ‘GMT’ として日付を出
     力します。これはプロトコルによっては (例えば HTTP) 必要です。これは
     'localtime' が ‘False’ のときのみ適用されます。デフォルトは ‘False’
     です。

 -- の関数: email.utils.format_datetime (dt, usegmt=False)

     Like ‘formatdate’, but the input is a *note datetime: 28. instance.
     If it is a naive datetime, it is assumed to be "UTC with no
     information about the source timezone", and the conventional
     ‘-0000’ is used for the timezone.  If it is an aware ‘datetime’,
     then the numeric timezone offset is used.  If it is an aware
     timezone with offset zero, then 'usegmt' may be set to ‘True’, in
     which case the string ‘GMT’ is used instead of the numeric timezone
     offset.  This provides a way to generate standards conformant HTTP
     date headers.

     Added in version 3.3.

 -- の関数: email.utils.decode_rfc2231 (s)

     RFC 2231(8) に従って文字列 's' をデコードします。

 -- の関数: email.utils.encode_rfc2231 (s, charset=None, language=None)

     RFC 2231(9) に従って 's' をエンコードします。オプション引数
     'charset' および 'language' が与えられた場合、これらは文字セット名
     と言語名として使われます。もしこれらのどちらも与えられていない場合
     、 's' はそのまま返されます。 'charset' は与えられているが
     'language' が与えられていない場合、文字列 's' は 'language' の空文
     字列を使ってエンコードされます。

 -- の関数: email.utils.collapse_rfc2231_value (value, errors='replace',
          fallback_charset='us-ascii')

     ヘッダのパラメータが RFC 2231(10) 形式でエンコードされている場合、
     *note Message.get_param: 34c6. は 3 要素からなるタプルを返すことが
     あります。ここには、そのパラメータの文字セット、言語、および値の順
     に格納されています。 *note collapse_rfc2231_value(): 34c7. はこのパ
     ラメータをひとつの Unicode 文字列にまとめます。オプション引数
     'errors' は *note str: 418. の *note encode(): 8a3. メソッドの引数
     'errors' に渡されます。このデフォルト値は ‘'replace'’ となっていま
     す。オプション引数 'fallback_charset' は、もし RFC 2231(11) ヘッダ
     の使用している文字セットが Python の知っているものではなかった場合
     の非常用文字セットとして使われます。デフォルトでは、この値は
     ‘'us-ascii'’ です。

     便宜上、 *note collapse_rfc2231_value(): 34c7. に渡された引数
     'value' がタプルでない場合には、これは文字列でなければなりません。
     その場合にはクォートを除いた文字列を返します。

 -- の関数: email.utils.decode_params (params)

     RFC 2231(12) に従って引数のリストをデコードします。 'params' は
     ‘(content-type, string-value)’ のような形式の 2 要素タプルです。

脚注
....

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/email/utils.py

   (2) https://datatracker.ietf.org/doc/html/rfc2822.html

   (3) https://datatracker.ietf.org/doc/html/rfc2047.html

   (4) https://datatracker.ietf.org/doc/html/rfc2822.html

   (5) https://datatracker.ietf.org/doc/html/rfc2822.html

   (6) 注意: この時間帯のオフセット値は ‘time.timezone’ の値と符号が逆で
す。これは ‘time.timezone’ が POSIX 標準に準拠しているのに対して、こちら
は RFC 2822 (https://datatracker.ietf.org/doc/html/rfc2822.html) に準拠
しているからです。

   (7) https://datatracker.ietf.org/doc/html/rfc2822.html

   (8) https://datatracker.ietf.org/doc/html/rfc2231.html

   (9) https://datatracker.ietf.org/doc/html/rfc2231.html

   (10) https://datatracker.ietf.org/doc/html/rfc2231.html

   (11) https://datatracker.ietf.org/doc/html/rfc2231.html

   (12) https://datatracker.ietf.org/doc/html/rfc2231.html


File: python.info,  Node: email iterators イテレータ,  Prev: email utils Miscellaneous utilities,  Up: email --- 電子メールと MIME 処理のためのパッケージ

5.19.1.19 ‘email.iterators’: イテレータ
.......................................

'ソースコード:' Lib/email/iterators.py(1)

__________________________________________________________________

*note Message.walk: 34cf. メソッドを使うと、簡単にメッセージオブジェクト
ツリー内を次から次へとたどる (iteration) ことができます。 *note
email.iterators: 3a. モジュールはこのための高水準イテレータをいくつか提
供します。

 -- の関数: email.iterators.body_line_iterator (msg, decode=False)

     このイテレータは 'msg' 中のすべてのサブパートに含まれるペイロードを
     すべて順にたどっていき、ペイロード内の文字列を 1 行ずつ返します。サ
     ブパートのヘッダはすべて無視され、Python 文字列でないペイロードから
     なるサブパートも無視されます。これは *note readline(): 1c27. を使っ
     て、ファイルからメッセージを (ヘッダだけとばして) フラットなテキス
     トとして読むのにいくぶん似ているかもしれません。

     オプション引数 'decode' は、 *note Message.get_payload: 119d. にそ
     のまま渡されます。

 -- の関数: email.iterators.typed_subpart_iterator (msg,
          maintype='text', subtype=None)

     このイテレータは 'msg' 中のすべてのサブパートをたどり、それらの中で
     指定されたMIME 形式 'maintype' と 'subtype' をもつようなパートのみ
     を返します。

     'subtype' は省略可能であることに注意してください。これが省略された
     場合、サブパートの MIME 形式は maintype のみがチェックされます。じ
     つは 'maintype' も省略可能で、その場合にはデフォルトは ‘text’ です
     。

     つまり、デフォルトでは *note typed_subpart_iterator(): 3506. は
     MIME 形式 ‘text/*’ をもつサブパートを順に返していくというわけです。

以下の関数は役に立つデバッグ用ツールとして追加されたもので、パッケージと
して公式なサポートのあるインターフェイスでは 'ありません'。

 -- の関数: email.iterators._structure (msg, fp=None, level=0,
          include_default=False)

     そのメッセージオブジェクト構造の content-type をインデントつきで表
     示します。例えば:

          >>> msg = email.message_from_file(somefile)
          >>> _structure(msg)
          multipart/mixed
              text/plain
              text/plain
              multipart/digest
                  message/rfc822
                      text/plain
                  message/rfc822
                      text/plain
                  message/rfc822
                      text/plain
                  message/rfc822
                      text/plain
                  message/rfc822
                      text/plain
              text/plain

     オプション引数 'fp' は出力を渡すための file-like オブジェクトです。
     これは Python の *note print(): f42. 関数が対応できるようになってい
     る必要があります。 'level' は内部的に使用されます。
     'include_default' が真の場合、デフォルトの型も出力します。

参考
....

*note smtplib: b7. モジュール

     SMTP（簡易メール転送プロトコル）クライアント

*note poplib: 9a. モジュール

     POP (Post Office Protocol) クライアント

モジュール *note imaplib: 6a.

     IMAP (Internet Message Access Protocol) クライアント

*note mailbox: 7f. モジュール

     Tools for creating, reading, and managing collections of messages
     on disk using a variety standard formats.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/email/iterators.py


File: python.info,  Node: json --- JSON エンコーダーとデコーダー,  Next: mailbox --- 様々な形式のメールボックスを操作する,  Prev: email --- 電子メールと MIME 処理のためのパッケージ,  Up: インターネット上のデータの操作

5.19.2 ‘json’ -- JSON エンコーダーとデコーダー
----------------------------------------------

'ソースコード:' Lib/json/__init__.py(1)

__________________________________________________________________

JSON (JavaScript Object Notation)(2), specified by RFC 7159(3) (which
obsoletes RFC 4627(4)) and by ECMA-404(5), is a lightweight data
interchange format inspired by JavaScript(6) object literal syntax
(although it is not a strict subset of JavaScript (7) ).

     警告: 信頼されていないソースからの JSON データをパースするときは十
     分注意してください。悪意を持った JSON 文字列はデコーダに著しい量の
     CPU とメモリリソースを消費させる可能性があります。パースするデータ
     量を制限することを推奨します。

*note json: 76. の API は標準ライブラリの *note marshal: 80. や *note
pickle: 95. のユーザに馴染み深いものです。

基本的な Python オブジェクト階層のエンコーディング:

     >>> import json
     >>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
     '["foo", {"bar": ["baz", null, 1.0, 2]}]'
     >>> print(json.dumps("\"foo\bar"))
     "\"foo\bar"
     >>> print(json.dumps('\u1234'))
     "\u1234"
     >>> print(json.dumps('\\'))
     "\\"
     >>> print(json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True))
     {"a": 0, "b": 0, "c": 0}
     >>> from io import StringIO
     >>> io = StringIO()
     >>> json.dump(['streaming API'], io)
     >>> io.getvalue()
     '["streaming API"]'

コンパクトなエンコーディング:

     >>> import json
     >>> json.dumps([1, 2, 3, {'4': 5, '6': 7}], separators=(',', ':'))
     '[1,2,3,{"4":5,"6":7}]'

見やすい表示:

     >>> import json
     >>> print(json.dumps({'6': 7, '4': 5}, sort_keys=True, indent=4))
     {
         "4": 5,
         "6": 7
     }

JSON オブジェクトのエンコーディングに特化する:

     >>> import json
     >>> def custom_json(obj):
     ...     if isinstance(obj, complex):
     ...         return {'__complex__': True, 'real': obj.real, 'imag': obj.imag}
     ...     raise TypeError(f'Cannot serialize object of {type(obj)}')
     ...
     >>> json.dumps(1 + 2j, default=custom_json)
     '{"__complex__": true, "real": 1.0, "imag": 2.0}'

JSON のデコーディング:

     >>> import json
     >>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
     ['foo', {'bar': ['baz', None, 1.0, 2]}]
     >>> json.loads('"\\"foo\\bar"')
     '"foo\x08ar'
     >>> from io import StringIO
     >>> io = StringIO('["streaming API"]')
     >>> json.load(io)
     ['streaming API']

JSON オブジェクトのデコーディング方法を誂える:

     >>> import json
     >>> def as_complex(dct):
     ...     if '__complex__' in dct:
     ...         return complex(dct['real'], dct['imag'])
     ...     return dct
     ...
     >>> json.loads('{"__complex__": true, "real": 1, "imag": 2}',
     ...     object_hook=as_complex)
     (1+2j)
     >>> import decimal
     >>> json.loads('1.1', parse_float=decimal.Decimal)
     Decimal('1.1')

*note JSONEncoder: d14. の拡張:

     >>> import json
     >>> class ComplexEncoder(json.JSONEncoder):
     ...     def default(self, obj):
     ...         if isinstance(obj, complex):
     ...             return [obj.real, obj.imag]
     ...         # Let the base class default method raise the TypeError
     ...         return super().default(obj)
     ...
     >>> json.dumps(2 + 1j, cls=ComplexEncoder)
     '[2.0, 1.0]'
     >>> ComplexEncoder().encode(2 + 1j)
     '[2.0, 1.0]'
     >>> list(ComplexEncoder().iterencode(2 + 1j))
     ['[2.0', ', 1.0', ']']

シェルから *note json.tool: 77. を使って妥当性チェックをして見やすく表示
:

     $ echo '{"json":"obj"}' | python -m json.tool
     {
         "json": "obj"
     }
     $ echo '{1.2:3.4}' | python -m json.tool
     Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

詳細については *note コマンドラインインターフェイス: 350a. を参照してく
ださい。

     注釈: JSON は YAML(8) 1.2 のサブセットです。このモジュールのデフォ
     ルト設定 (特に、デフォルトの 'セパレータ' 値) で生成される JSON は
     YAML 1.0 および 1.1 のサブセットでもあります。このモジュールは YAML
     シリアライザとしても使えます。

     注釈: このモジュールのエンコーダとデコーダは、デフォルトで入力順と
     出力順を保つようになっています。根底のコンテナに順序がない場合のみ
     、順序が失われます。

* Menu:

* 基本的な使い方: 基本的な使い方<2>.
* エンコーダとデコーダ::
* 例外: 例外<16>.
* 標準への準拠と互換性::
* コマンドラインインターフェイス: コマンドラインインターフェイス<4>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/json/__init__.py

   (2) https://json.org

   (3) https://datatracker.ietf.org/doc/html/rfc7159.html

   (4) https://datatracker.ietf.org/doc/html/rfc4627.html

   (5) 
https://ecma-international.org/publications-and-standards/standards/ecma-404/

   (6) https://en.wikipedia.org/wiki/JavaScript

   (7) RFC 7159 正誤表
(https://www.rfc-editor.org/errata_search.php?rfc=7159) で述べられている
通り、JSON は (ECMAScript Edition 5.1 の) JavaScript とは逆に、 U+2028
(LINE SEPARATOR) と U+2029 (PARAGRAPH SEPARATOR) が文字列内に含まれるこ
とを許容しています。

   (8) https://yaml.org/


File: python.info,  Node: 基本的な使い方<2>,  Next: エンコーダとデコーダ,  Up: json --- JSON エンコーダーとデコーダー

5.19.2.1 基本的な使い方
.......................

 -- の関数: json.dump (obj, fp, *, skipkeys=False, ensure_ascii=True,
          check_circular=True, allow_nan=True, cls=None, indent=None,
          separators=None, default=None, sort_keys=False, **kw)

     この *note 変換表: 350c. を使って、 'obj' を JSON 形式の 'fp'
     (‘.write()’ がサポートされている *note file-like object: 24e0.) へ
     のストリームとして直列化します。

     'skipkeys' が true (デフォルトは ‘False’) ならば、基本型 (*note
     str: 418, *note int: 238, *note float: 2ce, *note bool: 434,
     ‘None’) 以外の辞書のキーは *note TypeError: 502. を送出せずに読み飛
     ばされます。

     この *note json: 76. モジュールは常に、 *note bytes: 1a4. オブジェ
     クトではなく、 *note str: 418. オブジェクトを生成します。従って、
     ‘fp.write()’ は *note str: 418. の入力をサポートしていなければなり
     ません。

     'ensure_ascii' が (デフォルト値の) true の場合、出力では入力された
     全ての非 ASCII 文字はエスケープされていることが保証されています。
     'ensure_ascii' が false の場合、これらの文字はそのまま出力されます
     。

     'check_circular' が false (デフォルトは ‘True’) ならば、コンテナ型
     の循環参照チェックが省かれ、循環参照があれば *note RecursionError:
     d39. (またはもっと悪い結果) に終わります。

     'allow_nan' が偽 (デフォルトは ‘True’) の場合、許容範囲外の *note
     float: 2ce. 値 (‘nan’, ‘inf’, ‘-inf’) を JSON 仕様を厳格に守って 直
     列化すると、*note ValueError: 1e3. になります。 'allow_nan' が真の
     場合は、 JavaScript での等価なもの (‘NaN’, ‘Infinity’, ‘-Infinity’)
     が使われます。

     'indent' が非負の整数または文字列であれば、JSON の配列要素とオブジ
     ェクトメンバはそのインデントレベルで見やすく表示されます。インデン
     トレベルが 0 か負数または ‘""’ であれば 改行だけが挿入されます。
     ‘None’ (デフォルト) では最もコンパクトな表現が選択されます。正の数
     のindentはレベル毎に、指定した数のスペースでインデントします。もし
     'indent' が文字列 (‘"\t"’ のような) であれば、その文字列が個々のレ
     ベルのインデントに使用されます。

     バージョン 3.2 で変更: 整数に加えて、文字列が 'indent' に使用できる
     ようになりました。

     'separators' はもし指定するなら ‘(item_separator, key_separator)’ と
     いうタプルでなければなりません。デフォルトは 'indent' が ‘None’ の
     とき ‘(', ', ': ')’ で、そうでなければ ‘(',', ': ')’ です。最もコン
     パクトな JSON の表現を得たければ空白を削った ‘(',', ':')’ を指定す
     ればいいでしょう。

     バージョン 3.4 で変更: 'indent' が ‘None’ でなければ ‘(',', ': ')’
     がデフォルトで使われます。

     'default' を指定する場合は関数を指定して、この関数はそれ以外では直
     列化できないオブジェクトに対して呼び出されます。 その関数は、オブジ
     ェクトを JSON でエンコードできるバージョンにして返すか、さもなけれ
     ば *note TypeError: 502. を送出しなければなりません。 指定しない場
     合は、 *note TypeError: 502. が送出されます。

     'sort_keys' が true (デフォルトでは ‘False’ です)であれば、辞書の出
     力がキーでソートされます。

     カスタマイズされた *note JSONEncoder: d14. のサブクラス (たとえば追
     加の型を直列化するように *note default(): 350d. メソッドをオーバー
     ライドしたもの) を使うには、 'cls' キーワード引数に指定します; 指定
     しなければ *note JSONEncoder: d14. が使われます。

     バージョン 3.6 で変更: すべてのオプション引数は、 *note
     キーワード専用: 285. になりました。

          注釈: *note pickle: 95. や *note marshal: 80. とは異なり JSON
          はフレーム付きのプロトコルではないので、同じ 'fp' に対し繰り返
          し *note dump(): d12. を呼び、複数のオブジェクトを直列化しよう
          とすると、不正な JSON ファイルが作られてしまいます。

 -- の関数: json.dumps (obj, *, skipkeys=False, ensure_ascii=True,
          check_circular=True, allow_nan=True, cls=None, indent=None,
          separators=None, default=None, sort_keys=False, **kw)

     この *note 変換表: 350c. を使って、'obj' を JSON 形式の *note str:
     418. オブジェクトに直列化します。引数は *note dump(): d12. と同じ意
     味です。

          注釈: JSON のキー値ペアのキーは、常に *note str: 418. 型です。
          辞書が JSON に変換されるとき、辞書の全てのキーは文字列へ強制的
          に変換が行われます。この結果として、辞書が JSON に変換され、そ
          れから辞書に戻された場合、辞書は元のものと同じではありません。
          つまり文字列ではないキーを持っている場合、 ‘loads(dumps(x)) !=
          x’ となるということです。

 -- の関数: json.load (fp, *, cls=None, object_hook=None,
          parse_float=None, parse_int=None, parse_constant=None,
          object_pairs_hook=None, **kw)

     この *note 変換表: 350e. を使い、 'fp' (‘.read()’ をサポートし JSON
     ドキュメントを含んでいる *note text file: 1bf0. もしくは *note
     binary file: 1bf1.) を Python オブジェクトへ脱直列化します。

     'object_hook' はオプションの関数で、任意のオブジェクトリテラルがデ
     コードされた結果 (*note dict: 237.) に対し呼び出されます。
     'object_hook' の返り値は *note dict: 237. の代わりに使われます。こ
     の機能は独自のデコーダ (例えば JSON-RPC(1) クラスヒンティング) を実
     装するのに使えます。

     'object_pairs_hook' is an optional function that will be called
     with the result of any object literal decoded with an ordered list
     of pairs.  The return value of 'object_pairs_hook' will be used
     instead of the *note dict: 237.  This feature can be used to
     implement custom decoders.  If 'object_hook' is also defined, the
     'object_pairs_hook' takes priority.

     バージョン 3.1 で変更: 'object_pairs_hook' のサポートが追加されまし
     た。

     'parse_float' is an optional function that will be called with the
     string of every JSON float to be decoded.  By default, this is
     equivalent to ‘float(num_str)’.  This can be used to use another
     datatype or parser for JSON floats (e.g.  *note decimal.Decimal:
     27d.).

     'parse_int' is an optional function that will be called with the
     string of every JSON int to be decoded.  By default, this is
     equivalent to ‘int(num_str)’.  This can be used to use another
     datatype or parser for JSON integers (e.g.  *note float: 2ce.).

     バージョン 3.11 で変更: デフォルトの 'parse_int' である *note
     int(): 238. は、インタープリタの *note integer string conversion
     length limitation: 5bf. により整数文字列の最大長を制限するようにな
     り、サービスを妨害する攻撃を拒否します。

     'parse_constant' is an optional function that will be called with
     one of the following strings: ‘'-Infinity'’, ‘'Infinity'’, ‘'NaN'’.
     This can be used to raise an exception if invalid JSON numbers are
     encountered.

     バージョン 3.1 で変更: 'null', 'true', 'false' に対して
     'parse_constant' は呼びされません。

     カスタマイズされた *note JSONDecoder: d15. のサブクラスを使うには、
     'cls' キーワード引数に指定します; 指定しなかった場合は *note
     JSONDecoder: d15. が使われます。追加のキーワード引数はこのクラスの
     コンストラクタに引き渡されます。

     脱直列化しようとしているデータが不正な JSON ドキュメントだった場合
     、 *note JSONDecodeError: ded. が送出されます。

     バージョン 3.6 で変更: すべてのオプション引数は、 *note
     キーワード専用: 285. になりました。

     バージョン 3.6 で変更: 'fp' には *note binary file: 1bf1. 型も使え
     るようになりました。入力のエンコーディングは UTF-8, UTF-16, UTF-32
     のいずれかでなければなりません。

 -- の関数: json.loads (s, *, cls=None, object_hook=None,
          parse_float=None, parse_int=None, parse_constant=None,
          object_pairs_hook=None, **kw)

     この *note 変換表: 350e. を使い、 's' (JSON ドキュメントを含んでい
     る *note str: 418, *note bytes: 1a4, *note bytearray: 508. のいずれ
     かのインスタンス) を Python オブジェクトへ脱直列化します。

     その他の引数は *note load(): c82. のものと同じ意味です。

     脱直列化しようとしているデータが不正な JSON ドキュメントだった場合
     、 *note JSONDecodeError: ded. が送出されます。

     バージョン 3.6 で変更: 's' には *note bytes: 1a4. 型と *note
     bytearray: 508. 型も使えるようになりました。 入力エンコーディングは
     UTF-8, UTF-16, UTF-32 のいずれかでなければなりません。

     バージョン 3.9 で変更: キーワード引数 'encoding' が削除されました。

   ---------- Footnotes ----------

   (1) https://www.jsonrpc.org


File: python.info,  Node: エンコーダとデコーダ,  Next: 例外<16>,  Prev: 基本的な使い方<2>,  Up: json --- JSON エンコーダーとデコーダー

5.19.2.2 エンコーダとデコーダ
.............................

 -- クラス: json.JSONDecoder (*, object_hook=None, parse_float=None,
          parse_int=None, parse_constant=None, strict=True,
          object_pairs_hook=None)

     単純な JSON デコーダ。

     デフォルトではデコーディングの際、以下の変換を行います:

     JSON                Python
                         
     --------------------------------------------
                         
     object              dict
                         
                         
     array               list
                         
                         
     string              str
                         
                         
     number (int)        int
                         
                         
     number (real)       浮動小数点数
                         
                         
     true                True
                         
                         
     false               False
                         
                         
     null                None
                         

     また、このデコーダは ‘NaN’, ‘Infinity’, ‘-Infinity’ を対応する
     ‘float’ の値として、JSON の仕様からは外れますが、理解します。

     'object_hook' is an optional function that will be called with the
     result of every JSON object decoded and its return value will be
     used in place of the given *note dict: 237.  This can be used to
     provide custom deserializations (e.g.  to support JSON-RPC(1) class
     hinting).

     'object_pairs_hook' is an optional function that will be called
     with the result of every JSON object decoded with an ordered list
     of pairs.  The return value of 'object_pairs_hook' will be used
     instead of the *note dict: 237.  This feature can be used to
     implement custom decoders.  If 'object_hook' is also defined, the
     'object_pairs_hook' takes priority.

     バージョン 3.1 で変更: 'object_pairs_hook' のサポートが追加されまし
     た。

     'parse_float' is an optional function that will be called with the
     string of every JSON float to be decoded.  By default, this is
     equivalent to ‘float(num_str)’.  This can be used to use another
     datatype or parser for JSON floats (e.g.  *note decimal.Decimal:
     27d.).

     'parse_int' is an optional function that will be called with the
     string of every JSON int to be decoded.  By default, this is
     equivalent to ‘int(num_str)’.  This can be used to use another
     datatype or parser for JSON integers (e.g.  *note float: 2ce.).

     'parse_constant' is an optional function that will be called with
     one of the following strings: ‘'-Infinity'’, ‘'Infinity'’, ‘'NaN'’.
     This can be used to raise an exception if invalid JSON numbers are
     encountered.

     'strict' が false (デフォルトは ‘True’) の場合、制御文字を文字列に
     含めることができます。ここで言う制御文字とは、‘'\t'’ (タブ)、
     ‘'\n'’、‘'\r'’、‘'\0'’ を含む 0-31 の範囲のコードを持つ文字のことで
     す。

     脱直列化しようとしているデータが不正な JSON ドキュメントだった場合
     、 *note JSONDecodeError: ded. が送出されます。

     バージョン 3.6 で変更: すべての引数は、 *note キーワード専用: 285.
     になりました。

      -- メソッド: decode (s)

          's' (*note str: 418. インスタンスで JSON 文書を含むもの) の
          Python 表現を返します。

          不正な JSON ドキュメントが与えられた場合、 *note
          JSONDecodeError: ded. が送出されます。

      -- メソッド: raw_decode (s)

          's' (*note str: 418. インスタンスで JSON 文書で始まるもの) か
          ら JSON 文書をデコードし、Python 表現と 's' の文書の終わるとこ
          ろのインデックスからなる 2 要素のタプルを返します。

          このメソッドは後ろに余分なデータを従えた文字列から JSON 文書を
          デコードするのに使えます。

 -- クラス: json.JSONEncoder (*, skipkeys=False, ensure_ascii=True,
          check_circular=True, allow_nan=True, sort_keys=False,
          indent=None, separators=None, default=None)

     Python データ構造に対する拡張可能な JSON エンコーダ。

     デフォルトでは以下のオブジェクトと型をサポートします:

     Python                                       JSON
                                                  
     -----------------------------------------------------------------
                                                  
     dict                                         object
                                                  
                                                  
     list, tuple                                  array
                                                  
                                                  
     str                                          string
                                                  
                                                  
     int、float と int や float の派生列挙型      number
                                                  
                                                  
     True                                         true
                                                  
                                                  
     False                                        false
                                                  
                                                  
     None                                         null
                                                  

     バージョン 3.4 で変更: int と float の派生列挙型クラスの対応が追加
     されました。

     このクラスを拡張して他のオブジェクトも認識するようにするには、サブ
     クラスを作って *note default(): 350d. メソッドを次のように実装しま
     す。もう一つ別のメソッドでオブジェクト ‘o’ に対する直列化可能なオブ
     ジェクトを返すものを呼び出すようにします。変換できない時はスーパー
     クラスの実装を (*note TypeError: 502. を送出させるために) 呼ばなけ
     ればなりません。

     'skipkeys' が false (デフォルト) ならば、*note str: 418, *note int:
     238, *note float: 2ce, ‘None’ 以外のキーをエンコードしようとすると
     *note TypeError: 502. を送出します。 'skipkeys' が true の場合は、
     それらのアイテムは単に読み飛ばされます。

     'ensure_ascii' が (デフォルト値の) true の場合、出力では入力された
     全ての非 ASCII 文字はエスケープされていることが保証されています。
     'ensure_ascii' が false の場合、これらの文字はそのまま出力されます
     。

     'check_circular' が true (デフォルト) ならば、リスト、辞書および自
     作でエンコードしたオブジェクトは循環参照がないかエンコード中にチェ
     ックされ、無限再帰 (これは *note RecursionError: d39. を引き起こし
     ます) を防止します。 ‘True’ でない場合は、そういったチェックは施さ
     れません。

     'allow_nan' が true (デフォルト) ならば、 ‘NaN’, ‘Infinity’,
     ‘-Infinity’ はそのままエンコードされます。この振る舞いは JSON 仕様
     に従っていませんが、大半の JavaScript ベースのエンコーダ、デコーダ
     と矛盾しません。 ‘True’ でない場合は、そのような浮動小数点数をエン
     コードすると *note ValueError: 1e3. が送出されます。

     'sort_keys' が true (デフォルトは ‘False’) ならば、辞書の出力がキー
     でソートされます。これは JSON の直列化がいつでも比較できるようにな
     るので回帰試験の際に便利です。

     'indent' が非負の整数または文字列であれば、JSON の配列要素とオブジ
     ェクトメンバはそのインデントレベルで見やすく表示されます。インデン
     トレベルが 0 か負数または ‘""’ であれば 改行だけが挿入されます。
     ‘None’ (デフォルト) では最もコンパクトな表現が選択されます。正の数
     のindentはレベル毎に、指定した数のスペースでインデントします。もし
     'indent' が文字列 (‘"\t"’ のような) であれば、その文字列が個々のレ
     ベルのインデントに使用されます。

     バージョン 3.2 で変更: 整数に加えて、文字列が 'indent' に使用できる
     ようになりました。

     'separators' はもし指定するなら ‘(item_separator, key_separator)’ と
     いうタプルでなければなりません。デフォルトは 'indent' が ‘None’ の
     とき ‘(', ', ': ')’ で、そうでなければ ‘(',', ': ')’ です。最もコン
     パクトな JSON の表現を得たければ空白を削った ‘(',', ':')’ を指定す
     ればいいでしょう。

     バージョン 3.4 で変更: 'indent' が ‘None’ でなければ ‘(',', ': ')’
     がデフォルトで使われます。

     'default' を指定する場合は関数を指定して、この関数はそれ以外では直
     列化できないオブジェクトに対して呼び出されます。 その関数は、オブジ
     ェクトを JSON でエンコードできるバージョンにして返すか、さもなけれ
     ば *note TypeError: 502. を送出しなければなりません。 指定しない場
     合は、 *note TypeError: 502. が送出されます。

     バージョン 3.6 で変更: すべての引数は、 *note キーワード専用: 285.
     になりました。

      -- メソッド: default (o)

          このメソッドをサブクラスで実装する際には 'o' に対して直列化可
          能なオブジェクトを返すか、基底クラスの実装を (*note TypeError:
          502. を送出するために) 呼び出すかします。

          例えば、任意のイテレータをサポートする場合、 *note default():
          350d. をこのように実装できます

               def default(self, o):
                  try:
                      iterable = iter(o)
                  except TypeError:
                      pass
                  else:
                      return list(iterable)
                  # Let the base class default method raise the TypeError
                  return super().default(o)

      -- メソッド: encode (o)

          Python データ構造 'o' の JSON 文字列表現を返します。たとえば:

               >>> json.JSONEncoder().encode({"foo": ["bar", "baz"]})
               '{"foo": ["bar", "baz"]}'

      -- メソッド: iterencode (o)

          与えられたオブジェクト 'o' をエンコードし、得られた文字列表現
          ごとに yield します。たとえば:

               for chunk in json.JSONEncoder().iterencode(bigobject):
                   mysocket.write(chunk)

   ---------- Footnotes ----------

   (1) https://www.jsonrpc.org


File: python.info,  Node: 例外<16>,  Next: 標準への準拠と互換性,  Prev: エンコーダとデコーダ,  Up: json --- JSON エンコーダーとデコーダー

5.19.2.3 例外
.............

 -- 例外: json.JSONDecodeError (msg, doc, pos)

     *note ValueError: 1e3. のサブクラスで、以下の追加の属性を持ちます:

      -- の属性: msg

          フォーマットされていないエラーメッセージです。

      -- の属性: doc

          パース対象 JSON ドキュメントです。

      -- の属性: pos

          'doc' の、解析に失敗した開始インデクスです。

      -- の属性: lineno

          'pos' に対応する行です。

      -- の属性: colno

          'pos' に対応する列です。

     Added in version 3.5.


File: python.info,  Node: 標準への準拠と互換性,  Next: コマンドラインインターフェイス<4>,  Prev: 例外<16>,  Up: json --- JSON エンコーダーとデコーダー

5.19.2.4 標準への準拠と互換性
.............................

The JSON format is specified by RFC 7159(1) and by ECMA-404(2).  This
section details this module's level of compliance with the RFC. For
simplicity, *note JSONEncoder: d14. and *note JSONDecoder: d15.
subclasses, and parameters other than those explicitly mentioned, are
not considered.

このモジュールは、JavaScript では正しいが JSON では不正ないくつかの拡張
が実装されているため、厳密な意味では RFC に準拠していません。特に:

   - 無限および NaN の数値を受け付け、また出力します;

   - あるオブジェクト内での同じ名前の繰り返しを受け付け、最後の名前と値
     のペアの値のみを使用します。

この RFC は、RFC 準拠のパーサが RFC 準拠でない入力テキストを受け付けるこ
とを許容しているので、このモジュールの脱直列化は技術的に言えば、デフォル
トの設定では RFC に準拠しています。

* Menu:

* 文字エンコーディング::
* 無限および NaN の数値::
* オブジェクト中に重複した名前の扱い::
* トップレベルの非オブジェクト、非配列の値の扱い::
* 実装の制限::

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc7159.html

   (2) 
https://ecma-international.org/publications-and-standards/standards/ecma-404/


File: python.info,  Node: 文字エンコーディング,  Next: 無限および NaN の数値,  Up: 標準への準拠と互換性

5.19.2.5 文字エンコーディング
.............................

RFC は、UTF-8、UTF-16、UTF-32のいずれかでJSONを表現するように要求してお
り、UTF-8 が最大の互換性を確保するために推奨されるデフォルトです。

RFC で要求ではなく許可されている通り、このモジュールのシリアライザはデフ
ォルトで 'ensure_ascii=True' という設定を用い、従って、結果の文字列が
ASCII 文字しか含まないように出力をエスケープします。

'ensure_ascii' パラメータ以外は、このモジュールは Python オブジェクトと
*note Unicode 文字列: 418. の間の変換において厳密に定義されていて、それ
以外のパラメータで文字エンコーディングに直接的に関わるものはありません。

RFC は JSON テキストの最初にバイトオーダマーク(BOM)を追加することを禁止
していますので、このモジュールはその出力に BOM を追加しません。RFC は
JSON デシリアライザが入力の一番最初の BOM を無視することを、許容はします
が求めてはいません。このモジュールのデシリアライザは一番最初の BOM を見
つけると *note ValueError: 1e3. を送出します。

RFC は JSON 文字列に正当な Unicode 文字に対応付かないバイト列(例えばペア
にならない UTF-16 サロゲートのかたわれ)が含まれることを明示的に禁止して
はおらず、もちろんこれは相互運用性の問題を引き起こします。デフォルトでは
、このモジュールは(オリジナルの *note str: 418. にある場合)そのようなシ
ーケンスのコードポイントを受け取り、出力します。


File: python.info,  Node: 無限および NaN の数値,  Next: オブジェクト中に重複した名前の扱い,  Prev: 文字エンコーディング,  Up: 標準への準拠と互換性

5.19.2.6 無限および NaN の数値
..............................

RFC は、無限もしくは NaN の数値の表現は許可していません。それにも関わら
ずデフォルトでは、このモジュールは ‘Infinity’、‘-Infinity’、‘NaN’ を正し
い JSON の数値リテラルの値であるかのように受け付け、出力します:

     >>> # Neither of these calls raises an exception, but the results are not valid JSON
     >>> json.dumps(float('-inf'))
     '-Infinity'
     >>> json.dumps(float('nan'))
     'NaN'
     >>> # Same when deserializing
     >>> json.loads('-Infinity')
     -inf
     >>> json.loads('NaN')
     nan

シリアライザでは、この振る舞いを変更するのに 'allow_nan' パラメータが使
えます。デシリアライザでは、この振る舞いを変更するのに 'parse_constant'
パラメータが使えます。


File: python.info,  Node: オブジェクト中に重複した名前の扱い,  Next: トップレベルの非オブジェクト、非配列の値の扱い,  Prev: 無限および NaN の数値,  Up: 標準への準拠と互換性

5.19.2.7 オブジェクト中に重複した名前の扱い
...........................................

RFC は JSON オブジェクト中の名前はユニークでなければならないと規定してい
ますが、JSONオブジェクトで名前が繰り返された場合の扱いについて指定してい
ません。デフォルトでは、このモジュールは例外を送出せず、かわりに重複した
名前のうち、最後に出現した名前と値のペア以外を無視します。

     >>> weird_json = '{"x": 1, "x": 2, "x": 3}'
     >>> json.loads(weird_json)
     {'x': 3}

'object_pairs_hook' パラメータでこの動作を変更できます。


File: python.info,  Node: トップレベルの非オブジェクト、非配列の値の扱い,  Next: 実装の制限,  Prev: オブジェクト中に重複した名前の扱い,  Up: 標準への準拠と互換性

5.19.2.8 トップレベルの非オブジェクト、非配列の値の扱い
.......................................................

廃止された RFC 4627(1) によって規定された古いバージョンの JSON では、
JSON テキストのトップレベルの値は JSON オブジェクトか配列(Python での
*note dict: 237. か *note list: 5dc.)であることを要求していて、JSON の
null, boolean, number, string であることは許されていませんでしたが、この
制限は RFC 7159(2) により取り払われました。このモジュールはこの制限を持
っていませんし、シリアライザでもデシリアライズでも、一度としてこの制限で
実装されたことはありません。

それにも関わらず、相互運用可能性を最大化したいならば、あなた自身の手で自
発的にその制約に忠実に従いたいと思うでしょう。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc4627.html

   (2) https://datatracker.ietf.org/doc/html/rfc7159.html


File: python.info,  Node: 実装の制限,  Prev: トップレベルの非オブジェクト、非配列の値の扱い,  Up: 標準への準拠と互換性

5.19.2.9 実装の制限
...................

いくつかの JSON デシリアライザの実装は、以下の制限を設定することがありま
す。

   * 受け入れられる JSON テキストのサイズ

   * JSON オブジェクトと配列のネストの最大の深さ

   * JSON 数値の範囲と精度

   * JSON 文字列の内容と最大の長さ

このモジュールは関連する Python データ型や Python インタプリタ自身の制約
の世界を超えたそのような制約を強要はしません。

JSON にシリアライズする際には、あなたの JSON を消費する側のアプリケーシ
ョンが持つ当該制約に思いを馳せてください。とりわけJSON 数値を IEEE 754 倍
精度浮動小数にデシリアライズする際の問題はありがちで、すなわちその有効桁
数と精度の制限の影響を受けます。これは、極端に大きな値を持った Python
*note int: 238. をシリアライズするとき、あるいは *note decimal.Decimal:
27d. のような "風変わりな" 数値型をシリアライズするとき、に特に関係があ
ります。


File: python.info,  Node: コマンドラインインターフェイス<4>,  Prev: 標準への準拠と互換性,  Up: json --- JSON エンコーダーとデコーダー

5.19.2.10 コマンドラインインターフェイス
........................................

'ソースコード:' Lib/json/tool.py(1)

__________________________________________________________________

*note json.tool: 77. モジュールは JSON オブジェクトの検証と整形出力のた
めの、単純なコマンドラインインターフェイスを提供します。

オプション引数の ‘infile’ と ‘outfile’ が指定されない場合、それぞれ
*note sys.stdin: 507. と *note sys.stdout: aa4. が使用されます。

     $ echo '{"json": "obj"}' | python -m json.tool
     {
         "json": "obj"
     }
     $ echo '{1.2:3.4}' | python -m json.tool
     Expecting property name enclosed in double quotes: line 1 column 2 (char 1)

バージョン 3.5 で変更: 出力が、入力と同じ順序になりました。辞書をキーで
アルファベット順に並べ替えた出力が欲しければ、 *note -sort-keys: 3521. オ
プションを使ってください。

* Menu:

* コマンドラインオプション: コマンドラインオプション<4>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/json/tool.py


File: python.info,  Node: コマンドラインオプション<4>,  Up: コマンドラインインターフェイス<4>

5.19.2.11 コマンドラインオプション
..................................

 -- Option: infile

     検証を行う、あるいは整形出力を行う JSON ファイルを指定します:

          $ python -m json.tool mp_films.json
          [
              {
                  "title": "And Now for Something Completely Different",
                  "year": 1971
              },
              {
                  "title": "Monty Python and the Holy Grail",
                  "year": 1975
              }
          ]

     'infile' が指定されない場合、 *note sys.stdin: 507. から読み込みま
     す。

 -- Option: outfile

     'infile' の出力を 'outfile' に書き込みます。そうでない場合、 *note
     sys.stdout: aa4. に書き込みます。

 -- Option: --sort-keys

     辞書の出力を、キーのアルファベット順にソートします。

     Added in version 3.5.

 -- Option: --no-ensure-ascii

     非 ASCII 文字のエスケープを無効化します。より詳しくは *note
     json.dumps(): d13. を参照してください。

     Added in version 3.9.

 -- Option: --json-lines

     すべての入力行を個別のJSON オブジェクトとしてパースします。

     Added in version 3.8.

 -- Option: --indent, --tab, --no-indent, --compact

     空白文字の制御のための排他的なオプション。

     Added in version 3.9.

 -- Option: -h, --help

     ヘルプメッセージを出力します

脚注
....


File: python.info,  Node: mailbox --- 様々な形式のメールボックスを操作する,  Next: mimetypes --- ファイル名を MIME タイプへマップする,  Prev: json --- JSON エンコーダーとデコーダー,  Up: インターネット上のデータの操作

5.19.3 ‘mailbox’ -- 様々な形式のメールボックスを操作する
--------------------------------------------------------

'ソースコード:' Lib/mailbox.py(1)

__________________________________________________________________

このモジュールでは二つのクラス *note Mailbox: 121d. および *note
Message: 1222. をディスク上のメールボックスとそこに収められたメッセージ
へのアクセスと操作のために定義しています。 ‘Mailbox’ は辞書のようなキー
からメッセージへの対応付けを提供しています。 ‘Message’ は *note
email.message: 3b. モジュールの *note Message: 25d. を拡張して形式ごとの
状態と振る舞いを追加しています。サポートされるメールボックスの形式は
Maildir, mbox, MH, Babyl, MMDF です。

参考
....

*note email: 32. モジュール

     メッセージの表現と操作。

* Menu:

* Mailbox オブジェクト::
* Message オブジェクト::
* 例外: 例外<17>.
* 使用例: 使用例<30>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/mailbox.py


File: python.info,  Node: Mailbox オブジェクト,  Next: Message オブジェクト,  Up: mailbox --- 様々な形式のメールボックスを操作する

5.19.3.1 ‘Mailbox’ オブジェクト
...............................

 -- クラス: mailbox.Mailbox

     メールボックス。内容を確認したり変更したりできます。

     ‘Mailbox’ クラスはインターフェースを定義するもので、インスタンス化
     されることは想定していません。代わりに、‘Mailbox’ から継承した形式
     ごとのサブクラスを作り、コードでは特定のサブクラスをインスタンス化
     するべきです。

     ‘Mailbox’ のインターフェースは辞書風で、小さなキーがメッセージに対
     応します。キーは対象となる ‘Mailbox’ インスタンスが発行するもので、
     その ‘Mailbox’ インスタンスに対してのみ意味を持ちます。一つのキーは
     一つのメッセージにひも付けられ、その対応はメッセージが他のメッセー
     ジで置き換えられるような更新をされたあとも続きます。

     メッセージを ‘Mailbox’ インスタンスに追加するには集合風のメソッド
     *note add(): 121e. を使います。また削除は ‘del’ 文または集合風の
     *note remove(): 3531. や *note discard(): 3532. を使って行ないます
     。

     ‘Mailbox’ インターフェースのセマンティクスと辞書のそれとは注意すべ
     き違いがあります。メッセージは、要求されるたびに新しい表現(典型的に
     は *note Message: 1222. インスタンス)が現在のメールボックスの状態に
     基づいて生成されます。同様に、メッセージが ‘Mailbox’ インスタンスに
     追加される時も、渡されたメッセージ表現の内容がコピーされます。どち
     らの場合も ‘Mailbox’ インスタンスにメッセージ表現への参照は保たれま
     せん。

     デフォルトの ‘Mailbox’ *note イテレータ: 191. はメッセージ表現ごと
     に繰り返すもので、*note 辞書: 237. のイテレータのようにキーごとの繰
     り返しではありません。さらに、繰り返し中のメールボックスを変更する
     ことは安全であり整合的に定義されています。イテレータが作られた後に
     メールボックスに追加されたメッセージはそのイテレータからは見えませ
     ん。そのイテレータが yield するまえにメールボックスから削除されたメ
     ッセージは黙ってスキップされますが、イテレータからのキーを使ったと
     きにはそのキーに対応するメッセージが削除されているならば *note
     KeyError: 31d. を受け取ることになります。

          警告: 十分な注意を、何か他のプロセスによっても同時に変更される
          可能性のあるメールボックスを更新する時は、払わなければなりませ
          ん。そのようなタスクをこなすのに最も安全なメールボックス形式は
          *note Maildir: 3f5. で、 *note mbox: 15e3. のような単一ファイ
          ルの形式を並行した書き込みに利用するのは避けるように努力しまし
          ょう。メールボックスを更新する場面では、 '必ず' *note lock():
          3533. と *note unlock(): 3534. メソッドを、ファイル内のメッセ
          ージを読んだり書き込んだり削除したりといった操作をする '前' に
          、呼び出してロックします。メールボックスをロックし損なうと、メ
          ッセージを失ったりメールボックス全体をぐちゃぐちゃにしたりする
          羽目に陥ります。

     ‘Mailbox’ インスタンスには次のメソッドがあります:

      -- メソッド: add (message)

          メールボックスに 'message' を追加し、それに割り当てられたキー
          を返します。

          引数 'message' は *note Message: 1222. インスタンス、 *note
          email.message.Message: 25d. インスタンス、文字列、バイト文字列
          、ファイル風オブジェクト (バイナリモードで開かれていなければな
          りません) を使えます。 'message' が適切な形式に特化した *note
          Message: 1222. サブクラスのインスタンス (例えばメールボックス
          が *note mbox: 15e3. インスタンスのときの *note mboxMessage:
          3406. インスタンス) であれば、形式ごとの情報が利用されます。そ
          うでなければ、形式ごとに必要な情報は適当なデフォルトが使われま
          す。

          バージョン 3.2 で変更: バイナリ入力のサポートが追加されました
          。

      -- メソッド: remove (key)
      -- メソッド: __delitem__ (key)
      -- メソッド: discard (key)

          メールボックスから 'key' に対応するメッセージを削除します。

          対応するメッセージが無い場合、メソッドが *note remove(): 3531.
          または *note __delitem__(): 3535. として呼び出されている時は
          *note KeyError: 31d. 例外が送出されます。しかし、 *note
          discard(): 3532. として呼び出されている場合は例外は発生しませ
          ん。基づいているメールボックス形式が別のプロセスからの平行した
          変更をサポートしているならば、この *note discard(): 3532. の振
          る舞いの方が好まれるかもしれません。

      -- メソッド: __setitem__ (key, message)

          'key' に対応するメッセージを 'message' で置き換えます。 'key'
          に対応しているメッセージが既に無くなっている場合 *note
          KeyError: 31d. 例外が送出されます。

          *note add(): 121e. と同様に、引数の 'message' には *note
          Message: 1222. インスタンス、 *note email.message.Message:
          25d. インスタンス、文字列、バイト文字列、ファイル風オブジェク
          ト (バイナリモードで開かれていなければなりません) を使えます。
          'message' が適切な形式に特化した *note Message: 1222. サブクラ
          スのインスタンス (例えばメールボックスが *note mbox: 15e3. イ
          ンスタンスのときの *note mboxMessage: 3406. インスタンス) であ
          れば、形式ごとの情報が利用されます。そうでなければ、現在 'key'
          に対応するメッセージの形式ごとの情報が変更されずに残ります。

      -- メソッド: iterkeys ()

          Return an *note iterator: 191. over all keys

      -- メソッド: keys ()

          The same as *note iterkeys(): 3537, except that a *note list:
          5dc. is returned rather than an *note iterator: 191.

      -- メソッド: itervalues ()
      -- メソッド: __iter__ ()

          全てのメッセージの表現についての *note イテレータ: 191. を返し
          ます。メッセージは適切な形式ごとの *note Message: 1222. サブク
          ラスのインスタンスとして表現されるのが普通ですが、 ‘Mailbox’ イ
          ンスタンスが初期化されるときに指定すればお好みのメッセージファ
          クトリを使うこともできます。

               注釈: *note __iter__(): 353a. は辞書のそれのようにキーに
               ついてのイテレータではありません。

      -- メソッド: values ()

          The same as *note itervalues(): 3539, except that a *note
          list: 5dc. is returned rather than an *note iterator: 191.

      -- メソッド: iteritems ()

          ('key', 'message') ペア、ただし 'key' はキーで 'message' はメ
          ッセージ表現、のイテレータを返します。メッセージは適切な形式ご
          との *note Message: 1222. サブクラスのインスタンスとして表現さ
          れるのが普通ですが、 ‘Mailbox’ インスタンスが初期化されるとき
          に指定すればお好みのメッセージファクトリを使うこともできます。

      -- メソッド: items ()

          The same as *note iteritems(): 353c, except that a *note list:
          5dc. of pairs is returned rather than an *note iterator: 191.
          of pairs.

      -- メソッド: get (key, default=None)
      -- メソッド: __getitem__ (key)

          'key' に対応するメッセージの表現を返します。対応するメッセージ
          が存在しない場合、 *note get(): 353e. として呼び出されたなら
          'default' を返しますが、 ‘__getitem__()’ として呼び出されたな
          ら *note KeyError: 31d. 例外が送出されます。メッセージは適切な
          形式ごとの *note Message: 1222. サブクラスのインスタンスとして
          表現されるのが普通ですが、 ‘Mailbox’ スタンスが初期化されると
          きに指定すればお好みのメッセージファクトリを使うこともできます
          。

      -- メソッド: get_message (key)

          'key' に対応するメッセージの表現を形式ごとの *note Message:
          1222. サブクラスのインスタンスとして返します。もし対応するメッ
          セージが存在しなければ *note KeyError: 31d. 例外が送出されます
          。

      -- メソッド: get_bytes (key)

          'key' に対応するメッセージのバイト列を返すか、そのようなメッセ
          ージが存在しない場合は *note KeyError: 31d. 例外を送出します。

          Added in version 3.2.

      -- メソッド: get_string (key)

          'key' に対応するメッセージの文字列表現を返すか、そのようなメッ
          セージが存在しない場合は *note KeyError: 31d. 例外を送出します
          。このメッセージは *note email.message.Message: 25d. を通して
          処理されて7ビットクリーンな表現へ変換されます。

      -- メソッド: get_file (key)

          'key' に対応するメッセージの表現を *note ファイル風: 24e0. 表
          現として返します。もし対応するメッセージが存在しなければ *note
          KeyError: 31d. 例外が送出されます。ファイル風オブジェクトはバ
          イナリモードで開かれているように振る舞います。このファイルは必
          要がなくなったら閉じなければなりません。

          バージョン 3.2 で変更: ファイルオブジェクトは実際は *note
          バイナリファイル: 1bf1. です; 以前は誤ってテキストモードで返さ
          れていました。 また、現在 *note ファイル風オブジェクト: 24e0.
          は *note コンテキストマネージャ: 59e. プロトコルをサポートして
          います: *note with: 59c. 文を用いることで自動的にファイルを閉
          じることができます。

               注釈: 他の表現方法とは違い、*note ファイル風: 24e0. 表現
               はそれを作り出した ‘Mailbox’ インスタンスやそれが基づいて
               いるメールボックスと独立である必要がありません。より詳細
               な説明は各サブクラスごとにあります。

      -- メソッド: __contains__ (key)

          'key' がメッセージに対応していれば ‘True’ を、そうでなければ
          ‘False’ を返します。

      -- メソッド: __len__ ()

          メールボックス中のメッセージ数を返します。

      -- メソッド: clear ()

          メールボックスから全てのメッセージを削除します。

      -- メソッド: pop (key, default=None)

          'key' に対応するメッセージの表現を返します。メッセージは適切な
          形式ごとの *note Message: 1222. サブクラスのインスタンスとして
          表現されるのが普通ですが、 ‘Mailbox’ インスタンスが初期化され
          るときに指定すればお好みのメッセージファクトリを使うこともでき
          ます。

      -- メソッド: popitem ()

          任意に選んだ ('key', 'message') ペアを返します。ただしここで
          'key' はキーで 'message' はメッセージ表現です。もしメールボッ
          クスが空ならば、 *note KeyError: 31d. 例外を送出します。メッセ
          ージは適切な形式ごとの *note Message: 1222. サブクラスのインス
          タンスとして表現されるのが普通ですが、 ‘Mailbox’ インスタンス
          が初期化されるときに指定すればお好みのメッセージファクトリを使
          うこともできます。

      -- メソッド: update (arg)

          引数 'arg' は 'key' から 'message' へのマッピングまたは
          ('key', 'message') ペアのイテレート可能オブジェクトでなければ
          なりません。メールボックスは、各 'key' と 'message' のペアにつ
          いて *note __setitem__(): 3536. を使ったかのように 'key' に対
          応するメッセージが 'message' になるように更新されます。 *note
          __setitem__(): 3536. と同様に、 'key' は既存のメールボックス中
          のメッセージに対応しているものでなければならず、そうでなければ
          *note KeyError: 31d. が送出されます。ですから、一般的には
          'arg' に ‘Mailbox’ インスタンスを渡すのは間違いです。

               注釈: 辞書と違い、キーワード引数はサポートされていません
               。

      -- メソッド: flush ()

          保留されている変更をファイルシステムに書き込みます。 *note
          Mailbox: 121d. のサブクラスによっては変更はいつも直ちにファイ
          ルに書き込まれ ‘flush()’ は何もしないということもありますが、
          それでもこのメソッドを呼ぶように習慣付けておきましょう。

      -- メソッド: lock ()

          メールボックスの排他的アドバイザリロックを取得し、他のプロセス
          が変更しないようにします。ロックが取得できない場合 *note
          ExternalClashError: 3548. が送出されます。ロック機構はメールボ
          ックス形式によって変わります。メールボックスの内容に変更を加え
          るときは 'いつも' ロックを掛けるべきです。

      -- メソッド: unlock ()

          メールボックスのロックが存在する場合は解放します。

      -- メソッド: close ()

          メールボックスをフラッシュし、必要ならばアンロックし、開いてい
          るファイルを閉じます。 ‘Mailbox’ サブクラスによっては何もしな
          いこともあります。

* Menu:

* Maildir オブジェクト::
* mbox オブジェクト::
* MH オブジェクト::
* Babyl オブジェクト::
* MMDF オブジェクト::


File: python.info,  Node: Maildir オブジェクト,  Next: mbox オブジェクト,  Up: Mailbox オブジェクト

5.19.3.2 ‘Maildir’ オブジェクト
...............................

 -- クラス: mailbox.Maildir (dirname, factory=None, create=True)

     Maildir 形式のメールボックスのための *note Mailbox: 121d. のサブク
     ラス。パラメータ 'factory' は呼び出し可能オブジェクトで (バイナリモ
     ードで開かれているかのように振る舞う)ファイル風メッセージ表現を受け
     付けて好みの表現を返すものです。 'factory' が ‘None’ ならば、 *note
     MaildirMessage: 354c. がデフォルトのメッセージ表現として使われます
     。 'create' が ‘True’ ならばメールボックスが存在しないときには作成
     します。

     'create' が ‘True’ で、パス 'dirname' が存在する場合、ディレクトリ
     レイアウトを検証せずに既存の maildir として扱います。

     'path' ではなく 'dirname' と命名される歴史的な理由のためです。

     Maildir はディレクトリ型のメールボックス形式でメール転送エージェン
     ト qmail 用に発明され、現在では多くの他のプログラムでもサポートされ
     ているものです。Maildir メールボックス中のメッセージは共通のディレ
     クトリ構造の下で個別のファイルに保存されます。このデザインにより、
     Maildir メールボックスは複数の無関係のプログラムからデータを失うこ
     となくアクセスしたり変更したりできます。そのためロックは不要です。

     Maildir メールボックスには三つのサブディレクトリ ‘tmp’, ‘new’,
     ‘cur’ があります。メッセージはまず ‘tmp’ サブディレクトリに瞬間的に
     作られた後、 ‘new’ サブディレクトリに移動されて配送を完了します。メ
     ールユーザエージェントが引き続いて ‘cur’ サブディレクトリにメッセー
     ジを移動しメッセージの状態についての情報をファイル名に追加される特
     別な "info" セクションに保存することができます。

     Courier メール転送エージェントによって導入されたスタイルのフォルダ
     もサポートされます。主たるメールボックスのサブディレクトリは ‘'.'’
     がファイル名の先頭であればフォルダと見なされます。フォルダ名は
     ‘Maildir’ によって先頭の ‘'.'’ を除いて表現されます。各フォルダはま
     た Maildir メールボックスですがさらにフォルダを含むことはできません
     。その代わり、論理的包含関係は例えば "Archived.2005.07" のような
     ‘'.'’ を使ったレベル分けで表わされます。

      -- の属性: colon

          本来の Maildir 仕様ではある種のメッセージのファイル名にコロン
          (‘':'’) を使う必要があります。しかしながら、オペレーティングシ
          ステムによってはこの文字をファイル名に含めることができないこと
          があります。そういった環境で Maildir のような形式を使いたい場
          合、代わりに使われる文字を指定する必要があります。感嘆符
          (‘'!'’) を使うのが一般的な選択です。以下の例を見てください:

               import mailbox
               mailbox.Maildir.colon = '!'

          ‘colon’ 属性はインスタンスごとにセットしても構いません。

     バージョン 3.13 で変更: *note Maildir: 3f5. now ignores files with
     a leading dot.

     ‘Maildir’ インスタンスには *note Mailbox: 121d. の全てのメソッドに
     加え以下のメソッドもあります:

      -- メソッド: list_folders ()

          全てのフォルダ名のリストを返します。

      -- メソッド: get_folder (folder)

          名前が 'folder' であるフォルダを表わす ‘Maildir’ インスタンス
          を返します。そのようなフォルダが存在しなければ *note
          NoSuchMailboxError: 3550. 例外が送出されます。

      -- メソッド: add_folder (folder)

          名前が 'folder' であるフォルダを作り、それを表わす ‘Maildir’ イ
          ンスタンスを返します。

      -- メソッド: remove_folder (folder)

          名前が 'folder' であるフォルダを削除します。もしフォルダに一つ
          でもメッセージが含まれていれば *note NotEmptyError: 3553. 例外
          が送出されフォルダは削除されません。

      -- メソッド: clean ()

          過去36時間以内にアクセスされなかったメールボックス内の一時ファ
          イルを削除します。Maildir 仕様はメールを読むプログラムはときど
          きこの作業をすべきだとしています。

      -- メソッド: get_flags (key)

          Return as a string the flags that are set on the message
          corresponding to 'key'.  This is the same as
          ‘get_message(key).get_flags()’ but much faster, because it
          does not open the message file.  Use this method when
          iterating over the keys to determine which messages are
          interesting to get.

          If you do have a *note MaildirMessage: 354c. object, use its
          *note get_flags(): 3555. method instead, because changes made
          by the message's *note set_flags(): 3556, *note add_flag():
          3557. and *note remove_flag(): 3558. methods are not reflected
          here until the mailbox's *note __setitem__(): 3559. method is
          called.

          Added in version 3.13.

      -- メソッド: set_flags (key, flags)

          On the message corresponding to 'key', set the flags specified
          by 'flags' and unset all others.  Calling
          ‘some_mailbox.set_flags(key, flags)’ is similar to

               one_message = some_mailbox.get_message(key)
               one_message.set_flags(flags)
               some_mailbox[key] = one_message

          but faster, because it does not open the message file.

          If you do have a *note MaildirMessage: 354c. object, use its
          *note set_flags(): 3556. method instead, because changes made
          with this mailbox method will not be visible to the message
          object's method, *note get_flags(): 3555.

          Added in version 3.13.

      -- メソッド: add_flag (key, flag)

          On the message corresponding to 'key', set the flags specified
          by 'flag' without changing other flags.  To add more than one
          flag at a time, 'flag' may be a string of more than one
          character.

          Considerations for using this method versus the message
          object's *note add_flag(): 3557. method are similar to those
          for *note set_flags(): 1638.; see the discussion there.

          Added in version 3.13.

      -- メソッド: remove_flag (key, flag)

          On the message corresponding to 'key', unset the flags
          specified by 'flag' without changing other flags.  To remove
          more than one flag at a time, 'flag' may be a string of more
          than one character.

          Considerations for using this method versus the message
          object's *note remove_flag(): 3558. method are similar to
          those for *note set_flags(): 1638.; see the discussion there.

          Added in version 3.13.

      -- メソッド: get_info (key)

          Return a string containing the info for the message
          corresponding to 'key'.  This is the same as
          ‘get_message(key).get_info()’ but much faster, because it does
          not open the message file.  Use this method when iterating
          over the keys to determine which messages are interesting to
          get.

          If you do have a *note MaildirMessage: 354c. object, use its
          *note get_info(): 355a. method instead, because changes made
          by the message's *note set_info(): 355b. method are not
          reflected here until the mailbox's *note __setitem__(): 3559.
          method is called.

          Added in version 3.13.

      -- メソッド: set_info (key, info)

          Set the info of the message corresponding to 'key' to 'info'.
          Calling ‘some_mailbox.set_info(key, flags)’ is similar to

               one_message = some_mailbox.get_message(key)
               one_message.set_info(info)
               some_mailbox[key] = one_message

          but faster, because it does not open the message file.

          If you do have a *note MaildirMessage: 354c. object, use its
          *note set_info(): 355b. method instead, because changes made
          with this mailbox method will not be visible to the message
          object's method, *note get_info(): 355a.

          Added in version 3.13.

     ‘Maildir’ で実装された *note Mailbox: 121d. のいくつかのメソッドに
     は特別な注意が必要です:

      -- メソッド: add (message)
      -- メソッド: __setitem__ (key, message)
      -- メソッド: update (arg)

               警告: これらのメソッドは一意的なファイル名をプロセスIDに
               基づいて生成します。複数のスレッドを使う場合は、同じメー
               ルボックスを同時に操作しないようにスレッド間で調整してお
               かないと検知されない名前の衝突が起こりメールボックスを壊
               すかもしれません。

      -- メソッド: flush ()

          Maildir メールボックスへの変更は即時に適用されるので、このメソ
          ッドは何もしません。

      -- メソッド: lock ()
      -- メソッド: unlock ()

          Maildir メールボックスはロックをサポート(または要求)しないので
          、このメソッドは何もしません。

      -- メソッド: close ()

          ‘Maildir’ インスタンスは開いたファイルを保持しませんしメールボ
          ックスはロックをサポートしませんので、このメソッドは何もしませ
          ん。

      -- メソッド: get_file (key)

          ホストのプラットフォームによっては、返されたファイルが開いてい
          る間、元になったメッセージを変更したり削除したりできない場合が
          あります。

参考
....

Courier の maildir マニュアルページ(1)

     Maildir 形式の仕様。フォルダをサポートする一般的な拡張について記述
     されています。

Using maildir format(2)

     Maildir 形式の発明者による注意書き。更新された名前生成規則と "info"
     の解釈についても含まれます。

   ---------- Footnotes ----------

   (1) https://www.courier-mta.org/maildir.html

   (2) https://cr.yp.to/proto/maildir.html


File: python.info,  Node: mbox オブジェクト,  Next: MH オブジェクト,  Prev: Maildir オブジェクト,  Up: Mailbox オブジェクト

5.19.3.3 ‘mbox’ オブジェクト
............................

 -- クラス: mailbox.mbox (path, factory=None, create=True)

     mbox 形式のメールボックスのための *note Mailbox: 121d. のサブクラス
     。パラメータ 'factory' は呼び出し可能オブジェクトで (バイナリモード
     で開かれているかのように振る舞う)ファイル風メッセージ表現を受け付け
     て好みの表現を返すものです。 'factory' が ‘None’ ならば、 *note
     mboxMessage: 3406. がデフォルトのメッセージ表現として使われます。
     'create' が ‘True’ ならばメールボックスが存在しないときには作成しま
     す。

     mbox 形式は Unixシステム上でメールを保存する古くからある形式です。
     mbox メールボックスでは全てのメッセージが一つのファイルに保存されて
     おりそれぞれのメッセージは "From " という5文字で始まる行を先頭に付
     けられています。

     mbox 形式には幾つかのバリエーションがあり、それぞれオリジナルの形式
     にあった欠点を克服すると主張しています。互換性のために、 ‘mbox’ は
     オリジナルの(時に 'mboxo' と呼ばれる) 形式を実装しています。すなわ
     ち、 ‘Content-Length’ ヘッダはもしあっても無視され、メッセージのボ
     ディにある行頭の "From " はメッセージを保存する際に ">From " に変換
     されますが、この ">From " は読み出し時にも "From " に変換されません
     。

     ‘mbox’ で実装された *note Mailbox: 121d. のいくつかのメソッドには特
     別な注意が必要です:

      -- メソッド: get_file (key)

          ‘mbox’ インスタンスに対し *note flush(): 3547. や
          meth:‘~Mailbox.close’ を呼び出した後でファイルを使用すると予期
          しない結果を引き起こしたり例外が送出されたりすることがあります
          。

      -- メソッド: lock ()
      -- メソッド: unlock ()

          3種類のロック機構が使われます -- ドットロッキングと、もし使用
          可能ならば ‘flock()’ と ‘lockf()’ システムコールです。

参考
....

tin の mbox マニュアルページ(1)

     mbox 形式の仕様でロックについての詳細を含む。

Configuring Netscape Mail on Unix: Why The Content-Length Format is Bad(2)

     バリエーションの一つではなくオリジナルの mbox を使う理由。

"mbox" は相互に互換性を持たないいくつかのメールボックスフォーマットの集まりです(3)

     mbox バリエーションの歴史。

   ---------- Footnotes ----------

   (1) http://www.tin.org/bin/man.cgi?section=5&topic=mbox

   (2) https://www.jwz.org/doc/content-length.html

   (3) 
https://www.loc.gov/preservation/digital/formats/fdd/fdd000383.shtml


File: python.info,  Node: MH オブジェクト,  Next: Babyl オブジェクト,  Prev: mbox オブジェクト,  Up: Mailbox オブジェクト

5.19.3.4 ‘MH’ オブジェクト
..........................

 -- クラス: mailbox.MH (path, factory=None, create=True)

     MH 形式のメールボックスのための *note Mailbox: 121d. のサブクラス。
     パラメータ 'factory' は呼び出し可能オブジェクトで (バイナリモードで
     開かれているかのように振る舞う)ファイル風メッセージ表現を受け付けて
     好みの表現を返すものです。 'factory' が ‘None’ ならば、 *note
     MHMessage: 356a. がデフォルトのメッセージ表現として使われます。
     'create' が ‘True’ ならばメールボックスが存在しないときには作成しま
     す。

     MH はディレクトリに基づいたメールボックス形式で MH Message Handling
     System というメールユーザエージェントのために発明されました。 MH メ
     ールボックス中のそれぞれのメッセージは一つのファイルとして収められ
     ています。 MH メールボックスにはメッセージの他に別の MH メールボッ
     クス ('フォルダ' と呼ばれます)を含んでもかまいません。フォルダは無
     限にネストできます。 MH メールボックスにはもう一つ 'シーケンス' と
     いう名前付きのリストでメッセージをサブフォルダに移動することなく論
     理的に分類するものがサポートされています。シーケンスは各フォルダの
     ‘.mh_sequences’ というファイルで定義されます。

     ‘MH’ クラスは MH メールボックスを操作しますが、 ‘mh’ の動作の全てを
     模倣しようとはしていません。特に、 ‘mh’ が状態と設定を保存する
     ‘context’ や ‘.mh_profile’ といったファイルは書き換えませんし影響も
     受けません。

     ‘MH’ インスタンスには *note Mailbox: 121d. の全てのメソッドの他に次
     のメソッドがあります:

     バージョン 3.13 で変更: Supported folders that don't contain a
     ‘.mh_sequences’ file.

      -- メソッド: list_folders ()

          全てのフォルダ名のリストを返します。

      -- メソッド: get_folder (folder)

          'folder' という名前のフォルダを表わす ‘MH’ インスタンスを返し
          ます。もしフォルダが存在しなければ *note NoSuchMailboxError:
          3550. 例外が送出されます。

      -- メソッド: add_folder (folder)

          'folder' という名前のフォルダを作成し、それを表わす ‘MH’ イン
          スタンスを返します。

      -- メソッド: remove_folder (folder)

          名前が 'folder' であるフォルダを削除します。もしフォルダに一つ
          でもメッセージが含まれていれば *note NotEmptyError: 3553. 例外
          が送出されフォルダは削除されません。

      -- メソッド: get_sequences ()

          シーケンス名をキーのリストに対応付ける辞書を返します。シーケン
          スが一つもなければ空の辞書を返します。

      -- メソッド: set_sequences (sequences)

          メールボックス中のシーケンスを *note get_sequences(): 356f. で
          返されるような名前とキーのリストを対応付ける辞書 'sequences' に
          基づいて再定義します。

      -- メソッド: pack ()

          番号付けの間隔を詰める必要に応じてメールボックス中のメッセージ
          の名前を付け替えます。シーケンスのリストのエントリもそれに応じ
          て更新されます。

               注釈: 既に発行されたキーはこの操作によって無効になるので
               それ以降使ってはなりません。

     ‘MH’ で実装された *note Mailbox: 121d. のいくつかのメソッドには特別
     な注意が必要です:

      -- メソッド: remove (key)
      -- メソッド: __delitem__ (key)
      -- メソッド: discard (key)

          これらのメソッドはメッセージを直ちに削除します。名前の前にコン
          マを付加してメッセージに削除の印を付けるという MH の規約は使い
          ません。

      -- メソッド: lock ()
      -- メソッド: unlock ()

          3種類のロック機構が使われます -- ドットロッキングと、もし使用
          可能ならば ‘flock()’ と ‘lockf()’ システムコールです。 MH メー
          ルボックスに対するロックとは ‘.mh_sequences’ のロックと、それ
          が影響を与える操作中だけの個々のメッセージファイルに対するロッ
          クを意味します。

      -- メソッド: get_file (key)

          ホストプラットフォームにより、ファイルが開かれたままの場合はメ
          ッセージを削除することができない場合があります。

      -- メソッド: flush ()

          MH メールボックスへの変更は即時に適用されますのでこのメソッド
          は何もしません。

      -- メソッド: close ()

          ‘MH’ インスタンスは開いたファイルを保持しませんのでこのメソッ
          ドは *note unlock(): 3576. と同じです。

参考
....

nmh - Message Handling System(1)

     ‘mh’ の改良版である ‘nmh’ のホームページ。

MH & nmh: Email for Users & Programmers(2)

     GPLライセンスの ‘mh’ および ‘nmh’ の本で、このメールボックス形式に
     ついての情報があります。

   ---------- Footnotes ----------

   (1) https://www.nongnu.org/nmh/

   (2) https://rand-mh.sourceforge.io/book/


File: python.info,  Node: Babyl オブジェクト,  Next: MMDF オブジェクト,  Prev: MH オブジェクト,  Up: Mailbox オブジェクト

5.19.3.5 ‘Babyl’ オブジェクト
.............................

 -- クラス: mailbox.Babyl (path, factory=None, create=True)

     Babyl 形式のメールボックスのための *note Mailbox: 121d. のサブクラ
     ス。パラメータ 'factory' は呼び出し可能オブジェクトで (バイナリモー
     ドで開かれているかのように振る舞う)ファイル風メッセージ表現を受け付
     けて好みの表現を返すものです。 'factory' が ‘None’ ならば、 *note
     BabylMessage: 357d. がデフォルトのメッセージ表現として使われます。
     'create' が ‘True’ ならばメールボックスが存在しないときには作成しま
     す。

     Babyl は単一ファイルのメールボックス形式で Emacs に付属している
     Rmail メールユーザエージェントで使われているものです。メッセージの
     開始は Control-Underscore (‘'\037'’) および Control-L (‘'\014'’) の
     二文字を含む行で示されます。メッセージの終了は次のメッセージの開始
     または最後のメッセージの場合には Control-Underscore を含む行で示さ
     れます。

     Babyl メールボックス中のメッセージには二つのヘッダのセット、オリジ
     ナルヘッダといわゆる可視ヘッダ、があります。可視ヘッダは典型的には
     オリジナルヘッダの一部を分り易いように再整形したり短くしたりしたも
     のです。 Babyl メールボックス中のそれぞれのメッセージには 'ラベル'
     というそのメッセージについての追加情報を記録する短い文字列のリスト
     を伴い、メールボックス中に見出されるユーザが定義した全てのラベルの
     リストは Babyl オプションセクションに保持されます。

     ‘Babyl’ インスタンスには *note Mailbox: 121d. の全てのメソッドの他
     に次のメソッドがあります:

      -- メソッド: get_labels ()

          メールボックスで使われているユーザが定義した全てのラベルのリス
          トを返します。

               注釈: メールボックスにどのようなラベルが存在するかを決め
               るのに、Babyl オプションセクションのリストを参考にせず、
               実際のメッセージを捜索しますが、Babyl セクションもメール
               ボックスが変更されたときにはいつでも更新されます。

     ‘Babyl’ で実装された *note Mailbox: 121d. のいくつかのメソッドには
     特別な注意が必要です:

      -- メソッド: get_file (key)

          Babyl メールボックスにおいて、メッセージのヘッダはボディと繋が
          って格納されていません。ファイル風の表現を生成するために、ヘッ
          ダとボディがファイルと同じ API を持つ *note io.BytesIO: e6d. イ
          ンスタンスに一緒にコピーされます。その結果、ファイル風オブジェ
          クトは元にしているメールボックスとは真に独立していますが、文字
          列表現と比べてメモリーを節約することにはなりません。

      -- メソッド: lock ()
      -- メソッド: unlock ()

          3種類のロック機構が使われます -- ドットロッキングと、もし使用
          可能ならば ‘flock()’ と ‘lockf()’ システムコールです。

参考
....

Format of Version 5 Babyl Files(1)

     Babyl 形式の仕様。

Reading Mail with Rmail(2)

     Rmail のマニュアルで Babyl のセマンティクスについての情報も少しある
     。

   ---------- Footnotes ----------

   (1) https://quimby.gnus.org/notes/BABYL

   (2) 
https://www.gnu.org/software/emacs/manual/html_node/emacs/Rmail.html


File: python.info,  Node: MMDF オブジェクト,  Prev: Babyl オブジェクト,  Up: Mailbox オブジェクト

5.19.3.6 ‘MMDF’ オブジェクト
............................

 -- クラス: mailbox.MMDF (path, factory=None, create=True)

     MMDF 形式のメールボックスのための *note Mailbox: 121d. のサブクラス
     。パラメータ 'factory' は呼び出し可能オブジェクトで (バイナリモード
     で開かれているかのように振る舞う)ファイル風メッセージ表現を受け付け
     て好みの表現を返すものです。 'factory' が ‘None’ ならば、 *note
     MMDFMessage: 3584. がデフォルトのメッセージ表現として使われます。
     'create' が ‘True’ ならばメールボックスが存在しないときには作成しま
     す。

     MMDF は単一ファイルのメールボックス形式で Multichannel Memorandum
     Distribution Facility というメール転送エージェント用に発明されたも
     のです。各メッセージは mbox と同様の形式で収められますが、前後を4つ
     の Control-A (‘'\001'’) を含む行で挟んであります。mbox 形式と同じよ
     うにそれぞれのメッセージの開始は "From " の5文字を含む行で示されま
     すが、それ以外の場所での "From " は格納の際 ">From " には変えられま
     せん。それは追加されたメッセージ区切りによって新たなメッセージの開
     始と見間違うことが避けられるからです。

     ‘MMDF’ で実装された *note Mailbox: 121d. のいくつかのメソッドには特
     別な注意が必要です:

      -- メソッド: get_file (key)

          ‘MMDF’ インスタンスに対し *note flush(): 3547. や
          meth:‘~Mailbox.close’ を呼び出した後でファイルを使用すると予期
          しない結果を引き起こしたり例外が送出されたりすることがあります
          。

      -- メソッド: lock ()
      -- メソッド: unlock ()

          3種類のロック機構が使われます -- ドットロッキングと、もし使用
          可能ならば ‘flock()’ と ‘lockf()’ システムコールです。

参考
....

mmdf man page from tin(1)

     ニュースリーダ tin のドキュメント中の MMDF 形式仕様。

MMDF(2)

     Multichannel Memorandum Distribution Facility についてのウィキペデ
     ィアの記事。

   ---------- Footnotes ----------

   (1) http://www.tin.org/bin/man.cgi?section=5&topic=mmdf

   (2) https://en.wikipedia.org/wiki/MMDF


File: python.info,  Node: Message オブジェクト,  Next: 例外<17>,  Prev: Mailbox オブジェクト,  Up: mailbox --- 様々な形式のメールボックスを操作する

5.19.3.7 ‘Message’ オブジェクト
...............................

 -- クラス: mailbox.Message (message=None)

     *note email.message: 3b. モジュールの *note Message: 25d. のサブク
     ラス。 ‘mailbox.Message’ のサブクラスはメールボックス形式ごとの状態
     と動作を追加します。

     'message' が省略された場合、新しいインスタンスはデフォルトの空の状
     態で生成されます。 'message' が *note email.message.Message: 25d. イ
     ンスタンスならばその内容がコピーされます。さらに、 'message' が
     ‘Message’ インスタンスならば、形式固有の情報も可能な限り変換されま
     す。 'message' が文字列かバイト列またはファイルならば、読まれ解析さ
     れるべき RFC 2822(1) 準拠のメッセージを含んでいなければなりません。
     ファイルはバイナリモードで開かれているべきですが、後方互換性のため
     テキストモードファイルも受け付けます。

     サブクラスにより提供される形式ごとの状態と動作は様々ですが、一般に
     或るメールボックスに固有のものでないプロパティだけがサポートされま
     す(おそらくプロパティのセットはメールボックス形式ごとに固有でしょう
     が)。例えば、単一ファイルメールボックス形式におけるファイルオフセッ
     トやディレクトリ式メールボックス形式におけるファイル名は保持されま
     せん、というのもそれらは元々のメールボックスにしか適用できないから
     です。しかし、メッセージがユーザに読まれたかどうかあるいは重要だと
     マークされたかどうかという状態は保持されます、というのはそれらはメ
     ッセージ自体に適用されるからです。

     *note Mailbox: 121d. インスタンスを使って取得したメッセージを表現す
     るのに ‘Message’ インスタンスが使われなければいけないとは要求してい
     ません。ある種の状況では ‘Message’ による表現を生成するのに必要な時
     間やメモリーが受け入れられないこともあります。そういった状況では
     ‘Mailbox’ インスタンスは文字列やファイル風オブジェクトの表現も提供
     できますし、 ‘Mailbox’ インスタンスを初期化する際にメッセージファク
     トリーを指定することもできます。

* Menu:

* MaildirMessage オブジェクト::
* mboxMessage オブジェクト::
* MHMessage オブジェクト::
* BabylMessage オブジェクト::
* MMDFMessage オブジェクト::

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2822.html


File: python.info,  Node: MaildirMessage オブジェクト,  Next: mboxMessage オブジェクト,  Up: Message オブジェクト

5.19.3.8 ‘MaildirMessage’ オブジェクト
......................................

 -- クラス: mailbox.MaildirMessage (message=None)

     Maildir 固有の動作をするメッセージ。引数 'message' は *note
     Message: 1222. のコンストラクタと同じ意味を持ちます。

     通常、メールユーザエージェントは ‘new’ サブディレクトリにある全ての
     メッセージをユーザが最初にメールボックスを開くか閉じるかした後で
     ‘cur’ サブディレクトリに移動し、メッセージが実際に読まれたかどうか
     を記録します。 ‘cur’ にある各メッセージには状態情報を保存するファイ
     ル名に付け加えられた "info" セクションがあります。(メールリーダの中
     には "info" セクションを ‘new’ にあるメッセージに付けることもありま
     す。) "info" セクションには二つの形式があります。一つは "2," の後に
     標準化されたフラグのリストを付けたもの (たとえば "2,FR")、もう一つ
     は "1," の後にいわゆる実験的情報を付け加えるものです。 Maildir の標
     準的なフラグは以下の通りです:

     Flag       意味          説明
                              
     --------------------------------------------------------------
                              
     D          ドラフト      作成中
                (Draft)       
                
                              
     F          フラグ付き    重要とされたもの
                (Flagged)     
                
                              
     P          通過          転送、再送またはバウンス
                (Passed)      
                
                              
     R          返答済み      返答されたもの
                (Replied)     
                
                              
     S          既読(Seen)    読んだもの
                              
                              
     T          ごみ          削除予定とされたもの
                (Trashed)     
                

     ‘MaildirMessage’ インスタンスは以下のメソッドを提供します:

      -- メソッド: get_subdir ()

          "new" (メッセージが ‘new’ サブディレクトリに保存されるべき場合
          ) または "cur" (メッセージが ‘cur’ サブディレクトリに保存され
          るべき場合)のどちらかを返します。

               注釈: メッセージは通常メールボックスがアクセスされた後、
               メッセージが読まれたかどうかに関わらず ‘new’ から ‘cur’ に
               移動されます。メッセージ ‘msg’ は ‘"S" in
               msg.get_flags()’ が ‘True’ ならば読まれています。

      -- メソッド: set_subdir (subdir)

          メッセージが保存されるべきサブディレクトリをセットします。パラ
          メータ 'subdir' は "new" または "cur" のいずれかでなければなり
          ません。

      -- メソッド: get_flags ()

          現在セットされているフラグを特定する文字列を返します。メッセー
          ジが標準 Maildir 形式に準拠しているならば、結果はアルファベッ
          ト順に並べられたゼロまたは1回の ‘'D'’、‘'F'’、‘'P'’、‘'R'’、
          ‘'S'’、‘'T'’ をつなげたものです。空文字列が返されるのはフラグ
          が一つもない場合、または "info" が実験的セマンティクスを使って
          いる場合です。

      -- メソッド: set_flags (flags)

          'flags' で指定されたフラグをセットし、他のフラグは下ろします。

      -- メソッド: add_flag (flag)

          'flag' で指定されたフラグをセットしますが他のフラグは変えませ
          ん。一度に二つ以上のフラグをセットすることは、'flag' に2文字以
          上の文字列を指定すればできます。現在の "info" はフラグの代わり
          に実験的情報を使っていても上書きされます。

      -- メソッド: remove_flag (flag)

          'flag' で指定されたフラグを下ろしますが他のフラグは変えません
          。一度に二つ以上のフラグを取り除くことは、'flag' に2文字以上の
          文字列を指定すればできます。"info" がフラグの代わりに実験的情
          報を使っている場合は現在の "info" は書き換えられません。

      -- メソッド: get_date ()

          メッセージの配送日時をエポックからの秒数を表わす浮動小数点数で
          返します。

      -- メソッド: set_date (date)

          メッセージの配送日時を 'date' にセットします。'date' はエポッ
          クからの秒数を表わす浮動小数点数です。

      -- メソッド: get_info ()

          メッセージの "info" を含む文字列を返します。このメソッドは実験
          的 (即ちフラグのリストでない) "info" にアクセスし、また変更す
          るのに役立ちます。

      -- メソッド: set_info (info)

          "info" に文字列 'info' をセットします。

‘MaildirMessage’ インスタンスが *note mboxMessage: 3406. や *note
MMDFMessage: 3584. のインスタンスに基づいて生成されるとき、 ‘Status’ お
よび ‘X-Status’ ヘッダは省かれ以下の変換が行われます:

結果の状態               *note mboxMessage: 3406. または
                         *note MMDFMessage: 3584. の状態
                         
----------------------------------------------------------------------------
                         
"cur" サブディレクトリ   O フラグ
                         
                         
F フラグ                 F フラグ
                         
                         
R フラグ                 A フラグ
                         
                         
S フラグ                 R フラグ
                         
                         
T フラグ                 D フラグ
                         

‘MaildirMessage’ インスタンスが *note MHMessage: 356a. インスタンスに基
づいて生成されるとき、以下の変換が行われます:

結果の状態                          *note MHMessage: 356a. の状
                                    態
                                    
-------------------------------------------------------------------
                                    
"cur" サブディレクトリ              "unseen" シーケンス
                                    
                                    
"cur" サブディレクトリおよび S フ   "unseen" シーケンス無し
ラグ                                

F フラグ                            "flagged" シーケンス
                                    
                                    
R フラグ                            "replied" シーケンス
                                    

‘MaildirMessage’ インスタンスが *note BabylMessage: 357d. インスタンスに
基づいて生成されるとき、以下の変換が行われます:

結果の状態                          *note BabylMessage: 357d. の状態
                                    
------------------------------------------------------------------------
                                    
"cur" サブディレクトリ              "unseen" ラベル
                                    
                                    
"cur" サブディレクトリおよび S フ   "unseen" ラベル無し
ラグ                                

P フラグ                            "forwarded" または "resent" ラベ
                                    ル
                                    
                                    
R フラグ                            "answered" ラベル
                                    
                                    
T フラグ                            "deleted" ラベル
                                    


File: python.info,  Node: mboxMessage オブジェクト,  Next: MHMessage オブジェクト,  Prev: MaildirMessage オブジェクト,  Up: Message オブジェクト

5.19.3.9 ‘mboxMessage’ オブジェクト
...................................

 -- クラス: mailbox.mboxMessage (message=None)

     mbox 固有の動作をするメッセージ。引数 'message' は *note Message:
     1222. のコンストラクタと同じ意味を持ちます。

     mbox メールボックス中のメッセージは単一ファイルにまとめて格納されて
     います。送り主のエンベロープアドレスおよび配送日時は通常メッセージ
     の開始を示す "From " から始まる行に記録されますが、正確なフォーマッ
     トに関しては mbox の実装ごとに大きな違いがあります。メッセージの状
     態を示すフラグ、たとえば読んだかどうかあるいは重要だとマークを付け
     られているかどうかといったようなもの、は典型的には ‘Status’ および
     ‘X-Status’ に収められます。

     規定されている mbox メッセージのフラグは以下の通りです:

     Flag       意味           説明
                               
     ---------------------------------------------------------------
                               
     R          読んだもの     読んだもの
                               
                               
     O          古い(Old)      以前に MUA に発見された
                               
                               
     D          削除           削除予定とされたもの
                (Deleted)      
                
                               
     F          フラグ付き     重要とされたもの
                (Flagged)      
                
                               
     A          返答済み       返答されたもの
                (Answered)     
                

     "R" および "O" フラグは ‘Status’ ヘッダに記録され、 "D"、"F"、"A" フ
     ラグは ‘X-Status’ ヘッダに記録されます。フラグとヘッダは通常記述さ
     れた順番に出現します。

     ‘mboxMessage’ インスタンスは以下のメソッドを提供します:

      -- メソッド: get_from ()

          mbox メールボックスのメッセージの開始を示す "From " 行を表わす
          文字列を返します。先頭の "From " および末尾の改行は含まれませ
          ん。

      -- メソッド: set_from (from_, time_=None)

          "From " 行を 'from_' にセットします。 'from_' は先頭の "From "
          や末尾の改行を含まない形で指定しなければなりません。利便性のた
          めに、 'time_' を指定して適切に整形して 'from_' に追加させるこ
          とができます。 'time_' を指定する場合、それは *note
          time.struct_time: cb8. インスタンス、 *note time.strftime():
          11ba. に渡すのに適したタプル、または ‘True’ (この場合 *note
          time.gmtime(): 1190. を使います) のいずれかでなければなりませ
          ん。

      -- メソッド: get_flags ()

          現在セットされているフラグを特定する文字列を返します。メッセー
          ジが規定された形式に準拠しているならば、結果は次の順に並べられ
          た 0回か1回の ‘'R'’、‘'O'’、‘'D'’、‘'F'’、‘'A'’ です。

      -- メソッド: set_flags (flags)

          'flags' で指定されたフラグをセットして、他のフラグは下ろします
          。'flags' は並べられたゼロまたは1回の ‘'R'’、‘'O'’、‘'D'’、
          ‘'F'’、‘'A'’ です。

      -- メソッド: add_flag (flag)

          'flag' で指定されたフラグをセットしますが他のフラグは変えませ
          ん。一度に二つ以上のフラグをセットすることは、'flag' に2文字以
          上の文字列を指定すればできます。

      -- メソッド: remove_flag (flag)

          'flag' で指定されたフラグを下ろしますが他のフラグは変えません
          。一二つ以上のフラグを取り除くことは、'flag' に2文字以上の文字
          列を指定すればできます。

‘mboxMessage’ インスタンスが *note MaildirMessage: 354c. インスタンスに
基づいて生成されるとき、 *note MaildirMessage: 354c. インスタンスの配送
日時に基づいて "From " 行が作り出され、次の変換が行われます:

結果の状態            *note MaildirMessage: 354c. の状
                      態
                      
----------------------------------------------------------
                      
R フラグ              S フラグ
                      
                      
O フラグ              "cur" サブディレクトリ
                      
                      
D フラグ              T フラグ
                      
                      
F フラグ              F フラグ
                      
                      
A フラグ              R フラグ
                      

‘mboxMessage’ インスタンスが *note MHMessage: 356a. インスタンスに基づい
て生成されるとき、以下の変換が行われます:

結果の状態              *note MHMessage: 356a. の状
                        態
                        
-------------------------------------------------------
                        
R フラグおよび O フラ   "unseen" シーケンス無し
グ                      

O フラグ                "unseen" シーケンス
                        
                        
F フラグ                "flagged" シーケンス
                        
                        
A フラグ                "replied" シーケンス
                        

‘mboxMessage’ インスタンスが *note BabylMessage: 357d. インスタンスに基
づいて生成されるとき、以下の変換が行われます:

結果の状態              *note BabylMessage: 357d. の状
                        態
                        
----------------------------------------------------------
                        
R フラグおよび O フラ   "unseen" ラベル無し
グ                      

O フラグ                "unseen" ラベル
                        
                        
D フラグ                "deleted" ラベル
                        
                        
A フラグ                "answered" ラベル
                        

‘mboxMessage’ インスタンスが *note MMDFMessage: 3584. インスタンスに基づ
いて生成されるとき、"From " 行はコピーされ全てのフラグは直接対応します:

結果の状態            *note MMDFMessage: 3584. の状
                      態
                      
-------------------------------------------------------
                      
R フラグ              R フラグ
                      
                      
O フラグ              O フラグ
                      
                      
D フラグ              D フラグ
                      
                      
F フラグ              F フラグ
                      
                      
A フラグ              A フラグ
                      


File: python.info,  Node: MHMessage オブジェクト,  Next: BabylMessage オブジェクト,  Prev: mboxMessage オブジェクト,  Up: Message オブジェクト

5.19.3.10 ‘MHMessage’ オブジェクト
..................................

 -- クラス: mailbox.MHMessage (message=None)

     MH 固有の動作をするメッセージ。引数 'message' は *note Message:
     1222. のコンストラクタと同じ意味を持ちます。

     MH メッセージは伝統的な意味あいにおいてマークやフラグをサポートしま
     せん。しかし、MH メッセージにはシーケンスがあり任意のメッセージを論
     理的にグループ分けできます。いくつかのメールソフト(標準の ‘mh’ や
     ‘nmh’ はそうではありませんが) は他の形式におけるフラグとほぼ同じよ
     うにシーケンスを使います:

     シーケンス     説明
                    
     --------------------------------------------------------------
                    
     unseen         読んではいないが既にMUAに見つけられている
                    
                    
     replied        返答されたもの
                    
                    
     flagged        重要とされたもの
                    

     ‘MHMessage’ インスタンスは以下のメソッドを提供します:

      -- メソッド: get_sequences ()

          このメッセージを含むシーケンスの名前のリストを返す。

      -- メソッド: set_sequences (sequences)

          このメッセージを含むシーケンスのリストをセットする。

      -- メソッド: add_sequence (sequence)

          'sequence' をこのメッセージを含むシーケンスのリストに追加する
          。

      -- メソッド: remove_sequence (sequence)

          'sequence' をこのメッセージを含むシーケンスのリストから除く。

‘MHMessage’ インスタンスが *note MaildirMessage: 354c. インスタンスに基
づいて生成されるとき、以下の変換が行われます:

結果の状態               *note MaildirMessage: 354c. の状
                         態
                         
-------------------------------------------------------------
                         
"unseen" シーケンス      S フラグ無し
                         
                         
"replied" シーケンス     R フラグ
                         
                         
"flagged" シーケンス     F フラグ
                         

‘MHMessage’ インスタンスが *note mboxMessage: 3406. や *note
MMDFMessage: 3584. のインスタンスに基づいて生成されるとき、 ‘Status’ お
よび ‘X-Status’ ヘッダは省かれ以下の変換が行われます:

結果の状態               *note mboxMessage: 3406. または
                         *note MMDFMessage: 3584. の状態
                         
----------------------------------------------------------------------------
                         
"unseen" シーケンス      R フラグ無し
                         
                         
"replied" シーケンス     A フラグ
                         
                         
"flagged" シーケンス     F フラグ
                         

‘MHMessage’ インスタンスが *note BabylMessage: 357d. インスタンスに基づ
いて生成されるとき、以下の変換が行われます:

結果の状態               *note BabylMessage: 357d. の状
                         態
                         
-----------------------------------------------------------
                         
"unseen" シーケンス      "unseen" ラベル
                         
                         
"replied" シーケンス     "answered" ラベル
                         


File: python.info,  Node: BabylMessage オブジェクト,  Next: MMDFMessage オブジェクト,  Prev: MHMessage オブジェクト,  Up: Message オブジェクト

5.19.3.11 ‘BabylMessage’ オブジェクト
.....................................

 -- クラス: mailbox.BabylMessage (message=None)

     Babyl 固有の動作をするメッセージ。引数 'message' は *note Message:
     1222. のコンストラクタと同じ意味を持ちます。

     ある種のメッセージラベルは 'アトリビュート' と呼ばれ、規約により特
     別な意味が与えられています。アトリビュートは以下の通りです:

     ラベル          説明
                     
     ---------------------------------------------------------------
                     
     unseen          読んではいないが既にMUAに見つけられている
                     
                     
     deleted         削除予定とされたもの
                     
                     
     filed           他のファイルまたはメールボックスにコピーされ
                     た
                     
                     
     answered        返答されたもの
                     
                     
     forwarded       転送された
                     
                     
     edited          ユーザによって変更された
                     
                     
     resent          再送された
                     

     デフォルトでは Rmail は可視ヘッダのみ表示します。 ‘BabylMessage’ ク
     ラスはしかし、オリジナルヘッダをより完全だという理由で使います。可
     視ヘッダは望むならそのように指示してアクセスすることができます。

     ‘BabylMessage’ インスタンスは以下のメソッドを提供します:

      -- メソッド: get_labels ()

          メッセージに付いているラベルのリストを返します。

      -- メソッド: set_labels (labels)

          メッセージに付いているラベルのリストを 'labels' にセットします
          。

      -- メソッド: add_label (label)

          メッセージに付いているラベルのリストに 'label' を追加します。

      -- メソッド: remove_label (label)

          メッセージに付いているラベルのリストから 'label' を削除します
          。

      -- メソッド: get_visible ()

          ヘッダがメッセージの可視ヘッダでありボディが空であるような
          *note Message: 1222. インスタンスを返します。

      -- メソッド: set_visible (visible)

          メッセージの可視ヘッダを 'visible' のヘッダと同じにセットしま
          す。引数 'visible' は *note Message: 1222. インスタンスまたは
          *note email.message.Message: 25d. インスタンス、文字列、ファイ
          ル風オブジェクト(テキストモードで開かれてなければなりません)の
          いずれかです。

      -- メソッド: update_visible ()

          ‘BabylMessage’ インスタンスのオリジナルヘッダが変更されたとき
          、可視ヘッダは自動的に対応して変更されるわけではありません。こ
          のメソッドは可視ヘッダを以下のように更新します。対応するオリジ
          ナルヘッダのある可視ヘッダはオリジナルヘッダの値がセットされま
          す。対応するオリジナルヘッダの無い可視ヘッダは除去されます。そ
          して、オリジナルヘッダにあって可視ヘッダに無い ‘Date’ 、
          ‘From’ 、 ‘Reply-To’ 、 ‘To’ 、 ‘CC’ 、 ‘Subject’ は可視ヘッダ
          に追加されます。

‘BabylMessage’ インスタンスが *note MaildirMessage: 354c. インスタンスに
基づいて生成されるとき、以下の変換が行われます:

結果の状態              *note MaildirMessage: 354c. の状
                        態
                        
------------------------------------------------------------
                        
"unseen" ラベル         S フラグ無し
                        
                        
"deleted" ラベル        T フラグ
                        
                        
"answered" ラベル       R フラグ
                        
                        
"forwarded" ラベル      P フラグ
                        

‘BabylMessage’ インスタンスが *note mboxMessage: 3406. や *note
MMDFMessage: 3584. のインスタンスに基づいて生成されるとき、 ‘Status’ お
よび ‘X-Status’ ヘッダは省かれ以下の変換が行われます:

結果の状態             *note mboxMessage: 3406. または
                       *note MMDFMessage: 3584. の状態
                       
--------------------------------------------------------------------------
                       
"unseen" ラベル        R フラグ無し
                       
                       
"deleted" ラベル       D フラグ
                       
                       
"answered" ラベル      A フラグ
                       

‘BabylMessage’ インスタンスが *note MHMessage: 356a. インスタンスに基づ
いて生成されるとき、以下の変換が行われます:

結果の状態             *note MHMessage: 356a. の状
                       態
                       
------------------------------------------------------
                       
"unseen" ラベル        "unseen" シーケンス
                       
                       
"answered" ラベル      "replied" シーケンス
                       


File: python.info,  Node: MMDFMessage オブジェクト,  Prev: BabylMessage オブジェクト,  Up: Message オブジェクト

5.19.3.12 ‘MMDFMessage’ オブジェクト
....................................

 -- クラス: mailbox.MMDFMessage (message=None)

     MMDF 固有の動作をするメッセージ。引数 'message' は *note Message:
     1222. のコンストラクタと同じ意味を持ちます。

     mbox メールボックスのメッセージと同様に、MMDF メッセージは送り主の
     アドレスと配送日時が最初の "From " で始まる行に記録されています。同
     様に、メッセージの状態を示すフラグは通常 ‘Status’ および ‘X-Status’
     ヘッダに収められています。

     よく使われる MMDF メッセージのフラグは mbox メッセージのものと同一
     で以下の通りです:

     Flag       意味           説明
                               
     ---------------------------------------------------------------
                               
     R          読んだもの     読んだもの
                               
                               
     O          古い(Old)      以前に MUA に発見された
                               
                               
     D          削除           削除予定とされたもの
                (Deleted)      
                
                               
     F          フラグ付き     重要とされたもの
                (Flagged)      
                
                               
     A          返答済み       返答されたもの
                (Answered)     
                

     "R" および "O" フラグは ‘Status’ ヘッダに記録され、 "D"、"F"、"A" フ
     ラグは ‘X-Status’ ヘッダに記録されます。フラグとヘッダは通常記述さ
     れた順番に出現します。

     ‘MMDFMessage’ インスタンスは *note mboxMessage: 3406. インスタンス
     と同一の以下のメソッドを提供します:

      -- メソッド: get_from ()

          mbox メールボックスのメッセージの開始を示す "From " 行を表わす
          文字列を返します。先頭の "From " および末尾の改行は含まれませ
          ん。

      -- メソッド: set_from (from_, time_=None)

          "From " 行を 'from_' にセットします。 'from_' は先頭の "From "
          や末尾の改行を含まない形で指定しなければなりません。利便性のた
          めに、 'time_' を指定して適切に整形して 'from_' に追加させるこ
          とができます。 'time_' を指定する場合、それは *note
          time.struct_time: cb8. インスタンス、 *note time.strftime():
          11ba. に渡すのに適したタプル、または ‘True’ (この場合 *note
          time.gmtime(): 1190. を使います) のいずれかでなければなりませ
          ん。

      -- メソッド: get_flags ()

          現在セットされているフラグを特定する文字列を返します。メッセー
          ジが規定された形式に準拠しているならば、結果は次の順に並べられ
          た 0回か1回の ‘'R'’、‘'O'’、‘'D'’、‘'F'’、‘'A'’ です。

      -- メソッド: set_flags (flags)

          'flags' で指定されたフラグをセットして、他のフラグは下ろします
          。'flags' は並べられたゼロまたは1回の ‘'R'’、‘'O'’、‘'D'’、
          ‘'F'’、‘'A'’ です。

      -- メソッド: add_flag (flag)

          'flag' で指定されたフラグをセットしますが他のフラグは変えませ
          ん。一度に二つ以上のフラグをセットすることは、'flag' に2文字以
          上の文字列を指定すればできます。

      -- メソッド: remove_flag (flag)

          'flag' で指定されたフラグを下ろしますが他のフラグは変えません
          。一二つ以上のフラグを取り除くことは、'flag' に2文字以上の文字
          列を指定すればできます。

‘MMDFMessage’ インスタンスが *note MaildirMessage: 354c. インスタンスに
基づいて生成されるとき、"From"行が *note MaildirMessage: 354c. インスタ
ンスの配信日をもとに生成され、以下の変換が行われます:

結果の状態            *note MaildirMessage: 354c. の状
                      態
                      
----------------------------------------------------------
                      
R フラグ              S フラグ
                      
                      
O フラグ              "cur" サブディレクトリ
                      
                      
D フラグ              T フラグ
                      
                      
F フラグ              F フラグ
                      
                      
A フラグ              R フラグ
                      

 ‘MMDFMessage’ インスタンスが *note MHMessage: 356a. インスタンスに基づ
いて生成されるとき、以下の変換が行われます:

結果の状態              *note MHMessage: 356a. の状
                        態
                        
-------------------------------------------------------
                        
R フラグおよび O フラ   "unseen" シーケンス無し
グ                      

O フラグ                "unseen" シーケンス
                        
                        
F フラグ                "flagged" シーケンス
                        
                        
A フラグ                "replied" シーケンス
                        

‘MMDFMessage’ インスタンスが *note BabylMessage: 357d. インスタンスに基
づいて生成されるとき、以下の変換が行われます:

結果の状態              *note BabylMessage: 357d. の状
                        態
                        
----------------------------------------------------------
                        
R フラグおよび O フラ   "unseen" ラベル無し
グ                      

O フラグ                "unseen" ラベル
                        
                        
D フラグ                "deleted" ラベル
                        
                        
A フラグ                "answered" ラベル
                        

‘MMDFMessage’ インスタンスが *note mboxMessage: 3406. インスタンスに基づ
いて生成されるとき、"From"行がコピーされ、全てのフラグが直接対応します:

結果の状態            *note mboxMessage: 3406. の状
                      態
                      
-------------------------------------------------------
                      
R フラグ              R フラグ
                      
                      
O フラグ              O フラグ
                      
                      
D フラグ              D フラグ
                      
                      
F フラグ              F フラグ
                      
                      
A フラグ              A フラグ
                      


File: python.info,  Node: 例外<17>,  Next: 使用例<30>,  Prev: Message オブジェクト,  Up: mailbox --- 様々な形式のメールボックスを操作する

5.19.3.13 例外
..............

‘mailbox’ モジュールでは以下の例外クラスが定義されています:

 -- 例外: mailbox.Error

     他の全てのモジュール固有の例外の基底クラス。

 -- 例外: mailbox.NoSuchMailboxError

     メールボックスがあると思っていたが見つからなかった場合に送出されま
     す。これはたとえば *note Mailbox: 121d. のサブクラスを存在しないパ
     スでインスタンス化しようとしたとき(かつ 'create' パラメータは
     ‘False’ であった場合)、あるいは存在しないフォルダを開こうとした時な
     どに発生します。

 -- 例外: mailbox.NotEmptyError

     メールボックスが空であることを期待されているときに空でない場合、た
     とえばメッセージの残っているフォルダを削除しようとした時などに送出
     されます。

 -- 例外: mailbox.ExternalClashError

     メールボックスに関係したある条件がプログラムの制御を外れてそれ以上
     作業を続けられなくなった場合、たとえば他のプログラムが既に保持して
     いるロックを取得しようとして失敗したとき、あるいは一意的に生成され
     たファイル名が既に存在していた場合などに送出されます。

 -- 例外: mailbox.FormatError

     ファイル中のデータが解析できない場合、たとえば *note MH: 161a. イン
     スタンスが壊れた ‘.mh_sequences’ ファイルを読もうと試みた場合などに
     送出されます。


File: python.info,  Node: 使用例<30>,  Prev: 例外<17>,  Up: mailbox --- 様々な形式のメールボックスを操作する

5.19.3.14 使用例
................

メールボックス中の面白そうなメッセージのサブジェクトを全て印字する簡単な
例:

     import mailbox
     for message in mailbox.mbox('~/mbox'):
         subject = message['subject']       # Could possibly be None.
         if subject and 'python' in subject.lower():
             print(subject)

Babyl メールボックスから MH メールボックスへ全てのメールをコピーし、変換
可能な全ての形式固有の情報を変換する:

     import mailbox
     destination = mailbox.MH('~/Mail')
     destination.lock()
     for message in mailbox.Babyl('~/RMAIL'):
         destination.add(mailbox.MHMessage(message))
     destination.flush()
     destination.unlock()

この例は幾つかのメーリングリストのメールをソートするものです。他のプログ
ラムと平行して変更を加えることでメールが破損したり、プログラムを中断する
ことでメールを失ったり、はたまた半端なメッセージがメールボックス中にある
ことで途中で終了してしまう、といったことを避けるように注意深く扱っていま
す:

     import mailbox
     import email.errors

     list_names = ('python-list', 'python-dev', 'python-bugs')

     boxes = {name: mailbox.mbox('~/email/%s' % name) for name in list_names}
     inbox = mailbox.Maildir('~/Maildir', factory=None)

     for key in inbox.iterkeys():
         try:
             message = inbox[key]
         except email.errors.MessageParseError:
             continue                # The message is malformed. Just leave it.

         for name in list_names:
             list_id = message['list-id']
             if list_id and name in list_id:
                 # Get mailbox to use
                 box = boxes[name]

                 # Write copy to disk before removing original.
                 # If there's a crash, you might duplicate a message, but
                 # that's better than losing a message completely.
                 box.lock()
                 box.add(message)
                 box.flush()
                 box.unlock()

                 # Remove original message
                 inbox.lock()
                 inbox.discard(key)
                 inbox.flush()
                 inbox.unlock()
                 break               # Found destination, so stop looking.

     for box in boxes.itervalues():
         box.close()


File: python.info,  Node: mimetypes --- ファイル名を MIME タイプへマップする,  Next: base64 --- Base16 Base32 Base64 Base85 データのエンコード,  Prev: mailbox --- 様々な形式のメールボックスを操作する,  Up: インターネット上のデータの操作

5.19.4 ‘mimetypes’ -- ファイル名を MIME タイプへマップする
----------------------------------------------------------

'ソースコード:' Lib/mimetypes.py(1)

__________________________________________________________________

*note mimetypes: 82. モジュールは、ファイル名あるいは URL と、ファイル名
拡張子に関連付けられた MIME 型とを変換します。ファイル名から MIME 型へと
、 MIME 型からファイル名拡張子への変換が提供されます; 後者の変換では符号
化方式はサポートされていません。

このモジュールは、一つのクラスと多くの便利な関数を提供します。これらの関
数がこのモジュールへの標準のインターフェースですが、アプリケーションによ
っては、そのクラスにも関係するかもしれません。

以下で説明されている関数は、このモジュールへの主要なインターフェースを提
供します。たとえモジュールが初期化されていなくても、もしこれらの関数が、
*note init(): 35b6. がセットアップする情報に依存していれば、これらの関数
は、 *note init(): 35b6. を呼びます。

 -- の関数: mimetypes.guess_type (url, strict=True)

     'url' で与えられるファイル名あるいは URL に基づいて、ファイルの型を
     推定します。URL は文字列または *note path-like object: 280. です。

     戻り値は、タプル ‘(type, encoding)’ です、ここで 'type' は、もし型
     が(拡張子がないあるいは未定義のため)推定できない場合は、 ‘None’ を
     、あるいは、 MIME ‘content-type’ ヘッダ に利用できる、
     ‘'type/subtype'’ の形の文字列です。

     'encoding' は、符合化方式がない場合は ‘None’ を、あるいは、符号化に
     使われるプログラムの名前 (たとえば、 ‘compress’ あるいは ‘gzip’)で
     す。符号化方式は ‘Content-Encoding’ ヘッダとして使うのに適しており
     、 ‘Content-Transfer-Encoding’ ヘッダには適して 'いません' 。マッピ
     ングはテーブル駆動です。符号化方式のサフィックスは大/小文字を区別し
     ます; データ型サフィックスは、最初大/小文字を区別して試し、それから
     大/小文字を区別せずに試します。

     省略可能な 'strict' 引数は、既知の MIME 型のリストとして認識される
     ものが、IANAに登録された(2) 正式な型のみに限定されるかどうかを指定
     するフラグです。'strict' が ‘True’ (デフォルト)の時は、IANA 型のみ
     がサポートされます; 'strict' が ‘False’ のときは、いくつかの追加の
     、非標準ではあるが、一般的に使用される MIME 型も認識されます。

     バージョン 3.8 で変更: Added support for 'url' being a *note
     path-like object: 280.

     バージョン 3.13 で非推奨: Passing a file path instead of URL is
     *note soft deprecated: 1ea.  Use *note guess_file_type(): 1e8. for
     this.

 -- の関数: mimetypes.guess_file_type (path, *, strict=True)

     Guess the type of a file based on its path, given by 'path'.
     Similar to the *note guess_type(): 1e9. function, but accepts a
     path instead of URL. Path can be a string, a bytes object or a
     *note path-like object: 280.

     Added in version 3.13.

 -- の関数: mimetypes.guess_all_extensions (type, strict=True)

     Guess the extensions for a file based on its MIME type, given by
     'type'.  The return value is a list of strings giving all possible
     filename extensions, including the leading dot (‘'.'’).  The
     extensions are not guaranteed to have been associated with any
     particular data stream, but would be mapped to the MIME type 'type'
     by *note guess_type(): 1e9. and *note guess_file_type(): 1e8.

     省略可能な 'strict' 引数は *note guess_type(): 1e9. 関数のものと同
     じ意味を持ちます。

 -- の関数: mimetypes.guess_extension (type, strict=True)

     Guess the extension for a file based on its MIME type, given by
     'type'.  The return value is a string giving a filename extension,
     including the leading dot (‘'.'’).  The extension is not guaranteed
     to have been associated with any particular data stream, but would
     be mapped to the MIME type 'type' by *note guess_type(): 1e9. and
     *note guess_file_type(): 1e8.  If no extension can be guessed for
     'type', ‘None’ is returned.

     省略可能な 'strict' 引数は *note guess_type(): 1e9. 関数のものと同
     じ意味を持ちます。

モジュールの動作を制御するために、いくつかの追加の関数とデータ項目が利用
できます。

 -- の関数: mimetypes.init (files=None)

     内部のデータ構造を初期化します。もし 'files' が与えられていれば、こ
     れはデフォルトの type map を増やすために使われる、一連のファイル名
     でなければなりません。もし省略されていれば、使われるファイル名は
     *note knownfiles: 35b8. から取られます。 Windows であれば、現在のレ
     ジストリの設定が読み込まれます。 'files' あるいは *note knownfiles:
     35b8. 内の各ファイル名は、それ以前に現れる名前より優先されます。繰
     り返し *note init(): 35b6. を呼び出すことは許されています。

     'files' に空リストを与えることで、システムのデフォルトが適用される
     のを避けることが出来ます; 組み込みのリストから well-known な値だけ
     が取り込まれます。

     'files' が ‘None’ の場合、内部のデータ構造は初期のデフォルト値に完
     全に再構築されます。 これは安定な操作であり、複数回呼び出されたとき
     は同じ結果になります。

     バージョン 3.2 で変更: 前のバージョンでは、 Windows のレジストリの
     設定は無視されていました。

 -- の関数: mimetypes.read_mime_types (filename)

     ファイル 'filename' で与えられた型のマップが、もしあればロードしま
     す。型のマップは、先頭の dot (‘'.'’) を含むファイル名拡張子を、
     ‘'type/subtype'’ の形の文字列にマッピングする辞書として返されます。
     もしファイル 'filename' が存在しないか、読み込めなければ、‘None’ が
     返されます。

 -- の関数: mimetypes.add_type (type, ext, strict=True)

     MIME 型 'type' からのマッピングを拡張子 'ext' に追加します。拡張子
     がすでに既知であれば、新しい型が古いものに置き替わります。その型が
     すでに既知であれば、その拡張子が、既知の拡張子のリストに追加されま
     す。

     'strict' が ‘True’ の時(デフォルト)は、そのマッピングは正式な MIME
     型に、そうでなければ、非標準の MIME 型に追加されます。

 -- データ: mimetypes.inited

     グローバルなデータ構造が初期化されているかどうかを示すフラグ。これ
     は *note init(): 35b6. により ‘True’ に設定されます。

 -- データ: mimetypes.knownfiles

     共通にインストールされた型マップファイル名のリスト。これらのファイ
     ルは、普通 ‘mime.types’ という名前であり、パッケージごとに異なる場
     所にインストールされます。

 -- データ: mimetypes.suffix_map

     サフィックスをサフィックスにマップする辞書。これは、符号化方式と型
     が同一拡張子で示される符号化ファイルが認識できるように使用されます
     。例えば、 ‘.tgz’ 拡張子は、符号化と型が別個に認識できるように
     ‘.tar.gz’ にマップされます。

 -- データ: mimetypes.encodings_map

     ファイル名拡張子を符号化方式型にマッピングする辞書。

 -- データ: mimetypes.types_map

     ファイル名拡張子を MIME 型にマップする辞書。

 -- データ: mimetypes.common_types

     ファイル名拡張子を非標準ではあるが、一般に使われている MIME 型にマ
     ップする辞書。

モジュールの使用例:

     >>> import mimetypes
     >>> mimetypes.init()
     >>> mimetypes.knownfiles
     ['/etc/mime.types', '/etc/httpd/mime.types', ... ]
     >>> mimetypes.suffix_map['.tgz']
     '.tar.gz'
     >>> mimetypes.encodings_map['.gz']
     'gzip'
     >>> mimetypes.types_map['.tgz']
     'application/x-tar-gz'

* Menu:

* Mime 型オブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/mimetypes.py

   (2) https://www.iana.org/assignments/media-types/media-types.xhtml


File: python.info,  Node: Mime 型オブジェクト,  Up: mimetypes --- ファイル名を MIME タイプへマップする

5.19.4.1 Mime 型オブジェクト
............................

*note MimeTypes: 14a4. クラスは一つ以上の MIME 型データベースが欲しいア
プリケーションにとって有用でしょう。これは *note mimetypes: 82. モジュー
ルのそれと似たインターフェースを提供します。

 -- クラス: mimetypes.MimeTypes (filenames=(), strict=True)

     このクラスは、MIME 型データベースを表現します。デフォルトでは、この
     モジュールの他のものと同じデータベースへのアクセスを提供します。初
     期データベースは、このモジュールによって提供されるもののコピーで、
     追加の ‘mime.types’ 形式のファイルを、 *note read(): 35c1. あるいは
     *note readfp(): 35c2. メソッドを使って、データベースにロードするこ
     とで拡張されます。マッピング辞書も、もしデフォルトのデータが望むも
     のでなければ、追加のデータをロードする前にクリアされます。

     省略可能な 'filenames' パラメータは、追加のファイルを、デフォルトデ
     ータベースの"トップに"ロードさせるのに使うことができます。

      -- の属性: suffix_map

          サフィックスをサフィックスにマップする辞書。これは、符号化方式
          と型が同一拡張子で示されるような符号化ファイルが認識できるよう
          に使用されます。例えば、 ‘.tgz’ 拡張子は、符号化方式と型が別個
          に認識できるように ‘.tar.gz’ に対応づけられます。これは、最初
          はモジュールで定義されたグローバルな *note suffix_map: 35bb. の
          コピーです。

      -- の属性: encodings_map

          ファイル名拡張子を符号化型にマッピングする辞書。これは、最初は
          モジュールで定義されたグローバルな *note encodings_map: 35bc.
          のコピーです。

      -- の属性: types_map

          ファイル名拡張子を MIME 型にマッピングする 2 種類の辞書のタプ
          ル; 最初の辞書は非標準型、二つ目は標準型の辞書です。初期状態で
          はそれぞれ *note common_types: 35be. と *note types_map: 35bd.
          です。

      -- の属性: types_map_inv

          MIME 型をファイル名拡張子のリストにマッピングする 2 種類の辞書
          のタプル; 最初の辞書は非標準型、二つ目は標準型の辞書です。初期
          状態ではそれぞれ *note common_types: 35be. と *note types_map:
          35bd. です。

      -- メソッド: guess_extension (type, strict=True)

          *note guess_extension(): 35b7. 関数と同様ですが、オブジェクト
          に保存されたテーブルを使用します。

      -- メソッド: guess_type (url, strict=True)

          *note guess_type(): 1e9. 関数と同様ですが、オブジェクトに保存
          されたテーブルを使用します。

      -- メソッド: guess_file_type (path, *, strict=True)

          Similar to the *note guess_file_type(): 1e8. function, using
          the tables stored as part of the object.

          Added in version 3.13.

      -- メソッド: guess_all_extensions (type, strict=True)

          *note guess_all_extensions(): 1800. と同様ですが、オブジェクト
          に保存されたテーブルを参照します。

      -- メソッド: read (filename, strict=True)

          MIME 情報を、 'filename' という名のファイルからロードします。
          これはファイルを解析するのに *note readfp(): 35c2. を使用しま
          す。

          'strict' が ‘True’ の時 (デフォルト) は、そのマッピングは標準
          MIME 型のリストに、そうでなければ、非標準 MIME 型のリストに追
          加されます。

      -- メソッド: readfp (fp, strict=True)

          MIME 型情報を、オープンしたファイル 'fp' からロードします。フ
          ァイルは、標準の ‘mime.types’ ファイルの形式でなければなりませ
          ん。

          'strict' が ‘True’ の時 (デフォルト) は、そのマッピングは標準
          MIME 型のリストに、そうでなければ、非標準 MIME 型のリストに追
          加されます。

      -- メソッド: read_windows_registry (strict=True)

          MIME type 情報を Windows のレジストリから読み込みます。

          *note Availability: 1cbe.: Windows.

          'strict' が ‘True’ の時 (デフォルト) は、そのマッピングは標準
          MIME 型のリストに、そうでなければ、非標準 MIME 型のリストに追
          加されます。

          Added in version 3.2.

      -- メソッド: add_type (type, ext, strict=True)

          MIME 型 'type' からのマッピングを拡張子 'ext' に追加します。拡
          張子がすでに既知であれば、新しい型が古いものに置き替わります。
          その型がすでに既知であれば、その拡張子が、既知の拡張子のリスト
          に追加されます。

          'strict' が ‘True’ の時(デフォルト)は、そのマッピングは正式な
          MIME 型に、そうでなければ、非標準の MIME 型に追加されます。


File: python.info,  Node: base64 --- Base16 Base32 Base64 Base85 データのエンコード,  Next: binascii --- バイナリ と ASCII 間の変換,  Prev: mimetypes --- ファイル名を MIME タイプへマップする,  Up: インターネット上のデータの操作

5.19.5 ‘base64’ -- Base16, Base32, Base64, Base85 データのエンコード
--------------------------------------------------------------------

'ソースコード:' Lib/base64.py(1)

__________________________________________________________________

このモジュールは、バイナリデータを印刷可能なASCII文字列にエンコードして
、また逆にデコードするための関数を提供しています。 RFC 4648(2) に定義さ
れている Base16、Base32、 Base64 に加えて事実上の標準となっている
Ascii85 と Base 85 をサポートしています。

RFC 4648(3) エンコーディングは、email で安全に送信したり、 URL の一部と
して使ったり、あるいは HTTP POST リクエストの一部に含めるために用いるの
に適しています。このエンコーディングで使われているアルゴリズムは
‘uuencode’ プログラムで用いられているものとは同じではありません。

このモジュールは、2つのインターフェースを提供します。このモダンなインタ
ーフェースは、*note bytes-like object: cfb. を ASCII *note bytes: 1a4. に
エンコードし、*note bytes-like object: cfb. か ASCII 文字列を、*note
bytes: 1a4. にデコードすることができます。 RFC 4648(4) に定義されている
base-64 アルファベット (一般の、URL あるいはファイルシステムセーフなもの
) の両方が使用できます。

従来のインターフェースは文字列からのデコードができませんが、*note file
object: 1193. との間のエンコードとデコードが可能な関数を提供します。これ
は標準の base64 アルファベットのみをサポートし、 RFC 2045(5) の規定にあ
るように、76文字ごとに改行されます。 RFC 2045(6) のサポートのためには、
代わりに *note email: 32. パッケージを参照する必要があるかもしれません。

バージョン 3.3 で変更: モダンなインターフェイスのデコード関数が ASCII の
みの Unicode 文字列を受け付けるようになりました。

バージョン 3.4 で変更: このモジュールのすべてのエンコード・デコード関数
が任意の *note bytes-like オブジェクト: cfb. を受け取るようになりました
。Ascii85/Base85 のサポートが追加されました。

モダンなインターフェイスは以下のものを提供します:

 -- の関数: base64.b64encode (s, altchars=None)

     Base64 を使って *note bytes-like object: cfb. の 's' をエンコードし
     、エンコードされた *note bytes: 1a4. を返します。

     オプション引数 'altchars' は長さ 2 の *note bytes-like object: cfb.
     で 、‘+’ と ‘/’ の代わりに使われる代替アルファベットを指定します。
     これにより、アプリケーションはたとえば URL やファイルシステムの影響
     を受けない Base64 文字列を生成できます。デフォルトは ‘None’ で、標
     準の Base64 アルファベットが使われます。

     'altchars' の長さが2でない場合は、 assert または *note ValueError:
     1e3. が発生します。 'altchars' が *note bytes-like object: cfb. で
     ない場合は、 *note TypeError: 502. が発生します。

 -- の関数: base64.b64decode (s, altchars=None, validate=False)

     Base64 エンコードされた *note bytes-like object: cfb. または ASCII
     文字列 's' をデコードし、デコードされた *note bytes: 1a4. を返しま
     す。

     オプション引数の 'altchars' は長さ 2 の *note bytes-like object:
     cfb. または ASCII 文字列で、‘+’ と ‘/’ の代わりに使われる代替アルフ
     ァベットを指定します。

     's' が正しくパディングされていない場合は *note binascii.Error: ff0.
     例外を発生させます。

     'validate' が ‘False’ (デフォルト) の場合、標準の base64 アルファベ
     ットでも代替文字でもない文字はパディングチェックの前に無視されます
     。 'validate' が ‘True’ の場合、入力に base64 アルファベット以外の
     文字があると *note binascii.Error: ff0. を発生させます。

     厳密な base64 チェックのについての詳細は *note
     binascii.a2b_base64(): 1591. を参照してください

     May assert or raise a *note ValueError: 1e3. if the length of
     'altchars' is not 2.

 -- の関数: base64.standard_b64encode (s)

     標準の base64 アルファベットを使用して *note bytes-like object:
     cfb. の 's' をエンコードし、エンコードされた *note bytes: 1a4. を返
     します。

 -- の関数: base64.standard_b64decode (s)

     標準の base64 アルファベットを使用した *note bytes-like object:
     cfb. または ASCII 文字列 's' をデコードし、デコードされた *note
     bytes: 1a4. を返します。

 -- の関数: base64.urlsafe_b64encode (s)

     *note bytes-like object: cfb. 's' を URLとファイルシステムセーフな
     アルファベットを利用してエンコードし、エンコードされた *note bytes:
     1a4. を返します。標準 base64 アルファベットに比べて、‘+’ の替わりに
     ‘-’ を、‘/’ の替わりに ‘_’ を利用します。結果は ‘=’ を含みます。

 -- の関数: base64.urlsafe_b64decode (s)

     *note bytes-like object: cfb. または ASCII 文字列 's' を URLとファ
     イルシステムセーフなアルファベットを利用してデコードし、デコードさ
     れた *note bytes: 1a4. を返します。標準 base64 アルファベットに比べ
     て、‘+’ の替わりに ‘-’ を、‘/’ の替わりに ‘_’ を置換します。

 -- の関数: base64.b32encode (s)

     Base32 を使って *note bytes-like object: cfb. の 's' をエンコードし
     、エンコードされた *note bytes: 1a4. を返します。

 -- の関数: base64.b32decode (s, casefold=False, map01=None)

     Base32 エンコードされた *note bytes-like object: cfb. または ASCII
     文字列 's' をデコードし、デコードされた *note bytes: 1a4. を返しま
     す。

     オプション引数 'casefold' は小文字のアルファベットを受けつけるかど
     うかを指定します。セキュリティ上の理由により、デフォルトではこれは
     ‘False’ になっています。

     RFC 4648(7) は付加的なマッピングとして、数字の 0 (零) をアルファベ
     ットの O (オー) に、数字の 1 (壱) をアルファベットの I (アイ) また
     は L (エル) に対応させることを許しています。オプション引数は
     'map01' は、 ‘None’ でないときは、数字の 1 をどの文字に対応づけるか
     を指定します ('map01' が ‘None’ でないとき、数字の 0 はつねにアルフ
     ァベットの O (オー) に対応づけられます)。セキュリティ上の理由により
     、これはデフォルトでは ‘None’ になっているため、 0 および 1 は入力
     として許可されていません。

     's' が正しくパディングされていない場合や、入力にアルファベットでな
     い文字が含まれていた場合に、 *note binascii.Error: ff0. 例外を発生
     させます。

 -- の関数: base64.b32hexencode (s)

     Similar to *note b32encode(): 35d3. but uses the Extended Hex
     Alphabet, as defined in RFC 4648(8).

     Added in version 3.10.

 -- の関数: base64.b32hexdecode (s, casefold=False)

     Similar to *note b32decode(): fef. but uses the Extended Hex
     Alphabet, as defined in RFC 4648(9).

     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.

     Added in version 3.10.

 -- の関数: base64.b16encode (s)

     Base16 を使って *note bytes-like object: cfb. の 's' をエンコードし
     、エンコードされた *note bytes: 1a4. を返します。

 -- の関数: base64.b16decode (s, casefold=False)

     Base16 エンコードされた *note bytes-like object: cfb. または ASCII
     文字列 's' をデコードし、デコードされた *note bytes: 1a4. を返しま
     す。

     オプション引数 'casefold' は小文字のアルファベットを受けつけるかど
     うかを指定します。セキュリティ上の理由により、デフォルトではこれは
     ‘False’ になっています。

     's' が正しくパディングされていない場合や、入力にアルファベットでな
     い文字が含まれていた場合に、 *note binascii.Error: ff0. 例外を発生
     させます。

 -- の関数: base64.a85encode (b, *, foldspaces=False, wrapcol=0,
          pad=False, adobe=False)

     Ascii85 を使って *note bytes-like object: cfb. の 'b' をエンコード
     し、エンコードされた *note bytes: 1a4. を返します。

     'foldspaces' を使うと、4 つの連続した空白文字(ASCII 0x20)を 'btoa'
     によってサポートされている短い特殊文字 'y' に置き換えます。この機能
     は "標準" Ascii85 ではサポートされていません。

     'wrapcol' controls whether the output should have newline (‘b'\n'’)
     characters added to it.  If this is non-zero, each output line will
     be at most this many characters long, excluding the trailing
     newline.

     'pad' を指定すると、エンコード前に入力が 4 の倍数になるようにパディ
     ングされます。なお、 ‘btoa’ の実装は常にパディングします。

     'adobe' を指定すると、エンコードしたバイトシーケンスを ‘<~’ と ‘~>’
     で囲みます。これは Adobe の実装で使われています。

     Added in version 3.4.

 -- の関数: base64.a85decode (b, *, foldspaces=False, adobe=False,
          ignorechars=b' \t\n\r\x0b')

     Ascii85 エンコードされた *note bytes-like object: cfb. または ASCII
     文字列 'b' をデコードし、デコードされた *note bytes: 1a4. を返しま
     す。

     'foldspaces' は、短い特殊文字 'y' を受け取って 4 つの連続した空白文
     字(ASCII 0x20)と解釈するかどうかを制御します。この機能は "標準"
     Ascii85 ではサポートされていません。

     'adobe' で、入力シーケンスが Adobe Ascii85 (つまり ‘<~’ と ‘~>’ で
     囲まれている)かどうかを伝えます。

     'ignorechars' には、入力に含まれていれば無視する文字で構成された
     *note bytes-like object: cfb. または ASCII 文字列を指定してください
     。これは空白文字だけで構成されているべきです。デフォルトは ASCII に
     おける空白文字全てです。

     Added in version 3.4.

 -- の関数: base64.b85encode (b, pad=False)

     base85 (これは例えば git スタイルのバイナリ diff で用いられています
     ) を使って *note bytes-like object: cfb. の 'b' をエンコードし、エ
     ンコードされた *note bytes: 1a4. を返します。

     'pad' が真ならば、エンコードに先立って、バイト数が 4 の倍数となるよ
     うに入力が ‘b'\0'’ でパディングされます。

     Added in version 3.4.

 -- の関数: base64.b85decode (b)

     base85でエンコードされた *note bytes-like object: cfb. または ASCII
     文字列の 'b' をデコードし、デコードされた *note bytes: 1a4. を返し
     ます。パディングは、もしあれば、暗黙に削除されます。

     Added in version 3.4.

 -- の関数: base64.z85encode (s)

     Encode the *note bytes-like object: cfb. 's' using Z85 (as used in
     ZeroMQ) and return the encoded *note bytes: 1a4.  See Z85
     specification(10) for more information.

     Added in version 3.13.

 -- の関数: base64.z85decode (s)

     Decode the Z85-encoded *note bytes-like object: cfb. or ASCII
     string 's' and return the decoded *note bytes: 1a4.  See Z85
     specification(11) for more information.

     Added in version 3.13.

レガシーなインターフェイスは以下のものを提供します:

 -- の関数: base64.decode (input, output)

     'input' ファイルの中身をデコードし、結果のバイナリデータを 'output'
     ファイルに出力します。 'input' 、 'output' ともに *note file
     objects: 1193. でなければなりません。 'input' は ‘input.readline()’
     が空バイト列を返すまで読まれます。

 -- の関数: base64.decodebytes (s)

     *note bytes-like object: cfb. 's' をデコードし、デコードされた
     *note bytes: 1a4. を返します。 's' には一行以上の base64 形式でエン
     コードされたデータが含まれている必要があります。

     Added in version 3.1.

 -- の関数: base64.encode (input, output)

     バイナリの 'input' ファイルの中身を base64 形式でエンコードした結果
     を 'output' ファイルに出力します。 'input' 、 'output' ともに *note
     file objects: 1193. でなければなりません。 'input' は
     ‘input.read()’ が空バイト列を返すまで読まれます。 *note encode():
     35d7. は76バイトの出力ごとに改行文字(‘b'\n'’)を挿入し、 RFC
     2045(12) (MIME) の規定にあるように常に出力が新しい行で終わることを
     保証します。

 -- の関数: base64.encodebytes (s)

     *note bytes-like object: cfb. 's' (任意のバイナリデータを含むことが
     できます) を、 RFC 2045(13) (MIME) に規定されるように末尾に新しい行
     のある、76バイトの出力ごとに新しい行 (‘b'\n'’) が挿入された、base64
     形式でエンコードしたデータを含む *note bytes: 1a4. を返します。

     Added in version 3.1.

モジュールの使用例:

     >>> import base64
     >>> encoded = base64.b64encode(b'data to be encoded')
     >>> encoded
     b'ZGF0YSB0byBiZSBlbmNvZGVk'
     >>> data = base64.b64decode(encoded)
     >>> data
     b'data to be encoded'

* Menu:

* セキュリティで考慮すべき点: セキュリティで考慮すべき点<4>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/base64.py

   (2) https://datatracker.ietf.org/doc/html/rfc4648.html

   (3) https://datatracker.ietf.org/doc/html/rfc4648.html

   (4) https://datatracker.ietf.org/doc/html/rfc4648.html

   (5) https://datatracker.ietf.org/doc/html/rfc2045.html

   (6) https://datatracker.ietf.org/doc/html/rfc2045.html

   (7) https://datatracker.ietf.org/doc/html/rfc4648.html

   (8) https://datatracker.ietf.org/doc/html/rfc4648.html

   (9) https://datatracker.ietf.org/doc/html/rfc4648.html

   (10) https://rfc.zeromq.org/spec/32/

   (11) https://rfc.zeromq.org/spec/32/

   (12) https://datatracker.ietf.org/doc/html/rfc2045.html

   (13) https://datatracker.ietf.org/doc/html/rfc2045.html


File: python.info,  Node: セキュリティで考慮すべき点<4>,  Up: base64 --- Base16 Base32 Base64 Base85 データのエンコード

5.19.5.1 セキュリティで考慮すべき点
...................................

A new security considerations section was added to RFC 4648(1) (section
12); it's recommended to review the security section for any code
deployed to production.

参考
....

モジュール *note binascii: c.

     ASCII からバイナリへ、バイナリから ASCII への変換をサポートするモジ
     ュール。

RFC 1521(2) - MIME (Multipurpose Internet Mail Extensions) Part One: Mechanisms for Specifying and Describing the Format of Internet Message Bodies

     Section 5.2, "Base64 Content-Transfer-Encoding," provides the
     definition of the base64 encoding.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc4648.html

   (2) https://datatracker.ietf.org/doc/html/rfc1521.html


File: python.info,  Node: binascii --- バイナリ と ASCII 間の変換,  Next: quopri --- MIME quoted-printable データのエンコードとデコード,  Prev: base64 --- Base16 Base32 Base64 Base85 データのエンコード,  Up: インターネット上のデータの操作

5.19.6 ‘binascii’ -- バイナリ と ASCII 間の変換
-----------------------------------------------

__________________________________________________________________

*note binascii: c. モジュールにはバイナリと ASCII コード化されたバイナリ
表現との間の変換を行うための多数のメソッドが含まれています。通常はこれら
の関数を直接使わずに *note base64: a. といったラッパーモジュールを使いま
す。*note binascii: c. モジュールは C で書かれた高速な低水準関数を提供し
ていて、それらは上記の高水準なモジュールで利用されます。

     注釈: ‘a2b_*’ 関数は ASCII 文字だけを含むユニコード文字列を受け取り
     ます。他の関数は (*note bytes: 1a4. や *note bytearray: 508. または
     バッファープロトコルをサポートするその他のオブジェクトのような)
     *note bytes-like オブジェクト: cfb. だけを受け取ります。

     バージョン 3.3 で変更: ‘a2b_*’ 関数は ASCII のみのユニコード文字列
     を受け取るようになりました。

*note binascii: c. モジュールでは以下の関数を定義します:

 -- の関数: binascii.a2b_uu (string)

     uuencode された 1 行のデータをバイナリに変換し、変換後のバイナリデ
     ータを返します。最後の行を除いて、通常 1 行には (バイナリデータで)
     45 バイトが含まれます。入力データの先頭には空白文字が連続していても
     かまいません。

 -- の関数: binascii.b2a_uu (data, *, backtick=False)

     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.

     バージョン 3.7 で変更: 'backtick' パラメータを追加しました.

 -- の関数: binascii.a2b_base64 (string, /, *, strict_mode=False)

     base64 でエンコードされたデータのブロックをバイナリに変換し、変換後
     のバイナリデータを返します。一度に 1 行以上のデータを与えてもかまい
     ません。

     If 'strict_mode' is true, only valid base64 data will be converted.
     Invalid base64 data will raise *note binascii.Error: ff0.

     Valid base64:

        * Conforms to RFC 3548(1).

        * Contains only characters from the base64 alphabet.

        * Contains no excess data after padding (including excess
          padding, newlines, etc.).

        * Does not start with a padding.

     バージョン 3.11 で変更: Added the 'strict_mode' parameter.

 -- の関数: binascii.b2a_base64 (data, *, newline=True)

     バイナリデータを base64 でエンコードされた 1 行の ASCII 文字列に変
     換します。戻り値は変換後の 1 行の文字列で、'newline' が真の場合改行
     文字を含みます。この関数の出力は RFC 3548(2) を遵守します。

     バージョン 3.6 で変更: パラメータに 'newline' を追加しました。

 -- の関数: binascii.a2b_qp (data, header=False)

     quoted-printable 形式のデータをバイナリに変換し、バイナリデータを返
     します。一度に 1 行以上のデータを渡すことができます。オプション引数
     'header' が与えられており、かつその値が真であれば、アンダースコアは
     空白文字にデコードされます。

 -- の関数: binascii.b2a_qp (data, quotetabs=False, istext=True,
          header=False)

     バイナリデータを quoted-printable 形式でエンコードして 1 行から複数
     行の ASCII 文字列に変換します。変換後の文字列を返します。オプション
     引数 'quptetabs' が存在し、かつその値が真であれば、全てのタブおよび
     空白文字もエンコードされます。オプション引数 'istext' が存在し、か
     つその値が真であれば、改行はエンコードされませんが、行末の空白文字
     はエンコードされます。オプション引数 'header' が存在し、かつその値
     が真である場合、空白文字は RFC 1522(3) にしたがってアンダースコアに
     エンコードされます。オプション引数 'header' が存在し、かつその値が
     偽である場合、改行文字も同様にエンコードされます。そうでない場合、
     復帰 (linefeed) 文字の変換によってバイナリデータストリームが破損し
     てしまうかもしれません。

 -- の関数: binascii.crc_hqx (data, value)

     'value' を CRC の初期値として 'data' の 16 ビット CRC 値を計算し、
     その結果を返します。 この関数は、よく 0x1021 と表現される CRC-CCITT
     多項式 'x'^16 + 'x'^12 + 'x'^5 + 1 を使います。 この CRC は binhex4
     形式で使われています。

 -- の関数: binascii.crc32 (data[, value])

     符号無し 32 ビットチェックサムである CRC-32 を 'data' に対して計算
     します。 crc の初期値は 'value' です。デフォルトの CRC の初期値はゼ
     ロです。このアルゴリズムは ZIP ファイルのチェックサムと同じです。こ
     のアルゴリズムはチェックサムアルゴリズムとして設計されたもので、一
     般的なハッシュアルゴリズムには向きません。以下のようにして使います:

          print(binascii.crc32(b"hello world"))
          # Or, in two pieces:
          crc = binascii.crc32(b"hello")
          crc = binascii.crc32(b" world", crc)
          print('crc32 = {:#010x}'.format(crc))

     バージョン 3.0 で変更: The result is always unsigned.

 -- の関数: binascii.b2a_hex (data[, sep[, bytes_per_sep=1]])
 -- の関数: binascii.hexlify (data[, sep[, bytes_per_sep=1]])

     バイナリ 'data' の16進表現を返します。'data' の各バイトは、対応する
     2桁の16進表現に変換されます。したがって、返されるバイトオブジェクト
     は 'data' の2倍の長さになります。

     Similar functionality (but returning a text string) is also
     conveniently accessible using the *note bytes.hex(): d36. method.

     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.

          >>> import binascii
          >>> binascii.b2a_hex(b'\xb9\x01\xef')
          b'b901ef'
          >>> binascii.hexlify(b'\xb9\x01\xef', '-')
          b'b9-01-ef'
          >>> binascii.b2a_hex(b'\xb9\x01\xef', b'_', 2)
          b'b9_01ef'
          >>> binascii.b2a_hex(b'\xb9\x01\xef', b' ', -2)
          b'b901 ef'

     バージョン 3.8 で変更: 引数 'sep' と 'bytes_per_sep' が追加されまし
     た.

 -- の関数: binascii.a2b_hex (hexstr)
 -- の関数: binascii.unhexlify (hexstr)

     16進数表記の文字列 'hexstr' の表すバイナリデータを返します。この関
     数は *note b2a_hex(): 236d. の逆です。 'hexstr' は 16進数字 (大文字
     でも小文字でも構いません) を偶数個含んでいなければなりません。そう
     でない場合、例外 *note Error: ff0. が送出されます。

     Similar functionality (accepting only text string arguments, but
     more liberal towards whitespace) is also accessible using the *note
     bytes.fromhex(): abd. class method.

 -- 例外: binascii.Error

     エラーが発生した際に送出される例外です。通常はプログラムのエラーで
     す。

 -- 例外: binascii.Incomplete

     変換するデータが不完全な場合に送出される例外です。通常はプログラム
     のエラーではなく、多少追加読み込みを行って再度変換を試みることで対
     処できます。

参考
....

*note base64: a. モジュール

     RFC 準拠の base64 形式の、底が 16、32、64、85 のエンコーディング。

*note quopri: a5. モジュール

     MIME 電子メールメッセージで使われる quoted-printable エンコードのサ
     ポート。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3548.html

   (2) https://datatracker.ietf.org/doc/html/rfc3548.html

   (3) https://datatracker.ietf.org/doc/html/rfc1522.html


File: python.info,  Node: quopri --- MIME quoted-printable データのエンコードとデコード,  Prev: binascii --- バイナリ と ASCII 間の変換,  Up: インターネット上のデータの操作

5.19.7 ‘quopri’ -- MIME quoted-printable データのエンコードとデコード
---------------------------------------------------------------------

'ソースコード:' Lib/quopri.py(1)

__________________________________________________________________

このモジュールは RFC 1521(2): "MIME (Multipurpose Internet Mail
Extensions) Part One: Mechanisms for Specifying and Describing the
Format of Internet Message Bodies" で定義されている quoted-printable に
よる伝送のエンコードおよびデコードを行います。 quoted-printable エンコー
ディングは比較的印字不可能な文字の少ないデータのために設計されています;
画像ファイルを送るときのように印字不可能な文字がたくさんある場合には、
*note base64: a. モジュールで利用できる base64 エンコーディングのほうが
よりコンパクトになります。

 -- の関数: quopri.decode (input, output, header=False)

     ファイル 'input' の内容をデコードして、デコードされたバイナリデータ
     をファイル 'output' に書き出します。 'input' および 'output' は
     *note バイナリファイルオブジェクト: 1193. でなければなりません。オ
     プション引数 'header' が存在し、かつその値が真である場合、アンダー
     スコアは空白文字にデコードされます。これは RFC 1522(3): "MIME
     (Multipurpose Internet Mail Extensions) Part Two: Message Header
     Extensions for Non-ASCII Text" で記述されているところの "Q"-エンコ
     ードされたヘッダをデコードするのに使われます。

 -- の関数: quopri.encode (input, output, quotetabs, header=False)

     ファイル 'input' の内容をエンコードして、その結果の
     quoted-printable データをファイル 'output' に書き出します。 'input'
     および 'output' は *note バイナリファイルオブジェクト: 1193. でなけ
     ればなりません。 'quotetabs' は、内容に含まれている空白とタブ文字を
     エンコードするかどうかを制御する必須のフラグで、真のときは空白文字
     をエンコードし、偽のときはエンコードしないままにしておきます。 RFC
     1521(4) に従って、行末にある空白とタブ文字は常にエンコードされるこ
     とに注意してください。 'header' は、空白を RFC 1522(5) に従ってアン
     ダースコアにエンコードするかどうかを制御するフラグです。

 -- の関数: quopri.decodestring (s, header=False)

     *note decode(): 2370. に似ていますが、ソース *note bytes: 1a4. を受
     け取り、対応するデコードされた *note bytes: 1a4. を返します。

 -- の関数: quopri.encodestring (s, quotetabs=False, header=False)

     *note encode(): 236f. に似ていますが、ソース *note bytes: 1a4. を受
     け取り、対応するエンコードされた *note bytes: 1a4. を返します。 デ
     フォルトでは、 *note encode(): 236f. 関数の 'quotetabs' パラメータ
     に ‘False’ を渡します。

参考
....

*note base64: a. モジュール

     MIME base64 形式データのエンコードおよびデコード

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/quopri.py

   (2) https://datatracker.ietf.org/doc/html/rfc1521.html

   (3) https://datatracker.ietf.org/doc/html/rfc1522.html

   (4) https://datatracker.ietf.org/doc/html/rfc1521.html

   (5) https://datatracker.ietf.org/doc/html/rfc1522.html


File: python.info,  Node: 構造化マークアップツール,  Next: インターネットプロトコルとサポート,  Prev: インターネット上のデータの操作,  Up: Python 標準ライブラリ

5.20 構造化マークアップツール
=============================

Python は様々な構造化データマークアップ形式を扱うための、様々なモジュー
ルをサポートしています。これらは標準化一般マークアップ言語 (SGML) および
ハイパーテキストマークアップ言語 (HTML)、そして可拡張性マークアップ言語
(XML) を扱うためのいくつかのインターフェースからなります。

* Menu:

* html: html --- HyperText Markup Language のサポート. HyperText Markup Language のサポート
* html.parser: html parser --- HTML と XHTML のシンプルなパーサー. HTML と XHTML のシンプルなパーサー
* html.entities: html entities --- HTML 一般実体の定義. HTML 一般実体の定義
* XMLを扱うモジュール群::
* xml.etree.ElementTree: xml etree ElementTree --- ElementTree XML API. ElementTree XML API
* xml.dom: xml dom --- ドキュメントオブジェクトモデル API. ドキュメントオブジェクトモデル API
* xml.dom.minidom: xml dom minidom --- 最小限の DOM の実装. 最小限の DOM の実装
* xml.dom.pulldom: xml dom pulldom --- 部分的な DOM ツリー構築のサポート. 部分的な DOM ツリー構築のサポート
* xml.sax: xml sax --- SAX2 バーサーのサポート. SAX2 バーサーのサポート
* xml.sax.handler: xml sax handler --- SAX ハンドラーの基底クラス. SAX ハンドラーの基底クラス
* xml.sax.saxutils: xml sax saxutils --- SAX ユーティリティー. SAX ユーティリティー
* xml.sax.xmlreader: xml sax xmlreader --- XML パーサーのインターフェース. XML パーサーのインターフェース
* xml.parsers.expat: xml parsers expat --- Expat を使用した高速な XML 解析. Expat を使用した高速な XML 解析


File: python.info,  Node: html --- HyperText Markup Language のサポート,  Next: html parser --- HTML と XHTML のシンプルなパーサー,  Up: 構造化マークアップツール

5.20.1 ‘html’ -- HyperText Markup Language のサポート
-----------------------------------------------------

'ソースコード:' Lib/html/__init__.py(1)

__________________________________________________________________

このモジュールは HTML を操作するユーティリティを定義しています。

 -- の関数: html.escape (s, quote=True)

     文字列 's' 内の ‘&’、‘<’、および ‘>’ を HTML セーフなシーケンスに変
     換します。これらの文字を含む HTML を表示する必要がある場合に使用し
     ます。オプションフラグ 'quote' が真の場合、文字 (‘"’) および (‘'’)
     も変換します。これは例えば ‘<a href="...">’ など、引用符で括られて
     いる HTML 属性値を包含する時に役立ちます。

     Added in version 3.2.

 -- の関数: html.unescape (s)

     文字列 's' 中の名前や数字による参照 (例えば ‘&gt;’, ‘&#62;’,
     ‘&#x3e;’) を全て対応するユニコード文字に変換します。 この関数は、
     HTML 5 標準規格で定められた有効な文字参照および無効な文字参照、
     *note list of HTML 5 named character references: 10a5. を対象としま
     す。

     Added in version 3.4.

__________________________________________________________________

‘html’ パッケージのサブモジュールは以下のとおりです:

   * *note html.parser: 63. - 許容性のあるモードを持つ HTML/XHTML パーサ
     ー

   * *note html.entities: 62. - HTML 実体の定義

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/html/__init__.py


File: python.info,  Node: html parser --- HTML と XHTML のシンプルなパーサー,  Next: html entities --- HTML 一般実体の定義,  Prev: html --- HyperText Markup Language のサポート,  Up: 構造化マークアップツール

5.20.2 ‘html.parser’ -- HTML と XHTML のシンプルなパーサー
----------------------------------------------------------

'ソースコード:' Lib/html/parser.py(1)

__________________________________________________________________

このモジュールでは *note HTMLParser: 843. クラスを定義します。このクラス
は HTML (ハイパーテキスト記述言語、HyperText Mark-up Language) および
XHTML で書式化されているテキストファイルを解釈するための基礎となります。

 -- クラス: html.parser.HTMLParser (*, convert_charrefs=True)

     不正なマークアップをパースできるパーサーインスタンスを作成します。

     'convert_charrefs' が (デフォルトの) ‘True’ である場合、全ての文字
     参照 (‘script’/‘style’ 要素にあるものは除く) は自動的に対応する
     Unicode 文字に変換されます。

     *note HTMLParser: 843. インスタンスは、HTML データが入力されると、
     開始タグ、終了タグ、およびその他の要素が見つかる度にハンドラーメソ
     ッドを呼び出します。各メソッドの挙動を実装するには *note
     HTMLParser: 843. サブクラスを使ってそれぞれを上書きして行います。

     このパーサーは終了タグが開始タグと一致しているか調べたり、外側のタ
     グ要素が閉じるときに内側で明示的に閉じられていないタグ要素のタグ終
     了ハンドラーを呼び出したりはしません。

     バージョン 3.4 で変更: キーワード引数 'convert_charrefs' を追加。

     バージョン 3.5 で変更: 'convert_charrefs' のデフォルト値は ‘True’ に
     なりました。

* Menu:

* HTML パーサーアプリケーションの例::
* HTMLParser メソッド::
* 使用例: 使用例<31>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/html/parser.py


File: python.info,  Node: HTML パーサーアプリケーションの例,  Next: HTMLParser メソッド,  Up: html parser --- HTML と XHTML のシンプルなパーサー

5.20.2.1 HTML パーサーアプリケーションの例
..........................................

基礎的な例として、*note HTMLParser: 843. クラスを使い、発見した開始タグ
、終了タグ、およびデータを出力する、シンプルな HTML パーサーを以下に示し
ます:

     from html.parser import HTMLParser

     class MyHTMLParser(HTMLParser):
         def handle_starttag(self, tag, attrs):
             print("Encountered a start tag:", tag)

         def handle_endtag(self, tag):
             print("Encountered an end tag :", tag)

         def handle_data(self, data):
             print("Encountered some data  :", data)

     parser = MyHTMLParser()
     parser.feed('<html><head><title>Test</title></head>'
                 '<body><h1>Parse me!</h1></body></html>')

出力は以下のようになります:

     Encountered a start tag: html
     Encountered a start tag: head
     Encountered a start tag: title
     Encountered some data  : Test
     Encountered an end tag : title
     Encountered an end tag : head
     Encountered a start tag: body
     Encountered a start tag: h1
     Encountered some data  : Parse me!
     Encountered an end tag : h1
     Encountered an end tag : body
     Encountered an end tag : html


File: python.info,  Node: HTMLParser メソッド,  Next: 使用例<31>,  Prev: HTML パーサーアプリケーションの例,  Up: html parser --- HTML と XHTML のシンプルなパーサー

5.20.2.2 ‘HTMLParser’ メソッド
..............................

*note HTMLParser: 843. インスタンスは以下のメソッドを提供します:

 -- メソッド: HTMLParser.feed (data)

     パーサーにテキストを入力します。入力が完全なタグ要素で構成されてい
     る場合に限り処理が行われます; 不完全なデータであった場合、新たにデ
     ータが入力されるか、*note close(): 35ef. が呼び出されるまでバッファ
     ーされます。 'data' は *note str: 418. でなければなりません。

 -- メソッド: HTMLParser.close ()

     全てのバッファーされているデータについて、その後にファイル終端マー
     クが続いているとみなして強制的に処理を行います。このメソッドは入力
     データの終端で行う追加処理を定義するために、派生クラスで再定義する
     ことができます。しかし、再定義されたバージョンでは、常に *note
     HTMLParser: 843. 基底クラスのメソッド *note close(): 35ef. を呼び出
     さなくてはなりません。

 -- メソッド: HTMLParser.reset ()

     インスタンスをリセットします。未処理のデータはすべて失われます。イ
     ンスタンス化の際に暗黙的に呼び出されます。

 -- メソッド: HTMLParser.getpos ()

     現在の行番号およびオフセット値を返します。

 -- メソッド: HTMLParser.get_starttag_text ()

     最も最近開かれた開始タグのテキスト部分を返します。このテキストは必
     ずしも元データを構造化する上で必須ではありませんが、 "広く知られて
     いる (as deployed)" HTML を扱ったり、入力を最小限の変更で再生成 (属
     性間の空白をそのままにする、など) したりする場合に便利なことがあり
     ます。

以下のメソッドはデータまたはマークアップ要素が見つかる度に呼び出されます
。これらはサブクラスで上書きされることを想定されています。基底クラスの実
装は (*note handle_startendtag(): 35f3. を除き) 何もしません:

 -- メソッド: HTMLParser.handle_starttag (tag, attrs)

     このメソッドは要素の開始タグを扱うために呼び出されます (例: ‘<div
     id="main">’)。

     引数 'tag' はタグの名前で、小文字に変換されます。引数 'attrs' は
     ‘(name, value)’ のペアからなるリストで、タグの ‘<>’ 括弧内にある属
     性が収められています。'name' は小文字に変換され、'value' 内の引用符
     は取り除かれ、文字参照と実態参照は置き換えられます。

     例えば、タグ ‘<A HREF="https://www.cwi.nl/">’ を処理する場合、この
     メソッドは ‘handle_starttag('a', [('href',
     'https://www.cwi.nl/')])’ として呼び出されます。

     *note html.entities: 62. からのすべての実態参照は、属性値に置き換え
     られます。

 -- メソッド: HTMLParser.handle_endtag (tag)

     このメソッドは要素の終了タグを扱うために呼び出されます (例:
     ‘</div>’)。

     引数 'tag' はタグの名前で、小文字に変換されます。

 -- メソッド: HTMLParser.handle_startendtag (tag, attrs)

     *note handle_starttag(): 35f4. と似ていますが、パーサーが XHTML 形
     式の空タグ (‘<img ... />’) を見つける度に呼び出されます。この特定の
     字句情報が必要な場合にこのメソッドをサブクラスで上書きすることがで
     きます; 既定の実装では、単に *note handle_starttag(): 35f4. および
     *note handle_endtag(): 35f5. を呼び出します。

 -- メソッド: HTMLParser.handle_data (data)

     このメソッドは任意のデータを処理するために呼び出されます (例: テキ
     ストノードおよび ‘<script>...</script>’ aや ‘<style>...</style>’ の
     内容)。

 -- メソッド: HTMLParser.handle_entityref (name)

     このメソッドは ‘&name;’ 形式の名前指定文字参照 (例: ‘&gt;’) を処理
     するために呼び出されます。'name' は一般実体参照になります (例:
     ‘'gt'’)。このメソッドは 'convert_charrefs' が ‘True’ なら呼び出され
     ることはありません。

 -- メソッド: HTMLParser.handle_charref (name)

     このメソッドは ‘&#NNN;’ あるいは ‘&#xNNN;’ 形式の 10進および 16 進
     数値文字参照を処理するために呼び出されます。例えば、‘&gt;’ と等価な
     10 進数は ‘&#62;’ で、16進数は ‘&#x3E;’ になります。この場合、メソ
     ッドは ‘'62'’ あるいは ‘'x3E'’ を受け取ります。このメソッドは
     'convert_charrefs' が ‘True’ なら呼び出されることはありません。

 -- メソッド: HTMLParser.handle_comment (data)

     このメソッドはコメントが見つかった場合に呼び出されます (例:
     ‘<!--comment-->’)。

     例えば、コメント ‘<!-- comment -->’ があると。このメソッドを引数 ‘'
     comment '’ で呼び出されます。

     Internet Explorer 独自拡張の条件付きコメント (condcoms) はこのメソ
     ッドに送ることができます。‘<!--[if IE 9]>IE9-specific
     content<![endif]-->’ の場合、このメソッドは ‘'[if IE
     9]>IE9-specific content<![endif]'’ を受け取ります。

 -- メソッド: HTMLParser.handle_decl (decl)

     このメソッドは HTML doctype 宣言を扱うために呼び出されます (例:
     ‘<!DOCTYPE html>’)。

     引数 'decl' は ‘<!...>’ マークアップ内の宣言の内容全体になります (例
     : ‘'DOCTYPE html'’)。

 -- メソッド: HTMLParser.handle_pi (data)

     処理指令が見つかった場合に呼び出されます。'data' には、処理指令全体
     が含まれ、例えば ‘<?proc color='red'>’ という処理指令の場合、
     ‘handle_pi("proc color='red'")’ のように呼び出されます。このメソッ
     ドは派生クラスで上書きするためのメソッドです; 基底クラスの実装では
     何も行いません。

          注釈: *note HTMLParser: 843. クラスでは、処理指令に SGML の構
          文を使用します。末尾に ‘'?'’ がある XHTML の処理指令では、
          ‘'?'’ が 'data' に含まれることになります。

 -- メソッド: HTMLParser.unknown_decl (data)

     このメソッドはパーサーが未知の宣言を読み込んだ時に呼び出されます。

     パラメータ 'data' は ‘<![...]>’ マークアップ内の宣言の内容全体にな
     ります。 これは派生クラスで上書きする時に役立つことがあります。 基
     底クラスの実装では何もしません。


File: python.info,  Node: 使用例<31>,  Prev: HTMLParser メソッド,  Up: html parser --- HTML と XHTML のシンプルなパーサー

5.20.2.3 使用例
...............

以下のクラスは、より多くの例を示すのに用いられるパーサーの実装です:

     from html.parser import HTMLParser
     from html.entities import name2codepoint

     class MyHTMLParser(HTMLParser):
         def handle_starttag(self, tag, attrs):
             print("Start tag:", tag)
             for attr in attrs:
                 print("     attr:", attr)

         def handle_endtag(self, tag):
             print("End tag  :", tag)

         def handle_data(self, data):
             print("Data     :", data)

         def handle_comment(self, data):
             print("Comment  :", data)

         def handle_entityref(self, name):
             c = chr(name2codepoint[name])
             print("Named ent:", c)

         def handle_charref(self, name):
             if name.startswith('x'):
                 c = chr(int(name[1:], 16))
             else:
                 c = chr(int(name))
             print("Num ent  :", c)

         def handle_decl(self, data):
             print("Decl     :", data)

     parser = MyHTMLParser()

doctype をパースします:

     >>> parser.feed('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" '
     ...             '"http://www.w3.org/TR/html4/strict.dtd">')
     Decl     : DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"

要素のタイトルと一部属性をパースします:

     >>> parser.feed('<img src="python-logo.png" alt="The Python logo">')
     Start tag: img
          attr: ('src', 'python-logo.png')
          attr: ('alt', 'The Python logo')
     >>>
     >>> parser.feed('<h1>Python</h1>')
     Start tag: h1
     Data     : Python
     End tag  : h1

それ以上のパースを行わずに、‘script’ と ‘style’ 要素の内容をそのまま返し
ます:

     >>> parser.feed('<style type="text/css">#python { color: green }</style>')
     Start tag: style
          attr: ('type', 'text/css')
     Data     : #python { color: green }
     End tag  : style

     >>> parser.feed('<script type="text/javascript">'
     ...             'alert("<strong>hello!</strong>");</script>')
     Start tag: script
          attr: ('type', 'text/javascript')
     Data     : alert("<strong>hello!</strong>");
     End tag  : script

コメントをパースします:

     >>> parser.feed('<!-- a comment -->'
     ...             '<!--[if IE 9]>IE-specific content<![endif]-->')
     Comment  :  a comment
     Comment  : [if IE 9]>IE-specific content<![endif]

名前指定および数値文字参照をパースし、正しい文字に変換します (注: これら
3 個の参照はすべて ‘'>'’ と等価です):

     >>> parser.feed('&gt;&#62;&#x3E;')
     Named ent: >
     Num ent  : >
     Num ent  : >

不完全なチャンクを *note feed(): 35ee. に入力しても、('convert_charrefs'
が ‘True’ に設定されていない限り) *note handle_data(): 35f6. は 1 回以上
呼び出される場合があります:

     >>> for chunk in ['<sp', 'an>buff', 'ered ', 'text</s', 'pan>']:
     ...     parser.feed(chunk)
     ...
     Start tag: span
     Data     : buff
     Data     : ered
     Data     : text
     End tag  : span

不正な HTML (例えば属性が引用符で括られていない) のパースも動作します:

     >>> parser.feed('<p><a class=link href=#main>tag soup</p ></a>')
     Start tag: p
     Start tag: a
          attr: ('class', 'link')
          attr: ('href', '#main')
     Data     : tag soup
     End tag  : p
     End tag  : a


File: python.info,  Node: html entities --- HTML 一般実体の定義,  Next: XMLを扱うモジュール群,  Prev: html parser --- HTML と XHTML のシンプルなパーサー,  Up: 構造化マークアップツール

5.20.3 ‘html.entities’ -- HTML 一般実体の定義
---------------------------------------------

'ソースコード:' Lib/html/entities.py(1)

__________________________________________________________________

このモジュールは 4 つの辞書、*note html5: 10a5.、*note name2codepoint:
3601.、*note codepoint2name: 3602.、および *note entitydefs: 3603. を定
義しています。

 -- データ: html.entities.html5

     HTML5 名前付き文字参照 (2) と Unicode 文字とを対応付ける辞書です (例
     : ‘html5['gt;'] == '>'’)。末尾のセミコロンは名前に含まれますが (例:
     ‘'gt;'’)、一部の名前はセミコロンなしでも標準で受け付けます。この場
     合、‘';'’ ありの名前と ‘';'’ なしの名前が両方存在します。 *note
     html.unescape(): 925. も参照してください。

     Added in version 3.3.

 -- データ: html.entities.entitydefs

     各 XHTML 1.0 実体定義と ISO Latin-1 における置換テキストとを対応付
     ける辞書です。

 -- データ: html.entities.name2codepoint

     HTML4 実体名と Unicode コードポイントとを対応付ける辞書です。

 -- データ: html.entities.codepoint2name

     Unicode コードポイントと HTML4 実体名とを対応付ける辞書です。

脚注
....

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/html/entities.py

   (2) 
‘https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references’
を参照


File: python.info,  Node: XMLを扱うモジュール群,  Next: xml etree ElementTree --- ElementTree XML API,  Prev: html entities --- HTML 一般実体の定義,  Up: 構造化マークアップツール

5.20.4 XMLを扱うモジュール群
----------------------------

'ソースコード:' Lib/xml/(1)

__________________________________________________________________

PythonのXMLを扱うインターフェースは ‘xml’ パッケージにまとめられています
。

     警告: XML モジュール群は不正なデータや悪意を持って作成されたデータ
     に対して安全ではありません。信頼できないデータをパースする必要があ
     る場合は *note XML の脆弱性: 3607. と *note defusedxml パッケージ:
     3608. を参照してください。

注意すべき重要な点として、 *note xml: 107. パッケージのモジュールは SAX
に対応した XML パーザが少なくとも一つ利用可能でなければなりません。Expat
パーザが Python に取り込まれているので、 *note xml.parsers.expat: 10d. モ
ジュールは常に利用できます。

*note xml.dom: 108. および *note xml.sax: 110. パッケージのドキュメント
は Python による DOM および SAX インターフェースへのバインディングに関す
る定義です。

XML に関連するサブモジュール:

   * *note xml.etree.ElementTree: 10c.: ElementTree API、シンプルで軽量
     な XML プロセッサ

   * *note xml.dom: 108.: DOM API の定義

   * *note xml.dom.minidom: 109.: 最小限の DOM の実装

   * *note xml.dom.pulldom: 10a.: 部分的な DOM ツリー構築のサポート

   * *note xml.sax: 110.: SAX2 基底クラスと便利関数群

   * *note xml.parsers.expat: 10d.: Expat parser バインディング

* Menu:

* XML の脆弱性::
* defusedxml パッケージ::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/xml/


File: python.info,  Node: XML の脆弱性,  Next: defusedxml パッケージ,  Up: XMLを扱うモジュール群

5.20.4.1 XML の脆弱性
.....................

XML 処理モジュールは悪意を持って生成されたデータに対して安全ではありませ
ん。攻撃者は XML の機能を悪用して DoS攻撃、ローカルファイルへのアクセス
、他マシンへのネットワーク接続、ファイアーウォールの迂回などを行うことが
出来ます。

以下の表は既知の攻撃と各モジュールがそれに対し脆弱かどうかの概要を示して
います。

種類                          sax                    etree                  minidom                pulldom                xmlrpc
                                                                                                                          
-------------------------------------------------------------------------------------------------------------------------------------------------
                                                                                                                          
billion laughs                '脆弱' (1)             '脆弱' (1)             '脆弱' (1)             '脆弱' (1)             '脆弱' (1)
                                                                                                                          
                                                                                                                          
quadratic blowup              '脆弱' (1)             '脆弱' (1)             '脆弱' (1)             '脆弱' (1)             '脆弱' (1)
                                                                                                                          
                                                                                                                          
external entity expansion     安全 (5)               安全 (2)               安全 (3)               安全 (5)               安全 (4)
                                                                                                                          
                                                                                                                          
DTD(1) retrieval              安全 (5)               安全                   安全                   安全 (5)               安全
                                                                                                                          
                                                                                                                          
decompression bomb            安全                   安全                   安全                   安全                   '脆弱'
                                                                                                                          
                                                                                                                          
large tokens                  '脆弱' (6)             '脆弱' (6)             '脆弱' (6)             '脆弱' (6)             '脆弱' (6)
                                                                                                                          

  1. Expat 2.4.1 and newer is not vulnerable to the "billion laughs" and
     "quadratic blowup" vulnerabilities.  Items still listed as
     vulnerable due to potential reliance on system-provided libraries.
     Check ‘pyexpat.EXPAT_VERSION’.

  2. *note xml.etree.ElementTree: 10c. doesn't expand external entities
     and raises a *note ParseError: 1249. when an entity occurs.

  3. *note xml.dom.minidom: 109. は外部エンティティを展開せず、展開前の
     エンティティをそのまま返します。

  4. *note xmlrpc.client: 114. doesn't expand external entities and
     omits them.

  5. Python 3.7.1 からは、一般の外部エンティティはデフォルトで処理されな
     くなりました。

  6. Expat 2.6.0 and newer is not vulnerable to denial of service
     through quadratic runtime caused by parsing large tokens.  Items
     still listed as vulnerable due to potential reliance on
     system-provided libraries.  Check ‘pyexpat.EXPAT_VERSION’.

billion laughs / exponential entity expansion

     Billion Laughs(2) 攻撃 - または指数関数的エンティティ展開
     (exponential entity expansion) - は複数階層の入れ子になったエンティ
     ティを使用します。 各エンティティは別のエンティティを複数回参照し、
     最終的なエンティティの定義は短い文字列です。 指数関数的に展開される
     ことで数 GB のテキストができ、多くのメモリと CPU 時間を消費します。

quadratic blowup entity expansion

     二次爆発攻撃 (quadratic blowup attack) はエンティティ展開を悪用する
     点で Billion Laughs(3) 攻撃に似ています。 入れ子になったエンティテ
     ィの代わりに、この攻撃は数千字の大きなエンティティを何度も繰り返し
     ます。 この攻撃は指数関数的なものほど効率的ではありませんが、パーザ
     の深い入れ子になったエンティティを禁止する対抗手段をすり抜けます。

external entity expansion

     (外部エンティティ展開) エンティティの定義はただのテキスト置換以上の
     ことが出来ます。 外部のリソースやローカルファイルを参照することも出
     来ます。 XML パーザはリソースにアクセスしてその内容を XML 文書に埋
     め込みます。

DTD(4) retrieval

     Python の *note xml.dom.pulldom: 10a. のような XML ライブラリは DTD
     をリモートやローカルの場所から読み込みます。 この機能には外部エンテ
     ィティ展開の問題と同じことが予想されます。

decompression bomb

     解凍爆弾 (あるいは ZIP 爆弾(5)) は、gzip 圧縮 HTTP ストリームや
     LZMA 圧縮ファイルなどの圧縮された XML ストリームをパースできる全て
     の XML ライブラリに対し行われます。 攻撃者は送信データ量を1/3以下に
     減らすことができます。

large tokens

     Expat needs to re-parse unfinished tokens; without the protection
     introduced in Expat 2.6.0, this can lead to quadratic runtime that
     can be used to cause denial of service in the application parsing
     XML. The issue is known as CVE 2023-52425(6).

The documentation for defusedxml(7) on PyPI has further information
about all known attack vectors with examples and references.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Document_type_definition

   (2) https://en.wikipedia.org/wiki/Billion_laughs

   (3) https://en.wikipedia.org/wiki/Billion_laughs

   (4) https://en.wikipedia.org/wiki/Document_type_definition

   (5) 
https://ja.wikipedia.org/wiki/%E9%AB%98%E5%9C%A7%E7%B8%AE%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E7%88%86%E5%BC%BE

   (6) https://www.cve.org/CVERecord?id=CVE-2023-52425

   (7) https://pypi.org/project/defusedxml/


File: python.info,  Node: defusedxml パッケージ,  Prev: XML の脆弱性,  Up: XMLを扱うモジュール群

5.20.4.2 ‘defusedxml’ パッケージ
................................

defusedxml(1) is a pure Python package with modified subclasses of all
stdlib XML parsers that prevent any potentially malicious operation.
Use of this package is recommended for any server code that parses
untrusted XML data.  The package also ships with example exploits and
extended documentation on more XML exploits such as XPath injection.

   ---------- Footnotes ----------

   (1) https://pypi.org/project/defusedxml/


File: python.info,  Node: xml etree ElementTree --- ElementTree XML API,  Next: xml dom --- ドキュメントオブジェクトモデル API,  Prev: XMLを扱うモジュール群,  Up: 構造化マークアップツール

5.20.5 ‘xml.etree.ElementTree’ -- ElementTree XML API
-----------------------------------------------------

'Source code:' Lib/xml/etree/ElementTree.py(1)

__________________________________________________________________

*note xml.etree.ElementTree: 10c. モジュールは、XML データを解析および作
成するシンプルかつ効率的な API を実装しています。

バージョン 3.3 で変更: このモジュールは利用出来る場合は常に高速な実装を
使用します。

バージョン 3.3 で非推奨: The ‘xml.etree.cElementTree’ モジュールは非推奨
です。

     警告: *note xml.etree.ElementTree: 10c. モジュールは悪意を持って作
     成されたデータに対して安全ではありません。信頼できないデータや認証
     されていないデータをパースする必要がある場合は *note XML の脆弱性:
     3607. を参照してください。

* Menu:

* チュートリアル: チュートリアル<2>.
* XPath サポート::
* リファレンス: リファレンス<3>.
* XInclude サポート::
* リファレンス: リファレンス<4>.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/etree/ElementTree.py


File: python.info,  Node: チュートリアル<2>,  Next: XPath サポート,  Up: xml etree ElementTree --- ElementTree XML API

5.20.5.1 チュートリアル
.......................

これは *note xml.etree.ElementTree: 10c. (略して ‘ET’) を使用するための
短いチュートリアルで、ブロックの構築およびモジュールの基本コンセプトを紹
介することを目的としています。

* Menu:

* XML 木構造と要素::
* XML の解析::
* 非ブロックパースのためのプル API::
* 関心ある要素の検索::
* XML ファイルの編集::
* XML 文書の構築::
* 名前空間のある XML の解析::


File: python.info,  Node: XML 木構造と要素,  Next: XML の解析,  Up: チュートリアル<2>

5.20.5.2 XML 木構造と要素
.........................

XML は本質的に階層データ形式で、木構造で表すのが最も自然な方法です。‘ET’
はこの目的のために 2 つのクラス - XML 文書全体を木で表す *note
ElementTree: 91c. および木構造内の単一ノードを表す *note Element: 2e8. -
を持っています。文書全体とのやりとり (ファイルの読み書き) は通常 *note
ElementTree: 91c. レベルで行います。単一 XML 要素およびその子要素とのや
りとりは *note Element: 2e8. レベルで行います。


File: python.info,  Node: XML の解析,  Next: 非ブロックパースのためのプル API,  Prev: XML 木構造と要素,  Up: チュートリアル<2>

5.20.5.3 XML の解析
...................

We'll be using the fictive ‘country_data.xml’ XML document as the sample
data for this section:

     <?xml version="1.0"?>
     <data>
         <country name="Liechtenstein">
             <rank>1</rank>
             <year>2008</year>
             <gdppc>141100</gdppc>
             <neighbor name="Austria" direction="E"/>
             <neighbor name="Switzerland" direction="W"/>
         </country>
         <country name="Singapore">
             <rank>4</rank>
             <year>2011</year>
             <gdppc>59900</gdppc>
             <neighbor name="Malaysia" direction="N"/>
         </country>
         <country name="Panama">
             <rank>68</rank>
             <year>2011</year>
             <gdppc>13600</gdppc>
             <neighbor name="Costa Rica" direction="W"/>
             <neighbor name="Colombia" direction="E"/>
         </country>
     </data>

ファイルを読み込むことでこのデータをインポートすることが出来ます:

     import xml.etree.ElementTree as ET
     tree = ET.parse('country_data.xml')
     root = tree.getroot()

文字列から直接インポートすることも出来ます:

     root = ET.fromstring(country_data_as_string)

*note fromstring(): 3611. は XML を文字列から *note Element: 2e8. に直接
パースします。*note Element: 2e8. はパースされた木のルート要素です。他の
パース関数は *note ElementTree: 91c. を作成するかもしれません。ドキュメ
ントをきちんと確認してください。

*note Element: 2e8. として、‘root’ はタグと属性の辞書を持ちます:

     >>> root.tag
     'data'
     >>> root.attrib
     {}

さらにイテレート可能な子ノードも持ちます:

     >>> for child in root:
     ...     print(child.tag, child.attrib)
     ...
     country {'name': 'Liechtenstein'}
     country {'name': 'Singapore'}
     country {'name': 'Panama'}

子ノードは入れ子になっており、インデックスで子ノードを指定してアクセスで
きます:

     >>> root[0][1].text
     '2008'

     注釈: XML 入力の全ての要素が、パース後の木に要素として含まれる訳で
     はありません。現在、このモジュールは入力中のいかなる XML コメント、
     処理命令、ドキュメントタイプ宣言も読み飛ばします。しかし、XML テキ
     ストからのパースではなく、このモジュールの API を使用して構築された
     木には、コメントや処理命令を含むことができ、それらは XML 出力の生成
     時に含まれます。ドキュメントタイプ宣言は、 *note XMLParser: a22. コ
     ンストラクタにカスタムの *note TreeBuilder: a23. インスタンスを渡す
     ことで、アクセスすることができます。


File: python.info,  Node: 非ブロックパースのためのプル API,  Next: 関心ある要素の検索,  Prev: XML の解析,  Up: チュートリアル<2>

5.20.5.4 非ブロックパースのためのプル API
.........................................

このモジュールが提供するパース関数のほとんどは、結果を返す前に、ドキュメ
ント全体を読む必要があります。 *note XMLParser: a22. を使用して、インク
リメンタルにデータを渡すことは可能ではありますが、それはコールバック対象
のメソッドを呼ぶプッシュ API であり、多くの場合、低水準すぎて不便です。
ユーザーが望むのは、完全に出来上がった *note Element: 2e8. オブジェクト
を便利に使いながら、操作をブロックすることなく XML のパースをインクリメ
ンタルに行えることです。

これを行うための最も強力なツールは、 *note XMLPullParser: fbe. です。XML
データを取得するためにブロックするような読み込みは必要なく、 *note
XMLPullParser.feed(): 3613. を呼び出して、インクリメンタルにデータを読み
ます。パースされた XML 要素を取得するには、*note
XMLPullParser.read_events(): 3614. を呼び出します。以下に、例を示します
。

     >>> parser = ET.XMLPullParser(['start', 'end'])
     >>> parser.feed('<mytag>sometext')
     >>> list(parser.read_events())
     [('start', <Element 'mytag' at 0x7fa66db2be58>)]
     >>> parser.feed(' more text</mytag>')
     >>> for event, elem in parser.read_events():
     ...     print(event)
     ...     print(elem.tag, 'text=', elem.text)
     ...
     end
     mytag text= sometext more text

これの分かりやすい用途は、XML データをソケットから受信したり、ストレージ
デバイスからインクリメンタルに読み出したりするような、非ブロック式に動作
するアプリケーションです。このような場合、ブロッキング読み出しは使用でき
ません。

*note XMLPullParser: fbe. は柔軟性が非常に高いため、単純に使用したいユー
ザーにとっては不便かもしれません。アプリケーションにおいて、XML データの
読み取り時にブロックすることに支障がないが、インクリメンタルにパースする
能力が欲しい場合、*note iterparse(): 254. を参照してください。大きな XML
ドキュメントを読んでいて、全てメモリ上にあるという状態にしたくない場合に
有用です。

Where 'immediate' feedback through events is wanted, calling method
*note XMLPullParser.flush(): 251. can help reduce delay; please make
sure to study the related security notes.


File: python.info,  Node: 関心ある要素の検索,  Next: XML ファイルの編集,  Prev: 非ブロックパースのためのプル API,  Up: チュートリアル<2>

5.20.5.5 関心ある要素の検索
...........................

*note Element: 2e8. は、例えば、*note Element.iter(): 131e. などの、配下
(その子ノードや孫ノードなど) の部分木全体を再帰的にイテレートするいくつ
かの役立つメソッドを持っています:

     >>> for neighbor in root.iter('neighbor'):
     ...     print(neighbor.attrib)
     ...
     {'name': 'Austria', 'direction': 'E'}
     {'name': 'Switzerland', 'direction': 'W'}
     {'name': 'Malaysia', 'direction': 'N'}
     {'name': 'Costa Rica', 'direction': 'W'}
     {'name': 'Colombia', 'direction': 'E'}

*note Element.findall(): 3616. はタグで現在の要素の直接の子要素のみ検索
します。 *note Element.find(): 3617. は特定のタグで '最初の' 子要素を検
索し、 *note Element.text: 3618. は要素のテキストコンテンツにアクセスし
ます。 *note Element.get(): 3619. は要素の属性にアクセスします:

     >>> for country in root.findall('country'):
     ...     rank = country.find('rank').text
     ...     name = country.get('name')
     ...     print(name, rank)
     ...
     Liechtenstein 1
     Singapore 4
     Panama 68

*note XPath: b7b. を使用すると、より洗練された方法で、検索したい要素を指
定することができます。


File: python.info,  Node: XML ファイルの編集,  Next: XML 文書の構築,  Prev: 関心ある要素の検索,  Up: チュートリアル<2>

5.20.5.6 XML ファイルの編集
...........................

*note ElementTree: 91c. は XML 文書を構築してファイルに出力する簡単な方
法を提供しています。*note ElementTree.write(): fc2. メソッドはこの目的に
適います。

*note Element: 2e8. オブジェクトを作成すると、そのフィールドの直接変更
(*note Element.text: 3618. など) や、属性の追加および変更 (*note
Element.set(): 361b. メソッド)、あるいは新しい子ノードの追加 (例えば
*note Element.append(): 361c. など) によってそれを操作できます。

例えば各 country の rank に 1 を足して、rank 要素に ‘updated’ 属性を追加
したい場合:

     >>> for rank in root.iter('rank'):
     ...     new_rank = int(rank.text) + 1
     ...     rank.text = str(new_rank)
     ...     rank.set('updated', 'yes')
     ...
     >>> tree.write('output.xml')

XML はこのようになります:

     <?xml version="1.0"?>
     <data>
         <country name="Liechtenstein">
             <rank updated="yes">2</rank>
             <year>2008</year>
             <gdppc>141100</gdppc>
             <neighbor name="Austria" direction="E"/>
             <neighbor name="Switzerland" direction="W"/>
         </country>
         <country name="Singapore">
             <rank updated="yes">5</rank>
             <year>2011</year>
             <gdppc>59900</gdppc>
             <neighbor name="Malaysia" direction="N"/>
         </country>
         <country name="Panama">
             <rank updated="yes">69</rank>
             <year>2011</year>
             <gdppc>13600</gdppc>
             <neighbor name="Costa Rica" direction="W"/>
             <neighbor name="Colombia" direction="E"/>
         </country>
     </data>

*note Element.remove(): 361d. を使って要素を削除することが出来ます。例え
ば rank が 50 より大きい全ての country を削除したい場合:

     >>> for country in root.findall('country'):
     ...     # using root.findall() to avoid removal during traversal
     ...     rank = int(country.find('rank').text)
     ...     if rank > 50:
     ...         root.remove(country)
     ...
     >>> tree.write('output.xml')

Note that concurrent modification while iterating can lead to problems,
just like when iterating and modifying Python lists or dicts.
Therefore, the example first collects all matching elements with
‘root.findall()’, and only then iterates over the list of matches.

XML はこのようになります:

     <?xml version="1.0"?>
     <data>
         <country name="Liechtenstein">
             <rank updated="yes">2</rank>
             <year>2008</year>
             <gdppc>141100</gdppc>
             <neighbor name="Austria" direction="E"/>
             <neighbor name="Switzerland" direction="W"/>
         </country>
         <country name="Singapore">
             <rank updated="yes">5</rank>
             <year>2011</year>
             <gdppc>59900</gdppc>
             <neighbor name="Malaysia" direction="N"/>
         </country>
     </data>


File: python.info,  Node: XML 文書の構築,  Next: 名前空間のある XML の解析,  Prev: XML ファイルの編集,  Up: チュートリアル<2>

5.20.5.7 XML 文書の構築
.......................

*note SubElement(): 361f. 関数は、与えられた要素に新しい子要素を作成する
便利な手段も提供しています:

     >>> a = ET.Element('a')
     >>> b = ET.SubElement(a, 'b')
     >>> c = ET.SubElement(a, 'c')
     >>> d = ET.SubElement(c, 'd')
     >>> ET.dump(a)
     <a><b /><c><d /></c></a>


File: python.info,  Node: 名前空間のある XML の解析,  Prev: XML 文書の構築,  Up: チュートリアル<2>

5.20.5.8 名前空間のある XML の解析
..................................

XML 入力が 名前空間(1) を持っている場合、 ‘prefix:sometag’ の形式で修飾
されたタグと属性が、その 'prefix' が完全な 'URI' で置換された
‘{uri}sometag’ の形に展開されます。さらに、 デフォルトの XML 名前空間(2)
があると、修飾されていない全てのタグにその完全 URI が前置されます。

ひとつは接頭辞 "fictional" でもうひとつがデフォルト名前空間で提供された
、 2 つの名前空間を組み込んだ XML の例をここにお見せします:

     <?xml version="1.0"?>
     <actors xmlns:fictional="http://characters.example.com"
             xmlns="http://people.example.com">
         <actor>
             <name>John Cleese</name>
             <fictional:character>Lancelot</fictional:character>
             <fictional:character>Archie Leach</fictional:character>
         </actor>
         <actor>
             <name>Eric Idle</name>
             <fictional:character>Sir Robin</fictional:character>
             <fictional:character>Gunther</fictional:character>
             <fictional:character>Commander Clement</fictional:character>
         </actor>
     </actors>

この XML の例を、検索し、渡り歩くためのひとつの方法としては、 *note
find(): 3617. や *note findall(): 3616. に渡す xpath で全てのタグや属性
に手作業で URI を付けてまわる手があります:

     root = fromstring(xml_text)
     for actor in root.findall('{http://people.example.com}actor'):
         name = actor.find('{http://people.example.com}name')
         print(name.text)
         for char in actor.findall('{http://characters.example.com}character'):
             print(' |-->', char.text)

もっと良い方法があります。接頭辞の辞書を作り、これを検索関数で使うことで
す:

     ns = {'real_person': 'http://people.example.com',
           'role': 'http://characters.example.com'}

     for actor in root.findall('real_person:actor', ns):
         name = actor.find('real_person:name', ns)
         print(name.text)
         for char in actor.findall('role:character', ns):
             print(' |-->', char.text)

どちらのアプローチでも同じ結果です:

     John Cleese
      |--> Lancelot
      |--> Archie Leach
     Eric Idle
      |--> Sir Robin
      |--> Gunther
      |--> Commander Clement

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/XML_namespace

   (2) https://www.w3.org/TR/xml-names/#defaulting


File: python.info,  Node: XPath サポート,  Next: リファレンス<3>,  Prev: チュートリアル<2>,  Up: xml etree ElementTree --- ElementTree XML API

5.20.5.9 XPath サポート
.......................

このモジュールは木構造内の要素の位置決めのための XPath 式(1) を限定的に
サポートしています。その目指すところは短縮構文のほんの一部だけのサポート
であり、XPath エンジンのフルセットは想定していません。

* Menu:

* 使用例: 使用例<32>.
* サポートされている XPath 構文::

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/xpath


File: python.info,  Node: 使用例<32>,  Next: サポートされている XPath 構文,  Up: XPath サポート

5.20.5.10 使用例
................

以下はこのモジュールの XPath 機能の一部を紹介する例です。*note XML
の解析: 360f. 節から XML 文書 ‘countrydata’ を使用します:

     import xml.etree.ElementTree as ET

     root = ET.fromstring(countrydata)

     # Top-level elements
     root.findall(".")

     # All 'neighbor' grand-children of 'country' children of the top-level
     # elements
     root.findall("./country/neighbor")

     # Nodes with name='Singapore' that have a 'year' child
     root.findall(".//year/..[@name='Singapore']")

     # 'year' nodes that are children of nodes with name='Singapore'
     root.findall(".//*[@name='Singapore']/year")

     # All 'neighbor' nodes that are the second child of their parent
     root.findall(".//neighbor[2]")

For XML with namespaces, use the usual qualified ‘{namespace}tag’
notation:

     # All dublin-core "title" tags in the document
     root.findall(".//{http://purl.org/dc/elements/1.1/}title")


File: python.info,  Node: サポートされている XPath 構文,  Prev: 使用例<32>,  Up: XPath サポート

5.20.5.11 サポートされている XPath 構文
.......................................

操作                        意味
                            
---------------------------------------------------------------------------------------
                            
‘tag’                       Selects all child elements with the given tag.  For
                            example, ‘spam’ selects all child elements named ‘spam’,
                            and ‘spam/egg’ selects all grandchildren named ‘egg’ in
                            all children named ‘spam’.  ‘{namespace}*’ selects all
                            tags in the given namespace, ‘{*}spam’ selects tags
                            named ‘spam’ in any (or no) namespace, and ‘{}*’ only
                            selects tags that are not in a namespace.
                            
                            バージョン 3.8 で変更: Support for star-wildcards was
                            added.
                            
                            
‘*’                         Selects all child elements, including comments and
                            processing instructions.  For example, ‘*/egg’ selects
                            all grandchildren named ‘egg’.
                            
                            
‘.’                         現在のノードを選択します。これはパスの先頭に置くことで相
                            対パスであることを示すのに役立ちます。
                            
                            
‘//’                        現在の要素の下にある全てのレベルの全ての子要素を選択しま
                            す。例えば、‘.//egg’ は木全体から ‘egg’ 要素を選択します
                            。
                            
                            
‘..’                        親ノードを選択します。パスが開始要素 (‘find’ が呼ばれた
                            要素) の上の要素に進もうとした場合 ‘None’ を返します。
                            
                            
‘[@attrib]’                 与えられた属性を持つ全ての要素を選択します。
                            
                            
‘[@attrib='value']’         与えられた属性が与えられた値を持つ全ての要素を選択します
                            。 値に引用符は含められません。
                            
                            
‘[@attrib!='value']’        Selects all elements for which the given attribute does
                            not have the given value.  The value cannot contain
                            quotes.
                            
                            Added in version 3.10.
                            
                            
‘[tag]’                     ‘tag’ という名前の子要素を持つ全ての要素を選択します。 直
                            下の子要素のみサポートしています。
                            
                            
‘[.='text']’                子孫のうち、与えられた ‘text’ とテキスト全体が等しい全て
                            の要素を選択します。
                            
                            Added in version 3.7.
                            
                            
‘[.!='text']’               Selects all elements whose complete text content,
                            including descendants, does not equal the given ‘text’.
                            
                            Added in version 3.10.
                            
                            
‘[tag='text']’              子孫を含む完全なテキストコンテンツと与えられた ‘text’ が
                            一致する、 ‘tag’ と名付けられた子要素を持つすべての要素
                            を選択します。
                            
                            
‘[tag!='text']’             Selects all elements that have a child named ‘tag’ whose
                            complete text content, including descendants, does not
                            equal the given ‘text’.
                            
                            Added in version 3.10.
                            
                            
‘[position]’                与えられた位置にあるすべての要素を選択します。位置は整数
                            (先頭は 1)、式 ‘last()’ (末尾)、あるいは末尾からの相対位
                            置 (例えば ‘last()-1’) のいずれかで指定できます。
                            

述語 (角括弧内の式) の前にはタグ名、アスタリスク、あるいはその他の述語が
なければなりません。 ‘position’ 述語の前にはタグ名がなければなりません。


File: python.info,  Node: リファレンス<3>,  Next: XInclude サポート,  Prev: XPath サポート,  Up: xml etree ElementTree --- ElementTree XML API

5.20.5.12 リファレンス
......................

* Menu:

* 関数: 関数<9>.


File: python.info,  Node: 関数<9>,  Up: リファレンス<3>

5.20.5.13 関数
..............

 -- の関数: xml.etree.ElementTree.canonicalize (xml_data=None, *,
          out=None, from_file=None, **options)

     C14N 2.0(1) transformation function.

     Canonicalization is a way to normalise XML output in a way that
     allows byte-by-byte comparisons and digital signatures.  It reduces
     the freedom that XML serializers have and instead generates a more
     constrained XML representation.  The main restrictions regard the
     placement of namespace declarations, the ordering of attributes,
     and ignorable whitespace.

     This function takes an XML data string ('xml_data') or a file path
     or file-like object ('from_file') as input, converts it to the
     canonical form, and writes it out using the 'out' file(-like)
     object, if provided, or returns it as a text string if not.  The
     output file receives text, not bytes.  It should therefore be
     opened in text mode with ‘utf-8’ encoding.

     Typical uses:

          xml_data = "<root>...</root>"
          print(canonicalize(xml_data))

          with open("c14n_output.xml", mode='w', encoding='utf-8') as out_file:
              canonicalize(xml_data, out=out_file)

          with open("c14n_output.xml", mode='w', encoding='utf-8') as out_file:
              canonicalize(from_file="inputfile.xml", out=out_file)

     The configuration 'options' are as follows:

        - 'with_comments': set to true to include comments (default:
          false)

        - 
          'strip_text': set to true to strip whitespace before and after text content

               (default: false)

        - 
          'rewrite_prefixes': set to true to replace namespace prefixes by "n{number}"

               (default: false)

        - 
          'qname_aware_tags': a set of qname aware tag names in which prefixes

               should be replaced in text content (default: empty)

        - 
          'qname_aware_attrs': a set of qname aware attribute names in which prefixes

               should be replaced in text content (default: empty)

        - 'exclude_attrs': a set of attribute names that should not be
          serialised

        - 'exclude_tags': a set of tag names that should not be
          serialised

     In the option list above, "a set" refers to any collection or
     iterable of strings, no ordering is expected.

     Added in version 3.8.

 -- の関数: xml.etree.ElementTree.Comment (text=None)

     コメント要素のファクトリです。このファクトリ関数は、標準のシリアラ
     イザでは XML コメントにシリアライズされる特別な要素を作ります。コメ
     ント文字列はバイト文字列でも Unicode 文字列でも構いません。'text' は
     そのコメント文字列を含んだ文字列です。コメントを表わす要素のインス
     タンスを返します。

     *note XMLParser: a22. は、入力に含まれるコメントを読み飛ばし、コメ
     ントオブジェクトは作成しません。*note ElementTree: 91c. は、*note
     Element: 2e8. メソッドの 1 つを使用して木内に挿入されたコメントノー
     ドのみを含みます。

 -- の関数: xml.etree.ElementTree.dump (elem)

     要素の木もしくは要素の構造を sys.stdout に出力します。この関数はデ
     バッグ目的のみに使用してください。

     出力される形式の正確なところは実装依存です。このバージョンでは、通
     常の XML ファイルとして出力されます。

     'elem' は要素の木もしくは個別の要素です。

     バージョン 3.8 で変更: The *note dump(): 3629. function now
     preserves the attribute order specified by the user.

 -- の関数: xml.etree.ElementTree.fromstring (text, parser=None)

     文字列定数で与えられた XML 断片を解析します。 *note XML(): 362a. と
     同じです。 'text' には XML データを含む文字列を指定します。
     'parser' はオプションで、パーザのインスタンスを指定します。指定され
     なかった場合、標準の *note XMLParser: a22. パーザを使用します。
     *note Element: 2e8. インスタンスを返します。

 -- の関数: xml.etree.ElementTree.fromstringlist (sequence, parser=None)

     文字列フラグメントのシーケンスから XML ドキュメントを解析します。
     'sequence' は XML データのフラグメントを格納した、リストかその他の
     シーケンスです。 'parser' はオプションのパーザインスタンスです。パ
     ーザが指定されない場合、標準の *note XMLParser: a22. パーザが使用さ
     れます。 *note Element: 2e8. インスタンスを返します。

     Added in version 3.2.

 -- の関数: xml.etree.ElementTree.indent (tree, space=' ', level=0)

     Appends whitespace to the subtree to indent the tree visually.
     This can be used to generate pretty-printed XML output.  'tree' can
     be an Element or ElementTree.  'space' is the whitespace string
     that will be inserted for each indentation level, two space
     characters by default.  For indenting partial subtrees inside of an
     already indented tree, pass the initial indentation level as
     'level'.

     Added in version 3.9.

 -- の関数: xml.etree.ElementTree.iselement (element)

     オブジェクトが正当な要素オブジェクトであるかをチェックします。
     'element' は要素インスタンスです。引数が要素オブジェクトの場合
     ‘True’ を返します。

 -- の関数: xml.etree.ElementTree.iterparse (source, events=None,
          parser=None)

     Parses an XML section into an element tree incrementally, and
     reports what's going on to the user.  'source' is a filename or
     *note file object: 1193. containing XML data.  'events' is a
     sequence of events to report back.  The supported events are the
     strings ‘"start"’, ‘"end"’, ‘"comment"’, ‘"pi"’, ‘"start-ns"’ and
     ‘"end-ns"’ (the "ns" events are used to get detailed namespace
     information).  If 'events' is omitted, only ‘"end"’ events are
     reported.  'parser' is an optional parser instance.  If not given,
     the standard *note XMLParser: a22. parser is used.  'parser' must
     be a subclass of *note XMLParser: a22. and can only use the default
     *note TreeBuilder: a23. as a target.  Returns an *note iterator:
     191. providing ‘(event, elem)’ pairs; it has a ‘root’ attribute
     that references the root element of the resulting XML tree once
     'source' is fully read.  The iterator has the ‘close()’ method that
     closes the internal file object if 'source' is a filename.

     *note iterparse(): 254. は木をインクリメンタルに構築しますが、
     'source' (または指定のファイル) でのブロッキング読みを起こします。
     したがって、ブロッキング読みが許可されないアプリケーションには適し
     ません。完全に非ブロックのパースのためには、*note XMLPullParser:
     fbe. を参照してください。

          注釈: *note iterparse(): 254. は "start" イベントを発行した時
          に開始タグの文字 ">" が現れたことだけを保証します。そのため、
          属性は定義されますが、その時点ではテキストの内容も tail 属性も
          定義されていません。同じことは子要素にも言えて、その時点ではあ
          るともないとも言えません。

          全部揃った要素が必要ならば、"end" イベントを探してください。

     バージョン 3.4 で非推奨: 'parser' 引数。

     バージョン 3.8 で変更: イベント ‘comment’, ‘pi’ が追加されました。

     バージョン 3.13 で変更: Added the ‘close()’ method.

 -- の関数: xml.etree.ElementTree.parse (source, parser=None)

     XML 断片を解析して要素の木にします。 'source' には XML データを含む
     ファイル名またはファイルオブジェクトを指定します。 'parser' はオプ
     ションでパーザインスタンスを指定します。パーザが指定されない場合、
     標準の *note XMLParser: a22. パーザが使用されます。 *note
     ElementTree: 91c. インスタンスを返します。

 -- の関数: xml.etree.ElementTree.ProcessingInstruction (target,
          text=None)

     PI 要素のファクトリです。このファクトリ関数は XML の処理命令として
     シリアライズされた特別な要素を作成します。'target' は PI ターゲット
     を含んだ文字列です。'text' を指定する場合は PI コンテンツを含む文字
     列にします。PI を表わす要素インスタンスを返します。

     Note that *note XMLParser: a22. skips over processing instructions
     in the input instead of creating PI objects for them.  An *note
     ElementTree: 91c. will only contain processing instruction nodes if
     they have been inserted into to the tree using one of the *note
     Element: 2e8. methods.

 -- の関数: xml.etree.ElementTree.register_namespace (prefix, uri)

     名前空間の接頭辞を登録します。レジストリはグローバルで、与えられた
     接頭辞か名前空間 URI のどちらかの既存のマッピングはすべて削除されま
     す。'prefix' には名前空間の接頭辞を指定します。'uri' には名前空間の
     URI を指定します。この名前空間のタグや属性は、可能な限り与えられた
     接頭辞をつけてシリアライズされます。

     Added in version 3.2.

 -- の関数: xml.etree.ElementTree.SubElement (parent, tag, attrib={},
          **extra)

     子要素のファクトリです。この関数は要素インスタンスを作成し、それを
     既存の要素に追加します。

     要素名、属性名、および属性値はバイト文字列でも Unicode 文字列でも構
     いません。 'parent' には親要素を指定します。 'tag' には要素名を指定
     します。'attrib' はオプションで要素の属性を含む辞書を指定します。
     'extra' は追加の属性で、キーワード引数として与えます。要素インスタ
     ンスを返します。

 -- の関数: xml.etree.ElementTree.tostring (element,
          encoding='us-ascii', method='xml', *, xml_declaration=None,
          default_namespace=None, short_empty_elements=True)

     XML 要素を全ての子要素を含めて表現する文字列を生成します。
     'element' は *note Element: 2e8. のインスタンスです。 'encoding'
     (2) は出力エンコーディング(デフォルトは US-ASCII)です。Unicode 文字
     列を生成するには、‘encoding="unicode"’ を使用してください。
     'method' は ‘"xml"’, ‘"html"’, ‘"text"’ のいずれか(デフォルトは
     ‘"xml"’) です。 'xml_declaration', 'default_namespace',
     'short_empty_elements' は、 *note ElementTree.write(): fc2. での意
     味と同じ意味を持ちます。 XML データを含んだ (オプションで) エンコー
     ドされた文字列を返します。

     バージョン 3.4 で変更: 'short_empty_elements' 引数を追加しました。

     バージョン 3.8 で変更: Added the 'xml_declaration' and
     'default_namespace' parameters.

     バージョン 3.8 で変更: The *note tostring(): fc0. function now
     preserves the attribute order specified by the user.

 -- の関数: xml.etree.ElementTree.tostringlist (element,
          encoding='us-ascii', method='xml', *, xml_declaration=None,
          default_namespace=None, short_empty_elements=True)

     XML 要素を全ての子要素を含めて表現する文字列を生成します。
     'element' は *note Element: 2e8. のインスタンスです。 'encoding'
     (3) は出力エンコーディング(デフォルトは US-ASCII)です。Unicode 文字
     列を生成するには、‘encoding="unicode"’ を使用してください。
     'method' は ‘"xml"’, ‘"html"’, ‘"text"’ のいずれか(デフォルトは
     ‘"xml"’) です。 xml_declaration*, 'default_namespace',
     'short_empty_elements' は、 *note ElementTree.write(): fc2. での意
     味と同じ意味を持ちます。 XML データを含んだ (オプションで) エンコー
     ドされた文字列のリストを返します。‘b"".join(tostringlist(element))
     == tostring(element)’ となること以外、特定の順序になる保証はありま
     せん。

     Added in version 3.2.

     バージョン 3.4 で変更: 'short_empty_elements' 引数を追加しました。

     バージョン 3.8 で変更: Added the 'xml_declaration' and
     'default_namespace' parameters.

     バージョン 3.8 で変更: *note tostringlist(): fc1. 関数はユーザーが
     指定した属性の順序を保持するようになりました。

 -- の関数: xml.etree.ElementTree.XML (text, parser=None)

     文字列定数で与えられた XML 断片を解析します。この関数は Python コー
     ドに "XML リテラル" を埋め込むのに使えます。 'text' には XML データ
     を含む文字列を指定します。 'parser' はオプションで、パーザのインス
     タンスを指定します。指定されなかった場合、標準の *note XMLParser:
     a22. パーザを使用します。 *note Element: 2e8. インスタンスを返しま
     す。

 -- の関数: xml.etree.ElementTree.XMLID (text, parser=None)

     文字列定数で与えられた XML 断片を解析し、要素 ID と要素を対応付ける
     辞書を返します。 'text' には XMLデータを含んだ文字列を指定します。
     'parser' はオプションで、パーザのインスタンスを指定します。指定され
     なかった場合、標準の *note XMLParser: a22. パーザを使用します。
     *note Element: 2e8. のインスタンスと辞書のタプルを返します。

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/xml-c14n2/

   (2) XML 出力に含まれるエンコーディング文字列は適切な規格に従っていな
ければなりません。例えば、"UTF-8" は有効ですが、"UTF8" はそうではありま
せん。‘https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl’ と
‘https://www.iana.org/assignments/character-sets/character-sets.xhtml’ を
参照してください。

   (3) XML 出力に含まれるエンコーディング文字列は適切な規格に従っていな
ければなりません。例えば、"UTF-8" は有効ですが、"UTF8" はそうではありま
せん。‘https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl’ と
‘https://www.iana.org/assignments/character-sets/character-sets.xhtml’ を
参照してください。


File: python.info,  Node: XInclude サポート,  Next: リファレンス<4>,  Prev: リファレンス<3>,  Up: xml etree ElementTree --- ElementTree XML API

5.20.5.14 XInclude サポート
...........................

This module provides limited support for XInclude directives(1), via the
*note xml.etree.ElementInclude: 10b. helper module.  This module can be
used to insert subtrees and text strings into element trees, based on
information in the tree.

* Menu:

* 使用例: 使用例<33>.

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/xinclude/


File: python.info,  Node: 使用例<33>,  Up: XInclude サポート

5.20.5.15 使用例
................

Here's an example that demonstrates use of the XInclude module.  To
include an XML document in the current document, use the
‘{http://www.w3.org/2001/XInclude}include’ element and set the 'parse'
attribute to ‘"xml"’, and use the 'href' attribute to specify the
document to include.

     <?xml version="1.0"?>
     <document xmlns:xi="http://www.w3.org/2001/XInclude">
       <xi:include href="source.xml" parse="xml" />
     </document>

By default, the 'href' attribute is treated as a file name.  You can use
custom loaders to override this behaviour.  Also note that the standard
helper does not support XPointer syntax.

To process this file, load it as usual, and pass the root element to the
*note xml.etree.ElementTree: 10c. module:

     from xml.etree import ElementTree, ElementInclude

     tree = ElementTree.parse("document.xml")
     root = tree.getroot()

     ElementInclude.include(root)

The ElementInclude module replaces the
‘{http://www.w3.org/2001/XInclude}include’ element with the root element
from the 'source.xml' document.  The result might look something like
this:

     <document xmlns:xi="http://www.w3.org/2001/XInclude">
       <para>This is a paragraph.</para>
     </document>

If the 'parse' attribute is omitted, it defaults to "xml".  The href
attribute is required.

To include a text document, use the
‘{http://www.w3.org/2001/XInclude}include’ element, and set the 'parse'
attribute to "text":

     <?xml version="1.0"?>
     <document xmlns:xi="http://www.w3.org/2001/XInclude">
       Copyright (c) <xi:include href="year.txt" parse="text" />.
     </document>

The result might look something like:

     <document xmlns:xi="http://www.w3.org/2001/XInclude">
       Copyright (c) 2003.
     </document>


File: python.info,  Node: リファレンス<4>,  Prev: XInclude サポート,  Up: xml etree ElementTree --- ElementTree XML API

5.20.5.16 リファレンス
......................

* Menu:

* 関数: 関数<10>.
* Element オブジェクト::
* ElementTree オブジェクト::
* QName オブジェクト::
* TreeBuilder オブジェクト::
* XMLParser オブジェクト::
* XMLPullParser オブジェクト::
* 例外: 例外<18>.


File: python.info,  Node: 関数<10>,  Next: Element オブジェクト,  Up: リファレンス<4>

5.20.5.17 関数
..............

 -- の関数: xml.etree.ElementInclude.default_loader (href, parse,
          encoding=None)

     Default loader.  This default loader reads an included resource
     from disk.  'href' is a URL. 'parse' is for parse mode either "xml"
     or "text".  'encoding' is an optional text encoding.  If not given,
     encoding is ‘utf-8’.  Returns the expanded resource.  If the parse
     mode is ‘"xml"’, this is an *note Element: 2e8. instance.  If the
     parse mode is ‘"text"’, this is a string.  If the loader fails, it
     can return ‘None’ or raise an exception.

 -- の関数: xml.etree.ElementInclude.include (elem, loader=None,
          base_url=None, max_depth=6)

     This function expands XInclude directives in-place in tree pointed
     by 'elem'.  'elem' is either the root *note Element: 2e8. or an
     *note ElementTree: 91c. instance to find such element.  'loader' is
     an optional resource loader.  If omitted, it defaults to *note
     default_loader(): 3636.  If given, it should be a callable that
     implements the same interface as *note default_loader(): 3636.
     'base_url' is base URL of the original file, to resolve relative
     include file references.  'max_depth' is the maximum number of
     recursive inclusions.  Limited to reduce the risk of malicious
     content explosion.  Pass ‘None’ to disable the limitation.

     バージョン 3.9 で変更: Added the 'base_url' and 'max_depth'
     parameters.


File: python.info,  Node: Element オブジェクト,  Next: ElementTree オブジェクト,  Prev: 関数<10>,  Up: リファレンス<4>

5.20.5.18 Element オブジェクト
..............................

 -- クラス: xml.etree.ElementTree.Element (tag, attrib={}, **extra)

     要素クラスです。この関数は Element インターフェースを定義すると同時
     に、そのリファレンス実装を提供します。

     要素名、属性名、および属性値はバイト文字列でも Unicode 文字列でも構
     いません。 'tag' には要素名を指定します。'attrib' はオプションで、
     要素と属性を含む辞書を指定します。'extra' は追加の属性で、キーワー
     ド引数として与えます。要素インスタンスを返します。

      -- の属性: tag

          この要素が表すデータの種類を示す文字列です (言い替えると、要素
          の型です)。

      -- の属性: text
      -- の属性: tail

          これらの属性は要素に結びつけられた付加的なデータを保持するのに
          使われます。これらの属性値はたいてい文字列ですが、アプリケーシ
          ョン固有のオブジェクトであって構いません。要素が XML ファイル
          から作られる場合、 'text' 属性は要素の開始タグとその最初の子要
          素または終了タグまでのテキストか、あるいは ‘None’ を保持し、
          'tail' 属性は要素の終了タグと次のタグまでのテキストか、あるい
          は ‘None’ を保持します。このような XML データ

               <a><b>1<c>2<d/>3</c></b>4</a>

          の場合、 'a' 要素は 'text', 'tail' 属性ともに ‘None’, 'b' 要素
          は 'text' に ‘"1"’ で 'tail' に ‘"4"’, 'c' 要素は 'text' に
          ‘"2"’ で 'tail' は ‘None’, 'd' 要素 は 'text' が ‘None’ で
          'tail' に ‘"3"’ をそれぞれ保持します。

          要素の内側のテキストを収集するためには、*note itertext():
          11a5. を参照してください。例えば ‘"".join(element.itertext())’
          のようにします。

          アプリケーションはこれらの属性に任意のオブジェクトを格納できま
          す。

      -- の属性: attrib

          要素の属性を保持する辞書です。 'attrib' の値は常に書き換え可能
          な Python 辞書ですが、ElementTree の実装によっては別の内部表現
          を使用し、要求されたときにだけ辞書を作るようにしているかもしれ
          ません。そうした実装の利益を享受するために、可能な限り下記の辞
          書メソッドを通じて使用してください。

     以下の辞書風メソッドが要素の属性に対して動作します。

      -- メソッド: clear ()

          要素をリセットします。この関数は全ての子要素を削除し、全属性を
          消去し、テキストとテール属性を ‘None’ に設定します。

      -- メソッド: get (key, default=None)

          要素の 'key' という名前の属性を取得します。

          属性の値、または属性がない場合は 'default' を返します。

      -- メソッド: items ()

          要素の属性を (名前, 値) ペアのシーケンスとして返します。返され
          る属性の順番は決まっていません。

      -- メソッド: keys ()

          要素の属性名をリストとして返します。返される名前の順番は決まっ
          ていません。

      -- メソッド: set (key, value)

          要素の属性 'key' に 'value' をセットします。

     以下のメソッドは要素の子要素 (副要素) に対して動作します。

      -- メソッド: append (subelement)

          要素 'subelement' を、要素の子要素の内部リストの末尾に追加しま
          す。'subelement' *note Element: 2e8. でない場合、*note
          TypeError: 502. を送出します。

      -- メソッド: extend (subelements)

          Appends 'subelements' from an iterable of elements.  Raises
          *note TypeError: 502. if a subelement is not an *note Element:
          2e8.

          Added in version 3.2.

      -- メソッド: find (match, namespaces=None)

          Finds the first subelement matching 'match'.  'match' may be a
          tag name or a *note path: b7b.  Returns an element instance or
          ‘None’.  'namespaces' is an optional mapping from namespace
          prefix to full name.  Pass ‘''’ as prefix to move all
          unprefixed tag names in the expression into the given
          namespace.

      -- メソッド: findall (match, namespaces=None)

          Finds all matching subelements, by tag name or *note path:
          b7b.  Returns a list containing all matching elements in
          document order.  'namespaces' is an optional mapping from
          namespace prefix to full name.  Pass ‘''’ as prefix to move
          all unprefixed tag names in the expression into the given
          namespace.

      -- メソッド: findtext (match, default=None, namespaces=None)

          Finds text for the first subelement matching 'match'.  'match'
          may be a tag name or a *note path: b7b.  Returns the text
          content of the first matching element, or 'default' if no
          element was found.  Note that if the matching element has no
          text content an empty string is returned.  'namespaces' is an
          optional mapping from namespace prefix to full name.  Pass
          ‘''’ as prefix to move all unprefixed tag names in the
          expression into the given namespace.

      -- メソッド: insert (index, subelement)

          要素内の指定された位置に 'subelement' を挿入します。
          'subelement' が *note Element: 2e8. でない場合、*note
          TypeError: 502. を送出します。

      -- メソッド: iter (tag=None)

          現在の要素を根とする木の *note イテレータ: 191. を作成します。
          イテレータは現在の要素とそれ以下のすべての要素を、文書内での出
          現順 (深さ優先順) でイテレートします。 'tag' が ‘None’ または
          ‘'*'’ でない場合、与えられたタグに等しいものについてのみイテレ
          ータから返されます。イテレート中に木構造が変更された場合の結果
          は未定義です。

          Added in version 3.2.

      -- メソッド: iterfind (match, namespaces=None)

          タグ名または *note パス: b7b. にマッチするすべての子要素を検索
          します。マッチしたすべての要素を文書内での出現順で yield する
          イテレータを返します。'namespaces' はオプションで、名前空間接
          頭辞と完全名を対応付けるマップオブジェクトを指定します。

          Added in version 3.2.

      -- メソッド: itertext ()

          テキストのイテレータを作成します。イテレータは、この要素とすべ
          ての子要素を文書上の順序で巡回し、すべての内部のテキストを返し
          ます。

          Added in version 3.2.

      -- メソッド: makeelement (tag, attrib)

          現在の要素と同じ型の新しい要素オブジェクトを作成します。このメ
          ソッドは呼び出さずに、 *note SubElement(): 361f. ファクトリ関
          数を使って下さい。

      -- メソッド: remove (subelement)

          要素から 'subelement' を削除します。find* メソッド群と異なり、
          このメソッドは要素をインスタンスの同一性で比較します。タグや内
          容では比較しません。

     *note Element: 2e8. オブジェクトは以下のシーケンス型のメソッドを、
     サブ要素を操作するためにサポートします: *note __delitem__(): 146f,
     *note __getitem__(): 264, *note __setitem__(): 146e, *note
     __len__(): 1ec3.

     Caution: Elements with no subelements will test as ‘False’.  In a
     future release of Python, all elements will test as ‘True’
     regardless of whether subelements exist.  Instead, prefer explicit
     ‘len(elem)’ or ‘elem is not None’ tests.:

          element = root.find('foo')

          if not element:  # careful!
              print("element not found, or element has no subelements")

          if element is None:
              print("element not found")

     バージョン 3.12 で変更: Testing the truth value of an Element emits
     *note DeprecationWarning: 18a.

     Prior to Python 3.8, the serialisation order of the XML attributes
     of elements was artificially made predictable by sorting the
     attributes by their name.  Based on the now guaranteed ordering of
     dicts, this arbitrary reordering was removed in Python 3.8 to
     preserve the order in which attributes were originally parsed or
     created by user code.

     In general, user code should try not to depend on a specific
     ordering of attributes, given that the XML Information Set(1)
     explicitly excludes the attribute order from conveying information.
     Code should be prepared to deal with any ordering on input.  In
     cases where deterministic XML output is required, e.g.  for
     cryptographic signing or test data sets, canonical serialisation is
     available with the *note canonicalize(): 3627. function.

     In cases where canonical output is not applicable but a specific
     attribute order is still desirable on output, code should aim for
     creating the attributes directly in the desired order, to avoid
     perceptual mismatches for readers of the code.  In cases where this
     is difficult to achieve, a recipe like the following can be applied
     prior to serialisation to enforce an order independently from the
     Element creation:

          def reorder_attributes(root):
              for el in root.iter():
                  attrib = el.attrib
                  if len(attrib) > 1:
                      # adjust attribute order, e.g. by sorting
                      attribs = sorted(attrib.items())
                      attrib.clear()
                      attrib.update(attribs)

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/xml-infoset/


File: python.info,  Node: ElementTree オブジェクト,  Next: QName オブジェクト,  Prev: Element オブジェクト,  Up: リファレンス<4>

5.20.5.19 ElementTree オブジェクト
..................................

 -- クラス: xml.etree.ElementTree.ElementTree (element=None, file=None)

     ElementTree ラッパークラスです。このクラスは要素の全階層を表現し、
     さらに標準 XML との相互変換を追加しています。

     'element' は根要素です。'file' が指定されている場合、その XML ファ
     イルの内容により木は初期化されます。

      -- メソッド: _setroot (element)

          この木の根要素を置き換えます。従って現在の木の内容は破棄され、
          与えられた要素が代わりに使われます。注意して使ってください。
          'element' は要素インスタンスです。

      -- メソッド: find (match, namespaces=None)

          *note Element.find(): 3617. と同じで、木の根要素を起点とします
          。

      -- メソッド: findall (match, namespaces=None)

          *note Element.findall(): 3616. と同じで、木の根要素を起点とし
          ます。

      -- メソッド: findtext (match, default=None, namespaces=None)

          *note Element.findtext(): 363f. と同じで、木の根要素を起点とし
          ます。

      -- メソッド: getroot ()

          この木のルート要素を返します。

      -- メソッド: iter (tag=None)

          根要素に対する、木を巡回するイテレータを返します。イテレータは
          木のすべての要素に渡ってセクション順にループします。'tag' は探
          したいタグです (デフォルトではすべての要素を返します)。

      -- メソッド: iterfind (match, namespaces=None)

          *note Element.iterfind(): 11a4. と同じで、木の根要素を起点とし
          ます。

          Added in version 3.2.

      -- メソッド: parse (source, parser=None)

          外部の XML 断片をこの要素木に入れます。'source' にはファイル名
          か *note ファイルオブジェクト: 1193. を指定します。'parser' は
          オプションで、パーザインスタンスを指定します。パーザが指定され
          ない場合、標準の *note XMLParser: a22. パーザが使用されます。
          断片の根要素を返します。

      -- メソッド: write (file, encoding='us-ascii',
               xml_declaration=None, default_namespace=None,
               method='xml', *, short_empty_elements=True)

          要素の木をファイルに XML として書き込みます。 'file' は、書き
          込み用に開かれたファイル名または *note ファイルオブジェクト:
          1193. です。 'encoding' (1) は出力エンコーディング(デフォルト
          は US-ASCII)です。 'xml_declaration' は、 XML 宣言がファイルに
          書かれるかどうかを制御します。 ‘False’ の場合は常に書かれず、
          ‘True’ の場合は常に書かれ、 ‘None’ の場合は US-ASCII 、 UTF-8
          、 Unicode 以外の場合に書かれます (デフォルトは ‘None’ です)。
          'default_namespace' でデフォルトの XML 名前空間 ("xmlns" 用) を
          指定します。 'method' は ‘"xml"’, ‘"html"’, ‘"text"’ のいずれ
          かです (デフォルトは ‘"xml"’ です)。 キーワード専用の
          'short_empty_elements' 引数は、内容がない属性のフォーマットを
          制御します。 ‘True’ (既定) の場合、単一の空要素タグとして書か
          れ、‘False’ の場合、開始タグと終了タグのペアとしてかかれます。

          出力は引数 'encoding' によって、文字列 (*note str: 418.) かバ
          イト列 (*note bytes: 1a4.) になります。'encoding' が
          ‘"unicode"’ の場合、出力は文字列になり、それ以外ではバイト列に
          なります。'file' が *note ファイルオブジェクト: 1193. の場合、
          型が衝突する場合があります。文字列をバイト列ファイルへ書き込ん
          だり、その逆を行わないよう注意してください。

          バージョン 3.4 で変更: 'short_empty_elements' 引数を追加しまし
          た。

          バージョン 3.8 で変更: *note write(): fc2. メソッドはユーザー
          が指定した属性の順序を保持するようになりました。

以下はこれから操作する XML ファイルです:

     <html>
         <head>
             <title>Example page</title>
         </head>
         <body>
             <p>Moved to <a href="http://example.org/">example.org</a>
             or <a href="http://example.com/">example.com</a>.</p>
         </body>
     </html>

第 1 段落のすべてのリンクの "target" 属性を変更する例:

     >>> from xml.etree.ElementTree import ElementTree
     >>> tree = ElementTree()
     >>> tree.parse("index.xhtml")
     <Element 'html' at 0xb77e6fac>
     >>> p = tree.find("body/p")     # Finds first occurrence of tag p in body
     >>> p
     <Element 'p' at 0xb77ec26c>
     >>> links = list(p.iter("a"))   # Returns list of all links
     >>> links
     [<Element 'a' at 0xb77ec2ac>, <Element 'a' at 0xb77ec1cc>]
     >>> for i in links:             # Iterates through all found links
     ...     i.attrib["target"] = "blank"
     ...
     >>> tree.write("output.xhtml")

   ---------- Footnotes ----------

   (1) XML 出力に含まれるエンコーディング文字列は適切な規格に従っていな
ければなりません。例えば、"UTF-8" は有効ですが、"UTF8" はそうではありま
せん。‘https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl’ と
‘https://www.iana.org/assignments/character-sets/character-sets.xhtml’ を
参照してください。


File: python.info,  Node: QName オブジェクト,  Next: TreeBuilder オブジェクト,  Prev: ElementTree オブジェクト,  Up: リファレンス<4>

5.20.5.20 QName オブジェクト
............................

 -- クラス: xml.etree.ElementTree.QName (text_or_uri, tag=None)

     QName ラッパーです。 このクラスは QName 属性値をラップし、出力時に
     適切な名前空間の扱いを得るために使われます。 'text_or_uri' は
     {uri}local という形式の QName 値を含む文字列、または tag 引数が与え
     られた場合には QName の URI 部分の文字列です。 'tag' が与えられた場
     合、一つめの引数は URI と解釈され、この引数はローカル名と解釈されま
     す。 *note QName: 364e. インスタンスは不透明です。


File: python.info,  Node: TreeBuilder オブジェクト,  Next: XMLParser オブジェクト,  Prev: QName オブジェクト,  Up: リファレンス<4>

5.20.5.21 TreeBuilder オブジェクト
..................................

 -- クラス: xml.etree.ElementTree.TreeBuilder (element_factory=None, *,
          comment_factory=None, pi_factory=None, insert_comments=False,
          insert_pis=False)

     汎用の要素構造ビルダー。これは start, data, end, comment, pi のメソ
     ッド呼び出しの列を整形式の要素構造に変換します。このクラスを使うと
     、好みの XML 構文解析器、または他の XML に似た形式の構文解析器を使
     って、要素構造を作り出すことができます。

     'element_factory', when given, must be a callable accepting two
     positional arguments: a tag and a dict of attributes.  It is
     expected to return a new element instance.

     The 'comment_factory' and 'pi_factory' functions, when given,
     should behave like the *note Comment(): 3628. and *note
     ProcessingInstruction(): 362e. functions to create comments and
     processing instructions.  When not given, the default factories
     will be used.  When 'insert_comments' and/or 'insert_pis' is true,
     comments/pis will be inserted into the tree if they appear within
     the root element (but not outside of it).

      -- メソッド: close ()

          ビルダのバッファをフラッシュし、最上位の文書要素を返します。戻
          り値は *note Element: 2e8. インスタンスになります。

      -- メソッド: data (data)

          現在の要素にテキストを追加します。 'data' は文字列です。バイト
          文字列もしくは Unicode 文字列でなければなりません。

      -- メソッド: end (tag)

          現在の要素を閉じます。 'tag' は要素の名前です。閉じられた要素
          を返します。

      -- メソッド: start (tag, attrs)

          新しい要素を開きます。 'tag' は要素の名前です。 'attrs' は要素
          の属性を保持した辞書です。開かれた要素を返します。

      -- メソッド: comment (text)

          Creates a comment with the given 'text'.  If ‘insert_comments’
          is true, this will also add it to the tree.

          Added in version 3.8.

      -- メソッド: pi (target, text)

          Creates a process instruction with the given 'target' name and
          'text'.  If ‘insert_pis’ is true, this will also add it to the
          tree.

          Added in version 3.8.

     加えて、カスタムの *note TreeBuilder: a23. オブジェクトは以下のメソ
     ッドを提供できます:

      -- メソッド: doctype (name, pubid, system)

          doctype 宣言を処理します。 'name' は doctype 名です。 'pubid'
          は公式の識別子です。 'system' はシステム識別子です。このメソッ
          ドはデフォルトの *note TreeBuilder: a23. クラスには存在しませ
          ん。

          Added in version 3.2.

      -- メソッド: start_ns (prefix, uri)

          Is called whenever the parser encounters a new namespace
          declaration, before the ‘start()’ callback for the opening
          element that defines it.  'prefix' is ‘''’ for the default
          namespace and the declared namespace prefix name otherwise.
          'uri' is the namespace URI.

          Added in version 3.8.

      -- メソッド: end_ns (prefix)

          Is called after the ‘end()’ callback of an element that
          declared a namespace prefix mapping, with the name of the
          'prefix' that went out of scope.

          Added in version 3.8.

 -- クラス: xml.etree.ElementTree.C14NWriterTarget (write, *,
          with_comments=False, strip_text=False, rewrite_prefixes=False,
          qname_aware_tags=None, qname_aware_attrs=None,
          exclude_attrs=None, exclude_tags=None)

     A C14N 2.0(1) writer.  Arguments are the same as for the *note
     canonicalize(): 3627. function.  This class does not build a tree
     but translates the callback events directly into a serialised form
     using the 'write' function.

     Added in version 3.8.

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/xml-c14n2/


File: python.info,  Node: XMLParser オブジェクト,  Next: XMLPullParser オブジェクト,  Prev: TreeBuilder オブジェクト,  Up: リファレンス<4>

5.20.5.22 XMLParser オブジェクト
................................

 -- クラス: xml.etree.ElementTree.XMLParser (*, target=None,
          encoding=None)

     このクラスは、このモジュールの構成要素のうち、低水準のものです。効
     率的でイベントベースのXMLパースのため、*note xml.parsers.expat:
     10d. を使用します。*note feed(): 365a. メソッドで XML データをイン
     クリメンタルに受け取り、'target' オブジェクトのコールバックを呼び出
     すことで、パースイベントをプッシュ API に変換します。'target' が省
     略された場合、標準の *note TreeBuilder: a23. が使用されます。
     'encoding' (1) が指定された場合、このあたいは XML ファイル内で指定
     されたエンコーディングを上書きします。

     バージョン 3.8 で変更: Parameters are now *note keyword-only: 285.
     The 'html' argument is no longer supported.

      -- メソッド: close ()

          パーザへのデータの提供を完了します。構築中に渡される 'target'
          の ‘close()’ メソッドを呼び出す結果を返します。既定では、これ
          がトップレベルのドキュメント要素になります。

      -- メソッド: feed (data)

          パーザへデータを入力します。 'data' はエンコードされたデータで
          す。

      -- メソッド: flush ()

          Triggers parsing of any previously fed unparsed data, which
          can be used to ensure more immediate feedback, in particular
          with Expat >=2.6.0.  The implementation of *note flush(): 250.
          temporarily disables reparse deferral with Expat (if currently
          enabled) and triggers a reparse.  Disabling reparse deferral
          has security consequences; please see *note
          xml.parsers.expat.xmlparser.SetReparseDeferralEnabled(): 253.
          for details.

          Note that *note flush(): 250. has been backported to some
          prior releases of CPython as a security fix.  Check for
          availability of *note flush(): 250. using *note hasattr():
          49e. if used in code running across a variety of Python
          versions.

          Added in version 3.13.

     *note XMLParser.feed(): 365a. は 'target' の ‘start(tag,
     attrs_dict)’ メソッドをそれぞれの開始タグに対して呼び、また
     ‘end(tag)’ メソッドを終了タグに対して呼び、そしてデータを
     ‘data(data)’ メソッドで処理します。サポートされているその他のコール
     バックメソッドについては、 *note TreeBuilder: a23. クラスを参照して
     ください。*note XMLParser.close(): 365b. は 'target' の ‘close()’ メ
     ソッドを呼びます。 *note XMLParser: a22. は木構造を構築する以外にも
     使えます。以下の例では、XML ファイルの最高の深さを数えます。

          >>> from xml.etree.ElementTree import XMLParser
          >>> class MaxDepth:                     # The target object of the parser
          ...     maxDepth = 0
          ...     depth = 0
          ...     def start(self, tag, attrib):   # Called for each opening tag.
          ...         self.depth += 1
          ...         if self.depth > self.maxDepth:
          ...             self.maxDepth = self.depth
          ...     def end(self, tag):             # Called for each closing tag.
          ...         self.depth -= 1
          ...     def data(self, data):
          ...         pass            # We do not need to do anything with data.
          ...     def close(self):    # Called when all data has been parsed.
          ...         return self.maxDepth
          ...
          >>> target = MaxDepth()
          >>> parser = XMLParser(target=target)
          >>> exampleXml = """
          ... <a>
          ...   <b>
          ...   </b>
          ...   <b>
          ...     <c>
          ...       <d>
          ...       </d>
          ...     </c>
          ...   </b>
          ... </a>"""
          >>> parser.feed(exampleXml)
          >>> parser.close()
          4

   ---------- Footnotes ----------

   (1) XML 出力に含まれるエンコーディング文字列は適切な規格に従っていな
ければなりません。例えば、"UTF-8" は有効ですが、"UTF8" はそうではありま
せん。‘https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl’ と
‘https://www.iana.org/assignments/character-sets/character-sets.xhtml’ を
参照してください。


File: python.info,  Node: XMLPullParser オブジェクト,  Next: 例外<18>,  Prev: XMLParser オブジェクト,  Up: リファレンス<4>

5.20.5.23 XMLPullParser オブジェクト
....................................

 -- クラス: xml.etree.ElementTree.XMLPullParser (events=None)

     非ブロックアプリケーションに適したプルパーザです。入力側の API は
     *note XMLParser: a22. のものと似ていますが、コールバックターゲット
     に呼び出しをプッシュするのではなく、 *note XMLPullParser: fbe. はパ
     ースイベントの内部リストを収集し、ユーザーがそこから読み出すことが
     できます。'events' は、呼び出し元に報告するイベントのシーケンスです
     。サポートされているイベントは、文字列の ‘"start"’, ‘"end"’,
     ‘"comment"’, ‘"pi"’, ‘"start-ns"’, ‘"end-ns"’ ("ns" イベントは、名
     前空間の詳細情報の取得に使用) です。'events' が省略された場合、
     ‘"end"’ イベントのみが報告されます。

      -- メソッド: feed (data)

          指定したバイトデータをパーザに与えます。

      -- メソッド: flush ()

          Triggers parsing of any previously fed unparsed data, which
          can be used to ensure more immediate feedback, in particular
          with Expat >=2.6.0.  The implementation of *note flush(): 251.
          temporarily disables reparse deferral with Expat (if currently
          enabled) and triggers a reparse.  Disabling reparse deferral
          has security consequences; please see *note
          xml.parsers.expat.xmlparser.SetReparseDeferralEnabled(): 253.
          for details.

          Note that *note flush(): 251. has been backported to some
          prior releases of CPython as a security fix.  Check for
          availability of *note flush(): 251. using *note hasattr():
          49e. if used in code running across a variety of Python
          versions.

          Added in version 3.13.

      -- メソッド: close ()

          パーザに、データストリームが終了したことを伝えます。*note
          XMLParser.close(): 365b. とは異なり、このメソッドは常に *note
          None: 641. を返します。パーザがクローズした時にまだ帰って来て
          いないイベントは、まだ *note read_events(): 3614. で読むことが
          できます。

      -- メソッド: read_events ()

          Return an iterator over the events which have been encountered
          in the data fed to the parser.  The iterator yields ‘(event,
          elem)’ pairs, where 'event' is a string representing the type
          of event (e.g.  ‘"end"’) and 'elem' is the encountered *note
          Element: 2e8. object, or other context value as follows.

             * ‘start’, ‘end’: the current Element.

             * ‘comment’, ‘pi’: the current comment / processing
               instruction

             * ‘start-ns’: a tuple ‘(prefix, uri)’ naming the declared
               namespace mapping.

             * ‘end-ns’: *note None: 641. (this may change in a future
               version)

          *note read_events(): 3614. の前の呼び出しで提供されたイベント
          は、再度 yield されることはありません。イベントは、イテレータ
          から取得された場合にのみ内部キューから消費されるため、*note
          read_events(): 3614. から取得されたイテレータに対して複数の読
          み出しを並行して反復的に行うと、予期せぬ結果が引き起こされます
          。

          注釈: *note XMLPullParser: fbe. は "start" イベントを発行した
          時に開始タグの文字 ">" が現れたことだけを保証します。そのため
          、属性は定義されますが、その時点ではテキストの内容も tail 属性
          も定義されていません。子要素にもそれが存在する、しないにかかわ
          らず同じ物が適用されます。

          全部揃った要素が必要ならば、"end" イベントを探してください。

     Added in version 3.4.

     バージョン 3.8 で変更: イベント ‘comment’, ‘pi’ が追加されました。


File: python.info,  Node: 例外<18>,  Prev: XMLPullParser オブジェクト,  Up: リファレンス<4>

5.20.5.24 例外
..............

 -- クラス: xml.etree.ElementTree.ParseError

     解析に失敗した時、このモジュールの様々なメソッドから送出される XML
     解析エラーです。この例外のインスタンスが表す文字列は、ユーザフレン
     ドリなメッセージを含んでいます。その他に、以下の属性も利用できます:

      -- の属性: code

          expat パーザからの数値エラーコードです。エラーコードの一覧とそ
          れらの意味については、*note xml.parsers.expat: 10d. のドキュメ
          ントを参照してください。

      -- の属性: position

          エラーが発生した場所を示す 'line' と 'column' 番号のタプルです
          。

脚注
....


File: python.info,  Node: xml dom --- ドキュメントオブジェクトモデル API,  Next: xml dom minidom --- 最小限の DOM の実装,  Prev: xml etree ElementTree --- ElementTree XML API,  Up: 構造化マークアップツール

5.20.6 ‘xml.dom’ -- ドキュメントオブジェクトモデル API
------------------------------------------------------

'ソースコード:' Lib/xml/dom/__init__.py(1)

__________________________________________________________________

文書オブジェクトモデル (Document Object Model)、すなわち "DOM" は、ワー
ルドワイドウェブコンソーシアム (World Wide Web Consortium, W3C) による、
XML ドキュメントにアクセスしたり変更を加えたりするための、プログラミング
言語間共通の API です。DOM 実装によって、XML ドキュメントはツリー構造と
して表現されます。また、クライアントコード側でツリー構造をゼロから構築で
きるようになります。さらに、前述の構造に対して、よく知られたインターフェ
ースをもつ一連のオブジェクトを通したアクセス手段も提供します。

DOM はランダムアクセスを行うアプリケーションで非常に有用です。SAX では、
一度に閲覧することができるのはドキュメントのほんの一部分です。ある SAX 要
素に注目している際には、別の要素をアクセスすることはできません。またテキ
ストノードに注目しているときには、その中に入っている要素をアクセスするこ
とができません。SAX によるアプリケーションを書くときには、プログラムがド
キュメント内のどこを処理しているのかを追跡するよう、コードのどこかに記述
する必要があります。SAX 自体がその作業を行ってくれることはありません。さ
らに、XML ドキュメントに対する先読み (look ahead) が必要だとすると不運な
ことになります。

アプリケーションによっては、ツリーにアクセスできなければイベント駆動モデ
ルを実現できません。もちろん、何らかのツリーを SAX イベントに応じて自分
で構築することもできるでしょうが、DOM ではそのようなコードを書かなくても
よくなります。DOM は XML データに対する標準的なツリー表現なのです。

文書オブジェクトモデルは、W3C によっていくつかの段階、W3C の用語で言えば
"レベル (level)" で定義されています。Python においては、DOM API への対応
付けは実質的には DOM レベル 2 勧告に基づいています。

DOM アプリケーションは、普通は XML を DOM に解析するところから始まります
。どのようにして解析を行うかについては DOM レベル 1 では全くカバーしてお
らず、レベル 2 では限定的な改良だけが行われました: レベル 2 では
‘Document’ を生成するメソッドを提供する ‘DOMImplementation’ オブジェクト
クラスがありますが、実装に依存しない方法で XML リーダ(reader)/パーザ
(parser)/文書ビルダ (Document builder) にアクセスする方法はありません。
また、既存の ‘Document’ オブジェクトなしにこれらのメソッドにアクセスする
ような、よく定義された方法もありません。 Python では、各々の DOM 実装で
*note getDOMImplementation(): 3664. が定義されているはずです。 DOM レベ
ル 3 ではロード(Load)/ストア(Store) 仕様が追加され、リーダのインターフェ
ースにを定義していますが、Python 標準ライブラリではまだ利用することがで
きません。

DOM 文書オブジェクトを生成したら、そのプロパティとメソッドを使って XML 文
書の一部にアクセスできます。これらのプロパティは DOM 仕様で定義されてい
ます; 本リファレンスマニュアルでは、Python において DOM 仕様がどのように
解釈されているかを記述しています。

W3C から提供されている仕様は、 DOM API を Java、ECMAScript、および OMG
IDL で定義しています。ここで定義されている Python での対応づけは、大部分
がこの仕様の IDL 版に基づいていますが、厳密な準拠は必要とされていません
(実装で IDL の厳密な対応付けをサポートするのは自由ですが)。API への対応
付けに関する詳細な議論は *note 適合性: 3665. を参照してください。

参考
....

Document Object Model (DOM) Level 2 Specification(2)

     Python DOM API が準拠している W3C 勧告。

Document Object Model (DOM) Level 1 Specification(3)

     *note xml.dom.minidom: 109. でサポートされている W3C の DOM に関す
     る勧告。

Python Language Mapping Specification(4)

     このドキュメントでは OMG IDL から Python への対応付けを記述していま
     す。

* Menu:

* モジュールコンテンツ: モジュールコンテンツ<4>.
* DOM 内のオブジェクト::
* 適合性::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/dom/__init__.py

   (2) https://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/

   (3) https://www.w3.org/TR/REC-DOM-Level-1/

   (4) https://www.omg.org/spec/PYTH/1.2/PDF


File: python.info,  Node: モジュールコンテンツ<4>,  Next: DOM 内のオブジェクト,  Up: xml dom --- ドキュメントオブジェクトモデル API

5.20.6.1 モジュールコンテンツ
.............................

*note xml.dom: 108. には以下の関数があります:

 -- の関数: xml.dom.registerDOMImplementation (name, factory)

     ファクトリ関数 (factory function) 'factory' を名前 'name' で登録し
     ます。ファクトリ関数は ‘DOMImplementation’ インターフェースを実装す
     るオブジェクトを返さなければなりません。特定の実装 (例えば実装が何
     らかのカスタマイズをサポートしている場合) に適切となるように、ファ
     クトリ関数は毎回同じオブジェクトを返したり、呼び出しごとに新しいオ
     ブジェクトを返したりすることが出来ます。

 -- の関数: xml.dom.getDOMImplementation (name=None, features=())

     適切な DOM 実装を返します。'name' は、よく知られた DOM 実装のモジュ
     ール名か、 ‘None’ になります。 ‘None’ でない場合、対応するモジュー
     ルを import して、import が成功した場合 ‘DOMImplementation’ オブジ
     ェクトを返します。 'name' が与えられておらず、環境変数 ‘PYTHON_DOM’
     が設定されていた場合、 DOM 実装を見つけるのに環境変数が使われます。

     'name' が与えられない場合、利用可能な実装を調べて、指定された機能
     (feature) セットを持つものを探します。実装が見つからなければ *note
     ImportError: 3f2. を送出します。 'features' のリストは ‘(feature,
     version)’ のペアからなるシーケンスで、利用可能な
     ‘DOMImplementation’ オブジェクトの ‘hasFeature()’ メソッドに渡され
     ます。

いくつかの便利な定数も提供されています:

 -- データ: xml.dom.EMPTY_NAMESPACE

     DOM 内のノードに名前空間が何も関連づけられていないことを示すために
     使われる値です。この値は通常、ノードの ‘namespaceURI’ の値として見
     つかったり、名前空間特有のメソッドに対する 'namespaceURI' パラメタ
     として使われます。

 -- データ: xml.dom.XML_NAMESPACE

     Namespaces in XML(1) (4 節) で定義されている、予約済みプレフィクス
     (reserved prefix) ‘xml’ に関連付けられた名前空間 URI です。

 -- データ: xml.dom.XMLNS_NAMESPACE

     Document Object Model (DOM) Level 2 Core Specification(2) (1.1.8 節
     ) で定義されている、名前空間宣言への名前空間 URI です。

 -- データ: xml.dom.XHTML_NAMESPACE

     XHTML 1.0: The Extensible HyperText Markup Language(3) (3.1.1 節) で
     定義されている、XHTML 名前空間 URI です。

加えて、 *note xml.dom: 108. には基底となる ‘Node’ クラスと DOM 例外クラ
スが収められています。このモジュールで提供されている ‘Node’ クラスは DOM
仕様で定義されているメソッドや属性は何ら実装していません; これらは具体的
な DOM 実装において提供しなければなりません。このモジュールの一部として
提供されている ‘Node’ クラスでは、具体的な ‘Node’ オブジェクトの
‘nodeType’ 属性として使う定数を提供しています; これらの定数は、DOM 仕様
に適合するため、クラスではなくモジュールのレベルに配置されています。

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/REC-xml-names/

   (2) https://www.w3.org/TR/DOM-Level-2-Core/core.html

   (3) https://www.w3.org/TR/xhtml1/


File: python.info,  Node: DOM 内のオブジェクト,  Next: 適合性,  Prev: モジュールコンテンツ<4>,  Up: xml dom --- ドキュメントオブジェクトモデル API

5.20.6.2 DOM 内のオブジェクト
.............................

DOM について最も明確に限定しているドキュメントは W3C による DOM 仕様です
。

DOM 属性は単純な文字列としてだけではなく、ノードとして操作されるかもしれ
ないので注意してください。とはいえ、そうしなければならない場合はかなり稀
なので、今のところ記述されていません。

インターフェース                     節                                      目的
                                                                             
-------------------------------------------------------------------------------------------------------------------
                                                                             
‘DOMImplementation’                  *note DOMImplementation オブジェクト: 366e.根底にある実装へのインターフェース
                                                                             。
                                                                             
                                                                             
‘Node’                               *note Node オブジェクト: 366f.          ドキュメント内の大部分のオブジェク
                                                                             トに対する基底インターフェース。
                                                                             
                                                                             
‘NodeList’                           *note NodeList オブジェクト: 3670.      ノード列に対するインターフェース。
                                                                             
                                                                             
‘DocumentType’                       *note DocumentType オブジェクト: 3671.  ドキュメントの処理に必要な宣言につ
                                                                             いての情報。
                                                                             
                                                                             
‘Document’                           *note Document オブジェクト: 3672.      ドキュメント全体を表現するオブジェ
                                                                             クト。
                                                                             
                                                                             
‘Element’                            *note Element オブジェクト: 3673.       ドキュメント階層内の要素ノード。
                                                                             
                                                                             
‘Attr’                               *note Attr オブジェクト: 3674.          要素ノード上の属性値ノード。
                                                                             
                                                                             
‘Comment’                            *note Comment オブジェクト: 3675.       ソースドキュメント内のコメント表現
                                                                             。
                                                                             
                                                                             
‘Text’                               *note Text オブジェクトおよび CDATASection オブジェクト: 3676.ドキュメント内のテキスト記述を含む
                                                                             ノード。
                                                                             
                                                                             
‘ProcessingInstruction’              *note ProcessingInstruction オブジェクト: 3677.処理命令 (processing instruction) 表
                                                                             現。
                                                                             

さらに追加の節として、Python で DOM を利用するために定義されている例外に
ついて記述しています。

* Menu:

* DOMImplementation オブジェクト::
* Node オブジェクト::
* NodeList オブジェクト::
* DocumentType オブジェクト::
* Document オブジェクト::
* Element オブジェクト: Element オブジェクト<2>.
* Attr オブジェクト::
* NamedNodeMap Objects::
* Comment オブジェクト::
* Text オブジェクトおよび CDATASection オブジェクト::
* ProcessingInstruction オブジェクト::
* 例外: 例外<19>.


File: python.info,  Node: DOMImplementation オブジェクト,  Next: Node オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.3 DOMImplementation オブジェクト
.......................................

‘DOMImplementation’ インターフェースは、利用している DOM 実装において特
定の機能が利用可能かどうかを決定するための方法をアプリケーションに提供し
ます。DOM レベル 2 では、 ‘DOMImplementation’ を使って新たな ‘Document’
オブジェクトや ‘DocumentType’ オブジェクトを生成する機能も追加しています
。

 -- メソッド: DOMImplementation.hasFeature (feature, version)

     機能名 'feature' とバージョン番号 'version' で識別される機能（
     feature）が実装されていれば ‘True’ を返します。

 -- メソッド: DOMImplementation.createDocument (namespaceUri,
          qualifiedName, doctype)

     新たな(DOMのスーパークラスである) ‘Document’ クラスのオブジェクトを
     返します。このクラスは 'namespaceUri' と 'qualifiedName' が設定され
     た子クラス ‘Element’ のオブジェクトを所有しています。 'doctype' は
     *note createDocumentType(): 367b. によって生成された ‘DocumentType’
     クラスのオブジェクト、または ‘None’ である必要があります。 Python
     DOM APIでは、子クラスである ‘Element’ を作成しないことを示すために
     、はじめの２つの引数を ‘None’ に設定することができます。

 -- メソッド: DOMImplementation.createDocumentType (qualifiedName,
          publicId, systemId)

     新たな ‘DocumentType’ クラスのオブジェクトを返します。このオブジェ
     クトは 'qualifiedName' 、 'publicId' 、そして 'systemId' 文字列をふ
     くんでおり、XML文書の形式情報を表現しています。


File: python.info,  Node: Node オブジェクト,  Next: NodeList オブジェクト,  Prev: DOMImplementation オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.4 Node オブジェクト
..........................

XML 文書の全ての構成要素は ‘Node’ のサブクラスです。

 -- の属性: Node.nodeType

     ノード (node) の型を表現する整数値です。型に対応する以下のシンボル
     定数: ‘ELEMENT_NODE’ 、 ‘ATTRIBUTE_NODE’ 、 ‘TEXT_NODE’ 、
     ‘CDATA_SECTION_NODE’ 、 ‘ENTITY_NODE’ 、
     ‘PROCESSING_INSTRUCTION_NODE’ 、 ‘COMMENT_NODE’ 、 ‘DOCUMENT_NODE’
     、 ‘DOCUMENT_TYPE_NODE’ 、 ‘NOTATION_NODE’ 、が ‘Node’ オブジェクト
     で定義されています。読み出し専用の属性です。

 -- の属性: Node.parentNode

     現在のノードの親ノードか、文書ノードの場合には ‘None’ になります。
     この値は常に ‘Node’ オブジェクトか ‘None’ になります。 ‘Element’ ノ
     ードの場合、この値はルート要素 (root element) の場合を除き親要素
     (parent element) となり、ルート要素の場合には ‘Document’ オブジェク
     トとなります。 ‘Attr’ ノードの場合、この値は常に ‘None’ となります
     。読み出し専用の属性です。

 -- の属性: Node.attributes

     属性オブジェクトの ‘NamedNodeMap’ です。要素だけがこの属性に実際の
     値を持ちます; その他のオブジェクトでは、この属性を ‘None’ にします
     。読み出し専用の属性です。

 -- の属性: Node.previousSibling

     このノードと同じ親ノードを持ち、直前にくるノードです。例えば、
     'self' 要素の開始タグの直前にくる終了タグを持つ要素です。もちろん、
     XML 文書は要素だけで構成されているだけではないので、直前にくる兄弟
     関係にある要素 (sibling) はテキストやコメント、その他になる可能性が
     あります。このノードが親ノードにおける先頭の子ノードである場合、属
     性値は ‘None’ になります。読み出し専用の属性です。

 -- の属性: Node.nextSibling

     このノードと同じ親ノードを持ち、直後にくるノードです。例えば、
     *note previousSibling: 3680. も参照してください。このノードが親ノー
     ドにおける末尾の子ノードである場合、属性値は ‘None’ になります。読
     み出し専用の属性です。

 -- の属性: Node.childNodes

     このノード内に収められているノードからなるリストです。読み出し専用
     の属性です。

 -- の属性: Node.firstChild

     このノードに子ノードがある場合、その先頭のノードです。そうでない場
     合 ‘None’ になります。読み出し専用の属性です。

 -- の属性: Node.lastChild

     このノードに子ノードがある場合、その末尾のノードです。そうでない場
     合 ‘None’ になります。読み出し専用の属性です。

 -- の属性: Node.localName

     ‘tagName’ にコロンがあれば、コロン以降の部分に、なければ ‘tagName’
     全体になります。値は文字列です。

 -- の属性: Node.prefix

     ‘tagName’ のコロンがあれば、コロン以前の部分に、なければ空文字列に
     なります。値は文字列か、 ‘None’ になります。

 -- の属性: Node.namespaceURI

     要素名に関連付けられた名前空間です。文字列か ‘None’ になります。読
     み出し専用の属性です。

 -- の属性: Node.nodeName

     この属性はノード型ごとに異なる意味を持ちます。その詳細は DOM 仕様を
     参照してください。この属性で得られることになる情報は、全てのノード
     型では ‘tagName’ 、属性では ‘name’ プロパティといったように、常に他
     のプロパティで得ることができます。全てのノード型で、この属性の値は
     文字列か ‘None’ になります。読み出し専用の属性です。

 -- の属性: Node.nodeValue

     この属性はノード型ごとに異なる意味を持ちます。その詳細は DOM 仕様を
     参照してください。その状況は *note nodeName: 3688. と似ています。こ
     の属性の値は文字列または ‘None’ になります。

 -- メソッド: Node.hasAttributes ()

     ノードが何らかの属性を持っている場合に ‘True’ を返します。

 -- メソッド: Node.hasChildNodes ()

     ノードが何らかの子ノードを持っている場合に ‘True’ を返します。

 -- メソッド: Node.isSameNode (other)

     'other' がこのノードと同じノードを参照している場合に ‘True’ を返し
     ます。このメソッドは、何らかのプロキシ (proxy) 機構を利用するような
     DOM 実装で特に便利です (一つ以上のオブジェクトが同じノードを参照す
     るかもしれないからです)。

          注釈: このメソッドは DOM レベル 3 API の提案に基づいたもので、
          まだ "ワーキングドラフト(working draft)" の段階です。しかし、
          このインターフェースには異論は出ないと考えられます。W3C による
          変更があっても、必ずしも Python DOM インターフェースにおけるこ
          のメソッドに影響するとは限りません (ただしこのメソッドに対する
          何らかの新しい W3C API もサポートされるかもしれません)。

 -- メソッド: Node.appendChild (newChild)

     現在のノードの子ノードリストの末尾に新たな子ノードを追加し、
     'newChild' を返します。もしノードが既にツリーにあれば、最初に削除さ
     れます。

 -- メソッド: Node.insertBefore (newChild, refChild)

     新たな子ノードを既存の子ノードの前に挿入します。 'refChild' は現在
     のノードの子ノードである場合に限られます; そうでない場合、 *note
     ValueError: 1e3. が送出されます。 'newChild' が返されます。もし
     'refChild' が ‘None’ なら、 'newChild' を子ノードリストの最後に挿入
     します。

 -- メソッド: Node.removeChild (oldChild)

     子ノードを削除します。 'oldChild' はこのノードの子ノードでなければ
     なりません。そうでない場合、 *note ValueError: 1e3. が送出されます
     。成功した場合 'oldChild' が返されます。 'oldChild' をそれ以降使わ
     ない場合、 ‘unlink()’ メソッドを呼び出さなければなりません。

 -- メソッド: Node.replaceChild (newChild, oldChild)

     既存のノードと新たなノードを置き換えます。この操作は 'oldChild' が
     現在のノードの子ノードである場合に限られます; そうでない場合、
     *note ValueError: 1e3. が送出されます。

 -- メソッド: Node.normalize ()

     一続きのテキスト全体を一個の ‘Text’ インスタンスとして保存するため
     に隣接するテキストノードを結合します。これにより、多くのアプリケー
     ションで DOM ツリーからのテキスト処理が簡単になります。

 -- メソッド: Node.cloneNode (deep)

     このノードを複製 (clone) します。'deep' を設定すると、子ノードも同
     様に複製することを意味します。複製されたノードを返します。


File: python.info,  Node: NodeList オブジェクト,  Next: DocumentType オブジェクト,  Prev: Node オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.5 NodeList オブジェクト
..............................

‘NodeList’ はノードのシーケンスを表現します。 これらのオブジェクトは DOM
コア勧告 (DOM Core recommendation) において、二通りに使われています:
‘Element’ オブジェクトでは、子ノードのリストを提供するのに ‘NodeList’ を
利用します。 また、このインターフェースにおける ‘Node’ の
‘getElementsByTagName()’ および ‘getElementsByTagNameNS()’ メソッドは、
クエリに対する結果を表現するのに ‘NodeList’ を利用します。

DOM レベル 2 勧告では、これらのオブジェクトに対し、以下のようにメソッド
を一つ、属性を一つ定義しています。

 -- メソッド: NodeList.item (i)

     存在する場合シークエンスの 'i' 番目の要素を、そうでない場合 ‘None’
     を返します。'i' は 0 未満やシークエンスの長さ以上であってはなりませ
     ん。

 -- の属性: NodeList.length

     シーケンス中のノードの数です。

この他に、Python の DOM インターフェースでは、 ‘NodeList’ オブジェクトを
Python のシーケンスとして使えるようにするサポートが追加されていることが
必要です。 ‘NodeList’ の実装では、全て *note __len__(): 1ec3. と *note
__getitem__(): 264. をサポートしなければなりません; このサポートにより、
*note for: 2c9. 文内で ‘NodeList’ にわたる繰り返しと、組み込み関数 *note
len(): 5fa. の適切なサポートができるようになります。

DOM 実装が文書の変更をサポートしている場合、 ‘NodeList’ の実装でも *note
__setitem__(): 146e. および *note __delitem__(): 146f. メソッドをサポー
トしなければなりません。


File: python.info,  Node: DocumentType オブジェクト,  Next: Document オブジェクト,  Prev: NodeList オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.6 DocumentType オブジェクト
..................................

文書で宣言されている記法 (notation) やエンティティ (entity) に関する (外
部サブセット(external subset) がパーザから利用でき、情報を提供できる場合
にはそれも含めた) 情報は、 ‘DocumentType’ オブジェクトから手に入れること
ができます。文書の ‘DocumentType’ は、 ‘Document’ オブジェクトの
‘doctype’ 属性で入手することができます; 文書の ‘DOCTYPE’ 宣言がない場合
、文書の ‘doctype’ 属性は、このインターフェースを持つインスタンスの代わ
りに ‘None’ に設定されます。

‘DocumentType’ は ‘Node’ を特殊化したもので、以下の属性を加えています:

 -- の属性: DocumentType.publicId

     文書型定義 (document type definition) の外部サブセットに対する公開
     識別子 (public identifier) です。文字列または ‘None’ になります。

 -- の属性: DocumentType.systemId

     文書型定義 (document type definition) の外部サブセットに対するシス
     テム識別子 (system identifier) です。文字列の URI または ‘None’ に
     なります。

 -- の属性: DocumentType.internalSubset

     ドキュメントの完全な内部サブセットを与える文字列です。サブセットを
     囲むブラケットは含みません。ドキュメントが内部サブセットを持たない
     場合、この値は ‘None’ です。

 -- の属性: DocumentType.name

     ‘DOCTYPE’ 宣言でルート要素の名前が与えられている場合、その値になり
     ます。

 -- の属性: DocumentType.entities

     外部エンティティの定義を与える ‘NamedNodeMap’ です。複数回定義され
     ているエンティティに対しては、最初の定義だけが提供されます (その他
     は XML 勧告での要求仕様によって無視されます)。パーザによって情報が
     提供されないか、エンティティが定義されていない場合には、この値は
     ‘None’ になることがあります。

 -- の属性: DocumentType.notations

     記法の定義を与える ‘NamedNodeMap’ です。複数回定義されている記法名
     に対しては、最初の定義だけが提供されます (その他は XML 勧告での要求
     仕様によって無視されます)。パーザによって情報が提供されないか、エン
     ティティが定義されていない場合には、この値は ‘None’ になることがあ
     ります。


File: python.info,  Node: Document オブジェクト,  Next: Element オブジェクト<2>,  Prev: DocumentType オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.7 Document オブジェクト
..............................

‘Document’ は XML ドキュメント全体を表現し、その構成要素である要素、属性
、処理命令、コメント等を持ちます。 ‘Document’ は ‘Node’ からプロパティを
継承していることを思い出してください。

 -- の属性: Document.documentElement

     ドキュメントの唯一無二のルート要素です。

 -- メソッド: Document.createElement (tagName)

     新たな要素ノードを生成して返します。要素は、生成された時点ではドキ
     ュメント内に挿入されません。 ‘insertBefore()’ や ‘appendChild()’ の
     ような他のメソッドの一つを使って明示的に挿入を行う必要があります。

 -- メソッド: Document.createElementNS (namespaceURI, tagName)

     名前空間を伴う新たな要素ノードを生成して返します。 'tagName' には接
     頭辞 (prefix) があってもかまいません。要素は、生成された時点では文
     書内に挿入されません。 ‘insertBefore()’ や ‘appendChild()’ のような
     他のメソッドの一つを使って明示的に挿入を行う必要があります。

 -- メソッド: Document.createTextNode (data)

     引数として渡されたデータの入ったテキストノードを生成して返します。
     他の生成 (create) メソッドと同じく、このメソッドは生成されたノード
     をツリーに挿入しません。

 -- メソッド: Document.createComment (data)

     引数として渡されたデータの入ったコメントノードを生成して返します。
     他の生成 (create) メソッドと同じく、このメソッドは生成されたノード
     をツリーに挿入しません。

 -- メソッド: Document.createProcessingInstruction (target, data)

     引数として渡された 'target' および 'data' の入った処理命令ノードを
     生成して返します。他の生成 (create) メソッドと同じく、このメソッド
     は生成されたノードをツリーに挿入しません。

 -- メソッド: Document.createAttribute (name)

     属性ノードを生成して返します。このメソッドは属性ノードを特定の要素
     に関連づけることはしません。新たに生成された属性インスタンスを使う
     には、適切な ‘Element’ オブジェクトの ‘setAttributeNode()’ を使わな
     ければなりません。

 -- メソッド: Document.createAttributeNS (namespaceURI, qualifiedName)

     名前空間を伴う新たな属性ノードを生成して返します。 'tagName' には接
     頭辞 (prefix) があってもかまいません。このメソッドは属性ノードを特
     定の要素に関連づけることはしません。新たに生成された属性インスタン
     スを使うには、適切な ‘Element’ オブジェクトの ‘setAttributeNode()’
     を使わなければなりません。

 -- メソッド: Document.getElementsByTagName (tagName)

     全ての下位要素 (直接の子要素、子要素の子要素等) から特定の要素型名
     を持つものを検索します。

 -- メソッド: Document.getElementsByTagNameNS (namespaceURI, localName)

     全ての下位要素 (直接の子要素、子要素の子要素等) から特定の名前空間
     URI とローカル名 (local name) を持つものを検索します。ローカル名は
     名前空間における接頭辞以降の部分です。


File: python.info,  Node: Element オブジェクト<2>,  Next: Attr オブジェクト,  Prev: Document オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.8 Element オブジェクト
.............................

‘Element’ は ‘Node’ のサブクラスです。このため ‘Node’ クラスの全ての属性
を継承します。

 -- の属性: Element.tagName

     要素型名です。名前空間使用の文書では、要素型名中にコロンがあるかも
     しれません。値は文字列です。

 -- メソッド: Element.getElementsByTagName (tagName)

     ‘Document’ クラス内における同名のメソッドと同じです。

 -- メソッド: Element.getElementsByTagNameNS (namespaceURI, localName)

     ‘Document’ クラス内における同名のメソッドと同じです。

 -- メソッド: Element.hasAttribute (name)

     指定要素に 'name' で渡した名前の属性が存在していれば ‘True’ を返し
     ます。

 -- メソッド: Element.hasAttributeNS (namespaceURI, localName)

     指定要素に 'namespaceURI' と 'localName' で指定した名前の属性が存在
     していれば ‘True’ を返します。

 -- メソッド: Element.getAttribute (name)

     'name' で指定した属性の値を文字列として返します。もし、属性が存在し
     ない、もしくは属性に値が設定されていない場合、空の文字列が返されま
     す。

 -- メソッド: Element.getAttributeNode (attrname)

     'attrname' で指定された属性の ‘Attr’ ノードを返します。

 -- メソッド: Element.getAttributeNS (namespaceURI, localName)

     'namespaceURI' と 'localName' によって指定した属性の値を文字列とし
     て返します。もし、属性が存在しない、もしくは属性に値が設定されてい
     ない場合、空の文字列が返されます。

 -- メソッド: Element.getAttributeNodeNS (namespaceURI, localName)

     指定した 'namespaceURI' および 'localName' を持つ属性値をノードとし
     て返します。

 -- メソッド: Element.removeAttribute (name)

     名前で指定された属性を削除します。該当する属性がない場合、*note
     NotFoundErr: 36b3. が送出されます。

 -- メソッド: Element.removeAttributeNode (oldAttr)

     'oldAttr' が属性リストにある場合、削除して返します。 'oldAttr' が存
     在しない場合、 *note NotFoundErr: 36b3. が送出されます。

 -- メソッド: Element.removeAttributeNS (namespaceURI, localName)

     名前で指定された属性を削除します。このメソッドは 'qname' ではなく
     'localName' を使うので注意してください。該当する属性がなくても例外
     は送出されません。

 -- メソッド: Element.setAttribute (name, value)

     文字列を使って属性値を設定します。

 -- メソッド: Element.setAttributeNode (newAttr)

     新たな属性ノードを要素に追加します。 ‘name’ 属性が既存の属性に一致
     した場合、必要に応じて属性を置換します。置換が行われると古い属性ノ
     ードが返されます。 'newAttr' がすでに使われていれば、 *note
     InuseAttributeErr: 36b8. が送出されます。

 -- メソッド: Element.setAttributeNodeNS (newAttr)

     新たな属性ノードを要素に追加します。 ‘namespaceURI’ および
     ‘localName’ 属性が既存の属性に一致した場合、必要に応じて属性を置き
     換えます。置換が生じると、古い属性ノードが返されます。 'newAttr' が
     すでに使われていれば、 *note InuseAttributeErr: 36b8. が送出されま
     す。

 -- メソッド: Element.setAttributeNS (namespaceURI, qname, value)

     指定された 'namespaceURI' および 'qname' で与えられた属性の値を文字
     列で設定します。qname は属性の完全な名前であり、この点が上記のメソ
     ッドと違うので注意してください。


File: python.info,  Node: Attr オブジェクト,  Next: NamedNodeMap Objects,  Prev: Element オブジェクト<2>,  Up: DOM 内のオブジェクト

5.20.6.9 Attr オブジェクト
..........................

‘Attr’ は ‘Node’ を継承しており、全ての属性を継承しています。

 -- の属性: Attr.name

     要素型名です。名前空間使用の文書では、要素型名中にコロンが含まれる
     かもしれません。

 -- の属性: Attr.localName

     名前にコロンがあればコロン以降の部分に、なければ名前全体になります
     。

 -- の属性: Attr.prefix

     名前にコロンがあればコロン以前の部分に、なければ空文字列になります
     。

 -- の属性: Attr.value

     その要素の text value.  これは ‘nodeValue’ 属性の別名です。


File: python.info,  Node: NamedNodeMap Objects,  Next: Comment オブジェクト,  Prev: Attr オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.10 NamedNodeMap Objects
..............................

‘NamedNodeMap’ は ‘Node’ を継承して 'いません' 。

 -- の属性: NamedNodeMap.length

     属性リストの長さです。

 -- メソッド: NamedNodeMap.item (index)

     特定のインデクスを持つ属性を返します。属性の並び方は任意ですが、
     DOM 文書が生成されている間は一定になります。各要素は属性ノードです
     。属性値はノードの ‘value’ 属性で取得してください。

このクラスをよりマップ型的な動作ができるようにする実験的なメソッドもあり
ます。そうしたメソッドを使うこともできますし、 ‘Element’ オブジェクトに
対して、標準化された ‘getAttribute*()’ ファミリのメソッドを使うこともで
きます。


File: python.info,  Node: Comment オブジェクト,  Next: Text オブジェクトおよび CDATASection オブジェクト,  Prev: NamedNodeMap Objects,  Up: DOM 内のオブジェクト

5.20.6.11 Comment オブジェクト
..............................

‘Comment’ は XML 文書中のコメントを表現します。 ‘Comment’ は ‘Node’ のサ
ブクラスですが、子ノードを持つことはありません。

 -- の属性: Comment.data

     文字列によるコメントの内容です。この属性には、コメントの先頭にある
     ‘<!-’ ‘-’ と末尾にある ‘-’ ‘->’ 間の全ての文字が入っていますが、
     ‘<!-’ ‘-’ と ‘-’ ‘->’ 自体は含みません。


File: python.info,  Node: Text オブジェクトおよび CDATASection オブジェクト,  Next: ProcessingInstruction オブジェクト,  Prev: Comment オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.12 Text オブジェクトおよび CDATASection オブジェクト
...........................................................

‘Text’ インターフェースは XML 文書内のテキストを表現します。パーザおよび
DOM 実装が DOM の XML 拡張をサポートしている場合、 CDATA でマークされた
区域 (section) に入れられている部分テキストは ‘CDATASection’ オブジェク
トに記憶されます。これら二つのインターフェースは同一のものですが、
‘nodeType’ 属性が異なります。

これらのインターフェースは ‘Node’ インターフェースを拡張したものです。し
かし子ノードを持つことはできません。

 -- の属性: Text.data

     文字列によるテキストノードの内容です。

     注釈: ‘CDATASection’ ノードの利用は、ノードが完全な CDATA マーク区
     域を表現するという意味ではなく、ノードの内容が CDATA 区域の一部であ
     るということを意味するだけです。単一の CDATA セクションは文書ツリー
     内で複数のノードとして表現されることがあります。二つの隣接する
     ‘CDATASection’ ノードが、異なる CDATA マーク区域かどうかを決定する
     方法はありません。


File: python.info,  Node: ProcessingInstruction オブジェクト,  Next: 例外<19>,  Prev: Text オブジェクトおよび CDATASection オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.13 ProcessingInstruction オブジェクト
............................................

XML 文書内の処理命令を表現します; ‘Node’ インターフェースを継承していま
すが、子ノードを持つことはできません。

 -- の属性: ProcessingInstruction.target

     最初の空白文字までの処理命令の内容です。読み出し専用の属性です。

 -- の属性: ProcessingInstruction.data

     最初の空白文字以降の処理命令の内容です。


File: python.info,  Node: 例外<19>,  Prev: ProcessingInstruction オブジェクト,  Up: DOM 内のオブジェクト

5.20.6.14 例外
..............

DOM レベル 2 勧告では、単一の例外 *note DOMException: 36cd. と、どの種の
エラーが発生したかをアプリケーションが決定できるようにする多くの定数を定
義しています。 *note DOMException: 36cd. インスタンスは、特定の例外に関
する適切な値を提供する *note code: 13. 属性を伴っています。

Python DOM インターフェースでは、上記の定数を提供していますが、同時に一
連の例外を拡張して、DOM で定義されている各例外コードに対して特定の例外が
存在するようにしています。 DOM の実装では、適切な特定の例外を送出しなけ
ればならず、各例外は *note code: 13. 属性に対応する適切な値を伴わなけれ
ばなりません。

 -- 例外: xml.dom.DOMException

     全ての特定の DOM 例外で使われている基底例外クラスです。この例外クラ
     スを直接インスタンス化することはできません。

 -- 例外: xml.dom.DomstringSizeErr

     指定された範囲のテキストが文字列に収まらない場合に送出されます。こ
     の例外は Python の DOM 実装で使われるかどうかは判っていませんが、
     Python で書かれていない DOM 実装から送出される場合があります。

 -- 例外: xml.dom.HierarchyRequestErr

     挿入できない型のノードを挿入しようと試みたときに送出されます。

 -- 例外: xml.dom.IndexSizeErr

     メソッドに与えたインデクスやサイズパラメタが負の値や許容範囲の値を
     超えた際に送出されます。

 -- 例外: xml.dom.InuseAttributeErr

     文書中にすでに存在する ‘Attr’ ノードを挿入しようと試みた際に送出さ
     れます。

 -- 例外: xml.dom.InvalidAccessErr

     パラメタまたは操作が根底にあるオブジェクトでサポートされていない場
     合に送出されます。

 -- 例外: xml.dom.InvalidCharacterErr

     この例外は、文字列パラメタが、現在使われているコンテキストで XML
     1.0 勧告によって許可されていない場合に送出されます。例えば、要素型
     に空白の入った ‘Element’ ノードを生成しようとすると、このエラーが送
     出されます。

 -- 例外: xml.dom.InvalidModificationErr

     ノードの型を変更しようと試みた際に送出されます。

 -- 例外: xml.dom.InvalidStateErr

     定義されていないオブジェクトや、もはや利用できなくなったオブジェク
     トを使おうと試みた際に送出されます。

 -- 例外: xml.dom.NamespaceErr

     Namespaces in XML(1) に照らして許可されていない方法でオブジェクトを
     変更しようと試みた場合、この例外が送出されます。

 -- 例外: xml.dom.NotFoundErr

     参照しているコンテキスト中に目的のノードが存在しない場合に送出され
     る例外です。例えば、 ‘NamedNodeMap.removeNamedItem()’ は渡されたノ
     ードがノードマップ中に存在しない場合にこの例外を送出します。

 -- 例外: xml.dom.NotSupportedErr

     要求された方のオブジェクトや操作が実装でサポートされていない場合に
     送出されます。

 -- 例外: xml.dom.NoDataAllowedErr

     データ属性をサポートしないノードにデータを指定した際に送出されます
     。

 -- 例外: xml.dom.NoModificationAllowedErr

     オブジェクトに対して (読み出し専用ノードに対する修正のように) 許可
     されていない修正を行おうと試みた際に送出されます。

 -- 例外: xml.dom.SyntaxErr

     無効または不正な文字列が指定された際に送出されます。

 -- 例外: xml.dom.WrongDocumentErr

     ノードが現在属している文書と異なる文書に挿入され、かつある文書から
     別の文書へのノードの移行が実装でサポートされていない場合に送出され
     ます。

DOM 勧告で定義されている例外コードは、以下のテーブルに従って上記の例外と
対応付けられます:

定数                                       例外
                                           
---------------------------------------------------------------------------------
                                           
‘DOMSTRING_SIZE_ERR’                       *note DomstringSizeErr: 36ce.
                                           
                                           
‘HIERARCHY_REQUEST_ERR’                    *note HierarchyRequestErr: 36cf.
                                           
                                           
‘INDEX_SIZE_ERR’                           *note IndexSizeErr: 36d0.
                                           
                                           
‘INUSE_ATTRIBUTE_ERR’                      *note InuseAttributeErr: 36b8.
                                           
                                           
‘INVALID_ACCESS_ERR’                       *note InvalidAccessErr: 36d1.
                                           
                                           
‘INVALID_CHARACTER_ERR’                    *note InvalidCharacterErr: 36d2.
                                           
                                           
‘INVALID_MODIFICATION_ERR’                 *note InvalidModificationErr: 36d3.
                                           
                                           
‘INVALID_STATE_ERR’                        *note InvalidStateErr: 36d4.
                                           
                                           
‘NAMESPACE_ERR’                            *note NamespaceErr: 36d5.
                                           
                                           
‘NOT_FOUND_ERR’                            *note NotFoundErr: 36b3.
                                           
                                           
‘NOT_SUPPORTED_ERR’                        *note NotSupportedErr: 36d6.
                                           
                                           
‘NO_DATA_ALLOWED_ERR’                      *note NoDataAllowedErr: 36d7.
                                           
                                           
‘NO_MODIFICATION_ALLOWED_ERR’              *note NoModificationAllowedErr: 36d8.
                                           
                                           
‘SYNTAX_ERR’                               *note SyntaxErr: 36d9.
                                           
                                           
‘WRONG_DOCUMENT_ERR’                       *note WrongDocumentErr: 36da.
                                           

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/REC-xml-names/


File: python.info,  Node: 適合性,  Prev: DOM 内のオブジェクト,  Up: xml dom --- ドキュメントオブジェクトモデル API

5.20.6.15 適合性
................

この節では適合性に関する要求と、Python DOM API、W3C DOM 勧告、および OMG
IDL の Python API への対応付けとの間の関係について述べます。

* Menu:

* 型の対応付け::
* アクセサメソッド::


File: python.info,  Node: 型の対応付け,  Next: アクセサメソッド,  Up: 適合性

5.20.6.16 型の対応付け
......................

DOM 仕様で使われている IDL 型は、以下のテーブルに従って Python の型に対
応付けられています。

IDL 型                 Python の型
                       
-----------------------------------------------------------------------
                       
‘boolean’              ‘bool’ または ‘int’
                       
                       
‘int’                  ‘int’
                       
                       
‘long int’             ‘int’
                       
                       
‘unsigned int’         ‘int’
                       
                       
‘DOMString’            ‘str’ または ‘bytes’
                       
                       
‘null’                 ‘None’
                       


File: python.info,  Node: アクセサメソッド,  Prev: 型の対応付け,  Up: 適合性

5.20.6.17 アクセサメソッド
..........................

OMG IDL から Python への対応付けは、IDL ‘attribute’ 宣言へのアクセサ関数
の定義を、Java による対応付けが行うのとほとんど同じように行います。IDL 宣
言の対応付け

     readonly attribute string someValue;
              attribute string anotherValue;

は、三つのアクセサ関数: ‘someValue’ に対する "get" メソッド
(‘_get_someValue()’)、そして ‘anotherValue’ に対する "get" および "set"
メソッド (‘_get_anotherValue()’ および ‘_set_anotherValue()’) を生成しま
す。とりわけ、対応付けでは、IDL 属性が通常の Python 属性としてアクセス可
能であることは必須ではありません: ‘object.someValue’ が動作することは必
須 'ではなく' 、 *note AttributeError: 326. を送出してもかまいません。

しかしながら、Python DOM API では、通常の属性アクセスが動作することが必
須です。これは、Python IDL コンパイラによって生成された典型的な代用物は
まず動作することはなく、DOM オブジェクトが CORBA を介してアクセスされる
場合には、クライアント上でラッパーオブジェクトが必要であることを意味しま
す。CORBA DOM クライアントでは他にもいくつか考慮すべきことがある一方で、
Python から CORBA を介して DOM を使った経験を持つ実装者はこのことを問題
視していません。‘readonly’ であると宣言された属性は、全ての DOM 実装で書
き込みアクセスを制限しているとは限りません。

Python DOM API では、アクセサ関数は必須ではありません。アクセサ関数が提
供された場合、Python IDL 対応付けによって定義された形式をとらなければな
りませんが、属性は Python から直接アクセスすることができるので、それらの
メソッドは必須ではないと考えられます。‘readonly’ であると宣言された属性
に対しては、 "set" アクセサを提供してはなりません。

このIDLでの定義はW3C DOM APIの全ての要件を実装しているわけではありません
。例えば、一部のオブジェクトの概念や ‘getElementsByTagName()’ が "live"
であることなどです。 Python DOM API はこれらの要件を実装することを強制し
ません。


File: python.info,  Node: xml dom minidom --- 最小限の DOM の実装,  Next: xml dom pulldom --- 部分的な DOM ツリー構築のサポート,  Prev: xml dom --- ドキュメントオブジェクトモデル API,  Up: 構造化マークアップツール

5.20.7 ‘xml.dom.minidom’ -- 最小限の DOM の実装
-----------------------------------------------

'ソースコード:' Lib/xml/dom/minidom.py(1)

__________________________________________________________________

*note xml.dom.minidom: 109. は、 Document Object Model インターフェース
の最小の実装です。他言語の実装と似た API を持ちます。このモジュールは、
完全な DOM に比べて単純で、非常に小さくなるように意図されています。 DOM
について既に熟知しているユーザを除き、 XML 処理には代わりに *note
xml.etree.ElementTree: 10c. モジュールを使うことを検討すべきです。

     警告: *note xml.dom.minidom: 109. モジュールは悪意を持って作成され
     たデータに対して安全ではありません。信頼できないデータや認証されて
     いないデータをパースする必要がある場合は *note XML の脆弱性: 3607.
     を参照してください。

DOM アプリケーションは通常、XML を DOM に解析 (parse) することで開始しま
す。 *note xml.dom.minidom: 109. では、以下のような解析用の関数を介して
行います:

     from xml.dom.minidom import parse, parseString

     dom1 = parse('c:\\temp\\mydata.xml')  # parse an XML file by name

     datasource = open('c:\\temp\\mydata.xml')
     dom2 = parse(datasource)  # parse an open file

     dom3 = parseString('<myxml>Some data<empty/> some more data</myxml>')

*note parse(): 36e2. 関数はファイル名か、開かれたファイルオブジェクトを
引数にとることができます。

 -- の関数: xml.dom.minidom.parse (filename_or_file, parser=None,
          bufsize=None)

     与えられた入力から ‘Document’ を返します。 'filename_or_file' はフ
     ァイル名でもファイルオブジェクトでもかまいません。 'parser' を指定
     する場合、SAX2 パーザオブジェクトでなければなりません。この関数はパ
     ーザの文書ハンドラを変更し、名前空間サポートを有効にします; (エンテ
     ィティリゾルバ (entity resolver) のような) 他のパーザ設定は前もって
     おこなわなければなりません。

XML データを文字列で持っている場合、 *note parseString(): 36e3. を代わり
に使うことができます:

 -- の関数: xml.dom.minidom.parseString (string, parser=None)

     'string' を表わす ‘Document’ を返します。このメソッドは、文字列に対
     する *note io.StringIO: ef3. オブジェクトを作成し、それを *note
     parse(): 36e2. に渡します。

これらの関数は両方とも、文書の内容を表現する ‘Document’ オブジェクトを返
します。

*note parse(): 36e2. や *note parseString(): 36e3. といった関数が行うの
は、 XML パーザを、何らかの SAX パーザからくる解析イベント (parse event)
を受け取って DOM ツリーに変換できるような "DOM ビルダ (DOM builder)" に
結合することです。関数は誤解を招くような名前になっているかもしれませんが
、インターフェースについて学んでいるときには理解しやすいでしょう。文書の
解析はこれらの関数が戻るより前に完結します; 要するに、これらの関数自体は
パーザ実装を提供しないということです。

"DOM 実装" オブジェクトのメソッドを呼び出して ‘Document’ を生成すること
もできます。このオブジェクトは、 *note xml.dom: 108. パッケージ、または
*note xml.dom.minidom: 109. モジュールの ‘getDOMImplementation()’ 関数を
呼び出して取得できます。 ‘Document’ を取得したら、DOM を構成するために子
ノードを追加していくことができます:

     from xml.dom.minidom import getDOMImplementation

     impl = getDOMImplementation()

     newdoc = impl.createDocument(None, "some_tag", None)
     top_element = newdoc.documentElement
     text = newdoc.createTextNode('Some textual content.')
     top_element.appendChild(text)

DOM 文書オブジェクトを手にしたら、XML 文書のプロパティやメソッドを使って
、文書の一部にアクセスすることができます。これらのプロパティは DOM 仕様
で定義されています。文書オブジェクトの主要なプロパティは
‘documentElement’ プロパティです。このプロパティは XML 文書の主要な要素
、つまり他の全ての要素を保持する要素を与えます。以下にプログラム例を示し
ます。

     dom3 = parseString("<myxml>Some data</myxml>")
     assert dom3.documentElement.tagName == "myxml"

DOM ツリーを使い終えたとき、 ‘unlink()’ メソッドを呼び出して不要になった
オブジェクトが早く片付けられるように働きかけることができます。
‘unlink()’ は、 DOM API に対する *note xml.dom.minidom: 109. 特有の拡張
で、ノードとその下位ノードを本質的に無意味なものとします。このメソッドを
呼び出さなくても、 Python のガベージコレクタがいつかはツリーのオブジェク
トを後片付けします。

参考
....

Document Object Model (DOM) Level 1 Specification(2)

     *note xml.dom.minidom: 109. でサポートされている W3C の DOM に関す
     る勧告。

* Menu:

* DOM オブジェクト::
* DOM の例::
* minidom と DOM 標準::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/dom/minidom.py

   (2) https://www.w3.org/TR/REC-DOM-Level-1/


File: python.info,  Node: DOM オブジェクト,  Next: DOM の例,  Up: xml dom minidom --- 最小限の DOM の実装

5.20.7.1 DOM オブジェクト
.........................

Python の DOM API 定義は *note xml.dom: 108. モジュールドキュメントの一
部として与えられています。この節では、 *note xml.dom: 108. の API と
*note xml.dom.minidom: 109. との違いについて列挙します。

 -- メソッド: Node.unlink ()

     DOM との内部的な参照を破壊して、循環参照ガベージコレクションを持た
     ないバージョンの Python でもガベージコレクションされるようにします
     。循環参照ガベージコレクションが利用できる場合でも、このメソッドを
     使えば大量のメモリをすぐに使えるようにできるため、不要になったらす
     ぐに DOM オブジェクトに対してこのメソッドを呼ぶのが良い習慣です。こ
     のメソッドは ‘Document’ オブジェクトに対して呼び出すだけでよいので
     すが、あるノードの子ノードを破棄するために子ノードに対して呼び出し
     てもかまいません。

     *note with: 59c. ステートメントを使用することで、このメソッドを明示
     的に呼ばないようにできます。 ‘with’ ブロックから出る時に自動的に次
     のコードが 'dom' を unlink します:

          with xml.dom.minidom.parse(datasource) as dom:
              ... # Work with dom.

 -- メソッド: Node.writexml (writer, indent='', addindent='', newl='',
          encoding=None, standalone=None)

     XML を 'writer' オブジェクトに書き込みます。 'writer' は入力として
     テキストは受け付けますが、バイト列は受け付けません。 'writer' はフ
     ァイルオブジェクトインターフェースの ‘write()’ に該当するメソッドを
     持たなければなりません。 'indent' 引数には現在のノードのインデント
     を指定します。 'addindent' 引数には現在のノードの下にサブノードを追
     加する際のインデント増分を指定します。 'newl' には、改行時に行末を
     終端する文字列を指定します。

     ‘Document’ ノードでは、追加のキーワード引数 'encoding' を使って XML
     ヘッダの encoding フィールドを指定することができます。

     同様に、'standalone' 引数を明示的に指定すると、スタンドアロン文書宣
     言がXMLのプロローグに追加されます。値が ‘True’ の場合、
     ‘standalone="yes"’ が追加され、それ以外の場合 ‘"no"’ が設定されます
     。引数を指定しない場合は文書から宣言が省略されます。

     バージョン 3.8 で変更: *note writexml(): 36e7. メソッドはユーザーが
     指定した属性の順序を保持するようになりました。

     バージョン 3.9 で変更: 'standalone' パラメータが追加されました。

 -- メソッド: Node.toxml (encoding=None, standalone=None)

     DOM ノードによって表わされる XML を含んだ文字列またはバイト文字列を
     返します。

     明示的に 'encoding' (1) 引数を渡すと、結果は指定されたエンコードの
     バイト文字列になります。'encoding' 引数なしだと、結果は unicode 文
     字列です。また、結果として生じる文字列の中の XML 宣言はエンコーディ
     ングを指定しません。XML のデフォルトエンコーディングは UTF-8 なので
     、この文字列を UTF-8 以外でエンコードすることはおそらく正しくありま
     せん。

     'standalone' 引数は *note writexml(): 36e7. と全く同じ動作をします
     。

     バージョン 3.8 で変更: *note toxml(): 1470. メソッドはユーザーが指
     定した属性の順序を保持するようになりました。

     バージョン 3.9 で変更: 'standalone' パラメータが追加されました。

 -- メソッド: Node.toprettyxml (indent='\t', newl='\n', encoding=None,
          standalone=None)

     文書の整形されたバージョンを返します。 'indent' はインデントを行う
     ための文字で、デフォルトはタブです; 'newl' には行末で出力される文字
     列を指定し、デフォルトは ‘\n’ です。

     'encoding' 引数は *note toxml(): 1470. の対応する引数と同様に振る舞
     います。

     'standalone' 引数は *note writexml(): 36e7. と全く同じ動作をします
     。

     バージョン 3.8 で変更: *note toprettyxml(): 1471. メソッドはユーザ
     ーが指定した属性の順序を保持するようになりました。

     バージョン 3.9 で変更: 'standalone' パラメータが追加されました。

   ---------- Footnotes ----------

   (1) XML 出力に含まれるエンコード名は適切な規格に従っていなければなり
ません。例えば "UTF-8" は有効ですが、 "UTF8" は XML 文書の宣言では有効で
はありません。後者はエンコード名として Python に認められるとしてもです。
‘https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl’ と
‘https://www.iana.org/assignments/character-sets/character-sets.xhtml’ を
参照してください。


File: python.info,  Node: DOM の例,  Next: minidom と DOM 標準,  Prev: DOM オブジェクト,  Up: xml dom minidom --- 最小限の DOM の実装

5.20.7.2 DOM の例
.................

以下のプログラム例は、単純なプログラムのかなり現実的な例です。特にこの例
に関しては、DOM の柔軟性をあまり活用してはいません。

     import xml.dom.minidom

     document = """\
     <slideshow>
     <title>Demo slideshow</title>
     <slide><title>Slide title</title>
     <point>This is a demo</point>
     <point>Of a program for processing slides</point>
     </slide>

     <slide><title>Another demo slide</title>
     <point>It is important</point>
     <point>To have more than</point>
     <point>one slide</point>
     </slide>
     </slideshow>
     """

     dom = xml.dom.minidom.parseString(document)

     def getText(nodelist):
         rc = []
         for node in nodelist:
             if node.nodeType == node.TEXT_NODE:
                 rc.append(node.data)
         return ''.join(rc)

     def handleSlideshow(slideshow):
         print("<html>")
         handleSlideshowTitle(slideshow.getElementsByTagName("title")[0])
         slides = slideshow.getElementsByTagName("slide")
         handleToc(slides)
         handleSlides(slides)
         print("</html>")

     def handleSlides(slides):
         for slide in slides:
             handleSlide(slide)

     def handleSlide(slide):
         handleSlideTitle(slide.getElementsByTagName("title")[0])
         handlePoints(slide.getElementsByTagName("point"))

     def handleSlideshowTitle(title):
         print(f"<title>{getText(title.childNodes)}</title>")

     def handleSlideTitle(title):
         print(f"<h2>{getText(title.childNodes)}</h2>")

     def handlePoints(points):
         print("<ul>")
         for point in points:
             handlePoint(point)
         print("</ul>")

     def handlePoint(point):
         print(f"<li>{getText(point.childNodes)}</li>")

     def handleToc(slides):
         for slide in slides:
             title = slide.getElementsByTagName("title")[0]
             print(f"<p>{getText(title.childNodes)}</p>")

     handleSlideshow(dom)


File: python.info,  Node: minidom と DOM 標準,  Prev: DOM の例,  Up: xml dom minidom --- 最小限の DOM の実装

5.20.7.3 minidom と DOM 標準
............................

*note xml.dom.minidom: 109. モジュールは、本質的には DOM 1.0 互換の DOM
に、いくつかの DOM 2 機能 (主に名前空間機能) を追加したものです。

Python における DOM インターフェースは率直なものです。以下の対応付け規則
が適用されます:

   * インターフェースはインスタンスオブジェクトを介してアクセスされます
     。アプリケーション自身から、クラスをインスタンス化してはなりません;
     ‘Document’ オブジェクト上で利用可能な生成関数 (creator function) を
     使わなければなりません。派生インターフェースでは基底インターフェー
     スの全ての演算 (および属性) に加え、新たな演算をサポートします。

   * 演算はメソッドとして使われます。DOM では *note in: 2cb. パラメタの
     みを使うので、引数は通常の順番 (左から右へ) で渡されます。オプショ
     ン引数はありません。 ‘void’ 演算は ‘None’ を返します。

   * IDL 属性はインスタンス属性に対応付けられます。OMG IDL 言語における
     Python への対応付けとの互換性のために、属性 ‘foo’ はアクセサメソッ
     ド ‘_get_foo()’ および ‘_set_foo()’ でもアクセスできます。
     ‘readonly’ 属性は変更してはなりません; とはいえ、これは実行時には強
     制されません。

   * ‘short int’ 、 ‘unsigned int’ 、 ‘unsigned long long’ 、および
     ‘boolean’ 型は、全て Python 整数オブジェクトに対応付けられます。

   * ‘DOMString’ 型は Python 文字列型に対応付けられます。 *note
     xml.dom.minidom: 109. ではバイト列か文字列のどちらかに対応づけられ
     ますが、通常文字列を生成します。 ‘DOMString’ 型の値は、W3C の DOM 仕
     様で、IDL ‘null’ 値になってもよいとされている場所では ‘None’ になる
     こともあります。

   * ‘const’ 宣言を行うと、
     (‘xml.dom.minidom.Node.PROCESSING_INSTRUCTION_NODE’ のように) 対応
     するスコープ内の変数に対応付けを行います; これらは変更してはなりま
     せん。

   * ‘DOMException’ は現状では *note xml.dom.minidom: 109. でサポートさ
     れていません。その代わり、 *note xml.dom.minidom: 109. は、 *note
     TypeError: 502. や *note AttributeError: 326. といった標準の Python
     例外を使います。

   * ‘NodeList’ オブジェクトは Python の組み込みのリスト型を使って実装さ
     れています。これらのオブジェクトは DOM 仕様で定義されたインターフェ
     ースを提供していますが、以前のバージョンの Python では、公式の API
     をサポートしていません。しかしながら、これらの API は W3C 勧告で定
     義されたインターフェースよりも "Python 的な" ものになっています。

以下のインターフェースは *note xml.dom.minidom: 109. では全く実装されて
いません:

   * ‘DOMTimeStamp’

   * ‘EntityReference’

これらの大部分は、ほとんどの DOM のユーザにとって一般的な用途として有用
とはならないような XML 文書内の情報を反映しています。

脚注
....


File: python.info,  Node: xml dom pulldom --- 部分的な DOM ツリー構築のサポート,  Next: xml sax --- SAX2 バーサーのサポート,  Prev: xml dom minidom --- 最小限の DOM の実装,  Up: 構造化マークアップツール

5.20.8 ‘xml.dom.pulldom’ -- 部分的な DOM ツリー構築のサポート
-------------------------------------------------------------

'Source code:' Lib/xml/dom/pulldom.py(1)

__________________________________________________________________

*note xml.dom.pulldom: 10a. モジュールは "プルパーザ" を提供します。 プ
ルパーザは必要に応じて文書の DOM アクセス可能な断片を生成することができ
ます。 基本概念は、入力 XML のストリームから "イベント" を取り出し (pull
し) て処理することです。 SAX とは、コールバックつきのイベント駆動処理モ
デルを採用しているという点で同様ですが、SAX とは対照的に、プルパーザの使
用者には処理が完了するかエラー状態が発生するまで、明示的にストリームから
イベントを取り出し、イベントに対しループを回す責任があります。

     警告: *note xml.dom.pulldom: 10a. モジュールは悪意を持って作成され
     たデータに対して安全ではありません。信頼できないデータや認証されて
     いないデータをパースする必要がある場合は *note XML の脆弱性: 3607.
     を参照してください。

バージョン 3.7.1 で変更: SAXパーサーは、デフォルトでセキュリティーを向上
させるために、一般的な外部エンティティーをデフォルトでは処理しなくなりま
した。外部エンティティの処理を有効にするには、次の場所にカスタムパーサー
インスタンスを渡します:

     from xml.dom.pulldom import parse
     from xml.sax import make_parser
     from xml.sax.handler import feature_external_ges

     parser = make_parser()
     parser.setFeature(feature_external_ges, True)
     parse(filename, parser=parser)

以下はプログラム例です:

     from xml.dom import pulldom

     doc = pulldom.parse('sales_items.xml')
     for event, node in doc:
         if event == pulldom.START_ELEMENT and node.tagName == 'item':
             if int(node.getAttribute('price')) > 50:
                 doc.expandNode(node)
                 print(node.toxml())

‘event’ は定数で以下の内の一つです:

   * ‘START_ELEMENT’

   * ‘END_ELEMENT’

   * ‘COMMENT’

   * ‘START_DOCUMENT’

   * ‘END_DOCUMENT’

   * ‘CHARACTERS’

   * ‘PROCESSING_INSTRUCTION’

   * ‘IGNORABLE_WHITESPACE’

‘node’ は型 ‘xml.dom.minidom.Document’、 ‘xml.dom.minidom.Element’ また
は ‘xml.dom.minidom.Text’ のオブジェクトです。

文書はイベントの 'フラットな' 流れとして扱われるため、文書の "木" は暗黙
のうちに全て読み込まれ、目的の要素は木の中の深さに依らずに見つけられます
。つまり、文書ノードの再帰的な検索のような階層的な問題を考える必要はあり
ません。しかしながら要素の前後関係が重要な場合は、前後関係の状態を維持す
る (すなわち文章中の任意の点の場所を記憶する) か、 *note
DOMEventStream.expandNode(): 36ee. メソッドを使用して DOM 関連の処理に切
り替える必要があります。

 -- クラス: xml.dom.pulldom.PullDom (documentFactory=None)

     *note xml.sax.handler.ContentHandler: 36f0. のサブクラスです。

 -- クラス: xml.dom.pulldom.SAX2DOM (documentFactory=None)

     *note xml.sax.handler.ContentHandler: 36f0. のサブクラスです。

 -- の関数: xml.dom.pulldom.parse (stream_or_string, parser=None,
          bufsize=None)

     与えられた入力から *note DOMEventStream: 700. を返します。
     'stream_or_string' はファイル名かファイル様オブジェクトのいずれかで
     す。'parser' は、与えれた場合、 *note XMLReader: 36f3. オブジェクト
     でなければなりません。この関数はパーザの文書ハンドラを変えて名前空
     間のサポートを有効にします。パーザの他の設定 (例えばエンティティリ
     ゾルバ) は前もってしておかなければなりません。

XML データを文字列で持っている場合、 *note parseString(): 36f4. を代わり
に使うことができます:

 -- の関数: xml.dom.pulldom.parseString (string, parser=None)

     (ユニコード) 'string' を表す *note DOMEventStream: 700. を返します
     。

 -- データ: xml.dom.pulldom.default_bufsize

     *note parse(): 36f2. の 'bufsize' パラメタのデフォルト値です。

     この変数の値は *note parse(): 36f2. を呼び出す前に変更することがで
     きます。その場合、その新しい値が有効になります。

* Menu:

* DOMEventStream オブジェクト::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/dom/pulldom.py


File: python.info,  Node: DOMEventStream オブジェクト,  Up: xml dom pulldom --- 部分的な DOM ツリー構築のサポート

5.20.8.1 DOMEventStream オブジェクト
....................................

 -- クラス: xml.dom.pulldom.DOMEventStream (stream, parser, bufsize)

     バージョン 3.11 で変更: *note __getitem__(): 264. メソッドのサポー
     トは削除されました。

      -- メソッド: getEvent ()

          event が ‘START_DOCUMENT’ の場合は 'event' と
          ‘xml.dom.minidom.Document’ としての現在の 'node' からなるタプ
          ルを、 ‘START_ELEMENT’ か ‘END_ELEMENT’ の場合は
          ‘xml.dom.minidom.Element’ を、 ‘CHARACTERS’ の場合は
          ‘xml.dom.minidom.Text’ を返します。 *note expandNode(): 36ee.
          が呼ばれない限り、現在のノードは子ノードの情報を持ちません。

      -- メソッド: expandNode (node)

          'node' の全子ノードを 'node' に展開します。例:

               from xml.dom import pulldom

               xml = '<html><title>Foo</title> <p>Some text <div>and more</div></p> </html>'
               doc = pulldom.parseString(xml)
               for event, node in doc:
                   if event == pulldom.START_ELEMENT and node.tagName == 'p':
                       # Following statement only prints '<p/>'
                       print(node.toxml())
                       doc.expandNode(node)
                       # Following statement prints node with all its children '<p>Some text <div>and more</div></p>'
                       print(node.toxml())

      -- メソッド: reset ()


File: python.info,  Node: xml sax --- SAX2 バーサーのサポート,  Next: xml sax handler --- SAX ハンドラーの基底クラス,  Prev: xml dom pulldom --- 部分的な DOM ツリー構築のサポート,  Up: 構造化マークアップツール

5.20.9 ‘xml.sax’ -- SAX2 バーサーのサポート
-------------------------------------------

'ソースコード:' Lib/xml/sax/__init__.py(1)

__________________________________________________________________

*note xml.sax: 110. パッケージは Python 用の Simple API for XML (SAX) イ
ンターフェースを実装した数多くのモジュールを提供しています。またパッケー
ジには SAX 例外と SAX API 利用者が頻繁に利用するであろう有用な関数群も含
まれています。

     警告: *note xml.sax: 110. モジュールは悪意を持って作成されたデータ
     に対して安全ではありません。信頼できないデータや認証されていないデ
     ータをパースする必要がある場合は *note XML の脆弱性: 3607. を参照し
     てください。

バージョン 3.7.1 で変更: SAXパーサーは、セキュリティーを向上させるために
、デフォルトで一般的な外部エンティティーを処理しなくなりました。以前は、
パーサーは、DTDおよびエンティティ用にファイルシステムからリモートファイ
ルまたはロードされたローカルファイルをフェッチするためのネットワーク接続
を作成していました。この機能は parser オブジェクトと(実) 引数 *note
feature_external_ges: 36fc. の *note setFeature(): 36fd. メソッドで再度
有効にすることができます。

その関数群は以下の通りです:

 -- の関数: xml.sax.make_parser (parser_list=[])

     SAX *note XMLReader: 36f3. オブジェクトを生成し、返します。最初に見
     つかったパーサーが使用されます。'parser_list' を与える場合、それは
     ‘create_parser()’ という名前の関数をもつモジュール名のイテラブルで
     なければなりません。 'parser_list' に列挙されているモジュールは、パ
     ーサーのデフォルトリストにあるモジュールよりも先に使われます。

     バージョン 3.8 で変更: 'parser_list' 引数はリストだけでなく、イテラ
     ブルでもよくなりました。

 -- の関数: xml.sax.parse (filename_or_stream, handler,
          error_handler=handler.ErrorHandler())

     SAX パーサを生成し、そのパーサをドキュメントの解析に使用します。
     'filename_or_stream' として与えられるドキュメントは、ファイル名でも
     ファイルオブジェクトでもかまいません。 'handler' 引数は SAX *note
     ContentHandler: 36f0. のインスタントである必要があります。
     'error_handler' が与えられる場合は、 SAX *note ErrorHandler: 36fe.
     のインスタンスである必要があります。この引数を省略した場合、全ての
     例外に対して *note SAXParseException: 36ff. が発生します。 戻り値は
     ありません。すべての操作は渡される 'handler' によって行われなければ
     なりません。

 -- の関数: xml.sax.parseString (string, handler,
          error_handler=handler.ErrorHandler())

     *note parse(): 196f. と同様ですが、こちらは引数で受け取ったバッファ
     'string' をパースします。 'string' は *note str: 418. インスタンス
     か *note bytes-like object: cfb. でなければなりません。

     バージョン 3.5 で変更: *note str: 418. インスタンスがサポートされま
     した。

典型的な SAX アプリケーションでは3種類のオブジェクト(リーダ、ハンドラ、
入力元)が用いられます。ここで言うリーダとはパーサを指しています。つまり
、入力元からバイト列または文字列を読み込み、一連のイベントを発生させるコ
ード片のことです。発生したイベントはハンドラ・オブジェクトに割り振られま
す。言い換えると、リーダがハンドラのメソッドを呼び出すわけです。つまり、
SAX アプリケーションは、リーダ・オブジェクトを作成し、入力元のオブジェク
トを作成するか開き、ハンドラ・オブジェクトを作成し、これら3つのオブジェ
クトを連携させる必要があります。準備の最終段階では、リーダが呼び出され、
入力をパースします。パース中には、入力データからの構造イベントや構文イベ
ントに基づいて、ハンドラ・オブジェクトのメソッドが呼び出されます。

これらのオブジェクトでは、インターフェースだけが関係します。通常、これら
はアプリケーション自体によってはインスタンス化されません。 Python は明示
的なインターフェースの概念を持たないので、インターフェースはクラスとして
導入されました。しかし、アプリケーションは、提供されたクラスを継承せずに
実装してもかまいません。インターフェース *note InputSource: e64, *note
Locator: 3700, ‘Attributes’, ‘AttributesNS’, *note XMLReader: 36f3. はモ
ジュール *note xml.sax.xmlreader: 113. で定義されています。ハンドライン
ターフェースは *note xml.sax.handler: 111. で定義されています。利便性の
ため、 *note InputSource: e64. (よく直接インスタンス化されるクラス) とハ
ンドラクラスは *note xml.sax: 110. からもアクセスできます。これらのイン
ターフェースについて下記で説明します。

このほかに *note xml.sax: 110. は次の例外クラスも提供しています。

 -- 例外: xml.sax.SAXException (msg, exception=None)

     XML エラーと警告をカプセル化します。このクラスには XML パーサとアプ
     リケーションで発生するエラーおよび警告の基本的な情報を持たせること
     ができます。また機能追加や地域化のためにサブクラス化することも可能
     です。なお *note ErrorHandler: 36fe. で定義されているハンドラがこの
     例外のインスタンスを受け取ることに注意してください。実際に例外を発
     生させることは必須でなく、情報のコンテナとして利用されることもある
     からです。

     インスタンスを作成する際 'msg' はエラー内容を示す可読データにしてく
     ださい。オプションの 'exception' 引数は ‘None’ にするか、パース用コ
     ードで捕捉されて情報として渡される例外にしてください。

     このクラスはSAX 例外の基底クラスになります。

 -- 例外: xml.sax.SAXParseException (msg, exception, locator)

     パースエラー時に発生する *note SAXException: 3701. のサブクラスです
     。パースエラーに関する情報として、このクラスのインスタンスが SAX
     *note ErrorHandler: 36fe. インターフェースのメソッドに渡されます。
     このクラスは *note SAXException: 3701. 同様 SAX *note Locator:
     3700. インターフェースもサポートしています。

 -- 例外: xml.sax.SAXNotRecognizedException (msg, exception=None)

     SAX *note XMLReader: 36f3. が認識できない機能やプロパティに遭遇した
     とき発生させる *note SAXException: 3701. のサブクラスです。 SAX ア
     プリケーションや拡張モジュールにおいて同様の目的にこのクラスを利用
     することもできます。

 -- 例外: xml.sax.SAXNotSupportedException (msg, exception=None)

     SAX *note XMLReader: 36f3. が要求された機能をサポートしていないとき
     発生させる *note SAXException: 3701. のサブクラスです。 SAX アプリ
     ケーションや拡張モジュールにおいて同様の目的にこのクラスを利用する
     こともできます。

参考
....

SAX: The Simple API for XML(2)

     SAX API 定義に関し中心となっているサイトです。Java による実装とオン
     ライン・ドキュメントが提供されています。実装と SAX API の歴史に関す
     る情報のリンクも掲載されています。

*note xml.sax.handler: 111. モジュール

     アプリケーションが提供するオブジェクトのインターフェース定義。

*note xml.sax.saxutils: 112. モジュール

     SAX アプリケーション向けの有用な関数群。

*note xml.sax.xmlreader: 113. モジュール

     パーサが提供するオブジェクトのインターフェース定義。

* Menu:

* SAXException オブジェクト::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/sax/__init__.py

   (2) http://www.saxproject.org/


File: python.info,  Node: SAXException オブジェクト,  Up: xml sax --- SAX2 バーサーのサポート

5.20.9.1 SAXException オブジェクト
..................................

*note SAXException: 3701. 例外クラスは以下のメソッドをサポートしています
:

 -- メソッド: SAXException.getMessage ()

     エラー状態を示す可読メッセージを返します。

 -- メソッド: SAXException.getException ()

     カプセル化した例外オブジェクトまたは ‘None’ を返します。


File: python.info,  Node: xml sax handler --- SAX ハンドラーの基底クラス,  Next: xml sax saxutils --- SAX ユーティリティー,  Prev: xml sax --- SAX2 バーサーのサポート,  Up: 構造化マークアップツール

5.20.10 ‘xml.sax.handler’ -- SAX ハンドラーの基底クラス
-------------------------------------------------------

'ソースコード:' Lib/xml/sax/handler.py(1)

__________________________________________________________________

The SAX API defines five kinds of handlers: content handlers, DTD
handlers, error handlers, entity resolvers and lexical handlers.
Applications normally only need to implement those interfaces whose
events they are interested in; they can implement the interfaces in a
single object or in multiple objects.  Handler implementations should
inherit from the base classes provided in the module *note
xml.sax.handler: 111, so that all methods get default implementations.

 -- クラス: xml.sax.handler.ContentHandler

     アプリケーションにとって最も重要なメインの SAX コールバック・インタ
     ーフェースです。このインターフェースで発生するイベントの順序はドキ
     ュメント内の情報の順序を反映しています。

 -- クラス: xml.sax.handler.DTDHandler

     DTD イベントのハンドラです。

     パースされていないエンティティや属性など、基本的なパースに必要な
     DTD イベントの指定だけを行うインターフェースです。

 -- クラス: xml.sax.handler.EntityResolver

     エンティティ解決用の基本インターフェースです。このインターフェース
     を実装したオブジェクトを作成しパーサに登録することで、パーサはすべ
     ての外部エンティティを解決するメソッドを呼び出すようになります。

 -- クラス: xml.sax.handler.ErrorHandler

     エラーや警告メッセージをアプリケーションに通知するためにパーサが使
     用するインターフェースです。このオブジェクトのメソッドが、エラーを
     ただちに例外に変換するか、あるいは別の方法で処理するかの制御をして
     います。

 -- クラス: xml.sax.handler.LexicalHandler

     Interface used by the parser to represent low frequency events
     which may not be of interest to many applications.

これらのクラスに加え、 *note xml.sax.handler: 111. は機能やプロパティ名
のシンボル定数を提供しています。

 -- データ: xml.sax.handler.feature_namespaces

          値: ‘"http://xml.org/sax/features/namespaces"’
          真: 名前空間を処理します。
          偽: オプションで名前空間を処理しません (暗黙に名前空間接頭辞も無効にします; デフォルト)。
          アクセス: (パース時) 読み込み専用; (パース時以外) 読み書き可

 -- データ: xml.sax.handler.feature_namespace_prefixes

          値: ‘"http://xml.org/sax/features/namespace-prefixes"’
          真: 名前空間宣言で用いられている元々の接頭辞付きの名前と属性を報告します。
          偽: 名前空間宣言で用いられている属性を報告しません。オプションで元々の接頭辞付きの名前も報告しません (デフォルト)。
          アクセス: (パース時) 読み込み専用; (パース時以外) 読み書き可

 -- データ: xml.sax.handler.feature_string_interning

          値: ‘"http://xml.org/sax/features/string-interning"’
          真: 全ての要素名、接頭辞、属性名、名前空間 URI、ローカル名を組込みの intern 関数を使ってシンボルに登録します。
          偽: 名前を必ずしもシンボルに登録しませんが、されるかもしれません (デフォルト)。
          アクセス: (パース時) 読み込み専用; (パース時以外) 読み書き可

 -- データ: xml.sax.handler.feature_validation

          値: ‘"http://xml.org/sax/features/validation"’
          真: 全ての妥当性検査エラーを報告します (外部一般エンティティと外部変数エンティティが暗示されます)。
          偽: 妥当性検査エラーを報告しません。
          アクセス: (パース時) 読み込み専用; (パース時以外) 読み書き可

 -- データ: xml.sax.handler.feature_external_ges

          値: ‘"http://xml.org/sax/features/external-general-entities"’
          真: 全ての外部一般 (テキスト) エンティティを取り込みます。
          偽: 外部一般エンティティを取り込みません。
          アクセス: (パース時) 読み込み専用; (パース時以外) 読み書き可

 -- データ: xml.sax.handler.feature_external_pes

          値: ‘"http://xml.org/sax/features/external-parameter-entities"’
          真: 外部 DTD サブセットを含む全ての外部変数エンティティを取り込みます。
          偽: 外部 DTD サブセットであっても外部変数エンティティを取り込みません。
          アクセス: (パース時) 読み込み専用; (パース時以外) 読み書き可

 -- データ: xml.sax.handler.all_features

     全機能のリスト。

 -- データ: xml.sax.handler.property_lexical_handler

          値: ‘"http://xml.org/sax/properties/lexical-handler"’
          data type: xml.sax.handler.LexicalHandler (not supported in Python 2)
          説明: コメントなど字句解析イベント用のオプション拡張ハンドラ。
          アクセス: 読み書き可

 -- データ: xml.sax.handler.property_declaration_handler

          値: ‘"http://xml.org/sax/properties/declaration-handler"’
          データ型: xml.sax.sax2lib.DeclHandler (Python 2 では未サポート)
          説明: 表記や未解析エンティティをのぞく DTD 関連イベント用のオプション拡張ハンドラ。
          アクセス: 読み書き可

 -- データ: xml.sax.handler.property_dom_node

          値: ‘"http://xml.org/sax/properties/dom-node"’
          データ型: org.w3c.dom.Node (Python 2 では未サポート)
          説明: パース時は DOM イテレータならば現在の DOM ノードです。非パース時はイテレートのルート DOM ノードです。
          アクセス: (パース時) 読み込み専用; (パース時以外) 読み書き可

 -- データ: xml.sax.handler.property_xml_string

          値: ‘"http://xml.org/sax/properties/xml-string"’
          data type: Bytes
          説明: 現在のイベントの元になったリテラル文字列。
          アクセス: 読み出し専用

 -- データ: xml.sax.handler.all_properties

     既知の全プロパティ名のリスト。

* Menu:

* ContentHandler オブジェクト::
* DTDHandler オブジェクト::
* EntityResolver オブジェクト::
* ErrorHandler オブジェクト::
* LexicalHandler Objects::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/sax/handler.py


File: python.info,  Node: ContentHandler オブジェクト,  Next: DTDHandler オブジェクト,  Up: xml sax handler --- SAX ハンドラーの基底クラス

5.20.10.1 ContentHandler オブジェクト
.....................................

*note ContentHandler: 36f0. はアプリケーション側でサブクラス化して利用す
ることが前提になっています。パーサは入力ドキュメントのイベントにより、そ
れぞれに対応する以下のメソッドを呼び出します:

 -- メソッド: ContentHandler.setDocumentLocator (locator)

     アプリケーションにドキュメントイベントの発生位置を指すロケータを与
     えるためにパーサから呼び出されます。

     SAX パーサによるロケータの提供は強く推奨されています(必須ではありま
     せん)。もし提供する場合は、DocumentHandler インターフェースのどのメ
     ソッドよりも先にこのメソッドが呼び出されるようにしなければなりませ
     ん。

     パーサがエラーを報告しない場合でも、ロケータによってアプリケーショ
     ンは全てのドキュメント関連イベントの終了位置を知ることが出来ます。
     通常、アプリケーションは自身のエラー (例えば文字コンテンツがアプリ
     ケーションの規則に適合しない場合) を報告するためにこれを使用します
     。 ロケータが返す情報は検索エンジンでの利用にはおそらく不充分です。

     ロケータが正しい情報を返すのは、このインターフェースからイベントの
     呼出しが実行されている間だけです。それ以外のときは使用すべきであり
     ません。

 -- メソッド: ContentHandler.startDocument ()

     ドキュメントの開始通知を受け取ります。

     SAX パーサはこのインターフェースやDTDHandler のどのメソッド (*note
     setDocumentLocator(): 3719. を除く) よりも先にこのメソッドを一度だ
     け呼び出します。

 -- メソッド: ContentHandler.endDocument ()

     ドキュメントの終了通知を受け取ります。

     SAX パーサはこのメソッドを一度だけ呼び出します。パース中に呼び出す
     最後のメソッドです。パーサは (回復不能なエラーで) パース処理を中断
     するか、あるいは入力の最後に到達するまでこのメソッドを呼び出しませ
     ん。

 -- メソッド: ContentHandler.startPrefixMapping (prefix, uri)

     接頭辞と URI 名前空間の関連付けのスコープを開始します。

     このイベントからの情報は名前空間処理に必須ではありません。SAX XML リ
     ーダは ‘feature_namespaces’ 機能が有効な場合 (デフォルト)、要素と属
     性名の接頭辞を自動的に置換します。

     しかしながら、接頭辞の自動展開を安全に行えないために、アプリケーシ
     ョンが文字データや属性値の中で接頭辞を使わなければならない場合があ
     ります。 必要ならば *note startPrefixMapping(): 371c. や *note
     endPrefixMapping(): 371d. イベントはアプリケーションにコンテキスト
     自身の中で接頭辞を展開するための情報を提供します。

     *note startPrefixMapping(): 371c. と *note endPrefixMapping():
     371d. イベントは相互に正しい入れ子関係になることが保証されていない
     ので注意が必要です。すべての *note startPrefixMapping(): 371c. は対
     応する *note startElement(): 14eb. の前に発生し、 *note
     endPrefixMapping(): 371d. イベントは対応する *note endElement():
     14ec. の後で発生しますが、その順序は保証されていません。

 -- メソッド: ContentHandler.endPrefixMapping (prefix)

     接頭辞と URI の関連付けのスコープを終了します。

     詳しくは *note startPrefixMapping(): 371c. を参照してください。この
     イベントは常に対応する *note endElement(): 14ec. の後で発生しますが
     、複数の *note endPrefixMapping(): 371d. イベントの順序は特に保証さ
     れません。

 -- メソッド: ContentHandler.startElement (name, attrs)

     非名前空間モードでの要素の開始を通知します。

     'name' 引数は要素型の生の XML 1.0 名を文字列として持ち、'attrs' 引
     数は要素の属性を持つ ‘Attributes’ インターフェイス (*note
     Attributes インターフェース: 371e. を参照) のオブジェクトを保持しま
     す。 'attrs' ととして渡されたオブジェクトはパーサに再利用されるかも
     しれません。 そのため、それへの参照を確保するのは属性のコピーを保持
     する確実な方法ではありません。 属性のコピーを保持するには 'attrs' 属
     性の *note copy(): 1e. メソッドを使用してください。

 -- メソッド: ContentHandler.endElement (name)

     非名前空間モードでの要素の終了を通知します。

     'name' 引数は *note startElement(): 14eb. イベントとまったく同じ要
     素型名を持ちます。

 -- メソッド: ContentHandler.startElementNS (name, qname, attrs)

     名前空間モードでの要素の開始を通知します。

     'name' 引数は要素型の名前を ‘(uri, localname)’ というタプルとして持
     ち、'qname' 引数は元の文書で使われている生の XML 1.0 名を持ち、要素
     の属性を持つ ‘AttributesNS’ インターフェイス (*note AttributesNS
     インターフェース: 3720. を参照) のインスタンスを保持します。 名前空
     間が要素に関連付けられていない場合、'name' の 'uri' 要素は ‘None’ で
     す。 'attrs' ととして渡されたオブジェクトはパーサに再利用されるかも
     しれません。 そのため、それへの参照を確保するのは属性のコピーを保持
     する確実な方法ではありません。 属性のコピーを保持するには 'attrs' 属
     性の *note copy(): 1e. メソッドを使用してください。

     ‘feature_namespace_prefixes’ 機能が有効でなければ、パーサで 'qname'
     を ‘None’ に設定することも可能です。

 -- メソッド: ContentHandler.endElementNS (name, qname)

     名前空間モードでの要素の終了を通知します。

     'name' 引数は *note startElementNS(): 371f. イベントとまったく同じ
     要素型を持ちます。 'qname' 引数も同様です。

 -- メソッド: ContentHandler.characters (content)

     文字データの通知を受け取ります。

     パーサはこのメソッドを呼び出して文字データの各チャンクを報告します
     。SAX パーサは一連の文字データを単一のチャンクとして返す場合と複数
     のチャンクに分けて返す場合がありますが、ロケータの情報が正しく保た
     れるように、一つのイベントの文字データは常に同じ外部エンティティの
     ものでなければなりません。

     'content' は文字列、バイト列のどちらでもかまいませんが、‘expat’ リ
     ーダ・モジュールは常に文字列を生成するようになっています。

          注釈: Python XML SIG が提供していた初期 SAX 1 では、このメソッ
          ドにもっと JAVA 風のインターフェースが用いられています。しかし
          Python で採用されている大半のパーサでは古いインターフェースを
          有効に使うことができないため、よりシンプルなものに変更されまし
          た。古いコードを新しいインターフェースに変更するには、古い
          'offset' と 'length' パラメータでスライスせずに、'content' を
          指定するようにしてください。

 -- メソッド: ContentHandler.ignorableWhitespace (whitespace)

     要素内容中の無視できる空白文字の通知を受け取ります。

     妥当性検査を行うパーサはこのメソッドを使って、無視できる空白文字
     (W3C XML 1.0 勧告の 2.10 節参照) の各チャンクを報告しなければなりま
     せん。妥当性検査をしないパーサもコンテンツモデルの利用とパースが可
     能な場合、このメソッドを利用することが可能です。

     SAX パーサは連続する複数の空白文字を単一のチャンクとして返す場合と
     複数のチャンクに分けて返す場合があります。しかし、ロケータが有用な
     情報を提供できるように、単一のイベント中のすべての文字は同じ外部エ
     ンティティからのものでなければなりません。

 -- メソッド: ContentHandler.processingInstruction (target, data)

     処理命令の通知を受け取ります。

     パーサは処理命令が見つかるたびにこのメソッドを呼び出します。処理命
     令はメインのドキュメント要素の前や後にも発生することがあるので注意
     してください。

     SAX パーサがこのメソッドを使って XML 宣言 (XML 1.0 のセクション
     2.8) やテキスト宣言 (XML 1.0 のセクション 4.3.1) の通知をすることは
     ありません。

 -- メソッド: ContentHandler.skippedEntity (name)

     スキップしたエンティティの通知を受け取ります。

     パーサはエンティティをスキップするたびにこのメソッドを呼び出します
     。妥当性検査をしないプロセッサは (外部 DTD サブセットで宣言されてい
     るなどの理由で) 宣言が見当たらないエンティティをスキップします。す
     べてのプロセッサは ‘feature_external_ges’ および
     ‘feature_external_pes’ 属性の値によっては外部エンティティをスキップ
     することがあります。


File: python.info,  Node: DTDHandler オブジェクト,  Next: EntityResolver オブジェクト,  Prev: ContentHandler オブジェクト,  Up: xml sax handler --- SAX ハンドラーの基底クラス

5.20.10.2 DTDHandler オブジェクト
.................................

*note DTDHandler: 370a. インスタンスは以下のメソッドを提供します:

 -- メソッド: DTDHandler.notationDecl (name, publicId, systemId)

     表記宣言イベントの通知を扱います。

 -- メソッド: DTDHandler.unparsedEntityDecl (name, publicId, systemId,
          ndata)

     未パースのエンティティ宣言イベントの通知を扱います。


File: python.info,  Node: EntityResolver オブジェクト,  Next: ErrorHandler オブジェクト,  Prev: DTDHandler オブジェクト,  Up: xml sax handler --- SAX ハンドラーの基底クラス

5.20.10.3 EntityResolver オブジェクト
.....................................

 -- メソッド: EntityResolver.resolveEntity (publicId, systemId)

     エンティティのシステム識別子を解決し、文字列として読み込んだシステ
     ム識別子あるいは InputSource オブジェクトのいずれかを返します。デフ
     ォルトの実装では 'systemId' を返します。


File: python.info,  Node: ErrorHandler オブジェクト,  Next: LexicalHandler Objects,  Prev: EntityResolver オブジェクト,  Up: xml sax handler --- SAX ハンドラーの基底クラス

5.20.10.4 ErrorHandler オブジェクト
...................................

Objects with this interface are used to receive error and warning
information from the *note XMLReader: 36f3.  If you create an object
that implements this interface, then register the object with your *note
XMLReader: 36f3, the parser will call the methods in your object to
report all warnings and errors.  There are three levels of errors
available: warnings, (possibly) recoverable errors, and unrecoverable
errors.  All methods take a *note SAXParseException: 36ff. as the only
parameter.  Errors and warnings may be converted to an exception by
raising the passed-in exception object.

 -- メソッド: ErrorHandler.error (exception)

     パーサが回復可能なエラーに遭遇すると呼び出されます。このメソッドが
     例外を送出しない場合パースは継続されますが、アプリケーションは更な
     るドキュメント情報を期待すべきではありません。パーサの処理を継続を
     認めることで入力ドキュメント内の他のエラーを見つけることができます
     。

 -- メソッド: ErrorHandler.fatalError (exception)

     パーサが回復不能なエラーに遭遇すると呼び出されます。このメソッドが
     return したとき、パースの停止が求められています。

 -- メソッド: ErrorHandler.warning (exception)

     パーサが軽微な警告情報をアプリケーションに通知するときに呼び出され
     ます。このメソッドが return したときはパースの継続が求められ、ドキ
     ュメント情報はアプリケーションに送り続けられます。このメソッドでの
     例外の送出はパースを終了します。


File: python.info,  Node: LexicalHandler Objects,  Prev: ErrorHandler オブジェクト,  Up: xml sax handler --- SAX ハンドラーの基底クラス

5.20.10.5 LexicalHandler Objects
................................

Optional SAX2 handler for lexical events.

This handler is used to obtain lexical information about an XML
document.  Lexical information includes information describing the
document encoding used and XML comments embedded in the document, as
well as section boundaries for the DTD and for any CDATA sections.  The
lexical handlers are used in the same manner as content handlers.

Set the LexicalHandler of an XMLReader by using the setProperty method
with the property identifier
‘'http://xml.org/sax/properties/lexical-handler'’.

 -- メソッド: LexicalHandler.comment (content)

     Reports a comment anywhere in the document (including the DTD and
     outside the document element).

 -- メソッド: LexicalHandler.startDTD (name, public_id, system_id)

     Reports the start of the DTD declarations if the document has an
     associated DTD.

 -- メソッド: LexicalHandler.endDTD ()

     Reports the end of DTD declaration.

 -- メソッド: LexicalHandler.startCDATA ()

     Reports the start of a CDATA marked section.

     The contents of the CDATA marked section will be reported through
     the characters handler.

 -- メソッド: LexicalHandler.endCDATA ()

     Reports the end of a CDATA marked section.


File: python.info,  Node: xml sax saxutils --- SAX ユーティリティー,  Next: xml sax xmlreader --- XML パーサーのインターフェース,  Prev: xml sax handler --- SAX ハンドラーの基底クラス,  Up: 構造化マークアップツール

5.20.11 ‘xml.sax.saxutils’ -- SAX ユーティリティー
--------------------------------------------------

'ソースコード:' Lib/xml/sax/saxutils.py(1)

__________________________________________________________________

モジュール *note xml.sax.saxutils: 112. には SAX アプリケーションの作成
に役立つ多くの関数やクラスも含まれており、直接利用したり、基底クラスとし
て使うことができます。

 -- の関数: xml.sax.saxutils.escape (data, entities={})

     文字列データ内の ‘'&'’, ‘'<'’, ‘'>'’ をエスケープします。

     オプションの 'entities' 引数に辞書を渡すことで、そのほかの文字列デ
     ータをエスケープすることも可能です。辞書のキーと値はすべて文字列で
     、キーは対応する値に置換されます。'entities' が与えられている場合で
     も、 ‘'&'’, ‘'<'’, ‘'>'’ は常にエスケープされます。

          注釈: この関数は、 XML 内で直接使用できない文字のエスケープに
          のみ使用するべきです。この関数を一般的な文字列変換関数のように
          使用してはなりません。

 -- の関数: xml.sax.saxutils.unescape (data, entities={})

     エスケープされた文字列 ‘'&amp;'’, ‘'&lt;'’, ‘'&gt;'’ を元の文字に戻
     します。

     オプションの 'entities' 引数に辞書を渡すことで、そのほかの文字列デ
     ータをエスケープ解除することも可能です。辞書のキーと値はすべて文字
     列で、キーは対応する値に置換されます。'entities' が与えられている場
     合でも、‘'&amp'’, ‘'&lt;'’, and ‘'&gt;'’ は常に元の文字に戻されます
     。

 -- の関数: xml.sax.saxutils.quoteattr (data, entities={})

     *note escape(): 373a. に似ていますが、 'data' は属性値の作成に使わ
     れます。戻り値はクォート済みの 'data' で、置換する文字の追加も可能
     です。 *note quoteattr(): 373c. はクォートすべき文字を 'data' の文
     脈から判断し、クォートすべき文字を残さないように文字列をエンコード
     します。 'data' の中にシングル・クォート、ダブル・クォートがあれば
     、両方ともエンコードし、全体をダブルクォートで囲みます。戻り値の文
     字列はそのままで属性値として利用できます:

          >>> print("<element attr=%s>" % quoteattr("ab ' cd \" ef"))
          <element attr="ab ' cd &quot; ef">

     この関数は参照具象構文を使って、 HTML や SGML の属性値を生成するの
     に便利です。

 -- クラス: xml.sax.saxutils.XMLGenerator (out=None,
          encoding='iso-8859-1', short_empty_elements=False)

     このクラスは SAX イベントを XML 文書に書き戻すことで *note
     ContentHandler: 36f0. インターフェースを実装しています。 つまり、
     *note XMLGenerator: 373d. をコンテントハンドラとして用いることで、
     パースしている元々の文書を複製することが出来ます。 'out' にはファイ
     ル様オブジェクトでなければなりません。 デフォルトは 'sys.stdout' で
     す。 'encoding' は出力ストリームのエンコーディングで、デフォルトは
     ‘'iso-8859-1'’ です。 'short_empty_elements' は 内容を持たない要素
     のフォーマットを制御します。 ‘False’ (デフォルト) の場合、開始/終了
     タグのペアとなり、 ‘True’ の場合、1つの空タグになります。

     バージョン 3.2 で変更: 'short_empty_elements' 引数を追加しました。

 -- クラス: xml.sax.saxutils.XMLFilterBase (base)

     このクラスは *note XMLReader: 36f3. とクライアント・アプリケーショ
     ンのイベント・ハンドラとの間に位置するものとして設計されています。
     デフォルトでは何もせず、ただリクエストをリーダに、イベントをハンド
     ラに、それぞれ加工せず渡すだけです。しかし、サブクラスでメソッドを
     オーバーライドすると、イベント・ストリームやリクエストを加工してか
     ら渡すように変更可能です。

 -- の関数: xml.sax.saxutils.prepare_input_source (source, base='')

     この関数は引数に入力ソース、オプションとして URL を取り、読み取り可
     能な解決済み *note InputSource: e64. オブジェクトを返します。入力ソ
     ースは文字列、ファイル風オブジェクト、 *note InputSource: e64. のい
     ずれでも良く、この関数を使うことで、パーサは様々な 'source' 引数を
     *note parse(): 3740. メソッドに実装することが可能になります。

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/sax/saxutils.py


File: python.info,  Node: xml sax xmlreader --- XML パーサーのインターフェース,  Next: xml parsers expat --- Expat を使用した高速な XML 解析,  Prev: xml sax saxutils --- SAX ユーティリティー,  Up: 構造化マークアップツール

5.20.12 ‘xml.sax.xmlreader’ -- XML パーサーのインターフェース
-------------------------------------------------------------

'ソースコード:' Lib/xml/sax/xmlreader.py(1)

__________________________________________________________________

各 SAX パーサは Python モジュールとして *note XMLReader: 36f3. インター
フェースを実装しており、関数 ‘create_parser()’ を提供しています。この関
数は新たなパーサ・オブジェクトを生成する際、 *note
xml.sax.make_parser(): 19a6. から引数なしで呼び出されます。

 -- クラス: xml.sax.xmlreader.XMLReader

     SAX パーサが継承可能な基底クラスです。

 -- クラス: xml.sax.xmlreader.IncrementalParser

     入力ソースを一度にパースするのではなく、ドキュメントのチャンクが利
     用可能になるごとに取得したいことがあります。SAX リーダは通常、ファ
     イル全体を一気に読み込まず、チャンク単位で処理するのですが、全体の
     処理が終わるまで ‘parse()’ は返りません。そのため、 ‘parse()’ の排
     他的挙動を望まないときにこれらのインターフェースを使用してください
     。

     パーサのインスタンスが作成されるとすぐに、feed メソッドを通じてデー
     タを受け入れられるようになります。パースが完了して閉じるための呼び
     出しが行われた後、パーサがフィードからまたはパースメソッドを使用し
     て新しいデータを受け入れられるように、reset メソッドが呼び出される
     必要があります。

     これらのメソッドをパース処理の途中で呼び出すことはできません。つま
     り、パースが実行された後で、パーサから return する前に呼び出す必要
     があるのです。

     デフォルトでは、SAX 2.0 ドライバを書く人のために、このクラスは
     IncrementalParser の feed、close、reset メソッドを使って XMLReader
     インターフェースの parse メソッドを実装しています。

 -- クラス: xml.sax.xmlreader.Locator

     SAX イベントと文書の位置を関連付けるインターフェースです。locator オ
     ブジェクトは DocumentHandler メソッドを呼び出している間だけ正しい結
     果を返し、それ以外とのときは、予測できない結果を返します。情報を利
     用できない場合、メソッドは ‘None’ を返すこともあります。

 -- クラス: xml.sax.xmlreader.InputSource (system_id=None)

     *note XMLReader: 36f3. がエンティティを読み込むために必要な情報をカ
     プセル化します。

     このクラスには公開識別子、システム識別子、(場合によっては文字エンコ
     ーディング情報を含む) バイト・ストリーム、そしてエンティティの文字
     ストリームなどの情報が含まれます。

     アプリケーションは *note XMLReader.parse(): 3740. メソッドでの使用
     や EntityResolver.resolveEntity の戻り値としてこのオブジェトを作成
     します。

     *note InputSource: e64. はアプリケーションに属します。 *note
     XMLReader: 36f3. はアプリケーションから渡された *note InputSource:
     e64. オブジェクトの変更を許可されていませんが、コピーを作ってそれを
     変更することは可能です。

 -- クラス: xml.sax.xmlreader.AttributesImpl (attrs)

     ‘Attributes’ インターフェース (*note Attributes インターフェース:
     371e. 参照) の実装です。これは辞書風のオブジェクトで、
     ‘startElement()’ 内で要素の属性を表示します。最も有用な辞書操作に加
     え、インターフェースに記述されているメソッドを多数サポートしていま
     す。このクラスのオブジェクトはリーダによってインスタンス化されなけ
     ればなりません。'attrs' は属性名と属性値の対応付けを含む辞書風オブ
     ジェクトでなければなりません。

 -- クラス: xml.sax.xmlreader.AttributesNSImpl (attrs, qnames)

     *note AttributesImpl: 3744. を名前空間認識型に改良したクラスで、
     ‘startElementNS()’ に渡されます。 *note AttributesImpl: 3744. の派
     生クラスですが、 'namespaceURI' と 'localname' の2要素のタプルを解
     釈します。さらに、元の文書に出てくる修飾名を返す多くのメソッドを提
     供します。このクラスは ‘AttributesNS’ インターフェース (*note
     AttributesNS インターフェース: 3720. 参照) の実装です。

* Menu:

* XMLReader オブジェクト::
* IncrementalParser オブジェクト::
* Locator オブジェクト::
* InputSource オブジェクト::
* Attributes インターフェース::
* AttributesNS インターフェース::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/xml/sax/xmlreader.py


File: python.info,  Node: XMLReader オブジェクト,  Next: IncrementalParser オブジェクト,  Up: xml sax xmlreader --- XML パーサーのインターフェース

5.20.12.1 XMLReader オブジェクト
................................

*note XMLReader: 36f3. は次のメソッドをサポートします:

 -- メソッド: XMLReader.parse (source)

     入力ソースを処理し、SAX イベントを作成します。 'source' オブジェク
     トはシステム識別子 (入力ソースを特定する文字列 - 一般にファイル名や
     URL)、 *note pathlib.Path: 20a. オブジェクトか *note path-like:
     280. オブジェクトまたは *note InputSource: e64. オブジェクトです。
     *note parse(): 3740. が return したとき、入力データの処理は完了し、
     パーサ・オブジェクトは破棄ないしリセットされます。

     バージョン 3.5 で変更: 文字ストリームがサポートされました。

     バージョン 3.8 で変更: path-like オブジェクトのサポートが追加されま
     した。

 -- メソッド: XMLReader.getContentHandler ()

     現在の *note ContentHandler: 36f0. を返します。

 -- メソッド: XMLReader.setContentHandler (handler)

     現在の *note ContentHandler: 36f0. を設定します。 *note
     ContentHandler: 36f0. が設定されていない場合、内容イベントは破棄さ
     れます。

 -- メソッド: XMLReader.getDTDHandler ()

     現在の *note DTDHandler: 370a. を返します。

 -- メソッド: XMLReader.setDTDHandler (handler)

     現在の *note DTDHandler: 370a. を返します。 *note DTDHandler: 370a.
     が設定されていな場合、DTD イベントは破棄されます。

 -- メソッド: XMLReader.getEntityResolver ()

     現在の *note EntityResolver: 370b. を返します。

 -- メソッド: XMLReader.setEntityResolver (handler)

     現在の *note EntityResolver: 370b. を返します。 *note
     EntityResolver: 370b. が設定されていない場合、外部エンティティの解
     決を試行することでエンティティのシステム識別子が開かれます。利用で
     きない場合は失敗します。

 -- メソッド: XMLReader.getErrorHandler ()

     現在の *note ErrorHandler: 36fe. を返します。

 -- メソッド: XMLReader.setErrorHandler (handler)

     現在のエラーハンドラを設定します。*note ErrorHandler: 36fe. が設定
     されていない場合、エラーが例外として送出され、警告が表示されます。

 -- メソッド: XMLReader.setLocale (locale)

     アプリケーションにエラーや警告のロケール設定を許可します。

     SAX パーサにとって、エラーや警告の地域化は必須ではありません。しか
     し、パーサが要求されたロケールをサポートしていない場合、SAX 例外を
     送出しなければなりません。アプリケーションはパースの途中でロケール
     の変更を要求することができます。

 -- メソッド: XMLReader.getFeature (featurename)

     機能 'featurename' の現在の設定を返します。その機能が認識できないと
     きは、 ‘SAXNotRecognizedException’ を送出します。有名な機能名はモジ
     ュール *note xml.sax.handler: 111. に列挙されています。

 -- メソッド: XMLReader.setFeature (featurename, value)

     機能名 'featurename' に値 'value' を設定します。その機能が認識でき
     ないときは、 ‘SAXNotRecognizedException’ を送出します。また、パーサ
     が指定された機能や設定をサポートしていないときは、
     ‘SAXNotSupportedException’ を送出します。

 -- メソッド: XMLReader.getProperty (propertyname)

     属性名 'propertyname' の現在の値を返します。その属性が認識できない
     ときは、 ‘SAXNotRecognizedException’ を送出します。有名な属性名はモ
     ジュール *note xml.sax.handler: 111. に列挙されています。

 -- メソッド: XMLReader.setProperty (propertyname, value)

     属性名 'propertyname' に値 'value' を設定します。その機能が認識でき
     ないときは、 ‘SAXNotRecognizedException’ を送出します。また、パーサ
     が指定された機能や設定をサポートしていないときは、
     ‘SAXNotSupportedException’ を送出します。


File: python.info,  Node: IncrementalParser オブジェクト,  Next: Locator オブジェクト,  Prev: XMLReader オブジェクト,  Up: xml sax xmlreader --- XML パーサーのインターフェース

5.20.12.2 IncrementalParser オブジェクト
........................................

*note IncrementalParser: 3743. のインスタンスは次の追加メソッドを提供し
ます:

 -- メソッド: IncrementalParser.feed (data)

     'data' のチャンクを処理します。

 -- メソッド: IncrementalParser.close ()

     文書の終端を決定します。文書の適格性を調べ (終端でのみ可能)、ハンド
     ラを起動し、パース時に割り当てた資源を解放します。

 -- メソッド: IncrementalParser.reset ()

     このメソッドは close が呼び出された後、新しい文書をパースできるよう
     に、パーサをリセットするのに呼び出されます。close 後 reset を呼び出
     さずに parse や feed を呼び出した場合の戻り値は未定義です。


File: python.info,  Node: Locator オブジェクト,  Next: InputSource オブジェクト,  Prev: IncrementalParser オブジェクト,  Up: xml sax xmlreader --- XML パーサーのインターフェース

5.20.12.3 Locator オブジェクト
..............................

*note Locator: 3700. のインスタンスは次のメソッドを提供します:

 -- メソッド: Locator.getColumnNumber ()

     現在のイベントが開始する列番号を返します。

 -- メソッド: Locator.getLineNumber ()

     現在のイベントが開始する行番号を返します。

 -- メソッド: Locator.getPublicId ()

     現在の文書イベントの公開識別子を返します。

 -- メソッド: Locator.getSystemId ()

     現在のイベントのシステム識別子を返します。


File: python.info,  Node: InputSource オブジェクト,  Next: Attributes インターフェース,  Prev: Locator オブジェクト,  Up: xml sax xmlreader --- XML パーサーのインターフェース

5.20.12.4 InputSource オブジェクト
..................................

 -- メソッド: InputSource.setPublicId (id)

     この *note InputSource: e64. の公開識別子を設定します。

 -- メソッド: InputSource.getPublicId ()

     この *note InputSource: e64. の公開識別子を返します。

 -- メソッド: InputSource.setSystemId (id)

     この *note InputSource: e64. のシステム識別子を設定します。

 -- メソッド: InputSource.getSystemId ()

     この *note InputSource: e64. のシステム識別子を返します。

 -- メソッド: InputSource.setEncoding (encoding)

     この *note InputSource: e64. の文字エンコーディングを設定します。

     エンコーディングは XML エンコーディング宣言として受け入れられる文字
     列でなければなりません (XML 勧告の 4.3.3 節を参照)。

     *note InputSource: e64. も文字ストリームを含んでいた場合、*note
     InputSource: e64. のエンコーディング属性は無視されます。

 -- メソッド: InputSource.getEncoding ()

     この InputSource の文字エンコーディングを取得します。

 -- メソッド: InputSource.setByteStream (bytefile)

     この入力ソースのバイトストリーム (*note binary file: 1bf1.) を設定
     します。

     文字ストリームも指定されている場合、SAX パーサはこのバイトストリー
     ムを無視しますが、URI 接続自体を開くときには優先してバイトストリー
     ムを使います。

     アプリケーションがバイトストリームの文字エンコーディングを知ってい
     る場合は、setEncoding メソッドで設定する必要があります。

 -- メソッド: InputSource.getByteStream ()

     この入力ソースのバイトストリームを取得します。

     getEncoding メソッドは、このバイトストリームの文字エンコーディング
     を返します。不明なときは ‘None’ を返します。

 -- メソッド: InputSource.setCharacterStream (charfile)

     この入力ソースの文字ストリーム (*note text file: 1bf0.) を設定しま
     す。

     文字ストリームが指定された場合、SAX パーサは全バイトストリームを無
     視し、システム識別子への URI 接続の開始を試みません。

 -- メソッド: InputSource.getCharacterStream ()

     この入力ソースの文字ストリームを取得します。


File: python.info,  Node: Attributes インターフェース,  Next: AttributesNS インターフェース,  Prev: InputSource オブジェクト,  Up: xml sax xmlreader --- XML パーサーのインターフェース

5.20.12.5 ‘Attributes’ インターフェース
.......................................

‘Attributes’ オブジェクトは ‘copy()’、‘get()’、*note __contains__():
1ebe.、‘items()’、‘keys()’、‘values()’ を含む *note
マッピングプロトコル: 118c. の一部を実装しています。以下のメソッドも提供
されています:

 -- メソッド: Attributes.getLength ()

     属性の数を返します。

 -- メソッド: Attributes.getNames ()

     属性の名前を返します。

 -- メソッド: Attributes.getType (name)

     属性名 'name' のタイプを返します。通常は ‘'CDATA'’ です。

 -- メソッド: Attributes.getValue (name)

     属性 'name' の値を返します。


File: python.info,  Node: AttributesNS インターフェース,  Prev: Attributes インターフェース,  Up: xml sax xmlreader --- XML パーサーのインターフェース

5.20.12.6 ‘AttributesNS’ インターフェース
.........................................

このインターフェースは ‘Attributes’ インターフェース (*note Attributes
インターフェース: 371e. 参照) のサブタイプです。 Attributes インターフェ
ースがサポートしているすべてのメソッドは ‘AttributesNS’ オブジェクトでも
利用可能です。

次のメソッドもサポートされています:

 -- メソッド: AttributesNS.getValueByQName (name)

     修飾名の値を返します。

 -- メソッド: AttributesNS.getNameByQName (name)

     修飾名 'name' に対応する ‘(namespace, localname)’ のペアを返します
     。

 -- メソッド: AttributesNS.getQNameByName (name)

     ‘(namespace, localname)’ のペアに対応する修飾名を返します。

 -- メソッド: AttributesNS.getQNames ()

     すべての属性の修飾名を返します。


File: python.info,  Node: xml parsers expat --- Expat を使用した高速な XML 解析,  Prev: xml sax xmlreader --- XML パーサーのインターフェース,  Up: 構造化マークアップツール

5.20.13 ‘xml.parsers.expat’ -- Expat を使用した高速な XML 解析
--------------------------------------------------------------

__________________________________________________________________

     警告: ‘pyexpat’ モジュールは悪意を持って作成されたデータに対して安
     全ではありません。信頼できないデータや認証されていないデータをパー
     スする必要がある場合は *note XML の脆弱性: 3607. を参照してください
     。

*note xml.parsers.expat: 10d. モジュールは、検証 (validation) を行わない
XML パーザ (parser, 解析器)、Expat への Python インターフェースです。モ
ジュールは一つの拡張型 ‘xmlparser’ を提供します。これは XMLパーザの現在
の状況を表します。一旦 ‘xmlparser’ オブジェクトを生成すると、オブジェク
トの様々な属性をハンドラ関数 (handler function) に設定できます。その後、
XML 文書をパーザに入力すると、 XML文書の文字列とマークアップに応じてハン
ドラ関数が呼び出されます。

このモジュールでは、Expatパーザへのアクセスを提供するために ‘pyexpat’ モ
ジュールを使用します。 ‘pyexpat’ モジュールの直接使用は撤廃されています
。

このモジュールは、例外を一つと型オブジェクトを一つ提供しています:

 -- 例外: xml.parsers.expat.ExpatError

     Expat がエラーを報告したときに例外を送出します。 Expatのエラーを解
     釈する上での詳細な情報は、 *note ExpatError 例外: 3777. を参照して
     ください。

 -- 例外: xml.parsers.expat.error

     *note ExpatError: 124a. の別名です。

 -- データ: xml.parsers.expat.XMLParserType

     *note ParserCreate(): 377a. 関数から返された戻り値の型を示します。

*note xml.parsers.expat: 10d. モジュールには以下の 2 つの関数が収められ
ています:

 -- の関数: xml.parsers.expat.ErrorString (errno)

     与えられたエラー番号 'errno' を解説する文字列を返します。

 -- の関数: xml.parsers.expat.ParserCreate (encoding=None,
          namespace_separator=None)

     新しい ‘xmlparser’ オブジェクトを作成し、返します。 'encoding' が指
     定されていた場合、XMLデータで使われている文字列のエンコード名でなけ
     ればなりません。 Expatは、Pythonのように多くのエンコードをサポート
     しておらず、またエンコーディングのレパートリを拡張することはできま
     せん; サポートするエンコードは、UTF-8, UTF-16, ISO-8859-1 (Latin1),
     ASCII です。 'encoding' (1) が指定されると、文書に対する明示的、非
     明示的なエンコード指定を上書き (override) します。

     Expat はオプションで XML 名前空間の処理を行うことができます。これは
     引数 'namespace_separator' に値を指定することで有効になります。この
     値は、1文字の文字列でなければなりません; 文字列が誤った長さを持つ場
     合には *note ValueError: 1e3. が送出されます (‘None’ は値の省略と見
     なされます)。名前空間の処理が可能なとき、名前空間に属する要素と属性
     が展開されます。要素のハンドラである ‘StartElementHandler’ と
     ‘EndElementHandler’ に渡された要素名は、名前空間の URI、名前空間の
     区切り文字、要素名のローカル部を連結したものになります。名前空間の
     区切り文字が 0 バイト (‘chr(0)’) の場合、名前空間の URI とローカル
     部は区切り文字なしで連結されます。

     たとえば、'namespace_separator' に空白文字(‘' '’)がセットされ、次の
     ような文書が解析されるとします:

          <?xml version="1.0"?>
          <root xmlns    = "http://default-namespace.org/"
                xmlns:py = "http://www.python.org/ns/">
            <py:elem1 />
            <elem2 xmlns="" />
          </root>

     ‘StartElementHandler’ は各要素ごとに次のような文字列を受け取ります:

          http://default-namespace.org/ root
          http://www.python.org/ns/ elem1
          elem2

     ‘pyexpat’ が使っている ‘Expat’ ライブラリの制限により、返される
     ‘xmlparser’ インスタンスは単独の XML ドキュメントの解析にしか使えま
     せん。それぞれのドキュメントごとに別々のパーサのインスタンスを作る
     ために ‘ParserCreate’ を呼び出してください。

参考
....

The Expat XML Parser(2)

     Expatプロジェクトのホームページ。

* Menu:

* XMLParser オブジェクト: XMLParser オブジェクト<2>.
* ExpatError 例外::
* 使用例: 使用例<34>.
* 内容モデルの記述::
* Expat エラー定数::

   ---------- Footnotes ----------

   (1) XML 出力に含まれるエンコーディング文字列は適切な規格に従っていな
ければなりません。例えば、 "UTF-8" は有効ですが、 "UTF8" はそうではあり
ません。‘https://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl’
と
‘https://www.iana.org/assignments/character-sets/character-sets.xhtml’ を
参照してください。

   (2) http://www.libexpat.org/


File: python.info,  Node: XMLParser オブジェクト<2>,  Next: ExpatError 例外,  Up: xml parsers expat --- Expat を使用した高速な XML 解析

5.20.13.1 XMLParser オブジェクト
................................

‘xmlparser’ オブジェクトは以下のようなメソッドを持ちます:

 -- メソッド: xmlparser.Parse (data[, isfinal])

     文字列 'data' の内容を解析し、解析されたデータを処理するための適切
     な関数を呼び出します。このメソッドを最後に呼び出す時は 'isfinal' を
     真にしなければなりません; 単体ファイルを細切れに渡して解析出来るこ
     とを意味しますが、複数ファイルは扱えません。 'data' にはいつでも空
     の文字列を渡せます。

 -- メソッド: xmlparser.ParseFile (file)

     'file' オブジェクトから読み込んだXMLデータを解析します。 'file' に
     は ‘read(nbytes)’ メソッドのみが必要です。このメソッドはデータがな
     くなった場合に空文字列を返さねばなりません。。

 -- メソッド: xmlparser.SetBase (base)

     (XML) 宣言中のシステム識別子中の相対 URI を解決するための、基底 URI
     を設定します。相対識別子の解決はアプリケーションに任されます: この
     値は関数 *note ExternalEntityRefHandler(): 3781. や *note
     NotationDeclHandler(): 3782, *note UnparsedEntityDeclHandler():
     3783. に引数 'base' としてそのまま渡されます。

 -- メソッド: xmlparser.GetBase ()

     以前の *note SetBase(): 3780. によって設定された基底 URI を文字列の
     形で返します。 *note SetBase(): 3780. が呼ばれていないときには
     ‘None’ を返します。

 -- メソッド: xmlparser.GetInputContext ()

     現在のイベントを発生させた入力データを文字列として返します。データ
     はテキストの入っているエンティティが持っているエンコードになります
     。イベントハンドラがアクティブでないときに呼ばれると、戻り値は
     ‘None’ となります。

 -- メソッド: xmlparser.ExternalEntityParserCreate (context[, encoding])

     親となるパーザで解析された内容が参照している、外部で解析されるエン
     ティティを解析するために使える "子の" パーザを作成します。
     'context' パラメータは、以下に記すように *note
     ExternalEntityRefHandler(): 3781. ハンドラ関数に渡される文字列でな
     ければなりません。子のパーザは *note ordered_attributes: 3787,
     *note specified_attributes: 3788. が現在のパーザの値に設定されて生
     成されます。

 -- メソッド: xmlparser.SetParamEntityParsing (flag)

     パラメータエンティティ (外部DTDサブセットを含む) の解析を制御します
     。 'flag' の有効な値は、 ‘XML_PARAM_ENTITY_PARSING_NEVER’,
     ‘XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE’,
     ‘XML_PARAM_ENTITY_PARSING_ALWAYS’ です。 flag の設定をしたら true を
     返します。

 -- メソッド: xmlparser.UseForeignDTD ([flag])

     'flag' の値をデフォルトのtrueにすると、Expatは代わりのDTDをロードす
     るため、すべての引数に *note None: 641. を設定して *note
     ExternalEntityRefHandler: 3781. を呼び出します。XML文書が文書型定義
     を持っていなければ、 *note ExternalEntityRefHandler: 3781. が呼び出
     しますが、 *note StartDoctypeDeclHandler: 378b. と *note
     EndDoctypeDeclHandler: 378c. は呼び出されません。

     'flag' にfalseを与えると、メソッドが前回呼ばれた時のtrueの設定が解
     除されますが、他には何も起こりません。

     このメソッドは *note Parse(): 377e. または *note ParseFile(): 377f.
     メソッドが呼び出される前にだけ呼び出されます;これら2つのメソッドの
     どちらかが呼び出されたあとにメソッドが呼ばれると、 *note code: 13.
     に定数
     ‘errors.codes[errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING]’ が
     設定されて例外 *note ExpatError: 124a. が送出されます。

 -- メソッド: xmlparser.SetReparseDeferralEnabled (enabled)

          警告: Calling ‘SetReparseDeferralEnabled(False)’ has security
          implications, as detailed below; please make sure to
          understand these consequences prior to using the
          ‘SetReparseDeferralEnabled’ method.

     Expat 2.6.0 introduced a security mechanism called "reparse
     deferral" where instead of causing denial of service through
     quadratic runtime from reparsing large tokens, reparsing of
     unfinished tokens is now delayed by default until a sufficient
     amount of input is reached.  Due to this delay, registered handlers
     may — depending of the sizing of input chunks pushed to Expat — no
     longer be called right after pushing new input to the parser.
     Where immediate feedback and taking over responsibility of
     protecting against denial of service from large tokens are both
     wanted, calling ‘SetReparseDeferralEnabled(False)’ disables reparse
     deferral for the current Expat parser instance, temporarily or
     altogether.  Calling ‘SetReparseDeferralEnabled(True)’ allows
     re-enabling reparse deferral.

     Note that *note SetReparseDeferralEnabled(): 253. has been
     backported to some prior releases of CPython as a security fix.
     Check for availability of *note SetReparseDeferralEnabled(): 253.
     using *note hasattr(): 49e. if used in code running across a
     variety of Python versions.

     Added in version 3.13.

 -- メソッド: xmlparser.GetReparseDeferralEnabled ()

     Returns whether reparse deferral is currently enabled for the given
     Expat parser instance.

     Added in version 3.13.

‘xmlparser’ オブジェクトは次のような属性を持ちます:

 -- の属性: xmlparser.buffer_size

     *note buffer_text: 1467. が真の時に使われるバッファのサイズです。こ
     の属性に新しい整数値を代入することで違うバッファサイズにできます。
     サイズが変えられるときにバッファはフラッシュされます。

 -- の属性: xmlparser.buffer_text

     Setting this to true causes the ‘xmlparser’ object to buffer
     textual content returned by Expat to avoid multiple calls to the
     *note CharacterDataHandler(): 378e. callback whenever possible.
     This can improve performance substantially since Expat normally
     breaks character data into chunks at every line ending.  This
     attribute is false by default, and may be changed at any time.
     Note that when it is false, data that does not contain newlines may
     be chunked too.

 -- の属性: xmlparser.buffer_used

     *note buffer_text: 1467. が利用可能なとき、バッファに保持されたバイ
     ト数です。これらのバイトはUTF-8でエンコードされたテキストを表します
     。この属性は *note buffer_text: 1467. が偽の時には意味がありません
     。

 -- の属性: xmlparser.ordered_attributes

     この属性をゼロ以外の整数にすると、報告される(XMLノードの) 属性を辞
     書型ではなくリスト型にします。属性は文書のテキスト中の出現順で示さ
     れます。それぞれの属性は、2つのリストのエントリ: 属性名とその値、が
     与えられます。 (このモジュールの古いバージョンでも、同じフォーマッ
     トが使われています。) デフォルトでは、この属性はデフォルトでは偽と
     なりますが、いつでも変更可能です。

 -- の属性: xmlparser.specified_attributes

     ゼロ以外の整数にすると、パーザは文書のインスタンスで特定される属性
     だけを報告し、属性宣言から導出された属性は報告しないようになります
     。この属性が指定されたアプリケーションでは、XMLプロセッサの振る舞い
     に関する標準に従うために必要とされる (文書型) 宣言によって、どのよ
     うな付加情報が利用できるのかということについて特に注意を払わなけれ
     ばなりません。デフォルトで、この属性は偽となりますが、いつでも変更
     可能です。

以下の属性には、 ‘xmlparser’ オブジェクトで最も最近に起きたエラーに関す
る値が入っており、また ‘Parse()’ または ‘ParseFile()’ メソッドが *note
xml.parsers.expat.ExpatError: 124a. 例外を送出した際にのみ正しい値となり
ます。

 -- の属性: xmlparser.ErrorByteIndex

     エラーが発生したバイトのインデクスです。

 -- の属性: xmlparser.ErrorCode

     エラーを特定する数値によるコードです。この値は *note ErrorString():
     377b. に渡したり、 ‘errors’ オブジェクトで定義された内容と比較でき
     ます。

 -- の属性: xmlparser.ErrorColumnNumber

     エラーの発生したカラム番号です。

 -- の属性: xmlparser.ErrorLineNumber

     エラーの発生した行番号です。

以下の属性は ‘xmlparser’ オブジェクトがその時パースしている位置に関する
値を保持しています。コールバックがパースイベントを報告している間、これら
の値はイベントの生成した文字列の先頭の位置を指し示します。コールバックの
外から参照された時には、（対応するコールバックであるかにかかわらず）直前
のパースイベントの位置を示します。

 -- の属性: xmlparser.CurrentByteIndex

     パーサへの入力の、現在のバイトインデックス。

 -- の属性: xmlparser.CurrentColumnNumber

     パーサへの入力の、現在のカラム番号。

 -- の属性: xmlparser.CurrentLineNumber

     パーサへの入力の、現在の行番号。

以下に指定可能なハンドラのリストを示します。 ‘xmlparser’ オブジェクト
'o' にハンドラを指定するには、 ‘o.handlername = func’ を使用します。
'handlername' は、以下のリストに挙げた値をとらなければならず、また
'func' は正しい数の引数を受理する呼び出し可能なオブジェクトでなければな
りません。引数は特に明記しない限り、すべて文字列となります。

 -- メソッド: xmlparser.XmlDeclHandler (version, encoding, standalone)

     XML 宣言が解析された時に呼ばれます。 XML宣言は XML 勧告の適用バージ
     ョン、文書テクストのエンコード、ならびに任意の "standalone" 宣言の
     (任意の) 宣言です。 'version' と 'encoding' は文字列で、
     'standalone' は文書がスタンドアローンと宣言された場合は ‘1’、スタン
     ドアローンでないと宣言された場合は ‘0’、スタンドアローン節がない場
     合は ‘-1’ です。 Expat のバージョン 1.95.0 以降でのみ使用できます。

 -- メソッド: xmlparser.StartDoctypeDeclHandler (doctypeName, systemId,
          publicId, has_internal_subset)

     Expatが文書型宣言 (‘<!DOCTYPE ...’)を解析し始めたときに呼び出されま
     す。 'doctypeName' は、与えられた値がそのまま Expat に提供されます
     。 'systemId' と 'publicId' パラメタが指定されている場合、それぞれ
     システムと公開識別子を与えます。省略する時には ‘None’ にします。文
     書が内部的な文書宣言のサブセット (internal document declaration
     subset) を持つか、サブセット自体の場合、 'has_internal_subset' は
     true になります。このハンドラには、Expat version 1.2以上が必要です
     。

 -- メソッド: xmlparser.EndDoctypeDeclHandler ()

     Expatが文書型宣言の解析を終えたときに呼び出されます。このハンドラに
     は、Expat version 1.2以上が必要です。

 -- メソッド: xmlparser.ElementDeclHandler (name, model)

     それぞれの要素型宣言ごとに呼び出されます。 'name' は要素型の名前で
     あり、 'model' は内容モデル (content model) の表現です。

 -- メソッド: xmlparser.AttlistDeclHandler (elname, attname, type,
          default, required)

     ひとつの要素型で宣言される属性ごとに呼び出されます。属性リストの宣
     言が 3つの属性を宣言したとすると、このハンドラは各属性に1度ずつ、
     3度呼び出されます。 'elname' は要素名であり、これに対して宣言が適用
     され、 'attname' が宣言された属性名となります。属性型は文字列で、
     'type' として渡されます。取り得る値は、 ‘'CDATA'’, ‘'ID'’,
     ‘'IDREF'’, ...  です。 'default' は、文書のインスタンスによって属性
     が指定されていないときに使用されるデフォルト値です。デフォルト値
     (‘#IMPLIED’ values)が存在しないときには ‘None’ を与えます。文書のイ
     ンスタンス中に属性値を与える必要のあるときには 'required' が true に
     なります。これにはExpat version 1.95.0 以上が必要です。

 -- メソッド: xmlparser.StartElementHandler (name, attributes)

     要素の開始ごとに呼び出されます。 'name' は要素名を持つ文字列で、
     'attributes' は要素の属性です。 *note ordered_attributes: 3787. が
     真の場合これはリストです (詳細は *note ordered_attributes: 3787. を
     参照してください)。 そうでなければ名前を値に対応させる辞書です。

 -- メソッド: xmlparser.EndElementHandler (name)

     要素の終端を処理するごとに呼び出されます。

 -- メソッド: xmlparser.ProcessingInstructionHandler (target, data)

     処理命令を処理するごとに呼び出されます。

 -- メソッド: xmlparser.CharacterDataHandler (data)

     Called for character data.  This will be called for normal
     character data, CDATA marked content, and ignorable whitespace.
     Applications which must distinguish these cases can use the *note
     StartCdataSectionHandler: 379d, *note EndCdataSectionHandler: 379e,
     and *note ElementDeclHandler: 3798. callbacks to collect the
     required information.  Note that the character data may be chunked
     even if it is short and so you may receive more than one call to
     *note CharacterDataHandler(): 378e.  Set the *note buffer_text:
     1467. instance attribute to ‘True’ to avoid that.

 -- メソッド: xmlparser.UnparsedEntityDeclHandler (entityName, base,
          systemId, publicId, notationName)

     解析されていない (NDATA) エンティティ宣言を処理するために呼び出され
     ます。このハンドラは Expat ライブラリのバージョン1.2のためだけに存
     在します; より最近のバージョンでは、代わりに *note
     EntityDeclHandler: 379f. を使用してください (根底にある Expat ライ
     ブラリ内の関数は、撤廃されたものであると宣言されています)。

 -- メソッド: xmlparser.EntityDeclHandler (entityName,
          is_parameter_entity, value, base, systemId, publicId,
          notationName)

     エンティティ宣言ごとに呼び出されます。パラメタと内部エンティティに
     ついて、 'value' はエンティティ宣言の宣言済みの内容を与える文字列と
     なります; 外部エンティティの時には ‘None’ となります。解析済みエン
     ティティの場合、 'notationName' パラメタは ‘None’ となり、解析され
     ていないエンティティの時には記法 (notation) 名となります。
     'is_parameter_entity' は、エンティティがパラメタエンティティの場合
     真に、一般エンティティ (general entitiy) の場合には偽になります (ほ
     とんどのアプリケーションでは、一般エンティティのことしか気にする必
     要がありません)。このハンドラは Expat ライブラリのバージョン1.95.0
     以降でのみ使用できます。

 -- メソッド: xmlparser.NotationDeclHandler (notationName, base,
          systemId, publicId)

     記法の宣言 (notation declaration) で呼び出されます。
     'notationName', 'base', 'systemId', および 'publicId' を与える場合
     、文字列にします。public な識別子が省略された場合、 'publicId' は
     ‘None’ になります。

 -- メソッド: xmlparser.StartNamespaceDeclHandler (prefix, uri)

     要素が名前空間宣言を含んでいる場合に呼び出されます。名前空間宣言は
     、宣言が配置されている要素に対して *note StartElementHandler: 379a.
     が呼び出される前に処理されます。

 -- メソッド: xmlparser.EndNamespaceDeclHandler (prefix)

     名前空間宣言を含んでいたエレメントの終了タグに到達したときに呼び出
     されます。このハンドラは、要素に関する名前空間宣言ごとに、 *note
     StartNamespaceDeclHandler: 37a0. とは逆の順番で一度だけ呼び出され、
     各名前空間宣言のスコープが開始されたことを示します。このハンドラは
     、要素が終了する際、対応する *note EndElementHandler: 379b. が呼ば
     れた後に呼び出されます。

 -- メソッド: xmlparser.CommentHandler (data)

     コメントで呼び出されます。 'data' はコメントのテキストで、先頭の
     '‘<!-’ ‘-’' と末尾の '‘-’ ‘->’' を除きます。

 -- メソッド: xmlparser.StartCdataSectionHandler ()

     CDATA セクションの開始時に呼び出されます。CDATA セクションの構文的
     な開始と終了位置を識別できるようにするには、このハンドラと *note
     EndCdataSectionHandler: 379e. が必要です。

 -- メソッド: xmlparser.EndCdataSectionHandler ()

     CDATA セクションの終了時に呼び出されます。

 -- メソッド: xmlparser.DefaultHandler (data)

     XML 文書中で、適用可能なハンドラが指定されていない文字すべてに対し
     て呼び出されます。この文字とは、検出されたことが報告されるが、ハン
     ドラは指定されていないようなコンストラクト (construct) の一部である
     文字を意味します。

 -- メソッド: xmlparser.DefaultHandlerExpand (data)

     *note DefaultHandler(): 37a3. と同じですが、内部エンティティの展開
     を禁止しません。エンティティ参照はデフォルトハンドラに渡されません
     。

 -- メソッド: xmlparser.NotStandaloneHandler ()

     XML 文書がスタンドアロンの文書として宣言されていない場合に呼び出さ
     れます。外部サブセットやパラメタエンティティへの参照が存在するが、
     XML 宣言が XML 宣言中で standalone 変数を ‘yes’ に設定していない場
     合に起きます。このハンドラが ‘0’ を返すと、パーザは
     ‘XML_ERROR_NOT_STANDALONE’ を発生させます。このハンドラが設定されて
     いなければ、パーザは前述の事態で例外を送出しません。

 -- メソッド: xmlparser.ExternalEntityRefHandler (context, base,
          systemId, publicId)

     外部エンティティの参照時に呼び出されます。 'base' は現在の基底
     (base) で、以前の *note SetBase(): 3780. で設定された値になっていま
     す。 public、および system の識別子である、 'systemId' と
     'publicId' が指定されている場合、値は文字列です; public 識別子が指
     定されていない場合、 'publicId' は ‘None’ になります。 'context' の
     値は不明瞭なものであり、以下に記述するようにしか使ってはなりません
     。

     外部エンティティが解析されるようにするには、このハンドラを実装しな
     ければなりません。このハンドラは、
     ‘ExternalEntityParserCreate(context)’ を使って適切なコールバックを
     指定し、子パーザを生成して、エンティティを解析する役割を担います。
     このハンドラは整数を返さなければなりません; ‘0’ を返した場合、パー
     ザは ‘XML_ERROR_EXTERNAL_ENTITY_HANDLING’ エラーを送出します。そう
     でない場合、解析を継続します。

     このハンドラが与えられておらず、 *note DefaultHandler: 37a3. コール
     バックが指定されていれば、外部エンティティは *note DefaultHandler:
     37a3. で報告されます。


File: python.info,  Node: ExpatError 例外,  Next: 使用例<34>,  Prev: XMLParser オブジェクト<2>,  Up: xml parsers expat --- Expat を使用した高速な XML 解析

5.20.13.2 ExpatError 例外
.........................

*note ExpatError: 124a. 例外はいくつかの興味深い属性を備えています:

 -- の属性: ExpatError.code

     特定のエラーに対する Expat の内部エラー番号です。 *note
     errors.messages: 37a8. 辞書はこれらのエラー番号を Expat のエラーメ
     ッセージに対応させます。 例えば:

          from xml.parsers.expat import ParserCreate, ExpatError, errors

          p = ParserCreate()
          try:
              p.Parse(some_xml_document)
          except ExpatError as err:
              print("Error:", errors.messages[err.code])

     *note errors: 10e. モジュールはエラーメッセージ定数と、それらのメッ
     セージをエラーコードに対応させる辞書 *note codes: 37a9. も提供して
     います。以下を参照してください。

 -- の属性: ExpatError.lineno

     エラーが検出された場所の行番号です。最初の行の番号は ‘1’ です。

 -- の属性: ExpatError.offset

     エラーが発生した場所の行内でのオフセットです。最初のカラムの番号は
     ‘0’ です。


File: python.info,  Node: 使用例<34>,  Next: 内容モデルの記述,  Prev: ExpatError 例外,  Up: xml parsers expat --- Expat を使用した高速な XML 解析

5.20.13.3 使用例
................

以下のプログラムでは、与えられた引数を出力するだけの三つのハンドラを定義
しています。

     import xml.parsers.expat

     # 3 handler functions
     def start_element(name, attrs):
         print('Start element:', name, attrs)
     def end_element(name):
         print('End element:', name)
     def char_data(data):
         print('Character data:', repr(data))

     p = xml.parsers.expat.ParserCreate()

     p.StartElementHandler = start_element
     p.EndElementHandler = end_element
     p.CharacterDataHandler = char_data

     p.Parse("""<?xml version="1.0"?>
     <parent id="top"><child1 name="paul">Text goes here</child1>
     <child2 name="fred">More text</child2>
     </parent>""", 1)

このプログラムの出力は以下のようになります:

     Start element: parent {'id': 'top'}
     Start element: child1 {'name': 'paul'}
     Character data: 'Text goes here'
     End element: child1
     Character data: '\n'
     Start element: child2 {'name': 'fred'}
     Character data: 'More text'
     End element: child2
     Character data: '\n'
     End element: parent


File: python.info,  Node: 内容モデルの記述,  Next: Expat エラー定数,  Prev: 使用例<34>,  Up: xml parsers expat --- Expat を使用した高速な XML 解析

5.20.13.4 内容モデルの記述
..........................

内容モデルは入れ子になったタプルを使って記述されています。各タプルには以
下の 4 つの値が収められています: 型、限定詞 (quantifier)、名前、そして子
のタプル。子のタプルは単に内容モデルを記述したものです。

最初の二つのフィールドの値は *note xml.parsers.expat.model: 10f. モジュ
ールで定義されている定数です。これらの定数は二つのグループ: モデル型
(model type) グループと限定子 (quantifier) グループ、に取りまとめられま
す。

以下にモデル型グループにおける定数を示します:

 -- データ: xml.parsers.expat.model.XML_CTYPE_ANY

     モデル名で指定された要素は ‘ANY’ の内容モデルを持つと宣言されます。

 -- データ: xml.parsers.expat.model.XML_CTYPE_CHOICE

     指定されたエレメントはいくつかのオプションから選択できるようになっ
     ています; ‘(A | B | C)’ のような内容モデルで用いられます。

 -- データ: xml.parsers.expat.model.XML_CTYPE_EMPTY

     ‘EMPTY’ であると宣言されている要素はこのモデル型を持ちます。

 -- データ: xml.parsers.expat.model.XML_CTYPE_MIXED

 -- データ: xml.parsers.expat.model.XML_CTYPE_NAME

 -- データ: xml.parsers.expat.model.XML_CTYPE_SEQ

     順々に続くようなモデルの系列を表すモデルがこのモデル型で表されます
     。 ‘(A, B, C)’ のようなモデルで用いられます。

限定子グループにおける定数を以下に示します:

 -- データ: xml.parsers.expat.model.XML_CQUANT_NONE

     修飾子 (modifier) が指定されていません。従って ‘A’ のように、厳密に
     一つだけです。

 -- データ: xml.parsers.expat.model.XML_CQUANT_OPT

     このモデルはオプションです: ‘A?’ のように、一つか全くないかです。

 -- データ: xml.parsers.expat.model.XML_CQUANT_PLUS

     このモデルは (‘A+’ のように) 一つかそれ以上あります。

 -- データ: xml.parsers.expat.model.XML_CQUANT_REP

     このモデルは ‘A*’ のようにゼロ回以上あります。


File: python.info,  Node: Expat エラー定数,  Prev: 内容モデルの記述,  Up: xml parsers expat --- Expat を使用した高速な XML 解析

5.20.13.5 Expat エラー定数
..........................

以下の定数は *note xml.parsers.expat.errors: 10e. モジュールで提供されて
います。 これらの定数は、エラーが発生した際に送出される ‘ExpatError’ 例
外オブジェクトのいくつかの属性を解釈する上で便利です。 後方互換性の理由
で、定数値は数字のエラー 'コード' ではなくエラー 'メッセージ' です。 属
性を解釈するには *note code: 13. 属性と
‘errors.codes[errors.XML_ERROR_CONSTANT_NAME]’ を比較します。

‘errors’ モジュールには以下の属性があります:

 -- データ: xml.parsers.expat.errors.codes

     文字列の記述をエラーコードに対応させる辞書です。

     Added in version 3.2.

 -- データ: xml.parsers.expat.errors.messages

     数値的なエラーコードを文字列の記述に対応させる辞書です。

     Added in version 3.2.

 -- データ: xml.parsers.expat.errors.XML_ERROR_ASYNC_ENTITY

 -- データ:
          xml.parsers.expat.errors.XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF

     属性値中のエンティティ参照が、内部エンティティではなく外部エンティ
     ティを参照しました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_BAD_CHAR_REF

     文字参照が、XML では正しくない (illegal) 文字を参照しました (例えば
     ‘0’ や '‘&#0;’')。

 -- データ: xml.parsers.expat.errors.XML_ERROR_BINARY_ENTITY_REF

     エンティティ参照が、記法 (notation) つきで宣言されているエンティテ
     ィを参照したため、解析できません。

 -- データ: xml.parsers.expat.errors.XML_ERROR_DUPLICATE_ATTRIBUTE

     一つの属性が一つの開始タグ内に一度より多く使われています。

 -- データ: xml.parsers.expat.errors.XML_ERROR_INCORRECT_ENCODING

 -- データ: xml.parsers.expat.errors.XML_ERROR_INVALID_TOKEN

     入力されたバイトが文字に適切に関連付けできない際に送出されます; 例
     えば、UTF-8 入力ストリームにおける NUL バイト (値 ‘0’) などです。

 -- データ: xml.parsers.expat.errors.XML_ERROR_JUNK_AFTER_DOC_ELEMENT

     空白以外の何かがドキュメント要素の後にあります。

 -- データ: xml.parsers.expat.errors.XML_ERROR_MISPLACED_XML_PI

     入力データの先頭以外の場所に XML 定義が見つかりました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS

     この文書には要素がありません (XML では全ての文書は確実に最上位の要
     素を正確に一つ持たなければなりません)。

 -- データ: xml.parsers.expat.errors.XML_ERROR_NO_MEMORY

     Expat が内部メモリを確保できませんでした。

 -- データ: xml.parsers.expat.errors.XML_ERROR_PARAM_ENTITY_REF

     パラメータエンティティが許可されていない場所で見つかりました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_PARTIAL_CHAR

     入力に不完全な文字が見つかりました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_RECURSIVE_ENTITY_REF

     エンティティ参照中に、同じエンティティへの別の参照が入っていました;
     おそらく違う名前で参照しているか、間接的に参照しています。

 -- データ: xml.parsers.expat.errors.XML_ERROR_SYNTAX

     何らかの仕様化されていない構文エラーに遭遇しました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_TAG_MISMATCH

     終了タグが最も内側で開かれている開始タグに一致しません。

 -- データ: xml.parsers.expat.errors.XML_ERROR_UNCLOSED_TOKEN

     何らかの (開始タグのような) トークンが閉じられないまま、ストリーム
     の終端や次のトークンに遭遇しました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_UNDEFINED_ENTITY

     定義されていないエンティティへの参照が行われました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_UNKNOWN_ENCODING

     ドキュメントのエンコードが Expat でサポートされていません。

 -- データ: xml.parsers.expat.errors.XML_ERROR_UNCLOSED_CDATA_SECTION

     CDATAセクションが閉じられていません。

 -- データ: xml.parsers.expat.errors.XML_ERROR_EXTERNAL_ENTITY_HANDLING

 -- データ: xml.parsers.expat.errors.XML_ERROR_NOT_STANDALONE

     XML文書が "standalone" だと宣言されており ‘NotStandaloneHandler’ が
     設定され ‘0’ が返されているにもかかわらず、パーサは "standalone" で
     はないと判別しました。

 -- データ: xml.parsers.expat.errors.XML_ERROR_UNEXPECTED_STATE

 -- データ: xml.parsers.expat.errors.XML_ERROR_ENTITY_DECLARED_IN_PE

 -- データ: xml.parsers.expat.errors.XML_ERROR_FEATURE_REQUIRES_XML_DTD

     その操作を完了するにはDTDのサポートが必要ですが、ExpatがDTDのサポー
     トをしない設定になっています。これは *note xml.parsers.expat: 10d.
     モジュールの標準的なビルドでは報告されません。

 -- データ:
          xml.parsers.expat.errors.XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING

     パースが始まったあとで動作の変更が要求されました。これはパースが開
     始される前にのみ変更可能です。（現在のところ） ‘UseForeignDTD()’ に
     よってのみ送出されます。

 -- データ: xml.parsers.expat.errors.XML_ERROR_UNBOUND_PREFIX

     名前空間の処理を有効すると宣言されていないプレフィックスが見つかり
     ます。

 -- データ: xml.parsers.expat.errors.XML_ERROR_UNDECLARING_PREFIX

     XML文書はプレフィックスに対応した名前空間宣言を削除しようとしました
     。

 -- データ: xml.parsers.expat.errors.XML_ERROR_INCOMPLETE_PE

     パラメータエンティティは不完全なマークアップを含んでいます。

 -- データ: xml.parsers.expat.errors.XML_ERROR_XML_DECL

     XML文書中に要素がありません。

 -- データ: xml.parsers.expat.errors.XML_ERROR_TEXT_DECL

     外部エンティティ中のテキスト宣言にエラーがあります。

 -- データ: xml.parsers.expat.errors.XML_ERROR_PUBLICID

     パブリックID中に許可されていない文字があります。

 -- データ: xml.parsers.expat.errors.XML_ERROR_SUSPENDED

     要求された操作は一時停止されたパーサで行われていますが、許可されて
     いない操作です。このエラーは追加の入力を行なおうとしている場合、も
     しくはパーサが停止しようとしている場合にも送出されます。

 -- データ: xml.parsers.expat.errors.XML_ERROR_NOT_SUSPENDED

     パーサを一時停止しようとしましたが、停止されませんでした。

 -- データ: xml.parsers.expat.errors.XML_ERROR_ABORTED

     Pythonアプリケーションには通知されません。

 -- データ: xml.parsers.expat.errors.XML_ERROR_FINISHED

     要求された操作で、パース対象となる入力が完了したと判断しましたが、
     入力は受理されませんでした。このエラーは追加の入力を行なおうとして
     いる場合、もしくはパーサが停止しようとしている場合に送出されます。

 -- データ: xml.parsers.expat.errors.XML_ERROR_SUSPEND_PE

 -- データ: xml.parsers.expat.errors.XML_ERROR_RESERVED_PREFIX_XML

     An attempt was made to undeclare reserved namespace prefix ‘xml’ or
     to bind it to another namespace URI.

 -- データ: xml.parsers.expat.errors.XML_ERROR_RESERVED_PREFIX_XMLNS

     An attempt was made to declare or undeclare reserved namespace
     prefix ‘xmlns’.

 -- データ: xml.parsers.expat.errors.XML_ERROR_RESERVED_NAMESPACE_URI

     An attempt was made to bind the URI of one the reserved namespace
     prefixes ‘xml’ and ‘xmlns’ to another namespace prefix.

 -- データ: xml.parsers.expat.errors.XML_ERROR_INVALID_ARGUMENT

     Pythonアプリケーションには通知されません。

 -- データ: xml.parsers.expat.errors.XML_ERROR_NO_BUFFER

     Pythonアプリケーションには通知されません。

 -- データ:
          xml.parsers.expat.errors.XML_ERROR_AMPLIFICATION_LIMIT_BREACH

     The limit on input amplification factor (from DTD and entities) has
     been breached.

脚注
....


File: python.info,  Node: インターネットプロトコルとサポート,  Next: マルチメディアサービス,  Prev: 構造化マークアップツール,  Up: Python 標準ライブラリ

5.21 インターネットプロトコルとサポート
=======================================

この章で記述されるモジュールは、インターネットプロトコルを実装し、関連技
術をサポートします。それらは全てPythonで実装されています。これらのモジュ
ールの大部分は、システム依存のモジュール *note socket: b8. が存在するこ
とが必要ですが、これは現在ではほとんどの一般的なプラットフォーム上でサポ
ートされています。ここに概観を示します:

* Menu:

* webbrowser: webbrowser --- 便利なウェブブラウザコントローラー. 便利なウェブブラウザコントローラー
* wsgiref: wsgiref --- WSGI ユーティリティとリファレンス実装. WSGI ユーティリティとリファレンス実装
* urllib: urllib --- URL を扱うモジュール群. URL を扱うモジュール群
* urllib.request: urllib request --- URL を開くための大規模なライブラリ. URL を開くための大規模なライブラリ
* urllib.response: urllib response --- urllib で使用するレスポンスクラス. urllib で使用するレスポンスクラス
* urllib.parse: urllib parse --- URL を構成要素に解析する. URL を構成要素に解析する
* urllib.error: urllib error --- urllib request によって送出される例外クラス. urllib.request によって送出される例外クラス
* urllib.robotparser: urllib robotparser --- robots txt 用のパーサー. robots.txt 用のパーサー
* http: http --- HTTP モジュール群. HTTP モジュール群
* http.client: http client --- HTTP プロトコルクライアント. HTTP プロトコルクライアント
* ftplib: ftplib --- FTP プロトコルクライアント. FTP プロトコルクライアント
* poplib: poplib --- POP3 プロトコルクライアント. POP3 プロトコルクライアント
* imaplib: imaplib --- IMAP4 プロトコルクライアント. IMAP4 プロトコルクライアント
* smtplib: smtplib --- SMTP プロトコルクライアント. SMTP プロトコルクライアント
* uuid: uuid --- RFC 4122 に従った UUID オブジェクト. RFC 4122 に従った UUID オブジェクト
* socketserver: socketserver --- ネットワークサーバーのフレームワーク. ネットワークサーバーのフレームワーク
* http.server: http server --- HTTP サーバー. HTTP サーバー
* http.cookies: http cookies --- HTTP の状態管理. HTTP の状態管理
* http.cookiejar: http cookiejar --- HTTP クライアント用の Cookie 処理. HTTP クライアント用の Cookie 処理
* xmlrpc: xmlrpc --- XMLRPC サーバーとクライアントモジュール群. XMLRPC サーバーとクライアントモジュール群
* xmlrpc.client: xmlrpc client --- XML-RPC クライアントアクセス. XML-RPC クライアントアクセス
* xmlrpc.server: xmlrpc server --- 基本的な XML-RPC サーバー. 基本的な XML-RPC サーバー
* ipaddress: ipaddress --- IPv4/IPv6 操作ライブラリ. IPv4/IPv6 操作ライブラリ


File: python.info,  Node: webbrowser --- 便利なウェブブラウザコントローラー,  Next: wsgiref --- WSGI ユーティリティとリファレンス実装,  Up: インターネットプロトコルとサポート

5.21.1 ‘webbrowser’ -- 便利なウェブブラウザコントローラー
---------------------------------------------------------

'ソースコード:' Lib/webbrowser.py(1)

__________________________________________________________________

*note webbrowser: fd. モジュールにはウェブベースのドキュメントを表示する
ための、とてもハイレベルなインターフェースが定義されています。たいていの
環境では、このモジュールの *note open(): 37e2. を呼び出すだけで正しく動
作します。

Unixでは、X11上でグラフィカルなブラウザが選択されますが、グラフィカルな
ブラウザが利用できなかったり、X11が利用できない場合はテキストモードのブ
ラウザが使われます。もしテキストモードのブラウザが使われたら、ユーザがブ
ラウザから抜け出すまでプロセスの呼び出しはブロックされます。

環境変数 ‘BROWSER’ が存在する場合、これは *note os.pathsep: 1cae. で区切
られたブラウザのリストとして解釈され、プラットフォームのデフォルトのブラ
ウザリストに先立って順に試みられます。リストの中の値に ‘%s’ が含まれてい
れば、 ‘%s’ を URL に置換したコマンドライン文字列と解釈されます；もし
‘%s’ が含まれなければ、起動するブラウザの名前として単純に解釈されます。
(2)

非UnixプラットフォームあるいはUnix上でリモートブラウザが利用可能な場合、
制御プロセスはユーザがブラウザを終了するのを待ちませんが、ディスプレイに
ブラウザのウィンドウを表示させたままにします。Unix上でリモートブラウザが
利用可能でない場合、制御プロセスは新しいブラウザを立ち上げ、待ちます。

iOS では、 ‘BROWSER’ 環境変数に加えて、 autoraise 、ブラウザー設定、新し
いタブ・ウィンドウの作成を操作する引数は無視されます。ウェブページは '常
に' ユーザーが設定したブラウザーで、新しいタブで、前面に表示されて開かれ
ます。 iOS で *note webbrowser: fd. モジュールを使用する場合には *note
ctypes: 22. モジュールが必要です。 *note ctypes: 22. が利用可能でない場
合は、 *note open(): 37e2. の呼び出しは失敗します。

‘webbrowser’ のスクリプトは、モジュールのコマンドラインインターフェース
として利用可能です。これは引数として URL を受け入れます。また、次のオプ
ションのパラメーターを受け入れます。

   * ‘-n’/‘--new-window’ 可能なら、ブラウザーの新しいウィンドウで URL を
     開きます。

   * ‘-t’/‘--new-tab’ ブラウザーの新しいページ ("タブ") で URL を開きま
     す。

当然、これらのオプションは互いに排他的です。使用例:

     python -m webbrowser -t "https://www.python.org"

*note Availability: 1cbe.: not WASI, not Android.

以下の例外が定義されています:

 -- 例外: webbrowser.Error

     ブラウザのコントロールエラーが起こると発生する例外。

以下の関数が定義されています:

 -- の関数: webbrowser.open (url, new=0, autoraise=True)

     デフォルトのブラウザで 'url' を表示します。'new' が 0 なら、'url' は
     ブラウザの今までと同じウィンドウで開きます。'new' が 1 なら、可能で
     あればブラウザの新しいウィンドウが開きます。'new' が 2 なら、可能で
     あればブラウザの新しいタブが開きます。'autoraise' が ‘True’ なら、
     可能であればウィンドウが前面に表示されます（多くのウィンドウマネー
     ジャではこの変数の設定に関わらず、前面に表示されます）。

     Returns ‘True’ if a browser was successfully launched, ‘False’
     otherwise.

     幾つかのプラットフォームにおいて、ファイル名をこの関数で開こうとす
     ると、OSによって関連付けられたプログラムが起動されます。しかし、こ
     の動作はポータブルではありませんし、サポートされていません。

     引数 ‘url’ を指定して *note 監査イベント: 1825. ‘webbrowser.open’ を
     送出します。

 -- の関数: webbrowser.open_new (url)

     可能であれば、デフォルトブラウザの新しいウィンドウで 'url' を開きま
     すが、そうでない場合はブラウザのただ１つのウィンドウで 'url' を開き
     ます。

     Returns ‘True’ if a browser was successfully launched, ‘False’
     otherwise.

 -- の関数: webbrowser.open_new_tab (url)

     可能であれば、デフォルトブラウザの新しいページ(「タブ」)で 'url' を
     開きますが、そうでない場合は *note open_new(): 37e4. と同様に振る舞
     います。

     Returns ‘True’ if a browser was successfully launched, ‘False’
     otherwise.

 -- の関数: webbrowser.get (using=None)

     ブラウザの種類 'using' のコントローラーオブジェクトを返します。もし
     'using' が ‘None’ なら、呼び出した環境に適したデフォルトブラウザの
     コントローラーを返します。

 -- の関数: webbrowser.register (name, constructor, instance=None, *,
          preferred=False)

     ブラウザの種類 'name' を登録します。ブラウザの種類が登録されたら、
     *note get(): 37e6. でそのブラウザのコントローラーを呼び出すことがで
     きます。 'instance' が指定されなかったり、 ‘None’ なら、インスタン
     スが必要な時には 'constructor' がパラメータなしに呼び出されて作られ
     ます。 'instance' が指定されたら、 'constructor' は呼び出されないの
     で、 ‘None’ でかまいません。

     'preferred' を ‘True’ に設定すると、 *note get(): 37e6. の引数無し
     の呼び出しの結果が優先的にこのブラウザになります。 そうでない場合は
     、この関数は、変数 ‘BROWSER’ を設定するか、 *note get(): 37e6. を空
     文字列ではない、宣言したハンドラの名前と一致する引数とともに呼び出
     すときにだけ、役に立ちます。

     バージョン 3.7 で変更: 'preferred' キーワード専用引数が追加されまし
     た。

いくつかの種類のブラウザがあらかじめ定義されています。このモジュールで定
義されている、関数 *note get(): 37e6. に与えるブラウザの名前と、それぞれ
のコントローラークラスのインスタンスを以下の表に示します。

Type Name                    Class Name                                    注釈
                                                                           
---------------------------------------------------------------------------------------
                                                                           
‘'mozilla'’                  ‘Mozilla('mozilla')’
                             
                                                                           
‘'firefox'’                  ‘Mozilla('mozilla')’
                             
                                                                           
‘'epiphany'’                 ‘Epiphany('epiphany')’
                             
                                                                           
‘'kfmclient'’                ‘Konqueror()’                                 (1)
                                                                           
                                                                           
‘'konqueror'’                ‘Konqueror()’                                 (1)
                                                                           
                                                                           
‘'kfm'’                      ‘Konqueror()’                                 (1)
                                                                           
                                                                           
‘'opera'’                    ‘Opera()’
                             
                                                                           
‘'links'’                    ‘GenericBrowser('links')’
                             
                                                                           
‘'elinks'’                   ‘Elinks('elinks')’
                             
                                                                           
‘'lynx'’                     ‘GenericBrowser('lynx')’
                             
                                                                           
‘'w3m'’                      ‘GenericBrowser('w3m')’
                             
                                                                           
‘'windows-default'’          ‘WindowsDefault’                              (2)
                                                                           
                                                                           
‘'macosx'’                   ‘MacOSXOSAScript('default')’                  (3)
                                                                           
                                                                           
‘'safari'’                   ‘MacOSXOSAScript('safari')’                   (3)
                                                                           
                                                                           
‘'google-chrome'’            ‘Chrome('google-chrome')’
                             
                                                                           
‘'chrome'’                   ‘Chrome('chrome')’
                             
                                                                           
‘'chromium'’                 ‘Chromium('chromium')’
                             
                                                                           
‘'chromium-browser'’         ‘Chromium('chromium-browser')’
                             
                                                                           
‘'iosbrowser'’               ‘IOSBrowser’                                  (4)
                                                                           

注釈:

  1. "Konqueror" は Unix の KDE デスクトップ環境のファイルマネージャで、
     KDE が動作している時にだけ意味を持ちます。何か信頼できる方法で KDE
     を検出するのがいいでしょう; 変数 ‘KDEDIR’ では十分ではありません。
     また、 KDE 2 で ‘konqueror’ コマンドを使うときにも、 "kfm" が使われ
     ます -- Konqueror を動作させるのに最も良い方法が実装によって選択さ
     れます。

  2. Windows プラットフォームのみ。

  3. macOS のみ。

  4. iOS のみ。

Added in version 3.2: 新しい ‘MacOSXOSAScript’ クラスが追加され、以前の
‘MacOSX’ に替わって Mac で使用されます。これにより、現在 OS のデフォルト
として設定されていないブラウザを開くサポートが追加されました。

Added in version 3.3: Chrome/Chromium のサポートが追加されました。

バージョン 3.12 で変更: いくつかの古いブラウザのサポートが削除されました
。削除されたブラウザには、 Grail 、 Mosaic 、 Netscape 、 Galeon 、
Skipstone 、 Iceape 、そして Firefox のバージョン 35 以前が含まれます。

バージョン 3.13 で変更: iOS のサポートが追加されました。

簡単な例を示します:

     url = 'https://docs.python.org/'

     # Open URL in a new tab, if a browser window is already open.
     webbrowser.open_new_tab(url)

     # Open URL in new window, raising the window if possible.
     webbrowser.open_new(url)

* Menu:

* ブラウザコントローラーオブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/webbrowser.py

   (2) ここでブラウザの名前が絶対パスで書かれていない場合は ‘PATH’ 環境
変数で与えられたディレクトリから探し出されます。


File: python.info,  Node: ブラウザコントローラーオブジェクト,  Up: webbrowser --- 便利なウェブブラウザコントローラー

5.21.1.1 ブラウザコントローラーオブジェクト
...........................................

ブラウザコントローラーには以下のメソッドが定義されていて、モジュールレベ
ルの便利な 3 つの関数に相当します:

 -- の属性: controller.name

     ブラウザのシステム依存名。

 -- メソッド: controller.open (url, new=0, autoraise=True)

     このコントローラーでハンドルされたブラウザで 'url' を表示します。
     'new' が 1 なら、可能であればブラウザの新しいウィンドウが開きます。
     'new' が 2 なら、可能であればブラウザの新しいページ(「タブ」)が開き
     ます。

 -- メソッド: controller.open_new (url)

     可能であれば、このコントローラーでハンドルされたブラウザの新しいウ
     ィンドウで 'url' を開きますが、そうでない場合はブラウザのただ１つの
     ウィンドウで 'url' を開きます。 *note open_new(): 37e4. の別名。

 -- メソッド: controller.open_new_tab (url)

     可能であれば、このコントローラーでハンドルされたブラウザの新しいペ
     ージ(「タブ」)で 'url' を開きますが、そうでない場合は *note
     open_new(): 37e4. と同じです。

脚注
....


File: python.info,  Node: wsgiref --- WSGI ユーティリティとリファレンス実装,  Next: urllib --- URL を扱うモジュール群,  Prev: webbrowser --- 便利なウェブブラウザコントローラー,  Up: インターネットプロトコルとサポート

5.21.2 ‘wsgiref’ -- WSGI ユーティリティとリファレンス実装
---------------------------------------------------------

'ソースコード:' Lib/wsgiref(1)

__________________________________________________________________

Web Server Gateway Interface (WSGI) は、Web サーバソフトウェアと Python
で記述された Web アプリケーションとの標準インターフェースです。標準イン
ターフェースを持つことで、WSGI をサポートするアプリケーションを幾つもの
異なる Web サーバで使うことが容易になります。

Web サーバとプログラミングフレームワークの作者だけが、WSGI デザインのあ
らゆる細部や特例などを知る必要があります。WSGI アプリケーションをインス
トールしたり、既存のフレームワークを使ったアプリケーションを記述するだけ
の皆さんは、すべてについて理解する必要はありません。

*note wsgiref: 100. は WSGI 仕様のリファレンス実装で、これは Web サーバ
やフレームワークに WSGI サポートを加えるのに利用できます。これは WSGI 環
境変数やレスポンスヘッダを操作するユーティリティ、 WSGI サーバ実装時のベ
ースクラス、WSGI アプリケーションを提供するデモ用 HTTP サーバ、静的型チ
ェック用の型、それと WSGI サーバとアプリケーションの WSGI 仕様 ( PEP
3333(2)) 準拠のバリデーションツールを提供します。

wsgi.readthedocs.io(3) に、WSGIに関するさらなる情報と、チュートリアルや
その他のリソースへのリンクがあります。

* Menu:

* wsgiref.util: wsgiref util -- WSGI 環境のユーティリティ. WSGI 環境のユーティリティ
* wsgiref.headers: wsgiref headers -- WSGI レスポンスヘッダツール群. WSGI レスポンスヘッダツール群
* wsgiref.simple_server: wsgiref simple_server -- シンプルな WSGI HTTP サーバ. シンプルな WSGI HTTP サーバ
* wsgiref.validate: wsgiref validate --- WSGI 準拠チェッカー. WSGI 準拠チェッカー
* wsgiref.handlers: wsgiref handlers -- サーバ／ゲートウェイのベースクラス. サーバ／ゲートウェイのベースクラス
* wsgiref.types: wsgiref types -- WSGI types for static type checking. WSGI types for static type checking
* 使用例: 使用例<35>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/wsgiref

   (2) https://peps.python.org/pep-3333/

   (3) https://wsgi.readthedocs.io/


File: python.info,  Node: wsgiref util -- WSGI 環境のユーティリティ,  Next: wsgiref headers -- WSGI レスポンスヘッダツール群,  Up: wsgiref --- WSGI ユーティリティとリファレンス実装

5.21.2.1 ‘wsgiref.util’ - WSGI 環境のユーティリティ
...................................................

このモジュールは WSGI 環境で使う様々なユーティリティ関数を提供します。
WSGI 環境は PEP 3333(1) で記述されているような HTTP リクエスト変数を含む
辞書です。'environ' パラメータを取るすべての関数は WSGI 準拠の辞書を与え
られることを期待しています; 細かい仕様については PEP 3333(2) を、型アノ
テーションに使える型エイリアスについては *note WSGIEnvironment: 37f0. を
参照してください。

 -- の関数: wsgiref.util.guess_scheme (environ)

     'environ' 辞書の ‘HTTPS’ 環境変数を調べることで ‘wsgi.url_scheme’ が
     "http" か "https" のどちらであるべきか推測し、その結果を返します。
     戻り値は文字列です。

     この関数は、CGI や FastCGI のような CGI に似たプロトコルをラップす
     るゲートウェイを作成する場合に便利です。典型的には、それらのプロト
     コルを提供するサーバが SSL 経由でリクエストを受け取った場合には
     ‘HTTPS’ 変数に値 "1", "yes" または "on" を持つでしょう。そのため、
     この関数はそのような値が見つかった場合には "https" を返し、そうでな
     ければ "http" を返します。

 -- の関数: wsgiref.util.request_uri (environ, include_query=True)

     リクエスト URI 全体 (オプションでクエリ文字列を含む) を、 PEP
     3333(3) の "URL 再構築(URL Reconstruction)" にあるアルゴリズムを使
     って返します。 'include_query' が false の場合、クエリ文字列は結果
     となる文字列には含まれません。

 -- の関数: wsgiref.util.application_uri (environ)

     ‘PATH_INFO’ と ‘QUERY_STRING’ 変数が無視されることを除けば *note
     request_uri(): 37f2. に似ています。結果はリクエストによって指定され
     たアプリケーションオブジェクトのベース URI です。

 -- の関数: wsgiref.util.shift_path_info (environ)

     ‘PATH_INFO’ から ‘SCRIPT_NAME’ に一つの名前をシフトしてその名前を返
     します。'environ' 辞書は '変更されます' 。‘PATH_INFO’ や
     ‘SCRIPT_NAME’ のオリジナルをそのまま残したい場合にはコピーを使って
     ください。

     ‘PATH_INFO’ にパスセグメントが何も残っていなければ、‘None’ が返され
     ます。

     典型的なこのルーチンの使い方はリクエスト URI のそれぞれの要素の処理
     で、例えばパスを一連の辞書のキーとして取り扱う場合です。このルーチ
     ンは、渡された環境を、ターゲット URL で示される別の WSGI アプリケー
     ションの呼び出しに合うように調整します。例えば、 ‘/foo’ に WSGI ア
     プリケーションがあったとして、そしてリクエスト URL パスが
     ‘/foo/bar/baz’ で、 ‘/foo’ の WSGI アプリケーションが *note
     shift_path_info(): 37f4. を呼んだ場合、これは "bar" 文字列を受け取
     り、 environ は ‘/foo/bar’ の WSGI アプリケーションへの受け渡しに適
     するように更新されます。つまり、 ‘SCRIPT_NAME’ は ‘/foo’ から
     ‘/foo/bar’ に変わって、 ‘PATH_INFO’ は ‘/bar/baz’ から ‘/baz’ に変
     化するのです。

     ‘PATH_INFO’ が単に "/" の場合、このルーチンは空の文字列を返し、
     ‘SCRIPT_NAME’ の末尾にスラッシュを加えます、これはたとえ空のパスセ
     グメントが通常は無視され、そして ‘SCRIPT_NAME’ は通常スラッシュで終
     わる事が無かったとしてもです。これは意図的な振る舞いで、このルーチ
     ンでオブジェクト巡回(object traversal) をした場合に ‘/x’ で終わる
     URI と ‘/x/’ で終わるものをアプリケーションが識別できることを保証す
     るためのものです。

 -- の関数: wsgiref.util.setup_testing_defaults (environ)

     'environ' をテスト用に自明なデフォルト値で更新します。

     このルーチンは WSGI に必要な様々なパラメータを追加します。そのよう
     なパラメータとして ‘HTTP_HOST’ 、 ‘SERVER_NAME’ 、 ‘SERVER_PORT’ 、
     ‘REQUEST_METHOD’ 、 ‘SCRIPT_NAME’ 、 ‘PATH_INFO’ 、そして PEP
     3333(4) で定義されている ‘wsgi.*’ 変数群が含まれます。このルーチン
     はデフォルト値を提供するだけで、これらの変数の既存設定は一切置きか
     えません。

     このルーチンは、ダミー環境をセットアップすることによって WSGI サー
     バとアプリケーションのユニットテストを容易にすることを意図していま
     す。これは実際の WSGI サーバやアプリケーションで使うべきではありま
     せん。なぜならこのデータは偽物なのです！

     使用例:

          from wsgiref.util import setup_testing_defaults
          from wsgiref.simple_server import make_server

          # A relatively simple WSGI application. It's going to print out the
          # environment dictionary after being updated by setup_testing_defaults
          def simple_app(environ, start_response):
              setup_testing_defaults(environ)

              status = '200 OK'
              headers = [('Content-type', 'text/plain; charset=utf-8')]

              start_response(status, headers)

              ret = [("%s: %s\n" % (key, value)).encode("utf-8")
                     for key, value in environ.items()]
              return ret

          with make_server('', 8000, simple_app) as httpd:
              print("Serving on port 8000...")
              httpd.serve_forever()

上記の環境用関数に加えて、 *note wsgiref.util: 105. モジュールも以下のよ
うなその他のユーティリティを提供します:

 -- の関数: wsgiref.util.is_hop_by_hop (header_name)

     'header_name' が RFC 2616(5) で定義されている HTTP/1.1 の
     "Hop-by-Hop" ヘッダの場合に ‘True’ を返します。

 -- クラス: wsgiref.util.FileWrapper (filelike, blksize=8192)

     A concrete implementation of the *note wsgiref.types.FileWrapper:
     37f6. protocol used to convert a file-like object to an *note
     iterator: 191.  The resulting objects are *note iterable: 10ad.s.
     As the object is iterated over, the optional 'blksize' parameter
     will be repeatedly passed to the 'filelike' object's ‘read()’
     method to obtain bytestrings to yield.  When ‘read()’ returns an
     empty bytestring, iteration is ended and is not resumable.

     'filelike' に ‘close()’ メソッドがある場合、返されたオブジェクトも
     ‘close()’ メソッドを持ち、これが呼ばれた場合には 'filelike' オブジ
     ェクトの ‘close()’ メソッドを呼び出します。

     使用例:

          from io import StringIO
          from wsgiref.util import FileWrapper

          # We're using a StringIO-buffer for as the file-like object
          filelike = StringIO("This is an example file-like object"*10)
          wrapper = FileWrapper(filelike, blksize=5)

          for chunk in wrapper:
              print(chunk)

     バージョン 3.11 で変更: *note __getitem__(): 264. メソッドのサポー
     トは削除されました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3333/

   (2) https://peps.python.org/pep-3333/

   (3) https://peps.python.org/pep-3333/

   (4) https://peps.python.org/pep-3333/

   (5) https://datatracker.ietf.org/doc/html/rfc2616.html


File: python.info,  Node: wsgiref headers -- WSGI レスポンスヘッダツール群,  Next: wsgiref simple_server -- シンプルな WSGI HTTP サーバ,  Prev: wsgiref util -- WSGI 環境のユーティリティ,  Up: wsgiref --- WSGI ユーティリティとリファレンス実装

5.21.2.2 ‘wsgiref.headers’ - WSGI レスポンスヘッダツール群
..........................................................

このモジュールは単一のクラス、 *note Headers: e61. を提供し、WSGI レスポ
ンスヘッダの操作をマップに似たインターフェースで便利にします。

 -- クラス: wsgiref.headers.Headers ([headers])

     'headers' をラップするマップ風オブジェクトを生成します。これは PEP
     3333(1) に定義されるようなヘッダの名前／値のタプルのリストです。
     'headers' のデフォルト値は空のリストです。

     *note Headers: e61. objects support typical mapping operations
     including *note __getitem__(): 264, *note get(): 21a0, *note
     __setitem__(): 146e, *note setdefault(): 104e, *note __delitem__():
     146f. and *note __contains__(): 1ebe.  For each of these methods,
     the key is the header name (treated case-insensitively), and the
     value is the first value associated with that header name.  Setting
     a header deletes any existing values for that header, then adds a
     new value at the end of the wrapped header list.  Headers' existing
     order is generally maintained, with new headers added to the end of
     the wrapped list.

     辞書とは違って、 *note Headers: e61. オブジェクトはラップされたヘッ
     ダリストに存在しないキーを取得または削除しようとした場合にもエラー
     を発生しません。単に、存在しないヘッダの取得は ‘None’ を返し、存在
     しないヘッダの削除は何もしません。

     *note Headers: e61. オブジェクトは ‘keys()’ 、 ‘values()’ 、
     ‘items()’ メソッドもサポートします。複数の値を持つヘッダがある場合
     には、 ‘keys()’ と ‘items()’ で返されるリストは同じキーを一つ以上含
     むことがあります。 *note Headers: e61. オブジェクトの ‘len()’ は、
     その ‘items()’ の長さと同じであり、ラップされたヘッダリストの長さと
     同じです。実際、 ‘items()’ メソッドは単にラップされたヘッダリストの
     コピーを返しているだけです。

     *note Headers: e61. オブジェクトに対して ‘bytes()’ を呼ぶと、HTTP レ
     スポンスヘッダとして送信するのに適した形に整形されたバイト文字列を
     返します。それぞれのヘッダはコロンとスペースで区切られた値と共に一
     列に並んでいます。それぞれの行はキャリッジリターンとラインフィード
     で終了し、バイト文字列は空行で終了しています。

     これらのマッピングインターフェースと整形機能に加えて、 *note
     Headers: e61. オブジェクトは複数の値を持つヘッダの取得と追加、MIME
     パラメータでヘッダを追加するための以下のようなメソッド群も持ってい
     ます:

      -- メソッド: get_all (name)

          指定されたヘッダのすべての値のリストを返します。

          返されるリストは、元々のヘッダリストに現れる順、またはこのイン
          スタンスに追加された順に並んでいて、重複を含む場合があります。
          削除されて加えられたフィールドはすべてヘッダリストの末尾に付き
          ます。与えられた name に対するフィールドが何もなければ、空のリ
          ストが返ります。

      -- メソッド: add_header (name, value, **_params)

          (複数の値を持つ可能性のある) ヘッダを、キーワード引数を通じて
          指定するオプションの MIME パラメータと共に追加します。

          'name' は追加するヘッダフィールドです。このヘッダフィールドに
          MIME パラメータを設定するためにキーワード引数を使うことができ
          ます。それぞれのパラメータは文字列か ‘None’ でなければいけませ
          ん。パラメータ中のアンダースコアはダッシュ (-) に変換されます
          。これは、ダッシュが Python の識別子としては不正なのですが、多
          くの MIME パラメータはダッシュを含むためです。パラメータ値が文
          字列の場合、これはヘッダ値のパラメータに ‘name="value"’ の形で
          追加されます。この値がもし ‘None’ の場合、パラメータ名だけが追
          加されます。（これは値なしの MIME パラメータの場合に使われます
          。）使い方の例は:

               h.add_header('content-disposition', 'attachment', filename='bud.gif')

          上記はこのようなヘッダを追加します:

               Content-Disposition: attachment; filename="bud.gif"

     バージョン 3.5 で変更: 'headers' 引数が任意になりました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3333/


File: python.info,  Node: wsgiref simple_server -- シンプルな WSGI HTTP サーバ,  Next: wsgiref validate --- WSGI 準拠チェッカー,  Prev: wsgiref headers -- WSGI レスポンスヘッダツール群,  Up: wsgiref --- WSGI ユーティリティとリファレンス実装

5.21.2.3 ‘wsgiref.simple_server’ - シンプルな WSGI HTTP サーバ
..............................................................

このモジュールは WSGI アプリケーションを提供するシンプルな HTTP サーバで
す (*note http.server: 68. がベースです)。個々のサーバインスタンスは単一
の WSGI アプリケーションを、特定のホストとポート上で提供します。もし一つ
のホストとポート上で複数のアプリケーションを提供したいならば、
‘PATH_INFO’ をパースして個々のリクエストでどのアプリケーションを呼び出す
か選択するような WSGI アプリケーションを作る必要があります。（例えば、
*note wsgiref.util: 105. から ‘shift_path_info()’ を利用します。）

 -- の関数: wsgiref.simple_server.make_server (host, port, app,
          server_class=WSGIServer, handler_class=WSGIRequestHandler)

     'host' と 'port' 上で待機し、 'app' へのコネクションを受け付ける
     WSGI サーバを作成します。戻り値は与えられた 'server_class' のインス
     タンスで、指定された 'handler_class' を使ってリクエストを処理します
     。 'app' は PEP 3333(1) で定義されるところの WSGI アプリケーション
     でなければいけません。

     使用例:

          from wsgiref.simple_server import make_server, demo_app

          with make_server('', 8000, demo_app) as httpd:
              print("Serving HTTP on port 8000...")

              # Respond to requests until process is killed
              httpd.serve_forever()

              # Alternative: serve one request, then exit
              httpd.handle_request()

 -- の関数: wsgiref.simple_server.demo_app (environ, start_response)

     この関数は小規模ながら完全な WSGI アプリケーションで、 "Hello
     world!"  メッセージと、 'environ' パラメータに提供されているキー／
     値のペアを含むテキストページを返します。これは WSGI サーバ (*note
     wsgiref.simple_server: 103. のような) がシンプルな WSGI アプリケー
     ションを正しく実行できるかを確かめるのに便利です。

 -- クラス: wsgiref.simple_server.WSGIServer (server_address,
          RequestHandlerClass)

     *note WSGIServer: 37fd. インスタンスを作成します。 'server_address'
     は ‘(host,port)’ のタプル、そして 'RequestHandlerClass' はリクエス
     トの処理に使われる *note http.server.BaseHTTPRequestHandler: 109e.
     のサブクラスでなければいけません。

     *note make_server(): 37fb. が細かい調整をやってくれるので、通常はこ
     のコンストラクタを呼ぶ必要はありません。

     *note WSGIServer: 37fd. は *note http.server.HTTPServer: 37fe. のサ
     ブクラスなので、そのすべてのメソッド (‘serve_forever()’ や
     ‘handle_request()’ のような) が利用できます。 *note WSGIServer:
     37fd. も以下のような WSGI 固有メソッドを提供します:

      -- メソッド: set_app (application)

          呼び出し可能 (callable) な 'application' をリクエストを受け取
          る WSGI アプリケーションとして設定します。

      -- メソッド: get_app ()

          Returns the currently set application callable.

     しかしながら、通常はこれらの追加されたメソッドを使う必要はありませ
     ん。 *note set_app(): 37ff. は普通は *note make_server(): 37fb. に
     よって呼ばれ、 *note get_app(): 3800. は主にリクエストハンドライン
     スタンスの便宜上存在するからです。

 -- クラス: wsgiref.simple_server.WSGIRequestHandler (request,
          client_address, server)

     与えられた 'request' （すなわちソケット）の HTTP ハンドラ、
     'client_address' (‘(host,port)’ のタプル)、 'server' (*note
     WSGIServer: 37fd. インスタンス) の HTTP ハンドラを作成します。

     このクラスのインスタンスを直接生成する必要はありません; これらは必
     要に応じて *note WSGIServer: 37fd. オブジェクトによって自動的に生成
     されます。しかしながら、このクラスをサブクラス化し、 *note
     make_server(): 37fb. 関数に 'handler_class' として与えることは可能
     でしょう。サブクラスにおいてオーバーライドする意味のありそうなもの
     は:

      -- メソッド: get_environ ()

          リクエストに対する *note WSGIEnvironment: 37f0. 辞書を返します
          。デフォルト実装では *note WSGIServer: 37fd. オブジェクトの
          ‘base_environ’ 辞書属性のコンテンツをコピーし、それから HTTP リ
          クエスト由来の様々なヘッダを追加しています。このメソッド呼び出
          し毎に、 PEP 3333(2) に指定されている関連する CGI 環境変数をす
          べて含む新規の辞書を返さなければいけません。

      -- メソッド: get_stderr ()

          ‘wsgi.errors’ ストリームとして使われるオブジェクトを返します。
          デフォルト実装では単に ‘sys.stderr’ を返します。

      -- メソッド: handle ()

          HTTP リクエストを処理します。デフォルト実装では実際の WGI アプ
          リケーションインターフェースを実装するのに *note
          wsgiref.handlers: 101. クラスを使ってハンドラインスタンスを作
          成します。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3333/

   (2) https://peps.python.org/pep-3333/


File: python.info,  Node: wsgiref validate --- WSGI 準拠チェッカー,  Next: wsgiref handlers -- サーバ／ゲートウェイのベースクラス,  Prev: wsgiref simple_server -- シンプルな WSGI HTTP サーバ,  Up: wsgiref --- WSGI ユーティリティとリファレンス実装

5.21.2.4 ‘wsgiref.validate’ -- WSGI 準拠チェッカー
..................................................

WSGI アプリケーションのオブジェクト、フレームワーク、サーバまたはミドル
ウェアの作成時には、その新規のコードを *note wsgiref.validate: 106. を使
って準拠の検証をすると便利です。このモジュールは WSGI サーバやゲートウェ
イと WSGI アプリケーションオブジェクト間の通信を検証する WSGI アプリケー
ションオブジェクトを作成する関数を提供し、双方のプロトコル準拠をチェック
します。

このユーティリティは完全な PEP 3333(1) 準拠を保証するものでないことは注
意してください; このモジュールでエラーが出ないことは必ずしもエラーが存在
しないことを意味しません。しかしこのモジュールがエラーを出したならば、ほ
ぼ確実にサーバかアプリケーションのどちらかが 100% 準拠ではありません。

このモジュールは lan Bicking の "Python Paste" ライブラリの ‘paste.lint’
モジュールをベースにしています。

 -- の関数: wsgiref.validate.validator (application)

     'application' をラップし、新しい WSGI アプリケーションオブジェクト
     を返します。返されたアプリケーションは全てのリクエストを元々の
     'application' に転送し、'application' とそれを呼び出すサーバの両方
     が WSGI 仕様と RFC 2616(2) の両方に準拠しているかをチェックします。

     何らかの非準拠が検出されると、 *note AssertionError: 675. 例外が送
     出されます; しかし、このエラーがどう扱われるかはサーバ依存であるこ
     とに注意してください。例えば、 *note wsgiref.simple_server: 103. と
     その他 *note wsgiref.handlers: 101. ベースのサーバ（エラー処理メソ
     ッドが他のことをするようにオーバライドしていないもの）は単純にエラ
     ーが発生したというメッセージとトレースバックのダンプを ‘sys.stderr’
     やその他のエラーストリームに出力します。

     このラッパーは、疑わしいものの実際には PEP 3333(3) で禁止されていな
     いかもしれない挙動を指摘するために *note warnings: fa. モジュールを
     使って出力を生成します。これらは Python のコマンドラインオプション
     や *note warnings: fa. API で抑制されなければ、 ‘sys.stderr’
     (‘wsgi.errors’ では 'ありません' 。ただし、たまたま同一のオブジェク
     トだった場合を除く)に書き出されます。

     使用例:

          from wsgiref.validate import validator
          from wsgiref.simple_server import make_server

          # Our callable object which is intentionally not compliant to the
          # standard, so the validator is going to break
          def simple_app(environ, start_response):
              status = '200 OK'  # HTTP Status
              headers = [('Content-type', 'text/plain')]  # HTTP Headers
              start_response(status, headers)

              # This is going to break because we need to return a list, and
              # the validator is going to inform us
              return b"Hello World"

          # This is the application wrapped in a validator
          validator_app = validator(simple_app)

          with make_server('', 8000, validator_app) as httpd:
              print("Listening on port 8000....")
              httpd.serve_forever()

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3333/

   (2) https://datatracker.ietf.org/doc/html/rfc2616.html

   (3) https://peps.python.org/pep-3333/


File: python.info,  Node: wsgiref handlers -- サーバ／ゲートウェイのベースクラス,  Next: wsgiref types -- WSGI types for static type checking,  Prev: wsgiref validate --- WSGI 準拠チェッカー,  Up: wsgiref --- WSGI ユーティリティとリファレンス実装

5.21.2.5 ‘wsgiref.handlers’ - サーバ／ゲートウェイのベースクラス
................................................................

このモジュールは WSGI サーバとゲートウェイ実装のベースハンドラクラスを提
供します。これらのベースクラスは、CGI 風の環境と、それに加えて入力、出力
そしてエラーストリームが与えられることで、WSGI アプリケーションとの通信
の大部分を処理します。

 -- クラス: wsgiref.handlers.CGIHandler

     ‘sys.stdin’、‘sys.stdout’、‘sys.stderr’ そして ‘os.environ’ 経由で
     の CGI ベースの呼び出しです。これは、もしあなたが WSGI アプリケーシ
     ョンを持っていて、これを CGI スクリプトとして実行したい場合に有用で
     す。単に ‘CGIHandler().run(app)’ を起動してください。‘app’ はあなた
     が起動したい WSGI アプリケーションオブジェクトです。

     このクラスは *note BaseCGIHandler: 3809. のサブクラスで、これは
     ‘wsgi.run_once’ を true、 ‘wsgi.multithread’ を false、そして
     ‘wsgi.multiprocess’ を true にセットし、常に *note sys: c3. と
     *note os: 91. を、必要な CGI ストリームと環境を取得するために使用し
     ます。

 -- クラス: wsgiref.handlers.IISCGIHandler

     (IIS 7 以降の) 設定オプションの allowPathInfo や (IIS 7 より前の) メ
     タベースの allowPathInfoForScriptMappings を設定せずに Microsoft の
     IIS Web サーバにデプロイするときに使う、 *note CGIHandler: 3808. ク
     ラス以外の専用の選択肢です。

     By default, IIS gives a ‘PATH_INFO’ that duplicates the
     ‘SCRIPT_NAME’ at the front, causing problems for WSGI applications
     that wish to implement routing.  This handler strips any such
     duplicated path.

     IIS can be configured to pass the correct ‘PATH_INFO’, but this
     causes another bug where ‘PATH_TRANSLATED’ is wrong.  Luckily this
     variable is rarely used and is not guaranteed by WSGI. On IIS<7,
     though, the setting can only be made on a vhost level, affecting
     all other script mappings, many of which break when exposed to the
     ‘PATH_TRANSLATED’ bug.  For this reason IIS<7 is almost never
     deployed with the fix (Even IIS7 rarely uses it because there is
     still no UI for it.).

     There is no way for CGI code to tell whether the option was set, so
     a separate handler class is provided.  It is used in the same way
     as *note CGIHandler: 3808, i.e., by calling
     ‘IISCGIHandler().run(app)’, where ‘app’ is the WSGI application
     object you wish to invoke.

     Added in version 3.2.

 -- クラス: wsgiref.handlers.BaseCGIHandler (stdin, stdout, stderr,
          environ, multithread=True, multiprocess=False)

     *note CGIHandler: 3808. に似ていますが、 *note sys: c3. と *note
     os: 91. モジュールを使う代わりに CGI 環境と I/O ストリームを明示的
     に指定します。 'multithread' と 'multiprocess' の値は、ハンドライン
     スタンスにより実行されるアプリケーションの ‘wsgi.multithread’ と
     ‘wsgi.multiprocess’ フラグの設定に使われます。

     このクラスは *note SimpleHandler: 380b. のサブクラスで、HTTP の "本
     サーバ" でないソフトウェアと使うことを意図しています。もしあなたが
     ‘Status:’ ヘッダを HTTP ステータスを送信するのに使うようなゲートウ
     ェイプロトコルの実装（CGI、FastCGI、SCGIなど）を書いている場合、お
     そらく *note SimpleHandler: 380b. ではなくこのクラスをサブクラス化
     するとよいでしょう。

 -- クラス: wsgiref.handlers.SimpleHandler (stdin, stdout, stderr,
          environ, multithread=True, multiprocess=False)

     *note BaseCGIHandler: 3809. と似ていますが、HTTP の本サーバと使うた
     めにデザインされています。もしあなたが HTTP サーバ実装を書いている
     場合、おそらく *note BaseCGIHandler: 3809. ではなくこのクラスをサブ
     クラス化するとよいでしょう。

     This class is a subclass of *note BaseHandler: 195b.  It overrides
     the ‘__init__()’, *note get_stdin(): 380c, *note get_stderr():
     380d, *note add_cgi_vars(): 380e, *note _write(): 380f, and *note
     _flush(): 3810. methods to support explicitly setting the
     environment and streams via the constructor.  The supplied
     environment and streams are stored in the ‘stdin’, ‘stdout’,
     ‘stderr’, and ‘environ’ attributes.

     The *note write(): ca9. method of 'stdout' should write each chunk
     in full, like *note io.BufferedIOBase: 660.

 -- クラス: wsgiref.handlers.BaseHandler

     これは WSGI アプリケーションを実行するための抽象ベースクラスです。
     それぞれのインスタンスは一つの HTTP リクエストを処理します。しかし
     原理上は複数のリクエスト用に再利用可能なサブクラスを作成することが
     できます。

     *note BaseHandler: 195b. インスタンスは外部から利用されるたった一つ
     のメソッドを持ちます:

      -- メソッド: run (app)

          指定された WSGI アプリケーション、'app' を実行します。

     その他のすべての *note BaseHandler: 195b. のメソッドはアプリケーシ
     ョン実行プロセスでこのメソッドから呼ばれます。したがって、それらは
     主にそのプロセスのカスタマイズのために存在しています。

     以下のメソッドはサブクラスでオーバーライドされなければいけません:

      -- メソッド: _write (data)

          バイト列の 'data' をクライアントへの転送用にバッファします。こ
          のメソッドが実際にデータを転送しても OK です: 下部システムが実
          際にそのような区別をしている場合に効率をより良くするために、
          *note BaseHandler: 195b. は書き出しとフラッシュ操作を分けてい
          るからです。

      -- メソッド: _flush ()

          バッファされたデータをクライアントに強制的に転送します。このメ
          ソッドは何もしなくても OK です（すなわち、 *note _write():
          380f. が実際にデータを送る場合）。

      -- メソッド: get_stdin ()

          Return an object compatible with *note InputStream: 3812.
          suitable for use as the ‘wsgi.input’ of the request currently
          being processed.

      -- メソッド: get_stderr ()

          Return an object compatible with *note ErrorStream: 3813.
          suitable for use as the ‘wsgi.errors’ of the request currently
          being processed.

      -- メソッド: add_cgi_vars ()

          現在のリクエストの CGI 変数を ‘environ’ 属性に追加します。

     オーバーライドされることの多いメソッド及び属性を以下に挙げます。し
     かし、このリストは単にサマリであり、オーバーライド可能なすべてのメ
     ソッドは含んでいません。カスタマイズした *note BaseHandler: 195b. サ
     ブクラスを作成しようとする前に docstring やソースコードでさらなる情
     報を調べてください。

     WSGI 環境のカスタマイズのための属性とメソッド:

      -- の属性: wsgi_multithread

          ‘wsgi.multithread’ 環境変数で使われる値。 *note BaseHandler:
          195b. ではデフォルトが true ですが、別のサブクラスではデフォル
          トで（またはコンストラクタによって設定されて）異なる値を持つこ
          とがあります。

      -- の属性: wsgi_multiprocess

          ‘wsgi.multiprocess’ 環境変数で使われる値。 *note BaseHandler:
          195b. ではデフォルトが true ですが、別のサブクラスではデフォル
          トで（またはコンストラクタによって設定されて）異なる値を持つこ
          とがあります。

      -- の属性: wsgi_run_once

          ‘wsgi.run_once’ 環境変数で使われる値。 *note BaseHandler:
          195b. ではデフォルトが false ですが、 *note CGIHandler: 3808.
          はデフォルトでこれを true に設定します。

      -- の属性: os_environ

          すべてのリクエストの WSGI 環境に含まれるデフォルトの環境変数。
          デフォルトでは *note wsgiref.handlers: 101. がインポートされた
          時点の ‘os.environ’ のコピーですが、サブクラスはクラスまたはイ
          ンスタンスレベルでそれら自身のものを作ることができます。デフォ
          ルト値は複数のクラスとインスタンスで共有されるため、この辞書は
          読み出し専用と考えるべきだという点に注意してください。

      -- の属性: server_software

          *note origin_server: 3819. 属性が設定されている場合、この属性
          の値がデフォルトの ‘SERVER_SOFTWARE’ WSGI 環境変数の設定や
          HTTP レスポンス中のデフォルトの ‘Server:’ ヘッダの設定に使われ
          ます。これは (*note BaseCGIHandler: 3809. や *note CGIHandler:
          3808. のような) HTTP オリジンサーバでないハンドラでは無視され
          ます。

          バージョン 3.3 で変更: "Python" という語は "CPython" や
          "Jython" などのような個別実装の語に置き換えられました。

      -- メソッド: get_scheme ()

          現在のリクエストで使われている URL スキームを返します。デフォ
          ルト実装は *note wsgiref.util: 105. の ‘guess_scheme()’ を使い
          、現在のリクエストの ‘environ’ 変数に基づいてスキームが"http"
          か "https" かを推測します。

      -- メソッド: setup_environ ()

          ‘environ’ 属性を、フル実装 (fully populated) の WSGI 環境に設
          定します。デフォルトの実装は、上記すべてのメソッドと属性、加え
          て *note get_stdin(): 380c. 、 *note get_stderr(): 380d. 、
          *note add_cgi_vars(): 380e. メソッドと *note
          wsgi_file_wrapper: 381c. 属性を利用します。これは、キーが存在
          せず、 *note origin_server: 3819. 属性が true 値で *note
          server_software: 3818. 属性も設定されている場合に
          ‘SERVER_SOFTWARE’ を挿入します。

     例外処理のカスタマイズのためのメソッドと属性:

      -- メソッド: log_exception (exc_info)

          'exc_info' タプルをサーバログに記録します。'exc_info' は
          ‘(type, value, traceback)’ のタプルです。デフォルトの実装は単
          純にトレースバックをリクエストの ‘wsgi.errors’ ストリームに書
          き出してフラッシュします。サブクラスはこのメソッドをオーバーラ
          イドしてフォーマットを変更したり出力先の変更、トレースバックを
          管理者にメールしたりその他適切と思われるいかなるアクションも取
          ることができます。

      -- の属性: traceback_limit

          デフォルトの *note log_exception(): 381d. メソッドで出力される
          トレースバック出力に含まれる最大のフレーム数です。 ‘None’ なら
          ば、すべてのフレームが含まれます。

      -- メソッド: error_output (environ, start_response)

          このメソッドは、ユーザに対してエラーページを出力する WSGI アプ
          リケーションです。これはクライアントにヘッダが送出される前にエ
          ラーが発生した場合にのみ呼び出されます。

          このメソッドは ‘sys.exception()’ を使って現在のエラーにアクセ
          スでき、その情報はこれを呼ぶときに 'start_response' に渡すべき
          です ( PEP 3333(1) の "Error Handling" セクションに記述があり
          ます)。

          デフォルト実装は単に *note error_status: 3820. 、 *note
          error_headers: 3821. 、 *note error_body: 3822. 属性を出力ペー
          ジの生成に使います。サブクラスではこれをオーバーライドしてもっ
          と動的なエラー出力をすることができます。

          しかし、セキュリティの観点からは診断をあらゆるユーザに吐き出す
          ことは推奨されないことに気をつけてください; 理想的には、診断的
          な出力を有効にするには何らかの特別なことをする必要があるように
          すべきで、これがデフォルト実装では何も含まれていない理由です。

      -- の属性: error_status

          エラーレスポンスで使われる HTTP ステータスです。これは PEP
          3333(2) で定義されているステータス文字列です; デフォルトは 500
          コードとメッセージです。

      -- の属性: error_headers

          エラーレスポンスで使われる HTTP ヘッダです。これは PEP 3333(3)
          で述べられているような、 WSGI レスポンスヘッダ (‘(name,
          value)’ タプル) のリストであるべきです。デフォルトのリストはコ
          ンテントタイプを ‘text/plain’ にセットしているだけです。

      -- の属性: error_body

          エラーレスポンスボディ。これは HTTP レスポンスのボディバイト文
          字列であるべきです。これはデフォルトではプレーンテキストで "A
          server error occurred.  Please contact the administrator."  で
          す。

     PEP 3333(4) の "オプションのプラットフォーム固有のファイルハンドリ
     ング" 機能のためのメソッドと属性:

      -- の属性: wsgi_file_wrapper

          A ‘wsgi.file_wrapper’ factory, compatible with *note
          wsgiref.types.FileWrapper: 37f6, or ‘None’.  The default value
          of this attribute is the *note wsgiref.util.FileWrapper: 701.
          class.

      -- メソッド: sendfile ()

          オーバーライドしてプラットフォーム固有のファイル転送を実装しま
          す。このメソッドはアプリケーションの戻り値が *note
          wsgi_file_wrapper: 381c. 属性で指定されたクラスのインスタンス
          の場合にのみ呼ばれます。これはファイルの転送が成功できた場合に
          は true を返して、デフォルトの転送コードが実行されないようにす
          るべきです。このデフォルトの実装は単に false 値を返します。

     その他のメソッドと属性:

      -- の属性: origin_server

          この属性はハンドラの *note _write(): 380f. と *note _flush():
          3810. が、特別に ‘Status:’ ヘッダに HTTP ステータスを求めるよ
          うな CGI 風のゲートウェイプロトコル経由でなく、クライアントと
          直接通信をするような場合には true 値に設定されているべきです。

          この属性のデフォルト値は *note BaseHandler: 195b. では true で
          すが、 *note BaseCGIHandler: 3809. と *note CGIHandler: 3808.
          では false です。

      -- の属性: http_version

          *note origin_server: 3819. が true の場合、この文字列属性はク
          ライアントへのレスポンスセットの HTTP バージョンの設定に使われ
          ます。デフォルトは ‘"1.0"’ です。

 -- の関数: wsgiref.handlers.read_environ ()

     Transcode CGI variables from ‘os.environ’ to PEP 3333(5) "bytes in
     unicode" strings, returning a new dictionary.  This function is
     used by *note CGIHandler: 3808. and *note IISCGIHandler: 380a. in
     place of directly using ‘os.environ’, which is not necessarily
     WSGI-compliant on all platforms and web servers using Python 3 -
     specifically, ones where the OS's actual environment is Unicode
     (i.e.  Windows), or ones where the environment is bytes, but the
     system encoding used by Python to decode it is anything other than
     ISO-8859-1 (e.g.  Unix systems using UTF-8).

     If you are implementing a CGI-based handler of your own, you
     probably want to use this routine instead of just copying values
     out of ‘os.environ’ directly.

     Added in version 3.2.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3333/

   (2) https://peps.python.org/pep-3333/

   (3) https://peps.python.org/pep-3333/

   (4) https://peps.python.org/pep-3333/

   (5) https://peps.python.org/pep-3333/


File: python.info,  Node: wsgiref types -- WSGI types for static type checking,  Next: 使用例<35>,  Prev: wsgiref handlers -- サーバ／ゲートウェイのベースクラス,  Up: wsgiref --- WSGI ユーティリティとリファレンス実装

5.21.2.6 ‘wsgiref.types’ - WSGI types for static type checking
..............................................................

This module provides various types for static type checking as described
in PEP 3333(1).

Added in version 3.11.

 -- クラス: wsgiref.types.StartResponse

     A *note typing.Protocol: 245. describing start_response()(2)
     callables ( PEP 3333(3)).

 -- データ: wsgiref.types.WSGIEnvironment

     A type alias describing a WSGI environment dictionary.

 -- データ: wsgiref.types.WSGIApplication

     A type alias describing a WSGI application callable.

 -- クラス: wsgiref.types.InputStream

     A *note typing.Protocol: 245. describing a WSGI Input Stream(4).

 -- クラス: wsgiref.types.ErrorStream

     A *note typing.Protocol: 245. describing a WSGI Error Stream(5).

 -- クラス: wsgiref.types.FileWrapper

     A *note typing.Protocol: 245. describing a file wrapper(6).  See
     *note wsgiref.util.FileWrapper: 701. for a concrete implementation
     of this protocol.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3333/

   (2) https://peps.python.org/pep-3333/#the-start-response-callable

   (3) https://peps.python.org/pep-3333/

   (4) https://peps.python.org/pep-3333/#input-and-error-streams

   (5) https://peps.python.org/pep-3333/#input-and-error-streams

   (6) 
https://peps.python.org/pep-3333/#optional-platform-specific-file-handling


File: python.info,  Node: 使用例<35>,  Prev: wsgiref types -- WSGI types for static type checking,  Up: wsgiref --- WSGI ユーティリティとリファレンス実装

5.21.2.7 使用例
...............

これは動作する "Hello World" WSGIアプリケーションです:

     """
     Every WSGI application must have an application object - a callable
     object that accepts two arguments. For that purpose, we're going to
     use a function (note that you're not limited to a function, you can
     use a class for example). The first argument passed to the function
     is a dictionary containing CGI-style environment variables and the
     second variable is the callable object.
     """
     from wsgiref.simple_server import make_server


     def hello_world_app(environ, start_response):
         status = "200 OK"  # HTTP Status
         headers = [("Content-type", "text/plain; charset=utf-8")]  # HTTP Headers
         start_response(status, headers)

         # The returned object is going to be printed
         return [b"Hello World"]

     with make_server("", 8000, hello_world_app) as httpd:
         print("Serving on port 8000...")

         # Serve until process is killed
         httpd.serve_forever()

Example of a WSGI application serving the current directory, accept
optional directory and port number (default: 8000) on the command line:

     """
     Small wsgiref based web server. Takes a path to serve from and an
     optional port number (defaults to 8000), then tries to serve files.
     MIME types are guessed from the file names, 404 errors are raised
     if the file is not found.
     """
     import mimetypes
     import os
     import sys
     from wsgiref import simple_server, util


     def app(environ, respond):
         # Get the file name and MIME type
         fn = os.path.join(path, environ["PATH_INFO"][1:])
         if "." not in fn.split(os.path.sep)[-1]:
             fn = os.path.join(fn, "index.html")
         mime_type = mimetypes.guess_file_type(fn)[0]

         # Return 200 OK if file exists, otherwise 404 Not Found
         if os.path.exists(fn):
             respond("200 OK", [("Content-Type", mime_type)])
             return util.FileWrapper(open(fn, "rb"))
         else:
             respond("404 Not Found", [("Content-Type", "text/plain")])
             return [b"not found"]


     if __name__ == "__main__":
         # Get the path and port from command-line arguments
         path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd()
         port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000

         # Make and start the server until control-c
         httpd = simple_server.make_server("", port, app)
         print(f"Serving {path} on port {port}, control-C to stop")
         try:
             httpd.serve_forever()
         except KeyboardInterrupt:
             print("Shutting down.")
             httpd.server_close()


File: python.info,  Node: urllib --- URL を扱うモジュール群,  Next: urllib request --- URL を開くための大規模なライブラリ,  Prev: wsgiref --- WSGI ユーティリティとリファレンス実装,  Up: インターネットプロトコルとサポート

5.21.3 ‘urllib’ -- URL を扱うモジュール群
-----------------------------------------

'ソースコード:' Lib/urllib/(1)

__________________________________________________________________

‘urllib’ は URL を扱う幾つかのモジュールを集めたパッケージです:

   * *note urllib.request: f4. は URL を開いて読むためのモジュールです

   * *note urllib.error: f2. は *note urllib.request: f4. が発生させる例
     外を持っています

   * *note urllib.parse: f3. は URL をパースするためのモジュールです

   * *note urllib.robotparser: f6. は ‘robots.txt’ ファイルをパースする
     ためのモジュールです

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/urllib/


File: python.info,  Node: urllib request --- URL を開くための大規模なライブラリ,  Next: urllib response --- urllib で使用するレスポンスクラス,  Prev: urllib --- URL を扱うモジュール群,  Up: インターネットプロトコルとサポート

5.21.4 ‘urllib.request’ -- URL を開くための大規模なライブラリ
-------------------------------------------------------------

'ソースコード:' Lib/urllib/request.py(1)

__________________________________________________________________

*note urllib.request: f4. モジュールは基本的な認証、暗号化認証、リダイレ
クション、Cookie、その他の介在する複雑なアクセス環境において (大抵は
HTTP で) URL を開くための関数とクラスを定義します。

参考
....

より高水準のHTTPクライアントインターフェースとして Requestsパッケージ(2)
がお奨めです。

     警告: On macOS it is unsafe to use this module in programs using
     *note os.fork(): 17c. because the *note getproxies(): 382d.
     implementation for macOS uses a higher-level system API. Set the
     environment variable ‘no_proxy’ to ‘*’ to avoid this problem (e.g.
     ‘os.environ["no_proxy"] = "*"’).

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

*note urllib.request: f4. モジュールでは以下の関数を定義しています:

 -- の関数: urllib.request.urlopen (url, data=None[, timeout], *,
          context=None)

     Open 'url', which can be either a string containing a valid,
     properly encoded URL, or a *note Request: fa5. object.

     'data' はサーバーに送信する追加データを指定するオブジェクトであるか
     ‘None’ である必要があります。詳細は *note Request: fa5. を確認して
     ください。

     urllib.request モジュールは HTTP/1.1 を使用し、その HTTP リクエスト
     に ‘Connection:close’ ヘッダーを含みます。

     任意引数 'timeout' には接続開始などのブロックする操作におけるタイム
     アウト時間を秒数で指定します (指定されなかった場合、グローバルのデ
     フォルトタイムアウト時間が利用されます)。この引数は、 HTTP, HTTPS,
     FTP 接続でのみ有効です。

     'context' を指定する場合は、様々な SSL オプションを記述する *note
     ssl.SSLContext: 274. インスタンスでなければなりません。 詳細は
     *note HTTPSConnection: b0f. を参照してください。

     この関数は常にプロパティ 'url'、 'headers'、および 'status' を持ち
     、 *note コンテキストマネージャ: 59e. として動作するオブジェクトを
     返します。これらのプロパティに関する詳細は *note
     urllib.response.addinfourl: 382e. を確認してください。

     HTTP および HTTPS URL の場合、この関数は、わずかに修正された *note
     http.client.HTTPResponse: 10a1. オブジェクトを返します。上記の3つの
     新しいメソッドに加えて、 msg 属性が *note HTTPResponse: 10a1. のド
     キュメンテーションで指定されているレスポンスヘッダーの代わりに
     *note reason: 382f. 属性 -- サーバーから返された reason フレーズ --
     と同じ情報を含んでいます。

     FTP 、ファイルおよびデータ URL 、レガシーな *note URLopener: 2e6. や
     *note FancyURLopener: 2e7. によって明示的に扱われるリクエストの場合
     、この関数は *note urllib.response.addinfourl: 382e. オブジェクトを
     返します。

     プロトコルエラー発生時は *note URLError: 3830. を送出します。

     どのハンドラもリクエストを処理しなかった場合には ‘None’ を返すこと
     があるので注意してください (デフォルトでインストールされる グローバ
     ルハンドラの *note OpenerDirector: 3831. は、 *note UnknownHandler:
     3832. を使って上記の問題が起きないようにしています)。

     In addition, if proxy settings are detected (for example, when a
     ‘*_proxy’ environment variable like ‘http_proxy’ is set), *note
     ProxyHandler: 193b. is default installed and makes sure the
     requests are handled through the proxy.

     Python 2.6 以前のレガシーな ‘urllib.urlopen’ 関数は廃止されました。
     *note urllib.request.urlopen(): 273. が過去の ‘urllib2.urlopen’ に
     相当します。‘urllib.urlopen’ において辞書型オブジェクトで渡していた
     プロキシの扱いは、*note ProxyHandler: 193b. オブジェクトを使用して
     取得できます。

     The default opener raises an *note auditing event: 1825.
     ‘urllib.Request’ with arguments ‘fullurl’, ‘data’, ‘headers’,
     ‘method’ taken from the request object.

     バージョン 3.2 で変更: 'cafile' および 'capath' が追加されました。

     HTTPS virtual hosts are now supported if possible (that is, if
     *note ssl.HAS_SNI: 3325. is true).

     'data' にイテラブルなオブジェクトを指定できるようになりました。

     バージョン 3.3 で変更: 'cadefault' が追加されました。

     バージョン 3.4.3 で変更: 'context' が追加されました。

     バージョン 3.10 で変更: HTTPS connection now send an ALPN extension
     with protocol indicator ‘http/1.1’ when no 'context' is given.
     Custom 'context' should set ALPN protocols with *note
     set_alpn_protocols(): e2d.

     バージョン 3.13 で変更: Remove 'cafile', 'capath' and 'cadefault'
     parameters: use the 'context' parameter instead.

 -- の関数: urllib.request.install_opener (opener)

     指定された *note OpenerDirector: 3831. のインスタンスを、デフォルト
     で利用されるグローバルの opener としてインストールします。 opener の
     インストールは、 urlopen にその opener を使って欲しいとき以外必要あ
     りません。普段は単に *note urlopen(): 273. の代わりに *note
     OpenerDirector.open(): fa9. を利用してください。この関数は引数が本
     当に *note OpenerDirector: 3831. のインスタンスであるかどうかはチェ
     ックしません。適切なインターフェースを持った任意のクラスを利用する
     ことができます。

 -- の関数: urllib.request.build_opener ([handler, ...])

     与えられた順番に URL ハンドラを連鎖させる *note OpenerDirector:
     3831. のインスタンスを返します。 'handler' は *note BaseHandler:
     3835. または *note BaseHandler: 3835. のサブクラスのインスタンスの
     どちらかです (どちらの場合も、コンストラクトは引数無しで呼び出せる
     ようになっていなければなりません) 。クラス *note ProxyHandler:
     193b. (proxy 設定が検出された場合), *note UnknownHandler: 3832,
     *note HTTPHandler: 3836, *note HTTPDefaultErrorHandler: 3837, *note
     HTTPRedirectHandler: 3838, *note FTPHandler: 3839, *note
     FileHandler: 383a, *note HTTPErrorProcessor: 383b. については、その
     クラスのインスタンスか、そのサブクラスのインスタンスが 'handler' に
     含まれていない限り、 'handler' よりも先に連鎖します。

     Python が SSL をサポートするように設定してインストールされている場
     合 (すなわち、 *note ssl: bb. モジュールを import できる場合) *note
     HTTPSHandler: 11f5. も追加されます。

     *note BaseHandler: 3835. サブクラスでも ‘handler_order’ メンバー変
     数を変更して、ハンドラーリスト内での場所を変更できます。

 -- の関数: urllib.request.pathname2url (path)

     ローカルシステムにおける記法で表されたパス名 'path' をURL における
     パス部分の形式に変換します。これは完全な URL を生成するわけではあり
     ません。戻り値は *note quote(): b71. 関数によってクオートされていま
     す。

 -- の関数: urllib.request.url2pathname (path)

     URL の、パーセントエンコードされたパス部分 'path' をローカルシステ
     ムの記法に変換します。これは完全な URL を受け付けません。'path' の
     デコードには *note unquote(): 16f1. 関数を使用します。

 -- の関数: urllib.request.getproxies ()

     このヘルパー関数はスキーマからプロキシサーバーのURLへのマッピングを
     行う辞書を返します。この関数はまず、どのOSでも最初に
     ‘<scheme>_proxy’ という名前の環境変数を大文字小文字を区別せずにスキ
     ャンします。そこで見つからなかった場合、 macOS の場合は macOS シス
     テム環境設定を、 Windows の場合はシステムレジストリを参照します。も
     し小文字と大文字の環境変数が両方存在する (そして値が一致しない) な
     ら、小文字の環境変数が優先されます。

          注釈: もし環境変数 ‘REQUEST_METHOD’ が設定されていたら (これは
          通常スクリプトが CGI 環境で動いていることを示しています)、環境
          変数 ‘HTTP_PROXY’ (大文字の ‘_PROXY’) は無視されます。その理由
          は、クライアントが "Proxy:" HTTP ヘッダーを使ってこの環境変数
          を注入できるからです。もし CGI 環境で HTTP プロキシを使う必要
          があれば、 ‘ProxyHandler’ を明示的に使用するか、環境変数名を小
          文字にしてください (あるいは、少なくともサフィックスを
          ‘_proxy’ にしてください) 。

以下のクラスが提供されています:

 -- クラス: urllib.request.Request (url, data=None, headers={},
          origin_req_host=None, unverifiable=False, method=None)

     このクラスは URL リクエストを抽象化したものです。

     'url' should be a string containing a valid, properly encoded URL.

     'data' must be an object specifying additional data to send to the
     server, or ‘None’ if no such data is needed.  Currently HTTP
     requests are the only ones that use 'data'.  The supported object
     types include bytes, file-like objects, and iterables of bytes-like
     objects.  If no ‘Content-Length’ nor ‘Transfer-Encoding’ header
     field has been provided, *note HTTPHandler: 3836. will set these
     headers according to the type of 'data'.  ‘Content-Length’ will be
     used to send bytes objects, while ‘Transfer-Encoding: chunked’ as
     specified in RFC 7230(3), Section 3.3.1 will be used to send files
     and other iterables.

     HTTP POST リクエストメソッドでは 'data' は標準の
     ‘application/x-www-form-urlencoded’ 形式のバッファーでなければなり
     ません。 *note urllib.parse.urlencode(): e5e. 関数は、マップ型ある
     いは 2 タプルのシーケンスを取り、この形式の ASCII 文字列を返します
     。これは 'data' パラメーターとして使用される前に bytes 型にエンコー
     ドされなければなりません。

     'headers' は辞書でなければなりません。この辞書は *note
     add_header(): 383c. を辞書のキーおよび値を引数として呼び出した時と
     同じように扱われます。この引数は、多くの場合ブラウザーが何であるか
     を特定する ‘User-Agent’ ヘッダーの値を "偽装" するために用いられま
     す。これは一部の HTTP サーバーが、スクリプトからのアクセスを禁止す
     るために一般的なブラウザーの ‘User-Agent’ ヘッダーしか許可しないた
     めです。例えば、 Mozilla Firefox は ‘User-Agent’ に ‘"Mozilla/5.0
     (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"’ のように設定
     し、 *note urllib: f1. はデフォルトで ‘"Python-urllib/2.6"’ (Python
     2.6の場合) と設定します。headersのすべてのキーはキャメルケースで送
     信されます。

     An appropriate ‘Content-Type’ header should be included if the
     'data' argument is present.  If this header has not been provided
     and 'data' is not ‘None’, ‘Content-Type:
     application/x-www-form-urlencoded’ will be added as a default.

     次の2つの引数は、サードパーティの HTTP クッキーを正しく扱いたい場合
     にのみ関係してきます:

     'origin_req_host' は、 RFC 2965(4) で定義されている元のトランザクシ
     ョンにおけるリクエストホスト (request-host of the origin
     transaction) です。デフォルトの値は
     ‘http.cookiejar.request_host(self)’ です。この値は、ユーザーによっ
     て開始された元々のリクエストにおけるホスト名や IP アドレスです。例
     えば、もしリクエストがある HTML ドキュメント内の画像を指していれば
     、この値は画像を含んでいるページへのリクエストにおけるリクエストホ
     ストになるはずです。

     'unverifiable' は、 RFC 2965(5) の定義において、該当するリクエスト
     が証明不能 (unverifiable) であるかどうかを示します。デフォルトの値
     は ‘False’ です。証明不能なリクエストとは、ユーザが受け入れの可否を
     選択できないような URL を持つリクエストのことです。例えば、リクエス
     トが HTML ドキュメント中の画像であり、ユーザがこの画像を自動的に取
     得するか どうかを選択できない場合には、証明不能フラグは True になり
     ます。

     'method' should be a string that indicates the HTTP request method
     that will be used (e.g.  ‘'HEAD'’).  If provided, its value is
     stored in the *note method: fa6. attribute and is used by *note
     get_method(): 113c.  The default is ‘'GET'’ if 'data' is ‘None’ or
     ‘'POST'’ otherwise.  Subclasses may indicate a different default
     method by setting the *note method: fa6. attribute in the class
     itself.

          注釈: The request will not work as expected if the data object
          is unable to deliver its content more than once (e.g.  a file
          or an iterable that can produce the content only once) and the
          request is retried for HTTP redirects or authentication.  The
          'data' is sent to the HTTP server right away after the
          headers.  There is no support for a 100-continue expectation
          in the library.

     バージョン 3.3 で変更: 引数 *note Request.method: fa6. が Request ク
     ラスに追加されました。

     バージョン 3.4 で変更: *note Request.method: fa6. のデフォルト値は
     クラスレベルで指定されることがあります。

     バージョン 3.6 で変更: Do not raise an error if the
     ‘Content-Length’ has not been provided and 'data' is neither ‘None’
     nor a bytes object.  Fall back to use chunked transfer encoding
     instead.

 -- クラス: urllib.request.OpenerDirector

     *note OpenerDirector: 3831. クラスは、 *note BaseHandler: 3835. の
     連鎖的に呼び出して URL を開きます。このクラスはハンドラをどのように
     連鎖させるか、またどのようにエラーをリカバリするかを管理します。

 -- クラス: urllib.request.BaseHandler

     このクラスはハンドラ連鎖に登録される全てのハンドラがベースとしてい
     るクラスです - このクラスでは登録のための単純なメカニズムだけを扱い
     ます。

 -- クラス: urllib.request.HTTPDefaultErrorHandler

     HTTP エラーレスポンスのデフォルトハンドラーを定義するクラスです; す
     べてのレスポンスは *note HTTPError: fab. 例外に変換されます。

 -- クラス: urllib.request.HTTPRedirectHandler

     リダイレクションを扱うクラスです。

 -- クラス: urllib.request.HTTPCookieProcessor (cookiejar=None)

     HTTP Cookie を扱うためのクラスです。

 -- クラス: urllib.request.ProxyHandler (proxies=None)

     このクラスはプロキシを通過してリクエストを送らせます。引数
     'proxies' を与える場合、プロトコル名からプロキシの URL へ対応付ける
     辞書でなくてはなりません。標準では、プロキシのリストを環境変数
     ‘<protocol>_proxy’ から読み出します。プロキシ環境変数が設定されてい
     ない場合は、 Windows 環境では、 レジストリのインターネット設定セク
     ションからプロキシ設定を手に入れ、 macOS 環境では、 macOS システム
     設定フレームワーク (System Configuration Framework) からプロキシ情
     報を取得します。

     自動検出されたproxyを無効にするには、空の辞書を渡してください。

     ‘no_proxy’ 環境変数は、proxyを利用せずにアクセスするべきホストを指
     定するために利用されます。設定する場合は、カンマ区切りの、ホストネ
     ーム suffix のリストで、オプションとして ‘:port’ を付けることができ
     ます。例えば、 ‘cern.ch,ncsa.uiuc.edu,some.host:8080’.

          注釈: 変数 ‘REQUEST_METHOD’ が設定されている場合、
          ‘HTTP_PROXY’ は無視されます; *note getproxies(): 382d. のドキ
          ュメンテーションを参照してください。

 -- クラス: urllib.request.HTTPPasswordMgr

     ‘(realm, uri) -> (user, password)’ の対応付けデータベースを保持しま
     す。

 -- クラス: urllib.request.HTTPPasswordMgrWithDefaultRealm

     ‘(realm, uri) -> (user, password)’ の対応付けデータベースを保持しま
     す。レルム ‘None’ はその他諸々のレルムを表し、他のレルムが該当しな
     い場合に検索されます。

 -- クラス: urllib.request.HTTPPasswordMgrWithPriorAuth

     ‘uri -> is_authenticated’ マッピングのデータベースも持つ *note
     HTTPPasswordMgrWithDefaultRealm: 383f. のバリエーションです。最初に
     ‘401’ レスポンスを待つのではなく直ちに認証情報を送るときの条件を判
     断するために、 BasicAuth ハンドラによって使われます。

     Added in version 3.5.

 -- クラス: urllib.request.AbstractBasicAuthHandler (password_mgr=None)

     これは、リモートホストとプロキシの両方に対して HTTP 認証を行うこと
     を助ける mixin クラスです。 'password_mgr' は、もし与えられたら
     *note HTTPPasswordMgr: 383e. と互換性のあるオブジェクトでなければな
     りません; サポートすべきインターフェースに関する情報は *note
     HTTPPasswordMgr オブジェクト: 3840. 節を参照してください。もし
     'passwd_mgr' が ‘is_authenticated’ と ‘update_authenticated’ メソッ
     ドも提供するなら (*note HTTPPasswordMgrWithPriorAuth オブジェクト:
     3841. を参照)、ハンドラは与えられた URI に対する ‘is_authenticated’
     の結果を用いてリクエストにおいて認証情報を送るかどうかを決定します
     。もし ‘is_authenticated’ がその URI に対して ‘True’ を返すなら、認
     証情報が送られます。 ‘is_authenticated’ が ‘False’ なら認証情報は送
     られません。そして、もし ‘401’ レスポンスを受け取ったら、認証情報を
     付けて改めてリクエストが送信されます。もし認証が成功したら、それ以
     降その URI またはその親 URI に対して行われるリクエストが認証情報を
     自動的に含むように、 URI に対して ‘is_authenticated’ を ‘True’ に設
     定するために ‘update_authenticated’ が呼ばれます。

     Added in version 3.5: ‘is_authenticated’ サポートが追加されました。

 -- クラス: urllib.request.HTTPBasicAuthHandler (password_mgr=None)

     遠隔ホストとの間での認証を扱います。 'password_mgr' を与える場合、
     *note HTTPPasswordMgr: 383e. と互換性がなければなりません; 互換性の
     ためにサポートしなければならないインターフェースについての情報はセ
     クション *note HTTPPasswordMgr オブジェクト: 3840. を参照してくださ
     い。HTTPBasicAuthHandler は、間違った認証スキーマが与えられると
     *note ValueError: 1e3. を送出します。

 -- クラス: urllib.request.ProxyBasicAuthHandler (password_mgr=None)

     プロキシとの間での認証を扱います。 'password_mgr' を与える場合、
     *note HTTPPasswordMgr: 383e. と互換性が なければなりません; 互換性
     のためにサポートしなければならないインターフェースについての情報は
     セクション *note HTTPPasswordMgr オブジェクト: 3840. を参照してくだ
     さい。

 -- クラス: urllib.request.AbstractDigestAuthHandler (password_mgr=None)

     このクラスはHTTP 認証を補助するための混ぜ込みクラス (mixin class) で
     す。遠隔ホストとプロキシの両方に対応しています。 'password_mgr' を
     与える場合、 *note HTTPPasswordMgr: 383e. と互換性がなければなりま
     せん; 互換性のためにサポートしなければならないインターフェースにつ
     いての情報はセクション *note HTTPPasswordMgr オブジェクト: 3840. を
     参照してください。

 -- クラス: urllib.request.HTTPDigestAuthHandler (password_mgr=None)

     リモートホストとの認証を扱います。'password_mgr' を与える場合、
     *note HTTPPasswordMgr: 383e. と互換性のあるものでなければなりません
     。サポートしなければならないインターフェースについての情報は *note
     HTTPPasswordMgr オブジェクト: 3840. 節を参照してください。Digest 認
     証ハンドラーと Basic 認証ハンドラーの両方が追加された場合、常に
     Digest 認証を先に試みます。Digest 認証が 40x のレスポンスを再び返す
     と、Basic 認証ハンドラーに送信されます。このハンドラーメソッドは、
     Digest および Basic 以外の認証スキームが存在する場合は *note
     ValueError: 1e3. を送出します。

     バージョン 3.3 で変更: 未サポートの認証スキームでは *note
     ValueError: 1e3. を送出するようになりました。

 -- クラス: urllib.request.ProxyDigestAuthHandler (password_mgr=None)

     プロキシとの間での認証を扱います。 'password_mgr' を与える場合、
     *note HTTPPasswordMgr: 383e. と互換性が なければなりません; 互換性
     のためにサポートしなければならないインターフェースについての情報は
     セクション *note HTTPPasswordMgr オブジェクト: 3840. を参照してくだ
     さい。

 -- クラス: urllib.request.HTTPHandler

     HTTP の URL を開きます。

 -- クラス: urllib.request.HTTPSHandler (debuglevel=0, context=None,
          check_hostname=None)

     HTTPS で URL を開きます。'context' および 'check_hostname' は *note
     http.client.HTTPSConnection: b0f. のものと同じ意味です。

     バージョン 3.2 で変更: 'context' および 'check_hostname' が追加され
     ました。

 -- クラス: urllib.request.FileHandler

     ローカルファイルを開きます。

 -- クラス: urllib.request.DataHandler

     data URL を開きます。

     Added in version 3.4.

 -- クラス: urllib.request.FTPHandler

     FTP の URL を開きます。

 -- クラス: urllib.request.CacheFTPHandler

     FTP の URL を開きます。遅延を最小限にするために、開かれている FTP 接
     続に対するキャッシュを保持します。

 -- クラス: urllib.request.UnknownHandler

     その他諸々のためのクラスで、未知のプロトコルの URL を開きます。

 -- クラス: urllib.request.HTTPErrorProcessor

     HTTP エラー応答の処理をします。

* Menu:

* Request オブジェクト::
* OpenerDirector オブジェクト::
* BaseHandler オブジェクト::
* HTTPRedirectHandler オブジェクト::
* HTTPCookieProcessor オブジェクト::
* ProxyHandler オブジェクト::
* HTTPPasswordMgr オブジェクト::
* HTTPPasswordMgrWithPriorAuth オブジェクト::
* AbstractBasicAuthHandler オブジェクト::
* HTTPBasicAuthHandler オブジェクト::
* ProxyBasicAuthHandler オブジェクト::
* AbstractDigestAuthHandler オブジェクト::
* HTTPDigestAuthHandler オブジェクト::
* ProxyDigestAuthHandler オブジェクト::
* HTTPHandler オブジェクト::
* HTTPSHandler オブジェクト::
* FileHandler オブジェクト::
* DataHandler オブジェクト::
* FTPHandler オブジェクト::
* CacheFTPHandler オブジェクト::
* UnknownHandler オブジェクト::
* HTTPErrorProcessor オブジェクト::
* 使用例: 使用例<36>.
* レガシーインターフェース::
* urllib.request の制限事項: urllib request の制限事項.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/urllib/request.py

   (2) https://requests.readthedocs.io/en/master/

   (3) https://datatracker.ietf.org/doc/html/rfc7230.html

   (4) https://datatracker.ietf.org/doc/html/rfc2965.html

   (5) https://datatracker.ietf.org/doc/html/rfc2965.html


File: python.info,  Node: Request オブジェクト,  Next: OpenerDirector オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.1 Request オブジェクト
.............................

以下のメソッドは *note Request: fa5. の公開インターフェースについて説明
しています。これらはすべてサブクラスでオーバーライドできます。また、解析
したリクエストを調査するためにクライアントで使用するいくつかの属性も定義
します。

 -- の属性: Request.full_url

     コンストラクターに渡されたオリジナルの URL です。

     バージョン 3.4 で変更.

     Request.full_url は、 setter, getter, deleter を持つプロパティです
     。もし存在すれば、 *note full_url: fa7. はオリジナルのリクエスト
     URL フラグメント付きで返します。

 -- の属性: Request.type

     URI スキームです。

 -- の属性: Request.host

     URI オーソリティです。通常はホスト名ですが、コロンで区切られたポー
     ト番号が付随することもあります。

 -- の属性: Request.origin_req_host

     リクエストしたオリジナルのホスト名です。ポート番号はつきません。

 -- の属性: Request.selector

     URI パスです。*note Request: fa5. がプロキシを使用する場合、セレク
     ターはプロキシに渡される完全な URL になります。

 -- の属性: Request.data

     リクエストのエンティティボディか、指定されない場合は ‘None’ になり
     ます。

     バージョン 3.4 で変更: *note Request.data: fa8. の値が変更されると
     、もしそれ以前に "Content-Length" ヘッダーの値が設定または計算され
     ていたらヘッダーが削除されるようになりました。

 -- の属性: Request.unverifiable

     リクエストが RFC 2965(1) で定義された証明不能 (unverifiable) である
     かどうかを示す論理値です。

 -- の属性: Request.method

     HTTP リクエストで使うメソッドです。 デフォルト値は *note None: 641.
     で、このときは使うメソッドを *note get_method(): 113c. が通常の方法
     で決定するということになります。 この値を設定する (従って *note
     get_method(): 113c. のデフォルトの決定を上書きする) 方法は、 *note
     Request: fa5. サブクラスでのクラスレベルの設定処理でデフォルト値を
     提供するか、 *note Request: fa5. のコンストラクタの 'method' 引数へ
     値を渡すかです。

     Added in version 3.3.

     バージョン 3.4 で変更: サブクラスでデフォルト値が設定できるようにな
     りました; 以前はコンストラクタ引数からしか設定できませんでした。

 -- メソッド: Request.get_method ()

     HTTP リクエストメソッドを示す文字列を返します。*note
     Request.method: fa6. が ‘None’ でなければその値を返します。そうでな
     い場合、*note Request.data: fa8. が ‘None’ なら ‘'GET'’ を、そうで
     なければ ‘'POST'’ を返します。これは HTTP リクエストに対してのみ意
     味を持ちます。

     バージョン 3.3 で変更: get_method は *note Request.method: fa6. の
     値を参照するようになりました。

 -- メソッド: Request.add_header (key, val)

     リクエストに新たなヘッダーを追加します。ヘッダーは HTTP ハンドラ以
     外のハンドラでは無視されます。HTTP ハンドラでは、引数はサーバに送信
     される ヘッダーのリストに追加されます。同じ名前を持つヘッダを 2 つ
     以上持つことはできず、 'key' の衝突が生じた場合、後で追加したヘッダ
     ーが前に 追加したヘッダーを上書きします。現時点では、この機能は
     HTTP の機能を損ねることはありません。というのは、複数回呼び出したと
     きに意味を 持つようなヘッダーには、どれもただ一つのヘッダーを使って
     同じ機能を果たすための (ヘッダー特有の) 方法があるからです。このメ
     ソッドを使って追加されたヘッダーはリダイレクトされたリクエストにも
     追加されることに注意してください。

 -- メソッド: Request.add_unredirected_header (key, header)

     リダイレクトされたリクエストには追加されないヘッダーを追加します。

 -- メソッド: Request.has_header (header)

     インスタンスが名前つきヘッダーであるかどうかを (通常のヘッダーと非
     リダイレクトヘッダの両方を調べて) 返します。

 -- メソッド: Request.remove_header (header)

     リクエストインスタンス (の通常のヘッダーと非リダイレクトヘッダーの
     両方) から名前つきヘッダーを削除します。

     Added in version 3.4.

 -- メソッド: Request.get_full_url ()

     コンストラクタで与えられた URL を返します。

     バージョン 3.4 で変更.

     *note Request.full_url: fa7. を返します。

 -- メソッド: Request.set_proxy (host, type)

     リクエストがプロキシサーバを経由するように準備します。 'host' およ
     び 'type' はインスタンスのもとの設定と置き換えられ ます。インスタン
     スのセレクタはコンストラクタに与えたもともとの URL になります。

 -- メソッド: Request.get_header (header_name, default=None)

     指定されたヘッダーの値を返します。ヘッダーがない場合は、 'default'
     の値を返します。

 -- メソッド: Request.header_items ()

     リクエストヘッダーの値を、タプル (header_name, header_value) のリス
     トで返します。

バージョン 3.4 で変更: 3.3 から非推奨だった Request オブジェクトのメソッ
ド add_data, has_data, get_data, get_type, get_host, get_selector,
get_origin_req_host, is_unverifiable が削除されました。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2965.html


File: python.info,  Node: OpenerDirector オブジェクト,  Next: BaseHandler オブジェクト,  Prev: Request オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.2 OpenerDirector オブジェクト
....................................

*note OpenerDirector: 3831. インスタンスは以下のメソッドを持っています:

 -- メソッド: OpenerDirector.add_handler (handler)

     'handler' should be an instance of *note BaseHandler: 3835.  The
     following methods are searched, and added to the possible chains
     (note that HTTP errors are a special case).  Note that, in the
     following, 'protocol' should be replaced with the actual protocol
     to handle, for example ‘http_response()’ would be the HTTP protocol
     response handler.  Also 'type' should be replaced with the actual
     HTTP code, for example ‘http_error_404()’ would handle HTTP 404
     errors.

        * ‘<protocol>_open()’ -- signal that the handler knows how to
          open 'protocol' URLs.

          詳細は、 *note BaseHandler.<protocol>_open(): 3856. を参照して
          ください。

        * ‘http_error_<type>()’ -- signal that the handler knows how to
          handle HTTP errors with HTTP error code 'type'.

          詳細は、 *note BaseHandler.http_error_<nnn>(): 3857. を参照し
          てください。

        * ‘<protocol>_error()’ -- signal that the handler knows how to
          handle errors from (non-‘http’) 'protocol'.

        * ‘<protocol>_request()’ -- signal that the handler knows how to
          pre-process 'protocol' requests.

          詳細は、 *note BaseHandler.<protocol>_request(): 3858. を参照
          してください。

        * ‘<protocol>_response()’ -- signal that the handler knows how
          to post-process 'protocol' responses.

          詳細は、 *note BaseHandler.<protocol>_response(): 3859. を参照
          してください。

 -- メソッド: OpenerDirector.open (url, data=None[, timeout])

     与えられた 'url' (リクエストオブジェクトでも文字列でもかまいません)
     を開きます。オプションとして 'data' を与えることができます。 引数、
     戻り値、および送出される例外は *note urlopen(): 273. と同じです
     (*note urlopen(): 273. の場合、標準でインストールされている グロー
     バルな *note OpenerDirector: 3831. の *note open(): 4e5. メソッドを
     呼び出します) 。 オプションの 'timeout' 引数は、接続開始のようなブ
     ロックする処理におけるタイムアウト時間を 秒数で指定します。(指定し
     なかった場合は、グローバルのデフォルト設定が利用されます) タイムア
     ウト機能は、 HTTP, HTTPS, FTP 接続でのみ有効です。

 -- メソッド: OpenerDirector.error (proto, *args)

     Handle an error of the given protocol.  This will call the
     registered error handlers for the given protocol with the given
     arguments (which are protocol specific).  The HTTP protocol is a
     special case which uses the HTTP response code to determine the
     specific error handler; refer to the ‘http_error_<type>()’ methods
     of the handler classes.

     戻り値および送出される例外は *note urlopen(): 273. と同じものです。

OpenerDirector オブジェクトは、以下の 3 つのステージに分けて URL を開き
ます:

各ステージで OpenerDirector オブジェクトのメソッドがどのような順で呼び出
されるかは、ハンドラインスタンスの並び方で決まります。

  1. Every handler with a method named like ‘<protocol>_request()’ has
     that method called to pre-process the request.

  2. Handlers with a method named like ‘<protocol>_open()’ are called to
     handle the request.  This stage ends when a handler either returns
     a non-*note None: 641. value (ie.  a response), or raises an
     exception (usually *note URLError: 3830.).  Exceptions are allowed
     to propagate.

     In fact, the above algorithm is first tried for methods named *note
     default_open(): 385b.  If all such methods return *note None: 641,
     the algorithm is repeated for methods named like
     ‘<protocol>_open()’.  If all such methods return *note None: 641,
     the algorithm is repeated for methods named *note unknown_open():
     385c.

     これらのメソッドの実装には、親となる *note OpenerDirector: 3831. イ
     ンスタンスの ‘open()’ や ‘error()’ といったメソッド呼び出しが入る場
     合があるので注意してください。

  3. Every handler with a method named like ‘<protocol>_response()’ has
     that method called to post-process the response.


File: python.info,  Node: BaseHandler オブジェクト,  Next: HTTPRedirectHandler オブジェクト,  Prev: OpenerDirector オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.3 BaseHandler オブジェクト
.................................

*note BaseHandler: 3835. オブジェクトは直接的に役に立つ 2 つのメソッドと
、その他として派生クラスで使われることを想定したメソッドを 提供します。
以下は直接的に使うためのメソッドです:

 -- メソッド: BaseHandler.add_parent (director)

     親オブジェクトとして、 ‘director’ を追加します。

 -- メソッド: BaseHandler.close ()

     全ての親オブジェクトを削除します。

以下の属性およびメソッドは *note BaseHandler: 3835. から派生したクラスで
のみ使われます。

     注釈: The convention has been adopted that subclasses defining
     ‘<protocol>_request()’ or ‘<protocol>_response()’ methods are named
     ‘*Processor’; all others are named ‘*Handler’.

 -- の属性: BaseHandler.parent

     有効な *note OpenerDirector: 3831. です。この値は違うプロトコルを使
     って URL を開く場合やエラーを処理する際に使われます。

 -- メソッド: BaseHandler.default_open (req)

     このメソッドは *note BaseHandler: 3835. では定義されて 'いません' 。
     しかし、全ての URL をキャッチさせたいなら、サブクラスで定義する 必
     要があります。

     This method, if implemented, will be called by the parent *note
     OpenerDirector: 3831.  It should return a file-like object as
     described in the return value of the *note open(): fa9. method of
     *note OpenerDirector: 3831, or ‘None’.  It should raise *note
     URLError: 3830, unless a truly exceptional thing happens (for
     example, *note MemoryError: 1627. should not be mapped to *note
     URLError: 3830.).

     このメソッドはプロトコル固有のオープンメソッドが呼び出される前に呼
     び出されます。

 -- メソッド: BaseHandler.<protocol>_open(req)

     このメソッドは *note BaseHandler: 3835. では定義されて 'いません' 。
     しかしプロトコルの URL をキャッチしたいなら、サブクラスで定義する必
     要があります。

     This method, if defined, will be called by the parent *note
     OpenerDirector: 3831.  Return values should be the same as for
     *note default_open(): 385b.

 -- メソッド: BaseHandler.unknown_open (req)

     このメソッドは *note BaseHandler: 3835. では定義されて 'いません' 。
     しかし URL を開くための特定のハンドラが登録されていないような URL を
     キャッチしたいなら、サブクラスで定義する必要があります。

     このメソッドが定義されていた場合、 *note parent: 3861. *note
     OpenerDirector: 3831. から呼び出されます。戻り値は *note
     default_open(): 385b. と同じでなければなりません。

 -- メソッド: BaseHandler.http_error_default (req, fp, code, msg, hdrs)

     このメソッドは *note BaseHandler: 3835. では定義されて 'いません' 。
     しかしその他の処理されなかった HTTP エラーを処理する機能をもたせた
     いなら、サブクラスで定義する必要があります。このメソッドはエラーに
     遭遇した *note OpenerDirector: 3831. から自動的に呼び出されます。そ
     の他の状況では普通呼び出すべきではありません。

     'req' は *note Request: fa5. オブジェクトで、 'fp' は HTTP エラー本
     体を読み出せるようなファイル類似のオブジェクトに なります。 'code'
     は 3 桁の 10 進数からなるエラーコードで、 'msg' ユーザ向けのエラー
     コード解説です。 'hdrs' は エラー応答のヘッダーをマップしたオブジェ
     クトです。

     返される値および送出される例外は *note urlopen(): 273. と同じもので
     なければなりません。

 -- メソッド: BaseHandler.http_error_<nnn>(req, fp, code, msg, hdrs)

     'nnn' は 3 桁の 10 進数からなる HTTP エラーコードでなくてはなりませ
     ん。このメソッドも *note BaseHandler: 3835. では定義されていません
     が、サブクラスのインスタンスで定義されていた場合、エラーコード
     'nnn' の HTTP エラーが発生した際に呼び出されます。

     特定の HTTP エラーに対する処理を行うためには、このメソッドをサブク
     ラスでオーバライドする必要があります。

     Arguments, return values and exceptions raised should be the same
     as for *note http_error_default(): 3862.

 -- メソッド: BaseHandler.<protocol>_request(req)

     このメソッドは *note BaseHandler: 3835. では '定義されていません' が
     、サブクラスで特定のプロトコルのリクエストのプリプロセスを行いたい
     場合には定義する必要があります。

     このメソッドが定義されていると、親となる *note OpenerDirector:
     3831. から呼び出されます。その際、 'req' は *note Request: fa5. オ
     ブジェクトになります。戻り値は *note Request: fa5. オブジェクトでな
     ければなりません。

 -- メソッド: BaseHandler.<protocol>_response(req, response)

     このメソッドは *note BaseHandler: 3835. では '定義されていません' が
     、サブクラスで特定のプロトコルのリクエストのポストプロセスを行いた
     い場合には定義する必要があります。

     このメソッドが定義されていると、親となる *note OpenerDirector:
     3831. から呼び出されます。その際、 'req' は *note Request: fa5. オ
     ブジェクトになります。 'response' は *note urlopen(): 273. の戻り値
     と同じインターフェースを 実装したオブジェクトになります。戻り値もま
     た、 *note urlopen(): 273. の戻り値と同じインターフェースを実装した
     オブジェクトでなければなりません。


File: python.info,  Node: HTTPRedirectHandler オブジェクト,  Next: HTTPCookieProcessor オブジェクト,  Prev: BaseHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.4 HTTPRedirectHandler オブジェクト
.........................................

     注釈: 一部の HTTP リクエストはこのモジュールのクライアントモードか
     らの操作を要求します。その場合、*note HTTPError: fab. が送出されま
     す。さまざまなリダイレクションコードの正確な意味についての詳細は
     RFC 2616(1) を参照してください。

     An *note HTTPError: fab. exception raised as a security
     consideration if the HTTPRedirectHandler is presented with a
     redirected URL which is not an HTTP, HTTPS or FTP URL.

 -- メソッド: HTTPRedirectHandler.redirect_request (req, fp, code, msg,
          hdrs, newurl)

     Return a *note Request: fa5. or ‘None’ in response to a redirect.
     This is called by the default implementations of the
     ‘http_error_30*()’ methods when a redirection is received from the
     server.  If a redirection should take place, return a new *note
     Request: fa5. to allow ‘http_error_30*()’ to perform the redirect
     to 'newurl'.  Otherwise, raise *note HTTPError: fab. if no other
     handler should try to handle this URL, or return ‘None’ if you
     can't but another handler might.

          注釈: このメソッドのデフォルトの実装は、 RFC 2616(2) に厳密に
          従ったものではありません。 RFC 2616(3) では、 ‘POST’ リクエス
          トに対する 301 および 302 応答が、ユーザの承認なく自動的にリダ
          イレクトされてはならないと述べています。現実には、ブラウザは
          POST を ‘GET’ に変更することで、これらの応答に対して自動的にリ
          ダイレクトを行えるようにしています。デフォルトの実装でも、この
          挙動を再現しています。

 -- メソッド: HTTPRedirectHandler.http_error_301 (req, fp, code, msg,
          hdrs)

     ‘Location:’ か ‘URI:’ のURL にリダイレクトします。このメソッドは
     HTTP における 'moved permanently' レスポンスを取得した際に 親オブジ
     ェクトとなる *note OpenerDirector: 3831. によって呼び出されます。

 -- メソッド: HTTPRedirectHandler.http_error_302 (req, fp, code, msg,
          hdrs)

     *note http_error_301(): 3866. と同じですが、'found' レスポンスに対
     して呼び出されます。

 -- メソッド: HTTPRedirectHandler.http_error_303 (req, fp, code, msg,
          hdrs)

     *note http_error_301(): 3866. と同じですが、'see other' レスポンス
     に対して呼び出されます。

 -- メソッド: HTTPRedirectHandler.http_error_307 (req, fp, code, msg,
          hdrs)

     The same as *note http_error_301(): 3866, but called for the
     'temporary redirect' response.  It does not allow changing the
     request method from ‘POST’ to ‘GET’.

 -- メソッド: HTTPRedirectHandler.http_error_308 (req, fp, code, msg,
          hdrs)

     The same as *note http_error_301(): 3866, but called for the
     'permanent redirect' response.  It does not allow changing the
     request method from ‘POST’ to ‘GET’.

     Added in version 3.11.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2616.html

   (2) https://datatracker.ietf.org/doc/html/rfc2616.html

   (3) https://datatracker.ietf.org/doc/html/rfc2616.html


File: python.info,  Node: HTTPCookieProcessor オブジェクト,  Next: ProxyHandler オブジェクト,  Prev: HTTPRedirectHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.5 HTTPCookieProcessor オブジェクト
.........................................

*note HTTPCookieProcessor: 383d. インスタンスは属性をひとつだけ持ちます:

 -- の属性: HTTPCookieProcessor.cookiejar

     Cookie の入っている *note http.cookiejar.CookieJar: 386e. オブジェ
     クトです。


File: python.info,  Node: ProxyHandler オブジェクト,  Next: HTTPPasswordMgr オブジェクト,  Prev: HTTPCookieProcessor オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.6 ProxyHandler オブジェクト
..................................

 -- メソッド: ProxyHandler.<protocol>_open(request)

     The *note ProxyHandler: 193b. will have a method
     ‘<protocol>_open()’ for every 'protocol' which has a proxy in the
     'proxies' dictionary given in the constructor.  The method will
     modify requests to go through the proxy, by calling
     ‘request.set_proxy()’, and call the next handler in the chain to
     actually execute the protocol.


File: python.info,  Node: HTTPPasswordMgr オブジェクト,  Next: HTTPPasswordMgrWithPriorAuth オブジェクト,  Prev: ProxyHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.7 HTTPPasswordMgr オブジェクト
.....................................

以下のメソッドは *note HTTPPasswordMgr: 383e. および *note
HTTPPasswordMgrWithDefaultRealm: 383f. オブジェクトで利用できます。

 -- メソッド: HTTPPasswordMgr.add_password (realm, uri, user, passwd)

     'uri' は単一の URI でも複数の URI からなるシーケンスでもかまいませ
     ん。 'realm' 、 'user' および 'passwd' は文字列でなくてはなりません
     。このメソッドによって、 'realm' と与えられた URI の上位 URI に対し
     て ‘(user, passwd)’ が認証トークンとして使われるようになります。

 -- メソッド: HTTPPasswordMgr.find_user_password (realm, authuri)

     与えられたレルムおよび URI に対するユーザ名またはパスワードがあれば
     それを取得します。該当するユーザ名／パスワードが存在しない場合、こ
     のメソッドは ‘(None, None)’ を返します。

     *note HTTPPasswordMgrWithDefaultRealm: 383f. オブジェクトでは、与え
     られた 'realm' に対して該当するユーザ名/パスワードが存在しない場合
     、レルム ‘None’ が検索されます。


File: python.info,  Node: HTTPPasswordMgrWithPriorAuth オブジェクト,  Next: AbstractBasicAuthHandler オブジェクト,  Prev: HTTPPasswordMgr オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.8 HTTPPasswordMgrWithPriorAuth オブジェクト
..................................................

このパスワードマネージャは *note HTTPPasswordMgrWithDefaultRealm: 383f.
を継承して、認証の証明書を常に送らないといけない URI を追跡する機能をサ
ポートしています。

 -- メソッド: HTTPPasswordMgrWithPriorAuth.add_password (realm, uri,
          user, passwd, is_authenticated=False)

     'realm', 'uri', 'user', 'passwd' は *note
     HTTPPasswordMgr.add_password(): 3872. のものと同じです。
     'is_authenticated' は、与えられた URI や URI のリストの
     ‘is_authenticated’ フラグの初期値に設定されます。
     'is_authenticated' に ‘True’ を指定した場合は、 'realm' は無視され
     ます。

 -- メソッド: HTTPPasswordMgrWithPriorAuth.find_user_password (realm,
          authuri)

     *note HTTPPasswordMgrWithDefaultRealm: 383f. オブジェクトに対する同
     名のメソッドと同じです。

 -- メソッド: HTTPPasswordMgrWithPriorAuth.update_authenticated (self,
          uri, is_authenticated=False)

     与えられた 'url' や URI のリストの ‘is_authenticated’ フラグを更新
     します。

 -- メソッド: HTTPPasswordMgrWithPriorAuth.is_authenticated (self,
          authuri)

     与えられた URI の ‘is_authenticated’ フラグの現在の状態を返します。


File: python.info,  Node: AbstractBasicAuthHandler オブジェクト,  Next: HTTPBasicAuthHandler オブジェクト,  Prev: HTTPPasswordMgrWithPriorAuth オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.9 AbstractBasicAuthHandler オブジェクト
..............................................

 -- メソッド: AbstractBasicAuthHandler.http_error_auth_reqed (authreq,
          host, req, headers)

     ユーザ名／パスワードを取得し、再度サーバへのリクエストを試みること
     で、サーバからの認証リクエストを処理します。 'authreq' はリクエスト
     において レルムに関する情報が含まれているヘッダーの名前、 'host' は
     認証を行う対象の URL とパスを指定します、 'req' は (失敗した) *note
     Request: fa5. オブジェクト、そして 'headers' はエラーヘッダーでなく
     てはなりません。

     'host' は、オーソリティ (例 ‘"python.org"’) か、オーソリティコンポ
     ーネントを含む URL (例 ‘"http://python.org"’) です。どちらの場合も
     、オーソリティはユーザ情報コンポーネントを含んではいけません (なの
     で、 ‘"python.org"’ や ‘"python.org:80"’ は正しく、
     ‘"joe:password@python.org"’ は不正です) 。


File: python.info,  Node: HTTPBasicAuthHandler オブジェクト,  Next: ProxyBasicAuthHandler オブジェクト,  Prev: AbstractBasicAuthHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.10 HTTPBasicAuthHandler オブジェクト
...........................................

 -- メソッド: HTTPBasicAuthHandler.http_error_401 (req, fp, code, msg,
          hdrs)

     認証情報がある場合、認証情報付きで再度リクエストを試みます。


File: python.info,  Node: ProxyBasicAuthHandler オブジェクト,  Next: AbstractDigestAuthHandler オブジェクト,  Prev: HTTPBasicAuthHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.11 ProxyBasicAuthHandler オブジェクト
............................................

 -- メソッド: ProxyBasicAuthHandler.http_error_407 (req, fp, code, msg,
          hdrs)

     認証情報がある場合、認証情報付きで再度リクエストを試みます。


File: python.info,  Node: AbstractDigestAuthHandler オブジェクト,  Next: HTTPDigestAuthHandler オブジェクト,  Prev: ProxyBasicAuthHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.12 AbstractDigestAuthHandler オブジェクト
................................................

 -- メソッド: AbstractDigestAuthHandler.http_error_auth_reqed (authreq,
          host, req, headers)

     'authreq' はリクエストにおいてレルムに関する情報が含まれているヘッ
     ダーの名前、 'host' は認証を行う対象のホスト名、 'req' は (失敗した
     ) *note Request: fa5. オブジェクト、そして 'headers' はエラーヘッダ
     ーでなくてはなりません。


File: python.info,  Node: HTTPDigestAuthHandler オブジェクト,  Next: ProxyDigestAuthHandler オブジェクト,  Prev: AbstractDigestAuthHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.13 HTTPDigestAuthHandler オブジェクト
............................................

 -- メソッド: HTTPDigestAuthHandler.http_error_401 (req, fp, code, msg,
          hdrs)

     認証情報がある場合、認証情報付きで再度リクエストを試みます。


File: python.info,  Node: ProxyDigestAuthHandler オブジェクト,  Next: HTTPHandler オブジェクト,  Prev: HTTPDigestAuthHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.14 ProxyDigestAuthHandler オブジェクト
.............................................

 -- メソッド: ProxyDigestAuthHandler.http_error_407 (req, fp, code, msg,
          hdrs)

     認証情報がある場合、認証情報付きで再度リクエストを試みます。


File: python.info,  Node: HTTPHandler オブジェクト,  Next: HTTPSHandler オブジェクト,  Prev: ProxyDigestAuthHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.15 HTTPHandler オブジェクト
..................................

 -- メソッド: HTTPHandler.http_open (req)

     HTTP リクエストを送ります。 ‘req.has_data()’ に応じて、 GET または
     POST のどちらでも送ることができます。


File: python.info,  Node: HTTPSHandler オブジェクト,  Next: FileHandler オブジェクト,  Prev: HTTPHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.16 HTTPSHandler オブジェクト
...................................

 -- メソッド: HTTPSHandler.https_open (req)

     HTTPS リクエストを送ります。 ‘req.has_data()’ に応じて、 GET または
     POST のどちらでも送ることができます。


File: python.info,  Node: FileHandler オブジェクト,  Next: DataHandler オブジェクト,  Prev: HTTPSHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.17 FileHandler オブジェクト
..................................

 -- メソッド: FileHandler.file_open (req)

     ホスト名がない場合、またはホスト名が ‘'localhost'’ の場合にファイル
     をローカルでオープンします。

     バージョン 3.2 で変更: This method is applicable only for local
     hostnames.  When a remote hostname is given, a *note URLError:
     3830. is raised.


File: python.info,  Node: DataHandler オブジェクト,  Next: FTPHandler オブジェクト,  Prev: FileHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.18 DataHandler オブジェクト
..................................

 -- メソッド: DataHandler.data_open (req)

     Read a data URL. This kind of URL contains the content encoded in
     the URL itself.  The data URL syntax is specified in RFC 2397(1).
     This implementation ignores white spaces in base64 encoded data
     URLs so the URL may be wrapped in whatever source file it comes
     from.  But even though some browsers don't mind about a missing
     padding at the end of a base64 encoded data URL, this
     implementation will raise a *note ValueError: 1e3. in that case.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2397.html


File: python.info,  Node: FTPHandler オブジェクト,  Next: CacheFTPHandler オブジェクト,  Prev: DataHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.19 FTPHandler オブジェクト
.................................

 -- メソッド: FTPHandler.ftp_open (req)

     'req' で表されるファイルを FTP 越しにオープンします。ログインは常に
     空のユーザネームおよびパスワードで行われます。


File: python.info,  Node: CacheFTPHandler オブジェクト,  Next: UnknownHandler オブジェクト,  Prev: FTPHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.20 CacheFTPHandler オブジェクト
......................................

*note CacheFTPHandler: 168f. オブジェクトは *note FTPHandler: 3839. オブ
ジェクトに以下のメソッドを追加したものです:

 -- メソッド: CacheFTPHandler.setTimeout (t)

     接続のタイムアウトを 't' 秒に設定します。

 -- メソッド: CacheFTPHandler.setMaxConns (m)

     キャッシュ付き接続の最大接続数を 'm' に設定します。


File: python.info,  Node: UnknownHandler オブジェクト,  Next: HTTPErrorProcessor オブジェクト,  Prev: CacheFTPHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.21 UnknownHandler オブジェクト
.....................................

 -- メソッド: UnknownHandler.unknown_open ()

     *note URLError: 3830. 例外を送出します。


File: python.info,  Node: HTTPErrorProcessor オブジェクト,  Next: 使用例<36>,  Prev: UnknownHandler オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.22 HTTPErrorProcessor オブジェクト
.........................................

 -- メソッド: HTTPErrorProcessor.http_response (request, response)

     HTTP エラー応答の処理をします。

     エラーコード 200 の場合、レスポンスオブジェクトを即座に返します。

     For non-200 error codes, this simply passes the job on to the
     ‘http_error_<type>()’ handler methods, via *note
     OpenerDirector.error(): 385a.  Eventually, *note
     HTTPDefaultErrorHandler: 3837. will raise an *note HTTPError: fab.
     if no other handler handles the error.

 -- メソッド: HTTPErrorProcessor.https_response (request, response)

     HTTPS エラー応答の処理をします。

     振る舞いは *note http_response(): 38a1. と同じです。


File: python.info,  Node: 使用例<36>,  Next: レガシーインターフェース,  Prev: HTTPErrorProcessor オブジェクト,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.23 使用例
................

以下の例の他に *note urllib
パッケージを使ってインターネット上のリソースを取得するには: 38a5. に多く
の例があります。

以下の例では、python.org のメインページを取得して、その最初の 300 バイト
分を表示します。

     >>> import urllib.request
     >>> with urllib.request.urlopen('http://www.python.org/') as f:
     ...     print(f.read(300))
     ...
     b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n\n<html
     xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n\n<head>\n
     <meta http-equiv="content-type" content="text/html; charset=utf-8" />\n
     <title>Python Programming '

urlopen は bytes オブジェクトを返すことに注意してください。これは
urlopen が、HTTP サーバーから受信したバイトストリームのエンコーディング
を自動的に決定できないためです。一般に、返された bytes オブジェクトを文
字列にデコードするためのエンコーディングの決定あるいは推測はプログラム側
が行います。

以下の W3C ドキュメント ‘https://www.w3.org/International/O-charset’には
(X)HTML や XML ドキュメントでそのエンコーディング情報を指定するさまざま
な方法の一覧があります。

python.org ウェブサイトでは 'utf-8' エンコーディングを使用しており、それ
をその meta タグで指定していますので、bytes オブジェクトのデコードも同様
に行います。

     >>> with urllib.request.urlopen('http://www.python.org/') as f:
     ...     print(f.read(100).decode('utf-8'))
     ...
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtm

*note コンテキストマネージャー: 59e. を使用しないアプローチでも同様の結
果を得ることができます。

     >>> import urllib.request
     >>> f = urllib.request.urlopen('http://www.python.org/')
     >>> print(f.read(100).decode('utf-8'))
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtm

以下の例では、データストリームを CGI の標準入力へ送信し、返されたデータ
を読み込みます。この例は Python が SSL をサポートするように設定してイン
ストールされている場合のみ動作します。

     >>> import urllib.request
     >>> req = urllib.request.Request(url='https://localhost/cgi-bin/test.cgi',
     ...                       data=b'This data is passed to stdin of the CGI')
     >>> with urllib.request.urlopen(req) as f:
     ...     print(f.read().decode('utf-8'))
     ...
     Got Data: "This data is passed to stdin of the CGI"

上の例で使われているサンプルの CGI は以下のようになっています:

     #!/usr/bin/env python
     import sys
     data = sys.stdin.read()
     print('Content-type: text/plain\n\nGot Data: "%s"' % data)

これは *note Request: fa5. を使った ‘PUT’ リクエストの例です:

     import urllib.request
     DATA = b'some data'
     req = urllib.request.Request(url='http://localhost:8080', data=DATA, method='PUT')
     with urllib.request.urlopen(req) as f:
         pass
     print(f.status)
     print(f.reason)

以下はベーシック HTTP 認証の例です:

     import urllib.request
     # Create an OpenerDirector with support for Basic HTTP Authentication...
     auth_handler = urllib.request.HTTPBasicAuthHandler()
     auth_handler.add_password(realm='PDQ Application',
                               uri='https://mahler:8092/site-updates.py',
                               user='klem',
                               passwd='kadidd!ehopper')
     opener = urllib.request.build_opener(auth_handler)
     # ...and install it globally so it can be used with urlopen.
     urllib.request.install_opener(opener)
     urllib.request.urlopen('http://www.example.com/login.html')

*note build_opener(): 3834. provides many handlers by default, including
a *note ProxyHandler: 193b.  By default, *note ProxyHandler: 193b. uses
the environment variables named ‘<scheme>_proxy’, where ‘<scheme>’ is
the URL scheme involved.  For example, the ‘http_proxy’ environment
variable is read to obtain the HTTP proxy's URL.

この例では、デフォルトの *note ProxyHandler: 193b. を置き換えてプログラ
ム的に作成したプロキシ URL を使うようにし、 *note ProxyBasicAuthHandler:
3843. でプロキシ認証サポートを追加します。

     proxy_handler = urllib.request.ProxyHandler({'http': 'http://www.example.com:3128/'})
     proxy_auth_handler = urllib.request.ProxyBasicAuthHandler()
     proxy_auth_handler.add_password('realm', 'host', 'username', 'password')

     opener = urllib.request.build_opener(proxy_handler, proxy_auth_handler)
     # This time, rather than install the OpenerDirector, we use it directly:
     opener.open('http://www.example.com/login.html')

以下は HTTP ヘッダーを追加する例です:

'headers' 引数を使って *note Request: fa5. コンストラクタを呼び出す方法
の他に、以下のようにできます:

     import urllib.request
     req = urllib.request.Request('http://www.example.com/')
     req.add_header('Referer', 'http://www.python.org/')
     # Customize the default User-Agent header value:
     req.add_header('User-Agent', 'urllib-example/0.1 (Contact: . . .)')
     r = urllib.request.urlopen(req)

*note OpenerDirector: 3831. は全ての *note Request: fa5. に ‘User-Agent’
ヘッダーを自動的に追加します。これを変更するには以下のようにします:

     import urllib.request
     opener = urllib.request.build_opener()
     opener.addheaders = [('User-agent', 'Mozilla/5.0')]
     opener.open('http://www.example.com/')

また、 *note Request: fa5. が *note urlopen(): 273. (や *note
OpenerDirector.open(): fa9.)に渡される際には、いくつかの標準ヘッダー
(‘Content-Length’, ‘Content-Type’ および ‘Host’) も追加されることを忘れ
ないでください。 以下は ‘GET’ メソッドを使ってパラメータを含む URL を取
得するセッションの例です:

     >>> import urllib.request
     >>> import urllib.parse
     >>> params = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
     >>> url = "http://www.musi-cal.com/cgi-bin/query?%s" % params
     >>> with urllib.request.urlopen(url) as f:
     ...     print(f.read().decode('utf-8'))
     ...

以下の例では、‘POST’ メソッドを使用しています。urlencode から出力された
パラメーターは urlopen にデータとして渡される前に bytes にエンコードされ
ていることに注意してください:

     >>> import urllib.request
     >>> import urllib.parse
     >>> data = urllib.parse.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
     >>> data = data.encode('ascii')
     >>> with urllib.request.urlopen("http://requestb.in/xrbl82xr", data) as f:
     ...     print(f.read().decode('utf-8'))
     ...

以下の例では、環境変数による設定内容に対して上書きする形で HTTP プロキシ
を明示的に設定しています:

     >>> import urllib.request
     >>> proxies = {'http': 'http://proxy.example.com:8080/'}
     >>> opener = urllib.request.FancyURLopener(proxies)
     >>> with opener.open("http://www.python.org") as f:
     ...     f.read().decode('utf-8')
     ...

以下の例では、環境変数による設定内容に対して上書きする形で、まったくプロ
キシを使わないよう設定しています:

     >>> import urllib.request
     >>> opener = urllib.request.FancyURLopener({})
     >>> with opener.open("http://www.python.org/") as f:
     ...     f.read().decode('utf-8')
     ...


File: python.info,  Node: レガシーインターフェース,  Next: urllib request の制限事項,  Prev: 使用例<36>,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.24 レガシーインターフェース
..................................

以下の関数およびクラスは、Python 2 のモジュール ‘urllib’ (‘urllib2’ では
ありません) から移植されたものです。これらは将来的に廃止されるかもしれま
せん。

 -- の関数: urllib.request.urlretrieve (url, filename=None,
          reporthook=None, data=None)

     Copy a network object denoted by a URL to a local file.  If the URL
     points to a local file, the object will not be copied unless
     filename is supplied.  Return a tuple ‘(filename, headers)’ where
     'filename' is the local file name under which the object can be
     found, and 'headers' is whatever the ‘info()’ method of the object
     returned by *note urlopen(): 273. returned (for a remote object).
     Exceptions are the same as for *note urlopen(): 273.

     The second argument, if present, specifies the file location to
     copy to (if absent, the location will be a tempfile with a
     generated name).  The third argument, if present, is a callable
     that will be called once on establishment of the network connection
     and once after each block read thereafter.  The callable will be
     passed three arguments; a count of blocks transferred so far, a
     block size in bytes, and the total size of the file.  The third
     argument may be ‘-1’ on older FTP servers which do not return a
     file size in response to a retrieval request.

     以下は最も一般的な使用例です:

          >>> import urllib.request
          >>> local_filename, headers = urllib.request.urlretrieve('http://python.org/')
          >>> html = open(local_filename)
          >>> html.close()

     'url' が ‘http:’ スキーム識別子を使用していた場合、任意の引数
     'data' は ‘POST’ リクエストの指定に使用される場合があります (通常の
     リクエストタイプは ‘GET’ です)。引数 'data' は標準
     ‘application/x-www-form-urlencoded’ 形式のバイトオブジェクトでなけ
     ればなりません。 *note urllib.parse.urlencode(): e5e. 関数を参照し
     てください。

     *note urlretrieve(): 38a8. will raise *note ContentTooShortError:
     38a9. when it detects that the amount of data available was less
     than the expected amount (which is the size reported by a
     'Content-Length' header).  This can occur, for example, when the
     download is interrupted.

     'Content-Length' はデータ量の下限です: 読み込むデータ量がこれを超え
     ている場合 urlretrieve はそれらも読み込みますが、利用できるデータが
     これを下回った場合、例外が送出されます。

     You can still retrieve the downloaded data in this case, it is
     stored in the ‘content’ attribute of the exception instance.

     'Content-Length' ヘッダーが与えられなれけば urlretrieve はダウンロ
     ードしたデータのサイズをチェックできません。この場合ダウンロードは
     正常に完了したとみなすしかありません。

 -- の関数: urllib.request.urlcleanup ()

     以前の *note urlretrieve(): 38a8. 呼び出し後に残っているかもしれな
     い一時ファイルをクリーンアップします。

 -- クラス: urllib.request.URLopener (proxies=None, **x509)

     バージョン 3.3 で非推奨.

     URL をオープンし、読み出すためのクラスの基底クラスです。‘http:’,
     ‘ftp:’, ‘file:’ 以外のスキームを使ったオブジェクトのオープンをサポ
     ートしたいのでないかぎり、*note FancyURLopener: 2e7. を使おうと思う
     ことになるでしょう。

     デフォルトでは、 *note URLopener: 2e6. クラスは ‘User-Agent’ ヘッダ
     ーとして ‘urllib/VVV’ を送信します。ここで 'VVV' は *note urllib:
     f1. のバージョン番号です。アプリケーションで独自の ‘User-Agent’ ヘ
     ッダーを送信したい場合は、 *note URLopener: 2e6. かまたは *note
     FancyURLopener: 2e7. のサブクラスを作成し、サブクラス定義においてク
     ラス属性 *note version: 38aa. を適切な文字列値に設定することで行う
     ことができます。

     オプションのパラメーター 'proxies' はスキーム名をプロキシの URL に
     マップする辞書でなければなりません。空の辞書はプロキシ機能を完全に
     オフにします。デフォルトの値は ‘None’ で、この場合、 *note
     urlopen(): 273. の定義で述べたように、プロキシを設定する環境変数が
     存在するならそれを使います。

     追加のキーワードパラメーターは 'x509' に集められますが、これは
     ‘https:’ スキームを使った際のクライアント認証に使われることがありま
     す。キーワード引数 'key_file' および 'cert_file' が SSL 鍵と証明書
     を設定するためにサポートされています; クライアント認証をするには両
     方が必要です。

     *note URLopener: 2e6. オブジェクトはサーバーがエラーコードを返した
     場合に *note OSError: 3f0. 例外を送出します。

      -- メソッド: open (fullurl, data=None)

          適切なプロトコルを使って 'fullurl' を開きます。このメソッドは
          キャッシュとプロキシ情報を設定し、その後適切な open メソッドを
          入力引数つきで呼び出します。認識できないスキームが与えられた場
          合、 *note open_unknown(): 38ac. が呼び出されます。 'data' 引
          数は *note urlopen(): 273. の引数 'data' と同じ意味を持ってい
          ます。

          This method always quotes 'fullurl' using *note quote(): b71.

      -- メソッド: open_unknown (fullurl, data=None)

          オーバライド可能な、未知のタイプの URL を開くためのインターフ
          ェースです。

      -- メソッド: retrieve (url, filename=None, reporthook=None,
               data=None)

          'url' の内容を取得し、'filename' に保存します。戻り値は、ロー
          カルファイル名と、レスポンスヘッダーが含まれる *note
          email.message.Message: 25d. (リモート URL の場合) か ‘None’ (ロ
          ーカル URL の場合) からなるタプルになります。呼び出し側は、そ
          の後 'filename' を開いてその内容を読み込まなければなりません。
          'filename' が与えられず、URL がローカルファイルを参照している
          場合、入力ファイル名が返されます。URL がローカルでなく、
          'filename' が与えられていない場合、ファイル名は入力 URL のパス
          の最後の構成要素のサフィックスとマッチするサフィックスを持つ
          *note tempfile.mktemp(): 17f8. の出力になります。'reporthook'
          が与えられている場合、3 つの数値 (チャンク数、読み込んだチャン
          クの最大サイズ、および総ダウンロードサイズ -- 不明の場合は -1)
          の引数を受け取る関数でなければなりません。これは開始時に 1 回
          と、ネットワークからデータのチャンクを読み込む度に呼び出されま
          す。'reporthook' はローカル URL に対しては無視されます。

          'url' が ‘http:’ スキーム識別子を使用していた場合、任意の引数
          'data' は ‘POST’ リクエストの指定に使用される場合があります (通
          常のリクエストタイプは ‘GET’ です)。引数 'data' は標準
          ‘application/x-www-form-urlencoded’ 形式でなければなりません。
          *note urllib.parse.urlencode(): e5e. 関数を参照してください。

      -- の属性: version

          URL をオープンするオブジェクトのユーザエージェントを指定する変
          数です。 *note urllib: f1. を特定のユーザエージェントであると
          サーバに通知するには、サブクラスの中でこの値をクラス変数として
          値を設定するか、コンストラクタの中でベースクラスを呼び出す前に
          値を設定してください。

 -- クラス: urllib.request.FancyURLopener (...)

     バージョン 3.3 で非推奨.

     *note FancyURLopener: 2e7. は *note URLopener: 2e6. のサブクラスで
     、以下の HTTP レスポンスコード: 301、302、303、 307、および 401 を
     取り扱う機能を提供します。レスポンスコード 30x に対しては、
     ‘Location’ ヘッダーを使って実際の URL を取得します。レスポンスコー
     ド 401 (認証が要求されていることを示す) に対しては、BASIC認証
     (basic HTTP authintication) が行われます。レスポンスコード 30x に対
     しては、最大で 'maxtries' 属性に指定された数だけ再帰呼び出しを行う
     ようになっています。この値はデフォルトで 10 です。

     For all other response codes, the method *note
     http_error_default(): 3862. is called which you can override in
     subclasses to handle the error appropriately.

          注釈: RFC 2616(1) によると、 POST 要求に対する 301 および 302
          応答はユーザの承認無しに自動的にリダイレクトしてはなりません。
          実際は、これらの応答に対して自動リダイレクトを許すブラウザでは
          POST を GET に変更しており、 *note urllib: f1. でもこの動作を
          再現します。

     コンストラクタに与えるパラメーターは *note URLopener: 2e6. と同じで
     す。

          注釈: 基本的な HTTP 認証を行う際、 *note FancyURLopener: 2e7.
          インスタンスは *note prompt_user_passwd(): 38ad. メソッドを呼
          び出します。このメソッドはデフォルトでは実行を制御している端末
          上で認証に必要な情報を要求するように実装されています。必要なら
          ば、このクラスのサブクラスにおいてより適切な動作をサポートする
          ために *note prompt_user_passwd(): 38ad. メソッドをオーバライ
          ドしてもかまいません。

     *note FancyURLopener: 2e7. クラスはオーバライド可能な追加のメソッド
     を提供しており、適切な振る舞いをさせることができます:

      -- メソッド: prompt_user_passwd (host, realm)

          指定されたセキュリティ領域 (security realm) 下にある与えられた
          ホストにおいて、ユーザー認証に必要な情報を返すための関数です。
          この関数が返す値は ‘(user, password)’ からなるタプルでなければ
          なりません。値は Basic 認証で使われます。

          このクラスでの実装では、端末に情報を入力するようプロンプトを出
          します; ローカルの環境において適切な形で対話型モデルを使うには
          、このメソッドをオーバライドしなければなりません。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2616.html


File: python.info,  Node: urllib request の制限事項,  Prev: レガシーインターフェース,  Up: urllib request --- URL を開くための大規模なライブラリ

5.21.4.25 ‘urllib.request’ の制限事項
.....................................

   * 現在、次のプロトコルのみサポートされています: HTTP (バージョン 0.9
     および 1.0)、FTP、ローカルファイル、およびデータ URL

     バージョン 3.4 で変更: データ URL サポートが追加されました。

   * *note urlretrieve(): 38a8. のキャッシュ機能は、誰かが Expiration
     time ヘッダーの正しい処理をハックする時間を見つけるまで無効にされて
     います。

   * ある URL がキャッシュにあるかどうか調べるような関数があればと思って
     います。

   * 後方互換性のため、 URL がローカルシステム上のファイルを指しているよ
     うに見えるにも関わらずファイルを開くことができなければ、 URL は FTP
     プロトコルを使って再解釈されます。この機能は時として混乱を招くエラ
     ーメッセージを引き起こします。

   * 関数 *note urlopen(): 273. および *note urlretrieve(): 38a8. は、ネ
     ットワーク接続が確立されるまでの間、一定でない長さの遅延を引き起こ
     すことがあります。このことは、これらの関数を使ってインタラクティブ
     な Web クライアントを構築するのはスレッドなしには難しいことを意味し
     ます。

   * *note urlopen(): 273. あるいは *note urlretrieve(): 38a8. が返すデ
     ータはサーバーから返された生データです。これは (画像のような) バイ
     ナリ、プレーンテキスト、あるいは (例えば) HTML などになります。HTTP
     プロトコルはレスポンスヘッダー内でタイプ情報を提供しており、
     ‘Content-Type’ ヘッダーを見ることで調査できます。返されたデータが
     HTML の場合、モジュール *note html.parser: 63. を使用してこれを解析
     できます。

   * FTP プロトコルを扱うコードでは、ファイルとディレクトリを区別できま
     せん。このことから、アクセスできないファイルを指している URL からデ
     ータを読み出そうとすると、予期しない動作を引き起こす場合があります
     。 URL が ‘/’ で終わっていれば、ディレクトリを指しているものとみな
     して、それに適した処理を行います。しかし、ファイルの読み出し操作が
     550 エラー (URL が存在しないか、主にパーミッションの理由でアクセス
     できない) になった場合、 URL がディレクトリを指していて、末尾の ‘/’
     を忘れたケースを処理するため、パスをディレクトリとして扱います。こ
     のために、パーミッションのためにアクセスできないファイルを fetch し
     ようとすると、FTP コードはそのファイルを開こうとして 550 エラーに陥
     り、次にディレクトリ一覧を表示しようとするため、誤解を生むような結
     果を引き起こす可能性があるのです。よく調整された制御が必要なら、
     *note ftplib: 54. モジュールを使うか、 *note FancyURLopener: 2e7. を
     サブクラス化するか、 '_urlopener' を変更して目的に合わせるよう検討
     してください。


File: python.info,  Node: urllib response --- urllib で使用するレスポンスクラス,  Next: urllib parse --- URL を構成要素に解析する,  Prev: urllib request --- URL を開くための大規模なライブラリ,  Up: インターネットプロトコルとサポート

5.21.5 ‘urllib.response’ -- urllib で使用するレスポンスクラス
-------------------------------------------------------------

*note urllib.response: f5. モジュールは、‘read()’ および ‘readline()’ を
含む 最小限のファイルライクインターフェースを定義する関数およびクラスを
定義しています。このモジュールで定義された関数は、*note urllib.request:
f4. モジュール内で使用されます。代表的なレスポンスオブジェクトは *note
urllib.response.addinfourl: 382e. インスタンスです。

 -- クラス: urllib.response.addinfourl

      -- の属性: url

          取得されたリソースの URL、主にリダイレクトが発生したかどうかを
          確認するために利用します。

      -- の属性: headers

          Returns the headers of the response in the form of an *note
          EmailMessage: 25c. instance.

      -- の属性: status

          Added in version 3.9.

          サーバから返される状態コードです。

      -- メソッド: geturl ()

          バージョン 3.9 で非推奨: 非推奨となったので *note url: 38b0. を
          使用してください。

      -- メソッド: info ()

          バージョン 3.9 で非推奨: 非推奨となったので *note headers:
          38b1. を使用してください。

      -- の属性: code

          バージョン 3.9 で非推奨: 非推奨となったので *note status:
          38b2. を使用してください。

      -- メソッド: getcode ()

          バージョン 3.9 で非推奨: 非推奨となったので *note status:
          38b2. を使用してください。


File: python.info,  Node: urllib parse --- URL を構成要素に解析する,  Next: urllib error --- urllib request によって送出される例外クラス,  Prev: urllib response --- urllib で使用するレスポンスクラス,  Up: インターネットプロトコルとサポート

5.21.6 ‘urllib.parse’ -- URL を構成要素に解析する
-------------------------------------------------

'ソースコード:' Lib/urllib/parse.py(1)

__________________________________________________________________

このモジュールでは URL (Uniform Resource Locator) 文字列をその構成要素
(アドレススキーム、ネットワーク上の位置、パスその他) に分解したり、構成
要素を URL に組みなおしたり、 "相対 URL (relative URL)" を指定した "基底
URL (base URL)" に基づいて絶対 URL に変換するための標準的なインターフェ
ースを定義しています。

The module has been designed to match the internet RFC on Relative
Uniform Resource Locators.  It supports the following URL schemes:
‘file’, ‘ftp’, ‘gopher’, ‘hdl’, ‘http’, ‘https’, ‘imap’,
‘itms-services’, ‘mailto’, ‘mms’, ‘news’, ‘nntp’, ‘prospero’, ‘rsync’,
‘rtsp’, ‘rtsps’, ‘rtspu’, ‘sftp’, ‘shttp’, ‘sip’, ‘sips’, ‘snews’,
‘svn’, ‘svn+ssh’, ‘telnet’, ‘wais’, ‘ws’, ‘wss’.

'CPython 実装の詳細:' The inclusion of the ‘itms-services’ URL scheme
can prevent an app from passing Apple's App Store review process for the
macOS and iOS App Stores.  Handling for the ‘itms-services’ scheme is
always removed on iOS; on macOS, it 'may' be removed if CPython has been
built with the *note -with-app-store-compliance: 1556. option.

*note urllib.parse: f3. モジュールは、大きく分けると URL の解析を行う関
数と URL のクオートを行う関数を定義しています。以下にこれらの詳細を説明
します。

This module's functions use the deprecated term ‘netloc’ (or ‘net_loc’),
which was introduced in RFC 1808(2).  However, this term has been
obsoleted by RFC 3986(3), which introduced the term ‘authority’ as its
replacement.  The use of ‘netloc’ is continued for backward
compatibility.

* Menu:

* URL の解析::
* URL parsing security::
* ASCII エンコードバイト列の解析::
* 構造化された解析結果::
* URL のクオート::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/urllib/parse.py

   (2) https://datatracker.ietf.org/doc/html/rfc1808.html

   (3) https://datatracker.ietf.org/doc/html/rfc3986.html


File: python.info,  Node: URL の解析,  Next: URL parsing security,  Up: urllib parse --- URL を構成要素に解析する

5.21.6.1 URL の解析
...................

URL 解析関数は、URL 文字列を各構成要素に分割するか、あるいは URL の構成
要素を組み合わせて URL 文字列を生成します。

 -- の関数: urllib.parse.urlparse (urlstring, scheme='',
          allow_fragments=True)

     URL を解析して 6 つの構成要素にし、6 要素の *note named tuple: 61a.
     を返します。このタプルは URL の一般的な構造:
     ‘scheme://netloc/path;parameters?query#fragment’ に対応しています。
     各タプル要素は文字列で、空の場合もあります。構成要素がさらに小さい
     要素に分解されることはありません (例えばネットワーク上の位置は単一
     の文字列になります)。また % によるエスケープは展開されません。上で
     示された区切り文字がタプルの各要素の一部分として含まれることはあり
     ませんが、'path' 要素の先頭のスラッシュがある場合には例外です。たと
     えば以下のようになります:

          >>> from urllib.parse import urlparse
          >>> urlparse("scheme://netloc/path;parameters?query#fragment")
          ParseResult(scheme='scheme', netloc='netloc', path='/path;parameters', params='',
                      query='query', fragment='fragment')
          >>> o = urlparse("http://docs.python.org:80/3/library/urllib.parse.html?"
          ...              "highlight=params#url-parsing")
          >>> o
          ParseResult(scheme='http', netloc='docs.python.org:80',
                      path='/3/library/urllib.parse.html', params='',
                      query='highlight=params', fragment='url-parsing')
          >>> o.scheme
          'http'
          >>> o.netloc
          'docs.python.org:80'
          >>> o.hostname
          'docs.python.org'
          >>> o.port
          80
          >>> o._replace(fragment="").geturl()
          'http://docs.python.org:80/3/library/urllib.parse.html?highlight=params'

     RFC 1808(1) にある文法仕様に基づき、urlparse は '//' で始まる場合に
     のみ netloc を認識します。それ以外の場合は、入力は相対URLであると推
     定され、path 部分で始まることになります。

          >>> from urllib.parse import urlparse
          >>> urlparse('//www.cwi.nl:80/%7Eguido/Python.html')
          ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
                      params='', query='', fragment='')
          >>> urlparse('www.cwi.nl/%7Eguido/Python.html')
          ParseResult(scheme='', netloc='', path='www.cwi.nl/%7Eguido/Python.html',
                      params='', query='', fragment='')
          >>> urlparse('help/Python.html')
          ParseResult(scheme='', netloc='', path='help/Python.html', params='',
                      query='', fragment='')

     'scheme' 引数によってデフォルトのアドレススキームを与えると、アドレ
     ススキームを指定していない URL のみに使用されます。常に許されるデフ
     ォルトの ‘''’ (‘b''’ に自動変換出来る)を除き、 'urlstring' と同じ型
     (テキストもしくはバイト列)であるべきです。

     引数 'allow_fragments' が false の場合、フラグメント識別子は認識さ
     れません。その代わり、それはパス、パラメータ、またはクエリ要素の一
     部として解析され、戻り値の ‘fragment’ は空文字に設定されます。

     戻り値は *note 名前付きタプル: 61a. です。これは、インデックス指定
     もしくは以下のような名前属性で要素にアクセスできることを意味します:

     属性                   インデッ    値                            指定されなかった場合の値
                            クス                                      
                            
     ----------------------------------------------------------------------------------------------
                                                                      
     ‘scheme’               0           URL スキーム                  'scheme' パラメータ
                                                                      
                                                                      
     ‘netloc’               1           ネットワーク上の位置          空文字列
                                                                      
                                                                      
     ‘path’                 2           階層的パス                    空文字列
                                                                      
                                                                      
     ‘params’               3           最後のパス要素に対するパラ    空文字列
                                        メータ                        
                                        
                                                                      
     ‘query’                4           クエリ要素                    空文字列
                                                                      
                                                                      
     ‘fragment’             5           フラグメント識別子            空文字列
                                                                      
                                                                      
     ‘username’                         ユーザ名                      *note None: 641.
                                                                      
                                                                      
     ‘password’                         パスワード                    *note None: 641.
                                                                      
                                                                      
     ‘hostname’                         ホスト名 (小文字)             *note None: 641.
                                                                      
                                                                      
     ‘port’                             ポート番号を表わす整数 (も    *note None: 641.
                                        しあれば)                     
                                        

     URL中で不正なポートが指定されている場合、 ‘port’ 属性を読みだすと、
     *note ValueError: 1e3. を送出します。結果オブジェクトのより詳しい情
     報は *note 構造化された解析結果: 38ba. 節を参照してください。

     ‘netloc’ 属性にマッチしなかった角括弧があると *note ValueError:
     1e3. を送出します。

     Characters in the ‘netloc’ attribute that decompose under NFKC
     normalization (as used by the IDNA encoding) into any of ‘/’, ‘?’,
     ‘#’, ‘@’, or ‘:’ will raise a *note ValueError: 1e3.  If the URL is
     decomposed before parsing, no error will be raised.

     As is the case with all named tuples, the subclass has a few
     additional methods and attributes that are particularly useful.
     One such method is ‘_replace()’.  The ‘_replace()’ method will
     return a new ParseResult object replacing specified fields with new
     values.

          >>> from urllib.parse import urlparse
          >>> u = urlparse('//www.cwi.nl:80/%7Eguido/Python.html')
          >>> u
          ParseResult(scheme='', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
                      params='', query='', fragment='')
          >>> u._replace(scheme='http')
          ParseResult(scheme='http', netloc='www.cwi.nl:80', path='/%7Eguido/Python.html',
                      params='', query='', fragment='')

          警告: *note urlparse(): 2e5. does not perform validation.  See
          *note URL parsing security: 38bb. for details.

     バージョン 3.2 で変更: IPv6 URL の解析も行えるようになりました。

     バージョン 3.3 で変更: The fragment is now parsed for all URL
     schemes (unless 'allow_fragments' is false), in accordance with RFC
     3986(2).  Previously, an allowlist of schemes that support
     fragments existed.

     バージョン 3.6 で変更: 範囲外のポート番号を指定すると、 *note None:
     641. を返す代わりに、*note ValueError: 1e3. を送出するようになりま
     した。

     バージョン 3.8 で変更: Characters that affect netloc parsing under
     NFKC normalization will now raise *note ValueError: 1e3.

 -- の関数: urllib.parse.parse_qs (qs, keep_blank_values=False,
          strict_parsing=False, encoding='utf-8', errors='replace',
          max_num_fields=None, separator='&')

     文字列引数として渡されたクエリ文字列
     (‘application/x-www-form-urlencoded’ 型のデータ) を解析します。解析
     されたデータを辞書として返します。辞書のキーは一意なクエリ変数名で
     、値は各変数名に対する値からなるリストです。

     任意の引数 'keep_blank_values' は、パーセントエンコードされたクエリ
     の中の値が入っていないクエリの値を空白文字列と見なすかどうかを示す
     フラグです。値が真であれば、値の入っていないフィールドは空文字列の
     ままになります。標準では偽で、値の入っていないフィールドを無視し、
     そのフィールドはクエリに含まれていないものとして扱います。

     任意の引数 'strict_parsing' はパース時のエラーをどう扱うかを決める
     フラグです。値が偽なら (デフォルトの設定です)、エラーは暗黙のうちに
     無視します。値が真なら *note ValueError: 1e3. 例外を送出します。

     任意のパラメータ 'encoding' および 'errors' はパーセントエンコード
     されたシーケンスを Unicode 文字にデコードする方法を指定します。これ
     は *note bytes.decode(): 8a4. メソッドに渡されます。

     The optional argument 'max_num_fields' is the maximum number of
     fields to read.  If set, then throws a *note ValueError: 1e3. if
     there are more than 'max_num_fields' fields read.

     The optional argument 'separator' is the symbol to use for
     separating the query arguments.  It defaults to ‘&’.

     このような辞書をクエリ文字列に変換するには *note
     urllib.parse.urlencode(): e5e. 関数を (‘doseq’ パラメータに ‘True’
     を指定して) 使用します。

     バージョン 3.2 で変更: 'encoding' および 'errors' パラメータが追加
     されました。

     バージョン 3.8 で変更: 'max_num_fields' パラメータが追加されました
     。

     バージョン 3.10 で変更: Added 'separator' parameter with the
     default value of ‘&’.  Python versions earlier than Python 3.10
     allowed using both ‘;’ and ‘&’ as query parameter separator.  This
     has been changed to allow only a single separator key, with ‘&’ as
     the default separator.

 -- の関数: urllib.parse.parse_qsl (qs, keep_blank_values=False,
          strict_parsing=False, encoding='utf-8', errors='replace',
          max_num_fields=None, separator='&')

     文字列引数として渡されたクエリ文字列
     (‘application/x-www-form-urlencoded’ 型のデータ) を解析します。解析
     されたデータは名前と値のペアからなるリストです。

     任意の引数 'keep_blank_values' は、パーセントエンコードされたクエリ
     の中の値が入っていないクエリの値を空白文字列と見なすかどうかを示す
     フラグです。値が真であれば、値の入っていないフィールドは空文字列の
     ままになります。標準では偽で、値の入っていないフィールドを無視し、
     そのフィールドはクエリに含まれていないものとして扱います。

     任意の引数 'strict_parsing' はパース時のエラーをどう扱うかを決める
     フラグです。値が偽なら (デフォルトの設定です)、エラーは暗黙のうちに
     無視します。値が真なら *note ValueError: 1e3. 例外を送出します。

     任意のパラメータ 'encoding' および 'errors' はパーセントエンコード
     されたシーケンスを Unicode 文字にデコードする方法を指定します。これ
     は *note bytes.decode(): 8a4. メソッドに渡されます。

     The optional argument 'max_num_fields' is the maximum number of
     fields to read.  If set, then throws a *note ValueError: 1e3. if
     there are more than 'max_num_fields' fields read.

     The optional argument 'separator' is the symbol to use for
     separating the query arguments.  It defaults to ‘&’.

     ペアのリストからクエリ文字列を生成する場合には *note
     urllib.parse.urlencode(): e5e. 関数を使用します。

     バージョン 3.2 で変更: 'encoding' および 'errors' パラメータが追加
     されました。

     バージョン 3.8 で変更: 'max_num_fields' パラメータが追加されました
     。

     バージョン 3.10 で変更: Added 'separator' parameter with the
     default value of ‘&’.  Python versions earlier than Python 3.10
     allowed using both ‘;’ and ‘&’ as query parameter separator.  This
     has been changed to allow only a single separator key, with ‘&’ as
     the default separator.

 -- の関数: urllib.parse.urlunparse (parts)

     ‘urlparse()’ が返すような形式のタプルから URL を構築します。'parts'
     引数は任意の 6 要素イテラブルです。解析された元の URL が、不要な区
     切り文字を持っていた場合には、多少違いはあるが等価な URL になるかも
     しれません (例えばクエリ内容が空の ‘?’ のようなもので、RFC はこれら
     を等価だと述べています)。

 -- の関数: urllib.parse.urlsplit (urlstring, scheme='',
          allow_fragments=True)

     *note urlparse(): 2e5. に似ていますが、URL から params を切り離しま
     せん。このメソッドは通常、URL の 'path' 部分において、各セグメント
     にパラメータ指定をできるようにした最近の URL 構文 ( RFC 2396(3) 参
     照) が必要な場合に、 *note urlparse(): 2e5. の代わりに使われます。
     パスセグメントとパラメータを分割するためには分割用の関数が必要です
     。この関数は 5 要素の *note named tuple: 61a. を返します:

          (addressing scheme, network location, path, query, fragment identifier).

     戻り値は *note 名前付きタプル: 61a. で、インデックスによってもしく
     は名前属性として要素にアクセスできます:

     属性                   インデッ    値                            指定されなかった場合の値
                            クス                                      
                            
     --------------------------------------------------------------------------------------------
                                                                      
     ‘scheme’               0           URL スキーム                  'scheme' パラメータ
                                                                      
                                                                      
     ‘netloc’               1           ネットワーク上の位置          空文字列
                                                                      
                                                                      
     ‘path’                 2           階層的パス                    空文字列
                                                                      
                                                                      
     ‘query’                3           クエリ要素                    空文字列
                                                                      
                                                                      
     ‘fragment’             4           フラグメント識別子            空文字列
                                                                      
                                                                      
     ‘username’                         ユーザ名                      *note None: 641.
                                                                      
                                                                      
     ‘password’                         パスワード                    *note None: 641.
                                                                      
                                                                      
     ‘hostname’                         ホスト名 (小文字)             *note None: 641.
                                                                      
                                                                      
     ‘port’                             ポート番号を表わす整数 (も    *note None: 641.
                                        しあれば)                     
                                        

     URL中で不正なポートが指定されている場合、 ‘port’ 属性を読みだすと、
     *note ValueError: 1e3. を送出します。結果オブジェクトのより詳しい情
     報は *note 構造化された解析結果: 38ba. 節を参照してください。

     ‘netloc’ 属性にマッチしなかった角括弧があると *note ValueError:
     1e3. を送出します。

     Characters in the ‘netloc’ attribute that decompose under NFKC
     normalization (as used by the IDNA encoding) into any of ‘/’, ‘?’,
     ‘#’, ‘@’, or ‘:’ will raise a *note ValueError: 1e3.  If the URL is
     decomposed before parsing, no error will be raised.

     Following some of the WHATWG spec(4) that updates RFC 3986, leading
     C0 control and space characters are stripped from the URL. ‘\n’,
     ‘\r’ and tab ‘\t’ characters are removed from the URL at any
     position.

          警告: *note urlsplit(): d0d. does not perform validation.  See
          *note URL parsing security: 38bb. for details.

     バージョン 3.6 で変更: 範囲外のポート番号を指定すると、 *note None:
     641. を返す代わりに、*note ValueError: 1e3. を送出するようになりま
     した。

     バージョン 3.8 で変更: Characters that affect netloc parsing under
     NFKC normalization will now raise *note ValueError: 1e3.

     バージョン 3.10 で変更: ASCII newline and tab characters are
     stripped from the URL.

     バージョン 3.12 で変更: Leading WHATWG C0 control and space
     characters are stripped from the URL.

 -- の関数: urllib.parse.urlunsplit (parts)

     *note urlsplit(): d0d. が返すような形式のタプル中のエレメントを組み
     合わせて、文字列の完全な URL にします。 'parts' 引数は任意の 5 要素
     イテラブルです。解析された元の URL が、不要な区切り文字を持っていた
     場合には、多少違いはあるが等価な URL になるかもしれません (例えばク
     エリ内容が空の ?  のようなもので、RFC はこれらを等価だと述べていま
     す)。

 -- の関数: urllib.parse.urljoin (base, url, allow_fragments=True)

     "基底 URL"('base')と別のURL('url')を組み合わせて、完全な URL ("絶対
     URL") を構成します。くだけて言えば、この関数は相対 URL にない要素を
     提供するために基底 URL の要素、特にアドレススキーム、ネットワーク上
     の位置、およびパス (の一部) を使います。例えば:

          >>> from urllib.parse import urljoin
          >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
          'http://www.cwi.nl/%7Eguido/FAQ.html'

     'allow_fragments' 引数は *note urlparse(): 2e5. における引数と同じ
     意味とデフォルトを持ちます。

          注釈: 'url' が (‘//’ か ‘scheme://’ で始まる) 絶対URLであれば
          、その 'url' のホスト名と / もしくは scheme は結果に反映されま
          す。例えば:

               >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html',
               ...         '//www.python.org/%7Eguido')
               'http://www.python.org/%7Eguido'

          もしこの動作が望みのものでない場合は、 'url' を *note
          urlsplit(): d0d. と *note urlunsplit(): 1539. で先に処理して、
          'scheme' と 'netloc' を削除してください。

     バージョン 3.5 で変更: RFC 3986(5) で定義された意味論とマッチするよ
     うに挙動がアップデートされました。

 -- の関数: urllib.parse.urldefrag (url)

     'url' がフラグメント識別子を含む場合、フラグメント識別子を持たない
     バージョンに修正された 'url' と、別の文字列に分割されたフラグメント
     識別子を返します。'url' 中にフラグメント識別子がない場合、そのまま
     の 'url' と空文字列を返します。

     戻り値は *note 名前付きタプル: 61a. で、インデックスによってもしく
     は名前属性として要素にアクセスできます:

     属性                   インデッ    値                            指定されなかった場合の値
                            クス                                      
                            
     --------------------------------------------------------------------------------------------
                                                                      
     ‘url’                  0           フラグメントのない URL        空文字列
                                                                      
                                                                      
     ‘fragment’             1           フラグメント識別子            空文字列
                                                                      

     結果オブジェクトのより詳しい情報は *note 構造化された解析結果:
     38ba. 節を参照してください。

     バージョン 3.2 で変更: 結果はシンプルな 2 要素のタプルから構造化オ
     ブジェクトに変更されました。

 -- の関数: urllib.parse.unwrap (url)

     Extract the url from a wrapped URL (that is, a string formatted as
     ‘<URL:scheme://host/path>’, ‘<scheme://host/path>’,
     ‘URL:scheme://host/path’ or ‘scheme://host/path’).  If 'url' is not
     a wrapped URL, it is returned without changes.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc1808.html

   (2) https://datatracker.ietf.org/doc/html/rfc3986.html

   (3) https://datatracker.ietf.org/doc/html/rfc2396.html

   (4) https://url.spec.whatwg.org/#concept-basic-url-parser

   (5) https://datatracker.ietf.org/doc/html/rfc3986.html


File: python.info,  Node: URL parsing security,  Next: ASCII エンコードバイト列の解析,  Prev: URL の解析,  Up: urllib parse --- URL を構成要素に解析する

5.21.6.2 URL parsing security
.............................

The *note urlsplit(): d0d. and *note urlparse(): 2e5. APIs do not
perform 'validation' of inputs.  They may not raise errors on inputs
that other applications consider invalid.  They may also succeed on some
inputs that might not be considered URLs elsewhere.  Their purpose is
for practical functionality rather than purity.

Instead of raising an exception on unusual input, they may instead
return some component parts as empty strings.  Or components may contain
more than perhaps they should.

We recommend that users of these APIs where the values may be used
anywhere with security implications code defensively.  Do some
verification within your code before trusting a returned component part.
Does that ‘scheme’ make sense?  Is that a sensible ‘path’?  Is there
anything strange about that ‘hostname’?  etc.

What constitutes a URL is not universally well defined.  Different
applications have different needs and desired constraints.  For instance
the living WHATWG spec(1) describes what user facing web clients such as
a web browser require.  While RFC 3986(2) is more general.  These
functions incorporate some aspects of both, but cannot be claimed
compliant with either.  The APIs and existing user code with
expectations on specific behaviors predate both standards leading us to
be very cautious about making API behavior changes.

   ---------- Footnotes ----------

   (1) https://url.spec.whatwg.org/#concept-basic-url-parser

   (2) https://datatracker.ietf.org/doc/html/rfc3986.html


File: python.info,  Node: ASCII エンコードバイト列の解析,  Next: 構造化された解析結果,  Prev: URL parsing security,  Up: urllib parse --- URL を構成要素に解析する

5.21.6.3 ASCII エンコードバイト列の解析
.......................................

URL を解析する関数は元々文字列のみ操作するよう設計されていました。実際の
ところ、それは URL が正しくクオートされエンコードされた ASCII バイト列を
操作できた方が有用でした。結果的にこのモジュールの URL 解析関数はすべて
*note bytes: 1a4. および *note bytearray: 508. オブジェクトに加えて
*note str: 418. オブジェクトでも処理するようになりました。

*note str: 418. データが渡された場合、戻り値は *note str: 418. データの
みを含んだものになります。*note bytes: 1a4. あるいは *note bytearray:
508. が渡された場合、戻り値は *note bytes: 1a4. データのみを含んだものに
なります。

単一の関数を呼び出す時に *note bytes: 1a4. または *note bytearray: 508.
が混在した *note str: 418. を渡した場合、*note TypeError: 502. が、非
ASCII バイト値が渡された場合 *note UnicodeDecodeError: 9e1. が送出されま
す。

*note str: 418. と *note bytes: 1a4. 間で容易に変換を行えるよう、すべて
の URL 解析関数は ‘encode()’ メソッド (結果に *note str: 418. データが含
まれる時用) か ‘decode()’ メソッド (結果に *note bytes: 1a4. データが含
まれる時用) のどちらかを提供しています。これらメソッドの動作は対応する
*note str: 418. と *note bytes: 1a4. メソッドが持つものと同じです (ただ
しデフォルトのエンコーディングは ‘'utf-8'’ ではなく ‘'ascii'’ になります
)。それぞれは ‘encode()’ メソッドを持つ *note bytes: 1a4. データか
‘decode()’ メソッドを持つ *note str: 418. データのどちらかに対応した型を
生成します。

非 ASCII データを含むなど、不適切にクオートされた URL を操作する可能性の
あるアプリケーションでは、URL 解析メソッドを呼び出す前に独自にバイト列か
ら文字列にデコードする必要があります。

この項で説明された挙動は URL 解析関数にのみ該当します。URL クオート関数
でバイトシーケンスを生成もしくは消化する際には、別にURL クオート関数の項
で詳説されている通りのルールに従います。

バージョン 3.2 で変更: URL 解析関数は ASCII エンコードバイトシーケンスも
受け付けるようになりました


File: python.info,  Node: 構造化された解析結果,  Next: URL のクオート,  Prev: ASCII エンコードバイト列の解析,  Up: urllib parse --- URL を構成要素に解析する

5.21.6.4 構造化された解析結果
.............................

*note urlparse(): 2e5.、*note urlsplit(): d0d.、および *note
urldefrag(): 1219. 関数が返すオブジェクトは *note tuple: 349. 型のサブク
ラスになります。これらサブクラスにはそれぞれの関数で説明されている属性が
追加されており、前述のとおりエンコーディングとデコーディングをサポートし
ています:

 -- メソッド: urllib.parse.SplitResult.geturl ()

     オリジナルの URL を再結合した場合は文字列で返されます。これはスキー
     ムが小文字に正規化されていたり、空の構成要素が除去されるなど、オリ
     ジナルの URL とは異なる場合があります。特に、空のパラメータ、クエリ
     、およびフラグメント識別子は削除されます。

     *note urldefrag(): 1219. の戻り値では、空のフラグメント識別子のみ削
     除されます。*note urlsplit(): d0d. および *note urlparse(): 2e5. の
     戻り値では、このメソッドが返す URL には説明されているすべての変更が
     加えられます。

     加えた解析関数を逆に行えばこのメソッドの戻り値は元の URL になります
     :

          >>> from urllib.parse import urlsplit
          >>> url = 'HTTP://www.Python.org/doc/#'
          >>> r1 = urlsplit(url)
          >>> r1.geturl()
          'http://www.Python.org/doc/'
          >>> r2 = urlsplit(r1.geturl())
          >>> r2.geturl()
          'http://www.Python.org/doc/'

以下のクラスは *note str: 418. オブジェクトを操作した場合、構造化された
解析結果の実装を提供します:

 -- クラス: urllib.parse.DefragResult (url, fragment)

     *note urldefrag(): 1219. の具象クラスの結果には *note str: 418. デ
     ータが含まれます。‘encode()’ メソッドは *note DefragResultBytes:
     38c2. インスタンスを返します。

     Added in version 3.2.

 -- クラス: urllib.parse.ParseResult (scheme, netloc, path, params,
          query, fragment)

     *note urlparse(): 2e5. の具象クラスの結果には *note str: 418. デー
     タが含まれます。‘encode()’ メソッドは *note ParseResultBytes: 38c4.
     インスタンスを返します。

 -- クラス: urllib.parse.SplitResult (scheme, netloc, path, query,
          fragment)

     *note urlsplit(): d0d. の具象クラスの結果には *note str: 418. デー
     タが含まれます。‘encode()’ メソッドは *note SplitResultBytes: 38c6.
     インスタンスを返します。

以下のクラスは *note bytes: 1a4. または *note bytearray: 508. オブジェク
トを操作した時に解析結果の実装を提供します:

 -- クラス: urllib.parse.DefragResultBytes (url, fragment)

     *note urldefrag(): 1219. の具象クラスの結果には *note bytes: 1a4. デ
     ータが含まれます。‘decode()’ メソッドは *note DefragResult: 38c1. イ
     ンスタンスを返します。

     Added in version 3.2.

 -- クラス: urllib.parse.ParseResultBytes (scheme, netloc, path, params,
          query, fragment)

     *note urlparse(): 2e5. の具象クラスの結果には *note bytes: 1a4. が
     含まれます。‘decode()’ メソッドは *note ParseResult: 38c3. インスタ
     ンスを返します。

     Added in version 3.2.

 -- クラス: urllib.parse.SplitResultBytes (scheme, netloc, path, query,
          fragment)

     *note urlsplit(): d0d. の具象クラスの結果には *note bytes: 1a4. デ
     ータが含まれます。‘decode()’ メソッドは *note SplitResult: 38c5. イ
     ンスタンスを返します。

     Added in version 3.2.


File: python.info,  Node: URL のクオート,  Prev: 構造化された解析結果,  Up: urllib parse --- URL を構成要素に解析する

5.21.6.5 URL のクオート
.......................

URL クオート関数は、プログラムデータを取り URL 構成要素として使用できる
よう特殊文字をクオートしたり非 ASCII 文字を適切にエンコードすることに焦
点を当てています。これらは上述の URL 解析関数でカバーされていない URL 構
成要素からオリジナルデータの再作成もサポートしています。

 -- の関数: urllib.parse.quote (string, safe='/', encoding=None,
          errors=None)

     Replace special characters in 'string' using the ‘%XX’ escape.
     Letters, digits, and the characters ‘'_.-~'’ are never quoted.  By
     default, this function is intended for quoting the path section of
     a URL. The optional 'safe' parameter specifies additional ASCII
     characters that should not be quoted -- its default value is ‘'/'’.

     'string' に使用できるのは *note str: 418. か *note bytes: 1a4. オブ
     ジェクトです。

     バージョン 3.7 で変更: Moved from RFC 2396(1) to RFC 3986(2) for
     quoting URL strings.  "~" is now included in the set of unreserved
     characters.

     任意のパラメータ 'encoding' と 'errors' は *note str.encode(): 8a3.
     で受け付けられる非 ASCII 文字への対処法を指定します。'encoding' の
     デフォルトは ‘'utf-8'’、'errors' のデフォルトは ‘'strict'’ で、非サ
     ポート文字があると *note UnicodeEncodeError: 643. を送出します。
     'string' が *note bytes: 1a4. の場合 'encoding' と 'errors' を指定
     してはいけません。指定すると *note TypeError: 502. が送出されます。

     ‘quote(string, safe, encoding, errors)’ は
     ‘quote_from_bytes(string.encode(encoding, errors), safe)’ と等価で
     あることに留意してください。

     例: ‘quote('/El Niño/')’ は ‘'/El%20Ni%C3%B1o/'’ を返します。

 -- の関数: urllib.parse.quote_plus (string, safe='', encoding=None,
          errors=None)

     Like *note quote(): b71, but also replace spaces with plus signs,
     as required for quoting HTML form values when building up a query
     string to go into a URL. Plus signs in the original string are
     escaped unless they are included in 'safe'.  It also does not have
     'safe' default to ‘'/'’.

     例: ‘quote_plus('/El Niño/')’ は ‘'%2FEl+Ni%C3%B1o%2F'’ を返します
     。

 -- の関数: urllib.parse.quote_from_bytes (bytes, safe='/')

     *note quote(): b71. と似ていますが、*note str: 418. ではなく *note
     bytes: 1a4. オブジェクトを取り、文字列からバイト列へのエンコードを
     行いません。

     例: ‘quote_from_bytes(b'a&\xef')’ は ‘'a%26%EF'’ を返します。

 -- の関数: urllib.parse.unquote (string, encoding='utf-8',
          errors='replace')

     Replace ‘%XX’ escapes with their single-character equivalent.  The
     optional 'encoding' and 'errors' parameters specify how to decode
     percent-encoded sequences into Unicode characters, as accepted by
     the *note bytes.decode(): 8a4. method.

     'string' に使用できるのは *note str: 418. か *note bytes: 1a4. オブ
     ジェクトです。

     'encoding' のデフォルトは ‘'utf-8'’、'errors' のデフォルトは
     ‘'replace'’ で、不正なシーケンスはプレースホルダー文字に置き換えら
     れます。

     例: ‘unquote('/El%20Ni%C3%B1o/')’ は ‘'/El Niño/'’ を返します。

     バージョン 3.9 で変更: 'string' parameter supports bytes and str
     objects (previously only str).

 -- の関数: urllib.parse.unquote_plus (string, encoding='utf-8',
          errors='replace')

     *note unquote(): 16f1. と似ていますが、HTML フォームの値のアンクオ
     ートのために「+」を空白に置き換えます。

     'string' は *note str: 418. でなければなりません。

     例: ‘unquote_plus('/El+Ni%C3%B1o/')’ は ‘'/El Niño/'’ を返します。

 -- の関数: urllib.parse.unquote_to_bytes (string)

     Replace ‘%XX’ escapes with their single-octet equivalent, and
     return a *note bytes: 1a4. object.

     'string' に使用できるのは *note str: 418. か *note bytes: 1a4. オブ
     ジェクトです。

     *note str: 418. だった場合、'string' 内のエスケープされていない非
     ASCII 文字は UTF-8 バイト列にエンコードされます。

     例: ‘unquote_to_bytes('a%26%EF')’ は ‘b'a&\xef'’ を返します。

 -- の関数: urllib.parse.urlencode (query, doseq=False, safe='',
          encoding=None, errors=None, quote_via=quote_plus)

     マッピング型オブジェクトまたは 2 個の要素からなるタプルのシーケンス
     (*note str: 418. か *note bytes: 1a4. オブジェクトが含まれているか
     もしれません) を、パーセントエンコードされた ASCII 文字列に変換しま
     す。戻り値の文字列が *note urlopen(): 273. 関数での POST 操作の
     'data' で使用される場合はバイト列にエンコードしなければなりません。
     そうでない場合は *note TypeError: 502. が送出されます。

     戻り値は ‘'&'’ 文字で区切られた ‘key=value’ のペアからなる一組の文
     字列になります。 'key' と 'value' は 'quote_via' を使用してクオート
     されます。デフォルトで、値をクォートするために *note quote_plus():
     121a. が使用されます。つまり、スペースは ‘'+'’ 文字に、 '/' 文字は
     ‘%2F’ にクォートされます。これは GET リクエストの標準に準拠します
     (‘application/x-www-form-urlencoded’)。 'quote_via' として渡すこと
     ができる別の関数は *note quote(): b71. です。それはスペースを ‘%20’
     にエンコードし、 '/' をエンコードしません。何がクォートされるかを最
     大限コントロールしたければ、 ‘quote’ を使って 'safe' に値を指定して
     ください。

     引数 'query' が 2 要素のタプルのシーケンスの場合、各タプルの第一要
     素はキーに、第二要素は値になります。 値となる要素はシーケンスを取る
     こともでき、この場合、オプションのパラメーター 'doseq' が ‘True’ と
     評価されるのであれば、キーに対し値シーケンスの各要素を個別に結び付
     けた ‘key=value’ のペアを、 ‘'&'’ 文字でつないだものを生成します。
     エンコードされた文字列内のパラメーターの順序はシーケンス内のパラメ
     ータータプルの順序と一致します。

     'safe', 'encoding', および 'errors' パラメータは 'quote_via' にその
     まま渡されます (クエリ要素が *note str: 418. の場合は、 'encoding'
     と 'errors' パラメータだけが渡されます)。

     このエンコード処理の逆を行うには、このモジュールで提供されている
     *note parse_qs(): 25b. と *note parse_qsl(): 25a. を使用して、クエ
     リ文字列を Python データ構造に変換できます。

     POST リクエストのデータ、あるいは URL クエリ文字列を生成するために
     、 *note urllib.parse.urlencode(): e5e. メソッドをどのように使えば
     よいかを見るには、*note urllib の使用例: 38a6. を参照してください。

     バージョン 3.2 で変更: 'query' はバイト列と文字列オブジェクトをサポ
     ートします。

     バージョン 3.5 で変更: Added the 'quote_via' parameter.

参考
....

WHATWG(3) - URL Living standard

     Working Group for the URL Standard that defines URLs, domains, IP
     addresses, the application/x-www-form-urlencoded format, and their
     API.

RFC 3986(4) - Uniform Resource Identifiers

     これが現在の標準規格 (STD66) です。urllib.parse モジュールに対する
     すべての変更はこの規格に準拠していなければなりませんが、若干の逸脱
     はありえます。これは主には後方互換性のため、また主要なブラウザで一
     般的に見られる、URL を解析する上でのいくつかの事実上の要件を満たす
     ためです。

RFC 2732(5) - Format for Literal IPv6 Addresses in URL's.

     この規格は IPv6 の URL を解析するときの要求事項を記述しています。

RFC 2396(6) - Uniform Resource Identifiers (URI): Generic Syntax

     この RFC では Uniform Resource Name (URN) と Uniform Resource
     Locator (URL) の両方に対する一般的な文法的要求事項を記述しています
     。

RFC 2368(7) - The mailto URL scheme.

     mailto URL スキームに対する文法的要求事項です。

RFC 1808(8) - Relative Uniform Resource Locators

     この RFC には絶対 URL と相対 URL を結合するための規則がボーダケース
     の取扱い方を決定する "異常な例" つきで収められています。

RFC 1738(9) - Uniform Resource Locators (URL)

     この RFC では絶対 URL の形式的な文法と意味付けを仕様化しています。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2396.html

   (2) https://datatracker.ietf.org/doc/html/rfc3986.html

   (3) https://url.spec.whatwg.org/

   (4) https://datatracker.ietf.org/doc/html/rfc3986.html

   (5) https://datatracker.ietf.org/doc/html/rfc2732.html

   (6) https://datatracker.ietf.org/doc/html/rfc2396.html

   (7) https://datatracker.ietf.org/doc/html/rfc2368.html

   (8) https://datatracker.ietf.org/doc/html/rfc1808.html

   (9) https://datatracker.ietf.org/doc/html/rfc1738.html


File: python.info,  Node: urllib error --- urllib request によって送出される例外クラス,  Next: urllib robotparser --- robots txt 用のパーサー,  Prev: urllib parse --- URL を構成要素に解析する,  Up: インターネットプロトコルとサポート

5.21.7 ‘urllib.error’ -- urllib.request によって送出される例外クラス
--------------------------------------------------------------------

'ソースコード:' Lib/urllib/error.py(1)

__________________________________________________________________

*note urllib.error: f2. は *note urllib.request: f4. によって投げられる
例外を定義しています。基底クラスは *note URLError: 3830. です。

*note urllib.error: f2. は必要に応じて以下の例外が送出します:

 -- 例外: urllib.error.URLError

     ハンドラが何らかの問題に遭遇した場合、この例外 (またはこの例外から
     派生した例外)を送出します。この例外は *note OSError: 3f0. のサブク
     ラスです。

      -- の属性: reason

          このエラーの理由。メッセージ文字列あるいは他の例外インスタンス
          です。

     バージョン 3.3 で変更: *note URLError: 3830. は以前は *note
     IOError: 1026. のサブタイプでしたが、 *note OSError: 3f0. のエイリ
     アスになりました。

 -- 例外: urllib.error.HTTPError (url, code, msg, hdrs, fp)

     *note HTTPError: fab. は例外 (*note URLError: 3830. のサブクラス) で
     すが、同時に例外ではない file-like な戻り値を返す関数でもあります
     (*note urlopen(): 273. の戻り値と同じです)。これは、例えばサーバか
     らの認証リクエストのように、変わった HTTP エラーを処理するのに役立
     ちます。

      -- の属性: url

          リクエスト URL を含みます。 'filename' 属性のエイリアスです。

      -- の属性: code

          RFC 2616(2) に定義されているHTTPステータスコード。 この数値型
          の値は、 *note http.server.BaseHTTPRequestHandler.responses:
          38ce. の辞書に登録されているコードに対応します。

      -- の属性: reason

          これは通常、このエラーの原因を説明する文字列です。 'msg' 属性
          のエイリアスです。

      -- の属性: headers

          *note HTTPError: fab. の原因となった HTTP リクエストの HTTP レ
          スポンスヘッダ。 'hdrs' 属性のエイリアスです。

          Added in version 3.4.

      -- の属性: fp

          HTTP エラーの body を読み出し可能なファイルライクオブジェクト
          。

 -- 例外: urllib.error.ContentTooShortError (msg, content)

     この例外は *note urlretrieve(): 38a8. 関数が、ダウンロードされたデ
     ータの量が予期した量 ('Content-Length' ヘッダで与えられる) よりも少
     ないことを検知した際に発生します。

      -- の属性: content

          ダウンロードされた、 (おそらく切り捨てられた) データ。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/urllib/error.py

   (2) https://datatracker.ietf.org/doc/html/rfc2616.html


File: python.info,  Node: urllib robotparser --- robots txt 用のパーサー,  Next: http --- HTTP モジュール群,  Prev: urllib error --- urllib request によって送出される例外クラス,  Up: インターネットプロトコルとサポート

5.21.8 ‘urllib.robotparser’ -- robots.txt 用のパーサー
------------------------------------------------------

'ソースコード:' Lib/urllib/robotparser.py(1)

__________________________________________________________________

このモジュールでは単一のクラス、 *note RobotFileParser: ccb. を提供しま
す。このクラスは、特定のユーザエージェントが ‘robots.txt’ ファイルを公開
している Web サイトのある URL を取得可能かどうかの質問に答えます。
‘robots.txt’ ファイルの構造に関する詳細は
‘http://www.robotstxt.org/orig.html’ を参照してください。

 -- クラス: urllib.robotparser.RobotFileParser (url='')

     'url' の ‘robots.txt’ に対し読み込み、パーズ、応答するメソッドを提
     供します。

      -- メソッド: set_url (url)

          ‘robots.txt’ ファイルを参照するための URL を設定します。

      -- メソッド: read ()

          ‘robots.txt’ URL を読み出し、パーザに入力します。

      -- メソッド: parse (lines)

          引数 'lines' の内容を解釈します。

      -- メソッド: can_fetch (useragent, url)

          解釈された ‘robots.txt’ ファイル中に記載された規則に従ったとき
          、 'useragent' が 'url' を取得してもよい場合には ‘True’ を返し
          ます。

      -- メソッド: mtime ()

          ‘robots.txt’ ファイルを最後に取得した時刻を返します。この値は
          、定期的に新たな ‘robots.txt’ をチェックする必要がある、長時間
          動作する Web スパイダープログラムを実装する際に便利です。

      -- メソッド: modified ()

          ‘robots.txt’ ファイルを最後に取得した時刻を現在の時刻に設定し
          ます。

      -- メソッド: crawl_delay (useragent)

          当該の 'ユーザーエージェント' 用の ‘robots.txt’ の
          ‘Crawl-delay’ パラメーターの値を返します。そのようなパラメータ
          ーが存在しないか、指定された 'ユーザーエージェント' にあてはま
          らない、もしくは ‘robots.txt’ のこのパラメーターのエントリの構
          文が無効な場合は、 ‘None’ を返します。

          Added in version 3.6.

      -- メソッド: request_rate (useragent)

          ‘robots.txt’ の ‘Request-rate’ パラメーターの内容を *note
          named tuple: 61a. ‘RequestRate(requests, seconds)’ として返し
          ます。そのようなパラメーターが存在しないか、指定された 'ユーザ
          ーエージェント' にあてはまらない、もしくは ‘robots.txt’ のこの
          パラメーターのエントリの構文が無効な場合は、 ‘None’ を返します
          。

          Added in version 3.6.

      -- メソッド: site_maps ()

          ‘robots.txt’ の ‘Sitemap’ パラメーターの内容を *note list():
          5dc. の形式で返します。そのようなパラメーターが存在しないか、
          ‘robots.txt’ のこのパラメーターのエントリの構文が無効な場合は
          、 ‘None’ を返します。

          Added in version 3.8.

以下に *note RobotFileParser: ccb. クラスの利用例を示します。

     >>> import urllib.robotparser
     >>> rp = urllib.robotparser.RobotFileParser()
     >>> rp.set_url("http://www.musi-cal.com/robots.txt")
     >>> rp.read()
     >>> rrate = rp.request_rate("*")
     >>> rrate.requests
     3
     >>> rrate.seconds
     20
     >>> rp.crawl_delay("*")
     6
     >>> rp.can_fetch("*", "http://www.musi-cal.com/cgi-bin/search?city=San+Francisco")
     False
     >>> rp.can_fetch("*", "http://www.musi-cal.com/")
     True

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/urllib/robotparser.py


File: python.info,  Node: http --- HTTP モジュール群,  Next: http client --- HTTP プロトコルクライアント,  Prev: urllib robotparser --- robots txt 用のパーサー,  Up: インターネットプロトコルとサポート

5.21.9 ‘http’ -- HTTP モジュール群
----------------------------------

'ソースコード:' Lib/http/__init__.py(1)

__________________________________________________________________

*note http: 64. パッケージはハイパーテキスト転送プロトコルを扱うための幾
つかのモジュールを集めたものです:

   * *note http.client: 65. は低水準のHTTPプロトコルのクライアントです。
     高水準の URL を開く操作には *note urllib.request: f4. を使ってくだ
     さい

   * *note http.server: 68. は *note socketserver: b9. をベースにした基
     礎的な HTTP サーバーを実装しています

   * *note http.cookies: 67. は cookie の状態管理を実装するためのユーテ
     ィリティーを提供しています

   * *note http.cookiejar: 66. は cookie の永続化機能を提供しています

*note http: 64. モジュールは、 http 関連のコードの処理に役立つ以下の列挙
型も定義しています:

 -- クラス: http.HTTPStatus

     Added in version 3.5.

     一連の HTTP ステータスコード、理由の表現、英語で書かれた長い記述を
     定義した *note enum.IntEnum: cad. のサブクラスです。

     使い方:

          >>> from http import HTTPStatus
          >>> HTTPStatus.OK
          HTTPStatus.OK
          >>> HTTPStatus.OK == 200
          True
          >>> HTTPStatus.OK.value
          200
          >>> HTTPStatus.OK.phrase
          'OK'
          >>> HTTPStatus.OK.description
          'Request fulfilled, document follows'
          >>> list(HTTPStatus)
          [HTTPStatus.CONTINUE, HTTPStatus.SWITCHING_PROTOCOLS, ...]

* Menu:

* HTTP ステータスコード::
* HTTP ステータスコードカテゴリ::
* HTTP メソッド::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/http/__init__.py


File: python.info,  Node: HTTP ステータスコード,  Next: HTTP ステータスコードカテゴリ,  Up: http --- HTTP モジュール群

5.21.9.1 HTTP ステータスコード
..............................

*note http.HTTPStatus: 8ce. で利用可能な、サポートされている、IANA に登
録されたステータスコード(1) は:

コード      列挙名                                  詳細
                                                    
----------------------------------------------------------------------------------------------------------------------------------------
                                                    
‘100’       ‘CONTINUE’                              HTTP Semantics RFC 9110(2), Section 15.2.1
                                                    
                                                    
‘101’       ‘SWITCHING_PROTOCOLS’                   HTTP Semantics RFC 9110(3), Section 15.2.2
                                                    
                                                    
‘102’       ‘PROCESSING’                            WebDAV RFC 2518(4), Section 10.1
                                                    
                                                    
‘103’       ‘EARLY_HINTS’                           An HTTP Status Code for Indicating Hints RFC 8297(5)
                                                    
                                                    
‘200’       ‘OK’                                    HTTP Semantics RFC 9110(6), Section 15.3.1
                                                    
                                                    
‘201’       ‘CREATED’                               HTTP Semantics RFC 9110(7), Section 15.3.2
                                                    
                                                    
‘202’       ‘ACCEPTED’                              HTTP Semantics RFC 9110(8), Section 15.3.3
                                                    
                                                    
‘203’       ‘NON_AUTHORITATIVE_INFORMATION’         HTTP Semantics RFC 9110(9), Section 15.3.4
                                                    
                                                    
‘204’       ‘NO_CONTENT’                            HTTP Semantics RFC 9110(10), Section 15.3.5
                                                    
                                                    
‘205’       ‘RESET_CONTENT’                         HTTP Semantics RFC 9110(11), Section 15.3.6
                                                    
                                                    
‘206’       ‘PARTIAL_CONTENT’                       HTTP Semantics RFC 9110(12), Section 15.3.7
                                                    
                                                    
‘207’       ‘MULTI_STATUS’                          WebDAV RFC 4918(13), Section 11.1
                                                    
                                                    
‘208’       ‘ALREADY_REPORTED’                      WebDAV Binding Extensions RFC 5842(14), Section 7.1 (Experimental)
                                                    
                                                    
‘226’       ‘IM_USED’                               Delta Encoding in HTTP RFC 3229(15), Section 10.4.1
                                                    
                                                    
‘300’       ‘MULTIPLE_CHOICES’                      HTTP Semantics RFC 9110(16), Section 15.4.1
                                                    
                                                    
‘301’       ‘MOVED_PERMANENTLY’                     HTTP Semantics RFC 9110(17), Section 15.4.2
                                                    
                                                    
‘302’       ‘FOUND’                                 HTTP Semantics RFC 9110(18), Section 15.4.3
                                                    
                                                    
‘303’       ‘SEE_OTHER’                             HTTP Semantics RFC 9110(19), Section 15.4.4
                                                    
                                                    
‘304’       ‘NOT_MODIFIED’                          HTTP Semantics RFC 9110(20), Section 15.4.5
                                                    
                                                    
‘305’       ‘USE_PROXY’                             HTTP Semantics RFC 9110(21), Section 15.4.6
                                                    
                                                    
‘307’       ‘TEMPORARY_REDIRECT’                    HTTP Semantics RFC 9110(22), Section 15.4.8
                                                    
                                                    
‘308’       ‘PERMANENT_REDIRECT’                    HTTP Semantics RFC 9110(23), Section 15.4.9
                                                    
                                                    
‘400’       ‘BAD_REQUEST’                           HTTP Semantics RFC 9110(24), Section 15.5.1
                                                    
                                                    
‘401’       ‘UNAUTHORIZED’                          HTTP Semantics RFC 9110(25), Section 15.5.2
                                                    
                                                    
‘402’       ‘PAYMENT_REQUIRED’                      HTTP Semantics RFC 9110(26), Section 15.5.3
                                                    
                                                    
‘403’       ‘FORBIDDEN’                             HTTP Semantics RFC 9110(27), Section 15.5.4
                                                    
                                                    
‘404’       ‘NOT_FOUND’                             HTTP Semantics RFC 9110(28), Section 15.5.5
                                                    
                                                    
‘405’       ‘METHOD_NOT_ALLOWED’                    HTTP Semantics RFC 9110(29), Section 15.5.6
                                                    
                                                    
‘406’       ‘NOT_ACCEPTABLE’                        HTTP Semantics RFC 9110(30), Section 15.5.7
                                                    
                                                    
‘407’       ‘PROXY_AUTHENTICATION_REQUIRED’         HTTP Semantics RFC 9110(31), Section 15.5.8
                                                    
                                                    
‘408’       ‘REQUEST_TIMEOUT’                       HTTP Semantics RFC 9110(32), Section 15.5.9
                                                    
                                                    
‘409’       ‘CONFLICT’                              HTTP Semantics RFC 9110(33), Section 15.5.10
                                                    
                                                    
‘410’       ‘GONE’                                  HTTP Semantics RFC 9110(34), Section 15.5.11
                                                    
                                                    
‘411’       ‘LENGTH_REQUIRED’                       HTTP Semantics RFC 9110(35), Section 15.5.12
                                                    
                                                    
‘412’       ‘PRECONDITION_FAILED’                   HTTP Semantics RFC 9110(36), Section 15.5.13
                                                    
                                                    
‘413’       ‘CONTENT_TOO_LARGE’                     HTTP Semantics RFC 9110(37), Section 15.5.14
                                                    
                                                    
‘414’       ‘URI_TOO_LONG’                          HTTP Semantics RFC 9110(38), Section 15.5.15
                                                    
                                                    
‘415’       ‘UNSUPPORTED_MEDIA_TYPE’                HTTP Semantics RFC 9110(39), Section 15.5.16
                                                    
                                                    
‘416’       ‘RANGE_NOT_SATISFIABLE’                 HTTP Semantics RFC 9110(40), Section 15.5.17
                                                    
                                                    
‘417’       ‘EXPECTATION_FAILED’                    HTTP Semantics RFC 9110(41), Section 15.5.18
                                                    
                                                    
‘418’       ‘IM_A_TEAPOT’                           HTCPCP/1.0 RFC 2324(42), Section 2.3.2
                                                    
                                                    
‘421’       ‘MISDIRECTED_REQUEST’                   HTTP Semantics RFC 9110(43), Section 15.5.20
                                                    
                                                    
‘422’       ‘UNPROCESSABLE_CONTENT’                 HTTP Semantics RFC 9110(44), Section 15.5.21
                                                    
                                                    
‘423’       ‘LOCKED’                                WebDAV RFC 4918(45), Section 11.3
                                                    
                                                    
‘424’       ‘FAILED_DEPENDENCY’                     WebDAV RFC 4918(46), Section 11.4
                                                    
                                                    
‘425’       ‘TOO_EARLY’                             Using Early Data in HTTP RFC 8470(47)
                                                    
                                                    
‘426’       ‘UPGRADE_REQUIRED’                      HTTP Semantics RFC 9110(48), Section 15.5.22
                                                    
                                                    
‘428’       ‘PRECONDITION_REQUIRED’                 Additional HTTP Status Codes RFC 6585(49)
                                                    
                                                    
‘429’       ‘TOO_MANY_REQUESTS’                     Additional HTTP Status Codes RFC 6585(50)
                                                    
                                                    
‘431’       ‘REQUEST_HEADER_FIELDS_TOO_LARGE’       Additional HTTP Status Codes RFC 6585(51)
                                                    
                                                    
‘451’       ‘UNAVAILABLE_FOR_LEGAL_REASONS’         An HTTP Status Code to Report Legal Obstacles RFC 7725(52)
                                                    
                                                    
‘500’       ‘INTERNAL_SERVER_ERROR’                 HTTP Semantics RFC 9110(53), Section 15.6.1
                                                    
                                                    
‘501’       ‘NOT_IMPLEMENTED’                       HTTP Semantics RFC 9110(54), Section 15.6.2
                                                    
                                                    
‘502’       ‘BAD_GATEWAY’                           HTTP Semantics RFC 9110(55), Section 15.6.3
                                                    
                                                    
‘503’       ‘SERVICE_UNAVAILABLE’                   HTTP Semantics RFC 9110(56), Section 15.6.4
                                                    
                                                    
‘504’       ‘GATEWAY_TIMEOUT’                       HTTP Semantics RFC 9110(57), Section 15.6.5
                                                    
                                                    
‘505’       ‘HTTP_VERSION_NOT_SUPPORTED’            HTTP Semantics RFC 9110(58), Section 15.6.6
                                                    
                                                    
‘506’       ‘VARIANT_ALSO_NEGOTIATES’               Transparent Content Negotiation in HTTP RFC 2295(59), Section 8.1 (Experimental)
                                                    
                                                    
‘507’       ‘INSUFFICIENT_STORAGE’                  WebDAV RFC 4918(60), Section 11.5
                                                    
                                                    
‘508’       ‘LOOP_DETECTED’                         WebDAV Binding Extensions RFC 5842(61), Section 7.2 (Experimental)
                                                    
                                                    
‘510’       ‘NOT_EXTENDED’                          An HTTP Extension Framework RFC 2774(62), Section 7 (Experimental)
                                                    
                                                    
‘511’       ‘NETWORK_AUTHENTICATION_REQUIRED’       Additional HTTP Status Codes RFC 6585(63), Section 6
                                                    

後方互換性を保つために列挙値は *note http.client: 65. にも定数という形で
存在します。 列挙名は定数名と同じです (すなわち ‘http.HTTPStatus.OK’ は
‘http.client.OK’ としても利用可能です)。

バージョン 3.7 で変更: ステータスコード ‘421 MISDIRECTED_REQUEST’ が追加
されました。

Added in version 3.8: ステータスコード ‘451
UNAVAILABLE_FOR_LEGAL_REASONS’ が追加されました。

Added in version 3.9: ステータスコード ‘103 EARLY_HINTS’, ‘418
IM_A_TEAPOT’, ‘425 TOO_EARLY’ が追加されました。

バージョン 3.13 で変更: ステータス定数に RFC9110 の名前を実装。古い定数
名は後方互換性のために保たれています。

   ---------- Footnotes ----------

   (1) 
https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

   (2) https://datatracker.ietf.org/doc/html/rfc9110.html

   (3) https://datatracker.ietf.org/doc/html/rfc9110.html

   (4) https://datatracker.ietf.org/doc/html/rfc2518.html

   (5) https://datatracker.ietf.org/doc/html/rfc8297.html

   (6) https://datatracker.ietf.org/doc/html/rfc9110.html

   (7) https://datatracker.ietf.org/doc/html/rfc9110.html

   (8) https://datatracker.ietf.org/doc/html/rfc9110.html

   (9) https://datatracker.ietf.org/doc/html/rfc9110.html

   (10) https://datatracker.ietf.org/doc/html/rfc9110.html

   (11) https://datatracker.ietf.org/doc/html/rfc9110.html

   (12) https://datatracker.ietf.org/doc/html/rfc9110.html

   (13) https://datatracker.ietf.org/doc/html/rfc4918.html

   (14) https://datatracker.ietf.org/doc/html/rfc5842.html

   (15) https://datatracker.ietf.org/doc/html/rfc3229.html

   (16) https://datatracker.ietf.org/doc/html/rfc9110.html

   (17) https://datatracker.ietf.org/doc/html/rfc9110.html

   (18) https://datatracker.ietf.org/doc/html/rfc9110.html

   (19) https://datatracker.ietf.org/doc/html/rfc9110.html

   (20) https://datatracker.ietf.org/doc/html/rfc9110.html

   (21) https://datatracker.ietf.org/doc/html/rfc9110.html

   (22) https://datatracker.ietf.org/doc/html/rfc9110.html

   (23) https://datatracker.ietf.org/doc/html/rfc9110.html

   (24) https://datatracker.ietf.org/doc/html/rfc9110.html

   (25) https://datatracker.ietf.org/doc/html/rfc9110.html

   (26) https://datatracker.ietf.org/doc/html/rfc9110.html

   (27) https://datatracker.ietf.org/doc/html/rfc9110.html

   (28) https://datatracker.ietf.org/doc/html/rfc9110.html

   (29) https://datatracker.ietf.org/doc/html/rfc9110.html

   (30) https://datatracker.ietf.org/doc/html/rfc9110.html

   (31) https://datatracker.ietf.org/doc/html/rfc9110.html

   (32) https://datatracker.ietf.org/doc/html/rfc9110.html

   (33) https://datatracker.ietf.org/doc/html/rfc9110.html

   (34) https://datatracker.ietf.org/doc/html/rfc9110.html

   (35) https://datatracker.ietf.org/doc/html/rfc9110.html

   (36) https://datatracker.ietf.org/doc/html/rfc9110.html

   (37) https://datatracker.ietf.org/doc/html/rfc9110.html

   (38) https://datatracker.ietf.org/doc/html/rfc9110.html

   (39) https://datatracker.ietf.org/doc/html/rfc9110.html

   (40) https://datatracker.ietf.org/doc/html/rfc9110.html

   (41) https://datatracker.ietf.org/doc/html/rfc9110.html

   (42) https://datatracker.ietf.org/doc/html/rfc2324.html

   (43) https://datatracker.ietf.org/doc/html/rfc9110.html

   (44) https://datatracker.ietf.org/doc/html/rfc9110.html

   (45) https://datatracker.ietf.org/doc/html/rfc4918.html

   (46) https://datatracker.ietf.org/doc/html/rfc4918.html

   (47) https://datatracker.ietf.org/doc/html/rfc8470.html

   (48) https://datatracker.ietf.org/doc/html/rfc9110.html

   (49) https://datatracker.ietf.org/doc/html/rfc6585.html

   (50) https://datatracker.ietf.org/doc/html/rfc6585.html

   (51) https://datatracker.ietf.org/doc/html/rfc6585.html

   (52) https://datatracker.ietf.org/doc/html/rfc7725.html

   (53) https://datatracker.ietf.org/doc/html/rfc9110.html

   (54) https://datatracker.ietf.org/doc/html/rfc9110.html

   (55) https://datatracker.ietf.org/doc/html/rfc9110.html

   (56) https://datatracker.ietf.org/doc/html/rfc9110.html

   (57) https://datatracker.ietf.org/doc/html/rfc9110.html

   (58) https://datatracker.ietf.org/doc/html/rfc9110.html

   (59) https://datatracker.ietf.org/doc/html/rfc2295.html

   (60) https://datatracker.ietf.org/doc/html/rfc4918.html

   (61) https://datatracker.ietf.org/doc/html/rfc5842.html

   (62) https://datatracker.ietf.org/doc/html/rfc2774.html

   (63) https://datatracker.ietf.org/doc/html/rfc6585.html


File: python.info,  Node: HTTP ステータスコードカテゴリ,  Next: HTTP メソッド,  Prev: HTTP ステータスコード,  Up: http --- HTTP モジュール群

5.21.9.2 HTTP ステータスコードカテゴリ
......................................

Added in version 3.12.

列挙型の値は HTTP ステータスカテゴリを示すいくつかのプロパティを持ちます
。

プロパティ               示していること               詳細
                                                      
-------------------------------------------------------------------------------------------------
                                                      
‘is_informational’       ‘100 <= status <= 199’       HTTP Semantics RFC 9110(1), Section 15
                                                      
                                                      
‘is_success’             ‘200 <= status <= 299’       HTTP Semantics RFC 9110(2), Section 15
                                                      
                                                      
‘is_redirection’         ‘300 <= status <= 399’       HTTP Semantics RFC 9110(3), Section 15
                                                      
                                                      
‘is_client_error’        ‘400 <= status <= 499’       HTTP Semantics RFC 9110(4), Section 15
                                                      
                                                      
‘is_server_error’        ‘500 <= status <= 599’       HTTP Semantics RFC 9110(5), Section 15
                                                      

     使い方:

          >>> from http import HTTPStatus
          >>> HTTPStatus.OK.is_success
          True
          >>> HTTPStatus.OK.is_client_error
          False

 -- クラス: http.HTTPMethod

     Added in version 3.11.

     一連の HTTP メソッド、英語で書かれた記述を定義した *note
     enum.StrEnum: 5e6. のサブクラスです。

     使い方:

          >>> from http import HTTPMethod
          >>>
          >>> HTTPMethod.GET
          <HTTPMethod.GET>
          >>> HTTPMethod.GET == 'GET'
          True
          >>> HTTPMethod.GET.value
          'GET'
          >>> HTTPMethod.GET.description
          'Retrieve the target.'
          >>> list(HTTPMethod)
          [<HTTPMethod.CONNECT>,
           <HTTPMethod.DELETE>,
           <HTTPMethod.GET>,
           <HTTPMethod.HEAD>,
           <HTTPMethod.OPTIONS>,
           <HTTPMethod.PATCH>,
           <HTTPMethod.POST>,
           <HTTPMethod.PUT>,
           <HTTPMethod.TRACE>]

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc9110.html

   (2) https://datatracker.ietf.org/doc/html/rfc9110.html

   (3) https://datatracker.ietf.org/doc/html/rfc9110.html

   (4) https://datatracker.ietf.org/doc/html/rfc9110.html

   (5) https://datatracker.ietf.org/doc/html/rfc9110.html


File: python.info,  Node: HTTP メソッド,  Prev: HTTP ステータスコードカテゴリ,  Up: http --- HTTP モジュール群

5.21.9.3 HTTP メソッド
......................

*note http.HTTPMethod: 38e0. で利用可能な、サポートされている、IANA に登
録されたメソッド(1) は:

メソッド        列挙名                                  詳細
                                                        
-------------------------------------------------------------------------------------------------------------------------------
                                                        
‘GET’           ‘GET’                                   HTTP Semantics RFC 9110(2), Section 9.3.1
                                                        
                                                        
‘HEAD’          ‘HEAD’                                  HTTP Semantics RFC 9110(3), Section 9.3.2
                                                        
                                                        
‘POST’          ‘POST’                                  HTTP Semantics RFC 9110(4), Section 9.3.3
                                                        
                                                        
‘PUT’           ‘PUT’                                   HTTP Semantics RFC 9110(5), Section 9.3.4
                                                        
                                                        
‘DELETE’        ‘DELETE’                                HTTP Semantics RFC 9110(6), Section 9.3.5
                                                        
                                                        
‘CONNECT’       ‘CONNECT’                               HTTP Semantics RFC 9110(7), Section 9.3.6
                                                        
                                                        
‘OPTIONS’       ‘OPTIONS’                               HTTP Semantics RFC 9110(8), Section 9.3.7
                                                        
                                                        
‘TRACE’         ‘TRACE’                                 HTTP Semantics RFC 9110(9), Section 9.3.8
                                                        
                                                        
‘PATCH’         ‘PATCH’                                 HTTP/1.1 RFC 5789(10)
                                                        

   ---------- Footnotes ----------

   (1) https://www.iana.org/assignments/http-methods/http-methods.xhtml

   (2) https://datatracker.ietf.org/doc/html/rfc9110.html

   (3) https://datatracker.ietf.org/doc/html/rfc9110.html

   (4) https://datatracker.ietf.org/doc/html/rfc9110.html

   (5) https://datatracker.ietf.org/doc/html/rfc9110.html

   (6) https://datatracker.ietf.org/doc/html/rfc9110.html

   (7) https://datatracker.ietf.org/doc/html/rfc9110.html

   (8) https://datatracker.ietf.org/doc/html/rfc9110.html

   (9) https://datatracker.ietf.org/doc/html/rfc9110.html

   (10) https://datatracker.ietf.org/doc/html/rfc5789.html


File: python.info,  Node: http client --- HTTP プロトコルクライアント,  Next: ftplib --- FTP プロトコルクライアント,  Prev: http --- HTTP モジュール群,  Up: インターネットプロトコルとサポート

5.21.10 ‘http.client’ -- HTTP プロトコルクライアント
----------------------------------------------------

'ソースコード:' Lib/http/client.py(1)

__________________________________________________________________

このモジュールでは HTTP および HTTPS プロトコルのクライアントサイドを実
装しているクラスを定義しています。通常、このモジュールは直接使いません
-- *note urllib.request: f4. モジュールが HTTP や HTTPS を使った URL を
扱う上でこのモジュールを使います。

参考
....

より高水準の HTTP クライアントインターフェースとして Requests パッケージ
(2) が推奨されています。

     注釈: HTTPS のサポートは、Python が SSL サポート付きでコンパイルさ
     れている場合にのみ利用できます (*note ssl: bb. モジュールによって
     )。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

このモジュールでは以下のクラスを提供しています:

 -- クラス: http.client.HTTPConnection (host, port=None[, timeout],
          source_address=None, blocksize=8192)

     *note HTTPConnection: b0e. インスタンスは、HTTP サーバとの一回のト
     ランザクションを表現します。 インスタンスの生成はホスト名とオプショ
     ンのポート番号を与えることで行います。 ポート番号を指定しなかった場
     合、ホスト名文字列が ‘host:port’ の形式であれば、ホスト名からポート
     番号を抽出し、そうでない場合には標準の HTTP ポート番号 (80) を使い
     ます。 オプションの引数 'timeout' が渡された場合、ブロックする処理
     (コネクション接続など) のタイムアウト時間(秒数)として利用されます
     (渡されなかった場合は、グローバルのデフォルトタイムアウト設定が利用
     されます)。 オプションの引数 'source_address' を (host, port) とい
     う形式のタプルにすると HTTP 接続の接続元アドレスとして使用します。
     オプションの 'blocksize' 引数は、送信するファイル類メッセージボディ
     のバッファサイズをバイト単位で設定します。

     例えば、以下の呼び出しは全て同じサーバの同じポートに接続するインス
     タンスを生成します:

          >>> h1 = http.client.HTTPConnection('www.python.org')
          >>> h2 = http.client.HTTPConnection('www.python.org:80')
          >>> h3 = http.client.HTTPConnection('www.python.org', 80)
          >>> h4 = http.client.HTTPConnection('www.python.org', 80, timeout=10)

     バージョン 3.2 で変更: 'source_address' が追加されました。

     バージョン 3.4 で変更: 'strict' パラメータは廃止されました。HTTP
     0.9 の "シンプルなレスポンス" のような形式はもはやサポートされませ
     ん。

     バージョン 3.7 で変更: 'blocksize' 引数が追加されました。

 -- クラス: http.client.HTTPSConnection (host, port=None, *[, timeout],
          source_address=None, context=None, blocksize=8192)

     *note HTTPConnection: b0e. のサブクラスはセキュア・サーバとやりとり
     する為の SSL を使う場合に用います。デフォルトのポート番号は ‘443’ で
     す。'context' が指定されれば、それは様々な SSL オプションを記述する
     *note ssl.SSLContext: 274. インスタンスでなければなりません。

     ベストプラクティスに関するより良い情報が *note
     セキュリティで考慮すべき点: 31f1. にありますのでお読みください。

     バージョン 3.2 で変更: 'source_address'、'context' そして
     'check_hostname' が追加されました。

     バージョン 3.2 で変更: このクラスは現在、可能であれば (つまり *note
     ssl.HAS_SNI: 3325. が真の場合) HTTPS のバーチャルホストをサポートし
     ています。

     バージョン 3.4 で変更: 'strict' パラメータは廃止されました。HTTP
     0.9 の "シンプルなレスポンス" のような形式はもはやサポートされませ
     ん。

     バージョン 3.4.3 で変更: このクラスは今や全ての必要な証明書とホスト
     名の検証をデフォルトで行うようになりました。 'context' パラメーター
     に ‘ssl._create_unverified_context()’ を渡すことで、昔の、検証を行
     わない振る舞いに戻すことができます。

     バージョン 3.8 で変更: This class now enables TLS 1.3 *note
     ssl.SSLContext.post_handshake_auth: 9ff. for the default 'context'
     or when 'cert_file' is passed with a custom 'context'.

     バージョン 3.10 で変更: This class now sends an ALPN extension with
     protocol indicator ‘http/1.1’ when no 'context' is given.  Custom
     'context' should set ALPN protocols with *note
     set_alpn_protocols(): e2d.

     バージョン 3.12 で変更: The deprecated 'key_file', 'cert_file' and
     'check_hostname' parameters have been removed.

 -- クラス: http.client.HTTPResponse (sock, debuglevel=0, method=None,
          url=None)

     コネクションに成功したときに、このクラスのインスタンスが返されます
     。ユーザーから直接利用されることはありません。

     バージョン 3.4 で変更: 'strict' パラメータは廃止されました。HTTP
     0.9 の "シンプルなレスポンス" のような形式はもはやサポートされませ
     ん。

このモジュールは以下の関数を提供します:

 -- の関数: http.client.parse_headers (fp)

     Parse the headers from a file pointer 'fp' representing a HTTP
     request/response.  The file has to be a *note BufferedIOBase: 660.
     reader (i.e.  not text) and must provide a valid RFC 2822(3) style
     header.

     This function returns an instance of *note http.client.HTTPMessage:
     38e5. that holds the header fields, but no payload (the same as
     *note HTTPResponse.msg: 38e6. and *note
     http.server.BaseHTTPRequestHandler.headers: 38e7.).  After
     returning, the file pointer 'fp' is ready to read the HTTP body.

          注釈: *note parse_headers(): 19b4. does not parse the
          start-line of a HTTP message; it only parses the ‘Name: value’
          lines.  The file has to be ready to read these field lines, so
          the first line should already be consumed before calling the
          function.

状況に応じて、以下の例外が送出されます:

 -- 例外: http.client.HTTPException

     このモジュールにおける他の例外クラスの基底クラスです。 *note
     Exception: 9a7. のサブクラスです。

 -- 例外: http.client.NotConnected

     *note HTTPException: 38e8. サブクラスです。

 -- 例外: http.client.InvalidURL

     *note HTTPException: 38e8. のサブクラスです。ポート番号を指定したも
     のの、その値が数字でなかったり空のオブジェクトであった場合に送出さ
     れます。

 -- 例外: http.client.UnknownProtocol

     *note HTTPException: 38e8. サブクラスです。

 -- 例外: http.client.UnknownTransferEncoding

     *note HTTPException: 38e8. サブクラスです。

 -- 例外: http.client.UnimplementedFileMode

     *note HTTPException: 38e8. サブクラスです。

 -- 例外: http.client.IncompleteRead

     *note HTTPException: 38e8. サブクラスです。

 -- 例外: http.client.ImproperConnectionState

     *note HTTPException: 38e8. サブクラスです。

 -- 例外: http.client.CannotSendRequest

     *note ImproperConnectionState: 38ef. のサブクラスです。

 -- 例外: http.client.CannotSendHeader

     *note ImproperConnectionState: 38ef. のサブクラスです。

 -- 例外: http.client.ResponseNotReady

     *note ImproperConnectionState: 38ef. のサブクラスです。

 -- 例外: http.client.BadStatusLine

     *note HTTPException: 38e8. のサブクラスです。サーバが理解できない
     HTTP 状態コードで応答した場合に送出されます。

 -- 例外: http.client.LineTooLong

     A subclass of *note HTTPException: 38e8.  Raised if an excessively
     long line is received in the HTTP protocol from the server.

 -- 例外: http.client.RemoteDisconnected

     A subclass of *note ConnectionResetError: 1033. and *note
     BadStatusLine: 38f3.  Raised by *note HTTPConnection.getresponse():
     dd5. when the attempt to read the response results in no data read
     from the connection, indicating that the remote end has closed the
     connection.

     Added in version 3.5: Previously, *note BadStatusLine: 38f3.‘('')’
     was raised.

このモジュールで定義されている定数は以下の通りです:

 -- データ: http.client.HTTP_PORT

     HTTP プロトコルの標準のポート (通常は ‘80’) です。

 -- データ: http.client.HTTPS_PORT

     HTTPS プロトコルの標準のポート (通常は ‘443’) です。

 -- データ: http.client.responses

     このディクショナリは、HTTP 1.1ステータスコードをW3Cの名前にマップし
     たものです。

     例: ‘http.client.responses[http.client.NOT_FOUND]’ は ‘'Not Found'’
     を示します。

See *note HTTP ステータスコード: 38dd. for a list of HTTP status codes
that are available in this module as constants.

* Menu:

* HTTPConnection オブジェクト::
* HTTPResponse オブジェクト::
* 使用例: 使用例<37>.
* HTTPMessage オブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/http/client.py

   (2) https://requests.readthedocs.io/en/latest/

   (3) https://datatracker.ietf.org/doc/html/rfc2822.html


File: python.info,  Node: HTTPConnection オブジェクト,  Next: HTTPResponse オブジェクト,  Up: http client --- HTTP プロトコルクライアント

5.21.10.1 HTTPConnection オブジェクト
.....................................

*note HTTPConnection: b0e. インスタンスには以下のメソッドがあります:

 -- メソッド: HTTPConnection.request (method, url, body=None,
          headers={}, *, encode_chunked=False)

     This will send a request to the server using the HTTP request
     method 'method' and the request URI 'url'.  The provided 'url' must
     be an absolute path to conform with RFC 2616 §5.1.2(1) (unless
     connecting to an HTTP proxy server or using the ‘OPTIONS’ or
     ‘CONNECT’ methods).

     If 'body' is specified, the specified data is sent after the
     headers are finished.  It may be a *note str: 418, a *note
     bytes-like object: cfb, an open *note file object: 1193, or an
     iterable of *note bytes: 1a4.  If 'body' is a string, it is encoded
     as ISO-8859-1, the default for HTTP. If it is a bytes-like object,
     the bytes are sent as is.  If it is a *note file object: 1193, the
     contents of the file is sent; this file object should support at
     least the ‘read()’ method.  If the file object is an instance of
     *note io.TextIOBase: 661, the data returned by the ‘read()’ method
     will be encoded as ISO-8859-1, otherwise the data returned by
     ‘read()’ is sent as is.  If 'body' is an iterable, the elements of
     the iterable are sent as is until the iterable is exhausted.

     The 'headers' argument should be a mapping of extra HTTP headers to
     send with the request.  A Host header(2) must be provided to
     conform with RFC 2616 §5.1.2(3) (unless connecting to an HTTP proxy
     server or using the ‘OPTIONS’ or ‘CONNECT’ methods).

     If 'headers' contains neither Content-Length nor Transfer-Encoding,
     but there is a request body, one of those header fields will be
     added automatically.  If 'body' is ‘None’, the Content-Length
     header is set to ‘0’ for methods that expect a body (‘PUT’, ‘POST’,
     and ‘PATCH’).  If 'body' is a string or a bytes-like object that is
     not also a *note file: 1193, the Content-Length header is set to
     its length.  Any other type of 'body' (files and iterables in
     general) will be chunk-encoded, and the Transfer-Encoding header
     will automatically be set instead of Content-Length.

     The 'encode_chunked' argument is only relevant if Transfer-Encoding
     is specified in 'headers'.  If 'encode_chunked' is ‘False’, the
     HTTPConnection object assumes that all encoding is handled by the
     calling code.  If it is ‘True’, the body will be chunk-encoded.

     For example, to perform a ‘GET’ request to
     ‘https://docs.python.org/3/’:

          >>> import http.client
          >>> host = "docs.python.org"
          >>> conn = http.client.HTTPSConnection(host)
          >>> conn.request("GET", "/3/", headers={"Host": host})
          >>> response = conn.getresponse()
          >>> print(response.status, response.reason)
          200 OK

          注釈: Chunked transfer encoding has been added to the HTTP
          protocol version 1.1.  Unless the HTTP server is known to
          handle HTTP 1.1, the caller must either specify the
          Content-Length, or must pass a *note str: 418. or bytes-like
          object that is not also a file as the body representation.

     バージョン 3.2 で変更: 'body' は iterable オブジェクトとして使用で
     きます。

     バージョン 3.6 で変更: If neither Content-Length nor
     Transfer-Encoding are set in 'headers', file and iterable 'body'
     objects are now chunk-encoded.  The 'encode_chunked' argument was
     added.  No attempt is made to determine the Content-Length for file
     objects.

 -- メソッド: HTTPConnection.getresponse ()

     サーバに対して HTTP 要求を送り出した後に呼び出されなければりません
     。要求に対する応答を取得します。 *note HTTPResponse: 10a1. インスタ
     ンスを返します。

          注釈: すべての応答を読み込んでからでなければ新しい要求をサーバ
          に送ることはできないことに注意しましょう。

     バージョン 3.5 で変更: If a *note ConnectionError: dd7. or subclass
     is raised, the *note HTTPConnection: b0e. object will be ready to
     reconnect when a new request is sent.

 -- メソッド: HTTPConnection.set_debuglevel (level)

     Set the debugging level.  The default debug level is ‘0’, meaning
     no debugging output is printed.  Any value greater than ‘0’ will
     cause all currently defined debug output to be printed to stdout.
     The ‘debuglevel’ is passed to any new *note HTTPResponse: 10a1.
     objects that are created.

     Added in version 3.1.

 -- メソッド: HTTPConnection.set_tunnel (host, port=None, headers=None)

     HTTP トンネリング接続のホスト名とポート番号を設定します。これにより
     プロキシサーバを通しての接続を実行できます。

     The 'host' and 'port' arguments specify the endpoint of the
     tunneled connection (i.e.  the address included in the CONNECT
     request, 'not' the address of the proxy server).

     The 'headers' argument should be a mapping of extra HTTP headers to
     send with the CONNECT request.

     As HTTP/1.1 is used for HTTP CONNECT tunnelling request, as per the
     RFC(4), a HTTP ‘Host:’ header must be provided, matching the
     authority-form of the request target provided as the destination
     for the CONNECT request.  If a HTTP ‘Host:’ header is not provided
     via the headers argument, one is generated and transmitted
     automatically.

     For example, to tunnel through a HTTPS proxy server running locally
     on port 8080, we would pass the address of the proxy to the *note
     HTTPSConnection: b0f. constructor, and the address of the host that
     we eventually want to reach to the *note set_tunnel(): 11f9.
     method:

          >>> import http.client
          >>> conn = http.client.HTTPSConnection("localhost", 8080)
          >>> conn.set_tunnel("www.python.org")
          >>> conn.request("HEAD","/index.html")

     Added in version 3.2.

     バージョン 3.12 で変更: HTTP CONNECT tunnelling requests use
     protocol HTTP/1.1, upgraded from protocol HTTP/1.0.  ‘Host:’ HTTP
     headers are mandatory for HTTP/1.1, so one will be automatically
     generated and transmitted if not provided in the headers argument.

 -- メソッド: HTTPConnection.get_proxy_response_headers ()

     Returns a dictionary with the headers of the response received from
     the proxy server to the CONNECT request.

     If the CONNECT request was not sent, the method returns ‘None’.

     Added in version 3.12.

 -- メソッド: HTTPConnection.connect ()

     Connect to the server specified when the object was created.  By
     default, this is called automatically when making a request if the
     client does not already have a connection.

     Raises an *note auditing event: 1825. ‘http.client.connect’ with
     arguments ‘self’, ‘host’, ‘port’.

 -- メソッド: HTTPConnection.close ()

     サーバへの接続を閉じます。

 -- の属性: HTTPConnection.blocksize

     Buffer size in bytes for sending a file-like message body.

     Added in version 3.7.

As an alternative to using the *note request(): c77. method described
above, you can also send your request step by step, by using the four
functions below.

 -- メソッド: HTTPConnection.putrequest (method, url, skip_host=False,
          skip_accept_encoding=False)

     サーバへの接続が確立したら、最初にこのメソッドを呼び出さなくてはな
     りません。このメソッドは 'method' 文字列、'url' 文字列、そして HTTP
     バージョン (‘HTTP/1.1’) からなる一行を送信します。‘Host:’ や
     ‘Accept-Encoding:’ ヘッダの自動送信を無効にしたい場合 (例えば別のコ
     ンテンツエンコーディングを受け入れたい場合) には、'skip_host' や
     'skip_accept_encoding' を偽でない値に設定してください。

 -- メソッド: HTTPConnection.putheader (header, argument[, ...])

     RFC 822(5) 形式のヘッダをサーバに送ります。この処理では、 'header'
     、コロンとスペース、そして最初の引数からなる 1 行をサーバに送ります
     。追加の引数を指定した場合、継続して各行にタブ一つと引数の入った引
     数行が送信されます。

 -- メソッド: HTTPConnection.endheaders (message_body=None, *,
          encode_chunked=False)

     サーバに空行を送り、ヘッダ部が終了したことを通知します。オプション
     の 'message_body' 引数を、リクエストに関連したメッセージボディを渡
     すのに使うことが出来ます。

     If 'encode_chunked' is ‘True’, the result of each iteration of
     'message_body' will be chunk-encoded as specified in RFC 7230(6),
     Section 3.3.1.  How the data is encoded is dependent on the type of
     'message_body'.  If 'message_body' implements the *note buffer
     interface: 371. the encoding will result in a single chunk.  If
     'message_body' is a *note collections.abc.Iterable: 21ab, each
     iteration of 'message_body' will result in a chunk.  If
     'message_body' is a *note file object: 1193, each call to ‘.read()’
     will result in a chunk.  The method automatically signals the end
     of the chunk-encoded data immediately after 'message_body'.

          注釈: Due to the chunked encoding specification, empty chunks
          yielded by an iterator body will be ignored by the
          chunk-encoder.  This is to avoid premature termination of the
          read of the request by the target server due to malformed
          encoding.

     バージョン 3.6 で変更: Added chunked encoding support and the
     'encode_chunked' parameter.

 -- メソッド: HTTPConnection.send (data)

     サーバにデータを送ります。このメソッドは *note endheaders(): c78. が
     呼び出された直後で、かつ *note getresponse(): dd5. が呼び出される前
     に使わなければなりません。

     Raises an *note auditing event: 1825. ‘http.client.send’ with
     arguments ‘self’, ‘data’.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2616.html#section-5.1.2

   (2) https://datatracker.ietf.org/doc/html/rfc2616.html#section-14.23

   (3) https://datatracker.ietf.org/doc/html/rfc2616.html#section-5.1.2

   (4) https://datatracker.ietf.org/doc/html/rfc7231#section-4.3.6

   (5) https://datatracker.ietf.org/doc/html/rfc822.html

   (6) https://datatracker.ietf.org/doc/html/rfc7230.html


File: python.info,  Node: HTTPResponse オブジェクト,  Next: 使用例<37>,  Prev: HTTPConnection オブジェクト,  Up: http client --- HTTP プロトコルクライアント

5.21.10.2 HTTPResponse オブジェクト
...................................

*note HTTPResponse: 10a1. インスタンスはサーバからのHTTPレスポンスをラッ
プします。これを使用してリクエストヘッダとエンティティボディへアクセスす
ることができます。レスポンスはイテレート可能なオブジェクトであり、また
with文と使うことも可能です。

バージョン 3.5 で変更: The *note io.BufferedIOBase: 660. interface is
now implemented and all of its reader operations are supported.

 -- メソッド: HTTPResponse.read ([amt])

     応答の本体全体か、'amt' バイトまで読み出して返します。

 -- メソッド: HTTPResponse.readinto (b)

     バッファ 'b' にレスポンスボディの次のデータを最大 len(b) バイト読み
     込みます。何バイト読んだかを返します。

     Added in version 3.3.

 -- メソッド: HTTPResponse.getheader (name, default=None)

     Return the value of the header 'name', or 'default' if there is no
     header matching 'name'.  If there is more than one header with the
     name 'name', return all of the values joined by ', '.  If 'default'
     is any iterable other than a single string, its elements are
     similarly returned joined by commas.

 -- メソッド: HTTPResponse.getheaders ()

     (header, value) のタプルからなるリストを返します。

 -- メソッド: HTTPResponse.fileno ()

     ソケットの ‘fileno’ を返します。

 -- の属性: HTTPResponse.msg

     A *note http.client.HTTPMessage: 38e5. instance containing the
     response headers.  *note http.client.HTTPMessage: 38e5. is a
     subclass of *note email.message.Message: 25d.

 -- の属性: HTTPResponse.version

     サーバが使用した HTTP プロトコルバージョンです。10 は HTTP/1.0 を、
     11 は HTTP/1.1 を表します。

 -- の属性: HTTPResponse.url

     取得されたリソースの URL、主にリダイレクトが発生したかどうかを確認
     するために利用します。

 -- の属性: HTTPResponse.headers

     Headers of the response in the form of an *note
     email.message.EmailMessage: 25c. instance.

 -- の属性: HTTPResponse.status

     サーバから返される状態コードです。

 -- の属性: HTTPResponse.reason

     サーバから返される応答の理由文です。

 -- の属性: HTTPResponse.debuglevel

     A debugging hook.  If *note debuglevel: 390a. is greater than zero,
     messages will be printed to stdout as the response is read and
     parsed.

 -- の属性: HTTPResponse.closed

     ストリームが閉じている場合 ‘True’ となります。

 -- メソッド: HTTPResponse.geturl ()

     バージョン 3.9 で非推奨: 非推奨となったので *note url: 3907. を使用
     してください。

 -- メソッド: HTTPResponse.info ()

     バージョン 3.9 で非推奨: 非推奨となったので *note headers: 3908. を
     使用してください。

 -- メソッド: HTTPResponse.getcode ()

     バージョン 3.9 で非推奨: 非推奨となったので *note status: 3909. を
     使用してください。


File: python.info,  Node: 使用例<37>,  Next: HTTPMessage オブジェクト,  Prev: HTTPResponse オブジェクト,  Up: http client --- HTTP プロトコルクライアント

5.21.10.3 使用例
................

以下は ‘GET’ リクエストの送信方法を示した例です:

     >>> import http.client
     >>> conn = http.client.HTTPSConnection("www.python.org")
     >>> conn.request("GET", "/")
     >>> r1 = conn.getresponse()
     >>> print(r1.status, r1.reason)
     200 OK
     >>> data1 = r1.read()  # This will return entire content.
     >>> # The following example demonstrates reading data in chunks.
     >>> conn.request("GET", "/")
     >>> r1 = conn.getresponse()
     >>> while chunk := r1.read(200):
     ...     print(repr(chunk))
     b'<!doctype html>\n<!--[if"...
     ...
     >>> # Example of an invalid request
     >>> conn = http.client.HTTPSConnection("docs.python.org")
     >>> conn.request("GET", "/parrot.spam")
     >>> r2 = conn.getresponse()
     >>> print(r2.status, r2.reason)
     404 Not Found
     >>> data2 = r2.read()
     >>> conn.close()

次の例のセッションでは、‘HEAD’ メソッドを利用しています。‘HEAD’ メソッド
は全くデータを返さないことに注目してください。

     >>> import http.client
     >>> conn = http.client.HTTPSConnection("www.python.org")
     >>> conn.request("HEAD", "/")
     >>> res = conn.getresponse()
     >>> print(res.status, res.reason)
     200 OK
     >>> data = res.read()
     >>> print(len(data))
     0
     >>> data == b''
     True

Here is an example session that uses the ‘POST’ method:

     >>> import http.client, urllib.parse
     >>> params = urllib.parse.urlencode({'@number': 12524, '@type': 'issue', '@action': 'show'})
     >>> headers = {"Content-type": "application/x-www-form-urlencoded",
     ...            "Accept": "text/plain"}
     >>> conn = http.client.HTTPConnection("bugs.python.org")
     >>> conn.request("POST", "", params, headers)
     >>> response = conn.getresponse()
     >>> print(response.status, response.reason)
     302 Found
     >>> data = response.read()
     >>> data
     b'Redirecting to <a href="https://bugs.python.org/issue12524">https://bugs.python.org/issue12524</a>'
     >>> conn.close()

Client side HTTP ‘PUT’ requests are very similar to ‘POST’ requests.
The difference lies only on the server side where HTTP servers will
allow resources to be created via ‘PUT’ requests.  It should be noted
that custom HTTP methods are also handled in *note
urllib.request.Request: fa5. by setting the appropriate method
attribute.  Here is an example session that uses the ‘PUT’ method:

     >>> # This creates an HTTP request
     >>> # with the content of BODY as the enclosed representation
     >>> # for the resource http://localhost:8080/file
     ...
     >>> import http.client
     >>> BODY = "***filecontents***"
     >>> conn = http.client.HTTPConnection("localhost", 8080)
     >>> conn.request("PUT", "/file", BODY)
     >>> response = conn.getresponse()
     >>> print(response.status, response.reason)
     200, OK


File: python.info,  Node: HTTPMessage オブジェクト,  Prev: 使用例<37>,  Up: http client --- HTTP プロトコルクライアント

5.21.10.4 HTTPMessage オブジェクト
..................................

 -- クラス: http.client.HTTPMessage (email.message.Message)

*note http.client.HTTPMessage: 38e5. のインスタンスは HTTP レスポンスヘ
ッダを格納します。 *note email.message.Message: 25d. クラスを利用して実
装されています。


File: python.info,  Node: ftplib --- FTP プロトコルクライアント,  Next: poplib --- POP3 プロトコルクライアント,  Prev: http client --- HTTP プロトコルクライアント,  Up: インターネットプロトコルとサポート

5.21.11 ‘ftplib’ -- FTP プロトコルクライアント
----------------------------------------------

'ソースコード:' Lib/ftplib.py(1)

__________________________________________________________________

このモジュールでは *note FTP: 8c8. クラスと、それに関連するいくつかの項
目を定義しています。 *note FTP: 8c8. クラスは、FTPプロトコルのクライアン
ト側の機能を備えています。このクラスを使うとFTPのいろいろな機能の自動化
、例えば他のFTPサーバのミラーリングといったことを実行するPythonプログラ
ムを書くことができます。また、 *note urllib.request: f4. モジュールも
FTPを使うURLを操作するのにこのクラスを使っています。 FTP (File Transfer
Protocol)についての詳しい情報はinternet RFC 959(2) を参照して下さい。

The default encoding is UTF-8, following RFC 2640(3).

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

*note ftplib: 54. モジュールを使ったサンプルを以下に示します:

     >>> from ftplib import FTP
     >>> ftp = FTP('ftp.us.debian.org')  # connect to host, default port
     >>> ftp.login()                     # user anonymous, passwd anonymous@
     '230 Login successful.'
     >>> ftp.cwd('debian')               # change into "debian" directory
     '250 Directory successfully changed.'
     >>> ftp.retrlines('LIST')           # list directory contents
     -rw-rw-r--    1 1176     1176         1063 Jun 15 10:18 README
     ...
     drwxr-sr-x    5 1176     1176         4096 Dec 19  2000 pool
     drwxr-sr-x    4 1176     1176         4096 Nov 17  2008 project
     drwxr-xr-x    3 1176     1176         4096 Oct 10  2012 tools
     '226 Directory send OK.'
     >>> with open('README', 'wb') as fp:
     >>>     ftp.retrbinary('RETR README', fp.write)
     '226 Transfer complete.'
     >>> ftp.quit()
     '221 Goodbye.'

* Menu:

* リファレンス: リファレンス<5>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/ftplib.py

   (2) https://datatracker.ietf.org/doc/html/rfc959.html

   (3) https://datatracker.ietf.org/doc/html/rfc2640.html


File: python.info,  Node: リファレンス<5>,  Up: ftplib --- FTP プロトコルクライアント

5.21.11.1 リファレンス
......................

* Menu:

* FTP オブジェクト::
* FTP_TLS オブジェクト::
* モジュール変数::


File: python.info,  Node: FTP オブジェクト,  Next: FTP_TLS オブジェクト,  Up: リファレンス<5>

5.21.11.2 FTP オブジェクト
..........................

 -- クラス: ftplib.FTP (host='', user='', passwd='', acct='',
          timeout=None, source_address=None, *, encoding='utf-8')

     Return a new instance of the *note FTP: 8c8. class.


     パラメータ:

        * ‘host’ (*note str: 418.) - The hostname to connect to.  If
          given, ‘connect(host)’ is implicitly called by the
          constructor.

        * ‘user’ (*note str: 418.) - The username to log in with
          (default: ‘'anonymous'’).  If given, ‘login(host, passwd,
          acct)’ is implicitly called by the constructor.

        * ‘passwd’ (*note str: 418.) - The password to use when logging
          in.  If not given, and if 'passwd' is the empty string or
          ‘"-"’, a password will be automatically generated.

        * ‘acct’ (*note str: 418.) - Account information to be used for
          the ‘ACCT’ FTP command.  Few systems implement this.  See
          RFC-959(1) for more details.

        * ‘timeout’ (*note float: 2ce.‘ | ’‘None’) - A timeout in
          seconds for blocking operations like *note connect(): 3918.
          (default: the global default timeout setting).

        * ‘source_address’ (*note tuple: 349.‘ | ’‘None’) - A 2-tuple
          ‘(host, port)’ for the socket to bind to as its source address
          before connecting.

        * ‘encoding’ (*note str: 418.) - The encoding for directories
          and filenames (default: ‘'utf-8'’).

     *note FTP: 8c8. クラスは *note with: 59c. 文をサポートしています。
     例えば:

          >>> from ftplib import FTP
          >>> with FTP("ftp1.at.proftpd.org") as ftp:
          ...     ftp.login()
          ...     ftp.dir()
          ...
          '230 Anonymous login ok, restrictions apply.'
          dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 .
          dr-xr-xr-x   9 ftp      ftp           154 May  6 10:43 ..
          dr-xr-xr-x   5 ftp      ftp          4096 May  6 10:43 CentOS
          dr-xr-xr-x   3 ftp      ftp            18 Jul 10  2008 Fedora
          >>>

     バージョン 3.2 で変更: *note with: 59c. 構文のサポートが追加されま
     した。

     バージョン 3.3 で変更: 'source_address' 引数が追加されました。

     バージョン 3.9 で変更: If the 'timeout' parameter is set to be
     zero, it will raise a *note ValueError: 1e3. 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(2).

     Several ‘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.

     *note FTP: 8c8. インスタンスには以下のメソッドがあります:

      -- メソッド: set_debuglevel (level)

          Set the instance's debugging level as an *note int: 238.  This
          controls the amount of debugging output printed.  The debug
          levels are:

             * ‘0’ (default): No debug output.

             * ‘1’: Produce a moderate amount of debug output, generally
               a single line per request.

             * ‘2’ or higher: Produce the maximum amount of debugging
               output, logging each line sent and received on the
               control connection.

      -- メソッド: connect (host='', port=0, timeout=None,
               source_address=None)

          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 *note FTP: 8c8. instance
          was created.  All other ‘FTP’ methods can only be called after
          a connection has successfully been made.


          パラメータ:

             * ‘host’ (*note str: 418.) - The host to connect to.

             * ‘port’ (*note int: 238.) - 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.

             * ‘timeout’ (*note float: 2ce.‘ | ’‘None’) - A timeout in
               seconds for the connection attempt (default: the global
               default timeout setting).

             * ‘source_address’ (*note tuple: 349.‘ | ’‘None’) - A
               2-tuple ‘(host, port)’ for the socket to bind to as its
               source address before connecting.

          引数 ‘self’, ‘host’, ‘port’ を指定して *note 監査イベント:
          1825. ‘ftplib.connect’ を送出します。

          バージョン 3.3 で変更: 'source_address' 引数が追加されました。

      -- メソッド: getwelcome ()

          サーバに最初に接続した際に送信される応答中のウェルカムメッセー
          ジを返します。(このメッセージには時に、ユーザにとって重要な免
          責事項や ヘルプ情報が入っています。)

      -- メソッド: login (user='anonymous', passwd='', acct='')

          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 called if the 'host' and
          'user' arguments were given when the *note FTP: 8c8. instance
          was created.  Most FTP commands are only allowed after the
          client has logged in.


          パラメータ:

             * ‘user’ (*note str: 418.) - The username to log in with
               (default: ‘'anonymous'’).

             * ‘passwd’ (*note str: 418.) - The password to use when
               logging in.  If not given, and if 'passwd' is the empty
               string or ‘"-"’, a password will be automatically
               generated.

             * ‘acct’ (*note str: 418.) - Account information to be used
               for the ‘ACCT’ FTP command.  Few systems implement this.
               See RFC-959(3) for more details.

      -- メソッド: abort ()

          実行中のファイル転送を中止します。これはいつも機能するわけでは
          ありませんが、やってみる価値はあります。

      -- メソッド: sendcmd (cmd)

          シンプルなコマンド文字列をサーバに送信して、受信した文字列を返
          します。

          引数 ‘self’, ‘cmd’ を指定して *note 監査イベント: 1825.
          ‘ftplib.sendcmd’ を送出します。

      -- メソッド: voidcmd (cmd)

          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
          *note error_reply: 391f. otherwise.

          引数 ‘self’, ‘cmd’ を指定して *note 監査イベント: 1825.
          ‘ftplib.sendcmd’ を送出します。

      -- メソッド: retrbinary (cmd, callback, blocksize=8192, rest=None)

          Retrieve a file in binary transfer mode.


          パラメータ:

             * ‘cmd’ (*note str: 418.) - An appropriate ‘RETR’ command:
               ‘"RETR FILENAME"’.

             * ‘callback’ (*note callable: 2847.) - A single parameter
               callable that is called for each block of data received,
               with its single argument being the data as *note bytes:
               1a4.

             * ‘blocksize’ (*note int: 238.) - The maximum chunk size to
               read on the low-level *note socket: d6e. 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’.

             * ‘rest’ (*note int: 238.) - A ‘REST’ command to be sent to
               the server.  See the documentation for the 'rest'
               parameter of the *note transfercmd(): 3921. method.

      -- メソッド: retrlines (cmd, callback=None)

          Retrieve a file or directory listing in the encoding specified
          by the 'encoding' parameter at initialization.  'cmd' should
          be an appropriate ‘RETR’ command (see *note retrbinary():
          3920.) or a command such as ‘LIST’ or ‘NLST’ (usually just the
          string ‘'LIST'’).  ‘LIST’ retrieves a list of files and
          information about those files.  ‘NLST’ retrieves a list of
          file names.  The 'callback' function is called for each line
          with a string argument containing the line with the trailing
          CRLF stripped.  The default 'callback' prints the line to
          *note sys.stdout: aa4.

      -- メソッド: set_pasv (val)

          'val' が真の場合 "パッシブ" モードを有効化し、偽の場合は無効化
          します。 デフォルトではパッシブモードです。

      -- メソッド: storbinary (cmd, fp, blocksize=8192, callback=None,
               rest=None)

          Store a file in binary transfer mode.


          パラメータ:

             * ‘cmd’ (*note str: 418.) - An appropriate ‘STOR’ command:
               ‘"STOR FILENAME"’.

             * ‘fp’ (*note file object: 1193.) - A file object (opened
               in binary mode) which is read until EOF, using its *note
               read(): de9. method in blocks of size 'blocksize' to
               provide the data to be stored.

             * ‘blocksize’ (*note int: 238.) - The read block size.
               Defaults to ‘8192’.

             * ‘callback’ (*note callable: 2847.) - A single parameter
               callable that is called for each block of data sent, with
               its single argument being the data as *note bytes: 1a4.

             * ‘rest’ (*note int: 238.) - A ‘REST’ command to be sent to
               the server.  See the documentation for the 'rest'
               parameter of the *note transfercmd(): 3921. method.

          バージョン 3.2 で変更: The 'rest' parameter was added.

      -- メソッド: storlines (cmd, fp, callback=None)

          Store a file in line mode.  'cmd' should be an appropriate
          ‘STOR’ command (see *note storbinary(): 12d8.).  Lines are
          read until EOF from the *note file object: 1193. 'fp' (opened
          in binary mode) using its *note readline(): 12f8. 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.

      -- メソッド: transfercmd (cmd, rest=None)

          データ接続中に転送を初期化します。もし転送中なら、‘EPRT’ ある
          いは ‘PORT’ コマンドと、'cmd' で指定したコマンドを送信し、接続
          を続けます。サーバがパッシブなら、‘EPSV’ あるいは ‘PASV’ コマ
          ンドを送信して接続し、転送コマンドを開始します。どちらの場合も
          、接続のためのソケットを返します。

          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 requested file, telling the server to
          restart sending the file's bytes at the requested offset,
          skipping over the initial bytes.  Note however that the *note
          transfercmd(): 3921. method converts 'rest' to a string with
          the 'encoding' parameter specified at initialization, but no
          check is performed on the string's contents.  If the server
          does not recognize the ‘REST’ command, an *note error_reply:
          391f. exception will be raised.  If this happens, simply call
          *note transfercmd(): 3921. without a 'rest' argument.

      -- メソッド: ntransfercmd (cmd, rest=None)

          *note transfercmd(): 3921. と同様ですが、データと予想されるサ
          イズとのタプルを返します。もしサイズが計算できないなら、サイズ
          の代わりに ‘None’ が返されます。 'cmd' と 'rest' は *note
          transfercmd(): 3921. のものと同じです。

      -- メソッド: mlsd (path='', facts=[])

          List a directory in a standardized format by using ‘MLSD’
          command ( RFC 3659(4)).  If 'path' is omitted the current
          directory is assumed.  'facts' is a list of strings
          representing the type of information desired (e.g.  ‘["type",
          "size", "perm"]’).  Return a generator object yielding a tuple
          of two elements for every file found in path.  First element
          is the file name, the second one is a dictionary containing
          facts about the file name.  Content of this dictionary might
          be limited by the 'facts' argument but server is not
          guaranteed to return all requested facts.

          Added in version 3.3.

      -- メソッド: nlst (argument[, ...])

          ‘NLST’ コマンドで返されるファイル名のリストを返します。省略可
          能な 'argument' は、リストアップするディレクトリです（デフォル
          トではサーバのカレントディレクトリです）。 ‘NLST’ コマンドに非
          標準である複数の引数を渡すことができます。

               注釈: If your server supports the command, *note mlsd():
               1095. offers a better API.

      -- メソッド: dir (argument[, ...])

          Produce a directory listing as returned by the ‘LIST’ command,
          printing it to standard output.  The optional 'argument' is a
          directory to list (default is the current server directory).
          Multiple arguments can be used to pass non-standard options to
          the ‘LIST’ command.  If the last argument is a function, it is
          used as a 'callback' function as for *note retrlines(): 3922.;
          the default prints to *note sys.stdout: aa4.  This method
          returns ‘None’.

               注釈: If your server supports the command, *note mlsd():
               1095. offers a better API.

      -- メソッド: rename (fromname, toname)

          サーバ上のファイルのファイル名 'fromname' を 'toname' へ変更し
          ます。

      -- メソッド: delete (filename)

          サーバからファイル 'filename' を削除します。成功したら応答のテ
          キストを返し、そうでないならパーミッションエラーでは *note
          error_perm: 3928. を、他のエラーでは *note error_reply: 391f.
          を返します。

      -- メソッド: cwd (pathname)

          サーバのカレントディレクトリを設定します。

      -- メソッド: mkd (pathname)

          サーバ上に新たにディレクトリを作ります。

      -- メソッド: pwd ()

          サーバ上のカレントディレクトリのパスを返します。

      -- メソッド: rmd (dirname)

          サーバ上のディレクトリ 'dirname' を削除します。

      -- メソッド: size (filename)

          サーバ上のファイル 'filename' のサイズを尋ねます。成功したらフ
          ァイルサイズが整数で返され、そうでないなら ‘None’ が返されます
          。 ‘SIZE’ コマンドは標準化されていませんが、多くの普通のサーバ
          で実装されていることに注意して下さい。

      -- メソッド: quit ()

          サーバに ‘QUIT’ コマンドを送信し、接続を閉じます。これは接続を
          閉じるのに"礼儀正しい"方法ですが、 ‘QUIT’ コマンドに反応してサ
          ーバの例外が発生するかもしれません。この例外は、 *note
          close(): 392f. メソッドによって *note FTP: 8c8. インスタンスに
          対するその後のコマンド使用が不可になっていることを示しています
          （下記参照）。

      -- メソッド: close ()

          接続を一方的に閉じます。既に閉じた接続に対して実行すべきではあ
          りません（例えば *note quit(): 392e. を呼び出して成功した後な
          ど）。この実行の後、 *note FTP: 8c8. インスタンスはもう使用す
          べきではありません（ *note close(): 392f. あるいは *note
          quit(): 392e. を呼び出した後で、 *note login(): 391b. メソッド
          をもう一度実行して再び接続を開くことはできません）。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc959.html

   (2) https://datatracker.ietf.org/doc/html/rfc2640.html

   (3) https://datatracker.ietf.org/doc/html/rfc959.html

   (4) https://datatracker.ietf.org/doc/html/rfc3659.html


File: python.info,  Node: FTP_TLS オブジェクト,  Next: モジュール変数,  Prev: FTP オブジェクト,  Up: リファレンス<5>

5.21.11.3 FTP_TLS オブジェクト
..............................

 -- クラス: ftplib.FTP_TLS (host='', user='', passwd='', acct='', *,
          context=None, timeout=None, source_address=None,
          encoding='utf-8')

     An *note FTP: 8c8. subclass which adds TLS support to FTP as
     described in RFC 4217(1).  Connect to port 21 implicitly securing
     the FTP control connection before authenticating.

          注釈: The user must explicitly secure the data connection by
          calling the *note prot_p(): 3931. method.


     パラメータ:

        * ‘host’ (*note str: 418.) - The hostname to connect to.  If
          given, ‘connect(host)’ is implicitly called by the
          constructor.

        * ‘user’ (*note str: 418.) - The username to log in with
          (default: ‘'anonymous'’).  If given, ‘login(host, passwd,
          acct)’ is implicitly called by the constructor.

        * ‘passwd’ (*note str: 418.) - The password to use when logging
          in.  If not given, and if 'passwd' is the empty string or
          ‘"-"’, a password will be automatically generated.

        * ‘acct’ (*note str: 418.) - Account information to be used for
          the ‘ACCT’ FTP command.  Few systems implement this.  See
          RFC-959(2) for more details.

        * ‘context’ (*note ssl.SSLContext: 274.) - An SSL context object
          which allows bundling SSL configuration options, certificates
          and private keys into a single, potentially long-lived,
          structure.  Please read *note セキュリティで考慮すべき点:
          31f1. for best practices.

        * ‘timeout’ (*note float: 2ce.‘ | ’‘None’) - A timeout in
          seconds for blocking operations like *note connect(): 3918.
          (default: the global default timeout setting).

        * ‘source_address’ (*note tuple: 349.‘ | ’‘None’) - A 2-tuple
          ‘(host, port)’ for the socket to bind to as its source address
          before connecting.

        * ‘encoding’ (*note str: 418.) - The encoding for directories
          and filenames (default: ‘'utf-8'’).

     Added in version 3.2.

     バージョン 3.3 で変更: Added the 'source_address' parameter.

     バージョン 3.4 で変更: このクラスは *note
     ssl.SSLContext.check_hostname: 3313. と 'Server Name Indication' で
     ホスト名のチェックをサポートしました。(*note ssl.HAS_SNI: 3325. を
     参照してください)。

     バージョン 3.9 で変更: If the 'timeout' parameter is set to be
     zero, it will raise a *note ValueError: 1e3. 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(3).

     バージョン 3.12 で変更: 非推奨の 'keyfile' と 'certfile' 引数を削除
     しました。

     *note FTP_TLS: 8c9. クラスを使ったサンプルセッションはこちらです:

          >>> ftps = FTP_TLS('ftp.pureftpd.org')
          >>> ftps.login()
          '230 Anonymous user logged in'
          >>> ftps.prot_p()
          '200 Data protection level set to "private"'
          >>> ftps.nlst()
          ['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']

     ‘FTP_TLS’ class inherits from *note FTP: 8c8, defining these
     additional methods and attributes:

      -- の属性: ssl_version

          The SSL version to use (defaults to *note ssl.PROTOCOL_SSLv23:
          3317.).

      -- メソッド: auth ()

          *note ssl_version: 3932. 属性で指定されたものに従って、 TLS ま
          たは SSL を使い、セキュアコントロール接続をセットアップします
          。

          バージョン 3.4 で変更: The method now supports hostname check
          with *note ssl.SSLContext.check_hostname: 3313. and 'Server
          Name Indication' (see *note ssl.HAS_SNI: 3325.).

      -- メソッド: ccc ()

          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.

          Added in version 3.3.

      -- メソッド: prot_p ()

          セキュアデータ接続をセットアップします。

      -- メソッド: prot_c ()

          平文データ接続をセットアップします。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc4217.html

   (2) https://datatracker.ietf.org/doc/html/rfc959.html

   (3) https://datatracker.ietf.org/doc/html/rfc2640.html


File: python.info,  Node: モジュール変数,  Prev: FTP_TLS オブジェクト,  Up: リファレンス<5>

5.21.11.4 モジュール変数
........................

 -- 例外: ftplib.error_reply

     サーバから想定外の応答があったときに送出される例外。

 -- 例外: ftplib.error_temp

     一時的エラーを表すエラーコード(400-499の範囲の応答コード)を受け取っ
     た時に発生する例外。

 -- 例外: ftplib.error_perm

     永久エラーを表すエラーコード(500-599の範囲の応答コード)を受け取った
     時に発生する例外。

 -- 例外: ftplib.error_proto

     File Transfer Protocol の応答仕様に適合しない、すなわち1-5の数字で
     始まらない応答コードをサーバから受け取った時に発生する例外。

 -- データ: ftplib.all_errors

     *note FTP: 8c8. インスタンスのメソッド実行時、FTP接続で (プログラミ
     ングのエラーと考えられるメソッドの実行によって) 発生する全ての例外
     (タプル形式)。この例外には以上の４つのエラーはもちろん、 *note
     OSError: 3f0. と *note EOFError: 12a7. も含まれます。

参考
....

*note netrc: 8d. モジュール

     ‘.netrc’ ファイルフォーマットのパーザ。 ‘.netrc’ ファイルは、 FTPク
     ライアントがユーザにプロンプトを出す前に、ユーザ認証情報をロードす
     るのによく使われます。


File: python.info,  Node: poplib --- POP3 プロトコルクライアント,  Next: imaplib --- IMAP4 プロトコルクライアント,  Prev: ftplib --- FTP プロトコルクライアント,  Up: インターネットプロトコルとサポート

5.21.12 ‘poplib’ -- POP3 プロトコルクライアント
-----------------------------------------------

'ソースコード:' Lib/poplib.py(1)

__________________________________________________________________

このモジュールはクラス *note POP3: 8f2. を定義しています。 *note POP3:
8f2. はPOP3 サーバへの接続をカプセル化し、 RFC 1939(2) で定義されている
プロトコルを実装しています。 *note POP3: 8f2. クラスは RFC 1939(3) の最
小限のコマンドセットとオプションのコマンドセットをサポートしています。 既
に確立されている接続で暗号化された通信を行うために、 RFC 2595(4) で導入
された ‘STLS’ コマンドもサポートされています。

加えて、このモジュールはクラス *note POP3_SSL: 8f3. を提供しています。
*note POP3_SSL: 8f3. は SSL を下層のプロトコルレイヤーとして使う POP3 サ
ーバへの接続をサポートしています。

POP3についての注意事項は、それが広くサポートされているにもかかわらず、既
に時代遅れだということです。幾つも実装されているPOP3サーバーの品質は、貧
弱なものが多数を占めています。もし、お使いのメールサーバーがIMAPをサポー
トしているなら、 *note imaplib.IMAP4: 8d1. クラスが使えます。 IMAPサーバ
ーは、より良く実装されている傾向があります。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

*note poplib: 9a. モジュールは二つのクラスを提供します:

 -- クラス: poplib.POP3 (host, port=POP3_PORT[, timeout])

     このクラスが、実際にPOP3プロトコルを実装します。インスタンスが初期
     化されるときに、コネクションが作成されます。 'port' が省略されると
     、POP3標準のポート(110)が使われます。オプションの 'timeout' 引数は
     、接続時のタイムアウト時間を秒数で指定します (指定されなかった場合
     は、グローバルのデフォルトタイムアウト設定が利用されます)。

     引数 ‘self’, ‘host’, ‘port’ 付きで *note 監査イベント: 1825.
     ‘poplib.connect’ を送出します。

     全てのコマンドは引数 ‘self’ と ‘line’ を指定して *note auditing
     event: 1825. ‘poplib.putline’ を送出します。ここで ‘line’ はリモー
     トホストに送信されるバイト数です。

     バージョン 3.9 で変更: 'timeout' パラメータが0に設定されている場合
     、非ブロッキングソケットの作成を防ぐために *note ValueError: 1e3. を
     送出します。

 -- クラス: poplib.POP3_SSL (host, port=POP3_SSL_PORT, *, timeout=None,
          context=None)

     *note POP3: 8f2. クラスのサブクラスで、SSL でカプセル化されたソケッ
     トによる POP サーバへの接続を提供します。 'port' が指定されていない
     場合、 POP3-over-SSL 標準の 995 番ポートが使われます。'timeout' に
     ついては *note POP3: 8f2. クラスのコンストラクタの引数と同じです。
     'context' は SSL の設定、証明書、秘密鍵を一つの (POP3_SSL オブジェ
     クトよりも長く存在し続けうる) 構造にまとめた *note ssl.SSLContext:
     274. オブジェクトで、省略可能です。ベストプラクティスについては
     *note セキュリティで考慮すべき点: 31f1. を参照してください。

     引数 ‘self’, ‘host’, ‘port’ 付きで *note 監査イベント: 1825.
     ‘poplib.connect’ を送出します。

     全てのコマンドは引数 ‘self’ と ‘line’ を指定して *note auditing
     event: 1825. ‘poplib.putline’ を送出します。ここで ‘line’ はリモー
     トホストに送信されるバイト数です。

     バージョン 3.2 で変更: 'context' 引数が追加されました。

     バージョン 3.4 で変更: このクラスは *note
     ssl.SSLContext.check_hostname: 3313. と 'Server Name Indication' で
     ホスト名のチェックをサポートしました。(*note ssl.HAS_SNI: 3325. を
     参照してください)。

     バージョン 3.9 で変更: 'timeout' パラメータが0に設定されている場合
     、非ブロッキングソケットの作成を防ぐために *note ValueError: 1e3. を
     送出します。

     バージョン 3.12 で変更: 非推奨の 'keyfile' と 'certfile' 引数を削除
     しました。

1つの例外が、 *note poplib: 9a. モジュールのアトリビュートとして定義され
ています:

 -- 例外: poplib.error_proto

     このモジュール内で起こったあらゆるエラーで送出される例外です (*note
     socket: b8. モジュールからのエラーは捕捉されません)。例外の理由は文
     字列としてコンストラクタに渡されます。

参考
....

モジュール *note imaplib: 6a.

     標準 Python IMAP モジュールです。

Frequently Asked Questions About Fetchmail(5)

     POP/IMAPクライアント ‘fetchmail’ のFAQ。POPプロトコルをベースにした
     アプリケーションを書くときに有用な、POP3サーバの種類や RFCへの適合
     度といった情報を収集しています。

* Menu:

* POP3 オブジェクト::
* POP3 の例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/poplib.py

   (2) https://datatracker.ietf.org/doc/html/rfc1939.html

   (3) https://datatracker.ietf.org/doc/html/rfc1939.html

   (4) https://datatracker.ietf.org/doc/html/rfc2595.html

   (5) http://www.catb.org/~esr/fetchmail/fetchmail-FAQ.html


File: python.info,  Node: POP3 オブジェクト,  Next: POP3 の例,  Up: poplib --- POP3 プロトコルクライアント

5.21.12.1 POP3 オブジェクト
...........................

POP3コマンドはすべて、それと同じ名前のメソッドとして小文字で表現されます
。そしてそのほとんどは、サーバからのレスポンスとなるテキストを返します。

*note POP3: 8f2. クラスのインスタンスは以下のメソッドを持ちます:

 -- メソッド: POP3.set_debuglevel (level)

     インスタンスのデバッグレベルを設定します。この設定によってデバッグ
     時に出力される量を調節します。デフォルトは ‘0’ で、何も出力されませ
     ん。 ‘1’ なら、一般的に１つのコマンドあたり１行の適当な量のデバッグ
     出力を行います。 ‘2’ 以上なら、コントロール接続で受信した各行を出力
     して、最大のデバッグ出力をします。

 -- メソッド: POP3.getwelcome ()

     POP3サーバーから送られるグリーティングメッセージを返します。

 -- メソッド: POP3.capa ()

     RFC 2449(1) で規定されている機能についてサーバに問い合わせます。
     ‘{'name': ['param'...]}’ という形の辞書を返します。

     Added in version 3.4.

 -- メソッド: POP3.user (username)

     userコマンドを送出します。応答はパスワード要求を表示します。

 -- メソッド: POP3.pass_ (password)

     パスワードを送出します。応答は、メッセージ数とメールボックスのサイ
     ズを含みます。注意：サーバー上のメールボックスは *note quit():
     116d. が呼ばれるまでロックされます。

 -- メソッド: POP3.apop (user, secret)

     POP3サーバーにログオンするのに、よりセキュアなAPOP認証を使用します
     。

 -- メソッド: POP3.rpop (user)

     POP3サーバーにログオンするのに、（UNIXのr-コマンドと同様の）RPOP認
     証を使用します。

 -- メソッド: POP3.stat ()

     メールボックスの状態を得ます。結果は2つのintegerからなるタプルとな
     ります。 ‘(message count, mailbox size)’.

 -- メソッド: POP3.list ([which])

     メッセージのリストを要求します。結果は ‘(response, ['mesg_num
     octets', ...], octets)’ という形式で表されます。 'which' が与えられ
     ると、それによりメッセージを指定します。

 -- メソッド: POP3.retr (which)

     'which' 番のメッセージ全体を取り出し、そのメッセージに既読フラグを
     立てます。結果は ‘(response, ['line', ...], octets)’ という形式で表
     されます。

 -- メソッド: POP3.dele (which)

     'which' 番のメッセージに削除のためのフラグを立てます。ほとんどのサ
     ーバで、QUITコマンドが実行されるまでは実際の削除は行われません（も
     っとも良く知られた例外は Eudora QPOPで、その配送メカニズムはRFCに違
     反しており、どんな切断状況でも削除操作を未解決にしています）。

 -- メソッド: POP3.rset ()

     メールボックスの削除マークすべてを取り消します。

 -- メソッド: POP3.noop ()

     何もしません。接続保持のために使われます。

 -- メソッド: POP3.quit ()

     サインオフ: 変更をコミットし、メールボックスをアンロックして、接続
     を破棄します。

 -- メソッド: POP3.top (which, howmuch)

     メッセージヘッダと 'howmuch' で指定した行数のメッセージを、 'which'
     で指定したメッセージ分取り出します。結果は以下のような形式となりま
     す。 ‘(response, ['line', ...], octets)’.

     このメソッドはPOP3のTOPコマンドを利用し、RETRコマンドのように、メッ
     セージに既読フラグをセットしません。残念ながら、TOPコマンドはRFCで
     は貧弱な仕様しか定義されておらず、しばしばノーブランドのサーバーで
     は（その仕様が）守られていません。このメソッドを信用してしまう前に
     、実際に使用するPOPサーバーでテストをしてください。

 -- メソッド: POP3.uidl (which=None)

     （ユニークIDによる）メッセージダイジェストのリストを返します。
     'which' が設定されている場合、結果はユニークIDを含みます。それは
     ‘'response mesgnum uid’ という形式のメッセージ、または ‘(response,
     ['mesgnum uid', ...], octets)’ という形式のリストとなります。

 -- メソッド: POP3.utf8 ()

     UTF-8 モードへの切り替えを試行します。成功した場合はサーバの応答を
     返し、失敗した場合は *note error_proto: 116e. を送出します。 RFC
     6856(2) で規定されています。

     Added in version 3.5.

 -- メソッド: POP3.stls (context=None)

     アクティブな接続にて RFC 2595(3) で定められた方法で TLS セッション
     を開始します。TLS セッションはユーザ認証を行う前に開始する必要があ
     ります。

     'context' は SSL の設定、証明書、秘密鍵を一つの (POP3 オブジェクト
     よりも長く存在し続けうる) 構造にまとめた *note ssl.SSLContext: 274.
     オブジェクトです。ベストプラクティスについては *note
     セキュリティで考慮すべき点: 31f1. を参照してください。

     このメソッドは *note ssl.SSLContext.check_hostname: 3313. と
     'Server Name Indication' でホスト名のチェックをサポートしました。
     (*note ssl.HAS_SNI: 3325. を参照してください)。

     Added in version 3.4.

*note POP3_SSL: 8f3. クラスのインスタンスは追加のメソッドを持ちません。
このサブクラスのインターフェイスは親クラスと同じです。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2449.html

   (2) https://datatracker.ietf.org/doc/html/rfc6856.html

   (3) https://datatracker.ietf.org/doc/html/rfc2595.html


File: python.info,  Node: POP3 の例,  Prev: POP3 オブジェクト,  Up: poplib --- POP3 プロトコルクライアント

5.21.12.2 POP3 の例
...................

以下にメールボックスを開き、全てのメッセージを取得して印刷する最小の (エ
ラーチェックをしない) 使用例を示します:

     import getpass, poplib

     M = poplib.POP3('localhost')
     M.user(getpass.getuser())
     M.pass_(getpass.getpass())
     numMessages = len(M.list()[1])
     for i in range(numMessages):
         for j in M.retr(i+1)[1]:
             print(j)

モジュールの末尾に、より拡張的な使用例が収められたテストセクションがあり
ます。


File: python.info,  Node: imaplib --- IMAP4 プロトコルクライアント,  Next: smtplib --- SMTP プロトコルクライアント,  Prev: poplib --- POP3 プロトコルクライアント,  Up: インターネットプロトコルとサポート

5.21.13 ‘imaplib’ -- IMAP4 プロトコルクライアント
-------------------------------------------------

'ソースコード:' Lib/imaplib.py(1)

__________________________________________________________________

このモジュールでは三つのクラス、 *note IMAP4: 8d1, *note IMAP4_SSL: 8d2.
と *note IMAP4_stream: 8d4. を定義します。これらのクラスは IMAP4 サーバ
への接続をカプセル化し、 RFC 2060(2) に定義されている IMAP4rev1 クライア
ントプロトコルの大規模なサブセットを実装しています。このクラスは IMAP4 (
RFC 1730(3)) 準拠のサーバと後方互換性がありますが、 ‘STATUS’ コマンドは
IMAP4 ではサポートされていないので注意してください。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

*note imaplib: 6a. モジュール内では三つのクラスを提供しており、 *note
IMAP4: 8d1. は基底クラスとなります:

 -- クラス: imaplib.IMAP4 (host='', port=IMAP4_PORT, timeout=None)

     This class implements the actual IMAP4 protocol.  The connection is
     created and protocol version (IMAP4 or IMAP4rev1) is determined
     when the instance is initialized.  If 'host' is not specified, ‘''’
     (the local host) is used.  If 'port' is omitted, the standard IMAP4
     port (143) is used.  The optional 'timeout' parameter specifies a
     timeout in seconds for the connection attempt.  If timeout is not
     given or is ‘None’, the global default socket timeout is used.

     The *note IMAP4: 8d1. class supports the *note with: 59c.
     statement.  When used like this, the IMAP4 ‘LOGOUT’ command is
     issued automatically when the ‘with’ statement exits.  E.g.:

          >>> from imaplib import IMAP4
          >>> with IMAP4("domain.org") as M:
          ...     M.noop()
          ...
          ('OK', [b'Nothing Accomplished. d25if65hy903weo.87'])

     バージョン 3.5 で変更: *note with: 59c. 構文のサポートが追加されま
     した。

     バージョン 3.9 で変更: オプションの 'timeout' 引数が追加されました
     。

例外は *note IMAP4: 8d1. クラスの属性として定義されています:

 -- 例外: IMAP4.error

     何らかのエラー発生の際に送出される例外です。例外の理由は文字列とし
     てコンストラクタに渡されます。

 -- 例外: IMAP4.abort

     IMAP4 サーバのエラーが生じると、この例外が送出されます。この例外は
     *note IMAP4.error: 394f. のサブクラスです。通常、インスタンスを閉じ
     、新たなインスタンスを再び生成することで、この例外から復旧できます
     。

 -- 例外: IMAP4.readonly

     この例外は書き込み可能なメールボックスの状態がサーバによって変更さ
     れた際に送出されます。この例外は *note IMAP4.error: 394f. のサブク
     ラスです。他の何らかのクライアントが現在書き込み権限を獲得しており
     、メールボックスを開きなおして書き込み権限を再獲得する必要がありま
     す。

このモジュールではもう一つ、安全 (secure) な接続を使ったサブクラスがあり
ます:

 -- クラス: imaplib.IMAP4_SSL (host='', port=IMAP4_SSL_PORT, *,
          ssl_context=None, timeout=None)

     This is a subclass derived from *note IMAP4: 8d1. that connects
     over an SSL encrypted socket (to use this class you need a socket
     module that was compiled with SSL support).  If 'host' is not
     specified, ‘''’ (the local host) is used.  If 'port' is omitted,
     the standard IMAP4-over-SSL port (993) is used.  'ssl_context' is a
     *note ssl.SSLContext: 274. object which allows bundling SSL
     configuration options, certificates and private keys into a single
     (potentially long-lived) structure.  Please read *note
     セキュリティで考慮すべき点: 31f1. for best practices.

     The optional 'timeout' parameter specifies a timeout in seconds for
     the connection attempt.  If timeout is not given or is ‘None’, the
     global default socket timeout is used.

     バージョン 3.3 で変更: 'ssl_context' 引数が追加されました。

     バージョン 3.4 で変更: このクラスは *note
     ssl.SSLContext.check_hostname: 3313. と 'Server Name Indication' で
     ホスト名のチェックをサポートしました。(*note ssl.HAS_SNI: 3325. を
     参照してください)。

     バージョン 3.9 で変更: オプションの 'timeout' 引数が追加されました
     。

     バージョン 3.12 で変更: 非推奨の 'keyfile' と 'certfile' 引数を削除
     しました。

さらにもう一つのサブクラスは、子プロセスで確立した接続を使用する場合に使
用します:

 -- クラス: imaplib.IMAP4_stream (command)

     *note IMAP4: 8d1. から派生したサブクラスで、 'command' を
     ‘subprocess.Popen()’ に渡して作成される ‘stdin/stdout’ ディスクリプ
     タと接続します。

以下のユーティリティ関数が定義されています:

 -- の関数: imaplib.Internaldate2tuple (datestr)

     IMAP4 の ‘INTERNALDATE’ 文字列を解析してそれに相当するローカルタイ
     ムを返します。戻り値は *note time.struct_time: cb8. のタプルか、文
     字列のフォーマットが不正な場合は ‘None’ です。

 -- の関数: imaplib.Int2AP (num)

     整数を [‘A’ ..  ‘P’] からなる文字集合を用いて表現した bytes に変換
     します。

 -- の関数: imaplib.ParseFlags (flagstr)

     IMAP4 ‘FLAGS’ 応答を個々のフラグからなるタプルに変換します。

 -- の関数: imaplib.Time2Internaldate (date_time)

     Convert 'date_time' to an IMAP4 ‘INTERNALDATE’ representation.  The
     return value is a string in the form: ‘"DD-Mmm-YYYY HH:MM:SS
     +HHMM"’ (including double-quotes).  The 'date_time' argument can be
     a number (int or float) representing seconds since epoch (as
     returned by *note time.time(): 235.), a 9-tuple representing local
     time an instance of *note time.struct_time: cb8. (as returned by
     *note time.localtime(): 14a2.), an aware instance of *note
     datetime.datetime: 1ae, or a double-quoted string.  In the last
     case, it is assumed to already be in the correct format.

IMAP4 メッセージ番号は、メールボックスに対する変更が行われた後には変化し
ます; 特に、‘EXPUNGE’ 命令はメッセージの削除を行いますが、残ったメッセー
ジには再度番号を振りなおします。従って、メッセージ番号ではなく、UID 命令
を使い、その UID を利用するよう強く勧めます。

モジュールの末尾に、より拡張的な使用例が収められたテストセクションがあり
ます。

参考
....

Documents describing the protocol, sources for servers implementing it,
by the University of Washington's IMAP Information Center can all be
found at ('Source Code') ‘https://github.com/uw-imap/imap’ ('Not
Maintained').

* Menu:

* IMAP4 オブジェクト::
* IMAP4 の使用例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/imaplib.py

   (2) https://datatracker.ietf.org/doc/html/rfc2060.html

   (3) https://datatracker.ietf.org/doc/html/rfc1730.html


File: python.info,  Node: IMAP4 オブジェクト,  Next: IMAP4 の使用例,  Up: imaplib --- IMAP4 プロトコルクライアント

5.21.13.1 IMAP4 オブジェクト
............................

All IMAP4rev1 commands are represented by methods of the same name,
either uppercase or lowercase.

命令に対する引数は全て文字列に変換されます。例外は ‘AUTHENTICATE’ の引数
と ‘APPEND’ の最後の引数で、これは IMAP4 リテラルとして渡されます。必要
に応じて (IMAP4 プロトコルが感知対象としている文字が文字列に入っており、
かつ丸括弧か二重引用符で囲われていなかった場合) 文字列はクオートされます
。しかし、‘LOGIN’ 命令の 'password' 引数は常にクオートされます。文字列が
クオートされないようにしたい (例えば ‘STORE’ 命令の 'flags' 引数) 場合、
文字列を丸括弧で囲んでください (例: ‘r'(\Deleted)'’)。

各命令はタプル: ‘(type, [data, ...])’ を返し、'type' は通常 ‘'OK'’ また
は ‘'NO'’ です。'data' は命令に対する応答をテキストにしたものか、命令に
対する実行結果です。各 'data' は ‘bytes’ かタプルとなります。タプルの場
合、最初の要素はレスポンスのヘッダで、次の要素にはデータが格納されます
(ie: 'literal' value)。

以下のコマンドにおける 'message_set' オプションは、操作の対象となるひと
つあるいは複数のメッセージを指す文字列です。単一のメッセージ番号 (‘'1'’)
かメッセージ番号の範囲 (‘'2:4'’)、あるいは連続していないメッセージをカン
マでつなげたもの (‘'1:3,6:9'’) となります。範囲指定でアスタリスクを使用
すると、上限を無限とすることができます (‘'3:*'’)。

*note IMAP4: 8d1. のインスタンスは以下のメソッドを持っています:

 -- メソッド: IMAP4.append (mailbox, flags, date_time, message)

     指定された名前のメールボックスに 'message' を追加します。

 -- メソッド: IMAP4.authenticate (mechanism, authobject)

     認証命令です -- 応答の処理が必要です。

     'mechanism' は利用する認証メカニズムを与えます。認証メカニズムはイ
     ンスタンス変数 ‘capabilities’ の中に ‘AUTH=mechanism’ という形式で
     現れる必要があります。

     'authobject' は呼び出し可能なオブジェクトである必要があります:

          data = authobject(response)

     It will be called to process server continuation responses; the
     'response' argument it is passed will be ‘bytes’.  It should return
     ‘bytes’ 'data' that will be base64 encoded and sent to the server.
     It should return ‘None’ if the client abort response ‘*’ should be
     sent instead.

     バージョン 3.5 で変更: string usernames and passwords are now
     encoded to ‘utf-8’ instead of being limited to ASCII.

 -- メソッド: IMAP4.check ()

     サーバ上のメールボックスにチェックポイントを設定します。

 -- メソッド: IMAP4.close ()

     現在選択されているメールボックスを閉じます。削除されたメッセージは
     書き込み可能メールボックスから除去されます。‘LOGOUT’ 前に実行するこ
     とを勧めます。

 -- メソッド: IMAP4.copy (message_set, new_mailbox)

     'message_set' で指定したメッセージ群を 'new_mailbox' の末尾にコピー
     します。

 -- メソッド: IMAP4.create (mailbox)

     'mailbox' と名づけられた新たなメールボックスを生成します。

 -- メソッド: IMAP4.delete (mailbox)

     'mailbox' と名づけられた古いメールボックスを削除します。

 -- メソッド: IMAP4.deleteacl (mailbox, who)

     mailbox における who についてのACLを削除(権限を削除)します。

 -- メソッド: IMAP4.enable (capability)

     Enable 'capability' (see RFC 5161(1)).  Most capabilities do not
     need to be enabled.  Currently only the ‘UTF8=ACCEPT’ capability is
     supported (see RFC 6855(2)).

     Added in version 3.5: The *note enable(): dda. method itself, and
     RFC 6855(3) support.

 -- メソッド: IMAP4.expunge ()

     選択されたメールボックスから削除された要素を永久に除去します。各々
     の削除されたメッセージに対して、‘EXPUNGE’ 応答を生成します。返され
     るデータには ‘EXPUNGE’ メッセージ番号を受信した順番に並べたリストが
     入っています。

 -- メソッド: IMAP4.fetch (message_set, message_parts)

     メッセージ (の一部) を取りよせます。'message_parts' はメッセージパ
     ートの名前を表す文字列を丸括弧で囲ったもので、例えば: ‘"(UID
     BODY[TEXT])"’ のようになります。返されるデータはメッセージパートの
     エンベロープ情報とデータからなるタプルです。

 -- メソッド: IMAP4.getacl (mailbox)

     'mailbox' に対する ‘ACL’ を取得します。このメソッドは非標準ですが、
     ‘Cyrus’ サーバでサポートされています。

 -- メソッド: IMAP4.getannotation (mailbox, entry, attribute)

     'mailbox' に対する ‘ANNOTATION’ を取得します。このメソッドは非標準
     ですが、‘Cyrus’ サーバでサポートされています。

 -- メソッド: IMAP4.getquota (root)

     ‘quota’ 'root' により、リソース使用状況と制限値を取得します。このメ
     ソッドは RFC 2087(4) で定義されている IMAP4 QUOTA 拡張の一部です。

 -- メソッド: IMAP4.getquotaroot (mailbox)

     'mailbox' に対して ‘quota’ 'root' を実行した結果のリストを取得しま
     す。このメソッドは RFC 2087(5) で定義されている IMAP4 QUOTA 拡張の
     一部です。

 -- メソッド: IMAP4.list ([directory[, pattern]])

     'pattern' にマッチする 'directory' メールボックス名を列挙します。
     'directory' の標準の設定値は最上レベルのメールフォルダで、'pattern'
     は標準の設定では全てにマッチします。返されるデータには ‘LIST’ 応答
     のリストが入っています。

 -- メソッド: IMAP4.login (user, password)

     平文パスワードを使ってクライアントを照合します。'password' はクオー
     トされます。

 -- メソッド: IMAP4.login_cram_md5 (user, password)

     パスワードの保護のため、クライアント認証時に ‘CRAM-MD5’ だけを使用
     します。これは、‘CAPABILITY’ レスポンスに ‘AUTH=CRAM-MD5’ が含まれ
     る場合のみ有効です。

 -- メソッド: IMAP4.logout ()

     サーバへの接続を遮断します。サーバからの ‘BYE’ 応答を返します。

     バージョン 3.8 で変更: The method no longer ignores silently
     arbitrary exceptions.

 -- メソッド: IMAP4.lsub (directory='""', pattern='*')

     購読しているメールボックス名のうち、ディレクトリ内でパターンにマッ
     チするものを列挙します。'directory' の標準の設定値は最上レベルのメ
     ールフォルダで、'pattern' は標準の設定では全てにマッチします。返さ
     れるデータには返されるデータはメッセージパートエンベロープ情報とデ
     ータからなるタプルです。

 -- メソッド: IMAP4.myrights (mailbox)

     mailboxにおける自分のACLを返します (すなわち自分がmailboxで持ってい
     る権限を返します)。

 -- メソッド: IMAP4.namespace ()

     RFC 2342(6) で定義されるIMAP名前空間を返します。

 -- メソッド: IMAP4.noop ()

     サーバに ‘NOOP’ を送信します。

 -- メソッド: IMAP4.open (host, port, timeout=None)

     Opens socket to 'port' at 'host'.  The optional 'timeout' parameter
     specifies a timeout in seconds for the connection attempt.  If
     timeout is not given or is ‘None’, the global default socket
     timeout is used.  Also note that if the 'timeout' parameter is set
     to be zero, it will raise a *note ValueError: 1e3. to reject
     creating a non-blocking socket.  This method is implicitly called
     by the *note IMAP4: 8d1. constructor.  The connection objects
     established by this method will be used in the *note IMAP4.read():
     396d, *note IMAP4.readline(): 396e, *note IMAP4.send(): 396f, and
     *note IMAP4.shutdown(): 3970. methods.  You may override this
     method.

     引数 ‘self’, ‘host’, ‘port’ を指定して *note 監査イベント: 1825.
     ‘imaplib.open’ を送出します。

     バージョン 3.9 で変更: 'timeout' 引数が追加されました。

 -- メソッド: IMAP4.partial (message_num, message_part, start, length)

     メッセージの後略された部分を取り寄せます。返されるデータはメッセー
     ジパートエンベロープ情報とデータからなるタプルです。

 -- メソッド: IMAP4.proxyauth (user)

     'user' として認証されたものとします。認証された管理者がユーザの代理
     としてメールボックスにアクセスする際に使用します。

 -- メソッド: IMAP4.read (size)

     遠隔のサーバから 'size' バイト読み出します。このメソッドはオーバラ
     イドすることができます。

 -- メソッド: IMAP4.readline ()

     遠隔のサーバから一行読み出します。このメソッドはオーバライドするこ
     とができます。

 -- メソッド: IMAP4.recent ()

     サーバに更新を促します。新たなメッセージがない場合応答は ‘None’ に
     なり、そうでない場合 ‘RECENT’ 応答の値になります。

 -- メソッド: IMAP4.rename (oldmailbox, newmailbox)

     'oldmailbox' という名前のメールボックスを 'newmailbox' に名称変更し
     ます。

 -- メソッド: IMAP4.response (code)

     応答 'code' を受信していれば、そのデータを返し、そうでなければ
     ‘None’ を返します。通常の形式 (usual type) ではなく指定したコードを
     返します。

 -- メソッド: IMAP4.search (charset, criterion[, ...])

     Search mailbox for matching messages.  'charset' may be ‘None’, in
     which case no ‘CHARSET’ will be specified in the request to the
     server.  The IMAP protocol requires that at least one criterion be
     specified; an exception will be raised when the server returns an
     error.  'charset' must be ‘None’ if the ‘UTF8=ACCEPT’ capability
     was enabled using the *note enable(): dda. command.

     以下はプログラム例です:

          # M is a connected IMAP4 instance...
          typ, msgnums = M.search(None, 'FROM', '"LDJ"')

          # or:
          typ, msgnums = M.search(None, '(FROM "LDJ")')

 -- メソッド: IMAP4.select (mailbox='INBOX', readonly=False)

     メールボックスを選択します。返されるデータは 'mailbox' 内のメッセー
     ジ数 (‘EXISTS’ 応答) です。標準の設定では 'mailbox' は ‘'INBOX'’ で
     す。'readonly' が設定された場合、メールボックスに対する変更はできま
     せん。

 -- メソッド: IMAP4.send (data)

     遠隔のサーバに ‘data’ を送信します。このメソッドはオーバライドする
     ことができます。

     引数 ‘self’, ‘data’ を指定して *note 監査イベント: 1825.
     ‘imaplib.send’ を送出します。

 -- メソッド: IMAP4.setacl (mailbox, who, what)

     ‘ACL’ を 'mailbox' に設定します。このメソッドは非標準ですが、
     ‘Cyrus’ サーバでサポートされています。

 -- メソッド: IMAP4.setannotation (mailbox, entry, attribute[, ...])

     ‘ANNOTATION’ を 'mailbox' に設定します。このメソッドは非標準ですが
     、‘Cyrus’ サーバでサポートされています。

 -- メソッド: IMAP4.setquota (root, limits)

     ‘quota’ 'root' のリソースを 'limits' に設定します。このメソッドは
     RFC 2087(7) で定義されている IMAP4 QUOTA 拡張の一部です。

 -- メソッド: IMAP4.shutdown ()

     ‘open’ で確立された接続を閉じます。 *note IMAP4.logout(): 3968. は
     暗黙的にこのメソッドを呼び出します。このメソッドはオーバライドする
     ことができます。

 -- メソッド: IMAP4.socket ()

     サーバへの接続に使われているソケットインスタンスを返します。

 -- メソッド: IMAP4.sort (sort_criteria, charset, search_criterion[,
          ...])

     ‘sort’ 命令は ‘search’ に結果の並べ替え (sort) 機能をつけた変種です
     。返されるデータには、条件に合致するメッセージ番号をスペースで分割
     したリストが入っています。

     sort 命令は 'search_criterion' の前に二つの引数を持ちます;
     'sort_criteria' のリストを丸括弧で囲ったものと、検索時の 'charset'
     です。‘search’ と違って、検索時の 'charset' は必須です。‘uid sort’
     命令もあり、‘search’ に対する ‘uid search’ と同じように ‘sort’ 命令
     に対応します。‘sort’ 命令はまず、charset 引数の指定に従って
     searching criteria の文字列を解釈し、メールボックスから与えられた検
     索条件に合致するメッセージを探します。次に、合致したメッセージの数
     を返します。

     ‘IMAP4rev1’ 拡張命令です。

 -- メソッド: IMAP4.starttls (ssl_context=None)

     Send a ‘STARTTLS’ command.  The 'ssl_context' argument is optional
     and should be a *note ssl.SSLContext: 274. object.  This will
     enable encryption on the IMAP connection.  Please read *note
     セキュリティで考慮すべき点: 31f1. for best practices.

     Added in version 3.2.

     バージョン 3.4 で変更: The method now supports hostname check with
     *note ssl.SSLContext.check_hostname: 3313. and 'Server Name
     Indication' (see *note ssl.HAS_SNI: 3325.).

 -- メソッド: IMAP4.status (mailbox, names)

     'mailbox' の指定ステータス名の状態情報を要求します。

 -- メソッド: IMAP4.store (message_set, command, flag_list)

     メールボックス内のメッセージ群のフラグ設定を変更します。 'command'
     は RFC 2060(8) のセクション 6.4.6 で指定されているもので、 "FLAGS",
     "+FLAGS", あるいは "-FLAGS" のいずれかとなります。オプションで末尾
     に ".SILENT" がつくこともあります。

     たとえば、すべてのメッセージに削除フラグを設定するには次のようにし
     ます:

          typ, data = M.search(None, 'ALL')
          for num in data[0].split():
             M.store(num, '+FLAGS', '\\Deleted')
          M.expunge()

          注釈: Creating flags containing ']' (for example: "[test]")
          violates RFC 3501(9) (the IMAP protocol).  However, imaplib
          has historically allowed creation of such tags, and popular
          IMAP servers, such as Gmail, accept and produce such flags.
          There are non-Python programs which also create such tags.
          Although it is an RFC violation and IMAP clients and servers
          are supposed to be strict, imaplib still continues to allow
          such tags to be created for backward compatibility reasons,
          and as of Python 3.6, handles them if they are sent from the
          server, since this improves real-world compatibility.

 -- メソッド: IMAP4.subscribe (mailbox)

     新たなメールボックスを購読 (subscribe) します。

 -- メソッド: IMAP4.thread (threading_algorithm, charset,
          search_criterion[, ...])

     ‘thread’ コマンドは ‘search’ にスレッドの概念を加えた変形版です。返
     されるデータは空白で区切られたスレッドメンバのリストを含んでいます
     。

     各スレッドメンバは0以上のメッセージ番号からなり、空白で区切られてお
     り、親子関係を示しています。

     Thread has two arguments before the 'search_criterion' argument(s);
     a 'threading_algorithm', and the searching 'charset'.  Note that
     unlike ‘search’, the searching 'charset' argument is mandatory.
     There is also a ‘uid thread’ command which corresponds to ‘thread’
     the way that ‘uid search’ corresponds to ‘search’.  The ‘thread’
     command first searches the mailbox for messages that match the
     given searching criteria using the 'charset' argument for the
     interpretation of strings in the searching criteria.  It then
     returns the matching messages threaded according to the specified
     threading algorithm.

     ‘IMAP4rev1’ 拡張命令です。

 -- メソッド: IMAP4.uid (command, arg[, ...])

     command args を、メッセージ番号ではなく UID で指定されたメッセージ
     群に対して実行します。命令内容に応じた応答を返します。少なくとも一
     つの引数を与えなくてはなりません; 何も与えない場合、サーバはエラー
     を返し、例外が送出されます。

 -- メソッド: IMAP4.unsubscribe (mailbox)

     古いメールボックスの購読を解除 (unsubscribe) します。

 -- メソッド: IMAP4.unselect ()

     *note imaplib.IMAP4.unselect(): 8d5. frees server's resources
     associated with the selected mailbox and returns the server to the
     authenticated state.  This command performs the same actions as
     *note imaplib.IMAP4.close(): 8d6, except that no messages are
     permanently removed from the currently selected mailbox.

     Added in version 3.9.

 -- メソッド: IMAP4.xatom (name[, ...])

     サーバから ‘CAPABILITY’ 応答で通知された単純な拡張命令を許容
     (allow) します。

以下の属性が *note IMAP4: 8d1. のインスタンス上で定義されています:

 -- の属性: IMAP4.PROTOCOL_VERSION

     サーバから返された ‘CAPABILITY’ 応答にある、サポートされている最新
     のプロトコルです。

 -- の属性: IMAP4.debug

     デバッグ出力を制御するための整数値です。初期値はモジュール変数
     ‘Debug’ から取られます。3 以上の値にすると各命令をトレースします。

 -- の属性: IMAP4.utf8_enabled

     Boolean value that is normally ‘False’, but is set to ‘True’ if an
     *note enable(): dda. command is successfully issued for the
     ‘UTF8=ACCEPT’ capability.

     Added in version 3.5.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5161.html

   (2) https://datatracker.ietf.org/doc/html/rfc6855.html

   (3) https://datatracker.ietf.org/doc/html/rfc6855.html

   (4) https://datatracker.ietf.org/doc/html/rfc2087.html

   (5) https://datatracker.ietf.org/doc/html/rfc2087.html

   (6) https://datatracker.ietf.org/doc/html/rfc2342.html

   (7) https://datatracker.ietf.org/doc/html/rfc2087.html

   (8) https://datatracker.ietf.org/doc/html/rfc2060.html

   (9) https://datatracker.ietf.org/doc/html/rfc3501.html


File: python.info,  Node: IMAP4 の使用例,  Prev: IMAP4 オブジェクト,  Up: imaplib --- IMAP4 プロトコルクライアント

5.21.13.2 IMAP4 の使用例
........................

以下にメールボックスを開き、全てのメッセージを取得して印刷する最小の (エ
ラーチェックをしない) 使用例を示します:

     import getpass, imaplib

     M = imaplib.IMAP4(host='example.org')
     M.login(getpass.getuser(), getpass.getpass())
     M.select()
     typ, data = M.search(None, 'ALL')
     for num in data[0].split():
         typ, data = M.fetch(num, '(RFC822)')
         print('Message %s\n%s\n' % (num, data[0][1]))
     M.close()
     M.logout()


File: python.info,  Node: smtplib --- SMTP プロトコルクライアント,  Next: uuid --- RFC 4122 に従った UUID オブジェクト,  Prev: imaplib --- IMAP4 プロトコルクライアント,  Up: インターネットプロトコルとサポート

5.21.14 ‘smtplib’ -- SMTP プロトコルクライアント
------------------------------------------------

'ソースコード:' Lib/smtplib.py(1)

__________________________________________________________________

*note smtplib: b7. モジュールは、SMTPまたはESMTPのリスナーデーモンを備え
た任意のインターネット上のホストにメールを送るために使用することができる
SMTPクライアント・セッション・オブジェクトを定義します。 SMTPおよび
ESMTPオペレーションの詳細は、 RFC 821(2) (Simple Mail Transfer Protocol)
や RFC 1869(3) (SMTP Service Extensions)を調べてください。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

 -- クラス: smtplib.SMTP (host='', port=0, local_hostname=None[,
          timeout], source_address=None)

     *note SMTP: 8fb. インスタンスはSMTP接続をカプセル化します。SMTPと
     ESMTP操作の完全なレパートリーをサポートするメソッドがあります。オプ
     ションパラメータの 'host' および 'port' が指定されている場合、
     SMTPの *note connect(): 1935. メソッドは初期化中にこれらのパラメー
     タを使って呼び出されます。 'local_hostname' を指定した場合、それは
     HELO/EHLOコマンドのローカルホストのFQDNとして使用されます。指定しな
     い場合、ローカルホスト名は *note socket.getfqdn(): 16e7. を使用して
     検索されます。 *note connect(): 1935. 呼び出しが成功コード以外を返
     すと、 *note SMTPConnectError: 398a. が送出されます。オプションの
     'timeout' パラメータは、接続試行のようなブロッキング操作のタイムア
     ウトを秒単位で指定します（指定されていない場合、グローバルなデフォ
     ルトのタイムアウト設定が使用されます）。タイムアウトが切れると、
     *note TimeoutError: 800. が送出されます。オプションの
     'source_address' パラメータを使用すると、複数のネットワークインター
     フェースを持つマシンの特定の送信元アドレス、かつ（または）特定の送
     信元TCPポートにバインドできます。接続する前にソケットを送信元アドレ
     スとしてバインドするためにタプル ‘(host, port)’ が必要です。省略さ
     れた場合（あるいは、'host' または 'port' がそれぞれ ‘''’ かつ/また
     は ‘0’ の場合）、OSのデフォルト動作が使用されます。

     普通に使う場合は、初期化と接続を行ってから、 *note sendmail(): e22.
     と *note SMTP.quit(): 398b. メソッドを呼びます。使用例は先の方で記
     載しています。

     The *note SMTP: 8fb. class supports the *note with: 59c. statement.
     When used like this, the SMTP ‘QUIT’ command is issued
     automatically when the ‘with’ statement exits.  E.g.:

          >>> from smtplib import SMTP
          >>> with SMTP("domain.org") as smtp:
          ...     smtp.noop()
          ...
          (250, b'Ok')
          >>>

     全てのコマンドは引数 ‘self’ と ‘data’ を指定して *note auditing
     event: 1825. ‘smtplib.SMTP.send’ を送出します。ここで ‘data’ はリモ
     ートホストに送信されるバイト数です。

     バージョン 3.3 で変更: *note with: 59c. 構文のサポートが追加されま
     した。

     バージョン 3.3 で変更: 'source_address' argument was added.

     Added in version 3.5: SMTPUTF8 拡張 ( RFC 6531(4)) がサポートされま
     した。

     バージョン 3.9 で変更: 'timeout' パラメータが0に設定されている場合
     、非ブロッキングソケットの作成を防ぐために *note ValueError: 1e3. を
     送出します。

 -- クラス: smtplib.SMTP_SSL (host='', port=0, local_hostname=None, *[,
          timeout], context=None, source_address=None)

     *note SMTP_SSL: 8fc. インスタンスは *note SMTP: 8fb. と全く同じよう
     に動作します。*note SMTP_SSL: 8fc. は、接続の始めからSSLが必要であ
     り、 ‘starttls()’ が適切でない状況で使用するべきです。 'host' が指
     定されていない場合、ローカルホストが使用されます。 'port' が0の場合
     、標準のSMTP-over-SSLポート（465）が使用されます。オプション引数
     'local_hostname', 'timeout', 'source_address' は *note SMTP: 8fb. ク
     ラスと同じ意味を持ちます。 'context' オプションは *note SSLContext:
     274. を含むことができ、安全な接続のさまざまな側面を設定することがで
     きます。ベストプラクティスについては *note
     セキュリティで考慮すべき点: 31f1. を読んでください。

     バージョン 3.3 で変更: 'context' が追加されました。

     バージョン 3.3 で変更: The 'source_address' argument was added.

     バージョン 3.4 で変更: このクラスは *note
     ssl.SSLContext.check_hostname: 3313. と 'Server Name Indication' で
     ホスト名のチェックをサポートしました。(*note ssl.HAS_SNI: 3325. を
     参照してください)。

     バージョン 3.9 で変更: 'timeout' パラメータが0に設定されている場合
     、非ブロッキングソケットの作成を防ぐために *note ValueError: 1e3. を
     送出します。

     バージョン 3.12 で変更: 非推奨の 'keyfile' と 'certfile' 引数を削除
     しました。

 -- クラス: smtplib.LMTP (host='', port=LMTP_PORT, local_hostname=None,
          source_address=None[, timeout])

     The LMTP protocol, which is very similar to ESMTP, is heavily based
     on the standard SMTP client.  It's common to use Unix sockets for
     LMTP, so our ‘connect()’ method must support that as well as a
     regular host:port server.  The optional arguments 'local_hostname'
     and 'source_address' have the same meaning as they do in the *note
     SMTP: 8fb. class.  To specify a Unix socket, you must use an
     absolute path for 'host', starting with a '/'.

     認証は、通常のSMTP機構を利用してサポートされています。 Unixソケット
     を利用する場合、LMTPは通常認証をサポートしたり要求したりはしません
     。しかし、あなたが必要であれば、利用することができます。

     バージョン 3.9 で変更: オプションの 'timeout' 引数が追加されました
     。

このモジュールの例外には次のものがあります:

 -- 例外: smtplib.SMTPException

     *note OSError: 3f0. の派生クラスで、このモジュールが提供する他の全
     ての例外の基底クラスです。

     バージョン 3.4 で変更: SMTPException が *note OSError: 3f0. の派生
     クラスになりました。

 -- 例外: smtplib.SMTPServerDisconnected

     この例外はサーバが突然接続が切断されるか、*note SMTP: 8fb. インスタ
     ンスを生成する前に接続しようとした場合に送出されます。

 -- 例外: smtplib.SMTPResponseException

     SMTPのエラーコードを含んだ例外のクラスです。これらの例外はSMTPサー
     バがエラーコードを返すときに生成されます。エラーコードは
     ‘smtp_code’ 属性に格納されます。また、 ‘smtp_error’ 属性にはエラー
     メッセージが格納されます。

 -- 例外: smtplib.SMTPSenderRefused

     送信者のアドレスが弾かれたときに送出される例外です。全ての *note
     SMTPResponseException: 398d. 例外に、 SMTPサーバが弾いた 'sender' ア
     ドレスの文字列がセットされます。

 -- 例外: smtplib.SMTPRecipientsRefused

     全ての受取人アドレスが弾かれたときに送出される例外です。各受取人の
     エラーは属性 ‘recipients’ によってアクセス可能で、 *note
     SMTP.sendmail(): e22. が返す辞書と同じ並びの辞書になっています。

 -- 例外: smtplib.SMTPDataError

     SMTPサーバが、メッセージのデータを受け入れることを拒絶したときに送
     出される例外です。

 -- 例外: smtplib.SMTPConnectError

     サーバへの接続時にエラーが発生したときに送出される例外です。

 -- 例外: smtplib.SMTPHeloError

     サーバーが ‘HELO’ メッセージを弾いたときに送出される例外です。

 -- 例外: smtplib.SMTPNotSupportedError

     試行したコマンドやオプションはサーバにサポートされていません。

     Added in version 3.5.

 -- 例外: smtplib.SMTPAuthenticationError

     SMTP 認証が失敗しました。最もあり得るのは、サーバーがユーザ名/パス
     ワードのペアを受け付なかった事です。

参考
....

RFC 821(5) - Simple Mail Transfer Protocol

     SMTP のプロトコル定義です。このドキュメントでは SMTP のモデル、操作
     手順、プロトコルの詳細についてカバーしています。

RFC 1869(6) - SMTP Service Extensions

     SMTP に対する ESMTP 拡張の定義です。このドキュメントでは、新たな命
     令による SMTP の拡張、サーバによって提供される命令を動的に発見する
     機能のサポート、およびいくつかの追加命令定義について記述しています
     。

* Menu:

* SMTP オブジェクト::
* SMTP 使用例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/smtplib.py

   (2) https://datatracker.ietf.org/doc/html/rfc821.html

   (3) https://datatracker.ietf.org/doc/html/rfc1869.html

   (4) https://datatracker.ietf.org/doc/html/rfc6531.html

   (5) https://datatracker.ietf.org/doc/html/rfc821.html

   (6) https://datatracker.ietf.org/doc/html/rfc1869.html


File: python.info,  Node: SMTP オブジェクト,  Next: SMTP 使用例,  Up: smtplib --- SMTP プロトコルクライアント

5.21.14.1 SMTP オブジェクト
...........................

*note SMTP: 8fb. クラスインスタンスは次のメソッドを提供します:

 -- メソッド: SMTP.set_debuglevel (level)

     デバッグ出力レベルを設定します。'level' が 1 や ‘True’ の場合、接続
     ならびにサーバとの送受信のメッセージがデバッグメッセージとなります
     。'level' が 2 の場合、それらのメッセージにタイムスタンプが付きます
     。

     バージョン 3.5 で変更: デバッグレベル2が追加されました。

 -- メソッド: SMTP.docmd (cmd, args='')

     サーバへコマンド 'cmd' を送信します。オプション引数 'args' はスペー
     ス文字でコマンドに連結します。戻り値は、整数値のレスポンスコードと
     、サーバからの応答の値をタプルで返します (サーバからの応答が数行に
     渡る場合でも一つの大きな文字列で返します)。

     数値応答コードと実際の応答行 (複数の応答は 1 つの長い行に結合されま
     す) からなる 2 値タプルを返します。

     通常、このメソッドを明示的に使う必要はありません。他のメソッドを実
     装するのに使い、自分で拡張したものをテストするのに役立つかもしれま
     せん。

     応答待ちのときにサーバへの接続が切れると *note
     SMTPServerDisconnected: 398c. が送出されます。

 -- メソッド: SMTP.connect (host='localhost', port=0)

     ホスト名とポート番号をもとに接続します。デフォルトはlocalhostの標準
     的なSMTPポート(25番)に接続します。もしホスト名の末尾がコロン
     (‘':'’)で、後に番号がついている場合は、「ホスト名:ポート番号」とし
     て扱われます。このメソッドはコンストラクタにホスト名及びポート番号
     が指定されている場合、自動的に呼び出されます。戻り値は、この接続の
     応答内でサーバによって送信された応答コードとメッセージの2要素タプル
     です。

     引数 ‘self’, ‘host’, ‘port’ を指定して *note 監査イベント: 1825.
     ‘smtplib.connect’ を送出します。

 -- メソッド: SMTP.helo (name='')

     SMTPサーバに ‘HELO’ コマンドで身元を示します。デフォルトでは
     hostname引数はローカルホストを指します。サーバーが返したメッセージ
     は、オブジェクトの ‘helo_resp’ 属性に格納されます。

     通常は *note sendmail(): e22. が呼びだすため、これを明示的に呼び出
     す必要はありません。

 -- メソッド: SMTP.ehlo (name='')

     ‘EHLO’ を利用し、ESMTPサーバに身元を明かします。デフォルトでは
     hostname引数はローカルホストのFQDNです。また、ESMTPオプションのため
     に応答を調べたものは、 *note has_extn(): 3998. に備えて保存されます
     。また、幾つかの情報を属性に保存します: サーバーが返したメッセージ
     は ‘ehlo_resp’ 属性に、 ‘does_esmtp’ 属性はサーバーがESMTPをサポー
     トしているかどうかによって ‘True’ か ‘False’ に、 ‘esmtp_features’
     属性は辞書で、サーバーが対応しているSMTP サービス拡張の名前と、もし
     あればそのパラメータを格納します。

     メールを送信する前に *note has_extn(): 3998. を使おうとしない限り、
     このメソッドを明示的に呼ぶ必要はないはずです。必要な場合は *note
     sendmail(): e22. に暗黙的に呼ばれます。

 -- メソッド: SMTP.ehlo_or_helo_if_needed ()

     このメソッドは、現在のセッションでまだ ‘EHLO’ か ‘HELO’ コマンドが
     実行されていない場合、 *note ehlo(): 3997. and/or *note helo():
     3996. メソッドを呼び出します。このメソッドは先に ESMTP ‘EHLO’ を試
     します。

     *note SMTPHeloError: 3991.

          サーバーが ‘HELO’ に正しく返答しませんでした。

 -- メソッド: SMTP.has_extn (name)

     'name' が拡張SMTPサービスセットに含まれている場合には *note True:
     bdb. を返し、そうでなければ *note False: b05. を返します。大小文字
     は区別されません。

 -- メソッド: SMTP.verify (address)

     ‘VRFY’ を利用してSMTPサーバにアドレスの妥当性をチェックします。妥当
     である場合はコード250と完全な RFC 822(1) アドレス (人名を含む) のタ
     プルを返します。それ以外の場合は、400以上のエラーコードとエラー文字
     列を返します。

          注釈: ほとんどのサイトはスパマーの裏をかくためにSMTPの ‘VRFY’
          は使用不可になっています。

 -- メソッド: SMTP.login (user, password, *, initial_response_ok=True)

     認証が必要なSMTPサーバにログインします。認証に使用する引数はユーザ
     名とパスワードです。まだセッションが無い場合は、 ‘EHLO’ または
     ‘HELO’ コマンドでセッションを作ります。ESMTPの場合は ‘EHLO’ が先に
     試されます。認証が成功した場合は通常このメソッドは戻りますが、例外
     が起こった場合は以下の例外が上がります:

     *note SMTPHeloError: 3991.

          サーバーが ‘HELO’ に正しく返答しませんでした。

     *note SMTPAuthenticationError: 3992.

          サーバがユーザ名/パスワードでの認証に失敗しました。

     *note SMTPNotSupportedError: 1934.

          ‘AUTH’ コマンドはサーバにサポートされていません。

     *note SMTPException: f6d.

          適当な認証方法が見付かりませんでした。

     Each of the authentication methods supported by *note smtplib: b7.
     are tried in turn if they are advertised as supported by the
     server.  See *note auth(): e20. for a list of supported
     authentication methods.  'initial_response_ok' is passed through to
     *note auth(): e20.

     オプションのキーワード引数 'initial_response_ok' は、それをサポート
     する認証方法に対して、チャレンジ/レスポンスを要求するのではなく、
     "AUTH"コマンドとともに RFC 4954(2) で指定された"初期応答"を送信でき
     るかどうかを指定します。

     バージョン 3.5 で変更: *note SMTPNotSupportedError: 1934. が送出さ
     れる場合があります。'initial_response_ok' 引数が追加されました。

 -- メソッド: SMTP.auth (mechanism, authobject, *,
          initial_response_ok=True)

     Issue an ‘SMTP’ ‘AUTH’ command for the specified authentication
     'mechanism', and handle the challenge response via 'authobject'.

     'mechanism' specifies which authentication mechanism is to be used
     as argument to the ‘AUTH’ command; the valid values are those
     listed in the ‘auth’ element of ‘esmtp_features’.

     'authobject' must be a callable object taking an optional single
     argument:

          data = authobject(challenge=None)

     If optional keyword argument 'initial_response_ok' is true,
     ‘authobject()’ will be called first with no argument.  It can
     return the RFC 4954(3) "initial response" ASCII ‘str’ which will be
     encoded and sent with the ‘AUTH’ command as below.  If the
     ‘authobject()’ does not support an initial response (e.g.  because
     it requires a challenge), it should return ‘None’ when called with
     ‘challenge=None’.  If 'initial_response_ok' is false, then
     ‘authobject()’ will not be called first with ‘None’.

     If the initial response check returns ‘None’, or if
     'initial_response_ok' is false, ‘authobject()’ will be called to
     process the server's challenge response; the 'challenge' argument
     it is passed will be a ‘bytes’.  It should return ASCII ‘str’
     'data' that will be base64 encoded and sent to the server.

     The ‘SMTP’ class provides ‘authobjects’ for the ‘CRAM-MD5’,
     ‘PLAIN’, and ‘LOGIN’ mechanisms; they are named
     ‘SMTP.auth_cram_md5’, ‘SMTP.auth_plain’, and ‘SMTP.auth_login’
     respectively.  They all require that the ‘user’ and ‘password’
     properties of the ‘SMTP’ instance are set to appropriate values.

     User code does not normally need to call ‘auth’ directly, but can
     instead call the *note login(): 399b. method, which will try each
     of the above mechanisms in turn, in the order listed.  ‘auth’ is
     exposed to facilitate the implementation of authentication methods
     not (or not yet) supported directly by *note smtplib: b7.

     Added in version 3.5.

 -- メソッド: SMTP.starttls (*, context=None)

     TLS (Transport Layer Security) モードで SMTP 接続します。続く全ての
     SMTP コマンドは暗号化されます。その後、もう一度 *note ehlo(): 3997.
     を呼んでください。

     If 'keyfile' and 'certfile' are provided, they are used to create
     an *note ssl.SSLContext: 274.

     Optional 'context' parameter is an *note ssl.SSLContext: 274.
     object; This is an alternative to using a keyfile and a certfile
     and if specified both 'keyfile' and 'certfile' should be ‘None’.

     もしまだ ‘EHLO’ か ‘HELO’ コマンドが実行されていない場合、このメソ
     ッドは ESMTP ‘EHLO’ を先に試します。

     バージョン 3.12 で変更: 非推奨の 'keyfile' と 'certfile' 引数を削除
     しました。

     *note SMTPHeloError: 3991.

          サーバーが ‘HELO’ に正しく返答しませんでした。

     *note SMTPNotSupportedError: 1934.

          サーバーが STARTTLS 拡張に対応していません。

     *note RuntimeError: 17a.

          実行中の Python インタプリタで、SSL/TLS サポートが利用できませ
          ん。

     バージョン 3.3 で変更: 'context' が追加されました。

     バージョン 3.4 で変更: The method now supports hostname check with
     ‘SSLContext.check_hostname’ and 'Server Name Indicator' (see *note
     HAS_SNI: 3325.).

     バージョン 3.5 で変更: The error raised for lack of STARTTLS
     support is now the *note SMTPNotSupportedError: 1934. subclass
     instead of the base *note SMTPException: f6d.

 -- メソッド: SMTP.sendmail (from_addr, to_addrs, msg, mail_options=(),
          rcpt_options=())

     メールを送信します。必要な引数は RFC 822(4) のfromアドレス文字列、
     RFC 822(5) のtoアドレス文字列またはアドレス文字列のリスト、メッセー
     ジ文字列です。送信側は ‘MAIL FROM’ コマンドで使用される
     'mail_options' の ESMTPオプション(‘8bitmime’ のような)のリストを得
     るかもしれません。全ての ‘RCPT’ コマンドで使われるべきESMTPオプショ
     ン (例えば ‘DSN’ コマンド)は、 'rcpt_options' を通して利用すること
     ができます。(もし送信先別にESMTPオプションを使う必要があれば、メッ
     セージを送るために ‘mail()’ 、 ‘rcpt()’ 、 ‘data()’ といった下位レ
     ベルのメソッドを使う必要があります。)

          注釈: 配送エージェントは 'from_addr'、'to_addrs' 引数を使い、
          メッセージのエンベロープを構成します。‘sendmail’ はメッセージ
          ヘッダを修正しません。

     'msg' may be a string containing characters in the ASCII range, or
     a byte string.  A string is encoded to bytes using the ascii codec,
     and lone ‘\r’ and ‘\n’ characters are converted to ‘\r\n’
     characters.  A byte string is not modified.

     まだセッションが無い場合は、 ‘EHLO’ または ‘HELO’ コマンドでセッシ
     ョンを作ります。ESMTPの場合は ‘EHLO’ が先に試されます。また、サーバ
     がESMTP対応ならば、メッセージサイズとそれぞれ指定されたオプションも
     渡します。(featureオプションがあればサーバの広告をセットします)
     ‘EHLO’ が失敗した場合は、ESMTPオプションの無い ‘HELO’ が試されます
     。

     このメソッドは最低でも1人の受信者にメールが受け取られたときは正常に
     戻ります。そうでない場合は例外を投げます。つまり、このメソッドが例
     外を送出しないときは誰かが送信したメールを受け取ったはずです。また
     、例外を送出しない場合は拒絶された受信者ごとに項目のある辞書を返し
     ます。各項目はサーバーが送ったSMTPエラーコードと付随するエラーメッ
     セージのタプルを持ちます。

     'mail_options' に ‘SMTPUTF8’ があり、サーバがサポートしている場合は
     、'from_addr' と 'to_addrs' に非 ASCII 文字を含めることが出来ます。

     このメソッドは次の例外を送出することがあります:

     *note SMTPRecipientsRefused: 398f.

          全ての受信を拒否され、誰にもメールが届けられませんでした。例外
          オブジェクトの ‘recipients’ 属性は、受信拒否についての情報の入
          った辞書オブジェクトです。 (辞書は少なくとも一つは受信されたと
          きに似ています)。

     *note SMTPHeloError: 3991.

          サーバーが ‘HELO’ に正しく返答しませんでした。

     *note SMTPSenderRefused: 398e.

          サーバが 'from_addr' を受理しませんでした。

     *note SMTPDataError: 3990.

          サーバが予期しないエラーコードを返しました (受信拒否以外)。

     *note SMTPNotSupportedError: 1934.

          'mail_options' に ‘SMTPUTF8’ が与えられましたが、サーバがサポ
          ートしていません。

     また、この他の注意として、例外が上がった後もコネクションは開いたま
     まになっています。

     バージョン 3.2 で変更: 'msg' はバイト文字列でも構いません。

     バージョン 3.5 で変更: ‘SMTPUTF8’ のサポートが追加されました。
     ‘SMTPUTF8’ が与えられたが、サーバがサポートしていない場合は *note
     SMTPNotSupportedError: 1934. が送出されます。

 -- メソッド: SMTP.send_message (msg, from_addr=None, to_addrs=None,
          mail_options=(), rcpt_options=())

     This is a convenience method for calling *note sendmail(): e22.
     with the message represented by an *note email.message.Message:
     25d. object.  The arguments have the same meaning as for *note
     sendmail(): e22, except that 'msg' is a ‘Message’ object.

     If 'from_addr' is ‘None’ or 'to_addrs' is ‘None’, ‘send_message’
     fills those arguments with addresses extracted from the headers of
     'msg' as specified in RFC 5322(6): 'from_addr' is set to the
     ‘Sender’ field if it is present, and otherwise to the ‘From’ field.
     'to_addrs' combines the values (if any) of the ‘To’, ‘Cc’, and
     ‘Bcc’ fields from 'msg'.  If exactly one set of ‘Resent-*’ headers
     appear in the message, the regular headers are ignored and the
     ‘Resent-*’ headers are used instead.  If the message contains more
     than one set of ‘Resent-*’ headers, a *note ValueError: 1e3. is
     raised, since there is no way to unambiguously detect the most
     recent set of ‘Resent-’ headers.

     ‘send_message’ serializes 'msg' using *note BytesGenerator: 119f.
     with ‘\r\n’ as the 'linesep', and calls *note sendmail(): e22. to
     transmit the resulting message.  Regardless of the values of
     'from_addr' and 'to_addrs', ‘send_message’ does not transmit any
     ‘Bcc’ or ‘Resent-Bcc’ headers that may appear in 'msg'.  If any of
     the addresses in 'from_addr' and 'to_addrs' contain non-ASCII
     characters and the server does not advertise ‘SMTPUTF8’ support, an
     ‘SMTPNotSupported’ error is raised.  Otherwise the ‘Message’ is
     serialized with a clone of its *note policy: 46. with the *note
     utf8: dc5. attribute set to ‘True’, and ‘SMTPUTF8’ and
     ‘BODY=8BITMIME’ are added to 'mail_options'.

     Added in version 3.2.

     Added in version 3.5: 国際化アドレスのサポート (‘SMTPUTF8’)。

 -- メソッド: SMTP.quit ()

     SMTPセッションを終了し、接続を閉じます。SMTP ‘QUIT’ コマンドの結果
     を返します。

下位レベルのメソッドは標準SMTP/ESMTPコマンド ‘HELP’ 、 ‘RSET’ 、 ‘NOOP’
、 ‘MAIL’ 、 ‘RCPT’ 、 ‘DATA’ に対応しています。通常これらは直接呼ぶ必要
はなく、また、ドキュメントもありません。詳細はモジュールのコードを調べて
ください。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc822.html

   (2) https://datatracker.ietf.org/doc/html/rfc4954.html

   (3) https://datatracker.ietf.org/doc/html/rfc4954.html

   (4) https://datatracker.ietf.org/doc/html/rfc822.html

   (5) https://datatracker.ietf.org/doc/html/rfc822.html

   (6) https://datatracker.ietf.org/doc/html/rfc5322.html


File: python.info,  Node: SMTP 使用例,  Prev: SMTP オブジェクト,  Up: smtplib --- SMTP プロトコルクライアント

5.21.14.2 SMTP 使用例
.....................

This example prompts the user for addresses needed in the message
envelope ('To' and 'From' addresses), and the message to be delivered.
Note that the headers to be included with the message must be included
in the message as entered; this example doesn't do any processing of the
RFC 822(1) headers.  In particular, the 'To' and 'From' addresses must
be included in the message headers explicitly:

     import smtplib

     def prompt(title):
         return input(title).strip()

     from_addr = prompt("From: ")
     to_addrs  = prompt("To: ").split()
     print("Enter message, end with ^D (Unix) or ^Z (Windows):")

     # Add the From: and To: headers at the start!
     lines = [f"From: {from_addr}", f"To: {', '.join(to_addrs)}", ""]
     while True:
         try:
             line = input()
         except EOFError:
             break
         else:
             lines.append(line)

     msg = "\r\n".join(lines)
     print("Message length is", len(msg))

     server = smtplib.SMTP("localhost")
     server.set_debuglevel(1)
     server.sendmail(from_addr, to_addrs, msg)
     server.quit()

     注釈: 多くの場合、 *note email: 32. パッケージの機能を使って email
     メッセージを構築し、それを、 *note send_message(): e23. で送信する
     、という手順を用います。 *note email; 使用例: f09. を参照してくださ
     い。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc822.html


File: python.info,  Node: uuid --- RFC 4122 に従った UUID オブジェクト,  Next: socketserver --- ネットワークサーバーのフレームワーク,  Prev: smtplib --- SMTP プロトコルクライアント,  Up: インターネットプロトコルとサポート

5.21.15 ‘uuid’ --
-----------------

'RFC 4122' に従った UUID オブジェクト

'ソースコード:' Lib/uuid.py(1)

__________________________________________________________________

このモジュールでは immutable (変更不能) な *note UUID: a2f. オブジェクト
(*note UUID: a2f. クラス) と RFC 4122(2) の定めるバージョン 1、3、4、5 の
UUID を生成するための *note uuid1(): b76, *note uuid3(): 16b0, *note
uuid4(): 39a0, *note uuid5(): 16b1, が提供されています。

もしユニークな ID が必要なだけであれば、おそらく *note uuid1(): b76. か
*note uuid4(): 39a0. を呼び出せば良いでしょう。 *note uuid1(): b76. はコ
ンピュータのネットワークアドレスを含む UUID を生成するためにプライバシー
を侵害するかもしれない点に注意してください。 *note uuid4(): 39a0. はラン
ダムな UUID を生成します。

Depending on support from the underlying platform, *note uuid1(): b76.
may or may not return a "safe" UUID. A safe UUID is one which is
generated using synchronization methods that ensure no two processes can
obtain the same UUID. All instances of *note UUID: a2f. have an *note
is_safe: b74. attribute which relays any information about the UUID's
safety, using this enumeration:

 -- クラス: uuid.SafeUUID

     Added in version 3.7.

      -- の属性: safe

          UUID は並列処理に対して安全なプラットフォームで生成された

      -- の属性: unsafe

          UUID は並列処理に対して安全なプラットフォームで生成されなかっ
          た

      -- の属性: unknown

          プラットフォームは、UUID が安全に生成されたかどうかの情報を提
          供しなかった

 -- クラス: uuid.UUID (hex=None, bytes=None, bytes_le=None, fields=None,
          int=None, version=None, *, is_safe=SafeUUID.unknown)

     32 桁の 16 進数文字列、'bytes' に 16 バイトのビッグエンディアンの文
     字列、'bytes_le' 引数に 16 バイトのリトルエンディアンの文字列、
     'fields' 引数に 6 つの整数のタプル（32ビット 'time_low', 16 ビット
     'time_mid', 16ビット 'time_hi_version', 8ビット
     'clock_seq_hi_variant', 8ビット 'clock_seq_low', 48ビット 'node' ）
     、または 'int' に一つの 128 ビット整数のいずれかから UUID を生成し
     ます。16 進数が与えられた時、波括弧、ハイフン、それと URN 接頭辞は
     無視されます。例えば、これらの表現は全て同じ UUID を払い出します:

          UUID('{12345678-1234-5678-1234-567812345678}')
          UUID('12345678123456781234567812345678')
          UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
          UUID(bytes=b'\x12\x34\x56\x78'*4)
          UUID(bytes_le=b'\x78\x56\x34\x12\x34\x12\x78\x56' +
                        b'\x12\x34\x56\x78\x12\x34\x56\x78')
          UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
          UUID(int=0x12345678123456781234567812345678)

     'hex', 'bytes', 'bytes_le', 'fields', または 'int' のうち、どれかた
     だ一つだけが与えられなければいけません。'version' 引数はオプション
     です; 与えられた場合、結果の UUID は与えられた 'hex', 'bytes',
     'bytes_le', 'fields', または 'int' をオーバーライドして、 RFC
     4122(3) に準拠した variant と version ナンバーのセットを持つことに
     なります。'bytes_le', 'fields', or 'int'.

     2つのUUIDオブジェクトの比較は、*note UUID.int: 39a5. 属性の比較によ
     って行われます。UUIDではないオブジェクトとの比較は、 *note
     TypeError: 502. を送出します。

     ‘str(uuid)’ は 32桁の16進でUUIDを表す
     ''12345678-1234-5678-1234-567812345678'' 形式の文字列を返します。

*note UUID: a2f. インスタンスは以下の読み出し専用属性を持ちます:

 -- の属性: UUID.bytes

     16 バイト文字列（バイトオーダーがビッグエンディアンの 6 つの整数フ
     ィールドを持つ）のUUID。

 -- の属性: UUID.bytes_le

     16 バイト文字列（ 'time_low', 'time_mid', 'time_hi_version' をリト
     ルエンディアンで持つ）の UUID。

 -- の属性: UUID.fields

     UUID の 6 つの整数フィールドを持つタプルで、これは 6 つの個別の属性
     と 2 つの派生した属性としても取得可能です:

フィールド                                             意味
                                                       
                                                       
 -- の属性: UUID.time_low                              The first 32 bits of the UUID.
                                                       
                                                       
 -- の属性: UUID.time_mid                              The next 16 bits of the UUID.
                                                       
                                                       
 -- の属性: UUID.time_hi_version                       The next 16 bits of the UUID.
                                                       
                                                       
 -- の属性: UUID.clock_seq_hi_variant                  The next 8 bits of the UUID.
                                                       
                                                       
 -- の属性: UUID.clock_seq_low                         The next 8 bits of the UUID.
                                                       
                                                       
 -- の属性: UUID.node                                  The last 48 bits of the UUID.
                                                       
                                                       
 -- の属性: UUID.time                                  The 60-bit timestamp.
                                                       
                                                       
 -- の属性: UUID.clock_seq                             The 14-bit sequence number.
                                                       

 -- の属性: UUID.hex

     32 文字の小文字 16 進数文字列での UUID。

 -- の属性: UUID.int

     128 ビット整数での UUID。

 -- の属性: UUID.urn

     RFC 4122(4) で規定される URN での UUID。

 -- の属性: UUID.variant

     UUID の内部レイアウトを決定する UUID の variant。これは定数 *note
     RESERVED_NCS: 39b4, *note RFC_4122: 39b5, *note RESERVED_MICROSOFT:
     39b6, *note RESERVED_FUTURE: 39b7. のいずれかです。

 -- の属性: UUID.version

     UUID の version 番号（1 から 5、variant が *note RFC_4122: 39b5. で
     ある場合だけ意味があります）。

 -- の属性: UUID.is_safe

     *note SafeUUID: 39a1. の列挙で、UUID は並列処理に対して安全なプラッ
     トフォームで生成されたかを示す。

     Added in version 3.7.

The *note uuid: f8. モジュールには以下の関数があります:

 -- の関数: uuid.getnode ()

     48 ビットの正の整数としてハードウェアアドレスを取得します。最初にこ
     れを起動すると、別個のプログラムが立ち上がって非常に遅くなることが
     あります。もしハードウェアを取得する試みが全て失敗すると、ランダム
     な 48 ビットを、 RFC 4122(5) で推奨されているように、マルチキャスト
     ビット (最初のオクテットの最下位ビット) を 1 に設定して使います。
     "ハードウェアアドレス" とはネットワークインターフェースの MAC アド
     レスを指します。複数のネットワークインターフェースを持つマシンの場
     合、全域管理されたMACアドレス (最初のオクテットの下位より2番目のビ
     ットが '設定されていない' MACアドレス) が、他の個別管理アドレスより
     も優先的に使用されます。この優先順序は保証されません。

     バージョン 3.7 で変更: 全域管理されたMACアドレスは、グローバルに固
     有であると保証されるため、固有である保証のない個別管理アドレスより
     も好ましいです。

 -- の関数: uuid.uuid1 (node=None, clock_seq=None)

     UUID をホスト ID、シーケンス番号、現在時刻から生成します。 'node' が
     与えられなければ、 *note getnode(): b75. がハードウェアアドレス取得
     のために使われます。 'clock_seq' が与えられると、これはシーケンス番
     号として使われます; さもなくば 14 ビットのランダムなシーケンス番号
     が選ばれます。

 -- の関数: uuid.uuid3 (namespace, name)

     Generate a UUID based on the MD5 hash of a namespace identifier
     (which is a UUID) and a name (which is a *note bytes: 1a4. object
     or a string that will be encoded using UTF-8).

 -- の関数: uuid.uuid4 ()

     ランダムな UUID を生成します。

 -- の関数: uuid.uuid5 (namespace, name)

     Generate a UUID based on the SHA-1 hash of a namespace identifier
     (which is a UUID) and a name (which is a *note bytes: 1a4. object
     or a string that will be encoded using UTF-8).

*note uuid: f8. モジュールは *note uuid3(): 16b0. または *note uuid5():
16b1. で利用するために次の名前空間識別子を定義しています。

 -- データ: uuid.NAMESPACE_DNS

     この名前空間が指定された場合、'name' 文字列は完全修飾ドメイン名です
     。

 -- データ: uuid.NAMESPACE_URL

     この名前空間が指定された場合、'name' 文字列は URL です。

 -- データ: uuid.NAMESPACE_OID

     この名前空間が指定された場合、'name' 文字列は ISO OID です。

 -- データ: uuid.NAMESPACE_X500

     この名前空間が指定された場合、'name' 文字列は X.500 DN の DER また
     はテキスト出力形式です。

The *note uuid: f8. module defines the following constants for the
possible values of the *note variant: 39b3. attribute:

 -- データ: uuid.RESERVED_NCS

     NCS 互換性のために予約されています。

 -- データ: uuid.RFC_4122

     RFC 4122(6) で与えられた UUID レイアウトを指定します。

 -- データ: uuid.RESERVED_MICROSOFT

     Microsoft の互換性のために予約されています。

 -- データ: uuid.RESERVED_FUTURE

     将来のために予約されています。

参考
....

RFC 4122(7) - Universally Unique IDentifier (UUID) の URN 名前空間

     この仕様は UUID のための Uniform Resource Name 名前空間、UUID の内
     部フォーマットと UUID の生成方法を定義しています。

* Menu:

* コマンドラインからの使用: コマンドラインからの使用<2>.
* 使用例: 使用例<38>.
* Command-Line Example::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/uuid.py

   (2) https://datatracker.ietf.org/doc/html/rfc4122.html

   (3) https://datatracker.ietf.org/doc/html/rfc4122.html

   (4) https://datatracker.ietf.org/doc/html/rfc4122.html

   (5) https://datatracker.ietf.org/doc/html/rfc4122.html

   (6) https://datatracker.ietf.org/doc/html/rfc4122.html

   (7) https://datatracker.ietf.org/doc/html/rfc4122.html


File: python.info,  Node: コマンドラインからの使用<2>,  Next: 使用例<38>,  Up: uuid --- RFC 4122 に従った UUID オブジェクト

5.21.15.1 コマンドラインからの使用
..................................

Added in version 3.12.

The *note uuid: f8. module can be executed as a script from the command
line.

     python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-n NAMESPACE] [-N NAME]

以下のオプションが使用できます:

 -- Option: -h, --help

     ヘルプメッセージを表示して終了します。

 -- Option: -u <uuid>
 -- Option: --uuid <uuid>

     Specify the function name to use to generate the uuid.  By default
     *note uuid4(): 39a0. is used.

 -- Option: -n <namespace>
 -- Option: --namespace <namespace>

     The namespace is a ‘UUID’, or ‘@ns’ where ‘ns’ is a well-known
     predefined UUID addressed by namespace name.  Such as ‘@dns’,
     ‘@url’, ‘@oid’, and ‘@x500’.  Only required for *note uuid3():
     16b0. / *note uuid5(): 16b1. functions.

 -- Option: -N <name>
 -- Option: --name <name>

     The name used as part of generating the uuid.  Only required for
     *note uuid3(): 16b0. / *note uuid5(): 16b1. functions.


File: python.info,  Node: 使用例<38>,  Next: Command-Line Example,  Prev: コマンドラインからの使用<2>,  Up: uuid --- RFC 4122 に従った UUID オブジェクト

5.21.15.2 使用例
................

典型的な *note uuid: f8. モジュールの利用方法を示します:

     >>> import uuid

     >>> # make a UUID based on the host ID and current time
     >>> uuid.uuid1()
     UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')

     >>> # make a UUID using an MD5 hash of a namespace UUID and a name
     >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
     UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')

     >>> # make a random UUID
     >>> uuid.uuid4()
     UUID('16fd2706-8baf-433b-82eb-8c7fada847da')

     >>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
     >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
     UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')

     >>> # make a UUID from a string of hex digits (braces and hyphens ignored)
     >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')

     >>> # convert a UUID to a string of hex digits in standard form
     >>> str(x)
     '00010203-0405-0607-0809-0a0b0c0d0e0f'

     >>> # get the raw 16 bytes of the UUID
     >>> x.bytes
     b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'

     >>> # make a UUID from a 16-byte string
     >>> uuid.UUID(bytes=x.bytes)
     UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')


File: python.info,  Node: Command-Line Example,  Prev: 使用例<38>,  Up: uuid --- RFC 4122 に従った UUID オブジェクト

5.21.15.3 Command-Line Example
..............................

Here are some examples of typical usage of the *note uuid: f8. command
line interface:

     # generate a random uuid - by default uuid4() is used
     $ python -m uuid

     # generate a uuid using uuid1()
     $ python -m uuid -u uuid1

     # generate a uuid using uuid5
     $ python -m uuid -u uuid5 -n @url -N example.com


File: python.info,  Node: socketserver --- ネットワークサーバーのフレームワーク,  Next: http server --- HTTP サーバー,  Prev: uuid --- RFC 4122 に従った UUID オブジェクト,  Up: インターネットプロトコルとサポート

5.21.16 ‘socketserver’ -- ネットワークサーバーのフレームワーク
--------------------------------------------------------------

'ソースコード:' Lib/socketserver.py(1)

__________________________________________________________________

*note socketserver: b9. モジュールはネットワークサーバを実装するタスクを
単純化します。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

基本的な具象サーバクラスが4つあります:

 -- クラス: socketserver.TCPServer (server_address, RequestHandlerClass,
          bind_and_activate=True)

     This uses the internet TCP protocol, which provides for continuous
     streams of data between the client and server.  If
     'bind_and_activate' is true, the constructor automatically attempts
     to invoke *note server_bind(): 39cc. and *note server_activate():
     39cd.  The other parameters are passed to the *note BaseServer:
     1110. base class.

 -- クラス: socketserver.UDPServer (server_address, RequestHandlerClass,
          bind_and_activate=True)

     This uses datagrams, which are discrete packets of information that
     may arrive out of order or be lost while in transit.  The
     parameters are the same as for *note TCPServer: 12ee.

 -- クラス: socketserver.UnixStreamServer (server_address,
          RequestHandlerClass, bind_and_activate=True)
 -- クラス: socketserver.UnixDatagramServer (server_address,
          RequestHandlerClass, bind_and_activate=True)

     These more infrequently used classes are similar to the TCP and UDP
     classes, but use Unix domain sockets; they're not available on
     non-Unix platforms.  The parameters are the same as for *note
     TCPServer: 12ee.

これらの 4 つのクラスは要求を '同期的に (synchronously)' 処理します; 各
要求は次の要求を開始する前に完結していなければなりません。同期的な処理は
、サーバで大量の計算を必要とする、あるいはクライアントが処理するには時間
がかかりすぎるような大量のデータを返す、といった理由によってリクエストに
長い時間がかかる状況には向いていません。こうした状況の解決方法は別のプロ
セスを生成するか、個々の要求を扱うスレッドを生成することです; *note
ForkingMixIn: b45. および *note ThreadingMixIn: b46. 配合クラス (mix-in
classes) を使えば、非同期的な動作をサポートできます。

サーバの作成にはいくつかのステップが必要です。最初に、 *note
BaseRequestHandler: 39d1. クラスをサブクラス化して要求処理クラス
(request hander class) を生成し、その *note handle(): 39d2. メソッドをオ
ーバーライドしなければなりません; このメソッドは入力される要求を処理しま
す。次に、サーバクラスのうち一つを、サーバのアドレスと要求処理クラスを渡
してインスタンス化しなければなりません。サーバを *note with: 59c. 文中で
使うことが推奨されます。そして、*note handle_request(): 12f1. または
*note serve_forever(): 1112. メソッドを呼び出して、一つのまたは多数の要
求を処理します。最後に、(‘with’ 文を使っていなかったなら) *note
server_close(): 39d3. を呼び出してソケットを閉じます。

*note ThreadingMixIn: b46. から継承してスレッドを利用した接続を行う場合
、突発的な通信切断時の処理を明示的に指定する必要があります。 *note
ThreadingMixIn: b46. クラスには 'daemon_threads' 属性があり、サーバがス
レッドの終了を待ち合わせるかどうかを指定する事ができます。スレッドが独自
の処理を行う場合は、このフラグを明示的に指定します。デフォルトは *note
False: b05. で、Pythonは *note ThreadingMixIn: b46. クラスが起動した全て
のスレッドが終了するまで実行し続けます。

サーバクラス群は使用するネットワークプロトコルに関わらず、同じ外部メソッ
ドおよび属性を持ちます。

* Menu:

* サーバ生成に関するノート::
* Serverオブジェクト: Serverオブジェクト<2>.
* Request Handler Objects::
* 使用例: 使用例<39>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/socketserver.py


File: python.info,  Node: サーバ生成に関するノート,  Next: Serverオブジェクト<2>,  Up: socketserver --- ネットワークサーバーのフレームワーク

5.21.16.1 サーバ生成に関するノート
..................................

継承図にある五つのクラスのうち四つは四種類の同期サーバを表わしています:

     +------------+
     | BaseServer |
     +------------+
           |
           v
     +-----------+        +------------------+
     | TCPServer |------->| UnixStreamServer |
     +-----------+        +------------------+
           |
           v
     +-----------+        +--------------------+
     | UDPServer |------->| UnixDatagramServer |
     +-----------+        +--------------------+

*note UnixDatagramServer: 39d0. は *note UDPServer: 39ce. から派生してい
て、 *note UnixStreamServer: 39cf. からではないことに注意してください --
IP と Unix サーバの唯一の違いはアドレスファミリーです。

 -- クラス: socketserver.ForkingMixIn
 -- クラス: socketserver.ThreadingMixIn

     それぞれのタイプのサーバのフォークしたりスレッド実行したりするバー
     ジョンはそれらのミクシン(mix-in)クラスを使って作ることができます。
     たとえば、*note ThreadingUDPServer: 39d5. は以下のようにして作られ
     ます:

          class ThreadingUDPServer(ThreadingMixIn, UDPServer):
              pass

     ミクシンクラスは *note UDPServer: 39ce. で定義されるメソッドをオー
     バライドするために、最初に来ます。様々な属性を設定することで元にな
     るサーバ機構の振る舞いを変えられます。

     *note ForkingMixIn: b45. and the Forking classes mentioned below
     are only available on POSIX platforms that support *note fork():
     17c.

      -- の属性: block_on_close

          *note ForkingMixIn.server_close: 39d3. waits until all child
          processes complete, except if *note block_on_close: bcb.
          attribute is ‘False’.

          *note ThreadingMixIn.server_close: 39d3. waits until all
          non-daemon threads complete, except if *note block_on_close:
          bcb. attribute is ‘False’.

      -- の属性: daemon_threads

          For *note ThreadingMixIn: b46. use daemonic threads by setting
          *note ThreadingMixIn.daemon_threads: 39d6. to ‘True’ to not
          wait until threads complete.

     バージョン 3.7 で変更: *note ForkingMixIn.server_close: 39d3. and
     *note ThreadingMixIn.server_close: 39d3. now waits until all child
     processes and non-daemonic threads complete.  Add a new *note
     ForkingMixIn.block_on_close: bcb. class attribute to opt-in for the
     pre-3.7 behaviour.

 -- クラス: socketserver.ForkingTCPServer
 -- クラス: socketserver.ForkingUDPServer
 -- クラス: socketserver.ThreadingTCPServer
 -- クラス: socketserver.ThreadingUDPServer
 -- クラス: socketserver.ForkingUnixStreamServer
 -- クラス: socketserver.ForkingUnixDatagramServer
 -- クラス: socketserver.ThreadingUnixStreamServer
 -- クラス: socketserver.ThreadingUnixDatagramServer

     These classes are pre-defined using the mix-in classes.

Added in version 3.12: The ‘ForkingUnixStreamServer’ and
‘ForkingUnixDatagramServer’ classes were added.

サービスの実装には、 *note BaseRequestHandler: 39d1. からクラスを派生さ
せてその *note handle(): 39d2. メソッドを再定義しなければなりません。こ
のようにすれば、サーバクラスと要求処理クラスを結合して様々なバージョンの
サービスを実行することができます。要求処理クラスはデータグラムサービスか
ストリームサービスかで異なることでしょう。この違いは処理サブクラス *note
StreamRequestHandler: ca8. または *note DatagramRequestHandler: 39de. を
使うという形で隠蔽できます。

もちろん、まだ頭を使わなければなりません!  たとえば、サービスがリクエス
トによっては書き換えられるようなメモリ上の状態を使うならば、フォークする
サーバを使うのは馬鹿げています。というのも子プロセスでの書き換えは親プロ
セスで保存されている初期状態にも親プロセスから分配される各子プロセスの状
態にも届かないからです。この場合、スレッド実行するサーバを使うことはでき
ますが、共有データの一貫性を保つためにロックを使わなければならなくなるで
しょう。

一方、全てのデータが外部に(たとえばファイルシステムに)保存される HTTP サ
ーバを作っているのだとすると、同期クラスではどうしても一つの要求が処理さ
れている間サービスが「耳の聞こえない」状態を呈することになります -- この
状態はもしクライアントが要求した全てのデータをゆっくり受け取るととても長
い時間続きかねません。こういう場合にはサーバをスレッド実行したりフォーク
することが適切です。

ある場合には、要求の一部を同期的に処理する一方で、要求データに依って子プ
ロセスをフォークして処理を終了させる、といった方法も適当かもしれません。
こうした処理方法は同期サーバを使って要求処理クラスの *note handle():
39d2. メソッドの中で自分でフォークするようにして実装することができます。

Another approach to handling multiple simultaneous requests in an
environment that supports neither threads nor *note fork(): 17c. (or
where these are too expensive or inappropriate for the service) is to
maintain an explicit table of partially finished requests and to use
*note selectors: b0. to decide which request to work on next (or whether
to handle a new incoming request).  This is particularly important for
stream services where each client can potentially be connected for a
long time (if threads or subprocesses cannot be used).


File: python.info,  Node: Serverオブジェクト<2>,  Next: Request Handler Objects,  Prev: サーバ生成に関するノート,  Up: socketserver --- ネットワークサーバーのフレームワーク

5.21.16.2 Serverオブジェクト
............................

 -- クラス: socketserver.BaseServer (server_address,
          RequestHandlerClass)

     This is the superclass of all Server objects in the module.  It
     defines the interface, given below, but does not implement most of
     the methods, which is done in subclasses.  The two parameters are
     stored in the respective *note server_address: 39e0. and *note
     RequestHandlerClass: 39e1. attributes.

      -- メソッド: fileno ()

          サーバが要求待ちを行っているソケットのファイル記述子を整数で返
          します。この関数は一般的に、同じプロセス中の複数のサーバを監視
          できるようにするために、 *note selectors: b0. に渡されます。

      -- メソッド: handle_request ()

          単一の要求を処理します。この関数は以下のメソッド: *note
          get_request(): 39e3. 、 *note verify_request(): 39e4. 、および
          *note process_request(): 39e5. を順番に呼び出します。ハンドラ
          中でユーザによって提供された *note handle(): 39d2. が例外を送
          出した場合、サーバの *note handle_error(): d0f. メソッドが呼び
          出されます。 *note timeout: 12ef. 秒以内にリクエストが来なかっ
          た場合、 *note handle_timeout(): 12f0. が呼ばれて、 *note
          handle_request(): 12f1. が終了します。

      -- メソッド: serve_forever (poll_interval=0.5)

          Handle requests until an explicit *note shutdown(): 19a0.
          request.  Poll for shutdown every 'poll_interval' seconds.
          Ignores the *note timeout: 12ef. attribute.  It also calls
          *note service_actions(): 1111, which may be used by a subclass
          or mixin to provide actions specific to a given service.  For
          example, the *note ForkingMixIn: b45. class uses *note
          service_actions(): 1111. to clean up zombie child processes.

          バージョン 3.3 で変更: Added ‘service_actions’ call to the
          ‘serve_forever’ method.

      -- メソッド: service_actions ()

          This is called in the *note serve_forever(): 1112. loop.  This
          method can be overridden by subclasses or mixin classes to
          perform actions specific to a given service, such as cleanup
          actions.

          Added in version 3.3.

      -- メソッド: shutdown ()

          Tell the *note serve_forever(): 1112. loop to stop and wait
          until it does.  *note shutdown(): 19a0. must be called while
          *note serve_forever(): 1112. is running in a different thread
          otherwise it will deadlock.

      -- メソッド: server_close ()

          サーバをクリーンアップします。上書き出来ます。

      -- の属性: address_family

          サーバのソケットが属しているプロトコルファミリです。一般的な値
          は *note socket.AF_INET: 1788. および *note socket.AF_UNIX:
          178a. です。

      -- の属性: RequestHandlerClass

          ユーザが提供する要求処理クラスです; 要求ごとにこのクラスのイン
          スタンスが生成されます。

      -- の属性: server_address

          サーバが要求待ちを行うアドレスです。アドレスの形式はプロトコル
          ファミリによって異なります。詳細は *note socket: b8. モジュー
          ルを参照してください。インターネットプロトコルでは、この値は例
          えば ‘('127.0.0.1', 80)’ のようにアドレスを与える文字列と整数
          のポート番号を含むタプルです。

      -- の属性: socket

          サーバが入力の要求待ちを行うためのソケットオブジェクトです。

     サーバクラスは以下のクラス変数をサポートします:

      -- の属性: allow_reuse_address

          サーバがアドレスの再使用を許すかどうかを示す値です。この値は標
          準で *note False: b05. で、サブクラスで再使用ポリシを変更する
          ために設定することができます。

      -- の属性: request_queue_size

          要求待ち行列 (queue) のサイズです。単一の要求を処理するのに長
          時間かかる場合には、サーバが処理中に届いた要求は最大 *note
          request_queue_size: 39e9. 個まで待ち行列に置かれます。待ち行列
          が一杯になると、それ以降のクライアントからの要求は "接続拒否
          (Connection denied)" エラーになります。標準の値は通常 5 ですが
          、この値はサブクラスで上書きすることができます。

      -- の属性: socket_type

          サーバが使うソケットの型です; 一般的な2つの値は、 *note
          socket.SOCK_STREAM: 12c1. と *note socket.SOCK_DGRAM: 12c0. で
          す。

      -- の属性: timeout

          タイムアウト時間(秒)、もしくは、タイムアウトを望まない場合に
          *note None: 641. 。 *note handle_request(): 12f1. がこの時間内
          にリクエストを受信しない場合、 *note handle_timeout(): 12f0. メ
          ソッドが呼ばれます。

     *note TCPServer: 12ee. のような基底クラスのサブクラスで上書きできる
     サーバメソッドは多数あります; これらのメソッドはサーバオブジェクト
     の外部のユーザにとっては役にたたないものです。

      -- メソッド: finish_request (request, client_address)

          *note RequestHandlerClass: 39e1. をインスタンス化し、 *note
          handle(): 39d2. メソッドを呼び出して、実際に要求を処理します。

      -- メソッド: get_request ()

          ソケットから要求を受理して、クライアントとの通信に使われる '新
          しい' ソケットオブジェクト、およびクライアントのアドレスからな
          る、2 要素のタプルを返します。

      -- メソッド: handle_error (request, client_address)

          この関数は *note RequestHandlerClass: 39e1. インスタンスの
          *note handle(): 39d2. メソッドが例外を送出した際に呼び出されま
          す。標準の動作では標準エラー出力へトレースバックを出力し、後続
          する要求を継続して処理します。

          バージョン 3.6 で変更: Now only called for exceptions derived
          from the *note Exception: 9a7. class.

      -- メソッド: handle_timeout ()

          この関数は *note timeout: 12ef. 属性が *note None: 641. 以外に
          設定されて、リクエストがないままタイムアウト秒数が過ぎたときに
          呼ばれます。 fork型サーバーでのデフォルトの動作は、終了した子
          プロセスの情報を集めるようになっています。スレッド型サーバーで
          はこのメソッドは何もしません。

      -- メソッド: process_request (request, client_address)

          *note finish_request(): 39eb. を呼び出して、 *note
          RequestHandlerClass: 39e1. のインスタンスを生成します。必要な
          ら、この関数から新たなプロセスかスレッドを生成して要求を処理す
          ることができます; その処理は *note ForkingMixIn: b45. または
          *note ThreadingMixIn: b46. クラスが行います。

      -- メソッド: server_activate ()

          Called by the server's constructor to activate the server.
          The default behavior for a TCP server just invokes *note
          listen(): e27. on the server's socket.  May be overridden.

      -- メソッド: server_bind ()

          サーバのコンストラクタによって呼び出され、適切なアドレスにソケ
          ットをバインドします。このメソッドは上書きできます。

      -- メソッド: verify_request (request, client_address)

          ブール値を返さなければなりません; 値が *note True: bdb. の場合
          には要求が処理され、 *note False: b05. の場合には要求は拒否さ
          れます。サーバへのアクセス制御を実装するためにこの関数を上書き
          することができます。標準の実装では常に *note True: bdb. を返し
          ます。

     バージョン 3.6 で変更: *note context manager: 59e. プロトコルのサポ
     ートが追加されました。コンテキストマネージャを終了することは、
     *note server_close(): 39d3. を呼ぶことと同一です。


File: python.info,  Node: Request Handler Objects,  Next: 使用例<39>,  Prev: Serverオブジェクト<2>,  Up: socketserver --- ネットワークサーバーのフレームワーク

5.21.16.3 Request Handler Objects
.................................

 -- クラス: socketserver.BaseRequestHandler

     This is the superclass of all request handler objects.  It defines
     the interface, given below.  A concrete request handler subclass
     must define a new *note handle(): 39d2. method, and can override
     any of the other methods.  A new instance of the subclass is
     created for each request.

      -- メソッド: setup ()

          *note handle(): 39d2. メソッドより前に呼び出され、何らかの必要
          な初期化処理を行います。標準の実装では何も行いません。

      -- メソッド: handle ()

          This function must do all the work required to service a
          request.  The default implementation does nothing.  Several
          instance attributes are available to it; the request is
          available as *note request: 39ee.; the client address as *note
          client_address: 39ef.; and the server instance as *note
          server: 39f0, in case it needs access to per-server
          information.

          The type of *note request: 39ee. is different for datagram or
          stream services.  For stream services, *note request: 39ee. is
          a socket object; for datagram services, *note request: 39ee.
          is a pair of string and socket.

      -- メソッド: finish ()

          *note handle(): 39d2. メソッドより後に呼び出され、何らかの必要
          なクリーンアップ処理を行います。標準の実装では何も行いません。
          *note setup(): 39ed. メソッドが例外を送出した場合、このメソッ
          ドは呼び出されません。

      -- の属性: request

          The 'new' *note socket.socket: d6e. object to be used to
          communicate with the client.

      -- の属性: client_address

          Client address returned by *note BaseServer.get_request():
          39e3.

      -- の属性: server

          *note BaseServer: 1110. object used for handling the request.

 -- クラス: socketserver.StreamRequestHandler
 -- クラス: socketserver.DatagramRequestHandler

     These *note BaseRequestHandler: 39d1. subclasses override the *note
     setup(): 39ed. and *note finish(): 39f1. methods, and provide *note
     rfile: 39f2. and *note wfile: 39f3. attributes.

      -- の属性: rfile

          A file object from which receives the request is read.
          Support the *note io.BufferedIOBase: 660. readable interface.

      -- の属性: wfile

          A file object to which the reply is written.  Support the
          *note io.BufferedIOBase: 660. writable interface

     バージョン 3.6 で変更: *note wfile: 39f3. also supports the *note
     io.BufferedIOBase: 660. writable interface.


File: python.info,  Node: 使用例<39>,  Prev: Request Handler Objects,  Up: socketserver --- ネットワークサーバーのフレームワーク

5.21.16.4 使用例
................

* Menu:

* socketserver.TCPServer の例: socketserver TCPServer の例.
* socketserver.UDPServer の例: socketserver UDPServer の例.
* 非同期処理の Mix-in::


File: python.info,  Node: socketserver TCPServer の例,  Next: socketserver UDPServer の例,  Up: 使用例<39>

5.21.16.5 ‘socketserver.TCPServer’ の例
.......................................

サーバサイドの例です:

     import socketserver

     class MyTCPHandler(socketserver.BaseRequestHandler):
         """
         The request handler class for our server.

         It is instantiated once per connection to the server, and must
         override the handle() method to implement communication to the
         client.
         """

         def handle(self):
             # self.request is the TCP socket connected to the client
             self.data = self.request.recv(1024).strip()
             print("Received from {}:".format(self.client_address[0]))
             print(self.data)
             # just send back the same data, but upper-cased
             self.request.sendall(self.data.upper())

     if __name__ == "__main__":
         HOST, PORT = "localhost", 9999

         # Create the server, binding to localhost on port 9999
         with socketserver.TCPServer((HOST, PORT), MyTCPHandler) as server:
             # Activate the server; this will keep running until you
             # interrupt the program with Ctrl-C
             server.serve_forever()

別の、ストリーム(標準のファイル型のインターフェースを利用して通信をシン
プルにしたファイルライクオブジェクト)を使うリクエストハンドラクラスの例
です:

     class MyTCPHandler(socketserver.StreamRequestHandler):

         def handle(self):
             # self.rfile is a file-like object created by the handler;
             # we can now use e.g. readline() instead of raw recv() calls
             self.data = self.rfile.readline().strip()
             print("{} wrote:".format(self.client_address[0]))
             print(self.data)
             # Likewise, self.wfile is a file-like object used to write back
             # to the client
             self.wfile.write(self.data.upper())

The difference is that the ‘readline()’ call in the second handler will
call ‘recv()’ multiple times until it encounters a newline character,
while the single ‘recv()’ call in the first handler will just return
what has been received so far from the client's ‘sendall()’ call
(typically all of it, but this is not guaranteed by the TCP protocol).

クライアントサイドの例:

     import socket
     import sys

     HOST, PORT = "localhost", 9999
     data = " ".join(sys.argv[1:])

     # Create a socket (SOCK_STREAM means a TCP socket)
     with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
         # Connect to server and send data
         sock.connect((HOST, PORT))
         sock.sendall(bytes(data + "\n", "utf-8"))

         # Receive data from the server and shut down
         received = str(sock.recv(1024), "utf-8")

     print("Sent:     {}".format(data))
     print("Received: {}".format(received))

この例の出力は次のようになります:

サーバー:

     $ python TCPServer.py
     127.0.0.1 wrote:
     b'hello world with TCP'
     127.0.0.1 wrote:
     b'python is nice'

クライアント:

     $ python TCPClient.py hello world with TCP
     Sent:     hello world with TCP
     Received: HELLO WORLD WITH TCP
     $ python TCPClient.py python is nice
     Sent:     python is nice
     Received: PYTHON IS NICE


File: python.info,  Node: socketserver UDPServer の例,  Next: 非同期処理の Mix-in,  Prev: socketserver TCPServer の例,  Up: 使用例<39>

5.21.16.6 ‘socketserver.UDPServer’ の例
.......................................

サーバサイドの例です:

     import socketserver

     class MyUDPHandler(socketserver.BaseRequestHandler):
         """
         This class works similar to the TCP handler class, except that
         self.request consists of a pair of data and client socket, and since
         there is no connection the client address must be given explicitly
         when sending data back via sendto().
         """

         def handle(self):
             data = self.request[0].strip()
             socket = self.request[1]
             print("{} wrote:".format(self.client_address[0]))
             print(data)
             socket.sendto(data.upper(), self.client_address)

     if __name__ == "__main__":
         HOST, PORT = "localhost", 9999
         with socketserver.UDPServer((HOST, PORT), MyUDPHandler) as server:
             server.serve_forever()

クライアントサイドの例:

     import socket
     import sys

     HOST, PORT = "localhost", 9999
     data = " ".join(sys.argv[1:])

     # SOCK_DGRAM is the socket type to use for UDP sockets
     sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

     # As you can see, there is no connect() call; UDP has no connections.
     # Instead, data is directly sent to the recipient via sendto().
     sock.sendto(bytes(data + "\n", "utf-8"), (HOST, PORT))
     received = str(sock.recv(1024), "utf-8")

     print("Sent:     {}".format(data))
     print("Received: {}".format(received))

この例の出力は、TCPサーバーの例と全く同じようになります。


File: python.info,  Node: 非同期処理の Mix-in,  Prev: socketserver UDPServer の例,  Up: 使用例<39>

5.21.16.7 非同期処理の Mix-in
.............................

複数の接続を非同期に処理するハンドラを作るには、 *note ThreadingMixIn:
b46. か *note ForkingMixIn: b45. クラスを利用します。

*note ThreadingMixIn: b46. クラスの利用例:

     import socket
     import threading
     import socketserver

     class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler):

         def handle(self):
             data = str(self.request.recv(1024), 'ascii')
             cur_thread = threading.current_thread()
             response = bytes("{}: {}".format(cur_thread.name, data), 'ascii')
             self.request.sendall(response)

     class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
         pass

     def client(ip, port, message):
         with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
             sock.connect((ip, port))
             sock.sendall(bytes(message, 'ascii'))
             response = str(sock.recv(1024), 'ascii')
             print("Received: {}".format(response))

     if __name__ == "__main__":
         # Port 0 means to select an arbitrary unused port
         HOST, PORT = "localhost", 0

         server = ThreadedTCPServer((HOST, PORT), ThreadedTCPRequestHandler)
         with server:
             ip, port = server.server_address

             # Start a thread with the server -- that thread will then start one
             # more thread for each request
             server_thread = threading.Thread(target=server.serve_forever)
             # Exit the server thread when the main thread terminates
             server_thread.daemon = True
             server_thread.start()
             print("Server loop running in thread:", server_thread.name)

             client(ip, port, "Hello World 1")
             client(ip, port, "Hello World 2")
             client(ip, port, "Hello World 3")

             server.shutdown()

この例の出力は次のようになります:

     $ python ThreadedTCPServer.py
     Server loop running in thread: Thread-1
     Received: Thread-2: Hello World 1
     Received: Thread-3: Hello World 2
     Received: Thread-4: Hello World 3

*note ForkingMixIn: b45. クラスは同じように利用することができます。この
場合、サーバーはリクエスト毎に新しいプロセスを作成します。*note fork():
17c. をサポートする POSIX プラットフォームでのみ利用可能です。


File: python.info,  Node: http server --- HTTP サーバー,  Next: http cookies --- HTTP の状態管理,  Prev: socketserver --- ネットワークサーバーのフレームワーク,  Up: インターネットプロトコルとサポート

5.21.17 ‘http.server’ -- HTTP サーバー
--------------------------------------

'ソースコード:' Lib/http/server.py(1)

__________________________________________________________________

このモジュールは HTTP サーバを実装するためのクラスを提供しています。

     警告: *note http.server: 68. は、本番環境では推奨されません。これは
     、 *note 基本的なセキュリティチェック: 39fa. のみを実装します。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

クラス *note HTTPServer: 37fe. は *note socketserver.TCPServer: 12ee. の
サブクラスです。 *note HTTPServer: 37fe. は HTTP ソケットを生成してリク
エスト待ち (listen) を行い、リクエストをハンドラに渡します。 サーバを作
成して動作させるためのコードは以下のようになります:

     def run(server_class=HTTPServer, handler_class=BaseHTTPRequestHandler):
         server_address = ('', 8000)
         httpd = server_class(server_address, handler_class)
         httpd.serve_forever()

 -- クラス: http.server.HTTPServer (server_address, RequestHandlerClass)

     このクラスは *note TCPServer: 12ee. クラスの上に構築されており、サ
     ーバのアドレスをインスタンス変数 ‘server_name’ および ‘server_port’
     に記憶します。 サーバはハンドラからアクセス可能で、通常ハンドラの
     ‘server’ インスタンス変数からアクセスします。

 -- クラス: http.server.ThreadingHTTPServer (server_address,
          RequestHandlerClass)

     This class is identical to HTTPServer but uses threads to handle
     requests by using the *note ThreadingMixIn: b46.  This is useful to
     handle web browsers pre-opening sockets, on which *note HTTPServer:
     37fe. would wait indefinitely.

     Added in version 3.7.

*note HTTPServer: 37fe. と *note ThreadingHTTPServer: b12. は
'RequestHandlerClass' の初期化のときに与えられなければならず、このモジュ
ールはこのクラスの3つの変種を提供しています:

 -- クラス: http.server.BaseHTTPRequestHandler (request, client_address,
          server)

     このクラスはサーバに到着したリクエストを処理します。 このメソッド自
     体では、実際のリクエストに応答することはできません; (GET や POST の
     ような) 各リクエストメソッドを処理するためにはサブクラス化しなけれ
     ばなりません。 *note BaseHTTPRequestHandler: 109e. では、サブクラス
     で使うためのクラスやインスタンス変数、メソッド群を数多く提供してい
     ます。

     The handler will parse the request and the headers, then call a
     method specific to the request type.  The method name is
     constructed from the request.  For example, for the request method
     ‘SPAM’, the ‘do_SPAM()’ method will be called with no arguments.
     All of the relevant information is stored in instance variables of
     the handler.  Subclasses should not need to override or extend the
     ‘__init__()’ method.

     *note BaseHTTPRequestHandler: 109e. は以下のインスタンス変数を持っ
     ています:

      -- の属性: client_address

          HTTP クライアントのアドレスを参照している、‘(host, port)’ の形
          式をとるタプルが入っています。

      -- の属性: server

          server インスタンスが入っています。

      -- の属性: close_connection

          *note handle_one_request(): 39fe. が返る前に設定すべき真偽値で
          、別のリクエストが期待されているかどうか、もしくはコネクション
          を切断すべきかどうかを指し示しています。

      -- の属性: requestline

          HTTP リクエスト行の文字列表現を保持しています。 末尾の CRLF は
          除去されています。 この属性は *note handle_one_request():
          39fe. によって設定されるべきです。 妥当なリクエスト行が1行も処
          理されなかった場合は、空文字列に設定されるべきです。

      -- の属性: command

          HTTP 命令 (リクエスト形式) が入っています。例えば ‘'GET'’ です
          。

      -- の属性: path

          Contains the request path.  If query component of the URL is
          present, then ‘path’ includes the query.  Using the
          terminology of RFC 3986(2), ‘path’ here includes ‘hier-part’
          and the ‘query’.

      -- の属性: request_version

          リクエストのバージョン文字列が入っています。例えば
          ‘'HTTP/1.0'’ です。

      -- の属性: headers

          *note MessageClass: 3a03. クラス変数で指定されたクラスのインス
          タンスを保持しています。 このインスタンスは HTTP リクエストの
          ヘッダを解釈し、管理しています。 *note http.client: 65. の
          *note parse_headers(): 19b4. 関数がヘッダを解釈するために使わ
          れ、 HTTP リクエストが妥当な RFC 2822(3) スタイルのヘッダを提
          供することを要求します。

      -- の属性: rfile

          An *note io.BufferedIOBase: 660. input stream, ready to read
          from the start of the optional input data.

      -- の属性: wfile

          Contains the output stream for writing a response back to the
          client.  Proper adherence to the HTTP protocol must be used
          when writing to this stream in order to achieve successful
          interoperation with HTTP clients.

          バージョン 3.6 で変更: This is an *note io.BufferedIOBase:
          660. stream.

     *note BaseHTTPRequestHandler: 109e. は以下の属性を持っています:

      -- の属性: server_version

          サーバのソフトウェアバージョンを指定します。この値は上書きする
          必要が生じるかもしれません。書式は複数の文字列を空白で分割した
          もので、各文字列はソフトウェア名[/バージョン] の形式をとります
          。例えば、‘'BaseHTTP/0.2'’ です。

      -- の属性: sys_version

          Python 処理系のバージョンが, *note version_string: 3a08. メソ
          ッドや *note server_version: 3a06. クラス変数で利用可能な形式
          で入っています。例えば ‘'Python/1.4'’ です。

      -- の属性: error_message_format

          Specifies a format string that should be used by *note
          send_error(): f1d. method for building an error response to
          the client.  The string is filled by default with variables
          from *note responses: 38ce. based on the status code that
          passed to *note send_error(): f1d.

      -- の属性: error_content_type

          エラーレスポンスをクライアントに送信する時に使う Content-Type
          HTTP ヘッダを指定します。デフォルトでは ‘'text/html'’ です。

      -- の属性: protocol_version

          Specifies the HTTP version to which the server is conformant.
          It is sent in responses to let the client know the server's
          communication capabilities for future requests.  If set to
          ‘'HTTP/1.1'’, the server will permit HTTP persistent
          connections; however, your server 'must' then include an
          accurate ‘Content-Length’ header (using *note send_header():
          3a0c.) in all of its responses to clients.  For backwards
          compatibility, the setting defaults to ‘'HTTP/1.0'’.

      -- の属性: MessageClass

          HTTP ヘッダを解釈するための *note email.message.Message: 25d.
          類似のクラスを指定します。 通常この値が上書きされることはなく
          、デフォルトの *note http.client.HTTPMessage: 38e5. になってい
          ます。

      -- の属性: responses

          This attribute contains a mapping of error code integers to
          two-element tuples containing a short and long message.  For
          example, ‘{code: (shortmessage, longmessage)}’.  The
          'shortmessage' is usually used as the 'message' key in an
          error response, and 'longmessage' as the 'explain' key.  It is
          used by *note send_response_only(): 3a0d. and *note
          send_error(): f1d. methods.

     *note BaseHTTPRequestHandler: 109e. インスタンスは以下のメソッドを
     持っています:

      -- メソッド: handle ()

          Calls *note handle_one_request(): 39fe. once (or, if
          persistent connections are enabled, multiple times) to handle
          incoming HTTP requests.  You should never need to override it;
          instead, implement appropriate ‘do_*()’ methods.

      -- メソッド: handle_one_request ()

          This method will parse and dispatch the request to the
          appropriate ‘do_*()’ method.  You should never need to
          override it.

      -- メソッド: handle_expect_100 ()

          HTTP/1.1 準拠のサーバが ‘Expect: 100-continue’ リクエストヘッ
          ダを受け取ったとき、 ‘100 Continue’ を返し、その後に ‘200 OK’
          がきます。 このメソッドは、サーバがクライアントに継続を要求し
          ない場合、エラーを送出するようにオーバーライドできます。 例え
          ば、サーバはレスポンスヘッダとして ‘417 Expectation Failed’ を
          送る選択をし、 ‘return False’ とできます。

          Added in version 3.2.

      -- メソッド: send_error (code, message=None, explain=None)

          Sends and logs a complete error reply to the client.  The
          numeric 'code' specifies the HTTP error code, with 'message'
          as an optional, short, human readable description of the
          error.  The 'explain' argument can be used to provide more
          detailed information about the error; it will be formatted
          using the *note error_message_format: 3a09. attribute and
          emitted, after a complete set of headers, as the response
          body.  The *note responses: 38ce. attribute holds the default
          values for 'message' and 'explain' that will be used if no
          value is provided; for unknown codes the default value for
          both is the string ‘???’.  The body will be empty if the
          method is HEAD or the response code is one of the following:
          ‘1XX’, ‘204 No Content’, ‘205 Reset Content’, ‘304 Not
          Modified’.

          バージョン 3.4 で変更: The error response includes a
          Content-Length header.  Added the 'explain' argument.

      -- メソッド: send_response (code, message=None)

          Adds a response header to the headers buffer and logs the
          accepted request.  The HTTP response line is written to the
          internal buffer, followed by 'Server' and 'Date' headers.  The
          values for these two headers are picked up from the *note
          version_string(): 3a08. and *note date_time_string(): 3a11.
          methods, respectively.  If the server does not intend to send
          any other headers using the *note send_header(): 3a0c. method,
          then *note send_response(): 3a10. should be followed by an
          *note end_headers(): 109f. call.

          バージョン 3.3 で変更: Headers are stored to an internal
          buffer and *note end_headers(): 109f. needs to be called
          explicitly.

      -- メソッド: send_header (keyword, value)

          Adds the HTTP header to an internal buffer which will be
          written to the output stream when either *note end_headers():
          109f. or *note flush_headers(): 10a0. is invoked.  'keyword'
          should specify the header keyword, with 'value' specifying its
          value.  Note that, after the send_header calls are done, *note
          end_headers(): 109f. MUST BE called in order to complete the
          operation.

          バージョン 3.2 で変更: ヘッダは内部バッファに保存されます。

      -- メソッド: send_response_only (code, message=None)

          Sends the response header only, used for the purposes when
          ‘100 Continue’ response is sent by the server to the client.
          The headers not buffered and sent directly the output
          stream.If the 'message' is not specified, the HTTP message
          corresponding the response 'code' is sent.

          Added in version 3.2.

      -- メソッド: end_headers ()

          Adds a blank line (indicating the end of the HTTP headers in
          the response) to the headers buffer and calls *note
          flush_headers(): 10a0.

          バージョン 3.2 で変更: バッファされたヘッダは出力ストリームに
          書き出されます。

      -- メソッド: flush_headers ()

          最終的にヘッダを出力ストリームに送り、内部ヘッダバッファをフラ
          ッシュします。

          Added in version 3.3.

      -- メソッド: log_request (code='-', size='-')

          受理された (成功した) リクエストをログに記録します。'code' に
          はこの応答に関連付けられた HTTP コード番号を指定します。応答メ
          ッセージの大きさを知ることができる場合、'size' パラメタに渡す
          とよいでしょう。

      -- メソッド: log_error (...)

          リクエストを遂行できなかった際に、エラーをログに記録します。標
          準では、メッセージを *note log_message(): 3a14. に渡します。従
          って同じ引数 ('format' と追加の値) を取ります。

      -- メソッド: log_message (format, ...)

          任意のメッセージを ‘sys.stderr’ にログ記録します。このメソッド
          は通常、カスタムのエラーログ記録機構を作成するために上書きされ
          ます。 'format' 引数は標準の printf 形式の書式文字列で、 *note
          log_message(): 3a14. に渡された追加の引数は書式化の入力として
          適用されます。ログ記録される全てのメッセージには、クライアント
          の IP アドレスおよび現在の日付、時刻が先頭に付けられます。

      -- メソッド: version_string ()

          サーバーのソフトウェアのバージョンを示す文字列を返します。 そ
          の文字列は、*note server_version: 3a06. と *note sys_version:
          3a07. の属性が含まれます。

      -- メソッド: date_time_string (timestamp=None)

          メッセージヘッダ向けに書式化された、 'timestamp' (‘None’ また
          は *note time.time(): 235. のフォーマットである必要があります
          )で与えられた日時を返します。もし 'timestamp' が省略された場合
          には、現在の日時が使われます。

          出力は ‘'Sun, 06 Nov 1994 08:49:37 GMT'’ のようになります。

      -- メソッド: log_date_time_string ()

          ログ記録向けに書式化された、現在の日付および時刻を返します。

      -- メソッド: address_string ()

          クライアントのアドレスを返します。

          バージョン 3.3 で変更: Previously, a name lookup was
          performed.  To avoid name resolution delays, it now always
          returns the IP address.

 -- クラス: http.server.SimpleHTTPRequestHandler (request,
          client_address, server, directory=None)

     This class serves files from the directory 'directory' and below,
     or the current directory if 'directory' is not provided, directly
     mapping the directory structure to HTTP requests.

     バージョン 3.7 で変更: Added the 'directory' parameter.

     バージョン 3.9 で変更: The 'directory' parameter accepts a *note
     path-like object: 280.

     リクエストの解釈のような、多くの作業は基底クラス *note
     BaseHTTPRequestHandler: 109e. で行われます。このクラスは関数 *note
     do_GET(): 3a17. および *note do_HEAD(): 3a18. を実装しています。

     *note SimpleHTTPRequestHandler: b11. では以下のメンバ変数を定義して
     います:

      -- の属性: server_version

          この値は ‘"SimpleHTTP/" + __version__’ になります。
          ‘__version__’ はこのモジュールで定義されている値です。

      -- の属性: extensions_map

          A dictionary mapping suffixes into MIME types, contains custom
          overrides for the default system mappings.  The mapping is
          used case-insensitively, and so should contain only
          lower-cased keys.

          バージョン 3.9 で変更: This dictionary is no longer filled
          with the default system mappings, but only contains overrides.

     *note SimpleHTTPRequestHandler: b11. では以下のメソッドを定義してい
     ます:

      -- メソッド: do_HEAD ()

          このメソッドは ‘'HEAD'’ 型のリクエスト処理を実行します: すなわ
          ち、 ‘GET’ リクエストの時に送信されるものと同じヘッダを送信し
          ます。送信される可能性のあるヘッダについての完全な説明は *note
          do_GET(): 3a17. メソッドを参照してください。

      -- メソッド: do_GET ()

          リクエストを現在の作業ディレクトリからの相対的なパスとして解釈
          することで、リクエストをローカルシステム上のファイルと対応付け
          ます。

          リクエストがディレクトリに対応付けられた場合、 ‘index.html’ ま
          たは ‘index.htm’ を (この順序で) チェックします。もしファイル
          を発見できればその内容を、そうでなければディレクトリ一覧を
          ‘list_directory()’ メソッドで生成して、返します。このメソッド
          は *note os.listdir(): 10cd. をディレクトリのスキャンに用いて
          おり、 *note listdir(): 10cd. が失敗した場合には ‘404’ 応答が
          返されます。

          If the request was mapped to a file, it is opened.  Any *note
          OSError: 3f0. exception in opening the requested file is
          mapped to a ‘404’, ‘'File not found'’ error.  If there was an
          ‘'If-Modified-Since'’ header in the request, and the file was
          not modified after this time, a ‘304’, ‘'Not Modified'’
          response is sent.  Otherwise, the content type is guessed by
          calling the ‘guess_type()’ method, which in turn uses the
          'extensions_map' variable, and the file contents are returned.

          出力は ‘'Content-type:'’ と推測されたコンテントタイプで、その
          後にファイルサイズを示す ‘'Content-Length;'’ ヘッダと、ファイ
          ルの更新日時を示す ‘'Last-Modified:'’ ヘッダが続きます。

          そしてヘッダの終了を示す空白行が続き、さらにその後にファイルの
          内容が続きます。このファイルはコンテントタイプが ‘text/’ で始
          まっている場合はテキストモードで、そうでなければバイナリモード
          で開かれます。

          For example usage, see the implementation of the ‘test’
          function in Lib/http/server.py(4).

          バージョン 3.7 で変更: Support of the ‘'If-Modified-Since'’
          header.

The *note SimpleHTTPRequestHandler: b11. class can be used in the
following manner in order to create a very basic webserver serving files
relative to the current directory:

     import http.server
     import socketserver

     PORT = 8000

     Handler = http.server.SimpleHTTPRequestHandler

     with socketserver.TCPServer(("", PORT), Handler) as httpd:
         print("serving at port", PORT)
         httpd.serve_forever()

*note SimpleHTTPRequestHandler: b11. can also be subclassed to enhance
behavior, such as using different index file names by overriding the
class attribute ‘index_pages’.  *note http.server: 68. はインタプリタの
*note -m: 5ab. スイッチを使って直接実行することもできます。上の例と同じ
ように、これはカレントディレクトリ以下のファイルへのアクセスを提供します
:

     python -m http.server

The server listens to port 8000 by default.  The default can be
overridden by passing the desired port number as an argument:

     python -m http.server 9000

By default, the server binds itself to all interfaces.  The option
‘-b/--bind’ specifies a specific address to which it should bind.  Both
IPv4 and IPv6 addresses are supported.  For example, the following
command causes the server to bind to localhost only:

     python -m http.server --bind 127.0.0.1

バージョン 3.4 で変更: Added the ‘--bind’ option.

バージョン 3.8 で変更: Support IPv6 in the ‘--bind’ option.

By default, the server uses the current directory.  The option
‘-d/--directory’ specifies a directory to which it should serve the
files.  For example, the following command uses a specific directory:

     python -m http.server --directory /tmp/

バージョン 3.7 で変更: Added the ‘--directory’ option.

By default, the server is conformant to HTTP/1.0.  The option
‘-p/--protocol’ specifies the HTTP version to which the server is
conformant.  For example, the following command runs an HTTP/1.1
conformant server:

     python -m http.server --protocol HTTP/1.1

バージョン 3.11 で変更: Added the ‘--protocol’ option.

 -- クラス: http.server.CGIHTTPRequestHandler (request, client_address,
          server)

     このクラスは、現在のディレクトリかその下のディレクトリにおいて、フ
     ァイルか CGI スクリプト出力を提供するために使われます。 HTTP 階層構
     造からローカルなディレクトリ構造への対応付けは *note
     SimpleHTTPRequestHandler: b11. と全く同じなので注意してください。

          注釈: *note CGIHTTPRequestHandler: 281. クラスで実行される CGI
          スクリプトは HTTP コード 200 (スクリプトの出力が後に続く) を実
          行に先立って出力される (これがステータスコードになります) ため
          、リダイレクト(コード302) を行なうことができません。

     このクラスでは、ファイルが CGI スクリプトであると推測された場合、こ
     れをファイルとして提供する代わりにスクリプトを実行します。 -- 他の
     一般的なサーバ設定は特殊な拡張子を使って CGI スクリプトであることを
     示すのに対し、ディレクトリベースの CGI だけが使われます。

     ‘do_GET()’ および ‘do_HEAD()’ 関数は、HTTP 要求が ‘cgi_directories’
     パス以下のどこかを指している場合、ファイルを提供するのではなく、CGI
     スクリプトを実行してその出力を提供するように変更されています。

     *note CGIHTTPRequestHandler: 281. では以下のデータメンバを定義して
     います:

      -- の属性: cgi_directories

          この値は標準で ‘['/cgi-bin', '/htbin']’ であり、CGI スクリプト
          を含んでいることを示すディレクトリを記述します。

     *note CGIHTTPRequestHandler: 281. は以下のメソッドを定義しています:

      -- メソッド: do_POST ()

          このメソッドは、CGI スクリプトでのみ許されている ‘'POST'’ 型の
          HTTP 要求に対するサービスを行います。CGI でない url に対して
          POST を試みた場合、出力は Error 501, "Can only POST to CGI
          scripts" になります。

     セキュリティ上の理由から、CGI スクリプトはユーザ nobody の UID で動
     作するので注意してください。 CGI スクリプトが原因で発生した問題は、
     Error 403 に変換されます。

     Deprecated since version 3.13, will be removed in version 3.15:
     *note CGIHTTPRequestHandler: 281. is being removed in 3.15.  CGI
     has not been considered a good way to do things for well over a
     decade.  This code has been unmaintained for a while now and sees
     very little practical use.  Retaining it could lead to further
     *note security considerations: 39fa.

*note CGIHTTPRequestHandler: 281. can be enabled in the command line by
passing the ‘--cgi’ option:

     python -m http.server --cgi

Deprecated since version 3.13, will be removed in version 3.15: *note
http.server: 68. command line ‘--cgi’ support is being removed because
*note CGIHTTPRequestHandler: 281. is being removed.

     警告: *note CGIHTTPRequestHandler: 281. and the ‘--cgi’ command
     line option are not intended for use by untrusted clients and may
     be vulnerable to exploitation.  Always use within a secure
     environment.

* Menu:

* セキュリティで考慮すべき点: セキュリティで考慮すべき点<5>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/http/server.py

   (2) https://datatracker.ietf.org/doc/html/rfc3986.html

   (3) https://datatracker.ietf.org/doc/html/rfc2822.html

   (4) https://github.com/python/cpython/tree/3.13/Lib/http/server.py


File: python.info,  Node: セキュリティで考慮すべき点<5>,  Up: http server --- HTTP サーバー

5.21.17.1 セキュリティで考慮すべき点
....................................

*note SimpleHTTPRequestHandler: b11. will follow symbolic links when
handling requests, this makes it possible for files outside of the
specified directory to be served.

Earlier versions of Python did not scrub control characters from the log
messages emitted to stderr from ‘python -m http.server’ or the default
*note BaseHTTPRequestHandler: 109e. ‘.log_message’ implementation.  This
could allow remote clients connecting to your server to send nefarious
control codes to your terminal.

バージョン 3.12 で変更: Control characters are scrubbed in stderr logs.


File: python.info,  Node: http cookies --- HTTP の状態管理,  Next: http cookiejar --- HTTP クライアント用の Cookie 処理,  Prev: http server --- HTTP サーバー,  Up: インターネットプロトコルとサポート

5.21.18 ‘http.cookies’ -- HTTP の状態管理
-----------------------------------------

'ソースコード:' Lib/http/cookies.py(1)

__________________________________________________________________

*note http.cookies: 67. モジュールはHTTPの状態管理機能であるcookieの概念
を抽象化、定義しているクラスです。単純な文字列のみで構成されるcookieのほ
か、シリアル化可能なあらゆるデータ型でクッキーの値を保持するための機能も
備えています。

このモジュールは元々 RFC 2109(2) と RFC 2068(3) に定義されている構文解析
の規則を厳密に守っていました。しかし、MSIE 3.0x がこれらの RFC で定義さ
れた文字の規則に従っていなかったことが判明し、現在の多くのブラウザーとサ
ーバーも Cookie の処理に関しては緩い解析を行っています。結局、このモジュ
ールは昔よりもやや厳密さを欠く構文解析規則になっています。

文字集合 *note string.ascii_letters: 1293. 、 *note string.digits: 221e.
、 ‘!#$%&'*+-.^_`|~:’ を、このモジュールは cookie 名 (*note key: bcf.) と
して有効と認めています。

バージョン 3.3 で変更: ':' が有効な cookie 名の文字として認められました
。

     注釈: 不正な cookie に遭遇した場合、 *note CookieError: 3a20. 例外
     を送出します。そのため、ブラウザから持ってきた cookie データをパー
     スするときには常に不正なデータに備え *note CookieError: 3a20. 例外
     を捕捉してください。

 -- 例外: http.cookies.CookieError

     属性や ‘Set-Cookie’ ヘッダが正しくないなど、 RFC 2109(4) に合致して
     いないときに発生する例外です。

 -- クラス: http.cookies.BaseCookie ([input])

     このクラスはキーが文字列、値が *note Morsel: bd2. インスタンスで構
     成される辞書風オブジェクトです。値に対するキーを設定するときは、値
     がキーと値を含む *note Morsel: bd2. に変換されることに注意してくだ
     さい。

     'input' が与えられたときは、そのまま *note load(): 3a22. メソッドへ
     渡されます。

 -- クラス: http.cookies.SimpleCookie ([input])

     このクラスは *note BaseCookie: 3a21. を継承し、 *note
     value_decode(): 3a23. と *note value_encode(): 3a24. をオーバーライ
     ドします。 ‘SimpleCookie’ は文字列と cookie 値をサポートします。値
     を設定するとき、 ‘SimpleCookie’ は組み込みの *note str(): 418. を呼
     び出して値を文字列に変換します。HTTP から受け取った値は文字列として
     保持されます。

参考
....

モジュール *note http.cookiejar: 66.

     Web 'クライアント' 向けの HTTP クッキー処理です。 *note
     http.cookiejar: 66. と *note http.cookies: 67. は互いに独立していま
     す。

RFC 2109(5) - HTTP State Management Mechanism

     このモジュールが実装しているHTTPの状態管理に関する規格です。

* Menu:

* Cookieオブジェクト::
* Morselオブジェクト::
* 使用例: 使用例<40>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/http/cookies.py

   (2) https://datatracker.ietf.org/doc/html/rfc2109.html

   (3) https://datatracker.ietf.org/doc/html/rfc2068.html

   (4) https://datatracker.ietf.org/doc/html/rfc2109.html

   (5) https://datatracker.ietf.org/doc/html/rfc2109.html


File: python.info,  Node: Cookieオブジェクト,  Next: Morselオブジェクト,  Up: http cookies --- HTTP の状態管理

5.21.18.1 Cookieオブジェクト
............................

 -- メソッド: BaseCookie.value_decode (val)

     文字列表現のタプル ‘(real_value, coded_value)’ を返します。
     ‘real_value’ の型はどのようなものでも許容されます。このメソッドは
     *note BaseCookie: 3a21. においてデコードを行わず、オーバーライドさ
     れるためにだけ存在します。

 -- メソッド: BaseCookie.value_encode (val)

     タプル ‘(real_value, coded_value)’ を返します。 'val' の型はどのよ
     うなものでも許容されますが、 ‘coded_value’ は常に文字列に変換されま
     す。このメソッドは *note BaseCookie: 3a21. においてエンコードを行わ
     ず、オーバーライドされるためにだけ存在します。

     通常 *note value_encode(): 3a24. と *note value_decode(): 3a23. は
     ともに 'value_decode' の処理内容から逆算した範囲に収まっていなけれ
     ばなりません。

 -- メソッド: BaseCookie.output (attrs=None, header='Set-Cookie:',
          sep='\r\n')

     HTTPヘッダ形式の文字列表現を返します。 'attrs' と 'header' はそれぞ
     れ *note Morsel: bd2. の *note output(): 3a27. メソッドに送られます
     。 'sep' はヘッダの連結に用いられる文字で、デフォルトは ‘'\r\n'’
     (CRLF)となっています。

 -- メソッド: BaseCookie.js_output (attrs=None)

     ブラウザがJavaScriptをサポートしている場合、HTTPヘッダを送信した場
     合と同様に動作する埋め込み可能なJavaScript snippetを返します。

     'attrs' の意味は *note output(): 3a27. と同じです。

 -- メソッド: BaseCookie.load (rawdata)

     'rawdata' が文字列であれば、 ‘HTTP_COOKIE’ として処理し、その値を
     *note Morsel: bd2. として追加します。辞書の場合は次と同様の処理をお
     こないます。

          for k, v in rawdata.items():
              cookie[k] = v


File: python.info,  Node: Morselオブジェクト,  Next: 使用例<40>,  Prev: Cookieオブジェクト,  Up: http cookies --- HTTP の状態管理

5.21.18.2 Morselオブジェクト
............................

 -- クラス: http.cookies.Morsel

     RFC 2109(1) の属性をキーと値で保持するabstractクラスです。

     Morselは辞書風のオブジェクトで、キーは次のような RFC 2109(2) 準拠の
     定数となっています:

           -- の属性: expires
           -- の属性: path
           -- の属性: comment
           -- の属性: domain

           -- の属性: max-age
           -- の属性: secure
           -- の属性: version
           -- の属性: httponly
           -- の属性: samesite

     *note httponly: 1378. 属性は、 cookie が HTTP リクエストでのみ送信
     されて、 JavaScript からのはアクセスできない事を示します。これはい
     くつかのクロスサイトスクリプティングの脅威を和らげることを意図して
     います。

     *note samesite: 3a31. 属性は、ブラウザーがクロスサイトリクエストに
     加えて cookie の送信も禁止することを指定します。これは CSRF 攻撃の
     軽減に役立ちます。この属性い有効な値は、 "Strict" と "Lax" です。

     キーの大小文字は区別されません。そのデフォルト値は ‘''’ です。

     バージョン 3.5 で変更: ‘__eq__()’ は *note key: bcf. 及び *note
     value: bd0. を考慮するようになりました。

     バージョン 3.7 で変更: *note key: bcf. と *note value: bd0. 、
     *note coded_value: bd1. 属性は読み出し専用です。設定には、 *note
     set(): bd3. を使用してください。

     バージョン 3.8 で変更: *note samesite: 3a31. 属性がサポートされまし
     た。

 -- の属性: Morsel.value

     クッキーの値。

 -- の属性: Morsel.coded_value

     実際に送信する形式にエンコードされたcookieの値。

 -- の属性: Morsel.key

     cookieの名前。

 -- メソッド: Morsel.set (key, value, coded_value)

     属性 'key' 、 'value' 、 'coded_value' に値をセットします。

 -- メソッド: Morsel.isReservedKey (K)

     'K' が *note Morsel: bd2. のキーであるかどうかを判定します。

 -- メソッド: Morsel.output (attrs=None, header='Set-Cookie:')

     MoselをHTTPヘッダ形式の文字列表現にして返します。 'attrs' を指定し
     ない場合、デフォルトですべての属性を含めます。 'attrs' を指定する場
     合、属性をリストで渡さなければなりません。 'header' のデフォルトは
     ‘"Set-Cookie:"’ です。

 -- メソッド: Morsel.js_output (attrs=None)

     ブラウザがJavaScriptをサポートしている場合、HTTPヘッダを送信した場
     合と同様に動作する埋め込み可能なJavaScript snippetを返します。

     'attrs' の意味は *note output(): 3a33. と同じです。

 -- メソッド: Morsel.OutputString (attrs=None)

     Moselの文字列表現をHTTPやJavaScriptで囲まずに出力します。

     'attrs' の意味は *note output(): 3a33. と同じです。

 -- メソッド: Morsel.update (values)

     Morsel 辞書の値を辞書 'values' の値で更新します。'values' 辞書のキ
     ーのいずれかが有効な RFC 2109(3) 属性でない場合エラーを送出します。

     バージョン 3.5 で変更: 不正なキーではエラーが送出されます。

 -- メソッド: Morsel.copy (value)

     Morsel オブジェクトの浅いコピーを返します。

     バージョン 3.5 で変更: 辞書ではなく Morsel オブジェクトを返します。

 -- メソッド: Morsel.setdefault (key, value=None)

     キーが有効な RFC 2109(4) 属性でない場合エラーを送出します。そうでな
     い場合は *note dict.setdefault(): 104e. と同じように振る舞います。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2109.html

   (2) https://datatracker.ietf.org/doc/html/rfc2109.html

   (3) https://datatracker.ietf.org/doc/html/rfc2109.html

   (4) https://datatracker.ietf.org/doc/html/rfc2109.html


File: python.info,  Node: 使用例<40>,  Prev: Morselオブジェクト,  Up: http cookies --- HTTP の状態管理

5.21.18.3 使用例
................

次の例は *note http.cookies: 67. の使い方を示したものです。

     >>> from http import cookies
     >>> C = cookies.SimpleCookie()
     >>> C["fig"] = "newton"
     >>> C["sugar"] = "wafer"
     >>> print(C) # generate HTTP headers
     Set-Cookie: fig=newton
     Set-Cookie: sugar=wafer
     >>> print(C.output()) # same thing
     Set-Cookie: fig=newton
     Set-Cookie: sugar=wafer
     >>> C = cookies.SimpleCookie()
     >>> C["rocky"] = "road"
     >>> C["rocky"]["path"] = "/cookie"
     >>> print(C.output(header="Cookie:"))
     Cookie: rocky=road; Path=/cookie
     >>> print(C.output(attrs=[], header="Cookie:"))
     Cookie: rocky=road
     >>> C = cookies.SimpleCookie()
     >>> C.load("chips=ahoy; vienna=finger") # load from a string (HTTP header)
     >>> print(C)
     Set-Cookie: chips=ahoy
     Set-Cookie: vienna=finger
     >>> C = cookies.SimpleCookie()
     >>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
     >>> print(C)
     Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
     >>> C = cookies.SimpleCookie()
     >>> C["oreo"] = "doublestuff"
     >>> C["oreo"]["path"] = "/"
     >>> print(C)
     Set-Cookie: oreo=doublestuff; Path=/
     >>> C = cookies.SimpleCookie()
     >>> C["twix"] = "none for you"
     >>> C["twix"].value
     'none for you'
     >>> C = cookies.SimpleCookie()
     >>> C["number"] = 7 # equivalent to C["number"] = str(7)
     >>> C["string"] = "seven"
     >>> C["number"].value
     '7'
     >>> C["string"].value
     'seven'
     >>> print(C)
     Set-Cookie: number=7
     Set-Cookie: string=seven


File: python.info,  Node: http cookiejar --- HTTP クライアント用の Cookie 処理,  Next: xmlrpc --- XMLRPC サーバーとクライアントモジュール群,  Prev: http cookies --- HTTP の状態管理,  Up: インターネットプロトコルとサポート

5.21.19 ‘http.cookiejar’ -- HTTP クライアント用の Cookie 処理
-------------------------------------------------------------

'ソースコード:' Lib/http/cookiejar.py(1)

__________________________________________________________________

*note http.cookiejar: 66. モジュールは HTTP クッキーの自動処理をおこなう
クラスを定義します。これは小さなデータの断片 - 'クッキー' - を要求する
web サイトにアクセスする際に有用です。クッキーとは web サーバの HTTP レ
スポンスによってクライアントのマシンに設定され、のちの HTTP リクエストを
おこなうさいにサーバに返されるものです。

標準的な Netscape クッキープロトコルおよび RFC 2965(2) で定義されている
プロトコルの両方を処理できます。RFC 2965 の処理はデフォルトではオフにな
っています。 RFC 2109(3) のクッキーは Netscape クッキーとして解析され、
のちに有効な 'ポリシー' に従って Netscapeまたは RFC 2965 クッキーとして
処理されます。但し、インターネット上の大多数のクッキーは Netscapeクッキ
ーです。 *note http.cookiejar: 66. はデファクトスタンダードの Netscape ク
ッキープロトコル (これは元々 Netscape が策定した仕様とはかなり異なってい
ます) に従うようになっており、RFC 2109 で導入された ‘max-age’ や ‘port’
などのクッキー属性にも注意を払います。

     注釈: ‘Set-Cookie’ や ‘Set-Cookie2’ ヘッダに現れる多種多様なパラメ
     ータの名前 (‘domain’ や ‘expires’ など) は便宜上 '属性' と呼ばれま
     すが、ここでは Python の属性と区別するため、かわりに 'クッキー属性'
     と呼ぶことにします。

このモジュールは以下の例外を定義しています:

 -- 例外: http.cookiejar.LoadError

     この例外は *note FileCookieJar: 3a3c. インスタンスがファイルからク
     ッキーを読み込むのに失敗した場合に発生します。 *note LoadError:
     3a3b. は *note OSError: 3f0. のサブクラスです。

     バージョン 3.3 で変更: *note LoadError: 3a3b. は以前は *note
     IOError: 1026. のサブタイプでしたが、 *note OSError: 3f0. のエイリ
     アスになりました。

以下のクラスが提供されています:

 -- クラス: http.cookiejar.CookieJar (policy=None)

     'policy' は *note CookiePolicy: 3a3d. インターフェイスを実装するオ
     ブジェクトです。

     *note CookieJar: 386e. クラスには HTTP クッキーを保管します。これは
     HTTP リクエストに応じてクッキーを取り出し、それを HTTP レスポンスの
     中で返します。必要に応じて、 *note CookieJar: 386e. インスタンスは
     保管されているクッキーを自動的に破棄します。このサブクラスは、クッ
     キーをファイルやデータベースに格納したり取り出したりする操作をおこ
     なう役割を負っています。

 -- クラス: http.cookiejar.FileCookieJar (filename=None, delayload=None,
          policy=None)

     'policy' は *note CookiePolicy: 3a3d. インターフェイスを実装するオ
     ブジェクトです。これ以外の引数については、該当する属性の説明を参照
     してください。

     *note FileCookieJar: 3a3c. はディスク上のファイルからのクッキーの読
     み込み、もしくは書き込みをサポートします。実際には、 *note load():
     3a3e. または *note revert(): 3a3f. のどちらかのメソッドが呼ばれるま
     でクッキーは指定されたファイルからはロード 'されません' 。このクラ
     スのサブクラスは *note FileCookieJar のサブクラスと web
     ブラウザとの連携: 3a40. 節で説明します。

     これは直接初期化されるべきではありません。以下のサブクラスを代わり
     に使用してください。

     バージョン 3.8 で変更: 'filename' 引数が *note path-like object:
     280. を受け付けるようになりました。

 -- クラス: http.cookiejar.CookiePolicy

     このクラスは、あるクッキーをサーバから受け入れるべきか、そしてサー
     バに返すべきかを決定する役割を負っています。

 -- クラス: http.cookiejar.DefaultCookiePolicy (blocked_domains=None,
          allowed_domains=None, netscape=True, rfc2965=False,
          rfc2109_as_netscape=None, hide_cookie2=False,
          strict_domain=False, strict_rfc2965_unverifiable=True,
          strict_ns_unverifiable=False,
          strict_ns_domain=DefaultCookiePolicy.DomainLiberal,
          strict_ns_set_initial_dollar=False, strict_ns_set_path=False,
          secure_protocols=('https', 'wss'))

     コンストラクタはキーワード引数しか取りません。 'blocked_domains' は
     ドメイン名からなるシーケンスで、ここからは決してクッキーを受けとら
     ないし、このドメインにクッキーを返すこともありません。
     'allowed_domains' が *note None: 641. でない場合、クッキーを受けと
     り、返すのはこのシーケンスのドメインに限定されます。
     'secure_protocols' は、安全なクッキーを追加できるプロトコルのシーケ
     ンスです。デフォルトでは、 'https' と 'wss' (secure websocket) が安
     全なプロトコルとみなされます。これ以外の引数については *note
     CookiePolicy: 3a3d. および *note DefaultCookiePolicy: 197c. オブジ
     ェクトの説明をごらんください。

     *note DefaultCookiePolicy: 197c. は Netscape および RFC 2965(4) ク
     ッキーの標準的な許可 / 拒絶のルールを実装しています。デフォルトでは
     、 RFC 2109(5) のクッキー (‘Set-Cookie’ の version クッキー属性が 1
     で受けとられるもの) は RFC 2965 のルールで扱われます。しかし、RFC
     2965 処理が無効に設定されているか *note rfc2109_as_netscape: 3a41.
     が ‘True’ の場合、RFC 2109 クッキーは *note CookieJar: 386e. インス
     タンスによって *note Cookie: 3a42. のインスタンスの ‘version’ 属性
     を 0 に設定する事で Netscapeクッキーに「ダウングレード」されます。
     また *note DefaultCookiePolicy: 197c. にはいくつかの細かいポリシー
     設定をおこなうパラメータが用意されています。

 -- クラス: http.cookiejar.Cookie

     このクラスは Netscape クッキー、 RFC 2109(6) のクッキー、および RFC
     2965(7) のクッキーを表現します。 *note http.cookiejar: 66. のユーザ
     が自分で *note Cookie: 3a42. インスタンスを作成することは想定されて
     いません。かわりに、必要に応じて *note CookieJar: 386e. インスタン
     スの ‘make_cookies()’ を呼ぶことになっています。

参考
....

*note urllib.request: f4. モジュール

     クッキーの自動処理をおこない URL を開くモジュールです。

*note http.cookies: 67. モジュール

     HTTP のクッキークラスで、基本的にはサーバサイドのコードで有用です。
     *note http.cookiejar: 66. および *note http.cookies: 67. モジュール
     は互いに依存してはいません。

‘https://curl.se/rfc/cookie_spec.html’

     元祖 Netscape のクッキープロトコルの仕様です。今でもこれが主流のプ
     ロトコルですが、現在のメジャーなブラウザ (と *note http.cookiejar:
     66.) が実装している「Netscape クッキープロトコル」は
     ‘cookie_spec.html’ で述べられているものとおおまかにしか似ていません
     。

RFC 2109(8) - HTTP State Management Mechanism

     RFC 2965(9) によって過去の遺物になりました。 ‘Set-Cookie’ の
     version=1 で使います。

RFC 2965(10) - HTTP State Management Mechanism

     Netscape プロトコルのバグを修正したものです。 ‘Set-Cookie’ のかわり
     に ‘Set-Cookie2’ を使いますが、普及してはいません。

‘https://kristol.org/cookie/errata.html’

     RFC 2965(11) に対する未完の正誤表です。

RFC 2964(12) - Use of HTTP State Management

* Menu:

* CookieJar および FileCookieJar オブジェクト::
* FileCookieJar のサブクラスと web ブラウザとの連携::
* CookiePolicy オブジェクト::
* DefaultCookiePolicy オブジェクト::
* Cookieオブジェクト: Cookieオブジェクト<2>.
* 使用例: 使用例<41>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/http/cookiejar.py

   (2) https://datatracker.ietf.org/doc/html/rfc2965.html

   (3) https://datatracker.ietf.org/doc/html/rfc2109.html

   (4) https://datatracker.ietf.org/doc/html/rfc2965.html

   (5) https://datatracker.ietf.org/doc/html/rfc2109.html

   (6) https://datatracker.ietf.org/doc/html/rfc2109.html

   (7) https://datatracker.ietf.org/doc/html/rfc2965.html

   (8) https://datatracker.ietf.org/doc/html/rfc2109.html

   (9) https://datatracker.ietf.org/doc/html/rfc2965.html

   (10) https://datatracker.ietf.org/doc/html/rfc2965.html

   (11) https://datatracker.ietf.org/doc/html/rfc2965.html

   (12) https://datatracker.ietf.org/doc/html/rfc2964.html


File: python.info,  Node: CookieJar および FileCookieJar オブジェクト,  Next: FileCookieJar のサブクラスと web ブラウザとの連携,  Up: http cookiejar --- HTTP クライアント用の Cookie 処理

5.21.19.1 CookieJar および FileCookieJar オブジェクト
.....................................................

*note CookieJar: 386e. オブジェクトは保管されている *note Cookie: 3a42.
オブジェクトをひとつずつ取り出すための、 *note イテレータ: 191. プロトコ
ルをサポートしています。

*note CookieJar: 386e. は以下のようなメソッドを持っています:

 -- メソッド: CookieJar.add_cookie_header (request)

     'request' に正しい ‘Cookie’ ヘッダを追加します。

     ポリシーが許すようであれば (*note CookieJar: 386e. の *note
     CookiePolicy: 3a3d. インスタンスにある属性のうち、 ‘rfc2965’ および
     ‘hide_cookie2’ がそれぞれ真と偽であるような場合)、必要に応じて
     ‘Cookie2’ ヘッダも追加されます。

     'request' オブジェクト (通常は *note urllib.request.Request: fa5. イ
     ンスタンス) は、 *note urllib.request: f4. のドキュメントに記されて
     いるように、メソッド ‘get_full_url()’, ‘has_header()’,
     ‘get_header()’, ‘header_items()’, ‘add_unredirected_header()’ およ
     び属性 ‘host’, ‘type’, ‘unverifiable’, ‘origin_req_host’ をサポート
     している必要があります。

     バージョン 3.3 で変更: 'request' オブジェクトには ‘origin_req_host’
     属性が必要です。非推奨のメソッド ‘get_origin_req_host()’ への依存は
     解消されました。

 -- メソッド: CookieJar.extract_cookies (response, request)

     HTTP 'response' からクッキーを取り出し、ポリシーによって許可されて
     いればこれを *note CookieJar: 386e. 内に保管します。

     *note CookieJar: 386e. は 'response' 引数の中から許可されている
     ‘Set-Cookie’ および ‘Set-Cookie2’ ヘッダを探しだし、適切に (*note
     CookiePolicy.set_ok(): 3a47. メソッドの承認におうじて) クッキーを保
     管します。

     'response' オブジェクト (通常は *note urllib.request.urlopen():
     273. あるいはそれに類似する呼び出しによって得られます) は ‘info()’
     メソッドをサポートしている必要があります。これは *note
     email.message.Message: 25d. メソッドのあるオブジェクトを返すもので
     す。

     'request' オブジェクト (通常は *note urllib.request.Request: fa5. イ
     ンスタンス) は *note urllib.request: f4. のドキュメントに記されてい
     るように、メソッド ‘get_full_url()’, および属性 ‘host’,
     ‘unverifiable’, ‘origin_req_host’ をサポートしている必要があります
     。この request はそのクッキーの保存が許可されているかを検査するとと
     もに、クッキー属性のデフォルト値を設定するのに使われます。

     バージョン 3.3 で変更: 'request' オブジェクトには ‘origin_req_host’
     属性が必要です。非推奨のメソッド ‘get_origin_req_host()’ への依存は
     解消されました。

 -- メソッド: CookieJar.set_policy (policy)

     使用する *note CookiePolicy: 3a3d. インスタンスを指定します。

 -- メソッド: CookieJar.make_cookies (response, request)

     'response' オブジェクトから得られた *note Cookie: 3a42. オブジェク
     トからなるシーケンスを返します。

     'response' および 'request' 引数で要求されるインスタンスについては
     、 *note extract_cookies(): 3a46. の説明を参照してください。

 -- メソッド: CookieJar.set_cookie_if_ok (cookie, request)

     ポリシーが許すのであれば、与えられた *note Cookie: 3a42. を設定しま
     す。

 -- メソッド: CookieJar.set_cookie (cookie)

     与えられた *note Cookie: 3a42. を、それが設定されるべきかどうかのポ
     リシーのチェックを行わずに設定します。

 -- メソッド: CookieJar.clear ([domain[, path[, name]]])

     いくつかのクッキーを消去します。

     引数なしで呼ばれた場合は、すべてのクッキーを消去します。引数がひと
     つ与えられた場合、その 'domain' に属するクッキーのみを消去します。
     ふたつの引数が与えられた場合、指定された 'domain' と URL 'path' に
     属するクッキーのみを消去します。引数が 3つ与えられた場合、'domain',
     'path' および 'name' で指定されるクッキーが消去されます。

     与えられた条件に一致するクッキーがない場合は *note KeyError: 31d. を
     発生させます。

 -- メソッド: CookieJar.clear_session_cookies ()

     すべてのセッションクッキーを消去します。

     保存されているクッキーのうち、 ‘discard’ 属性が真になっているものす
     べてを消去します (通常これは ‘max-age’ または ‘expires’ のどちらの
     クッキー属性もないか、あるいは明示的に ‘discard’ クッキー属性が指定
     されているものです)。対話的なブラウザの場合、セッションの終了はふつ
     うブラウザのウィンドウを閉じることに相当します。

     注意: 'ignore_discard' 引数に真を指定しないかぎり、 ‘save()’ メソッ
     ドはセッションクッキーは保存しません。

さらに *note FileCookieJar: 3a3c. は以下のようなメソッドを実装しています
:

 -- メソッド: FileCookieJar.save (filename=None, ignore_discard=False,
          ignore_expires=False)

     クッキーをファイルに保存します。

     この基底クラスは *note NotImplementedError: 209. を発生させます。サ
     ブクラスはこのメソッドを実装しないままにしておいてもかまいません。

     'filename' はクッキーを保存するファイルの名前です。 'filename' が指
     定されない場合、 ‘self.filename’ が使用されます (このデフォルト値は
     、それが存在する場合は、コンストラクタに渡されています)。
     ‘self.filename’ も *note None: 641. の場合は *note ValueError: 1e3.
     が発生します。

     'ignore_discard' : 破棄されるよう指示されていたクッキーでも保存しま
     す。'ignore_expires' : 期限の切れたクッキーでも保存します。

     ここで指定されたファイルがもしすでに存在する場合は上書きされるため
     、以前にあったクッキーはすべて消去されます。保存したクッキーはあと
     で *note load(): 3a3e. または *note revert(): 3a3f. メソッドを使っ
     て復元することができます。

 -- メソッド: FileCookieJar.load (filename=None, ignore_discard=False,
          ignore_expires=False)

     ファイルからクッキーを読み込みます。

     それまでのクッキーは新しいものに上書きされない限り残ります。

     ここでの引数の値は *note save(): 3a4e. と同じです。

     名前のついたファイルはこのクラスがわかるやり方で指定する必要があり
     ます。さもないと *note LoadError: 3a3b. が発生します。さらに、例え
     ばファイルが存在しないような時に *note OSError: 3f0. が発生する場合
     があります。

     バージョン 3.3 で変更: 以前は *note IOError: 1026. が送出されました
     ; それは現在 *note OSError: 3f0. のエイリアスです。

 -- メソッド: FileCookieJar.revert (filename=None, ignore_discard=False,
          ignore_expires=False)

     すべてのクッキーを破棄し、保存されているファイルから読み込み直しま
     す。

     *note revert(): 3a3f. は *note load(): 3a3e. と同じ例外を発生させる
     事ができます。失敗した場合、オブジェクトの状態は変更されません。

*note FileCookieJar: 3a3c. インスタンスは以下のような公開の属性をもって
います:

 -- の属性: FileCookieJar.filename

     クッキーを保存するデフォルトのファイル名を指定します。この属性には
     代入することができます。

 -- の属性: FileCookieJar.delayload

     真であれば、クッキーを読み込むさいにディスクから遅延読み込みします
     。この属性には代入することができません。この情報は単なるヒントであ
     り、 (ディスク上のクッキーが変わらない限りは) インスタンスのふるま
     いには影響を与えず、パフォーマンスのみに影響します。 *note
     CookieJar: 386e. オブジェクトはこの値を無視することもあります。標準
     ライブラリに含まれている *note FileCookieJar: 3a3c. クラスで遅延読
     み込みをおこなうものはありません。


File: python.info,  Node: FileCookieJar のサブクラスと web ブラウザとの連携,  Next: CookiePolicy オブジェクト,  Prev: CookieJar および FileCookieJar オブジェクト,  Up: http cookiejar --- HTTP クライアント用の Cookie 処理

5.21.19.2 FileCookieJar のサブクラスと web ブラウザとの連携
...........................................................

クッキーの読み書きのために、以下の *note CookieJar: 386e. サブクラスが提
供されています。

 -- クラス: http.cookiejar.MozillaCookieJar (filename=None,
          delayload=None, policy=None)

     Mozilla の ‘cookies.txt’ ファイル形式 (この形式はまた curl や Lynx
     と Netscape ブラウザによっても使われています) でディスクにクッキー
     を読み書きするための *note FileCookieJar: 3a3c. です。

          注釈: このクラスは RFC 2965(1) クッキーに関する情報を失います
          。また、より新しいか、標準でない ‘port’ などのクッキー属性につ
          いての情報も失います。

          警告: もしクッキーの損失や欠損が望ましくない場合は、クッキーを
          保存する前にバックアップを取っておくようにしてください (ファイ
          ルへの読み込み / 保存をくり返すと微妙な変化が生じる場合があり
          ます)。

     また、Mozilla の起動中にクッキーを保存すると、Mozilla によって内容
     が破壊されてしまうことにも注意してください。

 -- クラス: http.cookiejar.LWPCookieJar (filename=None, delayload=None,
          policy=None)

     libwww-perl のライブラリである ‘Set-Cookie3’ ファイル形式でディスク
     にクッキーを読み書きするための *note FileCookieJar: 3a3c. です。こ
     れはクッキーを人間に可読な形式で保存するのに向いています。

     バージョン 3.8 で変更: 'filename' 引数が *note path-like object:
     280. を受け付けるようになりました。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2965.html


File: python.info,  Node: CookiePolicy オブジェクト,  Next: DefaultCookiePolicy オブジェクト,  Prev: FileCookieJar のサブクラスと web ブラウザとの連携,  Up: http cookiejar --- HTTP クライアント用の Cookie 処理

5.21.19.3 CookiePolicy オブジェクト
...................................

*note CookiePolicy: 3a3d. インターフェイスを実装するオブジェクトは以下の
ようなメソッドを持っています:

 -- メソッド: CookiePolicy.set_ok (cookie, request)

     クッキーがサーバから受け入れられるべきかどうかを表わす boolean 値を
     返します。

     'cookie' は *note Cookie: 3a42. インスタンスです。 'request' は
     *note CookieJar.extract_cookies(): 3a46. の説明で定義されているイン
     ターフェイスを実装するオブジェクトです。

 -- メソッド: CookiePolicy.return_ok (cookie, request)

     クッキーがサーバに返されるべきかどうかを表わす boolean 値を返します
     。

     'cookie' は *note Cookie: 3a42. インスタンスです。 'request' は
     *note CookieJar.add_cookie_header(): 3a45. の説明で定義されているイ
     ンターフェイスを実装するオブジェクトです。

 -- メソッド: CookiePolicy.domain_return_ok (domain, request)

     与えられたクッキーのドメインに対して、そこにクッキーを返すべきでな
     い場合には ‘False’ を返します。

     このメソッドは高速化のためのものです。これにより、すべてのクッキー
     をある特定のドメインに対してチェックする (これには多数のファイル読
     みこみを伴なう場合があります) 必要がなくなります。 *note
     domain_return_ok(): 3a57. および *note path_return_ok(): 3a58. の両
     方から true が返された場合、すべての決定は *note return_ok(): 3a56.
     に委ねられます。

     もし、このクッキードメインに対して *note domain_return_ok(): 3a57.
     が true を返すと、つぎにそのクッキーのパス名に対して *note
     path_return_ok(): 3a58. が呼ばれます。そうでない場合、そのクッキー
     ドメインに対する *note path_return_ok(): 3a58. および *note
     return_ok(): 3a56. は決して呼ばれることはありません。 *note
     path_return_ok(): 3a58. が true を返すと、 *note return_ok(): 3a56.
     がその *note Cookie: 3a42. オブジェクト自身の全チェックのために呼ば
     れます。そうでない場合、そのクッキーパス名に対する *note
     return_ok(): 3a56. は決して呼ばれることはありません。

     注意: *note domain_return_ok(): 3a57. は 'request' ドメインだけでは
     なく、すべての 'cookie' ドメインに対して呼ばれます。たとえば
     request ドメインが ‘"www.example.com"’ だった場合、この関数は
     ‘".example.com"’ および ‘"www.example.com"’ の両方に対して呼ばれる
     ことがあります。同じことは *note path_return_ok(): 3a58. にもいえま
     す。

     'request' 引数は *note return_ok(): 3a56. で説明されているとおりで
     す。

 -- メソッド: CookiePolicy.path_return_ok (path, request)

     与えられたクッキーのパス名に対して、そこにクッキーを返すべきでない
     場合には ‘False’ を返します。

     *note domain_return_ok(): 3a57. の説明を参照してください。

上のメソッドの実装にくわえて、 *note CookiePolicy: 3a3d. インターフェイ
スの実装では以下の属性を設定する必要があります。これはどのプロトコルがど
のように使われるべきかを示すもので、これらの属性にはすべて代入することが
許されています。

 -- の属性: CookiePolicy.netscape

     Netscape プロトコルを実装していることを示します。

 -- の属性: CookiePolicy.rfc2965

     RFC 2965(1) プロトコルを実装していることを示します。

 -- の属性: CookiePolicy.hide_cookie2

     ‘Cookie2’ ヘッダをリクエストに含めないようにします (このヘッダが存
     在する場合、私たちは RFC 2965(2) クッキーを理解するということをサー
     バに示すことになります)。

もっとも有用な方法は、 *note DefaultCookiePolicy: 197c. をサブクラス化し
た *note CookiePolicy: 3a3d. クラスを定義して、いくつか (あるいはすべて)
のメソッドをオーバーライドすることでしょう。 *note CookiePolicy: 3a3d. 自
体はどのようなクッキーも受け入れて設定を許可する「ポリシー無し」ポリシー
として使うこともできます (これが役に立つことはあまりありませんが)。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2965.html

   (2) https://datatracker.ietf.org/doc/html/rfc2965.html


File: python.info,  Node: DefaultCookiePolicy オブジェクト,  Next: Cookieオブジェクト<2>,  Prev: CookiePolicy オブジェクト,  Up: http cookiejar --- HTTP クライアント用の Cookie 処理

5.21.19.4 DefaultCookiePolicy オブジェクト
..........................................

クッキーを受けつけ、またそれを返す際の標準的なルールを実装します。

RFC 2965(1) クッキーと Netscape クッキーの両方に対応しています。デフォル
トでは、RFC 2965 の処理はオフになっています。

自分のポリシーを提供するいちばん簡単な方法は、このクラスを継承して、自分
用の追加チェックの前にオーバーライドした元のメソッドを呼び出すことです:

     import http.cookiejar
     class MyCookiePolicy(http.cookiejar.DefaultCookiePolicy):
         def set_ok(self, cookie, request):
             if not http.cookiejar.DefaultCookiePolicy.set_ok(self, cookie, request):
                 return False
             if i_dont_want_to_store_this_cookie(cookie):
                 return False
             return True

*note CookiePolicy: 3a3d. インターフェイスを実装するのに必要な機能に加え
て、このクラスではクッキーを受けとったり設定したりするドメインを許可した
り拒絶したりできるようになっています。ほかにも、 Netscape プロトコルのか
なり緩い規則をややきつくするために、いくつかの厳密性のスイッチがついてい
ます (いくつかの良性クッキーをブロックする危険性もありますが)。

ドメインの拒否リストや許可リストも提供されています (デフォルトではどちら
もオフです)。拒否リストになく、(許可リストがアクティブなら) 許可リストに
あるドメインのみがクッキーを設定したり返したりできます。コンストラクタの
引数 'blocked_domains' 、および ‘blocked_domains()’ と
‘set_blocked_domains()’ メソッド ( そして 'allowed_domains' に対応する引
数とメソッド) を使ってください。許可リストを設定した場合は、それを *note
None: 641. にすることでオフに戻せます。

拒否あるいは許可リスト中にあるドメインのうち、ドット (.)  で始まっていな
いものは、正確にそれと一致するドメインのクッキーにしか適用されません。た
とえば拒否リスト中のエントリ ‘"example.com"’ は、‘"example.com"’ にはマ
ッチしますが、‘"www.example.com"’ にはマッチしません。一方ドット (.)  で
始まっているドメインは、より特化されたドメインともマッチします。たとえば
、‘".example.com"’ は、‘"www.example.com"’ と ‘"www.coyote.example.com"’
の両方にマッチします (が、‘"example.com"’ 自身にはマッチしません)。IP ア
ドレスは例外で、つねに正確に一致する必要があります。たとえば、
'blocked_domains' が ‘"192.168.1.2"’ と ‘".168.1.2"’ を含んでいるとする
と、192.168.1.2 はブロックされますが、193.168.1.2 はブロックされません。

*note DefaultCookiePolicy: 197c. は以下のような追加メソッドを実装してい
ます:

 -- メソッド: DefaultCookiePolicy.blocked_domains ()

     ブロックしているドメインのシーケンスを (タプルとして) 返します。

 -- メソッド: DefaultCookiePolicy.set_blocked_domains (blocked_domains)

     ブロックするドメインを設定します。

 -- メソッド: DefaultCookiePolicy.is_blocked (domain)

     'domain' がクッキーを授受しない拒否リストに載っていれば ‘True’ を返
     します。

 -- メソッド: DefaultCookiePolicy.allowed_domains ()

     *note None: 641. あるいは明示的に許可されているドメインを (タプルと
     して) 返します。

 -- メソッド: DefaultCookiePolicy.set_allowed_domains (allowed_domains)

     許可するドメイン、あるいは *note None: 641. を設定します。

 -- メソッド: DefaultCookiePolicy.is_not_allowed (domain)

     'domain' がクッキーを授受する許可リストに載っていれば ‘True’ を返し
     ます。

*note DefaultCookiePolicy: 197c. インスタンスは以下の属性をもっています
。これらはすべてコンストラクタから同じ名前の引数をつかって初期化すること
ができ、代入してもかまいません。

 -- の属性: DefaultCookiePolicy.rfc2109_as_netscape

     真の場合、 *note CookieJar: 386e. のインスタンスに RFC 2109(2) クッ
     キー (即ち ‘Set-Cookie’ ヘッダのクッキー属性 Version の値が 1 のク
     ッキー) を Netscapeクッキーへ、 *note Cookie: 3a42. インスタンスの
     version 属性を 0 に設定する事でダウングレードするように要求します。
     デフォルトの値は *note None: 641. であり、この場合 RFC 2109 クッキ
     ーは RFC 2965(3) 処理が無効に設定されている場合に限りダウングレード
     されます。それ故に RFC 2109 クッキーはデフォルトではダウングレード
     されます。

一般的な厳密性のスイッチ:

 -- の属性: DefaultCookiePolicy.strict_domain

     サイトに、国別コードとトップレベルドメインだけからなるドメイン名
     (‘.co.uk’, ‘.gov.uk’, ‘.co.nz’ など) を設定させないようにします。こ
     れは完璧からはほど遠い実装であり、いつもうまくいくとは限りません!

RFC 2965(4) プロトコルの厳密性に関するスイッチ:

 -- の属性: DefaultCookiePolicy.strict_rfc2965_unverifiable

     検証不可能なトランザクション (通常これはリダイレクトか、別のサイト
     がホスティングしているイメージの読み込み要求です) に関する RFC
     2965(5) の規則に従います。この値が偽の場合、検証可能性を基準にして
     クッキーがブロックされることは '決して' ありません

Netscape プロトコルの厳密性に関するスイッチ:

 -- の属性: DefaultCookiePolicy.strict_ns_unverifiable

     検証不可能なトランザクションに関する RFC 2965(6) の規則を Netscape
     クッキーに対しても適用します。

 -- の属性: DefaultCookiePolicy.strict_ns_domain

     Netscape クッキーに対するドメインマッチングの規則をどの程度厳しくす
     るかを指示するフラグです。とりうる値については下の説明を見てくださ
     い。

 -- の属性: DefaultCookiePolicy.strict_ns_set_initial_dollar

     Set-Cookie: ヘッダで、‘'$'’ で始まる名前のクッキーを無視します。

 -- の属性: DefaultCookiePolicy.strict_ns_set_path

     要求した URI にパスがマッチしないクッキーの設定を禁止します。

‘strict_ns_domain’ はいくつかのフラグの集合です。これはいくつかの値を or
することで構成します (たとえば
‘DomainStrictNoDots|DomainStrictNonDomain’ は両方のフラグが設定されてい
ることになります)。

 -- の属性: DefaultCookiePolicy.DomainStrictNoDots

     クッキーを設定するさい、ホスト名のプレフィクスにドットが含まれるの
     を禁止します (例: ‘www.foo.bar.com’ は ‘.bar.com’ のクッキーを設定
     することはできません、なぜなら ‘www.foo’ はドットを含んでいるからで
     す)。

 -- の属性: DefaultCookiePolicy.DomainStrictNonDomain

     ‘domain’ クッキー属性を明示的に指定していないクッキーは、そのクッキ
     ーを設定したドメインと同一のドメインだけに返されます (例:
     ‘example.com’ からのクッキーに ‘domain’ クッキー属性がない場合、そ
     のクッキーが ‘spam.example.com’ に返されることはありません)。

 -- の属性: DefaultCookiePolicy.DomainRFC2965Match

     クッキーを設定するさい、 RFC 2965(7) の完全ドメインマッチングを要求
     します。

以下の属性は上記のフラグのうちもっともよく使われる組み合わせで、便宜をは
かるために提供されています:

 -- の属性: DefaultCookiePolicy.DomainLiberal

     0 と同じです (つまり、上述の Netscape のドメイン厳密性フラグがすべ
     てオフにされます)。

 -- の属性: DefaultCookiePolicy.DomainStrict

     ‘DomainStrictNoDots|DomainStrictNonDomain’ と同じです。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2965.html

   (2) https://datatracker.ietf.org/doc/html/rfc2109.html

   (3) https://datatracker.ietf.org/doc/html/rfc2965.html

   (4) https://datatracker.ietf.org/doc/html/rfc2965.html

   (5) https://datatracker.ietf.org/doc/html/rfc2965.html

   (6) https://datatracker.ietf.org/doc/html/rfc2965.html

   (7) https://datatracker.ietf.org/doc/html/rfc2965.html


File: python.info,  Node: Cookieオブジェクト<2>,  Next: 使用例<41>,  Prev: DefaultCookiePolicy オブジェクト,  Up: http cookiejar --- HTTP クライアント用の Cookie 処理

5.21.19.5 Cookieオブジェクト
............................

*note Cookie: 3a42. インスタンスは、さまざまなクッキーの標準で規定されて
いる標準的なクッキー属性とおおまかに対応する Python 属性をもっています。
しかしデフォルト値を決める複雑なやり方が存在しており、また ‘max-age’ お
よび ‘expires’ クッキー属性は同じ値をもつことになっているので、また RFC
2109(1) クッキーは *note http.cookiejar: 66. によって version 1 から
version 0 (Netscape) クッキーへ 'ダウングレード' される場合があるため、
この対応は 1 対 1 ではありません。

*note CookiePolicy: 3a3d. メソッド内でのごくわずかな例外を除けば、これら
の属性に代入する必要はないはずです。このクラスは内部の一貫性を保つように
はしていないため、代入するのは自分のやっていることを理解している場合のみ
にしてください。

 -- の属性: Cookie.version

     整数または *note None: 641. 。 Netscape クッキーはバージョン 0 であ
     り、 RFC 2965(2) および RFC 2109(3) クッキーはバージョン 1 です。し
     かし、 *note http.cookiejar: 66. は RFC 2109 クッキーを Netscape ク
     ッキー (*note version: 3a70. が 0) に 'ダウングレード' する場合があ
     る事に注意して下さい。

 -- の属性: Cookie.name

     クッキーの名前 (文字列)。

 -- の属性: Cookie.value

     クッキーの値 (文字列)、あるいは *note None: 641. 。

 -- の属性: Cookie.port

     ポートあるいはポートの集合をあらわす文字列 (例: '80' または
     '80,8080')、あるいは *note None: 641. 。

 -- の属性: Cookie.domain

     クッキーのドメイン (文字列) 。

 -- の属性: Cookie.path

     クッキーのパス名 (文字列、例: ‘'/acme/rocket_launchers'’)。

 -- の属性: Cookie.secure

     そのクッキーを返せるのがセキュアな接続のみならば ‘True’ を返します
     。

 -- の属性: Cookie.expires

     クッキーの期限が切れる日時をあわらす整数 (エポックから経過した秒数
     )、あるいは *note None: 641. 。 *note is_expired(): 3a78. も参照し
     てください。

 -- の属性: Cookie.discard

     これがセッションクッキーであれば ‘True’ を返します。

 -- の属性: Cookie.comment

     このクッキーの働きを説明する、サーバからのコメント文字列、あるいは
     *note None: 641. 。

 -- の属性: Cookie.comment_url

     このクッキーの働きを説明する、サーバからのコメントのリンク URL、あ
     るいは *note None: 641. 。

 -- の属性: Cookie.rfc2109

     RFC 2109(4) クッキー (即ち ‘Set-Cookie’ ヘッダにあり、かつクッキー
     属性 Version の値が 1 のクッキー) の場合、 ‘True’ を返します。
     *note http.cookiejar: 66. が RFC 2109クッキーを Netscape クッキー
     (*note version: 3a70. が 0) に 'ダウングレード' する場合があるので
     、この属性が提供されています。

 -- の属性: Cookie.port_specified

     サーバがポート、あるいはポートの集合を (‘Set-Cookie’ /
     ‘Set-Cookie2’ ヘッダ内で) 明示的に指定していれば ‘True’ を返します
     。

 -- の属性: Cookie.domain_specified

     サーバにより明示的にドメインが指定されていれば ‘True’ を返します。

 -- の属性: Cookie.domain_initial_dot

     サーバが明示的に指定したドメインがドット (‘'.'’) で始まっていれば
     ‘True’ を返します。

クッキーは、オプションとして標準的でないクッキー属性を持つこともできます
。これらは以下のメソッドでアクセスできます:

 -- メソッド: Cookie.has_nonstandard_attr (name)

     そのクッキーが指定された名前のクッキー属性をもっている場合には
     ‘True’ を返します。

 -- メソッド: Cookie.get_nonstandard_attr (name, default=None)

     クッキーが指定された名前のクッキー属性をもっていれば、その値を返し
     ます。そうでない場合は 'default' を返します。

 -- メソッド: Cookie.set_nonstandard_attr (name, value)

     指定された名前のクッキー属性を設定します。

*note Cookie: 3a42. クラスは以下のメソッドも定義しています:

 -- メソッド: Cookie.is_expired (now=None)

     サーバが要求するクッキーの有効期限を過ぎていれば ‘True’ を返します
     。 'now' が (エポックからの経過秒で) 指定されているときは、特定の時
     刻で期限切れかどうかを判定します。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2109.html

   (2) https://datatracker.ietf.org/doc/html/rfc2965.html

   (3) https://datatracker.ietf.org/doc/html/rfc2109.html

   (4) https://datatracker.ietf.org/doc/html/rfc2109.html


File: python.info,  Node: 使用例<41>,  Prev: Cookieオブジェクト<2>,  Up: http cookiejar --- HTTP クライアント用の Cookie 処理

5.21.19.6 使用例
................

はじめに、もっとも一般的な *note http.cookiejar: 66. の使用例をあげます:

     import http.cookiejar, urllib.request
     cj = http.cookiejar.CookieJar()
     opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
     r = opener.open("http://example.com/")

以下の例では、URL を開く際に Netscape や Mozilla または Lynx のクッキー
を使う方法を示しています (クッキーファイルの位置は Unix/Netscape の慣例
にしたがうものと仮定しています):

     import os, http.cookiejar, urllib.request
     cj = http.cookiejar.MozillaCookieJar()
     cj.load(os.path.join(os.path.expanduser("~"), ".netscape", "cookies.txt"))
     opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
     r = opener.open("http://example.com/")

つぎの例は *note DefaultCookiePolicy: 197c. の使用例です。 RFC 2965(1) ク
ッキーをオンにし、Netscape クッキーを設定したり返したりするドメインに対
してより厳密な規則を適用します。そしていくつかのドメインからクッキーを設
定あるいは返還するのをブロックしています:

     import urllib.request
     from http.cookiejar import CookieJar, DefaultCookiePolicy
     policy = DefaultCookiePolicy(
         rfc2965=True, strict_ns_domain=Policy.DomainStrict,
         blocked_domains=["ads.net", ".ads.net"])
     cj = CookieJar(policy)
     opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
     r = opener.open("http://example.com/")

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2965.html


File: python.info,  Node: xmlrpc --- XMLRPC サーバーとクライアントモジュール群,  Next: xmlrpc client --- XML-RPC クライアントアクセス,  Prev: http cookiejar --- HTTP クライアント用の Cookie 処理,  Up: インターネットプロトコルとサポート

5.21.20 ‘xmlrpc’ -- XMLRPC サーバーとクライアントモジュール群
-------------------------------------------------------------

XML-RPC は HTTP 経由の XML を使って遠隔手続き呼び出し (Remote Procedure
Call) を実現する方法です。XML-RPC を使うと、クライアントはリモートサーバ
ー (サーバーは URI で名前付けられます) 上のメソッドを引数付きで呼び出し
て、構造化されたデータを受け取る事ができます。

‘xmlrpc’ パッケージは XML-RPC のサーバーとクライアントを実装したモジュー
ルを持っています。モジュール一覧:

   * *note xmlrpc.client: 114.

   * *note xmlrpc.server: 115.


File: python.info,  Node: xmlrpc client --- XML-RPC クライアントアクセス,  Next: xmlrpc server --- 基本的な XML-RPC サーバー,  Prev: xmlrpc --- XMLRPC サーバーとクライアントモジュール群,  Up: インターネットプロトコルとサポート

5.21.21 ‘xmlrpc.client’ -- XML-RPC クライアントアクセス
-------------------------------------------------------

'ソースコード:' Lib/xmlrpc/client.py(1)

__________________________________________________________________

XML-RPCはXMLを利用した遠隔手続き呼び出し(Remote Procedure Call)の一種で
、HTTP(S)をトランスポートとして使用します。XML- RPCでは、クライアントは
リモートサーバ(URIで指定されたサーバ)上のメソッドをパラメータを指定して
呼び出し、構造化されたデータを取得します。このモジュールは、XML-RPCクラ
イアントの開発をサポートしており、Pythonオブジェクトに適合する転送用
XMLの変換の全てを行います。

     警告: *note xmlrpc.client: 114. モジュールは悪意を持って構築された
     データに対して安全ではありません。信頼できないデータや認証されてい
     ないデータを解析する必要がある場合は、*note XML の脆弱性: 3607. を
     参照してください。

バージョン 3.5 で変更: HTTPS URI の場合、 *note xmlrpc.client: 114. は必
要な証明書検証とホスト名チェックを全てデフォルトで行います。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

 -- クラス: xmlrpc.client.ServerProxy (uri, transport=None,
          encoding=None, verbose=False, allow_none=False,
          use_datetime=False, use_builtin_types=False, *, headers=(),
          context=None)

     *note ServerProxy: a25. は、リモートのXML-RPCサーバとの通信を管理す
     るオブジェクトです。最初のパラメータはURI(Uniform Resource
     Indicator)で、通常はサーバのURLを指定します。2番目のパラメータには
     トランスポート・ファクトリを指定する事ができます。トランスポート・
     ファクトリを省略した場合、URLが https: ならモジュール内部の
     ‘SafeTransport’ インスタンスを使用し、それ以外の場合にはモジュール
     内部の ‘Transport’ インスタンスを使用します。オプションの 3 番目の
     引数はエンコード方法で、デフォルトでは UTF-8 です。オプションの 4 番
     目の引数はデバッグフラグです。

     The following parameters govern the use of the returned proxy
     instance.  If 'allow_none' is true, the Python constant ‘None’ will
     be translated into XML; the default behaviour is for ‘None’ to
     raise a *note TypeError: 502.  This is a commonly used extension to
     the XML-RPC specification, but isn't supported by all clients and
     servers; see http://ontosys.com/xml-rpc/extensions.php(2) for a
     description.  The 'use_builtin_types' flag can be used to cause
     date/time values to be presented as *note datetime.datetime: 1ae.
     objects and binary data to be presented as *note bytes: 1a4.
     objects; this flag is false by default.  *note datetime.datetime:
     1ae, *note bytes: 1a4. and *note bytearray: 508. objects may be
     passed to calls.  The 'headers' parameter is an optional sequence
     of HTTP headers to send with each request, expressed as a sequence
     of 2-tuples representing the header name and value.  (e.g.
     ‘[('Header-Name', 'value')]’).  The obsolete 'use_datetime' flag is
     similar to 'use_builtin_types' but it applies only to date/time
     values.

バージョン 3.3 で変更: 'use_builtin_types' フラグが追加されました。

バージョン 3.8 で変更: 'headers' 引数が追加されました。

HTTP及びHTTPS通信の両方で、 ‘http://user:pass@host:port/path’ のような
HTTP基本認証のための拡張URL構文をサポートしています。 ‘user:pass’ は
base64でエンコードしてHTTPの'Authorization 'ヘッダとなり、XML-RPCメソッ
ド呼び出し時に接続処理の一部としてリモートサーバに送信されます。リモート
サーバが基本認証を要求する場合のみ、この機能を利用する必要があります。
HTTPS URL が与えられたなら、 'context' は *note ssl.SSLContext: 274. に
でき、基底のHTTP接続のSSL設定を設定します。

生成されるインスタンスはリモートサーバへのプロクシオブジェクトで、RPC呼
び出しを行う為のメソッドを持ちます。リモートサーバがイントロスペクション
APIをサポートしている場合は、リモートサーバのサポートするメソッドを検索
(サービス検索)やサーバのメタデータの取得なども行えます。

以下の型をXMLに変換(XMLを通じてマーシャルする)する事ができます (特別な指
定がない限り、逆変換でも同じ型として変換されます):

XML-RPC の型               Python の型
                           
---------------------------------------------------------------------------------------
                           
‘boolean’                  *note bool: 434.
                           
                           
‘int’, ‘i1’, ‘i2’, ‘i4’,   *note int: 238. in range from -2147483648 to 2147483647.
‘i8’ または ‘biginteger’   Values get the ‘<int>’ tag.
                           
                           
‘double’ または ‘float’    *note float: 2ce.  Values get the ‘<double>’ tag.
                           
                           
‘string’                   *note str: 418.
                           
                           
‘array’                    適合する要素を持つ *note list: 5dc. または
                           *note tuple: 349.。array は *note list: 5dc. として返しま
                           す。
                           
                           
‘struct’                   *note dict: 237. 。キーは文字列のみ。全ての値は変換可能で
                           なくてはならない。ユーザー定義型を渡すこともできます。
                           *note __dict__: 526. の属性のみ転送されます。
                           
                           
‘dateTime.iso8601’         *note DateTime: 138b. または
                           *note datetime.datetime: 1ae.。返される型は
                           'use_builtin_types' および 'use_datetime' の値に依ります
                           。
                           
                           
‘base64’                   *note Binary: 3a88.、 *note bytes: 1a4. または
                           *note bytearray: 508.。返される型は 'use_builtin_types' フ
                           ラグの値に依ります。
                           
                           
‘nil’                      ‘None’ 定数。 'allow_none' が真の場合にのみ渡すことが出来
                           ます。
                           
                           
‘bigdecimal’               *note decimal.Decimal: 27d.  Returned type only.
                           

上記のXML-RPCでサポートする全データ型を使用することができます。メソッド
呼び出し時、XML- RPCサーバエラーが発生すると *note Fault: 3a89. インスタ
ンスを送出し、HTTP/HTTPSトランスポート層でエラーが発生した場合には *note
ProtocolError: 3a8a. を送出します。 ‘Error’ をベースとする *note Fault:
3a89. と *note ProtocolError: 3a8a. の両方が発生します。現在のところ
xmlrpclibでは組み込み型のサブクラスのインスタンスをマーシャルすることは
できません。

文字列を渡す場合、 ‘<’, ‘>’, ‘&’ などのXMLで特殊な意味を持つ文字は自動的
にエスケープされます。しかし、ASCII値0〜31の制御文字(もちろん、タブ
'TAB',改行'LF',リターン'CR'は除く)などのXMLで使用することのできない文字
を使用することはできず、使用するとそのXML-RPCリクエストはwell-formedな
XMLとはなりません。そのようなバイト列を渡す必要がある場合は、 *note
bytes: 1a4, *note bytearray: 508. クラスまたは後述の *note Binary: 3a88.
ラッパークラスを使用してください。

‘Server’ は、後方互換性の為に *note ServerProxy: a25. の別名として残され
ています。新しいコードでは *note ServerProxy: a25. を使用してください。

バージョン 3.5 で変更: 'context' 引数が追加されました。

バージョン 3.6 で変更: Added support of type tags with prefixes (e.g.
‘ex:nil’).  Added support of unmarshalling additional types used by
Apache XML-RPC implementation for numerics: ‘i1’, ‘i2’, ‘i8’,
‘biginteger’, ‘float’ and ‘bigdecimal’.  See
‘https://ws.apache.org/xmlrpc/types.html’ for a description.

参考
....

XML-RPC HOWTO(3)

     数種類のプログラミング言語で記述された XML-RPCの操作とクライアント
     ソフトウェアの素晴らしい説明が掲載されています。 XML- RPCクライアン
     トの開発者が知っておくべきことがほとんど全て記載されています。

XML-RPC Introspection(4)

     インストロペクションをサポートする、 XML-RPC プロトコルの拡張を解説
     しています。

XML-RPC Specification(5)

     公式の仕様

* Menu:

* ServerProxy オブジェクト::
* DateTime オブジェクト::
* Binary オブジェクト::
* Fault オブジェクト::
* ProtocolError オブジェクト::
* MultiCall オブジェクト::
* 補助関数::
* クライアントのサンプル::
* クライアントとサーバーの利用例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/xmlrpc/client.py

   (2) 
https://web.archive.org/web/20130120074804/http://ontosys.com/xml-rpc/extensions.php

   (3) https://tldp.org/HOWTO/XML-RPC-HOWTO/index.html

   (4) https://xmlrpc-c.sourceforge.io/introspection.html

   (5) http://xmlrpc.scripting.com/spec.html


File: python.info,  Node: ServerProxy オブジェクト,  Next: DateTime オブジェクト,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.1 ServerProxy オブジェクト
..................................

*note ServerProxy: a25. インスタンスの各メソッドはそれぞれXML-RPCサーバ
の遠隔手続き呼び出しに対応しており、メソッドが呼び出されると名前と引数を
シグネチャとしてRPCを実行します(同じ名前のメソッドでも、異なる引数シグネ
チャによってオーバロードされます)。RPC実行後、変換された値を返すか、また
は *note Fault: 3a89. オブジェクトもしくは *note ProtocolError: 3a8a. オ
ブジェクトでエラーを通知します。

予約属性 ‘system’ から、XMLイントロスペクションAPIの一般的なメソッドを利
用する事ができます:

 -- メソッド: ServerProxy.system.listMethods ()

     XML-RPCサーバがサポートするメソッド名(system以外)を格納する文字列の
     リストを返します。

 -- メソッド: ServerProxy.system.methodSignature (name)

     XML-RPCサーバで実装されているメソッドの名前を指定し、利用可能なシグ
     ネチャの配列を取得します。シグネチャは型のリストで、先頭の型は戻り
     値の型を示し、以降はパラメータの型を示します。

     XML-RPCでは複数のシグネチャ(オーバロード)を使用することができるので
     、単独のシグネチャではなく、シグネチャのリストを返します。

     シグネチャは、メソッドが使用する最上位のパラメータにのみ適用されま
     す。例えばあるメソッドのパラメータが構造体の配列で戻り値が文字列の
     場合、シグネチャは単に"string, array" となります。パラメータが三つ
     の整数で戻り値が文字列の場合は"string, int, int, int"となります。

     メソッドにシグネチャが定義されていない場合、配列以外の値が返ります
     。 Pythonでは、この値はlist以外の値となります。

 -- メソッド: ServerProxy.system.methodHelp (name)

     XML-RPCサーバで実装されているメソッドの名前を指定し、そのメソッドを
     解説する文書文字列を取得します。文書文字列を取得できない場合は空文
     字列を返します。文書文字列にはHTMLマークアップが含まれます。

バージョン 3.5 で変更: Instances of *note ServerProxy: a25. support the
*note context manager: 59e. protocol for closing the underlying
transport.

以下は、動作する例です。サーバ側のコード:

     from xmlrpc.server import SimpleXMLRPCServer

     def is_even(n):
         return n % 2 == 0

     server = SimpleXMLRPCServer(("localhost", 8000))
     print("Listening on port 8000...")
     server.register_function(is_even, "is_even")
     server.serve_forever()

上記のサーバーに対するクライアントコード:

     import xmlrpc.client

     with xmlrpc.client.ServerProxy("http://localhost:8000/") as proxy:
         print("3 is even: %s" % str(proxy.is_even(3)))
         print("100 is even: %s" % str(proxy.is_even(100)))


File: python.info,  Node: DateTime オブジェクト,  Next: Binary オブジェクト,  Prev: ServerProxy オブジェクト,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.2 DateTime オブジェクト
...............................

 -- クラス: xmlrpc.client.DateTime

     このクラスは、エポックからの秒数、タプルで表現された時刻、ISO 8601形
     式の時間/日付文字列、 *note datetime.datetime: 1ae, のインスタンス
     のいずれかで初期化することができます。このクラスには以下のメソッド
     があり、主にコードをマーシャル/アンマーシャルするための内部処理を行
     います:

      -- メソッド: decode (string)

          文字列をインスタンスの新しい時間を示す値として指定します。

      -- メソッド: encode (out)

          出力ストリームオブジェクト 'out' に、XML-RPCエンコーディングの
          *note DateTime: 138b. 値を出力します。

     It also supports certain of Python's built-in operators through
     *note rich comparison: 12d9. and *note __repr__(): 5e8. methods.

以下は、動作する例です。サーバ側のコード:

     import datetime
     from xmlrpc.server import SimpleXMLRPCServer
     import xmlrpc.client

     def today():
         today = datetime.datetime.today()
         return xmlrpc.client.DateTime(today)

     server = SimpleXMLRPCServer(("localhost", 8000))
     print("Listening on port 8000...")
     server.register_function(today, "today")
     server.serve_forever()

上記のサーバーに対するクライアントコード:

     import xmlrpc.client
     import datetime

     proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")

     today = proxy.today()
     # convert the ISO8601 string to a datetime object
     converted = datetime.datetime.strptime(today.value, "%Y%m%dT%H:%M:%S")
     print("Today: %s" % converted.strftime("%d.%m.%Y, %H:%M"))


File: python.info,  Node: Binary オブジェクト,  Next: Fault オブジェクト,  Prev: DateTime オブジェクト,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.3 Binary オブジェクト
.............................

 -- クラス: xmlrpc.client.Binary

     このクラスは、バイト列データ(NULを含む)で初期化することができます。
     *note Binary: 3a88. の内容は、属性で参照します:

      -- の属性: data

          *note Binary: 3a88. インスタンスがカプセル化しているバイナリデ
          ータ。このデータは *note bytes: 1a4. オブジェクトです。

     *note Binary: 3a88. オブジェクトは以下のメソッドを持ち、主に内部的
     にマーシャル/アンマーシャル時に使用されます:

      -- メソッド: decode (bytes)

          指定されたbase64 *note bytes: 1a4. オブジェクトをデコードし、
          インスタンスのデータとします。

      -- メソッド: encode (out)

          バイナリ値をbase64でエンコードし、出力ストリームオブジェクト
          'out' に出力します。

          エンコードされたデータは、 RFC 2045 section 6.8(1) にある通り
          、76文字ごとに改行されます。これは、XMC-RPC仕様が作成された時
          のデ・ファクト・スタンダードのbase64です。

     It also supports certain of Python's built-in operators through
     *note __eq__(): ac8. and *note __ne__(): 14c1. methods.

バイナリオブジェクトの使用例です。 XML-RPCごしに画像を転送します。

     from xmlrpc.server import SimpleXMLRPCServer
     import xmlrpc.client

     def python_logo():
         with open("python_logo.jpg", "rb") as handle:
             return xmlrpc.client.Binary(handle.read())

     server = SimpleXMLRPCServer(("localhost", 8000))
     print("Listening on port 8000...")
     server.register_function(python_logo, 'python_logo')

     server.serve_forever()

クライアントは画像を取得して、ファイルに保存します。

     import xmlrpc.client

     proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
     with open("fetched_python_logo.jpg", "wb") as handle:
         handle.write(proxy.python_logo().data)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2045.html#section-6.8


File: python.info,  Node: Fault オブジェクト,  Next: ProtocolError オブジェクト,  Prev: Binary オブジェクト,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.4 Fault オブジェクト
............................

 -- クラス: xmlrpc.client.Fault

     *note Fault: 3a89. オブジェクトは、XML-RPCのfaultタグの内容をカプセ
     ル化しており、以下の属性を持ちます:

      -- の属性: faultCode

          失敗のタイプを示す整数。

      -- の属性: faultString

          失敗の診断メッセージを含む文字列。

以下のサンプルでは、複素数型のオブジェクトを返そうとして、故意に *note
Fault: 3a89. を起こしています。

     from xmlrpc.server import SimpleXMLRPCServer

     # A marshalling error is going to occur because we're returning a
     # complex number
     def add(x, y):
         return x+y+0j

     server = SimpleXMLRPCServer(("localhost", 8000))
     print("Listening on port 8000...")
     server.register_function(add, 'add')

     server.serve_forever()

上記のサーバーに対するクライアントコード:

     import xmlrpc.client

     proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
     try:
         proxy.add(2, 5)
     except xmlrpc.client.Fault as err:
         print("A fault occurred")
         print("Fault code: %d" % err.faultCode)
         print("Fault string: %s" % err.faultString)


File: python.info,  Node: ProtocolError オブジェクト,  Next: MultiCall オブジェクト,  Prev: Fault オブジェクト,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.5 ProtocolError オブジェクト
....................................

 -- クラス: xmlrpc.client.ProtocolError

     *note ProtocolError: 3a8a. オブジェクトはトランスポート層で発生した
     エラー(URI で指定したサーバが見つからなかった場合に発生する404 'not
     found'など)の内容を示し、以下の属性を持ちます:

      -- の属性: url

          エラーの原因となったURIまたはURL。

      -- の属性: errcode

          エラーコード。

      -- の属性: errmsg

          エラーメッセージまたは診断文字列。

      -- の属性: headers

          エラーの原因となったHTTP/HTTPSリクエストを含む辞書。

次の例では、不適切な URI を利用して、故意に *note ProtocolError: 3a8a. を
発生させています:

     import xmlrpc.client

     # create a ServerProxy with a URI that doesn't respond to XMLRPC requests
     proxy = xmlrpc.client.ServerProxy("http://google.com/")

     try:
         proxy.some_method()
     except xmlrpc.client.ProtocolError as err:
         print("A protocol error occurred")
         print("URL: %s" % err.url)
         print("HTTP/HTTPS headers: %s" % err.headers)
         print("Error code: %d" % err.errcode)
         print("Error message: %s" % err.errmsg)


File: python.info,  Node: MultiCall オブジェクト,  Next: 補助関数,  Prev: ProtocolError オブジェクト,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.6 MultiCall オブジェクト
................................

*note MultiCall: 3aa4. オブジェクトは遠隔のサーバに対する複数の呼び出し
をひとつのリクエストにカプセル化する方法を提供します (1)。

 -- クラス: xmlrpc.client.MultiCall (server)

     巨大な (boxcar) メソッド呼び出しに使えるオブジェクトを作成します。
     'server' には最終的に呼び出しを行う対象を指定します。作成した
     MultiCall オブジェクトを使って呼び出しを行うと、即座に ‘None’ を返
     し、呼び出したい手続き名とパラメタを *note MultiCall: 3aa4. オブジ
     ェクトに保存するだけに留まります。オブジェクト自体を呼び出すと、そ
     れまでに保存しておいたすべての呼び出しを単一の ‘system.multicall’ リ
     クエストの形で伝送します。呼び出し結果は *note ジェネレータ: 1035.
     になります。このジェネレータにわたってイテレーションを行うと、個々
     の呼び出し結果を返します。

以下は、このクラスの使用例です。サーバ側のコード:

     from xmlrpc.server import SimpleXMLRPCServer

     def add(x, y):
         return x + y

     def subtract(x, y):
         return x - y

     def multiply(x, y):
         return x * y

     def divide(x, y):
         return x // y

     # A simple server with simple arithmetic functions
     server = SimpleXMLRPCServer(("localhost", 8000))
     print("Listening on port 8000...")
     server.register_multicall_functions()
     server.register_function(add, 'add')
     server.register_function(subtract, 'subtract')
     server.register_function(multiply, 'multiply')
     server.register_function(divide, 'divide')
     server.serve_forever()

上記のサーバーに対するクライアントコード:

     import xmlrpc.client

     proxy = xmlrpc.client.ServerProxy("http://localhost:8000/")
     multicall = xmlrpc.client.MultiCall(proxy)
     multicall.add(7, 3)
     multicall.subtract(7, 3)
     multicall.multiply(7, 3)
     multicall.divide(7, 3)
     result = multicall()

     print("7+3=%d, 7-3=%d, 7*3=%d, 7//3=%d" % tuple(result))

   ---------- Footnotes ----------

   (1) このアプローチは a discussion on xmlrpc.com
(https://web.archive.org/web/20060624230303/http://www.xmlrpc.com/discuss/msgReader$1208?mode=topic)
にて最初に著されました。


File: python.info,  Node: 補助関数,  Next: クライアントのサンプル,  Prev: MultiCall オブジェクト,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.7 補助関数
..................

 -- の関数: xmlrpc.client.dumps (params, methodname=None,
          methodresponse=None, encoding=None, allow_none=False)

     'params' を XML-RPC リクエストの形式に変換します。 'methodresponse'
     が真の場合、XML-RPC レスポンスの形式に変換します。 'params' に指定
     できるのは、引数からなるタプルか *note Fault: 3a89. 例外クラスのイ
     ンスタンスです。 'methodresponse' が真の場合、単一の値だけを返しま
     す。従って、 'params' の長さも 1 でなければなりません。 'encoding'
     を指定した場合、生成される XML のエンコード方式になります。デフォル
     トは UTF-8 です。 Python の *note None: 641. は標準の XML-RPC には
     利用できません。 *note None: 641. を使えるようにするには、
     'allow_none' を真にして、拡張機能つきにしてください。

 -- の関数: xmlrpc.client.loads (data, use_datetime=False,
          use_builtin_types=False)

     XML-RPC リクエストまたはレスポンスを ‘(params, methodname)’ の形式
     をとる Python オブジェクトにします。 'params' は引数のタプルです。
     'methodname' は文字列で、パケット中にメソッド名がない場合には
     ‘None’ になります。例外条件を示す XML-RPC パケットの場合には、
     *note Fault: 3a89. 例外を送出します。 'use_builtin_types' フラグは
     *note datetime.datetime: 1ae. のオブジェクトとして日付/時刻を、
     *note bytes: 1a4. のオブジェクトとしてバイナリデータを表現する時に
     使用し、デフォルトでは false に設定されています。

     非推奨となった 'use_datetime' フラグは 'use_builtin_types' に似てい
     ますが date/time 値にのみ適用されます。

     バージョン 3.3 で変更: 'use_builtin_types' フラグが追加されました。


File: python.info,  Node: クライアントのサンプル,  Next: クライアントとサーバーの利用例,  Prev: 補助関数,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.8 クライアントのサンプル
................................

     # simple test program (from the XML-RPC specification)
     from xmlrpc.client import ServerProxy, Error

     # server = ServerProxy("http://localhost:8000") # local server
     with ServerProxy("http://betty.userland.com") as proxy:

         print(proxy)

         try:
             print(proxy.examples.getStateName(41))
         except Error as v:
             print("ERROR", v)

XML-RPC サーバに HTTP プロキシを経由して接続する場合、カスタムトランスポ
ートを定義する必要があります。以下に例を示します:

     import http.client
     import xmlrpc.client

     class ProxiedTransport(xmlrpc.client.Transport):

         def set_proxy(self, host, port=None, headers=None):
             self.proxy = host, port
             self.proxy_headers = headers

         def make_connection(self, host):
             connection = http.client.HTTPConnection(*self.proxy)
             connection.set_tunnel(host, headers=self.proxy_headers)
             self._connection = host, connection
             return connection

     transport = ProxiedTransport()
     transport.set_proxy('proxy-server', 8080)
     server = xmlrpc.client.ServerProxy('http://betty.userland.com', transport=transport)
     print(server.examples.getStateName(41))


File: python.info,  Node: クライアントとサーバーの利用例,  Prev: クライアントのサンプル,  Up: xmlrpc client --- XML-RPC クライアントアクセス

5.21.21.9 クライアントとサーバーの利用例
........................................

*note SimpleXMLRPCServer の例: 3aaa. を参照してください。

脚注
....


File: python.info,  Node: xmlrpc server --- 基本的な XML-RPC サーバー,  Next: ipaddress --- IPv4/IPv6 操作ライブラリ,  Prev: xmlrpc client --- XML-RPC クライアントアクセス,  Up: インターネットプロトコルとサポート

5.21.22 ‘xmlrpc.server’ -- 基本的な XML-RPC サーバー
----------------------------------------------------

'ソースコード:' Lib/xmlrpc/server.py(1)

__________________________________________________________________

*note xmlrpc.server: 115. モジュールはPythonで記述された基本的なXML-RPC
サーバーフレームワークを提供します。サーバーはスタンドアロンであるか、
*note SimpleXMLRPCServer: 3aad. を使うか、 *note
CGIXMLRPCRequestHandler: 3aae. を使って CGI 環境に組み込まれるかの、いず
れかです。

     警告: *note xmlrpc.server: 115. モジュールは悪意を持って構築された
     データに対して安全ではありません。信頼できないデータや認証されてい
     ないデータを解析する必要がある場合は、 *note XML の脆弱性: 3607. を
     参照してください。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

 -- クラス: xmlrpc.server.SimpleXMLRPCServer (addr,
          requestHandler=SimpleXMLRPCRequestHandler, logRequests=True,
          allow_none=False, encoding=None, bind_and_activate=True,
          use_builtin_types=False)

     サーバーインスタンスを新たに作成します。 このクラスは XML-RPC プロ
     トコルで呼ばれる関数の登録のためのメソッドを提供します。 引数
     'requestHandler' にはリクエストハンドラーインスタンスのファクトリー
     を設定します。 デフォルトは *note SimpleXMLRPCRequestHandler: 12f6.
     です。 引数 'addr' と 'requestHandler' は *note
     socketserver.TCPServer: 12ee. のコンストラクターに渡されます。
     'logRequests' が真の場合 (デフォルト)、 リクエストはログに記録され
     ます。 この引数を偽にするとはログは記録されません。 引数
     'allow_none' と 'encoding' は *note xmlrpc.client: 114. に渡され、
     サーバーが返す XML-RPC 応答を制御します。 'bind_and_activate' 引数
     はコンストラクタが直ちに ‘server_bind()’ と ‘server_activate()’ を
     呼ぶかどうかを制御します。デフォルトでは真です。 この引数に ‘False’
     を設定することで、アドレスを束縛する前に 'allow_reuse_address' クラ
     ス変数を操作することが出来ます。 'use_builtin_types' 引数は *note
     loads(): 13dc. 関数に渡されます。 この引数は日付/時刻の値やバイナリ
     データを受け取ったときにどの型が処理されるかを制御します。デフォル
     トでは偽です。

     バージョン 3.3 で変更: 'use_builtin_types' フラグが追加されました。

 -- クラス: xmlrpc.server.CGIXMLRPCRequestHandler (allow_none=False,
          encoding=None, use_builtin_types=False)

     CGI 環境における XML-RPC リクエストハンドラーを新たに作成します。 引
     数 'allow_none' と 'encoding' は *note xmlrpc.client: 114. に渡され
     、サーバーが返す XML-RPC 応答を制御します。 'use_builtin_types' 引
     数は *note loads(): 13dc. 関数に渡されます。 この引数は日付/時刻の
     値やバイナリデータを受け取ったときにどの型が処理されるかを制御しま
     す。デフォルトは偽です。

     バージョン 3.3 で変更: 'use_builtin_types' フラグが追加されました。

 -- クラス: xmlrpc.server.SimpleXMLRPCRequestHandler

     リクエストハンドラーインスタンスを新たに作成します。このリクエスト
     ハンドラーは ‘POST’ リクエストをサポートし、 *note
     SimpleXMLRPCServer: 3aad. コンストラクターの引数 'logRequests' に従
     ってログ出力を行います。

* Menu:

* SimpleXMLRPCServer オブジェクト::
* CGIXMLRPCRequestHandler::
* XMLRPC サーバの文書化::
* DocXMLRPCServer オブジェクト::
* DocCGIXMLRPCRequestHandler::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/xmlrpc/server.py


File: python.info,  Node: SimpleXMLRPCServer オブジェクト,  Next: CGIXMLRPCRequestHandler,  Up: xmlrpc server --- 基本的な XML-RPC サーバー

5.21.22.1 SimpleXMLRPCServer オブジェクト
.........................................

*note SimpleXMLRPCServer: 3aad. クラスは *note socketserver.TCPServer:
12ee. のサブクラスで、基本的なスタンドアロンの XML-RPC サーバーを作成す
る手段を提供します。

 -- メソッド: SimpleXMLRPCServer.register_function (function=None,
          name=None)

     XML-RPC リクエストに応答可能な関数を登録します。引数 'name' が与え
     られた場合は、それが関数 'function' に関連付けられたメソッド名とな
     ります。そうでない場合は、 *note function.__name__: 12a2. の値が用
     いられます。引数 'name' は文字列で、例えばピリオド "."  のような
     Pythonで識別子として正しくない文字を含んでいても構いません。

     このメソッドはデコレーターとしても使用することができます。デコレー
     ターとして使用するときは、 'name' は関数を 'name' で登録するキーワ
     ード引数としてのみ渡すことができます。 'name' が与えられていないと
     きは、 *note function.__name__: 12a2. が使用されます。

     バージョン 3.7 で変更: *note register_function(): 3ab1. はデコレー
     ターとして使用できます。

 -- メソッド: SimpleXMLRPCServer.register_instance (instance,
          allow_dotted_names=False)

     オブジェクトを登録します。 オブジェクトは *note
     register_function(): 3ab1. を使用して登録されていないメソッド名を公
     開するのに使われます。 'instance' に ‘_dispatch()’ メソッドがあった
     場合、リクエストされたメソッド名と引数で ‘_dispatch()’ を呼び出しま
     す。 API は ‘def _dispatch(self, method, params)’ ('params' 可変引
     数リストではないことに注意) です。 タスクを実行するのに下層の関数を
     呼び出す場合、その関数は ‘func(*params)’ のように引数リストを展開し
     て呼び出されます。 ‘_dispatch()’ の返り値は結果としてクライアントに
     返されます。 'instance' に ‘_dispatch()’ メソッドがない場合、リクエ
     ストされたメソッド名にマッチする属性を検索します。

     オプション引数 'allow_dotted_names' が真でインスタンスに
     ‘_dispatch()’ メソッドがない場合、リクエストされたメソッド名がピリ
     オドを含むなら、メソッド名の各要素が個々に検索され、簡単な階層的検
     索が行われます。 その検索で発見された値をリクエストの引数で呼び出し
     、クライアントに返り値を返します。

          警告: 'allow_dotted_names' オプションを有効にすると、侵入者は
          あなたのモジュールのグローバル変数にアクセスすることができ、あ
          なたのマシンで任意のコードを実行できる可能性があります。このオ
          プションは閉じた安全なネットワークでのみお使い下さい。

 -- メソッド: SimpleXMLRPCServer.register_introspection_functions ()

     XML-RPC のイントロスペクション関数、 ‘system.listMethods’ 、
     ‘system.methodHelp’ 、 ‘system.methodSignature’ を登録します。

 -- メソッド: SimpleXMLRPCServer.register_multicall_functions ()

     XML-RPC における複数の要求を処理する関数 system.multicall を登録し
     ます。

 -- の属性: SimpleXMLRPCRequestHandler.rpc_paths

     この属性値はXML-RPCリクエストを受け付けるURLの有効なパス部分をリス
     トするタプルでなければなりません。これ以外のパスへのリクエストは
     404「そのようなページはありません」 HTTPエラーになります。このタプ
     ルが空の場合は全てのパスが有効であると見なされます。デフォルト値は
     ‘('/', '/RPC2')’ です。

* Menu:

* SimpleXMLRPCServer の例::


File: python.info,  Node: SimpleXMLRPCServer の例,  Up: SimpleXMLRPCServer オブジェクト

5.21.22.2 SimpleXMLRPCServer の例
.................................

サーバーのコード:

     from xmlrpc.server import SimpleXMLRPCServer
     from xmlrpc.server import SimpleXMLRPCRequestHandler

     # Restrict to a particular path.
     class RequestHandler(SimpleXMLRPCRequestHandler):
         rpc_paths = ('/RPC2',)

     # Create server
     with SimpleXMLRPCServer(('localhost', 8000),
                             requestHandler=RequestHandler) as server:
         server.register_introspection_functions()

         # Register pow() function; this will use the value of
         # pow.__name__ as the name, which is just 'pow'.
         server.register_function(pow)

         # Register a function under a different name
         def adder_function(x, y):
             return x + y
         server.register_function(adder_function, 'add')

         # Register an instance; all the methods of the instance are
         # published as XML-RPC methods (in this case, just 'mul').
         class MyFuncs:
             def mul(self, x, y):
                 return x * y

         server.register_instance(MyFuncs())

         # Run the server's main loop
         server.serve_forever()

以下のクライアントコードは上のサーバーで使えるようになったメソッドを呼び
出します:

     import xmlrpc.client

     s = xmlrpc.client.ServerProxy('http://localhost:8000')
     print(s.pow(2,3))  # Returns 2**3 = 8
     print(s.add(2,3))  # Returns 5
     print(s.mul(5,2))  # Returns 5*2 = 10

     # Print list of available methods
     print(s.system.listMethods())

‘register_function()’ はデコレーターとしても使用できます。前のサーバーの
例は、デコレーターの方法で関数を登録することもできます。

     from xmlrpc.server import SimpleXMLRPCServer
     from xmlrpc.server import SimpleXMLRPCRequestHandler

     class RequestHandler(SimpleXMLRPCRequestHandler):
         rpc_paths = ('/RPC2',)

     with SimpleXMLRPCServer(('localhost', 8000),
                             requestHandler=RequestHandler) as server:
         server.register_introspection_functions()

         # Register pow() function; this will use the value of
         # pow.__name__ as the name, which is just 'pow'.
         server.register_function(pow)

         # Register a function under a different name, using
         # register_function as a decorator. *name* can only be given
         # as a keyword argument.
         @server.register_function(name='add')
         def adder_function(x, y):
             return x + y

         # Register a function under function.__name__.
         @server.register_function
         def mul(x, y):
             return x * y

         server.serve_forever()

‘Lib/xmlrpc/server.py’ モジュール内にある以下の例はドット付名前を許容し
複数呼び出し関数を登録するサーバです。

     警告: 'allow_dotted_names' オプションを有効にすると、侵入者はあなた
     のモジュールのグローバル変数にアクセスすることができ、あなたのマシ
     ンで任意のコードを実行できる可能性があります。この例は閉じた安全な
     ネットワークでのみお使い下さい。

     import datetime

     class ExampleService:
         def getData(self):
             return '42'

         class currentTime:
             @staticmethod
             def getCurrentTime():
                 return datetime.datetime.now()

     with SimpleXMLRPCServer(("localhost", 8000)) as server:
         server.register_function(pow)
         server.register_function(lambda x,y: x+y, 'add')
         server.register_instance(ExampleService(), allow_dotted_names=True)
         server.register_multicall_functions()
         print('Serving XML-RPC on localhost port 8000')
         try:
             server.serve_forever()
         except KeyboardInterrupt:
             print("\nKeyboard interrupt received, exiting.")
             sys.exit(0)

この ExampleService デモはコマンドラインから起動することができます。

     python -m xmlrpc.server

上記のサーバとやりとりするクライアントは ‘Lib/xmlrpc/client.py’ にありま
す:

     server = ServerProxy("http://localhost:8000")

     try:
         print(server.currentTime.getCurrentTime())
     except Error as v:
         print("ERROR", v)

     multi = MultiCall(server)
     multi.getData()
     multi.pow(2,9)
     multi.add(1,2)
     try:
         for response in multi():
             print(response)
     except Error as v:
         print("ERROR", v)

デモ XMLRPC サーバとやりとりするクライアントは以下のように呼び出します:

     python -m xmlrpc.client


File: python.info,  Node: CGIXMLRPCRequestHandler,  Next: XMLRPC サーバの文書化,  Prev: SimpleXMLRPCServer オブジェクト,  Up: xmlrpc server --- 基本的な XML-RPC サーバー

5.21.22.3 CGIXMLRPCRequestHandler
.................................

*note CGIXMLRPCRequestHandler: 3aae. クラスは、Python の CGI スクリプト
に送られた XML-RPC リクエストを処理するときに使用できます。

 -- メソッド: CGIXMLRPCRequestHandler.register_function (function=None,
          name=None)

     XML-RPC リクエストに応答可能な関数を登録します。引数 'name' が与え
     られた場合は、それが関数 'function' に関連付けられたメソッド名とな
     ります。そうでない場合は、 *note function.__name__: 12a2. の値が用
     いられます。引数 'name' は文字列で、例えばピリオド "."  のような
     Pythonで識別子として正しくない文字を含んでいても構いません。

     このメソッドはデコレーターとしても使用することができます。デコレー
     ターとして使用するときは、 'name' は関数を 'name' で登録するキーワ
     ード引数としてのみ渡すことができます。 'name' が与えられていないと
     きは、 *note function.__name__: 12a2. が使用されます。

     バージョン 3.7 で変更: *note register_function(): 3ab8. はデコレー
     ターとして使用できます。

 -- メソッド: CGIXMLRPCRequestHandler.register_instance (instance)

     オブジェクトを登録します。 オブジェクトは *note
     register_function(): 3ab8. を使用して登録されていないメソッド名を公
     開するのに使われます。 'instance' に ‘_dispatch()’ メソッドがあった
     場合、リクエストされたメソッド名と引数で ‘_dispatch()’ を呼び出しま
     す。 返り値は結果としてクライアントに返されます。 'instance' に
     ‘_dispatch()’ メソッドがなかった場合、リクエストされたメソッド名に
     マッチする属性を検索します。 リクエストされたメソッド名がピリオドを
     含む場合、モジュール名の各要素が個々に検索され、簡単な階層的検索が
     実行されます。 その検索で発見された値をリクエストの引数で呼び出し、
     クライアントに返り値を返します。

 -- メソッド: CGIXMLRPCRequestHandler.register_introspection_functions
          ()

     XML-RPC のイントロスペクション関数、 ‘system.listMethods’ 、
     ‘system.methodHelp’ 、 ‘system.methodSignature’ を登録します。

 -- メソッド: CGIXMLRPCRequestHandler.register_multicall_functions ()

     XML-RPC マルチコール関数 ‘system.multicall’ を登録します。

 -- メソッド: CGIXMLRPCRequestHandler.handle_request (request_text=None)

     XML-RPC リクエストを処理します。 与えられた場合、 'request_text' は
     HTTP サーバが提供する POST データでなければなりません。 そうでない
     場合、標準入力の内容が使われます。

以下はプログラム例です:

     class MyFuncs:
         def mul(self, x, y):
             return x * y


     handler = CGIXMLRPCRequestHandler()
     handler.register_function(pow)
     handler.register_function(lambda x,y: x+y, 'add')
     handler.register_introspection_functions()
     handler.register_instance(MyFuncs())
     handler.handle_request()


File: python.info,  Node: XMLRPC サーバの文書化,  Next: DocXMLRPCServer オブジェクト,  Prev: CGIXMLRPCRequestHandler,  Up: xmlrpc server --- 基本的な XML-RPC サーバー

5.21.22.4 XMLRPC サーバの文書化
...............................

これらのクラスは HTTP GET 要求への応答内で HTML 文書となるよう上記クラス
を拡張します。 サーバは独立していても CGI 環境に埋め込まれていてもかまい
ません。 前者では *note DocXMLRPCServer: 1929. を、後者では *note
DocCGIXMLRPCRequestHandler: 3abe. を使用します。

 -- クラス: xmlrpc.server.DocXMLRPCServer (addr,
          requestHandler=DocXMLRPCRequestHandler, logRequests=True,
          allow_none=False, encoding=None, bind_and_activate=True,
          use_builtin_types=True)

     サーバ・インスタンスを新たに生成します。全ての引数の意味は *note
     SimpleXMLRPCServer: 3aad. のものと同じですが、 'requestHandler' の
     デフォルトは *note DocXMLRPCRequestHandler: 3abf. になっています。

     バージョン 3.3 で変更: 'use_builtin_types' フラグが追加されました。

 -- クラス: xmlrpc.server.DocCGIXMLRPCRequestHandler

     CGI環境で XMR-RPC リクエストを処理するインスタンスを新たに生成しま
     す。

 -- クラス: xmlrpc.server.DocXMLRPCRequestHandler

     リクエスト・ハンドラのインスタンスを新たに生成します。このリクエス
     ト・ハンドラは XML-RPC POST 要求とドキュメントの GET 要求をサポート
     し、 *note DocXMLRPCServer: 1929. コンストラクタに与えられた引数
     'logRequests' を優先するためにロギングを変更します。


File: python.info,  Node: DocXMLRPCServer オブジェクト,  Next: DocCGIXMLRPCRequestHandler,  Prev: XMLRPC サーバの文書化,  Up: xmlrpc server --- 基本的な XML-RPC サーバー

5.21.22.5 DocXMLRPCServer オブジェクト
......................................

*note DocXMLRPCServer: 1929. は *note SimpleXMLRPCServer: 3aad. の派生ク
ラスで、自己文書化するスタンドアローン XML-RPC サーバの作成手段を提供し
ます。 HTTP POST リクエストは XML-RPC メソッドの呼び出しとして処理されま
す。 HTTP GET リクエストは pydoc スタイルの HTML 文書の生成に処理されま
す。 これによりサーバは自身の web ベースの文書を提供できます。

 -- メソッド: DocXMLRPCServer.set_server_title (server_title)

     生成する HTML 文書で使用されるタイトルを設定します。このタイトルは
     HTML の title 要素内で使われます。

 -- メソッド: DocXMLRPCServer.set_server_name (server_name)

     生成する HTML 文書内で使用される名前を設定します。この名前は生成し
     た文書冒頭の h1 要素内で使われます。

 -- メソッド: DocXMLRPCServer.set_server_documentation
          (server_documentation)

     生成する HTML 文書内で使用される説明を設定します。この説明は文書中
     のサーバ名の下にパラグラフとして出力されます。


File: python.info,  Node: DocCGIXMLRPCRequestHandler,  Prev: DocXMLRPCServer オブジェクト,  Up: xmlrpc server --- 基本的な XML-RPC サーバー

5.21.22.6 DocCGIXMLRPCRequestHandler
....................................

*note DocCGIXMLRPCRequestHandler: 3abe. は *note
CGIXMLRPCRequestHandler: 3aae. の派生クラスで、自己文書化する XML-RPC
CGI スクリプトの作成手段を提供します。 HTTP POST リクエストは XML-RCP メ
ソッドの呼び出しとして処理されます。 HTTP GET リクエストは pydoc スタイ
ルの HTML 文書の生成に処理されます。 これによりサーバは自身の web ベース
の文書を提供できます。

 -- メソッド: DocCGIXMLRPCRequestHandler.set_server_title (server_title)

     生成する HTML 文書で使用されるタイトルを設定します。このタイトルは
     HTML の title 要素内で使われます。

 -- メソッド: DocCGIXMLRPCRequestHandler.set_server_name (server_name)

     生成する HTML 文書内で使用される名前を設定します。この名前は生成し
     た文書冒頭の h1 要素内で使われます。

 -- メソッド: DocCGIXMLRPCRequestHandler.set_server_documentation
          (server_documentation)

     生成する HTML 文書内で使用される説明を設定します。この説明は文書中
     のサーバ名の下にパラグラフとして出力されます。


File: python.info,  Node: ipaddress --- IPv4/IPv6 操作ライブラリ,  Prev: xmlrpc server --- 基本的な XML-RPC サーバー,  Up: インターネットプロトコルとサポート

5.21.23 ‘ipaddress’ -- IPv4/IPv6 操作ライブラリ
-----------------------------------------------

'ソースコード:' Lib/ipaddress.py(1)

__________________________________________________________________

*note ipaddress: 74. は IPv4 と IPv6 アドレスとネットワークの生成・変更
・操作を提供しています。

このモジュールの関数やクラスを使うと、IPアドレスに関する様々なタスク、例
えば2つのホストが同じサブネットに属しているかどうかをチェックしたり、特
定のサブネット内の全てのホストをイテレートしたり、文字列が正しい IP アド
レスかネットワークを定義しているかどうかをチェックするなどを簡単に実現す
ることができます。

これはモジュールの完全な API リファレンスです。概要や紹介は *note
ipaddressモジュールの紹介: 3acb. を参照してください。

Added in version 3.3.

* Menu:

* 便利なファクトリ関数::
* IP アドレス::
* IP ネットワーク定義::
* インターフェイスオブジェクト::
* その他のモジュールレベル関数::
* Custom Exceptions::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/ipaddress.py


File: python.info,  Node: 便利なファクトリ関数,  Next: IP アドレス,  Up: ipaddress --- IPv4/IPv6 操作ライブラリ

5.21.23.1 便利なファクトリ関数
..............................

*note ipaddress: 74. モジュールは簡単に IP アドレス、ネットワーク、イン
ターフェースを生成するためのファクトリ関数を提供しています:

 -- の関数: ipaddress.ip_address (address)

     引数に渡された IP address に応じて、 *note IPv4Address: 1dd. か
     *note IPv6Address: 1de. のオブジェクトを返します。 IPv4 か IPv6 の
     アドレスを受け取ります; ‘2**32’ より小さい整数はデフォルトでは IPv4
     アドレスだと判断されます。 'address' が正しい IPv4, IPv6 アドレスを
     表現していない場合は *note ValueError: 1e3. を発生させます。

          >>> ipaddress.ip_address('192.168.0.1')
          IPv4Address('192.168.0.1')
          >>> ipaddress.ip_address('2001:db8::')
          IPv6Address('2001:db8::')

 -- の関数: ipaddress.ip_network (address, strict=True)

     引数に渡された IP address に応じて、 *note IPv4Network: 1df. か
     *note IPv6Network: 1e0. のオブジェクトを返します。 'address' は IP
     ネットワークを示す文字列あるいは整数です。 IPv4 か IPv6 のネットワ
     ークを受け取ります; ‘2**32’ より小さい整数はデフォルトでは IPv4 ア
     ドレスだと判断されます。 'strict' は *note IPv4Network: 1df. か
     *note IPv6Network: 1e0. のコンストラクタに渡されます。 'address' が
     正しい IPv4, IPv6 アドレスを表現していない場合や、ネットワークの
     host bit がセットされていた場合は *note ValueError: 1e3. を発生させ
     ます。

          >>> ipaddress.ip_network('192.168.0.0/28')
          IPv4Network('192.168.0.0/28')

 -- の関数: ipaddress.ip_interface (address)

     引数に渡された IP address に応じて、 *note IPv4Interface: 1779. か
     *note IPv6Interface: 177a. のオブジェクトを返します。 'address' は
     IP ネットワークを示す文字列あるいは整数です。 IPv4 か IPv6 のネット
     ワークを受け取ります; ‘2**32’ より小さい整数はデフォルトでは IPv4 ア
     ドレスだと判断されます。 'address' が正しい IPv4, IPv6 アドレスを表
     現していない場合は *note ValueError: 1e3. を発生させます。

これらの便利関数を利用するデメリットとして、IPv4 と IPv6 両方のフォーマ
ットを扱う必要性があるために、どちらを期待されていたのかを知ることができ
ず、エラーメッセージが最小限の情報しか提供できないことです。利用したいバ
ージョンの特定のコンストラクタを直接呼ぶことで、より詳細なエラーレポート
を得ることができます。


File: python.info,  Node: IP アドレス,  Next: IP ネットワーク定義,  Prev: 便利なファクトリ関数,  Up: ipaddress --- IPv4/IPv6 操作ライブラリ

5.21.23.2 IP アドレス
.....................

* Menu:

* Address オブジェクト::
* 文字列と整数への変換::
* 演算子: 演算子<3>.


File: python.info,  Node: Address オブジェクト,  Next: 文字列と整数への変換,  Up: IP アドレス

5.21.23.3 Address オブジェクト
..............................

*note IPv4Address: 1dd. と *note IPv6Address: 1de. オブジェクトは多くの
共通した属性を持っています。両方の IP バージョンを扱うコードを書きやすく
するために、IPv6 アドレスでしか意味が無いいくつかの属性も *note
IPv4Address: 1dd. オブジェクトに実装されています。アドレスオブジェクトは
*note hashable: 5db. なので、辞書のキーとして利用できます。

 -- クラス: ipaddress.IPv4Address (address)

     IPv4 アドレスを構築する。 'address' が正しい IPv4 アドレスでない場
     合、 *note AddressValueError: 3ad2. を発生させます。

     以下のものが正しい IPv4 アドレスを構築します:

       1. A string in decimal-dot notation, consisting of four decimal
          integers in the inclusive range 0-255, separated by dots (e.g.
          ‘192.168.0.1’).  Each integer represents an octet (byte) in
          the address.  Leading zeroes are not tolerated to prevent
          confusion with octal notation.

       2. 32bit に収まる整数。

       3. 大きさ4の *note bytes: 1a4. オブジェクトに (最上位オクテットが
          最初になるように) パックされた整数。

          >>> ipaddress.IPv4Address('192.168.0.1')
          IPv4Address('192.168.0.1')
          >>> ipaddress.IPv4Address(3232235521)
          IPv4Address('192.168.0.1')
          >>> ipaddress.IPv4Address(b'\xC0\xA8\x00\x01')
          IPv4Address('192.168.0.1')

     バージョン 3.8 で変更: Leading zeros are tolerated, even in
     ambiguous cases that look like octal notation.

     バージョン 3.9.5 で変更: Leading zeros are no longer tolerated and
     are treated as an error.  IPv4 address strings are now parsed as
     strict as glibc *note inet_pton(): 930.

      -- の属性: version

          適切なバージョン番号: IPv4 なら ‘4’, IPv6 なら ‘6’.

      -- の属性: max_prefixlen

          このバージョンのアドレスを表現するのに必要なビット数: IPv4 な
          ら ‘32’, IPv6 なら ‘128’.

          prefix は、アドレスがネットワークに含まれるかどうかを決定する
          ために比較する、アドレスの先頭ビット数を定義します。

      -- の属性: compressed

      -- の属性: exploded

          ドットと10進数を使った表現の文字列。この表現には先頭の 0 は含
          まれません。

          IPv4 はアドレスの 0 オクテットを省略する記法を定義していないの
          で、IPv4 アドレスにおいてこれらの2つの属性は常に ‘str(addr)’ と
          等しくなります。これらの属性を用意することで、IPv4 と IPv6 ア
          ドレス両方を扱う、表示用コードが書きやすくなります。

      -- の属性: packed

          このアドレスのバイナリ表現 - 適切な長さをもった *note bytes:
          1a4. オブジェクト(最上位オクテットが先頭)。 IPv4 では 4 byte で
          、 IPv6 では 16 byte。

      -- の属性: reverse_pointer

          The name of the reverse DNS PTR record for the IP address,
          e.g.:

               >>> ipaddress.ip_address("127.0.0.1").reverse_pointer
               '1.0.0.127.in-addr.arpa'
               >>> ipaddress.ip_address("2001:db8::1").reverse_pointer
               '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa'

          This is the name that could be used for performing a PTR
          lookup, not the resolved hostname itself.

          Added in version 3.5.

      -- の属性: is_multicast

          アドレスがマルチキャスト用に予約されている場合は ‘True’ 。 RFC
          3171(1) (IPv4) か RFC 2373(2) (IPv6) を参照。

      -- の属性: is_private

          ‘True’ if the address is defined as not globally reachable by
          iana-ipv4-special-registry(3) (for IPv4) or
          iana-ipv6-special-registry(4) (for IPv6) with the following
          exceptions:

             * ‘is_private’ is ‘False’ for the shared address space
               (‘100.64.0.0/10’)

             * For IPv4-mapped IPv6-addresses the ‘is_private’ value is
               determined by the semantics of the underlying IPv4
               addresses and the following condition holds (see *note
               IPv6Address.ipv4_mapped: 3ada.):

                    address.is_private == address.ipv4_mapped.is_private

          ‘is_private’ has value opposite to *note is_global: f2c,
          except for the shared address space (‘100.64.0.0/10’ range)
          where they are both ‘False’.

          バージョン 3.13 で変更: Fixed some false positives and false
          negatives.

             * ‘192.0.0.0/24’ is considered private with the exception
               of ‘192.0.0.9/32’ and ‘192.0.0.10/32’ (previously: only
               the ‘192.0.0.0/29’ sub-range was considered private).

             * ‘64:ff9b:1::/48’ is considered private.

             * ‘2002::/16’ is considered private.

             * There are exceptions within ‘2001::/23’ (otherwise
               considered private): ‘2001:1::1/128’, ‘2001:1::2/128’,
               ‘2001:3::/32’, ‘2001:4:112::/48’, ‘2001:20::/28’,
               ‘2001:30::/28’.  The exceptions are not considered
               private.

      -- の属性: is_global

          ‘True’ if the address is defined as globally reachable by
          iana-ipv4-special-registry(5) (for IPv4) or
          iana-ipv6-special-registry(6) (for IPv6) with the following
          exception:

          For IPv4-mapped IPv6-addresses the ‘is_private’ value is
          determined by the semantics of the underlying IPv4 addresses
          and the following condition holds (see *note
          IPv6Address.ipv4_mapped: 3ada.):

               address.is_global == address.ipv4_mapped.is_global

          ‘is_global’ has value opposite to *note is_private: 15ad,
          except for the shared address space (‘100.64.0.0/10’ range)
          where they are both ‘False’.

          Added in version 3.4.

          バージョン 3.13 で変更: Fixed some false positives and false
          negatives, see *note is_private: 15ad. for details.

      -- の属性: is_unspecified

          アドレスが未定義の時に ‘True’.  RFC 5735(7) (IPv4) か RFC
          2373(8) (IPv6) を参照。

      -- の属性: is_reserved

          IETF で予約されているアドレスの場合に ‘True’。

      -- の属性: is_loopback

          ループバックアドレスである場合に ‘True’.  RFC 3330(9) (IPv4) か
          RFC 2373(10) (IPv6) を参照。

      -- の属性: is_link_local

          アドレスがリンクローカル用に予約されいている場合に ‘True’.
          RFC 3927(11) を参照。

      -- の属性: ipv6_mapped

          *note IPv4Address: 1dd. object representing the IPv4-mapped
          IPv6 address.  See RFC 4291(12).

          Added in version 3.13.

 -- メソッド: IPv4Address.__format__ (fmt)

     Returns a string representation of the IP address, controlled by an
     explicit format string.  'fmt' can be one of the following: ‘'s'’,
     the default option, equivalent to *note str(): 418, ‘'b'’ for a
     zero-padded binary string, ‘'X'’ or ‘'x'’ for an uppercase or
     lowercase hexadecimal representation, or ‘'n'’, which is equivalent
     to ‘'b'’ for IPv4 addresses and ‘'x'’ for IPv6.  For binary and
     hexadecimal representations, the form specifier ‘'#'’ and the
     grouping option ‘'_'’ are available.  ‘__format__’ is used by
     ‘format’, ‘str.format’ and f-strings.

          >>> format(ipaddress.IPv4Address('192.168.0.1'))
          '192.168.0.1'
          >>> '{:#b}'.format(ipaddress.IPv4Address('192.168.0.1'))
          '0b11000000101010000000000000000001'
          >>> f'{ipaddress.IPv6Address("2001:db8::1000"):s}'
          '2001:db8::1000'
          >>> format(ipaddress.IPv6Address('2001:db8::1000'), '_X')
          '2001_0DB8_0000_0000_0000_0000_0000_1000'
          >>> '{:#_n}'.format(ipaddress.IPv6Address('2001:db8::1000'))
          '0x2001_0db8_0000_0000_0000_0000_0000_1000'

     Added in version 3.9.

 -- クラス: ipaddress.IPv6Address (address)

     IPv6 アドレスを構築する。 'address' が正しい IPv6 アドレスでない場
     合、 *note AddressValueError: 3ad2. を発生させます。

     以下のものが正しい IPv6 アドレスを構築します:

       1. 4桁の16進数からなるグループ8個で構成された文字列。各グループは
          16bitを表現している。グループはコロンで区切られる。これは
          'exploded' (長い) 記法を表す。文字列は 'compressed' (省略) 記
          法でも良い。詳細は RFC 4291(13) を参照。例えば、
          ‘"0000:0000:0000:0000:0000:0abc:0007:0def"’ は ‘"::abc:7:def"’
          と省略できる。

          Optionally, the string may also have a scope zone ID,
          expressed with a suffix ‘%scope_id’.  If present, the scope ID
          must be non-empty, and may not contain ‘%’.  See RFC 4007(14)
          for details.  For example, ‘fe80::1234%1’ might identify
          address ‘fe80::1234’ on the first link of the node.

       2. 128bit に収まる整数。

       3. ビッグエンディアンで 16 バイトの長さの *note bytes: 1a4. オブ
          ジェクトにパックされた整数。

          >>> ipaddress.IPv6Address('2001:db8::1000')
          IPv6Address('2001:db8::1000')
          >>> ipaddress.IPv6Address('ff02::5678%1')
          IPv6Address('ff02::5678%1')

      -- の属性: compressed

     アドレス表現の短い形式で、グループ内の先頭の 0 を省略し、連続する完
     全に0のグループの一番長いシーケンスを1つの空グループに折りたたんだ
     もの。

     これは IPv6 アドレスに対して ‘str(addr)’ が返す値と同じです。

      -- の属性: exploded

     アドレス表現の長い形式。全てのグループの先頭の0は省略されず、完全に
     0のグループも省略されない。

     以降の属性とメソッドについては、*note IPv4Address: 1dd. クラスの対
     応するドキュメントを参照してください:

      -- の属性: packed

      -- の属性: reverse_pointer

      -- の属性: version

      -- の属性: max_prefixlen

      -- の属性: is_multicast

      -- の属性: is_private

      -- の属性: is_global

          Added in version 3.4.

      -- の属性: is_unspecified

      -- の属性: is_reserved

      -- の属性: is_loopback

      -- の属性: is_link_local

      -- の属性: is_site_local

          アドレスがサイトローカルな目的のために予約されいている場合に
          ‘True’.  サイトローカルアドレスは RFC 3879(15) によって廃止さ
          れている事に注意してください。アドレスが RFC 4193(16) で定義さ
          れているユニークローカルアドレスの範囲に含まれているかどうかを
          テストするには、 *note is_private: 15ad. を利用してください。

      -- の属性: ipv4_mapped

          IPv4 にマップされた(‘::FFFF/96’ で始まる)アドレスの場合、この
          プロパティは埋め込まれた IPv4 Address を返します。それ以外のア
          ドレスに対しては、このプロパティは ‘None’ になります。

      -- の属性: scope_id

          For scoped addresses as defined by RFC 4007(17), this property
          identifies the particular zone of the address's scope that the
          address belongs to, as a string.  When no scope zone is
          specified, this property will be ‘None’.

      -- の属性: sixtofour

          RFC 3056(18) で定義された 6to4 (‘2002::/16’ で始まる)アドレス
          の場合、このプロパティは埋め込まれた IPv4 Address を返します。
          それ以外のアドレスに対しては、このプロパティは ‘None’ になりま
          す。

      -- の属性: teredo

          RFC 4380(19) で定義された Teredo (‘2001::/32’ で始まる)アドレ
          スの場合、このプロパティは埋め込まれた ‘(server, client)’ IP ア
          ドレスペアを返します。それ以外のアドレスに対しては、このプロパ
          ティは ‘None’ になります。

 -- メソッド: IPv6Address.__format__ (fmt)

     *note IPv4Address: 1dd. の対応するメソッドのドキュメントを参照して
     ください。

     Added in version 3.9.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3171.html

   (2) https://datatracker.ietf.org/doc/html/rfc2373.html

   (3) 
https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml

   (4) 
https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml

   (5) 
https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml

   (6) 
https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml

   (7) https://datatracker.ietf.org/doc/html/rfc5735.html

   (8) https://datatracker.ietf.org/doc/html/rfc2373.html

   (9) https://datatracker.ietf.org/doc/html/rfc3330.html

   (10) https://datatracker.ietf.org/doc/html/rfc2373.html

   (11) https://datatracker.ietf.org/doc/html/rfc3927.html

   (12) https://datatracker.ietf.org/doc/html/rfc4291.html

   (13) https://datatracker.ietf.org/doc/html/rfc4291.html

   (14) https://datatracker.ietf.org/doc/html/rfc4007.html

   (15) https://datatracker.ietf.org/doc/html/rfc3879.html

   (16) https://datatracker.ietf.org/doc/html/rfc4193.html

   (17) https://datatracker.ietf.org/doc/html/rfc4007.html

   (18) https://datatracker.ietf.org/doc/html/rfc3056.html

   (19) https://datatracker.ietf.org/doc/html/rfc4380.html


File: python.info,  Node: 文字列と整数への変換,  Next: 演算子<3>,  Prev: Address オブジェクト,  Up: IP アドレス

5.21.23.4 文字列と整数への変換
..............................

socket モジュールなどのネットワークインターフェースを利用するには、アド
レスを文字列や整数に変換しなければなりません。これには組み込みの *note
str(): 418. と *note int(): 238. 関数を利用します:

     >>> str(ipaddress.IPv4Address('192.168.0.1'))
     '192.168.0.1'
     >>> int(ipaddress.IPv4Address('192.168.0.1'))
     3232235521
     >>> str(ipaddress.IPv6Address('::1'))
     '::1'
     >>> int(ipaddress.IPv6Address('::1'))
     1

Note that IPv6 scoped addresses are converted to integers without scope
zone ID.


File: python.info,  Node: 演算子<3>,  Prev: 文字列と整数への変換,  Up: IP アドレス

5.21.23.5 演算子
................

Address オブジェクトはいくつかの演算子をサポートします。明記されない限り
、演算子は互換性のあるオブジェクト間 (つまり IPv4 同士や IPv6 同士) での
み利用できます。

* Menu:

* 比較演算子::
* 算術演算::


File: python.info,  Node: 比較演算子,  Next: 算術演算,  Up: 演算子<3>

5.21.23.6 比較演算子
....................

Address objects can be compared with the usual set of comparison
operators.  Same IPv6 addresses with different scope zone IDs are not
equal.  Some examples:

     >>> IPv4Address('127.0.0.2') > IPv4Address('127.0.0.1')
     True
     >>> IPv4Address('127.0.0.2') == IPv4Address('127.0.0.1')
     False
     >>> IPv4Address('127.0.0.2') != IPv4Address('127.0.0.1')
     True
     >>> IPv6Address('fe80::1234') == IPv6Address('fe80::1234%1')
     False
     >>> IPv6Address('fe80::1234%1') != IPv6Address('fe80::1234%2')
     True


File: python.info,  Node: 算術演算,  Prev: 比較演算子,  Up: 演算子<3>

5.21.23.7 算術演算
..................

アドレスオブジェクトから整数を加減算できます。いくつかの例:

     >>> IPv4Address('127.0.0.2') + 3
     IPv4Address('127.0.0.5')
     >>> IPv4Address('127.0.0.2') - 3
     IPv4Address('126.255.255.255')
     >>> IPv4Address('255.255.255.255') + 1
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ipaddress.AddressValueError: 4294967296 (>= 2**32) is not permitted as an IPv4 address


File: python.info,  Node: IP ネットワーク定義,  Next: インターフェイスオブジェクト,  Prev: IP アドレス,  Up: ipaddress --- IPv4/IPv6 操作ライブラリ

5.21.23.8 IP ネットワーク定義
.............................

*note IPv4Network: 1df. と *note IPv6Network: 1e0. オブジェクトは IP ネ
ットワークの定義とインスペクトのための機構を提供します。ネットワーク定義
は 'mask' と 'ネットワークアドレス' からなり、 'mask' でマスク(bitごとの
AND) するとネットワークアドレスと同じになる IP アドレスの範囲を定義しま
す。例えば、 ‘255.255.255.0’ という 'mask' と ‘192.168.1.0’ というネット
ワークアドレスからなるネットワーク定義は、 ‘192.168.1.0’ から
‘192.168.1.255’ を含む範囲を表します。

* Menu:

* プリフィックス, ネットマスク、ホストマスク: プリフィックス ネットマスク、ホストマスク.
* Network オブジェクト::
* 演算子: 演算子<4>.


File: python.info,  Node: プリフィックス ネットマスク、ホストマスク,  Next: Network オブジェクト,  Up: IP ネットワーク定義

5.21.23.9 プリフィックス, ネットマスク、ホストマスク
....................................................

IP ネットワークマスクを定義する幾つかの等価な方法があります。'プリフィッ
クス' ‘/<nbits>’ は先頭の何bitがネットワークマスクで立っているかを示しま
す。'ネットマスク' は先頭の幾つかのbitが立っている IP アドレスです。プリ
フィックス ‘/24’ はIPv4 ではネットマスク ‘255.255.255.0’ と、IPv6 では
‘ffff:ff00::’ と同じになります。加えて、'ネットマスク' と論理が逆の 'ホ
ストマスク' があり、ときどき (例えば Cisco のアクセスコントロールリスト)
ネットワークマスクを表すために利用されます。‘/24’ と等しい IPv4 のホスト
マスクは ‘0.0.0.255’ になります。


File: python.info,  Node: Network オブジェクト,  Next: 演算子<4>,  Prev: プリフィックス ネットマスク、ホストマスク,  Up: IP ネットワーク定義

5.21.23.10 Network オブジェクト
...............................

address オブジェクトで実装されていた属性は全て network オブジェクトにも
実装されています。 network はそれに追加で幾つかの属性を実装しています。
全ての追加属性は *note IPv4Network: 1df. と *note IPv6Network: 1e0. で共
通なので、重複を避けるために *note IPv4Network: 1df. にだけドキュメント
されています。ネットワークオブジェクトは *note hashable: 5db. なので、辞
書のキーとして使用できます。

 -- クラス: ipaddress.IPv4Network (address, strict=True)

     IPv4 ネットワーク定義を構築します。'address' は以下の1つです:

       1. IPアドレスと、オプションでスラッシュ (‘/’) で区切られたマスク
          を持つ文字列。IPアドレスはネットワークアドレスで、マスクは 'プ
          リフィックス' を意味する1つの数値か、 IPv4 アドレスの文字列表
          現です。マスクがIPv4アドレスのとき、非ゼロのフィールドで始まる
          ときは 'ネットマスク' として、ゼロのフィールドで始まるときは
          'ホストマスク' として解釈されます。ただし、すべてのフィールド
          が0の場合は、'ネットマスク' として扱われます。マスクが省略され
          た場合、 ‘/32’ が指定されたものとします。

          例えば、次の 'address' 指定は全て等しくなります:
          ‘192.168.1.0/24’, ‘192.168.1.0/255.255.255.0’
          ‘192.168.1.0/0.0.0.255’.

       2. 32bit に収まる整数。これは1つのアドレスのネットワークと等しく
          、ネットワークアドレスが 'address' に、マスクが ‘/32’ になりま
          す。

       3. 4byte の *note bytes: 1a4. オブジェクトにビッグエンディアンで
          パックされた整数。これは整数の 'address' と同じように解釈され
          ます。

       4. アドレス記述とネットマスクの2要素のタプル。アドレス記述は、文
          字列、32ビットの整数、4バイトのパックされた整数、 既存の
          IPv4Address オブジェクトのいずれかです。ネットマスクは、プレフ
          ィックス長を表す整数（例えば '' 24''）またはプレフィックスマス
          クを表す文字列（例えば '' 255.255.255.0''）です。

     'address' が有効な IPv4 アドレスでない場合に *note
     AddressValueError: 3ad2. 例外を発生させます。マスクが IPv4 アドレス
     に対して有効でない場合に *note NetmaskValueError: 3af4. 例外を発生
     させます。

     'strict' が ‘True’ の場合、与えられたアドレスのホストビットが立って
     いたら *note ValueError: 1e3. を発生させます。そうでない場合、ホス
     トビットをマスクして正しいネットワークアドレスを計算します。

     特に明記されない場合、他の network や address を受け取る network の
     メソッドは、引数の IP バージョンが ‘self’ と異なる場合に *note
     TypeError: 502. を発生させます。

     バージョン 3.5 で変更: 'address' コンストラクタ引数に2要素のタプル
     形式を追加しました

      -- の属性: version

      -- の属性: max_prefixlen

          *note IPv4Address: 1dd. の対応する属性のドキュメントを参照して
          ください。

      -- の属性: is_multicast

      -- の属性: is_private

      -- の属性: is_unspecified

      -- の属性: is_reserved

      -- の属性: is_loopback

      -- の属性: is_link_local

          These attributes are true for the network as a whole if they
          are true for both the network address and the broadcast
          address.

      -- の属性: network_address

          この network のネットワークアドレス。ネットワークアドレスとプ
          リフィックス長によってユニークにネットワークが定義されます。

      -- の属性: broadcast_address

          このネットワークのブロードキャストアドレス。ブロードキャストア
          ドレスに投げられたパケットはそのネットワーク内の全てのホストに
          受信されます。

      -- の属性: hostmask

          *note IPv4Address: 1dd. オブジェクトとして表現された ホストマ
          スク。

      -- の属性: netmask

          *note IPv4Address: 1dd. オブジェクトとして表現された ネットマ
          スク。

      -- の属性: with_prefixlen

      -- の属性: compressed

      -- の属性: exploded

          A string representation of the network, with the mask in
          prefix notation.

          ‘with_prefixlen’ and ‘compressed’ are always the same as
          ‘str(network)’.  ‘exploded’ uses the exploded form the network
          address.

      -- の属性: with_netmask

          A string representation of the network, with the mask in net
          mask notation.

      -- の属性: with_hostmask

          A string representation of the network, with the mask in host
          mask notation.

      -- の属性: num_addresses

          ネットワーク内のアドレスの総数

      -- の属性: prefixlen

          ネットワークプレフィックスのビット長。

      -- メソッド: hosts ()

          Returns an iterator over the usable hosts in the network.  The
          usable hosts are all the IP addresses that belong to the
          network, except the network address itself and the network
          broadcast address.  For networks with a mask length of 31, the
          network address and network broadcast address are also
          included in the result.  Networks with a mask of 32 will
          return a list containing the single host address.

               >>> list(ip_network('192.0.2.0/29').hosts())
               [IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'),
                IPv4Address('192.0.2.3'), IPv4Address('192.0.2.4'),
                IPv4Address('192.0.2.5'), IPv4Address('192.0.2.6')]
               >>> list(ip_network('192.0.2.0/31').hosts())
               [IPv4Address('192.0.2.0'), IPv4Address('192.0.2.1')]
               >>> list(ip_network('192.0.2.1/32').hosts())
               [IPv4Address('192.0.2.1')]

      -- メソッド: overlaps (other)

          ‘True’ if this network is partly or wholly contained in
          'other' or 'other' is wholly contained in this network.

      -- メソッド: address_exclude (network)

          Computes the network definitions resulting from removing the
          given 'network' from this one.  Returns an iterator of network
          objects.  Raises *note ValueError: 1e3. if 'network' is not
          completely contained in this network.

               >>> n1 = ip_network('192.0.2.0/28')
               >>> n2 = ip_network('192.0.2.1/32')
               >>> list(n1.address_exclude(n2))
               [IPv4Network('192.0.2.8/29'), IPv4Network('192.0.2.4/30'),
                IPv4Network('192.0.2.2/31'), IPv4Network('192.0.2.0/32')]

      -- メソッド: subnets (prefixlen_diff=1, new_prefix=None)

          The subnets that join to make the current network definition,
          depending on the argument values.  'prefixlen_diff' is the
          amount our prefix length should be increased by.  'new_prefix'
          is the desired new prefix of the subnets; it must be larger
          than our prefix.  One and only one of 'prefixlen_diff' and
          'new_prefix' must be set.  Returns an iterator of network
          objects.

               >>> list(ip_network('192.0.2.0/24').subnets())
               [IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')]
               >>> list(ip_network('192.0.2.0/24').subnets(prefixlen_diff=2))
               [IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
                IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
               >>> list(ip_network('192.0.2.0/24').subnets(new_prefix=26))
               [IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
                IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
               >>> list(ip_network('192.0.2.0/24').subnets(new_prefix=23))
               Traceback (most recent call last):
                 File "<stdin>", line 1, in <module>
                   raise ValueError('new prefix must be longer')
               ValueError: new prefix must be longer
               >>> list(ip_network('192.0.2.0/24').subnets(new_prefix=25))
               [IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')]

      -- メソッド: supernet (prefixlen_diff=1, new_prefix=None)

          The supernet containing this network definition, depending on
          the argument values.  'prefixlen_diff' is the amount our
          prefix length should be decreased by.  'new_prefix' is the
          desired new prefix of the supernet; it must be smaller than
          our prefix.  One and only one of 'prefixlen_diff' and
          'new_prefix' must be set.  Returns a single network object.

               >>> ip_network('192.0.2.0/24').supernet()
               IPv4Network('192.0.2.0/23')
               >>> ip_network('192.0.2.0/24').supernet(prefixlen_diff=2)
               IPv4Network('192.0.0.0/22')
               >>> ip_network('192.0.2.0/24').supernet(new_prefix=20)
               IPv4Network('192.0.0.0/20')

      -- メソッド: subnet_of (other)

          このネットワークが 'other' のサブネットの場合に ‘True’ を返し
          ます。

               >>> a = ip_network('192.168.1.0/24')
               >>> b = ip_network('192.168.1.128/30')
               >>> b.subnet_of(a)
               True

          Added in version 3.7.

      -- メソッド: supernet_of (other)

          このネットワークが 'other' のスーパーネットの場合に ‘True’ を
          返します。

               >>> a = ip_network('192.168.1.0/24')
               >>> b = ip_network('192.168.1.128/30')
               >>> a.supernet_of(b)
               True

          Added in version 3.7.

      -- メソッド: compare_networks (other)

          このネットワークを 'other' と比較します。比較ではネットワーク
          アドレスのみが考慮され、ホストアドレスは考慮されません。‘-1’、
          ‘0’、‘1’ のいずれかを返します。

               >>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.2/32'))
               -1
               >>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.0/32'))
               1
               >>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.1/32'))
               0

          バージョン 3.7 で非推奨: It uses the same ordering and
          comparison algorithm as "<", "==", and ">"

 -- クラス: ipaddress.IPv6Network (address, strict=True)

     IPv6 ネットワーク定義を構築します。'address' は以下の1つです:

       1. A string consisting of an IP address and an optional prefix
          length, separated by a slash (‘/’).  The IP address is the
          network address, and the prefix length must be a single
          number, the 'prefix'.  If no prefix length is provided, it's
          considered to be ‘/128’.

          Note that currently expanded netmasks are not supported.  That
          means ‘2001:db00::0/24’ is a valid argument while
          ‘2001:db00::0/ffff:ff00::’ is not.

       2. 128bit に収まる整数。これは1つのアドレスのネットワークと等しく
          、ネットワークアドレスが 'address' に、マスクが ‘/128’ になり
          ます。

       3. 16byte の *note bytes: 1a4. オブジェクトにビッグエンディアンで
          パックされた整数。これは整数の 'address' と同じように解釈され
          ます。

       4. アドレス記述とネットマスクの2要素のタプル。アドレス記述は、文
          字列、128ビットの整数、16バイトのパックされた整数、 既存の
          IPv6Address オブジェクトのいずれかです。ネットマスクは、プレフ
          ィックス長を表す整数です。

     'address' が有効な IPv6 アドレスでない場合に *note
     AddressValueError: 3ad2. 例外を発生させます。マスクが IPv6 アドレス
     に対して有効でない場合に *note NetmaskValueError: 3af4. 例外を発生
     させます。

     'strict' が ‘True’ の場合、与えられたアドレスのホストビットが立って
     いたら *note ValueError: 1e3. を発生させます。そうでない場合、ホス
     トビットをマスクして正しいネットワークアドレスを計算します。

     バージョン 3.5 で変更: 'address' コンストラクタ引数に2要素のタプル
     形式を追加しました

      -- の属性: version

      -- の属性: max_prefixlen

      -- の属性: is_multicast

      -- の属性: is_private

      -- の属性: is_unspecified

      -- の属性: is_reserved

      -- の属性: is_loopback

      -- の属性: is_link_local

      -- の属性: network_address

      -- の属性: broadcast_address

      -- の属性: hostmask

      -- の属性: netmask

      -- の属性: with_prefixlen

      -- の属性: compressed

      -- の属性: exploded

      -- の属性: with_netmask

      -- の属性: with_hostmask

      -- の属性: num_addresses

      -- の属性: prefixlen

      -- メソッド: hosts ()

          Returns an iterator over the usable hosts in the network.  The
          usable hosts are all the IP addresses that belong to the
          network, except the Subnet-Router anycast address.  For
          networks with a mask length of 127, the Subnet-Router anycast
          address is also included in the result.  Networks with a mask
          of 128 will return a list containing the single host address.

      -- メソッド: overlaps (other)

      -- メソッド: address_exclude (network)

      -- メソッド: subnets (prefixlen_diff=1, new_prefix=None)

      -- メソッド: supernet (prefixlen_diff=1, new_prefix=None)

      -- メソッド: subnet_of (other)

      -- メソッド: supernet_of (other)

      -- メソッド: compare_networks (other)

          *note IPv4Network: 1df. の対応する属性のドキュメントを参照して
          ください。

      -- の属性: is_site_local

          These attribute is true for the network as a whole if it is
          true for both the network address and the broadcast address.


File: python.info,  Node: 演算子<4>,  Prev: Network オブジェクト,  Up: IP ネットワーク定義

5.21.23.11 演算子
.................

Network オブジェクトはいくつかの演算子をサポートします。明記されない限り
、演算子は互換性のあるオブジェクト間 (つまり IPv4 同士や IPv6 同士) での
み利用できます。

* Menu:

* 論理演算子::
* イテレーション::
* アドレスのコンテナとしてのネットワーク::


File: python.info,  Node: 論理演算子,  Next: イテレーション,  Up: 演算子<4>

5.21.23.12 論理演算子
.....................

Network objects can be compared with the usual set of logical operators.
Network objects are ordered first by network address, then by net mask.


File: python.info,  Node: イテレーション,  Next: アドレスのコンテナとしてのネットワーク,  Prev: 論理演算子,  Up: 演算子<4>

5.21.23.13 イテレーション
.........................

Network objects can be iterated to list all the addresses belonging to
the network.  For iteration, 'all' hosts are returned, including
unusable hosts (for usable hosts, use the *note hosts(): 3b08. method).
An example:

     >>> for addr in IPv4Network('192.0.2.0/28'):
     ...     addr
     ...
     IPv4Address('192.0.2.0')
     IPv4Address('192.0.2.1')
     IPv4Address('192.0.2.2')
     IPv4Address('192.0.2.3')
     IPv4Address('192.0.2.4')
     IPv4Address('192.0.2.5')
     IPv4Address('192.0.2.6')
     IPv4Address('192.0.2.7')
     IPv4Address('192.0.2.8')
     IPv4Address('192.0.2.9')
     IPv4Address('192.0.2.10')
     IPv4Address('192.0.2.11')
     IPv4Address('192.0.2.12')
     IPv4Address('192.0.2.13')
     IPv4Address('192.0.2.14')
     IPv4Address('192.0.2.15')


File: python.info,  Node: アドレスのコンテナとしてのネットワーク,  Prev: イテレーション,  Up: 演算子<4>

5.21.23.14 アドレスのコンテナとしてのネットワーク
.................................................

ネットワークオブジェクトは、アドレスのコンテナとして振舞えます。いくつか
例をあげます:

     >>> IPv4Network('192.0.2.0/28')[0]
     IPv4Address('192.0.2.0')
     >>> IPv4Network('192.0.2.0/28')[15]
     IPv4Address('192.0.2.15')
     >>> IPv4Address('192.0.2.6') in IPv4Network('192.0.2.0/28')
     True
     >>> IPv4Address('192.0.3.6') in IPv4Network('192.0.2.0/28')
     False


File: python.info,  Node: インターフェイスオブジェクト,  Next: その他のモジュールレベル関数,  Prev: IP ネットワーク定義,  Up: ipaddress --- IPv4/IPv6 操作ライブラリ

5.21.23.15 インターフェイスオブジェクト
.......................................

インターフェースオブジェクトは *note hashable: 5db. なので、辞書のキーと
して使用できます。

 -- クラス: ipaddress.IPv4Interface (address)

     Construct an IPv4 interface.  The meaning of 'address' is as in the
     constructor of *note IPv4Network: 1df, except that arbitrary host
     addresses are always accepted.

     *note IPv4Interface: 1779. is a subclass of *note IPv4Address: 1dd,
     so it inherits all the attributes from that class.  In addition,
     the following attributes are available:

      -- の属性: ip

          The address (*note IPv4Address: 1dd.) without network
          information.

               >>> interface = IPv4Interface('192.0.2.5/24')
               >>> interface.ip
               IPv4Address('192.0.2.5')

      -- の属性: network

          The network (*note IPv4Network: 1df.) this interface belongs
          to.

               >>> interface = IPv4Interface('192.0.2.5/24')
               >>> interface.network
               IPv4Network('192.0.2.0/24')

      -- の属性: with_prefixlen

          A string representation of the interface with the mask in
          prefix notation.

               >>> interface = IPv4Interface('192.0.2.5/24')
               >>> interface.with_prefixlen
               '192.0.2.5/24'

      -- の属性: with_netmask

          A string representation of the interface with the network as a
          net mask.

               >>> interface = IPv4Interface('192.0.2.5/24')
               >>> interface.with_netmask
               '192.0.2.5/255.255.255.0'

      -- の属性: with_hostmask

          A string representation of the interface with the network as a
          host mask.

               >>> interface = IPv4Interface('192.0.2.5/24')
               >>> interface.with_hostmask
               '192.0.2.5/0.0.0.255'

 -- クラス: ipaddress.IPv6Interface (address)

     Construct an IPv6 interface.  The meaning of 'address' is as in the
     constructor of *note IPv6Network: 1e0, except that arbitrary host
     addresses are always accepted.

     *note IPv6Interface: 177a. is a subclass of *note IPv6Address: 1de,
     so it inherits all the attributes from that class.  In addition,
     the following attributes are available:

      -- の属性: ip

      -- の属性: network

      -- の属性: with_prefixlen

      -- の属性: with_netmask

      -- の属性: with_hostmask

          *note IPv4Interface: 1779. の対応する属性のドキュメントを参照
          してください。

* Menu:

* 演算子: 演算子<5>.


File: python.info,  Node: 演算子<5>,  Up: インターフェイスオブジェクト

5.21.23.16 演算子
.................

Interface オブジェクトはいくつかの演算子をサポートします。明記されない限
り、演算子は互換性のあるオブジェクト間 (つまり IPv4 同士や IPv6 同士) で
のみ利用できます。

* Menu:

* 論理演算子: 論理演算子<2>.


File: python.info,  Node: 論理演算子<2>,  Up: 演算子<5>

5.21.23.17 論理演算子
.....................

Interface objects can be compared with the usual set of logical
operators.

For equality comparison (‘==’ and ‘!=’), both the IP address and network
must be the same for the objects to be equal.  An interface will not
compare equal to any address or network object.

For ordering (‘<’, ‘>’, etc) the rules are different.  Interface and
address objects with the same IP version can be compared, and the
address objects will always sort before the interface objects.  Two
interface objects are first compared by their networks and, if those are
the same, then by their IP addresses.


File: python.info,  Node: その他のモジュールレベル関数,  Next: Custom Exceptions,  Prev: インターフェイスオブジェクト,  Up: ipaddress --- IPv4/IPv6 操作ライブラリ

5.21.23.18 その他のモジュールレベル関数
.......................................

このモジュールは以下のモジュールレベル関数も提供しています:

 -- の関数: ipaddress.v4_int_to_packed (address)

     アドレスをネットワークバイトオーダー(ビッグエンディアン)でパックさ
     れた4バイトで表現します。 'address' は IPv4 IPアドレスを整数で表し
     たものです。整数が負だったり IPv4 IPアドレスとして大きすぎる場合は
     *note ValueError: 1e3. 例外を発生させます。

          >>> ipaddress.ip_address(3221225985)
          IPv4Address('192.0.2.1')
          >>> ipaddress.v4_int_to_packed(3221225985)
          b'\xc0\x00\x02\x01'

 -- の関数: ipaddress.v6_int_to_packed (address)

     アドレスをネットワークバイトオーダー(ビッグエンディアン)でパックさ
     れた16バイトで表現します。 'address' は IPv6 IPアドレスを整数で表し
     たものです。整数が負だったり IPv6 IPアドレスとして大きすぎる場合は
     *note ValueError: 1e3. 例外を発生させます。

 -- の関数: ipaddress.summarize_address_range (first, last)

     first と last で指定された IPアドレス帯に対するイテレーターを返しま
     す。 'first' はアドレス帯の中の最初の *note IPv4Address: 1dd. か
     *note IPv6Address: 1de. で、 'last' はアドレス帯の中の最後の *note
     IPv4Address: 1dd. か *note IPv6Address: 1de. です。 'first' か
     'last' がIPアドレスでない場合や、2つの型が揃っていない場合に、
     *note TypeError: 502. を発生させます。 'last' が 'first' より大きく
     ない場合や、 'first' アドレスのバージョンが 4 でも 6 でもない場合は
     *note ValueError: 1e3. を発生させます。

          >>> [ipaddr for ipaddr in ipaddress.summarize_address_range(
          ...    ipaddress.IPv4Address('192.0.2.0'),
          ...    ipaddress.IPv4Address('192.0.2.130'))]
          [IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/31'), IPv4Network('192.0.2.130/32')]

 -- の関数: ipaddress.collapse_addresses (addresses)

     Return an iterator of the collapsed *note IPv4Network: 1df. or
     *note IPv6Network: 1e0. objects.  'addresses' is an *note iterable:
     10ad. of *note IPv4Network: 1df. or *note IPv6Network: 1e0.
     objects.  A *note TypeError: 502. is raised if 'addresses' contains
     mixed version objects.

          >>> [ipaddr for ipaddr in
          ... ipaddress.collapse_addresses([ipaddress.IPv4Network('192.0.2.0/25'),
          ... ipaddress.IPv4Network('192.0.2.128/25')])]
          [IPv4Network('192.0.2.0/24')]

 -- の関数: ipaddress.get_mixed_type_key (obj)

     ネットワークとアドレスをソートするための key 関数を返します。アドレ
     スとネットワークは本質的に違うものなので、デフォルトでは比較できま
     せん。そのため、次の式は:

          IPv4Address('192.0.2.0') <= IPv4Network('192.0.2.0/24')

     doesn't make sense.  There are some times however, where you may
     wish to have *note ipaddress: 74. sort these anyway.  If you need
     to do this, you can use this function as the 'key' argument to
     *note sorted(): b9c.

     'obj' はネットワークオブジェクトかアドレスオブジェクトのどちらかで
     す。


File: python.info,  Node: Custom Exceptions,  Prev: その他のモジュールレベル関数,  Up: ipaddress --- IPv4/IPv6 操作ライブラリ

5.21.23.19 Custom Exceptions
............................

クラスのコンストラクタがより具体的なエラー報告をするために、このモジュー
ルでは以下の例外を定義します:

 -- 例外: ipaddress.AddressValueError (ValueError)

     Any value error related to the address.

 -- 例外: ipaddress.NetmaskValueError (ValueError)

     Any value error related to the net mask.


File: python.info,  Node: マルチメディアサービス,  Next: 国際化,  Prev: インターネットプロトコルとサポート,  Up: Python 標準ライブラリ

5.22 マルチメディアサービス
===========================

この章で記述されているモジュールは、主にマルチメディアアプリケーションに
役立つさまざまなアルゴリズムまたはインターフェイスを実装しています。これ
らのモジュールはインストール時の自由裁量に応じて利用できます:

* Menu:

* wave: wave --- WAV ファイルの読み書き. WAV ファイルの読み書き
* colorsys: colorsys --- 色体系間の変換. 色体系間の変換


File: python.info,  Node: wave --- WAV ファイルの読み書き,  Next: colorsys --- 色体系間の変換,  Up: マルチメディアサービス

5.22.1 ‘wave’ -- WAV ファイルの読み書き
---------------------------------------

'ソースコード:' Lib/wave.py(1)

__________________________________________________________________

The *note wave: fb. module provides a convenient interface to the
Waveform Audio "WAVE" (or "WAV") file format.  Only uncompressed PCM
encoded wave files are supported.

バージョン 3.12 で変更: Support for ‘WAVE_FORMAT_EXTENSIBLE’ headers was
added, provided that the extended format is ‘KSDATAFORMAT_SUBTYPE_PCM’.

*note wave: fb. モジュールは、以下の関数と例外を定義しています:

 -- の関数: wave.open (file, mode=None)

     'file' が文字列ならその名前のファイルを開き、そうでないなら file
     like オブジェクトとして扱います。 'mode' は以下のうちのいずれかです
     :

     ‘'rb'’

          読み出しのみのモード。

     ‘'wb'’

          書き込みのみのモード。

     WAVファイルに対して読み込み／書き込み両方のモードで開くことはできな
     いことに注意して下さい。

     'mode' が ‘'rb'’ の場合 *note Wave_read: 296. オブジェクトを返し、
     ‘'wb'’ の場合 *note Wave_write: 297. オブジェクトを返します。
     'mode' が省略されていて、 file-like オブジェクトが 'file' として渡
     されると、 ‘file.mode’ が 'mode' のデフォルト値として使われます。

     If you pass in a file-like object, the wave object will not close
     it when its ‘close()’ method is called; it is the caller's
     responsibility to close the file object.

     The *note open(): 919. function may be used in a *note with: 59c.
     statement.  When the ‘with’ block completes, the *note
     Wave_read.close(): 3b45. or *note Wave_write.close(): 3b46. method
     is called.

     バージョン 3.4 で変更: シーク不能なファイルのサポートが追加されまし
     た。

 -- 例外: wave.Error

     WAVの仕様を犯したり、実装の欠陥に遭遇して何か実行不可能となった時に
     発生するエラー。

* Menu:

* Wave_read オブジェクト::
* Wave_write オブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/wave.py


File: python.info,  Node: Wave_read オブジェクト,  Next: Wave_write オブジェクト,  Up: wave --- WAV ファイルの読み書き

5.22.1.1 Wave_read オブジェクト
...............................

 -- クラス: wave.Wave_read

     Read a WAV file.

     *note open(): 919. によって返される Wave_read オブジェクトには、以
     下のメソッドがあります:

      -- メソッド: close ()

          *note wave: fb. によって開かれていた場合はストリームを閉じ、こ
          のオブジェクトのインスタンスを使用できなくします。これはオブジ
          ェクトのガベージコレクション時に自動的に呼び出されます。

      -- メソッド: getnchannels ()

          オーディオチャンネル数（モノラルなら ‘1’ 、ステレオなら ‘2’ ）
          を返します。

      -- メソッド: getsampwidth ()

          サンプルサイズをバイト数で返します。

      -- メソッド: getframerate ()

          サンプリングレートを返します。

      -- メソッド: getnframes ()

          オーディオフレーム数を返します。

      -- メソッド: getcomptype ()

          圧縮形式を返します（ ‘'NONE'’ だけがサポートされている形式です
          ）。

      -- メソッド: getcompname ()

          *note getcomptype(): 3b4e. を人に判読可能な形にしたものです。
          通常、 ‘'NONE'’ に対して ‘'not compressed'’ が返されます。

      -- メソッド: getparams ()

          Returns a *note namedtuple(): 1ac. ‘(nchannels, sampwidth,
          framerate, nframes, comptype, compname)’, equivalent to output
          of the ‘get*()’ methods.

      -- メソッド: readframes (n)

          最大 'n' 個のオーディオフレームを読み込んで、 *note bytes:
          1a4. オブジェクトとして返します。

      -- メソッド: rewind ()

          ファイルのポインタをオーディオストリームの先頭に戻します。

     The following two methods are defined for compatibility with the
     old ‘aifc’ module, and don't do anything interesting.

      -- メソッド: getmarkers ()

          ‘None’ を返します。

          Deprecated since version 3.13, will be removed in version
          3.15: The method only existed for compatibility with the
          ‘aifc’ module which has been removed in Python 3.13.

      -- メソッド: getmark (id)

          エラーを発生します。

          Deprecated since version 3.13, will be removed in version
          3.15: The method only existed for compatibility with the
          ‘aifc’ module which has been removed in Python 3.13.

     以下の2つのメソッドは共通の"位置"を定義しています。"位置"は他の関数
     とは独立して実装されています。

      -- メソッド: setpos (pos)

          ファイルのポインタを指定した位置に設定します。

      -- メソッド: tell ()

          ファイルの現在のポインタ位置を返します。


File: python.info,  Node: Wave_write オブジェクト,  Prev: Wave_read オブジェクト,  Up: wave --- WAV ファイルの読み書き

5.22.1.2 Wave_write オブジェクト
................................

 -- クラス: wave.Wave_write

     Write a WAV file.

     Wave_write objects, as returned by *note open(): 919.

     For seekable output streams, the ‘wave’ header will automatically
     be updated to reflect the number of frames actually written.  For
     unseekable streams, the 'nframes' value must be accurate when the
     first frame data is written.  An accurate 'nframes' value can be
     achieved either by calling *note setnframes(): 3b56. or *note
     setparams(): 3b57. with the number of frames that will be written
     before *note close(): 3b46. is called and then using *note
     writeframesraw(): fb7. to write the frame data, or by calling *note
     writeframes(): fb8. with all of the frame data to be written.  In
     the latter case *note writeframes(): fb8. will calculate the number
     of frames in the data and set 'nframes' accordingly before writing
     the frame data.

     バージョン 3.4 で変更: シーク不能なファイルのサポートが追加されまし
     た。

     Wave_write objects have the following methods:

      -- メソッド: close ()

          'nframes' が正しいか確認して、ファイルが *note wave: fb. によ
          って開かれていた場合は閉じます。このメソッドはオブジェクトがガ
          ベージコレクションされるときに呼び出されます。もし出力ストリー
          ムがシーク不能で、 'nframes' が実際に書き込まれたフレームの数
          と一致しなければ、例外が起きます。

      -- メソッド: setnchannels (n)

          チャンネル数を設定します。

      -- メソッド: setsampwidth (n)

          サンプルサイズを 'n' バイトに設定します。

      -- メソッド: setframerate (n)

          サンプリングレートを 'n' に設定します。

          バージョン 3.2 で変更: 整数ではない値がこのメソッドに入力され
          た場合は、直近の整数に丸められます。

      -- メソッド: setnframes (n)

          フレーム数を 'n' に設定します。もし実際に書き込まれたフレーム
          の数と異なるなら、これは後で変更されます (出力ストリームがシー
          ク不能なら、更新しようとした時にエラーが起きます)。

      -- メソッド: setcomptype (type, name)

          圧縮形式とその記述を設定します。現在のところ、非圧縮を示す圧縮
          形式 ‘NONE’ だけがサポートされています。

      -- メソッド: setparams (tuple)

          The 'tuple' should be ‘(nchannels, sampwidth, framerate,
          nframes, comptype, compname)’, with values valid for the
          ‘set*()’ methods.  Sets all parameters.

      -- メソッド: tell ()

          ファイルの中の現在位置を返します。 *note Wave_read.tell():
          3b54. と *note Wave_read.setpos(): 3b53. メソッドでお断りした
          ことがこのメソッドにも当てはまります。

      -- メソッド: writeframesraw (data)

          'nframes' の修正なしにオーディオフレームを書き込みます。

          バージョン 3.4 で変更: どのような *note bytes-like object:
          cfb. も使用できるようになりました。

      -- メソッド: writeframes (data)

          出力ストリームが seek 不可能で、 'data' が書き込まれた後でそれ
          以前に 'nframes' に設定された値と書き込まれた全フレーム数が一
          致しなければ、エラーを送出します。

          バージョン 3.4 で変更: どのような *note bytes-like object:
          cfb. も使用できるようになりました。

          *note writeframes(): fb8. や *note writeframesraw(): fb7. メソ
          ッドを呼び出したあとで、どんなパラメータを設定しようとしても不
          正となることに注意して下さい。そうすると *note wave.Error:
          3b47. を発生します。


File: python.info,  Node: colorsys --- 色体系間の変換,  Prev: wave --- WAV ファイルの読み書き,  Up: マルチメディアサービス

5.22.2 ‘colorsys’ -- 色体系間の変換
-----------------------------------

'ソースコード:' Lib/colorsys.py(1)

__________________________________________________________________

The *note colorsys: 18. module defines bidirectional conversions of
color values between colors expressed in the RGB (Red Green Blue) color
space used in computer monitors and three other coordinate systems: YIQ,
HLS (Hue Lightness Saturation) and HSV (Hue Saturation Value).
Coordinates in all of these color spaces are floating-point values.  In
the YIQ space, the Y 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.

参考
....

色空間に関するより詳細な情報は ‘https://poynton.ca/ColorFAQ.html’ と
‘https://www.cambridgeincolour.com/tutorials/color-spaces.htm’ にありま
す。

*note colorsys: 18. モジュールでは、以下の関数が定義されています:

 -- の関数: colorsys.rgb_to_yiq (r, g, b)

     RGB から YIQ に変換します。

 -- の関数: colorsys.yiq_to_rgb (y, i, q)

     YIQ から RGB に変換します。

 -- の関数: colorsys.rgb_to_hls (r, g, b)

     RGB から HLS に変換します。

 -- の関数: colorsys.hls_to_rgb (h, l, s)

     HLS から RGB に変換します。

 -- の関数: colorsys.rgb_to_hsv (r, g, b)

     RGB から HSV に変換します。

 -- の関数: colorsys.hsv_to_rgb (h, s, v)

     HSV から RGB に変換します。

以下はプログラム例です:

     >>> import colorsys
     >>> colorsys.rgb_to_hsv(0.2, 0.4, 0.4)
     (0.5, 0.5, 0.4)
     >>> colorsys.hsv_to_rgb(0.5, 0.5, 0.4)
     (0.2, 0.4, 0.4)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/colorsys.py


File: python.info,  Node: 国際化,  Next: プログラムのフレームワーク,  Prev: マルチメディアサービス,  Up: Python 標準ライブラリ

5.23 国際化
===========

この章で解説されるモジュールは、プログラムのメッセージで使用される言語を
選択したり、または出力を地域の習慣に従って変更するメカニズムを提供して、
言語やロケールに依存しないソフトの開発を手助けします。

この章で解説されるモジュールのリスト:

* Menu:

* gettext: gettext --- 多言語国際化サービス. 多言語国際化サービス
* locale: locale --- 国際化サービス. 国際化サービス


File: python.info,  Node: gettext --- 多言語国際化サービス,  Next: locale --- 国際化サービス,  Up: 国際化

5.23.1 ‘gettext’ -- 多言語国際化サービス
----------------------------------------

'ソースコード:' Lib/gettext.py(1)

__________________________________________________________________

*note gettext: 59. モジュールは、 Python のモジュールやアプリケーション
の国際化 (I18N, I-nternationalizatio-N) および地域化 (L10N,
L-ocalizatio-N) サービスを提供します。 このモジュールは GNU ‘gettext’ メ
ッセージカタログの API と、より高水準で Python ファイルに適しているクラ
ス形式の API の両方をサポートしてます。 以下で述べるインターフェースを使
うことで、モジュールやアプリケーションのメッセージをある自然言語で記述し
ておき、後から提供する翻訳されたメッセージのカタログによって様々な自然言
語環境で実行できます。

ここでは Python のモジュールやアプリケーションを地域化するためのいくつか
のヒントも提供しています。

* Menu:

* GNU gettext API::
* クラス形式の API::
* プログラムやモジュールを国際化する::
* 謝辞: 謝辞<9>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/gettext.py


File: python.info,  Node: GNU gettext API,  Next: クラス形式の API,  Up: gettext --- 多言語国際化サービス

5.23.1.1 GNU ‘gettext’ API
..........................

*note gettext: 59. モジュールでは、以下の GNU ‘gettext’ API に非常に良く
似た API を提供しています。 この API を使う場合、アプリケーション全体の
翻訳に影響します。 アプリケーションが単一の言語しか扱わず、ユーザのロケ
ールに従って言語が選ばれるのなら、たいていはこの API が求めているもので
す。 Python モジュールを地域化していたり、アプリケーションの実行中に言語
を切り替える必要がある場合は、この API ではなくおそらくクラス形式の API
を使いたくなるでしょう。

 -- の関数: gettext.bindtextdomain (domain, localedir=None)

     'domain' をロケールディレクトリ 'localedir' に対応付けます。 具体的
     には、 *note gettext: 59. は与えられたドメインに対するバイナリ形式
     の ‘.mo’ ファイルを探しに、(Unixでは)
     ‘`localedir'/`language'/LC_MESSAGES/`domain'.mo’ というパスを見に行
     きます。 ここで 'language' はそれぞれ環境変数 ‘LANGUAGE’ 、
     ‘LC_ALL’ 、 ‘LC_MESSAGES’ 、 ‘LANG’ の中から検索されます。

     'localedir' が省略されるか ‘None’ の場合、現在 'domain' に対応付け
     られているロケールディレクトリが返されます。 (1)

 -- の関数: gettext.textdomain (domain=None)

     現在のグローバルドメインを変更したり調べたりします。 'domain' が
     ‘None’ の場合、現在のグローバルドメインが返されます。それ以外の場合
     には、グローバルドメインに 'domain' を設定し、その設定されたグロー
     バルドメインを返します。

 -- の関数: gettext.gettext (message)

     Return the localized translation of 'message', based on the current
     global domain, language, and locale directory.  This function is
     usually aliased as ‘_()’ in the local namespace (see examples
     below).

 -- の関数: gettext.dgettext (domain, message)

     *note gettext(): 140e. と同様ですが、指定された 'domain' からメッセ
     ージを探します。

 -- の関数: gettext.ngettext (singular, plural, n)

     *note gettext(): 140e. と同様ですが、複数形を考慮しています。 翻訳
     が見つかった場合、複数形の選択公式を 'n' に適用し、その結果得られた
     メッセージを返します (言語によっては二つ以上の複数形があります)。 翻
     訳が見つからなかった場合、 'n' が 1 なら 'singular' を返します; そ
     うでない場合 'plural' を返します。

     複数形の選択公式はカタログのヘッダから取得されます。 選択公式は自由
     変数 'n' を持つ C または Python の式です; その式の評価結果はカタロ
     グにある複数形のインデックスになります。 ‘.po’ ファイルで用いられる
     詳細な文法と、様々な言語における選択公式については GNU gettext ドキ
     ュメント(2) を参照してください。

 -- の関数: gettext.dngettext (domain, singular, plural, n)

     *note ngettext(): 3b6d. と同様ですが、指定された 'domain' からメッ
     セージを探します。

 -- の関数: gettext.pgettext (context, message)

 -- の関数: gettext.dpgettext (domain, context, message)

 -- の関数: gettext.npgettext (context, singular, plural, n)

 -- の関数: gettext.dnpgettext (domain, context, singular, plural, n)

     Similar to the corresponding functions without the ‘p’ in the
     prefix (that is, *note gettext(): 59, *note dgettext(): 3b6c, *note
     ngettext(): 3b6d, *note dngettext(): 3b6e.), but the translation is
     restricted to the given message 'context'.

     Added in version 3.8.

Note that GNU ‘gettext’ also defines a ‘dcgettext()’ method, but this
was deemed not useful and so it is currently unimplemented.

以下にこの API の典型的な使用法を示します:

     import gettext
     gettext.bindtextdomain('myapplication', '/path/to/my/language/directory')
     gettext.textdomain('myapplication')
     _ = gettext.gettext
     # ...
     print(_('This is a translatable string.'))

   ---------- Footnotes ----------

   (1) The default locale directory is system dependent; for example, on
Red Hat Linux it is ‘/usr/share/locale’, but on Solaris it is
‘/usr/lib/locale’.  The ‘gettext’ module does not try to support these
system dependent defaults; instead its default is
‘`sys.base_prefix'/share/locale’ (see *note sys.base_prefix: 3c9.).  For
this reason, it is always best to call *note bindtextdomain(): 3b6a.
with an explicit absolute path at the start of your application.

   (2) https://www.gnu.org/software/gettext/manual/gettext.html


File: python.info,  Node: クラス形式の API,  Next: プログラムやモジュールを国際化する,  Prev: GNU gettext API,  Up: gettext --- 多言語国際化サービス

5.23.1.2 クラス形式の API
.........................

The class-based API of the *note gettext: 59. module gives you more
flexibility and greater convenience than the GNU ‘gettext’ API. It is
the recommended way of localizing your Python applications and modules.
‘gettext’ defines a *note GNUTranslations: 3b73. class which implements
the parsing of GNU ‘.mo’ format files, and has methods for returning
strings.  Instances of this class can also install themselves in the
built-in namespace as the function ‘_()’.

 -- の関数: gettext.find (domain, localedir=None, languages=None,
          all=False)

     この関数は標準的な ‘.mo’ ファイル検索アルゴリズムを実装しています。
     *note textdomain(): 3b6b. と同じく、 'domain' を引数にとります。オ
     プションの 'localedir' は *note bindtextdomain(): 3b6a. と同じです
     。またオプションの 'languages' は文字列を列挙したリストで、各文字列
     は言語コードを表します。

     'localedir' が与えられていない場合、標準のシステムロケールディレク
     トリが使われます。 (1) 'languages' が与えられなかった場合、以下の環
     境変数: ‘LANGUAGE’ 、 ‘LC_ALL’ 、 ‘LC_MESSAGES’ 、および ‘LANG’ が
     検索されます。空でない値を返した最初の候補が 'languages' 変数として
     使われます。この環境変数は言語名をコロンで分かち書きしたリストを含
     んでいなければなりません。 *note find(): 3b74. はこの文字列をコロン
     で分割し、言語コードの候補リストを生成します。

     *note find(): 3b74. は次に言語コードを展開および正規化し、リストの
     各要素について、以下のパス構成:

     ‘`localedir'/`language'/LC_MESSAGES/`domain'.mo’

     からなる実在するファイルの探索を反復的に行います。 *note find():
     3b74. は上記のような実在するファイルで最初に見つかったものを返しま
     す。該当するファイルが見つからなかった場合、 ‘None’ が返されます。
     'all' が与えられていれば、全ファイル名のリストが言語リストまたは環
     境変数で指定されている順番に並べられたものを返します。

 -- の関数: gettext.translation (domain, localedir=None, languages=None,
          class_=None, fallback=False)

     Return a ‘*Translations’ instance based on the 'domain',
     'localedir', and 'languages', which are first passed to *note
     find(): 3b74. to get a list of the associated ‘.mo’ file paths.
     Instances with identical ‘.mo’ file names are cached.  The actual
     class instantiated is 'class_' if provided, otherwise *note
     GNUTranslations: 3b73.  The class's constructor must take a single
     *note file object: 1193. argument.

     複数の ‘.mo’ ファイルがあった場合、後ろのファイルは前のファイルのフ
     ォールバックとして利用されます。 フォールバックの設定のために、
     *note copy.copy(): 4fd. を使いキャッシュから翻訳オブジェクトを複製
     します; こうすることで、実際のインスタンスデータはキャッシュのもの
     と共有されたままになります。

     ‘.mo’ ファイルが見つからなかった場合、 'fallback' が偽 (デフォルト
     値) ならこの関数は *note OSError: 3f0. を送出し、 'fallback' が真な
     ら *note NullTranslations: 3b75. インスタンスが返されます。

     バージョン 3.3 で変更: 以前は *note IOError: 1026. が送出されました
     ; それは現在 *note OSError: 3f0. のエイリアスです。

     バージョン 3.11 で変更: 'codeset' parameter is removed.

 -- の関数: gettext.install (domain, localedir=None, *, names=None)

     This installs the function ‘_()’ in Python's builtins namespace,
     based on 'domain' and 'localedir' which are passed to the function
     *note translation(): a47.

     'names' パラメータについては、翻訳オブジェクトの *note install():
     3b76. メソッドの説明を参照ください。

     As seen below, you usually mark the strings in your application
     that are candidates for translation, by wrapping them in a call to
     the ‘_()’ function, like this:

          print(_('This string will be translated.'))

     For convenience, you want the ‘_()’ function to be installed in
     Python's builtins namespace, so it is easily accessible in all
     modules of your application.

     バージョン 3.11 で変更: 'names' is now a keyword-only parameter.

* Menu:

* NullTranslations クラス::
* GNUTranslations クラス::
* Solaris メッセージカタログ機構のサポート::
* Catalog コンストラクタ::

   ---------- Footnotes ----------

   (1) 上の *note bindtextdomain(): 3b6a. に関する脚注を参照してください
。


File: python.info,  Node: NullTranslations クラス,  Next: GNUTranslations クラス,  Up: クラス形式の API

5.23.1.3 ‘NullTranslations’ クラス
..................................

翻訳クラスは、元のソースファイル中のメッセージ文字列から翻訳されたメッセ
ージ文字列への変換処理が実際に実装されているクラスです。 全ての翻訳クラ
スで基底クラスとして使われているクラスが *note NullTranslations: 3b75. で
す; このクラスは、独自の翻訳クラスを実装するのに使える基本的なインターフ
ェースを提供しています。 以下に ‘NullTranslations’ のメソッドを示します:

 -- クラス: gettext.NullTranslations (fp=None)

     オプションの *note ファイルオブジェクト: 1193. 'fp' を取ります。こ
     の引数は基底クラスでは無視されます。このメソッドは "保護された
     (protected)" インスタンス変数 '_info' および '_charset' を初期化し
     ます。これらの変数の値は派生クラスで設定することができます。同様に
     '_fallback' も初期化しますが、この値は *note add_fallback(): 3b78.
     で設定されます。その後、 'fp' が ‘None’ でない場合
     ‘self._parse(fp)’ を呼び出します。

      -- メソッド: _parse (fp)

          基底クラスでは何もしない (no-op) ようになっています。このメソ
          ッドの役割はファイルオブジェクト 'fp' を引数に取り、ファイルか
          らデータを読み出し、メッセージカタログを初期化することです。サ
          ポートされていないメッセージカタログ形式を使っている場合、その
          形式を解釈するためにはこのメソッドを上書きしなくてはなりません
          。

      -- メソッド: add_fallback (fallback)

          'fallback' を現在の翻訳オブジェクトの代替オブジェクトとして追
          加します。翻訳オブジェクトが与えられたメッセージに対して翻訳メ
          ッセージを提供できない場合、この代替オブジェクトに問い合わせる
          ことになります。

      -- メソッド: gettext (message)

          フォールバックが設定されている場合、フォールバックの
          ‘gettext()’ に処理を移譲します。 そうでない場合、引数として受
          け取った 'message' を返します。 派生クラスで上書きするメソッド
          です。

      -- メソッド: ngettext (singular, plural, n)

          フォールバックが設定されている場合、フォールバックの
          ‘ngettext()’ に処理を移譲します。 そうでない場合、 'n' が 1 な
          ら 'singular' を返します; それ以外なら 'plural' を返します。 派
          生クラスで上書きするメソッドです。

      -- メソッド: pgettext (context, message)

          代替オブジェクトが設定されている場合、 *note pgettext(): 9c3.
          を代替オブジェクトに転送します。そうでない場合、翻訳されたメッ
          セージを返します。派生クラスで上書きするメソッドです。

          Added in version 3.8.

      -- メソッド: npgettext (context, singular, plural, n)

          代替オブジェクトが設定されている場合、 *note npgettext():
          3b70. を代替オブジェクトに転送します。そうでない場合、翻訳され
          たメッセージを返します。派生クラスで上書きするメソッドです。

          Added in version 3.8.

      -- メソッド: info ()

          Return a dictionary containing the metadata found in the
          message catalog file.

      -- メソッド: charset ()

          メッセージカタログファイルのエンコーディングを返します。

      -- メソッド: install (names=None)

          このメソッドは *note gettext(): 3b7a. を組み込み名前空間にイン
          ストールし、変数 ‘_’ に束縛します。

          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 ‘_()’.  Supported names are
          ‘'gettext'’, ‘'ngettext'’, ‘'pgettext'’, and ‘'npgettext'’.

          Note that this is only one way, albeit the most convenient
          way, to make the ‘_()’ function available to your application.
          Because it affects the entire application globally, and
          specifically the built-in namespace, localized modules should
          never install ‘_()’.  Instead, they should use this code to
          make ‘_()’ available to their module:

               import gettext
               t = gettext.translation('mymodule', ...)
               _ = t.gettext

          This puts ‘_()’ only in the module's global namespace and so
          only affects calls within this module.

          バージョン 3.8 で変更: ‘'pgettext'’ と ‘'npgettext'’ が追加さ
          れました。


File: python.info,  Node: GNUTranslations クラス,  Next: Solaris メッセージカタログ機構のサポート,  Prev: NullTranslations クラス,  Up: クラス形式の API

5.23.1.4 ‘GNUTranslations’ クラス
.................................

The ‘gettext’ module provides one additional class derived from *note
NullTranslations: 3b75.: *note GNUTranslations: 3b73.  This class
overrides ‘_parse()’ to enable reading GNU ‘gettext’ format ‘.mo’ files
in both big-endian and little-endian format.

*note GNUTranslations: 3b73. parses optional metadata out of the
translation catalog.  It is convention with GNU ‘gettext’ to include
metadata as the translation for the empty string.  This metadata is in
RFC 822(1)-style ‘key: value’ pairs, and should contain the
‘Project-Id-Version’ key.  If the key ‘Content-Type’ is found, then the
‘charset’ property is used to initialize the "protected" ‘_charset’
instance variable, defaulting to ‘None’ if not found.  If the charset
encoding is specified, then all message ids and message strings read
from the catalog are converted to Unicode using this encoding, else
ASCII is assumed.

Since message ids are read as Unicode strings too, all ‘*gettext()’
methods will assume message ids as Unicode strings, not byte strings.

The entire set of key/value pairs are placed into a dictionary and set
as the "protected" ‘_info’ instance variable.

‘.mo’ ファイルのマジックナンバーが不正な場合や、メジャーバージョン番号が
予期されないものの場合、あるいはその他の問題がファイルの読み出し中に発生
した場合、 *note GNUTranslations: 3b73. クラスのインスタンス化で *note
OSError: 3f0. が送出されることがあります。

 -- クラス: gettext.GNUTranslations

     以下のメソッドは基底クラスの実装からオーバライドされています:

      -- メソッド: gettext (message)

          カタログから 'message' id を検索して、対応するメッセージ文字列
          を Unicode でエンコードして返します。 'message' id に対応する
          エントリがカタログに存在せず、フォールバックが設定されている場
          合、検索処理をフォールバックの *note gettext(): 3b7a. メソッド
          に移譲します。 それ以外の場合は、 'message' id 自体が返されま
          す。

      -- メソッド: ngettext (singular, plural, n)

          メッセージ id に対する複数形を検索します。カタログに対する検索
          では 'singular' がメッセージ id として用いられ、 'n' にはどの
          複数形を用いるかを指定します。返されるメッセージ文字列は
          Unicode 文字列です。

          メッセージ id がカタログ中に見つからず、フォールバックが指定さ
          れている場合は、メッセージ検索要求はフォールバックの *note
          ngettext(): 3b7b. メソッドに移譲されます。 それ以外の場合、
          'n' が 1 ならば 'singular' が返され、それ以外なら 'plural' が
          返されます。

          以下に例を示します。:

               n = len(os.listdir('.'))
               cat = GNUTranslations(somefile)
               message = cat.ngettext(
                   'There is %(num)d file in this directory',
                   'There are %(num)d files in this directory',
                   n) % {'num': n}

      -- メソッド: pgettext (context, message)

          カタログから 'context' と 'message' id を検索して、対応するメ
          ッセージ文字列を、 Unicode でエンコードして返します。
          'message' id と 'context' に対するエントリがカタログに存在せず
          、フォールバックが設定されている場合、フォールバック検索はオブ
          ジェクトの *note pgettext(): 9c3. メソッドに転送されます。そう
          でない場合、 'message' id 自体が返されます。

          Added in version 3.8.

      -- メソッド: npgettext (context, singular, plural, n)

          メッセージ id に対する複数形を検索します。カタログに対する検索
          では 'singular' がメッセージ id として用いられ、 'n' にはどの
          複数形を用いるかを指定します。

          'context' に対するメッセージ id がカタログ中に見つからず、フォ
          ールバックオブジェクトが指定されている場合、メッセージ検索要求
          はフォールバックオブジェクトの *note npgettext(): 3b70. メソッ
          ドに転送されます。そうでない場合、 'n' が 1 ならば 'singular'
          が返され、それ以外に対しては 'plural' が返されます。

          Added in version 3.8.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc822.html


File: python.info,  Node: Solaris メッセージカタログ機構のサポート,  Next: Catalog コンストラクタ,  Prev: GNUTranslations クラス,  Up: クラス形式の API

5.23.1.5 Solaris メッセージカタログ機構のサポート
.................................................

Solaris オペレーティングシステムでは、独自の ‘.mo’ バイナリファイル形式
を定義していますが、この形式に関するドキュメントが手に入らないため、現時
点ではサポートされていません。


File: python.info,  Node: Catalog コンストラクタ,  Prev: Solaris メッセージカタログ機構のサポート,  Up: クラス形式の API

5.23.1.6 Catalog コンストラクタ
...............................

GNOME では、James Henstridge によるあるバージョンの *note gettext: 59. モ
ジュールを使っていますが、このバージョンは少し異なった API を持っていま
す。ドキュメントに書かれている利用法は:

     import gettext
     cat = gettext.Catalog(domain, localedir)
     _ = cat.gettext
     print(_('hello world'))

For compatibility with this older module, the function ‘Catalog()’ is an
alias for the *note translation(): a47. function described above.

このモジュールと Henstridge のバージョンとの間には一つ相違点があります:
彼のカタログオブジェクトはマップ型の API を介したアクセスがサポートされ
ていましたが、この API は使われていないらしく、現在はサポートされていま
せん。


File: python.info,  Node: プログラムやモジュールを国際化する,  Next: 謝辞<9>,  Prev: クラス形式の API,  Up: gettext --- 多言語国際化サービス

5.23.1.7 プログラムやモジュールを国際化する
...........................................

国際化 (I18N, I-nternationalizatio-N) とは、プログラムを複数の言語に対応
させる操作を指します。地域化 (L10N, L-ocalizatio-N) とは、すでに国際化さ
れているプログラムを特定地域の言語や文化的な事情に対応させることを指しま
す。Python プログラムに多言語メッセージ機能を追加するには、以下の手順を
踏む必要があります:

  1. プログラムやモジュールで翻訳対象とする文字列に特殊なマークをつけて
     準備します

  2. マークづけをしたファイルに一連のツールを走らせ、生のメッセージカタ
     ログを生成します

  3. 特定の言語へのメッセージカタログの翻訳を作成します

  4. メッセージ文字列を適切に変換するために *note gettext: 59. モジュー
     ルを使います

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
*note _: 59.  For example:

     filename = 'mylog.txt'
     message = _('writing a log message')
     with open(filename, 'w') as fp:
         fp.write(message)

この例では、文字列 ‘'writing a log message'’ が翻訳対象候補としてマーク
付けされており、文字列 ‘'mylog.txt'’ および ‘'w'’ はされていません。

翻訳対象の文字列を抽出するツールもあります。 オリジナルの GNU ‘gettext’
は C と C++ のソースコードしかサポートしませんが、拡張版の ‘xgettext’ は
Python を含めた多くの言語で書かれたコードを読み取り、翻訳できる文字列を
発見します。 Babel(1) は Python の国際化ライブラリで、翻訳文字列の抽出と
メッセージカタログのコンパイルを行う ‘pybabel’ スクリプトがあります。
François Pinard が開発した ‘xpot’ と呼ばれるプログラムは同じような処理を
行え、彼の po-utils package(2) の一部として利用可能です。

(Python には ‘pygettext.py’ および ‘msgfmt.py’ という名前の pure-Python
版プログラムもあります; これをインストールしてくれる Python ディストリビ
ューションもあります。 ‘pygettext.py’ は ‘xgettext’ に似たプログラムです
が Python のソースコードしか理解できず、 C や C++ のような他のプログラミ
ング言語を扱えません。 ‘pygettext.py’ は ‘xgettext’ と同様のコマンドライ
ンインターフェースをサポートしています; 詳しい使い方については
‘pygettext.py --help’ と実行してください。 ‘msgfmt.py’ は GNU ‘msgfmt’ と
バイナリ互換性があります。 この2つのプログラムがあれば、 GNU ‘gettext’ パ
ッケージを使わずに Python アプリケーションを国際化できるでしょう。)

‘xgettext’ や ‘pygettext’ のようなツールは、メッセージカタログである
‘.po’ ファイルを生成します。 このファイルは人間が判読可能な構造をしてい
て、ソースコード中のマークが着けられた文字列と、その文字列の仮置きの訳文
が一緒に書き込まれています。

生成された ‘.po’ ファイルは翻訳者個々人へ頒布され、サポート対象の各自然
言語への訳文が書き込まれます。 ある言語への飜訳が完了した
‘<language-name>.po’ ファイルは翻訳者により返送され、 ‘msgfmt’ を使い機
械が読み込みやすい ‘.mo’ バイナリカタログファイルへとコンパイルされます
。 この ‘.mo’ が *note gettext: 59. モジュールによる実行時の実際の飜訳処
理で使われます。

*note gettext: 59. モジュールをソースコード中でどのように使うかは単一の
モジュールを国際化するのか、それともアプリケーション全体を国際化するのか
によります。次のふたつのセクションで、それぞれについて説明します。

* Menu:

* モジュールを地域化する::
* アプリケーションを地域化する::
* 動作中 (on the fly) に言語を切り替える: 動作中 on the fly に言語を切り替える.
* 翻訳処理の遅延解決::

   ---------- Footnotes ----------

   (1) https://babel.pocoo.org/

   (2) https://github.com/pinard/po-utils


File: python.info,  Node: モジュールを地域化する,  Next: アプリケーションを地域化する,  Up: プログラムやモジュールを国際化する

5.23.1.8 モジュールを地域化する
...............................

モジュールを地域化する場合、グローバルな変更、例えば組み込み名前空間への
変更を行わないように注意しなければなりません。GNU ‘gettext’ API ではなく
、クラス形式の API を使うべきです。

仮に対象のモジュール名を "spam" とし、モジュールの各言語における翻訳が収
められた ‘.mo’ ファイルが ‘/usr/share/locale’ に GNU ‘gettext’ 形式で置
かれているとします。この場合、モジュールの最初で以下のようにします:

     import gettext
     t = gettext.translation('spam', '/usr/share/locale')
     _ = t.gettext


File: python.info,  Node: アプリケーションを地域化する,  Next: 動作中 on the fly に言語を切り替える,  Prev: モジュールを地域化する,  Up: プログラムやモジュールを国際化する

5.23.1.9 アプリケーションを地域化する
.....................................

If you are localizing your application, you can install the ‘_()’
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.

単純な場合では、単に以下の短いコードをアプリケーションの主ドライバファイ
ルに追加するだけです:

     import gettext
     gettext.install('myapplication')

ロケールの辞書を設定する必要がある場合、*note install(): a48. 関数に渡す
ことが出来ます:

     import gettext
     gettext.install('myapplication', '/usr/share/locale')


File: python.info,  Node: 動作中 on the fly に言語を切り替える,  Next: 翻訳処理の遅延解決,  Prev: アプリケーションを地域化する,  Up: プログラムやモジュールを国際化する

5.23.1.10 動作中 (on the fly) に言語を切り替える
................................................

多くの言語を同時にサポートする必要がある場合、複数の翻訳インスタンスを生
成して、例えば以下のコードのように、インスタンスを明示的に切り替えてもか
まいません。:

     import gettext

     lang1 = gettext.translation('myapplication', languages=['en'])
     lang2 = gettext.translation('myapplication', languages=['fr'])
     lang3 = gettext.translation('myapplication', languages=['de'])

     # start by using language1
     lang1.install()

     # ... time goes by, user selects language 2
     lang2.install()

     # ... more time goes by, user selects language 3
     lang3.install()


File: python.info,  Node: 翻訳処理の遅延解決,  Prev: 動作中 on the fly に言語を切り替える,  Up: プログラムやモジュールを国際化する

5.23.1.11 翻訳処理の遅延解決
............................

コードを書く上では、ほとんどの状況で文字列はコードされた場所で翻訳されま
す。しかし場合によっては、翻訳対象として文字列をマークはするが、その後実
際に翻訳が行われるように遅延させる必要が生じます。古典的な例は以下のよう
なコートです:

     animals = ['mollusk',
                'albatross',
                'rat',
                'penguin',
                'python', ]
     # ...
     for a in animals:
         print(a)

ここで、リスト ‘animals’ 内の文字列は翻訳対象としてマークはしたいが、文
字列が出力されるまで実際に翻訳を行うのは避けたいとします。

こうした状況を処理する一つの方法を以下に示します:

     def _(message): return message

     animals = [_('mollusk'),
                _('albatross'),
                _('rat'),
                _('penguin'),
                _('python'), ]

     del _

     # ...
     for a in animals:
         print(_(a))

This works because the dummy definition of ‘_()’ simply returns the
string unchanged.  And this dummy definition will temporarily override
any definition of ‘_()’ in the built-in namespace (until the *note del:
1711. command).  Take care, though if you have a previous definition of
‘_()’ in the local namespace.

Note that the second use of ‘_()’ will not identify "a" as being
translatable to the ‘gettext’ program, because the parameter is not a
string literal.

もう一つの処理法は、以下の例のようなやり方です:

     def N_(message): return message

     animals = [N_('mollusk'),
                N_('albatross'),
                N_('rat'),
                N_('penguin'),
                N_('python'), ]

     # ...
     for a in animals:
         print(_(a))

In this case, you are marking translatable strings with the function
‘N_()’, which won't conflict with any definition of ‘_()’.  However, you
will need to teach your message extraction program to look for
translatable strings marked with ‘N_()’.  ‘xgettext’, ‘pygettext’,
‘pybabel extract’, and ‘xpot’ all support this through the use of the
‘-k’ command-line switch.  The choice of ‘N_()’ here is totally
arbitrary; it could have just as easily been
‘MarkThisStringForTranslation()’.


File: python.info,  Node: 謝辞<9>,  Prev: プログラムやモジュールを国際化する,  Up: gettext --- 多言語国際化サービス

5.23.1.12 謝辞
..............

以下の人々が、このモジュールのコード、フィードバック、設計に関する助言、
過去の実装、そして有益な経験談による貢献をしてくれました:

   * Peter Funk

   * James Henstridge

   * Juan David Ibáñez Palomar

   * Marc-André Lemburg

   * Martin von Löwis

   * François Pinard

   * Barry Warsaw

   * Gustavo Niemeyer

脚注
....


File: python.info,  Node: locale --- 国際化サービス,  Prev: gettext --- 多言語国際化サービス,  Up: 国際化

5.23.2 ‘locale’ -- 国際化サービス
---------------------------------

'ソースコード:' Lib/locale.py(1)

__________________________________________________________________

*note locale: 7a. モジュールは POSIX ロケールデータベースおよびロケール
関連機能へのアクセスを提供します。 POSIX ロケール機構を使うことで、プロ
グラマはソフトウェアが実行される各国における詳細を知らなくても、アプリケ
ーション上で特定の地域文化に関係する部分を扱うことができます。

The *note locale: 7a. module is implemented on top of the ‘_locale’
module, which in turn uses an ANSI C locale implementation if available.

*note locale: 7a. モジュールでは以下の例外と関数を定義しています:

 -- 例外: locale.Error

     *note setlocale(): 2bd. に渡されたロケールが認識されない場合例外が
     送出されます。

 -- の関数: locale.setlocale (category, locale=None)

     'locale' が渡され ‘None’ でない場合、*note setlocale(): 2bd. は
     'category' のロケール設定を変更します。利用可能なカテゴリーは下記の
     表を参照してください。 'locale' は文字列か2つの文字列の iterable (言
     語コードと文字コード) です。iterale の場合 locale aliasing engine を
     用いてロケール名に変換されます。空の文字列はユーザのデフォルトの設
     定を指定します。ロケールの変更に失敗した場合 *note Error: 3b8f. が
     送出されます。成功した場合新しいロケールの設定が返されます。

     'locale' が省略されたり ‘None’ の場合、'category' の現在の設定が返
     されます。

     *note setlocale(): 2bd. はほとんどのシステムでスレッド安全ではあり
     ません。アプリケーションを書くとき、大抵は以下のコード

          import locale
          locale.setlocale(locale.LC_ALL, '')

     から書き始めます。これは全てのカテゴリをユーザの環境における標準設
     定 (大抵は環境変数 ‘LANG’ で指定されています) に設定します。その後
     複数スレッドを使ってロケールを変更したりしない限り、問題は起こらな
     いはずです。

 -- の関数: locale.localeconv ()

     地域的な慣行のデータベースを辞書として返します。辞書は以下の文字列
     をキーとして持っています:

     カテゴリ                   キー                                      意味
                                                                          
     ----------------------------------------------------------------------------------------------------------
                                                                          
     *note LC_NUMERIC: 3b90.    ‘'decimal_point'’                         小数点を表す文字です。
                                                                          
                                                                          
                                ‘'grouping'’                              ‘'thousands_sep'’ が来るかもしれな
                                                                          い場所を相対的に表した数からなる配
                                                                          列です。配列が
                                                                          *note CHAR_MAX: 3b91. で終端されて
                                                                          いる場合、それ以上の桁では桁数字の
                                                                          グループ化を行いません。配列が ‘0’
                                                                          で終端されている場合、最後に指定し
                                                                          たグループが反復的に使われます。
                                                                          
                                                                          
                                ‘'thousands_sep'’                         桁グループ間を区切るために使われる
                                                                          文字です。
                                                                          
                                                                          
     *note LC_MONETARY: 3b92.   ‘'int_curr_symbol'’                       国際通貨を表現する記号です。
                                                                          
                                                                          
                                ‘'currency_symbol'’                       地域的な通貨を表現する記号です。
                                                                          
                                                                          
                                ‘'p_cs_precedes/n_cs_precedes'’           通貨記号が値の前につくかどうかです
                                                                          (それぞれ正の値、負の値を表します
                                                                          )。
                                                                          
                                                                          
                                ‘'p_sep_by_space/n_sep_by_space'’         通貨記号と値との間にスペースを入れ
                                                                          るかどうかです (それぞれ正の値、負
                                                                          の値を表します)。
                                                                          
                                                                          
                                ‘'mon_decimal_point'’                     金額表示の際に使われる小数点です。
                                                                          
                                                                          
                                ‘'frac_digits'’                           金額を地域的な方法で表現する際の小
                                                                          数点以下の桁数です。
                                                                          
                                                                          
                                ‘'int_frac_digits'’                       金額を国際的な方法で表現する際の小
                                                                          数点以下の桁数です。
                                                                          
                                                                          
                                ‘'mon_thousands_sep'’                     金額表示の際に桁区切り記号です。
                                                                          
                                                                          
                                ‘'mon_grouping'’                          ‘'grouping'’ と同じで、金額表示の
                                                                          際に使われます。
                                                                          
                                                                          
                                ‘'positive_sign'’                         正の値の金額表示に使われる記号です
                                                                          。
                                                                          
                                                                          
                                ‘'negative_sign'’                         負の値の金額表示に使われる記号です
                                                                          。
                                                                          
                                                                          
                                ‘'p_sign_posn/n_sign_posn'’               符号の位置です (それぞれ正の値と負
                                                                          の値を表します)。以下を参照してく
                                                                          ださい。
                                                                          

     数値形式の値に *note CHAR_MAX: 3b91. を設定すると、そのロケールでは
     値が指定されていないことを表します。

     ‘'p_sign_posn'’ および ‘'n_sign_posn'’ の取り得る値は以下の通りです
     。

     値                 説明
                        
     -----------------------------------------------------------------
                        
     ‘0’                通貨記号および値は丸括弧で囲われます。
                        
                        
     ‘1’                符号は値と通貨記号より前に来ます。
                        
                        
     ‘2’                符号は値と通貨記号の後に続きます。
                        
                        
     ‘3’                符号は値の直前に来ます。
                        
                        
     ‘4’                符号は値の直後に来ます。
                        
                        
     ‘CHAR_MAX’         このロケールでは特に指定しません。
                        

     ‘LC_NUMERIC’ ロケールや ‘LC_MONETARY’ ロケールが ‘LC_CTYPE’ ロケー
     ルと異なっていて、数値文字列や通貨文字列が非 ASCII 文字列の場合、こ
     の関数は一時的に ‘LC_NUMERIC’ ロケールや ‘LC_MONETARY’ ロケールに
     ‘LC_CTYPE’ ロケールを設定します。 この一時的な変更は他のスレッドに
     影響を及ぼします。

     バージョン 3.7 で変更: この関数は、一時的に ‘LC_NUMERIC’ ロケールに
     ‘LC_CTYPE’ ロケールを設定する場合があります。

 -- の関数: locale.nl_langinfo (option)

     ロケール特有の情報を文字列として返します。この関数は全てのシステム
     で利用可能なわけではなく、指定できる 'option' もプラットフォーム間
     で大きく異なります。引数として使えるのは、locale モジュールで利用可
     能なシンボル定数を表す数字です。

     関数 *note nl_langinfo(): 3b93. は以下のキーのうち一つを受理します
     。ほとんどの記述は GNU C ライブラリ中の対応する説明から引用されてい
     ます。

      -- データ: locale.CODESET

          選択されたロケールで用いられている文字エンコーディングの名前を
          文字列で取得します。

      -- データ: locale.D_T_FMT

          日付と時刻をロケール特有の方法で表現するために、 *note
          time.strftime(): 11ba. の書式文字列として用いることのできる文
          字列を取得します。

      -- データ: locale.D_FMT

          日付をロケール特有の方法で表現するために、 *note
          time.strftime(): 11ba. の書式文字列として用いることのできる文
          字列を取得します。

      -- データ: locale.T_FMT

          時刻をロケール特有の方法で表現するために、 *note
          time.strftime(): 11ba. の書式文字列として用いることのできる文
          字列を取得します。

      -- データ: locale.T_FMT_AMPM

          時刻を午前／午後の書式で表現するために、 *note
          time.strftime(): 11ba. の書式文字列として用いることのできる文
          字列を取得します。

      -- データ: locale.DAY_1
      -- データ: locale.DAY_2
      -- データ: locale.DAY_3
      -- データ: locale.DAY_4
      -- データ: locale.DAY_5
      -- データ: locale.DAY_6
      -- データ: locale.DAY_7

          1 週間中の n 番目の曜日名を取得します。

               注釈: ロケール US における、 *note DAY_1: 3b99. を日曜日
               とする慣行に従っています。国際的な (ISO 8601) 月曜日を週
               の初めとする慣行ではありません。

      -- データ: locale.ABDAY_1
      -- データ: locale.ABDAY_2
      -- データ: locale.ABDAY_3
      -- データ: locale.ABDAY_4
      -- データ: locale.ABDAY_5
      -- データ: locale.ABDAY_6
      -- データ: locale.ABDAY_7

          1 週間中の n 番目の曜日名を略式表記で取得します。

      -- データ: locale.MON_1
      -- データ: locale.MON_2
      -- データ: locale.MON_3
      -- データ: locale.MON_4
      -- データ: locale.MON_5
      -- データ: locale.MON_6
      -- データ: locale.MON_7
      -- データ: locale.MON_8
      -- データ: locale.MON_9
      -- データ: locale.MON_10
      -- データ: locale.MON_11
      -- データ: locale.MON_12

          n 番目の月の名前を取得します。

      -- データ: locale.ABMON_1
      -- データ: locale.ABMON_2
      -- データ: locale.ABMON_3
      -- データ: locale.ABMON_4
      -- データ: locale.ABMON_5
      -- データ: locale.ABMON_6
      -- データ: locale.ABMON_7
      -- データ: locale.ABMON_8
      -- データ: locale.ABMON_9
      -- データ: locale.ABMON_10
      -- データ: locale.ABMON_11
      -- データ: locale.ABMON_12

          n 番目の月の名前を略式表記で取得します。

      -- データ: locale.RADIXCHAR

          基数点 (小数点ドット、あるいは小数点コンマ、等) を取得します。

      -- データ: locale.THOUSEP

          1000 単位桁区切り (3 桁ごとのグループ化) の区切り文字を取得し
          ます。

      -- データ: locale.YESEXPR

          肯定／否定で答える質問に対する肯定回答を正規表現関数で認識する
          ために利用できる正規表現を取得します。

      -- データ: locale.NOEXPR

          Get a regular expression that can be used with the ‘regex(3)’
          function to recognize a negative response to a yes/no
          question.

               注釈: The regular expressions for *note YESEXPR: 3bc1.
               and *note NOEXPR: 3bc2. use syntax suitable for the
               ‘regex’ function from the C library, which might differ
               from the syntax used in *note re: a7.

      -- データ: locale.CRNCYSTR

          通貨シンボルを取得します。シンボルを値の前に表示させる場合には
          "-"、値の後ろに表示させる場合には "+"、シンボルを基数点と置き
          換える場合には "."  を前につけます。

      -- データ: locale.ERA

          現在のロケールで使われている年代を表現する値を取得します。

          ほとんどのロケールではこの値を定義していません。この値を設定し
          ているロケールの例は Japanese です。日本には日付の伝統的な表示
          法として、時の天皇に対応する元号名があります。

          通常この値を直接指定する必要はありません。 ‘E’ を書式文字列に
          指定することで、関数 *note time.strftime(): 11ba. がこの情報を
          使うようになります。返される文字列の様式は決められていないので
          、異なるシステム間で様式に関する同じ知識が使えると期待してはい
          けません。

      -- データ: locale.ERA_D_T_FMT

          日付および時間をロケール固有の年代に基づいた方法で表現するため
          に、 *note time.strftime(): 11ba. の書式文字列として用いること
          のできる文字列を取得します。

      -- データ: locale.ERA_D_FMT

          日付をロケール固有の年代に基づいた方法で表現するために、 *note
          time.strftime(): 11ba. の書式文字列として用いることのできる文
          字列を取得します。

      -- データ: locale.ERA_T_FMT

          時刻をロケール固有の年代に基づいた方法で表現するために、 *note
          time.strftime(): 11ba. の書式文字列として用いることのできる文
          字列を取得します。

      -- データ: locale.ALT_DIGITS

          Get a string consisting of up to 100 semicolon-separated
          symbols used to represent the values 0 to 99 in a
          locale-specific way.  In most locales this is an empty string.

 -- の関数: locale.getdefaultlocale ([envvars])

     標準のロケール設定を取得しようと試み、結果をタプル ‘(language code,
     encoding)’ の形式で返します。

     POSIXによると、 ‘setlocale(LC_ALL, '')’ を呼ばなかったプログラムは
     、移植可能な ‘'C'’ ロケール設定を使います。 ‘setlocale(LC_ALL, '')’
     を呼ぶことで、 ‘LANG’ 変数で定義された標準のロケール設定を使うよう
     になります。 Python では現在のロケール設定に干渉したくないので、上
     で述べたような方法でその挙動をエミュレーションしています。

     他のプラットフォームとの互換性を維持するために、環境変数 ‘LANG’ だ
     けでなく、引数 'envvars' で指定された環境変数のリストも調べられます
     。最初に見つかった定義が使われます。 'envvars' は標準では GNU
     gettext で使われている検索順になります; これは常に変数名 ‘LANG’ を
     探します。GNU gettext では ‘'LC_ALL'’ 、 ‘'LC_CTYPE'’ 、 ‘'LANG'’ 、
     および ‘'LANGUAGE'’ の順に調べられます。

     ‘'C'’ の場合を除き、言語コードは RFC 1766(2) に対応します。
     'language code' および 'encoding' が決定できなかった場合、 ‘None’ に
     なるかもしれません。

     Deprecated since version 3.11, will be removed in version 3.15.

 -- の関数: locale.getlocale (category=LC_CTYPE)

     Returns the current setting for the given locale category as
     sequence containing 'language code', 'encoding'.  'category' may be
     one of the ‘LC_*’ values except *note LC_ALL: 3bc9.  It defaults to
     *note LC_CTYPE: 3bca.

     ‘'C'’ の場合を除き、言語コードは RFC 1766(3) に対応します。
     'language code' および 'encoding' が決定できなかった場合、 ‘None’ に
     なるかもしれません。

 -- の関数: locale.getpreferredencoding (do_setlocale=True)

     テキストデータに使われる *note ロケールエンコーディング: 223. を、
     ユーザの設定に基づいて返します。ユーザの設定は異なるシステム間では
     異なった方法で表現され、システムによってはプログラミング的に得るこ
     とができないこともあるので、この関数が返すのはただの推測です。

     システムによっては、ユーザの設定を取得するために *note setlocale():
     2bd. を呼び出す必要があるため、この関数はスレッド安全ではありません
     。 *note setlocale(): 2bd. を呼び出す必要がない、または呼び出したく
     ない場合、 'do_setlocale' を ‘False’ に設定する必要があります。

     On Android or if the *note Python UTF-8 Mode: 622. is enabled,
     always return ‘'utf-8'’, the *note locale encoding: 223. and the
     'do_setlocale' argument are ignored.

     The *note Python preinitialization: 3bcb. configures the LC_CTYPE
     locale.  See also the *note filesystem encoding and error handler:
     505.

     バージョン 3.7 で変更: この関数は、 Android 上あるいは *note Python
     UTF-8 モード: 622. が有効になっている場合、常に ‘"utf-8"’ を返すよ
     うになりました。

 -- の関数: locale.getencoding ()

     Get the current *note locale encoding: 223.:

        * On Android and VxWorks, return ‘"utf-8"’.

        * On Unix, return the encoding of the current *note LC_CTYPE:
          3bca. locale.  Return ‘"utf-8"’ if ‘nl_langinfo(CODESET)’
          returns an empty string: for example, if the current LC_CTYPE
          locale is not supported.

        * On Windows, return the ANSI code page.

     The *note Python preinitialization: 3bcb. configures the LC_CTYPE
     locale.  See also the *note filesystem encoding and error handler:
     505.

     This function is similar to *note getpreferredencoding(False): 504.
     except this function ignores the *note Python UTF-8 Mode: 622.

     Added in version 3.11.

 -- の関数: locale.normalize (localename)

     与えたロケール名を規格化したロケールコードを返します。返されるロケ
     ールコードは *note setlocale(): 2bd. で使うために書式化されています
     。規格化が失敗した場合、もとの名前がそのまま返されます。

     与えたエンコードがシステムにとって未知の場合、標準の設定では、この
     関数は *note setlocale(): 2bd. と同様に、エンコーディングをロケール
     コードにおける標準のエンコーディングに設定します。

 -- の関数: locale.strcoll (string1, string2)

     現在の *note LC_COLLATE: 3bce. 設定に従って二つの文字列を比較します
     。他の比較を行う関数と同じように、 'string1' が 'string2' に対して
     前に来るか、後に来るか、あるいは二つが等しいかによって、それぞれ負
     の値、正の値、あるいは ‘0’ を返します。

 -- の関数: locale.strxfrm (string)

     文字列を、ロケールを考慮した比較に使える形式に変換します。例えば、
     ‘strxfrm(s1) < strxfrm(s2)’ は ‘strcoll(s1, s2) < 0’ と等価です。こ
     の関数は同じ文字列が何度も比較される場合、例えば文字列からなるシー
     ケンスを順序付けて並べる際に使うことができます。

 -- の関数: locale.format_string (format, val, grouping=False,
          monetary=False)

     Formats a number 'val' according to the current *note LC_NUMERIC:
     3b90. setting.  The format follows the conventions of the ‘%’
     operator.  For floating-point values, the decimal point is modified
     if appropriate.  If 'grouping' is ‘True’, also takes the grouping
     into account.

     'monetary' が真なら、桁区切り記号やグループ化文字列を用いて変換を行
     います。

     ‘format % val’ 形式のフォーマット指定子を、現在のロケール設定を考慮
     したうえで処理します。

     バージョン 3.7 で変更: 'monetary' キーワード引数が追加されました。

 -- の関数: locale.currency (val, symbol=True, grouping=False,
          international=False)

     数値 'val' を、現在の *note LC_MONETARY: 3b92. の設定にあわせてフォ
     ーマットします。

     'symbol' が真の場合は、返される文字列に通貨記号が含まれるようになり
     ます。これはデフォルトの設定です。'grouping' が ‘True’ の場合(これ
     はデフォルトではありません)は、値をグループ化します。
     'international' が ‘True’ の場合(これはデフォルトではありません)は
     、国際的な通貨記号を使用します。

          注釈: この関数は 'C' ロケールでは動作しないので、まず *note
          setlocale(): 2bd. でロケールを設定する必要があります。

 -- の関数: locale.str (float)

     Formats a floating-point number using the same format as the
     built-in function ‘str(float)’, but takes the decimal point into
     account.

 -- の関数: locale.delocalize (string)

     文字列を *note LC_NUMERIC: 3b90. で設定された慣行に従って正規化され
     た数値文字列に変換します。

     Added in version 3.5.

 -- の関数: locale.localize (string, grouping=False, monetary=False)

     Converts a normalized number string into a formatted string
     following the *note LC_NUMERIC: 3b90. settings.

     Added in version 3.10.

 -- の関数: locale.atof (string, func=float)

     Converts a string to a number, following the *note LC_NUMERIC:
     3b90. settings, by calling 'func' on the result of calling *note
     delocalize(): df2. on 'string'.

 -- の関数: locale.atoi (string)

     文字列を *note LC_NUMERIC: 3b90. で設定された慣行に従って整数に変換
     します。

 -- データ: locale.LC_CTYPE

     Locale category for the character type functions.  Most
     importantly, this category defines the text encoding, i.e.  how
     bytes are interpreted as Unicode codepoints.  See PEP 538(4) and
     PEP 540(5) for how this variable might be automatically coerced to
     ‘C.UTF-8’ to avoid issues created by invalid settings in containers
     or incompatible settings passed over remote SSH connections.

     Python doesn't internally use locale-dependent character
     transformation functions from ‘ctype.h’.  Instead, an internal
     ‘pyctype.h’ provides locale-independent equivalents like
     ‘Py_TOLOWER’.

 -- データ: locale.LC_COLLATE

     文字列を並べ替えるためのロケールカテゴリです。 *note locale: 7a. モ
     ジュールの関数 *note strcoll(): 3bcd. および *note strxfrm(): 3bcf.
     が影響を受けます。

 -- データ: locale.LC_TIME

     時刻を書式化するためのロケールカテゴリです。 *note time.strftime():
     11ba. はこのカテゴリに設定されている慣行に従います。

 -- データ: locale.LC_MONETARY

     金額に関係する値を書式化するためのロケールカテゴリです。設定可能な
     オプションは関数 *note localeconv(): bcc. で得ることができます。

 -- データ: locale.LC_MESSAGES

     メッセージ表示のためのロケールカテゴリです。現在 Python はアプリケ
     ーション毎にロケールに対応したメッセージを出力する機能はサポートし
     ていません。 *note os.strerror(): 2a82. が返すような、オペレーティ
     ングシステムによって表示されるメッセージはこのカテゴリによって影響
     を受けます。

     This value may not be available on operating systems not conforming
     to the POSIX standard, most notably Windows.

 -- データ: locale.LC_NUMERIC

     Locale category for formatting numbers.  The functions *note
     format_string(): 4e8, *note atoi(): 3bd4, *note atof(): 3bd3. and
     *note str(): 3bd1. of the *note locale: 7a. module are affected by
     that category.  All other numeric formatting operations are not
     affected.

 -- データ: locale.LC_ALL

     全てのロケール設定を総合したものです。ロケールを変更する際にこのフ
     ラグが使われた場合、そのロケールにおける全てのカテゴリを設定しよう
     と試みます。一つでも失敗したカテゴリがあった場合、全てのカテゴリに
     おいて設定変更を行いません。このフラグを使ってロケールを取得した場
     合、全てのカテゴリにおける設定を示す文字列が返されます。この文字列
     は、後に設定を元に戻すために使うことができます。

 -- データ: locale.CHAR_MAX

     *note localeconv(): bcc. の返す特別な値のためのシンボル定数です。

以下はプログラム例です:

     >>> import locale
     >>> loc = locale.getlocale()  # get current locale
     # use German locale; name might vary with platform
     >>> locale.setlocale(locale.LC_ALL, 'de_DE')
     >>> locale.strcoll('f\xe4n', 'foo')  # compare a string containing an umlaut
     >>> locale.setlocale(locale.LC_ALL, '')   # use user's preferred locale
     >>> locale.setlocale(locale.LC_ALL, 'C')  # use default (C) locale
     >>> locale.setlocale(locale.LC_ALL, loc)  # restore saved locale

* Menu:

* ロケールの背景、詳細、ヒント、助言および補足説明::
* Python 拡張の作者と、Python を埋め込むようなプログラムに関して::
* メッセージカタログへのアクセス::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/locale.py

   (2) https://datatracker.ietf.org/doc/html/rfc1766.html

   (3) https://datatracker.ietf.org/doc/html/rfc1766.html

   (4) https://peps.python.org/pep-0538/

   (5) https://peps.python.org/pep-0540/


File: python.info,  Node: ロケールの背景、詳細、ヒント、助言および補足説明,  Next: Python 拡張の作者と、Python を埋め込むようなプログラムに関して,  Up: locale --- 国際化サービス

5.23.2.1 ロケールの背景、詳細、ヒント、助言および補足説明
.........................................................

C 標準では、ロケールはプログラム全体にわたる特性であり、その変更は高価な
処理であるとしています。加えて、頻繁にロケールを変更するようなひどい実装
はコアダンプを引き起こすこともあります。このことがロケールを正しく利用す
る上で苦痛となっています。

最初、プログラムが起動したときには、ユーザの希望するロケールにかかわらず
ロケールは ‘C’ です。例外が1つあります: *note LC_CTYPE: 3bca. カテゴリは
、現在のロケールエンコーディングをユーザーの希望するロケールエンコーディ
ングに設定するために、スタートアップで変更されます。他のカテゴリについて
は、プログラムは ‘setlocale(LC_ALL, '')’ を呼び出して、明示的にユーザの
希望するロケール設定を行わなければなりません。

*note setlocale(): 2bd. をライブラリルーチン内で呼ぶことは、それがプログ
ラム全体に及ぼす副作用の面から、一般的によくない考えです。ロケールを保存
したり復帰したりするのもよくありません: 高価な処理であり、ロケールの設定
が復帰する以前に起動してしまった他のスレッドに悪影響を及ぼすからです。

もし、汎用を目的としたモジュールを作っていて、ロケールによって影響をうけ
るような操作 (例えば *note time.strftime(): 11ba. の書式の一部) のロケー
ル独立のバージョンが必要ということになれば、標準ライブラリルーチンを使わ
ずに何とかしなければなりません。よりましな方法は、ロケール設定が正しく利
用できているか確かめることです。最後の手段は、あなたのモジュールが ‘C’ ロ
ケール以外の設定には互換性がないとドキュメントに書くことです。

The only way to perform numeric operations according to the locale is to
use the special functions defined by this module: *note atof(): 3bd3,
*note atoi(): 3bd4, *note format_string(): 4e8, *note str(): 3bd1.

ロケールに従ってケース変換や文字分類を行う方法はありません。 (ユニコード
) テキスト文字列については、これらは文字の値のみによって行われます。その
一方、バイト文字列はバイトの ASCII 値に従って変換と分類が行われます。そ
して、上位ビットが立っているバイト (すなわち、non-ASCII バイト) は、決し
て変換されず、英字や空白などの文字クラスの一部とみなされることもありませ
ん。


File: python.info,  Node: Python 拡張の作者と、Python を埋め込むようなプログラムに関して,  Next: メッセージカタログへのアクセス,  Prev: ロケールの背景、詳細、ヒント、助言および補足説明,  Up: locale --- 国際化サービス

5.23.2.2 Python 拡張の作者と、Python を埋め込むようなプログラムに関して
.......................................................................

拡張モジュールは、現在のロケールを調べる以外は、決して *note
setlocale(): 2bd. を呼び出してはなりません。しかし、返される値もロケール
の復帰のために使えるだけなので、さほど便利とはいえません (例外はおそらく
ロケールが ‘C’ かどうか調べることでしょう)。

When Python code uses the *note locale: 7a. module to change the locale,
this also affects the embedding application.  If the embedding
application doesn't want this to happen, it should remove the ‘_locale’
extension module (which does all the work) from the table of built-in
modules in the ‘config.c’ file, and make sure that the ‘_locale’ module
is not accessible as a shared library.


File: python.info,  Node: メッセージカタログへのアクセス,  Prev: Python 拡張の作者と、Python を埋め込むようなプログラムに関して,  Up: locale --- 国際化サービス

5.23.2.3 メッセージカタログへのアクセス
.......................................

 -- の関数: locale.gettext (msg)

 -- の関数: locale.dgettext (domain, msg)

 -- の関数: locale.dcgettext (domain, msg, category)

 -- の関数: locale.textdomain (domain)

 -- の関数: locale.bindtextdomain (domain, dir)

 -- の関数: locale.bind_textdomain_codeset (domain, codeset)

C ライブラリの gettext インタフェースが提供されているシステムでは、
locake モジュールでそのインタフェースを公開しています。このインタフェー
スは関数 *note gettext(): 59. 、 *note dgettext(): 3bdd. 、 *note
dcgettext(): 3bde. 、 *note textdomain(): 3bdf. 、 *note
bindtextdomain(): 3be0. 、および *note bind_textdomain_codeset(): 3be1.
からなります。これらは *note gettext: 59. モジュールの同名の関数に似てい
ますが、メッセージカタログとして C ライブラリのバイナリフォーマットを使
い、メッセージカタログを探すために C ライブラリのサーチアルゴリズムを使
います。

Python applications should normally find no need to invoke these
functions, and should use *note gettext: 59. instead.  A known exception
to this rule are applications that link with additional C libraries
which internally invoke C functions ‘gettext’ or ‘dcgettext’.  For these
applications, it may be necessary to bind the text domain, so that the
libraries can properly locate their message catalogs.


File: python.info,  Node: プログラムのフレームワーク,  Next: Tk を用いたグラフィカルユーザーインターフェース,  Prev: 国際化,  Up: Python 標準ライブラリ

5.24 プログラムのフレームワーク
===============================

この章で解説されるモジュールはあなたのプログラムの大枠を規定するフレーム
ワークです。現状では、ここで解説されるモジュールは全てコマンドラインイン
ターフェースを書くためのものです。

この章で解説されるモジュールの完全な一覧は:

* Menu:

* turtle: turtle --- タートルグラフィックス. タートルグラフィックス
* cmd: cmd --- 行指向のコマンドインタープリターのサポート. 行指向のコマンドインタープリターのサポート
* shlex: shlex --- 単純な字句解析. 単純な字句解析


File: python.info,  Node: turtle --- タートルグラフィックス,  Next: cmd --- 行指向のコマンドインタープリターのサポート,  Up: プログラムのフレームワーク

5.24.1 ‘turtle’ -- タートルグラフィックス
-----------------------------------------

'ソースコード:' Lib/turtle.py(1)

__________________________________________________________________

* Menu:

* はじめに: はじめに<9>.
* Get started::
* チュートリアル: チュートリアル<3>.
* How to...: How to.
* Turtle graphics reference::
* RawTurtle/Turtle のメソッドと対応する関数::
* TurtleScreen/Screen のメソッドと対応する関数::
* Public classes::
* 説明: 説明<2>.
* ヘルプと設定::
* turtledemo: turtledemo --- デモスクリプト. デモスクリプト
* python 2.6からの変更点: python 2 6からの変更点.
* python 3.0からの変更点: python 3 0からの変更点.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/turtle.py


File: python.info,  Node: はじめに<9>,  Next: Get started,  Up: turtle --- タートルグラフィックス

5.24.1.1 はじめに
.................

Turtle graphics is an implementation of the popular geometric drawing
tools introduced in Logo(1), developed by Wally Feurzeig, Seymour Papert
and Cynthia Solomon in 1967.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Turtle_(robot)


File: python.info,  Node: Get started,  Next: チュートリアル<3>,  Prev: はじめに<9>,  Up: turtle --- タートルグラフィックス

5.24.1.2 Get started
....................

x-y 平面の (0, 0) から動き出すロボット亀を想像してみて下さい。
‘turtle.forward(15)’ という命令を出すと、その亀が (スクリーン上で!)  15
ピクセル分顔を向けている方向に動き、動きに沿って線を引きます。
‘turtle.left(25)’ という命令を出すと、今度はその場で25度反時計回りに回り
ます。

Turtle star
...........

Turtle can draw intricate shapes using programs that repeat simple
moves.

[image src="python-figures/turtle-star.png"]


In Python, turtle graphics provides a representation of a physical
"turtle" (a little robot with a pen) that draws on a sheet of paper on
the floor.

It's an effective and well-proven way for learners to encounter
programming concepts and interaction with software, as it provides
instant, visible feedback.  It also provides convenient access to
graphical output in general.

Turtle drawing was originally created as an educational tool, to be used
by teachers in the classroom.  For the programmer who needs to produce
some graphical output it can be a way to do that without the overhead of
introducing more complex or external libraries into their work.


File: python.info,  Node: チュートリアル<3>,  Next: How to,  Prev: Get started,  Up: turtle --- タートルグラフィックス

5.24.1.3 チュートリアル
.......................

New users should start here.  In this tutorial we'll explore some of the
basics of turtle drawing.

* Menu:

* Starting a turtle environment::
* Basic drawing::
* Making algorithmic patterns::


File: python.info,  Node: Starting a turtle environment,  Next: Basic drawing,  Up: チュートリアル<3>

5.24.1.4 Starting a turtle environment
......................................

In a Python shell, import all the objects of the ‘turtle’ module:

     from turtle import *

If you run into a ‘No module named '_tkinter'’ error, you'll have to
install the *note Tk interface package: d9. on your system.


File: python.info,  Node: Basic drawing,  Next: Making algorithmic patterns,  Prev: Starting a turtle environment,  Up: チュートリアル<3>

5.24.1.5 Basic drawing
......................

Send the turtle forward 100 steps:

     forward(100)

You should see (most likely, in a new window on your display) a line
drawn by the turtle, heading East.  Change the direction of the turtle,
so that it turns 120 degrees left (anti-clockwise):

     left(120)

Let's continue by drawing a triangle:

     forward(100)
     left(120)
     forward(100)

Notice how the turtle, represented by an arrow, points in different
directions as you steer it.

Experiment with those commands, and also with ‘backward()’ and
‘right()’.

* Menu:

* Pen の制御::
* The turtle's position::


File: python.info,  Node: Pen の制御,  Next: The turtle's position,  Up: Basic drawing

5.24.1.6 Pen の制御
...................

Try changing the color - for example, ‘color('blue')’ - and width of the
line - for example, ‘width(3)’ - and then drawing again.

You can also move the turtle around without drawing, by lifting up the
pen: ‘up()’ before moving.  To start drawing again, use ‘down()’.


File: python.info,  Node: The turtle's position,  Prev: Pen の制御,  Up: Basic drawing

5.24.1.7 The turtle's position
..............................

Send your turtle back to its starting-point (useful if it has
disappeared off-screen):

     home()

The home position is at the center of the turtle's screen.  If you ever
need to know them, get the turtle's x-y coordinates with:

     pos()

Home is at ‘(0, 0)’.

And after a while, it will probably help to clear the window so we can
start anew:

     clearscreen()


File: python.info,  Node: Making algorithmic patterns,  Prev: Basic drawing,  Up: チュートリアル<3>

5.24.1.8 Making algorithmic patterns
....................................

Using loops, it's possible to build up geometric patterns:

     for steps in range(100):
         for c in ('blue', 'red', 'green'):
             color(c)
             forward(steps)
             right(30)

- which of course, are limited only by the imagination!

Let's draw the star shape at the top of this page.  We want red lines,
filled in with yellow:

     color('red')
     fillcolor('yellow')

Just as ‘up()’ and ‘down()’ determine whether lines will be drawn,
filling can be turned on and off:

     begin_fill()

Next we'll create a loop:

     while True:
         forward(200)
         left(170)
         if abs(pos()) < 1:
             break

‘abs(pos()) < 1’ is a good way to know when the turtle is back at its
home position.

Finally, complete the filling:

     end_fill()

(Note that filling only actually takes place when you give the
‘end_fill()’ command.)


File: python.info,  Node: How to,  Next: Turtle graphics reference,  Prev: チュートリアル<3>,  Up: turtle --- タートルグラフィックス

5.24.1.9 How to...
..................

This section covers some typical turtle use-cases and approaches.

* Menu:

* Get started as quickly as possible::
* Use the turtle module namespace::
* Use turtle graphics in a script::
* Use object-oriented turtle graphics::


File: python.info,  Node: Get started as quickly as possible,  Next: Use the turtle module namespace,  Up: How to

5.24.1.10 Get started as quickly as possible
............................................

One of the joys of turtle graphics is the immediate, visual feedback
that's available from simple commands - it's an excellent way to
introduce children to programming ideas, with a minimum of overhead (not
just children, of course).

The turtle module makes this possible by exposing all its basic
functionality as functions, available with ‘from turtle import *’.  The
*note turtle graphics tutorial: 3be9. covers this approach.

It's worth noting that many of the turtle commands also have even more
terse equivalents, such as ‘fd()’ for *note forward(): 3bf3.  These are
especially useful when working with learners for whom typing is not a
skill.

     You'll need to have the *note Tk interface package: d9. installed
     on your system for turtle graphics to work.  Be warned that this is
     not always straightforward, so check this in advance if you're
     planning to use turtle graphics with a learner.


File: python.info,  Node: Use the turtle module namespace,  Next: Use turtle graphics in a script,  Prev: Get started as quickly as possible,  Up: How to

5.24.1.11 Use the ‘turtle’ module namespace
...........................................

Using ‘from turtle import *’ is convenient - but be warned that it
imports a rather large collection of objects, and if you're doing
anything but turtle graphics you run the risk of a name conflict (this
becomes even more an issue if you're using turtle graphics in a script
where other modules might be imported).

The solution is to use ‘import turtle’ - ‘fd()’ becomes ‘turtle.fd()’,
‘width()’ becomes ‘turtle.width()’ and so on.  (If typing "turtle" over
and over again becomes tedious, use for example ‘import turtle as t’
instead.)


File: python.info,  Node: Use turtle graphics in a script,  Next: Use object-oriented turtle graphics,  Prev: Use the turtle module namespace,  Up: How to

5.24.1.12 Use turtle graphics in a script
.........................................

It's recommended to use the ‘turtle’ module namespace as described
immediately above, for example:

     import turtle as t
     from random import random

     for i in range(100):
         steps = int(random() * 100)
         angle = int(random() * 360)
         t.right(angle)
         t.fd(steps)

Another step is also required though - as soon as the script ends,
Python will also close the turtle's window.  Add:

     t.mainloop()

to the end of the script.  The script will now wait to be dismissed and
will not exit until it is terminated, for example by closing the turtle
graphics window.


File: python.info,  Node: Use object-oriented turtle graphics,  Prev: Use turtle graphics in a script,  Up: How to

5.24.1.13 Use object-oriented turtle graphics
.............................................

参考
....

*note Explanation of the object-oriented interface: 3bf8.

Other than for very basic introductory purposes, or for trying things
out as quickly as possible, it's more usual and much more powerful to
use the object-oriented approach to turtle graphics.  For example, this
allows multiple turtles on screen at once.

In this approach, the various turtle commands are methods of objects
(mostly of ‘Turtle’ objects).  You 'can' use the object-oriented
approach in the shell, but it would be more typical in a Python script.

The example above then becomes:

     from turtle import Turtle
     from random import random

     t = Turtle()
     for i in range(100):
         steps = int(random() * 100)
         angle = int(random() * 360)
         t.right(angle)
         t.fd(steps)

     t.screen.mainloop()

Note the last line.  ‘t.screen’ is an instance of the *note Screen:
3bf9. that a Turtle instance exists on; it's created automatically along
with the turtle.

The turtle's screen can be customised, for example:

     t.screen.title('Object-oriented turtle demo')
     t.screen.bgcolor("orange")


File: python.info,  Node: Turtle graphics reference,  Next: RawTurtle/Turtle のメソッドと対応する関数,  Prev: How to,  Up: turtle --- タートルグラフィックス

5.24.1.14 Turtle graphics reference
...................................

     注釈: 以下の文書では関数に対する引数リストが与えられています。メソ
     ッドでは、勿論、ここでは省略されている 'self' が第一引数になります
     。

* Menu:

* Turtle のメソッド::
* TurtleScreen/Screen のメソッド::


File: python.info,  Node: Turtle のメソッド,  Next: TurtleScreen/Screen のメソッド,  Up: Turtle graphics reference

5.24.1.15 Turtle のメソッド
...........................

Turtle の動き

     移動および描画

               *note forward(): 3bf3. | *note fd(): 3bfc.
               *note backward(): 3bfd. | *note bk(): 3bfe. | *note back(): 3bff.
               *note right(): 3c00. | *note rt(): 3c01.
               *note left(): 3c02. | *note lt(): 3c03.
               *note goto(): 3c04. | *note setpos(): 3c05. | *note setposition(): 3c06.
               *note teleport(): 168d.
               *note setx(): 3c07.
               *note sety(): 3c08.
               *note setheading(): 3c09. | *note seth(): 3c0a.
               *note home(): 3c0b.
               *note circle(): 3c0c.
               *note dot(): 3c0d.
               *note stamp(): 3c0e.
               *note clearstamp(): 3c0f.
               *note clearstamps(): 3c10.
               *note undo(): 3c11.
               *note speed(): 3c12.

     Turtle の状態を知る

               *note position(): 3c13. | *note pos(): 3c14.
               *note towards(): 3c15.
               *note xcor(): 3c16.
               *note ycor(): 3c17.
               *note heading(): 3c18.
               *note distance(): 3c19.

     設定と計測

               *note degrees(): 3c1a.
               *note radians(): 3c1b.

Pen の制御

     描画状態

               *note pendown(): 3c1c. | *note pd(): 3c1d. | *note down(): 3c1e.
               *note penup(): 3c1f. | *note pu(): 3c20. | *note up(): 3c21.
               *note pensize(): 3c22. | *note width(): 3c23.
               *note pen(): 3c24.
               *note isdown(): 3c25.

     色の制御

               *note color(): 3c26.
               *note pencolor(): 3c27.
               *note fillcolor(): 3c28.

     塗りつぶし

               *note filling(): 3c29.
               *note begin_fill(): 3c2a.
               *note end_fill(): 3c2b.

     さらなる描画の制御

               *note reset(): 3c2c.
               *note clear(): 3c2d.
               *note write(): 3c2e.

タートルの状態

     可視性

               *note showturtle(): 3c2f. | *note st(): 3c30.
               *note hideturtle(): 3c31. | *note ht(): 3c32.
               *note isvisible(): 3c33.

     見た目

               *note shape(): 3c34.
               *note resizemode(): 3c35.
               *note shapesize(): 3c36. | *note turtlesize(): 3c37.
               *note shearfactor(): 3c38.
               *note tiltangle(): 6f0.
               *note tilt(): 3c39.
               *note shapetransform(): 3c3a.
               *note get_shapepoly(): 3c3b.

イベントを利用する

          *note onclick(): 3c3c.
          *note onrelease(): 3c3d.
          *note ondrag(): 3c3e.

特別な Turtle のメソッド

          *note begin_poly(): 3c3f.
          *note end_poly(): 3c40.
          *note get_poly(): 3c41.
          *note clone(): 3c42.
          *note getturtle(): 3c43. | *note getpen(): 3c44.
          *note getscreen(): 3c45.
          *note setundobuffer(): 3c46.
          *note undobufferentries(): 3c47.


File: python.info,  Node: TurtleScreen/Screen のメソッド,  Prev: Turtle のメソッド,  Up: Turtle graphics reference

5.24.1.16 TurtleScreen/Screen のメソッド
........................................

ウィンドウの制御

          *note bgcolor(): 3c49.
          *note bgpic(): 3c4a.
          *note clearscreen(): 3c4b.
          *note resetscreen(): 3c4c.
          *note screensize(): 3c4d.
          *note setworldcoordinates(): 3c4e.

アニメーションの制御

          *note delay(): 3c4f.
          *note tracer(): 3c50.
          *note update(): 3c51.

スクリーンイベントを利用する

          *note listen(): 3c52.
          *note onkey(): 3c53. | *note onkeyrelease(): 3c54.
          *note onkeypress(): 3c55.
          *note onclick(): 3c3c. | *note onscreenclick(): 3c56.
          *note ontimer(): 3c57.
          *note mainloop(): 3c58. | *note done(): 3c59.

設定と特殊なメソッド

          *note mode(): 3c5a.
          *note colormode(): 3c5b.
          *note getcanvas(): 3c5c.
          *note getshapes(): 3c5d.
          *note register_shape(): 3c5e. | *note addshape(): 3c5f.
          *note turtles(): 3c60.
          *note window_height(): 3c61.
          *note window_width(): 3c62.

入力メソッド

          *note textinput(): 182d.
          *note numinput(): 182e.

Screen 独自のメソッド

          *note bye(): 3c63.
          *note exitonclick(): 3c64.
          *note setup(): 3c65.
          *note title(): 3c66.


File: python.info,  Node: RawTurtle/Turtle のメソッドと対応する関数,  Next: TurtleScreen/Screen のメソッドと対応する関数,  Prev: Turtle graphics reference,  Up: turtle --- タートルグラフィックス

5.24.1.17 RawTurtle/Turtle のメソッドと対応する関数
...................................................

この節のほとんどの例では ‘turtle’ という名前の Turtle インスタンスを使い
ます。

* Menu:

* Turtle の動き::
* Turtle の状態を知る::
* 設定と計測::
* Pen の制御: Pen の制御<2>.
* タートルの状態::
* イベントを利用する::
* 特別な Turtle のメソッド::
* Compound shapes::


File: python.info,  Node: Turtle の動き,  Next: Turtle の状態を知る,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.18 Turtle の動き
.......................

 -- の関数: turtle.forward (distance)
 -- の関数: turtle.fd (distance)


     パラメータ: ‘distance’ - 数 (整数または浮動小数点数)

     タートルが頭を向けている方へ、タートルを距離 'distance' だけ前進さ
     せます。

          >>> turtle.position()
          (0.00,0.00)
          >>> turtle.forward(25)
          >>> turtle.position()
          (25.00,0.00)
          >>> turtle.forward(-75)
          >>> turtle.position()
          (-50.00,0.00)

 -- の関数: turtle.back (distance)
 -- の関数: turtle.bk (distance)
 -- の関数: turtle.backward (distance)


     パラメータ: ‘distance’ - 数

     タートルが頭を向けている方と反対方向へ、タートルを距離 'distance' だ
     け後退させます。 タートルの向きは変えません。

          >>> turtle.position()
          (0.00,0.00)
          >>> turtle.backward(30)
          >>> turtle.position()
          (-30.00,0.00)

 -- の関数: turtle.right (angle)
 -- の関数: turtle.rt (angle)


     パラメータ: ‘angle’ - 数 (整数または浮動小数点数)

     タートルを 'angle' 単位だけ右に回します。 (単位のデフォルトは度です
     が、 *note degrees(): 3c1a. と *note radians(): 3c1b. 関数を使って
     設定できます。) 角度の向きはタートルのモードによって意味が変わりま
     す。 *note mode(): 3c5a. を参照してください。

          >>> turtle.heading()
          22.0
          >>> turtle.right(45)
          >>> turtle.heading()
          337.0

 -- の関数: turtle.left (angle)
 -- の関数: turtle.lt (angle)


     パラメータ: ‘angle’ - 数 (整数または浮動小数点数)

     タートルを 'angle' 単位だけ左に回します。 (単位のデフォルトは度です
     が、 *note degrees(): 3c1a. と *note radians(): 3c1b. 関数を使って
     設定できます。) 角度の向きはタートルのモードによって意味が変わりま
     す。 *note mode(): 3c5a. を参照してください。

          >>> turtle.heading()
          22.0
          >>> turtle.left(45)
          >>> turtle.heading()
          67.0

 -- の関数: turtle.goto (x, y=None)
 -- の関数: turtle.setpos (x, y=None)
 -- の関数: turtle.setposition (x, y=None)


     パラメータ:

        * ‘x’ - 数または数のペア/ベクトル

        * ‘y’ - 数または ‘None’

     'y' が ‘None’ の場合、 'x' は座標のペアかまたは *note Vec2D: 3c69.
     (たとえば *note pos(): 3c14. で返されます) でなければなりません。

     タートルを指定された絶対位置に移動します。ペンが下りていれば線を引
     きます。タートルの向きは変わりません。

          >>> tp = turtle.pos()
          >>> tp
          (0.00,0.00)
          >>> turtle.setpos(60,30)
          >>> turtle.pos()
          (60.00,30.00)
          >>> turtle.setpos((20,80))
          >>> turtle.pos()
          (20.00,80.00)
          >>> turtle.setpos(tp)
          >>> turtle.pos()
          (0.00,0.00)

 -- の関数: turtle.teleport (x, y=None, *, fill_gap=False)


     パラメータ:

        * ‘x’ - 数または ‘None’

        * ‘y’ - 数または ‘None’

        * ‘fill_gap’ - ブール値

     Move turtle to an absolute position.  Unlike goto(x, y), a line
     will not be drawn.  The turtle's orientation does not change.  If
     currently filling, the polygon(s) teleported from will be filled
     after leaving, and filling will begin again after teleporting.
     This can be disabled with fill_gap=True, which makes the imaginary
     line traveled during teleporting act as a fill barrier like in
     goto(x, y).

          >>> tp = turtle.pos()
          >>> tp
          (0.00,0.00)
          >>> turtle.teleport(60)
          >>> turtle.pos()
          (60.00,0.00)
          >>> turtle.teleport(y=10)
          >>> turtle.pos()
          (60.00,10.00)
          >>> turtle.teleport(20, 30)
          >>> turtle.pos()
          (20.00,30.00)

     Added in version 3.12.

 -- の関数: turtle.setx (x)


     パラメータ: ‘x’ - 数 (整数または浮動小数点数)

     タートルの第一座標を 'x' にします。第二座標は変わりません。

          >>> turtle.position()
          (0.00,240.00)
          >>> turtle.setx(10)
          >>> turtle.position()
          (10.00,240.00)

 -- の関数: turtle.sety (y)


     パラメータ: ‘y’ - 数 (整数または浮動小数点数)

     タートルの第二座標を 'y' にします。第一座標は変わりません。

          >>> turtle.position()
          (0.00,40.00)
          >>> turtle.sety(-10)
          >>> turtle.position()
          (0.00,-10.00)

 -- の関数: turtle.setheading (to_angle)
 -- の関数: turtle.seth (to_angle)


     パラメータ: ‘to_angle’ - 数 (整数または浮動小数点数)

     タートルの向きを 'to_angle' に設定します。以下はよく使われる方向を
     度で表わしたものです:

     標準モード              logo モード
                             
     -------------------------------------------------
                             
     0 - 東                  0 - 北
                             
                             
     90 - 北                 90 - 東
                             
                             
     180 - 西                180 - 南
                             
                             
     270 - 南                270 - 西
                             

          >>> turtle.setheading(90)
          >>> turtle.heading()
          90.0

 -- の関数: turtle.home ()

     タートルを原点 - 座標 (0, 0) - に移動し、向きを開始方向に設定します
     (開始方向はモードに依って違います。 *note mode(): 3c5a. を参照して
     ください)。

          >>> turtle.heading()
          90.0
          >>> turtle.position()
          (0.00,-10.00)
          >>> turtle.home()
          >>> turtle.position()
          (0.00,0.00)
          >>> turtle.heading()
          0.0

 -- の関数: turtle.circle (radius, extent=None, steps=None)


     パラメータ:

        * ‘radius’ - 数

        * ‘extent’ - 数 (または ‘None’)

        * ‘steps’ - 整数 (または ‘None’)

     半径 'radius' の円を描きます。中心はタートルの左 'radius' ユニット
     の点です。 'extent' - 角度です - は円のどの部分を描くかを決定します
     。 'extent' が与えられなければ、デフォルトで完全な円になります。
     'extent' が完全な円でない場合は、弧の一つの端点は、現在のペンの位置
     です。 'radius' が正の場合、弧は反時計回りに描かれます。そうでなけ
     れば、時計回りです。最後にタートルの向きが 'extent' 分だけ変わりま
     す。

     円は内接する正多角形で近似されます。 'steps' でそのために使うステッ
     プ数を決定します。この値は与えられなければ自動的に計算されます。ま
     た、これを正多角形の描画に利用することもできます。

          >>> turtle.home()
          >>> turtle.position()
          (0.00,0.00)
          >>> turtle.heading()
          0.0
          >>> turtle.circle(50)
          >>> turtle.position()
          (-0.00,0.00)
          >>> turtle.heading()
          0.0
          >>> turtle.circle(120, 180)  # draw a semicircle
          >>> turtle.position()
          (0.00,240.00)
          >>> turtle.heading()
          180.0

 -- の関数: turtle.dot (size=None, *color)


     パラメータ:

        * ‘size’ - 1 以上の整数 (与えられる場合には)

        * ‘color’ - 色を表わす文字列またはタプル

     直径 'size' の丸い点を 'color' で指定された色で描きます。 'size' が
     与えられなかった場合、pensize+4 と 2*pensize の大きい方が使われます
     。

          >>> turtle.home()
          >>> turtle.dot()
          >>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
          >>> turtle.position()
          (100.00,-0.00)
          >>> turtle.heading()
          0.0

 -- の関数: turtle.stamp ()

     キャンバス上の現在タートルがいる位置にタートルの姿のハンコを押しま
     す。そのハンコに対して stamp_id が返されますが、これを使うと後で
     ‘clearstamp(stamp_id)’ のように呼び出して消すことができます。

          >>> turtle.color("blue")
          >>> stamp_id = turtle.stamp()
          >>> turtle.fd(50)

 -- の関数: turtle.clearstamp (stampid)


     パラメータ: ‘stampid’ - 整数で、先立つ *note stamp(): 3c0e. 呼出し
     で返された値でなければなりません

     'stampid' に対応するハンコを消します。

          >>> turtle.position()
          (150.00,-0.00)
          >>> turtle.color("blue")
          >>> astamp = turtle.stamp()
          >>> turtle.fd(50)
          >>> turtle.position()
          (200.00,-0.00)
          >>> turtle.clearstamp(astamp)
          >>> turtle.position()
          (200.00,-0.00)

 -- の関数: turtle.clearstamps (n=None)


     パラメータ: ‘n’ - 整数 (または ‘None’)

     全ての、または最初の/最後の 'n' 個のハンコを消します。 'n' が
     ‘None’ の場合、全てのハンコを消します。 'n' が正の場合には最初の
     'n' 個、 'n' が負の場合には最後の 'n' 個を消します。

          >>> for i in range(8):
          ...     unused_stamp_id = turtle.stamp()
          ...     turtle.fd(30)
          >>> turtle.clearstamps(2)
          >>> turtle.clearstamps(-2)
          >>> turtle.clearstamps()

 -- の関数: turtle.undo ()

     最後の(繰り返すことにより複数の)タートルの動きを取り消します。取り
     消しできる動きの最大数は undobuffer のサイズによって決まります。

          >>> for i in range(4):
          ...     turtle.fd(50); turtle.lt(80)
          ...
          >>> for i in range(8):
          ...     turtle.undo()

 -- の関数: turtle.speed (speed=None)


     パラメータ: ‘speed’ - 0 から 10 までの整数またはスピードを表わす文
     字列(以下の説明を参照)

     タートルのスピードを 0 から 10 までの範囲の整数に設定します。引数が
     与えられない場合は現在のスピードを返します。

     与えられた数字が 10 より大きかったり 0.5 より小さかったりした場合は
     、スピードは 0 になります。スピードを表わす文字列は次のように数字に
     変換されます:

        * "fastest": 0

        * "fast": 10

        * "normal": 6

        * "slow": 3

        * "slowest": 1

     1 から 10 までのスピードを上げていくにつれて線を描いたりタートルが
     回ったりするアニメーションがだんだん速くなります。

     注意: 'speed' = 0 はアニメーションを無くします。forward/backward で
     はタートルがジャンプし、left/right では瞬時に方向を変えます。

          >>> turtle.speed()
          3
          >>> turtle.speed('normal')
          >>> turtle.speed()
          6
          >>> turtle.speed(9)
          >>> turtle.speed()
          9


File: python.info,  Node: Turtle の状態を知る,  Next: 設定と計測,  Prev: Turtle の動き,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.19 Turtle の状態を知る
.............................

 -- の関数: turtle.position ()
 -- の関数: turtle.pos ()

     タートルの現在位置を (*note Vec2D: 3c69. のベクトルとして) 返します
     。

          >>> turtle.pos()
          (440.00,-0.00)

 -- の関数: turtle.towards (x, y=None)


     パラメータ:

        * ‘x’ - 数または数のペア/ベクトルまたはタートルのインスタンス

        * ‘y’ - 'x' が数ならば数、そうでなければ ‘None’

     タートルの位置から指定された (x,y) への直線の角度を返します。この値
     はタートルの開始方向にそして開始方向はモード ("standard"/"world" ま
     たは "logo") に依存します。

          >>> turtle.goto(10, 10)
          >>> turtle.towards(0,0)
          225.0

 -- の関数: turtle.xcor ()

     タートルの x 座標を返します。

          >>> turtle.home()
          >>> turtle.left(50)
          >>> turtle.forward(100)
          >>> turtle.pos()
          (64.28,76.60)
          >>> print(round(turtle.xcor(), 5))
          64.27876

 -- の関数: turtle.ycor ()

     タートルの y 座標を返します。

          >>> turtle.home()
          >>> turtle.left(60)
          >>> turtle.forward(100)
          >>> print(turtle.pos())
          (50.00,86.60)
          >>> print(round(turtle.ycor(), 5))
          86.60254

 -- の関数: turtle.heading ()

     タートルの現在の向きを返します (返される値はタートルのモードに依存
     します。 *note mode(): 3c5a. を参照してください)。

          >>> turtle.home()
          >>> turtle.left(67)
          >>> turtle.heading()
          67.0

 -- の関数: turtle.distance (x, y=None)


     パラメータ:

        * ‘x’ - 数または数のペア/ベクトルまたはタートルのインスタンス

        * ‘y’ - 'x' が数ならば数、そうでなければ ‘None’

     タートルから与えられた (x,y) あるいはベクトルあるいは渡されたタート
     ルへの距離を、タートルのステップを単位として測った値を返します。

          >>> turtle.home()
          >>> turtle.distance(30,40)
          50.0
          >>> turtle.distance((30,40))
          50.0
          >>> joe = Turtle()
          >>> joe.forward(77)
          >>> turtle.distance(joe)
          77.0


File: python.info,  Node: 設定と計測,  Next: Pen の制御<2>,  Prev: Turtle の状態を知る,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.20 設定と計測
....................

 -- の関数: turtle.degrees (fullcircle=360.0)


     パラメータ: ‘fullcircle’ - 数

     角度を計る単位「度」を、円周を何等分するかという値に指定します。デ
     フォルトは360等分で通常の意味での度です。

          >>> turtle.home()
          >>> turtle.left(90)
          >>> turtle.heading()
          90.0

          Change angle measurement unit to grad (also known as gon,
          grade, or gradian and equals 1/100-th of the right angle.)
          >>> turtle.degrees(400.0)
          >>> turtle.heading()
          100.0
          >>> turtle.degrees(360)
          >>> turtle.heading()
          90.0

 -- の関数: turtle.radians ()

     角度を計る単位をラジアンにします。 ‘degrees(2*math.pi)’ と同じ意味
     です。

          >>> turtle.home()
          >>> turtle.left(90)
          >>> turtle.heading()
          90.0
          >>> turtle.radians()
          >>> turtle.heading()
          1.5707963267948966


File: python.info,  Node: Pen の制御<2>,  Next: タートルの状態,  Prev: 設定と計測,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.21 Pen の制御
....................

* Menu:

* 描画状態::
* 色の制御: 色の制御<2>.
* 塗りつぶし::
* さらなる描画の制御::


File: python.info,  Node: 描画状態,  Next: 色の制御<2>,  Up: Pen の制御<2>

5.24.1.22 描画状態
..................

 -- の関数: turtle.pendown ()
 -- の関数: turtle.pd ()
 -- の関数: turtle.down ()

     ペンを下ろします - 動くと線が引かれます。

 -- の関数: turtle.penup ()
 -- の関数: turtle.pu ()
 -- の関数: turtle.up ()

     ペンを上げます - 動いても線は引かれません。

 -- の関数: turtle.pensize (width=None)
 -- の関数: turtle.width (width=None)


     パラメータ: ‘width’ - 正の数

     線の太さを 'width' にするか、または現在の太さを返します。resizemode
     が "auto" でタートルの形が多角形の場合、その多角形も同じ太さで描画
     されます。引数が渡されなければ、現在の pensize が返されます。

          >>> turtle.pensize()
          1
          >>> turtle.pensize(10)   # from here on lines of width 10 are drawn

 -- の関数: turtle.pen (pen=None, **pendict)


     パラメータ:

        * ‘pen’ - 以下にリストされたキーをもった辞書

        * ‘pendict’ - 以下にリストされたキーをキーワードとするキーワード
          引数

     ペンの属性を "pen-dictionary" に以下のキー/値ペアで設定するかまたは
     返します:

        * "shown": True/False

        * "pendown": True/False

        * "pencolor": 色文字列または色タプル

        * "fillcolor": 色文字列または色タプル

        * "pensize": 正の数

        * "speed": 0 から 10 までの整数

        * "resizemode": "auto" または "user" または "noresize"

        * "stretchfactor": (正の数, 正の数)

        * "outline": 正の数

        * "tilt": 数

     この辞書を以降の *note pen(): 3c24. 呼出しに渡して以前のペンの状態
     に復旧することができます。さらに一つ以上の属性をキーワード引数とし
     て渡すこともできます。一つの文で幾つものペンの属性を設定するのに使
     えます。

          >>> turtle.pen(fillcolor="black", pencolor="red", pensize=10)
          >>> sorted(turtle.pen().items())
          [('fillcolor', 'black'), ('outline', 1), ('pencolor', 'red'),
           ('pendown', True), ('pensize', 10), ('resizemode', 'noresize'),
           ('shearfactor', 0.0), ('shown', True), ('speed', 9),
           ('stretchfactor', (1.0, 1.0)), ('tilt', 0.0)]
          >>> penstate=turtle.pen()
          >>> turtle.color("yellow", "")
          >>> turtle.penup()
          >>> sorted(turtle.pen().items())[:3]
          [('fillcolor', ''), ('outline', 1), ('pencolor', 'yellow')]
          >>> turtle.pen(penstate, fillcolor="green")
          >>> sorted(turtle.pen().items())[:3]
          [('fillcolor', 'green'), ('outline', 1), ('pencolor', 'red')]

 -- の関数: turtle.isdown ()

     もしペンが下りていれば ‘True’ を、上がっていれば ‘False’ を返します
     。

          >>> turtle.penup()
          >>> turtle.isdown()
          False
          >>> turtle.pendown()
          >>> turtle.isdown()
          True


File: python.info,  Node: 色の制御<2>,  Next: 塗りつぶし,  Prev: 描画状態,  Up: Pen の制御<2>

5.24.1.23 色の制御
..................

 -- の関数: turtle.pencolor (*args)

     ペンの色(pencolor)を設定するかまたは返します。

     4種類の入力形式が受け入れ可能です:

     ‘pencolor()’

          現在のペンの色を色指定文字列またはタプルで返します (例を見て下
          さい)。次の color/pencolor/fillcolor の呼び出しへの入力に使う
          こともあるでしょう。

     ‘pencolor(colorstring)’

          ペンの色を 'colorstring' に設定します。その値は Tk の色指定文
          字列で、 ‘"red"’, ‘"yellow"’, ‘"#33cc8c"’ のような文字列です。

     ‘pencolor((r, g, b))’

          ペンの色を 'r', 'g', 'b' のタプルで表された RGB の色に設定しま
          す。各 'r', 'g', 'b' は 0 から colormode の間の値でなければな
          りません。ここで colormode は 1.0 か 255 のどちらかです (*note
          colormode(): 3c5b. を参照)。

     ‘pencolor(r, g, b)’

          ペンの色を 'r', 'g', 'b' で表された RGB の色に設定します。各
          'r', 'g', 'b' は 0 から colormode の間の値でなければなりません
          。

     タートルの形(turtleshape)が多角形の場合、多角形の外側が新しく設定さ
     れた色で描かれます。

          >>> colormode()
          1.0
          >>> turtle.pencolor()
          'red'
          >>> turtle.pencolor("brown")
          >>> turtle.pencolor()
          'brown'
          >>> tup = (0.2, 0.8, 0.55)
          >>> turtle.pencolor(tup)
          >>> turtle.pencolor()
          (0.2, 0.8, 0.5490196078431373)
          >>> colormode(255)
          >>> turtle.pencolor()
          (51.0, 204.0, 140.0)
          >>> turtle.pencolor('#32c18f')
          >>> turtle.pencolor()
          (50.0, 193.0, 143.0)

 -- の関数: turtle.fillcolor (*args)

     塗りつぶしの色(fillcolor)を設定するかまたは返します。

     4種類の入力形式が受け入れ可能です:

     ‘fillcolor()’

          現在の塗りつぶしの色を色指定文字列またはタプルで返します (例を
          見て下さい)。次の color/pencolor/fillcolor の呼び出しへの入力
          に使うこともあるでしょう。

     ‘fillcolor(colorstring)’

          塗りつぶしの色を 'colorstring' に設定します。その値は Tk の色
          指定文字列で、 ‘"red"’, ‘"yellow"’, ‘"#33cc8c"’ のような文字列
          です。

     ‘fillcolor((r, g, b))’

          塗りつぶしの色を 'r', 'g', 'b' のタプルで表された RGB の色に設
          定します。各 'r', 'g', 'b' は 0 から colormode の間の値でなけ
          ればなりません。ここで colormode は 1.0 か 255 のどちらかです
          (*note colormode(): 3c5b. を参照)。

     ‘fillcolor(r, g, b)’

          塗りつぶしの色を 'r', 'g', 'b' で表された RGB の色に設定します
          。各 'r', 'g', 'b' は 0 から colormode の間の値でなければなり
          ません。

     タートルの形(turtleshape)が多角形の場合、多角形の内側が新しく設定さ
     れた色で描かれます。

          >>> turtle.fillcolor("violet")
          >>> turtle.fillcolor()
          'violet'
          >>> turtle.pencolor()
          (50.0, 193.0, 143.0)
          >>> turtle.fillcolor((50, 193, 143))  # Integers, not floats
          >>> turtle.fillcolor()
          (50.0, 193.0, 143.0)
          >>> turtle.fillcolor('#ffffff')
          >>> turtle.fillcolor()
          (255.0, 255.0, 255.0)

 -- の関数: turtle.color (*args)

     ペンの色(pencolor)と塗りつぶしの色(fillcolor)を設定するかまたは返し
     ます。

     いくつかの入力形式が受け入れ可能です。形式ごとに 0 から 3 個の引数
     を以下のように使います:

     ‘color()’

          現在のペンの色と塗りつぶしの色を *note pencolor(): 3c27. およ
          び *note fillcolor(): 3c28. で返される色指定文字列またはタプル
          のペアで返します。

     ‘color(colorstring)’, ‘color((r,g,b))’, ‘color(r,g,b)’

          *note pencolor(): 3c27. の入力と同じですが、塗りつぶしの色とペ
          ンの色、両方を与えられた値に設定します。

     ‘color(colorstring1, colorstring2)’, ‘color((r1,g1,b1), (r2,g2,b2))’

          ‘pencolor(colorstring1)’ および ‘fillcolor(colorstring2)’ を呼
          び出すのと等価です。もう一つの入力形式についても同様です。

     タートルの形(turtleshape)が多角形の場合、多角形の内側も外側も新しく
     設定された色で描かれます。

          >>> turtle.color("red", "green")
          >>> turtle.color()
          ('red', 'green')
          >>> color("#285078", "#a0c8f0")
          >>> color()
          ((40.0, 80.0, 120.0), (160.0, 200.0, 240.0))

こちらも参照: スクリーンのメソッド *note colormode(): 3c5b. 。


File: python.info,  Node: 塗りつぶし,  Next: さらなる描画の制御,  Prev: 色の制御<2>,  Up: Pen の制御<2>

5.24.1.24 塗りつぶし
....................

 -- の関数: turtle.filling ()

     Return fillstate (‘True’ if filling, ‘False’ else).

          >>> turtle.begin_fill()
          >>> if turtle.filling():
          ...    turtle.pensize(5)
          ... else:
          ...    turtle.pensize(3)

 -- の関数: turtle.begin_fill ()

     To be called just before drawing a shape to be filled.

 -- の関数: turtle.end_fill ()

     最後に呼び出された *note begin_fill(): 3c2a. の後に描かれた図形を塗
     りつぶします。

     Whether or not overlap regions for self-intersecting polygons or
     multiple shapes are filled depends on the operating system
     graphics, type of overlap, and number of overlaps.  For example,
     the Turtle star above may be either all yellow or have some white
     regions.

          >>> turtle.color("black", "red")
          >>> turtle.begin_fill()
          >>> turtle.circle(80)
          >>> turtle.end_fill()


File: python.info,  Node: さらなる描画の制御,  Prev: 塗りつぶし,  Up: Pen の制御<2>

5.24.1.25 さらなる描画の制御
............................

 -- の関数: turtle.reset ()

     タートルの描いたものをスクリーンから消し、タートルを中心に戻して、
     全ての変数をデフォルト値に設定し直します。

          >>> turtle.goto(0,-22)
          >>> turtle.left(100)
          >>> turtle.position()
          (0.00,-22.00)
          >>> turtle.heading()
          100.0
          >>> turtle.reset()
          >>> turtle.position()
          (0.00,0.00)
          >>> turtle.heading()
          0.0

 -- の関数: turtle.clear ()

     タートルの描いたものをスクリーンから消します。タートルは動かしませ
     ん。タートルの状態と位置、それに他のタートルたちの描いたものは影響
     を受けません。

 -- の関数: turtle.write (arg, move=False, align='left', font=('Arial',
          8, 'normal'))


     パラメータ:

        * ‘arg’ - TurtleScreen に書かれるオブジェクト

        * ‘move’ - True/False

        * ‘align’ - 文字列 "left", "center", right" のどれか

        * ‘font’ - 三つ組み (fontname, fontsize, fonttype)

     文字を書きます— 'arg' の文字列表現を、現在のタートルの位置に、
     'align' ("left", "center", "right" のどれか) に従って、 与えられた
     フォントで。 もし 'move' が真ならば、ペンは書いた文の右下隅に移動し
     ます。 デフォルトでは、 'move' は ‘False’ です。

          >>> turtle.write("Home = ", True, align="center")
          >>> turtle.write((0,0), True)


File: python.info,  Node: タートルの状態,  Next: イベントを利用する,  Prev: Pen の制御<2>,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.26 タートルの状態
........................

* Menu:

* 可視性::
* 見た目::


File: python.info,  Node: 可視性,  Next: 見た目,  Up: タートルの状態

5.24.1.27 可視性
................

 -- の関数: turtle.hideturtle ()
 -- の関数: turtle.ht ()

     タートルを見えなくします。 複雑な図を描いている途中、タートルが見え
     ないようにするのは良い考えです。 というのもタートルを隠すことで描画
     が目に見えて速くなるからです。

          >>> turtle.hideturtle()

 -- の関数: turtle.showturtle ()
 -- の関数: turtle.st ()

     タートルが見えるようにします。

          >>> turtle.showturtle()

 -- の関数: turtle.isvisible ()

     タートルが見えている状態ならば ‘True’ を、隠されていれば ‘False’ を
     返します。

          >>> turtle.hideturtle()
          >>> turtle.isvisible()
          False
          >>> turtle.showturtle()
          >>> turtle.isvisible()
          True


File: python.info,  Node: 見た目,  Prev: 可視性,  Up: タートルの状態

5.24.1.28 見た目
................

 -- の関数: turtle.shape (name=None)


     パラメータ: ‘name’ - 形の名前(shapename)として正しい文字列

     タートルの形を与えられた名前('name')の形に設定するか、もしくは名前
     が与えられなければ現在の形の名前を返します。 'name' という名前の形
     は TurtleScreen の形の辞書に載っていなければなりません。最初は次の
     多角形が載っています: "arrow", "turtle", "circle", "square",
     "triangle", "classic"。形についての扱いを学ぶには Screen のメソッド
     *note register_shape(): 3c5e. を参照して下さい。

          >>> turtle.shape()
          'classic'
          >>> turtle.shape("turtle")
          >>> turtle.shape()
          'turtle'

 -- の関数: turtle.resizemode (rmode=None)


     パラメータ: ‘rmode’ - 文字列 "auto", "user", "noresize" のどれか

     サイズ変更のモード(resizemode)を "auto", "user", "noresize" のどれ
     かに設定します。もし 'rmode' が与えられなければ、現在のサイズ変更モ
     ードを返します。それぞれのサイズ変更モードは以下の効果を持ちます:

        - "auto": ペンのサイズに対応してタートルの見た目を調整します。

        - "user": 伸長係数(stretchfactor)およびアウトライン幅
          (outlinewidth)の値に対応してタートルの見た目を調整します。これ
          らの値は *note shapesize(): 3c36. で設定します。

        - "noresize": タートルの見た目を調整しません。

     ‘resizemode("user")’ は *note shapesize(): 3c36. に引数を渡したとき
     に呼び出されます。

          >>> turtle.resizemode()
          'noresize'
          >>> turtle.resizemode("auto")
          >>> turtle.resizemode()
          'auto'

 -- の関数: turtle.shapesize (stretch_wid=None, stretch_len=None,
          outline=None)
 -- の関数: turtle.turtlesize (stretch_wid=None, stretch_len=None,
          outline=None)


     パラメータ:

        * ‘stretch_wid’ - 正の数

        * ‘stretch_len’ - 正の数

        * ‘outline’ - 正の数

     ペンの属性 x/y-伸長係数および/またはアウトラインを返すかまたは設定
     します。サイズ変更のモードは "user" に設定されます。サイズ変更のモ
     ードが "user" に設定されたときかつそのときに限り、タートルは伸長係
     数(stretchfactor)に従って伸長されて表示されます。 'stretch_wid' は
     進行方向に直交する向きの伸長係数で、 'stretch_len' は進行方向に沿っ
     たの伸長係数、 'outline' は形のアウトラインの幅を決めるものです。

          >>> turtle.shapesize()
          (1.0, 1.0, 1)
          >>> turtle.resizemode("user")
          >>> turtle.shapesize(5, 5, 12)
          >>> turtle.shapesize()
          (5, 5, 12)
          >>> turtle.shapesize(outline=8)
          >>> turtle.shapesize()
          (5, 5, 8)

 -- の関数: turtle.shearfactor (shear=None)


     パラメータ: ‘shear’ - number (optional)

     Set or return the current shearfactor.  Shear the turtleshape
     according to the given shearfactor shear, which is the tangent of
     the shear angle.  Do 'not' change the turtle's heading (direction
     of movement).  If shear is not given: return the current
     shearfactor, i.  e.  the tangent of the shear angle, by which lines
     parallel to the heading of the turtle are sheared.

          >>> turtle.shape("circle")
          >>> turtle.shapesize(5,2)
          >>> turtle.shearfactor(0.5)
          >>> turtle.shearfactor()
          0.5

 -- の関数: turtle.tilt (angle)


     パラメータ: ‘angle’ - 数

     タートルの形(turtleshape)を現在の傾斜角から角度('angle')だけ回転し
     ます。このときタートルの進む方向は '変わりません' 。

          >>> turtle.reset()
          >>> turtle.shape("circle")
          >>> turtle.shapesize(5,2)
          >>> turtle.tilt(30)
          >>> turtle.fd(50)
          >>> turtle.tilt(30)
          >>> turtle.fd(50)

 -- の関数: turtle.tiltangle (angle=None)


     パラメータ: ‘angle’ - a number (optional)

     Set or return the current tilt-angle.  If angle is given, rotate
     the turtleshape to point in the direction specified by angle,
     regardless of its current tilt-angle.  Do 'not' change the turtle's
     heading (direction of movement).  If angle is not given: return the
     current tilt-angle, i.  e.  the angle between the orientation of
     the turtleshape and the heading of the turtle (its direction of
     movement).

          >>> turtle.reset()
          >>> turtle.shape("circle")
          >>> turtle.shapesize(5,2)
          >>> turtle.tilt(45)
          >>> turtle.tiltangle()
          45.0

 -- の関数: turtle.shapetransform (t11=None, t12=None, t21=None,
          t22=None)


     パラメータ:

        * ‘t11’ - a number (optional)

        * ‘t12’ - a number (optional)

        * ‘t21’ - a number (optional)

        * ‘t12’ - a number (optional)

     Set or return the current transformation matrix of the turtle
     shape.

     If none of the matrix elements are given, return the transformation
     matrix as a tuple of 4 elements.  Otherwise set the given elements
     and transform the turtleshape according to the matrix consisting of
     first row t11, t12 and second row t21, t22.  The determinant t11 *
     t22 - t12 * t21 must not be zero, otherwise an error is raised.
     Modify stretchfactor, shearfactor and tiltangle according to the
     given matrix.

          >>> turtle = Turtle()
          >>> turtle.shape("square")
          >>> turtle.shapesize(4,2)
          >>> turtle.shearfactor(-0.5)
          >>> turtle.shapetransform()
          (4.0, -1.0, -0.0, 2.0)

 -- の関数: turtle.get_shapepoly ()

     Return the current shape polygon as tuple of coordinate pairs.
     This can be used to define a new shape or components of a compound
     shape.

          >>> turtle.shape("square")
          >>> turtle.shapetransform(4, -1, 0, 2)
          >>> turtle.get_shapepoly()
          ((50, -20), (30, 20), (-50, 20), (-30, -20))


File: python.info,  Node: イベントを利用する,  Next: 特別な Turtle のメソッド,  Prev: タートルの状態,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.29 イベントを利用する
............................

 -- の関数: turtle.onclick (fun, btn=1, add=None)


     パラメータ:

        * ‘fun’ - 2引数の関数でキャンバスのクリックされた点の座標を引数
          として呼び出されるものです

        * ‘btn’ - マウスボタンの番号、デフォルトは 1 (左マウスボタン)

        * ‘add’ - ‘True’ または ‘False’ - ‘True’ ならば、 新しい束縛が追
          加されますが、そうでなければ、 以前の束縛を置き換えます。

     'fun' をタートルのマウスクリック(mouse-click)イベントに束縛します。
     'fun' が ‘None’ ならば、既存の束縛が取り除かれます。無名タートル、
     つまり手続き的なやり方の例です:

          >>> def turn(x, y):
          ...     left(180)
          ...
          >>> onclick(turn)  # Now clicking into the turtle will turn it.
          >>> onclick(None)  # event-binding will be removed

 -- の関数: turtle.onrelease (fun, btn=1, add=None)


     パラメータ:

        * ‘fun’ - 2引数の関数でキャンバスのクリックされた点の座標を引数
          として呼び出されるものです

        * ‘btn’ - マウスボタンの番号、デフォルトは 1 (左マウスボタン)

        * ‘add’ - ‘True’ または ‘False’ - ‘True’ ならば、 新しい束縛が追
          加されますが、そうでなければ、 以前の束縛を置き換えます。

     'fun' をタートルのマウスボタンリリース(mouse-button-release)イベン
     トに束縛します。 'fun' が ‘None’ ならば、既存の束縛が取り除かれます
     。

          >>> class MyTurtle(Turtle):
          ...     def glow(self,x,y):
          ...         self.fillcolor("red")
          ...     def unglow(self,x,y):
          ...         self.fillcolor("")
          ...
          >>> turtle = MyTurtle()
          >>> turtle.onclick(turtle.glow)     # clicking on turtle turns fillcolor red,
          >>> turtle.onrelease(turtle.unglow) # releasing turns it to transparent.

 -- の関数: turtle.ondrag (fun, btn=1, add=None)


     パラメータ:

        * ‘fun’ - 2引数の関数でキャンバスのクリックされた点の座標を引数
          として呼び出されるものです

        * ‘btn’ - マウスボタンの番号、デフォルトは 1 (左マウスボタン)

        * ‘add’ - ‘True’ または ‘False’ - ‘True’ ならば、 新しい束縛が追
          加されますが、そうでなければ、 以前の束縛を置き換えます。

     'fun' をタートルのマウスムーブ(mouse-move)イベントに束縛します。
     'fun' が ‘None’ ならば、既存の束縛が取り除かれます。

     注意: 全てのマウスムーブイベントのシーケンスに先立ってマウスクリッ
     クイベントが起こります。

          >>> turtle.ondrag(turtle.goto)

     この後、タートルをクリックしてドラッグするとタートルはスクリーン上
     を動きそれによって(ペンが下りていれば)手書きの線ができあがります。


File: python.info,  Node: 特別な Turtle のメソッド,  Next: Compound shapes,  Prev: イベントを利用する,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.30 特別な Turtle のメソッド
..................................

 -- の関数: turtle.begin_poly ()

     多角形の頂点の記録を開始します。現在のタートル位置が最初の頂点です
     。

 -- の関数: turtle.end_poly ()

     多角形の頂点の記録を停止します。現在のタートル位置が最後の頂点です
     。この頂点が最初の頂点と結ばれます。

 -- の関数: turtle.get_poly ()

     最後に記録された多角形を返します。

          >>> turtle.home()
          >>> turtle.begin_poly()
          >>> turtle.fd(100)
          >>> turtle.left(20)
          >>> turtle.fd(30)
          >>> turtle.left(60)
          >>> turtle.fd(50)
          >>> turtle.end_poly()
          >>> p = turtle.get_poly()
          >>> register_shape("myFavouriteShape", p)

 -- の関数: turtle.clone ()

     位置、向きその他のプロパティがそっくり同じタートルのクローンを作っ
     て返します。

          >>> mick = Turtle()
          >>> joe = mick.clone()

 -- の関数: turtle.getturtle ()
 -- の関数: turtle.getpen ()

     Turtle オブジェクトそのものを返します。唯一の意味のある使い方: 無名
     タートルを返す関数として使う:

          >>> pet = getturtle()
          >>> pet.fd(50)
          >>> pet
          <turtle.Turtle object at 0x...>

 -- の関数: turtle.getscreen ()

     タートルが描画中の *note TurtleScreen: 3c76. オブジェクトを返します
     。 TurtleScreen のメソッドをそのオブジェクトに対して呼び出すことが
     できます。

          >>> ts = turtle.getscreen()
          >>> ts
          <turtle._Screen object at 0x...>
          >>> ts.bgcolor("pink")

 -- の関数: turtle.setundobuffer (size)


     パラメータ: ‘size’ - 整数または ‘None’

     アンドゥバッファを設定または無効化します。 'size' が整数ならばその
     サイズの空のアンドゥバッファを用意します。 'size' の値はタートルの
     アクションを何度 *note undo(): 3c11. メソッド/関数で取り消せるかの
     最大数を与えます。 'size' が ‘None’ ならば、アンドゥバッファは無効
     化されます。

          >>> turtle.setundobuffer(42)

 -- の関数: turtle.undobufferentries ()

     アンドゥバッファのエントリー数を返します。

          >>> while undobufferentries():
          ...     undo()


File: python.info,  Node: Compound shapes,  Prev: 特別な Turtle のメソッド,  Up: RawTurtle/Turtle のメソッドと対応する関数

5.24.1.31 Compound shapes
.........................

合成されたタートルの形、つまり幾つかの色の違う多角形から成るような形を使
うには、以下のように補助クラス *note Shape: 3c79. を直接使わなければなり
ません:

  1. タイプ "compound" の空の Shape オブジェクトを作ります。

  2. *note addcomponent(): 3c7a. メソッドを使って、好きなだけここにコン
     ポーネントを追加します。

     例えば:

          >>> s = Shape("compound")
          >>> poly1 = ((0,0),(10,-5),(0,10),(-10,-5))
          >>> s.addcomponent(poly1, "red", "blue")
          >>> poly2 = ((0,0),(10,-5),(-10,-5))
          >>> s.addcomponent(poly2, "blue", "red")

  3. こうして作った Shape を Screen の形のリスト(shapelist) に追加して使
     います:

          >>> register_shape("myshape", s)
          >>> shape("myshape")

     注釈: *note Shape: 3c79. クラスは *note register_shape(): 3c5e. の
     内部では違った使われ方をします。アプリケーションを書く人が Shape ク
     ラスを扱わなければならないのは、上で示したように合成された形を使う
     とき 'だけ' です！


File: python.info,  Node: TurtleScreen/Screen のメソッドと対応する関数,  Next: Public classes,  Prev: RawTurtle/Turtle のメソッドと対応する関数,  Up: turtle --- タートルグラフィックス

5.24.1.32 TurtleScreen/Screen のメソッドと対応する関数
......................................................

この節のほとんどの例では ‘screen’ という名前の TurtleScreen インスタンス
を使います。

* Menu:

* ウィンドウの制御::
* アニメーションの制御::
* スクリーンイベントを利用する::
* 入力メソッド::
* 設定と特殊なメソッド::
* Screen 独自のメソッド、TurtleScreen から継承したもの以外::


File: python.info,  Node: ウィンドウの制御,  Next: アニメーションの制御,  Up: TurtleScreen/Screen のメソッドと対応する関数

5.24.1.33 ウィンドウの制御
..........................

 -- の関数: turtle.bgcolor (*args)


     パラメータ: ‘args’ - 色文字列または 0 から colormode の範囲の数3つ
     、 またはそれを三つ組みにしたもの

     TurtleScreen の背景色を設定するかまたは返します。

          >>> screen.bgcolor("orange")
          >>> screen.bgcolor()
          'orange'
          >>> screen.bgcolor("#800080")
          >>> screen.bgcolor()
          (128.0, 0.0, 128.0)

 -- の関数: turtle.bgpic (picname=None)


     パラメータ: ‘picname’ - 文字列で gif ファイルの名前 ‘"nopic"’ 、ま
     たは ‘None’

     背景の画像を設定するかまたは現在の背景画像(backgroundimage)の名前を
     返します。 'picname' がファイル名ならば、その画像を背景に設定します
     。 'picname' が ‘"nopic"’ ならば、(もしあれば)背景画像を削除します
     。 'picname' が ‘None’ ならば、現在の背景画像のファイル名を返します
     。

          >>> screen.bgpic()
          'nopic'
          >>> screen.bgpic("landscape.gif")
          >>> screen.bgpic()
          "landscape.gif"

 -- の関数: turtle.clear ()

          注釈: この TurtleScreen メソッドはグローバル関数としては
          ‘clearscreen’ という名前でだけ使えます。グローバル関数 ‘clear’
          は Turtle メソッドの ‘clear’ から派生した別ものです。

 -- の関数: turtle.clearscreen ()

     全ての図形と全てのタートルを TurtleScreen から削除します。そして空
     になった TurtleScreen をリセットして初期状態に戻します: 白い背景、
     背景画像もイベント束縛もなく、トレーシングはオンです。

 -- の関数: turtle.reset ()

          注釈: この TurtleScreen メソッドはグローバル関数としては
          ‘resetscreen’ という名前でだけ使えます。グローバル関数 ‘reset’
          は Turtle メソッドの ‘reset’ から派生した別ものです。

 -- の関数: turtle.resetscreen ()

     スクリーン上の全てのタートルをリセットしその初期状態に戻します。

 -- の関数: turtle.screensize (canvwidth=None, canvheight=None, bg=None)


     パラメータ:

        * ‘canvwidth’ - 正の整数でピクセル単位の新しいキャンバス幅
          (canvaswidth)

        * ‘canvheight’ - 正の整数でピクセル単位の新しいキャンバス高さ
          (canvasheight)

        * ‘bg’ - 色文字列または色タプルで新しい背景色

     引数が渡されなければ、現在の (キャンバス幅, キャンバス高さ) を返し
     ます。そうでなければタートルが描画するキャンバスのサイズを変更しま
     す。描画ウィンドウには影響しません。キャンバスの隠れた部分を見るた
     めにはスクロールバーを使って下さい。このメソッドを使うと、以前はキ
     ャンバスの外にあったそうした図形の一部を見えるようにすることができ
     ます。

          >>> screen.screensize()
          (400, 300)
          >>> screen.screensize(2000,1500)
          >>> screen.screensize()
          (2000, 1500)

     # 逃げ出してしまったタートルを探すためとかね ;-)

 -- の関数: turtle.setworldcoordinates (llx, lly, urx, ury)


     パラメータ:

        * ‘llx’ - 数でキャンバスの左下隅の x-座標

        * ‘lly’ - 数でキャンバスの左下隅の y-座標

        * ‘urx’ - 数でキャンバスの右上隅の x-座標

        * ‘ury’ - 数でキャンバスの右上隅の y-座標

     ユーザー定義座標系を準備し必要ならばモードを "world" に切り替えます
     。この動作は ‘screen.reset()’ を伴います。すでに "world" モードにな
     っていた場合、全ての図形は新しい座標に従って再描画されます。

     '重要なお知らせ': ユーザー定義座標系では角度が歪むかもしれません。

          >>> screen.reset()
          >>> screen.setworldcoordinates(-50,-7.5,50,7.5)
          >>> for _ in range(72):
          ...     left(10)
          ...
          >>> for _ in range(8):
          ...     left(45); fd(2)   # a regular octagon


File: python.info,  Node: アニメーションの制御,  Next: スクリーンイベントを利用する,  Prev: ウィンドウの制御,  Up: TurtleScreen/Screen のメソッドと対応する関数

5.24.1.34 アニメーションの制御
..............................

 -- の関数: turtle.delay (delay=None)


     パラメータ: ‘delay’ - 正の整数

     描画の遅延('delay')をミリ秒単位で設定するかまたはその値を返します。
     (これは概ね引き続くキャンバス更新の時間間隔です。) 遅延が大きくなる
     と、アニメーションは遅くなります。

     オプション引数:

          >>> screen.delay()
          10
          >>> screen.delay(5)
          >>> screen.delay()
          5

 -- の関数: turtle.tracer (n=None, delay=None)


     パラメータ:

        * ‘n’ - 非負整数

        * ‘delay’ - 非負整数

     タートルのアニメーションをオン・オフし、描画更新の遅延を設定します
     。 'n' が与えられた場合、通常のスクリーン更新のうち 1/n しか実際に
     実行されません。 (複雑なグラフィックスの描画を加速するのに使えます
     。) 引数なしで呼び出されたなら、現在保存されている n の値を返します
     。二つ目の引数は遅延の値を設定します(*note delay(): 3c4f. も参照)。

          >>> screen.tracer(8, 25)
          >>> dist = 2
          >>> for i in range(200):
          ...     fd(dist)
          ...     rt(90)
          ...     dist += 2

 -- の関数: turtle.update ()

     TurtleScreen の更新を実行します。トレーサーがオフの時に使われます。

RawTurtle/Turtle のメソッド *note speed(): 3c12. も参照して下さい。


File: python.info,  Node: スクリーンイベントを利用する,  Next: 入力メソッド,  Prev: アニメーションの制御,  Up: TurtleScreen/Screen のメソッドと対応する関数

5.24.1.35 スクリーンイベントを利用する
......................................

 -- の関数: turtle.listen (xdummy=None, ydummy=None)

     TurtleScreen に(キー・イベントを収集するために)フォーカスします。ダ
     ミー引数は *note listen(): 3c52. を onclick メソッドに渡せるように
     するためのものです。

 -- の関数: turtle.onkey (fun, key)
 -- の関数: turtle.onkeyrelease (fun, key)


     パラメータ:

        * ‘fun’ - 引数なしの関数または ‘None’

        * ‘key’ - 文字列: キー (例 "a") またはキー・シンボル (例
          "space")

     'fun' を指定されたキーのキーリリース(key-release)イベントに束縛しま
     す。 'fun' が ‘None’ ならばイベント束縛は除かれます。注意: キー・イ
     ベントを登録できるようにするためには TurtleScreen はフォーカスを持
     っていないとなりません(*note listen(): 3c52. を参照)。

          >>> def f():
          ...     fd(50)
          ...     lt(60)
          ...
          >>> screen.onkey(f, "Up")
          >>> screen.listen()

 -- の関数: turtle.onkeypress (fun, key=None)


     パラメータ:

        * ‘fun’ - 引数なしの関数または ‘None’

        * ‘key’ - 文字列: キー (例 "a") またはキー・シンボル (例
          "space")

     Bind 'fun' to key-press event of key if key is given, or to any
     key-press-event if no key is given.  Remark: in order to be able to
     register key-events, TurtleScreen must have focus.  (See method
     *note listen(): 3c52.)

          >>> def f():
          ...     fd(50)
          ...
          >>> screen.onkey(f, "Up")
          >>> screen.listen()

 -- の関数: turtle.onclick (fun, btn=1, add=None)
 -- の関数: turtle.onscreenclick (fun, btn=1, add=None)


     パラメータ:

        * ‘fun’ - 2引数の関数でキャンバスのクリックされた点の座標を引数
          として呼び出されるものです

        * ‘btn’ - マウスボタンの番号、デフォルトは 1 (左マウスボタン)

        * ‘add’ - ‘True’ または ‘False’ - ‘True’ ならば、 新しい束縛が追
          加されますが、そうでなければ、 以前の束縛を置き換えます。

     'fun' をタートルのマウスクリック(mouse-click)イベントに束縛します。
     'fun' が ‘None’ ならば、既存の束縛が取り除かれます。

     Example for a ‘screen’ という名の TurtleScreen インスタンスと
     ‘turtle’ という名前の Turtle インスタンスの例:

          >>> screen.onclick(turtle.goto) # Subsequently clicking into the TurtleScreen will
          >>>                             # make the turtle move to the clicked point.
          >>> screen.onclick(None)        # remove event binding again

          注釈: この TurtleScreen メソッドはグローバル関数としては
          ‘onscreenclick’ という名前でだけ使えます。グローバル関数
          ‘onclick’ は Turtle メソッドの ‘onclick’ から派生した別もので
          す。

 -- の関数: turtle.ontimer (fun, t=0)


     パラメータ:

        * ‘fun’ - 引数なし関数

        * ‘t’ - 数 >= 0

     't' ミリ秒後に 'fun' を呼び出すタイマーを仕掛けます。

          >>> running = True
          >>> def f():
          ...     if running:
          ...         fd(50)
          ...         lt(60)
          ...         screen.ontimer(f, 250)
          >>> f()   ### makes the turtle march around
          >>> running = False

 -- の関数: turtle.mainloop ()
 -- の関数: turtle.done ()

     Starts event loop - calling Tkinter's mainloop function.  Must be
     the last statement in a turtle graphics program.  Must 'not' be
     used if a script is run from within IDLE in -n mode (No subprocess)
     - for interactive use of turtle graphics.

          >>> screen.mainloop()


File: python.info,  Node: 入力メソッド,  Next: 設定と特殊なメソッド,  Prev: スクリーンイベントを利用する,  Up: TurtleScreen/Screen のメソッドと対応する関数

5.24.1.36 入力メソッド
......................

 -- の関数: turtle.textinput (title, prompt)


     パラメータ:

        * ‘title’ - string

        * ‘prompt’ - string

     Pop up a dialog window for input of a string.  Parameter title is
     the title of the dialog window, prompt is a text mostly describing
     what information to input.  Return the string input.  If the dialog
     is canceled, return ‘None’.

          >>> screen.textinput("NIM", "Name of first player:")

 -- の関数: turtle.numinput (title, prompt, default=None, minval=None,
          maxval=None)


     パラメータ:

        * ‘title’ - string

        * ‘prompt’ - string

        * ‘default’ - number (optional)

        * ‘minval’ - number (optional)

        * ‘maxval’ - number (optional)

     Pop up a dialog window for input of a number.  title is the title
     of the dialog window, prompt is a text mostly describing what
     numerical information to input.  default: default value, minval:
     minimum value for input, maxval: maximum value for input.  The
     number input must be in the range minval ..  maxval if these are
     given.  If not, a hint is issued and the dialog remains open for
     correction.  Return the number input.  If the dialog is canceled,
     return ‘None’.

          >>> screen.numinput("Poker", "Your stakes:", 1000, minval=10, maxval=10000)


File: python.info,  Node: 設定と特殊なメソッド,  Next: Screen 独自のメソッド、TurtleScreen から継承したもの以外,  Prev: 入力メソッド,  Up: TurtleScreen/Screen のメソッドと対応する関数

5.24.1.37 設定と特殊なメソッド
..............................

 -- の関数: turtle.mode (mode=None)


     パラメータ: ‘mode’ - 文字列 "standard", "logo", "world" のいずれか

     タートルのモード("standard", "logo", "world" のいずれか)を設定して
     リセットします。モードが渡されなければ現在のモードが返されます。

     モード "standard" は古い *note turtle: ea. 互換です。モード "logo"
     は Logo タートルグラフィックスとほぼ互換です。モード "world" はユー
     ザーの定義した「世界座標(world coordinates)」を使います。 '重要なお
     知らせ': このモードでは ‘x/y’ 比が 1 でないと角度が歪むかもしれませ
     ん。

     モード           タートルの向きの初期値        正の角度
                                                    
     -----------------------------------------------------------------------
                                                    
     "standard"       右 (東) 向き                  反時計回り
                                                    
                                                    
     "logo"           上 (北) 向き                  時計回り
                                                    

          >>> mode("logo")   # resets turtle heading to north
          >>> mode()
          'logo'

 -- の関数: turtle.colormode (cmode=None)


     パラメータ: ‘cmode’ - 1.0 か 255 のどちらかの値

     色モード(colormode)を返すか、または 1.0 か 255 のどちらかの値に設定
     します。設定した後は、色トリプルの 'r', 'g', 'b' 値は 0 から
     'cmode' の範囲になければなりません。

          >>> screen.colormode(1)
          >>> turtle.pencolor(240, 160, 80)
          Traceback (most recent call last):
               ...
          TurtleGraphicsError: bad color sequence: (240, 160, 80)
          >>> screen.colormode()
          1.0
          >>> screen.colormode(255)
          >>> screen.colormode()
          255
          >>> turtle.pencolor(240,160,80)

 -- の関数: turtle.getcanvas ()

     この TurtleScreen の Canvas を返します。Tkinter の Canvas を使って
     何をするか知っている人には有用です。

          >>> cv = screen.getcanvas()
          >>> cv
          <turtle.ScrolledCanvas object ...>

 -- の関数: turtle.getshapes ()

     現在使うことのできる全てのタートルの形のリストを返します。

          >>> screen.getshapes()
          ['arrow', 'blank', 'circle', ..., 'turtle']

 -- の関数: turtle.register_shape (name, shape=None)
 -- の関数: turtle.addshape (name, shape=None)

     この関数を呼び出す三つの異なる方法があります:

       1. 'name' が gif ファイルの名前で 'shape' が ‘None’: 対応する画像
          の形を取り込みます。

               >>> screen.register_shape("turtle.gif")

               注釈: 画像の形はタートルが向きを変えても '回転しません' の
               で、タートルがどちらを向いているか見ても判りません!

       2. 'name' が任意の文字列で 'shape' が座標ペアのタプル: 対応する多
          角形を取り込みます。

               >>> screen.register_shape("triangle", ((5,-3), (0,5), (-5,-3)))

       3. 'name' が任意の文字列で 'shape' が (合成形の) *note Shape:
          3c79. オブジェクト: 対応する合成形を取り込みます。

     タートルの形を TurtleScreen の形リスト(shapelist)に加えます。このよ
     うに登録された形だけが ‘shape(shapename)’ コマンドに使えます。

 -- の関数: turtle.turtles ()

     スクリーン上のタートルのリストを返します。

          >>> for turtle in screen.turtles():
          ...     turtle.color("red")

 -- の関数: turtle.window_height ()

     タートルウィンドウの高さを返します。

          >>> screen.window_height()
          480

 -- の関数: turtle.window_width ()

     タートルウィンドウの幅を返します。

          >>> screen.window_width()
          640


File: python.info,  Node: Screen 独自のメソッド、TurtleScreen から継承したもの以外,  Prev: 設定と特殊なメソッド,  Up: TurtleScreen/Screen のメソッドと対応する関数

5.24.1.38 Screen 独自のメソッド、TurtleScreen から継承したもの以外
..................................................................

 -- の関数: turtle.bye ()

     タートルグラフィックス(turtlegraphics)のウィンドウを閉じます。

 -- の関数: turtle.exitonclick ()

     スクリーン上のマウスクリックに ‘bye()’ メソッドを束縛します。

     設定辞書中の "using_IDLE" の値が ‘False’ (デフォルトです) の場合、
     さらにメインループ(mainloop)に入ります。注意: もし IDLE が ‘-n’ ス
     イッチ(サブプロセスなし)付きで使われているときは、この値は
     ‘turtle.cfg’ の中で ‘True’ とされているべきです。この場合、IDLE の
     メインループもクライアントスクリプトから見てアクティブです。

 -- の関数: turtle.setup (width=_CFG['width'], height=_CFG['height'],
          startx=_CFG['leftright'], starty=_CFG['topbottom'])

     メインウィンドウのサイズとポジションを設定します。引数のデフォルト
     値は設定辞書に収められており、 ‘turtle.cfg’ ファイルを通じて変更で
     きます。


     パラメータ:

        * ‘width’ - 整数ならばピクセル単位のサイズ、浮動小数点数ならばス
          クリーンに対する割合 (スクリーンの 50% がデフォルト)

        * ‘height’ - 整数ならばピクセル単位の高さ、浮動小数点数ならばス
          クリーンに対する割合 (スクリーンの 75% がデフォルト)

        * ‘startx’ - 正の数ならばスクリーンの左端からピクセル単位で測っ
          た開始位置、 負の数ならば右端から、‘None’ ならば水平方向に真ん
          中

        * ‘starty’ - 正の数ならばスクリーンの上端からピクセル単位で測っ
          た開始位置、 負の数ならば下端から、‘None’ ならば垂直方向に真ん
          中

          >>> screen.setup (width=200, height=200, startx=0, starty=0)
          >>>              # sets window to 200x200 pixels, in upper left of screen
          >>> screen.setup(width=.75, height=0.5, startx=None, starty=None)
          >>>              # sets window to 75% of screen by 50% of screen and centers

 -- の関数: turtle.title (titlestring)


     パラメータ: ‘titlestring’ - タートルグラフィックスウィンドウのタイ
     トルバーに表示される文字列

     ウインドウのタイトルを 'titlestring' に設定します。

          >>> screen.title("Welcome to the turtle zoo!")


File: python.info,  Node: Public classes,  Next: 説明<2>,  Prev: TurtleScreen/Screen のメソッドと対応する関数,  Up: turtle --- タートルグラフィックス

5.24.1.39 Public classes
........................

 -- クラス: turtle.RawTurtle (canvas)
 -- クラス: turtle.RawPen (canvas)


     パラメータ: ‘canvas’ - a ‘tkinter.Canvas’, a *note ScrolledCanvas:
     3c86. or a *note TurtleScreen: 3c76.

     タートルを作ります。タートルには上の「Turtle/RawTurtle のメソッド」
     で説明した全てのメソッドがあります。

 -- クラス: turtle.Turtle

     RawTurtle のサブクラスで同じインターフェイスを持ちますが、最初に必
     要になったとき自動的に作られる *note Screen: 3bf9. オブジェクトに描
     画します。

 -- クラス: turtle.TurtleScreen (cv)


     パラメータ: ‘cv’ - a ‘tkinter.Canvas’

     上で説明した *note bgcolor(): 3c49. のようなスクリーン向けのメソッ
     ドを提供します。

 -- クラス: turtle.Screen

     TurtleScreen のサブクラスで *note 4つのメソッドが加わっています:
     3c82. 。

 -- クラス: turtle.ScrolledCanvas (master)


     パラメータ: ‘master’ - この ScrolledCanvas すなわちスクロールバーの
     付いた Tkinter canvas を収める Tkinter ウィジェット

     タートルたちが遊び回る場所として自動的に ScrolledCanvas を提供する
     Screen クラスによって使われます。

 -- クラス: turtle.Shape (type_, data)


     パラメータ: ‘type_’ - 文字列 "polygon", "image", "compound" のいず
     れか

     形をモデル化するデータ構造。ペア ‘(type_, data)’ は以下の仕様に従わ
     なければなりません:

     'type_'         'data'
                     
     -------------------------------------------------------------------------------
                     
     "polygon"       多角形タプル、すなわち座標ペアのタプル
                     
                     
     "image"         画像 (この形式は内部的にのみ使用されます!)
                     
                     
     "compound"      ‘None’ (合成形は *note addcomponent(): 3c7a. メソッドを使っ
                     て作らなければなりません)
                     

      -- メソッド: addcomponent (poly, fill, outline=None)


          パラメータ:

             * ‘poly’ - 多角形、すなわち数のペアのタプル

             * ‘fill’ - 'poly' を塗りつぶす色

             * ‘outline’ - 'poly' のアウトラインの色 (与えられた場合)

          例:

               >>> poly = ((0,0),(10,-5),(0,10),(-10,-5))
               >>> s = Shape("compound")
               >>> s.addcomponent(poly, "red", "blue")
               >>> # ... add more components and then use register_shape()

          *note Compound shapes: 3c78. を参照。

 -- クラス: turtle.Vec2D (x, y)

     2次元ベクトルのクラスで、タートルグラフィックスを実装するための補助
     クラス。タートルグラフィックスを使ったプログラムでも有用でしょう。
     タプルから派生しているので、ベクターはタプルです!

     以下の演算が使えます ('a', 'b' はベクトル、 'k' は数):

        * ‘a + b’ ベクトル和

        * ‘a - b’ ベクトル差

        * ‘a * b’ 内積

        * ‘k * a’ および ‘a * k’ スカラー倍

        * ‘abs(a)’ a の絶対値

        * ‘a.rotate(angle)’ 回転


File: python.info,  Node: 説明<2>,  Next: ヘルプと設定,  Prev: Public classes,  Up: turtle --- タートルグラフィックス

5.24.1.40 説明
..............

A turtle object draws on a screen object, and there a number of key
classes in the turtle object-oriented interface that can be used to
create them and relate them to each other.

A *note Turtle: 3c87. instance will automatically create a *note Screen:
3bf9. instance if one is not already present.

‘Turtle’ is a subclass of *note RawTurtle: 3c84, which 'doesn't'
automatically create a drawing surface - a 'canvas' will need to be
provided or created for it.  The 'canvas' can be a ‘tkinter.Canvas’,
*note ScrolledCanvas: 3c86. or *note TurtleScreen: 3c76.

*note TurtleScreen: 3c76. is the basic drawing surface for a turtle.
*note Screen: 3bf9. is a subclass of ‘TurtleScreen’, and includes *note
some additional methods: 3c82. for managing its appearance (including
size and title) and behaviour.  ‘TurtleScreen’'s constructor needs a
‘tkinter.Canvas’ or a *note ScrolledCanvas: 3c86. as an argument.

The functional interface for turtle graphics uses the various methods of
‘Turtle’ and ‘TurtleScreen’/‘Screen’.  Behind the scenes, a screen
object is automatically created whenever a function derived from a
‘Screen’ method is called.  Similarly, a turtle object is automatically
created whenever any of the functions derived from a Turtle method is
called.

To use multiple turtles on a screen, the object-oriented interface must
be used.


File: python.info,  Node: ヘルプと設定,  Next: turtledemo --- デモスクリプト,  Prev: 説明<2>,  Up: turtle --- タートルグラフィックス

5.24.1.41 ヘルプと設定
......................

* Menu:

* ヘルプの使い方::
* ドキュメント文字列の翻訳::
* Screen および Turtle の設定方法::


File: python.info,  Node: ヘルプの使い方,  Next: ドキュメント文字列の翻訳,  Up: ヘルプと設定

5.24.1.42 ヘルプの使い方
........................

Screen と Turtle クラスのパブリックメソッドはドキュメント文字列で網羅的
に文書化されていますので、Python のヘルプ機能を通じてオンラインヘルプと
して利用できます:

   - IDLE を使っているときは、打ち込んだ関数/メソッド呼び出しのシグニチ
     ャとドキュメント文字列の一行目がツールチップとして表示されます。

   - *note help(): 8a5. をメソッドや関数に対して呼び出すとドキュメント文
     字列が表示されます:

          >>> help(Screen.bgcolor)
          Help on method bgcolor in module turtle:

          bgcolor(self, *args) unbound turtle.Screen method
              Set or return backgroundcolor of the TurtleScreen.

              Arguments (if given): a color string or three numbers
              in the range 0..colormode or a 3-tuple of such numbers.


              >>> screen.bgcolor("orange")
              >>> screen.bgcolor()
              "orange"
              >>> screen.bgcolor(0.5,0,0.5)
              >>> screen.bgcolor()
              "#800080"

          >>> help(Turtle.penup)
          Help on method penup in module turtle:

          penup(self) unbound turtle.Turtle method
              Pull the pen up -- no drawing when moving.

              Aliases: penup | pu | up

              No argument

              >>> turtle.penup()

   - メソッドに由来する関数のドキュメント文字列は変更された形をとります:

          >>> help(bgcolor)
          Help on function bgcolor in module turtle:

          bgcolor(*args)
              Set or return backgroundcolor of the TurtleScreen.

              Arguments (if given): a color string or three numbers
              in the range 0..colormode or a 3-tuple of such numbers.

              Example::

                >>> bgcolor("orange")
                >>> bgcolor()
                "orange"
                >>> bgcolor(0.5,0,0.5)
                >>> bgcolor()
                "#800080"

          >>> help(penup)
          Help on function penup in module turtle:

          penup()
              Pull the pen up -- no drawing when moving.

              Aliases: penup | pu | up

              No argument

              Example:
              >>> penup()

これらの変更されたドキュメント文字列はインポート時にメソッドから導出され
る関数定義と一緒に自動的に作られます。


File: python.info,  Node: ドキュメント文字列の翻訳,  Next: Screen および Turtle の設定方法,  Prev: ヘルプの使い方,  Up: ヘルプと設定

5.24.1.43 ドキュメント文字列の翻訳
..................................

Screen と Turtle クラスのパブリックメソッドについて、キーがメソッド名で
値がドキュメント文字列である辞書を作るユーティリティがあります。

 -- の関数: turtle.write_docstringdict (filename='turtle_docstringdict')


     パラメータ: ‘filename’ - ファイル名として使われる文字列

     ドキュメント文字列辞書(docstring-dictionary)を作って与えられたファ
     イル名の Python スクリプトに書き込みます。この関数はわざわざ呼び出
     さなければなりません (タートルグラフィックスのクラスから使われるこ
     とはありません)。ドキュメント文字列辞書は ‘`filename'.py’ という
     Python スクリプトに書き込まれます。ドキュメント文字列の異なった言語
     への翻訳に対するテンプレートとして使われることを意図したものです。

もしあなたが(またはあなたの生徒さんが) *note turtle: ea. を自国語のオン
ラインヘルプ付きで使いたいならば、ドキュメント文字列を翻訳してできあがっ
たファイルをたとえば ‘turtle_docstringdict_german.py’ という名前で保存し
なければなりません。

さらに ‘turtle.cfg’ ファイルで適切な設定をしておけば、このファイルがイン
ポート時に読み込まれて元の英語のドキュメント文字列を置き換えます。

この文書を書いている時点ではドイツ語とイタリア語のドキュメント文字列辞書
が存在します。 ( <glingl@aon.at> にリクエストして下さい。)


File: python.info,  Node: Screen および Turtle の設定方法,  Prev: ドキュメント文字列の翻訳,  Up: ヘルプと設定

5.24.1.44 Screen および Turtle の設定方法
.........................................

初期デフォルト設定では古い turtle の見た目と振る舞いを真似るようにして、
互換性を最大限に保つようにしています。

このモジュールの特性を反映した、あるいは個々人の必要性 (たとえばクラスル
ームでの使用)に合致した、異なった設定を使いたい場合、設定ファイル
‘turtle.cfg’ を用意してインポート時に読み込ませその設定に従わせることが
できます。

初期設定は以下の ‘turtle.cfg’ に対応します:

     width = 0.5
     height = 0.75
     leftright = None
     topbottom = None
     canvwidth = 400
     canvheight = 300
     mode = standard
     colormode = 1.0
     delay = 10
     undobuffersize = 1000
     shape = classic
     pencolor = black
     fillcolor = black
     resizemode = noresize
     visible = True
     language = english
     exampleturtle = turtle
     examplescreen = screen
     title = Python Turtle Graphics
     using_IDLE = False

いくつかピックアップしたエントリーの短い説明:

   - 最初の4行は *note Screen.setup: 3c65. メソッドの引数に当たります。

   - 5行目6行目は *note Screen.screensize: 3c4d. メソッドの引数に当たり
     ます。

   - 'shape' は最初から用意されている形ならどれでも使えます(arrow,
     turtle など)。詳しくは ‘help(shape)’ をお試し下さい。

   - 塗りつぶしの色(fill color)を使いたくない(つまりタートルを透明にした
     い)場合、 ‘fillcolor = ""’ と書かなければなりません (しかし全ての空
     でない文字列は cfg ファイル中で引用符を付けてはいけません)。

   - タートルにその状態を反映させるためには ‘resizemode = auto’ とします
     。

   - たとえば ‘language = italian’ とするとドキュメント文字列辞書
     (docstringdict) として ‘turtle_docstringdict_italian.py’ がインポー
     ト時に読み込まれます (もしそれがインポートパス、たとえば *note
     turtle: ea. と同じディレクトリにあれば)。

   - 'exampleturtle' および 'examplescreen' はこれらのオブジェクトのドキ
     ュメント文字列内での呼び名を決めます。メソッドのドキュメント文字列
     から関数のドキュメント文字列に変換する際に、これらの名前は取り除か
     れます。

   - 'using_IDLE': IDLE とその ‘-n’ スイッチ(サブプロセスなし)を常用する
     ならば、この値を ‘True’ に設定して下さい。これにより *note
     exitonclick(): 3c64. がメインループ(mainloop)に入るのを阻止します。

‘turtle.cfg’ ファイルは *note turtle: ea. の保存されているディレクトリと
現在の作業ディレクトリに追加的に存在し得ます。後者が前者の設定をオーバー
ライドします。

‘Lib/turtledemo’ ディレクトリにも ‘turtle.cfg’ ファイルがあります。 デモ
を実際に(できればデモビュワーからでなく)実行してそこに書かれたものとその
効果を学びましょう。


File: python.info,  Node: turtledemo --- デモスクリプト,  Next: python 2 6からの変更点,  Prev: ヘルプと設定,  Up: turtle --- タートルグラフィックス

5.24.1.45 ‘turtledemo’ -- デモスクリプト
........................................

*note turtledemo: eb. パッケージには一連のデモスクリプトが含まれています
。これらのスクリプトは以下のように、付属のデモビューアを使用して実行およ
び表示できます:

     python -m turtledemo

あるいは、個別にデモスクリプトを実行できます。たとえば 、:

     python -m turtledemo.bytedesign

*note turtledemo: eb. パッケージのディレクトリには次のものが含まれます:

   - ソースコードを眺めつつスクリプトを実行できるデモビュワー
     ‘__main__.py’ 。

   - Multiple scripts demonstrating different features of the *note
     turtle: ea. module.  Examples can be accessed via the Examples
     menu.  They can also be run standalone.

   - 設定ファイルの書き方や使い方の例として参考にできる ‘turtle.cfg’ フ
     ァイル。

デモスクリプトは以下の通りです:

名前                 説明                               フィーチャー
                                                        
------------------------------------------------------------------------------------
                                                        
bytedesign           複雑な古典的タートルグラフィック   *note tracer(): 3c50,
                     スパターン                         delay,
                                                        *note update(): 3c51.
                                                        
                                                        
chaos                verhust 力学系のグラフ化, コンピ   世界座標系
                     ュータの計算が常識的な予想に反す   
                     る場合があることを示します。
                     
                                                        
clock                コンピュータの時間を示すアナログ   タートルが時計の針,
                     時計                               ontimer
                                                        
                                                        
colormixer           r, g, b の実験                     *note ondrag(): 3c3e.
                                                        
                                                        
forest               3 breadth-first trees              randomization
                                                        
                                                        
fractalcurves        Hilbert & Koch 曲線                再帰
                                                        
                                                        
lindenmayer          民俗的数学 (インド kolams)         L-システム
                                                        
                                                        
minimal_hanoi        ハノイの塔                         ハノイ盤として正方形のタ
                                                        ートル (shape, shapesize)
                                                        
                                                        
nim                  play the classical nim game with   turtles as nimsticks,
                     three heaps of sticks against      event driven (mouse,
                     the computer.                      keyboard)
                                                        
                                                        
paint                超極小主義的描画プログラム         *note onclick(): 3c3c.
                                                        
                                                        
peace                初歩的                             turtle: 見た目とアニメー
                                                        ション
                                                        
                                                        
penrose              凧と矢による非周期的タイリング     *note stamp(): 3c0e.
                                                        
                                                        
planet_and_moon      重力系のシミュレーション           合成形,
                                                        *note Vec2D: 3c69.
                                                        
                                                        
rosette              タートルグラフィックスについての   *note clone(): 3c42,
                     wikipedia の記事の例               *note undo(): 3c11.
                                                        
                                                        
round_dance          dancing turtles rotating           compound shapes, clone
                     pairwise in opposite direction     shapesize, tilt,
                                                        get_shapepoly, update
                                                        
                                                        
sorting_animate      visual demonstration of            simple alignment,
                     different sorting methods          randomization
                                                        
                                                        
tree                 (図形的) 幅優先木 (ジェネレータ    *note clone(): 3c42.
                     を使って)                          
                     
                                                        
two_canvases         simple design                      turtles on two canvases
                                                        
                                                        
yinyang              もう一つの初歩的な例               *note circle(): 3c0c.
                                                        

楽しんでね!


File: python.info,  Node: python 2 6からの変更点,  Next: python 3 0からの変更点,  Prev: turtledemo --- デモスクリプト,  Up: turtle --- タートルグラフィックス

5.24.1.46 python 2.6からの変更点
................................

   - The methods *note Turtle.tracer: 3c50, *note Turtle.window_width:
     3c62. and *note Turtle.window_height: 3c61. have been eliminated.
     Methods with these names and functionality are now available only
     as methods of *note Screen: 3bf9.  The functions derived from these
     remain available.  (In fact already in Python 2.6 these methods
     were merely duplications of the corresponding *note TurtleScreen:
     3c76./*note Screen: 3bf9. methods.)

   - The method ‘Turtle.fill()’ has been eliminated.  The behaviour of
     *note begin_fill(): 3c2a. and *note end_fill(): 3c2b. have changed
     slightly: now every filling process must be completed with an
     ‘end_fill()’ call.

   - A method *note Turtle.filling: 3c29. has been added.  It returns a
     boolean value: ‘True’ if a filling process is under way, ‘False’
     otherwise.  This behaviour corresponds to a ‘fill()’ call without
     arguments in Python 2.6.


File: python.info,  Node: python 3 0からの変更点,  Prev: python 2 6からの変更点,  Up: turtle --- タートルグラフィックス

5.24.1.47 python 3.0からの変更点
................................

   - The *note Turtle: 3c87. methods *note shearfactor(): 3c38, *note
     shapetransform(): 3c3a. and *note get_shapepoly(): 3c3b. have been
     added.  Thus the full range of regular linear transforms is now
     available for transforming turtle shapes.  *note tiltangle(): 6f0.
     has been enhanced in functionality: it now can be used to get or
     set the tilt angle.

   - The *note Screen: 3bf9. method *note onkeypress(): 3c55. has been
     added as a complement to *note onkey(): 3c53.  As the latter binds
     actions to the key release event, an alias: *note onkeyrelease():
     3c54. was also added for it.

   - The method *note Screen.mainloop: 3c58. has been added, so there is
     no longer a need to use the standalone *note mainloop(): 3c58.
     function when working with *note Screen: 3bf9. and *note Turtle:
     3c87. objects.

   - Two input methods have been added: *note Screen.textinput: 182d.
     and *note Screen.numinput: 182e.  These pop up input dialogs and
     return strings and numbers respectively.

   - Two example scripts ‘tdemo_nim.py’ and ‘tdemo_round_dance.py’ have
     been added to the ‘Lib/turtledemo’ directory.


File: python.info,  Node: cmd --- 行指向のコマンドインタープリターのサポート,  Next: shlex --- 単純な字句解析,  Prev: turtle --- タートルグラフィックス,  Up: プログラムのフレームワーク

5.24.2 ‘cmd’ -- 行指向のコマンドインタープリターのサポート
----------------------------------------------------------

'ソースコード:' Lib/cmd.py(1)

__________________________________________________________________

*note Cmd: 162b. クラスでは、行指向のコマンドインタープリタを書くための
簡単なフレームワークを提供します。テストハーネスや管理ツール、そして、後
により洗練されたインターフェイスでラップするプロトタイプとして、こうした
インタープリタはよく役に立ちます。

 -- クラス: cmd.Cmd (completekey='tab', stdin=None, stdout=None)

     *note Cmd: 162b. インスタンス、あるいはサブクラスのインスタンスは、
     行指向のインタープリタ・フレームワークです。 *note Cmd: 162b. 自身
     をインスタンス化することはありません。むしろ、 *note Cmd: 162b. の
     メソッドを継承したり、アクションメソッドをカプセル化するために、あ
     なたが自分で定義するインタープリタクラスのスーパークラスとしての便
     利です。

     オプション引数 'completekey' は、補完キーの *note readline: a8. 名
     です。デフォルトは ‘Tab’ です。 'completekey' が *note None: 641. で
     なく、 *note readline: a8. が利用できるならば、コマンド補完は自動的
     に行われます。

     The default, ‘'tab'’, is treated specially, so that it refers to
     the ‘Tab’ key on every *note readline.backend: 1613.  Specifically,
     if *note readline.backend: 1613. is ‘editline’, ‘Cmd’ will use
     ‘'^I'’ instead of ‘'tab'’.  Note that other values are not treated
     this way, and might only work with a specific backend.

     オプション引数の 'stdin' と 'stdout' には、Cmd またはそのサブクラス
     のインスタンスが入出力に使用するファイルオブジェクトを指定します。
     省略時には *note sys.stdin: 507. と *note sys.stdout: aa4. が使用さ
     れます。

     引数に渡した 'stdin' を使いたい場合は、インスタンスの *note
     use_rawinput: 3c93. 属性を ‘False’ にセットしてください。そうしない
     と 'stdin' は無視されます。

     バージョン 3.13 で変更: ‘completekey='tab'’ is replaced by ‘'^I'’
     for ‘editline’.

* Menu:

* Cmdオブジェクト::
* Cmd の例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/cmd.py


File: python.info,  Node: Cmdオブジェクト,  Next: Cmd の例,  Up: cmd --- 行指向のコマンドインタープリターのサポート

5.24.2.1 Cmdオブジェクト
........................

*note Cmd: 162b. インスタンスは、次のメソッドを持ちます:

 -- メソッド: Cmd.cmdloop (intro=None)

     プロンプトを繰り返し出力し、入力を受け取り、受け取った入力から取り
     去った先頭の語を解析し、その行の残りを引数としてアクションメソッド
     へディスパッチします。

     オプションの引数は、最初のプロンプトの前に表示されるバナーあるいは
     イントロ用の文字列です (これはクラス属性 *note intro: 3c97. をオー
     バーライドします)。

     *note readline: a8. モジュールがロードされているなら、入力は自動的
     に ‘bash’ のような履歴リスト編集機能を受け継ぎます(例えば、
     ‘Control-P’ は直前のコマンドへのスクロールバック、 ‘Control-N’ は次
     のものへ進む、 ‘Control-F’ はカーソルを右へ非破壊的に進める、
     ‘Control-B’ はカーソルを非破壊的に左へ移動させる等)。

     入力のファイル終端は、文字列 ‘'EOF'’ として渡されます。

     An interpreter instance will recognize a command name ‘foo’ if and
     only if it has a method ‘do_foo()’.  As a special case, a line
     beginning with the character ‘'?'’ is dispatched to the method
     *note do_help(): 1618.  As another special case, a line beginning
     with the character ‘'!'’ is dispatched to the method ‘do_shell()’
     (if such a method is defined).

     This method will return when the *note postcmd(): 3c98. method
     returns a true value.  The 'stop' argument to *note postcmd():
     3c98. is the return value from the command's corresponding ‘do_*()’
     method.

     If completion is enabled, completing commands will be done
     automatically, and completing of commands args is done by calling
     ‘complete_foo()’ with arguments 'text', 'line', 'begidx', and
     'endidx'.  'text' is the string prefix we are attempting to match:
     all returned matches must begin with it.  'line' is the current
     input line with leading whitespace removed, 'begidx' and 'endidx'
     are the beginning and ending indexes of the prefix text, which
     could be used to provide different completion depending upon which
     position the argument is in.

 -- メソッド: Cmd.do_help (arg)

     All subclasses of *note Cmd: 162b. inherit a predefined
     ‘do_help()’.  This method, called with an argument ‘'bar'’, invokes
     the corresponding method ‘help_bar()’, and if that is not present,
     prints the docstring of ‘do_bar()’, if available.  With no
     argument, ‘do_help()’ lists all available help topics (that is, all
     commands with corresponding ‘help_*()’ methods or commands that
     have docstrings), and also lists any undocumented commands.

 -- メソッド: Cmd.onecmd (str)

     Interpret the argument as though it had been typed in response to
     the prompt.  This may be overridden, but should not normally need
     to be; see the *note precmd(): 3c9a. and *note postcmd(): 3c98.
     methods for useful execution hooks.  The return value is a flag
     indicating whether interpretation of commands by the interpreter
     should stop.  If there is a ‘do_*()’ method for the command 'str',
     the return value of that method is returned, otherwise the return
     value from the *note default(): 3c9b. method is returned.

 -- メソッド: Cmd.emptyline ()

     プロンプトに空行が入力されたときに呼び出されるメソッド。このメソッ
     ドがオーバーライドされていないなら、最後に入力された空行でないコマ
     ンドが繰り返されます。

 -- メソッド: Cmd.default (line)

     コマンドの先頭の語が認識されないときに、入力行に対して呼び出されま
     す。このメソッドがオーバーライドされていないなら、エラーメッセージ
     を表示して戻ります。

 -- メソッド: Cmd.completedefault (text, line, begidx, endidx)

     Method called to complete an input line when no command-specific
     ‘complete_*()’ method is available.  By default, it returns an
     empty list.

 -- メソッド: Cmd.columnize (list, displaywidth=80)

     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.

 -- メソッド: Cmd.precmd (line)

     コマンド行 'line' が解釈実行される直前、しかし入力プロンプトが作ら
     れ表示された後に実行されるフックメソッド。このメソッドは *note Cmd:
     162b. 内のスタブであって、サブクラスでオーバーライドされるために存
     在します。戻り値は *note onecmd(): 3c99. メソッドが実行するコマンド
     として使われます。 *note precmd(): 3c9a. の実装では、コマンドを書き
     換えるかもしれないし、あるいは単に変更していない 'line' を返すかも
     しれません。

 -- メソッド: Cmd.postcmd (stop, line)

     コマンドディスパッチが終わった直後に実行されるフックメソッド。この
     メソッドは *note Cmd: 162b. 内のスタブで、サブクラスでオーバーライ
     ドされるために存在します。 'line' は実行されたコマンド行で、 'stop'
     は *note postcmd(): 3c98. の呼び出しの後に実行を停止するかどうかを
     示すフラグです。これは *note onecmd(): 3c99. メソッドの戻り値です。
     このメソッドの戻り値は、 'stop' に対応する内部フラグの新しい値とし
     て使われます。偽を返すと、実行を続けます。

 -- メソッド: Cmd.preloop ()

     *note cmdloop(): 3c96. が呼び出されたときに一度だけ実行されるフック
     メソッド。このメソッドは *note Cmd: 162b. 内のスタブであって、サブ
     クラスでオーバーライドされるために存在します。

 -- メソッド: Cmd.postloop ()

     *note cmdloop(): 3c96. が戻る直前に一度だけ実行されるフックメソッド
     。このメソッドは *note Cmd: 162b. 内のスタブであって、サブクラスで
     オーバーライドされるために存在します。

*note Cmd: 162b. のサブクラスのインスタンスは、公開されたインスタンス変
数をいくつか持っています:

 -- の属性: Cmd.prompt

     入力を求めるために表示されるプロンプト。

 -- の属性: Cmd.identchars

     コマンドの先頭の語として受け入れられる文字の文字列。

 -- の属性: Cmd.lastcmd

     最後の空でないコマンド接頭辞。

 -- の属性: Cmd.cmdqueue

     キューに入れられた入力行のリスト。cmdqueue リストは新たな入力が必要
     な際に *note cmdloop(): 3c96. 内でチェックされます; これが空でない
     場合、その要素は、あたかもプロンプトから入力されたかのように順に処
     理されます。

 -- の属性: Cmd.intro

     イントロあるいはバナーとして表示される文字列。 *note cmdloop():
     3c96. メソッドに引数を与えるために、オーバーライドされるかもしれま
     せん。

 -- の属性: Cmd.doc_header

     ヘルプ出力に文書化されたコマンドのセクションがある場合に表示するヘ
     ッダ。

 -- の属性: Cmd.misc_header

     The header to issue if the help output has a section for
     miscellaneous help topics (that is, there are ‘help_*()’ methods
     without corresponding ‘do_*()’ methods).

 -- の属性: Cmd.undoc_header

     The header to issue if the help output has a section for
     undocumented commands (that is, there are ‘do_*()’ methods without
     corresponding ‘help_*()’ methods).

 -- の属性: Cmd.ruler

     ヘルプメッセージのヘッダの下に、区切り行を表示するために使われる文
     字。空のときは、ルーラ行が表示されません。デフォルトでは、‘'='’ で
     す。

 -- の属性: Cmd.use_rawinput

     A flag, defaulting to true.  If true, *note cmdloop(): 3c96. uses
     *note input(): 12a6. to display a prompt and read the next command;
     if false, *note sys.stdout.write(): aa4. and *note
     sys.stdin.readline(): 507. are used.  (This means that by importing
     *note readline: a8, on systems that support it, the interpreter
     will automatically support ‘Emacs’-like line editing and
     command-history keystrokes.)


File: python.info,  Node: Cmd の例,  Prev: Cmdオブジェクト,  Up: cmd --- 行指向のコマンドインタープリターのサポート

5.24.2.2 Cmd の例
.................

*note cmd: 12. モジュールは、ユーザーがプログラムと対話的に連携できるカ
スタムシェルを構築するのに主に役立ちます。

この節では、*note turtle: ea. モジュールのいくつかのコマンドを持ったシェ
ルの作成方法の簡単な例を示します。

Basic turtle commands such as *note forward(): 3bf3. are added to a
*note Cmd: 162b. subclass with method named ‘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.

The example also includes a basic record and playback facility
implemented with the *note precmd(): 3c9a. method which is responsible
for converting the input to lowercase and writing the commands to a
file.  The ‘do_playback()’ method reads the file and adds the recorded
commands to the *note cmdqueue: 3ca3. for immediate playback:

     import cmd, sys
     from turtle import *

     class TurtleShell(cmd.Cmd):
         intro = 'Welcome to the turtle shell.   Type help or ? to list commands.\n'
         prompt = '(turtle) '
         file = None

         # ----- basic turtle commands -----
         def do_forward(self, arg):
             'Move the turtle forward by the specified distance:  FORWARD 10'
             forward(*parse(arg))
         def do_right(self, arg):
             'Turn turtle right by given number of degrees:  RIGHT 20'
             right(*parse(arg))
         def do_left(self, arg):
             'Turn turtle left by given number of degrees:  LEFT 90'
             left(*parse(arg))
         def do_goto(self, arg):
             'Move turtle to an absolute position with changing orientation.  GOTO 100 200'
             goto(*parse(arg))
         def do_home(self, arg):
             'Return turtle to the home position:  HOME'
             home()
         def do_circle(self, arg):
             'Draw circle with given radius an options extent and steps:  CIRCLE 50'
             circle(*parse(arg))
         def do_position(self, arg):
             'Print the current turtle position:  POSITION'
             print('Current position is %d %d\n' % position())
         def do_heading(self, arg):
             'Print the current turtle heading in degrees:  HEADING'
             print('Current heading is %d\n' % (heading(),))
         def do_color(self, arg):
             'Set the color:  COLOR BLUE'
             color(arg.lower())
         def do_undo(self, arg):
             'Undo (repeatedly) the last turtle action(s):  UNDO'
         def do_reset(self, arg):
             'Clear the screen and return turtle to center:  RESET'
             reset()
         def do_bye(self, arg):
             'Stop recording, close the turtle window, and exit:  BYE'
             print('Thank you for using Turtle')
             self.close()
             bye()
             return True

         # ----- record and playback -----
         def do_record(self, arg):
             'Save future commands to filename:  RECORD rose.cmd'
             self.file = open(arg, 'w')
         def do_playback(self, arg):
             'Playback commands from a file:  PLAYBACK rose.cmd'
             self.close()
             with open(arg) as f:
                 self.cmdqueue.extend(f.read().splitlines())
         def precmd(self, line):
             line = line.lower()
             if self.file and 'playback' not in line:
                 print(line, file=self.file)
             return line
         def close(self):
             if self.file:
                 self.file.close()
                 self.file = None

     def parse(arg):
         'Convert a series of zero or more numbers to an argument tuple'
         return tuple(map(int, arg.split()))

     if __name__ == '__main__':
         TurtleShell().cmdloop()

以下は、turtle シェルでの機能のヘルプ表示、空行によるコマンドの繰り返し
、単純な記録と再実行のセッション例です:

     Welcome to the turtle shell.   Type help or ? to list commands.

     (turtle) ?

     Documented commands (type help <topic>):
     ========================================
     bye     color    goto     home  playback  record  right
     circle  forward  heading  left  position  reset   undo

     (turtle) help forward
     Move the turtle forward by the specified distance:  FORWARD 10
     (turtle) record spiral.cmd
     (turtle) position
     Current position is 0 0

     (turtle) heading
     Current heading is 0

     (turtle) reset
     (turtle) circle 20
     (turtle) right 30
     (turtle) circle 40
     (turtle) right 30
     (turtle) circle 60
     (turtle) right 30
     (turtle) circle 80
     (turtle) right 30
     (turtle) circle 100
     (turtle) right 30
     (turtle) circle 120
     (turtle) right 30
     (turtle) circle 120
     (turtle) heading
     Current heading is 180

     (turtle) forward 100
     (turtle)
     (turtle) right 90
     (turtle) forward 100
     (turtle)
     (turtle) right 90
     (turtle) forward 400
     (turtle) right 90
     (turtle) forward 500
     (turtle) right 90
     (turtle) forward 400
     (turtle) right 90
     (turtle) forward 300
     (turtle) playback spiral.cmd
     Current position is 0 0

     Current heading is 0

     Current heading is 180

     (turtle) bye
     Thank you for using Turtle


File: python.info,  Node: shlex --- 単純な字句解析,  Prev: cmd --- 行指向のコマンドインタープリターのサポート,  Up: プログラムのフレームワーク

5.24.3 ‘shlex’ -- 単純な字句解析
--------------------------------

'ソースコード:' Lib/shlex.py(1)

__________________________________________________________________

*note shlex: c9b. クラスは Unix シェルに似た、単純な構文に対する字句解析
器を簡単に書けるようにします。このクラスはしばしば、 Python アプリケーシ
ョンのための実行制御ファイルのような小規模言語を書く上で便利です。

*note shlex: b2. モジュールは以下の関数を定義しています:

 -- の関数: shlex.split (s, comments=False, posix=True)

     シェルに似た文法を使って、文字列 's' を分割します。 'comments' が
     *note False: b05. (デフォルト値) の場合、受理した文字列内のコメント
     を解析しません (*note shlex: c9b. インスタンスの *note commenters:
     3cac. メンバの値を空文字列にします)。この関数はデフォルトでは POSIX
     モードで動作し、 'posix' 引数が偽の場合は非 POSIX モードで動作しま
     す。

     バージョン 3.12 で変更: Passing ‘None’ for 's' argument now raises
     an exception, rather than reading *note sys.stdin: 507.

 -- の関数: shlex.join (split_command)

     Concatenate the tokens of the list 'split_command' and return a
     string.  This function is the inverse of *note split(): 506.

          >>> from shlex import join
          >>> print(join(['echo', '-n', 'Multiple words']))
          echo -n 'Multiple words'

     The returned value is shell-escaped to protect against injection
     vulnerabilities (see *note quote(): 25e.).

     Added in version 3.8.

 -- の関数: shlex.quote (s)

     文字列 's' をシェルエスケープして返します。戻り値は、リストを使えな
     いようなケースで、シェルコマンドライン内で一つのトークンとして安全
     に利用出来る文字列です。
          警告: The ‘shlex’ module is 'only designed for Unix shells'.

          The *note quote(): 25e. function is not guaranteed to be
          correct on non-POSIX compliant shells or shells from other
          operating systems such as Windows.  Executing commands quoted
          by this module on such shells can open up the possibility of a
          command injection vulnerability.

          Consider using functions that pass command arguments with
          lists such as *note subprocess.run(): b54. with ‘shell=False’.

     以下のイディオムは安全ではないかもしれません:

          >>> filename = 'somefile; rm -rf ~'
          >>> command = 'ls -l {}'.format(filename)
          >>> print(command)  # executed by a shell: boom!
          ls -l somefile; rm -rf ~

     *note quote(): 25e. がそのセキュリティホールをふさぎます:

          >>> from shlex import quote
          >>> command = 'ls -l {}'.format(quote(filename))
          >>> print(command)
          ls -l 'somefile; rm -rf ~'
          >>> remote_command = 'ssh home {}'.format(quote(command))
          >>> print(remote_command)
          ssh home 'ls -l '"'"'somefile; rm -rf ~'"'"''

     クォーティングは UNIX シェルならびに *note split(): 506. と互換です
     :

          >>> from shlex import split
          >>> remote_command = split(remote_command)
          >>> remote_command
          ['ssh', 'home', "ls -l 'somefile; rm -rf ~'"]
          >>> command = split(remote_command[-1])
          >>> command
          ['ls', '-l', 'somefile; rm -rf ~']

     Added in version 3.3.

*note shlex: b2. モジュールは以下のクラスを定義します。

 -- クラス: shlex.shlex (instream=None, infile=None, posix=False,
          punctuation_chars=False)

     A *note shlex: c9b. instance or subclass instance is a lexical
     analyzer object.  The initialization argument, if present,
     specifies where to read characters from.  It must be a
     file-/stream-like object with *note read(): 1bef. and *note
     readline(): 1c27. methods, or a string.  If no argument is given,
     input will be taken from ‘sys.stdin’.  The second optional argument
     is a filename string, which sets the initial value of the *note
     infile: 3cad. attribute.  If the 'instream' argument is omitted or
     equal to ‘sys.stdin’, this second argument defaults to "stdin".
     The 'posix' argument defines the operational mode: when 'posix' is
     not true (default), the *note shlex: c9b. instance will operate in
     compatibility mode.  When operating in POSIX mode, *note shlex:
     c9b. will try to be as close as possible to the POSIX shell parsing
     rules.  The 'punctuation_chars' argument provides a way to make the
     behaviour even closer to how real shells parse.  This can take a
     number of values: the default value, ‘False’, preserves the
     behaviour seen under Python 3.5 and earlier.  If set to ‘True’,
     then parsing of the characters ‘();<>|&’ is changed: any run of
     these characters (considered punctuation characters) is returned as
     a single token.  If set to a non-empty string of characters, those
     characters will be used as the punctuation characters.  Any
     characters in the *note wordchars: 3cae. attribute that appear in
     'punctuation_chars' will be removed from *note wordchars: 3cae.
     See *note Improved Compatibility with Shells: c9c. for more
     information.  'punctuation_chars' can be set only upon *note shlex:
     c9b. instance creation and can't be modified later.

     バージョン 3.6 で変更: 'punctuation_chars' 引数が追加されました。

参考
....

*note configparser: 1b. モジュール

     Windows ‘.ini’ ファイルに似た設定ファイルのパーザ。

* Menu:

* shlex オブジェクト::
* 解析規則::
* Improved Compatibility with Shells::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/shlex.py


File: python.info,  Node: shlex オブジェクト,  Next: 解析規則,  Up: shlex --- 単純な字句解析

5.24.3.1 shlex オブジェクト
...........................

*note shlex: c9b. インスタンスは以下のメソッドを持っています:

 -- メソッド: shlex.get_token ()

     トークンを一つ返します。トークンが *note push_token(): 3cb2. で使っ
     てスタックに積まれていた場合、トークンをスタックからポップします。
     そうでない場合、トークンを一つ入力ストリームから読み出します。読み
     出し即時にファイル終了子に遭遇した場合、 *note eof: 3cb3. (非 POSIX
     モードでは空文字列 (‘''’)、POSIX モードでは ‘None’) が返されます。

 -- メソッド: shlex.push_token (str)

     トークンスタックに引数文字列をスタックします。

 -- メソッド: shlex.read_token ()

     生 (raw) のトークンを読み出します。プッシュバックスタックを無視し、
     かつソースリクエストを解釈しません (通常これは便利なエントリポイン
     トではありません。完全性のためにここで記述されています)。

 -- メソッド: shlex.sourcehook (filename)

     *note shlex: c9b. がソースリクエスト (下の *note source: 3cb6. を参
     照してください) を検出した際、このメソッドはその後に続くトークンを
     引数として渡され、ファイル名と開かれたファイル類似オブジェクトから
     なるタプルを返すとされています。

     通常、このメソッドはまず引数から何らかのクオートを取り除きます。処
     理後の引数が絶対パス名であった場合か、以前に有効になったソースリク
     エストが存在しない場合か、以前のソースが (‘sys.stdin’ のような) ス
     トリームであった場合、この結果はそのままにされます。そうでない場合
     で、処理後の引数が相対パス名の場合、ソースインクルードスタックにあ
     る直前のファイル名からディレクトリ部分が取り出され、相対パスの前の
     部分に追加されます (この動作は C 言語プリプロセッサにおける
     ‘#include "file.h"’ の扱いと同様です)。

     これらの操作の結果はファイル名として扱われ、タプルの最初の要素とし
     て返されます。同時にこのファイル名で *note open(): 4e5. を呼び出し
     た結果が二つ目の要素になります (注意: インスタンス初期化のときとは
     引数の並びが逆になっています！)

     このフックはディレクトリサーチパスや、ファイル拡張子の追加、その他
     の名前空間に関するハックを実装できるようにするために公開されていま
     す。 'close' フックに対応するものはありませんが、shlex インスタンス
     はソースリクエストされている入力ストリームが EOF を返した時には
     *note close(): 1d7. を呼び出します。

     ソーススタックをより明示的に操作するには、 *note push_source():
     3cb7. および *note pop_source(): 3cb8. メソッドを使ってください。

 -- メソッド: shlex.push_source (newstream, newfile=None)

     入力ソースストリームを入力スタックにプッシュします。ファイル名引数
     が指定された場合、以後のエラーメッセージ中で利用することができます
     。 *note sourcehook(): 3cb5. メソッドが内部で使用しているのと同じメ
     ソッドです。

 -- メソッド: shlex.pop_source ()

     最後にプッシュされた入力ソースを入力スタックからポップします。字句
     解析器がスタック上の入力ストリームの EOF に到達した際に利用するメソ
     ッドと同じです。

 -- メソッド: shlex.error_leader (infile=None, lineno=None)

     このメソッドはエラーメッセージの論述部分を Unix C コンパイラエラー
     ラベルの形式で生成します; この書式は ‘'"%s", line %d: '’ で、 ‘%s’
     は現在のソースファイル名で置き換えられ、 ‘%d’ は現在の入力行番号で
     置き換えられます (オプションの引数を使ってこれらを上書きすることも
     できます)。

     このやり方は、 *note shlex: b2. のユーザに対して、Emacs やその他の
     Unix ツール群が解釈できる一般的な書式でのメッセージを生成することを
     推奨するために提供されています。

*note shlex: c9b. サブクラスのインスタンスは、字句解析を制御したり、デバ
ッグに使えるような public なインスタンス変数を持っています:

 -- の属性: shlex.commenters

     コメントの開始として認識される文字列です。コメントの開始から行末ま
     でのすべてのキャラクタ文字は無視されます。標準では単に ‘'#'’ が入っ
     ています。

 -- の属性: shlex.wordchars

     The string of characters that will accumulate into multi-character
     tokens.  By default, includes all ASCII alphanumerics and
     underscore.  In POSIX mode, the accented characters in the Latin-1
     set are also included.  If *note punctuation_chars: 193c. is not
     empty, the characters ‘~-./*?=’, which can appear in filename
     specifications and command line parameters, will also be included
     in this attribute, and any characters which appear in
     ‘punctuation_chars’ will be removed from ‘wordchars’ if they are
     present there.  If *note whitespace_split: 3cba. is set to ‘True’,
     this will have no effect.

 -- の属性: shlex.whitespace

     空白と見なされ、読み飛ばされる文字群です。空白はトークンの境界を作
     ります。標準では、スペース、タブ、改行 (linefeed) および復帰
     (carriage-return) が入っています。

 -- の属性: shlex.escape

     エスケープ文字と見なされる文字群です。これは POSIX モードでのみ使わ
     れ、デフォルトでは ‘'\'’ だけが入っています。

 -- の属性: shlex.quotes

     文字列引用符と見なされる文字群です。トークンを構成する際、同じクオ
     ートが再び出現するまで文字をバッファに蓄積します (すなわち、異なる
     クオート形式はシェル中で互いに保護し合う関係にあります)。標準では、
     ASCII 単引用符および二重引用符が入っています。

 -- の属性: shlex.escapedquotes

     *note quotes: 3cbd. のうち、 *note escape: 3cbc. で定義されたエスケ
     ープ文字を解釈する文字群です。これは POSIX モードでのみ使われ、デフ
     ォルトでは ‘'"'’ だけが入っています。

 -- の属性: shlex.whitespace_split

     If ‘True’, tokens will only be split in whitespaces.  This is
     useful, for example, for parsing command lines with *note shlex:
     c9b, getting tokens in a similar way to shell arguments.  When used
     in combination with *note punctuation_chars: 193c, tokens will be
     split on whitespace in addition to those characters.

     バージョン 3.8 で変更: The *note punctuation_chars: 193c. attribute
     was made compatible with the *note whitespace_split: 3cba.
     attribute.

 -- の属性: shlex.infile

     現在の入力ファイル名です。クラスのインスタンス化時に初期設定される
     か、その後のソースリクエストでスタックされます。エラーメッセージを
     構成する際にこの値を調べると便利なことがあります。

 -- の属性: shlex.instream

     *note shlex: c9b. インスタンスが文字を読み出している入力ストリーム
     です。

 -- の属性: shlex.source

     このメンバ変数は標準で *note None: 641. を取ります。この値に文字列
     を代入すると、その文字列は多くのシェルにおける ‘source’ キーワード
     に似た、字句解析レベルでのインクルード要求として認識されます。すな
     わち、その直後に現れるトークンをファイル名として新たなストリームを
     開き、そのストリームを入力として、EOF に到達するまで読み込まれます
     。新たなストリームの EOF に到達した時点で *note close(): 1d7. が呼
     び出され、入力は元の入力ストリームに戻されます。ソースリクエストは
     任意のレベルの深さまでスタックしてかまいません。

 -- の属性: shlex.debug

     このメンバ変数が数値で、かつ ‘1’ またはそれ以上の値の場合、 *note
     shlex: c9b. インスタンスは動作に関する冗長な進捗報告を出力します。
     この出力を使いたいなら、モジュールのソースコードを読めば詳細を学ぶ
     ことができます。

 -- の属性: shlex.lineno

     ソース行番号 (遭遇した改行の数に 1 を加えたもの) です。

 -- の属性: shlex.token

     トークンバッファです。例外を捕捉した際にこの値を調べると便利なこと
     があります。

 -- の属性: shlex.eof

     ファイルの終端を決定するのに使われるトークンです。非 POSIX モードで
     は空文字列 (‘''’) 、POSIX モードでは ‘None’ が入ります。

 -- の属性: shlex.punctuation_chars

     A read-only property.  Characters that will be considered
     punctuation.  Runs of punctuation characters will be returned as a
     single token.  However, note that no semantic validity checking
     will be performed: for example, '>>>' could be returned as a token,
     even though it may not be recognised as such by shells.

     Added in version 3.6.


File: python.info,  Node: 解析規則,  Next: Improved Compatibility with Shells,  Prev: shlex オブジェクト,  Up: shlex --- 単純な字句解析

5.24.3.2 解析規則
.................

非 POSIX モードで動作中の *note shlex: c9b. は以下の規則に従おうとします
。

   * ワード内の引用符を認識しない (‘Do"Not"Separate’ は単一ワード
     ‘Do"Not"Separate’ として解析されます)

   * エスケープ文字を認識しない

   * 引用符で囲まれた文字列は、引用符内の全ての文字リテラルを保持する

   * 閉じ引用符でワードを区切る (‘"Do"Separate’ は、 ‘"Do"’ と
     ‘Separate’ であると解析されます)

   * *note whitespace_split: 3cba. が ‘False’ の場合、wordchar、
     whitespace または quote として宣言されていない全ての文字を、単一の
     文字トークンとして返す。 ‘True’ の場合、 *note shlex: c9b. は空白文
     字でのみ単語を区切る。

   * 空文字列 (‘''’) で EOF を送出する

   * 引用符に囲んであっても、空文字列を解析しない

POSIX モードで動作中の *note shlex: c9b. は以下の解析規則に従おうとしま
す。

   * 引用符を取り除き、引用符で単語を分解しない (‘"Do"Not"Separate"’ は
     単一ワード ‘DoNotSeparate’ として解析されます)

   * 引用符で囲まれないエスケープ文字群 (‘'\'’ など) は直後に続く文字の
     リテラル値を保持する

   * *note escapedquotes: 3cbe. でない引用符文字 (‘"'"’ など) で囲まれて
     いる全ての文字のリテラル値を保持する

   * 引用符に囲まれた *note escapedquotes: 3cbe. に含まれる文字 (‘'"'’ な
     ど) は、 *note escape: 3cbc. に含まれる文字を除き、全ての文字のリテ
     ラル値を保持する。エスケープ文字群は使用中の引用符、または、そのエ
     スケープ文字自身が直後にある場合のみ、特殊な機能を保持する。他の場
     合にはエスケープ文字は普通の文字とみなされる。

   * *note None: 641. で EOF を送出する

   * 引用符に囲まれた空文字列 (‘''’) を許す。


File: python.info,  Node: Improved Compatibility with Shells,  Prev: 解析規則,  Up: shlex --- 単純な字句解析

5.24.3.3 Improved Compatibility with Shells
...........................................

Added in version 3.6.

The *note shlex: b2. class provides compatibility with the parsing
performed by common Unix shells like ‘bash’, ‘dash’, and ‘sh’.  To take
advantage of this compatibility, specify the ‘punctuation_chars’
argument in the constructor.  This defaults to ‘False’, which preserves
pre-3.6 behaviour.  However, if it is set to ‘True’, then parsing of the
characters ‘();<>|&’ is changed: any run of these characters is returned
as a single token.  While this is short of a full parser for shells
(which would be out of scope for the standard library, given the
multiplicity of shells out there), it does allow you to perform
processing of command lines more easily than you could otherwise.  To
illustrate, you can see the difference in the following snippet:

     >>> import shlex
     >>> text = "a && b; c && d || e; f >'abc'; (def \"ghi\")"
     >>> s = shlex.shlex(text, posix=True)
     >>> s.whitespace_split = True
     >>> list(s)
     ['a', '&&', 'b;', 'c', '&&', 'd', '||', 'e;', 'f', '>abc;', '(def', 'ghi)']
     >>> s = shlex.shlex(text, posix=True, punctuation_chars=True)
     >>> s.whitespace_split = True
     >>> list(s)
     ['a', '&&', 'b', ';', 'c', '&&', 'd', '||', 'e', ';', 'f', '>', 'abc', ';',
     '(', 'def', 'ghi', ')']

Of course, tokens will be returned which are not valid for shells, and
you'll need to implement your own error checks on the returned tokens.

Instead of passing ‘True’ as the value for the punctuation_chars
parameter, you can pass a string with specific characters, which will be
used to determine which characters constitute punctuation.  For example:

     >>> import shlex
     >>> s = shlex.shlex("a && b || c", punctuation_chars="|")
     >>> list(s)
     ['a', '&', '&', 'b', '||', 'c']

     注釈: When ‘punctuation_chars’ is specified, the *note wordchars:
     3cae. attribute is augmented with the characters ‘~-./*?=’.  That
     is because these characters can appear in file names (including
     wildcards) and command-line arguments (e.g.  ‘--color=auto’).
     Hence:

          >>> import shlex
          >>> s = shlex.shlex('~/a && b-c --color=auto || d *.py?',
          ...                 punctuation_chars=True)
          >>> list(s)
          ['~/a', '&&', 'b-c', '--color=auto', '||', 'd', '*.py?']

     However, to match the shell as closely as possible, it is
     recommended to always use ‘posix’ and *note whitespace_split: 3cba.
     when using *note punctuation_chars: 193c, which will negate *note
     wordchars: 3cae. entirely.

For best effect, ‘punctuation_chars’ should be set in conjunction with
‘posix=True’.  (Note that ‘posix=False’ is the default for *note shlex:
c9b.)


File: python.info,  Node: Tk を用いたグラフィカルユーザーインターフェース,  Next: 開発ツール,  Prev: プログラムのフレームワーク,  Up: Python 標準ライブラリ

5.25 Tk を用いたグラフィカルユーザーインターフェース
====================================================

Tk/Tcl は長きにわたり Python の不可欠な一部でありつづけています。 Tk/Tcl
は頑健でプラットホームに依存しないウィンドウ構築ツールキットであり、
Python プログラマは *note tkinter: d9. パッケージやその拡張の *note
tkinter.ttk: e2. モジュールを使って利用できます。

*note tkinter: d9. パッケージはオブジェクトの薄い層で作ったTcl/Tkの最上
層です。*note tkinter: d9. を使うには、Tcl のコードを書く必要はありませ
んが、Tk のドキュメント、またはときどき、Tcl のドキュメントを調べる 必要
が出て来ます。*note tkinter: d9. は Python クラスとして実装した Tk ウィ
ジェットのラッパーの集合です。

*note tkinter: d9. の一番素晴らしい点は、速く、そしてほとんどの Python に
付属していることです。標準ドキュメントが頼りないものだとしても、代わりと
なる、リファレンス、チュートリアル、書籍その他が入手可能です。*note
tkinter: d9. は古臭いルックアンドフィールでも有名ですが、その点は Tk 8.5
で大きく改善されました。とはいえ、他にも興味を引きそうな GUI ライブラリ
は多数あります。 Python wiki には、いくつかの代替の GUI フレームワークと
ツール(1) の一覧があります。

* Menu:

* tkinter: tkinter --- Tcl/Tk の Python インターフェース. Tcl/Tk の Python インターフェース
* tkinter.colorchooser: tkinter colorchooser --- カラー選択ダイアログ. カラー選択ダイアログ
* tkinter.font: tkinter font --- Tkinter フォントラッパー. Tkinter フォントラッパー
* Tkinter ダイアログ::
* tkinter.messagebox: tkinter messagebox --- Tkinter メッセージプロンプト. Tkinter メッセージプロンプト
* tkinter.scrolledtext: tkinter scrolledtext --- スクロール可能なテキストウィジェット. スクロール可能なテキストウィジェット
* tkinter.dnd: tkinter dnd --- ドラッグアンドドロップのサポート. ドラッグアンドドロップのサポート
* tkinter.ttk: tkinter ttk --- Tk のテーマ付きウィジェット. Tk のテーマ付きウィジェット
* IDLE: IDLE<64>.

   ---------- Footnotes ----------

   (1) https://wiki.python.org/moin/GuiProgramming


File: python.info,  Node: tkinter --- Tcl/Tk の Python インターフェース,  Next: tkinter colorchooser --- カラー選択ダイアログ,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.1 ‘tkinter’ -- Tcl/Tk の Python インターフェース
-----------------------------------------------------

'ソースコード:' Lib/tkinter/__init__.py(1)

__________________________________________________________________

*note tkinter: d9. パッケージ ("Tk インターフェース") は、 Tcl/Tk GUI ツ
ールキットに対する標準の Python インターフェースです。 Tk と *note
tkinter: d9. は macOS を含むほとんどの Unix プラットフォームの他、
Windows システム上でも利用できます。

コマンドラインから ‘python -m tkinter’ を実行すると簡素な Tk インターフ
ェースを表示するウィンドウが開き、システムに *note tkinter: d9. が正しく
インストールされたことが分かり、さらにインストールされた Tcl/Tk がどのバ
ーションなのかが表示されるので、そのバージョンの Tcl/Tk ドキュメントを選
んで読めます。

Tkinter supports a range of Tcl/Tk versions, built either with or
without thread support.  The official Python binary release bundles
Tcl/Tk 8.6 threaded.  See the source code for the *note _tkinter: 3.
module for more information about supported versions.

Tkinter is not a thin wrapper, but adds a fair amount of its own logic
to make the experience more pythonic.  This documentation will
concentrate on these additions and changes, and refer to the official
Tcl/Tk documentation for details that are unchanged.

     注釈: Tcl/Tk 8.5 (2007) introduced a modern set of themed user
     interface components along with a new API to use them.  Both old
     and new APIs are still available.  Most documentation you will find
     online still uses the old API and can be woefully outdated.

参考
....

   * 
     TkDocs(2)

          Extensive tutorial on creating user interfaces with Tkinter.
          Explains key concepts, and illustrates recommended approaches
          using the modern API.

   * 
     Tkinter 8.5 reference: a GUI for Python(3)

          Reference documentation for Tkinter 8.5 detailing available
          classes, methods, and options.

Tcl/Tk Resources:

   * 
     Tk commands(4)

          Comprehensive reference to each of the underlying Tcl/Tk
          commands used by Tkinter.

   * 
     Tcl/Tk ホームページ(5)

          Additional documentation, and links to Tcl/Tk core
          development.

Books:

   * 
     Modern Tkinter for Busy Python Developers(6)

          By Mark Roseman.  (ISBN 978-1999149567)

   * 
     Python GUI programming with Tkinter(7)

          By Alan D. Moore.  (ISBN 978-1788835886)

   * 
     Programming Python(8)

          By Mark Lutz; has excellent coverage of Tkinter.  (ISBN
          978-0596158101)

   * 
     Tcl and the Tk Toolkit (2nd edition)(9)

          By John Ousterhout, inventor of Tcl/Tk, and Ken Jones; does
          not cover Tkinter.  (ISBN 978-0321336330)

* Menu:

* Architecture::
* Tkinter モジュール::
* Tkinter お助け手帳::
* Threading model::
* 簡単なリファレンス::
* ファイルハンドラ::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/tkinter/__init__.py

   (2) https://tkdocs.com/

   (3) https://www.tkdocs.com/shipman/

   (4) https://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm

   (5) https://www.tcl.tk

   (6) https://tkdocs.com/book.html

   (7) 
https://www.packtpub.com/en-us/product/python-gui-programming-with-tkinter-9781788835886

   (8) https://learning-python.com/about-pp4e.html

   (9) https://www.amazon.com/exec/obidos/ASIN/032133633X


File: python.info,  Node: Architecture,  Next: Tkinter モジュール,  Up: tkinter --- Tcl/Tk の Python インターフェース

5.25.1.1 Architecture
.....................

Tcl/Tk is not a single library but rather consists of a few distinct
modules, each with separate functionality and its own official
documentation.  Python's binary releases also ship an add-on module
together with it.

Tcl

     Tcl is a dynamic interpreted programming language, just like
     Python.  Though it can be used on its own as a general-purpose
     programming language, it is most commonly embedded into C
     applications as a scripting engine or an interface to the Tk
     toolkit.  The Tcl library has a C interface to create and manage
     one or more instances of a Tcl interpreter, run Tcl commands and
     scripts in those instances, and add custom commands implemented in
     either Tcl or C. Each interpreter has an event queue, and there are
     facilities to send events to it and process them.  Unlike Python,
     Tcl's execution model is designed around cooperative multitasking,
     and Tkinter bridges this difference (see *note Threading model:
     3ccc. for details).

Tk

     Tk is a Tcl package(1) implemented in C that adds custom commands
     to create and manipulate GUI widgets.  Each *note Tk: 159a. object
     embeds its own Tcl interpreter instance with Tk loaded into it.
     Tk's widgets are very customizable, though at the cost of a dated
     appearance.  Tk uses Tcl's event queue to generate and process GUI
     events.

Ttk

     Themed Tk (Ttk) is a newer family of Tk widgets that provide a much
     better appearance on different platforms than many of the classic
     Tk widgets.  Ttk is distributed as part of Tk, starting with Tk
     version 8.5.  Python bindings are provided in a separate module,
     *note tkinter.ttk: e2.

Internally, Tk and Ttk use facilities of the underlying operating
system, i.e., Xlib on Unix/X11, Cocoa on macOS, GDI on Windows.

When your Python application uses a class in Tkinter, e.g., to create a
widget, the *note tkinter: d9. module first assembles a Tcl/Tk command
string.  It passes that Tcl command string to an internal *note
_tkinter: 3. binary module, which then calls the Tcl interpreter to
evaluate it.  The Tcl interpreter will then call into the Tk and/or Ttk
packages, which will in turn make calls to Xlib, Cocoa, or GDI.

   ---------- Footnotes ----------

   (1) https://wiki.tcl-lang.org/37432


File: python.info,  Node: Tkinter モジュール,  Next: Tkinter お助け手帳,  Prev: Architecture,  Up: tkinter --- Tcl/Tk の Python インターフェース

5.25.1.2 Tkinter モジュール
...........................

Support for Tkinter is spread across several modules.  Most applications
will need the main *note tkinter: d9. module, as well as the *note
tkinter.ttk: e2. module, which provides the modern themed widget set and
API:

     from tkinter import *
     from tkinter import ttk

 -- クラス: tkinter.Tk (screenName=None, baseName=None, className='Tk',
          useTk=True, sync=False, use=None)

     Construct a toplevel Tk widget, which is usually the main window of
     an application, and initialize a Tcl interpreter for this widget.
     Each instance has its own associated Tcl interpreter.

     The *note Tk: 159a. class is typically instantiated using all
     default values.  However, the following keyword arguments are
     currently recognized:

     'screenName'

          When given (as a string), sets the ‘DISPLAY’ environment
          variable.  (X11 only)

     'baseName'

          Name of the profile file.  By default, 'baseName' is derived
          from the program name (‘sys.argv[0]’).

     'className'

          Name of the widget class.  Used as a profile file and also as
          the name with which Tcl is invoked ('argv0' in 'interp').

     'useTk'

          If ‘True’, initialize the Tk subsystem.  The *note
          tkinter.Tcl(): 3cce. function sets this to ‘False’.

     'sync'

          If ‘True’, execute all X server commands synchronously, so
          that errors are reported immediately.  Can be used for
          debugging.  (X11 only)

     'use'

          Specifies the 'id' of the window in which to embed the
          application, instead of it being created as an independent
          toplevel window.  'id' must be specified in the same way as
          the value for the -use option for toplevel widgets (that is,
          it has a form like that returned by ‘winfo_id()’).

          Note that on some platforms this will only work correctly if
          'id' refers to a Tk frame or toplevel that has its -container
          option enabled.

     *note Tk: 159a. reads and interprets profile files, named
     ‘.`className'.tcl’ and ‘.`baseName'.tcl’, into the Tcl interpreter
     and calls *note exec(): 164. on the contents of ‘.`className'.py’
     and ‘.`baseName'.py’.  The path for the profile files is the ‘HOME’
     environment variable or, if that isn't defined, then *note
     os.curdir: 272b.

      -- の属性: tk

          The Tk application object created by instantiating *note Tk:
          159a.  This provides access to the Tcl interpreter.  Each
          widget that is attached the same instance of *note Tk: 159a.
          has the same value for its *note tk: 3ccf. attribute.

      -- の属性: master

          The widget object that contains this widget.  For *note Tk:
          159a, the 'master' is *note None: 641. because it is the main
          window.  The terms 'master' and 'parent' are similar and
          sometimes used interchangeably as argument names; however,
          calling ‘winfo_parent()’ returns a string of the widget name
          whereas *note master: 3cd0. returns the object.
          'parent'/'child' reflects the tree-like relationship while
          'master'/'slave' reflects the container structure.

      -- の属性: children

          The immediate descendants of this widget as a *note dict: 237.
          with the child widget names as the keys and the child instance
          objects as the values.

 -- の関数: tkinter.Tcl (screenName=None, baseName=None, className='Tk',
          useTk=False)

     *note Tcl(): 3cce. はファクトリ関数で、 *note Tk: 159a. クラスで生
     成するオブジェクトとよく似たオブジェクトを生成します。ただし Tk サ
     ブシステムを初期化しません。この関数は、余分なトップレベルウィンド
     ウを作る必要がなかったり、 (X サーバを持たない Unix/Linux システム
     などのように) 作成できない環境において Tcl インタプリタを駆動したい
     場合に便利です。 *note Tcl(): 3cce. で生成したオブジェクトに対して
     ‘loadtk()’ メソッドを呼び出せば、トップレベルウィンドウを作成 (して
     、Tk サブシステムを初期化) します。

The modules that provide Tk support include:

*note tkinter: d9.

     Main Tkinter module.

*note tkinter.colorchooser: da.

     ユーザに色を選択させるためのダイアログです。

*note tkinter.commondialog: db.

     このリストの他のモジュールが定義しているダイアログの基底クラスです
     。

*note tkinter.filedialog: dd.

     ユーザが開きたいファイルや保存したいファイルを指定できるようにする
     共通のダイアログです。

*note tkinter.font: de.

     フォントの扱いを補助するためのユーティリティです。

*note tkinter.messagebox: df.

     標準的な Tk のダイアログボックスにアクセスします。

*note tkinter.scrolledtext: e0.

     垂直スクロールバー付きのテキストウィジェットです。

*note tkinter.simpledialog: e1.

     基本的なダイアログと便宜関数 (convenience function) です。

*note tkinter.ttk: e2.

     Themed widget set introduced in Tk 8.5, providing modern
     alternatives for many of the classic widgets in the main *note
     tkinter: d9. module.

Additional modules:

*note _tkinter: 3.

     A binary module that contains the low-level interface to Tcl/Tk.
     It is automatically imported by the main *note tkinter: d9. module,
     and should never be used directly by application programmers.  It
     is usually a shared library (or DLL), but might in some cases be
     statically linked with the Python interpreter.

*note idlelib: 69.

     Python's Integrated Development and Learning Environment (IDLE).
     Based on *note tkinter: d9.

‘tkinter.constants’

     Symbolic constants that can be used in place of strings when
     passing various parameters to Tkinter calls.  Automatically
     imported by the main *note tkinter: d9. module.

*note tkinter.dnd: dc.

     (experimental) Drag-and-drop support for *note tkinter: d9.  This
     will become deprecated when it is replaced with the Tk DND.

*note turtle: ea.

     Tk ウィンドウ上でタートルグラフィックスを実現します。


File: python.info,  Node: Tkinter お助け手帳,  Next: Threading model,  Prev: Tkinter モジュール,  Up: tkinter --- Tcl/Tk の Python インターフェース

5.25.1.3 Tkinter お助け手帳
...........................

This section is not designed to be an exhaustive tutorial on either Tk
or Tkinter.  For that, refer to one of the external resources noted
earlier.  Instead, this section provides a very quick orientation to
what a Tkinter application looks like, identifies foundational Tk
concepts, and explains how the Tkinter wrapper is structured.

The remainder of this section will help you to identify the classes,
methods, and options you'll need in your Tkinter application, and where
to find more detailed documentation on them, including in the official
Tcl/Tk reference manual.

* Menu:

* A Hello World Program::
* Important Tk Concepts::
* Understanding How Tkinter Wraps Tcl/Tk::
* How do I...? What option does...?: How do I ? What option does ?.
* Navigating the Tcl/Tk Reference Manual::


File: python.info,  Node: A Hello World Program,  Next: Important Tk Concepts,  Up: Tkinter お助け手帳

5.25.1.4 A Hello World Program
..............................

We'll start by walking through a "Hello World" application in Tkinter.
This isn't the smallest one we could write, but has enough to illustrate
some key concepts you'll need to know.

     from tkinter import *
     from tkinter import ttk
     root = Tk()
     frm = ttk.Frame(root, padding=10)
     frm.grid()
     ttk.Label(frm, text="Hello World!").grid(column=0, row=0)
     ttk.Button(frm, text="Quit", command=root.destroy).grid(column=1, row=0)
     root.mainloop()

After the imports, the next line creates an instance of the ‘Tk’ class,
which initializes Tk and creates its associated Tcl interpreter.  It
also creates a toplevel window, known as the root window, which serves
as the main window of the application.

The following line creates a frame widget, which in this case will
contain a label and a button we'll create next.  The frame is fit inside
the root window.

The next line creates a label widget holding a static text string.  The
‘grid()’ method is used to specify the relative layout (position) of the
label within its containing frame widget, similar to how tables in HTML
work.

A button widget is then created, and placed to the right of the label.
When pressed, it will call the ‘destroy()’ method of the root window.

Finally, the ‘mainloop()’ method puts everything on the display, and
responds to user input until the program terminates.


File: python.info,  Node: Important Tk Concepts,  Next: Understanding How Tkinter Wraps Tcl/Tk,  Prev: A Hello World Program,  Up: Tkinter お助け手帳

5.25.1.5 Important Tk Concepts
..............................

Even this simple program illustrates the following key Tk concepts:

widgets

     A Tkinter user interface is made up of individual 'widgets'.  Each
     widget is represented as a Python object, instantiated from classes
     like ‘ttk.Frame’, ‘ttk.Label’, and ‘ttk.Button’.

widget hierarchy

     Widgets are arranged in a 'hierarchy'.  The label and button were
     contained within a frame, which in turn was contained within the
     root window.  When creating each 'child' widget, its 'parent'
     widget is passed as the first argument to the widget constructor.

configuration options

     Widgets have 'configuration options', which modify their appearance
     and behavior, such as the text to display in a label or button.
     Different classes of widgets will have different sets of options.

geometry management

     Widgets aren't automatically added to the user interface when they
     are created.  A 'geometry manager' like ‘grid’ controls where in
     the user interface they are placed.

event loop

     Tkinter reacts to user input, changes from your program, and even
     refreshes the display only when actively running an 'event loop'.
     If your program isn't running the event loop, your user interface
     won't update.


File: python.info,  Node: Understanding How Tkinter Wraps Tcl/Tk,  Next: How do I ? What option does ?,  Prev: Important Tk Concepts,  Up: Tkinter お助け手帳

5.25.1.6 Understanding How Tkinter Wraps Tcl/Tk
...............................................

When your application uses Tkinter's classes and methods, internally
Tkinter is assembling strings representing Tcl/Tk commands, and
executing those commands in the Tcl interpreter attached to your
application's ‘Tk’ instance.

Whether it's trying to navigate reference documentation, trying to find
the right method or option, adapting some existing code, or debugging
your Tkinter application, there are times that it will be useful to
understand what those underlying Tcl/Tk commands look like.

To illustrate, here is the Tcl/Tk equivalent of the main part of the
Tkinter script above.

     ttk::frame .frm -padding 10
     grid .frm
     grid [ttk::label .frm.lbl -text "Hello World!"] -column 0 -row 0
     grid [ttk::button .frm.btn -text "Quit" -command "destroy ."] -column 1 -row 0

Tcl's syntax is similar to many shell languages, where the first word is
the command to be executed, with arguments to that command following it,
separated by spaces.  Without getting into too many details, notice the
following:

   * The commands used to create widgets (like ‘ttk::frame’) correspond
     to widget classes in Tkinter.

   * Tcl widget options (like ‘-text’) correspond to keyword arguments
     in Tkinter.

   * Widgets are referred to by a 'pathname' in Tcl (like ‘.frm.btn’),
     whereas Tkinter doesn't use names but object references.

   * A widget's place in the widget hierarchy is encoded in its
     (hierarchical) pathname, which uses a ‘.’ (dot) as a path
     separator.  The pathname for the root window is just ‘.’ (dot).  In
     Tkinter, the hierarchy is defined not by pathname but by specifying
     the parent widget when creating each child widget.

   * Operations which are implemented as separate 'commands' in Tcl
     (like ‘grid’ or ‘destroy’) are represented as 'methods' on Tkinter
     widget objects.  As you'll see shortly, at other times Tcl uses
     what appear to be method calls on widget objects, which more
     closely mirror what would is used in Tkinter.


File: python.info,  Node: How do I ? What option does ?,  Next: Navigating the Tcl/Tk Reference Manual,  Prev: Understanding How Tkinter Wraps Tcl/Tk,  Up: Tkinter お助け手帳

5.25.1.7 How do I...? What option does...?
..........................................

If you're not sure how to do something in Tkinter, and you can't
immediately find it in the tutorial or reference documentation you're
using, there are a few strategies that can be helpful.

First, remember that the details of how individual widgets work may vary
across different versions of both Tkinter and Tcl/Tk.  If you're
searching documentation, make sure it corresponds to the Python and
Tcl/Tk versions installed on your system.

When searching for how to use an API, it helps to know the exact name of
the class, option, or method that you're using.  Introspection, either
in an interactive Python shell or with *note print(): f42, can help you
identify what you need.

To find out what configuration options are available on any widget, call
its ‘configure()’ method, which returns a dictionary containing a
variety of information about each object, including its default and
current values.  Use ‘keys()’ to get just the names of each option.

     btn = ttk.Button(frm, ...)
     print(btn.configure().keys())

As most widgets have many configuration options in common, it can be
useful to find out which are specific to a particular widget class.
Comparing the list of options to that of a simpler widget, like a frame,
is one way to do that.

     print(set(btn.configure().keys()) - set(frm.configure().keys()))

Similarly, you can find the available methods for a widget object using
the standard *note dir(): 5fe. function.  If you try it, you'll see
there are over 200 common widget methods, so again identifying those
specific to a widget class is helpful.

     print(dir(btn))
     print(set(dir(btn)) - set(dir(frm)))


File: python.info,  Node: Navigating the Tcl/Tk Reference Manual,  Prev: How do I ? What option does ?,  Up: Tkinter お助け手帳

5.25.1.8 Navigating the Tcl/Tk Reference Manual
...............................................

As noted, the official Tk commands(1) reference manual (man pages) is
often the most accurate description of what specific operations on
widgets do.  Even when you know the name of the option or method that
you need, you may still have a few places to look.

While all operations in Tkinter are implemented as method calls on
widget objects, you've seen that many Tcl/Tk operations appear as
commands that take a widget pathname as its first parameter, followed by
optional parameters, e.g.

     destroy .
     grid .frm.btn -column 0 -row 0

Others, however, look more like methods called on a widget object (in
fact, when you create a widget in Tcl/Tk, it creates a Tcl command with
the name of the widget pathname, with the first parameter to that
command being the name of a method to call).

     .frm.btn invoke
     .frm.lbl configure -text "Goodbye"

In the official Tcl/Tk reference documentation, you'll find most
operations that look like method calls on the man page for a specific
widget (e.g., you'll find the ‘invoke()’ method on the ttk::button(2)
man page), while functions that take a widget as a parameter often have
their own man page (e.g., grid(3)).

You'll find many common options and methods in the options(4) or
ttk::widget(5) man pages, while others are found in the man page for a
specific widget class.

You'll also find that many Tkinter methods have compound names, e.g.,
‘winfo_x()’, ‘winfo_height()’, ‘winfo_viewable()’.  You'd find
documentation for all of these in the winfo(6) man page.

     注釈: Somewhat confusingly, there are also methods on all Tkinter
     widgets that don't actually operate on the widget, but operate at a
     global scope, independent of any widget.  Examples are methods for
     accessing the clipboard or the system bell.  (They happen to be
     implemented as methods in the base ‘Widget’ class that all Tkinter
     widgets inherit from).

   ---------- Footnotes ----------

   (1) https://www.tcl.tk/man/tcl8.6/TkCmd/contents.htm

   (2) https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_button.htm

   (3) https://www.tcl.tk/man/tcl8.6/TkCmd/grid.htm

   (4) https://www.tcl.tk/man/tcl8.6/TkCmd/options.htm

   (5) https://www.tcl.tk/man/tcl8.6/TkCmd/ttk_widget.htm

   (6) https://www.tcl.tk/man/tcl8.6/TkCmd/winfo.htm


File: python.info,  Node: Threading model,  Next: 簡単なリファレンス,  Prev: Tkinter お助け手帳,  Up: tkinter --- Tcl/Tk の Python インターフェース

5.25.1.9 Threading model
........................

Python and Tcl/Tk have very different threading models, which *note
tkinter: d9. tries to bridge.  If you use threads, you may need to be
aware of this.

A Python interpreter may have many threads associated with it.  In Tcl,
multiple threads can be created, but each thread has a separate Tcl
interpreter instance associated with it.  Threads can also create more
than one interpreter instance, though each interpreter instance can be
used only by the one thread that created it.

Each ‘Tk’ object created by *note tkinter: d9. contains a Tcl
interpreter.  It also keeps track of which thread created that
interpreter.  Calls to *note tkinter: d9. can be made from any Python
thread.  Internally, if a call comes from a thread other than the one
that created the ‘Tk’ object, an event is posted to the interpreter's
event queue, and when executed, the result is returned to the calling
Python thread.

Tcl/Tk applications are normally event-driven, meaning that after
initialization, the interpreter runs an event loop (i.e.
‘Tk.mainloop()’) and responds to events.  Because it is single-threaded,
event handlers must respond quickly, otherwise they will block other
events from being processed.  To avoid this, any long-running
computations should not run in an event handler, but are either broken
into smaller pieces using timers, or run in another thread.  This is
different from many GUI toolkits where the GUI runs in a completely
separate thread from all application code including event handlers.

If the Tcl interpreter is not running the event loop and processing
events, any *note tkinter: d9. calls made from threads other than the
one running the Tcl interpreter will fail.

A number of special cases exist:

   * Tcl/Tk libraries can be built so they are not thread-aware.  In
     this case, *note tkinter: d9. calls the library from the
     originating Python thread, even if this is different than the
     thread that created the Tcl interpreter.  A global lock ensures
     only one call occurs at a time.

   * While *note tkinter: d9. allows you to create more than one
     instance of a ‘Tk’ object (with its own interpreter), all
     interpreters that are part of the same thread share a common event
     queue, which gets ugly fast.  In practice, don't create more than
     one instance of ‘Tk’ at a time.  Otherwise, it's best to create
     them in separate threads and ensure you're running a thread-aware
     Tcl/Tk build.

   * Blocking event handlers are not the only way to prevent the Tcl
     interpreter from reentering the event loop.  It is even possible to
     run multiple nested event loops or abandon the event loop entirely.
     If you're doing anything tricky when it comes to events or threads,
     be aware of these possibilities.

   * There are a few select *note tkinter: d9. functions that presently
     work only when called from the thread that created the Tcl
     interpreter.


File: python.info,  Node: 簡単なリファレンス,  Next: ファイルハンドラ,  Prev: Threading model,  Up: tkinter --- Tcl/Tk の Python インターフェース

5.25.1.10 簡単なリファレンス
............................

* Menu:

* オプションの設定::
* Packer::
* Packer のオプション::
* ウィジェット変数を関連付ける::
* ウィンドウマネージャ::
* Tk オプションデータ型::
* バインドとイベント::
* index パラメータ::
* 画像::


File: python.info,  Node: オプションの設定,  Next: Packer,  Up: 簡単なリファレンス

5.25.1.11 オプションの設定
..........................

オプションは、色やウィジェットの境界線幅などを制御します。オプションの設
定には三通りの方法があります:

オブジェクト生成時、キーワード引数を使用する

          fred = Button(self, fg="red", bg="blue")

オブジェクト生成後、オプション名を辞書インデックスのように扱う

          fred["fg"] = "red"
          fred["bg"] = "blue"

オブジェクト生成後に、config()メソッドを使って複数の属性を更新する

          fred.config(fg="red", bg="blue")

オプションとその振る舞いに関する詳細な説明は、該当するウィジェットの Tk
の man ページを参照してください。

man ページには、各ウィジェットの "STANDARD OPTIONS (標準オプション)" と
"WIDGET SPECIFIC OPTIONS (ウィジェット固有のオプション)" がリストされて
いることに注意してください。前者は多くのウィジェットに共通のオプションの
リストで、後者は特定のウィジェットに特有のオプションです。標準オプション
の説明は man ページの ‘options(3)(1)’ にあります。

このドキュメントでは、標準オプションとウィジェット固有のオプションを区別
していません。オプションによっては、ある種のウィジェットに適用できません
。あるウィジェットがあるオプションに対応しているかどうかは、ウィジェット
のクラスによります。例えばボタンには ‘command’ オプションがありますが、
ラベルにはありません。

あるウィジェットがどんなオプションをサポートしているかは、ウィジェットの
man ページにリストされています。また、実行時にウィジェットの ‘config()’
メソッドを引数なしで呼び出したり、 ‘keys()’ メソッドを呼び出したりして問
い合わせることもできます。メソッド呼び出しを行うと辞書型の値を返します。
この辞書は、オプションの名前がキー (例えば ‘'relief'’) になっていて、値
が 5 要素のタプルになっています。

‘bg’ のように、いくつかのオプションはより長い名前を持つ共通のオプション
に対する同義語になっています (‘bg’ は "background" を短縮したものです)。
短縮形のオプション名を ‘config()’ に渡すと、 5 要素ではなく 2 要素のタプ
ルを返します。このタプルには、同義語の名前と「本当の」オプション名が入っ
ています (例えば ‘('bg', 'background')’)。

インデッ    意味                                  使用例
クス                                              

---------------------------------------------------------------------
                                                  
0           オプション名                          ‘'relief'’
                                                  
                                                  
1           データベース検索用のオプション名      ‘'relief'’
                                                  
                                                  
2           データベース検索用のオプションクラ    ‘'Relief'’
            ス                                    
            
                                                  
3           デフォルト値                          ‘'raised'’
                                                  
                                                  
4           現在の値                              ‘'groove'’
                                                  

以下はプログラム例です:

     >>> print(fred.config())
     {'relief': ('relief', 'relief', 'Relief', 'raised', 'groove')}

もちろん、実際に出力される辞書には利用可能なオプションが全て表示されます
。上の表示例は単なる例にすぎません。

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/options(3)


File: python.info,  Node: Packer,  Next: Packer のオプション,  Prev: オプションの設定,  Up: 簡単なリファレンス

5.25.1.12 Packer
................

packer は Tk のジオメトリ管理メカニズムの一つです。ジオメトリマネージャ
は、複数のウィジェットの位置を、それぞれのウィジェットを含むコンテナ - 共
通の 'マスタ (master)' からの相対で指定するために使います。やや扱いにく
い 'placer' (あまり使われないのでここでは取り上げません) と違い、packer
は定性的な関係を表す指定子 - '上 (above)' 、 '〜の左 (to the left of)' 、
'引き延ばし (filling)' など - を受け取り、厳密な配置座標の決定を全て行っ
てくれます。

どんな 'マスタ' ウィジェットでも、大きさは内部の "スレイブ (slave) ウィ
ジェット" の大きさで決まります。 packer は、スレイブウィジェットを pack
先のマスタウィジェット中のどこに配置するかを制御するために使われます。望
みのレイアウトを達成するには、ウィジェットをフレームにパックし、そのフレ
ームをまた別のフレームにパックできます。さらに、一度パックを行うと、それ
以後の設定変更に合わせて動的に並べ方を調整します。

ジオメトリマネージャがウィジェットのジオメトリを確定するまで、ウィジェッ
トは表示されないので注意してください。初心者のころにはよくジオメトリの確
定を忘れてしまい、ウィジェットを生成したのに何も表示されず驚くことになり
ます。ウィジェットは、(例えば packer の ‘pack()’ メソッドを適用して) ジ
オメトリを確定した後で初めて表示されます。

pack() メソッドは、キーワード引数つきで呼び出せます。キーワード引数は、
ウィジェットをコンテナ内のどこに表示するか、メインのアプリケーションウィ
ンドウをリサイズしたときにウィジェットがどう振舞うかを制御します。以下に
例を示します:

     fred.pack()                     # defaults to side = "top"
     fred.pack(side="left")
     fred.pack(expand=1)


File: python.info,  Node: Packer のオプション,  Next: ウィジェット変数を関連付ける,  Prev: Packer,  Up: 簡単なリファレンス

5.25.1.13 Packer のオプション
.............................

packer と packer の取りえるオプションについての詳細は、man ページや John
Ousterhout の本の183ページを参照してください。

anchor

     アンカーの型です。 packer が区画内に各スレイブを配置する位置を示し
     ます。

expand

     ブール値で、 ‘0’ または ‘1’ になります。

fill

     指定できる値は ‘'x'’ 、 ‘'y'’ 、 ‘'both'’ 、 ‘'none'’ です。

ipadx および ipady

     スレイブウィジェットの各側面の内側に行うパディング幅を表す長さを指
     定します。

padx および pady

     スレイブウィジェットの各側面の外側に行うパディング幅を表す長さを指
     定します。

side

     指定できる値は ‘'left'’, ‘'right'’, ‘'top'’, ‘'bottom'’ です。


File: python.info,  Node: ウィジェット変数を関連付ける,  Next: ウィンドウマネージャ,  Prev: Packer のオプション,  Up: 簡単なリファレンス

5.25.1.14 ウィジェット変数を関連付ける
......................................

ウィジェットによっては、(テキスト入力ウィジェットのように) 特殊なオプシ
ョンを使って、現在設定されている値をアプリケーション内の変数に直接関連付
けできます。このようなオプションには ‘variable’, ‘textvariable’,
‘onvalue’, ‘offvalue’ および ‘value’ があります。この関連付けは双方向に
働きます: 変数の値が何らかの理由で変更されると、関連付けされているウィジ
ェットも更新され、新しい値を反映します。

残念ながら、現在の *note tkinter: d9. の実装では、‘variable’ や
‘textvariable’ オプションでは任意の Python の値をウィジェットに渡せませ
ん。この関連付け機能がうまく働くのは、*note tkinter: d9. 内で Variable と
いうクラスからサブクラス化されている変数によるオプションだけです。

Variable には、 ‘StringVar’, ‘IntVar’, ‘DoubleVar’, ‘BooleanVar’ といっ
た便利なサブクラスがすでにすでに数多く定義されています。こうした変数の現
在の値を読み出したければ、 ‘get()’ メソッドを呼び出します。また、値を変
更したければ ‘set()’ メソッドを呼び出します。このプロトコルに従っている
限り、それ以上なにも手を加えなくてもウィジェットは常に現在値に追従します
。

例えば:

     import tkinter as tk

     class App(tk.Frame):
         def __init__(self, master):
             super().__init__(master)
             self.pack()

             self.entrythingy = tk.Entry()
             self.entrythingy.pack()

             # Create the application variable.
             self.contents = tk.StringVar()
             # Set it to some value.
             self.contents.set("this is a variable")
             # Tell the entry widget to watch this variable.
             self.entrythingy["textvariable"] = self.contents

             # Define a callback for when the user hits return.
             # It prints the current value of the variable.
             self.entrythingy.bind('<Key-Return>',
                                  self.print_contents)

         def print_contents(self, event):
             print("Hi. The current entry content is:",
                   self.contents.get())

     root = tk.Tk()
     myapp = App(root)
     myapp.mainloop()


File: python.info,  Node: ウィンドウマネージャ,  Next: Tk オプションデータ型,  Prev: ウィジェット変数を関連付ける,  Up: 簡単なリファレンス

5.25.1.15 ウィンドウマネージャ
..............................

Tk には、ウィンドウマネジャとやり取りするための ‘wm’ というユーティリテ
ィコマンドがあります。‘wm’ コマンドにオプションを指定すると、タイトルや
配置、アイコンビットマップなどを操作できます。*note tkinter: d9. では、
こうしたコマンドは ‘Wm’ クラスのメソッドとして実装されています。トップレ
ベルウィジェットは ‘Wm’ クラスからサブクラス化されているので、‘Wm’ のメ
ソッドを直接呼び出せます。

あるウィジェットの入っているトップレベルウィンドウを取得したい場合、大抵
は単にウィジェットのマスタを参照するだけですみます。とはいえ、ウィジェッ
トがフレーム内にパックされている場合、マスタはトップレベルウィンドウでは
ありません。任意のウィジェットの入っているトップレベルウィンドウを知りた
ければ ‘_root()’ メソッドを呼び出してください。このメソッドはアンダース
コアがついていますが、これはこの関数が ‘Tkinter’ の実装の一部であり、Tk
の機能に対するインターフェースではないことを示しています。

以下に典型的な使い方の例をいくつか挙げます:

     import tkinter as tk

     class App(tk.Frame):
         def __init__(self, master=None):
             super().__init__(master)
             self.pack()

     # create the application
     myapp = App()

     #
     # here are method calls to the window manager class
     #
     myapp.master.title("My Do-Nothing Application")
     myapp.master.maxsize(1000, 400)

     # start the program
     myapp.mainloop()


File: python.info,  Node: Tk オプションデータ型,  Next: バインドとイベント,  Prev: ウィンドウマネージャ,  Up: 簡単なリファレンス

5.25.1.16 Tk オプションデータ型
...............................

anchor

     指定できる値はコンパスの方位です: ‘"n"’ 、 ‘"ne"’ 、 ‘"e"’ 、
     ‘"se"’ 、 ‘"s"’ 、 ‘"sw"’ 、 ‘"w"’ 、 ‘"nw"’ 、および ‘"center"’ 。

bitmap

     八つの組み込み、名前付きビットマップ: ‘'error'’ 、 ‘'gray25'’ 、
     ‘'gray50'’ 、 ‘'hourglass'’ 、 ‘'info'’ 、 ‘'questhead'’ 、
     ‘'question'’ 、 ‘'warning'’ 。 X ビットマップファイル名を指定するた
     めに、 ‘"@/usr/contrib/bitmap/gumby.bit"’ のような ‘@’ を先頭に付け
     たファイルへの完全なパスを与えてください。

boolean

     整数 0 または 1 、あるいは、文字列 ‘"yes"’ または ‘"no"’ を渡すこと
     ができます。

callback

     これは引数を取らない Python 関数ならどれでも構いません。例えば:

          def print_it():
              print("hi there")
          fred["command"] = print_it

color

     Colors can be given as the names of X colors in the rgb.txt file,
     or as strings representing RGB values in 4 bit: ‘"#RGB"’, 8 bit:
     ‘"#RRGGBB"’, 12 bit: ‘"#RRRGGGBBB"’, or 16 bit: ‘"#RRRRGGGGBBBB"’
     ranges, where R,G,B here represent any legal hex digit.  See page
     160 of Ousterhout's book for details.

cursor

     ‘cursorfont.h’ の標準Xカーソル名を、接頭語 ‘XC_’ 無しで使うことがで
     きます。例えば、handカーソル(‘XC_hand2’)を得るには、文字列
     ‘"hand2"’ を使ってください。あなた自身のビットマップとマスクファイ
     ルを指定することもできます。 Ousterhout の本の179ページを参照してく
     ださい。

distance

     スクリーン上の距離をピクセルか絶対距離のどちらかで指定できます。ピ
     クセルは数値として与えられ、絶対距離は文字列として与えられます。絶
     対距離を表す文字列は、単位を表す終了文字 (センチメートルには ‘c’ 、
     インチには ‘i’ 、ミリメートルには ‘m’ 、プリンタのポイントには
     ‘p’)を伴います。例えば、3.5インチは ‘"3.5i"’ と表現します。

font

     Tkはフォント名の形式に ‘{courier 10 bold}’ のようなリストを使います
     。正の数のフォントサイズはポイント単位で使用され、負の数のサイズは
     ピクセル単位と見なされます。

geometry

     これは ‘widthxheight’ 形式の文字列です。ここでは、ほとんどのウィジ
     ェットに対して幅と高さピクセル単位で (テキストを表示するウィジェッ
     トに対しては文字単位で)表されます。例えば: ‘fred["geometry"] =
     "200x100"’ 。

justify

     指定できる値は文字列です: ‘"left"’ 、 ‘"center"’ 、 ‘"right"’ 、そ
     して ‘"fill"’ 。

region

     これは空白で区切られた四つの要素をもつ文字列です。各要素は指定可能
     な距離です(以下を参照)。例えば: ‘"2 3 4 5"’ と ‘"3i 2i 4.5i 2i"’ と
     ‘"3c 2c 4c 10.43c"’ は、すべて指定可能な範囲です。

relief

     ウィジェットのボーダのスタイルが何かを決めます。指定できる値は:
     ‘"raised"’ 、 ‘"sunken"’ 、 ‘"flat"’ 、 ‘"groove"’ 、と ‘"ridge"’ 。

scrollcommand

     これはほとんどの場合スクロールバーウィジェットの ‘set()’ メソッドで
     すが、1 個の引数を取るあらゆるウィジェットにもなりえます。

wrap

     次の中の一つでなければなりません: ‘"none"’ 、 ‘"char"’ 、あるいは
     ‘"word"’ 。


File: python.info,  Node: バインドとイベント,  Next: index パラメータ,  Prev: Tk オプションデータ型,  Up: 簡単なリファレンス

5.25.1.17 バインドとイベント
............................

ウィジェットコマンドからの bind メソッドによって、あるイベントを待つこと
と、そのイベント型が起きたときにコールバック関数を呼び出すことができるよ
うになります。 bind メソッドの形式は:

     def bind(self, sequence, func, add=''):

ここでは:

sequence

     is a string that denotes the target kind of event.  (See the
     ‘bind(3tk)(1)’ man page, and page 201 of John Ousterhout's book,
     ‘Tcl and the Tk Toolkit (2nd edition)’, for details).

func

     は一引数を取り、イベントが起きるときに呼び出される Python 関数です
     。イベント・インスタンスが引数として渡されます。 (このように実施さ
     れる関数は、一般に 'callbacks' として知られています。)

add

     はオプションで、 ‘''’ か ‘'+'’ のどちらかです。空文字列を渡すことは
     、このイベントが関係する他のどんなバインドをもこのバインドが置き換
     えることを意味します。 ‘'+'’ を使う仕方は、この関数がこのイベント型
     にバインドされる関数のリストに追加されることを意味しています。

例えば:

     def turn_red(self, event):
         event.widget["activeforeground"] = "red"

     self.button.bind("<Enter>", self.turn_red)

イベントのウィジェットフィールドが ‘turn_red()’ コールバック内でどのよう
にアクセスされているかに注目してください。このフィールドは X イベントを
捕らえたウィジェットを含んでいます。以下の表はアクセスできる他のイベント
フィールドとそれらの Tk での表現方法の一覧です。Tk man ページを参照する
ときに役に立つでしょう。

Tk       Tkinter イベントフィー    Tk       Tkinter イベントフィー
         ルド                               ルド
                                            
----------------------------------------------------------------------
                                            
%f       focus                     %A       char
                                            
                                            
%h       高さ                      %E       send_event
                                            
                                            
%k       keycode                   %K       keysym
                                            
                                            
%s       state                     %N       keysym_num
                                            
                                            
%t       time                      %T       type
                                            
                                            
%w       幅                        %W       widget
                                            
                                            
%x       x                         %X       x_root
                                            
                                            
%y       y                         %Y       y_root
                                            

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/bind(3tk)


File: python.info,  Node: index パラメータ,  Next: 画像,  Prev: バインドとイベント,  Up: 簡単なリファレンス

5.25.1.18 index パラメータ
..........................

多くのウィジェットにはパラメータ "index" を渡す必要があります。これらは
テキストウィジェット内の特定の位置や、エントリウィジェット内の特定の文字
、あるいはメニューウィジェット内の特定のメニューアイテムを指定するために
使用されます。

エントリウィジェットのインデックス(インデックス、ビューインデックスなど)

     エントリウィジェットは表示されているテキスト内の文字位置を参照する
     オプションを持っています。テキストウィジェットにおけるこれらの特別
     な位置にアクセスするために、次の *note tkinter: d9. 関数を使うこと
     ができます:

テキストウィジェットのインデックス

     テキストウィジェットに対するインデックス記法はとても機能が豊富で、
     Tk manページでよく説明されています。

メニューのインデックス(menu.invoke()、menu.entryconfig()など)

     メニューに対するいくつかのオプションとメソッドは特定のメニュー項目
     を操作します。メニューインデックスはオプションまたはパラメータのた
     めに必要とされるときはいつでも、以下のものを渡すことができます:

        * ウィジェット内の数字の先頭からの位置を指す整数。先頭は 0。

        * 文字列 ‘"active"’。現在カーソルがあるメニューの位置を指します
          。

        * 文字列 ‘"last"’ 。最後のメニューを指します。

        * ‘@6’ のような ‘@’ が前に来る整数。ここでは、整数がメニューの座
          標系における y ピクセル座標として解釈されます。

        * 文字列 ‘"none"’。どんなメニューエントリもまったく指しておらず
          、ほとんどの場合、すべてのエントリの動作を停止させるために
          menu.activate() と一緒に使われます。そして、最後に、

        * メニューの先頭から一番下までスキャンしたときに、メニューエント
          リのラベルに一致したパターンであるテキスト文字列。このインデッ
          クス型は他すべての後に考慮されることに注意してください。その代
          わりに、それは ‘last’ 、 ‘active’ または ‘none’ とラベル付けさ
          れたメニュー項目への一致は上のリテラルとして解釈されることを意
          味します。


File: python.info,  Node: 画像,  Prev: index パラメータ,  Up: 簡単なリファレンス

5.25.1.19 画像
..............

様々な形式の画像を、それに対応する ‘tkinter.Image’ のサブクラスを使って
作成できます:

   * XBM 形式の画像のための ‘BitmapImage’ 。

   * PGM, PPM, GIF, PNG 形式の画像のための ‘PhotoImage’ 。 最後のは Tk
     8.6 からサポートされるようになりました。

画像のどちらの型でも ‘file’ または ‘data’ オプションを使って作られます
(その上、他のオプションも利用できます)。

バージョン 3.13 で変更: Added the ‘PhotoImage’ method ‘copy_replace()’
to copy a region from one image to other image, possibly with pixel
zooming and/or subsampling.  Add 'from_coords' parameter to ‘PhotoImage’
methods ‘copy()’, ‘zoom()’ and ‘subsample()’.  Add 'zoom' and
'subsample' parameters to ‘PhotoImage’ method ‘copy()’.

‘image’ オプションがウィジェットにサポートされるところならどこでも、画像
オブジェクトを使うことができます (例えば、ラベル、ボタン、メニュー)。こ
れらの場合では、Tk は画像への参照を保持しないでしょう。画像オブジェクト
への最後の Python の参照が削除されたときに、画像データも削除されます。そ
して、どこで画像が使われていようとも、Tk は空の箱を表示します。

参考
....

The Pillow(1) package adds support for formats such as BMP, JPEG, TIFF,
and WebP, among others.

   ---------- Footnotes ----------

   (1) https://python-pillow.org/


File: python.info,  Node: ファイルハンドラ,  Prev: 簡単なリファレンス,  Up: tkinter --- Tcl/Tk の Python インターフェース

5.25.1.20 ファイルハンドラ
..........................

Tk を使うとコールバック関数の登録や解除ができ、ファイルディスクリプタに
対する入出力が可能なときに、Tk のメインループからその関数が呼ばれます。
ファイルディスクリプタ1つにつき、1つだけハンドラは登録されます。コード例
です:

     import tkinter
     widget = tkinter.Tk()
     mask = tkinter.READABLE | tkinter.WRITABLE
     widget.tk.createfilehandler(file, mask, callback)
     ...
     widget.tk.deletefilehandler(file)

これらの機能は Windows では利用できません。

読み込みに使えるバイト数は分からないので、 *note BufferedIOBase: 660. ク
ラスや *note TextIOBase: 661. クラスの *note read(): 12f7. メソッドおよ
び *note readline(): 12f8. メソッドを使おうとしないでください。これらは
読み込みの際に、あらかじめ決められたバイト数を要求するのです。ソケットに
は、 *note recv(): d71. や *note recvfrom(): d72. メソッドを使うといいで
す。その他のファイルには、 raw 読み込みか ‘os.read(file.fileno(),
maxbytecount)’ を使ってください。

 -- メソッド: Widget.tk.createfilehandler (file, mask, func)

     ファイルハンドラであるコールバック関数 'func' を登録します。 'file'
     引数は、 (ファイルやソケットオブジェクトのような) *note fileno():
     27a6. メソッドを持つオブジェクトか、整数のファイルディスクリプタと
     なります。 'mask' 引数は、以下にある3つの定数の組み合わせの OR を取
     ったものです。コールバックは次のように呼ばれます:

          callback(file, mask)

 -- メソッド: Widget.tk.deletefilehandler (file)

     ファイルハンドラの登録を解除します。

 -- データ: _tkinter.READABLE
 -- データ: _tkinter.WRITABLE
 -- データ: _tkinter.EXCEPTION

     'mask' 引数で使う定数です。


File: python.info,  Node: tkinter colorchooser --- カラー選択ダイアログ,  Next: tkinter font --- Tkinter フォントラッパー,  Prev: tkinter --- Tcl/Tk の Python インターフェース,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.2 ‘tkinter.colorchooser’ -- カラー選択ダイアログ
-----------------------------------------------------

'ソースコード:' Lib/tkinter/colorchooser.py(1)

__________________________________________________________________

‘Chooser’*note tkinter.colorchooser: da. モジュールは *note Chooser:
3ced. クラスをネイティブカラー選択ダイアログのインターフェースとして提供
します。はモーダルなカラー選択ウィンドウを実装しています。 ‘Chooser’ ク
ラスは *note Dialog: 3cee. を継承しています。

 -- クラス: tkinter.colorchooser.Chooser (master=None, **options)

 -- の関数: tkinter.colorchooser.askcolor (color=None, **options)

     カラー選択ダイアログを作成します。このメソッドを呼び出すと、ウィン
     ドウが表示されユーザーが選択するのを待ち、選択された色（もしくは
     ‘None’ ）を呼び出し元に返します。

参考
....

モジュール *note tkinter.commondialog: db.

     Tkinter標準ダイアログモジュール

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/tkinter/colorchooser.py


File: python.info,  Node: tkinter font --- Tkinter フォントラッパー,  Next: Tkinter ダイアログ,  Prev: tkinter colorchooser --- カラー選択ダイアログ,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.3 ‘tkinter.font’ -- Tkinter フォントラッパー
-------------------------------------------------

'ソースコード:' Lib/tkinter/font.py(1)

__________________________________________________________________

*note tkinter.font: de. モジュールは名前付きフォントを作成、使用するため
の *note Font: 1875. クラスを提供します。

The different font weights and slants are:

 -- データ: tkinter.font.NORMAL
 -- データ: tkinter.font.BOLD
 -- データ: tkinter.font.ITALIC
 -- データ: tkinter.font.ROMAN

 -- クラス: tkinter.font.Font (root=None, font=None, name=None,
          exists=False, **options)

     The *note Font: 1875. class represents a named font.  'Font'
     instances are given unique names and can be specified by their
     family, size, and style configuration.  Named fonts are Tk's method
     of creating and identifying fonts as a single object, rather than
     specifying a font by its attributes with each occurrence.

          arguments:

                    'font' - font specifier tuple (family, size, options)
                    'name' - unique font name
                    'exists' - self points to existing named font if true

          additional keyword options (ignored if 'font' is specified):

                    'family' - font family i.e. Courier, Times
                    'size' - font size
                         If 'size' is positive it is interpreted as size in points.
                         If 'size' is a negative number its absolute value is treated
                         as size in pixels.
                    'weight' - font emphasis (NORMAL, BOLD)
                    'slant' - ROMAN, ITALIC
                    'underline' - font underlining (0 - none, 1 - underline)
                    'overstrike' - font strikeout (0 - none, 1 - strikeout)

      -- メソッド: actual (option=None, displayof=None)

          Return the attributes of the font.

      -- メソッド: cget (option)

          Retrieve an attribute of the font.

      -- メソッド: config (**options)

          Modify attributes of the font.

      -- メソッド: copy ()

          Return new instance of the current font.

      -- メソッド: measure (text, displayof=None)

          Return amount of space the text would occupy on the specified
          display when formatted in the current font.  If no display is
          specified then the main application window is assumed.

      -- メソッド: metrics (*options, **kw)

          Return font-specific data.  Options include:

          'ascent' - distance between baseline and highest point that a

               character of the font can occupy

          'descent' - distance between baseline and lowest point that a

               character of the font can occupy

          'linespace' - minimum vertical separation necessary between any two

               characters of the font that ensures no vertical overlap
               between lines.

          'fixed' - 1 if font is fixed-width else 0

 -- の関数: tkinter.font.families (root=None, displayof=None)

     Return the different font families.

 -- の関数: tkinter.font.names (root=None)

     Return the names of defined fonts.

 -- の関数: tkinter.font.nametofont (name, root=None)

     Return a *note Font: 1875. representation of a tk named font.

     バージョン 3.10 で変更: The 'root' parameter was added.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tkinter/font.py


File: python.info,  Node: Tkinter ダイアログ,  Next: tkinter messagebox --- Tkinter メッセージプロンプト,  Prev: tkinter font --- Tkinter フォントラッパー,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.4 Tkinter ダイアログ
-------------------------

* Menu:

* tkinter.simpledialog: tkinter simpledialog --- 標準 Tkinter 入力ダイアログ. 標準 Tkinter 入力ダイアログ
* tkinter.filedialog: tkinter filedialog --- ファイル選択ダイアログ. ファイル選択ダイアログ
* tkinter.commondialog: tkinter commondialog --- Dialog window templates. Dialog window templates


File: python.info,  Node: tkinter simpledialog --- 標準 Tkinter 入力ダイアログ,  Next: tkinter filedialog --- ファイル選択ダイアログ,  Up: Tkinter ダイアログ

5.25.4.1 ‘tkinter.simpledialog’ -- 標準 Tkinter 入力ダイアログ
..............................................................

'ソースコード:' Lib/tkinter/simpledialog.py(1)

__________________________________________________________________

*note tkinter.simpledialog: e1. モジュールは、ユーザーに値を入力させる単
純なモーダルダイアログを作成するための便利なクラスや関数を含んでいます。

 -- の関数: tkinter.simpledialog.askfloat (title, prompt, **kw)
 -- の関数: tkinter.simpledialog.askinteger (title, prompt, **kw)
 -- の関数: tkinter.simpledialog.askstring (title, prompt, **kw)

     上の３つの関数は、ユーザーに期待する型の値を入力を促すダイアログを
     提供します。

 -- クラス: tkinter.simpledialog.Dialog (parent, title=None)

     カスタムダイアログ用の基底クラスです。

      -- メソッド: body (master)

          ダイアログインターフェースの構築をオーバーライドし、初期フォー
          カスを持つべきウィジットを返します。

      -- メソッド: buttonbox ()

          デフォルト動作はOKとCancelボタンを追加します。カスタムのボタン
          レイアウトが必要であればオーバーライドします。

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/tkinter/simpledialog.py


File: python.info,  Node: tkinter filedialog --- ファイル選択ダイアログ,  Next: tkinter commondialog --- Dialog window templates,  Prev: tkinter simpledialog --- 標準 Tkinter 入力ダイアログ,  Up: Tkinter ダイアログ

5.25.4.2 ‘tkinter.filedialog’ -- ファイル選択ダイアログ
.......................................................

'ソースコード:' Lib/tkinter/filedialog.py(1)

__________________________________________________________________

The *note tkinter.filedialog: dd. module provides classes and factory
functions for creating file/directory selection windows.

* Menu:

* ネイティブの読み込み/保存ダイアログ::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/tkinter/filedialog.py


File: python.info,  Node: ネイティブの読み込み/保存ダイアログ,  Up: tkinter filedialog --- ファイル選択ダイアログ

5.25.4.3 ネイティブの読み込み/保存ダイアログ
............................................

下記のクラスは、振る舞いをカスタマイズできる設定オプション付きの、ネイテ
ィブルック＆フィールと統合したファイルダイアログを提供します。以下のキー
ワード引数は、下記で列挙するクラスや関数に適用できます。

          'parent' - ダイアログをその上に表示するウィンドウ

          'title' - ウィンドウのタイトル

          'initialdir' - 最初に表示するディレクトリ

          'initialfile' - ダイアログを表示した際に選択するファイル

          'filetypes' - (ラベル, パターン) のタプルからなるシーケンスで、'*' ワイルドカードが利用できます

          'defaultextension' - ファイルに追加するデフォルトの拡張子 (保存ダイアログ向け)

          'multiple' - 真の場合、複数要素の選択を許可します

'静的なファクトリ関数'

The below functions when called create a modal, native look-and-feel
dialog, wait for the user's selection, then return the selected value(s)
or ‘None’ to the caller.

 -- の関数: tkinter.filedialog.askopenfile (mode='r', **options)
 -- の関数: tkinter.filedialog.askopenfiles (mode='r', **options)

     The above two functions create an *note Open: 3d0a. dialog and
     return the opened file object(s) in read-only mode.

 -- の関数: tkinter.filedialog.asksaveasfile (mode='w', **options)

     Create a *note SaveAs: 3d0c. dialog and return a file object opened
     in write-only mode.

 -- の関数: tkinter.filedialog.askopenfilename (**options)
 -- の関数: tkinter.filedialog.askopenfilenames (**options)

     The above two functions create an *note Open: 3d0a. dialog and
     return the selected filename(s) that correspond to existing
     file(s).

 -- の関数: tkinter.filedialog.asksaveasfilename (**options)

     Create a *note SaveAs: 3d0c. dialog and return the selected
     filename.

 -- の関数: tkinter.filedialog.askdirectory (**options)

          Prompt user to select a directory.
          Additional keyword option:
               'mustexist' - determines if selection must be an existing directory.

 -- クラス: tkinter.filedialog.Open (master=None, **options)
 -- クラス: tkinter.filedialog.SaveAs (master=None, **options)

     The above two classes provide native dialog windows for saving and
     loading files.

'便利なクラス'

The below classes are used for creating file/directory windows from
scratch.  These do not emulate the native look-and-feel of the platform.

 -- クラス: tkinter.filedialog.Directory (master=None, **options)

     Create a dialog prompting the user to select a directory.

     注釈: The 'FileDialog' class should be subclassed for custom event
     handling and behaviour.

 -- クラス: tkinter.filedialog.FileDialog (master, title=None)

     Create a basic file selection dialog.

      -- メソッド: cancel_command (event=None)

          Trigger the termination of the dialog window.

      -- メソッド: dirs_double_event (event)

          Event handler for double-click event on directory.

      -- メソッド: dirs_select_event (event)

          Event handler for click event on directory.

      -- メソッド: files_double_event (event)

          Event handler for double-click event on file.

      -- メソッド: files_select_event (event)

          Event handler for single-click event on file.

      -- メソッド: filter_command (event=None)

          Filter the files by directory.

      -- メソッド: get_filter ()

          Retrieve the file filter currently in use.

      -- メソッド: get_selection ()

          Retrieve the currently selected item.

      -- メソッド: go (dir_or_file=os.curdir, pattern='*', default='',
               key=None)

          Render dialog and start event loop.

      -- メソッド: ok_event (event)

          Exit dialog returning current selection.

      -- メソッド: quit (how=None)

          Exit dialog returning filename, if any.

      -- メソッド: set_filter (dir, pat)

          Set the file filter.

      -- メソッド: set_selection (file)

          Update the current file selection to 'file'.

 -- クラス: tkinter.filedialog.LoadFileDialog (master, title=None)

     A subclass of FileDialog that creates a dialog window for selecting
     an existing file.

      -- メソッド: ok_command ()

          Test that a file is provided and that the selection indicates
          an already existing file.

 -- クラス: tkinter.filedialog.SaveFileDialog (master, title=None)

     A subclass of FileDialog that creates a dialog window for selecting
     a destination file.

      -- メソッド: ok_command ()

          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.


File: python.info,  Node: tkinter commondialog --- Dialog window templates,  Prev: tkinter filedialog --- ファイル選択ダイアログ,  Up: Tkinter ダイアログ

5.25.4.4 ‘tkinter.commondialog’ -- Dialog window templates
..........................................................

'Source code:' Lib/tkinter/commondialog.py(1)

__________________________________________________________________

The *note tkinter.commondialog: db. module provides the *note Dialog:
3cee. class that is the base class for dialogs defined in other
supporting modules.

 -- クラス: tkinter.commondialog.Dialog (master=None, **options)

      -- メソッド: show (color=None, **options)

          Render the Dialog window.

参考
....

Modules *note tkinter.messagebox: df, *note ファイルを読み書きする:
1be9.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/tkinter/commondialog.py


File: python.info,  Node: tkinter messagebox --- Tkinter メッセージプロンプト,  Next: tkinter scrolledtext --- スクロール可能なテキストウィジェット,  Prev: Tkinter ダイアログ,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.5 ‘tkinter.messagebox’ -- Tkinter メッセージプロンプト
-----------------------------------------------------------

'ソースコード:' Lib/tkinter/messagebox.py(1)

__________________________________________________________________

The *note tkinter.messagebox: df. module provides a template base class
as well as a variety of convenience methods for commonly used
configurations.  The message boxes are modal and will return a subset of
(‘True’, ‘False’, ‘None’, *note OK: 3d28, *note CANCEL: 3d29, *note YES:
3d2a, *note NO: 3d2b.) based on the user's selection.  Common message
box styles and layouts include but are not limited to:

[image src="python-figures/tk_msg.png"]


Figure
 -- クラス: tkinter.messagebox.Message (master=None, **options)

     Create a message window with an application-specified message, an
     icon and a set of buttons.  Each of the buttons in the message
     window is identified by a unique symbolic name (see the 'type'
     options).

     The following options are supported:

          'command'

               Specifies the function to invoke when the user closes the
               dialog.  The name of the button clicked by the user to
               close the dialog is passed as argument.  This is only
               available on macOS.

          'default'

               Gives the *note symbolic name: 3d2d. of the default
               button for this message window (*note OK: 3d28, *note
               CANCEL: 3d29, and so on).  If this option is not
               specified, the first button in the dialog will be made
               the default.

          'detail'

               Specifies an auxiliary message to the main message given
               by the 'message' option.  The message detail will be
               presented beneath the main message and, where supported
               by the OS, in a less emphasized font than the main
               message.

          'icon'

               Specifies an *note icon: 3d2e. to display.  If this
               option is not specified, then the *note INFO: 3d2f. icon
               will be displayed.

          'message'

               Specifies the message to display in this message box.
               The default value is an empty string.

          'parent'

               Makes the specified window the logical parent of the
               message box.  The message box is displayed on top of its
               parent window.

          'title'

               Specifies a string to display as the title of the message
               box.  This option is ignored on macOS, where platform
               guidelines forbid the use of a title on this kind of
               dialog.

          'type'

               Arranges for a *note predefined set of buttons: 3d30. to
               be displayed.

      -- メソッド: show (**options)

          Display a message window and wait for the user to select one
          of the buttons.  Then return the symbolic name of the selected
          button.  Keyword arguments can override options specified in
          the constructor.

'情報メッセージボックス'

 -- の関数: tkinter.messagebox.showinfo (title=None, message=None,
          **options)

     Creates and displays an information message box with the specified
     title and message.

'警告メッセージボックス'

 -- の関数: tkinter.messagebox.showwarning (title=None, message=None,
          **options)

     Creates and displays a warning message box with the specified title
     and message.

 -- の関数: tkinter.messagebox.showerror (title=None, message=None,
          **options)

     Creates and displays an error message box with the specified title
     and message.

'質問メッセージボックス'

 -- の関数: tkinter.messagebox.askquestion (title=None, message=None, *,
          type=YESNO, **options)

     Ask a question.  By default shows buttons *note YES: 3d2a. and
     *note NO: 3d2b.  Returns the symbolic name of the selected button.

 -- の関数: tkinter.messagebox.askokcancel (title=None, message=None,
          **options)

     Ask if operation should proceed.  Shows buttons *note OK: 3d28. and
     *note CANCEL: 3d29.  Returns ‘True’ if the answer is ok and ‘False’
     otherwise.

 -- の関数: tkinter.messagebox.askretrycancel (title=None, message=None,
          **options)

     Ask if operation should be retried.  Shows buttons *note RETRY:
     3d38. and *note CANCEL: 3d29.  Return ‘True’ if the answer is yes
     and ‘False’ otherwise.

 -- の関数: tkinter.messagebox.askyesno (title=None, message=None,
          **options)

     Ask a question.  Shows buttons *note YES: 3d2a. and *note NO: 3d2b.
     Returns ‘True’ if the answer is yes and ‘False’ otherwise.

 -- の関数: tkinter.messagebox.askyesnocancel (title=None, message=None,
          **options)

     Ask a question.  Shows buttons *note YES: 3d2a, *note NO: 3d2b. and
     *note CANCEL: 3d29.  Return ‘True’ if the answer is yes, ‘None’ if
     cancelled, and ‘False’ otherwise.
Symbolic names of buttons:

 -- データ: tkinter.messagebox.ABORT = 'abort'

 -- データ: tkinter.messagebox.RETRY = 'retry'

 -- データ: tkinter.messagebox.IGNORE = 'ignore'

 -- データ: tkinter.messagebox.OK = 'ok'

 -- データ: tkinter.messagebox.CANCEL = 'cancel'

 -- データ: tkinter.messagebox.YES = 'yes'

 -- データ: tkinter.messagebox.NO = 'no'
Predefined sets of buttons:

 -- データ: tkinter.messagebox.ABORTRETRYIGNORE = 'abortretryignore'

     Displays three buttons whose symbolic names are *note ABORT: 3d3b,
     *note RETRY: 3d38. and *note IGNORE: 3d3c.

 -- データ: tkinter.messagebox.OK = 'ok'

     Displays one button whose symbolic name is *note OK: 3d28.

 -- データ: tkinter.messagebox.OKCANCEL = 'okcancel'

     Displays two buttons whose symbolic names are *note OK: 3d28. and
     *note CANCEL: 3d29.

 -- データ: tkinter.messagebox.RETRYCANCEL = 'retrycancel'

     Displays two buttons whose symbolic names are *note RETRY: 3d38.
     and *note CANCEL: 3d29.

 -- データ: tkinter.messagebox.YESNO = 'yesno'

     Displays two buttons whose symbolic names are *note YES: 3d2a. and
     *note NO: 3d2b.

 -- データ: tkinter.messagebox.YESNOCANCEL = 'yesnocancel'

     Displays three buttons whose symbolic names are *note YES: 3d2a,
     *note NO: 3d2b. and *note CANCEL: 3d29.
Icon images:

 -- データ: tkinter.messagebox.ERROR = 'error'

 -- データ: tkinter.messagebox.INFO = 'info'

 -- データ: tkinter.messagebox.QUESTION = 'question'

 -- データ: tkinter.messagebox.WARNING = 'warning'

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/tkinter/messagebox.py


File: python.info,  Node: tkinter scrolledtext --- スクロール可能なテキストウィジェット,  Next: tkinter dnd --- ドラッグアンドドロップのサポート,  Prev: tkinter messagebox --- Tkinter メッセージプロンプト,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.6 ‘tkinter.scrolledtext’ -- スクロール可能なテキストウィジェット
---------------------------------------------------------------------

'ソースコード:' Lib/tkinter/scrolledtext.py(1)

__________________________________________________________________

*note tkinter.scrolledtext: e0. モジュールは"正しい動作"をするように設定
された垂直スクロールバーをもつ基本的なテキストウィジェットを実装する同じ
名前のクラスを提供します。 *note ScrolledText: 3d47. クラスを使うことは
、テキストウィジェットとスクロールバーを直接設定するより簡単です。

テキストウィジェットとスクロールバーは ‘Frame’ の中に一緒にpackされ、
‘Grid’ と ‘Pack’ ジオメトリマネジャのメソッドは‘Frame’ オブジェクトから
得られます。これによって、もっとも標準的なジオメトリマネジャの振る舞いに
するために、直接 *note ScrolledText: 3d47. ウィジェットを使えるようにな
ります。

特定の制御が必要ならば、以下の属性が利用できます:

 -- クラス: tkinter.scrolledtext.ScrolledText (master=None, **kw)

      -- の属性: frame

          テキストとスクロールバーウィジェットを取り囲むフレーム。

      -- の属性: vbar

          スクロールバーウィジェット。

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/tkinter/scrolledtext.py


File: python.info,  Node: tkinter dnd --- ドラッグアンドドロップのサポート,  Next: tkinter ttk --- Tk のテーマ付きウィジェット,  Prev: tkinter scrolledtext --- スクロール可能なテキストウィジェット,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.7 ‘tkinter.dnd’ -- ドラッグアンドドロップのサポート
--------------------------------------------------------

'ソースコード:' Lib/tkinter/dnd.py(1)

__________________________________________________________________

     注釈: This is experimental and due to be deprecated when it is
     replaced with the Tk DND.

The *note tkinter.dnd: dc. module provides drag-and-drop support for
objects within a single application, within the same window or between
windows.  To enable an object to be dragged, you must create an event
binding for it that starts the drag-and-drop process.  Typically, you
bind a ButtonPress event to a callback function that you write (see
*note バインドとイベント: 3ce0.).  The function should call *note
dnd_start(): 3d4c, where 'source' is the object to be dragged, and
'event' is the event that invoked the call (the argument to your
callback function).

Selection of a target object occurs as follows:

  1. Top-down search of area under mouse for target widget

        * Target widget should have a callable 'dnd_accept' attribute

        * If 'dnd_accept' is not present or returns ‘None’, search moves
          to parent widget

        * If no target widget is found, then the target object is ‘None’

  2. Call to '<old_target>.dnd_leave(source, event)'

  3. Call to '<new_target>.dnd_enter(source, event)'

  4. Call to '<target>.dnd_commit(source, event)' to notify of drop

  5. Call to '<source>.dnd_end(target, event)' to signal end of
     drag-and-drop

 -- クラス: tkinter.dnd.DndHandler (source, event)

     The 'DndHandler' class handles drag-and-drop events tracking Motion
     and ButtonRelease events on the root of the event widget.

      -- メソッド: cancel (event=None)

          Cancel the drag-and-drop process.

      -- メソッド: finish (event, commit=0)

          Execute end of drag-and-drop functions.

      -- メソッド: on_motion (event)

          Inspect area below mouse for target objects while drag is
          performed.

      -- メソッド: on_release (event)

          Signal end of drag when the release pattern is triggered.

 -- の関数: tkinter.dnd.dnd_start (source, event)

     Factory function for drag-and-drop process.

参考
....

*note バインドとイベント: 3ce0.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tkinter/dnd.py


File: python.info,  Node: tkinter ttk --- Tk のテーマ付きウィジェット,  Next: IDLE<64>,  Prev: tkinter dnd --- ドラッグアンドドロップのサポート,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.8 ‘tkinter.ttk’ -- Tk のテーマ付きウィジェット
---------------------------------------------------

'ソースコード:' Lib/tkinter/ttk.py(1)

__________________________________________________________________

*note tkinter.ttk: e2. モジュールは Tk 8.5 で導入された Tk のテーマ付き
ウィジェットへのアクセスを提供します。これは X11 上のフォントのアンチエ
イリアスや透過ウィンドウ (X11 ではコンポジションウィンドウマネージャが必
要です) を含む、さらなる利点を提供します。

*note tkinter.ttk: e2. の基本的なアイディアは、拡張可能性のためにウィジ
ェットの動作を実装するコードと見た目を記述するコードを分離することです。

参考
....

Tk Widget Styling Support(2)

     Tk のテーマサポートを紹介するドキュメント

* Menu:

* Ttk を使う::
* Ttk ウィジェット::
* ウィジェット::
* コンボボックス::
* Spinbox::
* ノートブック::
* プログレスバー::
* セパレータ::
* サイズグリップ::
* ツリービュー::
* Ttk スタイル::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tkinter/ttk.py

   (2) https://core.tcl.tk/tips/doc/trunk/tip/48.md


File: python.info,  Node: Ttk を使う,  Next: Ttk ウィジェット,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.1 Ttk を使う
...................

Ttk を使い始めるために、モジュールをインポートします:

     from tkinter import ttk

基本的な Tk ウィジェットを上書きするため、次のように Tk のインポートに続
けてインポートを行います:

     from tkinter import *
     from tkinter.ttk import *

このように書くと、いくつかの *note tkinter.ttk: e2. ウィジェット
(‘Button’, ‘Checkbutton’, ‘Entry’, ‘Frame’, ‘Label’, ‘LabelFrame’,
‘Menubutton’, ‘PanedWindow’, ‘Radiobutton’, ‘Scale’, ‘Scrollbar’) は自動
的に Tk ウィジェットを置き換えます。

これにはプラットフォームをまたいでより良い見た目を得られるという、直接的
な利益がありますが、ウィジェットは完全な互換性を持っているわけではありま
せん。一番の違いは "fg" や "bg" やその他のスタイルに関係するウィジェット
のオプションが Ttk ウィジェットから無くなっていることです。同じ (もしく
はより良い) 見た目にするためには ‘ttk.Style’ を使ってください。

参考
....

Converting existing applications to use Tile widgets(1)

     アプリケーションを移行して新しいウィジェットを使用する際に出くわす
     典型的な差異について (Tcl の用語を使って) 書かれている研究論文

   ---------- Footnotes ----------

   (1) https://tktable.sourceforge.net/tile/doc/converting.txt


File: python.info,  Node: Ttk ウィジェット,  Next: ウィジェット,  Prev: Ttk を使う,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.2 Ttk ウィジェット
.........................

Ttk には 18 のウィジェットがあり、そのうち 12 は Tkinter に既にあるもの
です: ‘Button’, ‘Checkbutton’, ‘Entry’, ‘Frame’, ‘Label’, ‘LabelFrame’,
‘Menubutton’, ‘PanedWindow’, ‘Radiobutton’, ‘Scale’, ‘Scrollbar’, *note
Spinbox: b62. 。新しい 6 つは次のものです: *note Combobox: 3d56, *note
Notebook: 3d57, *note Progressbar: 3d58, ‘Separator’, ‘Sizegrip’, *note
Treeview: a62. 。そして、これらは全て *note Widget: 3d59. の子クラスです
。

Ttk ウィジェットを使用すると、アプリケーションの見た目と使いやすさが向上
します。上述の通り、書式をコーディングする方法は異なります。

Tk のコード

     l1 = tkinter.Label(text="Test", fg="black", bg="white")
     l2 = tkinter.Label(text="Test", fg="black", bg="white")

Ttk のコード:

     style = ttk.Style()
     style.configure("BW.TLabel", foreground="black", background="white")

     l1 = ttk.Label(text="Test", style="BW.TLabel")
     l2 = ttk.Label(text="Test", style="BW.TLabel")

*note TtkStyling: 3d5a. についての詳細は *note Style: 23a. クラスの文書
を読んでください。


File: python.info,  Node: ウィジェット,  Next: コンボボックス,  Prev: Ttk ウィジェット,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.3 ウィジェット
.....................

‘ttk.Widget’ はTk のテーマ付きウィジェットがサポートしている標準のオプシ
ョンやメソッドを定義するもので、これを直接インスタンス化するものではあり
ません。

* Menu:

* 標準オプション::
* スクロール可能ウィジェットのオプション::
* ラベルオプション::
* 互換性オプション::
* ウィジェットの状態::
* ttk.Widget: ttk Widget.


File: python.info,  Node: 標準オプション,  Next: スクロール可能ウィジェットのオプション,  Up: ウィジェット

5.25.8.4 標準オプション
.......................

All the ‘ttk’ Widgets accept the following options:

オプション      説明
                
-----------------------------------------------------------------------------------
                
クラス          ウィンドウクラスを指定します。このクラスはオプションデータベース
                にウィンドウの他のオプションについて問い合わせを行うときに使われ
                、これによりウィンドウのデフォルトのバインドタグを決定したり、ウ
                ィジェットのデフォルトのレイアウトやスタイルを選択します。このオ
                プションは読み出し専用で、ウィンドウが作成されるときにのみ指定で
                きます。
                
                
cursor          このウィジェットで使うマウスカーソルを指定します。空文字列 (デフ
                ォルト) が設定されている場合は、カーソルは親ウィジェットのものを
                引き継ぎます。
                
                
takefocus       キーボードによる移動のときにウィンドウがフォーカスを受け入れるか
                を決定します。0、1、空文字列のいずれかを返します。0 が返されると
                、キーボードによる移動でそのウィンドウは常にスキップされます。1
                なら、そのウィンドウが表示されているときに限り入力フォーカスを受
                け入れます。そして空文字列は、移動スクリプトによってウィンドウに
                フォーカスを当てるかどうかが決まることを意味します。
                
                
style           独自のウィジェットスタイルを指定するのに使われます。
                


File: python.info,  Node: スクロール可能ウィジェットのオプション,  Next: ラベルオプション,  Prev: 標準オプション,  Up: ウィジェット

5.25.8.5 スクロール可能ウィジェットのオプション
...............................................

以下のオプションはスクロールバーで操作されるウィジェットが持っているオプ
ションです。

オプション           説明
                     
-----------------------------------------------------------------------------------
                     
xscrollcommand       水平方向のスクロールバーとのやり取りに使われます。
                     
                     ウィジェットのウィンドウが再描画されたとき, ウィジェットは
                     scrollcommand に基いて Tcl コマンドを生成します。
                     
                     通常このオプションにはあるスクロールバーのメソッド
                     ‘Scrollbar.set()’ が設定されます。こうすると、ウィンドウの
                     見た目が変わったときにスクロールバーの状態も更新されます。
                     
                     
yscrollcommand       垂直方向のスクロールバーとのやり取りに使われます。詳しくは
                     、上記を参照してください。
                     


File: python.info,  Node: ラベルオプション,  Next: 互換性オプション,  Prev: スクロール可能ウィジェットのオプション,  Up: ウィジェット

5.25.8.6 ラベルオプション
.........................

以下のオプションはラベルやボタンやボタンに類似したウィジェットが持ってい
るオプションです。

オプション         説明
                   
-----------------------------------------------------------------------------------
                   
text               ウィジェットに表示される文字列を指定します。
                   
                   
textvariable       text オプションの代わりに使う値の変数名を指定します。
                   
                   
underline          このオプションを設定すると、文字列の中で下線を引く文字のイン
                   デックス (0 基点) を指定します。下線が引かれた文字はショート
                   カットとして使われます。
                   
                   
image              表示する画像を指定します。これは 1 つ以上の要素を持つリストで
                   す。先頭の要素はデフォルトの画像名です。残りの要素は
                   *note Style.map(): 1888. で定義されているような状態名と値のペ
                   アの並びで、ウィジェットがある状態、もしくはある状態の組み合
                   わせにいるときに使用する別の画像を指定します。このリストにあ
                   る全ての画像は同じサイズでなればなりません。
                   
                   
compound           text オプションと image オプションが両方とも指定されていた場
                   合に、テキストに対して画像をどう配置するかを指定します。適当
                   な値は:
                   
                      * text: テキストのみ表示する
                   
                      * image: 画像のみ表示する
                   
                      * top, bottom, left, right: それぞれ画像をテキストの上、下
                        、左、右に配置する。
                   
                      * none: デフォルト。もしあれば画像を表示し、そうでなければ
                        テキストを表示する。
                   
                   
幅                 0 より大きい場合、テキストラベルを作成するのにどれくらいのス
                   ペースを使うかを文字の幅で指定します。0 より小さい場合、最小
                   の幅が指定されます。0 もしくは無指定の場合、テキストラベルに
                   対して自然な幅が使われます。
                   


File: python.info,  Node: 互換性オプション,  Next: ウィジェットの状態,  Prev: ラベルオプション,  Up: ウィジェット

5.25.8.7 互換性オプション
.........................

オプション   説明
             
----------------------------------------------------------------------------------
             
state        "normal" か "disabled" に設定され、 "disabled" 状態のビットをコン
             トロールします。これは書き込み専用のオプションです: これを設定する
             とウィジェットの状態を変更できますが、 *note Widget.state(): 3d60.
             メソッドはこのオプションに影響を及ぼしません。
             


File: python.info,  Node: ウィジェットの状態,  Next: ttk Widget,  Prev: 互換性オプション,  Up: ウィジェット

5.25.8.8 ウィジェットの状態
...........................

ウィジェットの状態は独立した状態フラグのビットマップです。

Flag             説明
                 
-----------------------------------------------------------------------------------
                 
active           マウスカーソルがウィジェットの上にあり、マウスのボタンをクリッ
                 クすることで何らかの動作をさせられます
                 
                 
disabled         プログラムによってウィジェットは無効化されています
                 
                 
focus            ウィジェットにキーボードフォーカスがあります
                 
                 
pressed          ウィジェットは押されています
                 
                 
selected         チェックボタンやラジオボタンのようなウィジェットでの "オン" や
                 "チェック有" や "選択中" に当たります
                 
                 
background       Windows と Mac には "アクティブな" もしくは最前面のウィンドウと
                 いう概念があります。背面のウィンドウにあるウィジェットには
                 'background' 状態が設定され、最前面のウィンドウにあるウィジェッ
                 トでは解除されます
                 
                 
readonly         ウィジェットはユーザからの変更を受け付けません
                 
                 
alternate        ウィジェット特有の切り替え表示になっています
                 
                 
invalid          ウィジェットの値が不正です
                 

状態仕様は状態名の並びになっていて、状態名の先頭にはビットがオフになって
いることを示す感嘆符が付くことがあります。


File: python.info,  Node: ttk Widget,  Prev: ウィジェットの状態,  Up: ウィジェット

5.25.8.9 ttk.Widget
...................

以下に書かれているメソッドに加えて、 ‘ttk.Widget’ は
‘tkinter.Widget.cget()’ メソッドと ‘tkinter.Widget.configure()’ メソッド
をサポートしています。

 -- クラス: tkinter.ttk.Widget

      -- メソッド: identify (x, y)

          'x' 'y' の位置にある要素の名前、もしくはその位置に要素が無けれ
          ば空文字列を返します。

          'x' と 'y' はウィジェットに対するピクセル単位の座標です。

      -- メソッド: instate (statespec, callback=None, *args, **kw)

          ウィジェットの状態をチェックします。コールバックが指定されてい
          ない場合、ウィジェットの状態が 'statespec' に一致していれば
          ‘True’ 、そうでなければ ‘False’ を返します。コールバックが指定
          されていて、ウィジェットの状態が 'statespec' に一致している場
          合、引数に args を指定してそのコールバックを呼び出します。

      -- メソッド: state (statespec=None)

          ウィジェットの状態を変更したり、取得したりします。'statespec'
          が指定されている場合、それに応じてウィジェットの状態を設定し、
          どのフラグが変更されたかを示す新しい 'statespec' を返します。
          'statespec' が指定されていない場合、現在の状態フラグを返します
          。

     通常 'statespec' はリストもしくはタプルです。


File: python.info,  Node: コンボボックス,  Next: Spinbox,  Prev: ウィジェット,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.10 コンボボックス
........................

‘ttk.Combobox’ ウィジェットはテキストフィールドと値のポップダウンリスト
を結び付けます。このウィジェットは ‘Entry’ の子クラスです。

*note Widget: 3d59. から継承したメソッド (‘Widget.cget()’,
‘Widget.configure()’, *note Widget.identify(): 3d63, *note
Widget.instate(): 3d64, *note Widget.state(): 3d60.) と以下の ‘Entry’ か
ら継承したメソッド (‘Entry.bbox()’, ‘Entry.delete()’, ‘Entry.icursor()’,
‘Entry.index()’, ‘Entry.insert()’, ‘Entry.selection()’, ‘Entry.xview()’)
に加え、このクラスには ‘ttk.Combobox’ で説明するメソッドがあります。

* Menu:

* オプション::
* 仮想イベント::
* ttk.Combobox: ttk Combobox.


File: python.info,  Node: オプション,  Next: 仮想イベント,  Up: コンボボックス

5.25.8.11 オプション
....................

このウィジェットは以下の固有のオプションを受け付けます:

オプション            説明
                      
-----------------------------------------------------------------------------------
                      
exportselection       真偽値を取る。設定されている場合、ウィジェットの選択はウィ
                      ンドウマネージャの選択とリンクしています (例えば、
                      Misc.selection_get を実行することで得られます)。
                      
                      
justify               ウィジェットの中でテキストをどう配置するかを指定します。
                      "left", "center", "right" のうちのどれか 1 つです。
                      
                      
高さ                  ポップダウンリストの高さを行数で指定します。
                      
                      
postcommand           コンボボックスの値を表示する直前に呼び出される、
                      (Misc.register などで登録した) スクリプトです。どの値を表
                      示するかについても指定できます。
                      
                      
state                 "normal", "readonly", "disabled" のどれか 1 つです。
                      "readonly" 状態では、直接入力値を編集することはできず、ユ
                      ーザはドロップダウンリストから値を 1 つ選ぶことしかできま
                      せん。"normal" 状態では、テキストフィールドは直接編集でき
                      ます。"disabled" 状態では、コンボボックスは一切反応しませ
                      ん。
                      
                      
textvariable          コンボボックスの値とリンクさせる変数名を指定します。その変
                      数の値が変更されたとき、ウィジェットの値は更新されます。ウ
                      ィジェットの値が更新されたときも同様です。
                      ‘tkinter.StringVar’ を参照してください。
                      
                      
‘values’              ドロップダウンリストに表示する値のリストを指定します。
                      
                      
幅                    入力ウィンドウに必要な幅をウィジェットのフォントの平均的な
                      サイズの文字で測った、文字数を指定します。
                      


File: python.info,  Node: 仮想イベント,  Next: ttk Combobox,  Prev: オプション,  Up: コンボボックス

5.25.8.12 仮想イベント
......................

コンボボックスウィジェットは、ユーザが値のリストから1つ選んだときに仮想
イベント '<<ComboboxSelected>>' を生成します。


File: python.info,  Node: ttk Combobox,  Prev: 仮想イベント,  Up: コンボボックス

5.25.8.13 ttk.Combobox
......................

 -- クラス: tkinter.ttk.Combobox

      -- メソッド: current (newindex=None)

          'newindex' が指定されている場合、コンボボックスの値がドロップ
          ダウンリストの 'newindex' の位置にある値に設定されます。そうで
          ない場合、現在の値のインデックスを、もしくは現在の値がリストに
          含まれていないなら -1 を返します。

      -- メソッド: get ()

          コンボボックスの現在の値を返します。

      -- メソッド: set (value)

          コンボボックスの値を 'value' に設定します。


File: python.info,  Node: Spinbox,  Next: ノートブック,  Prev: コンボボックス,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.14 Spinbox
.................

The ‘ttk.Spinbox’ widget is a ‘ttk.Entry’ enhanced with increment and
decrement arrows.  It can be used for numbers or lists of string values.
This widget is a subclass of ‘Entry’.

*note Widget: 3d59. から継承したメソッド: ‘Widget.cget()’,
‘Widget.configure()’, *note Widget.identify(): 3d63, *note
Widget.instate(): 3d64, *note Widget.state(): 3d60. と、以下の ‘Entry’ か
ら継承したメソッド: ‘Entry.bbox()’, ‘Entry.delete()’, ‘Entry.icursor()’,
‘Entry.index()’, ‘Entry.insert()’, ‘Entry.xview()’ に加え、このクラスに
は ‘ttk.Spinbox’ で説明するいくつかのメソッドがあります。

* Menu:

* オプション: オプション<2>.
* 仮想イベント: 仮想イベント<2>.
* ttk.Spinbox: ttk Spinbox.


File: python.info,  Node: オプション<2>,  Next: 仮想イベント<2>,  Up: Spinbox

5.25.8.15 オプション
....................

このウィジェットは以下の固有のオプションを受け付けます:

オプション                 説明
                           
--------------------------------------------------------------------------------------
                           
from                       Float value.  If set, this is the minimum value to which
                           the decrement button will decrement.  Must be spelled as
                           ‘from_’ when used as an argument, since ‘from’ is a
                           Python keyword.
                           
                           
to                         Float value.  If set, this is the maximum value to which
                           the increment button will increment.
                           
                           
increment                  Float value.  Specifies the amount which the
                           increment/decrement buttons change the value.  Defaults
                           to 1.0.
                           
                           
‘values’                   Sequence of string or float values.  If specified, the
                           increment/decrement buttons will cycle through the items
                           in this sequence rather than incrementing or
                           decrementing numbers.
                           
                           
wrap                       Boolean value.  If ‘True’, increment and decrement
                           buttons will cycle from the ‘to’ value to the ‘from’
                           value or the ‘from’ value to the ‘to’ value,
                           respectively.
                           
                           
format                     String value.  This specifies the format of numbers set
                           by the increment/decrement buttons.  It must be in the
                           form "%W.Pf", where W is the padded width of the value,
                           P is the precision, and '%' and 'f' are literal.
                           
                           
command                    Python callable.  Will be called with no arguments
                           whenever either of the increment or decrement buttons
                           are pressed.
                           


File: python.info,  Node: 仮想イベント<2>,  Next: ttk Spinbox,  Prev: オプション<2>,  Up: Spinbox

5.25.8.16 仮想イベント
......................

The spinbox widget generates an '<<Increment>>' virtual event when the
user presses <Up>, and a '<<Decrement>>' virtual event when the user
presses <Down>.


File: python.info,  Node: ttk Spinbox,  Prev: 仮想イベント<2>,  Up: Spinbox

5.25.8.17 ttk.Spinbox
.....................

 -- クラス: tkinter.ttk.Spinbox

      -- メソッド: get ()

          Returns the current value of the spinbox.

      -- メソッド: set (value)

          Sets the value of the spinbox to 'value'.


File: python.info,  Node: ノートブック,  Next: プログレスバー,  Prev: Spinbox,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.18 ノートブック
......................

ノートブックウィジェットは複数のウィンドウを管理し、同時に 1 つのウィン
ドウを表示します。それぞれの子ウィンドウはタブの関連付けられていて、ユー
ザはそれを選択して表示されているウィンドウを切り替えます。

* Menu:

* オプション: オプション<3>.
* タブオプション::
* タブ識別子::
* 仮想イベント: 仮想イベント<3>.
* ttk.Notebook: ttk Notebook.


File: python.info,  Node: オプション<3>,  Next: タブオプション,  Up: ノートブック

5.25.8.19 オプション
....................

このウィジェットは以下の固有のオプションを受け付けます:

オプション    説明
              
-----------------------------------------------------------------------------------
              
高さ          0 より大きな値が設定されている場合、 (内部のパディングやタブを含ま
              ない) ペイン領域に必要な高さを指定します。設定されていない場合、全
              てのペインの高さの最大値が使われます。
              
              
padding       ノートブックの外周に付け足す追加の領域の量を指定します。パディング
              は最大 4 個の長さ指定のリストです: 左、上、右、下の順で指定します
              。4 個より少ない場合、デフォルトで下は上と、右は左と、上は左と同じ
              値が、それぞれ使われます。
              
              
幅            0 より大きな値が指定されている場合、(内部のパディングを含まない) ペ
              イン領域に必要な幅を指定します。設定されていない場合、全てのペイン
              の幅の最大値が使われます。
              


File: python.info,  Node: タブオプション,  Next: タブ識別子,  Prev: オプション<3>,  Up: ノートブック

5.25.8.20 タブオプション
........................

タブ用のオプションもあります:

オプション      説明
                
-----------------------------------------------------------------------------------
                
state           "normal", "disabled", "hidden" のうちどれか 1 つです。
                "disabled" の場合、タブは選択することができません。 "hidden" の
                場合、タブは表示されません。
                
                
sticky          ペイン領域の中に子ウィンドウがどう置かれるかを指定します。指定す
                る値は "n", "s", "e", "w" からなる 0 文字以上の文字列です。配置
                マネージャの ‘grid()’ と同様に、それぞれの文字は子ウィンドウが
                (北、南、東、西の) どの辺に対して追随するかに対応しています。
                
                
padding         ノートブックとこのペインの間に付け足す追加の領域の量を指定します
                。文法はこのウィジェットの padding オプションと同じです。
                
                
text            タブに表示するテキストを指定します。
                
                
image           タブに表示する画像を指定します。 *note Widget: 3d59. のオプショ
                ン image の説明を参照してください。
                
                
compound        text オプションと image オプションが両方指定されているときにテキ
                ストに対して画像をどう表示するかを指定します。指定する値について
                は *note Label Options: 3d5e. を参照してください。
                
                
underline       テキスト中の下線を引く文字のインデックス (0 基点) を指定します。
                *note Notebook.enable_traversal(): 3d75. が呼ばれていた場合、下
                線が引かれた文字はショートカットとして使われます。
                


File: python.info,  Node: タブ識別子,  Next: 仮想イベント<3>,  Prev: タブオプション,  Up: ノートブック

5.25.8.21 タブ識別子
....................

‘ttk.Notebook’ のいくつかのメソッドにある 'tab_id' は以下の形式を取りま
す:

   * 0 からタブの数の間の整数

   * 子ウィンドウの名前

   * タブを指し示す "@x,y" という形式の位置指定

   * 現在選択されているタブを指し示すリテラル文字列 "current"

   * タブ数を返すリテラル文字列 "end" (*note Notebook.index(): 3d77. で
     のみ有効)


File: python.info,  Node: 仮想イベント<3>,  Next: ttk Notebook,  Prev: タブ識別子,  Up: ノートブック

5.25.8.22 仮想イベント
......................

このウィジェットは新しいタブが選択された後に仮想イベント
'<<NotebookTabChanged>>' を生成します。


File: python.info,  Node: ttk Notebook,  Prev: 仮想イベント<3>,  Up: ノートブック

5.25.8.23 ttk.Notebook
......................

 -- クラス: tkinter.ttk.Notebook

      -- メソッド: add (child, **kw)

          ノートブックに新しいタブを追加します。

          ウィンドウが現在ノートブックによって管理されているが隠れている
          場合、以前の位置に復元します。

          利用可能なオプションのリストについては *note Tab Options:
          3d74. を参照してください。

      -- メソッド: forget (tab_id)

          'tab_id' で指定されたタブを削除します。関連付けられていたウィ
          ンドウは切り離され、管理対象でなくなります。

      -- メソッド: hide (tab_id)

          'tab_id' で指定されたタブを隠します。

          タブは表示されませんが、関連付いているウィンドウはノートブック
          によって保持されていて、その設定も記憶されています。隠れたタブ
          は *note add(): 3d7a. コマンドで復元できます。

      -- メソッド: identify (x, y)

          'x' 'y' の位置にあるタブの名前を、そこにタブが無ければ空文字列
          を返します。

      -- メソッド: index (tab_id)

          'tab_id' で指定されたタブのインデックスを、 'tab_id' が文字列
          の "end" だった場合はタブの総数を返します。

      -- メソッド: insert (pos, child, **kw)

          指定された位置にペインを挿入します。

          'pos' は文字列の "end" か整数のインデックスか管理されている子
          ウィンドウの名前です。 'child' が既にノートブックの管理対象だ
          った場合、指定された場所に移動させます。

          利用可能なオプションのリストについては *note Tab Options:
          3d74. を参照してください。

      -- メソッド: select (tab_id=None)

          指定された 'tab_id' を選択します。

          関連付いている子ウィンドウは表示され、直前に選択されていたウィ
          ンドウは (もし異なれば) 表示されなくなります。 'tab_id' が指定
          されていない場合は、現在選択されているペインのウィジェット名を
          返します。

      -- メソッド: tab (tab_id, option=None, **kw)

          指定された 'tab_id' のオプションを問い合わせたり、変更したりし
          ます。

          'kw' が与えられなかった場合、タブのオプション値の辞書を返しま
          す。 'option' が指定されていた場合、その 'option' の値を返しま
          す。それ以外の場合は、オプションに対応する値が設定されます。

      -- メソッド: tabs ()

          ノートブックに管理されているウィンドウのリストを返します。

      -- メソッド: enable_traversal ()

          このノートブックを含む最上位にあるウィンドウでのキーボード移動
          を可能にします。

          これによりノートブックを含んだ最上位にあるウィンドウに対し、以
          下のキーバインディングが追加されます:

             * ‘Control-Tab’: 現在選択されているタブの 1 つ次のタブを選
               択します。

             * ‘Shift-Control-Tab’: 現在選択されているタブの 1 つ前のタ
               ブを選択します。

             * ‘Alt-K’: 'K' があるタブの (下線が引かれた) ショートカット
               キーだとして、そのタブを選択します。

          ネストしたノートブックも含め、1 つのウィンドウの最上位にある複
          数のノートブックのキーボード移動が可能になることもあります。し
          かしノートブック上の移動は、全てのペインが同じノートブックを親
          としているときのみ正しく動作します。


File: python.info,  Node: プログレスバー,  Next: セパレータ,  Prev: ノートブック,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.24 プログレスバー
........................

‘ttk.Progressbar’ ウィジェットは長く走る処理の状態を表示します。このウィ
ジェットは 2 つのモードで動作します: 1) 決定的モードでは、全ての処理の総
量のうち完了した量を表示します。 2) 非決定的モードでは、今作業が進んでい
ることをユーザに示します。

* Menu:

* オプション: オプション<4>.
* ttk.Progressbar: ttk Progressbar.


File: python.info,  Node: オプション<4>,  Next: ttk Progressbar,  Up: プログレスバー

5.25.8.25 オプション
....................

このウィジェットは以下の固有のオプションを受け付けます:

オプション     説明
               
-----------------------------------------------------------------------------------
               
orient         "horizontal" もしくは "vertical" のいずれかです。プログレスバーの
               方向を指定します。
               
               
length         プログレスバーの長さを指定します。 (水平方向の場合は幅、垂直方向
               の場合は高さです)
               
               
mode           "determinate" か "indeterminate" のいずれかです。
               
               
maximum        最大値を数値で指定します。デフォルトは 100 です。
               
               
value          プログレスバーの現在値です。決定的 ("determinate") モードでは、完
               了した処理の量を表します。非決定的 ("indeterminate") モードでは、
               'maximum' を法として解釈され、値が 'maximum' に達したときにプログ
               レスバーは 1 "サイクル" を完了したことになります。
               
               
variable       value オプションとリンクさせる変数名です。指定されている場合、変
               数の値が変更されるとプログレスバーの値は自動的にその値に設定され
               ます。
               
               
phase          読み出し専用のオプションです。このウィジェットの値が 0 より大きく
               、かつ決定的モードでは最大値より小さいときに、ウィジェットが定期
               的にこのオプションの値を増加させます。このオプションは現在の画面
               テーマが追加のアニメーション効果を出すのに使います。
               


File: python.info,  Node: ttk Progressbar,  Prev: オプション<4>,  Up: プログレスバー

5.25.8.26 ttk.Progressbar
.........................

 -- クラス: tkinter.ttk.Progressbar

      -- メソッド: start (interval=None)

          自動増加モードを開始します: 'interval' ミリ秒ごとに *note
          Progressbar.step(): 3d86. を繰り返し呼び出すタイマーイベントを
          設定します。引数で指定しない場合は、 'interval' はデフォルトで
          50 ミリ秒になります。

      -- メソッド: step (amount=None)

          プログレスバーの値を 'amount' だけ増加させます。

          引数で指定しない場合は、 'amount' はデフォルトで 1.0 になりま
          す。

      -- メソッド: stop ()

          自動増加モードを停止します: このプログレスバーの *note
          Progressbar.start(): 3d85. で開始された繰り返しのタイマーイベ
          ントを全てキャンセルします。


File: python.info,  Node: セパレータ,  Next: サイズグリップ,  Prev: プログレスバー,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.27 セパレータ
....................

‘ttk.Separator’ ウィジェットは水平もしくは垂直のセパレータを表示します。

‘ttk.Widget’ から継承したメソッド以外にメソッドを持ちません。

* Menu:

* オプション: オプション<5>.


File: python.info,  Node: オプション<5>,  Up: セパレータ

5.25.8.28 オプション
....................

このウィジェットは次の特定のオプションを受け付けます。

オプション   説明
             
----------------------------------------------------------------------------------
             
orient       "horizontal" か "vertical" のいずれかです。セパレータの方向を指定
             します。
             


File: python.info,  Node: サイズグリップ,  Next: ツリービュー,  Prev: セパレータ,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.29 サイズグリップ
........................

(グローボックスとしても知られる) ‘ttk.Sizegrip’ ウィジェットを使用すると
、つまみ部分を押してドラッグすることで、このウィジェットを含む最上位のウ
ィンドウのサイズを変更できます。

このウィジェットは ‘ttk.Widget’ から継承したもの以外のオプションとメソッ
ドを持ちません。

* Menu:

* プラットフォーム固有のメモ::
* バグ::


File: python.info,  Node: プラットフォーム固有のメモ,  Next: バグ,  Up: サイズグリップ

5.25.8.30 プラットフォーム固有のメモ
....................................

   * macOS では、最上位のウィンドウにはデフォルトで組み込みのサイズグリ
     ップが含まれています。組み込みのグリップが ‘Sizegrip’ を隠してしま
     うので、 ‘Sizegrip’ を追加しても問題ありません。


File: python.info,  Node: バグ,  Prev: プラットフォーム固有のメモ,  Up: サイズグリップ

5.25.8.31 バグ
..............

   * このウィジェットを含む最上位のウィンドウの位置がスクリーンの右端や
     下端に対して相対的に指定されている場合 (例: ....)  、 ‘Sizegrip’ ウ
     ィジェットはウィンドウのサイズ変更をしません。

   * このウィジェットは "南東" 方向のサイズ変更しかサポートしていません
     。


File: python.info,  Node: ツリービュー,  Next: Ttk スタイル,  Prev: サイズグリップ,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.32 ツリービュー
......................

‘ttk.Treeview’ ウィジェットは階層のある要素 (アイテム) の集まりを表示し
ます。それぞれの要素はテキストラベル、オプションの画像、オプションのデー
タのリストを持っています。データはラベルの後に続くカラムに表示されます。

データが表示される順序はウィジェットの ‘displaycolumns’ オプションで制御
されます。ツリーウィジェットはカラムヘッダを表示することもできます。カラ
ムには数字もしくはウィジェットの columns オプションにある名前でアクセス
できます。 *note Column Identifiers: 3d8e. を参照してください。

それぞれの要素は一意な名前で識別されます。要素の作成時に識別子が与えられ
なかった場合、ウィジェットが要素の識別子を生成します。このウィジェットに
は ‘{}’ という名前の特別なルート要素があります。ルート要素自身は表示され
ません; その子要素たちが階層の最上位に現れます。

それぞれの要素はタグのリストも持っていて、イベントバインディングと個別の
要素を関連付け、要素の見た目を管理するのに使えます。

ツリービューウィジェットは水平方向と垂直方向のスクロールをサポートしてい
て、 *note Scrollable Widget Options: 3d5d. に記述してあるオプションと
*note Treeview.xview(): 3d8f. メソッドおよび *note Treeview.yview():
3d90. メソッドが使えます。

* Menu:

* オプション: オプション<6>.
* 要素オプション::
* タグオプション::
* カラム識別子::
* 仮想イベント: 仮想イベント<4>.
* ttk.Treeview: ttk Treeview.


File: python.info,  Node: オプション<6>,  Next: 要素オプション,  Up: ツリービュー

5.25.8.33 オプション
....................

このウィジェットは以下の固有のオプションを受け付けます:

オプション           説明
                     
----------------------------------------------------------------------------------
                     
columns              カラム数とその名前を指定するカラム識別子のリストです。
                     
                     
displaycolumns       どのデータカラムをどの順序で表示するかを指定する、 (名前も
                     しくは整数のインデックスの) カラム識別子のリストか、文字列
                     "#all" です。
                     
                     
高さ                 表示する行数を指定します。メモ: 表示に必要な幅はカラム幅の
                     合計から決定されます。
                     
                     
padding              ウィジェットの内部のパディングのサイズを指定します。パディ
                     ングは最大 4 個の長さ指定のリストです。
                     
                     
selectmode           組み込みのクラスバインディングが選択状態をどう管理するかを
                     指定します。設定する値は "extended", "browse", "none" のど
                     れか 1 つです。 "extended" に設定した場合 (デフォルト)、複
                     数の要素が選択できます。 "browse" に設定した場合、同時に 1
                     つの要素しか選択できません。 "none" に設定した場合、選択を
                     変更することはできません。
                     
                     このオプションの値によらず、アプリケーションのコードと関連
                     付けられているタグからは好きなように選択状態を設定できます
                     。
                     
                     
show                 ツリーのどの要素を表示するかを指定する、以下にある値を 0 個
                     以上含むリストです。
                     
                        * tree: カラム #0 にツリーのラベルを表示します。
                     
                        * headings: ヘッダ行を表示します。
                     
                     デフォルトは "tree headings" 、つまり全ての要素を表示しま
                     す。
                     
                     'メモ': show="tree" が指定されていない場合でも、カラム #0
                     は常にツリーカラムを参照します。
                     


File: python.info,  Node: 要素オプション,  Next: タグオプション,  Prev: オプション<6>,  Up: ツリービュー

5.25.8.34 要素オプション
........................

以下の要素オプションは、ウィジェットの insert コマンドと item コマンドで
要素に対して指定できます。

オプション   説明
             
---------------------------------------------------------------------------------
             
text         アイテムに表示するテキストラベルです。
             
             
image        ラベルの左に表示される Tk 画像です。
             
             
‘values’     要素に関連付けられている値のリストです。
             
             それぞれの要素はウィジェットの columns オプションと同じ数の値を持
             たなければいけません。 columns オプションより少ない場合、残りの値
             は空として扱われます。 columns オプションより多い場合、余計な値は
             無視されます。
             
             
open         要素の子供を表示するか隠すかを指示する ‘True’/‘False’ 値です。
             
             
tags         この要素に関連付いているタグのリストです。
             


File: python.info,  Node: タグオプション,  Next: カラム識別子,  Prev: 要素オプション,  Up: ツリービュー

5.25.8.35 タグオプション
........................

以下のオプションはタグに対して設定できます:

オプション       説明
                 
---------------------------------------------------------------------------------
                 
foreground       テキストの色を指定します。
                 
                 
background       セルや要素の背景色を指定します。
                 
                 
font             テキストを描画するときに使うフォントを指定します。
                 
                 
image            要素の image オプションが空だった場合に使用する画像を指定しま
                 す。
                 


File: python.info,  Node: カラム識別子,  Next: 仮想イベント<4>,  Prev: タグオプション,  Up: ツリービュー

5.25.8.36 カラム識別子
......................

カラム識別子は以下のいずれかの形式を取ります:

   * columns オプションのリストにある名前。

   * n 番目のデータカラムを指し示す整数 n 。

   * n を整数として n 番目の表示されているカラムを指し示す #n という形式
     の文字列。

注釈:

   * 要素のオプション値は実際に格納されている順序とは違った順序で表示さ
     れることがあります。

   * show="tree" が指定されていない場合でも、カラム #0 は常にツリーカラ
     ムを指しています。

データカラムを指す数字は、要素の values オプションのリストのインデックス
です; 表示カラムを指す数字は、値が表示されているツリーのカラム番号です。
ツリーラベルはカラム #0 に表示されます。 displaycolumns オプションが設定
されていない場合は、 n 番目のデータカラムはカラム #n+1 に表示されます。
再度言っておくと、 'カラム #0 は常にツリーカラムを指します' 。


File: python.info,  Node: 仮想イベント<4>,  Next: ttk Treeview,  Prev: カラム識別子,  Up: ツリービュー

5.25.8.37 仮想イベント
......................

ツリービューは以下の仮想イベントを生成します。

Event                    説明
                         
--------------------------------------------------------------------------------
                         
<<TreeviewSelect>>       選択状態が変更されたときに生成されます。
                         
                         
<<TreeviewOpen>>         フォーカスが当たっている要素に open=True が設定され
                         る直前に生成されます。
                         
                         
<<TreeviewClose>>        フォーカスが当たっている要素に open=False が設定され
                         た直後に生成されます。
                         

*note Treeview.focus(): 3d95. メソッドと *note Treeview.selection():
a61. メソッドは変更を受けた要素を判別するのに使えます。


File: python.info,  Node: ttk Treeview,  Prev: 仮想イベント<4>,  Up: ツリービュー

5.25.8.38 ttk.Treeview
......................

 -- クラス: tkinter.ttk.Treeview

      -- メソッド: bbox (item, column=None)

          (ツリービューウィジェットのウィンドウを基準として) 指定された
          'item' のバウンディングボックス情報を (x 座標, y 座標, 幅, 高
          さ) の形式で返します。

          'column' が指定されている場合は、セルのバウンディングボックス
          を返します。 (例えば、閉じた状態の要素の子供であったり、枠外に
          スクロールされていて) 'item' が見えなくなっている場合は、空文
          字列が返されます。

      -- メソッド: get_children (item=None)

          'item' の子要素のリストを返します。

          'item' が指定されていなかった場合は、ルート要素の子供が返され
          ます。

      -- メソッド: set_children (item, *newchildren)

          'item' の子要素を 'newchildren' で置き換えます。

          'item' にいる子供のうち 'newchildren' にないものはツリーから切
          り離されます。 'newchildren' にあるどの要素も 'item' の祖先で
          あってはいけません。 'newchildren' を指定しなかった場合は、
          'item' の子要素が全て切り離されることに注意してください。

      -- メソッド: column (column, option=None, **kw)

          指定した 'column' のオプションを問い合わせたり、変更したりしま
          す。

          'kw' が与えられなかった場合は、カラムのオプション値の辞書が返
          されます。 'option' が指定されていた場合は、その 'option' の値
          が返されます。それ以外の場合は、オプションに値を設定します。

          設定できるオプションとその値は次の通りです:

          'id'

               カラム名を返します。これは読み出し専用のオプションです。

          'anchor': One of the standard Tk anchor values.

               このカラムでセルに対してテキストをどう配置するかを指定し
               ます。

          'minwidth': width

               カラムの最小幅をピクセル単位で表したものです。ツリービュ
               ーウィジェットは、ウィジェットのサイズが変更されたりカラ
               ムをユーザがドラッグして移動させたりしたときに、このオプ
               ションで指定した幅より狭くすることはありません。

          'stretch': ‘True’/‘False’

               ウィジェットがサイズ変更されたとき、カラムの幅をそれに合
               わせるかどうかを指定します。

          'width': width

               カラムの幅をピクセル単位で表したものです。

          ツリーカラムの設定を行うには、 column = "#0" を付けてこのメソ
          ッドを呼び出してください。

      -- メソッド: delete (*items)

          指定された 'items' とその子孫たち全てを削除します。

          ルート要素は削除されません。

      -- メソッド: detach (*items)

          指定された 'items' を全てツリーから切り離します。

          その要素と子孫たちは依然として存在していて、ツリーの別の場所に
          再度挿入することができますが、隠された状態になり表示はされませ
          ん。

          ルート要素は切り離されません。

      -- メソッド: exists (item)

          指定された 'item' がツリーの中にあれば ‘True’ を返します。

      -- メソッド: focus (item=None)

          'item' が指定されていた場合は、 'item' にフォーカスを当てます
          。そうでない場合は、現在フォーカスが当たっている要素が、どの要
          素にもフォーカスが当たっていない場合は '' が返されます。

      -- メソッド: heading (column, option=None, **kw)

          指定された 'column' の heading のオプションを問い合わせたり、
          変更したりします。

          'kw' が与えられなかった場合は、見出しのオプション値の辞書が返
          されます。 'option' が指定されている場合は、 'option' の値が返
          されます。それ以外の場合は、オプションに値を設定します。

          設定できるオプションとその値は次の通りです:

          'text': text

               カラムの見出しに表示するテキスト。

          'image': imageName

               カラムの見出しの右に表示する画像を指定します。

          'anchor': anchor

               見出しのテキストをどう配置するかを指定します。標準の Tk
               anchor の値です。

          'command': callback

               見出しラベルがクリックされたときに実行されるコールバック
               です。

          ツリーカラムの見出しの設定を行うには、 column = "#0" を付けて
          このメソッドを呼び出してください。

      -- メソッド: identify (component, x, y)

          'x' 'y' で与えられた場所にある指定された 'component' の説明を
          返します。その場所に指定された 'component' が無い場合は空文字
          列を返します。 (訳注: component には "region", "item",
          "column", "row", "element" が指定でき、それぞれ "cell",
          "heading" などの場所の名前、要素の識別子、 #n という形式のカラ
          ム名、その行にある要素の識別子、 "text", "padding" などの画面
          構成要素の名前を返します。)

      -- メソッド: identify_row (y)

          y 座標が 'y' の位置にある要素の識別子を返します。

      -- メソッド: identify_column (x)

          x 座標が 'x' の位置にあるセルのデータカラムの識別子を返します
          。

          ツリーカラムは #0 という識別子を持ちます。

      -- メソッド: identify_region (x, y)

          以下のうち 1 つを返します:

          region          意味
                          
          -----------------------------------------------------------
                          
          heading         ツリーの見出し領域
                          
                          
          separator       2 つのカラム見出しの間のスペース
                          
                          
          tree            ツリーの領域
                          
                          
          cell            データセル
                          

          使用可能バージョン: Tk 8.6

      -- メソッド: identify_element (x, y)

          'x' 'y' の位置にある画面構成要素の名前を返します。

          使用可能バージョン: Tk 8.6

      -- メソッド: index (item)

          親要素の子要素リストの中での 'item' のインデックスを返します。

      -- メソッド: insert (parent, index, iid=None, **kw)

          新しい要素を作り、その要素の識別子を返します。

          'parent' は親となる要素の識別子で、空文字列にすると新しい要素
          を最上位に作成します。 'index' は整数もしくは "end" という値で
          、それによって親要素の子要素リストのどこに新しい要素を挿入する
          かを指定します。 'index' が 0 以下だった場合は、新しい要素は先
          頭に挿入されます; 'index' が現在の子要素の数以上だった場合は末
          尾に挿入されます。 'iid' が指定された場合は、要素の識別子とし
          て使われます; 'iid' はまだツリーに存在していないものに限ります
          。それ以外の場合は、一意な識別子が生成されます。

          See *note Item Options: 3d92. for the list of available
          options.

      -- メソッド: item (item, option=None, **kw)

          指定された 'item' のオプションを問い合わせたり、変更したりしま
          す。

          オプションが与えられなかった場合は、要素のオプションと値が辞書
          の形で返されます。 'option' が指定された場合は、そのオプション
          の値が返されます。それ以外の場合は、 'kw' で与えられたようにオ
          プションに値が設定されます。

      -- メソッド: move (item, parent, index)

          'item' を 'parent' の子要素リストの 'index' の位置に移動します
          。

          要素を自身の子孫の下に移動させるのは許されていません。 'index'
          が 0 以下の場合、 'item' は先頭に移動されます; 子要素の数以上
          だった場合、末尾に移動されます。 'item' が切り離された状態の場
          合は、再度取り付けられます。

      -- メソッド: next (item)

          'item' の 1 つ下の兄弟の識別子を、 'item' が親にとって一番下の
          子供だった場合 '' を返します。

      -- メソッド: parent (item)

          'item' の親の識別子を、 'item' が階層の最上位にいた場合 '' を
          返します。

      -- メソッド: prev (item)

          'item' の 1 つ上の兄弟の識別子を、 'item' が親にとって一番上の
          子供だった場合 '' を返します。

      -- メソッド: reattach (item, parent, index)

          *note Treeview.move(): 3da7. のエイリアスです。

      -- メソッド: see (item)

          'item' を見える状態にします。

          'item' の全ての子孫の open オプションを ‘True’ にし、必要であ
          れば 'item' がツリーの見える範囲に来るようにウィジェットをスク
          ロールさせます。

      -- メソッド: selection ()

          Returns a tuple of selected items.

          バージョン 3.8 で変更: ‘selection()’ no longer takes
          arguments.  For changing the selection state use the following
          selection methods.

      -- メソッド: selection_set (*items)

          新しく選択状態の要素が 'items' になります。

          バージョン 3.6 で変更: 'items' は 1 つのタプルとしてだけでなく
          、別々の引数としても渡せます。

      -- メソッド: selection_add (*items)

          選択状態の要素として 'items' を追加します。

          バージョン 3.6 で変更: 'items' は 1 つのタプルとしてだけでなく
          、別々の引数としても渡せます。

      -- メソッド: selection_remove (*items)

          選択状態の要素から 'items' を取り除きます。

          バージョン 3.6 で変更: 'items' は 1 つのタプルとしてだけでなく
          、別々の引数としても渡せます。

      -- メソッド: selection_toggle (*items)

          'items' のそれぞれの要素の選択状態を入れ替えます。

          バージョン 3.6 で変更: 'items' は 1 つのタプルとしてだけでなく
          、別々の引数としても渡せます。

      -- メソッド: set (item, column=None, value=None)

          1 引数で呼び出された場合、指定された 'item' のカラムと値のペア
          からなる辞書を返します。 2 引数で呼び出された場合、指定された
          'column' の現在の値を返します。 3 引数で呼び出された場合、与え
          られた 'item' の 'column' を指定された値 'value' に設定します
          。

      -- メソッド: tag_bind (tagname, sequence=None, callback=None)

          与えられたイベント 'sequence' 用のコールバックをタグ 'tagname'
          にバインドします。イベントが要素に渡ってきたときに、要素の
          tags オプションのそれぞれのコールバックが呼び出されます。

      -- メソッド: tag_configure (tagname, option=None, **kw)

          指定された 'tagname' のオプションを問い合わせたり、変更したり
          します。

          'kw' が与えられなかった場合、 'tagname' のオプション設定を辞書
          の形で返します。 'option' が指定された場合、指定された
          'tagname' の 'option' の値を返します。それ以外の場合、与えられ
          た 'tagname' のオプションに値を設定します。

      -- メソッド: tag_has (tagname, item=None)

          'item' が指定されていた場合、指定された 'item' が与えられた
          'tagname' を持っているかどうかに従って 1 または 0 が返されます
          。そうでない場合、指定されたタグを持つ全ての要素のリストを返し
          ます。

          使用可能バージョン: Tk 8.6

      -- メソッド: xview (*args)

          ツリービューの水平方向の位置を問い合わせたり、変更したりします
          。

      -- メソッド: yview (*args)

          ツリービューの垂直方向の位置を問い合わせたり、変更したりします
          。


File: python.info,  Node: Ttk スタイル,  Prev: ツリービュー,  Up: tkinter ttk --- Tk のテーマ付きウィジェット

5.25.8.39 Ttk スタイル
......................

‘ttk’ のそれぞれのウィジェットにはスタイルが関連付けられていて、それと動
的もしくはデフォルトで設定される要素のオプションによってウィジェットを構
成する要素とその配置を指定します。デフォルトではスタイル名はウィジェット
のクラス名と同じですが、ウィジェットの style オプションで上書きすること
ができます。ウィジェットのクラス名が分からない場合は、
‘Misc.winfo_class()’ (somewidget.winfo_class()) メソッドを使ってください
。

参考
....

Tcl'2004 conference のプレゼンテーション(1)

     この文書ではテーマエンジンがどう動くかを説明しています

 -- クラス: tkinter.ttk.Style

     このクラスはスタイルデータベースを操作するために使われます。

      -- メソッド: configure (style, query_opt=None, **kw)

          'style' の指定されたオプションのデフォルト値を問い合わせたり、
          設定したりします。

          'kw' のそれぞれのキーはオプション名で値はそのオプションの値の
          文字列です。

          例えば、全てのデフォルトのボタンをパディングのある平らな見た目
          にし、背景の色を変更するには以下のようにします:

               from tkinter import ttk
               import tkinter

               root = tkinter.Tk()

               ttk.Style().configure("TButton", padding=6, relief="flat",
                  background="#ccc")

               btn = ttk.Button(text="Sample")
               btn.pack()

               root.mainloop()

      -- メソッド: map (style, query_opt=None, **kw)

          'style' の指定されたオプションの動的な値を問い合わせたり、設定
          したりします。

          'kw' のそれぞれのキーはオプション名で、値はタプルやリストや何
          か他のお好みのものでグループ化された状態仕様 (statespec) を要
          素とするリストやタプルです。状態仕様は 1 つもしくは複数の状態
          と値の組み合わせです。

          以下のように、例を示す方がわかりやすいでしょう:

               import tkinter
               from tkinter import ttk

               root = tkinter.Tk()

               style = ttk.Style()
               style.map("C.TButton",
                   foreground=[('pressed', 'red'), ('active', 'blue')],
                   background=[('pressed', '!disabled', 'black'), ('active', 'white')]
                   )

               colored_btn = ttk.Button(text="Test", style="C.TButton").pack()

               root.mainloop()

          あるオプションに対する状態と値の組 (states, value) の並び順は
          スタイルに影響を与えることに注意してください。例えば、
          foreground オプションの順序を ‘[('active', 'blue'),
          ('pressed', 'red')]’ に変更した場合、ウィジェットがアクティブ
          もしくは押された状態のとき前面が青くなります。

      -- メソッド: lookup (style, option, state=None, default=None)

          'style' の指定された 'option' の値を返します。

          'state' を指定する場合は、1 つ以上の状態名の並びである必要があ
          ります。 'default' 引数が指定されていた場合は、オプション指定
          が見付からなかったときに代わりに返される値として使われます。

          デフォルトでボタンがどのフォントを使うかを調べるには、以下のよ
          うに実行します:

               from tkinter import ttk

               print(ttk.Style().lookup("TButton", "font"))

      -- メソッド: layout (style, layoutspec=None)

          与えられた 'style' でのウィジェットのレイアウトを定義します。
          'layoutspec' が省略されていた場合は、与えられたスタイルのレイ
          アウト仕様を返します。

          'layoutspec' を指定する場合は、リストもしくは (文字列を除いた)
          何か他のシーケンス型である必要があります。それぞれの要素はタプ
          ルで、レイアウト名を 1 番目の要素とし、2 番目の要素は *note
          Layouts: 3db8. で説明されているフォーマットである必要がありま
          す。

          フォーマットを理解するために以下の例を見てください (何かを使い
          易くするための例ではありません):

               from tkinter import ttk
               import tkinter

               root = tkinter.Tk()

               style = ttk.Style()
               style.layout("TMenubutton", [
                  ("Menubutton.background", None),
                  ("Menubutton.button", {"children":
                      [("Menubutton.focus", {"children":
                          [("Menubutton.padding", {"children":
                              [("Menubutton.label", {"side": "left", "expand": 1})]
                          })]
                      })]
                  }),
               ])

               mbtn = ttk.Menubutton(text='Text')
               mbtn.pack()
               root.mainloop()

      -- メソッド: element_create (elementname, etype, *args, **kw)

          Create a new element in the current theme, of the given
          'etype' which is expected to be either "image", "from" or
          "vsapi".  The latter is only available in Tk 8.6 on Windows.

          "image" が使われた場合、 'args' はデフォルトの画像名の後ろに状
          態仕様と値のペア (これが画像仕様です) を並べたものである必要が
          あります。 'kw' には以下のオプションが指定できます:

          border=padding

               padding は 4 個以下の整数のリストで、それぞれ左、上、右、
               下の縁の幅を指定します。

          height=height

               要素の最小の高さを指定します。0 より小さい場合は、画像の
               高さをデフォルトとして使用します。

          padding=padding

               要素の内部のパディングを指定します。指定されない場合は、
               border の値がデフォルトとして使われます。

          sticky=spec

               1 つ外側の枠に対し画像をどう配置するかを指定します。 spec
               は "n", "s", "w", "e" の文字を 0 個以上含みます。

          width=width

               要素の最小の幅を指定します。0 より小さい場合は、画像の幅
               をデフォルトとして使用します。

          以下はプログラム例です:

               img1 = tkinter.PhotoImage(master=root, file='button.png')
               img1 = tkinter.PhotoImage(master=root, file='button-pressed.png')
               img1 = tkinter.PhotoImage(master=root, file='button-active.png')
               style = ttk.Style(root)
               style.element_create('Button.button', 'image',
                                    img1, ('pressed', img2), ('active', img3),
                                    border=(2, 4), sticky='we')

          'etype' の値として "from" が使われた場合は、 *note
          element_create(): 239. が現在の要素を複製します。 'args' は要
          素の複製元のテーマの名前と、オプションで複製する要素を含んでい
          る必要があります。複製元の要素が指定されていなかった場合、空要
          素が使用され、 'kw' は破棄されます。

          以下はプログラム例です:

               style = ttk.Style(root)
               style.element_create('plain.background', 'from', 'default')

          If "vsapi" is used as the value of 'etype', *note
          element_create(): 239. will create a new element in the
          current theme whose visual appearance is drawn using the
          Microsoft Visual Styles API which is responsible for the
          themed styles on Windows XP and Vista.  'args' is expected to
          contain the Visual Styles class and part as given in the
          Microsoft documentation followed by an optional sequence of
          tuples of ttk states and the corresponding Visual Styles API
          state value.  'kw' may have the following options:

          padding=padding

               Specify the element's interior padding.  'padding' is a
               list of up to four integers specifying the left, top,
               right and bottom padding quantities respectively.  If
               fewer than four elements are specified, bottom defaults
               to top, right defaults to left, and top defaults to left.
               In other words, a list of three numbers specify the left,
               vertical, and right padding; a list of two numbers
               specify the horizontal and the vertical padding; a single
               number specifies the same padding all the way around the
               widget.  This option may not be mixed with any other
               options.

          margins=padding

               Specifies the elements exterior padding.  'padding' is a
               list of up to four integers specifying the left, top,
               right and bottom padding quantities respectively.  This
               option may not be mixed with any other options.

          width=width

               Specifies the width for the element.  If this option is
               set then the Visual Styles API will not be queried for
               the recommended size or the part.  If this option is set
               then 'height' should also be set.  The 'width' and
               'height' options cannot be mixed with the 'padding' or
               'margins' options.

          height=height

               Specifies the height of the element.  See the comments
               for 'width'.

          以下はプログラム例です:

               style = ttk.Style(root)
               style.element_create('pin', 'vsapi', 'EXPLORERBAR', 3, [
                                    ('pressed', '!selected', 3),
                                    ('active', '!selected', 2),
                                    ('pressed', 'selected', 6),
                                    ('active', 'selected', 5),
                                    ('selected', 4),
                                    ('', 1)])
               style.layout('Explorer.Pin',
                            [('Explorer.Pin.pin', {'sticky': 'news'})])
               pin = ttk.Checkbutton(style='Explorer.Pin')
               pin.pack(expand=True, fill='both')

          バージョン 3.13 で変更: Added support of the "vsapi" element
          factory.

      -- メソッド: element_names ()

          現在のテーマに定義されている要素のリストを返します。

      -- メソッド: element_options (elementname)

          'elementname' のオプションのリストを返します。

      -- メソッド: theme_create (themename, parent=None, settings=None)

          新しいテーマを作成します。

          'themename' が既に存在していた場合はエラーになります。
          'parent' が指定されていた場合は、新しいテーマは親テーマからス
          タイルや要素やレイアウトを継承します。 'settings' が指定された
          場合は、 *note theme_settings(): 3dbc. で使われるのと同じ形式
          である必要があります。

      -- メソッド: theme_settings (themename, settings)

          一時的に現在のテーマを 'themename' に設定し、指定された
          'settings' を適用した後、元のテーマを復元します。

          'settings' のそれぞれのキーはスタイル名で値はさらに
          'configure', 'map', 'layout', 'element create' をキーとして持
          ち、その値はそれぞれ *note Style.configure(): 3db5, *note
          Style.map(): 1888, *note Style.layout(): 3db7, *note
          Style.element_create(): 239. メソッドで指定するのと同じ形式で
          ある必要があります。

          例として、コンボボックスの default テーマを少し変更してみまし
          ょう

               from tkinter import ttk
               import tkinter

               root = tkinter.Tk()

               style = ttk.Style()
               style.theme_settings("default", {
                  "TCombobox": {
                      "configure": {"padding": 5},
                      "map": {
                          "background": [("active", "green2"),
                                         ("!disabled", "green4")],
                          "fieldbackground": [("!disabled", "green3")],
                          "foreground": [("focus", "OliveDrab1"),
                                         ("!disabled", "OliveDrab2")]
                      }
                  }
               })

               combo = ttk.Combobox().pack()

               root.mainloop()

      -- メソッド: theme_names ()

          全ての既存のテーマのリストを返します。

      -- メソッド: theme_use (themename=None)

          'themename' が与えられなかった場合は、現在使用中のテーマ名を返
          します。そうでない場合は、現在のテーマを 'themename' に設定し
          、全てのウィジェットを再描画し、 <<ThemeChanged>> イベントを発
          生させます。

* Menu:

* レイアウト::

   ---------- Footnotes ----------

   (1) https://tktable.sourceforge.net/tile/tile-tcl2004.pdf


File: python.info,  Node: レイアウト,  Up: Ttk スタイル

5.25.8.40 レイアウト
....................

A layout can be just ‘None’, if it takes no options, or a dict of
options specifying how to arrange the element.  The layout mechanism
uses a simplified version of the pack geometry manager: given an initial
cavity, each element is allocated a parcel.

設定できるオプションとその値は次の通りです:

'side': whichside

     要素を空間のどちら側に配置するかを指定します; top, right, bottom,
     left のどれか 1 つです。省略された場合は、要素は空間全体を占めます
     。

'sticky': nswe

     配分された空間の内部に要素をどう配置するかを指定します。

'unit': 0 or 1

     1 に設定されると、 *note Widget.identify(): 3d63. などには要素とそ
     の子で単一の要素として扱われます。これは、グリップのついたスクロー
     ルバーサムのようなものに使われます。

'children': [sublayout... ]

     要素の内部に配置する要素のリストを指定します。リストのそれぞれの要
     素はタプル (もしくは他のシーケンス型) で、それの 1 番目の要素はレイ
     アウト名でそれ以降は *note Layout: 3db8. です。


File: python.info,  Node: IDLE<64>,  Prev: tkinter ttk --- Tk のテーマ付きウィジェット,  Up: Tk を用いたグラフィカルユーザーインターフェース

5.25.9 IDLE
-----------

'ソースコード:' Lib/idlelib/(1)

__________________________________________________________________

IDLE は Python の統合開発環境で、学習用環境です。

IDLE は次のような特徴があります:

   * クロスプラットホーム: Windows, Unix, macOS で動作します

   * コード入力、出力、エラーメッセージの色付け機能を持った Python shell
     (対話的インタプリタ) ウィンドウ

   * 多段 Undo、 Python 対応の色づけ、自動的な字下げ、呼び出し情報の表示
     、自動補完、他たくさんの機能をもつマルチウィンドウ・テキストエディ
     タ

   * 任意のウィンドウ内での検索、エディタウィンドウ内での置換、複数ファ
     イルを跨いだ検索 (grep)

   * 永続的なブレイクポイント、ステップ実行、グローバルとローカル名前空
     間の視覚化機能を持ったデバッガ

   * 設定、ブラウザ群、ほかダイアログ群

* Menu:

* メニュー::
* Editing and Navigation::
* Startup and Code Execution::
* Help and Preferences::
* idlelib::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/idlelib/


File: python.info,  Node: メニュー,  Next: Editing and Navigation,  Up: IDLE<64>

5.25.9.1 メニュー
.................

IDLE には2種類のメインウィンドウ、Shell ウィンドウと Editor ウィンドウが
あります。 Editor ウィンドウは同時に複数開けます。 Windows と Linux では
、それぞれ個別のトップメニューがあります。 後で解説するそれぞれのメニュ
ーは、ウィンドウがどちらのウィンドウタイプなのかを示しています。

ファイル内の編集 (Edit) => 検索 (Find) で使われるような出力ウィンドウ
(Output ウィンドウ) は editor ウィンドウのサブタイプで、 Editor ウィンド
ウと同じトップメニューを持ちますが、デフォルトタイトルとコンテキストメニ
ューが違います。

On macOS, there is one application menu.  It dynamically changes
according to the window currently selected.  It has an IDLE menu, and
some entries described below are moved around to conform to Apple
guidelines.

* Menu:

* File メニュー (Shell ウィンドウ、Editor ウィンドウ): File メニュー Shell ウィンドウ、Editor ウィンドウ.
* Edit メニュー (Shell ウィンドウ、Editor ウィンドウ): Edit メニュー Shell ウィンドウ、Editor ウィンドウ.
* Format メニュー (Shell ウィンドウ、Editor ウィンドウ): Format メニュー Shell ウィンドウ、Editor ウィンドウ.
* Run メニュー (Editor ウィンドウのみ): Run メニュー Editor ウィンドウのみ.
* Shell メニュー (Shell ウィンドウのみ): Shell メニュー Shell ウィンドウのみ.
* Debug メニュー (Shell ウィンドウのみ): Debug メニュー Shell ウィンドウのみ.
* Options メニュー (Shell ウィンドウ、Editor ウィンドウ): Options メニュー Shell ウィンドウ、Editor ウィンドウ.
* Window メニュー (Shell ウィンドウ、Editor ウィンドウ): Window メニュー Shell ウィンドウ、Editor ウィンドウ.
* Help メニュー (Shell ウィンドウ、Editor ウィンドウ): Help メニュー Shell ウィンドウ、Editor ウィンドウ.
* Context menus::


File: python.info,  Node: File メニュー Shell ウィンドウ、Editor ウィンドウ,  Next: Edit メニュー Shell ウィンドウ、Editor ウィンドウ,  Up: メニュー

5.25.9.2 File メニュー (Shell ウィンドウ、Editor ウィンドウ)
............................................................

New File [新規ファイル]

     新しいファイル編集ウィンドウを作成します。

Open... [開く...]

     Open ダイアログを使って既存のファイルをオープンします。

Open Module... [モジュールを開く...]

     既存のモジュールをオープンします (sys.path を検索します)。

Recent Files [最近使ったファイル]

     最近使ったファイルのリストを開きます。ファイルを一つクリックすると
     それを開きます。

Module Browser

     現在 Editor が開いているファイル内にあるクラス、関数、メソッドを木
     構造で可視化します。 Shell からの場合は、先にモジュール選択のダイア
     ログが開きます。

Path Browser [パスブラウザ]

     sys.path ディレクトリ、モジュール、クラスおよびメソッドを木構造で可
     視化します。

Save [保存]

     現在のウィンドウを対応するファイルがあればそこに保存します。開いて
     から、または最後に保存したのちに編集があった場合のウィンドウには、
     ウィンドウタイトルの前後に * が付けられます。対応するファイルがなけ
     れば代わりに Save As が実行されます。

Save As... [名前を付けて保存...]

     Save the current window with a Save As dialog.  The file saved
     becomes the new associated file for the window.  (If your file
     namager is set to hide extensions, the current extension will be
     omitted in the file name box.  If the new filename has no '.',
     '.py' and '.txt' will be added for Python and text files, except
     that on macOS Aqua,'.py' is added for all files.)

Save Copy As... [コピーとして保存...]

     Save the current window to different file without changing the
     associated file.  (See Save As note above about filename
     extensions.)

Print Window [ウィンドウを印刷]

     現在のウィンドウをデフォルトプリンタで印刷します。

Close Window

     Close the current window (if an unsaved editor, ask to save; if an
     unsaved Shell, ask to quit execution).  Calling ‘exit()’ or
     ‘close()’ in the Shell window also closes Shell.  If this is the
     only window, also exit IDLE.

Exit IDLE

     Close all windows and quit IDLE (ask to save unsaved edit windows).


File: python.info,  Node: Edit メニュー Shell ウィンドウ、Editor ウィンドウ,  Next: Format メニュー Shell ウィンドウ、Editor ウィンドウ,  Prev: File メニュー Shell ウィンドウ、Editor ウィンドウ,  Up: メニュー

5.25.9.3 Edit メニュー (Shell ウィンドウ、Editor ウィンドウ)
............................................................

Undo [元に戻す]

     現在のウィンドウに対する最後の変更を Undo (取り消し) します。最大で
     1000 個の変更が Undo できます。

Redo [やり直し]

     現在のウィンドウに対する最後にundoされた変更をRedo(再スタート)しま
     す。

Select All [全て選択]

     カレントウィンドウの内容全体を選択します。

Cut [切り取り]

     システムのクリップボードへ選択された部分をコピーします。それから選
     択された部分を削除します。

Copy [コピー]

     選択された部分をシステムのクリップボードへコピーします。

Paste [貼り付け]

     システムのクリップボードの内容をカレントウィンドウへ挿入します。

クリップボードの機能はコンテキストメニューからも使えます。

Find... [検索...]

     たくさんのオプションをもつ検索ダイアログボックスを開きます。

Find Again [再検索]

     直前の検索があれば、それを繰り返します。

Find Selection [現在の選択を検索]

     現在選択された文字列があれば、それを検索します。

Find in Files... [ファイルから検索...]

     ファイル検索ダイアログを開きます。結果を新しい出力ウィンドウに出力
     します。

Replace... [置換...]

     検索と置換ダイアログを開きます。

Go to Line [指定行へジャンプ]

     Move the cursor to the beginning of the line requested and make
     that line visible.  A request past the end of the file goes to the
     end.  Clear any selection and update the line and column status.

Show Completions [補完候補の一覧]

     既存の名前が選択できるスクロール可能なリストを開きます。 下の編集と
     ナビゲーションの節にある *note 補完: 3dc5. の項を参照してください。

Expand Word [語の展開]

     先頭だけタイプしたものを、同一ウィンドウ内の完全な語と合致するもの
     に展開します。異なる展開を得るためには繰り返します。

Show Call Tip

     関数の開き括弧の後ろで、関数パラメータについてのヒントを表示する小
     さなウィンドウを開きます。 下の編集とナビゲーションの節にある *note
     呼び出しヒント: 3dc6. の項を参照してください。

Show Surrounding Parens

     囲んでいる括弧をハイライトします。


File: python.info,  Node: Format メニュー Shell ウィンドウ、Editor ウィンドウ,  Next: Run メニュー Editor ウィンドウのみ,  Prev: Edit メニュー Shell ウィンドウ、Editor ウィンドウ,  Up: メニュー

5.25.9.4 Format メニュー (Shell ウィンドウ、Editor ウィンドウ)
..............................................................

Format Paragraph [パラグラフのフォーマット]

     コメント内、マルチライン文字列リテラル内、あるいは選択行の現在位置
     の (空行区切り) パラグラフの再整形。パラグラフ内の全ての行は N カラ
     ム (デフォルトは 72) 以内で再整形されます。

Indent Region [領域をインデント]

     選択された行を右へインデント幅分シフトします (デフォルトは空白 4 個
     )。

Dedent Region [領域をインデント解除]

     選択された行を左へインデント幅分シフトします (デフォルトは空白 4 個
     )。

Comment Out Region [領域をコメントアウト]

     選択された行の先頭に ## を挿入します。

Uncomment Region [領域のコメントを解除]

     選択された行から先頭の # あるいは ## を取り除きます。

Tabify Region [領域のタブ化]

     '先頭' の一続きの空白をタブに置き換えます (注意: Python コードのイ
     ンデントには 4 つの空白を使うことをお勧めします)。

Untabify Region [領域の非タブ化]

     'すべての' タブを適切な数の空白に置き換えます。

Toggle Tabs [タブの切り替え]

     字下げのために空白を使うかタブを使うかを切り替えるダイアログを開き
     ます。

New Indent Width [新しいインデント幅]

     インデント幅を変更するダイアログを開きます。Python コミュニティによ
     って受け容れられているデフォルトは空白 4 個です。

Strip Trailing Chitespace

     Remove trailing space and other whitespace characters after the
     last non-whitespace character of a line by applying str.rstrip to
     each line, including lines within multiline strings.  Except for
     Shell windows, remove extra newlines at the end of the file.


File: python.info,  Node: Run メニュー Editor ウィンドウのみ,  Next: Shell メニュー Shell ウィンドウのみ,  Prev: Format メニュー Shell ウィンドウ、Editor ウィンドウ,  Up: メニュー

5.25.9.5 Run メニュー (Editor ウィンドウのみ)
.............................................

Run Module [モジュールの実行]

     *note Check Module: 3dcb. を実行します。エラーがなければ Shell の環
     境をクリーンにして再スタートした上で、モジュールを実行します。出力
     は Shell ウィンドウに表示されます。‘print’ や ‘write’ しない限り、
     この出力はされません。モジュール実行が完了すると Shell はフォーカス
     された状態のままで、プロンプトを表示します。これにより対話的に実行
     結果を調べることができます。この機能は、コマンドラインからファイル
     を ‘python -i file’ で実行することに相当します。

Run... Customized

     Same as *note Run Module: 3dca, but run the module with customized
     settings.  'Command Line Arguments' extend *note sys.argv: 1236. as
     if passed on a command line.  The module can be run in the Shell
     without restarting.

Check Module [モジュールのチェック]

     Editor ウィンドウでいま開いているモジュールを構文チェックします。モ
     ジュールが未保存の場合、 Options -> Configure IDLE -> General の
     "Autosave Preferences" の設定にもとづき、確認を求められるか自動的に
     保存します。構文エラーが見つかると Editor ウィンドウでそのおよその
     位置に移動します。

Python Shell [Python シェル]

     Python Shell ウィンドウを開くか、起こします。


File: python.info,  Node: Shell メニュー Shell ウィンドウのみ,  Next: Debug メニュー Shell ウィンドウのみ,  Prev: Run メニュー Editor ウィンドウのみ,  Up: メニュー

5.25.9.6 Shell メニュー (Shell ウィンドウのみ)
..............................................

View Last Restart [最後のリスタートを表示する]

     最後に Shell のリスタートを行った場所まで Shell ウインドウをスクロ
     ールします。

Restart Shell [Shell のリスタート]

     Restart the shell to clean the environment and reset display and
     exception handling.

Previous History

     Cycle through earlier commands in history which match the current
     entry.

Next History

     Cycle through later commands in history which match the current
     entry.

Interrupt Execution [実行の中断]

     プログラムの実行を停止します。


File: python.info,  Node: Debug メニュー Shell ウィンドウのみ,  Next: Options メニュー Shell ウィンドウ、Editor ウィンドウ,  Prev: Shell メニュー Shell ウィンドウのみ,  Up: メニュー

5.25.9.7 Debug メニュー (Shell ウィンドウのみ)
..............................................

Go to File/Line [ファイル/行へ移動]

     カーソルのある現在行の上にファイル名と行番号が見つかれば、(開かれて
     いなければ) そのファイルを開いてその行に飛びます。例外のトレースバ
     ックが参照しているソース行を見るのにこれを使いましょう。そのような
     ファイル名・行番号表示をしている行を見つけるのには Find を使えます
     。この機能は Shell ウィンドウと Output ウィンドウのコンテキストメニ
     ューからも使えます。

Debugger [デバッガ] (トグル切り替え)

     アクティブにすると、Shell または Editor に入力したコードをデバッガ
     のもとで実行します。Editor ではコンテキストメニューからブレイクポイ
     ントをセット出来ます。この機能はまだ不完全で、少々実験的です。

Stack Viewer [スタックビューア]

     最後の例外のスタックトレースと locals 辞書、 globals 辞書をツリーウ
     ィジットで表示します。

Auto-open Stack Viewer [スタックビューアの自動オープン]

     未捕捉の例外時にスタックビューアを自動的に開くかどうかを切り替えま
     す。


File: python.info,  Node: Options メニュー Shell ウィンドウ、Editor ウィンドウ,  Next: Window メニュー Shell ウィンドウ、Editor ウィンドウ,  Prev: Debug メニュー Shell ウィンドウのみ,  Up: メニュー

5.25.9.8 Options メニュー (Shell ウィンドウ、Editor ウィンドウ)
...............................................................

Configure IDLE [IDLE の設定]

     Open a configuration dialog and change preferences for the
     following: fonts, indentation, keybindings, text color themes,
     startup windows and size, additional help sources, and extensions.
     On macOS, open the configuration dialog by selecting Preferences in
     the application menu.  For more details, see *note Setting
     preferences: 3dd1. under Help and preferences.

Most configuration options apply to all windows or all future windows.
The option items below only apply to the active window.

Show/Hide Code Context (Editor Window only)

     Editor ウィンドウの上部にペインが開き、そこにウィンドウの一番上のコ
     ードのブロックコンテキスト (訳注: コードが含まれているブロックのイ
     ンデント構造) が表示されます。 下の編集とナビゲーションの節にある
     *note コードコンテキスト: 3dd2. の項を参照してください。

Show/Hide Line Numbers (Editor Window only)

     Open a column to the left of the edit window which shows the number
     of each line of text.  The default is off, which may be changed in
     the preferences (see *note Setting preferences: 3dd1.).

Zoom/Restore Height

     Toggles the window between normal size and maximum height.  The
     initial size defaults to 40 lines by 80 chars unless changed on the
     General tab of the Configure IDLE dialog.  The maximum height for a
     screen is determined by momentarily maximizing a window the first
     time one is zoomed on the screen.  Changing screen settings may
     invalidate the saved height.  This toggle has no effect when a
     window is maximized.


File: python.info,  Node: Window メニュー Shell ウィンドウ、Editor ウィンドウ,  Next: Help メニュー Shell ウィンドウ、Editor ウィンドウ,  Prev: Options メニュー Shell ウィンドウ、Editor ウィンドウ,  Up: メニュー

5.25.9.9 Window メニュー (Shell ウィンドウ、Editor ウィンドウ)
..............................................................

Lists the names of all open windows; select one to bring it to the
foreground (deiconifying it if necessary).


File: python.info,  Node: Help メニュー Shell ウィンドウ、Editor ウィンドウ,  Next: Context menus,  Prev: Window メニュー Shell ウィンドウ、Editor ウィンドウ,  Up: メニュー

5.25.9.10 Help メニュー (Shell ウィンドウ、Editor ウィンドウ)
.............................................................

About IDLE [IDLE について]

     バージョン、コピーライト、ライセンス、クレジット、その他を表示しま
     す。

IDLE Help [IDLE ヘルプ]

     メニューオプション、基本的な編集やナビゲーションその他チップスを詳
     しく書いた IDLE のドキュメントを表示します。

Python Docs [Python ドキュメント]

     Python ドキュメントがローカルにインストールされていればそれを開きま
     す。もしくはウェブブラウザで最新の Python ドキュメント
     (‘https://docs.python.org’) を開きます。(訳注: いずれも何もしていな
     ければ英語。下記参照。)

Turtle Demo [Turtle デモ]

     Python コード例とタートルによる描画を使って turtledemo モジュールを
     実行します。

General タブの下の方にある Configure IDLE ダイアログで、追加のヘルプソー
スを Help メニューに加えられます。 下の編集とナビゲーションの節にある
*note ヘルプソース: 3dd5. の項を参照してください。


File: python.info,  Node: Context menus,  Prev: Help メニュー Shell ウィンドウ、Editor ウィンドウ,  Up: メニュー

5.25.9.11 Context menus
.......................

ウィンドウ内で右クリック (macOS では Control-クリック) でコンテキストメ
ニューが開きます。コンテキストメニューには Edit メニューにもある標準的な
クリップボード機能が含まれています。

Cut [切り取り]

     システムのクリップボードへ選択された部分をコピーします。それから選
     択された部分を削除します。

Copy [コピー]

     選択された部分をシステムのクリップボードへコピーします。

Paste [貼り付け]

     システムのクリップボードの内容をカレントウィンドウへ挿入します。

Editor ウィンドウではさらにブレイクポイント機能が使えます。ブレイクポイ
ントがセットされた行には、特別に印がつきます。ブレイクポイントはデバッガ
のもとでの実行にだけ影響します。ファイルに付けたブレイクポイントはユーザ
の ‘.idlerc’ ディレクトリに保存されます。

Set Breakpoint [ブレークポイントのセット]

     現在行にブレークポイントをセットします。

Clear Breakpoint [ブレークポイントのクリア]

     その行のブレークポイントをクリアします。

Shell ウィンドウや Output ウィンドウには次のメニューもあります。

Go to file/line [ファイル/行へ移動]

     Debug メニューと同じものです。

The Shell window also has an output squeezing facility explained in the
'Python Shell window' subsection below.

Squeeze

     If the cursor is over an output line, squeeze all the output
     between the code above and the prompt below down to a 'Squeezed
     text' label.


File: python.info,  Node: Editing and Navigation,  Next: Startup and Code Execution,  Prev: メニュー,  Up: IDLE<64>

5.25.9.12 Editing and Navigation
................................

* Menu:

* Editor windows::
* Key bindings::
* 自動的な字下げ::
* 検索と置換::
* 補完 (Completions): 補完 Completions.
* 呼び出しヒント (Calltips): 呼び出しヒント Calltips.
* Code Context::
* Shell window::
* テキストの色::


File: python.info,  Node: Editor windows,  Next: Key bindings,  Up: Editing and Navigation

5.25.9.13 Editor windows
........................

IDLE may open editor windows when it starts, depending on settings and
how you start IDLE. Thereafter, use the File menu.  There can be only
one open editor window for a given file.

The title bar contains the name of the file, the full path, and the
version of Python and IDLE running the window.  The status bar contains
the line number ('Ln') and column number ('Col').  Line numbers start
with 1; column numbers with 0.

IDLE assumes that files with a known .py* extension contain Python code
and that other files do not.  Run Python code with the Run menu.


File: python.info,  Node: Key bindings,  Next: 自動的な字下げ,  Prev: Editor windows,  Up: Editing and Navigation

5.25.9.14 Key bindings
......................

The IDLE insertion cursor is a thin vertical bar between character
positions.  When characters are entered, the insertion cursor and
everything to its right moves right one character and the new character
is entered in the new space.

Several non-character keys move the cursor and possibly delete
characters.  Deletion does not puts text on the clipboard, but IDLE has
an undo list.  Wherever this doc discusses keys, 'C' refers to the
‘Control’ key on Windows and Unix and the ‘Command’ key on macOS. (And
all such discussions assume that the keys have not been re-bound to
something else.)

   * Arrow keys move the cursor one character or line.

   * ‘C-LeftArrow’ and ‘C-RightArrow’ moves left or right one word.

   * ‘Home’ and ‘End’ go to the beginning or end of the line.

   * ‘Page Up’ and ‘Page Down’ go up or down one screen.

   * ‘C-Home’ and ‘C-End’ go to beginning or end of the file.

   * ‘Backspace’ and ‘Del’ (or ‘C-d’) delete the previous or next
     character.

   * ‘C-Backspace’ and ‘C-Del’ delete one word left or right.

   * ‘C-k’ deletes ('kills') everything to the right.

標準的なキーバインディング (‘C-c’ がコピーで ‘C-v’ がペースト、など) は
機能するかもしれません。キーバインディングは Configure IDLE ダイアログで
選択します。


File: python.info,  Node: 自動的な字下げ,  Next: 検索と置換,  Prev: Key bindings,  Up: Editing and Navigation

5.25.9.15 自動的な字下げ
........................

ブロックの始まりの文の後、次の行は 4 つの空白 (Python Shell ウィンドウで
は、一つのタブ) で字下げされます。あるキーワード (break、return など) の
後では、次の行は字下げが解除 (dedent) されます。先頭の字下げでは、
‘Backspace’ は 4 つの空白があれば削除します。 ‘Tab’ はインデント幅に対応
する数の空白 (Python Shell ウィンドウでは一つのタブ) を挿入します。現在
、タブは Tcl/Tk の制約のため 4 つの空白に固定されています。

*note Format メニュー: 3dc7. の indent/dedent region コマンドも参照して
ください。


File: python.info,  Node: 検索と置換,  Next: 補完 Completions,  Prev: 自動的な字下げ,  Up: Editing and Navigation

5.25.9.16 検索と置換
....................

Any selection becomes a search target.  However, only selections within
a line work because searches are only performed within lines with the
terminal newline removed.  If ‘[x] Regular expression’ is checked, the
target is interpreted according to the Python re module.


File: python.info,  Node: 補完 Completions,  Next: 呼び出しヒント Calltips,  Prev: 検索と置換,  Up: Editing and Navigation

5.25.9.17 補完 (Completions)
............................

Completions are supplied, when requested and available, for module
names, attributes of classes or functions, or filenames.  Each request
method displays a completion box with existing names.  (See tab
completions below for an exception.)  For any box, change the name being
completed and the item highlighted in the box by typing and deleting
characters; by hitting ‘Up’, ‘Down’, ‘PageUp’, ‘PageDown’, ‘Home’, and
‘End’ keys; and by a single click within the box.  Close the box with
‘Escape’, ‘Enter’, and double ‘Tab’ keys or clicks outside the box.  A
double click within the box selects and closes.

One way to open a box is to type a key character and wait for a
predefined interval.  This defaults to 2 seconds; customize it in the
settings dialog.  (To prevent auto popups, set the delay to a large
number of milliseconds, such as 100000000.)  For imported module names
or class or function attributes, type '.'.  For filenames in the root
directory, type *note os.sep: 636. or *note os.altsep: 637. immediately
after an opening quote.  (On Windows, one can specify a drive first.)
Move into subdirectories by typing a directory name and a separator.

Instead of waiting, or after a box is closed, open a completion box
immediately with Show Completions on the Edit menu.  The default hot key
is ‘C-space’.  If one types a prefix for the desired name before opening
the box, the first match or near miss is made visible.  The result is
the same as if one enters a prefix after the box is displayed.  Show
Completions after a quote completes filenames in the current directory
instead of a root directory.

Hitting ‘Tab’ after a prefix usually has the same effect as Show
Completions.  (With no prefix, it indents.)  However, if there is only
one match to the prefix, that match is immediately added to the editor
text without opening a box.

Invoking 'Show Completions', or hitting ‘Tab’ after a prefix, outside of
a string and without a preceding '.'  opens a box with keywords, builtin
names, and available module-level names.

When editing code in an editor (as oppose to Shell), increase the
available module-level names by running your code and not restarting the
Shell thereafter.  This is especially useful after adding imports at the
top of a file.  This also increases possible attribute completions.

Completion boxes initially exclude names beginning with '_' or, for
modules, not included in '__all__'.  The hidden names can be accessed by
typing '_' after '.', either before or after the box is opened.


File: python.info,  Node: 呼び出しヒント Calltips,  Next: Code Context,  Prev: 補完 Completions,  Up: Editing and Navigation

5.25.9.18 呼び出しヒント (Calltips)
...................................

A calltip is shown automatically when one types ‘(’ after the name of an
'accessible' function.  A function name expression may include dots and
subscripts.  A calltip remains until it is clicked, the cursor is moved
out of the argument area, or ‘)’ is typed.  Whenever the cursor is in
the argument part of a definition, select Edit and "Show Call Tip" on
the menu or enter its shortcut to display a calltip.

The calltip consists of the function's signature and docstring up to the
latter's first blank line or the fifth non-blank line.  (Some builtin
functions lack an accessible signature.)  A '/' or '*' in the signature
indicates that the preceding or following arguments are passed by
position or name (keyword) only.  Details are subject to change.

In Shell, the accessible functions depends on what modules have been
imported into the user process, including those imported by Idle itself,
and which definitions have been run, all since the last restart.

For example, restart the Shell and enter ‘itertools.count(’.  A calltip
appears because Idle imports itertools into the user process for its own
use.  (This could change.)  Enter ‘turtle.write(’ and nothing appears.
Idle does not itself import turtle.  The menu entry and shortcut also do
nothing.  Enter ‘import turtle’.  Thereafter, ‘turtle.write(’ will
display a calltip.

In an editor, import statements have no effect until one runs the file.
One might want to run a file after writing import statements, after
adding function definitions, or after opening an existing file.


File: python.info,  Node: Code Context,  Next: Shell window,  Prev: 呼び出しヒント Calltips,  Up: Editing and Navigation

5.25.9.19 Code Context
......................

Within an editor window containing Python code, code context can be
toggled in order to show or hide a pane at the top of the window.  When
shown, this pane freezes the opening lines for block code, such as those
beginning with ‘class’, ‘def’, or ‘if’ keywords, that would have
otherwise scrolled out of view.  The size of the pane will be expanded
and contracted as needed to show the all current levels of context, up
to the maximum number of lines defined in the Configure IDLE dialog
(which defaults to 15).  If there are no current context lines and the
feature is toggled on, a single blank line will display.  Clicking on a
line in the context pane will move that line to the top of the editor.

The text and background colors for the context pane can be configured
under the Highlights tab in the Configure IDLE dialog.


File: python.info,  Node: Shell window,  Next: テキストの色,  Prev: Code Context,  Up: Editing and Navigation

5.25.9.20 Shell window
......................

In IDLE's Shell, enter, edit, and recall complete statements.  (Most
consoles and terminals only work with a single physical line at a time).

Submit a single-line statement for execution by hitting ‘Return’ with
the cursor anywhere on the line.  If a line is extended with Backslash
(‘\’), the cursor must be on the last physical line.  Submit a
multi-line compound statement by entering a blank line after the
statement.

When one pastes code into Shell, it is not compiled and possibly
executed until one hits ‘Return’, as specified above.  One may edit
pasted code first.  If one pastes more than one statement into Shell,
the result will be a *note SyntaxError: 172. when multiple statements
are compiled as if they were one.

Lines containing ‘RESTART’ mean that the user execution process has been
re-started.  This occurs when the user execution process has crashed,
when one requests a restart on the Shell menu, or when one runs code in
an editor window.

The editing features described in previous subsections work when
entering code interactively.  IDLE's Shell window also responds to the
following:

   * ‘C-c’ attempts to interrupt statement execution (but may fail).

   * ‘C-d’ closes Shell if typed at a ‘>>>’ prompt.

   * ‘Alt-p’ and ‘Alt-n’ (‘C-p’ and ‘C-n’ on macOS) retrieve to the
     current prompt the previous or next previously entered statement
     that matches anything already typed.

   * ‘Return’ while the cursor is on any previous statement appends the
     latter to anything already typed at the prompt.


File: python.info,  Node: テキストの色,  Prev: Shell window,  Up: Editing and Navigation

5.25.9.21 テキストの色
......................

IDLE の表示はデフォルトで白背景に黒字ですが、以下のような特別な意味を持
ったテキストには色が付きす。Shell では shell 出力、 shell エラー、ユーザ
エラー。Python コードでは Shell プロンプト内や Editor でのキーワード、組
み込みクラスや組み込み関数の名前、 ‘class’ や ‘def’ に続く名前、文字列、
そしてコメント。どんなテキストウィンドウでも、カーソル (あれば)、検索で
合致したテキスト (あれば)、そして選択されているテキストには色が付きます
。

IDLE also highlights the *note soft keywords: 7d7. *note match: 7d8,
*note case: 7d8, and *note _: 7d9. in pattern-matching statements.
However, this highlighting is not perfect and will be incorrect in some
rare cases, including some ‘_’-s in ‘case’ patterns.

このテキストの色付けはバックグラウンドで行われるため、たまに色が付いてな
い状態が見えてしまいます。カラースキームは、 Configure IDLE [IDLE の設定
] ダイアログの Highlighting タブで変更できます。ただし、エディタ内のデバ
ッガブレークポイント行のマーキングと、ポップアップとダイアログないのテキ
ストの色は、ユーザーにより変更することはできません。


File: python.info,  Node: Startup and Code Execution,  Next: Help and Preferences,  Prev: Editing and Navigation,  Up: IDLE<64>

5.25.9.22 Startup and Code Execution
....................................

‘-s’ オプションとともに起動すると、IDLE は環境変数 ‘IDLESTARTUP’ か
*note PYTHONSTARTUP: f95. で参照されているファイルを実行します。 IDLE は
まず ‘IDLESTARTUP’ をチェックし、あれば参照しているファイルを実行します
。 ‘IDLESTARTUP’ が無ければ、IDLE は ‘PYTHONSTARTUP’ をチェックします。
これらの環境変数で参照されているファイルは、IDLE シェルでよく使う関数を
置いたり、一般的なモジュールの import 文を実行するのに便利です。

加えて、‘Tk’ もスタートアップファイルがあればそれをロードします。その Tk
のファイルは無条件にロードされることに注意してください。このファイルは
‘.Idle.py’ で、ユーザーのホームディレクトリから探されます。このファイル
の中の文は Tk の名前空間で実行されるので、IDLE の Python シェルで使う関
数を import するのには便利ではありません。

* Menu:

* コマンドラインの使い方::
* Startup failure::
* Running user code::
* User output in Shell::
* Developing tkinter applications::
* サブプロセスを起こさずに起動する::


File: python.info,  Node: コマンドラインの使い方,  Next: Startup failure,  Up: Startup and Code Execution

5.25.9.23 コマンドラインの使い方
................................

     idle.py [-c command] [-d] [-e] [-h] [-i] [-r file] [-s] [-t title] [-] [arg] ...

     -c command  run command in the shell window
     -d          enable debugger and open shell window
     -e          open editor window
     -h          print help message with legal combinations and exit
     -i          open shell window
     -r file     run file in shell window
     -s          run $IDLESTARTUP or $PYTHONSTARTUP first, in shell window
     -t title    set title of shell window
     -           run stdin in shell (- must be last option before args)

引数がある場合 (訳注: 以下の説明、たぶん実情に反してますが一応訳していま
す):

   * ‘-’, ‘-c’, ‘-r’ のどれかを使う場合、全ての引数は ‘sys.argv[1:...]’
     に入り、 ‘sys.argv[0]’ には ‘''’, ‘'-c'’, ‘'-r'’ の、与えたものが入
     ります。 Options ダイアログでデフォルトだったとしても Editor ウィン
     ドウが開くことはありません。

   * これ以外の場合は引数は編集対象のファイルとして開かれて、 ‘sys.argv’
     には IDLE そのものに渡された引数が反映されます。


File: python.info,  Node: Startup failure,  Next: Running user code,  Prev: コマンドラインの使い方,  Up: Startup and Code Execution

5.25.9.24 Startup failure
.........................

IDLE uses a socket to communicate between the IDLE GUI process and the
user code execution process.  A connection must be established whenever
the Shell starts or restarts.  (The latter is indicated by a divider
line that says 'RESTART'). If the user process fails to connect to the
GUI process, it usually displays a ‘Tk’ error box with a 'cannot
connect' message that directs the user here.  It then exits.

One specific connection failure on Unix systems results from
misconfigured masquerading rules somewhere in a system's network setup.
When IDLE is started from a terminal, one will see a message starting
with ‘** Invalid host:’.  The valid value is ‘127.0.0.1
(idlelib.rpc.LOCALHOST)’.  One can diagnose with ‘tcpconnect -irv
127.0.0.1 6543’ in one terminal window and ‘tcplisten <same args>’ in
another.

A common cause of failure is a user-written file with the same name as a
standard library module, such as 'random.py' and 'tkinter.py'.  When
such a file is located in the same directory as a file that is about to
be run, IDLE cannot import the stdlib file.  The current fix is to
rename the user file.

Though less common than in the past, an antivirus or firewall program
may stop the connection.  If the program cannot be taught to allow the
connection, then it must be turned off for IDLE to work.  It is safe to
allow this internal connection because no data is visible on external
ports.  A similar problem is a network mis-configuration that blocks
connections.

Python installation issues occasionally stop IDLE: multiple versions can
clash, or a single installation might need admin access.  If one undo
the clash, or cannot or does not want to run as admin, it might be
easiest to completely remove Python and start over.

A zombie pythonw.exe process could be a problem.  On Windows, use Task
Manager to check for one and stop it if there is.  Sometimes a restart
initiated by a program crash or Keyboard Interrupt (control-C) may fail
to connect.  Dismissing the error box or using Restart Shell on the
Shell menu may fix a temporary problem.

When IDLE first starts, it attempts to read user configuration files in
‘~/.idlerc/’ (~ is one's home directory).  If there is a problem, an
error message should be displayed.  Leaving aside random disk glitches,
this can be prevented by never editing the files by hand.  Instead, use
the configuration dialog, under Options.  Once there is an error in a
user configuration file, the best solution may be to delete it and start
over with the settings dialog.

If IDLE quits with no message, and it was not started from a console,
try starting it from a console or terminal (‘python -m idlelib’) and see
if this results in an error message.

On Unix-based systems with tcl/tk older than ‘8.6.11’ (see ‘About IDLE’)
certain characters of certain fonts can cause a tk failure with a
message to the terminal.  This can happen either if one starts IDLE to
edit a file with such a character or later when entering such a
character.  If one cannot upgrade tcl/tk, then re-configure IDLE to use
a font that works better.


File: python.info,  Node: Running user code,  Next: User output in Shell,  Prev: Startup failure,  Up: Startup and Code Execution

5.25.9.25 Running user code
...........................

With rare exceptions, the result of executing Python code with IDLE is
intended to be the same as executing the same code by the default
method, directly with Python in a text-mode system console or terminal
window.  However, the different interface and operation occasionally
affect visible results.  For instance, ‘sys.modules’ starts with more
entries, and ‘threading.active_count()’ returns 2 instead of 1.

By default, IDLE runs user code in a separate OS process rather than in
the user interface process that runs the shell and editor.  In the
execution process, it replaces ‘sys.stdin’, ‘sys.stdout’, and
‘sys.stderr’ with objects that get input from and send output to the
Shell window.  The original values stored in ‘sys.__stdin__’,
‘sys.__stdout__’, and ‘sys.__stderr__’ are not touched, but may be
‘None’.

Sending print output from one process to a text widget in another is
slower than printing to a system terminal in the same process.  This has
the most effect when printing multiple arguments, as the string for each
argument, each separator, the newline are sent separately.  For
development, this is usually not a problem, but if one wants to print
faster in IDLE, format and join together everything one wants displayed
together and then print a single string.  Both format strings and *note
str.join(): 2110. can help combine fields and lines.

IDLE's standard stream replacements are not inherited by subprocesses
created in the execution process, whether directly by user code or by
modules such as multiprocessing.  If such subprocess use ‘input’ from
sys.stdin or ‘print’ or ‘write’ to sys.stdout or sys.stderr, IDLE should
be started in a command line window.  (On Windows, use ‘python’ or ‘py’
rather than ‘pythonw’ or ‘pyw’.)  The secondary subprocess will then be
attached to that window for input and output.

If ‘sys’ is reset by user code, such as with ‘importlib.reload(sys)’,
IDLE's changes are lost and input from the keyboard and output to the
screen will not work correctly.

When Shell has the focus, it controls the keyboard and screen.  This is
normally transparent, but functions that directly access the keyboard
and screen will not work.  These include system-specific functions that
determine whether a key has been pressed and if so, which.

The IDLE code running in the execution process adds frames to the call
stack that would not be there otherwise.  IDLE wraps
‘sys.getrecursionlimit’ and ‘sys.setrecursionlimit’ to reduce the effect
of the additional stack frames.

When user code raises SystemExit either directly or by calling sys.exit,
IDLE returns to a Shell prompt instead of exiting.


File: python.info,  Node: User output in Shell,  Next: Developing tkinter applications,  Prev: Running user code,  Up: Startup and Code Execution

5.25.9.26 User output in Shell
..............................

When a program outputs text, the result is determined by the
corresponding output device.  When IDLE executes user code, ‘sys.stdout’
and ‘sys.stderr’ are connected to the display area of IDLE's Shell.
Some of its features are inherited from the underlying Tk Text widget.
Others are programmed additions.  Where it matters, Shell is designed
for development rather than production runs.

For instance, Shell never throws away output.  A program that sends
unlimited output to Shell will eventually fill memory, resulting in a
memory error.  In contrast, some system text windows only keep the last
n lines of output.  A Windows console, for instance, keeps a
user-settable 1 to 9999 lines, with 300 the default.

A Tk Text widget, and hence IDLE's Shell, displays characters
(codepoints) in the BMP (Basic Multilingual Plane) subset of Unicode.
Which characters are displayed with a proper glyph and which with a
replacement box depends on the operating system and installed fonts.
Tab characters cause the following text to begin after the next tab
stop.  (They occur every 8 'characters').  Newline characters cause
following text to appear on a new line.  Other control characters are
ignored or displayed as a space, box, or something else, depending on
the operating system and font.  (Moving the text cursor through such
output with arrow keys may exhibit some surprising spacing behavior.)

     >>> s = 'a\tb\a<\x02><\r>\bc\nd'  # Enter 22 chars.
     >>> len(s)
     14
     >>> s  # Display repr(s)
     'a\tb\x07<\x02><\r>\x08c\nd'
     >>> print(s, end='')  # Display s as is.
     # Result varies by OS and font.  Try it.

The ‘repr’ function is used for interactive echo of expression values.
It returns an altered version of the input string in which control
codes, some BMP codepoints, and all non-BMP codepoints are replaced with
escape codes.  As demonstrated above, it allows one to identify the
characters in a string, regardless of how they are displayed.

Normal and error output are generally kept separate (on separate lines)
from code input and each other.  They each get different highlight
colors.

For SyntaxError tracebacks, the normal '^' marking where the error was
detected is replaced by coloring the text with an error highlight.  When
code run from a file causes other exceptions, one may right click on a
traceback line to jump to the corresponding line in an IDLE editor.  The
file will be opened if necessary.

Shell has a special facility for squeezing output lines down to a
'Squeezed text' label.  This is done automatically for output over N
lines (N = 50 by default).  N can be changed in the PyShell section of
the General page of the Settings dialog.  Output with fewer lines can be
squeezed by right clicking on the output.  This can be useful lines long
enough to slow down scrolling.

Squeezed output is expanded in place by double-clicking the label.  It
can also be sent to the clipboard or a separate view window by
right-clicking the label.


File: python.info,  Node: Developing tkinter applications,  Next: サブプロセスを起こさずに起動する,  Prev: User output in Shell,  Up: Startup and Code Execution

5.25.9.27 Developing tkinter applications
.........................................

IDLE is intentionally different from standard Python in order to
facilitate development of tkinter programs.  Enter ‘import tkinter as
tk; root = tk.Tk()’ in standard Python and nothing appears.  Enter the
same in IDLE and a tk window appears.  In standard Python, one must also
enter ‘root.update()’ to see the window.  IDLE does the equivalent in
the background, about 20 times a second, which is about every 50
milliseconds.  Next enter ‘b = tk.Button(root, text='button');
b.pack()’.  Again, nothing visibly changes in standard Python until one
enters ‘root.update()’.

Most tkinter programs run ‘root.mainloop()’, which usually does not
return until the tk app is destroyed.  If the program is run with
‘python -i’ or from an IDLE editor, a ‘>>>’ shell prompt does not appear
until ‘mainloop()’ returns, at which time there is nothing left to
interact with.

When running a tkinter program from an IDLE editor, one can comment out
the mainloop call.  One then gets a shell prompt immediately and can
interact with the live application.  One just has to remember to
re-enable the mainloop call when running in standard Python.


File: python.info,  Node: サブプロセスを起こさずに起動する,  Prev: Developing tkinter applications,  Up: Startup and Code Execution

5.25.9.28 サブプロセスを起こさずに起動する
..........................................

デフォルトでは、IDLE でのユーザコードの実行は、内部的なループバックイン
ターフェイスを使用する、ソケット経由の分離されたサブプロセスで行われます
。この接続は外部からは見えませんし、インターネットとのデータの送受信は行
われません。ファイアウォールソフトウェアの警告が発生しても、無視して構い
ません。

ソケット接続の確立を試みて失敗した場合、IDLE によって通知されます。この
ような失敗は一過性の場合もありますが、永続的に失敗する場合は、ファイアウ
ォールが接続をブロックしているか、特定のシステムの設定が誤っていることが
原因かもしれません。問題が解決するまでは、 IDLE をコマンドラインオプショ
ン ‘-n’ で起動することもできます。

IDLE を ‘-n’ コマンドラインスイッチを使って開始した場合、IDLE は単一のプ
ロセス内で動作し、RPC Python 実行サーバを走らせるサブプロセスを作りませ
ん。これは、プラットフォーム上で Python がサブプロセスや RPC ソケットイ
ンターフェイスを作れない場合に有用かもしれません。ただし、このモードでは
ユーザコードが IDLE 自身から隔離されませんし、Run/Run Module (F5) 選択時
に環境が再起動されてまっさらな状態になることもありません。コードを変更し
た場合、影響するモジュールを reload() しないといけませんし、変更を反映す
るには、すべての特定の項目 (‘from foo import baz’ など) を再インポートし
ないといけません。これらの理由から、可能なら常にデフォルトのサブプロセス
を起こすモードで IDLE を起動するのが吉です。

バージョン 3.4 で非推奨.


File: python.info,  Node: Help and Preferences,  Next: idlelib,  Prev: Startup and Code Execution,  Up: IDLE<64>

5.25.9.29 Help and Preferences
..............................

* Menu:

* Help sources::
* Setting preferences [お好み設定]::
* IDLE on macOS::
* Extensions [拡張]::


File: python.info,  Node: Help sources,  Next: Setting preferences [お好み設定],  Up: Help and Preferences

5.25.9.30 Help sources
......................

Help menu entry "IDLE Help" displays a formatted html version of the
IDLE chapter of the Library Reference.  The result, in a read-only
tkinter text window, is close to what one sees in a web browser.
Navigate through the text with a mousewheel, the scrollbar, or up and
down arrow keys held down.  Or click the TOC (Table of Contents) button
and select a section header in the opened box.

Help menu entry "Python Docs" opens the extensive sources of help,
including tutorials, available at ‘docs.python.org/x.y’, where 'x.y' is
the currently running Python version.  If your system has an off-line
copy of the docs (this may be an installation option), that will be
opened instead.

Selected URLs can be added or removed from the help menu at any time
using the General tab of the Configure IDLE dialog.


File: python.info,  Node: Setting preferences [お好み設定],  Next: IDLE on macOS,  Prev: Help sources,  Up: Help and Preferences

5.25.9.31 Setting preferences [お好み設定]
..........................................

The font preferences, highlighting, keys, and general preferences can be
changed via Configure IDLE on the Option menu.  Non-default user
settings are saved in a ‘.idlerc’ directory in the user's home
directory.  Problems caused by bad user configuration files are solved
by editing or deleting one or more of the files in ‘.idlerc’.

On the Font tab, see the text sample for the effect of font face and
size on multiple characters in multiple languages.  Edit the sample to
add other characters of personal interest.  Use the sample to select
monospaced fonts.  If particular characters have problems in Shell or an
editor, add them to the top of the sample and try changing first size
and then font.

On the Highlights and Keys tab, select a built-in or custom color theme
and key set.  To use a newer built-in color theme or key set with older
IDLEs, save it as a new custom theme or key set and it well be
accessible to older IDLEs.


File: python.info,  Node: IDLE on macOS,  Next: Extensions [拡張],  Prev: Setting preferences [お好み設定],  Up: Help and Preferences

5.25.9.32 IDLE on macOS
.......................

Under System Preferences: Dock, one can set "Prefer tabs when opening
documents" to "Always".  This setting is not compatible with the
tk/tkinter GUI framework used by IDLE, and it breaks a few IDLE
features.


File: python.info,  Node: Extensions [拡張],  Prev: IDLE on macOS,  Up: Help and Preferences

5.25.9.33 Extensions [拡張]
...........................

IDLE contains an extension facility.  Preferences for extensions can be
changed with the Extensions tab of the preferences dialog.  See the
beginning of config-extensions.def in the idlelib directory for further
information.  The only current default extension is zzdummy, an example
also used for testing.


File: python.info,  Node: idlelib,  Prev: Help and Preferences,  Up: IDLE<64>

5.25.9.34 idlelib
.................

'Source code:' Lib/idlelib(1)

__________________________________________________________________

The Lib/idlelib package implements the IDLE application.  See the rest
of this page for how to use IDLE.

The files in idlelib are described in idlelib/README.txt.  Access it
either in idlelib or click Help => About IDLE on the IDLE menu.  This
file also maps IDLE menu items to the code that implements the item.
Except for files listed under 'Startup', the idlelib code is 'private'
in sense that feature changes can be backported (see PEP 434(2)).

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/idlelib

   (2) https://peps.python.org/pep-0434/


File: python.info,  Node: 開発ツール,  Next: デバッグとプロファイル,  Prev: Tk を用いたグラフィカルユーザーインターフェース,  Up: Python 標準ライブラリ

5.26 開発ツール
===============

この章で紹介されるモジュールはソフトウェアを書くことを支援します。たとえ
ば、 *note pydoc: a3. モジュールはモジュールの内容からドキュメントを生成
します。 *note doctest: 31. と *note unittest: ef. モジュールでは、自動
的に実行して予想通りの出力が生成されるか確認するユニットテストを書くこと
ができます。

この章で解説されるモジュールのリスト:

* Menu:

* typing: typing --- 型ヒントのサポート. 型ヒントのサポート
* pydoc: pydoc --- ドキュメント生成とオンラインヘルプシステム. ドキュメント生成とオンラインヘルプシステム
* Python 開発モード::
* doctest: doctest --- 対話型の Python の例をテストする. 対話型の Python の例をテストする
* unittest: unittest --- ユニットテストフレームワーク. ユニットテストフレームワーク
* unittest.mock: unittest mock --- モックオブジェクトライブラリ. モックオブジェクトライブラリ
* unittest.mock: unittest mock --- 入門. 入門
* test: test --- Regression tests package for Python. Regression tests package for Python
* test.support: test support --- テストのためのユーティリティ関数. テストのためのユーティリティ関数
* test.support.socket_helper: test support socket_helper --- Utilities for socket tests. Utilities for socket tests
* test.support.script_helper: test support script_helper --- Utilities for the Python execution tests. Utilities for the Python execution tests
* test.support.bytecode_helper: test support bytecode_helper --- Support tools for testing correct bytecode generation. Support tools for testing correct bytecode
                                generation
* test.support.threading_helper: test support threading_helper --- Utilities for threading tests. Utilities for threading tests
* test.support.os_helper: test support os_helper --- Utilities for os tests. Utilities for os tests
* test.support.import_helper: test support import_helper --- Utilities for import tests. Utilities for import tests
* test.support.warnings_helper: test support warnings_helper --- Utilities for warnings tests. Utilities for warnings tests


File: python.info,  Node: typing --- 型ヒントのサポート,  Next: pydoc --- ドキュメント生成とオンラインヘルプシステム,  Up: 開発ツール

5.26.1 ‘typing’ -- 型ヒントのサポート
-------------------------------------

Added in version 3.5.

'ソースコード:' Lib/typing.py(1)

     注釈: The Python runtime does not enforce function and variable
     type annotations.  They can be used by third party tools such as
     *note type checkers: 24e, IDEs, linters, etc.

__________________________________________________________________

This module provides runtime support for type hints.

Consider the function below:

     def surface_area_of_cube(edge_length: float) -> str:
         return f"The surface area of the cube is {6 * edge_length ** 2}."

‘surface_area_of_cube’ 関数は、‘edge_length: float’ という *note type
hint: 1ee2. で示されているように、引数が *note float: 2ce. のインスタン
スであるという前提です。 そして、‘-> str’ というヒントにある通り、この関
数は *note str: 418. のインスタンスを返すことになっています。

型ヒントは *note float: 2ce. や *note str: 418. のような単純な型を指定す
ることもできますし、もっと複雑な型も指定できます。 *note typing: ed. モ
ジュールには、より高度な型ヒントを表現するためのいろいろな型が含まれてい
ます。

‘typing’ モジュールには新しい機能が頻繁に追加されます。
typing_extensions(2) パッケージを使うことで、古い Python バージョンから
もその新機能を使うことができます。

参考
....

"Typing cheat sheet"(3)

     型ヒントの簡単な概要 (mypy ドキュメンテーション)

mypy ドキュメンテーション(4) の "Type System Reference" セクション

     Python の型システムの規格は PEP によって定められているので、このレ
     ファレンスはほとんどの Python 型チェッカーに適用できるはずです。
     (mypy のみに適用される部分もあるかもしれません。)

"Static Typing with Python"(5)

     コミュニティーによって書かれた、型システムの機能や便利な型関連のツ
     ール、型に関するベストプラクティスを詳しく説明している、特定の型チ
     ェッカーに依らないドキュメンテーション。

* Menu:

* Python 型システムの仕様::
* 型エイリアス::
* NewType::
* 呼び出し可能オブジェクトのアノテーション::
* ジェネリクス::
* タプルのアノテーション::
* クラスオブジェクトの型::
* Annotating generators and coroutines::
* ユーザー定義のジェネリック型::
* Any 型::
* 名前的部分型 vs 構造的部分型::
* モジュールの内容: モジュールの内容<3>.
* メジャーな機能の非推奨時系列::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/typing.py

   (2) https://pypi.org/project/typing_extensions/

   (3) https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html

   (4) https://mypy.readthedocs.io/en/stable/index.html

   (5) https://typing.readthedocs.io/en/latest/


File: python.info,  Node: Python 型システムの仕様,  Next: 型エイリアス,  Up: typing --- 型ヒントのサポート

5.26.1.1 Python 型システムの仕様
................................

The canonical, up-to-date specification of the Python type system can be
found at "Specification for the Python type system"(1).

   ---------- Footnotes ----------

   (1) https://typing.readthedocs.io/en/latest/spec/index.html


File: python.info,  Node: 型エイリアス,  Next: NewType,  Prev: Python 型システムの仕様,  Up: typing --- 型ヒントのサポート

5.26.1.2 型エイリアス
.....................

型エイリアスは *note type: 404. 文を用いて定義され、 *note
TypeAliasType: 421. インスタンスが生成されます。 この例では、静的型検査
器は ‘Vector’ と ‘list[float]’ を等しいものとして扱います

     type Vector = list[float]

     def scale(scalar: float, vector: Vector) -> Vector:
         return [scalar * num for num in vector]

     # passes type checking; a list of floats qualifies as a Vector.
     new_vector = scale(2.0, [1.0, -4.2, 5.4])

型エイリアスは複雑な型シグネチャを単純化するのに有用です。例えば:

     from collections.abc import Sequence

     type ConnectionOptions = dict[str, str]
     type Address = tuple[str, int]
     type Server = tuple[Address, ConnectionOptions]

     def broadcast_message(message: str, servers: Sequence[Server]) -> None:
         ...

     # The static type checker will treat the previous type signature as
     # being exactly equivalent to this one.
     def broadcast_message(
         message: str,
         servers: Sequence[tuple[tuple[str, int], dict[str, str]]]
     ) -> None:
         ...

*note type: 404. 文はPython3.12で新しく導入されました。後方互換性のため
に、単に代入によって型エイリアスを作成することもできます：

     Vector = list[float]

あるいは、 *note TypeAlias: 794. でマークすることで、これが通常の変数代
入ではなく、型エイリアスであることを明示できます

     from typing import TypeAlias

     Vector: TypeAlias = list[float]


File: python.info,  Node: NewType,  Next: 呼び出し可能オブジェクトのアノテーション,  Prev: 型エイリアス,  Up: typing --- 型ヒントのサポート

5.26.1.3 NewType
................

異なる型を作るためには *note NewType: cc3. ヘルパークラスを使います:

     from typing import NewType

     UserId = NewType('UserId', int)
     some_id = UserId(524313)

静的型検査器は新しい型を元々の型のサブクラスのように扱います。この振る舞
いは論理的な誤りを見つける手助けとして役に立ちます。

     def get_user_name(user_id: UserId) -> str:
         ...

     # passes type checking
     user_a = get_user_name(UserId(42351))

     # fails type checking; an int is not a UserId
     user_b = get_user_name(-1)

‘UserId’ 型の変数も ‘int’ の全ての演算が行えますが、その結果は常に ‘int’
型になります。 この振る舞いにより、 ‘int’ が期待されるところに ‘UserId’
を渡せますが、不正な方法で ‘UserId’ を作ってしまうことを防ぎます。

     # 'output' is of type 'int', not 'UserId'
     output = UserId(23413) + UserId(54341)

これらのチェックは静的型検査器のみによって強制されるということに注意して
ください。 実行時に ‘Derived = NewType('Derived', Base)’ という文は渡さ
れた仮引数をただちに返す ‘Derived’ callable を作ります。 つまり
‘Derived(some_value)’ という式は新しいクラスを作ることはなく、通常の関数
呼び出しより多くのオーバーヘッドがないということを意味します。

より正確に言うと、式 ‘some_value is Derived(some_value)’ は実行時に常に
真を返します。

‘Derived’ のサブタイプを作成することはできません

     from typing import NewType

     UserId = NewType('UserId', int)

     # Fails at runtime and does not pass type checking
     class AdminUserId(UserId): pass

しかし、 'derived' である ‘NewType’ をもとにした *note NewType: cc3. は
作ることが出来ます:

     from typing import NewType

     UserId = NewType('UserId', int)

     ProUserId = NewType('ProUserId', UserId)

そして ‘ProUserId’ に対する型検査は期待通りに動作します。

より詳しくは PEP 484(1) を参照してください。

     注釈: 型エイリアスの使用は、2つの型が互いに等価であることを宣言する
     ことを思い出してください。 ‘type Alias = Original’ とすると、静的型
     チェッカーは ‘Alias’ を ‘Original’ と"正確に等価な"ものとして扱いま
     す。これは、複雑な型シグネチャを単純化したい場合に便利です。

     これに対し、 ‘NewType’ はある型をもう一方の型の 'サブタイプ' として
     宣言します。 ‘Derived = NewType('Derived', Original)’ とすると静的
     型検査器は ‘Derived’ を ‘Original’ の 'サブクラス' として扱います。
     つまり ‘Original’ 型の値は ‘Derived’ 型の値が期待される場所で使うこ
     とが出来ないということです。これは論理的な誤りを最小の実行時のコス
     トで防ぎたい時に有用です。

Added in version 3.5.2.

バージョン 3.10 で変更: ‘NewType’ は関数ではなくクラスになりました。その
結果、通常の関数よりも ‘NewType’ を呼び出す際に多少の実行時コストが追加
されます。

バージョン 3.11 で変更: ‘NewType’ 呼び出し時のパフォーマンスが Python
3.9 のレベルに戻りました

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/


File: python.info,  Node: 呼び出し可能オブジェクトのアノテーション,  Next: ジェネリクス,  Prev: NewType,  Up: typing --- 型ヒントのサポート

5.26.1.4 呼び出し可能オブジェクトのアノテーション
.................................................

Functions - or other *note callable: 2847. objects - can be annotated
using *note collections.abc.Callable: 7b5. or deprecated *note
typing.Callable: 790.  ‘Callable[[int], str]’ signifies a function that
takes a single parameter of type *note int: 238. and returns a *note
str: 418.

例えば:

     from collections.abc import Callable, Awaitable

     def feeder(get_next_item: Callable[[], str]) -> None:
         ...  # Body

     def async_query(on_success: Callable[[int], None],
                     on_error: Callable[[int, Exception], None]) -> None:
         ...  # Body

     async def on_update(value: str) -> None:
         ...  # Body

     callback: Callable[[str], Awaitable[None]] = on_update

添字表記は常に2つの値とともに使われなければなりません。実引数のリストと
返り値の型です。 実引数のリストは型のリスト、*note ParamSpec: 144.、
*note Concatenate: 78f.、ellipsis のいずれかでなければなりません。返り値
の型は単一の型でなければなりません。

もしellipsisリテラル ‘...’ が引数リストとして与えられた場合、それは任意
のパラメータリストを持つ呼び出し可能オブジェクトを受け入れることを示しま
す。

     def concat(x: str, y: str) -> str:
         return x + y

     x: Callable[..., str]
     x = str     # OK
     x = concat  # Also OK

‘Callable’ は可変引数、*note オーバーロード関数: 3dfa.、キーワード専用引
数などを含む複雑な型シグネチャを表現することはできません。 しかし、*note
Protocol: 245. クラスとその *note __call__(): 523. メソッドを定義すれば
表現することができます:

     from collections.abc import Iterable
     from typing import Protocol

     class Combiner(Protocol):
         def __call__(self, *vals: bytes, maxlen: int | None = None) -> list[bytes]: ...

     def batch_proc(data: Iterable[bytes], cb_results: Combiner) -> bytes:
         for item in data:
             ...

     def good_cb(*vals: bytes, maxlen: int | None = None) -> list[bytes]:
         ...
     def bad_cb(*vals: bytes, maxitems: int | None) -> list[bytes]:
         ...

     batch_proc([], good_cb)  # OK
     batch_proc([], bad_cb)   # Error! Argument 2 has incompatible type because of
                              # different name and kind in the callback

callable が別の callable を引数に取る場合は、*note ParamSpec: 144. を使
えば両者のパラメータ引数の依存関係を表現することができます。 さらに、あ
る callable が別の callable から引数を追加したり削除したりする場合は、
*note Concatenate: 78f. 演算子を使うことで表現できます。 その場合、
callable の型は ‘Callable[ParamSpecVariable, ReturnType]’ と
‘Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable],
ReturnType]’ という形になります。

バージョン 3.10 で変更: ‘Callable’ は *note ParamSpec: 144. と *note
Concatenate: 78f. をサポートしました。詳細は PEP 612(1) を参照してくださ
い。

参考
....

*note ParamSpec: 144. と *note Concatenate: 78f. のドキュメントに、
‘Callable’ での使用例が記載されています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0612/


File: python.info,  Node: ジェネリクス,  Next: タプルのアノテーション,  Prev: 呼び出し可能オブジェクトのアノテーション,  Up: typing --- 型ヒントのサポート

5.26.1.5 ジェネリクス
.....................

コンテナに含まれるオブジェクトに関する型情報は、一般的な方法で静的に推論
することができないため、標準ライブラリの多くのコンテナクラスは、要素に期
待する型を示す添字表記をサポートしています

     from collections.abc import Mapping, Sequence

     class Employee: ...

     # Sequence[Employee] indicates that all elements in the sequence
     # must be instances of "Employee".
     # Mapping[str, str] indicates that all keys and all values in the mapping
     # must be strings.
     def notify_by_email(employees: Sequence[Employee],
                         overrides: Mapping[str, str]) -> None: ...

Generic functions and classes can be parameterized by using *note type
parameter syntax: 293.:

     from collections.abc import Sequence

     def first[T](l: Sequence[T]) -> T:  # Function is generic over the TypeVar "T"
         return l[0]

Or by using the *note TypeVar: 143. factory directly:

     from collections.abc import Sequence
     from typing import TypeVar

     U = TypeVar('U')                  # Declare type variable "U"

     def second(l: Sequence[U]) -> U:  # Function is generic over the TypeVar "U"
         return l[1]

バージョン 3.12 で変更: Syntactic support for generics is new in Python
3.12.


File: python.info,  Node: タプルのアノテーション,  Next: クラスオブジェクトの型,  Prev: ジェネリクス,  Up: typing --- 型ヒントのサポート

5.26.1.6 タプルのアノテーション
...............................

For most containers in Python, the typing system assumes that all
elements in the container will be of the same type.  For example:

     from collections.abc import Mapping

     # Type checker will infer that all elements in ``x`` are meant to be ints
     x: list[int] = []

     # Type checker error: ``list`` only accepts a single type argument:
     y: list[int, str] = [1, 'foo']

     # Type checker will infer that all keys in ``z`` are meant to be strings,
     # and that all values in ``z`` are meant to be either strings or ints
     z: Mapping[str, str | int] = {}

*note list: 5dc. は引数に1つの型のみ受け入れるので、型チェッカーは上記の
‘y’ への代入でエラーを出力します。同様に、*note Mapping: 898. は引数に
2つの型のみ受け入れます。1つ目はキーの型を示し、2つ目は値の型を示します
。

しかし、他の多くのPythonのコンテナとは異なり、タプルがすべて同じ型ではな
い要素を持つことは、慣用的なPythonコードでは一般的です。このため、タプル
はPythonの型システムの中でも特殊です。*note tuple: 349. は任意の数の引数
を受け入れます

     # OK: ``x`` is assigned to a tuple of length 1 where the sole element is an int
     x: tuple[int] = (5,)

     # OK: ``y`` is assigned to a tuple of length 2;
     # element 1 is an int, element 2 is a str
     y: tuple[int, str] = (5, "foo")

     # Error: the type annotation indicates a tuple of length 1,
     # but ``z`` has been assigned to a tuple of length 3
     z: tuple[int] = (1, 2, 3)

'任意の' 長さで、全ての要素が同じ型 ‘T’ であるタプルを示すには ‘tuple[T,
...]’ を使います。空のタプルを示すには ‘tuple[()]’ を使います。単に
‘tuple’ とアノテーションすることは、‘tuple[Any, ...]’ と等価です。

     x: tuple[int, ...] = (1, 2)
     # These reassignments are OK: ``tuple[int, ...]`` indicates x can be of any length
     x = (1, 2, 3)
     x = ()
     # This reassignment is an error: all elements in ``x`` must be ints
     x = ("foo", "bar")

     # ``y`` can only ever be assigned to an empty tuple
     y: tuple[()] = ()

     z: tuple = ("foo", "bar")
     # These reassignments are OK: plain ``tuple`` is equivalent to ``tuple[Any, ...]``
     z = (1, 2, 3)
     z = ()


File: python.info,  Node: クラスオブジェクトの型,  Next: Annotating generators and coroutines,  Prev: タプルのアノテーション,  Up: typing --- 型ヒントのサポート

5.26.1.7 クラスオブジェクトの型
...............................

A variable annotated with ‘C’ may accept a value of type ‘C’.  In
contrast, a variable annotated with ‘type[C]’ (or deprecated *note
typing.Type[C]: 3e00.) may accept values that are classes themselves -
specifically, it will accept the 'class object' of ‘C’.  For example:

     a = 3         # Has type ``int``
     b = int       # Has type ``type[int]``
     c = type(a)   # Also has type ``type[int]``

Note that ‘type[C]’ is covariant:

     class User: ...
     class ProUser(User): ...
     class TeamUser(User): ...

     def make_new_user(user_class: type[User]) -> User:
         # ...
         return user_class()

     make_new_user(User)      # OK
     make_new_user(ProUser)   # Also OK: ``type[ProUser]`` is a subtype of ``type[User]``
     make_new_user(TeamUser)  # Still fine
     make_new_user(User())    # Error: expected ``type[User]`` but got ``User``
     make_new_user(int)       # Error: ``type[int]`` is not a subtype of ``type[User]``

The only legal parameters for *note type: d16. are classes, *note Any:
678, *note type variables: 1ee0, and unions of any of these types.  For
example:

     def new_non_team_user(user_class: type[BasicUser | ProUser]): ...

     new_non_team_user(BasicUser)  # OK
     new_non_team_user(ProUser)    # OK
     new_non_team_user(TeamUser)   # Error: ``type[TeamUser]`` is not a subtype
                                   # of ``type[BasicUser | ProUser]``
     new_non_team_user(User)       # Also an error

‘type[Any]’ is equivalent to *note type: d16, which is the root of
Python's *note metaclass hierarchy: 1ed4.


File: python.info,  Node: Annotating generators and coroutines,  Next: ユーザー定義のジェネリック型,  Prev: クラスオブジェクトの型,  Up: typing --- 型ヒントのサポート

5.26.1.8 Annotating generators and coroutines
.............................................

A generator can be annotated using the generic type *note
Generator[YieldType, SendType, ReturnType]: da8.  For example:

     def echo_round() -> Generator[int, float, str]:
         sent = yield 0
         while sent >= 0:
             sent = yield round(sent)
         return 'Done'

Note that unlike many other generic classes in the standard library, the
‘SendType’ of *note Generator: da8. behaves contravariantly, not
covariantly or invariantly.

The ‘SendType’ and ‘ReturnType’ parameters default to ‘None’:

     def infinite_stream(start: int) -> Generator[int]:
         while True:
             yield start
             start += 1

It is also possible to set these types explicitly:

     def infinite_stream(start: int) -> Generator[int, None, None]:
         while True:
             yield start
             start += 1

Simple generators that only ever yield values can also be annotated as
having a return type of either *note Iterable[YieldType]: 21ab. or *note
Iterator[YieldType]: 21ac.:

     def infinite_stream(start: int) -> Iterator[int]:
         while True:
             yield start
             start += 1

Async generators are handled in a similar fashion, but don't expect a
‘ReturnType’ type argument (*note AsyncGenerator[YieldType, SendType]:
c58.).  The ‘SendType’ argument defaults to ‘None’, so the following
definitions are equivalent:

     async def infinite_stream(start: int) -> AsyncGenerator[int]:
         while True:
             yield start
             start = await increment(start)

     async def infinite_stream(start: int) -> AsyncGenerator[int, None]:
         while True:
             yield start
             start = await increment(start)

As in the synchronous case, *note AsyncIterable[YieldType]: dac. and
*note AsyncIterator[YieldType]: dab. are available as well:

     async def infinite_stream(start: int) -> AsyncIterator[int]:
         while True:
             yield start
             start = await increment(start)

Coroutines can be annotated using *note Coroutine[YieldType, SendType,
ReturnType]: daa.  Generic arguments correspond to those of *note
Generator: da8, for example:

     from collections.abc import Coroutine
     c: Coroutine[list[str], str, int]  # Some coroutine defined elsewhere
     x = c.send('hi')                   # Inferred type of 'x' is list[str]
     async def bar() -> None:
         y = await c                    # Inferred type of 'y' is int


File: python.info,  Node: ユーザー定義のジェネリック型,  Next: Any 型,  Prev: Annotating generators and coroutines,  Up: typing --- 型ヒントのサポート

5.26.1.9 ユーザー定義のジェネリック型
.....................................

ユーザー定義のクラスを、ジェネリッククラスとして定義できます。

     from logging import Logger

     class LoggedVar[T]:
         def __init__(self, value: T, name: str, logger: Logger) -> None:
             self.name = name
             self.logger = logger
             self.value = value

         def set(self, new: T) -> None:
             self.log('Set ' + repr(self.value))
             self.value = new

         def get(self) -> T:
             self.log('Get ' + repr(self.value))
             return self.value

         def log(self, message: str) -> None:
             self.logger.info('%s: %s', self.name, message)

This syntax indicates that the class ‘LoggedVar’ is parameterised around
a single *note type variable: 3e03. ‘T’ .  This also makes ‘T’ valid as
a type within the class body.

Generic classes implicitly inherit from *note Generic: 157c.  For
compatibility with Python 3.11 and lower, it is also possible to inherit
explicitly from *note Generic: 157c. to indicate a generic class:

     from typing import TypeVar, Generic

     T = TypeVar('T')

     class LoggedVar(Generic[T]):
         ...

Generic classes have *note __class_getitem__(): 706. methods, meaning
they can be parameterised at runtime (e.g.  ‘LoggedVar[int]’ below):

     from collections.abc import Iterable

     def zero_all_vars(vars: Iterable[LoggedVar[int]]) -> None:
         for var in vars:
             var.set(0)

A generic type can have any number of type variables.  All varieties of
*note TypeVar: 143. are permissible as parameters for a generic type:

     from typing import TypeVar, Generic, Sequence

     class WeirdTrio[T, B: Sequence[bytes], S: (int, str)]:
         ...

     OldT = TypeVar('OldT', contravariant=True)
     OldB = TypeVar('OldB', bound=Sequence[bytes], covariant=True)
     OldS = TypeVar('OldS', int, str)

     class OldWeirdTrio(Generic[OldT, OldB, OldS]):
         ...

*note Generic: 157c. の引数のそれぞれの型変数は別のものでなければなりま
せん。このため次のクラス定義は無効です:

     from typing import TypeVar, Generic
     ...

     class Pair[M, M]:  # SyntaxError
         ...

     T = TypeVar('T')

     class Pair(Generic[T, T]):   # INVALID
         ...

Generic classes can also inherit from other classes:

     from collections.abc import Sized

     class LinkedList[T](Sized):
         ...

When inheriting from generic classes, some type parameters could be
fixed:

     from collections.abc import Mapping

     class MyDict[T](Mapping[str, T]):
         ...

この場合では ‘MyDict’ は仮引数 ‘T’ を 1 つとります。

Using a generic class without specifying type parameters assumes *note
Any: 678. for each position.  In the following example, ‘MyIterable’ is
not generic but implicitly inherits from ‘Iterable[Any]’:

     from collections.abc import Iterable

     class MyIterable(Iterable): # Same as Iterable[Any]
         ...

User-defined generic type aliases are also supported.  Examples:

     from collections.abc import Iterable

     type Response[S] = Iterable[S] | int

     # Return type here is same as Iterable[str] | int
     def response(query: str) -> Response[str]:
         ...

     type Vec[T] = Iterable[tuple[T, T]]

     def inproduct[T: (int, float, complex)](v: Vec[T]) -> T: # Same as Iterable[tuple[T, T]]
         return sum(x*y for x, y in v)

For backward compatibility, generic type aliases can also be created
through a simple assignment:

     from collections.abc import Iterable
     from typing import TypeVar

     S = TypeVar("S")
     Response = Iterable[S] | int

バージョン 3.7 で変更: *note Generic: 157c. にあった独自のメタクラスは無
くなりました。

バージョン 3.12 で変更: Syntactic support for generics and type aliases
is new in version 3.12.  Previously, generic classes had to explicitly
inherit from *note Generic: 157c. or contain a type variable in one of
their bases.

User-defined generics for parameter expressions are also supported via
parameter specification variables in the form ‘[**P]’.  The behavior is
consistent with type variables' described above as parameter
specification variables are treated by the typing module as a
specialized type variable.  The one exception to this is that a list of
types can be used to substitute a *note ParamSpec: 144.:

     >>> class Z[T, **P]: ...  # T is a TypeVar; P is a ParamSpec
     ...
     >>> Z[int, [dict, float]]
     __main__.Z[int, [dict, float]]

Classes generic over a *note ParamSpec: 144. can also be created using
explicit inheritance from *note Generic: 157c.  In this case, ‘**’ is
not used:

     from typing import ParamSpec, Generic

     P = ParamSpec('P')

     class Z(Generic[P]):
         ...

Another difference between *note TypeVar: 143. and *note ParamSpec: 144.
is that a generic with only one parameter specification variable will
accept parameter lists in the forms ‘X[[Type1, Type2, ...]]’ and also
‘X[Type1, Type2, ...]’ for aesthetic reasons.  Internally, the latter is
converted to the former, so the following are equivalent:

     >>> class X[**P]: ...
     ...
     >>> X[int, str]
     __main__.X[[int, str]]
     >>> X[[int, str]]
     __main__.X[[int, str]]

Note that generics with *note ParamSpec: 144. may not have correct
‘__parameters__’ after substitution in some cases because they are
intended primarily for static type checking.

バージョン 3.10 で変更: *note Generic: 157c. can now be parameterized
over parameter expressions.  See *note ParamSpec: 144. and PEP 612(1)
for more details.

ユーザーが定義したジェネリッククラスはメタクラスの衝突を起こすことなく基
底クラスに抽象基底クラスをとれます。 ジェネリックメタクラスはサポートさ
れません。 パラメータ化を行うジェネリクスの結果はキャッシュされていて、
typing モジュールのほとんどの型は *note ハッシュ可能: 5db. で等価比較で
きます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0612/


File: python.info,  Node: Any 型,  Next: 名前的部分型 vs 構造的部分型,  Prev: ユーザー定義のジェネリック型,  Up: typing --- 型ヒントのサポート

5.26.1.10 ‘Any’ 型
..................

*note Any: 678. は特別な種類の型です。静的型検査器はすべての型を *note
Any: 678. と互換として扱い、 *note Any: 678. をすべての型と互換として扱
います。

これは、 *note Any: 678. 型の値では、任意の演算やメソッドの呼び出しが行
えることを意味します:

     from typing import Any

     a: Any = None
     a = []          # OK
     a = 2           # OK

     s: str = ''
     s = a           # OK

     def foo(item: Any) -> int:
         # Passes type checking; 'item' could be any type,
         # and that type might have a 'bar' method
         item.bar()
         ...

*note Any: 678. 型の値をより詳細な型に代入する時に型検査が行われないこと
に注意してください。例えば、静的型検査器は ‘a’ を ‘s’ に代入する時、‘s’
が *note str: 418. 型として宣言されていて実行時に *note int: 238. の値を
受け取るとしても、エラーを報告しません。

さらに、返り値や引数の型のないすべての関数は暗黙的に *note Any: 678. を
使用します。

     def legacy_parser(text):
         ...
         return data

     # A static type checker will treat the above
     # as having the same signature as:
     def legacy_parser(text: Any) -> Any:
         ...
         return data

この挙動により、動的型付けと静的型付けが混在したコードを書かなければなら
ない時に *note Any: 678. を '非常口' として使用することができます。

*note Any: 678. の挙動と *note object: a5a. の挙動を対比しましょう。
*note Any: 678. と同様に、すべての型は *note object: a5a. のサブタイプで
す。しかしながら、 *note Any: 678. と異なり、逆は成り立ちません: *note
object: a5a. はすべての他の型のサブタイプでは 'ありません'。

これは、ある値の型が *note object: a5a. のとき、型検査器はこれについての
ほとんどすべての操作を拒否し、これをより特殊化された変数に代入する (また
は返り値として利用する) ことは型エラーになることを意味します。例えば:

     def hash_a(item: object) -> int:
         # Fails type checking; an object does not have a 'magic' method.
         item.magic()
         ...

     def hash_b(item: Any) -> int:
         # Passes type checking
         item.magic()
         ...

     # Passes type checking, since ints and strs are subclasses of object
     hash_a(42)
     hash_a("foo")

     # Passes type checking, since Any is compatible with all types
     hash_b(42)
     hash_b("foo")

*note object: a5a. は、ある値が型安全な方法で任意の型として使えることを
示すために使用します。 *note Any: 678. はある値が動的に型付けられること
を示すために使用します。


File: python.info,  Node: 名前的部分型 vs 構造的部分型,  Next: モジュールの内容<3>,  Prev: Any 型,  Up: typing --- 型ヒントのサポート

5.26.1.11 名前的部分型 vs 構造的部分型
......................................

初めは PEP 484(1) は Python の静的型システムを '名前的部分型' を使って定
義していました。 名前的部分型とは、クラス ‘B’ が期待されているところにク
ラス ‘A’ が許容されるのは ‘A’ が ‘B’ のサブクラスの場合かつその場合に限
る、ということです。

前出の必要条件は、*note Iterable: 21ab. などの抽象基底クラスにも当て嵌ま
ります。 この型付け手法の問題は、この手法をサポートするためにクラスに明
確な型付けを行う必要があることで、これは pythonic ではなく、普段行ってい
る 慣用的な Python コードへの動的型付けとは似ていません。 例えば、次のコ
ードは PEP 484(2) に従ったものです

     from collections.abc import Sized, Iterable, Iterator

     class Bucket(Sized, Iterable[int]):
         ...
         def __len__(self) -> int: ...
         def __iter__(self) -> Iterator[int]: ...

PEP 544(3) によって上にあるようなクラス定義で基底クラスを明示しないコー
ドをユーザーが書け、静的型チェッカーで ‘Bucket’ が ‘Sized’ と
‘Iterable[int]’ 両方のサブタイプだと暗黙的に見なせるようになり、この問題
が解決しました。 これは 'structural subtyping (構造的部分型)' (あるいは
、静的ダックタイピング) として知られています:

     from collections.abc import Iterator, Iterable

     class Bucket:  # Note: no base classes
         ...
         def __len__(self) -> int: ...
         def __iter__(self) -> Iterator[int]: ...

     def collect(items: Iterable[int]) -> int: ...
     result = collect(Bucket())  # Passes type check

さらに、特別なクラス *note Protocol: 245. のサブクラスを作ることで、新し
い独自のプロトコルを作って構造的部分型というものを満喫できます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0484/

   (3) https://peps.python.org/pep-0544/


File: python.info,  Node: モジュールの内容<3>,  Next: メジャーな機能の非推奨時系列,  Prev: 名前的部分型 vs 構造的部分型,  Up: typing --- 型ヒントのサポート

5.26.1.12 モジュールの内容
..........................

The ‘typing’ module defines the following classes, functions and
decorators.

* Menu:

* 特殊型付けプリミティブ::
* プロトコル: プロトコル<3>.
* ABCs for working with IO::
* Functions and decorators::
* Introspection helpers::
* 定数: 定数<10>.
* 非推奨のエイリアス::


File: python.info,  Node: 特殊型付けプリミティブ,  Next: プロトコル<3>,  Up: モジュールの内容<3>

5.26.1.13 特殊型付けプリミティブ
................................

* Menu:

* 特殊型::
* 特殊形式::
* Building generic types and type aliases::
* Other special directives::


File: python.info,  Node: 特殊型,  Next: 特殊形式,  Up: 特殊型付けプリミティブ

5.26.1.14 特殊型
................

These can be used as types in annotations.  They do not support
subscription using ‘[]’.

 -- データ: typing.Any

     制約のない型であることを示す特別な型です。

        * 任意の型は *note Any: 678. と互換です。

        * *note Any: 678. は任意の型と互換です。

     バージョン 3.11 で変更: *note Any: 678. can now be used as a base
     class.  This can be useful for avoiding type checker errors with
     classes that can duck type anywhere or are highly dynamic.

 -- データ: typing.AnyStr

     A *note constrained type variable: 3e09.

     Definition:

          AnyStr = TypeVar('AnyStr', str, bytes)

     ‘AnyStr’ is meant to be used for functions that may accept *note
     str: 418. or *note bytes: 1a4. arguments but cannot allow the two
     to mix.

     例えば:

          def concat(a: AnyStr, b: AnyStr) -> AnyStr:
              return a + b

          concat("foo", "bar")    # OK, output has type 'str'
          concat(b"foo", b"bar")  # OK, output has type 'bytes'
          concat("foo", b"bar")   # Error, cannot mix str and bytes

     Note that, despite its name, ‘AnyStr’ has nothing to do with the
     *note Any: 678. type, nor does it mean "any string".  In
     particular, ‘AnyStr’ and ‘str | bytes’ are different from each
     other and have different use cases:

          # Invalid use of AnyStr:
          # The type variable is used only once in the function signature,
          # so cannot be "solved" by the type checker
          def greet_bad(cond: bool) -> AnyStr:
              return "hi there!" if cond else b"greetings!"

          # The better way of annotating this function:
          def greet_proper(cond: bool) -> str | bytes:
              return "hi there!" if cond else b"greetings!"

     Deprecated since version 3.13, will be removed in version 3.18:
     Deprecated in favor of the new *note type parameter syntax: 293.
     Use ‘class A[T: (str, bytes)]: ...’ instead of importing ‘AnyStr’.
     See PEP 695(1) for more details.

     In Python 3.16, ‘AnyStr’ will be removed from ‘typing.__all__’, and
     deprecation warnings will be emitted at runtime when it is accessed
     or imported from ‘typing’.  ‘AnyStr’ will be removed from ‘typing’
     in Python 3.18.

 -- データ: typing.LiteralString

     Special type that includes only literal strings.

     Any string literal is compatible with ‘LiteralString’, as is
     another ‘LiteralString’.  However, an object typed as just ‘str’ is
     not.  A string created by composing ‘LiteralString’-typed objects
     is also acceptable as a ‘LiteralString’.

     例:

          def run_query(sql: LiteralString) -> None:
              ...

          def caller(arbitrary_string: str, literal_string: LiteralString) -> None:
              run_query("SELECT * FROM students")  # OK
              run_query(literal_string)  # OK
              run_query("SELECT * FROM " + literal_string)  # OK
              run_query(arbitrary_string)  # type checker error
              run_query(  # type checker error
                  f"SELECT * FROM students WHERE name = {arbitrary_string}"
              )

     ‘LiteralString’ is useful for sensitive APIs where arbitrary
     user-generated strings could generate problems.  For example, the
     two cases above that generate type checker errors could be
     vulnerable to an SQL injection attack.

     より詳しくは PEP 675(2) を参照してください。

     Added in version 3.11.

 -- データ: typing.Never
 -- データ: typing.NoReturn

     ‘Never’ and ‘NoReturn’ represent the bottom type(3), a type that
     has no members.

     They can be used to indicate that a function never returns, such as
     *note sys.exit(): 1318.:

          from typing import Never  # or NoReturn

          def stop() -> Never:
              raise RuntimeError('no way')

     Or to define a function that should never be called, as there are
     no valid arguments, such as *note assert_never(): 673.:

          from typing import Never  # or NoReturn

          def never_call_me(arg: Never) -> None:
              pass

          def int_or_str(arg: int | str) -> None:
              never_call_me(arg)  # type checker error
              match arg:
                  case int():
                      print("It's an int")
                  case str():
                      print("It's a str")
                  case _:
                      never_call_me(arg)  # OK, arg is of type Never (or NoReturn)

     ‘Never’ and ‘NoReturn’ have the same meaning in the type system and
     static type checkers treat both equivalently.

     Added in version 3.6.2: Added *note NoReturn: 3e0a.

     Added in version 3.11: Added *note Never: 674.

 -- データ: typing.Self

     Special type to represent the current enclosed class.

     例えば:

          from typing import Self, reveal_type

          class Foo:
              def return_self(self) -> Self:
                  ...
                  return self

          class SubclassOfFoo(Foo): pass

          reveal_type(Foo().return_self())  # Revealed type is "Foo"
          reveal_type(SubclassOfFoo().return_self())  # Revealed type is "SubclassOfFoo"

     This annotation is semantically equivalent to the following, albeit
     in a more succinct fashion:

          from typing import TypeVar

          Self = TypeVar("Self", bound="Foo")

          class Foo:
              def return_self(self: Self) -> Self:
                  ...
                  return self

     In general, if something returns ‘self’, as in the above examples,
     you should use ‘Self’ as the return annotation.  If
     ‘Foo.return_self’ was annotated as returning ‘"Foo"’, then the type
     checker would infer the object returned from
     ‘SubclassOfFoo.return_self’ as being of type ‘Foo’ rather than
     ‘SubclassOfFoo’.

     Other common use cases include:

        - *note classmethod: 14c.s that are used as alternative
          constructors and return instances of the ‘cls’ parameter.

        - Annotating an *note __enter__(): 592. method which returns
          self.

     You should not use ‘Self’ as the return annotation if the method is
     not guaranteed to return an instance of a subclass when the class
     is subclassed:

          class Eggs:
              # Self would be an incorrect return annotation here,
              # as the object returned is always an instance of Eggs,
              # even in subclasses
              def returns_eggs(self) -> "Eggs":
                  return Eggs()

     より詳しくは PEP 673(4) を参照してください。

     Added in version 3.11.

 -- データ: typing.TypeAlias

     Special annotation for explicitly declaring a *note type alias:
     420.

     例えば:

          from typing import TypeAlias

          Factors: TypeAlias = list[int]

     ‘TypeAlias’ is particularly useful on older Python versions for
     annotating aliases that make use of forward references, as it can
     be hard for type checkers to distinguish these from normal variable
     assignments:

          from typing import Generic, TypeAlias, TypeVar

          T = TypeVar("T")

          # "Box" does not exist yet,
          # so we have to use quotes for the forward reference on Python <3.12.
          # Using ``TypeAlias`` tells the type checker that this is a type alias declaration,
          # not a variable assignment to a string.
          BoxOfStrings: TypeAlias = "Box[str]"

          class Box(Generic[T]):
              @classmethod
              def make_box_of_strings(cls) -> BoxOfStrings: ...

     より詳しくは、 PEP 613(5) をご覧ください。

     Added in version 3.10.

     バージョン 3.12 で非推奨: *note TypeAlias: 794. is deprecated in
     favor of the *note type: 404. statement, which creates instances of
     *note TypeAliasType: 421. and which natively supports forward
     references.  Note that while *note TypeAlias: 794. and *note
     TypeAliasType: 421. serve similar purposes and have similar names,
     they are distinct and the latter is not the type of the former.
     Removal of *note TypeAlias: 794. is not currently planned, but
     users are encouraged to migrate to *note type: 404. statements.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0695/

   (2) https://peps.python.org/pep-0675/

   (3) https://en.wikipedia.org/wiki/Bottom_type

   (4) https://peps.python.org/pep-0673/

   (5) https://peps.python.org/pep-0613/


File: python.info,  Node: 特殊形式,  Next: Building generic types and type aliases,  Prev: 特殊型,  Up: 特殊型付けプリミティブ

5.26.1.15 特殊形式
..................

これらはアノテーションの型として使用できます。これらは全て ‘[]’ を使用し
た添字表記をサポートしますが、それぞれ固有の構文があります。

 -- データ: typing.Union

     ユニオン型; ‘Union[X, Y]’ は ‘X | Y’ と等価で X または Y を表します
     。

     To define a union, use e.g.  ‘Union[int, str]’ or the shorthand
     ‘int | str’.  Using that shorthand is recommended.  Details:

        * 引数は型でなければならず、少なくとも一つ必要です。

        * ユニオン型のユニオン型は平滑化されます。例えば:

               Union[Union[int, str], float] == Union[int, str, float]

        * 引数が一つのユニオン型は消えます。例えば:

               Union[int] == int  # The constructor actually returns int

        * 冗長な実引数は飛ばされます。例えば:

               Union[int, str, int] == Union[int, str] == int | str

        * ユニオン型を比較するとき引数の順序は無視されます。例えば:

               Union[int, str] == Union[str, int]

        * ‘Union’ のサブクラスを作成したり、インスタンスを作成することは
          出来ません。

        * ‘Union[X][Y]’ と書くことは出来ません。

     バージョン 3.7 で変更: 明示的に書かれているサブクラスを、実行時に直
     和型から取り除かなくなりました。

     バージョン 3.10 で変更: ユニオン型は ‘X | Y’ のように書けるようにな
     りました。 *note union型の表現: 78d. を参照ください。

 -- データ: typing.Optional

     ‘Optional[X]’ は ‘X | None’ (や ‘Union[X, None]’) と同等です。

     これがデフォルト値を持つオプション引数とは同じ概念ではないというこ
     とに注意してください。 デフォルト値を持つオプション引数はオプション
     引数であるために、型アノテーションに ‘Optional’ 修飾子は必要ありま
     せん。 例えば次のようになります:

          def foo(arg: int = 0) -> None:
              ...

     それとは逆に、 ‘None’ という値が許されていることが明示されている場
     合は、引数がオプションであろうとなかろうと、 ‘Optional’ を使うのが
     好ましいです。 例えば次のようになります:

          def foo(arg: Optional[int] = None) -> None:
              ...

     バージョン 3.10 で変更: Optionalは ‘X | None’ のように書けるように
     なりました。 ref:‘union型の表現 <types-union>’ を参照ください。

 -- データ: typing.Concatenate

     Special form for annotating higher-order functions.

     ‘Concatenate’ can be used in conjunction with *note Callable: 2480.
     and *note ParamSpec: 144. to annotate a higher-order callable which
     adds, removes, or transforms parameters of another callable.  Usage
     is in the form ‘Concatenate[Arg1Type, Arg2Type, ...,
     ParamSpecVariable]’.  ‘Concatenate’ is currently only valid when
     used as the first argument to a *note Callable: 2480.  The last
     parameter to ‘Concatenate’ must be a *note ParamSpec: 144. or
     ellipsis (‘...’).

     For example, to annotate a decorator ‘with_lock’ which provides a
     *note threading.Lock: 15db. to the decorated function,
     ‘Concatenate’ can be used to indicate that ‘with_lock’ expects a
     callable which takes in a ‘Lock’ as the first argument, and returns
     a callable with a different type signature.  In this case, the
     *note ParamSpec: 144. indicates that the returned callable's
     parameter types are dependent on the parameter types of the
     callable being passed in:

          from collections.abc import Callable
          from threading import Lock
          from typing import Concatenate

          # Use this lock to ensure that only one thread is executing a function
          # at any time.
          my_lock = Lock()

          def with_lock[**P, R](f: Callable[Concatenate[Lock, P], R]) -> Callable[P, R]:
              '''A type-safe decorator which provides a lock.'''
              def inner(*args: P.args, **kwargs: P.kwargs) -> R:
                  # Provide the lock as the first argument.
                  return f(my_lock, *args, **kwargs)
              return inner

          @with_lock
          def sum_threadsafe(lock: Lock, numbers: list[float]) -> float:
              '''Add a list of numbers together in a thread-safe manner.'''
              with lock:
                  return sum(numbers)

          # We don't need to pass in the lock ourselves thanks to the decorator.
          sum_threadsafe([1.1, 2.2, 3.3])

     Added in version 3.10.

     参考
     ....

        * PEP 612(1) - Parameter Specification Variables (the PEP which
          introduced ‘ParamSpec’ and ‘Concatenate’)

        * *note ParamSpec: 144.

        * *note 呼び出し可能オブジェクトのアノテーション: 2480.

 -- データ: typing.Literal

     Special typing form to define "literal types".

     ‘Literal’ can be used to indicate to type checkers that the
     annotated object has a value equivalent to one of the provided
     literals.

     例えば:

          def validate_simple(data: Any) -> Literal[True]:  # always returns True
              ...

          type Mode = Literal['r', 'rb', 'w', 'wb']
          def open_helper(file: str, mode: Mode) -> str:
              ...

          open_helper('/some/path', 'r')      # Passes type check
          open_helper('/other/path', 'typo')  # Error in type checker

     ‘Literal[...]’ はサブクラスにはできません。 実行時に、任意の値が
     ‘Literal[...]’ の型引数として使えますが、型チェッカーが制約を課すこ
     とがあります。 リテラル型についてより詳しいことは PEP 586(2) を参照
     してください。

     Added in version 3.8.

     バージョン 3.9.1 で変更: ‘Literal’ ではパラメータの重複を解消するよ
     うになりました。‘Literal’ オブジェクトの等値比較は順序に依存しない
     ようになりました。‘Literal’ オブジェクトは、等値比較する際に、パラ
     メータのうち 1 つでも *note hashable: 5db. でない場合は *note
     TypeError: 502. を送出するようになりました。

 -- データ: typing.ClassVar

     クラス変数であることを示す特別な型構築子です。

     PEP 526(3) で導入された通り、 ClassVar でラップされた変数アノテーシ
     ョンによって、ある属性はクラス変数として使うつもりであり、そのクラ
     スのインスタンスから設定すべきではないということを示せます。使い方
     は次のようになります:

          class Starship:
              stats: ClassVar[dict[str, int]] = {} # class variable
              damage: int = 10                     # instance variable

     *note ClassVar: 247. は型のみを受け入れ、それ以外は受け付けられませ
     ん。

     *note ClassVar: 247. はクラスそのものではなく、*note isinstance():
     40e. や *note issubclass(): 78c. で使うべきではありません。 *note
     ClassVar: 247. は Python の実行時の挙動を変えませんが、サードパーテ
     ィの型検査器で使えます。 例えば、型チェッカーは次のコードをエラーと
     するかもしれません:

          enterprise_d = Starship(3000)
          enterprise_d.stats = {} # Error, setting class variable on instance
          Starship.stats = {}     # This is OK

     Added in version 3.5.3.

     バージョン 3.13 で変更: *note ClassVar: 247. can now be nested in
     *note Final: 248. and vice versa.

 -- データ: typing.Final

     Special typing construct to indicate final names to type checkers.

     Final names cannot be reassigned in any scope.  Final names
     declared in class scopes cannot be overridden in subclasses.

     例えば:

          MAX_SIZE: Final = 9000
          MAX_SIZE += 1  # Error reported by type checker

          class Connection:
              TIMEOUT: Final[int] = 10

          class FastConnector(Connection):
              TIMEOUT = 1  # Error reported by type checker

     この機能は実行時には検査されません。詳細については PEP 591(4) を参
     照してください。

     Added in version 3.8.

     バージョン 3.13 で変更: *note Final: 248. can now be nested in
     *note ClassVar: 247. and vice versa.

 -- データ: typing.Required

     Special typing construct to mark a *note TypedDict: 148. key as
     required.

     This is mainly useful for ‘total=False’ TypedDicts.  See *note
     TypedDict: 148. and PEP 655(5) for more details.

     Added in version 3.11.

 -- データ: typing.NotRequired

     Special typing construct to mark a *note TypedDict: 148. key as
     potentially missing.

     より詳しくは、 *note TypedDict: 148. と PEP 655(6) を参照してくださ
     い。

     Added in version 3.11.

 -- データ: typing.ReadOnly

     A special typing construct to mark an item of a *note TypedDict:
     148. as read-only.

     例えば:

          class Movie(TypedDict):
             title: ReadOnly[str]
             year: int

          def mutate_movie(m: Movie) -> None:
             m["year"] = 1999  # allowed
             m["title"] = "The Matrix"  # typechecker error

     There is no runtime checking for this property.

     See *note TypedDict: 148. and PEP 705(7) for more details.

     Added in version 3.13.

 -- データ: typing.Annotated

     Special typing form to add context-specific metadata to an
     annotation.

     Add metadata ‘x’ to a given type ‘T’ by using the annotation
     ‘Annotated[T, x]’.  Metadata added using ‘Annotated’ can be used by
     static analysis tools or at runtime.  At runtime, the metadata is
     stored in a ‘__metadata__’ attribute.

     If a library or tool encounters an annotation ‘Annotated[T, x]’ and
     has no special logic for the metadata, it should ignore the
     metadata and simply treat the annotation as ‘T’.  As such,
     ‘Annotated’ can be useful for code that wants to use annotations
     for purposes outside Python's static typing system.

     Using ‘Annotated[T, x]’ as an annotation still allows for static
     typechecking of ‘T’, as type checkers will simply ignore the
     metadata ‘x’.  In this way, ‘Annotated’ differs from the *note
     @no_type_check: 680. decorator, which can also be used for adding
     annotations outside the scope of the typing system, but completely
     disables typechecking for a function or class.

     The responsibility of how to interpret the metadata lies with the
     tool or library encountering an ‘Annotated’ annotation.  A tool or
     library encountering an ‘Annotated’ type can scan through the
     metadata elements to determine if they are of interest (e.g., using
     *note isinstance(): 40e.).

      -- Describe: Annotated[<type>, <metadata>]

     Here is an example of how you might use ‘Annotated’ to add metadata
     to type annotations if you were doing range analysis:

          @dataclass
          class ValueRange:
              lo: int
              hi: int

          T1 = Annotated[int, ValueRange(-10, 5)]
          T2 = Annotated[T1, ValueRange(-20, 3)]

     Details of the syntax:

        * The first argument to ‘Annotated’ must be a valid type

        * Multiple metadata elements can be supplied (‘Annotated’
          supports variadic arguments):

               @dataclass
               class ctype:
                   kind: str

               Annotated[int, ValueRange(3, 10), ctype("char")]

          It is up to the tool consuming the annotations to decide
          whether the client is allowed to add multiple metadata
          elements to one annotation and how to merge those annotations.

        * ‘Annotated’ must be subscripted with at least two arguments (
          ‘Annotated[int]’ is not valid)

        * The order of the metadata elements is preserved and matters
          for equality checks:

               assert Annotated[int, ValueRange(3, 10), ctype("char")] != Annotated[
                   int, ctype("char"), ValueRange(3, 10)
               ]

        * Nested ‘Annotated’ types are flattened.  The order of the
          metadata elements starts with the innermost annotation:

               assert Annotated[Annotated[int, ValueRange(3, 10)], ctype("char")] == Annotated[
                   int, ValueRange(3, 10), ctype("char")
               ]

        * Duplicated metadata elements are not removed:

               assert Annotated[int, ValueRange(3, 10)] != Annotated[
                   int, ValueRange(3, 10), ValueRange(3, 10)
               ]

        * ‘Annotated’ can be used with nested and generic aliases:

               @dataclass
               class MaxLen:
                   value: int

               type Vec[T] = Annotated[list[tuple[T, T]], MaxLen(10)]

               # When used in a type annotation, a type checker will treat "V" the same as
               # ``Annotated[list[tuple[int, int]], MaxLen(10)]``:
               type V = Vec[int]

        * ‘Annotated’ cannot be used with an unpacked *note
          TypeVarTuple: 145.:

               type Variadic[*Ts] = Annotated[*Ts, Ann1]  # NOT valid

          This would be equivalent to:

               Annotated[T1, T2, T3, ..., Ann1]

          where ‘T1’, ‘T2’, etc.  are *note TypeVars: 143.  This would
          be invalid: only one type should be passed to Annotated.

        * By default, *note get_type_hints(): 67d. strips the metadata
          from annotations.  Pass ‘include_extras=True’ to have the
          metadata preserved:

               >>> from typing import Annotated, get_type_hints
               >>> def func(x: Annotated[int, "metadata"]) -> None: pass
               ...
               >>> get_type_hints(func)
               {'x': <class 'int'>, 'return': <class 'NoneType'>}
               >>> get_type_hints(func, include_extras=True)
               {'x': typing.Annotated[int, 'metadata'], 'return': <class 'NoneType'>}

        * At runtime, the metadata associated with an ‘Annotated’ type
          can be retrieved via the ‘__metadata__’ attribute:

               >>> from typing import Annotated
               >>> X = Annotated[int, "very", "important", "metadata"]
               >>> X
               typing.Annotated[int, 'very', 'important', 'metadata']
               >>> X.__metadata__
               ('very', 'important', 'metadata')

        * At runtime, if you want to retrieve the original type wrapped
          by ‘Annotated’, use the ‘__origin__’ attribute:

               >>> from typing import Annotated, get_origin
               >>> Password = Annotated[str, "secret"]
               >>> Password.__origin__
               <class 'str'>

          Note that using *note get_origin(): a15. will return
          ‘Annotated’ itself:

               >>> get_origin(Password)
               typing.Annotated

     参考
     ....

     PEP 593(8) - Flexible function and variable annotations

          The PEP introducing ‘Annotated’ to the standard library.

     Added in version 3.9.

 -- データ: typing.TypeIs

     Special typing construct for marking user-defined type predicate
     functions.

     ‘TypeIs’ can be used to annotate the return type of a user-defined
     type predicate function.  ‘TypeIs’ only accepts a single type
     argument.  At runtime, functions marked this way should return a
     boolean and take at least one positional argument.

     ‘TypeIs’ aims to benefit 'type narrowing' - a technique used by
     static type checkers to determine a more precise type of an
     expression within a program's code flow.  Usually type narrowing is
     done by analyzing conditional code flow and applying the narrowing
     to a block of code.  The conditional expression here is sometimes
     referred to as a "type predicate":

          def is_str(val: str | float):
              # "isinstance" type predicate
              if isinstance(val, str):
                  # Type of ``val`` is narrowed to ``str``
                  ...
              else:
                  # Else, type of ``val`` is narrowed to ``float``.
                  ...

     Sometimes it would be convenient to use a user-defined boolean
     function as a type predicate.  Such a function should use
     ‘TypeIs[...]’ or *note TypeGuard: 14a. as its return type to alert
     static type checkers to this intention.  ‘TypeIs’ usually has more
     intuitive behavior than ‘TypeGuard’, but it cannot be used when the
     input and output types are incompatible (e.g., ‘list[object]’ to
     ‘list[int]’) or when the function does not return ‘True’ for all
     instances of the narrowed type.

     Using ‘-> TypeIs[NarrowedType]’ tells the static type checker that
     for a given function:

       1. The return value is a boolean.

       2. If the return value is ‘True’, the type of its argument is the
          intersection of the argument's original type and
          ‘NarrowedType’.

       3. If the return value is ‘False’, the type of its argument is
          narrowed to exclude ‘NarrowedType’.

     例えば:

          from typing import assert_type, final, TypeIs

          class Parent: pass
          class Child(Parent): pass
          @final
          class Unrelated: pass

          def is_parent(val: object) -> TypeIs[Parent]:
              return isinstance(val, Parent)

          def run(arg: Child | Unrelated):
              if is_parent(arg):
                  # Type of ``arg`` is narrowed to the intersection
                  # of ``Parent`` and ``Child``, which is equivalent to
                  # ``Child``.
                  assert_type(arg, Child)
              else:
                  # Type of ``arg`` is narrowed to exclude ``Parent``,
                  # so only ``Unrelated`` is left.
                  assert_type(arg, Unrelated)

     The type inside ‘TypeIs’ must be consistent with the type of the
     function's argument; if it is not, static type checkers will raise
     an error.  An incorrectly written ‘TypeIs’ function can lead to
     unsound behavior in the type system; it is the user's
     responsibility to write such functions in a type-safe manner.

     If a ‘TypeIs’ function is a class or instance method, then the type
     in ‘TypeIs’ maps to the type of the second parameter (after ‘cls’
     or ‘self’).

     In short, the form ‘def foo(arg: TypeA) -> TypeIs[TypeB]: ...’,
     means that if ‘foo(arg)’ returns ‘True’, then ‘arg’ is an instance
     of ‘TypeB’, and if it returns ‘False’, it is not an instance of
     ‘TypeB’.

     ‘TypeIs’ also works with type variables.  For more information, see
     PEP 742(9) (Narrowing types with ‘TypeIs’).

     Added in version 3.13.

 -- データ: typing.TypeGuard

     Special typing construct for marking user-defined type predicate
     functions.

     Type predicate functions are user-defined functions that return
     whether their argument is an instance of a particular type.
     ‘TypeGuard’ works similarly to *note TypeIs: 149, but has subtly
     different effects on type checking behavior (see below).

     Using ‘-> TypeGuard’ tells the static type checker that for a given
     function:

       1. The return value is a boolean.

       2. If the return value is ‘True’, the type of its argument is the
          type inside ‘TypeGuard’.

     ‘TypeGuard’ also works with type variables.  See PEP 647(10) for
     more details.

     例えば:

          def is_str_list(val: list[object]) -> TypeGuard[list[str]]:
              '''Determines whether all objects in the list are strings'''
              return all(isinstance(x, str) for x in val)

          def func1(val: list[object]):
              if is_str_list(val):
                  # Type of ``val`` is narrowed to ``list[str]``.
                  print(" ".join(val))
              else:
                  # Type of ``val`` remains as ``list[object]``.
                  print("Not a list of strings!")

     ‘TypeIs’ and ‘TypeGuard’ differ in the following ways:

        * ‘TypeIs’ requires the narrowed type to be a subtype of the
          input type, while ‘TypeGuard’ does not.  The main reason is to
          allow for things like narrowing ‘list[object]’ to ‘list[str]’
          even though the latter is not a subtype of the former, since
          ‘list’ is invariant.

        * When a ‘TypeGuard’ function returns ‘True’, type checkers
          narrow the type of the variable to exactly the ‘TypeGuard’
          type.  When a ‘TypeIs’ function returns ‘True’, type checkers
          can infer a more precise type combining the previously known
          type of the variable with the ‘TypeIs’ type.  (Technically,
          this is known as an intersection type.)

        * When a ‘TypeGuard’ function returns ‘False’, type checkers
          cannot narrow the type of the variable at all.  When a
          ‘TypeIs’ function returns ‘False’, type checkers can narrow
          the type of the variable to exclude the ‘TypeIs’ type.

     Added in version 3.10.

 -- データ: typing.Unpack

     Typing operator to conceptually mark an object as having been
     unpacked.

     For example, using the unpack operator ‘*’ on a *note type variable
     tuple: 3e0c. is equivalent to using ‘Unpack’ to mark the type
     variable tuple as having been unpacked:

          Ts = TypeVarTuple('Ts')
          tup: tuple[*Ts]
          # Effectively does:
          tup: tuple[Unpack[Ts]]

     In fact, ‘Unpack’ can be used interchangeably with ‘*’ in the
     context of *note typing.TypeVarTuple: 145. and *note
     builtins.tuple: 349. types.  You might see ‘Unpack’ being used
     explicitly in older versions of Python, where ‘*’ couldn't be used
     in certain places:

          # In older versions of Python, TypeVarTuple and Unpack
          # are located in the `typing_extensions` backports package.
          from typing_extensions import TypeVarTuple, Unpack

          Ts = TypeVarTuple('Ts')
          tup: tuple[*Ts]         # Syntax error on Python <= 3.10!
          tup: tuple[Unpack[Ts]]  # Semantically equivalent, and backwards-compatible

     ‘Unpack’ can also be used along with *note typing.TypedDict: 148.
     for typing ‘**kwargs’ in a function signature:

          from typing import TypedDict, Unpack

          class Movie(TypedDict):
              name: str
              year: int

          # This function expects two keyword arguments - `name` of type `str`
          # and `year` of type `int`.
          def foo(**kwargs: Unpack[Movie]): ...

     See PEP 692(11) for more details on using ‘Unpack’ for ‘**kwargs’
     typing.

     Added in version 3.11.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0612/

   (2) https://peps.python.org/pep-0586/

   (3) https://peps.python.org/pep-0526/

   (4) https://peps.python.org/pep-0591/

   (5) https://peps.python.org/pep-0655/

   (6) https://peps.python.org/pep-0655/

   (7) https://peps.python.org/pep-0705/

   (8) https://peps.python.org/pep-0593/

   (9) https://peps.python.org/pep-0742/

   (10) https://peps.python.org/pep-0647/

   (11) https://peps.python.org/pep-0692/


File: python.info,  Node: Building generic types and type aliases,  Next: Other special directives,  Prev: 特殊形式,  Up: 特殊型付けプリミティブ

5.26.1.16 Building generic types and type aliases
.................................................

The following classes should not be used directly as annotations.  Their
intended purpose is to be building blocks for creating generic types and
type aliases.

These objects can be created through special syntax (*note type
parameter lists: 293. and the *note type: 404. statement).  For
compatibility with Python 3.11 and earlier, they can also be created
without the dedicated syntax, as documented below.

 -- クラス: typing.Generic

     ジェネリック型のための抽象基底クラスです。

     A generic type is typically declared by adding a list of type
     parameters after the class name:

          class Mapping[KT, VT]:
              def __getitem__(self, key: KT) -> VT:
                  ...
                  # Etc.

     Such a class implicitly inherits from ‘Generic’.  The runtime
     semantics of this syntax are discussed in the *note Language
     Reference: 41e.

     このクラスは次のように使用することが出来ます:

          def lookup_name[X, Y](mapping: Mapping[X, Y], key: X, default: Y) -> Y:
              try:
                  return mapping[key]
              except KeyError:
                  return default

     Here the brackets after the function name indicate a *note generic
     function: 41f.

     For backwards compatibility, generic classes can also be declared
     by explicitly inheriting from ‘Generic’.  In this case, the type
     parameters must be declared separately:

          KT = TypeVar('KT')
          VT = TypeVar('VT')

          class Mapping(Generic[KT, VT]):
              def __getitem__(self, key: KT) -> VT:
                  ...
                  # Etc.

 -- クラス: typing.TypeVar (name, *constraints, bound=None,
          covariant=False, contravariant=False, infer_variance=False,
          default=typing.NoDefault)

     型変数です。

     The preferred way to construct a type variable is via the dedicated
     syntax for *note generic functions: 41f, *note generic classes:
     41e, and *note generic type aliases: 422.:

          class Sequence[T]:  # T is a TypeVar
              ...

     This syntax can also be used to create bounded and constrained type
     variables:

          class StrSequence[S: str]:  # S is a TypeVar with a `str` upper bound;
              ...                     # we can say that S is "bounded by `str`"


          class StrOrBytesSequence[A: (str, bytes)]:  # A is a TypeVar constrained to str or bytes
              ...

     However, if desired, reusable type variables can also be
     constructed manually, like so:

          T = TypeVar('T')  # Can be anything
          S = TypeVar('S', bound=str)  # Can be any subtype of str
          A = TypeVar('A', str, bytes)  # Must be exactly str or bytes

     Type variables exist primarily for the benefit of static type
     checkers.  They serve as the parameters for generic types as well
     as for generic function and type alias definitions.  See *note
     Generic: 157c. for more information on generic types.  Generic
     functions work as follows:

          def repeat[T](x: T, n: int) -> Sequence[T]:
              """Return a list containing n references to x."""
              return [x]*n


          def print_capitalized[S: str](x: S) -> S:
              """Print x capitalized, and return x."""
              print(x.capitalize())
              return x


          def concatenate[A: (str, bytes)](x: A, y: A) -> A:
              """Add two strings or bytes objects together."""
              return x + y

     Note that type variables can be 'bounded', 'constrained', or
     neither, but cannot be both bounded 'and' constrained.

     The variance of type variables is inferred by type checkers when
     they are created through the *note type parameter syntax: 293. or
     when ‘infer_variance=True’ is passed.  Manually created type
     variables may be explicitly marked covariant or contravariant by
     passing ‘covariant=True’ or ‘contravariant=True’.  By default,
     manually created type variables are invariant.  See PEP 484(1) and
     PEP 695(2) for more details.

     Bounded type variables and constrained type variables have
     different semantics in several important ways.  Using a 'bounded'
     type variable means that the ‘TypeVar’ will be solved using the
     most specific type possible:

          x = print_capitalized('a string')
          reveal_type(x)  # revealed type is str

          class StringSubclass(str):
              pass

          y = print_capitalized(StringSubclass('another string'))
          reveal_type(y)  # revealed type is StringSubclass

          z = print_capitalized(45)  # error: int is not a subtype of str

     The upper bound of a type variable can be a concrete type, abstract
     type (ABC or Protocol), or even a union of types:

          # Can be anything with an __abs__ method
          def print_abs[T: SupportsAbs](arg: T) -> None:
              print("Absolute value:", abs(arg))

          U = TypeVar('U', bound=str|bytes)  # Can be any subtype of the union str|bytes
          V = TypeVar('V', bound=SupportsAbs)  # Can be anything with an __abs__ method
     Using a 'constrained' type variable, however, means that the
     ‘TypeVar’ can only ever be solved as being exactly one of the
     constraints given:

          a = concatenate('one', 'two')
          reveal_type(a)  # revealed type is str

          b = concatenate(StringSubclass('one'), StringSubclass('two'))
          reveal_type(b)  # revealed type is str, despite StringSubclass being passed in

          c = concatenate('one', b'two')  # error: type variable 'A' can be either str or bytes in a function call, but not both

     At runtime, ‘isinstance(x, T)’ will raise *note TypeError: 502.

      -- の属性: __name__

          The name of the type variable.

      -- の属性: __covariant__

          Whether the type var has been explicitly marked as covariant.

      -- の属性: __contravariant__

          Whether the type var has been explicitly marked as
          contravariant.

      -- の属性: __infer_variance__

          Whether the type variable's variance should be inferred by
          type checkers.

          Added in version 3.12.

      -- の属性: __bound__

          The upper bound of the type variable, if any.

          バージョン 3.12 で変更: For type variables created through
          *note type parameter syntax: 293, the bound is evaluated only
          when the attribute is accessed, not when the type variable is
          created (see *note Lazy evaluation: 423.).

      -- の属性: __constraints__

          A tuple containing the constraints of the type variable, if
          any.

          バージョン 3.12 で変更: For type variables created through
          *note type parameter syntax: 293, the constraints are
          evaluated only when the attribute is accessed, not when the
          type variable is created (see *note Lazy evaluation: 423.).

      -- の属性: __default__

          The default value of the type variable, or *note
          typing.NoDefault: 243. if it has no default.

          Added in version 3.13.

      -- メソッド: has_default ()

          Return whether or not the type variable has a default value.
          This is equivalent to checking whether *note __default__:
          3e14. is not the *note typing.NoDefault: 243. singleton,
          except that it does not force evaluation of the *note lazily
          evaluated: 423. default value.

          Added in version 3.13.

     バージョン 3.12 で変更: Type variables can now be declared using
     the *note type parameter: 293. syntax introduced by PEP 695(3).
     The ‘infer_variance’ parameter was added.

     バージョン 3.13 で変更: Support for default values was added.

 -- クラス: typing.TypeVarTuple (name, *, default=typing.NoDefault)

     Type variable tuple.  A specialized form of *note type variable:
     3e03. that enables 'variadic' generics.

     Type variable tuples can be declared in *note type parameter lists:
     293. using a single asterisk (‘*’) before the name:

          def move_first_element_to_last[T, *Ts](tup: tuple[T, *Ts]) -> tuple[*Ts, T]:
              return (*tup[1:], tup[0])

     Or by explicitly invoking the ‘TypeVarTuple’ constructor:

          T = TypeVar("T")
          Ts = TypeVarTuple("Ts")

          def move_first_element_to_last(tup: tuple[T, *Ts]) -> tuple[*Ts, T]:
              return (*tup[1:], tup[0])

     A normal type variable enables parameterization with a single type.
     A type variable tuple, in contrast, allows parameterization with an
     'arbitrary' number of types by acting like an 'arbitrary' number of
     type variables wrapped in a tuple.  For example:

          # T is bound to int, Ts is bound to ()
          # Return value is (1,), which has type tuple[int]
          move_first_element_to_last(tup=(1,))

          # T is bound to int, Ts is bound to (str,)
          # Return value is ('spam', 1), which has type tuple[str, int]
          move_first_element_to_last(tup=(1, 'spam'))

          # T is bound to int, Ts is bound to (str, float)
          # Return value is ('spam', 3.0, 1), which has type tuple[str, float, int]
          move_first_element_to_last(tup=(1, 'spam', 3.0))

          # This fails to type check (and fails at runtime)
          # because tuple[()] is not compatible with tuple[T, *Ts]
          # (at least one element is required)
          move_first_element_to_last(tup=())

     Note the use of the unpacking operator ‘*’ in ‘tuple[T, *Ts]’.
     Conceptually, you can think of ‘Ts’ as a tuple of type variables
     ‘(T1, T2, ...)’.  ‘tuple[T, *Ts]’ would then become ‘tuple[T, *(T1,
     T2, ...)]’, which is equivalent to ‘tuple[T, T1, T2, ...]’.  (Note
     that in older versions of Python, you might see this written using
     *note Unpack: 1593. instead, as ‘Unpack[Ts]’.)

     Type variable tuples must 'always' be unpacked.  This helps
     distinguish type variable tuples from normal type variables:

          x: Ts          # Not valid
          x: tuple[Ts]   # Not valid
          x: tuple[*Ts]  # The correct way to do it

     Type variable tuples can be used in the same contexts as normal
     type variables.  For example, in class definitions, arguments, and
     return types:

          class Array[*Shape]:
              def __getitem__(self, key: tuple[*Shape]) -> float: ...
              def __abs__(self) -> "Array[*Shape]": ...
              def get_shape(self) -> tuple[*Shape]: ...

     Type variable tuples can be happily combined with normal type
     variables:

          class Array[DType, *Shape]:  # This is fine
              pass

          class Array2[*Shape, DType]:  # This would also be fine
              pass

          class Height: ...
          class Width: ...

          float_array_1d: Array[float, Height] = Array()     # Totally fine
          int_array_2d: Array[int, Height, Width] = Array()  # Yup, fine too

     However, note that at most one type variable tuple may appear in a
     single list of type arguments or type parameters:

          x: tuple[*Ts, *Ts]            # Not valid
          class Array[*Shape, *Shape]:  # Not valid
              pass

     Finally, an unpacked type variable tuple can be used as the type
     annotation of ‘*args’:

          def call_soon[*Ts](
              callback: Callable[[*Ts], None],
              *args: *Ts
          ) -> None:
              ...
              callback(*args)

     In contrast to non-unpacked annotations of ‘*args’ - e.g.  ‘*args:
     int’, which would specify that 'all' arguments are ‘int’ - ‘*args:
     *Ts’ enables reference to the types of the 'individual' arguments
     in ‘*args’.  Here, this allows us to ensure the types of the
     ‘*args’ passed to ‘call_soon’ match the types of the (positional)
     arguments of ‘callback’.

     See PEP 646(4) for more details on type variable tuples.

      -- の属性: __name__

          The name of the type variable tuple.

      -- の属性: __default__

          The default value of the type variable tuple, or *note
          typing.NoDefault: 243. if it has no default.

          Added in version 3.13.

      -- メソッド: has_default ()

          Return whether or not the type variable tuple has a default
          value.  This is equivalent to checking whether *note
          __default__: 3e17. is not the *note typing.NoDefault: 243.
          singleton, except that it does not force evaluation of the
          *note lazily evaluated: 423. default value.

          Added in version 3.13.

     Added in version 3.11.

     バージョン 3.12 で変更: Type variable tuples can now be declared
     using the *note type parameter: 293. syntax introduced by PEP
     695(5).

     バージョン 3.13 で変更: Support for default values was added.

 -- クラス: typing.ParamSpec (name, *, bound=None, covariant=False,
          contravariant=False, default=typing.NoDefault)

     Parameter specification variable.  A specialized version of *note
     type variables: 3e03.

     In *note type parameter lists: 293, parameter specifications can be
     declared with two asterisks (‘**’):

          type IntFunc[**P] = Callable[P, int]

     For compatibility with Python 3.11 and earlier, ‘ParamSpec’ objects
     can also be created as follows:

          P = ParamSpec('P')

     Parameter specification variables exist primarily for the benefit
     of static type checkers.  They are used to forward the parameter
     types of one callable to another callable - a pattern commonly
     found in higher order functions and decorators.  They are only
     valid when used in ‘Concatenate’, or as the first argument to
     ‘Callable’, or as parameters for user-defined Generics.  See *note
     Generic: 157c. for more information on generic types.

     For example, to add basic logging to a function, one can create a
     decorator ‘add_logging’ to log function calls.  The parameter
     specification variable tells the type checker that the callable
     passed into the decorator and the new callable returned by it have
     inter-dependent type parameters:

          from collections.abc import Callable
          import logging

          def add_logging[T, **P](f: Callable[P, T]) -> Callable[P, T]:
              '''A type-safe decorator to add logging to a function.'''
              def inner(*args: P.args, **kwargs: P.kwargs) -> T:
                  logging.info(f'{f.__name__} was called')
                  return f(*args, **kwargs)
              return inner

          @add_logging
          def add_two(x: float, y: float) -> float:
              '''Add two numbers together.'''
              return x + y

     Without ‘ParamSpec’, the simplest way to annotate this previously
     was to use a *note TypeVar: 143. with upper bound ‘Callable[...,
     Any]’.  However this causes two problems:

       1. The type checker can't type check the ‘inner’ function because
          ‘*args’ and ‘**kwargs’ have to be typed *note Any: 678.

       2. *note cast(): 3e19. may be required in the body of the
          ‘add_logging’ decorator when returning the ‘inner’ function,
          or the static type checker must be told to ignore the ‘return
          inner’.

      -- の属性: args

      -- の属性: kwargs

          Since ‘ParamSpec’ captures both positional and keyword
          parameters, ‘P.args’ and ‘P.kwargs’ can be used to split a
          ‘ParamSpec’ into its components.  ‘P.args’ represents the
          tuple of positional parameters in a given call and should only
          be used to annotate ‘*args’.  ‘P.kwargs’ represents the
          mapping of keyword parameters to their values in a given call,
          and should be only be used to annotate ‘**kwargs’.  Both
          attributes require the annotated parameter to be in scope.  At
          runtime, ‘P.args’ and ‘P.kwargs’ are instances respectively of
          *note ParamSpecArgs: 791. and *note ParamSpecKwargs: 792.

      -- の属性: __name__

          The name of the parameter specification.

      -- の属性: __default__

          The default value of the parameter specification, or *note
          typing.NoDefault: 243. if it has no default.

          Added in version 3.13.

      -- メソッド: has_default ()

          Return whether or not the parameter specification has a
          default value.  This is equivalent to checking whether *note
          __default__: 3e1d. is not the *note typing.NoDefault: 243.
          singleton, except that it does not force evaluation of the
          *note lazily evaluated: 423. default value.

          Added in version 3.13.

     Parameter specification variables created with ‘covariant=True’ or
     ‘contravariant=True’ can be used to declare covariant or
     contravariant generic types.  The ‘bound’ argument is also
     accepted, similar to *note TypeVar: 143.  However the actual
     semantics of these keywords are yet to be decided.

     Added in version 3.10.

     バージョン 3.12 で変更: Parameter specifications can now be
     declared using the *note type parameter: 293. syntax introduced by
     PEP 695(6).

     バージョン 3.13 で変更: Support for default values was added.

          注釈: Only parameter specification variables defined in global
          scope can be pickled.

     参考
     ....

        * PEP 612(7) - Parameter Specification Variables (the PEP which
          introduced ‘ParamSpec’ and ‘Concatenate’)

        * *note Concatenate: 78f.

        * *note 呼び出し可能オブジェクトのアノテーション: 2480.

 -- データ: typing.ParamSpecArgs
 -- データ: typing.ParamSpecKwargs

     Arguments and keyword arguments attributes of a *note ParamSpec:
     144.  The ‘P.args’ attribute of a ‘ParamSpec’ is an instance of
     ‘ParamSpecArgs’, and ‘P.kwargs’ is an instance of
     ‘ParamSpecKwargs’.  They are intended for runtime introspection and
     have no special meaning to static type checkers.

     Calling *note get_origin(): a15. on either of these objects will
     return the original ‘ParamSpec’:

          >>> from typing import ParamSpec, get_origin
          >>> P = ParamSpec("P")
          >>> get_origin(P.args) is P
          True
          >>> get_origin(P.kwargs) is P
          True

     Added in version 3.10.

 -- クラス: typing.TypeAliasType (name, value, *, type_params=())

     The type of type aliases created through the *note type: 404.
     statement.

     例:

          >>> type Alias = int
          >>> type(Alias)
          <class 'typing.TypeAliasType'>

     Added in version 3.12.

      -- の属性: __name__

          The name of the type alias:

               >>> type Alias = int
               >>> Alias.__name__
               'Alias'

      -- の属性: __module__

          The module in which the type alias was defined:

               >>> type Alias = int
               >>> Alias.__module__
               '__main__'

      -- の属性: __type_params__

          The type parameters of the type alias, or an empty tuple if
          the alias is not generic:

               >>> type ListOrSet[T] = list[T] | set[T]
               >>> ListOrSet.__type_params__
               (T,)
               >>> type NotGeneric = int
               >>> NotGeneric.__type_params__
               ()

      -- の属性: __value__

          The type alias's value.  This is *note lazily evaluated: 423,
          so names used in the definition of the alias are not resolved
          until the ‘__value__’ attribute is accessed:

               >>> type Mutually = Recursive
               >>> type Recursive = Mutually
               >>> Mutually
               Mutually
               >>> Recursive
               Recursive
               >>> Mutually.__value__
               Recursive
               >>> Recursive.__value__
               Mutually

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0695/

   (3) https://peps.python.org/pep-0695/

   (4) https://peps.python.org/pep-0646/

   (5) https://peps.python.org/pep-0695/

   (6) https://peps.python.org/pep-0695/

   (7) https://peps.python.org/pep-0612/


File: python.info,  Node: Other special directives,  Prev: Building generic types and type aliases,  Up: 特殊型付けプリミティブ

5.26.1.17 Other special directives
..................................

These functions and classes should not be used directly as annotations.
Their intended purpose is to be building blocks for creating and
declaring types.

 -- クラス: typing.NamedTuple

     *note collections.namedtuple(): 1ac. の型付き版です。

     使い方:

          class Employee(NamedTuple):
              name: str
              id: int

     これは次と等価です:

          Employee = collections.namedtuple('Employee', ['name', 'id'])

     フィールドにデフォルト値を与えるにはクラス本体で代入してください:

          class Employee(NamedTuple):
              name: str
              id: int = 3

          employee = Employee('Guido')
          assert employee.id == 3

     デフォルト値のあるフィールドはデフォルト値のないフィールドの後でな
     ければなりません。

     最終的に出来上がるクラスには、フィールド名をフィールド型へ対応付け
     る辞書を提供する ‘__annotations__’ 属性が追加されています。 (フィー
     ルド名は ‘_fields’ 属性に、デフォルト値は ‘_field_defaults’ 属性に
     格納されていて、両方とも *note namedtuple(): 1ac. API の一部分です
     。)

     ‘NamedTuple’ のサブクラスは docstring やメソッドも持てます:

          class Employee(NamedTuple):
              """Represents an employee."""
              name: str
              id: int = 3

              def __repr__(self) -> str:
                  return f'<Employee {self.name}, id={self.id}>'

     ‘NamedTuple’ subclasses can be generic:

          class Group[T](NamedTuple):
              key: T
              group: list[T]

     後方互換な使用法:

          # For creating a generic NamedTuple on Python 3.11
          T = TypeVar("T")

          class Group(NamedTuple, Generic[T]):
              key: T
              group: list[T]

          # A functional syntax is also supported
          Employee = NamedTuple('Employee', [('name', str), ('id', int)])

     バージョン 3.6 で変更: PEP 526(1) 変数アノテーションのシンタックス
     が追加されました。

     バージョン 3.6.1 で変更: デフォルト値、メソッド、ドキュメンテーショ
     ン文字列への対応が追加されました。

     バージョン 3.8 で変更: ‘_field_types’ 属性および ‘__annotations__’
     属性は ‘OrderedDict’ インスタンスではなく普通の辞書になりました。

     バージョン 3.9 で変更: ‘_field_types’ 属性は削除されました。代わり
     に同じ情報を持つより標準的な ‘__annotations__’ 属性を使ってください
     。

     バージョン 3.11 で変更: Added support for generic namedtuples.

     Deprecated since version 3.13, will be removed in version 3.15: The
     undocumented keyword argument syntax for creating NamedTuple
     classes (‘NT = NamedTuple("NT", x=int)’) is deprecated, and will be
     disallowed in 3.15.  Use the class-based syntax or the functional
     syntax instead.

     Deprecated since version 3.13, will be removed in version 3.15:
     When using the functional syntax to create a NamedTuple class,
     failing to pass a value to the 'fields' parameter (‘NT =
     NamedTuple("NT")’) is deprecated.  Passing ‘None’ to the 'fields'
     parameter (‘NT = NamedTuple("NT", None)’) is also deprecated.  Both
     will be disallowed in Python 3.15.  To create a NamedTuple class
     with 0 fields, use ‘class NT(NamedTuple): pass’ or ‘NT =
     NamedTuple("NT", [])’.

 -- クラス: typing.NewType (name, tp)

     Helper class to create low-overhead *note distinct types: 3df7.

     A ‘NewType’ is considered a distinct type by a typechecker.  At
     runtime, however, calling a ‘NewType’ returns its argument
     unchanged.

     使い方:

          UserId = NewType('UserId', int)  # Declare the NewType "UserId"
          first_user = UserId(1)  # "UserId" returns the argument unchanged at runtime

      -- の属性: __module__

          The module in which the new type is defined.

      -- の属性: __name__

          The name of the new type.

      -- の属性: __supertype__

          The type that the new type is based on.

     Added in version 3.5.2.

     バージョン 3.10 で変更: ‘NewType’ is now a class rather than a
     function.

 -- クラス: typing.Protocol (Generic)

     Base class for protocol classes.

     Protocol classes are defined like this:

          class Proto(Protocol):
              def meth(self) -> int:
                  ...

     このようなクラスは主に構造的部分型 (静的ダックタイピング) を認識す
     る静的型チェッカーが使います。例えば:

          class C:
              def meth(self) -> int:
                  return 0

          def func(x: Proto) -> int:
              return x.meth()

          func(C())  # Passes static type check

     詳細については PEP 544(2) を参照してください。 *note
     runtime_checkable(): 40f. (後で説明します) でデコレートされたプロト
     コルクラスは、与えられたメソッドがあることだけを確認し、その型シグ
     ネチャは全く見ない安直な動作をする実行時プロトコルとして振る舞いま
     す。

     プロトコルクラスはジェネリックにもできます。例えば:

          class GenProto[T](Protocol):
              def meth(self) -> T:
                  ...

     In code that needs to be compatible with Python 3.11 or older,
     generic Protocols can be written as follows:

          T = TypeVar("T")

          class GenProto(Protocol[T]):
              def meth(self) -> T:
                  ...

     Added in version 3.8.

 -- の関数: @typing.runtime_checkable

     Mark a protocol class as a runtime protocol.

     Such a protocol can be used with *note isinstance(): 40e. and *note
     issubclass(): 78c.  This raises *note TypeError: 502. when applied
     to a non-protocol class.  This allows a simple-minded structural
     check, very similar to "one trick ponies" in *note collections.abc:
     17. such as *note Iterable: 21ab.  For example:

          @runtime_checkable
          class Closable(Protocol):
              def close(self): ...

          assert isinstance(open('/some/file'), Closable)

          @runtime_checkable
          class Named(Protocol):
              name: str

          import threading
          assert isinstance(threading.Thread(name='Bob'), Named)

          注釈: ‘runtime_checkable()’ will check only the presence of
          the required methods or attributes, not their type signatures
          or types.  For example, *note ssl.SSLObject: b4f. is a class,
          therefore it passes an *note issubclass(): 78c. check against
          *note Callable: 2480.  However, the ‘ssl.SSLObject.__init__’
          method exists only to raise a *note TypeError: 502. with a
          more informative message, therefore making it impossible to
          call (instantiate) *note ssl.SSLObject: b4f.

          注釈: An *note isinstance(): 40e. check against a
          runtime-checkable protocol can be surprisingly slow compared
          to an ‘isinstance()’ check against a non-protocol class.
          Consider using alternative idioms such as *note hasattr():
          49e. calls for structural checks in performance-sensitive
          code.

     Added in version 3.8.

     バージョン 3.12 で変更: The internal implementation of *note
     isinstance(): 40e. checks against runtime-checkable protocols now
     uses *note inspect.getattr_static(): 461. to look up attributes
     (previously, *note hasattr(): 49e. was used).  As a result, some
     objects which used to be considered instances of a
     runtime-checkable protocol may no longer be considered instances of
     that protocol on Python 3.12+, and vice versa.  Most users are
     unlikely to be affected by this change.

     バージョン 3.12 で変更: The members of a runtime-checkable protocol
     are now considered "frozen" at runtime as soon as the class has
     been created.  Monkey-patching attributes onto a runtime-checkable
     protocol will still work, but will have no impact on *note
     isinstance(): 40e. checks comparing objects to the protocol.  See
     *note "What's new in Python 3.12": 49d. for more details.

 -- クラス: typing.TypedDict (dict)

     Special construct to add type hints to a dictionary.  At runtime it
     is a plain *note dict: 237.

     ‘TypedDict’ は、その全てのインスタンスにおいてキーの集合が固定され
     ていて、各キーに対応する値が全てのインスタンスで同じ型を持つことが
     期待される辞書型を宣言します。 この期待は実行時にはチェックされず、
     型チェッカーでのみ強制されます。 使用方法は次の通りです:

          class Point2D(TypedDict):
              x: int
              y: int
              label: str

          a: Point2D = {'x': 1, 'y': 2, 'label': 'good'}  # OK
          b: Point2D = {'z': 3, 'label': 'bad'}           # Fails type check

          assert Point2D(x=1, y=2, label='first') == dict(x=1, y=2, label='first')

     An alternative way to create a ‘TypedDict’ is by using
     function-call syntax.  The second argument must be a literal *note
     dict: 237.:

          Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': str})

     This functional syntax allows defining keys which are not valid
     *note identifiers: 1df6, for example because they are keywords or
     contain hyphens:

          # raises SyntaxError
          class Point2D(TypedDict):
              in: int  # 'in' is a keyword
              x-y: int  # name with hyphens

          # OK, functional syntax
          Point2D = TypedDict('Point2D', {'in': int, 'x-y': int})

     By default, all keys must be present in a ‘TypedDict’.  It is
     possible to mark individual keys as non-required using *note
     NotRequired: 58f.:

          class Point2D(TypedDict):
              x: int
              y: int
              label: NotRequired[str]

          # Alternative syntax
          Point2D = TypedDict('Point2D', {'x': int, 'y': int, 'label': NotRequired[str]})

     This means that a ‘Point2D’ ‘TypedDict’ can have the ‘label’ key
     omitted.

     It is also possible to mark all keys as non-required by default by
     specifying a totality of ‘False’:

          class Point2D(TypedDict, total=False):
              x: int
              y: int

          # Alternative syntax
          Point2D = TypedDict('Point2D', {'x': int, 'y': int}, total=False)

     This means that a ‘Point2D’ ‘TypedDict’ can have any of the keys
     omitted.  A type checker is only expected to support a literal
     ‘False’ or ‘True’ as the value of the ‘total’ argument.  ‘True’ is
     the default, and makes all items defined in the class body
     required.

     Individual keys of a ‘total=False’ ‘TypedDict’ can be marked as
     required using *note Required: 58e.:

          class Point2D(TypedDict, total=False):
              x: Required[int]
              y: Required[int]
              label: str

          # Alternative syntax
          Point2D = TypedDict('Point2D', {
              'x': Required[int],
              'y': Required[int],
              'label': str
          }, total=False)

     It is possible for a ‘TypedDict’ type to inherit from one or more
     other ‘TypedDict’ types using the class-based syntax.  Usage:

          class Point3D(Point2D):
              z: int

     ‘Point3D’ has three items: ‘x’, ‘y’ and ‘z’.  It is equivalent to
     this definition:

          class Point3D(TypedDict):
              x: int
              y: int
              z: int

     A ‘TypedDict’ cannot inherit from a non-‘TypedDict’ class, except
     for *note Generic: 157c.  For example:

          class X(TypedDict):
              x: int

          class Y(TypedDict):
              y: int

          class Z(object): pass  # A non-TypedDict class

          class XY(X, Y): pass  # OK

          class XZ(X, Z): pass  # raises TypeError

     A ‘TypedDict’ can be generic:

          class Group[T](TypedDict):
              key: T
              group: list[T]

     To create a generic ‘TypedDict’ that is compatible with Python 3.11
     or lower, inherit from *note Generic: 157c. explicitly:

          T = TypeVar("T")

          class Group(TypedDict, Generic[T]):
              key: T
              group: list[T]

     A ‘TypedDict’ can be introspected via annotations dicts (see *note
     Annotations Best Practices: 7a4. for more information on
     annotations best practices), *note __total__: 3e27, *note
     __required_keys__: 3e28, and *note __optional_keys__: 3e29.

      -- の属性: __total__

          ‘Point2D.__total__’ gives the value of the ‘total’ argument.
          Example:

               >>> from typing import TypedDict
               >>> class Point2D(TypedDict): pass
               >>> Point2D.__total__
               True
               >>> class Point2D(TypedDict, total=False): pass
               >>> Point2D.__total__
               False
               >>> class Point3D(Point2D): pass
               >>> Point3D.__total__
               True

          This attribute reflects 'only' the value of the ‘total’
          argument to the current ‘TypedDict’ class, not whether the
          class is semantically total.  For example, a ‘TypedDict’ with
          ‘__total__’ set to ‘True’ may have keys marked with *note
          NotRequired: 58f, or it may inherit from another ‘TypedDict’
          with ‘total=False’.  Therefore, it is generally better to use
          *note __required_keys__: 3e28. and *note __optional_keys__:
          3e29. for introspection.

      -- の属性: __required_keys__

          Added in version 3.9.

      -- の属性: __optional_keys__

          ‘Point2D.__required_keys__’ and ‘Point2D.__optional_keys__’
          return *note frozenset: 5a4. objects containing required and
          non-required keys, respectively.

          Keys marked with *note Required: 58e. will always appear in
          ‘__required_keys__’ and keys marked with *note NotRequired:
          58f. will always appear in ‘__optional_keys__’.

          For backwards compatibility with Python 3.10 and below, it is
          also possible to use inheritance to declare both required and
          non-required keys in the same ‘TypedDict’ .  This is done by
          declaring a ‘TypedDict’ with one value for the ‘total’
          argument and then inheriting from it in another ‘TypedDict’
          with a different value for ‘total’:

               >>> class Point2D(TypedDict, total=False):
               ...     x: int
               ...     y: int
               ...
               >>> class Point3D(Point2D):
               ...     z: int
               ...
               >>> Point3D.__required_keys__ == frozenset({'z'})
               True
               >>> Point3D.__optional_keys__ == frozenset({'x', 'y'})
               True

          Added in version 3.9.

               注釈: If ‘from __future__ import annotations’ is used or
               if annotations are given as strings, annotations are not
               evaluated when the ‘TypedDict’ is defined.  Therefore,
               the runtime introspection that ‘__required_keys__’ and
               ‘__optional_keys__’ rely on may not work properly, and
               the values of the attributes may be incorrect.

     Support for *note ReadOnly: 147. is reflected in the following
     attributes:

      -- の属性: __readonly_keys__

          A *note frozenset: 5a4. containing the names of all read-only
          keys.  Keys are read-only if they carry the *note ReadOnly:
          147. qualifier.

          Added in version 3.13.

      -- の属性: __mutable_keys__

          A *note frozenset: 5a4. containing the names of all mutable
          keys.  Keys are mutable if they do not carry the *note
          ReadOnly: 147. qualifier.

          Added in version 3.13.

     他の例や、 ‘TypedDict’ を扱う詳細な規則については PEP 589(3) を参照
     してください。

     Added in version 3.8.

     バージョン 3.11 で変更: Added support for marking individual keys
     as *note Required: 58e. or *note NotRequired: 58f.  See PEP 655(4).

     バージョン 3.11 で変更: Added support for generic ‘TypedDict’s.

     バージョン 3.13 で変更: Removed support for the keyword-argument
     method of creating ‘TypedDict’s.

     バージョン 3.13 で変更: Support for the *note ReadOnly: 147.
     qualifier was added.

     Deprecated since version 3.13, will be removed in version 3.15:
     When using the functional syntax to create a TypedDict class,
     failing to pass a value to the 'fields' parameter (‘TD =
     TypedDict("TD")’) is deprecated.  Passing ‘None’ to the 'fields'
     parameter (‘TD = TypedDict("TD", None)’) is also deprecated.  Both
     will be disallowed in Python 3.15.  To create a TypedDict class
     with 0 fields, use ‘class TD(TypedDict): pass’ or ‘TD =
     TypedDict("TD", {})’.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0526/

   (2) https://peps.python.org/pep-0544/

   (3) https://peps.python.org/pep-0589/

   (4) https://peps.python.org/pep-0655/


File: python.info,  Node: プロトコル<3>,  Next: ABCs for working with IO,  Prev: 特殊型付けプリミティブ,  Up: モジュールの内容<3>

5.26.1.18 プロトコル
....................

The following protocols are provided by the typing module.  All are
decorated with *note @runtime_checkable: 40f.

 -- クラス: typing.SupportsAbs

     返り値の型と共変な抽象メソッド ‘__abs__’ を備えた ABC です。

 -- クラス: typing.SupportsBytes

     抽象メソッド ‘__bytes__’ を備えた ABC です。

 -- クラス: typing.SupportsComplex

     抽象メソッド ‘__complex__’ を備えた ABC です。

 -- クラス: typing.SupportsFloat

     抽象メソッド ‘__float__’ を備えた ABC です。

 -- クラス: typing.SupportsIndex

     抽象メソッド ‘__index__’ を備えた ABC です。

     Added in version 3.8.

 -- クラス: typing.SupportsInt

     抽象メソッド ‘__int__’ を備えた ABC です。

 -- クラス: typing.SupportsRound

     返り値の型と共変な抽象メソッド ‘__round__’ を備えた ABC です。


File: python.info,  Node: ABCs for working with IO,  Next: Functions and decorators,  Prev: プロトコル<3>,  Up: モジュールの内容<3>

5.26.1.19 ABCs for working with IO
..................................

 -- クラス: typing.IO
 -- クラス: typing.TextIO
 -- クラス: typing.BinaryIO

     ジェネリック型 ‘IO[AnyStr]’ とそのサブクラスの ‘TextIO(IO[str])’ お
     よび ‘BinaryIO(IO[bytes])’ は、 *note open(): 4e5. 関数が返すような
     I/O ストリームの型を表します。


File: python.info,  Node: Functions and decorators,  Next: Introspection helpers,  Prev: ABCs for working with IO,  Up: モジュールの内容<3>

5.26.1.20 Functions and decorators
..................................

 -- の関数: typing.cast (typ, val)

     値をある型にキャストします。

     この関数は値を変更せずに返します。 型検査器に対して、返り値が指定さ
     れた型を持っていることを通知しますが、実行時には意図的に何も検査し
     ません。 (その理由は、処理をできる限り速くしたかったためです。)

 -- の関数: typing.assert_type (val, typ, /)

     Ask a static type checker to confirm that 'val' has an inferred
     type of 'typ'.

     At runtime this does nothing: it returns the first argument
     unchanged with no checks or side effects, no matter the actual type
     of the argument.

     When a static type checker encounters a call to ‘assert_type()’, it
     emits an error if the value is not of the specified type:

          def greet(name: str) -> None:
              assert_type(name, str)  # OK, inferred type of `name` is `str`
              assert_type(name, int)  # type checker error

     This function is useful for ensuring the type checker's
     understanding of a script is in line with the developer's
     intentions:

          def complex_function(arg: object):
              # Do some complex type-narrowing logic,
              # after which we hope the inferred type will be `int`
              ...
              # Test whether the type checker correctly understands our function
              assert_type(arg, int)

     Added in version 3.11.

 -- の関数: typing.assert_never (arg, /)

     Ask a static type checker to confirm that a line of code is
     unreachable.

     以下はプログラム例です:

          def int_or_str(arg: int | str) -> None:
              match arg:
                  case int():
                      print("It's an int")
                  case str():
                      print("It's a str")
                  case _ as unreachable:
                      assert_never(unreachable)

     Here, the annotations allow the type checker to infer that the last
     case can never execute, because ‘arg’ is either an *note int: 238.
     or a *note str: 418, and both options are covered by earlier cases.

     If a type checker finds that a call to ‘assert_never()’ is
     reachable, it will emit an error.  For example, if the type
     annotation for ‘arg’ was instead ‘int | str | float’, the type
     checker would emit an error pointing out that ‘unreachable’ is of
     type *note float: 2ce.  For a call to ‘assert_never’ to pass type
     checking, the inferred type of the argument passed in must be the
     bottom type, *note Never: 674, and nothing else.

     At runtime, this throws an exception when called.

     参考
     ....

     Unreachable Code and Exhaustiveness Checking(1) has more
     information about exhaustiveness checking with static typing.

     Added in version 3.11.

 -- の関数: typing.reveal_type (obj, /)

     Ask a static type checker to reveal the inferred type of an
     expression.

     When a static type checker encounters a call to this function, it
     emits a diagnostic with the inferred type of the argument.  For
     example:

          x: int = 1
          reveal_type(x)  # Revealed type is "builtins.int"

     This can be useful when you want to debug how your type checker
     handles a particular piece of code.

     At runtime, this function prints the runtime type of its argument
     to *note sys.stderr: 907. and returns the argument unchanged
     (allowing the call to be used within an expression):

          x = reveal_type(1)  # prints "Runtime type is int"
          print(x)  # prints "1"

     Note that the runtime type may be different from (more or less
     specific than) the type statically inferred by a type checker.

     Most type checkers support ‘reveal_type()’ anywhere, even if the
     name is not imported from ‘typing’.  Importing the name from
     ‘typing’, however, allows your code to run without runtime errors
     and communicates intent more clearly.

     Added in version 3.11.

 -- の関数: @typing.dataclass_transform (*, eq_default=True,
          order_default=False, kw_only_default=False,
          frozen_default=False, field_specifiers=(), **kwargs)

     Decorator to mark an object as providing *note dataclass: 1ad.-like
     behavior.

     ‘dataclass_transform’ may be used to decorate a class, metaclass,
     or a function that is itself a decorator.  The presence of
     ‘@dataclass_transform()’ tells a static type checker that the
     decorated object performs runtime "magic" that transforms a class
     in a similar way to *note @dataclasses.dataclass: 1ad.

     Example usage with a decorator function:

          @dataclass_transform()
          def create_model[T](cls: type[T]) -> type[T]:
              ...
              return cls

          @create_model
          class CustomerModel:
              id: int
              name: str

     On a base class:

          @dataclass_transform()
          class ModelBase: ...

          class CustomerModel(ModelBase):
              id: int
              name: str

     On a metaclass:

          @dataclass_transform()
          class ModelMeta(type): ...

          class ModelBase(metaclass=ModelMeta): ...

          class CustomerModel(ModelBase):
              id: int
              name: str

     The ‘CustomerModel’ classes defined above will be treated by type
     checkers similarly to classes created with *note
     @dataclasses.dataclass: 1ad.  For example, type checkers will
     assume these classes have ‘__init__’ methods that accept ‘id’ and
     ‘name’.

     The decorated class, metaclass, or function may accept the
     following bool arguments which type checkers will assume have the
     same effect as they would have on the *note @dataclasses.dataclass:
     1ad. decorator: ‘init’, ‘eq’, ‘order’, ‘unsafe_hash’, ‘frozen’,
     ‘match_args’, ‘kw_only’, and ‘slots’.  It must be possible for the
     value of these arguments (‘True’ or ‘False’) to be statically
     evaluated.

     The arguments to the ‘dataclass_transform’ decorator can be used to
     customize the default behaviors of the decorated class, metaclass,
     or function:


     パラメータ:

        * ‘eq_default’ (*note bool: 434.) - Indicates whether the ‘eq’
          parameter is assumed to be ‘True’ or ‘False’ if it is omitted
          by the caller.  Defaults to ‘True’.

        * ‘order_default’ (*note bool: 434.) - Indicates whether the
          ‘order’ parameter is assumed to be ‘True’ or ‘False’ if it is
          omitted by the caller.  Defaults to ‘False’.

        * ‘kw_only_default’ (*note bool: 434.) - Indicates whether the
          ‘kw_only’ parameter is assumed to be ‘True’ or ‘False’ if it
          is omitted by the caller.  Defaults to ‘False’.

        * ‘frozen_default’ (*note bool: 434.) - Indicates whether the
          ‘frozen’ parameter is assumed to be ‘True’ or ‘False’ if it is
          omitted by the caller.  Defaults to ‘False’.

          Added in version 3.12.

        * ‘field_specifiers’ (*note tuple: 349.‘[’*note Callable:
          7b5.‘[’‘...’‘, ’‘Any’‘]’‘, ’‘...’‘]’) - Specifies a static
          list of supported classes or functions that describe fields,
          similar to *note dataclasses.field(): 198b.  Defaults to ‘()’.

        * ‘**kwargs’ (‘Any’) - Arbitrary other keyword arguments are
          accepted in order to allow for possible future extensions.

     Type checkers recognize the following optional parameters on field
     specifiers: 'Recognised parameters for field specifiers'

     Parameter name           説明
                              
     --------------------------------------------------------------------------------------------------------------
                              
     ‘init’                   Indicates whether the field should be included in the synthesized ‘__init__’
                              method.  If unspecified, ‘init’ defaults to ‘True’.
                              
                              
     ‘default’                Provides the default value for the field.
                              
                              
     ‘default_factory’        Provides a runtime callback that returns the default value for the field.  If
                              neither ‘default’ nor ‘default_factory’ are specified, the field is assumed to
                              have no default value and must be provided a value when the class is instantiated.
                              
                              
     ‘factory’                An alias for the ‘default_factory’ parameter on field specifiers.
                              
                              
     ‘kw_only’                Indicates whether the field should be marked as keyword-only.  If ‘True’, the
                              field will be keyword-only.  If ‘False’, it will not be keyword-only.  If
                              unspecified, the value of the ‘kw_only’ parameter on the object decorated with
                              ‘dataclass_transform’ will be used, or if that is unspecified, the value of
                              ‘kw_only_default’ on ‘dataclass_transform’ will be used.
                              
                              
     ‘alias’                  Provides an alternative name for the field.  This alternative name is used in the
                              synthesized ‘__init__’ method.
                              

     At runtime, this decorator records its arguments in the
     ‘__dataclass_transform__’ attribute on the decorated object.  It
     has no other runtime effect.

     より詳しくは PEP 681(2) を参照してください。

     Added in version 3.11.

 -- の関数: @typing.overload

     Decorator for creating overloaded functions and methods.

     The ‘@overload’ decorator allows describing functions and methods
     that support multiple different combinations of argument types.  A
     series of ‘@overload’-decorated definitions must be followed by
     exactly one non-‘@overload’-decorated definition (for the same
     function/method).

     ‘@overload’-decorated definitions are for the benefit of the type
     checker only, since they will be overwritten by the
     non-‘@overload’-decorated definition.  The
     non-‘@overload’-decorated definition, meanwhile, will be used at
     runtime but should be ignored by a type checker.  At runtime,
     calling an ‘@overload’-decorated function directly will raise *note
     NotImplementedError: 209.

     An example of overload that gives a more precise type than can be
     expressed using a union or a type variable:

          @overload
          def process(response: None) -> None:
              ...
          @overload
          def process(response: int) -> tuple[int, str]:
              ...
          @overload
          def process(response: bytes) -> str:
              ...
          def process(response):
              ...  # actual implementation goes here

     詳細と他の型付け意味論との比較は PEP 484(3) を参照してください。

     バージョン 3.11 で変更: Overloaded functions can now be
     introspected at runtime using *note get_overloads(): 67a.

 -- の関数: typing.get_overloads (func)

     Return a sequence of *note @overload: 3e34.-decorated definitions
     for 'func'.

     'func' is the function object for the implementation of the
     overloaded function.  For example, given the definition of
     ‘process’ in the documentation for *note @overload: 3e34,
     ‘get_overloads(process)’ will return a sequence of three function
     objects for the three defined overloads.  If called on a function
     with no overloads, ‘get_overloads()’ returns an empty sequence.

     ‘get_overloads()’ can be used for introspecting an overloaded
     function at runtime.

     Added in version 3.11.

 -- の関数: typing.clear_overloads ()

     Clear all registered overloads in the internal registry.

     This can be used to reclaim the memory used by the registry.

     Added in version 3.11.

 -- の関数: @typing.final

     Decorator to indicate final methods and final classes.

     Decorating a method with ‘@final’ indicates to a type checker that
     the method cannot be overridden in a subclass.  Decorating a class
     with ‘@final’ indicates that it cannot be subclassed.

     例えば:

          class Base:
              @final
              def done(self) -> None:
                  ...
          class Sub(Base):
              def done(self) -> None:  # Error reported by type checker
                  ...

          @final
          class Leaf:
              ...
          class Other(Leaf):  # Error reported by type checker
              ...

     この機能は実行時には検査されません。詳細については PEP 591(4) を参
     照してください。

     Added in version 3.8.

     バージョン 3.11 で変更: The decorator will now attempt to set a
     ‘__final__’ attribute to ‘True’ on the decorated object.  Thus, a
     check like ‘if getattr(obj, "__final__", False)’ can be used at
     runtime to determine whether an object ‘obj’ has been marked as
     final.  If the decorated object does not support setting
     attributes, the decorator returns the object unchanged without
     raising an exception.

 -- の関数: @typing.no_type_check

     アノテーションが型ヒントでないことを示すデコレータです。

     This works as a class or function *note decorator: 6fc.  With a
     class, it applies recursively to all methods and classes defined in
     that class (but not to methods defined in its superclasses or
     subclasses).  Type checkers will ignore all annotations in a
     function or class with this decorator.

     ‘@no_type_check’ mutates the decorated object in place.

 -- の関数: @typing.no_type_check_decorator

     別のデコレータに *note no_type_check(): 680. の効果を与えるデコレー
     タです。

     これは何かの関数をラップするデコレータを *note no_type_check():
     680. でラップします。

     Deprecated since version 3.13, will be removed in version 3.15: No
     type checker ever added support for ‘@no_type_check_decorator’.  It
     is therefore deprecated, and will be removed in Python 3.15.

 -- の関数: @typing.override

     Decorator to indicate that a method in a subclass is intended to
     override a method or attribute in a superclass.

     Type checkers should emit an error if a method decorated with
     ‘@override’ does not, in fact, override anything.  This helps
     prevent bugs that may occur when a base class is changed without an
     equivalent change to a child class.

     例えば:

          class Base:
              def log_status(self) -> None:
                  ...

          class Sub(Base):
              @override
              def log_status(self) -> None:  # Okay: overrides Base.log_status
                  ...

              @override
              def done(self) -> None:  # Error reported by type checker
                  ...

     There is no runtime checking of this property.

     The decorator will attempt to set an ‘__override__’ attribute to
     ‘True’ on the decorated object.  Thus, a check like ‘if
     getattr(obj, "__override__", False)’ can be used at runtime to
     determine whether an object ‘obj’ has been marked as an override.
     If the decorated object does not support setting attributes, the
     decorator returns the object unchanged without raising an
     exception.

     See PEP 698(5) for more details.

     Added in version 3.12.

 -- の関数: @typing.type_check_only

     Decorator to mark a class or function as unavailable at runtime.

     このデコレータ自身は実行時には使えません。 このデコレータは主に、実
     装がプライベートクラスのインスタンスを返す場合に、型スタブファイル
     に定義されているクラスに対して印を付けるためのものです:

          @type_check_only
          class Response:  # private or not available at runtime
              code: int
              def get_header(self, name: str) -> str: ...

          def fetch_response() -> Response: ...

     プライベートクラスのインスタンスを返すのは推奨されません。 そのよう
     なクラスは公開クラスにするのが望ましいです。

   ---------- Footnotes ----------

   (1) https://typing.readthedocs.io/en/latest/guides/unreachable.html

   (2) https://peps.python.org/pep-0681/

   (3) https://peps.python.org/pep-0484/

   (4) https://peps.python.org/pep-0591/

   (5) https://peps.python.org/pep-0698/


File: python.info,  Node: Introspection helpers,  Next: 定数<10>,  Prev: Functions and decorators,  Up: モジュールの内容<3>

5.26.1.21 Introspection helpers
...............................

 -- の関数: typing.get_type_hints (obj, globalns=None, localns=None,
          include_extras=False)

     関数、メソッド、モジュールまたはクラスのオブジェクトの型ヒントを含
     む辞書を返します。

     This is often the same as ‘obj.__annotations__’, but this function
     makes the following changes to the annotations dictionary:

        * Forward references encoded as string literals or *note
          ForwardRef: 17ae. objects are handled by evaluating them in
          'globalns', 'localns', and (where applicable) 'obj"s *note
          type parameter: 293. namespace.  If 'globalns' or 'localns' is
          not given, appropriate namespace dictionaries are inferred
          from 'obj'.

        * ‘None’ is replaced with *note types.NoneType: 81d.

        * If *note @no_type_check: 680. has been applied to 'obj', an
          empty dictionary is returned.

        * If 'obj' is a class ‘C’, the function returns a dictionary
          that merges annotations from ‘C’'s base classes with those on
          ‘C’ directly.  This is done by traversing *note C.__mro__:
          1e89. and iteratively combining ‘__annotations__’
          dictionaries.  Annotations on classes appearing earlier in the
          *note method resolution order: 20e5. always take precedence
          over annotations on classes appearing later in the method
          resolution order.

        * The function recursively replaces all occurrences of
          ‘Annotated[T, ...]’ with ‘T’, unless 'include_extras' is set
          to ‘True’ (see *note Annotated: 90b. for more information).

     See also *note inspect.get_annotations(): 7de, a lower-level
     function that returns annotations more directly.

          注釈: If any forward references in the annotations of 'obj'
          are not resolvable or are not valid Python code, this function
          will raise an exception such as *note NameError: 40b.  For
          example, this can happen with imported *note type aliases:
          420. that include forward references, or with names imported
          under *note if TYPE_CHECKING: cc2.

     バージョン 3.9 で変更: Added ‘include_extras’ parameter as part of
     PEP 593(1).  See the documentation on *note Annotated: 90b. for
     more information.

     バージョン 3.11 で変更: Previously, ‘Optional[t]’ was added for
     function and method annotations if a default value equal to ‘None’
     was set.  Now the annotation is returned unchanged.

 -- の関数: typing.get_origin (tp)

     Get the unsubscripted version of a type: for a typing object of the
     form ‘X[Y, Z, ...]’ return ‘X’.

     If ‘X’ is a typing-module alias for a builtin or *note collections:
     16. class, it will be normalized to the original class.  If ‘X’ is
     an instance of *note ParamSpecArgs: 791. or *note ParamSpecKwargs:
     792, return the underlying *note ParamSpec: 144.  Return ‘None’ for
     unsupported objects.

     例:

          assert get_origin(str) is None
          assert get_origin(Dict[str, int]) is dict
          assert get_origin(Union[int, str]) is Union
          assert get_origin(Annotated[str, "metadata"]) is Annotated
          P = ParamSpec('P')
          assert get_origin(P.args) is P
          assert get_origin(P.kwargs) is P

     Added in version 3.8.

 -- の関数: typing.get_args (tp)

     Get type arguments with all substitutions performed: for a typing
     object of the form ‘X[Y, Z, ...]’ return ‘(Y, Z, ...)’.

     If ‘X’ is a union or *note Literal: 820. contained in another
     generic type, the order of ‘(Y, Z, ...)’ may be different from the
     order of the original arguments ‘[Y, Z, ...]’ due to type caching.
     Return ‘()’ for unsupported objects.

     例:

          assert get_args(int) == ()
          assert get_args(Dict[int, str]) == (int, str)
          assert get_args(Union[int, str]) == (int, str)

     Added in version 3.8.

 -- の関数: typing.get_protocol_members (tp)

     Return the set of members defined in a *note Protocol: 245.

          >>> from typing import Protocol, get_protocol_members
          >>> class P(Protocol):
          ...     def a(self) -> str: ...
          ...     b: int
          >>> get_protocol_members(P) == frozenset({'a', 'b'})
          True

     Raise *note TypeError: 502. for arguments that are not Protocols.

     Added in version 3.13.

 -- の関数: typing.is_protocol (tp)

     Determine if a type is a *note Protocol: 245.

     例えば:

          class P(Protocol):
              def a(self) -> str: ...
              b: int

          is_protocol(P)    # => True
          is_protocol(int)  # => False

     Added in version 3.13.

 -- の関数: typing.is_typeddict (tp)

     Check if a type is a *note TypedDict: 148.

     例えば:

          class Film(TypedDict):
              title: str
              year: int

          assert is_typeddict(Film)
          assert not is_typeddict(list | str)

          # TypedDict is a factory for creating typed dicts,
          # not a typed dict itself
          assert not is_typeddict(TypedDict)

     Added in version 3.10.

 -- クラス: typing.ForwardRef

     Class used for internal typing representation of string forward
     references.

     For example, ‘List["SomeClass"]’ is implicitly transformed into
     ‘List[ForwardRef("SomeClass")]’.  ‘ForwardRef’ should not be
     instantiated by a user, but may be used by introspection tools.

          注釈: PEP 585(2) generic types such as ‘list["SomeClass"]’
          will not be implicitly transformed into
          ‘list[ForwardRef("SomeClass")]’ and thus will not
          automatically resolve to ‘list[SomeClass]’.

     Added in version 3.7.4.

 -- データ: typing.NoDefault

     A sentinel object used to indicate that a type parameter has no
     default value.  For example:

          >>> T = TypeVar("T")
          >>> T.__default__ is typing.NoDefault
          True
          >>> S = TypeVar("S", default=None)
          >>> S.__default__ is None
          True

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0593/

   (2) https://peps.python.org/pep-0585/


File: python.info,  Node: 定数<10>,  Next: 非推奨のエイリアス,  Prev: Introspection helpers,  Up: モジュールの内容<3>

5.26.1.22 定数
..............

 -- データ: typing.TYPE_CHECKING

     A special constant that is assumed to be ‘True’ by 3rd party static
     type checkers.  It is ‘False’ at runtime.

     使い方:

          if TYPE_CHECKING:
              import expensive_mod

          def fun(arg: 'expensive_mod.SomeType') -> None:
              local_var: expensive_mod.AnotherType = other_fun()

     The first type annotation must be enclosed in quotes, making it a
     "forward reference", to hide the ‘expensive_mod’ reference from the
     interpreter runtime.  Type annotations for local variables are not
     evaluated, so the second annotation does not need to be enclosed in
     quotes.

          注釈: ‘from __future__ import annotations’ が使われた場合、ア
          ノーテーションは関数定義時に評価されません。代わりにアノーテー
          ションは ‘__annotations__’ 属性に文字列として保存されます。こ
          れによりアノーテーションをシングルクォートで囲む必要がなくなり
          ます ( PEP 563(1) を参照してください)。

     Added in version 3.5.2.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0563/


File: python.info,  Node: 非推奨のエイリアス,  Prev: 定数<10>,  Up: モジュールの内容<3>

5.26.1.23 非推奨のエイリアス
............................

このモジュールは、既存の標準ライブラリ・クラスに対するいくつかの非推奨エ
イリアスを定義しています。これらは元々、 ‘[]’ を使ったジェネリッククラス
のパラメータ化をサポートするためにtypingモジュールに含まれていました。し
かしこのエイリアスは、Python 3.9 で既存の相当するクラスが ‘[]’ をサポー
トするように拡張されたため、冗長な書き方になりました( PEP 585(1) を参照
)。

The redundant types are deprecated as of Python 3.9.  However, while the
aliases may be removed at some point, removal of these aliases is not
currently planned.  As such, no deprecation warnings are currently
issued by the interpreter for these aliases.

If at some point it is decided to remove these deprecated aliases, a
deprecation warning will be issued by the interpreter for at least two
releases prior to removal.  The aliases are guaranteed to remain in the
typing module without deprecation warnings until at least Python 3.14.

Type checkers are encouraged to flag uses of the deprecated types if the
program they are checking targets a minimum Python version of 3.9 or
newer.

* Menu:

* Aliases to built-in types::
* Aliases to types in collections::
* Aliases to other concrete types::
* Aliases to container ABCs in collections.abc: Aliases to container ABCs in collections abc.
* Aliases to asynchronous ABCs in collections.abc: Aliases to asynchronous ABCs in collections abc.
* Aliases to other ABCs in collections.abc: Aliases to other ABCs in collections abc.
* Aliases to contextlib ABCs::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/


File: python.info,  Node: Aliases to built-in types,  Next: Aliases to types in collections,  Up: 非推奨のエイリアス

5.26.1.24 Aliases to built-in types
...................................

 -- クラス: typing.Dict (dict, MutableMapping[KT, VT])

     *note dict: 237. の非推奨なエイリアス。

     Note that to annotate arguments, it is preferred to use an abstract
     collection type such as *note Mapping: 898. rather than to use
     *note dict: 237. or ‘typing.Dict’.

     バージョン 3.9 で非推奨: *note builtins.dict: 237. は添字表記
     (‘[]’) をサポートするようになりました。 PEP 585(1) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.List (list, MutableSequence[T])

     *note list: 5dc. の非推奨なエイリアス。

     Note that to annotate arguments, it is preferred to use an abstract
     collection type such as *note Sequence: 1194. or *note Iterable:
     21ab. rather than to use *note list: 5dc. or ‘typing.List’.

     バージョン 3.9 で非推奨: *note builtins.list: 5dc. は添字表記
     (‘[]’) をサポートするようになりました。 PEP 585(2) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Set (set, MutableSet[T])

     Deprecated alias to *note builtins.set: 5a3.

     Note that to annotate arguments, it is preferred to use an abstract
     collection type such as *note collections.abc.Set: 21a3. rather
     than to use *note set: 5a3. or *note typing.Set: 3e3f.

     バージョン 3.9 で非推奨: *note builtins.set: 5a3. は添字表記 (‘[]’)
     をサポートするようになりました。 PEP 585(3) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.FrozenSet (frozenset, AbstractSet[T_co])

     Deprecated alias to *note builtins.frozenset: 5a4.

     バージョン 3.9 で非推奨: *note builtins.frozenset: 5a4. は添字表記
     (‘[]’) をサポートするようになりました。 PEP 585(4) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- データ: typing.Tuple

     *note tuple: 349. の非推奨なエイリアス。

     *note tuple: 349. and ‘Tuple’ are special-cased in the type system;
     see *note タプルのアノテーション: 3dfc. for more details.

     バージョン 3.9 で非推奨: *note builtins.tuple: 349. は添字表記
     (‘[]’) をサポートするようになりました。 PEP 585(5) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Type (Generic[CT_co])

     *note type: d16. の非推奨なエイリアス。

     See *note クラスオブジェクトの型: 3dff. for details on using *note
     type: d16. or ‘typing.Type’ in type annotations.

     Added in version 3.5.2.

     バージョン 3.9 で非推奨: *note builtins.type: d16. は添字表記
     (‘[]’) をサポートするようになりました。 PEP 585(6) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://peps.python.org/pep-0585/

   (3) https://peps.python.org/pep-0585/

   (4) https://peps.python.org/pep-0585/

   (5) https://peps.python.org/pep-0585/

   (6) https://peps.python.org/pep-0585/


File: python.info,  Node: Aliases to types in collections,  Next: Aliases to other concrete types,  Prev: Aliases to built-in types,  Up: 非推奨のエイリアス

5.26.1.25 Aliases to types in ‘collections’
...........................................

 -- クラス: typing.DefaultDict (collections.defaultdict,
          MutableMapping[KT, VT])

     *note collections.defaultdict: 118d. の非推奨なエイリアス。

     Added in version 3.5.2.

     バージョン 3.9 で非推奨: *note collections.defaultdict: 118d. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(1) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.OrderedDict (collections.OrderedDict,
          MutableMapping[KT, VT])

     *note collections.OrderedDict: 5a5. の非推奨なエイリアス。

     Added in version 3.7.2.

     バージョン 3.9 で非推奨: *note collections.OrderedDict: 5a5. は添字
     表記 (‘[]’) をサポートするようになりました。 PEP 585(2) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.ChainMap (collections.ChainMap, MutableMapping[KT,
          VT])

     *note collections.ChainMap: bea. の非推奨なエイリアス。

     Added in version 3.6.1.

     バージョン 3.9 で非推奨: *note collections.ChainMap: bea. は添字表
     記 (‘[]’) をサポートするようになりました。 PEP 585(3) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Counter (collections.Counter, Dict[T, int])

     *note collections.Counter: 1067. の非推奨なエイリアス。

     Added in version 3.6.1.

     バージョン 3.9 で非推奨: *note collections.Counter: 1067. は添字表
     記 (‘[]’) をサポートするようになりました。 PEP 585(4) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Deque (deque, MutableSequence[T])

     *note collections.deque: 5a6. の非推奨なエイリアス。

     Added in version 3.6.1.

     バージョン 3.9 で非推奨: *note collections.deque: 5a6. は添字表記
     (‘[]’) をサポートするようになりました。 PEP 585(5) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://peps.python.org/pep-0585/

   (3) https://peps.python.org/pep-0585/

   (4) https://peps.python.org/pep-0585/

   (5) https://peps.python.org/pep-0585/


File: python.info,  Node: Aliases to other concrete types,  Next: Aliases to container ABCs in collections abc,  Prev: Aliases to types in collections,  Up: 非推奨のエイリアス

5.26.1.26 Aliases to other concrete types
.........................................

 -- クラス: typing.Pattern
 -- クラス: typing.Match

     Deprecated aliases corresponding to the return types from *note
     re.compile(): ba1. and *note re.match(): 11fe.

     These types (and the corresponding functions) are generic over
     *note AnyStr: 292.  ‘Pattern’ can be specialised as ‘Pattern[str]’
     or ‘Pattern[bytes]’; ‘Match’ can be specialised as ‘Match[str]’ or
     ‘Match[bytes]’.

     バージョン 3.9 で非推奨: Classes ‘Pattern’ and ‘Match’ from *note
     re: a7. now support ‘[]’.  See PEP 585(1) and *note
     ジェネリックエイリアス型: 67e.

 -- クラス: typing.Text

     Deprecated alias for *note str: 418.

     ‘Text’ is provided to supply a forward compatible path for Python 2
     code: in Python 2, ‘Text’ is an alias for ‘unicode’.

     ‘Text’ は Python 2 と Python 3 の両方と互換性のある方法で値が
     unicode 文字列を含んでいなければならない場合に使用してください。

          def add_unicode_checkmark(text: Text) -> Text:
              return text + u' \u2713'

     Added in version 3.5.2.

     バージョン 3.11 で非推奨: Python 2 is no longer supported, and most
     type checkers also no longer support type checking Python 2 code.
     Removal of the alias is not currently planned, but users are
     encouraged to use *note str: 418. instead of ‘Text’.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/


File: python.info,  Node: Aliases to container ABCs in collections abc,  Next: Aliases to asynchronous ABCs in collections abc,  Prev: Aliases to other concrete types,  Up: 非推奨のエイリアス

5.26.1.27 Aliases to container ABCs in ‘collections.abc’
........................................................

 -- クラス: typing.AbstractSet (Collection[T_co])

     *note collections.abc.Set: 21a3. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.Set: 21a3. は添字表
     記 (‘[]’) をサポートするようになりました。 PEP 585(1) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.ByteString (Sequence[int])

     この型は *note bytes: 1a4. と *note bytearray: 508. 、バイト列の
     *note memoryview: 435. を表します。

     Deprecated since version 3.9, will be removed in version 3.14:
     Prefer *note collections.abc.Buffer: 2a4, or a union like ‘bytes |
     bytearray | memoryview’.

 -- クラス: typing.Collection (Sized, Iterable[T_co], Container[T_co])

     *note collections.abc.Collection: c56. の非推奨なエイリアス。

     Added in version 3.6.

     バージョン 3.9 で非推奨: *note collections.abc.Collection: c56. は
     添字表記 (‘[]’) をサポートするようになりました。 PEP 585(2) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Container (Generic[T_co])

     *note collections.abc.Container: 21ad. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.Container: 21ad. は
     添字表記 (‘[]’) をサポートするようになりました。 PEP 585(3) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.ItemsView (MappingView, AbstractSet[tuple[KT_co,
          VT_co]])

     *note collections.abc.ItemsView: 21b1. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.ItemsView: 21b1. は
     添字表記 (‘[]’) をサポートするようになりました。 PEP 585(4) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.KeysView (MappingView, AbstractSet[KT_co])

     *note collections.abc.KeysView: 21b0. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.KeysView: 21b0. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(5) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Mapping (Collection[KT], Generic[KT, VT_co])

     *note collections.abc.Mapping: 898. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.Mapping: 898. は添字
     表記 (‘[]’) をサポートするようになりました。 PEP 585(6) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.MappingView (Sized)

     *note collections.abc.MappingView: 21af. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.MappingView: 21af. は
     添字表記 (‘[]’) をサポートするようになりました。 PEP 585(7) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.MutableMapping (Mapping[KT, VT])

     *note collections.abc.MutableMapping: 107e. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.MutableMapping:
     107e. は添字表記 (‘[]’) をサポートするようになりました。 PEP 585(8)
     と *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.MutableSequence (Sequence[T])

     *note collections.abc.MutableSequence: 186. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.MutableSequence:
     186. は添字表記 (‘[]’) をサポートするようになりました。 PEP 585(9)
     と *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.MutableSet (AbstractSet[T])

     *note collections.abc.MutableSet: 21ae. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.MutableSet: 21ae. は
     添字表記 (‘[]’) をサポートするようになりました。 PEP 585(10) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Sequence (Reversible[T_co], Collection[T_co])

     *note collections.abc.Sequence: 1194. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.Sequence: 1194. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(11) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.ValuesView (MappingView, Collection[_VT_co])

     *note collections.abc.ValuesView: 21b2. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.ValuesView: 21b2. は
     添字表記 (‘[]’) をサポートするようになりました。 PEP 585(12) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://peps.python.org/pep-0585/

   (3) https://peps.python.org/pep-0585/

   (4) https://peps.python.org/pep-0585/

   (5) https://peps.python.org/pep-0585/

   (6) https://peps.python.org/pep-0585/

   (7) https://peps.python.org/pep-0585/

   (8) https://peps.python.org/pep-0585/

   (9) https://peps.python.org/pep-0585/

   (10) https://peps.python.org/pep-0585/

   (11) https://peps.python.org/pep-0585/

   (12) https://peps.python.org/pep-0585/


File: python.info,  Node: Aliases to asynchronous ABCs in collections abc,  Next: Aliases to other ABCs in collections abc,  Prev: Aliases to container ABCs in collections abc,  Up: 非推奨のエイリアス

5.26.1.28 Aliases to asynchronous ABCs in ‘collections.abc’
...........................................................

 -- クラス: typing.Coroutine (Awaitable[ReturnType], Generic[YieldType,
          SendType, ReturnType])

     *note collections.abc.Coroutine: daa. の非推奨なエイリアス。

     See *note Annotating generators and coroutines: 2481. for details
     on using *note collections.abc.Coroutine: daa. and
     ‘typing.Coroutine’ in type annotations.

     Added in version 3.5.3.

     バージョン 3.9 で非推奨: *note collections.abc.Coroutine: daa. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(1) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.AsyncGenerator (AsyncIterator[YieldType],
          Generic[YieldType, SendType])

     *note collections.abc.AsyncGenerator: c58. の非推奨なエイリアス。

     See *note Annotating generators and coroutines: 2481. for details
     on using *note collections.abc.AsyncGenerator: c58. and
     ‘typing.AsyncGenerator’ in type annotations.

     Added in version 3.6.1.

     バージョン 3.9 で非推奨: *note collections.abc.AsyncGenerator: c58.
     は添字表記 (‘[]’) をサポートするようになりました。 PEP 585(2) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

     バージョン 3.13 で変更: The ‘SendType’ parameter now has a default.

 -- クラス: typing.AsyncIterable (Generic[T_co])

     *note collections.abc.AsyncIterable: dac. の非推奨なエイリアス。

     Added in version 3.5.2.

     バージョン 3.9 で非推奨: *note collections.abc.AsyncIterable: dac.
     は添字表記 (‘[]’) をサポートするようになりました。 PEP 585(3) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.AsyncIterator (AsyncIterable[T_co])

     *note collections.abc.AsyncIterator: dab. の非推奨なエイリアス。

     Added in version 3.5.2.

     バージョン 3.9 で非推奨: *note collections.abc.AsyncIterator: dab.
     は添字表記 (‘[]’) をサポートするようになりました。 PEP 585(4) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Awaitable (Generic[T_co])

     *note collections.abc.Awaitable: da9. の非推奨なエイリアス。

     Added in version 3.5.2.

     バージョン 3.9 で非推奨: *note collections.abc.Awaitable: da9. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(5) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://peps.python.org/pep-0585/

   (3) https://peps.python.org/pep-0585/

   (4) https://peps.python.org/pep-0585/

   (5) https://peps.python.org/pep-0585/


File: python.info,  Node: Aliases to other ABCs in collections abc,  Next: Aliases to contextlib ABCs,  Prev: Aliases to asynchronous ABCs in collections abc,  Up: 非推奨のエイリアス

5.26.1.29 Aliases to other ABCs in ‘collections.abc’
....................................................

 -- クラス: typing.Iterable (Generic[T_co])

     *note collections.abc.Iterable: 21ab. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.Iterable: 21ab. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(1) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Iterator (Iterable[T_co])

     *note collections.abc.Iterator: 21ac. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.Iterator: 21ac. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(2) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

 -- データ: typing.Callable

     *note collections.abc.Callable: 7b5. の非推奨なエイリアス。

     See *note 呼び出し可能オブジェクトのアノテーション: 2480. for
     details on how to use *note collections.abc.Callable: 7b5. and
     ‘typing.Callable’ in type annotations.

     バージョン 3.9 で非推奨: *note collections.abc.Callable: 7b5. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(3) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

     バージョン 3.10 で変更: ‘Callable’ は *note ParamSpec: 144. と
     *note Concatenate: 78f. をサポートしました。詳細は PEP 612(4) を参
     照してください。

 -- クラス: typing.Generator (Iterator[YieldType], Generic[YieldType,
          SendType, ReturnType])

     *note collections.abc.Generator: da8. の非推奨なエイリアス。

     See *note Annotating generators and coroutines: 2481. for details
     on using *note collections.abc.Generator: da8. and
     ‘typing.Generator’ in type annotations.

     バージョン 3.9 で非推奨: *note collections.abc.Generator: da8. は添
     字表記 (‘[]’) をサポートするようになりました。 PEP 585(5) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

     バージョン 3.13 で変更: Default values for the send and return
     types were added.

 -- クラス: typing.Hashable

     *note collections.abc.Hashable: 4c2. の非推奨なエイリアス。

     バージョン 3.12 で非推奨: 代わりに *note collections.abc.Hashable:
     4c2. を直接使用してください。

 -- クラス: typing.Reversible (Iterable[T_co])

     *note collections.abc.Reversible: c57. の非推奨なエイリアス。

     バージョン 3.9 で非推奨: *note collections.abc.Reversible: c57. は
     添字表記 (‘[]’) をサポートするようになりました。 PEP 585(6) と
     *note ジェネリックエイリアス型: 67e. を参照してください。

 -- クラス: typing.Sized

     *note collections.abc.Sized: 4c3. の非推奨なエイリアス。

     バージョン 3.12 で非推奨: 代わりに *note collections.abc.Sized:
     4c3. を直接使用してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://peps.python.org/pep-0585/

   (3) https://peps.python.org/pep-0585/

   (4) https://peps.python.org/pep-0612/

   (5) https://peps.python.org/pep-0585/

   (6) https://peps.python.org/pep-0585/


File: python.info,  Node: Aliases to contextlib ABCs,  Prev: Aliases to other ABCs in collections abc,  Up: 非推奨のエイリアス

5.26.1.30 Aliases to ‘contextlib’ ABCs
......................................

 -- クラス: typing.ContextManager (Generic[T_co, ExitT_co])

     *note contextlib.AbstractContextManager: c5b. の非推奨なエイリアス
     。

     The first type parameter, ‘T_co’, represents the type returned by
     the *note __enter__(): 592. method.  The optional second type
     parameter, ‘ExitT_co’, which defaults to ‘bool | None’, represents
     the type returned by the *note __exit__(): 12ce. method.

     Added in version 3.5.4.

     バージョン 3.9 で非推奨: *note contextlib.AbstractContextManager:
     c5b. は添字表記 (‘[]’) をサポートするようになりました。 PEP 585(1)
     と *note ジェネリックエイリアス型: 67e. を参照してください。

     バージョン 3.13 で変更: Added the optional second type parameter,
     ‘ExitT_co’.

 -- クラス: typing.AsyncContextManager (Generic[T_co, AExitT_co])

     *note contextlib.AbstractAsyncContextManager: af9. の非推奨なエイリ
     アス。

     The first type parameter, ‘T_co’, represents the type returned by
     the *note __aenter__(): 1f30. method.  The optional second type
     parameter, ‘AExitT_co’, which defaults to ‘bool | None’, represents
     the type returned by the *note __aexit__(): 158e. method.

     Added in version 3.6.2.

     バージョン 3.9 で非推奨: *note
     contextlib.AbstractAsyncContextManager: af9. は添字表記 (‘[]’) をサ
     ポートするようになりました。 PEP 585(2) と *note
     ジェネリックエイリアス型: 67e. を参照してください。

     バージョン 3.13 で変更: Added the optional second type parameter,
     ‘AExitT_co’.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://peps.python.org/pep-0585/


File: python.info,  Node: メジャーな機能の非推奨時系列,  Prev: モジュールの内容<3>,  Up: typing --- 型ヒントのサポート

5.26.1.31 メジャーな機能の非推奨時系列
......................................

‘typing’ の機能の中には非推奨のものがあり、Python の将来のバージョンで削
除される可能性があります。以下の表は主な非推奨機能をまとめたものです。こ
れは変更される可能性があり、すべての非推奨機能がリストされているわけでは
ありません。

機能                          非推奨となるバージョン        削除予定のバージョン          PEP/issue
                                                                                          
------------------------------------------------------------------------------------------------------------------------
                                                                                          
標準コレクションのエイリア    3.9                           未定（                        PEP 585(1)
ス                                                          *note 非推奨のエイリアス: 3e39.
                                                            を参照）
                                                            
                                                                                          
*note typing.ByteString: 2b5. 3.9                           3.14                          gh-91896(2)
                                                                                          
                                                                                          
*note typing.Text: 2e3.       3.11                          未定                          gh-92332(3)
                                                                                          
                                                                                          
*note typing.Hashable: 4c0.、 3.12                          未定                          gh-94309(4)
*note typing.Sized: 4c1.                                                                  

*note typing.TypeAlias: 794.  3.12                          未定                          PEP 695(5)
                                                                                          
                                                                                          
*note @typing.no_type_check_decorator: 291.3.13             3.15                          gh-106309(6)
                                                                                          
                                                                                          
*note typing.AnyStr: 292.     3.13                          3.18                          gh-105578(7)
                                                                                          

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0585/

   (2) https://github.com/python/cpython/issues/91896

   (3) https://github.com/python/cpython/issues/92332

   (4) https://github.com/python/cpython/issues/94309

   (5) https://peps.python.org/pep-0695/

   (6) https://github.com/python/cpython/issues/106309

   (7) https://github.com/python/cpython/issues/105578


File: python.info,  Node: pydoc --- ドキュメント生成とオンラインヘルプシステム,  Next: Python 開発モード,  Prev: typing --- 型ヒントのサポート,  Up: 開発ツール

5.26.2 ‘pydoc’ -- ドキュメント生成とオンラインヘルプシステム
------------------------------------------------------------

'ソースコード:' Lib/pydoc.py(1)

__________________________________________________________________

The ‘pydoc’ module automatically generates documentation from Python
modules.  The documentation can be presented as pages of text on the
console, served to a web browser, or saved to HTML files.

For modules, classes, functions and methods, the displayed documentation
is derived from the docstring (i.e.  the *note __doc__: 8f6. attribute)
of the object, and recursively of its documentable members.  If there is
no docstring, ‘pydoc’ tries to obtain a description from the block of
comment lines just above the definition of the class, function or method
in the source file, or at the top of the module (see *note
inspect.getcomments(): 1529.).

The built-in function *note help(): 8a5. invokes the online help system
in the interactive interpreter, which uses ‘pydoc’ to generate its
documentation as text on the console.  The same text documentation can
also be viewed from outside the Python interpreter by running ‘pydoc’ as
a script at the operating system's command prompt.  For example, running

     python -m pydoc sys

シェルから行うと *note sys: c3. モジュールのドキュメントを、Unix の
‘man’ コマンドのような形式で表示させることができます。 ‘pydoc’ の引数と
して与えることができるのは、関数名・モジュール名・パッケージ名、また、モ
ジュールやパッケージ内のモジュールに含まれるクラス・メソッド・関数へのド
ット形式での参照です。 ‘pydoc’ への引数がパスと解釈されるような場合で(オ
ペレーティングシステムのパス区切り記号を含む場合です。例えばUnixならばス
ラッシュ含む場合になります)、さらに、そのパスがPythonのソースファイルを
指しているなら、そのファイルに対するドキュメントが生成されます。

     注釈: In order to find objects and their documentation, ‘pydoc’
     imports the module(s) to be documented.  Therefore, any code on
     module level will be executed on that occasion.  Use an ‘if
     __name__ == '__main__':’ guard to only execute code when a file is
     invoked as a script and not just imported.

When printing output to the console, ‘pydoc’ attempts to paginate the
output for easier reading.  If either the ‘MANPAGER’ or the ‘PAGER’
environment variable is set, ‘pydoc’ will use its value as a pagination
program.  When both are set, ‘MANPAGER’ is used.

引数の前に ‘-w’ フラグを指定すると、コンソールにテキストを表示させるかわ
りにカレントディレクトリにHTMLドキュメントを生成します。

引数の前に ‘-k’ フラグを指定すると、引数をキーワードとして利用可能な全て
のモジュールの概要を検索します。検索のやりかたは、Unixの ‘man’ コマンド
と同様です。モジュールの概要というのは、モジュールのドキュメントの一行目
のことです。

また、 ‘pydoc’ を使うことでローカルマシンにウェブブラウザから閲覧可能な
ドキュメントを提供するHTTPサーバーを起動することもできます。 ‘python -m
pydoc -p 1234’ とすると、HTTPサーバーをポート1234に起動します。これで、
お好きなウェブブラウザを使って ‘http://localhost:1234/’ からドキュメント
を見ることができます。ポート番号に ‘0’ を指定すると、任意の空きポートが
選択されます。

‘python -m pydoc -n <hostname>’ は、与えられたホスト名で listen するサー
バーを起動します。 デフォルトではホスト名は 'localhost' ですが、他のマシ
ンからサーバーへ疎通できるようにしたい場合は、サーバーが応答するホスト名
を変更したいと思うでしょう。 開発作業中に、コンテナ内で pydoc を走らせた
い場合は、これは特に便利です。

‘python -m pydoc -b’ では、サーバとして起動するとともにブラウザも起動し
、モジュールインデクスページを開きます。提供されるページには、個別のヘル
プページに飛ぶための 'Get' ボタン、全モジュールから概要行に基くキーワー
ド検索するための 'Search' ボタン、と、'Module index', 'Topics' ,
'Keywords' へのそれぞれリンクがついたナビゲーションバーがページの一番上
に付きます。

‘pydoc’ でドキュメントを生成する場合、その時点での環境とパス情報に基づい
てモジュールがどこにあるのか決定されます。そのため、 ‘pydoc spam’ を実行
した場合につくられるドキュメントは、 Pythonインタプリタを起動して
‘import spam’ と入力したときに読み込まれるモジュールに対するドキュメント
になります。

Module docs for core modules are assumed to reside in
‘https://docs.python.org/X.Y/library/’ where ‘X’ and ‘Y’ are the major
and minor version numbers of the Python interpreter.  This can be
overridden by setting the ‘PYTHONDOCS’ environment variable to a
different URL or to a local directory containing the Library Reference
Manual pages.

バージョン 3.2 で変更: ‘-b’ オプションが追加されました。

バージョン 3.3 で変更: ‘-g’ コマンドラインオプションが削除されました。

バージョン 3.4 で変更: ‘pydoc’ now uses *note inspect.signature(): 703.
rather than *note inspect.getfullargspec(): 704. to extract signature
information from callables.

バージョン 3.7 で変更: ‘-n’ オプションが追加されました。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pydoc.py


File: python.info,  Node: Python 開発モード,  Next: doctest --- 対話型の Python の例をテストする,  Prev: pydoc --- ドキュメント生成とオンラインヘルプシステム,  Up: 開発ツール

5.26.3 Python 開発モード
------------------------

Added in version 3.7.

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.

It can be enabled using the *note -X dev: 15c. command line option or by
setting the *note PYTHONDEVMODE: abb. environment variable to ‘1’.

See also *note Python debug build: 1da.

* Menu:

* Effects of the Python Development Mode::
* ResourceWarning Example::
* Bad file descriptor error example::


File: python.info,  Node: Effects of the Python Development Mode,  Next: ResourceWarning Example,  Up: Python 開発モード

5.26.3.1 Effects of the Python Development Mode
...............................................

Enabling the Python Development Mode is similar to the following
command, but with additional effects described below:

     PYTHONMALLOC=debug PYTHONASYNCIODEBUG=1 python -W default -X faulthandler

Effects of the Python Development Mode:

   * Add ‘default’ *note warning filter: 1ca3.  The following warnings
     are shown:

        * *note DeprecationWarning: 18a.

        * *note ImportWarning: 4c7.

        * *note PendingDeprecationWarning: 895.

        * *note ResourceWarning: 225.

     Normally, the above warnings are filtered by the default *note
     warning filters: 1ca3.

     It behaves as if the *note -W default: 896. command line option is
     used.

     Use the *note -W error: 896. command line option or set the *note
     PYTHONWARNINGS: b78. environment variable to ‘error’ to treat
     warnings as errors.

   * Install debug hooks on memory allocators to check for:

        * Buffer underflow

        * Buffer overflow

        * Memory allocator API violation

        * Unsafe usage of the GIL

     See the *note PyMem_SetupDebugHooks(): c38. C function.

     It behaves as if the *note PYTHONMALLOC: c32. environment variable
     is set to ‘debug’.

     To enable the Python Development Mode without installing debug
     hooks on memory allocators, set the *note PYTHONMALLOC: c32.
     environment variable to ‘default’.

   * Call *note faulthandler.enable(): c6c. at Python startup to install
     handlers for the *note SIGSEGV: 1cb3, *note SIGFPE: 1cb4, *note
     SIGABRT: 1cb5, *note SIGBUS: 1cb6. and *note SIGILL: 1cb7. signals
     to dump the Python traceback on a crash.

     It behaves as if the *note -X faulthandler: 15c. command line
     option is used or if the *note PYTHONFAULTHANDLER: 1055.
     environment variable is set to ‘1’.

   * Enable *note asyncio debug mode: 1cb9.  For example, *note asyncio:
     8. checks for coroutines that were not awaited and logs them.

     It behaves as if the *note PYTHONASYNCIODEBUG: 1cb8. environment
     variable is set to ‘1’.

   * Check the 'encoding' and 'errors' arguments for string encoding and
     decoding operations.  Examples: *note open(): 4e5, *note
     str.encode(): 8a3. and *note bytes.decode(): 8a4.

     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.

   * The *note io.IOBase: 1d6. destructor logs ‘close()’ exceptions.

   * Set the *note dev_mode: 1a0c. attribute of *note sys.flags: 658. to
     ‘True’.

The Python Development Mode does not enable the *note tracemalloc: e8.
module by default, because the overhead cost (to performance and memory)
would be too large.  Enabling the *note tracemalloc: e8. module provides
additional information on the origin of some errors.  For example, *note
ResourceWarning: 225. logs the traceback where the resource was
allocated, and a buffer overflow error logs the traceback where the
memory block was allocated.

The Python Development Mode does not prevent the *note -O: d82. command
line option from removing *note assert: 936. statements nor from setting
*note __debug__: 7a5. to ‘False’.

The Python Development Mode can only be enabled at the Python startup.
Its value can be read from *note sys.flags.dev_mode: 658.

バージョン 3.8 で変更: The *note io.IOBase: 1d6. destructor now logs
‘close()’ exceptions.

バージョン 3.9 で変更: The 'encoding' and 'errors' arguments are now
checked for string encoding and decoding operations.


File: python.info,  Node: ResourceWarning Example,  Next: Bad file descriptor error example,  Prev: Effects of the Python Development Mode,  Up: Python 開発モード

5.26.3.2 ResourceWarning Example
................................

Example of a script counting the number of lines of the text file
specified in the command line:

     import sys

     def main():
         fp = open(sys.argv[1])
         nlines = len(fp.readlines())
         print(nlines)
         # The file is closed implicitly

     if __name__ == "__main__":
         main()

The script does not close the file explicitly.  By default, Python does
not emit any warning.  Example using README.txt, which has 269 lines:

     $ python script.py README.txt
     269

Enabling the Python Development Mode displays a *note ResourceWarning:
225. warning:

     $ python -X dev script.py README.txt
     269
     script.py:10: ResourceWarning: unclosed file <_io.TextIOWrapper name='README.rst' mode='r' encoding='UTF-8'>
       main()
     ResourceWarning: Enable tracemalloc to get the object allocation traceback

In addition, enabling *note tracemalloc: e8. shows the line where the
file was opened:

     $ python -X dev -X tracemalloc=5 script.py README.rst
     269
     script.py:10: ResourceWarning: unclosed file <_io.TextIOWrapper name='README.rst' mode='r' encoding='UTF-8'>
       main()
     Object allocated at (most recent call last):
       File "script.py", lineno 10
         main()
       File "script.py", lineno 4
         fp = open(sys.argv[1])

The fix is to close explicitly the file.  Example using a context
manager:

     def main():
         # Close the file explicitly when exiting the with block
         with open(sys.argv[1]) as fp:
             nlines = len(fp.readlines())
         print(nlines)

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.


File: python.info,  Node: Bad file descriptor error example,  Prev: ResourceWarning Example,  Up: Python 開発モード

5.26.3.3 Bad file descriptor error example
..........................................

Script displaying the first line of itself:

     import os

     def main():
         fp = open(__file__)
         firstline = fp.readline()
         print(firstline.rstrip())
         os.close(fp.fileno())
         # The file is closed implicitly

     main()

By default, Python does not emit any warning:

     $ python script.py
     import os

The Python Development Mode shows a *note ResourceWarning: 225. and logs
a "Bad file descriptor" error when finalizing the file object:

     $ python -X dev script.py
     import os
     script.py:10: ResourceWarning: unclosed file <_io.TextIOWrapper name='script.py' mode='r' encoding='UTF-8'>
       main()
     ResourceWarning: Enable tracemalloc to get the object allocation traceback
     Exception ignored in: <_io.TextIOWrapper name='script.py' mode='r' encoding='UTF-8'>
     Traceback (most recent call last):
       File "script.py", line 10, in <module>
         main()
     OSError: [Errno 9] Bad file descriptor

‘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 file descriptor’ error.  A file descriptor must be closed only
once.  In the worst case scenario, closing it twice can lead to a crash
(see bpo-18748(1) for an example).

The fix is to remove the ‘os.close(fp.fileno())’ line, or open the file
with ‘closefd=False’.

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=18748


File: python.info,  Node: doctest --- 対話型の Python の例をテストする,  Next: unittest --- ユニットテストフレームワーク,  Prev: Python 開発モード,  Up: 開発ツール

5.26.4 ‘doctest’ -- 対話型の Python の例をテストする
----------------------------------------------------

'ソースコード:' Lib/doctest.py(1)

__________________________________________________________________

*note doctest: 31. モジュールは、対話的 Python セッションのように見える
テキストを探し出し、セッションの内容を実行して、そこに書かれている通りに
振舞うかを調べます。 *note doctest: 31. は以下のような用途によく使われて
います:

   * モジュールの docstring (ドキュメンテーション文字列) 中にある対話実
     行例のすべてが書かれている通りに動作するか検証することで、docstring
     の内容が最新かどうかチェックする。

   * テストファイルやテストオブジェクト中の対話実行例が期待通りに動作す
     るかを検証することで、回帰テストを実現します。

   * 入出力例を豊富に使ったパッケージのチュートリアルドキュメントが書け
     ます。入出力例と解説文のどちらに注目するかによって、ドキュメントは
     「読めるテスト」にも「実行できるドキュメント」にもなります。

以下に完全かつ短い実行例を示します:

     """
     This is the "example" module.

     The example module supplies one function, factorial().  For example,

     >>> factorial(5)
     120
     """

     def factorial(n):
         """Return the factorial of n, an exact integer >= 0.

         >>> [factorial(n) for n in range(6)]
         [1, 1, 2, 6, 24, 120]
         >>> factorial(30)
         265252859812191058636308480000000
         >>> factorial(-1)
         Traceback (most recent call last):
             ...
         ValueError: n must be >= 0

         Factorials of floats are OK, but the float must be an exact integer:
         >>> factorial(30.1)
         Traceback (most recent call last):
             ...
         ValueError: n must be exact integer
         >>> factorial(30.0)
         265252859812191058636308480000000

         It must also not be ridiculously large:
         >>> factorial(1e100)
         Traceback (most recent call last):
             ...
         OverflowError: n too large
         """

         import math
         if not n >= 0:
             raise ValueError("n must be >= 0")
         if math.floor(n) != n:
             raise ValueError("n must be exact integer")
         if n+1 == n:  # catch a value like 1e300
             raise OverflowError("n too large")
         result = 1
         factor = 2
         while factor <= n:
             result *= factor
             factor += 1
         return result


     if __name__ == "__main__":
         import doctest
         doctest.testmod()

‘example.py’ をコマンドラインから直接実行すると、 *note doctest: 31. は
その魔法を働かせます:

     $ python example.py
     $

出力は何もありません！しかしこれが正常で、すべての実行例が正しく動作する
ことを意味しています。スクリプトに ‘-v’ を与えると、 *note doctest: 31.
は何を行おうとしているのかを記録した詳細なログを出力し、最後にまとめを出
力します:

     $ python example.py -v
     Trying:
         factorial(5)
     Expecting:
         120
     ok
     Trying:
         [factorial(n) for n in range(6)]
     Expecting:
         [1, 1, 2, 6, 24, 120]
     ok

といった具合で、最後には:

     Trying:
         factorial(1e100)
     Expecting:
         Traceback (most recent call last):
             ...
         OverflowError: n too large
     ok
     2 items passed all tests:
        1 test in __main__
        6 tests in __main__.factorial
     7 tests in 2 items.
     7 passed.
     Test passed.
     $

That's all you need to know to start making productive use of *note
doctest: 31.!  Jump in.  The following sections provide full details.
Note that there are many examples of doctests in the standard Python
test suite and libraries.  Especially useful examples can be found in
the standard test file ‘Lib/test/test_doctest/test_doctest.py’.

* Menu:

* 簡単な利用法; docstring 中の実行例をチェックする: 簡単な利用法 docstring 中の実行例をチェックする.
* 簡単な利用法; テキストファイル中の実行例をチェックする: 簡単な利用法 テキストファイル中の実行例をチェックする.
* doctest のからくり::
* 基本 API::
* 単体テスト API::
* 拡張 API::
* デバッグ::
* アドバイス::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/doctest.py


File: python.info,  Node: 簡単な利用法 docstring 中の実行例をチェックする,  Next: 簡単な利用法 テキストファイル中の実行例をチェックする,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.1 簡単な利用法: docstring 中の実行例をチェックする
.........................................................

The simplest way to start using doctest (but not necessarily the way
you'll continue to do it) is to end each module ‘M’ with:

     if __name__ == "__main__":
         import doctest
         doctest.testmod()

‘doctest’ then examines docstrings in module ‘M’.

モジュールをスクリプトとして実行すると、docstring 中の実行例が実行され、
検証されます:

     python M.py

docstring に書かれた実行例の実行が失敗しない限り、何も表示されません。失
敗すると、失敗した実行例と、その原因が (場合によっては複数) 標準出力に印
字され、最後に ‘***Test Failed*** N failures.’ という行を出力します。こ
こで、'N' は失敗した実行例の数です。

一方、‘-v’ スイッチをつけて走らせると:

     python M.py -v

実行を試みたすべての実行例について詳細に報告し、最後に各種まとめを行った
内容が標準出力に印字されます。

‘verbose=True’ を *note testmod(): 1412. に渡せば、詳細報告 (verbose) モ
ードを強制できます。また、 ‘verbose=False’ にすれば禁止できます。どちら
の場合にも、 *note testmod(): 1412. は ‘sys.argv’ 上のスイッチを調べませ
ん。(したがって、 ‘-v’ をつけても効果はありません)。

*note testmod(): 1412. を実行するコマンドラインショートカットもあります
。 Python インタプリタに doctest モジュールを標準ライブラリから直接実行
して、テストするモジュール名をコマンドライン引数に与えます:

     python -m doctest -v example.py

こうすると ‘example.py’ を単体モジュールとしてインポートして、それに対し
て *note testmod(): 1412. を実行します。このファイルがパッケージの一部で
他のサブモジュールをそのパッケージからインポートしている場合はうまく動か
ないことに注意してください。

*note testmod(): 1412. の詳しい情報は *note 基本 API: 3e72. 節を参照して
ください。


File: python.info,  Node: 簡単な利用法 テキストファイル中の実行例をチェックする,  Next: doctest のからくり,  Prev: 簡単な利用法 docstring 中の実行例をチェックする,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.2 簡単な利用法: テキストファイル中の実行例をチェックする
...............................................................

doctest のもう一つの簡単な用途は、テキストファイル中にある対話実行例に対
するテストです。これには *note testfile(): 3e75. 関数を使います:

     import doctest
     doctest.testfile("example.txt")

この短いスクリプトは、 ‘example.txt’ というファイルの中に入っている対話
モードの Python 操作例すべてを実行して、その内容を検証します。ファイルの
内容は一つの巨大な docstring であるかのように扱われます; ファイルが
Python プログラムである必要はありません！例えば、 ‘example.txt’ には以下
のような内容が入っているとします:

     The ``example`` module
     ======================

     Using ``factorial``
     -------------------

     This is an example text file in reStructuredText format.  First import
     ``factorial`` from the ``example`` module:

         >>> from example import factorial

     Now use it:

         >>> factorial(6)
         120

‘doctest.testfile("example.txt")’ を実行すると、このドキュメント内のエラ
ーを見つけ出します:

     File "./example.txt", line 14, in example.txt
     Failed example:
         factorial(6)
     Expected:
         120
     Got:
         720

*note testmod(): 1412. と同じく、 *note testfile(): 3e75. は実行例が失敗
しない限り何も表示しません。実行例が失敗すると、失敗した実行例とその原因
が (場合によっては複数) *note testmod(): 1412. と同じ書式で標準出力に書
き出されます。

デフォルトでは、 *note testfile(): 3e75. は自分自身を呼び出したモジュー
ルのあるディレクトリを探します。その他の場所にあるファイルを見に行くよう
に *note testfile(): 3e75. に指示するためのオプション引数についての説明
は *note 基本 API: 3e72. 節を参照してください。

*note testmod(): 1412. と同様に *note testfile(): 3e75. の冗長性
(verbosity) はコマンドラインスイッチ ‘-v’ またはオプションのキーワード引
数 'verbose' によって指定できます。

*note testfile(): 3e75. を実行するコマンドラインショートカットもあります
。 Python インタプリタに doctest モジュールを標準ライブラリから直接実行
して、テストするモジュール名をコマンドライン引数に与えます:

     python -m doctest -v example.txt

ファイル名が ‘.py’ で終っていないので、 *note doctest: 31. は *note
testmod(): 1412. ではなく *note testfile(): 3e75. を使って実行するのだと
判断します。

*note testfile(): 3e75. の詳細は *note 基本 API: 3e72. 節を参照してくだ
さい。


File: python.info,  Node: doctest のからくり,  Next: 基本 API,  Prev: 簡単な利用法 テキストファイル中の実行例をチェックする,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.3 doctest のからくり
...........................

この節では、doctest のからくり: どの docstring を見に行くのか、どのよう
に対話実行例を見つけ出すのか、どんな実行コンテキストを使うのか、例外をど
う扱うか、上記の振る舞いを制御するためにどのようなオプションフラグを使う
か、について詳しく吟味します。こうした情報は、doctest に対応した実行例を
書くために必要な知識です; 書いた実行例に対して実際に doctest を実行する
上で必要な情報については後続の節を参照してください。

* Menu:

* どの docstring が検証されるのか?::
* docstring 内の実行例をどのように認識するのか?::
* 実行コンテキストとは何か?::
* 例外はどう扱えばよいか?::
* オプションフラグ::
* ディレクティブ (Directives): ディレクティブ Directives.
* 警告: 警告<2>.


File: python.info,  Node: どの docstring が検証されるのか?,  Next: docstring 内の実行例をどのように認識するのか?,  Up: doctest のからくり

5.26.4.4 どの docstring が検証されるのか?
.........................................

モジュールの docstring と、すべての関数、クラスおよびメソッドの
docstring が検索されます。モジュールに import されたオブジェクトは検索さ
れません。

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 the docstring.  Doctest looks for a module-level variable
called ‘__test__’ and uses it to locate other tests.  If ‘M.__test__’
exists, it must be a dict, and each entry maps a (string) name to a
function object, class object, or string.  Function and class object
docstrings found from ‘M.__test__’ are searched, and strings are treated
as if they were docstrings.  In output, a key ‘K’ in ‘M.__test__’
appears with name ‘M.__test__.K’.

For example, place this block of code at the top of ‘example.py’:

     __test__ = {
         'numbers': """
     >>> factorial(6)
     720

     >>> [factorial(n) for n in range(6)]
     [1, 1, 2, 6, 24, 120]
     """
     }

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 that the value can be mapped to a function, class object, or
module; if so, ‘doctest’ searches them recursively for docstrings, which
are then scanned for tests.

検索中に見つかったクラスも同様に再帰的に検索が行われ、クラスに含まれてい
るメソッドおよびネストされたクラスについて docstring のテストが行われま
す。


File: python.info,  Node: docstring 内の実行例をどのように認識するのか?,  Next: 実行コンテキストとは何か?,  Prev: どの docstring が検証されるのか?,  Up: doctest のからくり

5.26.4.5 docstring 内の実行例をどのように認識するのか?
......................................................

ほとんどの場合、対話コンソールセッション上でのコピー／ペーストはうまく動
作します。とはいえ、*note doctest: 31. は特定の Python シェルの振る舞い
を正確にエミュレーションしようとするわけではありません。

     >>> # comments are ignored
     >>> x = 12
     >>> x
     12
     >>> if x == 13:
     ...     print("yes")
     ... else:
     ...     print("no")
     ...     print("NO")
     ...     print("NO!!!")
     ...
     no
     NO
     NO!!!
     >>>

コードを含む最後の ‘'>>> '’ または ‘'... '’ 行の直下に期待する出力結果が
置かれます。(出力結果がもしあれば) それは次の ‘'>>> '’ 行か、すべて空白
文字の行まで続きます。

詳細事項:

   * 期待する出力結果には、空白だけの行が入っていてはなりません。そのよ
     うな行は期待する出力結果の終了を表すと見なされるからです。もし期待
     する出力結果の内容に空白行が入っている場合には、空白行が入るべき場
     所すべてに ‘<BLANKLINE>’ を入れてください。

   * 全てのタブ文字は 8 カラムのタブ位置でスペースに展開されます。テスト
     対象のコードが作成した出力にあるタブは変更されません。出力例にある
     どんなタブも展開 'される' ので、コードの出力がハードタブを含んでい
     た場合、 doctest が通るには *note NORMALIZE_WHITESPACE: 3e7c. オプ
     ションか *note directive: 3e7d. を有効にするしかありません。そうす
     る代わりに、テストが出力を読み取りテストの一部として期待される値と
     正しく比較するように、テストを書き直すこともできます。このソース中
     のタブの扱いは試行錯誤の結果であり、タブの扱いの中で最も問題の起き
     にくいものだということが分かっています。タブの扱いについては、独自
     の *note DocTestParser: 3e7e. クラスを実装して、別のアルゴリズムを
     使うこともできます。

   * 標準出力への出力は取り込まれますが、標準エラーは取り込まれません (例
     外発生時のトレースバックは別の方法で取り込まれます)。

   * 対話セッションにおいて、バックスラッシュを用いて次の行に続ける場合
     や、その他の理由でバックスラッシュを用いる場合、raw docstring を使
     ってバックスラッシュを入力どおりに扱わせるようにしなければなりませ
     ん:

          >>> def f(x):
          ...     r'''Backslashes in a raw docstring: m\n'''
          ...
          >>> print(f.__doc__)
          Backslashes in a raw docstring: m\n

     そうしない場合は、バックスラッシュは文字列の一部として解釈されます
     。例えば、上の ‘\n’ は改行文字として解釈されてしまいます。それ以外
     の方法では、doctest にあるバックスラッシュを二重にする (そして raw
     string を使わない) という方法もあります:

          >>> def f(x):
          ...     '''Backslashes in a raw docstring: m\\n'''
          ...
          >>> print(f.__doc__)
          Backslashes in a raw docstring: m\n

   * 開始カラムはどこでもかまいません:

          >>> assert "Easy!"
                >>> import math
                    >>> math.floor(1.9)
                    1

     期待する出力結果の先頭部にある空白文字列は、実行例の開始部分にあた
     る ‘'>>> '’ 行の先頭にある空白文字列と同じだけ取り除かれます。


File: python.info,  Node: 実行コンテキストとは何か?,  Next: 例外はどう扱えばよいか?,  Prev: docstring 内の実行例をどのように認識するのか?,  Up: doctest のからくり

5.26.4.6 実行コンテキストとは何か?
..................................

By default, each time *note doctest: 31. finds a docstring to test, it
uses a 'shallow copy' of ‘M’'s globals, so that running tests doesn't
change the module's real globals, and so that one test in ‘M’ can't
leave behind crumbs that accidentally allow another test to work.  This
means examples can freely use any names defined at top-level in ‘M’, and
names defined earlier in the docstring being run.  Examples cannot see
names defined in other docstrings.

*note testmod(): 1412. や *note testfile(): 3e75. に ‘globs=your_dict’ を
渡し、自前の辞書を実行コンテキストとして使うこともできます。


File: python.info,  Node: 例外はどう扱えばよいか?,  Next: オプションフラグ,  Prev: 実行コンテキストとは何か?,  Up: doctest のからくり

5.26.4.7 例外はどう扱えばよいか?
................................

トレースバックが実行例によって生成される唯一の出力なら問題ありません。単
にトレースバックを貼り付けてください。(1) トレースバックには、頻繁に変更
されがちな情報 (例えばファイルパスや行番号など) が入っているものなので、
これは受け入れるテスト結果に柔軟性を持たせようと doctest が苦労している
部分の一つです。

簡単な例を示しましょう:

     >>> [1, 2, 3].remove(42)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ValueError: list.remove(x): x not in list

この doctest は、 *note ValueError: 1e3. が送出され、その詳細情報が
‘list.remove(x): x not in list’ である場合に成功します。

例外が発生したときの期待する出力はトレースバックヘッダから始まっていなけ
ればなりません。トレースバックの形式は以下の二通りの行のいずれかで、実行
例の最初の行と同じインデントでなければりません:

     Traceback (most recent call last):
     Traceback (innermost last):

トレースバックヘッダの後ろにトレースバックスタックが続いてもかまいません
が、doctest はその内容を無視します。普通はトレースバックスタックを省略す
るか、対話セッションからそのままコピーしてきます。

トレースバックスタックの後ろにはもっとも有意義な部分、例外の型と詳細情報
の入った行があります。これは通常トレースバックの最後の行ですが、例外が複
数行の詳細情報を持っている場合、複数の行にわたることもあります:

     >>> raise ValueError('multi\n    line\ndetail')
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     ValueError: multi
         line
     detail

上の例では、最後の 3 行 (*note ValueError: 1e3. から始まる行) における例
外の型と詳細情報だけが比較され、それ以外の部分は無視されます。

例外を扱うコツは、実行例をドキュメントとして読む上で明らかに価値のある情
報でない限り、トレースバックスタックは省略する、ということです。したがっ
て、先ほどの例は以下のように書くべきでしょう:

     >>> raise ValueError('multi\n    line\ndetail')
     Traceback (most recent call last):
         ...
     ValueError: multi
         line
     detail

トレースバックの扱いは非常に特殊なので注意してください。特に、上の書き直
した実行例では、 ‘...’ の扱いは doctest の *note ELLIPSIS: 1413. オプシ
ョンとは独立しています。この例での省略記号は何かの省略を表しているかもし
れませんし、コンマや数字が 3 個 (または 300 個) かもしれませんし、 Monty
Python のスキットをインデントして書き写したものかもしれません。

以下の詳細はずっと覚えておく必要はないのですが、一度目を通しておいてくだ
さい:

   * doctest は期待する出力の出所が print 文なのか例外なのかを推測できま
     せん。したがって、例えば期待する出力が ‘ValueError: 42 is prime’ で
     あるような実行例は、 *note ValueError: 1e3. が実際に送出された場合
     と、万が一期待する出力と同じ文字列を print した場合の両方で成功して
     しまいます。現実的には、通常の出力がトレースバックヘッダから始まる
     ことはないので、実際に問題になることはないでしょう。

   * トレースバックスタック (がある場合) の各行は、実行例の最初の行より
     も深くインデントされているか、'または' 英数文字以外で始まっていなけ
     ればなりません。トレースバックヘッダ以後に現れる行のうち、インデン
     トが等しく英数文字で始まる最初の行は例外の詳細情報が書かれた行とみ
     なされるからです。もちろん、本物のトレースバックでは正しく動作しま
     す。

   * doctest のオプション *note IGNORE_EXCEPTION_DETAIL: 12d7. を指定し
     た場合、最も左端のコロン以後の全ての内容と、例外名の中の全てのモジ
     ュール情報が無視されます。

   * 対話シェルでは、 *note SyntaxError: 172. の場合にトレースバックヘッ
     ダが省略されることがあります。しかし doctest にとっては、例外を例外
     でないものと区別するためにトレースバックヘッダが必要です。そこで、
     トレースバックヘッダを省略するような *note SyntaxError: 172. をテス
     トする必要があるというごく稀なケースでは、実行例にトレースバックヘ
     ッダを手作業で追加する必要があるでしょう。

   * For some exceptions, Python displays the position of the error
     using ‘^’ markers and tildes:

          >>> 1 + None
            File "<stdin>", line 1
              1 + None
              ~~^~~~~~
          TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

     例外の型と詳細情報の前にエラー位置を示す行がくるため、doctest はこ
     の行を調べません。例えば、以下の例では、間違った場所に ‘^’ マーカを
     入れても成功してしまいます:

          >>> 1 + None
            File "<stdin>", line 1
              1 + None
              ^~~~~~~~
          TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'

   ---------- Footnotes ----------

   (1) 期待する出力結果と例外の両方を含んだ例はサポートされていません。
一方の終わりと他方の始まりを見分けようとするのはエラーの元になりがちです
し、解りにくいテストになってしまいます。


File: python.info,  Node: オプションフラグ,  Next: ディレクティブ Directives,  Prev: 例外はどう扱えばよいか?,  Up: doctest のからくり

5.26.4.8 オプションフラグ
.........................

doctest の振る舞いは、数多くのオプションフラグによって様々な側面から制御
されています。フラグのシンボル名はモジュールの定数として提供され、 *note
ビット単位論理和: 1fcd. でつないで様々な関数に渡すことができます。シンボ
ル名は *note doctest directives: 3e7d. でも使用でき、doctest コマンドラ
インインターフェースに ‘-o’ を通して与えることができます。

Added in version 3.4: ‘-o’ コマンドラインオプション

最初に説明するオプション群は、テストのセマンティクスを決めます。すなわち
、実際にテストを実行したときの出力と実行例中の期待する出力とが一致してい
るかどうかを doctest がどのように判断するかを制御します:

 -- データ: doctest.DONT_ACCEPT_TRUE_FOR_1

     デフォルトでは、期待する出力ブロックに単に ‘1’ だけが入っており、実
     際の出力ブロックに ‘1’ または ‘True’ だけが入っていた場合、これらの
     出力は一致しているとみなされます。 ‘0’ と ‘False’ の場合も同様です
     。 *note DONT_ACCEPT_TRUE_FOR_1: 3e85. を指定すると、こうした値の読
     み替えを行いません。デフォルトの挙動で読み替えを行うのは、最近の
     Python で多くの関数の戻り値型が整数型からブール型に変更されたことに
     対応するためです; 読み替えを行う場合、"通常の整数" の出力を期待する
     出力とするような doctest も動作します。このオプションはそのうちなく
     なるでしょうが、ここ数年はそのままでしょう。

 -- データ: doctest.DONT_ACCEPT_BLANKLINE

     デフォルトでは、期待する出力ブロックに ‘<BLANKLINE>’ だけの入った行
     がある場合、その行は実際の出力における空行に一致するようになります
     。完全な空行を入れてしまうと期待する出力がそこで終わっているとみな
     されてしまうため、期待する出力に空行を入れたい場合にはこの方法を使
     わなければなりません。 *note DONT_ACCEPT_BLANKLINE: 3e86. を指定す
     ると、 ‘<BLANKLINE>’ の読み替えを行わなくなります。

 -- データ: doctest.NORMALIZE_WHITESPACE

     このフラグを指定すると、連続する空白 (空白と改行文字) は互いに等価
     であるとみなします。期待する出力における任意の空白列は実際の出力に
     おける任意の空白と一致します。デフォルトでは、空白は厳密に一致しな
     ければなりません。 *note NORMALIZE_WHITESPACE: 3e7c. は、期待する出
     力の内容が非常に長いために、ソースコード中でその内容を複数行に折り
     返して書きたい場合に特に便利です。

 -- データ: doctest.ELLIPSIS

     このフラグを指定すると、期待する出力中の省略記号マーカ (‘...’) が実
     際の出力中の任意の部分文字列と一致するようになります。部分文字列は
     行境界にわたるものや空文字列を含みます。したがって、このフラグを使
     うのは単純な内容を対象にする場合にとどめましょう。複雑な使い方をす
     ると、正規表現に ‘.*’ を使ったときのように "しまった、マッチしすぎ
     た！ (match too much!)"  と驚くことになりかねません。

 -- データ: doctest.IGNORE_EXCEPTION_DETAIL

     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.

     For example, an example expecting ‘ValueError: 42’ will pass if the
     actual exception raised is ‘ValueError: 3*14’, but will fail if,
     say, a *note TypeError: 502. is raised instead.  It will also
     ignore any fully qualified name included before the exception
     class, which can vary between implementations and versions of
     Python and the code/libraries in use.  Hence, all three of these
     variations will work with the flag specified:

          >>> raise Exception('message')
          Traceback (most recent call last):
          Exception: message

          >>> raise Exception('message')
          Traceback (most recent call last):
          builtins.Exception: message

          >>> raise Exception('message')
          Traceback (most recent call last):
          __main__.Exception: message

     Note that *note ELLIPSIS: 1413. 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.

     バージョン 3.2 で変更: *note doctest: 31. モジュールの *note
     IGNORE_EXCEPTION_DETAIL: 12d7. フラグが、 テストされている例外を含
     むモジュールの名前を無視するようになりました。

 -- データ: doctest.SKIP

     このフラグを指定すると、実行例は一切実行されません。こうした機能は
     doctest の実行例がドキュメントとテストを兼ねていて、ドキュメントの
     ためには含めておかなければならないけれどチェックされなくても良い、
     というような文脈で役に立ちます。例えば、実行例の出力がランダムであ
     るとか、テストドライバーには利用できないリソースに依存している場合
     などです。

     SKIP フラグは一時的に実行例を"コメントアウト"するのにも使えます。

 -- データ: doctest.COMPARISON_FLAGS

     上記の比較フラグすべての論理和をとったビットマスクです。

二つ目のオプション群は、テストの失敗を報告する方法を制御します:

 -- データ: doctest.REPORT_UDIFF

     このオプションを指定すると、期待する出力および実際の出力が複数行に
     なるときにテストの失敗結果を unified diff 形式を使って表示します。

 -- データ: doctest.REPORT_CDIFF

     このオプションを指定すると、期待する出力および実際の出力が複数行に
     なるときにテストの失敗結果を context diff 形式を使って表示します。

 -- データ: doctest.REPORT_NDIFF

     このオプションを指定すると、期待する出力と実際の出力との間の差分を
     ‘difflib.Differ’ を使って算出します。使われているアルゴリズムは有名
     な ‘ndiff.py’ ユーティリティと同じです。これは、行単位の差分と同じ
     ように行内の差分にマーカをつけられるようにする唯一の手段です。例え
     ば、期待する出力のある行に数字の ‘1’ が入っていて、実際の出力には
     ‘l’ が入っている場合、不一致の起きているカラム位置を示すキャレット
     の入った行が一行挿入されます。

 -- データ: doctest.REPORT_ONLY_FIRST_FAILURE

     このオプションを指定すると、各 doctest で最初にエラーの起きた実行例
     だけを表示し、それ以後の実行例の出力を抑制します。これにより、正し
     く書かれた実行例が、それ以前の実行例の失敗によっておかしくなってし
     まった場合に、 doctest がそれを報告しないようになります。とはいえ、
     最初に失敗を引き起こした実行例とは関係なく誤って書かれた実行例の報
     告も抑制してしまいます。 *note REPORT_ONLY_FIRST_FAILURE: 3e89. を
     指定した場合、実行例がどこかで失敗しても、それ以後の実行例を続けて
     実行し、失敗したテストの総数を報告します; 出力が抑制されるだけです
     。

 -- データ: doctest.FAIL_FAST

     このオプションを指定すると、最初に実行例が失敗した時点で終了し、残
     りの実行例を実行しません。つまり、報告される失敗の数はたかだか 1 つ
     になります。最初の失敗より後の例はデバッグ出力を生成しないため、こ
     のフラグはデバッグの際に有用でしょう。

     doctest コマンドラインは ‘-f’ を ‘-o FAIL_FAST’ の短縮形として受け
     付けます。

     Added in version 3.4.

 -- データ: doctest.REPORTING_FLAGS

     上記のエラー報告に関するフラグすべての論理和をとったビットマスクで
     す。

サブクラス化で *note doctest: 31. 内部を拡張するつもりがなければ役に立ち
ませんが、別の新しいオプションフラグ名を登録する方法もあります:

 -- の関数: doctest.register_optionflag (name)

     名前 'name' の新たなオプションフラグを作成し、作成されたフラグの整
     数値を返します。 *note register_optionflag(): 3e8b. は *note
     OutputChecker: 3e8c. や *note DocTestRunner: 3e8d. をサブクラス化し
     て、その中で新たに作成したオプションをサポートさせる際に使います。
     *note register_optionflag(): 3e8b. は以下のような定形文で呼び出さな
     ければなりません:

          MY_FLAG = register_optionflag('MY_FLAG')


File: python.info,  Node: ディレクティブ Directives,  Next: 警告<2>,  Prev: オプションフラグ,  Up: doctest のからくり

5.26.4.9 ディレクティブ (Directives)
....................................

doctest ディレクティブは個々の実行例の *note オプションフラグ: eff. を操
作するために使われます。 doctest ディレクティブは後のソースコード例にあ
るような特殊な Python コメントです:

     directive             ::= "#" "doctest:" directive_options
     directive_options     ::= directive_option ("," directive_option)*
     directive_option      ::= on_or_off directive_option_name
     on_or_off             ::= "+" | "-"
     directive_option_name ::= "DONT_ACCEPT_BLANKLINE" | "NORMALIZE_WHITESPACE" | ...

‘+’ や ‘-’ とディレクティブオプション名の間に空白を入れてはなりません。
ディレクティブオプション名は上で説明したオプションフラグ名のいずれかです
。

ある実行例の doctest ディレクティブは、その実行例だけの doctest の振る舞
いを変えます。ある特定の挙動を有効にしたければ ‘+’ を、無効にしたければ
‘-’ を使います。

例えば、以下のテストは成功します:

     >>> print(list(range(20)))  # doctest: +NORMALIZE_WHITESPACE
     [0,   1,  2,  3,  4,  5,  6,  7,  8,  9,
     10,  11, 12, 13, 14, 15, 16, 17, 18, 19]

ディレクティブがない場合、実際の出力には一桁の数字の間に二つスペースが入
っていないこと、実際の出力は 1 行になることから、テストは成功しないはず
です。別のディレクティブを使って、このテストを成功させることもできます:

     >>> print(list(range(20)))  # doctest: +ELLIPSIS
     [0, 1, ..., 18, 19]

複数のディレクティブは、一つの物理行の中にコンマで区切って指定できます:

     >>> print(list(range(20)))  # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
     [0,    1, ...,   18,    19]

一つの実行例中で複数のディレクティブコメントを使った場合、それらは組み合
わされます:

     >>> print(list(range(20)))  # doctest: +ELLIPSIS
     ...                         # doctest: +NORMALIZE_WHITESPACE
     [0,    1, ...,   18,    19]

この実行例で分かるように、実行例にはディレクティブだけを含む ‘...’ 行を
追加することができます。この書きかたは、実行例が長すぎるためにディレクテ
ィブを同じ行に入れると収まりが悪い場合に便利です:

     >>> print(list(range(5)) + list(range(10, 20)) + list(range(30, 40)))
     ... # doctest: +ELLIPSIS
     [0, ..., 4, 10, ..., 19, 30, ..., 39]

フォルトではすべてのオプションが無効になっており、ディレクティブは特定の
実行例だけに影響を及ぼすので、通常意味があるのは有効にするためのオプショ
ン (‘+’ のついたディレクティブ) だけです。とはいえ、doctest を実行する関
数はオプションフラグを指定してデフォルトとは異なった挙動を実現できるので
、そのような場合には ‘-’ を使った無効化オプションも意味を持ちます。


File: python.info,  Node: 警告<2>,  Prev: ディレクティブ Directives,  Up: doctest のからくり

5.26.4.10 警告
..............

*note doctest: 31. では、期待する出力に対する完全一致を厳格に求めます。
一致しない文字が一文字でもあると、テストは失敗してしまいます。 このため
、 Python が出力に関して何を保証していて、何を保証していないかを正確に知
っていないと混乱させられることがあるでしょう。 例えば、集合を出力する際
、 Python は要素がある特定の順番で並ぶよう保証してはいません。したがって
、以下のようなテスト

     >>> foo()
     {"spam", "eggs"}

は失敗するかもしれないのです!  回避するには

     >>> foo() == {"spam", "eggs"}
     True

とするのが一つのやり方です。別のやり方は

     >>> d = sorted(foo())
     >>> d
     ['eggs', 'spam']

他のやり方もありますが、あとは自分で考えてみてください。

以下のように、オブジェクトアドレスを埋め込むような結果を print するのも
よくありません :

     >>> id(1.0)  # certain to fail some of the time
     7948648
     >>> class C: pass
     >>> C()  # the default repr() for instances embeds an address
     <C object at 0x00AC18F0>

*note ELLIPSIS: 1413. ディレクティブを使うと、上のような例をうまく解決で
きます:

     >>> C()  # doctest: +ELLIPSIS
     <C object at 0x...>

浮動小数点数もまた、プラットフォーム間での微妙な出力の違いの原因となりま
す。というのも、Python は浮動小数点の書式化をプラットフォームの C ライブ
ラリに委ねており、この点では、C ライブラリはプラットフォーム間で非常に大
きく異なっているからです。

     >>> 1./7  # risky
     0.14285714285714285
     >>> print(1./7) # safer
     0.142857142857
     >>> print(round(1./7, 6)) # much safer
     0.142857

‘I/2.**J’ の形式になる数値はどのプラットフォームでもうまく動作するので、
私はこの形式の数値を生成するように doctest の実行例を工夫しています:

     >>> 3./4  # utterly safe
     0.75

単純な分数は人間にとっても理解しやすく、良いドキュメントを書くために役に
立ちます。


File: python.info,  Node: 基本 API,  Next: 単体テスト API,  Prev: doctest のからくり,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.11 基本 API
..................

数 *note testmod(): 1412. と *note testfile(): 3e75. は、ほとんどの基本
的な用途に十分な doctest インターフェースを提供しています。これら二つの
関数についてあまり形式的でない入門が読みたければ、 *note 簡単な利用法;
docstring 中の実行例をチェックする: 3e70. 節や *note 簡単な利用法;
テキストファイル中の実行例をチェックする: 3e73. 節を参照してください。

 -- の関数: doctest.testfile (filename, module_relative=True, name=None,
          package=None, globs=None, verbose=None, report=True,
          optionflags=0, extraglobs=None, raise_on_error=False,
          parser=DocTestParser(), encoding=None)

     'filename' 以外の引数はすべてオプションで、キーワード引数形式で指定
     しなければなりません。

     'filename' に指定したファイル内にある実行例をテストします。
     ‘(failure_count, test_count)’ を返します。

     オプション引数の 'module_relative' は、ファイル名をどのように解釈す
     るかを指定します:

        * 'module_relative' が ‘True’ (デフォルト) の場合、'filename' は
          OS に依存しないモジュールの相対パスになります。デフォルトでは
          、このパスは関数 *note testfile(): 3e75. を呼び出しているモジ
          ュールからの相対パスになります; ただし、'package' 引数を指定し
          た場合には、パッケージからの相対になります。OS への依存性を除
          くため、'filename' ではパスを分割する文字に ‘/’ を使わなければ
          ならず、絶対パスにしてはなりません (パス文字列を ‘/’ で始めて
          はなりません)。

        * 'module_relative' が ‘False’ の場合、'filename' は OS 依存のパ
          スを示します。パスは絶対パスでも相対パスでもかまいません; 相対
          パスにした場合、現在の作業ディレクトリを基準に解決します。

     オプション引数 'name' には、テストの名前を指定します; デフォルトの
     場合や ‘None’ を指定した場合、‘os.path.basename(filename)’ になりま
     す。

     オプション引数 'package' には、Python パッケージを指定するか、モジ
     ュール相対のファイル名の場合には相対の基準ディレクトリとなる Python
     パッケージの名前を指定します。パッケージを指定しない場合、関数を呼
     び出しているモジュールのディレクトリを相対の基準ディレクトリとして
     使います。'module_relative' を ‘False’ に指定している場合、
     'package' を指定するとエラーになります。

     オプション引数 'globs' には辞書を指定します。この辞書は、実行例を実
     行する際のグローバル変数として用いられます。doctest はこの辞書の浅
     いコピーを生成するので、実行例は白紙の状態からスタートします。デフ
     ォルトの場合や ‘None’ を指定した場合、新たな空の辞書になります。

     オプション引数 'extraglobs' には辞書を指定します。この辞書は、実行
     例を実行する際にグローバル変数にマージされます。マージは *note
     dict.update(): 140a. のように振舞います: 'globs' と 'extraglobs' と
     の間に同じキー値がある場合、両者を合わせた辞書中には 'extraglobs' の
     方の値が入ります。デフォルト、または ‘None’ であるとき、追加のグロ
     ーバル変数は使われません。この仕様は、パラメータ付きで doctest を実
     行するという、やや進んだ機能です。例えば、一般的な名前を使って基底
     クラス向けに doctest を書いておき、その後で辞書で一般的な名前からテ
     ストしたいサブクラスへの対応付けを行う辞書を 'extraglobs' に渡して
     、様々なサブクラスをテストできます。

     オプション引数 'verbose' が真の場合、様々な情報を出力します。偽の場
     合にはテストの失敗だけを報告します。デフォルトの場合や ‘None’ を指
     定した場合、‘sys.argv’ に ‘'-v'’ を指定しない限りこの値は真になりま
     せん。

     オプション引数 'report' が真の場合、テストの最後にサマリを出力しま
     す。それ以外の場合には何も出力しません。verbose モードの場合、サマ
     リには詳細な情報を出力しますが、そうでない場合にはサマリはとても簡
     潔になります (実際には、すべてのテストが成功した場合には何も出力し
     ません)。

     オプション引数 'optionflags' (デフォルト値 0) は、各オプションフラ
     グの *note ビット単位論理和: 1fcd. を取ります。 *note
     オプションフラグ: eff. 節を参照してください。

     オプション引数 'raise_on_error' の値はデフォルトでは偽です。真にす
     ると、最初のテスト失敗や予期しない例外が起きたときに例外を送出しま
     す。このオプションを使うと、失敗の原因を検死デバッグ (post-mortem
     debug) できます。デフォルトの動作では、実行例の実行を継続します。

     オプション引数 'parser' には、 *note DocTestParser: 3e7e. (またはそ
     のサブクラス) を指定します。このクラスはファイルから実行例を抽出す
     るために使われます。デフォルトでは通常のパーザ (‘DocTestParser()’)
     です。

     オプション引数 'encoding' にはファイルをユニコードに変換する際に使
     われるエンコーディングを指定します。

 -- の関数: doctest.testmod (m=None, name=None, globs=None,
          verbose=None, report=True, optionflags=0, extraglobs=None,
          raise_on_error=False, exclude_empty=False)

     引数はすべてオプションで、'm' 以外の引数はキーワード引数として指定
     しなければなりません。

     モジュール 'm' ('m' を指定しないか ‘None’ にした場合には *note
     __main__: 1.) から到達可能な関数およびクラスの docstring 内にある実
     行例をテストします。 ‘m.__doc__’ 内の実行例からテストを開始します。

     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.

     モジュール 'm' に属するオブジェクトにつけられた docstring のみを検
     索します。

     ‘(failure_count, test_count)’ を返します。

     オプション引数 'name' には、モジュールの名前を指定します。デフォル
     トの場合や ‘None’ を指定した場合には、‘m.__name__’ を使います。

     Optional argument 'exclude_empty' defaults to false.  If true,
     objects for which no doctests are found are excluded from
     consideration.  The default is a backward compatibility hack, so
     that code still using *note doctest.master.summarize: 3e97. in
     conjunction with *note testmod(): 1412. continues to get output for
     objects with no tests.  The 'exclude_empty' argument to the newer
     *note DocTestFinder: 1596. constructor defaults to true.

     オプション引数 'extraglobs', 'verbose', 'report', 'optionflags',
     'raise_on_error', および 'globs' は上で説明した *note testfile():
     3e75. の引数と同じです。ただし、 'globs' のデフォルト値は
     ‘m.__dict__’ になります。

 -- の関数: doctest.run_docstring_examples (f, globs, verbose=False,
          name='NoName', compileflags=None, optionflags=0)

     オブジェクト 'f' に関連付けられた実行例をテストします。 'f' は文字
     列、モジュール、関数、またはクラスオブジェクトです。

     引数 'globs' に辞書を指定すると、その浅いコピーを実行コンテキストに
     使います。

     オプション引数 'name' はテスト失敗時のメッセージに使われます。デフ
     ォルトの値は ‘'NoName'’ です。

     オプション引数 'verbose' の値を真にすると、テストが失敗しなくても出
     力を生成します。デフォルトでは、実行例のテストに失敗したときのみ出
     力を生成します。

     オプション引数 'compileflags' には、実行例を実行するときに Python バ
     イトコードコンパイラが使うフラグを指定します。デフォルトの場合や
     ‘None’ を指定した場合、フラグは 'globs' 内にある future 機能セット
     に対応したものになります。

     オプション引数 'optionflags' は、上で述べた *note testfile(): 3e75.
     と同様の働きをします。


File: python.info,  Node: 単体テスト API,  Next: 拡張 API,  Prev: 基本 API,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.12 単体テスト API
........................

As your collection of doctest'ed modules grows, you'll want a way to run
all their doctests systematically.  *note doctest: 31. provides two
functions that can be used to create *note unittest: ef. test suites
from modules and text files containing doctests.  To integrate with
*note unittest: ef. test discovery, include a *note load_tests: 3e9b.
function in your test module:

     import unittest
     import doctest
     import my_module_with_doctests

     def load_tests(loader, tests, ignore):
         tests.addTests(doctest.DocTestSuite(my_module_with_doctests))
         return tests

doctest の入ったテキストファイルやモジュールから *note
unittest.TestSuite: dc1. インスタンスを生成するための主な関数は二つあり
ます:

 -- の関数: doctest.DocFileSuite (*paths, module_relative=True,
          package=None, setUp=None, tearDown=None, globs=None,
          optionflags=0, parser=DocTestParser(), encoding=None)

     単一または複数のテキストファイルに入っている doctest 形式のテストを
     、 *note unittest.TestSuite: dc1. インスタンスに変換します。

     The returned *note unittest.TestSuite: dc1. is to be run by the
     unittest framework and runs the interactive examples in each file.
     If an example in any file fails, then the synthesized unit test
     fails, and a *note failureException: 3e9d. exception is raised
     showing the name of the file containing the test and a (sometimes
     approximate) line number.  If all the examples in a file are
     skipped, then the synthesized unit test is also marked as skipped.

     関数には、テストを行いたい一つまたは複数のファイルへのパスを (文字
     列で) 渡します。

     *note DocFileSuite(): 3e9c. には、キーワード引数でオプションを指定
     できます:

     オプション引数 'module_relative' は 'paths' に指定したファイル名を
     どのように解釈するかを指定します:

        * 'module_relative' が ‘True’ (デフォルト) の場合、'paths' 中の
          ファイル名は OS に依存しないモジュールの相対パスになります。デ
          フォルトでは、このパスは呼び出し元のモジュールのディレクトリか
          らの相対パスになります; ただし、'package' 引数を指定した場合に
          は、パッケージからの相対になります。OS への依存性を除くため、
          各ファイル名はパスを分割するのに ‘/’ 文字を使わなければならず
          、絶対パスにしてはなりません (パス文字列を ‘/’ で始めてはなり
          ません)。

        * 'module_relative' が ‘False’ の場合、'filename' は OS 依存のパ
          スを示します。パスは絶対パスでも相対パスでもかまいません; 相対
          パスにした場合、現在の作業ディレクトリを基準に解決します。

     オプション引数 'package' には、Python パッケージを指定するか、モジ
     ュール相対のファイル名の場合には相対の基準ディレクトリとなる Python
     パッケージの名前を指定します。パッケージを指定しない場合、関数を呼
     び出しているモジュールのディレクトリを相対の基準ディレクトリとして
     使います。'module_relative' を ‘False’ に指定している場合、
     'package' を指定するとエラーになります。

     オプション引数 'setUp' には、テストスイートのセットアップに使う関数
     を指定します。この関数は、各ファイルのテストを実行する前に呼び出さ
     れます。 'setUp' 関数は *note DocTest: 1616. オブジェクトに引き渡さ
     れます。 'setUp' は 'globs' 属性を介してテストのグローバル変数にア
     クセスできます。

     オプション引数 'tearDown' には、テストを解体 (tear-down) するための
     関数を指定します。この関数は、各ファイルのテストの実行を終了するた
     びに呼び出されます。 'tearDown' 関数は *note DocTest: 1616. オブジ
     ェクトに引き渡されます。 'tearDown' は 'globs' 属性を介してテストの
     グローバル変数にアクセスできます。

     オプション引数 'globs' は辞書で、テストのグローバル変数の初期値が入
     ります。この辞書は各テストごとに新たにコピーして使われます。デフォ
     ルトでは 'globs' は空の新たな辞書です。

     オプション引数 'optionflags' には、テストを実行する際にデフォルトで
     適用される doctest オプションを OR で結合して指定します。 *note
     オプションフラグ: eff. 節を参照してください。結果レポートに関するオ
     プションを指定するより適切な方法は下記の *note
     set_unittest_reportflags(): 3e9e. の説明を参照してください。

     オプション引数 'parser' には、 *note DocTestParser: 3e7e. (またはそ
     のサブクラス) を指定します。このクラスはファイルから実行例を抽出す
     るために使われます。デフォルトでは通常のパーザ (‘DocTestParser()’)
     です。

     オプション引数 'encoding' にはファイルをユニコードに変換する際に使
     われるエンコーディングを指定します。

     *note DocFileSuite(): 3e9c. を使用してテキストファイルからロードさ
     れた doctests に提供される globals に、グローバル変数 ‘__file__’ が
     追加されます。

 -- の関数: doctest.DocTestSuite (module=None, globs=None,
          extraglobs=None, test_finder=None, setUp=None, tearDown=None,
          optionflags=0, checker=None)

     doctest のテストを *note unittest.TestSuite: dc1. に変換します。

     The returned *note unittest.TestSuite: dc1. is to be run by the
     unittest framework and runs each doctest in the module.  If any of
     the doctests fail, then the synthesized unit test fails, and a
     *note failureException: 3e9d. exception is raised showing the name
     of the file containing the test and a (sometimes approximate) line
     number.  If all the examples in a docstring are skipped, then the
     synthesized unit test is also marked as skipped.

     オプション引数 'module' には、テストしたいモジュールの名前を指定し
     ます。'module' にはモジュールオブジェクトまたは (ドット表記の) モジ
     ュール名を指定できます。'module' を指定しない場合、この関数を呼び出
     しているモジュールになります。

     オプション引数 'globs' は辞書で、テストのグローバル変数の初期値が入
     ります。この辞書は各テストごとに新たにコピーして使われます。デフォ
     ルトでは 'globs' は空の新たな辞書です。

     オプション引数 'extraglobs' には追加のグローバル変数セットを指定し
     ます。この変数セットは 'globs' に統合されます。デフォルトでは、追加
     のグローバル変数はありません。

     オプション引数 'test_finder' は、モジュールから doctest を抽出する
     ための *note DocTestFinder: 1596. オブジェクト (またはその代替とな
     るオブジェクト) です。

     オプション引数 'setUp' 、 'tearDown' 、および 'optionflags' は上の
     *note DocFileSuite(): 3e9c. と同じです。

     この関数は *note testmod(): 1412. と同じ検索方法を使います。

     バージョン 3.5 で変更: 'module' がドキュメンテーション文字列を含ま
     ない場合には、 *note DocTestSuite(): dc0. は *note ValueError: 1e3.
     を送出するのではなく空の *note unittest.TestSuite: dc1. を返します
     。

 -- 例外: doctest.failureException

     When doctests which have been converted to unit tests by *note
     DocFileSuite(): 3e9c. or *note DocTestSuite(): dc0. fail, this
     exception is raised showing the name of the file containing the
     test and a (sometimes approximate) line number.

Under the covers, *note DocTestSuite(): dc0. creates a *note
unittest.TestSuite: dc1. out of ‘doctest.DocTestCase’ instances, and
‘DocTestCase’ is a subclass of *note unittest.TestCase: 41a.
‘DocTestCase’ isn't documented here (it's an internal detail), but
studying its code can answer questions about the exact details of *note
unittest: ef. integration.

Similarly, *note DocFileSuite(): 3e9c. creates a *note
unittest.TestSuite: dc1. out of ‘doctest.DocFileCase’ instances, and
‘DocFileCase’ is a subclass of ‘DocTestCase’.

So both ways of creating a *note unittest.TestSuite: dc1. run instances
of ‘DocTestCase’.  This is important for a subtle reason: when you run
*note doctest: 31. functions yourself, you can control the *note
doctest: 31. options in use directly, by passing option flags to *note
doctest: 31. functions.  However, if you're writing a *note unittest:
ef. framework, *note unittest: ef. ultimately controls when and how
tests get run.  The framework author typically wants to control *note
doctest: 31. reporting options (perhaps, e.g., specified by command line
options), but there's no way to pass options through *note unittest: ef.
to *note doctest: 31. test runners.

このため、 *note doctest: 31. では、以下の関数を使って、 *note unittest:
ef. サポートに特化したレポートフラグ表記方法もサポートしています:

 -- の関数: doctest.set_unittest_reportflags (flags)

     *note doctest: 31. のレポートフラグをセットします。

     引数 'flags' はオプションフラグの *note ビット単位論理和: 1fcd. を
     取ります。 *note オプションフラグ: eff. 節を参照してください。「レ
     ポートフラグ」しか使えません。

     This is a module-global setting, and affects all future doctests
     run by module *note unittest: ef.: the ‘runTest()’ method of
     ‘DocTestCase’ looks at the option flags specified for the test case
     when the ‘DocTestCase’ instance was constructed.  If no reporting
     flags were specified (which is the typical and expected case),
     ‘doctest’'s *note unittest: ef. reporting flags are *note bitwise
     ORed: 1fcd. into the option flags, and the option flags so
     augmented are passed to the *note DocTestRunner: 3e8d. instance
     created to run the doctest.  If any reporting flags were specified
     when the ‘DocTestCase’ instance was constructed, ‘doctest’'s *note
     unittest: ef. reporting flags are ignored.

     この関数は、関数を呼び出す前に有効になっていた *note unittest: ef.
     レポートフラグの値を返します。


File: python.info,  Node: 拡張 API,  Next: デバッグ,  Prev: 単体テスト API,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.13 拡張 API
..................

基本 API は、doctest を使いやすくするための簡単なラッパであり、柔軟性が
あってほとんどのユーザの必要を満たしています; とはいえ、もっとテストをき
め細かに制御したい場合や、doctest の機能を拡張したい場合、拡張 API
(advanced API) を使わなければなりません。

拡張 API は、doctest ケースから抽出した対話モードでの実行例を記憶するた
めの二つのコンテナクラスを中心に構成されています:

   * *note Example: 3ea1.: 1つの Python *note 文: 26d2. と、その期待する
     出力をペアにしたもの。

   * *note DocTest: 1616.: *note Example: 3ea1. の集まり。通常一つの
     docstring やテキストファイルから抽出されます。

その他に、doctest の実行例を検索、構文解析、実行、チェックするための処理
クラスが以下のように定義されています:

   * *note DocTestFinder: 1596.: 与えられたモジュールからすべての
     docstring を検索し、 *note DocTestParser: 3e7e. を使って対話モード
     での実行例が入ったすべての docstring から *note DocTest: 1616. を生
     成します。

   * *note DocTestParser: 3e7e.: (オブジェクトの docstring 等の) 文字列
     から *note DocTest: 1616. オブジェクトを生成します。

   * *note DocTestRunner: 3e8d.: *note DocTest: 1616. 内の実行例を実行し
     、 *note OutputChecker: 3e8c. を使って出力を検証します。

   * *note OutputChecker: 3e8c.: doctest 実行例から実際に出力された結果
     を期待する出力と比較し、両者が一致するか判別します。

これらの処理クラスの関係を図にまとめると、以下のようになります:

                                 list of:
     +------+                   +---------+
     |module| --DocTestFinder-> | DocTest | --DocTestRunner-> results
     +------+    |        ^     +---------+     |       ^    (printed)
                 |        |     | Example |     |       |
                 v        |     |   ...   |     v       |
                DocTestParser   | Example |   OutputChecker
                                +---------+

* Menu:

* DocTest オブジェクト::
* Example オブジェクト::
* DocTestFinder オブジェクト::
* DocTestParser オブジェクト::
* TestResults objects::
* DocTestRunner オブジェクト::
* OutputChecker オブジェクト::


File: python.info,  Node: DocTest オブジェクト,  Next: Example オブジェクト,  Up: 拡張 API

5.26.4.14 DocTest オブジェクト
..............................

 -- クラス: doctest.DocTest (examples, globs, name, filename, lineno,
          docstring)

     単一の名前空間内で実行される doctest 実行例の集まりです。コンストラ
     クタの引数は *note DocTest: 1616. インスタンス中の同名の属性の初期
     化に使われます。

     *note DocTest: 1616. では、以下の属性を定義しています。これらの変数
     はコンストラクタで初期化されます。直接変更してはなりません。

      -- の属性: examples

          対話モードにおける実行例それぞれをエンコードしていて、テストで
          実行される、 *note Example: 3ea1. オブジェクトからなるリストで
          す。

      -- の属性: globs

          実行例を実行する名前空間 (いわゆるグローバル変数) です。このメ
          ンバは、名前から値への対応付けを行っている辞書です。実行例が名
          前空間に対して (新たな変数を束縛するなど) 何らかの変更を行った
          場合、 *note globs: 3ea5. への反映はテストの実行後に起こります
          。

      -- の属性: name

          *note DocTest: 1616. を識別する名前の文字列です。通常、この値
          はテストを取り出したオブジェクトかファイルの名前になります。

      -- の属性: filename

          *note DocTest: 1616. を取り出したファイルの名前です; ファイル
          名が未知の場合や *note DocTest: 1616. をファイルから取り出した
          のでない場合には ‘None’ になります。

      -- の属性: lineno

          *note filename: 3ea7. 中で *note DocTest: 1616. のテスト実行例
          が始まっている行の行番号で、行番号が利用できなければ ‘None’ で
          す。行番号は、ファイルの先頭を 0 として数えます。

      -- の属性: docstring

          テストを取り出した docstring 自体を現す文字列です。docstring 文
          字列を得られない場合や、文字列からテスト実行例を取り出したので
          ない場合には ‘None’ になります。


File: python.info,  Node: Example オブジェクト,  Next: DocTestFinder オブジェクト,  Prev: DocTest オブジェクト,  Up: 拡張 API

5.26.4.15 Example オブジェクト
..............................

 -- クラス: doctest.Example (source, want, exc_msg=None, lineno=0,
          indent=0, options=None)

     ひとつの Python 文と、それに対する期待する出力からなる、単一の対話
     的モードの実行例です。コンストラクタの引数は *note Example: 3ea1. イ
     ンスタンス中の同名の属性の初期化に使われます。

     *note Example: 3ea1. では、以下の属性を定義しています。これらの変数
     はコンストラクタで初期化されます。直接変更してはなりません。

      -- の属性: source

          実行例のソースコードが入った文字列です。ソースコードは単一の
          Python で、末尾は常に改行です。コンストラクタは必要に応じて改
          行を追加します。

      -- の属性: want

          実行例のソースコードを実行した際の期待する出力 (標準出力と、例
          外が生じた場合にはトレースバック) です。 *note want: 3eac. の
          末尾は、期待する出力がまったくない場合を除いて常に改行になりま
          す。期待する出力がない場合には空文字列になります。コンストラク
          タは必要に応じて改行を追加します。

      -- の属性: exc_msg

          実行例が例外を生成すると期待される場合の例外メッセージです。例
          外を送出しない場合には ‘None’ です。この例外メッセージは、
          *note traceback.format_exception_only(): 819. の戻り値と比較さ
          れます。値が ‘None’ でない限り、 *note exc_msg: 3ead. は改行で
          終わっていなければなりません; コンストラクタは必要に応じて改行
          を追加します。

      -- の属性: lineno

          この実行例を含む文字列における実行例が始まる行番号です。行番号
          は文字列の先頭を 0 として数えます。

      -- の属性: indent

          実行例の入っている文字列のインデント、すなわち実行例の最初のプ
          ロンプトより前にある空白文字の数です。

      -- の属性: options

          A dictionary mapping from option flags to ‘True’ or ‘False’,
          which is used to override default options for this example.
          Any option flags not contained in this dictionary are left at
          their default value (as specified by the *note DocTestRunner:
          3e8d.'s *note optionflags: eff.).  By default, no options are
          set.


File: python.info,  Node: DocTestFinder オブジェクト,  Next: DocTestParser オブジェクト,  Prev: Example オブジェクト,  Up: 拡張 API

5.26.4.16 DocTestFinder オブジェクト
....................................

 -- クラス: doctest.DocTestFinder (verbose=False,
          parser=DocTestParser(), recurse=True, exclude_empty=True)

     与えられたオブジェクトについて、そのオブジェクト自身の docstring か
     、そのオブジェクトに含まれるオブジェクトの docstring から *note
     DocTest: 1616. を抽出する処理クラスです。モジュール、クラス、関数、
     メソッド、静的メソッド、クラスメソッド、プロパティから *note
     DocTest: 1616. を抽出できます。

     オプション引数 'verbose' を使うと、抽出処理の対象となるオブジェクト
     を表示できます。デフォルトは ‘False’ (出力を行わない) です。

     オプション引数 'parser' には、 docstring から *note DocTest: 1616.
     を抽出するのに使う *note DocTestParser: 3e7e. オブジェクト (または
     その代替となるオブジェクト) を指定します。

     オプション引数 'recurse' が偽の場合、 *note DocTestFinder.find():
     1664. は与えられたオブジェクトだけを調べ、そのオブジェクトに含まれ
     る他のオブジェクトを調べません。

     オプション引数 'exclude_empty' が偽の場合、 *note
     DocTestFinder.find(): 1664. は空の docstring を持つオブジェクトもテ
     スト対象に含めます。

     *note DocTestFinder: 1596. では以下のメソッドを定義しています:

      -- メソッド: find (obj[, name][, module][, globs][, extraglobs])

          'obj' または 'obj' 内に入っているオブジェクトの docstring 中で
          定義されている *note DocTest: 1616. のリストを返します。

          オプション引数 'name' には、オブジェクトの名前を指定します。こ
          の名前は、関数が返す *note DocTest: 1616. の名前になります。
          'name' を指定しない場合、 ‘obj.__name__’ を使います。

          オプションのパラメータ 'module' は、指定したオブジェクトを収め
          ているモジュールを指定します。 'module' を指定しないか、‘None’
          を指定した場合には、正しいモジュールを自動的に決定しようと試み
          ます。 オブジェクトのモジュールは以下のような役割を果たします:

             * 'globs' を指定していない場合、オブジェクトのモジュールは
               デフォルトの名前空間になります。

             * 他のモジュールから import されたオブジェクトに対して
               *note DocTestFinder: 1596. が *note DocTest: 1616. を抽出
               するのを避けるために使います。 ('module' 由来でないオブジ
               ェクトを無視します。)

             * オブジェクトの入っているファイル名を調べるために使います
               。

             * オブジェクトがファイル内の何行目にあるかを調べる手助けに
               します。

          'module' が ‘False’ の場合には、モジュールの検索を試みません。
          これは正確さを欠くような使い方で、通常 doctest 自体のテストに
          しか使いません。'module' が ‘False’ の場合、または 'module' が
          ‘None’ で自動的に的確なモジュールを見つけ出せない場合には、す
          べてのオブジェクトは ‘(non-existent)’ モジュールに属するとみな
          され、そのオブジェクト内のすべてのオブジェクトに対して (再帰的
          に) doctest の検索を行います。

          各 *note DocTest: 1616. のグローバル変数は、 'globs' と
          'extraglobs' を合わせたもの ('extraglobs' 内の束縛が 'globs' 内
          の束縛を上書きする) になります。各々の *note DocTest: 1616. に
          対して、グローバル変数を表す辞書の新たな浅いコピーを生成します
          。 'globs' を指定しない場合に使われるのデフォルト値は、モジュ
          ールを指定していればそのモジュールの '__dict__' になり、指定し
          ていなければ ‘{}’ になります。 'extraglobs' を指定しない場合、
          デフォルトの値は ‘{}’ になります。


File: python.info,  Node: DocTestParser オブジェクト,  Next: TestResults objects,  Prev: DocTestFinder オブジェクト,  Up: 拡張 API

5.26.4.17 DocTestParser オブジェクト
....................................

 -- クラス: doctest.DocTestParser

     対話モードの実行例を文字列から抽出し、それを使って *note DocTest:
     1616. オブジェクトを生成するために使われる処理クラスです。

     *note DocTestParser: 3e7e. では以下のメソッドを定義しています:

      -- メソッド: get_doctest (string, globs, name, filename, lineno)

          指定した文字列からすべての doctest 実行例を抽出し、 *note
          DocTest: 1616. オブジェクト内に集めます。

          'globs', 'name', 'filename', および 'lineno' は新たに作成され
          る *note DocTest: 1616. オブジェクトの属性になります。詳しくは
          *note DocTest: 1616. のドキュメントを参照してください。

      -- メソッド: get_examples (string, name='<string>')

          指定した文字列からすべての doctest 実行例を抽出し、 *note
          Example: 3ea1. オブジェクトからなるリストにして返します。各
          *note Example: 3ea1. の行番号は 0 から数えます。オプション引数
          'name' はこの文字列につける名前で、エラーメッセージにしか使わ
          れません。

      -- メソッド: parse (string, name='<string>')

          指定した文字列を、実行例とその間のテキストに分割し、実行例を
          *note Example: 3ea1. オブジェクトに変換し、 *note Example:
          3ea1. と文字列からなるリストにして返します。各 *note Example:
          3ea1. の行番号は 0から数えます。オプション引数 'name' はこの文
          字列につける名前で、エラーメッセージにしか使われません。


File: python.info,  Node: TestResults objects,  Next: DocTestRunner オブジェクト,  Prev: DocTestParser オブジェクト,  Up: 拡張 API

5.26.4.18 TestResults objects
.............................

 -- クラス: doctest.TestResults (failed, attempted)

      -- の属性: failed

          Number of failed tests.

      -- の属性: attempted

          Number of attempted tests.

      -- の属性: skipped

          Number of skipped tests.

          Added in version 3.13.


File: python.info,  Node: DocTestRunner オブジェクト,  Next: OutputChecker オブジェクト,  Prev: TestResults objects,  Up: 拡張 API

5.26.4.19 DocTestRunner オブジェクト
....................................

 -- クラス: doctest.DocTestRunner (checker=None, verbose=None,
          optionflags=0)

     *note DocTest: 1616. 内の対話モード実行例を実行し、検証する際に用い
     られる処理クラスです。

     期待する出力と実際の出力との比較は *note OutputChecker: 3e8c. で行
     います。比較は様々なオプションフラグを使ってカスタマイズできます; 詳
     しくは *note オプションフラグ: eff. を参照してください。オプション
     フラグでは不十分な場合、コンストラクタに *note OutputChecker: 3e8c.
     のサブクラスを渡して比較方法をカスタマイズできます。

     The test runner's display output can be controlled in two ways.
     First, an output function can be passed to *note run(): 1c0.; this
     function will be called with strings that should be displayed.  It
     defaults to ‘sys.stdout.write’.  If capturing the output is not
     sufficient, then the display output can be also customized by
     subclassing DocTestRunner, and overriding the methods *note
     report_start(): 3ebe, *note report_success(): 3ebf, *note
     report_unexpected_exception(): 3ec0, and *note report_failure():
     3ec1.

     オプションのキーワード引数 'checker' には、 *note OutputChecker:
     3e8c. オブジェクト (またはその代替となるオブジェクト) を指定します
     。このオブジェクトは doctest 実行例の期待する出力と実際の出力との比
     較を行う際に使われます。

     オプションのキーワード引数 'verbose' は、 *note DocTestRunner:
     3e8d. の出すメッセージの冗長性を制御します。 'verbose' が ‘True’ の
     場合、各実行例を実行する都度、その実行例についての情報を出力します
     。 'verbose' が ‘False’ の場合、テストの失敗だけを出力します。
     'verbose' を指定しない場合や ‘None’ を指定した場合、コマンドライン
     スイッチ ‘-v’ を使った場合にのみ 'verbose' 出力を適用します。

     オプションのキーワード引数 'optionflags' を使うと、テストランナーが
     期待される出力と実際の出力を比較する方法や、テストの失敗を表示する
     方法を制御できます。詳しくは *note オプションフラグ: eff. 節を参照
     してください。

     The test runner accumulates statistics.  The aggregated number of
     attempted, failed and skipped examples is also available via the
     *note tries: 3ec2, *note failures: 3ec3. and *note skips: 1c1.
     attributes.  The *note run(): 1c0. and *note summarize(): 3e97.
     methods return a *note TestResults: 3eb9. instance.

     *note DocTestRunner: 3e8d. defines the following methods:

      -- メソッド: report_start (out, test, example)

          テストランナーが実行例を処理しようとしているときにレポートを出
          力します。 *note DocTestRunner: 3e8d. の出力をサブクラスでカス
          タマイズできるようにするためのメソッドです。直接呼び出してはな
          りません。

          'example' は処理する実行例です。 'test' は 'example' の入って
          いるテストです。 'out' は出力用の関数で、 *note
          DocTestRunner.run(): 1c0. に渡されます。

      -- メソッド: report_success (out, test, example, got)

          与えられた実行例が正しく動作したことを報告します。このメソッド
          は *note DocTestRunner: 3e8d. のサブクラスで出力をカスタマイズ
          できるようにするために提供されています; 直接呼び出してはなりま
          せん。

          'example' は処理する実行例です。 'got' は実行例から実際に得ら
          れた出力です。 'test' は 'example' の入っているテストです。
          'out' は出力用の関数で、 *note DocTestRunner.run(): 1c0. に渡
          されます。

      -- メソッド: report_failure (out, test, example, got)

          与えられた実行例が正しく動作しなかったことを報告します。このメ
          ソッドは *note DocTestRunner: 3e8d. のサブクラスで出力をカスタ
          マイズできるようにするために提供されています; 直接呼び出しては
          なりません。

          'example' は処理する実行例です。 'got' は実行例から実際に得ら
          れた出力です。 'test' は 'example' の入っているテストです。
          'out' は出力用の関数で、 *note DocTestRunner.run(): 1c0. に渡
          されます。

      -- メソッド: report_unexpected_exception (out, test, example,
               exc_info)

          与えられた実行例が期待とは違う例外を送出したことを報告します。
          このメソッドは *note DocTestRunner: 3e8d. のサブクラスで出力を
          カスタマイズできるようにするために提供されています; 直接呼び出
          してはなりません。

          'example' は処理する実行例です。 'exc_info' には予期せず送出さ
          れた例外の情報を入れたタプル (*note sys.exc_info(): 656. の返
          す内容) になります。 'test' は 'example' の入っているテストで
          す。 'out' は出力用の関数で、 *note DocTestRunner.run(): 1c0.
          に渡されます。

      -- メソッド: run (test, compileflags=None, out=None,
               clear_globs=True)

          Run the examples in 'test' (a *note DocTest: 1616. object),
          and display the results using the writer function 'out'.
          Return a *note TestResults: 3eb9. instance.

          実行例は名前空間 ‘test.globs’ の下で実行されます。
          'clear_globs' が真 (デフォルト) の場合、名前空間はテストの実行
          後に消去され、ガベージコレクションを促します。テストの実行完了
          後にその内容を調べたければ、'clear_globs=False' としてください
          。

          'compileflags' には、実行例を実行する際に Python コンパイラに
          適用するフラグセットを指定します。'compileflags' を指定しない
          場合、デフォルト値は 'globs' で適用されている future-import フ
          ラグセットになります。

          The output of each example is checked using the *note
          DocTestRunner: 3e8d.'s output checker, and the results are
          formatted by the ‘DocTestRunner.report_*()’ methods.

      -- メソッド: summarize (verbose=None)

          Print a summary of all the test cases that have been run by
          this DocTestRunner, and return a *note TestResults: 3eb9.
          instance.

          オプションの 'verbose' 引数を使うと、どのくらいサマリを詳しく
          するかを制御できます。冗長度を指定しない場合、 *note
          DocTestRunner: 3e8d. 自体の冗長度を使います。

     *note DocTestParser: 3e7e. has the following attributes:

      -- の属性: tries

          Number of attempted examples.

      -- の属性: failures

          Number of failed examples.

      -- の属性: skips

          Number of skipped examples.

          Added in version 3.13.


File: python.info,  Node: OutputChecker オブジェクト,  Prev: DocTestRunner オブジェクト,  Up: 拡張 API

5.26.4.20 OutputChecker オブジェクト
....................................

 -- クラス: doctest.OutputChecker

     doctest 実行例を実際に実行したときの出力が期待する出力と一致するか
     どうかをチェックするために使われるクラスです。 *note OutputChecker:
     3e8c. では、与えられた二つの出力を比較して、一致する場合には ‘True’
     を返す *note check_output(): 3ec6. と、二つの出力間の違いを説明する
     文字列を返す *note output_difference(): 3ec7. の、二つのメソッドが
     あります。

     *note OutputChecker: 3e8c. では以下のメソッドを定義しています:

      -- メソッド: check_output (want, got, optionflags)

          実行例から実際に得られた出力 ('got') と、期待する出力 ('want')
          が一致する場合にのみ ‘True’ を返します。二つの文字列がまったく
          同一の場合には常に一致するとみなしますが、テストランナーの使っ
          ているオプションフラグにより、厳密には同じ内容になっていなくて
          も一致するとみなす場合もあります。オプションフラグについての詳
          しい情報は *note オプションフラグ: eff. 節を参照してください。

      -- メソッド: output_difference (example, got, optionflags)

          与えられた実行例 ('example') の期待する出力と、実際に得られた
          出力 ('got') の間の差異を解説している文字列を返します。
          'optionflags' は 'want' と 'got' を比較する際に使われるオプシ
          ョンフラグのセットです。


File: python.info,  Node: デバッグ,  Next: アドバイス,  Prev: 拡張 API,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.21 デバッグ
..................

*note doctest: 31. では、doctest 実行例をデバッグするメカニズムをいくつ
か提供しています:

   * doctest を実行可能な Python プログラムに変換し、 Python デバッガ
     *note pdb: 94. で実行できるようにするための関数がいくつかあります。

   * *note DocTestRunner: 3e8d. のサブクラス *note DebugRunner: 3eca. ク
     ラスがあります。このクラスは、最初に失敗した実行例に対して例外を送
     出します。例外には実行例に関する情報が入っています。この情報は実行
     例の検死デバッグに利用できます。

   * *note DocTestSuite(): dc0. の生成する *note unittest: ef. テストケ
     ースは、 *note debug(): 3ecb. メソッドをサポートしています。 *note
     debug(): 3ecb. は *note unittest.TestCase: 41a. で定義されています
     。

   * *note pdb.set_trace(): 216. を doctest 実行例の中で呼び出しておけば
     、その行が実行されたときに Python デバッガが組み込まれます。デバッ
     ガを組み込んだあとは、変数の現在の値などを調べられます。たとえば、
     以下のようなモジュールレベルの docstring の入ったファイル ‘a.py’ が
     あるとします:

          """
          >>> def f(x):
          ...     g(x*2)
          >>> def g(x):
          ...     print(x+3)
          ...     import pdb; pdb.set_trace()
          >>> f(3)
          9
          """

     対話セッションは以下のようになるでしょう:

          >>> import a, doctest
          >>> doctest.testmod(a)
          --Return--
          > <doctest a[1]>(3)g()->None
          -> import pdb; pdb.set_trace()
          (Pdb) list
            1     def g(x):
            2         print(x+3)
            3  ->     import pdb; pdb.set_trace()
          [EOF]
          (Pdb) p x
          6
          (Pdb) step
          --Return--
          > <doctest a[0]>(2)f()->None
          -> g(x*2)
          (Pdb) list
            1     def f(x):
            2  ->     g(x*2)
          [EOF]
          (Pdb) p x
          3
          (Pdb) step
          --Return--
          > <doctest a[2]>(1)?()->None
          -> f(3)
          (Pdb) cont
          (0, 3)
          >>>

以下は、doctest を Python コードに変換して、できたコードをデバッガ下で実
行できるようにするための関数です:

 -- の関数: doctest.script_from_examples (s)

     実行例の入ったテキストをスクリプトに変換します。

     引数 's' は doctest 実行例の入った文字列です。この文字列は Python ス
     クリプトに変換され、その中では 's' の doctest 実行例が通常のコード
     に、それ以外は Python のコメント文になります。生成したスクリプトを
     文字列で返します。例えば、

          import doctest
          print(doctest.script_from_examples(r"""
              Set x and y to 1 and 2.
              >>> x, y = 1, 2

              Print their sum:
              >>> print(x+y)
              3
          """))

     は:

          # Set x and y to 1 and 2.
          x, y = 1, 2
          #
          # Print their sum:
          print(x+y)
          # Expected:
          ## 3

     この関数は内部的に他の関数から使われていますが (下記参照)、対話セッ
     ションを Python スクリプトに変換したいような場合にも便利でしょう。

 -- の関数: doctest.testsource (module, name)

     あるオブジェクトの doctest をスクリプトに変換します。

     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 (within the module) of the object with the
     doctests of interest.  The result is a string, containing the
     object's docstring converted to a Python script, as described for
     *note script_from_examples(): 3ecc. above.  For example, if module
     ‘a.py’ contains a top-level function ‘f()’, then

          import a, doctest
          print(doctest.testsource(a, "a.f"))

     prints a script version of function ‘f()’'s docstring, with
     doctests converted to code, and the rest placed in comments.

 -- の関数: doctest.debug (module, name, pm=False)

     オブジェクトの持つ doctest をデバッグします。

     'module' および 'name' 引数は上の *note testsource(): 3ecd. と同じ
     です。指定したオブジェクトの docstring から合成された Python スクリ
     プトは一時ファイルに書き出され、その後 Python デバッガ *note pdb:
     94. の制御下で実行されます。

     ローカルおよびグローバルの実行コンテキストには、‘module.__dict__’ の
     浅いコピーが使われます。

     オプション引数 'pm' は、検死デバッグを行うかどうかを指定します。
     'pm' が真の場合、スクリプトファイルは直接実行され、スクリプトが送出
     した例外が処理されないまま終了した場合にのみデバッガが立ち入ります
     。その場合、 *note pdb.post_mortem(): 1382. によって検死デバッグを
     起動し、処理されなかった例外から得られたトレースバックオブジェクト
     を渡します。 'pm' を指定しないか値を偽にした場合、 *note pdb.run():
     3ece. に適切な *note exec(): 164. 呼び出しを渡して、最初からデバッ
     ガの下でスクリプトを実行します。

 -- の関数: doctest.debug_src (src, pm=False, globs=None)

     文字列中の doctest をデバッグします。

     上の *note debug(): 3ecb. に似ていますが、doctest の入った文字列は
     'src' 引数で直接指定します。

     オプション引数 'pm' は上の *note debug(): 3ecb. と同じ意味です。

     オプション引数 'globs' には、ローカルおよびグローバルな実行コンテキ
     ストの両方に使われる辞書を指定します。'globs' を指定しない場合や
     ‘None’ にした場合、空の辞書を使います。辞書を指定した場合、実際の実
     行コンテキストには浅いコピーが使われます。

*note DebugRunner: 3eca. クラス自体や *note DebugRunner: 3eca. クラスが
送出する特殊な例外は、テストフレームワークの作者にとって非常に興味のある
ところですが、ここでは概要しか述べられません。詳しくはソースコード、とり
わけ *note DebugRunner: 3eca. の docstring (それ自体 doctest です!)  を
参照してください:

 -- クラス: doctest.DebugRunner (checker=None, verbose=None,
          optionflags=0)

     テストの失敗に遭遇するとすぐに例外を送出するようになっている *note
     DocTestRunner: 3e8d. のサブクラスです。予期しない例外が生じると、
     *note UnexpectedException: 3ed0. 例外を送出します。この例外には、テ
     スト、実行例、もともと送出された例外が入っています。期待する出力と
     実際の出力が一致しないために失敗した場合には、 *note
     DocTestFailure: 3ed1. 例外を送出します。この例外には、テスト、実行
     例、実際の出力が入っています。

     コンストラクタのパラメータやメソッドについては、 *note 拡張 API:
     3ea0. 節の *note DocTestRunner: 3e8d. のドキュメントを参照してくだ
     さい。

*note DebugRunner: 3eca. インスタンスの送出する例外には以下の二つがあり
ます:

 -- 例外: doctest.DocTestFailure (test, example, got)

     doctest 実行例の実際の出力が期待する出力と一致しなかったことを示す
     ために *note DocTestRunner: 3e8d. が送出する例外です。コンストラク
     タの引数は、インスタンスの同名の属性を初期化するために使われます。

*note DocTestFailure: 3ed1. では以下の属性を定義しています:

 -- の属性: DocTestFailure.test

     実行例が失敗した時に実行されていた *note DocTest: 1616. オブジェク
     トです。

 -- の属性: DocTestFailure.example

     失敗した *note Example: 3ea1. オブジェクトです。

 -- の属性: DocTestFailure.got

     実行例の実際の出力です。

 -- 例外: doctest.UnexpectedException (test, example, exc_info)

     doctest 実行例が予期しない例外を送出したことを示すために *note
     DocTestRunner: 3e8d. が送出する例外です。コンストラクタの引数は、イ
     ンスタンスの同名の属性を初期化するために使われます。

*note UnexpectedException: 3ed0. では以下の属性を定義しています:

 -- の属性: UnexpectedException.test

     実行例が失敗した時に実行されていた *note DocTest: 1616. オブジェク
     トです。

 -- の属性: UnexpectedException.example

     失敗した *note Example: 3ea1. オブジェクトです。

 -- の属性: UnexpectedException.exc_info

     予期しない例外についての情報の入ったタプルで、 *note
     sys.exc_info(): 656. が返すのと同じものです。


File: python.info,  Node: アドバイス,  Prev: デバッグ,  Up: doctest --- 対話型の Python の例をテストする

5.26.4.22 アドバイス
....................

冒頭でも触れたように、 *note doctest: 31. は、以下の三つの主な用途を持つ
ようになりました:

  1. docstring 内の実行例をチェックする。

  2. 回帰テストを行う。

  3. 実行可能なドキュメント/読めるテストの実現。

これらの用途にはそれぞれ違った要求があるので、区別して考えるのが重要です
。特に、docstring を曖昧なテストケースに埋もれさせてしまうとドキュメント
としては最悪です。

docstring の例は注意深く作成してください。 doctest の作成にはコツがあり
、きちんと学ぶ必要があります -- 最初はすんなりできないでしょう。実行例は
ドキュメントに本物の価値を与えます。良い例は、たくさんの言葉と同じ価値を
持つことがしばしばあります。注意深くやれば、例はユーザにとっては非常に有
益であり、時を経るにつれて、あるいは状況が変わった際に、何度も修正するの
にかかる時間を節約するという形で、きっと見返りを得るでしょう。私は今でも
、自分の *note doctest: 31. 実行例が "無害な" 変更を行った際にうまく動作
しなくなることに驚いています。

説明テキストの作成をけちらなければ、*note doctest: 31. は回帰テストの優
れたツールにもなり得ます。説明文と実行例を交互に記述していけば、実際に何
をどうしてテストしているのかもっと簡単に把握できるようになるでしょう。も
ちろん、コードベースのテストに詳しくコメントを入れるのも手ですが、そんな
ことをするプログラマはほとんどいません。多くの人々が、*note doctest: 31.
のアプローチをとった方がきれいにテストを書けると気づいています。おそらく
、これは単にコード中にコメントを書くのが少し面倒だからという理由でしょう
。私はもう少し穿った見方もしています。doctest ベースのテストを書くときの
自然な態度は、自分のソフトウェアのよい点を説明しようとして、実行例を使っ
て説明しようとするときの態度そのものだからだ、という理由です。それゆえに
、テストファイルは自然と単純な機能の解説から始め、論理的により複雑で境界
条件的なケースに進むような形になります。結果的に、一見ランダムに見えるよ
うな個別の機能をテストしている個別の関数の集まりではなく、首尾一貫した説
明ができるようになるのです。*note doctest: 31. によるテストの作成はまっ
たく別の取り組み方であり、テストと説明の区別をなくして、まったく違う結果
を生み出すのです。

回帰テストは特定のオブジェクトやファイルにまとめておくのがよいでしょう。
回帰テストの組み方にはいくつか選択肢があります:

   * テストケースを対話モードの実行例にして入れたテキストファイルを書き
     、 *note testfile(): 3e75. や *note DocFileSuite(): 3e9c. を使って
     そのファイルをテストします。この方法をお勧めします。最初から
     doctest を使うようにしている新たなプロジェクトでは、この方法が一番
     簡単です。

   * ‘_regrtest_topic’ という名前の関数を定義します。この関数には、ある
     トピックに対応するテストケースの入った docstring が一つだけ入ってい
     ます。この関数はモジュールと同じファイルの中にも置けますし、別のテ
     ストファイルに分けてもかまいません。

   * 回帰テストのトピックをテストケースの入った docstring に対応付けた辞
     書 ‘__test__’ 辞書を定義します。

テストコードをモジュールに組み込むことで、そのモジュールは、モジュール自
身がテストランナーになることができます。テストが失敗した場合には、問題箇
所をデバッグする際に、失敗したdoctestだけを再度実行することで、作成した
テストランナーを修正することができます。これがこのようなテストランナーの
最小例となります。

     if __name__ == '__main__':
         import doctest
         flags = doctest.REPORT_NDIFF|doctest.FAIL_FAST
         if len(sys.argv) > 1:
             name = sys.argv[1]
             if name in globals():
                 obj = globals()[name]
             else:
                 obj = __test__[name]
             doctest.run_docstring_examples(obj, globals(), name=name,
                                            optionflags=flags)
         else:
             fail, total = doctest.testmod(optionflags=flags)
             print(f"{fail} failures out of {total} tests")

脚注
....


File: python.info,  Node: unittest --- ユニットテストフレームワーク,  Next: unittest mock --- モックオブジェクトライブラリ,  Prev: doctest --- 対話型の Python の例をテストする,  Up: 開発ツール

5.26.5 ‘unittest’ -- ユニットテストフレームワーク
-------------------------------------------------

'ソースコード:' Lib/unittest/__init__.py(1)

__________________________________________________________________

(すでにテストの基本概念について詳しいようでしたら、この部分をとばして
*note アサートメソッド一覧: 3edc. に進むと良いでしょう。)

*note unittest: ef. ユニットテストフレームワークは元々 JUnit に触発され
たもので、 他の言語の主要なユニットテストフレームワークと同じような感じ
です。 テストの自動化、テスト用のセットアップやシャットダウンのコードの
共有、テストのコレクション化、そして報告フレームワークからのテストの独立
性をサポートしています。

これを実現するために、 *note unittest: ef. はいくつかの重要な概念をオブ
ジェクト指向の方法でサポートしています:

テストフィクスチャ (test fixture)

     テストフィクスチャ ('test fixture') とは、テスト実行のために必要な
     準備や終了処理を指します。例: テスト用データベースの作成・ディレク
     トリ・サーバプロセスの起動など。

テストケース (test case)

     テストケース ('test case') はテストの独立した単位で、各入力に対する
     結果をチェックします。テストケースを作成する場合は、 *note
     unittest: ef. が提供する *note TestCase: 41a. クラスを基底クラスと
     して利用することができます。

テストスイート (test suite)

     テストスイート ('test suite') はテストケースとテストスイートの集ま
     りで、同時に実行しなければならないテストをまとめる場合に使用します
     。

テストランナー (test runner)

     テストランナー ('test runner') はテストの実行を管理し結果を提供する
     要素です。ランナーはグラフィカルインターフェースやテキストインター
     フェースを使用しても構いませんし、テストの実行結果を示す特別な値を
     返しても構いません。

参考
....

*note doctest: 31. モジュール

     テストをサポートするもうひとつのモジュールで、このモジュールとは趣
     きがだいぶ異なります。

Simple Smalltalk Testing: With Patterns(2)

     Kent Beck のテスティングフレームワークに関する原論文で、ここに記載
     されたパターンを *note unittest: ef. が使用しています。

pytest(3)

     サードパーティのユニットテストフレームワークでより軽量な構文でテス
     トを書くことができます。例えば、‘assert func(10) == 42’ のように書
     きます。

The Python Testing Tools Taxonomy(4)

     多くの Python のテストツールが一覧で紹介されています。ファンクショ
     ナルテストのフレームワークやモックライブラリも掲載されています。

Testing in Python メーリングリスト(5)

     Python でテストやテストツールについての議論に特化したグループです。

Python のソースコード配布物にあるスクリプト
‘Tools/unittestgui/unittestgui.py’ はテストディスカバリとテスト実行のた
めの GUI ツールです。 主な目的は単体テストの初心者が簡単に使えるようにす
ることです。 実際の生産環境では、 Buildbot(6), Jenkins(7) 、 GitHub
Actions(8), AppVeyor(9) のような継続的インテグレーションシステムでテスト
を実行することを推奨します。

* Menu:

* 基本的な例: 基本的な例<2>.
* コマンドラインインターフェイス: コマンドラインインターフェイス<5>.
* テストディスカバリ::
* テストコードの構成::
* 既存テストコードの再利用::
* テストのスキップと予期された失敗::
* サブテストを利用して繰り返しテストの区別を付ける::
* クラスと関数::
* クラスとモジュールのフィクスチャ::
* シグナルハンドリング::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/unittest/__init__.py

   (2) 
https://web.archive.org/web/20150315073817/http://www.xprogramming.com/testfram.htm

   (3) https://docs.pytest.org/

   (4) https://wiki.python.org/moin/PythonTestingToolsTaxonomy

   (5) http://lists.idyll.org/listinfo/testing-in-python

   (6) https://buildbot.net/

   (7) https://www.jenkins.io/

   (8) https://github.com/features/actions

   (9) https://www.appveyor.com/


File: python.info,  Node: 基本的な例<2>,  Next: コマンドラインインターフェイス<5>,  Up: unittest --- ユニットテストフレームワーク

5.26.5.1 基本的な例
...................

*note unittest: ef. モジュールには、テストの開発や実行の為の優れたツール
が用意されており、この節では、その一部を紹介します。ほとんどのユーザとっ
ては、ここで紹介するツールだけで十分でしょう。

以下は、三つの文字列メソッドをテストするスクリプトです:

     import unittest

     class TestStringMethods(unittest.TestCase):

         def test_upper(self):
             self.assertEqual('foo'.upper(), 'FOO')

         def test_isupper(self):
             self.assertTrue('FOO'.isupper())
             self.assertFalse('Foo'.isupper())

         def test_split(self):
             s = 'hello world'
             self.assertEqual(s.split(), ['hello', 'world'])
             # check that s.split fails when the separator is not a string
             with self.assertRaises(TypeError):
                 s.split(2)

     if __name__ == '__main__':
         unittest.main()

テストケースは、 *note unittest.TestCase: 41a. のサブクラスとして作成し
ます。メソッド名が ‘test’ で始まる三つのメソッドがテストです。テストラン
ナーはこの命名規約によってテストを行うメソッドを検索します。

これらのテスト内では、予定の結果が得られていることを確かめるために *note
assertEqual(): 4f2. を、条件のチェックに *note assertTrue(): 4f0. や
*note assertFalse(): 4f1. を、例外が発生する事を確認するために *note
assertRaises(): 4f6. をそれぞれ呼び出しています。 *note assert: 936. 文
の代わりにこれらのメソッドを使用すると、テストランナーでテスト結果を集計
してレポートを作成する事ができます。

*note setUp(): 1308. および *note tearDown(): 1309. メソッドによって各テ
ストメソッドの前後に実行する命令を実装することが出来ます。 詳細は *note
テストコードの構成: 3edf. を参照してください。

最後のブロックは簡単なテストの実行方法を示しています。 *note
unittest.main(): fb0. は、テストスクリプトのコマンドライン用インターフェ
ースを提供します。コマンドラインから起動された場合、上記のスクリプトは以
下のような結果を出力します:

     ...
     ----------------------------------------------------------------------
     Ran 3 tests in 0.000s

     OK

‘-v’ オプションをテストスクリプトに渡すことで *note unittest.main():
fb0. はより冗長になり、以下のような出力をします:

     test_isupper (__main__.TestStringMethods.test_isupper) ... ok
     test_split (__main__.TestStringMethods.test_split) ... ok
     test_upper (__main__.TestStringMethods.test_upper) ... ok

     ----------------------------------------------------------------------
     Ran 3 tests in 0.001s

     OK

上の例が *note unittest: ef. モジュールで最もよく使われる機能で、ほとん
どのテストではこれで十分です。以下では全ての機能を一から解説しています。

バージョン 3.11 で変更: テストメソッドが（デフォルトの''None''以外の）戻
り値を返す挙動は現在非推奨です。


File: python.info,  Node: コマンドラインインターフェイス<5>,  Next: テストディスカバリ,  Prev: 基本的な例<2>,  Up: unittest --- ユニットテストフレームワーク

5.26.5.2 コマンドラインインターフェイス
.......................................

ユニットテストモジュールはコマンドラインから使って、モジュール、クラス、
あるいは個別のテストメソッドで定義されたテストを実行することが出来ます:

     python -m unittest test_module1 test_module2
     python -m unittest test_module.TestClass
     python -m unittest test_module.TestClass.test_method

モジュール名ならびに完全修飾されたクラス名やメソッド名の任意の組み合わせ
を一覧で渡すことが出来ます。

テストモジュールはファイルパスで指定することも出来ます:

     python -m unittest tests/test_something.py

そのため、テストモジュールを指定するのにシェルのファイル名補完が使えます
。指定されたファイルはやはりモジュールとしてインポート可能でなければなり
ません。パスから '.py' を取り除き、パスセパレータを '.'  に置き換えるこ
とでモジュール名に変換されます。モジュールとしてインポート可能でないテス
トファイルを実行したい場合は、代わりにそのファイルを直接実行するのが良い
でしょう。

テスト実行時に (より冗長な) 詳細を表示するには -v フラグを渡します:

     python -m unittest -v test_module

引数無しで実行すると *note テストディスカバリ: 3ee1. が開始されます:

     python -m unittest

コマンドラインプションの一覧を表示するには以下のコマンドを実行します:

     python -m unittest -h

バージョン 3.2 で変更: 以前のバージョンでは、個々のテストメソッドしか実
行することができず、モジュール単位やクラス単位で実行することは不可能でし
た。

* Menu:

* コマンドラインオプション: コマンドラインオプション<5>.


File: python.info,  Node: コマンドラインオプション<5>,  Up: コマンドラインインターフェイス<5>

5.26.5.3 コマンドラインオプション
.................................

‘unittest’ には以下のコマンドラインオプションがあります:

 -- Option: -b, --buffer

     標準出力と標準エラーのストリームをテストの実行中にバッファします。
     テストが成功している間は結果の出力は破棄されます。テストの失敗やエ
     ラーの場合、出力は通常通り表示され、エラーメッセージに追加されます
     。

 -- Option: -c, --catch

     ‘Control-C’ を実行中のテストが終了するまで遅延させ、そこまでの結果
     を出力します。二回目の ‘Control-C’ は、通常通り *note
     KeyboardInterrupt: 99f. の例外を発生させます。

     この機能の仕組みについては、*note シグナルハンドリング: 3ee5. を参
     照してください。

 -- Option: -f, --failfast

     初回のエラーもしくは失敗の時にテストを停止します。

 -- Option: -k

     パターンや部分文字列にマッチするテストメソッドとテストクラスのみ実
     行します。このオプションは複数回使うことができ、その場合はすべての
     パターンにマッチするテストケースが実行対象に含まれます。

     ワイルドカード(‘*’) を含むパターンは *note fnmatch.fnmatchcase():
     180b. を使用してテスト名と照合され、それ以外の場合は単純な大文字と
     小文字を区別した部分文字列マッチングが使用されます。

     パターンは、テストローダがインポートする時の完全修飾されたテストメ
     ソッド名と照合されます。

     たとえば、 ‘-k foo’ は ‘foo_tests.SomeTest.test_something’,
     ‘bar_tests.SomeTest.test_foo’ にマッチし、
     ‘bar_tests.FooTest.test_something’ はマッチしません。

 -- Option: --locals

     トレースバック内の局所変数を表示します。

 -- Option: --durations N

     Show the N slowest test cases (N=0 for all).

Added in version 3.2: コマンドラインオプションの ‘-b’、‘-c’、‘-f’ が追加
されました。

Added in version 3.5: コマンドラインオプション ‘--locals’。

Added in version 3.7: コマンドラインオプション ‘-k’。

Added in version 3.12: The command-line option ‘--durations’.

コマンドラインによってテストディスカバリ、すなわちプロジェクトの全テスト
を実行したりサブセットのみを実行したりすることも出来ます。


File: python.info,  Node: テストディスカバリ,  Next: テストコードの構成,  Prev: コマンドラインインターフェイス<5>,  Up: unittest --- ユニットテストフレームワーク

5.26.5.4 テストディスカバリ
...........................

Added in version 3.2.

unittest はシンプルなテストディスカバリをサポートします。このテストディ
スカバリに対応するために、テストが定義された全ファイルは *note modules:
1bc0. もしくは *note packages: 1bd1. としてプロジェクトの最上位のディス
カバリでインポート可能である必要があります (つまり、これらのファイルは
*note identifiers: 1df6. として有効である必要があるということです)。

テストディスカバリは *note TestLoader.discover(): fb2. で実装されていま
すが、コマンドラインから使う事も出来ます。その基本的な使い方は:

     cd project_directory
     python -m unittest discover

     注釈: ‘python -m unittest’ は ‘python -m unittest discover’ と等価
     なショートカットです。テストディスカバリに引数を渡したい場合は、
     ‘discover’ サブコマンドを明示的に使用しなければなりません。

‘discover’ サブコマンドには以下のオプションがあります:

 -- Option: -v, --verbose

     詳細な出力

 -- Option: -s, --start-directory directory

     ディスカバリを開始するディレクトリ (デフォルトは ‘.’)

 -- Option: -p, --pattern pattern

     テストファイル名を識別するパターン (デフォルトは ‘test*.py’)

 -- Option: -t, --top-level-directory directory

     プロジェクトの最上位のディスカバリのディレクトリ (デフォルトは開始
     のディレクトリ)

*note -s: 3eed. 、 *note -p: 3eef. 、および *note -t: 3ef1. オプションは
、この順番であれば位置引数として渡す事ができます。以下の二つのコマンドは
等価です:

     python -m unittest discover -s project_directory -p "*_test.py"
     python -m unittest discover project_directory "*_test.py"

パスと同様にパッケージ名を、例えば ‘myproject.subpackage.test’ のように
、開始ディレクトリとして渡すことができます。 指定したパッケージ名はイン
ポートされ、そのファイルシステム上の場所が開始ディレクトリとして使われま
す。

     注意: テストディスカバリはインポートによりテストを読み込みます。 一
     旦テストディスカバリが指定された開始ディレクトリから全テストファイ
     ルを見付けると、パスはインポートするパッケージ名に変換されます。 例
     えば、 ‘foo/bar/baz.py’ は ‘foo.bar.baz’ としてインポートされます。

     グローバルにインストールされたパッケージがあり、それとは異なるコピ
     ーでディスカバリしようとしたとき、誤った場所からインポートが行われ
     る 'かもしれません'。 その場合テストディスカバリは警告し、停止しま
     す。

     ディレクトリのパスではなくパッケージ名を開始ディレクトリに指定した
     場合、ディスカバリはインポートするいずれの場所も意図した場所とする
     ため、警告を受けないはずです。

テストモジュールとパッケージは、 *note load_tests プロトコル: 3ef3. によ
ってテストのロードとディスカバリをカスタマイズすることができます。

バージョン 3.4 で変更: テストディスカバリは開始ディレクトリとして *note
名前空間パッケージ: 1bd2. をサポートします。トップレベルのディレクトリも
指定する必要があることに注意してください(例えば ‘python -m unittest
discover -s root/namespace -t root’)。

バージョン 3.11 で変更: *note unittest: ef. dropped the *note namespace
packages: 1bd2. support in Python 3.11.  It has been broken since Python
3.7.  Start directory and subdirectories containing tests must be
regular package that have ‘__init__.py’ file.

Directories containing start directory still can be a namespace package.
In this case, you need to specify start directory as dotted package
name, and target directory explicitly.  For example:

     # proj/  <-- current directory
     #   namespace/
     #     mypkg/
     #       __init__.py
     #       test_mypkg.py

     python -m unittest discover -s namespace.mypkg -t .


File: python.info,  Node: テストコードの構成,  Next: 既存テストコードの再利用,  Prev: テストディスカバリ,  Up: unittest --- ユニットテストフレームワーク

5.26.5.5 テストコードの構成
...........................

ユニットテストの基本的な構成要素は、 'テストケース' -- 設定され正しさの
ためにチェックされるべき単独のシナリオ -- です。 *note unittest: ef. で
は、テストケースは *note unittest.TestCase: 41a. クラスのインスタンスで
表現されます。 独自のテストケースを作成するには *note TestCase: 41a. の
サブクラスを記述するか、 *note FunctionTestCase: 166e. を使用しなければ
なりません。

*note TestCase: 41a. インスタンスのテストコードは完全に独立していなけれ
ばなりません。 すなわち単独でか、他の様々なテストケースの任意の組み合わ
せのいずれかで実行可能でなければなりません。

最も単純な *note TestCase: 41a. のサブクラスは、特定のテストコードを実行
するためのテストメソッド (すなわち名前が ‘test’ で始まるメソッド) を実装
するだけで簡単に書くことができます:

     import unittest

     class DefaultWidgetSizeTestCase(unittest.TestCase):
         def test_default_widget_size(self):
             widget = Widget('The widget')
             self.assertEqual(widget.size(), (50, 50))

Note that in order to test something, we use one of the *note assert*
methods: 3edc. provided by the *note TestCase: 41a. base class.  If the
test fails, an exception will be raised with an explanatory message, and
*note unittest: ef. will identify the test case as a 'failure'.  Any
other exceptions will be treated as 'errors'.

テストは多くなり、それらの設定は繰り返しになるかもしれません。 幸いにも
、*note setUp(): 1308. メソッドを実装することで設定コードをくくり出すこ
とができます。 テストフレームワークは実行するテストごとに自動的に *note
setUp(): 1308. を呼びます:

     import unittest

     class WidgetTestCase(unittest.TestCase):
         def setUp(self):
             self.widget = Widget('The widget')

         def test_default_widget_size(self):
             self.assertEqual(self.widget.size(), (50,50),
                              'incorrect default size')

         def test_widget_resize(self):
             self.widget.resize(100,150)
             self.assertEqual(self.widget.size(), (100,150),
                              'wrong size after resize')

     注釈: いろいろなテストが実行される順序は、文字列の組み込みの順序で
     テストメソッド名をソートすることで決まります。

テスト中に *note setUp(): 1308. メソッドで例外が発生した場合、フレームワ
ークはそのテストに問題があるとみなし、そのテストメソッドは実行されません
。

同様に、テストメソッド実行後に片付けをする *note tearDown(): 1309. メソ
ッドを提供出来ます:

     import unittest

     class WidgetTestCase(unittest.TestCase):
         def setUp(self):
             self.widget = Widget('The widget')

         def tearDown(self):
             self.widget.dispose()

*note setUp(): 1308. が成功した場合、テストメソッドが成功したかどうかに
関わらず *note tearDown(): 1309. が実行されます。

そのようなテストコードのための作業環境は 'テストフィクスチャ (test
fixture)' と呼ばれます。 新しい TestCase インスタンスはある単一のテスト
フィクスチャとして作成され、個々のテストメソッドを実行するのに使われます
。 従って、 *note setUp(): 1308, *note tearDown(): 1309, ‘__init__()’ は
1回のテストにつき1回だけ呼び出されます。

テストケースの実装では、テストする機能に従ってテストをまとめるのをお勧め
します。 *note unittest: ef. はこのための機構、*note unittest: ef. の
*note TestSuite: dc1. クラスで表現される 'test suite'、を提供します。 た
いていの場合 *note unittest.main(): fb0. を呼び出しは正しい処理を行い、
モジュールの全テストケースを集めて実行します。

しかし、テストスイートの構築をカスタマイズしたい場合、自分ですることがで
きます:

     def suite():
         suite = unittest.TestSuite()
         suite.addTest(WidgetTestCase('test_default_widget_size'))
         suite.addTest(WidgetTestCase('test_widget_resize'))
         return suite

     if __name__ == '__main__':
         runner = unittest.TextTestRunner()
         runner.run(suite())

テストケースやテストコードの定義を (‘widget.py’ のような) テスト対象コー
ドと同じモジュールに置くことが出来ますが、テストコードを
(‘test_widget.py’ のような) 独立したモジュールに置くのには以下のような利
点があります:

   * テストモジュールだけをコマンドラインから独立に実行することができる
     。

   * テストコードと出荷するコードをより簡単に分ける事ができる。

   * 余程のことがない限り、テスト対象のコードに合わせてテストコードを変
     更することになりにくい。

   * テストコードは、テスト対象コードほど頻繁に変更されない。

   * テストコードをより簡単にリファクタリングすることができる。

   * Cで書いたモジュールのテストはどうせ独立したモジュールなのだから、同
     様にしない理由がない

   * テストの方策を変更した場合でも、ソースコードを変更する必要がない。


File: python.info,  Node: 既存テストコードの再利用,  Next: テストのスキップと予期された失敗,  Prev: テストコードの構成,  Up: unittest --- ユニットテストフレームワーク

5.26.5.6 既存テストコードの再利用
.................................

既存のテストコードが有るとき、このテストを *note unittest: ef. で実行し
ようとするために古いテスト関数をいちいち *note TestCase: 41a. クラスのサ
ブクラスに変換するのは大変です。

このような場合は、 *note unittest: ef. では *note TestCase: 41a. のサブ
クラスである *note FunctionTestCase: 166e. クラスを使い、既存のテスト関
数をラップします。初期設定と終了処理も行なえます。

以下のテストコードがあった場合:

     def testSomething():
         something = makeSomething()
         assert something.name is not None
         # ...

オプションの set-up と tear-down メソッドを持った同等のテストケースイン
スタンスは次のように作成します:

     testcase = unittest.FunctionTestCase(testSomething,
                                          setUp=makeSomethingDB,
                                          tearDown=deleteSomethingDB)

     注釈: *note FunctionTestCase: 166e. を使って既存のテストを *note
     unittest: ef. ベースのテスト体系に変換することができますが、この方
     法は推奨されません。時間を掛けて *note TestCase: 41a. のサブクラス
     に書き直した方が将来的なテストのリファクタリングが限りなく易しくな
     ります。

既存のテストが *note doctest: 31. を使って書かれている場合もあるでしょう
。その場合、 *note doctest: 31. は ‘DocTestSuite’ クラスを提供します。こ
のクラスは、既存の *note doctest: 31.ベースのテストから、自動的に *note
unittest.TestSuite: dc1. のインスタンスを作成します。


File: python.info,  Node: テストのスキップと予期された失敗,  Next: サブテストを利用して繰り返しテストの区別を付ける,  Prev: 既存テストコードの再利用,  Up: unittest --- ユニットテストフレームワーク

5.26.5.7 テストのスキップと予期された失敗
.........................................

Added in version 3.1.

unittest は特定のテストメソッドやテストクラス全体をスキップする仕組みを
備えています。さらに、この機能はテスト結果を「予期された失敗 (expected
failure)」とすることができ、テストが失敗しても *note TestResult: 113a. の
失敗数にはカウントされなくなります。

テストをスキップするには、 *note skip(): 1944. *note デコレータ: 6fc. か
その条件付きバージョンの一つを使うか、*note setUp(): 1308. やテストメソ
ッドの中で *note TestCase.skipTest(): 3ef9. を呼び出すか、あるいは直接
*note SkipTest: fb1. を送出するだけです。

基本的なスキップは以下のようになります:

     class MyTestCase(unittest.TestCase):

         @unittest.skip("demonstrating skipping")
         def test_nothing(self):
             self.fail("shouldn't happen")

         @unittest.skipIf(mylib.__version__ < (1, 3),
                          "not supported in this library version")
         def test_format(self):
             # Tests that work for only a certain version of the library.
             pass

         @unittest.skipUnless(sys.platform.startswith("win"), "requires Windows")
         def test_windows_support(self):
             # windows specific testing code
             pass

         def test_maybe_skipped(self):
             if not external_resource_available():
                 self.skipTest("external resource not available")
             # test code that depends on the external resource
             pass

このサンプルを冗長モードで実行すると以下のように出力されます:

     test_format (__main__.MyTestCase.test_format) ... skipped 'not supported in this library version'
     test_nothing (__main__.MyTestCase.test_nothing) ... skipped 'demonstrating skipping'
     test_maybe_skipped (__main__.MyTestCase.test_maybe_skipped) ... skipped 'external resource not available'
     test_windows_support (__main__.MyTestCase.test_windows_support) ... skipped 'requires Windows'

     ----------------------------------------------------------------------
     Ran 4 tests in 0.005s

     OK (skipped=4)

テストクラスは以下のようにメソッドをスキップすることができます:

     @unittest.skip("showing class skipping")
     class MySkippedTestCase(unittest.TestCase):
         def test_not_run(self):
             pass

*note TestCase.setUp(): 1308. もスキップすることができます。この機能はセ
ットアップの対象のリソースが使用不可能な時に便利です。

予期された失敗の機能を使用するには *note expectedFailure(): 3efa. デコレ
ータを使います。

     class ExpectedFailureTestCase(unittest.TestCase):
         @unittest.expectedFailure
         def test_fail(self):
             self.assertEqual(1, 0, "broken")

独自のスキップ用のデコレータの作成は簡単です。 そのためには、独自のデコ
レータのスキップしたい時点で *note skip(): 1944. を呼び出します。 以下の
デコレータはオブジェクトに指定した属性が無い場合にテストをスキップします
:

     def skipUnlessHasattr(obj, attr):
         if hasattr(obj, attr):
             return lambda func: func
         return unittest.skip("{!r} doesn't have {!r}".format(obj, attr))

以下のデコレータと例外はテストのスキップと予期された失敗を実装しています
:

 -- の関数: @unittest.skip (reason)

     デコレートしたテストを無条件でスキップします。'reason' にはテストを
     スキップした理由を記載します。

 -- の関数: @unittest.skipIf (condition, reason)

     'condition' が真の場合、デコレートしたテストをスキップします。

 -- の関数: @unittest.skipUnless (condition, reason)

     'condition' が偽の場合、デコレートしたテストをスキップします。

 -- の関数: @unittest.expectedFailure

     失敗またはエラーが予測されるものとしてテストをマークします。テスト
     が失敗するか ('test fixture' メソッドのいずれかではなく、) テスト関
     数そのものでエラーとなった場合に成功したとみなされます。テストが成
     功した場合は失敗とみなされます。

 -- 例外: unittest.SkipTest (reason)

     この例外はテストをスキップするために送出されます。

     ふつうはこれを直接送出する代わりに *note TestCase.skipTest(): 3ef9.
     やスキッピングデコレータの一つを使用出来ます。

スキップしたテストの前後では、 *note setUp(): 1308. および *note
tearDown(): 1309. は実行されません。同様に、スキップしたクラスの前後では
、 *note setUpClass(): a1d. および *note tearDownClass(): 1306. は実行さ
れません。スキップしたモジュールの前後では、 ‘setUpModule()’ および
‘tearDownModule()’ は実行されません。


File: python.info,  Node: サブテストを利用して繰り返しテストの区別を付ける,  Next: クラスと関数,  Prev: テストのスキップと予期された失敗,  Up: unittest --- ユニットテストフレームワーク

5.26.5.8 サブテストを利用して繰り返しテストの区別を付ける
.........................................................

Added in version 3.4.

テストの間にとても小さな差異がある場合（例えばいくつかのパラメータなど）
、unittestでは *note subTest(): fae. コンテキストマネージャを使用してテ
ストメソッドの内部でそれらを区別することができます。

例えば以下のテストは:

     class NumbersTest(unittest.TestCase):

         def test_even(self):
             """
             Test that numbers between 0 and 5 are all even.
             """
             for i in range(0, 6):
                 with self.subTest(i=i):
                     self.assertEqual(i % 2, 0)

以下の出力をします:

     ======================================================================
     FAIL: test_even (__main__.NumbersTest.test_even) (i=1)
     Test that numbers between 0 and 5 are all even.
     ----------------------------------------------------------------------
     Traceback (most recent call last):
       File "subtests.py", line 11, in test_even
         self.assertEqual(i % 2, 0)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
     AssertionError: 1 != 0

     ======================================================================
     FAIL: test_even (__main__.NumbersTest.test_even) (i=3)
     Test that numbers between 0 and 5 are all even.
     ----------------------------------------------------------------------
     Traceback (most recent call last):
       File "subtests.py", line 11, in test_even
         self.assertEqual(i % 2, 0)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
     AssertionError: 1 != 0

     ======================================================================
     FAIL: test_even (__main__.NumbersTest.test_even) (i=5)
     Test that numbers between 0 and 5 are all even.
     ----------------------------------------------------------------------
     Traceback (most recent call last):
       File "subtests.py", line 11, in test_even
         self.assertEqual(i % 2, 0)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
     AssertionError: 1 != 0

サブテスト無しの場合、最初の失敗で実行は停止し、‘i’ の値が表示されないた
めエラーの原因を突き止めるのは困難になります:

     ======================================================================
     FAIL: test_even (__main__.NumbersTest.test_even)
     ----------------------------------------------------------------------
     Traceback (most recent call last):
       File "subtests.py", line 32, in test_even
         self.assertEqual(i % 2, 0)
     AssertionError: 1 != 0


File: python.info,  Node: クラスと関数,  Next: クラスとモジュールのフィクスチャ,  Prev: サブテストを利用して繰り返しテストの区別を付ける,  Up: unittest --- ユニットテストフレームワーク

5.26.5.9 クラスと関数
.....................

この節では、 *note unittest: ef. モジュールのAPIの詳細について説明します
。

* Menu:

* テストクラス::
* テストのグループ化::
* テストのロードと起動::


File: python.info,  Node: テストクラス,  Next: テストのグループ化,  Up: クラスと関数

5.26.5.10 テストクラス
......................

 -- クラス: unittest.TestCase (methodName='runTest')

     *note TestCase: 41a. クラスのインスタンスは、 *note unittest: ef. の
     世界における論理的なテストの単位を示します。このクラスをベースクラ
     スとして使用し、必要なテストを具象サブクラスに実装します。 *note
     TestCase: 41a. クラスでは、テストランナーがテストを実行するため の
     インターフェースと、各種の失敗をチェックしレポートするためのメソッ
     ドを実装しています。

     *note TestCase: 41a. の各インスタンスは 'methodName' という名前の単
     一の基底メソッドを実行します。 *note TestCase: 41a. を使用する大半
     の場合 'methodName' を変更したりデフォルトの ‘runTest()’ メソッドを
     再実装することはありません。

     バージョン 3.2 で変更: *note TestCase: 41a. が 'methodName' を指定
     しなくてもインスタンス化できるようになりました。これにより対話的イ
     ンタプリタから *note TestCase: 41a. を簡単に試せるようになりました
     。

     *note TestCase: 41a. のインスタンスのメソッドは3種類のグループを提
     供します。 1つ目のグループはテストの実行で使用されます。 2つ目のグ
     ループは条件のチェックおよび失敗のレポートを行うテストの実装で使用
     されます。 3つ目のグループである問い合わせ用のメソッドによってテス
     ト自身の情報が収集されます。

     はじめのグループ (テスト実行) に含まれるメソッドは以下の通りです:

      -- メソッド: setUp ()

          テストフィクスチャの準備のために呼び出されるメソッドです。テス
          トメソッドの直前に呼び出されます。このメソッドで *note
          AssertionError: 675. や *note SkipTest: fb1. 以外の例外が発生
          した場合、テストの失敗ではなくエラーとされます。デフォルトの実
          装では何も行いません。

      -- メソッド: tearDown ()

          テストメソッドが実行され、結果が記録された直後に呼び出されるメ
          ソッドです。 このメソッドはテストメソッドで例外が投げられても
          呼び出されます。 そのため、サブクラスでこのメソッドを実装する
          場合は、内部状態を確認することが必要になるでしょう。 このメソ
          ッドで *note AssertionError: 675. や *note SkipTest: fb1. 以外
          の例外が発生した場合、テストの失敗とは別のエラーとみなされます
          (従って報告されるエラーの総数は増えます)。 このメソッドは、テ
          ストの結果に関わらず *note setUp(): 1308. が成功した場合にのみ
          呼ばれます。 デフォルトの実装では何も行いません。

      -- メソッド: setUpClass ()

          個別のクラス内のテストが実行される前に呼び出されるクラスメソッ
          ドです。 ‘setUpClass’ はクラスを唯一の引数として取り、 *note
          classmethod(): 14c. でデコレートされていなければなりません:

               @classmethod
               def setUpClass(cls):
                   ...

          詳しくは *note クラスとモジュールのフィクスチャ: 3f02. を参照
          してください。

          Added in version 3.2.

      -- メソッド: tearDownClass ()

          個別のクラス内のテストが実行された後に呼び出されるクラスメソッ
          ドです。 ‘tearDownClass’ はクラスを唯一の引数として取り、
          *note classmethod(): 14c. でデコレートされていなければなりませ
          ん:

               @classmethod
               def tearDownClass(cls):
                   ...

          詳しくは *note クラスとモジュールのフィクスチャ: 3f02. を参照
          してください。

          Added in version 3.2.

      -- メソッド: run (result=None)

          テストを実行し、テスト結果を 'result' に指定された *note
          TestResult: 113a. オブジェクトにまとめます。 'result' が省略さ
          れるか ‘None’ が渡された場合、 (*note defaultTestResult():
          3f03. メソッドを呼んで) 一時的な結果オブジェクトを生成し、使用
          します。 結果オブジェクトは *note run(): 1139. の呼び出し元に
          返されます。

          このメソッドは、単に *note TestCase: 41a. インスタンスを呼び出
          した場合と同様に振る舞います。

          バージョン 3.3 で変更: 以前のバージョンの ‘run’ は結果オブジェ
          クトを返しませんでした。また *note TestCase: 41a. インスタンス
          を呼び出した場合も同様でした。

      -- メソッド: skipTest (reason)

          テストメソッドや *note setUp(): 1308. が現在のテストをスキップ
          する間に呼ばれます。詳細については、 *note
          テストのスキップと予期された失敗: 3ef8. を参照してください。

          Added in version 3.1.

      -- メソッド: subTest (msg=None, **params)

          このメソッドを囲っているブロックをサブテストとして実行するコン
          テキストマネージャを返します。 'msg' と 'params' はサブテスト
          が失敗したときに表示されるオプションの任意の値で、どんな値が使
          われたかを明確にするものです。

          テストケースには subtest 宣言を幾らでも含めることができ、任意
          にネストすることができます。

          詳細は *note サブテストを利用して繰り返しテストの区別を付ける:
          faf. を参照してください。

          Added in version 3.4.

      -- メソッド: debug ()

          テスト結果を収集せずにテストを実行します。例外が呼び出し元に通
          知されます。また、テストをデバッガで実行することができます。
     *note TestCase: 41a. クラスは失敗の検査と報告を行う多くのメソッドを
     提供しています。 以下の表は最も一般的に使われるメソッドを列挙してい
     ます (より多くのアサートメソッドについては表の下を見てください):

     メソッド                                      確認事項                          初出
                                                                                     
     ----------------------------------------------------------------------------------------------------
                                                                                     
     *note assertEqual(a, b): 4f2.                 ‘a == b’
                                                   
                                                                                     
     *note assertNotEqual(a, b): 4f3.              ‘a != b’
                                                   
                                                                                     
     *note assertTrue(x): 4f0.                     ‘bool(x) is True’
                                                   
                                                                                     
     *note assertFalse(x): 4f1.                    ‘bool(x) is False’
                                                   
                                                                                     
     *note assertIs(a, b): 130a.                   ‘a is b’                          3.1
                                                                                     
                                                                                     
     *note assertIsNot(a, b): 130b.                ‘a is not b’                      3.1
                                                                                     
                                                                                     
     *note assertIsNone(x): 125b.                  ‘x is None’                       3.1
                                                                                     
                                                                                     
     *note assertIsNotNone(x): 125c.               ‘x is not None’                   3.1
                                                                                     
                                                                                     
     *note assertIn(a, b): 1313.                   ‘a in b’                          3.1
                                                                                     
                                                                                     
     *note assertNotIn(a, b): 1314.                ‘a not in b’                      3.1
                                                                                     
                                                                                     
     *note assertIsInstance(a, b): 130c.           ‘isinstance(a, b)’                3.2
                                                                                     
                                                                                     
     *note assertNotIsInstance(a, b): 130d.        ‘not isinstance(a, b)’            3.2
                                                                                     

     全てのアサートメソッドは 'msg' 引数を受け取り、指定された場合、失敗
     時のエラーメッセージとして使われます。 (*note longMessage: 1305. も
     参照してください)。 'msg' キーワード引数は *note assertRaises():
     4f6. 、 *note assertRaisesRegex(): 4f8. 、 *note assertWarns():
     1137. 、 *note assertWarnsRegex(): 1138. には、そのメソッドをコンテ
     キストマネージャとして使った場合にのみ使えます。

      -- メソッド: assertEqual (first, second, msg=None)

          'first' と 'second' が等しいことをテストします。両者が等しくな
          い場合、テストは失敗です。

          さらに、 'first' と 'second' が厳密に同じ型であり、list、
          tuple、dict、set、frozenset もしくは str のいずれか、またはサ
          ブクラスが *note addTypeEqualityFunc(): 1317. に登録されている
          任意の型の場合、より有用なデフォルトのエラーメッセージを生成す
          るために、その型特有の比較関数が呼ばれます（*note
          型固有のメソッドの一覧: 3f04. も参照してください）。

          バージョン 3.1 で変更: 自動で型固有の比較関数が呼ばれるように
          なりました。

          バージョン 3.2 で変更: 文字列比較のデフォルトの比較関数として
          *note assertMultiLineEqual(): 1312. が追加されました。

      -- メソッド: assertNotEqual (first, second, msg=None)

          'first' と 'second' が等しくないことをテストします。両者が等し
          い場合、テストは失敗です。

      -- メソッド: assertTrue (expr, msg=None)
      -- メソッド: assertFalse (expr, msg=None)

          'expr' が真 (偽) であることをテストします。

          このメソッドは、‘bool(expr) is True’ と等価であり、‘expr is
          True’ と等価ではないことに注意が必要です (後者のためには、
          ‘assertIs(expr, True)’ が用意されています)。また、専用のメソッ
          ドが使用できる場合には、そちらを使用してください (例えば
          ‘assertTrue(a == b)’ の代わりに ‘assertEqual(a, b)’ を使用して
          ください)。そうすることにより、テスト失敗時のエラーメッセージ
          を詳細に表示することができます。

      -- メソッド: assertIs (first, second, msg=None)
      -- メソッド: assertIsNot (first, second, msg=None)

          'first' と 'second' が同じオブジェクトであること (またはそうで
          ないこと) をテストします。

          Added in version 3.1.

      -- メソッド: assertIsNone (expr, msg=None)
      -- メソッド: assertIsNotNone (expr, msg=None)

          'expr' が ‘None’ であること (および、そうでないこと) をテスト
          します。

          Added in version 3.1.

      -- メソッド: assertIn (member, container, msg=None)
      -- メソッド: assertNotIn (member, container, msg=None)

          'member' が 'container' に含まれること (またはそうでないこと)
          をテストします。

          Added in version 3.1.

      -- メソッド: assertIsInstance (obj, cls, msg=None)
      -- メソッド: assertNotIsInstance (obj, cls, msg=None)

          'obj' が 'cls' のインスタンスであること (あるいはそうでないこ
          と) をテストします (この 'cls' は、 *note isinstance(): 40e. が
          扱うことのできる、クラスもしくはクラスのタプルである必要があり
          ます)。正確な型をチェックするためには、 *note
          assertIs(type(obj), cls): 130a. を使用してください。

          Added in version 3.2.

     以下のメソッドを使用して例外、警告、およびログメッセージの発生を確
     認することが出来ます:

     メソッド                                                      確認事項                                   初出
                                                                                                              
     --------------------------------------------------------------------------------------------------------------------------
                                                                                                              
     *note assertRaises(exc, fun, *args, **kwds): 4f6.             ‘fun(*args, **kwds)’ が 'exc' を送出する
                                                                   
                                                                                                              
     *note assertRaisesRegex(exc, r, fun, *args, **kwds): 4f8.     ‘fun(*args, **kwds)’ が 'exc' を送出して   3.1
                                                                   メッセージが正規表現 'r' とマッチする      
                                                                   
                                                                                                              
     *note assertWarns(warn, fun, *args, **kwds): 1137.            ‘fun(*args, **kwds)’ が 'warn' を送出す    3.2
                                                                   る                                         
                                                                   
                                                                                                              
     *note assertWarnsRegex(warn, r, fun, *args, **kwds): 1138.    ‘fun(*args, **kwds)’ が 'warn' を送出し    3.2
                                                                   てメッセージが正規表現 'r' とマッチする    
                                                                   
                                                                                                              
     *note assertLogs(logger, level): 824.                         ‘with’ ブロックが 最低 'level' で          3.4
                                                                   'logger' を使用する                        
                                                                   
                                                                                                              
     *note assertNoLogs(logger, level): 823.                       The ‘with’ block does not log on           3.10
                                                                                                              
                                                                        'logger' with minimum 'level'
                                                                   

      -- メソッド: assertRaises (exception, callable, *args, **kwds)

      -- メソッド: assertRaises (exception, *, msg=None)

          'callable' を呼び出した時に例外が発生することをテストします。
          *note assertRaises(): 4f6. で指定した位置パラメータとキーワー
          ドパラメータを該当メソッドに渡します。 'exception' が送出され
          た場合、テストは成功です。また、他の例外が投げられた場合はエラ
          ー、例外が送出されなかった場合は失敗になります。複数の例外をキ
          ャッチする場合には、例外クラスのタプルを 'exception' に指定し
          てください。

          'exception' 引数のみ（またはそれに加えて 'msg' 引数）が渡され
          た場合には、コンテキストマネージャが返されます。これにより関数
          名を渡す形式ではなく、インラインでテスト対象のコードを書くこと
          ができます:

               with self.assertRaises(SomeException):
                   do_something()

          コンテキストマネージャとして使われたときは、 *note
          assertRaises(): 4f6. は加えて 'msg' キーワード引数も受け付けま
          す。

          このコンテキストマネージャは ‘exception’ で指定されたオブジェ
          クトを格納します。これにより、例外発生時の詳細な確認をおこなう
          ことができます:

               with self.assertRaises(SomeException) as cm:
                   do_something()

               the_exception = cm.exception
               self.assertEqual(the_exception.error_code, 3)

          バージョン 3.1 で変更: *note assertRaises(): 4f6. がコンテキス
          トマネージャとして使えるようになりました。

          バージョン 3.2 で変更: ‘exception’ 属性が追加されました。

          バージョン 3.3 で変更: コンテキストマネージャとして使用したと
          きに 'msg' キーワード引数が追加されました。

      -- メソッド: assertRaisesRegex (exception, regex, callable, *args,
               **kwds)

      -- メソッド: assertRaisesRegex (exception, regex, *, msg=None)

          *note assertRaises(): 4f6. と同等ですが、例外の文字列表現が
          'regex' にマッチすることもテストします。 'regex' は正規表現オ
          ブジェクトか、 *note re.search(): 11fd. が扱える正規表現が書か
          れた文字列である必要があります。例えば以下のようになります:

               self.assertRaisesRegex(ValueError, "invalid literal for.*XYZ'$",
                                      int, 'XYZ')

          もしくは:

               with self.assertRaisesRegex(ValueError, 'literal'):
                  int('XYZ')

          Added in version 3.1: ‘assertRaisesRegexp’ という名前で追加さ
          れました。

          バージョン 3.2 で変更: *note assertRaisesRegex(): 4f8. にリネ
          ームされました。

          バージョン 3.3 で変更: コンテキストマネージャとして使用したと
          きに 'msg' キーワード引数が追加されました。

      -- メソッド: assertWarns (warning, callable, *args, **kwds)

      -- メソッド: assertWarns (warning, *, msg=None)

          'callable' を呼び出した時に警告が発生することをテストします。
          *note assertWarns(): 1137. で指定した位置パラメータとキーワー
          ドパラメータを該当メソッドに渡します。 'warning' が発生した場
          合にテストが成功し、そうでなければ失敗になります。例外が送出さ
          れた場合はエラーになります。複数の警告を捕捉する場合には、警告
          クラスのタプルを 'warnings' に指定してください。

          'warning' 引数のみ（またはそれに加えて 'msg' 引数）が渡された
          場合には、コンテキストマネージャが返されます。これにより関数名
          を渡す形式ではなく、インラインでテスト対象のコードを書くことが
          できます:

               with self.assertWarns(SomeWarning):
                   do_something()

          コンテキストマネージャとして使われたときは、 *note
          assertWarns(): 1137. は加えて 'msg' キーワード引数も受け付けま
          す。

          このコンテキストマネージャは、捕捉した警告オブジェクトを
          ‘warning’ 属性に、警告が発生したソース行を ‘filename’ 属性と
          ‘lineno’ 属性に格納します。これは警告発生時に捕捉された警告に
          対して追加の確認を行いたい場合に便利です:

               with self.assertWarns(SomeWarning) as cm:
                   do_something()

               self.assertIn('myfile.py', cm.filename)
               self.assertEqual(320, cm.lineno)

          このメソッドは呼び出されたときに警告フィルタを無視して動作しま
          す。

          Added in version 3.2.

          バージョン 3.3 で変更: コンテキストマネージャとして使用したと
          きに 'msg' キーワード引数が追加されました。

      -- メソッド: assertWarnsRegex (warning, regex, callable, *args,
               **kwds)

      -- メソッド: assertWarnsRegex (warning, regex, *, msg=None)

          *note assertWarns(): 1137. と同等ですが、警告メッセージが
          'regex' にマッチすることもテストします。 'regex' は正規表現オ
          ブジェクトか、 *note re.search(): 11fd. が扱える正規表現が書か
          れた文字列である必要があります。例えば以下のようになります:

               self.assertWarnsRegex(DeprecationWarning,
                                     r'legacy_function\(\) is deprecated',
                                     legacy_function, 'XYZ')

          もしくは:

               with self.assertWarnsRegex(RuntimeWarning, 'unsafe frobnicating'):
                   frobnicate('/etc/passwd')

          Added in version 3.2.

          バージョン 3.3 で変更: コンテキストマネージャとして使用したと
          きに 'msg' キーワード引数が追加されました。

      -- メソッド: assertLogs (logger=None, level=None)

          'logger' かその子ロガーのうちの1つに、少なくとも1つのログメッ
          セージが少なくとも与えられた 'level' で出力されることをテスト
          するコンテキストマネージャです。

          If given, 'logger' should be a *note logging.Logger: b1d.
          object or a *note str: 418. giving the name of a logger.  The
          default is the root logger, which will catch all messages that
          were not blocked by a non-propagating descendent logger.

          If given, 'level' should be either a numeric logging level or
          its string equivalent (for example either ‘"ERROR"’ or *note
          logging.ERROR: 1c60.).  The default is *note logging.INFO:
          1c5e.

          ‘with’ ブロック内で出たメッセージの少なくとも一つが 'logger' お
          よび 'level' 条件に合っている場合、このテストをパスします。そ
          れ以外の場合は失敗です。

          コンテキストマネージャから返されるオブジェクトは、条件に該当す
          るログメッセージを追跡し続ける記録のためのヘルパーです。 この
          オブジェクトには2つの属性があります:

           -- の属性: records

               該当するログメッセージを表す *note logging.LogRecord:
               fb3. オブジェクトのリスト。

           -- の属性: output

               該当するメッセージ出力をフォーマットした *note str: 418.
               オブジェクトのリスト。

          以下はプログラム例です:

               with self.assertLogs('foo', level='INFO') as cm:
                   logging.getLogger('foo').info('first message')
                   logging.getLogger('foo.bar').error('second message')
               self.assertEqual(cm.output, ['INFO:foo:first message',
                                            'ERROR:foo.bar:second message'])

          Added in version 3.4.

      -- メソッド: assertNoLogs (logger=None, level=None)

          A context manager to test that no messages are logged on the
          'logger' or one of its children, with at least the given
          'level'.

          'logger' が与えられた場合、 *note logging.Logger: b1d. オブジ
          ェクトもしくはロガーの名前である *note str: 418. であるべきで
          す。 デフォルトはルートロガーで、これは全てのメッセージを掴ま
          えます。

          If given, 'level' should be either a numeric logging level or
          its string equivalent (for example either ‘"ERROR"’ or *note
          logging.ERROR: 1c60.).  The default is *note logging.INFO:
          1c5e.

          *note assertLogs(): 824. と異なり、このコンテキストマネージャ
          は何も返しません。

          Added in version 3.10.

     より具体的な確認を行うために以下のメソッドが用意されています:

     メソッド                                    確認事項                             初出
                                                                                      
     ----------------------------------------------------------------------------------------------------
                                                                                      
     *note assertAlmostEqual(a, b): 4f4.         ‘round(a-b, 7) == 0’
                                                 
                                                                                      
     *note assertNotAlmostEqual(a, b): 4f5.      ‘round(a-b, 7) != 0’
                                                 
                                                                                      
     *note assertGreater(a, b): 130e.            ‘a > b’                              3.1
                                                                                      
                                                                                      
     *note assertGreaterEqual(a, b): 130f.       ‘a >= b’                             3.1
                                                                                      
                                                                                      
     *note assertLess(a, b): 1310.               ‘a < b’                              3.1
                                                                                      
                                                                                      
     *note assertLessEqual(a, b): 1311.          ‘a <= b’                             3.1
                                                                                      
                                                                                      
     *note assertRegex(s, r): 4f7.               ‘r.search(s)’                        3.1
                                                                                      
                                                                                      
     *note assertNotRegex(s, r): 4f9.            ‘not r.search(s)’                    3.2
                                                                                      
                                                                                      
     *note assertCountEqual(a, b): 11fb.         'a' と 'b' に、順番によらず同じ要    3.2
                                                 素が同じ数だけある。                 
                                                 

      -- メソッド: assertAlmostEqual (first, second, places=7, msg=None,
               delta=None)
      -- メソッド: assertNotAlmostEqual (first, second, places=7,
               msg=None, delta=None)

          'first' と 'second' が近似的に等しい (等しくない) ことをテスト
          します。これは、'places' (デフォルト7) で指定した小数位で丸め
          た差分をゼロと比較することで行われます。これらのメソッドは
          (*note round(): 12a8. と同様に) '小数位' を指定するのであって
          、'有効桁数' を指定するのではないことに注意してください。

          'places' の代わりに 'delta' が渡された場合には、'first' と
          'second' の差分が 'delta' 以下 (以上) であることをテストします
          。

          'delta' と 'places' の両方が指定された場合は *note TypeError:
          502. が送出されます。

          バージョン 3.2 で変更: *note assertAlmostEqual(): 4f4. は、オ
          ブジェクトが等しい場合には自動で近似的に等しいとみなすようにな
          りました。 *note assertNotAlmostEqual(): 4f5. は、オブジェクト
          が等しい場合には自動的に失敗するようになりました。 'delta' 引
          数が追加されました。

      -- メソッド: assertGreater (first, second, msg=None)
      -- メソッド: assertGreaterEqual (first, second, msg=None)
      -- メソッド: assertLess (first, second, msg=None)
      -- メソッド: assertLessEqual (first, second, msg=None)

          'first' が 'second' と比べて、メソッド名に対応して >, >=, < も
          しくは <= であることをテストします。そうでない場合はテストは失
          敗です:

               >>> self.assertGreaterEqual(3, 4)
               AssertionError: "3" unexpectedly not greater than or equal to "4"

          Added in version 3.1.

      -- メソッド: assertRegex (text, regex, msg=None)
      -- メソッド: assertNotRegex (text, regex, msg=None)

          'regex' の検索が 'text' とマッチする (またはマッチしない) こと
          をテストします。テスト失敗時には、エラーメッセージにパターンと
          'text' が表示されます（もしくは、パターンと意図しないかたちで
          マッチした 'text' の一部が表示されます）。 'regex' は正規表現
          オブジェクトか、 *note re.search(): 11fd. が扱える正規表現が書
          かれた文字列である必要があります。

          Added in version 3.1: ‘assertRegexpMatches’ という名前で追加さ
          れました。

          バージョン 3.2 で変更: メソッド ‘assertRegexpMatches()’ は
          *note assertRegex(): 4f7. にリネームされました。

          Added in version 3.2: *note assertNotRegex(): 4f9.。

      -- メソッド: assertCountEqual (first, second, msg=None)

          シーケンス 'first' が 'second' と同じ要素を含んでいることをテ
          ストします。要素の順序はテスト結果に影響しません。要素が含まれ
          ていない場合には、シーケンスの差分がエラーメッセージとして表示
          されます。

          'first' と 'second' の比較では、重複した要素は無視 'されません
          '。両者に同じ数の要素が含まれていることを検証します。このメソ
          ッドは ‘assertEqual(Counter(list(first)),
          Counter(list(second)))’ と同等に振る舞うことに加えて、ハッシュ
          化できないオブジェクトのシーケンスでも動作します。

          Added in version 3.2.

     *note assertEqual(): 4f2. メソッドは、同じ型のオブジェクトの等価性
     確認のために、型ごとに特有のメソッドにディスパッチします。これらの
     メソッドは、ほとんどの組み込み型用のメソッドは既に実装されています
     。さらに、 *note addTypeEqualityFunc(): 1317. を使う事で新たなメソ
     ッドを登録することができます:

      -- メソッド: addTypeEqualityFunc (typeobj, function)

          *note assertEqual(): 4f2. で呼び出される型特有のメソッドを登録
          します。登録するメソッドは、比較する2つのオブジェクトの型が厳
          密に 'typeobj' と同じ (サブクラスでもいけません) の場合に等価
          性を確認します。 'function' は *note assertEqual(): 4f2. と同
          様に、2つの位置引数と、3番目に msg=None のキーワード引数を取れ
          る必要があります。このメソッドは、始めの2つに指定したパラメー
          タ間の差分を検出した時に *note self.failureException(msg):
          3f07. の例外を投げる必要があります。この例外を投げる際は、出来
          る限り、エラーの内容が分かる有用な情報と差分の詳細をエラーメッ
          セージに含めてください。

          Added in version 3.1.

     *note assertEqual(): 4f2. が自動的に呼び出す型特有のメソッドの概要
     を以下の表示に記載しています。これらのメソッドは通常は直接呼び出す
     必要がないことに注意が必要です。

     メソッド                                      比較の対象                        初出
                                                                                     
     ---------------------------------------------------------------------------------------------------
                                                                                     
     *note assertMultiLineEqual(a, b): 1312.       文字列                            3.1
                                                                                     
                                                                                     
     *note assertSequenceEqual(a, b): 125a.        シーケンス                        3.1
                                                                                     
                                                                                     
     *note assertListEqual(a, b): 1258.            リスト                            3.1
                                                                                     
                                                                                     
     *note assertTupleEqual(a, b): 1259.           タプル                            3.1
                                                                                     
                                                                                     
     *note assertSetEqual(a, b): 1256.             set または frozenset              3.1
                                                                                     
                                                                                     
     *note assertDictEqual(a, b): 1257.            辞書                              3.1
                                                                                     

      -- メソッド: assertMultiLineEqual (first, second, msg=None)

          複数行の文字列 'first' が文字列 'second' と等しいことをテスト
          します。等しくない場合には、両者の差分がハイライトされてエラー
          メッセージに表示されます。このメソッドは、デフォルトで、 *note
          assertEqual(): 4f2. が string を比較するときに自動的に使用しま
          す。

          Added in version 3.1.

      -- メソッド: assertSequenceEqual (first, second, msg=None,
               seq_type=None)

          2つのシーケンスが等しいことをテストします。'seq_type' が指定さ
          れた場合、'first' と 'second' が 'seq_type' のインスタンスで無
          い場合にはテストが失敗します。シーケンスどうしが異なる場合には
          、両者の差分がエラーメッセージに表示されます。

          このメソッドは直接 *note assertEqual(): 4f2. からは呼ばれませ
          んが、 *note assertListEqual(): 1258. と *note
          assertTupleEqual(): 1259. の実装で使われています。

          Added in version 3.1.

      -- メソッド: assertListEqual (first, second, msg=None)
      -- メソッド: assertTupleEqual (first, second, msg=None)

          2つのリストまたはタプルが等しいかどうかをテストします。等しく
          ない場合には、両者の差分を表示します。2つのパラメータの型が異
          なる場合にはテストがエラーになります。このメソッドは、デフォル
          トで、 *note assertEqual(): 4f2. が list または tuple を比較す
          るときに自動的に使用します。

          Added in version 3.1.

      -- メソッド: assertSetEqual (first, second, msg=None)

          2つのセットが等しいかどうかをテストします。等しくない場合には
          、両者の差分を表示します。このメソッドは、デフォルトで、 *note
          assertEqual(): 4f2. が set もしくは frozenset を比較するときに
          自動的に使用します。

          'first' or 'second' のいずれかに ‘set.difference()’ が無い場合
          にはテストは失敗します。

          Added in version 3.1.

      -- メソッド: assertDictEqual (first, second, msg=None)

          2つの辞書が等しいかどうかをテストします。等しくない場合には、
          両者の差分を表示します。このメソッドは、デフォルトで、 *note
          assertEqual(): 4f2. が dict を比較するときに自動的に使用します
          。

          Added in version 3.1.

     最後に、 *note TestCase: 41a. の残りのメソッドと属性を紹介します:

      -- メソッド: fail (msg=None)

          無条件にテストを失敗させます。エラーメッセージの表示に、'msg'
          または ‘None’ が使われます。

      -- の属性: failureException

          *note test(): cb. メソッドが送出する例外を指定するクラス属性で
          す。例えばテストフレームワークで追加情報を付した特殊な例外が必
          要になる場合、この例外のサブクラスとして作成します。この属性の
          初期値は *note AssertionError: 675. です。

      -- の属性: longMessage

          このクラス属性は、失敗した assertXYY の呼び出しで独自の失敗時
          のメッセージが msg 引数として渡されていたときにどうするかを決
          定します。 ‘True’ がデフォルト値です。 この場合、標準の失敗時
          のメッセージの後に独自のメッセージが追記されます。 ‘False’ に
          設定したときは、標準のメッセージを独自のメッセージで置き換えま
          す。

          アサートメソッドを呼び出す前に、個別のテストメソッドの中でイン
          スタンス属性 self.longMessage を ‘True’ または ‘False’ に設定
          して、この設定を上書きできます。

          このクラスの設定はそれぞれのテストを呼び出す前にリセットされま
          す。

          Added in version 3.1.

      -- の属性: maxDiff

          この属性は、アサーションメソッドが失敗をレポートする時に表示す
          る差分の長さをコントロールします。デフォルトは 80*8 文字です。
          この属性が影響するメソッドは、 *note assertSequenceEqual():
          125a. (およびこのメソッドに委譲するシーケンス比較メソッド)、
          *note assertDictEqual(): 1257. と *note
          assertMultiLineEqual(): 1312. です。

          ‘maxDiff’ を ‘None’ に設定すると差分表示の上限がなくなります。

          Added in version 3.2.

     テストフレームワークは、テスト情報を収集するために以下のメソッドを
     使用します:

      -- メソッド: countTestCases ()

          テストオブジェクトに含まれるテストの数を返します。 *note
          TestCase: 41a. インスタンスは常に ‘1’ を返します。

      -- メソッド: defaultTestResult ()

          このテストケースクラスで使われるテスト結果クラスのインスタンス
          を (もし *note run(): 1139. メソッドに他の結果インスタンスが提
          供されないならば) 返します。

          *note TestCase: 41a. インスタンスに対しては、いつも *note
          TestResult: 113a. のインスタンスですので、 *note TestCase:
          41a. のサブクラスでは必要に応じてこのメソッドをオーバライドし
          てください。

      -- メソッド: id ()

          テストケースを特定する文字列を返します。通常、'id' はモジュー
          ル名・クラス名を含む、テストメソッドのフルネームを指定します。

      -- メソッド: shortDescription ()

          テストの説明を一行分、または説明がない場合には ‘None’ を返しま
          す。デフォルトでは、テストメソッドの docstring の先頭の一行、
          または ‘None’ を返します。

          バージョン 3.1 で変更: 3.1で docstring があったとしても、返さ
          れる短い説明文字列にテスト名が付けられるようになりました。 こ
          の変更によって unittest 拡張に互換性の問題が発生し、 Python
          3.2 でテスト名が追加される場所は *note TextTestResult: 4fa. へ
          移動しました。

      -- メソッド: addCleanup (function, /, *args, **kwargs)

          *note tearDown(): 1309. の後に呼び出される関数を追加します。こ
          の関数はリソースのクリーンアップのために使用します。追加された
          関数は、追加された順と逆の順番で呼び出されます（LIFO）。 *note
          addCleanup(): a4f. に渡された引数とキーワード引数が追加された
          関数にも渡されます。

          *note setUp(): 1308. が失敗した場合、つまり *note tearDown():
          1309. が呼ばれなかった場合でも、追加されたクリーンアップ関数は
          呼び出されます。

          Added in version 3.1.

      -- メソッド: enterContext (cm)

          Enter the supplied *note context manager: 59e.  If successful,
          also add its *note __exit__(): 12ce. method as a cleanup
          function by *note addCleanup(): a4f. and return the result of
          the *note __enter__(): 592. method.

          Added in version 3.11.

      -- メソッド: doCleanups ()

          このメソッドは、 *note tearDown(): 1309. の後、もしくは、
          *note setUp(): 1308. が例外を投げた場合は *note setUp(): 1308.
          の後に、無条件で呼ばれます。

          このメソッドは、 *note addCleanup(): a4f. で追加された関数を呼
          び出す責務を担います。もし、クリーンアップ関数を *note
          tearDown(): 1309. より前に呼び出す必要がある場合には、 *note
          doCleanups(): 1307. を明示的に呼び出してください。

          *note doCleanups(): 1307. は、どこで呼び出されても、クリーンア
          ップ関数をスタックから削除して実行します。

          Added in version 3.1.

      -- メソッド: classmethod addClassCleanup (function, /, *args,
               **kwargs)

          *note tearDownClass(): 1306. の後に呼び出される関数を追加しま
          す。この関数はリソースのクリーンアップのために使用します。追加
          された関数は、追加された順と逆の順番で呼び出されます（LIFO）。
          *note addClassCleanup(): a1c. に渡された引数とキーワード引数が
          追加された関数にも渡されます。

          *note setUpClass(): a1d. が失敗した場合、つまり *note
          tearDownClass(): 1306. が呼ばれなかった場合でも、追加されたク
          リーンアップ関数は呼び出されます。

          Added in version 3.8.

      -- メソッド: classmethod enterClassContext (cm)

          Enter the supplied *note context manager: 59e.  If successful,
          also add its *note __exit__(): 12ce. method as a cleanup
          function by *note addClassCleanup(): a1c. and return the
          result of the *note __enter__(): 592. method.

          Added in version 3.11.

      -- メソッド: classmethod doClassCleanups ()

          このメソッドは、 *note tearDownClass(): 1306. の後、もしくは、
          *note setUpClass(): a1d. が例外を投げた場合は *note
          setUpClass(): a1d. の後に、無条件で呼ばれます。

          このメソッドは、 *note addClassCleanup(): a1c. で追加された関
          数を呼び出す責務を担います。もし、クリーンアップ関数を *note
          tearDownClass(): 1306. より前に呼び出す必要がある場合には、
          *note doClassCleanups(): 3f0d. を明示的に呼び出してください。

          *note doClassCleanups(): 3f0d. は、どこで呼び出されても、クリ
          ーンアップ関数をスタックから削除して実行します。

          Added in version 3.8.

 -- クラス: unittest.IsolatedAsyncioTestCase (methodName='runTest')

     このクラスは *note TestCase: 41a. と似たAPIを提供し、テスト関数とし
     てコルーチンも許容します。

     Added in version 3.8.

      -- の属性: loop_factory

          The 'loop_factory' passed to *note asyncio.Runner: 5cb.
          Override in subclasses with *note asyncio.EventLoop: 165b. to
          avoid using the asyncio policy system.

          Added in version 3.13.

      -- メソッド: coroutine asyncSetUp ()

          テストフィクスチャを用意するために呼び出されるメソッドです。こ
          れは ‘setUp()’.  の後に呼び出されます。これはテストメソッドを
          呼び出す直前に呼び出されます。*note AssertionError: 675. と
          *note SkipTest: fb1. を除いて、このメソッドのによって送出され
          たあらゆる例外はテストの失敗ではなくエラーとみなされます。デフ
          ォルトの実装では何もしません。

      -- メソッド: coroutine asyncTearDown ()

          テストメソッドが呼び出され、その結果が記録された直後に呼び出さ
          れるメソッドです。これは ‘tearDown()’ の前に呼び出されます。こ
          れはテストメソッドが例外を送出した場合でも呼び出されるので、サ
          ブクラスの実装では内部状態のチェックに特に気を付ける必要があり
          ます。このメソッドで送出された *note AssertionError: 675. と
          *note SkipTest: fb1. 以外の例外は、テストの失敗ではなく追加の
          エラーとみなされます(そのため、報告されるエラーの総数が増える
          ことになります)。このメソッドはテストメソッドの結果に関係なく
          、*note asyncSetUp(): 3f0f. が成功した場合にのみ呼び出されます
          。デフォルトの実装では何もしません。

      -- メソッド: addAsyncCleanup (function, /, *args, **kwargs)

          このメソッドはクリーンアップ関数として使用できるコルーチンを受
          け入れます。

      -- メソッド: coroutine enterAsyncContext (cm)

          Enter the supplied *note asynchronous context manager: 5a1.
          If successful, also add its *note __aexit__(): 158e. method as
          a cleanup function by *note addAsyncCleanup(): 3f11. and
          return the result of the *note __aenter__(): 1f30. method.

          Added in version 3.11.

      -- メソッド: run (result=None)

          テストを実行するための新しいイベントループを作成し、 'result'
          として渡された *note TestResult: 113a. オブジェクトに結果を収
          集します。'result' が省略された場合や ‘None’ の場合は、一時的
          なresultオブジェクトが(‘defaultTestResult()’ メソッドの呼び出
          しによって)作成され、使用されます。このresultオブジェクトは
          *note run(): 3f12. の呼び出し元に返されます。テスト終了時には
          、イベントループ内のすべてのタスクがキャンセルされます。

     順番を示す例です:

          from unittest import IsolatedAsyncioTestCase

          events = []


          class Test(IsolatedAsyncioTestCase):


              def setUp(self):
                  events.append("setUp")

              async def asyncSetUp(self):
                  self._async_connection = await AsyncConnection()
                  events.append("asyncSetUp")

              async def test_response(self):
                  events.append("test_response")
                  response = await self._async_connection.get("https://example.com")
                  self.assertEqual(response.status_code, 200)
                  self.addAsyncCleanup(self.on_cleanup)

              def tearDown(self):
                  events.append("tearDown")

              async def asyncTearDown(self):
                  await self._async_connection.close()
                  events.append("asyncTearDown")

              async def on_cleanup(self):
                  events.append("cleanup")

          if __name__ == "__main__":
              unittest.main()

     テスト実行後、‘events’ には ‘["setUp", "asyncSetUp",
     "test_response", "asyncTearDown", "tearDown", "cleanup"]’ が含まれ
     ます。

 -- クラス: unittest.FunctionTestCase (testFunc, setUp=None,
          tearDown=None, description=None)

     このクラスでは *note TestCase: 41a. インターフェースの内、テストラ
     ンナーがテストを実行するためのインターフェースだけを実装しており、
     テスト結果のチェックやレポートに関するメソッドは実装していません。
     既存のテストコードを *note unittest: ef. によるテストフレームワーク
     に組み込むために使用します。


File: python.info,  Node: テストのグループ化,  Next: テストのロードと起動,  Prev: テストクラス,  Up: クラスと関数

5.26.5.11 テストのグループ化
............................

 -- クラス: unittest.TestSuite (tests=())

     このクラスは、個々のテストケースやテストスイートの集合を表現してい
     ます。 通常のテストケースと同じようにテストランナーで実行するための
     インターフェースを備えています。 *note TestSuite: dc1. インスタンス
     を実行することはスイートをイテレートして得られる個々のテストを実行
     することと同じです。

     引数 'tests' が指定された場合、それはテストケースに亘る繰り返し可能
     オブジェクトまたは内部でスイートを組み立てるための他のテストスイー
     トでなければなりません。後からテストケースやスイートをコレクション
     に付け加えるためのメソッドも提供されています。

     *note TestSuite: dc1. は *note TestCase: 41a. オブジェクトのように
     振る舞います。違いは、スイートにはテストを実装しない点にあります。
     代わりに、テストをまとめてグループ化して、同時に実行します。 *note
     TestSuite: dc1. のインスタンスにテスト追加するためのメソッドが用意
     されています:

      -- メソッド: addTest (test)

          *note TestCase: 41a. 又は *note TestSuite: dc1. のインスタンス
          をスイートに追加します。

      -- メソッド: addTests (tests)

          イテラブル 'tests' に含まれる全ての *note TestCase: 41a. 又は
          *note TestSuite: dc1. のインスタンスをスイートに追加します。

          このメソッドは 'tests' 上のイテレーションをしながらそれぞれの
          要素に *note addTest(): 3f15. を呼び出すのと等価です。

     *note TestSuite: dc1. クラスは *note TestCase: 41a. と以下のメソッ
     ドを共有します:

      -- メソッド: run (result)

          スイート内のテストを実行し、結果を 'result' で指定した結果オブ
          ジェクトに収集します。 *note TestCase.run(): 1139. と異なり、
          *note TestSuite.run(): 3f17. では必ず結果オブジェクトを指定す
          る必要があります。

      -- メソッド: debug ()

          このスイートに関連づけられたテストを結果を収集せずに実行します
          。これによりテストで送出された例外は呼び出し元に伝わるようにな
          り、デバッガの下でのテスト実行をサポートできるようになります。

      -- メソッド: countTestCases ()

          このテストオブジェクトによって表現されるテストの数を返します。
          これには個別のテストと下位のスイートも含まれます。

      -- メソッド: __iter__ ()

          Tests grouped by a *note TestSuite: dc1. are always accessed
          by iteration.  Subclasses can lazily provide tests by
          overriding ‘__iter__()’.  Note that this method may be called
          several times on a single suite (for example when counting
          tests or comparing for equality) so the tests returned by
          repeated iterations before *note TestSuite.run(): 3f17. must
          be the same for each call iteration.  After *note
          TestSuite.run(): 3f17, callers should not rely on the tests
          returned by this method unless the caller uses a subclass that
          overrides ‘TestSuite._removeTestAtIndex()’ to preserve test
          references.

          バージョン 3.2 で変更: In earlier versions the *note
          TestSuite: dc1. accessed tests directly rather than through
          iteration, so overriding ‘__iter__()’ wasn't sufficient for
          providing tests.

          バージョン 3.4 で変更: 以前のバージョンでは、 *note
          TestSuite.run(): 3f17. の実行後は *note TestSuite: dc1. が各
          *note TestCase: 41a. への参照を保持していました。 サブクラスで
          ‘TestSuite._removeTestAtIndex()’ をオーバーライドすることでこ
          の振る舞いを復元できます。

     通常、 *note TestSuite: dc1. の *note run(): 3f17. メソッドは
     ‘TestRunner’ が起動するため、ユーザが直接実行する必要はありません。


File: python.info,  Node: テストのロードと起動,  Prev: テストのグループ化,  Up: クラスと関数

5.26.5.12 テストのロードと起動
..............................

 -- クラス: unittest.TestLoader

     *note TestLoader: 26e. クラスはクラスとモジュールからテストスイート
     を生成します。通常、このクラスのインスタンスを明示的に生成する必要
     はありません。 *note unittest: ef. モジュールの *note
     unittest.defaultTestLoader: 3f1b. を共用インスタンスとして使用する
     ことができます。 しかし、このクラスのサブクラスやインスタンスで、属
     性をカスタマイズすることができます。

     *note TestLoader: 26e. オブジェクトには以下の属性があります:

      -- の属性: errors

          テストの読み込み中に起きた致命的でないエラーのリストです。 ど
          の時点でもローダーからリセットされることはありません。 致命的
          なエラーは適切なメソッドが例外を送出して、呼び出し元に通知しま
          す。 致命的でないエラーも、実行したときのエラーを総合テストが
          通知してくれます。

          Added in version 3.5.

     *note TestLoader: 26e. のオブジェクトには以下のメソッドがあります:

      -- メソッド: loadTestsFromTestCase (testCaseClass)

          *note TestCase: 41a. の派生クラス ‘testCaseClass’ に含まれる全
          テストケースのスイートを返します。

          *note getTestCaseNames(): 271. で指定されたメソッドに対し、テ
          ストケースインスタンスが作成されます。 デフォルトでは ‘test’ で
          始まる名前のメソッド群です。 *note getTestCaseNames(): 271. が
          メソッド名を返さなかったが、 ‘runTest()’ メソッドが実装されて
          いる場合は、そのメソッドに対するテストケースが代わりに作成され
          ます。

      -- メソッド: loadTestsFromModule (module, *, pattern=None)

          指定したモジュールに含まれる全テストケースのスイートを返します
          。このメソッドは 'module' 内の *note TestCase: 41a. 派生クラス
          を検索し、見つかったクラスのテストメソッドごとにクラスのインス
          タンスを作成します。

               注釈: *note TestCase: 41a. クラスを基底クラスとしてクラス
               階層を構築するとテストフィクスチャや補助的な関数をうまく
               共用することができますが、基底クラスに直接インスタンス化
               できないテストメソッドがあると、この
               ‘loadTestsFromModule()’ を使うことができません。この場合
               でも、 fixture が全て別々で定義がサブクラスにある場合は使
               用することができます。

          モジュールが ‘load_tests’ 関数を用意している場合、この関数がテ
          ストの読み込みに使われます。 これによりテストの読み込み処理が
          カスタマイズできます。 これが *note load_tests プロトコル:
          3ef3. です。 'pattern' 引数は ‘load_tests’ に第3引数として渡さ
          れます。

          バージョン 3.2 で変更: ‘load_tests’ のサポートが追加されました
          。

          バージョン 3.5 で変更: Support for a keyword-only argument
          'pattern' has been added.

          バージョン 3.12 で変更: The undocumented and unofficial
          'use_load_tests' parameter has been removed.

      -- メソッド: loadTestsFromName (name, module=None)

          文字列で指定される全テストケースを含むスイートを返します。

          'name' には "ドット修飾名" でモジュールかテストケースクラス、
          テストケースクラス内のメソッド、 *note TestSuite: dc1. インス
          タンスまたは *note TestCase: 41a. か *note TestSuite: dc1. の
          インスタンスを返す呼び出し可能オブジェクトを指定します。このチ
          ェックはここで挙げた順番に行なわれます。すなわち、候補テストケ
          ースクラス内のメソッドは「呼び出し可能オブジェクト」としてでは
          なく「テストケースクラス内のメソッド」として拾い出されます。

          例えば ‘SampleTests’ モジュールに *note TestCase: 41a. から派
          生した ‘SampleTestCase’ クラスがあり、 ‘SampleTestCase’ にはテ
          ストメソッド ‘test_one()’ ・ ‘test_two()’ ・ ‘test_three()’ が
          あるとします。この場合、 'name' に
          ‘'SampleTests.SampleTestCase'’ と指定すると、 ‘SampleTestCase’
          の三つのテストメソッドを実行するテストスイートが作成されます。
          ‘'SampleTests.SampleTestCase.test_two'’ と指定すれば、
          ‘test_two()’ だけを実行するテストスイートが作成されます。イン
          ポートされていないモジュールやパッケージ名を含んだ名前を指定し
          た場合は自動的にインポートされます。

          また、'module' を指定した場合、'module' 内の 'name' を取得しま
          す。

          バージョン 3.5 で変更: 'name' を巡回している間に *note
          ImportError: 3f2. か *note AttributeError: 326. が発生した場合
          、実行するとその例外を発生させるようなテストを合成して返します
          。それらのエラーは self.errors に集められます。

      -- メソッド: loadTestsFromNames (names, module=None)

          *note loadTestsFromName(): 1315. と同じですが、名前を一つだけ
          指定するのではなく、複数の名前のシーケンスを指定する事ができま
          す。戻り値は 'names' 中の名前で指定されるテスト全てを含むテス
          トスイートです。

      -- メソッド: getTestCaseNames (testCaseClass)

          'testCaseClass' 中の全てのメソッド名を含むソート済みシーケンス
          を返します。 'testCaseClass' は *note TestCase: 41a. のサブク
          ラスでなければなりません。

      -- メソッド: discover (start_dir, pattern='test*.py',
               top_level_dir=None)

          指定された開始ディレクトリからサブディレクトリに再帰することで
          すべてのテストモジュールを検索し、それらを含む TestSuite オブ
          ジェクトを返します。'pattern' にマッチしたテストファイルだけが
          ロードの対象になります。 (シェルスタイルのパターンマッチングが
          使われます)。その中で、インポート可能なもジュール (つまり
          Python の識別子として有効であるということです) がロードされま
          す。

          All test modules must be importable from the top level of the
          project.  If the start directory is not the top level
          directory then 'top_level_dir' must be specified separately.

          シンタックスエラーなどでモジュールのインポートに失敗した場合、
          エラーが記録され、ディスカバリ自体は続けられます。 import の失
          敗が *note SkipTest: fb1. 例外が発生したためだった場合は、その
          モジュールはエラーではなく skip として記録されます。

          パッケージ (‘__init__.py’ という名前のファイルがあるディレクト
          リ) が見付かった場合、そのパッケージに ‘load_tests’ 関数がある
          かをチェックします。 関数があった場合、次に
          ‘package.load_tests(loader, tests, pattern)’ が呼ばれます。 テ
          ストの検索の実行では、たとえ load_tests 関数自身が
          ‘loader.discover’ を呼んだとしても、パッケージのチェックは1回
          のみとなることが保証されています。

          ‘load_tests’ が存在して、ディスカバリがパッケージ内を再帰的な
          検索を続けている途中で 'ない' 場合、‘load_tests’ はそのパッケ
          ージ内の全てのテストをロードする責務を担います。

          The pattern is deliberately not stored as a loader attribute
          so that packages can continue discovery themselves.

          'top_level_dir' is stored internally, and used as a default to
          any nested calls to ‘discover()’.  That is, if a package's
          ‘load_tests’ calls ‘loader.discover()’, it does not need to
          pass this argument.

          'start_dir' はドット付のモジュール名でもディレクトリでも構いま
          せん。

          Added in version 3.2.

          バージョン 3.4 で変更: インポート時に *note SkipTest: fb1. を
          送出するモジュールはエラーではなくスキップとして記録されます。

          バージョン 3.4 で変更: 'start_dir' に *note
          名前空間パッケージ: 1bd2. を指定できます。

          バージョン 3.4 で変更: ファイルシステムの順序がファイル名に従
          わないとしても実行順序が一定になるように、パスはインポートする
          前にソートされます。

          バージョン 3.5 で変更: パッケージ名がデフォルトのパターンに適
          合するのは不可能なので、パスが 'pattern' に適合するかどうかに
          関係無く、見付けたパッケージに ‘load_tests’ があるかをチェック
          するようになりました。

          バージョン 3.11 で変更: 'start_dir' can not be a *note
          namespace packages: 1bd2.  It has been broken since Python 3.7
          and Python 3.11 officially remove it.

          バージョン 3.13 で変更: 'top_level_dir' is only stored for the
          duration of 'discover' call.

     以下の属性は、サブクラス化またはインスタンスの属性値を変更して
     *note TestLoader: 26e. をカスタマイズする場合に使用します:

      -- の属性: testMethodPrefix

          テストメソッドの名前と判断されるメソッド名の接頭語を示す文字列
          。デフォルト値は ‘'test'’ です。

          This affects *note getTestCaseNames(): 271. and all the
          ‘loadTestsFrom*’ methods.

      -- の属性: sortTestMethodsUsing

          Function to be used to compare method names when sorting them
          in *note getTestCaseNames(): 271. and all the ‘loadTestsFrom*’
          methods.

      -- の属性: suiteClass

          テストのリストからテストスイートを構築する呼び出し可能オブジェ
          クト。メソッドを持つ必要はありません。デフォルト値は *note
          TestSuite: dc1. です。

          This affects all the ‘loadTestsFrom*’ methods.

      -- の属性: testNamePatterns

          テストメソッドがテストスイートに含まれるためにマッチしなければ
          ならないUnixシェルスタイルのワイルドカードテスト名パターンのリ
          ストです(‘-k’ オプションを参照)。

          この属性が ‘None’ (デフォルト)でない場合、テストスイートに含ま
          れるすべてのテストメソッドはこのリストのパターンのいずれかにマ
          ッチしていなければなりません。マッチは常に *note
          fnmatch.fnmatchcase(): 180b. を使用して実行されるため、‘-k’ オ
          プションに渡されるパターンとは異なり、単純な部分文字列パターン
          は ‘*’ ワイルドカードを使用して変換する必要があることに注意し
          てください。

          This affects all the ‘loadTestsFrom*’ methods.

          Added in version 3.7.

 -- クラス: unittest.TestResult

     このクラスはどのテストが成功しどのテストが失敗したかという情報を収
     集するのに使います。

     *note TestResult: 113a. は、複数のテスト結果を記録します。 *note
     TestCase: 41a. クラスと *note TestSuite: dc1. クラスのテスト結果を
     正しく記録しますので、テスト開発者が独自にテスト結果を管理する処理
     を開発する必要はありません。

     *note unittest: ef. を利用したテストフレームワークでは、
     ‘TestRunner.run()’ が返す *note TestResult: 113a. インスタンスを参
     照し、テスト結果をレポートします。

     *note TestResult: 113a. インスタンスの以下の属性は、テストの実行結
     果を検査する際に使用することができます:

      -- の属性: errors

          *note TestCase: 41a. と例外のトレースバック情報をフォーマット
          した文字列の 2 要素タプルからなるリスト。それぞれのタプルは予
          想外の例外を送出したテストに対応します。

      -- の属性: failures

          A list containing 2-tuples of *note TestCase: 41a. instances
          and strings holding formatted tracebacks.  Each tuple
          represents a test where a failure was explicitly signalled
          using the *note assert* methods: 3edc.

      -- の属性: skipped

          *note TestCase: 41a. インスタンスとテストをスキップした理由を
          保持する文字列の2要素タプルからなるリストです。

          Added in version 3.1.

      -- の属性: expectedFailures

          *note TestCase: 41a. と例外のトレースバック情報をフォーマット
          済の文字列の 2 要素タプルからなるリストです。それぞれのタプル
          は予期された失敗またはエラーに対応します。

      -- の属性: unexpectedSuccesses

          予期された失敗とされていながら成功してしまった *note TestCase:
          41a. のインスタンスのリスト。

      -- の属性: collectedDurations

          A list containing 2-tuples of test case names and floats
          representing the elapsed time of each test which was run.

          Added in version 3.12.

      -- の属性: shouldStop

          ‘True’ が設定されると *note stop(): 3f26. によりテストの実行が
          停止します。

      -- の属性: testsRun

          これまでに実行したテストの総数です。

      -- の属性: buffer

          ‘True’ が設定されると、 ‘sys.stdout’ と ‘sys.stderr’ は、
          *note startTest(): 3f29. から *note stopTest(): 3f2a. が呼ばれ
          るまでの間バッファリングされます。実際に、結果が ‘sys.stdout’
          と ‘sys.stderr’ に出力されるのは、テストが失敗するかエラーが発
          生した時になります。表示の際には、全ての失敗 / エラーメッセー
          ジが表示されます。

          Added in version 3.2.

      -- の属性: failfast

          真の場合 *note stop(): 3f26. が始めの失敗もしくはエラーの時に
          呼び出され、テストの実行が終了します。

          Added in version 3.2.

      -- の属性: tb_locals

          真の場合、局所変数がトレースバックに表示されます。

          Added in version 3.5.

      -- メソッド: wasSuccessful ()

          これまでに実行したテストが全て成功していれば ‘True’ を、それ以
          外なら ‘False’ を返します。

          バージョン 3.4 で変更: *note expectedFailure(): 3efa. デコレ－
          タでマークされたテストに *note unexpectedSuccesses: 3f24. があ
          った場合 ‘False’ を返します。

      -- メソッド: stop ()

          このメソッドを呼び出して *note TestResult: 113a. の *note
          shouldStop: 3f25. 属性に ‘True’ をセットすることで、実行中のテ
          ストは中断しなければならないというシグナルを送ることができます
          。 ‘TestRunner’ オブジェクトはこのフラグを順守してそれ以上のテ
          ストを実行することなく復帰しなければなりません。

          たとえばこの機能は、ユーザのキーボード割り込みを受け取って
          *note TextTestRunner: 16ad. クラスがテストフレームワークを停止
          させるのに使えます。 ‘TestRunner’ の実装を提供する対話的なツー
          ルでも同じように使用することができます。

     *note TestResult: 113a. クラスの以下のメソッドは内部データ管理用の
     メソッドですが、対話的にテスト結果をレポートするテストツールを開発
     する場合などにはサブクラスで拡張することができます。

      -- メソッド: startTest (test)

          'test' を実行する直前に呼び出されます。

      -- メソッド: stopTest (test)

          'test' の実行直後に、テスト結果に関わらず呼び出されます。

      -- メソッド: startTestRun ()

          全てのテストが実行される前に一度だけ実行されます。

          Added in version 3.1.

      -- メソッド: stopTestRun ()

          全てのテストが実行された後に一度だけ実行されます。

          Added in version 3.1.

      -- メソッド: addError (test, err)

          テスト 'test' 実行中に、想定外の例外が発生した場合に呼び出され
          ます。 'err' は *note sys.exc_info(): 656. が返すタプル
          ‘(type, value, traceback)’ です。

          デフォルトの実装では、タプル、 ‘(test, formatted_err)’ をイン
          スタンスの *note errors: 3f20. 属性に追加します。ここで、
          'formatted_err' は、 'err' から導出される、整形されたトレース
          バックです。

      -- メソッド: addFailure (test, err)

          テストケース 'test' が失敗した場合に呼び出されます。 'err' は
          *note sys.exc_info(): 656. が返すタプル ‘(type, value,
          traceback)’ です。

          デフォルトの実装では、タプル、 ‘(test, formatted_err)’ をイン
          スタンスの *note failures: 3f21. 属性に追加します。ここで、
          'formatted_err' は、 'err' から導出される、整形されたトレース
          バックです。

      -- メソッド: addSuccess (test)

          テストケース 'test' が成功した場合に呼び出されます。

          デフォルトの実装では何もしません。

      -- メソッド: addSkip (test, reason)

          'test' がスキップされた時に呼び出されます。'reason' はスキップ
          の際に渡された理由の文字列です。

          デフォルトの実装では、 ‘(test, reason)’ のタプルをインスタンス
          の *note skipped: 3f22. 属性に追加します。

      -- メソッド: addExpectedFailure (test, err)

          *note expectedFailure(): 3efa. のデコレータでマークされた
          'test' が失敗またはエラーの時に呼び出されます。

          デフォルトの実装では ‘(test, formatted_err)’ のタプルをインス
          タンスの *note expectedFailures: 3f23. に追加します。ここで
          'formatted_err' は 'err' から派生した整形されたトレースバック
          です。

      -- メソッド: addUnexpectedSuccess (test)

          *note expectedFailure(): 3efa. のデコレータでマークされた
          'test' が成功した時に呼び出されます。

          デフォルトの実装ではテストをインスタンスの *note
          unexpectedSuccesses: 3f24. 属性に追加します。

      -- メソッド: addSubTest (test, subtest, outcome)

          サブテストが終了すると呼ばれます。 'test' はテストメソッドに対
          応するテストケースです。 'subtest' はサブテストを記述するカス
          タムの *note TestCase: 41a. インスタンスです。

          'outcome' が *note None: 641. の場合サブテストは成功です。 そ
          れ以外の場合は失敗で、*note sys.exc_info(): 656. が返す形式
          ‘(type, value, traceback)’ の 'outcome' を持つ例外を伴います。

          結果が成功の場合デフォルトの実装では何もせず、サブテストの失敗
          を通常の失敗として報告します。

          Added in version 3.4.

      -- メソッド: addDuration (test, elapsed)

          Called when the test case finishes.  'elapsed' is the time
          represented in seconds, and it includes the execution of
          cleanup functions.

          Added in version 3.12.

 -- クラス: unittest.TextTestResult (stream, descriptions, verbosity, *,
          durations=None)

     A concrete implementation of *note TestResult: 113a. used by the
     *note TextTestRunner: 16ad.  Subclasses should accept ‘**kwargs’ to
     ensure compatibility as the interface changes.

     Added in version 3.2.

     バージョン 3.12 で変更: Added the 'durations' keyword parameter.

 -- データ: unittest.defaultTestLoader

     *note TestLoader: 26e. のインスタンスで、共用することが目的です。
     *note TestLoader: 26e. をカスタマイズする必要がなければ、新しい
     *note TestLoader: 26e. オブジェクトを作らずにこのインスタンスを使用
     します。

 -- クラス: unittest.TextTestRunner (stream=None, descriptions=True,
          verbosity=1, failfast=False, buffer=False, resultclass=None,
          warnings=None, *, tb_locals=False, durations=None)

     結果をストリームに出力する、基本的なテストランナーの実装です。
     'stream' が ‘None’ の場合、デフォルトで *note sys.stderr: 907. が出
     力ストリームとして使われます。 このクラスはいくつかの設定項目がある
     だけで、基本的に非常に単純です。 グラフィカルなテスト実行アプリケー
     ションでは、独自のテストランナーを実装してください。 テストランナー
     の実装は、 unittest に新しい機能が追加されランナーを構築するインタ
     ーフェースが変更されたときに備えて ‘**kwargs’ を受け取れるようにす
     るべきです。

     By default this runner shows *note DeprecationWarning: 18a, *note
     PendingDeprecationWarning: 895, *note ResourceWarning: 225. and
     *note ImportWarning: 4c7. even if they are *note ignored by
     default: 3f31.  This behavior can be overridden using Python's
     ‘-Wd’ or ‘-Wa’ options (see *note Warning control: 1ca2.) and
     leaving 'warnings' to ‘None’.

     バージョン 3.2 で変更: Added the 'warnings' parameter.

     バージョン 3.2 で変更: インポート時でなくインスタンス化時にデフォル
     トのストリームが *note sys.stderr: 907. に設定されます。

     バージョン 3.5 で変更: Added the 'tb_locals' parameter.

     バージョン 3.12 で変更: Added the 'durations' parameter.

      -- メソッド: _makeResult ()

          このメソッドは *note run(): 3f33. で使われる ‘TestResult’ のイ
          ンスタンスを返します。このメソッドは明示的に呼び出す必要はあり
          ませんが、サブクラスで ‘TestResult’ をカスタマイズすることがで
          きます。

          ‘_makeResult()’ は、 ‘TextTestRunner’ のコンストラクタで
          ‘resultclass’ 引数として渡されたクラスもしくはコーラブルオブジ
          ェクトをインスタンス化します。 ‘resultclass’ が指定されていな
          い場合には、デフォルトで *note TextTestResult: 4fa. が使用され
          ます。結果のクラスは以下の引数が渡されインスタンス化されます:

               stream, descriptions, verbosity

      -- メソッド: run (test)

          このメソッドは ‘TextTestRunner’ へのメインの公開インターフェー
          スです。 このメソッドは *note TestSuite: dc1. インスタンスある
          いは *note TestCase: 41a. インスタンスを受け取ります。 *note
          _makeResult(): 3f32. が呼ばれて *note TestResult: 113a. が作成
          され、テストが実行され、結果が標準出力に表示されます。

 -- の関数: unittest.main (module='__main__', defaultTest=None,
          argv=None, testRunner=None,
          testLoader=unittest.defaultTestLoader, exit=True, verbosity=1,
          failfast=None, catchbreak=None, buffer=None, warnings=None)

     'module' から複数のテストを読み込んで実行するためのコマンドラインプ
     ログラム。この関数を使えば、簡単に実行可能なテストモジュールを作成
     する事ができます。一番簡単なこの関数の使い方は、以下の行をテストス
     クリプトの最後に置くことです:

          if __name__ == '__main__':
              unittest.main()

     より詳細な情報は verbosity 引数を指定して実行すると得られます:

          if __name__ == '__main__':
              unittest.main(verbosity=2)

     'defaultTest' 引数は、 'argv' にテスト名が指定されていない場合に実
     行する、ある1つのテストの名前もしくはテスト名のイテラブルです。 こ
     の引数を指定しないか ‘None’ を指定し、かつ 'argv' にテスト名が与え
     られない場合は、 'module' にある全てのテストを実行します。

     'argv' 引数には、プログラムに渡されたオプションのリストを、最初の要
     素がプログラム名のままで渡せます。指定しないか ‘None’ の場合は
     *note sys.argv: 1236. が使われます。

     The 'testRunner' argument can either be a test runner class or an
     already created instance of it.  By default ‘main’ calls *note
     sys.exit(): 1318. with an exit code indicating success (0) or
     failure (1) of the tests run.  An exit code of 5 indicates that no
     tests were run or skipped.

     'testLoader' 引数は *note TestLoader: 26e. インスタンスでなければな
     りません。デフォルトは *note defaultTestLoader: 3f1b. です。

     ‘main’ は、 ‘exit=False’ を指定する事で対話的なインタプリタから使用
     することもできます。この引数を指定すると、 *note sys.exit(): 1318.
     を呼ばずに、結果のみを出力します:

          >>> from unittest import main
          >>> main(module='test_module', exit=False)

     'failfast', 'catchbreak', 'buffer' は、*note
     コマンドラインオプション: 3ee2. にある同名のオプションと同じ効果の
     あるパラメータです。

     'warnings' 引数では、テストの実行中に使うべき *note 警告フィルタ:
     897. を指定します。 この引数が指定されない場合には、 ‘-W’ オプショ
     ンが ‘python’ に渡されていなければ ‘None’ のまま (*note 警告の制御:
     1ca2. を参照してください) で、そうでなければ ‘'default'’ が設定され
     ます。

     Calling ‘main’ returns an object with the ‘result’ attribute that
     contains the result of the tests run as a *note
     unittest.TestResult: 113a.

     バージョン 3.1 で変更: 'exit' パラメータが追加されました。

     バージョン 3.2 で変更: 'verbosity'、'failfast'、'catchbreak'、
     'buffer'、'warnings' 引数が追加されました。

     バージョン 3.4 で変更: 'defaultTest' 引数がテスト名のイテラブルも受
     け取るようになりました。

* Menu:

* load_tests プロトコル::


File: python.info,  Node: load_tests プロトコル,  Up: テストのロードと起動

5.26.5.13 load_tests プロトコル
...............................

Added in version 3.2.

モジュールやパッケージには、‘load_tests’ と呼ばれる関数を実装できます。
これにより、通常のテスト実行時やテストディスカバリ時のテストのロードされ
方をカスタマイズできます。

テストモジュールが ‘load_tests’ を定義していると、それが *note
TestLoader.loadTestsFromModule(): 26f. から呼ばれます。引数は以下です:

     load_tests(loader, standard_tests, pattern)

'pattern' は ‘loadTestsFromModule’ からそのまま渡されます。デフォルトは
‘None’ です。

これは *note TestSuite: dc1. を返すべきです。

'loader' はローディングを行う *note TestLoader: 26e. のインスタンスです
。 'standard_tests' は、そのモジュールからデフォルトでロードされるテスト
です。これは、テストの標準セットのテストの追加や削除のみを行いたいテスト
モジュールに一般に使われます。第三引数は、パッケージをテストディスカバリ
の一部としてロードするときに使われます。

特定の *note TestCase: 41a. クラスのセットからテストをロードする典型的な
‘load_tests’ 関数は、このようになります:

     test_cases = (TestCase1, TestCase2, TestCase3)

     def load_tests(loader, tests, pattern):
         suite = TestSuite()
         for test_class in test_cases:
             tests = loader.loadTestsFromTestCase(test_class)
             suite.addTests(tests)
         return suite

コマンドラインからでも *note TestLoader.discover(): fb2. の呼び出しでも
、パッケージを含むディレクトリで検索を始めた場合、そのパッケージの
‘__init__.py’ をチェックして ‘load_tests’ を探します。 その関数が存在し
ない場合、他のディレクトリであるかのようにパッケージの中を再帰的に検索し
ます。 その関数が存在した場合、パッケージのテストの検索をそちらに任せ、
‘load_tests’ が次の引数で呼び出されます:

     load_tests(loader, standard_tests, pattern)

これはパッケージ内のすべてのテストを表す *note TestSuite: dc1. を返すべ
きです。 (‘standard_tests’ には、 ‘__init__.py’ から収集されたテストのみ
が含まれます。)

パターンは ‘load_tests’ に渡されるので、パッケージは自由にテストディスカ
バリを継続 (必要なら変更) できます。テストパッケージに '何もしない'
‘load_tests’ 関数は次のようになります:

     def load_tests(loader, standard_tests, pattern):
         # top level directory cached on loader instance
         this_dir = os.path.dirname(__file__)
         package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
         standard_tests.addTests(package_tests)
         return standard_tests

バージョン 3.5 で変更: パッケージ名がデフォルトのパターンに適合するのが
不可能なため、検索ではパッケージ名が 'pattern' に適合するかのチェックは
行われなくなりました。


File: python.info,  Node: クラスとモジュールのフィクスチャ,  Next: シグナルハンドリング,  Prev: クラスと関数,  Up: unittest --- ユニットテストフレームワーク

5.26.5.14 クラスとモジュールのフィクスチャ
..........................................

クラスレベルとモジュールレベルのフィクスチャが *note TestSuite: dc1. に
実装されました。 テストスイートが新しいクラスのテストを始める時、以前の
クラス (あれば)の ‘tearDownClass()’ を呼び出し、その後に新しいクラスの
‘setUpClass()’ を呼び出します。

同様に、今回のテストのモジュールが前回のテストとは異なる場合、以前のモジ
ュールの ‘tearDownModule’ を実行し、次に新しいモジュールの ‘setUpModule’
を実行します。

すべてのテストが実行された後、最後の ‘tearDownClass’ と ‘tearDownModule’
が実行されます。

なお、共有フィクスチャは、テストの並列化などの [潜在的な] 機能と同時には
うまくいかず、テストの分離を壊すので、気をつけて使うべきです。

unittest テストローダによるテスト作成のデフォルトの順序では、同じモジュ
ールやクラスからのテストはすべて同じグループにまとめられます。これにより
、‘setUpClass’ / ‘setUpModule’ (など) は、一つのクラスやモジュールにつき
一度だけ呼ばれます。この順序をバラバラにし、異なるモジュールやクラスのテ
ストが並ぶようにすると、共有フィクスチャ関数は、一度のテストで複数回呼ば
れるようにもなります。

共有フィクスチャは標準でない順序で実行されることを意図していません。 共
有フィクスチャをサポートしたくないフレームワークのために、
‘BaseTestSuite’ がまだ存在しています。

共有フィクスチャ関数のいずれかで例外が発生した場合、そのテストはエラーと
して報告されます。 そのとき、対応するテストインスタンスが無いので(*note
TestCase: 41a. と同じインターフェースの) ‘_ErrorHolder’ オブジェクトが生
成され、エラーを表します。 標準 unittest テストランナーを使っている場合
はこの詳細は問題になりませんが、あなたがフレームワークの作者である場合は
注意してください。

* Menu:

* setUpClass と tearDownClass::
* setUpModule と tearDownModule::


File: python.info,  Node: setUpClass と tearDownClass,  Next: setUpModule と tearDownModule,  Up: クラスとモジュールのフィクスチャ

5.26.5.15 setUpClass と tearDownClass
.....................................

これらはクラスメソッドとして実装されなければなりません:

     import unittest

     class Test(unittest.TestCase):
         @classmethod
         def setUpClass(cls):
             cls._connection = createExpensiveConnectionObject()

         @classmethod
         def tearDownClass(cls):
             cls._connection.destroy()

基底クラスの ‘setUpClass’ および ‘tearDownClass’ を使いたいなら、それら
を自分で呼び出さなければなりません。 *note TestCase: 41a. の実装は空です
。

‘setUpClass’ の中で例外が送出されたら、クラス内のテストは実行されず、
‘tearDownClass’ も実行されません。スキップされたクラスは ‘setUpClass’ も
‘tearDownClass’ も実行されません。例外が *note SkipTest: fb1. 例外であれ
ば、そのクラスはエラーではなくスキップされたものとして報告されます。


File: python.info,  Node: setUpModule と tearDownModule,  Prev: setUpClass と tearDownClass,  Up: クラスとモジュールのフィクスチャ

5.26.5.16 setUpModule と tearDownModule
.......................................

これらは関数として実装されなければなりません:

     def setUpModule():
         createConnection()

     def tearDownModule():
         closeConnection()

‘setUpModule’ の中で例外が送出されたら、モジュール内のテストは実行されず
、 ‘tearDownModule’ も実行されません。例外が *note SkipTest: fb1. 例外で
あれば、そのモジュールはエラーではなくスキップされたものとして報告されま
す。

例外が発生した場合でも実行しなければならないクリーンアップコードを追加す
るには''addModuleCleanup''を使用します:

 -- の関数: unittest.addModuleCleanup (function, /, *args, **kwargs)

     ‘tearDownModule()’ の後に呼び出される関数を追加します。この関数はリ
     ソースのクリーンアップのために使用します。追加された関数は、追加さ
     れた順と逆の順番で呼び出されます（LIFO）。 *note
     addModuleCleanup(): a1b. に渡された引数とキーワード引数が追加された
     関数にも渡されます。

     ‘setUpModule()’ が失敗した場合、つまり ‘tearDownModule()’ が呼ばれ
     なかった場合でも、追加されたクリーンアップ関数は呼び出されます。

     Added in version 3.8.

 -- メソッド: classmethod unittest.enterModuleContext (cm)

     Enter the supplied *note context manager: 59e.  If successful, also
     add its *note __exit__(): 12ce. method as a cleanup function by
     *note addModuleCleanup(): a1b. and return the result of the *note
     __enter__(): 592. method.

     Added in version 3.11.

 -- の関数: unittest.doModuleCleanups ()

     この関数は、 ‘tearDownModule()’ の後、もしくは、 ‘setUpModule()’ が
     例外を投げた場合は ‘setUpModule()’ の後に、無条件で呼ばれます。

     このメソッドは、 *note addModuleCleanup(): a1b. で追加された関数を
     呼び出す責務を担います。もし、クリーンアップ関数を
     ‘tearDownModule()’ より前に呼び出す必要がある場合には、 *note
     doModuleCleanups(): 17a7. を明示的に呼び出してください。

     *note doModuleCleanups(): 17a7. は、どこで呼び出されても、クリーン
     アップ関数をスタックから削除して実行します。

     Added in version 3.8.


File: python.info,  Node: シグナルハンドリング,  Prev: クラスとモジュールのフィクスチャ,  Up: unittest --- ユニットテストフレームワーク

5.26.5.17 シグナルハンドリング
..............................

Added in version 3.2.

The *note -c/-catch: 1302. command-line option to unittest, along with
the ‘catchbreak’ parameter to *note unittest.main(): fb0, provide more
friendly handling of control-C during a test run.  With catch break
behavior enabled control-C will allow the currently running test to
complete, and the test run will then end and report all the results so
far.  A second control-c will raise a *note KeyboardInterrupt: 99f. in
the usual way.

シグナルハンドラを処理する control-c は、独自の *note signal.SIGINT:
80f. ハンドラをインストールするコードやテストの互換性を保とうとします。
‘unittest’ ハンドラが呼ばれ、それがインストールされた *note
signal.SIGINT: 80f. ハンドラで 'なければ' 、すなわちテスト中のシステムに
置き換えられて移譲されたなら、それはデフォルトのハンドラを呼び出します。
インストールされたハンドラを置き換えて委譲するようなコードは、通常その動
作を期待するからです。 ‘unittest’ の control-c 処理を無効にしたいような
個別のテストには、 *note removeHandler(): 1303. デコレータが使えます。

フレームワークの作者がテストフレームワーク内で control-c 処理を有効にす
るための、いくつかのユーティリティ関数があります。

 -- の関数: unittest.installHandler ()

     control-c ハンドラをインストールします。(主にユーザが control-c を
     押したことにより) *note signal.SIGINT: 80f. が受け取られると、登録
     した結果すべてに *note stop(): 3f26. が呼び出されます。

 -- の関数: unittest.registerResult (result)

     control-c 処理のために *note TestResult: 113a. を登録します。結果を
     登録するとそれに対する弱参照が格納されるので、結果がガベージコレク
     トされるのを妨げません。

     control-c 処理が有効でなければ、 *note TestResult: 113a. オブジェク
     トの登録には副作用がありません。ですからテストフレームワークは、処
     理が有効か無効かにかかわらず、作成する全ての結果を無条件に登録でき
     ます。

 -- の関数: unittest.removeResult (result)

     登録された結果を削除します。一旦結果が削除されると、control-c が押
     された際にその結果オブジェクトに対して *note stop(): 3f26. が呼び出
     されなくなります。

 -- の関数: unittest.removeHandler (function=None)

     引数なしで呼び出されると、この関数はCtrl+Cのシグナルハンドラを（そ
     れがインストールされていた場合）削除します。また、この関数はテスト
     が実行されている間、Ctrl+Cのハンドラを一時的に削除するテストデコレ
     ーターとしても使用できます。

          @unittest.removeHandler
          def test_signal_handling(self):
              ...


File: python.info,  Node: unittest mock --- モックオブジェクトライブラリ,  Next: unittest mock --- 入門,  Prev: unittest --- ユニットテストフレームワーク,  Up: 開発ツール

5.26.6 ‘unittest.mock’ -- モックオブジェクトライブラリ
------------------------------------------------------

Added in version 3.3.

'ソースコード:' Lib/unittest/mock.py(1)

__________________________________________________________________

*note unittest.mock: f0. はPython におけるソフトウェアテストのためのライ
ブラリです。テスト中のシステムの一部をモックオブジェクトで置き換え、それ
らがどのように使われるかをアサートすることができます。

*note unittest.mock: f0. はコア *note Mock: a1a. クラスを提供しており、
それによってテストスイート内でたくさんのスタブを作成しなくてすみます 。
アクションの実行後、メソッドや属性の使用や実引数についてアサートできます
。また通常の方法で戻り値を明記したり、必要な属性を設定することもできます
。

加えて、 mock はテストのスコープ内にあるモジュールやクラスの属性を変更す
る *note patch(): e5b. デコレータを提供します。さらに、ユニークなオブジ
ェクトの作成には *note sentinel: b6e. が利用できます。 *note Mock: a1a.
や *note MagicMock: e5a. 、 *note patch(): e5b. の利用例は *note quick
guide: 3f3b. を参照してください。

Mock は *note unittest: ef. で利用するために設計されており、多くのモック
フレームワークで使われる 'record -> replay' パターンの代わりに、 'action
-> assertion' パターンに基づいています。

There is a backport of *note unittest.mock: f0. for earlier versions of
Python, available as mock(2) on PyPI.

* Menu:

* クイックガイド::
* Mock クラス::
* patcher::
* MagicMock と magic method のサポート::
* ヘルパー::
* Order of precedence of side_effect, return_value and wraps: Order of precedence of side_effect return_value and wraps.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/unittest/mock.py

   (2) https://pypi.org/project/mock/


File: python.info,  Node: クイックガイド,  Next: Mock クラス,  Up: unittest mock --- モックオブジェクトライブラリ

5.26.6.1 クイックガイド
.......................

*note Mock: a1a. および *note MagicMock: e5a. オブジェクトはアクセスした
すべての属性とメソッドを作成し、どのように使用されたかについての詳細な情
報を格納します。戻り値を指定したり利用できる属性を制限するために *note
Mock: a1a. および *note MagicMock: e5a. を設定でき、どのよう使用されたか
についてアサートできます:

     >>> from unittest.mock import MagicMock
     >>> thing = ProductionClass()
     >>> thing.method = MagicMock(return_value=3)
     >>> thing.method(3, 4, 5, key='value')
     3
     >>> thing.method.assert_called_with(3, 4, 5, key='value')

*note side_effect: 3f3c. allows you to perform side effects, including
raising an exception when a mock is called:

     >>> from unittest.mock import Mock
     >>> mock = Mock(side_effect=KeyError('foo'))
     >>> mock()
     Traceback (most recent call last):
      ...
     KeyError: 'foo'

     >>> values = {'a': 1, 'b': 2, 'c': 3}
     >>> def side_effect(arg):
     ...     return values[arg]
     ...
     >>> mock.side_effect = side_effect
     >>> mock('a'), mock('b'), mock('c')
     (1, 2, 3)
     >>> mock.side_effect = [5, 4, 3, 2, 1]
     >>> mock(), mock(), mock()
     (5, 4, 3)

モックには多くの設定法や挙動の制御法があります。例えば 'spec' 引数によっ
て別のオブジェクトからの仕様を受け取るよう設定できます。 spec にないモッ
クの属性やメソッドにアクセスを試みた場合、 *note AttributeError: 326. で
失敗します。

*note patch(): e5b. デコレータ / コンテキストマネージャーによってテスト
対象のモジュール内のクラスやオブジェクトを簡単にモックできます。指定した
オブジェクトはテスト中はモック (または別のオブジェクト) に置換され、テス
ト終了時に復元されます:

     >>> from unittest.mock import patch
     >>> @patch('module.ClassName2')
     ... @patch('module.ClassName1')
     ... def test(MockClass1, MockClass2):
     ...     module.ClassName1()
     ...     module.ClassName2()
     ...     assert MockClass1 is module.ClassName1
     ...     assert MockClass2 is module.ClassName2
     ...     assert MockClass1.called
     ...     assert MockClass2.called
     ...
     >>> test()

     注釈: patch デコレータをネストした場合、モックは適用されるときと同
     じ順番 (デコレータを適用するときの通常の 'Python' の順番) でデコレ
     ートされた関数に渡されます。 つまり下から順に適用されるため、上の例
     では ‘module.ClassName1’ のモックが最初に渡されます。

     *note patch(): e5b. では探索される名前空間内のオブジェクトにパッチ
     をあてることが重要です。通常は単純ですが、クイックガイドには *note
     どこにパッチするか: 3f3d. を読んでください。

*note patch(): e5b. デコレータと同様に with 文でコンテキストマネージャー
として使用できます:

     >>> with patch.object(ProductionClass, 'method', return_value=None) as mock_method:
     ...     thing = ProductionClass()
     ...     thing.method(1, 2, 3)
     ...
     >>> mock_method.assert_called_once_with(1, 2, 3)

また、 *note patch.dict(): 195e. を使うと、スコープ内だけで辞書に値を設
定し、テスト終了時には元の状態に復元されます:

     >>> foo = {'key': 'value'}
     >>> original = foo.copy()
     >>> with patch.dict(foo, {'newkey': 'newvalue'}, clear=True):
     ...     assert foo == {'newkey': 'newvalue'}
     ...
     >>> assert foo == original

mock は Python の *note マジックメソッド: 3f3e. のモックをサポートしてい
ます。 マジックメソッドのもっとも簡単な利用法は *note MagicMock: e5a. ク
ラスと使うことです。以下のように利用します:

     >>> mock = MagicMock()
     >>> mock.__str__.return_value = 'foobarbaz'
     >>> str(mock)
     'foobarbaz'
     >>> mock.__str__.assert_called_with()

mock によってマジックメソッドに関数 (あるいは他の Mock インスタンス) を
割り当てることができ、それらは適切に呼び出されます。 *note MagicMock:
e5a. クラスは、すべてのマジックメソッドがあらかじめ作成されている点を除
けば *note Mock: a1a. クラスと一緒です (まあ、とにかく便利ってこと)。

以下は通常の Mock クラスでマジックメソッドを利用する例です:

     >>> mock = Mock()
     >>> mock.__str__ = Mock(return_value='wheeeeee')
     >>> str(mock)
     'wheeeeee'

テスト内のモックオブジェクトが置換するオブジェクトと同じ API を持つこと
を保証するには、 *note auto-speccing: 3f3f. を使うことができます。パッチ
をあてる 'autospec' 引数、または *note create_autospec(): 156b. 関数を通
じて auto-speccing は行われます。 auto-speccing は置換するオブジェクトと
同じ属性とメソッドを持つモックオブジェクトを作成し、すべての関数および
(コンストラクタを含む) メソッドは本物のオブジェクトと同じ呼び出しシグネ
チャを持ちます。

誤って使用された場合、モックは製品コードと同じように失敗されることが保証
されています:

     >>> from unittest.mock import create_autospec
     >>> def function(a, b, c):
     ...     pass
     ...
     >>> mock_function = create_autospec(function, return_value='fishy')
     >>> mock_function(1, 2, 3)
     'fishy'
     >>> mock_function.assert_called_once_with(1, 2, 3)
     >>> mock_function('wrong arguments')
     Traceback (most recent call last):
      ...
     TypeError: missing a required argument: 'b'

*note create_autospec(): 156b. はクラスにおいても利用でき、 ‘__init__’ メ
ソッドのシグニチャをコピーします。また、呼び出し可能オブジェクトについて
も ‘__call__’ メソッドのシグニチャをコピーします。


File: python.info,  Node: Mock クラス,  Next: patcher,  Prev: クイックガイド,  Up: unittest mock --- モックオブジェクトライブラリ

5.26.6.2 Mock クラス
....................

*note Mock: a1a. は、コードにおけるスタブの使用やテストダブルを置き換え
るための柔軟なモックオブジェクトです。モックは呼び出し可能で、属性にアク
セスした場合それを新たなモックとして作成します (1)。同じ属性にアクセスし
た場合は常に同じモックを返します。 モックはどのように使われたかを記録す
るので、コードがモックに行うことについてアサートできます。

*note MagicMock: e5a. は *note Mock: a1a. のサブクラスで、すべてのマジッ
クメソッドが事前に作成され、利用できます。また、呼び出し不可能なモックを
作成する場合には、呼び出し不能な変種の *note NonCallableMock: 3f41. や
*note NonCallableMagicMock: 3f42. があります。

*note patch(): e5b. デコレータによって特定のモジュール内のクラスを *note
Mock: a1a. オブジェクトで一時的に置換することが簡単にできます。デフォル
トでは *note patch(): e5b. は *note MagicMock: e5a. を作成します。 *note
patch(): e5b. に渡す 'new_callable' 引数によって、別の *note Mock: a1a.
クラスを指定できます。

 -- クラス: unittest.mock.Mock (spec=None, side_effect=None,
          return_value=DEFAULT, wraps=None, name=None, spec_set=None,
          unsafe=False, **kwargs)

     新しい *note Mock: a1a. オブジェクトを作成します。 *note Mock: a1a.
     はモックオブジェクトの挙動を指定するオプション引数をいくつか取りま
     す:

        * 'spec': モックオブジェクトの仕様として働く文字列のリストもしく
          は存在するオブジェクト (クラスもしくはインスタンス) を指定しま
          す。オブジェクトを渡した場合には、 dir 関数によって文字列のリ
          ストが生成されます (サポートされない特殊属性や特殊メソッドは除
          く) 。このリストにない属性にアクセスした際には *note
          AttributeError: 326. が発生します。

          If 'spec' is an object (rather than a list of strings) then
          *note __class__: 1452. returns the class of the spec object.
          This allows mocks to pass *note isinstance(): 40e. tests.

        * 'spec_set': より厳しい 'spec' です。こちらを利用した場合、
          'spec_set' に渡されたオブジェクトに存在しない属性に対し '設定'
          や取得をしようとした際に *note AttributeError: 326. が発生しま
          す。

        * 'side_effect': モックが呼び出された際に呼び出される関数を指定
          します。 *note side_effect: 3f3c. 属性を参考にしてください。例
          外を発生させたり、動的に戻り値を変更する場合に便利です。関数に
          は、モックと同じ引数が渡され、 *note DEFAULT: 3f43. を返さない
          限りはこの関数の戻り値が使われます。

          一方で、 'side_effect' には、例外クラスやインスタンスを指定で
          きます。この場合は、モックが呼び出された際に指定された例外を発
          生します。

          もし、 'side_effect' にイテレート可能オブジェクトを指定した場
          合には、モックの呼び出しごとに順に値を返します。

          'side_effect' に ‘None’ を指定した場合には、設定がクリアされま
          す。

        * 'return_value': モックが呼び出された際に返す値です。デフォルト
          では (最初にアクセスされた際に生成される) 新しい Mock を返しま
          す。 *note return_value: 3f44. を参照してください。

        * 'unsafe': By default, accessing any attribute whose name
          starts with 'assert', 'assret', 'asert', 'aseert' or 'assrt'
          will raise an *note AttributeError: 326.  Passing
          ‘unsafe=True’ will allow access to these attributes.

          Added in version 3.5.

        * 'wraps': このモックオブジェクトがラップするものです。 'wraps'
          が ‘None’ でなければ、このモックを呼び出すと、その呼び出しがラ
          ップされたオブジェクトに渡され (て実際の結果を返し) ます。モッ
          クの属性アクセスは、ラップされたオブジェクトの対応する属性をラ
          ップする Mock オブジェクトを返します (なので、存在しない属性に
          アクセスしようとすると *note AttributeError: 326. を送出します
          )。

          モックが明示的に 'return_value' を設定されていると、呼び出しは
          ラップされたオブジェクトに渡されず、代わりに 'return_value' が
          返されます。

        * 'name': モックに名前があるなら、それがモックの repr として使わ
          れます。これはデバッグの際に役立つでしょう。この名前は子のモッ
          クにも伝播します。

     モックは、任意のキーワード引数を与えることができます。これらはモッ
     クの生成後、属性の設定に使われます。詳細は *note configure_mock():
     3f45. を参照してください。

      -- メソッド: assert_called ()

          モックが少なくとも一度は呼び出されたことをアサートします。

               >>> mock = Mock()
               >>> mock.method()
               <Mock name='mock.method()' id='...'>
               >>> mock.method.assert_called()

          Added in version 3.6.

      -- メソッド: assert_called_once ()

          モックが一度だけ呼び出されたことをアサートします。

               >>> mock = Mock()
               >>> mock.method()
               <Mock name='mock.method()' id='...'>
               >>> mock.method.assert_called_once()
               >>> mock.method()
               <Mock name='mock.method()' id='...'>
               >>> mock.method.assert_called_once()
               Traceback (most recent call last):
               ...
               AssertionError: Expected 'method' to have been called once. Called 2 times.
               Calls: [call(), call()].

          Added in version 3.6.

      -- メソッド: assert_called_with (*args, **kwargs)

          This method is a convenient way of asserting that the last
          call has been made in a particular way:

               >>> mock = Mock()
               >>> mock.method(1, 2, 3, test='wow')
               <Mock name='mock.method()' id='...'>
               >>> mock.method.assert_called_with(1, 2, 3, test='wow')

      -- メソッド: assert_called_once_with (*args, **kwargs)

          モックが一度だけ呼び出され、かつ指定された引数で呼び出されたこ
          とをアサートします。

               >>> mock = Mock(return_value=None)
               >>> mock('foo', bar='baz')
               >>> mock.assert_called_once_with('foo', bar='baz')
               >>> mock('other', bar='values')
               >>> mock.assert_called_once_with('other', bar='values')
               Traceback (most recent call last):
                 ...
               AssertionError: Expected 'mock' to be called once. Called 2 times.
               Calls: [call('foo', bar='baz'), call('other', bar='values')].

      -- メソッド: assert_any_call (*args, **kwargs)

          モックが特定の引数で呼び出されたことがあるのをアサートします。

          The assert passes if the mock has 'ever' been called, unlike
          *note assert_called_with(): 198c. and *note
          assert_called_once_with(): 3f46. that only pass if the call is
          the most recent one, and in the case of *note
          assert_called_once_with(): 3f46. it must also be the only
          call.

               >>> mock = Mock(return_value=None)
               >>> mock(1, 2, arg='thing')
               >>> mock('some', 'thing', 'else')
               >>> mock.assert_any_call(1, 2, arg='thing')

      -- メソッド: assert_has_calls (calls, any_order=False)

          モックが特定の呼び出しで呼ばれたことをアサートします。呼び出し
          では *note mock_calls: 3f48. のリストがチェックされます。

          'any_order' が false の場合、呼び出しは連続していなければなり
          ません。指定された呼び出しの前、あるいは呼び出しの後に余分な呼
          び出しがある場合があります。

          'any_order' が true の場合、呼び出しは任意の順番でも構いません
          が、それらがすべて *note mock_calls: 3f48. に現われなければな
          りません。

               >>> mock = Mock(return_value=None)
               >>> mock(1)
               >>> mock(2)
               >>> mock(3)
               >>> mock(4)
               >>> calls = [call(2), call(3)]
               >>> mock.assert_has_calls(calls)
               >>> calls = [call(4), call(2), call(3)]
               >>> mock.assert_has_calls(calls, any_order=True)

      -- メソッド: assert_not_called ()

          モックが一度も呼ばれなかったことをアサートします。

               >>> m = Mock()
               >>> m.hello.assert_not_called()
               >>> obj = m.hello()
               >>> m.hello.assert_not_called()
               Traceback (most recent call last):
                 ...
               AssertionError: Expected 'hello' to not have been called. Called 1 times.
               Calls: [call()].

          Added in version 3.5.

      -- メソッド: reset_mock (*, return_value=False, side_effect=False)

          モックオブジェクトのすべての呼び出し属性をリセットします:

               >>> mock = Mock(return_value=None)
               >>> mock('hello')
               >>> mock.called
               True
               >>> mock.reset_mock()
               >>> mock.called
               False

          バージョン 3.6 で変更: 2つのキーワード専用引数が reset_mock 関
          数に追加されました。

          This can be useful where you want to make a series of
          assertions that reuse the same object.  Note that *note
          reset_mock(): cc8. 'doesn't' clear the *note return_value:
          3f44, *note side_effect: 3f3c. or any child attributes you
          have set using normal assignment by default.  In case you want
          to reset *note return_value: 3f44. or *note side_effect: 3f3c,
          then pass the corresponding parameter as ‘True’.  Child mocks
          and the return value mock (if any) are reset as well.

               注釈: 'return_value', and 'side_effect' are keyword-only
               arguments.

      -- メソッド: mock_add_spec (spec, spec_set=False)

          モックに仕様を追加します。 'spec' にはオブジェクトもしくは文字
          列のリストを指定してください。 'spec' で設定した属性は、モック
          の属性としてのみアクセスできます。

          'spec_set' が真なら、 spec 以外の属性は設定できません。

      -- メソッド: attach_mock (mock, attribute)

          属性として mock を設定して、その名前と親を入れ替えます。設定さ
          れたモックの呼び出しは、 *note method_calls: 3f4a. や *note
          mock_calls: 3f48. 属性に記録されます。

      -- メソッド: configure_mock (**kwargs)

          モックの属性をキーワード引数で設定します。

          属性に加え、子の戻り値や副作用もドット表記を用いて設定でき、辞
          書はメソッドの呼び出し時にアンパックされます:

               >>> mock = Mock()
               >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
               >>> mock.configure_mock(**attrs)
               >>> mock.method()
               3
               >>> mock.other()
               Traceback (most recent call last):
                 ...
               KeyError

          コンストラクタの呼び出しでも同様に行うことができます:

               >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
               >>> mock = Mock(some_attribute='eggs', **attrs)
               >>> mock.some_attribute
               'eggs'
               >>> mock.method()
               3
               >>> mock.other()
               Traceback (most recent call last):
                 ...
               KeyError

          *note configure_mock(): 3f45. は、モック生成後のコンフィギュレ
          ーションを容易に行うために存在します。

      -- メソッド: __dir__ ()

          *note Mock: a1a. オブジェクトは、有用な結果を得るために
          ‘dir(some_mock)’ の結果を制限します。 'spec' を設定したモック
          に対しては、許可された属性のみを含みます。

          このフィルタが何をしていて、どのように停止させるかは、 *note
          FILTER_DIR: 3f4c. を参照してください。

      -- メソッド: _get_child_mock (**kw)

          子のモックを作成し、その値を返すようにしてください。デフォルト
          では親と同じタイプで作成されます。サブクラスで子モックの作成さ
          れる方法をカスタマイズしたい場合には、このメソッドをオーバーラ
          イドします。

          呼び出し不可能なモックに対しては、(カスタムのサブクラスではな
          く) 呼び出し可能なモックが使われます。

      -- の属性: called

          このモックが呼び出されたかどうかを表します:

               >>> mock = Mock(return_value=None)
               >>> mock.called
               False
               >>> mock()
               >>> mock.called
               True

      -- の属性: call_count

          このモックオブジェクトが呼び出された回数を返します:

               >>> mock = Mock(return_value=None)
               >>> mock.call_count
               0
               >>> mock()
               >>> mock()
               >>> mock.call_count
               2

      -- の属性: return_value

          モックが呼び出された際に返す値を設定します:

               >>> mock = Mock()
               >>> mock.return_value = 'fish'
               >>> mock()
               'fish'

          デフォルトの戻り値はモックオブジェクトです。通常の方法で設定す
          ることもできます:

               >>> mock = Mock()
               >>> mock.return_value.attribute = sentinel.Attribute
               >>> mock.return_value()
               <Mock name='mock()()' id='...'>
               >>> mock.return_value.assert_called_with()

          *note return_value: 3f44. は生成時にも設定可能です:

               >>> mock = Mock(return_value=3)
               >>> mock.return_value
               3
               >>> mock()
               3

      -- の属性: side_effect

          このモックが呼ばれた際に呼び出される関数、イテラブル、もしくは
          発生させる例外 (クラスまたはインスタンス) を設定できます。

          関数を渡した場合はモックと同じ引数で呼び出され、 *note
          DEFAULT: 3f43. を返さない限りはその関数の戻り値が返されます。
          関数が *note DEFAULT: 3f43. を返した場合は ( *note
          return_value: 3f44. によって) モックの通常の値を返します。

          iterable が渡された場合、その値はイテレータを取り出すために使
          用されます。イテレータは毎回の呼び出しにおいて値を yield しな
          ければなりません。この値は、送出される例外インスタンスか、呼び
          出しからモックに返される値のいずれかです (*note DEFAULT: 3f43.
          の処理は関数の場合と同一です)。

          以下はモックが (API による例外の扱いをテストするために) 例外を
          発生させる例です:

               >>> mock = Mock()
               >>> mock.side_effect = Exception('Boom!')
               >>> mock()
               Traceback (most recent call last):
                 ...
               Exception: Boom!

          *note side_effect: 3f3c. を使用して連続的に値を返します:

               >>> mock = Mock()
               >>> mock.side_effect = [3, 2, 1]
               >>> mock(), mock(), mock()
               (3, 2, 1)

          呼び出し可能オブジェクトを使います:

               >>> mock = Mock(return_value=3)
               >>> def side_effect(*args, **kwargs):
               ...     return DEFAULT
               ...
               >>> mock.side_effect = side_effect
               >>> mock()
               3

          *note side_effect: 3f3c. は生成時にも設定可能です。呼び出し時
          の値に 1 を加えて返す例を以下に示します:

               >>> side_effect = lambda value: value + 1
               >>> mock = Mock(side_effect=side_effect)
               >>> mock(3)
               4
               >>> mock(-8)
               -7

          *note side_effect: 3f3c. に ‘None’ を設定した場合はクリアされ
          ます:

               >>> m = Mock(side_effect=KeyError, return_value=3)
               >>> m()
               Traceback (most recent call last):
                ...
               KeyError
               >>> m.side_effect = None
               >>> m()
               3

      -- の属性: call_args

          This is either ‘None’ (if the mock hasn't been called), or the
          arguments that the mock was last called with.  This will be in
          the form of a tuple: the first member, which can also be
          accessed through the ‘args’ property, is any ordered arguments
          the mock was called with (or an empty tuple) and the second
          member, which can also be accessed through the ‘kwargs’
          property, is any keyword arguments (or an empty dictionary).

               >>> mock = Mock(return_value=None)
               >>> print(mock.call_args)
               None
               >>> mock()
               >>> mock.call_args
               call()
               >>> mock.call_args == ()
               True
               >>> mock(3, 4)
               >>> mock.call_args
               call(3, 4)
               >>> mock.call_args == ((3, 4),)
               True
               >>> mock.call_args.args
               (3, 4)
               >>> mock.call_args.kwargs
               {}
               >>> mock(3, 4, 5, key='fish', next='w00t!')
               >>> mock.call_args
               call(3, 4, 5, key='fish', next='w00t!')
               >>> mock.call_args.args
               (3, 4, 5)
               >>> mock.call_args.kwargs
               {'key': 'fish', 'next': 'w00t!'}

          *note call_args: 18eb. は、 *note call_args_list: 3f50. や
          *note method_calls: 3f4a. 、 *note mock_calls: 3f48. と同様、
          *note call: 1939. オブジェクトです。これらはタプルとしてアンパ
          ックすることで個別に取り出すことができます。そして、より複雑な
          アサーションを行うことができます。 *note calls as tuples:
          3f51. を参照してください。

          バージョン 3.8 で変更: ‘args’ と ‘kwargs’ 属性が追加されました
          。

      -- の属性: call_args_list

          モックの呼び出しを順に記録したリストです (よって、このリストの
          長さはモックが呼び出された回数と等しくなります)。モックを作成
          してから一度も呼び出しを行なっていない場合は、空のリストが返さ
          れます。 *note call: 1939. オブジェクトは、 *note
          call_args_list: 3f50. の比較対象となる呼び出しのリストを作成す
          る際に便利です。

               >>> mock = Mock(return_value=None)
               >>> mock()
               >>> mock(3, 4)
               >>> mock(key='fish', next='w00t!')
               >>> mock.call_args_list
               [call(), call(3, 4), call(key='fish', next='w00t!')]
               >>> expected = [(), ((3, 4),), ({'key': 'fish', 'next': 'w00t!'},)]
               >>> mock.call_args_list == expected
               True

          *note call_args_list: 3f50. のメンバは *note call: 1939. オブ
          ジェクトです。タプルとしてアンパックすることで個別に取り出すこ
          とができます。 *note calls as tuples: 3f51. を参照してください
          。

      -- の属性: method_calls

          自身の呼び出しと同様に、モックはメソッドや属性、そして 'それら
          の' メソッドや属性の呼び出しも追跡します:

               >>> mock = Mock()
               >>> mock.method()
               <Mock name='mock.method()' id='...'>
               >>> mock.property.method.attribute()
               <Mock name='mock.property.method.attribute()' id='...'>
               >>> mock.method_calls
               [call.method(), call.property.method.attribute()]

          *note method_calls: 3f4a. のメンバは *note call: 1939. オブジ
          ェクトです。タプルとしてアンパックすることで個別に取り出すこと
          ができます。 *note calls as tuples: 3f51. を参照してください。

      -- の属性: mock_calls

          *note mock_calls: 3f48. は、メソッド、特殊メソッド、 'そして'
          戻り値のモックまで、モックオブジェクトに対する 'すべての' 呼び
          出しを記録します。

               >>> mock = MagicMock()
               >>> result = mock(1, 2, 3)
               >>> mock.first(a=3)
               <MagicMock name='mock.first()' id='...'>
               >>> mock.second()
               <MagicMock name='mock.second()' id='...'>
               >>> int(mock)
               1
               >>> result(1)
               <MagicMock name='mock()()' id='...'>
               >>> expected = [call(1, 2, 3), call.first(a=3), call.second(),
               ... call.__int__(), call()(1)]
               >>> mock.mock_calls == expected
               True

          *note mock_calls: 3f48. のメンバは *note call: 1939. オブジェ
          クトです。タプルとしてアンパックすることで個別に取り出すことが
          できます。 *note calls as tuples: 3f51. を参照してください。

               注釈: The way *note mock_calls: 3f48. are recorded means
               that where nested calls are made, the parameters of
               ancestor calls are not recorded and so will always
               compare equal:

                    >>> mock = MagicMock()
                    >>> mock.top(a=3).bottom()
                    <MagicMock name='mock.top().bottom()' id='...'>
                    >>> mock.mock_calls
                    [call.top(a=3), call.top().bottom()]
                    >>> mock.mock_calls[-1] == call.top(a=-1).bottom()
                    True

      -- の属性: __class__

          Normally the ‘__class__’ attribute of an object will return
          its type.  For a mock object with a ‘spec’, ‘__class__’
          returns the spec class instead.  This allows mock objects to
          pass *note isinstance(): 40e. tests for the object they are
          replacing / masquerading as:

               >>> mock = Mock(spec=3)
               >>> isinstance(mock, int)
               True

          ‘__class__’ is assignable to, this allows a mock to pass an
          *note isinstance(): 40e. check without forcing you to use a
          spec:

               >>> mock = Mock()
               >>> mock.__class__ = dict
               >>> isinstance(mock, dict)
               True

 -- クラス: unittest.mock.NonCallableMock (spec=None, wraps=None,
          name=None, spec_set=None, **kwargs)

     呼び出しができない *note Mock: a1a. です。コンストラクタのパラメー
     タは *note Mock: a1a. と同様ですが、 'return_value' や
     'side_effect' は意味を持ちません。

Mock objects that use a class or an instance as a ‘spec’ or ‘spec_set’
are able to pass *note isinstance(): 40e. tests:

     >>> mock = Mock(spec=SomeClass)
     >>> isinstance(mock, SomeClass)
     True
     >>> mock = Mock(spec_set=SomeClass())
     >>> isinstance(mock, SomeClass)
     True

*note Mock: a1a. クラスは、 特殊メソッドをサポートしています。すべての詳
細は *note magic methods: 3f3e. を参照してください。

モッククラスや *note patch(): e5b. デコレータは、任意のキーワード引数を
設定できます。 *note patch(): e5b. デコレータへのキーワード引数は、モッ
クが作られる際のコンストラクタに渡されます。キーワード引数は、モックの属
性を設定します:

     >>> m = MagicMock(attribute=3, other='fish')
     >>> m.attribute
     3
     >>> m.other
     'fish'

子の戻り値や副作用も、ドットで表記することで同様に設定できます。呼び出し
時に直接ドットのついた名前を使用できないので、作成した辞書を ‘**’ でアン
パックする必要があります:

     >>> attrs = {'method.return_value': 3, 'other.side_effect': KeyError}
     >>> mock = Mock(some_attribute='eggs', **attrs)
     >>> mock.some_attribute
     'eggs'
     >>> mock.method()
     3
     >>> mock.other()
     Traceback (most recent call last):
       ...
     KeyError

'spec' (または 'spec_set') によって作成された呼び出し可能なモックは、モ
ックへの呼び出しがマッチしたときに仕様オブジェクトのシグネチャを内省しま
す。したがって、引数を位置引数として渡したか名前で渡したかどうかに関わら
ず、実際の呼び出しの引数とマッチすることができます:

     >>> def f(a, b, c): pass
     ...
     >>> mock = Mock(spec=f)
     >>> mock(1, 2, c=3)
     <Mock name='mock()' id='140161580456576'>
     >>> mock.assert_called_with(1, 2, 3)
     >>> mock.assert_called_with(a=1, b=2, c=3)

これは *note assert_called_with(): 198c, *note
assert_called_once_with(): 3f46, *note assert_has_calls(): 160c. and
*note assert_any_call(): 3f47. にも適用されます。 *note autospec を使う:
3f3f. と、 モックオブジェクトのメソッド呼び出しにも適用されます。

バージョン 3.4 で変更: spec や autospec を用いて生成されたモックオブジェ
クトは、シグネチャを考慮するようになりました。

 -- クラス: unittest.mock.PropertyMock (*args, **kwargs)

     A mock intended to be used as a *note property: 179, or other *note
     descriptor: 1ed1, on a class.  *note PropertyMock: 3f53. provides
     *note __get__(): 1490. and *note __set__(): 1eca. methods so you
     can specify a return value when it is fetched.

     オブジェクトから *note PropertyMock: 3f53. のインスタンスを取得する
     ことは、引数を与えないモックの呼び出しに相当します。設定は、 設定す
     る値を伴った呼び出しになります。:

          >>> class Foo:
          ...     @property
          ...     def foo(self):
          ...         return 'something'
          ...     @foo.setter
          ...     def foo(self, value):
          ...         pass
          ...
          >>> with patch('__main__.Foo.foo', new_callable=PropertyMock) as mock_foo:
          ...     mock_foo.return_value = 'mockity-mock'
          ...     this_foo = Foo()
          ...     print(this_foo.foo)
          ...     this_foo.foo = 6
          ...
          mockity-mock
          >>> mock_foo.mock_calls
          [call(), call(6)]

*note PropertyMock: 3f53. を直接モックに取り付ける方法は、モックの属性を
保存する方法によりうまく動作しません。代わりに、モック型に取り付けてくだ
さい:

     >>> m = MagicMock()
     >>> p = PropertyMock(return_value=3)
     >>> type(m).foo = p
     >>> m.foo
     3
     >>> p.assert_called_once_with()

     注意: If an *note AttributeError: 326. is raised by *note
     PropertyMock: 3f53, it will be interpreted as a missing descriptor
     and *note __getattr__(): 49f. will be called on the parent mock:

          >>> m = MagicMock()
          >>> no_attribute = PropertyMock(side_effect=AttributeError)
          >>> type(m).my_property = no_attribute
          >>> m.my_property
          <MagicMock name='mock.my_property' id='140165240345424'>

     See *note __getattr__(): 49f. for details.

 -- クラス: unittest.mock.AsyncMock (spec=None, side_effect=None,
          return_value=DEFAULT, wraps=None, name=None, spec_set=None,
          unsafe=False, **kwargs)

     An asynchronous version of *note MagicMock: e5a.  The *note
     AsyncMock: a19. object will behave so the object is recognized as
     an async function, and the result of a call is an awaitable.

          >>> mock = AsyncMock()
          >>> asyncio.iscoroutinefunction(mock)
          True
          >>> inspect.isawaitable(mock())
          True

     The result of ‘mock()’ is an async function which will have the
     outcome of ‘side_effect’ or ‘return_value’ after it has been
     awaited:

        - if ‘side_effect’ is a function, the async function will return
          the result of that function,

        - if ‘side_effect’ is an exception, the async function will
          raise the exception,

        - if ‘side_effect’ is an iterable, the async function will
          return the next value of the iterable, however, if the
          sequence of result is exhausted, ‘StopAsyncIteration’ is
          raised immediately,

        - if ‘side_effect’ is not defined, the async function will
          return the value defined by ‘return_value’, hence, by default,
          the async function returns a new *note AsyncMock: a19. object.

     Setting the 'spec' of a *note Mock: a1a. or *note MagicMock: e5a.
     to an async function will result in a coroutine object being
     returned after calling.

          >>> async def async_func(): pass
          ...
          >>> mock = MagicMock(async_func)
          >>> mock
          <MagicMock spec='function' id='...'>
          >>> mock()
          <coroutine object AsyncMockMixin._mock_call at ...>

     Setting the 'spec' of a *note Mock: a1a, *note MagicMock: e5a, or
     *note AsyncMock: a19. to a class with asynchronous and synchronous
     functions will automatically detect the synchronous functions and
     set them as *note MagicMock: e5a. (if the parent mock is *note
     AsyncMock: a19. or *note MagicMock: e5a.) or *note Mock: a1a. (if
     the parent mock is *note Mock: a1a.).  All asynchronous functions
     will be *note AsyncMock: a19.

          >>> class ExampleClass:
          ...     def sync_foo():
          ...         pass
          ...     async def async_foo():
          ...         pass
          ...
          >>> a_mock = AsyncMock(ExampleClass)
          >>> a_mock.sync_foo
          <MagicMock name='mock.sync_foo' id='...'>
          >>> a_mock.async_foo
          <AsyncMock name='mock.async_foo' id='...'>
          >>> mock = Mock(ExampleClass)
          >>> mock.sync_foo
          <Mock name='mock.sync_foo' id='...'>
          >>> mock.async_foo
          <AsyncMock name='mock.async_foo' id='...'>

     Added in version 3.8.

      -- メソッド: assert_awaited ()

          Assert that the mock was awaited at least once.  Note that
          this is separate from the object having been called, the
          ‘await’ keyword must be used:

               >>> mock = AsyncMock()
               >>> async def main(coroutine_mock):
               ...     await coroutine_mock
               ...
               >>> coroutine_mock = mock()
               >>> mock.called
               True
               >>> mock.assert_awaited()
               Traceback (most recent call last):
               ...
               AssertionError: Expected mock to have been awaited.
               >>> asyncio.run(main(coroutine_mock))
               >>> mock.assert_awaited()

      -- メソッド: assert_awaited_once ()

          Assert that the mock was awaited exactly once.

               >>> mock = AsyncMock()
               >>> async def main():
               ...     await mock()
               ...
               >>> asyncio.run(main())
               >>> mock.assert_awaited_once()
               >>> asyncio.run(main())
               >>> mock.assert_awaited_once()
               Traceback (most recent call last):
               ...
               AssertionError: Expected mock to have been awaited once. Awaited 2 times.

      -- メソッド: assert_awaited_with (*args, **kwargs)

          Assert that the last await was with the specified arguments.

               >>> mock = AsyncMock()
               >>> async def main(*args, **kwargs):
               ...     await mock(*args, **kwargs)
               ...
               >>> asyncio.run(main('foo', bar='bar'))
               >>> mock.assert_awaited_with('foo', bar='bar')
               >>> mock.assert_awaited_with('other')
               Traceback (most recent call last):
               ...
               AssertionError: expected await not found.
               Expected: mock('other')
               Actual: mock('foo', bar='bar')

      -- メソッド: assert_awaited_once_with (*args, **kwargs)

          Assert that the mock was awaited exactly once and with the
          specified arguments.

               >>> mock = AsyncMock()
               >>> async def main(*args, **kwargs):
               ...     await mock(*args, **kwargs)
               ...
               >>> asyncio.run(main('foo', bar='bar'))
               >>> mock.assert_awaited_once_with('foo', bar='bar')
               >>> asyncio.run(main('foo', bar='bar'))
               >>> mock.assert_awaited_once_with('foo', bar='bar')
               Traceback (most recent call last):
               ...
               AssertionError: Expected mock to have been awaited once. Awaited 2 times.

      -- メソッド: assert_any_await (*args, **kwargs)

          Assert the mock has ever been awaited with the specified
          arguments.

               >>> mock = AsyncMock()
               >>> async def main(*args, **kwargs):
               ...     await mock(*args, **kwargs)
               ...
               >>> asyncio.run(main('foo', bar='bar'))
               >>> asyncio.run(main('hello'))
               >>> mock.assert_any_await('foo', bar='bar')
               >>> mock.assert_any_await('other')
               Traceback (most recent call last):
               ...
               AssertionError: mock('other') await not found

      -- メソッド: assert_has_awaits (calls, any_order=False)

          Assert the mock has been awaited with the specified calls.
          The *note await_args_list: 18ea. list is checked for the
          awaits.

          If 'any_order' is false then the awaits must be sequential.
          There can be extra calls before or after the specified awaits.

          If 'any_order' is true then the awaits can be in any order,
          but they must all appear in *note await_args_list: 18ea.

               >>> mock = AsyncMock()
               >>> async def main(*args, **kwargs):
               ...     await mock(*args, **kwargs)
               ...
               >>> calls = [call("foo"), call("bar")]
               >>> mock.assert_has_awaits(calls)
               Traceback (most recent call last):
               ...
               AssertionError: Awaits not found.
               Expected: [call('foo'), call('bar')]
               Actual: []
               >>> asyncio.run(main('foo'))
               >>> asyncio.run(main('bar'))
               >>> mock.assert_has_awaits(calls)

      -- メソッド: assert_not_awaited ()

          Assert that the mock was never awaited.

               >>> mock = AsyncMock()
               >>> mock.assert_not_awaited()

      -- メソッド: reset_mock (*args, **kwargs)

          See *note Mock.reset_mock(): cc8.  Also sets *note
          await_count: 3f5c. to 0, *note await_args: 3f5d. to None, and
          clears the *note await_args_list: 18ea.

      -- の属性: await_count

          An integer keeping track of how many times the mock object has
          been awaited.

               >>> mock = AsyncMock()
               >>> async def main():
               ...     await mock()
               ...
               >>> asyncio.run(main())
               >>> mock.await_count
               1
               >>> asyncio.run(main())
               >>> mock.await_count
               2

      -- の属性: await_args

          This is either ‘None’ (if the mock hasn’t been awaited), or
          the arguments that the mock was last awaited with.  Functions
          the same as *note Mock.call_args: 18eb.

               >>> mock = AsyncMock()
               >>> async def main(*args):
               ...     await mock(*args)
               ...
               >>> mock.await_args
               >>> asyncio.run(main('foo'))
               >>> mock.await_args
               call('foo')
               >>> asyncio.run(main('bar'))
               >>> mock.await_args
               call('bar')

      -- の属性: await_args_list

          This is a list of all the awaits made to the mock object in
          sequence (so the length of the list is the number of times it
          has been awaited).  Before any awaits have been made it is an
          empty list.

               >>> mock = AsyncMock()
               >>> async def main(*args):
               ...     await mock(*args)
               ...
               >>> mock.await_args_list
               []
               >>> asyncio.run(main('foo'))
               >>> mock.await_args_list
               [call('foo')]
               >>> asyncio.run(main('bar'))
               >>> mock.await_args_list
               [call('foo'), call('bar')]

 -- クラス: unittest.mock.ThreadingMock (spec=None, side_effect=None,
          return_value=DEFAULT, wraps=None, name=None, spec_set=None,
          unsafe=False, *, timeout=UNSET, **kwargs)

     A version of *note MagicMock: e5a. for multithreading tests.  The
     *note ThreadingMock: 3f5e. object provides extra methods to wait
     for a call to be invoked, rather than assert on it immediately.

     The default timeout is specified by the ‘timeout’ argument, or if
     unset by the *note ThreadingMock.DEFAULT_TIMEOUT: 3f5f. attribute,
     which defaults to blocking (‘None’).

     You can configure the global default timeout by setting *note
     ThreadingMock.DEFAULT_TIMEOUT: 3f5f.

      -- メソッド: wait_until_called (*, timeout=UNSET)

          Waits until the mock is called.

          If a timeout was passed at the creation of the mock or if a
          timeout argument is passed to this function, the function
          raises an *note AssertionError: 675. if the call is not
          performed in time.

               >>> mock = ThreadingMock()
               >>> thread = threading.Thread(target=mock)
               >>> thread.start()
               >>> mock.wait_until_called(timeout=1)
               >>> thread.join()

      -- メソッド: wait_until_any_call_with (*args, **kwargs)

          Waits until the mock is called with the specified arguments.

          If a timeout was passed at the creation of the mock the
          function raises an *note AssertionError: 675. if the call is
          not performed in time.

               >>> mock = ThreadingMock()
               >>> thread = threading.Thread(target=mock, args=("arg1", "arg2",), kwargs={"arg": "thing"})
               >>> thread.start()
               >>> mock.wait_until_any_call_with("arg1", "arg2", arg="thing")
               >>> thread.join()

      -- の属性: DEFAULT_TIMEOUT

          Global default timeout in seconds to create instances of *note
          ThreadingMock: 3f5e.

     Added in version 3.13.

* Menu:

* 呼び出し::
* 属性の削除::
* Mock の名前と name 属性::
* 属性として設定されるモック::

   ---------- Footnotes ----------

   (1) 例外は特殊メソッドと属性だけです (これらは2つのアンダースコアで開
始・終了します)。モックはこれらの代わりに *note AttributeError: 326. を
発生させます。これは、インタープリタが暗黙的にこれらのメソッドを要求する
ためであり、特殊メソッドを予測する際に '非常に' 混乱してしまいます。もし
特殊メソッドのサポートが必要な場合は、 *note magic methods: 3f3e. を参照
してください。


File: python.info,  Node: 呼び出し,  Next: 属性の削除,  Up: Mock クラス

5.26.6.3 呼び出し
.................

モックオブジェクトは呼び出し可能です。呼び出しの戻り値は *note
return_value: 3f44. 属性に設定された値です。デフォルトでは新しいモックオ
ブジェクトを返します。この新しいモックは、属性に最初にアクセスした際に作
成されます (明示もしくはモックの呼び出しによって)。 そしてそれは保存され
、それ以降は同じものが返されます。

呼び出しはオブジェクトとして *note call_args: 18eb. や *note
call_args_list: 3f50. に記録されます。

If *note side_effect: 3f3c. is set then it will be called after the call
has been recorded, so if ‘side_effect’ raises an exception the call is
still recorded.

呼び出された際に例外を発生させるモックを作成するためには、 *note
side_effect: 3f3c. を例外クラスかインスタンスにする方法が最もシンプルで
す:

     >>> m = MagicMock(side_effect=IndexError)
     >>> m(1, 2, 3)
     Traceback (most recent call last):
       ...
     IndexError
     >>> m.mock_calls
     [call(1, 2, 3)]
     >>> m.side_effect = KeyError('Bang!')
     >>> m('two', 'three', 'four')
     Traceback (most recent call last):
       ...
     KeyError: 'Bang!'
     >>> m.mock_calls
     [call(1, 2, 3), call('two', 'three', 'four')]

If *note side_effect: 3f3c. is a function then whatever that function
returns is what calls to the mock return.  The ‘side_effect’ function is
called with the same arguments as the mock.  This allows you to vary the
return value of the call dynamically, based on the input:

     >>> def side_effect(value):
     ...     return value + 1
     ...
     >>> m = MagicMock(side_effect=side_effect)
     >>> m(1)
     2
     >>> m(2)
     3
     >>> m.mock_calls
     [call(1), call(2)]

If you want the mock to still return the default return value (a new
mock), or any set return value, then there are two ways of doing this.
Either return *note return_value: 3f44. from inside *note side_effect:
3f3c, or return *note DEFAULT: 3f43.:

     >>> m = MagicMock()
     >>> def side_effect(*args, **kwargs):
     ...     return m.return_value
     ...
     >>> m.side_effect = side_effect
     >>> m.return_value = 3
     >>> m()
     3
     >>> def side_effect(*args, **kwargs):
     ...     return DEFAULT
     ...
     >>> m.side_effect = side_effect
     >>> m()
     3

To remove a *note side_effect: 3f3c, and return to the default
behaviour, set the ‘side_effect’ to ‘None’:

     >>> m = MagicMock(return_value=6)
     >>> def side_effect(*args, **kwargs):
     ...     return 3
     ...
     >>> m.side_effect = side_effect
     >>> m()
     3
     >>> m.side_effect = None
     >>> m()
     6

The *note side_effect: 3f3c. can also be any iterable object.  Repeated
calls to the mock will return values from the iterable (until the
iterable is exhausted and a *note StopIteration: bc8. is raised):

     >>> m = MagicMock(side_effect=[1, 2, 3])
     >>> m()
     1
     >>> m()
     2
     >>> m()
     3
     >>> m()
     Traceback (most recent call last):
       ...
     StopIteration

もしイテレート可能オブジェクトの要素が例外だった場合には、戻り値として返
される代わりに例外が発生します:

     >>> iterable = (33, ValueError, 66)
     >>> m = MagicMock(side_effect=iterable)
     >>> m()
     33
     >>> m()
     Traceback (most recent call last):
      ...
     ValueError
     >>> m()
     66


File: python.info,  Node: 属性の削除,  Next: Mock の名前と name 属性,  Prev: 呼び出し,  Up: Mock クラス

5.26.6.4 属性の削除
...................

モックオブジェクトは要求に応じて属性を生成することで，任意のオブジェクト
として振る舞うことができます。

You may want a mock object to return ‘False’ to a *note hasattr(): 49e.
call, or raise an *note AttributeError: 326. when an attribute is
fetched.  You can do this by providing an object as a ‘spec’ for a mock,
but that isn't always convenient.

属性を削除することで， *note AttributeError: 326. を発生させ，アクセスを
"妨げる" ようになります．

     >>> mock = MagicMock()
     >>> hasattr(mock, 'm')
     True
     >>> del mock.m
     >>> hasattr(mock, 'm')
     False
     >>> del mock.f
     >>> mock.f
     Traceback (most recent call last):
         ...
     AttributeError: f


File: python.info,  Node: Mock の名前と name 属性,  Next: 属性として設定されるモック,  Prev: 属性の削除,  Up: Mock クラス

5.26.6.5 Mock の名前と name 属性
................................

"name" は *note Mock: a1a. コンストラクタの引数なので、モックオブジェク
トが "name" 属性を持つことを望む場合、単に生成時にそれを渡すことはできま
せん。2つの選択肢があります。1つのオプションは *note configure_mock():
3f45. を使用することです:

     >>> mock = MagicMock()
     >>> mock.configure_mock(name='my_name')
     >>> mock.name
     'my_name'

より単純なオプションはモックの生成後に単に "name" 属性をセットすることで
す:

     >>> mock = MagicMock()
     >>> mock.name = "foo"


File: python.info,  Node: 属性として設定されるモック,  Prev: Mock の名前と name 属性,  Up: Mock クラス

5.26.6.6 属性として設定されるモック
...................................

属性 (もしくは戻り値) に他のモックを設定した場合、このモックは "子" にな
ります。この子に対する呼び出しは、親の *note method_calls: 3f4a. や
*note mock_calls: 3f48. に記録されます。これは、子のモックを構成し、親に
そのモックを設定する際に有用です。また、親に対して設定したすべての子の呼
び出しを記録するため、それらの間の順番を確認する際にも有用です:

     >>> parent = MagicMock()
     >>> child1 = MagicMock(return_value=None)
     >>> child2 = MagicMock(return_value=None)
     >>> parent.child1 = child1
     >>> parent.child2 = child2
     >>> child1(1)
     >>> child2(2)
     >>> parent.mock_calls
     [call.child1(1), call.child2(2)]

モックが名前をもつ場合は、例外的に扱われます。何らかの理由で "子守り" が
発生してほしくないときに、それを防ぐことができます。

     >>> mock = MagicMock()
     >>> not_a_child = MagicMock(name='not-a-child')
     >>> mock.attribute = not_a_child
     >>> mock.attribute()
     <MagicMock name='not-a-child()' id='...'>
     >>> mock.mock_calls
     []

*note patch(): e5b. を用いて作成したモックには、自動的に名前が与えられま
す。名前を持つモックを設定したい場合には、親に対して *note
attach_mock(): 1572. メソッドを呼び出します:

     >>> thing1 = object()
     >>> thing2 = object()
     >>> parent = MagicMock()
     >>> with patch('__main__.thing1', return_value=None) as child1:
     ...     with patch('__main__.thing2', return_value=None) as child2:
     ...         parent.attach_mock(child1, 'child1')
     ...         parent.attach_mock(child2, 'child2')
     ...         child1('one')
     ...         child2('two')
     ...
     >>> parent.mock_calls
     [call.child1('one'), call.child2('two')]


File: python.info,  Node: patcher,  Next: MagicMock と magic method のサポート,  Prev: Mock クラス,  Up: unittest mock --- モックオブジェクトライブラリ

5.26.6.7 patcher
................

patch デコレータは、その関数のスコープ内でパッチを適用するオブジェクトに
対して使用されます。たとえ例外が発生したとしても、パッチは自動的に解除さ
れます。これらすべての機能は文やクラスのデコレータとしても使用できます。

* Menu:

* patch::
* patch.object: patch object.
* patch.dict: patch dict.
* patch.multiple: patch multiple.
* patch のメソッド; start と stop: patch のメソッド start と stop.
* ビルトインをパッチする::
* TEST_PREFIX::
* patch デコレータをネストする::
* どこにパッチするか::
* デスクリプタやプロキシオブジェクトにパッチする::


File: python.info,  Node: patch,  Next: patch object,  Up: patcher

5.26.6.8 patch
..............

     注釈: 重要なのは正しい名前空間に対して patch することです。*note
     where to patch: 3f69. セクションを参照してください。

 -- の関数: unittest.mock.patch (target, new=DEFAULT, spec=None,
          create=False, spec_set=None, autospec=None, new_callable=None,
          **kwargs)

     *note patch(): e5b. は関数デコレータ、クラスデコレータ、コンテキス
     トマネージャーとして利用できます。関数や with 文の body では、
     'target' は 'new' オブジェクトにパッチされます。関数/with 文が終了
     すると、パッチは元に戻されます。

     If 'new' is omitted, then the target is replaced with an *note
     AsyncMock: a19. if the patched object is an async function or a
     *note MagicMock: e5a. otherwise.  If *note patch(): e5b. is used as
     a decorator and 'new' is omitted, the created mock is passed in as
     an extra argument to the decorated function.  If *note patch():
     e5b. is used as a context manager the created mock is returned by
     the context manager.

     'target' は ‘'package.module.ClassName'’ の形式の文字列でなければな
     りません。 ‘target’ はインポートされ、指定されたオブジェクトが
     ‘new’ オブジェクトに置き換えられます。なので、 'target' は *note
     patch(): e5b. を呼び出した環境からインポート可能でなければなりませ
     ん。 target がインポートされるのは、デコレートした時ではなく、デコ
     レートされた関数が呼び出された時です。

     patch が *note MagicMock: e5a. を生成する場合、 'spec' と
     'spec_set' キーワード引数は *note MagicMock: e5a. に渡されます。

     加えて、 ‘spec=True’ もしくは ‘spec_set=True’ を渡すことで、モック
     対象のオブジェクトが spec/spec_set に渡されます。

     'new_callable' allows you to specify a different class, or callable
     object, that will be called to create the 'new' object.  By default
     *note AsyncMock: a19. is used for async functions and *note
     MagicMock: e5a. for the rest.

     より強力な 'spec' の形は 'autospec' です。 ‘autospec=True’ を指定し
     た場合、 mock は置換対象となるオブジェクトから得られる spec で生成
     されます。 mock のすべての属性もまた置換対象となるオブジェクトの属
     性に応じた spec を持ちます。 mock されたメソッドや関数は引数をチェ
     ックし、間違ったシグネチャで呼び出された場合は *note TypeError:
     502. を発生させます。クラスを置き換える mock の場合、その戻り値 (つ
     まりインスタンス) はそのクラスと同じ spec を持ちます。 *note
     create_autospec(): 156b. 関数と *note autospec を使う: 3f3f. を参照
     してください。

     置換対象ではなく任意のオブジェクトを spec として使うために、
     ‘autospec=True’ の代わりに、 ‘autospec=some_object’ と指定すること
     ができます。

     By default *note patch(): e5b. will fail to replace attributes that
     don't exist.  If you pass in ‘create=True’, and the attribute
     doesn't exist, patch will create the attribute for you when the
     patched function is called, and delete it again after the patched
     function has exited.  This is useful for writing tests against
     attributes that your production code creates at runtime.  It is off
     by default because it can be dangerous.  With it switched on you
     can write passing tests against APIs that don't actually exist!

          注釈: 
          バージョン 3.5 で変更: モジュールのビルトインにパッチを当てよ
          うとしているなら、 ‘create=True’ を渡す必要はありません。それ
          はデフォルトで追加されます。

     Patch can be used as a *note TestCase: 41a. class decorator.  It
     works by decorating each test method in the class.  This reduces
     the boilerplate code when your test methods share a common
     patchings set.  *note patch(): e5b. finds tests by looking for
     method names that start with ‘patch.TEST_PREFIX’.  By default this
     is ‘'test'’, which matches the way *note unittest: ef. finds tests.
     You can specify an alternative prefix by setting
     ‘patch.TEST_PREFIX’.

     patch は with 文を使ってコンテキストマネージャーとして使うこともで
     きます。その場合パッチは with 文のブロック内でのみ適用されます。
     "as" を使って、 "as" に続いて指定した変数にパッチされたオブジェクト
     が代入されます。これは *note patch(): e5b. が mock オブジェクトを生
     成するときに便利です。

     *note patch(): e5b. takes arbitrary keyword arguments.  These will
     be passed to *note AsyncMock: a19. if the patched object is
     asynchronous, to *note MagicMock: e5a. otherwise or to
     'new_callable' if specified.

     異なるユースケースのために、 ‘patch.dict(...)’,
     ‘patch.multiple(...)’, ‘patch.object(...)’ が用意されています。

*note patch(): e5b. を関数デコレータとして利用し、 mock を生成してそれを
デコレートされた関数に渡します:

     >>> @patch('__main__.SomeClass')
     ... def function(normal_argument, mock_class):
     ...     print(mock_class is SomeClass)
     ...
     >>> function(None)
     True

クラスをパッチするとそのクラスを *note MagicMock: e5a. の 'インスタンス'
に置き換えます。テスト中のコードからそのクラスがインスタンス化される場合
、 mock の *note return_value: 3f44. が利用されます。

クラスが複数回インスタンス化される場合、 *note side_effect: 3f3c. を利用
して毎回新しい mock を返すようにできます。もしくは、 'return_value' に、
何でも好きなものを設定できます。

To configure return values on methods of 'instances' on the patched
class you must do this on the *note return_value: 3f44.  For example:

     >>> class Class:
     ...     def method(self):
     ...         pass
     ...
     >>> with patch('__main__.Class') as MockClass:
     ...     instance = MockClass.return_value
     ...     instance.method.return_value = 'foo'
     ...     assert Class() is instance
     ...     assert Class().method() == 'foo'
     ...

'spec' か 'spec_set' を指定し、 *note patch(): e5b. が 'クラス' を置換す
るとき、生成された mock の戻り値は同じ spec を持ちます。:

     >>> Original = Class
     >>> patcher = patch('__main__.Class', spec=True)
     >>> MockClass = patcher.start()
     >>> instance = MockClass()
     >>> assert isinstance(instance, Original)
     >>> patcher.stop()

'new_callable' 引数は、デフォルトの *note MagicMock: e5a. の代わりに別の
クラスをモックとして生成したい場合に便利です。例えば、 *note
NonCallableMock: 3f41. を利用したい場合:

     >>> thing = object()
     >>> with patch('__main__.thing', new_callable=NonCallableMock) as mock_thing:
     ...     assert thing is mock_thing
     ...     thing()
     ...
     Traceback (most recent call last):
       ...
     TypeError: 'NonCallableMock' object is not callable

別のユースケースとしては、オブジェクトを *note io.StringIO: ef3. インス
タンスで置き換えることがあります:

     >>> from io import StringIO
     >>> def foo():
     ...     print('Something')
     ...
     >>> @patch('sys.stdout', new_callable=StringIO)
     ... def test(mock_stdout):
     ...     foo()
     ...     assert mock_stdout.getvalue() == 'Something\n'
     ...
     >>> test()

*note patch(): e5b. に mock を生成させる場合、たいてい最初に必要なことは
その mock をセットアップすることです。幾らかのセットアップは patch の呼
び出しから行うことができます。任意のキーワード引数が、生成された mock の
属性に設定されます:

     >>> patcher = patch('__main__.thing', first='one', second='two')
     >>> mock_thing = patcher.start()
     >>> mock_thing.first
     'one'
     >>> mock_thing.second
     'two'

生成された mock の属性のさらに属性、 *note return_value: 3f44. *note
side_effect: 3f3c. などもセットアップできます。これらはキーワード引数の
シンタックスでは直接指定できませんが、それらをキーとする辞書を ‘**’ を使
って *note patch(): e5b. に渡すことができます:

     >>> config = {'method.return_value': 3, 'other.side_effect': KeyError}
     >>> patcher = patch('__main__.thing', **config)
     >>> mock_thing = patcher.start()
     >>> mock_thing.method()
     3
     >>> mock_thing.other()
     Traceback (most recent call last):
       ...
     KeyError

By default, attempting to patch a function in a module (or a method or
an attribute in a class) that does not exist will fail with *note
AttributeError: 326.:

     >>> @patch('sys.non_existing_attribute', 42)
     ... def test():
     ...     assert sys.non_existing_attribute == 42
     ...
     >>> test()
     Traceback (most recent call last):
       ...
     AttributeError: <module 'sys' (built-in)> does not have the attribute 'non_existing_attribute'

but adding ‘create=True’ in the call to *note patch(): e5b. will make
the previous example work as expected:

     >>> @patch('sys.non_existing_attribute', 42, create=True)
     ... def test(mock_stdout):
     ...     assert sys.non_existing_attribute == 42
     ...
     >>> test()

バージョン 3.8 で変更: *note patch(): e5b. now returns an *note
AsyncMock: a19. if the target is an async function.


File: python.info,  Node: patch object,  Next: patch dict,  Prev: patch,  Up: patcher

5.26.6.9 patch.object
.....................

 -- の関数: patch.object (target, attribute, new=DEFAULT, spec=None,
          create=False, spec_set=None, autospec=None, new_callable=None,
          **kwargs)

     オブジェクト ('target') の指定された名前のメンバー ('attribute') を
     mock オブジェクトでパッチします。

     *note patch.object(): 14ff. はデコレータ、クラスデコレータ、コンテ
     キストマネージャーとして利用できます。引数の 'new', 'spec',
     'create', 'spec_set', 'autospec', 'new_callable' は *note patch():
     e5b. と同じ意味を持ちます。 *note patch(): e5b. と同じく、 *note
     patch.object(): 14ff. も mock を生成するための任意のキーワード引数
     を受け取ります。

     クラスデコレータとして利用する場合、 *note patch.object(): 14ff. は
     ‘patch.TEST_PREFIX’ にしたがってラップするメソッドを選択します。

*note patch.object(): 14ff. の呼び出しには3引数の形式と2引数の形式があり
ます。 3引数の場合、 patch 対象のオブジェクト、属性名、その属性を置き換
えるオブジェクトを取ります。

2引数の形式では、置き換えるオブジェクトを省略し、生成された mock がデコ
レート対象となる関数に追加の引数として渡されます:

     >>> @patch.object(SomeClass, 'class_method')
     ... def test(mock_method):
     ...     SomeClass.class_method(3)
     ...     mock_method.assert_called_with(3)
     ...
     >>> test()

'spec', 'create' やその他の *note patch.object(): 14ff. の引数は *note
patch(): e5b. の引数と同じ意味を持ちます。


File: python.info,  Node: patch dict,  Next: patch multiple,  Prev: patch object,  Up: patcher

5.26.6.10 patch.dict
....................

 -- の関数: patch.dict (in_dict, values=(), clear=False, **kwargs)

     辞書や辞書のようなオブジェクトにパッチし、テスト後に元の状態に戻し
     ます。

     'in_dict' は辞書やその他のマップ型のコンテナです。マップ型の場合、
     最低限 get, set, del 操作とキーに対するイテレートをサポートしている
     必要があります。

     'in_dict' に辞書を指定する文字列を渡した場合、それをインポートして
     取得します。

     'values' は対象の辞書にセットする値を含む、辞書か ‘(key, value)’ ペ
     アの iterable です。

     'clear' が true なら、新しい値が設定される前に辞書がクリアされます
     。

     *note patch.dict(): 195e. はまた、任意のキーワード引数を受け取って
     辞書に設定します。

     バージョン 3.8 で変更: *note patch.dict(): 195e. now returns the
     patched dictionary when used as a context manager.

*note patch.dict(): 195e. can be used as a context manager, decorator or
class decorator:

     >>> foo = {}
     >>> @patch.dict(foo, {'newkey': 'newvalue'})
     ... def test():
     ...     assert foo == {'newkey': 'newvalue'}
     ...
     >>> test()
     >>> assert foo == {}

When used as a class decorator *note patch.dict(): 195e. honours
‘patch.TEST_PREFIX’ (default to ‘'test'’) for choosing which methods to
wrap:

     >>> import os
     >>> import unittest
     >>> from unittest.mock import patch
     >>> @patch.dict('os.environ', {'newkey': 'newvalue'})
     ... class TestSample(unittest.TestCase):
     ...     def test_sample(self):
     ...         self.assertEqual(os.environ['newkey'], 'newvalue')

If you want to use a different prefix for your test, you can inform the
patchers of the different prefix by setting ‘patch.TEST_PREFIX’.  For
more details about how to change the value of see *note TEST_PREFIX:
3f6c.

*note patch.dict(): 195e. を使うと、辞書にメンバーを追加するか、または単
にテストが辞書を変更して、その後テストが終了した時にその辞書が確実に復元
されるようにすることができます。

     >>> foo = {}
     >>> with patch.dict(foo, {'newkey': 'newvalue'}) as patched_foo:
     ...     assert foo == {'newkey': 'newvalue'}
     ...     assert patched_foo == {'newkey': 'newvalue'}
     ...     # You can add, update or delete keys of foo (or patched_foo, it's the same dict)
     ...     patched_foo['spam'] = 'eggs'
     ...
     >>> assert foo == {}
     >>> assert patched_foo == {}

     >>> import os
     >>> with patch.dict('os.environ', {'newkey': 'newvalue'}):
     ...     print(os.environ['newkey'])
     ...
     newvalue
     >>> assert 'newkey' not in os.environ

*note patch.dict(): 195e. を呼び出すときにキーワード引数を使って辞書に値
をセットすることができます。

     >>> mymodule = MagicMock()
     >>> mymodule.function.return_value = 'fish'
     >>> with patch.dict('sys.modules', mymodule=mymodule):
     ...     import mymodule
     ...     mymodule.function('some', 'args')
     ...
     'fish'

*note patch.dict(): 195e. can be used with dictionary like objects that
aren't actually dictionaries.  At the very minimum they must support
item getting, setting, deleting and either iteration or membership test.
This corresponds to the magic methods *note __getitem__(): 264, *note
__setitem__(): 146e, *note __delitem__(): 146f. and either *note
__iter__(): 1c2b. or *note __contains__(): 1ebe.

     >>> class Container:
     ...     def __init__(self):
     ...         self.values = {}
     ...     def __getitem__(self, name):
     ...         return self.values[name]
     ...     def __setitem__(self, name, value):
     ...         self.values[name] = value
     ...     def __delitem__(self, name):
     ...         del self.values[name]
     ...     def __iter__(self):
     ...         return iter(self.values)
     ...
     >>> thing = Container()
     >>> thing['one'] = 1
     >>> with patch.dict(thing, one=2, two=3):
     ...     assert thing['one'] == 2
     ...     assert thing['two'] == 3
     ...
     >>> assert thing['one'] == 1
     >>> assert list(thing) == ['one']


File: python.info,  Node: patch multiple,  Next: patch のメソッド start と stop,  Prev: patch dict,  Up: patcher

5.26.6.11 patch.multiple
........................

 -- の関数: patch.multiple (target, spec=None, create=False,
          spec_set=None, autospec=None, new_callable=None, **kwargs)

     1回の呼び出しで複数のパッチを実行します。パッチ対象のオブジェクト
     (あるいはそのオブジェクトをインポートするための文字列) と、パッチ用
     のキーワード引数を取ります:

          with patch.multiple(settings, FIRST_PATCH='one', SECOND_PATCH='two'):
              ...

     *note patch.multiple(): 3f6e. に mock を生成させたい場合、キーワー
     ド引数の値に *note DEFAULT: 3f43. を指定します。この場合生成された
     モックはデコレート対象の関数にキーワード引数として渡され、コンテキ
     ストマネージャーとして *note patch.multiple(): 3f6e. が利用された場
     合は辞書として返します。

     *note patch.multiple(): 3f6e. はデコレータ、クラスデコレータ、コン
     テキストマネージャーとして使えます。引数の 'spec', 'spec_set',
     'create', 'autospec', 'new_callable' は *note patch(): e5b. の引数
     と同じ意味を持ちます。これらの引数は *note patch.multiple(): 3f6e.
     によって適用される 'すべての' パッチに対して適用されます。

     クラスデコレータとして利用する場合、 *note patch.multiple(): 3f6e.
     は ‘patch.TEST_PREFIX’ にしたがってラップするメソッドを選択します。

*note patch.multiple(): 3f6e. に mock を生成させたい場合、キーワード引数
の値に *note DEFAULT: 3f43. を指定します。*note patch.multiple(): 3f6e.
をデコレータとして使った場合生成されたモックはデコレート対象の関数にキー
ワード引数として渡されます。:

     >>> thing = object()
     >>> other = object()

     >>> @patch.multiple('__main__', thing=DEFAULT, other=DEFAULT)
     ... def test_function(thing, other):
     ...     assert isinstance(thing, MagicMock)
     ...     assert isinstance(other, MagicMock)
     ...
     >>> test_function()

*note patch.multiple(): 3f6e. は他の ‘patch’ デコレータとネストして利用
できますが、キーワード引数は *note patch(): e5b. によって作られる通常の
引数の '後ろ' で受け取る必要があります:

     >>> @patch('sys.exit')
     ... @patch.multiple('__main__', thing=DEFAULT, other=DEFAULT)
     ... def test_function(mock_exit, other, thing):
     ...     assert 'other' in repr(other)
     ...     assert 'thing' in repr(thing)
     ...     assert 'exit' in repr(mock_exit)
     ...
     >>> test_function()

*note patch.multiple(): 3f6e. がコンテキストマネージャーとして利用される
場合、コンテキストマネージャーが返す値は、名前がキーで値が生成された
mock となる辞書です:

     >>> with patch.multiple('__main__', thing=DEFAULT, other=DEFAULT) as values:
     ...     assert 'other' in repr(values['other'])
     ...     assert 'thing' in repr(values['thing'])
     ...     assert values['thing'] is thing
     ...     assert values['other'] is other
     ...


File: python.info,  Node: patch のメソッド start と stop,  Next: ビルトインをパッチする,  Prev: patch multiple,  Up: patcher

5.26.6.12 patch のメソッド: start と stop
.........................................

All the patchers have ‘start()’ and ‘stop()’ methods.  These make it
simpler to do patching in ‘setUp’ methods or where you want to do
multiple patches without nesting decorators or with statements.

To use them call *note patch(): e5b, *note patch.object(): 14ff. or
*note patch.dict(): 195e. as normal and keep a reference to the returned
‘patcher’ object.  You can then call ‘start()’ to put the patch in place
and ‘stop()’ to undo it.

*note patch(): e5b. に mock を生成させる場合、 ‘patcher.start’ の呼び出
しの戻り値として mock を受け取れます。:

     >>> patcher = patch('package.module.ClassName')
     >>> from package import module
     >>> original = module.ClassName
     >>> new_mock = patcher.start()
     >>> assert module.ClassName is not original
     >>> assert module.ClassName is new_mock
     >>> patcher.stop()
     >>> assert module.ClassName is original
     >>> assert module.ClassName is not new_mock

A typical use case for this might be for doing multiple patches in the
‘setUp’ method of a *note TestCase: 41a.:

     >>> class MyTest(unittest.TestCase):
     ...     def setUp(self):
     ...         self.patcher1 = patch('package.module.Class1')
     ...         self.patcher2 = patch('package.module.Class2')
     ...         self.MockClass1 = self.patcher1.start()
     ...         self.MockClass2 = self.patcher2.start()
     ...
     ...     def tearDown(self):
     ...         self.patcher1.stop()
     ...         self.patcher2.stop()
     ...
     ...     def test_something(self):
     ...         assert package.module.Class1 is self.MockClass1
     ...         assert package.module.Class2 is self.MockClass2
     ...
     >>> MyTest('test_something').run()

     注意: この方式を使う場合、必ず ‘stop’ メソッドを呼び出してパッチが
     解除する必要があります。 ‘setUp’ の中で例外が発生した場合
     ‘tearDown’ が呼び出されないので、これは意外に面倒です。 *note
     unittest.TestCase.addCleanup(): a4f. を使うと簡単にできます:

          >>> class MyTest(unittest.TestCase):
          ...     def setUp(self):
          ...         patcher = patch('package.module.Class')
          ...         self.MockClass = patcher.start()
          ...         self.addCleanup(patcher.stop)
          ...
          ...     def test_something(self):
          ...         assert package.module.Class is self.MockClass
          ...

     この方式を使うと ‘patcher’ オブジェクトの参照を維持する必要がなくな
     るという特典も付きます。

*note patch.stopall(): 3f71. を利用してすべての start されたパッチを
stop することもできます。

 -- の関数: patch.stopall ()

     すべての有効なパッチを stop します。 ‘start’ で開始したパッチしか
     stop しません。


File: python.info,  Node: ビルトインをパッチする,  Next: TEST_PREFIX,  Prev: patch のメソッド start と stop,  Up: patcher

5.26.6.13 ビルトインをパッチする
................................

モジュール内の任意のビルトインに対してパッチを当てることができます。以下
の例はビルトインの *note ord(): 1e51. を修正します:

     >>> @patch('__main__.ord')
     ... def test(mock_ord):
     ...     mock_ord.return_value = 101
     ...     print(ord('c'))
     ...
     >>> test()
     101


File: python.info,  Node: TEST_PREFIX,  Next: patch デコレータをネストする,  Prev: ビルトインをパッチする,  Up: patcher

5.26.6.14 TEST_PREFIX
.....................

すべての patcher はクラスデコレータとして利用できます。この場合、そのク
ラスのすべてのテストメソッドをラップします。 patcher は ‘'test'’ で始ま
る名前のメソッドをテストメソッドだと認識します。これはデフォルトで *note
unittest.TestLoader: 26e. がテストメソッドを見つける方法と同じです。

他の prefix を使う事もできます。その場合、 patcher にその prefix を
‘patch.TEST_PREFIX’ に設定することで教えることができます:

     >>> patch.TEST_PREFIX = 'foo'
     >>> value = 3
     >>>
     >>> @patch('__main__.value', 'not three')
     ... class Thing:
     ...     def foo_one(self):
     ...         print(value)
     ...     def foo_two(self):
     ...         print(value)
     ...
     >>>
     >>> Thing().foo_one()
     not three
     >>> Thing().foo_two()
     not three
     >>> value
     3


File: python.info,  Node: patch デコレータをネストする,  Next: どこにパッチするか,  Prev: TEST_PREFIX,  Up: patcher

5.26.6.15 patch デコレータをネストする
......................................

複数のパッチを行いたい場合、シンプルにデコレータを重ねることができます。

次のパターンのように patch デコレータを重ねることができます:

     >>> @patch.object(SomeClass, 'class_method')
     ... @patch.object(SomeClass, 'static_method')
     ... def test(mock1, mock2):
     ...     assert SomeClass.static_method is mock1
     ...     assert SomeClass.class_method is mock2
     ...     SomeClass.static_method('foo')
     ...     SomeClass.class_method('bar')
     ...     return mock1, mock2
     ...
     >>> mock1, mock2 = test()
     >>> mock1.assert_called_once_with('foo')
     >>> mock2.assert_called_once_with('bar')

デコレータは下から上へと適用されることに注意してください。これは Python
がデコレータを適用する標準的な方法です。テスト関数に渡される生成された
mock の順番もこれに一致します。


File: python.info,  Node: どこにパッチするか,  Next: デスクリプタやプロキシオブジェクトにパッチする,  Prev: patch デコレータをネストする,  Up: patcher

5.26.6.16 どこにパッチするか
............................

*note patch(): e5b. は (一時的に) ある '名前' が参照しているオブジェクト
を別のものに変更することで適用されます。任意のオブジェクトには、それを参
照するたくさんの名前が存在しえます。なので、必ずテスト対象のシステムが使
っている名前に対して patch しなければなりません。

基本的な原則は、オブジェクトが 'ルックアップ' されるところにパッチするこ
とです。その場所はオブジェクトが定義されたところとは限りません。これを説
明するためにいくつかの例を挙げます。

次のような構造を持ったプロジェクトをテストしようとしていると仮定してくだ
さい:

     a.py
         -> Defines SomeClass

     b.py
         -> from a import SomeClass
         -> some_function instantiates SomeClass

いま、 ‘some_function’ をテストしようとしていて、そのために ‘SomeClass’
を *note patch(): e5b. を使って mock しようとしています。 モジュール b を
インポートした時点で、 b は ‘SomeClass’ を a からインポートしています。
この状態で ‘a.SomeClass’ を *note patch(): e5b. を使って mock out しても
テストには影響しません。モジュール b はすでに '本物の' ‘SomeClass’ への
参照を持っていて、パッチの影響を受けないからです。

重要なのは、 ‘SomeClass’ が使われている (もしくはルックアップされている)
場所にパッチすることです。この場合、 ‘some_function’ はモジュール b の中
にインポートされた ‘SomeClass’ をルックアップしています。なのでパッチは
次のようにしなければなりません:

     @patch('b.SomeClass')

ですが、別のシナリオとして、module b が ‘from a import SomeClass’ ではな
く ‘import a’ をしていて、 ‘some_function’ が ‘a.SomeClass’ を利用してい
たとします。どちらのインポートも一般的なものです。この場合、パッチしたい
クラスはそのモジュールからルックアップされているので、 ‘a.SomeClass’ を
パッチする必要があります:

     @patch('a.SomeClass')


File: python.info,  Node: デスクリプタやプロキシオブジェクトにパッチする,  Prev: どこにパッチするか,  Up: patcher

5.26.6.17 デスクリプタやプロキシオブジェクトにパッチする
........................................................

*note patch: 3f68. と *note patch.object: 3f6a. はどちらも デスクリプタ
(クラスメソッド、static メソッド、プロパティ) を正しく patch できます。
デスクリプタに patch する場合、インスタンスではなく 'class' にパッチする
必要があります。これらはまた '幾らかの' 属性アクセスをプロキシするオブジ
ェクト、例えば django の setttings オブジェクト(1) に対しても機能します
。

   ---------- Footnotes ----------

   (1) 
https://web.archive.org/web/20200603181648/http://www.voidspace.org.uk/python/weblog/arch_d7_2010_12_04.shtml#e1198


File: python.info,  Node: MagicMock と magic method のサポート,  Next: ヘルパー,  Prev: patcher,  Up: unittest mock --- モックオブジェクトライブラリ

5.26.6.18 MagicMock と magic method のサポート
..............................................

* Menu:

* Magic Method をモックする::
* Magic Mock::


File: python.info,  Node: Magic Method をモックする,  Next: Magic Mock,  Up: MagicMock と magic method のサポート

5.26.6.19 Magic Method をモックする
...................................

*note Mock: a1a. supports mocking the Python protocol methods, also
known as *note "magic methods": 3f79.  This allows mock objects to
replace containers or other objects that implement Python protocols.

magic method は通常のメソッドとはルックアップ方法が異なるので (1), magic
method のサポートは特別に実装されています。そのため、サポートされている
のは特定の magic method のみです。'ほとんど' すべてのメソッドをサポート
していますが、足りないものを見つけたら私達に教えてください。

magic method を mock するには、対象の method に対して関数や mock のイン
スタンスをセットします。もし関数を使う場合、それは第一引数に ‘self’ を取
る '必要があります' (2).

     >>> def __str__(self):
     ...     return 'fooble'
     ...
     >>> mock = Mock()
     >>> mock.__str__ = __str__
     >>> str(mock)
     'fooble'

     >>> mock = Mock()
     >>> mock.__str__ = Mock()
     >>> mock.__str__.return_value = 'fooble'
     >>> str(mock)
     'fooble'

     >>> mock = Mock()
     >>> mock.__iter__ = Mock(return_value=iter([]))
     >>> list(mock)
     []

ユースケースの1つは *note with: 59c. 文の中でコンテキストマネージャーと
して使われるオブジェクトを mock することです。

     >>> mock = Mock()
     >>> mock.__enter__ = Mock(return_value='foo')
     >>> mock.__exit__ = Mock(return_value=False)
     >>> with mock as m:
     ...     assert m == 'foo'
     ...
     >>> mock.__enter__.assert_called_with()
     >>> mock.__exit__.assert_called_with(None, None, None)

magic method の呼び出しは *note method_calls: 3f4a. に含まれませんが、
*note mock_calls: 3f48. には記録されます。

     注釈: mock を生成するのに 'spec' キーワード引数を使った場合、 spec
     に含まれない magic method を設定しようとすると *note
     AttributeError: 326. が発生します。

サポートしている magic method の完全なリスト:

   * ‘__hash__’, ‘__sizeof__’, ‘__repr__’, ‘__str__’

   * ‘__dir__’, ‘__format__’, ‘__subclasses__’

   * ‘__round__’, ‘__floor__’, ‘__trunc__’ と ‘__ceil__’

   * 比較: ‘__lt__’, ‘__gt__’, ‘__le__’, ‘__ge__’, ‘__eq__’, ‘__ne__’

   * コンテナメソッド: ‘__getitem__’, ‘__setitem__’, ‘__delitem__’,
     ‘__contains__’, ‘__len__’, ‘__iter__’, ‘__reversed__’,
     ‘__missing__’

   * Context manager: ‘__enter__’, ‘__exit__’, ‘__aenter__’ and
     ‘__aexit__’

   * 単項算術メソッド: ‘__neg__’, ‘__pos__’, ‘__invert__’

   * The numeric methods (including right hand and in-place variants):
     ‘__add__’, ‘__sub__’, ‘__mul__’, ‘__matmul__’, ‘__truediv__’,
     ‘__floordiv__’, ‘__mod__’, ‘__divmod__’, ‘__lshift__’,
     ‘__rshift__’, ‘__and__’, ‘__xor__’, ‘__or__’, and ‘__pow__’

   * 算術変換メソッド: ‘__complex__’, ‘__int__’, ‘__float__’,
     ‘__index__’

   * デスクリプタメソッド: ‘__get__’, ‘__set__’, ‘__delete__’

   * pickle: ‘__reduce__’, ‘__reduce_ex__’, ‘__getinitargs__’,
     ‘__getnewargs__’, ‘__getstate__’, ‘__setstate__’

   * File system path representation: ‘__fspath__’

   * Asynchronous iteration methods: ‘__aiter__’ and ‘__anext__’

バージョン 3.8 で変更: Added support for *note os.PathLike.__fspath__():
c20.

バージョン 3.8 で変更: Added support for ‘__aenter__’, ‘__aexit__’,
‘__aiter__’ and ‘__anext__’.

以下のメソッドは存在しますが、mock が利用している、動的に設定不可能、そ
の他の問題が発生する可能性があるなどの理由で 'サポートされていません':

   * ‘__getattr__’, ‘__setattr__’, ‘__init__’, ‘__new__’

   * ‘__prepare__’, ‘__instancecheck__’, ‘__subclasscheck__’, ‘__del__’

   ---------- Footnotes ----------

   (1) Magic method はインスタンスではなくクラスからルックアップされるは
ずです。Python のバージョンによってこのルールが適用されるかどうかに違い
があります。サポートされているプロトコルメソッドは、サポートされているす
べての Python のバージョンで動作するはずです。

   (2) 関数はクラスまで hook しますが、各 ‘Mock’ インスタンス間の独立性
は保たれます。


File: python.info,  Node: Magic Mock,  Prev: Magic Method をモックする,  Up: MagicMock と magic method のサポート

5.26.6.20 Magic Mock
....................

‘MagicMock’ 系のクラスは2種類あります: *note MagicMock: e5a. と *note
NonCallableMagicMock: 3f42. です。

 -- クラス: unittest.mock.MagicMock (*args, **kw)

     ‘MagicMock’ is a subclass of *note Mock: a1a. with default
     implementations of most of the *note magic methods: 3f79.  You can
     use ‘MagicMock’ without having to configure the magic methods
     yourself.

     コンストラクタの引数は *note Mock: a1a. と同じ意味を持っています。

     'spec' か 'spec_set' 引数を利用した場合、 spec に存在する magic
     method 'のみ' が生成されます。

 -- クラス: unittest.mock.NonCallableMagicMock (*args, **kw)

     callable でないバージョンの *note MagicMock: e5a.

     コンストラクタの引数は *note MagicMock: e5a. と同じ意味を持ちますが
     、 'return_value' と 'side_effect' は callable でない mock では意味
     を持ちません。

*note MagicMock: e5a. が magic method をセットアップするので、あとは通常
の方法で構成したり利用したりできます:

     >>> mock = MagicMock()
     >>> mock[3] = 'fish'
     >>> mock.__setitem__.assert_called_with(3, 'fish')
     >>> mock.__getitem__.return_value = 'result'
     >>> mock[2]
     'result'

デフォルトでは、多くのプロトコルメソッドは特定の型の戻り値を要求されます
。それらのメソッドではその型のデフォルトの戻り値がデフォルトの戻り値とし
て設定されているので、戻り値に興味が有る場合以外は何もしなくても利用可能
です。デフォルトの値を変更したい場合は手動で戻り値を設定可能です。

メソッドとそのデフォルト値:

   * ‘__lt__’: *note NotImplemented: 79d.

   * ‘__gt__’: ‘NotImplemented’

   * ‘__le__’: ‘NotImplemented’

   * ‘__ge__’: ‘NotImplemented’

   * ‘__int__’: ‘1’

   * ‘__contains__’: ‘False’

   * ‘__len__’: ‘0’

   * ‘__iter__’: ‘iter([])’

   * ‘__exit__’: ‘False’

   * ‘__aexit__’: ‘False’

   * ‘__complex__’: ‘1j’

   * ‘__float__’: ‘1.0’

   * ‘__bool__’: ‘True’

   * ‘__index__’: ‘1’

   * ‘__hash__’: mock のデフォルトの hash

   * ‘__str__’: mock のデフォルトの str

   * ‘__sizeof__’: mock のデフォルトの sizeof

例えば:

     >>> mock = MagicMock()
     >>> int(mock)
     1
     >>> len(mock)
     0
     >>> list(mock)
     []
     >>> object() in mock
     False

The two equality methods, ‘__eq__()’ and ‘__ne__()’, are special.  They
do the default equality comparison on identity, using the *note
side_effect: 3f3c. attribute, unless you change their return value to
return something else:

     >>> MagicMock() == 3
     False
     >>> MagicMock() != 3
     True
     >>> mock = MagicMock()
     >>> mock.__eq__.return_value = True
     >>> mock == 3
     True

‘MagicMock.__iter__()’ の return_value は任意の iterable で、イテレータ
である必要はありません:

     >>> mock = MagicMock()
     >>> mock.__iter__.return_value = ['a', 'b', 'c']
     >>> list(mock)
     ['a', 'b', 'c']
     >>> list(mock)
     ['a', 'b', 'c']

return_value が iterator であった場合、最初のイテレートでその iterator を
消費してしまい、2回目以降のイテレートの結果が空になってしまいます:

     >>> mock.__iter__.return_value = iter(['a', 'b', 'c'])
     >>> list(mock)
     ['a', 'b', 'c']
     >>> list(mock)
     []

‘MagicMock’ はいくつかの曖昧であったり時代遅れなものをのぞいて、対応して
いる magic method を事前にセットアップします。自動でセットアップされてい
ないものも必要なら手動でセットアップすることができます。

‘MagicMock’ がサポートしているもののデフォルトではセットアップしない
magic method:

   * ‘__subclasses__’

   * ‘__dir__’

   * ‘__format__’

   * ‘__get__’, ‘__set__’, ‘__delete__’

   * ‘__reversed__’, ‘__missing__’

   * ‘__reduce__’, ‘__reduce_ex__’, ‘__getinitargs__’, ‘__getnewargs__’,
     ‘__getstate__’, ‘__setstate__’

   * ‘__getformat__’


File: python.info,  Node: ヘルパー,  Next: Order of precedence of side_effect return_value and wraps,  Prev: MagicMock と magic method のサポート,  Up: unittest mock --- モックオブジェクトライブラリ

5.26.6.21 ヘルパー
..................

* Menu:

* sentinel::
* DEFAULT::
* call::
* create_autospec::
* ANY::
* FILTER_DIR::
* mock_open::
* autospec を使う::
* Sealing mocks::


File: python.info,  Node: sentinel,  Next: DEFAULT,  Up: ヘルパー

5.26.6.22 sentinel
..................

 -- データ: unittest.mock.sentinel

     ‘sentinel’ オブジェクトはテストで必要なユニークなオブジェクトを簡単
     に提供します。

     属性はアクセス時にオンデマンドで生成されます。同じ属性に複数回アク
     セスすると必ず同じオブジェクトが返されます。返されるオブジェクトは
     、テスト失敗のメッセージがわかりやすくなるように気が利いた repr を
     持ちます。

     バージョン 3.7 で変更: The ‘sentinel’ attributes now preserve their
     identity when they are *note copied: 1e. or *note pickled: 95.

特定のオブジェクトが他のメソッドに引数として渡されることをテストしたり、
返されることをテストしたい場合があります。このテストのために名前がついた
sentinel オブジェクトを作るのが一般的です。 *note sentinel: b6e. はこの
ようなオブジェクトを生成し、同一性をテストするのに便利な方法を提供します
。

次の例では、 ‘method’ が ‘sentinel.some_object’ を返すようにモンキーパッ
チしています:

     >>> real = ProductionClass()
     >>> real.method = Mock(name="method")
     >>> real.method.return_value = sentinel.some_object
     >>> result = real.method()
     >>> assert result is sentinel.some_object
     >>> result
     sentinel.some_object


File: python.info,  Node: DEFAULT,  Next: call,  Prev: sentinel,  Up: ヘルパー

5.26.6.23 DEFAULT
.................

 -- データ: unittest.mock.DEFAULT

     *note DEFAULT: 3f43. オブジェクトは事前に生成された sentinel (実際
     には ‘sentinel.DEFAULT’) オブジェクトです。 *note side_effect:
     3f3c. 関数が、通常の戻り値を使うことを示すために使います。


File: python.info,  Node: call,  Next: create_autospec,  Prev: DEFAULT,  Up: ヘルパー

5.26.6.24 call
..............

 -- の関数: unittest.mock.call (*args, **kwargs)

     *note call(): 1939. は *note call_args: 18eb, *note call_args_list:
     3f50, *note mock_calls: 3f48, *note method_calls: 3f4a. と比較して
     より下端に assert できるようにするためのヘルパーオブジェクトです。
     *note call(): 1939. は *note assert_has_calls(): 160c. と組み合わせ
     て使うこともできます。

          >>> m = MagicMock(return_value=None)
          >>> m(1, 2, a='foo', b='bar')
          >>> m()
          >>> m.call_args_list == [call(1, 2, a='foo', b='bar'), call()]
          True

 -- メソッド: call.call_list ()

     複数回の呼び出しを表す call オブジェクトに対して、 *note
     call_list(): 3f7f. はすべての途中の呼び出しと最終の呼び出しを含むリ
     ストを返します。

‘call_list’ は特に "chained call" に対して assert するのに便利です。
"chained call" は1行のコードにおける複数の呼び出しです。この結果は mock
の *note mock_calls: 3f48. に複数の call エントリとして格納されます。こ
の call のシーケンスを手動で構築するのは退屈な作業になります。

*note call_list(): 3f7f. は同じ chained call からその call のシーケンス
を構築することができます:

     >>> m = MagicMock()
     >>> m(1).method(arg='foo').other('bar')(2.0)
     <MagicMock name='mock().method().other()()' id='...'>
     >>> kall = call(1).method(arg='foo').other('bar')(2.0)
     >>> kall.call_list()
     [call(1),
      call().method(arg='foo'),
      call().method().other('bar'),
      call().method().other()(2.0)]
     >>> m.mock_calls == kall.call_list()
     True
‘call’ オブジェクトは、どう構築されたかによって、 (位置引数、キーワード
引数) のタプルか、 (名前、位置引数、キーワード引数) のタプルになります。
自分で call オブジェクトを構築するときはこれを意識する必要はありませんが
、 *note Mock.call_args: 18eb, *note Mock.call_args_list: 3f50, *note
Mock.mock_calls: 3f48. 属性の中の ‘call’ オブジェクトを解析して個々の引
数を解析することができます。

*note Mock.call_args: 18eb. と *note Mock.call_args_list: 3f50. の中の
‘call’ オブジェクトは (位置引数, キーワード引数) のタプルで、 *note
Mock.mock_calls: 3f48. の中の ‘call’ オブジェクトや自分で構築したオブジ
ェクトは (名前, 位置引数, キーワード引数) のタプルになります。

call オブジェクトの "タプル性" を使って、より複雑な内省とアサートを行う
ために各引数を取り出しすことができます。位置引数はタプル (位置引数が存在
しない場合は空のタプル) で、キーワード引数は辞書になります:

     >>> m = MagicMock(return_value=None)
     >>> m(1, 2, 3, arg='one', arg2='two')
     >>> kall = m.call_args
     >>> kall.args
     (1, 2, 3)
     >>> kall.kwargs
     {'arg': 'one', 'arg2': 'two'}
     >>> kall.args is kall[0]
     True
     >>> kall.kwargs is kall[1]
     True

     >>> m = MagicMock()
     >>> m.foo(4, 5, 6, arg='two', arg2='three')
     <MagicMock name='mock.foo()' id='...'>
     >>> kall = m.mock_calls[0]
     >>> name, args, kwargs = kall
     >>> name
     'foo'
     >>> args
     (4, 5, 6)
     >>> kwargs
     {'arg': 'two', 'arg2': 'three'}
     >>> name is m.mock_calls[0][0]
     True


File: python.info,  Node: create_autospec,  Next: ANY,  Prev: call,  Up: ヘルパー

5.26.6.25 create_autospec
.........................

 -- の関数: unittest.mock.create_autospec (spec, spec_set=False,
          instance=False, **kwargs)

     他のオブジェクトを spec として利用して mock オブジェクトを作ります
     。 mock の属性も、 'spec' オブジェクトの該当する属性を spec として
     利用します。

     mock された関数やメソッドは、正しいシグネチャで呼び出されたことを確
     認するために引数をチェックします。

     'spec_set' が ‘True’ のとき、 spec オブジェクトにない属性をセットし
     ようとすると *note AttributeError: 326. を発生させます。

     spec にクラスが指定された場合、 mock の戻り値 (そのクラスのインスタ
     ンス) は同じ spec を持ちます。 ‘instance=True’ を指定すると、インス
     タンスオブジェクトの spec としてクラスを利用できます。返される mock
     は、モックのインスタンスが callable な場合にだけ callable となりま
     す。

     *note create_autospec(): 156b. は任意のキーワード引数を受け取り、生
     成する mock のコンストラクタに渡します。

*note create_autospec(): 156b. や、 *note patch(): e5b. の 'autospec' 引
数で autospec を使うサンプルは *note autospec を使う: 3f3f. を参照してく
ださい。

バージョン 3.8 で変更: *note create_autospec(): 156b. now returns an
*note AsyncMock: a19. if the target is an async function.


File: python.info,  Node: ANY,  Next: FILTER_DIR,  Prev: create_autospec,  Up: ヘルパー

5.26.6.26 ANY
.............

 -- データ: unittest.mock.ANY

mock の呼び出しのうち '幾つか' の引数に対して assert したいけれども、そ
れ以外の引数は気にしない、あるいは *note call_args: 18eb. から個別に取り
出してより高度な assert を行いたい場合があります。

特定の引数を無視するために、 'すべて' と等しくなるオブジェクトを使うこと
ができます。そうすると、 *note assert_called_with(): 198c. と *note
assert_called_once_with(): 3f46. は、実際の引数が何であったかに関わらず
成功します。

     >>> mock = Mock(return_value=None)
     >>> mock('foo', bar=object())
     >>> mock.assert_called_once_with('foo', bar=ANY)

*note mock_calls: 3f48. などの call list との比較に *note ANY: 1937. を
使うこともできます:

     >>> m = MagicMock(return_value=None)
     >>> m(1)
     >>> m(1, 2)
     >>> m(object())
     >>> m.mock_calls == [call(1), call(1, 2), ANY]
     True

*note ANY: 1937. is not limited to comparisons with call objects and so
can also be used in test assertions:

     class TestStringMethods(unittest.TestCase):

         def test_split(self):
             s = 'hello world'
             self.assertEqual(s.split(), ['hello', ANY])


File: python.info,  Node: FILTER_DIR,  Next: mock_open,  Prev: ANY,  Up: ヘルパー

5.26.6.27 FILTER_DIR
....................

 -- データ: unittest.mock.FILTER_DIR

*note FILTER_DIR: 3f4c. は mock オブジェクトが *note dir(): 5fe. に何を
返すかを制御するためのモジュールレベル変数です。デフォルトは ‘True’ で、
以下に示すフィルタリングを行い、有用なメンバーだけを表示します。このフィ
ルタリングが嫌な場合や、何かの診断のためにフィルタリングを切りたい場合は
、 ‘mock.FILTER_DIR = False’ と設定してください。

フィルタリングが有効な場合、 ‘dir(some_mock)’ は有用な属性だけを表示し、
また通常は表示されない動的に生成される属性も表示します。 mock が 'spec'
を使って(もちろん 'autospec' でも)生成された場合、元のオブジェクトのすべ
ての属性が、まだアクセスされていなかったとしても、表示されます。

     >>> dir(Mock())
     ['assert_any_call',
      'assert_called',
      'assert_called_once',
      'assert_called_once_with',
      'assert_called_with',
      'assert_has_calls',
      'assert_not_called',
      'attach_mock',
      ...
     >>> from urllib import request
     >>> dir(Mock(spec=request))
     ['AbstractBasicAuthHandler',
      'AbstractDigestAuthHandler',
      'AbstractHTTPHandler',
      'BaseHandler',
      ...

多くのあまり有用ではない (mock 対象のものではなく、 *note Mock: a1a. 自
身のプライベートな) 属性は、アンダースコアと2つのアンダースコアで prefix
された属性は *note Mock: a1a. に対して *note dir(): 5fe. した結果からフ
ィルタリングされます。この動作が嫌な場合は、モジュールレベルの *note
FILTER_DIR: 3f4c. スイッチを設定することでフィルターを切ることができます
。

     >>> from unittest import mock
     >>> mock.FILTER_DIR = False
     >>> dir(mock.Mock())
     ['_NonCallableMock__get_return_value',
      '_NonCallableMock__get_side_effect',
      '_NonCallableMock__return_value_doc',
      '_NonCallableMock__set_return_value',
      '_NonCallableMock__set_side_effect',
      '__call__',
      '__class__',
      ...

Alternatively you can just use ‘vars(my_mock)’ (instance members) and
‘dir(type(my_mock))’ (type members) to bypass the filtering irrespective
of *note FILTER_DIR: 3f4c.


File: python.info,  Node: mock_open,  Next: autospec を使う,  Prev: FILTER_DIR,  Up: ヘルパー

5.26.6.28 mock_open
...................

 -- の関数: unittest.mock.mock_open (mock=None, read_data=None)

     *note open(): 4e5. の利用を置き換えるための mock を作るヘルパー関数
     。 *note open(): 4e5. を直接呼んだりコンテキストマネージャーとして
     利用する場合に使うことができます。

     'mock' 引数は構成する mock オブジェクトです。 ‘None’ (デフォルト) な
     ら、通常のファイルハンドルと同じ属性やメソッドにAPIが制限された
     *note MagicMock: e5a. が生成されます。

     'read_data' is a string for the *note read(): de9, *note
     readline(): 12f8, and *note readlines(): 228f. methods of the file
     handle to return.  Calls to those methods will take data from
     'read_data' until it is depleted.  The mock of these methods is
     pretty simplistic: every time the 'mock' is called, the 'read_data'
     is rewound to the start.  If you need more control over the data
     that you are feeding to the tested code you will need to customize
     this mock for yourself.  When that is insufficient, one of the
     in-memory filesystem packages on PyPI(1) can offer a realistic
     filesystem for testing.

     バージョン 3.4 で変更: Added *note readline(): 12f8. and *note
     readlines(): 228f. support.  The mock of *note read(): de9. changed
     to consume 'read_data' rather than returning it on each call.

     バージョン 3.5 で変更: 'read_data' は 'mock' を呼び出す度に毎回リセ
     ットされるようになりました。

     バージョン 3.8 で変更: Added *note __iter__(): 1c2b. to
     implementation so that iteration (such as in for loops) correctly
     consumes 'read_data'.

*note open(): 4e5. をコンテキストマネージャーとして使う方法は、ファイル
が必ず適切に閉じられるようにする素晴らしい方法で、今では一般的になってい
ます:

     with open('/some/path', 'w') as f:
         f.write('something')

The issue is that even if you mock out the call to *note open(): 4e5. it
is the 'returned object' that is used as a context manager (and has
*note __enter__(): 592. and *note __exit__(): 12ce. called).

コンテキストマネージャーを *note MagicMock: e5a. でモックするのは一般的
かつ面倒なので、ヘルパー関数を用意しています。:

     >>> m = mock_open()
     >>> with patch('__main__.open', m):
     ...     with open('foo', 'w') as h:
     ...         h.write('some stuff')
     ...
     >>> m.mock_calls
     [call('foo', 'w'),
      call().__enter__(),
      call().write('some stuff'),
      call().__exit__(None, None, None)]
     >>> m.assert_called_once_with('foo', 'w')
     >>> handle = m()
     >>> handle.write.assert_called_once_with('some stuff')

ファイルの読み込みをモックする例:

     >>> with patch('__main__.open', mock_open(read_data='bibble')) as m:
     ...     with open('foo') as h:
     ...         result = h.read()
     ...
     >>> m.assert_called_once_with('foo')
     >>> assert result == 'bibble'

   ---------- Footnotes ----------

   (1) https://pypi.org


File: python.info,  Node: autospec を使う,  Next: Sealing mocks,  Prev: mock_open,  Up: ヘルパー

5.26.6.29 autospec を使う
.........................

Autospeccing is based on the existing ‘spec’ feature of mock.  It limits
the api of mocks to the api of an original object (the spec), but it is
recursive (implemented lazily) so that attributes of mocks only have the
same api as the attributes of the spec.  In addition mocked functions /
methods have the same call signature as the original so they raise a
*note TypeError: 502. if they are called incorrectly.

autospec の動作について説明する前に、それが必要となる背景から説明してい
きます。

*note Mock: a1a. is a very powerful and flexible object, but it suffers
from a flaw which is general to mocking.  If you refactor some of your
code, rename members and so on, any tests for code that is still using
the 'old api' but uses mocks instead of the real objects will still
pass.  This means your tests can all pass even though your code is
broken.

バージョン 3.5 で変更: Before 3.5, tests with a typo in the word assert
would silently pass when they should raise an error.  You can still
achieve this behavior by passing ‘unsafe=True’ to Mock.

各ユニットが互いにどのように接続されるかをテストしない場合、依然としてテ
ストで見つけることができるバグの余地が多く残っています。

*note unittest.mock: f0. already provides a feature to help with this,
called speccing.  If you use a class or instance as the ‘spec’ for a
mock then you can only access attributes on the mock that exist on the
real class:

     >>> from urllib import request
     >>> mock = Mock(spec=request.Request)
     >>> mock.assret_called_with  # Intentional typo!
     Traceback (most recent call last):
      ...
     AttributeError: Mock object has no attribute 'assret_called_with'

spec はその mock 自体にしか適用されません。なので、同じ問題がその mock の
すべてのメソッドに対して発生します:

     >>> mock.has_data()
     <mock.Mock object at 0x...>
     >>> mock.has_data.assret_called_with()  # Intentional typo!

autospec はこの問題を解決します。 *note patch(): e5b. か *note
patch.object(): 14ff. に ‘autospec=True’ を渡すか、 *note
create_autospec(): 156b. 関数を使って spec をもとに mock を作ることがで
きます。 *note patch(): e5b. の引数に ‘autospec=True’ を渡した場合、置換
対象のオブジェクトが spec オブジェクトとして利用されます。 spec は遅延処
理される (mock の属性にアクセスされた時に spec が生成される) ので、非常
に複雑だったり深くネストしたオブジェクト (例えばモジュールをインポートす
るモジュールをインポートするモジュール) に対しても大きなパフォーマンスの
問題なしに autospec を使うことができます。

autospec の利用例:

     >>> from urllib import request
     >>> patcher = patch('__main__.request', autospec=True)
     >>> mock_request = patcher.start()
     >>> request is mock_request
     True
     >>> mock_request.Request
     <MagicMock name='request.Request' spec='Request' id='...'>

You can see that ‘request.Request’ has a spec.  ‘request.Request’ takes
two arguments in the constructor (one of which is 'self').  Here's what
happens if we try to call it incorrectly:

     >>> req = request.Request()
     Traceback (most recent call last):
      ...
     TypeError: <lambda>() takes at least 2 arguments (1 given)

spec はクラスがインスタンス化されたとき (つまり spec が適用された mock の
戻り値) にも適用されます:

     >>> req = request.Request('foo')
     >>> req
     <NonCallableMagicMock name='request.Request()' spec='Request' id='...'>

‘Request’ objects are not callable, so the return value of instantiating
our mocked out ‘request.Request’ is a non-callable mock.  With the spec
in place any typos in our asserts will raise the correct error:

     >>> req.add_header('spam', 'eggs')
     <MagicMock name='request.Request().add_header()' id='...'>
     >>> req.add_header.assret_called_with  # Intentional typo!
     Traceback (most recent call last):
      ...
     AttributeError: Mock object has no attribute 'assret_called_with'
     >>> req.add_header.assert_called_with('spam', 'eggs')

多くの場合、単に既存の *note patch(): e5b. 呼び出しに ‘autospec=True’ を
加えるだけで、ミススペルやAPI変更に伴うバグから守られます。

*note patch(): e5b. を経由する以外にも、 *note create_autospec(): 156b.
を使って 'autospec' が適用された mock を直接作る方法もあります:

     >>> from urllib import request
     >>> mock_request = create_autospec(request)
     >>> mock_request.Request('foo', 'bar')
     <NonCallableMagicMock name='mock.Request()' spec='Request' id='...'>

とはいえ、autospec には注意しなければならない点や制限があり、そのためデ
フォルトでは無効になっています。spec オブジェクトでどんな属性が使えるか
どうかを調べるために、autospec は spec オブジェクトをイントロスペクト (実
際に属性にアクセスする) 必要があります。mock の属性を利用するとき、水面
下で元のオブジェクトに対しても同じ属性の探索が行われます。spec したオブ
ジェクトのどれかがコードを実行するプロパティやデスクリプタを持っている場
合、autospec は正しく動きません。もしくは、イントロスペクションしても安
全なようにオブジェクトを設計するのがよいでしょう (1)。

A more serious problem is that it is common for instance attributes to
be created in the *note __init__(): 67c. method and not to exist on the
class at all.  'autospec' can't know about any dynamically created
attributes and restricts the api to visible attributes.

     >>> class Something:
     ...   def __init__(self):
     ...     self.a = 33
     ...
     >>> with patch('__main__.Something', autospec=True):
     ...   thing = Something()
     ...   thing.a
     ...
     Traceback (most recent call last):
       ...
     AttributeError: Mock object has no attribute 'a'

この問題を解決するためにいくつかの方法があります。一番簡単な、ただし一番
面倒でないとは限らない方法は、必要とされる属性を mock が生成された後に設
定することです。 'autospec' は属性を参照することを禁止しますが、設定する
ことは禁止していません:

     >>> with patch('__main__.Something', autospec=True):
     ...   thing = Something()
     ...   thing.a = 33
     ...

'spec' と 'autospec' にはよりアグレッシブなバージョンがあり、存在しない
属性への設定も禁止します。これはコードが正しい属性にのみ代入することを保
証したいときに便利ですが、もちろん先ほどの方法も制限されてしまいます:

     >>> with patch('__main__.Something', autospec=True, spec_set=True):
     ...   thing = Something()
     ...   thing.a = 33
     ...
     Traceback (most recent call last):
      ...
     AttributeError: Mock object has no attribute 'a'

Probably the best way of solving the problem is to add class attributes
as default values for instance members initialised in *note __init__():
67c.  Note that if you are only setting default attributes in
‘__init__()’ then providing them via class attributes (shared between
instances of course) is faster too.  e.g.

     class Something:
         a = 33

クラス属性を使ってもまた別の問題があります。メンバーのデフォルト値に
‘None’ を利用し、後から別の型のオブジェクトを代入するのは比較的よくある
パターンです。 spec として ‘None’ を使うと 'すべての' 属性やメソッドへの
アクセスも許されなくなるので使い物になりません。 ‘None’ を spec にするこ
とが有用な場面は '決して' なく、おそらくそのメンバーは他の何かの型のメン
バーになることを示すので、 autospec は ‘None’ に設定されているメンバーに
は spec を使いません。その属性は通常の mock (MagicMocks) になります。

     >>> class Something:
     ...     member = None
     ...
     >>> mock = create_autospec(Something)
     >>> mock.member.foo.bar.baz()
     <MagicMock name='mock.member.foo.bar.baz()' id='...'>

すでに利用されているクラスにデフォルト値属性を追加するのが嫌な場合は、他
の選択肢もあります。選択肢の1つは、クラスではなくインスタンスを spec に
使うことです。別の選択肢は、実際のクラスのサブクラスを作り、実際に利用さ
れている方に影響を与えずにデフォルト値属性を追加することです。どちらの方
法も spec として代替オブジェクトを利用することが必要です。 *note
patch(): e5b. はこれをサポートしていて、 'autospec' 引数に代替オブジェク
トを渡すことができます:

     >>> class Something:
     ...   def __init__(self):
     ...     self.a = 33
     ...
     >>> class SomethingForTest(Something):
     ...   a = 33
     ...
     >>> p = patch('__main__.Something', autospec=SomethingForTest)
     >>> mock = p.start()
     >>> mock.a
     <NonCallableMagicMock name='Something.a' spec='int' id='...'>

   ---------- Footnotes ----------

   (1) これはクラスやすでにインスタンス化されたオブジェクトにだけ当ては
まります。 mock されたクラスを呼び出して mock インスタンスを作っても、実
際のオブジェクトのインスタンスは生成されません。 mock は属性を - *note
dir(): 5fe. を呼び出して - 検索するだけです。


File: python.info,  Node: Sealing mocks,  Prev: autospec を使う,  Up: ヘルパー

5.26.6.30 Sealing mocks
.......................

 -- の関数: unittest.mock.seal (mock)

     Seal will disable the automatic creation of mocks when accessing an
     attribute of the mock being sealed or any of its attributes that
     are already mocks recursively.

     If a mock instance with a name or a spec is assigned to an
     attribute it won't be considered in the sealing chain.  This allows
     one to prevent seal from fixing part of the mock object.

          >>> mock = Mock()
          >>> mock.submock.attribute1 = 2
          >>> mock.not_submock = mock.Mock(name="sample_name")
          >>> seal(mock)
          >>> mock.new_attribute  # This will raise AttributeError.
          >>> mock.submock.attribute2  # This will raise AttributeError.
          >>> mock.not_submock.attribute2  # This won't raise.

     Added in version 3.7.


File: python.info,  Node: Order of precedence of side_effect return_value and wraps,  Prev: ヘルパー,  Up: unittest mock --- モックオブジェクトライブラリ

5.26.6.31 Order of precedence of ‘side_effect’, ‘return_value’ and 'wraps'
..........................................................................

The order of their precedence is:

  1. *note side_effect: 3f3c.

  2. *note return_value: 3f44.

  3. 'wraps'

If all three are set, mock will return the value from *note side_effect:
3f3c, ignoring *note return_value: 3f44. and the wrapped object
altogether.  If any two are set, the one with the higher precedence will
return the value.  Regardless of the order of which was set first, the
order of precedence remains unchanged.

     >>> from unittest.mock import Mock
     >>> class Order:
     ...     @staticmethod
     ...     def get_value():
     ...         return "third"
     ...
     >>> order_mock = Mock(spec=Order, wraps=Order)
     >>> order_mock.get_value.side_effect = ["first"]
     >>> order_mock.get_value.return_value = "second"
     >>> order_mock.get_value()
     'first'

As ‘None’ is the default value of *note side_effect: 3f3c, if you
reassign its value back to ‘None’, the order of precedence will be
checked between *note return_value: 3f44. and the wrapped object,
ignoring *note side_effect: 3f3c.

     >>> order_mock.get_value.side_effect = None
     >>> order_mock.get_value()
     'second'

If the value being returned by *note side_effect: 3f3c. is *note
DEFAULT: 3f43, it is ignored and the order of precedence moves to the
successor to obtain the value to return.

     >>> from unittest.mock import DEFAULT
     >>> order_mock.get_value.side_effect = [DEFAULT]
     >>> order_mock.get_value()
     'second'

When *note Mock: a1a. wraps an object, the default value of *note
return_value: 3f44. will be *note DEFAULT: 3f43.

     >>> order_mock = Mock(spec=Order, wraps=Order)
     >>> order_mock.return_value
     sentinel.DEFAULT
     >>> order_mock.get_value.return_value
     sentinel.DEFAULT

The order of precedence will ignore this value and it will move to the
last successor which is the wrapped object.

As the real call is being made to the wrapped object, creating an
instance of this mock will return the real instance of the class.  The
positional arguments, if any, required by the wrapped object must be
passed.

     >>> order_mock_instance = order_mock()
     >>> isinstance(order_mock_instance, Order)
     True
     >>> order_mock_instance.get_value()
     'third'

     >>> order_mock.get_value.return_value = DEFAULT
     >>> order_mock.get_value()
     'third'

     >>> order_mock.get_value.return_value = "second"
     >>> order_mock.get_value()
     'second'

But if you assign ‘None’ to it, this will not be ignored as it is an
explicit assignment.  So, the order of precedence will not move to the
wrapped object.

     >>> order_mock.get_value.return_value = None
     >>> order_mock.get_value() is None
     True

Even if you set all three at once when initializing the mock, the order
of precedence remains the same:

     >>> order_mock = Mock(spec=Order, wraps=Order,
     ...                   **{"get_value.side_effect": ["first"],
     ...                      "get_value.return_value": "second"}
     ...                   )
     ...
     >>> order_mock.get_value()
     'first'
     >>> order_mock.get_value.side_effect = None
     >>> order_mock.get_value()
     'second'
     >>> order_mock.get_value.return_value = DEFAULT
     >>> order_mock.get_value()
     'third'

If *note side_effect: 3f3c. is exhausted, the order of precedence will
not cause a value to be obtained from the successors.  Instead,
‘StopIteration’ exception is raised.

     >>> order_mock = Mock(spec=Order, wraps=Order)
     >>> order_mock.get_value.side_effect = ["first side effect value",
     ...                                     "another side effect value"]
     >>> order_mock.get_value.return_value = "second"

     >>> order_mock.get_value()
     'first side effect value'
     >>> order_mock.get_value()
     'another side effect value'

     >>> order_mock.get_value()
     Traceback (most recent call last):
      ...
     StopIteration


File: python.info,  Node: unittest mock --- 入門,  Next: test --- Regression tests package for Python,  Prev: unittest mock --- モックオブジェクトライブラリ,  Up: 開発ツール

5.26.7 ‘unittest.mock’ -- 入門
------------------------------

Added in version 3.3.

* Menu:

* Mock を使う::
* patch デコレータ::
* さらなる例::


File: python.info,  Node: Mock を使う,  Next: patch デコレータ,  Up: unittest mock --- 入門

5.26.7.1 Mock を使う
....................

* Menu:

* Mock のパッチ用メソッド::
* オブジェクトのメソッド呼び出しに対するモック::
* クラスをモックする::
* モックに名前をつける::
* 全ての呼び出しのトラッキング::
* 戻り値や属性を設定する::
* モックから例外を発生させる::
* side_effect の関数と iterable::
* 非同期イテレータをモックする::
* 非同期コンテキストマネージャをモックする::
* 既存のオブジェクトから Mock を作る::
* Using side_effect to return per file content::


File: python.info,  Node: Mock のパッチ用メソッド,  Next: オブジェクトのメソッド呼び出しに対するモック,  Up: Mock を使う

5.26.7.2 Mock のパッチ用メソッド
................................

一般的な *note Mock: a1a. の使い方の中には次のものがあります:

   * メソッドにパッチを当てる

   * オブジェクトに対するメソッド呼び出しを記録する

システムの他の部分からメソッドが正しい引数で呼び出されたかどうかを確認す
るために、そのオブジェクトのメソッドを置き換えることができます:

     >>> real = SomeClass()
     >>> real.method = MagicMock(name='method')
     >>> real.method(3, 4, 5, key='value')
     <MagicMock name='method()' id='...'>

モック(上の例では ‘real.method’)が利用された場合、どう使われたかを
assert できるようにする属性やメソッドがモックにあります。

     注釈: この例のような場合、たいてい *note Mock: a1a. と *note
     MagicMock: e5a. は互換です。 ‘MagicMock’ の方が強力なので、デフォル
     トではこちらを使うといいでしょう。

モックが呼び出されると、その *note called: 3f4e. 属性が ‘True’ に設定さ
れます。そして *note assert_called_with(): 198c. や *note
assert_called_once_with(): 3f46. メソッドを使ってそのメソッドが正しい引
数で呼び出されたかどうかをチェックできます。

次の例では ‘ProductionClass().method’ が ‘something’ メソッドを呼び出し
たことをテストしています:

     >>> class ProductionClass:
     ...     def method(self):
     ...         self.something(1, 2, 3)
     ...     def something(self, a, b, c):
     ...         pass
     ...
     >>> real = ProductionClass()
     >>> real.something = MagicMock()
     >>> real.method()
     >>> real.something.assert_called_once_with(1, 2, 3)


File: python.info,  Node: オブジェクトのメソッド呼び出しに対するモック,  Next: クラスをモックする,  Prev: Mock のパッチ用メソッド,  Up: Mock を使う

5.26.7.3 オブジェクトのメソッド呼び出しに対するモック
.....................................................

上の例ではオブジェクトのメソッドに対して直接パッチを当てて、それが正しく
呼び出されていたかどうかをテストしていました。もう一つのよくあるユースケ
ースが、モックをメソッド (またはテスト対象のシステムのどこか) に渡して、
それが正しく利用されたかどうかをチェックする方法です。

次の例で、‘ProductionClass’ は ‘closer’ メソッドを持っています。このメソ
ッドは渡されたオブジェクトの ‘close’ メソッドを呼び出します。

     >>> class ProductionClass:
     ...     def closer(self, something):
     ...         something.close()
     ...

ですからこれをテストするには、‘close’ メソッドを持ったオブジェクトを渡し
て、それが正しく呼び出されたかどうかをテストしなければなりません。

     >>> real = ProductionClass()
     >>> mock = Mock()
     >>> real.closer(mock)
     >>> mock.close.assert_called_with()

モックに ‘close’ メソッドを持たせるために何か準備する必要はありません。
‘close’ メソッドにアクセスすると自動的にそれが作られます。なので、もし
‘close’ が呼び出されなかったとしてもテスト時に生成されるのですが、 *note
assert_called_with(): 198c. が failure 例外を発生させます。


File: python.info,  Node: クラスをモックする,  Next: モックに名前をつける,  Prev: オブジェクトのメソッド呼び出しに対するモック,  Up: Mock を使う

5.26.7.4 クラスをモックする
...........................

他のよくあるユースケースが、テスト対象のコードによってインスタンス化され
ているクラスをモックに置き換えることです。クラスに patch すると、そのク
ラスがモックに置き換えられます。インスタンスは 'クラスを呼び出した時に'
作られます。なので、モックの戻り値を使うことで、「モックのインスタンス」
にアクセスできます。

次の例では、 ‘some_function’ という関数が ‘Foo’ をインスタンス化し、その
method を呼び出しています。 *note patch(): e5b. を呼び出すと ‘Foo’ クラ
スをモックに置き換えます。 ‘Foo’ のインスタンスはモックを呼び出して作ら
れるので、モックの *note return_value: 3f44. を変更することでカスタマイ
ズできます。:

     >>> def some_function():
     ...     instance = module.Foo()
     ...     return instance.method()
     ...
     >>> with patch('module.Foo') as mock:
     ...     instance = mock.return_value
     ...     instance.method.return_value = 'the result'
     ...     result = some_function()
     ...     assert result == 'the result'


File: python.info,  Node: モックに名前をつける,  Next: 全ての呼び出しのトラッキング,  Prev: クラスをモックする,  Up: Mock を使う

5.26.7.5 モックに名前をつける
.............................

モックに名前をつけると便利なことがあります。その名前はモックを repr した
ときに表示されるので、モックがテスト失敗のメッセージ内に現れた時に便利で
す。また、モックの名前はそのモックの属性やメソッドにも伝播します:

     >>> mock = MagicMock(name='foo')
     >>> mock
     <MagicMock name='foo' id='...'>
     >>> mock.method
     <MagicMock name='foo.method' id='...'>


File: python.info,  Node: 全ての呼び出しのトラッキング,  Next: 戻り値や属性を設定する,  Prev: モックに名前をつける,  Up: Mock を使う

5.26.7.6 全ての呼び出しのトラッキング
.....................................

メソッドの複数回の呼び出しをトラックしたいことがあります。 *note
mock_calls: 3f48. 属性は、そのモックの子属性やさらにその子孫に対する呼び
出しすべてを記録しています。

     >>> mock = MagicMock()
     >>> mock.method()
     <MagicMock name='mock.method()' id='...'>
     >>> mock.attribute.method(10, x=53)
     <MagicMock name='mock.attribute.method()' id='...'>
     >>> mock.mock_calls
     [call.method(), call.attribute.method(10, x=53)]

‘mock_calls’ に対して assert すると、予期していないメソッド呼び出しがあ
ったときにその assert が失敗します。これはあるメソッド呼び出しが期待通り
に実行されたかどうかだけでなく、その呼び出し順序や期待した以外の呼び出し
が起こらなかったことまでテストできるので便利です:

‘mock_calls’ と比較するリストを作るために *note call: 1939. オブジェクト
を利用できます:

     >>> expected = [call.method(), call.attribute.method(10, x=53)]
     >>> mock.mock_calls == expected
     True

However, parameters to calls that return mocks are not recorded, which
means it is not possible to track nested calls where the parameters used
to create ancestors are important:

     >>> m = Mock()
     >>> m.factory(important=True).deliver()
     <Mock name='mock.factory().deliver()' id='...'>
     >>> m.mock_calls[-1] == call.factory(important=False).deliver()
     True


File: python.info,  Node: 戻り値や属性を設定する,  Next: モックから例外を発生させる,  Prev: 全ての呼び出しのトラッキング,  Up: Mock を使う

5.26.7.7 戻り値や属性を設定する
...............................

モックオブジェクトに戻り値を設定するのはとっても簡単です:

     >>> mock = Mock()
     >>> mock.return_value = 3
     >>> mock()
     3

もちろん同じことがモックのメソッドに対しても行えます:

     >>> mock = Mock()
     >>> mock.method.return_value = 3
     >>> mock.method()
     3

コンストラクターで戻り値を設定することもできます:

     >>> mock = Mock(return_value=3)
     >>> mock()
     3

モックに属性を設定したかったら、普通に設定するだけです:

     >>> mock = Mock()
     >>> mock.x = 3
     >>> mock.x
     3

‘mock.connection.cursor().execute("SELECT 1")’ のような複雑なケースでモ
ックを使いたい場合もあります。この呼出があるリストを返すようにしたい場合
、このネストした呼び出しを構成しなければなりません。

*note call: 1939. を使って "chained call" 内の呼び出しを構成して、
assert で使うことができます:

     >>> mock = Mock()
     >>> cursor = mock.connection.cursor.return_value
     >>> cursor.execute.return_value = ['foo']
     >>> mock.connection.cursor().execute("SELECT 1")
     ['foo']
     >>> expected = call.connection.cursor().execute("SELECT 1").call_list()
     >>> mock.mock_calls
     [call.connection.cursor(), call.connection.cursor().execute('SELECT 1')]
     >>> mock.mock_calls == expected
     True

call object を chained call を表す list にするために ‘.call_list()’ を使
います。


File: python.info,  Node: モックから例外を発生させる,  Next: side_effect の関数と iterable,  Prev: 戻り値や属性を設定する,  Up: Mock を使う

5.26.7.8 モックから例外を発生させる
...................................

*note side_effect: 3f3c. という便利な属性があります。この属性に例外クラ
スやそのインスタンスを設定すると、モックが呼ばれた時にその例外を発生させ
ます。

     >>> mock = Mock(side_effect=Exception('Boom!'))
     >>> mock()
     Traceback (most recent call last):
       ...
     Exception: Boom!


File: python.info,  Node: side_effect の関数と iterable,  Next: 非同期イテレータをモックする,  Prev: モックから例外を発生させる,  Up: Mock を使う

5.26.7.9 side_effect の関数と iterable
......................................

‘side_effect’ には関数や iterable を設定することもできます。
‘side_effect’ に iterable を設定するユースケースは、そのモックが複数回呼
び出され、そのたびに違う値を返したい場合です。‘side_effect’ に iterable
を設定すると、そのモックに対するすべての呼び出しは iterable の次の値を返
します:

     >>> mock = MagicMock(side_effect=[4, 5, 6])
     >>> mock()
     4
     >>> mock()
     5
     >>> mock()
     6

より高度なユースケースとして、mock が呼び出された時の引数によって戻り値
を変化させたい場合は、‘side_effect’ に関数を設定することができます。その
関数は mock と同じ引数で呼び出されます。その関数の戻り値がそのモック呼び
出しの戻り値になります:

     >>> vals = {(1, 2): 1, (2, 3): 2}
     >>> def side_effect(*args):
     ...     return vals[args]
     ...
     >>> mock = MagicMock(side_effect=side_effect)
     >>> mock(1, 2)
     1
     >>> mock(2, 3)
     2


File: python.info,  Node: 非同期イテレータをモックする,  Next: 非同期コンテキストマネージャをモックする,  Prev: side_effect の関数と iterable,  Up: Mock を使う

5.26.7.10 非同期イテレータをモックする
......................................

Python 3.8以降、‘AsyncMock’ と ‘MagicMock’ は ‘__aiter__’ を通じて *note
非同期イテレータ (Asynchronous Iterator): d47. のモックをサポートしてい
ます。‘__aiter__’ の *note return_value: 3f44. 属性はイテレーションに使
用される戻り値を設定するために使用できます。

     >>> mock = MagicMock()  # AsyncMock also works here
     >>> mock.__aiter__.return_value = [1, 2, 3]
     >>> async def main():
     ...     return [i async for i in mock]
     ...
     >>> asyncio.run(main())
     [1, 2, 3]


File: python.info,  Node: 非同期コンテキストマネージャをモックする,  Next: 既存のオブジェクトから Mock を作る,  Prev: 非同期イテレータをモックする,  Up: Mock を使う

5.26.7.11 非同期コンテキストマネージャをモックする
..................................................

Python 3.8以降、‘AsyncMock’ と ‘MagicMock’ は ‘__aenter__’ と
‘__aexit__’ を通じて *note 非同期コンテキストマネージャ (Asynchronous
Context Manager): 5c6. のモックをサポートしています。デフォルトでは、
‘__aenter__’ と ‘__aexit__’ は非同期関数を返す ‘AsyncMock’ インスタンス
です。

     >>> class AsyncContextManager:
     ...     async def __aenter__(self):
     ...         return self
     ...     async def __aexit__(self, exc_type, exc, tb):
     ...         pass
     ...
     >>> mock_instance = MagicMock(AsyncContextManager())  # AsyncMock also works here
     >>> async def main():
     ...     async with mock_instance as result:
     ...         pass
     ...
     >>> asyncio.run(main())
     >>> mock_instance.__aenter__.assert_awaited_once()
     >>> mock_instance.__aexit__.assert_awaited_once()


File: python.info,  Node: 既存のオブジェクトから Mock を作る,  Next: Using side_effect to return per file content,  Prev: 非同期コンテキストマネージャをモックする,  Up: Mock を使う

5.26.7.12 既存のオブジェクトから Mock を作る
............................................

mock を使いすぎることの問題の一つは、テストが実際のコードではなく mock の
実装をテストするようになってしまうことです。‘some_method’ というメソッド
を実装したクラスがあるとします。他のクラスをテストするときに、
‘some_method’ を提供する mock を使います。最初のクラスをリファクタリング
して ‘some_method’ がなくなった時、コードは壊れているのにテストは通る状
態になってしまいます

*note Mock: a1a. は 'spec' というキーワード引数で mock の定義となるオブ
ジェクトを指定できます。定義オブジェクトに存在しないメソッドや属性にアク
セスすると AttributeError を発生させます。定義となるクラスの実装を変更し
た場合、テストの中でそのクラスをインスタンス化させなくても、テストを失敗
させる事ができます。

     >>> mock = Mock(spec=SomeClass)
     >>> mock.old_method()
     Traceback (most recent call last):
        ...
     AttributeError: Mock object has no attribute 'old_method'. Did you mean: 'class_method'?

また、定義を指定することで、パラメータが位置引数と名前付き引数のどちらで
渡されたかに関わらず、モックへの呼び出しをよりスマートに照合することがで
きます。

     >>> def f(a, b, c): pass
     ...
     >>> mock = Mock(spec=f)
     >>> mock(1, 2, 3)
     <Mock name='mock()' id='140161580456576'>
     >>> mock.assert_called_with(a=1, b=2, c=3)

このよりスマートなマッチングをモックのメソッド呼び出しにも適用したい場合
は、*note auto-speccing: 3f3f. を使用します。

任意の属性の参照だけでなく代入も禁止するより強い定義を利用したい場合は、
'spec' の代わりに 'spec_set' を使います。


File: python.info,  Node: Using side_effect to return per file content,  Prev: 既存のオブジェクトから Mock を作る,  Up: Mock を使う

5.26.7.13 Using side_effect to return per file content
......................................................

*note mock_open(): 166f. is used to patch *note open(): 4e5. method.
*note side_effect: 3f3c. can be used to return a new Mock object per
call.  This can be used to return different contents per file stored in
a dictionary:

     DEFAULT = "default"
     data_dict = {"file1": "data1",
                  "file2": "data2"}

     def open_side_effect(name):
         return mock_open(read_data=data_dict.get(name, DEFAULT))()

     with patch("builtins.open", side_effect=open_side_effect):
         with open("file1") as file1:
             assert file1.read() == "data1"

         with open("file2") as file2:
             assert file2.read() == "data2"

         with open("file3") as file2:
             assert file2.read() == "default"


File: python.info,  Node: patch デコレータ,  Next: さらなる例,  Prev: Mock を使う,  Up: unittest mock --- 入門

5.26.7.14 patch デコレータ
..........................

     注釈: *note patch(): e5b. では探索される名前空間内のオブジェクトに
     パッチをあてることが重要です。通常は単純ですが、クイックガイドには
     *note どこにパッチするか: 3f3d. を読んでください。

テストの中でクラス属性やモジュール属性、例えば組み込み関数や、テスト対象
モジュールにあるインスタンス化されるクラスに対してパッチしたいことがあり
ます。モジュールやクラスは実際はグローバルなので、パッチするときは必ずテ
スト後にパッチを解除しないと、そのパッチが永続化されて他のテストに影響を
与え、解析しにくい問題になります。

mock はこのために3つの便利なデコレータを提供しています: *note patch():
e5b, *note patch.object(): 14ff, *note patch.dict(): 195e. です。‘patch’
はパッチ対象を指定する ‘package.module.Class.attribute’ の形式の文字列を
引数に取ります。オプションでその属性 (やクラスなど) を置き換えるオブジェ
クトを渡すことができます。 'patch.object' はオブジェクトとパッチしたい属
性名、それにオプションで置き換えるオブジェクトを受け取ります。

‘patch.object’:

     >>> original = SomeClass.attribute
     >>> @patch.object(SomeClass, 'attribute', sentinel.attribute)
     ... def test():
     ...     assert SomeClass.attribute == sentinel.attribute
     ...
     >>> test()
     >>> assert SomeClass.attribute == original

     >>> @patch('package.module.attribute', sentinel.attribute)
     ... def test():
     ...     from package.module import attribute
     ...     assert attribute is sentinel.attribute
     ...
     >>> test()

モジュール (*note builtins: e. を含む) をパッチしようとする場合、 *note
patch.object(): 14ff. の代わりに *note patch(): e5b. を使用してください:

     >>> mock = MagicMock(return_value=sentinel.file_handle)
     >>> with patch('builtins.open', mock):
     ...     handle = open('filename', 'r')
     ...
     >>> mock.assert_called_with('filename', 'r')
     >>> assert handle == sentinel.file_handle, "incorrect file handle returned"

モジュール名は必要に応じて ‘package.module’ のようにドットを含むことがで
きます:

     >>> @patch('package.module.ClassName.attribute', sentinel.attribute)
     ... def test():
     ...     from package.module import ClassName
     ...     assert ClassName.attribute == sentinel.attribute
     ...
     >>> test()

テストメソッド自体をデコレートするのは良いパターンです:

     >>> class MyTest(unittest.TestCase):
     ...     @patch.object(SomeClass, 'attribute', sentinel.attribute)
     ...     def test_something(self):
     ...         self.assertEqual(SomeClass.attribute, sentinel.attribute)
     ...
     >>> original = SomeClass.attribute
     >>> MyTest('test_something').test_something()
     >>> assert SomeClass.attribute == original

Mock を使ってパッチしたい場合は、 *note patch(): e5b. を1引数で (または
*note patch.object(): 14ff. を2引数で) 使うことができます。mock が自動で
生成され、テスト関数/メソッドに渡されます:

     >>> class MyTest(unittest.TestCase):
     ...     @patch.object(SomeClass, 'static_method')
     ...     def test_something(self, mock_method):
     ...         SomeClass.static_method()
     ...         mock_method.assert_called_with()
     ...
     >>> MyTest('test_something').test_something()

次のパターンのように patch デコレータを重ねることができます:

     >>> class MyTest(unittest.TestCase):
     ...     @patch('package.module.ClassName1')
     ...     @patch('package.module.ClassName2')
     ...     def test_something(self, MockClass2, MockClass1):
     ...         self.assertIs(package.module.ClassName1, MockClass1)
     ...         self.assertIs(package.module.ClassName2, MockClass2)
     ...
     >>> MyTest('test_something').test_something()

patch デコレータをネストした際、モックは (デコレータを適用する 'Python'
の通常の) 順に適用されます。つまり引数は下から上の順になり、よって上記の
例では ‘test_module.ClassName2’ が先になります。

また、 *note patch.dict(): 195e. を使うと、スコープ内だけで辞書に値を設
定し、テスト終了時には元の状態に復元されます:

     >>> foo = {'key': 'value'}
     >>> original = foo.copy()
     >>> with patch.dict(foo, {'newkey': 'newvalue'}, clear=True):
     ...     assert foo == {'newkey': 'newvalue'}
     ...
     >>> assert foo == original

‘patch’, ‘patch.object’, ‘patch.dict’ は全てコンテキストマネージャーとし
ても利用できます。

*note patch(): e5b. に mock を生成させる場合、その参照を with 文の as を
使って受け取れます:

     >>> class ProductionClass:
     ...     def method(self):
     ...         pass
     ...
     >>> with patch.object(ProductionClass, 'method') as mock_method:
     ...     mock_method.return_value = None
     ...     real = ProductionClass()
     ...     real.method(1, 2, 3)
     ...
     >>> mock_method.assert_called_with(1, 2, 3)

他の方法として、‘patch’, ‘patch.object’, ‘patch.dict’ はクラスデコレータ
としても利用できます。その場合、"test" で始まる全てのメソッドにデコレー
タを適用するのと同じになります。


File: python.info,  Node: さらなる例,  Prev: patch デコレータ,  Up: unittest mock --- 入門

5.26.7.15 さらなる例
....................

より高度なシナリオを想定した例をあげていきます。

* Menu:

* chained call をモックする::
* 部分的なモック::
* ジェネレータメソッドをモックする::
* 同じパッチを全てのメソッドに適用する::
* Unboundメソッドをモックする::
* モックで複数回の呼び出しをチェックする::
* ミュータブルな引数に対処する::
* patch をネストする::
* MagicMock で辞書をモックする::
* Mock のサブクラスと属性::
* patch.dict で import をモックする: patch dict で import をモックする.
* Tracking order of calls and less verbose call assertions::
* More complex argument matching::


File: python.info,  Node: chained call をモックする,  Next: 部分的なモック,  Up: さらなる例

5.26.7.16 chained call をモックする
...................................

chained call を mock するのは、一度 *note return_value: 3f44. 属性を理解
してしまえば簡単です。mock が最初に呼ばれた時や、呼び出される前に
‘return_value’ を参照した場合、新しい *note Mock: a1a. が生成されます。

つまり、戻り値のオブジェクトがどう利用されたかは、‘return_value’ mock を
調べれば分かります:

     >>> mock = Mock()
     >>> mock().foo(a=2, b=3)
     <Mock name='mock().foo()' id='...'>
     >>> mock.return_value.foo.assert_called_with(a=2, b=3)

これをもとに、mock を構成して chained call に対する assert を行うのは簡
単です。もちろん、元のコードを最初からもっとテストしやすく書くという選択
肢もありますが...

では、例として次のようなコードがあるとします:

     >>> class Something:
     ...     def __init__(self):
     ...         self.backend = BackendProvider()
     ...     def method(self):
     ...         response = self.backend.get_endpoint('foobar').create_call('spam', 'eggs').start_call()
     ...         # more code

‘BackendProvider’ はすでに十分テストされているとします。‘method()’ をど
うテストしましょうか？特に、response オブジェクトを使う ‘# more code’ の
部分のコードをテストしたいとします。

この chained call はインスタンス属性を起点にしているので、 ‘Something’ イ
ンスタンスの ‘backend’ 属性に対してモンキーパッチすることができます。今
回の場合だと、最後の ‘start_call’ の呼び出しが返す値にだけ興味があるので
、あまり多くの構成は必要ありません。このメソッドが返すのが 'file-like' オ
ブジェクトだとしましょう。そうすると、 response オブジェクトは組み込みの
*note open(): 4e5. を ‘spec’ として利用できます。

これをするために、backend のモックとしてモックインスタンスを作成し、それ
に対するモックの response オブジェクトを作成します。最終的な
‘start_call’ の返り値として response をセットすると、このようにすること
ができます:

     mock_backend.get_endpoint.return_value.create_call.return_value.start_call.return_value = mock_response

これより少し良いやり方として、返り値を直接セットする *note
configure_mock(): 3f45. メソッドを使用して次のようにすることができます:

     >>> something = Something()
     >>> mock_response = Mock(spec=open)
     >>> mock_backend = Mock()
     >>> config = {'get_endpoint.return_value.create_call.return_value.start_call.return_value': mock_response}
     >>> mock_backend.configure_mock(**config)

これらによって「モックの backend」をその場で monkey patch して、実際の呼
び出しを行うことができます:

     >>> something.backend = mock_backend
     >>> something.method()

*note mock_calls: 3f48. を使用すると、チェーンされた呼び出しを単一のアサ
ーションでチェックすることができます。チェーンされた呼び出しは、1行のコ
ードの中で行われる複数の呼び出しです。したがって、 ‘mock_calls’ には複数
のエントリーがあるでしょう。 *note call.call_list(): 3f7f. を使用するこ
とで、この呼び出しのリストを作成することができます:

     >>> chained = call.get_endpoint('foobar').create_call('spam', 'eggs').start_call()
     >>> call_list = chained.call_list()
     >>> assert mock_backend.mock_calls == call_list


File: python.info,  Node: 部分的なモック,  Next: ジェネレータメソッドをモックする,  Prev: chained call をモックする,  Up: さらなる例

5.26.7.17 部分的なモック
........................

テストによっては、 *note datetime.date.today(): 1473. の呼び出しを既知の
date を返すようにモックしたいと思うことがありました。しかし、テスト対象
のコードが新しい date オブジェクトを生成するのを妨げたくはありません。不
運にも、 *note datetime.date: 1af. は C で書かれています。したがって、静
的な *note datetime.date.today(): 1473. メソッドを単にモンキーパッチする
ことはできませんでした。

私はこれを行う単純な方法を見つけました。それは、date クラスをモックで事
実上ラップして、しかしコンストラクタの呼び出しを実際のクラスへと素通りさ
せる (そして、実際のインスタンスを返す) というものです。

ここで、テスト対象のモジュール中の ‘date’ クラスをモックするために *note
patch decorator: e5b. が使用されています。そして、モックの date クラスの
*note side_effect: 3f3c. 属性は、本物の date を返すラムダ関数にセットさ
れます。モックの date クラスが呼ばれる時、 ‘side_effect’ によって本物の
date が構築されて返されます。:

     >>> from datetime import date
     >>> with patch('mymodule.date') as mock_date:
     ...     mock_date.today.return_value = date(2010, 10, 8)
     ...     mock_date.side_effect = lambda *args, **kw: date(*args, **kw)
     ...
     ...     assert mymodule.date.today() == date(2010, 10, 8)
     ...     assert mymodule.date(2009, 6, 8) == date(2009, 6, 8)

グローバルに *note datetime.date: 1af. にパッチするのではなく、それを使
用するモジュールの中の ‘date’ にパッチしていることに留意してください。
*note どこにパッチするか: 3f3d. を参照してください。

When ‘date.today()’ is called a known date is returned, but calls to the
‘date(...)’ constructor still return normal dates.  Without this you can
find yourself having to calculate an expected result using exactly the
same algorithm as the code under test, which is a classic testing
anti-pattern.

dateコンストラクタの呼び出しは、‘mock_date’ の属性(‘call_count’ とその仲
間)に記録され、テストに役立つこともあります。

日付や他の組み込みクラスのモックに対処する別の方法は このブログエントリ
(1).で議論されています。

   ---------- Footnotes ----------

   (1) 
https://williambert.online/2011/07/how-to-unit-testing-in-django-with-mocking-and-patching/


File: python.info,  Node: ジェネレータメソッドをモックする,  Next: 同じパッチを全てのメソッドに適用する,  Prev: 部分的なモック,  Up: さらなる例

5.26.7.18 ジェネレータメソッドをモックする
..........................................

Pythonのジェネレータは、反復処理された時に一連の値を返す *note yield:
99b. 文を使用した関数やメソッドです (1)。

ジェネレータメソッド/関数はジェネレータオブジェクトを返すために呼び出さ
れます。そしてこのジェネレータオブジェクトが反復処理されます。イテレーシ
ョンのためのプロトコルメソッドは *note __iter__(): 1c2b. なので、*note
MagicMock: e5a. を使ってこれをモックすることができます。

ここでは"iter"メソッドをジェネレータとして実装したクラスの例を紹介します
:

     >>> class Foo:
     ...     def iter(self):
     ...         for i in [1, 2, 3]:
     ...             yield i
     ...
     >>> foo = Foo()
     >>> list(foo.iter())
     [1, 2, 3]

このクラス、特に "iter"メソッドをどのようにモックするのでしょうか。

(*note list: 5dc. の呼び出しの中での暗黙的な)イテレーションから返される
値を設定するには、‘foo.iter()’ の呼び出しで返されるオブジェクトを設定す
る必要がある。

     >>> mock_foo = MagicMock()
     >>> mock_foo.iter.return_value = iter([1, 2, 3])
     >>> list(mock_foo.iter())
     [1, 2, 3]

   ---------- Footnotes ----------

   (1) ジェネレータ式やジェネレータのより'高度な使い方
<‘http://www.dabeaz.com/coroutines/index.html’>'_ もありますが、ここでは
それらについては触れません。ジェネレータとその強力さについての非常に良い
紹介記事があります: Generator Tricks for Systems Programmers
(http://www.dabeaz.com/generators/)。


File: python.info,  Node: 同じパッチを全てのメソッドに適用する,  Next: Unboundメソッドをモックする,  Prev: ジェネレータメソッドをモックする,  Up: さらなる例

5.26.7.19 同じパッチを全てのメソッドに適用する
..............................................

複数のテストメソッドに複数のパッチを適用したい場合、当然のことながらすべ
てのメソッドにパッチデコレータを適用することになります。これは不要な繰り
返しのように感じられます。代わりに、(あらゆる形態の) *note patch(): e5b.
をクラスデコレータとして使用することができます。これはそのクラスのすべて
のテストメソッドにパッチを適用します。テストメソッドは名前が ‘test’ で始
まるメソッドで識別されます。

     >>> @patch('mymodule.SomeClass')
     ... class MyTest(unittest.TestCase):
     ...
     ...     def test_one(self, MockSomeClass):
     ...         self.assertIs(mymodule.SomeClass, MockSomeClass)
     ...
     ...     def test_two(self, MockSomeClass):
     ...         self.assertIs(mymodule.SomeClass, MockSomeClass)
     ...
     ...     def not_a_test(self):
     ...         return 'something'
     ...
     >>> MyTest('test_one').test_one()
     >>> MyTest('test_two').test_two()
     >>> MyTest('test_two').not_a_test()
     'something'

パッチを管理する別の方法として、*note patch のメソッド; start と stop:
3f70.を使用する方法があります。これらを使うと、パッチを ‘setUp’ と
''tearDown''メソッドに移すことができます。

     >>> class MyTest(unittest.TestCase):
     ...     def setUp(self):
     ...         self.patcher = patch('mymodule.foo')
     ...         self.mock_foo = self.patcher.start()
     ...
     ...     def test_foo(self):
     ...         self.assertIs(mymodule.foo, self.mock_foo)
     ...
     ...     def tearDown(self):
     ...         self.patcher.stop()
     ...
     >>> MyTest('test_foo').run()

この方式を使う場合、必ず ‘stop’ メソッドを呼び出してパッチが解除する必要
があります。setUp の中で例外が発生した場合 tearDown が呼び出されないので
、これは意外に面倒です。 *note unittest.TestCase.addCleanup(): a4f. を使
うと簡単にできます:

     >>> class MyTest(unittest.TestCase):
     ...     def setUp(self):
     ...         patcher = patch('mymodule.foo')
     ...         self.addCleanup(patcher.stop)
     ...         self.mock_foo = patcher.start()
     ...
     ...     def test_foo(self):
     ...         self.assertIs(mymodule.foo, self.mock_foo)
     ...
     >>> MyTest('test_foo').run()


File: python.info,  Node: Unboundメソッドをモックする,  Next: モックで複数回の呼び出しをチェックする,  Prev: 同じパッチを全てのメソッドに適用する,  Up: さらなる例

5.26.7.20 Unboundメソッドをモックする
.....................................

Whilst writing tests today I needed to patch an 'unbound method'
(patching the method on the class rather than on the instance).  I
needed self to be passed in as the first argument because I want to make
asserts about which objects were calling this particular method.  The
issue is that you can't patch with a mock for this, because if you
replace an unbound method with a mock it doesn't become a bound method
when fetched from the instance, and so it doesn't get self passed in.
The workaround is to patch the unbound method with a real function
instead.  The *note patch(): e5b. decorator makes it so simple to patch
out methods with a mock that having to create a real function becomes a
nuisance.

If you pass ‘autospec=True’ to patch then it does the patching with a
'real' function object.  This function object has the same signature as
the one it is replacing, but delegates to a mock under the hood.  You
still get your mock auto-created in exactly the same way as before.
What it means though, is that if you use it to patch out an unbound
method on a class the mocked function will be turned into a bound method
if it is fetched from an instance.  It will have ‘self’ passed in as the
first argument, which is exactly what I wanted:

     >>> class Foo:
     ...   def foo(self):
     ...     pass
     ...
     >>> with patch.object(Foo, 'foo', autospec=True) as mock_foo:
     ...   mock_foo.return_value = 'foo'
     ...   foo = Foo()
     ...   foo.foo()
     ...
     'foo'
     >>> mock_foo.assert_called_once_with(foo)

‘autospec=True’ を使用しない場合、束縛されていないメソッドは代わりに
Mockインスタンスでパッチされ、‘self’ で呼び出されることはありません。


File: python.info,  Node: モックで複数回の呼び出しをチェックする,  Next: ミュータブルな引数に対処する,  Prev: Unboundメソッドをモックする,  Up: さらなる例

5.26.7.21 モックで複数回の呼び出しをチェックする
................................................

モックには、モックオブジェクトがどのように使用されるかをアサートするため
の素晴らしいAPIがあります。

     >>> mock = Mock()
     >>> mock.foo_bar.return_value = None
     >>> mock.foo_bar('baz', spam='eggs')
     >>> mock.foo_bar.assert_called_with('baz', spam='eggs')

If your mock is only being called once you can use the *note
assert_called_once_with(): 3f46. method that also asserts that the *note
call_count: 3f4f. is one.

     >>> mock.foo_bar.assert_called_once_with('baz', spam='eggs')
     >>> mock.foo_bar()
     >>> mock.foo_bar.assert_called_once_with('baz', spam='eggs')
     Traceback (most recent call last):
         ...
     AssertionError: Expected 'foo_bar' to be called once. Called 2 times.
     Calls: [call('baz', spam='eggs'), call()].

Both ‘assert_called_with’ and ‘assert_called_once_with’ make assertions
about the 'most recent' call.  If your mock is going to be called
several times, and you want to make assertions about 'all' those calls
you can use *note call_args_list: 3f50.:

     >>> mock = Mock(return_value=None)
     >>> mock(1, 2, 3)
     >>> mock(4, 5, 6)
     >>> mock()
     >>> mock.call_args_list
     [call(1, 2, 3), call(4, 5, 6), call()]

*note call: 1939. ヘルパーを使えば、これらの呼び出しについて簡単にアサー
トすることができます。予想される呼び出しのリストを作成し、それを
''call_args_list''と比較することができます。これは''call_args_list''の
reprと驚くほど似ています:

     >>> expected = [call(1, 2, 3), call(4, 5, 6), call()]
     >>> mock.call_args_list == expected
     True


File: python.info,  Node: ミュータブルな引数に対処する,  Next: patch をネストする,  Prev: モックで複数回の呼び出しをチェックする,  Up: さらなる例

5.26.7.22 ミュータブルな引数に対処する
......................................

稀ではありますが、問題となることがあるのはミュータブルな引数でモックが呼
び出された場合です。‘call_args’ や''call_args_list'' は引数への*参照*を
保存します。もしテスト対象のコードによって引数が変更されてしまうと、モッ
クが呼び出された時の値をアサートすることはできなくなります。

この問題を示すサンプルコードを示します。

     def frob(val):
         pass

     def grob(val):
         "First frob and then clear val"
         frob(val)
         val.clear()

‘grob’ が''frob''を正しい引数で呼び出していることをテストしようとすると
何が起こるか見てみましょう:

     >>> with patch('mymodule.frob') as mock_frob:
     ...     val = {6}
     ...     mymodule.grob(val)
     ...
     >>> val
     set()
     >>> mock_frob.assert_called_with({6})
     Traceback (most recent call last):
         ...
     AssertionError: Expected: (({6},), {})
     Called with: ((set(),), {})

一つの選択肢は、あなたが渡す引数をモックがコピーすることです。この方法は
、オブジェクトidの同一性に依存したアサーションを行う場合に問題を引き起こ
す可能性があります。

Here's one solution that uses the *note side_effect: 3f3c.
functionality.  If you provide a ‘side_effect’ function for a mock then
‘side_effect’ will be called with the same args as the mock.  This gives
us an opportunity to copy the arguments and store them for later
assertions.  In this example I'm using 'another' mock to store the
arguments so that I can use the mock methods for doing the assertion.
Again a helper function sets this up for me.

     >>> from copy import deepcopy
     >>> from unittest.mock import Mock, patch, DEFAULT
     >>> def copy_call_args(mock):
     ...     new_mock = Mock()
     ...     def side_effect(*args, **kwargs):
     ...         args = deepcopy(args)
     ...         kwargs = deepcopy(kwargs)
     ...         new_mock(*args, **kwargs)
     ...         return DEFAULT
     ...     mock.side_effect = side_effect
     ...     return new_mock
     ...
     >>> with patch('mymodule.frob') as mock_frob:
     ...     new_mock = copy_call_args(mock_frob)
     ...     val = {6}
     ...     mymodule.grob(val)
     ...
     >>> new_mock.assert_called_with({6})
     >>> new_mock.call_args
     call({6})

‘copy_call_args’ は、テストで呼び出されるモックとともに呼び出されます。
この関数はアサーションで使用するための新しいモックを返します。
‘side_effect’ 関数は引数のコピーを作成し、そのコピーを使って ‘new_mock’
を呼び出します。

     注釈: もしモックが一度しか使われないのであれば、呼び出された時点で
     引数をチェックする簡単な方法があります。単純に''side_effect''関数の
     中でチェックを行えばいいのです。

          >>> def side_effect(arg):
          ...     assert arg == {6}
          ...
          >>> mock = Mock(side_effect=side_effect)
          >>> mock({6})
          >>> mock(set())
          Traceback (most recent call last):
              ...
          AssertionError

別の方法としては、（ *note copy.deepcopy(): b3c. を使用して）引数をコピ
ーする、 *note Mock: a1a. や *note MagicMock: e5a. のサブクラスを作成す
る方法があります。以下に実装例を示します。

     >>> from copy import deepcopy
     >>> class CopyingMock(MagicMock):
     ...     def __call__(self, /, *args, **kwargs):
     ...         args = deepcopy(args)
     ...         kwargs = deepcopy(kwargs)
     ...         return super().__call__(*args, **kwargs)
     ...
     >>> c = CopyingMock(return_value=None)
     >>> arg = set()
     >>> c(arg)
     >>> arg.add(1)
     >>> c.assert_called_with(set())
     >>> c.assert_called_with(arg)
     Traceback (most recent call last):
         ...
     AssertionError: expected call not found.
     Expected: mock({1})
     Actual: mock(set())
     >>> c.foo
     <CopyingMock name='mock.foo' id='...'>

When you subclass ‘Mock’ or ‘MagicMock’ all dynamically created
attributes, and the ‘return_value’ will use your subclass automatically.
That means all children of a ‘CopyingMock’ will also have the type
‘CopyingMock’.


File: python.info,  Node: patch をネストする,  Next: MagicMock で辞書をモックする,  Prev: ミュータブルな引数に対処する,  Up: さらなる例

5.26.7.23 patch をネストする
............................

Using patch as a context manager is nice, but if you do multiple patches
you can end up with nested with statements indenting further and further
to the right:

     >>> class MyTest(unittest.TestCase):
     ...
     ...     def test_foo(self):
     ...         with patch('mymodule.Foo') as mock_foo:
     ...             with patch('mymodule.Bar') as mock_bar:
     ...                 with patch('mymodule.Spam') as mock_spam:
     ...                     assert mymodule.Foo is mock_foo
     ...                     assert mymodule.Bar is mock_bar
     ...                     assert mymodule.Spam is mock_spam
     ...
     >>> original = mymodule.Foo
     >>> MyTest('test_foo').test_foo()
     >>> assert mymodule.Foo is original

With unittest ‘cleanup’ functions and the *note patch のメソッド; start
と stop: 3f70. we can achieve the same effect without the nested
indentation.  A simple helper method, ‘create_patch’, puts the patch in
place and returns the created mock for us:

     >>> class MyTest(unittest.TestCase):
     ...
     ...     def create_patch(self, name):
     ...         patcher = patch(name)
     ...         thing = patcher.start()
     ...         self.addCleanup(patcher.stop)
     ...         return thing
     ...
     ...     def test_foo(self):
     ...         mock_foo = self.create_patch('mymodule.Foo')
     ...         mock_bar = self.create_patch('mymodule.Bar')
     ...         mock_spam = self.create_patch('mymodule.Spam')
     ...
     ...         assert mymodule.Foo is mock_foo
     ...         assert mymodule.Bar is mock_bar
     ...         assert mymodule.Spam is mock_spam
     ...
     >>> original = mymodule.Foo
     >>> MyTest('test_foo').run()
     >>> assert mymodule.Foo is original


File: python.info,  Node: MagicMock で辞書をモックする,  Next: Mock のサブクラスと属性,  Prev: patch をネストする,  Up: さらなる例

5.26.7.24 MagicMock で辞書をモックする
......................................

You may want to mock a dictionary, or other container object, recording
all access to it whilst having it still behave like a dictionary.

We can do this with *note MagicMock: e5a, which will behave like a
dictionary, and using *note side_effect: 3f3c. to delegate dictionary
access to a real underlying dictionary that is under our control.

When the *note __getitem__(): 264. and *note __setitem__(): 146e.
methods of our ‘MagicMock’ are called (normal dictionary access) then
‘side_effect’ is called with the key (and in the case of ‘__setitem__’
the value too).  We can also control what is returned.

After the ‘MagicMock’ has been used we can use attributes like *note
call_args_list: 3f50. to assert about how the dictionary was used:

     >>> my_dict = {'a': 1, 'b': 2, 'c': 3}
     >>> def getitem(name):
     ...      return my_dict[name]
     ...
     >>> def setitem(name, val):
     ...     my_dict[name] = val
     ...
     >>> mock = MagicMock()
     >>> mock.__getitem__.side_effect = getitem
     >>> mock.__setitem__.side_effect = setitem

     注釈: An alternative to using ‘MagicMock’ is to use ‘Mock’ and
     'only' provide the magic methods you specifically want:

          >>> mock = Mock()
          >>> mock.__getitem__ = Mock(side_effect=getitem)
          >>> mock.__setitem__ = Mock(side_effect=setitem)

     A 'third' option is to use ‘MagicMock’ but passing in ‘dict’ as the
     'spec' (or 'spec_set') argument so that the ‘MagicMock’ created
     only has dictionary magic methods available:

          >>> mock = MagicMock(spec_set=dict)
          >>> mock.__getitem__.side_effect = getitem
          >>> mock.__setitem__.side_effect = setitem

With these side effect functions in place, the ‘mock’ will behave like a
normal dictionary but recording the access.  It even raises a *note
KeyError: 31d. if you try to access a key that doesn't exist.

     >>> mock['a']
     1
     >>> mock['c']
     3
     >>> mock['d']
     Traceback (most recent call last):
         ...
     KeyError: 'd'
     >>> mock['b'] = 'fish'
     >>> mock['d'] = 'eggs'
     >>> mock['b']
     'fish'
     >>> mock['d']
     'eggs'

After it has been used you can make assertions about the access using
the normal mock methods and attributes:

     >>> mock.__getitem__.call_args_list
     [call('a'), call('c'), call('d'), call('b'), call('d')]
     >>> mock.__setitem__.call_args_list
     [call('b', 'fish'), call('d', 'eggs')]
     >>> my_dict
     {'a': 1, 'b': 'fish', 'c': 3, 'd': 'eggs'}


File: python.info,  Node: Mock のサブクラスと属性,  Next: patch dict で import をモックする,  Prev: MagicMock で辞書をモックする,  Up: さらなる例

5.26.7.25 Mock のサブクラスと属性
.................................

There are various reasons why you might want to subclass *note Mock:
a1a.  One reason might be to add helper methods.  Here's a silly
example:

     >>> class MyMock(MagicMock):
     ...     def has_been_called(self):
     ...         return self.called
     ...
     >>> mymock = MyMock(return_value=None)
     >>> mymock
     <MyMock id='...'>
     >>> mymock.has_been_called()
     False
     >>> mymock()
     >>> mymock.has_been_called()
     True

The standard behaviour for ‘Mock’ instances is that attributes and the
return value mocks are of the same type as the mock they are accessed
on.  This ensures that ‘Mock’ attributes are ‘Mocks’ and ‘MagicMock’
attributes are ‘MagicMocks’ (1).  So if you're subclassing to add helper
methods then they'll also be available on the attributes and return
value mock of instances of your subclass.

     >>> mymock.foo
     <MyMock name='mock.foo' id='...'>
     >>> mymock.foo.has_been_called()
     False
     >>> mymock.foo()
     <MyMock name='mock.foo()' id='...'>
     >>> mymock.foo.has_been_called()
     True

Sometimes this is inconvenient.  For example, one user(2) is subclassing
mock to created a Twisted adaptor(3).  Having this applied to attributes
too actually causes errors.

‘Mock’ (in all its flavours) uses a method called ‘_get_child_mock’ to
create these "sub-mocks" for attributes and return values.  You can
prevent your subclass being used for attributes by overriding this
method.  The signature is that it takes arbitrary keyword arguments
(‘**kwargs’) which are then passed onto the mock constructor:

     >>> class Subclass(MagicMock):
     ...     def _get_child_mock(self, /, **kwargs):
     ...         return MagicMock(**kwargs)
     ...
     >>> mymock = Subclass()
     >>> mymock.foo
     <MagicMock name='mock.foo' id='...'>
     >>> assert isinstance(mymock, Subclass)
     >>> assert not isinstance(mymock.foo, Subclass)
     >>> assert not isinstance(mymock(), Subclass)

   ---------- Footnotes ----------

   (1) An exception to this rule are the non-callable mocks.  Attributes
use the callable variant because otherwise non-callable mocks couldn't
have callable methods.

   (2) https://code.google.com/archive/p/mock/issues/105

   (3) 
https://twisted.org/documents/11.0.0/api/twisted.python.components.html


File: python.info,  Node: patch dict で import をモックする,  Next: Tracking order of calls and less verbose call assertions,  Prev: Mock のサブクラスと属性,  Up: さらなる例

5.26.7.26 patch.dict で import をモックする
...........................................

One situation where mocking can be hard is where you have a local import
inside a function.  These are harder to mock because they aren't using
an object from the module namespace that we can patch out.

Generally local imports are to be avoided.  They are sometimes done to
prevent circular dependencies, for which there is 'usually' a much
better way to solve the problem (refactor the code) or to prevent "up
front costs" by delaying the import.  This can also be solved in better
ways than an unconditional local import (store the module as a class or
module attribute and only do the import on first use).

That aside there is a way to use ‘mock’ to affect the results of an
import.  Importing fetches an 'object' from the *note sys.modules: 18d6.
dictionary.  Note that it fetches an 'object', which need not be a
module.  Importing a module for the first time results in a module
object being put in ‘sys.modules’, so usually when you import something
you get a module back.  This need not be the case however.

This means you can use *note patch.dict(): 195e. to 'temporarily' put a
mock in place in *note sys.modules: 18d6.  Any imports whilst this patch
is active will fetch the mock.  When the patch is complete (the
decorated function exits, the with statement body is complete or
‘patcher.stop()’ is called) then whatever was there previously will be
restored safely.

Here's an example that mocks out the 'fooble' module.

     >>> import sys
     >>> mock = Mock()
     >>> with patch.dict('sys.modules', {'fooble': mock}):
     ...    import fooble
     ...    fooble.blob()
     ...
     <Mock name='mock.blob()' id='...'>
     >>> assert 'fooble' not in sys.modules
     >>> mock.blob.assert_called_once_with()

As you can see the ‘import fooble’ succeeds, but on exit there is no
'fooble' left in *note sys.modules: 18d6.

This also works for the ‘from module import name’ form:

     >>> mock = Mock()
     >>> with patch.dict('sys.modules', {'fooble': mock}):
     ...    from fooble import blob
     ...    blob.blip()
     ...
     <Mock name='mock.blob.blip()' id='...'>
     >>> mock.blob.blip.assert_called_once_with()

With slightly more work you can also mock package imports:

     >>> mock = Mock()
     >>> modules = {'package': mock, 'package.module': mock.module}
     >>> with patch.dict('sys.modules', modules):
     ...    from package.module import fooble
     ...    fooble()
     ...
     <Mock name='mock.module.fooble()' id='...'>
     >>> mock.module.fooble.assert_called_once_with()


File: python.info,  Node: Tracking order of calls and less verbose call assertions,  Next: More complex argument matching,  Prev: patch dict で import をモックする,  Up: さらなる例

5.26.7.27 Tracking order of calls and less verbose call assertions
..................................................................

The *note Mock: a1a. class allows you to track the 'order' of method
calls on your mock objects through the *note method_calls: 3f4a.
attribute.  This doesn't allow you to track the order of calls between
separate mock objects, however we can use *note mock_calls: 3f48. to
achieve the same effect.

Because mocks track calls to child mocks in ‘mock_calls’, and accessing
an arbitrary attribute of a mock creates a child mock, we can create our
separate mocks from a parent one.  Calls to those child mock will then
all be recorded, in order, in the ‘mock_calls’ of the parent:

     >>> manager = Mock()
     >>> mock_foo = manager.foo
     >>> mock_bar = manager.bar

     >>> mock_foo.something()
     <Mock name='mock.foo.something()' id='...'>
     >>> mock_bar.other.thing()
     <Mock name='mock.bar.other.thing()' id='...'>

     >>> manager.mock_calls
     [call.foo.something(), call.bar.other.thing()]

We can then assert about the calls, including the order, by comparing
with the ‘mock_calls’ attribute on the manager mock:

     >>> expected_calls = [call.foo.something(), call.bar.other.thing()]
     >>> manager.mock_calls == expected_calls
     True

If ‘patch’ is creating, and putting in place, your mocks then you can
attach them to a manager mock using the *note attach_mock(): 1572.
method.  After attaching calls will be recorded in ‘mock_calls’ of the
manager.

     >>> manager = MagicMock()
     >>> with patch('mymodule.Class1') as MockClass1:
     ...     with patch('mymodule.Class2') as MockClass2:
     ...         manager.attach_mock(MockClass1, 'MockClass1')
     ...         manager.attach_mock(MockClass2, 'MockClass2')
     ...         MockClass1().foo()
     ...         MockClass2().bar()
     <MagicMock name='mock.MockClass1().foo()' id='...'>
     <MagicMock name='mock.MockClass2().bar()' id='...'>
     >>> manager.mock_calls
     [call.MockClass1(),
     call.MockClass1().foo(),
     call.MockClass2(),
     call.MockClass2().bar()]

If many calls have been made, but you're only interested in a particular
sequence of them then an alternative is to use the *note
assert_has_calls(): 160c. method.  This takes a list of calls
(constructed with the *note call: 1939. object).  If that sequence of
calls are in *note mock_calls: 3f48. then the assert succeeds.

     >>> m = MagicMock()
     >>> m().foo().bar().baz()
     <MagicMock name='mock().foo().bar().baz()' id='...'>
     >>> m.one().two().three()
     <MagicMock name='mock.one().two().three()' id='...'>
     >>> calls = call.one().two().three().call_list()
     >>> m.assert_has_calls(calls)

Even though the chained call ‘m.one().two().three()’ aren't the only
calls that have been made to the mock, the assert still succeeds.

Sometimes a mock may have several calls made to it, and you are only
interested in asserting about 'some' of those calls.  You may not even
care about the order.  In this case you can pass ‘any_order=True’ to
‘assert_has_calls’:

     >>> m = MagicMock()
     >>> m(1), m.two(2, 3), m.seven(7), m.fifty('50')
     (...)
     >>> calls = [call.fifty('50'), call(1), call.seven(7)]
     >>> m.assert_has_calls(calls, any_order=True)


File: python.info,  Node: More complex argument matching,  Prev: Tracking order of calls and less verbose call assertions,  Up: さらなる例

5.26.7.28 More complex argument matching
........................................

Using the same basic concept as *note ANY: 1937. we can implement
matchers to do more complex assertions on objects used as arguments to
mocks.

Suppose we expect some object to be passed to a mock that by default
compares equal based on object identity (which is the Python default for
user defined classes).  To use *note assert_called_with(): 198c. we
would need to pass in the exact same object.  If we are only interested
in some of the attributes of this object then we can create a matcher
that will check these attributes for us.

You can see in this example how a 'standard' call to
‘assert_called_with’ isn't sufficient:

     >>> class Foo:
     ...     def __init__(self, a, b):
     ...         self.a, self.b = a, b
     ...
     >>> mock = Mock(return_value=None)
     >>> mock(Foo(1, 2))
     >>> mock.assert_called_with(Foo(1, 2))
     Traceback (most recent call last):
         ...
     AssertionError: expected call not found.
     Expected: mock(<__main__.Foo object at 0x...>)
     Actual: mock(<__main__.Foo object at 0x...>)

A comparison function for our ‘Foo’ class might look something like
this:

     >>> def compare(self, other):
     ...     if not type(self) == type(other):
     ...         return False
     ...     if self.a != other.a:
     ...         return False
     ...     if self.b != other.b:
     ...         return False
     ...     return True
     ...

And a matcher object that can use comparison functions like this for its
equality operation would look something like this:

     >>> class Matcher:
     ...     def __init__(self, compare, some_obj):
     ...         self.compare = compare
     ...         self.some_obj = some_obj
     ...     def __eq__(self, other):
     ...         return self.compare(self.some_obj, other)
     ...

全てをつなぎ合わせて:

     >>> match_foo = Matcher(compare, Foo(1, 2))
     >>> mock.assert_called_with(match_foo)

The ‘Matcher’ is instantiated with our compare function and the ‘Foo’
object we want to compare against.  In ‘assert_called_with’ the
‘Matcher’ equality method will be called, which compares the object the
mock was called with against the one we created our matcher with.  If
they match then ‘assert_called_with’ passes, and if they don't an *note
AssertionError: 675. is raised:

     >>> match_wrong = Matcher(compare, Foo(3, 4))
     >>> mock.assert_called_with(match_wrong)
     Traceback (most recent call last):
         ...
     AssertionError: Expected: ((<Matcher object at 0x...>,), {})
     Called with: ((<Foo object at 0x...>,), {})

With a bit of tweaking you could have the comparison function raise the
*note AssertionError: 675. directly and provide a more useful failure
message.

As of version 1.5, the Python testing library PyHamcrest(1) provides
similar functionality, that may be useful here, in the form of its
equality matcher (hamcrest.library.integration.match_equality(2)).

   ---------- Footnotes ----------

   (1) https://pyhamcrest.readthedocs.io/

   (2) 
https://pyhamcrest.readthedocs.io/en/release-1.8/integration/#module-hamcrest.library.integration.match_equality


File: python.info,  Node: test --- Regression tests package for Python,  Next: test support --- テストのためのユーティリティ関数,  Prev: unittest mock --- 入門,  Up: 開発ツール

5.26.8 ‘test’ -- Regression tests package for Python
----------------------------------------------------

     注釈: *note test: cb. パッケージは Python の内部利用専用です。 ドキ
     ュメント化されているのは Python のコア開発者のためです。 ここで述べ
     られているコードは Python のリリースで予告なく変更されたり、削除さ
     れる可能性があるため、Python 標準ライブラリー外でこのパッケージを使
     用することは推奨されません。

__________________________________________________________________

*note test: cb. パッケージには、Python 用の全ての回帰テストの他に、
*note test.support: cd. モジュールと *note test.regrtest: cc. モジュール
が入っています。 *note test.support: cd. はテストを充実させるために使い
、 *note test.regrtest: cc. はテストスイートを実行するのに使います。

*note test: cb. パッケージ内のモジュールのうち、名前が ‘test_’ で始まる
ものは、特定のモジュールや機能に対するテストスイートです。新しいテストは
すべて *note unittest: ef. か *note doctest: 31. モジュールを使って書く
ようにしてください。古いテストのいくつかは、 ‘sys.stdout’ への出力を比較
する「従来の」テスト形式になっていますが、この形式のテストは廃止予定です
。

参考
....

*note unittest: ef. モジュール

     PyUnit 回帰テストを書く。

*note doctest: 31. モジュール

     ドキュメンテーション文字列に埋め込まれたテスト。

* Menu:

* test パッケージのためのユニットテストを書く::
* コマンドラインインターフェースを利用してテストを実行する::


File: python.info,  Node: test パッケージのためのユニットテストを書く,  Next: コマンドラインインターフェースを利用してテストを実行する,  Up: test --- Regression tests package for Python

5.26.8.1 ‘test’ パッケージのためのユニットテストを書く
......................................................

*note unittest: ef. モジュールを使ってテストを書く場合、幾つかのガイドラ
インに従うことが推奨されます。 1つは、テストモジュールの名前を、 ‘test_’
で始め、テスト対象となるモジュール名で終えることです。テストモジュール中
のテストメソッドは名前を ‘test_’ で始めて、そのメソッドが何をテストして
いるかという説明で終えます。これはテスト実行プログラムが、そのメソッドを
テストメソッドとして認識するために必要です。また、テストメソッドにはドキ
ュメンテーション文字列を入れるべきではありません。コメント（例えば ‘#
True あるいは False だけを返すテスト関数’ ）を使用して、テストメソッドの
ドキュメントを記述してください。これは、ドキュメンテーション文字列が存在
する場合はその内容が出力されてしまうため、どのテストを実行しているのかを
いちいち表示したくないからです。

以下のような決まり文句を使います:

     import unittest
     from test import support

     class MyTestCase1(unittest.TestCase):

         # Only use setUp() and tearDown() if necessary

         def setUp(self):
             ... code to execute in preparation for tests ...

         def tearDown(self):
             ... code to execute to clean up after tests ...

         def test_feature_one(self):
             # Test feature one.
             ... testing code ...

         def test_feature_two(self):
             # Test feature two.
             ... testing code ...

         ... more test methods ...

     class MyTestCase2(unittest.TestCase):
         ... same structure as MyTestCase1 ...

     ... more test classes ...

     if __name__ == '__main__':
         unittest.main()

このコードのパターンを使うと *note test.regrtest: cc. からテストスイート
を実行でき、 *note unittest: ef. のコマンドラインインターフェースをサポ
ートしているスクリプトとして自分自身を起動したり、 ‘python -m unittest’
というコマンドラインインターフェースを通して起動したりできます。

回帰テストの目的はコードを解き明かすことです。そのためには以下のいくつか
のガイドラインに従ってください:

   * テストスイートから、すべてのクラス、関数および定数を実行するべきで
     す。これには外部に公開される外部APIだけでなく「プライベートな」コー
     ドも含みます。

   * ホワイトボックス・テスト（対象のコードの詳細を元にテストを書くこと
     ）を推奨します。ブラックボックス・テスト（公開されるインターフェー
     ス仕様だけをテストすること）は、すべての境界条件を確実にテストする
     には完全ではありません。

   * すべての取りうる値を、無効値も含めてテストするようにしてください。
     そのようなテストを書くことで、全ての有効値が通るだけでなく、不適切
     な値が正しく処理されることも確認できます。

   * コード内のできる限り多くのパスを網羅してください。分岐するように入
     力を調整したテストを書くことで、コードの多くのパスをたどることがで
     きます。

   * テスト対象のコードにバグが発見された場合は、明示的にテスト追加する
     ようにしてください。そのようなテストを追加することで、将来コードを
     変更した際にエラーが再発することを防止できます。

   * テストの後始末 (例えば一時ファイルをすべて閉じたり削除したりするこ
     と) を必ず行ってください。

   * テストがオペレーティングシステムの特定の状況に依存する場合、テスト
     開始時に条件を満たしているかを検証してください。

   * インポートするモジュールをできるかぎり少なくし、可能な限り早期にイ
     ンポートを行ってください。そうすることで、テストの外部依存性を最小
     限にし、モジュールのインポートによる副作用から生じる変則的な動作を
     最小限にできます。

   * できる限りテストコードを再利用するようにしましょう。時として、入力
     の違いだけを記述すれば良くなるくらい、テストコードを小さくすること
     ができます。例えば以下のように、サブクラスで入力を指定することで、
     コードの重複を最小化することができます:

          class TestFuncAcceptsSequencesMixin:

              func = mySuperWhammyFunction

              def test_func(self):
                  self.func(self.arg)

          class AcceptLists(TestFuncAcceptsSequencesMixin, unittest.TestCase):
              arg = [1, 2, 3]

          class AcceptStrings(TestFuncAcceptsSequencesMixin, unittest.TestCase):
              arg = 'abc'

          class AcceptTuples(TestFuncAcceptsSequencesMixin, unittest.TestCase):
              arg = (1, 2, 3)

     When using this pattern, remember that all classes that inherit
     from *note unittest.TestCase: 41a. are run as tests.  The
     ‘TestFuncAcceptsSequencesMixin’ class in the example above does not
     have any data and so can't be run by itself, thus it does not
     inherit from *note unittest.TestCase: 41a.

参考
....

Test Driven Development

     コードより前にテストを書く方法論に関する Kent Beck の著書。


File: python.info,  Node: コマンドラインインターフェースを利用してテストを実行する,  Prev: test パッケージのためのユニットテストを書く,  Up: test --- Regression tests package for Python

5.26.8.2 コマンドラインインターフェースを利用してテストを実行する
.................................................................

*note test: cb. パッケージはスクリプトとして Python の回帰テストスイート
を実行できます。 *note -m: 5ab. オプションを利用して、 ‘python -m
test.regrtest’ として実行します。 この仕組みの内部では *note
test.regrtest: cc.; を使っています; 古いバージョンの Python で使われてい
る ‘python -m test.regrtest’ という呼び出しは今でも上手く動きます。 スク
リプトを実行すると、自動的に *note test: cb. パッケージ内のすべての回帰
テストを実行し始めます。 パッケージ内の名前が ‘test_’ で始まる全モジュー
ルを見つけ、それをインポートし、もしあるなら関数 ‘test_main()’ を実行し
、 ‘test_main’ が無い場合は unittest.TestLoader.loadTestsFromModule から
テストをロードしてテストを実行します。 実行するテストの名前もスクリプト
に渡される可能性があります。 単一の回帰テストを指定 (‘python -m test
test_spam’) すると、出力を最小限にし、テストが成功したかあるいは失敗した
かだけを出力します。

直接 *note test: cb. を実行すると、テストに利用するリソースを設定できま
す。これを行うには、 ‘-u’ コマンドラインオプションを使います。 ‘-u’ のオ
プションに ‘all’ を指定すると、すべてのリソースを有効にします: ‘python
-m test -uall’ 。(よくある場合ですが) 何か一つを除く全てが必要な場合、カ
ンマで区切った不要なリソースのリストを ‘all’ の後に並べます。コマンド
‘python -m test -uall,-audio,-largefile’ とすると、 ‘audio’ と
‘largefile’ リソースを除く全てのリソースを使って *note test: cb. を実行
します。すべてのリソースのリストと追加のコマンドラインオプションを出力す
るには、 ‘python -m test -h’ を実行してください。

テストを実行しようとするプラットフォームによっては、回帰テストを実行する
別の方法があります。 Unix では、Python をビルドしたトップレベルディレク
トリで ‘make test’ を実行できます。 Windows上では、 ‘PCbuild’ ディレクト
リから ‘rt.bat’ を実行すると、すべての回帰テストを実行します。


File: python.info,  Node: test support --- テストのためのユーティリティ関数,  Next: test support socket_helper --- Utilities for socket tests,  Prev: test --- Regression tests package for Python,  Up: 開発ツール

5.26.9 ‘test.support’ -- テストのためのユーティリティ関数
---------------------------------------------------------

*note test.support: cd. モジュールでは、 Python の回帰テストに対するサポ
ートを提供しています。

     注釈: *note test.support: cd. はパブリックなモジュールではありませ
     ん。 ここでドキュメント化されているのは Python 開発者がテストを書く
     のを助けるためです。 このモジュールの API はリリース間で後方非互換
     な変更がなされる可能性があります。

このモジュールは次の例外を定義しています:

 -- 例外: test.support.TestFailed

     テストが失敗したとき送出される例外です。これは、 *note unittest:
     ef. ベースのテストでは廃止予定で、 *note unittest.TestCase: 41a. の
     assertXXX メソッドが推奨されます。

 -- 例外: test.support.ResourceDenied

     *note unittest.SkipTest: fb1. のサブクラスです。 (ネットワーク接続
     のような) リソースが利用できないとき送出されます。 *note
     requires(): 3faf. 関数によって送出されます。

*note test.support: cd. モジュールでは、以下の定数を定義しています:

 -- データ: test.support.verbose

     冗長な出力が有効な場合は ‘True’ です。実行中のテストについてのより
     詳細な情報が欲しいときにチェックします。 'verbose' は *note
     test.regrtest: cc. によって設定されます。

 -- データ: test.support.is_jython

     実行中のインタプリタが Jython ならば ‘True’ になります。

 -- データ: test.support.is_android

     システムが Android の場合 ‘True’ になります。

 -- データ: test.support.unix_shell

     Windows 以外ではシェルのパスです; そうでない場合は ‘None’ です。

 -- データ: test.support.LOOPBACK_TIMEOUT

     Timeout in seconds for tests using a network server listening on
     the network local loopback interface like ‘127.0.0.1’.

     The timeout is long enough to prevent test failure: it takes into
     account that the client and the server can run in different threads
     or even different processes.

     The timeout should be long enough for *note connect(): d70, *note
     recv(): d71. and *note send(): d74. methods of *note socket.socket:
     d6e.

     デフォルト値は5秒です。

     *note INTERNET_TIMEOUT: 1920. も参照してください。

 -- データ: test.support.INTERNET_TIMEOUT

     Timeout in seconds for network requests going to the internet.

     The timeout is short enough to prevent a test to wait for too long
     if the internet request is blocked for whatever reason.

     Usually, a timeout using *note INTERNET_TIMEOUT: 1920. should not
     mark a test as failed, but skip the test instead: see *note
     transient_internet(): 3fb4.

     デフォルト値は1分です。

     *note LOOPBACK_TIMEOUT: 191f. も参照してください。

 -- データ: test.support.SHORT_TIMEOUT

     Timeout in seconds to mark a test as failed if the test takes "too
     long".

     The timeout value depends on the regrtest ‘--timeout’ command line
     option.

     If a test using *note SHORT_TIMEOUT: 1819. starts to fail randomly
     on slow buildbots, use *note LONG_TIMEOUT: 1921. instead.

     デフォルト値は30秒です。

 -- データ: test.support.LONG_TIMEOUT

     Timeout in seconds to detect when a test hangs.

     It is long enough to reduce the risk of test failure on the slowest
     Python buildbots.  It should not be used to mark a test as failed
     if the test takes "too long".  The timeout value depends on the
     regrtest ‘--timeout’ command line option.

     デフォルト値は5分です。

     See also *note LOOPBACK_TIMEOUT: 191f, *note INTERNET_TIMEOUT:
     1920. and *note SHORT_TIMEOUT: 1819.

 -- データ: test.support.PGO

     テストが PGO (Profile Guided Optimization) の役に立たないときにスキ
     ップできるなら設定します。

 -- データ: test.support.PIPE_MAX_SIZE

     書き込みをブロックするための、基底にある OS のパイプバッファサイズ
     より大きいであろう定数。

 -- データ: test.support.Py_DEBUG

     ‘True’ if Python was built with the *note Py_DEBUG: 3fb8. macro
     defined, that is, if Python was *note built in debug mode: 1da.

     Added in version 3.12.

 -- データ: test.support.SOCK_MAX_SIZE

     書き込みをブロックするための、基底にある OS のソケットバッファサイ
     ズより大きいであろう定数。

 -- データ: test.support.TEST_SUPPORT_DIR

     *note test.support: cd. を含んだトップディレクトリを設定します。

 -- データ: test.support.TEST_HOME_DIR

     テストパッケージのトップディレクトリを設定します。

 -- データ: test.support.TEST_DATA_DIR

     テストパッケージ内の ‘data’ ディレクトリを設定します。

 -- データ: test.support.MAX_Py_ssize_t

     大量のメモリを使うテストのための *note sys.maxsize: 1195. を設定し
     ます。

 -- データ: test.support.max_memuse

     大量のメモリを使うテストのためのメモリ上限となる *note
     set_memlimit(): 3fbf. を設定します。 *note MAX_Py_ssize_t: 3fbd. が
     設定上限です。

 -- データ: test.support.real_max_memuse

     大量のメモリを使うテストのためのメモリ上限となる *note
     set_memlimit(): 3fbf. を設定します。 *note MAX_Py_ssize_t: 3fbd. の
     設定上限はありません。

 -- データ: test.support.MISSING_C_DOCSTRINGS

     Set to ‘True’ if Python is built without docstrings (the
     ‘WITH_DOC_STRINGS’ macro is not defined).  See the *note configure
     -without-doc-strings: 1d19. option.

     See also the *note HAVE_DOCSTRINGS: 3fc2. variable.

 -- データ: test.support.HAVE_DOCSTRINGS

     Set to ‘True’ if function docstrings are available.  See the *note
     python -OO: d82. option, which strips docstrings of functions
     implemented in Python.

     See also the *note MISSING_C_DOCSTRINGS: 3fc1. variable.

 -- データ: test.support.TEST_HTTP_URL

     ネットワークテスト専用の HTTP サーバーの URL を定義します。

 -- データ: test.support.ALWAYS_EQ

     Object that is equal to anything.  Used to test mixed type
     comparison.

 -- データ: test.support.NEVER_EQ

     Object that is not equal to anything (even to *note ALWAYS_EQ:
     3fc4.).  Used to test mixed type comparison.

 -- データ: test.support.LARGEST

     Object that is greater than anything (except itself).  Used to test
     mixed type comparison.

 -- データ: test.support.SMALLEST

     Object that is less than anything (except itself).  Used to test
     mixed type comparison.

*note test.support: cd. モジュールでは、以下の関数を定義しています:

 -- の関数: test.support.busy_retry (timeout, err_msg=None, /, *,
          error=True)

     Run the loop body until ‘break’ stops the loop.

     After 'timeout' seconds, raise an *note AssertionError: 675. if
     'error' is true, or just stop the loop if 'error' is false.

     以下はプログラム例です:

          for _ in support.busy_retry(support.SHORT_TIMEOUT):
              if check():
                  break

     Example of error=False usage:

          for _ in support.busy_retry(support.SHORT_TIMEOUT, error=False):
              if check():
                  break
          else:
              raise RuntimeError('my custom error')

 -- の関数: test.support.sleeping_retry (timeout, err_msg=None, /, *,
          init_delay=0.010, max_delay=1.0, error=True)

     Wait strategy that applies exponential backoff.

     Run the loop body until ‘break’ stops the loop.  Sleep at each loop
     iteration, but not at the first iteration.  The sleep delay is
     doubled at each iteration (up to 'max_delay' seconds).

     See *note busy_retry(): 3fc8. documentation for the parameters
     usage.

     Example raising an exception after SHORT_TIMEOUT seconds:

          for _ in support.sleeping_retry(support.SHORT_TIMEOUT):
              if check():
                  break

     Example of error=False usage:

          for _ in support.sleeping_retry(support.SHORT_TIMEOUT, error=False):
              if check():
                  break
          else:
              raise RuntimeError('my custom error')

 -- の関数: test.support.is_resource_enabled (resource)

     'resource' が有効で利用可能ならば ‘True’ を返します。利用可能なリソ
     ースのリストは、 *note test.regrtest: cc. がテストを実行している間
     のみ設定されます。

 -- の関数: test.support.python_is_optimized ()

     Return ‘True’ if Python was not built with ‘-O0’ or ‘-Og’.

 -- の関数: test.support.with_pymalloc ()

     Return ‘_testcapi.WITH_PYMALLOC’.

 -- の関数: test.support.requires (resource, msg=None)

     'resource' が利用できなければ、 *note ResourceDenied: 3fae. を送出
     します。その場合、 'msg' は *note ResourceDenied: 3fae. の引数にな
     ります。 ‘__name__’ が ‘'__main__'’ である関数にから呼び出された場
     合には常に ‘True’ を返します。テストを *note test.regrtest: cc. か
     ら実行するときに使われます。

 -- の関数: test.support.sortdict (dict)

     Return a repr of 'dict' with keys sorted.

 -- の関数: test.support.findfile (filename, subdir=None)

     'filename' という名前のファイルへのパスを返します。一致するものが見
     つからなければ、 'filename' 自体を返します。 'filename' 自体もファ
     イルへのパスでありえるので、 'filename' が返っても失敗ではありませ
     ん。

     'subdir' を設定することで、パスのディレクトリを直接見に行くのではな
     く、相対パスを使って見付けにいくように指示できます。

 -- の関数: test.support.get_pagesize ()

     Get size of a page in bytes.

     Added in version 3.12.

 -- の関数: test.support.setswitchinterval (interval)

     Set the *note sys.setswitchinterval(): 918. to the given
     'interval'.  Defines a minimum interval for Android systems to
     prevent the system from hanging.

 -- の関数: test.support.check_impl_detail (**guards)

     Use this check to guard CPython's implementation-specific tests or
     to run them only on the implementations guarded by the arguments.
     This function returns ‘True’ or ‘False’ depending on the host
     platform.  Example usage:

          check_impl_detail()               # Only on CPython (default).
          check_impl_detail(jython=True)    # Only on Jython.
          check_impl_detail(cpython=False)  # Everywhere except CPython.

 -- の関数: test.support.set_memlimit (limit)

     Set the values for *note max_memuse: 3fbe. and *note
     real_max_memuse: 3fc0. for big memory tests.

 -- の関数: test.support.record_original_stdout (stdout)

     Store the value from 'stdout'.  It is meant to hold the stdout at
     the time the regrtest began.

 -- の関数: test.support.get_original_stdout ()

     Return the original stdout set by *note record_original_stdout():
     3fd2. or ‘sys.stdout’ if it's not set.

 -- の関数: test.support.args_from_interpreter_flags ()

     Return a list of command line arguments reproducing the current
     settings in ‘sys.flags’ and ‘sys.warnoptions’.

 -- の関数: test.support.optim_args_from_interpreter_flags ()

     Return a list of command line arguments reproducing the current
     optimization settings in ‘sys.flags’.

 -- の関数: test.support.captured_stdin ()
 -- の関数: test.support.captured_stdout ()
 -- の関数: test.support.captured_stderr ()

     名前付きストリ－ムを *note io.StringIO: ef3. オブジェクトで一時的に
     置き換えるコンテキストマネージャです。

     出力ストリームの使用例:

          with captured_stdout() as stdout, captured_stderr() as stderr:
              print("hello")
              print("error", file=sys.stderr)
          assert stdout.getvalue() == "hello\n"
          assert stderr.getvalue() == "error\n"

     入力ストリ－ムの使用例:

          with captured_stdin() as stdin:
              stdin.write('hello\n')
              stdin.seek(0)
              # call test code that consumes from sys.stdin
              captured = input()
          self.assertEqual(captured, "hello")

 -- の関数: test.support.disable_faulthandler ()

     A context manager that temporary disables *note faulthandler: 4e.

 -- の関数: test.support.gc_collect ()

     Force as many objects as possible to be collected.  This is needed
     because timely deallocation is not guaranteed by the garbage
     collector.  This means that ‘__del__’ methods may be called later
     than expected and weakrefs may remain alive for longer than
     expected.

 -- の関数: test.support.disable_gc ()

     A context manager that disables the garbage collector on entry.  On
     exit, the garbage collector is restored to its prior state.

 -- の関数: test.support.swap_attr (obj, attr, new_val)

     Context manager to swap out an attribute with a new object.

     使い方:

          with swap_attr(obj, "attr", 5):
              ...

     This will set ‘obj.attr’ to 5 for the duration of the ‘with’ block,
     restoring the old value at the end of the block.  If ‘attr’ doesn't
     exist on ‘obj’, it will be created and then deleted at the end of
     the block.

     The old value (or ‘None’ if it doesn't exist) will be assigned to
     the target of the "as" clause, if there is one.

 -- の関数: test.support.swap_item (obj, attr, new_val)

     Context manager to swap out an item with a new object.

     使い方:

          with swap_item(obj, "item", 5):
              ...

     This will set ‘obj["item"]’ to 5 for the duration of the ‘with’
     block, restoring the old value at the end of the block.  If ‘item’
     doesn't exist on ‘obj’, it will be created and then deleted at the
     end of the block.

     The old value (or ‘None’ if it doesn't exist) will be assigned to
     the target of the "as" clause, if there is one.

 -- の関数: test.support.flush_std_streams ()

     Call the ‘flush()’ method on *note sys.stdout: aa4. and then on
     *note sys.stderr: 907.  It can be used to make sure that the logs
     order is consistent before writing into stderr.

     Added in version 3.11.

 -- の関数: test.support.print_warning (msg)

     Print a warning into *note sys.__stderr__: 3fdf.  Format the
     message as: ‘f"Warning -- {msg}"’.  If 'msg' is made of multiple
     lines, add ‘"Warning -- "’ prefix to each line.

     Added in version 3.9.

 -- の関数: test.support.wait_process (pid, *, exitcode, timeout=None)

     Wait until process 'pid' completes and check that the process exit
     code is 'exitcode'.

     Raise an *note AssertionError: 675. if the process exit code is not
     equal to 'exitcode'.

     If the process runs longer than 'timeout' seconds (*note
     SHORT_TIMEOUT: 1819. by default), kill the process and raise an
     *note AssertionError: 675.  The timeout feature is not available on
     Windows.

     Added in version 3.9.

 -- の関数: test.support.calcobjsize (fmt)

     Return the size of the *note PyObject: 312. whose structure members
     are defined by 'fmt'.  The returned value includes the size of the
     Python object header and alignment.

 -- の関数: test.support.calcvobjsize (fmt)

     Return the size of the *note PyVarObject: 3fe2. whose structure
     members are defined by 'fmt'.  The returned value includes the size
     of the Python object header and alignment.

 -- の関数: test.support.checksizeof (test, o, size)

     For testcase 'test', assert that the ‘sys.getsizeof’ for 'o' plus
     the GC header size equals 'size'.

 -- の関数: @test.support.anticipate_failure (condition)

     ある条件で *note unittest.expectedFailure(): 3efa. の印をテストに付
     けるデコレータ。 このデコレータを使うときはいつも、関連する問題を指
     し示すコメントを付けておくべきです。

 -- の関数: test.support.system_must_validate_cert (f)

     A decorator that skips the decorated test on TLS certification
     validation failures.

 -- の関数: @test.support.run_with_locale (catstr, *locales)

     別のロケールで関数を実行し、完了したら適切に元の状態に戻すためのデ
     コレータ。 'catstr' は (例えば ‘"LC_ALL"’ のような) ロケールカテゴ
     リを文字列で表したものです。 渡された 'locales' が順々に試され、一
     番最初に出てきた妥当なロケールが使われます。

 -- の関数: @test.support.run_with_tz (tz)

     A decorator for running a function in a specific timezone,
     correctly resetting it after it has finished.

 -- の関数: @test.support.requires_freebsd_version (*min_version)

     Decorator for the minimum version when running test on FreeBSD. If
     the FreeBSD version is less than the minimum, the test is skipped.

 -- の関数: @test.support.requires_linux_version (*min_version)

     Decorator for the minimum version when running test on Linux.  If
     the Linux version is less than the minimum, the test is skipped.

 -- の関数: @test.support.requires_mac_version (*min_version)

     Decorator for the minimum version when running test on macOS. If
     the macOS version is less than the minimum, the test is skipped.

 -- の関数: @test.support.requires_gil_enabled

     Decorator for skipping tests on the free-threaded build.  If the
     *note GIL: 13f. is disabled, the test is skipped.

 -- の関数: @test.support.requires_IEEE_754

     Decorator for skipping tests on non-IEEE 754 platforms.

 -- の関数: @test.support.requires_zlib

     Decorator for skipping tests if *note zlib: 119. doesn't exist.

 -- の関数: @test.support.requires_gzip

     Decorator for skipping tests if *note gzip: 5d. doesn't exist.

 -- の関数: @test.support.requires_bz2

     Decorator for skipping tests if *note bz2: f. doesn't exist.

 -- の関数: @test.support.requires_lzma

     Decorator for skipping tests if *note lzma: 7e. doesn't exist.

 -- の関数: @test.support.requires_resource (resource)

     Decorator for skipping tests if 'resource' is not available.

 -- の関数: @test.support.requires_docstrings

     Decorator for only running the test if *note HAVE_DOCSTRINGS: 3fc2.

 -- の関数: @test.support.requires_limited_api

     Decorator for only running the test if *note Limited C API: 36f. is
     available.

 -- の関数: @test.support.cpython_only

     Decorator for tests only applicable to CPython.

 -- の関数: @test.support.impl_detail (msg=None, **guards)

     Decorator for invoking *note check_impl_detail(): 3fd1. on
     'guards'.  If that returns ‘False’, then uses 'msg' as the reason
     for skipping the test.

 -- の関数: @test.support.no_tracing

     Decorator to temporarily turn off tracing for the duration of the
     test.

 -- の関数: @test.support.refcount_test

     Decorator for tests which involve reference counting.  The
     decorator does not run the test if it is not run by CPython.  Any
     trace function is unset for the duration of the test to prevent
     unexpected refcounts caused by the trace function.

 -- の関数: @test.support.bigmemtest (size, memuse, dry_run=True)

     Decorator for bigmem tests.

     'size' is a requested size for the test (in arbitrary,
     test-interpreted units.)  'memuse' is the number of bytes per unit
     for the test, or a good estimate of it.  For example, a test that
     needs two byte buffers, of 4 GiB each, could be decorated with
     ‘@bigmemtest(size=_4G, memuse=2)’.

     The 'size' argument is normally passed to the decorated test method
     as an extra argument.  If 'dry_run' is ‘True’, the value passed to
     the test method may be less than the requested value.  If 'dry_run'
     is ‘False’, it means the test doesn't support dummy runs when ‘-M’
     is not specified.

 -- の関数: @test.support.bigaddrspacetest

     Decorator for tests that fill the address space.

 -- の関数: test.support.check_syntax_error (testcase, statement,
          errtext='', *, lineno=None, offset=None)

     Test for syntax errors in 'statement' by attempting to compile
     'statement'.  'testcase' is the *note unittest: ef. instance for
     the test.  'errtext' is the regular expression which should match
     the string representation of the raised *note SyntaxError: 172.  If
     'lineno' is not ‘None’, compares to the line of the exception.  If
     'offset' is not ‘None’, compares to the offset of the exception.

 -- の関数: test.support.open_urlresource (url, *args, **kw)

     Open 'url'.  If open fails, raises *note TestFailed: 3fad.

 -- の関数: test.support.reap_children ()

     Use this at the end of ‘test_main’ whenever sub-processes are
     started.  This will help ensure that no extra children (zombies)
     stick around to hog resources and create problems when looking for
     refleaks.

 -- の関数: test.support.get_attribute (obj, name)

     Get an attribute, raising *note unittest.SkipTest: fb1. if *note
     AttributeError: 326. is raised.

 -- の関数: test.support.catch_unraisable_exception ()

     Context manager catching unraisable exception using *note
     sys.unraisablehook(): 1d8.

     Storing the exception value (‘cm.unraisable.exc_value’) creates a
     reference cycle.  The reference cycle is broken explicitly when the
     context manager exits.

     Storing the object (‘cm.unraisable.object’) can resurrect it if it
     is set to an object which is being finalized.  Exiting the context
     manager clears the stored object.

     使い方:

          with support.catch_unraisable_exception() as cm:
              # code creating an "unraisable exception"
              ...

              # check the unraisable exception: use cm.unraisable
              ...

          # cm.unraisable attribute no longer exists at this point
          # (to break a reference cycle)

     Added in version 3.8.

 -- の関数: test.support.load_package_tests (pkg_dir, loader,
          standard_tests, pattern)

     Generic implementation of the *note unittest: ef. ‘load_tests’
     protocol for use in test packages.  'pkg_dir' is the root directory
     of the package; 'loader', 'standard_tests', and 'pattern' are the
     arguments expected by ‘load_tests’.  In simple cases, the test
     package's ‘__init__.py’ can be the following:

          import os
          from test.support import load_package_tests

          def load_tests(*args):
              return load_package_tests(os.path.dirname(__file__), *args)

 -- の関数: test.support.detect_api_mismatch (ref_api, other_api, *,
          ignore=())

     Returns the set of attributes, functions or methods of 'ref_api'
     not found on 'other_api', except for a defined list of items to be
     ignored in this check specified in 'ignore'.

     By default this skips private attributes beginning with '_' but
     includes all magic methods, i.e.  those starting and ending in
     '__'.

     Added in version 3.5.

 -- の関数: test.support.patch (test_instance, object_to_patch,
          attr_name, new_value)

     Override 'object_to_patch.attr_name' with 'new_value'.  Also add
     cleanup procedure to 'test_instance' to restore 'object_to_patch'
     for 'attr_name'.  The 'attr_name' should be a valid attribute for
     'object_to_patch'.

 -- の関数: test.support.run_in_subinterp (code)

     Run 'code' in subinterpreter.  Raise *note unittest.SkipTest: fb1.
     if *note tracemalloc: e8. is enabled.

 -- の関数: test.support.check_free_after_iterating (test, iter, cls,
          args=())

     Assert instances of 'cls' are deallocated after iterating.

 -- の関数: test.support.missing_compiler_executable (cmd_names=[])

     Check for the existence of the compiler executables whose names are
     listed in 'cmd_names' or all the compiler executables when
     'cmd_names' is empty and return the first missing executable or
     ‘None’ when none is found missing.

 -- の関数: test.support.check__all__ (test_case, module,
          name_of_module=None, extra=(), not_exported=())

     Assert that the ‘__all__’ variable of 'module' contains all public
     names.

     The module's public names (its API) are detected automatically
     based on whether they match the public name convention and were
     defined in 'module'.

     The 'name_of_module' argument can specify (as a string or tuple
     thereof) what module(s) an API could be defined in order to be
     detected as a public API. One case for this is when 'module'
     imports part of its public API from other modules, possibly a C
     backend (like ‘csv’ and its ‘_csv’).

     The 'extra' argument can be a set of names that wouldn't otherwise
     be automatically detected as "public", like objects without a
     proper *note __module__: 21d4. attribute.  If provided, it will be
     added to the automatically detected ones.

     The 'not_exported' argument can be a set of names that must not be
     treated as part of the public API even though their names indicate
     otherwise.

     使用例:

          import bar
          import foo
          import unittest
          from test import support

          class MiscTestCase(unittest.TestCase):
              def test__all__(self):
                  support.check__all__(self, foo)

          class OtherTestCase(unittest.TestCase):
              def test__all__(self):
                  extra = {'BAR_CONST', 'FOO_CONST'}
                  not_exported = {'baz'}  # Undocumented name.
                  # bar imports part of its API from _bar.
                  support.check__all__(self, bar, ('bar', '_bar'),
                                       extra=extra, not_exported=not_exported)

     Added in version 3.6.

 -- の関数: test.support.skip_if_broken_multiprocessing_synchronize ()

     Skip tests if the ‘multiprocessing.synchronize’ module is missing,
     if there is no available semaphore implementation, or if creating a
     lock raises an *note OSError: 3f0.

     Added in version 3.10.

 -- の関数: test.support.check_disallow_instantiation (test_case, tp,
          *args, **kwds)

     Assert that type 'tp' cannot be instantiated using 'args' and
     'kwds'.

     Added in version 3.10.

 -- の関数: test.support.adjust_int_max_str_digits (max_digits)

     This function returns a context manager that will change the global
     *note sys.set_int_max_str_digits(): 1729. setting for the duration
     of the context to allow execution of test code that needs a
     different limit on the number of digits when converting between an
     integer and string.

     Added in version 3.11.

*note test.support: cd. モジュールでは、以下のクラスを定義しています:

 -- クラス: test.support.SuppressCrashReport

     A context manager used to try to prevent crash dialog popups on
     tests that are expected to crash a subprocess.

     On Windows, it disables Windows Error Reporting dialogs using
     SetErrorMode(1).

     On UNIX, *note resource.setrlimit(): 4007. is used to set *note
     resource.RLIMIT_CORE: 4008.'s soft limit to 0 to prevent coredump
     file creation.

     On both platforms, the old value is restored by *note __exit__():
     12ce.

 -- クラス: test.support.SaveSignals

     Class to save and restore signal handlers registered by the Python
     signal handler.

      -- メソッド: save (self)

          Save the signal handlers to a dictionary mapping signal
          numbers to the current signal handler.

      -- メソッド: restore (self)

          Set the signal numbers from the *note save(): 400a. dictionary
          to the saved handler.

 -- クラス: test.support.Matcher

      -- メソッド: matches (self, d, **kwargs)

          Try to match a single dict with the supplied arguments.

      -- メソッド: match_value (self, k, dv, v)

          Try to match a single stored value ('dv') with a supplied
          value ('v').

   ---------- Footnotes ----------

   (1) 
https://msdn.microsoft.com/en-us/library/windows/desktop/ms680621.aspx


File: python.info,  Node: test support socket_helper --- Utilities for socket tests,  Next: test support script_helper --- Utilities for the Python execution tests,  Prev: test support --- テストのためのユーティリティ関数,  Up: 開発ツール

5.26.10 ‘test.support.socket_helper’ -- Utilities for socket tests
------------------------------------------------------------------

The *note test.support.socket_helper: d2. module provides support for
socket tests.

Added in version 3.9.

 -- データ: test.support.socket_helper.IPV6_ENABLED

     Set to ‘True’ if IPv6 is enabled on this host, ‘False’ otherwise.

 -- の関数: test.support.socket_helper.find_unused_port
          (family=socket.AF_INET, socktype=socket.SOCK_STREAM)

     Returns an unused port that should be suitable for binding.  This
     is achieved by creating a temporary socket with the same family and
     type as the ‘sock’ parameter (default is *note AF_INET: 1788, *note
     SOCK_STREAM: 12c1.), and binding it to the specified host address
     (defaults to ‘0.0.0.0’) with the port set to 0, eliciting an unused
     ephemeral port from the OS. The temporary socket is then closed and
     deleted, and the ephemeral port is returned.

     Either this method or *note bind_port(): 4012. should be used for
     any tests where a server socket needs to be bound to a particular
     port for the duration of the test.  Which one to use depends on
     whether the calling code is creating a Python socket, or if an
     unused port needs to be provided in a constructor or passed to an
     external program (i.e.  the ‘-accept’ argument to openssl's
     s_server mode).  Always prefer *note bind_port(): 4012. over *note
     find_unused_port(): 4011. where possible.  Using a hard coded port
     is discouraged since it can make multiple instances of the test
     impossible to run simultaneously, which is a problem for buildbots.

 -- の関数: test.support.socket_helper.bind_port (sock, host=HOST)

     Bind the socket to a free port and return the port number.  Relies
     on ephemeral ports in order to ensure we are using an unbound port.
     This is important as many tests may be running simultaneously,
     especially in a buildbot environment.  This method raises an
     exception if the ‘sock.family’ is *note AF_INET: 1788. and
     ‘sock.type’ is *note SOCK_STREAM: 12c1, and the socket has
     ‘SO_REUSEADDR’ or ‘SO_REUSEPORT’ set on it.  Tests should never set
     these socket options for TCP/IP sockets.  The only case for setting
     these options is testing multicasting via multiple UDP sockets.

     Additionally, if the ‘SO_EXCLUSIVEADDRUSE’ socket option is
     available (i.e.  on Windows), it will be set on the socket.  This
     will prevent anyone else from binding to our host/port for the
     duration of the test.

 -- の関数: test.support.socket_helper.bind_unix_socket (sock, addr)

     Bind a Unix socket, raising *note unittest.SkipTest: fb1. if *note
     PermissionError: d10. is raised.

 -- の関数: @test.support.socket_helper.skip_unless_bind_unix_socket

     A decorator for running tests that require a functional ‘bind()’
     for Unix sockets.

 -- の関数: test.support.socket_helper.transient_internet
          (resource_name, *, timeout=30.0, errnos=())

     A context manager that raises *note ResourceDenied: 3fae. when
     various issues with the internet connection manifest themselves as
     exceptions.


File: python.info,  Node: test support script_helper --- Utilities for the Python execution tests,  Next: test support bytecode_helper --- Support tools for testing correct bytecode generation,  Prev: test support socket_helper --- Utilities for socket tests,  Up: 開発ツール

5.26.11 ‘test.support.script_helper’ -- Utilities for the Python execution tests
--------------------------------------------------------------------------------

The *note test.support.script_helper: d1. module provides support for
Python's script execution tests.

 -- の関数: test.support.script_helper.interpreter_requires_environment
          ()

     Return ‘True’ if ‘sys.executable interpreter’ requires environment
     variables in order to be able to run at all.

     This is designed to be used with ‘@unittest.skipIf()’ to annotate
     tests that need to use an ‘assert_python*()’ function to launch an
     isolated mode (‘-I’) or no environment mode (‘-E’) sub-interpreter
     process.

     A normal build & test does not run into this situation but it can
     happen when trying to run the standard library test suite from an
     interpreter that doesn't have an obvious home with Python's current
     home finding logic.

     Setting *note PYTHONHOME: 396. is one way to get most of the
     testsuite to run in that situation.  *note PYTHONPATH: fe8. or
     ‘PYTHONUSERSITE’ are other common environment variables that might
     impact whether or not the interpreter can start.

 -- の関数: test.support.script_helper.run_python_until_end (*args,
          **env_vars)

     Set up the environment based on 'env_vars' for running the
     interpreter in a subprocess.  The values can include ‘__isolated’,
     ‘__cleanenv’, ‘__cwd’, and ‘TERM’.

     バージョン 3.9 で変更: The function no longer strips whitespaces
     from 'stderr'.

 -- の関数: test.support.script_helper.assert_python_ok (*args,
          **env_vars)

     Assert that running the interpreter with 'args' and optional
     environment variables 'env_vars' succeeds (‘rc == 0’) and return a
     ‘(return code, stdout, stderr)’ tuple.

     If the '__cleanenv' keyword-only parameter is set, 'env_vars' is
     used as a fresh environment.

     Python is started in isolated mode (command line option ‘-I’),
     except if the '__isolated' keyword-only parameter is set to
     ‘False’.

     バージョン 3.9 で変更: The function no longer strips whitespaces
     from 'stderr'.

 -- の関数: test.support.script_helper.assert_python_failure (*args,
          **env_vars)

     Assert that running the interpreter with 'args' and optional
     environment variables 'env_vars' fails (‘rc != 0’) and return a
     ‘(return code, stdout, stderr)’ tuple.

     See *note assert_python_ok(): 4018. for more options.

     バージョン 3.9 で変更: The function no longer strips whitespaces
     from 'stderr'.

 -- の関数: test.support.script_helper.spawn_python (*args,
          stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw)

     Run a Python subprocess with the given arguments.

     'kw' is extra keyword args to pass to *note subprocess.Popen():
     17e.  Returns a *note subprocess.Popen: 17e. object.

 -- の関数: test.support.script_helper.kill_python (p)

     Run the given *note subprocess.Popen: 17e. process until completion
     and return stdout.

 -- の関数: test.support.script_helper.make_script (script_dir,
          script_basename, source, omit_suffix=False)

     Create script containing 'source' in path 'script_dir' and
     'script_basename'.  If 'omit_suffix' is ‘False’, append ‘.py’ to
     the name.  Return the full script path.

 -- の関数: test.support.script_helper.make_zip_script (zip_dir,
          zip_basename, script_name, name_in_zip=None)

     Create zip file at 'zip_dir' and 'zip_basename' with extension
     ‘zip’ which contains the files in 'script_name'.  'name_in_zip' is
     the archive name.  Return a tuple containing ‘(full path, full path
     of archive name)’.

 -- の関数: test.support.script_helper.make_pkg (pkg_dir,
          init_source='')

     Create a directory named 'pkg_dir' containing an ‘__init__’ file
     with 'init_source' as its contents.

 -- の関数: test.support.script_helper.make_zip_pkg (zip_dir,
          zip_basename, pkg_name, script_basename, source, depth=1,
          compiled=False)

     Create a zip package directory with a path of 'zip_dir' and
     'zip_basename' containing an empty ‘__init__’ file and a file
     'script_basename' containing the 'source'.  If 'compiled' is
     ‘True’, both source files will be compiled and added to the zip
     package.  Return a tuple of the full zip path and the archive name
     for the zip file.


File: python.info,  Node: test support bytecode_helper --- Support tools for testing correct bytecode generation,  Next: test support threading_helper --- Utilities for threading tests,  Prev: test support script_helper --- Utilities for the Python execution tests,  Up: 開発ツール

5.26.12 ‘test.support.bytecode_helper’ -- Support tools for testing correct bytecode generation
-----------------------------------------------------------------------------------------------

The *note test.support.bytecode_helper: ce. module provides support for
testing and inspecting bytecode generation.

Added in version 3.9.

The module defines the following class:

 -- クラス: test.support.bytecode_helper.BytecodeTestCase
          (unittest.TestCase)

     This class has custom assertion methods for inspecting bytecode.

 -- メソッド: BytecodeTestCase.get_disassembly_as_string (co)

     Return the disassembly of 'co' as string.

 -- メソッド: BytecodeTestCase.assertInBytecode (x, opname,
          argval=_UNSPECIFIED)

     Return instr if 'opname' is found, otherwise throws *note
     AssertionError: 675.

 -- メソッド: BytecodeTestCase.assertNotInBytecode (x, opname,
          argval=_UNSPECIFIED)

     Throws *note AssertionError: 675. if 'opname' is found.


File: python.info,  Node: test support threading_helper --- Utilities for threading tests,  Next: test support os_helper --- Utilities for os tests,  Prev: test support bytecode_helper --- Support tools for testing correct bytecode generation,  Up: 開発ツール

5.26.13 ‘test.support.threading_helper’ -- Utilities for threading tests
------------------------------------------------------------------------

The *note test.support.threading_helper: d3. module provides support for
threading tests.

Added in version 3.10.

 -- の関数: test.support.threading_helper.join_thread (thread,
          timeout=None)

     Join a 'thread' within 'timeout'.  Raise an *note AssertionError:
     675. if thread is still alive after 'timeout' seconds.

 -- の関数: @test.support.threading_helper.reap_threads

     Decorator to ensure the threads are cleaned up even if the test
     fails.

 -- の関数: test.support.threading_helper.start_threads (threads,
          unlock=None)

     Context manager to start 'threads', which is a sequence of threads.
     'unlock' is a function called after the threads are started, even
     if an exception was raised; an example would be *note
     threading.Event.set(): 2fca.  ‘start_threads’ will attempt to join
     the started threads upon exit.

 -- の関数: test.support.threading_helper.threading_cleanup
          (*original_values)

     Cleanup up threads not specified in 'original_values'.  Designed to
     emit a warning if a test leaves running threads in the background.

 -- の関数: test.support.threading_helper.threading_setup ()

     Return current thread count and copy of dangling threads.

 -- の関数: test.support.threading_helper.wait_threads_exit
          (timeout=None)

     Context manager to wait until all threads created in the ‘with’
     statement exit.

 -- の関数: test.support.threading_helper.catch_threading_exception ()

     Context manager catching *note threading.Thread: 91a. exception
     using *note threading.excepthook(): 816.

     Attributes set when an exception is caught:

        * ‘exc_type’

        * ‘exc_value’

        * ‘exc_traceback’

        * ‘thread’

     See *note threading.excepthook(): 816. documentation.

     These attributes are deleted at the context manager exit.

     使い方:

          with threading_helper.catch_threading_exception() as cm:
              # code spawning a thread which raises an exception
              ...

              # check the thread exception, use cm attributes:
              # exc_type, exc_value, exc_traceback, thread
              ...

          # exc_type, exc_value, exc_traceback, thread attributes of cm no longer
          # exists at this point
          # (to avoid reference cycles)

     Added in version 3.8.


File: python.info,  Node: test support os_helper --- Utilities for os tests,  Next: test support import_helper --- Utilities for import tests,  Prev: test support threading_helper --- Utilities for threading tests,  Up: 開発ツール

5.26.14 ‘test.support.os_helper’ -- Utilities for os tests
----------------------------------------------------------

The *note test.support.os_helper: d0. module provides support for os
tests.

Added in version 3.10.

 -- データ: test.support.os_helper.FS_NONASCII

     *note os.fsencode(): c23. でエンコードできる 非 ASCII 文字。

 -- データ: test.support.os_helper.SAVEDCWD

     *note os.getcwd(): 1503. に設定されます。

 -- データ: test.support.os_helper.TESTFN

     テンポラリファイルの名前として安全に利用できる名前に設定されます。
     作成した一時ファイルは全て閉じ、unlink (削除) しなければなりません
     。

 -- データ: test.support.os_helper.TESTFN_NONASCII

     Set to a filename containing the *note FS_NONASCII: 402e.
     character, if it exists.  This guarantees that if the filename
     exists, it can be encoded and decoded with the default filesystem
     encoding.  This allows tests that require a non-ASCII filename to
     be easily skipped on platforms where they can't work.

 -- データ: test.support.os_helper.TESTFN_UNENCODABLE

     strictモードのファイルシステムエンコーディングでエンコードできない
     ファイル名（str型）に設定します。そのようなファイル名を生成できない
     場合は、 ‘None’ になる可能性があります。

 -- データ: test.support.os_helper.TESTFN_UNDECODABLE

     strictモードのファイルシステムエンコーディングでデコードできないフ
     ァイル名（bytes型）に設定します。そのようなファイル名を生成できない
     場合は、 ‘None’ になる可能性があります。

 -- データ: test.support.os_helper.TESTFN_UNICODE

     非 ASCII 名を一時ファイルに設定します。

 -- クラス: test.support.os_helper.EnvironmentVarGuard

     一時的に環境変数をセット・アンセットするためのクラスです。このクラ
     スのインスタンスはコンテキストマネージャーとして利用されます。また
     、 ‘os.environ’ に対する参照・更新を行う完全な辞書のインターフェー
     スを持ちます。コンテキストマネージャーが終了した時、このインスタン
     ス経由で環境変数へ行った全ての変更はロールバックされます。

     バージョン 3.1 で変更: 辞書のインターフェースを追加しました。

 -- クラス: test.support.os_helper.FakePath (path)

     Simple *note path-like object: 280.  It implements the *note
     __fspath__(): c20. method which just returns the 'path' argument.
     If 'path' is an exception, it will be raised in ‘__fspath__()’.

 -- メソッド: EnvironmentVarGuard.set (envvar, value)

     一時的に、 ‘envvar’ を ‘value’ にセットします。

 -- メソッド: EnvironmentVarGuard.unset (envvar)

     一時的に ‘envvar’ をアンセットします。

 -- の関数: test.support.os_helper.can_symlink ()

     OS がシンボリックリンクをサポートする場合 ‘True’ を返し、その他の場
     合は ‘False’ を返します。

 -- の関数: test.support.os_helper.can_xattr ()

     Return ‘True’ if the OS supports xattr, ‘False’ otherwise.

 -- の関数: test.support.os_helper.change_cwd (path, quiet=False)

     カレントディレクトリを一時的に 'path' に変更し与えるコンテキストマ
     ネージャです。

     'quiet' が ‘False’ の場合、コンテキストマネージャはエラーが起きると
     例外を送出します。 それ以外の場合には、警告を出すだけでカレントディ
     レクトリは同じままにしておきます。

 -- の関数: test.support.os_helper.create_empty_file (filename)

     Create an empty file with 'filename'.  If it already exists,
     truncate it.

 -- の関数: test.support.os_helper.fd_count ()

     Count the number of open file descriptors.

 -- の関数: test.support.os_helper.fs_is_case_insensitive (directory)

     Return ‘True’ if the file system for 'directory' is
     case-insensitive.

 -- の関数: test.support.os_helper.make_bad_fd ()

     一時ファイルを開いた後に閉じ、そのファイル記述子を返すことで無効な
     記述子を作成します。

 -- の関数: test.support.os_helper.rmdir (filename)

     Call *note os.rmdir(): 10c4. on 'filename'.  On Windows platforms,
     this is wrapped with a wait loop that checks for the existence of
     the file, which is needed due to antivirus programs that can hold
     files open and prevent deletion.

 -- の関数: test.support.os_helper.rmtree (path)

     Call *note shutil.rmtree(): 2d8. on 'path' or call *note
     os.lstat(): 46e. and *note os.rmdir(): 10c4. to remove a path and
     its contents.  As with *note rmdir(): 403f, on Windows platforms
     this is wrapped with a wait loop that checks for the existence of
     the files.

 -- の関数: @test.support.os_helper.skip_unless_symlink

     シンボリックリンクのサポートが必要なテストを実行することを表すデコ
     レータ。

 -- の関数: @test.support.os_helper.skip_unless_xattr

     A decorator for running tests that require support for xattr.

 -- の関数: test.support.os_helper.temp_cwd (name='tempcwd',
          quiet=False)

     一時的に新しいディレクトリを作成し、カレントディレクトリ (current
     working directory, CWD) を変更するコンテキストマネージャです。

     一時的にカレントディレクトリを変更する前に、カレントディレクトリに
     'name' という名前のディレクトリを作成します。 'name' が ‘None’ の場
     合は、一時ディレクトリは *note tempfile.mkdtemp(): 200. を使って作
     成されます。

     'quiet' が ‘False’ でカレントディレクトリの作成や変更ができない場合
     、例外を送出します。 それ以外の場合には、警告を出すだけで元のカレン
     トディレクトリが使われます。

 -- の関数: test.support.os_helper.temp_dir (path=None, quiet=False)

     'path' に一時ディレクトリを作成し与えるコンテキストマネージャです。

     If 'path' is ‘None’, the temporary directory is created using *note
     tempfile.mkdtemp(): 200.  If 'quiet' is ‘False’, the context
     manager raises an exception on error.  Otherwise, if 'path' is
     specified and cannot be created, only a warning is issued.

 -- の関数: test.support.os_helper.temp_umask (umask)

     一時的にプロセスの umask を設定するコンテキストマネージャ。

 -- の関数: test.support.os_helper.unlink (filename)

     Call *note os.unlink(): 10c6. on 'filename'.  As with *note
     rmdir(): 403f, on Windows platforms, this is wrapped with a wait
     loop that checks for the existence of the file.


File: python.info,  Node: test support import_helper --- Utilities for import tests,  Next: test support warnings_helper --- Utilities for warnings tests,  Prev: test support os_helper --- Utilities for os tests,  Up: 開発ツール

5.26.15 ‘test.support.import_helper’ -- Utilities for import tests
------------------------------------------------------------------

The *note test.support.import_helper: cf. module provides support for
import tests.

Added in version 3.10.

 -- の関数: test.support.import_helper.forget (module_name)

     モジュール名 'module_name' を ‘sys.modules’ から取り除き、モジュー
     ルのバイトコンパイル済みファイルを全て削除します。

 -- の関数: test.support.import_helper.import_fresh_module (name,
          fresh=(), blocked=(), deprecated=False)

     この関数は、 'name' で指定された Python モジュールを、インポート前
     に ‘sys.modules’ から削除することで新規にインポートしてそのコピーを
     返します。 ‘reload()’ 関数と違い、もとのモジュールはこの操作によっ
     て影響をうけません。

     'fresh' は、同じようにインポート前に ‘sys.modules’ から削除されるモ
     ジュール名の iterable です。

     'blocked' もモジュール名のイテラブルで、インポート中にモジュールキ
     ャッシュ内でその名前を ‘None’ に置き換えることで、そのモジュールを
     インポートしようとすると *note ImportError: 3f2. を発生させます。

     指定されたモジュールと 'fresh' や 'blocked' 引数内のモジュール名は
     インポート前に保存され、フレッシュなインポートが完了したら
     ‘sys.modules’ に戻されます。

     'deprecated' が ‘True’ の場合、インポート中はモジュールとパッケージ
     の廃止メッセージが抑制されます。

     指定したモジュールがインポートできなかった場合に、この関数は *note
     ImportError: 3f2. を送出します。

     使用例:

          # Get copies of the warnings module for testing without affecting the
          # version being used by the rest of the test suite. One copy uses the
          # C implementation, the other is forced to use the pure Python fallback
          # implementation
          py_warnings = import_fresh_module('warnings', blocked=['_warnings'])
          c_warnings = import_fresh_module('warnings', fresh=['_warnings'])

     Added in version 3.1.

 -- の関数: test.support.import_helper.import_module (name,
          deprecated=False, *, required_on=())

     この関数は 'name' で指定されたモジュールをインポートして返します。
     通常のインポートと異なり、この関数はモジュールをインポートできなか
     った場合に *note unittest.SkipTest: fb1. 例外を発生させます。

     Module and package deprecation messages are suppressed during this
     import if 'deprecated' is ‘True’.  If a module is required on a
     platform but optional for others, set 'required_on' to an iterable
     of platform prefixes which will be compared against *note
     sys.platform: a5b.

     Added in version 3.1.

 -- の関数: test.support.import_helper.modules_setup ()

     Return a copy of *note sys.modules: 18d6.

 -- の関数: test.support.import_helper.modules_cleanup (oldmodules)

     Remove modules except for 'oldmodules' and ‘encodings’ in order to
     preserve internal cache.

 -- の関数: test.support.import_helper.unload (name)

     ‘sys.modules’ から 'name' を削除します。

 -- の関数: test.support.import_helper.make_legacy_pyc (source)

     Move a PEP 3147(1)/ PEP 488(2) pyc file to its legacy pyc location
     and return the file system path to the legacy pyc file.  The
     'source' value is the file system path to the source file.  It does
     not need to exist, however the PEP 3147/488 pyc file must exist.

 -- クラス: test.support.import_helper.CleanImport (*module_names)

     A context manager to force import to return a new module reference.
     This is useful for testing module-level behaviors, such as the
     emission of a *note DeprecationWarning: 18a. on import.  Example
     usage:

          with CleanImport('foo'):
              importlib.import_module('foo')  # New reference.

 -- クラス: test.support.import_helper.DirsOnSysPath (*paths)

     A context manager to temporarily add directories to *note sys.path:
     38e.

     This makes a copy of *note sys.path: 38e, appends any directories
     given as positional arguments, then reverts *note sys.path: 38e. to
     the copied settings when the context ends.

     Note that 'all' *note sys.path: 38e. modifications in the body of
     the context manager, including replacement of the object, will be
     reverted at the end of the block.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3147/

   (2) https://peps.python.org/pep-0488/


File: python.info,  Node: test support warnings_helper --- Utilities for warnings tests,  Prev: test support import_helper --- Utilities for import tests,  Up: 開発ツール

5.26.16 ‘test.support.warnings_helper’ -- Utilities for warnings tests
----------------------------------------------------------------------

The *note test.support.warnings_helper: d4. module provides support for
warnings tests.

Added in version 3.10.

 -- の関数: test.support.warnings_helper.ignore_warnings (*, category)

     Suppress warnings that are instances of 'category', which must be
     *note Warning: 220f. or a subclass.  Roughly equivalent to *note
     warnings.catch_warnings(): 550. with *note
     warnings.simplefilter('ignore', category=category): 68d.  For
     example:

          @warning_helper.ignore_warnings(category=DeprecationWarning)
          def test_suppress_warning():
              # do something

     Added in version 3.8.

 -- の関数: test.support.warnings_helper.check_no_resource_warning
          (testcase)

     Context manager to check that no *note ResourceWarning: 225. was
     raised.  You must remove the object which may emit *note
     ResourceWarning: 225. before the end of the context manager.

 -- の関数: test.support.warnings_helper.check_syntax_warning (testcase,
          statement, errtext='', *, lineno=1, offset=None)

     Test for syntax warning in 'statement' by attempting to compile
     'statement'.  Test also that the *note SyntaxWarning: 432. is
     emitted only once, and that it will be converted to a *note
     SyntaxError: 172. when turned into error.  'testcase' is the *note
     unittest: ef. instance for the test.  'errtext' is the regular
     expression which should match the string representation of the
     emitted *note SyntaxWarning: 432. and raised *note SyntaxError:
     172.  If 'lineno' is not ‘None’, compares to the line of the
     warning and exception.  If 'offset' is not ‘None’, compares to the
     offset of the exception.

     Added in version 3.8.

 -- の関数: test.support.warnings_helper.check_warnings (*filters,
          quiet=True)

     A convenience wrapper for *note warnings.catch_warnings(): 550.
     that makes it easier to test that a warning was correctly raised.
     It is approximately equivalent to calling
     ‘warnings.catch_warnings(record=True)’ with *note
     warnings.simplefilter(): 68d. set to ‘always’ and with the option
     to automatically validate the results that are recorded.

     ‘check_warnings’ は ‘("message regexp", WarningCategory)’ の形をし
     た 2要素タプルを位置引数として受け取ります。1つ以上の 'filters' が
     与えられた場合や、オプションのキーワード引数 'quiet' が ‘False’ の
     場合、警告が期待通りであるかどうかをチェックします。指定された各
     filter は最低でも1回は囲われたコード内で発生した警告とマッチしなけ
     ればテストが失敗しますし、指定されたどの filter ともマッチしない警
     告が発生してもテストが失敗します。前者のチェックを無効にするには、
     'quiet' を ‘True’ にします。

     引数が1つもない場合、デフォルトでは次のようになります:

          check_warnings(("", Warning), quiet=True)

     この場合、全ての警告は補足され、エラーは発生しません。

     コンテキストマネージャーに入る時、 ‘WarningRecorder’ インスタンスが
     返されます。このレコーダーオブジェクトの *note warnings: fa. 属性か
     ら、 *note catch_warnings(): 550. から得られる警告のリストを取得す
     ることができます。便利さのために、レコーダーオブジェクトから直接、
     一番最近に発生した警告を表すオブジェクトの属性にアクセスできます(以
     下にある例を参照してください)。警告が1つも発生しなかった場合、それ
     らの全ての属性は ‘None’ を返します。

     レコーダーオブジェクトの ‘reset()’ メソッドは警告リストをクリアしま
     す。

     コンテキストマネージャーは次のようにして使います:

          with check_warnings(("assertion is always true", SyntaxWarning),
                              ("", UserWarning)):
              exec('assert(False, "Hey!")')
              warnings.warn(UserWarning("Hide me!"))

     この場合、どちらの警告も発生しなかった場合や、それ以外の警告が発生
     した場合は、 *note check_warnings(): 4054. はエラーを発生させます。

     警告が発生したかどうかだけでなく、もっと詳しいチェックが必要な場合
     は、次のようなコードになります:

          with check_warnings(quiet=True) as w:
              warnings.warn("foo")
              assert str(w.args[0]) == "foo"
              warnings.warn("bar")
              assert str(w.args[0]) == "bar"
              assert str(w.warnings[0].args[0]) == "foo"
              assert str(w.warnings[1].args[0]) == "bar"
              w.reset()
              assert len(w.warnings) == 0

     全ての警告をキャプチャし、テストコードがその警告を直接テストします
     。

     バージョン 3.2 で変更: 新しいオプション引数 'filters' と 'quiet'

 -- クラス: test.support.warnings_helper.WarningsRecorder

     ユニットテスト時に warning を記録するためのクラスです。上の、 *note
     check_warnings(): 4054. のドキュメントを参照してください。


File: python.info,  Node: デバッグとプロファイル,  Next: ソフトウェア・パッケージと配布,  Prev: 開発ツール,  Up: Python 標準ライブラリ

5.27 デバッグとプロファイル
===========================

ここに含まれるライブラリは Python での開発を手助けするものです。デバッガ
を使うと、コードのステップ実行や、スタックフレームの解析、ブレークポイン
トの設定などができます。プロファイラはコードを実行して実行時間の詳細を提
供し、プログラムのボトルネックを特定できるようにします。

* Menu:

* 監査イベント表::
* bdb: bdb --- デバッガーフレームワーク. デバッガーフレームワーク
* faulthandler: faulthandler --- Python トレースバックをダンプする. Python トレースバックをダンプする
* pdb: pdb --- Python デバッガ. Python デバッガ
* Python プロファイラ::
* timeit: timeit --- 小さなコードスニペットの実行時間計測. 小さなコードスニペットの実行時間計測
* trace: trace --- Python 文実行のトレースと追跡. Python 文実行のトレースと追跡
* tracemalloc: tracemalloc --- メモリ割り当ての追跡. メモリ割り当ての追跡


File: python.info,  Node: 監査イベント表,  Next: bdb --- デバッガーフレームワーク,  Up: デバッグとプロファイル

5.27.1 監査イベント表
---------------------

この表は、 CPython ランタイムと標準ライブラリ全体で *note sys.audit():
151a. または *note PySys_Audit(): 348. の呼び出しによって送出されるすべ
てのイベントを含んでいます。これらの呼び出しは、 3.8 以降に追加されまし
た ( PEP 578(1) を参照) 。

これらのイベントの処理についての情報は *note sys.addaudithook(): 405a. と
*note PySys_AddAuditHook(): 405b. を参照してください。

'CPython 実装の詳細:' この表は CPython ドキュメントから生成されており、
他の実装により送出されるイベントを表示していない可能性があります。実際に
送出されるイベントは、ランタイム固有のドキュメントを参照してください。

Audit event                        Arguments                                                   References
                                                                                               
-------------------------------------------------------------------------------------------------------------------
                                                                                               
_thread.start_new_thread           ‘function’, ‘args’, ‘kwargs’                                *note [1]: 405c.
                                                                                               
                                                                                               
array.__new__                      ‘typecode’, ‘initializer’                                   *note [1]: 185.
                                                                                               
                                                                                               
builtins.breakpoint                ‘breakpointhook’                                            *note [1]: 215.
                                                                                               
                                                                                               
builtins.id                        ‘id’                                                        *note [1]: 13ca.
                                                                                               
                                                                                               
builtins.input                     ‘prompt’                                                    *note [1]: 12a6.
                                                                                               
                                                                                               
builtins.input/result              ‘result’                                                    *note [1]: 12a6.
                                                                                               
                                                                                               
code.__new__                       ‘code’, ‘filename’, ‘name’, ‘argcount’,                     *note [1]: 2c0.
                                   ‘posonlyargcount’, ‘kwonlyargcount’, ‘nlocals’,             
                                   ‘stacksize’, ‘flags’
                                   
                                                                                               
compile                            ‘source’, ‘filename’                                        *note [1]: 177.
                                                                                               
                                                                                               
cpython.PyInterpreterState_Clear                                                               *note [1]: 405d.
                                                                                               
                                                                                               
cpython.PyInterpreterState_New                                                                 *note [1]: 405e.
                                                                                               
                                                                                               
cpython._PySys_ClearAuditHooks                                                                 *note [1]: ce3.
                                                                                               
                                                                                               
cpython.run_command                ‘command’                                                   *note [1]: 5aa.
                                                                                               
                                                                                               
cpython.run_file                   ‘filename’                                                  *note [1]: 405f.
                                                                                               
                                                                                               
cpython.run_interactivehook        ‘hook’                                                      *note [1]: f94.
                                                                                               
                                                                                               
cpython.run_module                 ‘module-name’                                               *note [1]: 5ab.
                                                                                               
                                                                                               
cpython.run_startup                ‘filename’                                                  *note [1]: f95.
                                                                                               
                                                                                               
cpython.run_stdin                                                                              *note [1]: 4060.*note [2]: 4061.*note [3]: 4062.
                                                                                               
                                                                                               
ctypes.addressof                   ‘obj’                                                       *note [1]: 2f80.
                                                                                               
                                                                                               
ctypes.call_function               ‘func_pointer’, ‘arguments’                                 *note [1]: 2f78.
                                                                                               
                                                                                               
ctypes.cdata                       ‘address’                                                   *note [1]: 2f92.
                                                                                               
                                                                                               
ctypes.cdata/buffer                ‘pointer’, ‘size’, ‘offset’                                 *note [1]: 2f90.*note [2]: 2f91.
                                                                                               
                                                                                               
ctypes.create_string_buffer        ‘init’, ‘size’                                              *note [1]: 2f35.
                                                                                               
                                                                                               
ctypes.create_unicode_buffer       ‘init’, ‘size’                                              *note [1]: 193a.
                                                                                               
                                                                                               
ctypes.dlopen                      ‘name’                                                      *note [1]: 2f76.
                                                                                               
                                                                                               
ctypes.dlsym                       ‘library’, ‘name’                                           *note [1]: 2f76.
                                                                                               
                                                                                               
ctypes.dlsym/handle                ‘handle’, ‘name’                                            *note [1]: 2f76.
                                                                                               
                                                                                               
ctypes.get_errno                                                                               *note [1]: 2f70.
                                                                                               
                                                                                               
ctypes.get_last_error                                                                          *note [1]: 2f72.
                                                                                               
                                                                                               
ctypes.set_errno                   ‘errno’                                                     *note [1]: 2f71.
                                                                                               
                                                                                               
ctypes.set_exception               ‘code’                                                      *note [1]: 2f78.
                                                                                               
                                                                                               
ctypes.set_last_error              ‘error’                                                     *note [1]: 2f73.
                                                                                               
                                                                                               
ctypes.string_at                   ‘ptr’, ‘size’                                               *note [1]: 2f89.
                                                                                               
                                                                                               
ctypes.wstring_at                  ‘ptr’, ‘size’                                               *note [1]: 2f8b.
                                                                                               
                                                                                               
ensurepip.bootstrap                ‘root’                                                      *note [1]: 4063.
                                                                                               
                                                                                               
exec                               ‘code_object’                                               *note [1]: 165.*note [2]: 164.
                                                                                               
                                                                                               
fcntl.fcntl                        ‘fd’, ‘cmd’, ‘arg’                                          *note [1]: 32f0.
                                                                                               
                                                                                               
fcntl.flock                        ‘fd’, ‘operation’                                           *note [1]: 4064.
                                                                                               
                                                                                               
fcntl.ioctl                        ‘fd’, ‘request’, ‘arg’                                      *note [1]: 141f.
                                                                                               
                                                                                               
fcntl.lockf                        ‘fd’, ‘cmd’, ‘len’, ‘start’, ‘whence’                       *note [1]: 1394.
                                                                                               
                                                                                               
ftplib.connect                     ‘self’, ‘host’, ‘port’                                      *note [1]: 3918.
                                                                                               
                                                                                               
ftplib.sendcmd                     ‘self’, ‘cmd’                                               *note [1]: 391d.*note [2]: 391e.
                                                                                               
                                                                                               
function.__new__                   ‘code’                                                      *note [1]: 850.
                                                                                               
                                                                                               
gc.get_objects                     ‘generation’                                                *note [1]: 7ce.
                                                                                               
                                                                                               
gc.get_referents                   ‘objs’                                                      *note [1]: 7d0.
                                                                                               
                                                                                               
gc.get_referrers                   ‘objs’                                                      *note [1]: 7cf.
                                                                                               
                                                                                               
glob.glob                          ‘pathname’, ‘recursive’                                     *note [1]: 27f.*note [2]: 7d2.
                                                                                               
                                                                                               
glob.glob/2                        ‘pathname’, ‘recursive’, ‘root_dir’, ‘dir_fd’               *note [1]: 27f.*note [2]: 7d2.
                                                                                               
                                                                                               
http.client.connect                ‘self’, ‘host’, ‘port’                                      *note [1]: 38fb.
                                                                                               
                                                                                               
http.client.send                   ‘self’, ‘data’                                              *note [1]: 3900.
                                                                                               
                                                                                               
imaplib.open                       ‘self’, ‘host’, ‘port’                                      *note [1]: 8d3.
                                                                                               
                                                                                               
imaplib.send                       ‘self’, ‘data’                                              *note [1]: 396f.
                                                                                               
                                                                                               
import                             ‘module’, ‘filename’, ‘sys.path’, ‘sys.meta_path’,          *note [1]: 5ac.
                                   ‘sys.path_hooks’                                            
                                   
                                                                                               
marshal.dumps                      ‘value’, ‘version’                                          *note [1]: 2811.
                                                                                               
                                                                                               
marshal.load                                                                                   *note [1]: 197e.
                                                                                               
                                                                                               
marshal.loads                      ‘bytes’                                                     *note [1]: 197e.
                                                                                               
                                                                                               
mmap.__new__                       ‘fileno’, ‘length’, ‘access’, ‘offset’                      *note [1]: 1ec.
                                                                                               
                                                                                               
msvcrt.get_osfhandle               ‘fd’                                                        *note [1]: 4065.
                                                                                               
                                                                                               
msvcrt.locking                     ‘fd’, ‘mode’, ‘nbytes’                                      *note [1]: 4066.
                                                                                               
                                                                                               
msvcrt.open_osfhandle              ‘handle’, ‘flags’                                           *note [1]: 4067.
                                                                                               
                                                                                               
object.__delattr__                 ‘obj’, ‘name’                                               *note [1]: 1e8e.
                                                                                               
                                                                                               
object.__getattr__                 ‘obj’, ‘name’                                               *note [1]: ba0.
                                                                                               
                                                                                               
object.__setattr__                 ‘obj’, ‘name’, ‘value’                                      *note [1]: 1e8d.
                                                                                               
                                                                                               
open                               ‘path’, ‘mode’, ‘flags’                                     *note [1]: 4e5.*note [2]: 4e6.*note [3]: d5f.
                                                                                               
                                                                                               
os.add_dll_directory               ‘path’                                                      *note [1]: 9b8.
                                                                                               
                                                                                               
os.chdir                           ‘path’                                                      *note [1]: 5d8.*note [2]: d56.
                                                                                               
                                                                                               
os.chflags                         ‘path’, ‘flags’                                             *note [1]: 10be.*note [2]: 2ada.
                                                                                               
                                                                                               
os.chmod                           ‘path’, ‘mode’, ‘dir_fd’                                    *note [1]: 1fc.*note [2]: 1fd.*note [3]: 1fb.
                                                                                               
                                                                                               
os.chown                           ‘path’, ‘uid’, ‘gid’, ‘dir_fd’                              *note [1]: 10bf.*note [2]: d57.*note [3]: 2adb.
                                                                                               
                                                                                               
os.exec                            ‘path’, ‘args’, ‘env’                                       *note [1]: 2b17.
                                                                                               
                                                                                               
os.fork                                                                                        *note [1]: 17c.
                                                                                               
                                                                                               
os.forkpty                                                                                     *note [1]: 17d.
                                                                                               
                                                                                               
os.fwalk                           ‘top’, ‘topdown’, ‘onerror’, ‘follow_symlinks’, ‘dir_fd’    *note [1]: b29.
                                                                                               
                                                                                               
os.getxattr                        ‘path’, ‘attribute’                                         *note [1]: 10d7.
                                                                                               
                                                                                               
os.kill                            ‘pid’, ‘sig’                                                *note [1]: 132f.
                                                                                               
                                                                                               
os.killpg                          ‘pgid’, ‘sig’                                               *note [1]: 1941.
                                                                                               
                                                                                               
os.link                            ‘src’, ‘dst’, ‘src_dir_fd’, ‘dst_dir_fd’                    *note [1]: 10c0.
                                                                                               
                                                                                               
os.listdir                         ‘path’                                                      *note [1]: 10cd.
                                                                                               
                                                                                               
os.listdrives                                                                                  *note [1]: 46a.
                                                                                               
                                                                                               
os.listmounts                      ‘volume’                                                    *note [1]: 46c.
                                                                                               
                                                                                               
os.listvolumes                                                                                 *note [1]: 46b.
                                                                                               
                                                                                               
os.listxattr                       ‘path’                                                      *note [1]: 10d8.
                                                                                               
                                                                                               
os.lockf                           ‘fd’, ‘cmd’, ‘len’                                          *note [1]: 10e6.
                                                                                               
                                                                                               
os.mkdir                           ‘path’, ‘mode’, ‘dir_fd’                                    *note [1]: 1ff.*note [2]: 1fe.
                                                                                               
                                                                                               
os.posix_spawn                     ‘path’, ‘argv’, ‘env’                                       *note [1]: 201.*note [2]: 199a.
                                                                                               
                                                                                               
os.putenv                          ‘key’, ‘value’                                              *note [1]: 8ea.
                                                                                               
                                                                                               
os.remove                          ‘path’, ‘dir_fd’                                            *note [1]: 10c1.*note [2]: 2adf.*note [3]: 10c6.
                                                                                               
                                                                                               
os.removexattr                     ‘path’, ‘attribute’                                         *note [1]: 10d9.
                                                                                               
                                                                                               
os.rename                          ‘src’, ‘dst’, ‘src_dir_fd’, ‘dst_dir_fd’                    *note [1]: 10c2.*note [2]: 2ae0.*note [3]: 10c3.
                                                                                               
                                                                                               
os.rmdir                           ‘path’, ‘dir_fd’                                            *note [1]: 10c4.
                                                                                               
                                                                                               
os.scandir                         ‘path’                                                      *note [1]: a2d.
                                                                                               
                                                                                               
os.setxattr                        ‘path’, ‘attribute’, ‘value’, ‘flags’                       *note [1]: 10da.
                                                                                               
                                                                                               
os.spawn                           ‘mode’, ‘path’, ‘args’, ‘env’                               *note [1]: 1699.
                                                                                               
                                                                                               
os.startfile                       ‘path’, ‘operation’                                         *note [1]: 1836.
                                                                                               
                                                                                               
os.startfile/2                     ‘path’, ‘operation’, ‘arguments’, ‘cwd’, ‘show_cmd’         *note [1]: 1836.
                                                                                               
                                                                                               
os.symlink                         ‘src’, ‘dst’, ‘dir_fd’                                      *note [1]: 10c5.
                                                                                               
                                                                                               
os.system                          ‘command’                                                   *note [1]: 1402.
                                                                                               
                                                                                               
os.truncate                        ‘fd’, ‘length’                                              *note [1]: d5c.*note [2]: e09.
                                                                                               
                                                                                               
os.unsetenv                        ‘key’                                                       *note [1]: 8e9.
                                                                                               
                                                                                               
os.utime                           ‘path’, ‘times’, ‘ns’, ‘dir_fd’                             *note [1]: 10c7.
                                                                                               
                                                                                               
os.walk                            ‘top’, ‘topdown’, ‘onerror’, ‘followlinks’                  *note [1]: 476.
                                                                                               
                                                                                               
pathlib.Path.glob                  ‘self’, ‘pattern’                                           *note [1]: 20e.
                                                                                               
                                                                                               
pathlib.Path.rglob                 ‘self’, ‘pattern’                                           *note [1]: 20f.
                                                                                               
                                                                                               
pdb.Pdb                                                                                        *note [1]: 8f0.
                                                                                               
                                                                                               
pickle.find_class                  ‘module’, ‘name’                                            *note [1]: 27ef.
                                                                                               
                                                                                               
poplib.connect                     ‘self’, ‘host’, ‘port’                                      *note [1]: 8f2.*note [2]: 8f3.
                                                                                               
                                                                                               
poplib.putline                     ‘self’, ‘line’                                              *note [1]: 8f2.*note [2]: 8f3.
                                                                                               
                                                                                               
pty.spawn                          ‘argv’                                                      *note [1]: f4f.
                                                                                               
                                                                                               
resource.prlimit                   ‘pid’, ‘resource’, ‘limits’                                 *note [1]: f56.
                                                                                               
                                                                                               
resource.setrlimit                 ‘resource’, ‘limits’                                        *note [1]: 4007.
                                                                                               
                                                                                               
setopencodehook                                                                                *note [1]: 1690.
                                                                                               
                                                                                               
shutil.chown                       ‘path’, ‘user’, ‘group’                                     *note [1]: 221.
                                                                                               
                                                                                               
shutil.copyfile                    ‘src’, ‘dst’                                                *note [1]: a28.*note [2]: a29.*note [3]: a27.
                                                                                               
                                                                                               
shutil.copymode                    ‘src’, ‘dst’                                                *note [1]: a28.*note [2]: 160f.
                                                                                               
                                                                                               
shutil.copystat                    ‘src’, ‘dst’                                                *note [1]: a29.*note [2]: 1101.
                                                                                               
                                                                                               
shutil.copytree                    ‘src’, ‘dst’                                                *note [1]: 9f7.
                                                                                               
                                                                                               
shutil.make_archive                ‘base_name’, ‘format’, ‘root_dir’, ‘base_dir’               *note [1]: 47f.
                                                                                               
                                                                                               
shutil.move                        ‘src’, ‘dst’                                                *note [1]: a2a.
                                                                                               
                                                                                               
shutil.rmtree                      ‘path’, ‘dir_fd’                                            *note [1]: 2d8.
                                                                                               
                                                                                               
shutil.unpack_archive              ‘filename’, ‘extract_dir’, ‘format’                         *note [1]: 438.
                                                                                               
                                                                                               
signal.pthread_kill                ‘thread_id’, ‘signalnum’                                    *note [1]: 1104.
                                                                                               
                                                                                               
smtplib.connect                    ‘self’, ‘host’, ‘port’                                      *note [1]: 1935.
                                                                                               
                                                                                               
smtplib.send                       ‘self’, ‘data’                                              *note [1]: 8fb.
                                                                                               
                                                                                               
socket.__new__                     ‘self’, ‘family’, ‘type’, ‘protocol’                        *note [1]: d6e.
                                                                                               
                                                                                               
socket.bind                        ‘self’, ‘address’                                           *note [1]: 1093.
                                                                                               
                                                                                               
socket.connect                     ‘self’, ‘address’                                           *note [1]: d70.*note [2]: 14e2.
                                                                                               
                                                                                               
socket.getaddrinfo                 ‘host’, ‘port’, ‘family’, ‘type’, ‘protocol’                *note [1]: 16bd.
                                                                                               
                                                                                               
socket.gethostbyaddr               ‘ip_address’                                                *note [1]: 1837.
                                                                                               
                                                                                               
socket.gethostbyname               ‘hostname’                                                  *note [1]: 32e5.*note [2]: 1838.
                                                                                               
                                                                                               
socket.gethostname                                                                             *note [1]: 2a84.
                                                                                               
                                                                                               
socket.getnameinfo                 ‘sockaddr’                                                  *note [1]: 1629.
                                                                                               
                                                                                               
socket.getservbyname               ‘servicename’, ‘protocolname’                               *note [1]: 32e7.
                                                                                               
                                                                                               
socket.getservbyport               ‘port’, ‘protocolname’                                      *note [1]: 32e8.
                                                                                               
                                                                                               
socket.sendmsg                     ‘self’, ‘address’                                           *note [1]: 443.
                                                                                               
                                                                                               
socket.sendto                      ‘self’, ‘address’                                           *note [1]: d76.
                                                                                               
                                                                                               
socket.sethostname                 ‘name’                                                      *note [1]: 110e.
                                                                                               
                                                                                               
sqlite3.connect                    ‘database’                                                  *note [1]: 288.
                                                                                               
                                                                                               
sqlite3.connect/handle             ‘connection_handle’                                         *note [1]: 288.
                                                                                               
                                                                                               
sqlite3.enable_load_extension      ‘connection’, ‘enabled’                                     *note [1]: 809.
                                                                                               
                                                                                               
sqlite3.load_extension             ‘connection’, ‘path’                                        *note [1]: 484.
                                                                                               
                                                                                               
subprocess.Popen                   ‘executable’, ‘args’, ‘cwd’, ‘env’                          *note [1]: 17e.
                                                                                               
                                                                                               
sys._current_exceptions                                                                        *note [1]: 48e.
                                                                                               
                                                                                               
sys._current_frames                                                                            *note [1]: 13da.
                                                                                               
                                                                                               
sys._getframe                      ‘frame’                                                     *note [1]: 6ac.
                                                                                               
                                                                                               
sys._getframemodulename            ‘depth’                                                     *note [1]: 16da.
                                                                                               
                                                                                               
sys.addaudithook                                                                               *note [1]: 405b.*note [2]: 405a.
                                                                                               
                                                                                               
sys.excepthook                     ‘hook’, ‘type’, ‘value’, ‘traceback’                        *note [1]: 7d6.
                                                                                               
                                                                                               
sys.set_asyncgen_hooks_finalizer                                                               *note [1]: 158a.
                                                                                               
                                                                                               
sys.set_asyncgen_hooks_firstiter                                                               *note [1]: 158a.
                                                                                               
                                                                                               
sys.setprofile                                                                                 *note [1]: 14a8.
                                                                                               
                                                                                               
sys.settrace                                                                                   *note [1]: 14a9.
                                                                                               
                                                                                               
sys.unraisablehook                 ‘hook’, ‘unraisable’                                        *note [1]: 1d8.
                                                                                               
                                                                                               
syslog.closelog                                                                                *note [1]: 50a.
                                                                                               
                                                                                               
syslog.openlog                     ‘ident’, ‘logoption’, ‘facility’                            *note [1]: 509.
                                                                                               
                                                                                               
syslog.setlogmask                  ‘maskpri’                                                   *note [1]: 4068.
                                                                                               
                                                                                               
syslog.syslog                      ‘priority’, ‘message’                                       *note [1]: 50b.
                                                                                               
                                                                                               
tempfile.mkdtemp                   ‘fullpath’                                                  *note [1]: 1205.*note [2]: 200.
                                                                                               
                                                                                               
tempfile.mkstemp                   ‘fullpath’                                                  *note [1]: 492.*note [2]: 27a3.*note [3]: 27a4.
                                                                                               
                                                                                               
time.sleep                         ‘secs’                                                      *note [1]: 4069.
                                                                                               
                                                                                               
urllib.Request                     ‘fullurl’, ‘data’, ‘headers’, ‘method’                      *note [1]: 273.
                                                                                               
                                                                                               
webbrowser.open                    ‘url’                                                       *note [1]: 37e2.
                                                                                               
                                                                                               
winreg.ConnectRegistry             ‘computer_name’, ‘key’                                      *note [1]: 406a.
                                                                                               
                                                                                               
winreg.CreateKey                   ‘key’, ‘sub_key’, ‘access’                                  *note [1]: 406b.*note [2]: 132a.
                                                                                               
                                                                                               
winreg.DeleteKey                   ‘key’, ‘sub_key’, ‘access’                                  *note [1]: 406c.*note [2]: 132b.
                                                                                               
                                                                                               
winreg.DeleteValue                 ‘key’, ‘value’                                              *note [1]: 406d.
                                                                                               
                                                                                               
winreg.DisableReflectionKey        ‘key’                                                       *note [1]: 132c.
                                                                                               
                                                                                               
winreg.EnableReflectionKey         ‘key’                                                       *note [1]: 132d.
                                                                                               
                                                                                               
winreg.EnumKey                     ‘key’, ‘index’                                              *note [1]: 406e.
                                                                                               
                                                                                               
winreg.EnumValue                   ‘key’, ‘index’                                              *note [1]: 406f.
                                                                                               
                                                                                               
winreg.ExpandEnvironmentStrings    ‘str’                                                       *note [1]: 13a0.
                                                                                               
                                                                                               
winreg.LoadKey                     ‘key’, ‘sub_key’, ‘file_name’                               *note [1]: 4070.
                                                                                               
                                                                                               
winreg.OpenKey                     ‘key’, ‘sub_key’, ‘access’                                  *note [1]: 4071.
                                                                                               
                                                                                               
winreg.OpenKey/result              ‘key’                                                       *note [1]: 406b.*note [2]: 132a.*note [3]: 4071.
                                                                                               
                                                                                               
winreg.PyHKEY.Detach               ‘key’                                                       *note [1]: 4072.
                                                                                               
                                                                                               
winreg.QueryInfoKey                ‘key’                                                       *note [1]: 4073.
                                                                                               
                                                                                               
winreg.QueryReflectionKey          ‘key’                                                       *note [1]: 132e.
                                                                                               
                                                                                               
winreg.QueryValue                  ‘key’, ‘sub_key’, ‘value_name’                              *note [1]: 4074.*note [2]: 4075.
                                                                                               
                                                                                               
winreg.SaveKey                     ‘key’, ‘file_name’                                          *note [1]: 4076.
                                                                                               
                                                                                               
winreg.SetValue                    ‘key’, ‘sub_key’, ‘type’, ‘value’                           *note [1]: 4077.*note [2]: 16f9.
                                                                                               

以下のイベントは内部で送出され、 CPython の公開 API に対応しません。

監査イベント                   引数
                               
-------------------------------------------------------------------------------
                               
_winapi.CreateFile             ‘file_name’, ‘desired_access’, ‘share_mode’,
                               ‘creation_disposition’,
                               ‘flags_and_attributes’
                               
                               
_winapi.CreateJunction         ‘src_path’, ‘dst_path’
                               
                               
_winapi.CreateNamedPipe        ‘name’, ‘open_mode’, ‘pipe_mode’
                               
                               
_winapi.CreatePipe

_winapi.CreateProcess          ‘application_name’, ‘command_line’,
                               ‘current_directory’
                               
                               
_winapi.OpenProcess            ‘process_id’, ‘desired_access’
                               
                               
_winapi.TerminateProcess       ‘handle’, ‘exit_code’
                               
                               
ctypes.PyObj_FromPtr           ‘obj’
                               

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0578/


File: python.info,  Node: bdb --- デバッガーフレームワーク,  Next: faulthandler --- Python トレースバックをダンプする,  Prev: 監査イベント表,  Up: デバッグとプロファイル

5.27.2 ‘bdb’ -- デバッガーフレームワーク
----------------------------------------

'ソースコード:' Lib/bdb.py(1)

__________________________________________________________________

*note bdb: b. モジュールは、ブレークポイントを設定したり、デバッガー経由
で実行を管理するような、基本的なデバッガー機能を提供します。

以下の例外が定義されています:

 -- 例外: bdb.BdbQuit

     *note Bdb: 12d0. クラスが、デバッガーを終了させるために投げる例外。

*note bdb: b. モジュールは2つのクラスを定義しています:

 -- クラス: bdb.Breakpoint (self, file, line, temporary=False,
          cond=None, funcname=None)

     このクラスはテンポラリブレークポイント、無視するカウント、無効化と
     再有効化、条件付きブレークポイントを実装しています。

     ブレークポイントは *note bpbynumber: 407c. という名前のリストで番号
     によりインデックスされ、 *note bplist: 407d. により ‘(file, line)’
     の形でインデックスされます。 *note bpbynumber: 407c. は *note
     Breakpoint: 407b. クラスのインスタンスを指しています。一方 *note
     bplist: 407d. は、同じ行に複数のブレークポイントが設定される場合が
     あるので、インスタンスのリストを指しています。

     ブレークポイントを作るとき、関連付けられる *note ファイル名: 407e.
     は正規化されていなければなりません。*note funcname: 407f. が定義さ
     れると、ブレークポイントの *note ヒット: 4080. はその関数の最初の行
     が実行されたときにカウントされます。*note 条件付き: 4081. ブレーク
     ポイントは毎回 *note ヒット: 4080. をカウントします。

     *note Breakpoint: 407b. インスタンスは以下のメソッドを持ちます:

      -- メソッド: deleteMe ()

          このブレークポイントをファイル/行に関連付けられたリストから削
          除します。このブレークポイントがその行に設定された最後のブレー
          クポイントだった場合、そのファイル/行に対するエントリ自体を削
          除します。

      -- メソッド: enable ()

          このブレークポイントを有効にします。

      -- メソッド: disable ()

          このブレークポイントを無効にします。

      -- メソッド: bpformat ()

          ブレークポイントに関する情報を持つ文字列をフォーマットして返し
          ます:

             * Breakpoint number.

             * Temporary status (del or keep).

             * File/line position.

             * Break condition.

             * Number of times to ignore.

             * Number of times hit.

          Added in version 3.2.

      -- メソッド: bpprint (out=None)

          ファイル 'out' に、またはそれが ‘None’ の場合は標準出力に、
          *note bpformat(): 4085. の出力を表示する。

     *note Breakpoint: 407b. インスタンスは以下の属性を持ちます:

      -- の属性: file

          File name of the *note Breakpoint: 407b.

      -- の属性: line

          Line number of the *note Breakpoint: 407b. within *note file:
          407e.

      -- の属性: temporary

          ‘True’ if a *note Breakpoint: 407b. at (file, line) is
          temporary.

      -- の属性: cond

          Condition for evaluating a *note Breakpoint: 407b. at (file,
          line).

      -- の属性: funcname

          Function name that defines whether a *note Breakpoint: 407b.
          is hit upon entering the function.

      -- の属性: enabled

          ‘True’ if *note Breakpoint: 407b. is enabled.

      -- の属性: bpbynumber

          Numeric index for a single instance of a *note Breakpoint:
          407b.

      -- の属性: bplist

          Dictionary of *note Breakpoint: 407b. instances indexed by
          (*note file: 407e, *note line: 4087.) tuples.

      -- の属性: ignore

          Number of times to ignore a *note Breakpoint: 407b.

      -- の属性: hits

          Count of the number of times a *note Breakpoint: 407b. has
          been hit.

 -- クラス: bdb.Bdb (skip=None)

     *note Bdb: 12d0. クラスは一般的なPythonデバッガーの基本クラスとして
     振舞います。

     このクラスはトレース機能の詳細を扱います。ユーザーとのインタラクシ
     ョンは、派生クラスが実装するべきです。標準ライブラリのデバッガクラ
     ス (*note pdb.Pdb: 8f0.) がその利用例です。

     'skip' 引数は、もし与えられたならグロブ形式のモジュール名パターンの
     iterable でなければなりません。デバッガはこれらのパターンのどれかに
     マッチするモジュールで発生したフレームにステップインしなくなります
     。フレームが特定のモジュールで発生したかどうかは、フレームのグロー
     バル変数の ‘__name__’ によって決定されます。

     バージョン 3.1 で変更: 'skip' パラメータが追加されました。

     以下の *note Bdb: 12d0. のメソッドは、通常オーバーライドする必要は
     ありません。

      -- メソッド: canonic (filename)

          Return canonical form of 'filename'.

          For real file names, the canonical form is an
          operating-system-dependent, *note case-normalized: 272a. *note
          absolute path: 12ea.  A 'filename' with angle brackets, such
          as ‘"<stdin>"’ generated in interactive mode, is returned
          unchanged.

      -- メソッド: reset ()

          Set the ‘botframe’, ‘stopframe’, ‘returnframe’ and *note
          quitting: 408d. attributes with values ready to start
          debugging.

      -- メソッド: trace_dispatch (frame, event, arg)

          この関数は、デバッグされているフレームのトレース関数としてイン
          ストールされます。戻り値は新しいトレース関数(殆どの場合はこの
          関数自身)です。

          デフォルトの実装は、実行しようとしている 'event' (文字列として
          渡されます) の種類に基づいてフレームのディスパッチ方法を決定し
          ます。'event' は次のうちのどれかです:

             * ‘"line"’: 新しい行を実行しようとしています。

             * ‘"call"’: 関数が呼び出されているか、別のコードブロックに
               入ります。

             * ‘"return"’: 関数か別のコードブロックからreturnしようとし
               ています。

             * ‘"exception"’: 例外が発生しました。

             * ‘"c_call"’: C関数を呼び出そうとしています。

             * ‘"c_return"’: C関数からreturnしました。

             * ‘"c_exception"’: C関数が例外を発生させました。

          Pythonのイベントに対しては、以下の専用の関数群が呼ばれます。
          Cのイベントに対しては何もしません。

          'arg' 引数は以前のイベントに依存します。

          トレース関数についてのより詳しい情報は、 *note sys.settrace():
          14a9. のドキュメントを参照してください。コードとフレームオブジ
          ェクトについてのより詳しい情報は、 *note 標準型の階層: 1e46. を
          参照してください。

      -- メソッド: dispatch_line (frame)

          If the debugger should stop on the current line, invoke the
          *note user_line(): 4090. method (which should be overridden in
          subclasses).  Raise a *note BdbQuit: 407a. exception if the
          *note quitting: 408d. flag is set (which can be set from *note
          user_line(): 4090.).  Return a reference to the *note
          trace_dispatch(): 408e. method for further tracing in that
          scope.

      -- メソッド: dispatch_call (frame, arg)

          If the debugger should stop on this function call, invoke the
          *note user_call(): 4092. method (which should be overridden in
          subclasses).  Raise a *note BdbQuit: 407a. exception if the
          *note quitting: 408d. flag is set (which can be set from *note
          user_call(): 4092.).  Return a reference to the *note
          trace_dispatch(): 408e. method for further tracing in that
          scope.

      -- メソッド: dispatch_return (frame, arg)

          If the debugger should stop on this function return, invoke
          the *note user_return(): 4094. method (which should be
          overridden in subclasses).  Raise a *note BdbQuit: 407a.
          exception if the *note quitting: 408d. flag is set (which can
          be set from *note user_return(): 4094.).  Return a reference
          to the *note trace_dispatch(): 408e. method for further
          tracing in that scope.

      -- メソッド: dispatch_exception (frame, arg)

          If the debugger should stop at this exception, invokes the
          *note user_exception(): 4096. method (which should be
          overridden in subclasses).  Raise a *note BdbQuit: 407a.
          exception if the *note quitting: 408d. flag is set (which can
          be set from *note user_exception(): 4096.).  Return a
          reference to the *note trace_dispatch(): 408e. method for
          further tracing in that scope.

     通常、継承クラスは以下のメソッド群をオーバーライドしません。しかし
     、停止やブレークポイント機能を再定義したい場合には、オーバーライド
     することもあります。

      -- メソッド: is_skipped_line (module_name)

          Return ‘True’ if 'module_name' matches any skip pattern.

      -- メソッド: stop_here (frame)

          Return ‘True’ if 'frame' is below the starting frame in the
          stack.

      -- メソッド: break_here (frame)

          Return ‘True’ if there is an effective breakpoint for this
          line.

          Check whether a line or function breakpoint exists and is in
          effect.  Delete temporary breakpoints based on information
          from *note effective(): 409a.

      -- メソッド: break_anywhere (frame)

          Return ‘True’ if any breakpoint exists for 'frame"s filename.

     継承クラスはデバッガー操作をするために以下のメソッド群をオーバーラ
     イドするべきです。

      -- メソッド: user_call (frame, argument_list)

          Called from *note dispatch_call(): 4091. if a break might stop
          inside the called function.

          'argument_list' is not used anymore and will always be ‘None’.
          The argument is kept for backwards compatibility.

      -- メソッド: user_line (frame)

          *note stop_here(): 4098. か *note break_here(): 4099. が
          ‘True’ を返したときに、 *note dispatch_line(): 408f. から呼び
          出されます。

      -- メソッド: user_return (frame, return_value)

          *note stop_here(): 4098. が ‘True’ を返したときに、 *note
          dispatch_return(): 4093. から呼び出されます。

      -- メソッド: user_exception (frame, exc_info)

          *note stop_here(): 4098. が ‘True’ を返したときに、 *note
          dispatch_exception(): 4095. から呼び出されます。

      -- メソッド: do_clear (arg)

          ブレークポイントがテンポラリブレークポイントだったときに、それ
          をどう削除するかを決定します。

          継承クラスはこのメソッドを実装しなければなりません。

     継承クラスとクライアントは、ステップ状態に影響を及ぼすために以下の
     メソッドを呼び出すことができます。

      -- メソッド: set_step ()

          コードの次の行でストップします。

      -- メソッド: set_next (frame)

          与えられたフレームかそれより下(のフレーム)にある、次の行でスト
          ップします。

      -- メソッド: set_return (frame)

          指定されたフレームから抜けるときにストップします。

      -- メソッド: set_until (frame, lineno=None)

          現在の行番号よりも大きい 'lineno' に到達したとき、あるいは、現
          在のフレームから戻るときにストップします。

      -- メソッド: set_trace ([frame])

          'frame' からデバッグを開始します。'frame' が指定されなかった場
          合、デバッグは呼び出し元のフレームから開始します。

          バージョン 3.13 で変更: *note set_trace(): 40a2. will enter
          the debugger immediately, rather than on the next line of code
          to be executed.

      -- メソッド: set_continue ()

          ブレークポイントに到達するか終了したときにストップします。もし
          ブレークポイントが1つも無い場合、システムのトレース関数を
          ‘None’ に設定します。

      -- メソッド: set_quit ()

          Set the ‘quitting’ attribute to ‘True’.  This raises *note
          BdbQuit: 407a. in the next call to one of the ‘dispatch_*()’
          methods.

     継承クラスとクライアントは以下のメソッドをブレークポイント操作に利
     用できます。これらのメソッドは、何か悪いことがあればエラーメッセー
     ジを含む文字列を返し、すべてが順調であれば ‘None’ を返します。

      -- メソッド: set_break (filename, lineno, temporary=False,
               cond=None, funcname=None)

          新しいブレークポイントを設定します。引数の 'lineno' 行が
          'filename' に存在しない場合、エラーメッセージを返します。
          'filename' は、 *note canonic(): 408b. メソッドで説明されてい
          るような、標準形である必要があります。

      -- メソッド: clear_break (filename, lineno)

          'filename' の 'lineno' 行にあるブレークポイントを削除します。
          もしブレークポイントが無かった場合、エラーメッセージを返します
          。

      -- メソッド: clear_bpbynumber (arg)

          *note Breakpoint.bpbynumber: 407c. の中で 'arg' のインデックス
          を持つブレークポイントを削除します。 'arg' が数値でないか範囲
          外の場合、エラーメッセージを返します。

      -- メソッド: clear_all_file_breaks (filename)

          'filename' にあるすべてのブレークポイントを削除します。もしブ
          レークポイントが無かった場合、エラーメッセージを返します。

      -- メソッド: clear_all_breaks ()

          存在するすべてのブレークポイントを削除します。もしブレークポイ
          ントが無かった場合、エラーメッセージを返します。

      -- メソッド: get_bpbynumber (arg)

          与えられた数値によって指定されるブレークポイントを返します。
          'arg' が文字列なら数値に変換されます。 'arg' が非数値の文字列
          である場合、指定されたブレークポイントが存在しないか削除された
          場合、 *note ValueError: 1e3. が上げられます。

          Added in version 3.2.

      -- メソッド: get_break (filename, lineno)

          Return ‘True’ if there is a breakpoint for 'lineno' in
          'filename'.

      -- メソッド: get_breaks (filename, lineno)

          'filename' の 'lineno' にあるすべてのブレークポイントを返しま
          す。ブレークポイントが存在しない場合は空のリストを返します。

      -- メソッド: get_file_breaks (filename)

          'filename' の中のすべてのブレークポイントを返します。ブレーク
          ポイントが存在しない場合は空のリストを返します。

      -- メソッド: get_all_breaks ()

          セットされているすべてのブレークポイントを返します。

     継承クラスとクライアントは以下のメソッドを呼んでスタックトレースを
     表現するデータ構造を取得することができます。

      -- メソッド: get_stack (f, t)

          Return a list of (frame, lineno) tuples in a stack trace, and
          a size.

          The most recently called frame is last in the list.  The size
          is the number of frames below the frame where the debugger was
          invoked.

      -- メソッド: format_stack_entry (frame_lineno, lprefix=': ')

          Return a string with information about a stack entry, which is
          a ‘(frame, lineno)’ tuple.  The return string contains:

             * The canonical filename which contains the frame.

             * 関数名もしくは ‘"<lambda>"’。

             * 入力された引数。

             * 戻り値。

             * (あれば)その行のコード。

     以下の2つのメソッドは、文字列として渡された *note 文: 26d2. をデバ
     ッグするもので、クライアントから利用されます。

      -- メソッド: run (cmd, globals=None, locals=None)

          Debug a statement executed via the *note exec(): 164.
          function.  'globals' defaults to ‘__main__.__dict__’, 'locals'
          defaults to 'globals'.

      -- メソッド: runeval (expr, globals=None, locals=None)

          *note eval(): 165. 関数を利用して式を実行しデバッグします。
          'globals' と 'locals' は *note run(): 40b0. と同じ意味です。

      -- メソッド: runctx (cmd, globals, locals)

          後方互換性のためのメソッドです。 *note run(): 40b0. を使ってく
          ださい。

      -- メソッド: runcall (func, /, *args, **kwds)

          1つの関数呼び出しをデバッグし、その結果を返します。

最後に、このモジュールは以下の関数を提供しています:

 -- の関数: bdb.checkfuncname (b, frame)

     Return ‘True’ if we should break here, depending on the way the
     *note Breakpoint: 407b. 'b' was set.

     If it was set via line number, it checks if *note b.line: 4087. is
     the same as the one in 'frame'.  If the breakpoint was set via
     *note function name: 407f, we have to check we are in the right
     'frame' (the right function) and if we are on its first executable
     line.

 -- の関数: bdb.effective (file, line, frame)

     Return ‘(active breakpoint, delete temporary flag)’ or ‘(None,
     None)’ as the breakpoint to act upon.

     The 'active breakpoint' is the first entry in *note bplist: 407d.
     for the (*note file: 407e, *note line: 4087.) (which must exist)
     that is *note enabled: 4089, for which *note checkfuncname(): 40b3.
     is true, and that has neither a false *note condition: 4081. nor
     positive *note ignore: 408a. count.  The 'flag', meaning that a
     temporary breakpoint should be deleted, is ‘False’ only when the
     *note cond: 4081. cannot be evaluated (in which case, *note ignore:
     408a. count is ignored).

     If no such entry exists, then ‘(None, None)’ is returned.

 -- の関数: bdb.set_trace ()

     *note Bdb: 12d0. クラスのインスタンスを使って、呼び出し元のフレーム
     からデバッグを開始します。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/bdb.py


File: python.info,  Node: faulthandler --- Python トレースバックをダンプする,  Next: pdb --- Python デバッガ,  Prev: bdb --- デバッガーフレームワーク,  Up: デバッグとプロファイル

5.27.3 ‘faulthandler’ -- Python トレースバックをダンプする
----------------------------------------------------------

Added in version 3.3.

__________________________________________________________________

このモジュールは、例外発生時、タイムアウト時、ユーザシグナルの発生時など
のタイミングでpython tracebackを明示的にダンプするための関数を含んでいま
す。これらのシグナル、*note SIGSEGV: 1cb3.、*note SIGFPE: 1cb4.、*note
SIGABRT: 1cb5.、*note SIGBUS: 1cb6.、*note SIGILL: 1cb7. に対するフォー
ルトハンドラをインストールするには *note faulthandler.enable(): c6c. を
実行してください。python起動時に有効にするには環境変数 *note
PYTHONFAULTHANDLER: 1055. を設定するか、コマンドライン引数に *note -X:
15c. ‘faulthandler’ を指定してください。

Pythonのフォールトハンドラは、apportやWindowsのフォールトハンドラのよう
なシステムフォールトハンドラと互換性があります。このモジュールは
‘sigaltstack()’ 関数が使用可能であればシグナルハンドラ用に代替スタックを
利用します。これによってスタックオーバーフロー時にもトレースバックを出力
することができます。

フォールトハンドラは絶望的なケースで呼び出されます。そのためシグナルセー
フな関数しか使うことができません (例: ヒープメモリ上にメモリ確保はできま
せん)。この制限により、tracebackのダンプ機能は通常のPythonのtracebackと
比べてごく僅かなものです:

   * ASCIIのみサポートされます。エンコード時には ‘backslashreplace’ エラ
     ーハンドラを使用します。

   * すべての文字列は500文字以内に制限されています。

   * ファイル名、関数名、行数のみ表示します。(ソースコードの表示はありま
     せん)

   * 100フレーム、100スレッドに制限されています。

   * 順番は保持されます: 最新の呼び出しが最初に表示されます。

デフォルトでは、Pythonのtracebackは *note sys.stderr: 907. に書き出され
ます。tracebackを見るには、対象アプリケーションはターミナル上で実行しな
ければなりません。 *note faulthandler.enable(): c6c. に渡す引数によって
ログファイルを指定することができます。

モジュールはC言語で実装されているので、アプリのクラッシュ時でもPythonが
デッドロックした場合でもダンプができます。

The *note Python Development Mode: 1d9. calls *note
faulthandler.enable(): c6c. at Python startup.

参考
....

Module *note pdb: 94.

     Interactive source code debugger for Python programs.

*note traceback: e7. モジュール

     Standard interface to extract, format and print stack traces of
     Python programs.

* Menu:

* tracebackのダンプ::
* フォールトハンドラの状態::
* タイムアウト後にtracebackをダンプする::
* ユーザシグナルに対してtracebackをダンプする::
* ファイル記述子の問題::
* 使用例: 使用例<42>.


File: python.info,  Node: tracebackのダンプ,  Next: フォールトハンドラの状態,  Up: faulthandler --- Python トレースバックをダンプする

5.27.3.1 tracebackのダンプ
..........................

 -- の関数: faulthandler.dump_traceback (file=sys.stderr,
          all_threads=True)

     全スレッドのtracebackを 'file' へダンプします。もし 'all_threads' が
     ‘False’ であれば、現在のスレッドのみダンプします。

     参考
     ....

     *note traceback.print_tb(): e50, which can be used to print a
     traceback object.

     バージョン 3.5 で変更: Added support for passing file descriptor to
     this function.


File: python.info,  Node: フォールトハンドラの状態,  Next: タイムアウト後にtracebackをダンプする,  Prev: tracebackのダンプ,  Up: faulthandler --- Python トレースバックをダンプする

5.27.3.2 フォールトハンドラの状態
.................................

 -- の関数: faulthandler.enable (file=sys.stderr, all_threads=True)

     Enable the fault handler: install handlers for the *note SIGSEGV:
     1cb3, *note SIGFPE: 1cb4, *note SIGABRT: 1cb5, *note SIGBUS: 1cb6.
     and *note SIGILL: 1cb7. signals to dump the Python traceback.  If
     'all_threads' is ‘True’, produce tracebacks for every running
     thread.  Otherwise, dump only the current thread.

     The 'file' must be kept open until the fault handler is disabled:
     see *note issue with file descriptors: 40b8.

     バージョン 3.5 で変更: Added support for passing file descriptor to
     this function.

     バージョン 3.6 で変更: On Windows, a handler for Windows exception
     is also installed.

     バージョン 3.10 で変更: The dump now mentions if a garbage
     collector collection is running if 'all_threads' is true.

 -- の関数: faulthandler.disable ()

     フォールトハンドラを無効にします: *note enable(): c6c. によってイン
     ストールされたシグナルハンドラをアンインストールします。

 -- の関数: faulthandler.is_enabled ()

     フォールトハンドラが有効かどうかチェックします。


File: python.info,  Node: タイムアウト後にtracebackをダンプする,  Next: ユーザシグナルに対してtracebackをダンプする,  Prev: フォールトハンドラの状態,  Up: faulthandler --- Python トレースバックをダンプする

5.27.3.3 タイムアウト後にtracebackをダンプする
..............................................

 -- の関数: faulthandler.dump_traceback_later (timeout, repeat=False,
          file=sys.stderr, exit=False)

     Dump the tracebacks of all threads, after a timeout of 'timeout'
     seconds, or every 'timeout' seconds if 'repeat' is ‘True’.  If
     'exit' is ‘True’, call ‘_exit()’ with status=1 after dumping the
     tracebacks.  (Note ‘_exit()’ exits the process immediately, which
     means it doesn't do any cleanup like flushing file buffers.)  If
     the function is called twice, the new call replaces previous
     parameters and resets the timeout.  The timer has a sub-second
     resolution.

     The 'file' must be kept open until the traceback is dumped or *note
     cancel_dump_traceback_later(): 40bc. is called: see *note issue
     with file descriptors: 40b8.

     This function is implemented using a watchdog thread.

     バージョン 3.5 で変更: Added support for passing file descriptor to
     this function.

     バージョン 3.7 で変更: This function is now always available.

 -- の関数: faulthandler.cancel_dump_traceback_later ()

     *note dump_traceback_later(): dcc. の最新の呼び出しをキャンセルしま
     す。


File: python.info,  Node: ユーザシグナルに対してtracebackをダンプする,  Next: ファイル記述子の問題,  Prev: タイムアウト後にtracebackをダンプする,  Up: faulthandler --- Python トレースバックをダンプする

5.27.3.4 ユーザシグナルに対してtracebackをダンプする
....................................................

 -- の関数: faulthandler.register (signum, file=sys.stderr,
          all_threads=True, chain=False)

     ユーザシグナルを登録します: すべてのスレッドでtracebackをダンプする
     ために 'signum' シグナルをインストールします。ただし 'all_threads'
     が ‘False’ であれば現在のスレッドのみ 'file' にダンプします。もし
     chain が ‘True’ であれば以前のハンドラも呼び出します。

     The 'file' must be kept open until the signal is unregistered by
     *note unregister(): 40be.: see *note issue with file descriptors:
     40b8.

     Windowsでは利用不可です。

     バージョン 3.5 で変更: Added support for passing file descriptor to
     this function.

 -- の関数: faulthandler.unregister (signum)

     ユーザシグナルを登録解除します: *note register(): dca. でインストー
     ルした 'signum' シグナルハンドラをアンインストールします。シグナル
     が登録された場合は ‘True’ を返し、そうでなければ ‘False’ を返します
     。

     Windowsでは利用不可です。


File: python.info,  Node: ファイル記述子の問題,  Next: 使用例<42>,  Prev: ユーザシグナルに対してtracebackをダンプする,  Up: faulthandler --- Python トレースバックをダンプする

5.27.3.5 ファイル記述子の問題
.............................

*note enable(): c6c.、*note dump_traceback_later(): dcc. ならびに *note
register(): dca. は引数 'file' に渡されたファイル記述子を保持します。フ
ァイルが閉じられファイル記述子が新しいファイルで再利用された場合や、
*note os.dup2(): b31. の使用でファイル記述子が置き換えた場合、 traceback
の結果は別のファイルへ書き込まれます。ファイルが置き換えられた場合は、毎
回これらの関数を呼び出しなおしてください。


File: python.info,  Node: 使用例<42>,  Prev: ファイル記述子の問題,  Up: faulthandler --- Python トレースバックをダンプする

5.27.3.6 使用例
...............

フォールトハンドラを有効化・無効化したときの Linuxでのセグメンテーション
フォールトの例:

     $ python -c "import ctypes; ctypes.string_at(0)"
     Segmentation fault

     $ python -q -X faulthandler
     >>> import ctypes
     >>> ctypes.string_at(0)
     Fatal Python error: Segmentation fault

     Current thread 0x00007fb899f39700 (most recent call first):
       File "/home/python/cpython/Lib/ctypes/__init__.py", line 486 in string_at
       File "<stdin>", line 1 in <module>
     Segmentation fault


File: python.info,  Node: pdb --- Python デバッガ,  Next: Python プロファイラ,  Prev: faulthandler --- Python トレースバックをダンプする,  Up: デバッグとプロファイル

5.27.4 ‘pdb’ -- Python デバッガ
-------------------------------

'ソースコード:' Lib/pdb.py(1)

__________________________________________________________________

モジュール *note pdb: 94. は Python プログラム用の対話型ソースコードデバ
ッガを定義します。 (条件付き)ブレークポイントの設定やソース行レベルでの
シングルステップ実行、スタックフレームのインスペクション、ソースコードリ
スティングおよびあらゆるスタックフレームのコンテキストにおける任意の
Python コードの評価をサポートしています。事後解析デバッギングもサポート
し、プログラムの制御下で呼び出すことができます。

デバッガーは拡張可能です - 実際にはクラス *note Pdb: 8f0. として定義され
ています。現在これについてのドキュメントはありませんが、ソースを読めば簡
単に理解できます。拡張インターフェースはモジュール *note bdb: b. と
*note cmd: 12. を使っています。

参考
....

*note faulthandler: 4e. モジュール

     Used to dump Python tracebacks explicitly, on a fault, after a
     timeout, or on a user signal.

*note traceback: e7. モジュール

     Standard interface to extract, format and print stack traces of
     Python programs.

The typical usage to break into the debugger is to insert:

     import pdb; pdb.set_trace()

Or:

     breakpoint()

at the location you want to break into the debugger, and then run the
program.  You can then step through the code following this statement,
and continue running without the debugger using the *note continue:
40c4. command.

バージョン 3.7 で変更: The built-in *note breakpoint(): 215, when called
with defaults, can be used instead of ‘import pdb; pdb.set_trace()’.

     def double(x):
        breakpoint()
        return x * 2
     val = 3
     print(f"{val} * 2 is {double(val)}")

The debugger's prompt is ‘(Pdb)’, which is the indicator that you are in
debug mode:

     > ...(2)double()
     -> breakpoint()
     (Pdb) p x
     3
     (Pdb) continue
     3 * 2 is 6

バージョン 3.3 で変更: *note readline: a8. モジュールによるコマンドおよ
びコマンド引数のタブ補完が利用できます。たとえば、‘p’ コマンドの引数では
現在のグローバルおよびローカル名が候補として表示されます。

You can also invoke *note pdb: 94. from the command line to debug other
scripts.  For example:

     python -m pdb myscript.py

モジュールとして pdb を起動すると、デバッグ中のプログラムが異常終了した
ときに pdb が自動的に事後デバッグモードに入ります。事後デバッグ後 (また
はプログラムの正常終了後)、pdb はプログラムを再起動します。自動再起動を
行った場合、pdb の状態 (ブレークポイントなど) はそのまま維持されるので、
たいていの場合、プログラム終了時にデバッガーも終了させるよりも便利なはず
です。

バージョン 3.2 で変更: Added the ‘-c’ option to execute commands as if
given in a ‘.pdbrc’ file; see *note デバッガコマンド: 40c5.

バージョン 3.7 で変更: Added the ‘-m’ option to execute modules similar
to the way ‘python -m’ does.  As with a script, the debugger will pause
execution just before the first line of the module.

Typical usage to execute a statement under control of the debugger is:

     >>> import pdb
     >>> def f(x):
     ...     print(1 / x)
     >>> pdb.run("f(2)")
     > <string>(1)<module>()
     (Pdb) continue
     0.5
     >>>

クラッシュしたプログラムを調べるための典型的な使い方は以下のようになりま
す:

     >>> import pdb
     >>> def f(x):
     ...     print(1 / x)
     ...
     >>> f(0)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 2, in f
     ZeroDivisionError: division by zero
     >>> pdb.pm()
     > <stdin>(2)f()
     (Pdb) p x
     0
     (Pdb)

バージョン 3.13 で変更: The implementation of PEP 667(2) means that name
assignments made via ‘pdb’ will immediately affect the active scope,
even when running inside an *note optimized scope: 163.

このモジュールは以下の関数を定義しています。それぞれが少しづつ違った方法
でデバッガに入ります:

 -- の関数: pdb.run (statement, globals=None, locals=None)

     デバッガーに制御された状態で (文字列またはコードオブジェクトとして
     与えられた) 'statement' を実行します。あらゆるコードが実行される前
     にデバッガープロンプトが現れます。ブレークポイントを設定し、*note
     continue: 40c4. とタイプできます。あるいは、文を *note step: 40c6.
     や *note next: 40c7. を使って一つづつ実行することができます (これら
     のコマンドはすべて下で説明します)。オプションの 'globals' と
     'locals' 引数はコードを実行する環境を指定します。デフォルトでは、モ
     ジュール *note __main__: 1. の辞書が使われます。(組み込み関数 *note
     exec(): 164. または *note eval(): 165. の説明を参照してください。)

 -- の関数: pdb.runeval (expression, globals=None, locals=None)

     デバッガーに制御された状態で (文字列またはコードオブジェクトとして
     与えられる) 'expression' を評価します。*note runeval(): 40c8. から
     復帰するとき、式の値を返します。その他の点では、この関数は *note
     run(): 3ece. と同様です。

 -- の関数: pdb.runcall (function, *args, **kwds)

     'function' (関数またはメソッドオブジェクト、文字列ではありません) を
     与えられた引数とともに呼び出します。 *note runcall(): 40c9. から復
     帰するとき、関数呼び出しが返したものはなんでも返します。関数に入る
     とすぐにデバッガプロンプトが現れます。

 -- の関数: pdb.set_trace (*, header=None)

     Enter the debugger at the calling stack frame.  This is useful to
     hard-code a breakpoint at a given point in a program, even if the
     code is not otherwise being debugged (e.g.  when an assertion
     fails).  If given, 'header' is printed to the console just before
     debugging begins.

     バージョン 3.7 で変更: 'header' キーワード専用引数。

     バージョン 3.13 で変更: *note set_trace(): 216. will enter the
     debugger immediately, rather than on the next line of code to be
     executed.

 -- の関数: pdb.post_mortem (traceback=None)

     与えられた 'traceback' オブジェクトの事後解析デバッギングに入ります
     。もし 'traceback' が与えられなければ、その時点で取り扱っている例外
     のうちのひとつを使います。 (デフォルト動作をさせるには、例外を取り
     扱っている最中である必要があります。)

 -- の関数: pdb.pm ()

     Enter post-mortem debugging of the exception found in *note
     sys.last_exc: 48a.

‘run*’ 関数と *note set_trace(): 216. は、 *note Pdb: 8f0. クラスをイン
スタンス化して同名のメソッドを実行することのエイリアス関数です。それ以上
の機能を利用したい場合は、インスタンス化を自分で行わなければなりません:

 -- クラス: pdb.Pdb (completekey='tab', stdin=None, stdout=None,
          skip=None, nosigint=False, readrc=True)

     *note Pdb: 8f0. はデバッガクラスです。

     'completekey', 'stdin', 'stdout' 引数は、基底にある *note cmd.Cmd:
     162b. クラスに渡されます。そちらの解説を参照してください。

     'skip' 引数が指定された場合、 glob スタイルのモジュール名パターンの
     iterable (イテレート可能オブジェクト) でなければなりません。デバッ
     ガはこのパターンのどれかにマッチするモジュールに属するフレームには
     ステップインしません。 (3)

     デフォルトでは、Pdb は *note continue: 40c4. コマンドが投入されると
     、(ユーザーがコンソールから ‘Ctrl-C’ を押したときに送られる) SIGINT
     シグナル用ハンドラーを設定します。これにより ‘Ctrl-C’ を押すことで
     再度デバッガーを起動することができます。Pdb に SIGINT ハンドラーを
     変更させたくない場合は 'nosigint' を true に設定してください。

     'readrc' 引数はデフォルトでは真で、 Pdb が .pdbrc ファイルをファイ
     ルシステムから読み込むかどうかを制御します。

     'skip' を使ってトレースする呼び出しの例:

          import pdb; pdb.Pdb(skip=['django.*']).set_trace()

     引数無しで *note 監査イベント: 1825. ‘pdb.Pdb’ を送出します。

     バージョン 3.1 で変更: 'skip' パラメータが追加されました。

     バージョン 3.2 で変更: Added the 'nosigint' parameter.  Previously,
     a SIGINT handler was never set by Pdb.

     バージョン 3.6 で変更: 'readrc' 引数。

      -- メソッド: run (statement, globals=None, locals=None)
      -- メソッド: runeval (expression, globals=None, locals=None)
      -- メソッド: runcall (function, *args, **kwds)
      -- メソッド: set_trace ()

          前述のこれら関数のドキュメントを参照してください。

* Menu:

* デバッガコマンド::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pdb.py

   (2) https://peps.python.org/pep-0667/

   (3) フレームが属するモジュールは、そのフレームのグローバルの
‘__name__’ によって決定されます。


File: python.info,  Node: デバッガコマンド,  Up: pdb --- Python デバッガ

5.27.4.1 デバッガコマンド
.........................

デバッガーに認識されるコマンドは以下に一覧されています。たいていのコマン
ドは以下のように 1、2 文字に省略できます。例えば ‘h(elp)’ は ‘h’ か
‘help’ がで help コマンドを呼び出すことを意味します (ただし ‘he’, ‘hel’,
‘H’, ‘Help’, ‘HELP’ は使用できません)。コマンドの引数はホワイトスペース
(スペースかタブ) で区切ってください。コマンド構文として任意の引数は大括
弧 (‘[]’) で括られています (実際に大括弧はタイプしないでください)。いく
つかから選択できる引数は縦線 (‘|’) で分割されて記述されています。

空行を入力すると入力された直前のコマンドを繰り返します。例外: 直前のコマ
ンドが *note list: 40cf. コマンドならば、次の 11 行がリストされます。

デバッガが認識しないコマンドは Python 文とみなして、デバッグしているプロ
グラムのコンテキストおいて実行されます。先頭にに感嘆符 (‘!’) を付けるこ
とで Python 文であると明示することもできます。これはデバッグ中のプログラ
ムを調査する強力な方法です。変数を変更したり関数を呼び出したりすることも
可能です。このような文で例外が発生した場合には例外名が出力されますが、デ
バッガの状態は変化しません。

バージョン 3.13 で変更: Expressions/Statements whose prefix is a pdb
command are now correctly identified and executed.

デバッガーは *note エイリアス: 40d0. をサポートしています。エイリアスは
デバッグ中のコンテキストに適用可能な一定レベルのパラメータを保持すること
ができます。

Multiple commands may be entered on a single line, separated by ‘;;’.
(A single ‘;’ is not used as it is the separator for multiple commands
in a line that is passed to the Python parser.)  No intelligence is
applied to separating the commands; the input is split at the first ‘;;’
pair, even if it is in the middle of a quoted string.  A workaround for
strings with double semicolons is to use implicit string concatenation
‘';'';'’ or ‘";"";"’.

To set a temporary global variable, use a 'convenience variable'.  A
'convenience variable' is a variable whose name starts with ‘$’.  For
example, ‘$foo = 1’ sets a global variable ‘$foo’ which you can use in
the debugger session.  The 'convenience variables' are cleared when the
program resumes execution so it's less likely to interfere with your
program compared to using normal variables like ‘foo = 1’.

There are three preset 'convenience variables':

   * ‘$_frame’: the current frame you are debugging

   * ‘$_retval’: the return value if the frame is returning

   * ‘$_exception’: the exception if the frame is raising an exception

Added in version 3.12: Added the 'convenience variable' feature.

If a file ‘.pdbrc’ exists in the user's home directory or in the current
directory, it is read with ‘'utf-8'’ encoding and executed as if it had
been typed at the debugger prompt, with the exception that empty lines
and lines starting with ‘#’ are ignored.  This is particularly useful
for aliases.  If both files exist, the one in the home directory is read
first and aliases defined there can be overridden by the local file.

バージョン 3.2 で変更: ‘.pdbrc’ に *note continue: 40c4. や *note next:
40c7. のようなデバッグを続行するコマンドが使用できるようになりました。以
前はこのようなコマンドは無視されていました。

バージョン 3.11 で変更: ‘.pdbrc’ is now read with ‘'utf-8'’ encoding.
Previously, it was read with the system locale encoding.

 -- Pdbcommand: h(elp) [command]

     引数を指定しない場合、利用できるコマンドの一覧が表示されます。引数
     として 'command' が与えられた場合、そのコマンドのヘルプが表示されま
     す。‘help pdb’ で完全なドキュメント (*note pdb: 94. モジュールの
     doctring) が表示されます。'command' 引数は識別子でなければならない
     ため、‘!’ コマンドのヘルプを表示するには ‘help exec’ と入力します。

 -- Pdbcommand: w(here)

     スタックの底にある最も新しいフレームと一緒にスタックトレースをプリ
     ントします。矢印 (‘>’) はカレントフレームを指し、それがほとんどのコ
     マンドのコンテキストを決定します。

 -- Pdbcommand: d(own) [count]

     スタックフレーム内で現在のフレームを 'count' レベル (デフォルトは
     1) 新しいフレーム方向に移動します。

 -- Pdbcommand: u(p) [count]

     スタックフレーム内で現在のフレームを 'count' レベル (デフォルトは
     1) 古いフレーム方向に移動します。

 -- Pdbcommand: b(reak) [([filename:]lineno | function) [, condition]]

     With a 'lineno' argument, set a break at line 'lineno' in the
     current file.  The line number may be prefixed with a 'filename'
     and a colon, to specify a breakpoint in another file (possibly one
     that hasn't been loaded yet).  The file is searched on *note
     sys.path: 38e.  Accepatable forms of 'filename' are
     ‘/abspath/to/file.py’, ‘relpath/file.py’, ‘module’ and
     ‘package.module’.

     With a 'function' argument, set a break at the first executable
     statement within that function.  'function' can be any expression
     that evaluates to a function in the current namespace.

     第二引数を指定する場合、その値は式で、その評価値が真でなければブレ
     ークポイントは有効になりません。

     引数なしの場合は、それぞれのブレークポイントに対して、そのブレーク
     ポイントに行き当たった回数、現在の通過カウント ( ignore count ) と
     、もしあれば関連条件を含めてすべてのブレークポイントをリストします
     。

     Each breakpoint is assigned a number to which all the other
     breakpoint commands refer.

 -- Pdbcommand: tbreak [([filename:]lineno | function) [, condition]]

     一時的なブレークポイントで、最初にそこに達したときに自動的に取り除
     かれます。引数は *note break: 40d5. と同じです。

 -- Pdbcommand: cl(ear) [filename:lineno | bpnumber ...]

     'filename:lineno' 引数を与えると、その行にある全てのブレークポイン
     トを解除します。スペースで区切られたブレークポイントナンバーのリス
     トを与えると、それらのブレークポイントを解除します。引数なしの場合
     は、すべてのブレークポイントを解除します ( が、はじめに確認します )
     。

 -- Pdbcommand: disable bpnumber [bpnumber ...]

     ブレークポイント番号 'bpnumber' のブレークポイントを無効にします。
     ブレークポイントを無効にすると、プログラムの実行を止めることができ
     なくなりますが、ブレークポイントの解除と違いブレークポイントのリス
     トに残っており、(再び) 有効にできます。

 -- Pdbcommand: enable bpnumber [bpnumber ...]

     指定したブレークポイントを有効にします。

 -- Pdbcommand: ignore bpnumber [count]

     与えられたブレークポイントナンバーに通過カウントを設定します。count
     が省略されると、通過カウントは 0 に設定されます。通過カウントがゼロ
     になったとき、ブレークポイントが機能する状態になります。ゼロでない
     ときは、そのブレークポイントが無効にされず、どんな関連条件も真に評
     価されていて、ブレークポイントに来るたびに 'count' が減らされます。

 -- Pdbcommand: condition bpnumber [condition]

     ブレークポイントに新しい 'condition' を設定します。'condition' はブ
     レークポイントを制御する条件式で、この式が真を返す場合のみブレーク
     ポイントが有効になります。'condition' を指定しないと既存の条件が除
     去されます; ブレークポイントは常に有効になります。

 -- Pdbcommand: commands [bpnumber]

     ブレークポイントナンバー 'bpnumber' にコマンドのリストを指定します
     。コマンドそのものはその後の行に続けます。‘end’ だけからなる行を入
     力することでコマンド群の終わりを示します。例を挙げます:

          (Pdb) commands 1
          (com) p some_variable
          (com) end
          (Pdb)

     ブレークポイントからコマンドを取り除くには、 ‘commands’ のあとに
     ‘end’ だけを続けます。つまり、コマンドを一つも指定しないようにしま
     す。

     'bpnumber' 引数を指定しない場合、‘commands’ は最後にセットしたブレ
     ークポイントを参照します。

     ブレークポイントコマンドはプログラムを走らせ直すのに使えます。単に
     *note continue: 40c4. コマンドや *note step: 40c6.、その他実行を再
     開するコマンドを使えば良いのです。

     実行を再開するコマンド (現在のところ *note continue: 40c4, *note
     step: 40c6, *note next: 40c7, *note return: 40dd, *note jump: 40de,
     *note quit: 40df. とそれらの省略形) によって、コマンドリストは終了
     するものと見なされます (コマンドにすぐ end が続いているかのように
     )。というのも実行を再開すれば (それが単純な next や step であっても
     ) 別のブレークポイントに到達するかもしれないからです。そのブレーク
     ポイントにさらにコマンドリストがあれば、どちらのリストを実行すべき
     か状況が曖昧になります。

     コマンドリストの中で ‘silent’ コマンドを使うと、ブレークポイントで
     停止したという通常のメッセージはプリントされません。この振る舞いは
     特定のメッセージを出して実行を続けるようなブレークポイントでは望ま
     しいものでしょう。他のコマンドが何も画面出力をしなければ、そのブレ
     ークポイントに到達したというサインを見ないことになります。

 -- Pdbcommand: s(tep)

     現在の行を実行し、最初に実行可能なものがあらわれたときに (呼び出さ
     れた関数の中か、現在の関数の次の行で) 停止します。

 -- Pdbcommand: n(ext)

     現在の関数の次の行に達するか、あるいは関数が返るまで実行を継続しま
     す。 (*note next: 40c7. と *note step: 40c6. の差は *note step:
     40c6. が呼び出された関数の内部で停止するのに対し、 *note next:
     40c7. は呼び出された関数を (ほぼ) 全速力で実行し、現在の関数内の次
     の行で停止するだけです。)

 -- Pdbcommand: unt(il) [lineno]

     引数なしだと、現在の行から 1 行先まで実行します。

     'lineno' を指定すると、番号が 'lineno' 以上である行に到達するまで実
     行します。どちらにしても現在のフレームが返ってきた時点で停止します
     。

     バージョン 3.2 で変更: 明示的に行数指定ができるようになりました。

 -- Pdbcommand: r(eturn)

     現在の関数が返るまで実行を継続します。

 -- Pdbcommand: c(ont(inue))

     ブレークポイントに出会うまで、実行を継続します。

 -- Pdbcommand: j(ump) lineno

     次に実行する行を指定します。最も底のフレーム中でのみ実行可能です。
     前に戻って実行したり、不要な部分をスキップして先の処理を実行する場
     合に使用します。

     ジャンプには制限があり、例えば *note for: 2c9. ループの中には飛び込
     めませんし、 *note finally: 997. 節の外にも飛ぶ事ができません。

 -- Pdbcommand: l(ist) [first[, last]]

     現在のファイルのソースコードを表示します。引数を指定しないと、現在
     の行の前後 11 行分を表示するか、直前の表示を続行します。引数に ‘.’
     を指定すると、現在の行の前後 11 行分を表示します。数値を 1 個指定す
     ると、その行番号の前後 11 行分を表示します。数値を 2 個指定すると、
     開始行と最終行として表示します; 2 個めの引数が 1 個め未満だった場合
     、1 個目を開始行、2 個めを開始行からの行数とみなします。

     現在のフレーム内の現在の行は ‘->’ で表示されます。例外をデバッグ中
     の場合、例外が発生または伝搬した行は、それが現在の行とは異なるとき
     ‘>>’ で表示されます。

     バージョン 3.2 で変更: ‘>>’ マーカーが追加されました。

 -- Pdbcommand: ll | longlist

     現在の関数またはフレームの全ソースコードを表示します。注目する行は
     *note list: 40cf. と同じようにマーカーがつきます。

     Added in version 3.2.

 -- Pdbcommand: a(rgs)

     Print the arguments of the current function and their current
     values.

 -- Pdbcommand: p expression

     現在のコンテキストにおいて 'expression' を評価し、その値をプリント
     します。

          注釈: ‘print()’ も使えますが、これはデバッガーコマンドではあり
          ません -- これは Python の関数 *note print(): f42. が実行され
          ます。

 -- Pdbcommand: pp expression

     *note p: f43. コマンドに似ていますが、'expression' の値以外は *note
     pprint: 9c. モジュールを使用して "pretty-print" されます。

 -- Pdbcommand: whatis expression

     'expression' の型を表示します。

 -- Pdbcommand: source expression

     'expression' のソースコードの取得を試み、可能であれば表示します。

     Added in version 3.2.

 -- Pdbcommand: display [expression]

     'expression' の値が変更されていれば表示します。毎回実行は現在のフレ
     ームで停止します。

     'expression' を指定しない場合、現在のフレームのすべての式を表示しま
     す。

          注釈: Display evaluates 'expression' and compares to the
          result of the previous evaluation of 'expression', so when the
          result is mutable, display may not be able to pick up the
          changes.

     以下はプログラム例です:

          lst = []
          breakpoint()
          pass
          lst.append(1)
          print(lst)

     Display won't realize ‘lst’ has been changed because the result of
     evaluation is modified in place by ‘lst.append(1)’ before being
     compared:

          > example.py(3)<module>()
          -> pass
          (Pdb) display lst
          display lst: []
          (Pdb) n
          > example.py(4)<module>()
          -> lst.append(1)
          (Pdb) n
          > example.py(5)<module>()
          -> print(lst)
          (Pdb)

     You can do some tricks with copy mechanism to make it work:

          > example.py(3)<module>()
          -> pass
          (Pdb) display lst[:]
          display lst[:]: []
          (Pdb) n
          > example.py(4)<module>()
          -> lst.append(1)
          (Pdb) n
          > example.py(5)<module>()
          -> print(lst)
          display lst[:]: [1]  [old: []]
          (Pdb)

     Added in version 3.2.

 -- Pdbcommand: undisplay [expression]

     現在のフレーム内で 'expression' をこれ以上表示しないようにします。
     'expression' を指定しない場合、現在のフレームで display 指定されて
     いる式を全てクリアします。

     Added in version 3.2.

 -- Pdbcommand: interact

     Start an interactive interpreter (using the *note code: 13. module)
     in a new global namespace initialised from the local and global
     namespaces for the current scope.  Use ‘exit()’ or ‘quit()’ to exit
     the interpreter and return to the debugger.

          注釈: As ‘interact’ creates a new dedicated namespace for code
          execution, assignments to variables will not affect the
          original namespaces.  However, modifications to any referenced
          mutable objects will be reflected in the original namespaces
          as usual.

     Added in version 3.2.

     バージョン 3.13 で変更: ‘exit()’ and ‘quit()’ can be used to exit
     the *note interact: 40e8. command.

     バージョン 3.13 で変更: *note interact: 40e8. directs its output to
     the debugger's output channel rather than *note sys.stderr: 907.

 -- Pdbcommand: alias [name [command]]

     Create an alias called 'name' that executes 'command'.  The
     'command' must 'not' be enclosed in quotes.  Replaceable parameters
     can be indicated by ‘%1’, ‘%2’, ...  and ‘%9’, while ‘%*’ is
     replaced by all the parameters.  If 'command' is omitted, the
     current alias for 'name' is shown.  If no arguments are given, all
     aliases are listed.

     エイリアスは入れ子になってもよく、pdb プロンプトで合法的にタイプで
     きるどんなものでも含めることができます。内部 pdb コマンドをエイリア
     スによって上書きすることが 'できます'。そのとき、このようなコマンド
     はエイリアスが取り除かれるまで隠されます。エイリアス化はコマンド行
     の最初の語へ再帰的に適用されます。行の他のすべての語はそのままです
     。

     例として、二つの便利なエイリアスがあります (特に ‘.pdbrc’ ファイル
     に置かれたときに):

          # Print instance variables (usage "pi classInst")
          alias pi for k in %1.__dict__.keys(): print(f"%1.{k} = {%1.__dict__[k]}")
          # Print instance variables in self
          alias ps pi self

 -- Pdbcommand: unalias name

     指定したエイリアス 'name' を削除します。

 -- Pdbcommand: ! statement

     Execute the (one-line) 'statement' in the context of the current
     stack frame.  The exclamation point can be omitted unless the first
     word of the statement resembles a debugger command, e.g.:

          (Pdb) ! n=42
          (Pdb)

     To set a global variable, you can prefix the assignment command
     with a *note global: 16f. statement on the same line, e.g.:

          (Pdb) global list_options; list_options = ['-l']
          (Pdb)

 -- Pdbcommand: run [args ...]
 -- Pdbcommand: restart [args ...]

     デバッグ中の Python プログラムを再実行します。'args' が与えられると
     、 *note shlex: b2. で分割され、結果が新しい *note sys.argv: 1236.
     として使われます。ヒストリー、ブレークポイント、アクション、そして
     、デバッガーオプションは引き継がれます。 *note restart: 40ed. は
     *note run: 40ec. の別名です。

 -- Pdbcommand: q(uit)

     デバッガーを終了します。実行しているプログラムは中断されます。

 -- Pdbcommand: debug code

     Enter a recursive debugger that steps through 'code' (which is an
     arbitrary expression or statement to be executed in the current
     environment).

 -- Pdbcommand: retval

     Print the return value for the last return of the current function.

 -- Pdbcommand: exceptions [excnumber]

     List or jump between chained exceptions.

     When using ‘pdb.pm()’ or ‘Pdb.post_mortem(...)’ with a chained
     exception instead of a traceback, it allows the user to move
     between the chained exceptions using ‘exceptions’ command to list
     exceptions, and ‘exception <number>’ to switch to that exception.

     以下はプログラム例です:

          def out():
              try:
                  middle()
              except Exception as e:
                  raise ValueError("reraise middle() error") from e

          def middle():
              try:
                  return inner(0)
              except Exception as e:
                  raise ValueError("Middle fail")

          def inner(x):
              1 / x

           out()

     calling ‘pdb.pm()’ will allow to move between exceptions:

          > example.py(5)out()
          -> raise ValueError("reraise middle() error") from e

          (Pdb) exceptions
            0 ZeroDivisionError('division by zero')
            1 ValueError('Middle fail')
          > 2 ValueError('reraise middle() error')

          (Pdb) exceptions 0
          > example.py(16)inner()
          -> 1 / x

          (Pdb) up
          > example.py(10)middle()
          -> return inner(0)

     Added in version 3.13.

脚注
....


File: python.info,  Node: Python プロファイラ,  Next: timeit --- 小さなコードスニペットの実行時間計測,  Prev: pdb --- Python デバッガ,  Up: デバッグとプロファイル

5.27.5 Python プロファイラ
--------------------------

'ソースコード:' Lib/profile.py(1) と Lib/pstats.py(2)

__________________________________________________________________

* Menu:

* プロファイラとは::
* かんたんユーザマニュアル::
* リファレンスマニュアル: リファレンスマニュアル -- profile と cProfile. profile と cProfile
* Stats クラス::
* 決定論的プロファイリングとは::
* 制限事項: 制限事項<2>.
* キャリブレーション (補正): キャリブレーション 補正.
* カスタムな時刻取得用関数を使う::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/profile.py

   (2) https://github.com/python/cpython/tree/3.13/Lib/pstats.py


File: python.info,  Node: プロファイラとは,  Next: かんたんユーザマニュアル,  Up: Python プロファイラ

5.27.5.1 プロファイラとは
.........................

*note cProfile: 20. と *note profile: 9d. は '決定論的プロファイリング
(deterministic profiling)' を行います。 'プロファイル (profile)' とは、
プログラムの各部分がどれだけ頻繁に呼ばれたか、そして実行にどれだけ時間が
かかったかという統計情報です。 *note pstats: 9e. モジュールを使ってこの
統計情報をフォーマットし表示することができます。

Python 標準ライブラリは同じインターフェイスを提供するプロファイラの実装
を2つ提供しています:

  1. *note cProfile: 20. はほとんどのユーザーに推奨されるモジュールです
     。 C言語で書かれた拡張モジュールで、オーバーヘッドが少ないため長時
     間実行されるプログラムのプロファイルに適しています。 Brett Rosen と
     Ted Czotter によって提供された ‘lsprof’ に基づいています。

  2. *note profile: 9d. はピュア Python モジュールで、 *note cProfile:
     20. モジュールはこのモジュールのインターフェースを真似ています。対
     象プログラムに相当のオーバーヘッドが生じます。もしプロファイラに何
     らかの拡張をしたいのであれば、こちらのモジュールを拡張する方が簡単
     でしょう。このモジュールはもともと Jim Roskind により設計、実装され
     ました。

     注釈: 2つのプロファイラモジュールは、与えられたプログラムの実行時プ
     ロファイルを取得するために設計されており、ベンチマークのためのもの
     ではありません (ベンチマーク用途には *note timeit: d8. のほうが正確
     な計測結果を求められます)。これは Python コードと C で書かれたコー
     ドをベンチマークするときに特に大きく影響します。プロファイラは
     Python コードに対してオーバーヘッドを発生しますが、C言語レベルの関
     数に対してはオーバーヘッドを生じません。なのでC言語で書かれたコード
     が、実際の速度と関係なく、Pythonで書かれたコードより速く見えるでし
     ょう。


File: python.info,  Node: かんたんユーザマニュアル,  Next: リファレンスマニュアル -- profile と cProfile,  Prev: プロファイラとは,  Up: Python プロファイラ

5.27.5.2 かんたんユーザマニュアル
.................................

この節は "マニュアルなんか読みたくない人"のために書かれています。ここで
はきわめて簡単な概要説明とアプリケーションのプロファイリングを手っ取り早
く行う方法だけを解説します。

1つの引数を取る関数をプロファイルしたい場合、次のようにできます:

     import cProfile
     import re
     cProfile.run('re.compile("foo|bar")')

(お使いのシステムで *note cProfile: 20. が使えないときは代わりに *note
profile: 9d. を使って下さい)

上のコードは *note re.compile(): ba1. を実行して、プロファイル結果を次の
ように表示します:

           214 function calls (207 primitive calls) in 0.002 seconds

     Ordered by: cumulative time

     ncalls  tottime  percall  cumtime  percall filename:lineno(function)
          1    0.000    0.000    0.002    0.002 {built-in method builtins.exec}
          1    0.000    0.000    0.001    0.001 <string>:1(<module>)
          1    0.000    0.000    0.001    0.001 __init__.py:250(compile)
          1    0.000    0.000    0.001    0.001 __init__.py:289(_compile)
          1    0.000    0.000    0.000    0.000 _compiler.py:759(compile)
          1    0.000    0.000    0.000    0.000 _parser.py:937(parse)
          1    0.000    0.000    0.000    0.000 _compiler.py:598(_code)
          1    0.000    0.000    0.000    0.000 _parser.py:435(_parse_sub)

The first line indicates that 214 calls were monitored.  Of those calls,
207 were 'primitive', meaning that the call was not induced via
recursion.  The next line: ‘Ordered by: cumulative time’ indicates the
output is sorted by the ‘cumtime’ values.  The column headings include:

ncalls

     呼び出し回数

tottime

     与えられた関数に消費された合計時間 (sub-function の呼び出しで消費さ
     れた時間は除外されています)

percall

     ‘tottime’ を ‘ncalls’ で割った値

cumtime

     この関数と全ての subfunction に消費された累積時間 (起動から終了まで
     )。この数字は再帰関数に 'ついても' 正確です。

percall

     ‘cumtime’ をプリミティブな呼び出し回数で割った値

filename:lineno(function)

     その関数のファイル名、行番号、関数名

最初の行に 2 つの数字がある場合 (たとえば ‘3/1’) は、関数が再帰的に呼び
出されたということです。2 つ目の数字はプリミティブな呼び出しの回数で、1
つ目の数字は総呼び出し回数です。関数が再帰的に呼び出されなかった場合、そ
れらは同じ値で数字は 1 つしか表示されないことに留意してください。

‘run()’ 関数でファイル名を指定することで、プロファイル実行の終了時に出力
を表示する代わりに、ファイルに保存することが出来ます。

     import cProfile
     import re
     cProfile.run('re.compile("foo|bar")', 'restats')

*note pstats.Stats: 40f7. クラスはファイルからプロファイルの結果を読み込
んで様々な書式に整えます。 ファイル *note cProfile: 20. と *note
profile: 9d. は他のスクリプトをプロファイルするためのスクリプトとして起
動することも出来ます。例えば:

     python -m cProfile [-o output_file] [-s sort_order] (-m module | myscript.py)

‘-o’ はプロファイルの結果を標準出力の代わりにファイルに書き出します。

‘-s’ は出力を *note sort_stats(): 40f9. で出力をソートする値を指定します
。‘-o’ がない場合に有効です。

‘-m’ specifies that a module is being profiled instead of a script.

Added in version 3.7: Added the ‘-m’ option to *note cProfile: 20.

Added in version 3.8: Added the ‘-m’ option to *note profile: 9d.

*note pstats: 9e. モジュールの *note Stats: 40f7. クラスにはプロファイル
結果のファイルに保存されているデータを処理して出力するための様々なメソッ
ドがあります。

     import pstats
     from pstats import SortKey
     p = pstats.Stats('restats')
     p.strip_dirs().sort_stats(-1).print_stats()

*note strip_dirs(): 40fa. メソッドによって全モジュール名から無関係なパス
が取り除かれました。*note sort_stats(): 40f9. メソッドにより、出力される
標準的な モジュール/行/名前 文字列にしたがって全項目がソートされました。
*note print_stats(): 40fb. メソッドによって全統計が出力されました。以下
のようなソート呼び出しを試すことができます:

     p.sort_stats(SortKey.NAME)
     p.print_stats()

最初の行ではリストを関数名でソートしています。2行目で情報を出力していま
す。さらに次の内容も試してください:

     p.sort_stats(SortKey.CUMULATIVE).print_stats(10)

このようにすると、関数が消費した累計時間でソートして、さらにその上位10件
だけを表示します。どのアルゴリズムが時間を多く消費しているのか知りたいと
きは、この方法が役に立つはずです。

ループで多くの時間を消費している関数はどれか調べたいときは、次のようにし
ます:

     p.sort_stats(SortKey.TIME).print_stats(10)

上記はそれぞれの関数で消費された時間でソートして、上位10件の関数の情報が
表示されます。

次の内容も試してください:

     p.sort_stats(SortKey.FILENAME).print_stats('__init__')

このようにするとファイル名でソートされ、そのうちクラスの初期化メソッド
(メソッド名 ‘__init__’) に関する統計情報だけが表示されます:

     p.sort_stats(SortKey.TIME, SortKey.CUMULATIVE).print_stats(.5, 'init')

上記は時間 (time) をプライマリキー、累計時間 (cumulative time) をセカン
ダリキーにしてソートした後でさらに条件を絞って統計情報を出力します。
‘.5’ は上位 50% だけを選択することを意味し、さらにその中から文字列
‘init’ を含むものだけが表示されます。

どの関数がどの関数を呼び出しているのかを知りたければ、次のようにします
(‘p’ は最後に実行したときの状態でソートされています):

     p.print_callers(.5, 'init')

このようにすると、関数ごとの呼び出し側関数の一覧が得られます。

さらに詳しい機能を知りたければマニュアルを読むか、次の関数の実行結果から
内容を推察してください:

     p.print_callees()
     p.add('restats')

スクリプトとして起動した場合、 *note pstats: 9e. モジュールはプロファイ
ルのダンプを読み込み、分析するための統計ブラウザとして動きます。シンプル
な行指向のインターフェース (*note cmd: 12. を使って実装) とヘルプ機能を
備えています。


File: python.info,  Node: リファレンスマニュアル -- profile と cProfile,  Next: Stats クラス,  Prev: かんたんユーザマニュアル,  Up: Python プロファイラ

5.27.5.3 リファレンスマニュアル - ‘profile’ と ‘cProfile’
.........................................................

*note profile: 9d. および *note cProfile: 20. モジュールは以下の関数を提
供します:

 -- の関数: profile.run (command, filename=None, sort=-1)

     この関数は *note exec(): 164. 関数に渡せる一つの引数と、オプション
     引数としてファイル名を指定できます。全ての場合でこのルーチンは以下
     を実行します:

          exec(command, __main__.__dict__, __main__.__dict__)

     そして実行結果からプロファイル情報を収集します。 ファイル名が指定さ
     れていない場合は、 *note Stats: 40f7. のインスタンスが自動的に作ら
     れ、簡単なプロファイルレポートが表示されます。 'sort' が指定されて
     いる場合は、 *note Stats: 40f7. インスタンスに渡され、結果をどのよ
     うに並び替えるかを制御します。

 -- の関数: profile.runctx (command, globals, locals, filename=None,
          sort=-1)

     This function is similar to *note run(): 40fd, with added arguments
     to supply the globals and locals mappings for the 'command' string.
     This routine executes:

          exec(command, globals, locals)

     そしてプロファイル統計情報を *note run(): 40fd. 同様に収集します。

 -- クラス: profile.Profile (timer=None, timeunit=0.0, subcalls=True,
          builtins=True)

     このクラスは普通、プロファイリングを ‘cProfile.run()’ 関数が提供す
     るもの以上に正確に制御したい場合にのみ使われます。

     'timer' 引数に、コードの実行時間を計測するためのカスタムな時刻取得
     用関数を渡せます。これは現在時刻を表す単一の数値を返す関数でなけれ
     ばなりません。もしこれが整数を返す関数ならば、 'timeunit' には単位
     時間当たりの実際の持続時間を指定します。たとえば関数が 1000 分の 1
     秒単位で計測した時間を返すとすると、 'timeunit' は ‘.001’ でしょう
     。

     *note Profile: 9b1. クラスを直接使うと、プロファイルデータをファイ
     ルに書き出すことなしに結果をフォーマット出来ます:

          import cProfile, pstats, io
          from pstats import SortKey
          pr = cProfile.Profile()
          pr.enable()
          # ... do something ...
          pr.disable()
          s = io.StringIO()
          sortby = SortKey.CUMULATIVE
          ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
          ps.print_stats()
          print(s.getvalue())

     The *note Profile: 9b1. class can also be used as a context manager
     (supported only in *note cProfile: 20. module.  see *note
     コンテキストマネージャ型: 1f20.):

          import cProfile

          with cProfile.Profile() as pr:
              # ... do something ...

              pr.print_stats()

     バージョン 3.8 で変更: コンテキストマネージャーサポートが追加されま
     した。

      -- メソッド: enable ()

          Start collecting profiling data.  Only in *note cProfile: 20.

      -- メソッド: disable ()

          Stop collecting profiling data.  Only in *note cProfile: 20.

      -- メソッド: create_stats ()

          プロファイリングデータの収集を停止し、現在のプロファイルとして
          結果を内部で記録します。

      -- メソッド: print_stats (sort=-1)

          現在のプロファイルに基づいて *note Stats: 40f7. オブジェクトを
          作成し、結果を標準出力に出力します。

          The 'sort' parameter specifies the sorting order of the
          displayed statistics.  It accepts a single key or a tuple of
          keys to enable multi-level sorting, as in *note
          Stats.sort_stats: 40f9.

          Added in version 3.13: *note print_stats(): 4102. now accepts
          a tuple of keys.

      -- メソッド: dump_stats (filename)

          現在のプロファイルの結果を 'filename' に書き出します。

      -- メソッド: run (cmd)

          *note exec(): 164. を用いて cmd をプロファイルします。

      -- メソッド: runctx (cmd, globals, locals)

          *note exec(): 164. を用いて指定されたグローバルおよびローカル
          な環境で cmd をプロファイルします。

      -- メソッド: runcall (func, /, *args, **kwargs)

          ‘func(*args, **kwargs)’ をプロファイルします。

Note that profiling will only work if the called command/function
actually returns.  If the interpreter is terminated (e.g.  via a *note
sys.exit(): 1318. call during the called command/function execution) no
profiling results will be printed.


File: python.info,  Node: Stats クラス,  Next: 決定論的プロファイリングとは,  Prev: リファレンスマニュアル -- profile と cProfile,  Up: Python プロファイラ

5.27.5.4 ‘Stats’ クラス
.......................

*note Stats: 40f7. クラスを使用してプロファイラデータを解析します。

 -- クラス: pstats.Stats (*filenames or profile, stream=sys.stdout)

     このコンストラクタは 'filename' で指定した (単一または複数の) ファ
     イルもしくは ‘Profile’ のインスタンスから "統計情報オブジェクト" の
     インスタンスを生成します。出力は 'stream' で指定したストリームに出
     力されます。

     上記コンストラクタで指定するファイルは、使用する *note Stats: 40f7.
     に対応したバージョンの *note profile: 9d. または *note cProfile:
     20. で作成されたものでなければなりません。将来のバージョンのプロフ
     ァイラとの互換性は '保証されておらず' 、他のプロファイラで生成され
     たファイルや異なるオペレーティングシステムで実行される同じプロファ
     イルとの互換性もないことに注意してください。複数のファイルを指定し
     た場合、同一の関数の統計情報はすべて合算され、複数のプロセスで構成
     される全体をひとつのレポートで検証することが可能になります。既存の
     *note Stats: 40f7. オブジェクトに別のファイルの情報を追加するときは
     、 *note add(): 4108. メソッドを使用します。

     プロファイルデータをファイルから読み込む代わりに、
     ‘cProfile.Profile’ または *note profile.Profile: 9b1. オブジェクト
     をプロファイルデータのソースとして使うことができます。

     *note Stats: 40f7. には次のメソッドがあります:

      -- メソッド: strip_dirs ()

          *note Stats: 40f7. クラスのこのメソッドは、ファイル名の前に付
          いているすべてのパス情報を取り除くためのものです。出力の幅を
          80文字以内に収めたいときに重宝します。このメソッドはオブジェク
          トを変更するため、取り除いたパス情報は失われます。パス情報除去
          の操作後、オブジェクトが保持するデータエントリは、オブジェクト
          の初期化、ロード直後と同じように "ランダムに" 並んでいます。
          *note strip_dirs(): 40fa. を実行した結果、2つの関数名が区別で
          きない (両者が同じファイルの同じ行番号で同じ関数名となった) 場
          合、一つのエントリに合算されされます。

      -- メソッド: add (*filenames)

          *note Stats: 40f7. クラスのこのメソッドは、既存のプロファイリ
          ングオブジェクトに情報を追加します。引数は対応するバージョンの
          *note profile.run(): 40fd. または ‘cProfile.run()’ によって生
          成されたファイルの名前でなくてはなりません。関数の名前が区別で
          きない (ファイル名、行番号、関数名が同じ) 場合、一つの関数の統
          計情報として合算されます。

      -- メソッド: dump_stats (filename)

          *note Stats: 40f7. オブジェクトに読み込まれたデータを、ファイ
          ル名 'filename' のファイルに保存します。ファイルが存在しない場
          合は新たに作成され、すでに存在する場合には上書きされます。この
          メソッドは *note profile.Profile: 9b1. クラスおよび
          ‘cProfile.Profile’ クラスの同名のメソッドと等価です。

      -- メソッド: sort_stats (*keys)

          This method modifies the *note Stats: 40f7. object by sorting
          it according to the supplied criteria.  The argument can be
          either a string or a SortKey enum identifying the basis of a
          sort (example: ‘'time'’, ‘'name'’, ‘SortKey.TIME’ or
          ‘SortKey.NAME’).  The SortKey enums argument have advantage
          over the string argument in that it is more robust and less
          error prone.

          2つ以上のキーが指定された場合、2つ目以降のキーは、それ以前のキ
          ーで等価となったデータエントリの再ソートに使われます。たとえば
          ‘sort_stats(SortKey.NAME, SortKey.FILE)’ とした場合、まずすべ
          てのエントリが関数名でソートされた後、同じ関数名で複数のエント
          リがあればファイル名でソートされます。

          For the string argument, abbreviations can be used for any key
          names, as long as the abbreviation is unambiguous.

          The following are the valid string and SortKey:

          Valid String Arg       Valid enum Arg            意味
                                                           
          ----------------------------------------------------------------------------
                                                           
          ‘'calls'’              SortKey.CALLS             呼び出し数
                                                           
                                                           
          ‘'cumulative'’         SortKey.CUMULATIVE        累積時間
                                                           
                                                           
          ‘'cumtime'’            N/A                       累積時間
                                                           
                                                           
          ‘'file'’               N/A                       ファイル名
                                                           
                                                           
          ‘'filename'’           SortKey.FILENAME          ファイル名
                                                           
                                                           
          ‘'module'’             N/A                       ファイル名
                                                           
                                                           
          ‘'ncalls'’             N/A                       呼び出し数
                                                           
                                                           
          ‘'pcalls'’             SortKey.PCALLS            プリミティブな呼び出し回
                                                           数
                                                           
                                                           
          ‘'line'’               SortKey.LINE              行番号
                                                           
                                                           
          ‘'name'’               SortKey.NAME              関数名
                                                           
                                                           
          ‘'nfl'’                SortKey.NFL               関数名/ファイル名/行番号
                                                           
                                                           
          ‘'stdname'’            SortKey.STDNAME           標準名
                                                           
                                                           
          ‘'time'’               SortKey.TIME              内部時間
                                                           
                                                           
          ‘'tottime'’            N/A                       内部時間
                                                           

          すべての統計情報のソート結果は降順 (最も多く時間を消費したもの
          が一番上に来る) となることに注意してください。ただし、関数名、
          ファイル名、行数に関しては昇順 (アルファベット順) になります。
          ‘SortKey.NFL’ と ‘SortKey.STDNAME’ には微妙な違いがあります。
          標準名 (standard name) とは表示された名前によるソートで、埋め
          込まれた行番号のソート順が特殊です。たとえば、 (ファイル名が同
          じで) 3、20、40という行番号のエントリがあった場合、20、3、40 の
          順に表示されます。一方 ‘SortKey.NFL’ は行番号を数値として比較
          します。要するに、 ‘sort_stats(SortKey.NFL)’ は
          ‘sort_stats(SortKey.NAME, SortKey.FILENAME, SortKey.LINE)’ と
          指定した場合と同じになります。

          後方互換性のため、数値を引数に使った ‘-1’, ‘0’, ‘1’, ‘2’ の形
          式もサポートしています。それぞれ ‘'stdname'’, ‘'calls'’,
          ‘'time'’, ‘'cumulative'’ として処理されます。引数をこの旧スタ
          イルで指定した場合、最初のキー (数値キー) だけが使われ、複数の
          キーを指定しても2番目以降は無視されます。

          Added in version 3.7: Added the SortKey enum.

      -- メソッド: reverse_order ()

          *note Stats: 40f7. クラスのこのメソッドは、オブジェクト内の情
          報のリストを逆順にソートします。デフォルトでは選択したキーに応
          じて昇順、降順が適切に選ばれることに注意してください。

      -- メソッド: print_stats (*restrictions)

          *note Stats: 40f7. クラスのこのメソッドは、 *note
          profile.run(): 40fd. の項で述べたプロファイルのレポートを出力
          します。

          出力するデータの順序はオブジェクトに対し最後に行った *note
          sort_stats(): 40f9. による操作に基づきます (*note add(): 4108.
          と *note strip_dirs(): 40fa. による制限にも支配されます)。

          引数は (もし与えられると) リストを重要なエントリのみに制限する
          ために使われます。初期段階でリストはプロファイルした関数の完全
          な情報を持っています。制限の指定は、 (行数を指定する) 整数、
          (行のパーセンテージを指定する) 0.0 から 1.0 までの割合を指定す
          る小数、 (出力する standard name にマッチする) 正規表現として
          解釈される文字列のいずれかを使って行います。複数の制限が指定さ
          れた場合、指定の順に適用されます。たとえば次のようになります:

               print_stats(.1, 'foo:')

          上記の場合まず出力するリストは全体の10%に制限され、さらにファ
          イル名の一部に文字列 ‘.*foo:’ を持つ関数だけが出力されます:

               print_stats('foo:', .1)

          こちらの例の場合、リストはまずファイル名に ‘.*foo:’ を持つ関数
          だけに制限され、その中の最初の 10% だけが出力されます。

      -- メソッド: print_callers (*restrictions)

          *note Stats: 40f7. クラスのこのメソッドは、プロファイルのデー
          タベースの中から何らかの関数呼び出しを行った関数をすべて出力し
          ます。出力の順序は *note print_stats(): 40fb. によって与えられ
          るものと同じです。出力を制限する引数も同じです。各呼び出し側関
          数についてそれぞれ一行ずつ表示されます。フォーマットは統計を作
          り出したプロファイラごとに微妙に異なります:

             * *note profile: 9d. の場合、呼び出し側関数の後に括弧で囲ま
               れて表示される数値はその呼び出しが何回行われたかを示して
               います。利便性のため、 2番目の括弧なしで表示される数値に
               よって、関数が消費した累積時間を表しています。

             * *note cProfile: 20. の場合、各呼び出し側関数の後に3つの数
               字が付きます。呼び出しが何回行われたかと、この呼び出し側
               関数からの呼び出しによって現在の関数内で消費された合計時
               間および累積時間です。

      -- メソッド: print_callees (*restrictions)

          *note Stats: 40f7. クラスのこのメソッドは、指定した関数から呼
          び出された関数のリストを出力します。呼び出し側、呼び出される側
          の方向は逆ですが、引数と出力の順序に関しては *note
          print_callers(): 410b. と同じです。

      -- メソッド: get_stats_profile ()

          This method returns an instance of StatsProfile, which
          contains a mapping of function names to instances of
          FunctionProfile.  Each FunctionProfile instance holds
          information related to the function's profile such as how long
          the function took to run, how many times it was called, etc...

          Added in version 3.9: Added the following dataclasses:
          StatsProfile, FunctionProfile.  Added the following function:
          get_stats_profile.


File: python.info,  Node: 決定論的プロファイリングとは,  Next: 制限事項<2>,  Prev: Stats クラス,  Up: Python プロファイラ

5.27.5.5 決定論的プロファイリングとは
.....................................

'決定論的プロファイリング' とは、すべての '関数呼び出し', '関数からのリ
ターン', '例外発生' をモニターし、正確なタイミングを記録することで、イベ
ント間の時間、つまりどの時間にユーザコードが実行されているのかを計測する
やり方です。もう一方の '統計的プロファイリング' (このモジュールでこの方
法は採用していません) とは、有効なインストラクションポインタからランダム
にサンプリングを行い、プログラムのどこで時間が使われているかを推定する方
法です。後者の方法は、オーバヘッドが少ないものの、プログラムのどこで多く
の時間が使われているか、その相対的な示唆に留まります。

Python の場合、実行中は必ずインタプリタが動作しているため、決定論的プロ
ファイリングを行うために計測用のコードを追加する必要はありません。
Python は自動的に各イベントに 'フック' (オプションのコールバック) を提供
します。加えて Python のインタプリタという性質によって、実行時に大きなオ
ーバーヘッドを伴う傾向がありますが、それに比べると一般的なアプリケーショ
ンでは決定論的プロファイリングで追加される処理のオーバーヘッドは少ない傾
向にあります。結果的に、決定論的プロファイリングは少ないコストで Python
プログラムの実行時間に関する詳細な統計を得られる方法となっているのです。

呼び出し回数はコード中のバグ発見にも使用できます (とんでもない数の呼び出
しが行われている部分)。インライン拡張の対象とすべき部分を見つけるために
も使えます (呼び出し頻度の高い部分)。内部時間の統計は、注意深く最適化す
べき"ホットループ"の発見にも役立ちます。累積時間の統計は、アルゴリズム選
択に関連した高レベルのエラー検知に役立ちます。なお、このプロファイラは再
帰的なアルゴリズム実装の累計時間を計ることが可能で、通常のループを使った
実装と直接比較することもできるようになっています。


File: python.info,  Node: 制限事項<2>,  Next: キャリブレーション 補正,  Prev: 決定論的プロファイリングとは,  Up: Python プロファイラ

5.27.5.6 制限事項
.................

一つの制限はタイミング情報の正確さに関するものです。決定論的プロファイラ
には正確さに関する根本的問題があります。最も明白な制限は、 (一般に) "ク
ロック"は .001 秒の精度しかないということです。これ以上の精度で計測する
ことはできません。仮に充分な精度が得られたとしても、"誤差"が計測の平均値
に影響を及ぼすことがあります。この最初の誤差を取り除いたとしても、それが
また別の誤差を引き起こす原因となります。

もう一つの問題として、イベントを検知してからプロファイラがその時刻を実際
に '取得' するまでに "いくらかの時間がかかる" ことです。同様に、イベント
ハンドラが終了する時にも、時刻を取得して (そしてその値を保存して) から、
ユーザコードが処理を再開するまでの間に遅延が発生します。結果的に多く呼び
出される関数または多数の関数から呼び出される関数の情報にはこの種の誤差が
蓄積する傾向にあります。このようにして蓄積される誤差は、典型的にはクロッ
クの精度を下回ります (1クロック以下) が、一方でこの時間が累計して非常に
大きな値になることも 'あり得ます' 。

この問題はオーバーヘッドの小さい *note cProfile: 20. よりも *note
profile: 9d. においてより重要です。そのため、 *note profile: 9d. は誤差
が確率的に (平均値で) 減少するようにプラットフォームごとに補正する機能を
備えています。プロファイラに補正を施すと (最小二乗の意味で) 正確さが増し
ますが、ときには数値が負の値になってしまうこともあります (呼び出し回数が
極めて少なく、確率の神があなたに意地悪をしたとき :-) )。プロファイルの結
果に負の値が出力されても '驚かないでください' 。これは補正を行った場合に
のみ生じることで、補正を行わない場合に比べて計測結果は実際にはより正確に
なっているはずだからです。


File: python.info,  Node: キャリブレーション 補正,  Next: カスタムな時刻取得用関数を使う,  Prev: 制限事項<2>,  Up: Python プロファイラ

5.27.5.7 キャリブレーション (補正)
..................................

*note profile: 9d. のプロファイラは time 関数呼び出しおよびその値を保存
するためのオーバーヘッドを補正するために、各イベントの処理時間から定数を
引きます。デフォルトでこの定数の値は 0 です。以下の手順で、プラットフォ
ームに合った、より適切な定数が得られます (*note 制限事項: 4111. 参照)。

     import profile
     pr = profile.Profile()
     for i in range(5):
         print(pr.calibrate(10000))

calibrate メソッドは引数として与えられた数だけ Python の呼び出しを行いま
す。直接呼び出す場合と、プロファイラを使って呼び出す場合の両方が実施され
、それぞれの時間が計測されます。その結果、プロファイラのイベントに隠され
たオーバーヘッドが計算され、その値は浮動小数として返されます。たとえば、
1.8 GHz の Intel Core i5 で macOS を使用、 Python の time.process_time()
をタイマとして使った場合、値はおよそ 4.04e-6 となります。

この手順で使用しているオブジェクトはほぼ一定の結果を返します。 '非常に'
早いコンピュータを使う場合、もしくはタイマの性能が貧弱な場合は、一定の結
果を得るために引数に 100000 や 1000000 といった大きな値を指定する必要が
あるかもしれません。

一定の結果が得られたら、それを使う方法には3通りあります:

     import profile

     # 1. Apply computed bias to all Profile instances created hereafter.
     profile.Profile.bias = your_computed_bias

     # 2. Apply computed bias to a specific Profile instance.
     pr = profile.Profile()
     pr.bias = your_computed_bias

     # 3. Specify computed bias in instance constructor.
     pr = profile.Profile(bias=your_computed_bias)

選択肢がある場合は、補正値は小さめに設定した方が良いでしょう。プロファイ
ルの結果に負の値が表われる"頻度が低く"なるはずです。


File: python.info,  Node: カスタムな時刻取得用関数を使う,  Prev: キャリブレーション 補正,  Up: Python プロファイラ

5.27.5.8 カスタムな時刻取得用関数を使う
.......................................

プロファイラが時刻を取得する方法を変更したいなら (たとえば、実測時間やプ
ロセスの経過時間を使いたい場合)、時刻取得用の関数を ‘Profile’ クラスのコ
ンストラクタに指定することができます:

     pr = profile.Profile(your_time_func)

この結果生成されるプロファイラは時刻取得に ‘your_time_func()’ を呼び出す
ようになります。 *note profile.Profile: 9b1. と ‘cProfile.Profile’ のど
ちらを使っているかにより、 ‘your_time_func’ の戻り値は異なって解釈されま
す:

*note profile.Profile: 9b1.

     ‘your_time_func()’ は単一の数値、あるいは (*note os.times(): 10e8.
     と同じように) その合計が累計時間を示すリストを返すようになっていな
     ければなりません。関数が1つの数値、あるいは長さ2の数値のリストを返
     すようになっていれば、ディスパッチルーチンには特別な高速化バージョ
     ンが使われます。

     Be warned that you should calibrate the profiler class for the
     timer function that you choose (see *note キャリブレーション
     (補正): 4113.).  For most machines, a timer that returns a lone
     integer value will provide the best results in terms of low
     overhead during profiling.  (*note os.times(): 10e8. is 'pretty'
     bad, as it returns a tuple of floating-point values).  If you want
     to substitute a better timer in the cleanest fashion, derive a
     class and hardwire a replacement dispatch method that best handles
     your timer call, along with the appropriate calibration constant.

‘cProfile.Profile’

     ‘your_time_func()’ は単一の数値を返すようになっていなければなりませ
     ん。単一の整数を返すのであれば、クラスコンストラクタの第二引数に単
     位時間当たりの実際の持続時間を渡せます。例えば
     ‘your_integer_time_func’ が 1000 分の 1 秒単位で計測した時間を返す
     とすると、 ‘Profile’ インスタンスを以下のように構築出来ます:

          pr = cProfile.Profile(your_integer_time_func, 0.001)

     As the ‘cProfile.Profile’ class cannot be calibrated, custom timer
     functions should be used with care and should be as fast as
     possible.  For the best results with a custom timer, it might be
     necessary to hard-code it in the C source of the internal ‘_lsprof’
     module.

Python 3.3 で *note time: d7. に、プロセス時間や実時間の精密な計測に使え
る新しい関数が追加されました。 例えば、 *note time.perf_counter(): a56.
を参照してください。


File: python.info,  Node: timeit --- 小さなコードスニペットの実行時間計測,  Next: trace --- Python 文実行のトレースと追跡,  Prev: Python プロファイラ,  Up: デバッグとプロファイル

5.27.6 ‘timeit’ -- 小さなコードスニペットの実行時間計測
-------------------------------------------------------

'ソースコード:' Lib/timeit.py(1)

__________________________________________________________________

このモジュールは小さい Python コードをの時間を計測するシンプルな手段を提
供しています。*note コマンドラインインターフェイス: 4118. の他 *note
呼び出しも可能: 4119. です。このモジュールは実行時間を計測するときに共通
するいくつかの罠を回避します。O'Reilly 出版の 'Python Cookbook' 第2版に
ある、Tim Peter による "Algorithms" 章も参照してください。

* Menu:

* 基本的な例: 基本的な例<3>.
* Python インターフェイス::
* コマンドラインインターフェイス: コマンドラインインターフェイス<6>.
* 使用例: 使用例<43>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/timeit.py


File: python.info,  Node: 基本的な例<3>,  Next: Python インターフェイス,  Up: timeit --- 小さなコードスニペットの実行時間計測

5.27.6.1 基本的な例
...................

次の例は *note コマンドラインインターフェイス: 4118. を使って 3 つの異な
る式の時間を測定する方法を示しています。

     $ python -m timeit "'-'.join(str(n) for n in range(100))"
     10000 loops, best of 5: 30.2 usec per loop
     $ python -m timeit "'-'.join([str(n) for n in range(100)])"
     10000 loops, best of 5: 27.5 usec per loop
     $ python -m timeit "'-'.join(map(str, range(100)))"
     10000 loops, best of 5: 23.2 usec per loop

同じ事を *note Python インターフェイス: 4119. を使って実現することもでき
ます:

     >>> import timeit
     >>> timeit.timeit('"-".join(str(n) for n in range(100))', number=10000)
     0.3018611848820001
     >>> timeit.timeit('"-".join([str(n) for n in range(100)])', number=10000)
     0.2727368790656328
     >>> timeit.timeit('"-".join(map(str, range(100)))', number=10000)
     0.23702679807320237

呼び出し可能オブジェクトは *note Python インターフェイス: 4119. から渡す
こともできます:

     >>> timeit.timeit(lambda: "-".join(map(str, range(100))), number=10000)
     0.19665591977536678

ただし、*note timeit(): e49. はコマンドラインインターフェイスを使った時
だけ繰り返し回数を自動で決定する事に注意してください。*note 使用例:
411b. 節でより高度な例を説明しています。


File: python.info,  Node: Python インターフェイス,  Next: コマンドラインインターフェイス<6>,  Prev: 基本的な例<3>,  Up: timeit --- 小さなコードスニペットの実行時間計測

5.27.6.2 Python インターフェイス
................................

このモジュールは 3 つの有用な関数と 1 つの公開クラスを持っています:

 -- の関数: timeit.timeit (stmt='pass', setup='pass', timer=<default
          timer>, number=1000000, globals=None)

     与えられた文、'setup' コードおよび 'timer' 関数で *note Timer:
     146d. インスタンスを作成し、その *note timeit(): cbb. メソッドを
     'number' 回実行します。 任意の 'globals' 引数はコードを実行する名前
     空間を指定します。

     バージョン 3.5 で変更: 任意の 'globals' 引数が追加されました。

 -- の関数: timeit.repeat (stmt='pass', setup='pass', timer=<default
          timer>, repeat=5, number=1000000, globals=None)

     与えられた文、'setup' コードおよび 'timer' 関数で *note Timer:
     146d. インスタンスを作成し、その *note repeat(): 411e. メソッドを
     'repeat' 回繰り返すのを 'number' 回実行します。 任意の 'globals' 引
     数はコードを実行する名前空間を指定します。

     バージョン 3.5 で変更: 任意の 'globals' 引数が追加されました。

     バージョン 3.7 で変更: 'repeat' のデフォルト値が 3 から 5 へ変更さ
     れました。

 -- の関数: timeit.default_timer ()

     浮動小数点数の秒数を返すデフォルトのタイマーで、常に
     time.perf_counter() でとなります。代わりに、 time.perf_counter_ns は
     整数のナノ秒を返します。

     バージョン 3.3 で変更: デフォルトのタイマーが *note
     time.perf_counter(): a56. になりました。

 -- クラス: timeit.Timer (stmt='pass', setup='pass', timer=<timer
          function>, globals=None)

     小さなコード片の実行時間を計測するためのクラスです。

     コンストラクターは計測する文、セットアップのための追加の文、ならび
     にタイマー関数を取ります。 両文のデフォルトは ‘'pass'’ です。 タイ
     マー関数はプラットフォーム依存です (モジュールの doctring を参照)。
     'stmt' および 'setup' には、複数行の文字列リテラルを含まない限り、
     ‘;’ や改行で区切られた複数の文でも構いません。 デフォルトでは文は
     timeit の名前空間内で実行されます。 この挙動は名前空間を 'globals'
     に渡すことで制御出来ます。

     最初の命令文の実行時間を計測するには、*note timeit(): cbb. メソッド
     を使用します。*note repeat(): 411e. と *note autorange(): cba. メソ
     ッドは *note timeit(): cbb. を複数回呼び出したい時に使用します。

     'setup' の実行時間は全実行時間から除外されています。

     'stmt' および 'setup' パラメータは、引数なしの呼び出し可能オブジェ
     クトをとることもできます。呼び出し可能オブジェクトを指定すると、そ
     のオブジェクトの呼び出しがタイマー関数に埋め込まれ、その関数が
     *note timeit(): cbb. メソッドによって実行されます。この場合、関数呼
     び出しが増えるためにタイミングのオーバーヘッドが少し増える点に注意
     してください。

     バージョン 3.5 で変更: 任意の 'globals' 引数が追加されました。

      -- メソッド: timeit (number=1000000)

          メイン文を 'number' 回実行した時間を計測します。このメソッドは
          セットアップ文を1回だけ実行し、メイン文を指定回数実行するのに
          かかった時間を返します。デフォルトのタイマーは秒数を浮動小数点
          数で返します。引数はループを何回実行するかの指定で、デフォルト
          値は 100万回です。メイン文、セットアップ文、タイマー関数はコン
          ストラクターで指定されたものを使用します。

               注釈: デフォルトでは、*note timeit(): cbb. は計測中、一時
               的に *note ガベージコレクション: 1884. を停止します。 こ
               の手法の利点は個々の計測結果がより比較しやすくなることで
               す。 欠点は、ガベージコレクションが計測される関数の性能の
               重要な要素である場合があることです。 その場合、'setup' 文
               字列の最初の文でガベージコレクションを有効にできます。 以
               下に例を示します:

                    timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit()

      -- メソッド: autorange (callback=None)

          *note timeit(): cbb. を呼び出す回数を自動的に決定します。

          これは総時間が0.2秒以上になるように *note timeit(): cbb. を繰
          り返し呼び出す便利な関数で、最終的な結果（ループ回数、ループ回
          数に要した時間）を返します。 要した時間が少なくとも0.2秒になる
          まで、シーケンス1, 2, 5, 10, 20, 50, ...  から増加する回数で
          *note timeit(): cbb. を呼び出します。

          'callback' が与えられ、Noneでない場合は、 callback(number,
          time_taken) という2つの引数を指定して試行された後に呼び出され
          ます。

          Added in version 3.6.

      -- メソッド: repeat (repeat=5, number=1000000)

          *note timeit(): cbb. を複数回繰り返します。

          これは *note timeit(): cbb. を繰り返し呼び出したい時に有用で、
          結果をリストにして返します。最初の引数で何回 *note timeit():
          cbb. を呼ぶか指定します。第 2 引数で *note timeit(): cbb. の引
          数 'number' を指定します。

               注釈: 結果のベクトルから平均値や標準偏差を計算して出力さ
               せたいと思うかもしれませんが、それはあまり意味がありませ
               ん。多くの場合、最も低い値がそのマシンが与えられたコード
               断片を実行する場合の下限値です。結果のうち高めの値は、
               Python のスピードが一定しないために生じたものではなく、そ
               の他の計測精度に影響を及ぼすプロセスによるものです。した
               がって、結果のうち *note min(): ed3. だけが見るべき値とな
               るでしょう。この点を押さえた上で、統計的な分析よりも常識
               的な判断で結果を見るようにしてください。

          バージョン 3.7 で変更: 'repeat' のデフォルト値が 3 から 5 へ変
          更されました。

      -- メソッド: print_exc (file=None)

          計測対象コードのトレースバックを出力するためのヘルパーです。

          利用例:

               t = Timer(...)       # outside the try/except
               try:
                   t.timeit(...)    # or t.repeat(...)
               except Exception:
                   t.print_exc()

          これの標準のトレースバックより優れた点は、コンパイルしたテンプ
          レートのソース行が表示されることです。オプションの引数 'file'
          にはトレースバックの出力先を指定します。デフォルトは *note
          sys.stderr: 907. になります。


File: python.info,  Node: コマンドラインインターフェイス<6>,  Next: 使用例<43>,  Prev: Python インターフェイス,  Up: timeit --- 小さなコードスニペットの実行時間計測

5.27.6.3 コマンドラインインターフェイス
.......................................

コマンドラインからプログラムとして呼び出す場合は、次の書式を使います:

     python -m timeit [-n N] [-r N] [-u U] [-s S] [-p] [-v] [-h] [statement ...]

以下のオプションが使用できます:

 -- Option: -n N, --number=N

     'statement' を実行する回数

 -- Option: -r N, --repeat=N

     timer を繰り返す回数（デフォルトは5）

 -- Option: -s S, --setup=S

     最初に1回だけ実行する文 (デフォルトは ‘pass’)

 -- Option: -p, --process

     デフォルトの *note time.perf_counter(): a56. の代わり *note
     time.process_time(): a57. を利用して、実時間ではなくプロセス時間を
     計測します

     Added in version 3.3.

 -- Option: -u, --unit=U

     timer 出力の時間の単位を指定します。 ‘nsec’、‘usec’、‘msec’、‘sec’
     を選択できます。

     Added in version 3.5.

 -- Option: -v, --verbose

     時間計測の結果をそのまま詳細な数値でくり返し表示する

 -- Option: -h, --help

     簡単な使い方を表示して終了する

文は複数行指定することもできます。その場合、各行は独立した文として引数に
指定されたものとして処理します。クォートと行頭のスペースを使って、インデ
ントした文を使うことも可能です。この複数行のオプションは *note -s: 4126.
においても同じ形式で指定可能です。

オプション *note -n: 4122. でループの回数が指定されていない場合、1, 2,
5, 10, 20, 50, ...  という数列で、少なくとも総時間が 0.2 秒になるまで回
数を増やしていって、適切なループ回数が計算されます。

*note default_timer(): 411f. の測定値は、同じマシン上で実行されている他
のプログラムの影響を受ける可能性があるため、正確な時間計測が必要な場合は
、計測を数回繰り返し、最適な時間を使用することをおすすめします。 *note
-r: 4124. オプションはこれに適しています。ほとんどの場合、デフォルトの
5回の繰り返しで十分でしょう。 *note time.process_time(): a57. を使用すれ
ばCPU時間を測定できます。

     注釈: pass 文の実行には基本的なオーバーヘッドが存在します。ここにあ
     るコードはこの事実を隠そうとはしていませんが、注意する必要がありま
     す。基本的なオーバーヘッドは引数なしでプログラムを起動することによ
     り計測でき、それは Python のバージョンによって異なるでしょう。


File: python.info,  Node: 使用例<43>,  Prev: コマンドラインインターフェイス<6>,  Up: timeit --- 小さなコードスニペットの実行時間計測

5.27.6.4 使用例
...............

最初に 1 回だけ実行されるセットアップ文を指定することが可能です:

     $ python -m timeit -s "text = 'sample string'; char = 'g'" "char in text"
     5000000 loops, best of 5: 0.0877 usec per loop
     $ python -m timeit -s "text = 'sample string'; char = 'g'" "text.find(char)"
     1000000 loops, best of 5: 0.342 usec per loop

出力には、3つのフィールドがあります。ループ回数は、ループの反復ごとに何
回文の内容が実行されたかを示します。反復回数 ('best of 5') は計時ループ
が何回繰り返されたかを示し、最後に文の内容が平均して計時ループの中の最良
の反復で要した時間を示します。つまり、最速の反復をループ回数で割った時間
です。

     >>> import timeit
     >>> timeit.timeit('char in text', setup='text = "sample string"; char = "g"')
     0.41440500499993504
     >>> timeit.timeit('text.find(char)', setup='text = "sample string"; char = "g"')
     1.7246671520006203

同じことは *note Timer: 146d. クラスとそのメソッドを使用して行うこともで
きます:

     >>> import timeit
     >>> t = timeit.Timer('char in text', setup='text = "sample string"; char = "g"')
     >>> t.timeit()
     0.3955516149999312
     >>> t.repeat()
     [0.40183617287970225, 0.37027556854118704, 0.38344867356679524, 0.3712595970846668, 0.37866875250654886]

以下の例は、複数行を含んだ式を計測する方法を示しています。ここでは、オブ
ジェクトの存在する属性と存在しない属性に対してテストするために *note
hasattr(): 49e. と *note try: 6b4./*note except: 170. を使用した場合のコ
ストを比較しています:

     $ python -m timeit "try:" "  str.__bool__" "except AttributeError:" "  pass"
     20000 loops, best of 5: 15.7 usec per loop
     $ python -m timeit "if hasattr(str, '__bool__'): pass"
     50000 loops, best of 5: 4.26 usec per loop

     $ python -m timeit "try:" "  int.__bool__" "except AttributeError:" "  pass"
     200000 loops, best of 5: 1.43 usec per loop
     $ python -m timeit "if hasattr(int, '__bool__'): pass"
     100000 loops, best of 5: 2.23 usec per loop

     >>> import timeit
     >>> # attribute is missing
     >>> s = """\
     ... try:
     ...     str.__bool__
     ... except AttributeError:
     ...     pass
     ... """
     >>> timeit.timeit(stmt=s, number=100000)
     0.9138244460009446
     >>> s = "if hasattr(str, '__bool__'): pass"
     >>> timeit.timeit(stmt=s, number=100000)
     0.5829014980008651
     >>>
     >>> # attribute is present
     >>> s = """\
     ... try:
     ...     int.__bool__
     ... except AttributeError:
     ...     pass
     ... """
     >>> timeit.timeit(stmt=s, number=100000)
     0.04215312199994514
     >>> s = "if hasattr(int, '__bool__'): pass"
     >>> timeit.timeit(stmt=s, number=100000)
     0.08588060699912603

定義した関数に *note timeit: d8. モジュールがアクセスできるようにするた
めに、 import 文の入った 'setup' パラメータを渡すことができます:

     def test():
         """Stupid test function"""
         L = [i for i in range(100)]

     if __name__ == '__main__':
         import timeit
         print(timeit.timeit("test()", setup="from __main__ import test"))

他のオプションは *note globals(): 17d2. を 'globals' 引数に渡すことです
。 これによりコードはあなたのグローバル名前空間内で実行されます。 これは
それぞれでインポートするより 便利です:

     def f(x):
         return x**2
     def g(x):
         return x**4
     def h(x):
         return x**8

     import timeit
     print(timeit.timeit('[func(42) for func in (f,g,h)]', globals=globals()))


File: python.info,  Node: trace --- Python 文実行のトレースと追跡,  Next: tracemalloc --- メモリ割り当ての追跡,  Prev: timeit --- 小さなコードスニペットの実行時間計測,  Up: デバッグとプロファイル

5.27.7 ‘trace’ -- Python 文実行のトレースと追跡
-----------------------------------------------

'ソースコード:' Lib/trace.py(1)

__________________________________________________________________

*note trace: e6. モジュールにより、プログラム実行のトレース、 注釈された
文のカバレッジの一覧の作成、呼び出し元/呼び出し先の関係の出力、プログラ
ム実行中に実行された関数の表の作成を行うことができます。 これは別のプロ
グラム中やコマンドラインから利用することができます。

参考
....

Coverage.py(2)

     サードパーティの人気なカバレッジツールで、 HTML 出力に加えて分岐カ
     バレッジのような高度な機能も提供しています。

* Menu:

* コマンドラインからの使用: コマンドラインからの使用<3>.
* プログラミングインターフェース::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/trace.py

   (2) https://coverage.readthedocs.io/


File: python.info,  Node: コマンドラインからの使用<3>,  Next: プログラミングインターフェース,  Up: trace --- Python 文実行のトレースと追跡

5.27.7.1 コマンドラインからの使用
.................................

*note trace: e6. モジュールはコマンドラインから起動することができます。
これは次のように簡単です

     python -m trace --count -C . somefile.py ...

これで、 ‘somefile.py’ の実行中に import された Python モジュールの注釈
付きリストがカレントディレクトリに生成されます。

 -- Option: --help

     使い方を表示して終了します。

 -- Option: --version

     モジュールのバージョンを表示して終了します。

Added in version 3.8: 実行可能なモジュールを走らせられる ‘--module’ オプ
ションが追加されました。

* Menu:

* 主要なオプション::
* 修飾的オプション::
* フィルターオプション::


File: python.info,  Node: 主要なオプション,  Next: 修飾的オプション,  Up: コマンドラインからの使用<3>

5.27.7.2 主要なオプション
.........................

*note trace: e6. を実行するときには、以下のオプションの少なくとも 1 つを
指定しなければいけません。 *note -listfuncs: 4138. オプションは、 *note
-trace: 4139. オプション、 *note -count: 413a. オプションと相互排他的で
す。 *note -listfuncs: 4138. が与えられたとき、 *note -trace: 4139. オプ
ション、 *note -count: 413a. オプションの両方とも受け付けず、他の場合も
同様です。

 -- Option: -c, --count

     プログラム完了時に、それぞれの文が何回実行されたかを示す注釈付きリ
     ストのファイルを生成します。下記の *note -coverdir: 413c, *note
     -file: 413d, *note -no-report: 413e. も参照してください。

 -- Option: -t, --trace

     実行された通りに行を表示します。

 -- Option: -l, --listfuncs

     プログラム実行の際に実行された関数を表示します。

 -- Option: -r, --report

     *note -count: 413a. と *note -file: 413d. 引数を使った過去のプログ
     ラム実行結果から、注釈付きリストのファイルを生成します。コードを実
     行するわけではありません。

 -- Option: -T, --trackcalls

     プログラム実行によって明らかになった呼び出しの関係を表示します。


File: python.info,  Node: 修飾的オプション,  Next: フィルターオプション,  Prev: 主要なオプション,  Up: コマンドラインからの使用<3>

5.27.7.3 修飾的オプション
.........................

 -- Option: -f, --file=<file>

     複数回にわたるトレース実行についてカウント (count) を累積するファイ
     ルに名前をつけます。 *note -count: 413a. オプションと一緒に使って下
     さい。

 -- Option: -C, --coverdir=<dir>

     レポートファイルを保存するディレクトリを指定します。
     ‘package.module’ についてのカバレッジレポートは
     ‘`dir'/`package'/`module'.cover’ に書き込まれます。

 -- Option: -m, --missing

     注釈付きリストの生成時に、実行されなかった行に ‘>>>>>>’ の印を付け
     ます。

 -- Option: -s, --summary

     *note -count: 413a. または *note -report: 4141. の利用時に、処理さ
     れたファイルそれぞれの簡潔な概要を標準出力 (stdout) に書き出します
     。

 -- Option: -R, --no-report

     注釈付きリストを生成しません。これは *note -count: 413a. を何度か走
     らせてから最後に単一の注釈付きリストを生成するような場合に便利です
     。

 -- Option: -g, --timing

     各行の先頭にプログラム開始からの時間を付けます。トレース中にだけ使
     われます。


File: python.info,  Node: フィルターオプション,  Prev: 修飾的オプション,  Up: コマンドラインからの使用<3>

5.27.7.4 フィルターオプション
.............................

これらのオプションは複数回指定できます。

 -- Option: --ignore-module=<mod>

     指定されたモジュールと（パッケージだった場合は）そのサブモジュール
     を無視します。引数はカンマ区切りのモジュール名リストです。

 -- Option: --ignore-dir=<dir>

     指定されたディレクトリとサブディレクトリ中のモジュールとパッケージ
     を全て無視します。引数は *note os.pathsep: 1cae. で区切られたディレ
     クトリのリストです。


File: python.info,  Node: プログラミングインターフェース,  Prev: コマンドラインからの使用<3>,  Up: trace --- Python 文実行のトレースと追跡

5.27.7.5 プログラミングインターフェース
.......................................

 -- クラス: trace.Trace (count=1, trace=1, countfuncs=0, countcallers=0,
          ignoremods=(), ignoredirs=(), infile=None, outfile=None,
          timing=False)

     文 (statement) や式 (expression) の実行をトレースするオブジェクトを
     作成します。引数は全てオプションです。'count' は行数を数えます。
     'trace' は行実行のトレースを行います。'countfuncs' は実行中に呼ばれ
     た関数を列挙します。'countcallers' は呼び出しの関係を追跡します。
     'ignoremods' は無視するモジュールやパッケージのリストです。
     'ignoredirs' は無視するパッケージやモジュールを含むディレクトリのリ
     ストです。'infile' は保存された集計 (count) 情報を読むファイルの名
     前です。'outfile' は更新された集計 (count) 情報を書き出すファイルの
     名前です。'timing' は、タイムスタンプをトレース開始時点からの相対秒
     数で表示します。

      -- メソッド: run (cmd)

          コマンドを実行して、現在のトレースパラメータに基づいてその実行
          から統計情報を集めます。 'cmd' は、 *note exec(): 164. に渡せ
          るような文字列か code オブジェクトです。

      -- メソッド: runctx (cmd, globals=None, locals=None)

          指定された globals と locals 環境下で、コマンドを実行して、現
          在のトレースパラメータに基づいてその実行から統計情報を集めます
          。定義しない場合、'globals' と 'locals' はデフォルトで空の辞書
          となります。

      -- メソッド: runfunc (func, /, *args, **kwds)

          与えられた引数の 'func' を、 *note Trace: 4154. オブジェクトの
          コントロール下で現在のトレースパラメタのもとに呼び出します。

      -- メソッド: results ()

          与えられた *note Trace: 4154. インスタンスの ‘run’, ‘runctx’,
          ‘runfunc’ の以前の呼び出しについて集計した結果を納めた *note
          CoverageResults: 4158. オブジェクトを返します。蓄積されたトレ
          ース結果はリセットしません。

 -- クラス: trace.CoverageResults

     カバレッジ結果のコンテナで、 *note Trace.results(): 4157. で生成さ
     れるものです。ユーザーが直接生成するものではありません。

      -- メソッド: update (other)

          別の *note CoverageResults: 4158. オブジェクトのデータを統合し
          ます。

      -- メソッド: write_results (show_missing=True, summary=False,
               coverdir=None, *, ignore_missing_files=False)

          カバレッジ結果を書き出します。ヒットしなかった行も出力するには
          'show_missing' を指定します。モジュールごとの概要を出力に含め
          るには 'summary' を指定します。'coverdir' に指定するのは結果フ
          ァイルを出力するディレクトリです。‘None’ の場合は各ソースファ
          イルごとの結果がそれぞれのディレクトリに置かれます。

          'ignore_missing_files' が ‘True’ の場合には、すでに存在しない
          ファイルのカバレッジカウントはサイレントに無視されます。そうで
          なければ、ファイルが見つからないと *note FileNotFoundError:
          e8f. が発生します。

          バージョン 3.13 で変更: 'ignore_missing_files' 引数が追加され
          ました。

簡単な例でプログラミングインターフェースの使い方を見てみましょう:

     import sys
     import trace

     # create a Trace object, telling it what to ignore, and whether to
     # do tracing or line-counting or both.
     tracer = trace.Trace(
         ignoredirs=[sys.prefix, sys.exec_prefix],
         trace=0,
         count=1)

     # run the new command using the given tracer
     tracer.run('main()')

     # make a report, placing output in the current directory
     r = tracer.results()
     r.write_results(show_missing=True, coverdir=".")


File: python.info,  Node: tracemalloc --- メモリ割り当ての追跡,  Prev: trace --- Python 文実行のトレースと追跡,  Up: デバッグとプロファイル

5.27.8 ‘tracemalloc’ -- メモリ割り当ての追跡
--------------------------------------------

Added in version 3.4.

'ソースコード:' Lib/tracemalloc.py(1)

__________________________________________________________________

tracemallocモジュールは、Python が割り当てたメモリブロックをトレースする
ためのデバッグツールです。このモジュールは以下の情報を提供します。

   * オブジェクトが割り当てられた場所のトレースバック

   * ファイル名ごと、及び行ごとに割り当てられたメモリブロックの以下の統
     計を取ります：総サイズ、ブロック数、割り当てられたブロックの平均サ
     イズ

   * メモリリークを検出するために2つのスナップショットの差を計算します。

Python が割り当てたメモリブロックの大半をトレースするには、 *note
PYTHONTRACEMALLOC: 1ca6. 環境変数を ‘1’ に設定して可能な限り早くモジュー
ルを開始させるか、*note -X: 15c. ‘tracemalloc’ コマンドラインオプション
を使用してください。実行時に *note tracemalloc.start(): 1ca5. を呼んで
Python のメモリ割り当てのトレースを開始することが出来ます。

デフォルトでは、割り当てられたメモリブロック1つのトレースは最新1フレーム
を保存します。開始時に25フレームを保存するには、 *note
PYTHONTRACEMALLOC: 1ca6. 環境変数を ‘25’ に設定するか、*note -X: 15c.
‘tracemalloc=25’ コマンドラインオプションを使用してください。

* Menu:

* 使用例: 使用例<44>.
* API::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tracemalloc.py


File: python.info,  Node: 使用例<44>,  Next: API,  Up: tracemalloc --- メモリ割り当ての追跡

5.27.8.1 使用例
...............

* Menu:

* 上位10を表示する::
* 差を計算する::
* メモリブロックのトレースバックを取得する::
* top を整形化する::


File: python.info,  Node: 上位10を表示する,  Next: 差を計算する,  Up: 使用例<44>

5.27.8.2 上位10を表示する
.........................

最も多くのメモリを割り当てているファイル10を表示します:

     import tracemalloc

     tracemalloc.start()

     # ... run your application ...

     snapshot = tracemalloc.take_snapshot()
     top_stats = snapshot.statistics('lineno')

     print("[ Top 10 ]")
     for stat in top_stats[:10]:
         print(stat)

Python テストスイートの出力例です:

     [ Top 10 ]
     <frozen importlib._bootstrap>:716: size=4855 KiB, count=39328, average=126 B
     <frozen importlib._bootstrap>:284: size=521 KiB, count=3199, average=167 B
     /usr/lib/python3.4/collections/__init__.py:368: size=244 KiB, count=2315, average=108 B
     /usr/lib/python3.4/unittest/case.py:381: size=185 KiB, count=779, average=243 B
     /usr/lib/python3.4/unittest/case.py:402: size=154 KiB, count=378, average=416 B
     /usr/lib/python3.4/abc.py:133: size=88.7 KiB, count=347, average=262 B
     <frozen importlib._bootstrap>:1446: size=70.4 KiB, count=911, average=79 B
     <frozen importlib._bootstrap>:1454: size=52.0 KiB, count=25, average=2131 B
     <string>:5: size=49.7 KiB, count=148, average=344 B
     /usr/lib/python3.4/sysconfig.py:411: size=48.0 KiB, count=1, average=48.0 KiB

Python がモジュールから ‘4855 KiB’ のデータ (バイトコードで定数) を読み
込んでいることと、*note collections: 16. モジュールが *note namedtuple:
1ac. 型をビルドするのに ‘244 KiB’ を割り当てていることが分かります。

オプションの詳細については *note Snapshot.statistics(): 415f. を参照して
ください。


File: python.info,  Node: 差を計算する,  Next: メモリブロックのトレースバックを取得する,  Prev: 上位10を表示する,  Up: 使用例<44>

5.27.8.3 差を計算する
.....................

スナップショットを2つ取り、差を表示します:

     import tracemalloc
     tracemalloc.start()
     # ... start your application ...

     snapshot1 = tracemalloc.take_snapshot()
     # ... call the function leaking memory ...
     snapshot2 = tracemalloc.take_snapshot()

     top_stats = snapshot2.compare_to(snapshot1, 'lineno')

     print("[ Top 10 differences ]")
     for stat in top_stats[:10]:
         print(stat)

Python テストスイートのテストを実行する前後の出力例です:

     [ Top 10 differences ]
     <frozen importlib._bootstrap>:716: size=8173 KiB (+4428 KiB), count=71332 (+39369), average=117 B
     /usr/lib/python3.4/linecache.py:127: size=940 KiB (+940 KiB), count=8106 (+8106), average=119 B
     /usr/lib/python3.4/unittest/case.py:571: size=298 KiB (+298 KiB), count=589 (+589), average=519 B
     <frozen importlib._bootstrap>:284: size=1005 KiB (+166 KiB), count=7423 (+1526), average=139 B
     /usr/lib/python3.4/mimetypes.py:217: size=112 KiB (+112 KiB), count=1334 (+1334), average=86 B
     /usr/lib/python3.4/http/server.py:848: size=96.0 KiB (+96.0 KiB), count=1 (+1), average=96.0 KiB
     /usr/lib/python3.4/inspect.py:1465: size=83.5 KiB (+83.5 KiB), count=109 (+109), average=784 B
     /usr/lib/python3.4/unittest/mock.py:491: size=77.7 KiB (+77.7 KiB), count=143 (+143), average=557 B
     /usr/lib/python3.4/urllib/parse.py:476: size=71.8 KiB (+71.8 KiB), count=969 (+969), average=76 B
     /usr/lib/python3.4/contextlib.py:38: size=67.2 KiB (+67.2 KiB), count=126 (+126), average=546 B

Python がモジュールデータ ‘8173 KiB’ (バイトコードと定数) を読み込み、 前
回スナップショットを取ったとき、すなわちテストの前に読み込んだ量より
‘4428 KiB’ 多いということが分かります。 同様に、 *note linecache: 79. モ
ジュールはトレースバックの書式化に Python ソースコード ‘940 KiB’ をキャ
ッシュし、その全ては前回のスナップショットの後に行われたことが分かります
。

システムに空きメモリがほとんどない場合、スナップショットをオフラインで解
析するための *note Snapshot.dump(): 4161. メソッドを使用して、スナップシ
ョットをディスクに書き込むことが出来ます。 そして *note Snapshot.load():
4162. メソッドを使用してスナップショットを再読み込みします。


File: python.info,  Node: メモリブロックのトレースバックを取得する,  Next: top を整形化する,  Prev: 差を計算する,  Up: 使用例<44>

5.27.8.4 メモリブロックのトレースバックを取得する
.................................................

最大のメモリブロックのトレースバックを表示するコードです:

     import tracemalloc

     # Store 25 frames
     tracemalloc.start(25)

     # ... run your application ...

     snapshot = tracemalloc.take_snapshot()
     top_stats = snapshot.statistics('traceback')

     # pick the biggest memory block
     stat = top_stats[0]
     print("%s memory blocks: %.1f KiB" % (stat.count, stat.size / 1024))
     for line in stat.traceback.format():
         print(line)

Python テストスイートの出力例です (トレースバックは 25 フレームに制限さ
れています):

     903 memory blocks: 870.1 KiB
       File "<frozen importlib._bootstrap>", line 716
       File "<frozen importlib._bootstrap>", line 1036
       File "<frozen importlib._bootstrap>", line 934
       File "<frozen importlib._bootstrap>", line 1068
       File "<frozen importlib._bootstrap>", line 619
       File "<frozen importlib._bootstrap>", line 1581
       File "<frozen importlib._bootstrap>", line 1614
       File "/usr/lib/python3.4/doctest.py", line 101
         import pdb
       File "<frozen importlib._bootstrap>", line 284
       File "<frozen importlib._bootstrap>", line 938
       File "<frozen importlib._bootstrap>", line 1068
       File "<frozen importlib._bootstrap>", line 619
       File "<frozen importlib._bootstrap>", line 1581
       File "<frozen importlib._bootstrap>", line 1614
       File "/usr/lib/python3.4/test/support/__init__.py", line 1728
         import doctest
       File "/usr/lib/python3.4/test/test_pickletools.py", line 21
         support.run_doctest(pickletools)
       File "/usr/lib/python3.4/test/regrtest.py", line 1276
         test_runner()
       File "/usr/lib/python3.4/test/regrtest.py", line 976
         display_failure=not verbose)
       File "/usr/lib/python3.4/test/regrtest.py", line 761
         match_tests=ns.match_tests)
       File "/usr/lib/python3.4/test/regrtest.py", line 1563
         main()
       File "/usr/lib/python3.4/test/__main__.py", line 3
         regrtest.main_in_temp_cwd()
       File "/usr/lib/python3.4/runpy.py", line 73
         exec(code, run_globals)
       File "/usr/lib/python3.4/runpy.py", line 160
         "__main__", fname, loader, pkg_name)

We can see that the most memory was allocated in the *note importlib:
6b. module to load data (bytecode and constants) from modules: ‘870.1
KiB’.  The traceback is where the *note importlib: 6b. loaded data most
recently: on the ‘import pdb’ line of the *note doctest: 31. module.
The traceback may change if a new module is loaded.


File: python.info,  Node: top を整形化する,  Prev: メモリブロックのトレースバックを取得する,  Up: 使用例<44>

5.27.8.5 top を整形化する
.........................

‘<frozen importlib._bootstrap>’ および ‘<unknown>’ ファイルを無視して、
メモリ割り当て量の上位10を整形化して表示するコードです:

     import linecache
     import os
     import tracemalloc

     def display_top(snapshot, key_type='lineno', limit=10):
         snapshot = snapshot.filter_traces((
             tracemalloc.Filter(False, "<frozen importlib._bootstrap>"),
             tracemalloc.Filter(False, "<unknown>"),
         ))
         top_stats = snapshot.statistics(key_type)

         print("Top %s lines" % limit)
         for index, stat in enumerate(top_stats[:limit], 1):
             frame = stat.traceback[0]
             print("#%s: %s:%s: %.1f KiB"
                   % (index, frame.filename, frame.lineno, stat.size / 1024))
             line = linecache.getline(frame.filename, frame.lineno).strip()
             if line:
                 print('    %s' % line)

         other = top_stats[limit:]
         if other:
             size = sum(stat.size for stat in other)
             print("%s other: %.1f KiB" % (len(other), size / 1024))
         total = sum(stat.size for stat in top_stats)
         print("Total allocated size: %.1f KiB" % (total / 1024))

     tracemalloc.start()

     # ... run your application ...

     snapshot = tracemalloc.take_snapshot()
     display_top(snapshot)

Python テストスイートの出力例です:

     Top 10 lines
     #1: Lib/base64.py:414: 419.8 KiB
         _b85chars2 = [(a + b) for a in _b85chars for b in _b85chars]
     #2: Lib/base64.py:306: 419.8 KiB
         _a85chars2 = [(a + b) for a in _a85chars for b in _a85chars]
     #3: collections/__init__.py:368: 293.6 KiB
         exec(class_definition, namespace)
     #4: Lib/abc.py:133: 115.2 KiB
         cls = super().__new__(mcls, name, bases, namespace)
     #5: unittest/case.py:574: 103.1 KiB
         testMethod()
     #6: Lib/linecache.py:127: 95.4 KiB
         lines = fp.readlines()
     #7: urllib/parse.py:476: 71.8 KiB
         for a in _hexdig for b in _hexdig}
     #8: <string>:5: 62.0 KiB
     #9: Lib/_weakrefset.py:37: 60.0 KiB
         self.data = set()
     #10: Lib/base64.py:142: 59.8 KiB
         _b32tab2 = [a + b for a in _b32tab for b in _b32tab]
     6220 other: 3602.8 KiB
     Total allocated size: 5303.1 KiB

オプションの詳細については *note Snapshot.statistics(): 415f. を参照して
ください。

* Menu:

* Record the current and peak size of all traced memory blocks::


File: python.info,  Node: Record the current and peak size of all traced memory blocks,  Up: top を整形化する

5.27.8.6 Record the current and peak size of all traced memory blocks
.....................................................................

The following code computes two sums like ‘0 + 1 + 2 + ...’
inefficiently, by creating a list of those numbers.  This list consumes
a lot of memory temporarily.  We can use *note get_traced_memory():
4166. and *note reset_peak(): 909. to observe the small memory usage
after the sum is computed as well as the peak memory usage during the
computations:

     import tracemalloc

     tracemalloc.start()

     # Example code: compute a sum with a large temporary list
     large_sum = sum(list(range(100000)))

     first_size, first_peak = tracemalloc.get_traced_memory()

     tracemalloc.reset_peak()

     # Example code: compute a sum with a small temporary list
     small_sum = sum(list(range(1000)))

     second_size, second_peak = tracemalloc.get_traced_memory()

     print(f"{first_size=}, {first_peak=}")
     print(f"{second_size=}, {second_peak=}")

出力:

     first_size=664, first_peak=3592984
     second_size=804, second_peak=29704

Using *note reset_peak(): 909. ensured we could accurately record the
peak during the computation of ‘small_sum’, even though it is much
smaller than the overall peak size of memory blocks since the *note
start(): 1ca5. call.  Without the call to *note reset_peak(): 909,
‘second_peak’ would still be the peak from the computation ‘large_sum’
(that is, equal to ‘first_peak’).  In this case, both peaks are much
higher than the final memory usage, and which suggests we could optimise
(by removing the unnecessary call to *note list: 5dc, and writing
‘sum(range(...))’).


File: python.info,  Node: API,  Prev: 使用例<44>,  Up: tracemalloc --- メモリ割り当ての追跡

5.27.8.7 API
............

* Menu:

* 関数: 関数<11>.
* DomainFilter::
* Filter::
* Frame::
* Snapshot::
* Statistic::
* StatisticDiff::
* Trace::
* Traceback::


File: python.info,  Node: 関数<11>,  Next: DomainFilter,  Up: API

5.27.8.8 関数
.............

 -- の関数: tracemalloc.clear_traces ()

     Python が割り当てたメモリブロックのトレースを消去します。

     *note stop(): 416a. を参照してください。

 -- の関数: tracemalloc.get_object_traceback (obj)

     Python オブジェクト 'obj' が割り当てられたトレースバックを取得しま
     す。*note Traceback: b64. インスタンスか、*note tracemalloc: e8. モ
     ジュールがメモリ割り当てをトレースしていない場合かオブジェクトの割
     り当てをトレースしていない場合は、‘None’ を返します。

     *note gc.get_referrers(): 7cf. や *note sys.getsizeof(): 16d5. 関数
     も参照してください。

 -- の関数: tracemalloc.get_traceback_limit ()

     トレースのトレースバック内に格納されている最大フレーム数を取得しま
     す。

     *note tracemalloc: e8. モジュールは上限を取得するためにメモリ割り当
     てをトレースしていなければなりません。そうでなければ例外が送出され
     ます。

     *note start(): 1ca5. 関数で上限を設定します。

 -- の関数: tracemalloc.get_traced_memory ()

     *note tracemalloc: e8. モジュールがトレースするメモリブロックの現在
     のサイズと最大時のサイズをタプルとして取得します: ‘(current: int,
     peak: int)’。

 -- の関数: tracemalloc.reset_peak ()

     *note tracemalloc: e8. モジュールがトレースするメモリブロックの最大
     時のサイズを現在のサイズに設定します。

     Do nothing if the *note tracemalloc: e8. module is not tracing
     memory allocations.

     This function only modifies the recorded peak size, and does not
     modify or clear any traces, unlike *note clear_traces(): 4169.
     Snapshots taken with *note take_snapshot(): 416c. before a call to
     *note reset_peak(): 909. can be meaningfully compared to snapshots
     taken after the call.

     *note get_traced_memory(): 4166. も参照してください。

     Added in version 3.9.

 -- の関数: tracemalloc.get_tracemalloc_memory ()

     *note tracemalloc: e8. モジュールがメモリブロックのトレースを保存す
     るのに使用しているメモリ使用量をバイト単位で取得します。*note int:
     238. を返します。

 -- の関数: tracemalloc.is_tracing ()

     *note tracemalloc: e8. モジュールが Python のメモリ割り当てをトレー
     スしていれば ‘True’ を、そうでなければ ‘False’ を返します。

     *note start(): 1ca5. ならびに *note stop(): 416a. 関数も参照してく
     ださい。

 -- の関数: tracemalloc.start (nframe: int = 1)

     Python のメモリ割り当てのトレースを開始します: Python メモリアロケ
     ータにフックします。 トレースの収集されたトレースバックは 'nframe'
     フレームに制限されます。 デフォルトでは、あるブロックのトレースは最
     新のフレームのみを保存します、つまり上限は ‘1’ です。 'nframe' は
     ‘1’ 以上でなければなりません。

     You can still read the original number of total frames that
     composed the traceback by looking at the *note
     Traceback.total_nframe: 416f. attribute.

     ‘1’ より多くのフレームを保存するのは ‘'traceback'’ でグループ化され
     た統計や累積的な統計を計算する場合にのみ有用です。 *note
     Snapshot.compare_to(): 4170. および *note Snapshot.statistics():
     415f. メソッドを参照してください。

     保存するフレーム数を増やすと *note tracemalloc: e8. モジュールのメ
     モリと CPU のオーバーヘッドは増加します。 *note tracemalloc: e8. モ
     ジュールが使用しているメモリ量を調べるには *note
     get_tracemalloc_memory(): 416d. 関数を使用してください。

     *note PYTHONTRACEMALLOC: 1ca6. 環境変数
     (‘PYTHONTRACEMALLOC=NFRAME’) と *note -X: 15c. ‘tracemalloc=NFRAME’
     コマンドラインオプションを使って実行開始時にトレースを始めることが
     出来ます。

     *note stop(): 416a.、*note is_tracing(): 416e.、*note
     get_traceback_limit(): 416b. 関数を参照してください。

 -- の関数: tracemalloc.stop ()

     Python のメモリ割り当てのトレースを停止します。つまり、Python のメ
     モリ割り当てへのフックをアンインストールします。 Python が割り当て
     たメモリブロックについてこれまで集めたトレースも全てクリアします。

     トレースが全部クリアされる前にスナップショットを取りたい場合は
     *note take_snapshot(): 416c. 関数を呼んでください。

     *note start(): 1ca5.、*note is_tracing(): 416e.、*note
     clear_traces(): 4169. 関数も参照してください。

 -- の関数: tracemalloc.take_snapshot ()

     Python が割り当てたメモリブロックのトレースのスナップショットを取り
     ます。新しい *note Snapshot: 4171. インスタンスを返します。

     スナップショットは *note tracemalloc: e8. モジュールがメモリ割り当
     てのトレースを始める前に割り当てられたメモリブロックを含みません。

     トレースのトレースバックは *note get_traceback_limit(): 416b. フレ
     ームに制限されています。より多くのフレームを保存するには *note
     start(): 1ca5. 関数の 'nframe' 引数を使用してください。

     スナップショットを取るには *note tracemalloc: e8. モジュールはメモ
     リ割り当てをトレースしていなければなりません。 *note start(): 1ca5.
     関数を参照してください。

     *note get_object_traceback(): 1ac3. 関数を参照してください。


File: python.info,  Node: DomainFilter,  Next: Filter,  Prev: 関数<11>,  Up: API

5.27.8.9 DomainFilter
.....................

 -- クラス: tracemalloc.DomainFilter (inclusive: bool, domain: int)

     Filter traces of memory blocks by their address space (domain).

     Added in version 3.6.

      -- の属性: inclusive

          If 'inclusive' is ‘True’ (include), match memory blocks
          allocated in the address space *note domain: 4174.

          If 'inclusive' is ‘False’ (exclude), match memory blocks not
          allocated in the address space *note domain: 4174.

      -- の属性: domain

          Address space of a memory block (‘int’).  Read-only property.


File: python.info,  Node: Filter,  Next: Frame,  Prev: DomainFilter,  Up: API

5.27.8.10 Filter
................

 -- クラス: tracemalloc.Filter (inclusive: bool, filename_pattern: str,
          lineno: int = None, all_frames: bool = False, domain: int =
          None)

     メモリブロックのトレースをフィルターします。

     'filename_pattern' のシンタックスについては *note
     fnmatch.fnmatch(): 180a. 関数を参照してください。‘'.pyc'’ 拡張子は
     ‘'.py'’ に置換されます。

     例:

        * ‘Filter(True, subprocess.__file__)’ は *note subprocess: c1. モ
          ジュールのみを含みます

        * ‘Filter(False, tracemalloc.__file__)’ は *note tracemalloc:
          e8. モジュールのトレースを除外します

        * ‘Filter(False, "<unknown>")’ は空のトレースバックを除外します

     バージョン 3.5 で変更: ‘'.pyo'’ ファイル拡張子が ‘'.py'’ に置換され
     ることはもうありません。

     バージョン 3.6 で変更: *note domain: 4177. 属性が追加されました。

      -- の属性: domain

          Address space of a memory block (‘int’ or ‘None’).

          tracemalloc uses the domain ‘0’ to trace memory allocations
          made by Python.  C extensions can use other domains to trace
          other resources.

      -- の属性: inclusive

          If 'inclusive' is ‘True’ (include), only match memory blocks
          allocated in a file with a name matching *note
          filename_pattern: 4179. at line number *note lineno: 417a.

          If 'inclusive' is ‘False’ (exclude), ignore memory blocks
          allocated in a file with a name matching *note
          filename_pattern: 4179. at line number *note lineno: 417a.

      -- の属性: lineno

          フィルタの行番号です (‘int’)。'lineno' が ‘None’ の場合フィル
          タはあらゆる行番号にマッチします。

      -- の属性: filename_pattern

          フィルタのファイル名のパターンです (‘str’)。読み出し専用のプロ
          パティです。

      -- の属性: all_frames

          'all_frames' が ‘True’ の場合トレースバックの全てのフレームを
          チェックします。'all_frames' が ‘False’ の場合最新のフレームを
          チェックします。

          トレースバックの上限が ‘1’ の場合この属性の影響はありません。
          *note get_traceback_limit(): 416b. 関数と *note
          Snapshot.traceback_limit: 417c. 属性を参照してください。


File: python.info,  Node: Frame,  Next: Snapshot,  Prev: Filter,  Up: API

5.27.8.11 Frame
...............

 -- クラス: tracemalloc.Frame

     トレースバックのフレームです。

     *note Traceback: b64. クラスは *note Frame: 417e. インスタンスのシ
     ークエンスです。

      -- の属性: filename

          ファイル名 (‘str’)。

      -- の属性: lineno

          行番号 (‘int’)。


File: python.info,  Node: Snapshot,  Next: Statistic,  Prev: Frame,  Up: API

5.27.8.12 Snapshot
..................

 -- クラス: tracemalloc.Snapshot

     Python が割り当てたメモリブロックのトレースのスナップショットです。

     *note take_snapshot(): 416c. 関数はスナップショットのインスタンスを
     作ります。

      -- メソッド: compare_to (old_snapshot: Snapshot, key_type: str,
               cumulative: bool = False)

          古いスナップショットとの差を計算します。 'key_type' でグループ
          化された *note StatisticDiff: 4182. インスタンスのソート済みリ
          ストとして統計を取得します。

          'key_type' および 'cumulative' 引数については *note
          Snapshot.statistics(): 415f. メソッドを参照してください。

          結果は降順でソートされます: キーは *note
          StatisticDiff.size_diff: 4183. の絶対値、 *note
          StatisticDiff.size: 4184.、 *note StatisticDiff.count_diff:
          4185. の絶対置、 *note Statistic.count: 4186.、そして *note
          StatisticDiff.traceback: 4187. です。

      -- メソッド: dump (filename)

          スナップショットをファイルに書き込みます。

          スナップショットをリロードするには *note load(): 4162. を使用
          します。

      -- メソッド: filter_traces (filters)

          Create a new *note Snapshot: 4171. instance with a filtered
          *note traces: 4189. sequence, 'filters' is a list of *note
          DomainFilter: cbf. and *note Filter: 4176. instances.  If
          'filters' is an empty list, return a new *note Snapshot: 4171.
          instance with a copy of the traces.

          All inclusive filters are applied at once, a trace is ignored
          if no inclusive filters match it.  A trace is ignored if at
          least one exclusive filter matches it.

          バージョン 3.6 で変更: *note DomainFilter: cbf. instances are
          now also accepted in 'filters'.

      -- メソッド: classmethod load (filename)

          スナップショットをファイルからロードします。

          *note dump(): 4161. を参照してください。

      -- メソッド: statistics (key_type: str, cumulative: bool = False)

          'key_type' でグループ化された *note Statistic: 418a. インスタ
          ンスのソート済みリストとして統計を取得します:

          key_type                  description
                                    
          -------------------------------------------------------
                                    
          ‘'filename'’              ファイル名
                                    
                                    
          ‘'lineno'’                ファイル名と行番号
                                    
                                    
          ‘'traceback'’             traceback
                                    

          'cumulative' が ‘True’ の場合、最新のフレームだけでなく、トレ
          ースのトレースバックの全フレームのメモリーブロックについて大き
          さと数を累積します。 累積モードは 'key_type' が ‘'filename'’ お
          よび ‘'lineno'’ と等しい場合にのみ使用することが出来ます。

          結果は降順でソートされます: キーは *note Statistic.size: 418b,
          *note Statistic.count: 4186, *note Statistic.traceback: 418c.
          です。

      -- の属性: traceback_limit

          *note traces: 4189. のトレースバック内に保存されるフレーム数の
          最大値です。 スナップショットが取られたときの *note
          get_traceback_limit(): 416b. の結果です。

      -- の属性: traces

          Python が割り当てた全メモリブロックのトレースで、 *note Trace:
          418d. インスタンスのシークェンスです。

          シークェンスの順序は未定義です。統計のソート済みリストを取得す
          るには *note Snapshot.statistics(): 415f. を使用してください。


File: python.info,  Node: Statistic,  Next: StatisticDiff,  Prev: Snapshot,  Up: API

5.27.8.13 Statistic
...................

 -- クラス: tracemalloc.Statistic

     メモリ割り当ての統計です。

     *note Snapshot.statistics(): 415f. は *note Statistic: 418a. インス
     タンスの一覧を返します。

     *note StatisticDiff: 4182. クラスも参照してください。

      -- の属性: count

          メモリブロック数 (‘int’)。

      -- の属性: size

          メモリブロックのバイト単位の総サイズ (‘int’)。

      -- の属性: traceback

          メモリブロックが割り当てられているトレースバック。*note
          Traceback: b64. インスタンス。


File: python.info,  Node: StatisticDiff,  Next: Trace,  Prev: Statistic,  Up: API

5.27.8.14 StatisticDiff
.......................

 -- クラス: tracemalloc.StatisticDiff

     新旧 *note Snapshot: 4171. インスタンスのメモリ割り当ての統計差です
     。

     *note Snapshot.compare_to(): 4170. は *note StatisticDiff: 4182. イ
     ンスタンスのリストを返します。 *note Statistic: 418a. クラスも参照
     してください。

      -- の属性: count

          新しいスナップショット内のメモリブロックの数 (‘int’) です。新
          しいスナップショット内でメモリブロックが解放された場合は ‘0’ で
          す。

      -- の属性: count_diff

          新旧スナップショットのメモリブロック数の差 (‘int’) です。メモ
          リブロックが新しいスナップショット内で割り当てられた場合は ‘0’
          です。

      -- の属性: size

          新しいスナップショット内のメモリブロックのバイト単位での総サイ
          ズ (‘int’) です。新しいスナップショット内でメモリブロックが解
          放された場合は ‘0’ です。

      -- の属性: size_diff

          新旧スナップショットのバイト単位での総サイズの差 (‘int’) です
          。メモリブロックが新しいスナップショット内で割り当てられた場合
          は ‘0’ です。

      -- の属性: traceback

          メモリブロックが割り当てられたトレースバックで、 *note
          Traceback: b64. のインスタンスです。


File: python.info,  Node: Trace,  Next: Traceback,  Prev: StatisticDiff,  Up: API

5.27.8.15 Trace
...............

 -- クラス: tracemalloc.Trace

     メモリブロックをトレースします。

     *note Snapshot.traces: 4189. 属性は *note Trace: 418d. インスタンス
     のシークエンスです。

     バージョン 3.6 で変更: *note domain: 4192. 属性が追加されました。

      -- の属性: domain

          Address space of a memory block (‘int’).  Read-only property.

          tracemalloc uses the domain ‘0’ to trace memory allocations
          made by Python.  C extensions can use other domains to trace
          other resources.

      -- の属性: size

          メモリブロックのバイト単位のサイズ (‘int’)。

      -- の属性: traceback

          メモリブロックが割り当てられているトレースバック。*note
          Traceback: b64. インスタンス。


File: python.info,  Node: Traceback,  Prev: Trace,  Up: API

5.27.8.16 Traceback
...................

 -- クラス: tracemalloc.Traceback

     Sequence of *note Frame: 417e. instances sorted from the oldest
     frame to the most recent frame.

     A traceback contains at least ‘1’ frame.  If the ‘tracemalloc’
     module failed to get a frame, the filename ‘"<unknown>"’ at line
     number ‘0’ is used.

     When a snapshot is taken, tracebacks of traces are limited to *note
     get_traceback_limit(): 416b. frames.  See the *note
     take_snapshot(): 416c. function.  The original number of frames of
     the traceback is stored in the *note Traceback.total_nframe: 416f.
     attribute.  That allows to know if a traceback has been truncated
     by the traceback limit.

     *note Trace.traceback: 4194. 属性は *note Traceback: b64. のインス
     タンスです。

     バージョン 3.7 で変更: Frames are now sorted from the oldest to the
     most recent, instead of most recent to oldest.

      -- の属性: total_nframe

          Total number of frames that composed the traceback before
          truncation.  This attribute can be set to ‘None’ if the
          information is not available.

     バージョン 3.9 で変更: *note Traceback.total_nframe: 416f. 属性が追
     加されました。

      -- メソッド: format (limit=None, most_recent_first=False)

          Format the traceback as a list of lines.  Use the *note
          linecache: 79. module to retrieve lines from the source code.
          If 'limit' is set, format the 'limit' most recent frames if
          'limit' is positive.  Otherwise, format the ‘abs(limit)’
          oldest frames.  If 'most_recent_first' is ‘True’, the order of
          the formatted frames is reversed, returning the most recent
          frame first instead of last.

          Similar to the *note traceback.format_tb(): 4196. function,
          except that *note format(): b65. does not include newlines.

          以下はプログラム例です:

               print("Traceback (most recent call first):")
               for line in traceback:
                   print(line)

          出力:

               Traceback (most recent call first):
                 File "test.py", line 9
                   obj = Object()
                 File "test.py", line 12
                   tb = tracemalloc.get_object_traceback(f())


File: python.info,  Node: ソフトウェア・パッケージと配布,  Next: Python ランタイムサービス,  Prev: デバッグとプロファイル,  Up: Python 標準ライブラリ

5.28 ソフトウェア・パッケージと配布
===================================

以下のライブラリは Python で書かれたソフトウェアを配布、インストールする
ためのものです。これらのモジュールは Python Package Index(1) に対して動
作するように設計されていますが、ローカルのインデックスサーバーや、インデ
ックスサーバーなしに使うこともできます。

* Menu:

* ensurepip: ensurepip --- pip インストーラーのブートストラップ. pip インストーラーのブートストラップ
* venv: venv --- 仮想環境の作成. 仮想環境の作成
* zipapp: zipapp --- 実行可能な Python zip アーカイブを管理する. 実行可能な Python zip アーカイブを管理する

   ---------- Footnotes ----------

   (1) https://pypi.org


File: python.info,  Node: ensurepip --- pip インストーラーのブートストラップ,  Next: venv --- 仮想環境の作成,  Up: ソフトウェア・パッケージと配布

5.28.1 ‘ensurepip’ -- ‘pip’ インストーラーのブートストラップ
------------------------------------------------------------

Added in version 3.4.

'ソースコード:' Lib/ensurepip(1)

__________________________________________________________________

*note ensurepip: 4b. パッケージは ‘pip’ インストーラを既にインストールさ
れている Python 環境や仮想環境にブートストラップする助けになります。この
ブートストラップのアプローチは ‘pip’ が独立したリリースサイクルを持ち、
最新の利用可能な安定版が CPython リファレンスインタープリタのメンテナン
スリリースや feature リリースにバンドルされていることを反映しています。

ほとんどの場合、Python のエンドユーザーがこのモジュールを直接呼び出す必
要はないでしょう(‘pip’ はデフォルトでブートストラップされるからです)。し
かし、もし Python のインストール時に ‘pip’ のインストールをスキップした
り、仮想環境を構築したり、明示的に ‘pip’ をアンインストールした場合、直
接呼び出す必要があるかもしれません。

     注釈: このモジュールはインターネットに 'アクセスしません'。‘pip’ の
     ブートストラップに必要な全てはこのパッケージの一部として含まれてい
     ます。

参考
....

*note Python モジュールのインストール: ec0.

     エンドユーザーが Python パッケージをインストールする際のガイドです
     。

PEP 453(2): Python インストールの際の明示的なpipのブートストラッピング

     このモジュールのもともとの論拠と仕様。

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

* Menu:

* コマンドラインインターフェイス: コマンドラインインターフェイス<7>.
* モジュール API::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/ensurepip

   (2) https://peps.python.org/pep-0453/


File: python.info,  Node: コマンドラインインターフェイス<7>,  Next: モジュール API,  Up: ensurepip --- pip インストーラーのブートストラップ

5.28.1.1 コマンドラインインターフェイス
.......................................

コマンドラインインターフェースを起動するには ‘-m’ スイッチをつけてインタ
ープリターを使用します。

最も簡単な起動方法は:

     python -m ensurepip

この起動方法は ‘pip’ をインストールします。既にインストールされていた場
合は何もしません。インストールされた ‘pip’ のバージョンを ‘ensurepip’ で
利用できるもののうち、できるだけ新しいものにするためには、‘--upgrade’ オ
プションを追加して:

     python -m ensurepip --upgrade

デフォルトでは、‘pip’ は現在の仮想環境(もしアクティブなら)か、システムの
サイトパッケージ(もしアクティブな仮想環境がなければ)にインストールされま
す。インストール先は２つの追加コマンドラインオプションで制御できます:

   * ‘--root DIR’: 現在のアクティブな仮想環境 (もしあれば) のルートや現
     在インストールされている Python のルートディレクトリに入れる代わり
     に、与えられたディレクトリをルートとして ‘pip’ をインストールします
     。

   * ‘--user’: は、現在インストールされている Python にグローバルにイン
     ストールされる代わりに、ユーザーの site packages ディレクトリに
     ‘pip’ をインストールします(このオプションはアクティブな仮想環境のも
     とでは許可されません)。

デフォルトでは ‘pipX’ と ‘pipX.Y’ がインストールされます(X.Yは
‘ensurepip’ を起動したPythonのバージョン)。インストールされるスクリプト
は2つの追加コマンドラインオプションで制御できます:

   * ‘--altinstall’: alternate インストール。X.Y でバージョン付けされた
     ものだけがインストールされます。

   * ‘--default-pip’: "default pip" のインストールが要求されると、通常の
     二つのスクリプトに加えて ‘pip’ スクリプトがインストールされます。

2つのスクリプト選択オプションを指定すると例外が発生します。


File: python.info,  Node: モジュール API,  Prev: コマンドラインインターフェイス<7>,  Up: ensurepip --- pip インストーラーのブートストラップ

5.28.1.2 モジュール API
.......................

*note ensurepip: 4b. はプログラムから利用出来る 2 つの関数を公開していま
す:

 -- の関数: ensurepip.version ()

     環境にブートストラップする際にインストールされることになる利用可能
     な pip のバージョンを示す文字列を返します。

 -- の関数: ensurepip.bootstrap (root=None, upgrade=False, user=False,
          altinstall=False, default_pip=False, verbosity=0)

     現在の環境あるいは指示された環境へ ‘pip’ をブートストラップします。

     'root' で、インストールの root ディレクトリを変更します。 'root' が
     ‘None’ の場合は、インストールは現在の環境でのデフォルトの場所を使い
     ます。

     'upgrade' で、 ‘pip’ の利用可能なバージョンとして、インストール済み
     の以前のバージョンをアップグレードするかどうかを指定します。

     'user' で、グローバルなインストールではなく user スキームを使うかど
     うかを指定します。

     デフォルトではスクリプト ‘pipX’ と ‘pipX.Y’ はインストールされます
     (X.YはPythonの現在のバージョンです)。

     'altinstall' が設定されていた場合は ‘pipX’ はインストール 'されませ
     ん'。

     'default_pip' がセットされていれば、 ‘pip’ スクリプトが2つの標準ス
     クリプトと共にインストールされます。

     'altinstall' と 'default_pip' の両方を指定すると、 *note
     ValueError: 1e3. を起こします。

     'verbosity' でブートストラップ操作からの *note sys.stdout: aa4. へ
     の出力の冗長レベルをコントロールします。

     引数 ‘root’ 付きで *note 監査イベント: 1825. ‘ensurepip.bootstrap’
     を送出します。

          注釈: ブートストラップ処理は ‘sys.path’, ‘os.environ’ の両方に
          対して副作用を持ちます。代わりに、サブプロセスとしてコマンドラ
          インインターフェイスを使うことで、これら副作用を避けることが出
          来ます。

          注釈: ブートストラップ処理は ‘pip’ によって必要とされるモジュ
          ールを追加インストールするかもしれませんが、ほかのソフトウェア
          はそれら依存物がいつもデフォルトで存在していることを仮定すべき
          ではありません(将来のバージョンの ‘pip’ ではその依存はなくなる
          かもしれませんので)。


File: python.info,  Node: venv --- 仮想環境の作成,  Next: zipapp --- 実行可能な Python zip アーカイブを管理する,  Prev: ensurepip --- pip インストーラーのブートストラップ,  Up: ソフトウェア・パッケージと配布

5.28.2 ‘venv’ -- 仮想環境の作成
-------------------------------

Added in version 3.3.

'ソースコード:' Lib/venv/(1)

__________________________________________________________________

‘venv’ モジュールは、軽量な仮想環境の作成を行います。それぞれの仮想環境
は、*note site: b5. ディレクトリに独立した Python パッケージの集合を持っ
ています。仮想環境は、ベース Python とも呼ばれる、すでにインストールされ
ている Python の上に作成され、明示的にインストールしたパッケージのみが利
用可能となるよう、ベース Python から隔離することもできます。

仮想環境の中から使われると、 pip(2) のような一般的なインストールツールは
明示的に指定しなくても仮想環境に Python パッケージをインストールします。

A virtual environment is (amongst other things):

   * Used to contain a specific Python interpreter and software
     libraries and binaries which are needed to support a project
     (library or application).  These are by default isolated from
     software in other virtual environments and Python interpreters and
     libraries installed in the operating system.

   * Contained in a directory, conventionally named ‘.venv’ or ‘venv’ in
     the project directory, or under a container directory for lots of
     virtual environments, such as ‘~/.virtualenvs’.

   * Not checked into source control systems such as Git.

   * Considered as disposable - it should be simple to delete and
     recreate it from scratch.  You don't place any project code in the
     environment.

   * Not considered as movable or copyable - you just recreate the same
     environment in the target location.

Python仮想環境の背景についてより詳しくは PEP 405(3) を参照してください。

参考
....

Python Packaging User Guide: Creating and using virtual environments(4)

*note Availability: 1cbe.: not Android, not iOS, not WASI.

This module is not supported on *note mobile platforms: 1dbd. or *note
WebAssembly platforms: 174c.

* Menu:

* 仮想環境の作成: 仮想環境の作成<2>.
* 仮想環境のしくみ::
* API: API<2>.
* EnvBuilder を拡張する例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/venv/

   (2) https://pypi.org/project/pip/

   (3) https://peps.python.org/pep-0405/

   (4) 
https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#create-and-use-virtual-environments


File: python.info,  Node: 仮想環境の作成<2>,  Next: 仮想環境のしくみ,  Up: venv --- 仮想環境の作成

5.28.2.1 仮想環境の作成
.......................

*note Virtual environments: 41a0. are created by executing the ‘venv’
module:

     python -m venv /path/to/new/virtual/environment

This creates the target directory (including parent directories as
needed) and places a ‘pyvenv.cfg’ file in it with a ‘home’ key pointing
to the Python installation from which the command was run.  It also
creates a ‘bin’ (or ‘Scripts’ on Windows) subdirectory containing a copy
or symlink of the Python executable (as appropriate for the platform or
arguments used at environment creation time).  It also creates a
‘lib/pythonX.Y/site-packages’ subdirectory (on Windows, this is
‘Libsite-packages’).  If an existing directory is specified, it will be
re-used.

バージョン 3.5 で変更: 仮想環境の作成には、 ‘venv’ の使用が今は推奨され
ています。

Deprecated since version 3.6, removed in version 3.8: ‘pyvenv’ was the
recommended tool for creating virtual environments for Python 3.3 and
3.4, and replaced in 3.5 by executing ‘venv’ directly.

On Windows, invoke the ‘venv’ command as follows:

     PS> python -m venv C:\path\to\new\virtual\environment

このコマンドを ‘-h’ をつけて実行すると利用できるオプションが表示されます
:

     usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear]
                 [--upgrade] [--without-pip] [--prompt PROMPT] [--upgrade-deps]
                 [--without-scm-ignore-files]
                 ENV_DIR [ENV_DIR ...]

     Creates virtual Python environments in one or more target directories.

     positional arguments:
       ENV_DIR               A directory to create the environment in.

     options:
       -h, --help            show this help message and exit
       --system-site-packages
                             Give the virtual environment access to the system
                             site-packages dir.
       --symlinks            Try to use symlinks rather than copies, when
                             symlinks are not the default for the platform.
       --copies              Try to use copies rather than symlinks, even when
                             symlinks are the default for the platform.
       --clear               Delete the contents of the environment directory
                             if it already exists, before environment creation.
       --upgrade             Upgrade the environment directory to use this
                             version of Python, assuming Python has been
                             upgraded in-place.
       --without-pip         Skips installing or upgrading pip in the virtual
                             environment (pip is bootstrapped by default)
       --prompt PROMPT       Provides an alternative prompt prefix for this
                             environment.
       --upgrade-deps        Upgrade core dependencies (pip) to the latest
                             version in PyPI
       --without-scm-ignore-files
                             Skips adding SCM ignore files to the environment
                             directory (Git is supported by default).

     Once an environment has been created, you may wish to activate it, e.g. by
     sourcing an activate script in its bin directory.

バージョン 3.4 で変更: Installs pip by default, added the
‘--without-pip’ and ‘--copies’ options.

バージョン 3.4 で変更: 以前のバージョンでは、対象となるディレクトリが既
に存在していた場合は、 ‘--clear’ オプションや ‘--upgrade’ オプションを付
けない限りはエラーを送出していました。

バージョン 3.9 で変更: Add ‘--upgrade-deps’ option to upgrade pip +
setuptools to the latest on PyPI.

バージョン 3.12 で変更: ‘setuptools’ is no longer a core venv
dependency.

バージョン 3.13 で変更: Added the ‘--without-scm-ignore-files’ option.

バージョン 3.13 で変更: ‘venv’ now creates a ‘.gitignore’ file for Git
by default.

     注釈: Windows でもシンボリックリンクはサポートされていますが、シン
     ボリックリンクを使うのは推奨されません。 特に注目すべきなのは、ファ
     イルエクスプローラ上で ‘python.exe’ をダブルクリックすると、シンボ
     リックリンクを貪欲に解決し仮想環境を無視するということです。

     注釈: Microsoft Windows では、ユーザー向けの実行ポリシーを設定して
     ‘Activate.ps1’ スクリプトが使えるようにする必要があるかもしれません
     。 この設定は次の PowerShell コマンドでできます:

          PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

     さらに詳しくは About Execution Policies(1) を参照してください。

The created ‘pyvenv.cfg’ file also includes the
‘include-system-site-packages’ key, set to ‘true’ if ‘venv’ is run with
the ‘--system-site-packages’ option, ‘false’ otherwise.

‘--without-pip’ オプションが与えられない限り、‘pip’ を仮想環境でブートす
るために *note ensurepip: 4b. が呼ばれます。

‘venv’ には複数のパスを渡すことができ、その場合はそれぞれのパスに同一の
仮想環境が作成されます。

   ---------- Footnotes ----------

   (1) https://go.microsoft.com/fwlink/?LinkID=135170


File: python.info,  Node: 仮想環境のしくみ,  Next: API<2>,  Prev: 仮想環境の作成<2>,  Up: venv --- 仮想環境の作成

5.28.2.2 仮想環境のしくみ
.........................

Python インタプリタが仮想環境で実行しているとき、*note sys.prefix: 390.
と *note sys.exec_prefix: 38c. は仮想環境のディレクトリを指し示し、
*note sys.base_prefix: 3c9. と *note sys.base_exec_prefix: 3c8. は仮想環
境の作成に使われたベース Python のディレクトリを指し示します。
‘sys.prefix != sys.base_prefix’ を調べれば、現在のインタプリタが仮想環境
で実行しているかを判定できます。

A virtual environment may be "activated" using a script in its binary
directory (‘bin’ on POSIX; ‘Scripts’ on Windows).  This will prepend
that directory to your ‘PATH’, so that running ‘python’ will invoke the
environment's Python interpreter and you can run installed scripts
without having to use their full path.  The invocation of the activation
script is platform-specific (‘<VENV>’ must be replaced by the path to
the directory containing the virtual environment):

プラットフォー    シェル           仮想環境を有効化するためのコマンド
ム                                 

------------------------------------------------------------------------------------------
                                   
POSIX             bash/zsh         ‘$ source <VENV>/bin/activate’
                                   
                  
fish              ‘$ source
                  <VENV>/bin/activate.fish’
                  
                  
csh/tcsh          ‘$ source
                  <VENV>/bin/activate.csh’
                  
                  
pwsh              ‘$
                  <VENV>/bin/Activate.ps1’
                  
                                   
Windows           cmd.exe          ‘C:\> <VENV>\Scripts\activate.bat’
                                   
                  
PowerShell        ‘PS C:\>
                  <VENV>\Scripts\Activate.ps1’
                  

Added in version 3.4: ‘fish’ および ‘csh’ の有効化スクリプト。

Added in version 3.8: PowerShell Core のサポートのために POSIX 環境にイ
ンストールされた、PowerShell 有効化スクリプト。

Python を呼び出すときに仮想環境の Python インタプリタへのフルパスを指定
すれば良いだけなので、仮想環境をアクティベートする '必要' はありません。
さらに、仮想環境にインストールされたすべてのスクリプトはアクティベートせ
ずとも実行可能なはずです。

In order to achieve this, scripts installed into virtual environments
have a "shebang" line which points to the environment's Python
interpreter, ‘#!/<PATH-TO-VENV>/bin/python’.  This means that the script
will run with that interpreter regardless of the value of ‘PATH’.  On
Windows, "shebang" line processing is supported if you have the *note
Windows の Python ランチャ: 588. installed.  Thus, double-clicking an
installed script in a Windows Explorer window should run it with the
correct interpreter without the environment needing to be activated or
on the ‘PATH’.

仮想環境がアクティベートされると、‘VIRTUAL_ENV’ 環境変数の値が仮想環境へ
のパスに設定されます。アクティベートしなくても仮想環境を使うことは可能な
ため、仮想環境が使われているか否かの判断を ‘VIRTUAL_ENV’ に頼ることはで
きません。

     警告: 仮想環境にインストールされたスクリプトは仮想環境がアクティベ
     ートされていることを前提とすべきではないため、shebang の行は仮想環
     境のインタプリタへの絶対パスを含みます。このため、本質的に、仮想環
     境は一般の場合ポータブルではありません。いつでも仮想環境を再作成で
     きる簡単な方法を持っておくべきです（例えば、‘requirements.txt’ とい
     う requirements ファイルがあれば、仮想環境の ‘pip’ を用いて、‘pip
     install -r requirements.txt’ を呼び出すことで、仮想環境が必要とする
     すべてのパッケージをインストールできます）。何らかの理由で仮想環境
     を別の場所に移動する必要がある場合は、新しい場所で仮想環境を再作成
     し、古い場所にある仮想環境を削除してください。仮想環境の親ディレク
     トリを移動したため仮想環境も移動された場合は、新しい場所で仮想環境
     を再作成する必要があります。さもなくば、仮想環境にインストールされ
     たソフトウェアが想定通りに動作しない可能性があります。

シェルで ‘deactivate’ と入力することで仮想環境を無効化できます。 厳密な
仕組みはプラットフォーム固有であり、内部の実装詳細です (たいていはスクリ
プトかシェル関数が使われます)。


File: python.info,  Node: API<2>,  Next: EnvBuilder を拡張する例,  Prev: 仮想環境のしくみ,  Up: venv --- 仮想環境の作成

5.28.2.3 API
............

上述の高水準のメソッドは、サードパーティの仮想環境の作成者が環境の作成を
必要に応じてカスタマイズするための機構を提供する簡素な API を利用します
。それが *note EnvBuilder: 24b. クラスです。

 -- クラス: venv.EnvBuilder (system_site_packages=False, clear=False,
          symlinks=False, upgrade=False, with_pip=False, prompt=None,
          upgrade_deps=False, *, scm_ignore_files=frozenset())

     *note EnvBuilder: 24b. クラスを実体化するときに、以下のキーワード引
     数を受け取ります:

        * 'system_site_packages' - a boolean value indicating that the
          system Python site-packages should be available to the
          environment (defaults to ‘False’).

        * 'clear' - a boolean value which, if true, will delete the
          contents of any existing target directory, before creating the
          environment.

        * 'symlinks' - a boolean value indicating whether to attempt to
          symlink the Python binary rather than copying.

        * 'upgrade' - a boolean value which, if true, will upgrade an
          existing environment with the running Python - for use when
          that Python has been upgraded in-place (defaults to ‘False’).

        * 'with_pip' - a boolean value which, if true, ensures pip is
          installed in the virtual environment.  This uses *note
          ensurepip: 4b. with the ‘--default-pip’ option.

        * 'prompt' - a string to be used after virtual environment is
          activated (defaults to ‘None’ which means directory name of
          the environment would be used).  If the special string ‘"."’
          is provided, the basename of the current directory is used as
          the prompt.

        * 'upgrade_deps' - Update the base venv modules to the latest on
          PyPI

        * 'scm_ignore_files' - Create ignore files based for the
          specified source control managers (SCM) in the iterable.
          Support is defined by having a method named
          ‘create_{scm}_ignore_file’.  The only value supported by
          default is ‘"git"’ via *note create_git_ignore_file(): 41a5.

     バージョン 3.4 で変更: ‘with_pip’ 引数が追加されました。

     バージョン 3.6 で変更: ‘prompt’ 引数が追加されました。

     バージョン 3.9 で変更: ‘upgrade_deps’ 引数が追加されました。

     バージョン 3.13 で変更: Added the ‘scm_ignore_files’ parameter

     *note EnvBuilder: 24b. may be used as a base class.

      -- メソッド: create (env_dir)

          仮想環境を持つことになるターゲットディレクトリ (絶対パスあるい
          は現在のディレクトリからの相対パス) を指定し、仮想環境を作成し
          ます。 ‘create’ メソッドは、指定されたディレクトリに仮想環境を
          構築するか、適切な例外を送出します。

          *note EnvBuilder: 24b. クラスの ‘create’ メソッドは、サブクラ
          スのカスタマイズに使えるフックを説明します:

               def create(self, env_dir):
                   """
                   Create a virtualized Python environment in a directory.
                   env_dir is the target directory to create an environment in.
                   """
                   env_dir = os.path.abspath(env_dir)
                   context = self.ensure_directories(env_dir)
                   self.create_configuration(context)
                   self.setup_python(context)
                   self.setup_scripts(context)
                   self.post_setup(context)

          メソッド *note ensure_directories(): 41a7, *note
          create_configuration(): 41a8, *note setup_python(): 41a9,
          *note setup_scripts(): 41aa, *note post_setup(): 41ab. はそれ
          ぞれオーバーライドできます。

      -- メソッド: ensure_directories (env_dir)

          仮想環境のディレクトリとすべての必要なサブディレクトリのうちま
          だ存在しないものを作成し、コンテキストオブジェクトを返します。
          このコンテキストオブジェクトは他のメソッドで使うために（パスな
          どの）属性を保持しているだけです。もし *note EnvBuilder: 24b.
          が ‘clear=True’ の引数で作成された場合、仮想環境のディレクトリ
          の中身は消去され、すべての必要なサブディレクトリが再作成されま
          す。

          返されるコンテキストオブジェクトは以下の属性を持った *note
          types.SimpleNamespace: 1b3. です:

             * ‘env_dir’ - 仮想環境の場所。アクティベートスクリプトの中
               の ‘__VENV_DIR__’ で使われます（*note install_scripts():
               41ac. を参照してください）。

             * ‘env_name’ - 仮想環境の名前。アクティベートスクリプトの中
               の ‘__VENV_NAME__’ で使われます（*note install_scripts():
               41ac. を参照してください）。

             * ‘prompt’ - アクティベートスクリプトで使われるプロンプト。
               アクティベートスクリプトの中の ‘__VENV_PROMPT__’ で使われ
               ます（*note install_scripts(): 41ac. を参照してください）
               。

             * ‘executable’ - 仮想環境の元になっている Python 実行可能フ
               ァイル。これは仮想環境が別の仮想環境から作られた場合も考
               慮に入れます。

             * ‘inc_path’ - 仮想環境の include パス。

             * ‘lib_path’ - 仮想環境の purelib パス。

             * ‘bin_path’ - 仮想環境のスクリプトのパス。

             * ‘bin_name’ - 仮想環境の場所に相対的な、スクリプトのパス。
               アクティベートスクリプトの中の ‘__VENV_BIN_NAME__’ で使わ
               れます（*note install_scripts(): 41ac. を参照してください
               ）。

             * ‘env_exe’ - 仮想環境の中の Python インタプリタの名前。ア
               クティベートスクリプトの中の ‘__VENV_PYTHON__’ で使われま
               す（*note install_scripts(): 41ac. を参照してください）。

             * ‘env_exec_cmd’ - ファイルシステムのリダイレクトを考慮に入
               れた、Python インタプリタの名前。これは仮想環境の中で
               Python を実行するのに使えます。

          バージョン 3.11 で変更: 'venv' *note
          システム構成インストールスキーム: 65b. は作成されたディレクト
          リのパスを構築するために使われます。

          バージョン 3.12 で変更: コンテキストに ‘lib_path’ 属性が追加さ
          れ、コンテキストオブジェクトがドキュメントに追加されました。

      -- メソッド: create_configuration (context)

          仮想環境に ‘pyvenv.cfg’ 設定ファイルを作成します。

      -- メソッド: setup_python (context)

          Python 実行ファイルのコピーまたはシンボリックリンクを仮想環境
          に作成します。 POSIX システムで、特定の ‘python3.x’ 実行ファイ
          ルが使われている場合、同じ名前のファイルが既に存在していない限
          り、 ‘python’ および ‘python3’ へのシンボリックリンクがその実
          行ファイルを指すように作成されます。

      -- メソッド: setup_scripts (context)

          プラットフォームに対応した有効化スクリプトを仮想環境にインスト
          ールします。

      -- メソッド: upgrade_dependencies (context)

          Upgrades the core venv dependency packages (currently pip(1))
          in the environment.  This is done by shelling out to the ‘pip’
          executable in the environment.

          Added in version 3.9.

          バージョン 3.12 で変更: setuptools(2) is no longer a core venv
          dependency.

      -- メソッド: post_setup (context)

          サードパーティーライブラリがオーバーライドするための空のメソッ
          ドです。このメソッドをオーバーライドして、仮想環境構築後にパッ
          ケージのプリインストールなどのステップを実装できます。

      -- メソッド: install_scripts (context, path)

          This method can be called from *note setup_scripts(): 41aa. or
          *note post_setup(): 41ab. in subclasses to assist in
          installing custom scripts into the virtual environment.

          'path' is the path to a directory that should contain
          subdirectories ‘common’, ‘posix’, ‘nt’; each containing
          scripts destined for the ‘bin’ directory in the environment.
          The contents of ‘common’ and the directory corresponding to
          *note os.name: 2a60. are copied after some text replacement of
          placeholders:

             * ‘__VENV_DIR__’ は仮想環境ディレクトリの絶対パスに置換され
               ます。

             * ‘__VENV_NAME__’ は仮想環境の名前 (仮想環境ディレクトリの
               パスの最後の部分) に置換されます。

             * ‘__VENV_PROMPT__’ はプロンプトに置換されます (括弧で囲ま
               れ空白が続く環境名)。

             * ‘__VENV_BIN_NAME__’ は bin ディレクトリ名 (‘bin’ か
               ‘Scripts’) に置換されます。

             * ‘__VENV_PYTHON__’ は仮想環境の Python 実行ファイルの絶対
               パスに置換されます。

          (既存環境のアップグレード中は) ディレクトリは存在しても構いま
          せん。

      -- メソッド: create_git_ignore_file (context)

          Creates a ‘.gitignore’ file within the virtual environment
          that causes the entire directory to be ignored by the Git
          source control manager.

          Added in version 3.13.

     バージョン 3.7.2 で変更: Windows では、バイナリそのものをコピーする
     のではなく、‘python[w].exe’ にリダイレクトを行うスクリプトを使うよ
     うになりました。 3.7.2 でのみ、ソース群でビルドを実行しているのでな
     ければ *note setup_python(): 41a9. だけは何もしません。

     バージョン 3.7.3 で変更: Windows では、 *note setup_scripts():
     41aa. の代わりに *note setup_python(): 41a9. の一部としてリダイレク
     トを行うスクリプトをコピーします。 これは 3.7.2 には当てはまりませ
     ん。 シンボリックリンクを使ったときは、オリジナルの実行ファイルをコ
     ピーします。

モジュールレベルの簡易関数もあります:

 -- の関数: venv.create (env_dir, system_site_packages=False,
          clear=False, symlinks=False, with_pip=False, prompt=None,
          upgrade_deps=False, *, scm_ignore_files=frozenset())

     *note EnvBuilder: 24b. を指定されたキーワード引数を使って作成し、そ
     の *note create(): 41a6. メソッドに 'env_dir' 引数を渡して実行しま
     す。

     Added in version 3.3.

     バージョン 3.4 で変更: Added the 'with_pip' parameter

     バージョン 3.6 で変更: Added the 'prompt' parameter

     バージョン 3.9 で変更: Added the 'upgrade_deps' parameter

     バージョン 3.13 で変更: Added the 'scm_ignore_files' parameter

   ---------- Footnotes ----------

   (1) https://pypi.org/project/pip/

   (2) https://pypi.org/project/setuptools/


File: python.info,  Node: EnvBuilder を拡張する例,  Prev: API<2>,  Up: venv --- 仮想環境の作成

5.28.2.4 ‘EnvBuilder’ を拡張する例
..................................

次のスクリプトで、作成された仮想環境に setuptools と pip をインストール
するサブクラスを実装して *note EnvBuilder: 24b. を拡張する方法を示します
:

     import os
     import os.path
     from subprocess import Popen, PIPE
     import sys
     from threading import Thread
     from urllib.parse import urlparse
     from urllib.request import urlretrieve
     import venv

     class ExtendedEnvBuilder(venv.EnvBuilder):
         """
         This builder installs setuptools and pip so that you can pip or
         easy_install other packages into the created virtual environment.

         :param nodist: If true, setuptools and pip are not installed into the
                        created virtual environment.
         :param nopip: If true, pip is not installed into the created
                       virtual environment.
         :param progress: If setuptools or pip are installed, the progress of the
                          installation can be monitored by passing a progress
                          callable. If specified, it is called with two
                          arguments: a string indicating some progress, and a
                          context indicating where the string is coming from.
                          The context argument can have one of three values:
                          'main', indicating that it is called from virtualize()
                          itself, and 'stdout' and 'stderr', which are obtained
                          by reading lines from the output streams of a subprocess
                          which is used to install the app.

                          If a callable is not specified, default progress
                          information is output to sys.stderr.
         """

         def __init__(self, *args, **kwargs):
             self.nodist = kwargs.pop('nodist', False)
             self.nopip = kwargs.pop('nopip', False)
             self.progress = kwargs.pop('progress', None)
             self.verbose = kwargs.pop('verbose', False)
             super().__init__(*args, **kwargs)

         def post_setup(self, context):
             """
             Set up any packages which need to be pre-installed into the
             virtual environment being created.

             :param context: The information for the virtual environment
                             creation request being processed.
             """
             os.environ['VIRTUAL_ENV'] = context.env_dir
             if not self.nodist:
                 self.install_setuptools(context)
             # Can't install pip without setuptools
             if not self.nopip and not self.nodist:
                 self.install_pip(context)

         def reader(self, stream, context):
             """
             Read lines from a subprocess' output stream and either pass to a progress
             callable (if specified) or write progress information to sys.stderr.
             """
             progress = self.progress
             while True:
                 s = stream.readline()
                 if not s:
                     break
                 if progress is not None:
                     progress(s, context)
                 else:
                     if not self.verbose:
                         sys.stderr.write('.')
                     else:
                         sys.stderr.write(s.decode('utf-8'))
                     sys.stderr.flush()
             stream.close()

         def install_script(self, context, name, url):
             _, _, path, _, _, _ = urlparse(url)
             fn = os.path.split(path)[-1]
             binpath = context.bin_path
             distpath = os.path.join(binpath, fn)
             # Download script into the virtual environment's binaries folder
             urlretrieve(url, distpath)
             progress = self.progress
             if self.verbose:
                 term = '\n'
             else:
                 term = ''
             if progress is not None:
                 progress('Installing %s ...%s' % (name, term), 'main')
             else:
                 sys.stderr.write('Installing %s ...%s' % (name, term))
                 sys.stderr.flush()
             # Install in the virtual environment
             args = [context.env_exe, fn]
             p = Popen(args, stdout=PIPE, stderr=PIPE, cwd=binpath)
             t1 = Thread(target=self.reader, args=(p.stdout, 'stdout'))
             t1.start()
             t2 = Thread(target=self.reader, args=(p.stderr, 'stderr'))
             t2.start()
             p.wait()
             t1.join()
             t2.join()
             if progress is not None:
                 progress('done.', 'main')
             else:
                 sys.stderr.write('done.\n')
             # Clean up - no longer needed
             os.unlink(distpath)

         def install_setuptools(self, context):
             """
             Install setuptools in the virtual environment.

             :param context: The information for the virtual environment
                             creation request being processed.
             """
             url = "https://bootstrap.pypa.io/ez_setup.py"
             self.install_script(context, 'setuptools', url)
             # clear up the setuptools archive which gets downloaded
             pred = lambda o: o.startswith('setuptools-') and o.endswith('.tar.gz')
             files = filter(pred, os.listdir(context.bin_path))
             for f in files:
                 f = os.path.join(context.bin_path, f)
                 os.unlink(f)

         def install_pip(self, context):
             """
             Install pip in the virtual environment.

             :param context: The information for the virtual environment
                             creation request being processed.
             """
             url = 'https://bootstrap.pypa.io/get-pip.py'
             self.install_script(context, 'pip', url)


     def main(args=None):
         import argparse

         parser = argparse.ArgumentParser(prog=__name__,
                                          description='Creates virtual Python '
                                                      'environments in one or '
                                                      'more target '
                                                      'directories.')
         parser.add_argument('dirs', metavar='ENV_DIR', nargs='+',
                             help='A directory in which to create the '
                                  'virtual environment.')
         parser.add_argument('--no-setuptools', default=False,
                             action='store_true', dest='nodist',
                             help="Don't install setuptools or pip in the "
                                  "virtual environment.")
         parser.add_argument('--no-pip', default=False,
                             action='store_true', dest='nopip',
                             help="Don't install pip in the virtual "
                                  "environment.")
         parser.add_argument('--system-site-packages', default=False,
                             action='store_true', dest='system_site',
                             help='Give the virtual environment access to the '
                                  'system site-packages dir.')
         if os.name == 'nt':
             use_symlinks = False
         else:
             use_symlinks = True
         parser.add_argument('--symlinks', default=use_symlinks,
                             action='store_true', dest='symlinks',
                             help='Try to use symlinks rather than copies, '
                                  'when symlinks are not the default for '
                                  'the platform.')
         parser.add_argument('--clear', default=False, action='store_true',
                             dest='clear', help='Delete the contents of the '
                                                'virtual environment '
                                                'directory if it already '
                                                'exists, before virtual '
                                                'environment creation.')
         parser.add_argument('--upgrade', default=False, action='store_true',
                             dest='upgrade', help='Upgrade the virtual '
                                                  'environment directory to '
                                                  'use this version of '
                                                  'Python, assuming Python '
                                                  'has been upgraded '
                                                  'in-place.')
         parser.add_argument('--verbose', default=False, action='store_true',
                             dest='verbose', help='Display the output '
                                                  'from the scripts which '
                                                  'install setuptools and pip.')
         options = parser.parse_args(args)
         if options.upgrade and options.clear:
             raise ValueError('you cannot supply --upgrade and --clear together.')
         builder = ExtendedEnvBuilder(system_site_packages=options.system_site,
                                        clear=options.clear,
                                        symlinks=options.symlinks,
                                        upgrade=options.upgrade,
                                        nodist=options.nodist,
                                        nopip=options.nopip,
                                        verbose=options.verbose)
         for d in options.dirs:
             builder.create(d)

     if __name__ == '__main__':
         rc = 1
         try:
             main()
             rc = 0
         except Exception as e:
             print('Error: %s' % e, file=sys.stderr)
         sys.exit(rc)

このスクリプトは オンライン(1) よりダウンロードすることも可能です。

   ---------- Footnotes ----------

   (1) https://gist.github.com/vsajip/4673395


File: python.info,  Node: zipapp --- 実行可能な Python zip アーカイブを管理する,  Prev: venv --- 仮想環境の作成,  Up: ソフトウェア・パッケージと配布

5.28.3 ‘zipapp’ -- 実行可能な Python zip アーカイブを管理する
-------------------------------------------------------------

Added in version 3.5.

'ソースコード:' Lib/zipapp.py(1)

__________________________________________________________________

このモジュールは Python コードを含む zip ファイルの作成を行うツールを提
供します。 zip ファイルは *note Python
インタープリタで直接実行することが出来ます: 1c93.。 このモジュールは
*note コマンドラインインターフェイス: 41b1. と *note Python API: 41b2. の
両方を提供します。

* Menu:

* 基本的な例: 基本的な例<4>.
* コマンドラインインターフェイス: コマンドラインインターフェイス<8>.
* Python API::
* 使用例: 使用例<45>.
* インタープリタの指定::
* Creating Standalone Applications with zipapp::
* The Python Zip Application Archive Format::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/zipapp.py


File: python.info,  Node: 基本的な例<4>,  Next: コマンドラインインターフェイス<8>,  Up: zipapp --- 実行可能な Python zip アーカイブを管理する

5.28.3.1 基本的な例
...................

実行可能なアーカイブを Python コードを含むディレクトリから作成する為に
*note コマンドラインインターフェイス: 41b1. をどのように利用することがで
きるかを以下に例示します。アーカイブは実行時にアーカイブ内の ‘myapp’ モ
ジュールから ‘main’ 関数を実行します。

     $ python -m zipapp myapp -m "myapp:main"
     $ python myapp.pyz
     <output from myapp>


File: python.info,  Node: コマンドラインインターフェイス<8>,  Next: Python API,  Prev: 基本的な例<4>,  Up: zipapp --- 実行可能な Python zip アーカイブを管理する

5.28.3.2 コマンドラインインターフェイス
.......................................

コマンドラインからプログラムとして呼び出す場合は、次の形式を使用います:

     $ python -m zipapp source [options]

'source' がディレクトリである場合、 'source' ディレクトリの内容からアー
カイブを作成します。 'source' がファイルである場合、 'source' ファイル自
身をアーカイブ化し、保存先アーカイブへコピーします。(または -info オプシ
ョンが指定されている場合はファイルのシェバン行が表示されます。)

以下のオプションが解釈されます:

 -- Option: -o <output>, --output=<output>

     出力を 'output' に指定した名前のファイルへ書込みます。このオプショ
     ンが指定されていない場合、出力先ファイル名は入力元 'source' と同じ
     になり、 ‘.pyz’ 拡張子が付与されます。 ファイル名が明示的に指定され
     ている場合は、指定されたファイル名を使用します。(必要であれば
     ‘.pyz’ 拡張子が含まれます。)

     'source' がアーカイブである場合は、出力先ファイル名を必ず指定しなけ
     ればなりません。 ('source' がアーカイブである場合は 'output' を必ず
     'source' とは別の名前にしてください。)

 -- Option: -p <interpreter>, --python=<interpreter>

     実行コマンドとしての 'interpreter' を指定する ‘#!’ 行を書庫に追加し
     ます。 また、POSIX では書庫を実行可能にします。 デフォルトでは ‘#!’
     行を書かず、ファイルを実行可能にはしません。

 -- Option: -m <mainfn>, --main=<mainfn>

     'mainfn' を実行するアーカイブへ ‘__main__.py’ ファイルを書込んでく
     ださい。 'mainfn' 引数は "pkg.mod:fn" の形式で指定します。
     "pkg.mod" の場所はアーカイブ内の package/module です。 "fn" は指定
     した module から呼出すことのできる関数です。 ‘__main__.py’ ファイル
     が module から呼出すことのできる関数を実行します。

     書庫をコピーする際、 *note -main: 41b9. を指定することは出来ません
     。

 -- Option: -c, --compress

     Compress files with the deflate method, reducing the size of the
     output file.  By default, files are stored uncompressed in the
     archive.

     書庫をコピーする際、 *note -compress: 41bb. に効果はありません。

     Added in version 3.7.

 -- Option: --info

     診断するために書庫に埋め込まれたインタープリタを表示します。 この場
     合、他の全てのオプションは無視され、SOURCE はディレクトリではなく書
     庫でなければなりません。

 -- Option: -h, --help

     簡単な使用法を表示して終了します。


File: python.info,  Node: Python API,  Next: 使用例<45>,  Prev: コマンドラインインターフェイス<8>,  Up: zipapp --- 実行可能な Python zip アーカイブを管理する

5.28.3.3 Python API
...................

このモジュールは 2 つの簡便関数を定義しています:

 -- の関数: zipapp.create_archive (source, target=None,
          interpreter=None, main=None, filter=None, compressed=False)

     'source' からアプリケーション書庫を作成します。 ソースは以下のいず
     れかです:

        * ディレクトリ名、または 新しいアプリケーションアーカイブがディ
          レクトリのコンテンツから作成される場合に *note path-like
          object: 280. オブジェクトが参照するディレクトリ。

        * 既存のアプリケーションアーカイブファイルの名前、 または
          ('interpreter' 引数に指定した値を反映し、修正する)アーカイブへ
          ファイルがコピーされる場合に *note path-like object: 280. オブ
          ジェクトが参照するファイル。

        * バイトモードの読込みで開くファイルオブジェクト。 ファイルの内
          容がアプリケーションアーカイブとなり、 ファイルオブジェクトが
          アーカイブの起点となります。

     'target' 引数は作成される書庫が書き込まれる場所を決めます:

        * ファイル名、または *note path-like object: 280. オブジェクトを
          指定した場合、アーカイブは指定したファイルへ書き込まれます。

        * 開いているファイルオブジェクトを指定した場合、 アーカイブはそ
          のファイルオブジェクトへ書込みを行ないます。 ファイルオブジェ
          クトは必ずバイトモードの書込みで開いてください。

        * target を指定しないか ‘None’ を渡した場合、 source は必ずディ
          レクトリでなければならず、target は source のファイル名に
          ‘.pyz’ 拡張子を付与したファイル名となります。

     'interpreter' 引数はアーカイブが実行時に使用する Python インタープ
     リタの名前を指定します。 インタープリタ名は "シェバン" 行としてアー
     カイブの起点に書込まれます。 POSIX では OS によってシェバンが解釈さ
     れ、 Windows では Python ランチャーによって扱われます。 シェバン行
     が書込まれていない場合は 'interpreter' の結果を無視します。
     interpreter が指定されており、 target がファイル名である場合、
     target ファイルの実行可能ビットが設定されます。

     'main' 引数はアーカイブのメインプログラムとして使用する callable の
     名前を指定します。 'main' 引数は source がディレクトリであり、
     source が既に ‘__main__.py’ ファイルを保持していない場合に限り、指
     定することができます。 'main' 引数は "pkg.module:callable" の形式を
     取り、 アーカイブは "pkg.module" をインポートして実行され、 指定し
     た callable を引数なしで実行します。 source がディレクトリであり、
     ‘__main__.py’ が含まれていない場合、 'main' は無視すべきエラーとな
     り、 作成されたアーカイブには実行可能ビットが設定されません。

     The optional 'filter' argument specifies a callback function that
     is passed a Path object representing the path to the file being
     added (relative to the source directory).  It should return ‘True’
     if the file is to be added.

     The optional 'compressed' argument determines whether files are
     compressed.  If set to ‘True’, files in the archive are compressed
     with the deflate method; otherwise, files are stored uncompressed.
     This argument has no effect when copying an existing archive.

     'source' または 'target' へファイルオブジェクトを指定した場合、
     caller が create_archive の呼出し後にオブジェクトを閉じます。

     既存のアーカイブをコピーする際、ファイルオブジェクトは ‘read’ ,
     ‘readline’ , ‘write’ メソッドのみを提供します。 アーカイブをディレ
     クトリから作成する際、 target がファイルオブジェクトである場合は、
     ‘zipfile.ZipFile’ クラスへ渡されます。必ずクラスが必要とするメソッ
     ドを提供してください。

     バージョン 3.7 で変更: Added the 'filter' and 'compressed'
     parameters.

 -- の関数: zipapp.get_interpreter (archive)

     アーカイブの最初の行の ‘#!’ に指定されたインタープリタを返します。
     ‘#!’ が無い場合は *note None: 641. を返します。 'archive' 引数は、
     ファイル名またはバイトモードの読込みで開いた ファイルに準じるオブジ
     ェクトを指定することができ、アーカイブの起点で決定されます。


File: python.info,  Node: 使用例<45>,  Next: インタープリタの指定,  Prev: Python API,  Up: zipapp --- 実行可能な Python zip アーカイブを管理する

5.28.3.4 使用例
...............

ディレクトリを書庫に圧縮し、実行します。

     $ python -m zipapp myapp
     $ python myapp.pyz
     <output from myapp>

同じことを *note create_archive(): b7e. 関数を使用して行うことができます
:

     >>> import zipapp
     >>> zipapp.create_archive('myapp', 'myapp.pyz')

POSIX でアプリケーションを直接実行可能にするには使用するインタープリタを
指定します。

     $ python -m zipapp myapp -p "/usr/bin/env python"
     $ ./myapp.pyz
     <output from myapp>

シバン行を既存の書庫で置換するには、 *note create_archive(): b7e.
function: を使用して変更された書庫を作成します:

     >>> import zipapp
     >>> zipapp.create_archive('old_archive.pyz', 'new_archive.pyz', '/usr/bin/python3')

アーカイブ内のファイルを更新するには *note BytesIO: e6d. オブジェクトを
使用してメモリーへ格納し、 元のファイルを上書きして置換してください。 フ
ァイルを上書きする際にエラーが発生し、元のファイルが失われる危険性がある
ことに注意してください。 このコードは上記のようなエラーからファイルを保
護しませんが、プロダクションコードは保護するべきです。 この方法はアーカ
イブがメモリーに収まる場合にのみ動作します:

     >>> import zipapp
     >>> import io
     >>> temp = io.BytesIO()
     >>> zipapp.create_archive('myapp.pyz', temp, '/usr/bin/python2')
     >>> with open('myapp.pyz', 'wb') as f:
     >>>     f.write(temp.getvalue())


File: python.info,  Node: インタープリタの指定,  Next: Creating Standalone Applications with zipapp,  Prev: 使用例<45>,  Up: zipapp --- 実行可能な Python zip アーカイブを管理する

5.28.3.5 インタープリタの指定
.............................

Note that if you specify an interpreter and then distribute your
application archive, you need to ensure that the interpreter used is
portable.  The Python launcher for Windows supports most common forms of
POSIX ‘#!’ line, but there are other issues to consider:

   * If you use "/usr/bin/env python" (or other forms of the "python"
     command, such as "/usr/bin/python"), you need to consider that your
     users may have either Python 2 or Python 3 as their default, and
     write your code to work under both versions.

   * If you use an explicit version, for example "/usr/bin/env python3"
     your application will not work for users who do not have that
     version.  (This may be what you want if you have not made your code
     Python 2 compatible).

   * There is no way to say "python X.Y or later", so be careful of
     using an exact version like "/usr/bin/env python3.4" as you will
     need to change your shebang line for users of Python 3.5, for
     example.

Typically, you should use an "/usr/bin/env python2" or "/usr/bin/env
python3", depending on whether your code is written for Python 2 or 3.


File: python.info,  Node: Creating Standalone Applications with zipapp,  Next: The Python Zip Application Archive Format,  Prev: インタープリタの指定,  Up: zipapp --- 実行可能な Python zip アーカイブを管理する

5.28.3.6 Creating Standalone Applications with zipapp
.....................................................

Using the *note zipapp: 116. module, it is possible to create
self-contained Python programs, which can be distributed to end users
who only need to have a suitable version of Python installed on their
system.  The key to doing this is to bundle all of the application's
dependencies into the archive, along with the application code.

The steps to create a standalone archive are as follows:

  1. Create your application in a directory as normal, so you have a
     ‘myapp’ directory containing a ‘__main__.py’ file, and any
     supporting application code.

  2. Install all of your application's dependencies into the ‘myapp’
     directory, using pip:

          $ python -m pip install -r requirements.txt --target myapp

     (this assumes you have your project requirements in a
     ‘requirements.txt’ file - if not, you can just list the
     dependencies manually on the pip command line).

  3. Package the application using:

          $ python -m zipapp -p "interpreter" myapp

This will produce a standalone executable, which can be run on any
machine with the appropriate interpreter available.  See *note
インタープリタの指定: 41c5. for details.  It can be shipped to users as
a single file.

On Unix, the ‘myapp.pyz’ file is executable as it stands.  You can
rename the file to remove the ‘.pyz’ extension if you prefer a "plain"
command name.  On Windows, the ‘myapp.pyz[w]’ file is executable by
virtue of the fact that the Python interpreter registers the ‘.pyz’ and
‘.pyzw’ file extensions when installed.

* Menu:

* Caveats::


File: python.info,  Node: Caveats,  Up: Creating Standalone Applications with zipapp

5.28.3.7 Caveats
................

If your application depends on a package that includes a C extension,
that package cannot be run from a zip file (this is an OS limitation, as
executable code must be present in the filesystem for the OS loader to
load it).  In this case, you can exclude that dependency from the
zipfile, and either require your users to have it installed, or ship it
alongside your zipfile and add code to your ‘__main__.py’ to include the
directory containing the unzipped module in ‘sys.path’.  In this case,
you will need to make sure to ship appropriate binaries for your target
architecture(s) (and potentially pick the correct version to add to
‘sys.path’ at runtime, based on the user's machine).


File: python.info,  Node: The Python Zip Application Archive Format,  Prev: Creating Standalone Applications with zipapp,  Up: zipapp --- 実行可能な Python zip アーカイブを管理する

5.28.3.8 The Python Zip Application Archive Format
..................................................

Python has been able to execute zip files which contain a ‘__main__.py’
file since version 2.6.  In order to be executed by Python, an
application archive simply has to be a standard zip file containing a
‘__main__.py’ file which will be run as the entry point for the
application.  As usual for any Python script, the parent of the script
(in this case the zip file) will be placed on *note sys.path: 38e. and
thus further modules can be imported from the zip file.

The zip file format allows arbitrary data to be prepended to a zip file.
The zip application format uses this ability to prepend a standard POSIX
"shebang" line to the file (‘#!/path/to/interpreter’).

Formally, the Python zip application format is therefore:

  1. An optional shebang line, containing the characters ‘b'#!'’
     followed by an interpreter name, and then a newline (‘b'\n'’)
     character.  The interpreter name can be anything acceptable to the
     OS "shebang" processing, or the Python launcher on Windows.  The
     interpreter should be encoded in UTF-8 on Windows, and in *note
     sys.getfilesystemencoding(): c27. on POSIX.

  2. Standard zipfile data, as generated by the *note zipfile: 117.
     module.  The zipfile content 'must' include a file called
     ‘__main__.py’ (which must be in the "root" of the zipfile - i.e.,
     it cannot be in a subdirectory).  The zipfile data can be
     compressed or uncompressed.

If an application archive has a shebang line, it may have the executable
bit set on POSIX systems, to allow it to be executed directly.

There is no requirement that the tools in this module are used to create
application archives - the module is a convenience, but archives in the
above format created by any means are acceptable to Python.


File: python.info,  Node: Python ランタイムサービス,  Next: カスタム Python インタプリタ,  Prev: ソフトウェア・パッケージと配布,  Up: Python 標準ライブラリ

5.29 Python ランタイムサービス
==============================

この章では、Python インタープリタや Python 環境に深く関連する各種の機能
を解説します。以下に一覧を示します:

* Menu:

* sys: sys --- システム固有のパラメーターと関数. システム固有のパラメーターと関数
* sys.monitoring: sys monitoring --- Execution event monitoring. Execution event monitoring
* sysconfig: sysconfig --- Python の構成情報へのアクセスを提供する. Python の構成情報へのアクセスを提供する
* builtins: builtins --- 組み込みオブジェクト. 組み込みオブジェクト
* __main__: __main__ --- トップレベルのコード環境. トップレベルのコード環境
* warnings: warnings --- 警告の制御. 警告の制御
* dataclasses: dataclasses --- データクラス. データクラス
* contextlib: contextlib --- with 文コンテキスト用ユーティリティ. with 文コンテキスト用ユーティリティ
* abc: abc --- 抽象基底クラス. 抽象基底クラス
* atexit: atexit --- 終了ハンドラー. 終了ハンドラー
* traceback: traceback --- スタックトレースの表示または取得. スタックトレースの表示または取得
* __future__: __future__ --- future 文の定義. future 文の定義
* gc: gc --- ガベージコレクターインターフェース. ガベージコレクターインターフェース
* inspect: inspect --- 活動中のオブジェクトを調査する. 活動中のオブジェクトを調査する
* site: site --- サイト固有の設定フック. サイト固有の設定フック


File: python.info,  Node: sys --- システム固有のパラメーターと関数,  Next: sys monitoring --- Execution event monitoring,  Up: Python ランタイムサービス

5.29.1 ‘sys’ -- システム固有のパラメーターと関数
------------------------------------------------

__________________________________________________________________

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

 -- データ: sys.abiflags

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

     Added in version 3.2.

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

     *note Availability: 1cbe.: Unix.

 -- の関数: sys.addaudithook (hook)

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

     When an auditing event is raised through the *note sys.audit():
     151a. 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 *note PySys_AddAuditHook(): 405b. 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.

     Note that audit hooks are primarily for collecting information
     about internal or otherwise unobservable actions, whether by Python
     or libraries written in Python.  They are not suitable for
     implementing a "sandbox".  In particular, malicious code can
     trivially disable or bypass hooks added using this function.  At a
     minimum, any security-sensitive hooks must be added using the C API
     *note PySys_AddAuditHook(): 405b. before initialising the runtime,
     and any modules allowing arbitrary memory modification (such as
     *note ctypes: 22.) should be completely removed or closely
     monitored.

     Calling *note sys.addaudithook(): 405a. will itself raise an
     auditing event named ‘sys.addaudithook’ with no arguments.  If any
     existing hooks raise an exception derived from *note RuntimeError:
     17a, the new hook will not be added and the exception suppressed.
     As a result, callers cannot assume that their hook has been added
     unless they control all existing hooks.

     See the *note audit events table: 17db. for all events raised by
     CPython, and PEP 578(2) for the original design discussion.

     Added in version 3.8.

     バージョン 3.8.1 で変更: *note RuntimeError: 17a. ではない *note
     Exception: 9a7. は抑制されなくなりました。

     'CPython 実装の詳細:' When tracing is enabled (see *note
     settrace(): 14a9.), 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によって異な
     ります。コマンドライン引数に *note -c: 5aa. を付けて Pythonを起動し
     た場合、 ‘argv[0]’ は文字列 ‘'-c'’ となります。スクリプト名なしで
     Pythonを起動した場合、 ‘argv[0]’ は空文字列になります。

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

     See also *note sys.orig_argv: 80b.

          注釈: 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.

     *note sys.audit(): 151a. 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 *note sys.addaudithook(): 405a. or *note
     PySys_AddAuditHook(): 405b. functions.

     The native equivalent of this function is *note PySys_Audit(): 348.
     Using the native function is preferred when possible.

     See the *note audit events table: 17db. for all events raised by
     CPython.

     Added in version 3.8.

 -- データ: sys.base_exec_prefix

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

     Added in version 3.3.

 -- データ: sys.base_prefix

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

     Added in version 3.3.

 -- データ: sys.byteorder

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

 -- データ: sys.builtin_module_names

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

     See also the *note sys.stdlib_module_names: 80c. list.

 -- の関数: sys.call_tracing (func, args)

     Call ‘func(*args)’, while tracing is enabled.  The tracing state is
     saved, and restored afterwards.  This is intended to be called from
     a debugger from a checkpoint, to recursively debug or profile some
     other code.

     Tracing is suspended while calling a tracing function set by *note
     settrace(): 14a9. or *note setprofile(): 14a8. to avoid infinite
     recursion.  ‘call_tracing()’ enables explicit recursion of the
     tracing function.

 -- データ: sys.copyright

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

 -- の関数: sys._clear_type_cache ()

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

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

     バージョン 3.13 で非推奨: Use the more general *note
     _clear_internal_caches(): 15d4. function instead.

 -- の関数: sys._clear_internal_caches ()

     Clear all internal performance-related caches.  Use this function
     'only' to release unnecessary references and memory blocks when
     hunting for leaks.

     Added in version 3.13.

 -- の関数: sys._current_frames ()

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

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

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

     引数無しで *note 監査イベント: 1825. ‘sys._current_frames’ を送出し
     ます。

 -- の関数: sys._current_exceptions ()

     Return a dictionary mapping each thread's identifier to the topmost
     exception currently active in that thread at the time the function
     is called.  If a thread is not currently handling an exception, it
     is not included in the result dictionary.

     This is most useful for statistical profiling.

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

     引数無しで *note 監査イベント: 1825. ‘sys._current_exceptions’ を送
     出します。

     バージョン 3.12 で変更: Each value in the dictionary is now a
     single exception instance, rather than a 3-tuple as returned from
     ‘sys.exc_info()’.

 -- の関数: sys.breakpointhook ()

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

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

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

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

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

     Added in version 3.7.

 -- の関数: sys._debugmallocstats ()

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

     If Python is *note built in debug mode: 1da. (*note configure
     -with-pydebug option: 3fb.), it also performs some expensive
     internal consistency checks.

     Added in version 3.3.

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

 -- データ: sys.dllhandle

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

     *note Availability: 1cbe.: 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の対話セッションで入力された *note 式:
     1ee6. が評価されたときに呼び出されます。対話セッションの出力をカス
     タマイズする場合、 ‘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 で変更: *note UnicodeEncodeError: 643. には
     ‘'backslashreplace'’ エラーハンドラを指定してください。

 -- データ: sys.dont_write_bytecode

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

 -- データ: sys._emscripten_info

     A *note named tuple: 61a. holding information about the environment
     on the 'wasm32-emscripten' platform.  The named tuple is
     provisional and may change in the future.

      -- の属性: _emscripten_info.emscripten_version

          Emscripten version as tuple of ints (major, minor, micro),
          e.g.  ‘(3, 1, 8)’.

      -- の属性: _emscripten_info.runtime

          Runtime string, e.g.  browser user agent, ‘'Node.js
          v14.18.2'’, or ‘'UNKNOWN'’.

      -- の属性: _emscripten_info.pthreads

          ‘True’ if Python is compiled with Emscripten pthreads support.

      -- の属性: _emscripten_info.shared_memory

          ‘True’ if Python is compiled with shared memory support.

     *note Availability: 1cbe.: Emscripten.

     Added in version 3.11.

 -- データ: 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 *note
     compileall: 19. 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 *note -X:
     15c. ‘pycache_prefix=PATH’ command-line option or the *note
     PYTHONPYCACHEPREFIX: 971. environment variable (command-line takes
     precedence).  If neither are set, it is ‘None’.

     Added in version 3.8.

 -- の関数: sys.excepthook (type, value, traceback)

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

     When an exception other than *note SystemExit: d0e. is raised and
     uncaught, the interpreter calls ‘sys.excepthook’ with three
     arguments, the exception class, exception instance, and a traceback
     object.  In an interactive session this happens just before control
     is returned to the prompt; in a Python program this happens just
     before the program exits.  The handling of such top-level
     exceptions can be customized by assigning another three-argument
     function to ‘sys.excepthook’.

     Raise an auditing event ‘sys.excepthook’ with arguments ‘hook’,
     ‘type’, ‘value’, ‘traceback’ when an uncaught exception occurs.  If
     no hook has been set, ‘hook’ may be ‘None’.  If any hook raises an
     exception derived from *note RuntimeError: 17a. the call to the
     hook will be suppressed.  Otherwise, the audit hook exception will
     be reported as unraisable and ‘sys.excepthook’ will be called.

     参考
     ....

     The *note sys.unraisablehook(): 1d8. function handles unraisable
     exceptions and the *note threading.excepthook(): 816. function
     handles exception raised by *note threading.Thread.run(): a0b.

 -- データ: sys.__breakpointhook__
 -- データ: sys.__displayhook__
 -- データ: sys.__excepthook__
 -- データ: sys.__unraisablehook__

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

     Added in version 3.7: __breakpointhook__

     Added in version 3.8: __unraisablehook__

 -- の関数: sys.exception ()

     This function, when called while an exception handler is executing
     (such as an ‘except’ or ‘except*’ clause), returns the exception
     instance that was caught by this handler.  When exception handlers
     are nested within one another, only the exception handled by the
     innermost handler is accessible.

     If no exception handler is executing, this function returns ‘None’.

     Added in version 3.11.

 -- の関数: sys.exc_info ()

     This function returns the old-style representation of the handled
     exception.  If an exception ‘e’ is currently handled (so *note
     exception(): 657. would return ‘e’), *note exc_info(): 656. returns
     the tuple ‘(type(e), e, e.__traceback__)’.  That is, a tuple
     containing the type of the exception (a subclass of *note
     BaseException: 584.), the exception itself, and a *note traceback
     object: ac2. which typically encapsulates the call stack at the
     point where the exception last occurred.

     If no exception is being handled anywhere on the stack, this
     function return a tuple containing three ‘None’ values.

     バージョン 3.11 で変更: The ‘type’ and ‘traceback’ fields are now
     derived from the ‘value’ (the exception instance), so when an
     exception is modified while it is being handled, the changes are
     reflected in the results of subsequent calls to *note exc_info():
     656.

 -- データ: 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 のバージョン番号)。

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

 -- データ: sys.executable

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

 -- の関数: sys.exit ([arg])

     Raise a *note SystemExit: d0e. exception, signaling an intention to
     exit the interpreter.

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

     Since *note exit(): 20ee. 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 *note try: 6b4. statements are honored, and it
     is possible to intercept the exit attempt at an outer level.

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

 -- データ: sys.flags

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

      -- の属性: flags.debug                                *note -d: 1c9b.
                                                            
                                                            
      -- の属性: flags.inspect                              *note -i: 1484.
                                                            
                                                            
      -- の属性: flags.interactive                          *note -i: 1484.
                                                            
                                                            
      -- の属性: flags.isolated                             *note -I: 92c.
                                                            
                                                            
      -- の属性: flags.optimize                             *note -O: d82. または *note -OO: d83.
                                                            
                                                            
      -- の属性: flags.dont_write_bytecode                  *note -B: 1375.
                                                            
                                                            
      -- の属性: flags.no_user_site                         *note -s: 1353.
                                                            
                                                            
      -- の属性: flags.no_site                              *note -S: 1179.
                                                            
                                                            
      -- の属性: flags.ignore_environment                   *note -E: 92b.
                                                            
                                                            
      -- の属性: flags.verbose                              *note -v: 13cc.
                                                            
                                                            
      -- の属性: flags.bytes_warning                        *note -b: 5ad.
                                                            
                                                            
      -- の属性: flags.quiet                                *note -q: 1c9e.
                                                            
                                                            
      -- の属性: flags.hash_randomization                   *note -R: 1a02.
                                                            
                                                            
      -- の属性: flags.dev_mode                             *note -X dev: 15c.
                                                            (*note Python Development Mode: 1d9.)
                                                            
                                                            
      -- の属性: flags.utf8_mode                            *note -X utf8: 15c.
                                                            
                                                            
      -- の属性: flags.safe_path                            *note -P: 56e.
                                                            
                                                            
      -- の属性: flags.int_max_str_digits                   *note -X int_max_str_digits: 15c.
                                                            (*note integer string conversion length limitation: 5bf.)
                                                            
                                                            
      -- の属性: flags.warn_default_encoding                *note -X warn_default_encoding: 15c.
                                                            

     バージョン 3.2 で変更: 新しい *note -q: 1c9e. 向けに ‘quiet’ 属性が
     追加されました。

     Added in version 3.2.3: ‘hash_randomization’ 属性が追加されました。

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

     バージョン 3.4 で変更: *note -I: 92c. ‘isolated’ フラグ向けに
     ‘isolated’ 属性が追加されました。

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

     バージョン 3.10 で変更: Added ‘warn_default_encoding’ attribute for
     *note -X: 15c. ‘warn_default_encoding’ flag.

     バージョン 3.11 で変更: Added the ‘safe_path’ attribute for *note
     -P: 56e. option.

     バージョン 3.11 で変更: Added the ‘int_max_str_digits’ attribute.

 -- データ: sys.float_info

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

     属性                                  float.h のマクロ                      説明
                                                                                 
     ------------------------------------------------------------------------------------------------------------------
                                                                                 
      -- の属性: float_info.epsilon        ‘DBL_EPSILON’                         difference between 1.0 and the
                                                                                 least value greater than 1.0 that
                                                                                 is representable as a float.
                                                                                 
                                                                                 *note math.ulp(): 8e0. を参照してく
                                                                                 ださい。
                                                                                 
                                                                                 
      -- の属性: float_info.dig            ‘DBL_DIG’                             The maximum number of decimal
                                                                                 digits that can be faithfully
                                                                                 represented in a float; see below.
                                                                                 
                                                                                 
      -- の属性: float_info.mant_dig       ‘DBL_MANT_DIG’                        Float precision: the number of
                                                                                 base-‘radix’ digits in the
                                                                                 significand of a float.
                                                                                 
                                                                                 
      -- の属性: float_info.max            ‘DBL_MAX’                             The maximum representable positive
                                                                                 finite float.
                                                                                 
                                                                                 
      -- の属性: float_info.max_exp        ‘DBL_MAX_EXP’                         The maximum integer 'e' such that
                                                                                 ‘radix**(e-1)’ is a representable
                                                                                 finite float.
                                                                                 
                                                                                 
      -- の属性: float_info.max_10_exp     ‘DBL_MAX_10_EXP’                      The maximum integer 'e' such that
                                                                                 ‘10**e’ is in the range of
                                                                                 representable finite floats.
                                                                                 
                                                                                 
      -- の属性: float_info.min            ‘DBL_MIN’                             The minimum representable positive
                                                                                 'normalized' float.
                                                                                 
                                                                                 Use *note math.ulp(0.0): 8e0. to
                                                                                 get the smallest positive
                                                                                 'denormalized' representable float.
                                                                                 
                                                                                 
      -- の属性: float_info.min_exp        ‘DBL_MIN_EXP’                         The minimum integer 'e' such that
                                                                                 ‘radix**(e-1)’ is a normalized
                                                                                 float.
                                                                                 
                                                                                 
      -- の属性: float_info.min_10_exp     ‘DBL_MIN_10_EXP’                      The minimum integer 'e' such that
                                                                                 ‘10**e’ is a normalized float.
                                                                                 
                                                                                 
      -- の属性: float_info.radix          ‘FLT_RADIX’                           The radix of exponent
                                                                                 representation.
                                                                                 
                                                                                 
      -- の属性: float_info.rounds         ‘FLT_ROUNDS’                          An integer representing the
                                                                                 rounding mode for floating-point
                                                                                 arithmetic.  This reflects the
                                                                                 value of the system ‘FLT_ROUNDS’
                                                                                 macro at interpreter startup time:
                                                                                 
                                                                                    * ‘-1’: indeterminable
                                                                                 
                                                                                    * ‘0’: toward zero
                                                                                 
                                                                                    * ‘1’: to nearest
                                                                                 
                                                                                    * ‘2’: toward positive infinity
                                                                                 
                                                                                    * ‘3’: toward negative infinity
                                                                                 
                                                                                 All other values for ‘FLT_ROUNDS’
                                                                                 characterize implementation-defined
                                                                                 rounding behavior.
                                                                                 

     The attribute *note sys.float_info.dig: 41eb. needs further
     explanation.  If ‘s’ is any string representing a decimal number
     with at most ‘sys.float_info.dig’ significant digits, then
     converting ‘s’ to a float and back again will recover a string
     representing the same decimal value:

          >>> 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'

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

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

 -- データ: sys.float_repr_style

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

     Added in version 3.1.

 -- の関数: sys.getallocatedblocks ()

     Return the number of memory blocks currently allocated by the
     interpreter, regardless of their size.  This function is mainly
     useful for tracking and debugging memory leaks.  Because of the
     interpreter's internal caches, the result can vary from call to
     call; you may have to call *note _clear_internal_caches(): 15d4.
     and *note gc.collect(): a08. to get more predictable results.

     If a Python build or implementation cannot reasonably compute this
     information, *note getallocatedblocks(): f92. is allowed to return
     0 instead.

     Added in version 3.4.

 -- の関数: sys.getunicodeinternedsize ()

     Return the number of unicode objects that have been interned.

     Added in version 3.12.

 -- の関数: sys.getandroidapilevel ()

     Return the build-time API level of Android as an integer.  This
     represents the minimum version of Android this build of Python can
     run on.  For runtime version information, see *note
     platform.android_ver(): 15b0.

     *note Availability: 1cbe.: Android.

     Added in version 3.7.

 -- の関数: sys.getdefaultencoding ()

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

 -- の関数: sys.getdlopenflags ()

     Return the current value of the flags that are used for ‘dlopen()’
     calls.  Symbolic names for the flag values can be found in the
     *note os: 91. module (‘RTLD_XXX’ constants, e.g.  *note
     os.RTLD_LAZY: 10eb.).

     *note Availability: 1cbe.: Unix.

 -- の関数: sys.getfilesystemencoding ()

     Get the *note filesystem encoding: 505.: the encoding used with the
     *note filesystem error handler: 505. to convert between Unicode
     filenames and bytes filenames.  The filesystem error handler is
     returned from *note getfilesystemencodeerrors(): cb4.

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

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

     The *note filesystem encoding and error handler: 505. are
     configured at Python startup by the *note PyConfig_Read(): 75b.
     function: see *note filesystem_encoding: 3c2. and *note
     filesystem_errors: 3c3. members of *note PyConfig: 380.

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

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

     バージョン 3.7 で変更: *note Python UTF-8 モード: 622. が有効なら
     ‘"utf-8"’ を返します。

 -- の関数: sys.getfilesystemencodeerrors ()

     Get the *note filesystem error handler: 505.: the error handler
     used with the *note filesystem encoding: 505. to convert between
     Unicode filenames and bytes filenames.  The filesystem encoding is
     returned from *note getfilesystemencoding(): c27.

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

     The *note filesystem encoding and error handler: 505. are
     configured at Python startup by the *note PyConfig_Read(): 75b.
     function: see *note filesystem_encoding: 3c2. and *note
     filesystem_errors: 3c3. members of *note PyConfig: 380.

     Added in version 3.6.

 -- の関数: sys.get_int_max_str_digits ()

     Returns the current value for the *note integer string conversion
     length limitation: 5bf.  See also *note set_int_max_str_digits():
     1729.

     Added in version 3.11.

 -- の関数: sys.getrefcount (object)

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

     戻り値は、実際に保持されているオブジェクトの参照の数を実際に反映し
     ているとは限らないことに注意してください。例えば、一部のオブジェク
     トは永続 (*note immortal: 41f8.) であり、実際の参照の数を反映しない
     非常に高い参照数を持ちます。したがって、 0 か 1 の値以外では、正確
     な戻り値に頼らないでください。

     バージョン 3.12 で変更: Immortal objects have very large refcounts
     that do not match the actual number of references to the object.

 -- の関数: sys.getrecursionlimit ()

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

 -- の関数: sys.getsizeof (object[, default])

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

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

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

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

     See recursive sizeof recipe(4) for an example of using *note
     getsizeof(): 16d5. recursively to find the size of containers and
     all their contents.

 -- の関数: sys.getswitchinterval ()

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

     Added in version 3.2.

 -- の関数: sys._getframe ([depth])

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

     引数 ‘frame’ で *note 監査イベント: 1825. ‘sys._getframe’ を送出し
     ます。

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

 -- の関数: sys._getframemodulename ([depth])

     Return the name of a module from the call stack.  If optional
     integer 'depth' is given, return the module that many calls below
     the top of the stack.  If that is deeper than the call stack, or if
     the module is unidentifiable, ‘None’ is returned.  The default for
     'depth' is zero, returning the module at the top of the call stack.

     Raises an *note auditing event: 1825. ‘sys._getframemodulename’
     with argument ‘depth’.

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

 -- の関数: sys.getobjects (limit[, type])

     This function only exists if CPython was built using the
     specialized configure option *note -with-trace-refs: 36e.  It is
     intended only for debugging garbage-collection issues.

     Return a list of up to 'limit' dynamically allocated Python
     objects.  If 'type' is given, only objects of that exact type (not
     subtypes) are included.

     Objects from the list are not safe to use.  Specifically, the
     result will include objects from all interpreters that share their
     object allocator state (that is, ones created with *note
     PyInterpreterConfig.use_main_obmalloc: 41f9. set to 1 or using
     *note Py_NewInterpreter(): 1721, and the *note main interpreter:
     553.).  Mixing objects from different interpreters may lead to
     crashes or other unexpected behavior.

     'CPython 実装の詳細:' This function should be used for specialized
     purposes only.  It is not guaranteed to exist in all
     implementations of Python.

     バージョン 3.13.0 (unreleased) で変更: The result may include
     objects from other interpreters.

 -- の関数: sys.getprofile ()

     *note setprofile(): 14a8. 関数で設定したプロファイラ関数を取得しま
     す。

 -- の関数: sys.gettrace ()

     *note settrace(): 14a9. 関数で設定したトレース関数を取得します。

     'CPython 実装の詳細:' *note gettrace(): 1389. 関数は、デバッガ、プ
     ロファイラ、カバレッジツールなどの実装に使うことのみを想定していま
     す。この関数の振る舞いは言語定義ではなく実装プラットフォームの一部
     です。そのため、他の 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' will be ‘2’ (VER_PLATFORM_WIN32_NT).

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

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

     This function wraps the Win32 ‘GetVersionEx()’ function; see the
     Microsoft documentation on ‘OSVERSIONINFOEX()’ for more information
     about these fields.

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

          注釈: 'platform_version' derives the version from kernel32.dll
          which can be of a different version than the OS version.
          Please use *note platform: 98. module for achieving accurate
          OS version.

     *note Availability: 1cbe.: 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)’ という形の *note namedtuple: 1ac. に似た形
     をしています。 'firstiter' と 'finalizer' は両方とも ‘None’ か、
     *note asynchronous generator iterator: 41fa. を引数に取る関数と、イ
     ベントループが非同期ジェネレータの終了処理をスケジューリングするの
     に使う関数であることが求められます。

     Added in version 3.6: より詳しくは PEP 525(5) を参照してください。

          注釈: This function has been added on a provisional basis (see
          PEP 411(6) for details.)

 -- の関数: sys.get_coroutine_origin_tracking_depth ()

     Get the current coroutine origin tracking depth, as set by *note
     set_coroutine_origin_tracking_depth(): b5a.

     Added in version 3.7.

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

 -- データ: sys.hash_info

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

      -- の属性: hash_info.width

          The width in bits used for hash values

      -- の属性: hash_info.modulus

          The prime modulus P used for numeric hash scheme

      -- の属性: hash_info.inf

          The hash value returned for a positive infinity

      -- の属性: hash_info.nan

          (This attribute is no longer used)

      -- の属性: hash_info.imag

          The multiplier used for the imaginary part of a complex number

      -- の属性: hash_info.algorithm

          The name of the algorithm for hashing of str, bytes, and
          memoryview

      -- の属性: hash_info.hash_bits

          The internal output size of the hash algorithm

      -- の属性: hash_info.seed_bits

          The size of the seed key of the hash algorithm

     Added in version 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’ は *note hex(): 129d. 関数を使って 16 進数に変換しなけ
     れば値の意味を持ちません。より読みやすいバージョン番号が必要な場合
     には *note named tuple: 61a. *note sys.version_info: 66c. を使用し
     てください。

     ‘hexversion’ のより詳しい情報については *note API と ABI
     のバージョニング: 4203. を参照してください。

 -- データ: sys.implementation

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

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

     'version' は *note sys.version_info: 66c. と同じ形式の、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' は *note sys.hexversion: 4202. と同形式の、16 進数での
     実装のバージョンです。

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

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

     Added in version 3.3.

          注釈: The addition of new required attributes must go through
          the normal PEP process.  See PEP 421(9) for more information.

 -- データ: sys.int_info

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

      -- の属性: int_info.bits_per_digit

          The number of bits held in each digit.  Python integers are
          stored internally in base ‘2**int_info.bits_per_digit’.

      -- の属性: int_info.sizeof_digit

          The size in bytes of the C type used to represent a digit.

      -- の属性: int_info.default_max_str_digits

          The default value for *note sys.get_int_max_str_digits():
          21da. when it is not otherwise explicitly configured.

      -- の属性: int_info.str_digits_check_threshold

          The minimum non-zero value for *note
          sys.set_int_max_str_digits(): 1729, *note
          PYTHONINTMAXSTRDIGITS: 1728, or *note -X int_max_str_digits:
          15c.

     Added in version 3.1.

     バージョン 3.11 で変更: Added *note default_max_str_digits: 21d9.
     and *note str_digits_check_threshold: 4206.

 -- データ: sys.__interactivehook__

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

     Raises an *note auditing event: 1825. ‘cpython.run_interactivehook’
     with the hook object as the argument when the hook is called on
     startup.

     Added in version 3.4.

 -- の関数: sys.intern (string)

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

     Interned strings are not *note immortal: 41f8.; you must keep a
     reference to the return value of *note intern(): 12a9. around to
     benefit from it.

 -- の関数: sys._is_gil_enabled ()

     Return *note True: bdb. if the *note GIL: 13f. is enabled and *note
     False: b05. if it is disabled.

     Added in version 3.13.

 -- の関数: sys.is_finalizing ()

     Return *note True: bdb. if the main Python interpreter is *note
     shutting down: 134.  Return *note False: b05. otherwise.

     See also the *note PythonFinalizationError: 133. exception.

     Added in version 3.5.

 -- データ: sys.last_exc

     This variable is not always defined; it is set to the exception
     instance when an exception is not handled and the interpreter
     prints an error message and a stack traceback.  Its intended use is
     to allow an interactive user to import a debugger module and engage
     in post-mortem debugging without having to re-execute the command
     that caused the error.  (Typical use is ‘import pdb; pdb.pm()’ to
     enter the post-mortem debugger; see *note pdb: 94. module for more
     information.)

     Added in version 3.12.

 -- の関数: sys._is_interned (string)

     Return *note True: bdb. if the given string is "interned", *note
     False: b05. otherwise.

     Added in version 3.13.

     'CPython 実装の詳細:' It is not guaranteed to exist in all
     implementations of Python.

 -- データ: sys.last_type
 -- データ: sys.last_value
 -- データ: sys.last_traceback

     These three variables are deprecated; use *note sys.last_exc: 48a.
     instead.  They hold the legacy representation of ‘sys.last_exc’, as
     returned from *note exc_info(): 656. above.

 -- データ: sys.maxsize

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

 -- データ: sys.maxunicode

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

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

 -- データ: sys.meta_path

     A list of *note meta path finder: 1045. objects that have their
     *note find_spec(): 834. methods called to see if one of the objects
     can find the module to be imported.  By default, it holds entries
     that implement Python's default import semantics.  The *note
     find_spec(): 834. 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 *note __path__:
     1bd8. attribute is passed in as a second argument.  The method
     returns a *note module spec: 1e76, or ‘None’ if the module cannot
     be found.

     参考
     ....

     *note importlib.abc.MetaPathFinder: 83a.

          The abstract base class defining the interface of finder
          objects on *note meta_path: cf9.

     *note importlib.machinery.ModuleSpec: 1dcb.

          The concrete class which *note find_spec(): 834. should return
          instances of.

     バージョン 3.4 で変更: *note Module specs: 1e76. were introduced in
     Python 3.4, by PEP 451(11).

     バージョン 3.12 で変更: Removed the fallback that looked for a
     ‘find_module()’ method if a *note meta_path: cf9. entry didn't have
     a *note find_spec(): 834. method.

 -- データ: sys.modules

     This is a dictionary that maps module names to modules which have
     already been loaded.  This can be manipulated to force reloading of
     modules and other tricks.  However, replacing the dictionary will
     not necessarily work as expected and deleting essential items from
     the dictionary may cause Python to fail.  If you want to iterate
     over this global dictionary always use ‘sys.modules.copy()’ or
     ‘tuple(sys.modules)’ to avoid exceptions as its size may change
     during iteration as a side effect of code or activity in other
     threads.

 -- データ: sys.orig_argv

     The list of the original command line arguments passed to the
     Python executable.

     The elements of *note sys.orig_argv: 80b. are the arguments to the
     Python interpreter, while the elements of *note sys.argv: 1236. are
     the arguments to the user's program.  Arguments consumed by the
     interpreter itself will be present in *note sys.orig_argv: 80b. and
     missing from *note sys.argv: 1236.

     Added in version 3.10.

 -- データ: sys.path

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

     By default, as initialized upon program startup, a potentially
     unsafe path is prepended to *note sys.path: 38e. ('before' the
     entries inserted as a result of *note PYTHONPATH: fe8.):

        * ‘python -m module’ command line: prepend the current working
          directory.

        * ‘python script.py’ command line: prepend the script's
          directory.  If it's a symbolic link, resolve symbolic links.

        * ‘python -c code’ and ‘python’ (REPL) command lines: prepend an
          empty string, which means the current working directory.

     To not prepend this potentially unsafe path, use the *note -P: 56e.
     command line option or the *note PYTHONSAFEPATH: 56f. environment
     variable.

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

     参考
     ....

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

 -- データ: sys.path_hooks

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

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

 -- データ: sys.path_importer_cache

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

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

 -- データ: sys.platform

     A string containing a platform identifier.  Known values are:

     システム             ‘platform’ の値
                          
     -----------------------------------------------------
                          
     AIX                  ‘'aix'’
                          
                          
     Android              ‘'android'’
                          
                          
     Emscripten           ‘'emscripten'’
                          
                          
     iOS                  ‘'ios'’
                          
                          
     Linux                ‘'linux'’
                          
                          
     macOS                ‘'darwin'’
                          
                          
     Windows              ‘'win32'’
                          
                          
     Windows/Cygwin       ‘'cygwin'’
                          
                          
     WASI                 ‘'wasi'’
                          

     On Unix systems not listed in the table, the value is the
     lowercased OS name as returned by ‘uname -s’, with the first part
     of the version as returned by ‘uname -r’ appended, e.g.  ‘'sunos5'’
     or ‘'freebsd8'’, 'at the time when Python was built'.  Unless you
     want to test for a specific system version, it is therefore
     recommended to use the following idiom:

          if sys.platform.startswith('freebsd'):
              # FreeBSD-specific code here...

     バージョン 3.3 で変更: On Linux, *note sys.platform: a5b. doesn't
     contain the major version anymore.  It is always ‘'linux'’, instead
     of ‘'linux2'’ or ‘'linux3'’.

     バージョン 3.8 で変更: On AIX, *note sys.platform: a5b. doesn't
     contain the major version anymore.  It is always ‘'aix'’, instead
     of ‘'aix5'’ or ‘'aix7'’.

     バージョン 3.13 で変更: On Android, *note sys.platform: a5b. now
     returns ‘'android'’ rather than ‘'linux'’.

     参考
     ....

     *note os.name: 2a60. has a coarser granularity.  *note os.uname():
     10e9. gives system-dependent version information.

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

 -- データ: 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
          *note os: 91. module)

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

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

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

     Added in version 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
     *note -prefix: 1cca. argument to the ‘configure’ script.  See *note
     インストールパス: 65b. for derived paths.

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

 -- データ: sys.ps1
 -- データ: sys.ps2

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

 -- の関数: sys.setdlopenflags (n)

     Set the flags used by the interpreter for ‘dlopen()’ calls, such as
     when the interpreter loads extension modules.  Among other things,
     this will enable a lazy resolving of symbols when importing a
     module, if called as ‘sys.setdlopenflags(0)’.  To share symbols
     across extension modules, call as
     ‘sys.setdlopenflags(os.RTLD_GLOBAL)’.  Symbolic names for the flag
     values can be found in the *note os: 91. module (‘RTLD_XXX’
     constants, e.g.  *note os.RTLD_LAZY: 10eb.).

     *note Availability: 1cbe.: Unix.

 -- の関数: sys.set_int_max_str_digits (maxdigits)

     Set the *note integer string conversion length limitation: 5bf.
     used by this interpreter.  See also *note get_int_max_str_digits():
     21da.

     Added in version 3.11.

 -- の関数: sys.setprofile (profilefunc)

     Set the system's profile function, which allows you to implement a
     Python source code profiler in Python.  See chapter *note Python
     プロファイラ: 40f1. for more information on the Python profiler.
     The system's profile function is called similarly to the system's
     trace function (see *note settrace(): 14a9.), 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.

          注釈: The same tracing mechanism is used for ‘setprofile()’ as
          *note settrace(): 14a9.  To trace calls with ‘setprofile()’
          inside a tracing function (e.g.  in a debugger breakpoint),
          see *note call_tracing(): 179d.

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

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

     ‘'call'’

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

     ‘'return'’

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

     ‘'c_call'’

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

     ‘'c_return'’

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

     ‘'c_exception'’

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

     引数無しで *note 監査イベント: 1825. ‘sys.setprofile’ を送出します
     。

 -- の関数: sys.setrecursionlimit (limit)

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

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

     If the new limit is too low at the current recursion depth, a *note
     RecursionError: d39. exception is raised.

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

 -- の関数: sys.setswitchinterval (interval)

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

     Added in version 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 *note settrace(): 14a9. for
     each thread being debugged or use *note threading.settrace(): 813.

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

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

     The local trace function should return a reference to itself, or to
     another function which would then be used as the local trace
     function for the scope.

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

          注釈: Tracing is disabled while calling the trace function
          (e.g.  a function set by ‘settrace()’).  For recursive tracing
          see *note call_tracing(): 179d.

     '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 *note f_trace_lines: ba9.
          to *note False: b05. on that *note frame: 6ab.

     ‘'return'’

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

     ‘'exception'’

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

     ‘'opcode'’

          The interpreter is about to execute a new opcode (see *note
          dis: 30. 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 *note
          f_trace_opcodes: baa. to *note True: bdb. on the *note frame:
          6ab.

     例外が呼び出しチェインを辿って伝播していくことに注意してください。
     ‘'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 *note
     settrace(): 14a9. doesn't do.  Note that in order for this to work,
     a global tracing function must have been installed with *note
     settrace(): 14a9. 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 オブジェクトについては、 *note 標準型の階層: 1e46. を
     参照してください。

     引数無しで *note 監査イベント: 1825. ‘sys.settrace’ を送出します。

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

     バージョン 3.7 で変更: ‘'opcode'’ event type added; *note
     f_trace_lines: ba9. and *note f_trace_opcodes: baa. attributes
     added to frames

 -- の関数: sys.set_asyncgen_hooks ([firstiter] [, finalizer])

     Accepts two optional keyword arguments which are callables that
     accept an *note asynchronous generator iterator: 41fa. 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.

     引数無しで *note 監査イベント: 1825.
     ‘sys.set_asyncgen_hooks_firstiter’ を送出します。

     引数無しで *note 監査イベント: 1825.
     ‘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.

     Added in version 3.6: See PEP 525(14) 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(15)

          注釈: This function has been added on a provisional basis (see
          PEP 411(16) 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.

     Added in version 3.7.

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

 -- の関数: sys.activate_stack_trampoline (backend, /)

     Activate the stack profiler trampoline 'backend'.  The only
     supported backend is ‘"perf"’.

     *note Availability: 1cbe.: Linux.

     Added in version 3.12.

     参考
     ....

        * *note Python support for the Linux perf profiler: 174.

        * ‘https://perf.wiki.kernel.org’

 -- の関数: sys.deactivate_stack_trampoline ()

     Deactivate the current stack profiler trampoline backend.

     If no stack profiler is activated, this function has no effect.

     *note Availability: 1cbe.: Linux.

     Added in version 3.12.

 -- の関数: sys.is_stack_trampoline_active ()

     Return ‘True’ if a stack profiler trampoline is active.

     *note Availability: 1cbe.: Linux.

     Added in version 3.12.

 -- の関数: sys._enablelegacywindowsfsencoding ()

     Changes the *note filesystem encoding and error handler: 505. to
     'mbcs' and 'replace' respectively, for consistency with versions of
     Python prior to 3.6.

     This is equivalent to defining the *note
     PYTHONLEGACYWINDOWSFSENCODING: 28f. environment variable before
     launching Python.

     See also *note sys.getfilesystemencoding(): c27. and *note
     sys.getfilesystemencodeerrors(): cb4.

     *note Availability: 1cbe.: Windows.

          注釈: Changing the filesystem encoding after Python startup is
          risky because the old fsencoding or paths encoded by the old
          fsencoding may be cached somewhere.  Use *note
          PYTHONLEGACYWINDOWSFSENCODING: 28f. instead.

     Added in version 3.6: より詳しくは PEP 529(18) を参照してください。

     Deprecated since version 3.13, will be removed in version 3.16: Use
     *note PYTHONLEGACYWINDOWSFSENCODING: 28f. instead.

 -- データ: sys.stdin
 -- データ: sys.stdout
 -- データ: sys.stderr

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

        * ‘stdin’ は (*note input(): 12a6. の呼び出しも含む) すべての対
          話型入力に使われます。

        * ‘stdout’ は *note print(): f42. および *note expression: 1ee6.
          文の出力と、*note input(): 12a6. のプロンプトに使用されます。

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

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

        * The encoding and error handling are is initialized from *note
          PyConfig.stdio_encoding: 37d. and *note PyConfig.stdio_errors:
          4208.

          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 *note locale
          encoding: 223. 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 *note PYTHONIOENCODING: fd5. environment
          variable before starting Python or by using the new *note -X:
          15c. ‘utf8’ command line option and *note PYTHONUTF8: aa6.
          environment variable.  However, for the Windows console, this
          only applies when *note PYTHONLEGACYWINDOWSSTDIO: c29. 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 *note -u: 190f.
          command-line option or setting the *note PYTHONUNBUFFERED:
          1910. environment variable.

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

          注釈: 標準ストリームにバイナリーデータの読み書きを行うには下位
          のバイナリー *note buffer: 1274. オブジェクトを使用してくださ
          い。例えば *note bytes: 1a4. を *note stdout: aa4. に書き出す
          場合は ‘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
          *note io.StringIO: ef3. 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.stdlib_module_names

     A frozenset of strings containing the names of standard library
     modules.

     It is the same on all platforms.  Modules which are not available
     on some platforms and modules disabled at Python build are also
     listed.  All module kinds are listed: pure Python, built-in, frozen
     and extension modules.  Test modules are excluded.

     For packages, only the main package is listed: sub-packages and
     sub-modules are not listed.  For example, the ‘email’ package is
     listed, but the ‘email.mime’ sub-package and the ‘email.message’
     sub-module are not listed.

     See also the *note sys.builtin_module_names: 1bc9. list.

     Added in version 3.10.

 -- データ: sys.thread_info

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

      -- の属性: thread_info.name

          The name of the thread implementation:

             * ‘"nt"’: Windows threads

             * ‘"pthread"’: POSIX threads

             * ‘"pthread-stubs"’: stub POSIX threads (on WebAssembly
               platforms without threading support)

             * ‘"solaris"’: Solaris threads

      -- の属性: thread_info.lock

          The name of the lock implementation:

             * ‘"semaphore"’: a lock uses a semaphore

             * ‘"mutex+cond"’: a lock uses a mutex and a condition
               variable

             * ‘None’ この情報が不明の場合

      -- の属性: thread_info.version

          The name and version of the thread library.  It is a string,
          or ‘None’ if this information is unknown.

     Added in version 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 (*note gc.collect(): a08.).

     The 'unraisable' argument has the following attributes:

        * ‘exc_type’: Exception type.

        * ‘exc_value’: Exception value, can be ‘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’.

     *note sys.unraisablehook(): 1d8. can be overridden to control how
     unraisable exceptions are handled.

     参考
     ....

     *note excepthook(): 7d6. which handles uncaught exceptions.

          警告: 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.

     Raise an auditing event ‘sys.unraisablehook’ with arguments 'hook',
     'unraisable' when an exception that cannot be handled occurs.  The
     'unraisable' object is the same as what will be passed to the hook.
     If no hook has been set, 'hook' may be ‘None’.

     Added in version 3.8.

 -- データ: sys.version

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

 -- データ: 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 フレームワーク内部のみ使用され、変更することはで
     きません。詳細は *note warnings: fa. を参照してください。

 -- データ: sys.winver

     The version number used to form registry keys on Windows platforms.
     This is stored as string resource 1000 in the Python DLL. The value
     is normally the major and minor versions of the running Python
     interpreter.  It is provided in the *note sys: c3. module for
     informational purposes; modifying this value has no effect on the
     registry keys used by Python.

     *note Availability: 1cbe.: Windows.

 -- データ: sys.monitoring

     Namespace containing functions and constants for register callbacks
     and controlling monitoring events.  See *note sys.monitoring: c4.
     for details.

 -- データ: sys._xoptions

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

          $ ./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 実装の詳細:' この *note -X: 15c. によって渡されたオプショ
     ンにアクセスする方法は CPython 固有です。他の実装ではそれらは他の意
     味でエクスポートされるか、あるいは何もしません。

     Added in version 3.2.

出典
....

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

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3149/

   (2) https://peps.python.org/pep-0578/

   (3) https://peps.python.org/pep-0529/

   (4) 
https://code.activestate.com/recipes/577504-compute-memory-footprint-of-an-object-and-its-cont/

   (5) https://peps.python.org/pep-0525/

   (6) https://peps.python.org/pep-0411/

   (7) https://peps.python.org/pep-0411/

   (8) https://peps.python.org/pep-0421/

   (9) https://peps.python.org/pep-0421/

   (10) https://peps.python.org/pep-0393/

   (11) https://peps.python.org/pep-0451/

   (12) https://peps.python.org/pep-0302/

   (13) https://peps.python.org/pep-0302/

   (14) https://peps.python.org/pep-0525/

   (15) 
https://github.com/python/cpython/tree/3.13/Lib/asyncio/base_events.py

   (16) https://peps.python.org/pep-0411/

   (17) https://peps.python.org/pep-0411/

   (18) https://peps.python.org/pep-0529/


File: python.info,  Node: sys monitoring --- Execution event monitoring,  Next: sysconfig --- Python の構成情報へのアクセスを提供する,  Prev: sys --- システム固有のパラメーターと関数,  Up: Python ランタイムサービス

5.29.2 ‘sys.monitoring’ -- Execution event monitoring
-----------------------------------------------------

Added in version 3.12.

__________________________________________________________________

     注釈: *note sys.monitoring: c4. is a namespace within the *note
     sys: c3. module, not an independent module, so there is no need to
     ‘import sys.monitoring’, simply ‘import sys’ and then use
     ‘sys.monitoring’.

This namespace provides access to the functions and constants necessary
to activate and control event monitoring.

As programs execute, events occur that might be of interest to tools
that monitor execution.  The *note sys.monitoring: c4. namespace
provides means to receive callbacks when events of interest occur.

The monitoring API consists of three components:

   * *note Tool identifiers: 4211.

   * *note Events: 4212.

   * *note Callbacks: 4213.

* Menu:

* Tool identifiers::
* Events::
* Turning events on and off::
* Registering callback functions::


File: python.info,  Node: Tool identifiers,  Next: Events,  Up: sys monitoring --- Execution event monitoring

5.29.2.1 Tool identifiers
.........................

A tool identifier is an integer and the associated name.  Tool
identifiers are used to discourage tools from interfering with each
other and to allow multiple tools to operate at the same time.
Currently tools are completely independent and cannot be used to monitor
each other.  This restriction may be lifted in the future.

Before registering or activating events, a tool should choose an
identifier.  Identifiers are integers in the range 0 to 5 inclusive.

* Menu:

* Registering and using tools::


File: python.info,  Node: Registering and using tools,  Up: Tool identifiers

5.29.2.2 Registering and using tools
....................................

 -- の関数: sys.monitoring.use_tool_id (tool_id: int, name: str, /) ->
          None

     Must be called before 'tool_id' can be used.  'tool_id' must be in
     the range 0 to 5 inclusive.  Raises a *note ValueError: 1e3. if
     'tool_id' is in use.

 -- の関数: sys.monitoring.free_tool_id (tool_id: int, /) -> None

     Should be called once a tool no longer requires 'tool_id'.

     注釈: *note free_tool_id(): 4216. will not disable global or local
     events associated with 'tool_id', nor will it unregister any
     callback functions.  This function is only intended to be used to
     notify the VM that the particular 'tool_id' is no longer in use.

 -- の関数: sys.monitoring.get_tool (tool_id: int, /) -> str | None

     Returns the name of the tool if 'tool_id' is in use, otherwise it
     returns ‘None’.  'tool_id' must be in the range 0 to 5 inclusive.

All IDs are treated the same by the VM with regard to events, but the
following IDs are pre-defined to make co-operation of tools easier:

     sys.monitoring.DEBUGGER_ID = 0
     sys.monitoring.COVERAGE_ID = 1
     sys.monitoring.PROFILER_ID = 2
     sys.monitoring.OPTIMIZER_ID = 5


File: python.info,  Node: Events,  Next: Turning events on and off,  Prev: Tool identifiers,  Up: sys monitoring --- Execution event monitoring

5.29.2.3 Events
...............

The following events are supported:

 -- monitoring-event: sys.monitoring.events.BRANCH

     A conditional branch is taken (or not).

 -- monitoring-event: sys.monitoring.events.CALL

     A call in Python code (event occurs before the call).

 -- monitoring-event: sys.monitoring.events.C_RAISE

     An exception raised from any callable, except for Python functions
     (event occurs after the exit).

 -- monitoring-event: sys.monitoring.events.C_RETURN

     Return from any callable, except for Python functions (event occurs
     after the return).

 -- monitoring-event: sys.monitoring.events.EXCEPTION_HANDLED

     An exception is handled.

 -- monitoring-event: sys.monitoring.events.INSTRUCTION

     A VM instruction is about to be executed.

 -- monitoring-event: sys.monitoring.events.JUMP

     An unconditional jump in the control flow graph is made.

 -- monitoring-event: sys.monitoring.events.LINE

     An instruction is about to be executed that has a different line
     number from the preceding instruction.

 -- monitoring-event: sys.monitoring.events.PY_RESUME

     Resumption of a Python function (for generator and coroutine
     functions), except for ‘throw()’ calls.

 -- monitoring-event: sys.monitoring.events.PY_RETURN

     Return from a Python function (occurs immediately before the
     return, the callee's frame will be on the stack).

 -- monitoring-event: sys.monitoring.events.PY_START

     Start of a Python function (occurs immediately after the call, the
     callee's frame will be on the stack)

 -- monitoring-event: sys.monitoring.events.PY_THROW

     A Python function is resumed by a ‘throw()’ call.

 -- monitoring-event: sys.monitoring.events.PY_UNWIND

     Exit from a Python function during exception unwinding.

 -- monitoring-event: sys.monitoring.events.PY_YIELD

     Yield from a Python function (occurs immediately before the yield,
     the callee's frame will be on the stack).

 -- monitoring-event: sys.monitoring.events.RAISE

     An exception is raised, except those that cause a *note
     STOP_ITERATION: 4225. event.

 -- monitoring-event: sys.monitoring.events.RERAISE

     An exception is re-raised, for example at the end of a *note
     finally: 997. block.

 -- monitoring-event: sys.monitoring.events.STOP_ITERATION

     An artificial *note StopIteration: bc8. is raised; see *note the
     STOP_ITERATION event: 4227.

More events may be added in the future.

These events are attributes of the ‘sys.monitoring.events’ namespace.
Each event is represented as a power-of-2 integer constant.  To define a
set of events, simply bitwise or the individual events together.  For
example, to specify both *note PY_RETURN: 4220. and *note PY_START:
4221. events, use the expression ‘PY_RETURN | PY_START’.

 -- monitoring-event: sys.monitoring.events.NO_EVENTS

     An alias for ‘0’ so users can do explicit comparisons like:

          if get_events(DEBUGGER_ID) == NO_EVENTS:
              ...

Events are divided into three groups:

* Menu:

* Local events::
* Ancillary events::
* Other events::
* The STOP_ITERATION event::


File: python.info,  Node: Local events,  Next: Ancillary events,  Up: Events

5.29.2.4 Local events
.....................

Local events are associated with normal execution of the program and
happen at clearly defined locations.  All local events can be disabled.
The local events are:

   * *note PY_START: 4221.

   * *note PY_RESUME: 421f.

   * *note PY_RETURN: 4220.

   * *note PY_YIELD: 4224.

   * *note CALL: 15aa.

   * *note LINE: 421e.

   * *note INSTRUCTION: 421c.

   * *note JUMP: 421d.

   * *note BRANCH: 4218.

   * *note STOP_ITERATION: 4225.


File: python.info,  Node: Ancillary events,  Next: Other events,  Prev: Local events,  Up: Events

5.29.2.5 Ancillary events
.........................

Ancillary events can be monitored like other events, but are controlled
by another event:

   * *note C_RAISE: 4219.

   * *note C_RETURN: 421a.

The *note C_RETURN: 421a. and *note C_RAISE: 4219. events are controlled
by the *note CALL: 15aa. event.  *note C_RETURN: 421a. and *note
C_RAISE: 4219. events will only be seen if the corresponding *note CALL:
15aa. event is being monitored.


File: python.info,  Node: Other events,  Next: The STOP_ITERATION event,  Prev: Ancillary events,  Up: Events

5.29.2.6 Other events
.....................

Other events are not necessarily tied to a specific location in the
program and cannot be individually disabled.

The other events that can be monitored are:

   * *note PY_THROW: 4222.

   * *note PY_UNWIND: 4223.

   * *note RAISE: 1552.

   * *note EXCEPTION_HANDLED: 421b.


File: python.info,  Node: The STOP_ITERATION event,  Prev: Other events,  Up: Events

5.29.2.7 The STOP_ITERATION event
.................................

PEP 380(1) specifies that a *note StopIteration: bc8. exception is
raised when returning a value from a generator or coroutine.  However,
this is a very inefficient way to return a value, so some Python
implementations, notably CPython 3.12+, do not raise an exception unless
it would be visible to other code.

To allow tools to monitor for real exceptions without slowing down
generators and coroutines, the *note STOP_ITERATION: 4225. event is
provided.  *note STOP_ITERATION: 4225. can be locally disabled, unlike
*note RAISE: 1552.

   ---------- Footnotes ----------

   (1) 
https://peps.python.org/pep-0380/#use-of-stopiteration-to-return-values


File: python.info,  Node: Turning events on and off,  Next: Registering callback functions,  Prev: Events,  Up: sys monitoring --- Execution event monitoring

5.29.2.8 Turning events on and off
..................................

In order to monitor an event, it must be turned on and a corresponding
callback must be registered.  Events can be turned on or off by setting
the events either globally or for a particular code object.

* Menu:

* Setting events globally::
* Per code object events::
* Disabling events::


File: python.info,  Node: Setting events globally,  Next: Per code object events,  Up: Turning events on and off

5.29.2.9 Setting events globally
................................

Events can be controlled globally by modifying the set of events being
monitored.

 -- の関数: sys.monitoring.get_events (tool_id: int, /) -> int

     Returns the ‘int’ representing all the active events.

 -- の関数: sys.monitoring.set_events (tool_id: int, event_set: int, /)
          -> None

     Activates all events which are set in 'event_set'.  Raises a *note
     ValueError: 1e3. if 'tool_id' is not in use.

No events are active by default.


File: python.info,  Node: Per code object events,  Next: Disabling events,  Prev: Setting events globally,  Up: Turning events on and off

5.29.2.10 Per code object events
................................

Events can also be controlled on a per code object basis.  The functions
defined below which accept a *note types.CodeType: 2c0. should be
prepared to accept a look-alike object from functions which are not
defined in Python (see *note Monitoring C API: 142.).

 -- の関数: sys.monitoring.get_local_events (tool_id: int, code:
          CodeType, /) -> int

     Returns all the local events for 'code'

 -- の関数: sys.monitoring.set_local_events (tool_id: int, code:
          CodeType, event_set: int, /) -> None

     Activates all the local events for 'code' which are set in
     'event_set'.  Raises a *note ValueError: 1e3. if 'tool_id' is not
     in use.

Local events add to global events, but do not mask them.  In other
words, all global events will trigger for a code object, regardless of
the local events.


File: python.info,  Node: Disabling events,  Prev: Per code object events,  Up: Turning events on and off

5.29.2.11 Disabling events
..........................

 -- データ: sys.monitoring.DISABLE

     A special value that can be returned from a callback function to
     disable events for the current code location.

Local events can be disabled for a specific code location by returning
*note sys.monitoring.DISABLE: 4234. from a callback function.  This does
not change which events are set, or any other code locations for the
same event.

Disabling events for specific locations is very important for high
performance monitoring.  For example, a program can be run under a
debugger with no overhead if the debugger disables all monitoring except
for a few breakpoints.

 -- の関数: sys.monitoring.restart_events () -> None

     Enable all the events that were disabled by *note
     sys.monitoring.DISABLE: 4234. for all tools.


File: python.info,  Node: Registering callback functions,  Prev: Turning events on and off,  Up: sys monitoring --- Execution event monitoring

5.29.2.12 Registering callback functions
........................................

To register a callable for events call

 -- の関数: sys.monitoring.register_callback (tool_id: int, event: int,
          func: Callable | None, /) -> Callable | None

     Registers the callable 'func' for the 'event' with the given
     'tool_id'

     If another callback was registered for the given 'tool_id' and
     'event', it is unregistered and returned.  Otherwise *note
     register_callback(): 4237. returns ‘None’.

Functions can be unregistered by calling
‘sys.monitoring.register_callback(tool_id, event, None)’.

Callback functions can be registered and unregistered at any time.

Registering or unregistering a callback function will generate a *note
sys.audit(): 151a. event.

* Menu:

* Callback function arguments::


File: python.info,  Node: Callback function arguments,  Up: Registering callback functions

5.29.2.13 Callback function arguments
.....................................

 -- データ: sys.monitoring.MISSING

     A special value that is passed to a callback function to indicate
     that there are no arguments to the call.

When an active event occurs, the registered callback function is called.
Different events will provide the callback function with different
arguments, as follows:

   * *note PY_START: 4221. and *note PY_RESUME: 421f.:

          func(code: CodeType, instruction_offset: int) -> DISABLE | Any

   * *note PY_RETURN: 4220. and *note PY_YIELD: 4224.:

          func(code: CodeType, instruction_offset: int, retval: object) -> DISABLE | Any

   * *note CALL: 15aa, *note C_RAISE: 4219. and *note C_RETURN: 421a.:

          func(code: CodeType, instruction_offset: int, callable: object, arg0: object | MISSING) -> DISABLE | Any

     If there are no arguments, 'arg0' is set to *note
     sys.monitoring.MISSING: 4239.

   * *note RAISE: 1552, *note RERAISE: 4226, *note EXCEPTION_HANDLED:
     421b, *note PY_UNWIND: 4223, *note PY_THROW: 4222. and *note
     STOP_ITERATION: 4225.:

          func(code: CodeType, instruction_offset: int, exception: BaseException) -> DISABLE | Any

   * *note LINE: 421e.:

          func(code: CodeType, line_number: int) -> DISABLE | Any

   * *note BRANCH: 4218. and *note JUMP: 421d.:

          func(code: CodeType, instruction_offset: int, destination_offset: int) -> DISABLE | Any

     Note that the 'destination_offset' is where the code will next
     execute.  For an untaken branch this will be the offset of the
     instruction following the branch.

   * *note INSTRUCTION: 421c.:

          func(code: CodeType, instruction_offset: int) -> DISABLE | Any


File: python.info,  Node: sysconfig --- Python の構成情報へのアクセスを提供する,  Next: builtins --- 組み込みオブジェクト,  Prev: sys monitoring --- Execution event monitoring,  Up: Python ランタイムサービス

5.29.3 ‘sysconfig’ -- Python の構成情報へのアクセスを提供する
-------------------------------------------------------------

Added in version 3.2.

'ソースコード:' Lib/sysconfig(1)

__________________________________________________________________

*note sysconfig: c5. モジュールは、インストールパスのリストや、現在のプ
ラットフォームに関連した構成などの、Python の構成情報 (configuration
information) へのアクセスを提供します。

* Menu:

* 構成変数::
* インストールパス::
* User scheme::
* Home scheme::
* Prefix scheme::
* Installation path functions::
* その他の関数: その他の関数<3>.
* sysconfig をスクリプトとして使う::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/sysconfig


File: python.info,  Node: 構成変数,  Next: インストールパス,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.1 構成変数
.................

Python の配布物は、Python 自体のバイナリや、 ‘setuptools’ によってコンパ
イルされるサードパーティの C 拡張をビルドするために必要な、‘Makefile’ と
‘pyconfig.h’ ヘッダーファイルを含んでいます。

*note sysconfig: c5. はこれらのファイルに含まれるすべての変数を辞書に格
納し、*note get_config_vars(): ff6. や *note get_config_var(): ff5. でア
クセスできるようにします。

Windows では構成変数はだいぶ少なくなります。

 -- の関数: sysconfig.get_config_vars (*args)

     引数がない場合、現在のプラットフォームに関するすべての構成変数の辞
     書を返します。

     引数がある場合、各引数を構成変数辞書から検索した結果の変数のリスト
     を返します。

     各引数において、変数が見つからなかった場合は ‘None’ が返されます。

 -- の関数: sysconfig.get_config_var (name)

     1つの変数 'name' を返します。‘get_config_vars().get(name)’ と同じで
     す。

     'name' が見つからない場合、‘None’ を返します。

Example of usage:

     >>> import sysconfig
     >>> sysconfig.get_config_var('Py_ENABLE_SHARED')
     0
     >>> sysconfig.get_config_var('LIBDIR')
     '/usr/local/lib'
     >>> sysconfig.get_config_vars('AR', 'CXX')
     ['ar', 'g++']


File: python.info,  Node: インストールパス,  Next: User scheme,  Prev: 構成変数,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.2 インストールパス
.........................

Python uses an installation scheme that differs depending on the
platform and on the installation options.  These schemes are stored in
*note sysconfig: c5. under unique identifiers based on the value
returned by *note os.name: 2a60.  The schemes are used by package
installers to determine where to copy files to.

Python は現在9つのスキームをサポートしています:

   - 'posix_prefix': Linux や macOS などの POSIX プラットフォーム用のス
     キームです。これは Python やコンポーネントをインストールするときに
     使われるデフォルトのスキームです。

   - 'posix_home': scheme for POSIX platforms, when the 'home' option is
     used.  This scheme defines paths located under a specific home
     prefix.

   - 'posix_user': scheme for POSIX platforms, when the 'user' option is
     used.  This scheme defines paths located under the user's home
     directory (*note site.USER_BASE: 12eb.).

   - 'posix_venv': scheme for *note Python virtual environments: f9. on
     POSIX platforms; by default it is the same as 'posix_prefix'.

   - 'nt': scheme for Windows.  This is the default scheme used when
     Python or a component is installed.

   - 'nt_user': scheme for Windows, when the 'user' option is used.

   - 'nt_venv': scheme for *note Python virtual environments: f9. on
     Windows; by default it is the same as 'nt'.

   - 'venv': a scheme with values from either 'posix_venv' or 'nt_venv'
     depending on the platform Python runs on.

   - 'osx_framework_user' オプションが利用された場合の、macOS 用のスキー
     ムです。

各スキームは、ユニークな識別子を持ったいくつかのパスの集合から成っていま
す。現在 Python は8つのパスを利用します:

   - 'stdlib': プラットフォーム非依存の、標準 Python ライブラリファイル
     を格納するディレクトリ.

   - 'platstdlib': プラットフォーム依存の、標準 Python ライブラリファイ
     ルを格納するディレクトリ.

   - 'platlib': プラットフォーム依存の、site ごとのファイルを格納するデ
     ィレクトリ。

   - 'purelib': directory for site-specific, non-platform-specific files
     ('pure' Python).

   - 'include': directory for non-platform-specific header files for the
     Python C-API.

   - 'platinclude': directory for platform-specific header files for the
     Python C-API.

   - 'scripts': スクリプトファイルのためのディレクトリ。

   - 'data': データファイルのためのディレクトリ。


File: python.info,  Node: User scheme,  Next: Home scheme,  Prev: インストールパス,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.3 User scheme
....................

This scheme is designed to be the most convenient solution for users
that don't have write permission to the global site-packages directory
or don't want to install into it.

Files will be installed into subdirectories of *note site.USER_BASE:
12eb. (written as ‘`userbase'’ hereafter).  This scheme installs pure
Python modules and extension modules in the same location (also known as
*note site.USER_SITE: 1c9f.).

* Menu:

* posix_user::
* nt_user::
* osx_framework_user::


File: python.info,  Node: posix_user,  Next: nt_user,  Up: User scheme

5.29.3.4 ‘posix_user’
.....................

Path               インストールディレクトリ
                   
-----------------------------------------------------------------------------------
                   
'stdlib'           ‘`userbase'/lib/python`X.Y'’
                   
                   
'platstdlib'       ‘`userbase'/lib/python`X.Y'’
                   
                   
'platlib'          ‘`userbase'/lib/python`X.Y'/site-packages’
                   
                   
'purelib'          ‘`userbase'/lib/python`X.Y'/site-packages’
                   
                   
'include'          ‘`userbase'/include/python`X.Y'’
                   
                   
'scripts'          ‘`userbase'/bin’
                   
                   
'data'             ‘`userbase'’
                   


File: python.info,  Node: nt_user,  Next: osx_framework_user,  Prev: posix_user,  Up: User scheme

5.29.3.5 ‘nt_user’
..................

Path               インストールディレクトリ
                   
-----------------------------------------------------------------------------------
                   
'stdlib'           ‘`userbase'\Python`XY'’
                   
                   
'platstdlib'       ‘`userbase'\Python`XY'’
                   
                   
'platlib'          ‘`userbase'\Python`XY'\site-packages’
                   
                   
'purelib'          ‘`userbase'\Python`XY'\site-packages’
                   
                   
'include'          ‘`userbase'\Python`XY'\Include’
                   
                   
'scripts'          ‘`userbase'\Python`XY'\Scripts’
                   
                   
'data'             ‘`userbase'’
                   


File: python.info,  Node: osx_framework_user,  Prev: nt_user,  Up: User scheme

5.29.3.6 ‘osx_framework_user’
.............................

Path               インストールディレクトリ
                   
-----------------------------------------------------------------------------------
                   
'stdlib'           ‘`userbase'/lib/python’
                   
                   
'platstdlib'       ‘`userbase'/lib/python’
                   
                   
'platlib'          ‘`userbase'/lib/python/site-packages’
                   
                   
'purelib'          ‘`userbase'/lib/python/site-packages’
                   
                   
'include'          ‘`userbase'/include/python`X.Y'’
                   
                   
'scripts'          ‘`userbase'/bin’
                   
                   
'data'             ‘`userbase'’
                   


File: python.info,  Node: Home scheme,  Next: Prefix scheme,  Prev: User scheme,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.7 Home scheme
....................

"home スキーム" の背後にある考え方は、Python モジュールを個人用のモジュ
ール置き場でビルドし、維持するというものです。このスキームの名前は Unixの
「ホーム」ディレクトリの概念からとりました。というのも、 Unixのユーザに
とって、自分のホームディレクトリを ‘/usr/’ や ‘/usr/local/’ のようにレイ
アウトするのはよくあることだからです。とはいえ、このスキームはどのオペレ
ーティングシステムのユーザでも使えます。

* Menu:

* posix_home::


File: python.info,  Node: posix_home,  Up: Home scheme

5.29.3.8 ‘posix_home’
.....................

Path               インストールディレクトリ
                   
-----------------------------------------------------------------------------------
                   
'stdlib'           ‘`home'/lib/python’
                   
                   
'platstdlib'       ‘`home'/lib/python’
                   
                   
'platlib'          ‘`home'/lib/python’
                   
                   
'purelib'          ‘`home'/lib/python’
                   
                   
'include'          ‘`home'/include/python’
                   
                   
'platinclude'      ‘`home'/include/python’
                   
                   
'scripts'          ‘`home'/bin’
                   
                   
'data'             ‘`home'’
                   


File: python.info,  Node: Prefix scheme,  Next: Installation path functions,  Prev: Home scheme,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.9 Prefix scheme
......................

あるインストール済みの Python を使ってモジュールのビルド/インストールを
(例えば setup スクリプトを実行して) 行いたいけれども、 別のインストール
済みの Python のサードパーティ製モジュール置き場 (あるいは、そう見えるよ
うなディレクトリ構造) に、ビルドされた モジュールをインストールしたい場
合には、"prefix スキーム" が便利です。そんな作業はまったくありえそうにな
い、と思うなら、確かにその通りです -- "home スキーム" を先に説明したのも
そのためです。とはいえ、prefix スキームが有用なケースは少なくとも二つあ
ります。

First, consider that many Linux distributions put Python in ‘/usr’,
rather than the more traditional ‘/usr/local’.  This is entirely
appropriate, since in those cases Python is part of "the system" rather
than a local add-on.  However, if you are installing Python modules from
source, you probably want them to go in ‘/usr/local/lib/python2.`X'’
rather than ‘/usr/lib/python2.`X'’.

Another possibility is a network filesystem where the name used to write
to a remote directory is different from the name used to read it: for
example, the Python interpreter accessed as ‘/usr/local/bin/python’
might search for modules in ‘/usr/local/lib/python2.`X'’, but those
modules would have to be installed to, say,
‘/mnt/`@server'/export/lib/python2.`X'’.

* Menu:

* posix_prefix::
* nt::


File: python.info,  Node: posix_prefix,  Next: nt,  Up: Prefix scheme

5.29.3.10 ‘posix_prefix’
........................

Path               インストールディレクトリ
                   
----------------------------------------------------------------------------------
                   
'stdlib'           ‘`prefix'/lib/python`X.Y'’
                   
                   
'platstdlib'       ‘`prefix'/lib/python`X.Y'’
                   
                   
'platlib'          ‘`prefix'/lib/python`X.Y'/site-packages’
                   
                   
'purelib'          ‘`prefix'/lib/python`X.Y'/site-packages’
                   
                   
'include'          ‘`prefix'/include/python`X.Y'’
                   
                   
'platinclude'      ‘`prefix'/include/python`X.Y'’
                   
                   
'scripts'          ‘`prefix'/bin’
                   
                   
'data'             ‘`prefix'’
                   


File: python.info,  Node: nt,  Prev: posix_prefix,  Up: Prefix scheme

5.29.3.11 ‘nt’
..............

Path               インストールディレクトリ
                   
----------------------------------------------------------------------------------
                   
'stdlib'           ‘`prefix'\Lib’
                   
                   
'platstdlib'       ‘`prefix'\Lib’
                   
                   
'platlib'          ‘`prefix'\Lib\site-packages’
                   
                   
'purelib'          ‘`prefix'\Lib\site-packages’
                   
                   
'include'          ‘`prefix'\Include’
                   
                   
'platinclude'      ‘`prefix'\Include’
                   
                   
'scripts'          ‘`prefix'\Scripts’
                   
                   
'data'             ‘`prefix'’
                   


File: python.info,  Node: Installation path functions,  Next: その他の関数<3>,  Prev: Prefix scheme,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.12 Installation path functions
.....................................

*note sysconfig: c5. provides some functions to determine these
installation paths.

 -- の関数: sysconfig.get_scheme_names ()

     現在 *note sysconfig: c5. でサポートされているすべてのスキームを格
     納したタプルを返します。

 -- の関数: sysconfig.get_default_scheme ()

     Return the default scheme name for the current platform.

     Added in version 3.10: This function was previously named
     ‘_get_default_scheme()’ and considered an implementation detail.

     バージョン 3.11 で変更: When Python runs from a virtual
     environment, the 'venv' scheme is returned.

 -- の関数: sysconfig.get_preferred_scheme (key)

     Return a preferred scheme name for an installation layout specified
     by 'key'.

     'key' must be either ‘"prefix"’, ‘"home"’, or ‘"user"’.

     The return value is a scheme name listed in *note
     get_scheme_names(): 424a.  It can be passed to *note sysconfig: c5.
     functions that take a 'scheme' argument, such as *note get_paths():
     1215.

     Added in version 3.10.

     バージョン 3.11 で変更: When Python runs from a virtual environment
     and ‘key="prefix"’, the 'venv' scheme is returned.

 -- の関数: sysconfig._get_preferred_schemes ()

     Return a dict containing preferred scheme names on the current
     platform.  Python implementers and redistributors may add their
     preferred schemes to the ‘_INSTALL_SCHEMES’ module-level global
     value, and modify this function to return those scheme names, to
     e.g.  provide different schemes for system and language package
     managers to use, so packages installed by either do not mix with
     those by the other.

     End users should not use this function, but *note
     get_default_scheme(): 178e. and *note get_preferred_scheme(): 65c.
     instead.

     Added in version 3.10.

 -- の関数: sysconfig.get_path_names ()

     現在 *note sysconfig: c5. でサポートされているすべてのパス名を格納
     したタプルを返します。

 -- の関数: sysconfig.get_path (name[, scheme[, vars[, expand]]])

     'scheme' で指定されたインストールスキームから、パス 'name' に従って
     インストールパスを返します。

     'name' は *note get_path_names(): 424c. が返すリストに含まれる値で
     なければなりません。

     *note sysconfig: c5. はインストールパスを、パス名、プラットフォーム
     、展開される変数に従って格納します。例えば、'nt' スキームでの
     'stdlib' パスは ‘{base}/Lib’ になります。

     *note get_path(): 12fd. はパスを展開するのに *note
     get_config_vars(): ff6. が返す変数を利用します。すべての変数は各プ
     ラットフォームにおいてデフォルト値を持っていて、この関数を呼び出し
     たときにデフォルト値を取得する場合があります。

     'scheme' が指定された場合、*note get_scheme_names(): 424a. が返すリ
     ストに含まれる値でなければなりません。指定されなかった場合は、現在
     のプラットフォームでのデフォルトスキームが利用されます。

     If 'vars' is provided, it must be a dictionary of variables that
     will update the dictionary returned by *note get_config_vars():
     ff6.

     'expand' が ‘False’ に設定された場合、パスは変数を使って展開されま
     せん。

     'name' が見つからない場合、*note KeyError: 31d. を送出します。

 -- の関数: sysconfig.get_paths ([scheme[, vars[, expand]]])

     インストールスキームに基づいたすべてのインストールパスを格納した辞
     書を返します。詳しい情報は *note get_path(): 12fd. を参照してくださ
     い。

     'scheme' が指定されない場合、現在のプラットフォームでのデフォルトス
     キーマが使用されます。

     'vars' を指定する場合、パスを展開するために使用される辞書を更新する
     値の辞書でなければなりません。

     'expand' に偽を指定すると、パスは展開されません。

     'scheme' が実在するスキームでなかった場合、*note get_paths(): 1215.
     は *note KeyError: 31d. を発生させます。


File: python.info,  Node: その他の関数<3>,  Next: sysconfig をスクリプトとして使う,  Prev: Installation path functions,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.13 その他の関数
......................

 -- の関数: sysconfig.get_python_version ()

     ‘MAJOR.MINOR’ の型の Python バージョン番号文字列を返します。
     ‘'%d.%d' % sys.version_info[:2]’ に似ています。

 -- の関数: sysconfig.get_platform ()

     現在のプラットフォームを識別するための文字列を返します。

     This is used mainly to distinguish platform-specific build
     directories and platform-specific built distributions.  Typically
     includes the OS name and version and the architecture (as supplied
     by *note os.uname(): 10e9.), although the exact information
     included depends on the OS; e.g., on Linux, the kernel version
     isn't particularly important.

     返される値の例:

        - linux-i586

        - linux-alpha (?)

        - solaris-2.6-sun4u

     Windows では以下のどれかを返します:

        - win-amd64 (64bit Windows on AMD64, 別名 x86_64, Intel64,
          EM64T)

        - win32 (その他すべて - 具体的には sys.platform が返す値)

     macOS では以下のどれかを返します:

        - macosx-10.6-ppc

        - macosx-10.4-ppc64

        - macosx-10.3-i386

        - macosx-10.4-fat

     その他の非 POSIX プラットフォームでは、現在のところ単に *note
     sys.platform: a5b. を返します。

 -- の関数: sysconfig.is_python_build ()

     実行中の Python インタプリタがソースからビルドされ、かつそのビルド
     された場所から実行されている場合に ‘True’ を返します。 ‘make
     install’ を実行した場所からの実行やバイナリインストーラによるインス
     トールではいけません。

 -- の関数: sysconfig.parse_config_h (fp[, vars])

     ‘config.h’ スタイルのファイルを解析します。

     'fp' は ‘config.h’ スタイルのファイルを指すファイルライクオブジェク
     トです。

     name/value ペアを格納した辞書を返します。第二引数にオプションの辞書
     が渡された場合、新しい辞書ではなくその辞書を利用し、ファイルから読
     み込んだ値で更新します。

 -- の関数: sysconfig.get_config_h_filename ()

     ‘pyconfig.h’ のパスを返します。

 -- の関数: sysconfig.get_makefile_filename ()

     ‘Makefile’ のパスを返します。


File: python.info,  Node: sysconfig をスクリプトとして使う,  Prev: その他の関数<3>,  Up: sysconfig --- Python の構成情報へのアクセスを提供する

5.29.3.14 ‘sysconfig’ をスクリプトとして使う
............................................

Python の '-m' オプションを使えば、*note sysconfig: c5. をスクリプトとし
て使用できます:

     $ python -m sysconfig
     Platform: "macosx-10.4-i386"
     Python version: "3.2"
     Current installation scheme: "posix_prefix"

     Paths:
             data = "/usr/local"
             include = "/Users/tarek/Dev/svn.python.org/py3k/Include"
             platinclude = "."
             platlib = "/usr/local/lib/python3.2/site-packages"
             platstdlib = "/usr/local/lib/python3.2"
             purelib = "/usr/local/lib/python3.2/site-packages"
             scripts = "/usr/local/bin"
             stdlib = "/usr/local/lib/python3.2"

     Variables:
             AC_APPLE_UNIVERSAL_BUILD = "0"
             AIX_GENUINE_CPLUSPLUS = "0"
             AR = "ar"
             ARFLAGS = "rc"
             ...

これは、*note get_platform(): 1213.、*note get_python_version(): 1214.、
*note get_path(): 12fd. および *note get_config_vars(): ff6. が返す情報
を標準出力に出力します。


File: python.info,  Node: builtins --- 組み込みオブジェクト,  Next: __main__ --- トップレベルのコード環境,  Prev: sysconfig --- Python の構成情報へのアクセスを提供する,  Up: Python ランタイムサービス

5.29.4 ‘builtins’ -- 組み込みオブジェクト
-----------------------------------------

__________________________________________________________________

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 *note open(): 4e5.

通常このモジュールはほとんどのアプリケーションで明示的にアクセスされるこ
とはありませんが、組み込みの値と同じ名前のオブジェクトを提供するモジュー
ルが同時にその名前の組み込みオブジェクトも必要とするような場合には有用で
す。たとえば、組み込みの *note open(): 4e5. をラップした *note open():
4e5. という関数を実装したいモジュールがあったとすると、このモジュールは
次のように直接的に使われます:

     import builtins

     def open(path):
         f = builtins.open(path, 'r')
         return UpperCaser(f)

     class UpperCaser:
         '''Wrapper around a file that converts output to uppercase.'''

         def __init__(self, f):
             self._f = f

         def read(self, count=-1):
             return self._f.read(count).upper()

         # ...

ほとんどのモジュールではグローバル変数の一部として ‘__builtins__’ が利用
できるようになっています。 ‘__builtins__’ の内容は通常このモジュールその
ものか、あるいはこのモジュールの *note __dict__: 526. 属性です。これは実
装の詳細部分なので、異なる Python の実装では ‘__builtins__’ は使われてい
ないこともあります。

参考
....

   * *note 組み込み定数: 20e9.

   * *note 組み込み例外: 17ee.

   * *note 組み込み関数: 122e.

   * *note 組み込み型: 20f3.


File: python.info,  Node: __main__ --- トップレベルのコード環境,  Next: warnings --- 警告の制御,  Prev: builtins --- 組み込みオブジェクト,  Up: Python ランタイムサービス

5.29.5 ‘__main__’ -- トップレベルのコード環境
---------------------------------------------

__________________________________________________________________

Python では、 ‘__main__’ という特別な名前が次の二つの重要な用途で使われ
ます:

  1. プログラムのトップレベル環境の名前。 ‘__name__ == '__main__'’ とい
     う式でチェックすることができる。

  2. Python パッケージにおける ‘__main__.py’ ファイル。

どちらも Python のモジュールに関わる機能です。 １つ目はユーザーがどうモ
ジュールを使うか、２つ目はモジュールとモジュールがどうやりとりするかに関
係します。 詳細は以下で説明します。 Python モジュールがどういうものかに
ついては、 *note モジュール: 1bc0. を参照してください。

* Menu:

* __name__ == '__main__'::
* __main__.py in Python Packages: __main__ py in Python Packages.
* import __main__::


File: python.info,  Node: __name__ == '__main__',  Next: __main__ py in Python Packages,  Up: __main__ --- トップレベルのコード環境

5.29.5.1 ‘__name__ == '__main__'’
.................................

Python モジュールやパッケージがインポートされるとき、 ‘__name__’ の値は
そのモジュールの名前となります。 通常、インポートされる Python ファイル
自体のファイル名から拡張子''.py'' を除いたものとなります:

     >>> import configparser
     >>> configparser.__name__
     'configparser'

インポートされるファイルがパッケージの一部である場合は、 ‘__name__’ には
そのパッケージのパスも含まれます:

     >>> from concurrent.futures import process
     >>> process.__name__
     'concurrent.futures.process'

しかし、モジュールがトップレベルのスクリプト環境で実行される場合は、
‘__name__’ が ‘'__main__'’ という文字列になります。

* Menu:

* 「トップレベルのスクリプト環境」とは::
* 通常の使われ方::
* パッケージングで考慮すべき点::


File: python.info,  Node: 「トップレベルのスクリプト環境」とは,  Next: 通常の使われ方,  Up: __name__ == '__main__'

5.29.5.2 「トップレベルのスクリプト環境」とは
.............................................

‘__main__’ は、トップレベルのコードが実行される環境の名前です。 "トップ
レベルのコード" は、実行を開始する最初のユーザー指定の Python モジュール
です。これは、このモジュールがプログラムに必要なすべての他のモジュールを
インポートするために、 "トップレベル" なのです。時折、 "トップレベルのコ
ード" は、アプリケーションには 'エントリーポイント' と呼ばれます。

以下のものがトップレベルのスクリプト環境となります:

   * インタラクティブプロンプトのスコープ:

          >>> __name__
          '__main__'

   * Python インタープリタにファイル引数として渡される Python モジュール
     :

          $ python helloworld.py
          Hello, world!

   * Python インタープリタにPython *note -m: 5ab. オプションとして渡され
     る Python モジュールまたはパッケージ:

          $ python -m tarfile
          usage: tarfile.py [-h] [-v] (...)

   * 標準入力から Python インタープリタが読み込む Python コード:

          $ echo "import this" | python
          The Zen of Python, by Tim Peters

          Beautiful is better than ugly.
          Explicit is better than implicit.
          ...

   * Python インタープリタに *note -c: 5aa. オプションで渡される Python
     コード:

          $ python -c "import this"
          The Zen of Python, by Tim Peters

          Beautiful is better than ugly.
          Explicit is better than implicit.
          ...

上記それぞれの場合で、トップレベルのモジュールの ‘__name__’ の値が
‘'__main__'’ となります。

これにより、 ‘__name__’ をチェックすれば各モジュールは自分がトップレベル
環境で実行されているかどうかを知ることができます。 このことから、モジュ
ールが import 文で初期化された場合以外の場合でのみコードを実行するため、
次のコードがしばしば用いられます:

     if __name__ == '__main__':
         # Execute when the module is not initialized from an import statement.
         ...

参考
....

あらゆる場合に ‘__name__’ の値がどうセットされるのかについて、詳しくはチ
ュートリアルの *note モジュール: 1bc0. セクションを参照してください。


File: python.info,  Node: 通常の使われ方,  Next: パッケージングで考慮すべき点,  Prev: 「トップレベルのスクリプト環境」とは,  Up: __name__ == '__main__'

5.29.5.3 通常の使われ方
.......................

一部のモジュールでは、コマンドライン引数をパースしたり標準入力からデータ
を取得したなど、スクリプト用途のみのコードが含まれています。 このような
モジュールが、例えばユニットテストのため、別のモジュールからインポートさ
れると、そのスクリプト用コードが意図に反して実行されてしまいます。

‘if __name__ == '__main__'’ というコードは、このようなときに役立ちます。
このブロックの中にあるコードは、当該のモジュールがトップレベル環境で実行
されていない限り、実行されません。

‘if __name__ == '__main__'’ の下のブロックにあるコードはできるだけ少なく
した方が、コードの分かりやすさや正確さにつながります。 最もよくあるのが
、プログラムの主要な処理を ‘main’ 関数の中にカプセル化することです:

     # echo.py

     import shlex
     import sys

     def echo(phrase: str) -> None:
        """A dummy wrapper around print."""
        # for demonstration purposes, you can imagine that there is some
        # valuable and reusable logic inside this function
        print(phrase)

     def main() -> int:
         """Echo the input arguments to standard output"""
         phrase = shlex.join(sys.argv)
         echo(phrase)
         return 0

     if __name__ == '__main__':
         sys.exit(main())  # next section explains the use of sys.exit

注意すべき点として、もし ‘main’ 関数内のコードをカプセル化せず ‘if
__name__ == '__main__'’ の下に直接書いた場合、 ‘phrase’ 変数はモジュール
全体からグローバルにアクセスできてしまいます。 モジュール内の他の関数が
意図せずローカル変数ではなくそのグローバル変数を使用してしまう可能性があ
るため、ミスにつながります。 ‘main’ 関数を用意することでこの問題は解決で
きます。

‘main’ 関数を使うことのもう一つのメリットとして、 ‘echo’ 関数が分離し、
別の場所からインポートできるようになることです。 ‘echo.py’ がインポート
されるとき、 ‘echo’ 関数と ‘main’ 関数が定義されますが、 ‘__name__ !=
'__main__'’ であるため、どちらの関数も呼び出されません。


File: python.info,  Node: パッケージングで考慮すべき点,  Prev: 通常の使われ方,  Up: __name__ == '__main__'

5.29.5.4 パッケージングで考慮すべき点
.....................................

‘main’ functions are often used to create command-line tools by
specifying them as entry points for console scripts.  When this is done,
pip(1) inserts the function call into a template script, where the
return value of ‘main’ is passed into *note sys.exit(): 1318.  For
example:

     sys.exit(main())

Since the call to ‘main’ is wrapped in *note sys.exit(): 1318, the
expectation is that your function will return some value acceptable as
an input to *note sys.exit(): 1318.; typically, an integer or ‘None’
(which is implicitly returned if your function does not have a return
statement).

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.

In particular, be careful about returning strings from your ‘main’
function.  *note sys.exit(): 1318. will interpret a string argument as a
failure message, so your program will have an exit code of ‘1’,
indicating failure, and the string will be written to *note sys.stderr:
907.  The ‘echo.py’ example from earlier exemplifies using the
‘sys.exit(main())’ convention.

参考
....

Python Packaging User Guide(2) contains a collection of tutorials and
references on how to distribute and install Python packages with modern
tools.

   ---------- Footnotes ----------

   (1) https://pip.pypa.io/

   (2) https://packaging.python.org/


File: python.info,  Node: __main__ py in Python Packages,  Next: import __main__,  Prev: __name__ == '__main__',  Up: __main__ --- トップレベルのコード環境

5.29.5.5 ‘__main__.py’ in Python Packages
.........................................

If you are not familiar with Python packages, see section *note
パッケージ: 1bd1. 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":

     bandclass
       ├── __init__.py
       ├── __main__.py
       └── student.py

‘__main__.py’ will be executed when the package itself is invoked
directly from the command line using the *note -m: 5ab. flag.  For
example:

     $ python -m bandclass

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:

     # bandclass/__main__.py

     import sys
     from .student import search_students

     student_name = sys.argv[1] if len(sys.argv) >= 2 else ''
     print(f'Found student: {search_students(student_name)}')

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 *note パッケージ内参照: 1bd6.
in the *note モジュール: 1bc0. section of the tutorial.

* Menu:

* 通常の使われ方: 通常の使われ方<2>.


File: python.info,  Node: 通常の使われ方<2>,  Up: __main__ py in Python Packages

5.29.5.6 通常の使われ方
.......................

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.

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:

     >>> import asyncio.__main__
     >>> asyncio.__main__.__name__
     'asyncio.__main__'

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.

参考
....

See *note venv: f9. 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]’.

See *note runpy: ac. for more details on the *note -m: 5ab. flag to the
interpreter executable.

See *note zipapp: 116. 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.


File: python.info,  Node: import __main__,  Prev: __main__ py in Python Packages,  Up: __main__ --- トップレベルのコード環境

5.29.5.7 ‘import __main__’
..........................

Regardless of which module a Python program was started with, other
modules running within that same program can import the top-level
environment's scope (*note namespace: 1bc1.) by importing the ‘__main__’
module.  This doesn't import a ‘__main__.py’ file but rather whichever
module that received the special name ‘'__main__'’.

Here is an example module that consumes the ‘__main__’ namespace:

     # namely.py

     import __main__

     def did_user_define_their_name():
         return 'my_name' in dir(__main__)

     def print_user_name():
         if not did_user_define_their_name():
             raise ValueError('Define the variable `my_name`!')

         if '__file__' in dir(__main__):
             print(__main__.my_name, "found in file", __main__.__file__)
         else:
             print(__main__.my_name)

Example usage of this module could be as follows:

     # start.py

     import sys

     from namely import print_user_name

     # my_name = "Dinsdale"

     def main():
         try:
             print_user_name()
         except ValueError as ve:
             return str(ve)

     if __name__ == "__main__":
         sys.exit(main())

Now, if we started our program, the result would look like this:

     $ python start.py
     Define the variable `my_name`!

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:

     $ python start.py
     Dinsdale found in file /path/to/start.py

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?

Python inserts an empty ‘__main__’ module in *note sys.modules: 18d6. at
interpreter startup, and populates it by running top-level code.  In our
example this is the ‘start’ module which runs line by line and imports
‘namely’.  In turn, ‘namely’ imports ‘__main__’ (which is really
‘start’).  That's an import cycle!  Fortunately, since the partially
populated ‘__main__’ module is present in *note sys.modules: 18d6,
Python passes that to ‘namely’.  See *note Special considerations for
__main__: 1f6b. in the import system's reference for details on how this
works.

The Python REPL is another example of a "top-level environment", so
anything defined in the REPL becomes part of the ‘__main__’ scope:

     >>> import namely
     >>> namely.did_user_define_their_name()
     False
     >>> namely.print_user_name()
     Traceback (most recent call last):
     ...
     ValueError: Define the variable `my_name`!
     >>> my_name = 'Jabberwocky'
     >>> namely.did_user_define_their_name()
     True
     >>> namely.print_user_name()
     Jabberwocky

Note that in this case the ‘__main__’ scope doesn't contain a ‘__file__’
attribute as it's interactive.

The ‘__main__’ scope is used in the implementation of *note pdb: 94. and
*note rlcompleter: ab.


File: python.info,  Node: warnings --- 警告の制御,  Next: dataclasses --- データクラス,  Prev: __main__ --- トップレベルのコード環境,  Up: Python ランタイムサービス

5.29.6 ‘warnings’ -- 警告の制御
-------------------------------

'ソースコード:' Lib/warnings.py(1)

__________________________________________________________________

警告メッセージは一般に、ユーザに警告しておいた方がよいような状況下にプロ
グラムが置かれているが、その状況は (通常は) 例外を送出したりそのプログラ
ムを終了させるほどの正当な理由がないといった状況で発されます。例えば、プ
ログラムが古いモジュールを使っている場合には警告を発したくなるかもしれま
せん。

Python プログラマは、このモジュールの *note warn(): 14c3. 関数を使って警
告を発することができます。(C 言語のプログラマは *note PyErr_WarnEx():
13f2. を使います; 詳細は *note 例外処理: 4261. を参照してください)。

警告メッセージは通常 *note sys.stderr: 907. に出力されますが、すべての警
告を無視したり、警告を例外にしたりと、その処理を柔軟に変更することができ
ます。 警告の処理は *note warning category: 220e. 、警告メッセージのテキ
スト、警告が発行されたソースの位置に基づいて変化します。 同じソースの位
置で特定の警告が繰り返された場合、通常は抑制されます。

警告制御には 2 つの段階 (stage) があります: 第一に、警告が発されるたびに
、メッセージを出力すべきかどうかの決定が行われます; 次に、メッセージを出
力するなら、メッセージはユーザによって設定が可能なフックを使って書式化さ
れ印字されます。

警告メッセージを出力するかどうかの決定は、 *note 警告フィルタ: 897. によ
って制御されます。警告フィルタは一致規則 (matching rule)と動作からなるシ
ーケンスです。 *note filterwarnings(): 144e. を呼び出して一致規則をフィ
ルタに追加することができ、 *note resetwarnings(): 4262. を呼び出してフィ
ルタを標準設定の状態にリセットすることができます。

警告メッセージの印字は *note showwarning(): 4263. を呼び出して行うことが
でき、この関数は上書きすることができます; この関数の標準の実装では、
*note formatwarning(): 1980. を呼び出して警告メッセージを書式化しますが
、この関数についても自作の実装を使うことができます。

参考
....

*note logging.captureWarnings(): 2c76. を使うことで、標準ロギング基盤で
すべての警告を扱うことができます。

* Menu:

* 警告カテゴリ::
* 警告フィルタ::
* 一時的に警告を抑制する::
* 警告のテスト::
* Updating Code For New Versions of Dependencies::
* 利用可能な関数::
* 利用可能なコンテキストマネージャー::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/warnings.py


File: python.info,  Node: 警告カテゴリ,  Next: 警告フィルタ,  Up: warnings --- 警告の制御

5.29.6.1 警告カテゴリ
.....................

警告カテゴリを表現する組み込み例外は数多くあります。このカテゴリ化は警告
をグループごとフィルタする上で便利です。

これらは厳密に言えば *note 組み込み例外: 220c. ですが、概念的には警告メ
カニズムに属しているのでここで記述されています。

標準の警告カテゴリをユーザの作成したコード上でサブクラス化することで、さ
らに別の警告カテゴリを定義することができます。警告カテゴリは常に *note
Warning: 220f. クラスのサブクラスでなければなりません。

現在以下の警告カテゴリクラスが定義されています:

クラス                                 説明
                                       
-------------------------------------------------------------------------------------------
                                       
*note Warning: 220f.                   すべての警告カテゴリクラスの基底クラスです。
                                       *note Exception: 9a7. のサブクラスです。
                                       
                                       
*note UserWarning: 2210.               *note warn(): 14c3. の標準のカテゴリです。
                                       
                                       
*note DeprecationWarning: 18a.         他の Python 開発者へ向けて警告を発するときの、非
                                       推奨の機能についての警告の基底カテゴリです
                                       (‘__main__’ によって引き起こされない限り通常は無
                                       視されます)。
                                       
                                       
*note SyntaxWarning: 432.              その文法機能があいまいであることを示す警告カテゴ
                                       リの基底クラスです。
                                       
                                       
*note RuntimeWarning: 1a2.             そのランタイム機能があいまいであることを示す警告
                                       カテゴリの基底クラスです。
                                       
                                       
*note FutureWarning: 3ee.              Python で書かれたアプリケーションのエンドユーザー
                                       へ向けて警告を発するときの、非推奨の機能について
                                       の警告の基底カテゴリです。
                                       
                                       
*note PendingDeprecationWarning: 895.  将来その機能が非推奨になることを示す警告カテゴリ
                                       の基底クラスです(デフォルトでは無視されます)。
                                       
                                       
*note ImportWarning: 4c7.              モジュールのインポート処理中に引き起こされる警告
                                       カテゴリの基底クラスです (デフォルトでは無視され
                                       ます)。
                                       
                                       
*note UnicodeWarning: 13cb.            Unicode に関係した警告カテゴリの基底クラスです。
                                       
                                       
*note BytesWarning: bf1.               *note bytes: 1a4. や *note bytearray: 508. に関連
                                       した警告カテゴリの基底クラスです。
                                       
                                       
*note ResourceWarning: 225.            リソースの使用に関連した警告カテゴリの基底クラス
                                       です (デフォルトでは無視されます)。
                                       

バージョン 3.7 で変更: Previously *note DeprecationWarning: 18a. and
*note FutureWarning: 3ee. were distinguished based on whether a feature
was being removed entirely or changing its behaviour.  They are now
distinguished based on their intended audience and the way they're
handled by the default warnings filters.


File: python.info,  Node: 警告フィルタ,  Next: 一時的に警告を抑制する,  Prev: 警告カテゴリ,  Up: warnings --- 警告の制御

5.29.6.2 警告フィルタ
.....................

警告フィルタは、ある警告を無視すべきか、表示すべきか、あるいは (例外を送
出する) エラーにするべきかを制御します。

概念的には、警告フィルタは複数のフィルタ仕様からなる順番リストを維持して
います; 何らかの特定の警告が生じると、一致するものが見つかるまでリスト中
の各フィルタとの照合が行われます; 一致したフィルタ仕様がその警告の処理方
法を決定します。フィルタの各エントリは ('action', 'message', 'category',
'module', 'lineno') からなるタプルです。ここで:

   * 'action' は以下の文字列のうちの一つです:

     値                  処理方法
                         
     -----------------------------------------------------------------------
                         
     ‘"default"’         print the first occurrence of matching warnings
                         for each location (module + line number) where
                         the warning is issued
                         
                         
     ‘"error"’           一致した警告を例外に変えます
                         
                         
     ‘"ignore"’          一致した警告を出力しません
                         
                         
     ‘"always"’          一致した警告を常に出力します
                         
                         
     ‘"module"’          print the first occurrence of matching warnings
                         for each module where the warning is issued
                         (regardless of line number)
                         
                         
     ‘"once"’            一致した警告のうち、警告の原因になった場所にかか
                         わらず最初の警告のみ出力します
                         

   * 'message' is a string containing a regular expression that the
     start of the warning message must match, case-insensitively.  In
     *note -W: 896. and *note PYTHONWARNINGS: b78, 'message' is a
     literal string that the start of the warning message must contain
     (case-insensitively), ignoring any whitespace at the start or end
     of 'message'.

   * 'category' はクラス (*note Warning: 220f. のサブクラス) です。警告
     クラスはこのクラスのサブクラスに一致しなければなりません。

   * 'module' is a string containing a regular expression that the start
     of the fully qualified module name must match, case-sensitively.
     In *note -W: 896. and *note PYTHONWARNINGS: b78, 'module' is a
     literal string that the fully qualified module name must be equal
     to (case-sensitively), ignoring any whitespace at the start or end
     of 'module'.

   * 'lineno' は整数で、警告が発生した場所の行番号に一致しなければなりま
     せん。‘0’ の場合はすべての行と一致します。

*note Warning: 220f. クラスは組み込みの *note Exception: 9a7. クラスから
派生しているので、警告をエラーに変換するには単に ‘category(message)’ を
‘raise’ します。

If a warning is reported and doesn't match any registered filter then
the "default" action is applied (hence its name).

* Menu:

* Repeated Warning Suppression Criteria::
* Describing Warning Filters::
* デフォルトの警告フィルタ::
* Overriding the default filter::


File: python.info,  Node: Repeated Warning Suppression Criteria,  Next: Describing Warning Filters,  Up: 警告フィルタ

5.29.6.3 Repeated Warning Suppression Criteria
..............................................

The filters that suppress repeated warnings apply the following criteria
to determine if a warning is considered a repeat:

   - ‘"default"’: A warning is considered a repeat only if the
     ('message', 'category', 'module', 'lineno') are all the same.

   - ‘"module"’: A warning is considered a repeat if the ('message',
     'category', 'module') are the same, ignoring the line number.

   - ‘"once"’: A warning is considered a repeat if the ('message',
     'category') are the same, ignoring the module and line number.


File: python.info,  Node: Describing Warning Filters,  Next: デフォルトの警告フィルタ,  Prev: Repeated Warning Suppression Criteria,  Up: 警告フィルタ

5.29.6.4 Describing Warning Filters
...................................

The warnings filter is initialized by *note -W: 896. options passed to
the Python interpreter command line and the *note PYTHONWARNINGS: b78.
environment variable.  The interpreter saves the arguments for all
supplied entries without interpretation in *note sys.warnoptions: 38a.;
the *note warnings: fa. module parses these when it is first imported
(invalid options are ignored, after printing a message to *note
sys.stderr: 907.).

Individual warnings filters are specified as a sequence of fields
separated by colons:

     action:message:category:module:line

The meaning of each of these fields is as described in *note
警告フィルタ: 897.  When listing multiple filters on a single line (as
for *note PYTHONWARNINGS: b78.), the individual filters are separated by
commas and the filters listed later take precedence over those listed
before them (as they're applied left-to-right, and the most recently
applied filters take precedence over earlier ones).

Commonly used warning filters apply to either all warnings, warnings in
a particular category, or warnings raised by particular modules or
packages.  Some examples:

     default                      # Show all warnings (even those ignored by default)
     ignore                       # Ignore all warnings
     error                        # Convert all warnings to errors
     error::ResourceWarning       # Treat ResourceWarning messages as errors
     default::DeprecationWarning  # Show DeprecationWarning messages
     ignore,default:::mymodule    # Only report warnings triggered by "mymodule"
     error:::mymodule             # Convert warnings to errors in "mymodule"


File: python.info,  Node: デフォルトの警告フィルタ,  Next: Overriding the default filter,  Prev: Describing Warning Filters,  Up: 警告フィルタ

5.29.6.5 デフォルトの警告フィルタ
.................................

デフォルトで、 Python はいくつかの警告フィルタをインストールします。これ
は *note -W: 896. コマンドラインオプション、 *note PYTHONWARNINGS: b78.
環境変数または *note filterwarnings(): 144e. の呼び出しでオーバーライド
できます。

In regular release builds, the default warning filter has the following
entries (in order of precedence):

     default::DeprecationWarning:__main__
     ignore::DeprecationWarning
     ignore::PendingDeprecationWarning
     ignore::ImportWarning
     ignore::ResourceWarning

In a *note debug build: 1da, the list of default warning filters is
empty.

バージョン 3.2 で変更: *note PendingDeprecationWarning: 895. に加えて、
*note DeprecationWarning: 18a. もデフォルトで無視されるようになりました
。

バージョン 3.7 で変更: *note DeprecationWarning: 18a. is once again
shown by default when triggered directly by code in ‘__main__’.

バージョン 3.7 で変更: *note BytesWarning: bf1. no longer appears in the
default filter list and is instead configured via *note sys.warnoptions:
38a. when *note -b: 5ad. is specified twice.


File: python.info,  Node: Overriding the default filter,  Prev: デフォルトの警告フィルタ,  Up: 警告フィルタ

5.29.6.6 Overriding the default filter
......................................

Developers of applications written in Python may wish to hide 'all'
Python level warnings from their users by default, and only display them
when running tests or otherwise working on the application.  The *note
sys.warnoptions: 38a. attribute used to pass filter configurations to
the interpreter can be used as a marker to indicate whether or not
warnings should be disabled:

     import sys

     if not sys.warnoptions:
         import warnings
         warnings.simplefilter("ignore")

Developers of test runners for Python code are advised to instead ensure
that 'all' warnings are displayed by default for the code under test,
using code like:

     import sys

     if not sys.warnoptions:
         import os, warnings
         warnings.simplefilter("default") # Change the filter in this process
         os.environ["PYTHONWARNINGS"] = "default" # Also affect subprocesses

Finally, developers of interactive shells that run user code in a
namespace other than ‘__main__’ are advised to ensure that *note
DeprecationWarning: 18a. messages are made visible by default, using
code like the following (where ‘user_ns’ is the module used to execute
code entered interactively):

     import warnings
     warnings.filterwarnings("default", category=DeprecationWarning,
                                        module=user_ns.get("__name__"))


File: python.info,  Node: 一時的に警告を抑制する,  Next: 警告のテスト,  Prev: 警告フィルタ,  Up: warnings --- 警告の制御

5.29.6.7 一時的に警告を抑制する
...............................

If you are using code that you know will raise a warning, such as a
deprecated function, but do not want to see the warning (even when
warnings have been explicitly configured via the command line), then it
is possible to suppress the warning using the *note catch_warnings: 550.
context manager:

     import warnings

     def fxn():
         warnings.warn("deprecated", DeprecationWarning)

     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         fxn()

このサンプルのコンテキストマネージャーの中では、すべての警告が無視されて
います。これで、他の廃止予定のコードを含まない(つもりの)部分まで警告を抑
止せずに、廃止予定だと分かっているコードだけ警告を表示させないようにする
ことができます。注意: これが保証できるのはシングルスレッドのアプリケーシ
ョンだけです。 2つ以上のスレッドが同時に *note catch_warnings: 550. コン
テキストマネージャーを使用した場合、動作は未定義です。


File: python.info,  Node: 警告のテスト,  Next: Updating Code For New Versions of Dependencies,  Prev: 一時的に警告を抑制する,  Up: warnings --- 警告の制御

5.29.6.8 警告のテスト
.....................

コードが警告を発生させることをテストするには、 *note catch_warnings:
550. コンテキストマネージャーを利用します。このクラスを使うと、一時的に
警告フィルタを操作してテストに利用できます。例えば、次のコードでは、発生
したすべての警告を取得してチェックしています:

     import warnings

     def fxn():
         warnings.warn("deprecated", DeprecationWarning)

     with warnings.catch_warnings(record=True) as w:
         # Cause all warnings to always be triggered.
         warnings.simplefilter("always")
         # Trigger a warning.
         fxn()
         # Verify some things
         assert len(w) == 1
         assert issubclass(w[-1].category, DeprecationWarning)
         assert "deprecated" in str(w[-1].message)

‘always’ の代わりに ‘error’ を利用することで、すべての警告で例外を発生さ
せることができます。1つ気をつけないといけないのは、一度 ‘once’/‘default’
ルールによって発生した警告は、フィルタに何をセットしているかにかかわらず
、警告レジストリをクリアしない限りは 2度と発生しません。

コンテキストマネージャーが終了したら、警告フィルタはコンテキストマネージ
ャーに入る前のものに戻されます。これは、テスト中に予期しない方法で警告フ
ィルタが変更され、テスト結果が中途半端になる事を予防します。このモジュー
ルの *note showwarning(): 4263. 関数も元の値に戻されます。注意: これが保
証できるのはシングルスレッドのアプリケーションだけです。 2つ以上のスレッ
ドが同時に *note catch_warnings: 550. コンテキストマネージャを使用した場
合、動作は未定義です。

同じ種類の警告を発生させる複数の操作をテストする場合、各操作が新しい警告
を発生させている事を確認するのは大切な事です (例えば、警告を例外として発
生させて各操作が例外を発生させることを確認したり、警告リストの長さが各操
作で増加していることを確認したり、警告リストを各操作の前に毎回クリアする
事ができます)。


File: python.info,  Node: Updating Code For New Versions of Dependencies,  Next: 利用可能な関数,  Prev: 警告のテスト,  Up: warnings --- 警告の制御

5.29.6.9 Updating Code For New Versions of Dependencies
.......................................................

Warning categories that are primarily of interest to Python developers
(rather than end users of applications written in Python) are ignored by
default.

Notably, this "ignored by default" list includes *note
DeprecationWarning: 18a. (for every module except ‘__main__’), which
means developers should make sure to test their code with typically
ignored warnings made visible in order to receive timely notifications
of future breaking API changes (whether in the standard library or third
party packages).

In the ideal case, the code will have a suitable test suite, and the
test runner will take care of implicitly enabling all warnings when
running tests (the test runner provided by the *note unittest: ef.
module does this).

In less ideal cases, applications can be checked for use of deprecated
interfaces by passing *note -Wd: 896. to the Python interpreter (this is
shorthand for ‘-W default’) or setting ‘PYTHONWARNINGS=default’ in the
environment.  This enables default handling for all warnings, including
those that are ignored by default.  To change what action is taken for
encountered warnings you can change what argument is passed to *note -W:
896. (e.g.  ‘-W error’).  See the *note -W: 896. flag for more details
on what is possible.


File: python.info,  Node: 利用可能な関数,  Next: 利用可能なコンテキストマネージャー,  Prev: Updating Code For New Versions of Dependencies,  Up: warnings --- 警告の制御

5.29.6.10 利用可能な関数
........................

 -- の関数: warnings.warn (message, category=None, stacklevel=1,
          source=None, *, skip_file_prefixes=())

     警告を発するか、無視するか、あるいは例外を送出します。 'category' 引
     数が与えられた場合、 *note 警告カテゴリクラス: 220e. でなければなり
     ません; 標準の値は *note UserWarning: 2210. です。 'message' を
     *note Warning: 220f. インスタンスで代用することもできますが、この場
     合 'category' は無視され、 ‘message.__class__’ が使われ、メッセージ
     文は ‘str(message)’ になります。発された例外が前述した *note
     警告フィルタ: 897. によってエラーに変更された場合、この関数は例外を
     送出します。引数 'stacklevel' は Python でラッパー関数を書く際に利
     用することができます。例えば:

          def deprecated_api(message):
              warnings.warn(message, DeprecationWarning, stacklevel=2)

     This makes the warning refer to ‘deprecated_api’'s caller, rather
     than to the source of ‘deprecated_api’ itself (since the latter
     would defeat the purpose of the warning message).

     The 'skip_file_prefixes' keyword argument can be used to indicate
     which stack frames are ignored when counting stack levels.  This
     can be useful when you want the warning to always appear at call
     sites outside of a package when a constant 'stacklevel' does not
     fit all call paths or is otherwise challenging to maintain.  If
     supplied, it must be a tuple of strings.  When prefixes are
     supplied, stacklevel is implicitly overridden to be ‘max(2,
     stacklevel)’.  To cause a warning to be attributed to the caller
     from outside of the current package you might write:

          # example/lower.py
          _warn_skips = (os.path.dirname(__file__),)

          def one_way(r_luxury_yacht=None, t_wobbler_mangrove=None):
              if r_luxury_yacht:
                  warnings.warn("Please migrate to t_wobbler_mangrove=.",
                                skip_file_prefixes=_warn_skips)

          # example/higher.py
          from . import lower

          def another_way(**kw):
              lower.one_way(**kw)

     This makes the warning refer to both the ‘example.lower.one_way()’
     and ‘package.higher.another_way()’ call sites only from calling
     code living outside of ‘example’ package.

     'source' 引数が与えられた場合、これは *note ResourceWarning: 225. を
     発生させた破壊されたオブジェクトです。

     バージョン 3.6 で変更: 'source' 引数を追加しました。

     バージョン 3.12 で変更: Added 'skip_file_prefixes'.

 -- の関数: warnings.warn_explicit (message, category, filename, lineno,
          module=None, registry=None, module_globals=None, source=None)

     *note warn(): 14c3. の機能に対する低レベルのインターフェースで、メ
     ッセージ、警告カテゴリ、ファイル名および行番号、そしてオプションの
     モジュール名およびレジストリ情報 (モジュールの
     ‘__warningregistry__’ 辞書) を明示的に渡します。モジュール名は標準
     で ‘.py’ が取り去られたファイル名になります; レジストリが渡されなか
     った場合、警告が抑制されることはありません。 'message' が文字列のと
     き、 'category' は *note Warning: 220f. のサブクラスでなければなり
     ません。また 'message' は *note Warning: 220f. のインスタンスであっ
     てもよく、この場合 'category' は無視されます。

     'module_globals' は、もし与えられるならば、警告が発せられるコードが
     使っているグローバル名前空間でなければなりません (この引数は
     zipfile やその他の非ファイルシステムのインポート元の中にあるモジュ
     ールのソースを表示することをサポートするためのものです)。

     'source' 引数が与えられた場合、これは *note ResourceWarning: 225. を
     発生させた破壊されたオブジェクトです。

     バージョン 3.6 で変更: 'source' 引数を追加しました。

 -- の関数: warnings.showwarning (message, category, filename, lineno,
          file=None, line=None)

     警告をファイルに書き込みます。標準の実装では、
     ‘formatwarning(message, category, filename, lineno, line)’ を呼び出
     し、返された文字列を 'file' に書き込みます。 'file' は標準では
     *note sys.stderr: 907. です。この関数は ‘warnings.showwarning’ に任
     意の呼び出し可能オブジェクトを代入して置き換えることができます。
     'line' は警告メッセージに含めるソースコードの1行です。 'line' が与
     えられない場合、 *note showwarning(): 4263. は 'filename' と
     'lineno' から行を取得することを試みます。

 -- の関数: warnings.formatwarning (message, category, filename, lineno,
          line=None)

     警告を通常の方法で書式化します。返される文字列内には改行が埋め込ま
     れている可能性があり、かつ文字列は改行で終端されています。 'line' は
     警告メッセージに含まれるソースコードの1行です。 'line' が渡されない
     場合、 *note formatwarning(): 1980. は 'filename' と 'lineno' から
     行の取得を試みます。

 -- の関数: warnings.filterwarnings (action, message='',
          category=Warning, module='', lineno=0, append=False)

     *note 警告フィルタ仕様: 897. のリストにエントリを一つ挿入します。標
     準ではエントリは先頭に挿入されます; 'append' が真ならば、末尾に挿入
     されます。この関数は引数の型をチェックし、 'message' および
     'module' の正規表現をコンパイルしてから、これらをタプルにして警告フ
     ィルタのリストに挿入します。二つのエントリが特定の警告に合致した場
     合、リストの先頭に近い方のエントリが後方にあるエントリに優先します
     。引数が省略されると、標準ではすべてにマッチする値に設定されます。

 -- の関数: warnings.simplefilter (action, category=Warning, lineno=0,
          append=False)

     単純なエントリを *note 警告フィルタ仕様: 897. のリストに挿入します
     。引数の意味は *note filterwarnings(): 144e. と同じですが、この関数
     により挿入されるフィルタはカテゴリと行番号が一致していればすべての
     モジュールのすべてのメッセージに合致しますので、正規表現は必要あり
     ません。

 -- の関数: warnings.resetwarnings ()

     警告フィルタをリセットします。これにより、 *note -W: 896. コマンド
     ラインオプションによるもの *note simplefilter(): 68d. 呼び出しによ
     るものを含め、 *note filterwarnings(): 144e. の呼び出しによる影響は
     すべて無効化されます。

 -- の関数: @warnings.deprecated (msg, *, category=DeprecationWarning,
          stacklevel=1)

     Decorator to indicate that a class, function or overload is
     deprecated.

     When this decorator is applied to an object, deprecation warnings
     may be emitted at runtime when the object is used.  *note static
     type checkers: 24e. will also generate a diagnostic on usage of the
     deprecated object.

     使い方:

          from warnings import deprecated
          from typing import overload

          @deprecated("Use B instead")
          class A:
              pass

          @deprecated("Use g instead")
          def f():
              pass

          @overload
          @deprecated("int support is deprecated")
          def g(x: int) -> int: ...
          @overload
          def g(x: str) -> int: ...

     The warning specified by 'category' will be emitted at runtime on
     use of deprecated objects.  For functions, that happens on calls;
     for classes, on instantiation and on creation of subclasses.  If
     the 'category' is ‘None’, no warning is emitted at runtime.  The
     'stacklevel' determines where the warning is emitted.  If it is ‘1’
     (the default), the warning is emitted at the direct caller of the
     deprecated object; if it is higher, it is emitted further up the
     stack.  Static type checker behavior is not affected by the
     'category' and 'stacklevel' arguments.

     The deprecation message passed to the decorator is saved in the
     ‘__deprecated__’ attribute on the decorated object.  If applied to
     an overload, the decorator must be after the *note @overload: 3e34.
     decorator for the attribute to exist on the overload as returned by
     *note typing.get_overloads(): 67a.

     Added in version 3.13: See PEP 702(1).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0702/


File: python.info,  Node: 利用可能なコンテキストマネージャー,  Prev: 利用可能な関数,  Up: warnings --- 警告の制御

5.29.6.11 利用可能なコンテキストマネージャー
............................................

 -- クラス: warnings.catch_warnings (*, record=False, module=None,
          action=None, category=Warning, lineno=0, append=False)

     警告フィルタと *note showwarning(): 4263. 関数をコピーし、終了時に
     復元するコンテキストマネージャーです。 'record' 引数が *note False:
     b05. (デフォルト値)だった場合、コンテキスト開始時には *note None:
     641. を返します。もし 'record' が *note True: bdb. だった場合、リス
     トを返します。このリストにはカスタムの *note showwarning(): 4263. 関
     数(この関数は同時に ‘sys.stdout’ への出力を抑制します)によってオブ
     ジェクトが継続的に追加されます。リストの中の各オブジェクトは、
     *note showwarning(): 4263. 関数の引数と同じ名前の属性を持っています
     。

     'module' 引数は、保護したいフィルタを持つモジュールを取ります。
     *note warnings: fa. を import して得られるモジュールの代わりに利用
     されます。この引数は、主に *note warnings: fa. モジュール自体をテス
     トする目的で追加されました。

     If the 'action' argument is not ‘None’, the remaining arguments are
     passed to *note simplefilter(): 68d. as if it were called
     immediately on entering the context.

     See *note 警告フィルタ: 897. for the meaning of the 'category' and
     'lineno' parameters.

          注釈: *note catch_warnings: 550. マネージャーは、モジュールの
          *note showwarning(): 4263. 関数と内部のフィルタ仕様のリストを
          置き換え、その後復元することによって動作しています。これは、コ
          ンテキストマネージャーがグローバルな状態を変更していることを意
          味していて、したがってスレッドセーフではありません。

     バージョン 3.11 で変更: Added the 'action', 'category', 'lineno',
     and 'append' parameters.


File: python.info,  Node: dataclasses --- データクラス,  Next: contextlib --- with 文コンテキスト用ユーティリティ,  Prev: warnings --- 警告の制御,  Up: Python ランタイムサービス

5.29.7 ‘dataclasses’ -- データクラス
------------------------------------

'ソースコード:' Lib/dataclasses.py(1)

__________________________________________________________________

このモジュールは、*note __init__(): 67c. や *note __repr__(): 5e8. のよ
うな *note 特殊メソッド: 1816. を生成し、ユーザー定義のクラスに自動的に
追加するデコレーターや関数を提供します。このモジュールは元々、 PEP
557(2) で説明されていました。

これらの生成されたメソッドで利用されるメンバー変数は PEP 526(3) 型アノテ
ーションを用いて定義されます。例えば、このコードでは:

     from dataclasses import dataclass

     @dataclass
     class InventoryItem:
         """Class for keeping track of an item in inventory."""
         name: str
         unit_price: float
         quantity_on_hand: int = 0

         def total_cost(self) -> float:
             return self.unit_price * self.quantity_on_hand

とりわけ、以下のような ‘__init__()’ が追加されます:

     def __init__(self, name: str, unit_price: float, quantity_on_hand: int = 0):
         self.name = name
         self.unit_price = unit_price
         self.quantity_on_hand = quantity_on_hand

このメソッドは自動的にクラスに追加される点に留意して下さい。上記の
‘InventoryItem’ クラスの定義中にこのメソッドが直接明記されるわけではあり
ません。

Added in version 3.7.

* Menu:

* モジュールの内容: モジュールの内容<4>.
* 初期化後の処理::
* クラス変数::
* 初期化限定変数::
* 凍結されたインスタンス::
* 継承: 継承<2>.
* Re-ordering of keyword-only parameters in __init__(): Re-ordering of keyword-only parameters in __init__.
* デフォルトファクトリ関数::
* 可変なデフォルト値::
* Descriptor-typed fields::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/dataclasses.py

   (2) https://peps.python.org/pep-0557/

   (3) https://peps.python.org/pep-0526/


File: python.info,  Node: モジュールの内容<4>,  Next: 初期化後の処理,  Up: dataclasses --- データクラス

5.29.7.1 モジュールの内容
.........................

 -- の関数: @dataclasses.dataclass (*, init=True, repr=True, eq=True,
          order=False, unsafe_hash=False, frozen=False, match_args=True,
          kw_only=False, slots=False, weakref_slot=False)

     この関数は、後述する *note 特殊メソッド: 1816. を生成し、クラスに追
     加する *note decorator: 6fc. です。

     ‘@dataclass’ デコレータは、‘field’ を探すためにクラスを検査します。
     ‘field’ は *note 型アノテーション: d23. を持つクラス変数として定義
     されます。後述する２つの例外を除き、 ‘@dataclass’ は変数アノテーシ
     ョンで指定した型を検査しません。

     生成されるすべてのメソッドの中でのフィールドの順序は、それらのフィ
     ールドがクラス定義に現れた順序です。

     ‘@dataclass’ デコレータは、後述する様々な "ダンダー" メソッド (訳注
     ：dunderはdouble underscoreの略で、メソッド名の前後にアンダースコア
     が2つ付いているメソッド) をクラスに追加します。クラスに既にこれらの
     メソッドが存在する場合の動作は、後述する引数によって異なります。デ
     コレータは呼び出した際に指定したクラスと同じクラスを返します。新し
     いクラスは生成されません。

     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:

          @dataclass
          class C:
              ...

          @dataclass()
          class C:
              ...

          @dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False,
                     match_args=True, kw_only=False, slots=False, weakref_slot=False)
          class C:
              ...

     The parameters to ‘@dataclass’ are:

        - 'init': If true (the default), a *note __init__(): 67c. method
          will be generated.

          If the class already defines ‘__init__()’, this parameter is
          ignored.

        - 'repr': If true (the default), a *note __repr__(): 5e8. method
          will be generated.  The generated repr string will have the
          class name and the name and repr of each field, in the order
          they are defined in the class.  Fields that are marked as
          being excluded from the repr are not included.  For example:
          ‘InventoryItem(name='widget', unit_price=3.0,
          quantity_on_hand=10)’.

          If the class already defines ‘__repr__()’, this parameter is
          ignored.

        - 'eq': If true (the default), an *note __eq__(): ac8. method
          will be generated.  This method compares the class as if it
          were a tuple of its fields, in order.  Both instances in the
          comparison must be of the identical type.

          If the class already defines ‘__eq__()’, this parameter is
          ignored.

        - 'order': If true (the default is ‘False’), *note __lt__():
          12d9, *note __le__(): 12da, *note __gt__(): 12db, and *note
          __ge__(): 12dc. methods will be generated.  These compare the
          class as if it were a tuple of its fields, in order.  Both
          instances in the comparison must be of the identical type.  If
          'order' is true and 'eq' is false, a *note ValueError: 1e3. is
          raised.

          If the class already defines any of ‘__lt__()’, ‘__le__()’,
          ‘__gt__()’, or ‘__ge__()’, then *note TypeError: 502. is
          raised.

        - 'unsafe_hash': If ‘False’ (the default), a *note __hash__():
          ac9. method is generated according to how 'eq' and 'frozen'
          are set.

          ‘__hash__()’ is used by built-in *note hash(): 5b5, and when
          objects are added to hashed collections such as dictionaries
          and sets.  Having a ‘__hash__()’ implies that instances of the
          class are immutable.  Mutability is a complicated property
          that depends on the programmer's intent, the existence and
          behavior of ‘__eq__()’, and the values of the 'eq' and
          'frozen' flags in the ‘@dataclass’ decorator.

          By default, ‘@dataclass’ will not implicitly add a *note
          __hash__(): ac9. method unless it is safe to do so.  Neither
          will it add or change an existing explicitly defined
          ‘__hash__()’ method.  Setting the class attribute ‘__hash__ =
          None’ has a specific meaning to Python, as described in the
          ‘__hash__()’ documentation.

          If ‘__hash__()’ is not explicitly defined, or if it is set to
          ‘None’, then ‘@dataclass’ 'may' add an implicit ‘__hash__()’
          method.  Although not recommended, you can force ‘@dataclass’
          to create a ‘__hash__()’ method with ‘unsafe_hash=True’.  This
          might be the case if your class is logically immutable but can
          still be mutated.  This is a specialized use case and should
          be considered carefully.

          Here are the rules governing implicit creation of a
          ‘__hash__()’ method.  Note that you cannot both have an
          explicit ‘__hash__()’ method in your dataclass and set
          ‘unsafe_hash=True’; this will result in a *note TypeError:
          502.

          If 'eq' and 'frozen' are both true, by default ‘@dataclass’
          will generate a ‘__hash__()’ method for you.  If 'eq' is true
          and 'frozen' is false, ‘__hash__()’ will be set to ‘None’,
          marking it unhashable (which it is, since it is mutable).  If
          'eq' is false, ‘__hash__()’ will be left untouched meaning the
          ‘__hash__()’ method of the superclass will be used (if the
          superclass is *note object: a5a, this means it will fall back
          to id-based hashing).

        - 'frozen': If true (the default is ‘False’), assigning to
          fields will generate an exception.  This emulates read-only
          frozen instances.  If *note __setattr__(): 1e8d. or *note
          __delattr__(): 1e8e. is defined in the class, then *note
          TypeError: 502. is raised.  See the discussion below.

        - 'match_args': If true (the default is ‘True’), the *note
          __match_args__: 182a. tuple will be created from the list of
          parameters to the generated *note __init__(): 67c. method
          (even if ‘__init__()’ is not generated, see above).  If false,
          or if ‘__match_args__’ is already defined in the class, then
          ‘__match_args__’ will not be generated.

          Added in version 3.10.

        - '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 effect is that the *note
          __init__(): 67c. parameter generated from a keyword-only field
          must be specified with a keyword when ‘__init__()’ is called.
          There is no effect on any other aspect of dataclasses.  See
          the *note parameter: 1e5e. glossary entry for details.  Also
          see the *note KW_ONLY: 4278. section.

          Added in version 3.10.

        - 'slots': If true (the default is ‘False’), *note __slots__:
          1493. attribute will be generated and new class will be
          returned instead of the original one.  If ‘__slots__’ is
          already defined in the class, then *note TypeError: 502. is
          raised.

               警告: Calling no-arg *note super(): 4a8. in dataclasses
               using ‘slots=True’ will result in the following exception
               being raised: ‘TypeError: super(type, obj): obj must be
               an instance or subtype of type’.  The two-arg *note
               super(): 4a8. is a valid workaround.  See gh-90562(1) for
               full details.

               警告: Passing parameters to a base class *note
               __init_subclass__(): 5fd. when using ‘slots=True’ will
               result in a *note TypeError: 502.  Either use
               ‘__init_subclass__’ with no parameters or use default
               values as a workaround.  See gh-91126(2) for full
               details.

          Added in version 3.10.

          バージョン 3.11 で変更: If a field name is already included in
          the ‘__slots__’ of a base class, it will not be included in
          the generated ‘__slots__’ to prevent *note overriding them:
          1ecf.  Therefore, do not use ‘__slots__’ to retrieve the field
          names of a dataclass.  Use *note fields(): 16aa. instead.  To
          be able to determine inherited slots, base class ‘__slots__’
          may be any iterable, but 'not' an iterator.

        - 'weakref_slot': If true (the default is ‘False’), add a slot
          named "__weakref__", which is required to make an instance
          *note weakref-able: fbb.  It is an error to specify
          ‘weakref_slot=True’ without also specifying ‘slots=True’.

          Added in version 3.11.

     ‘フィールド’ には、通常の Python の文法でデフォルト値を指定できます
     。

          @dataclass
          class C:
              a: int       # 'a' has no default value
              b: int = 0   # assign a default value for 'b'

     In this example, both ‘a’ and ‘b’ will be included in the added
     *note __init__(): 67c. method, which will be defined as:

          def __init__(self, a: int, b: int = 0):

     デフォルト値を指定しないフィールドを、デフォルト値を指定したフィー
     ルドの後ろに定義すると、 *note TypeError: 502. が送出されます。これ
     は、単一のクラスであっても、クラス継承の結果でも起きえます。

 -- の関数: dataclasses.field (*, default=MISSING,
          default_factory=MISSING, init=True, repr=True, hash=None,
          compare=True, metadata=None, kw_only=MISSING)

     For common and simple use cases, no other functionality is
     required.  There are, however, some dataclass features that require
     additional per-field information.  To satisfy this need for
     additional information, you can replace the default field value
     with a call to the provided ‘field()’ function.  For example:

          @dataclass
          class C:
              mylist: list[int] = field(default_factory=list)

          c = C()
          c.mylist += [1, 2, 3]

     As shown above, the *note MISSING: 4279. value is a 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 *note MISSING: 4279. value.

     The parameters to ‘field()’ are:

        - 'default': If provided, this will be the default value for
          this field.  This is needed because the ‘field()’ call itself
          replaces the normal position of the default value.

        - '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 purposes, this can be used to
          specify fields with mutable default values, as discussed
          below.  It is an error to specify both 'default' and
          'default_factory'.

        - 'init': If true (the default), this field is included as a
          parameter to the generated *note __init__(): 67c. method.

        - 'repr': If true (the default), this field is included in the
          string returned by the generated *note __repr__(): 5e8.
          method.

        - 'hash': This can be a bool or ‘None’.  If true, this field is
          included in the generated *note __hash__(): ac9. method.  If
          ‘None’ (the default), use the value of 'compare': this would
          normally be the expected behavior.  A field should be
          considered in the hash if it's used for comparisons.  Setting
          this value to anything other than ‘None’ is discouraged.

          フィールドのハッシュ値を計算するコストが高い場合に、
          ‘hash=False’ だが ‘compare=True’ と設定する理由が 1 つあるとす
          れば、フィールドが等価検査に必要かつ、その型のハッシュ値を計算
          するのに他のフィールドも使われることです。 フィールドがハッシ
          ュから除外されていたとしても、比較には使えます。

        - 'compare': If true (the default), this field is included in
          the generated equality and comparison methods (*note __eq__():
          ac8, *note __gt__(): 12db, et al.).

        - 'metadata': This can be a mapping or ‘None’.  ‘None’ is
          treated as an empty dict.  This value is wrapped in *note
          MappingProxyType(): 43a. to make it read-only, and exposed on
          the *note Field: 21b3. object.  It is not used at all by Data
          Classes, and is provided as a third-party extension mechanism.
          Multiple third-parties can each have their own key, to use as
          a namespace in the metadata.

        - 'kw_only': If true, this field will be marked as keyword-only.
          This is used when the generated *note __init__(): 67c.
          method's parameters are computed.

          Added in version 3.10.

     If the default value of a field is specified by a call to
     ‘field()’, then the class attribute for this field will be replaced
     by the specified 'default' value.  If 'default' is not provided,
     then the class attribute will be deleted.  The intent is that after
     the *note @dataclass: 1ad. decorator runs, the class attributes
     will all contain the default values for the fields, just as if the
     default value itself were specified.  For example, after:

          @dataclass
          class C:
              x: int
              y: int = field(repr=False)
              z: int = field(repr=False, default=10)
              t: int = 20

     The class attribute ‘C.z’ will be ‘10’, the class attribute ‘C.t’
     will be ‘20’, and the class attributes ‘C.x’ and ‘C.y’ will not be
     set.

 -- クラス: dataclasses.Field

     ‘Field’ objects describe each defined field.  These objects are
     created internally, and are returned by the *note fields(): 16aa.
     module-level method (see below).  Users should never instantiate a
     ‘Field’ object directly.  Its documented attributes are:

        - ‘name’: The name of the field.

        - ‘type’: The type of the field.

        - ‘default’, ‘default_factory’, ‘init’, ‘repr’, ‘hash’,
          ‘compare’, ‘metadata’, and ‘kw_only’ have the identical
          meaning and values as they do in the *note field(): 198b.
          function.

     他の属性があることもありますが、それらはプライベートであり、調べた
     り、依存したりしてはなりません。

 -- の関数: dataclasses.fields (class_or_instance)

     このデータクラスのフィールドを定義する *note Field: 21b3. オブジェ
     クトをタプルで返します。 データクラスあるいはデータクラスのインスタ
     ンスを受け付けます。 データクラスやデータクラスのインスタンスが渡さ
     れなかった場合は、 *note TypeError: 502. を送出します。 ‘ClassVar’
     や ‘InitVar’ といった疑似フィールドは返しません。

 -- の関数: dataclasses.asdict (obj, *, dict_factory=dict)

     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, lists, and
     tuples are recursed into.  Other objects are copied with *note
     copy.deepcopy(): b3c.

     Example of using ‘asdict()’ on nested dataclasses:

          @dataclass
          class Point:
               x: int
               y: int

          @dataclass
          class C:
               mylist: list[Point]

          p = Point(10, 20)
          assert asdict(p) == {'x': 10, 'y': 20}

          c = C([Point(0, 0), Point(10, 4)])
          assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}

     To create a shallow copy, the following workaround may be used:

          {field.name: getattr(obj, field.name) for field in fields(obj)}

     ‘asdict()’ raises *note TypeError: 502. if 'obj' is not a dataclass
     instance.

 -- の関数: dataclasses.astuple (obj, *, tuple_factory=tuple)

     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, lists, and tuples are
     recursed into.  Other objects are copied with *note
     copy.deepcopy(): b3c.

     1つ前の例の続きです:

          assert astuple(p) == (10, 20)
          assert astuple(c) == ([(0, 0), (10, 4)],)

     To create a shallow copy, the following workaround may be used:

          tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))

     ‘astuple()’ raises *note TypeError: 502. if 'obj' is not a
     dataclass instance.

 -- の関数: dataclasses.make_dataclass (cls_name, fields, *, bases=(),
          namespace=None, init=True, repr=True, eq=True, order=False,
          unsafe_hash=False, frozen=False, match_args=True,
          kw_only=False, slots=False, weakref_slot=False, module=None)

     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 in 'namespace'.  'fields' is an iterable whose
     elements are each either ‘name’, ‘(name, type)’, or ‘(name, type,
     Field)’.  If just ‘name’ is supplied, *note typing.Any: 678. is
     used for ‘type’.  The values of 'init', 'repr', 'eq', 'order',
     'unsafe_hash', 'frozen', 'match_args', 'kw_only', 'slots', and
     'weakref_slot' have the same meaning as they do in *note
     @dataclass: 1ad.

     If 'module' is defined, the ‘__module__’ attribute of the dataclass
     is set to that value.  By default, it is set to the module name of
     the caller.

     This function is not strictly required, because any Python
     mechanism for creating a new class with ‘__annotations__’ can then
     apply the *note @dataclass: 1ad. function to convert that class to
     a dataclass.  This function is provided as a convenience.  For
     example:

          C = make_dataclass('C',
                             [('x', int),
                               'y',
                              ('z', int, field(default=5))],
                             namespace={'add_one': lambda self: self.x + 1})

     は、次のコードと等しいです:

          @dataclass
          class C:
              x: int
              y: 'typing.Any'
              z: int = 5

              def add_one(self):
                  return self.x + 1

 -- の関数: dataclasses.replace (obj, /, **changes)

     Creates a new object of the same type as 'obj', replacing fields
     with values from 'changes'.  If 'obj' is not a Data Class, raises
     *note TypeError: 502.  If keys in 'changes' are not field names of
     the given dataclass, raises *note TypeError: 502.

     The newly returned object is created by calling the *note
     __init__(): 67c. method of the dataclass.  This ensures that *note
     __post_init__(): 427a, if present, is also called.

     Init-only variables without default values, if any exist, must be
     specified on the call to ‘replace()’ so that they can be passed to
     ‘__init__()’ and *note __post_init__(): 427a.

     It is an error for 'changes' to contain any fields that are defined
     as having ‘init=False’.  A *note ValueError: 1e3. will be raised in
     this case.

     Be forewarned about how ‘init=False’ fields work during a call to
     ‘replace()’.  They are not copied from the source object, but
     rather are initialized in *note __post_init__(): 427a, if they're
     initialized at all.  It is expected that ‘init=False’ fields will
     be rarely and judiciously used.  If they are used, it might be wise
     to have alternate class constructors, or perhaps a custom
     ‘replace()’ (or similarly named) method which handles instance
     copying.

     Dataclass instances are also supported by generic function *note
     copy.replace(): 137.

 -- の関数: dataclasses.is_dataclass (obj)

     Return ‘True’ if its parameter is a dataclass (including subclasses
     of a dataclass) or an instance of one, otherwise return ‘False’.

     引数がデータクラスのインスタンスである (そして、データクラスそのも
     のではない) かどうかを知る必要がある場合は、 ‘not isinstance(obj,
     type)’ で追加のチェックをしてください:

          def is_dataclass_instance(obj):
              return is_dataclass(obj) and not isinstance(obj, type)

 -- データ: dataclasses.MISSING

     デフォルト値やdefault_factoryが設定されてない場合の番兵の値を設定し
     ます。

 -- データ: dataclasses.KW_ONLY

     A sentinel value used as a type annotation.  Any fields after a
     pseudo-field with the type of ‘KW_ONLY’ are marked as keyword-only
     fields.  Note that a pseudo-field of type ‘KW_ONLY’ is otherwise
     completely ignored.  This includes the name of such a field.  By
     convention, a name of ‘_’ is used for a ‘KW_ONLY’ field.
     Keyword-only fields signify *note __init__(): 67c. parameters that
     must be specified as keywords when the class is instantiated.

     このサンプルでは ‘y’ と ‘z’ がキーワード専用フィールドとなります:

          @dataclass
          class Point:
              x: float
              _: KW_ONLY
              y: float
              z: float

          p = Point(0, y=1.5, z=2.0)

     In a single dataclass, it is an error to specify more than one
     field whose type is ‘KW_ONLY’.

     Added in version 3.10.

 -- 例外: dataclasses.FrozenInstanceError

     ‘frozen=True’ 付きで定義されたデータクラスで、暗黙的に定義された
     *note __setattr__(): 1e8d. または *note __delattr__(): 1e8e. が呼び
     出されたときに送出されます。これは *note AttributeError: 326. のサ
     ブクラスです。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/90562

   (2) https://github.com/python/cpython/issues/91126


File: python.info,  Node: 初期化後の処理,  Next: クラス変数,  Prev: モジュールの内容<4>,  Up: dataclasses --- データクラス

5.29.7.2 初期化後の処理
.......................

 -- の関数: dataclasses.__post_init__ ()

     When defined on the class, it will be called by the generated *note
     __init__(): 67c, normally as ‘self.__post_init__()’.  However, if
     any ‘InitVar’ fields are defined, they will also be passed to
     ‘__post_init__()’ in the order they were defined in the class.  If
     no ‘__init__()’ method is generated, then ‘__post_init__()’ will
     not automatically be called.

     他の機能と組み合わせることで、他の 1 つ以上のフィールドに依存してい
     るフィールドが初期化できます。 例えば次のようにできます:

          @dataclass
          class C:
              a: float
              b: float
              c: float = field(init=False)

              def __post_init__(self):
                  self.c = self.a + self.b

The *note __init__(): 67c. method generated by *note @dataclass: 1ad.
does not call base class ‘__init__()’ methods.  If the base class has an
‘__init__()’ method that has to be called, it is common to call this
method in a *note __post_init__(): 427a. method:

     class Rectangle:
         def __init__(self, height, width):
             self.height = height
             self.width = width

     @dataclass
     class Square(Rectangle):
         side: float

         def __post_init__(self):
             super().__init__(self.side, self.side)

Note, however, that in general the dataclass-generated ‘__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.

下にある初期化限定変数についての節で、 ‘__post_init__()’ にパラメータを
渡す方法を参照してください。 *note replace(): 165e. が ‘init=False’ であ
るフィールドをどう取り扱うかについての警告も参照してください。


File: python.info,  Node: クラス変数,  Next: 初期化限定変数,  Prev: 初期化後の処理,  Up: dataclasses --- データクラス

5.29.7.3 クラス変数
...................

One of the few places where *note @dataclass: 1ad. actually inspects the
type of a field is to determine if a field is a class variable as
defined in PEP 526(1).  It does this by checking if the type of the
field is *note typing.ClassVar: 247.  If a field is a ‘ClassVar’, it is
excluded from consideration as a field and is ignored by the dataclass
mechanisms.  Such ‘ClassVar’ pseudo-fields are not returned by the
module-level *note fields(): 16aa. function.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0526/


File: python.info,  Node: 初期化限定変数,  Next: 凍結されたインスタンス,  Prev: クラス変数,  Up: dataclasses --- データクラス

5.29.7.4 初期化限定変数
.......................

Another place where *note @dataclass: 1ad. inspects a type annotation is
to determine if a field is an init-only variable.  It does this by
seeing if the type of a field is of type ‘dataclasses.InitVar’.  If a
field is an ‘InitVar’, it is considered a pseudo-field called an
init-only field.  As it is not a true field, it is not returned by the
module-level *note fields(): 16aa. function.  Init-only fields are added
as parameters to the generated *note __init__(): 67c. method, and are
passed to the optional *note __post_init__(): 427a. method.  They are
not otherwise used by dataclasses.

例えば、あるフィールドがデータベースから初期化されると仮定して、クラスを
作成するときには値が与えられない次の場合を考えます:

     @dataclass
     class C:
         i: int
         j: int | None = None
         database: InitVar[DatabaseType | None] = None

         def __post_init__(self, database):
             if self.j is None and database is not None:
                 self.j = database.lookup('j')

     c = C(10, database=my_database)

In this case, *note fields(): 16aa. will return *note Field: 21b3.
objects for ‘i’ and ‘j’, but not for ‘database’.


File: python.info,  Node: 凍結されたインスタンス,  Next: 継承<2>,  Prev: 初期化限定変数,  Up: dataclasses --- データクラス

5.29.7.5 凍結されたインスタンス
...............................

It is not possible to create truly immutable Python objects.  However,
by passing ‘frozen=True’ to the *note @dataclass: 1ad. decorator you can
emulate immutability.  In that case, dataclasses will add *note
__setattr__(): 1e8d. and *note __delattr__(): 1e8e. methods to the
class.  These methods will raise a *note FrozenInstanceError: 427b. when
invoked.

There is a tiny performance penalty when using ‘frozen=True’: *note
__init__(): 67c. cannot use simple assignment to initialize fields, and
must use ‘object.__setattr__()’.


File: python.info,  Node: 継承<2>,  Next: Re-ordering of keyword-only parameters in __init__,  Prev: 凍結されたインスタンス,  Up: dataclasses --- データクラス

5.29.7.6 継承
.............

When the dataclass is being created by the *note @dataclass: 1ad.
decorator, it looks through all of the class's base classes in reverse
MRO (that is, starting at *note object: a5a.) and, for each dataclass
that it finds, adds the fields from that base class to an ordered
mapping of fields.  After all of the base class fields are added, it
adds its own fields to the ordered mapping.  All of the generated
methods will use this combined, calculated ordered mapping of fields.
Because the fields are in insertion order, derived classes override base
classes.  An example:

     @dataclass
     class Base:
         x: Any = 15.0
         y: int = 0

     @dataclass
     class C(Base):
         z: int = 10
         x: int = 15

The final list of fields is, in order, ‘x’, ‘y’, ‘z’.  The final type of
‘x’ is *note int: 238, as specified in class ‘C’.

The generated *note __init__(): 67c. method for ‘C’ will look like:

     def __init__(self, x: int = 15, y: int = 0, z: int = 10):


File: python.info,  Node: Re-ordering of keyword-only parameters in __init__,  Next: デフォルトファクトリ関数,  Prev: 継承<2>,  Up: dataclasses --- データクラス

5.29.7.7 Re-ordering of keyword-only parameters in ‘__init__()’
...............................................................

*note __init__(): 67c. で必要なパラメータが算出されると、キーワード専用
引数は他の一般的な（非キーワード専用）パラメータの後に移動します。これは
、すべてのキーワード専用引数は、非キーワード専用パラメータの末尾にこなけ
ればならないという、キーワード専用パラメータのPythonの実装の都合で必要な
ことです。

In this example, ‘Base.y’, ‘Base.w’, and ‘D.t’ are keyword-only fields,
and ‘Base.x’ and ‘D.z’ are regular fields:

     @dataclass
     class Base:
         x: Any = 15.0
         _: KW_ONLY
         y: int = 0
         w: int = 1

     @dataclass
     class D(Base):
         z: int = 10
         t: int = field(kw_only=True, default=0)

The generated ‘__init__()’ method for ‘D’ will look like:

     def __init__(self, x: Any = 15.0, z: int = 10, *, y: int = 0, w: int = 1, t: int = 0):

パラメータは、フィールドのリストの表示方法によって並べ替えられます。通常
のフィールドから派生したパラメータの後に、キーワードのみのフィールドから
派生したパラメータが続きます。

The relative ordering of keyword-only parameters is maintained in the
re-ordered ‘__init__()’ parameter list.


File: python.info,  Node: デフォルトファクトリ関数,  Next: 可変なデフォルト値,  Prev: Re-ordering of keyword-only parameters in __init__,  Up: dataclasses --- データクラス

5.29.7.8 デフォルトファクトリ関数
.................................

If a *note field(): 198b. 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:

     mylist: list = field(default_factory=list)

If a field is excluded from *note __init__(): 67c. (using ‘init=False’)
and the field also specifies 'default_factory', then the default factory
function will always be called from the generated ‘__init__()’ function.
This happens because there is no other way to give the field an initial
value.


File: python.info,  Node: 可変なデフォルト値,  Next: Descriptor-typed fields,  Prev: デフォルトファクトリ関数,  Up: dataclasses --- データクラス

5.29.7.9 可変なデフォルト値
...........................

Python はメンバ変数のデフォルト値をクラス属性に保持します。 データクラス
を使っていない、この例を考えてみましょう:

     class C:
         x = []
         def add(self, element):
             self.x.append(element)

     o1 = C()
     o2 = C()
     o1.add(1)
     o2.add(2)
     assert o1.x == [1, 2]
     assert o1.x is o2.x

Note that the two instances of class ‘C’ share the same class variable
‘x’, as expected.

データクラスを使っているこのコードが 'もし仮に' 有効なものだとしたら:

     @dataclass
     class D:
         x: list = []      # This code raises ValueError
         def add(self, element):
             self.x.append(element)

データクラスは次のようなコードを生成するでしょう:

     class D:
         x = []
         def __init__(self, x=x):
             self.x = x
         def add(self, element):
             self.x.append(element)

     assert D().x is D().x

This has the same issue as the original example using class ‘C’.  That
is, two instances of class ‘D’ that do not specify a value for ‘x’ when
creating a class instance will share the same copy of ‘x’.  Because
dataclasses just use normal Python class creation they also share this
behavior.  There is no general way for Data Classes to detect this
condition.  Instead, the *note @dataclass: 1ad. decorator will raise a
*note ValueError: 1e3. if it detects an unhashable default parameter.
The assumption is that if a value is unhashable, it is mutable.  This is
a partial solution, but it does protect against many common errors.

デフォルトファクトリ関数を使うのが、フィールドのデフォルト値として可変な
型の新しいインスタンスを作成する手段です:

     @dataclass
     class D:
         x: list = field(default_factory=list)

     assert D().x is not D().x

バージョン 3.11 で変更: Instead of looking for and disallowing objects
of type *note list: 5dc, *note dict: 237, or *note set: 5a3, unhashable
objects are now not allowed as default values.  Unhashability is used to
approximate mutability.


File: python.info,  Node: Descriptor-typed fields,  Prev: 可変なデフォルト値,  Up: dataclasses --- データクラス

5.29.7.10 Descriptor-typed fields
.................................

Fields that are assigned *note descriptor objects: c1d. as their default
value have the following special behaviors:

   * The value for the field passed to the dataclass's *note __init__():
     67c. method is passed to the descriptor's *note __set__(): 1eca.
     method rather than overwriting the descriptor object.

   * Similarly, when getting or setting the field, the descriptor's
     *note __get__(): 1490. or ‘__set__()’ method is called rather than
     returning or overwriting the descriptor object.

   * To determine whether a field contains a default value, *note
     @dataclass: 1ad. will call the descriptor's ‘__get__()’ method
     using its class access form: ‘descriptor.__get__(obj=None,
     type=cls)’.  If the descriptor returns a value in this case, it
     will be used as the field's default.  On the other hand, if the
     descriptor raises *note AttributeError: 326. in this situation, no
     default value will be provided for the field.

     class IntConversionDescriptor:
         def __init__(self, *, default):
             self._default = default

         def __set_name__(self, owner, name):
             self._name = "_" + name

         def __get__(self, obj, type):
             if obj is None:
                 return self._default

             return getattr(obj, self._name, self._default)

         def __set__(self, obj, value):
             setattr(obj, self._name, int(value))

     @dataclass
     class InventoryItem:
         quantity_on_hand: IntConversionDescriptor = IntConversionDescriptor(default=100)

     i = InventoryItem()
     print(i.quantity_on_hand)   # 100
     i.quantity_on_hand = 2.5    # calls __set__ with 2.5
     print(i.quantity_on_hand)   # 2

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.


File: python.info,  Node: contextlib --- with 文コンテキスト用ユーティリティ,  Next: abc --- 抽象基底クラス,  Prev: dataclasses --- データクラス,  Up: Python ランタイムサービス

5.29.8 ‘contextlib’ -- ‘with’ 文コンテキスト用ユーティリティ
------------------------------------------------------------

'ソースコード:' Lib/contextlib.py(1)

__________________________________________________________________

このモジュールは *note with: 59c. 文に関わる一般的なタスクのためのユーテ
ィリティを提供します。詳しい情報は、 *note コンテキストマネージャ型:
1f20. と *note with文とコンテキストマネージャ: 1f1e. を参照してください
。

* Menu:

* ユーティリティ::
* 例とレシピ: 例とレシピ<3>.
* 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/contextlib.py


File: python.info,  Node: ユーティリティ,  Next: 例とレシピ<3>,  Up: contextlib --- with 文コンテキスト用ユーティリティ

5.29.8.1 ユーティリティ
.......................

以下の関数とクラスを提供しています:

 -- クラス: contextlib.AbstractContextManager

     *note object.__enter__(): 592. と *note object.__exit__(): 12ce. の
     2つのメソッドを実装した抽象基底クラス (*note abstract base class:
     1186.) です。 *note object.__enter__(): 592. は ‘self’ を返すデフォ
     ルトの実装が提供されるいっぽう、 *note object.__exit__(): 12ce. は
     デフォルトで ‘None’ を返す抽象メソッドです。 *note
     コンテキストマネージャ型: 1f20. の定義も参照してください。

     Added in version 3.6.

 -- クラス: contextlib.AbstractAsyncContextManager

     *note object.__aenter__(): 1f30. と *note object.__aexit__(): 158e.
     の2つのメソッドを実装するクラスのための抽象基底クラス (*note
     abstract base class: 1186.) です。 *note object.__aenter__(): 1f30.
     は ‘self’ を返すデフォルト実装が提供されるいっぽう、 *note
     object.__aexit__(): 158e. はデフォルトで ‘None’ を返す抽象メソッド
     です。 *note 非同期コンテキストマネージャ (Asynchronous Context
     Manager): 5c6. の定義も参照してください。

     Added in version 3.7.

 -- の関数: @contextlib.contextmanager

     この関数は *note with: 59c. 文コンテキストマネージャのファクトリ関
     数を定義するために利用できる *note デコレータ: 6fc. です。新しいク
     ラスや *note __enter__(): 592. と *note __exit__(): 12ce. メソッド
     を別々に定義しなくても、ファクトリ関数を定義することができます。

     多くのオブジェクトが with 文の仕様を固有にサポートしていますが、コ
     ンテキストマネージャの権限に属さず、 ‘close()’ メソッドを実装してい
     ないために ‘contextlib.closing’ の利用もできないリソースを管理する
     必要があることがあります。

     リソースを正しく管理するよう保証する抽象的な例は以下のようなもので
     しょう:

          from contextlib import contextmanager

          @contextmanager
          def managed_resource(*args, **kwds):
              # Code to acquire resource, e.g.:
              resource = acquire_resource(*args, **kwds)
              try:
                  yield resource
              finally:
                  # Code to release resource, e.g.:
                  release_resource(resource)

     このとき、関数は次のように使うことができます:

          >>> with managed_resource(timeout=3600) as resource:
          ...     # Resource is released at the end of this block,
          ...     # even if code in the block raises an exception

     デコレート対象の関数は呼び出されたときに *note ジェネレータ:
     1035.-イテレータを返す必要があります。このイテレータは必ず値を1つ
     yield しなければなりません。 *note with: 59c. 文の ‘as’ 節が存在す
     るなら、その値は as 節のターゲットへ束縛されることになります。

     ジェネレータが yield を実行した箇所で *note with: 59c. 文のネストさ
     れたブロックが実行されます。ブロックから抜けた後でジェネレータは再
     開されます。ブロック内で処理されない例外が発生した場合は、ジェネレ
     ータ内部の yield を実行した箇所で例外が再送出されます。なので、(も
     しあれば) エラーを捕捉したり、クリーンアップ処理を確実に実行したり
     するために、*note try: 6b4...*note except: 170...*note finally:
     997. 構文を使用できます。例外を捕捉する目的が、(完全に例外を抑制し
     てしまうのではなく) 単に例外のログをとるため、もしくはあるアクショ
     ンを実行するためなら、ジェネレータはその例外を再送出しなければなり
     ません。例外を再送出しない場合、ジェネレータのコンテキストマネージ
     ャは ‘with’ 文に対して例外が処理されたことを示し、‘with’ 文の直後の
     文から実行を再開します。

     *note contextmanager(): 11d3. は *note ContextDecorator: 11d2. を使
     っているので、 *note contextmanager(): 11d3. で作ったコンテキストマ
     ネージャは *note with: 59c. 文だけでなくデコレータとしても利用でき
     ます。デコレーターとして利用された場合、新しい generator インスタン
     スが関数呼び出しのたびに暗黙に生成されます (このことによって、
     *note contextmanager(): 11d3. によって作られたなにがしか「単発」コ
     ンテキストマネージャを、コンテキストマネージャがデコレータとして使
     われるためには多重に呼び出されることをサポートする必要がある、とい
     う要件に合致させることが出来ます。)

     バージョン 3.2 で変更: *note ContextDecorator: 11d2. の使用。

 -- の関数: @contextlib.asynccontextmanager

          *note contextmanager(): 11d3. と似ていますが、 *note
          非同期コンテキストマネージャ (asynchronous context manager):
          5c6. を生成します。

          この関数は *note async with: 59f. 文のための非同期コンテキスト
          マネージャのファクトリ関数を定義するために利用できるデコレータ
          (*note decorator: 6fc.) です。新しいクラスや *note
          __aenter__(): 1f30. と *note __aexit__(): 158e. メソッドを個別
          に定義する必要はありません。このデコレータは非同期ジェネレータ
          (*note asynchronous generator: 1f99.) 関数に適用しなければなり
          ません。

          簡単な例:

               from contextlib import asynccontextmanager

               @asynccontextmanager
               async def get_connection():
                   conn = await acquire_db_connection()
                   try:
                       yield conn
                   finally:
                       await release_db_connection(conn)

               async def get_all_users():
                   async with get_connection() as conn:
                       return conn.query('SELECT ...')

          Added in version 3.7.

          *note asynccontextmanager(): af8. とともに定義されたコンテキス
          トマネージャは、デコレータとして使うことも *note async with:
          59f. 文と組み合わせて使うこともできます:

               import time
               from contextlib import asynccontextmanager

               @asynccontextmanager
               async def timeit():
                   now = time.monotonic()
                   try:
                       yield
                   finally:
                       print(f'it took {time.monotonic() - now}s to run')

               @timeit()
               async def main():
                   # ... async code ...

          デコレータとして使われた場合は、各関数呼び出しに対して暗黙のう
          ちに新しいジェネレータインスタンスが生成されます。これにより、
          *note asynccontextmanager(): af8. で生成された単回使用のコンテ
          キストマネージャが複数回呼び出し可能となり、コンテキストマネー
          ジャをデコレータとして使うことができるための要件を満たすように
          することができます。

     バージョン 3.10 で変更: *note asynccontextmanager(): af8. により生
     成された非同期コンテキストマネージャをデコレータとして使うことがで
     きるようになりました。

 -- の関数: contextlib.closing (thing)

     ブロックの完了時に 'thing' を close するコンテキストマネージャを返
     します。これは基本的に以下と等価です:

          from contextlib import contextmanager

          @contextmanager
          def closing(thing):
              try:
                  yield thing
              finally:
                  thing.close()

     そして、明示的に ‘page’ を close する必要なしに、次のように書くこと
     ができます:

          from contextlib import closing
          from urllib.request import urlopen

          with closing(urlopen('https://www.python.org')) as page:
              for line in page:
                  print(line)

     ‘page’ を明示的に close する必要は無く、エラーが発生した場合でも、
     *note with: 59c. ブロックを出るときに ‘page.close()’ が呼ばれます。

          注釈: Most types managing resources support the *note context
          manager: 59e. protocol, which closes 'thing' on leaving the
          *note with: 59c. statement.  As such, ‘closing()’ is most
          useful for third party types that don't support context
          managers.  This example is purely for illustration purposes,
          as *note urlopen(): 273. would normally be used in a context
          manager.

 -- の関数: contextlib.aclosing (thing)

     ブロックの完了時に 'thing' の ‘aclose()’ メソッドを呼び出すような非
     同期コンテキストマネージャを返します。これは基本的に以下と等価です:

          from contextlib import asynccontextmanager

          @asynccontextmanager
          async def aclosing(thing):
              try:
                  yield thing
              finally:
                  await thing.aclose()

     重要なことは、たとえば次の例のように *note break: a77. や例外によっ
     て早期にブロックが終了した場合に、 ‘aclosing()’ は非同期ジェネレー
     タの決定論的なクリーンアップをサポートすることです:

          from contextlib import aclosing

          async with aclosing(my_generator()) as values:
              async for value in values:
                  if value == 42:
                      break

     このパターンは、ジェネレータの非同期な終了のコードがイテレーション
     処理と同じコンテキストの中で実行されることを保証します (すなわち例
     外とコンテキスト変数は期待通りに動作し、またジェネレータが依存する
     タスクの寿命が尽きたあとに終了のコードが実行されることもありません
     )。

     Added in version 3.10.

 -- の関数: contextlib.nullcontext (enter_result=None)

     'enter_result' を ‘__enter__’ メソッドが返すだけで、その他は何もし
     ないコンテキストマネージャを返します。たとえば以下のように、ある機
     能を持った別のコンテキストマネージャに対する、選択可能な代役として
     使われることが意図されています:

          def myfunction(arg, ignore_exceptions=False):
              if ignore_exceptions:
                  # Use suppress to ignore all exceptions.
                  cm = contextlib.suppress(Exception)
              else:
                  # Do not ignore any exceptions, cm has no effect.
                  cm = contextlib.nullcontext()
              with cm:
                  # Do something

     'enter_result' を使った例です:

          def process_file(file_or_path):
              if isinstance(file_or_path, str):
                  # If string, open file
                  cm = open(file_or_path)
              else:
                  # Caller is responsible for closing file
                  cm = nullcontext(file_or_path)

              with cm as file:
                  # Perform processing on the file

     *note 非同期コンテキストマネージャ: 5c6. の代役として使うこともでき
     ます:

          async def send_http(session=None):
              if not session:
                  # If no http session, create it with aiohttp
                  cm = aiohttp.ClientSession()
              else:
                  # Caller is responsible for closing the session
                  cm = nullcontext(session)

              async with cm as session:
                  # Send http requests with session

     Added in version 3.7.

     バージョン 3.10 で変更: 非同期コンテキストマネージャ (*note
     asynchronous context manager: 5a1.) のサポートが追加されました。

 -- の関数: contextlib.suppress (*exceptions)

     ‘with’ 文の内部で指定された例外の発生を抑えるコンテキストマネージャ
     を返します。 ‘with’ 文の後に続く最初の文から処理が再開されます。

     ほかの完全に例外を抑制するメカニズム同様、このコンテキストマネージ
     ャは、黙ってプログラム実行を続けることが正しいことであるとわかって
     いる、非常に限定的なエラーをカバーする以上の使い方はしてはいけませ
     ん。

     例えば:

          from contextlib import suppress

          with suppress(FileNotFoundError):
              os.remove('somefile.tmp')

          with suppress(FileNotFoundError):
              os.remove('someotherfile.tmp')

     これは以下と等価です:

          try:
              os.remove('somefile.tmp')
          except FileNotFoundError:
              pass

          try:
              os.remove('someotherfile.tmp')
          except FileNotFoundError:
              pass

     このコンテキストマネージャは *note 再入可能(リエントラント): 428e.
     です。

     If the code within the ‘with’ block raises a *note
     BaseExceptionGroup: 240, suppressed exceptions are removed from the
     group.  Any exceptions of the group which are not suppressed are
     re-raised in a new group which is created using the original
     group's *note derive(): 1624. method.

     Added in version 3.4.

     バージョン 3.12 で変更: ‘suppress’ now supports suppressing
     exceptions raised as part of a *note BaseExceptionGroup: 240.

 -- の関数: contextlib.redirect_stdout (new_target)

     *note sys.stdout: aa4. を一時的に別のファイルまたは file-like オブ
     ジェクトにリダイレクトするコンテキストマネージャです。

     このツールは、出力先が標準出力 (stdout) に固定されている既存の関数
     やクラスに出力先の柔軟性を追加します。

     たとえば、 *note help(): 8a5. の出力は通常標準出力 ('sys.stdout') に
     送られます。出力される文字列を *note io.StringIO: ef3. オブジェクト
     にリダイレクトすることによって捕捉することができます。代替の出力ス
     トリームは ‘__enter__’ メソッドによって返されるので、 *note with:
     59c. 文のターゲットとして利用可能です:

          with redirect_stdout(io.StringIO()) as f:
              help(pow)
          s = f.getvalue()

     *note help(): 8a5. の出力をディスク上のファイルに送るためには、出力
     を通常のファイルにリダイレクトします:

          with open('help.txt', 'w') as f:
              with redirect_stdout(f):
                  help(pow)

     *note help(): 8a5. の出力を標準エラー出力 ('sys.stderr') に送るには
     以下のようにします:

          with redirect_stdout(sys.stderr):
              help(pow)

     *note sys.stdout: aa4. のシステム全体にわたる副作用により、このコン
     テキストマネージャはライブラリコードやマルチスレッドアプリケーショ
     ンでの使用には適していません。また、サブプロセスの出力に対しても効
     果がありません。そのような制限はありますが、それでも多くのユーティ
     リティスクリプトに対して有用なアプローチです。

     このコンテキストマネージャは *note 再入可能(リエントラント): 428e.
     です。

     Added in version 3.4.

 -- の関数: contextlib.redirect_stderr (new_target)

     *note redirect_stdout(): db5. と同じですが、標準エラー出力 (*note
     sys.stderr: 907.) を別のファイルや file-like オブジェクトにリダイレ
     クトします。

     このコンテキストマネージャは *note 再入可能(リエントラント): 428e.
     です。

     Added in version 3.5.

 -- の関数: contextlib.chdir (path)

     現在の作業ディレクトリを変更するパラレル非安全なコンテキストマネー
     ジャです。グローバルな状態である作業ディレクトリを変更するため、ほ
     とんどのマルチスレッドまたは非同期のコンテキストに対する利用は適切
     ではありません。また、プログラムの実行権限を一時的に放棄するジェネ
     レータのような、直線的でないコードを実行する場合も適切ではありませ
     ん - 明確に必要でないかぎり、このコンテキストマネージャがアクティブ
     な状態で yield すべきではありません。

     これは *note chdir(): 5d8. の単純なラッパーで、コンテキストに入ると
     きに現在の作業ディレクトリを変更し、終了時に元の作業ディレクトリを
     復元します。

     このコンテキストマネージャは *note 再入可能(リエントラント): 428e.
     です。

     Added in version 3.11.

 -- クラス: contextlib.ContextDecorator

     コンテキストマネージャをデコレータとしても使用できるようにする基底
     クラスです。

     ‘ContextDecorator’ から継承したコンテキストマネージャは、通常のコン
     テキストマネージャーと同じく ‘__enter__’ および ‘__exit__’ を実装す
     る必要があります。‘__exit__’ はデコレータとして使用された場合でも例
     外をオプションの引数として受け取ります。

     *note contextmanager(): 11d3. は ‘ContextDecorator’ を利用している
     ので、自動的にデコレーターとしても利用できるようになります。

     ‘ContextDecorator’ の例:

          from contextlib import ContextDecorator

          class mycontext(ContextDecorator):
              def __enter__(self):
                  print('Starting')
                  return self

              def __exit__(self, *exc):
                  print('Finishing')
                  return False

     このとき、クラスは次のように使うことができます:

          >>> @mycontext()
          ... def function():
          ...     print('The bit in the middle')
          ...
          >>> function()
          Starting
          The bit in the middle
          Finishing

          >>> with mycontext():
          ...     print('The bit in the middle')
          ...
          Starting
          The bit in the middle
          Finishing

     これは次のような形のコードに対するシンタックスシュガーになります:

          def f():
              with cm():
                  # Do stuff

     ‘ContextDecorator’ を使うと代わりに次のように書けます:

          @cm()
          def f():
              # Do stuff

     デコレーターを使うと、‘cm’ が関数の一部ではなく全体に適用されている
     ことが明確になります (インデントレベルを1つ節約できるのもメリットで
     す)。

     すでに基底クラスを持っているコンテキストマネージャーも、
     ‘ContextDecorator’ を mixin クラスとして利用することで拡張できます:

          from contextlib import ContextDecorator

          class mycontext(ContextBaseClass, ContextDecorator):
              def __enter__(self):
                  return self

              def __exit__(self, *exc):
                  return False

          注釈: デコレートされた関数が複数回呼び出せるように、内部のコン
          テキストマネージャーは複数の *note with: 59c. 文に対応する必要
          があります。そうでないなら、明示的な ‘with’ 文を関数内で利用す
          るべきです。

     Added in version 3.2.

 -- クラス: contextlib.AsyncContextDecorator

     *note ContextDecorator: 11d2. と同じですが、非同期関数専用のクラス
     です。

     ‘AsyncContextDecorator’ の使用例:

          from asyncio import run
          from contextlib import AsyncContextDecorator

          class mycontext(AsyncContextDecorator):
              async def __aenter__(self):
                  print('Starting')
                  return self

              async def __aexit__(self, *exc):
                  print('Finishing')
                  return False

     このとき、クラスは次のように使うことができます:

          >>> @mycontext()
          ... async def function():
          ...     print('The bit in the middle')
          ...
          >>> run(function())
          Starting
          The bit in the middle
          Finishing

          >>> async def function():
          ...    async with mycontext():
          ...         print('The bit in the middle')
          ...
          >>> run(function())
          Starting
          The bit in the middle
          Finishing

     Added in version 3.10.

 -- クラス: contextlib.ExitStack

     他の、特にオプションであったり入力に依存するようなコンテキストマネ
     ージャーやクリーンアップ関数を動的に組み合わせるためのコンテキスト
     マネージャーです。

     例えば、複数のファイルを1つの with 文で簡単に扱うことができます:

          with ExitStack() as stack:
              files = [stack.enter_context(open(fname)) for fname in filenames]
              # All opened files will automatically be closed at the end of
              # the with statement, even if attempts to open files later
              # in the list raise an exception

     The *note __enter__(): 592. method returns the *note ExitStack:
     af7. instance, and performs no additional operations.

     各インスタンスは登録されたコールバックのスタックを管理し、インスタ
     ンスが (明示的に、あるいは *note with: 59c. 文の終わりに暗黙的に)
     close されるときに逆順でそれを呼び出します。コンテキストスタックの
     インスタンスが暗黙的にガベージコレクトされたときには callback は呼
     び出され 'ません' 。

     このスタックモデルは、(file オブジェクトのように) ‘__init__’ メソッ
     ドでリソースを確保するコンテキストマネージャーを正しく扱うためのも
     のです。

     登録されたコールバックが登録の逆順で実行されるので、複数のネストさ
     れた *note with: 59c. 文を利用するのと同じ振る舞いをします。これは
     例外処理にも適用されます。内側のコールバックが例外を抑制したり置き
     換えたりした場合、外側のコールバックには更新された状態に応じた引数
     が渡されます。

     これは正しく exit callback の stack を巻き戻すための、比較的低レベ
     ルな API です。アプリケーション独自のより高レベルなコンテキストマネ
     ージャーを作るための基板として使うのに適しています。

     Added in version 3.3.

      -- メソッド: enter_context (cm)

          Enters a new context manager and adds its *note __exit__():
          12ce. method to the callback stack.  The return value is the
          result of the context manager's own *note __enter__(): 592.
          method.

          コンテキストマネージャーは、普段 *note with: 59c. 文で利用され
          た時と同じように、例外を抑制することができます。

          バージョン 3.11 で変更: 'cm' がコンテキストマネージャでなかっ
          た場合、 *note AttributeError: 326. の代わりに *note
          TypeError: 502. 例外を送出します。

      -- メソッド: push (exit)

          Adds a context manager's *note __exit__(): 12ce. method to the
          callback stack.

          As ‘__enter__’ is 'not' invoked, this method can be used to
          cover part of an *note __enter__(): 592. implementation with a
          context manager's own *note __exit__(): 12ce. method.

          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 *note __exit__(): 12ce. method and adds it directly
          to the callback stack.

          By returning true values, these callbacks can suppress
          exceptions the same way context manager *note __exit__():
          12ce. methods can.

          この関数はデコレータとしても使えるように、受け取ったオブジェク
          トをそのまま返します。

      -- メソッド: callback (callback, /, *args, **kwds)

          任意の関数と引数を受け取り、コールバックスタックに追加します。

          他のメソッドと異なり、このメソッドで追加されたコールバックは例
          外を抑制しません (例外の詳細も渡されません)。

          この関数はデコレータとしても使えるように、受け取った callback
          をそのまま返します。

      -- メソッド: pop_all ()

          コールバックスタックを新しい *note ExitStack: af7. インスタン
          スに移して、それを返します。このメソッドは callback を実行しま
          せん。代わりに、新しい stack が (明示的に、あるいは *note
          with: 59c. 文の終わりに暗黙的に) close されるときに実行されま
          す。

          例えば、複数のファイルを "all or nothing" に開く処理を次のよう
          に書けます:

               with ExitStack() as stack:
                   files = [stack.enter_context(open(fname)) for fname in filenames]
                   # Hold onto the close method, but don't call it yet.
                   close_files = stack.pop_all().close
                   # If opening any file fails, all previously opened files will be
                   # closed automatically. If all files are opened successfully,
                   # they will remain open even after the with statement ends.
                   # close_files() can then be invoked explicitly to close them all.

      -- メソッド: close ()

          すぐにコールバックスタックを巻き戻し、コールバック関数を登録の
          逆順に呼び出します。登録されたすべてのコンテキストマネージャー
          と終了 callback に、例外が起こらなかった場合の引数が渡されます
          。

 -- クラス: contextlib.AsyncExitStack

     *note ExitStack: af7. に似た *note 非同期コンテキストマネージャ:
     5c6. です。スタック上で同期と非同期の両方のコンテキストマネージャの
     組み合わせをサポートします。また、後処理のためのコルーチンも持って
     います。

     The *note close(): 4291. method is not implemented; *note aclose():
     4292. must be used instead.

      -- メソッド: coroutine enter_async_context (cm)

          Similar to *note ExitStack.enter_context(): 59d. but expects
          an asynchronous context manager.

          バージョン 3.11 で変更: 'cm' が非同期コンテキストマネージャで
          なかった場合、 *note AttributeError: 326. の代わりに *note
          TypeError: 502. 例外を送出します。

      -- メソッド: push_async_exit (exit)

          Similar to *note ExitStack.push(): 428f. but expects either an
          asynchronous context manager or a coroutine function.

      -- メソッド: push_async_callback (callback, /, *args, **kwds)

          Similar to *note ExitStack.callback(): a51. but expects a
          coroutine function.

      -- メソッド: coroutine aclose ()

          Similar to *note ExitStack.close(): 4291. but properly handles
          awaitables.

     *note asynccontextmanager(): af8. の使用例の続きです:

          async with AsyncExitStack() as stack:
              connections = [await stack.enter_async_context(get_connection())
                  for i in range(5)]
              # All opened connections will automatically be released at the end of
              # the async with statement, even if attempts to open a connection
              # later in the list raise an exception.

     Added in version 3.7.


File: python.info,  Node: 例とレシピ<3>,  Next: 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ,  Prev: ユーティリティ,  Up: contextlib --- with 文コンテキスト用ユーティリティ

5.29.8.2 例とレシピ
...................

このセクションでは、 *note contextlib: 1c. が提供するツールの効果的な使
い方を示す例とレシピを紹介します。

* Menu:

* 可変数個のコンテキストマネージャーをサポートする::
* __enter__ メソッドからの例外をキャッチする::
* __enter__ 実装内のクリーンアップ::
* try-finally + flag 変数パターンを置き換える::
* コンテキストマネージャーを関数デコレーターとして使う::


File: python.info,  Node: 可変数個のコンテキストマネージャーをサポートする,  Next: __enter__ メソッドからの例外をキャッチする,  Up: 例とレシピ<3>

5.29.8.3 可変数個のコンテキストマネージャーをサポートする
.........................................................

*note ExitStack: af7. の第一のユースケースは、クラスのドキュメントにかか
れている通り、一つの *note with: 59c. 文で可変数個のコンテキストマネージ
ャーや他のクリーンアップ関数をサポートすることです。ユーザーの入力 (指定
された複数個のファイルを開く場合など) に応じて複数個のコンテキストマネー
ジャーが必要となる場合や、いくつかのコンテキストマネージャーがオプション
となる場合に、可変数個のコンテキストマネージャーが必要になります:

     with ExitStack() as stack:
         for resource in resources:
             stack.enter_context(resource)
         if need_special_resource():
             special = acquire_special_resource()
             stack.callback(release_special_resource, special)
         # Perform operations that use the acquired resources

上の例にあるように、 *note ExitStack: af7. はコンテキストマネージャープ
ロトコルをサポートしていないリソースの管理を *note with: 59c. 文を使って
簡単に行えるようにします。


File: python.info,  Node: __enter__ メソッドからの例外をキャッチする,  Next: __enter__ 実装内のクリーンアップ,  Prev: 可変数個のコンテキストマネージャーをサポートする,  Up: 例とレシピ<3>

5.29.8.4 ‘__enter__’ メソッドからの例外をキャッチする
.....................................................

稀に、 ‘__enter__’ メソッドからの例外を、 *note with: 59c. 文の body や
コンテキストマネージャーの ‘__exit__’ メソッドからの例外は間違えて捕まえ
ないように、 catch したい場合があります。 *note ExitStack: af7. を使って
、コンテキストマネージャープロトコル内のステップを分離することができます
:

     stack = ExitStack()
     try:
         x = stack.enter_context(cm)
     except Exception:
         # handle __enter__ exception
     else:
         with stack:
             # Handle normal case

実際のところ、このようなコードが必要になるのならば、利用している API 側
で *note try: 6b4./*note except: 170./*note finally: 997. 文を使った直接
的なリソース管理インターフェースを提供するべきです。しかし、すべての API
がそのようによく設計されているとは限りません。もしコンテキストマネージャ
ーが提供されている唯一のリソース管理APIであるなら、 *note ExitStack:
af7. を使って *note with: 59c. 文を使って処理することができない様々なシ
チュエーションの処理をすることができます。


File: python.info,  Node: __enter__ 実装内のクリーンアップ,  Next: try-finally + flag 変数パターンを置き換える,  Prev: __enter__ メソッドからの例外をキャッチする,  Up: 例とレシピ<3>

5.29.8.5 ‘__enter__’ 実装内のクリーンアップ
...........................................

As noted in the documentation of *note ExitStack.push(): 428f, this
method can be useful in cleaning up an already allocated resource if
later steps in the *note __enter__(): 592. implementation fail.

次の例では、リソースの確保と開放の関数に加えて、オプションのバリデーショ
ン関数を受け取るコンテキストマネージャーで、この方法を使ってコンテキスト
マネージャープロトコルを提供しています:

     from contextlib import contextmanager, AbstractContextManager, ExitStack

     class ResourceManager(AbstractContextManager):

         def __init__(self, acquire_resource, release_resource, check_resource_ok=None):
             self.acquire_resource = acquire_resource
             self.release_resource = release_resource
             if check_resource_ok is None:
                 def check_resource_ok(resource):
                     return True
             self.check_resource_ok = check_resource_ok

         @contextmanager
         def _cleanup_on_error(self):
             with ExitStack() as stack:
                 stack.push(self)
                 yield
                 # The validation check passed and didn't raise an exception
                 # Accordingly, we want to keep the resource, and pass it
                 # back to our caller
                 stack.pop_all()

         def __enter__(self):
             resource = self.acquire_resource()
             with self._cleanup_on_error():
                 if not self.check_resource_ok(resource):
                     msg = "Failed validation for {!r}"
                     raise RuntimeError(msg.format(resource))
             return resource

         def __exit__(self, *exc_details):
             # We don't need to duplicate any of our resource release logic
             self.release_resource()


File: python.info,  Node: try-finally + flag 変数パターンを置き換える,  Next: コンテキストマネージャーを関数デコレーターとして使う,  Prev: __enter__ 実装内のクリーンアップ,  Up: 例とレシピ<3>

5.29.8.6 ‘try-finally’ + flag 変数パターンを置き換える
......................................................

‘try-finally’ 文に、‘finally’ 句の内容を実行するかどうかを示すフラグ変数
を組み合わせたパターンを目にすることがあるかもしれません。一番シンプルな
(単に ‘except’ 句を使うだけでは処理できない) ケースでは次のようなコード
になります:

     cleanup_needed = True
     try:
         result = perform_operation()
         if result:
             cleanup_needed = False
     finally:
         if cleanup_needed:
             cleanup_resources()

‘try’ 文を使ったコードでは、セットアップとクリーンアップのコードが任意の
長さのコードで分離してしまうので、開発者やレビューアにとって問題になりえ
ます。

*note ExitStack: af7. を使えば、代わりに ‘with’ 文の終わりに実行されるコ
ールバックを登録し、後でそのコールバックをスキップするかどうかを決定でき
ます:

     from contextlib import ExitStack

     with ExitStack() as stack:
         stack.callback(cleanup_resources)
         result = perform_operation()
         if result:
             stack.pop_all()

This allows the intended cleanup behaviour to be made explicit up front,
rather than requiring a separate flag variable.

もしあるアプリケーションがこのパターンを多用するのであれば、小さいヘルパ
ークラスを導入してよりシンプルにすることができます:

     from contextlib import ExitStack

     class Callback(ExitStack):
         def __init__(self, callback, /, *args, **kwds):
             super().__init__()
             self.callback(callback, *args, **kwds)

         def cancel(self):
             self.pop_all()

     with Callback(cleanup_resources) as cb:
         result = perform_operation()
         if result:
             cb.cancel()

もしリソースのクリーンアップが単体の関数にまとまってない場合でも、 *note
ExitStack.callback(): a51. のデコレーター形式を利用してリソース開放処理
を宣言することができます:

     from contextlib import ExitStack

     with ExitStack() as stack:
         @stack.callback
         def cleanup_resources():
             ...
         result = perform_operation()
         if result:
             stack.pop_all()

デコレータープロトコルの使用上、このように宣言されたコールバック関数は引
数を取ることができません。その代わりに、リリースするリソースをクロージャ
ー変数としてアクセスできる必要があります。


File: python.info,  Node: コンテキストマネージャーを関数デコレーターとして使う,  Prev: try-finally + flag 変数パターンを置き換える,  Up: 例とレシピ<3>

5.29.8.7 コンテキストマネージャーを関数デコレーターとして使う
.............................................................

*note ContextDecorator: 11d2. はコンテキストマネージャーを通常の ‘with’
文に加えて関数デコレーターとしても利用できるようにします。

例えば、関数やまとまった文を、そこに入った時と出た時の時間をトラックする
ロガーでラップしたい場合があります。そのために関数デコレーターとコンテキ
ストマネージャーを別々に書く代わりに、 *note ContextDecorator: 11d2. を
継承すると1つの定義で両方の機能を提供できます:

     from contextlib import ContextDecorator
     import logging

     logging.basicConfig(level=logging.INFO)

     class track_entry_and_exit(ContextDecorator):
         def __init__(self, name):
             self.name = name

         def __enter__(self):
             logging.info('Entering: %s', self.name)

         def __exit__(self, exc_type, exc, exc_tb):
             logging.info('Exiting: %s', self.name)

このクラスのインスタンスはコンテキストマネージャーとしても利用でき:

     with track_entry_and_exit('widget loader'):
         print('Some time consuming activity goes here')
         load_widget()

また関数デコレーターとしても利用できます:

     @track_entry_and_exit('widget loader')
     def activity():
         print('Some time consuming activity goes here')
         load_widget()

Note that there is one additional limitation when using context managers
as function decorators: there's no way to access the return value of
*note __enter__(): 592.  If that value is needed, then it is still
necessary to use an explicit ‘with’ statement.

参考
....

PEP 343(1) - "with" ステートメント

     Python の *note with: 59c. 文の仕様、背景、および例が記載されていま
     す。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0343/


File: python.info,  Node: 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ,  Prev: 例とレシピ<3>,  Up: contextlib --- with 文コンテキスト用ユーティリティ

5.29.8.8 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ
...........................................................................

ほとんどのコンテキストマネージャは、 *note with: 59c. 文の中で一度だけ使
われるような場合に効果的になるように書かれています。これら単回使用のコン
テキストマネージャは毎回新規に生成されなければなりません - それらを再利
用しようとすると、例外を引き起こすか、正しく動作しません。

この共通の制限が意味することは、コンテキストマネージャは (上記すべての使
用例に示すとおり) 一般に *note with: 59c. 文のヘッダ部分で直接生成するこ
とが推奨されるということです。

ファイルオブジェクトは単回使用のコンテキストマネージャ有効に利用した例で
す。最初の *note with: 59c. 文によりファイルがクローズされ、それ以降その
ファイルオブジェクトに対するすべての IO 操作を防止します。

*note contextmanager(): 11d3. により生成されたコンテキストマネージャも単
回使用のコンテキスト マネージャです。二回目に使おうとした場合、内部にあ
るジェネレータが値の生成に失敗したと訴えるでしょう:

     >>> from contextlib import contextmanager
     >>> @contextmanager
     ... def singleuse():
     ...     print("Before")
     ...     yield
     ...     print("After")
     ...
     >>> cm = singleuse()
     >>> with cm:
     ...     pass
     ...
     Before
     After
     >>> with cm:
     ...     pass
     ...
     Traceback (most recent call last):
         ...
     RuntimeError: generator didn't yield

* Menu:

* リエントラントなコンテキストマネージャ::
* 再利用可能なコンテキストマネージャ::


File: python.info,  Node: リエントラントなコンテキストマネージャ,  Next: 再利用可能なコンテキストマネージャ,  Up: 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ

5.29.8.9 リエントラントなコンテキストマネージャ
...............................................

より洗練されたコンテキストマネージャには"リエントラント"なものがあります
。そのようなコンテキストマネージャは、複数の *note with: 59c. 文で使える
だけでなく、同じコンテキストマネージャをすでに使っている ‘with’ 文の '内
部' でも使うことができます。

*note threading.RLock: 2bf. はリエントラントなコンテキストマネージャの例
であり、また *note suppress(): ef2, *note redirect_stdout(): db5, そして
*note chdir(): 5d7. もリエントラントです。以下はリエントラントな利用法の
非常に単純な例です:

     >>> from contextlib import redirect_stdout
     >>> from io import StringIO
     >>> stream = StringIO()
     >>> write_to_stream = redirect_stdout(stream)
     >>> with write_to_stream:
     ...     print("This is written to the stream rather than stdout")
     ...     with write_to_stream:
     ...         print("This is also written to the stream")
     ...
     >>> print("This is written directly to stdout")
     This is written directly to stdout
     >>> print(stream.getvalue())
     This is written to the stream rather than stdout
     This is also written to the stream

リエントラントな性質の実例はお互いを呼び出しあう複数の関数を含んでいる可
能性が高く、したがってこの例よりもはるかに複雑です。

リエントラントであることはスレッドセーフであることと同じ 'ではない' こと
には注意が必要です。たとえば *note redirect_stdout(): db5. は、 *note
sys.stdout: aa4. を異なるストリームに束縛することによりシステムの状態に
対してグローバルな変更を行うことから、明らかにスレッドセーフではありませ
ん。


File: python.info,  Node: 再利用可能なコンテキストマネージャ,  Prev: リエントラントなコンテキストマネージャ,  Up: 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ

5.29.8.10 再利用可能なコンテキストマネージャ
............................................

単回使用のコンテキストマネージャとリエントラントなコンテキストマネージャ
のいずれとも異なるタイプに "再利用可能" なコンテキストマネージャがありま
す (あるいは、より明確には、"再利用可能だがリエントラントでない" コンテ
キストマネージャです。リエントラントなコンテキストマネージャもまた再利用
可能だからです)。再利用可能なコンテキストマネージャは複数回利用をサポー
トしますが、同じコンテキストマネージャのインスタンスがすでに with 文で使
われている場合には失敗します (もしくは正しく動作しません)。

*note threading.Lock: 15db. は再利用可能だがリエントラントでないコンテキ
ストマネージャの例です (リエントラントなロックのためには *note
threading.RLock: 2bf. を代わりに使う必要があります)。

再利用可能だがリエントラントでないコンテキストマネージャのもうひとつの例
は *note ExitStack: af7. です。これは現在登録されている '全ての' コール
バック関数を、どこで登録されたかにかかわらず、呼び出します:

     >>> from contextlib import ExitStack
     >>> stack = ExitStack()
     >>> with stack:
     ...     stack.callback(print, "Callback: from first context")
     ...     print("Leaving first context")
     ...
     Leaving first context
     Callback: from first context
     >>> with stack:
     ...     stack.callback(print, "Callback: from second context")
     ...     print("Leaving second context")
     ...
     Leaving second context
     Callback: from second context
     >>> with stack:
     ...     stack.callback(print, "Callback: from outer context")
     ...     with stack:
     ...         stack.callback(print, "Callback: from inner context")
     ...         print("Leaving inner context")
     ...     print("Leaving outer context")
     ...
     Leaving inner context
     Callback: from inner context
     Callback: from outer context
     Leaving outer context

例における出力が示すように、ひとつのスタックオブジェクトを複数の with 文
で再利用しても正しく動作します。しかし入れ子にして使った場合は、一番内側
の with 文を抜ける際にスタックが空になります。これは望ましい動作とは思え
ません。

ひとつの *note ExitStack: af7. インスタンスを再利用する代わりに複数のイ
ンスタンスを使うことにより、この問題は回避することができます:

     >>> from contextlib import ExitStack
     >>> with ExitStack() as outer_stack:
     ...     outer_stack.callback(print, "Callback: from outer context")
     ...     with ExitStack() as inner_stack:
     ...         inner_stack.callback(print, "Callback: from inner context")
     ...         print("Leaving inner context")
     ...     print("Leaving outer context")
     ...
     Leaving inner context
     Callback: from inner context
     Leaving outer context
     Callback: from outer context


File: python.info,  Node: abc --- 抽象基底クラス,  Next: atexit --- 終了ハンドラー,  Prev: contextlib --- with 文コンテキスト用ユーティリティ,  Up: Python ランタイムサービス

5.29.9 ‘abc’ -- 抽象基底クラス
------------------------------

'ソースコード:' Lib/abc.py(1)

__________________________________________________________________

このモジュールは Python に PEP 3119(2) で概要が示された *note
抽象基底クラス: 1186. (ABC) を定義する基盤を提供します。なぜこれが
Python に付け加えられたかについてはその PEP を参照してください。 (ABC に
基づいた数の型階層を扱った PEP 3141(3) と *note numbers: 8e. モジュール
も参照してください。)

The *note collections: 16. module has some concrete classes that derive
from ABCs; these can, of course, be further derived.  In addition, the
*note collections.abc: 17. submodule has some ABCs that can be used to
test whether a class or instance provides a particular interface, for
example, if it is *note hashable: 5db. or if it is a *note mapping:
118c.

このモジュールは、 抽象基底クラスを定義するためのメタクラス *note
ABCMeta: ee4. と、 継承を利用して抽象基底クラスを代替的に定義するヘルパ
ークラス *note ABC: ee3. を提供します。

 -- クラス: abc.ABC

     A helper class that has *note ABCMeta: ee4. as its metaclass.  With
     this class, an abstract base class can be created by simply
     deriving from ‘ABC’ avoiding sometimes confusing metaclass usage,
     for example:

          from abc import ABC

          class MyABC(ABC):
              pass

     Note that the type of ‘ABC’ is still *note ABCMeta: ee4, therefore
     inheriting from ‘ABC’ requires the usual precautions regarding
     metaclass usage, as multiple inheritance may lead to metaclass
     conflicts.  One may also define an abstract base class by passing
     the metaclass keyword and using ‘ABCMeta’ directly, for example:

          from abc import ABCMeta

          class MyABC(metaclass=ABCMeta):
              pass

     Added in version 3.4.

 -- クラス: abc.ABCMeta

     抽象基底クラス(ABC)を定義するためのメタクラス。

     ABC を作るときにこのメタクラスを使います。ABC は直接的にサブクラス
     化することができ、ミックスイン(mix-in)クラスのように振る舞います。
     また、無関係な具象クラス(組み込み型でも構いません)と無関係な ABC を
     "仮想的サブクラス" として登録できます - これらとその子孫は組み込み
     関数 *note issubclass(): 78c. によって登録した ABC のサブクラスと判
     定されますが、登録した ABC は MRO (Method Resolution Order, メソッ
     ド解決順)には現れませんし、この ABC のメソッド実装が(*note super():
     4a8. を通してだけでなく)呼び出し可能になるわけでもありません。 (4)

     Classes created with a metaclass of ‘ABCMeta’ have the following
     method:

      -- メソッド: register (subclass)

          'subclass' を "仮想的サブクラス" としてこの ABC に登録します。
          たとえば:

               from abc import ABC

               class MyABC(ABC):
                   pass

               MyABC.register(tuple)

               assert issubclass(tuple, MyABC)
               assert isinstance((), MyABC)

          バージョン 3.3 で変更: クラスデコレータとして使うことができる
          ように、登録されたサブクラスを返します。

          バージョン 3.4 で変更: To detect calls to ‘register()’, you
          can use the *note get_cache_token(): ee2. function.

     また、次のメソッドを抽象基底クラスの中でオーバーライドできます:

      -- メソッド: __subclasshook__ (subclass)

          (クラスメソッドとして定義しなければなりません。)

          Check whether 'subclass' is considered a subclass of this ABC.
          This means that you can customize the behavior of *note
          issubclass(): 78c. further without the need to call *note
          register(): 105e. on every class you want to consider a
          subclass of the ABC. (This class method is called from the
          *note __subclasscheck__(): 1ede. method of the ABC.)

          This method should return ‘True’, ‘False’ or *note
          NotImplemented: 79d.  If it returns ‘True’, the 'subclass' is
          considered a subclass of this ABC. If it returns ‘False’, the
          'subclass' is not considered a subclass of this ABC, even if
          it would normally be one.  If it returns ‘NotImplemented’, the
          subclass check is continued with the usual mechanism.

     この概念のデモとして、次の ABC 定義の例を見てください:

          class Foo:
              def __getitem__(self, index):
                  ...
              def __len__(self):
                  ...
              def get_iterator(self):
                  return iter(self)

          class MyIterable(ABC):

              @abstractmethod
              def __iter__(self):
                  while False:
                      yield None

              def get_iterator(self):
                  return self.__iter__()

              @classmethod
              def __subclasshook__(cls, C):
                  if cls is MyIterable:
                      if any("__iter__" in B.__dict__ for B in C.__mro__):
                          return True
                  return NotImplemented

          MyIterable.register(Foo)

     The ABC ‘MyIterable’ defines the standard iterable method, *note
     __iter__(): 1c2e, as an abstract method.  The implementation given
     here can still be called from subclasses.  The ‘get_iterator()’
     method is also part of the ‘MyIterable’ abstract base class, but it
     does not have to be overridden in non-abstract derived classes.

     The *note __subclasshook__(): 247e. class method defined here says
     that any class that has an *note __iter__(): 1c2e. method in its
     *note __dict__: 526. (or in that of one of its base classes,
     accessed via the *note __mro__: 1e89. list) is considered a
     ‘MyIterable’ too.

     Finally, the last line makes ‘Foo’ a virtual subclass of
     ‘MyIterable’, even though it does not define an *note __iter__():
     1c2e. method (it uses the old-style iterable protocol, defined in
     terms of *note __len__(): 1ec3. and *note __getitem__(): 264.).
     Note that this will not make ‘get_iterator’ available as a method
     of ‘Foo’, so it is provided separately.

The ‘abc’ module also provides the following decorator:

 -- の関数: @abc.abstractmethod

     抽象メソッドを示すデコレータです。

     Using this decorator requires that the class's metaclass is *note
     ABCMeta: ee4. or is derived from it.  A class that has a metaclass
     derived from ‘ABCMeta’ cannot be instantiated unless all of its
     abstract methods and properties are overridden.  The abstract
     methods can be called using any of the normal 'super' call
     mechanisms.  ‘abstractmethod()’ may be used to declare abstract
     methods for properties and descriptors.

     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 supported using the *note
     update_abstractmethods(): 42a0. function.  The ‘abstractmethod()’
     only affects subclasses derived using regular inheritance; "virtual
     subclasses" registered with the ABC's *note register(): 105e.
     method are not affected.

     When ‘abstractmethod()’ is applied in combination with other method
     descriptors, it should be applied as the innermost decorator, as
     shown in the following usage examples:

          class C(ABC):
              @abstractmethod
              def my_abstract_method(self, arg1):
                  ...
              @classmethod
              @abstractmethod
              def my_abstract_classmethod(cls, arg2):
                  ...
              @staticmethod
              @abstractmethod
              def my_abstract_staticmethod(arg3):
                  ...

              @property
              @abstractmethod
              def my_abstract_property(self):
                  ...
              @my_abstract_property.setter
              @abstractmethod
              def my_abstract_property(self, val):
                  ...

              @abstractmethod
              def _get_x(self):
                  ...
              @abstractmethod
              def _set_x(self, val):
                  ...
              x = property(_get_x, _set_x)

     In order to correctly interoperate with the abstract base class
     machinery, the descriptor must identify itself as abstract using
     ‘__isabstractmethod__’.  In general, this attribute should be
     ‘True’ if any of the methods used to compose the descriptor are
     abstract.  For example, Python's built-in *note property: 179. does
     the equivalent of:

          class Descriptor:
              ...
              @property
              def __isabstractmethod__(self):
                  return any(getattr(f, '__isabstractmethod__', False) for
                             f in (self._fget, self._fset, self._fdel))

          注釈: Java の抽象メソッドと違い、これらの抽象メソッドは実装を
          持ち得ます。この実装は *note super(): 4a8. メカニズムを通して
          それをオーバーライドしたクラスから呼び出すことができます。これ
          は協調的多重継承を使ったフレームワークにおいて super 呼び出し
          の終点として有効です。

The ‘abc’ module also supports the following legacy decorators:

 -- の関数: @abc.abstractclassmethod

     Added in version 3.2.

     バージョン 3.3 で非推奨: *note classmethod: 14c. を *note
     abstractmethod(): 105b. と一緒に使えるようになったため、このデコレ
     ータは冗長になりました。

     組み込みの *note classmethod(): 14c. のサブクラスで、抽象クラスメソ
     ッドであることを示します。それ以外は *note abstractmethod(): 105b.
     と同じです。

     この特殊ケースは *note classmethod(): 14c. デコレータが抽象メソッド
     に適用された場合に抽象的だと正しく認識されるようになったため撤廃さ
     れます:

          class C(ABC):
              @classmethod
              @abstractmethod
              def my_abstract_classmethod(cls, arg):
                  ...

 -- の関数: @abc.abstractstaticmethod

     Added in version 3.2.

     バージョン 3.3 で非推奨: *note staticmethod: 3ef. を *note
     abstractmethod(): 105b. と一緒に使えるようになったため、このデコレ
     ータは冗長になりました。

     組み込みの *note staticmethod(): 3ef. のサブクラスで、抽象静的メソ
     ッドであることを示します。それ以外は *note abstractmethod(): 105b.
     と同じです。

     この特殊ケースは *note staticmethod(): 3ef. デコレータが抽象メソッ
     ドに適用された場合に抽象的だと正しく認識されるようになったため撤廃
     されます:

          class C(ABC):
              @staticmethod
              @abstractmethod
              def my_abstract_staticmethod(arg):
                  ...

 -- の関数: @abc.abstractproperty

     バージョン 3.3 で非推奨: *note property: 179. 、 *note
     property.getter(): 15be. 、 *note property.setter(): 15bf. および
     *note property.deleter(): 15c0. を *note abstractmethod(): 105b. と
     一緒に使えるようになったため、このデコレータは冗長になりました。

     組み込みの *note property(): 179. のサブクラスで、抽象プロパティで
     あることを示します。

     この特殊ケースは *note property(): 179. デコレータが抽象メソッドに
     適用された場合に抽象的だと正しく認識されるようになったため撤廃され
     ます:

          class C(ABC):
              @property
              @abstractmethod
              def my_abstract_property(self):
                  ...

     この例は読み出し専用のプロパティを定義しています。プロパティを構成
     するメソッドの1つ以上を abstract にすることで、読み書きできる抽象プ
     ロパティを定義することができます:

          class C(ABC):
              @property
              def x(self):
                  ...

              @x.setter
              @abstractmethod
              def x(self, val):
                  ...

     構成するメソッド全てが abstract でない場合、abstract と定義されたメ
     ソッドのみが、具象サブクラスによってオーバーライドする必要がありま
     す:

          class D(C):
              @C.x.setter
              def x(self, val):
                  ...

The ‘abc’ module also provides the following functions:

 -- の関数: abc.get_cache_token ()

     現在の抽象基底クラスのキャッシュトークンを返します。

     このトークンは、仮想サブクラスのための抽象基底クラスの現在のバージ
     ョンを特定する (等価性検査をサポートしている) 不透明なオブジェクト
     です。 任意のABCでの *note ABCMeta.register(): 105e. の呼び出しごと
     に、トークンは変更されます。

     Added in version 3.4.

 -- の関数: abc.update_abstractmethods (cls)

     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.

     Returns 'cls', to allow usage as a class decorator.

     If 'cls' is not an instance of *note ABCMeta: ee4, does nothing.

          注釈: This function assumes that 'cls"s superclasses are
          already updated.  It does not update any subclasses.

     Added in version 3.10.

脚注
....

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/abc.py

   (2) https://peps.python.org/pep-3119/

   (3) https://peps.python.org/pep-3141/

   (4) C++ プログラマは Python の仮想的基底クラスの概念は C++ のものと同
じではないということを銘記すべきです。


File: python.info,  Node: atexit --- 終了ハンドラー,  Next: traceback --- スタックトレースの表示または取得,  Prev: abc --- 抽象基底クラス,  Up: Python ランタイムサービス

5.29.10 ‘atexit’ -- 終了ハンドラー
----------------------------------

__________________________________________________________________

*note atexit: 9. モジュールは、クリーンアップ関数の登録およびその解除を
行う関数を定義します。登録された関数はインタプリタの通常終了時に自動的に
実行されます。*note atexit: 9. はそれら関数を登録した順と '逆に' 実行し
ます; ‘A’、‘B’、‘C’ の順に登録した場合、インタプリタ終了時に ‘C’、‘B’、
‘A’ の順に実行されます。

'注意:' このモジュールを使用して登録された関数は、プログラムが Python が
扱わないシグナルによって kill された場合、Python 内部で致命的なエラーが
検出された場合、あるいは *note os._exit(): 21f4. が呼び出された場合は実
行されません。

'注意:' クリーンアップ関数内からの関数の登録・登録解除効果は定義されてい
ません。

バージョン 3.7 で変更: C-API のサブインタープリタで使われているとき、登
録された関数は登録先のインタープリタのローカルな関数になります。

 -- の関数: atexit.register (func, *args, **kwargs)

     'func' を終了時に実行する関数として登録します。'func' に渡す引数は
     *note register(): 84a. の引数として指定しなければなりません。同じ関
     数を同じ引数で複数回登録できます。

     通常のプログラムの終了時、例えば *note sys.exit(): 1318. が呼び出さ
     れるとき、あるいは、メインモジュールの実行が完了したときに、登録さ
     れた全ての関数を、最後に登録されたものから順に呼び出します。通常、
     より低レベルのモジュールはより高レベルのモジュールより前に import さ
     れるので、後で後始末が行われるという仮定に基づいています。

     終了ハンドラの実行中に例外が発生すると、(*note SystemExit: d0e. 以
     外の場合は)トレースバックを表示して、例外の情報を保存します。全ての
     終了ハンドラに動作するチャンスを与えた後に、最後に送出された例外を
     再送出します。

     この関数は 'func' を返し、これをデコレータとして利用できます。

          警告: 登録された関数から新しいスレッドを開始したり、 *note
          os.fork(): 17c. を呼び出したりすると、メインの Python ランタイ
          ムスレッドがスレッド状態を開放する一方で、内部の *note
          threading: d6. ルーチンや新しいプロセスがそのスレッド状態を使
          用しようと試みる競合が発生します。これはクリーンなシャットダウ
          ンではなく、クラッシュにつながる恐れがあります。

     バージョン 3.12 で変更: 登録された関数から新しいスレッドの開始また
     は新しいプロセスの *note os.fork(): 17c. が試みられた場合は、 *note
     RuntimeError: 17a. が発生するようになりました。

 -- の関数: atexit.unregister (func)

     関数 'func' をインタプリタ終了時に実行する関数のリストから削除しま
     す。'func' が登録されていなければ、*note unregister(): 42a3. は何も
     しません。'func' が2回以上登録されている場合は *note atexit: 9. の
     コールスタックにおける 'func' のすべての出現が削除されます。削除の
     際の比較には等価比較 (‘==’) が使われます。したがって削除したいもの
     と同一の関数を 'func' に指定する必要はありません。

参考
....

*note readline: a8. モジュール

     *note readline: a8. ヒストリファイルを読み書きするための *note
     atexit: 9. の有用な例です。

* Menu:

* atexit の例::


File: python.info,  Node: atexit の例,  Up: atexit --- 終了ハンドラー

5.29.10.1 ‘atexit’ の例
.......................

次の簡単な例では、あるモジュールを import した時にカウンタを初期化してお
き、プログラムが終了するときにアプリケーションがこのモジュールを明示的に
呼び出さなくてもカウンタが更新されるようにする方法を示しています。

     try:
         with open('counterfile') as infile:
             _count = int(infile.read())
     except FileNotFoundError:
         _count = 0

     def incrcounter(n):
         global _count
         _count = _count + n

     def savecounter():
         with open('counterfile', 'w') as outfile:
             outfile.write('%d' % _count)

     import atexit

     atexit.register(savecounter)

*note register(): 84a. に指定した位置引数とキーワード引数は登録した関数
を呼び出す際に渡されます:

     def goodbye(name, adjective):
         print('Goodbye %s, it was %s to meet you.' % (name, adjective))

     import atexit

     atexit.register(goodbye, 'Donny', 'nice')
     # or:
     atexit.register(goodbye, adjective='nice', name='Donny')

*note デコレータ: 6fc. として利用する例:

     import atexit

     @atexit.register
     def goodbye():
         print('You are now leaving the Python sector.')

デコレータとして利用できるのは、その関数が引数なしで呼び出された場合に限
られます。


File: python.info,  Node: traceback --- スタックトレースの表示または取得,  Next: __future__ --- future 文の定義,  Prev: atexit --- 終了ハンドラー,  Up: Python ランタイムサービス

5.29.11 ‘traceback’ -- スタックトレースの表示または取得
-------------------------------------------------------

'ソースコード:' Lib/traceback.py(1)

__________________________________________________________________

This module provides a standard interface to extract, format and print
stack traces of Python programs.  It is more flexible than the
interpreter's default traceback display, and therefore makes it possible
to configure certain aspects of the output.  Finally, it contains a
utility for capturing enough information about an exception to print it
later, without the need to save a reference to the actual exception.
Since exceptions can be the roots of large objects graph, this utility
can significantly improve memory management.

The module uses *note traceback objects: ac2. -- these are objects of
type *note types.TracebackType: ac0, which are assigned to the *note
__traceback__: 1296. field of *note BaseException: 584. instances.

参考
....

*note faulthandler: 4e. モジュール

     Used to dump Python tracebacks explicitly, on a fault, after a
     timeout, or on a user signal.

Module *note pdb: 94.

     Interactive source code debugger for Python programs.

The module's API can be divided into two parts:

   * Module-level functions offering basic functionality, which are
     useful for interactive inspection of exceptions and tracebacks.

   * *note TracebackException: 23d. class and its helper classes *note
     StackSummary: e4e. and *note FrameSummary: e4f.  These offer both
     more flexibility in the output generated and the ability to store
     the information necessary for later formatting without holding
     references to actual exception and traceback objects.

* Menu:

* モジュールレベルの関数: モジュールレベルの関数<2>.
* TracebackException オブジェクト::
* StackSummary オブジェクト::
* FrameSummary オブジェクト::
* Examples of Using the Module-Level Functions::
* Examples of Using TracebackException::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/traceback.py


File: python.info,  Node: モジュールレベルの関数<2>,  Next: TracebackException オブジェクト,  Up: traceback --- スタックトレースの表示または取得

5.29.11.1 モジュールレベルの関数
................................

 -- の関数: traceback.print_tb (tb, limit=None, file=None)

     Print up to 'limit' stack trace entries from *note traceback
     object: ac2. 'tb' (starting from the caller's frame) if 'limit' is
     positive.  Otherwise, print the last ‘abs(limit)’ entries.  If
     'limit' is omitted or ‘None’, all entries are printed.  If 'file'
     is omitted or ‘None’, the output goes to *note sys.stderr: 907.;
     otherwise it should be an open *note file: 1193. or *note file-like
     object: 24e0. to receive the output.

          注釈: The meaning of the 'limit' parameter is different than
          the meaning of *note sys.tracebacklimit: 153d.  A negative
          'limit' value corresponds to a positive value of
          ‘sys.tracebacklimit’, whereas the behaviour of a positive
          'limit' value cannot be achieved with ‘sys.tracebacklimit’.

     バージョン 3.5 で変更: 負の 'limit' がサポートされました。

 -- の関数: traceback.print_exception (exc, /[, value, tb], limit=None,
          file=None, chain=True)

     Print exception information and stack trace entries from *note
     traceback object: ac2. 'tb' to 'file'.  This differs from *note
     print_tb(): e50. in the following ways:

        * 'tb' が ‘None’ でない場合ヘッダ ‘Traceback (most recent call
          last):’ を出力します

        * it prints the exception type and 'value' after the stack trace

        * 'type(value)' が *note SyntaxError: 172. であり、 'value' が適
          切な形式を持っていれば、そのエラーのおおよその位置を示すマーク
          と共にシンタックスエラーが発生した行が表示されます。

     Since Python 3.10, instead of passing 'value' and 'tb', an
     exception object can be passed as the first argument.  If 'value'
     and 'tb' are provided, the first argument is ignored in order to
     provide backwards compatibility.

     The optional 'limit' argument has the same meaning as for *note
     print_tb(): e50.  If 'chain' is true (the default), then chained
     exceptions (the *note __cause__: 1298. or *note __context__: 1297.
     attributes of the exception) will be printed as well, like the
     interpreter itself does when printing an unhandled exception.

     バージョン 3.5 で変更: 引数 'etype' は無視され、 'value' の型から推
     論されます。

     バージョン 3.10 で変更: The 'etype' parameter has been renamed to
     'exc' and is now positional-only.

 -- の関数: traceback.print_exc (limit=None, file=None, chain=True)

     ‘print_exception(sys.exception(), limit, file, chain)’ の省略表現で
     す。

 -- の関数: traceback.print_last (limit=None, file=None, chain=True)

     This is a shorthand for ‘print_exception(sys.last_exc, limit, file,
     chain)’.  In general it will work only after an exception has
     reached an interactive prompt (see *note sys.last_exc: 48a.).

 -- の関数: traceback.print_stack (f=None, limit=None, file=None)

     Print up to 'limit' stack trace entries (starting from the
     invocation point) if 'limit' is positive.  Otherwise, print the
     last ‘abs(limit)’ entries.  If 'limit' is omitted or ‘None’, all
     entries are printed.  The optional 'f' argument can be used to
     specify an alternate *note stack frame: 6ab. to start.  The
     optional 'file' argument has the same meaning as for *note
     print_tb(): e50.

     バージョン 3.5 で変更: 負の 'limit' がサポートされました。

 -- の関数: traceback.extract_tb (tb, limit=None)

     Return a *note StackSummary: e4e. object representing a list of
     "pre-processed" stack trace entries extracted from the *note
     traceback object: ac2. 'tb'.  It is useful for alternate formatting
     of stack traces.  The optional 'limit' argument has the same
     meaning as for *note print_tb(): e50.  A "pre-processed" stack
     trace entry is a *note FrameSummary: e4f. object containing
     attributes *note filename: 42ab, *note lineno: 42ac, *note name:
     42ad, and *note line: 42ae. representing the information that is
     usually printed for a stack trace.

 -- の関数: traceback.extract_stack (f=None, limit=None)

     Extract the raw traceback from the current *note stack frame: 6ab.
     The return value has the same format as for *note extract_tb():
     42aa.  The optional 'f' and 'limit' arguments have the same meaning
     as for *note print_stack(): e51.

 -- の関数: traceback.format_list (extracted_list)

     *note extract_tb(): 42aa. または *note extract_stack(): 42af. が返
     すタプルのリストまたは *note FrameSummary: e4f. オブジェクトが与え
     られると、出力の準備を整えた文字列のリストを返します。結果として生
     じるリストの中の各文字列は、引数リストの中の同じインデックスの要素
     に対応します。各文字列は末尾に改行が付いています。さらに、ソーステ
     キスト行が ‘None’ でないそれらの要素に対しては、文字列は内部に改行
     を含んでいるかもしれません。

 -- の関数: traceback.format_exception_only (exc, /[, value], *,
          show_group=False)

     Format the exception part of a traceback using an exception value
     such as given by *note sys.last_value: 48c.  The return value is a
     list of strings, each ending in a newline.  The list contains the
     exception's message, which is normally a single string; however,
     for *note SyntaxError: 172. exceptions, it contains several lines
     that (when printed) display detailed information about where the
     syntax error occurred.  Following the message, the list contains
     the exception's *note notes: 21e1.

     Since Python 3.10, instead of passing 'value', an exception object
     can be passed as the first argument.  If 'value' is provided, the
     first argument is ignored in order to provide backwards
     compatibility.

     When 'show_group' is ‘True’, and the exception is an instance of
     *note BaseExceptionGroup: 240, the nested exceptions are included
     as well, recursively, with indentation relative to their nesting
     depth.

     バージョン 3.10 で変更: The 'etype' parameter has been renamed to
     'exc' and is now positional-only.

     バージョン 3.11 で変更: The returned list now includes any *note
     notes: 21e1. attached to the exception.

     バージョン 3.13 で変更: 'show_group' parameter was added.

 -- の関数: traceback.format_exception (exc, /[, value, tb], limit=None,
          chain=True)

     スタックトレースと例外情報を書式化します。引数は *note
     print_exception(): 81a. の対応する引数と同じ意味を持ちます。戻り値
     は文字列のリストで、それぞれの文字列は改行で終わり、そのいくつかは
     内部に改行を含みます。これらの行が連結されて出力される場合は、厳密
     に *note print_exception(): 81a. と同じテキストが出力されます。

     バージョン 3.5 で変更: 引数 'etype' は無視され、 'value' の型から推
     論されます。

     バージョン 3.10 で変更: This function's behavior and signature were
     modified to match *note print_exception(): 81a.

 -- の関数: traceback.format_exc (limit=None, chain=True)

     これは、‘print_exc(limit)’ に似ていますが、ファイルに出力する代わり
     に文字列を返します。

 -- の関数: traceback.format_tb (tb, limit=None)

     ‘format_list(extract_tb(tb, limit))’ の省略表現です。

 -- の関数: traceback.format_stack (f=None, limit=None)

     ‘format_list(extract_stack(f, limit))’ の省略表現です。

 -- の関数: traceback.clear_frames (tb)

     Clears the local variables of all the stack frames in a *note
     traceback: ac2. 'tb' by calling the *note clear(): 261. method of
     each *note frame object: 6ab.

     Added in version 3.4.

 -- の関数: traceback.walk_stack (f)

     Walk a stack following *note f.f_back: 757. from the given frame,
     yielding the frame and line number for each frame.  If 'f' is
     ‘None’, the current stack is used.  This helper is used with *note
     StackSummary.extract(): 42b3.

     Added in version 3.5.

 -- の関数: traceback.walk_tb (tb)

     Walk a traceback following *note tb_next: ac1. yielding the frame
     and line number for each frame.  This helper is used with *note
     StackSummary.extract(): 42b3.

     Added in version 3.5.


File: python.info,  Node: TracebackException オブジェクト,  Next: StackSummary オブジェクト,  Prev: モジュールレベルの関数<2>,  Up: traceback --- スタックトレースの表示または取得

5.29.11.2 ‘TracebackException’ オブジェクト
...........................................

Added in version 3.5.

‘TracebackException’ objects are created from actual exceptions to
capture data for later printing.  They offer a more lightweight method
of storing this information by avoiding holding references to *note
traceback: ac2. and *note frame: 6ab. objects In addition, they expose
more options to configure the output compared to the module-level
functions described above.

 -- クラス: traceback.TracebackException (exc_type, exc_value,
          exc_traceback, *, limit=None, lookup_lines=True,
          capture_locals=False, compact=False, max_group_width=15,
          max_group_depth=10)

     Capture an exception for later rendering.  The meaning of 'limit',
     'lookup_lines' and 'capture_locals' are as for the *note
     StackSummary: e4e. class.

     If 'compact' is true, only data that is required by
     ‘TracebackException’'s *note format(): 5eb. method is saved in the
     class attributes.  In particular, the *note __context__: 42b5.
     field is calculated only if *note __cause__: 42b6. is ‘None’ and
     *note __suppress_context__: 42b7. is false.

     局所変数がキャプチャされたとき、それらはトレースバックに表示される
     ことに注意してください。

     'max_group_width' and 'max_group_depth' control the formatting of
     exception groups (see *note BaseExceptionGroup: 240.).  The depth
     refers to the nesting level of the group, and the width refers to
     the size of a single exception group's exceptions array.  The
     formatted output is truncated when either limit is exceeded.

     バージョン 3.10 で変更: 'compact' 引数が追加されました。

     バージョン 3.11 で変更: Added the 'max_group_width' and
     'max_group_depth' parameters.

      -- の属性: __cause__

          A ‘TracebackException’ of the original *note __cause__: 1298.

      -- の属性: __context__

          A ‘TracebackException’ of the original *note __context__:
          1297.

      -- の属性: exceptions

          If ‘self’ represents an *note ExceptionGroup: 19b, this field
          holds a list of ‘TracebackException’ instances representing
          the nested exceptions.  Otherwise it is ‘None’.

          Added in version 3.11.

      -- の属性: __suppress_context__

          The *note __suppress_context__: 2013. value from the original
          exception.

      -- の属性: __notes__

          The *note __notes__: 21e1. value from the original exception,
          or ‘None’ if the exception does not have any notes.  If it is
          not ‘None’ is it formatted in the traceback after the
          exception string.

          Added in version 3.11.

      -- の属性: stack

          トレースバックを表す *note StackSummary: e4e.。

      -- の属性: exc_type

          元々のトレースバックのクラス。

          バージョン 3.13 で非推奨.

      -- の属性: exc_type_str

          String display of the class of the original exception.

          Added in version 3.13.

      -- の属性: filename

          構文エラー用 - エラーが発生したファイルの名前。

      -- の属性: lineno

          構文エラー用 - エラーが発生した行番号。

      -- の属性: end_lineno

          For syntax errors - the end line number where the error
          occurred.  Can be ‘None’ if not present.

          Added in version 3.10.

      -- の属性: text

          構文エラー用 - エラーが発生したテクスト。

      -- の属性: offset

          構文エラー用 - エラーが発生したテクストへのオフセット。

      -- の属性: end_offset

          For syntax errors - the end offset into the text where the
          error occurred.  Can be ‘None’ if not present.

          Added in version 3.10.

      -- の属性: msg

          構文エラー用 - コンパイラのエラーメッセージ。

      -- メソッド: classmethod from_exception (exc, *, limit=None,
               lookup_lines=True, capture_locals=False)

          後のレンダリングのために例外をキャプチャします。 'limit'、
          'lookup_lines'、'capture_locals' は *note StackSummary: e4e.
          class のものです。

          局所変数がキャプチャされたとき、それらはトレースバックに表示さ
          れることに注意してください。

      -- メソッド: print (*, file=None, chain=True)

          Print to 'file' (default ‘sys.stderr’) the exception
          information returned by *note format(): 5eb.

          Added in version 3.11.

      -- メソッド: format (*, chain=True)

          例外を書式化します。

          If 'chain' is not ‘True’, *note __cause__: 42b6. and *note
          __context__: 42b5. will not be formatted.

          返り値は文字列のジェネレータで、それぞれ改行で終わりますが、内
          部に改行を持つものもあります。 *note print_exception(): 81a. は
          このメソッドのラッパで、単にファイルに出力します。

      -- メソッド: format_exception_only (*, show_group=False)

          トレースバックの例外部を書式化します。

          返り値は文字列のジェネレータで、それぞれ改行で終わります。

          When 'show_group' is ‘False’, the generator emits the
          exception's message followed by its notes (if it has any).
          The exception message is normally a single string; however,
          for *note SyntaxError: 172. exceptions, it consists of several
          lines that (when printed) display detailed information about
          where the syntax error occurred.

          When 'show_group' is ‘True’, and the exception is an instance
          of *note BaseExceptionGroup: 240, the nested exceptions are
          included as well, recursively, with indentation relative to
          their nesting depth.

          バージョン 3.11 で変更: The exception's *note notes: 21e1. are
          now included in the output.

          バージョン 3.13 で変更: Added the 'show_group' parameter.


File: python.info,  Node: StackSummary オブジェクト,  Next: FrameSummary オブジェクト,  Prev: TracebackException オブジェクト,  Up: traceback --- スタックトレースの表示または取得

5.29.11.3 ‘StackSummary’ オブジェクト
.....................................

Added in version 3.5.

‘StackSummary’ objects represent a call stack ready for formatting.

 -- クラス: traceback.StackSummary

      -- メソッド: classmethod extract (frame_gen, *, limit=None,
               lookup_lines=True, capture_locals=False)

          Construct a ‘StackSummary’ object from a frame generator (such
          as is returned by *note walk_stack(): e4c. or *note walk_tb():
          e4d.).

          If 'limit' is supplied, only this many frames are taken from
          'frame_gen'.  If 'lookup_lines' is ‘False’, the returned *note
          FrameSummary: e4f. objects will not have read their lines in
          yet, making the cost of creating the ‘StackSummary’ cheaper
          (which may be valuable if it may not actually get formatted).
          If 'capture_locals' is ‘True’ the local variables in each
          ‘FrameSummary’ are captured as object representations.

          バージョン 3.12 で変更: Exceptions raised from *note repr():
          7c8. on a local variable (when 'capture_locals' is ‘True’) are
          no longer propagated to the caller.

      -- メソッド: classmethod from_list (a_list)

          Construct a ‘StackSummary’ object from a supplied list of
          *note FrameSummary: e4f. objects or old-style list of tuples.
          Each tuple should be a 4-tuple with 'filename', 'lineno',
          'name', 'line' as the elements.

      -- メソッド: format ()

          Returns a list of strings ready for printing.  Each string in
          the resulting list corresponds to a single *note frame: 6ab.
          from the stack.  Each string ends in a newline; the strings
          may contain internal newlines as well, for those items with
          source text lines.

          For long sequences of the same frame and line, the first few
          repetitions are shown, followed by a summary line stating the
          exact number of further repetitions.

          バージョン 3.6 で変更: Long sequences of repeated frames are
          now abbreviated.

      -- メソッド: format_frame_summary (frame_summary)

          Returns a string for printing one of the *note frames: 6ab.
          involved in the stack.  This method is called for each *note
          FrameSummary: e4f. object to be printed by *note
          StackSummary.format(): 42c6.  If it returns ‘None’, the frame
          is omitted from the output.

          Added in version 3.11.


File: python.info,  Node: FrameSummary オブジェクト,  Next: Examples of Using the Module-Level Functions,  Prev: StackSummary オブジェクト,  Up: traceback --- スタックトレースの表示または取得

5.29.11.4 ‘FrameSummary’ オブジェクト
.....................................

Added in version 3.5.

A ‘FrameSummary’ object represents a single *note frame: 6ab. in a *note
traceback: ac2.

 -- クラス: traceback.FrameSummary (filename, lineno, name,
          lookup_line=True, locals=None, line=None)

     Represents a single *note frame: 6ab. in the *note traceback: ac2.
     or stack that is being formatted or printed.  It may optionally
     have a stringified version of the frame's locals included in it.
     If 'lookup_line' is ‘False’, the source code is not looked up until
     the ‘FrameSummary’ has the *note line: 42ae. attribute accessed
     (which also happens when casting it to a *note tuple: 349.).  *note
     line: 42ae. may be directly provided, and will prevent line lookups
     happening at all.  'locals' is an optional local variable mapping,
     and if supplied the variable representations are stored in the
     summary for later display.

     ‘FrameSummary’ instances have the following attributes:

      -- の属性: filename

          The filename of the source code for this frame.  Equivalent to
          accessing *note f.f_code.co_filename: 1335. on a *note frame
          object: 6ab. 'f'.

      -- の属性: lineno

          The line number of the source code for this frame.

      -- の属性: name

          Equivalent to accessing *note f.f_code.co_name: 1e96. on a
          *note frame object: 6ab. 'f'.

      -- の属性: line

          A string representing the source code for this frame, with
          leading and trailing whitespace stripped.  If the source is
          not available, it is ‘None’.


File: python.info,  Node: Examples of Using the Module-Level Functions,  Next: Examples of Using TracebackException,  Prev: FrameSummary オブジェクト,  Up: traceback --- スタックトレースの表示または取得

5.29.11.5 Examples of Using the Module-Level Functions
......................................................

この簡単な例では基本的な read-eval-print ループを実装しています。標準的
な Python の対話インタープリタループに似ていますが、 Python のものより便
利ではありません。インタープリタループのより完全な実装については、 *note
code: 13. モジュールを参照してください。

     import sys, traceback

     def run_user_code(envdir):
         source = input(">>> ")
         try:
             exec(source, envdir)
         except Exception:
             print("Exception in user code:")
             print("-"*60)
             traceback.print_exc(file=sys.stdout)
             print("-"*60)

     envdir = {}
     while True:
         run_user_code(envdir)

次の例は例外とトレースバックの出力並びに形式が異なることを示します:

     import sys, traceback

     def lumberjack():
         bright_side_of_life()

     def bright_side_of_life():
         return tuple()[0]

     try:
         lumberjack()
     except IndexError as exc:
         print("*** print_tb:")
         traceback.print_tb(exc.__traceback__, limit=1, file=sys.stdout)
         print("*** print_exception:")
         traceback.print_exception(exc, limit=2, file=sys.stdout)
         print("*** print_exc:")
         traceback.print_exc(limit=2, file=sys.stdout)
         print("*** format_exc, first and last line:")
         formatted_lines = traceback.format_exc().splitlines()
         print(formatted_lines[0])
         print(formatted_lines[-1])
         print("*** format_exception:")
         print(repr(traceback.format_exception(exc)))
         print("*** extract_tb:")
         print(repr(traceback.extract_tb(exc.__traceback__)))
         print("*** format_tb:")
         print(repr(traceback.format_tb(exc.__traceback__)))
         print("*** tb_lineno:", exc.__traceback__.tb_lineno)

この例の出力は次のようになります:

     *** print_tb:
       File "<doctest...>", line 10, in <module>
         lumberjack()
         ~~~~~~~~~~^^
     *** print_exception:
     Traceback (most recent call last):
       File "<doctest...>", line 10, in <module>
         lumberjack()
         ~~~~~~~~~~^^
       File "<doctest...>", line 4, in lumberjack
         bright_side_of_life()
         ~~~~~~~~~~~~~~~~~~~^^
     IndexError: tuple index out of range
     *** print_exc:
     Traceback (most recent call last):
       File "<doctest...>", line 10, in <module>
         lumberjack()
         ~~~~~~~~~~^^
       File "<doctest...>", line 4, in lumberjack
         bright_side_of_life()
         ~~~~~~~~~~~~~~~~~~~^^
     IndexError: tuple index out of range
     *** format_exc, first and last line:
     Traceback (most recent call last):
     IndexError: tuple index out of range
     *** format_exception:
     ['Traceback (most recent call last):\n',
      '  File "<doctest default[0]>", line 10, in <module>\n    lumberjack()\n    ~~~~~~~~~~^^\n',
      '  File "<doctest default[0]>", line 4, in lumberjack\n    bright_side_of_life()\n    ~~~~~~~~~~~~~~~~~~~^^\n',
      '  File "<doctest default[0]>", line 7, in bright_side_of_life\n    return tuple()[0]\n           ~~~~~~~^^^\n',
      'IndexError: tuple index out of range\n']
     *** extract_tb:
     [<FrameSummary file <doctest...>, line 10 in <module>>,
      <FrameSummary file <doctest...>, line 4 in lumberjack>,
      <FrameSummary file <doctest...>, line 7 in bright_side_of_life>]
     *** format_tb:
     ['  File "<doctest default[0]>", line 10, in <module>\n    lumberjack()\n    ~~~~~~~~~~^^\n',
      '  File "<doctest default[0]>", line 4, in lumberjack\n    bright_side_of_life()\n    ~~~~~~~~~~~~~~~~~~~^^\n',
      '  File "<doctest default[0]>", line 7, in bright_side_of_life\n    return tuple()[0]\n           ~~~~~~~^^^\n']
     *** tb_lineno: 10

次の例は、スタックの print と format の違いを示しています:

     >>> import traceback
     >>> def another_function():
     ...     lumberstack()
     ...
     >>> def lumberstack():
     ...     traceback.print_stack()
     ...     print(repr(traceback.extract_stack()))
     ...     print(repr(traceback.format_stack()))
     ...
     >>> another_function()
       File "<doctest>", line 10, in <module>
         another_function()
       File "<doctest>", line 3, in another_function
         lumberstack()
       File "<doctest>", line 6, in lumberstack
         traceback.print_stack()
     [('<doctest>', 10, '<module>', 'another_function()'),
      ('<doctest>', 3, 'another_function', 'lumberstack()'),
      ('<doctest>', 7, 'lumberstack', 'print(repr(traceback.extract_stack()))')]
     ['  File "<doctest>", line 10, in <module>\n    another_function()\n',
      '  File "<doctest>", line 3, in another_function\n    lumberstack()\n',
      '  File "<doctest>", line 8, in lumberstack\n    print(repr(traceback.format_stack()))\n']

最後の例は、残りの幾つかの関数のデモをします:

     >>> import traceback
     >>> traceback.format_list([('spam.py', 3, '<module>', 'spam.eggs()'),
     ...                        ('eggs.py', 42, 'eggs', 'return "bacon"')])
     ['  File "spam.py", line 3, in <module>\n    spam.eggs()\n',
      '  File "eggs.py", line 42, in eggs\n    return "bacon"\n']
     >>> an_error = IndexError('tuple index out of range')
     >>> traceback.format_exception_only(an_error)
     ['IndexError: tuple index out of range\n']


File: python.info,  Node: Examples of Using TracebackException,  Prev: Examples of Using the Module-Level Functions,  Up: traceback --- スタックトレースの表示または取得

5.29.11.6 Examples of Using ‘TracebackException’
................................................

With the helper class, we have more options:

     >>> import sys
     >>> from traceback import TracebackException
     >>>
     >>> def lumberjack():
     ...     bright_side_of_life()
     ...
     >>> def bright_side_of_life():
     ...     t = "bright", "side", "of", "life"
     ...     return t[5]
     ...
     >>> try:
     ...     lumberjack()
     ... except IndexError as e:
     ...     exc = e
     ...
     >>> try:
     ...     try:
     ...         lumberjack()
     ...     except:
     ...         1/0
     ... except Exception as e:
     ...     chained_exc = e
     ...
     >>> # limit works as with the module-level functions
     >>> TracebackException.from_exception(exc, limit=-2).print()
     Traceback (most recent call last):
       File "<python-input-1>", line 6, in lumberjack
         bright_side_of_life()
         ~~~~~~~~~~~~~~~~~~~^^
       File "<python-input-1>", line 10, in bright_side_of_life
         return t[5]
                ~^^^
     IndexError: tuple index out of range

     >>> # capture_locals adds local variables in frames
     >>> TracebackException.from_exception(exc, limit=-2, capture_locals=True).print()
     Traceback (most recent call last):
       File "<python-input-1>", line 6, in lumberjack
         bright_side_of_life()
         ~~~~~~~~~~~~~~~~~~~^^
       File "<python-input-1>", line 10, in bright_side_of_life
         return t[5]
                ~^^^
         t = ("bright", "side", "of", "life")
     IndexError: tuple index out of range

     >>> # The *chain* kwarg to print() controls whether chained
     >>> # exceptions are displayed
     >>> TracebackException.from_exception(chained_exc).print()
     Traceback (most recent call last):
       File "<python-input-19>", line 4, in <module>
         lumberjack()
         ~~~~~~~~~~^^
       File "<python-input-8>", line 7, in lumberjack
         bright_side_of_life()
         ~~~~~~~~~~~~~~~~~~~^^
       File "<python-input-8>", line 11, in bright_side_of_life
         return t[5]
                ~^^^
     IndexError: tuple index out of range

     During handling of the above exception, another exception occurred:

     Traceback (most recent call last):
       File "<python-input-19>", line 6, in <module>
         1/0
         ~^~
     ZeroDivisionError: division by zero

     >>> TracebackException.from_exception(chained_exc).print(chain=False)
     Traceback (most recent call last):
       File "<python-input-19>", line 6, in <module>
         1/0
         ~^~
     ZeroDivisionError: division by zero


File: python.info,  Node: __future__ --- future 文の定義,  Next: gc --- ガベージコレクターインターフェース,  Prev: traceback --- スタックトレースの表示または取得,  Up: Python ランタイムサービス

5.29.12 ‘__future__’ -- future 文の定義
---------------------------------------

'ソースコード:' Lib/__future__.py(1)

__________________________________________________________________

‘from __future__ import feature’ の形式でのインポートは *note future 文:
16e. の定義と呼ばれています。これらは特殊なケースで、 Python の新機能が
標準になるリリースの前に Python コンパイラーが future 文を含むモジュール
で Python の新機能を使用できるようにします。

これらの future 文が Python コンパイラーによって追加の特殊な意味を与えら
れる一方で、それらは依然として他のインポート文のように実行され、 *note
__future__: 0. は存在し、他の Python モジュールと同じようにインポートシ
ステムによって処理されます。この設計は3つの目的にかなっています:

   * import 文を解析する既存のツールを混乱させることを避け、インポートし
     ようとしているモジュールを見つけられるようにするため。

   * 互換性のない変化がいつ言語に導入され、いつ言語の一部になる -- ある
     いは、なった -- のかを文書化するため。これは実行できる形式で書かれ
     たドキュメントなので、 *note __future__: 0. をインポートしてその中
     身を調べることでプログラムから調査することができます。

   * Python 2.1 以前のリリースで *note future 文: 16e. が実行された場合
     に、最低でもランタイム例外を投げるようにするため (*note __future__:
     0. のインポートは失敗します。なぜなら、 2.1 以前にはそういう名前の
     モジュールはなかったからです)。

* Menu:

* モジュールコンテンツ: モジュールコンテンツ<5>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/__future__.py


File: python.info,  Node: モジュールコンテンツ<5>,  Up: __future__ --- future 文の定義

5.29.12.1 モジュールコンテンツ
..............................

機能の記述が *note __future__: 0. から削除されたことはまだありません。
Python 2.1 で future 文が導入されて以来、この仕組みを使って以下の機能が
言語に導入されてきました:

feature                optional in       mandatory in       effect
                                                            
--------------------------------------------------------------------------------------------------------------
                                                            
nested_scopes          2.1.0b1           2.2                PEP 227(1): 'Statically Nested Scopes'
                                                            
                                                            
generators             2.2.0a1           2.3                PEP 255(2): 'Simple Generators'
                                                            
                                                            
division               2.2.0a2           3.0                PEP 238(3): 'Changing the Division Operator'
                                                            
                                                            
absolute_import        2.5.0a1           3.0                PEP 328(4): 'Imports: Multi-Line and
                                                            Absolute/Relative'
                                                            
                                                            
with_statement         2.5.0a1           2.6                PEP 343(5): 'The "with" Statement'
                                                            
                                                            
print_function         2.6.0a2           3.0                PEP 3105(6): 'Make print a function'
                                                            
                                                            
unicode_literals       2.6.0a2           3.0                PEP 3112(7): 'Bytes literals in Python 3000'
                                                            
                                                            
generator_stop         3.5.0b1           3.7                PEP 479(8): 'StopIteration handling inside
                                                            generators'
                                                            
                                                            
annotations            3.7.0b1           TBD (9)            PEP 563(10): 'Postponed evaluation of
                                                            annotations'
                                                            

 -- クラス: __future__._Feature

     ‘__future__.py’ のそれぞれの文は次のような形式をしています:

          FeatureName = _Feature(OptionalRelease, MandatoryRelease,
                                 CompilerFlag)

     ここで、普通は、 'OptionalRelease' は 'MandatoryRelease' より小さく
     、2つとも *note sys.version_info: 66c. と同じフォーマットの5つのタ
     プルからなります:

          (PY_MAJOR_VERSION, # the 2 in 2.1.0a3; an int
           PY_MINOR_VERSION, # the 1; an int
           PY_MICRO_VERSION, # the 0; an int
           PY_RELEASE_LEVEL, # "alpha", "beta", "candidate" or "final"; string
           PY_RELEASE_SERIAL # the 3; an int
          )

 -- メソッド: _Feature.getOptionalRelease ()

     'OptionalRelease' はその機能が導入された最初のリリースを記録します
     。

 -- メソッド: _Feature.getMandatoryRelease ()

     まだ時期が来ていない 'MandatoryRelease' の場合、'MandatoryRelease'
     はその機能が言語の一部となるリリースを記します。

     その他の場合、'MandatoryRelease' はその機能がいつ言語の一部になった
     のかを記録します。そのリリースから、あるいはそれ以降のリリースでは
     、この機能を使う際に future 文は必要ではありませんが、future 文を使
     い続けても構いません。

     'MandatoryRelease' は ‘None’ になるかもしれません。つまり、予定され
     た機能が破棄されたか、まだ決定されていないということです。

 -- の属性: _Feature.compiler_flag

     'CompilerFlag' は、動的にコンパイルされるコードでその機能を有効にす
     るために、組み込み関数 *note compile(): 177. の第4引数に渡す(ビット
     フィールド)フラグです。このフラグは *note _Feature: 20c8. インスタ
     ンスの *note _Feature.compiler_flag: 20c9. 属性に保存されています。

参考
....

*note future 文 (future statement): 16e.

     コンパイラがどのように future インポートを扱うか。

PEP 236(11) - Back to the __future__

     __future__ 機構の原案

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0227/

   (2) https://peps.python.org/pep-0255/

   (3) https://peps.python.org/pep-0238/

   (4) https://peps.python.org/pep-0328/

   (5) https://peps.python.org/pep-0343/

   (6) https://peps.python.org/pep-3105/

   (7) https://peps.python.org/pep-3112/

   (8) https://peps.python.org/pep-0479/

   (9) ‘from __future__ import annotations’ は以前は Python 3.10 で必須
となる予定でしたが、 Python 運営評議会はこの変更を延期することを2度決定
しました (Python 3.10 での発表
(https://mail.python.org/archives/list/python-dev@python.org/message/CLVXXPQ2T2LQ5MP2Y53VVQFCXYWQJHKZ/);
Python 3.11 での発表
(https://mail.python.org/archives/list/python-dev@python.org/message/VIZEBX5EYMSYIJNDBF6DMUMZOCWHARSO/))
。最終決定はまだ下されていません。 PEP 563
(https://peps.python.org/pep-0563/) と PEP 649
(https://peps.python.org/pep-0649/) も参照してください。

   (10) https://peps.python.org/pep-0563/

   (11) https://peps.python.org/pep-0236/


File: python.info,  Node: gc --- ガベージコレクターインターフェース,  Next: inspect --- 活動中のオブジェクトを調査する,  Prev: __future__ --- future 文の定義,  Up: Python ランタイムサービス

5.29.13 ‘gc’ -- ガベージコレクターインターフェース
--------------------------------------------------

__________________________________________________________________

このモジュールは、循環ガベージコレクタの無効化・検出頻度の調整・デバッグ
オブションの設定などを行うインターフェースを提供します。また、検出した到
達不能オブジェクトのうち、解放する事ができないオブジェクトを参照する事も
できます。循環ガベージコレクタはPythonの参照カウントを補うためのものなの
で、もしプログラム中で循環参照が発生しない事が明らかな場合には検出をする
必要はありません。自動検出は、 ‘gc.disable()’ で停止する事ができます。メ
モリリークをデバッグするときには、 ‘gc.set_debug(gc.DEBUG_LEAK)’ としま
す。これは ‘gc.DEBUG_SAVEALL’ を含んでいることに注意しましょう。ガベージ
として検出されたオブジェクトは、インスペクション用に gc.garbage に保存さ
れます。

*note gc: 56. モジュールは、以下の関数を提供しています:

 -- の関数: gc.enable ()

     自動ガベージコレクションを有効にします。

 -- の関数: gc.disable ()

     自動ガベージコレクションを無効にします。

 -- の関数: gc.isenabled ()

     自動ガベージコレクションが有効なら ‘True’ を返します。

 -- の関数: gc.collect (generation=2)

     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 *note ValueError: 1e3. is raised if the
     generation number is invalid.  The sum of collected objects and
     uncollectable objects is returned.

     ビルトイン型が持っている free list は、フルGCか最高世代(2)のGCの時
     にクリアされます。 *note float: 2ce. など、実装によって幾つかの
     free list では全ての要素が解放されるわけではありません。

     The effect of calling ‘gc.collect()’ while the interpreter is
     already performing a collection is undefined.

 -- の関数: gc.set_debug (flags)

     ガベージコレクションのデバッグフラグを設定します。デバッグ情報は
     ‘sys.stderr’ に出力されます。デバッグフラグは、下の値の組み合わせを
     指定する事ができます。

 -- の関数: gc.get_debug ()

     現在のデバッグフラグを返します。

 -- の関数: gc.get_objects (generation=None)

     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.

     バージョン 3.8 で変更: 新しい 'generation' パラメータ。

     引数 ‘generation’ で *note 監査イベント: 1825. ‘gc.get_objects’ を
     送出します。

 -- の関数: gc.get_stats ()

     インタプリタが開始してからの、世代ごと回収統計を持つ辞書の、3 世代
     ぶんのリストを返します。キーの数は将来変わるかもしれませんが、現在
     のところそれぞれの辞書には以下の項目が含まれています:

        * ‘collections’ は、この世代が検出を行った回数です;

        * ‘collected’ は、この世代内で回収されたオブジェクトの総数です;

        * ‘uncollectable’ は、この世代内で回収不能であることがわかった
          (そしてそれゆえに *note garbage: 1191. リストに移動した) オブ
          ジェクトの総数です。

     Added in version 3.4.

 -- の関数: gc.set_threshold (threshold0[, threshold1[, threshold2]])

     ガベージコレクションの閾値（検出頻度）を指定します。 'threshold0' を
     0 にすると、検出は行われません。

     The GC classifies objects into three generations depending on how
     many collection sweeps they have survived.  New objects are placed
     in the youngest generation (generation ‘0’).  If an object survives
     a collection it is moved into the next older generation.  Since
     generation ‘2’ is the oldest generation, objects in that generation
     remain there after a collection.  In order to decide when to run,
     the collector keeps track of the number object allocations and
     deallocations since the last collection.  When the number of
     allocations minus the number of deallocations exceeds 'threshold0',
     collection starts.  Initially only generation ‘0’ is examined.  If
     generation ‘0’ has been examined more than 'threshold1' times since
     generation ‘1’ has been examined, then generation ‘1’ is examined
     as well.  With the third generation, things are a bit more
     complicated, see Collecting the oldest generation(1) for more
     information.

 -- の関数: gc.get_count ()

     現在の検出数を、 ‘(count0, count1, count2)’ のタプルで返します。

 -- の関数: gc.get_threshold ()

     現在の検出閾値を、 ‘(threshold0, threshold1, threshold2)’ のタプル
     で返します。

 -- の関数: gc.get_referrers (*objs)

     objsで指定したオブジェクトのいずれかを参照しているオブジェクトのリ
     ストを返します。この関数では、ガベージコレクションをサポートしてい
     るコンテナのみを返します。他のオブジェクトを参照していても、ガベー
     ジコレクションをサポートしていない拡張型は含まれません。

     尚、戻り値のリストには、すでに参照されなくなっているが、循環参照の
     一部でまだガベージコレクションで回収されていないオブジェクトも含ま
     れるので注意が必要です。有効なオブジェクトのみを取得する場合、
     *note get_referrers(): 7cf. の前に *note collect(): a08. を呼び出し
     てください。

          警告: *note get_referrers(): 7cf. から返されるオブジェクトは作
          りかけや利用できない状態である場合があるので、利用する際には注
          意が必要です。 *note get_referrers(): 7cf. をデバッグ以外の目
          的で利用するのは避けてください。

     引数 ‘objs’ を指定して *note 監査イベント: 1825. ‘gc.get_referrers’
     を送出します。

 -- の関数: gc.get_referents (*objs)

     引数で指定したオブジェクトのいずれかから参照されている、全てのオブ
     ジェクトのリストを返します。参照先のオブジェクトは、引数で指定した
     オブジェクトの Cレベルメソッド *note tp_traverse: 749. で取得し、全
     てのオブジェクトが直接到達可能な全てのオブジェクトを返すわけではあ
     りません。 *note tp_traverse: 749. はガベージコレクションをサポート
     するオブジェクトのみが実装しており、ここで取得できるオブジェクトは
     循環参照の一部となる可能性のあるオブジェクトのみです。従って、例え
     ば整数オブジェクトが直接到達可能であっても、このオブジェクトは戻り
     値には含まれません。

     引数 ‘objs’ を指定して *note 監査イベント: 1825. ‘gc.get_referents’
     を送出します。

 -- の関数: gc.is_tracked (obj)

     ‘obj’ がガベージコレクタに管理されていたら ‘True’ を返し、それ以外
     の場合は ‘False’ を返します。 一般的なルールとして、アトミックな (訳
     注: 他のオブジェクトを参照しないで単一で値を表す型。 int や str な
     ど) 型のインスタンスは管理されず、それ以外の型 (コンテナ型、ユーザ
     ー定義型など) のインスタンスは管理されます。 しかし、いくつかの型で
     は専用の最適化を行い、シンプルなインスタンスの場合に GCのオーバーヘ
     ッドを減らしています。 (例: 全ての key と value がアトミック型の値
     である dict)

          >>> gc.is_tracked(0)
          False
          >>> gc.is_tracked("a")
          False
          >>> gc.is_tracked([])
          True
          >>> gc.is_tracked({})
          False
          >>> gc.is_tracked({"a": 1})
          False
          >>> gc.is_tracked({"a": []})
          True

     Added in version 3.1.

 -- の関数: gc.is_finalized (obj)

     Returns ‘True’ if the given object has been finalized by the
     garbage collector, ‘False’ otherwise.

          >>> x = None
          >>> class Lazarus:
          ...     def __del__(self):
          ...         global x
          ...         x = self
          ...
          >>> lazarus = Lazarus()
          >>> gc.is_finalized(lazarus)
          False
          >>> del lazarus
          >>> gc.is_finalized(x)
          True

     Added in version 3.9.

 -- の関数: gc.freeze ()

     Freeze all the objects tracked by the garbage collector; move them
     to a permanent generation and ignore them in all the future
     collections.

     If a process will ‘fork()’ without ‘exec()’, avoiding unnecessary
     copy-on-write in child processes will maximize memory sharing and
     reduce overall memory usage.  This requires both avoiding creation
     of freed "holes" in memory pages in the parent process and ensuring
     that GC collections in child processes won't touch the ‘gc_refs’
     counter of long-lived objects originating in the parent process.
     To accomplish both, call ‘gc.disable()’ early in the parent
     process, ‘gc.freeze()’ right before ‘fork()’, and ‘gc.enable()’
     early in child processes.

     Added in version 3.7.

 -- の関数: gc.unfreeze ()

     Permanent世代領域にあるオブジェクトを解凍します。つまり、最も古い世
     代へ戻します。

     Added in version 3.7.

 -- の関数: gc.get_freeze_count ()

     Permanent世代領域にあるオブジェクトの数を返します。

     Added in version 3.7.

以下の変数は読み出し専用アクセスのために提供されています。(この変数を操
作することはできますが、その値は記憶されません):

 -- データ: gc.garbage

     到達不能であることが検出されたが、解放する事ができないオブジェクト
     のリスト（回収不能オブジェクト）。Python 3.4 からは、‘NULL’ でない
     ‘tp_del’ スロットを持つ C 拡張型のインスタンスを使っている場合を除
     き、このリストはほとんど常に空であるはずです。

     *note DEBUG_SAVEALL: 42db. が設定されている場合、全ての到達不能オブ
     ジェクトは解放されずにこのリストに格納されます。

     バージョン 3.2 で変更: *note インタプリタシャットダウン: 134. 時に
     このリストが空でない場合、(デフォルトでは黙りますが) *note
     ResourceWarning: 225. が発行されます。 *note DEBUG_UNCOLLECTABLE:
     1192. がセットされていると、加えて回収不能オブジェクトを出力します
     。

     バージョン 3.4 で変更: Following PEP 442(2), objects with a *note
     __del__(): 1ec1. method don't end up in *note gc.garbage: 1191.
     anymore.

 -- データ: gc.callbacks

     ガベージコレクタの起動前と終了後に呼び出されるコールバック関数のリ
     スト。コールバックは 'phase' と 'info' の2つの引数で呼び出されます
     。

     'phase' は以下 2 つのいずれかです:

          "start": ガベージコレクションを始めます。

          "stop": ガベージコレクションが終了しました。

     'info' はコールバックに付加情報を提供する辞書です。現在のところ以下
     のキーが定義されています:

          "generation": 回収される最も古い世代。

          "collected": 'phase' が "stop" のとき、正常に回収されたオブジ
          ェクトの数。

          "uncollectable": 'phase' が "stop" のとき、回収出来ずに *note
          garbage: 1191. リストに入れられたオブジェクトの数。

     アプリケーションは自身のコールバックをこのリストに追加出来ます。基
     本的なユースケースは以下のようなものでしょう:

          世代が回収される頻度やガベージコレクションにかかった時間の長さ
          といった、ガベージコレクションの統計情報を集めます。

          *note garbage: 1191. に回収できない独自の型のオブジェクトが現
          れたとき、アプリケーションがそれらを特定し消去できるようにする
          。

     Added in version 3.3.

以下は *note set_debug(): 42d6. に指定することのできる定数です:

 -- データ: gc.DEBUG_STATS

     検出中に統計情報を出力します。この情報は、検出頻度を最適化する際に
     有益です。

 -- データ: gc.DEBUG_COLLECTABLE

     見つかった回収可能オブジェクトの情報を出力します。

 -- データ: gc.DEBUG_UNCOLLECTABLE

     見つかった回収不能オブジェクト（到達不能だが、ガベージコレクション
     で解放する事ができないオブジェクト）の情報を出力します。回収不能オ
     ブジェクトは、 ‘garbage’ リストに追加されます。

     バージョン 3.2 で変更: *note インタプリタシャットダウン: 134. 時に
     *note garbage: 1191. リストが空でない場合に、その中身の出力も行いま
     す。

 -- データ: gc.DEBUG_SAVEALL

     設定されている場合、全ての到達不能オブジェクトは解放されずに
     'garbage' に追加されます。これはプログラムのメモリリークをデバッグ
     するときに便利です。

 -- データ: gc.DEBUG_LEAK

     プログラムのメモリリークをデバッグするときに指定します（
     ‘DEBUG_COLLECTABLE | DEBUG_UNCOLLECTABLE | DEBUG_SAVEALL’ と同じ）
     。

   ---------- Footnotes ----------

   (1) 
https://devguide.python.org/garbage_collector/#collecting-the-oldest-generation

   (2) https://peps.python.org/pep-0442/


File: python.info,  Node: inspect --- 活動中のオブジェクトを調査する,  Next: site --- サイト固有の設定フック,  Prev: gc --- ガベージコレクターインターフェース,  Up: Python ランタイムサービス

5.29.14 ‘inspect’ -- 活動中のオブジェクトを調査する
---------------------------------------------------

'ソースコード:' Lib/inspect.py(1)

__________________________________________________________________

*note inspect: 72. は、活動中のオブジェクト (モジュール、クラス、メソッ
ド、関数、トレースバック、フレームオブジェクト、コードオブジェクトなど)
から情報を取得する関数を定義しており、クラスの内容を調べたり、メソッドの
ソースコードを取得したり、関数の引数リストを取り出して整形したり、詳細な
トレースバックを表示するのに必要な情報を取得したりするために利用できます
。

このモジュールの機能は4種類に分類することができます。型チェック、ソース
コードの情報取得、クラスや関数からの情報取得、インタープリタのスタック情
報の調査です。

* Menu:

* 型とメンバー::
* ソースコードの情報取得::
* Signature オブジェクトで呼び出し可能オブジェクトを内省する::
* クラスと関数: クラスと関数<2>.
* インタープリタスタック::
* 属性の静的なフェッチ::
* Current State of Generators, Coroutines, and Asynchronous Generators: Current State of Generators Coroutines and Asynchronous Generators.
* Code Objects Bit Flags::
* Buffer flags::
* コマンドラインインターフェイス: コマンドラインインターフェイス<9>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/inspect.py


File: python.info,  Node: 型とメンバー,  Next: ソースコードの情報取得,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.1 型とメンバー
......................

*note getmembers(): 17bf. は、クラスやモジュールなどのオブジェクトからメ
ンバーを取得します。名前が "is" で始まる関数は、主に *note getmembers():
17bf. の第2引数として利用するために提供されています。以下のような特殊属
性を参照できるかどうか調べる時にも使えるでしょう (モジュール属性について
は *note Import-related attributes on module objects: 1e74. を参照してく
ださい):

型                    属性                    説明
                                              
------------------------------------------------------------------------------
                                              
クラス                __doc__                 ドキュメント文字列
                                              
                                              
                      __name__                クラスの定義名
                                              
                                              
                      __qualname__            qualified name
                                              
                                              
                      __module__              クラスを定義しているモジュー
                                              ルの名前
                                              
                                              
                      __type_params__         A tuple containing the
                                              *note type parameters: 293.
                                              of a generic class
                                              
                                              
メソッド              __doc__                 ドキュメント文字列
                                              
                                              
                      __name__                メソッドの定義名
                                              
                                              
                      __qualname__            qualified name
                                              
                                              
                      __func__                メソッドを実装している関数オ
                                              ブジェクト
                                              
                                              
                      __self__                メソッドに結合しているインス
                                              タンス、または ‘None’
                                              
                                              
                      __module__              name of module in which this
                                              method was defined
                                              
                                              
関数                  __doc__                 ドキュメント文字列
                                              
                                              
                      __name__                関数の定義名
                                              
                                              
                      __qualname__            qualified name
                                              
                                              
                      __code__                関数をコンパイルした
                                              *note バイトコード: 16c. を格
                                              納するコードオブジェクト
                                              
                                              
                      __defaults__            位置またはキーワード引数の全
                                              ての既定値のタプル
                                              
                                              
                      __kwdefaults__          キーワード専用引数の全ての既
                                              定値のマッピング
                                              
                                              
                      __globals__             関数が定義されたグローバル名
                                              前空間
                                              
                                              
                      __builtins__            builtins namespace
                                              
                                              
                      __annotations__         仮引数名からアノテーションへ
                                              のマッピング; ‘"return"’ キー
                                              は return アノテーションに予
                                              約されています
                                              
                                              
                      __type_params__         A tuple containing the
                                              *note type parameters: 293.
                                              of a generic function
                                              
                                              
                      __module__              name of module in which this
                                              function was defined
                                              
                                              
traceback             tb_frame                このレベルのフレームオブジェ
                                              クト
                                              
                                              
                      tb_lasti                最後に実行しようとしたバイト
                                              コード中のインストラクション
                                              を示すインデックス
                                              
                                              
                      tb_lineno               現在の Python ソースコードの
                                              行番号
                                              
                                              
                      tb_next                 このオブジェクトの内側 (この
                                              レベルから呼び出された) のト
                                              レースバックオブジェクト
                                              
                                              
フレーム              f_back                  外側 (このフレームを呼び出し
                                              た) のフレームオブジェクト
                                              
                                              
                      f_builtins              このフレームで参照している組
                                              み込み名前空間
                                              
                                              
                      f_code                  このフレームで実行しているコ
                                              ードオブジェクト
                                              
                                              
                      f_globals               このフレームで参照しているグ
                                              ローバル名前空間
                                              
                                              
                      f_lasti                 最後に実行しようとしたバイト
                                              コード中のインストラクション
                                              を示すインデックス
                                              
                                              
                      f_lineno                現在の Python ソースコードの
                                              行番号
                                              
                                              
                      f_locals                このフレームで参照しているロ
                                              ーカル名前空間
                                              
                                              
                      f_trace                 このフレームのトレース関数、
                                              または ‘None’
                                              
                                              
コード                co_argcount             number of arguments (not
                                              including keyword only
                                              arguments, * or ** args)
                                              
                                              
                      co_code                 コンパイルされたバイトコード
                                              そのままの文字列
                                              
                                              
                      co_cellvars             tuple of names of cell
                                              variables (referenced by
                                              containing scopes)
                                              
                                              
                      co_consts               バイトコード中で使用している
                                              定数のタプル
                                              
                                              
                      co_filename             コードオブジェクトを生成した
                                              ファイルのファイル名
                                              
                                              
                      co_firstlineno          Python ソースコードの先頭行
                                              
                                              
                      co_flags                bitmap of ‘CO_*’ flags, read
                                              more *note here: 1ea6.
                                              
                                              
                      co_lnotab               行番号からバイトコードインデ
                                              ックスへの変換表を文字列にエ
                                              ンコードしたもの
                                              
                                              
                      co_freevars             tuple of names of free
                                              variables (referenced via a
                                              function's closure)
                                              
                                              
                      co_posonlyargcount      number of positional only
                                              arguments
                                              
                                              
                      co_kwonlyargcount       number of keyword only
                                              arguments (not including **
                                              arg)
                                              
                                              
                      co_name                 コードオブジェクトが定義され
                                              たときの名前
                                              
                                              
                      co_qualname             fully qualified name with
                                              which this code object was
                                              defined
                                              
                                              
                      co_names                tuple of names other than
                                              arguments and function locals
                                              
                                              
                      co_nlocals              ローカル変数の数
                                              
                                              
                      co_stacksize            必要とされる仮想マシンのスタ
                                              ックスペース
                                              
                                              
                      co_varnames             引数名とローカル変数名のタプ
                                              ル
                                              
                                              
ジェネレータ          __name__                name
                                              
                                              
                      __qualname__            qualified name
                                              
                                              
                      gi_frame                フレーム
                                              
                                              
                      gi_running              ジェネレータが実行中かどうか
                                              
                                              
                      gi_code                 コード
                                              
                                              
                      gi_yieldfrom            ‘yield from’ でイテレートされ
                                              ているオブジェクト、または
                                              ‘None’
                                              
                                              
async generator       __name__                name
                                              
                                              
                      __qualname__            qualified name
                                              
                                              
                      ag_await                待機されているオブジェクト、
                                              または ‘None’
                                              
                                              
                      ag_frame                フレーム
                                              
                                              
                      ag_running              ジェネレータが実行中かどうか
                                              
                                              
                      ag_code                 コード
                                              
                                              
コルーチン            __name__                name
                                              
                                              
                      __qualname__            qualified name
                                              
                                              
                      cr_await                待機されているオブジェクト、
                                              または ‘None’
                                              
                                              
                      cr_frame                フレーム
                                              
                                              
                      cr_running              コルーチンが実行中かどうか
                                              
                                              
                      cr_code                 コード
                                              
                                              
                      cr_origin               where coroutine was created,
                                              or ‘None’.  See
                                              *note sys.set_coroutine_origin_tracking_depth(): b5a.
                                              
                                              
組み込み              __doc__                 ドキュメント文字列
                                              
                                              
                      __name__                関数、メソッドの元々の名前
                                              
                                              
                      __qualname__            qualified name
                                              
                                              
                      __self__                メソッドが結合しているインス
                                              タンス、または ‘None’
                                              

バージョン 3.5 で変更: ジェネレータに ‘__qualname__’ と ‘gi_yieldfrom’ 属
性が追加されました。

ジェネレータの ‘__name__’ 属性がコード名ではなく関数名から設定されるよう
になり、変更できるようになりました。

バージョン 3.7 で変更: Add ‘cr_origin’ attribute to coroutines.

バージョン 3.10 で変更: Add ‘__builtins__’ attribute to functions.

 -- の関数: inspect.getmembers (object[, predicate])

     Return all the members of an object in a list of ‘(name, value)’
     pairs sorted by name.  If the optional 'predicate' argument—which
     will be called with the ‘value’ object of each member—is supplied,
     only members for which the predicate returns a true value are
     included.

          注釈: *note getmembers(): 17bf. will only return class
          attributes defined in the metaclass when the argument is a
          class and those attributes have been listed in the metaclass'
          custom *note __dir__(): 1ec7.

 -- の関数: inspect.getmembers_static (object[, predicate])

     Return all the members of an object in a list of ‘(name, value)’
     pairs sorted by name without triggering dynamic lookup via the
     descriptor protocol, __getattr__ or __getattribute__.  Optionally,
     only return members that satisfy a given predicate.

          注釈: *note getmembers_static(): 615. may not be able to
          retrieve all members that getmembers can fetch (like
          dynamically created attributes) and may find members that
          getmembers can't (like descriptors that raise AttributeError).
          It can also return descriptor objects instead of instance
          members in some cases.

     Added in version 3.11.

 -- の関数: inspect.getmodulename (path)

     Return the name of the module named by the file 'path', without
     including the names of enclosing packages.  The file extension is
     checked against all of the entries in *note
     importlib.machinery.all_suffixes(): 42e2.  If it matches, the final
     path component is returned with the extension removed.  Otherwise,
     ‘None’ is returned.

     Note that this function 'only' returns a meaningful name for actual
     Python modules - paths that potentially refer to Python packages
     will still return ‘None’.

     バージョン 3.3 で変更: The function is based directly on *note
     importlib: 6b.

 -- の関数: inspect.ismodule (object)

     オブジェクトがモジュールの場合 ‘True’ を返します。

 -- の関数: inspect.isclass (object)

     オブジェクトが組み込みか Python が生成したクラスの場合に ‘True’ を
     返します。

 -- の関数: inspect.ismethod (object)

     オブジェクトがメソッドの場合 ‘True’ を返します。

 -- の関数: inspect.isfunction (object)

     オブジェクトが、 *note lambda: 268a. 式で生成されたものを含む
     Python 関数の場合に ‘True’ を返します。

 -- の関数: inspect.isgeneratorfunction (object)

     オブジェクトが Python のジェネレータ関数の場合 ‘True’ を返します。

     バージョン 3.8 で変更: Functions wrapped in *note
     functools.partial(): 3ed. now return ‘True’ if the wrapped function
     is a Python generator function.

     バージョン 3.13 で変更: Functions wrapped in *note
     functools.partialmethod(): a49. now return ‘True’ if the wrapped
     function is a Python generator function.

 -- の関数: inspect.isgenerator (object)

     オブジェクトがジェネレータの場合 ‘True’ を返します。

 -- の関数: inspect.iscoroutinefunction (object)

     Return ‘True’ if the object is a *note coroutine function: d44. (a
     function defined with an *note async def: 59b. syntax), a *note
     functools.partial(): 3ed. wrapping a *note coroutine function: d44,
     or a sync function marked with *note markcoroutinefunction(): 45d.

     Added in version 3.5.

     バージョン 3.8 で変更: Functions wrapped in *note
     functools.partial(): 3ed. now return ‘True’ if the wrapped function
     is a *note coroutine function: d44.

     バージョン 3.12 で変更: Sync functions marked with *note
     markcoroutinefunction(): 45d. now return ‘True’.

     バージョン 3.13 で変更: Functions wrapped in *note
     functools.partialmethod(): a49. now return ‘True’ if the wrapped
     function is a *note coroutine function: d44.

 -- の関数: inspect.markcoroutinefunction (func)

     Decorator to mark a callable as a *note coroutine function: d44. if
     it would not otherwise be detected by *note iscoroutinefunction():
     2c5.

     This may be of use for sync functions that return a *note
     coroutine: 45e, if the function is passed to an API that requires
     *note iscoroutinefunction(): 2c5.

     When possible, using an *note async def: 59b. function is
     preferred.  Also acceptable is calling the function and testing the
     return with *note iscoroutine(): de3.

     Added in version 3.12.

 -- の関数: inspect.iscoroutine (object)

     オブジェクトが *note async def: 59b. で生成された *note コルーチン:
     45e. の場合 ‘True’ を返します。

     Added in version 3.5.

 -- の関数: inspect.isawaitable (object)

     オブジェクトを *note await: 19e. 式内で使用できる場合 ‘True’ を返し
     ます。

     Can also be used to distinguish generator-based coroutines from
     regular generators:

          import types

          def gen():
              yield
          @types.coroutine
          def gen_coro():
              yield

          assert not isawaitable(gen())
          assert isawaitable(gen_coro())

     Added in version 3.5.

 -- の関数: inspect.isasyncgenfunction (object)

     Return ‘True’ if the object is an *note asynchronous generator:
     1f99. function, for example:

          >>> async def agen():
          ...     yield 1
          ...
          >>> inspect.isasyncgenfunction(agen)
          True

     Added in version 3.6.

     バージョン 3.8 で変更: Functions wrapped in *note
     functools.partial(): 3ed. now return ‘True’ if the wrapped function
     is an *note asynchronous generator: 1f99. function.

     バージョン 3.13 で変更: Functions wrapped in *note
     functools.partialmethod(): a49. now return ‘True’ if the wrapped
     function is a *note coroutine function: d44.

 -- の関数: inspect.isasyncgen (object)

     オブジェクトが *note asynchronous generator: 1f99. 関数によって生成
     された *note asynchronous generator iterator: 41fa. である場合に
     ‘True’ を返します。

     Added in version 3.6.

 -- の関数: inspect.istraceback (object)

     オブジェクトがトレースバックの場合は ‘True’ を返します。

 -- の関数: inspect.isframe (object)

     オブジェクトがフレームの場合は ‘True’ を返します。

 -- の関数: inspect.iscode (object)

     オブジェクトがコードの場合は ‘True’ を返します。

 -- の関数: inspect.isbuiltin (object)

     オブジェクトが組み込み関数か束縛済みの組み込みメソッドの場合に
     ‘True’ を返します。

 -- の関数: inspect.ismethodwrapper (object)

     Return ‘True’ if the type of object is a *note MethodWrapperType:
     617.

     These are instances of *note MethodWrapperType: 617, such as *note
     __str__(): 5e9, *note __eq__(): ac8. and *note __repr__(): 5e8.

     Added in version 3.11.

 -- の関数: inspect.isroutine (object)

     オブジェクトがユーザ定義か組み込みの関数またはメソッドの場合は
     ‘True’ を返します。

 -- の関数: inspect.isabstract (object)

     オブジェクトが抽象基底クラスであるときに ‘True’ を返します。

 -- の関数: inspect.ismethoddescriptor (object)

     オブジェクトがメソッドデスクリプタであり、 *note ismethod(): 42e5,
     *note isclass(): 42e4, *note isfunction(): 42e6, *note isbuiltin():
     42ec. でない場合に ‘True’ を返します。

     This, for example, is true of ‘int.__add__’.  An object passing
     this test has a *note __get__(): 1490. method, but not a *note
     __set__(): 1eca. method or a *note __delete__(): 156c. method.
     Beyond that, the set of attributes varies.  A *note __name__: 103b.
     attribute is usually sensible, and *note __doc__: 8f6. often is.

     Methods implemented via descriptors that also pass one of the other
     tests return ‘False’ from the *note ismethoddescriptor(): 154d.
     test, simply because the other tests promise more - you can, e.g.,
     count on having the *note __func__: 12ca. attribute (etc) when an
     object passes *note ismethod(): 42e5.

     バージョン 3.13 で変更: This function no longer incorrectly reports
     objects with *note __get__(): 1490. and *note __delete__(): 156c,
     but not *note __set__(): 1eca, as being method descriptors (such
     objects are data descriptors, not method descriptors).

 -- の関数: inspect.isdatadescriptor (object)

     オブジェクトがデータデスクリプタの場合に ‘True’ を返します。

     Data descriptors have a *note __set__: 1eca. or a *note __delete__:
     156c. method.  Examples are properties (defined in Python),
     getsets, and members.  The latter two are defined in C and there
     are more specific tests available for those types, which is robust
     across Python implementations.  Typically, data descriptors will
     also have *note __name__: 103b. and ‘__doc__’ attributes
     (properties, getsets, and members have both of these attributes),
     but this is not guaranteed.

 -- の関数: inspect.isgetsetdescriptor (object)

     オブジェクトが getset デスクリプタの場合に ‘True’ を返します。

     'CPython 実装の詳細:' getset とは、拡張モジュールで *note
     PyGetSetDef: b86. 構造体を用いて定義された属性のことです。そのよう
     な型を持たない Python 実装の場合は、このメソッドは常に ‘False’ を返
     します。

 -- の関数: inspect.ismemberdescriptor (object)

     オブジェクトがメンバーデスクリプタの場合に ‘True’ を返します。

     'CPython 実装の詳細:' メンバーデスクリプタとは、拡張モジュールで
     *note PyMemberDef: 51a. 構造体を用いて定義された属性のことです。そ
     のような型を持たない Python 実装の場合は、このメソッドは常に
     ‘False’ を返します。


File: python.info,  Node: ソースコードの情報取得,  Next: Signature オブジェクトで呼び出し可能オブジェクトを内省する,  Prev: 型とメンバー,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.2 ソースコードの情報取得
................................

 -- の関数: inspect.getdoc (object)

     Get the documentation string for an object, cleaned up with *note
     cleandoc(): 1619.  If the documentation string for an object is not
     provided and the object is a class, a method, a property or a
     descriptor, retrieve the documentation string from the inheritance
     hierarchy.  Return ‘None’ if the documentation string is invalid or
     missing.

     バージョン 3.5 で変更: ドキュメンテーション文字列がオーバーライドさ
     れていない場合は継承されるようになりました。

 -- の関数: inspect.getcomments (object)

     Return in a single string any lines of comments immediately
     preceding the object's source code (for a class, function, or
     method), or at the top of the Python source file (if the object is
     a module).  If the object's source code is unavailable, return
     ‘None’.  This could happen if the object has been defined in C or
     the interactive shell.

 -- の関数: inspect.getfile (object)

     オブジェクトを定義している (テキストまたはバイナリの) ファイルの名
     前を返します。オブジェクトが組み込みモジュール、クラス、関数の場合
     は *note TypeError: 502. 例外が発生します。

 -- の関数: inspect.getmodule (object)

     Try to guess which module an object was defined in.  Return ‘None’
     if the module cannot be determined.

 -- の関数: inspect.getsourcefile (object)

     Return the name of the Python source file in which an object was
     defined or ‘None’ if no way can be identified to get the source.
     This will fail with a *note TypeError: 502. if the object is a
     built-in module, class, or function.

 -- の関数: inspect.getsourcelines (object)

     Return a list of source lines and starting line number for an
     object.  The argument may be a module, class, method, function,
     traceback, frame, or code object.  The source code is returned as a
     list of the lines corresponding to the object and the line number
     indicates where in the original source file the first line of code
     was found.  An *note OSError: 3f0. is raised if the source code
     cannot be retrieved.  A *note TypeError: 502. is raised if the
     object is a built-in module, class, or function.

     バージョン 3.3 で変更: *note IOError: 1026. の代わりに *note
     OSError: 3f0. を送出します。前者は後者のエイリアスです。

 -- の関数: inspect.getsource (object)

     Return the text of the source code for an object.  The argument may
     be a module, class, method, function, traceback, frame, or code
     object.  The source code is returned as a single string.  An *note
     OSError: 3f0. is raised if the source code cannot be retrieved.  A
     *note TypeError: 502. is raised if the object is a built-in module,
     class, or function.

     バージョン 3.3 で変更: *note IOError: 1026. の代わりに *note
     OSError: 3f0. を送出します。前者は後者のエイリアスです。

 -- の関数: inspect.cleandoc (doc)

     コードブロックと位置を合わせるためのインデントを docstring から削除
     します。

     先頭行の行頭の空白文字は全て削除されます。 2行目以降では全行で同じ
     数の行頭の空白文字が、削除できるだけ削除されます。 その後、先頭と末
     尾の空白行が削除され、全てのタブが空白に展開されます。


File: python.info,  Node: Signature オブジェクトで呼び出し可能オブジェクトを内省する,  Next: クラスと関数<2>,  Prev: ソースコードの情報取得,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.3 Signature オブジェクトで呼び出し可能オブジェクトを内省する
....................................................................

Added in version 3.3.

The *note Signature: 1b1. object represents the call signature of a
callable object and its return annotation.  To retrieve a ‘Signature’
object, use the ‘signature()’ function.

 -- の関数: inspect.signature (callable, *, follow_wrapped=True,
          globals=None, locals=None, eval_str=False)

     Return a *note Signature: 1b1. object for the given 'callable':

          >>> from inspect import signature
          >>> def foo(a, *, b:int, **kwargs):
          ...     pass

          >>> sig = signature(foo)

          >>> str(sig)
          '(a, *, b: int, **kwargs)'

          >>> str(sig.parameters['b'])
          'b: int'

          >>> sig.parameters['b'].annotation
          <class 'int'>

     単純な関数やクラスから、 *note functools.partial(): 3ed. オブジェク
     トまで、幅広い Python の呼び出し可能なオブジェクトを受け付けます。

     For objects defined in modules using stringized annotations (‘from
     __future__ import annotations’), *note signature(): 703. will
     attempt to automatically un-stringize the annotations using *note
     get_annotations(): 7de.  The 'globals', 'locals', and 'eval_str'
     parameters are passed into *note get_annotations(): 7de. when
     resolving the annotations; see the documentation for *note
     get_annotations(): 7de. for instructions on how to use these
     parameters.

     Raises *note ValueError: 1e3. if no signature can be provided, and
     *note TypeError: 502. if that type of object is not supported.
     Also, if the annotations are stringized, and 'eval_str' is not
     false, the ‘eval()’ call(s) to un-stringize the annotations in
     *note get_annotations(): 7de. could potentially raise any kind of
     exception.

     A slash(/) in the signature of a function denotes that the
     parameters prior to it are positional-only.  For more info, see
     *note the FAQ entry on positional-only parameters: 20d8.

     バージョン 3.5 で変更: The 'follow_wrapped' parameter was added.
     Pass ‘False’ to get a signature of 'callable' specifically
     (‘callable.__wrapped__’ will not be used to unwrap decorated
     callables.)

     バージョン 3.10 で変更: The 'globals', 'locals', and 'eval_str'
     parameters were added.

          注釈: Some callables may not be introspectable in certain
          implementations of Python.  For example, in CPython, some
          built-in functions defined in C provide no metadata about
          their arguments.

     'CPython 実装の詳細:' If the passed object has a ‘__signature__’
     attribute, we may use it to create the signature.  The exact
     semantics are an implementation detail and are subject to
     unannounced changes.  Consult the source code for current
     semantics.

 -- クラス: inspect.Signature (parameters=None, *,
          return_annotation=Signature.empty)

     A ‘Signature’ object represents the call signature of a function
     and its return annotation.  For each parameter accepted by the
     function it stores a *note Parameter: 1b2. object in its *note
     parameters: 42f6. collection.

     The optional 'parameters' argument is a sequence of *note
     Parameter: 1b2. objects, which is validated to check that there are
     no parameters with duplicate names, and that the parameters are in
     the right order, i.e.  positional-only first, then
     positional-or-keyword, and that parameters with defaults follow
     parameters without defaults.

     The optional 'return_annotation' argument can be an arbitrary
     Python object.  It represents the "return" annotation of the
     callable.

     ‘Signature’ objects are 'immutable'.  Use *note
     Signature.replace(): 42f7. or *note copy.replace(): 137. to make a
     modified copy.

     バージョン 3.5 で変更: ‘Signature’ objects are now picklable and
     *note hashable: 5db.

      -- の属性: empty

          return アノテーションがないことを指すクラスレベルの特殊マーカ
          です。

      -- の属性: parameters

          An ordered mapping of parameters' names to the corresponding
          *note Parameter: 1b2. objects.  Parameters appear in strict
          definition order, including keyword-only parameters.

          バージョン 3.7 で変更: Python only explicitly guaranteed that
          it preserved the declaration order of keyword-only parameters
          as of version 3.7, although in practice this order had always
          been preserved in Python 3.

      -- の属性: return_annotation

          呼び出し可能オブジェクトの "return" アノテーションです。呼び出
          し可能オブジェクトに "return" アノテーションがない場合、この属
          性は *note Signature.empty: 42f8. に設定されます。

      -- メソッド: bind (*args, **kwargs)

          Create a mapping from positional and keyword arguments to
          parameters.  Returns *note BoundArguments: 103e. if ‘*args’
          and ‘**kwargs’ match the signature, or raises a *note
          TypeError: 502.

      -- メソッド: bind_partial (*args, **kwargs)

          Works the same way as *note Signature.bind(): 157d, but allows
          the omission of some required arguments (mimics *note
          functools.partial(): 3ed. behavior.)  Returns *note
          BoundArguments: 103e, or raises a *note TypeError: 502. if the
          passed arguments do not match the signature.

      -- メソッド: replace (*[, parameters][, return_annotation])

          Create a new *note Signature: 1b1. instance based on the
          instance *note replace(): 42f7. was invoked on.  It is
          possible to pass different 'parameters' and/or
          'return_annotation' to override the corresponding properties
          of the base signature.  To remove ‘return_annotation’ from the
          copied ‘Signature’, pass in *note Signature.empty: 42f8.

               >>> def test(a, b):
               ...     pass
               ...
               >>> sig = signature(test)
               >>> new_sig = sig.replace(return_annotation="new return anno")
               >>> str(new_sig)
               "(a, b) -> 'new return anno'"

          *note Signature: 1b1. objects are also supported by the
          generic function *note copy.replace(): 137.

      -- メソッド: format (*, max_width=None)

          Create a string representation of the *note Signature: 1b1.
          object.

          If 'max_width' is passed, the method will attempt to fit the
          signature into lines of at most 'max_width' characters.  If
          the signature is longer than 'max_width', all parameters will
          be on separate lines.

          Added in version 3.13.

      -- メソッド: classmethod from_callable (obj, *,
               follow_wrapped=True, globals=None, locals=None,
               eval_str=False)

          Return a *note Signature: 1b1. (or its subclass) object for a
          given callable 'obj'.

          This method simplifies subclassing of *note Signature: 1b1.:

               class MySignature(Signature):
                   pass
               sig = MySignature.from_callable(sum)
               assert isinstance(sig, MySignature)

          Its behavior is otherwise identical to that of *note
          signature(): 703.

          Added in version 3.5.

          バージョン 3.10 で変更: The 'globals', 'locals', and
          'eval_str' parameters were added.

 -- クラス: inspect.Parameter (name, kind, *, default=Parameter.empty,
          annotation=Parameter.empty)

     ‘Parameter’ objects are 'immutable'.  Instead of modifying a
     ‘Parameter’ object, you can use *note Parameter.replace(): 42fc. or
     *note copy.replace(): 137. to create a modified copy.

     バージョン 3.5 で変更: Parameter objects are now picklable and
     *note hashable: 5db.

      -- の属性: empty

          デフォルト値とアノテーションがないことを指すクラスレベルの特殊
          マーカです。

      -- の属性: name

          仮引数名 (文字列) です。名前は有効な Python 識別子でなければな
          りません。

          'CPython 実装の詳細:' CPython generates implicit parameter
          names of the form ‘.0’ on the code objects used to implement
          comprehensions and generator expressions.

          バージョン 3.6 で変更: These parameter names are now exposed
          by this module as names like ‘implicit0’.

      -- の属性: default

          引数のデフォルト値です。引数にデフォルト値がない場合、この属性
          は *note Parameter.empty: 42fd. に設定されます。

      -- の属性: annotation

          引数のアノテーションです。引数にアノテーションがない場合、この
          属性は *note Parameter.empty: 42fd. に設定されます。

      -- の属性: kind

          Describes how argument values are bound to the parameter.  The
          possible values are accessible via *note Parameter: 1b2. (like
          ‘Parameter.KEYWORD_ONLY’), and support comparison and
          ordering, in the following order:

          名前                         意味
                                       
          --------------------------------------------------------------------------------
                                       
          'POSITIONAL_ONLY'            Value must be supplied as a positional argument.
                                       Positional only parameters are those which
                                       appear before a ‘/’ entry (if present) in a
                                       Python function definition.
                                       
                                       
          'POSITIONAL_OR_KEYWORD'      値をキーワードまたは位置引数として渡すことができ
                                       ます (これは Python で実装された関数の標準的な束
                                       縛動作です)。
                                       
                                       
          'VAR_POSITIONAL'             その他の仮引数に束縛されていない位置引数のタプル
                                       です。Python の関数定義における ‘*args’ 仮引数に
                                       対応します。
                                       
                                       
          'KEYWORD_ONLY'               値をキーワード引数として渡さなければなりません。
                                       キーワード専用引数は Python の関数定義において
                                       ‘*’ や ‘*args’ の後に現れる引数です。
                                       
                                       
          'VAR_KEYWORD'                その他の仮引数に束縛されていないキーワード引数の
                                       辞書です。Python の関数定義における ‘**kwargs’ 仮
                                       引数に対応します。
                                       

          Example: print all keyword-only arguments without default
          values:

               >>> def foo(a, b, *, c, d=10):
               ...     pass

               >>> sig = signature(foo)
               >>> for param in sig.parameters.values():
               ...     if (param.kind == param.KEYWORD_ONLY and
               ...                        param.default is param.empty):
               ...         print('Parameter:', param)
               Parameter: c

      -- の属性: kind.description

          Describes an enum value of *note Parameter.kind: 4301.

          Added in version 3.8.

          Example: print all descriptions of arguments:

               >>> def foo(a, b, *, c, d=10):
               ...     pass

               >>> sig = signature(foo)
               >>> for param in sig.parameters.values():
               ...     print(param.kind.description)
               positional or keyword
               positional or keyword
               keyword-only
               keyword-only

      -- メソッド: replace (*[, name][, kind][, default][, annotation])

          Create a new *note Parameter: 1b2. instance based on the
          instance replaced was invoked on.  To override a ‘Parameter’
          attribute, pass the corresponding argument.  To remove a
          default value or/and an annotation from a ‘Parameter’, pass
          *note Parameter.empty: 42fd.

               >>> from inspect import Parameter
               >>> param = Parameter('foo', Parameter.KEYWORD_ONLY, default=42)
               >>> str(param)
               'foo=42'

               >>> str(param.replace()) # Will create a shallow copy of 'param'
               'foo=42'

               >>> str(param.replace(default=Parameter.empty, annotation='spam'))
               "foo: 'spam'"

          *note Parameter: 1b2. objects are also supported by the
          generic function *note copy.replace(): 137.

     バージョン 3.4 で変更: In Python 3.3 *note Parameter: 1b2. objects
     were allowed to have ‘name’ set to ‘None’ if their ‘kind’ was set
     to ‘POSITIONAL_ONLY’.  This is no longer permitted.

 -- クラス: inspect.BoundArguments

     Result of a *note Signature.bind(): 157d. or *note
     Signature.bind_partial(): 42fa. call.  Holds the mapping of
     arguments to the function's parameters.

      -- の属性: arguments

          A mutable mapping of parameters' names to arguments' values.
          Contains only explicitly bound arguments.  Changes in *note
          arguments: 8da. will reflect in *note args: 4303. and *note
          kwargs: 4304.

          Should be used in conjunction with *note Signature.parameters:
          42f6. for any argument processing purposes.

               注釈: Arguments for which *note Signature.bind(): 157d.
               or *note Signature.bind_partial(): 42fa. relied on a
               default value are skipped.  However, if needed, use *note
               BoundArguments.apply_defaults(): de2. to add them.

          バージョン 3.9 で変更: *note arguments: 8da. is now of type
          *note dict: 237.  Formerly, it was of type *note
          collections.OrderedDict: 5a5.

      -- の属性: args

          位置引数の値のタプルです。*note arguments: 8da. 属性から動的に
          計算されます。

      -- の属性: kwargs

          A dict of keyword arguments values.  Dynamically computed from
          the *note arguments: 8da. attribute.  Arguments that can be
          passed positionally are included in *note args: 4303. instead.

      -- の属性: signature

          親の *note Signature: 1b1. オブジェクトへの参照です。

      -- メソッド: apply_defaults ()

          存在しない引数のデフォルト値を設定します。

          For variable-positional arguments (‘*args’) the default is an
          empty tuple.

          For variable-keyword arguments (‘**kwargs’) the default is an
          empty dict.

               >>> def foo(a, b='ham', *args): pass
               >>> ba = inspect.signature(foo).bind('spam')
               >>> ba.apply_defaults()
               >>> ba.arguments
               {'a': 'spam', 'b': 'ham', 'args': ()}

          Added in version 3.5.

     The *note args: 4303. and *note kwargs: 4304. properties can be
     used to invoke functions:

          def test(a, *, b):
              ...

          sig = signature(test)
          ba = sig.bind(10, b=20)
          test(*ba.args, **ba.kwargs)

参考
....

PEP 362(1): - 関数シグニチャオブジェクト

     The detailed specification, implementation details and examples.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0362/


File: python.info,  Node: クラスと関数<2>,  Next: インタープリタスタック,  Prev: Signature オブジェクトで呼び出し可能オブジェクトを内省する,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.4 クラスと関数
......................

 -- の関数: inspect.getclasstree (classes, unique=False)

     リストで指定したクラスの継承関係から、ネストしたリストを作成します
     。ネストしたリストには、直前の要素から派生したクラスが格納されます
     。各要素は長さ2のタプルで、クラスと基底クラスのタプルを格納していま
     す。'unique' が真の場合、各クラスは戻り値のリスト内に一つだけしか格
     納されません。真でなければ、多重継承を利用したクラスとその派生クラ
     スは複数回格納される場合があります。

 -- の関数: inspect.getfullargspec (func)

     Get the names and default values of a Python function's parameters.
     A *note named tuple: 61a. is returned:

     ‘FullArgSpec(args, varargs, varkw, defaults, kwonlyargs,
     kwonlydefaults, annotations)’

     'args' is a list of the positional parameter names.  'varargs' is
     the name of the ‘*’ parameter or ‘None’ if arbitrary positional
     arguments are not accepted.  'varkw' is the name of the ‘**’
     parameter or ‘None’ if arbitrary keyword arguments are not
     accepted.  'defaults' is an 'n'-tuple of default argument values
     corresponding to the last 'n' positional parameters, or ‘None’ if
     there are no such defaults defined.  'kwonlyargs' is a list of
     keyword-only parameter names in declaration order.
     'kwonlydefaults' is a dictionary mapping parameter names from
     'kwonlyargs' to the default values used if no argument is supplied.
     'annotations' is a dictionary mapping parameter names to
     annotations.  The special key ‘"return"’ is used to report the
     function return value annotation (if any).

     Note that *note signature(): 703. and *note Signature Object: 42f4.
     provide the recommended API for callable introspection, and support
     additional behaviours (like positional-only arguments) that are
     sometimes encountered in extension module APIs.  This function is
     retained primarily for use in code that needs to maintain
     compatibility with the Python 2 ‘inspect’ module API.

     バージョン 3.4 で変更: This function is now based on *note
     signature(): 703, but still ignores ‘__wrapped__’ attributes and
     includes the already bound first parameter in the signature output
     for bound methods.

     バージョン 3.6 で変更: This method was previously documented as
     deprecated in favour of *note signature(): 703. in Python 3.5, but
     that decision has been reversed in order to restore a clearly
     supported standard interface for single-source Python 2/3 code
     migrating away from the legacy ‘getargspec()’ API.

     バージョン 3.7 で変更: Python only explicitly guaranteed that it
     preserved the declaration order of keyword-only parameters as of
     version 3.7, although in practice this order had always been
     preserved in Python 3.

 -- の関数: inspect.getargvalues (frame)

     指定したフレームに渡された引数の情報を取得します。戻り値は *note
     名前付きタプル: 61a. ‘ArgInfo(args, varargs, keywords, locals)’ で
     す。'args' は引数名のリストです。 'varargs' と 'keywords' は ‘*’ 引
     数と ‘**’ 引数の名前で、引数がなければ ‘None’ となります。 'locals'
     は指定したフレームのローカル変数の辞書です。

          注釈: This function was inadvertently marked as deprecated in
          Python 3.5.

 -- の関数: inspect.formatargvalues (args[, varargs, varkw, locals,
          formatarg, formatvarargs, formatvarkw, formatvalue])

     *note getargvalues(): e87. で取得した4つの値を読みやすく整形します
     。 format* 引数はオプションで、名前と値を文字列に変換する整形関数を
     指定することができます。

          注釈: This function was inadvertently marked as deprecated in
          Python 3.5.

 -- の関数: inspect.getmro (cls)

     'cls' クラスの基底クラス ('cls' 自身も含む) を、メソッドの優先順位
     順に並べたタプルを返します。結果のリスト内で各クラスは一度だけ格納
     されます。メソッドの優先順位はクラスの型によって異なります。非常に
     特殊なユーザ定義のメタクラスを使用していない限り、'cls' が戻り値の
     先頭要素となります。

 -- の関数: inspect.getcallargs (func, /, *args, **kwds)

     Bind the 'args' and 'kwds' to the argument names of the Python
     function or method 'func', as if it was called with them.  For
     bound methods, bind also the first argument (typically named
     ‘self’) to the associated instance.  A dict is returned, mapping
     the argument names (including the names of the ‘*’ and ‘**’
     arguments, if any) to their values from 'args' and 'kwds'.  In case
     of invoking 'func' incorrectly, i.e.  whenever ‘func(*args,
     **kwds)’ would raise an exception because of incompatible
     signature, an exception of the same type and the same or similar
     message is raised.  For example:

          >>> from inspect import getcallargs
          >>> def f(a, b=1, *pos, **named):
          ...     pass
          ...
          >>> getcallargs(f, 1, 2, 3) == {'a': 1, 'named': {}, 'b': 2, 'pos': (3,)}
          True
          >>> getcallargs(f, a=2, x=4) == {'a': 2, 'named': {'x': 4}, 'b': 1, 'pos': ()}
          True
          >>> getcallargs(f)
          Traceback (most recent call last):
          ...
          TypeError: f() missing 1 required positional argument: 'a'

     Added in version 3.2.

     バージョン 3.5 で非推奨: Use *note Signature.bind(): 157d. and
     *note Signature.bind_partial(): 42fa. instead.

 -- の関数: inspect.getclosurevars (func)

     Get the mapping of external name references in a Python function or
     method 'func' to their current values.  A *note named tuple: 61a.
     ‘ClosureVars(nonlocals, globals, builtins, unbound)’ is returned.
     'nonlocals' maps referenced names to lexical closure variables,
     'globals' to the function's module globals and 'builtins' to the
     builtins visible from the function body.  'unbound' is the set of
     names referenced in the function that could not be resolved at all
     given the current module globals and builtins.

     'func' が Python の関数やメソッドでない場合 *note TypeError: 502. が
     送出されます。

     Added in version 3.3.

 -- の関数: inspect.unwrap (func, *, stop=None)

     Get the object wrapped by 'func'.  It follows the chain of
     ‘__wrapped__’ attributes returning the last object in the chain.

     'stop' is an optional callback accepting an object in the wrapper
     chain as its sole argument that allows the unwrapping to be
     terminated early if the callback returns a true value.  If the
     callback never returns a true value, the last object in the chain
     is returned as usual.  For example, *note signature(): 703. uses
     this to stop unwrapping if any object in the chain has a
     ‘__signature__’ attribute defined.

     *note ValueError: 1e3. is raised if a cycle is encountered.

     Added in version 3.4.

 -- の関数: inspect.get_annotations (obj, *, globals=None, locals=None,
          eval_str=False)

     Compute the annotations dict for an object.

     ‘obj’ may be a callable, class, or module.  Passing in an object of
     any other type raises *note TypeError: 502.

     Returns a dict.  ‘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.

     This function handles several details for you:

        * If ‘eval_str’ is true, values of type ‘str’ will be
          un-stringized using *note eval(): 165.  This is intended for
          use with stringized annotations (‘from __future__ import
          annotations’).

        * 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.)

        * Ignores inherited annotations on classes.  If a class doesn't
          have its own annotations dict, returns an empty dict.

        * All accesses to object members and dict values are done using
          ‘getattr()’ and ‘dict.get()’ for safety.

        * Always, always, always returns a freshly created dict.

     ‘eval_str’ controls whether or not values of type ‘str’ are
     replaced with the result of calling *note eval(): 165. on those
     values:

        * If eval_str is true, *note eval(): 165. is called on values of
          type ‘str’.  (Note that ‘get_annotations’ doesn't catch
          exceptions; if *note eval(): 165. raises an exception, it will
          unwind the stack past the ‘get_annotations’ call.)

        * If eval_str is false (the default), values of type ‘str’ are
          unchanged.

     ‘globals’ and ‘locals’ are passed in to *note eval(): 165.; see the
     documentation for *note eval(): 165. for more information.  If
     ‘globals’ or ‘locals’ is ‘None’, this function may replace that
     value with a context-specific default, contingent on ‘type(obj)’:

        * If ‘obj’ is a module, ‘globals’ defaults to ‘obj.__dict__’.

        * If ‘obj’ is a class, ‘globals’ defaults to
          ‘sys.modules[obj.__module__].__dict__’ and ‘locals’ defaults
          to the ‘obj’ class namespace.

        * If ‘obj’ is a callable, ‘globals’ defaults to *note
          obj.__globals__: 12a1, although if ‘obj’ is a wrapped function
          (using *note functools.update_wrapper(): fec.) it is first
          unwrapped.

     Calling ‘get_annotations’ is best practice for accessing the
     annotations dict of any object.  See *note Annotations Best
     Practices: 7a4. for more information on annotations best practices.

     Added in version 3.10.


File: python.info,  Node: インタープリタスタック,  Next: 属性の静的なフェッチ,  Prev: クラスと関数<2>,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.5 インタープリタスタック
................................

Some of the following functions return *note FrameInfo: 618. objects.
For backwards compatibility these objects allow tuple-like operations on
all attributes except ‘positions’.  This behavior is considered
deprecated and may be removed in the future.

 -- クラス: inspect.FrameInfo

      -- の属性: frame

          The *note frame object: 6ab. that the record corresponds to.

      -- の属性: filename

          The file name associated with the code being executed by the
          frame this record corresponds to.

      -- の属性: lineno

          The line number of the current line associated with the code
          being executed by the frame this record corresponds to.

      -- の属性: function

          The function name that is being executed by the frame this
          record corresponds to.

      -- の属性: code_context

          A list of lines of context from the source code that's being
          executed by the frame this record corresponds to.

      -- の属性: index

          The index of the current line being executed in the *note
          code_context: 4310. list.

      -- の属性: positions

          A *note dis.Positions: 4313. object containing the start line
          number, end line number, start column offset, and end column
          offset associated with the instruction being executed by the
          frame this record corresponds to.

     バージョン 3.5 で変更: Return a *note named tuple: 61a. instead of
     a *note tuple: 349.

     バージョン 3.11 で変更: ‘FrameInfo’ is now a class instance (that
     is backwards compatible with the previous *note named tuple: 61a.).

 -- クラス: inspect.Traceback

      -- の属性: filename

          The file name associated with the code being executed by the
          frame this traceback corresponds to.

      -- の属性: lineno

          The line number of the current line associated with the code
          being executed by the frame this traceback corresponds to.

      -- の属性: function

          The function name that is being executed by the frame this
          traceback corresponds to.

      -- の属性: code_context

          A list of lines of context from the source code that's being
          executed by the frame this traceback corresponds to.

      -- の属性: index

          The index of the current line being executed in the *note
          code_context: 4317. list.

      -- の属性: positions

          A *note dis.Positions: 4313. object containing the start line
          number, end line number, start column offset, and end column
          offset associated with the instruction being executed by the
          frame this traceback corresponds to.

     バージョン 3.11 で変更: ‘Traceback’ is now a class instance (that
     is backwards compatible with the previous *note named tuple: 61a.).

     注釈: フレームレコードの最初の要素などのフレームオブジェクトへの参
     照を保存すると、循環参照になってしまう場合があります。循環参照がで
     きると、Python の循環参照検出機能を有効にしていたとしても関連するオ
     ブジェクトが参照しているすべてのオブジェクトが解放されにくくなり、
     明示的に参照を削除しないとメモリ消費量が増大する恐れがあります。

     参照の削除を Python の循環参照検出機能にまかせることもできますが、
     *note finally: 997. 節で循環参照を解除すれば確実にフレーム (とその
     ローカル変数) は削除されます。また、循環参照検出機能は Python のコ
     ンパイルオプションや *note gc.disable(): 42d4. で無効とされている場
     合がありますので注意が必要です。例:

          def handle_stackframe_without_leak():
              frame = inspect.currentframe()
              try:
                  # do something with the frame
              finally:
                  del frame

     If you want to keep the frame around (for example to print a
     traceback later), you can also break reference cycles by using the
     *note frame.clear(): 261. method.

以下の関数でオプション引数 'context' には、戻り値のソース行リストに何行
分のソースを含めるかを指定します。ソース行リストには、実行中の行を中心と
して指定された行数分のリストを返します。

 -- の関数: inspect.getframeinfo (frame, context=1)

     Get information about a frame or traceback object.  A *note
     Traceback: 619. object is returned.

     バージョン 3.11 で変更: A *note Traceback: 619. object is returned
     instead of a named tuple.

 -- の関数: inspect.getouterframes (frame, context=1)

     指定したフレームと、その外側の全フレームの *note FrameInfo: 618. オ
     ブジェクトのリストを取得します。外側のフレームとは 'frame' が生成さ
     れるまでのすべての関数呼び出しを示します。戻り値のリストの先頭は
     'frame' のフレームレコードで、末尾の要素は 'frame' のスタックにある
     最も外側のフレームのフレームレコードとなります。

     バージョン 3.5 で変更: *note 名前付きタプル: 61a. ‘FrameInfo(frame,
     filename, lineno, function, code_context, index)’ のリストが返され
     ます。

     バージョン 3.11 で変更: A list of *note FrameInfo: 618. objects is
     returned.

 -- の関数: inspect.getinnerframes (traceback, context=1)

     トレースバックのフレームと、その内側の全フレームの *note FrameInfo:
     618. オブジェクトのリストを取得します。内のフレームとは 'frame' か
     ら続く一連の関数呼び出しを示します。戻り値のリストの先頭は
     'traceback' のフレームレコードで、末尾の要素は例外が発生した位置を
     示します。

     バージョン 3.5 で変更: *note 名前付きタプル: 61a. ‘FrameInfo(frame,
     filename, lineno, function, code_context, index)’ のリストが返され
     ます。

     バージョン 3.11 で変更: A list of *note FrameInfo: 618. objects is
     returned.

 -- の関数: inspect.currentframe ()

     呼び出し元のフレームオブジェクトを返します。

     'CPython 実装の詳細:' この関数はインタプリタの Python スタックフレ
     ームサポートに依存します。これは Python のすべての実装に存在してい
     る保証はありません。Python スタックフレームサポートのない環境では、
     この関数は ‘None’ を返します。

 -- の関数: inspect.stack (context=1)

     呼び出し元スタックの *note FrameInfo: 618. オブジェクトのリストを返
     します。最初の要素は呼び出し元のフレームレコードで、末尾の要素はス
     タックにある最も外側のフレームのフレームレコードとなります。

     バージョン 3.5 で変更: *note 名前付きタプル: 61a. ‘FrameInfo(frame,
     filename, lineno, function, code_context, index)’ のリストが返され
     ます。

     バージョン 3.11 で変更: A list of *note FrameInfo: 618. objects is
     returned.

 -- の関数: inspect.trace (context=1)

     実行中のフレームと処理中の例外が発生したフレームの間の *note
     FrameInfo: 618. オブジェクトのリストを返します。最初の要素は呼び出
     し元のフレームレコードで、末尾の要素は例外が発生した位置を示します
     。

     バージョン 3.5 で変更: *note 名前付きタプル: 61a. ‘FrameInfo(frame,
     filename, lineno, function, code_context, index)’ のリストが返され
     ます。

     バージョン 3.11 で変更: A list of *note FrameInfo: 618. objects is
     returned.


File: python.info,  Node: 属性の静的なフェッチ,  Next: Current State of Generators Coroutines and Asynchronous Generators,  Prev: インタープリタスタック,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.6 属性の静的なフェッチ
..............................

Both *note getattr(): b9f. and *note hasattr(): 49e. can trigger code
execution when fetching or checking for the existence of attributes.
Descriptors, like properties, will be invoked and *note __getattr__():
49f. and *note __getattribute__(): ba0. may be called.

For cases where you want passive introspection, like documentation
tools, this can be inconvenient.  *note getattr_static(): 461. has the
same signature as *note getattr(): b9f. but avoids executing code when
it fetches attributes.

 -- の関数: inspect.getattr_static (obj, attr, default=None)

     Retrieve attributes without triggering dynamic lookup via the
     descriptor protocol, *note __getattr__(): 49f. or *note
     __getattribute__(): ba0.

     Note: this function may not be able to retrieve all attributes that
     getattr can fetch (like dynamically created attributes) and may
     find attributes that getattr can't (like descriptors that raise
     AttributeError).  It can also return descriptors objects instead of
     instance members.

     If the instance *note __dict__: 526. is shadowed by another member
     (for example a property) then this function will be unable to find
     instance members.

     Added in version 3.2.

*note getattr_static(): 461. does not resolve descriptors, for example
slot descriptors or getset descriptors on objects implemented in C. The
descriptor object is returned instead of the underlying attribute.

You can handle these with code like the following.  Note that for
arbitrary getset descriptors invoking these may trigger code execution:

     # example code for resolving the builtin descriptor types
     class _foo:
         __slots__ = ['foo']

     slot_descriptor = type(_foo.foo)
     getset_descriptor = type(type(open(__file__)).name)
     wrapper_descriptor = type(str.__dict__['__add__'])
     descriptor_types = (slot_descriptor, getset_descriptor, wrapper_descriptor)

     result = getattr_static(some_object, 'foo')
     if type(result) in descriptor_types:
         try:
             result = result.__get__()
         except AttributeError:
             # descriptors can raise AttributeError to
             # indicate there is no underlying value
             # in which case the descriptor itself will
             # have to do
             pass


File: python.info,  Node: Current State of Generators Coroutines and Asynchronous Generators,  Next: Code Objects Bit Flags,  Prev: 属性の静的なフェッチ,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.7 Current State of Generators, Coroutines, and Asynchronous Generators
..............................................................................

When implementing coroutine schedulers and for other advanced uses of
generators, it is useful to determine whether a generator is currently
executing, is waiting to start or resume or execution, or has already
terminated.  *note getgeneratorstate(): 1207. allows the current state
of a generator to be determined easily.

 -- の関数: inspect.getgeneratorstate (generator)

     ジェネレータイテレータの現在の状態を取得します。

     取り得る状態は:

        * GEN_CREATED: 実行開始を待機しています。

        * GEN_RUNNING: インタープリタによって現在実行されています。

        * GEN_SUSPENDED: yield 式で現在サスペンドされています。

        * GEN_CLOSED: 実行が完了しました。

     Added in version 3.2.

 -- の関数: inspect.getcoroutinestate (coroutine)

     Get current state of a coroutine object.  The function is intended
     to be used with coroutine objects created by *note async def: 59b.
     functions, but will accept any coroutine-like object that has
     ‘cr_running’ and ‘cr_frame’ attributes.

     取り得る状態は:

        * CORO_CREATED: 実行開始を待機しています。

        * CORO_RUNNING: インタープリタにより現在実行中です。

        * CORO_SUSPENDED: await 式により現在停止中です。

        * CORO_CLOSED: 実行が完了しました。

     Added in version 3.5.

 -- の関数: inspect.getasyncgenstate (agen)

     Get current state of an asynchronous generator object.  The
     function is intended to be used with asynchronous iterator objects
     created by *note async def: 59b. functions which use the *note
     yield: 99b. statement, but will accept any asynchronous
     generator-like object that has ‘ag_running’ and ‘ag_frame’
     attributes.

     取り得る状態は:

        * AGEN_CREATED: Waiting to start execution.

        * AGEN_RUNNING: Currently being executed by the interpreter.

        * AGEN_SUSPENDED: Currently suspended at a yield expression.

        * AGEN_CLOSED: Execution has completed.

     Added in version 3.12.

ジェネレータの現在の内部状態を問い合わせることも出来ます。これは主に内部
状態が期待通り更新されているかどうかを確認するためのテストの目的に有用で
す。

 -- の関数: inspect.getgeneratorlocals (generator)

     Get the mapping of live local variables in 'generator' to their
     current values.  A dictionary is returned that maps from variable
     names to values.  This is the equivalent of calling *note locals():
     127. in the body of the generator, and all the same caveats apply.

     If 'generator' is a *note generator: 1035. with no currently
     associated frame, then an empty dictionary is returned.  *note
     TypeError: 502. is raised if 'generator' is not a Python generator
     object.

     'CPython 実装の詳細:' This function relies on the generator
     exposing a Python stack frame for introspection, which isn't
     guaranteed to be the case in all implementations of Python.  In
     such cases, this function will always return an empty dictionary.

     Added in version 3.3.

 -- の関数: inspect.getcoroutinelocals (coroutine)

     This function is analogous to *note getgeneratorlocals(): 10a9, but
     works for coroutine objects created by *note async def: 59b.
     functions.

     Added in version 3.5.

 -- の関数: inspect.getasyncgenlocals (agen)

     This function is analogous to *note getgeneratorlocals(): 10a9, but
     works for asynchronous generator objects created by *note async
     def: 59b. functions which use the *note yield: 99b. statement.

     Added in version 3.12.


File: python.info,  Node: Code Objects Bit Flags,  Next: Buffer flags,  Prev: Current State of Generators Coroutines and Asynchronous Generators,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.8 Code Objects Bit Flags
................................

Python code objects have a *note co_flags: 1ea5. attribute, which is a
bitmap of the following flags:

 -- データ: inspect.CO_OPTIMIZED

     The code object is optimized, using fast locals.

 -- データ: inspect.CO_NEWLOCALS

     If set, a new dict will be created for the frame's *note f_locals:
     167. when the code object is executed.

 -- データ: inspect.CO_VARARGS

     The code object has a variable positional parameter (‘*args’-like).

 -- データ: inspect.CO_VARKEYWORDS

     The code object has a variable keyword parameter (‘**kwargs’-like).

 -- データ: inspect.CO_NESTED

     The flag is set when the code object is a nested function.

 -- データ: inspect.CO_GENERATOR

     The flag is set when the code object is a generator function, i.e.
     a generator object is returned when the code object is executed.

 -- データ: inspect.CO_COROUTINE

     The flag is set when the code object is a coroutine function.  When
     the code object is executed it returns a coroutine object.  See PEP
     492(1) for more details.

     Added in version 3.5.

 -- データ: inspect.CO_ITERABLE_COROUTINE

     The flag is used to transform generators into generator-based
     coroutines.  Generator objects with this flag can be used in
     ‘await’ expression, and can ‘yield from’ coroutine objects.  See
     PEP 492(2) for more details.

     Added in version 3.5.

 -- データ: inspect.CO_ASYNC_GENERATOR

     The flag is set when the code object is an asynchronous generator
     function.  When the code object is executed it returns an
     asynchronous generator object.  See PEP 525(3) for more details.

     Added in version 3.6.

     注釈: The flags are specific to CPython, and may not be defined in
     other Python implementations.  Furthermore, the flags are an
     implementation detail, and can be removed or deprecated in future
     Python releases.  It's recommended to use public APIs from the
     *note inspect: 72. module for any introspection needs.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0492/

   (2) https://peps.python.org/pep-0492/

   (3) https://peps.python.org/pep-0525/


File: python.info,  Node: Buffer flags,  Next: コマンドラインインターフェイス<9>,  Prev: Code Objects Bit Flags,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.9 Buffer flags
......................

 -- クラス: inspect.BufferFlags

     This is an *note enum.IntFlag: 2255. that represents the flags that
     can be passed to the *note __buffer__(): 42b. method of objects
     implementing the *note buffer protocol: 371.

     The meaning of the flags is explained at *note
     バッファリクエストのタイプ: 1011.

      -- の属性: SIMPLE

      -- の属性: WRITABLE

      -- の属性: FORMAT

      -- の属性: ND

      -- の属性: STRIDES

      -- の属性: C_CONTIGUOUS

      -- の属性: F_CONTIGUOUS

      -- の属性: ANY_CONTIGUOUS

      -- の属性: INDIRECT

      -- の属性: CONTIG

      -- の属性: CONTIG_RO

      -- の属性: STRIDED

      -- の属性: STRIDED_RO

      -- の属性: RECORDS

      -- の属性: RECORDS_RO

      -- の属性: FULL

      -- の属性: FULL_RO

      -- の属性: READ

      -- の属性: WRITE

     Added in version 3.12.


File: python.info,  Node: コマンドラインインターフェイス<9>,  Prev: Buffer flags,  Up: inspect --- 活動中のオブジェクトを調査する

5.29.14.10 コマンドラインインターフェイス
.........................................

The *note inspect: 72. module also provides a basic introspection
capability from the command line.

By default, accepts the name of a module and prints the source of that
module.  A class or function within the module can be printed instead by
appended a colon and the qualified name of the target object.

 -- Option: --details

     Print information about the specified object rather than the source
     code


File: python.info,  Node: site --- サイト固有の設定フック,  Prev: inspect --- 活動中のオブジェクトを調査する,  Up: Python ランタイムサービス

5.29.15 ‘site’ -- サイト固有の設定フック
----------------------------------------

'ソースコード:' Lib/site.py(1)

__________________________________________________________________

'このモジュールは初期化中に自動的にインポートされます。' 自動インポート
はインタプリタの *note -S: 1179. オプションで禁止できます。

Importing this module normally appends site-specific paths to the module
search path and adds *note callables: 20ec, including *note help(): 8a5.
to the built-in namespace.  However, Python startup option *note -S:
1179. blocks this and this module can be safely imported with no
automatic modifications to the module search path or additions to the
builtins.  To explicitly trigger the usual site-specific additions, call
the *note main(): 1ca0. function.

バージョン 3.3 で変更: 以前は *note -S: 1179. を使っているときでも、モジ
ュールをインポートするとパス変更が起動されていました。

It starts by constructing up to four directories from a head and a tail
part.  For the head part, it uses ‘sys.prefix’ and ‘sys.exec_prefix’;
empty heads are skipped.  For the tail part, it uses the empty string
and then ‘lib/site-packages’ (on Windows) or
‘lib/python`X.Y[t]'/site-packages’ (on Unix and macOS). (The optional
suffix "t" indicates the *note free threading: 433e. build, and is
appended if ‘"t"’ is present in the *note sys.abiflags: a32. constant.)
For each of the distinct head-tail combinations, it sees if it refers to
an existing directory, and if so, adds it to ‘sys.path’ and also
inspects the newly added path for configuration files.

バージョン 3.5 で変更: "site-python" ディレクトリのサポートは削除されま
した。

バージョン 3.13 で変更: On Unix, *note Free threading: 433e. Python
installations are identified by the "t" suffix in the version-specific
directory name, such as ‘lib/python3.13t/’.

"pyvenv.cfg" という名前のファイルが上で挙げたディレクトリの 1 つに存在し
ていた場合、 sys.executable, sys.prefix, sys.exec_prefix にはそのディレ
クトリが設定され、 site-packages もチェックします (sys.base_prefix と
sys.base_exec_prefix は常にインストールされているPythonの "実際の" プレ
フィックスです)。 (ブートストラップの設定ファイルである) "pyvenv.cfg" で
、キー "include-system-site-packages" に "true" (大文字小文字は区別しな
い) 以外が設定されている場合は、 site-packages を探しにシステムレベルの
プレフィックスも見に行きません; そうでない場合は見に行きます。

パス設定ファイルは ‘`name'.pth’ という形式の名前をもつファイルで、上の
4つのディレクトリのひとつにあります。その内容は ‘sys.path’ に追加される
追加項目(一行に一つ)です。存在しない項目は ‘sys.path’ へは決して追加され
ませんが、項目がファイルではなくディレクトリを参照しているかどうかはチェ
ックされません。項目が ‘sys.path’ へ二回以上追加されることはありません。
空行と ‘#’ で始まる行は読み飛ばされます。 ‘import’ で始まる(そしてその後
ろにスペースかタブが続く)行は実行されます。

     注釈: ‘.pth’ ファイル内の実行可能な行は、特定のモジュールが実際に使
     用されるかどうかに関係なく、Pythonの起動時に毎回実行されます。した
     がって、その影響は最小限に抑えられるべきです。実行可能な行の主な目
     的は、対応するモジュールをインポート可能にすることです(サードパーテ
     ィ製インポートフックのロード、 ‘PATH’ の調整など)。その他の初期化は
     、モジュールが実際にインポートされたときに行われます。コードのチャ
     ンクを1行に制限することは、より複雑なものをここに入れないようにする
     ための意図的な手段です。

バージョン 3.13 で変更: ‘.pth’ ファイルは、最初に UTF-8 で、失敗した場合
は *note locale encoding: 223. でデコードされるようになります。

例えば、 ‘sys.prefix’ と ‘sys.exec_prefix’ が ‘/usr/local’ に設定されて
いると仮定します。そのときPython X.Y ライブラリは
‘/usr/local/lib/python`X.Y'’ にインストールされています。ここにはサブデ
ィレクトリ ‘/usr/local/lib/python`X.Y'/site-packages’ があり、その中に三
つのサブディレクトリ ‘foo’, ‘bar’ および ‘spam’ と二つのパス設定ファイル
‘foo.pth’ と ‘bar.pth’ をもつと仮定します。 ‘foo.pth’ には以下のものが記
載されていると想定してください:

     # foo package configuration

     foo
     bar
     bletch

また、 ‘bar.pth’ には:

     # bar package configuration

     bar

が記載されているとします。そのとき、次のバージョンごとのディレクトリが
‘sys.path’ へこの順番で追加されます:

     /usr/local/lib/pythonX.Y/site-packages/bar
     /usr/local/lib/pythonX.Y/site-packages/foo

‘bletch’ は存在しないため省略されるということに注意してください。 ‘bar’
ディレクトリは ‘foo’ ディレクトリの前に来ます。なぜなら、 ‘bar.pth’ がア
ルファベット順で ‘foo.pth’ の前に来るからです。また、 ‘spam’ はどちらの
パス設定ファイルにも記載されていないため、省略されます。

* Menu:

* sitecustomize::
* usercustomize::
* readline の設定::
* モジュールの内容: モジュールの内容<5>.
* コマンドラインインターフェイス: コマンドラインインターフェイス<10>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/site.py


File: python.info,  Node: sitecustomize,  Next: usercustomize,  Up: site --- サイト固有の設定フック

5.29.15.1 ‘sitecustomize’
.........................

これらのパス操作の後に、 *note sitecustomize: b6. という名前のモジュール
をインポートしようします。そのモジュールは任意のサイト固有のカスタマイゼ
ーションを行うことができます。典型的にはこれはシステム管理者によって
site-packages ディレクトリに作成されます。 このインポートが *note
ImportError: 3f2. またはそのサブクラス例外で失敗し、例外の *note name:
21e5. 属性が ‘'sitecustomize'’ に等しい場合は、何も表示せずに無視されま
す。Pythonが出力ストリームを利用できない状態で起動された場合、Windowsで
は ‘pythonw.exe’ (IDLEを開始するとデフォルトで使われます) のような、
*note sitecustomize: b6. から試みられた出力は無視されます。その他の例外
は黙殺され、そしてそれはおそらく不可思議な失敗にみえるでしょう。


File: python.info,  Node: usercustomize,  Next: readline の設定,  Prev: sitecustomize,  Up: site --- サイト固有の設定フック

5.29.15.2 ‘usercustomize’
.........................

このあとで、 *note ENABLE_USER_SITE: 4341. が真であれば、任意のユーザ固
有のカスタマイズを行うことが出来る *note usercustomize: f7. と名付けられ
たモジュールのインポートが試みられます。このファイルはユーザの
site-packages ディレクトリ(下記参照)に作られることを意図していて、その場
所はオプション *note -s: 1353. によって無効にされない限りは ‘sys.path’ に
含まれます。このインポートが *note ImportError: 3f2. またはそのサブクラ
ス例外で失敗し、例外の *note name: 21e5. 属性が ‘'usercustomize'’ と等し
い場合、それは黙って無視されます。

いくつかの非Unixシステムでは、 ‘sys.prefix’ と ‘sys.exec_prefix’ は空で
、パス操作は省略されます。しかし、 *note sitecustomize: b6. と *note
usercustomize: f7. のインポートはそのときでも試みられます。


File: python.info,  Node: readline の設定,  Next: モジュールの内容<5>,  Prev: usercustomize,  Up: site --- サイト固有の設定フック

5.29.15.3 readline の設定
.........................

*note readline: a8. をサポートするシステムではこのモジュールは、Python を
*note 対話モード: f93. で *note -S: 1179. オプションなしで開始した場合に
*note rlcompleter: ab. モジュールをインポートして設定します。デフォルト
の振る舞いでは、タブ補完を有効にし、履歴保存ファイルに
‘~/.python_history’ を使います。これを無効にするには、あなたの *note
sitecustomize: b6. または *note usercustomize: f7. あるいは *note
PYTHONSTARTUP: f95. ファイル内で *note sys.__interactivehook__: f94. 属
性を削除 (または上書き) してください。 (--訳注: site モジュールは *note
__interactivehook__: f94. に readline 設定関数を設定後に *note
sitecustomize: b6. 等のユーザ設定を実行します。 *note
__interactivehook__: f94. のチェックが行われるのは site モジュール実行の
後です。 --)

バージョン 3.4 で変更: rlcompleter とhistory のアクティベーションが自動
で行われるようになりました。


File: python.info,  Node: モジュールの内容<5>,  Next: コマンドラインインターフェイス<10>,  Prev: readline の設定,  Up: site --- サイト固有の設定フック

5.29.15.4 モジュールの内容
..........................

 -- データ: site.PREFIXES

     siteパッケージディレクトリのprefixのリスト。

 -- データ: site.ENABLE_USER_SITE

     ユーザサイトディレクトリのステータスを示すフラグ。 ‘True’ の場合、
     ユーザサイトディレクトリが有効で ‘sys.path’ に追加されていることを
     意味しています。 ‘False’ の場合、ユーザによるリクエスト(オプション
     *note -s: 1353. か *note PYTHONNOUSERSITE: 1354.)によって、 ‘None’
     の場合セキュリティ上の理由(ユーザまたはグループIDと実効IDの間のミス
     マッチ)あるいは管理者によって、ユーザサイトディレクトリが無効になっ
     ていることを示しています。

 -- データ: site.USER_SITE

     Path to the user site-packages for the running Python.  Can be
     ‘None’ if *note getusersitepackages(): 1211. hasn't been called
     yet.  Default value is ‘~/.local/lib/python`X.Y'[t]/site-packages’
     for UNIX and non-framework macOS builds,
     ‘~/Library/Python/`X.Y'/lib/python/site-packages’ for macOS
     framework builds, and ‘`%APPDATA%'\Python\Python`XY'\site-packages’
     on Windows.  The optional "t" indicates the free-threaded build.
     This directory is a site directory, which means that ‘.pth’ files
     in it will be processed.

 -- データ: site.USER_BASE

     ユーザの site-packages のベースとなるディレクトリへのパスです。
     *note getuserbase(): 1210. がまだ呼び出されていなければ ‘None’ かも
     しれません。デフォルト値は UNIX と frameworkなしの macOS ビルドでは
     ‘~/.local’ 、macOS framework ビルドでは ‘~/Library/Python/`X.Y'’ 、
     Windows では ‘`%APPDATA%'\Python’ です。この値は、スクリプト、デー
     タファイル、Python モジュールなどのインストール先のディレクトリを
     *note ユーザーインストールスキーム: 1cb1. で計算するのに使われます
     。 *note PYTHONUSERBASE: 1352. も参照してください。

 -- の関数: site.main ()

     モジュール検索パスに標準のサイト固有ディレクトリを追加します。この
     関数は、Python インタプリタが *note -S: 1179. で開始されていない限
     り、このモジュールインポート時に自動的に呼び出されます。

     バージョン 3.3 で変更: この関数は以前は無条件に呼び出されていました
     。

 -- の関数: site.addsitedir (sitedir, known_paths=None)

     sys.path にディレクトリを追加し、その ‘.pth’ ファイル群を処理します
     。典型的には *note sitecustomize: b6. か *note usercustomize: f7. 内
     で使われます(上述)。

 -- の関数: site.getsitepackages ()

     全てのグローバルな site-packages ディレクトリのリストを返します。

     Added in version 3.2.

 -- の関数: site.getuserbase ()

     ユーザのベースディレクトリへのパス *note USER_BASE: 12eb. を返しま
     す。未初期化であればこの関数は *note PYTHONUSERBASE: 1352. を参考に
     して、設定もします。

     Added in version 3.2.

 -- の関数: site.getusersitepackages ()

     ユーザ固有の site パッケージのディレクトリへのパス *note USER_SITE:
     1c9f. を返します。未初期化であればこの関数は *note USER_BASE: 12eb.
     を参考にして、設定もします。 ユーザ固有の site パッケージが
     ‘sys.path’ に追加されたかどうかを確認するには *note
     ENABLE_USER_SITE: 4341. を使ってください。

     Added in version 3.2.


File: python.info,  Node: コマンドラインインターフェイス<10>,  Prev: モジュールの内容<5>,  Up: site --- サイト固有の設定フック

5.29.15.5 コマンドラインインターフェイス
........................................

*note site: b5. モジュールはユーザディレクトリをコマンドラインから得る手
段も提供しています:

     $ python -m site --user-site
     /home/user/.local/lib/python3.11/site-packages

引数なしで呼び出された場合、*note sys.path: 38e. の中身を表示し、続けて
*note USER_BASE: 12eb. とそのディレクトリが存在するかどうか、 *note
USER_SITE: 1c9f. とそのディレクトリが存在するかどうか、最後に *note
ENABLE_USER_SITE: 4341. の値を、標準出力に出力します。

 -- Option: --user-base

     ユーザのベースディレクトリを表示します。

 -- Option: --user-site

     ユーザの site-packages ディレクトリを表示します。

両方のオプションが指定された場合、ユーザのベースとユーザの site が(常に
この順序で) *note os.pathsep: 1cae. 区切りで表示されます。

いずれかのオプションが与えられた場合に、このスクリプトは次のいずれかの終
了コードで終了します: ユーザの site-packages が有効ならば ‘0’ 、ユーザに
より無効にされていれば ‘1’ 、セキュリティ的な理由あるいは管理者によって
無効にされている場合 ‘2’ 、そして何かエラーがあった場合は 2 より大きな値
。

参考
....

   * PEP 370(1) - ユーザごとの ‘site-packages’ ディレクトリ

   * *note sys.path モジュール検索パスの初期化: 1bca. - *note sys.path:
     38e.  の初期化。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0370/


File: python.info,  Node: カスタム Python インタプリタ,  Next: モジュールのインポート,  Prev: Python ランタイムサービス,  Up: Python 標準ライブラリ

5.30 カスタム Python インタプリタ
=================================

この章で解説されるモジュールで Python の対話型インタープリターに似たイン
ターフェースを書くことができます。もし Python そのもの以外に何か特殊な機
能をサポートした Python インタープリターを作りたければ、 *note code: 13.
モジュールを参照してください。 (*note codeop: 15. モジュールはより低レベ
ルで、不完全かもしれない Python コード断片のコンパイルをサポートするため
に使われます。)

この章で解説されるモジュールの完全な一覧は:

* Menu:

* code: code --- インタープリター基底クラス. インタープリター基底クラス
* codeop: codeop --- Python コードをコンパイルする. Python コードをコンパイルする


File: python.info,  Node: code --- インタープリター基底クラス,  Next: codeop --- Python コードをコンパイルする,  Up: カスタム Python インタプリタ

5.30.1 ‘code’ -- インタープリター基底クラス
-------------------------------------------

'ソースコード:' Lib/code.py(1)

__________________________________________________________________

‘code’ モジュールはread-eval-print (読み込み-評価-表示)ループをPythonで
実装するための機能を提供します。対話的なインタプリタプロンプトを提供する
アプリケーションを作るために使える二つのクラスと便利な関数が含まれていま
す。

 -- クラス: code.InteractiveInterpreter (locals=None)

     このクラスは構文解析とインタープリター状態(ユーザの名前空間)を取り
     扱います。入力バッファリングやプロンプト出力、または入力ファイル指
     定を扱いません(ファイル名は常に明示的に渡されます)。オプションの
     'locals' 引数はその中でコードが実行される名前空間として使用されるマ
     ッピングを指定します。その初期値は、キー ‘'__name__'’ が
     ‘'__console__'’ に設定され、キー ‘'__doc__'’ が ‘None’ に設定された
     新しく作られた辞書です。

 -- クラス: code.InteractiveConsole (locals=None, filename='<console>',
          local_exit=False)

     Python の対話型インタープリターの振る舞いを忠実にエミュレートします
     。このクラスは *note InteractiveInterpreter: 153c. を継承しており、
     よく知られた ‘sys.ps1’ と ‘sys.ps2’ を使用してプロンプトと入力バッ
     ファリングを追加します。 'local_exit' が真の場合、コンソールでの
     ‘exit()’ と ‘quit()’ は *note SystemExit: d0e. を送出せず、代わりに
     呼び出し元のコードに戻ります。

     バージョン 3.13 で変更: 'local_exit' 引数が追加されました。

 -- の関数: code.interact (banner=None, readfunc=None, local=None,
          exitmsg=None, local_exit=False)

     read-eval-print ループを実行するための便利な関数。これは *note
     InteractiveConsole: 22f8. の新しいインスタンスを作り、 'readfunc' が
     与えられた場合は *note InteractiveConsole.raw_input(): 434f. メソッ
     ドとして使われるように設定します。 'local' が与えられた場合は、イン
     タープリターループのデフォルト名前空間として使うために *note
     InteractiveConsole: 22f8. コンストラクタへ渡されます。 'local_exit'
     が与えられた場合は、 *note InteractiveConsole: 22f8. コンストラクタ
     へ渡されます。そして、インスタンスの *note interact(): 4350. メソッ
     ドは、もし提供されていれば、見出しと終了メッセージして使うために
     'banner' と 'exitmsg' を受け取り実行されます。コンソールオブジェク
     トは使われた後捨てられます。

     バージョン 3.6 で変更: 'exitmsg' 引数が追加されました.

     バージョン 3.13 で変更: 'local_exit' 引数が追加されました。

 -- の関数: code.compile_command (source, filename='<input>',
          symbol='single')

     この関数はPythonのインタプリタメインループ(別名、read-eval-printル
     ープ)をエミュレートしようとするプログラムにとって役に立ちます。扱い
     にくい部分は、ユーザが(完全なコマンドや構文エラーではなく)さらにテ
     キストを入力すれば完全になりうる不完全なコマンドを入力したときを決
     定することです。この関数は 'ほとんど' の場合に実際のインタプリタメ
     インループと同じ決定を行います。

     'source' はソース文字列です。'filename' はオプションのソースが読み
     出されたファイル名で、デフォルトで ‘'<input>'’ です。'symbol' はオ
     プションの文法の開始記号で、‘'single'’ (デフォルト)または ‘'eval'’
     か ‘'exec'’ にすべきです。

     コマンドが完全で有効ならば、コードオブジェクトを返します
     (‘compile(source, filename, symbol)’ と同じ)。コマンドが完全でない
     ならば、 ‘None’ を返します。コマンドが完全で構文エラーを含む場合は
     、 *note SyntaxError: 172. を発生させます。または、コマンドが無効な
     リテラルを含む場合は、 *note OverflowError: 84e. もしくは *note
     ValueError: 1e3. を発生させます。

* Menu:

* 対話的なインタプリタオブジェクト::
* 対話的なコンソールオブジェクト::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/code.py


File: python.info,  Node: 対話的なインタプリタオブジェクト,  Next: 対話的なコンソールオブジェクト,  Up: code --- インタープリター基底クラス

5.30.1.1 対話的なインタプリタオブジェクト
.........................................

 -- メソッド: InteractiveInterpreter.runsource (source,
          filename='<input>', symbol='single')

     インタプリタ内のあるソースをコンパイルし実行します。引数は *note
     compile_command(): 4351. のものと同じです。 'filename' のデフォルト
     は ‘'<input>'’ で、 'symbol' は ‘'single'’ です。あるいくつかのこと
     が起きる可能性があります:

        * 入力が不正。 *note compile_command(): 4351. が例外(*note
          SyntaxError: 172. か *note OverflowError: 84e.)を起こした場合
          。 *note showsyntaxerror(): 4355. メソッドの呼び出によって、構
          文トレースバックが表示されるでしょう。 *note runsource():
          4354. は ‘False’ を返します。

        * 入力が完全でなく、さらに入力が必要。 *note compile_command():
          4351. が ‘None’ を返した場合。 *note runsource(): 4354. は
          ‘True’ を返します。

        * 入力が完全。 *note compile_command(): 4351. がコードオブジェク
          トを返した場合。 (*note SystemExit: d0e. を除く実行時例外も処
          理する) *note runcode(): 4356. を呼び出すことによって、コード
          は実行されます。 *note runsource(): 4354. は ‘False’ を返しま
          す。

     戻り値は、次の行のプロンプトに ‘sys.ps1’ か ‘sys.ps2’ のどちらを使
     うのか判断するために使えます。

 -- メソッド: InteractiveInterpreter.runcode (code)

     コードオブジェクトを実行します。例外が生じたときは、トレースバック
     を表示するために *note showtraceback(): d9d. が呼び出されます。伝搬
     することが許されている *note SystemExit: d0e. を除くすべての例外が
     捉えられます。

     *note KeyboardInterrupt: 99f. についての注意。このコードの他の場所
     でこの例外が生じる可能性がありますし、常に捕らえることができるとは
     限りません。呼び出し側はそれを処理するために準備しておくべきです。

 -- メソッド: InteractiveInterpreter.showsyntaxerror (filename=None)

     起きたばかりの構文エラーを表示します。複数の構文エラーに対して一つ
     あるのではないため、これはスタックトレースを表示しません。
     'filename' が与えられた場合は、Pythonのパーサが与えるデフォルトのフ
     ァイル名の代わりに例外の中へ入れられます。なぜなら、文字列から読み
     込んでいるときはパーサは常に ‘'<string>'’ を使うからです。出力は
     *note write(): 4357. メソッドによって書き込まれます。

 -- メソッド: InteractiveInterpreter.showtraceback ()

     起きたばかりの例外を表示します。スタックの最初の項目を取り除きます
     。なぜなら、それはインタプリタオブジェクトの実装の内部にあるからで
     す。出力は *note write(): 4357. メソッドによって書き込まれます。

     バージョン 3.5 で変更: 最初のトレースバックではなく、完全なトレース
     バックの連鎖が表示されます。

 -- メソッド: InteractiveInterpreter.write (data)

     文字列を標準エラーストリーム(‘sys.stderr’)へ書き込みます。必要に応
     じて適切な出力処理を提供するために、派生クラスはこれをオーバーライ
     ドすべきです。


File: python.info,  Node: 対話的なコンソールオブジェクト,  Prev: 対話的なインタプリタオブジェクト,  Up: code --- インタープリター基底クラス

5.30.1.2 対話的なコンソールオブジェクト
.......................................

*note InteractiveConsole: 22f8. クラスは *note InteractiveInterpreter:
153c. のサブクラスです。以下の追加メソッドだけでなく、インタプリタオブジ
ェクトのすべてのメソッドも提供します。

 -- メソッド: InteractiveConsole.interact (banner=None, exitmsg=None)

     対話的な Python コンソールをそっくりにエミュレートします。オプショ
     ンの 'banner' 引数は最初のやりとりの前に表示するバナーを指定します
     。デフォルトでは、標準 Python インタプリタが表示するものと同じよう
     なバナーを表示します。それに続けて、実際のインタプリタと混乱しない
     ように (とても似ているから!)  括弧の中にコンソールオブジェクトのク
     ラス名を表示します。

     オプション引数の 'exitmsg' は、終了時に出力される終了メッセージを指
     定します。空文字列を渡すと、出力メッセージを抑止します。もし、
     'exitmsg' が与えられないか、‘None’ の場合は、デフォルトのメッセージ
     が出力されます。

     バージョン 3.4 で変更: バナーの表示を抑制するには、空の文字列を渡し
     てください。

     バージョン 3.6 で変更: 終了時に、終了メッセージを表示します。

 -- メソッド: InteractiveConsole.push (line)

     ソーステキストの一行をインタープリターへ送ります。その行の末尾に改
     行がついていてはいけません。内部に改行を持っているかもしれません。
     その行はバッファへ追加され、ソースとして連結されたバッファの内容が
     渡されインタープリターの *note runsource(): 4354. メソッドが呼び出
     されます。コマンドが実行されたか、有効であることをこれが示している
     場合は、バッファはリセットされます。そうでなければ、コマンドが不完
     全で、その行が付加された後のままバッファは残されます。さらに入力が
     必要ならば、戻り値は ‘True’ です。その行がある方法で処理されたなら
     ば、 ‘False’ です(これは ‘runsource()’ と同じです)。

 -- メソッド: InteractiveConsole.resetbuffer ()

     入力バッファから処理されていないソーステキストを取り除きます。

 -- メソッド: InteractiveConsole.raw_input (prompt='')

     プロンプトを書き込み、一行を読み込みます。返る行は末尾に改行を含み
     ません。ユーザがEOFキーシーケンスを入力したときは、 *note EOFError:
     12a7. を発生させます。基本実装では、 ‘sys.stdin’ から読み込みます。
     サブクラスはこれを異なる実装と置き換えるかもしれません。


File: python.info,  Node: codeop --- Python コードをコンパイルする,  Prev: code --- インタープリター基底クラス,  Up: カスタム Python インタプリタ

5.30.2 ‘codeop’ -- Python コードをコンパイルする
------------------------------------------------

'ソースコード:' Lib/codeop.py(1)

__________________________________________________________________

*note codeop: 15. モジュールは、 *note code: 13. モジュールで行われてい
るようなPythonの read-eval-printループをエミュレートするユーティリティを
提供します。そのため、このモジュールを直接利用する場面はあまり無いでしょ
う。プログラムにこのようなループを含めたい場合は、 *note code: 13. モジ
ュールの方が便利です。

この仕事には二つの部分があります:

  1. 入力の一行がPythonの文として完全であるかどうかを見分けられること: 簡
     単に言えば、次が '‘>>>’' か、あるいは '‘...’' かどうかを見分けます
     。

  2. どのfuture文をユーザが入力したのかを覚えていること。したがって、実
     質的にそれに続く入力をこれらとともにコンパイルすることができます。

*note codeop: 15. モジュールはこうしたことのそれぞれを行う方法とそれら両
方を行う方法を提供します。

前者は実行するには:

 -- の関数: codeop.compile_command (source, filename='<input>',
          symbol='single')

     Pythonコードの文字列であるべき 'source' をコンパイルしてみて、
     'source' が有効なPythonコードの場合はコードオブジェクトを返します。
     このような場合、コードオブジェクトのファイル名属性は、デフォルトで
     ‘'<input>'’ である 'filename' でしょう。'source' が有効なPythonコー
     ドでは 'ない' が、有効なPythonコードの接頭語である場合には、‘None’
     を返します。

     'source' に問題がある場合は、例外を発生させます。無効なPython構文が
     ある場合は、 *note SyntaxError: 172. を発生させます。また、無効なリ
     テラルがある場合は、 *note OverflowError: 84e. または *note
     ValueError: 1e3. を発生させます。

     'symbol' 引数は 'source' が文としてコンパイルされるか(‘'single'’ 、
     デフォルト) 、*note 文: 26d2. のシーケンスとしてか (‘'exec'’) 、ま
     たは *note 式: 1ee6. としてコンパイルされるかを決定します
     (‘'eval'’)。他のどんな値も *note ValueError: 1e3. を送出させます。

          注釈: ソースの終わりに達する前に、成功した結果をもってパーサは
          構文解析を止めることがあります。このような場合、後ろに続く記号
          はエラーとならずに無視されます。例えば、バックスラッシュの後ろ
          に改行が2つあって、その後ろにゴミがあるかもしれません。パーサ
          のAPIがより良くなればすぐに、この挙動は修正されるでしょう。

 -- クラス: codeop.Compile

     このクラスのインスタンスは組み込み関数 *note compile(): 177. とシグ
     ネチャが一致する *note __call__(): 523. メソッドを持っていますが、
     インスタンスが *note __future__: 0. 文を含むプログラムテキストをコ
     ンパイルする場合は、インスタンスは有効なその文とともに続くすべての
     プログラムテキストを'覚えていて'コンパイルするという違いがあります
     。

 -- クラス: codeop.CommandCompiler

     このクラスのインスタンスは *note compile_command(): 1733. とシグネ
     チャが一致する *note __call__(): 523. メソッドを持っています。イン
     スタンスが *note __future__: 0. 文を含むプログラムテキストをコンパ
     イルする場合に、インスタンスは有効なその文とともにそれに続くすべて
     のプログラムテキストを'覚えていて'コンパイルするという違いがありま
     す。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/codeop.py


File: python.info,  Node: モジュールのインポート,  Next: Python言語サービス,  Prev: カスタム Python インタプリタ,  Up: Python 標準ライブラリ

5.31 モジュールのインポート
===========================

この章で解説されるモジュールは他のPythonモジュールをインポートする新しい
方法と、インポート処理をカスタマイズするためのフックを提供します。

この章で解説されるモジュールの完全な一覧は:

* Menu:

* zipimport: zipimport --- Zip アーカイブからモジュールをインポートする. Zip アーカイブからモジュールをインポートする
* pkgutil: pkgutil --- パッケージ拡張ユーティリティ. パッケージ拡張ユーティリティ
* modulefinder: modulefinder --- スクリプト中で使用されているモジュールの検索. スクリプト中で使用されているモジュールの検索
* runpy: runpy --- Python モジュールの位置特定と実行. Python モジュールの位置特定と実行
* importlib: importlib --- import の実装. import の実装
* importlib.resources: importlib resources -- パッケージリソースの読み取り、オープン、アクセス. パッケージリソースの読み取り、オープン、アクセス
* importlib.resources.abc: importlib resources abc -- リソースの抽象基底クラス. リソースの抽象基底クラス
* importlib.metadata: importlib metadata -- パッケージメタデータへのアクセス. パッケージメタデータへのアクセス
* sys.path モジュール検索パスの初期化: sys path モジュール検索パスの初期化.


File: python.info,  Node: zipimport --- Zip アーカイブからモジュールをインポートする,  Next: pkgutil --- パッケージ拡張ユーティリティ,  Up: モジュールのインポート

5.31.1 ‘zipimport’ -- Zip アーカイブからモジュールをインポートする
------------------------------------------------------------------

'ソースコード:' Lib/zipimport.py(1)

__________________________________________________________________

このモジュールは、 Python モジュール (‘*.py’, ‘*.pyc’) やパッケージを
ZIP 形式のアーカイブから import できるようにします。通常、 *note
zipimport: 118. を明示的に使う必要はありません; 組み込みの *note import:
5ac. は、 *note sys.path: 38e. の要素が ZIP アーカイブへのパスを指してい
る場合にこのモジュールを自動的に使います。

普通、 *note sys.path: 38e. はディレクトリ名の文字列からなるリストです。
このモジュールを使うと、 *note sys.path: 38e. の要素に ZIP ファイルアー
カイブを示す文字列を使えるようになります。ZIP アーカイブにはサブディレク
トリ構造を含めることができ、パッケージの import をサポートさせたり、アー
カイブ内のパスを指定してサブディレクトリ下から import を行わせたりできま
す。例えば、 ‘example.zip/lib/’ のように指定すると、アーカイブ中の
‘lib/’ サブディレクトリ下だけから import を行います。

ZIP アーカイブ内にはどんなファイルを置いてもかまいませんが、インポートは
‘.py’ および ‘.pyc’ ファイルにのみ呼び出されます。動的モジュール
(‘.pyd’, ‘.so’) の ZIP インポートは行えません。アーカイブ内に ‘.py’ ファ
イルしかない場合、 Python は対応する ‘.pyc’ ファイルを追加してアーカイブ
を変更しようとはしません。つまり、 ZIP アーカイブ内に ‘.pyc’ がない場合
は、インポートが多少遅くなるかもしれないので注意してください。

バージョン 3.13 で変更: ZIP64 is supported

バージョン 3.8 で変更: 以前は、アーカイブコメント付きの ZIP アーカイブは
サポートされていませんでした。

参考
....

PKZIP Application Note(2)

     ZIP ファイルフォーマットおよびアルゴリズムを作成した Phil Katz によ
     るドキュメント。

PEP 273(3) - Zip アーカイブからモジュールをインポートする

     このモジュールの実装も行った、James C. Ahlstrom による PEP です。
     Python 2.3 は PEP 273(4) の仕様に従っていますが、Just van Rossum の
     書いた import フックによる実装を使っています。インポートフックは
     PEP 302(5) で解説されています。

*note importlib: 6b. - *note import: 5ac. の実装

     Package providing the relevant protocols for all importers to
     implement.

このモジュールでは例外を一つ定義しています:

 -- 例外: zipimport.ZipImportError

     zipimporter オブジェクトが送出する例外です。 *note ImportError:
     3f2. のサブクラスなので、 *note ImportError: 3f2. としても捕捉でき
     ます。

* Menu:

* zipimporter オブジェクト::
* 使用例: 使用例<46>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/zipimport.py

   (2) https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

   (3) https://peps.python.org/pep-0273/

   (4) https://peps.python.org/pep-0273/

   (5) https://peps.python.org/pep-0302/


File: python.info,  Node: zipimporter オブジェクト,  Next: 使用例<46>,  Up: zipimport --- Zip アーカイブからモジュールをインポートする

5.31.1.1 zipimporter オブジェクト
.................................

*note zipimporter: 4368. は ZIP ファイルを import するためのクラスです。

 -- クラス: zipimport.zipimporter (archivepath)

     新たな zipimporter インスタンスを生成します。 'archivepath' は ZIP
     ファイルへのパスまたは ZIP ファイル中の特定のパスへのパスでなければ
     なりません。たとえば、 ‘foo/bar.zip/lib’ という 'archivepath' の場
     合、 ‘foo/bar.zip’ という ZIP ファイルの中の ‘lib’ ディレクトリにあ
     るモジュールを (存在するものとして) 検索します。

     'archivepath' が有効な ZIP アーカイブを指していない場合、 *note
     ZipImportError: 4365. を送出します。

     バージョン 3.12 で変更: Methods ‘find_loader()’ and
     ‘find_module()’, deprecated in 3.10 are now removed.  Use *note
     find_spec(): 829. instead.

      -- メソッド: create_module (spec)

          Implementation of *note importlib.abc.Loader.create_module():
          c7c. that returns *note None: 641. to explicitly request the
          default semantics.

          Added in version 3.10.

      -- メソッド: exec_module (module)

          *note importlib.abc.Loader.exec_module(): 836. の実装です。

          Added in version 3.10.

      -- メソッド: find_spec (fullname, target=None)

          *note importlib.abc.PathEntryFinder.find_spec(): 838. の実装で
          す。

          Added in version 3.10.

      -- メソッド: get_code (fullname)

          'fullname' に指定したモジュールのコードオブジェクトを返します
          。モジュールがインポートできなかった場合には *note
          ZipImportError: 4365. を送出します。

      -- メソッド: get_data (pathname)

          'pathname' に関連付けられたデータを返します。該当するファイル
          が見つからなかった場合には *note OSError: 3f0. を送出します。

          バージョン 3.3 で変更: 以前は *note IOError: 1026. が送出され
          ました; それは現在 *note OSError: 3f0. のエイリアスです。

      -- メソッド: get_filename (fullname)

          指定されたモジュールが import された場合、そのモジュールに設定
          した ‘__file__’ の値を返します。モジュールがインポートできなか
          った場合、 *note ZipImportError: 4365. を送出します。

          Added in version 3.1.

      -- メソッド: get_source (fullname)

          'fullname' で指定されたモジュールのソースコードを返します。モ
          ジュールが見つからない場合、*note ZipImportError: 4365. を送出
          します。アーカイブにはモジュールがあるもののソースコードがない
          場合、 *note None: 641. を返します。

      -- メソッド: is_package (fullname)

          'fullname' で指定されたモジュールがパッケージの場合 ‘True’ を
          返します。モジュールを見つけられない場合 *note ZipImportError:
          4365. を送出します。

      -- メソッド: load_module (fullname)

          Load the module specified by 'fullname'.  'fullname' must be
          the fully qualified (dotted) module name.  Returns the
          imported module on success, raises *note ZipImportError: 4365.
          on failure.

          バージョン 3.10 で非推奨: 代わりに *note exec_module(): 2ea. を
          使用してください。

      -- メソッド: invalidate_caches ()

          Clear out the internal cache of information about files found
          within the ZIP archive.

          Added in version 3.10.

      -- の属性: archive

          importer に関連付けられた ZIP ファイルのファイル名です。サブパ
          スは含まれません。

      -- の属性: prefix

          モジュールを検索する ZIP ファイル中のサブパスです。この文字列
          は ZIP ファイルのルートを指している zipimporter オブジェクトで
          は空です。

     スラッシュでつなげると、*note archive: 436e. と *note prefix: 436f.
     属性は *note zipimporter: 4368. コンストラクタに渡された元々の
     'archivepath' 引数と等しくなります。


File: python.info,  Node: 使用例<46>,  Prev: zipimporter オブジェクト,  Up: zipimport --- Zip アーカイブからモジュールをインポートする

5.31.1.2 使用例
...............

モジュールを ZIP アーカイブから import する例を以下に示します - *note
zipimport: 118. モジュールが明示的に使われていないことに注意してください
。

     $ unzip -l example.zip
     Archive:  example.zip
       Length     Date   Time    Name
      --------    ----   ----    ----
          8467  11-26-02 22:30   jwzthreading.py
      --------                   -------
          8467                   1 file
     $ ./python
     Python 2.3 (#1, Aug 1 2003, 19:54:32)
     >>> import sys
     >>> sys.path.insert(0, 'example.zip')  # Add .zip file to front of path
     >>> import jwzthreading
     >>> jwzthreading.__file__
     'example.zip/jwzthreading.py'


File: python.info,  Node: pkgutil --- パッケージ拡張ユーティリティ,  Next: modulefinder --- スクリプト中で使用されているモジュールの検索,  Prev: zipimport --- Zip アーカイブからモジュールをインポートする,  Up: モジュールのインポート

5.31.2 ‘pkgutil’ -- パッケージ拡張ユーティリティ
------------------------------------------------

'ソースコード:' Lib/pkgutil.py(1)

__________________________________________________________________

このモジュールはインポートシステムの、特にパッケージサポートに関するユー
ティリティです。

 -- クラス: pkgutil.ModuleInfo (module_finder, name, ispkg)

     モジュールの概要情報を格納する namedtuple

     Added in version 3.6.

 -- の関数: pkgutil.extend_path (path, name)

     パッケージを構成するモジュールの検索パスを拡張します。パッケージの
     ‘__init__.py’ で次のように書くことを意図したものです:

          from pkgutil import extend_path
          __path__ = extend_path(__path__, __name__)

     For each directory on *note sys.path: 38e. that has a subdirectory
     that matches the package name, add the subdirectory to the
     package's *note __path__: 1bd8.  This is useful if one wants to
     distribute different parts of a single logical package as multiple
     directories.

     It also looks for ‘*.pkg’ files beginning where ‘*’ matches the
     'name' argument.  This feature is similar to ‘*.pth’ files (see the
     *note site: b5. module for more information), except that it
     doesn't special-case lines starting with ‘import’.  A ‘*.pkg’ file
     is trusted at face value: apart from skipping blank lines and
     ignoring comments, all entries found in a ‘*.pkg’ file are added to
     the path, regardless of whether they exist on the filesystem (this
     is a feature).

     入力パスがリストでない場合(フリーズされたパッケージのとき)は何もせ
     ずにリターンします。入力パスが変更されていなければ、アイテムを末尾
     に追加しただけのコピーを返します。

     *note sys.path: 38e. はシーケンスであることが前提になっています。
     *note sys.path: 38e. の要素の内、実在するディレクトリを指す文字列と
     なっていないものは無視されます。ファイル名として使ったときにエラー
     が発生する *note sys.path: 38e. の Unicode要素がある場合、この関数
     (*note os.path.isdir(): 9de. を実行している行) で例外が発生する可能
     性があります。

 -- の関数: pkgutil.find_loader (fullname)

     'fullname' に対するモジュール *note loader: 1614. オブジェクトを取
     得します。

     これは後方互換性のために提供している *note
     importlib.util.find_spec(): 2ae. へのラッパーで、そこでのほどんどの
     失敗を *note ImportError: 3f2. に変換し、完全な *note
     importlib.machinery.ModuleSpec: 1dcb. を返す代わりにローダのみを返
     しています。

     バージョン 3.3 で変更: パッケージ内部の PEP 302(2) エミュレーション
     に依存するのではなく直接的に *note importlib: 6b. に基くように更新
     されました。

     バージョン 3.4 で変更: PEP 451(3) ベースに更新されました。

     Deprecated since version 3.12, will be removed in version 3.14: 代
     わりに *note importlib.util.find_spec(): 2ae. を使用してください。

 -- の関数: pkgutil.get_importer (path_item)

     指定された 'path_item' に対する *note finder: 1e7e. を取得します。

     path hook により新しい finder が作成された場合は、それは *note
     sys.path_importer_cache: 5ae. にキャッシュされます。

     キャッシュ (やその一部) は、 *note sys.path_hooks: fee. のリスキャ
     ンが必要になった場合は手動でクリアすることができます。

     バージョン 3.3 で変更: パッケージ内部の PEP 302(4) エミュレーション
     に依存するのではなく直接的に *note importlib: 6b. に基くように更新
     されました。

 -- の関数: pkgutil.get_loader (module_or_name)

     'module_or_name' に対する *note loader: 1614. オブジェクトを取得し
     ます。

     module か package が通常の import 機構によってアクセスできる場合、
     その機構の該当部分に対するラッパーを返します。モジュールが見つから
     なかったり import できない場合は ‘None’ を返します。その名前のモジ
     ュールがまだ import されていない場合、そのモジュールを含むパッケー
     ジが(あれば)そのパッケージの ‘__path__’ を確立するために import さ
     れます。

     バージョン 3.3 で変更: パッケージ内部の PEP 302(5) エミュレーション
     に依存するのではなく直接的に *note importlib: 6b. に基くように更新
     されました。

     バージョン 3.4 で変更: PEP 451(6) ベースに更新されました。

     Deprecated since version 3.12, will be removed in version 3.14: 代
     わりに *note importlib.util.find_spec(): 2ae. を使用してください。

 -- の関数: pkgutil.iter_importers (fullname='')

     Yield *note finder: 1e7e. objects for the given module name.

     If fullname contains a ‘'.'’, the finders will be for the package
     containing fullname, otherwise they will be all registered top
     level finders (i.e.  those on both *note sys.meta_path: cf9. and
     *note sys.path_hooks: fee.).

     その名前のついたモジュールがパッケージ内に含まれている場合、この関
     数を実行した副作用としてそのパッケージが import されます。

     モジュール名が指定されない場合は全てのトップレベルの finder が生成
     されます。

     バージョン 3.3 で変更: パッケージ内部の PEP 302(7) エミュレーション
     に依存するのではなく直接的に *note importlib: 6b. に基くように更新
     されました。

 -- の関数: pkgutil.iter_modules (path=None, prefix='')

     'path' を指定すればそのすべてのサブモジュールに対して、 'path' が
     ‘None’ なら *note sys.path: 38e. のすべてのトップレベルモジュールに
     対して、*note ModuleInfo: d19. を yield します。

     'path' は ‘None’ か、モジュールを検索する path のリストのどちらかで
     なければなりません。

     'prefix' は出力の全てのモジュール名の頭に出力する文字列です。

          注釈: これは ‘iter_modules()’ メソッドを定義している *note
          finder: 1e7e. に対してのみ動作します。このインターフェイスは非
          標準なので、モジュールは *note importlib.machinery.FileFinder:
          1047. と *note zipimport.zipimporter: 4368. の実装も提供します
          。

     バージョン 3.3 で変更: パッケージ内部の PEP 302(8) エミュレーション
     に依存するのではなく直接的に *note importlib: 6b. に基くように更新
     されました。

 -- の関数: pkgutil.walk_packages (path=None, prefix='', onerror=None)

     'path' を指定すれば再帰的にその中のモジュールすべてに対して、
     'path' が ‘None’ ならばアクセスできるすべてのモジュールに対して、
     *note ModuleInfo: d19. を yield します。

     'path' は ‘None’ か、モジュールを検索する path のリストのどちらかで
     なければなりません。

     'prefix' は出力の全てのモジュール名の頭に出力する文字列です。

     この関数は与えられた 'path' 上の全ての 'パッケージ' (全てのモジュー
     ル 'ではない') を、サブモジュールを検索するのに必要な ‘__path__’ 属
     性にアクセスするために import します。

     'onerror' は、パッケージを import しようとしたときに何かの例外が発
     生した場合に、 1つの引数 (import しようとしていたパッケージの名前)
     で呼び出される関数です。 'onerror' 関数が提供されない場合、 *note
     ImportError: 3f2. は補足され無視されます。それ以外の全ての例外は伝
     播し、検索を停止させます。

     例:

          # list all modules python can access
          walk_packages()

          # list all submodules of ctypes
          walk_packages(ctypes.__path__, ctypes.__name__ + '.')

          注釈: これは ‘iter_modules()’ メソッドを定義している *note
          finder: 1e7e. に対してのみ動作します。このインターフェイスは非
          標準なので、モジュールは *note importlib.machinery.FileFinder:
          1047. と *note zipimport.zipimporter: 4368. の実装も提供します
          。

     バージョン 3.3 で変更: パッケージ内部の PEP 302(9) エミュレーション
     に依存するのではなく直接的に *note importlib: 6b. に基くように更新
     されました。

 -- の関数: pkgutil.get_data (package, resource)

     パッケージからリソースを取得します。

     この関数は *note loader: 1614. *note get_data: 4376. API のラッパー
     です。 'package' 引数は標準的なモジュール形式 (‘foo.bar’) のパッケ
     ージ名でなければなりません。 'resource' 引数は ‘/’ をパス区切りに使
     った相対ファイル名の形式です。親ディレクトリを ‘..’ としたり、ルー
     トからの (‘/’ で始まる) 名前を使うことはできません。

     この関数が返すのは指定されたリソースの内容であるバイナリ文字列です
     。

     ファイルシステム中に位置するパッケージで既にインポートされているも
     のに対しては、次と大体同じです:

          d = os.path.dirname(sys.modules[package].__file__)
          data = open(os.path.join(d, resource), 'rb').read()

     If the package cannot be located or loaded, or it uses a *note
     loader: 1614. which does not support *note get_data: 4376, then
     ‘None’ is returned.  In particular, the *note loader: 1614. for
     *note namespace packages: 1bd2. does not support *note get_data:
     4376.

 -- の関数: pkgutil.resolve_name (name)

     Resolve a name to an object.

     This functionality is used in numerous places in the standard
     library (see bpo-12915(10)) - and equivalent functionality is also
     in widely used third-party packages such as setuptools, Django and
     Pyramid.

     It is expected that 'name' will be a string in one of the following
     formats, where W is shorthand for a valid Python identifier and dot
     stands for a literal period in these pseudo-regexes:

        * ‘W(.W)*’

        * ‘W(.W)*:(W(.W)*)?’

     The first form is intended for backward compatibility only.  It
     assumes that some part of the dotted name is a package, and the
     rest is an object somewhere within that package, possibly nested
     inside other objects.  Because the place where the package stops
     and the object hierarchy starts can't be inferred by inspection,
     repeated attempts to import must be done with this form.

     In the second form, the caller makes the division point clear
     through the provision of a single colon: the dotted name to the
     left of the colon is a package to be imported, and the dotted name
     to the right is the object hierarchy within that package.  Only one
     import is needed in this form.  If it ends with the colon, then a
     module object is returned.

     The function will return an object (which might be a module), or
     raise one of the following exceptions:

     *note ValueError: 1e3. - if 'name' isn't in a recognised format.

     *note ImportError: 3f2. - if an import failed when it shouldn't
     have.

     *note AttributeError: 326. - If a failure occurred when traversing
     the object hierarchy within the imported package to get to the
     desired object.

     Added in version 3.9.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pkgutil.py

   (2) https://peps.python.org/pep-0302/

   (3) https://peps.python.org/pep-0451/

   (4) https://peps.python.org/pep-0302/

   (5) https://peps.python.org/pep-0302/

   (6) https://peps.python.org/pep-0451/

   (7) https://peps.python.org/pep-0302/

   (8) https://peps.python.org/pep-0302/

   (9) https://peps.python.org/pep-0302/

   (10) https://bugs.python.org/issue?@action=redirect&bpo=12915


File: python.info,  Node: modulefinder --- スクリプト中で使用されているモジュールの検索,  Next: runpy --- Python モジュールの位置特定と実行,  Prev: pkgutil --- パッケージ拡張ユーティリティ,  Up: モジュールのインポート

5.31.3 ‘modulefinder’ -- スクリプト中で使用されているモジュールの検索
---------------------------------------------------------------------

'ソースコード:' Lib/modulefinder.py(1)

__________________________________________________________________

このモジュールでは、スクリプト中で import されているモジュールセットを調
べるために使える *note ModuleFinder: 196e. クラスを提供しています。
‘modulefinder.py’ はまた、Python スクリプトのファイル名を引数に指定して
スクリプトとして実行し、 import されているモジュールのレポートを出力させ
ることもできます。

 -- の関数: modulefinder.AddPackagePath (pkg_name, path)

     'pkg_name' という名前のパッケージの在り処が 'path' であることを記録
     します。

 -- の関数: modulefinder.ReplacePackage (oldname, newname)

     実際にはパッケージ内で 'oldname' という名前になっているモジュールを
     'newname' という名前で指定できるようにします。

 -- クラス: modulefinder.ModuleFinder (path=None, debug=0, excludes=[],
          replace_paths=[])

     このクラスでは *note run_script(): 437c. および *note report():
     437d. メソッドを提供しています。これらのメソッドは何らかのスクリプ
     ト中で import されているモジュールの集合を調べます。 'path' はモジ
     ュールを検索する先のディレクトリ名からなるリストです。 'path' を指
     定しない場合、 ‘sys.path’ を使います。 'debug' にはデバッグレベルを
     設定します; 値を大きくすると、実行している内容を表すデバッグメッセ
     ージを出力します。 'excludes' は検索から除外するモジュール名です。
     'replace_paths' には、モジュールパス内で置き換えられるパスをタプル
     ‘(oldpath, newpath)’ からなるリストで指定します。

      -- メソッド: report ()

          スクリプトで import しているモジュールと、そのパスからなるリス
          トを列挙したレポートを標準出力に出力します。モジュールを見つけ
          られなかったり、モジュールがないように見える場合にも報告します
          。

      -- メソッド: run_script (pathname)

          'pathname' に指定したファイルの内容を解析します。ファイルには
          Python コードが入っていなければなりません。

      -- の属性: modules

          モジュール名をモジュールに結びつける辞書。 *note ModuleFinder
          の使用例: 437f. を参照して下さい。

* Menu:

* ModuleFinder の使用例::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/modulefinder.py


File: python.info,  Node: ModuleFinder の使用例,  Up: modulefinder --- スクリプト中で使用されているモジュールの検索

5.31.3.1 ‘ModuleFinder’ の使用例
................................

解析対象のスクリプトはこれ (bacon.py) です:

     import re, itertools

     try:
         import baconhameggs
     except ImportError:
         pass

     try:
         import guido.python.ham
     except ImportError:
         pass

bacon.py のレポートを出力するスクリプトです:

     from modulefinder import ModuleFinder

     finder = ModuleFinder()
     finder.run_script('bacon.py')

     print('Loaded modules:')
     for name, mod in finder.modules.items():
         print('%s: ' % name, end='')
         print(','.join(list(mod.globalnames.keys())[:3]))

     print('-'*50)
     print('Modules not imported:')
     print('\n'.join(finder.badmodules.keys()))

出力例です (アーキテクチャに依って違ってくるかもしれません):

     Loaded modules:
     _types:
     copyreg:  _inverted_registry,_slotnames,__all__
     re._compiler:  isstring,_sre,_optimize_unicode
     _sre:
     re._constants:  REPEAT_ONE,makedict,AT_END_LINE
     sys:
     re:  __module__,finditer,_expand
     itertools:
     __main__:  re,itertools,baconhameggs
     re._parser:  _PATTERNENDERS,SRE_FLAG_UNICODE
     array:
     types:  __module__,IntType,TypeType
     ---------------------------------------------------
     Modules not imported:
     guido.python.ham
     baconhameggs


File: python.info,  Node: runpy --- Python モジュールの位置特定と実行,  Next: importlib --- import の実装,  Prev: modulefinder --- スクリプト中で使用されているモジュールの検索,  Up: モジュールのインポート

5.31.4 ‘runpy’ -- Python モジュールの位置特定と実行
---------------------------------------------------

'ソースコード:' Lib/runpy.py(1)

__________________________________________________________________

*note runpy: ac. モジュールは Python のモジュールをインポートせずにその
位置を特定したり実行したりするのに使われます。その主な目的はファイルシス
テムではなく Python のモジュール名前空間を使って位置を特定したスクリプト
の実行を可能にする *note -m: 5ab. コマンドラインスイッチを実装することで
す。

これはサンドボックスモジュール 'ではない' ことに注意してください。すべて
のコードは現在のプロセスで実行され、あらゆる副作用 (たとえば他のモジュー
ルのキャッシュされたインポート等) は関数から戻った後にそのまま残ります。

さらに、 *note runpy: ac. 関数から戻った後で、実行されたコードによって定
義された任意の関数およびクラスが正常に動作することは保証されません。この
制限が受け入れられないユースケースでは、 *note importlib: 6b. がこのモジ
ュールより適切な選択となるでしょう。

*note runpy: ac. モジュールは2つの関数を提供しています:

 -- の関数: runpy.run_module (mod_name, init_globals=None,
          run_name=None, alter_sys=False)

     Execute the code of the specified module and return the resulting
     module's globals dictionary.  The module's code is first located
     using the standard import mechanism (refer to PEP 302(2) for
     details) and then executed in a fresh module namespace.

     The 'mod_name' argument should be an absolute module name.  If the
     module name refers to a package rather than a normal module, then
     that package is imported and the *note __main__: 1. submodule
     within that package is then executed and the resulting module
     globals dictionary returned.

     The optional dictionary argument 'init_globals' may be used to
     pre-populate the module's globals dictionary before the code is
     executed.  'init_globals' will not be modified.  If any of the
     special global variables below are defined in 'init_globals', those
     definitions are overridden by *note run_module(): 1777.

     The special global variables ‘__name__’, ‘__spec__’, ‘__file__’,
     ‘__cached__’, ‘__loader__’ and ‘__package__’ are set in the globals
     dictionary before the module code is executed.  (Note that this is
     a minimal set of variables - other variables may be set implicitly
     as an interpreter implementation detail.)

     ‘__name__’ は、オプション引数 'run_name' が *note None: 641. でない
     場合、指定されたモジュールがパッケージであれば ‘mod_name +
     '.__main__'’ に、そうでなければ 'mod_name' 引数の値がセットされます
     。

     ‘__spec__’ will be set appropriately for the 'actually' imported
     module (that is, ‘__spec__.name’ will always be 'mod_name' or
     ‘mod_name + '.__main__'’, never 'run_name').

     ‘__file__’, ‘__cached__’, ‘__loader__’ and ‘__package__’ are *note
     set as normal: 1e74. based on the module spec.

     引数 'alter_sys' が与えられて *note True: bdb. に評価されるならば、
     ‘sys.argv[0]’ は ‘__file__’ の値で更新され ‘sys.modules[__name__]’
     は実行されるモジュールの一時的モジュールオブジェクトで更新されます
     。 ‘sys.argv[0]’ と ‘sys.modules[__name__]’ はどちらも関数が処理を
     戻す前にもとの値に復旧します。

     Note that this manipulation of *note sys: c3. is not thread-safe.
     Other threads may see the partially initialised module, as well as
     the altered list of arguments.  It is recommended that the ‘sys’
     module be left alone when invoking this function from threaded
     code.

     参考
     ....

     コマンドラインから、 *note -m: 5ab. オプションを与えることで同じ機
     能を実現出来ます。

     バージョン 3.1 で変更: Added ability to execute packages by looking
     for a *note __main__: 1. submodule.

     バージョン 3.2 で変更: ‘__cached__’ グローバル変数が追加されました
     ( PEP 3147(3) を参照)。

     バージョン 3.4 で変更: Updated to take advantage of the module spec
     feature added by PEP 451(4).  This allows ‘__cached__’ to be set
     correctly for modules run this way, as well as ensuring the real
     module name is always accessible as ‘__spec__.name’.

     バージョン 3.12 で変更: The setting of ‘__cached__’, ‘__loader__’,
     and ‘__package__’ are deprecated.  See *note ModuleSpec: 1dcb. for
     alternatives.

 -- の関数: runpy.run_path (path_name, init_globals=None, run_name=None)

     Execute the code at the named filesystem location and return the
     resulting module's globals dictionary.  As with a script name
     supplied to the CPython command line, 'file_path' may refer to a
     Python source file, a compiled bytecode file or a valid *note
     sys.path: 38e. entry containing a *note __main__: 1. module (e.g.
     a zipfile containing a top-level ‘__main__.py’ file).

     For a simple script, the specified code is simply executed in a
     fresh module namespace.  For a valid *note sys.path: 38e. entry
     (typically a zipfile or directory), the entry is first added to the
     beginning of ‘sys.path’.  The function then looks for and executes
     a *note __main__: 1. module using the updated path.  Note that
     there is no special protection against invoking an existing
     ‘__main__’ entry located elsewhere on ‘sys.path’ if there is no
     such module at the specified location.

     The optional dictionary argument 'init_globals' may be used to
     pre-populate the module's globals dictionary before the code is
     executed.  'init_globals' will not be modified.  If any of the
     special global variables below are defined in 'init_globals', those
     definitions are overridden by *note run_path(): 166.

     The special global variables ‘__name__’, ‘__spec__’, ‘__file__’,
     ‘__cached__’, ‘__loader__’ and ‘__package__’ are set in the globals
     dictionary before the module code is executed.  (Note that this is
     a minimal set of variables - other variables may be set implicitly
     as an interpreter implementation detail.)

     ‘__name__’ は、オプション引数 'run_name' が *note None: 641. でない
     場合、 'run_name' に設定され、それ以外の場合は ‘'<run_path>'’ に設
     定されます。

     If 'file_path' directly references a script file (whether as source
     or as precompiled byte code), then ‘__file__’ will be set to
     'file_path', and ‘__spec__’, ‘__cached__’, ‘__loader__’ and
     ‘__package__’ will all be set to *note None: 641.

     If 'file_path' is a reference to a valid *note sys.path: 38e.
     entry, then ‘__spec__’ will be set appropriately for the imported
     *note __main__: 1. module (that is, ‘__spec__.name’ will always be
     ‘__main__’).  ‘__file__’, ‘__cached__’, ‘__loader__’ and
     ‘__package__’ will be *note set as normal: 1e74. based on the
     module spec.

     A number of alterations are also made to the *note sys: c3. module.
     Firstly, *note sys.path: 38e. may be altered as described above.
     ‘sys.argv[0]’ is updated with the value of 'file_path' and
     ‘sys.modules[__name__]’ is updated with a temporary module object
     for the module being executed.  All modifications to items in *note
     sys: c3. are reverted before the function returns.

     Note that, unlike *note run_module(): 1777, the alterations made to
     *note sys: c3. are not optional in this function as these
     adjustments are essential to allowing the execution of *note
     sys.path: 38e. entries.  As the thread-safety limitations still
     apply, use of this function in threaded code should be either
     serialised with the import lock or delegated to a separate process.

     参考
     ....

     コマンドラインから *note インターフェイスオプション: 1c93. で同じ機
     能を使えます (‘python path/to/script’)。

     Added in version 3.2.

     バージョン 3.4 で変更: Updated to take advantage of the module spec
     feature added by PEP 451(5).  This allows ‘__cached__’ to be set
     correctly in the case where ‘__main__’ is imported from a valid
     *note sys.path: 38e. entry rather than being executed directly.

     バージョン 3.12 で変更: The setting of ‘__cached__’, ‘__loader__’,
     and ‘__package__’ are deprecated.

参考
....

PEP 338(6) - モジュールをスクリプトとして実行する

     PEP written and implemented by Nick Coghlan.

PEP 366(7) - main モジュールの明示的な相対インポート

     PEP written and implemented by Nick Coghlan.

PEP 451(8) - インポートシステムのための ModuleSpec 型

     PEP written and implemented by Eric Snow

*note コマンドラインと環境: 192a. - CPython コマンドライン詳細

*note importlib.import_module(): 4e1. 関数

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/runpy.py

   (2) https://peps.python.org/pep-0302/

   (3) https://peps.python.org/pep-3147/

   (4) https://peps.python.org/pep-0451/

   (5) https://peps.python.org/pep-0451/

   (6) https://peps.python.org/pep-0338/

   (7) https://peps.python.org/pep-0366/

   (8) https://peps.python.org/pep-0451/


File: python.info,  Node: importlib --- import の実装,  Next: importlib resources -- パッケージリソースの読み取り、オープン、アクセス,  Prev: runpy --- Python モジュールの位置特定と実行,  Up: モジュールのインポート

5.31.5 ‘importlib’ -- ‘import’ の実装
-------------------------------------

Added in version 3.1.

'ソースコード:' Lib/importlib/__init__.py(1)

__________________________________________________________________

* Menu:

* はじめに: はじめに<10>.
* 関数: 関数<12>.
* importlib.abc: importlib abc -- インポートに関連する抽象基底クラス. インポートに関連する抽象基底クラス
* importlib.machinery: importlib machinery -- インポータおよびパスフック. インポータおよびパスフック
* importlib.util: importlib util -- インポータのためのユーティリティコード. インポータのためのユーティリティコード
* 使用例: 使用例<47>.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/importlib/__init__.py


File: python.info,  Node: はじめに<10>,  Next: 関数<12>,  Up: importlib --- import の実装

5.31.5.1 はじめに
.................

*note importlib: 6b. パッケージの目的は3つあります。

1つ目は Python ソースコード中にある *note import: 5ac. 文の(そして、拡張
として、 *note __import__(): 8a2. 関数の)実装を提供することです。このパ
ッケージは ‘import’ 文の、どの Python インタープリターでも動作する実装を
提供します。また、 Python 以外の言語で実装されたどの実装よりも把握しやす
い実装を提供します。

2つ目の目的は、このパッケージが公開している *note import: 5ac. を実装す
るための要素を利用して、(*note インポーター: 1f54. として知られる) イン
ポートプロセスで動作するカスタムのオブジェクトを実装しやすくすることです
。

Three, the package contains modules exposing additional functionality
for managing aspects of Python packages:

   * *note importlib.metadata: 6e. presents access to metadata from
     third-party distributions.

   * *note importlib.resources: 6f. provides routines for accessing
     non-code "resources" from Python packages.

参考
....

*note import 文: 5ac.

     *note import: 5ac. 文の言語リファレンス。

Packages specification(1)

     パッケージの元の仕様。幾つかの動作はこの仕様が書かれた頃から変更さ
     れています (例: *note sys.modules: 18d6. で ‘None’ に基づくリダイレ
     クト)。

*note __import__(): 1042. 関数

     *note import: 5ac. 文はこの関数のシンタックスシュガーです。

*note sys.path モジュール検索パスの初期化: 1bca.

     The initialization of *note sys.path: 38e.

PEP 235(2)

     大文字小文字を区別しないプラットフォームでのインポート

PEP 263(3)

     Python のソースコードのエンコーディング

PEP 302(4)

     新しいインポートフック

PEP 328(5)

     複数行のインポートと、絶対/相対インポート

PEP 366(6)

     main モジュールの明示的な相対インポート

PEP 420(7)

     暗黙的な名前空間パッケージ

PEP 451(8)

     インポートシステムのための ModuleSpec 型

PEP 488(9)

     PYO ファイルの撤廃

PEP 489(10)

     複数フェーズでの拡張モジュールの初期化

PEP 552(11)

     決定論的 pyc

PEP 3120(12)

     デフォルトのソースエンコーディングとして UTF-8 を使用

PEP 3147(13)

     PYC リポジトリディレクトリ

   ---------- Footnotes ----------

   (1) https://www.python.org/doc/essays/packages/

   (2) https://peps.python.org/pep-0235/

   (3) https://peps.python.org/pep-0263/

   (4) https://peps.python.org/pep-0302/

   (5) https://peps.python.org/pep-0328/

   (6) https://peps.python.org/pep-0366/

   (7) https://peps.python.org/pep-0420/

   (8) https://peps.python.org/pep-0451/

   (9) https://peps.python.org/pep-0488/

   (10) https://peps.python.org/pep-0489/

   (11) https://peps.python.org/pep-0552/

   (12) https://peps.python.org/pep-3120/

   (13) https://peps.python.org/pep-3147/


File: python.info,  Node: 関数<12>,  Next: importlib abc -- インポートに関連する抽象基底クラス,  Prev: はじめに<10>,  Up: importlib --- import の実装

5.31.5.2 関数
.............

 -- の関数: importlib.__import__ (name, globals=None, locals=None,
          fromlist=(), level=0)

     組み込みの *note __import__(): 8a2. 関数の実装です。

          注釈: プログラムからモジュールをインポートする場合はこの関数の
          代わりに *note import_module(): 4e1. を使ってください。

 -- の関数: importlib.import_module (name, package=None)

     モジュールをインポートします。'name' 引数は、インポートするモジュー
     ルを絶対または相対表現 (例えば ‘pkg.mod’ または ‘..mod’) で指定しま
     す。name が相対表現で与えられたら、'package' 引数を、パッケージ名を
     解決するためのアンカーとなるパッケージの名前に設定する必要がありま
     す (例えば ‘import_module('..mod', 'pkg.subpkg')’ は ‘pkg.mod’ をイ
     ンポートします)。

     *note import_module(): 4e1. 関数は *note importlib.__import__():
     1042. を単純化するラッパーとして働きます。つまり、この関数のすべて
     の意味は *note importlib.__import__(): 1042. から受け継いでいます。
     これらの2つの関数の最も重要な違いは、 *note import_module(): 4e1. が
     指定されたパッケージやモジュール (例えば ‘pkg.mod’) を返すのに対し
     、 *note __import__(): 8a2. はトップレベルのパッケージやモジュール
     (例えば ‘pkg’) を返すことです。

     もしモジュールを動的にインポートしていて、インタープリタの実行開始
     後にモジュールが作成された (例えば、 Python ソースファイルを作成し
     た) 場合、インポートシステムが新しいモジュールを見つけられるように
     、 *note invalidate_caches(): bde. を呼ぶ必要があるでしょう。

     バージョン 3.3 で変更: 親パッケージは自動的にインポートされます。

 -- の関数: importlib.invalidate_caches ()

     *note sys.meta_path: cf9. に保存されたファインダーの内部キャッシュ
     を無効にします。ファインダーが ‘invalidate_caches()’ を実装していれ
     ば、無効化を行うためにそれが呼び出されます。すべてのファインダーが
     新しいモジュールの存在に気づくことを保証しているプログラムの実行中
     に、モジュールが作成またはインストールされたなら、この関数が呼び出
     されるべきです。

     Added in version 3.3.

     バージョン 3.10 で変更: Namespace packages created/installed in a
     different *note sys.path: 38e. location after the same namespace
     was already imported are noticed.

 -- の関数: importlib.reload (module)

     以前にインポートされた 'module' をリロードします。引数はモジュール
     オブジェクトでなければならず、したがってそれ以前に必ずインポートに
     成功していなければなりません。この関数は、モジュールのソースファイ
     ルを外部エディタで編集していて Python インタープリタから離れること
     なく新しいバージョンを試したい際に便利です。戻り値はモジュールオブ
     ジェクトです。 (もし再インポートが異なるオブジェクトを *note
     sys.modules: 18d6. に配置したら、元の 'module' とは異なるかもしれま
     せん。)

     *note reload(): 4e2. が実行された場合:

        * Python モジュールのコードは再コンパイルされ、モジュールレベル
          のコードが再度実行されます。モジュールの辞書中にある何らかの名
          前に結び付けられたオブジェクトは、そのモジュールを最初にロード
          したときの *note ローダー: 1614. を再利用して新たに定義されま
          す。拡張モジュールの ‘init’ 関数が二度呼び出されることはありま
          せん。

        * Python における他のオブジェクトと同様、以前のオブジェクトのメ
          モリ領域は、参照カウントがゼロにならないかぎり再利用されません
          。

        * モジュール名前空間内の名前は新しいオブジェクト (または更新され
          たオブジェクト) を指すよう更新されます。

        * 以前のオブジェクトが (外部の他のモジュールなどからの) 参照を受
          けている場合、それらを新たなオブジェクトに再束縛し直すことはな
          いので、必要なら自分で名前空間を更新しなければなりません。

     いくつか補足説明があります:

     モジュールが再ロードされた際、その辞書 (モジュールのグローバル変数
     を含みます) はそのまま残ります。名前の再定義を行うと、以前の定義を
     上書きするので、一般的には問題はありません。新たなバージョンのモジ
     ュールが古いバージョンで定義された名前を定義していない場合、古い定
     義がそのまま残ります。辞書がグローバルテーブルやオブジェクトのキャ
     ッシュを維持していれば、この機能をモジュールを有効性を引き出すため
     に使うことができます -- つまり、 *note try: 6b4. 文を使えば、必要に
     応じてテーブルがあるかどうかをテストし、その初期化を飛ばすことがで
     きます:

          try:
              cache
          except NameError:
              cache = {}

     組み込みモジュールや動的にロードされるモジュールを再ロードすること
     は、一般的にそれほど便利ではありません。 *note sys: c3, *note
     __main__: 1, *note builtins: e. やその他重要なモジュールの再ロード
     はお勧め出来ません。多くの場合、拡張モジュールは 1 度以上初期化され
     るようには設計されておらず、再ロードされた場合には何らかの理由で失
     敗するかもしれません。

     一方のモジュールが *note from: 127d. ...  *note import: 5ac. ...  を
     使って、オブジェクトを他方のモジュールからインポートしているなら、
     他方のモジュールを *note reload(): 4e2. で呼び出しても、そのモジュ
     ールからインポートされたオブジェクトを再定義することはできません --
     この問題を回避する一つの方法は、 *note from: 127d. 文を再度実行する
     ことで、もう一つの方法は ‘from’ 文の代わりに ‘import’ と限定的な名
     前 ('module.name') を使うことです。

     あるモジュールがクラスのインスタンスを生成している場合、そのクラス
     を定義しているモジュールの再ロードはそれらインスタンスのメソッド定
     義に影響しません -- それらは古いクラス定義を使い続けます。これは派
     生クラスの場合でも同じです。

     Added in version 3.4.

     バージョン 3.7 で変更: リロードされたモジュールの *note ModuleSpec:
     1dcb. が欠けていたときは *note ModuleNotFoundError: b15. が送出され
     ます。


File: python.info,  Node: importlib abc -- インポートに関連する抽象基底クラス,  Next: importlib machinery -- インポータおよびパスフック,  Prev: 関数<12>,  Up: importlib --- import の実装

5.31.5.3 ‘importlib.abc’ - インポートに関連する抽象基底クラス
.............................................................

'ソースコード:' Lib/importlib/abc.py(1)

__________________________________________________________________

*note importlib.abc: 6c. モジュールは、 *note import: 5ac. に使われるす
べてのコア抽象基底クラス含みます。コア抽象基底クラスの実装を助けるために
、コア抽象基底クラスのサブクラスもいくつか提供されています。

抽象基底クラス階層:

     object
      +-- MetaPathFinder
      +-- PathEntryFinder
      +-- Loader
           +-- ResourceLoader --------+
           +-- InspectLoader          |
                +-- ExecutionLoader --+
                                      +-- FileLoader
                                      +-- SourceLoader

 -- クラス: importlib.abc.MetaPathFinder

     *note meta path finder: 1045. を表す抽象基底クラスです。

     Added in version 3.3.

     バージョン 3.10 で変更: No longer a subclass of ‘Finder’.

      -- メソッド: find_spec (fullname, path, target=None)

          An abstract method for finding a *note spec: 1e76. for the
          specified module.  If this is a top-level import, 'path' will
          be ‘None’.  Otherwise, this is a search for a subpackage or
          module and 'path' will be the value of *note __path__: 1bd8.
          from the parent package.  If a spec cannot be found, ‘None’ is
          returned.  When passed in, ‘target’ is a module object that
          the finder may use to make a more educated guess about what
          spec to return.  *note importlib.util.spec_from_loader(): 839.
          may be useful for implementing concrete ‘MetaPathFinders’.

          Added in version 3.4.

      -- メソッド: invalidate_caches ()

          このファインダーで使われている内部キャッシュがあれば無効にする
          オプションのメソッドです。 *note sys.meta_path: cf9. 上のすべ
          てのファインダーのキャッシュを無効化する際、 *note
          importlib.invalidate_caches(): bde. によって使われます。

          バージョン 3.4 で変更: Returns ‘None’ when called instead of
          *note NotImplemented: 79d.

 -- クラス: importlib.abc.PathEntryFinder

     *note path entry finder: 1046. を表す抽象基底クラスです。 *note
     MetaPathFinder: 83a. と似ているところがありますが、
     ‘PathEntryFinder’ は *note importlib.machinery.PathFinder: fed. が
     提供するパスに基づく import サブシステムの中でのみ使うことが意図さ
     れています。

     Added in version 3.3.

     バージョン 3.10 で変更: No longer a subclass of ‘Finder’.

      -- メソッド: find_spec (fullname, target=None)

          指定されたモジュールに対応する *note スペック: 1e76. を検索す
          る抽象メソッド。ファインダーは、割り当てられている *note
          パス・エントリー: 1f64. 内のモジュールだけを検索します。スペッ
          クが見つからなければ ‘None’ が返されます。 ‘target’ は、渡され
          てきたならモジュールオブジェクトです。これはファインダーがどの
          ようなスペックを返せばよいか推測するために使用します。具体的な
          ‘PathEntryFinders’ を実装するためには *note
          importlib.util.spec_from_loader(): 839. が便利かもしれません。

          Added in version 3.4.

      -- メソッド: invalidate_caches ()

          このファインダーで使われている内部キャッシュがあれば無効にする
          オプションのメソッドです。キャッシュされたすべてのファインダー
          の無効化する際、 *note
          importlib.machinery.PathFinder.invalidate_caches(): bdd. によ
          って使われます。

 -- クラス: importlib.abc.Loader

     *note loader: 1614. の抽象基底クラスです。ローダーの厳密な定義は
     PEP 302(2) を参照してください。

     リソースの読み出しをサポートさせたいローダーには、 *note
     importlib.resources.abc.ResourceReader: 438a. で指定されている
     ‘get_resource_reader()’ メソッドを実装してください。

     バージョン 3.7 で変更: オプションの ‘get_resource_reader()’ メソッ
     ドが導入されました。

      -- メソッド: create_module (spec)

          モジュールをインポートする際に使用されるモジュールオブジェクト
          を返すメソッド。このメソッドは ‘None’ を戻すことができ、その場
          合はデフォルトのモジュール作成のセマンティクスが適用されること
          を示します。

          Added in version 3.4.

          バージョン 3.6 で変更: *note exec_module(): 836. が定義されて
          いる場合は、このメソッドはオプションではなくなりました。

      -- メソッド: exec_module (module)

          モジュールがインポートまたはリロードされる際に、そのモジュール
          をモジュール自身の名前空間の中で実行する抽象的なメソッド。
          *note exec_module(): 836. が呼ばれる時点で、モジュールはすでに
          初期設定されている必要があります。 このメソッドが存在するとき
          は、 *note create_module(): c7c. の定義が必須です。

          Added in version 3.4.

          バージョン 3.6 で変更: *note create_module(): c7c. の定義が必
          須となりました。

      -- メソッド: load_module (fullname)

          モジュールをロードするためのレガシーなメソッドです。モジュール
          がロードできなければ *note ImportError: 3f2. を送出し、ロード
          できればロードされたモジュールを返します。

          If the requested module already exists in *note sys.modules:
          18d6, that module should be used and reloaded.  Otherwise the
          loader should create a new module and insert it into *note
          sys.modules: 18d6. before any loading begins, to prevent
          recursion from the import.  If the loader inserted a module
          and the load fails, it must be removed by the loader from
          *note sys.modules: 18d6.; modules already in *note
          sys.modules: 18d6. before the loader began execution should be
          left alone.

          ローダーはモジュールにいくつかの属性を設定する必要があります。
          (なお、これらの属性には、モジュールがリロードされた際に変化す
          るものがあります):

             - *note module.__name__: 1350.

             - *note module.__file__: 1e7d.

             - *note module.__cached__: 2b7. '(deprecated)'

             - *note module.__path__: 1bd8.

             - *note module.__package__: 2b9. '(deprecated)'

             - *note module.__loader__: 2c3. '(deprecated)'

          *note exec_module(): 836. が利用可能な場合、後方互換な機能が提
          供されます。

          バージョン 3.4 で変更: Raise *note ImportError: 3f2. when
          called instead of *note NotImplementedError: 209.
          Functionality provided when *note exec_module(): 836. is
          available.

          バージョン 3.4 で非推奨: モジュールをロードするための推奨され
          る API は、 *note exec_module(): 836. (および *note
          create_module(): c7c.) です。ローダーは *note load_module():
          835. の代わりにそれを実装するべきです。 *note exec_module():
          836. が実装されている場合、インポート機構は *note
          load_module(): 835. の他のすべての責任を肩代わりします。

 -- クラス: importlib.abc.ResourceLoader

     *note loader: 1614. の抽象基底クラスで、ストレージバックエンドから
     任意のリソースをロードするオプションの PEP 302(3) プロトコルを実装
     します。

     バージョン 3.7 で非推奨: This ABC is deprecated in favour of
     supporting resource loading through *note
     importlib.resources.abc.ResourceReader: 438a.

      -- メソッド: abstractmethod get_data (path)

          An abstract method to return the bytes for the data located at
          'path'.  Loaders that have a file-like storage back-end that
          allows storing arbitrary data can implement this abstract
          method to give direct access to the data stored.  *note
          OSError: 3f0. is to be raised if the 'path' cannot be found.
          The 'path' is expected to be constructed using a module's
          *note __file__: 1e7d. attribute or an item from a package's
          *note __path__: 1bd8.

          バージョン 3.4 で変更: *note NotImplementedError: 209. の代わ
          りに *note OSError: 3f0. を送出します。

 -- クラス: importlib.abc.InspectLoader

     *note loader: 1614. の抽象基底クラスで、ローダーがモジュールを検査
     するためのオプションの PEP 302(4) プロトコルを実装します。

      -- メソッド: get_code (fullname)

          モジュールの *note code: 13. オブジェクトを返すか、 (例えば組
          み込みモジュールの場合に) モジュールがコードオブジェクトを持た
          なければ ‘None’ を返します。要求されたモジュールをローダーが見
          つけられなかった場合は *note ImportError: 3f2. を送出します。

               注釈: このメソッドにはデフォルト実装がありますが、とはい
               えパフォーマンスのために、可能ならばオーバライドしたほう
               が良いです。

          バージョン 3.4 で変更: このメソッドはもはや抽象メソッドではな
          く、具象実装が提供されます。

      -- メソッド: abstractmethod get_source (fullname)

          モジュールのソースを返す抽象メソッドです。これは認識されたすべ
          ての行セパレータを ‘'\n'’ 文字に変換し、 *note universal
          newlines: d08. を使ったテキスト文字列として返されます。利用で
          きるソースがなければ (例えば組み込みモジュール)、 ‘None’ を返
          します。指定されたモジュールが見つからなければ、 *note
          ImportError: 3f2. を送出します。

          バージョン 3.4 で変更: *note NotImplementedError: 209. の代わ
          りに *note ImportError: 3f2. を送出します。

      -- メソッド: is_package (fullname)

          モジュールがパッケージであれば True を返し、そうでなければ
          False を返すオプションのメソッドです。 *note ローダー: 1614. が
          モジュールを見つけられなかったなら *note ImportError: 3f2. が
          送出されます。

          バージョン 3.4 で変更: *note NotImplementedError: 209. の代わ
          りに *note ImportError: 3f2. を送出します。

      -- メソッド: static source_to_code (data, path='<string>')

          Python のソースからコードオブジェクトを作ります。

          'data' 引数は *note compile(): 177. 関数がサポートするもの (す
          なわち文字列かバイト) なら何でも構いません。'path' 引数はソー
          スコードの元々の場所への "パス" でなければなりませんが、抽象概
          念 (例えば zip ファイル内の場所) でも構いません。

          結果のコードオブジェクトを使って、 ‘exec(code,
          module.__dict__)’ を呼ぶことでモジュール内でコードを実行できま
          す。

          Added in version 3.4.

          バージョン 3.5 で変更: スタティックメソッドになりました。

      -- メソッド: exec_module (module)

          *note Loader.exec_module(): 836. の実装です。

          Added in version 3.4.

      -- メソッド: load_module (fullname)

          *note Loader.load_module(): 835. の実装です。

          バージョン 3.4 で非推奨: 代わりに *note exec_module(): fdd. を
          使用してください。

 -- クラス: importlib.abc.ExecutionLoader

     *note InspectLoader: f21. から継承された抽象基底クラスで、実装され
     ていれば、モジュールをスクリプトとして実行する助けになります。この
     抽象基底クラスはオプションの PEP 302(5) プロトコルを表します。

      -- メソッド: abstractmethod get_filename (fullname)

          An abstract method that is to return the value of *note
          __file__: 1e7d. for the specified module.  If no path is
          available, *note ImportError: 3f2. is raised.

          ソースコードが利用できるなら、そのモジュールのロードにバイトコ
          ードが使われたかにかかわらず、このメソッドはそのソースファイル
          へのパスを返す必要があります。

          バージョン 3.4 で変更: *note NotImplementedError: 209. の代わ
          りに *note ImportError: 3f2. を送出します。

 -- クラス: importlib.abc.FileLoader (fullname, path)

     *note ResourceLoader: bb5. と *note ExecutionLoader: 438d. から継承
     された抽象基底クラスで、 *note ResourceLoader.get_data(): 4376. お
     よび *note ExecutionLoader.get_filename(): 438e. の具象実装を提供し
     ます。

     'fullname' 引数は、ローダーが解決しようとするモジュールの、完全に解
     決された名前です。'path' 引数は、モジュールのファイルへのパスです。

     Added in version 3.3.

      -- の属性: name

          ローダーが扱えるモジュールの名前です。

      -- の属性: path

          モジュールのファイルへのパスです。

      -- メソッド: load_module (fullname)

          親クラスの ‘load_module()’ を呼び出します。

          バージョン 3.4 で非推奨: 代わりに *note Loader.exec_module():
          836. を使用してください。

      -- メソッド: abstractmethod get_filename (fullname)

          *note path: 4390. を返します。

      -- メソッド: abstractmethod get_data (path)

          'path' をバイナリファイルとして読み込み、そのバイト列を返しま
          す。

 -- クラス: importlib.abc.SourceLoader

     ソース (オプションでバイトコード) ファイルのロードを実装する抽象基
     底クラスです。このクラスは、 *note ResourceLoader: bb5. と *note
     ExecutionLoader: 438d. の両方を継承し、以下の実装が必要です:

        * *note ResourceLoader.get_data(): 4376.

        * 
          *note ExecutionLoader.get_filename(): 438e.

               ソースファイルへのパスのみを返す必要があります。ソースな
               しのロードはサポートされていません。

     このクラスでこれらの抽象メソッドを定義することで、バイトコードファ
     イルを追加でサポートします。これらのメソッドを定義しなければ (また
     はそのモジュールが *note NotImplementedError: 209. を送出すれば)、
     このローダーはソースコードに対してのみ働きます。これらのメソッドを
     実装することで、ローダーはソースとバイトコードファイル 'の組み合わ
     せ' に対して働きます。バイトコードのみを与えた 'ソースのない' ロー
     ドは認められません。バイトコードファイルは、 Python コンパイラによ
     る解析の工程をなくして速度を上げる最適化です。ですから、バイトコー
     ド特有の API は公開されていません。

      -- メソッド: path_stats (path)

          指定されたパスについてのメタデータを含む *note dict: 237. を返
          す、オプションの抽象メソッドです。サポートされる辞書のキーは:

             - ‘'mtime'’ (必須): ソースコードの更新時刻を表す整数または
               浮動小数点数です。

             - ‘'size'’ (任意): バイト数で表したソースコードのサイズです
               。

          未来の拡張のため、辞書内の他のキーは無視されます。パスが扱えな
          ければ、 *note OSError: 3f0. が送出されます。

          Added in version 3.3.

          バージョン 3.4 で変更: *note NotImplementedError: 209. の代わ
          りに *note OSError: 3f0. を送出します。

      -- メソッド: path_mtime (path)

          指定されたパスの更新時刻を返す、オプションの抽象メソッドです。

          バージョン 3.3 で非推奨: このメソッドは廃止され、 *note
          path_stats(): 115c. が推奨されます。このモジュールを実装する必
          要はありませんが、互換性のため現在も利用できます。パスが扱えな
          ければ、 *note OSError: 3f0. が送出されます。

          バージョン 3.4 で変更: *note NotImplementedError: 209. の代わ
          りに *note OSError: 3f0. を送出します。

      -- メソッド: set_data (path, data)

          ファイルパスに指定されたバイト列を書き込むオプションの抽象メソ
          ッドです。存在しない中間ディレクトリがあれば、自動で作成されま
          す。

          When writing to the path fails because the path is read-only
          (*note errno.EACCES: 2209./*note PermissionError: d10.), do
          not propagate the exception.

          バージョン 3.4 で変更: 呼ばれたときに *note
          NotImplementedError: 209. を送出することは最早ありません。

      -- メソッド: get_code (fullname)

          *note InspectLoader.get_code(): f22. の具象実装です。

      -- メソッド: exec_module (module)

          *note Loader.exec_module(): 836. の具象実装です。

          Added in version 3.4.

      -- メソッド: load_module (fullname)

          *note Loader.load_module(): 835. の具象実装です。

          バージョン 3.4 で非推奨: 代わりに *note exec_module(): fde. を
          使用してください。

      -- メソッド: get_source (fullname)

          *note InspectLoader.get_source(): f25. の具象実装です。

      -- メソッド: is_package (fullname)

          *note InspectLoader.is_package(): 438b. の具象実装です。モジュ
          ールは、次の '両方' を満たすならパッケージであると決定されます
          。モジュールの (*note ExecutionLoader.get_filename(): 438e. で
          与えられる) ファイルパスが、ファイル拡張子を除くと ‘__init__’
          という名のファイルであること。モジュール名自体が ‘__init__’ で
          終わらないこと。

 -- クラス: importlib.abc.ResourceReader

     'TraversableResources に取って代わられました'

     'resources' の読み出し機能を提供する *note 抽象基底クラス (abstract
     base class, ABC): 1186. です。

     From the perspective of this ABC, a 'resource' is a binary artifact
     that is shipped within a package.  Typically this is something like
     a data file that lives next to the ‘__init__.py’ file of the
     package.  The purpose of this class is to help abstract out the
     accessing of such data files so that it does not matter if the
     package and its data file(s) are stored e.g.  in a zip file versus
     on the file system.

     For any of methods of this class, a 'resource' argument is expected
     to be a *note path-like object: 280. which represents conceptually
     just a file name.  This means that no subdirectory paths should be
     included in the 'resource' argument.  This is because the location
     of the package the reader is for, acts as the "directory".  Hence
     the metaphor for directories and file names is packages and
     resources, respectively.  This is also why instances of this class
     are expected to directly correlate to a specific package (instead
     of potentially representing multiple packages or a module).

     Loaders that wish to support resource reading are expected to
     provide a method called ‘get_resource_reader(fullname)’ which
     returns an object implementing this ABC's interface.  If the module
     specified by fullname is not a package, this method should return
     *note None: 641.  An object compatible with this ABC should only be
     returned when the specified module is a package.

     Added in version 3.7.

     Deprecated since version 3.12, will be removed in version 3.14: Use
     *note importlib.resources.abc.TraversableResources: 2a6. instead.

      -- メソッド: abstractmethod open_resource (resource)

          Returns an opened, *note file-like object: 24e0. for binary
          reading of the 'resource'.

          リソースが見付からない場合は、 *note FileNotFoundError: e8f. が
          送出されます。

      -- メソッド: abstractmethod resource_path (resource)

          'resource' へのファイルシステムパスを返します。

          リソースの実体がファイルシステムに存在しない場合、 *note
          FileNotFoundError: e8f. が送出されます。

      -- メソッド: abstractmethod is_resource (name)

          'name' という名前がリソースだと見なせるなら ‘True’ を返します
          。 'name' が存在しない場合は *note FileNotFoundError: e8f. が
          送出されます。

      -- メソッド: abstractmethod contents ()

          Returns an *note iterable: 10ad. of strings over the contents
          of the package.  Do note that it is not required that all
          names returned by the iterator be actual resources, e.g.  it
          is acceptable to return names for which *note is_resource():
          439b. would be false.

          Allowing non-resource names to be returned is to allow for
          situations where how a package and its resources are stored
          are known a priori and the non-resource names would be useful.
          For instance, returning subdirectory names is allowed so that
          when it is known that the package and resources are stored on
          the file system then those subdirectory names can be used
          directly.

          The abstract method returns an iterable of no items.

 -- クラス: importlib.abc.Traversable

     An object with a subset of *note pathlib.Path: 20a. methods
     suitable for traversing directories and opening files.

     For a representation of the object on the file-system, use *note
     importlib.resources.as_file(): 45a.

     Added in version 3.9.

     Deprecated since version 3.12, will be removed in version 3.14: Use
     *note importlib.resources.abc.Traversable: 1d4. instead.

      -- の属性: name

          Abstract.  The base name of this object without any parent
          references.

      -- メソッド: abstractmethod iterdir ()

          Yield ‘Traversable’ objects in ‘self’.

      -- メソッド: abstractmethod is_dir ()

          Return ‘True’ if ‘self’ is a directory.

      -- メソッド: abstractmethod is_file ()

          Return ‘True’ if ‘self’ is a file.

      -- メソッド: abstractmethod joinpath (child)

          Return Traversable child in ‘self’.

      -- メソッド: abstractmethod __truediv__ (child)

          Return ‘Traversable’ child in ‘self’.

      -- メソッド: abstractmethod open (mode='r', *args, **kwargs)

          'mode' may be 'r' or 'rb' to open as text or binary.  Return a
          handle suitable for reading (same as *note pathlib.Path.open:
          2712.).

          When opening as text, accepts encoding parameters such as
          those accepted by *note io.TextIOWrapper: 786.

      -- メソッド: read_bytes ()

          Read contents of ‘self’ as bytes.

      -- メソッド: read_text (encoding=None)

          Read contents of ‘self’ as text.

 -- クラス: importlib.abc.TraversableResources

     An abstract base class for resource readers capable of serving the
     *note importlib.resources.files(): 45b. interface.  Subclasses
     *note importlib.resources.abc.ResourceReader: 438a. and provides
     concrete implementations of the *note
     importlib.resources.abc.ResourceReader: 438a.'s abstract methods.
     Therefore, any loader supplying *note
     importlib.abc.TraversableResources: 17ed. also supplies
     ResourceReader.

     Loaders that wish to support resource reading are expected to
     implement this interface.

     Added in version 3.9.

     Deprecated since version 3.12, will be removed in version 3.14: Use
     *note importlib.resources.abc.TraversableResources: 2a6. instead.

      -- メソッド: abstractmethod files ()

          Returns a *note importlib.resources.abc.Traversable: 1d4.
          object for the loaded package.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/importlib/abc.py

   (2) https://peps.python.org/pep-0302/

   (3) https://peps.python.org/pep-0302/

   (4) https://peps.python.org/pep-0302/

   (5) https://peps.python.org/pep-0302/


File: python.info,  Node: importlib machinery -- インポータおよびパスフック,  Next: importlib util -- インポータのためのユーティリティコード,  Prev: importlib abc -- インポートに関連する抽象基底クラス,  Up: importlib --- import の実装

5.31.5.4 ‘importlib.machinery’ - インポータおよびパスフック
...........................................................

'ソースコード:' Lib/importlib/machinery.py(1)

__________________________________________________________________

このモジュールには、 *note import: 5ac. がモジュールを検索してロードする
のに役立つ様々なオブジェクトがあります。

 -- の属性: importlib.machinery.SOURCE_SUFFIXES

     認識されているソースモジュールのファイル接尾辞を表す文字列のリスト
     です。

     Added in version 3.3.

 -- の属性: importlib.machinery.DEBUG_BYTECODE_SUFFIXES

     最適化されていないバイトコードモジュールのファイル接尾辞を表す文字
     列のリストです。

     Added in version 3.3.

     バージョン 3.5 で非推奨: 代わりに *note BYTECODE_SUFFIXES: 4df. を
     使ってください。

 -- の属性: importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES

     最適化されたバイトコードモジュールのファイル接尾辞を表す文字列のリ
     ストです。

     Added in version 3.3.

     バージョン 3.5 で非推奨: 代わりに *note BYTECODE_SUFFIXES: 4df. を
     使ってください。

 -- の属性: importlib.machinery.BYTECODE_SUFFIXES

     認識されているバイトコードモジュールのファイル接尾辞を表す文字列の
     リストです (先頭のドットを含みます)。

     Added in version 3.3.

     バージョン 3.5 で変更: この値は ‘__debug__’ に依存しなくなりました
     。

 -- の属性: importlib.machinery.EXTENSION_SUFFIXES

     認識されている最適化された拡張モジュールのファイル接尾辞を表す文字
     列のリストです。

     Added in version 3.3.

 -- の関数: importlib.machinery.all_suffixes ()

     標準のインポート機構によって認識されているすべてのファイル接尾辞を
     表す文字列の組み合わせられたリストを返します。これが役立つのは、あ
     るファイルシステムパスがモジュールを参照する可能性があるかだけを知
     りたくて、そのモジュールの種類を詳しく知る必要はないコード (例えば
     *note inspect.getmodulename(): d07.) です。

     Added in version 3.3.

 -- クラス: importlib.machinery.BuiltinImporter

     組み込みモジュールの *note importer: 1f54. です。すべての既知のモジ
     ュールは *note sys.builtin_module_names: 1bc9. に列挙されています。
     このクラスは *note importlib.abc.MetaPathFinder: 83a. および *note
     importlib.abc.InspectLoader: f21. 抽象基底クラスを実装します。

     インスタンス化の必要性を軽減するため、このクラスにはクラスメソッド
     だけが定義されています。

     バージョン 3.5 で変更: PEP 489(2) の一環として、ビルトインインポー
     ターは ‘Loader.create_module()’ と ‘Loader.exec_module()’ を実装し
     ています。

 -- クラス: importlib.machinery.FrozenImporter

     フリーズされたモジュールの *note インポーター: 1f54. です。このクラ
     スは *note importlib.abc.MetaPathFinder: 83a. および *note
     importlib.abc.InspectLoader: f21. 抽象基底クラスを実装します。

     インスタンス化の必要性を軽減するため、このクラスにはクラスメソッド
     だけが定義されています。

     バージョン 3.4 で変更: Gained ‘create_module()’ and ‘exec_module()’
     methods.

 -- クラス: importlib.machinery.WindowsRegistryFinder

     Windows レジストリで宣言されたモジュールの *note finder: 1e7e. です
     。このクラスは *note importlib.abc.MetaPathFinder: 83a. 抽象基底ク
     ラスを実装します。

     インスタンス化の必要性を軽減するため、このクラスにはクラスメソッド
     だけが定義されています。

     Added in version 3.3.

     バージョン 3.6 で非推奨: 代わりに *note site: b5. の設定を使ってく
     ださい。 Python の将来のバージョンでは、デフォルトでこのファインダ
     ーが使えなくなるかもしれません。

 -- クラス: importlib.machinery.PathFinder

     *note sys.path: 38e. およびパッケージの ‘__path__’ 属性の *note
     Finder: 1e7e. です。このクラスは *note
     importlib.abc.MetaPathFinder: 83a. 抽象基底クラスを実装します。

     インスタンス化の必要性を軽減するため、このクラスにはクラスメソッド
     だけが定義されています。

      -- メソッド: classmethod find_spec (fullname, path=None,
               target=None)

          *note sys.path: 38e. または定義されていれば 'path' から、
          'fullname' で指定されたモジュールの *note スペック: 1e76. の検
          索を試みるクラスメソッドです。検索されるそれぞれのパスエントリ
          に対して *note sys.path_importer_cache: 5ae. が検査されます。
          偽でないオブジェクトが見つかれば、それが目的のモジュールを検索
          するための *note パスエントリ・ファインダー: 1046. として使わ
          れます。 *note sys.path_importer_cache: 5ae. に目的のエントリ
          が見つからなければ、パスエントリに対するファインダーが *note
          sys.path_hooks: fee. から検索され、見つかれば、それが *note
          sys.path_importer_cache: 5ae. に保管されるとともに、モジュール
          について問い合わせられます。それでもファインダーが見つからなけ
          れば ‘None’ が保管され、また返されます。

          Added in version 3.4.

          バージョン 3.5 で変更: もしカレントワーキングディレクトリ - 空
          の文字列によって表されている - がすでに有効でなければ、 ‘None’
          が返されますが値は *note sys.path_importer_cache: 5ae. にキャ
          ッシュされません。

      -- メソッド: classmethod invalidate_caches ()

          Calls *note importlib.abc.PathEntryFinder.invalidate_caches():
          4389. on all finders stored in *note sys.path_importer_cache:
          5ae. that define the method.  Otherwise entries in *note
          sys.path_importer_cache: 5ae. set to ‘None’ are deleted.

          バージョン 3.7 で変更: Entries of ‘None’ in *note
          sys.path_importer_cache: 5ae. are deleted.

     バージョン 3.4 で変更: ‘''’ (すなわち空の文字列) に対してはカレント
     ワーキングディレクトリとともに *note sys.path_hooks: fee. のオブジ
     ェクトを呼び出します。

 -- クラス: importlib.machinery.FileFinder (path, *loader_details)

     ファイルシステムからの結果をキャッシュする *note
     importlib.abc.PathEntryFinder: 83b. の具象実装です。

     'path' 引数は検索を担当するファインダーのディレクトリです。

     'loader_details' 引数は、可変個の 2 要素タプルで、それぞれがローダ
     ーとローダーが認識するファイル接尾辞のシーケンスとを含みます。ロー
     ダーは、呼び出し可能でモジュール名と見つかったファイルのパスとの 2
     引数を受け付けることを期待されます。

     ファインダーはモジュール検索のたびに stat を呼び出し、必要に応じて
     ディレクトリの内容をキャッシュすることで、コードキャッシュが古くな
     っていないことを確かめます。キャッシュの古さはオペレーティングシス
     テムのファイルシステムのステート情報の粒度に依存しますから、モジュ
     ールを検索し、新しいファイルを作成し、その後に新しいファイルが表す
     モジュールを検索する、という競合状態の可能性があります。この操作が
     stat の呼び出しの粒度に収まるほど速く起こると、モジュールの検索が失
     敗します。これを防ぐためには、モジュールを動的に作成する際に、必ず
     *note importlib.invalidate_caches(): bde. を呼び出してください。

     Added in version 3.3.

      -- の属性: path

          ファインダーが検索されるパスです。

      -- メソッド: find_spec (fullname, target=None)

          *note path: 43a9. 内で 'fullname' を扱うスペックの探索を試みま
          す。

          Added in version 3.4.

      -- メソッド: invalidate_caches ()

          内部キャッシュを完全に消去します。

      -- メソッド: classmethod path_hook (*loader_details)

          A class method which returns a closure for use on *note
          sys.path_hooks: fee.  An instance of *note FileFinder: 1047.
          is returned by the closure using the path argument given to
          the closure directly and 'loader_details' indirectly.

          クロージャへの引数が存在するディレクトリでなければ、 *note
          ImportError: 3f2. が送出されます。

 -- クラス: importlib.machinery.SourceFileLoader (fullname, path)

     *note importlib.abc.FileLoader: 1048. を継承し、その他いくつかのメ
     ソッドの具象実装を提供する、 *note importlib.abc.SourceLoader:
     4394. の具象実装です。

     Added in version 3.3.

      -- の属性: name

          このローダーが扱うモジュールの名前です。

      -- の属性: path

          ソースファイルへのパスです。

      -- メソッド: is_package (fullname)

          *note path: 43ad. がパッケージを表すとき ‘True’ を返します。

      -- メソッド: path_stats (path)

          *note importlib.abc.SourceLoader.path_stats(): 115c. の具象実
          装です。

      -- メソッド: set_data (path, data)

          *note importlib.abc.SourceLoader.set_data(): 4395. の具象実装
          です。

      -- メソッド: load_module (name=None)

          ロードするモジュールの名前指定がオプションの、 *note
          importlib.abc.Loader.load_module(): 835. の具象実装です。

          バージョン 3.6 で非推奨: 代わりに *note
          importlib.abc.Loader.exec_module(): 836. を使用してください。

 -- クラス: importlib.machinery.SourcelessFileLoader (fullname, path)

     バイトコードファイル (すなわちソースコードファイルが存在しない) を
     インポートできる *note importlib.abc.FileLoader: 1048. の具象実装で
     す。

     注意として、バイトコードを直接使う (つまりソースコードファイルがな
     い) と、そのモジュールはすべての Python 実装では使用できないし、新
     しいバージョンの Python ではバイトコードフォーマットが変更されてい
     たら使用できません。

     Added in version 3.3.

      -- の属性: name

          ローダーが扱うモジュールの名前です。

      -- の属性: path

          バイトコードファイルへのパスです。

      -- メソッド: is_package (fullname)

          そのモジュールがパッケージであるかを *note path: 43b2. に基づ
          いて決定します。

      -- メソッド: get_code (fullname)

          *note path: 43b2. から作成された *note name: 43b1. のコードオ
          ブジェクトを返します。

      -- メソッド: get_source (fullname)

          このローダーが使われたとき、バイトコードファイルのソースがなけ
          れば ‘None’ を返します。

      -- メソッド: load_module (name=None)

     ロードするモジュールの名前指定がオプションの、 *note
     importlib.abc.Loader.load_module(): 835. の具象実装です。

     バージョン 3.6 で非推奨: 代わりに *note
     importlib.abc.Loader.exec_module(): 836. を使用してください。

 -- クラス: importlib.machinery.ExtensionFileLoader (fullname, path)

     拡張モジュールのための *note importlib.abc.ExecutionLoader: 438d. の
     具象実装です。

     'fullname' 引数はローダーがサポートするモジュールの名前を指定します
     。'path' 引数は拡張モジュールのファイルへのパスです。

     Note that, by default, importing an extension module will fail in
     subinterpreters if it doesn't implement multi-phase init (see PEP
     489(3)), even if it would otherwise import successfully.

     Added in version 3.3.

     バージョン 3.12 で変更: Multi-phase init is now required for use in
     subinterpreters.

      -- の属性: name

          ローダーがサポートするモジュールの名前です。

      -- の属性: path

          拡張モジュールへのパスです。

      -- メソッド: create_module (spec)

          与えられたスペックから PEP 489(4) に従ってモジュールオブジェク
          トを作成します。

          Added in version 3.5.

      -- メソッド: exec_module (module)

          与えられたモジュールオブジェクトを PEP 489(5) に従って初期化し
          ます。

          Added in version 3.5.

      -- メソッド: is_package (fullname)

          *note EXTENSION_SUFFIXES: 4de. に基づいて、ファイルパスがパッ
          ケージの ‘__init__’ モジュールを指していれば ‘True’ を返します
          。

      -- メソッド: get_code (fullname)

          拡張モジュールにコードオブジェクトがなければ ‘None’ を返します
          。

      -- メソッド: get_source (fullname)

          拡張モジュールにソースコードがなければ ‘None’ を返します。

      -- メソッド: get_filename (fullname)

          *note path: 43b7. を返します。

          Added in version 3.4.

 -- クラス: importlib.machinery.NamespaceLoader (name, path,
          path_finder)

     A concrete implementation of *note importlib.abc.InspectLoader:
     f21. for namespace packages.  This is an alias for a private class
     and is only made public for introspecting the ‘__loader__’
     attribute on namespace packages:

          >>> from importlib.machinery import NamespaceLoader
          >>> import my_namespace
          >>> isinstance(my_namespace.__loader__, NamespaceLoader)
          True
          >>> import importlib.abc
          >>> isinstance(my_namespace.__loader__, importlib.abc.Loader)
          True

     Added in version 3.11.

 -- クラス: importlib.machinery.ModuleSpec (name, loader, *,
          origin=None, loader_state=None, is_package=None)

     A specification for a module's import-system-related state.  This
     is typically exposed as the module's *note __spec__: 1e77.
     attribute.  Many of these attributes are also available directly on
     a module: for example, ‘module.__spec__.origin == module.__file__’.
     Note, however, that while the 'values' are usually equivalent, they
     can differ since there is no synchronization between the two
     objects.  For example, it is possible to update the module's *note
     __file__: 1e7d. at runtime and this will not be automatically
     reflected in the module's *note __spec__.origin: 43bd, and vice
     versa.

     Added in version 3.4.

      -- の属性: name

          The module's fully qualified name (see *note module.__name__:
          1350.).  The *note finder: 1e7e. should always set this
          attribute to a non-empty string.

      -- の属性: loader

          The *note loader: 1614. used to load the module (see *note
          module.__loader__: 2c3.).  The *note finder: 1e7e. should
          always set this attribute.

      -- の属性: origin

          The location the *note loader: 1614. should use to load the
          module (see *note module.__file__: 1e7d.).  For example, for
          modules loaded from a ‘.py’ file this is the filename.  The
          *note finder: 1e7e. should always set this attribute to a
          meaningful value for the *note loader: 1614. to use.  In the
          uncommon case that there is not one (like for namespace
          packages), it should be set to ‘None’.

      -- の属性: submodule_search_locations

          A (possibly empty) *note sequence: 4be. of strings enumerating
          the locations in which a package's submodules will be found
          (see *note module.__path__: 1bd8.).  Most of the time there
          will only be a single directory in this list.

          The *note finder: 1e7e. should set this attribute to a
          sequence, even an empty one, to indicate to the import system
          that the module is a package.  It should be set to ‘None’ for
          non-package modules.  It is set automatically later to a
          special object for namespace packages.

      -- の属性: loader_state

          The *note finder: 1e7e. may set this attribute to an object
          containing additional, module-specific data to use when
          loading the module.  Otherwise it should be set to ‘None’.

      -- の属性: cached

          The filename of a compiled version of the module's code (see
          *note module.__cached__: 2b7.).  The *note finder: 1e7e.
          should always set this attribute but it may be ‘None’ for
          modules that do not need compiled code stored.

      -- の属性: parent

          (Read-only) The fully qualified name of the package the module
          is in (or the empty string for a top-level module).  See *note
          module.__package__: 2b9.  If the module is a package then this
          is the same as *note name: 1e78.

      -- の属性: has_location

          ‘True’ if the spec's *note origin: 43bd. refers to a loadable
          location, ‘False’ otherwise.  This value impacts how ‘origin’
          is interpreted and how the module's *note __file__: 1e7d. is
          populated.

 -- クラス: importlib.machinery.AppleFrameworkLoader (name, path)

     フレームワーク形式の拡張モジュールを読み込み事ができる、特殊な
     *note importlib.machinery.ExtensionFileLoader: c7e. です。

     iOS App Store との互換性のため、 iOS アプリの 'すべての' バイナリモ
     ジュールは、パッケージ化されたアプリの ‘Frameworks’ フォルダーに保
     存された、適切なメタデータ付きのフレームワークにある動的ライブラリ
     である必要があります。フレームワークごとにバイナリは一つだけで、
     Frameworks フォルダーの外に実行可能バイナリデータを設置することはで
     きません。

     To accommodate this requirement, when running on iOS, extension
     module binaries are 'not' packaged as ‘.so’ files on ‘sys.path’,
     but as individual standalone frameworks.  To discover those
     frameworks, this loader is be registered against the ‘.fwork’ file
     extension, with a ‘.fwork’ file acting as a placeholder in the
     original location of the binary on ‘sys.path’.  The ‘.fwork’ file
     contains the path of the actual binary in the ‘Frameworks’ folder,
     relative to the app bundle.  To allow for resolving a
     framework-packaged binary back to the original location, the
     framework is expected to contain a ‘.origin’ file that contains the
     location of the ‘.fwork’ file, relative to the app bundle.

     例えば、‘from foo.bar import _whiz’ をインポートする場合を考えてみ
     ましょう。 ‘_whiz’ がバイナリモジュール
     ‘sources/foo/bar/_whiz.abi3.so’ で実装されており、 ‘sources’ のアプ
     リケーションバンドルからの相対パスが ‘sys.path’ に登録されています
     。このモジュールは
     ‘Frameworks/foo.bar._whiz.framework/foo.bar._whiz’ （フレームワーク
     名はモジュールの完全なインポートパスから命名されています）として、
     ‘Info.plist’ ファイルをバイナリをフレームワークとして識別する
     ‘.framework’ ディレクトリ内に設置して配布しなければなりません。
     ‘foo.bar._whiz’ モジュールは、元の場所で、
     ‘Frameworks/foo.bar._whiz/foo.bar._whiz’ のパスを含む
     ‘sources/foo/bar/_whiz.abi3.fwork’ マーカーファイルに記述されます。
     また、フレームワークは、 ‘.fwork’ へのパスを含む
     ‘Frameworks/foo.bar._whiz.framework/foo.bar._whiz.origin’ も含まな
     ければなりません。

     モジュールがこのローダーで読み込まれるとき、モジュールの ‘__file__’
     は ‘.fwork’ ファイルの場所となります。これにより、コードはモジュー
     ルの ‘__file__’ をファイルシステム横断用のアンカーとして使用できま
     す。しかし、 spec origin は、 ‘.framework’ フォルダー下のバイナリの
     '実際の' 場所を参照します。

     The Xcode project building the app is responsible for converting
     any ‘.so’ files from wherever they exist in the ‘PYTHONPATH’ into
     frameworks in the ‘Frameworks’ folder (including stripping
     extensions from the module file, the addition of framework
     metadata, and signing the resulting framework), and creating the
     ‘.fwork’ and ‘.origin’ files.  This will usually be done with a
     build step in the Xcode project; see the iOS documentation for
     details on how to construct this build step.

     Added in version 3.13.

     *note Availability: 1cbe.: iOS.

      -- の属性: name

          ローダーがサポートするモジュールの名前です。

      -- の属性: path

          拡張モジュールの ‘.fwork’ ファイルへのパス。

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/importlib/machinery.py

   (2) https://peps.python.org/pep-0489/

   (3) https://peps.python.org/pep-0489/

   (4) https://peps.python.org/pep-0489/

   (5) https://peps.python.org/pep-0489/


File: python.info,  Node: importlib util -- インポータのためのユーティリティコード,  Next: 使用例<47>,  Prev: importlib machinery -- インポータおよびパスフック,  Up: importlib --- import の実装

5.31.5.5 ‘importlib.util’ - インポータのためのユーティリティコード
..................................................................

'ソースコード:' Lib/importlib/util.py(1)

__________________________________________________________________

このモジュールには、 *note インポーター: 1f54. の構築を助ける様々なオブ
ジェクトがあります。

 -- の属性: importlib.util.MAGIC_NUMBER

     バイトコードバージョン番号を表しているバイト列。バイトコードのロー
     ド／書き込みについてヘルプが必要なら *note
     importlib.abc.SourceLoader: 4394. を参照してください。

     Added in version 3.4.

 -- の関数: importlib.util.cache_from_source (path, debug_override=None,
          *, optimization=None)

     ソース 'path' に関連付けられたバイトコンパイルされたファイルの PEP
     3147(2)/ PEP 488(3) パスを返します。例えば、 'path' が
     ‘/foo/bar/baz.py’ なら、 Python 3.2 の場合返り値は
     ‘/foo/bar/__pycache__/baz.cpython-32.pyc’ になります。 ‘cpython-32’
     という文字列は、現在のマジックタグから得られます (マジックタグにつ
     いては ‘get_tag()’ を参照; ‘sys.implementation.cache_tag’ が未定義
     なら *note NotImplementedError: 209. が送出されます。)

     'optimization' パラメータは、バイトコードファイルの最適化レベルを指
     定するために使われます。空文字列は最適化しないことを表します。した
     がって、 'optimization' が ‘''’ のとき ‘/foo/bar/baz.py’ に対して
     ‘/foo/bar/__pycache__/baz.cpython-32.pyc’ というバイトコードパスが
     返ります。 ‘None’ にするとインタープリタの最適化レベルが使われます
     。それ以外では値の文字列表現が使われます。したがって、
     'optimization' が ‘2’ のとき ‘/foo/bar/baz.py’ に対して
     ‘/foo/bar/__pycache__/baz.cpython-32.opt-2.pyc’ というバイトコード
     パスが返ります。 'optimization' の文字列表現は英数字だけが可能で、
     そうでなければ *note ValueError: 1e3. が上げられます。

     'debug_override' パラメータは deprecated で、システムの ‘__debug__’
     値をオーバーライドするために使用できます。 ‘True’ 値は
     'optimization' を空文字列に設定するのと等価です。 ‘False’ 値は
     'optimization' を ‘1’ に設定するのと同等です。もし 'debug_override'
     と 'optimization' のどちらも ‘None’ 以外であれば *note TypeError:
     502. が上げられます。

     Added in version 3.4.

     バージョン 3.5 で変更: 'optimization' パラメータが追加され、
     'debug_override' パラメータは deprecated になりました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: importlib.util.source_from_cache (path)

     PEP 3147(4) ファイル名への 'path' が与えられると、関連するソースコ
     ードのファイルパスを返します。例えば、 'path' が
     ‘/foo/bar/__pycache__/baz.cpython-32.pyc’ なら、返されるパスは
     ‘/foo/bar/baz.py’ になります。 'path' は存在する必要はありませんが
     、 PEP 3147(5) または PEP 488(6) フォーマットに一致しない場合は
     *note ValueError: 1e3. が送出されます。
     ‘sys.implementation.cache_tag’ が定義されていない場合、 *note
     NotImplementedError: 209. が送出されます。

     Added in version 3.4.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: importlib.util.decode_source (source_bytes)

     与えられたソースコードを表すバイト列をデコードして、文字列としてそ
     れを一般的な改行形式 (universal newlines) で返します (*note
     importlib.abc.InspectLoader.get_source(): f25. で要求されるように
     )。

     Added in version 3.4.

 -- の関数: importlib.util.resolve_name (name, package)

     相対的なモジュール名を解決して絶対的なものにします。

     'name' の先頭にドットがなければ、単に 'name' が返されます。これによ
     り、例えば ‘importlib.util.resolve_name('sys', __spec__.parent)’ を
     使うときに 'package' 変数が必要かどうかを確認する必要がなくなります
     。

     'name' が相対的なモジュール名であるにもかかわらず 'package' が偽値
     (例えば ‘None’ や空文字列) ならば、 *note ImportError: 3f2. が送出
     されます。相対的な名前がそれを含むパッケージから抜け出る (例えば
     ‘spam’ パッケージ内から ‘..bacon’ を要求する) 場合にも *note
     ImportError: 3f2. が送出されます。

     Added in version 3.3.

     バージョン 3.9 で変更: To improve consistency with import
     statements, raise *note ImportError: 3f2. instead of *note
     ValueError: 1e3. for invalid relative import attempts.

 -- の関数: importlib.util.find_spec (name, package=None)

     Find the *note spec: 1e76. for a module, optionally relative to the
     specified 'package' name.  If the module is in *note sys.modules:
     18d6, then ‘sys.modules[name].__spec__’ is returned (unless the
     spec would be ‘None’ or is not set, in which case *note ValueError:
     1e3. is raised).  Otherwise a search using *note sys.meta_path:
     cf9. is done.  ‘None’ is returned if no spec is found.

     'name' がサブモジュールを示している (ドットを含む) 場合、親モジュー
     ルは自動的にインポートされます。

     'name' と 'package' は ‘import_module()’ に対するものと同じように機
     能します。

     Added in version 3.4.

     バージョン 3.7 で変更: Raises *note ModuleNotFoundError: b15.
     instead of *note AttributeError: 326. if 'package' is in fact not a
     package (i.e.  lacks a *note __path__: 1bd8. attribute).

 -- の関数: importlib.util.module_from_spec (spec)

     'spec' と *note spec.loader.create_module: c7c. に基づいて新しいモ
     ジュールを作ります。

     *note spec.loader.create_module: c7c. が ‘None’ を返さない場合は、
     既に存在するどの属性もリセットされません。また、 'spec' にアクセス
     したり属性をモジュールに設定したりする際に *note AttributeError:
     326. 例外が起きても例外は送出されません。

     この関数は、新しいモジュールを作る方法として *note
     types.ModuleType: de0. よりも推奨されます。なぜなら、できるだけ多く
     のインポートコントロールされた属性をモジュールに設定するために
     'spec' が使用されるからです。

     Added in version 3.5.

 -- の関数: importlib.util.spec_from_loader (name, loader, *,
          origin=None, is_package=None)

     この関数は、スペックに不足している情報を埋めるために *note
     ModuleSpec: 1dcb. のような利用可能な *note loader: 1614. API を使い
     ます。

     Added in version 3.4.

 -- の関数: importlib.util.spec_from_file_location (name, location, *,
          loader=None, submodule_search_locations=None)

     ファイルへのパスにもとづいて *note ModuleSpec: 1dcb. インスタンスを
     生成するためのファクトリー関数。不足している情報は、ローダー API を
     利用してスペックから得られる情報と、モジュールがファイルベースであ
     るという暗黙的な情報によって埋められます。

     Added in version 3.4.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- の関数: importlib.util.source_hash (source_bytes)

     Return the hash of 'source_bytes' as bytes.  A hash-based ‘.pyc’
     file embeds the *note source_hash(): 43c3. of the corresponding
     source file's contents in its header.

     Added in version 3.7.

 -- の関数: importlib.util._incompatible_extension_module_restrictions
          (*, disable_check)

     A context manager that can temporarily skip the compatibility check
     for extension modules.  By default the check is enabled and will
     fail when a single-phase init module is imported in a
     subinterpreter.  It will also fail for a multi-phase init module
     that doesn't explicitly support a per-interpreter GIL, when
     imported in an interpreter with its own GIL.

     Note that this function is meant to accommodate an unusual case;
     one which is likely to eventually go away.  There's is a pretty
     good chance this is not what you were looking for.

     You can get the same effect as this function by implementing the
     basic interface of multi-phase init ( PEP 489(7)) and lying about
     support for multiple interpreters (or per-interpreter GIL).

          警告: Using this function to disable the check can lead to
          unexpected behavior and even crashes.  It should only be used
          during extension module development.

     Added in version 3.12.

 -- クラス: importlib.util.LazyLoader (loader)

     モジュールが属性アクセスできるようになるまで、モジュールのローダー
     の実行を遅延するクラス。

     This class 'only' works with loaders that define *note
     exec_module(): 836. as control over what module type is used for
     the module is required.  For those same reasons, the loader's *note
     create_module(): c7c. method must return ‘None’ or a type for which
     its ‘__class__’ attribute can be mutated along with not using *note
     slots: 5a9.  Finally, modules which substitute the object placed
     into *note sys.modules: 18d6. will not work as there is no way to
     properly replace the module references throughout the interpreter
     safely; *note ValueError: 1e3. is raised if such a substitution is
     detected.

          注釈: 起動時間が重要なプロジェクトでは、もし決して使われないモ
          ジュールがあれば、このクラスを使ってモジュールをロードするコス
          トを最小化できるかもしれません。スタートアップ時間が重要でない
          プロジェクトでは、遅延されたロードの際に発生して文脈の外で起こ
          るエラーメッセージのため、このクラスの使用は '著しく' 推奨され
          ません。

     Added in version 3.5.

     バージョン 3.6 で変更: Began calling *note create_module(): c7c,
     removing the compatibility warning for *note
     importlib.machinery.BuiltinImporter: c7d. and *note
     importlib.machinery.ExtensionFileLoader: c7e.

      -- メソッド: classmethod factory (loader)

          遅延ローダを生成する callable を返すクラスメソッド。これは、ロ
          ーダーをインスタンスとしてではなくクラスとして渡すような状況に
          おいて使われることを意図しています。

               suffixes = importlib.machinery.SOURCE_SUFFIXES
               loader = importlib.machinery.SourceFileLoader
               lazy_loader = importlib.util.LazyLoader.factory(loader)
               finder = importlib.machinery.FileFinder(path, (lazy_loader, suffixes))

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/importlib/util.py

   (2) https://peps.python.org/pep-3147/

   (3) https://peps.python.org/pep-0488/

   (4) https://peps.python.org/pep-3147/

   (5) https://peps.python.org/pep-3147/

   (6) https://peps.python.org/pep-0488/

   (7) https://peps.python.org/pep-0489/


File: python.info,  Node: 使用例<47>,  Prev: importlib util -- インポータのためのユーティリティコード,  Up: importlib --- import の実装

5.31.5.6 使用例
...............

* Menu:

* プログラムからのインポート::
* モジュールがインポートできるか確認する::
* ソースファイルから直接インポートする::
* Implementing lazy imports::
* インポーターのセットアップ::
* Approximating importlib.import_module(): Approximating importlib import_module.


File: python.info,  Node: プログラムからのインポート,  Next: モジュールがインポートできるか確認する,  Up: 使用例<47>

5.31.5.7 プログラムからのインポート
...................................

プログラムからモジュールをインポートするには、 *note
importlib.import_module(): 4e1. を使ってください。

     import importlib

     itertools = importlib.import_module('itertools')


File: python.info,  Node: モジュールがインポートできるか確認する,  Next: ソースファイルから直接インポートする,  Prev: プログラムからのインポート,  Up: 使用例<47>

5.31.5.8 モジュールがインポートできるか確認する
...............................................

インポートを実際に行わずに、あるモジュールがインポートできるかを知る必要
がある場合は、 *note importlib.util.find_spec(): 2ae. を使ってください。

Note that if ‘name’ is a submodule (contains a dot), *note
importlib.util.find_spec(): 2ae. will import the parent module.

     import importlib.util
     import sys

     # For illustrative purposes.
     name = 'itertools'

     if name in sys.modules:
         print(f"{name!r} already in sys.modules")
     elif (spec := importlib.util.find_spec(name)) is not None:
         # If you chose to perform the actual import ...
         module = importlib.util.module_from_spec(spec)
         sys.modules[name] = module
         spec.loader.exec_module(module)
         print(f"{name!r} has been imported")
     else:
         print(f"can't find the {name!r} module")


File: python.info,  Node: ソースファイルから直接インポートする,  Next: Implementing lazy imports,  Prev: モジュールがインポートできるか確認する,  Up: 使用例<47>

5.31.5.9 ソースファイルから直接インポートする
.............................................

This recipe should be used with caution: it is an approximation of an
import statement where the file path is specified directly, rather than
*note sys.path: 38e. being searched.  Alternatives should first be
considered first, such as modifying *note sys.path: 38e. when a proper
module is required, or using *note runpy.run_path(): 166. when the
global namespace resulting from running a Python file is appropriate.

To import a Python source file directly from a path, use the following
recipe:

     import importlib.util
     import sys


     def import_from_path(module_name, file_path):
         spec = importlib.util.spec_from_file_location(module_name, file_path)
         module = importlib.util.module_from_spec(spec)
         sys.modules[module_name] = module
         spec.loader.exec_module(module)
         return module


     # For illustrative purposes only (use of `json` is arbitrary).
     import json
     file_path = json.__file__
     module_name = json.__name__

     # Similar outcome as `import json`.
     json = import_from_path(module_name, file_path)


File: python.info,  Node: Implementing lazy imports,  Next: インポーターのセットアップ,  Prev: ソースファイルから直接インポートする,  Up: 使用例<47>

5.31.5.10 Implementing lazy imports
...................................

The example below shows how to implement lazy imports:

     >>> import importlib.util
     >>> import sys
     >>> def lazy_import(name):
     ...     spec = importlib.util.find_spec(name)
     ...     loader = importlib.util.LazyLoader(spec.loader)
     ...     spec.loader = loader
     ...     module = importlib.util.module_from_spec(spec)
     ...     sys.modules[name] = module
     ...     loader.exec_module(module)
     ...     return module
     ...
     >>> lazy_typing = lazy_import("typing")
     >>> #lazy_typing is a real module object,
     >>> #but it is not loaded in memory yet.
     >>> lazy_typing.TYPE_CHECKING
     False


File: python.info,  Node: インポーターのセットアップ,  Next: Approximating importlib import_module,  Prev: Implementing lazy imports,  Up: 使用例<47>

5.31.5.11 インポーターのセットアップ
....................................

For deep customizations of import, you typically want to implement an
*note importer: 1f54.  This means managing both the *note finder: 1e7e.
and *note loader: 1614. side of things.  For finders there are two
flavours to choose from depending on your needs: a *note meta path
finder: 1045. or a *note path entry finder: 1046.  The former is what
you would put on *note sys.meta_path: cf9. while the latter is what you
create using a *note path entry hook: 1f66. on *note sys.path_hooks:
fee. which works with *note sys.path: 38e. entries to potentially create
a finder.  This example will show you how to register your own importers
so that import will use them (for creating an importer for yourself,
read the documentation for the appropriate classes defined within this
package):

     import importlib.machinery
     import sys

     # For illustrative purposes only.
     SpamMetaPathFinder = importlib.machinery.PathFinder
     SpamPathEntryFinder = importlib.machinery.FileFinder
     loader_details = (importlib.machinery.SourceFileLoader,
                       importlib.machinery.SOURCE_SUFFIXES)

     # Setting up a meta path finder.
     # Make sure to put the finder in the proper location in the list in terms of
     # priority.
     sys.meta_path.append(SpamMetaPathFinder)

     # Setting up a path entry finder.
     # Make sure to put the path hook in the proper location in the list in terms
     # of priority.
     sys.path_hooks.append(SpamPathEntryFinder.path_hook(loader_details))


File: python.info,  Node: Approximating importlib import_module,  Prev: インポーターのセットアップ,  Up: 使用例<47>

5.31.5.12 Approximating ‘importlib.import_module()’
...................................................

Import itself is implemented in Python code, making it possible to
expose most of the import machinery through importlib.  The following
helps illustrate the various APIs that importlib exposes by providing an
approximate implementation of *note importlib.import_module(): 4e1.:

     import importlib.util
     import sys

     def import_module(name, package=None):
         """An approximate implementation of import."""
         absolute_name = importlib.util.resolve_name(name, package)
         try:
             return sys.modules[absolute_name]
         except KeyError:
             pass

         path = None
         if '.' in absolute_name:
             parent_name, _, child_name = absolute_name.rpartition('.')
             parent_module = import_module(parent_name)
             path = parent_module.__spec__.submodule_search_locations
         for finder in sys.meta_path:
             spec = finder.find_spec(absolute_name, path)
             if spec is not None:
                 break
         else:
             msg = f'No module named {absolute_name!r}'
             raise ModuleNotFoundError(msg, name=absolute_name)
         module = importlib.util.module_from_spec(spec)
         sys.modules[absolute_name] = module
         spec.loader.exec_module(module)
         if path is not None:
             setattr(parent_module, child_name, module)
         return module


File: python.info,  Node: importlib resources -- パッケージリソースの読み取り、オープン、アクセス,  Next: importlib resources abc -- リソースの抽象基底クラス,  Prev: importlib --- import の実装,  Up: モジュールのインポート

5.31.6 ‘importlib.resources’ - パッケージリソースの読み取り、オープン、アクセス
-------------------------------------------------------------------------------

'ソースコード:' Lib/importlib/resources/__init__.py(1)

__________________________________________________________________

Added in version 3.7.

This module leverages Python's import system to provide access to
'resources' within 'packages'.

"Resources" are file-like resources associated with a module or package
in Python.  The resources may be contained directly in a package, within
a subdirectory contained in that package, or adjacent to modules outside
a package.  Resources may be text or binary.  As a result, Python module
sources (.py) of a package and compilation artifacts (pycache) are
technically de-facto resources of that package.  In practice, however,
resources are primarily those non-Python artifacts exposed specifically
by the package author.

Resources can be opened or read in either binary or text mode.

リソースは大体ディレクトリの中のファイルに似ていますが、これは単なる例え
話であることを頭に入れておくことが重要です。例えば、パッケージとそのリソ
ースは *note zipimport: 118. を使って zip ファイルからインポートすること
ができます。

     注釈: このモジュールは、 pkg_resources(2) Basic Resource Access(3)
     に似た機能を、そのパッケージのパフォーマンスのオーバーヘッドを伴わ
     ずに提供します。 これにより、パッケージに含まれるリソースの読み込み
     がより簡単になり、より安定した一貫した意味付けができるようになりま
     す。

     このモジュールのスタンドアローンバックポートでは、
     importlib.resources の使用(4) と pkg_resources から
     importlib.resources への移行(5) についての詳細情報を提供しています
     。

*note Loaders: e90. でリソースの読み込みをサポートしたい場合は、 *note
importlib.resources.abc.ResourceReader: 438a. で指定された
‘get_resource_reader(fullname)’ メソッドを実装しなければいけません。

 -- クラス: importlib.resources.Anchor

     Represents an anchor for resources, either a *note module object:
     de0. or a module name as a string.  Defined as ‘Union[str,
     ModuleType]’.

 -- の関数: importlib.resources.files (anchor: Anchor | None = None)

     Returns a *note Traversable: 1d4. object representing the resource
     container (think directory) and its resources (think files).  A
     Traversable may contain other containers (think subdirectories).

     'anchor' is an optional *note Anchor: 43d0.  If the anchor is a
     package, resources are resolved from that package.  If a module,
     resources are resolved adjacent to that module (in the same package
     or the package root).  If the anchor is omitted, the caller's
     module is used.

     Added in version 3.9.

     バージョン 3.12 で変更: 'package' parameter was renamed to
     'anchor'.  'anchor' can now be a non-package module and if omitted
     will default to the caller's module.  'package' is still accepted
     for compatibility but will raise a *note DeprecationWarning: 18a.
     Consider passing the anchor positionally or using
     ‘importlib_resources >= 5.10’ for a compatible interface on older
     Pythons.

 -- の関数: importlib.resources.as_file (traversable)

     Given a *note Traversable: 1d4. object representing a file or
     directory, typically from *note importlib.resources.files(): 45b,
     return a context manager for use in a *note with: 59c. statement.
     The context manager provides a *note pathlib.Path: 20a. object.

     Exiting the context manager cleans up any temporary file or
     directory created when the resource was extracted from e.g.  a zip
     file.

     Use ‘as_file’ when the Traversable methods (‘read_text’, etc) are
     insufficient and an actual file or directory on the file system is
     required.

     Added in version 3.9.

     バージョン 3.12 で変更: Added support for 'traversable'
     representing a directory.

* Menu:

* 関数 API::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/importlib/resources/__init__.py

   (2) https://setuptools.readthedocs.io/en/latest/pkg_resources.html

   (3) 
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#basic-resource-access

   (4) https://importlib-resources.readthedocs.io/en/latest/using.html

   (5) 
https://importlib-resources.readthedocs.io/en/latest/migration.html


File: python.info,  Node: 関数 API,  Up: importlib resources -- パッケージリソースの読み取り、オープン、アクセス

5.31.6.1 関数 API
.................

A set of simplified, backwards-compatible helpers is available.  These
allow common operations in a single function call.

For all the following functions:

   - 'anchor' is an *note Anchor: 43d0, as in *note files(): 45b.
     Unlike in ‘files’, it may not be omitted.

   - 'path_names' are components of a resource's path name, relative to
     the anchor.  For example, to get the text of resource named
     ‘info.txt’, use:

          importlib.resources.read_text(my_module, "info.txt")

     Like *note Traversable.joinpath: 1d4, The individual components
     should use forward slashes (‘/’) as path separators.  For example,
     the following are equivalent:

          importlib.resources.read_binary(my_module, "pics/painting.png")
          importlib.resources.read_binary(my_module, "pics", "painting.png")

     For backward compatibility reasons, functions that read text
     require an explicit 'encoding' argument if multiple 'path_names'
     are given.  For example, to get the text of ‘info/chapter1.txt’,
     use:

          importlib.resources.read_text(my_module, "info", "chapter1.txt",
                                        encoding='utf-8')

 -- の関数: importlib.resources.open_binary (anchor, *path_names)

     Open the named resource for binary reading.

     See *note the introduction: 43d2. for details on 'anchor' and
     'path_names'.

     This function returns a *note BinaryIO: 3e32. object, that is, a
     binary stream open for reading.

     This function is roughly equivalent to:

          files(anchor).joinpath(*path_names).open('rb')

     バージョン 3.13 で変更: Multiple 'path_names' are accepted.

 -- の関数: importlib.resources.open_text (anchor, *path_names,
          encoding='utf-8', errors='strict')

     Open the named resource for text reading.  By default, the contents
     are read as strict UTF-8.

     See *note the introduction: 43d2. for details on 'anchor' and
     'path_names'.  'encoding' and 'errors' have the same meaning as in
     built-in *note open(): 4e5.

     For backward compatibility reasons, the 'encoding' argument must be
     given explicitly if there are multiple 'path_names'.  This
     limitation is scheduled to be removed in Python 3.15.

     This function returns a *note TextIO: 3e31. object, that is, a text
     stream open for reading.

     This function is roughly equivalent to:

          files(anchor).joinpath(*path_names).open('r', encoding=encoding)

     バージョン 3.13 で変更: Multiple 'path_names' are accepted.
     'encoding' and 'errors' must be given as keyword arguments.

 -- の関数: importlib.resources.read_binary (anchor, *path_names)

     Read and return the contents of the named resource as *note bytes:
     1a4.

     See *note the introduction: 43d2. for details on 'anchor' and
     'path_names'.

     This function is roughly equivalent to:

          files(anchor).joinpath(*path_names).read_bytes()

     バージョン 3.13 で変更: Multiple 'path_names' are accepted.

 -- の関数: importlib.resources.read_text (anchor, *path_names,
          encoding='utf-8', errors='strict')

     Read and return the contents of the named resource as *note str:
     418.  By default, the contents are read as strict UTF-8.

     See *note the introduction: 43d2. for details on 'anchor' and
     'path_names'.  'encoding' and 'errors' have the same meaning as in
     built-in *note open(): 4e5.

     For backward compatibility reasons, the 'encoding' argument must be
     given explicitly if there are multiple 'path_names'.  This
     limitation is scheduled to be removed in Python 3.15.

     This function is roughly equivalent to:

          files(anchor).joinpath(*path_names).read_text(encoding=encoding)

     バージョン 3.13 で変更: Multiple 'path_names' are accepted.
     'encoding' and 'errors' must be given as keyword arguments.

 -- の関数: importlib.resources.path (anchor, *path_names)

     Provides the path to the 'resource' as an actual file system path.
     This function returns a context manager for use in a *note with:
     59c. statement.  The context manager provides a *note pathlib.Path:
     20a. object.

     Exiting the context manager cleans up any temporary files created,
     e.g.  when the resource needs to be extracted from a zip file.

     For example, the *note stat(): 7ee. method requires an actual file
     system path; it can be used like this:

          with importlib.resources.path(anchor, "resource.txt") as fspath:
              result = fspath.stat()

     See *note the introduction: 43d2. for details on 'anchor' and
     'path_names'.

     This function is roughly equivalent to:

          as_file(files(anchor).joinpath(*path_names))

     バージョン 3.13 で変更: Multiple 'path_names' are accepted.
     'encoding' and 'errors' must be given as keyword arguments.

 -- の関数: importlib.resources.is_resource (anchor, *path_names)

     Return ‘True’ if the named resource exists, otherwise ‘False’.
     This function does not consider directories to be resources.

     See *note the introduction: 43d2. for details on 'anchor' and
     'path_names'.

     This function is roughly equivalent to:

          files(anchor).joinpath(*path_names).is_file()

     バージョン 3.13 で変更: Multiple 'path_names' are accepted.

 -- の関数: importlib.resources.contents (anchor, *path_names)

     Return an iterable over the named items within the package or path.
     The iterable returns names of resources (e.g.  files) and
     non-resources (e.g.  directories) as *note str: 418.  The iterable
     does not recurse into subdirectories.

     See *note the introduction: 43d2. for details on 'anchor' and
     'path_names'.

     This function is roughly equivalent to:

          for resource in files(anchor).joinpath(*path_names).iterdir():
              yield resource.name

     バージョン 3.11 で非推奨: Prefer ‘iterdir()’ as above, which offers
     more control over the results and richer functionality.


File: python.info,  Node: importlib resources abc -- リソースの抽象基底クラス,  Next: importlib metadata -- パッケージメタデータへのアクセス,  Prev: importlib resources -- パッケージリソースの読み取り、オープン、アクセス,  Up: モジュールのインポート

5.31.7 ‘importlib.resources.abc’ - リソースの抽象基底クラス
-----------------------------------------------------------

'ソースコード:' Lib/importlib/resources/abc.py(1)

__________________________________________________________________

Added in version 3.11.

 -- クラス: importlib.resources.abc.ResourceReader

     'TraversableResources に取って代わられました'

     'resources' の読み出し機能を提供する *note 抽象基底クラス (abstract
     base class, ABC): 1186. です。

     From the perspective of this ABC, a 'resource' is a binary artifact
     that is shipped within a package.  Typically this is something like
     a data file that lives next to the ‘__init__.py’ file of the
     package.  The purpose of this class is to help abstract out the
     accessing of such data files so that it does not matter if the
     package and its data file(s) are stored e.g.  in a zip file versus
     on the file system.

     For any of methods of this class, a 'resource' argument is expected
     to be a *note path-like object: 280. which represents conceptually
     just a file name.  This means that no subdirectory paths should be
     included in the 'resource' argument.  This is because the location
     of the package the reader is for, acts as the "directory".  Hence
     the metaphor for directories and file names is packages and
     resources, respectively.  This is also why instances of this class
     are expected to directly correlate to a specific package (instead
     of potentially representing multiple packages or a module).

     Loaders that wish to support resource reading are expected to
     provide a method called ‘get_resource_reader(fullname)’ which
     returns an object implementing this ABC's interface.  If the module
     specified by fullname is not a package, this method should return
     *note None: 641.  An object compatible with this ABC should only be
     returned when the specified module is a package.

     Deprecated since version 3.12, will be removed in version 3.14: Use
     *note importlib.resources.abc.TraversableResources: 2a6. instead.

      -- メソッド: abstractmethod open_resource (resource)

          Returns an opened, *note file-like object: 24e0. for binary
          reading of the 'resource'.

          リソースが見付からない場合は、 *note FileNotFoundError: e8f. が
          送出されます。

      -- メソッド: abstractmethod resource_path (resource)

          'resource' へのファイルシステムパスを返します。

          リソースの実体がファイルシステムに存在しない場合、 *note
          FileNotFoundError: e8f. が送出されます。

      -- メソッド: abstractmethod is_resource (name)

          'name' という名前がリソースだと見なせるなら ‘True’ を返します
          。 'name' が存在しない場合は *note FileNotFoundError: e8f. が
          送出されます。

      -- メソッド: abstractmethod contents ()

          Returns an *note iterable: 10ad. of strings over the contents
          of the package.  Do note that it is not required that all
          names returned by the iterator be actual resources, e.g.  it
          is acceptable to return names for which *note is_resource():
          43d7. would be false.

          Allowing non-resource names to be returned is to allow for
          situations where how a package and its resources are stored
          are known a priori and the non-resource names would be useful.
          For instance, returning subdirectory names is allowed so that
          when it is known that the package and resources are stored on
          the file system then those subdirectory names can be used
          directly.

          The abstract method returns an iterable of no items.

 -- クラス: importlib.resources.abc.Traversable

     An object with a subset of *note pathlib.Path: 20a. methods
     suitable for traversing directories and opening files.

     For a representation of the object on the file-system, use *note
     importlib.resources.as_file(): 45a.

      -- の属性: name

          Abstract.  The base name of this object without any parent
          references.

      -- メソッド: abstractmethod iterdir ()

          Yield Traversable objects in self.

      -- メソッド: abstractmethod is_dir ()

          Return ‘True’ if self is a directory.

      -- メソッド: abstractmethod is_file ()

          Return ‘True’ if self is a file.

      -- メソッド: abstractmethod joinpath (*pathsegments)

          Traverse directories according to 'pathsegments' and return
          the result as ‘Traversable’.

          Each 'pathsegments' argument may contain multiple names
          separated by forward slashes (‘/’, ‘posixpath.sep’ ).  For
          example, the following are equivalent:

               files.joinpath('subdir', 'subsuddir', 'file.txt')
               files.joinpath('subdir/subsuddir/file.txt')

          Note that some ‘Traversable’ implementations might not be
          updated to the latest version of the protocol.  For
          compatibility with such implementations, provide a single
          argument without path separators to each call to ‘joinpath’.
          For example:

               files.joinpath('subdir').joinpath('subsubdir').joinpath('file.txt')

          バージョン 3.11 で変更: ‘joinpath’ accepts multiple
          'pathsegments', and these segments may contain forward slashes
          as path separators.  Previously, only a single 'child'
          argument was accepted.

      -- メソッド: abstractmethod __truediv__ (child)

          Return Traversable child in self.  Equivalent to
          ‘joinpath(child)’.

      -- メソッド: abstractmethod open (mode='r', *args, **kwargs)

          'mode' may be 'r' or 'rb' to open as text or binary.  Return a
          handle suitable for reading (same as *note pathlib.Path.open:
          2712.).

          When opening as text, accepts encoding parameters such as
          those accepted by *note io.TextIOWrapper: 786.

      -- メソッド: read_bytes ()

          Read contents of self as bytes.

      -- メソッド: read_text (encoding=None)

          Read contents of self as text.

 -- クラス: importlib.resources.abc.TraversableResources

     An abstract base class for resource readers capable of serving the
     *note importlib.resources.files(): 45b. interface.  Subclasses
     *note ResourceReader: 438a. and provides concrete implementations
     of the ‘ResourceReader’'s abstract methods.  Therefore, any loader
     supplying ‘TraversableResources’ also supplies ‘ResourceReader’.

     Loaders that wish to support resource reading are expected to
     implement this interface.

      -- メソッド: abstractmethod files ()

          Returns a *note importlib.resources.abc.Traversable: 1d4.
          object for the loaded package.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/importlib/resources/abc.py


File: python.info,  Node: importlib metadata -- パッケージメタデータへのアクセス,  Next: sys path モジュール検索パスの初期化,  Prev: importlib resources abc -- リソースの抽象基底クラス,  Up: モジュールのインポート

5.31.8 ‘importlib.metadata’ - パッケージメタデータへのアクセス
--------------------------------------------------------------

Added in version 3.8.

バージョン 3.10 で変更: ‘importlib.metadata’ は暫定的なものではなくなり
ました。

'ソースコード:' Lib/importlib/metadata/__init__.py(1)

‘importlib.metadata’ はインストールされた 配布パッケージ(2) のエントリポ
イントやトップレベル名 (あれば、 パッケージ(3) やモジュール) のようなメ
タデータへのアクセスを提供するライブラリです。Pythonのインポートシステム
をベースに構築されており、このライブラリは ‘pkg_resources’ の entry
point API(4) と metadata API(5) にある同様の機能を置き換えることを目的と
しています。*note importlib.resources: 6f. と共に、このパッケージは古く
て効率の悪い ‘pkg_resources’ パッケージを使う必要性を無くすことができま
す。

‘importlib.metadata’ は、Pythonの ‘site-packages’ ディレクトリに pip(6)
などのツールでインストールしたサードパーティの '配布パッケージ' に対して
動作します。具体的には、 ‘dist-info’ や ‘egg-info’ ディレクトリを持つ配
布物や、 コアとなるメタデータの仕様(7) で定義されたメタデータを検出でき
るようにします。

     重要: これらはPythonコード内でインポートできるトップレベルの 'パッ
     ケージ' 名と '必ずしも' 同等であったり、1:1 で対応するものではあり
     ません。1つの '配布パッケージ' は複数の 'パッケージ' (および単一の
     モジュール) を含むことができ、1つのトップレベルの 'パッケージ' は、
     それが名前空間パッケージであれば複数の '配布パッケージ' にマップす
     ることができます。これらのマッピングを得るには *note
     packages_distributions(): 7db. を使用します。

デフォルトでは、配布物のメタデータはファイルシステム上、または *note
sys.path: 38e. のzipアーカイブに保存されます。拡張機構により、メタデータ
はほとんどどこにでも置くことができます。

参考
....

‘https://importlib-metadata.readthedocs.io/’

     ‘importlib_metadata’ のドキュメントは ‘importlib.metadata’ のバック
     ポートです。これには、このモジュールのクラスと関数の APIリファレン
     ス(8) と、 ‘pkg_resources’ の既存のユーザーのための 移行ガイド(9) が
     あります。

* Menu:

* 概要: 概要<3>.
* 機能 API::
* Distributions::
* Distribution Discovery::
* 検索アルゴリズムの拡張::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/importlib/metadata/__init__.py

   (2) 
https://packaging.python.org/ja/latest/glossary/#term-Distribution-Package

   (3) 
https://packaging.python.org/ja/latest/glossary/#term-Import-Package

   (4) 
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points

   (5) 
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#metadata-api

   (6) https://pypi.org/project/pip/

   (7) 
https://packaging.python.org/ja/latest/specifications/core-metadata/#core-metadata

   (8) https://importlib-metadata.readthedocs.io/en/latest/api.html

   (9) 
https://importlib-metadata.readthedocs.io/en/latest/migration.html


File: python.info,  Node: 概要<3>,  Next: 機能 API,  Up: importlib metadata -- パッケージメタデータへのアクセス

5.31.8.1 概要
.............

例えば、‘pip’ を使ってインストールした 配布パッケージ(1) のバージョン文
字列を取得したいとします。 まず、仮想環境を作成し、そこに何かをインスト
ールすることから始めましょう:

     $ python -m venv example
     $ source example/bin/activate
     (example) $ python -m pip install wheel

以下のように実行することで、‘wheel’ のバージョン文字列を取得することがで
きます:

     (example) $ python
     >>> from importlib.metadata import version
     >>> version('wheel')
     '0.32.3'

また、 ‘console_scripts’ や ‘distutils.commands’ などのエントリポイント
のプロパティ(通常は 'group' や 'name' )で選択可能なエントリポイントの集
合を取得することができます。 各グループは *note エントリポイント: 265. オ
ブジェクトの集合を含んでいます。

*note ディストリビューションのメタデータ: 43e7. を取得することができます
。:

     >>> list(metadata('wheel'))
     ['Metadata-Version', 'Name', 'Version', 'Summary', 'Home-page', 'Author', 'Author-email', 'Maintainer', 'Maintainer-email', 'License', 'Project-URL', 'Project-URL', 'Project-URL', 'Keywords', 'Platform', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Requires-Python', 'Provides-Extra', 'Requires-Dist', 'Requires-Dist']

また、 *note 配布物のバージョン番号: 43e8. を取得し、 *note
構成ファイル: 43e9. をリストアップし、配布物の *note 配布物の要件: 43ea.
のリストを取得することができます。

 -- 例外: importlib.metadata.PackageNotFoundError

     Subclass of *note ModuleNotFoundError: b15. raised by several
     functions in this module when queried for a distribution package
     which is not installed in the current Python environment.

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/ja/latest/glossary/#term-Distribution-Package


File: python.info,  Node: 機能 API,  Next: Distributions,  Prev: 概要<3>,  Up: importlib metadata -- パッケージメタデータへのアクセス

5.31.8.2 機能 API
.................

本パッケージは、公開APIを通じて以下の機能を提供します。

* Menu:

* エントリポイント::
* 配布物メタデータ::
* 配布物バージョン::
* 配布物ファイル::
* 配布物の要件::
* Mapping import to distribution packages::


File: python.info,  Node: エントリポイント,  Next: 配布物メタデータ,  Up: 機能 API

5.31.8.3 エントリポイント
.........................

 -- の関数: importlib.metadata.entry_points (**select_params)

     Returns a *note EntryPoints: 43ef. instance describing entry points
     for the current environment.  Any given keyword parameters are
     passed to the ‘select()’ method for comparison to the attributes of
     the individual entry point definitions.

     Note: it is not currently possible to query for entry points based
     on their ‘EntryPoint.dist’ attribute (as different ‘Distribution’
     instances do not currently compare equal, even if they have the
     same attributes)

 -- クラス: importlib.metadata.EntryPoints

     Details of a collection of installed entry points.

     Also provides a ‘.groups’ attribute that reports all identifed
     entry point groups, and a ‘.names’ attribute that reports all
     identified entry point names.

 -- クラス: importlib.metadata.EntryPoint

     Details of an installed entry point.

     Each ‘EntryPoint’ instance has ‘.name’, ‘.group’, and ‘.value’
     attributes and a ‘.load()’ method to resolve the value.  There are
     also ‘.module’, ‘.attr’, and ‘.extras’ attributes for getting the
     components of the ‘.value’ attribute, and ‘.dist’ for obtaining
     information regarding the distribution package that provides the
     entry point.

すべてのエントリポイントに問い合わせる:

     >>> eps = entry_points()

The ‘entry_points()’ function returns a ‘EntryPoints’ object, a
collection of all ‘EntryPoint’ objects with ‘names’ and ‘groups’
attributes for convenience:

     >>> sorted(eps.groups)
     ['console_scripts', 'distutils.commands', 'distutils.setup_keywords', 'egg_info.writers', 'setuptools.installation']

‘EntryPoints’ has a ‘select()’ method to select entry points matching
specific properties.  Select entry points in the ‘console_scripts’
group:

     >>> scripts = eps.select(group='console_scripts')

Equivalently, since ‘entry_points()’ passes keyword arguments through to
select:

     >>> scripts = entry_points(group='console_scripts')

"wheel" という名前の特定のスクリプトを選択します。(wheelプロジェクトにあ
ります):

     >>> 'wheel' in scripts.names
     True
     >>> wheel = scripts['wheel']

同様に、選択時にそのエントリポイントを問い合わせます:

     >>> (wheel,) = entry_points(group='console_scripts', name='wheel')
     >>> (wheel,) = entry_points().select(group='console_scripts', name='wheel')

解決したエントリポイントを検証する:

     >>> wheel
     EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')
     >>> wheel.module
     'wheel.cli'
     >>> wheel.attr
     'main'
     >>> wheel.extras
     []
     >>> main = wheel.load()
     >>> main
     <function main at 0x103528488>

‘group’ と ‘name’ はパッケージの作者によって定義された任意の値で、通常ク
ライアントは特定のグループのエントリポイントを解決したいと思うでしょう。
エントリポイント、その他の定義、使用方法についての詳細は setuptoolsのド
キュメント(1) を参照してください。

バージョン 3.12 で変更: The "selectable" entry points were introduced in
‘importlib_metadata’ 3.6 and Python 3.10.  Prior to those changes,
‘entry_points’ accepted no parameters and always returned a dictionary
of entry points, keyed by group.  With ‘importlib_metadata’ 5.0 and
Python 3.12, ‘entry_points’ always returns an ‘EntryPoints’ object.  See
backports.entry_points_selectable(2) for compatibility options.

バージョン 3.13 で変更: ‘EntryPoint’ objects no longer present a
tuple-like interface (*note __getitem__(): 264.).

   ---------- Footnotes ----------

   (1) https://setuptools.pypa.io/en/latest/userguide/entry_point.html

   (2) https://pypi.org/project/backports.entry_points_selectable/


File: python.info,  Node: 配布物メタデータ,  Next: 配布物バージョン,  Prev: エントリポイント,  Up: 機能 API

5.31.8.4 配布物メタデータ
.........................

 -- の関数: importlib.metadata.metadata (distribution_name)

     Return the distribution metadata corresponding to the named
     distribution package as a *note PackageMetadata: 43f3. instance.

     Raises *note PackageNotFoundError: 43eb. if the named distribution
     package is not installed in the current Python environment.

 -- クラス: importlib.metadata.PackageMetadata

     A concrete implementation of the PackageMetadata protocol(1).

     In addition to providing the defined protocol methods and
     attributes, subscripting the instance is equivalent to calling the
     ‘get()’ method.

Every Distribution Package(2) includes some metadata, which you can
extract using the ‘metadata()’ function:

     >>> wheel_metadata = metadata('wheel')

The keys of the returned data structure name the metadata keywords, and
the values are returned unparsed from the distribution metadata:

     >>> wheel_metadata['Requires-Python']
     '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'

*note PackageMetadata: 43f3. also presents a ‘json’ attribute that
returns all the metadata in a JSON-compatible form per PEP 566(3):

     >>> wheel_metadata.json['requires_python']
     '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'

The full set of available metadata is not described here.  See the PyPA
Core metadata specification(4) for additional details.

バージョン 3.10 で変更: ペイロードを通して提示されるとき、 ‘Description’
がメタデータに含まれるようになりました。行の継続文字は削除されました。

‘json’ 属性が追加されました。

   ---------- Footnotes ----------

   (1) 
https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.PackageMetadata

   (2) 
https://packaging.python.org/en/latest/glossary/#term-Distribution-Package

   (3) https://peps.python.org/pep-0566/

   (4) 
https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata


File: python.info,  Node: 配布物バージョン,  Next: 配布物ファイル,  Prev: 配布物メタデータ,  Up: 機能 API

5.31.8.5 配布物バージョン
.........................

 -- の関数: importlib.metadata.version (distribution_name)

     Return the installed distribution package version for the named
     distribution package.

     Raises *note PackageNotFoundError: 43eb. if the named distribution
     package is not installed in the current Python environment.

The ‘version()’ function is the quickest way to get a Distribution
Package(1)'s version number, as a string:

     >>> version('wheel')
     '0.32.3'

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/glossary/#term-Distribution-Package


File: python.info,  Node: 配布物ファイル,  Next: 配布物の要件,  Prev: 配布物バージョン,  Up: 機能 API

5.31.8.6 配布物ファイル
.......................

 -- の関数: importlib.metadata.files (distribution_name)

     Return the full set of files contained within the named
     distribution package.

     Raises *note PackageNotFoundError: 43eb. if the named distribution
     package is not installed in the current Python environment.

     Returns *note None: 641. if the distribution is found but the
     installation database records reporting the files associated with
     the distribuion package are missing.

 -- クラス: importlib.metadata.PackagePath

     A *note pathlib.PurePath: 473. derived object with additional
     ‘dist’, ‘size’, and ‘hash’ properties corresponding to the
     distribution package's installation metadata for that file.

The ‘files()’ function takes a Distribution Package(1) name and returns
all of the files installed by this distribution.  Each file is reported
as a *note PackagePath: 43f7. instance.  For example:

     >>> util = [p for p in files('wheel') if 'util.py' in str(p)][0]
     >>> util
     PackagePath('wheel/util.py')
     >>> util.size
     859
     >>> util.dist
     <importlib.metadata._hooks.PathDistribution object at 0x101e0cef0>
     >>> util.hash
     <FileHash mode: sha256 value: bYkw5oMccfazVCoYQwKkkemoVyMAFoR34mmKBx8R1NI>

ファイルを取得したら、その内容を読むこともできます:

     >>> print(util.read_text())
     import base64
     import sys
     ...
     def as_bytes(s):
         if isinstance(s, text_type):
             return s.encode('utf-8')
         return s

You can also use the ‘locate()’ method to get the absolute path to the
file:

     >>> util.locate()
     PosixPath('/home/gustav/example/lib/site-packages/wheel/util.py')

In the case where the metadata file listing files (‘RECORD’ or
‘SOURCES.txt’) is missing, ‘files()’ will return *note None: 641.  The
caller may wish to wrap calls to ‘files()’ in always_iterable(2) or
otherwise guard against this condition if the target distribution is not
known to have the metadata present.

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/glossary/#term-Distribution-Package

   (2) 
https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.always_iterable


File: python.info,  Node: 配布物の要件,  Next: Mapping import to distribution packages,  Prev: 配布物ファイル,  Up: 機能 API

5.31.8.7 配布物の要件
.....................

 -- の関数: importlib.metadata.requires (distribution_name)

     Return the declared dependency specifiers for the named
     distribution package.

     Raises *note PackageNotFoundError: 43eb. if the named distribution
     package is not installed in the current Python environment.

To get the full set of requirements for a Distribution Package(1), use
the ‘requires()’ function:

     >>> requires('wheel')
     ["pytest (>=3.0.0) ; extra == 'test'", "pytest-cov ; extra == 'test'"]

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/glossary/#term-Distribution-Package


File: python.info,  Node: Mapping import to distribution packages,  Prev: 配布物の要件,  Up: 機能 API

5.31.8.8 Mapping import to distribution packages
................................................

 -- の関数: importlib.metadata.packages_distributions ()

     Return a mapping from the top level module and import package names
     found via *note sys.meta_path: cf9. to the names of the
     distribution packages (if any) that provide the corresponding
     files.

     To allow for namespace packages (which may have members provided by
     multiple distribution packages), each top level import name maps to
     a list of distribution names rather than mapping directly to a
     single name.

インポート可能なトップレベルのPythonモジュールまたは パッケージ(1) を提
供する 配布パッケージ(2) 名(名前空間パッケージの場合はその名前)を解決す
る便利なメソッドです:

     >>> packages_distributions()
     {'importlib_metadata': ['importlib-metadata'], 'yaml': ['PyYAML'], 'jaraco': ['jaraco.classes', 'jaraco.functools'], ...}

Some editable installs, do not supply top-level names(3), and thus this
function is not reliable with such installs.

Added in version 3.10.

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/ja/latest/glossary/#term-Import-Package

   (2) 
https://packaging.python.org/en/latest/glossary/#term-Distribution-Package

   (3) https://github.com/pypa/packaging-problems/issues/609


File: python.info,  Node: Distributions,  Next: Distribution Discovery,  Prev: 機能 API,  Up: importlib metadata -- パッケージメタデータへのアクセス

5.31.8.9 Distributions
......................

 -- の関数: importlib.metadata.distribution (distribution_name)

     Return a *note Distribution: 43ff. instance describing the named
     distribution package.

     Raises *note PackageNotFoundError: 43eb. if the named distribution
     package is not installed in the current Python environment.

 -- クラス: importlib.metadata.Distribution

     Details of an installed distribution package.

     Note: different ‘Distribution’ instances do not currently compare
     equal, even if they relate to the same installed distribution and
     accordingly have the same attributes.

While the module level API described above is the most common and
convenient usage, you can get all of that information from the
‘Distribution’ class.  ‘Distribution’ is an abstract object that
represents the metadata for a Python Distribution Package(1).  You can
get the concreate ‘Distribution’ subclass instance for an installed
distribution package by calling the *note distribution(): 43fe.
function:

     >>> from importlib.metadata import distribution
     >>> dist = distribution('wheel')
     >>> type(dist)
     <class 'importlib.metadata.PathDistribution'>

Thus, an alternative way to get the version number is through the
‘Distribution’ instance:

     >>> dist.version
     '0.32.3'

There are all kinds of additional metadata available on ‘Distribution’
instances:

     >>> dist.metadata['Requires-Python']
     '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*'
     >>> dist.metadata['License']
     'MIT'

For editable packages, an ‘origin’ property may present PEP 610(2)
metadata:

     >>> dist.origin.url
     'file:///path/to/wheel-0.32.3.editable-py3-none-any.whl'

The full set of available metadata is not described here.  See the PyPA
Core metadata specification(3) for additional details.

Added in version 3.13: The ‘.origin’ property was added.

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/glossary/#term-Distribution-Package

   (2) https://peps.python.org/pep-0610/

   (3) 
https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata


File: python.info,  Node: Distribution Discovery,  Next: 検索アルゴリズムの拡張,  Prev: Distributions,  Up: importlib metadata -- パッケージメタデータへのアクセス

5.31.8.10 Distribution Discovery
................................

デフォルトでは、このパッケージは組み込みで、ファイルシステムおよび zip フ
ァイル 配布パッケージ(1) のメタデータを発見するためのサポートを提供しま
す。このメタデータ検索のデフォルトは ‘sys.path’ ですが、その値をどのよう
に解釈するかは、他のインポート機構が行う方法とは若干異なります。具体的に
は:

   - ‘importlib.metadata’ は ‘sys.path’ の *note bytes: 1a4. オブジェク
     トを受け入れません。

   - ‘importlib.metadata’ は、インポート時には無視されますが、
     ‘sys.path’ 上の *note pathlib.Path: 20a. オブジェクトを優先的に使用
     します。

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/ja/latest/glossary/#term-Distribution-Package


File: python.info,  Node: 検索アルゴリズムの拡張,  Prev: Distribution Discovery,  Up: importlib metadata -- パッケージメタデータへのアクセス

5.31.8.11 検索アルゴリズムの拡張
................................

Because Distribution Package(1) metadata is not available through *note
sys.path: 38e. searches, or package loaders directly, the metadata for a
distribution is found through import system *note finders: 1f52.  To
find a distribution package's metadata, ‘importlib.metadata’ queries the
list of *note meta path finders: 1045. on *note sys.meta_path: cf9.

By default ‘importlib.metadata’ installs a finder for distribution
packages found on the file system.  This finder doesn't actually find
any 'distributions', but it can find their metadata.

抽象クラス *note importlib.abc.MetaPathFinder: 83a. はPythonの importシ
ステムによってファインダーに期待されるインターフェイスを定義しています。
‘importlib.metadata’ はこのプロトコルを拡張し、 *note sys.meta_path:
cf9. からファインダーにオプションの ‘find_distributions’ を呼び出すこと
ができるようにし、この拡張インターフェースを ‘DistributionFinder’ 抽象基
底クラスとして提示し、この抽象メソッドを定義しています:

     @abc.abstractmethod
     def find_distributions(context=DistributionFinder.Context()):
         """Return an iterable of all Distribution instances capable of
         loading the metadata for packages for the indicated ``context``.
         """

‘DistributionFinder.Context’ オブジェクトは、検索するパスと一致する名前
を示す ‘.path’ と ‘.name’ のプロパティを提供し、その他の関連するコンテキ
ストを提供することもできます。

つまり、ファイルシステム以外の場所にある配布パッケージのメタデータを見つ
けるには、 ‘Distribution’ をサブクラス化して抽象メソッドを実装します。そ
して、カスタムファインダーから ‘find_distributions()’ メソッドで、派生し
た ‘Distribution’ のインスタンスを返します。

* Menu:

* 使用例: 使用例<48>.

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/glossary/#term-Distribution-Package


File: python.info,  Node: 使用例<48>,  Up: 検索アルゴリズムの拡張

5.31.8.12 使用例
................

Consider for example a custom finder that loads Python modules from a
database:

     class DatabaseImporter(importlib.abc.MetaPathFinder):
         def __init__(self, db):
             self.db = db

         def find_spec(self, fullname, target=None) -> ModuleSpec:
             return self.db.spec_from_name(fullname)

     sys.meta_path.append(DatabaseImporter(connect_db(...)))

That importer now presumably provides importable modules from a
database, but it provides no metadata or entry points.  For this custom
importer to provide metadata, it would also need to implement
‘DistributionFinder’:

     from importlib.metadata import DistributionFinder

     class DatabaseImporter(DistributionFinder):
         ...

         def find_distributions(self, context=DistributionFinder.Context()):
             query = dict(name=context.name) if context.name else {}
             for dist_record in self.db.query_distributions(query):
                 yield DatabaseDistribution(dist_record)

In this way, ‘query_distributions’ would return records for each
distribution served by the database matching the query.  For example, if
‘requests-1.0’ is in the database, ‘find_distributions’ would yield a
‘DatabaseDistribution’ for ‘Context(name='requests')’ or
‘Context(name=None)’.

For the sake of simplicity, this example ignores ‘context.path’.  The
‘path’ attribute defaults to ‘sys.path’ and is the set of import paths
to be considered in the search.  A ‘DatabaseImporter’ could potentially
function without any concern for a search path.  Assuming the importer
does no partitioning, the "path" would be irrelevant.  In order to
illustrate the purpose of ‘path’, the example would need to illustrate a
more complex ‘DatabaseImporter’ whose behavior varied depending on
‘sys.path’/‘PYTHONPATH’.  In that case, the ‘find_distributions’ should
honor the ‘context.path’ and only yield ‘Distribution’s pertinent to
that path.

‘DatabaseDistribution’, then, would look something like:

     class DatabaseDistribution(importlib.metadata.Distribution):
         def __init__(self, record):
             self.record = record

         def read_text(self, filename):
             """
             Read a file like "METADATA" for the current distribution.
             """
             if filename == "METADATA":
                 return f"""Name: {self.record.name}
     Version: {self.record.version}
     """
             if filename == "entry_points.txt":
                 return "\n".join(
                   f"""[{ep.group}]\n{ep.name}={ep.value}"""
                   for ep in self.record.entry_points)

         def locate_file(self, path):
             raise RuntimeError("This distribution has no file system")

This basic implementation should provide metadata and entry points for
packages served by the ‘DatabaseImporter’, assuming that the ‘record’
supplies suitable ‘.name’, ‘.version’, and ‘.entry_points’ attributes.

The ‘DatabaseDistribution’ may also provide other metadata files, like
‘RECORD’ (required for ‘Distribution.files’) or override the
implementation of ‘Distribution.files’.  See the source for more
inspiration.


File: python.info,  Node: sys path モジュール検索パスの初期化,  Prev: importlib metadata -- パッケージメタデータへのアクセス,  Up: モジュールのインポート

5.31.9 ‘sys.path’ モジュール検索パスの初期化
--------------------------------------------

モジュール検索パスは Python の開始時に初期化されます。このモジュール検索
パスは、 *note sys.path: 38e. でアクセス可能です。

The first entry in the module search path is the directory that contains
the input script, if there is one.  Otherwise, the first entry is the
current directory, which is the case when executing the interactive
shell, a *note -c: 5aa. command, or *note -m: 5ab. module.

The *note PYTHONPATH: fe8. environment variable is often used to add
directories to the search path.  If this environment variable is found
then the contents are added to the module search path.

     注釈: *note PYTHONPATH: fe8. will affect all installed Python
     versions/environments.  Be wary of setting this in your shell
     profile or global environment variables.  The *note site: b5.
     module offers more nuanced techniques as mentioned below.

The next items added are the directories containing standard Python
modules as well as any *note extension module: 4405.s that these modules
depend on.  Extension modules are ‘.pyd’ files on Windows and ‘.so’
files on other platforms.  The directory with the platform-independent
Python modules is called ‘prefix’.  The directory with the extension
modules is called ‘exec_prefix’.

The *note PYTHONHOME: 396. environment variable may be used to set the
‘prefix’ and ‘exec_prefix’ locations.  Otherwise these directories are
found by using the Python executable as a starting point and then
looking for various 'landmark' files and directories.  Note that any
symbolic links are followed so the real Python executable location is
used as the search starting point.  The Python executable location is
called ‘home’.

Once ‘home’ is determined, the ‘prefix’ directory is found by first
looking for ‘python`majorversion'`minorversion'.zip’ (‘python311.zip’).
On Windows the zip archive is searched for in ‘home’ and on Unix the
archive is expected to be in ‘lib’.  Note that the expected zip archive
location is added to the module search path even if the archive does not
exist.  If no archive was found, Python on Windows will continue the
search for ‘prefix’ by looking for ‘Lib\os.py’.  Python on Unix will
look for ‘lib/python`majorversion'.`minorversion'/os.py’
(‘lib/python3.11/os.py’).  On Windows ‘prefix’ and ‘exec_prefix’ are the
same, however on other platforms
‘lib/python`majorversion'.`minorversion'/lib-dynload’
(‘lib/python3.11/lib-dynload’) is searched for and used as an anchor for
‘exec_prefix’.  On some platforms ‘lib’ may be ‘lib64’ or another value,
see *note sys.platlibdir: 906. and *note PYTHONPLATLIBDIR: 18aa.

Once found, ‘prefix’ and ‘exec_prefix’ are available at *note
sys.prefix: 390. and *note sys.exec_prefix: 38c. respectively.

Finally, the *note site: b5. module is processed and ‘site-packages’
directories are added to the module search path.  A common way to
customize the search path is to create *note sitecustomize: b6. or *note
usercustomize: f7. modules as described in the *note site: b5. module
documentation.

     注釈: Certain command line options may further affect path
     calculations.  See *note -E: 92b, *note -I: 92c, *note -s: 1353.
     and *note -S: 1179. for further details.

* Menu:

* 仮想環境::
* _pth files::
* 埋め込みの Python::


File: python.info,  Node: 仮想環境,  Next: _pth files,  Up: sys path モジュール検索パスの初期化

5.31.9.1 仮想環境
.................

If Python is run in a virtual environment (as described at *note
仮想環境とパッケージ: 1c69.) then ‘prefix’ and ‘exec_prefix’ are
specific to the virtual environment.

If a ‘pyvenv.cfg’ file is found alongside the main executable, or in the
directory one level above the executable, the following variations
apply:

   * If ‘home’ is an absolute path and *note PYTHONHOME: 396. is not
     set, this path is used instead of the path to the main executable
     when deducing ‘prefix’ and ‘exec_prefix’.


File: python.info,  Node: _pth files,  Next: 埋め込みの Python,  Prev: 仮想環境,  Up: sys path モジュール検索パスの初期化

5.31.9.2 _pth files
...................

To completely override *note sys.path: 38e. create a ‘._pth’ file with
the same name as the shared library or executable (‘python._pth’ or
‘python311._pth’).  The shared library path is always known on Windows,
however it may not be available on other platforms.  In the ‘._pth’ file
specify one line for each path to add to *note sys.path: 38e.  The file
based on the shared library name overrides the one based on the
executable, which allows paths to be restricted for any program loading
the runtime if desired.

ファイルが存在したときは、全てのレジストリと環境変数は無視され、隔離モー
ドになり、そのファイルに ‘import site’ と指定していない限りは *note
site: b5. がインポートできなくなります。 空行と ‘#’ で始まる行は無視され
ます。 それぞれのパスはファイルの場所を指す絶対パスあるいは相対パスです
。 ‘site’ 以外のインポート文は許可されておらず、任意のコードも書けません
。

‘import site’ を指定したときは、(アンダースコアが前に付かない) ‘.pth’ フ
ァイルは *note site: b5. モジュールにより通常通り処理されることに注意し
てください。


File: python.info,  Node: 埋め込みの Python,  Prev: _pth files,  Up: sys path モジュール検索パスの初期化

5.31.9.3 埋め込みの Python
..........................

Python が他のアプリケーションに埋め込まれている場合は、 *note
Py_InitializeFromConfig(): 39f. と *note PyConfig: 380. 構造体が Python
の初期化に使用可能です。パス固有の詳細は、 *note Python Path
Configuration: 87b. で説明されています。

参考
....

   * Windows の詳細についてのメモは、 *note モジュールの検索: bef. を参
     照。

   * Unix の詳細は、 *note Unix プラットフォームで Python を使う: 1cc2.
     を参照。


File: python.info,  Node: Python言語サービス,  Next: MS Windows 固有のサービス,  Prev: モジュールのインポート,  Up: Python 標準ライブラリ

5.32 Python言語サービス
=======================

PythonにはPython言語を使って作業するときに役に立つモジュールがたくさん提
供されています。これらのモジュールはトークンの切り出し、パース、構文解析
、バイトコードのディスアセンブリおよびその他のさまざまな機能をサポートし
ています。

これらのモジュールには、次のものが含まれています:

* Menu:

* ast: ast --- 抽象構文木. 抽象構文木
* symtable: symtable --- コンパイラーの記号表へのアクセス. コンパイラーの記号表へのアクセス
* token: token --- Python 解析木で使われる定数. Python 解析木で使われる定数
* keyword: keyword --- Python キーワードのテスト. Python キーワードのテスト
* tokenize: tokenize --- Python ソース用のトークナイザー. Python ソース用のトークナイザー
* tabnanny: tabnanny --- あいまいなインデントの検出. あいまいなインデントの検出
* pyclbr: pyclbr --- Python モジュールブラウザーサポート. Python モジュールブラウザーサポート
* py_compile: py_compile --- Python ソースファイルをコンパイルする. Python ソースファイルをコンパイルする
* compileall: compileall --- Python ライブラリをバイトコンパイルする. Python ライブラリをバイトコンパイルする
* dis: dis --- Python バイトコードの逆アセンブラー. Python バイトコードの逆アセンブラー
* pickletools: pickletools --- pickle 開発者用のツール群. pickle 開発者用のツール群


File: python.info,  Node: ast --- 抽象構文木,  Next: symtable --- コンパイラーの記号表へのアクセス,  Up: Python言語サービス

5.32.1 ‘ast’ -- 抽象構文木
--------------------------

'ソースコード:' Lib/ast.py(1)

__________________________________________________________________

*note ast: 7. モジュールは、Python アプリケーションで Python の抽象構文
木を処理しやすくするものです。抽象構文そのものは、Python のリリースごと
に変化する可能性があります。このモジュールを使用すると、現在の文法をプロ
グラム上で知る助けになるでしょう。

抽象構文木を作成するには、 *note ast.PyCF_ONLY_AST: 440e. を組み込み関数
*note compile(): 177. のフラグとして渡すか、あるいはこのモジュールで提供
されているヘルパー関数 *note parse(): 18d. を使います。その結果は、
*note ast.AST: 18b. を継承したクラスのオブジェクトのツリーとなります。抽
象構文木は組み込み関数 *note compile(): 177. を使って Python コード・オ
ブジェクトにコンパイルすることができます。

* Menu:

* 抽象文法 (Abstract Grammar): 抽象文法 Abstract Grammar.
* Node クラス::
* ast ヘルパー::
* コンパイラフラグ::
* コマンドラインからの使用: コマンドラインからの使用<4>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/ast.py


File: python.info,  Node: 抽象文法 Abstract Grammar,  Next: Node クラス,  Up: ast --- 抽象構文木

5.32.1.1 抽象文法 (Abstract Grammar)
....................................

抽象文法は、現在次のように定義されています:

     -- ASDL's 4 builtin types are:
     -- identifier, int, string, constant

     module Python
     {
         mod = Module(stmt* body, type_ignore* type_ignores)
             | Interactive(stmt* body)
             | Expression(expr body)
             | FunctionType(expr* argtypes, expr returns)

         stmt = FunctionDef(identifier name, arguments args,
                            stmt* body, expr* decorator_list, expr? returns,
                            string? type_comment, type_param* type_params)
               | AsyncFunctionDef(identifier name, arguments args,
                                  stmt* body, expr* decorator_list, expr? returns,
                                  string? type_comment, type_param* type_params)

               | ClassDef(identifier name,
                  expr* bases,
                  keyword* keywords,
                  stmt* body,
                  expr* decorator_list,
                  type_param* type_params)
               | Return(expr? value)

               | Delete(expr* targets)
               | Assign(expr* targets, expr value, string? type_comment)
               | TypeAlias(expr name, type_param* type_params, expr value)
               | AugAssign(expr target, operator op, expr value)
               -- 'simple' indicates that we annotate simple name without parens
               | AnnAssign(expr target, expr annotation, expr? value, int simple)

               -- use 'orelse' because else is a keyword in target languages
               | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)
               | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)
               | While(expr test, stmt* body, stmt* orelse)
               | If(expr test, stmt* body, stmt* orelse)
               | With(withitem* items, stmt* body, string? type_comment)
               | AsyncWith(withitem* items, stmt* body, string? type_comment)

               | Match(expr subject, match_case* cases)

               | Raise(expr? exc, expr? cause)
               | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)
               | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)
               | Assert(expr test, expr? msg)

               | Import(alias* names)
               | ImportFrom(identifier? module, alias* names, int? level)

               | Global(identifier* names)
               | Nonlocal(identifier* names)
               | Expr(expr value)
               | Pass | Break | Continue

               -- col_offset is the byte offset in the utf8 string the parser uses
               attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

               -- BoolOp() can use left & right?
         expr = BoolOp(boolop op, expr* values)
              | NamedExpr(expr target, expr value)
              | BinOp(expr left, operator op, expr right)
              | UnaryOp(unaryop op, expr operand)
              | Lambda(arguments args, expr body)
              | IfExp(expr test, expr body, expr orelse)
              | Dict(expr* keys, expr* values)
              | Set(expr* elts)
              | ListComp(expr elt, comprehension* generators)
              | SetComp(expr elt, comprehension* generators)
              | DictComp(expr key, expr value, comprehension* generators)
              | GeneratorExp(expr elt, comprehension* generators)
              -- the grammar constrains where yield expressions can occur
              | Await(expr value)
              | Yield(expr? value)
              | YieldFrom(expr value)
              -- need sequences for compare to distinguish between
              -- x < 4 < 3 and (x < 4) < 3
              | Compare(expr left, cmpop* ops, expr* comparators)
              | Call(expr func, expr* args, keyword* keywords)
              | FormattedValue(expr value, int conversion, expr? format_spec)
              | JoinedStr(expr* values)
              | Constant(constant value, string? kind)

              -- the following expression can appear in assignment context
              | Attribute(expr value, identifier attr, expr_context ctx)
              | Subscript(expr value, expr slice, expr_context ctx)
              | Starred(expr value, expr_context ctx)
              | Name(identifier id, expr_context ctx)
              | List(expr* elts, expr_context ctx)
              | Tuple(expr* elts, expr_context ctx)

              -- can appear only in Subscript
              | Slice(expr? lower, expr? upper, expr? step)

               -- col_offset is the byte offset in the utf8 string the parser uses
               attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

         expr_context = Load | Store | Del

         boolop = And | Or

         operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift
                      | RShift | BitOr | BitXor | BitAnd | FloorDiv

         unaryop = Invert | Not | UAdd | USub

         cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn

         comprehension = (expr target, expr iter, expr* ifs, int is_async)

         excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)
                         attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

         arguments = (arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs,
                      expr* kw_defaults, arg? kwarg, expr* defaults)

         arg = (identifier arg, expr? annotation, string? type_comment)
                attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

         -- keyword arguments supplied to call (NULL identifier for **kwargs)
         keyword = (identifier? arg, expr value)
                    attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

         -- import name with optional 'as' alias.
         alias = (identifier name, identifier? asname)
                  attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset)

         withitem = (expr context_expr, expr? optional_vars)

         match_case = (pattern pattern, expr? guard, stmt* body)

         pattern = MatchValue(expr value)
                 | MatchSingleton(constant value)
                 | MatchSequence(pattern* patterns)
                 | MatchMapping(expr* keys, pattern* patterns, identifier? rest)
                 | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)

                 | MatchStar(identifier? name)
                 -- The optional "rest" MatchMapping parameter handles capturing extra mapping keys

                 | MatchAs(pattern? pattern, identifier? name)
                 | MatchOr(pattern* patterns)

                  attributes (int lineno, int col_offset, int end_lineno, int end_col_offset)

         type_ignore = TypeIgnore(int lineno, string tag)

         type_param = TypeVar(identifier name, expr? bound, expr? default_value)
                    | ParamSpec(identifier name, expr? default_value)
                    | TypeVarTuple(identifier name, expr? default_value)
                    attributes (int lineno, int col_offset, int end_lineno, int end_col_offset)
     }


File: python.info,  Node: Node クラス,  Next: ast ヘルパー,  Prev: 抽象文法 Abstract Grammar,  Up: ast --- 抽象構文木

5.32.1.2 Node クラス
....................

 -- クラス: ast.AST

     このクラスは全ての AST ノード・クラスの基底です。実際のノード・クラ
     スは *note 先に: 440f. 示した ‘Parser/Python.asdl’ ファイルから派生
     したものです。これらのクラスは ‘_ast’ C モジュールで定義され、
     *note ast: 7. にもエクスポートし直されています。

     抽象文法の左辺のシンボル一つずつにそれぞれ一つのクラスがあります (た
     とえば ‘ast.stmt’ や ‘ast.expr’)。それに加えて、右辺のコンストラク
     タ一つずつにそれぞれ一つのクラスがあり、これらのクラスは左辺のツリ
     ーのクラスを継承しています。たとえば、 *note ast.BinOp: 1938. は
     ‘ast.expr’ から継承しています。代替を伴った生成規則 (production
     rules with alternatives) (別名 "sums") の場合、左辺は抽象クラスとな
     り、特定のコンストラクタ・ノードのインスタンスのみが作成されます。

      -- の属性: _fields

          各具象クラスは属性 ‘_fields’ を持っており、すべての子ノードの
          名前をそこに保持しています。

          具象クラスのインスタンスは、各子ノードに対してそれぞれひとつの
          属性を持っています。この属性は、文法で定義された型となります。
          たとえば *note ast.BinOp: 1938. のインスタンスは ‘left’ という
          属性を持っており、その型は ‘ast.expr’ です。

          これらの属性が、文法上 (クエスチョンマークを用いて) オプション
          であるとマークされている場合は、その値が ‘None’ となることもあ
          ります。属性が0個以上の複数の値をとりうる場合 (アスタリスクで
          マークされている場合) は、値は Python のリストで表されます。全
          ての属性は AST を *note compile(): 177. でコンパイルする際には
          存在しなければならず、そして妥当な値でなければなりません。

      -- の属性: _field_types

          The ‘_field_types’ attribute on each concrete class is a
          dictionary mapping field names (as also listed in *note
          _fields: 150a.) to their types.

               >>> ast.TypeVar._field_types
               {'name': <class 'str'>, 'bound': ast.expr | None, 'default_value': ast.expr | None}

          Added in version 3.13.

      -- の属性: lineno
      -- の属性: col_offset
      -- の属性: end_lineno
      -- の属性: end_col_offset

          ‘ast.expr’ や ‘ast.stmt’ のサブクラスのインスタンスは *note
          lineno: 4412, *note col_offset: 4413, *note end_lineno: 4414,
          および *note end_col_offset: 4415. 属性を持ちます。 *note
          lineno: 4412. と *note end_lineno: 4414. はソーステキストの範
          囲を最初と最後の行番号で表し (1 から数え始めるので、最初の行の
          行番号は 1 となります)、 *note col_offset: 4413. と *note
          end_col_offset: 4415. はノードが生成した最初と最後のトークンの
          UTF-8 バイトオフセットです。 UTF-8 オフセットはパーサが内部で
          使用するので記録されます。

          コンパイラは終了位置を必要としないことに注意してください。この
          ため終了位置は省略可能です。終了位置を示すオフセットは最後のシ
          ンボルの '後の位置' になります。例えば一行で書かれた式のソース
          コードのセグメントは ‘source_line[node.col_offset :
          node.end_col_offset]’ により取得できます。

     クラス ‘ast.T’ のコンストラクタは引数を次のように解析します:

        * 位置引数があるとすれば、 ‘T._fields’ にあるのと同じだけの個数
          が無ければなりません。これらの引数はそこにある名前を持った属性
          として割り当てられます。

        * キーワード引数があるとすれば、それらはその名前の属性にその値を
          割り当てられます。

     たとえば、 *note ast.UnaryOp: 4416. ノードを生成して属性を埋めるに
     は、次のようにすることができます

          node = ast.UnaryOp(ast.USub(), ast.Constant(5, lineno=0, col_offset=0),
                             lineno=0, col_offset=0)

     If a field that is optional in the grammar is omitted from the
     constructor, it defaults to ‘None’.  If a list field is omitted, it
     defaults to the empty list.  If a field of type ‘ast.expr_context’
     is omitted, it defaults to *note Load(): 189.  If any other field
     is omitted, a *note DeprecationWarning: 18a. is raised and the AST
     node will not have this field.  In Python 3.15, this condition will
     raise an error.

バージョン 3.8 で変更: *note ast.Constant: 299. が全ての定数に使われるよ
うになりました。

バージョン 3.9 で変更: 単純なインデックスはその値で表現され、幅を持つス
ライスはタプルで表現されます。

バージョン 3.8 で非推奨: Old classes ‘ast.Num’, ‘ast.Str’, ‘ast.Bytes’,
‘ast.NameConstant’ and ‘ast.Ellipsis’ 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.

バージョン 3.9 で非推奨: Old classes ‘ast.Index’ and ‘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.

Deprecated since version 3.13, will be removed in version 3.15: Previous
versions of Python allowed the creation of AST nodes that were missing
required fields.  Similarly, AST node constructors allowed arbitrary
keyword arguments that were set as attributes of the AST node, even if
they did not match any of the fields of the AST node.  This behavior is
deprecated and will be removed in Python 3.15.

     注釈: ここに示されている特定のノードクラスについての記述は、素晴ら
     しい Green Tree Snakes(1) プロジェクトとそのすべての貢献者の成果物
     をもとにしています。

* Menu:

* Root nodes::
* リテラル: リテラル<3>.
* 変数::
* 式 (expression): 式 expression<2>.
* 文 (Statements): 文 Statements.
* 制御フロー::
* Pattern matching::
* Type parameters::
* 関数およびクラス定義::
* async と await::

   ---------- Footnotes ----------

   (1) https://greentreesnakes.readthedocs.io/en/latest/


File: python.info,  Node: Root nodes,  Next: リテラル<3>,  Up: Node クラス

5.32.1.3 Root nodes
...................

 -- クラス: ast.Module (body, type_ignores)

     A Python module, as with *note file input: 20a0.  Node type
     generated by *note ast.parse(): 18d. in the default ‘"exec"’
     'mode'.

     ‘body’ is a *note list: 5dc. of the module's *note 文 (Statements):
     441a.

     ‘type_ignores’ is a *note list: 5dc. of the module's type ignore
     comments; see *note ast.parse(): 18d. for more details.

          >>> print(ast.dump(ast.parse('x = 1'), indent=4))
          Module(
              body=[
                  Assign(
                      targets=[
                          Name(id='x', ctx=Store())],
                      value=Constant(value=1))])

 -- クラス: ast.Expression (body)

     A single Python *note expression input: 20a6.  Node type generated
     by *note ast.parse(): 18d. when 'mode' is ‘"eval"’.

     ‘body’ is a single node, one of the *note expression types: 441c.

          >>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
          Expression(
              body=Constant(value=123))

 -- クラス: ast.Interactive (body)

     A single *note interactive input: 20a3, like in *note 対話モード:
     155.  Node type generated by *note ast.parse(): 18d. when 'mode' is
     ‘"single"’.

     ‘body’ is a *note list: 5dc. of *note statement nodes: 441a.

          >>> print(ast.dump(ast.parse('x = 1; y = 2', mode='single'), indent=4))
          Interactive(
              body=[
                  Assign(
                      targets=[
                          Name(id='x', ctx=Store())],
                      value=Constant(value=1)),
                  Assign(
                      targets=[
                          Name(id='y', ctx=Store())],
                      value=Constant(value=2))])

 -- クラス: ast.FunctionType (argtypes, returns)

     A representation of an old-style type comments for functions, as
     Python versions prior to 3.5 didn't support PEP 484(1) annotations.
     Node type generated by *note ast.parse(): 18d. when 'mode' is
     ‘"func_type"’.

     Such type comments would look like this:

          def sum_two_number(a, b):
              # type: (int, int) -> int
              return a + b

     ‘argtypes’ is a *note list: 5dc. of *note expression nodes: 441c.

     ‘returns’ is a single *note expression node: 441c.

          >>> print(ast.dump(ast.parse('(int, str) -> List[int]', mode='func_type'), indent=4))
          FunctionType(
              argtypes=[
                  Name(id='int', ctx=Load()),
                  Name(id='str', ctx=Load())],
              returns=Subscript(
                  value=Name(id='List', ctx=Load()),
                  slice=Name(id='int', ctx=Load()),
                  ctx=Load()))

     Added in version 3.8.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/


File: python.info,  Node: リテラル<3>,  Next: 変数,  Prev: Root nodes,  Up: Node クラス

5.32.1.4 リテラル
.................

 -- クラス: ast.Constant (value)

     定数です。 ‘Constant’ リテラルの ‘value’ 属性は定数値を表す Python
     オブジェクトを保持します。定数として表現される値は数値、文字列、ま
     たは ‘None’ のような単純な型のほかに、全ての要素が定数であるイミュ
     ータブルなコンテナ型 (tuples および frozensets) も設定可能です。

          >>> print(ast.dump(ast.parse('123', mode='eval'), indent=4))
          Expression(
              body=Constant(value=123))

 -- クラス: ast.FormattedValue (value, conversion, format_spec)

     このノードは f-string における単一の書式指定置換フィールドを表現し
     ます。文字列が単一の置換フィールドしか持たず、他に何も含まない場合
     は、ノードは単独で存在できます。そうでない場合は *note JoinedStr:
     1650. の一部としてあらわれます。

        * ‘value’ は式ツリーのノードのいずれか (リテラル、変数、関数呼び
          出しなど) です。

        * ‘conversion’ は整数です:

             * -1: 書式指定なし

             * 115: ‘!s’ 文字列書式指定

             * 114: ‘!r’ repr 書式指定

             * 97: ‘!a’ ascii 書式指定

        * ‘format_spec’ は値の書式指定を表現する *note JoinedStr: 1650.
          ノード、もしくは書式指定がない場合は ‘None’ です。
          ‘conversion’ と ‘format_spec’ を同時に設定することができます。

 -- クラス: ast.JoinedStr (values)

     *note FormattedValue: 4420. ノードと *note Constant: 299. ノードの
     集まりからなる f-string です。

          >>> print(ast.dump(ast.parse('f"sin({a}) is {sin(a):.3}"', mode='eval'), indent=4))
          Expression(
              body=JoinedStr(
                  values=[
                      Constant(value='sin('),
                      FormattedValue(
                          value=Name(id='a', ctx=Load()),
                          conversion=-1),
                      Constant(value=') is '),
                      FormattedValue(
                          value=Call(
                              func=Name(id='sin', ctx=Load()),
                              args=[
                                  Name(id='a', ctx=Load())]),
                          conversion=-1,
                          format_spec=JoinedStr(
                              values=[
                                  Constant(value='.3')]))]))

 -- クラス: ast.List (elts, ctx)
 -- クラス: ast.Tuple (elts, ctx)

     リストまたはタプルをあらわします。 ‘elts’ は内包する要素を表現する
     ノードのリストを保持します。 ‘ctx’ はコンテナが代入のターゲットであ
     る場合 (たとえば ‘(x,y)=something’ のような場合) は *note Store:
     4423. であり、そうでない場合は *note Load: 189. です。

          >>> print(ast.dump(ast.parse('[1, 2, 3]', mode='eval'), indent=4))
          Expression(
              body=List(
                  elts=[
                      Constant(value=1),
                      Constant(value=2),
                      Constant(value=3)],
                  ctx=Load()))
          >>> print(ast.dump(ast.parse('(1, 2, 3)', mode='eval'), indent=4))
          Expression(
              body=Tuple(
                  elts=[
                      Constant(value=1),
                      Constant(value=2),
                      Constant(value=3)],
                  ctx=Load()))

 -- クラス: ast.Set (elts)

     集合 (set) をあらわします。 ‘elts’ は集合の各要素を表現するノードの
     リストを保持します。

          >>> print(ast.dump(ast.parse('{1, 2, 3}', mode='eval'), indent=4))
          Expression(
              body=Set(
                  elts=[
                      Constant(value=1),
                      Constant(value=2),
                      Constant(value=3)]))

 -- クラス: ast.Dict (keys, values)

     辞書をあらわします。 ‘keys’ と ‘values’ はそれぞれキーと値のノード
     のリスト を順序が一致した形で (それぞれ ‘dictionary.keys()’ と
     ‘dictionary.values()’ を呼び出したときに返される順序で) 保持します
     。

     辞書リテラルを使って辞書を展開した場合、展開された式ツリーにおいて
     辞書は ‘values’ リストに入り、 ‘keys’ の対応する位置には ‘None’ が
     入ります。

          >>> print(ast.dump(ast.parse('{"a":1, **d}', mode='eval'), indent=4))
          Expression(
              body=Dict(
                  keys=[
                      Constant(value='a'),
                      None],
                  values=[
                      Constant(value=1),
                      Name(id='d', ctx=Load())]))


File: python.info,  Node: 変数,  Next: 式 expression<2>,  Prev: リテラル<3>,  Up: Node クラス

5.32.1.5 変数
.............

 -- クラス: ast.Name (id, ctx)

     変数名をあらわします。 ‘id’ は変数名を文字列で保持し、 ‘ctx’ は以下
     に示す型のいずれかです。

 -- クラス: ast.Load
 -- クラス: ast.Store
 -- クラス: ast.Del

     変数の参照は変数の値をロードするか、新しい値を割り当てるか、または
     値を削除するために使うことができます。変数の参照はこれら3つの場合を
     区別するためのコンテキストによって与えられます。

          >>> print(ast.dump(ast.parse('a'), indent=4))
          Module(
              body=[
                  Expr(
                      value=Name(id='a', ctx=Load()))])

          >>> print(ast.dump(ast.parse('a = 1'), indent=4))
          Module(
              body=[
                  Assign(
                      targets=[
                          Name(id='a', ctx=Store())],
                      value=Constant(value=1))])

          >>> print(ast.dump(ast.parse('del a'), indent=4))
          Module(
              body=[
                  Delete(
                      targets=[
                          Name(id='a', ctx=Del())])])

 -- クラス: ast.Starred (value, ctx)

     ‘*var’ 形式の変数の参照をあらわします。 ‘value’ は変数、典型的には
     *note Name: 18a9. ノード、を保持します。この型は ‘*args’ を伴う関数
     呼び出しノード *note Call: 4428. を構築する際に使用します。

          >>> print(ast.dump(ast.parse('a, *b = it'), indent=4))
          Module(
              body=[
                  Assign(
                      targets=[
                          Tuple(
                              elts=[
                                  Name(id='a', ctx=Store()),
                                  Starred(
                                      value=Name(id='b', ctx=Store()),
                                      ctx=Store())],
                              ctx=Store())],
                      value=Name(id='it', ctx=Load()))])


File: python.info,  Node: 式 expression<2>,  Next: 文 Statements,  Prev: 変数,  Up: Node クラス

5.32.1.6 式 (expression)
........................

 -- クラス: ast.Expr (value)

     関数呼び出しのような式がそれ自身で文となり、戻り値が使われないかま
     たは保存されないとき、その式はこのコンテナでラップされます。
     ‘value’ はこの節で説明する他のノード、 *note Constant: 299. ノード
     、 *note Name: 18a9. ノード、 *note Lambda: 442b. ノード *note
     Yield: 442c. ノードまたは *note YieldFrom: 442d. ノードのいずれかを
     保持します。

          >>> print(ast.dump(ast.parse('-a'), indent=4))
          Module(
              body=[
                  Expr(
                      value=UnaryOp(
                          op=USub(),
                          operand=Name(id='a', ctx=Load())))])

 -- クラス: ast.UnaryOp (op, operand)

     単項演算をあらわします。 ‘op’ は演算子で、 ‘operand’ は任意の式ツリ
     ーのノードです。

 -- クラス: ast.UAdd
 -- クラス: ast.USub
 -- クラス: ast.Not
 -- クラス: ast.Invert

     単項演算の演算子をあらわします。 *note Not: 4430. は論理否定キーワ
     ード ‘not’ であり、 *note Invert: 4431. はビット反転演算子 ‘~’ です
     。

          >>> print(ast.dump(ast.parse('not x', mode='eval'), indent=4))
          Expression(
              body=UnaryOp(
                  op=Not(),
                  operand=Name(id='x', ctx=Load())))

 -- クラス: ast.BinOp (left, op, right)

     (加算や減算のような) 二項演算をあらわします。 ‘op’ は演算子、
     ‘left’ と ‘right’ は任意の式ツリーのノードです。

          >>> print(ast.dump(ast.parse('x + y', mode='eval'), indent=4))
          Expression(
              body=BinOp(
                  left=Name(id='x', ctx=Load()),
                  op=Add(),
                  right=Name(id='y', ctx=Load())))

 -- クラス: ast.Add
 -- クラス: ast.Sub
 -- クラス: ast.Mult
 -- クラス: ast.Div
 -- クラス: ast.FloorDiv
 -- クラス: ast.Mod
 -- クラス: ast.Pow
 -- クラス: ast.LShift
 -- クラス: ast.RShift
 -- クラス: ast.BitOr
 -- クラス: ast.BitXor
 -- クラス: ast.BitAnd
 -- クラス: ast.MatMult

     二項演算の演算子をあらわします。

 -- クラス: ast.BoolOp (op, values)

     'or' や 'and' のような論理演算をあらわします。 ‘op’ は *note Or:
     4440. または *note And: 4441. です。 ‘values’ は必要な値のリストで
     す。 ‘a or b or c’ のように同じ演算子を使う連続した演算は、複数の値
     を持った単一のノードとして表現されます。

     ‘not’ は単項演算 *note UnaryOp: 4416. のため、ここには含まれません
     。

          >>> print(ast.dump(ast.parse('x or y', mode='eval'), indent=4))
          Expression(
              body=BoolOp(
                  op=Or(),
                  values=[
                      Name(id='x', ctx=Load()),
                      Name(id='y', ctx=Load())]))

 -- クラス: ast.And
 -- クラス: ast.Or

     論理演算の演算子をあらわします。

 -- クラス: ast.Compare (left, ops, comparators)

     2つ以上の値の比較をあらわします。 ‘left’ 比較の中の最初の値、‘ops’
     は演算子のリスト、 ‘comparators’ は2つ目以降の値のリストです。

          >>> print(ast.dump(ast.parse('1 <= a < 10', mode='eval'), indent=4))
          Expression(
              body=Compare(
                  left=Constant(value=1),
                  ops=[
                      LtE(),
                      Lt()],
                  comparators=[
                      Name(id='a', ctx=Load()),
                      Constant(value=10)]))

 -- クラス: ast.Eq
 -- クラス: ast.NotEq
 -- クラス: ast.Lt
 -- クラス: ast.LtE
 -- クラス: ast.Gt
 -- クラス: ast.GtE
 -- クラス: ast.Is
 -- クラス: ast.IsNot
 -- クラス: ast.In
 -- クラス: ast.NotIn

     比較演算の演算子をあらわします。

 -- クラス: ast.Call (func, args, keywords)

     関数呼び出しをあらわします。 ‘func’ は関数で、多くの場合 *note
     Name: 18a9. または *note Attribute: 444d. のオブジェクトです。 関数
     呼び出しの引数:

        * ‘args’ は位置引数のリストを保持します。

        * ‘keywords’ holds a list of *note keyword: 444e. objects
          representing arguments passed by keyword.

     The ‘args’ and ‘keywords’ arguments are optional and default to
     empty lists.

          >>> print(ast.dump(ast.parse('func(a, b=c, *d, **e)', mode='eval'), indent=4))
          Expression(
              body=Call(
                  func=Name(id='func', ctx=Load()),
                  args=[
                      Name(id='a', ctx=Load()),
                      Starred(
                          value=Name(id='d', ctx=Load()),
                          ctx=Load())],
                  keywords=[
                      keyword(
                          arg='b',
                          value=Name(id='c', ctx=Load())),
                      keyword(
                          value=Name(id='e', ctx=Load()))]))

 -- クラス: ast.keyword (arg, value)

     関数呼び出しまたはクラス定義のキーワード引数をあらわします。 ‘arg’
     はパラメータ名をあらわす文字列、 ‘value’ は引数に渡す値をあらわすノ
     ードです。

 -- クラス: ast.IfExp (test, body, orelse)

     ‘a if b else c’ のような式をあらわします。各フィールドは単一のノー
     ドを保持します。以下の例では、3つの式ノードはすべて *note Name:
     18a9. ノードです。

          >>> print(ast.dump(ast.parse('a if b else c', mode='eval'), indent=4))
          Expression(
              body=IfExp(
                  test=Name(id='b', ctx=Load()),
                  body=Name(id='a', ctx=Load()),
                  orelse=Name(id='c', ctx=Load())))

 -- クラス: ast.Attribute (value, attr, ctx)

     たとえば ‘d.keys’ のような属性へのアクセスです。 ‘value’ はノードで
     、典型的には *note Name: 18a9. です。 ‘attr’ は属性名を与える生の文
     字列で、 ‘ctx’ はその属性がどのように振る舞うかに応じて *note Load:
     189.、 *note Store: 4423. または *note Del: 4426. のいずれかです。

          >>> print(ast.dump(ast.parse('snake.colour', mode='eval'), indent=4))
          Expression(
              body=Attribute(
                  value=Name(id='snake', ctx=Load()),
                  attr='colour',
                  ctx=Load()))

 -- クラス: ast.NamedExpr (target, value)

     代入式です。この AST ノードは代入式演算子（ウォルラス演算子、または
     「セイウチ演算子」としても知られています）によって生成されます。第
     一引数が複数のノードであってもよい *note Assign: 4451. ノードと異な
     り、このノードの場合は ‘target’ と ‘value’ の両方が単一のノードでな
     ければなりません。

          >>> print(ast.dump(ast.parse('(x := 4)', mode='eval'), indent=4))
          Expression(
              body=NamedExpr(
                  target=Name(id='x', ctx=Store()),
                  value=Constant(value=4)))

     Added in version 3.8.

* Menu:

* 配列要素の参照 (Subscripting): 配列要素の参照 Subscripting.
* 内包表記 (Comprehension): 内包表記 Comprehension.


File: python.info,  Node: 配列要素の参照 Subscripting,  Next: 内包表記 Comprehension,  Up: 式 expression<2>

5.32.1.7 配列要素の参照 (Subscripting)
......................................

 -- クラス: ast.Subscript (value, slice, ctx)

     ‘l[1]’ のような配列要素の参照をあらわします。 ‘value’ は参照元のオ
     ブジェクトです (通常シーケンス型またはマッピング型)。 ‘slice’ はイ
     ンデックス、スライス、またはキーです。 *note Slice: 4454. を含む
     *note Tuple: 4422. でもかまいません。 ‘ctx’ は要素の参照により実行
     されるアクションに応じて *note Load: 189.、 *note Store: 4423. また
     は *note Del: 4426. のいずれかです。

          >>> print(ast.dump(ast.parse('l[1:2, 3]', mode='eval'), indent=4))
          Expression(
              body=Subscript(
                  value=Name(id='l', ctx=Load()),
                  slice=Tuple(
                      elts=[
                          Slice(
                              lower=Constant(value=1),
                              upper=Constant(value=2)),
                          Constant(value=3)],
                      ctx=Load()),
                  ctx=Load()))

 -- クラス: ast.Slice (lower, upper, step)

     基本的なスライス操作 (‘lower:upper’ や ‘lower:upper:step’ の形式) を
     あらわします。 *note Subscript: 4453. の 'slice' フィールドでの直接
     指定か、または *note Tuple: 4422. の要素として指定する場合のみ利用
     可能です。

          >>> print(ast.dump(ast.parse('l[1:2]', mode='eval'), indent=4))
          Expression(
              body=Subscript(
                  value=Name(id='l', ctx=Load()),
                  slice=Slice(
                      lower=Constant(value=1),
                      upper=Constant(value=2)),
                  ctx=Load()))


File: python.info,  Node: 内包表記 Comprehension,  Prev: 配列要素の参照 Subscripting,  Up: 式 expression<2>

5.32.1.8 内包表記 (Comprehension)
.................................

 -- クラス: ast.ListComp (elt, generators)
 -- クラス: ast.SetComp (elt, generators)
 -- クラス: ast.GeneratorExp (elt, generators)
 -- クラス: ast.DictComp (key, value, generators)

     リストや集合の内包表記、ジェネレータ、および辞書の内包表記です。
     ‘elt’ (または ‘key’ と ‘value’) は各要素として評価される部品をあら
     わす単一のノードです。

     ‘generators’ は *note comprehension: 445a. ノードのリストです。

          >>> print(ast.dump(
          ...     ast.parse('[x for x in numbers]', mode='eval'),
          ...     indent=4,
          ... ))
          Expression(
              body=ListComp(
                  elt=Name(id='x', ctx=Load()),
                  generators=[
                      comprehension(
                          target=Name(id='x', ctx=Store()),
                          iter=Name(id='numbers', ctx=Load()),
                          is_async=0)]))
          >>> print(ast.dump(
          ...     ast.parse('{x: x**2 for x in numbers}', mode='eval'),
          ...     indent=4,
          ... ))
          Expression(
              body=DictComp(
                  key=Name(id='x', ctx=Load()),
                  value=BinOp(
                      left=Name(id='x', ctx=Load()),
                      op=Pow(),
                      right=Constant(value=2)),
                  generators=[
                      comprehension(
                          target=Name(id='x', ctx=Store()),
                          iter=Name(id='numbers', ctx=Load()),
                          is_async=0)]))
          >>> print(ast.dump(
          ...     ast.parse('{x for x in numbers}', mode='eval'),
          ...     indent=4,
          ... ))
          Expression(
              body=SetComp(
                  elt=Name(id='x', ctx=Load()),
                  generators=[
                      comprehension(
                          target=Name(id='x', ctx=Store()),
                          iter=Name(id='numbers', ctx=Load()),
                          is_async=0)]))

 -- クラス: ast.comprehension (target, iter, ifs, is_async)

     内包表記におけるひとつの ‘for’ 節をあらわします。 ‘target’ は各要素
     への参照です - 典型的には *note Name: 18a9. または *note Tuple:
     4422. ノードです。 ‘iter’ はイテレートする対象のオブジェクトです。
     ‘ifs’ は条件節のリストです: 各 ‘for’ 節は複数の ‘ifs’ を持つことが
     できます。

     ‘is_async’ は内包表記が非同期であることを示します (‘async for’ を
     ‘for’ の代わりに使います)。値は整数です (0 または 1)。

          >>> print(ast.dump(ast.parse('[ord(c) for line in file for c in line]', mode='eval'),
          ...                indent=4)) # Multiple comprehensions in one.
          Expression(
              body=ListComp(
                  elt=Call(
                      func=Name(id='ord', ctx=Load()),
                      args=[
                          Name(id='c', ctx=Load())]),
                  generators=[
                      comprehension(
                          target=Name(id='line', ctx=Store()),
                          iter=Name(id='file', ctx=Load()),
                          is_async=0),
                      comprehension(
                          target=Name(id='c', ctx=Store()),
                          iter=Name(id='line', ctx=Load()),
                          is_async=0)]))

          >>> print(ast.dump(ast.parse('(n**2 for n in it if n>5 if n<10)', mode='eval'),
          ...                indent=4)) # generator comprehension
          Expression(
              body=GeneratorExp(
                  elt=BinOp(
                      left=Name(id='n', ctx=Load()),
                      op=Pow(),
                      right=Constant(value=2)),
                  generators=[
                      comprehension(
                          target=Name(id='n', ctx=Store()),
                          iter=Name(id='it', ctx=Load()),
                          ifs=[
                              Compare(
                                  left=Name(id='n', ctx=Load()),
                                  ops=[
                                      Gt()],
                                  comparators=[
                                      Constant(value=5)]),
                              Compare(
                                  left=Name(id='n', ctx=Load()),
                                  ops=[
                                      Lt()],
                                  comparators=[
                                      Constant(value=10)])],
                          is_async=0)]))

          >>> print(ast.dump(ast.parse('[i async for i in soc]', mode='eval'),
          ...                indent=4)) # Async comprehension
          Expression(
              body=ListComp(
                  elt=Name(id='i', ctx=Load()),
                  generators=[
                      comprehension(
                          target=Name(id='i', ctx=Store()),
                          iter=Name(id='soc', ctx=Load()),
                          is_async=1)]))


File: python.info,  Node: 文 Statements,  Next: 制御フロー,  Prev: 式 expression<2>,  Up: Node クラス

5.32.1.9 文 (Statements)
........................

 -- クラス: ast.Assign (targets, value, type_comment)

     代入です。 ‘targets’ はノードのリスト、 ‘value’ は単一のノードです
     。

     ‘targets’ の複数のノードは、それぞれに対して同じ値を代入することを
     あらわします。分割代入は ‘targets’ 内に *note Tuple: 4422. または
     *note List: 4421. を置くことで表現されます。

      -- の属性: type_comment

          ‘type_comment’ はコメントとして型アノテーションをあらわすオプ
          ション文字列です。

          >>> print(ast.dump(ast.parse('a = b = 1'), indent=4)) # Multiple assignment
          Module(
              body=[
                  Assign(
                      targets=[
                          Name(id='a', ctx=Store()),
                          Name(id='b', ctx=Store())],
                      value=Constant(value=1))])

          >>> print(ast.dump(ast.parse('a,b = c'), indent=4)) # Unpacking
          Module(
              body=[
                  Assign(
                      targets=[
                          Tuple(
                              elts=[
                                  Name(id='a', ctx=Store()),
                                  Name(id='b', ctx=Store())],
                              ctx=Store())],
                      value=Name(id='c', ctx=Load()))])

 -- クラス: ast.AnnAssign (target, annotation, value, simple)

     An assignment with a type annotation.  ‘target’ is a single node
     and can be a *note Name: 18a9, an *note Attribute: 444d. or a *note
     Subscript: 4453.  ‘annotation’ is the annotation, such as a *note
     Constant: 299. or *note Name: 18a9. node.  ‘value’ is a single
     optional node.

     ‘simple’ is always either 0 (indicating a "complex" target) or 1
     (indicating a "simple" target).  A "simple" target consists solely
     of a *note Name: 18a9. node that does not appear between
     parentheses; all other targets are considered complex.  Only simple
     targets appear in the ‘__annotations__’ dictionary of modules and
     classes.

          >>> print(ast.dump(ast.parse('c: int'), indent=4))
          Module(
              body=[
                  AnnAssign(
                      target=Name(id='c', ctx=Store()),
                      annotation=Name(id='int', ctx=Load()),
                      simple=1)])

          >>> print(ast.dump(ast.parse('(a): int = 1'), indent=4)) # Annotation with parenthesis
          Module(
              body=[
                  AnnAssign(
                      target=Name(id='a', ctx=Store()),
                      annotation=Name(id='int', ctx=Load()),
                      value=Constant(value=1),
                      simple=0)])

          >>> print(ast.dump(ast.parse('a.b: int'), indent=4)) # Attribute annotation
          Module(
              body=[
                  AnnAssign(
                      target=Attribute(
                          value=Name(id='a', ctx=Load()),
                          attr='b',
                          ctx=Store()),
                      annotation=Name(id='int', ctx=Load()),
                      simple=0)])

          >>> print(ast.dump(ast.parse('a[1]: int'), indent=4)) # Subscript annotation
          Module(
              body=[
                  AnnAssign(
                      target=Subscript(
                          value=Name(id='a', ctx=Load()),
                          slice=Constant(value=1),
                          ctx=Store()),
                      annotation=Name(id='int', ctx=Load()),
                      simple=0)])

 -- クラス: ast.AugAssign (target, op, value)

     ‘a += 1’ のような累積代入をあらわします。下記の例では、 ‘target’ は
     (*note Store: 4423. コンテキストを伴う) ‘x’ のための *note Name:
     18a9. ノード、 ‘op’ は *note Add: 4432. 演算子、そして ‘value’ は定
     数1をあらわす *note Constant: 299. ノードです。

     *note Assign: 4451. と異なり、 ‘target’ 属性は class *note Tuple:
     4422. や *note List: 4421. であってはいけません。

          >>> print(ast.dump(ast.parse('x += 2'), indent=4))
          Module(
              body=[
                  AugAssign(
                      target=Name(id='x', ctx=Store()),
                      op=Add(),
                      value=Constant(value=2))])

 -- クラス: ast.Raise (exc, cause)

     ‘raise’ 文をあらわします。 ‘exc’ は送出される例外オブジェクトで、通
     常は *note Call: 4428. または *note Name: 18a9.、 もしくは単独の
     ‘raise’ では ‘None’ を指定します。 ‘cause’ はオプションで、 ‘raise
     x from y’ の ‘y’ にあたります。

          >>> print(ast.dump(ast.parse('raise x from y'), indent=4))
          Module(
              body=[
                  Raise(
                      exc=Name(id='x', ctx=Load()),
                      cause=Name(id='y', ctx=Load()))])

 -- クラス: ast.Assert (test, msg)

     アサーションです。 ‘test’ は *note Compare: 4442. ノードなどのよう
     な条件を保持します。 ‘msg’ は失敗した時のメッセージを保持します。

          >>> print(ast.dump(ast.parse('assert x,y'), indent=4))
          Module(
              body=[
                  Assert(
                      test=Name(id='x', ctx=Load()),
                      msg=Name(id='y', ctx=Load()))])

 -- クラス: ast.Delete (targets)

     ‘del’ 文をあらわします。 ‘targets’ は *note Name: 18a9, *note
     Attribute: 444d, *note Subscript: 4453. などのノードのリストです。

          >>> print(ast.dump(ast.parse('del x,y,z'), indent=4))
          Module(
              body=[
                  Delete(
                      targets=[
                          Name(id='x', ctx=Del()),
                          Name(id='y', ctx=Del()),
                          Name(id='z', ctx=Del())])])

 -- クラス: ast.Pass

     ‘pass’ 文をあらわします。

          >>> print(ast.dump(ast.parse('pass'), indent=4))
          Module(
              body=[
                  Pass()])

 -- クラス: ast.TypeAlias (name, type_params, value)

     A *note type alias: 420. created through the *note type: 404.
     statement.  ‘name’ is the name of the alias, ‘type_params’ is a
     list of *note type parameters: 4463, and ‘value’ is the value of
     the type alias.

          >>> print(ast.dump(ast.parse('type Alias = int'), indent=4))
          Module(
              body=[
                  TypeAlias(
                      name=Name(id='Alias', ctx=Store()),
                      value=Name(id='int', ctx=Load()))])

     Added in version 3.12.

関数またはループの内部でのみ適用可能な他の文は、別のセクションで説明しま
す。

* Menu:

* インポート::


File: python.info,  Node: インポート,  Up: 文 Statements

5.32.1.10 インポート
....................

 -- クラス: ast.Import (names)

     インポート文です。 ‘names’ は *note alias: 1829. ノードのリストです
     。

          >>> print(ast.dump(ast.parse('import x,y,z'), indent=4))
          Module(
              body=[
                  Import(
                      names=[
                          alias(name='x'),
                          alias(name='y'),
                          alias(name='z')])])

 -- クラス: ast.ImportFrom (module, names, level)

     ‘from x import y’ をあらわします。 ‘module’ は 'from' でインポート
     する先頭がドットでないモジュール名をあらわす文字列か、または ‘from
     . import foo’ のような構文の場合は ‘None’ を指定します。 ‘level’ は
     相対インポートのレベルを表す整数を保持します (0 は絶対インポートを
     意味します)。

          >>> print(ast.dump(ast.parse('from y import x,y,z'), indent=4))
          Module(
              body=[
                  ImportFrom(
                      module='y',
                      names=[
                          alias(name='x'),
                          alias(name='y'),
                          alias(name='z')],
                      level=0)])

 -- クラス: ast.alias (name, asname)

     いずれのパラメータも名前をあらわす生の文字列です。 ‘asname’ は標準
     の名前を使う場合は ‘None’ を指定できます。

          >>> print(ast.dump(ast.parse('from ..foo.bar import a as b, c'), indent=4))
          Module(
              body=[
                  ImportFrom(
                      module='foo.bar',
                      names=[
                          alias(name='a', asname='b'),
                          alias(name='c')],
                      level=2)])


File: python.info,  Node: 制御フロー,  Next: Pattern matching,  Prev: 文 Statements,  Up: Node クラス

5.32.1.11 制御フロー
....................

     注釈: ‘else’ 節のようなオプションの節が存在しない場合は、空のリスト
     として保存されます。

 -- クラス: ast.If (test, body, orelse)

     ‘if’ 文です。 ‘test’ は *note Compare: 4442. ノードなどの単一のノー
     ドを保持します。 ‘body’ と ‘orelse’ はそれぞれノードのリストを保持
     します。

     ‘elif’ 節は AST において固有の表現を持たず、先行する節をあらわすノ
     ードの ‘orelse’ セクションに追加の *note If: 4468. ノードとして現れ
     ます。

          >>> print(ast.dump(ast.parse("""
          ... if x:
          ...    ...
          ... elif y:
          ...    ...
          ... else:
          ...    ...
          ... """), indent=4))
          Module(
              body=[
                  If(
                      test=Name(id='x', ctx=Load()),
                      body=[
                          Expr(
                              value=Constant(value=Ellipsis))],
                      orelse=[
                          If(
                              test=Name(id='y', ctx=Load()),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))],
                              orelse=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

 -- クラス: ast.For (target, iter, body, orelse, type_comment)

     A ‘for’ loop.  ‘target’ holds the variable(s) the loop assigns to,
     as a single *note Name: 18a9, *note Tuple: 4422, *note List: 4421,
     *note Attribute: 444d. or *note Subscript: 4453. node.  ‘iter’
     holds the item to be looped over, again as a single node.  ‘body’
     and ‘orelse’ contain lists of nodes to execute.  Those in ‘orelse’
     are executed if the loop finishes normally, rather than via a
     ‘break’ statement.

      -- の属性: type_comment

          ‘type_comment’ はコメントとして型アノテーションをあらわすオプ
          ション文字列です。

          >>> print(ast.dump(ast.parse("""
          ... for x in y:
          ...     ...
          ... else:
          ...     ...
          ... """), indent=4))
          Module(
              body=[
                  For(
                      target=Name(id='x', ctx=Store()),
                      iter=Name(id='y', ctx=Load()),
                      body=[
                          Expr(
                              value=Constant(value=Ellipsis))],
                      orelse=[
                          Expr(
                              value=Constant(value=Ellipsis))])])

 -- クラス: ast.While (test, body, orelse)

     ‘while’ ループです。 ‘test’ は *note Compare: 4442. のような条件を
     あらわすノードを保持します。

          >> print(ast.dump(ast.parse("""
          ... while x:
          ...    ...
          ... else:
          ...    ...
          ... """), indent=4))
          Module(
              body=[
                  While(
                      test=Name(id='x', ctx=Load()),
                      body=[
                          Expr(
                              value=Constant(value=Ellipsis))],
                      orelse=[
                          Expr(
                              value=Constant(value=Ellipsis))])])

 -- クラス: ast.Break
 -- クラス: ast.Continue

     ‘break’ 文および ‘continue’ 文です。

          >>> print(ast.dump(ast.parse("""\
          ... for a in b:
          ...     if a > 5:
          ...         break
          ...     else:
          ...         continue
          ...
          ... """), indent=4))
          Module(
              body=[
                  For(
                      target=Name(id='a', ctx=Store()),
                      iter=Name(id='b', ctx=Load()),
                      body=[
                          If(
                              test=Compare(
                                  left=Name(id='a', ctx=Load()),
                                  ops=[
                                      Gt()],
                                  comparators=[
                                      Constant(value=5)]),
                              body=[
                                  Break()],
                              orelse=[
                                  Continue()])])])

 -- クラス: ast.Try (body, handlers, orelse, finalbody)

     ‘try’ ブロックです。 *note ExceptHandler: 446f. ノードのリストであ
     る ‘handlers’ を除き、全ての属性はそれぞれの節で実行するノードのリ
     ストです。

          >>> print(ast.dump(ast.parse("""
          ... try:
          ...    ...
          ... except Exception:
          ...    ...
          ... except OtherException as e:
          ...    ...
          ... else:
          ...    ...
          ... finally:
          ...    ...
          ... """), indent=4))
          Module(
              body=[
                  Try(
                      body=[
                          Expr(
                              value=Constant(value=Ellipsis))],
                      handlers=[
                          ExceptHandler(
                              type=Name(id='Exception', ctx=Load()),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))]),
                          ExceptHandler(
                              type=Name(id='OtherException', ctx=Load()),
                              name='e',
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])],
                      orelse=[
                          Expr(
                              value=Constant(value=Ellipsis))],
                      finalbody=[
                          Expr(
                              value=Constant(value=Ellipsis))])])

 -- クラス: ast.TryStar (body, handlers, orelse, finalbody)

     ‘try’ blocks which are followed by ‘except*’ clauses.  The
     attributes are the same as for *note Try: 446e. but the *note
     ExceptHandler: 446f. nodes in ‘handlers’ are interpreted as
     ‘except*’ blocks rather then ‘except’.

          >>> print(ast.dump(ast.parse("""
          ... try:
          ...    ...
          ... except* Exception:
          ...    ...
          ... """), indent=4))
          Module(
              body=[
                  TryStar(
                      body=[
                          Expr(
                              value=Constant(value=Ellipsis))],
                      handlers=[
                          ExceptHandler(
                              type=Name(id='Exception', ctx=Load()),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.11.

 -- クラス: ast.ExceptHandler (type, name, body)

     単一の ‘except’ 節をあらわします。 ‘type’ はこの節にマッチする例外
     のタイプで、典型的には *note Name: 18a9. ノードです (‘None’ を指定
     すると全ての例外をキャッチする ‘except:’ 節をあらわします)。 ‘name’
     は例外オブジェクトを保持する変数の名前をあらわす生の文字列で、 ‘as
     foo’ を持たない節の場合は ‘None’ を指定します。 ‘body’ はノードのリ
     ストです。

          >>> print(ast.dump(ast.parse("""\
          ... try:
          ...     a + 1
          ... except TypeError:
          ...     pass
          ... """), indent=4))
          Module(
              body=[
                  Try(
                      body=[
                          Expr(
                              value=BinOp(
                                  left=Name(id='a', ctx=Load()),
                                  op=Add(),
                                  right=Constant(value=1)))],
                      handlers=[
                          ExceptHandler(
                              type=Name(id='TypeError', ctx=Load()),
                              body=[
                                  Pass()])])])

 -- クラス: ast.With (items, body, type_comment)

     ‘with’ ブロックです。 ‘items’ は *note withitem: 4472. ノードのリス
     トで、コンテキストマネージャのリストをあらわします。また ‘body’ は
     コンテキスト内にインデントされたブロックです。

      -- の属性: type_comment

          ‘type_comment’ はコメントとして型アノテーションをあらわすオプ
          ション文字列です。

 -- クラス: ast.withitem (context_expr, optional_vars)

     ‘with’ ブロックにおける単一のコンテキストマネージャをあらわします。
     ‘context_expr’ はコンテキストマネージャで、しばしば *note Call:
     4428. ノードが設定されます。 ‘optional_vars’ は ‘as foo’ に相当する
     *note Name: 18a9, *note Tuple: 4422. または *note List: 4421. のい
     ずれかのノードか、または、この部分が不要な場合は ‘None’ を設定しま
     す。

          >>> print(ast.dump(ast.parse("""\
          ... with a as b, c as d:
          ...    something(b, d)
          ... """), indent=4))
          Module(
              body=[
                  With(
                      items=[
                          withitem(
                              context_expr=Name(id='a', ctx=Load()),
                              optional_vars=Name(id='b', ctx=Store())),
                          withitem(
                              context_expr=Name(id='c', ctx=Load()),
                              optional_vars=Name(id='d', ctx=Store()))],
                      body=[
                          Expr(
                              value=Call(
                                  func=Name(id='something', ctx=Load()),
                                  args=[
                                      Name(id='b', ctx=Load()),
                                      Name(id='d', ctx=Load())]))])])


File: python.info,  Node: Pattern matching,  Next: Type parameters,  Prev: 制御フロー,  Up: Node クラス

5.32.1.12 Pattern matching
..........................

 -- クラス: ast.Match (subject, cases)

     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 *note match_case: 4476. nodes with the
     different cases.

     Added in version 3.10.

 -- クラス: ast.match_case (pattern, guard, body)

     A single case pattern in a ‘match’ statement.  ‘pattern’ contains
     the match pattern that the subject will be matched against.  Note
     that the *note AST: 18b. nodes produced for patterns differ from
     those produced for expressions, even when they share the same
     syntax.

     The ‘guard’ attribute contains an expression that will be evaluated
     if the pattern matches the subject.

     ‘body’ contains a list of nodes to execute if the pattern matches
     and the result of evaluating the guard expression is true.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case [x] if x>0:
          ...         ...
          ...     case tuple():
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchSequence(
                                  patterns=[
                                      MatchAs(name='x')]),
                              guard=Compare(
                                  left=Name(id='x', ctx=Load()),
                                  ops=[
                                      Gt()],
                                  comparators=[
                                      Constant(value=0)]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))]),
                          match_case(
                              pattern=MatchClass(
                                  cls=Name(id='tuple', ctx=Load())),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchValue (value)

     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.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case "Relevant":
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchValue(
                                  value=Constant(value='Relevant')),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchSingleton (value)

     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.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case None:
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchSingleton(value=None),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchSequence (patterns)

     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.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case [1, 2]:
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchSequence(
                                  patterns=[
                                      MatchValue(
                                          value=Constant(value=1)),
                                      MatchValue(
                                          value=Constant(value=2))]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchStar (name)

     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.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case [1, 2, *rest]:
          ...         ...
          ...     case [*_]:
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchSequence(
                                  patterns=[
                                      MatchValue(
                                          value=Constant(value=1)),
                                      MatchValue(
                                          value=Constant(value=2)),
                                      MatchStar(name='rest')]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))]),
                          match_case(
                              pattern=MatchSequence(
                                  patterns=[
                                      MatchStar()]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchMapping (keys, patterns, rest)

     A match mapping pattern.  ‘keys’ is a sequence of expression nodes.
     ‘patterns’ is a corresponding sequence of pattern nodes.  ‘rest’ is
     an optional name that can be specified to capture the remaining
     mapping elements.  Permitted key expressions are restricted as
     described in the match statement documentation.

     This pattern succeeds if the subject is a mapping, all evaluated
     key expressions are present in the mapping, and the value
     corresponding to each key matches the corresponding subpattern.  If
     ‘rest’ is not ‘None’, a dict containing the remaining mapping
     elements is bound to that name if the overall mapping pattern is
     successful.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case {1: _, 2: _}:
          ...         ...
          ...     case {**rest}:
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchMapping(
                                  keys=[
                                      Constant(value=1),
                                      Constant(value=2)],
                                  patterns=[
                                      MatchAs(),
                                      MatchAs()]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))]),
                          match_case(
                              pattern=MatchMapping(rest='rest'),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchClass (cls, patterns, kwd_attrs, kwd_patterns)

     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 against the class defined sequence of pattern matching
     attributes.  ‘kwd_attrs’ is a sequence of additional attributes to
     be matched (specified as keyword arguments in the class pattern),
     ‘kwd_patterns’ are the corresponding patterns (specified as keyword
     values in the class pattern).

     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.

     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.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case Point2D(0, 0):
          ...         ...
          ...     case Point3D(x=0, y=0, z=0):
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchClass(
                                  cls=Name(id='Point2D', ctx=Load()),
                                  patterns=[
                                      MatchValue(
                                          value=Constant(value=0)),
                                      MatchValue(
                                          value=Constant(value=0))]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))]),
                          match_case(
                              pattern=MatchClass(
                                  cls=Name(id='Point3D', ctx=Load()),
                                  kwd_attrs=[
                                      'x',
                                      'y',
                                      'z'],
                                  kwd_patterns=[
                                      MatchValue(
                                          value=Constant(value=0)),
                                      MatchValue(
                                          value=Constant(value=0)),
                                      MatchValue(
                                          value=Constant(value=0))]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchAs (pattern, name)

     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.

     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.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case [x] as y:
          ...         ...
          ...     case _:
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchAs(
                                  pattern=MatchSequence(
                                      patterns=[
                                          MatchAs(name='x')]),
                                  name='y'),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))]),
                          match_case(
                              pattern=MatchAs(),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.

 -- クラス: ast.MatchOr (patterns)

     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 succeed.  If none of the subpatterns
     succeed the or-pattern fails.  The ‘patterns’ attribute contains a
     list of match pattern nodes that will be matched against the
     subject.

          >>> print(ast.dump(ast.parse("""
          ... match x:
          ...     case [x] | (y):
          ...         ...
          ... """), indent=4))
          Module(
              body=[
                  Match(
                      subject=Name(id='x', ctx=Load()),
                      cases=[
                          match_case(
                              pattern=MatchOr(
                                  patterns=[
                                      MatchSequence(
                                          patterns=[
                                              MatchAs(name='x')]),
                                      MatchAs(name='y')]),
                              body=[
                                  Expr(
                                      value=Constant(value=Ellipsis))])])])

     Added in version 3.10.


File: python.info,  Node: Type parameters,  Next: 関数およびクラス定義,  Prev: Pattern matching,  Up: Node クラス

5.32.1.13 Type parameters
.........................

*note Type parameters: 293. can exist on classes, functions, and type
aliases.

 -- クラス: ast.TypeVar (name, bound, default_value)

     A *note typing.TypeVar: 143.  ‘name’ is the name of the type
     variable.  ‘bound’ is the bound or constraints, if any.  If ‘bound’
     is a *note Tuple: 4422, it represents constraints; otherwise it
     represents the bound.  ‘default_value’ is the default value; if the
     ‘TypeVar’ has no default, this attribute will be set to ‘None’.

          >>> print(ast.dump(ast.parse("type Alias[T: int = bool] = list[T]"), indent=4))
          Module(
              body=[
                  TypeAlias(
                      name=Name(id='Alias', ctx=Store()),
                      type_params=[
                          TypeVar(
                              name='T',
                              bound=Name(id='int', ctx=Load()),
                              default_value=Name(id='bool', ctx=Load()))],
                      value=Subscript(
                          value=Name(id='list', ctx=Load()),
                          slice=Name(id='T', ctx=Load()),
                          ctx=Load()))])

     Added in version 3.12.

     バージョン 3.13 で変更: Added the 'default_value' parameter.

 -- クラス: ast.ParamSpec (name, default_value)

     A *note typing.ParamSpec: 144.  ‘name’ is the name of the parameter
     specification.  ‘default_value’ is the default value; if the
     ‘ParamSpec’ has no default, this attribute will be set to ‘None’.

          >>> print(ast.dump(ast.parse("type Alias[**P = (int, str)] = Callable[P, int]"), indent=4))
          Module(
              body=[
                  TypeAlias(
                      name=Name(id='Alias', ctx=Store()),
                      type_params=[
                          ParamSpec(
                              name='P',
                              default_value=Tuple(
                                  elts=[
                                      Name(id='int', ctx=Load()),
                                      Name(id='str', ctx=Load())],
                                  ctx=Load()))],
                      value=Subscript(
                          value=Name(id='Callable', ctx=Load()),
                          slice=Tuple(
                              elts=[
                                  Name(id='P', ctx=Load()),
                                  Name(id='int', ctx=Load())],
                              ctx=Load()),
                          ctx=Load()))])

     Added in version 3.12.

     バージョン 3.13 で変更: Added the 'default_value' parameter.

 -- クラス: ast.TypeVarTuple (name, default_value)

     A *note typing.TypeVarTuple: 145.  ‘name’ is the name of the type
     variable tuple.  ‘default_value’ is the default value; if the
     ‘TypeVarTuple’ has no default, this attribute will be set to
     ‘None’.

          >>> print(ast.dump(ast.parse("type Alias[*Ts = ()] = tuple[*Ts]"), indent=4))
          Module(
              body=[
                  TypeAlias(
                      name=Name(id='Alias', ctx=Store()),
                      type_params=[
                          TypeVarTuple(
                              name='Ts',
                              default_value=Tuple(ctx=Load()))],
                      value=Subscript(
                          value=Name(id='tuple', ctx=Load()),
                          slice=Tuple(
                              elts=[
                                  Starred(
                                      value=Name(id='Ts', ctx=Load()),
                                      ctx=Load())],
                              ctx=Load()),
                          ctx=Load()))])

     Added in version 3.12.

     バージョン 3.13 で変更: Added the 'default_value' parameter.


File: python.info,  Node: 関数およびクラス定義,  Next: async と await,  Prev: Type parameters,  Up: Node クラス

5.32.1.14 関数およびクラス定義
..............................

 -- クラス: ast.FunctionDef (name, args, body, decorator_list, returns,
          type_comment, type_params)

     関数定義です。

        * ‘name’ は関数名をあらわす生の文字列です。

        * ‘args’ は引数をあらわす *note arguments: 4484. ノードです。

        * ‘body’ は関数の本体をあらわすノードのリストです。

        * ‘decorator_list’ は関数に適用されるデコレータのリストで、外側
          のデコレータがリストの先頭に保存されます (すなわち、リストの先
          頭にあるデコレータが最後に適用されます)。

        * ‘returns’ は戻り値に対する注釈です。

        * ‘type_params’ is a list of *note type parameters: 4463.

      -- の属性: type_comment

          ‘type_comment’ はコメントとして型アノテーションをあらわすオプ
          ション文字列です。

     バージョン 3.12 で変更: Added ‘type_params’.

 -- クラス: ast.Lambda (args, body)

     ‘lambda’ は式の中で使うことができる最小限の関数定義です。 *note
     FunctionDef: 166d. ノードと異なり、 ‘body’ は単一のノードとなります
     。

          >>> print(ast.dump(ast.parse('lambda x,y: ...'), indent=4))
          Module(
              body=[
                  Expr(
                      value=Lambda(
                          args=arguments(
                              args=[
                                  arg(arg='x'),
                                  arg(arg='y')]),
                          body=Constant(value=Ellipsis)))])

 -- クラス: ast.arguments (posonlyargs, args, vararg, kwonlyargs,
          kw_defaults, kwarg, defaults)

     関数の引数

        * ‘posonlyargs’, ‘args’ および ‘kwonlyargs’ はそれぞれ *note
          arg: 4486. ノードのリストです。

        * ‘vararg’ と ‘kwarg’ はそれぞれ単一の *note arg: 4486. ノードで
          、 ‘*args, **kwargs’ パラメータに相当します。

        * ‘kw_defaults’ はキーワード専用引数に対するデフォルト値のリスト
          です。値が ‘None’ の場合、対応する引数は必須となります。

        * ‘defaults’ は位置引数として渡すことのできる引数に対するデフォ
          ルト値のリストです。デフォルト値の数nが位置引数の数より少ない
          場合、それらは最後のn個の引数に割り当てられます。

 -- クラス: ast.arg (arg, annotation, type_comment)

     A single argument in a list.  ‘arg’ is a raw string of the argument
     name; ‘annotation’ is its annotation, such as a *note Name: 18a9.
     node.

      -- の属性: type_comment

          ‘type_comment’ はコメントとして型アノテーションをあらわすオプ
          ション文字列です。

          >>> print(ast.dump(ast.parse("""\
          ... @decorator1
          ... @decorator2
          ... def f(a: 'annotation', b=1, c=2, *d, e, f=3, **g) -> 'return annotation':
          ...     pass
          ... """), indent=4))
          Module(
              body=[
                  FunctionDef(
                      name='f',
                      args=arguments(
                          args=[
                              arg(
                                  arg='a',
                                  annotation=Constant(value='annotation')),
                              arg(arg='b'),
                              arg(arg='c')],
                          vararg=arg(arg='d'),
                          kwonlyargs=[
                              arg(arg='e'),
                              arg(arg='f')],
                          kw_defaults=[
                              None,
                              Constant(value=3)],
                          kwarg=arg(arg='g'),
                          defaults=[
                              Constant(value=1),
                              Constant(value=2)]),
                      body=[
                          Pass()],
                      decorator_list=[
                          Name(id='decorator1', ctx=Load()),
                          Name(id='decorator2', ctx=Load())],
                      returns=Constant(value='return annotation'))])

 -- クラス: ast.Return (value)

     ‘return’ 文です。

          >>> print(ast.dump(ast.parse('return 4'), indent=4))
          Module(
              body=[
                  Return(
                      value=Constant(value=4))])

 -- クラス: ast.Yield (value)
 -- クラス: ast.YieldFrom (value)

     A ‘yield’ or ‘yield from’ expression.  Because these are
     expressions, they must be wrapped in an *note Expr: 442a. node if
     the value sent back is not used.

          >>> print(ast.dump(ast.parse('yield x'), indent=4))
          Module(
              body=[
                  Expr(
                      value=Yield(
                          value=Name(id='x', ctx=Load())))])

          >>> print(ast.dump(ast.parse('yield from x'), indent=4))
          Module(
              body=[
                  Expr(
                      value=YieldFrom(
                          value=Name(id='x', ctx=Load())))])

 -- クラス: ast.Global (names)
 -- クラス: ast.Nonlocal (names)

     ‘global’ および ‘nonlocal’ 文です。 ‘names’ は生の文字列のリストで
     す。

          >>> print(ast.dump(ast.parse('global x,y,z'), indent=4))
          Module(
              body=[
                  Global(
                      names=[
                          'x',
                          'y',
                          'z'])])

          >>> print(ast.dump(ast.parse('nonlocal x,y,z'), indent=4))
          Module(
              body=[
                  Nonlocal(
                      names=[
                          'x',
                          'y',
                          'z'])])

 -- クラス: ast.ClassDef (name, bases, keywords, body, decorator_list,
          type_params)

     クラス定義です。

        * ‘name’ はクラス名をあらわす生の文字列です。

        * ‘bases’ は明示的に指定された基底クラスをあらわすノードのリスト
          です。

        * ‘keywords’ is a list of *note keyword: 444e. nodes,
          principally for 'metaclass'.  Other keywords will be passed to
          the metaclass, as per PEP 3115(1).

        * ‘body’ はクラス定義に含まれるコードをあらわすノードのリストで
          す。

        * ‘decorator_list’ はノードのリストで、関数定義 *note
          FunctionDef: 166d. の場合と同様に解釈されます。

        * ‘type_params’ is a list of *note type parameters: 4463.

          >>> print(ast.dump(ast.parse("""\
          ... @decorator1
          ... @decorator2
          ... class Foo(base1, base2, metaclass=meta):
          ...     pass
          ... """), indent=4))
          Module(
              body=[
                  ClassDef(
                      name='Foo',
                      bases=[
                          Name(id='base1', ctx=Load()),
                          Name(id='base2', ctx=Load())],
                      keywords=[
                          keyword(
                              arg='metaclass',
                              value=Name(id='meta', ctx=Load()))],
                      body=[
                          Pass()],
                      decorator_list=[
                          Name(id='decorator1', ctx=Load()),
                          Name(id='decorator2', ctx=Load())])])

     バージョン 3.12 で変更: Added ‘type_params’.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3115/


File: python.info,  Node: async と await,  Prev: 関数およびクラス定義,  Up: Node クラス

5.32.1.15 async と await
........................

 -- クラス: ast.AsyncFunctionDef (name, args, body, decorator_list,
          returns, type_comment, type_params)

     ‘async def’ 形式の関数定義です。通常の関数定義 *note FunctionDef:
     166d. と同じフィールドを持ちます。

     バージョン 3.12 で変更: Added ‘type_params’.

 -- クラス: ast.Await (value)

     ‘await’ 式をあらわします。 ‘value’ は待ち受ける値です。 *note
     AsyncFunctionDef: 166c. の本体 (body) の中でのみ有効です。

     >>> print(ast.dump(ast.parse("""\
     ... async def f():
     ...     await other_func()
     ... """), indent=4))
     Module(
         body=[
             AsyncFunctionDef(
                 name='f',
                 args=arguments(),
                 body=[
                     Expr(
                         value=Await(
                             value=Call(
                                 func=Name(id='other_func', ctx=Load()))))])])

 -- クラス: ast.AsyncFor (target, iter, body, orelse, type_comment)
 -- クラス: ast.AsyncWith (items, body, type_comment)

     ‘async for’ ループと ‘async with’ コンテキストマネージャです。それ
     ぞれ *note For: 4469. および *note With: 4471. と同じフィールドを持
     ちます。 *note AsyncFunctionDef: 166c. の本体 (body) の中でのみ有効
     です。

     注釈: 文字列が *note ast.parse(): 18d. によってパースされたとき、戻
     り値のツリーに含まれる演算子ノード (‘ast.operator’, ‘ast.unaryop’,
     ‘ast.cmpop’, ‘ast.boolop’ および ‘ast.expr_context’ のサブクラス) は
     シングルトンです。したがっていずれかの演算子ノードを変更すると、そ
     の変更は他の全ての同じ値 (たとえば *note ast.Add: 4432. ノードを変
     更した場合はその他全ての *note ast.Add: 4432. ノード) に反映されま
     す。


File: python.info,  Node: ast ヘルパー,  Next: コンパイラフラグ,  Prev: Node クラス,  Up: ast --- 抽象構文木

5.32.1.16 ‘ast’ ヘルパー
........................

ノード・クラスの他に、 *note ast: 7. モジュールは以下のような抽象構文木
をトラバースするためのユーティリティ関数やクラスも定義しています:

 -- の関数: ast.parse (source, filename='<unknown>', mode='exec', *,
          type_comments=False, feature_version=None, optimize=-1)

     Parse the source into an AST node.  Equivalent to ‘compile(source,
     filename, mode, flags=FLAGS_VALUE, optimize=optimize)’, where
     ‘FLAGS_VALUE’ is ‘ast.PyCF_ONLY_AST’ if ‘optimize <= 0’ and
     ‘ast.PyCF_OPTIMIZED_AST’ otherwise.

     If ‘type_comments=True’ is given, the parser is modified to check
     and return type comments as specified by PEP 484(1) and PEP 526(2).
     This is equivalent to adding *note ast.PyCF_TYPE_COMMENTS: 4490. to
     the flags passed to *note compile(): 177.  This will report syntax
     errors for misplaced type comments.  Without this flag, type
     comments will be ignored, and the ‘type_comment’ field on selected
     AST nodes will always be ‘None’.  In addition, the locations of ‘#
     type: ignore’ comments will be returned as the ‘type_ignores’
     attribute of *note Module: 4419. (otherwise it is always an empty
     list).

     さらに ‘mode’ が ‘'func_type'’ の場合、入力構文は、たとえば ‘(str,
     int) -> List[str]’ のような PEP 484(3) の "シグネチャ型コメント
     (signature type comments)" に対応するように修正されます。

     Setting ‘feature_version’ to a tuple ‘(major, minor)’ will result
     in a "best-effort" attempt to parse using that Python version's
     grammar.  For example, setting ‘feature_version=(3, 9)’ will
     attempt to disallow parsing of *note match: 7d8. statements.
     Currently ‘major’ must equal to ‘3’.  The lowest supported version
     is ‘(3, 7)’ (and this may increase in future Python versions); the
     highest is ‘sys.version_info[0:2]’.  "Best-effort" attempt means
     there is no guarantee that the parse (or success of the parse) is
     the same as when run on the Python version corresponding to
     ‘feature_version’.

     If source contains a null character (‘\0’), *note ValueError: 1e3.
     is raised.

          警告: 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 executed as the compilation step
          can raise further *note SyntaxError: 172. exceptions.  For
          instance, the source ‘return 42’ generates a valid AST node
          for a return statement, but it cannot be compiled alone (it
          needs to be inside a function node).

          In particular, *note ast.parse(): 18d. won't do any scoping
          checks, which the compilation step does.

          警告: 十分に大きい文字列や複雑な文字列によって Python の抽象構
          文木コンパイラのスタックの深さの限界を越えることで、 Python イ
          ンタプリタをクラッシュさせることができます。

     バージョン 3.8 で変更: ‘type_comments’、‘mode='func_type'’、
     ‘feature_version’ が追加されました。

     バージョン 3.13 で変更: The minimum supported version for
     ‘feature_version’ is now ‘(3, 7)’.  The ‘optimize’ argument was
     added.

 -- の関数: ast.unparse (ast_obj)

     *note ast.AST: 18b. オブジェクトを逆に構文解析して、 *note
     ast.parse(): 18d. が元の *note ast.AST: 18b. と等価なオブジェクトを
     生成できるような文字列を生成します。

          警告: 生成されたコード文字列は、生成元のコードである *note
          ast.AST: 18b. オブジェクトと必ずしも等価であるとは限りません
          (定数タプルや frozenset などに対するコンパイラ最適化なしのコー
          ドです)。

          警告: 非常に複雑な式を逆構文解析すると *note RecursionError:
          d39. となることがあります。

     Added in version 3.9.

 -- の関数: ast.literal_eval (node_or_string)

     Python のリテラルやコンテナ表現のみを含む式ノードまたは文字列を評価
     します。与えられる文字列またはノードは次の Python リテラル構造のみ
     からなるものに限られます: 文字列、バイト列、数、タプル、リスト、辞
     書、集合、ブール値、‘None’、‘Ellipsis’。

     この関数は Python の式を含んだ文字列を、値自身を解析することなしに
     評価するのに使えます。この関数は、例えば演算や添え字を含んだ任意の
     複雑な表現を評価するのには使えません。

     This function had been documented as "safe" in the past without
     defining what that meant.  That was misleading.  This is
     specifically designed not to execute Python code, unlike the more
     general *note eval(): 165.  There is no namespace, no name lookups,
     or ability to call out.  But it is not free from attack: A
     relatively small input can lead to memory exhaustion or to C stack
     exhaustion, crashing the process.  There is also the possibility
     for excessive CPU consumption denial of service on some inputs.
     Calling it on untrusted data is thus not recommended.

          警告: Python の抽象構文木コンパイラのスタックの深さの限界を越
          えることで、 Python インタプリタをクラッシュさせる可能性があり
          ます。

          It can raise *note ValueError: 1e3, *note TypeError: 502,
          *note SyntaxError: 172, *note MemoryError: 1627. and *note
          RecursionError: d39. depending on the malformed input.

     バージョン 3.2 で変更: バイト列リテラルと集合リテラルが受け取れるよ
     うになりました。

     バージョン 3.9 で変更: ‘'set()'’ による空の集合の生成をサポートする
     ようになりました。

     バージョン 3.10 で変更: For string inputs, leading spaces and tabs
     are now stripped.

 -- の関数: ast.get_docstring (node, clean=True)

     与えられた 'node' (これは *note FunctionDef: 166d, *note
     AsyncFunctionDef: 166c, *note ClassDef: 166b, *note Module: 4419. の
     いずれかのノードでなければなりません) のドキュメント文字列を返しま
     す。もしドキュメント文字列が無ければ ‘None’ を返します。 'clean' が
     真ならば、ドキュメント文字列のインデントを *note
     inspect.cleandoc(): 1619. を用いて一掃します。

     バージョン 3.5 で変更: *note AsyncFunctionDef: 166c. がサポートされ
     ました。

 -- の関数: ast.get_source_segment (source, node, *, padded=False)

     Get source code segment of the 'source' that generated 'node'.  If
     some location information (*note lineno: 4412, *note end_lineno:
     4414, *note col_offset: 4413, or *note end_col_offset: 4415.) is
     missing, return ‘None’.

     'padded' が ‘True’ の場合、複数行にわたる文の最初の行が元の位置に一
     致するように空白文字でパディングされます。

     Added in version 3.8.

 -- の関数: ast.fix_missing_locations (node)

     When you compile a node tree with *note compile(): 177, the
     compiler expects *note lineno: 4412. and *note col_offset: 4413.
     attributes for every node that supports them.  This is rather
     tedious to fill in for generated nodes, so this helper adds these
     attributes recursively where not already set, by setting them to
     the values of the parent node.  It works recursively starting at
     'node'.

 -- の関数: ast.increment_lineno (node, n=1)

     'node' で始まるツリー内の各ノードの行番号と終了行番号を 'n' ずつ増
     やします。これはファイルの中で別の場所に "コードを移動する" ときに
     便利です。

 -- の関数: ast.copy_location (new_node, old_node)

     Copy source location (*note lineno: 4412, *note col_offset: 4413,
     *note end_lineno: 4414, and *note end_col_offset: 4415.) from
     'old_node' to 'new_node' if possible, and return 'new_node'.

 -- の関数: ast.iter_fields (node)

     'node' にある ‘node._fields’ のそれぞれのフィールドを ‘(フィールド
     名, 値)’ のタプルとして yield します。

 -- の関数: ast.iter_child_nodes (node)

     'node' の直接の子ノード全てを yield します。すなわち、yield される
     のは、ノードであるような全てのフィールドおよびノードのリストである
     ようなフィールドの全てのアイテムです。

 -- の関数: ast.walk (node)

     'node' の全ての子孫ノード('node' 自体を含む)を再帰的に yield します
     。順番は決められていません。この関数はノードをその場で変更するだけ
     で文脈を気にしないような場合に便利です。

 -- クラス: ast.NodeVisitor

     抽象構文木を渡り歩いてビジター関数を見つけたノードごとに呼び出すノ
     ード・ビジターの基底クラスです。この関数は *note visit(): 4496. メ
     ソッドに送られる値を返してもかまいません。

     このクラスはビジター・メソッドを付け加えたサブクラスを派生させるこ
     とを意図しています。

      -- メソッド: visit (node)

          ノードを訪れます。デフォルトの実装では ‘self.visit_CLASSNAME’
          というメソッド (ここで 'classname' はノードのクラス名です) を
          呼び出すか、そのメソッドがなければ *note generic_visit():
          4497. を呼び出します。

      -- メソッド: generic_visit (node)

          このビジターはノードの全ての子について *note visit(): 4496. を
          呼び出します。

          注意して欲しいのは、専用のビジター・メソッドを具えたノードの子
          ノードは、このビジターが *note generic_visit(): 4497. を呼び出
          すかそれ自身で子ノードを訪れない限り訪れられないということです
          。

      -- メソッド: visit_Constant (node)

          Handles all constant nodes.

     トラバースの途中でノードを変化させたいならば *note NodeVisitor:
     a3b. を使ってはいけません。そうした目的のために変更を許す特別なビジ
     ター (*note NodeTransformer: 4498.) があります。

     バージョン 3.8 で非推奨: Methods ‘visit_Num()’, ‘visit_Str()’,
     ‘visit_Bytes()’, ‘visit_NameConstant()’ and ‘visit_Ellipsis()’ are
     deprecated now and will not be called in future Python versions.
     Add the *note visit_Constant(): a3c. method to handle all constant
     nodes.

 -- クラス: ast.NodeTransformer

     *note NodeVisitor: a3b. のサブクラスで抽象構文木を渡り歩きながらノ
     ードを変更することを許すものです。

     *note NodeTransformer: 4498. は抽象構文木(AST)を渡り歩き、ビジター
     ・メソッドの戻り値を使って古いノードを置き換えたり削除したりします
     。ビジター・メソッドの戻り値が ‘None’ ならば、ノードはその場から取
     り去られ、そうでなければ戻り値で置き換えられます。置き換えない場合
     は戻り値が元のノードそのものであってもかまいません。

     それでは例を示しましょう。Name (たとえば ‘foo’) を見つけるたび全て
     ‘data['foo']’ に書き換える変換器 (transformer) です:

          class RewriteName(NodeTransformer):

              def visit_Name(self, node):
                  return Subscript(
                      value=Name(id='data', ctx=Load()),
                      slice=Constant(value=node.id),
                      ctx=node.ctx
                  )

     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
     *note generic_visit(): 4497. method for the node first.

     文のコレクションであるようなノード (全ての文のノードが当てはまりま
     す) に対して、このビジターは単独のノードではなくノードのリストを返
     すかもしれません。

     If *note NodeTransformer: 4498. introduces new nodes (that weren't
     part of original tree) without giving them location information
     (such as *note lineno: 4412.), *note fix_missing_locations(): 4491.
     should be called with the new sub-tree to recalculate the location
     information:

          tree = ast.parse('foo', mode='eval')
          new_tree = fix_missing_locations(RewriteName().visit(tree))

     たいてい、変換器の使い方は次のようになります:

          node = YourTransformer().visit(node)

 -- の関数: ast.dump (node, annotate_fields=True,
          include_attributes=False, *, indent=None, show_empty=False)

     'node' 内のツリーのフォーマットされたダンプを返します。主な使い道は
     デバッグです。 'annotate_fields' が true の場合 (デフォルト)、返さ
     れる文字列はフィールドの名前と値を示します。 'annotate_fields' が
     false の場合、あいまいさのないフィールド名を省略することにより、結
     果文字列はよりコンパクトになります。行番号や列オフセットのような属
     性はデフォルトではダンプされません。これが必要であれば、
     'include_attributes' を true にすると表示できます。

     'indent' が非負の整数または文字列の場合、ツリーは指定されたインデン
     トレベルで整形されて出力されます (pretty-printed)。インデントレベル
     がゼロ、負の数、または ‘""’ の場合は改行だけを挿入します。 ‘None’
     (デフォルト値) は単一行での表記になります。正の整数を指定すると各イ
     ンデントレベルでその数だけの空白でインデントされます。 'indent' が
     文字列 (‘"\t"’ など) の場合、その文字列が各レベルのインデントに使わ
     れます。

     If 'show_empty' is ‘False’ (the default), empty lists and fields
     that are ‘None’ will be omitted from the output.

     バージョン 3.9 で変更: 'indent' オプションを追加しました。

     バージョン 3.13 で変更: Added the 'show_empty' option.

          >>> print(ast.dump(ast.parse("""\
          ... async def f():
          ...     await other_func()
          ... """), indent=4, show_empty=True))
          Module(
              body=[
                  AsyncFunctionDef(
                      name='f',
                      args=arguments(
                          posonlyargs=[],
                          args=[],
                          kwonlyargs=[],
                          kw_defaults=[],
                          defaults=[]),
                      body=[
                          Expr(
                              value=Await(
                                  value=Call(
                                      func=Name(id='other_func', ctx=Load()),
                                      args=[],
                                      keywords=[])))],
                      decorator_list=[],
                      type_params=[])],
              type_ignores=[])

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0526/

   (3) https://peps.python.org/pep-0484/


File: python.info,  Node: コンパイラフラグ,  Next: コマンドラインからの使用<4>,  Prev: ast ヘルパー,  Up: ast --- 抽象構文木

5.32.1.17 コンパイラフラグ
..........................

以下のフラグはプログラムのコンパイルにおける効果を変更するために *note
compile(): 177. に渡すことができます:

 -- データ: ast.PyCF_ALLOW_TOP_LEVEL_AWAIT

     トップレベルの ‘await’, ‘async for’, ‘async with’ および async 内包
     表記のサポートを有効化します。

     Added in version 3.8.

 -- データ: ast.PyCF_ONLY_AST

     コンパイルされたコードオブジェクトの代わりに抽象構文木を生成して返
     します。

 -- データ: ast.PyCF_OPTIMIZED_AST

     The returned AST is optimized according to the 'optimize' argument
     in *note compile(): 177. or *note ast.parse(): 18d.

     Added in version 3.13.

 -- データ: ast.PyCF_TYPE_COMMENTS

     PEP 484(1) および PEP 526(2) 形式の型コメント (‘# type: <type>’, ‘#
     type: ignore <stuff>’) のサポートを有効化します。

     Added in version 3.8.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0526/


File: python.info,  Node: コマンドラインからの使用<4>,  Prev: コンパイラフラグ,  Up: ast --- 抽象構文木

5.32.1.18 コマンドラインからの使用
..................................

Added in version 3.9.

*note ast: 7. モジュールはコマンドラインからスクリプトとして実行すること
ができます。実行方法は単純です:

     python -m ast [-m <mode>] [-a] [infile]

以下のオプションが使用できます:

 -- Option: -h, --help

     ヘルプメッセージを表示して終了します。

 -- Option: -m <mode>
 -- Option: --mode <mode>

     *note parse(): 18d. 関数の 'mode' 引数と同様、コンパイルするコード
     の種類を指定します。

 -- Option: --no-type-comments

     型コメントをパースしません。

 -- Option: -a, --include-attributes

     行番号や列オフセットなどの属性を含めます。

 -- Option: -i <indent>
 -- Option: --indent <indent>

     AST におけるノードのインデント (空白の数) です。

‘infile’ を指定するとその内容が AST にパースされて標準出力に出力されます
。そうでない場合は標準入力から入力を読み込みます。

参考
....

外部ドキュメント Green Tree Snakes(1) には Python AST についての詳細が書
かれています。

ASTTokens(2) は Python AST を、生成元のソースコードのトークン位置やテキ
ストで注解します。これはソースコード変換を行うツールで有用です。

leoAst.py(3) unifies the token-based and parse-tree-based views of
python programs by inserting two-way links between tokens and ast nodes.

LibCST(4) はコードを ast ツリーに似た構文木 (Concrete Syntax Tree) にパ
ースし、かつ全ての書式設定の詳細を保持します。これは自動リファクタリング
アプリケーション (codemod) やリンタを作成する際に有用です。

Parso(5) 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.

   ---------- Footnotes ----------

   (1) https://greentreesnakes.readthedocs.io/

   (2) https://asttokens.readthedocs.io/en/latest/user-guide.html

   (3) https://leo-editor.github.io/leo-editor/appendices.html#leoast-py

   (4) https://libcst.readthedocs.io/

   (5) https://parso.readthedocs.io


File: python.info,  Node: symtable --- コンパイラーの記号表へのアクセス,  Next: token --- Python 解析木で使われる定数,  Prev: ast --- 抽象構文木,  Up: Python言語サービス

5.32.2 ‘symtable’ -- コンパイラーの記号表へのアクセス
-----------------------------------------------------

'ソースコード:' Lib/symtable.py(1)

__________________________________________________________________

記号表(symbol table)は、コンパイラが AST からバイトコードを生成する直前
に作られます。記号表はコード中の全ての識別子のスコープの算出に責任を持ち
ます。 *note symtable: c2. はこうした記号表を調べるインターフェイスを提
供します。

* Menu:

* 記号表の生成::
* 記号表の検査::
* コマンドラインからの使用: コマンドラインからの使用<5>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/symtable.py


File: python.info,  Node: 記号表の生成,  Next: 記号表の検査,  Up: symtable --- コンパイラーの記号表へのアクセス

5.32.2.1 記号表の生成
.....................

 -- の関数: symtable.symtable (code, filename, compile_type)

     Python ソース 'code' に対するトップレベルの *note SymbolTable:
     44aa. を返します。 'filename' はコードを収めてあるファイルの名前で
     す。 'compile_type' は *note compile(): 177. の 'mode' 引数のような
     ものです。


File: python.info,  Node: 記号表の検査,  Next: コマンドラインからの使用<5>,  Prev: 記号表の生成,  Up: symtable --- コンパイラーの記号表へのアクセス

5.32.2.2 記号表の検査
.....................

 -- クラス: symtable.SymbolTableType

     An enumeration indicating the type of a *note SymbolTable: 44aa.
     object.

      -- の属性: MODULE = "module"

          Used for the symbol table of a module.

      -- の属性: FUNCTION = "function"

          Used for the symbol table of a function.

      -- の属性: CLASS = "class"

          Used for the symbol table of a class.

     The following members refer to different flavors of *note
     annotation scopes: 16d.

      -- の属性: ANNOTATION = "annotation"

          Used for annotations if ‘from __future__ import annotations’
          is active.

      -- の属性: TYPE_ALIAS = "type alias"

          Used for the symbol table of *note type: 404. constructions.

      -- の属性: TYPE_PARAMETERS = "type parameters"

          Used for the symbol table of *note generic functions: 41f. or
          *note generic classes: 41e.

      -- の属性: TYPE_VARIABLE = "type variable"

          Used for the symbol table of the bound, the constraint tuple
          or the default value of a single type variable in the formal
          sense, i.e., a TypeVar, a TypeVarTuple or a ParamSpec object
          (the latter two do not support a bound or a constraint tuple).

     Added in version 3.13.

 -- クラス: symtable.SymbolTable

     ブロックに対する名前空間の記号表。コンストラクタはパブリックではあ
     りません。

      -- メソッド: get_type ()

          Return the type of the symbol table.  Possible values are
          members of the *note SymbolTableType: 1570. enumeration.

          バージョン 3.12 で変更: Added ‘'annotation'’, ‘'TypeVar
          bound'’, ‘'type alias'’, and ‘'type parameter'’ as possible
          return values.

          バージョン 3.13 で変更: Return values are members of the *note
          SymbolTableType: 1570. enumeration.

          The exact values of the returned string may change in the
          future, and thus, it is recommended to use *note
          SymbolTableType: 1570. members instead of hard-coded strings.

      -- メソッド: get_id ()

          記号表の識別子を返します。

      -- メソッド: get_name ()

          Return the table's name.  This is the name of the class if the
          table is for a class, the name of the function if the table is
          for a function, or ‘'top'’ if the table is global (*note
          get_type(): 1571. returns ‘'module'’).  For type parameter
          scopes (which are used for generic classes, functions, and
          type aliases), it is the name of the underlying class,
          function, or type alias.  For type alias scopes, it is the
          name of the type alias.  For *note TypeVar: 143. bound scopes,
          it is the name of the ‘TypeVar’.

      -- メソッド: get_lineno ()

          この記号表に対応するブロックの一行目の行番号を返します。

      -- メソッド: is_optimized ()

          この記号表に含まれるローカル変数が最適化できるならば ‘True’ を
          返します。

      -- メソッド: is_nested ()

          ブロックが入れ子のクラスまたは関数のとき ‘True’ を返します。

      -- メソッド: has_children ()

          ブロックが入れ子の名前空間を含んでいるならば ‘True’ を返します
          。入れ子の名前空間は *note get_children(): 44b9. で得られます
          。

      -- メソッド: get_identifiers ()

          Return a view object containing the names of symbols in the
          table.  See the *note documentation of view objects: 21a1.

      -- メソッド: lookup (name)

          記号表から名前 'name' を見つけ出して *note Symbol: 1634. イン
          スタンスとして返します。

      -- メソッド: get_symbols ()

          記号表中の名前を表す *note Symbol: 1634. インスタンスのリスト
          を返します。

      -- メソッド: get_children ()

          入れ子になった記号表のリストを返します。

 -- クラス: symtable.Function

     A namespace for a function or method.  This class inherits from
     *note SymbolTable: 44aa.

      -- メソッド: get_parameters ()

          この関数の引数名からなるタプルを返します。

      -- メソッド: get_locals ()

          この関数のローカル変数の名前からなるタプルを返します。

      -- メソッド: get_globals ()

          この関数のグローバル変数の名前からなるタプルを返します。

      -- メソッド: get_nonlocals ()

          Return a tuple containing names of explicitly declared
          nonlocals in this function.

      -- メソッド: get_frees ()

          Return a tuple containing names of *note free (closure)
          variables: 1e9f. in this function.

 -- クラス: symtable.Class

     A namespace of a class.  This class inherits from *note
     SymbolTable: 44aa.

      -- メソッド: get_methods ()

          Return a tuple containing the names of method-like functions
          declared in the class.

          Here, the term 'method' designates 'any' function defined in
          the class body via *note def: 13ff. or *note async def: 59b.

          Functions defined in a deeper scope (e.g., in an inner class)
          are not picked up by *note get_methods(): 2c6.

          例えば:

               >>> import symtable
               >>> st = symtable.symtable('''
               ... def outer(): pass
               ...
               ... class A:
               ...    def f():
               ...        def w(): pass
               ...
               ...    def g(self): pass
               ...
               ...    @classmethod
               ...    async def h(cls): pass
               ...
               ...    global outer
               ...    def outer(self): pass
               ... ''', 'test', 'exec')
               >>> class_A = st.get_children()[1]
               >>> class_A.get_methods()
               ('f', 'g', 'h')

          Although ‘A().f()’ raises *note TypeError: 502. at runtime,
          ‘A.f’ is still considered as a method-like function.

 -- クラス: symtable.Symbol

     *note SymbolTable: 44aa. のエントリーでソースの識別子に対応するもの
     です。コンストラクタはパブリックではありません。

      -- メソッド: get_name ()

          記号の名前を返します。

      -- メソッド: is_referenced ()

          記号がそのブロックの中で使われていれば ‘True’ を返します。

      -- メソッド: is_imported ()

          記号が import 文で作られたものならば ‘True’ を返します。

      -- メソッド: is_parameter ()

          記号がパラメータならば ‘True’ を返します。

      -- メソッド: is_global ()

          記号がグローバルならば ‘True’ を返します。

      -- メソッド: is_nonlocal ()

          記号が非ローカルならば ‘True’ を返します。

      -- メソッド: is_declared_global ()

          記号が global 文によってグローバルであると宣言されているなら
          ‘True’ を返します。

      -- メソッド: is_local ()

          記号がそのブロックに対してローカルならば ‘True’ を返します。

      -- メソッド: is_annotated ()

          記号が注釈付きならば ‘True’ を返します。

          Added in version 3.6.

      -- メソッド: is_free ()

          記号がそのブロックの中で参照されていて、しかし代入は行われない
          ならば ‘True’ を返します。

      -- メソッド: is_assigned ()

          記号がそのブロックの中で代入されているならば ‘True’ を返します
          。

      -- メソッド: is_namespace ()

          名前の束縛が新たな名前空間を導入するならば ‘True’ を返します。

          名前が関数または class 文のターゲットとして使われるならば、真
          です。

          例えば:

               >>> table = symtable.symtable("def some_func(): pass", "string", "exec")
               >>> table.lookup("some_func").is_namespace()
               True

          一つの名前が複数のオブジェクトに束縛されうることに注意しましょ
          う。結果が ‘True’ であったとしても、その名前は他のオブジェクト
          にも束縛されるかもしれず、それがたとえば整数やリストであれば、
          そこでは新たな名前空間は導入されません。

      -- メソッド: get_namespaces ()

          この名前に束縛された名前空間のリストを返します。

      -- メソッド: get_namespace ()

          この名前に束縛された名前空間を返します。この名前に束縛された名
          前空間が複数あるか一つもないなら *note ValueError: 1e3. が送出
          されます。


File: python.info,  Node: コマンドラインからの使用<5>,  Prev: 記号表の検査,  Up: symtable --- コンパイラーの記号表へのアクセス

5.32.2.3 コマンドラインからの使用
.................................

Added in version 3.13.

The *note symtable: c2. module can be executed as a script from the
command line.

     python -m symtable [infile...]

Symbol tables are generated for the specified Python source files and
dumped to stdout.  If no input file is specified, the content is read
from stdin.


File: python.info,  Node: token --- Python 解析木で使われる定数,  Next: keyword --- Python キーワードのテスト,  Prev: symtable --- コンパイラーの記号表へのアクセス,  Up: Python言語サービス

5.32.3 ‘token’ -- Python 解析木で使われる定数
---------------------------------------------

'ソースコード:' Lib/token.py(1)

__________________________________________________________________

このモジュールは解析木の葉ノード(終端記号)の数値を表す定数を提供します。
言語の文法のコンテキストにおける名前の定義については、 Python ディストリ
ビューションのファイル file:‘Grammar/Tokens’ を参照してください。名前が
マップする特定の数値は Python のバージョン間で変わります。

このモジュールは、数値コードから名前へのマッピングと、いくつかの関数も提
供しています。関数は Python の C ヘッダファイルの定義を反映します。

 -- データ: token.tok_name

     ディクショナリはこのモジュールで定義されている定数の数値を名前の文
     字列へマップし、より人が読みやすいように解析木を表現します。

 -- の関数: token.ISTERMINAL (x)

     終端トークンの値に対して ‘True’ を返します。

 -- の関数: token.ISNONTERMINAL (x)

     非終端トークンの値に対して ‘True’ を返します。

 -- の関数: token.ISEOF (x)

     'x' が入力の終わりを示すマーカーならば、 ‘True’ を返します。

token の定数一覧:

 -- データ: token.ENDMARKER

 -- データ: token.NAME

 -- データ: token.NUMBER

 -- データ: token.STRING

 -- データ: token.NEWLINE

 -- データ: token.INDENT

 -- データ: token.DEDENT

 -- データ: token.LPAR

     Token value for ‘"("’.

 -- データ: token.RPAR

     Token value for ‘")"’.

 -- データ: token.LSQB

     Token value for ‘"["’.

 -- データ: token.RSQB

     Token value for ‘"]"’.

 -- データ: token.COLON

     Token value for ‘":"’.

 -- データ: token.COMMA

     Token value for ‘","’.

 -- データ: token.SEMI

     Token value for ‘";"’.

 -- データ: token.PLUS

     Token value for ‘"+"’.

 -- データ: token.MINUS

     Token value for ‘"-"’.

 -- データ: token.STAR

     Token value for ‘"*"’.

 -- データ: token.SLASH

     Token value for ‘"/"’.

 -- データ: token.VBAR

     Token value for ‘"|"’.

 -- データ: token.AMPER

     Token value for ‘"&"’.

 -- データ: token.LESS

     Token value for ‘"<"’.

 -- データ: token.GREATER

     Token value for ‘">"’.

 -- データ: token.EQUAL

     Token value for ‘"="’.

 -- データ: token.DOT

     Token value for ‘"."’.

 -- データ: token.PERCENT

     Token value for ‘"%"’.

 -- データ: token.LBRACE

     Token value for ‘"{"’.

 -- データ: token.RBRACE

     Token value for ‘"}"’.

 -- データ: token.EQEQUAL

     Token value for ‘"=="’.

 -- データ: token.NOTEQUAL

     Token value for ‘"!="’.

 -- データ: token.LESSEQUAL

     Token value for ‘"<="’.

 -- データ: token.GREATEREQUAL

     Token value for ‘">="’.

 -- データ: token.TILDE

     Token value for ‘"~"’.

 -- データ: token.CIRCUMFLEX

     Token value for ‘"^"’.

 -- データ: token.LEFTSHIFT

     Token value for ‘"<<"’.

 -- データ: token.RIGHTSHIFT

     Token value for ‘">>"’.

 -- データ: token.DOUBLESTAR

     Token value for ‘"**"’.

 -- データ: token.PLUSEQUAL

     Token value for ‘"+="’.

 -- データ: token.MINEQUAL

     Token value for ‘"-="’.

 -- データ: token.STAREQUAL

     Token value for ‘"*="’.

 -- データ: token.SLASHEQUAL

     Token value for ‘"/="’.

 -- データ: token.PERCENTEQUAL

     Token value for ‘"%="’.

 -- データ: token.AMPEREQUAL

     Token value for ‘"&="’.

 -- データ: token.VBAREQUAL

     Token value for ‘"|="’.

 -- データ: token.CIRCUMFLEXEQUAL

     Token value for ‘"^="’.

 -- データ: token.LEFTSHIFTEQUAL

     Token value for ‘"<<="’.

 -- データ: token.RIGHTSHIFTEQUAL

     Token value for ‘">>="’.

 -- データ: token.DOUBLESTAREQUAL

     Token value for ‘"**="’.

 -- データ: token.DOUBLESLASH

     Token value for ‘"//"’.

 -- データ: token.DOUBLESLASHEQUAL

     Token value for ‘"//="’.

 -- データ: token.AT

     Token value for ‘"@"’.

 -- データ: token.ATEQUAL

     Token value for ‘"@="’.

 -- データ: token.RARROW

     Token value for ‘"->"’.

 -- データ: token.ELLIPSIS

     Token value for ‘"..."’.

 -- データ: token.COLONEQUAL

     Token value for ‘":="’.

 -- データ: token.EXCLAMATION

     Token value for ‘"!"’.

 -- データ: token.OP

 -- データ: token.TYPE_IGNORE

 -- データ: token.TYPE_COMMENT

 -- データ: token.SOFT_KEYWORD

 -- データ: token.FSTRING_START

 -- データ: token.FSTRING_MIDDLE

 -- データ: token.FSTRING_END

 -- データ: token.COMMENT

 -- データ: token.NL

 -- データ: token.ERRORTOKEN

 -- データ: token.N_TOKENS

 -- データ: token.NT_OFFSET

以下のトークン値は、Cのトークナイザでは利用されませんが、 *note
tokenize: e4. モジュールによって利用されます。

 -- データ: token.COMMENT

     コメントであることを表すために使われるトークン値です。

 -- データ: token.NL

     終わりではない改行を表すために使われるトークン値。 *note NEWLINE:
     44dc. トークンは Pythonコードの論理行の終わりを表します。 ‘NL’ トー
     クンはコードの論理行が複数の物理行にわたって続いているときに作られ
     ます。

 -- データ: token.ENCODING

     ソースの bytes をテキストにデコードするために使われるエンコーディン
     グを示すトークン値。*note tokenize.tokenize(): 4a6. は常に最初に
     ENCODING トークンを返します。

 -- データ: token.TYPE_COMMENT

     Token value indicating that a type comment was recognized.  Such
     tokens are only produced when *note ast.parse(): 18d. is invoked
     with ‘type_comments=True’.

バージョン 3.5 で変更: Added ‘AWAIT’ and ‘ASYNC’ tokens.

バージョン 3.7 で変更: *note COMMENT: 4516. 、*note NL: 4517.、*note
ENCODING: 451b. トークンが追加されました。

バージョン 3.7 で変更: Removed ‘AWAIT’ and ‘ASYNC’ tokens.  "async" and
"await" are now tokenized as *note NAME: 44d9. tokens.

バージョン 3.8 で変更: Added *note TYPE_COMMENT: 4511, *note
TYPE_IGNORE: 4510, *note COLONEQUAL: 450d.  Added ‘AWAIT’ and ‘ASYNC’
tokens back (they're needed to support parsing older Python versions for
*note ast.parse(): 18d. with ‘feature_version’ set to 6 or lower).

バージョン 3.13 で変更: Removed ‘AWAIT’ and ‘ASYNC’ tokens again.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/token.py


File: python.info,  Node: keyword --- Python キーワードのテスト,  Next: tokenize --- Python ソース用のトークナイザー,  Prev: token --- Python 解析木で使われる定数,  Up: Python言語サービス

5.32.4 ‘keyword’ -- Python キーワードのテスト
---------------------------------------------

'ソースコード:' Lib/keyword.py(1)

__________________________________________________________________

このモジュールでは、Python プログラムで文字列が *note キーワード: 1dfe.
や *note ソフトキーワード: 7d7. か否かをチェックする機能を提供します。

 -- の関数: keyword.iskeyword (s)

     's' が Python の *note キーワード: 1dfe. であれば ‘True’ を返します
     。

 -- データ: keyword.kwlist

     インタープリタで定義している全ての *note キーワード: 1dfe. のシーケ
     ンス。特定の *note __future__: 0. 宣言がなければ有効ではないキーワ
     ードでもこのリストには含まれます。

 -- の関数: keyword.issoftkeyword (s)

     's' が Python の *note ソフトキーワード: 7d7. であれば ‘True’ を返
     します。

     Added in version 3.9.

 -- データ: keyword.softkwlist

     インタープリタで定義している全ての *note ソフトキーワード: 7d7. の
     シーケンス。特定の *note __future__: 0. 宣言がなければ有効ではない
     ソフトキーワードでもこのリストには含まれます。

     Added in version 3.9.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/keyword.py


File: python.info,  Node: tokenize --- Python ソース用のトークナイザー,  Next: tabnanny --- あいまいなインデントの検出,  Prev: keyword --- Python キーワードのテスト,  Up: Python言語サービス

5.32.5 ‘tokenize’ -- Python ソース用のトークナイザー
----------------------------------------------------

'ソースコード:' Lib/tokenize.py(1)

__________________________________________________________________

*note tokenize: e4. モジュールでは、Python で実装された Python ソースコ
ードの字句解析器を提供します。さらに、このモジュールの字句解析器はコメン
トもトークンとして返します。このため、このモジュールはスクリーン上で表示
する際の色付け機能 (colorizers) を含む "清書出力器 (pretty-printer)" を
実装する上で便利です。

トークン・ストリームの扱いをシンプルにするために、全ての *note operator:
1e3e. と *note delimiter: 1e3f. トークンおよび *note Ellipsis: 20ea. は
ジェネリックな *note OP: 450f. トークンタイプとして返されます。正確な型
は *note tokenize.tokenize(): 4a6. が返す *note named tuple: 61a. の
‘exact_type’ プロパティをチェックすれば解ります。

     警告: Note that the functions in this module are only designed to
     parse syntactically valid Python code (code that does not raise
     when parsed using *note ast.parse(): 18d.).  The behavior of the
     functions in this module is 'undefined' when providing invalid
     Python code and it can change at any point.

* Menu:

* 入力のトークナイズ::
* コマンドラインからの使用: コマンドラインからの使用<6>.
* 使用例: 使用例<49>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tokenize.py


File: python.info,  Node: 入力のトークナイズ,  Next: コマンドラインからの使用<6>,  Up: tokenize --- Python ソース用のトークナイザー

5.32.5.1 入力のトークナイズ
...........................

第一のエントリポイントは *note ジェネレータ: 1035. です:

 -- の関数: tokenize.tokenize (readline)

     *note tokenize(): 4a6. ジェネレータは一つの引数 'readline' を必要と
     します。この引数は呼び出し可能オブジェクトで、ファイルオブジェクト
     の *note io.IOBase.readline(): 12f8. メソッドと同じインタフェースを
     提供している必要があります。この関数は呼び出しのたびに入力の一行を
     bytes で返さなければなりません。

     このジェネレータは次の5要素のタプルを返します; トークンタイプ; トー
     クン文字列; ソース内でそのトークンがどの行、列で開始するかを示す
     int の ‘(srow, scol)’ タプル; どの行、列で終了するかを示す int の
     ‘(erow, ecol)’ タプル; トークンが見つかった行。 (タプルの最後の要素
     にある) 行は '物理' 行です。この5要素のタプルは *note named tuple:
     61a. として返され、フィールド名は ‘type string start end line’ にな
     ります。

     返される *note named tuple: 61a. は追加のプロパティ ‘exact_type’ を
     持ちます。このプロパティは *note OP: 450f. トークンに対して正確な演
     算子のタイプを持ちます。それ以外のトークンタイプについては、
     ‘exact_type’ は ‘type’ フィールドと同じ値を持ちます。

     バージョン 3.1 で変更: named tuple のサポートを追加。

     バージョン 3.3 で変更: ‘exact_type’ のサポートを追加。

     *note tokenize(): 4a6. は PEP 263(1) にしたがって、ソースのエンコー
     ディングを UTF-8 BOM か encoding cookie を見つけて決定します。

 -- の関数: tokenize.generate_tokens (readline)

     Tokenize a source reading unicode strings instead of bytes.

     Like *note tokenize(): 4a6, the 'readline' argument is a callable
     returning a single line of input.  However, *note
     generate_tokens(): 4a7. expects 'readline' to return a str object
     rather than bytes.

     The result is an iterator yielding named tuples, exactly like *note
     tokenize(): 4a6.  It does not yield an *note ENCODING: 451b. token.

*note token: e3. モジュールの全ての定数は *note tokenize: e4. モジュール
からも公開されています。

もう一つの関数がトークン化プロセスを逆転するために提供されています。これ
は、スクリプトを字句解析し、トークンのストリームに変更を加え、変更された
スクリプトを書き戻すようなツールを作成する際に便利です。

 -- の関数: tokenize.untokenize (iterable)

     トークンの列を Python ソースコードに変換します。 'iterable' は少な
     くとも二つの要素、トークンタイプおよびトークン文字列、からなるシー
     ケンスを返さなければいけません。 その他のシーケンスの要素は無視され
     ます。

     再構築されたスクリプトは一つの文字列として返されます。得られる結果
     はもう一度字句解析すると入力と一致することが保証されるので、変換が
     ロスレスでありラウンドトリップできることは間違いありません。この保
     証はトークン型およびトークン文字列に対してのものでトークン間のスペ
     ース (コラム位置)のようなものは変わることがあり得ます。

     It returns bytes, encoded using the *note ENCODING: 451b. token,
     which is the first token sequence output by *note tokenize(): 4a6.
     If there is no encoding token in the input, it returns a str
     instead.

*note tokenize(): 4a6. はトークナイズしようとしているソースファイルのエ
ンコーディングを検出する必要があります。これを行うために使っている関数が
公開されています:

 -- の関数: tokenize.detect_encoding (readline)

     *note detect_encoding(): 27b8. 関数は Python のソースファイルをデコ
     ードするのに使うエンコーディングを検出するために使われます。 *note
     tokenize(): 4a6. ジェネレータと同じ readline を引数として取ります。

     readline を最大2回呼び出し、利用するエンコーディング (文字列として)
     と、読み込んだ行を (bytes からデコードされないままの状態で) 返しま
     す。

     UTF-8 BOM か PEP 263(2) で定義されている encoding cookie からエンコ
     ーディングを検出します。BOMと cookie の両方が存在し、一致していない
     場合、*note SyntaxError: 172. が送出されます。 BOM が見つかった場合
     はエンコーディングとして ‘'utf-8-sig'’ が返されます。

     エンコーディングが指定されていない場合、デフォルトの ‘'utf-8'’ が返
     されます。

     Python のソースファイルを開くには *note open(): 27b7. を使ってくだ
     さい。これは *note detect_encoding(): 27b8. を利用してファイルエン
     コーディングを検出します。

 -- の関数: tokenize.open (filename)

     *note detect_encoding(): 27b8. を使って検出したエンコーディングを利
     用して、ファイルを読み出し専用モードで開きます。

     Added in version 3.2.

 -- 例外: tokenize.TokenError

     docstring や複数行にわたることが許される式がファイル内のどこかで終
     わっていない場合に送出されます。例えば:

          """Beginning of
          docstring

     もしくは:

          [1,
           2,
           3

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0263/

   (2) https://peps.python.org/pep-0263/


File: python.info,  Node: コマンドラインからの使用<6>,  Next: 使用例<49>,  Prev: 入力のトークナイズ,  Up: tokenize --- Python ソース用のトークナイザー

5.32.5.2 コマンドラインからの使用
.................................

Added in version 3.3.

*note tokenize: e4. モジュールはコマンドラインからスクリプトとして実行す
ることができます。次のようにシンプルに利用できます:

     python -m tokenize [-e] [filename.py]

以下のオプションが使用できます:

 -- Option: -h, --help

     このヘルプメッセージを出力して終了します

 -- Option: -e, --exact

     exact type を使ってトークン名を表示します

‘filename.py’ が指定された場合、その内容がトークナイズされ stdout に出力
されます。指定されなかった場合は stdin からトークナイズします。


File: python.info,  Node: 使用例<49>,  Prev: コマンドラインからの使用<6>,  Up: tokenize --- Python ソース用のトークナイザー

5.32.5.3 使用例
...............

スクリプト書き換えの例で、浮動小数点数リテラルを Decimal オブジェクトに
変換します:

     from tokenize import tokenize, untokenize, NUMBER, STRING, NAME, OP
     from io import BytesIO

     def decistmt(s):
         """Substitute Decimals for floats in a string of statements.

         >>> from decimal import Decimal
         >>> s = 'print(+21.3e-5*-.1234/81.7)'
         >>> decistmt(s)
         "print (+Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7'))"

         The format of the exponent is inherited from the platform C library.
         Known cases are "e-007" (Windows) and "e-07" (not Windows).  Since
         we're only showing 12 digits, and the 13th isn't close to 5, the
         rest of the output should be platform-independent.

         >>> exec(s)  #doctest: +ELLIPSIS
         -3.21716034272e-0...7

         Output from calculations with Decimal should be identical across all
         platforms.

         >>> exec(decistmt(s))
         -3.217160342717258261933904529E-7
         """
         result = []
         g = tokenize(BytesIO(s.encode('utf-8')).readline)  # tokenize the string
         for toknum, tokval, _, _, _ in g:
             if toknum == NUMBER and '.' in tokval:  # replace NUMBER tokens
                 result.extend([
                     (NAME, 'Decimal'),
                     (OP, '('),
                     (STRING, repr(tokval)),
                     (OP, ')')
                 ])
             else:
                 result.append((toknum, tokval))
         return untokenize(result).decode('utf-8')

コマンドラインからトークナイズする例。次のスクリプトが:

     def say_hello():
         print("Hello, World!")

     say_hello()

トークナイズされて次のような出力になります。最初のカラムはトークンが現れ
た行／カラム、次のカラムはトークンの名前、最後のカラムは (あれば) トーク
ンの値です

     $ python -m tokenize hello.py
     0,0-0,0:            ENCODING       'utf-8'
     1,0-1,3:            NAME           'def'
     1,4-1,13:           NAME           'say_hello'
     1,13-1,14:          OP             '('
     1,14-1,15:          OP             ')'
     1,15-1,16:          OP             ':'
     1,16-1,17:          NEWLINE        '\n'
     2,0-2,4:            INDENT         '    '
     2,4-2,9:            NAME           'print'
     2,9-2,10:           OP             '('
     2,10-2,25:          STRING         '"Hello, World!"'
     2,25-2,26:          OP             ')'
     2,26-2,27:          NEWLINE        '\n'
     3,0-3,1:            NL             '\n'
     4,0-4,0:            DEDENT         ''
     4,0-4,9:            NAME           'say_hello'
     4,9-4,10:           OP             '('
     4,10-4,11:          OP             ')'
     4,11-4,12:          NEWLINE        '\n'
     5,0-5,0:            ENDMARKER      ''

トークンの exact_type 名は *note -e: 4528. オプションで表示できます:

     $ python -m tokenize -e hello.py
     0,0-0,0:            ENCODING       'utf-8'
     1,0-1,3:            NAME           'def'
     1,4-1,13:           NAME           'say_hello'
     1,13-1,14:          LPAR           '('
     1,14-1,15:          RPAR           ')'
     1,15-1,16:          COLON          ':'
     1,16-1,17:          NEWLINE        '\n'
     2,0-2,4:            INDENT         '    '
     2,4-2,9:            NAME           'print'
     2,9-2,10:           LPAR           '('
     2,10-2,25:          STRING         '"Hello, World!"'
     2,25-2,26:          RPAR           ')'
     2,26-2,27:          NEWLINE        '\n'
     3,0-3,1:            NL             '\n'
     4,0-4,0:            DEDENT         ''
     4,0-4,9:            NAME           'say_hello'
     4,9-4,10:           LPAR           '('
     4,10-4,11:          RPAR           ')'
     4,11-4,12:          NEWLINE        '\n'
     5,0-5,0:            ENDMARKER      ''

Example of tokenizing a file programmatically, reading unicode strings
instead of bytes with *note generate_tokens(): 4a7.:

     import tokenize

     with tokenize.open('hello.py') as f:
         tokens = tokenize.generate_tokens(f.readline)
         for token in tokens:
             print(token)

Or reading bytes directly with *note tokenize(): 4a6.:

     import tokenize

     with open('hello.py', 'rb') as f:
         tokens = tokenize.tokenize(f.readline)
         for token in tokens:
             print(token)


File: python.info,  Node: tabnanny --- あいまいなインデントの検出,  Next: pyclbr --- Python モジュールブラウザーサポート,  Prev: tokenize --- Python ソース用のトークナイザー,  Up: Python言語サービス

5.32.6 ‘tabnanny’ -- あいまいなインデントの検出
-----------------------------------------------

'ソースコード:' Lib/tabnanny.py(1)

__________________________________________________________________

差し当たり、このモジュールはスクリプトとして呼び出すことを意図しています
。しかし、IDE 上にインポートして下で説明する関数 *note check(): 452d. を
使うことができます。

     注釈: このモジュールが提供する API を将来のリリースで変更する確率が
     高いです。このような変更は後方互換性がないかもしれません。

 -- の関数: tabnanny.check (file_or_dir)

     'file_or_dir' がディレクトリであってシンボリックリンクでないときに
     、 'file_or_dir' という名前のディレクトリツリーを再帰的に下って行き
     、この通り道に沿ってすべての ‘.py’ ファイルをチェックします。
     'file_or_dir' が通常の Python ソースファイルの場合には、問題のある
     空白をチェックします。診断メッセージは *note print(): f42. 関数を使
     って標準出力に書き込まれます。

 -- データ: tabnanny.verbose

     冗長なメッセージをプリントするかどうかを示すフラグ。スクリプトとし
     て呼び出された場合は、‘-v’ オプションによって増加します。

 -- データ: tabnanny.filename_only

     問題のある空白を含むファイルのファイル名のみをプリントするかどうか
     を示すフラグ。スクリプトとして呼び出された場合は、‘-q’ オプションに
     よって真に設定されます。

 -- 例外: tabnanny.NannyNag

     あいまいなインデントを検出した場合に *note process_tokens(): 4531.
     が送出します。 この例外は *note check(): 452d. で捕捉され処理されま
     す。

 -- の関数: tabnanny.process_tokens (tokens)

     この関数は、 *note tokenize: e4. モジュールによって生成されたトーク
     ンを *note check(): 452d. が処理するために使われます。

参考
....

*note tokenize: e4. モジュール

     Pythonソースコードの字句解析器。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tabnanny.py


File: python.info,  Node: pyclbr --- Python モジュールブラウザーサポート,  Next: py_compile --- Python ソースファイルをコンパイルする,  Prev: tabnanny --- あいまいなインデントの検出,  Up: Python言語サービス

5.32.7 ‘pyclbr’ -- Python モジュールブラウザーサポート
------------------------------------------------------

'ソースコード:' Lib/pyclbr.py(1)

__________________________________________________________________

The *note pyclbr: a2. module provides limited information about the
functions, classes, and methods defined in a Python-coded module.  The
information is sufficient to implement a module browser.  The
information is extracted from the Python source code rather than by
importing the module, so this module is safe to use with untrusted code.
This restriction makes it impossible to use this module with modules not
implemented in Python, including all standard and optional extension
modules.

 -- の関数: pyclbr.readmodule (module, path=None)

     Return a dictionary mapping module-level class names to class
     descriptors.  If possible, descriptors for imported base classes
     are included.  Parameter 'module' is a string with the name of the
     module to read; it may be the name of a module within a package.
     If given, 'path' is a sequence of directory paths prepended to
     ‘sys.path’, which is used to locate the module source code.

     This function is the original interface and is only kept for back
     compatibility.  It returns a filtered version of the following.

 -- の関数: pyclbr.readmodule_ex (module, path=None)

     Return a dictionary-based tree containing a function or class
     descriptors for each function and class defined in the module with
     a ‘def’ or ‘class’ statement.  The returned dictionary maps
     module-level function and class names to their descriptors.  Nested
     objects are entered into the children dictionary of their parent.
     As with readmodule, 'module' names the module to be read and 'path'
     is prepended to sys.path.  If the module being read is a package,
     the returned dictionary has a key ‘'__path__'’ whose value is a
     list containing the package search path.

Added in version 3.7: Descriptors for nested definitions.  They are
accessed through the new children attribute.  Each has a new parent
attribute.

The descriptors returned by these functions are instances of Function
and Class classes.  Users are not expected to create instances of these
classes.

* Menu:

* Function オブジェクト::
* クラスオブジェクト: クラスオブジェクト<2>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pyclbr.py


File: python.info,  Node: Function オブジェクト,  Next: クラスオブジェクト<2>,  Up: pyclbr --- Python モジュールブラウザーサポート

5.32.7.1 Function オブジェクト
..............................

 -- クラス: pyclbr.Function

     Class ‘Function’ instances describe functions defined by def
     statements.  They have the following attributes:

      -- の属性: file

          Name of the file in which the function is defined.

      -- の属性: module

          The name of the module defining the function described.

      -- の属性: name

          関数の名前です。

      -- の属性: lineno

          The line number in the file where the definition starts.

      -- の属性: parent

          For top-level functions, ‘None’.  For nested functions, the
          parent.

          Added in version 3.7.

      -- の属性: children

          A *note dictionary: 237. mapping names to descriptors for
          nested functions and classes.

          Added in version 3.7.

      -- の属性: is_async

          ‘True’ for functions that are defined with the *note async:
          59b. prefix, ‘False’ otherwise.

          Added in version 3.10.


File: python.info,  Node: クラスオブジェクト<2>,  Prev: Function オブジェクト,  Up: pyclbr --- Python モジュールブラウザーサポート

5.32.7.2 クラスオブジェクト
...........................

 -- クラス: pyclbr.Class

     Class ‘Class’ instances describe classes defined by class
     statements.  They have the same attributes as *note Functions:
     4536. and two more.

      -- の属性: file

          Name of the file in which the class is defined.

      -- の属性: module

          The name of the module defining the class described.

      -- の属性: name

          クラスの名前です。

      -- の属性: lineno

          The line number in the file where the definition starts.

      -- の属性: parent

          For top-level classes, ‘None’.  For nested classes, the
          parent.

          Added in version 3.7.

      -- の属性: children

          A dictionary mapping names to descriptors for nested functions
          and classes.

          Added in version 3.7.

      -- の属性: super

          A list of ‘Class’ objects which describe the immediate base
          classes of the class being described.  Classes which are named
          as superclasses but which are not discoverable by *note
          readmodule_ex(): 7f7. are listed as a string with the class
          name instead of as ‘Class’ objects.

      -- の属性: methods

          A *note dictionary: 237. mapping method names to line numbers.
          This can be derived from the newer *note children: 4546.
          dictionary, but remains for back-compatibility.


File: python.info,  Node: py_compile --- Python ソースファイルをコンパイルする,  Next: compileall --- Python ライブラリをバイトコンパイルする,  Prev: pyclbr --- Python モジュールブラウザーサポート,  Up: Python言語サービス

5.32.8 ‘py_compile’ -- Python ソースファイルをコンパイルする
------------------------------------------------------------

'ソースコード:' Lib/py_compile.py(1)

__________________________________________________________________

*note py_compile: a1. モジュールには、ソースファイルからバイトコードファ
イルを作る関数と、モジュールのソースファイルがスクリプトとして呼び出され
る時に使用される関数が定義されています。

頻繁に必要となるわけではありませんが、共有ライブラリとしてモジュールをイ
ンストールする場合や、特にソースコードのあるディレクトリにバイトコードの
キャッシュファイルを書き込む権限がないユーザがいるときには、この関数は役
に立ちます。

 -- 例外: py_compile.PyCompileError

     ファイルをコンパイル中にエラーが発生すると送出される例外。

 -- の関数: py_compile.compile (file, cfile=None, dfile=None,
          doraise=False, optimize=-1,
          invalidation_mode=PycInvalidationMode.TIMESTAMP, quiet=0)

     Compile a source file to byte-code and write out the byte-code
     cache file.  The source code is loaded from the file named 'file'.
     The byte-code is written to 'cfile', which defaults to the PEP
     3147(2)/ PEP 488(3) path, ending in ‘.pyc’.  For example, if 'file'
     is ‘/foo/bar/baz.py’ 'cfile' will default to
     ‘/foo/bar/__pycache__/baz.cpython-32.pyc’ for Python 3.2.  If
     'dfile' is specified, it is used instead of 'file' as the name of
     the source file from which source lines are obtained for display in
     exception tracebacks.  If 'doraise' is true, a *note
     PyCompileError: 454b. is raised when an error is encountered while
     compiling 'file'.  If 'doraise' is false (the default), an error
     string is written to ‘sys.stderr’, but no exception is raised.
     This function returns the path to byte-compiled file, i.e.
     whatever 'cfile' value was used.

     The 'doraise' and 'quiet' arguments determine how errors are
     handled while compiling file.  If 'quiet' is 0 or 1, and 'doraise'
     is false, the default behaviour is enabled: an error string is
     written to ‘sys.stderr’, and the function returns ‘None’ instead of
     a path.  If 'doraise' is true, a *note PyCompileError: 454b. is
     raised instead.  However if 'quiet' is 2, no message is written,
     and 'doraise' has no effect.

     (明示的に指定されたか計算された結果の) 'cfile' のパスがシンボリック
     リンクだったり通常のファイルでなかったりした場合は、 *note
     FileExistsError: fea. が送出されます。この動作は、それらのパスにバ
     イトコンパイルされたファイルを書き込む権限がある場合、インポートの
     ときにそのパスを通常のファイルに変えてしまうことを警告するためのも
     のです。これはリネームを使ってバイトコンパイルされたファイルを配置
     するインポートで、同時にファイル書き込みをしてしまう問題を避けるた
     めの副作用です。

     'optimize' は最適化レベルを制御するもので、組み込みの *note
     compile(): 177. 関数に渡されます。デフォルトは現在のインタープリタ
     の最適化レベルを選ぶ ‘-1’ です。

     'invalidation_mode' should be a member of the *note
     PycInvalidationMode: 454c. enum and controls how the generated
     bytecode cache is invalidated at runtime.  The default is *note
     PycInvalidationMode.CHECKED_HASH: 454d. if the ‘SOURCE_DATE_EPOCH’
     environment variable is set, otherwise the default is *note
     PycInvalidationMode.TIMESTAMP: 454e.

     バージョン 3.2 で変更: PEP 3147(4) に準拠し 'cfile' のデフォルト値
     を変更しました。以前のデフォルトは 'file' + ‘'c'’ (最適化が有効な場
     合は ‘'o'’) でした。同時に 'optimize' パラメータも追加されました。

     バージョン 3.4 で変更: バイトコードをキャッシュするファイルへの書き
     込みに *note importlib: 6b. を使うようにコードを変更しました。これ
     により、例えば権限や write-and-move セマンティクスなどの、ファイル
     の作成や書き込みの動作が *note importlib: 6b. と一致するようになり
     ました。 'cfile' がシンボリックリンクであるか通常のファイルでない場
     合、 *note FileExistsError: fea. を送出するという注意書きも追加され
     ました。

     バージョン 3.7 で変更: The 'invalidation_mode' parameter was added
     as specified in PEP 552(5).  If the ‘SOURCE_DATE_EPOCH’ environment
     variable is set, 'invalidation_mode' will be forced to *note
     PycInvalidationMode.CHECKED_HASH: 454d.

     バージョン 3.7.2 で変更: The ‘SOURCE_DATE_EPOCH’ environment
     variable no longer overrides the value of the 'invalidation_mode'
     argument, and determines its default value instead.

     バージョン 3.8 で変更: 'quiet' パラメータが追加されました。

 -- クラス: py_compile.PycInvalidationMode

     An enumeration of possible methods the interpreter can use to
     determine whether a bytecode file is up to date with a source file.
     The ‘.pyc’ file indicates the desired invalidation mode in its
     header.  See *note キャッシュされたバイトコードの無効化: 5b6. for
     more information on how Python invalidates ‘.pyc’ files at runtime.

     Added in version 3.7.

      -- の属性: TIMESTAMP

          The ‘.pyc’ file includes the timestamp and size of the source
          file, which Python will compare against the metadata of the
          source file at runtime to determine if the ‘.pyc’ file needs
          to be regenerated.

      -- の属性: CHECKED_HASH

          The ‘.pyc’ file includes a hash of the source file content,
          which Python will compare against the source at runtime to
          determine if the ‘.pyc’ file needs to be regenerated.

      -- の属性: UNCHECKED_HASH

          Like *note CHECKED_HASH: 454d, the ‘.pyc’ file includes a hash
          of the source file content.  However, Python will at runtime
          assume the ‘.pyc’ file is up to date and not validate the
          ‘.pyc’ against the source file at all.

          This option is useful when the ‘.pycs’ are kept up to date by
          some system external to Python like a build system.

* Menu:

* コマンドラインインターフェイス: コマンドラインインターフェイス<11>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/py_compile.py

   (2) https://peps.python.org/pep-3147/

   (3) https://peps.python.org/pep-0488/

   (4) https://peps.python.org/pep-3147/

   (5) https://peps.python.org/pep-0552/


File: python.info,  Node: コマンドラインインターフェイス<11>,  Up: py_compile --- Python ソースファイルをコンパイルする

5.32.8.1 コマンドラインインターフェイス
.......................................

This module can be invoked as a script to compile several source files.
The files named in 'filenames' are compiled and the resulting bytecode
is cached in the normal manner.  This program does not search a
directory structure to locate source files; it only compiles files named
explicitly.  The exit status is nonzero if one of the files could not be
compiled.

 -- Option: <file> ... <fileN>
 -- Option: -

     Positional arguments are files to compile.  If ‘-’ is the only
     parameter, the list of files is taken from standard input.

 -- Option: -q, --quiet

     Suppress errors output.

バージョン 3.2 で変更: ‘-’ のサポートが追加されました。

バージョン 3.10 で変更: *note -q: 4554. のサポートが追加されました。

参考
....

*note compileall: 19. モジュール

     ディレクトリツリー内の Python ソースファイルを全てコンパイルするラ
     イブラリ。


File: python.info,  Node: compileall --- Python ライブラリをバイトコンパイルする,  Next: dis --- Python バイトコードの逆アセンブラー,  Prev: py_compile --- Python ソースファイルをコンパイルする,  Up: Python言語サービス

5.32.9 ‘compileall’ -- Python ライブラリをバイトコンパイルする
--------------------------------------------------------------

'ソースコード:' Lib/compileall.py(1)

__________________________________________________________________

このモジュールは、Python ライブラリのインストールを助けるユーティリティ
関数群を提供します。この関数群は、ディレクトリツリー内の Python ソースフ
ァイルをコンパイルします。このモジュールを使って、キャッシュされたバイト
コードファイルをライブラリのインストール時に生成することで、ライブラリデ
ィレクトリに書き込み権限をもたないユーザでも、これらを利用できるようにな
ります。

*note Availability: 1cbe.: not WASI.

このモジュールは WebAssembly では動作しないか、利用不可です。詳しくは、
*note WebAssembly プラットフォーム: 174c. を見てください。

* Menu:

* コマンドラインでの使用: コマンドラインでの使用<2>.
* パブリックな関数::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/compileall.py


File: python.info,  Node: コマンドラインでの使用<2>,  Next: パブリックな関数,  Up: compileall --- Python ライブラリをバイトコンパイルする

5.32.9.1 コマンドラインでの使用
...............................

このモジュールは、 (‘python -m compileall’ を使って) Python ソースをコン
パイルするスクリプトとして機能します。

 -- Option: directory ...
 -- Option: file ...

     位置引数は、コンパイルするファイル群か、再帰的に横断されるディレク
     トリでソースファイル群を含むものです。引数が与えられなければ、 ‘-l
     <DIRECTORIES FROM SYS.PATH>’ を渡したのと同じように動作します。

 -- Option: -l

     サブディレクトリを再帰処理せず、指名または暗示されたディレクトリ群
     に含まれるソースコードファイル群だけをコンパイルします。

 -- Option: -f

     タイムスタンプが最新であってもリビルドを強制します。

 -- Option: -q

     コンパイルされたファイルのリストを出力しません。 一つ渡された場合で
     もエラーメッセージは出力されます。 二つ (‘-qq’) の場合全ての出力は
     抑制されます。

 -- Option: -d destdir

     コンパイルされるそれぞれのファイルへのパスの先頭に、ディレクトリを
     追加します。これはコンパイル時トレースバックに使われ、バイトコード
     ファイルが実行される時点でソースファイルが存在しない場合に、トレー
     スバックやその他のメッセージに使われるバイトコードファイルにもコン
     パイルされます。

 -- Option: -s strip_prefix

 -- Option: -p prepend_prefix

     Remove (‘-s’) or append (‘-p’) the given prefix of paths recorded
     in the ‘.pyc’ files.  Cannot be combined with ‘-d’.

 -- Option: -x regex

     regex を使って、コンパイル候補のそれぞれのファイルのフルパスを検索
     し、regex がマッチしたファイルを除外します。

 -- Option: -i list

     ファイル ‘list’ を読み込み、そのファイルのそれぞれの行を、コンパイ
     ルするファイルとディレクトリのリストに加えます。‘list’ が ‘-’ なら
     、‘stdin’ の行を読み込みます。

 -- Option: -b

     バイトコードファイルを、他のバージョンの Python によって生成された
     バイトコードファイルを上書きするかもしれない、レガシーな場所に生成
     します。デフォルトでは PEP 3147(1) で決められた場所と名前を使い、複
     数のバージョンの Python が共存できるようにします。

 -- Option: -r

     サブディレクトリの最大再起深度を制御します。 このオプションが与えら
     れた場合、‘-l’ オプションは無視されます。 ‘python -m compileall
     <directory> -r 0’ は ‘python -m compileall <directory> -l’ と等価で
     す。

 -- Option: -j N

     Use 'N' workers to compile the files within the given directory.
     If ‘0’ is used, then the result of *note os.process_cpu_count():
     1a6. will be used.

 -- Option: --invalidation-mode [timestamp|checked-hash|unchecked-hash]

     生成したバイトコードファイルを実行時に無効化する方法を制御します。
     ‘timestamp’ を指定すると、生成した''.pyc'' ファイルにソースファイル
     のタイムスタンプとサイズを埋め込みます。‘checked-hash’ と
     ‘unchecked-hash’ を指定すると、ハッシュベースの pycファイルが生成さ
     れます。ハッシュベースのpycファイルは、ソースファイルにタイムスタン
     プではなくハッシュ値を埋め込みます。Python がバイトコードキャッシュ
     ファイルを実行時に検証する方法の詳細を知るには、*note
     キャッシュされたバイトコードの無効化: 5b6. を参照してください。デフ
     ォルト値は、 ‘SOURCE_DATE_EPOCH’ 環境変数が設定されていなければ
     ‘timestamp’ で、‘SOURCE_DATE_EPOCH’ 環境変数が設定されていれば、
     ‘checked-hash’ になります。

 -- Option: -o level

     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’).

 -- Option: -e dir

     Ignore symlinks pointing outside the given directory.

 -- Option: --hardlink-dupes

     If two ‘.pyc’ files with different optimization level have the same
     content, use hard links to consolidate duplicate files.

バージョン 3.2 で変更: ‘-i’, ‘-b’, ‘-h’ オプションを追加。

バージョン 3.5 で変更: ‘-j’, ‘-r’, ‘-qq’ オプションが追加されました。
‘-q’ オプションが複数のレベルの値に変更されました。‘-b’ は常に拡張子
‘.pyc’ のバイトエンコーディングファイルを生成し、‘.pyo’ を作りません。

バージョン 3.7 で変更: ‘--invalidation-mode’ オプションが追加されました
。

バージョン 3.9 で変更: Added the ‘-s’, ‘-p’, ‘-e’ and ‘--hardlink-dupes’
options.  Raised the default recursion limit from 10 to *note
sys.getrecursionlimit(): 490.  Added the possibility to specify the ‘-o’
option multiple times.

*note compile(): 177. 関数で利用される最適化レベルを制御するコマンドライ
ンオプションはありません。 Python インタプリタ自体のオプションを使ってく
ださい: ‘python -O -m compileall’.

Similarly, the *note compile(): 177. function respects the *note
sys.pycache_prefix: 972. setting.  The generated bytecode cache will
only be useful if *note compile(): 177. is run with the same *note
sys.pycache_prefix: 972. (if any) that will be used at runtime.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3147/


File: python.info,  Node: パブリックな関数,  Prev: コマンドラインでの使用<2>,  Up: compileall --- Python ライブラリをバイトコンパイルする

5.32.9.2 パブリックな関数
.........................

 -- の関数: compileall.compile_dir (dir,
          maxlevels=sys.getrecursionlimit(), ddir=None, force=False,
          rx=None, quiet=0, legacy=False, optimize=-1, workers=1,
          invalidation_mode=None, *, stripdir=None, prependdir=None,
          limit_sl_dest=None, hardlink_dupes=False)

     'dir' という名前のディレクトリーツリーをたどり、途中で見つけた全て
     の ‘.py’ をコンパイルします。全ファイルのコンパイルが成功した場合は
     真を、それ以外の場合は偽を返します。

     'maxlevels' パラメータで最大再帰深度を制限します。デフォルトは
     ‘sys.getrecursionlimit()’ です。

     'ddir' が与えられた場合、コンパイルされるそれぞれのファイルへのパス
     の先頭に、そのディレクトリを追加します。これはコンパイル時トレース
     バックに使われ、バイトコードファイルが実行される時点でソースファイ
     ルが存在しない場合に、トレースバックやその他のメッセージに使われる
     バイトコードファイルにもコンパイルされます。

     'force' が真の場合、タイムスタンプが最新のであってもモジュールは再
     コンパイルされます。

     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 *note re.Pattern: f53.
     object.

     'quiet' が ‘False’ か ‘0’ (デフォルト) の場合、ファイル名とその他の
     情報は標準出力に表示されます。 ‘1’ の場合エラーのみが表示されます。
     ‘2’ の場合出力はすべて抑制されます。

     'legacy' が真の時、バイトコードファイルは古い場所と名前に書かれ、他
     のバージョンの Python によって作られたバイトコードファイルを上書き
     する可能性があります。デフォルトは PEP 3147(1) で決められた場所と名
     前を使い、複数のバージョンの Python のバイトコードファイルが共存で
     きるようにします。

     'optimize' specifies the optimization level for the compiler.  It
     is passed to the built-in *note compile(): 177. function.  Accepts
     also a sequence of optimization levels which lead to multiple
     compilations of one ‘.py’ file in one call.

     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 can't use multiple workers and 'workers'
     argument is given, then sequential compilation will be used as a
     fallback.  If 'workers' is 0, the number of cores in the system is
     used.  If 'workers' is lower than ‘0’, a *note ValueError: 1e3.
     will be raised.

     'invalidation_mode' は、*note py_compile.PycInvalidationMode: 454c.
     のメンバーでなければならず、生成されたpycファイルを実行時に無効化す
     る方法を制御します。

     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 *note os.PathLike: c1f.

     If 'hardlink_dupes' is true and two ‘.pyc’ files with different
     optimization level have the same content, use hard links to
     consolidate duplicate files.

     バージョン 3.2 で変更: 'legacy' と 'optimize' 引数が追加されました
     。

     バージョン 3.5 で変更: ‘workers’ パラメータが追加されました。

     バージョン 3.5 で変更: 'quiet' 引数が複数のレベルの値に変更されまし
     た。

     バージョン 3.5 で変更: 'optimize' の値に関わらず、'legacy' 引数は
     ‘.pyc’ ファイルのみを書き出し、‘.pyo’ ファイルを書き出さないように
     なりました。

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

     バージョン 3.7 で変更: 'invalidation_mode' 引数を追加しました。

     バージョン 3.7.2 で変更: The 'invalidation_mode' parameter's
     default value is updated to ‘None’.

     バージョン 3.8 で変更: Setting 'workers' to 0 now chooses the
     optimal number of cores.

     バージョン 3.9 で変更: Added 'stripdir', 'prependdir',
     'limit_sl_dest' and 'hardlink_dupes' arguments.  Default value of
     'maxlevels' was changed from ‘10’ to ‘sys.getrecursionlimit()’

 -- の関数: compileall.compile_file (fullname, ddir=None, force=False,
          rx=None, quiet=0, legacy=False, optimize=-1,
          invalidation_mode=None, *, stripdir=None, prependdir=None,
          limit_sl_dest=None, hardlink_dupes=False)

     パス 'fullname' のファイルをコンパイルします。コンパイルが成功すれ
     ば真を、そうでなければ偽を返します。

     'ddir' が与えられた場合、コンパイルされるファイルのパスの先頭にその
     ディレクトリを追加します。これはコンパイル時トレースバックに使われ
     、バイトコードファイルが実行される時点でソースファイルが存在しない
     場合に、トレースバックやその他のメッセージに使われるバイトコードフ
     ァイルにもコンパイルされます。

     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 compiled and ‘True’ is returned.  This can be used to
     exclude files matching a regular expression, given as a *note
     re.Pattern: f53. object.

     'quiet' が ‘False’ か ‘0’ (デフォルト) の場合、ファイル名とその他の
     情報は標準出力に表示されます。 ‘1’ の場合エラーのみが表示されます。
     ‘2’ の場合出力はすべて抑制されます。

     'legacy' が真の時、バイトコードファイルは古い場所と名前に書かれ、他
     のバージョンの Python によって作られたバイトコードファイルを上書き
     する可能性があります。デフォルトは PEP 3147(2) で決められた場所と名
     前を使い、複数のバージョンの Python のバイトコードファイルが共存で
     きるようにします。

     'optimize' specifies the optimization level for the compiler.  It
     is passed to the built-in *note compile(): 177. function.  Accepts
     also a sequence of optimization levels which lead to multiple
     compilations of one ‘.py’ file in one call.

     'invalidation_mode' は、*note py_compile.PycInvalidationMode: 454c.
     のメンバーでなければならず、生成されたpycファイルを実行時に無効化す
     る方法を制御します。

     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 *note os.PathLike: c1f.

     If 'hardlink_dupes' is true and two ‘.pyc’ files with different
     optimization level have the same content, use hard links to
     consolidate duplicate files.

     Added in version 3.2.

     バージョン 3.5 で変更: 'quiet' 引数が複数のレベルの値に変更されまし
     た。

     バージョン 3.5 で変更: 'optimize' の値に関わらず、'legacy' 引数は
     ‘.pyc’ ファイルのみを書き出し、‘.pyo’ ファイルを書き出さないように
     なりました。

     バージョン 3.7 で変更: 'invalidation_mode' 引数を追加しました。

     バージョン 3.7.2 で変更: The 'invalidation_mode' parameter's
     default value is updated to ‘None’.

     バージョン 3.9 で変更: 引数 'stripdir' 、 'prependdir' 、
     'limit_sl_dest' 、および 'hardlink_dupes' を追加しました。

 -- の関数: compileall.compile_path (skip_curdir=True, maxlevels=0,
          force=False, quiet=0, legacy=False, optimize=-1,
          invalidation_mode=None)

     ‘sys.path’ からたどって見つけたすべての ‘.py’ ファイルをバイトコン
     パイルします。 すべてのファイルを問題なくコンパイルできたときに真を
     、それ以外のときに偽を返します。

     'skip_curdir' が真(デフォルト)のとき、カレントディレクトリは走査か
     ら除外されます。 それ以外のすべての引数は *note compile_dir(): af4.
     関数に渡されます。 その他の compile 関数群と異なり、 ‘maxlevels’ の
     デフォルトが ‘0’ になっていることに注意してください。

     バージョン 3.2 で変更: 'legacy' と 'optimize' 引数が追加されました
     。

     バージョン 3.5 で変更: 'quiet' 引数が複数のレベルの値に変更されまし
     た。

     バージョン 3.5 で変更: 'optimize' の値に関わらず、'legacy' 引数は
     ‘.pyc’ ファイルのみを書き出し、‘.pyo’ ファイルを書き出さないように
     なりました。

     バージョン 3.7 で変更: 'invalidation_mode' 引数を追加しました。

     バージョン 3.7.2 で変更: The 'invalidation_mode' parameter's
     default value is updated to ‘None’.

‘Lib/’ ディレクトリ以下にある全ての ‘.py’ ファイルを強制的に再コンパイル
するには、以下のようにします:

     import compileall

     compileall.compile_dir('Lib/', force=True)

     # Perform same compilation, excluding files in .svn directories.
     import re
     compileall.compile_dir('Lib/', rx=re.compile(r'[/\\][.]svn'), force=True)

     # pathlib.Path objects can also be used.
     import pathlib
     compileall.compile_dir(pathlib.Path('Lib/'), force=True)

参考
....

Module *note py_compile: a1.

     一つのソースファイルをバイトコンパイルします。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3147/

   (2) https://peps.python.org/pep-3147/


File: python.info,  Node: dis --- Python バイトコードの逆アセンブラー,  Next: pickletools --- pickle 開発者用のツール群,  Prev: compileall --- Python ライブラリをバイトコンパイルする,  Up: Python言語サービス

5.32.10 ‘dis’ -- Python バイトコードの逆アセンブラー
----------------------------------------------------

'ソースコード:' Lib/dis.py(1)

__________________________________________________________________

*note dis: 30. モジュールは CPython *note バイトコード: 16c. を逆アセン
ブルすることでバイトコードの解析をサポートします。このモジュールが入力と
して受け取る CPython バイトコードはファイル ‘Include/opcode.h’ に定義さ
れており、 コンパイラとインタプリタが使用しています。

'CPython 実装の詳細:' バイトコードは CPython インタプリタの実装詳細です
。Python のバージョン間でバイトコードの追加や、削除、変更がないという保
証はありません。このモジュールを使用することによって Python の異なる VM
または異なるリリースの間で動作すると考えるべきではありません。

バージョン 3.6 で変更: 従来は使用されるバイト数は命令ごとに異なりました
が、このモジュールでは各々一つの命令につき2バイト使用することとなってい
ます。

バージョン 3.10 で変更: The argument of jump, exception handling and
loop instructions is now the instruction offset rather than the byte
offset.

バージョン 3.11 で変更: Some instructions are accompanied by one or more
inline cache entries, which take the form of *note CACHE: 6c4.
instructions.  These instructions are hidden by default, but can be
shown by passing ‘show_caches=True’ to any *note dis: 30. utility.
Furthermore, the interpreter now adapts the bytecode to specialize it
for different runtime conditions.  The adaptive bytecode can be shown by
passing ‘adaptive=True’.

バージョン 3.12 で変更: The argument of a jump is the offset of the
target instruction relative to the instruction that appears immediately
after the jump instruction's *note CACHE: 6c4. entries.

As a consequence, the presence of the *note CACHE: 6c4. instructions is
transparent for forward jumps but needs to be taken into account when
reasoning about backward jumps.

バージョン 3.13 で変更: 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.

Example: Given the function ‘myfunc()’:

     def myfunc(alist):
         return len(alist)

the following command can be used to display the disassembly of
‘myfunc()’:

     >>> dis.dis(myfunc)
       2           RESUME                   0

       3           LOAD_GLOBAL              1 (len + NULL)
                   LOAD_FAST                0 (alist)
                   CALL                     1
                   RETURN_VALUE

("2" は行番号です)。

* Menu:

* コマンドライン・インターフェース: コマンドライン・インターフェース<2>.
* バイトコード解析::
* 解析関数::
* Python バイトコード命令::
* 命令コードコレクション::

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/dis.py


File: python.info,  Node: コマンドライン・インターフェース<2>,  Next: バイトコード解析,  Up: dis --- Python バイトコードの逆アセンブラー

5.32.10.1 コマンドライン・インターフェース
..........................................

The *note dis: 30. module can be invoked as a script from the command
line:

     python -m dis [-h] [-C] [-O] [infile]

以下のオプションが使用できます:

 -- プログラムオプション: -h, --help

     使い方を表示して終了します。

 -- プログラムオプション: -C, --show-caches

     Show inline caches.

 -- プログラムオプション: -O, --show-offsets

     Show offsets of instructions.

If ‘infile’ is specified, its disassembled code will be written to
stdout.  Otherwise, disassembly is performed on compiled source code
received from stdin.


File: python.info,  Node: バイトコード解析,  Next: 解析関数,  Prev: コマンドライン・インターフェース<2>,  Up: dis --- Python バイトコードの逆アセンブラー

5.32.10.2 バイトコード解析
..........................

Added in version 3.4.

バイトコード解析の API を使うと、 Python のコード片を *note Bytecode:
efa. オブジェクトでラップでき、コンパイルされたコードの細かいところに簡
単にアクセスできます。

 -- クラス: dis.Bytecode (x, *, first_line=None, current_offset=None,
          show_caches=False, adaptive=False, show_offsets=False)

     関数、ジェネレータ、非同期ジェネレータ、コルーチン、メソッド、ソー
     スコード文字列、(*note compile(): 177. が返すような) コードオブジェ
     クトに対応するバイトコードを解析します。

     これは、下で並べられている関数の多くのものをまとめた便利なラッパー
     です。 とりわけ目立つのは *note get_instructions(): 1bd. で、 *note
     Bytecode: efa. インスタンスに対し反復処理をしながら、バイトコード命
     令を *note Instruction: 1be. インスタンスとして返します。

     'first_line' が ‘None’ でない場合は、それを逆アセンブルしたコードの
     ソースの最初の行に表示する行番号とします。 そうでない場合は、ソース
     の行の情報 (もしあれば) を逆アセンブルされたコードオブジェクトから
     直接取得します。

     'current_offset' が ‘None’ でない場合は、逆アセンブルされたコードで
     のあるインストラクションのオフセット位置を示します。 これを設定する
     と、 *note dis(): efb. の出力において、指定された命令コード
     (opcode) に "現在の命令 (instruction)" を表す印が表示されます。

     If 'show_caches' is ‘True’, *note dis(): efb. will display inline
     cache entries used by the interpreter to specialize the bytecode.

     If 'adaptive' is ‘True’, *note dis(): efb. will display specialized
     bytecode that may be different from the original bytecode.

     If 'show_offsets' is ‘True’, *note dis(): efb. will include
     instruction offsets in the output.

      -- メソッド: classmethod from_traceback (tb, *, show_caches=False)

          与えられたトレースバックから *note Bytecode: efa. インスタンス
          を構築し、 'current_offset' がその例外の原因となった命令となる
          よう設定します。

      -- データ: codeobj

          コンパイルされたコードオブジェクト。

      -- データ: first_line

          コードオブジェクトのソースの最初の行 (利用可能であれば)

      -- メソッド: dis ()

          バイトコード命令の整形された表示を返します (*note dis.dis():
          b02. と同じ出力になりますが、複数行文字列として返されます)。

      -- メソッド: info ()

          *note code_info(): 120a. のようなコードオブジェクトの詳細を含
          んだ整形された複数行文字列を返します。

     バージョン 3.7 で変更: This can now handle coroutine and
     asynchronous generator objects.

     バージョン 3.11 で変更: Added the 'show_caches' and 'adaptive'
     parameters.

例:

     >>> bytecode = dis.Bytecode(myfunc)
     >>> for instr in bytecode:
     ...     print(instr.opname)
     ...
     RESUME
     LOAD_GLOBAL
     LOAD_FAST
     CALL
     RETURN_VALUE


File: python.info,  Node: 解析関数,  Next: Python バイトコード命令,  Prev: バイトコード解析,  Up: dis --- Python バイトコードの逆アセンブラー

5.32.10.3 解析関数
..................

*note dis: 30. モジュールには、以下に挙げる入力を直接欲しい出力に変換す
る解析関数も定義してあります。 1つの命令だけが実行されている場合は、解析
オブジェクトをいったん作るよりはこちらの方が便利です:

 -- の関数: dis.code_info (x)

     渡された関数、ジェネレータ、非同期ジェネレータ、コルーチン、メソッ
     ド、ソースコード文字列、コードオブジェクトに対する、詳細なコードオ
     ブジェクトの情報を、整形された複数行の文字列として返します。

     この結果は実装に強く依存しており、Python VM や Python のバージョン
     によって異なることがあります。

     Added in version 3.2.

     バージョン 3.7 で変更: This can now handle coroutine and
     asynchronous generator objects.

 -- の関数: dis.show_code (x, *, file=None)

     渡された関数、メソッド、ソースコード文字列、コードオブジェクトに対
     する、詳細なコードオブジェクトの情報を、'file' (または 'file' が指
     定されていなければ ‘sys.stdout’) に表示します。

     これは、インタラクティブシェル上で使うことを想定した、
     ‘print(code_info(x), file=file)’ の便利なショートカットです。

     Added in version 3.2.

     バージョン 3.4 で変更: 'file' 引数が追加されました。

 -- の関数: dis.dis (x=None, *, file=None, depth=None,
          show_caches=False, adaptive=False)

     Disassemble the 'x' object.  'x' can denote either a module, a
     class, a method, a function, a generator, an asynchronous
     generator, a coroutine, a code object, a string of source code or a
     byte sequence of raw bytecode.  For a module, it disassembles all
     functions.  For a class, it disassembles all methods (including
     class and static methods).  For a code object or sequence of raw
     bytecode, it prints one line per bytecode instruction.  It also
     recursively disassembles nested code objects.  These can include
     generator expressions, nested functions, the bodies of nested
     classes, and the code objects used for *note annotation scopes:
     16d.  Strings are first compiled to code objects with the *note
     compile(): 177. built-in function before being disassembled.  If no
     object is provided, this function disassembles the last traceback.

     'file' 引数が渡された場合は、アセンブリをそこに書き込みます。 そう
     でない場合は ‘sys.stdout’ に出力します。

     The maximal depth of recursion is limited by 'depth' unless it is
     ‘None’.  ‘depth=0’ means no recursion.

     If 'show_caches' is ‘True’, this function will display inline cache
     entries used by the interpreter to specialize the bytecode.

     If 'adaptive' is ‘True’, this function will display specialized
     bytecode that may be different from the original bytecode.

     バージョン 3.4 で変更: 'file' 引数が追加されました。

     バージョン 3.7 で変更: Implemented recursive disassembling and
     added 'depth' parameter.

     バージョン 3.7 で変更: This can now handle coroutine and
     asynchronous generator objects.

     バージョン 3.11 で変更: Added the 'show_caches' and 'adaptive'
     parameters.

 -- の関数: distb(tb=None, *, file=None, show_caches=False,
          adaptive=False,

 -- の関数: show_offset=False)

     トレースバックのスタックの先頭の関数を逆アセンブルします。Noneが渡
     された場合は最後のトレースバックを使います。例外を引き起こした命令
     が表示されます。

     'file' 引数が渡された場合は、アセンブリをそこに書き込みます。 そう
     でない場合は ‘sys.stdout’ に出力します。

     バージョン 3.4 で変更: 'file' 引数が追加されました。

     バージョン 3.11 で変更: Added the 'show_caches' and 'adaptive'
     parameters.

     バージョン 3.13 で変更: Added the 'show_offsets' parameter.

 -- の関数: dis.disassemble (code, lasti=-1, *, file=None,
          show_caches=False, adaptive=False)

 -- の関数: disco(code, lasti=-1, *, file=None, show_caches=False,
          adaptive=False,

 -- の関数: show_offsets=False)

     コードオブジェクトを逆アセンブルします。'lasti' が与えられた場合は
     、最後の命令を示します。出力は次のようなカラムに分割されます:

       1. 各行の最初の命令に対する行番号。

       2. 現在の命令。 ‘-->’ として示されます。

       3. ラベル付けされた命令。 ‘>>’ とともに表示されます。

       4. 命令のアドレス。

       5. 命令コード名。

       6. 命令パラメタ。

       7. パラメタの解釈を括弧で囲んだもの。

     パラメタの解釈は、ローカル変数とグローバル変数の名前、定数の値、 分
     岐先、比較命令を認識します。

     'file' 引数が渡された場合は、アセンブリをそこに書き込みます。 そう
     でない場合は ‘sys.stdout’ に出力します。

     バージョン 3.4 で変更: 'file' 引数が追加されました。

     バージョン 3.11 で変更: Added the 'show_caches' and 'adaptive'
     parameters.

     バージョン 3.13 で変更: Added the 'show_offsets' parameter.

 -- の関数: dis.get_instructions (x, *, first_line=None,
          show_caches=False, adaptive=False)

     渡された関数、メソッド、ソースコード文字列、コードオブジェクトにあ
     る命令のイテレータを返します。

     イテレータは、与えられたコードの各命令の詳細情報を保持する名前付き
     タプル *note Instruction: 1be. からなる列を生成します。

     'first_line' が ‘None’ でない場合は、それを逆アセンブルしたコードの
     ソースの最初の行に表示する行番号とします。 そうでない場合は、ソース
     の行の情報 (もしあれば) を逆アセンブルされたコードオブジェクトから
     直接取得します。

     The 'adaptive' parameter works as it does in *note dis(): 30.

     Added in version 3.4.

     バージョン 3.11 で変更: Added the 'show_caches' and 'adaptive'
     parameters.

     バージョン 3.13 で変更: The 'show_caches' parameter is deprecated
     and has no effect.  The iterator generates the *note Instruction:
     1be. 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.

 -- の関数: dis.findlinestarts (code)

     This generator function uses the *note co_lines(): 2d2. method of
     the *note code object: 1b4. 'code' to find the offsets which are
     starts of lines in the source code.  They are generated as
     ‘(offset, lineno)’ pairs.

     バージョン 3.6 で変更: Line numbers can be decreasing.  Before,
     they were always increasing.

     バージョン 3.10 で変更: The PEP 626(1) *note co_lines(): 2d2.
     method is used instead of the *note co_firstlineno: 1ea3. and *note
     co_lnotab: 2c1. attributes of the *note code object: 1b4.

     バージョン 3.13 で変更: Line numbers can be ‘None’ for bytecode
     that does not map to source lines.

 -- の関数: dis.findlabels (code)

     Detect all offsets in the raw compiled bytecode string 'code' which
     are jump targets, and return a list of these offsets.

 -- の関数: dis.stack_effect (opcode, oparg=None, *, jump=None)

     'opcode' と引数 'oparg' がスタックに与える影響を計算します。

     If the code has a jump target and 'jump' is ‘True’, *note
     stack_effect(): efd. 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.

     Added in version 3.4.

     バージョン 3.8 で変更: Added 'jump' parameter.

     バージョン 3.13 で変更: 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.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0626/


File: python.info,  Node: Python バイトコード命令,  Next: 命令コードコレクション,  Prev: 解析関数,  Up: dis --- Python バイトコードの逆アセンブラー

5.32.10.4 Python バイトコード命令
.................................

*note get_instructions(): 1bd. 関数と *note Bytecode: efa. クラスはバイ
トコード命令の詳細を *note Instruction: 1be. インスタンスの形で提供しま
す:

 -- クラス: dis.Instruction

     バイトコード命令の詳細

      -- データ: opcode

          以下の命令コードの値と *note 命令コードコレクション: 457e. の
          バイトコードの値に対応する、命令の数値コードです。

      -- データ: opname

          人間が読むための命令名

      -- データ: baseopcode

          numeric code for the base operation if operation is
          specialized; otherwise equal to *note opcode: 457d.

      -- データ: baseopname

          human readable name for the base operation if operation is
          specialized; otherwise equal to *note opname: 4582.

      -- データ: arg

          (ある場合は) 命令の数値引数、無ければ ‘None’

      -- データ: oparg

          alias for *note arg: 4583.

      -- データ: argval

          resolved arg value (if any), otherwise ‘None’

      -- データ: argrepr

          human readable description of operation argument (if any),
          otherwise an empty string.

      -- データ: offset

          バイトコード列の中での命令の開始位置

      -- データ: start_offset

          start index of operation within bytecode sequence, including
          prefixed ‘EXTENDED_ARG’ operations if present; otherwise equal
          to *note offset: 4587.

      -- データ: cache_offset

          start index of the cache entries following the operation

      -- データ: end_offset

          end index of the cache entries following the operation

      -- データ: starts_line

          ‘True’ if this opcode starts a source line, otherwise ‘False’

      -- データ: line_number

          source line number associated with this opcode (if any),
          otherwise ‘None’

      -- データ: is_jump_target

          他のコードからここへジャンプする場合は ‘True’ 、そうでない場合
          は ‘False’

      -- データ: jump_target

          bytecode index of the jump target if this is a jump operation,
          otherwise ‘None’

      -- データ: positions

          *note dis.Positions: 4313. object holding the start and end
          locations that are covered by this instruction.

     Added in version 3.4.

     バージョン 3.11 で変更: Field ‘positions’ is added.

     バージョン 3.13 で変更: Changed field ‘starts_line’.

     Added fields ‘start_offset’, ‘cache_offset’, ‘end_offset’,
     ‘baseopname’, ‘baseopcode’, ‘jump_target’, ‘oparg’, ‘line_number’
     and ‘cache_info’.

 -- クラス: dis.Positions

     In case the information is not available, some fields might be
     ‘None’.

      -- データ: lineno

      -- データ: end_lineno

      -- データ: col_offset

      -- データ: end_col_offset

     Added in version 3.11.

現在 Python コンパイラは次のバイトコード命令を生成します。

'一般的な命令'

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.

 -- Opcode: NOP

     Do nothing code.  Used as a placeholder by the bytecode optimizer,
     and to generate line tracing events.

 -- Opcode: POP_TOP

     Removes the top-of-stack item:

          STACK.pop()

 -- Opcode: END_FOR

     Removes the top-of-stack item.  Equivalent to ‘POP_TOP’.  Used to
     clean up at the end of loops, hence the name.

     Added in version 3.12.

 -- Opcode: END_SEND

     Implements ‘del STACK[-2]’.  Used to clean up when a generator
     exits.

     Added in version 3.12.

 -- Opcode: COPY (i)

     Push the i-th item to the top of the stack without removing it from
     its original location:

          assert i > 0
          STACK.append(STACK[-i])

     Added in version 3.11.

 -- Opcode: SWAP (i)

     Swap the top of the stack with the i-th element:

          STACK[-i], STACK[-1] = STACK[-1], STACK[-i]

     Added in version 3.11.

 -- Opcode: CACHE

     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’.

     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.

     Populated caches can look like arbitrary instructions, so great
     care should be taken when reading or modifying raw, adaptive
     bytecode containing quickened data.

     Added in version 3.11.

'1オペランド命令'

1オペランド命令はスタックの先頭を取り出して操作を適用し、結果をスタック
へプッシュし戻します。

 -- Opcode: UNARY_NEGATIVE

     Implements ‘STACK[-1] = -STACK[-1]’.

 -- Opcode: UNARY_NOT

     Implements ‘STACK[-1] = not STACK[-1]’.

     バージョン 3.13 で変更: This instruction now requires an exact
     *note bool: 434. operand.

 -- Opcode: UNARY_INVERT

     Implements ‘STACK[-1] = ~STACK[-1]’.

 -- Opcode: GET_ITER

     Implements ‘STACK[-1] = iter(STACK[-1])’.

 -- Opcode: GET_YIELD_FROM_ITER

     If ‘STACK[-1]’ is a *note generator iterator: bac. or *note
     coroutine: 45e. object it is left as is.  Otherwise, implements
     ‘STACK[-1] = iter(STACK[-1])’.

     Added in version 3.5.

 -- Opcode: TO_BOOL

     Implements ‘STACK[-1] = bool(STACK[-1])’.

     Added in version 3.13.

'Binary and in-place operations'

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.

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]’.

 -- Opcode: BINARY_OP (op)

     Implements the binary and in-place operators (depending on the
     value of 'op'):

          rhs = STACK.pop()
          lhs = STACK.pop()
          STACK.append(lhs op rhs)

     Added in version 3.11.

 -- Opcode: BINARY_SUBSCR

     Implements:

          key = STACK.pop()
          container = STACK.pop()
          STACK.append(container[key])

 -- Opcode: STORE_SUBSCR

     Implements:

          key = STACK.pop()
          container = STACK.pop()
          value = STACK.pop()
          container[key] = value

 -- Opcode: DELETE_SUBSCR

     Implements:

          key = STACK.pop()
          container = STACK.pop()
          del container[key]

 -- Opcode: BINARY_SLICE

     Implements:

          end = STACK.pop()
          start = STACK.pop()
          container = STACK.pop()
          STACK.append(container[start:end])

     Added in version 3.12.

 -- Opcode: STORE_SLICE

     Implements:

          end = STACK.pop()
          start = STACK.pop()
          container = STACK.pop()
          values = STACK.pop()
          container[start:end] = value

     Added in version 3.12.

'コルーチン命令コード'

 -- Opcode: GET_AWAITABLE (where)

     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 *note CO_ITERABLE_COROUTINE: 4324. flag,
     or resolves ‘o.__await__’.

          If the ‘where’ operand is nonzero, it indicates where the
          instruction occurs:

             * ‘1’: After a call to ‘__aenter__’

             * ‘2’: After a call to ‘__aexit__’

     Added in version 3.5.

     バージョン 3.11 で変更: Previously, this instruction did not have
     an oparg.

 -- Opcode: GET_AITER

     Implements ‘STACK[-1] = STACK[-1].__aiter__()’.

     Added in version 3.5.

     バージョン 3.7 で変更: Returning awaitable objects from ‘__aiter__’
     is no longer supported.

 -- Opcode: GET_ANEXT

     Implement ‘STACK.append(get_awaitable(STACK[-1].__anext__()))’ to
     the stack.  See ‘GET_AWAITABLE’ for details about ‘get_awaitable’.

     Added in version 3.5.

 -- Opcode: END_ASYNC_FOR

     Terminates an *note async for: a79. 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 *note StopAsyncIteration:
     1998, it is re-raised.

     Added in version 3.8.

     バージョン 3.11 で変更: Exception representation on the stack now
     consist of one, not three, items.

 -- Opcode: CLEANUP_THROW

     Handles an exception raised during a *note throw(): 4c5. or *note
     close(): 1659. call through the current frame.  If ‘STACK[-1]’ is
     an instance of *note StopIteration: bc8, pop three values from the
     stack and push its ‘value’ member.  Otherwise, re-raise
     ‘STACK[-1]’.

     Added in version 3.12.

 -- Opcode: BEFORE_ASYNC_WITH

     Resolves ‘__aenter__’ and ‘__aexit__’ from ‘STACK[-1]’.  Pushes
     ‘__aexit__’ and result of ‘__aenter__()’ to the stack:

          STACK.extend((__aexit__, __aenter__())

     Added in version 3.5.

'その他の命令コード'

 -- Opcode: SET_ADD (i)

     Implements:

          item = STACK.pop()
          set.add(STACK[-i], item)

     Used to implement set comprehensions.

 -- Opcode: LIST_APPEND (i)

     Implements:

          item = STACK.pop()
          list.append(STACK[-i], item)

     Used to implement list comprehensions.

 -- Opcode: MAP_ADD (i)

     Implements:

          value = STACK.pop()
          key = STACK.pop()
          dict.__setitem__(STACK[-i], key, value)

     Used to implement dict comprehensions.

     Added in version 3.1.

     バージョン 3.8 で変更: Map value is ‘STACK[-1]’ and map key is
     ‘STACK[-2]’.  Before, those were reversed.

*note SET_ADD: 45a0, *note LIST_APPEND: 45a1, *note MAP_ADD: a7a. は、追
加した値または key/value ペアをスタックから取り除きますが、コンテナオブ
ジェクトはループの次のイテレーションで利用できるようにスタックに残してお
きます。

 -- Opcode: RETURN_VALUE

     Returns with ‘STACK[-1]’ to the caller of the function.

 -- Opcode: RETURN_CONST (consti)

     Returns with ‘co_consts[consti]’ to the caller of the function.

     Added in version 3.12.

 -- Opcode: YIELD_VALUE

     Yields ‘STACK.pop()’ from a *note generator: 1035.

     バージョン 3.11 で変更: oparg set to be the stack depth.

     バージョン 3.12 で変更: oparg set to be the exception block depth,
     for efficient closing of generators.

     バージョン 3.13 で変更: oparg is ‘1’ if this instruction is part of
     a yield-from or await, and ‘0’ otherwise.

 -- Opcode: SETUP_ANNOTATIONS

     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 *note variable annotations: d23.
     statically.

     Added in version 3.6.

 -- Opcode: POP_EXCEPT

     Pops a value from the stack, which is used to restore the exception
     state.

     バージョン 3.11 で変更: Exception representation on the stack now
     consist of one, not three, items.

 -- Opcode: RERAISE

     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 *note f_lasti: 855. of the current frame.

     Added in version 3.9.

     バージョン 3.11 で変更: Exception representation on the stack now
     consist of one, not three, items.

 -- Opcode: PUSH_EXC_INFO

     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.

     Added in version 3.11.

 -- Opcode: CHECK_EXC_MATCH

     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.

     Added in version 3.11.

 -- Opcode: CHECK_EG_MATCH

     Performs exception matching for ‘except*’.  Applies
     ‘split(STACK[-1])’ on the exception group representing ‘STACK[-2]’.

     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’.

     Added in version 3.11.

 -- Opcode: WITH_EXCEPT_START

     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 *note with: 59c. statement.

     Added in version 3.9.

     バージョン 3.11 で変更: 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.

 -- Opcode: LOAD_ASSERTION_ERROR

     Pushes *note AssertionError: 675. onto the stack.  Used by the
     *note assert: 936. statement.

     Added in version 3.9.

 -- Opcode: LOAD_BUILD_CLASS

     Pushes ‘builtins.__build_class__()’ onto the stack.  It is later
     called to construct a class.

 -- Opcode: BEFORE_WITH

     This opcode performs several operations before a with block starts.
     First, it loads *note __exit__(): 12ce. from the context manager
     and pushes it onto the stack for later use by *note
     WITH_EXCEPT_START: 45a4.  Then, *note __enter__(): 592. is called.
     Finally, the result of calling the ‘__enter__()’ method is pushed
     onto the stack.

     Added in version 3.11.

 -- Opcode: GET_LEN

     Perform ‘STACK.append(len(STACK[-1]))’.  Used in *note match: 7d8.
     statements where comparison with structure of pattern is needed.

     Added in version 3.10.

 -- Opcode: MATCH_MAPPING

     If ‘STACK[-1]’ is an instance of *note collections.abc.Mapping:
     898. (or, more technically: if it has the *note Py_TPFLAGS_MAPPING:
     180e. flag set in its *note tp_flags: 1828.), push ‘True’ onto the
     stack.  Otherwise, push ‘False’.

     Added in version 3.10.

 -- Opcode: MATCH_SEQUENCE

     If ‘STACK[-1]’ is an instance of *note collections.abc.Sequence:
     1194. and is 'not' an instance of *note str: 418./*note bytes:
     1a4./*note bytearray: 508. (or, more technically: if it has the
     *note Py_TPFLAGS_SEQUENCE: 180f. flag set in its *note tp_flags:
     1828.), push ‘True’ onto the stack.  Otherwise, push ‘False’.

     Added in version 3.10.

 -- Opcode: MATCH_KEYS

     ‘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 *note tuple: 349. containing the corresponding
     values.  Otherwise, push ‘None’.

     Added in version 3.10.

     バージョン 3.11 で変更: Previously, this instruction also pushed a
     boolean value indicating success (‘True’) or failure (‘False’).

 -- Opcode: STORE_NAME (namei)

     Implements ‘name = STACK.pop()’.  'namei' is the index of 'name' in
     the attribute *note co_names: 1ea2. of the *note code object: 1b4.
     The compiler tries to use *note STORE_FAST: 1656. or *note
     STORE_GLOBAL: 45aa. if possible.

 -- Opcode: DELETE_NAME (namei)

     Implements ‘del name’, where 'namei' is the index into *note
     co_names: 1ea2. attribute of the *note code object: 1b4.

 -- Opcode: UNPACK_SEQUENCE (count)

     Unpacks ‘STACK[-1]’ into 'count' individual values, which are put
     onto the stack right-to-left.  Require there to be exactly 'count'
     values.:

          assert(len(STACK[-1]) == count)
          STACK.extend(STACK.pop()[:-count-1:-1])

 -- Opcode: UNPACK_EX (counts)

     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.

     The number of values before and after the list value is limited to
     255.

     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 ‘EXTENDED_ARG’.  As a consequence, the argument
     can be seen as a two bytes 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.

     The extracted values are put onto the stack right-to-left, i.e.
     ‘a, *b, c = d’ will be stored after execution as ‘STACK.extend((a,
     b, c))’.

 -- Opcode: STORE_ATTR (namei)

     Implements:

          obj = STACK.pop()
          value = STACK.pop()
          obj.name = value

     where 'namei' is the index of name in *note co_names: 1ea2. of the
     *note code object: 1b4.

 -- Opcode: DELETE_ATTR (namei)

     Implements:

          obj = STACK.pop()
          del obj.name

     where 'namei' is the index of name into *note co_names: 1ea2. of
     the *note code object: 1b4.

 -- Opcode: STORE_GLOBAL (namei)

     *note STORE_NAME: 45a9. と同じように動作しますが、 name をグローバ
     ルとして保存します。

 -- Opcode: DELETE_GLOBAL (namei)

     *note DELETE_NAME: 45ab. と同じように動作しますが、グローバルの
     name を削除します。

 -- Opcode: LOAD_CONST (consti)

     ‘co_consts[consti]’ をスタックにプッシュします。

 -- Opcode: LOAD_NAME (namei)

     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.

 -- Opcode: LOAD_LOCALS

     Pushes a reference to the locals dictionary onto the stack.  This
     is used to prepare namespace dictionaries for *note
     LOAD_FROM_DICT_OR_DEREF: 4b3. and *note LOAD_FROM_DICT_OR_GLOBALS:
     4b4.

     Added in version 3.12.

 -- Opcode: LOAD_FROM_DICT_OR_GLOBALS (i)

     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 builtins, similar to *note LOAD_GLOBAL:
     164f.  This is used for loading global variables in *note
     annotation scopes: 16d. within class bodies.

     Added in version 3.12.

 -- Opcode: BUILD_TUPLE (count)

     Creates a tuple consuming 'count' items from the stack, and pushes
     the resulting tuple onto the stack:

          if count == 0:
              value = ()
          else:
              value = tuple(STACK[-count:])
              STACK = STACK[:-count]

          STACK.append(value)

 -- Opcode: BUILD_LIST (count)

     *note BUILD_TUPLE: 45b1. と同じように動作しますが、この命令はリスト
     を作り出します。

 -- Opcode: BUILD_SET (count)

     *note BUILD_TUPLE: 45b1. と同じように動作しますが、この命令は set を
     作り出します。

 -- Opcode: BUILD_MAP (count)

     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]}’.

     バージョン 3.5 で変更: The dictionary is created from stack items
     instead of creating an empty dictionary pre-sized to hold 'count'
     items.

 -- Opcode: BUILD_CONST_KEY_MAP (count)

     The version of *note BUILD_MAP: 1648. specialized for constant
     keys.  Pops the top element on the stack which contains a tuple of
     keys, then starting from ‘STACK[-2]’, pops 'count' values to form
     values in the built dictionary.

     Added in version 3.6.

 -- Opcode: BUILD_STRING (count)

     Concatenates 'count' strings from the stack and pushes the
     resulting string onto the stack.

     Added in version 3.6.

 -- Opcode: LIST_EXTEND (i)

     Implements:

          seq = STACK.pop()
          list.extend(STACK[-i], seq)

     Used to build lists.

     Added in version 3.9.

 -- Opcode: SET_UPDATE (i)

     Implements:

          seq = STACK.pop()
          set.update(STACK[-i], seq)

     Used to build sets.

     Added in version 3.9.

 -- Opcode: DICT_UPDATE (i)

     Implements:

          map = STACK.pop()
          dict.update(STACK[-i], map)

     Used to build dicts.

     Added in version 3.9.

 -- Opcode: DICT_MERGE (i)

     Like *note DICT_UPDATE: 45b6. but raises an exception for duplicate
     keys.

     Added in version 3.9.

 -- Opcode: LOAD_ATTR (namei)

     If the low bit of ‘namei’ is not set, this replaces ‘STACK[-1]’
     with ‘getattr(STACK[-1], co_names[namei>>1])’.

     If the low bit of ‘namei’ is set, this will attempt to load a
     method named ‘co_names[namei>>1]’ from the ‘STACK[-1]’ object.
     ‘STACK[-1]’ is popped.  This bytecode distinguishes two cases: if
     ‘STACK[-1]’ has a method with the correct name, the bytecode pushes
     the unbound method and ‘STACK[-1]’.  ‘STACK[-1]’ will be used as
     the first argument (‘self’) by *note CALL: 6d2. or *note CALL_KW:
     1649. when calling the unbound method.  Otherwise, ‘NULL’ and the
     object returned by the attribute lookup are pushed.

     バージョン 3.12 で変更: 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.

 -- Opcode: LOAD_SUPER_ATTR (namei)

     This opcode implements *note super(): 4a8, both in its
     zero-argument and two-argument forms (e.g.  ‘super().method()’,
     ‘super().attr’ and ‘super(cls, self).method()’, ‘super(cls,
     self).attr’).

     It pops three values from the stack (from top of stack down):

        * ‘self’: the first argument to the current method

        * ‘cls’: the class within which the current method was defined

        * the global ‘super’

     With respect to its argument, it works similarly to *note
     LOAD_ATTR: 4ab, except that ‘namei’ is shifted left by 2 bits
     instead of 1.

     The low bit of ‘namei’ signals to attempt a method load, as with
     *note LOAD_ATTR: 4ab, which results in pushing ‘NULL’ and the
     loaded method.  When it is unset a single value is pushed to the
     stack.

     The second-low bit of ‘namei’, if set, means that this was a
     two-argument call to *note super(): 4a8. (unset means
     zero-argument).

     Added in version 3.12.

 -- Opcode: COMPARE_OP (opname)

     Performs a Boolean operation.  The operation name can be found in
     ‘cmp_op[opname >> 5]’.  If the fifth-lowest bit of ‘opname’ is set
     (‘opname & 16’), the result should be coerced to ‘bool’.

     バージョン 3.13 で変更: The fifth-lowest bit of the oparg now
     indicates a forced conversion to *note bool: 434.

 -- Opcode: IS_OP (invert)

     Performs ‘is’ comparison, or ‘is not’ if ‘invert’ is 1.

     Added in version 3.9.

 -- Opcode: CONTAINS_OP (invert)

     Performs ‘in’ comparison, or ‘not in’ if ‘invert’ is 1.

     Added in version 3.9.

 -- Opcode: IMPORT_NAME (namei)

     Imports the module ‘co_names[namei]’.  ‘STACK[-1]’ and ‘STACK[-2]’
     are popped and provide the 'fromlist' and 'level' arguments of
     *note __import__(): 8a2.  The module object is pushed onto the
     stack.  The current namespace is not affected: for a proper import
     statement, a subsequent *note STORE_FAST: 1656. instruction
     modifies the namespace.

 -- Opcode: IMPORT_FROM (namei)

     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 *note STORE_FAST: 1656. instruction.

 -- Opcode: JUMP_FORWARD (delta)

     バイトコードカウンタを 'delta' だけ増加させます。

 -- Opcode: JUMP_BACKWARD (delta)

     Decrements bytecode counter by 'delta'.  Checks for interrupts.

     Added in version 3.11.

 -- Opcode: JUMP_BACKWARD_NO_INTERRUPT (delta)

     Decrements bytecode counter by 'delta'.  Does not check for
     interrupts.

     Added in version 3.11.

 -- Opcode: POP_JUMP_IF_TRUE (delta)

     If ‘STACK[-1]’ is true, increments the bytecode counter by 'delta'.
     ‘STACK[-1]’ is popped.

     バージョン 3.11 で変更: 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).

     バージョン 3.12 で変更: This is no longer a pseudo-instruction.

     バージョン 3.13 で変更: This instruction now requires an exact
     *note bool: 434. operand.

 -- Opcode: POP_JUMP_IF_FALSE (delta)

     If ‘STACK[-1]’ is false, increments the bytecode counter by
     'delta'.  ‘STACK[-1]’ is popped.

     バージョン 3.11 で変更: 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).

     バージョン 3.12 で変更: This is no longer a pseudo-instruction.

     バージョン 3.13 で変更: This instruction now requires an exact
     *note bool: 434. operand.

 -- Opcode: POP_JUMP_IF_NOT_NONE (delta)

     If ‘STACK[-1]’ is not ‘None’, increments the bytecode counter by
     'delta'.  ‘STACK[-1]’ is popped.

     This opcode is a pseudo-instruction, replaced in final bytecode by
     the directed versions (forward/backward).

     Added in version 3.11.

     バージョン 3.12 で変更: This is no longer a pseudo-instruction.

 -- Opcode: POP_JUMP_IF_NONE (delta)

     If ‘STACK[-1]’ is ‘None’, increments the bytecode counter by
     'delta'.  ‘STACK[-1]’ is popped.

     This opcode is a pseudo-instruction, replaced in final bytecode by
     the directed versions (forward/backward).

     Added in version 3.11.

     バージョン 3.12 で変更: This is no longer a pseudo-instruction.

 -- Opcode: FOR_ITER (delta)

     ‘STACK[-1]’ is an *note iterator: 191.  Call its *note __next__():
     129b. method.  If this yields a new value, push it on the stack
     (leaving the iterator below it).  If the iterator indicates it is
     exhausted then the byte code counter is incremented by 'delta'.

     バージョン 3.12 で変更: Up until 3.11 the iterator was popped when
     it was exhausted.

 -- Opcode: LOAD_GLOBAL (namei)

     ‘co_names[namei>>1]’ という名前のグローバルをスタック上にロードしま
     す。

     バージョン 3.11 で変更: If the low bit of ‘namei’ is set, then a
     ‘NULL’ is pushed to the stack before the global variable.

 -- Opcode: LOAD_FAST (var_num)

     ローカルな ‘co_varnames[var_num]’ への参照をスタックにプッシュしま
     す。

     バージョン 3.12 で変更: This opcode is now only used in situations
     where the local variable is guaranteed to be initialized.  It
     cannot raise *note UnboundLocalError: 14df.

 -- Opcode: LOAD_FAST_CHECK (var_num)

     Pushes a reference to the local ‘co_varnames[var_num]’ onto the
     stack, raising an *note UnboundLocalError: 14df. if the local
     variable has not been initialized.

     Added in version 3.12.

 -- Opcode: LOAD_FAST_AND_CLEAR (var_num)

     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’.

     Added in version 3.12.

 -- Opcode: STORE_FAST (var_num)

     Stores ‘STACK.pop()’ into the local ‘co_varnames[var_num]’.

 -- Opcode: DELETE_FAST (var_num)

     ローカルな ‘co_varnames[var_num]’ を削除します。

 -- Opcode: MAKE_CELL (i)

     Creates a new cell in slot ‘i’.  If that slot is nonempty then that
     value is stored into the new cell.

     Added in version 3.11.

 -- Opcode: LOAD_DEREF (i)

     Loads the cell contained in slot ‘i’ of the "fast locals" storage.
     Pushes a reference to the object the cell contains on the stack.

     バージョン 3.11 で変更: ‘i’ is no longer offset by the length of
     *note co_varnames: 1e9c.

 -- Opcode: LOAD_FROM_DICT_OR_DEREF (i)

     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 found there, loads it from the cell contained in slot ‘i’,
     similar to *note LOAD_DEREF: 45be.  This is used for loading *note
     closure variables: 1e9f. in class bodies (which previously used
     ‘LOAD_CLASSDEREF’) and in *note annotation scopes: 16d. within
     class bodies.

     Added in version 3.12.

 -- Opcode: STORE_DEREF (i)

     Stores ‘STACK.pop()’ into the cell contained in slot ‘i’ of the
     "fast locals" storage.

     バージョン 3.11 で変更: ‘i’ is no longer offset by the length of
     *note co_varnames: 1e9c.

 -- Opcode: DELETE_DEREF (i)

     Empties the cell contained in slot ‘i’ of the "fast locals"
     storage.  Used by the *note del: 1711. statement.

     Added in version 3.2.

     バージョン 3.11 で変更: ‘i’ is no longer offset by the length of
     *note co_varnames: 1e9c.

 -- Opcode: COPY_FREE_VARS (n)

     Copies the ‘n’ *note free (closure) variables: 1e9f. from the
     closure into the frame.  Removes the need for special code on the
     caller's side when calling closures.

     Added in version 3.11.

 -- Opcode: RAISE_VARARGS (argc)

     Raises an exception using one of the 3 forms of the ‘raise’
     statement, depending on the value of 'argc':

        * 0: ‘raise’ (re-raise previous exception)

        * 1: ‘raise STACK[-1]’ (raise exception instance or type at
          ‘STACK[-1]’)

        * 2: ‘raise STACK[-2] from STACK[-1]’ (raise exception instance
          or type at ‘STACK[-2]’ with ‘__cause__’ set to ‘STACK[-1]’)

 -- Opcode: CALL (argc)

     Calls a callable object with the number of arguments specified by
     ‘argc’.  On the stack are (in ascending order):

        * The callable

        * ‘self’ or ‘NULL’

        * The remaining positional arguments

     ‘argc’ is the total of the positional arguments, excluding ‘self’.

     ‘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.

     Added in version 3.11.

     バージョン 3.13 で変更: The callable now always appears at the same
     position on the stack.

     バージョン 3.13 で変更: Calls with keyword arguments are now
     handled by *note CALL_KW: 1649.

 -- Opcode: CALL_KW (argc)

     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):

        * The callable

        * ‘self’ or ‘NULL’

        * The remaining positional arguments

        * The named arguments

        * A *note tuple: 349. of keyword argument names

     ‘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.

     ‘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.

     Added in version 3.13.

 -- Opcode: CALL_FUNCTION_EX (flags)

     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 contains a mapping object containing additional keyword
     arguments.  Before the callable is called, the mapping object and
     iterable object are each "unpacked" and their contents passed in as
     keyword and positional arguments respectively.  ‘CALL_FUNCTION_EX’
     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.

     Added in version 3.6.

 -- Opcode: PUSH_NULL

     Pushes a ‘NULL’ to the stack.  Used in the call sequence to match
     the ‘NULL’ pushed by *note LOAD_METHOD: bed. for non-method calls.

     Added in version 3.11.

 -- Opcode: MAKE_FUNCTION

     Pushes a new function object on the stack built from the code
     object at ‘STACK[-1]’.

     バージョン 3.10 で変更: Flag value ‘0x04’ is a tuple of strings
     instead of dictionary

     バージョン 3.11 で変更: Qualified name at ‘STACK[-1]’ was removed.

     バージョン 3.13 で変更: Extra function attributes on the stack,
     signaled by oparg flags, were removed.  They now use *note
     SET_FUNCTION_ATTRIBUTE: 45c2.

 -- Opcode: SET_FUNCTION_ATTRIBUTE (flag)

     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:

        * ‘0x01’ a tuple of default values for positional-only and
          positional-or-keyword parameters in positional order

        * ‘0x02’ a dictionary of keyword-only parameters' default values

        * ‘0x04’ a tuple of strings containing parameters' annotations

        * ‘0x08’ a tuple containing cells for free variables, making a
          closure

     Added in version 3.13.

 -- Opcode: BUILD_SLICE (argc)

     Pushes a slice object on the stack.  'argc' must be 2 or 3.  If it
     is 2, implements:

          end = STACK.pop()
          start = STACK.pop()
          STACK.append(slice(start, end))

     if it is 3, implements:

          step = STACK.pop()
          end = STACK.pop()
          start = STACK.pop()
          STACK.append(slice(start, end, step))

     See the *note slice(): 436. built-in function for more information.

 -- Opcode: EXTENDED_ARG (ext)

     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.

 -- Opcode: CONVERT_VALUE (oparg)

     Convert value to a string, depending on ‘oparg’:

          value = STACK.pop()
          result = func(value)
          STACK.append(result)

        * ‘oparg == 1’: call *note str(): 418. on 'value'

        * ‘oparg == 2’: call *note repr(): 7c8. on 'value'

        * ‘oparg == 3’: call *note ascii(): 138e. on 'value'

     Used for implementing formatted literal strings (f-strings).

     Added in version 3.13.

 -- Opcode: FORMAT_SIMPLE

     Formats the value on top of stack:

          value = STACK.pop()
          result = value.__format__("")
          STACK.append(result)

     Used for implementing formatted literal strings (f-strings).

     Added in version 3.13.

 -- Opcode: FORMAT_WITH_SPEC

     Formats the given value with the given format spec:

          spec = STACK.pop()
          value = STACK.pop()
          result = value.__format__(spec)
          STACK.append(result)

     Used for implementing formatted literal strings (f-strings).

     Added in version 3.13.

 -- Opcode: MATCH_CLASS (count)

     ‘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.

     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’.

     Added in version 3.10.

     バージョン 3.11 で変更: Previously, this instruction also pushed a
     boolean value indicating success (‘True’) or failure (‘False’).

 -- Opcode: RESUME (context)

     A no-op.  Performs internal tracing, debugging and optimization
     checks.

     The ‘context’ oparand consists of two parts.  The lowest two bits
     indicate where the ‘RESUME’ occurs:

        * ‘0’ The start of a function, which is neither a generator,
          coroutine nor an async generator

        * ‘1’ After a ‘yield’ expression

        * ‘2’ After a ‘yield from’ expression

        * ‘3’ After an ‘await’ expression

     The next bit is ‘1’ if the RESUME is at except-depth ‘1’, and ‘0’
     otherwise.

     Added in version 3.11.

     バージョン 3.13 で変更: The oparg value changed to include
     information about except-depth

 -- Opcode: RETURN_GENERATOR

     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.

     Added in version 3.11.

 -- Opcode: SEND (delta)

     Equivalent to ‘STACK[-1] = STACK[-2].send(STACK[-1])’.  Used in
     ‘yield from’ and ‘await’ statements.

     If the call raises *note StopIteration: bc8, pop the top value from
     the stack, push the exception's ‘value’ attribute, and increment
     the bytecode counter by 'delta'.

     Added in version 3.11.

 -- Opcode: HAVE_ARGUMENT

     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).

     If your application uses pseudo instructions or specialized
     instructions, use the *note hasarg: 27e. collection instead.

     バージョン 3.6 で変更: Now every instruction has an argument, but
     opcodes ‘< HAVE_ARGUMENT’ ignore it.  Before, only opcodes ‘>=
     HAVE_ARGUMENT’ had an argument.

     バージョン 3.12 で変更: Pseudo instructions were added to the *note
     dis: 30. module, and for them it is not true that comparison with
     ‘HAVE_ARGUMENT’ indicates whether they use their arg.

     バージョン 3.13 で非推奨: Use *note hasarg: 27e. instead.

 -- Opcode: CALL_INTRINSIC_1

     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.

     The operand determines which intrinsic function is called:

     Operand                                 説明
                                             
     --------------------------------------------------------------------------------
                                             
     ‘INTRINSIC_1_INVALID’                   Not valid
                                             
                                             
     ‘INTRINSIC_PRINT’                       Prints the argument to standard out.
                                             Used in the REPL.
                                             
                                             
     ‘INTRINSIC_IMPORT_STAR’                 Performs ‘import *’ for the named
                                             module.
                                             
                                             
     ‘INTRINSIC_STOPITERATION_ERROR’         Extracts the return value from a
                                             ‘StopIteration’ exception.
                                             
                                             
     ‘INTRINSIC_ASYNC_GEN_WRAP’              Wraps an async generator value
                                             
                                             
     ‘INTRINSIC_UNARY_POSITIVE’              Performs the unary ‘+’ operation
                                             
                                             
     ‘INTRINSIC_LIST_TO_TUPLE’               Converts a list to a tuple
                                             
                                             
     ‘INTRINSIC_TYPEVAR’                     Creates a *note typing.TypeVar: 143.
                                             
                                             
     ‘INTRINSIC_PARAMSPEC’                   Creates a
                                             *note typing.ParamSpec: 144.
                                             
                                             
     ‘INTRINSIC_TYPEVARTUPLE’                Creates a
                                             *note typing.TypeVarTuple: 145.
                                             
                                             
     ‘INTRINSIC_SUBSCRIPT_GENERIC’           Returns *note typing.Generic: 157c.
                                             subscripted with the argument
                                             
                                             
     ‘INTRINSIC_TYPEALIAS’                   Creates a
                                             *note typing.TypeAliasType: 421.;
                                             used in the *note type: 404.
                                             statement.  The argument is a tuple
                                             of the type alias's name, type
                                             parameters, and value.
                                             

     Added in version 3.12.

 -- Opcode: CALL_INTRINSIC_2

     Calls an intrinsic function with two arguments.  Used to implement
     functionality that is not performance critical:

          arg2 = STACK.pop()
          arg1 = STACK.pop()
          result = intrinsic2(arg1, arg2)
          STACK.append(result)

     The operand determines which intrinsic function is called:

     Operand                                      説明
                                                  
     -------------------------------------------------------------------------------------
                                                  
     ‘INTRINSIC_2_INVALID’                        Not valid
                                                  
                                                  
     ‘INTRINSIC_PREP_RERAISE_STAR’                Calculates the
                                                  *note ExceptionGroup: 19b. to raise
                                                  from a ‘try-except*’.
                                                  
                                                  
     ‘INTRINSIC_TYPEVAR_WITH_BOUND’               Creates a *note typing.TypeVar: 143.
                                                  with a bound.
                                                  
                                                  
     ‘INTRINSIC_TYPEVAR_WITH_CONSTRAINTS’         Creates a *note typing.TypeVar: 143.
                                                  with constraints.
                                                  
                                                  
     ‘INTRINSIC_SET_FUNCTION_TYPE_PARAMS’         Sets the ‘__type_params__’ attribute
                                                  of a function.
                                                  

     Added in version 3.12.

'Pseudo-instructions'

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.

 -- Opcode: SETUP_FINALLY (target)

     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’.

 -- Opcode: SETUP_CLEANUP (target)

     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 an exception occurs, the value stack level and the
     last instruction on the frame are restored to their current state,
     and control is transferred to the exception handler at ‘target’.

 -- Opcode: SETUP_WITH (target)

     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’.

     This variant is used in *note with: 59c. and *note async with: 59f.
     constructs, which push the return value of the context manager's
     *note __enter__(): 592. or *note __aenter__(): 1f30. to the stack.

 -- Opcode: POP_BLOCK

     Marks the end of the code block associated with the last
     ‘SETUP_FINALLY’, ‘SETUP_CLEANUP’ or ‘SETUP_WITH’.

 -- Opcode: JUMP

 -- Opcode: JUMP_NO_INTERRUPT

     Undirected relative jump instructions which are replaced by their
     directed (forward/backward) counterparts by the assembler.

 -- Opcode: LOAD_CLOSURE (i)

     Pushes a reference to the cell contained in slot ‘i’ of the "fast
     locals" storage.

     Note that ‘LOAD_CLOSURE’ is replaced with ‘LOAD_FAST’ in the
     assembler.

     バージョン 3.13 で変更: This opcode is now a pseudo-instruction.

 -- Opcode: LOAD_METHOD

     Optimized unbound method lookup.  Emitted as a ‘LOAD_ATTR’ opcode
     with a flag set in the arg.


File: python.info,  Node: 命令コードコレクション,  Prev: Python バイトコード命令,  Up: dis --- Python バイトコードの逆アセンブラー

5.32.10.5 命令コードコレクション
................................

これらのコレクションは、自動でバイトコード命令を解析するために提供されて
います:

バージョン 3.12 で変更: The collections now contain pseudo instructions
and instrumented instructions as well.  These are opcodes with values
‘>= MIN_PSEUDO_OPCODE’ and ‘>= MIN_INSTRUMENTED_OPCODE’.

 -- データ: dis.opname

     命令コード名のリスト。 バイトコードをインデックスに使って参照できま
     す。

 -- データ: dis.opmap

     命令コード名をバイトコードに対応づける辞書。

 -- データ: dis.cmp_op

     すべての比較命令の名前のリスト。

 -- データ: dis.hasarg

     Sequence of bytecodes that use their argument.

     Added in version 3.12.

 -- データ: dis.hasconst

     定数にアクセスするバイトコードのリスト。

 -- データ: dis.hasfree

     Sequence of bytecodes that access a *note free (closure) variable:
     1e9f.  'free' in this context refers to names in the current scope
     that are referenced by inner scopes or names in outer scopes that
     are referenced from this scope.  It does 'not' include references
     to global or builtin scopes.

 -- データ: dis.hasname

     名前によって属性にアクセスするバイトコードのリスト。

 -- データ: dis.hasjump

     Sequence of bytecodes that have a jump target.  All jumps are
     relative.

     Added in version 3.13.

 -- データ: dis.haslocal

     ローカル変数にアクセスするバイトコードのリスト。

 -- データ: dis.hascompare

     ブール命令のバイトコードのリスト。

 -- データ: dis.hasexc

     Sequence of bytecodes that set an exception handler.

     Added in version 3.12.

 -- データ: dis.hasjrel

     相対ジャンプ先を持つバイトコードのリスト。

     バージョン 3.13 で非推奨: All jumps are now relative.  Use *note
     hasjump: 45d2.

 -- データ: dis.hasjabs

     絶対ジャンプ先を持つバイトコードのリスト。

     バージョン 3.13 で非推奨: All jumps are now relative.  This list is
     empty.


File: python.info,  Node: pickletools --- pickle 開発者用のツール群,  Prev: dis --- Python バイトコードの逆アセンブラー,  Up: Python言語サービス

5.32.11 ‘pickletools’ -- pickle 開発者用のツール群
--------------------------------------------------

'ソースコード:' Lib/pickletools.py(1)

__________________________________________________________________

このモジュールには、 *note pickle: 95. モジュールの詳細に関わる様々な定
数や実装に関する長大なコメント、そして pickle 化されたデータを解析する上
で有用な関数をいくつか定義しています。このモジュールの内容は *note
pickle: 95. の実装に関わっている Python コア開発者にとって有用なものです
; 普通の *note pickle: 95. 利用者にとっては、 *note pickletools: 96. モ
ジュールはおそらく関係ないものでしょう。

* Menu:

* コマンドラインの使い方: コマンドラインの使い方<2>.
* プログラミングインターフェース: プログラミングインターフェース<2>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pickletools.py


File: python.info,  Node: コマンドラインの使い方<2>,  Next: プログラミングインターフェース<2>,  Up: pickletools --- pickle 開発者用のツール群

5.32.11.1 コマンドラインの使い方
................................

Added in version 3.2.

コマンドラインから実行するとき、‘python -m pickletools’ は 1 つもしくは
複数の pickle ファイルの内容を逆アセンブルします。pickle 形式の詳細では
なく pickle に保存された Python オブジェクトを見たい場合は、そのコマンド
ではなく ‘-m pickle’ を使いたいと思うかもしれません。しかし、調べたい
pickle ファイルが信頼できないソースから来たものであるとき、‘-m
pickletools’ は pickle のバイトコードを実行しないので、より安全な選択肢
です。

例えば、 ‘x.pickle’ ファイルに pickle 化されているタプル ‘(1, 2)’ に対し
て実行すると次のようになります:

     $ python -m pickle x.pickle
     (1, 2)

     $ python -m pickletools x.pickle
         0: \x80 PROTO      3
         2: K    BININT1    1
         4: K    BININT1    2
         6: \x86 TUPLE2
         7: q    BINPUT     0
         9: .    STOP
     highest protocol among opcodes = 2

* Menu:

* コマンドラインオプション: コマンドラインオプション<6>.


File: python.info,  Node: コマンドラインオプション<6>,  Up: コマンドラインの使い方<2>

5.32.11.2 コマンドラインオプション
..................................

 -- Option: -a, --annotate

     注釈として短い命令コードの説明を各行に表示します。

 -- Option: -o, --output=<file>

     出力結果を書き込むファイル名。

 -- Option: -l, --indentlevel=<num>

     新しい MARK レベルのインデントに使われる空白の数。

 -- Option: -m, --memo

     複数のオブジェクトが逆アセンブルされたとき、逆アセンブリ間でメモを
     保持します。

 -- Option: -p, --preamble=<preamble>

     複数の pickle ファイルが指定されたとき、各逆アセンブリの前に与えら
     れたプリアンブルを表示します。


File: python.info,  Node: プログラミングインターフェース<2>,  Prev: コマンドラインの使い方<2>,  Up: pickletools --- pickle 開発者用のツール群

5.32.11.3 プログラミングインターフェース
........................................

 -- の関数: pickletools.dis (pickle, out=None, memo=None, indentlevel=4,
          annotate=0)

     pickle の抽象的な逆アセンブリを file-like オブジェクト 'out' (デフ
     ォルトは ‘sys.stdout’) に出力します。'pickle' は文字列または
     file-like オブジェクトです。'memo' は Python の辞書で、pickle のメ
     モとして使われます; これは、pickle 処理を行う 1 つのオブジェクトが
     、複数の pickle にわたって逆アセンブルを行うために使われます。スト
     リーム上の ‘MARK’ 命令コードが示す後続のレベルは、'indentlevel' 個
     の空白でインデントされます。'annotate' に非ゼロの値が与えられた場合
     、出力される各命令コードは短い命令コードに注釈が付けられます。
     'annotate' の値は、注釈の先頭の位置のヒントとして使われます。

     バージョン 3.2 で変更: 'annotate' パラメーターを追加しました。

 -- の関数: pickletools.genops (pickle)

     pickle 内の全ての opcode を取り出す *note イテレータ: 191. を返しま
     す。このイテレータは ‘(opcode, arg, pos)’ の三つ組みからなる配列を
     返します。 'opcode' は ‘OpcodeInfo’ クラスのインスタンスのクラスで
     す。 'arg' は 'opcode' の引数としてデコードされた Python オブジェク
     トの値です。 'pos' は 'opcode' の場所を表す値です。 'pickle' は文字
     列でもファイル類似オブジェクトでもかまいません。

 -- の関数: pickletools.optimize (picklestring)

     使われていない ‘PUT’ 命令コードを除去した上で、その新しい pickle 文
     字列を返します。最適化された pickle は、長さがより短く、転送時間が
     より少なく、必要とするストレージ領域がより狭く、unpickle 化がより効
     率的になります。


File: python.info,  Node: MS Windows 固有のサービス,  Next: Unix 固有のサービス,  Prev: Python言語サービス,  Up: Python 標準ライブラリ

5.33 MS Windows 固有のサービス
==============================

この章では、MS Windows プラットフォーム上でのみ利用可能なモジュール群に
ついて記述します。

* Menu:

* msvcrt: msvcrt --- MS VC++ ランタイムの有用なルーチン群. MS VC++ ランタイムの有用なルーチン群
* winreg: winreg --- Windows レジストリへのアクセス. Windows レジストリへのアクセス
* winsound: winsound --- Windows 用の音声再生インターフェース. Windows 用の音声再生インターフェース


File: python.info,  Node: msvcrt --- MS VC++ ランタイムの有用なルーチン群,  Next: winreg --- Windows レジストリへのアクセス,  Up: MS Windows 固有のサービス

5.33.1 ‘msvcrt’ -- MS VC++ ランタイムの有用なルーチン群
-------------------------------------------------------

__________________________________________________________________

このモジュールの関数は、 Windows プラットフォームの便利な機能のいくつか
に対するアクセス機構を提供しています。高レベルモジュールのいくつかは、提
供するサービスを Windows で実装するために、これらの関数を使っています。
例えば、 *note getpass: 58. モジュールは関数 *note getpass(): 58. を実装
するためにこのモジュールの関数を使います。

ここに挙げた関数の詳細なドキュメントについては、プラットフォーム API ド
キュメントで見つけることができます。

このモジュールは、通常版とワイド文字列版の両方のコンソールI/O APIを実装
しています。通常版の API は ASCII 文字列のためのもので、国際化アプリケー
ションでは利用が制限されます。可能な限りワイド文字列版APIを利用するべき
です。

バージョン 3.3 で変更: このモジュールの操作で以前は *note IOError: 1026.
が送出されていたところで *note OSError: 3f0. が送出されるようになりまし
た。

* Menu:

* ファイル操作関連::
* コンソール I/O 関連::
* その多の関数::


File: python.info,  Node: ファイル操作関連,  Next: コンソール I/O 関連,  Up: msvcrt --- MS VC++ ランタイムの有用なルーチン群

5.33.1.1 ファイル操作関連
.........................

 -- の関数: msvcrt.locking (fd, mode, nbytes)

     Lock part of a file based on file descriptor 'fd' from the C
     runtime.  Raises *note OSError: 3f0. on failure.  The locked region
     of the file extends from the current file position for 'nbytes'
     bytes, and may continue beyond the end of the file.  'mode' must be
     one of the ‘LK_*’ constants listed below.  Multiple regions in a
     file may be locked at the same time, but may not overlap.  Adjacent
     regions are not merged; they must be unlocked individually.

     引数 ‘fd’, ‘mode’, ‘nbytes’ を指定して *note 監査イベント: 1825.
     ‘msvcrt.locking’ を送出します。

 -- データ: msvcrt.LK_LOCK
 -- データ: msvcrt.LK_RLCK

     Locks the specified bytes.  If the bytes cannot be locked, the
     program immediately tries again after 1 second.  If, after 10
     attempts, the bytes cannot be locked, *note OSError: 3f0. is
     raised.

 -- データ: msvcrt.LK_NBLCK
 -- データ: msvcrt.LK_NBRLCK

     指定されたバイト列にロックをかけます。指定領域がロックできなかった
     場合、 *note OSError: 3f0. が送出されます。

 -- データ: msvcrt.LK_UNLCK

     指定されたバイト列のロックを解除します。指定領域はあらかじめロック
     されていなければなりません。

 -- の関数: msvcrt.setmode (fd, flags)

     ファイル記述子 'fd' に対して、行末文字の変換モードを設定します。テ
     キストモードに設定するには、 'flags' を *note os.O_TEXT: 2ab3. にし
     ます; バイナリモードにするには *note os.O_BINARY: 2aa4. にします。

 -- の関数: msvcrt.open_osfhandle (handle, flags)

     Create a C runtime file descriptor from the file handle 'handle'.
     The 'flags' parameter should be a bitwise OR of *note os.O_APPEND:
     2aa6, *note os.O_RDONLY: 2aa2, *note os.O_TEXT: 2ab3. and *note
     os.O_NOINHERIT: 2aae.  The returned file descriptor may be used as
     a parameter to *note os.fdopen(): 1e92. to create a file object.

     The file descriptor is inheritable by default.  Pass *note
     os.O_NOINHERIT: 2aae. flag to make it non inheritable.

     引数 ‘handle’, ‘flags’ を指定して *note 監査イベント: 1825.
     ‘msvcrt.open_osfhandle’ を送出します。

 -- の関数: msvcrt.get_osfhandle (fd)

     Return the file handle for the file descriptor 'fd'.  Raises *note
     OSError: 3f0. if 'fd' is not recognized.

     引数 ‘fd’ を指定して *note 監査イベント: 1825.
     ‘msvcrt.get_osfhandle’ を送出します。


File: python.info,  Node: コンソール I/O 関連,  Next: その多の関数,  Prev: ファイル操作関連,  Up: msvcrt --- MS VC++ ランタイムの有用なルーチン群

5.33.1.2 コンソール I/O 関連
............................

 -- の関数: msvcrt.kbhit ()

     Returns a nonzero value if a keypress is waiting to be read.
     Otherwise, return 0.

 -- の関数: msvcrt.getch ()

     Read a keypress and return the resulting character as a byte
     string.  Nothing is echoed to the console.  This call will block if
     a keypress is not already available, but will not wait for ‘Enter’
     to be pressed.  If the pressed key was a special function key, this
     will return ‘'\000'’ or ‘'\xe0'’; the next call will return the
     keycode.  The ‘Control-C’ keypress cannot be read with this
     function.

 -- の関数: msvcrt.getwch ()

     *note getch(): 45f7. のワイド文字列版。Unicode の値を返します。

 -- の関数: msvcrt.getche ()

     Similar to *note getch(): 45f7, but the keypress will be echoed if
     it represents a printable character.

 -- の関数: msvcrt.getwche ()

     *note getche(): 45f8. のワイド文字列版。Unicode の値を返します。

 -- の関数: msvcrt.putch (char)

     バイト文字列 'char' をバッファリングを行わないでコンソールに出力し
     ます。

 -- の関数: msvcrt.putwch (unicode_char)

     *note putch(): 45f9. のワイド文字列版。Unicode の値を引数に取ります
     。

 -- の関数: msvcrt.ungetch (char)

     バイト文字列 'char' をコンソールバッファに "押し戻し (push back)" ま
     す; これにより、押し戻された文字は *note getch(): 45f7. や *note
     getche(): 45f8. で次に読み出される文字になります。

 -- の関数: msvcrt.ungetwch (unicode_char)

     *note ungetch(): 45fa. のワイド文字列版。Unicode の値を引数に取りま
     す。


File: python.info,  Node: その多の関数,  Prev: コンソール I/O 関連,  Up: msvcrt --- MS VC++ ランタイムの有用なルーチン群

5.33.1.3 その多の関数
.....................

 -- の関数: msvcrt.heapmin ()

     Force the ‘malloc()’ heap to clean itself up and return unused
     blocks to the operating system.  On failure, this raises *note
     OSError: 3f0.

 -- の関数: msvcrt.set_error_mode (mode)

     Changes the location where the C runtime writes an error message
     for an error that might end the program.  'mode' must be one of the
     ‘OUT_*’ constants listed below or *note REPORT_ERRMODE: 4600.
     Returns the old setting or -1 if an error occurs.  Only available
     in *note debug build of Python: 1da.

 -- データ: msvcrt.OUT_TO_DEFAULT

     Error sink is determined by the app's type.  Only available in
     *note debug build of Python: 1da.

 -- データ: msvcrt.OUT_TO_STDERR

     Error sink is a standard error.  Only available in *note debug
     build of Python: 1da.

 -- データ: msvcrt.OUT_TO_MSGBOX

     Error sink is a message box.  Only available in *note debug build
     of Python: 1da.

 -- データ: msvcrt.REPORT_ERRMODE

     Report the current error mode value.  Only available in *note debug
     build of Python: 1da.

 -- の関数: msvcrt.CrtSetReportMode (type, mode)

     Specifies the destination or destinations for a specific report
     type generated by ‘_CrtDbgReport()’ in the MS VC++ runtime.  'type'
     must be one of the ‘CRT_*’ constants listed below.  'mode' must be
     one of the ‘CRTDBG_*’ constants listed below.  Only available in
     *note debug build of Python: 1da.

 -- の関数: msvcrt.CrtSetReportFile (type, file)

     After you use *note CrtSetReportMode(): 4604. to specify *note
     CRTDBG_MODE_FILE: 4606, you can specify the file handle to receive
     the message text.  'type' must be one of the ‘CRT_*’ constants
     listed below.  'file' should be the file handle your want
     specified.  Only available in *note debug build of Python: 1da.

 -- データ: msvcrt.CRT_WARN

     Warnings, messages, and information that doesn't need immediate
     attention.

 -- データ: msvcrt.CRT_ERROR

     Errors, unrecoverable problems, and issues that require immediate
     attention.

 -- データ: msvcrt.CRT_ASSERT

     Assertion failures.

 -- データ: msvcrt.CRTDBG_MODE_DEBUG

     Writes the message to the debugger's output window.

 -- データ: msvcrt.CRTDBG_MODE_FILE

     Writes the message to a user-supplied file handle.  *note
     CrtSetReportFile(): 4605. should be called to define the specific
     file or stream to use as the destination.

 -- データ: msvcrt.CRTDBG_MODE_WNDW

     Creates a message box to display the message along with the
     ‘Abort’, ‘Retry’, and ‘Ignore’ buttons.

 -- データ: msvcrt.CRTDBG_REPORT_MODE

     Returns current 'mode' for the specified 'type'.

 -- データ: msvcrt.CRT_ASSEMBLY_VERSION

     The CRT Assembly version, from the ‘crtassem.h’ header file.

 -- データ: msvcrt.VC_ASSEMBLY_PUBLICKEYTOKEN

     The VC Assembly public key token, from the ‘crtassem.h’ header
     file.

 -- データ: msvcrt.LIBRARIES_ASSEMBLY_NAME_PREFIX

     The Libraries Assembly name prefix, from the ‘crtassem.h’ header
     file.


File: python.info,  Node: winreg --- Windows レジストリへのアクセス,  Next: winsound --- Windows 用の音声再生インターフェース,  Prev: msvcrt --- MS VC++ ランタイムの有用なルーチン群,  Up: MS Windows 固有のサービス

5.33.2 ‘winreg’ -- Windows レジストリへのアクセス
-------------------------------------------------

__________________________________________________________________

これらの関数は Windows レジストリ API を Python から使えるようにします。
プログラマがレジストリハンドルを明示的にクローズするのを忘れた場合でも、
確実にハンドルがクローズされるようにするために、レジストリハンドルとして
整数値ではなく *note ハンドルオブジェクト: 460f. が使われます。

バージョン 3.3 で変更: このモジュールのいくつかの関数は以前は *note
WindowsError: 1028. を送出していました。それは今では *note OSError: 3f0.
の別名です。

* Menu:

* 関数: 関数<13>.
* 定数: 定数<11>.
* レジストリハンドルオブジェクト::


File: python.info,  Node: 関数<13>,  Next: 定数<11>,  Up: winreg --- Windows レジストリへのアクセス

5.33.2.1 関数
.............

このモジュールでは以下の関数を提供します:

 -- の関数: winreg.CloseKey (hkey)

     以前開かれたレジストリキーを閉じます。'hkey' 引数は以前開かれたレジ
     ストリキーを指定します。

          注釈: このメソッドを使って (または *note hkey.Close(): 4614. に
          よって) 'hkey' が閉じられなかった場合、Python が 'hkey' オブジ
          ェクトを破壊する際に閉じられます。

 -- の関数: winreg.ConnectRegistry (computer_name, key)

     他のコンピュータ上にある事前に定義されたレジストリハンドルとの接続
     を確立し、 *note ハンドルオブジェクト: 460f. を返します。

     'computer_name' はリモートコンピュータの名前で、‘r"\\computername"’
     の形式をとります。‘None’ の場合、ローカルのコンピュータが使われます
     。

     'key' は、事前に定義された接続先のハンドルです。

     戻り値は開かれたキーのハンドルです。関数が失敗した場合、 *note
     OSError: 3f0. 例外が送出されます。

     引数 ‘computer_name’, ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.ConnectRegistry’ を送出します。

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.CreateKey (key, sub_key)

     指定されたキーを生成するか開き、 *note ハンドルオブジェクト: 460f.
     を返します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'sub_key' はこのメソッドが開く、または新規作成するキーの名前です。

     'key' が事前に定義されたキーのうちの一つなら、'sub_key' は ‘None’ で
     かまいません。その場合、この関数に渡されるキーハンドルと同じハンド
     ルが返されます。

     キーがすでに存在する場合、この関数はその既存のキーを開きます。

     戻り値は開かれたキーのハンドルです。関数が失敗した場合、 *note
     OSError: 3f0. 例外が送出されます。

     引数 ‘key’, ‘sub_key’, ‘access’ を指定して *note 監査イベント:
     1825. ‘winreg.CreateKey’ を送出します。

     引数 ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.OpenKey/result’ を送出します。

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.CreateKeyEx (key, sub_key, reserved=0,
          access=KEY_WRITE)

     指定されたキーを生成するか開き、 *note ハンドルオブジェクト: 460f.
     を返します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'sub_key' はこのメソッドが開く、または新規作成するキーの名前です。

     'reserved' は予約された整数で、 0 でなくてはなりません。デフォルト
     値は 0 です。

     'access' は、 key に対して想定されるセキュリティアクセスを示すアク
     セスマスクを指定する整数です。デフォルトは *note KEY_WRITE: 4616. で
     す。その他の利用可能な値については *note アクセス権: 4617. を参照し
     てください。

     'key' が事前に定義されたキーのうちの一つなら、'sub_key' は ‘None’ で
     かまいません。その場合、この関数に渡されるキーハンドルと同じハンド
     ルが返されます。

     キーがすでに存在する場合、この関数はその既存のキーを開きます。

     戻り値は開かれたキーのハンドルです。関数が失敗した場合、 *note
     OSError: 3f0. 例外が送出されます。

     引数 ‘key’, ‘sub_key’, ‘access’ を指定して *note 監査イベント:
     1825. ‘winreg.CreateKey’ を送出します。

     引数 ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.OpenKey/result’ を送出します。

     Added in version 3.2.

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.DeleteKey (key, sub_key)

     指定されたキーを削除します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'sub_key' は文字列で、'key' 引数によって指定されたキーのサブキーで
     なければなりません。この値は ‘None’ であってはならず、キーはサブキ
     ーを持っていなくてもかまいません。

     'このメソッドはサブキーをもつキーを削除することはできません。'

     このメソッドの実行が成功すると、キー全体が、その値すべてを含めて削
     除されます。このメソッドが失敗した場合、 *note OSError: 3f0. 例外が
     送出されます。

     Raises an *note auditing event: 1825. ‘winreg.DeleteKey’ with
     arguments ‘key’, ‘sub_key’, ‘access’.

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.DeleteKeyEx (key, sub_key, access=KEY_WOW64_64KEY,
          reserved=0)

     指定されたキーを削除します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'sub_key' は 'key' 引数によって指定された key の subkey でなければ
     なりません。この値は ‘None’ であってはなりません。また、key は
     subkey を持たないかもしれません。

     'reserved' は予約された整数で、 0 でなくてはなりません。デフォルト
     値は 0 です。

     'access' は、 key に対して想定されるセキュリティアクセスを示すアク
     セスマスクを指定する整数です。デフォルトは *note KEY_WOW64_64KEY:
     4618. です。32 bit Windows では、WOW64 定数は無視されます。その他の
     利用可能な値については *note アクセス権: 4617. を参照してください。

     'このメソッドはサブキーをもつキーを削除することはできません。'

     このメソッドの実行が成功すると、キー全体が、その値すべてを含めて削
     除されます。このメソッドが失敗した場合、 *note OSError: 3f0. 例外が
     送出されます。

     サポートされていない Windows バージョンでは、 *note
     NotImplementedError: 209. 例外を発生させます。

     Raises an *note auditing event: 1825. ‘winreg.DeleteKey’ with
     arguments ‘key’, ‘sub_key’, ‘access’.

     Added in version 3.2.

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.DeleteValue (key, value)

     レジストリキーから指定された名前つきの値を削除します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'value' は削除したい値を指定するための文字列です。

     引数 ‘key’, ‘value’ を指定して *note 監査イベント: 1825.
     ‘winreg.DeleteValue’ を送出します。

 -- の関数: winreg.EnumKey (key, index)

     開かれているレジストリキーのサブキーを列挙し、文字列で返します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'index' は整数値で、取得するキーのインデクスを指定します。

     この関数は、呼び出されるたびに一つのサブキーの名前を取得します。こ
     の関数は通常、これ以上値がないことを示す *note OSError: 3f0. 例外が
     送出されるまで繰り返し呼び出されます。

     引数 ‘key’, ‘index’ を指定して *note 監査イベント: 1825.
     ‘winreg.EnumKey’ を送出します。

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.EnumValue (key, index)

     開かれているレジストリキーの値を列挙し、タプルで返します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'index' は整数値で、取得する値のインデクスを指定します。

     この関数は、呼び出されるたびに一つのサブキーの名前を取得します。こ
     の関数は通常、これ以上値がないことを示す *note OSError: 3f0. 例外が
     送出されるまで繰り返し呼び出されます。

     結果は 3 要素のタプルになります:

     インデッ    意味
     クス        

     -------------------------------------------------------------
                 
     ‘0’         値の名前を指定する文字列
                 
                 
     ‘1’         値のデータを保持するためのオブジェクトで、その
                 型は背後のレジストリ型に依存します
                 
                 
     ‘2’         値のデータ型を指定する整数です
                 (*note SetValueEx(): 16f9. のドキュメント内の
                 テーブルを参照してください)
                 

     引数 ‘key’, ‘index’ を指定して *note 監査イベント: 1825.
     ‘winreg.EnumValue’ を送出します。

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.ExpandEnvironmentStrings (str)

     *note REG_EXPAND_SZ: 4619. のように、環境変数プレースホルダ
     ‘%NAME%’ を文字列で展開します:

          >>> ExpandEnvironmentStrings('%windir%')
          'C:\\Windows'

     引数 ‘str’ を指定して *note 監査イベント: 1825.
     ‘winreg.ExpandEnvironmentStrings’ を送出します。

 -- の関数: winreg.FlushKey (key)

     キーのすべての属性をレジストリに書き込みます。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     キーを変更するために *note FlushKey(): 461a. を呼ぶ必要はありません
     。レジストリの変更は怠惰なフラッシュ機構 (lazy flusher) を使ってフ
     ラッシュされます。また、システムの遮断時にもディスクにフラッシュさ
     れます。 *note CloseKey(): 4613. と違って、 *note FlushKey(): 461a.
     メソッドはレジストリに全てのデータを書き終えたときにのみ返ります。
     アプリケーションは、レジストリへの変更を絶対に確実にディスク上に反
     映させる必要がある場合にのみ、 *note FlushKey(): 461a. を呼ぶべきで
     す。

          注釈: *note FlushKey(): 461a. を呼び出す必要があるかどうか分か
          らない場合、おそらくその必要はありません。

 -- の関数: winreg.LoadKey (key, sub_key, file_name)

     指定されたキーの下にサブキーを生成し、サブキーに指定されたファイル
     のレジストリ情報を記録します。

     'key' は *note ConnectRegistry(): 406a. が返したハンドルか、定数
     *note HKEY_USERS: 461b. と *note HKEY_LOCAL_MACHINE: 461c. のどちら
     かです。

     'sub_key' は記録先のサブキーを指定する文字列です。

     'file_name' はレジストリデータを読み出すためのファイル名です。この
     ファイルは *note SaveKey(): 4076. 関数で生成されたファイルでなくて
     はなりません。ファイル割り当てテーブル (FAT) ファイルシステム下では
     、ファイル名は拡張子を持っていてはなりません。

     A call to *note LoadKey(): 4070. fails if the calling process does
     not have the ‘SE_RESTORE_PRIVILEGE’ privilege.  Note that
     privileges are different from permissions - see the RegLoadKey
     documentation(1) for more details.

     'key' が *note ConnectRegistry(): 406a. によって返されたハンドルの
     場合、 'file_name' に指定されたパスはリモートコンピュータに対する相
     対パス名になります。

     引数 ‘key’, ‘sub_key’, ‘file_name’ を指定して *note 監査イベント:
     1825. ‘winreg.LoadKey’ を送出します。

 -- の関数: winreg.OpenKey (key, sub_key, reserved=0, access=KEY_READ)
 -- の関数: winreg.OpenKeyEx (key, sub_key, reserved=0, access=KEY_READ)

     指定されたキーを開き、 *note ハンドルオブジェクト: 460f. を返します
     。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'sub_key' は開くサブキーを指定する文字列です。

     'reserved' は予約された整数で、 0 でなくてはなりません。デフォルト
     値は 0 です。

     'access' は、 key に対して想定されるセキュリティアクセスを示すアク
     セスマスクを指定する整数です。デフォルトは *note KEY_READ: 461e. で
     す。その他の利用可能な値については *note アクセス権: 4617. を参照し
     てください。

     指定されたキーへの新しいハンドルが返されます。

     この関数が失敗すると、 *note OSError: 3f0. が送出されます。

     引数 ‘key’, ‘sub_key’, ‘access’ を指定して *note 監査イベント:
     1825. ‘winreg.OpenKey’ を送出します。

     引数 ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.OpenKey/result’ を送出します。

     バージョン 3.2 で変更: 名前付き引数が使用できるようになりました。

     バージョン 3.3 で変更: *note 上記: 4610. を参照。

 -- の関数: winreg.QueryInfoKey (key)

     キーに関する情報をタプルとして返します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     結果は 3 要素のタプルになります:

     インデッ    意味
     クス        

     --------------------------------------------------------------
                 
     ‘0’         このキーが持つサブキーの数を表す整数。
                 
                 
     ‘1’         このキーが持つ値の数を表す整数。
                 
                 
     ‘2’         最後のキーの変更が (あれば) いつだったかを表す
                 整数で、1601 年 1 月 1 日からの 100 ナノ秒単位
                 で数えたもの。
                 

     引数 ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.QueryInfoKey’ を送出します。

 -- の関数: winreg.QueryValue (key, sub_key)

     キーに対する、名前付けられていない値を文字列で取得します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'sub_key' は値が関連付けられているサブキーの名前を保持する文字列で
     す。この引数が ‘None’ または空文字列の場合、この関数は 'key' で指定
     されたキーに対して *note SetValue(): 4077. メソッドで設定された値を
     取得します。

     レジストリ中の値は名前、型、およびデータから構成されています。この
     メソッドはあるキーのデータ中で、名前 ‘NULL’ をもつ最初の値を取得し
     ます。しかし背後のAPI 呼び出しは型情報を返しません。なので、可能な
     らいつでも *note QueryValueEx(): 4075. を使うべきです。

     引数 ‘key’, ‘sub_key’, ‘value_name’ を指定して *note 監査イベント:
     1825. ‘winreg.QueryValue’ を送出します。

 -- の関数: winreg.QueryValueEx (key, value_name)

     開かれたレジストリキーに関連付けられている、指定した名前の値に対し
     て、型およびデータを取得します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'value_name' は要求する値を指定する文字列です。

     結果は 2 つの要素からなるタプルです:

     インデッ    意味
     クス        

     ----------------------------------------------------------
                 
     ‘0’         レジストリ要素の値。
                 
                 
     ‘1’         この値のレジストリ型を表す整数。
                 (*note SetValueEx(): 16f9. のドキュメント内
                 のテーブルを参照してください。)
                 

     引数 ‘key’, ‘sub_key’, ‘value_name’ を指定して *note 監査イベント:
     1825. ‘winreg.QueryValue’ を送出します。

 -- の関数: winreg.SaveKey (key, file_name)

     指定されたキーと、そのサブキー全てを指定したファイルに保存します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'file_name' はレジストリデータを保存するファイルの名前です、このフ
     ァイルはすでに存在していてはいけません。このファイル名が拡張子を含
     んでいる場合、 *note LoadKey(): 4070. メソッドは、FAT ファイルシス
     テムを使うことができません。

     If 'key' represents a key on a remote computer, the path described
     by 'file_name' is relative to the remote computer.  The caller of
     this method must possess the 'SeBackupPrivilege' security
     privilege.  Note that privileges are different than permissions -
     see the Conflicts Between User Rights and Permissions
     documentation(2) for more details.

     この関数は 'security_attributes' を ‘NULL’ にして API に渡します。

     引数 ‘key’, ‘file_name’ を指定して *note 監査イベント: 1825.
     ‘winreg.SaveKey’ を送出します。

 -- の関数: winreg.SetValue (key, sub_key, type, value)

     値を指定したキーに関連付けます。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'sub_key' は値が関連付けられているサブキーの名前を表す文字列です。

     'type' はデータの型を指定する整数です。現状では、この値は *note
     REG_SZ: 461f. でなければならず、これは文字列だけがサポートされてい
     ることを示します。他のデータ型をサポートするには *note
     SetValueEx(): 16f9. を使ってください。

     'value' は新たな値を指定する文字列です。

     'sub_key' 引数で指定されたキーが存在しなければ、SetValue 関数で生成
     されます。

     値の長さは利用可能なメモリによって制限されます。(2048 バイト以上の)
     長い値はファイルに保存して、そのファイル名を設定レジストリに保存す
     るべきです。そうすればレジストリを効率的に動作させる役に立ちます。

     'key' 引数に指定されたキーは *note KEY_SET_VALUE: 4620. アクセスで
     開かれていなければなりません。

     引数 ‘key’, ‘sub_key’, ‘type’, ‘value’ を指定して *note
     監査イベント: 1825. ‘winreg.SetValue’ を送出します。

 -- の関数: winreg.SetValueEx (key, value_name, reserved, type, value)

     開かれたレジストリキーの値フィールドにデータを記録します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     'value_name' は値が関連付けられているサブキーの名前を表す文字列です
     。

     'reserved' は何もしません - API には常にゼロが渡されます。

     'type' はデータの型を指定する整数です。利用できる型については *note
     値の型: 4621. を参照してください。

     'value' は新たな値を指定する文字列です。

     このメソッドではまた、指定されたキーに対して、さらに別の値や型情報
     を設定することができます。 'key' 引数で指定されたキーは *note
     KEY_SET_VALUE: 4620. アクセスで開かれていなければなりません。

     キーを開くには、 *note CreateKey(): 406b. または *note OpenKey():
     4071. メソッドを使ってください。

     値の長さは利用可能なメモリによって制限されます。(2048 バイト以上の)
     長い値はファイルに保存して、そのファイル名を設定レジストリに保存す
     るべきです。そうすればレジストリを効率的に動作させる役に立ちます。

     引数 ‘key’, ‘sub_key’, ‘type’, ‘value’ を指定して *note
     監査イベント: 1825. ‘winreg.SetValue’ を送出します。

 -- の関数: winreg.DisableReflectionKey (key)

     64ビット OS上で動作している 32bit プロセスに対するレジストリリフレ
     クションを無効にします。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     32bit OS上では一般的に *note NotImplementedError: 209. 例外を発生さ
     せます。

     key がリフレクションリストに無い場合は、この関数は成功しますが効果
     はありません。あるキーのリフレクションを無効にしても、そのキーのサ
     ブキーのリフレクションには全く影響しません。

     引数 ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.DisableReflectionKey’ を送出します。

 -- の関数: winreg.EnableReflectionKey (key)

     指定された、リフレクションが無効にされたキーのリフレクションを再び
     有効にします。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     32bit OS上では一般的に *note NotImplementedError: 209. 例外を発生さ
     せます。

     あるキーのリフレクションを再開しても、その全てのサブキーには影響し
     ません。

     引数 ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.EnableReflectionKey’ を送出します。

 -- の関数: winreg.QueryReflectionKey (key)

     指定されたキーのリフレクション状態を確認します。

     'key' はすでに開かれたキーか、既定の *note HKEY_* 定数: 4615. のう
     ちの一つです。

     リフレクションが無効になっている場合、‘True’ を返します。

     32bit OS上では一般的に *note NotImplementedError: 209. 例外を発生さ
     せます。

     引数 ‘key’ を指定して *note 監査イベント: 1825.
     ‘winreg.QueryReflectionKey’ を送出します。

   ---------- Footnotes ----------

   (1) 
https://msdn.microsoft.com/en-us/library/ms724889%28v=VS.85%29.aspx

   (2) 
https://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx


File: python.info,  Node: 定数<11>,  Next: レジストリハンドルオブジェクト,  Prev: 関数<13>,  Up: winreg --- Windows レジストリへのアクセス

5.33.2.2 定数
.............

The following constants are defined for use in many *note winreg: fe.
functions.

* Menu:

* HKEY_* 定数::
* アクセス権限::
* 値の型::


File: python.info,  Node: HKEY_* 定数,  Next: アクセス権限,  Up: 定数<11>

5.33.2.3 HKEY_* 定数
....................

 -- データ: winreg.HKEY_CLASSES_ROOT

     このキー以下のレジストリエントリは、ドキュメントのタイプ（またはク
     ラス）や、それに関連付けられたプロパティを定義しています。シェルと
     COM アプリケーションがこの情報を利用します。

 -- データ: winreg.HKEY_CURRENT_USER

     このキー以下のレジストリエントリは、現在のユーザーの設定を定義しま
     す。この設定には、環境変数、プログラムグループに関するデータ、カラ
     ー、プリンター、ネットワーク接続、アプリケーション設定などが含まれ
     ます。

 -- データ: winreg.HKEY_LOCAL_MACHINE

     このキー以下のレジストリエントリは、コンピュータの物理的な状態を定
     義します。これには、バスタイプ、システムメモリ、インストールされて
     いるソフトウェアやハードウェアが含まれます。

 -- データ: winreg.HKEY_USERS

     このキー以下のレジストリエントリは、ローカルコンピュータの新規ユー
     ザーのためのデフォルト設定や、現在のユーザーの設定を定義しています
     。

 -- データ: winreg.HKEY_PERFORMANCE_DATA

     このキー以下のレジストリエントリは、パフォーマンスデータへのアクセ
     スを可能にしています。実際にはデータはレジストリには格納されていま
     せん。レジストリ関数がシステムにソースからデータを集めさせます。

 -- データ: winreg.HKEY_CURRENT_CONFIG

     ローカルコンピュータシステムの現在のハードウェアプロファイルに関す
     る情報を含みます。

 -- データ: winreg.HKEY_DYN_DATA

     このキーは Windows の 98 以降のバージョンでは利用されていません。


File: python.info,  Node: アクセス権限,  Next: 値の型,  Prev: HKEY_* 定数,  Up: 定数<11>

5.33.2.4 アクセス権限
.....................

より詳しい情報については、 Registry Key Security and Access(1) を参照し
てください。

 -- データ: winreg.KEY_ALL_ACCESS

     STANDARD_RIGHTS_REQUIRED (*note KEY_QUERY_VALUE: 462c, *note
     KEY_SET_VALUE: 4620, *note KEY_CREATE_SUB_KEY: 462d, *note
     KEY_ENUMERATE_SUB_KEYS: 462e, *note KEY_NOTIFY: 462f, *note
     KEY_CREATE_LINK: 4630.) アクセス権限の組み合わせ。

 -- データ: winreg.KEY_WRITE

     STANDARD_RIGHTS_WRITE (*note KEY_SET_VALUE: 4620, *note
     KEY_CREATE_SUB_KEY: 462d.) アクセス権限の組み合わせ。

 -- データ: winreg.KEY_READ

     STANDARD_RIGHTS_READ (*note KEY_QUERY_VALUE: 462c, *note
     KEY_ENUMERATE_SUB_KEYS: 462e, *note KEY_NOTIFY: 462f.) アクセス権限
     の組み合わせ。

 -- データ: winreg.KEY_EXECUTE

     *note KEY_READ: 461e. と同じ。

 -- データ: winreg.KEY_QUERY_VALUE

     レジストリキーの値を問い合わせるのに必要。

 -- データ: winreg.KEY_SET_VALUE

     レジストリの値を作成、削除、設定するのに必要。

 -- データ: winreg.KEY_CREATE_SUB_KEY

     レジストリキーのサブキーを作るのに必要。

 -- データ: winreg.KEY_ENUMERATE_SUB_KEYS

     レジストリキーのサブキーを列挙するのに必要。

 -- データ: winreg.KEY_NOTIFY

     レジストリキーやそのサブキーに対する変更通知を要求するのに必要。

 -- データ: winreg.KEY_CREATE_LINK

     システムでの利用のために予約されている。

* Menu:

* 64-bit 特有のアクセス権::

   ---------- Footnotes ----------

   (1) 
https://msdn.microsoft.com/en-us/library/ms724878%28v=VS.85%29.aspx


File: python.info,  Node: 64-bit 特有のアクセス権,  Up: アクセス権限

5.33.2.5 64-bit 特有のアクセス権
................................

より詳しい情報については、 Accessing an Alternate Registry View(1) を参
照してください。

 -- データ: winreg.KEY_WOW64_64KEY

     64 bit Windows 上のアプリケーションが、64 bit のレジストリビュー上
     で操作する事を示します。32 bit Windows では、この定数は無視されます
     。

 -- データ: winreg.KEY_WOW64_32KEY

     64 bit Windows 上のアプリケーションが、32 bit のレジストリビュー上
     で操作する事を示します。32 bit Windows では、この定数は無視されます
     。

   ---------- Footnotes ----------

   (1) https://msdn.microsoft.com/en-us/library/aa384129(v=VS.85).aspx


File: python.info,  Node: 値の型,  Prev: アクセス権限,  Up: 定数<11>

5.33.2.6 値の型
...............

より詳しい情報については、 Registry Value Types(1) を参照してください。

 -- データ: winreg.REG_BINARY

     何らかの形式のバイナリデータ。

 -- データ: winreg.REG_DWORD

     32 ビットの数。

 -- データ: winreg.REG_DWORD_LITTLE_ENDIAN

     32 ビットのリトルエンディアン形式の数。*note REG_DWORD: 4637. と等
     価。

 -- データ: winreg.REG_DWORD_BIG_ENDIAN

     32 ビットのビッグエンディアン形式の数。

 -- データ: winreg.REG_EXPAND_SZ

     環境変数を参照している、ヌル文字で終端された文字列。(‘%PATH%’)。

 -- データ: winreg.REG_LINK

     Unicode のシンボリックリンク。

 -- データ: winreg.REG_MULTI_SZ

     ヌル文字で終端された文字列からなり、二つのヌル文字で終端されている
     配列。 (Python はこの終端の処理を自動的に行います。)

 -- データ: winreg.REG_NONE

     定義されていない値の形式。

 -- データ: winreg.REG_QWORD

     64 ビットの数。

     Added in version 3.6.

 -- データ: winreg.REG_QWORD_LITTLE_ENDIAN

     64 ビットのリトルエンディアン形式の数。*note REG_QWORD: cd0. と等価
     。

     Added in version 3.6.

 -- データ: winreg.REG_RESOURCE_LIST

     デバイスドライバリソースのリスト。

 -- データ: winreg.REG_FULL_RESOURCE_DESCRIPTOR

     ハードウェアセッティング。

 -- データ: winreg.REG_RESOURCE_REQUIREMENTS_LIST

     ハードウェアリソースリスト。

 -- データ: winreg.REG_SZ

     ヌル文字で終端された文字列。

   ---------- Footnotes ----------

   (1) 
https://msdn.microsoft.com/en-us/library/ms724884%28v=VS.85%29.aspx


File: python.info,  Node: レジストリハンドルオブジェクト,  Prev: 定数<11>,  Up: winreg --- Windows レジストリへのアクセス

5.33.2.7 レジストリハンドルオブジェクト
.......................................

このオブジェクトは Windows の HKEY オブジェクトをラップし、オブジェクト
が破壊されたときに自動的にハンドルを閉じます。オブジェクトの *note
Close(): 4614. メソッドと *note CloseKey(): 4613. 関数のどちらも、後始末
がきちんと行われることを保証するために呼び出すことができます。

このモジュールのレジストリ関数は全て、これらのハンドルオブジェクトの一つ
を返します。

このモジュールのレジストリ関数でハンドルオブジェクトを受理するものは全て
整数も受理しますが、ハンドルオブジェクトを利用することを推奨します。

Handle objects provide semantics for *note __bool__(): 12a3. - thus

     if handle:
         print("Yes")

は、ハンドルが現在有効な (閉じられたり切り離されたりしていない) 場合には
‘Yes’ となります。

ハンドルオブジェクトは、比較の意味構成もサポートしています。このため、複
数のハンドルオブジェクトが参照している下層の Windows ハンドル値が同じ場
合、それらのハンドルオブジェクト同士の比較は真になります。

ハンドルオブジェクトは (例えば組み込みの *note int(): 238. 関数を使って)
整数に変換することができます。この場合、背後の Windows ハンドル値が返さ
れます、また、 *note Detach(): 4072. メソッドを使って整数のハンドル値を
返させると同時に、ハンドルオブジェクトから Windows ハンドルを切り離すこ
ともできます。

 -- メソッド: PyHKEY.Close ()

     背後の Windows ハンドルを閉じます。

     ハンドルがすでに閉じられていてもエラーは送出されません。

 -- メソッド: PyHKEY.Detach ()

     ハンドルオブジェクトから Windows ハンドルを切り離します。

     切り離される以前にそのハンドルを保持していた整数オブジェクトが返さ
     れます。ハンドルがすでに切り離されていたり閉じられていたりした場合
     、ゼロが返されます。

     この関数を呼び出した後、ハンドルは確実に無効化されますが、閉じられ
     るわけではありません。背後の Win32 ハンドルがハンドルオブジェクトよ
     りも長く維持される必要がある場合にはこの関数を呼び出すとよいでしょ
     う。

     Raises an *note auditing event: 1825. ‘winreg.PyHKEY.Detach’ with
     argument ‘key’.

 -- メソッド: PyHKEY.__enter__ ()
 -- メソッド: PyHKEY.__exit__ (*exc_info)

     HKEY オブジェクトは *note __enter__(): 592, *note __exit__(): 12ce.
     メソッドを実装していて、 *note with: 59c. 文のためのコンテキストプ
     ロトコルをサポートしています:

          with OpenKey(HKEY_LOCAL_MACHINE, "foo") as key:
              ...  # work with key

     このコードは、 *note with: 59c. ブロックから抜けるときに自動的に
     'key' を閉じます。


File: python.info,  Node: winsound --- Windows 用の音声再生インターフェース,  Prev: winreg --- Windows レジストリへのアクセス,  Up: MS Windows 固有のサービス

5.33.3 ‘winsound’ -- Windows 用の音声再生インターフェース
---------------------------------------------------------

__________________________________________________________________

*note winsound: ff. モジュールは Windows プラットフォーム上で提供されて
いる基本的な音声再生機構へのアクセス手段を提供します。このモジュールでは
いくつかの関数と定数が定義されています。

 -- の関数: winsound.Beep (frequency, duration)

     PC のスピーカを鳴らします。引数 'frequency' は鳴らす音の周波数の指
     定で、単位は Hz です。値は 37 から 32,767 でなくてはなりません。引
     数 'duration' は音を何ミリ秒鳴らすかの指定です。システムがスピーカ
     を鳴らすことができない場合、例外 *note RuntimeError: 17a. が送出さ
     れます。

 -- の関数: winsound.PlaySound (sound, flags)

     プラットフォームの API から関数 ‘PlaySound()’ を呼び出します。引数
     'sound' はファイル名、システム音エイリアス、音声データの *note
     bytes-like オブジェクト: cfb.、または ‘None’ をとり得ます。 'sound'
     の解釈は 'flags' の値に依存します。この値は以下に述べる定数をビット
     単位OR して組み合わせたものになります。 'sound' 引数が ‘None’ だっ
     た場合、現在再生中のWave形式サウンドの再生を停止します。システムの
     エラーが発生した場合、例外 *note RuntimeError: 17a. が送出されます
     。

 -- の関数: winsound.MessageBeep (type=MB_OK)

     根底にある ‘MessageBeep()’ 関数をプラットフォームの API から呼び出
     します。この関数は音声をレジストリの指定に従って再生します。 'type'
     引数はどの音声を再生するかを指定します; とり得る値は ‘-1’,
     ‘MB_ICONASTERISK’, ‘MB_ICONEXCLAMATION’, ‘MB_ICONHAND’,
     ‘MB_ICONQUESTION’,および ‘MB_OK’ で、全て以下に記述されています。値
     ‘-1’ は "単純なビープ音" を再生します; この値は他の場合で音声を再生
     することができなかった際の最終的な代替音です。システムがエラーを示
     したら、*note RuntimeError: 17a. が送出されます。

 -- データ: winsound.SND_FILENAME

     'sound' パラメタが WAV ファイル名であることを示します。 *note
     SND_ALIAS: 4646. と同時に使ってはいけません。

 -- データ: winsound.SND_ALIAS

     引数 'sound' はレジストリにある音声データに関連付けられた名前である
     ことを示します。指定した名前がレジストリ上にない場合、定数 *note
     SND_NODEFAULT: 4647. が同時に指定されていない限り、システム標準の音
     声データが再生されます。標準の音声データが登録されていない場合、例
     外 *note RuntimeError: 17a. が送出されます。 *note SND_FILENAME:
     4645. と同時に使ってはいけません。

     全ての Win32 システムは少なくとも以下の名前をサポートします; ほとん
     どのシステムでは他に多数あります:

     *note PlaySound(): cd4.        対応するコントロールパネルでの音声名
     'name'                         

     ----------------------------------------------------------------------------
                                    
     ‘'SystemAsterisk'’             Asterisk
                                    
                                    
     ‘'SystemExclamation'’          Exclamation
                                    
                                    
     ‘'SystemExit'’                 Exit Windows
                                    
                                    
     ‘'SystemHand'’                 Critical Stop
                                    
                                    
     ‘'SystemQuestion'’             Question
                                    

     例えば:

          import winsound
          # Play Windows exit sound.
          winsound.PlaySound("SystemExit", winsound.SND_ALIAS)

          # Probably play Windows default sound, if any is registered (because
          # "*" probably isn't the registered name of any sound).
          winsound.PlaySound("*", winsound.SND_ALIAS)

 -- データ: winsound.SND_LOOP

     音声データを繰り返し再生します。システムがブロックしないようにする
     ため、 *note SND_ASYNC: 4649. フラグを同時に使わなくてはなりません
     。 *note SND_MEMORY: 464a. と同時に使うことはできません。

 -- データ: winsound.SND_MEMORY

     *note PlaySound(): cd4. の引数 'sound' が *note bytes-like
     オブジェクト: cfb. の形式をとった WAV ファイルのメモリ上のイメージ
     であることを示します。

          注釈: このモジュールはメモリ上のイメージを非同期に再生する機能
          をサポートしていません。従って、このフラグと *note SND_ASYNC:
          4649. を組み合わせると例外 *note RuntimeError: 17a. が送出され
          ます。

 -- データ: winsound.SND_PURGE

     指定した音声の全てのインスタンスについて再生処理を停止します。

          注釈: このフラグは現代のWindowsプラットフォームではサポートさ
          れていません。

 -- データ: winsound.SND_ASYNC

     音声を非同期に再生するようにして、関数呼び出しを即座に返します。

 -- データ: winsound.SND_NODEFAULT

     指定した音声が見つからなかった場合にシステム標準の音声を鳴らさない
     ようにします。

 -- データ: winsound.SND_NOSTOP

     現在鳴っている音声を中断させないようにします。

 -- データ: winsound.SND_NOWAIT

     サウンドドライバがビジー状態にある場合、関数がすぐ返るようにします
     。

          注釈: このフラグは現代のWindowsプラットフォームではサポートさ
          れていません。

 -- データ: winsound.MB_ICONASTERISK

     音声 ‘SystemDefault’ を再生します。

 -- データ: winsound.MB_ICONEXCLAMATION

     音声 ‘SystemExclamation’ を再生します。

 -- データ: winsound.MB_ICONHAND

     音声 ‘SystemHand’ を再生します。

 -- データ: winsound.MB_ICONQUESTION

     音声 ‘SystemQuestion’ を再生します。

 -- データ: winsound.MB_OK

     音声 ‘SystemDefault’ を再生します。


File: python.info,  Node: Unix 固有のサービス,  Next: モジュールのコマンドラインインターフェース CLI,  Prev: MS Windows 固有のサービス,  Up: Python 標準ライブラリ

5.34 Unix 固有のサービス
========================

本章に記述されたモジュールは、Unix オペレーティングシステム、あるいはそ
れから派生した多くのものに固有の機能のためのインターフェースを提供します
。その概要を以下に述べます:

* Menu:

* posix: posix --- 最も一般的な POSIX システムコール群. 最も一般的な POSIX システムコール群
* pwd: pwd --- パスワードデータベース. パスワードデータベース
* grp: grp --- グループデータベース. グループデータベース
* termios: termios --- POSIX スタイルの端末制御. POSIX スタイルの端末制御
* tty: tty --- 端末制御用の関数群. 端末制御用の関数群
* pty: pty --- 擬似端末ユーティリティ. 擬似端末ユーティリティ
* fcntl: fcntl --- fcntl および ioctl システムコール. fcntl および ioctl システムコール
* resource: resource --- リソース使用情報. リソース使用情報
* syslog: syslog --- Unix syslog ライブラリルーチン群. Unix syslog ライブラリルーチン群


File: python.info,  Node: posix --- 最も一般的な POSIX システムコール群,  Next: pwd --- パスワードデータベース,  Up: Unix 固有のサービス

5.34.1 ‘posix’ -- 最も一般的な POSIX システムコール群
-----------------------------------------------------

__________________________________________________________________

このモジュールはオペレーティングシステムの機能のうち、C 言語標準および
(Unix インターフェースをほんの少し隠蔽した) POSIX 標準で標準化されている
機能に対するアクセス機構を提供します。

*note Availability: 1cbe.: Unix.

'このモジュールを直接インポートしてはいけません。' その代わりに、このイ
ンターフェースの 'ポータブル' 版である *note os: 91. モジュールをインポ
ートしてください。 Unix では、*note os: 91. モジュールは *note posix:
9b. インターフェースのスーパーセットを提供しています。非 Unix オペレーテ
ィングシステムでは、 *note posix: 9b. モジュールは利用できませんが、その
一部分は *note os: 91. インターフェースを通して常に利用可能です。一度
*note os: 91. をインポートし *note posix: 9b. の代わりにそれを使えば、パ
フォーマンス上の代償は 'ありません' 。加えて *note os: 91. は、
‘os.environ’ の要素が変更されたときに *note putenv(): 8ea. を呼び出すな
どの追加の機能も提供します。

エラーは例外として報告されます; よくある例外は型エラーです。一方、システ
ムコールから報告されたエラーは以下に述べるように *note OSError: 3f0. を
送出します。

* Menu:

* ラージファイルのサポート::
* 注目すべきモジュールの内容::


File: python.info,  Node: ラージファイルのサポート,  Next: 注目すべきモジュールの内容,  Up: posix --- 最も一般的な POSIX システムコール群

5.34.1.1 ラージファイルのサポート
.................................

いくつかのオペレーティングシステム (AIX および Solaris が含まれます) は
、 int および long を 32 ビット値とする C プログラムモデルで 2GB を超え
るサイズのファイルのサポートを提供しています。このサポートは典型的には関
連するサイズとオフセットの組合せを 64-bit 値として定義することで実現して
います。このようなファイルは時にラージファイル ('large files') と呼ばれ
ます。

Python では、 ‘off_t’ のサイズが long より大きく、かつ long long が少な
くとも ‘off_t’ と同じくらい大きなサイズであるとき、ラージファイルのサポ
ートが有効になります。 この場合、ファイルのサイズ、オフセットおよび
Python の通常整数型の範囲を超えるような値の表現には Python の長整数型が
使われます。 このモードを有効にするのに、 ‘configure’ で Python のコンパ
イルに特定のコンパイルフラグを必要とするかもしれません。 例えば、Solaris
2.6 および 2.7 では、以下のようにする必要があります:

     CFLAGS="`getconf LFS_CFLAGS`" OPT="-g -O2 $CFLAGS" \
             ./configure

ラージファイル対応の Linux システムでは、以下のようにすれば良いでしょう:

     CFLAGS='-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64' OPT="-g -O2 $CFLAGS" \
             ./configure


File: python.info,  Node: 注目すべきモジュールの内容,  Prev: ラージファイルのサポート,  Up: posix --- 最も一般的な POSIX システムコール群

5.34.1.2 注目すべきモジュールの内容
...................................

*note os: 91. モジュールのドキュメントで説明されている多数の関数に加え、
*note posix: 9b. では以下のデータ項目を定義しています:

 -- データ: posix.environ

     インタプリタが起動したときの環境を表す文字列辞書です。キーと値は
     Unix ではバイト列、 Windows では文字列です。例えば、
     ‘environ[b'HOME']’ (Windows では ‘environ['HOME']’) はホームディレ
     クトリのパス名で、 C の ‘getenv("HOME")’ と同じ値です。

     この辞書を編集しても、 *note execv(): 2a77. 、 *note popen(): a55.
     、 *note system(): 1402. で渡された環境変数文字列には影響は与えませ
     ん; 環境変数を変更したい場合は、 ‘environ’ を *note execve(): 10cc.
     に渡すか、変数への代入文と export 文を *note system(): 1402. や
     *note popen(): a55. に渡すコマンド文字列に追加してください。

     バージョン 3.2 で変更: Unix ではキーと値はバイト列になりました。

          注釈: *note os: 91. モジュールでは、もう一つの *note
          os.environ: 118a. 実装を提供しており、環境変数が変更された場合
          、その内容を更新するようになっています。 ‘environ’ を更新した
          場合、この辞書は古い内容を表していることになってしまうので、こ
          のことにも注意してください。 *note posix: 9b. モジュール版を直
          接アクセスするよりも、 *note os: 91. モジュール版を使う方が推
          奨されています。


File: python.info,  Node: pwd --- パスワードデータベース,  Next: grp --- グループデータベース,  Prev: posix --- 最も一般的な POSIX システムコール群,  Up: Unix 固有のサービス

5.34.2 ‘pwd’ -- パスワードデータベース
--------------------------------------

__________________________________________________________________

このモジュールは Unix のユーザアカウントとパスワードのデータベースへのア
クセスを提供します。全ての Unix 系 OS で利用できます。

*note Availability: 1cbe.: Unix, not WASI, not iOS.

パスワードデータベースの各エントリはタプルのようなオブジェクトで提供され
、それぞれの属性は ‘passwd’ 構造体のメンバに対応しています(下の属性欄に
ついては、‘<pwd.h>’ を見てください):

インデッ    属性                意味
クス                            

------------------------------------------------------------------
                                
0           ‘pw_name’           ログイン名
                                
                                
1           ‘pw_passwd’         暗号化されたパスワード
                                (optional))
                                
                                
2           ‘pw_uid’            ユーザID(UID)
                                
                                
3           ‘pw_gid’            グループID(GID)
                                
                                
4           ‘pw_gecos’          実名またはコメント
                                
                                
5           ‘pw_dir’            ホームディレクトリ
                                
                                
6           ‘pw_shell’          シェル
                                

UIDとGIDは整数で、それ以外は全て文字列です。検索したエントリが見つからな
いと *note KeyError: 31d. が発生します。

     注釈: 伝統的なUnixでは、 ‘pw_passwd’ フィールドはDES由来のアルゴリ
     ズムで暗号化されたパスワードが含まれています。しかし、近代的な
     UNIX系OSでは 'シャドウパスワード' とよばれる仕組みを利用しています
     。この場合には 'pw_passwd' フィールドにはアスタリスク(‘'*'’)か、
     ‘'x'’ という一文字だけが含まれており、暗号化されたパスワードは、一
     般には見えない ‘/etc/shadow’ というファイルに入っています。
     'pw_passwd' フィールドに有用な値が入っているかはシステムに依存しま
     す。

このモジュールでは以下の内容を定義しています:

 -- の関数: pwd.getpwuid (uid)

     与えられたUIDに対応するパスワードデータベースのエントリを返します。

 -- の関数: pwd.getpwnam (name)

     与えられたユーザ名に対応するパスワードデータベースのエントリを返し
     ます。

 -- の関数: pwd.getpwall ()

     パスワードデータベースの全てのエントリを、任意の順番で並べたリスト
     を返します。

参考
....

*note grp: 5c. モジュール

     このモジュールに似た、グループデータベースへのアクセスを提供するモ
     ジュール。


File: python.info,  Node: grp --- グループデータベース,  Next: termios --- POSIX スタイルの端末制御,  Prev: pwd --- パスワードデータベース,  Up: Unix 固有のサービス

5.34.3 ‘grp’ -- グループデータベース
------------------------------------

__________________________________________________________________

このモジュールでは Unix グループ (group) データベースへのアクセス機構を
提供します。全ての Unix バージョンで利用可能です。

*note Availability: 1cbe.: Unix, not WASI, not Android, not iOS.

このモジュールはグループデータベースのエントリをタプルに似たオブジェクト
として報告されます。このオブジェクトの属性は ‘group’ 構造体の各メンバ (以
下の属性フィールド、‘<grp.h>’ を参照) に対応します:

インデッ    属性            意味
クス                        

------------------------------------------------------------------
                            
0           gr_name         グループ名
                            
                            
1           gr_passwd       (暗号化された) グループパスワード;
                            しばしば空文字列になります
                            
                            
2           gr_gid          数字のグループ ID
                            
                            
3           gr_mem          グループメンバの全てのユーザ名
                            

gid は整数、名前およびパスワードは文字列、そしてメンバリストは文字列から
なるリストです。 (ほとんどのユーザは、パスワードデータベースで自分が入れ
られているグループのメンバとしてグループデータベース内では明示的に列挙さ
れていないので注意してください。完全なメンバ情報を取得するには両方のデー
タベースを調べてください。また、 ‘+’ や ‘-’ で始まる ‘gr_name’ は YP/NIS
参照である可能性があり、 *note getgrnam(): 30b1. や *note getgrgid():
cf4. でアクセスできないかもしれないことにも注意してください。)

このモジュールでは以下の内容を定義しています:

 -- の関数: grp.getgrgid (id)

     与えられたグループ ID に対するグループデータベースエントリを返しま
     す。要求したエントリが見つからなかった場合、 *note KeyError: 31d. が
     送出されます。

     バージョン 3.10 で変更: 浮動小数点数や文字列のような、整数でない引
     数には *note TypeError: 502. が送出されます。

 -- の関数: grp.getgrnam (name)

     与えられたグループ名に対するグループデータベースエントリを返します
     。要求したエントリが見つからなかった場合、 *note KeyError: 31d. が
     送出されます。

 -- の関数: grp.getgrall ()

     全ての入手可能なグループエントリを返します。順番は決まっていません
     。

参考
....

*note pwd: a0. モジュール

     このモジュールと類似の、ユーザデータベースへのインターフェース。


File: python.info,  Node: termios --- POSIX スタイルの端末制御,  Next: tty --- 端末制御用の関数群,  Prev: grp --- グループデータベース,  Up: Unix 固有のサービス

5.34.4 ‘termios’ -- POSIX スタイルの端末制御
--------------------------------------------

__________________________________________________________________

このモジュールでは端末 I/O 制御のための POSIX 準拠の関数呼び出しインター
フェースを提供します。これら呼び出しのための完全な記述については、 Unix
マニュアルページの ‘termios(3)(1)’ を参照してください。これは POSIX
'termios' 形式の端末制御をサポートしていてインストール時に有効にした
Unix のバージョンでのみ利用可能です。

*note Availability: 1cbe.: Unix.

このモジュールの関数は全て、ファイル記述子 'fd' を最初の引数としてとりま
す。この値は、 ‘sys.stdin.fileno()’ が返すような整数のファイル記述子でも
、 ‘sys.stdin’ 自体のような *note file object: 1193. でもかまいません。

このモジュールではまた、モジュールで提供されている関数を使う上で必要とな
る全ての定数を定義しています; これらの定数は C の対応する関数と同じ名前
を持っています。これらの端末制御インターフェースを利用する上でのさらなる
情報については、あなたのシステムのドキュメンテーションを参考にしてくださ
い。

このモジュールには、以下の関数が定義されています:

 -- の関数: termios.tcgetattr (fd)

     ファイル記述子 'fd' の端末属性を含むリストを返します。その形式は:
     ‘[iflag, oflag, cflag, lflag, ispeed, ospeed, cc]’ です。 'cc' は端
     末特殊文字のリストです (それぞれ長さ 1 の文字列です。ただしインデク
     ス ‘VMIN’ および ‘VTIME’ の内容は、それらのフィールドが定義されてい
     た場合整数の値となります)。端末設定フラグおよび端末速度の解釈、およ
     び配列 'cc' のインデクス検索は、 *note termios: ca. で定義されてい
     るシンボル定数を使って行わなければなりません。

 -- の関数: termios.tcsetattr (fd, when, attributes)

     Set the tty attributes for file descriptor 'fd' from the
     'attributes', which is a list like the one returned by *note
     tcgetattr(): 15da.  The 'when' argument determines when the
     attributes are changed:

      -- データ: termios.TCSANOW

          Change attributes immediately.

      -- データ: termios.TCSADRAIN

          Change attributes after transmitting all queued output.

      -- データ: termios.TCSAFLUSH

          Change attributes after transmitting all queued output and
          discarding all queued input.

 -- の関数: termios.tcsendbreak (fd, duration)

     ファイル記述子 'fd' にブレークを送信します。'duration' をゼロにする
     と、0.25〜0.5 秒間のブレークを送信します; 'duration' の値がゼロでな
     い場合、その意味はシステム依存です。

 -- の関数: termios.tcdrain (fd)

     ファイル記述子 'fd' に書き込まれた全ての出力が転送されるまで待ちま
     す。

 -- の関数: termios.tcflush (fd, queue)

     ファイル記述子 'fd' にキューされたデータを無視します。どのキューか
     は 'queue' セレクタで指定します: ‘TCIFLUSH’ は入力キュー、
     ‘TCOFLUSH’ は出力キュー、 ‘TCIOFLUSH’ は両方のキューです。

 -- の関数: termios.tcflow (fd, action)

     ファイル記述子 'fd' の入力または出力をサスペンドしたりレジュームし
     たりします。引数 'action' は出力をサスペンドする ‘TCOOFF’ 、出力を
     レジュームする ‘TCOON’ 、入力をサスペンドする ‘TCIOFF’ 、入力をレジ
     ュームする ‘TCION’ をとることができます。

 -- の関数: termios.tcgetwinsize (fd)

     Return a tuple ‘(ws_row, ws_col)’ containing the tty window size
     for file descriptor 'fd'.  Requires ‘termios.TIOCGWINSZ’ or
     ‘termios.TIOCGSIZE’.

     Added in version 3.11.

 -- の関数: termios.tcsetwinsize (fd, winsize)

     Set the tty window size for file descriptor 'fd' from 'winsize',
     which is a two-item tuple ‘(ws_row, ws_col)’ like the one returned
     by *note tcgetwinsize(): 466c.  Requires at least one of the pairs
     (‘termios.TIOCGWINSZ’, ‘termios.TIOCSWINSZ’); (‘termios.TIOCGSIZE’,
     ‘termios.TIOCSSIZE’) to be defined.

     Added in version 3.11.

参考
....

*note tty: e9. モジュール

     一般的な端末制御操作のための便利な関数。

* Menu:

* 使用例: 使用例<50>.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/termios(3)


File: python.info,  Node: 使用例<50>,  Up: termios --- POSIX スタイルの端末制御

5.34.4.1 使用例
...............

以下はエコーバックを切った状態でパスワード入力を促す関数です。ユーザの入
力に関わらず以前の端末属性を正確に回復するために、二つの *note
tcgetattr(): 15da. と *note try: 6b4. ...  *note finally: 997. 文による
テクニックが使われています:

     def getpass(prompt="Password: "):
         import termios, sys
         fd = sys.stdin.fileno()
         old = termios.tcgetattr(fd)
         new = termios.tcgetattr(fd)
         new[3] = new[3] & ~termios.ECHO          # lflags
         try:
             termios.tcsetattr(fd, termios.TCSADRAIN, new)
             passwd = input(prompt)
         finally:
             termios.tcsetattr(fd, termios.TCSADRAIN, old)
         return passwd


File: python.info,  Node: tty --- 端末制御用の関数群,  Next: pty --- 擬似端末ユーティリティ,  Prev: termios --- POSIX スタイルの端末制御,  Up: Unix 固有のサービス

5.34.5 ‘tty’ -- 端末制御用の関数群
----------------------------------

'ソースコード:' Lib/tty.py(1)

__________________________________________________________________

*note tty: e9. モジュールは端末を cbreak および raw モードにするための関
数を定義しています。

*note Availability: 1cbe.: Unix.

このモジュールは *note termios: ca. モジュールを必要とするため、 Unix で
しか動作しません。

*note tty: e9. モジュールでは、以下の関数を定義しています:

 -- の関数: tty.cfmakeraw (mode)

     Convert the tty attribute list 'mode', which is a list like the one
     returned by *note termios.tcgetattr(): 15da, to that of a tty in
     raw mode.

     Added in version 3.12.

 -- の関数: tty.cfmakecbreak (mode)

     Convert the tty attribute list 'mode', which is a list like the one
     returned by *note termios.tcgetattr(): 15da, to that of a tty in
     cbreak mode.

     This clears the ‘ECHO’ and ‘ICANON’ local mode flags in 'mode' as
     well as setting the minimum input to 1 byte with no delay.

     Added in version 3.12.

     バージョン 3.12.2 で変更: The ‘ICRNL’ flag is no longer cleared.
     This matches Linux and macOS ‘stty cbreak’ behavior and what *note
     setcbreak(): 15dc. historically did.

 -- の関数: tty.setraw (fd, when=termios.TCSAFLUSH)

     Change the mode of the file descriptor 'fd' to raw.  If 'when' is
     omitted, it defaults to *note termios.TCSAFLUSH: 4667, and is
     passed to *note termios.tcsetattr(): 165d.  The return value of
     *note termios.tcgetattr(): 15da. is saved before setting 'fd' to
     raw mode; this value is returned.

     バージョン 3.12 で変更: The return value is now the original tty
     attributes, instead of ‘None’.

 -- の関数: tty.setcbreak (fd, when=termios.TCSAFLUSH)

     Change the mode of file descriptor 'fd' to cbreak.  If 'when' is
     omitted, it defaults to *note termios.TCSAFLUSH: 4667, and is
     passed to *note termios.tcsetattr(): 165d.  The return value of
     *note termios.tcgetattr(): 15da. is saved before setting 'fd' to
     cbreak mode; this value is returned.

     This clears the ‘ECHO’ and ‘ICANON’ local mode flags as well as
     setting the minimum input to 1 byte with no delay.

     バージョン 3.12 で変更: The return value is now the original tty
     attributes, instead of ‘None’.

     バージョン 3.12.2 で変更: The ‘ICRNL’ flag is no longer cleared.
     This restores the behavior of Python 3.11 and earlier as well as
     matching what Linux, macOS, & BSDs describe in their ‘stty(1)’ man
     pages regarding cbreak mode.

参考
....

モジュール *note termios: ca.

     低水準端末制御インターフェース。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/tty.py


File: python.info,  Node: pty --- 擬似端末ユーティリティ,  Next: fcntl --- fcntl および ioctl システムコール,  Prev: tty --- 端末制御用の関数群,  Up: Unix 固有のサービス

5.34.6 ‘pty’ -- 擬似端末ユーティリティ
--------------------------------------

'ソースコード:' Lib/pty.py(1)

__________________________________________________________________

*note pty: 9f. モジュールは擬似端末(他のプロセスを実行してその制御をして
いる端末をプログラムで読み書きする)を制御する操作を定義しています。

*note Availability: 1cbe.: Unix.

Pseudo-terminal handling is highly platform dependent.  This code is
mainly tested on Linux, FreeBSD, and macOS (it is supposed to work on
other POSIX platforms but it's not been thoroughly tested).

*note pty: 9f. モジュールでは以下の関数を定義しています:

 -- の関数: pty.fork ()

     forkします。子プロセスの制御端末を擬似端末に接続します。返り値は
     ‘(pid, fd)’ です。子プロセスは 'pid' として0、'fd' として 'invalid'
     をそれぞれ受けとります。親プロセスは 'pid' として子プロセスのPID、
     'fd' として子プロセスの制御端末 (子プロセスの標準入出力に接続されて
     いる)のファイル記述子を受けとります。

          警告: On macOS the use of this function is unsafe when mixed
          with using higher-level system APIs, and that includes using
          *note urllib.request: f4.

 -- の関数: pty.openpty ()

     新しい擬似端末のペアを開きます。利用できるなら *note os.openpty():
     2ab9. を使い、利用できなければ一般的なUnixシステム用のエミュレーシ
     ョンコードを使います。マスター、スレーブそれぞれのためのファイル記
     述子、 ‘(master, slave)’ のタプルを返します。

 -- の関数: pty.spawn (argv[, master_read[, stdin_read]])

     Spawn a process, and connect its controlling terminal with the
     current process's standard io.  This is often used to baffle
     programs which insist on reading from the controlling terminal.  It
     is expected that the process spawned behind the pty will eventually
     terminate, and when it does 'spawn' will return.

     A loop copies STDIN of the current process to the child and data
     received from the child to STDOUT of the current process.  It is
     not signaled to the child if STDIN of the current process closes
     down.

     The functions 'master_read' and 'stdin_read' are passed a file
     descriptor which they should read from, and they should always
     return a byte string.  In order to force spawn to return before the
     child process exits an empty byte array should be returned to
     signal end of file.

     The default implementation for both functions will read and return
     up to 1024 bytes each time the function is called.  The
     'master_read' callback is passed the pseudoterminal’s master file
     descriptor to read output from the child process, and 'stdin_read'
     is passed file descriptor 0, to read from the parent process's
     standard input.

     Returning an empty byte string from either callback is interpreted
     as an end-of-file (EOF) condition, and that callback will not be
     called after that.  If 'stdin_read' signals EOF the controlling
     terminal can no longer communicate with the parent process OR the
     child process.  Unless the child process will quit without any
     input, 'spawn' will then loop forever.  If 'master_read' signals
     EOF the same behavior results (on linux at least).

     Return the exit status value from *note os.waitpid(): d67. on the
     child process.

     *note os.waitstatus_to_exitcode(): 8eb. can be used to convert the
     exit status into an exit code.

     引数 ‘argv’ を指定して *note 監査イベント: 1825. ‘pty.spawn’ を送出
     します。

     バージョン 3.4 で変更: *note spawn(): f4f. が *note os.waitpid():
     d67. が返す子プロセスのステータス値を返すようになりました。

* Menu:

* 使用例: 使用例<51>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/pty.py


File: python.info,  Node: 使用例<51>,  Up: pty --- 擬似端末ユーティリティ

5.34.6.1 使用例
...............

下記のプログラムは Unix コマンド ‘script(1)(1)’ のように動作します。疑似
端末を使用して、端末セッションのすべての入出力を "typescript" に記録しま
す。

     import argparse
     import os
     import pty
     import sys
     import time

     parser = argparse.ArgumentParser()
     parser.add_argument('-a', dest='append', action='store_true')
     parser.add_argument('-p', dest='use_python', action='store_true')
     parser.add_argument('filename', nargs='?', default='typescript')
     options = parser.parse_args()

     shell = sys.executable if options.use_python else os.environ.get('SHELL', 'sh')
     filename = options.filename
     mode = 'ab' if options.append else 'wb'

     with open(filename, mode) as script:
         def read(fd):
             data = os.read(fd, 1024)
             script.write(data)
             return data

         print('Script started, file is', filename)
         script.write(('Script started on %s\n' % time.asctime()).encode())

         pty.spawn(shell, read)

         script.write(('Script done on %s\n' % time.asctime()).encode())
         print('Script done, file is', filename)

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/script(1)


File: python.info,  Node: fcntl --- fcntl および ioctl システムコール,  Next: resource --- リソース使用情報,  Prev: pty --- 擬似端末ユーティリティ,  Up: Unix 固有のサービス

5.34.7 ‘fcntl’ -- ‘fcntl’ および ‘ioctl’ システムコール
-------------------------------------------------------

__________________________________________________________________

This module performs file and I/O control on file descriptors.  It is an
interface to the ‘fcntl()’ and ‘ioctl()’ Unix routines.  See the
‘fcntl(2)(1)’ and ‘ioctl(2)(2)’ Unix manual pages for full details.

*note Availability: 1cbe.: Unix, not WASI.

このモジュール内の全ての関数はファイル記述子 'fd' を最初の引数に取ります
。 この値は ‘sys.stdin.fileno()’ が返すような整数のファイル記述子でも、
‘sys.stdin’ 自体のような、純粋にファイル記述子だけを返す *note fileno():
27a6. メソッドを提供している *note io.IOBase: 1d6. オブジェクトでもかま
いません。

バージョン 3.3 で変更: 以前は *note IOError: 1026. を送出していたこのモ
ジュールの操作が、 *note OSError: 3f0. を送出するようになりました。

バージョン 3.8 で変更: The ‘fcntl’ module now contains ‘F_ADD_SEALS’,
‘F_GET_SEALS’, and ‘F_SEAL_*’ constants for sealing of *note
os.memfd_create(): 9d9. file descriptors.

バージョン 3.9 で変更: On macOS, the ‘fcntl’ module exposes the
‘F_GETPATH’ constant, which obtains the path of a file from a file
descriptor.  On Linux(>=3.15), the ‘fcntl’ module exposes the
‘F_OFD_GETLK’, ‘F_OFD_SETLK’ and ‘F_OFD_SETLKW’ constants, which are
used when working with open file description locks.

バージョン 3.10 で変更: On Linux >= 2.6.11, the ‘fcntl’ module exposes
the ‘F_GETPIPE_SZ’ and ‘F_SETPIPE_SZ’ constants, which allow to check
and modify a pipe's size respectively.

バージョン 3.11 で変更: On FreeBSD, the ‘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.

バージョン 3.12 で変更: On Linux >= 4.5, the *note fcntl: 4f. 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".

バージョン 3.13 で変更: On Linux >= 2.6.32, the ‘fcntl’ module exposes
the ‘F_GETOWN_EX’, ‘F_SETOWN_EX’, ‘F_OWNER_TID’, ‘F_OWNER_PID’,
‘F_OWNER_PGRP’ constants, which allow to direct I/O availability signals
to a specific thread, process, or process group.  On Linux >= 4.13, the
‘fcntl’ module exposes the ‘F_GET_RW_HINT’, ‘F_SET_RW_HINT’,
‘F_GET_FILE_RW_HINT’, ‘F_SET_FILE_RW_HINT’, and ‘RWH_WRITE_LIFE_*’
constants, which allow to inform the kernel about the relative expected
lifetime of writes on a given inode or via a particular open file
description.  On Linux >= 5.1 and NetBSD, the ‘fcntl’ module exposes the
‘F_SEAL_FUTURE_WRITE’ constant for use with ‘F_ADD_SEALS’ and
‘F_GET_SEALS’ operations.  On FreeBSD, the ‘fcntl’ module exposes the
‘F_READAHEAD’, ‘F_ISUNIONSTACK’, and ‘F_KINFO’ constants.  On macOS and
FreeBSD, the ‘fcntl’ module exposes the ‘F_RDAHEAD’ constant.  On NetBSD
and AIX, the ‘fcntl’ module exposes the ‘F_CLOSEM’ constant.  On NetBSD,
the ‘fcntl’ module exposes the ‘F_MAXFD’ constant.  On macOS and NetBSD,
the ‘fcntl’ module exposes the ‘F_GETNOSIGPIPE’ and ‘F_SETNOSIGPIPE’
constant.

このモジュールには、以下の関数が定義されています:

 -- の関数: fcntl.fcntl (fd, cmd, arg=0)

     操作 'cmd' をファイル記述子 'fd' (または *note fileno(): 27a6. メソ
     ッドを提供しているファイルオブジェクト) に対して実行します。 'cmd'
     として用いられる値はオペレーティングシステム依存で、 *note fcntl:
     4f. モジュール内に関連する C ヘッダファイルと同じ名前が使われている
     定数の形で利用出来ます。引数 'arg' は整数値か *note bytes: 1a4. オ
     ブジェクトをとります。引数が整数値の場合、この関数の戻り値は C 言語
     の ‘fcntl()’ を呼び出した際の整数の戻り値になります。引数が bytes の
     場合には、 *note struct.pack(): 1248. で作られるようなバイナリの構
     造体を表します。バイナリデータはバッファにコピーされ、そのアドレス
     が C 言語の ‘fcntl()’ 呼び出しに渡されます。 呼び出しが成功した後に
     戻される値はバッファの内容で、 *note bytes: 1a4. オブジェクトに変換
     されています。 返されるオブジェクトは 'arg' 引数と同じ長さになりま
     す。 この値は 1024 バイトに制限されています。 オペレーティングシス
     テムからバッファに返される情報の長さが 1024 バイトよりも大きい場合
     、大抵はセグメンテーション違反となるか、より不可思議なデータの破損
     を引き起こします。

     If the ‘fcntl()’ call fails, an *note OSError: 3f0. is raised.

     引数 ‘fd’, ‘cmd’, ‘arg’ を指定して *note 監査イベント: 1825.
     ‘fcntl.fcntl’ を送出します。

 -- の関数: fcntl.ioctl (fd, request, arg=0, mutate_flag=True)

     この関数は *note fcntl(): 32f0. 関数と同じですが、引数の扱いがより
     複雑であるところが異なります。

     パラメータ 'request' は32ビットに収まる値に制限されます。 'request'
     引数として使うのに関係のある追加の定数は *note termios: ca. モジュ
     ールにあり、関連する C ヘッダファイルで使われているのと同じ名前が付
     けられています。

     パラメタ 'arg' は、整数、 (*note bytes: 1a4. のような) 読み出し専用
     のバッファインターフェースをサポートするオブジェクト、(*note
     bytearray: 508. のような) 読み書きバッファインターフェースをサポー
     トするオブジェクトのどれかです。

     最後の型のオブジェクトを除き、動作は *note fcntl(): 32f0. 関数と同
     じです。

     可変なバッファが渡された場合、動作は 'mutate_flag' 引数の値で決定さ
     れます。

     この値が偽の場合、バッファの可変性は無視され、読み出し専用バッファ
     の場合と同じ動作になりますが、上で述べた 1024 バイトの制限は回避さ
     れます - 従って、オペレーティングシステムが希望するバッファ長までで
     あれば正しく動作します。

     'mutate_flag' が真 (デフォルト) の場合、バッファは (実際には) 根底
     にある *note ioctl(): 141f. システムコールに渡され、後者の戻り値が
     呼び出し側の Python に引き渡され、バッファの新たな内容は *note
     ioctl(): 141f. の動作を反映します。この説明はやや単純化されています
     。というのは、与えられたバッファが 1024 バイト長よりも短い場合、バ
     ッファはまず 1024 バイト長の静的なバッファにコピーされてから *note
     ioctl(): 141f. に渡され、その後引数で与えたバッファに戻しコピーされ
     るからです。

     If the ‘ioctl()’ call fails, an *note OSError: 3f0. exception is
     raised.

     以下に例を示します:

          >>> import array, fcntl, struct, termios, os
          >>> os.getpgrp()
          13341
          >>> struct.unpack('h', fcntl.ioctl(0, termios.TIOCGPGRP, "  "))[0]
          13341
          >>> buf = array.array('h', [0])
          >>> fcntl.ioctl(0, termios.TIOCGPGRP, buf, 1)
          0
          >>> buf
          array('h', [13341])

     引数 ‘fd’, ‘request’, ‘arg’ を指定して *note 監査イベント: 1825.
     ‘fcntl.ioctl’ を送出します。

 -- の関数: fcntl.flock (fd, operation)

     ファイル記述子 'fd' (*note fileno(): 27a6. メソッドを提供しているフ
     ァイルオブジェクトも含む) に対してロック操作 'operation' を実行しま
     す。 詳細は Unix マニュアルの ‘flock(2)(3)’ を参照してください (シ
     ステムによっては、この関数は ‘fcntl()’ を使ってエミュレーションされ
     ています)。

     If the ‘flock()’ call fails, an *note OSError: 3f0. exception is
     raised.

     引数 ‘fd’, ‘operation’ を指定して *note 監査イベント: 1825.
     ‘fcntl.flock’ を送出します。

 -- の関数: fcntl.lockf (fd, cmd, len=0, start=0, whence=0)

     本質的に *note fcntl(): 32f0. によるロッキングの呼び出しをラップし
     たものです。 'fd' はロックまたはアンロックするファイルのファイル記
     述子 (*note fileno(): 27a6. メソッドを提供するファイルオブジェクト
     も受け付けられます) で、 'cmd' は以下の値のうちいずれかになります:

      -- データ: fcntl.LOCK_UN

          Release an existing lock.

      -- データ: fcntl.LOCK_SH

          Acquire a shared lock.

      -- データ: fcntl.LOCK_EX

          Acquire an exclusive lock.

      -- データ: fcntl.LOCK_NB

          Bitwise OR with any of the other three ‘LOCK_*’ constants to
          make the request non-blocking.

     If ‘LOCK_NB’ is used and the lock cannot be acquired, an *note
     OSError: 3f0. will be raised and the exception will have an 'errno'
     attribute set to *note EACCES: 2209. or *note EAGAIN: 21fa.
     (depending on the operating system; for portability, check for both
     values).  On at least some systems, ‘LOCK_EX’ can only be used if
     the file descriptor refers to a file opened for writing.

     'len' はロックを行いたいバイト数、 'start' はロック領域先頭の
     'whence' からの相対的なバイトオフセット、 'whence' は *note
     io.IOBase.seek(): 125d. と同じで、具体的には:

        * ‘0’ - relative to the start of the file (*note os.SEEK_SET:
          125e.)

        * ‘1’ - relative to the current buffer position (*note
          os.SEEK_CUR: 125f.)

        * ‘2’ - relative to the end of the file (*note os.SEEK_END:
          1260.)

     'start' の標準の値は 0 で、ファイルの先頭から開始することを意味しま
     す。'len' の標準の値は 0 で、ファイルの終了までロックすることを表し
     ます。'whence' の標準の値も 0 です。

     引数 ‘fd’, ‘cmd’, ‘len’, ‘start’, ‘whence’ を指定して *note
     監査イベント: 1825. ‘fcntl.lockf’ を送出します。

以下に (全ての SVR4 互換システムでの) 例を示します:

     import struct, fcntl, os

     f = open(...)
     rv = fcntl.fcntl(f, fcntl.F_SETFL, os.O_NDELAY)

     lockdata = struct.pack('hhllhh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
     rv = fcntl.fcntl(f, fcntl.F_SETLKW, lockdata)

最初の例では、戻り値 'rv' は整数値を保持しています; 二つ目の例では *note
bytes: 1a4. オブジェクトを保持しています。 'lockdata' 変数の構造体レイア
ウトはシステム依存です -- 従って *note flock(): 4064. を呼ぶ方が良いでし
ょう。

参考
....

*note os: 91. モジュール

     If the locking flags *note O_SHLOCK: 13d6. and *note O_EXLOCK:
     13d7. are present in the *note os: 91. module (on BSD only), the
     *note os.open(): d5f. function provides an alternative to the *note
     lockf(): 1394. and *note flock(): 4064. functions.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/fcntl(2)

   (2) https://manpages.debian.org/ioctl(2)

   (3) https://manpages.debian.org/flock(2)


File: python.info,  Node: resource --- リソース使用情報,  Next: syslog --- Unix syslog ライブラリルーチン群,  Prev: fcntl --- fcntl および ioctl システムコール,  Up: Unix 固有のサービス

5.34.8 ‘resource’ -- リソース使用情報
-------------------------------------

__________________________________________________________________

このモジュールでは、プログラムによって使用されているシステムリソースを計
測したり制御するための基本的なメカニズムを提供します。

*note Availability: 1cbe.: Unix, not WASI.

特定のシステムリソースを指定したり、現在のプロセスやその子プロセスのリソ
ース使用情報を要求するためにシンボル定数が使われます。

システムコールが失敗した場合 *note OSError: 3f0. を送出します。

 -- 例外: resource.error

     *note OSError: 3f0. の非推奨のエイリアスです。

     バージョン 3.3 で変更: PEP 3151(1) に基づき、このクラスは *note
     OSError: 3f0. のエイリアスになりました。

* Menu:

* リソースの制限::
* リソースの使用状態::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3151/


File: python.info,  Node: リソースの制限,  Next: リソースの使用状態,  Up: resource --- リソース使用情報

5.34.8.1 リソースの制限
.......................

リソースの使用は下に述べる *note setrlimit(): 4007. 関数を使って制限する
ことができます。各リソースは二つ組の制限値: ソフトリミット (soft limit)
、およびハードリミット (hard limit) 、で制御されます。ソフトリミットは現
在の制限値で、時間とともにプロセスによって下げたり上げたりできます。ソフ
トリミットはハードリミットを超えることはできません。ハードリミットはソフ
トリミットよりも高い任意の値まで下げることができますが、上げることはでき
ません。 (スーパユーザの有効な UID を持つプロセスのみがハードリミットを
上げることができます。)

制限をかけるべく指定できるリソースはシステムに依存します。指定できるリソ
ースは ‘getrlimit(2)(1)’ マニュアルページで解説されています。以下に列挙
するリソースは背後のオペレーティングシステムがサポートする場合にサポート
されています; オペレーティングシステム側で値を調べたり制御したりできない
リソースは、そのプラットフォーム向けのこのモジュール内では定義されていま
せん。

 -- データ: resource.RLIM_INFINITY

     無制限のリソースの上限を示すための定数です。

 -- の関数: resource.getrlimit (resource)

     'resource' の現在のソフトおよびハードリミットを表すタプル ‘(soft,
     hard)’ を返します。無効なリソースが指定された場合には *note
     ValueError: 1e3. が、背後のシステムコールが予期せず失敗した場合には
     *note error: 467d. が送出されます。

 -- の関数: resource.setrlimit (resource, limits)

     'resource' の新たな消費制限を設定します。 'limits' 引数には、タプル
     ‘(soft, hard)’ による二つの整数で、新たな制限を記述しなければなりま
     せん。 *note RLIM_INFINITY: 467f. を指定することで、無制限を要求す
     ることが出来ます。

     無効なリソースが指定された場合、ソフトリミットの値がハードリミット
     の値を超えている場合、プロセスがハードリミットを引き上げようとした
     場合には *note ValueError: 1e3. が送出されます。リソースのハードリ
     ミットやシステムリミットが無制限でないのに *note RLIM_INFINITY:
     467f. を指定した場合も、 *note ValueError: 1e3. になります。スーパ
     ーユーザの実効 UID を持ったプロセスは無制限を含めあらゆる妥当な制限
     値を要求出来ますが、システムが課している制限を超過した要求ではやは
     り *note ValueError: 1e3. となります。

     ‘setrlimit’ は背後のシステムコールが予期せず失敗した場合に、 *note
     error: 467d. を送出する場合があります。

     VxWorks only supports setting *note RLIMIT_NOFILE: 4681.

     引数 ‘src’, ‘dst`, ``limits’ を指定して *note 監査イベント: 1825.
     ‘resource.setrlimit’ を送出します。

 -- の関数: resource.prlimit (pid, resource[, limits])

     1つの関数の中で *note setrlimit(): 4007. と *note getrlimit():
     4680. を組み合わせ、任意のプロセスのリソースの制限値を取得したり設
     定したりします。 'pid' が 0 の場合は、現在のプロセスに適用されます
     。 'resource' および 'limits' は、 'limits' がオプションであること
     を除けば、 *note setrlimit(): 4007. と同じ意味です。

     'limits' が与えられないときは、関数はプロセス 'pid' の 'resource' の
     制限値を返します。 'limits' が与えられたときは、プロセスの
     'resource' の制限値が設定され、設定が変更される前のリソースの制限値
     が返されます。

     'pid' が見付からないときは *note ProcessLookupError: 102f. を、ユー
     ザがプロセスの ‘CAP_SYS_RESOURCE’ を持ってないときは *note
     PermissionError: d10. を送出します。

     引数 ‘pid’, ‘dst`, ``limits’ を指定して *note 監査イベント: 1825.
     ‘resource.prlimit’ を送出します。

     *note Availability: 1cbe.: Linux >= 2.6.36 with glibc >= 2.13.

     Added in version 3.4.

以下のシンボルは、後に述べる関数 *note setrlimit(): 4007. および *note
getrlimit(): 4680. を使って消費量を制御することができるリソースを定義し
ています。これらのシンボルの値は、C プログラムで使われているシンボルと全
く同じです。

‘getrlimit(2)(2)’ の Unix マニュアルページには、指定可能なリソースが列挙
されています。全てのシステムで同じシンボルが使われているわけではなく、ま
た同じリソースを表すために同じ値が使われているとも限らないので注意してく
ださい。このモジュールはプラットフォーム間の相違を隠蔽しようとはしていま
せん -- あるプラットフォームで定義されていないシンボルは、そのプラットフ
ォーム向けの本モジュールでは利用することができません。

 -- データ: resource.RLIMIT_CORE

     現在のプロセスが生成できるコアファイルの最大 (バイト) サイズです。
     プロセスの全体イメージを入れるためにこの値より大きなサイズのコアフ
     ァイルが要求された結果、部分的なコアファイルが生成される可能性があ
     ります。

 -- データ: resource.RLIMIT_CPU

     プロセッサが利用することができる最大プロセッサ時間 (秒) です。この
     制限を超えた場合、 ‘SIGXCPU’ シグナルがプロセスに送られます。 (どの
     ようにしてシグナルを捕捉したり、例えば開かれているファイルをディス
     クにフラッシュするといった有用な処理を行うかについての情報は、
     *note signal: b4. モジュールのドキュメントを参照してください)

 -- データ: resource.RLIMIT_FSIZE

     プロセスが作成するファイルの最大サイズです。

 -- データ: resource.RLIMIT_DATA

     プロセスのヒープの最大 (バイト) サイズです。

 -- データ: resource.RLIMIT_STACK

     現在のプロセスのコールスタックの最大サイズ (バイト単位) です。 これ
     はマルチスレッドプロセスのメインスレッドのスタックのみに影響します
     。

 -- データ: resource.RLIMIT_RSS

     プロセスが取りうる最大 RAM 常駐ページサイズ (resident set size) で
     す。

 -- データ: resource.RLIMIT_NPROC

     現在のプロセスが生成できるプロセスの上限です。

 -- データ: resource.RLIMIT_NOFILE

     現在のプロセスが開けるファイル記述子の上限です。

 -- データ: resource.RLIMIT_OFILE

     *note RLIMIT_NOFILE: 4681. の BSD での名称です。

 -- データ: resource.RLIMIT_MEMLOCK

     メモリ中でロックできる最大アドレス空間です。

 -- データ: resource.RLIMIT_VMEM

     プロセスが占有できるマップメモリの最大領域です。

     *note Availability: 1cbe.: FreeBSD >= 11.

 -- データ: resource.RLIMIT_AS

     アドレス空間でプロセスが占有できる最大領域 (バイト単位) です。

 -- データ: resource.RLIMIT_MSGQUEUE

     POSIX メッセージキューに割り当てることの出来るバイト数です。

     *note Availability: 1cbe.: Linux >= 2.6.8.

     Added in version 3.4.

 -- データ: resource.RLIMIT_NICE

     プロセスの nice の上限です (20 - rlim_cur)。

     *note Availability: 1cbe.: Linux >= 2.6.12.

     Added in version 3.4.

 -- データ: resource.RLIMIT_RTPRIO

     リアルタイム優先順位の上限です。

     *note Availability: 1cbe.: Linux >= 2.6.12.

     Added in version 3.4.

 -- データ: resource.RLIMIT_RTTIME

     リアルタイムスケジューリングにおいて、プロセスがブロッキングシステ
     ムコールを行わずに使用できるCPU時間の制限値（マイクロ秒単位）。

     *note Availability: 1cbe.: Linux >= 2.6.25.

     Added in version 3.4.

 -- データ: resource.RLIMIT_SIGPENDING

     プロセスがキュー出来るシグナルの数です。

     *note Availability: 1cbe.: Linux >= 2.6.8.

     Added in version 3.4.

 -- データ: resource.RLIMIT_SBSIZE

     このユーザが使用するソケットバッファの最大サイズ(バイト単位)。これ
     は、このユーザが常に保持できるネットワークメモリの量、つまり mbuf の
     量を制限します。

     *note Availability: 1cbe.: FreeBSD.

     Added in version 3.4.

 -- データ: resource.RLIMIT_SWAP

     このユーザ ID のすべてのプロセスで予約または使用できるスワップスペ
     ースの最大サイズ (バイト単位)。この制限は vm.overcommit sysctl のビ
     ット 1 が設定されている場合のみ適用されます。この sysctl の完全な説
     明については tuning(7)(3) を参照してください。

     *note Availability: 1cbe.: FreeBSD.

     Added in version 3.4.

 -- データ: resource.RLIMIT_NPTS

     このユーザ ID が作成する擬似端末の数の上限です。

     *note Availability: 1cbe.: FreeBSD.

     Added in version 3.4.

 -- データ: resource.RLIMIT_KQUEUES

     The maximum number of kqueues this user id is allowed to create.

     *note Availability: 1cbe.: FreeBSD >= 11.

     Added in version 3.10.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/getrlimit(2)

   (2) https://manpages.debian.org/getrlimit(2)

   (3) https://man.freebsd.org/cgi/man.cgi?query=tuning&sektion=7


File: python.info,  Node: リソースの使用状態,  Prev: リソースの制限,  Up: resource --- リソース使用情報

5.34.8.2 リソースの使用状態
...........................

以下の関数はリソース使用情報を取得するために使われます:

 -- の関数: resource.getrusage (who)

     This function returns an object that describes the resources
     consumed by either the current process or its children, as
     specified by the 'who' parameter.  The 'who' parameter should be
     specified using one of the ‘RUSAGE_*’ constants described below.

     簡単な例:

          from resource import *
          import time

          # a non CPU-bound task
          time.sleep(3)
          print(getrusage(RUSAGE_SELF))

          # a CPU-bound task
          for i in range(10 ** 8):
             _ = 1 + 1
          print(getrusage(RUSAGE_SELF))

     返される値の各フィールドはそれぞれ、個々のシステムリソースがどれく
     らい使用されているか、例えばユーザモードでの実行に費やされた時間や
     プロセスが主記憶からスワップアウトされた回数、を示しています。幾つ
     かの値、例えばプロセスが使用しているメモリ量は、内部時計の最小単位
     に依存します。

     以前のバージョンとの互換性のため、返される値は 16 要素からなるタプ
     ルとしてアクセスすることもできます。

     The fields ‘ru_utime’ and ‘ru_stime’ of the return value are
     floating-point values representing the amount of time spent
     executing in user mode and the amount of time spent executing in
     system mode, respectively.  The remaining values are integers.
     Consult the ‘getrusage(2)(1)’ man page for detailed information
     about these values.  A brief summary is presented here:

     インデック   フィールド                リソース
     ス                                     

     -----------------------------------------------------------------------------------
                                            
     ‘0’          ‘ru_utime’                time in user mode (float seconds)
                                            
                                            
     ‘1’          ‘ru_stime’                time in system mode (float seconds)
                                            
                                            
     ‘2’          ‘ru_maxrss’               最大常駐ページサイズ
                                            
                                            
     ‘3’          ‘ru_ixrss’                共有メモリサイズ
                                            
                                            
     ‘4’          ‘ru_idrss’                非共有メモリサイズ
                                            
                                            
     ‘5’          ‘ru_isrss’                非共有スタックサイズ
                                            
                                            
     ‘6’          ‘ru_minflt’               I/O を必要としないページフォールト数
                                            
                                            
     ‘7’          ‘ru_majflt’               I/O を必要とするページフォールト数
                                            
                                            
     ‘8’          ‘ru_nswap’                スワップアウト回数
                                            
                                            
     ‘9’          ‘ru_inblock’              ブロック入力操作数
                                            
                                            
     ‘10’         ‘ru_oublock’              ブロック出力操作数
                                            
                                            
     ‘11’         ‘ru_msgsnd’               送信メッセージ数
                                            
                                            
     ‘12’         ‘ru_msgrcv’               受信メッセージ数
                                            
                                            
     ‘13’         ‘ru_nsignals’             受信シグナル数
                                            
                                            
     ‘14’         ‘ru_nvcsw’                自発的な実行コンテキスト切り替え数
                                            
                                            
     ‘15’         ‘ru_nivcsw’               非自発的な実行コンテキスト切り替え数
                                            

     この関数は無効な 'who' 引数を指定した場合には *note ValueError:
     1e3. を送出します。また、異常が発生した場合には *note error: 467d.
     例外が送出される可能性があります。

 -- の関数: resource.getpagesize ()

     システムページ内のバイト数を返します。(ハードウェアページサイズと同
     じとは限りません。)

The following ‘RUSAGE_*’ symbols are passed to the *note getrusage():
13d8. function to specify which processes information should be provided
for.

 -- データ: resource.RUSAGE_SELF

     *note getrusage(): 13d8. に渡すと呼び出し中のプロセスが消費している
     リソースを要求します。そのプロセスの全スレッドが使用するリソースの
     合計です。

 -- データ: resource.RUSAGE_CHILDREN

     呼び出し元のプロセスの子プロセスが消費するリソースを要求するために
     、 *note getrusage(): 13d8. に渡して終了させ、待機させることができ
     ます。

 -- データ: resource.RUSAGE_BOTH

     *note getrusage(): 13d8. に渡すと現在のプロセスおよび子プロセスの両
     方が消費しているリソースを要求します。全てのシステムで利用可能なわ
     けではありません。

 -- データ: resource.RUSAGE_THREAD

     *note getrusage(): 13d8. に渡すと現在のスレッドが消費しているリソー
     スを要求します。全てのシステムで利用可能なわけではありません。

     Added in version 3.2.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/getrusage(2)


File: python.info,  Node: syslog --- Unix syslog ライブラリルーチン群,  Prev: resource --- リソース使用情報,  Up: Unix 固有のサービス

5.34.9 ‘syslog’ -- Unix syslog ライブラリルーチン群
---------------------------------------------------

__________________________________________________________________

このモジュールでは Unix ‘syslog’ ライブラリルーチン群へのインターフェー
スを提供します。‘syslog’ の便宜レベルに関する詳細な記述は Unix マニュア
ルページを参照してください。

*note Availability: 1cbe.: Unix, not WASI, not iOS.

このモジュールはシステムの ‘syslog’ ファミリのルーチンをラップしています
。 syslog サーバーと通信できる pure Python のライブラリが、 *note
logging.handlers: 7d. モジュールの *note SysLogHandler: 628. にあります
。

このモジュールには、以下の関数が定義されています:

 -- の関数: syslog.syslog (message)

 -- の関数: syslog.syslog (priority, message)

     文字列 'message' をシステムログ機構に送信します。末尾の改行文字は必
     要に応じて追加されます。各メッセージは 'facility' および 'level' か
     らなる優先度でタグ付けされます。オプションの 'priority' 引数はメッ
     セージの優先度を定義します。標準の値は *note LOG_INFO: 4694. です。
     'priority' 中に、便宜レベルが (‘LOG_INFO | LOG_USER’ のように) 論理
     和を使ってコード化されていない場合、 *note openlog(): 509. を呼び出
     した際の値が使われます。

     *note syslog(): c6. が呼び出される前に *note openlog(): 509. が呼び
     出されなかった場合、 *note openlog(): 509. が引数なしで呼び出されま
     す。

     引数 ‘priority’, ‘message’ を指定して *note 監査イベント: 1825.
     ‘syslog.syslog’ を送出します。

     バージョン 3.2 で変更: In previous versions, *note openlog(): 509.
     would not be called automatically if it wasn't called prior to the
     call to *note syslog(): c6, deferring to the syslog implementation
     to call ‘openlog()’.

     バージョン 3.12 で変更: This function is restricted in
     subinterpreters.  (Only code that runs in multiple interpreters is
     affected and the restriction is not relevant for most users.)
     *note openlog(): 509. must be called in the main interpreter before
     *note syslog(): c6. may be used in a subinterpreter.  Otherwise it
     will raise *note RuntimeError: 17a.

 -- の関数: syslog.openlog ([ident[, logoption[, facility]]])

     *note openlog(): 509. 関数を呼び出すことで以降の *note syslog():
     c6. の呼び出しに対するログオプションを設定することができます。ログ
     がまだ開かれていない状態で *note syslog(): c6. を呼び出すと *note
     openlog(): 509. が引数なしで呼び出されます。

     オプションの 'ident' キーワード引数は全てのメッセージの先頭に付く文
     字列で、デフォルトでは ‘sys.argv[0]’ から前方のパス部分を取り除いた
     ものです。オプションの 'logoption' キーワード引数 (デフォルトは 0)
     はビットフィールドです。組み合わせられる値については下記を参照して
     ください。オプションの 'facility' キーワード引数 (デフォルトは
     *note LOG_USER: 4695.) は明示的に facility が encode されていないメ
     ッセージに設定される facility です。

     引数 ‘ident’, ‘logoptiona'’, ‘facility’ を指定して *note
     監査イベント: 1825. ‘syslog.openlog’ を送出します。

     バージョン 3.2 で変更: In previous versions, keyword arguments were
     not allowed, and 'ident' was required.

     バージョン 3.12 で変更: This function is restricted in
     subinterpreters.  (Only code that runs in multiple interpreters is
     affected and the restriction is not relevant for most users.)  This
     may only be called in the main interpreter.  It will raise *note
     RuntimeError: 17a. if called in a subinterpreter.

 -- の関数: syslog.closelog ()

     syslog モジュールの値をリセットし、システムライブラリの
     ‘closelog()’ を呼び出します。

     この関数を呼ぶと、モジュールが最初に import されたときと同じように
     ふるまいます。例えば、(*note openlog(): 509. を呼び出さないで)
     *note syslog(): c6. を最初に呼び出したときに、 *note openlog():
     509. が呼び出され、 'ident' やその他の *note openlog(): 509. の引数
     はデフォルト値にリセットされます。

     引数無しで *note 監査イベント: 1825. ‘syslog.closelog’ を送出します
     。

     バージョン 3.12 で変更: This function is restricted in
     subinterpreters.  (Only code that runs in multiple interpreters is
     affected and the restriction is not relevant for most users.)  This
     may only be called in the main interpreter.  It will raise *note
     RuntimeError: 17a. if called in a subinterpreter.

 -- の関数: syslog.setlogmask (maskpri)

     優先度マスクを 'maskpri' に設定し、以前のマスク値を返します。
     'maskpri' に設定されていない優先度レベルを持った *note syslog():
     c6. の呼び出しは無視されます。標準では全ての優先度をログ出力します
     。関数 ‘LOG_MASK(pri)’ は個々の優先度 'pri' に対する優先度マスクを
     計算します。関数 ‘LOG_UPTO(pri)’ は優先度 'pri' までの全ての優先度
     を含むようなマスクを計算します。

     引数 ‘maskpri’ を指定して *note 監査イベント: 1825.
     ‘socket.setlogmask’ を送出します。

このモジュールでは以下の定数を定義しています:

 -- データ: syslog.LOG_EMERG
 -- データ: syslog.LOG_ALERT
 -- データ: syslog.LOG_CRIT
 -- データ: syslog.LOG_ERR
 -- データ: syslog.LOG_WARNING
 -- データ: syslog.LOG_NOTICE
 -- データ: syslog.LOG_INFO
 -- データ: syslog.LOG_DEBUG

     優先度 (高いものから低いもの) 。

 -- データ: syslog.LOG_AUTH
 -- データ: syslog.LOG_AUTHPRIV
 -- データ: syslog.LOG_CRON
 -- データ: syslog.LOG_DAEMON
 -- データ: syslog.LOG_FTP
 -- データ: syslog.LOG_INSTALL
 -- データ: syslog.LOG_KERN
 -- データ: syslog.LOG_LAUNCHD
 -- データ: syslog.LOG_LPR
 -- データ: syslog.LOG_MAIL
 -- データ: syslog.LOG_NETINFO
 -- データ: syslog.LOG_NEWS
 -- データ: syslog.LOG_RAS
 -- データ: syslog.LOG_REMOTEAUTH
 -- データ: syslog.LOG_SYSLOG
 -- データ: syslog.LOG_USER
 -- データ: syslog.LOG_UUCP
 -- データ: syslog.LOG_LOCAL0
 -- データ: syslog.LOG_LOCAL1
 -- データ: syslog.LOG_LOCAL2
 -- データ: syslog.LOG_LOCAL3
 -- データ: syslog.LOG_LOCAL4
 -- データ: syslog.LOG_LOCAL5
 -- データ: syslog.LOG_LOCAL6
 -- データ: syslog.LOG_LOCAL7

     Facilities, depending on availability in ‘<syslog.h>’ for *note
     LOG_AUTHPRIV: 469e, *note LOG_FTP: 46a1, *note LOG_NETINFO: 46a7,
     *note LOG_REMOTEAUTH: 46aa, *note LOG_INSTALL: 46a2. and *note
     LOG_RAS: 46a9.

     バージョン 3.13 で変更: Added *note LOG_FTP: 46a1, *note
     LOG_NETINFO: 46a7, *note LOG_REMOTEAUTH: 46aa, *note LOG_INSTALL:
     46a2, *note LOG_RAS: 46a9, and *note LOG_LAUNCHD: 46a4.

 -- データ: syslog.LOG_PID
 -- データ: syslog.LOG_CONS
 -- データ: syslog.LOG_NDELAY
 -- データ: syslog.LOG_ODELAY
 -- データ: syslog.LOG_NOWAIT
 -- データ: syslog.LOG_PERROR

     Log options, depending on availability in ‘<syslog.h>’ for *note
     LOG_ODELAY: 46b8, *note LOG_NOWAIT: 46b9. and *note LOG_PERROR:
     46ba.

* Menu:

* 使用例: 使用例<52>.


File: python.info,  Node: 使用例<52>,  Up: syslog --- Unix syslog ライブラリルーチン群

5.34.9.1 使用例
...............

* Menu:

* シンプルな例::


File: python.info,  Node: シンプルな例,  Up: 使用例<52>

5.34.9.2 シンプルな例
.....................

1つ目のシンプルな例:

     import syslog

     syslog.syslog('Processing started')
     if error:
         syslog.syslog(syslog.LOG_ERR, 'Processing started')

いくつかのログオプションを設定する例。ログメッセージにプロセスIDを含み、
メッセージをメールのログ用の facility にメッセージを書きます:

     syslog.openlog(logoption=syslog.LOG_PID, facility=syslog.LOG_MAIL)
     syslog.syslog('E-mail processing initiated...')


File: python.info,  Node: モジュールのコマンドラインインターフェース CLI,  Next: 取って代わられたモジュール群,  Prev: Unix 固有のサービス,  Up: Python 標準ライブラリ

5.35 モジュールのコマンドラインインターフェース (CLI)
=====================================================

以下のモジュールにはコマンドラインインターフェースがあります。

   * *note ast: 449c.

   * *note asyncio: 312c.

   * *note base64: a.

   * *note calendar: 243e.

   * *note code: 13.

   * *note compileall: 4559.

   * *note cProfile: 20.: *note profile: 40f8. を参照

   * *note difflib: 2291.

   * *note dis: 456f.

   * *note doctest: 31.

   * ‘encodings.rot_13’

   * *note ensurepip: 4b.

   * *note filecmp: 50.

   * *note fileinput: 51.

   * *note ftplib: 54.

   * *note gzip: 28c2.

   * *note http.server: f1e.

   * ‘idlelib’

   * *note inspect: f28.

   * *note json.tool: 350a.

   * *note mimetypes: 82.

   * *note pdb: 94.

   * *note pickle: 95.

   * *note pickletools: 45da.

   * *note platform: 98.

   * *note poplib: 9a.

   * *note profile: 40f8.

   * *note pstats: 9e.

   * *note py_compile: 4551.

   * *note pyclbr: a2.

   * *note pydoc: a3.

   * *note quopri: a5.

   * *note random: 13a.

   * *note runpy: ac.

   * *note site: 4347.

   * *note sqlite3: 40d.

   * *note symtable: 44d1.

   * *note sysconfig: 4251.

   * *note tabnanny: c7.

   * *note tarfile: f98.

   * ‘this’

   * *note timeit: 4118.

   * *note tokenize: 4525.

   * *note trace: 4134.

   * *note turtledemo: eb.

   * *note unittest: f01.

   * *note uuid: 410.

   * *note venv: f9.

   * *note webbrowser: fd.

   * *note zipapp: 41b1.

   * *note zipfile: 2930.

*note Python コマンドラインインターフェース: 192a. も参照してください。


File: python.info,  Node: 取って代わられたモジュール群,  Next: セキュリティで考慮すべき点<6>,  Prev: モジュールのコマンドラインインターフェース CLI,  Up: Python 標準ライブラリ

5.36 取って代わられたモジュール群
=================================

この章に記述されたモジュール群は非推奨またはソフト非推奨 (*note soft
deprecated: 1ea.) で、後方互換性のためにのみ保存されています。これらは他
のモジュール群に取って代わられました。

* Menu:

* getopt: getopt --- C-style parser for command line options. C-style parser for command line options
* optparse: optparse --- Parser for command line options. Parser for command line options


File: python.info,  Node: getopt --- C-style parser for command line options,  Next: optparse --- Parser for command line options,  Up: 取って代わられたモジュール群

5.36.1 ‘getopt’ -- C-style parser for command line options
----------------------------------------------------------

'ソースコード:' Lib/getopt.py(1)

バージョン 3.13 で非推奨: The *note getopt: 57. module is *note soft
deprecated: 1ea. and will not be developed further; development will
continue with the *note argparse: 5. module.

     注釈: The *note getopt: 57. module is a parser for command line
     options whose API is designed to be familiar to users of the C
     ‘getopt()’ function.  Users who are unfamiliar with the C
     ‘getopt()’ function or who would like to write less code and get
     better help and error messages should consider using the *note
     argparse: 5. module instead.

__________________________________________________________________

This module helps scripts to parse the command line arguments in
‘sys.argv’.  It supports the same conventions as the Unix ‘getopt()’
function (including the special meanings of arguments of the form '‘-’'
and '‘--’').  Long options similar to those supported by GNU software
may be used as well via an optional third argument.

このモジュールは2つの関数と1つの例外を提供しています:

 -- の関数: getopt.getopt (args, shortopts, longopts=[])

     Parses command line options and parameter list.  'args' is the
     argument list to be parsed, without the leading reference to the
     running program.  Typically, this means ‘sys.argv[1:]’.
     'shortopts' is the string of option letters that the script wants
     to recognize, with options that require an argument followed by a
     colon (‘':'’; i.e., the same format that Unix ‘getopt()’ uses).

          注釈: Unlike GNU ‘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.

     'longopts' は長形式のオプションの名前を示す文字列のリストです。名前
     には、先頭の ‘'--'’ は含めません。引数が必要な場合には名前の最後に
     等号 (‘'='’) を入れます。オプション引数はサポートしていません。長形
     式のオプションだけを受けつけるためには、'shortopts' は空文字列であ
     る必要があります。長形式のオプションは、該当するオプションを一意に
     決定できる長さまで入力されていれば認識されます。たとえば、
     'longopts' が ‘['foo', 'frob']’ の場合、‘--fo’ は ‘--foo’ にマッチ
     しますが、‘--f’ では一意に決定できないので、*note GetoptError:
     46c4. が送出されます。

     返り値は2つの要素から成っています: 最初は ‘(option, value)’ のタプ
     ルのリスト、2つ目はオプションリストを取り除いたあとに残ったプログラ
     ムの引数リストです ('args' の末尾部分のスライスになります)。それぞ
     れの引数と値のタプルの最初の要素は、短形式の時はハイフン 1つで始ま
     る文字列 (例: ‘'-x'’)、長形式の時はハイフン2つで始まる文字列 (例:
     ‘'--long-option'’) となり、引数が2番目の要素になります。引数をとら
     ない場合には空文字列が入ります。オプションは見つかった順に並んでい
     て、複数回同じオプションを指定できます。長形式と短形式のオプション
     は混在できます。

 -- の関数: getopt.gnu_getopt (args, shortopts, longopts=[])

     この関数はデフォルトで GNU スタイルのスキャンモードを使う以外は
     *note getopt(): 57. と同じように動作します。つまり、オプションとオ
     プションでない引数とを混在させることができます。*note getopt(): 57.
     関数はオプションでない引数を見つけると解析を停止します。

     If the first character of the option string is ‘'+'’, or if the
     environment variable ‘POSIXLY_CORRECT’ is set, then option
     processing stops as soon as a non-option argument is encountered.

 -- 例外: getopt.GetoptError

     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 exception is a string indicating the cause of the
     error.  For long options, an argument given to an option which does
     not require one will also cause this exception to be raised.  The
     attributes ‘msg’ and ‘opt’ give the error message and related
     option; if there is no specific option to which the exception
     relates, ‘opt’ is an empty string.

 -- 例外: getopt.error

     *note GetoptError: 46c4. へのエイリアスです。後方互換性のために残さ
     れています。

Unix スタイルのオプションを使った例です:

     >>> import getopt
     >>> args = '-a -b -cfoo -d bar a1 a2'.split()
     >>> args
     ['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
     >>> optlist, args = getopt.getopt(args, 'abc:d:')
     >>> optlist
     [('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
     >>> args
     ['a1', 'a2']

長形式のオプションを使っても同様です:

     >>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
     >>> args = s.split()
     >>> args
     ['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', 'a2']
     >>> optlist, args = getopt.getopt(args, 'x', [
     ...     'condition=', 'output-file=', 'testing'])
     >>> optlist
     [('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-x', '')]
     >>> args
     ['a1', 'a2']

In a script, typical usage is something like this:

     import getopt, sys

     def main():
         try:
             opts, args = getopt.getopt(sys.argv[1:], "ho:v", ["help", "output="])
         except getopt.GetoptError as err:
             # print help information and exit:
             print(err)  # will print something like "option -a not recognized"
             usage()
             sys.exit(2)
         output = None
         verbose = False
         for o, a in opts:
             if o == "-v":
                 verbose = True
             elif o in ("-h", "--help"):
                 usage()
                 sys.exit()
             elif o in ("-o", "--output"):
                 output = a
             else:
                 assert False, "unhandled option"
         # ...

     if __name__ == "__main__":
         main()

Note that an equivalent command line interface could be produced with
less code and more informative help and error messages by using the
*note argparse: 5. module:

     import argparse

     if __name__ == '__main__':
         parser = argparse.ArgumentParser()
         parser.add_argument('-o', '--output')
         parser.add_argument('-v', dest='verbose', action='store_true')
         args = parser.parse_args()
         # ... do something with args.output ...
         # ... do something with args.verbose ..

参考
....

*note argparse: 5. モジュール

     別のコマンドラインオプションと引数の解析ライブラリ。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/getopt.py


File: python.info,  Node: optparse --- Parser for command line options,  Prev: getopt --- C-style parser for command line options,  Up: 取って代わられたモジュール群

5.36.2 ‘optparse’ -- Parser for command line options
----------------------------------------------------

'ソースコード:' Lib/optparse.py(1)

バージョン 3.2 で非推奨: *note optparse: 90. モジュールは *note soft
deprecated: 1ea. であり、これ以上の開発は行われません。*note argparse:
5. モジュールを使用してください。

__________________________________________________________________

*note optparse: 90. モジュールは、昔からある *note getopt: 57. よりも簡
便で、柔軟性に富み、かつ強力なコマンドライン解析ライブラリです。 *note
optparse: 90. では、より宣言的なスタイルのコマンドライン解析手法、すなわ
ち *note OptionParser: 1476. のインスタンスを作成してオプションを追加し
てゆき、そのインスタンスでコマンドラインを解析するという手法をとっていま
す。 *note optparse: 90. を使うと、GNU/POSIX 構文でオプションを指定でき
るだけでなく、使用法やヘルプメッセージの生成も行えます。

*note optparse: 90. を使った簡単なスクリプトの例を以下に示します:

     from optparse import OptionParser
     ...
     parser = OptionParser()
     parser.add_option("-f", "--file", dest="filename",
                       help="write report to FILE", metavar="FILE")
     parser.add_option("-q", "--quiet",
                       action="store_false", dest="verbose", default=True,
                       help="don't print status messages to stdout")

     (options, args) = parser.parse_args()

このようにわずかな行数のコードによって、スクリプトのユーザはコマンドライ
ン上で例えば以下のような「よくある使い方」を実行できるようになります:

     <yourscript> --file=outfile -q

コマンドライン解析の中で、 *note optparse: 90. はユーザの指定したコマン
ドライン引数値に応じて *note parse_args(): 1477. の返す ‘options’ の属性
値を設定してゆきます。 *note parse_args(): 1477. がコマンドライン解析か
ら処理を戻したとき、 ‘options.filename’ は ‘"outfile"’ に、
‘options.verbose’ は ‘False’ になっているはずです。 *note optparse: 90.
は長い形式と短い形式の両方のオプション表記をサポートしており、短い形式は
結合して指定できます。また、様々な形でオプションに引数値を関連付けられま
す。従って、以下のコマンドラインは全て上の例と同じ意味になります:

     <yourscript> -f outfile --quiet
     <yourscript> --quiet --file outfile
     <yourscript> -q -foutfile
     <yourscript> -qfoutfile

さらに、ユーザが以下のいずれかを実行すると

     <yourscript> -h
     <yourscript> --help

*note optparse: 90. はスクリプトのオプションについて簡単にまとめた内容を
出力します:

     Usage: <yourscript> [options]

     Options:
       -h, --help            show this help message and exit
       -f FILE, --file=FILE  write report to FILE
       -q, --quiet           don't print status messages to stdout

'yourscript' の中身は実行時に決まります (通常は ‘sys.argv[0]’ になります
)。

* Menu:

* 背景::
* チュートリアル: チュートリアル<4>.
* リファレンスガイド::
* オプション処理コールバック::
* optparse の拡張::
* 例外: 例外<20>.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Lib/optparse.py


File: python.info,  Node: 背景,  Next: チュートリアル<4>,  Up: optparse --- Parser for command line options

5.36.2.1 背景
.............

*note optparse: 90. は、素直で慣習に則ったコマンドラインインターフェース
を備えたプログラムの作成を援助する目的で設計されました。その結果、Unix で
慣習的に使われているコマンドラインの構文や機能だけをサポートするに留まっ
ています。こうした慣習に詳しくなければ、よく知っておくためにもこの節を読
んでおきましょう。

* Menu:

* 用語集::
* オプションとは何か::
* 位置引数とは何か::


File: python.info,  Node: 用語集,  Next: オプションとは何か,  Up: 背景

5.36.2.2 用語集
...............

引数 (argument)

     コマンドラインでユーザが入力するテキストの塊で、シェルが ‘execl’ や
     ‘execv’ に引き渡すものです。Python では、引数は ‘sys.argv[1:]’ の要
     素となります。(‘sys.argv[0]’ は実行しようとしているプログラムの名前
     です。引数解析に関しては、この要素はあまり重要ではありません。)
     Unix シェルでは、「語 (word)」という用語も使います。

     場合によっては ‘sys.argv[1:]’ 以外の引数リストを代入する方が望まし
     いことがあるので、「引数」は「 ‘sys.argv[1:]’ または ‘sys.argv[1:]’
     の代替として提供される別のリストの要素」と読むべきでしょう。

オプション (option)

     追加的な情報を与えるための引数で、プログラムの実行に対する教示やカ
     スタマイズを行います。オプションには多様な文法が存在します。伝統的
     な Unix における書法はハイフン ("-") の後ろに一文字が続くもので、例
     えば ‘-x’ や ‘-F’ です。また、伝統的な Unix における書法では、複数
     のオプションを一つの引数にまとめられます。例えば ‘-x -F’ は ‘-xF’ と
     等価です。 GNU プロジェクトでは ‘--’ の後ろにハイフンで区切りの語を
     指定する方法、例えば ‘--file’ や ‘--dry-run’ も提供しています。
     *note optparse: 90. は、これら二種類のオプション書法だけをサポート
     しています。

     他に見られる他のオプション書法には以下のようなものがあります:

        * ハイフンの後ろに数個の文字が続くもので、例えば ‘-pf’ (このオプ
          ションは複数のオプションを一つにまとめたものとは '違います')

        * ハイフンの後ろに語が続くもので、例えば ‘-file’ (これは技術的に
          は上の書式と同じですが、通常同じプログラム上で一緒に使うことは
          ありません)

        * プラス記号の後ろに一文字、数個の文字、または語を続けたもので、
          例えば ‘+f’, ‘+rgb’

        * スラッシュ記号の後ろに一文字、数個の文字、または語を続けたもの
          で、例えば ‘/f’, ‘/file’

     上記のオプション書法は *note optparse: 90. ではサポートしておらず、
     今後もサポートする予定はありません。これは故意によるものです: 最初
     の三つはどの環境の標準でもなく、最後の一つは Windows や特定のレガシ
     ーなプラットフォーム (VMS や MS-DOS など) を対象にしているときにし
     か意味をなさないからです。

オプション引数 (option argument)

     あるオプションの後ろに続く引数で、そのオプションに密接な関連をもち
     、オプションと同時に引数リストから取り出されます。 *note optparse:
     90. では、オプション引数は以下のように別々の引数にできます:

          -f foo
          --file foo

     また、一つの引数中にも入れられます:

          -ffoo
          --file=foo

     通常、オプションは引数をとることもとらないこともあります。あるオプ
     ションは引数をとることがなく、またあるオプションは常に引数をとりま
     す。多くの人々が「オプションのオプション引数」機能を欲しています。
     これは、あるオプションが引数が指定されている場合には引数をとり、そ
     うでない場合には引数をもたないようにするという機能です。この機能は
     引数解析をあいまいにするため、議論の的となっています: 例えば、もし
     ‘-a’ がオプション引数をとり、 ‘-b’ がまったく別のオプションだとした
     ら、 ‘-ab’ をどうやって解析すればいいのでしょうか？こうした曖昧さが
     存在するため、 *note optparse: 90. は今のところこの機能をサポートし
     ていません。

位置引数 (positional argument)

     他のオプションが解析される、すなわち他のオプションとその引数が解析
     されて引数リストから除去された後に引数リストに置かれているものです
     。

必須のオプション (required option)

     コマンドラインで与えなければならないオプションです; 「必須のオプシ
     ョン (required option)」という語は、英語では矛盾した言葉です。
     *note optparse: 90. では必須オプションの実装を妨げてはいませんが、
     とりたてて実装上役立つこともしていません。

例えば、下記のような架空のコマンドラインを考えてみましょう:

     prog -v --report report.txt foo bar

‘-v’ と ‘--report’ はどちらもオプションです。‘--report’ オプションが引数
をとるとすれば、‘report.txt’ はオプションの引数です。‘foo’ と ‘bar’ は位
置引数になります。


File: python.info,  Node: オプションとは何か,  Next: 位置引数とは何か,  Prev: 用語集,  Up: 背景

5.36.2.3 オプションとは何か
...........................

オプションはプログラムの実行を調整したり、カスタマイズしたりするための補
助的な情報を与えるために使います。もっとはっきりいうと、オプションはあく
までもオプション (省略可能)であるということです。本来、プログラムはとも
かくもオプションなしでうまく実行できてしかるべきです。(Unix やGNU ツール
セットのプログラムをランダムにピックアップしてみてください。オプションを
全く指定しなくてもちゃんと動くでしょう？例外は ‘find’, ‘tar’, ‘dd’ くら
いです--これらの例外は、オプション文法が標準的でなく、インターフェースが
混乱を招くと酷評されてきた変種のはみ出しものなのです)

多くの人が自分のプログラムに「必須のオプション」を持たせたいと考えます。
しかしよく考えてください。必須なら、それは 'オプション(省略可能) ではな
いのです！' プログラムを正しく動作させるのに絶対的に必要な情報があるとす
れば、そこには位置引数を割り当てるべきなのです。

良くできたコマンドライン インターフェース設計として、ファイルのコピーに
使われる ‘cp’ ユーティリティのことを考えてみましょう。ファイルのコピーで
は、コピー先を指定せずにファイルをコピーするのは無意味な操作ですし、少な
くとも一つのコピー元が必要です。従って、‘cp’ は引数無しで実行すると失敗
します。とはいえ、‘cp’ はオプションを全く必要としない柔軟で便利なコマン
ドライン文法を備えています:

     cp SOURCE DEST
     cp SOURCE ... DEST-DIR

まだあります。ほとんどの ‘cp’ の実装では、ファイルモードや変更時刻を変え
ずにコピーする、シンボリックリンクの追跡を行わない、すでにあるファイルを
上書きする前にユーザに尋ねる、など、ファイルをコピーする方法をいじるため
の一連のオプションを実装しています。しかし、こうしたオプションは、一つの
ファイルを別の場所にコピーする、または複数のファイルを別のディレクトリに
コピーするという、‘cp’ の中心的な処理を乱すことはないのです。


File: python.info,  Node: 位置引数とは何か,  Prev: オプションとは何か,  Up: 背景

5.36.2.4 位置引数とは何か
.........................

位置引数とは、プログラムを動作させる上で絶対的に必要な情報となる引数です
。

よいユーザインターフェースとは、絶対に必要だとされるものが可能な限り少な
いものです。プログラムを正しく動作させるために 17 個もの別個の情報が必要
だとしたら、その '方法' はさして問題にはなりません --ユーザはプログラム
を正しく動作させられないうちに諦め、立ち去ってしまうからです。ユーザイン
ターフェースがコマンドラインでも、設定ファイルでも、GUI やその他の何であ
っても同じです: 多くの要求をユーザに押し付ければ、ほとんどのユーザはただ
音をあげてしまうだけなのです。

要するに、ユーザが絶対に提供しなければならない情報だけに制限する -- そし
て可能な限りよく練られたデフォルト設定を使うよう試みてください。もちろん
、プログラムには適度な柔軟性を持たせたいとも望むはずですが、それこそがオ
プションの果たす役割です。繰り返しますが、設定ファイルのエントリであろう
が、GUI でできた「環境設定」ダイアログ上のウィジェットであろうが、コマン
ドラインオプションであろうが関係ありません -- より多くのオプションを実装
すればプログラムはより柔軟性を持ちますが、実装はより難解になるのです。高
すぎる柔軟性はユーザを閉口させ、コードの維持をより難しくするのです。


File: python.info,  Node: チュートリアル<4>,  Next: リファレンスガイド,  Prev: 背景,  Up: optparse --- Parser for command line options

5.36.2.5 チュートリアル
.......................

*note optparse: 90. はとても柔軟で強力でありながら、ほとんどの場合には簡
単に利用できます。この節では、 *note optparse: 90. ベースのプログラムで
広く使われているコードパターンについて述べます。

まず、*note OptionParser: 1476. クラスを import しておかなければなりませ
ん。次に、プログラムの冒頭で *note OptionParser: 1476. インスタンスを生
成しておきます:

     from optparse import OptionParser
     ...
     parser = OptionParser()

これでオプションを定義できるようになりました。基本的な構文は以下の通りで
す:

     parser.add_option(opt_str, ...,
                       attr=value, ...)

各オプションには、 ‘-f’ や ‘--file’ のような一つまたは複数のオプション文
字列と、パーザがコマンドライン上のオプションを見つけた際に、何を準備し、
何を行うべきかを *note optparse: 90. に教えるためのオプション属性
(option attribute)がいくつか入ります。

通常、各オプションには短いオプション文字列と長いオプション文字列がありま
す。例えば:

     parser.add_option("-f", "--file", ...)

オプション文字列は、(ゼロ文字の場合も含め)いくらでも短く、またいくらでも
長くできます。ただしオプション文字列は少なくとも一つなければなりません。

*note OptionParser.add_option(): 2c1c. に渡されたオプション文字列は、実
際にはこの関数で定義したオプションに対するラベルになります。簡単のため、
以後ではコマンドライン上で 'オプションを見つける' という表現をしばしば使
いますが、これは実際には *note optparse: 90. がコマンドライン上の 'オプ
ション文字列' を見つけ、対応づけされているオプションを探し出す、という処
理に相当します。

オプションを全て定義したら、 *note optparse: 90. にコマンドラインを解析
するように指示します:

     (options, args) = parser.parse_args()

(お望みなら、 *note parse_args(): 1477. に自作の引数リストを渡してもかま
いません。とはいえ、実際にはそうした必要はほとんどないでしょう:
‘optionparser’ はデフォルトで ‘sys.argv[1:]’ を使うからです。)

*note parse_args(): 1477. は二つの値を返します:

   * 全てのオプションに対する値の入ったオブジェクト ‘options’ -- 例えば
     、‘--file’ が単一の文字列引数をとる場合、‘options.file’ はユーザが
     指定したファイル名になります。オプションを指定しなかった場合には
     ‘None’ になります

   * オプションの解析後に残った位置引数からなるリスト ‘args’

このチュートリアルの節では、最も重要な四つのオプション属性: *note
action: 46d2, *note type: 46d3, *note dest: 46d4. (destination), *note
help: 46d5. についてしか触れません。このうち最も重要なのは *note action:
46d2. です。

* Menu:

* オプション・アクションを理解する::
* store アクション::
* ブール値 (フラグ) オプションの処理: ブール値 フラグ オプションの処理.
* その他のアクション::
* デフォルト値::
* ヘルプの生成::
* バージョン番号の出力::
* optparse のエラー処理法::
* 全てをつなぎ合わせる::


File: python.info,  Node: オプション・アクションを理解する,  Next: store アクション,  Up: チュートリアル<4>

5.36.2.6 オプション・アクションを理解する
.........................................

アクション(action)は *note optparse: 90. がコマンドライン上にあるオプシ
ョンを見つけたときに何をすべきかを指示します。 *note optparse: 90. には
押し着せのアクションのセットがハードコードされています。新たなアクション
の追加は上級者向けの話題であり、 *note optparse の拡張: 46d8. で触れます
。ほとんどのアクションは、値を何らかの変数に記憶するよう *note optparse:
90. に指示します -- 例えば、文字列をコマンドラインから取り出して、
‘options’ の属性の中に入れる、といった具合にです。

オプション・アクションを指定しない場合、 *note optparse: 90. のデフォル
トの動作は ‘store’ になります。


File: python.info,  Node: store アクション,  Next: ブール値 フラグ オプションの処理,  Prev: オプション・アクションを理解する,  Up: チュートリアル<4>

5.36.2.7 store アクション
.........................

もっとも良く使われるアクションは ‘store’ です。このアクションは次の引数
(あるいは現在の引数の残りの部分) を取り出し、正しい型の値か確かめ、指定
した保存先に保存するよう *note optparse: 90. に指示します。

例えば:

     parser.add_option("-f", "--file",
                       action="store", type="string", dest="filename")

例えば、以下のように指定しておき、偽のコマンドラインを作成して *note
optparse: 90. に解析させてみましょう:

     args = ["-f", "foo.txt"]
     (options, args) = parser.parse_args(args)

オプション文字列 ‘-f’ を見つけると、 *note optparse: 90. は次の引数であ
る ‘foo.txt’ を消費し、その値を ‘options.filename’ に保存します。従って
、この *note parse_args(): 1477. 呼び出し後には ‘options.filename’ は
‘"foo.txt"’ になっています。

オプションの型として、 *note optparse: 90. は他にも ‘int’ や ‘float’ を
サポートしています:

     parser.add_option("-n", type="int", dest="num")

このオプションには長い形式のオプション文字列がないため、設定に問題がない
ということに注意してください。また、デフォルトのアクションは ‘store’ な
ので、ここでは action を明示的に指定していません。

架空のコマンドラインをもう一つ解析してみましょう。今度は、オプション引数
をオプションの右側にぴったりくっつけて一緒くたにします: ‘-n42’ (一つの引
数のみ) は ‘-n 42’ (二つの引数からなる) と等価になるので

     (options, args) = parser.parse_args(["-n42"])
     print(options.num)

は ‘42’ を出力します。

型を指定しない場合、 *note optparse: 90. は引数を ‘string’ であると仮定
します。デフォルトのアクションが ‘store’ であることも併せて考えると、最
初の例はもっと短くなります:

     parser.add_option("-f", "--file", dest="filename")

保存先 (destination) を指定しない場合、 *note optparse: 90. はデフォルト
値としてオプション文字列から気のきいた名前を設定します: 最初に指定した長
い形式のオプション文字列が ‘--foo-bar’ であれば、デフォルトの保存先は
‘foo_bar’ になります。長い形式のオプション文字列がなければ、 *note
optparse: 90. は最初に指定した短い形式のオプション文字列を探します: 例え
ば、 ‘-f’ に対する保存先は ‘f’ になります。

*note optparse: 90. にはビルトインの ‘complex’ 型も含まれています。型の
追加については *note optparse の拡張: 46d8. で触れています。


File: python.info,  Node: ブール値 フラグ オプションの処理,  Next: その他のアクション,  Prev: store アクション,  Up: チュートリアル<4>

5.36.2.8 ブール値 (フラグ) オプションの処理
...........................................

フラグオプション--特定のオプションに対して真または偽の値の値を設定するオ
プション-- はよく使われます。 *note optparse: 90. では、二つのアクション
、 ‘store_true’ および ‘store_false’ をサポートしています。例えば、
‘verbose’ というフラグを ‘-v’ で有効にして、 ‘-q’ で無効にしたいとします
:

     parser.add_option("-v", action="store_true", dest="verbose")
     parser.add_option("-q", action="store_false", dest="verbose")

ここでは二つのオプションに同じ保存先を指定していますが、全く問題ありませ
ん。(下記のように、デフォルト値の設定を少し注意深く行わなければならない
だけです。)

‘-v’ をコマンドライン上に見つけると、 *note optparse: 90. は
‘options.verbose’ を ‘True’ に設定します。 ‘-q’ を見つければ、
‘options.verbose’ は ‘False’ にセットされます。


File: python.info,  Node: その他のアクション,  Next: デフォルト値,  Prev: ブール値 フラグ オプションの処理,  Up: チュートリアル<4>

5.36.2.9 その他のアクション
...........................

この他にも、 *note optparse: 90. は以下のようなアクションをサポートして
います:

‘"store_const"’

     store a constant value, pre-set via *note Option.const: 46df.

‘"append"’

     オプションの引数を指定のリストに追加します

‘"count"’

     指定のカウンタを 1 増やします

‘"callback"’

     指定の関数を呼び出します

これらのアクションについては、 *note リファレンスガイド: 46e0. 節および
*note オプション処理コールバック: 46e1. 節で触れます。


File: python.info,  Node: デフォルト値,  Next: ヘルプの生成,  Prev: その他のアクション,  Up: チュートリアル<4>

5.36.2.10 デフォルト値
......................

上記の例は全て、何らかのコマンドラインオプションが見つかった時に何らかの
変数 (保存先: destination) に値を設定していました。では、該当するオプシ
ョンが見つからなかった場合には何が起きるのでしょうか？デフォルトは全く与
えていないため、これらの値は全て ‘None’ になります。たいていはこれで十分
ですが、もっときちんと制御したい場合もあります。 *note optparse: 90. で
は各保存先に対してデフォルト値を指定し、コマンドラインの解析前にデフォル
ト値が設定されるようにできます。

まず、 verbose/quiet の例について考えてみましょう。 *note optparse: 90.
に対して、 ‘-q’ がない限り ‘verbose’ を ‘True’ に設定させたいなら、以下
のようにします:

     parser.add_option("-v", action="store_true", dest="verbose", default=True)
     parser.add_option("-q", action="store_false", dest="verbose")

デフォルトの値は特定のオプションではなく '保存先' に対して適用されます。
また、これら二つのオプションはたまたま同じ保存先を持っているにすぎないた
め、上のコードは下のコードと全く等価になります:

     parser.add_option("-v", action="store_true", dest="verbose")
     parser.add_option("-q", action="store_false", dest="verbose", default=True)

下のような場合を考えてみましょう:

     parser.add_option("-v", action="store_true", dest="verbose", default=False)
     parser.add_option("-q", action="store_false", dest="verbose", default=True)

やはり ‘verbose’ のデフォルト値は ‘True’ になります; 特定の目的変数に対
するデフォルト値として有効なのは、最後に指定した値だからです。

デフォルト値をすっきりと指定するには、 *note OptionParser: 1476. の
‘set_defaults()’ メソッドを使います。このメソッドは *note parse_args():
1477. を呼び出す前ならいつでも使えます:

     parser.set_defaults(verbose=True)
     parser.add_option(...)
     (options, args) = parser.parse_args()

前の例と同様、あるオプションの値の保存先に対するデフォルトの値は最後に指
定した値になります。コードを読みやすくするため、デフォルト値を設定すると
きには両方のやり方を混ぜるのではなく、片方だけを使うようにしましょう。


File: python.info,  Node: ヘルプの生成,  Next: バージョン番号の出力,  Prev: デフォルト値,  Up: チュートリアル<4>

5.36.2.11 ヘルプの生成
......................

*note optparse: 90. にはヘルプと使い方の説明 (usage text) を生成する機能
があり、ユーザに優しいコマンドライン インターフェースを作成する上で役立
ちます。やらなければならないのは、各オプションに対する *note help: 46d5.
の値と、必要ならプログラム全体の使用法を説明する短いメッセージを与えるこ
とだけです。ユーザフレンドリな (ドキュメント付きの) オプションを追加した
*note OptionParser: 1476. を以下に示します:

     usage = "usage: %prog [options] arg1 arg2"
     parser = OptionParser(usage=usage)
     parser.add_option("-v", "--verbose",
                       action="store_true", dest="verbose", default=True,
                       help="make lots of noise [default]")
     parser.add_option("-q", "--quiet",
                       action="store_false", dest="verbose",
                       help="be vewwy quiet (I'm hunting wabbits)")
     parser.add_option("-f", "--filename",
                       metavar="FILE", help="write output to FILE")
     parser.add_option("-m", "--mode",
                       default="intermediate",
                       help="interaction mode: novice, intermediate, "
                            "or expert [default: %default]")

*note optparse: 90. がコマンドライン上で ‘-h’ や ‘--help’ を見つけた場合
や、 ‘parser.print_help()’ を呼び出した場合、この *note OptionParser:
1476. は以下のようなメッセージを標準出力に出力します:

     Usage: <yourscript> [options] arg1 arg2

     Options:
       -h, --help            show this help message and exit
       -v, --verbose         make lots of noise [default]
       -q, --quiet           be vewwy quiet (I'm hunting wabbits)
       -f FILE, --filename=FILE
                             write output to FILE
       -m MODE, --mode=MODE  interaction mode: novice, intermediate, or
                             expert [default: intermediate]

(help オプションでヘルプを出力した場合、 *note optparse: 90. は出力後に
プログラムを終了します。)

*note optparse: 90. ができるだけうまくメッセージを生成するよう手助けする
には、他にもまだまだやるべきことがあります:

   * スクリプト自体の利用法を表すメッセージを定義します:

          usage = "usage: %prog [options] arg1 arg2"

     *note optparse: 90. は ‘%prog’ を現在のプログラム名、すなわち
     ‘os.path.basename(sys.argv[0])’ と置き換えます。この文字列は詳細な
     オプションヘルプの前に展開され出力されます。

     usage の文字列を指定しない場合、 *note optparse: 90. は型どおりとは
     いえ気の利いたデフォルト値、 ‘"Usage: %prog [options]"’ を使います
     。位置引数をとらないスクリプトの場合はこれで十分でしょう。

   * 全てのオプションにヘルプ文字列を定義します。行の折り返しは気にしな
     くてかまいません --*note optparse: 90. は行の折り返しに気を配り、見
     栄えのよいヘルプ出力を生成します。

   * オプションが値をとるということは自動的に生成されるヘルプメッセージ
     の中で分かります。例えば、"mode" option の場合にはこのようになりま
     す:

          -m MODE, --mode=MODE

     ここで "MODE" はメタ変数 (meta-variable) と呼ばれます: メタ変数は、
     ユーザが ‘-m’/‘--mode’ に対して指定するはずの引数を表します。デフォ
     ルトでは、 *note optparse: 90. は保存先の変数名を大文字だけにしたも
     のをメタ変数に使います。これは時として期待通りの結果になりません --
     例えば、上の例の ‘--filename’ オプションでは明示的に
     ‘metavar="FILE"’ を設定しており、その結果自動生成されたオプション説
     明テキストは:

          -f FILE, --filename=FILE

     この機能の重要さは、単に表示スペースを節約するといった理由にとどま
     りません: 上の例では、手作業で書いたヘルプテキストの中でメタ変数と
     して ‘FILE’ を使っています。その結果、ユーザに対してやや堅苦しい表
     現の書法 ‘-f FILE’ と、より平易に意味付けを説明した "write output
     to FILE" との間に対応があるというヒントを与えています。これは、エン
     ドユーザにとってより明解で便利なヘルプテキストを作成する単純であり
     ながら効果的な手法なのです。

   * デフォルト値を持つオプションはヘルプ文字列に ‘%default’ を含むこと
     ができます--*note optparse: 90. はそれをオプションのデフォルト値に
     *note str(): 418. を適用したもので置き換えます。オプションがデフォ
     ルト値を持たない (もしくはデフォルト値が ‘None’ である) 場合、
     ‘%default’ は ‘none’ に展開されます。

* Menu:

* オプションをグループ化する::


File: python.info,  Node: オプションをグループ化する,  Up: ヘルプの生成

5.36.2.12 オプションをグループ化する
....................................

たくさんのオプションを扱う場合、オプションをグループ分けするとヘルプ出力
が見やすくなります。 *note OptionParser: 1476. は、複数のオプションをま
とめたオプショングループを複数持つことができます。

オプションのグループは、 *note OptionGroup: 46e7. を使って作成します:

 -- クラス: optparse.OptionGroup (parser, title, description=None)

     ここでは:

        * 'parser' は、このグループが属する *note OptionParser: 1476. の
          インスタンスです

        * 'title' はグループのタイトルです

        * 'description' はオプションで、グループの長い説明です

*note OptionGroup: 46e7. は (*note OptionParser: 1476. のように)
‘OptionContainer’ を継承していて、オプションをグループに追加するために
‘add_option()’ メソッドを利用できます。

全てのオプションを定義したら、 *note OptionParser: 1476. の
‘add_option_group()’ メソッドを使ってグループを定義済みのパーサーに追加
します。

前のセクションで定義したパーサーに、続けて *note OptionGroup: 46e7. を追
加します:

     group = OptionGroup(parser, "Dangerous Options",
                         "Caution: use these options at your own risk.  "
                         "It is believed that some of them bite.")
     group.add_option("-g", action="store_true", help="Group option.")
     parser.add_option_group(group)

この結果のヘルプ出力は次のようになります:

     Usage: <yourscript> [options] arg1 arg2

     Options:
       -h, --help            show this help message and exit
       -v, --verbose         make lots of noise [default]
       -q, --quiet           be vewwy quiet (I'm hunting wabbits)
       -f FILE, --filename=FILE
                             write output to FILE
       -m MODE, --mode=MODE  interaction mode: novice, intermediate, or
                             expert [default: intermediate]

       Dangerous Options:
         Caution: use these options at your own risk.  It is believed that some
         of them bite.

         -g                  Group option.

さらにサンプルを拡張して、複数のグループを使うようにしてみます:

     group = OptionGroup(parser, "Dangerous Options",
                         "Caution: use these options at your own risk.  "
                         "It is believed that some of them bite.")
     group.add_option("-g", action="store_true", help="Group option.")
     parser.add_option_group(group)

     group = OptionGroup(parser, "Debug Options")
     group.add_option("-d", "--debug", action="store_true",
                      help="Print debug information")
     group.add_option("-s", "--sql", action="store_true",
                      help="Print all SQL statements executed")
     group.add_option("-e", action="store_true", help="Print every action done")
     parser.add_option_group(group)

出力結果は次のようになります:

     Usage: <yourscript> [options] arg1 arg2

     Options:
       -h, --help            show this help message and exit
       -v, --verbose         make lots of noise [default]
       -q, --quiet           be vewwy quiet (I'm hunting wabbits)
       -f FILE, --filename=FILE
                             write output to FILE
       -m MODE, --mode=MODE  interaction mode: novice, intermediate, or expert
                             [default: intermediate]

       Dangerous Options:
         Caution: use these options at your own risk.  It is believed that some
         of them bite.

         -g                  Group option.

       Debug Options:
         -d, --debug         Print debug information
         -s, --sql           Print all SQL statements executed
         -e                  Print every action done

もう1つの、特にオプショングループをプログラムから操作するときに利用でき
るメソッドがあります:

 -- メソッド: OptionParser.get_option_group (opt_str)

     短いオプション文字列もしくは長いオプション文字列 'opt_str' (例。
     ‘'-o'’ 、 ‘'--option'’) が属する *note OptionGroup: 46e7. を返しま
     す。そのような *note OptionGroup: 46e7. が無い場合は、 ‘None’ を返
     します。


File: python.info,  Node: バージョン番号の出力,  Next: optparse のエラー処理法,  Prev: ヘルプの生成,  Up: チュートリアル<4>

5.36.2.13 バージョン番号の出力
..............................

*note optparse: 90. では、使用法メッセージと同様にプログラムのバージョン
文字列を出力できます。 *note OptionParser: 1476. の ‘version’ 引数に文字
列を渡します:

     parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0")

‘%prog’ は ‘usage’ と同じような展開を受けます。その他にも ‘version’ には
何でも好きな内容を入れられます。 ‘version’ を指定した場合、 *note
optparse: 90. は自動的に ‘--version’ オプションをパーザに渡します。コマ
ンドライン中に ‘--version’ が見つかると、 *note optparse: 90. は
‘version’ 文字列を展開して (‘%prog’ を置き換えて) 標準出力に出力し、プロ
グラムを終了します。

例えば、‘/usr/bin/foo’ という名前のスクリプトなら:

     $ /usr/bin/foo --version
     foo 1.0

以下の2つのメソッドを、‘version’ 文字列を表示するために利用できます:

 -- メソッド: OptionParser.print_version (file=None)

     現在のプログラムのバージョン (‘self.version’) を 'file' (デフォルト
     : stdout) へ表示します。 *note print_usage(): 46ec. と同じく、
     ‘self.version’ の中の全ての ‘%prog’ が現在のプログラム名に置き換え
     られます。 ‘self.version’ が空文字列だだったり未定義だったときは何
     もしません。

 -- メソッド: OptionParser.get_version ()

     *note print_version(): 46eb. と同じですが、バージョン文字列を表示す
     る代わりに返します。


File: python.info,  Node: optparse のエラー処理法,  Next: 全てをつなぎ合わせる,  Prev: バージョン番号の出力,  Up: チュートリアル<4>

5.36.2.14 ‘optparse’ のエラー処理法
...................................

*note optparse: 90. を使う場合に気を付けなければならないエラーには、大き
く分けてプログラマ側のエラーとユーザ側のエラーという二つの種類があります
。プログラマ側のエラーの多くは、例えば不正なオプション文字列や定義されて
いないオプション属性の指定、あるいはオプション属性を指定し忘れるといった
、誤った *note OptionParser.add_option(): 2c1c, 呼び出しによるものです。
こうした誤りは通常通りに処理されます。すなわち、例外(*note
optparse.OptionError: 2c1f. や *note TypeError: 502.) を送出して、プログ
ラムをクラッシュさせます。

もっと重要なのはユーザ側のエラーの処理です。というのも、ユーザの操作エラ
ーというものはコードの安定性に関係なく起こるからです。 *note optparse:
90. は、誤ったオプション引数の指定 (整数を引数にとるオプション ‘-n’ に対
して ‘-n 4x’ と指定してしまうなど) や、引数を指定し忘れた場合 (‘-n’ が何
らかの引数をとるオプションであるのに、 ‘-n’ が引数の末尾に来ている場合)
といった、ユーザによるエラーを自動的に検出します。また、アプリケーション
側で定義されたエラー条件が起きた場合、 ‘OptionParser.error()’ を呼び出し
てエラーを通知できます:

     (options, args) = parser.parse_args()
     ...
     if options.a and options.b:
         parser.error("options -a and -b are mutually exclusive")

いずれの場合にも *note optparse: 90. はエラーを同じやり方で処理します。
すなわち、プログラムの使用法メッセージとエラーメッセージを標準エラー出力
に出力して、終了ステータス 2 でプログラムを終了させます。

上に挙げた最初の例、すなわち整数を引数にとるオプションにユーザが ‘4x’ を
指定した場合を考えてみましょう:

     $ /usr/bin/foo -n 4x
     Usage: foo [options]

     foo: error: option -n: invalid integer value: '4x'

値を全く指定しない場合には、以下のようになります:

     $ /usr/bin/foo -n
     Usage: foo [options]

     foo: error: -n option requires an argument

*note optparse: 90. は、常にエラーを引き起こしたオプションについて説明の
入ったエラーメッセージを生成するよう気を配ります; 従って、
‘OptionParser.error()’ をアプリケーションコードから呼び出す場合にも、同
じようなメッセージになるようにしてください。

*note optparse: 90. のデフォルトのエラー処理動作が気に入らないのなら、
*note OptionParser: 1476. をサブクラス化して、 ‘exit()’ かつ/または
‘error()’ をオーバライドする必要があります。


File: python.info,  Node: 全てをつなぎ合わせる,  Prev: optparse のエラー処理法,  Up: チュートリアル<4>

5.36.2.15 全てをつなぎ合わせる
..............................

*note optparse: 90. を使ったスクリプトは、通常以下のようになります:

     from optparse import OptionParser
     ...
     def main():
         usage = "usage: %prog [options] arg"
         parser = OptionParser(usage)
         parser.add_option("-f", "--file", dest="filename",
                           help="read data from FILENAME")
         parser.add_option("-v", "--verbose",
                           action="store_true", dest="verbose")
         parser.add_option("-q", "--quiet",
                           action="store_false", dest="verbose")
         ...
         (options, args) = parser.parse_args()
         if len(args) != 1:
             parser.error("incorrect number of arguments")
         if options.verbose:
             print("reading %s..." % options.filename)
         ...

     if __name__ == "__main__":
         main()


File: python.info,  Node: リファレンスガイド,  Next: オプション処理コールバック,  Prev: チュートリアル<4>,  Up: optparse --- Parser for command line options

5.36.2.16 リファレンスガイド
............................

* Menu:

* parserを作る::
* パーザへのオプション追加::
* オプションの定義::
* オプション属性::
* 標準的なオプション・アクション::
* 標準のオプション型::
* 引数を解析する::
* オプション解析器への問い合わせと操作::
* オプション間の衝突::
* クリーンアップ: クリーンアップ<2>.
* その他のメソッド::


File: python.info,  Node: parserを作る,  Next: パーザへのオプション追加,  Up: リファレンスガイド

5.36.2.17 parserを作る
......................

*note optparse: 90. を使う最初の一歩は OptionParser インスタンスを作るこ
とです。

 -- クラス: optparse.OptionParser (...)

     OptionParser のコンストラクタの引数はどれも必須ではありませんが、い
     くつものキーワード引数がオプションとして使えます。これらはキーワー
     ド引数として渡さなければなりません。すなわち、引数が宣言されている
     順番に頼ってはいけません。

     ‘usage’ (デフォルト: ‘"%prog [options]"’)

          プログラムが間違った方法で実行されるかまたはヘルプオプションを
          付けて実行された場合に表示される使用法です。 *note optparse:
          90. は使用法の文字列を表示する際に ‘%prog’ を
          ‘os.path.basename(sys.argv[0])’ (または ‘prog’ キーワード引数
          が指定されていればその値) に展開します。使用法メッセージを抑制
          するためには特別な ‘optparse.SUPPRESS_USAGE’ という値を指定し
          ます。

     ‘option_list’ (デフォルト: ‘[]’)

          パーザに追加する Option オブジェクトのリストです。
          ‘option_list’ の中のオプションは ‘standard_option_list’
          (OptionParser のサブクラスでセットされる可能性のあるクラス属性
          ) の後に追加されますが、バージョンやヘルプのオプションよりは前
          になります。このオプションの使用は推奨されません。パーザを作成
          した後で、 *note add_option(): 2c1c. を使って追加してください
          。

     ‘option_class’ (デフォルト: optparse.Option)

          *note add_option(): 2c1c. でパーザにオプションを追加するときに
          使用されるクラス。

     ‘version’ (デフォルト: ‘None’)

          ユーザがバージョンオプションを与えたときに表示されるバージョン
          文字列です。 ‘version’ に真の値を与えると、 *note optparse:
          90. は自動的に単独のオプション文字列 ‘--version’ とともにバー
          ジョンオプションを追加します。部分文字列 ‘%prog’ は ‘usage’ と
          同様に展開されます。

     ‘conflict_handler’ (デフォルト: ‘"error"’)

          オプション文字列が衝突するようなオプションがパーザに追加された
          ときにどうするかを指定します。 *note オプション間の衝突: 46f5.
          節を参照して下さい。

     ‘description’ (デフォルト: ‘None’)

          プログラムの概要を表す一段落のテキストです。 *note optparse:
          90. はユーザがヘルプを要求したときにこの概要を現在のターミナル
          の幅に合わせて整形し直して表示します (‘usage’ の後、オプション
          リストの前に表示されます)。

     ‘formatter’ (デフォルト: 新しい ‘IndentedHelpFormatter’)

          ヘルプテキストを表示する際に使われる optparse.HelpFormatter の
          インスタンスです。 *note optparse: 90. はこの目的のためにすぐ
          使えるクラスを二つ提供しています。 IndentedHelpFormatter と
          TitledHelpFormatter がそれです。

     ‘add_help_option’ (デフォルト: ‘True’)

          もし真ならば、 *note optparse: 90. はパーザにヘルプオプション
          を (オプション文字列 ‘-h’ と ‘--help’ とともに)追加します。

     ‘prog’

          ‘usage’ や ‘version’ の中の ‘%prog’ を展開するときに
          ‘os.path.basename(sys.argv[0])’ の代わりに使われる文字列です。

     ‘epilog’ (デフォルト: ‘None’)

          オプションのヘルプの後に表示されるヘルプテキスト.


File: python.info,  Node: パーザへのオプション追加,  Next: オプションの定義,  Prev: parserを作る,  Up: リファレンスガイド

5.36.2.18 パーザへのオプション追加
..................................

パーザにオプションを加えていくにはいくつか方法があります。推奨するのは
*note チュートリアル: 46d0. 節で示したような *note
OptionParser.add_option(): 2c1c. を使う方法です。 ‘add_option()’ は以下
の二つのうちいずれかの方法で呼び出せます:

   * (‘make_option()’ などが返す) *note Option: 46f8. インスタンスを渡し
     ます

   * ‘make_option()’ に (すなわち *note Option: 46f8. のコンストラクタに
     ) 位置引数とキーワード引数の組み合わせを渡して、 *note Option:
     46f8. インスタンスを生成させます

もう一つの方法は、あらかじめ作成しておいた *note Option: 46f8. インスタ
ンスからなるリストを、以下のようにして *note OptionParser: 1476. のコン
ストラクタに渡すというものです:

     option_list = [
         make_option("-f", "--filename",
                     action="store", type="string", dest="filename"),
         make_option("-q", "--quiet",
                     action="store_false", dest="verbose"),
         ]
     parser = OptionParser(option_list=option_list)

(‘make_option()’ は *note Option: 46f8. インスタンスを生成するファクトリ
関数です; 現在のところ、この関数は *note Option: 46f8. のコンストラクタ
の別名にすぎません。 *note optparse: 90. の将来のバージョンでは、 *note
Option: 46f8. を複数のクラスに分割し、 ‘make_option()’ は適切なクラスを
選んでインスタンスを生成するようになる予定です。従って、 *note Option:
46f8. を直接インスタンス化しないでください。)


File: python.info,  Node: オプションの定義,  Next: オプション属性,  Prev: パーザへのオプション追加,  Up: リファレンスガイド

5.36.2.19 オプションの定義
..........................

各々の *note Option: 46f8. インスタンス、は ‘-f’ や ‘--file’ といった同
義のコマンドラインオプションからなる集合を表現しています。一つの *note
Option: 46f8. には任意の数のオプションを短い形式でも長い形式でも指定でき
ます。ただし、少なくとも一つは指定しなければなりません。

正しい方法で *note Option: 46f8. インスタンスを生成するには、 *note
OptionParser: 1476. の ‘add_option()’ を使います。

 -- メソッド: OptionParser.add_option (option)

 -- メソッド: OptionParser.add_option (*opt_str, attr=value, ...)

     短い形式のオプション文字列を一つだけ持つようなオプションを生成する
     には次のようにします:

          parser.add_option("-f", attr=value, ...)

     また、長い形式のオプション文字列を一つだけ持つようなオプションの定
     義は次のようになります:

          parser.add_option("--foo", attr=value, ...)

     キーワード引数は新しい *note Option: 46f8. オブジェクトの属性を定義
     します。オプションの属性のうちでもっとも重要なのは *note action:
     46d2. です。この属性は、他のどの属性と関連があるか、そしてどの属性
     が必要かに大きく作用します。関係のないオプション属性を指定したり、
     必要な属性を指定し忘れたりすると、 *note optparse: 90. は誤りを解説
     した *note OptionError: 2c1f. 例外を送出します。

     コマンドライン上にあるオプションが見つかったときの *note optparse:
     90. の振舞いを決定しているのは 'アクション(action)' です。 *note
     optparse: 90. でハードコードされている標準的なアクションには以下の
     ようなものがあります:

     ‘"store"’

          オプションの引数を保存します (デフォルトの動作です)

     ‘"store_const"’

          store a constant value, pre-set via *note Option.const: 46df.

     ‘"store_true"’

          store ‘True’

     ‘"store_false"’

          store ‘False’

     ‘"append"’

          オプションの引数を指定のリストに追加します

     ‘"append_const"’

          append a constant value to a list, pre-set via *note
          Option.const: 46df.

     ‘"count"’

          指定のカウンタを 1 増やします

     ‘"callback"’

          指定の関数を呼び出します

     ‘"help"’

          全てのオプションとそのドキュメントの入った使用法メッセージを出
          力します

     (アクションを指定しない場合、デフォルトは ‘"store"’ になります。こ
     のアクションでは、 *note type: 46d3. および *note dest: 46d4. オプ
     ション属性を指定できます。 *note 標準的なオプション・アクション:
     46fb. を参照してください。)

As you can see, most actions involve storing or updating a value
somewhere.  *note optparse: 90. always creates a special object for
this, conventionally called ‘options’, which is an instance of *note
optparse.Values: 2c1e.

 -- クラス: optparse.Values

     An object holding parsed argument names and values as attributes.
     Normally created by calling when calling *note
     OptionParser.parse_args(): 1477, and can be overridden by a custom
     subclass passed to the 'values' argument of *note
     OptionParser.parse_args(): 1477. (as described in *note
     引数を解析する: 46fc.).

Option arguments (and various other values) are stored as attributes of
this object, according to the *note dest: 46d4. (destination) option
attribute.

例えばこれを呼び出した場合

     parser.parse_args()

*note optparse: 90. はまず ‘options’ オブジェクトを生成します:

     options = Values()

パーザ中で以下のようなオプションが定義されていて

     parser.add_option("-f", "--file", action="store", type="string", dest="filename")

パーズしたコマンドラインに以下のいずれかが入っていた場合:

     -ffoo
     -f foo
     --file=foo
     --file foo

*note optparse: 90. はこのオプションを見つけて、以下と同等の処理を行いま
す

     options.filename = "foo"

*note type: 46d3. および *note dest: 46d4. オプション属性は *note
action: 46d2. と同じくらい重要ですが、 '全ての' オプションで意味をなすの
は *note action: 46d2. だけなのです。


File: python.info,  Node: オプション属性,  Next: 標準的なオプション・アクション,  Prev: オプションの定義,  Up: リファレンスガイド

5.36.2.20 オプション属性
........................

 -- クラス: optparse.Option

     A single command line argument, with various attributes passed by
     keyword to the constructor.  Normally created with *note
     OptionParser.add_option(): 2c1c. rather than directly, and can be
     overridden by a custom class via the 'option_class' argument to
     *note OptionParser: 1476.

以下のオプション属性は *note OptionParser.add_option(): 2c1c. へのキーワ
ード引数として渡すことができます。特定のオプションに無関係なオプション属
性を渡した場合、または必須のオプションを渡しそこなった場合、 *note
optparse: 90. は *note OptionError: 2c1f. を送出します。

 -- の属性: Option.action

     (デフォルト: ‘"store"’)

     このオプションがコマンドラインにあった場合に *note optparse: 90. に
     何をさせるかを決めます。取りうるオプションについては *note こちら:
     46fb. を参照してください。

 -- の属性: Option.type

     (デフォルト: ‘"string"’)

     このオプションに与えられる引数の型 (たとえば ‘"string"’ や ‘"int"’)
     です。取りうるオプションについては *note こちら: 46ff. を参照してく
     ださい。

 -- の属性: Option.dest

     (デフォルト: オプション文字列を使う)

     このオプションのアクションがある値をどこかに書いたり書き換えたりを
     意味する場合、これは *note optparse: 90. にその書く場所を教えます。
     詳しく言えば *note dest: 46d4. には *note optparse: 90. がコマンド
     ラインを解析しながら組み立てる ‘options’ オブジェクトの属性の名前を
     指定します。

 -- の属性: Option.default

     コマンドラインに指定がなかったときにこのオプションの対象に使われる
     値です。 *note OptionParser.set_defaults(): 4701. も参照してくださ
     い。

 -- の属性: Option.nargs

     (デフォルト: 1)

     このオプションがあったときに幾つの *note type: 46d3. 型の引数が消費
     されるべきかを指定します。 1 より大きい場合、 *note optparse: 90. は
     *note dest: 46d4. に値のタプルを格納します。

 -- の属性: Option.const

     定数を格納する動作のための、その定数です。

 -- の属性: Option.choices

     ‘"choice"’ 型オプションに対してユーザが選べる選択肢となる文字列のリ
     ストです。

 -- の属性: Option.callback

     アクションが ‘"callback"’ であるオプションに対し、このオプションが
     あったときに呼ばれる呼び出し可能オブジェクトです。呼び出し時に渡さ
     れる引数の詳細については、 *note オプション処理コールバック: 46e1.
     を参照してください。

 -- の属性: Option.callback_args
 -- の属性: Option.callback_kwargs

     ‘callback’ に渡される標準的な4つのコールバック引数の後ろに追加する
     、位置引数とキーワード引数。

 -- の属性: Option.help

     ユーザが *note help: 46d5. オプション(‘--help’ のような)を指定した
     ときに表示される、使用可能な全オプションのリストの中のこのオプショ
     ンに関する説明文です。説明文を提供しておかなければ、オプションは説
     明文なしで表示されます。オプションを隠すには特殊な値
     ‘optparse.SUPPRESS_HELP’ を使います。

 -- の属性: Option.metavar

     (デフォルト: オプション文字列を使う)

     説明文を表示する際にオプションの引数の身代わりになるものです。例は
     *note チュートリアル: 46d0. 節を参照してください。


File: python.info,  Node: 標準的なオプション・アクション,  Next: 標準のオプション型,  Prev: オプション属性,  Up: リファレンスガイド

5.36.2.21 標準的なオプション・アクション
........................................

様々なオプション・アクションにはどれも互いに少しづつ異なった条件と作用が
あります。ほとんどのアクションに関連するオプション属性がいくつかあり、値
を指定して *note optparse: 90. の挙動を操作できます。いくつかのアクショ
ンには必須の属性があり、必ず値を指定しなければなりません。

   * ‘"store"’ [関連: *note type: 46d3, *note dest: 46d4, *note nargs:
     4702, *note choices: 4703.]

     オプションの後には必ず引数が続きます。引数は *note type: 46d3. に従
     って値に変換されて *note dest: 46d4. に保存されます。 *note nargs:
     4702. > 1 の場合、複数の引数をコマンドラインから取り出します。引数
     は全て *note type: 46d3. に従って変換され、 *note dest: 46d4. にタ
     プルとして保存されます。 *note 標準のオプション型: 46ff. 節を参照し
     てください。

     *note choices: 4703. を(文字列のリストかタプルで) 指定した場合、型
     のデフォルト値は ‘"choice"’ になります。

     *note type: 46d3. を指定しない場合、デフォルトの値は ‘"string"’ で
     す。

     *note dest: 46d4. を指定しない場合、 *note optparse: 90. は保存先を
     最初の長い形式のオプション文字列から導出します (例えば、
     ‘--foo-bar’ は ‘foo_bar’ になります)。長い形式のオプション文字列が
     ない場合、 *note optparse: 90. は最初の短い形式のオプションから保存
     先の変数名を導出します (‘-f’ は ‘f’ になります)。

     以下はプログラム例です:

          parser.add_option("-f")
          parser.add_option("-p", type="float", nargs=3, dest="point")

     とすると、以下のようなコマンドライン

          -f foo.txt -p 1 -3.5 4 -fbar.txt

     を解析した場合、 *note optparse: 90. は以下のように設定を行います

          options.f = "foo.txt"
          options.point = (1.0, -3.5, 4.0)
          options.f = "bar.txt"

   * ‘"store_const"’ [関連: *note const: 46df.; 関連: *note dest: 46d4.]

     値 *note const: 46df. を *note dest: 46d4. に保存します。

     以下はプログラム例です:

          parser.add_option("-q", "--quiet",
                            action="store_const", const=0, dest="verbose")
          parser.add_option("-v", "--verbose",
                            action="store_const", const=1, dest="verbose")
          parser.add_option("--noisy",
                            action="store_const", const=2, dest="verbose")

     とします。 ‘--noisy’ が見つかると、 *note optparse: 90. は

          options.verbose = 2

   * ‘"store_true"’ [関連: *note dest: 46d4.]

     A special case of ‘"store_const"’ that stores ‘True’ to *note dest:
     46d4.

   * ‘"store_false"’ [関連: *note dest: 46d4.]

     Like ‘"store_true"’, but stores ‘False’.

     以下はプログラム例です:

          parser.add_option("--clobber", action="store_true", dest="clobber")
          parser.add_option("--no-clobber", action="store_false", dest="clobber")

   * ‘"append"’ [関連: *note type: 46d3, *note dest: 46d4, *note nargs:
     4702, *note choices: 4703.]

     このオプションの後ろには必ず引数が続きます。引数は *note dest:
     46d4. のリストに追加されます。 *note dest: 46d4. のデフォルト値を指
     定しなかった場合、 *note optparse: 90. がこのオプションを最初にみつ
     けた時点で空のリストを自動的に生成します。 *note nargs: 4702. > 1 の
     場合、複数の引数をコマンドラインから取り出し、長さ *note nargs:
     4702. のタプルを生成して *note dest: 46d4. に追加します。

     *note type: 46d3. および *note dest: 46d4. のデフォルト値は
     ‘"store"’ アクションと同じです。

     以下はプログラム例です:

          parser.add_option("-t", "--tracks", action="append", type="int")

     ‘-t3’ がコマンドライン上で見つかると、 *note optparse: 90. は:

          options.tracks = []
          options.tracks.append(int("3"))

     その後、‘--tracks=4’ が見つかると以下を実行します:

          options.tracks.append(int("4"))

     ‘append’ アクションは、オプションの現在の値の ‘append’ メソッドを呼
     び出します。これは、どのデフォルト値も ‘append’ メソッドを持ってい
     なければならないことを意味します。また、デフォルト値が空でない場合
     、オプションの解析結果は、そのデフォルトの要素の後ろにコマンドライ
     ンからの値が追加されたものになる、ということも意味します:

          >>> parser.add_option("--files", action="append", default=['~/.mypkg/defaults'])
          >>> opts, args = parser.parse_args(['--files', 'overrides.mypkg'])
          >>> opts.files
          ['~/.mypkg/defaults', 'overrides.mypkg']

   * ‘"append_const"’ [関連: *note const: 46df.; 関連: *note dest:
     46d4.]

     ‘"store_const"’ と同様ですが、 *note const: 46df. の値は *note
     dest: 46d4. に追加(append)されます。 ‘"append"’ の場合と同じように
     *note dest: 46d4. のデフォルトは ‘None’ ですがこのオプションを最初
     にみつけた時点で空のリストを自動的に生成します。

   * ‘"count"’ [関連: *note dest: 46d4.]

     *note dest: 46d4. に保存されている整数値をインクリメントします。
     *note dest: 46d4. は (デフォルトの値を指定しない限り) 最初にインク
     リメントを行う前にゼロに設定されます。

     以下はプログラム例です:

          parser.add_option("-v", action="count", dest="verbosity")

     コマンドライン上で最初に ‘-v’ が見つかると、 *note optparse: 90. は
     :

          options.verbosity = 0
          options.verbosity += 1

     以後、‘-v’ が見つかるたびに

          options.verbosity += 1

   * ‘"callback"’ [必須: *note callback: 4704.; 関連: *note type: 46d3,
     *note nargs: 4702, *note callback_args: 4705, *note
     callback_kwargs: 4706.]

     *note callback: 4704. に指定された関数を次のように呼び出します

          func(option, opt_str, value, parser, *args, **kwargs)

     詳細は、 *note オプション処理コールバック: 46e1. 節を参照してくださ
     い。

   * ‘"help"’

     現在のオプションパーザ内の全てのオプションに対する完全なヘルプメッ
     セージを出力します。ヘルプメッセージは *note OptionParser: 1476. の
     コンストラクタに渡した ‘usage’ 文字列と、各オプションに渡した *note
     help: 46d5. 文字列から生成します。

     オプションに *note help: 46d5. 文字列が指定されていなくても、オプシ
     ョンはヘルプメッセージ中に列挙されます。オプションを完全に表示させ
     ないようにするには、特殊な値 ‘optparse.SUPPRESS_HELP’ を使ってくだ
     さい。

     *note optparse: 90. は全ての *note OptionParser: 1476. に自動的に
     *note help: 46d5. オプションを追加するので、通常自分で生成する必要
     はありません。

     以下はプログラム例です:

          from optparse import OptionParser, SUPPRESS_HELP

          # usually, a help option is added automatically, but that can
          # be suppressed using the add_help_option argument
          parser = OptionParser(add_help_option=False)

          parser.add_option("-h", "--help", action="help")
          parser.add_option("-v", action="store_true", dest="verbose",
                            help="Be moderately verbose")
          parser.add_option("--file", dest="filename",
                            help="Input file to read data from")
          parser.add_option("--secret", help=SUPPRESS_HELP)

     *note optparse: 90. がコマンドライン上に ‘-h’ または ‘--help’ を見
     つけると、以下のようなヘルプメッセージを標準出力に出力します
     (‘sys.argv[0]’ は ‘"foo.py"’ だとします):

          Usage: foo.py [options]

          Options:
            -h, --help        Show this help message and exit
            -v                Be moderately verbose
            --file=FILENAME   Input file to read data from

     ヘルプメッセージの出力後、 *note optparse: 90. は ‘sys.exit(0)’ で
     プロセスを終了します。

   * ‘"version"’

     *note OptionParser: 1476. に指定されているバージョン番号を標準出力
     に出力して終了します。バージョン番号は、実際には *note
     OptionParser: 1476. の ‘print_version()’ メソッドで書式化されてから
     出力されます。通常、 *note OptionParser: 1476. のコンストラクタに
     ‘version’ 引数が指定されたときのみ関係のあるアクションです。 *note
     help: 46d5. オプションと同様、 *note optparse: 90. はこのオプション
     を必要に応じて自動的に追加するので、 ‘version’ オプションを作成する
     ことはほとんどないでしょう。


File: python.info,  Node: 標準のオプション型,  Next: 引数を解析する,  Prev: 標準的なオプション・アクション,  Up: リファレンスガイド

5.36.2.22 標準のオプション型
............................

*note optparse: 90. には、 ‘"string"’, ‘"int"’, ‘"choice"’, ‘"float"’,
‘"complex"’ の 5 種類のビルトインのオプション型があります。 新たなオプシ
ョンの型を追加したければ、 *note optparse の拡張: 46d8. 節を参照してくだ
さい。

文字列オプションの引数はチェックや変換を一切受けません: コマンドライン上
のテキストは保存先にそのまま保存されます (またはコールバックに渡されます
)。

整数引数 (‘"int"’ 型) は次のように解析されます:

   * 数が ‘0x’ から始まるならば、16進数として読み取られます

   * 数が ‘0’ から始まるならば、8進数として読み取られます

   * 数が ‘0b’ から始まるならば、2進数として読み取られます

   * それ以外の場合、数は10進数として読み取られます

変換は適切な底 (2, 8, 10, 16 のどれか) とともに *note int(): 238. を呼び
出すことで行なわれます。この変換が失敗した場合 *note optparse: 90. の処
理も失敗に終わりますが、 より役に立つエラーメッセージを出力します。

‘"float"’ および ‘"complex"’ のオプション引数は直接 *note float(): 2ce.
や *note complex(): 2cf. で変換されます。エラーは同様の扱いです。

‘"choice"’ オプションは ‘"string"’ オプションのサブタイプです。 *note
choices: 4703. オプションの属性 (文字列からなるシーケンス) には、利用で
きるオプション引数のセットを指定します。 ‘optparse.check_choice()’ はユ
ーザの指定したオプション引数とマスタリストを比較して、無効な文字列が指定
された場合には *note OptionValueError: 2c20. を送出します。


File: python.info,  Node: 引数を解析する,  Next: オプション解析器への問い合わせと操作,  Prev: 標準のオプション型,  Up: リファレンスガイド

5.36.2.23 引数を解析する
........................

OptionParser を作成してオプションを追加していく上で大事なポイントは、
*note parse_args(): 1477. メソッドの呼び出しです。

 -- メソッド: OptionParser.parse_args (args=None, values=None)

     Parse the command-line options found in 'args'.

     The input parameters are

     ‘args’

          処理する引数のリスト (デフォルト: ‘sys.argv[1:]’)

     ‘values’

          オプション引数を格納する *note Values: 2c1e. のオブジェクト (デ
          フォルト: 新しい *note Values: 2c1e. のインスタンス) - 既存の
          オブジェクトを指定した場合、オプションのデフォルトは初期化され
          ません

     and the return value is a pair ‘(options, args)’ where

     ‘options’

          'values' に渡されたものと同じオブジェクト、または *note
          optparse: 90. によって生成された ‘optparse.Values’ インスタン
          ス

     ‘args’

          全てのオプションの処理が終わった後で残った位置引数

一番普通の使い方は一切キーワード引数を使わないというものです。 ‘values’
を指定した場合、それは繰り返される *note setattr(): 20bd. の呼び出し (大
雑把に言うと保存される各オプション引数につき一回ずつ) で更新されていき、
*note parse_args(): 1477. で返されます。

*note parse_args(): 1477. が引数リストでエラーに遭遇した場合、
OptionParser の ‘error()’ メソッドを適切なエンドユーザ向けのエラーメッセ
ージとともに呼び出します。この呼び出しにより、最終的に終了ステータス 2
(伝統的な Unix におけるコマンドラインエラーの終了ステータス) でプロセス
を終了させることになります。


File: python.info,  Node: オプション解析器への問い合わせと操作,  Next: オプション間の衝突,  Prev: 引数を解析する,  Up: リファレンスガイド

5.36.2.24 オプション解析器への問い合わせと操作
..............................................

オプションパーザのデフォルトの振る舞いは、ある程度カスタマイズすることが
できます。また、オプションパーザの中を調べることもできます。*note
OptionParser: 1476. は幾つかのヘルパーメソッドを提供しています:

 -- メソッド: OptionParser.disable_interspersed_args ()

     オプションで無い最初の引数を見つけた時点でパースを止めるように設定
     します。例えば、 ‘-a’ と ‘-b’ が両方とも引数を取らないシンプルなオ
     プションだったとすると、 *note optparse: 90. は通常次の構文を受け付
     け:

          prog -a arg1 -b arg2

     それを次と同じように扱います

          prog -a -b arg1 arg2

     この機能を無効にしたいときは、 *note disable_interspersed_args():
     2c1d. メソッドを呼び出してください。古典的な Unix システムのように
     、最初のオプションでない引数を見つけたときにオプションの解析を止め
     るようになります。

     別のコマンドを実行するコマンドをプロセッサを作成する際、別のコマン
     ドのオプションと自身のオプションが混ざるのを防ぐために利用すること
     ができます。例えば、各コマンドがそれぞれ異なるオプションのセットを
     持つ場合などに有効です。

 -- メソッド: OptionParser.enable_interspersed_args ()

     オプションで無い最初の引数を見つけてもパースを止めないように設定し
     ます。オプションとコマンド引数の順序が混ざっても良いようになります
     。これはデフォルトの動作です。

 -- メソッド: OptionParser.get_option (opt_str)

     オプション文字列 'opt_str' に対する *note Option: 46f8. インスタン
     スを返します。該当するオプションがなければ ‘None’ を返します。

 -- メソッド: OptionParser.has_option (opt_str)

     *note OptionParser: 1476. に(‘-q’ や ‘--verbose’ のような) オプショ
     ン 'opt_str' がある場合、‘True’ を返します。

 -- メソッド: OptionParser.remove_option (opt_str)

     *note OptionParser: 1476. に 'opt_str' に対応するオプションがある場
     合、そのオプションを削除します。該当するオプションに他のオプション
     文字列が指定されていた場合、それらのオプション文字列は全て無効にな
     ります。 'opt_str' がこの *note OptionParser: 1476. オブジェクトの
     どのオプションにも属さない場合、 *note ValueError: 1e3. を送出しま
     す。


File: python.info,  Node: オプション間の衝突,  Next: クリーンアップ<2>,  Prev: オプション解析器への問い合わせと操作,  Up: リファレンスガイド

5.36.2.25 オプション間の衝突
............................

注意が足りないと、衝突するオプションを定義してしまうことがあります:

     parser.add_option("-n", "--dry-run", ...)
     ...
     parser.add_option("-n", "--noisy", ...)

(とりわけ、*note OptionParser: 1476. から標準的なオプションを備えた自前
のサブクラスを定義してしまった場合にはよく起きます。)

ユーザがオプションを追加するたびに、 *note optparse: 90. は既存のオプシ
ョンとの衝突がないかチェックします。何らかの衝突が見付かると、現在設定さ
れている衝突処理メカニズムを呼び出します。衝突処理メカニズムはコンストラ
クタ中で呼び出せます:

     parser = OptionParser(..., conflict_handler=handler)

個別にも呼び出せます:

     parser.set_conflict_handler(handler)

衝突時の処理をおこなうハンドラ(handler)には、以下のものが利用できます:

     ‘"error"’ (デフォルト)

          オプション間の衝突をプログラム上のエラーとみなし、 *note
          OptionConflictError: 4712. を送出します

     ‘"resolve"’

          オプション間の衝突をインテリジェントに解決します (下記参照)

一例として、衝突をインテリジェントに解決する *note OptionParser: 1476. を
定義し、衝突を起こすようなオプションを追加してみましょう:

     parser = OptionParser(conflict_handler="resolve")
     parser.add_option("-n", "--dry-run", ..., help="do no harm")
     parser.add_option("-n", "--noisy", ..., help="be noisy")

この時点で、 *note optparse: 90. はすでに追加済のオプションがオプション
文字列 ‘-n’ を使っていることを検出します。 ‘conflict_handler’ が
‘"resolve"’ なので、 *note optparse: 90. は既に追加済のオプションリスト
の方から ‘-n’ を除去して問題を解決します。従って、 ‘-n’ の除去されたオプ
ションは ‘--dry-run’ だけでしか有効にできなくなります。ユーザがヘルプ文
字列を要求した場合、問題解決の結果を反映したメッセージが出力されます:

     Options:
       --dry-run     do no harm
       ...
       -n, --noisy   be noisy

これまでに追加したオプション文字列を跡形もなく削り去り、ユーザがそのオプ
ションをコマンドラインから起動する手段をなくせます。この場合、 *note
optparse: 90. はオプションを完全に除去してしまうので、こうしたオプション
はヘルプテキストやその他のどこにも表示されなくなります。例えば、現在の
*note OptionParser: 1476. の場合、以下の操作:

     parser.add_option("--dry-run", ..., help="new dry-run option")

を行った時点で、最初の ‘-n’/‘--dry-run’ オプションはもはやアクセスできな
くなります。このため、 *note optparse: 90. はオプションを消去してしまい
、ヘルプテキストだけが残ります:

     Options:
       ...
       -n, --noisy   be noisy
       --dry-run     new dry-run option


File: python.info,  Node: クリーンアップ<2>,  Next: その他のメソッド,  Prev: オプション間の衝突,  Up: リファレンスガイド

5.36.2.26 クリーンアップ
........................

OptionParser インスタンスはいくつかの循環参照を抱えています。このことは
Python のガーベジコレクタにとって問題になるわけではありませんが、使い終
わった OptionParser に対して ‘destroy()’ を呼び出すことでこの循環参照を
意図的に断ち切るという方法を選ぶこともできます。この方法は特に長時間実行
するアプリケーションで OptionParser から大きなオブジェクトグラフが到達可
能になっているような場合に有用です。


File: python.info,  Node: その他のメソッド,  Prev: クリーンアップ<2>,  Up: リファレンスガイド

5.36.2.27 その他のメソッド
..........................

OptionParser にはその他にも幾つかの公開されたメソッドがあります:

 -- メソッド: OptionParser.set_usage (usage)

     上で説明したコンストラクタの ‘usage’ キーワード引数での規則に従った
     使用法の文字列をセットします。 ‘None’ を渡すとデフォルトの使用法文
     字列が使われるようになり、 ‘optparse.SUPPRESS_USAGE’ によって使用法
     メッセージを抑制できます。

 -- メソッド: OptionParser.print_usage (file=None)

     現在のプログラムの使用法メッセージ (‘self.usage’) を 'file' (デフォ
     ルト: stdout) に表示します。‘self.usage’ 内にある全ての ‘%prog’ と
     いう文字列は現在のプログラム名に置換されます。‘self.usage’ が空もし
     くは未定義の時は何もしません。

 -- メソッド: OptionParser.get_usage ()

     *note print_usage(): 46ec. と同じですが、使用法メッセージを表示する
     代わりに文字列として返します。

 -- メソッド: OptionParser.set_defaults (dest=value, ...)

     幾つかの保存先に対してデフォルト値をまとめてセットします。 *note
     set_defaults(): 4701. を使うのは複数のオプションにデフォルト値をセ
     ットする好ましいやり方です。複数のオプションが同じ保存先を共有する
     ことがあり得るからです。たとえば幾つかの "mode" オプションが全て同
     じ保存先をセットするものだったとすると、どのオプションもデフォルト
     をセットすることができ、しかし最後に指定したものだけが有効になりま
     す:

          parser.add_option("--advanced", action="store_const",
                            dest="mode", const="advanced",
                            default="novice")    # overridden below
          parser.add_option("--novice", action="store_const",
                            dest="mode", const="novice",
                            default="advanced")  # overrides above setting

     こうした混乱を避けるために *note set_defaults(): 4701. を使います:

          parser.set_defaults(mode="advanced")
          parser.add_option("--advanced", action="store_const",
                            dest="mode", const="advanced")
          parser.add_option("--novice", action="store_const",
                            dest="mode", const="novice")


File: python.info,  Node: オプション処理コールバック,  Next: optparse の拡張,  Prev: リファレンスガイド,  Up: optparse --- Parser for command line options

5.36.2.28 オプション処理コールバック
....................................

*note optparse: 90. の組み込みのアクションや型が望みにかなったものでない
場合、二つの選択肢があります: 一つは *note optparse: 90. の拡張、もう一
つは callback オプションの定義です。 *note optparse: 90. の拡張は汎用性
に富んでいますが、単純なケースに対していささか大げさでもあります。大体は
簡単なコールバックで事足りるでしょう。

‘callback’ オプションの定義は二つのステップからなります:

   * ‘"callback"’ アクションを使ってオプション自体を定義する

   * コールバックを書く。コールバックは少なくとも後で説明する 4 つの引数
     をとる関数 (またはメソッド) でなければなりません

* Menu:

* callbackオプションの定義::
* コールバック関数はどのように呼び出されるか::
* コールバック中で例外を送出する::
* コールバックの例 1; ありふれたコールバック: コールバックの例 1 ありふれたコールバック.
* コールバックの例 2; オプションの順番をチェックする: コールバックの例 2 オプションの順番をチェックする.
* コールバックの例 3; オプションの順番をチェックする (汎用的): コールバックの例 3 オプションの順番をチェックする 汎用的.
* コールバックの例 4; 任意の条件をチェックする: コールバックの例 4 任意の条件をチェックする.
* コールバックの例5; 固定引数: コールバックの例5 固定引数.
* コールバックの例6; 可変個の引数: コールバックの例6 可変個の引数.


File: python.info,  Node: callbackオプションの定義,  Next: コールバック関数はどのように呼び出されるか,  Up: オプション処理コールバック

5.36.2.29 callbackオプションの定義
..................................

callback オプションを最も簡単に定義するには、 *note
OptionParser.add_option(): 2c1c. メソッドを使います。 *note action:
46d2. の他に指定しなければならない属性は ‘callback’ すなわちコールバック
する関数自体です:

     parser.add_option("-c", action="callback", callback=my_callback)

‘callback’ は関数 (または呼び出し可能オブジェクト)なので、callback オプ
ションを定義する時にはあらかじめ ‘my_callback()’ を定義しておかなければ
なりません。この単純なケースでは、 *note optparse: 90. は ‘-c’ が何らか
の引数をとるかどうか判別できず、通常は ‘-c’ が引数を伴わないことを意味し
ます -- 知りたいことはただ単に ‘-c’ がコマンドライン上に現れたどうかだけ
です。とはいえ、場合によっては、自分のコールバック関数に任意の個数のコマ
ンドライン引数を消費させたいこともあるでしょう。これがコールバック関数を
トリッキーなものにしています; これについてはこの節の後の方で説明します。

*note optparse: 90. は常に四つの引数をコールバックに渡し、その他には
*note callback_args: 4705. および *note callback_kwargs: 4706. で指定し
た追加引数しか渡しません。従って、最小のコールバック関数シグネチャは:

     def my_callback(option, opt, value, parser):

コールバックの四つの引数については後で説明します。

callback オプションを定義する場合には、他にもいくつかオプション属性を指
定できます:

*note type: 46d3.

     他で使われているのと同じ意味です: ‘"store"’ や ‘"append"’ アクショ
     ンの時と同じく、この属性は *note optparse: 90. に引数を一つ消費して
     *note type: 46d3. で指定した型に変換させます。 *note optparse: 90.
     は変換後の値をどこかに保存する代わりにコールバック関数に渡します。

*note nargs: 4702.

     これも他で使われているのと同じ意味です: このオプションが指定されて
     いて、かつ ‘nargs’ > 1 である場合、 *note optparse: 90. は *note
     nargs: 4702. 個の引数を消費します。このとき各引数は *note type:
     46d3. 型に変換できなければなりません。変換後の値はタプルとしてコー
     ルバックに渡されます。

*note callback_args: 4705.

     その他の位置引数からなるタプルで、コールバックに渡されます

*note callback_kwargs: 4706.

     その他のキーワード引数からなる辞書で、コールバックに渡されます


File: python.info,  Node: コールバック関数はどのように呼び出されるか,  Next: コールバック中で例外を送出する,  Prev: callbackオプションの定義,  Up: オプション処理コールバック

5.36.2.30 コールバック関数はどのように呼び出されるか
....................................................

コールバックは全て以下の形式で呼び出されます:

     func(option, opt_str, value, parser, *args, **kwargs)

ここでは:

‘option’

     コールバックを呼び出している *note Option: 46f8. のインスタンスです

‘opt_str’

     は、コールバック呼び出しのきっかけとなったコマンドライン上のオプシ
     ョン文字列です。(長い形式のオプションに対する省略形が使われている場
     合、‘opt_str’ は完全な、正式な形のオプション文字列となります -- 例
     えば、ユーザが ‘--foobar’ の短縮形として ‘--foo’ をコマンドラインに
     入力した時には、‘opt_str’ は ‘"--foobar"’ となります。)

‘value’

     オプションの引数で、コマンドライン上に見つかったものです。 *note
     optparse: 90. は、 *note type: 46d3. が設定されている場合、単一の引
     数しかとりません。 ‘value’ の型はオプションの型として指定された型に
     なります。このオプションに対する *note type: 46d3. が ‘None’ である
     (引数なしの) 場合、 ‘value’ は ‘None’ になります。 *note nargs:
     4702. > 1 であれば、 ‘value’ は適切な型をもつ値のタプルになります。

‘parser’

     現在のオプション解析の全てを駆動している *note OptionParser: 1476.
     インスタンスです。この変数が有用なのは、この値を介してインスタンス
     属性としていくつかの興味深いデータにアクセスできるからです:

     ‘parser.largs’

          現在放置されている引数、すなわち、すでに消費されたものの、オプ
          ションでもオプション引数でもない引数からなるリストです。
          ‘parser.largs’ は自由に変更でき、たとえば引数を追加したりでき
          ます (このリストは ‘args’ 、すなわち *note parse_args(): 1477.
          の二つ目の戻り値になります)

     ‘parser.rargs’

          現在残っている引数、すなわち、‘opt_str’ および ‘value’ があれ
          ば除き、それ以外の引数が残っているリストです。‘parser.rargs’ は
          自由に変更でき、例えばさらに引数を消費したりできます。

     ‘parser.values’

          オプションの値がデフォルトで保存されるオブジェクト
          (‘optparse.OptionValues’ のインスタンス) です。この値を使うと
          、コールバック関数がオプションの値を記憶するために、他の *note
          optparse: 90. と同じ機構を使えるようにするため、グローバル変数
          や閉包 (closure) を台無しにしないので便利です。コマンドライン
          上にすでに現れているオプションの値にもアクセスできます。

‘args’

     *note callback_args: 4705. オプション属性で与えられた任意の位置引数
     からなるタプルです。

‘kwargs’

     *note callback_kwargs: 4706. オプション属性で与えられた任意のキーワ
     ード引数からなるタプルです。


File: python.info,  Node: コールバック中で例外を送出する,  Next: コールバックの例 1 ありふれたコールバック,  Prev: コールバック関数はどのように呼び出されるか,  Up: オプション処理コールバック

5.36.2.31 コールバック中で例外を送出する
........................................

オプション自体か、あるいはその引数に問題がある場合、コールバック関数は
*note OptionValueError: 2c20. を送出しなければなりません。 *note
optparse: 90. はこの例外をとらえてプログラムを終了させ、ユーザが指定して
おいたエラーメッセージを標準エラー出力に出力します。エラーメッセージは明
確、簡潔かつ正確で、どのオプションに誤りがあるかを示さなければなりません
。さもなければ、ユーザは自分の操作のどこに問題があるかを解決するのに苦労
することになります。


File: python.info,  Node: コールバックの例 1 ありふれたコールバック,  Next: コールバックの例 2 オプションの順番をチェックする,  Prev: コールバック中で例外を送出する,  Up: オプション処理コールバック

5.36.2.32 コールバックの例 1: ありふれたコールバック
....................................................

引数をとらず、発見したオプションを単に記録するだけのコールバックオプショ
ンの例を以下に示します:

     def record_foo_seen(option, opt_str, value, parser):
         parser.values.saw_foo = True

     parser.add_option("--foo", action="callback", callback=record_foo_seen)

もちろん、‘"store_true"’ アクションを使っても実現できます。


File: python.info,  Node: コールバックの例 2 オプションの順番をチェックする,  Next: コールバックの例 3 オプションの順番をチェックする 汎用的,  Prev: コールバックの例 1 ありふれたコールバック,  Up: オプション処理コールバック

5.36.2.33 コールバックの例 2: オプションの順番をチェックする
............................................................

もう少し面白みのある例を示します: この例では、‘-b’ を発見して、その後で
‘-a’ がコマンドライン中に現れた場合にはエラーになります。

     def check_order(option, opt_str, value, parser):
         if parser.values.b:
             raise OptionValueError("can't use -a after -b")
         parser.values.a = 1
     ...
     parser.add_option("-a", action="callback", callback=check_order)
     parser.add_option("-b", action="store_true", dest="b")


File: python.info,  Node: コールバックの例 3 オプションの順番をチェックする 汎用的,  Next: コールバックの例 4 任意の条件をチェックする,  Prev: コールバックの例 2 オプションの順番をチェックする,  Up: オプション処理コールバック

5.36.2.34 コールバックの例 3: オプションの順番をチェックする (汎用的)
.....................................................................

このコールバック (フラグを立てるが、‘-b’ が既に指定されていればエラーに
なる) を同様の複数のオプションに対して再利用したければ、もう少し作業する
必要があります: エラーメッセージとセットされるフラグを一般化しなければな
りません。

     def check_order(option, opt_str, value, parser):
         if parser.values.b:
             raise OptionValueError("can't use %s after -b" % opt_str)
         setattr(parser.values, option.dest, 1)
     ...
     parser.add_option("-a", action="callback", callback=check_order, dest='a')
     parser.add_option("-b", action="store_true", dest="b")
     parser.add_option("-c", action="callback", callback=check_order, dest='c')


File: python.info,  Node: コールバックの例 4 任意の条件をチェックする,  Next: コールバックの例5 固定引数,  Prev: コールバックの例 3 オプションの順番をチェックする 汎用的,  Up: オプション処理コールバック

5.36.2.35 コールバックの例 4: 任意の条件をチェックする
......................................................

もちろん、単に定義済みのオプションの値を調べるだけにとどまらず、コールバ
ックには任意の条件を入れられます。例えば、満月でなければ呼び出してはなら
ないオプションがあるとしましょう。やらなければならないことはこれだけです
:

     def check_moon(option, opt_str, value, parser):
         if is_moon_full():
             raise OptionValueError("%s option invalid when moon is full"
                                    % opt_str)
         setattr(parser.values, option.dest, 1)
     ...
     parser.add_option("--foo",
                       action="callback", callback=check_moon, dest="foo")

(‘is_moon_full()’ の定義は読者への課題としましょう。)


File: python.info,  Node: コールバックの例5 固定引数,  Next: コールバックの例6 可変個の引数,  Prev: コールバックの例 4 任意の条件をチェックする,  Up: オプション処理コールバック

5.36.2.36 コールバックの例5: 固定引数
.....................................

決まった数の引数をとるようなコールパックオプションを定義するなら、問題は
やや興味深くなってきます。引数をとるようコールバックに指定するのは、
‘"store"’ や ‘"append"’ オプションの定義に似ています。 *note type: 46d3.
を定義していれば、そのオプションは引数を受け取ったときに該当する型に変換
できなければなりません。さらに *note nargs: 4702. を指定すれば、オプショ
ンは *note nargs: 4702. 個の引数を受け取ります。

標準の ‘"store"’ アクションをエミュレートする例を以下に示します:

     def store_value(option, opt_str, value, parser):
         setattr(parser.values, option.dest, value)
     ...
     parser.add_option("--foo",
                       action="callback", callback=store_value,
                       type="int", nargs=3, dest="foo")

*note optparse: 90. は 3 個の引数を受け取り、それらを整数に変換するとこ
ろまで面倒をみてくれます。ユーザは単にそれを保存するだけです。 (他の処理
もできます; いうまでもなく、この例にはコールバックは必要ありません)


File: python.info,  Node: コールバックの例6 可変個の引数,  Prev: コールバックの例5 固定引数,  Up: オプション処理コールバック

5.36.2.37 コールバックの例6: 可変個の引数
.........................................

あるオプションに可変個の引数を持たせたいと考えているなら、問題はいささか
手強くなってきます。この場合、 *note optparse: 90. では該当する組み込み
のオプション解析機能を提供していないので、自分でコールバックを書かなけれ
ばなりません。さらに、 *note optparse: 90. が普段処理している、伝統的な
Unix コマンドライン解析における難題を自分で解決しなければなりません。と
りわけ、コールバック関数では引数が裸の ‘--’ や ‘-’ の場合における慣習的
な処理規則:

   * either ‘--’ or ‘-’ can be option arguments

   * 裸の ‘--’ (何らかのオプションの引数でない場合): コマンドライン処理
     を停止し、‘--’ を無視します

   * 裸の ‘-’ (何らかのオプションの引数でない場合): コマンドライン処理を
     停止しますが、‘-’ は残します (‘parser.largs’ に追加します)

オプションが可変個の引数をとるようにさせたいなら、いくつかの巧妙で厄介な
問題に配慮しなければなりません。どういう実装をとるかは、アプリケーション
でどのようなトレードオフを考慮するかによります (このため、 *note
optparse: 90. では可変個の引数に関する問題を直接的に取り扱わないのです
)。

とはいえ、可変個の引数をもつオプションに対するスタブ (stub、仲介インター
フェース) を以下に示しておきます:

     def vararg_callback(option, opt_str, value, parser):
         assert value is None
         value = []

         def floatable(str):
             try:
                 float(str)
                 return True
             except ValueError:
                 return False

         for arg in parser.rargs:
             # stop on --foo like options
             if arg[:2] == "--" and len(arg) > 2:
                 break
             # stop on -a, but not on -3 or -3.0
             if arg[:1] == "-" and len(arg) > 1 and not floatable(arg):
                 break
             value.append(arg)

         del parser.rargs[:len(value)]
         setattr(parser.values, option.dest, value)

     ...
     parser.add_option("-c", "--callback", dest="vararg_attr",
                       action="callback", callback=vararg_callback)


File: python.info,  Node: optparse の拡張,  Next: 例外<20>,  Prev: オプション処理コールバック,  Up: optparse --- Parser for command line options

5.36.2.38 ‘optparse’ の拡張
...........................

*note optparse: 90. がコマンドラインオプションをどのように解釈するかを決
める二つの重要な要素はそれぞれのオプションのアクションと型なので、拡張の
方向は新しいアクションと型を追加することになると思います。

* Menu:

* 新しい型の追加::
* 新しいアクションの追加::


File: python.info,  Node: 新しい型の追加,  Next: 新しいアクションの追加,  Up: optparse の拡張

5.36.2.39 新しい型の追加
........................

新しい型を追加するためには、 *note optparse: 90. の *note Option: 46f8.
クラスのサブクラスを自身で定義する必要があります。このクラスには *note
optparse: 90. における型を定義する一対の属性があります。それは *note
TYPES: 472f. と *note TYPE_CHECKER: 4730. です。

 -- の属性: Option.TYPES

     *note TYPES: 472f. は型名のタプルです。新しく作るサブクラスでは、タ
     プル *note TYPES: 472f. を単純に標準のものを利用して新しく定義する
     と良いでしょう。

 -- の属性: Option.TYPE_CHECKER

     ‘TYPE_CHECKER’ は辞書で型名を型チェック関数に対応付けるものです。型
     チェック関数は以下のようなシグネチャを持ちます:

          def check_mytype(option, opt, value)

     ここで ‘option’ は *note Option: 46f8. のインスタンスであり、 ‘opt’
     はオプション文字列(たとえば ‘-f’)で、 ‘value’ は望みの型としてチェ
     ックされ変換されるべくコマンドラインで与えられる文字列です。
     ‘check_mytype()’ は想定されている型 ‘mytype’ のオブジェクトを返さな
     ければなりません。型チェック関数から返される値は *note
     OptionParser.parse_args(): 1477. で返されるOptionValues インスタン
     スに収められるか、またはコールバックに ‘value’ パラメータとして渡さ
     れます。

     型チェック関数は何か問題に遭遇したら *note OptionValueError: 2c20.
     を送出しなければなりません。 *note OptionValueError: 2c20. は文字列
     一つを引数に取り、それはそのまま *note OptionParser: 1476. の
     ‘error()’ メソッドに渡され、そこでプログラム名と文字列 ‘"error:"’ が
     前置されてプロセスが終了する前に stderr に出力されます。

馬鹿馬鹿しい例ですが、Python スタイルの複素数を解析する ‘"complex"’ オプ
ション型を作ってみせることにします。(*note optparse: 90. 1.3 が複素数の
サポートを組み込んでしまったため以前にも増して馬鹿らしくなりましたが、気
にしないでください。)

最初に必要な import 文を書きます:

     from copy import copy
     from optparse import Option, OptionValueError

まずは型チェック関数を定義しなければなりません。これは後で(これから定義
する Option のサブクラスの *note TYPE_CHECKER: 4730. クラス属性の中で) 参
照されることになります:

     def check_complex(option, opt, value):
         try:
             return complex(value)
         except ValueError:
             raise OptionValueError(
                 "option %s: invalid complex value: %r" % (opt, value))

最後に Option のサブクラスです:

     class MyOption (Option):
         TYPES = Option.TYPES + ("complex",)
         TYPE_CHECKER = copy(Option.TYPE_CHECKER)
         TYPE_CHECKER["complex"] = check_complex

(もしここで *note Option.TYPE_CHECKER: 4730. に *note copy(): 1e. を適用
しなければ、 *note optparse: 90. の Option クラスの *note TYPE_CHECKER:
4730. 属性をいじってしまうことになります。 Python の常として、良いマナー
と常識以外にそうすることを止めるものはありません。)

これだけです!  もう新しいオプション型を使うスクリプトを他の *note
optparse: 90. に基づいたスクリプトとまるで同じように書くことができます。
ただし、 OptionParser に Option でなく MyOption を使うように指示しなけれ
ばなければなりません:

     parser = OptionParser(option_class=MyOption)
     parser.add_option("-c", type="complex")

別のやり方として、オプションリストを構築して OptionParser に渡すという方
法もあります。 ‘add_option()’ を上でやったように使わないならば、
OptionParser にどのクラスを使うのか教える必要はありません:

     option_list = [MyOption("-c", action="store", type="complex", dest="c")]
     parser = OptionParser(option_list=option_list)


File: python.info,  Node: 新しいアクションの追加,  Prev: 新しい型の追加,  Up: optparse の拡張

5.36.2.40 新しいアクションの追加
................................

新しいアクションの追加はもう少しトリッキーです。というのも *note
optparse: 90. が使っている二つのアクションの分類を理解する必要があるから
です:

"store" アクション

     *note optparse: 90. が値を現在の OptionValues の属性に格納すること
     になるアクションです。この種類のオプションは Option のコンストラク
     タに *note dest: 46d4. 属性を与えることが要求されます。

"typed" アクション

     コマンドラインから引数を受け取り、それがある型であることが期待され
     ているアクションです。もう少しはっきり言えば、その型に変換される文
     字列を受け取るものです。この種類のオプションは Option のコンストラ
     クタに *note type: 46d3. 属性を与えることが要求されます。

この分類には重複する部分があります。デフォルトの "store" アクションには
‘"store"’, ‘"store_const"’, ‘"append"’, ‘"count"’ などがありますが、デフ
ォルトの "typed" オプションは ‘"store"’, ‘"append"’, ‘"callback"’ の三つ
です。

アクションを追加する際に、以下の Option のクラス属性(全て文字列のリスト
です) の中の少なくとも一つに付け加えることでそのアクションを分類する必要
があります:

 -- の属性: Option.ACTIONS

     全てのアクションは ACTIONS にリストされていなければなりません。

 -- の属性: Option.STORE_ACTIONS

     "store" アクションはここにもリストされます。

 -- の属性: Option.TYPED_ACTIONS

     "typed" アクションはここにもリストされます。

 -- の属性: Option.ALWAYS_TYPED_ACTIONS

     型を取るアクション (つまりそのオプションが値を取る) はここにもリス
     トされます。このことの唯一の効果は *note optparse: 90. が、型の指定
     が無くアクションが *note ALWAYS_TYPED_ACTIONS: 4736. のリストにある
     オプションに、デフォルト型 ‘"string"’ を割り当てるということだけで
     す。

実際に新しいアクションを実装するには、Option の ‘take_action()’ メソッド
をオーバライドしてそのアクションを認識する場合分けを追加しなければなりま
せん。

例えば、‘"extend"’ アクションというのを追加してみましょう。このアクショ
ンは標準的な ‘"append"’ アクションと似ていますが、コマンドラインから一つ
だけ値を読み取って既存のリストに追加するのではなく、複数の値をコンマ区切
りの文字列として読み取ってそれらで既存のリストを拡張します。すなわち、も
し ‘--names’ が ‘"string"’ 型の ‘"extend"’ オプションだとすると、次のコ
マンドライン

     --names=foo,bar --names blah --names ding,dong

の結果は次のリストになります

     ["foo", "bar", "blah", "ding", "dong"]

再び Option のサブクラスを定義します:

     class MyOption(Option):

         ACTIONS = Option.ACTIONS + ("extend",)
         STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
         TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
         ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)

         def take_action(self, action, dest, opt, value, values, parser):
             if action == "extend":
                 lvalue = value.split(",")
                 values.ensure_value(dest, []).extend(lvalue)
             else:
                 Option.take_action(
                     self, action, dest, opt, value, values, parser)

注意すべきは次のようなところです:

   * ‘"extend"’ はコマンドラインの値を予期していると同時にその値をどこか
     に格納しますので、 *note STORE_ACTIONS: 4734. と *note
     TYPED_ACTIONS: 4735. の両方に入ります。

   * *note optparse: 90. が ‘"extend"’ アクションに ‘"string"’ 型を割り
     当てるように ‘"extend"’ アクションは *note ALWAYS_TYPED_ACTIONS:
     4736. にも入れてあります。

   * ‘MyOption.take_action()’ にはこの新しいアクション一つの扱いだけを実
     装してあり、他の標準的な *note optparse: 90. のアクションについては
     ‘Option.take_action()’ に制御を戻すようにしてあります。

   * ‘values’ は optparse_parser.Values クラスのインスタンスであり、非常
     に有用な ‘ensure_value()’ メソッドを提供しています。
     ‘ensure_value()’ は本質的に安全弁付きの *note getattr(): b9f. です
     。次のように呼び出します

          values.ensure_value(attr, value)

     ‘values’ に ‘attr’ 属性が無いか ‘None’ だった場合に、
     ‘ensure_value()’ は最初に ‘value’ をセットし、それから ‘value’ を返
     します。この振る舞いは ‘"extend"’, ‘"append"’, ‘"count"’ のように、
     データを変数に集積し、またその変数がある型 (最初の二つはリスト、最
     後のは整数) であると期待されるアクションを作るのにとても使い易いも
     のです。 ‘ensure_value()’ を使えば、作ったアクションを使うスクリプ
     トはオプションに保存先にデフォルト値をセットすることに煩わされずに
     済みます。デフォルトを ‘None’ にしておけば ‘ensure_value()’ がそれ
     が必要になったときに適当な値を返してくれます。


File: python.info,  Node: 例外<20>,  Prev: optparse の拡張,  Up: optparse --- Parser for command line options

5.36.2.41 例外
..............

 -- 例外: optparse.OptionError

     Raised if an *note Option: 46f8. instance is created with invalid
     or inconsistent arguments.

 -- 例外: optparse.OptionConflictError

     Raised if conflicting options are added to an *note OptionParser:
     1476.

 -- 例外: optparse.OptionValueError

     Raised if an invalid option value is encountered on the command
     line.

 -- 例外: optparse.BadOptionError

     Raised if an invalid option is passed on the command line.

 -- 例外: optparse.AmbiguousOptionError

     Raised if an ambiguous option is passed on the command line.


File: python.info,  Node: セキュリティで考慮すべき点<6>,  Prev: 取って代わられたモジュール群,  Up: Python 標準ライブラリ

5.37 セキュリティで考慮すべき点
===============================

The following modules have specific security considerations:

   * *note base64: a.: *note base64 security considerations: 35d8. in
     RFC 4648(1)

   * *note hashlib: 5e.: *note all constructors take a "usedforsecurity"
     keyword-only argument disabling known insecure and blocked
     algorithms: 2a28.

   * *note http.server: 68. is not suitable for production use, only
     implementing basic security checks.  See the *note security
     considerations: 39fa.

   * *note logging: 7b.: *note Logging configuration uses eval(): 2c7e.

   * *note multiprocessing: 86.: *note Connection.recv() uses pickle:
     301b.

   * *note pickle: 95.: *note Restricting globals in pickle: 27f0.

   * *note random: a6. shouldn't be used for security purposes, use
     *note secrets: ae. instead

   * *note shelve: b1.: *note shelve is based on pickle and thus
     unsuitable for dealing with untrusted sources: 280c.

   * *note ssl: bb.: *note SSL/TLS security considerations: 31f1.

   * *note subprocess: c1.: *note Subprocess security considerations:
     30c1.

   * *note tempfile: c9.: *note mktemp is deprecated due to
     vulnerability to race conditions: 27af.

   * *note xml: 107.: *note XML vulnerabilities: 3607.

   * *note zipfile: 117.: *note maliciously prepared .zip files can
     cause disk volume exhaustion: 293f.

The *note -I: 92c. command line option can be used to run Python in
isolated mode.  When it cannot be used, the *note -P: 56e. option or the
*note PYTHONSAFEPATH: 56f. environment variable can be used to not
prepend a potentially unsafe path to *note sys.path: 38e. such as the
current directory, the script's directory or an empty string.

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc4648.html


File: python.info,  Node: Python インタプリタの拡張と埋め込み,  Next: Python/C API リファレンスマニュアル,  Prev: Python 標準ライブラリ,  Up: Top

6 Python インタプリタの拡張と埋め込み
*************************************

このドキュメントでは、Pythonインタプリンタを拡張する新しいモジュールをで
C またはC++ で書く方法を解説しています。このようなモジュールでは新しい関
数を定義するだけではなく、新しい型や、そのメソッドを定義することができま
す。ドキュメントでは他のアプリケーションでPythonを拡張言語として使用する
ために、Pythonインタプリタをアプリケーションに埋め込む方法についても解説
します。最後に、下層のオペレーティングシステムが動的(実行時)ロードをサポ
ートしていれば、拡張モジュールが動的にライブラリにロードされるように、モ
ジュールをコンパイルしリンクする方法について解説します。

このドキュメントでは、読者は Python について基礎的な知識を持ち合わせてい
るものと仮定しています。形式ばらない Python 言語の入門には、 *note
Python チュートリアル: 1b45. を読んでください。 *note Python
言語リファレンス: 12b. を読めば、 Python 言語についてより形式的な定義を
得られます。また、 *note Python 標準ライブラリ: 12a. では、Python に広い
適用範囲をもたらしている既存のオブジェクト型、関数、および (組み込み、お
よび Python で書かれたものの両方の) モジュールについて解説しています。

Python/C API 全体の詳しい説明は、別のドキュメントである、 *note Python/C
API リファレンスマニュアル: 1b47. を参照してください。

* Menu:

* おすすめのサードパーティツール::
* サードパーティツールなしで拡張を作る::
* 大規模なアプリケーションへの Python ランタイムの埋め込み::


File: python.info,  Node: おすすめのサードパーティツール,  Next: サードパーティツールなしで拡張を作る,  Up: Python インタプリタの拡張と埋め込み

6.1 おすすめのサードパーティツール
==================================

このガイドがカバーするのは、このバージョンの CPython の一部として提供さ
れている、拡張を作成するための基本的なツールだけです。 Cython(1),
cffi(2), SWIG(3), Numba(4) のようなサードパーティのツールは、 Python の
C および C++ 拡張を作成するための、より簡潔かつより洗練された手法を提供
します。

参考
....

Python Packaging User Guide: Binary Extensions(5)

     Python Packaging User Guideはバイナリ拡張の作成が簡単になる便利なツ
     ールをカバーしているだけではなく、まず始めになぜ拡張モジュールを作
     ることが望ましいかの様々な理由について議論しています。

   ---------- Footnotes ----------

   (1) https://cython.org/

   (2) https://cffi.readthedocs.io

   (3) https://www.swig.org

   (4) https://numba.pydata.org/

   (5) https://packaging.python.org/guides/packaging-binary-extensions/


File: python.info,  Node: サードパーティツールなしで拡張を作る,  Next: 大規模なアプリケーションへの Python ランタイムの埋め込み,  Prev: おすすめのサードパーティツール,  Up: Python インタプリタの拡張と埋め込み

6.2 サードパーティツールなしで拡張を作る
========================================

ガイドのこの節ではサードパーティツールの補助無しに C および C++ 拡張を作
成する方法を説明します。 これは自分自身の C 拡張を作成するおすすめの方法
というよりも、主にそれらのツールを作成する人向けのものです。

* Menu:

* C や C++ による Python の拡張::
* 拡張の型の定義; チュートリアル: 拡張の型の定義 チュートリアル.
* 拡張の型の定義; 雑多なトピック: 拡張の型の定義 雑多なトピック.
* C および C++ 拡張のビルド::
* Windows 上での C および C++ 拡張モジュールのビルド::


File: python.info,  Node: C や C++ による Python の拡張,  Next: 拡張の型の定義 チュートリアル,  Up: サードパーティツールなしで拡張を作る

6.2.1 C や C++ による Python の拡張
-----------------------------------

C プログラムの書き方を知っているなら、Python に新たな組み込みモジュール
を追加するのはきわめて簡単です。この新たなモジュール、拡張モジュール
('extension module') を使うと、Python が直接行えない二つのこと: 新しい組
み込みオブジェクトの実装、そして全ての C ライブラリ関数とシステムコール
に対する呼び出し、ができるようになります。

拡張モジュールをサポートするため、Python API (Application Programmer's
Interface) では一連の関数、マクロおよび変数を提供していて、Python ランタ
イムシステムのほとんどの側面へのアクセス手段を提供しています。 Python
API は、ヘッダ ‘"Python.h"’ をインクルードして C ソースに取り込みます。

拡張モジュールのコンパイル方法は、モジュールの用途やシステムの設定方法に
依存します。詳細は後の章で説明します。

     注釈: C 拡張のインターフェイスは CPython に固有のものであり、これに
     よる拡張モジュールはほかの Python 実装では動作しません。多くの場合
     、C 拡張を書くことを避けてほかの Python 実装のために移植性を確保す
     ることは可能です。たとえば、あなたがしたいことが C ライブラリの関数
     やシステムコールを呼び出すことである場合、 *note ctypes: 22. あるい
     は cffi(1) ライブラリの利用を検討すべきです。これらのモジュールは C
     コードとインターフェイスし、C 拡張を書いてコンパイルするのに較べて
     Python 実装間のより高い移植性をもった Python コードを書かせてくれま
     す。

* Menu:

* 簡単な例::
* 幕間小話; エラーと例外: 幕間小話 エラーと例外.
* 例に戻る::
* モジュールのメソッドテーブルと初期化関数::
* コンパイルとリンク::
* C から Python 関数を呼び出す::
* 拡張モジュール関数でのパラメタ展開::
* 拡張モジュール関数のキーワードパラメタ::
* 任意の値を構築する::
* 参照カウント法::
* C++での拡張モジュール作成::
* 拡張モジュールに C API を提供する::

   ---------- Footnotes ----------

   (1) https://cffi.readthedocs.io/


File: python.info,  Node: 簡単な例,  Next: 幕間小話 エラーと例外,  Up: C や C++ による Python の拡張

6.2.1.1 簡単な例
................

‘spam’ (Monty Python ファンの好物ですね) という名の拡張モジュールを作成
することにして、C ライブラリ関数 ‘system()’ に対する Python インターフェ
イスを作成したいとします。 (1) この関数は null で終端されたキャラクタ文
字列を引数にとり、整数を返します。この関数を以下のようにして Python から
呼び出せるようにしたいとします。

     >>> import spam
     >>> status = spam.system("ls -l")

まずは ‘spammodule.c’ を作成するところから始めます。 (伝統として、
‘spam’ という名前のモジュールを作成する場合、モジュールの実装が入った C
ファイルを ‘spammodule.c’ と呼ぶことになっています; ‘spammify’ のように
長すぎるモジュール名の場合には、単に ‘spammify.c’ にもできます。)

このファイルの最初の 2 行は以下のようにします:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

これで、Python API を取り込みます (必要なら、モジュールの用途に関する説
明や、著作権表示を追加します)。

     注釈: Python は、システムによっては標準ヘッダの定義に影響するような
     プリプロセッサ定義を行っているので、 ‘Python.h’ をいずれの標準ヘッ
     ダよりも前にインクルード 'せねばなりません' 。

     ‘#define PY_SSIZE_T_CLEAN’ は、いくつかの API では ‘int’ の代わりに
     ‘Py_ssize_t’ が使われるべきであることを示すために使われていました。
     これは Python 3.13 以降では不要となりましたが、後方互換性のために維
     持されています。このマクロの説明は *note 文字列とバッファ: 364. に
     あります。

‘Python.h’ で定義されているユーザから可視のシンボルは、全て接頭辞 ‘Py’ ま
たは ‘PY’ が付いています。ただし、標準ヘッダファイル内の定義は除きます。
簡単のためと、Python 内で広範に使うことになるという理由から、
‘"Python.h"’ はいくつかの標準ヘッダファイル: ‘<stdio.h>’ 、 ‘<string.h>’
、 ‘<errno.h>’ 、および ‘<stdlib.h>’ をインクルードしています。後者のヘ
ッダファイルがシステム上になければ、 ‘"Python.h"’ が関数 ‘malloc()’ 、
‘free()’ および ‘realloc()’ を直接定義します。

次にファイルに追加する内容は、Python 式 ‘spam.system(string)’ を評価する
際に呼び出されることになる C 関数です (この関数を最終的にどのように呼び
出すかは、後ですぐわかります):

     static PyObject *
     spam_system(PyObject *self, PyObject *args)
     {
         const char *command;
         int sts;

         if (!PyArg_ParseTuple(args, "s", &command))
             return NULL;
         sts = system(command);
         return PyLong_FromLong(sts);
     }

ここでは、Python の引数リスト (例えば、単一の式 ‘"ls -l"’) から C 関数に
渡す引数にそのまま変換しています。 C 関数は常に二つの引数を持ち、便宜的
に 'self' および 'args' と呼ばれます。

'self' 引数には、モジュールレベルの関数であればモジュールが、メソッドに
はオブジェクトインスタンスが渡されます。

'args' 引数は、引数の入った Python タプルオブジェクトへのポインタになり
ます。タプル内の各要素は、呼び出しの際の引数リストにおける各引数に対応し
ます。引数は Python オブジェクトです -- C 関数で引数を使って何かを行うに
は、オブジェクトから C の値に変換せねばなりません。Python API の関数
*note PyArg_ParseTuple(): 53d. は引数の型をチェックし、C の値に変換しま
す。 *note PyArg_ParseTuple(): 53d. はテンプレート文字列を使って、引数オ
ブジェクトの型と、変換された値を入れる C 変数の型を判別します。これにつ
いては後で詳しく説明します。

*note PyArg_ParseTuple(): 53d. は、全ての引数が正しい型を持っていて、ア
ドレス渡しされた各変数に各引数要素を保存したときに真 (非ゼロ) を返します
。この関数は不正な引数リストを渡すと偽 (ゼロ) を返します。後者の場合、関
数は適切な例外を送出するので、呼び出し側は (例にもあるように) すぐに
‘NULL’ を返すようにしてください。

   ---------- Footnotes ----------

   (1) この関数へのインターフェースはすでに標準モジュール *note os: 91.
にあります -- この関数を選んだのは、単純で直接的な例を示したいからです。


File: python.info,  Node: 幕間小話 エラーと例外,  Next: 例に戻る,  Prev: 簡単な例,  Up: C や C++ による Python の拡張

6.2.1.2 幕間小話: エラーと例外
..............................

An important convention throughout the Python interpreter is the
following: when a function fails, it should set an exception condition
and return an error value (usually ‘-1’ or a ‘NULL’ pointer).  Exception
information is stored in three members of the interpreter's thread
state.  These are ‘NULL’ if there is no exception.  Otherwise they are
the C equivalents of the members of the Python tuple returned by *note
sys.exc_info(): 656.  These are the exception type, exception instance,
and a traceback object.  It is important to know about them to
understand how errors are passed around.

Python API では、様々な型の例外をセットするための関数をいくつか定義して
います。

もっともよく用いられるのは *note PyErr_SetString(): 548. です。引数は例
外オブジェクトと C 文字列です。例外オブジェクトは通常、
‘PyExc_ZeroDivisionError’ のような定義済みのオブジェクトです。 C 文字列
はエラーの原因を示し、Python 文字列オブジェクトに変換されて例外の "付属
値" に保存されます。

もう一つ有用な関数として *note PyErr_SetFromErrno(): 4748. があります。
この関数は引数に例外だけをとり、付属値はグローバル変数 ‘errno’ から構築
します。もっとも汎用的な関数は *note PyErr_SetObject(): 547. で、二つの
オブジェクト、例外と付属値を引数にとります。これら関数に渡すオブジェクト
には *note Py_INCREF(): 53a. を使う必要はありません。

例外がセットされているかどうかは、 *note PyErr_Occurred(): 185c. を使っ
て非破壊的に調べられます。この関数は現在の例外オブジェクトを返します。例
外が発生していない場合には ‘NULL’ を返します。通常は、関数の戻り値からエ
ラーが発生したかを判別できるはずなので、 *note PyErr_Occurred(): 185c. を
呼び出す必要はありません。

関数 'g' を呼び出す 'f' が、前者の関数の呼び出しに失敗したことを検出する
と、 'f' 自体はエラー値 (大抵は ‘NULL’ や ‘-1’) を返さねばなりません。し
かし、 ‘PyErr_*’ 関数群のいずれかを呼び出す必要は 'ありません' -- なぜな
ら、 'g' がすでに呼び出しているからです。次いで 'f' を呼び出したコードも
エラーを示す値を '自らを呼び出したコード' に返すことになりますが、同様に
‘PyErr_*’ は '呼び出しません' 。以下同様に続きます -- エラーの最も詳しい
原因は、最初にエラーを検出した関数がすでに報告しているからです。エラーが
Python インタプリタのメインループに到達すると、現在実行中の Python コー
ドは一時停止し、 Python プログラマが指定した例外ハンドラを探し出そうとし
ます。

(モジュールが ‘PyErr_*’ 関数をもう一度呼び出して、より詳細なエラーメッセ
ージを提供するような状況があります。このような状況ではそうすべきです。と
はいえ、一般的な規則としては、この関数を何度も呼び出す必要はなく、ともす
ればエラーの原因に関する情報を失う結果になりがちです: これにより、ほとん
どの操作が様々な理由から失敗するかもしれません)

ある関数呼び出しでの処理の失敗によってセットされた例外を無視するには、
*note PyErr_Clear(): ffb. を呼び出して例外状態を明示的に消去しなくてはな
りません。エラーをインタプリタには渡したくなく、自前で (何か他の作業を行
ったり、何も起こらなかったかのように見せかけるような) エラー処理を完全に
行う場合にのみ、 *note PyErr_Clear(): ffb. を呼び出すようにすべきです。

‘malloc()’ の呼び出し失敗は、常に例外にしなくてはなりません --
‘malloc()’ (または ‘realloc()’) を直接呼び出しているコードは、 *note
PyErr_NoMemory(): 4749. を呼び出して、失敗を示す値を返さねばなりません。
オブジェクトを生成する全ての関数 (例えば *note PyLong_FromLong(): 17a4.)
は *note PyErr_NoMemory(): 4749. の呼び出しを済ませてしまうので、この規
則が関係するのは直接 ‘malloc()’ を呼び出すコードだけです。

また、 *note PyArg_ParseTuple(): 53d. という重要な例外を除いて、整数の状
態コードを返す関数はたいてい、Unix のシステムコールと同じく、処理が成功
した際にはゼロまたは正の値を返し、失敗した場合には ‘-1’ を返します。

最後に、エラー標示値を返す際に、(エラーが発生するまでに既に生成してしま
ったオブジェクトに対して *note Py_XDECREF(): 75a. や *note Py_DECREF():
53b. を呼び出して) ごみ処理を注意深く行ってください!

The choice of which exception to raise is entirely yours.  There are
predeclared C objects corresponding to all built-in Python exceptions,
such as ‘PyExc_ZeroDivisionError’, which you can use directly.  Of
course, you should choose exceptions wisely -- don't use
‘PyExc_TypeError’ to mean that a file couldn't be opened (that should
probably be ‘PyExc_OSError’).  If something's wrong with the argument
list, the *note PyArg_ParseTuple(): 53d. function usually raises
‘PyExc_TypeError’.  If you have an argument whose value must be in a
particular range or must satisfy other conditions, ‘PyExc_ValueError’ is
appropriate.

モジュール固有の新たな例外も定義できます。定義するには、通常はファイルの
先頭部分に静的なオブジェクト変数の宣言を行います:

     static PyObject *SpamError;

and initialize it in your module's initialization function
(‘PyInit_spam()’) with an exception object:

     PyMODINIT_FUNC
     PyInit_spam(void)
     {
         PyObject *m;

         m = PyModule_Create(&spammodule);
         if (m == NULL)
             return NULL;

         SpamError = PyErr_NewException("spam.error", NULL, NULL);
         if (PyModule_AddObjectRef(m, "error", SpamError) < 0) {
             Py_CLEAR(SpamError);
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

Note that the Python name for the exception object is ‘spam.error’.  The
*note PyErr_NewException(): 123b. function may create a class with the
base class being *note Exception: 9a7. (unless another class is passed
in instead of ‘NULL’), described in *note 組み込み例外: 17ee.

Note also that the ‘SpamError’ variable retains a reference to the newly
created exception class; this is intentional!  Since the exception could
be removed from the module by external code, an owned reference to the
class is needed to ensure that it will not be discarded, causing
‘SpamError’ to become a dangling pointer.  Should it become a dangling
pointer, C code which raises the exception could cause a core dump or
other unintended side effects.

We discuss the use of *note PyMODINIT_FUNC: 147c. as a function return
type later in this sample.

The ‘spam.error’ exception can be raised in your extension module using
a call to *note PyErr_SetString(): 548. as shown below:

     static PyObject *
     spam_system(PyObject *self, PyObject *args)
     {
         const char *command;
         int sts;

         if (!PyArg_ParseTuple(args, "s", &command))
             return NULL;
         sts = system(command);
         if (sts < 0) {
             PyErr_SetString(SpamError, "System command failed");
             return NULL;
         }
         return PyLong_FromLong(sts);
     }


File: python.info,  Node: 例に戻る,  Next: モジュールのメソッドテーブルと初期化関数,  Prev: 幕間小話 エラーと例外,  Up: C や C++ による Python の拡張

6.2.1.3 例に戻る
................

先ほどの関数の例に戻ると、今度は以下の実行文を理解できるはずです:

     if (!PyArg_ParseTuple(args, "s", &command))
         return NULL;

It returns ‘NULL’ (the error indicator for functions returning object
pointers) if an error is detected in the argument list, relying on the
exception set by *note PyArg_ParseTuple(): 53d.  Otherwise the string
value of the argument has been copied to the local variable ‘command’.
This is a pointer assignment and you are not supposed to modify the
string to which it points (so in Standard C, the variable ‘command’
should properly be declared as ‘const char *command’).

次の文では、 *note PyArg_ParseTuple(): 53d. で得た文字列を渡して Unix 関
数 ‘system()’ を呼び出しています:

     sts = system(command);

Our ‘spam.system()’ function must return the value of ‘sts’ as a Python
object.  This is done using the function *note PyLong_FromLong(): 17a4.

     return PyLong_FromLong(sts);

上の場合では、整数オブジェクトを返します。(そう、整数ですら、 Python に
おいてはヒープ上のオブジェクトなのです!  )

何ら有用な値を返さない関数 (void を返す関数) に対応する Python の関数は
‘None’ を返さねばなりません。関数に ‘None’ を返させるには、以下のような
慣用句を使います (この慣用句は *note Py_RETURN_NONE: 1418. マクロに実装
されています):

     Py_INCREF(Py_None);
     return Py_None;

*note Py_None: 474c. は特殊な Pyhton オブジェクトである ‘None’ に対応す
る C での名前です。これまで見てきたようにほとんどのコンテキストで "エラ
ー" を意味する ‘NULL’ ポインタとは違い、 ‘None’ は純粋な Python のオブジ
ェクトです。


File: python.info,  Node: モジュールのメソッドテーブルと初期化関数,  Next: コンパイルとリンク,  Prev: 例に戻る,  Up: C や C++ による Python の拡張

6.2.1.4 モジュールのメソッドテーブルと初期化関数
................................................

I promised to show how ‘spam_system()’ is called from Python programs.
First, we need to list its name and address in a "method table":

     static PyMethodDef SpamMethods[] = {
         ...
         {"system",  spam_system, METH_VARARGS,
          "Execute a shell command."},
         ...
         {NULL, NULL, 0, NULL}        /* Sentinel */
     };

リスト要素の三つ目のエントリ (‘METH_VARARGS’) に注意してください。このエ
ントリは、C 関数が使う呼び出し規約をインタプリタに教えるためのフラグです
。通常この値は ‘METH_VARARGS’ か ‘METH_VARARGS | METH_KEYWORDS’ のはずで
す; ‘0’ は旧式の *note PyArg_ParseTuple(): 53d. の変化形が使われることを
意味します。

‘METH_VARARGS’ だけを使う場合、C 関数は、Python レベルでの引数が *note
PyArg_ParseTuple(): 53d. が受理できるタプルの形式で渡されるものと想定し
なければなりません; この関数についての詳細は下で説明します。

The *note METH_KEYWORDS: 474f. bit may be set in the third field if
keyword arguments should be passed to the function.  In this case, the C
function should accept a third ‘PyObject *’ parameter which will be a
dictionary of keywords.  Use *note PyArg_ParseTupleAndKeywords(): 35c.
to parse the arguments to such a function.

メソッドテーブルはモジュール定義の構造体から参照されていなければなりませ
ん:

     static struct PyModuleDef spammodule = {
         PyModuleDef_HEAD_INIT,
         "spam",   /* name of module */
         spam_doc, /* module documentation, may be NULL */
         -1,       /* size of per-interpreter state of the module,
                      or -1 if the module keeps state in global variables. */
         SpamMethods
     };

This structure, in turn, must be passed to the interpreter in the
module's initialization function.  The initialization function must be
named ‘PyInit_name()’, where 'name' is the name of the module, and
should be the only non-‘static’ item defined in the module file:

     PyMODINIT_FUNC
     PyInit_spam(void)
     {
         return PyModule_Create(&spammodule);
     }

Note that *note PyMODINIT_FUNC: 147c. declares the function as ‘PyObject
*’ return type, declares any special linkage declarations required by
the platform, and for C++ declares the function as ‘extern "C"’.

When the Python program imports module ‘spam’ for the first time,
‘PyInit_spam()’ is called.  (See below for comments about embedding
Python.)  It calls *note PyModule_Create(): 4750, which returns a module
object, and inserts built-in function objects into the newly created
module based upon the table (an array of *note PyMethodDef: 1480.
structures) found in the module definition.  *note PyModule_Create():
4750. returns a pointer to the module object that it creates.  It may
abort with a fatal error for certain errors, or return ‘NULL’ if the
module could not be initialized satisfactorily.  The init function must
return the module object to its caller, so that it then gets inserted
into ‘sys.modules’.

When embedding Python, the ‘PyInit_spam()’ function is not called
automatically unless there's an entry in the ‘PyImport_Inittab’ table.
To add the module to the initialization table, use *note
PyImport_AppendInittab(): 170e, optionally followed by an import of the
module:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

     int
     main(int argc, char *argv[])
     {
         PyStatus status;
         PyConfig config;
         PyConfig_InitPythonConfig(&config);

         /* Add a built-in module, before Py_Initialize */
         if (PyImport_AppendInittab("spam", PyInit_spam) == -1) {
             fprintf(stderr, "Error: could not extend in-built modules table\n");
             exit(1);
         }

         /* Pass argv[0] to the Python interpreter */
         status = PyConfig_SetBytesString(&config, &config.program_name, argv[0]);
         if (PyStatus_Exception(status)) {
             goto exception;
         }

         /* Initialize the Python interpreter.  Required.
            If this step fails, it will be a fatal error. */
         status = Py_InitializeFromConfig(&config);
         if (PyStatus_Exception(status)) {
             goto exception;
         }
         PyConfig_Clear(&config);

         /* Optionally import the module; alternatively,
            import can be deferred until the embedded script
            imports it. */
         PyObject *pmodule = PyImport_ImportModule("spam");
         if (!pmodule) {
             PyErr_Print();
             fprintf(stderr, "Error: could not import module 'spam'\n");
         }

         // ... use Python C API here ...

         return 0;

       exception:
          PyConfig_Clear(&config);
          Py_ExitStatusException(status);
     }

     注釈: 単一のプロセス内 (または ‘fork()’ 後の ‘exec()’ が介入してい
     ない状態) における複数のインタプリタにおいて、 ‘sys.modules’ からエ
     ントリを除去したり新たなコンパイル済みモジュールを import したりす
     ると、拡張モジュールによっては問題を生じることがあります。拡張モジ
     ュールの作者は、内部データ構造を初期化する際にはよくよく用心すべき
     です。

より実質的なモジュール例は、Python ソース配布物に ‘Modules/xxmodule.c’ と
いう名前で入っています。このファイルはテンプレートとしても利用できますし
、単に例としても読めます。

     注釈: ‘xmodule’ は ‘spam’ と異なり、 '多段階初期化 (multi-phase
     initialization' (Python 3.5 の新機能) を使っています。
     ‘PyInit_spam’ が PyModuleDef を返し、モジュールの生成は後に import
     機構が行います。多段階初期化についての詳細は PEP 489(1) を参照して
     ください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0489/


File: python.info,  Node: コンパイルとリンク,  Next: C から Python 関数を呼び出す,  Prev: モジュールのメソッドテーブルと初期化関数,  Up: C や C++ による Python の拡張

6.2.1.5 コンパイルとリンク
..........................

新しい拡張モジュールを使えるようになるまで、まだ二つの作業: コンパイルと
、Python システムへのリンク、が残っています。動的読み込み (dynamic
loading) を使っているのなら、作業の詳細は自分のシステムが使っている動的
読み込みの形式によって変わるかもしれません; 詳しくは、拡張モジュールのビ
ルドに関する章 (*note C および C++ 拡張のビルド: 4753. 章) や、Windows に
おけるビルドに関係する追加情報の章 (*note Windows 上での C および C++
拡張モジュールのビルド: 1da0. 章) を参照してください。

動的読み込みを使えなかったり、モジュールを常時 Python インタプリタの一部
にしておきたい場合には、インタプリタのビルド設定を変更して再ビルドしなけ
ればならなくなるでしょう。Unixでは、幸運なことにこの作業はとても単純です
: 単に自作のモジュールファイル (例えば ‘spammodule.c’) を展開したソース
配布物の ‘Modules/’ ディレクトリに置き、 ‘Modules/Setup.local’ に自分の
ファイルを説明する以下の一行:

     spam spammodule.o

を追加して、トップレベルのディレクトリで ‘make’ を実行して、インタプリタ
を再ビルドするだけです。 ‘Modules/’ サブディレクトリでも ‘make’ を実行で
きますが、前もって '‘make’ Makefile' を実行して ‘Makefile’ を再ビルドし
ておかなければならりません。(この作業は ‘Setup’ ファイルを変更するたびに
必要です。)

モジュールが別のライブラリとリンクされている必要がある場合、ライブラリも
設定ファイルに列挙できます。例えば以下のようにします。

     spam spammodule.o -lX11


File: python.info,  Node: C から Python 関数を呼び出す,  Next: 拡張モジュール関数でのパラメタ展開,  Prev: コンパイルとリンク,  Up: C や C++ による Python の拡張

6.2.1.6 C から Python 関数を呼び出す
....................................

これまでは、Python からの C 関数の呼び出しに重点を置いて述べてきました。
ところでこの逆: C からの Python 関数の呼び出しもまた有用です。とりわけ、
いわゆる "コールバック" 関数をサポートするようなライブラリを作成する際に
はこの機能が便利です。ある C インターフェースがコールバックを利用してい
る場合、同等の機能を提供する Python コードでは、しばしば Python プログラ
マにコールバック機構を提供する必要があります; このとき実装では、 C で書
かれたコールバック関数から Python で書かれたコールパック関数を呼び出すよ
うにする必要があるでしょう。もちろん、他の用途も考えられます。

幸運なことに、Python インタプリタは簡単に再帰呼び出しでき、 Python 関数
を呼び出すための標準インターフェースもあります。 (Python パーザを特定の
入力文字を使って呼び出す方法について詳説するつもりはありません -- この方
法に興味があるなら、 Python ソースコードの ‘Modules/main.c’ にある、コマ
ンドラインオプション *note -c: 5aa. の実装を見てください)

Python 関数の呼び出しは簡単です。まず、C のコードに対してコールバックを
登録しようとする Python プログラムは、何らかの方法で Python の関数オブジ
ェクトを渡さねばなりません。このために、コールバック登録関数 (またはその
他のインターフェース) を提供せねばなりません。このコールバック登録関数が
呼び出された際に、引き渡された Python 関数オブジェクトへのポインタをグロ
ーバル変数に -- あるいは、どこか適切な場所に -- 保存します (関数オブジェ
クトを *note Py_INCREF(): 53a. するようよく注意してください!)。例えば、
以下のような関数がモジュールの一部になっていることでしょう:

     static PyObject *my_callback = NULL;

     static PyObject *
     my_set_callback(PyObject *dummy, PyObject *args)
     {
         PyObject *result = NULL;
         PyObject *temp;

         if (PyArg_ParseTuple(args, "O:set_callback", &temp)) {
             if (!PyCallable_Check(temp)) {
                 PyErr_SetString(PyExc_TypeError, "parameter must be callable");
                 return NULL;
             }
             Py_XINCREF(temp);         /* Add a reference to new callback */
             Py_XDECREF(my_callback);  /* Dispose of previous callback */
             my_callback = temp;       /* Remember new callback */
             /* Boilerplate to return "None" */
             Py_INCREF(Py_None);
             result = Py_None;
         }
         return result;
     }

This function must be registered with the interpreter using the *note
METH_VARARGS: 14b3. flag; this is described in section *note
モジュールのメソッドテーブルと初期化関数: 474d.  The *note
PyArg_ParseTuple(): 53d. function and its arguments are documented in
section *note 拡張モジュール関数でのパラメタ展開: 4756.

*note Py_XINCREF(): a33. および *note Py_XDECREF(): 75a. は、オブジェク
トに対する参照カウントをインクリメント/デクリメントするためのマクロで、
‘NULL’ ポインタが渡されても安全に操作できる形式です (とはいえ、上の流れ
では 'temp' が ‘NULL’ になることはありません)。これらのマクロと参照カウ
ントについては、 *note 参照カウント法: 4757. で説明しています。

その後、コールバック関数を呼び出す時が来たら、C 関数 *note
PyObject_CallObject(): 4758. を呼び出します。この関数には二つの引数:
Python 関数と Python 関数の引数リストがあり、いずれも任意の Python オブ
ジェクトを表すポインタ型です。引数リストは常にタプルオブジェクトでなけれ
ばならず、その長さは引数の数になります。Python 関数を引数なしで呼び出す
のなら、 ‘NULL’ か空のタプルを渡します; 単一の引数で関数を呼び出すのなら
、単要素 (singleton) のタプルを渡します。 *note Py_BuildValue(): 875. の
書式文字列中に、ゼロ個または一個以上の書式化コードが入った丸括弧がある場
合、この関数はタプルを返します。以下に例を示します:

     int arg;
     PyObject *arglist;
     PyObject *result;
     ...
     arg = 123;
     ...
     /* Time to call the callback */
     arglist = Py_BuildValue("(i)", arg);
     result = PyObject_CallObject(my_callback, arglist);
     Py_DECREF(arglist);

*note PyObject_CallObject(): 4758. は Python オブジェクトへのポインタを
返します: これは Python 関数からの戻り値になります。 *note
PyObject_CallObject(): 4758. は、引数に対して "参照カウント中立
(reference-count- neutral)" です。上の例ではタプルを生成して引数リストと
して提供しており、このタプルは *note PyObject_CallObject(): 4758. の呼び
出し直後に *note Py_DECREF(): 53b. されています。

*note PyObject_CallObject(): 4758. は戻り値として "新しい" オブジェクト:
新規に作成されたオブジェクトか、既存のオブジェクトの参照カウントをインク
リメントしたものを返します。従って、このオブジェクトをグローバル変数に保
存したいのでないかぎり、たとえこの戻り値に興味がなくても (むしろ、そうで
あればなおさら!)  何がしかの方法で戻り値オブジェクトを *note
Py_DECREF(): 53b. しなければなりません。

とはいえ、戻り値を *note Py_DECREF(): 53b. する前には、値が ‘NULL’ でな
いかチェックしておくことが重要です。もし ‘NULL’ なら、呼び出した Python
関数は例外を送出して終了させられています。 *note PyObject_CallObject():
4758. を呼び出しているコード自体もまた Python から呼び出されているのであ
れば、今度は C コードが自分を呼び出している Python コードにエラー標示値
を返さねばなりません。それにより、インタプリタはスタックトレースを出力し
たり、例外を処理するための Python コードを呼び出したりできます。例外の送
出が不可能だったり、したくないのなら、 *note PyErr_Clear(): ffb. を呼ん
で例外を消去しておかねばなりません。例えば以下のようにします:

     if (result == NULL)
         return NULL; /* Pass error back */
     ...use result...
     Py_DECREF(result);

Python コールバック関数をどんなインターフェースにしたいかによっては、引
数リストを *note PyObject_CallObject(): 4758. に与えなければならない場合
もあります。あるケースでは、コールバック関数を指定したのと同じインターフ
ェースを介して、引数リストも渡されているかもしれません。また別のケースで
は、新しいタプルを構築して引数リストを渡さねばならないかもしれません。こ
の場合最も簡単なのは *note Py_BuildValue(): 875. を呼ぶやり方です。例え
ば、整数のイベントコードを渡したければ、以下のようなコードを使うことにな
るでしょう:

     PyObject *arglist;
     ...
     arglist = Py_BuildValue("(l)", eventcode);
     result = PyObject_CallObject(my_callback, arglist);
     Py_DECREF(arglist);
     if (result == NULL)
         return NULL; /* Pass error back */
     /* Here maybe use the result */
     Py_DECREF(result);

‘Py_DECREF(arglist)’ が呼び出しの直後、エラーチェックよりも前に置かれて
いることに注意してください!  また、厳密に言えば、このコードは完全ではあ
りません: *note Py_BuildValue(): 875. はメモリ不足におちいるかもしれず、
チェックしておくべきです。

通常の引数とキーワード引数をサポートする *note PyObject_Call(): 376. を
使って、キーワード引数を伴う関数呼び出しをすることができます。上の例と同
じように、 *note Py_BuildValue(): 875. を作って辞書を作ります。

     PyObject *dict;
     ...
     dict = Py_BuildValue("{s:i}", "name", val);
     result = PyObject_Call(my_callback, NULL, dict);
     Py_DECREF(dict);
     if (result == NULL)
         return NULL; /* Pass error back */
     /* Here maybe use the result */
     Py_DECREF(result);


File: python.info,  Node: 拡張モジュール関数でのパラメタ展開,  Next: 拡張モジュール関数のキーワードパラメタ,  Prev: C から Python 関数を呼び出す,  Up: C や C++ による Python の拡張

6.2.1.7 拡張モジュール関数でのパラメタ展開
..........................................

*note PyArg_ParseTuple(): 53d. 関数は以下のように宣言されています:

     int PyArg_ParseTuple(PyObject *arg, const char *format, ...);

引数 'arg' は C 関数から Python に渡される引数リストが入ったタプルオブジ
ェクトでなければなりません。 'format' 引数は書式文字列で、 Python/C API
リファレンスマニュアルの *note 引数の解釈と値の構築: 876. で解説されてい
る書法に従わねばなりません。残りの引数は、それぞれの変数のアドレスで、書
式化文字列から決まる型になっていなければなりません。

*note PyArg_ParseTuple(): 53d. は Python 側から与えられた引数が必要な型
になっているか調べるのに対し、 *note PyArg_ParseTuple(): 53d. は呼び出し
の際に渡された C 変数のアドレスが有効な値を持つか調べられないことに注意
してください: ここで間違いを犯すと、コードがクラッシュするかもしれません
し、少なくともでたらめなビットをメモリに上書きしてしまいます。慎重に!

呼び出し側に提供されるオブジェクトへの参照はすべて '借用' 参照 (borrowed
reference) になります; これらのオブジェクトの参照カウントをデクリメント
してはなりません!

以下にいくつかの呼び出し例を示します:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

     int ok;
     int i, j;
     long k, l;
     const char *s;
     Py_ssize_t size;

     ok = PyArg_ParseTuple(args, ""); /* No arguments */
         /* Python call: f() */

     ok = PyArg_ParseTuple(args, "s", &s); /* A string */
         /* Possible Python call: f('whoops!') */

     ok = PyArg_ParseTuple(args, "lls", &k, &l, &s); /* Two longs and a string */
         /* Possible Python call: f(1, 2, 'three') */

     ok = PyArg_ParseTuple(args, "(ii)s#", &i, &j, &s, &size);
         /* A pair of ints and a string, whose size is also returned */
         /* Possible Python call: f((1, 2), 'three') */

     {
         const char *file;
         const char *mode = "r";
         int bufsize = 0;
         ok = PyArg_ParseTuple(args, "s|si", &file, &mode, &bufsize);
         /* A string, and optionally another string and an integer */
         /* Possible Python calls:
            f('spam')
            f('spam', 'w')
            f('spam', 'wb', 100000) */
     }

     {
         int left, top, right, bottom, h, v;
         ok = PyArg_ParseTuple(args, "((ii)(ii))(ii)",
                  &left, &top, &right, &bottom, &h, &v);
         /* A rectangle and a point */
         /* Possible Python call:
            f(((0, 0), (400, 300)), (10, 10)) */
     }

     {
         Py_complex c;
         ok = PyArg_ParseTuple(args, "D:myfunction", &c);
         /* a complex, also providing a function name for errors */
         /* Possible Python call: myfunction(1+2j) */
     }


File: python.info,  Node: 拡張モジュール関数のキーワードパラメタ,  Next: 任意の値を構築する,  Prev: 拡張モジュール関数でのパラメタ展開,  Up: C や C++ による Python の拡張

6.2.1.8 拡張モジュール関数のキーワードパラメタ
..............................................

*note PyArg_ParseTupleAndKeywords(): 35c. は、以下のように宣言されていま
す:

     int PyArg_ParseTupleAndKeywords(PyObject *arg, PyObject *kwdict,
                                     const char *format, char * const *kwlist, ...);

'arg' と 'format' パラメタは *note PyArg_ParseTuple(): 53d. のものと同じ
です。 'kwdict' パラメタはキーワード引数の入った辞書で、 Python ランタイ
ムシステムから第三パラメタとして受け取ります。 'kwlist' パラメタは各パラ
メタを識別するための文字列からなる、 ‘NULL’ 終端されたリストです; 各パラ
メタ名は 'format' 中の型情報に対して左から右の順に照合されます。成功する
と *note PyArg_ParseTupleAndKeywords(): 35c. は真を返し、それ以外の場合
には適切な例外を送出して偽を返します。

     注釈: キーワード引数を使っている場合、タプルは入れ子にして使えませ
     ん!  'kwlist' 内に存在しないキーワードパラメタが渡された場合、
     *note TypeError: 502. の送出を引き起こします。

以下にキーワードを使ったモジュール例を示します。これは Geoff Philbrick
(<philbrick@hks.com>) によるプログラム例をもとにしています:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

     static PyObject *
     keywdarg_parrot(PyObject *self, PyObject *args, PyObject *keywds)
     {
         int voltage;
         const char *state = "a stiff";
         const char *action = "voom";
         const char *type = "Norwegian Blue";

         static char *kwlist[] = {"voltage", "state", "action", "type", NULL};

         if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|sss", kwlist,
                                          &voltage, &state, &action, &type))
             return NULL;

         printf("-- This parrot wouldn't %s if you put %i Volts through it.\n",
                action, voltage);
         printf("-- Lovely plumage, the %s -- It's %s!\n", type, state);

         Py_RETURN_NONE;
     }

     static PyMethodDef keywdarg_methods[] = {
         /* The cast of the function is necessary since PyCFunction values
          * only take two PyObject* parameters, and keywdarg_parrot() takes
          * three.
          */
         {"parrot", (PyCFunction)(void(*)(void))keywdarg_parrot, METH_VARARGS | METH_KEYWORDS,
          "Print a lovely skit to standard output."},
         {NULL, NULL, 0, NULL}   /* sentinel */
     };

     static struct PyModuleDef keywdargmodule = {
         PyModuleDef_HEAD_INIT,
         "keywdarg",
         NULL,
         -1,
         keywdarg_methods
     };

     PyMODINIT_FUNC
     PyInit_keywdarg(void)
     {
         return PyModule_Create(&keywdargmodule);
     }


File: python.info,  Node: 任意の値を構築する,  Next: 参照カウント法,  Prev: 拡張モジュール関数のキーワードパラメタ,  Up: C や C++ による Python の拡張

6.2.1.9 任意の値を構築する
..........................

*note Py_BuildValue(): 875. は *note PyArg_ParseTuple(): 53d. の対極に位
置するものです。この関数は以下のように定義されています:

     PyObject *Py_BuildValue(const char *format, ...);

*note Py_BuildValue(): 875. は、 *note PyArg_ParseTuple(): 53d. の認識す
る一連の書式単位に似た書式単位を認識します。ただし (関数への出力ではなく
、入力に使われる) 引数はポインタではなく、ただの値でなければなりません。
Python から呼び出された C 関数が返す値として適切な、新たな Python オブジ
ェクトを返します。

*note PyArg_ParseTuple(): 53d. とは一つ違う点があります: *note
PyArg_ParseTuple(): 53d. は第一引数をタプルにする必要があります (Python
の引数リストは内部的には常にタプルとして表現されるからです) が、 *note
Py_BuildValue(): 875. はタプルを生成するとは限りません。 *note
Py_BuildValue(): 875. は書式文字列中に書式単位が二つかそれ以上入っている
場合にのみタプルを構築します。書式文字列が空なら、 ‘None’ を返します。き
っかり一つの書式単位なら、その書式単位が記述している何らかのオブジェクト
になります。サイズが 0 や 1 のタプル返させたいのなら、書式文字列を丸括弧
で囲います。

以下に例を示します (左に呼び出し例を、右に構築される Python 値を示します
):

     Py_BuildValue("")                        None
     Py_BuildValue("i", 123)                  123
     Py_BuildValue("iii", 123, 456, 789)      (123, 456, 789)
     Py_BuildValue("s", "hello")              'hello'
     Py_BuildValue("y", "hello")              b'hello'
     Py_BuildValue("ss", "hello", "world")    ('hello', 'world')
     Py_BuildValue("s#", "hello", 4)          'hell'
     Py_BuildValue("y#", "hello", 4)          b'hell'
     Py_BuildValue("()")                      ()
     Py_BuildValue("(i)", 123)                (123,)
     Py_BuildValue("(ii)", 123, 456)          (123, 456)
     Py_BuildValue("(i,i)", 123, 456)         (123, 456)
     Py_BuildValue("[i,i]", 123, 456)         [123, 456]
     Py_BuildValue("{s:i,s:i}",
                   "abc", 123, "def", 456)    {'abc': 123, 'def': 456}
     Py_BuildValue("((ii)(ii)) (ii)",
                   1, 2, 3, 4, 5, 6)          (((1, 2), (3, 4)), (5, 6))


File: python.info,  Node: 参照カウント法,  Next: C++での拡張モジュール作成,  Prev: 任意の値を構築する,  Up: C や C++ による Python の拡張

6.2.1.10 参照カウント法
.......................

C や C++のような言語では、プログラマはヒープ上のメモリを動的に確保したり
解放したりする責任があります。こうした作業は C では関数 ‘malloc()’ や
‘free()’ で行います。C++では本質的に同じ意味で演算子 ‘new’ や ‘delete’ が
使われます。そこで、以下の議論は C の場合に限定して行います。

Every block of memory allocated with ‘malloc()’ should eventually be
returned to the pool of available memory by exactly one call to
‘free()’.  It is important to call ‘free()’ at the right time.  If a
block's address is forgotten but ‘free()’ is not called for it, the
memory it occupies cannot be reused until the program terminates.  This
is called a 'memory leak'.  On the other hand, if a program calls
‘free()’ for a block and then continues to use the block, it creates a
conflict with reuse of the block through another ‘malloc()’ call.  This
is called 'using freed memory'.  It has the same bad consequences as
referencing uninitialized data -- core dumps, wrong results, mysterious
crashes.

よくあるメモリリークの原因はコード中の普通でない処理経路です。例えば、あ
る関数があるメモリブロックを確保し、何らかの計算を行って、再度ブロックを
解放するとします。さて、関数の要求仕様を変更して、計算に対するテストを追
加すると、エラー条件を検出し、関数の途中で処理を戻すようになるかもしれま
せん。この途中での終了が起きるとき、確保されたメモリブロックは解放し忘れ
やすいのです。コードが後で追加された場合には特にそうです。このようなメモ
リリークが一旦紛れ込んでしまうと、長い間検出されないままになることがよく
あります: エラーによる関数の終了は、全ての関数呼び出しのに対してほんのわ
ずかな割合しか起きず、その一方でほとんどの近代的な計算機は相当量の仮想記
憶を持っているため、メモリリークが明らかになるのは、長い間動作していたプ
ロセスがリークを起こす関数を何度も使った場合に限られるからです。従って、
この種のエラーを最小限にとどめるようなコーディング規約や戦略を設けて、不
慮のメモリリークを避けることが重要なのです。

Python は ‘malloc()’ や ‘free()’ を非常によく利用するため、メモリリーク
の防止に加え、解放されたメモリの使用を防止する戦略が必要です。このために
選ばれたのが参照カウント法 ('reference counting') と呼ばれる手法です。参
照カウント法の原理は簡単です: 全てのオブジェクトにはカウンタがあり、オブ
ジェクトに対する参照がどこかに保存されたらカウンタをインクリメントし、オ
ブジェクトに対する参照が削除されたらデクリメントします。カウンタがゼロに
なったら、オブジェクトへの最後の参照が削除されたことになり、オブジェクト
は解放されます。

もう一つの戦略は自動ガベージコレクション ('automatic garbage
collection') と呼ばれています。 (参照カウント法はガベージコレクション戦
略の一つとして挙げられることもあるので、二つを区別するために筆者は "自動
(automatic)" を使っています。) 自動ガベージコレクションの大きな利点は、
ユーザが ‘free()’ を明示的によばなくてよいことにあります。 (速度やメモリ
の有効利用性も利点として主張されています -- が、これは確たる事実ではあり
ません。) C における自動ガベージコレクションの欠点は、真に可搬性のあるガ
ベージコレクタが存在しないということです。それに対し、参照カウント法は可
搬性のある実装ができます (‘malloc()’ や ‘free()’ を利用できるのが前提で
す -- C 標準はこれを保証しています)。いつの日か、十分可搬性のあるガベー
ジコレクタが C で使えるようになるかもしれませんが、それまでは参照カウン
ト法でやっていく以外にはないのです。

Python では、伝統的な参照カウント法の実装を行っている一方で、参照の循環
を検出するために働く循環参照検出機構 (cycle detector) も提供しています。
循環参照検出機構のおかげで、直接、間接にかかわらず循環参照の生成を気にせ
ずにアプリケーションを構築できます; というのも、参照カウント法だけを使っ
たガベージコレクション実装にとって循環参照は弱点だからです。循環参照は、
(間接参照の場合も含めて) 相互への参照が入ったオブジェクトから形成される
ため、循環内のオブジェクトは各々非ゼロの参照カウントを持ちます。典型的な
参照カウント法の実装では、たとえ循環参照を形成するオブジェクトに対して他
に全く参照がないとしても、循環参照内のどのオブジェクトに属するメモリも再
利用できません。

循環参照検出機構はそのようなガベージサイクル (前述したような循環参照オブ
ジェクト) を検出して回収することができます。 *note gc: 56. モジュールそ
のような検出機構の実行 (*note collect(): a08. 関数) を提供するとともに、
設定のためのインタフェースおよび検出機構を実行時に無効にする方法も提供し
ています。

* Menu:

* Python における参照カウント法::
* 所有権にまつわる規則::
* 薄氷::
* NULL ポインタ::


File: python.info,  Node: Python における参照カウント法,  Next: 所有権にまつわる規則,  Up: 参照カウント法

6.2.1.11 Python における参照カウント法
......................................

Python には、参照カウントのインクリメントやデクリメントを処理する二つの
マクロ、 ‘Py_INCREF(x)’ と ‘Py_DECREF(x)’ があります。 *note
Py_DECREF(): 53b. は、参照カウントがゼロに到達した際に、オブジェクトのメ
モリ解放も行います。柔軟性を持たせるために、 ‘free()’ を直接呼び出しませ
ん -- その代わりにオブジェクトの型オブジェクト ('type object') を介しま
す。このために (他の目的もありますが)、全てのオブジェクトには自身の型オ
ブジェクトに対するポインタが入っています。

さて、まだ重大な疑問が残っています: いつ ‘Py_INCREF(x)’ や
‘Py_DECREF(x)’ を使えばよいのでしょうか?  まず、いくつかの用語説明から始
めさせてください。まず、オブジェクトは "占有 (own)" されることはありませ
ん; しかし、あるオブジェクトに対する参照の所有 'own a reference' はでき
ます。オブジェクトの参照カウントは、そのオブジェクトが参照の所有を受けて
いる回数と定義されています。参照の所有者は、参照が必要なくなった際に
*note Py_DECREF(): 53b. を呼び出す役割を担います。参照の所有権は委譲
(transfer) できます。所有参照 (owned reference) の放棄には、渡す、保存す
る、 *note Py_DECREF(): 53b. を呼び出す、という三つの方法があります。所
有参照を処理し忘れると、メモリリークを引き起こします。

オブジェクトに対する参照は、借用 ('borrow') も可能です。 (1) 参照の借用
者は、 *note Py_DECREF(): 53b. を呼んではなりません。借用者は、参照の所
有者から借用した期間を超えて参照を保持し続けてはなりません。所有者が参照
を放棄した後で借用参照を使うと、解放済みメモリを使用してしまう危険がある
ので、絶対に避けねばなりません。 (2)

参照の借用が参照の所有よりも優れている点は、コードがとりうるあらゆる処理
経路で参照を廃棄しておくよう注意しなくて済むことです -- 別の言い方をすれ
ば、借用参照の場合には、処理の途中で関数を終了してもメモリリークの危険を
冒すことがない、ということです。逆に、所有よりも不利な点は、ごくまともに
見えるコードが、実際には参照の借用元で放棄されてしまった後にその参照を使
うかもしれないような微妙な状況があるということです。

*note Py_INCREF(): 53a. を呼び出すと、借用参照を所有参照に変更できます。
この操作は参照の借用元の状態には影響しません -- *note Py_INCREF(): 53a.
は新たな所有参照を生成し、参照の所有者が担うべき全ての責任を課します (つ
まり、新たな参照の所有者は、以前の所有者と同様、参照の放棄を適切に行わね
ばなりません)。

   ---------- Footnotes ----------

   (1) 参照を "借用する" というメタファは厳密には正しくありません: なぜ
なら、参照の所有者は依然として参照のコピーを持っているからです。

   (2) 参照カウントが 1 以上かどうか調べる方法は 'うまくいきません' -- 参
照カウント自体も解放されたメモリ上にあるため、その領域が他のオブジェクト
に使われている可能性があります!


File: python.info,  Node: 所有権にまつわる規則,  Next: 薄氷,  Prev: Python における参照カウント法,  Up: 参照カウント法

6.2.1.12 所有権にまつわる規則
.............................

オブジェクトへの参照を関数の内外に渡す場合には、オブジェクトの所有権が参
照と共に渡されるか否かが常に関数インターフェース仕様の一部となります。

オブジェクトへの参照を返すほとんどの関数は、参照とともに所有権も渡します
。特に、 *note PyLong_FromLong(): 17a4. や *note Py_BuildValue(): 875. の
ように、新しいオブジェクトを生成する関数は全て所有権を相手に渡します。オ
ブジェクトが実際には新たなオブジェクトでなくても、そのオブジェクトに対す
る新たな参照の所有権を得ます。例えば、 *note PyLong_FromLong(): 17a4. は
よく使う値をキャッシュしており、キャッシュされた値への参照を返すことがあ
ります。

*note PyObject_GetAttrString(): 325. のように、あるオブジェクトから別の
オブジェクトを抽出するような関数もまた、参照とともに所有権を委譲します。
こちらの方はやや理解しにくいかもしれません。というのはよく使われるルーチ
ンのいくつかが例外となっているからです: *note PyTuple_GetItem(): 4763. 、
*note PyList_GetItem(): 335. 、 *note PyDict_GetItem(): 360. 、および
*note PyDict_GetItemString(): 361. は全て、タプル、リスト、または辞書か
ら借用参照を返します。

*note PyImport_AddModule(): 332. は、実際にはオブジェクトを生成して返す
ことがあるにもかかわらず、借用参照を返します: これが可能なのは、生成され
たオブジェクトに対する所有参照は ‘sys.modules’ に保持されるからです。

オブジェクトへの参照を別の関数に渡す場合、一般的には、関数側は呼び出し手
から参照を借用します -- 参照を保存する必要があるなら、関数側は *note
Py_INCREF(): 53a. を呼び出して独立した所有者になります。とはいえ、この規
則には二つの重要な例外: *note PyTuple_SetItem(): 4764. と *note
PyList_SetItem(): 4765. があります。これらの関数は、渡された引数要素に対
して所有権を乗っ取り (take over) ます -- たとえ失敗してもです!  (*note
PyDict_SetItem(): 4766. とその仲間は所有権を乗っ取りません -- これらはい
わば "普通の" 関数です。)

Python から C 関数が呼び出される際には、C 関数は呼び出し側から引数への参
照を借用します。C 関数の呼び出し側はオブジェクトへの参照を所有しているの
で、借用参照の生存期間が保証されるのは関数が処理を返すまでです。このよう
にして借用参照を保存したり他に渡したりしたい場合にのみ、 *note
Py_INCREF(): 53a. を使って所有参照にする必要があります。

Python から呼び出された C 関数が返す参照は所有参照でなければなりません
-- 所有権は関数から呼び出し側へと委譲されます。


File: python.info,  Node: 薄氷,  Next: NULL ポインタ,  Prev: 所有権にまつわる規則,  Up: 参照カウント法

6.2.1.13 薄氷
.............

数少ない状況において、一見無害に見える借用参照の利用が問題をひきおこすこ
とがあります。この問題はすべて、インタプリタが非明示的に呼び出され、イン
タプリタが参照の所有者に参照を放棄させてしまう状況と関係しています。

知っておくべきケースのうち最初の、そして最も重要なものは、リスト要素に対
する参照を借りている際に起きる、関係ないオブジェクトに対する *note
Py_DECREF(): 53b. の使用です。例えば:

     void
     bug(PyObject *list)
     {
         PyObject *item = PyList_GetItem(list, 0);

         PyList_SetItem(list, 1, PyLong_FromLong(0L));
         PyObject_Print(item, stdout, 0); /* BUG! */
     }

上の関数はまず、 ‘list[0]’ への参照を借用し、次に ‘list[1]’ を値 ‘0’ で
置き換え、最後にさきほど借用した参照を出力しています。何も問題ないように
見えますね?  でもそうではないのです!

Let's follow the control flow into *note PyList_SetItem(): 4765.  The
list owns references to all its items, so when item 1 is replaced, it
has to dispose of the original item 1.  Now let's suppose the original
item 1 was an instance of a user-defined class, and let's further
suppose that the class defined a ‘__del__()’ method.  If this class
instance has a reference count of 1, disposing of it will call its
‘__del__()’ method.

Since it is written in Python, the ‘__del__()’ method can execute
arbitrary Python code.  Could it perhaps do something to invalidate the
reference to ‘item’ in ‘bug()’?  You bet!  Assuming that the list passed
into ‘bug()’ is accessible to the ‘__del__()’ method, it could execute a
statement to the effect of ‘del list[0]’, and assuming this was the last
reference to that object, it would free the memory associated with it,
thereby invalidating ‘item’.

問題の原因が分かれば、解決は簡単です。一時的に参照回数を増やせばよいので
す。正しく動作するバージョンは以下のようになります:

     void
     no_bug(PyObject *list)
     {
         PyObject *item = PyList_GetItem(list, 0);

         Py_INCREF(item);
         PyList_SetItem(list, 1, PyLong_FromLong(0L));
         PyObject_Print(item, stdout, 0);
         Py_DECREF(item);
     }

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 ‘__del__()’ methods would fail...

二つ目は、借用参照がスレッドに関係しているケースです。通常は、 Python イ
ンタプリタにおける複数のスレッドは、グローバルインタプリタロックがオブジ
ェクト空間全体を保護しているため、互いに邪魔し合うことはありません。とは
いえ、ロックは *note Py_BEGIN_ALLOW_THREADS: 4769. マクロで一時的に解除
したり、 *note Py_END_ALLOW_THREADS: a5c. で再獲得したりできます。これら
のマクロはブロックの起こる I/O 呼び出しの周囲によく置かれ、 I/O が完了す
るまでの間に他のスレッドがプロセッサを利用できるようにします。明らかに、
以下の関数は上の例と似た問題をはらんでいます:

     void
     bug(PyObject *list)
     {
         PyObject *item = PyList_GetItem(list, 0);
         Py_BEGIN_ALLOW_THREADS
         ...some blocking I/O call...
         Py_END_ALLOW_THREADS
         PyObject_Print(item, stdout, 0); /* BUG! */
     }


File: python.info,  Node: NULL ポインタ,  Prev: 薄氷,  Up: 参照カウント法

6.2.1.14 NULL ポインタ
......................

一般論として、オブジェクトへの参照を引数にとる関数はユーザが ‘NULL’ ポイ
ンタを渡すとは予想しておらず、渡そうとするとコアダンプになる (か、あとで
コアダンプを引き起こす) ことでしょう。一方、オブジェクトへの参照を返すよ
うな関数は一般に、例外の発生を示す場合にのみ ‘NULL’ を返します。引数に対
して ‘NULL’ テストを行わない理由は、関数はしばしば受け取ったオブジェクト
を他の関数へと引き渡すからです -- 各々の関数が ‘NULL’ テストを行えば、冗
長なテストが大量に行われ、コードはより低速に動くことになります。

従って、 ‘NULL’ のテストはオブジェクトの "発生源"、すなわち値が ‘NULL’ に
なるかもしれないポインタを受け取ったときだけにしましょう。 ‘malloc()’ や
、例外を送出する可能性のある関数がその例です。

マクロ *note Py_INCREF(): 53a. および *note Py_DECREF(): 53b. は ‘NULL’
ポインタのチェックを行いません -- しかし、これらのマクロの変化形である
*note Py_XINCREF(): a33. および *note Py_XDECREF(): 75a. はチェックを行
います。

特定のオブジェクト型について調べるマクロ (‘Pytype_Check()’) は 'NULL' ポ
インタのチェックを行いません -- 繰り返しますが、様々な異なる型を想定して
オブジェクトの型を調べる際には、こうしたマクロを続けて呼び出す必要がある
ので、個別に ‘NULL’ ポインタのチェックをすると冗長なテストになってしまう
のです。型を調べるマクロには、 ‘NULL’ チェックを行う変化形はありません。

Python から C 関数を呼び出す機構は、C 関数に渡される引数リスト (例でいう
ところの ‘args’) が決して ‘NULL’ にならないよう保証しています -- 実際に
は、常にタプル型になるよう保証しています。(1)

‘NULL’ ポインタを Python ユーザレベルに "逃がし" てしまうと、深刻なエラ
ーを引き起こします。

   ---------- Footnotes ----------

   (1) "旧式の" 呼び出し規約を使っている場合には、この保証は適用されませ
ん -- 既存のコードにはいまだに旧式の呼び出し規約が多々あります。


File: python.info,  Node: C++での拡張モジュール作成,  Next: 拡張モジュールに C API を提供する,  Prev: 参照カウント法,  Up: C や C++ による Python の拡張

6.2.1.15 C++での拡張モジュール作成
..................................

C++でも拡張モジュールは作成できます。ただしいくつか制限があります。メイ
ンプログラム (Python インタプリタ) は C コンパイラでコンパイルされリンク
されているので、グローバル変数や静的オブジェクトをコンストラクタで作成で
きません。メインプログラムが C++ コンパイラでリンクされているならこれは
問題ではありません。 Python インタプリタから呼び出される関数 (特にモジュ
ール初期化関数) は、 ‘extern "C"’ を使って宣言しなければなりません。また
、Python ヘッダファイルを ‘extern "C" {...}’ に入れる必要はありません--
シンボル ‘__cplusplus’ (最近の C++ コンパイラは全てこのシンボルを定義し
ています) が定義されているときに ‘extern "C" {...}’ が行われるように、ヘ
ッダファイル内にすでに書かれているからです。


File: python.info,  Node: 拡張モジュールに C API を提供する,  Prev: C++での拡張モジュール作成,  Up: C や C++ による Python の拡張

6.2.1.16 拡張モジュールに C API を提供する
..........................................

多くの拡張モジュールは単に Python から使える新たな関数や型を提供するだけ
ですが、時に拡張モジュール内のコードが他の拡張モジュールでも便利なことが
あります。例えば、あるモジュールでは順序概念のないリストのように動作する
"コレクション (collection)" クラスを実装しているかもしれません。ちょうど
リストを生成したり操作したりできる C API を備えた標準の Python リスト型
のように、この新たなコレクション型も他の拡張モジュールから直接操作できる
ようにするには一連の C 関数を持っていなければなりません。

一見するとこれは簡単なこと: 単に関数を (もちろん ‘static’ などとは宣言せ
ずに) 書いて、適切なヘッダファイルを提供し、C API を書けばよいだけ、に思
えます。そして実際のところ、全ての拡張モジュールが Python インタプリタに
常に静的にリンクされている場合にはうまく動作します。ところがモジュールが
共有ライブラリの場合には、一つのモジュールで定義されているシンボルが他の
モジュールから不可視なことがあります。可視性の詳細はオペレーティングシス
テムによります; あるシステムは Python インタプリタと全ての拡張モジュール
用に単一のグローバルな名前空間を用意しています (例えば Windows)。別のシ
ステムはモジュールのリンク時に取り込まれるシンボルを明示的に指定する必要
があります (AIX がその一例です)、また別のシステム (ほとんどの Unix) では
、違った戦略を選択肢として提供しています。そして、たとえシンボルがグロー
バル変数として可視であっても、呼び出したい関数の入ったモジュールがまだロ
ードされていないことだってあります!

従って、可搬性の点からシンボルの可視性には何ら仮定をしてはならないことに
なります。つまり拡張モジュール中の全てのシンボルは ‘static’ と宣言せねば
なりません。例外はモジュールの初期化関数で、これは (*note
モジュールのメソッドテーブルと初期化関数: 474d. で述べたように) 他の拡張
モジュールとの間で名前が衝突するのを避けるためです。また、他の拡張モジュ
ールからアクセスを '受けるべきではない' シンボルは別のやり方で公開せねば
なりません。

Python はある拡張モジュールの C レベルの情報 (ポインタ) を別のモジュール
に渡すための特殊な機構: Capsule (カプセル)を提供しています。 Capsule は
ポインタ (void*) を記憶する Python のデータ型です。 Capsule は C API を
介してのみ生成したりアクセスしたりできますが、他の Python オブジェクトと
同じように受け渡しできます。とりわけ、Capsule は拡張モジュールの名前空間
内にある名前に代入できます。他の拡張モジュールはこのモジュールを import
でき、次に名前を取得し、最後にCapsule へのポインタを取得します。

拡張モジュールの C API を公開するために、様々な方法で Capsule が使われま
す。各関数を1つのオブジェクトに入れたり、全ての C API のポインタ配列を
Capsule に入れることができます。そして、ポインタに対する保存や取得といっ
た様々な作業は、コードを提供しているモジュールとクライアントモジュールと
の間では異なる方法で分散できます。

どの方法を選ぶにしても、 Capsule の name を正しく設定することは重要です
。 *note PyCapsule_New(): 476f. は name 引数 (const char*) を取ります。
‘NULL’ を name に渡すことも許可されていますが、 name を設定することを強
く推奨します。正しく名前を付けられた Capsule はある程度の実行時型安全性
を持ちます。名前を付けられていない Capsule を他の Capsule と区別する現実
的な方法はありません。

特に、 C API を公開するための Capsule には次のルールに従った名前を付ける
べきです:

     modulename.attributename

*note PyCapsule_Import(): 17d8. という便利関数は、 Capsule の名前がこの
ルールに一致しているときにのみ、簡単に Capsule 経由で公開されている C
API をロードすることができます。この挙動により、 C API のユーザーが、確
実に正しい C API を格納している Capsule をロードできたことを確かめること
ができます。

以下の例では、名前を公開するモジュールの作者にほとんどの負荷が掛かります
が、よく使われるライブラリを作る際に適切なアプローチを実演します。このア
プローチでは、全ての C API ポインタ (例中では一つだけですが!)  を、
Capsule の値となる void ポインタの配列に保存します。拡張モジュールに対応
するヘッダファイルは、モジュールの import と C API ポインタを取得するよ
う手配するマクロを提供します; クライアントモジュールは、C API にアクセス
する前にこのマクロを呼ぶだけです。

The exporting module is a modification of the ‘spam’ module from section
*note 簡単な例: 4745.  The function ‘spam.system()’ does not call the C
library function ‘system()’ directly, but a function ‘PySpam_System()’,
which would of course do something more complicated in reality (such as
adding "spam" to every command).  This function ‘PySpam_System()’ is
also exported to other extension modules.

The function ‘PySpam_System()’ is a plain C function, declared ‘static’
like everything else:

     static int
     PySpam_System(const char *command)
     {
         return system(command);
     }

The function ‘spam_system()’ is modified in a trivial way:

     static PyObject *
     spam_system(PyObject *self, PyObject *args)
     {
         const char *command;
         int sts;

         if (!PyArg_ParseTuple(args, "s", &command))
             return NULL;
         sts = PySpam_System(command);
         return PyLong_FromLong(sts);
     }

モジュールの先頭にある以下の行

     #include <Python.h>

の直後に、以下の二行を必ず追加してください:

     #define SPAM_MODULE
     #include "spammodule.h"

‘#define’ は、ファイル ‘spammodule.h’ をインクルードしているのが名前を公
開する側のモジュールであって、クライアントモジュールではないことをヘッダ
ファイルに教えるために使われます。最後に、モジュールの初期化関数は C API
のポインタ配列を初期化するよう手配しなければなりません:

     PyMODINIT_FUNC
     PyInit_spam(void)
     {
         PyObject *m;
         static void *PySpam_API[PySpam_API_pointers];
         PyObject *c_api_object;

         m = PyModule_Create(&spammodule);
         if (m == NULL)
             return NULL;

         /* Initialize the C API pointer array */
         PySpam_API[PySpam_System_NUM] = (void *)PySpam_System;

         /* Create a Capsule containing the API pointer array's address */
         c_api_object = PyCapsule_New((void *)PySpam_API, "spam._C_API", NULL);

         if (PyModule_Add(m, "_C_API", c_api_object) < 0) {
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

Note that ‘PySpam_API’ is declared ‘static’; otherwise the pointer array
would disappear when ‘PyInit_spam()’ terminates!

からくりの大部分はヘッダファイル ‘spammodule.h’ 内にあり、以下のようにな
っています:

     #ifndef Py_SPAMMODULE_H
     #define Py_SPAMMODULE_H
     #ifdef __cplusplus
     extern "C" {
     #endif

     /* Header file for spammodule */

     /* C API functions */
     #define PySpam_System_NUM 0
     #define PySpam_System_RETURN int
     #define PySpam_System_PROTO (const char *command)

     /* Total number of C API pointers */
     #define PySpam_API_pointers 1


     #ifdef SPAM_MODULE
     /* This section is used when compiling spammodule.c */

     static PySpam_System_RETURN PySpam_System PySpam_System_PROTO;

     #else
     /* This section is used in modules that use spammodule's API */

     static void **PySpam_API;

     #define PySpam_System \
      (*(PySpam_System_RETURN (*)PySpam_System_PROTO) PySpam_API[PySpam_System_NUM])

     /* Return -1 on error, 0 on success.
      * PyCapsule_Import will set an exception if there's an error.
      */
     static int
     import_spam(void)
     {
         PySpam_API = (void **)PyCapsule_Import("spam._C_API", 0);
         return (PySpam_API != NULL) ? 0 : -1;
     }

     #endif

     #ifdef __cplusplus
     }
     #endif

     #endif /* !defined(Py_SPAMMODULE_H) */

All that a client module must do in order to have access to the function
‘PySpam_System()’ is to call the function (or rather macro)
‘import_spam()’ in its initialization function:

     PyMODINIT_FUNC
     PyInit_client(void)
     {
         PyObject *m;

         m = PyModule_Create(&clientmodule);
         if (m == NULL)
             return NULL;
         if (import_spam() < 0)
             return NULL;
         /* additional initialization can happen here */
         return m;
     }

このアプローチの主要な欠点は、 ‘spammodule.h’ がやや難解になるということ
です。とはいえ、各関数の基本的な構成は公開されるものと同じなので、書き方
を一度だけ学べばすみます。

最後に、Capsule は、自身に保存されているポインタをメモリ確保したり解放し
たりする際に特に便利な、もう一つの機能を提供しているということに触れてお
かねばなりません。詳細は Python/C API リファレンスマニュアルの *note
カプセル: 24d4, および Capsule の実装部分 (Python ソースコード配布物中の
ファイル ‘Include/pycapsule.h’ および ‘Objects/pycapsule.c’ に述べられて
います。

脚注
....


File: python.info,  Node: 拡張の型の定義 チュートリアル,  Next: 拡張の型の定義 雑多なトピック,  Prev: C や C++ による Python の拡張,  Up: サードパーティツールなしで拡張を作る

6.2.2 拡張の型の定義: チュートリアル
------------------------------------

Python では、組み込みの *note str: 418. 型や *note list: 5dc. 型のような
Python コードから操作できる新しい型を C 拡張モジュールの作者が定義できま
す。 全ての拡張の型のコードはあるパターンに従うのですが、書き始める前に
理解しておくべき細かいことがあります。 このドキュメントはその話題につい
てのやさしい入門です。

* Menu:

* 基本的なこと::
* 基本のサンプルにデータとメソッドを追加する::
* データ属性をこまかく制御する::
* 循環ガベージコレクションをサポートする::
* 他の型のサブクラスを作る::


File: python.info,  Node: 基本的なこと,  Next: 基本のサンプルにデータとメソッドを追加する,  Up: 拡張の型の定義 チュートリアル

6.2.2.1 基本的なこと
....................

*note CPython: 6c1. ランタイムは Python の全てのオブジェクトを、 Python
の全てのオブジェクトの "基底型 (base type)" である *note PyObject: 312.*
型の変数と見なします。 *note PyObject: 312. 構造体自身は *note
参照カウント: 4774. と、オブジェクトの "型オブジェクト" へのポインタのみ
を持ちます。ここには動作が定義されています; 型オブジェクトは、例えば、あ
る属性があるオブジェクトから検索されたり、メソッドが呼ばれたり、他のオブ
ジェクトによって操作されたりしたときに、どの (C) 関数がインタープリター
から呼ばれるのかを決定します。これらの C 関数は "型メソッド (type
method)" と呼ばれます。

それなので、新しい拡張の型を定義したいときは、新しい型オブジェクトを作成
すればよいわけです。

この手のことは例を見たほうが早いでしょうから、以下に C 拡張モジュール
‘custom’ にある ‘Custom’ という名前の新しい型を定義する、最小限ながら完
全なモジュールをあげておきます:

     注釈: ここで紹介している例は、 '静的な' 拡張の型を定義する伝統的な
     実装方法です。 これはほとんどの場面で十分なものなのです。 C API で
     は、 *note PyType_FromSpec(): 549. 関数を使い、ヒープ上に配置された
     拡張の型も定義できますが、これについてはこのチュートリアルでは扱い
     ません。

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

     typedef struct {
         PyObject_HEAD
         /* Type-specific fields go here. */
     } CustomObject;

     static PyTypeObject CustomType = {
         .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "custom.Custom",
         .tp_doc = PyDoc_STR("Custom objects"),
         .tp_basicsize = sizeof(CustomObject),
         .tp_itemsize = 0,
         .tp_flags = Py_TPFLAGS_DEFAULT,
         .tp_new = PyType_GenericNew,
     };

     static PyModuleDef custommodule = {
         .m_base = PyModuleDef_HEAD_INIT,
         .m_name = "custom",
         .m_doc = "Example module that creates an extension type.",
         .m_size = -1,
     };

     PyMODINIT_FUNC
     PyInit_custom(void)
     {
         PyObject *m;
         if (PyType_Ready(&CustomType) < 0)
             return NULL;

         m = PyModule_Create(&custommodule);
         if (m == NULL)
             return NULL;

         if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

一度に把握するにはちょっと量が多いですが、前の章よりはとっつきやすくなっ
ていることと思います。このファイルでは、3つの要素が定義されています:

  1. ‘Custom’ 'オブジェクト' が何を含んでいるか: これが ‘CustomObject’ 構
     造体で、 ‘Custom’ インスタンスごとに1回だけメモリ確保が行われます。

  2. ‘Custom’ '型' がどのように振る舞うか: これが ‘CustomType’ 構造体で
     、フラグと関数ポインタの集まりを定義しています。特定の操作が要求さ
     れたときに、この関数ポインタをインタープリターが見に行きます。

  3. ‘custom’ モジュールをどう初期化するか: これが ‘PyInit_custom’ 関数
     とそれに関係する ‘custommodule’ 構造体です。

まず最初はこれです:

     typedef struct {
         PyObject_HEAD
     } CustomObject;

これが Custom オブジェクトの内容です。 ‘PyObject_HEAD’ はそれぞれのオブ
ジェクト構造体の先頭に必須なもので、 *note PyObject: 312. 型の ‘ob_base’
という名前のフィールドを定義します。 *note PyObject: 312. 型には (それぞ
れ *note Py_TYPE: 74b. マクロおよび *note Py_REFCNT: 877. マクロからアク
セスできる) 型オブジェクトへのポインタと参照カウントが格納されています。
このマクロが用意されている理由は、構造体のレイアウトを抽象化し、デバッグ
ビルドでフィールドを追加できるようにするためです。

     注釈: 上の例では *note PyObject_HEAD: 12ac. マクロの後にセミコロン
     はありません。 うっかりセミコロンを追加しないように気を付けてくださ
     い: これを警告するコンパイラもあります。

もちろん、一般的にはオブジェクトは標準的な ‘PyObject_HEAD’ ボイラープレ
ートの他にもデータを保持しています; 例えば、これは Python 標準の浮動小数
点数の定義です:

     typedef struct {
         PyObject_HEAD
         double ob_fval;
     } PyFloatObject;

2つ目は型オブジェクトの定義です。

     static PyTypeObject CustomType = {
         .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "custom.Custom",
         .tp_doc = PyDoc_STR("Custom objects"),
         .tp_basicsize = sizeof(CustomObject),
         .tp_itemsize = 0,
         .tp_flags = Py_TPFLAGS_DEFAULT,
         .tp_new = PyType_GenericNew,
     };

     注釈: 上にあるように C99 スタイルの指示付き初期化子を使って、 *note
     PyTypeObject: a73. の特に関心の無いフィールドまで全て並べたり、フィ
     ールドを宣言する順序に気を使ったりせずに済ませるのをお薦めします。

‘object.h’ にある実際の *note PyTypeObject: a73. の定義には上の定義にあ
るよりももっと多くの *note フィールド: 95b. があります。 ここに出てきて
いないフィールドは C コンパイラによってゼロで埋められるので、必要でない
限り明示的には値の指定をしないのが一般的な作法になっています。

一度に1つずつフィールドを取り上げていきましょう:

     .ob_base = PyVarObject_HEAD_INIT(NULL, 0)

この行は、上で触れた ‘ob_base’ フィールドの初期化に必須のボイラープレー
トです。

     .tp_name = "custom.Custom",

実装している型の名前です。 これは、オブジェクトのデフォルトの文字列表現
やエラーメッセージに現れます。例えば次の通りです:

     >>> "" + custom.Custom()
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: can only concatenate str (not "custom.Custom") to str

型の名前が、モジュール名とモジュールにおける型の名前の両方をドットでつな
いだ名前になっていることに注意してください。この場合は、モジュールは
‘custom’ で型は ‘Custom’ なので、型の名前を ‘custom.Custom’ に設定しまし
た。実際のドット付きのインポートパスを使うのは、 *note pydoc: a3. モジュ
ールや *note pickle: 95. モジュールと互換性を持たせるために重要なのです
。

     .tp_basicsize = sizeof(CustomObject),
     .tp_itemsize = 0,

これは、新しい ‘Custom’ インスタンスを作るときに Python が割り当てるべき
メモリがどのくらいなのかを知るためのものです。 *note tp_itemsize: 1ed0.
は可変サイズのオブジェクトでのみ使うものなので、サイズが可変でないオブジ
ェクトでは 0 にすべきです。

     注釈: If you want your type to be subclassable from Python, and
     your type has the same *note tp_basicsize: 955. as its base type,
     you may have problems with multiple inheritance.  A Python subclass
     of your type will have to list your type first in its *note
     __bases__: 1451, or else it will not be able to call your type's
     *note __new__(): 54c. method without getting an error.  You can
     avoid this problem by ensuring that your type has a larger value
     for *note tp_basicsize: 955. than its base type does.  Most of the
     time, this will be true anyway, because either your base type will
     be *note object: a5a, or else you will be adding data members to
     your base type, and therefore increasing its size.

*note Py_TPFLAGS_DEFAULT: 4775. にクラスフラグを設定します。

     .tp_flags = Py_TPFLAGS_DEFAULT,

すべての型はフラグにこの定数を含めておく必要があります。これは最低でも
Python 3.3 までに定義されているすべてのメンバを許可します。それ以上のメ
ンバが必要なら、対応するフラグの OR をとる必要があります。

この型の docstring は *note tp_doc: 4776. に入れます。

     .tp_doc = PyDoc_STR("Custom objects"),

オブジェクトが生成できるように、 *note tp_new: 54b. ハンドラを提供する必
要があります。これは Python のメソッド *note __new__(): 54c. と同等のも
のですが、明示的に与える必要があります。今の場合では、 API 関数の *note
PyType_GenericNew(): 4777. として提供されるデフォルトの実装をそのまま使
えます。

     .tp_new = PyType_GenericNew,

ファイルの残りの部分はきっと馴染みやすいものだと思いますが、
‘PyInit_custom()’ の一部のコードはそうではないでしょう:

     if (PyType_Ready(&CustomType) < 0)
         return;

これは、 ‘NULL’ に初期化された *note ob_type: 4778. も含めて、いくつかの
メンバーを適切なデフォルト値で埋めて、 ‘Custom’ 型を初期化します。

     if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
         Py_DECREF(m);
         return NULL;
     }

これは型をモジュールの辞書に追加します。こうすることで ‘Custom’ クラスの
呼び出しで ‘Custom’ インスタンスが作成できるようになります:

     >>> import custom
     >>> mycustom = custom.Custom()

以上です!残りの作業はビルドだけです; ‘custom.c’ という名前のファイルにこ
こまでのコードを書き込み、

     [build-system]
     requires = ["setuptools"]
     build-backend = "setuptools.build_meta"

     [project]
     name = "custom"
     version = "1"

‘pyproject.toml’ というファイルにこれを書き込み、

     from setuptools import Extension, setup
     setup(ext_modules=[Extension("custom", ["custom.c"])])

そして ‘setup.py’ というファイルにこのように書き込み、そして、以下のよう
に

     $ python -m pip install .

シェルに入力します。これにより、サブディレクトリに ‘custom.so’ が生成さ
れ、インストールされます。これで、 Python を立ち上げて、 ‘import custom’
すると ‘Custom’ オブジェクトで遊べるようになっているはずです。

そんなにむずかしくありません、よね?

もちろん、現在の Custom 型は面白みに欠けています。何もデータを持っていな
いし、何もできません。継承してサブクラスを作ることさえできないのです。


File: python.info,  Node: 基本のサンプルにデータとメソッドを追加する,  Next: データ属性をこまかく制御する,  Prev: 基本的なこと,  Up: 拡張の型の定義 チュートリアル

6.2.2.2 基本のサンプルにデータとメソッドを追加する
..................................................

この基本のサンプルにデータとメソッドを追加してみましょう。ついでに、この
型を基底クラスとしても利用できるようにします。ここでは新しいモジュール
‘custom2’ をつくり、これらの機能を追加します:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>
     #include <stddef.h> /* for offsetof() */

     typedef struct {
         PyObject_HEAD
         PyObject *first; /* first name */
         PyObject *last;  /* last name */
         int number;
     } CustomObject;

     static void
     Custom_dealloc(CustomObject *self)
     {
         Py_XDECREF(self->first);
         Py_XDECREF(self->last);
         Py_TYPE(self)->tp_free((PyObject *) self);
     }

     static PyObject *
     Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     {
         CustomObject *self;
         self = (CustomObject *) type->tp_alloc(type, 0);
         if (self != NULL) {
             self->first = PyUnicode_FromString("");
             if (self->first == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->last = PyUnicode_FromString("");
             if (self->last == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->number = 0;
         }
         return (PyObject *) self;
     }

     static int
     Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
     {
         static char *kwlist[] = {"first", "last", "number", NULL};
         PyObject *first = NULL, *last = NULL;

         if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist,
                                          &first, &last,
                                          &self->number))
             return -1;

         if (first) {
             Py_XSETREF(self->first, Py_NewRef(first));
         }
         if (last) {
             Py_XSETREF(self->last, Py_NewRef(last));
         }
         return 0;
     }

     static PyMemberDef Custom_members[] = {
         {"first", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,
          "first name"},
         {"last", Py_T_OBJECT_EX, offsetof(CustomObject, last), 0,
          "last name"},
         {"number", Py_T_INT, offsetof(CustomObject, number), 0,
          "custom number"},
         {NULL}  /* Sentinel */
     };

     static PyObject *
     Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))
     {
         if (self->first == NULL) {
             PyErr_SetString(PyExc_AttributeError, "first");
             return NULL;
         }
         if (self->last == NULL) {
             PyErr_SetString(PyExc_AttributeError, "last");
             return NULL;
         }
         return PyUnicode_FromFormat("%S %S", self->first, self->last);
     }

     static PyMethodDef Custom_methods[] = {
         {"name", (PyCFunction) Custom_name, METH_NOARGS,
          "Return the name, combining the first and last name"
         },
         {NULL}  /* Sentinel */
     };

     static PyTypeObject CustomType = {
         .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "custom2.Custom",
         .tp_doc = PyDoc_STR("Custom objects"),
         .tp_basicsize = sizeof(CustomObject),
         .tp_itemsize = 0,
         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
         .tp_new = Custom_new,
         .tp_init = (initproc) Custom_init,
         .tp_dealloc = (destructor) Custom_dealloc,
         .tp_members = Custom_members,
         .tp_methods = Custom_methods,
     };

     static PyModuleDef custommodule = {
         .m_base =PyModuleDef_HEAD_INIT,
         .m_name = "custom2",
         .m_doc = "Example module that creates an extension type.",
         .m_size = -1,
     };

     PyMODINIT_FUNC
     PyInit_custom2(void)
     {
         PyObject *m;
         if (PyType_Ready(&CustomType) < 0)
             return NULL;

         m = PyModule_Create(&custommodule);
         if (m == NULL)
             return NULL;

         if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

モジュールのこのバージョンでは、いくつもの変更をおこないます。

‘Custom’ 型は そのC構造体に 3つのデータ属性 'first' 、 'last' 、および
'number' をもつようになりました。 'first' と 'last' 属性はファーストネー
ムとラストネームを格納した Python 文字列で、 'number' 属性は C言語での整
数の値です。

これにしたがうと、オブジェクトの構造体は次のようになります:

     typedef struct {
         PyObject_HEAD
         PyObject *first; /* first name */
         PyObject *last;  /* last name */
         int number;
     } CustomObject;

いまや管理すべきデータができたので、オブジェクトの割り当てと解放に際して
はより慎重になる必要があります。最低限、オブジェクトの解放メソッドが必要
です:

     static void
     Custom_dealloc(CustomObject *self)
     {
         Py_XDECREF(self->first);
         Py_XDECREF(self->last);
         Py_TYPE(self)->tp_free((PyObject *) self);
     }

この関数は *note tp_dealloc: 477a. メンバに代入されます。

     .tp_dealloc = (destructor) Custom_dealloc,

このメソッドは、まず二つのPython 属性の参照カウントをクリアします。
*note Py_XDECREF(): 75a. は引数が ‘NULL’ のケースを正しく扱えます (これ
は、‘tp_new’ が途中で失敗した場合に起こりえます) 。このメソッドは、つぎ
にオブジェクトの型 (‘Py_TYPE(self)’ で算出します) のメンバ *note
tp_free: 477b. を呼び出し、オブジェクトのメモリを開放します。オブジェク
トの型が ‘CustomType’ であるとは限らない点に注意してください。なぜなら、
オブジェクトはサブクラスのインスタンスかもしれないからです。

     注釈: 上の ‘destructor’ への明示的な型変換は必要です。なぜなら、
     ‘Custom_dealloc’ が ‘CustomObject *’ 引数をとると定義しましたが、
     ‘tp_dealloc’ 関数のポインタは ‘PyObject *’ 引数を受け取ることになっ
     ているからです。もし明示的に型変換をしなければ、コンパイラが警告を
     発するでしょう。これは、 C におけるオブジェクト指向のポリモーフィズ
     ムです！

ファーストネームとラストネームを空文字列に初期化しておきたいので、
‘tp_new’ の実装を追加することにしましょう:

     static PyObject *
     Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     {
         CustomObject *self;
         self = (CustomObject *) type->tp_alloc(type, 0);
         if (self != NULL) {
             self->first = PyUnicode_FromString("");
             if (self->first == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->last = PyUnicode_FromString("");
             if (self->last == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->number = 0;
         }
         return (PyObject *) self;
     }

そしてこれを *note tp_new: 54b. メンバとしてインストールします:

     .tp_new = Custom_new,

The ‘tp_new’ handler is responsible for creating (as opposed to
initializing) objects of the type.  It is exposed in Python as the *note
__new__(): 54c. method.  It is not required to define a ‘tp_new’ member,
and indeed many extension types will simply reuse *note
PyType_GenericNew(): 4777. as done in the first version of the ‘Custom’
type above.  In this case, we use the ‘tp_new’ handler to initialize the
‘first’ and ‘last’ attributes to non-‘NULL’ default values.

‘tp_new’ is passed the type being instantiated (not necessarily
‘CustomType’, if a subclass is instantiated) and any arguments passed
when the type was called, and is expected to return the instance
created.  ‘tp_new’ handlers always accept positional and keyword
arguments, but they often ignore the arguments, leaving the argument
handling to initializer (a.k.a.  ‘tp_init’ in C or ‘__init__’ in Python)
methods.

     注釈: ‘tp_new’ は明示的に ‘tp_init’ を呼び出してはいけません、これ
     はインタープリタが自分で行うためです。

この ‘tp_new’ の実装は、*note tp_alloc: 477c. スロットを呼び出してメモリ
を割り当てます:

     self = (CustomObject *) type->tp_alloc(type, 0);

メモリ割り当ては失敗するかもしれないので、先に進む前に *note tp_alloc:
477c. の結果が ‘NULL’ でないかチェックしなければなりません。

     注釈: We didn't fill the *note tp_alloc: 477c. slot ourselves.
     Rather *note PyType_Ready(): 747. fills it for us by inheriting it
     from our base class, which is *note object: a5a. by default.  Most
     types use the default allocation strategy.

     注釈: もし協力的な *note tp_new: 54b. (基底タイプの *note tp_new:
     54b. または *note __new__(): 54c. を呼んでいるもの) を作りたいのな
     らば、実行時のメソッド解決順序をつかってどのメソッドを呼びだすかを
     決定しようとしては 'いけません' 。常に呼び出す型を静的に決めておき
     、直接その *note tp_new: 54b. を呼び出すか、あるいは
     ‘type->tp_base->tp_new’ を経由してください。こうしないと、あなたが
     作成したタイプの Python サブクラスが他の Python で定義されたクラス
     も継承している場合にうまく動かない場合があります。 (とりわけ、その
     ようなサブクラスのインスタンスを *note TypeError: 502. を出さずに作
     ることが不可能になります。)

We also define an initialization function which accepts arguments to
provide initial values for our instance:

     static int
     Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
     {
         static char *kwlist[] = {"first", "last", "number", NULL};
         PyObject *first = NULL, *last = NULL, *tmp;

         if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist,
                                          &first, &last,
                                          &self->number))
             return -1;

         if (first) {
             tmp = self->first;
             Py_INCREF(first);
             self->first = first;
             Py_XDECREF(tmp);
         }
         if (last) {
             tmp = self->last;
             Py_INCREF(last);
             self->last = last;
             Py_XDECREF(tmp);
         }
         return 0;
     }

これは *note tp_init: 54d. メンバに代入されます。

     .tp_init = (initproc) Custom_init,

The *note tp_init: 54d. slot is exposed in Python as the *note
__init__(): 67c. 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.

Unlike the ‘tp_new’ handler, there is no guarantee that ‘tp_init’ is
called at all (for example, the *note pickle: 95. module by default
doesn't call *note __init__(): 67c. on unpickled instances).  It can
also be called multiple times.  Anyone can call the ‘__init__()’ method
on our objects.  For this reason, we have to be extra careful when
assigning the new attribute values.  We might be tempted, for example to
assign the ‘first’ member like this:

     if (first) {
         Py_XDECREF(self->first);
         Py_INCREF(first);
         self->first = first;
     }

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
destructor that causes code to be executed that tries to access the
‘first’ member; or that destructor could release the *note Global
interpreter Lock: 13f. and let arbitrary code run in other threads that
accesses and modifies our object.

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?

   * その参照カウントが 1 より大きいと確信できる場合

   * when we know that deallocation of the object (1) will neither
     release the *note GIL: 13f. nor cause any calls back into our
     type's code;

   * when decrementing a reference count in a *note tp_dealloc: 477a.
     handler on a type which doesn't support cyclic garbage collection
     (2).

ここではインスタンス変数を属性として見えるようにしたいのですが、これには
いくつもの方法があります。もっとも簡単な方法は、メンバの定義を与えること
です:

     static PyMemberDef Custom_members[] = {
         {"first", Py_T_OBJECT_EX, offsetof(CustomObject, first), 0,
          "first name"},
         {"last", Py_T_OBJECT_EX, offsetof(CustomObject, last), 0,
          "last name"},
         {"number", Py_T_INT, offsetof(CustomObject, number), 0,
          "custom number"},
         {NULL}  /* Sentinel */
     };

そして、この定義を *note tp_members: 477d. スロットに入れましょう:

     .tp_members = Custom_members,

Each member definition has a member name, type, offset, access flags and
documentation string.  See the *note 総称的な属性を管理する: 477e.
section below for details.

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 expect the first and last names to be strings, but any
Python objects can be assigned.  Further, the attributes can be deleted,
setting the C pointers to ‘NULL’.  Even though we can make sure the
members are initialized to non-‘NULL’ values, the members can be set to
‘NULL’ if the attributes are deleted.

We define a single method, ‘Custom.name()’, that outputs the objects
name as the concatenation of the first and last names.

     static PyObject *
     Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))
     {
         if (self->first == NULL) {
             PyErr_SetString(PyExc_AttributeError, "first");
             return NULL;
         }
         if (self->last == NULL) {
             PyErr_SetString(PyExc_AttributeError, "last");
             return NULL;
         }
         return PyUnicode_FromFormat("%S %S", self->first, self->last);
     }

The method is implemented as a C function that takes a ‘Custom’ (or
‘Custom’ subclass) instance as the first argument.  Methods always take
an instance as the first argument.  Methods often take positional and
keyword arguments as well, but in this case we don't take any and don't
need to accept a positional argument tuple or keyword argument
dictionary.  This method is equivalent to the Python method:

     def name(self):
         return "%s %s" % (self.first, self.last)

Note that we have to check for the possibility that our ‘first’ and
‘last’ members are ‘NULL’.  This is because they can be deleted, in
which case they are set to ‘NULL’.  It would be better to prevent
deletion of these attributes and to restrict the attribute values to be
strings.  We'll see how to do that in the next section.

さて、メソッドを定義したので、ここでメソッド定義用の配列を作成する必要が
あります:

     static PyMethodDef Custom_methods[] = {
         {"name", (PyCFunction) Custom_name, METH_NOARGS,
          "Return the name, combining the first and last name"
         },
         {NULL}  /* Sentinel */
     };

(note that we used the *note METH_NOARGS: 147d. flag to indicate that
the method is expecting no arguments other than 'self')

and assign it to the *note tp_methods: 477f. slot:

     .tp_methods = Custom_methods,

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 *note Py_TPFLAGS_BASETYPE: 4780. to our
class flag definition:

     .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,

We rename ‘PyInit_custom()’ to ‘PyInit_custom2()’, update the module
name in the *note PyModuleDef: 94b. struct, and update the full class
name in the *note PyTypeObject: a73. struct.

Finally, we update our ‘setup.py’ file to include the new module,

     from setuptools import Extension, setup
     setup(ext_modules=[
         Extension("custom", ["custom.c"]),
         Extension("custom2", ["custom2.c"]),
     ])

and then we re-install so that we can ‘import custom2’:

     $ python -m pip install .

   ---------- Footnotes ----------

   (1) これはそのオブジェクトが文字列や実数などの基本タイプであるような
時に成り立ちます。

   (2) We relied on this in the *note tp_dealloc: 477a. handler in this
example, because our type doesn't support garbage collection.


File: python.info,  Node: データ属性をこまかく制御する,  Next: 循環ガベージコレクションをサポートする,  Prev: 基本のサンプルにデータとメソッドを追加する,  Up: 拡張の型の定義 チュートリアル

6.2.2.3 データ属性をこまかく制御する
....................................

In this section, we'll provide finer control over how the ‘first’ and
‘last’ attributes are set in the ‘Custom’ example.  In the previous
version of our module, the instance variables ‘first’ and ‘last’ could
be set to non-string values or even deleted.  We want to make sure that
these attributes always contain strings.

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>
     #include <stddef.h> /* for offsetof() */

     typedef struct {
         PyObject_HEAD
         PyObject *first; /* first name */
         PyObject *last;  /* last name */
         int number;
     } CustomObject;

     static void
     Custom_dealloc(CustomObject *self)
     {
         Py_XDECREF(self->first);
         Py_XDECREF(self->last);
         Py_TYPE(self)->tp_free((PyObject *) self);
     }

     static PyObject *
     Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     {
         CustomObject *self;
         self = (CustomObject *) type->tp_alloc(type, 0);
         if (self != NULL) {
             self->first = PyUnicode_FromString("");
             if (self->first == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->last = PyUnicode_FromString("");
             if (self->last == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->number = 0;
         }
         return (PyObject *) self;
     }

     static int
     Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
     {
         static char *kwlist[] = {"first", "last", "number", NULL};
         PyObject *first = NULL, *last = NULL;

         if (!PyArg_ParseTupleAndKeywords(args, kwds, "|UUi", kwlist,
                                          &first, &last,
                                          &self->number))
             return -1;

         if (first) {
             Py_SETREF(self->first, Py_NewRef(first));
         }
         if (last) {
             Py_SETREF(self->last, Py_NewRef(last));
         }
         return 0;
     }

     static PyMemberDef Custom_members[] = {
         {"number", Py_T_INT, offsetof(CustomObject, number), 0,
          "custom number"},
         {NULL}  /* Sentinel */
     };

     static PyObject *
     Custom_getfirst(CustomObject *self, void *closure)
     {
         return Py_NewRef(self->first);
     }

     static int
     Custom_setfirst(CustomObject *self, PyObject *value, void *closure)
     {
         if (value == NULL) {
             PyErr_SetString(PyExc_TypeError, "Cannot delete the first attribute");
             return -1;
         }
         if (!PyUnicode_Check(value)) {
             PyErr_SetString(PyExc_TypeError,
                             "The first attribute value must be a string");
             return -1;
         }
         Py_SETREF(self->first, Py_NewRef(value));
         return 0;
     }

     static PyObject *
     Custom_getlast(CustomObject *self, void *closure)
     {
         return Py_NewRef(self->last);
     }

     static int
     Custom_setlast(CustomObject *self, PyObject *value, void *closure)
     {
         if (value == NULL) {
             PyErr_SetString(PyExc_TypeError, "Cannot delete the last attribute");
             return -1;
         }
         if (!PyUnicode_Check(value)) {
             PyErr_SetString(PyExc_TypeError,
                             "The last attribute value must be a string");
             return -1;
         }
         Py_SETREF(self->last, Py_NewRef(value));
         return 0;
     }

     static PyGetSetDef Custom_getsetters[] = {
         {"first", (getter) Custom_getfirst, (setter) Custom_setfirst,
          "first name", NULL},
         {"last", (getter) Custom_getlast, (setter) Custom_setlast,
          "last name", NULL},
         {NULL}  /* Sentinel */
     };

     static PyObject *
     Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))
     {
         return PyUnicode_FromFormat("%S %S", self->first, self->last);
     }

     static PyMethodDef Custom_methods[] = {
         {"name", (PyCFunction) Custom_name, METH_NOARGS,
          "Return the name, combining the first and last name"
         },
         {NULL}  /* Sentinel */
     };

     static PyTypeObject CustomType = {
         .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "custom3.Custom",
         .tp_doc = PyDoc_STR("Custom objects"),
         .tp_basicsize = sizeof(CustomObject),
         .tp_itemsize = 0,
         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
         .tp_new = Custom_new,
         .tp_init = (initproc) Custom_init,
         .tp_dealloc = (destructor) Custom_dealloc,
         .tp_members = Custom_members,
         .tp_methods = Custom_methods,
         .tp_getset = Custom_getsetters,
     };

     static PyModuleDef custommodule = {
         .m_base = PyModuleDef_HEAD_INIT,
         .m_name = "custom3",
         .m_doc = "Example module that creates an extension type.",
         .m_size = -1,
     };

     PyMODINIT_FUNC
     PyInit_custom3(void)
     {
         PyObject *m;
         if (PyType_Ready(&CustomType) < 0)
             return NULL;

         m = PyModule_Create(&custommodule);
         if (m == NULL)
             return NULL;

         if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

To provide greater control, over the ‘first’ and ‘last’ attributes,
we'll use custom getter and setter functions.  Here are the functions
for getting and setting the ‘first’ attribute:

     static PyObject *
     Custom_getfirst(CustomObject *self, void *closure)
     {
         Py_INCREF(self->first);
         return self->first;
     }

     static int
     Custom_setfirst(CustomObject *self, PyObject *value, void *closure)
     {
         PyObject *tmp;
         if (value == NULL) {
             PyErr_SetString(PyExc_TypeError, "Cannot delete the first attribute");
             return -1;
         }
         if (!PyUnicode_Check(value)) {
             PyErr_SetString(PyExc_TypeError,
                             "The first attribute value must be a string");
             return -1;
         }
         tmp = self->first;
         Py_INCREF(value);
         self->first = value;
         Py_DECREF(tmp);
         return 0;
     }

The getter function is passed a ‘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.)

The setter function is passed the ‘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.

ここでは *note PyGetSetDef: b86. 構造体の配列をつくります:

     static PyGetSetDef Custom_getsetters[] = {
         {"first", (getter) Custom_getfirst, (setter) Custom_setfirst,
          "first name", NULL},
         {"last", (getter) Custom_getlast, (setter) Custom_setlast,
          "last name", NULL},
         {NULL}  /* Sentinel */
     };

そしてこれを *note tp_getset: 4782. スロットに登録します:

     .tp_getset = Custom_getsetters,

The last item in a *note PyGetSetDef: b86. structure is the "closure"
mentioned above.  In this case, we aren't using a closure, so we just
pass ‘NULL’.

また、メンバ定義からはこれらの属性を除いておきましょう:

     static PyMemberDef Custom_members[] = {
         {"number", Py_T_INT, offsetof(CustomObject, number), 0,
          "custom number"},
         {NULL}  /* Sentinel */
     };

また、ここでは *note tp_init: 54d. ハンドラも渡されるものとして文字列の
みを許可するように修正する必要があります (1):

     static int
     Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
     {
         static char *kwlist[] = {"first", "last", "number", NULL};
         PyObject *first = NULL, *last = NULL, *tmp;

         if (!PyArg_ParseTupleAndKeywords(args, kwds, "|UUi", kwlist,
                                          &first, &last,
                                          &self->number))
             return -1;

         if (first) {
             tmp = self->first;
             Py_INCREF(first);
             self->first = first;
             Py_DECREF(tmp);
         }
         if (last) {
             tmp = self->last;
             Py_INCREF(last);
             self->last = last;
             Py_DECREF(tmp);
         }
         return 0;
     }

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
cases.  This means that most of the *note Py_XDECREF(): 75a. calls can
be converted to *note Py_DECREF(): 53b. calls.  The only place we can't
change these calls is in the ‘tp_dealloc’ implementation, where there is
the possibility that the initialization of these members failed in
‘tp_new’.

さて、先ほどもしたように、このモジュール初期化関数と初期化関数内にあるモ
ジュール名を変更しましょう。そして ‘setup.py’ ファイルに追加の定義をくわ
えます。

   ---------- Footnotes ----------

   (1) 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 accept instances of string subclasses.  Even though
deallocating normal strings won't call back into our objects, we can't
guarantee that deallocating an instance of a string subclass won't call
back into our objects.


File: python.info,  Node: 循環ガベージコレクションをサポートする,  Next: 他の型のサブクラスを作る,  Prev: データ属性をこまかく制御する,  Up: 拡張の型の定義 チュートリアル

6.2.2.4 循環ガベージコレクションをサポートする
..............................................

Python は *note 循環ガベージコレクタ (GC) 機能: 1884. をもっており、これ
は不要なオブジェクトを、たとえ参照カウントがゼロでなくても発見することが
できます。そのような状況はオブジェクトの参照が循環しているときに起こりえ
ます。たとえば以下の例を考えてください:

     >>> l = []
     >>> l.append(l)
     >>> del l

この例では、自分自身をふくむリストを作りました。たとえこのリストを 削除
しても、それは自分自身への参照をまだ持ちつづけますから、参照カウントはゼ
ロにはなりません。嬉しいことに Python には循環ガベージコレクタは最終的に
はこのリストが不要であることを検出し、解放できます。

In the second version of the ‘Custom’ example, we allowed any kind of
object to be stored in the ‘first’ or ‘last’ attributes (1).  Besides,
in the second and third versions, we allowed subclassing ‘Custom’, and
subclasses may add arbitrary attributes.  For any of those two reasons,
‘Custom’ objects can participate in cycles:

     >>> import custom3
     >>> class Derived(custom3.Custom): pass
     ...
     >>> n = Derived()
     >>> n.some_attribute = n

To allow a ‘Custom’ instance participating in a reference cycle to be
properly detected and collected by the cyclic GC, our ‘Custom’ type
needs to fill two additional slots and to enable a flag that enables
these slots:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>
     #include <stddef.h> /* for offsetof() */

     typedef struct {
         PyObject_HEAD
         PyObject *first; /* first name */
         PyObject *last;  /* last name */
         int number;
     } CustomObject;

     static int
     Custom_traverse(CustomObject *self, visitproc visit, void *arg)
     {
         Py_VISIT(self->first);
         Py_VISIT(self->last);
         return 0;
     }

     static int
     Custom_clear(CustomObject *self)
     {
         Py_CLEAR(self->first);
         Py_CLEAR(self->last);
         return 0;
     }

     static void
     Custom_dealloc(CustomObject *self)
     {
         PyObject_GC_UnTrack(self);
         Custom_clear(self);
         Py_TYPE(self)->tp_free((PyObject *) self);
     }

     static PyObject *
     Custom_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
     {
         CustomObject *self;
         self = (CustomObject *) type->tp_alloc(type, 0);
         if (self != NULL) {
             self->first = PyUnicode_FromString("");
             if (self->first == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->last = PyUnicode_FromString("");
             if (self->last == NULL) {
                 Py_DECREF(self);
                 return NULL;
             }
             self->number = 0;
         }
         return (PyObject *) self;
     }

     static int
     Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
     {
         static char *kwlist[] = {"first", "last", "number", NULL};
         PyObject *first = NULL, *last = NULL;

         if (!PyArg_ParseTupleAndKeywords(args, kwds, "|UUi", kwlist,
                                          &first, &last,
                                          &self->number))
             return -1;

         if (first) {
             Py_SETREF(self->first, Py_NewRef(first));
         }
         if (last) {
             Py_SETREF(self->last, Py_NewRef(last));
         }
         return 0;
     }

     static PyMemberDef Custom_members[] = {
         {"number", Py_T_INT, offsetof(CustomObject, number), 0,
          "custom number"},
         {NULL}  /* Sentinel */
     };

     static PyObject *
     Custom_getfirst(CustomObject *self, void *closure)
     {
         return Py_NewRef(self->first);
     }

     static int
     Custom_setfirst(CustomObject *self, PyObject *value, void *closure)
     {
         if (value == NULL) {
             PyErr_SetString(PyExc_TypeError, "Cannot delete the first attribute");
             return -1;
         }
         if (!PyUnicode_Check(value)) {
             PyErr_SetString(PyExc_TypeError,
                             "The first attribute value must be a string");
             return -1;
         }
         Py_XSETREF(self->first, Py_NewRef(value));
         return 0;
     }

     static PyObject *
     Custom_getlast(CustomObject *self, void *closure)
     {
         return Py_NewRef(self->last);
     }

     static int
     Custom_setlast(CustomObject *self, PyObject *value, void *closure)
     {
         if (value == NULL) {
             PyErr_SetString(PyExc_TypeError, "Cannot delete the last attribute");
             return -1;
         }
         if (!PyUnicode_Check(value)) {
             PyErr_SetString(PyExc_TypeError,
                             "The last attribute value must be a string");
             return -1;
         }
         Py_XSETREF(self->last, Py_NewRef(value));
         return 0;
     }

     static PyGetSetDef Custom_getsetters[] = {
         {"first", (getter) Custom_getfirst, (setter) Custom_setfirst,
          "first name", NULL},
         {"last", (getter) Custom_getlast, (setter) Custom_setlast,
          "last name", NULL},
         {NULL}  /* Sentinel */
     };

     static PyObject *
     Custom_name(CustomObject *self, PyObject *Py_UNUSED(ignored))
     {
         return PyUnicode_FromFormat("%S %S", self->first, self->last);
     }

     static PyMethodDef Custom_methods[] = {
         {"name", (PyCFunction) Custom_name, METH_NOARGS,
          "Return the name, combining the first and last name"
         },
         {NULL}  /* Sentinel */
     };

     static PyTypeObject CustomType = {
         .ob_base = PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "custom4.Custom",
         .tp_doc = PyDoc_STR("Custom objects"),
         .tp_basicsize = sizeof(CustomObject),
         .tp_itemsize = 0,
         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
         .tp_new = Custom_new,
         .tp_init = (initproc) Custom_init,
         .tp_dealloc = (destructor) Custom_dealloc,
         .tp_traverse = (traverseproc) Custom_traverse,
         .tp_clear = (inquiry) Custom_clear,
         .tp_members = Custom_members,
         .tp_methods = Custom_methods,
         .tp_getset = Custom_getsetters,
     };

     static PyModuleDef custommodule = {
         .m_base = PyModuleDef_HEAD_INIT,
         .m_name = "custom4",
         .m_doc = "Example module that creates an extension type.",
         .m_size = -1,
     };

     PyMODINIT_FUNC
     PyInit_custom4(void)
     {
         PyObject *m;
         if (PyType_Ready(&CustomType) < 0)
             return NULL;

         m = PyModule_Create(&custommodule);
         if (m == NULL)
             return NULL;

         if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

First, the traversal method lets the cyclic GC know about subobjects
that could participate in cycles:

     static int
     Custom_traverse(CustomObject *self, visitproc visit, void *arg)
     {
         int vret;
         if (self->first) {
             vret = visit(self->first, arg);
             if (vret != 0)
                 return vret;
         }
         if (self->last) {
             vret = visit(self->last, arg);
             if (vret != 0)
                 return vret;
         }
         return 0;
     }

For each subobject that can participate in cycles, we need to call the
‘visit()’ function, which is passed to the traversal method.  The
‘visit()’ function takes as arguments the subobject and the extra
argument 'arg' passed to the traversal method.  It returns an integer
value that must be returned if it is non-zero.

Python provides a *note Py_VISIT(): 4784. macro that automates calling
visit functions.  With *note Py_VISIT(): 4784, we can minimize the
amount of boilerplate in ‘Custom_traverse’:

     static int
     Custom_traverse(CustomObject *self, visitproc visit, void *arg)
     {
         Py_VISIT(self->first);
         Py_VISIT(self->last);
         return 0;
     }

     注釈: The *note tp_traverse: 749. implementation must name its
     arguments exactly 'visit' and 'arg' in order to use *note
     Py_VISIT(): 4784.

Second, we need to provide a method for clearing any subobjects that can
participate in cycles:

     static int
     Custom_clear(CustomObject *self)
     {
         Py_CLEAR(self->first);
         Py_CLEAR(self->last);
         return 0;
     }

Notice the use of the *note Py_CLEAR(): 544. macro.  It is the
recommended and safe way to clear data attributes of arbitrary types
while decrementing their reference counts.  If you were to call *note
Py_XDECREF(): 75a. instead on the attribute before setting it to ‘NULL’,
there is a possibility that the attribute's destructor would call back
into code that reads the attribute again ('especially' if there is a
reference cycle).

     注釈: You could emulate *note Py_CLEAR(): 544. by writing:

          PyObject *tmp;
          tmp = self->first;
          self->first = NULL;
          Py_XDECREF(tmp);

     Nevertheless, it is much easier and less error-prone to always use
     *note Py_CLEAR(): 544. when deleting an attribute.  Don't try to
     micro-optimize at the expense of robustness!

The deallocator ‘Custom_dealloc’ may call arbitrary code when clearing
attributes.  It means the circular GC can be triggered inside the
function.  Since the GC assumes reference count is not zero, we need to
untrack the object from the GC by calling *note PyObject_GC_UnTrack():
14b0. before clearing members.  Here is our reimplemented deallocator
using *note PyObject_GC_UnTrack(): 14b0. and ‘Custom_clear’:

     static void
     Custom_dealloc(CustomObject *self)
     {
         PyObject_GC_UnTrack(self);
         Custom_clear(self);
         Py_TYPE(self)->tp_free((PyObject *) self);
     }

Finally, we add the *note Py_TPFLAGS_HAVE_GC: 748. flag to the class
flags:

     .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,

これで完了です。 *note tp_alloc: 477c. スロットまたは *note tp_free:
477b. ハンドラが書かれていれば、それらを循環ガベージコレクションに使える
よう修正すればよいのです。ほとんどの拡張機能は自動的に提供されるバージョ
ンを使うでしょう。

   ---------- Footnotes ----------

   (1) Also, even with our attributes restricted to strings instances,
the user could pass arbitrary *note str: 418. subclasses and therefore
still create reference cycles.


File: python.info,  Node: 他の型のサブクラスを作る,  Prev: 循環ガベージコレクションをサポートする,  Up: 拡張の型の定義 チュートリアル

6.2.2.5 他の型のサブクラスを作る
................................

既存の型を継承した新しい拡張型を作成することができます。組み込み型から継
承するのは特に簡単です。必要な *note PyTypeObject: a73. を簡単に利用でき
るからです。それに比べて、 *note PyTypeObject: a73. 構造体を拡張モジュー
ル間で共有するのは難しいです。

In this example we will create a ‘SubList’ type that inherits from the
built-in *note list: 5dc. type.  The new type will be completely
compatible with regular lists, but will have an additional ‘increment()’
method that increases an internal counter:

     >>> import sublist
     >>> s = sublist.SubList(range(3))
     >>> s.extend(s)
     >>> print(len(s))
     6
     >>> print(s.increment())
     1
     >>> print(s.increment())
     2

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

     typedef struct {
         PyListObject list;
         int state;
     } SubListObject;

     static PyObject *
     SubList_increment(SubListObject *self, PyObject *unused)
     {
         self->state++;
         return PyLong_FromLong(self->state);
     }

     static PyMethodDef SubList_methods[] = {
         {"increment", (PyCFunction) SubList_increment, METH_NOARGS,
          PyDoc_STR("increment state counter")},
         {NULL},
     };

     static int
     SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)
     {
         if (PyList_Type.tp_init((PyObject *) self, args, kwds) < 0)
             return -1;
         self->state = 0;
         return 0;
     }

     static PyTypeObject SubListType = {
         PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "sublist.SubList",
         .tp_doc = PyDoc_STR("SubList objects"),
         .tp_basicsize = sizeof(SubListObject),
         .tp_itemsize = 0,
         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
         .tp_init = (initproc) SubList_init,
         .tp_methods = SubList_methods,
     };

     static PyModuleDef sublistmodule = {
         PyModuleDef_HEAD_INIT,
         .m_name = "sublist",
         .m_doc = "Example module that creates an extension type.",
         .m_size = -1,
     };

     PyMODINIT_FUNC
     PyInit_sublist(void)
     {
         PyObject *m;
         SubListType.tp_base = &PyList_Type;
         if (PyType_Ready(&SubListType) < 0)
             return NULL;

         m = PyModule_Create(&sublistmodule);
         if (m == NULL)
             return NULL;

         if (PyModule_AddObjectRef(m, "SubList", (PyObject *) &SubListType) < 0) {
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

As you can see, the source code closely resembles the ‘Custom’ examples
in previous sections.  We will break down the main differences between
them.

     typedef struct {
         PyListObject list;
         int state;
     } SubListObject;

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 *note PyObject_HEAD(): 12ac. at the beginning of its
structure.

When a Python object is a ‘SubList’ instance, its ‘PyObject *’ pointer
can be safely cast to both ‘PyListObject *’ and ‘SubListObject *’:

     static int
     SubList_init(SubListObject *self, PyObject *args, PyObject *kwds)
     {
         if (PyList_Type.tp_init((PyObject *) self, args, kwds) < 0)
             return -1;
         self->state = 0;
         return 0;
     }

We see above how to call through to the *note __init__(): 67c. method of
the base type.

This pattern is important when writing a type with custom *note tp_new:
54b. and *note tp_dealloc: 477a. members.  The *note tp_new: 54b.
handler should not actually create the memory for the object with its
*note tp_alloc: 477c, but let the base class handle it by calling its
own *note tp_new: 54b.

The *note PyTypeObject: a73. struct supports a *note tp_base: 4786.
specifying the type's concrete base class.  Due to cross-platform
compiler issues, you can't fill that field directly with a reference to
*note PyList_Type: 4787.; it should be done later in the module
initialization function:

     PyMODINIT_FUNC
     PyInit_sublist(void)
     {
         PyObject* m;
         SubListType.tp_base = &PyList_Type;
         if (PyType_Ready(&SubListType) < 0)
             return NULL;

         m = PyModule_Create(&sublistmodule);
         if (m == NULL)
             return NULL;

         if (PyModule_AddObjectRef(m, "SubList", (PyObject *) &SubListType) < 0) {
             Py_DECREF(m);
             return NULL;
         }

         return m;
     }

‘PyType_Read()’ を呼ぶ前に、型の構造体の *note tp_base: 4786. スロットは
埋められていなければなりません。既存の型を継承する際には、 *note
tp_alloc: 477c. スロットを *note PyType_GenericNew(): 4777. で埋める必要
はありません。 - 基底型のアロケーション関数が継承されます。

After that, calling *note PyType_Ready(): 747. and adding the type
object to the module is the same as with the basic ‘Custom’ examples.

脚注
....


File: python.info,  Node: 拡張の型の定義 雑多なトピック,  Next: C および C++ 拡張のビルド,  Prev: 拡張の型の定義 チュートリアル,  Up: サードパーティツールなしで拡張を作る

6.2.3 拡張の型の定義: 雑多なトピック
------------------------------------

この節ではさまざまな実装可能なタイプメソッドと、それらが何をするものであ
るかについて、ざっと説明します。

以下は *note PyTypeObject: a73. の定義です。 *note デバッグビルド: 1da.
でしか使われないいくつかのメンバは省いてあります:

     typedef struct _typeobject {
         PyObject_VAR_HEAD
         const char *tp_name; /* For printing, in format "<module>.<name>" */
         Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */

         /* Methods to implement standard operations */

         destructor tp_dealloc;
         Py_ssize_t tp_vectorcall_offset;
         getattrfunc tp_getattr;
         setattrfunc tp_setattr;
         PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
                                         or tp_reserved (Python 3) */
         reprfunc tp_repr;

         /* Method suites for standard classes */

         PyNumberMethods *tp_as_number;
         PySequenceMethods *tp_as_sequence;
         PyMappingMethods *tp_as_mapping;

         /* More standard operations (here for binary compatibility) */

         hashfunc tp_hash;
         ternaryfunc tp_call;
         reprfunc tp_str;
         getattrofunc tp_getattro;
         setattrofunc tp_setattro;

         /* Functions to access object as input/output buffer */
         PyBufferProcs *tp_as_buffer;

         /* Flags to define presence of optional/expanded features */
         unsigned long tp_flags;

         const char *tp_doc; /* Documentation string */

         /* Assigned meaning in release 2.0 */
         /* call function for all accessible objects */
         traverseproc tp_traverse;

         /* delete references to contained objects */
         inquiry tp_clear;

         /* Assigned meaning in release 2.1 */
         /* rich comparisons */
         richcmpfunc tp_richcompare;

         /* weak reference enabler */
         Py_ssize_t tp_weaklistoffset;

         /* Iterators */
         getiterfunc tp_iter;
         iternextfunc tp_iternext;

         /* Attribute descriptor and subclassing stuff */
         struct PyMethodDef *tp_methods;
         struct PyMemberDef *tp_members;
         struct PyGetSetDef *tp_getset;
         // Strong reference on a heap type, borrowed reference on a static type
         struct _typeobject *tp_base;
         PyObject *tp_dict;
         descrgetfunc tp_descr_get;
         descrsetfunc tp_descr_set;
         Py_ssize_t tp_dictoffset;
         initproc tp_init;
         allocfunc tp_alloc;
         newfunc tp_new;
         freefunc tp_free; /* Low-level free-memory routine */
         inquiry tp_is_gc; /* For PyObject_IS_GC */
         PyObject *tp_bases;
         PyObject *tp_mro; /* method resolution order */
         PyObject *tp_cache;
         PyObject *tp_subclasses;
         PyObject *tp_weaklist;
         destructor tp_del;

         /* Type attribute cache version tag. Added in version 2.6 */
         unsigned int tp_version_tag;

         destructor tp_finalize;
         vectorcallfunc tp_vectorcall;

         /* bitset of which type-watchers care about this type */
         unsigned char tp_watched;
     } PyTypeObject;

'たくさんの' メソッドがありますね。でもそんなに心配する必要はありません
。定義したい型があるなら、実装するのはこのうちのごくわずかですむことがほ
とんどです。

すでに予想されているでしょうが、この構造体について入念に見ていき、様々な
ハンドラについてより詳しい情報を提供します。 しかしこれらのメンバが構造
体中で定義されている順番は無視します。というのは、これらのメンバの現れる
順序は歴史的な遺産によるものだからです。 多くの場合いちばん簡単なのは、
必要とするメンバがすべて含まれている例をとってきて、新しく作る型に合わせ
て値を変更することです。

     const char *tp_name; /* For printing */

これは型の名前です。前の章で説明したように、これは色々な場面で現れ、ほと
んどは診断目的で使われるものです。 それなので、そのような場面で役に立つ
であろう名前を選んでください!

     Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */

これらのフィールドは、この型のオブジェクトが新しく作成されるときにどれだ
けのメモリを割り当てればよいのかをランタイムに指示します。Python には可
変長の構造体 (文字列やタプルなどを想像してください) に対する組み込みのサ
ポートがある程度あり、ここで *note tp_itemsize: 1ed0. メンバが使われます
。これらについてはあとでふれます。

     const char *tp_doc;

ここには Python スクリプトリファレンス ‘obj.__doc__’ が doc string を返
すときの文字列 (あるいはそのアドレス) を入れます。

では次に、型の基本的なメソッドに進みます。ほとんどの拡張の型がこのメソッ
ドを実装します。

* Menu:

* ファイナライズとメモリ解放::
* オブジェクト表現::
* 属性を管理する::
* オブジェクトの比較::
* 抽象的なプロトコルのサポート::
* 弱参照(Weak Reference)のサポート: 弱参照 Weak Reference のサポート.
* その他いろいろ::


File: python.info,  Node: ファイナライズとメモリ解放,  Next: オブジェクト表現,  Up: 拡張の型の定義 雑多なトピック

6.2.3.1 ファイナライズとメモリ解放
..................................

     destructor tp_dealloc;

型のインスタンスの参照カウントがゼロになり、Python インタプリタがそれを
潰して再利用したくなると、この関数が呼ばれます。解放すべきメモリをその型
が保持していたり、それ以外にも実行すべき後処理がある場合は、それらをここ
に入れられます。オブジェクトそれ自体もここで解放される必要があります。こ
の関数の例は、以下のようなものです:

     static void
     newdatatype_dealloc(newdatatypeobject *obj)
     {
         free(obj->obj_UnderlyingDatatypePtr);
         Py_TYPE(obj)->tp_free((PyObject *)obj);
     }

If your type supports garbage collection, the destructor should call
*note PyObject_GC_UnTrack(): 14b0. before clearing any member fields:

     static void
     newdatatype_dealloc(newdatatypeobject *obj)
     {
         PyObject_GC_UnTrack(obj);
         Py_CLEAR(obj->other_obj);
         ...
         Py_TYPE(obj)->tp_free((PyObject *)obj);
     }

メモリ解放関数でひとつ重要なのは、処理待ちの例外にいっさい手をつけないこ
とです。なぜなら、解放用の関数は Python インタプリタがスタックを元の状態
に戻すときに呼ばれることが多いからです。そして (通常の関数からの復帰でな
く) 例外のためにスタックが巻き戻されるときは、すでに発生している例外から
メモリ解放関数を守るものはありません。解放用の関数がおこなう動作が追加の
Python のコードを実行してしまうと、それらは例外が発生していることを検知
するかもしれません。これはインタプリタが誤解させるエラーを発生させること
につながります。これを防ぐ正しい方法は、安全でない操作を実行する前に処理
待ちの例外を保存しておき、終わったらそれを元に戻すことです。これは *note
PyErr_Fetch(): 3cc. および *note PyErr_Restore(): 3cf. 関数を使うことに
よって可能になります:

     static void
     my_dealloc(PyObject *obj)
     {
         MyObject *self = (MyObject *) obj;
         PyObject *cbresult;

         if (self->my_callback != NULL) {
             PyObject *err_type, *err_value, *err_traceback;

             /* This saves the current exception state */
             PyErr_Fetch(&err_type, &err_value, &err_traceback);

             cbresult = PyObject_CallNoArgs(self->my_callback);
             if (cbresult == NULL)
                 PyErr_WriteUnraisable(self->my_callback);
             else
                 Py_DECREF(cbresult);

             /* This restores the saved exception state */
             PyErr_Restore(err_type, err_value, err_traceback);

             Py_DECREF(self->my_callback);
         }
         Py_TYPE(obj)->tp_free((PyObject*)self);
     }

     注釈: メモリ解放関数の中で安全に行えることにはいくつか制限がありま
     す。 1つ目は、その型が (*note tp_traverse: 749. および *note
     tp_clear: 478d. を使って) ガベージコレクションをサポートしている場
     合、 *note tp_dealloc: 477a. が呼び出されるまでに、消去されファイナ
     ライズされてしまうオブジェクトのメンバーが有り得ることです。 2つ目
     は、 *note tp_dealloc: 477a. の中ではオブジェクトは不安定な状態にあ
     ることです: つまり参照カウントが0であるということです。 (上の例にあ
     るような) 複雑なオブジェクトや API の呼び出しでは、 *note
     tp_dealloc: 477a. を再度呼び出し、二重解放からクラッシュすることに
     なるかもしれません。

     Python 3.4 からは、複雑なファイナライズのコードは *note tp_dealloc:
     477a. に置かず、代わりに新しく導入された *note tp_finalize: a74. と
     いう型メソッドを使うことが推奨されています。

     参考
     ....

     PEP 442(1) で新しいファイナライズの仕組みが説明されています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0442/


File: python.info,  Node: オブジェクト表現,  Next: 属性を管理する,  Prev: ファイナライズとメモリ解放,  Up: 拡張の型の定義 雑多なトピック

6.2.3.2 オブジェクト表現
........................

Python では、オブジェクトの文字列表現を生成するのに 2つのやり方がありま
す: *note repr(): 7c8. 関数を使う方法と、 *note str(): 418. 関数を使う方
法です。 (*note print(): f42. 関数は単に *note str(): 418. を呼び出しま
す。) これらのハンドラはどちらも省略できます。

     reprfunc tp_repr;
     reprfunc tp_str;

*note tp_repr: 478f. ハンドラは呼び出されたインスタンスの文字列表現を格
納した文字列オブジェクトを返す必要があります。簡単な例は以下のようなもの
です:

     static PyObject *
     newdatatype_repr(newdatatypeobject *obj)
     {
         return PyUnicode_FromFormat("Repr-ified_newdatatype{{size:%d}}",
                                     obj->obj_UnderlyingDatatypePtr->size);
     }

If no *note tp_repr: 478f. handler is specified, the interpreter will
supply a representation that uses the type's *note tp_name: 185d. and a
uniquely identifying value for the object.

*note tp_str: 4790. ハンドラと *note str(): 418. の関係は、上の *note
tp_repr: 478f. ハンドラと *note repr(): 7c8. の関係に相当します。つまり
、これは Python のコードがオブジェクトのインスタンスに対して *note
str(): 418. を呼び出したときに呼ばれます。この関数の実装は *note
tp_repr: 478f. ハンドラのそれと非常に似ていますが、得られる文字列表現は
人間が読むことを意図されています。 *note tp_str: 4790. が指定されていな
い場合、かわりに *note tp_repr: 478f. ハンドラが使われます。

以下は簡単な例です:

     static PyObject *
     newdatatype_str(newdatatypeobject *obj)
     {
         return PyUnicode_FromFormat("Stringified_newdatatype{{size:%d}}",
                                     obj->obj_UnderlyingDatatypePtr->size);
     }


File: python.info,  Node: 属性を管理する,  Next: オブジェクトの比較,  Prev: オブジェクト表現,  Up: 拡張の型の定義 雑多なトピック

6.2.3.3 属性を管理する
......................

For every object which can support attributes, the corresponding type
must provide the functions that control how the attributes are resolved.
There needs to be a function which can retrieve attributes (if any are
defined), and another to set attributes (if setting attributes is
allowed).  Removing an attribute is a special case, for which the new
value passed to the handler is ‘NULL’.

Python supports two pairs of attribute handlers; a type that supports
attributes only needs to implement the functions for one pair.  The
difference is that one pair takes the name of the attribute as a char*,
while the other accepts a *note PyObject: 312.*.  Each type can use
whichever pair makes more sense for the implementation's convenience.

     getattrfunc  tp_getattr;        /* char * version */
     setattrfunc  tp_setattr;
     /* ... */
     getattrofunc tp_getattro;       /* PyObject * version */
     setattrofunc tp_setattro;

If accessing attributes of an object is always a simple operation (this
will be explained shortly), there are generic implementations which can
be used to provide the *note PyObject: 312.* version of the attribute
management functions.  The actual need for type-specific attribute
handlers almost completely disappeared starting with Python 2.2, though
there are many examples which have not been updated to use some of the
new generic mechanism that is available.

* Menu:

* 総称的な属性を管理する::
* 特定の型に特化した属性の管理::


File: python.info,  Node: 総称的な属性を管理する,  Next: 特定の型に特化した属性の管理,  Up: 属性を管理する

6.2.3.4 総称的な属性を管理する
..............................

ほとんどの型は '単純な' 属性を使うだけです。では、どのような属性が単純だ
といえるのでしょうか?  それが満たすべき条件はごくわずかです:

  1. *note PyType_Ready(): 747. が呼ばれたとき、すでに属性の名前がわかっ
     ていること。

  2. 属性を参照したり設定したりするときに、特別な記録のための処理が必要
     でなく、また参照したり設定した値に対してどんな操作も実行する必要が
     ないこと。

これらの条件は、属性の値や、値が計算されるタイミング、または格納されたデ
ータがどの程度妥当なものであるかといったことになんら制約を課すものではな
いことに注意してください。

When *note PyType_Ready(): 747. is called, it uses three tables
referenced by the type object to create *note descriptor: 1ed1.s which
are placed in the dictionary of the type object.  Each descriptor
controls access to one attribute of the instance object.  Each of the
tables is optional; if all three are ‘NULL’, instances of the type will
only have attributes that are inherited from their base type, and should
leave the *note tp_getattro: 1657. and *note tp_setattro: 4793. fields
‘NULL’ as well, allowing the base type to handle attributes.

テーブルはタイプオブジェクト中の 3つのメンバとして宣言されています:

     struct PyMethodDef *tp_methods;
     struct PyMemberDef *tp_members;
     struct PyGetSetDef *tp_getset;

If *note tp_methods: 477f. is not ‘NULL’, it must refer to an array of
*note PyMethodDef: 1480. structures.  Each entry in the table is an
instance of this structure:

     typedef struct PyMethodDef {
         const char  *ml_name;       /* method name */
         PyCFunction  ml_meth;       /* implementation function */
         int          ml_flags;      /* flags */
         const char  *ml_doc;        /* docstring */
     } PyMethodDef;

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 *note ml_name: 4794. field of the sentinel must
be ‘NULL’.

2番目のテーブルは、インスタンス中に格納されるデータと直接対応づけられた
属性を定義するのに使います。いくつもの C の原始的な型がサポートされてお
り、アクセスを読み出し専用にも読み書き可能にもできます。このテーブルで使
われる構造体は次のように定義されています:

     typedef struct PyMemberDef {
         const char *name;
         int         type;
         int         offset;
         int         flags;
         const char *doc;
     } PyMemberDef;

For each entry in the table, a *note descriptor: 1ed1. will be
constructed and added to the type which will be able to extract a value
from the instance structure.  The *note type: 4795. field should contain
a type code like *note Py_T_INT: 55b. or *note Py_T_DOUBLE: 55c.; the
value will be used to determine how to convert Python values to and from
C values.  The *note flags: 4796. field is used to store flags which
control how the attribute can be accessed: you can set it to *note
Py_READONLY: 55d. to prevent Python code from setting it.

An interesting advantage of using the *note tp_members: 477d. table to
build descriptors that are used at runtime is that any attribute defined
this way can have an associated doc string simply by providing the text
in the table.  An application can use the introspection API to retrieve
the descriptor from the class object, and get the doc string using its
*note __doc__: 1c16. attribute.

As with the *note tp_methods: 477f. table, a sentinel entry with a *note
ml_name: 4794. value of ‘NULL’ is required.


File: python.info,  Node: 特定の型に特化した属性の管理,  Prev: 総称的な属性を管理する,  Up: 属性を管理する

6.2.3.5 特定の型に特化した属性の管理
....................................

For simplicity, only the char* version will be demonstrated here; the
type of the name parameter is the only difference between the char* and
*note PyObject: 312.* flavors of the interface.  This example
effectively does the same thing as the generic example above, but does
not use the generic support added in Python 2.2.  It explains how the
handler functions are called, so that if you do need to extend their
functionality, you'll understand what needs to be done.

The *note tp_getattr: 4798. handler is called when the object requires
an attribute look-up.  It is called in the same situations where the
*note __getattr__(): 49f. method of a class would be called.

以下に例を示します。:

     static PyObject *
     newdatatype_getattr(newdatatypeobject *obj, char *name)
     {
         if (strcmp(name, "data") == 0)
         {
             return PyLong_FromLong(obj->data);
         }

         PyErr_Format(PyExc_AttributeError,
                      "'%.100s' object has no attribute '%.400s'",
                      Py_TYPE(obj)->tp_name, name);
         return NULL;
     }

The *note tp_setattr: 4799. handler is called when the *note
__setattr__(): 1e8d. or *note __delattr__(): 1e8e. method of a class
instance would be called.  When an attribute should be deleted, the
third parameter will be ‘NULL’.  Here is an example that simply raises
an exception; if this were really all you wanted, the *note tp_setattr:
4799. handler should be set to ‘NULL’.

     static int
     newdatatype_setattr(newdatatypeobject *obj, char *name, PyObject *v)
     {
         PyErr_Format(PyExc_RuntimeError, "Read-only attribute: %s", name);
         return -1;
     }


File: python.info,  Node: オブジェクトの比較,  Next: 抽象的なプロトコルのサポート,  Prev: 属性を管理する,  Up: 拡張の型の定義 雑多なトピック

6.2.3.6 オブジェクトの比較
..........................

     richcmpfunc tp_richcompare;

The *note tp_richcompare: 479b. handler is called when comparisons are
needed.  It is analogous to the *note rich comparison methods: 1ec2,
like ‘__lt__()’, and also called by *note PyObject_RichCompare(): 479c.
and *note PyObject_RichCompareBool(): 190e.

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’,
‘Py_GE’, ‘Py_LT’ or ‘Py_GT’.  It should compare the two objects with
respect to the specified operator and return ‘Py_True’ or ‘Py_False’ if
the comparison is successful, ‘Py_NotImplemented’ to indicate that
comparison is not implemented and the other object's comparison method
should be tried, or ‘NULL’ if an exception was set.

これは内部ポインタのサイズが等しければ等しいと見なすデータ型のサンプル実
装です:

     static PyObject *
     newdatatype_richcmp(newdatatypeobject *obj1, newdatatypeobject *obj2, int op)
     {
         PyObject *result;
         int c, size1, size2;

         /* code to make sure that both arguments are of type
            newdatatype omitted */

         size1 = obj1->obj_UnderlyingDatatypePtr->size;
         size2 = obj2->obj_UnderlyingDatatypePtr->size;

         switch (op) {
         case Py_LT: c = size1 <  size2; break;
         case Py_LE: c = size1 <= size2; break;
         case Py_EQ: c = size1 == size2; break;
         case Py_NE: c = size1 != size2; break;
         case Py_GT: c = size1 >  size2; break;
         case Py_GE: c = size1 >= size2; break;
         }
         result = c ? Py_True : Py_False;
         Py_INCREF(result);
         return result;
      }


File: python.info,  Node: 抽象的なプロトコルのサポート,  Next: 弱参照 Weak Reference のサポート,  Prev: オブジェクトの比較,  Up: 拡張の型の定義 雑多なトピック

6.2.3.7 抽象的なプロトコルのサポート
....................................

Python はいくつもの '抽象的な' “プロトコル”をサポートしています。これら
を使用する特定のインターフェイスについては *note 抽象オブジェクトレイヤ
(Abstract Objects Layer): 479e. で解説されています。

A number of these abstract interfaces were defined early in the
development of the Python implementation.  In particular, the number,
mapping, and sequence protocols have been part of Python since the
beginning.  Other protocols have been added over time.  For protocols
which depend on several handler routines from the type implementation,
the older protocols have been defined as optional blocks of handlers
referenced by the type object.  For newer protocols there are additional
slots in the main type object, with a flag bit being set to indicate
that the slots are present and should be checked by the interpreter.
(The flag bit does not indicate that the slot values are non-‘NULL’.
The flag may be set to indicate the presence of a slot, but a slot may
still be unfilled.)

     PyNumberMethods   *tp_as_number;
     PySequenceMethods *tp_as_sequence;
     PyMappingMethods  *tp_as_mapping;

お使いのオブジェクトを数値やシーケンス、あるいは辞書のようにふるまうよう
にしたいならば、それぞれに C の *note PyNumberMethods: 13c5. 構造体、
*note PySequenceMethods: 479f. 構造体、または *note PyMappingMethods:
47a0. 構造体のアドレスを入れます。これらに適切な値を入れても入れなくても
かまいません。これらを使った例は Python の配布ソースにある ‘Objects’ で
みつけることができるでしょう。

     hashfunc tp_hash;

この関数は、もし使うことにしたならば、データ型のインスタンスのハッシュ番
号を返すようにします。次のは単純な例です:

     static Py_hash_t
     newdatatype_hash(newdatatypeobject *obj)
     {
         Py_hash_t result;
         result = obj->some_size + 32767 * obj->some_number;
         if (result == -1)
            result = -2;
         return result;
     }

*note Py_hash_t: 1235. is a signed integer type with a platform-varying
width.  Returning ‘-1’ from *note tp_hash: 47a1. indicates an error,
which is why you should be careful to avoid returning it when hash
computation is successful, as seen above.

     ternaryfunc tp_call;

この関数は、その型のインスタンスが「関数として呼び出される」ときに呼ばれ
ます。たとえばもし ‘obj1’ にそのインスタンスが入っていて、Python スクリ
プトで ‘obj1('hello')’ を実行したとすると、 *note tp_call: 524. ハンドラ
が呼ばれます。

この関数は 3つの引数をとります:

  1. 'self' は呼び出しの対象となるデータ型のインスタンスです。 たとえば
     呼び出しが ‘obj1('hello')’ の場合、'self' は ‘obj1’ になります。

  2. 'args' は呼び出しの引数を格納しているタプルです。ここから引数を取り
     出すには *note PyArg_ParseTuple(): 53d. を使います。

  3. 'kwds' is a dictionary of keyword arguments that were passed.  If
     this is non-‘NULL’ and you support keyword arguments, use *note
     PyArg_ParseTupleAndKeywords(): 35c. to extract the arguments.  If
     you do not want to support keyword arguments and this is
     non-‘NULL’, raise a *note TypeError: 502. with a message saying
     that keyword arguments are not supported.

以下は ‘tp_call’ の簡易な実装です:

     static PyObject *
     newdatatype_call(newdatatypeobject *obj, PyObject *args, PyObject *kwds)
     {
         PyObject *result;
         const char *arg1;
         const char *arg2;
         const char *arg3;

         if (!PyArg_ParseTuple(args, "sss:call", &arg1, &arg2, &arg3)) {
             return NULL;
         }
         result = PyUnicode_FromFormat(
             "Returning -- value: [%d] arg1: [%s] arg2: [%s] arg3: [%s]\n",
             obj->obj_UnderlyingDatatypePtr->size,
             arg1, arg2, arg3);
         return result;
     }

     /* Iterators */
     getiterfunc tp_iter;
     iternextfunc tp_iternext;

These functions provide support for the iterator protocol.  Both
handlers take exactly one parameter, the instance for which they are
being called, and return a new reference.  In the case of an error, they
should set an exception and return ‘NULL’.  *note tp_iter: 1497.
corresponds to the Python *note __iter__(): 1ebc. method, while *note
tp_iternext: 1498. corresponds to the Python *note __next__(): 129b.
method.

Any *note iterable: 10ad. object must implement the *note tp_iter: 1497.
handler, which must return an *note iterator: 191. object.  Here the
same guidelines apply as for Python classes:

   * 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 *note tp_iter: 1497.

   * Objects which can only be iterated over once (usually due to side
     effects of iteration, such as file objects) can implement *note
     tp_iter: 1497. by returning a new reference to themselves - and
     should also therefore implement the *note tp_iternext: 1498.
     handler.

Any *note iterator: 191. object should implement both *note tp_iter:
1497. and *note tp_iternext: 1498.  An iterator's *note tp_iter: 1497.
handler should return a new reference to the iterator.  Its *note
tp_iternext: 1498. handler should return a new reference to the next
object in the iteration, if there is one.  If the iteration has reached
the end, *note tp_iternext: 1498. may return ‘NULL’ without setting an
exception, or it may set *note StopIteration: bc8. 'in addition' to
returning ‘NULL’; avoiding the exception can yield slightly better
performance.  If an actual error occurs, *note tp_iternext: 1498. should
always set an exception and return ‘NULL’.


File: python.info,  Node: 弱参照 Weak Reference のサポート,  Next: その他いろいろ,  Prev: 抽象的なプロトコルのサポート,  Up: 拡張の型の定義 雑多なトピック

6.2.3.8 弱参照(Weak Reference)のサポート
........................................

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).

参考
....

Documentation for the *note weakref: fc. module.

For an object to be weakly referenceable, the extension type must set
the ‘Py_TPFLAGS_MANAGED_WEAKREF’ bit of the *note tp_flags: 1828. field.
The legacy *note tp_weaklistoffset: 956. field should be left as zero.

Concretely, here is how the statically declared type object would look:

     static PyTypeObject TrivialType = {
         PyVarObject_HEAD_INIT(NULL, 0)
         /* ... other members omitted for brevity ... */
         .tp_flags = Py_TPFLAGS_MANAGED_WEAKREF | ...,
     };

The only further addition is that ‘tp_dealloc’ needs to clear any weak
references (by calling *note PyObject_ClearWeakRefs(): 542.):

     static void
     Trivial_dealloc(TrivialObject *self)
     {
         /* Clear weakrefs first before calling any destructors */
         PyObject_ClearWeakRefs((PyObject *) self);
         /* ... remainder of destruction code omitted for brevity ... */
         Py_TYPE(self)->tp_free((PyObject *) self);
     }


File: python.info,  Node: その他いろいろ,  Prev: 弱参照 Weak Reference のサポート,  Up: 拡張の型の定義 雑多なトピック

6.2.3.9 その他いろいろ
......................

In order to learn how to implement any specific method for your new data
type, get the *note CPython: 6c1. source code.  Go to the ‘Objects’
directory, then search the C source files for ‘tp_’ plus the function
you want (for example, ‘tp_richcompare’).  You will find examples of the
function you want to implement.

When you need to verify that an object is a concrete instance of the
type you are implementing, use the *note PyObject_TypeCheck(): 1862.
function.  A sample of its use might be something like the following:

     if (!PyObject_TypeCheck(some_object, &MyType)) {
         PyErr_SetString(PyExc_TypeError, "arg #1 not a mything");
         return NULL;
     }

参考
....

Download CPython source releases.

     ‘https://www.python.org/downloads/source/’

The CPython project on GitHub, where the CPython source code is developed.

     ‘https://github.com/python/cpython’


File: python.info,  Node: C および C++ 拡張のビルド,  Next: Windows 上での C および C++ 拡張モジュールのビルド,  Prev: 拡張の型の定義 雑多なトピック,  Up: サードパーティツールなしで拡張を作る

6.2.4 C および C++ 拡張のビルド
-------------------------------

CPython の C 拡張は '初期化関数' をエクスポートした共有ライブラリ (例、
Linux の ‘.so’ ファイルや Windows の ‘.pyd’ ファイル) です。

インポートできるように、共有ライブラリは使える状態で *note PYTHONPATH:
fe8. 上になければならず、ファイル名をモジュール名に揃え、適切な拡張子に
なっていなければいけません。 setuptools を使っているときは、自動的に正し
いファイル名が生成されます。

初期化関数のシグネチャは次のとおりです:

 -- C の関数: *note PyObject: 312. *PyInit_modulename (void)

この関数は完全に初期化されたモジュールか、 *note PyModuleDef: 94b. イン
スタンスを返します。 詳しいことは *note Cモジュールの初期化: 47a7. を参
照してください。

名前にASCIIしか使っていないモジュールの場合、関数名は
‘PyInit_<modulename>’ の ‘<modulename>’ をモジュール名で置き換えたもので
なければなりません。 *note 多段階初期化: 47a8. を使っているときは、モジ
ュール名にASCII以外の文字も使えます。 この場合、初期化関数の名前は
‘PyInitU_<modulename>’ で、 ‘<modulename>’ はハイフンをアンダースコアで
置き換えて Python の 'punycode' エンコーディングでエンコードしたものにな
ります。 Python で書くと次のような処理になります:

     def initfunc_name(name):
         try:
             suffix = b'_' + name.encode('ascii')
         except UnicodeEncodeError:
             suffix = b'U_' + name.encode('punycode').replace(b'-', b'_')
         return b'PyInit' + suffix

1つの共有ライブラリに複数の初期化関数を定義することで、複数のモジュール
をエクスポートすることは可能です。 しかし、デフォルトではファイル名に対
応した関数しか見付けようとしないので、複数のモジュールをインポートさせる
にはシンボリックリンクか独自のインポーターを使う必要があります。 詳しい
ことは PEP 489(1) の '"Multiple modules in one library"' 節を参照してく
ださい。
* Menu:

* setuptools による C および C++ 拡張のビルド::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0489/


File: python.info,  Node: setuptools による C および C++ 拡張のビルド,  Up: C および C++ 拡張のビルド

6.2.4.1 setuptools による C および C++ 拡張のビルド
...................................................

Python 3.12 以降には、 distutils は含まれていません。 setuptools で
C/C++ 拡張をビルドする方法について更に学ぶには、
‘https://setuptools.readthedocs.io/en/latest/setuptools.html’ にある
‘setuptools’ のドキュメントを参照してください。


File: python.info,  Node: Windows 上での C および C++ 拡張モジュールのビルド,  Prev: C および C++ 拡張のビルド,  Up: サードパーティツールなしで拡張を作る

6.2.5 Windows 上での C および C++ 拡張モジュールのビルド
--------------------------------------------------------

この章では Windows 向けの Python 拡張モジュールを Microsoft Visual C++ を
使って作成する方法について簡単に述べ、その後に拡張モジュールのビルドがど
のように動作するのかについて詳しい背景を述べます。この説明は、Python 拡
張モジュールを作成する Windows プログラマと、Unix と Windows の双方でう
まくビルドできるようなソフトウェアの作成に興味がある Unix プログラマの双
方にとって有用です。

モジュールの作者には、この節で説明している方法よりも、distutils によるア
プローチで拡張モジュールをビルドするよう勧めます。また、Python をビルド
した際に使われた C コンパイラが必要です; 通常は Microsoft Visual C++です
。

     注釈: この章では、Python のバージョン番号が符号化されて入っているた
     くさんのファイル名について触れます。これらのファイル名は ‘XY’ で表
     されるバージョン名付きで表現されます; ‘'X'’ は使っている Python リ
     リースのメジャーバージョン番号、‘'Y'’ はマイナーバージョン番号です
     。例えば、Python 2.2.1 を使っているなら、‘XY’ は実際には ‘22’ にな
     ります。

* Menu:

* 型どおりのアプローチ::
* Unix と Windows の相違点::
* DLL 使用の実際::


File: python.info,  Node: 型どおりのアプローチ,  Next: Unix と Windows の相違点,  Up: Windows 上での C および C++ 拡張モジュールのビルド

6.2.5.1 型どおりのアプローチ
............................

There are two approaches to building extension modules on Windows, just
as there are on Unix: use the ‘setuptools’ package to control the build
process, or do things manually.  The setuptools approach works well for
most extensions; documentation on using ‘setuptools’ to build and
package extension modules is available in *note setuptools による C
および C++ 拡張のビルド: ec2.  If you find you really need to do things
manually, it may be instructive to study the project file for the
winsound(1) standard library module.

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/PCbuild/winsound.vcxproj


File: python.info,  Node: Unix と Windows の相違点,  Next: DLL 使用の実際,  Prev: 型どおりのアプローチ,  Up: Windows 上での C および C++ 拡張モジュールのビルド

6.2.5.2 Unix と Windows の相違点
................................

Unix と Windows では、コードの実行時読み込みに全く異なるパラダイムを用い
ています。動的ロードされるようなモジュールをビルドしようとする前に、自分
のシステムがどのように動作するか知っておいてください。

Unix では、共有オブジェクト (‘.so’) ファイルにプログラムが使うコード、そ
してプログラム内で使う関数名やデータが入っています。ファイルがプログラム
に結合されると、これらの関数やデータに対するファイルのコード内の全ての参
照は、メモリ内で関数やデータが配置されている、プログラム中の実際の場所を
指すように変更されます。これは基本的にはリンク操作にあたります。

Windows では、動的リンクライブラリ (‘.dll’) ファイルにはぶら下がり参照
(dangling reference) はありません。その代わり、関数やデータへのアクセス
はルックアップテーブルを介します。従って DLL コードの場合、実行時にポイ
ンタがプログラムメモリ上の正しい場所を指すように修正する必要はありません
; その代わり、コードは常に DLL のルックアップテーブルを使い、ルックアッ
プテーブル自体は実行時に実際の関数やデータを指すように修正されます。

Unix には、唯一のライブラリファイル形式 (‘.a’) しかありません。 ‘.a’ フ
ァイルには複数のオブジェクトファイル (‘.o’) 由来のコードが入っています。
共有オブジェクトファイル (‘.so’) を作成するリンク処理の段階中に、リンカ
は定義場所の不明な識別子に遭遇することがあります。このときリンカはライブ
ラリ内のオブジェクトファイルを検索します; もし識別子が見つかると、リンカ
はそのオブジェクトファイルから全てのコードを取り込みます。

Windows では、二つの形式のライブラリ、静的ライブラリとインポートライブラ
リがあります (どちらも ‘.lib’ と呼ばれています)。静的ライブラリは Unix に
おける ‘.a’ ファイルに似ています; このファイルには、必要に応じて取り込ま
れるようなコードが入っています。インポートライブラリは、基本的には特定の
識別子が不正ではなく、 DLL がロードされた時点で存在することを保証するた
めにだけ使われます。リンカはインポートライブラリからの情報を使ってルック
アップテーブルを作成し、DLL に入っていない識別子を使えるようにします。ア
プリケーションや DLL がリンクされるさい、インポートライブラリが生成され
ることがあります。このライブラリは、アプリケーションや DLL 内のシンボル
に依存するような、将来作成される全ての DLL で使うために必要になります。

二つの動的ロードモジュール、B と C を作成し、別のコードブロック A を共有
するとします。Unix では、 ‘A.a’ を ‘B.so’ や ‘C.so’ をビルドするときのリ
ンカに渡したりは 'しません' ; そんなことをすれば、コードは二度取り込まれ
、B と C のそれぞれが自分用のコピーを持ってしまいます。 Windows では、
‘A.dll’ をビルドすると ‘A.lib’ もビルドされます。 B や C のリンクには
‘A.lib’ を渡します。 ‘A.lib’ にはコードは入っていません; 単に A のコード
にアクセスするするために実行時に用いられる情報が入っているだけです。

Windows ではインポートライブラリの使用は ‘import spam’ とするようなもの
です; この操作によって spam の名前にアクセスできますが、コードのコピーを
個別に作成したりはしません。Unix では、ライブラリとのリンクはむしろ
‘from spam import *’ に似ています; この操作では個別にコードのコピーを生
成します。


File: python.info,  Node: DLL 使用の実際,  Prev: Unix と Windows の相違点,  Up: Windows 上での C および C++ 拡張モジュールのビルド

6.2.5.3 DLL 使用の実際
......................

Windows Python is built in Microsoft Visual C++; using other compilers
may or may not work.  The rest of this section is MSVC++ specific.

Windows で DLL を作成する際は、 ‘pythonXY.lib’ をリンカに渡さねばなりま
せん。例えば二つの DLL 、spam と ni (spam の中には C 関数が入っていると
します) をビルドするには、以下のコマンドを実行します:

     cl /LD /I/python/include spam.c ../libs/pythonXY.lib
     cl /LD /I/python/include ni.c spam.lib ../libs/pythonXY.lib

最初のコマンドで、三つのファイル: ‘spam.obj’ 、 ‘spam.dll’ および
‘spam.lib’ ができます。 ‘Spam.dll’ には (*note PyArg_ParseTuple(): 53d.
のような) Python 関数は全く入っていませんが、 ‘pythonXY.lib’ のおかげで
Python コードを見つけることはできます。

二つ目のコマンドでは、 ‘ni.dll’ (および ‘.obj’ と ‘.lib’) ができ、このラ
イブラリは spam と Python 実行形式中の必要な関数をどうやって見つければよ
いか知っています。

全ての識別子がルックアップテーブル上に公開されるわけではありません。他の
モジュール (Python 自体を含みます) から、自作の識別子が見えるようにする
には、‘void _declspec(dllexport) initspam(void)’ や ‘PyObject
_declspec(dllexport) *NiGetSpamData(void)’ のように、
‘_declspec(dllexport)’ で宣言せねばなりません。

Developer Studio will throw in a lot of import libraries that you do not
really need, adding about 100K to your executable.  To get rid of them,
use the Project Settings dialog, Link tab, to specify 'ignore default
libraries'.  Add the correct ‘msvcrt`xx'.lib’ to the list of libraries.


File: python.info,  Node: 大規模なアプリケーションへの Python ランタイムの埋め込み,  Prev: サードパーティツールなしで拡張を作る,  Up: Python インタプリタの拡張と埋め込み

6.3 大規模なアプリケーションへの Python ランタイムの埋め込み
============================================================

Python インタープリタの中でメインアプリケーションとして実行される拡張を
作るのではなく、 CPython をより大きなアプリケーションの中に埋め込む方が
望ましいことがあります。 この節ではその上手い埋め込みに関わる詳細につい
て説明します。

* Menu:

* 他のアプリケーションへの Python の埋め込み::


File: python.info,  Node: 他のアプリケーションへの Python の埋め込み,  Up: 大規模なアプリケーションへの Python ランタイムの埋め込み

6.3.1 他のアプリケーションへの Python の埋め込み
------------------------------------------------

前章では、 Python を拡張する方法、すなわち C 関数のライブラリを Python に
結びつけて機能を拡張する方法について述べました。同じようなことを別の方法
でも実行できます: それは、自分の C/C++ アプリケーションに Python を埋め
込んで機能を強化する、というものです。埋め込みを行うことで、アプリケーシ
ョンの何らかの機能を C や C++ の代わりに Python で実装できるようになりま
す。埋め込みは多くの用途で利用できます; ユーザが Python でスクリプトを書
き、アプリケーションを自分好みに仕立てられるようにする、というのがその一
例です。プログラマが、特定の機能を Python でより楽に書ける場合に自分自身
のために埋め込みを行うこともできます。

Python の埋め込みは Python の拡張と似ていますが、全く同じというわけでは
ありません。その違いは、Python を拡張した場合にはアプリケーションのメイ
ンプログラムは依然として Python インタプリタである一方、 Python を組み込
みんだ場合には、メインプログラムには Python が関係しない -- その代わりに
、アプリケーションのある一部分が時折 Python インタプリタを呼び出して何ら
かの Python コードを実行させる -- かもしれない、ということです。

従って、 Python の埋め込みを行う場合、自作のメインプログラムを提供しなけ
ればなりません。メインプログラムがやらなければならないことの一つに、
Python インタプリタの初期化があります。とにかく少なくとも関数 *note
Py_Initialize(): 87a. を呼び出さねばなりません。オプションとして、Python
側にコマンドライン引数を渡すために関数呼び出しを行います。その後、アプリ
ケーションのどこでもインタプリタを呼び出せるようになります。

インタプリタを呼び出すには、異なるいくつかの方法があります: Python 文が
入った文字列を *note PyRun_SimpleString(): 47b5. に渡す、 stdio ファイル
ポインタとファイル名 (これはエラーメッセージ内でコードを識別するためだけ
のものです) を *note PyRun_SimpleFile(): 47b6. に渡す、といった具合です
。これまでの各章で説明した低水準の操作を呼び出して、Python オブジェクト
を構築したり使用したりもできます。

参考
....

*note Python/C API リファレンスマニュアル: 1b47.

     Python C インターフェースの詳細はこのマニュアルに書かれています。必
     要な情報の大部分はここにあるはずです。

* Menu:

* 高水準の埋め込み::
* 超高水準の埋め込みから踏み出す; 概要: 超高水準の埋め込みから踏み出す 概要.
* 純粋な埋め込み::
* 埋め込まれた Python の拡張::
* C++による Python の埋め込み::
* Unix 系システムにおけるコンパイルとリンク::


File: python.info,  Node: 高水準の埋め込み,  Next: 超高水準の埋め込みから踏み出す 概要,  Up: 他のアプリケーションへの Python の埋め込み

6.3.1.1 高水準の埋め込み
........................

Python の埋め込みの最も簡単な形式は、超高水準インターフェースの利用です
。このインターフェースは、アプリケーションとやり取りする必要がない
Python スクリプトを実行するためのものです。例えばこれは、一つのファイル
上で何らかの操作を実現するのに利用できます。

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

     int
     main(int argc, char *argv[])
     {
         PyStatus status;
         PyConfig config;
         PyConfig_InitPythonConfig(&config);

         /* optional but recommended */
         status = PyConfig_SetBytesString(&config, &config.program_name, argv[0]);
         if (PyStatus_Exception(status)) {
             goto exception;
         }

         status = Py_InitializeFromConfig(&config);
         if (PyStatus_Exception(status)) {
             goto exception;
         }
         PyConfig_Clear(&config);

         PyRun_SimpleString("from time import time,ctime\n"
                            "print('Today is', ctime(time()))\n");
         if (Py_FinalizeEx() < 0) {
             exit(120);
         }
         return 0;

       exception:
          PyConfig_Clear(&config);
          Py_ExitStatusException(status);
     }

     注釈: ‘#define PY_SSIZE_T_CLEAN’ は、いくつかの API では ‘int’ の代
     わりに ‘Py_ssize_t’ が使われるべきであることを示すために使われてい
     ました。これは Python 3.13 以降では不要となりましたが、後方互換性の
     ために維持されています。このマクロの説明は *note 文字列とバッファ:
     364. にあります。

Setting *note PyConfig.program_name: 39e. should be called before *note
Py_InitializeFromConfig(): 39f. to inform the interpreter about paths to
Python run-time libraries.  Next, the Python interpreter is initialized
with *note Py_Initialize(): 87a, followed by the execution of a
hard-coded Python script that prints the date and time.  Afterwards, the
*note Py_FinalizeEx(): ce3. call shuts the interpreter down, followed by
the end of the program.  In a real program, you may want to get the
Python script from another source, perhaps a text-editor routine, a
file, or a database.  Getting the Python code from a file can better be
done by using the *note PyRun_SimpleFile(): 47b6. function, which saves
you the trouble of allocating memory space and loading the file
contents.


File: python.info,  Node: 超高水準の埋め込みから踏み出す 概要,  Next: 純粋な埋め込み,  Prev: 高水準の埋め込み,  Up: 他のアプリケーションへの Python の埋め込み

6.3.1.2 超高水準の埋め込みから踏み出す: 概要
............................................

高水準インターフェースは、断片的な Python コードをアプリケーションから実
行できるようにしてくれますが、アプリケーションと Python コードの間でのデ
ータのやり取りは、控えめに言っても煩わしいものです。データのやり取りをし
たいなら、より低水準のインターフェース呼び出しを利用しなくてはなりません
。より多く C コードを書かねばならない代わりに、ほぼ何でもできるようにな
ります。

Python の拡張と埋め込みは、趣旨こそ違え、同じ作業であるということに注意
せねばなりません。これまでの章で議論してきたトピックのほとんどが埋め込み
でもあてはまります。これを示すために、 Python から C への拡張を行うコー
ドが実際には何をするか考えてみましょう:

  1. データ値を Python から C に変換する。

  2. 変換された値を使って C ルーチンの関数呼び出しを行い、

  3. 呼び出しで得られたデータ値 C から Python に変換する。

Python を埋め込む場合には、インターフェースコードが行う作業は以下のよう
になります:

  1. データ値を C から Python に変換する。

  2. 変換された値を使って Python インターフェースルーチンの関数呼び出し
     を行い、

  3. 呼び出しで得られたデータ値 Python から C に変換する。

一見して分かるように、データ変換のステップは、言語間でデータを転送する方
向が変わったのに合わせて単に入れ替えただけです。唯一の相違点は、データ変
換の間にあるルーチンです。拡張を行う際には C ルーチンを呼び出しますが、
埋め込みの際には Python ルーチンを呼び出します。

この章では、Python から C へ、そしてその逆へとデータを変換する方法につい
ては議論しません。また、正しい参照の使い方やエラーの扱い方についてすでに
理解しているものと仮定します。これらの側面についてはインタプリタの拡張と
何ら変わるところがないので、必要な情報については以前の章を参照できます。


File: python.info,  Node: 純粋な埋め込み,  Next: 埋め込まれた Python の拡張,  Prev: 超高水準の埋め込みから踏み出す 概要,  Up: 他のアプリケーションへの Python の埋め込み

6.3.1.3 純粋な埋め込み
......................

最初に例示するプログラムは、Python スクリプト内の関数を実行するためのも
のです。超高水準インターフェースに関する節で挙げた例と同様に、Python イ
ンタプリタはアプリケーションと直接やりとりはしません (が、次の節でやりと
りするよう変更します)。

Python スクリプト内で定義されている関数を実行するためのコードは以下のよ
うになります:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

     int
     main(int argc, char *argv[])
     {
         PyObject *pName, *pModule, *pFunc;
         PyObject *pArgs, *pValue;
         int i;

         if (argc < 3) {
             fprintf(stderr,"Usage: call pythonfile funcname [args]\n");
             return 1;
         }

         Py_Initialize();
         pName = PyUnicode_DecodeFSDefault(argv[1]);
         /* Error checking of pName left out */

         pModule = PyImport_Import(pName);
         Py_DECREF(pName);

         if (pModule != NULL) {
             pFunc = PyObject_GetAttrString(pModule, argv[2]);
             /* pFunc is a new reference */

             if (pFunc && PyCallable_Check(pFunc)) {
                 pArgs = PyTuple_New(argc - 3);
                 for (i = 0; i < argc - 3; ++i) {
                     pValue = PyLong_FromLong(atoi(argv[i + 3]));
                     if (!pValue) {
                         Py_DECREF(pArgs);
                         Py_DECREF(pModule);
                         fprintf(stderr, "Cannot convert argument\n");
                         return 1;
                     }
                     /* pValue reference stolen here: */
                     PyTuple_SetItem(pArgs, i, pValue);
                 }
                 pValue = PyObject_CallObject(pFunc, pArgs);
                 Py_DECREF(pArgs);
                 if (pValue != NULL) {
                     printf("Result of call: %ld\n", PyLong_AsLong(pValue));
                     Py_DECREF(pValue);
                 }
                 else {
                     Py_DECREF(pFunc);
                     Py_DECREF(pModule);
                     PyErr_Print();
                     fprintf(stderr,"Call failed\n");
                     return 1;
                 }
             }
             else {
                 if (PyErr_Occurred())
                     PyErr_Print();
                 fprintf(stderr, "Cannot find function \"%s\"\n", argv[2]);
             }
             Py_XDECREF(pFunc);
             Py_DECREF(pModule);
         }
         else {
             PyErr_Print();
             fprintf(stderr, "Failed to load \"%s\"\n", argv[1]);
             return 1;
         }
         if (Py_FinalizeEx() < 0) {
             return 120;
         }
         return 0;
     }

このコードは ‘argv[1]’ を使って Python スクリプトをロードし、 ‘argv[2]’
内に指定された名前の関数を呼び出します。関数の整数引数は ‘argv’ 配列中の
他の値になります。このプログラムを *note コンパイルしてリンク: 47bd. し
(できた実行可能形式を ‘call’ と呼びましょう)、以下のような Python スクリ
プトを実行することにします:

     def multiply(a,b):
         print("Will compute", a, "times", b)
         c = 0
         for i in range(0, a):
             c = c + b
         return c

実行結果は以下のようになるはずです:

     $ call multiply multiply 3 2
     Will compute 3 times 2
     Result of call: 6

この程度の機能を実現するにはプログラムがいささか大きすぎますが、ほとんど
は Python から C へのデータ変換やエラー報告のためのコードです。Python の
埋め込みという観点から最も興味深い部分は以下のコードから始まる部分です:

     Py_Initialize();
     pName = PyUnicode_DecodeFSDefault(argv[1]);
     /* Error checking of pName left out */
     pModule = PyImport_Import(pName);

インタプリタの初期化後、スクリプトは *note PyImport_Import(): 13a4. を使
って読み込まれます。このルーチンは Python 文字列を引数に取る必要があり、
データ変換ルーチン *note PyUnicode_FromString(): 47be. で構築します。

     pFunc = PyObject_GetAttrString(pModule, argv[2]);
     /* pFunc is a new reference */

     if (pFunc && PyCallable_Check(pFunc)) {
         ...
     }
     Py_XDECREF(pFunc);

ひとたびスクリプトが読み込まれると、 *note PyObject_GetAttrString():
325. を使って必要な名前を取得できます。名前がスクリプト中に存在し、取得
したオブジェクトが呼び出し可能オブジェクトであれば、このオブジェクトが関
数であると考えて差し支えないでしょう。そこでプログラムは定石どおりに引数
のタプル構築に進みます。その後、Python 関数を以下のコードで呼び出します:

     pValue = PyObject_CallObject(pFunc, pArgs);

関数が処理を戻す際、 ‘pValue’ は ‘NULL’ になるか、関数の戻り値への参照が
入っています。値を調べた後には忘れずに参照を解放してください。


File: python.info,  Node: 埋め込まれた Python の拡張,  Next: C++による Python の埋め込み,  Prev: 純粋な埋め込み,  Up: 他のアプリケーションへの Python の埋め込み

6.3.1.4 埋め込まれた Python の拡張
..................................

ここまでは、埋め込み Python インタプリタはアプリケーション本体の機能にア
クセスする手段がありませんでした。 Python API を使うと、埋め込みインタプ
リタを拡張することでアプリケーション本体へのアクセスを可能にします。つま
り、アプリケーションで提供されているルーチンを使って、埋め込みインタプリ
タを拡張するのです。複雑なことのように思えますが、それほどひどいわけでは
ありません。さしあたって、アプリケーションが Python インタプリタを起動し
たということをちょっと忘れてみてください。その代わり、アプリケーションが
サブルーチンの集まりで、あたかも普通の Python 拡張モジュールを書くかのよ
うに、Python から各ルーチンにアクセスできるようにするグルー(glue, 糊) コ
ードを書くと考えてください。例えば以下のようにです:

     static int numargs=0;

     /* Return the number of arguments of the application command line */
     static PyObject*
     emb_numargs(PyObject *self, PyObject *args)
     {
         if(!PyArg_ParseTuple(args, ":numargs"))
             return NULL;
         return PyLong_FromLong(numargs);
     }

     static PyMethodDef EmbMethods[] = {
         {"numargs", emb_numargs, METH_VARARGS,
          "Return the number of arguments received by the process."},
         {NULL, NULL, 0, NULL}
     };

     static PyModuleDef EmbModule = {
         PyModuleDef_HEAD_INIT, "emb", NULL, -1, EmbMethods,
         NULL, NULL, NULL, NULL
     };

     static PyObject*
     PyInit_emb(void)
     {
         return PyModule_Create(&EmbModule);
     }

上のコードを ‘main()’ 関数のすぐ上に挿入します。また、以下の二つの文を
*note Py_Initialize(): 87a. の呼び出しの前に挿入します:

     numargs = argc;
     PyImport_AppendInittab("emb", &PyInit_emb);

These two lines initialize the ‘numargs’ variable, and make the
‘emb.numargs()’ function accessible to the embedded Python interpreter.
With these extensions, the Python script can do things like

     import emb
     print("Number of arguments", emb.numargs())

実際のアプリケーションでは、こうしたメソッドでアプリケーション内の API を
Python に公開することになります。


File: python.info,  Node: C++による Python の埋め込み,  Next: Unix 系システムにおけるコンパイルとリンク,  Prev: 埋め込まれた Python の拡張,  Up: 他のアプリケーションへの Python の埋め込み

6.3.1.5 C++による Python の埋め込み
...................................

C++ プログラム中にも Python を埋め込めます; 厳密に言うと、どうやって埋め
込むかは使っているC++ 処理系の詳細に依存します; 一般的には、メインプログ
ラムをC++で書き、C++ コンパイラを使ってプログラムをコンパイル・リンクす
る必要があるでしょう。 Python 自体を C++でコンパイルしなおす必要はありま
せん。


File: python.info,  Node: Unix 系システムにおけるコンパイルとリンク,  Prev: C++による Python の埋め込み,  Up: 他のアプリケーションへの Python の埋め込み

6.3.1.6 Unix 系システムにおけるコンパイルとリンク
.................................................

Python インタプリタをアプリケーションに埋め込むためにコンパイラ (とリン
カ) に渡すべき正しいフラグを見出すのは簡単でないかもしれません。これは特
に、Python がライブラリモジュールに対してリンクされた C 動的拡張 (‘.so’
ファイル) として実装されたものをロードする必要があるためです。

必要なコンパイル・リンクのオプションを知るために、 ‘python`X.Y'-config’
スクリプトが使えます(これは Python インストール時に生成されたもので、
‘python3-config’ スクリプトも利用出来るかもしれません)。このスクリプトに
はオプションが多くありますが、直接的に有用なのはこれでしょう:

   * ‘pythonX.Y-config --cflags’ は推奨のコンパイルオプションを出力しま
     す:

          $ /opt/bin/python3.11-config --cflags
          -I/opt/include/python3.11 -I/opt/include/python3.11 -Wsign-compare  -DNDEBUG -g -fwrapv -O3 -Wall

   * ‘pythonX.Y-config --ldflags --embed’ は推奨のリンクオプションを出力
     します:

          $ /opt/bin/python3.11-config --ldflags --embed
          -L/opt/lib/python3.11/config-3.11-x86_64-linux-gnu -L/opt/lib -lpython3.11 -lpthread -ldl  -lutil -lm

     注釈: 複数 Python バージョン共存(とりわけシステムの Python とあなた
     自身でビルドした Python)での混乱を避けるために、上での例のように
     ‘python`X.Y'-config’ は絶対パスで起動したほうが良いです。

もしこの手順でうまくいかなければ(たしかにこれは全ての Unix 的なプラット
フォームで動作することを保障するものではないですが、 *note bug reports:
47c4. は歓迎です)、あなたのシステムのダイナミックリンクについてのドキュ
メントを読み、Python の ‘Makefile’ のコンパイルオプションを調べる必要が
あるでしょう(Makefile の場所を調べるには *note
sysconfig.get_makefile_filename(): 4250. を使ってください)。この場合、
*note sysconfig: c5. モジュールが役に立つ道具になります。これによってあ
なたが付け加えたいコンパイル・リンクのオプション構成をプログラム的に抽出
できます。例えば:

     >>> import sysconfig
     >>> sysconfig.get_config_var('LIBS')
     '-lpthread -ldl  -lutil'
     >>> sysconfig.get_config_var('LINKFORSHARED')
     '-Xlinker -export-dynamic'


File: python.info,  Node: Python/C API リファレンスマニュアル,  Next: Python モジュールのインストール,  Prev: Python インタプリタの拡張と埋め込み,  Up: Top

7 Python/C API リファレンスマニュアル
*************************************

このマニュアルでは、拡張モジュールを書いたり Python インタプリタをアプリ
ケーションに埋め込んだりしたい C/C++ プログラマが利用できる API について
述べています。 *note Python インタプリタの拡張と埋め込み: 1b46. は拡張モ
ジュールを書く際の一般的な決まりごとについて記述していますが、 API の詳
細までは記述していないので、このドキュメントが手引きになります。

* Menu:

* はじめに: はじめに<11>.
* C API の安定性::
* 超高水準レイヤ::
* 参照カウント::
* 例外処理::
* ユーティリティ: ユーティリティ<2>.
* 抽象オブジェクトレイヤ (Abstract Objects Layer): 抽象オブジェクトレイヤ Abstract Objects Layer.
* 具象オブジェクト (concrete object) レイヤ: 具象オブジェクト concrete object レイヤ.
* 初期化 (initialization)、終了処理 (finalization)、スレッド: 初期化 initialization 、終了処理 finalization 、スレッド.
* Python 初期化設定::
* メモリ管理::
* オブジェクト実装サポート (object implementation support): オブジェクト実装サポート object implementation support.
* API と ABI のバージョニング::
* Monitoring C API::
* Generating Execution Events::


File: python.info,  Node: はじめに<11>,  Next: C API の安定性,  Up: Python/C API リファレンスマニュアル

7.1 はじめに
============

Python のアプリケーションプログラマ用インタフェース (Application
Programmer's Interface, API) は、 Python インタプリタに対する様々なレベ
ルでのアクセス手段を C や C++ のプログラマに提供しています。この API は
通常 C++ からも全く同じように利用できるのですが、簡潔な呼び名にするため
に Python/C API と名づけられています。根本的に異なる二つの目的から、
Python/C API が用いられます。第一は、特定用途の '拡張モジュール
(extension module)' 、すなわち Python インタプリタを拡張する C で書かれ
たモジュールを記述する、という目的です。第二は、より大規模なアプリケーシ
ョン内で Python を構成要素 (component) として利用するという目的です; こ
のテクニックは、一般的にはアプリケーションへの Python の埋め込み
('embedding') と呼びます。

拡張モジュールの作成は比較的わかりやすいプロセスで、 "手引書 (cookbook)"
的なアプローチでうまく実現できます。作業をある程度まで自動化してくれるツ
ールもいくつかあります。一方、他のアプリケーションへの Python の埋め込み
は、Python ができてから早い時期から行われてきましたが、拡張モジュールの
作成に比べるとやや難解です。

多くの API 関数は、Python の埋め込みであるか拡張であるかに関わらず役立ち
ます; とはいえ、Python を埋め込んでいるほとんどのアプリケーションは、同
時に自作の拡張モジュールも提供する必要が生じることになるでしょうから、
Python を実際にアプリケーションに埋め込んでみる前に拡張モジュールの書き
方に詳しくなっておくのはよい考えだと思います。

* Menu:

* コーディング基準::
* インクルードファイル::
* 便利なマクロ::
* オブジェクト、型および参照カウント::
* 例外: 例外<21>.
* Python の埋め込み: Python の埋め込み<2>.
* デバッグ版ビルド (Debugging Builds): デバッグ版ビルド Debugging Builds.


File: python.info,  Node: コーディング基準,  Next: インクルードファイル,  Up: はじめに<11>

7.1.1 コーディング基準
----------------------

CPython に含める C コードを書いている場合は、 PEP 7(1) のガイドラインと
基準に従わなければ 'なりません' 。 このガイドラインは、コントリビュート
対象の Python のバージョンに関係無く適用されます。 自身のサードパーティ
ーのモジュールでは、それをいつか Python にコントリビュートするつもりでな
ければ、この慣習に従う必要はありません。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0007/


File: python.info,  Node: インクルードファイル,  Next: 便利なマクロ,  Prev: コーディング基準,  Up: はじめに<11>

7.1.2 インクルードファイル
--------------------------

Python/C API を使うために必要な、関数、型およびマクロの全ての定義をイン
クルードするには、以下の行:

     #define PY_SSIZE_T_CLEAN
     #include <Python.h>

をソースコードに記述します。この行を記述すると、標準ヘッダ: ‘<stdio.h>’,
‘<string.h>’, ‘<errno.h>’, ‘<limits.h>’, ‘<assert.h>’, ‘<stdlib.h>’ を
(利用できれば) インクルードします。

     注釈: Python は、システムによっては標準ヘッダの定義に影響するような
     プリプロセッサ定義を行っているので、 ‘Python.h’ をいずれの標準ヘッ
     ダよりも前にインクルード 'せねばなりません' 。

     ‘Python.h’ をインクルードする前に、常に ‘PY_SSIZE_T_CLEAN’ を定義す
     ることが推奨されます。 このマクロの解説については *note
     引数の解釈と値の構築: 876. を参照してください。

Python.h で定義されている、ユーザから見える名前全て (Python.h がインクル
ードしている標準ヘッダの名前は除きます) には、接頭文字列 ‘Py’ または
‘_Py’ が付きます。‘_Py’ で始まる名前は Python 実装で内部使用するための名
前で、拡張モジュールの作者は使ってはなりません。構造体のメンバには予約済
みの接頭文字列はありません。

     注釈: API のユーザは、‘Py’ や ‘_Py’ で始まる名前を定義するコードを
     絶対に書いてはなりません。 後からコードを読む人を混乱させたり、将来
     の Python のバージョンで同じ名前が定義されて、ユーザの書いたコード
     の可搬性を危うくする可能性があります。

ヘッダファイル群は通常 Python と共にインストールされます。 Unixでは
‘`prefix'/include/pythonversion/’ および
‘`exec_prefix'/include/pythonversion/’ に置かれます。 *note prefix:
1cca. と *note exec_prefix: 1ccb. は Python をビルドする際の ‘configure’
スクリプトに与えたパラメタに対応し、 'version' は ‘'%d.%d' %
sys.version_info[:2]’ に対応します。 Windows では、ヘッダは
‘`prefix'/include’ に置かれます。 ‘prefix’ はインストーラに指定したイン
ストールディレクトリです。

ヘッダをインクルードするには、各ヘッダの入ったディレクトリ (別々のディレ
クトリの場合は両方) を、コンパイラがインクルードファイルを検索するための
パスに入れます。親ディレクトリをサーチパスに入れて、 ‘#include
<pythonX.Y/Python.h>’ のようにしては 'なりません' ; *note prefix: 1cca.
内のプラットフォームに依存しないヘッダは、 *note exec_prefix: 1ccb. から
プラットフォーム依存のヘッダをインクルードしているので、このような操作を
行うと複数のプラットフォームでのビルドができなくなります。

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++.


File: python.info,  Node: 便利なマクロ,  Next: オブジェクト、型および参照カウント,  Prev: インクルードファイル,  Up: はじめに<11>

7.1.3 便利なマクロ
------------------

Python のヘッダーファイルには便利なマクロがいくつか定義されています。 多
くのマクロは、それが役に立つところ (例えば、 *note Py_RETURN_NONE:
1418.) の近くに定義があります。 より一般的な使われかたをする他のマクロは
これらのヘッダーファイルに定義されています。 ただし、ここで完全に列挙さ
れているとは限りません。

 -- C のマクロ: PyMODINIT_FUNC

     Declare an extension module ‘PyInit’ initialization function.  The
     function return type is *note PyObject: 312.*.  The macro declares
     any special linkage declarations required by the platform, and for
     C++ declares the function as ‘extern "C"’.

     The initialization function must be named ‘PyInit_NAME’, where
     'name' is the name of the module, and should be the only
     non-‘static’ item defined in the module file.  Example:

          static struct PyModuleDef spam_module = {
              PyModuleDef_HEAD_INIT,
              .m_name = "spam",
              ...
          };

          PyMODINIT_FUNC
          PyInit_spam(void)
          {
              return PyModule_Create(&spam_module);
          }

 -- C のマクロ: Py_ABS (x)

     ‘x’ の絶対値を返します。

     Added in version 3.3.

 -- C のマクロ: Py_ALWAYS_INLINE

     Ask the compiler to always inline a static inline function.  The
     compiler can ignore it and decides to not inline the function.

     It can be used to inline performance critical static inline
     functions when building Python in debug mode with function inlining
     disabled.  For example, MSC disables function inlining when
     building in debug mode.

     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.

     If Python is *note built in debug mode: 1da. (if the *note
     Py_DEBUG: 3fb8. macro is defined), the *note Py_ALWAYS_INLINE:
     1821. macro does nothing.

     It must be specified before the function return type.  Usage:

          static inline Py_ALWAYS_INLINE int random(void) { return 4; }

     Added in version 3.11.

 -- C のマクロ: Py_CHARMASK (c)

     引数は文字か、[-128, 127] あるいは [0, 255] の範囲の整数でなければ
     なりません。 このマクロは ‘符号なし文字’ にキャストした ‘c’ を返し
     ます。

 -- C のマクロ: Py_DEPRECATED (version)

     Use this for deprecated declarations.  The macro must be placed
     before the symbol name.

     以下はプログラム例です:

          Py_DEPRECATED(3.8) PyAPI_FUNC(int) Py_OldFunction(void);

     バージョン 3.8 で変更: MSVC サポートが追加されました。

 -- C のマクロ: Py_GETENV (s)

     Like ‘getenv(s)’, but returns ‘NULL’ if *note -E: 92b. was passed
     on the command line (see *note PyConfig.use_environment: 3b3.).

 -- C のマクロ: Py_MAX (x, y)

     ‘x’ と ‘y’ の最大値を返します。

     Added in version 3.3.

 -- C のマクロ: Py_MEMBER_SIZE (type, member)

     (‘type’) 構造体の ‘member’ のサイズをバイト単位で返します。

     Added in version 3.6.

 -- C のマクロ: Py_MIN (x, y)

     ‘x’ と ‘y’ の最小値を返します。

     Added in version 3.3.

 -- C のマクロ: Py_NO_INLINE

     Disable inlining on a function.  For example, it reduces the C
     stack consumption: useful on LTO+PGO builds which heavily inline
     code (see bpo-33720(1)).

     使い方:

          Py_NO_INLINE static int random(void) { return 4; }

     Added in version 3.11.

 -- C のマクロ: Py_STRINGIFY (x)

     ‘x’ を C 文字列へ変換します。 例えば、 ‘Py_STRINGIFY(123)’ は
     ‘"123"’ を返します。

     Added in version 3.4.

 -- C のマクロ: Py_UNREACHABLE ()

     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.

     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.

     A use for ‘Py_UNREACHABLE()’ is following a call a function that
     never returns but that is not declared ‘_Py_NO_RETURN’.

     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 or if a system call returns a value out of the
     expected range.  In this case, it's better to report the error to
     the caller.  If the error cannot be reported to caller, *note
     Py_FatalError(): 951. can be used.

     Added in version 3.7.

 -- C のマクロ: Py_UNUSED (arg)

     Use this for unused arguments in a function definition to silence
     compiler warnings.  Example: ‘int func(int a, int Py_UNUSED(b)) {
     return a; }’.

     Added in version 3.4.

 -- C のマクロ: PyDoc_STRVAR (name, str)

     Creates a variable with name ‘name’ that can be used in docstrings.
     If Python is built without docstrings, the value will be empty.

     Use *note PyDoc_STRVAR: 18dd. for docstrings to support building
     Python without docstrings, as specified in PEP 7(2).

     以下はプログラム例です:

          PyDoc_STRVAR(pop_doc, "Remove and return the rightmost element.");

          static PyMethodDef deque_methods[] = {
              // ...
              {"pop", (PyCFunction)deque_pop, METH_NOARGS, pop_doc},
              // ...
          }

 -- C のマクロ: PyDoc_STR (str)

     Creates a docstring for the given input string or an empty string
     if docstrings are disabled.

     Use *note PyDoc_STR: 1776. in specifying docstrings to support
     building Python without docstrings, as specified in PEP 7(3).

     以下はプログラム例です:

          static PyMethodDef pysqlite_row_methods[] = {
              {"keys", (PyCFunction)pysqlite_row_keys, METH_NOARGS,
                  PyDoc_STR("Returns the keys of the row.")},
              {NULL, NULL}
          };

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=33720

   (2) https://peps.python.org/pep-0007/

   (3) https://peps.python.org/pep-0007/


File: python.info,  Node: オブジェクト、型および参照カウント,  Next: 例外<21>,  Prev: 便利なマクロ,  Up: はじめに<11>

7.1.4 オブジェクト、型および参照カウント
----------------------------------------

Python/C API 関数は、 *note PyObject: 312.* 型の一つ以上の引数と戻り値を
持ちます。この型は、任意の Python オブジェクトを表現する不透明 (opaque)
なデータ型へのポインタです。 Python 言語は、全ての Python オブジェクト型
をほとんどの状況 (例えば代入、スコープ規則 (scope rule)、引数渡し) で同
様に扱います。ほとんど全ての Python オブジェクトはヒープ (heap) 上に置か
れます: このため、 *note PyObject: 312. 型のオブジェクトは、自動記憶
(automatic) としても静的記憶 (static) としても宣言できません。 *note
PyObject: 312.* 型のポインタ変数のみ宣言できます。唯一の例外は、型オブジ
ェクトです; 型オブジェクトはメモリ解放 (deallocate) してはならないので、
通常は静的記憶の *note PyTypeObject: a73. オブジェクトにします。

全ての Python オブジェクトには (Python 整数型ですら) 型 ('type') と参照
カウント ('reference count') があります。あるオブジェクトの型は、そのオ
ブジェクトがどの種類のオブジェクトか (例えば整数、リスト、ユーザ定義関数
、など; その他多数については *note 標準型の階層: 1e46. で説明しています)
を決定します。よく知られている型については、各々マクロが存在して、あるオ
ブジェクトがその型かどうか調べられます; 例えば、 ‘PyList_Check(a)’ は、
'a' で示されたオブジェクトが Python リスト型のとき (かつそのときに限り)
真値を返します。

* Menu:

* 参照カウント法: 参照カウント法<2>.
* 型::


File: python.info,  Node: 参照カウント法<2>,  Next: 型,  Up: オブジェクト、型および参照カウント

7.1.4.1 参照カウント法
......................

The reference count is important because today's computers have a finite
(and often severely limited) memory size; it counts how many different
places there are that have a *note strong reference: 316. to an object.
Such a place could be another object, or a global (or static) C
variable, or a local variable in some C function.  When the last *note
strong reference: 316. to an object is released (i.e.  its reference
count becomes zero), the object is deallocated.  If it contains
references to other objects, those references are released.  Those other
objects may be deallocated in turn, if there are no more references to
them, and so on.  (There's an obvious problem with objects that
reference each other here; for now, the solution is "don't do that.")

Reference counts are always manipulated explicitly.  The normal way is
to use the macro *note Py_INCREF(): 53a. to take a new reference to an
object (i.e.  increment its reference count by one), and *note
Py_DECREF(): 53b. to release that reference (i.e.  decrement the
reference count by one).  The *note Py_DECREF(): 53b. macro is
considerably more complex than the incref one, since it must check
whether the reference count becomes zero and then cause the object's
deallocator to be called.  The deallocator is a function pointer
contained in the object's type structure.  The type-specific deallocator
takes care of releasing references for other objects contained in the
object if this is a compound object type, such as a list, as well as
performing any additional finalization that's needed.  There's no chance
that the reference count can overflow; at least as many bits are used to
hold the reference count as there are distinct memory locations in
virtual memory (assuming ‘sizeof(Py_ssize_t) >= sizeof(void*)’).  Thus,
the reference count increment is a simple operation.

It is not necessary to hold a *note strong reference: 316. (i.e.
increment the reference count) for every local variable that contains a
pointer to an object.  In theory, the object's reference count goes up
by one when the variable is made to point to it and it goes down by one
when the variable goes out of scope.  However, these two cancel each
other out, so at the end the reference count hasn't changed.  The only
real reason to use the reference count is to prevent the object from
being deallocated as long as our variable is pointing to it.  If we know
that there is at least one other reference to the object that lives at
least as long as our variable, there is no need to take a new *note
strong reference: 316. (i.e.  increment the reference count)
temporarily.  An important situation where this arises is in objects
that are passed as arguments to C functions in an extension module that
are called from Python; the call mechanism guarantees to hold a
reference to every argument for the duration of the call.

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 conceivably remove the object from the list, releasing
that reference, and possibly deallocating it.  The real danger is that
innocent-looking operations may invoke arbitrary Python code which could
do this; there is a code path which allows control to flow back to the
user from a *note Py_DECREF(): 53b, so almost any operation is
potentially dangerous.

A safe approach is to always use the generic operations (functions whose
name begins with ‘PyObject_’, ‘PyNumber_’, ‘PySequence_’ or
‘PyMapping_’).  These operations always create a new *note strong
reference: 316. (i.e.  increment the reference count) of the object they
return.  This leaves the caller with the responsibility to call *note
Py_DECREF(): 53b. when they are done with the result; this soon becomes
second nature.

* Menu:

* 参照カウントの詳細::


File: python.info,  Node: 参照カウントの詳細,  Up: 参照カウント法<2>

7.1.4.2 参照カウントの詳細
..........................

The reference count behavior of functions in the Python/C API is best
explained in terms of 'ownership of references'.  Ownership pertains to
references, never to objects (objects are not owned: they are always
shared).  "Owning a reference" means being responsible for calling
Py_DECREF on it when the reference is no longer needed.  Ownership can
also be transferred, meaning that the code that receives ownership of
the reference then becomes responsible for eventually releasing it by
calling *note Py_DECREF(): 53b. or *note Py_XDECREF(): 75a. when it's no
longer needed--or passing on this responsibility (usually to its
caller).  When a function passes ownership of a reference on to its
caller, the caller is said to receive a 'new' reference.  When no
ownership is transferred, the caller is said to 'borrow' the reference.
Nothing needs to be done for a *note borrowed reference: 317.

逆に、ある関数呼び出しで、あるオブジェクトへの参照を呼び出される関数に渡
す際には、二つの可能性: 関数がオブジェクトへの参照を '盗み取る' (steal)
場合と、そうでない場合があります。'参照を盗む' とは、関数に参照を渡した
ときに、参照の所有者がその関数になったと仮定し、関数の呼び出し元には所有
権がなくなるということです。

参照を盗み取る関数はほとんどありません; 例外としてよく知られているのは、
*note PyList_SetItem(): 4765. と *note PyTuple_SetItem(): 4764. で、これ
らはシーケンスに入れる要素に対する参照を盗み取ります (しかし、要素の入る
先のタプルやリストの参照は盗み取りません!)。これらの関数は、リストやタプ
ルの中に新たに作成されたオブジェクトを入れていく際の常套的な書き方をしや
すくするために、参照を盗み取るように設計されています; 例えば、 ‘(1, 2,
"three")’ というタプルを生成するコードは以下のようになります (とりあえず
例外処理のことは忘れておきます; もっとよい書き方を後で示します):

     PyObject *t;

     t = PyTuple_New(3);
     PyTuple_SetItem(t, 0, PyLong_FromLong(1L));
     PyTuple_SetItem(t, 1, PyLong_FromLong(2L));
     PyTuple_SetItem(t, 2, PyUnicode_FromString("three"));

ここで、 *note PyLong_FromLong(): 17a4. は新しい参照を返し、すぐに *note
PyTuple_SetItem(): 4764. に盗まれます。参照が盗まれた後もそのオブジェク
トを利用したい場合は、参照盗む関数を呼び出す前に、 *note Py_INCREF():
53a. を利用してもう一つの参照を取得してください。

ちなみに、 *note PyTuple_SetItem(): 4764. はタプルに値をセットするための
'唯一の' 方法です; タプルは変更不能なデータ型なので、 *note
PySequence_SetItem(): 19bf. や *note PyObject_SetItem(): 47da. を使うと
上の操作は拒否されてしまいます。自分でタプルの値を入れていくつもりなら、
*note PyTuple_SetItem(): 4764. だけしか使えません。

同じく、リストに値を入れていくコードは *note PyList_New(): 47db. と
*note PyList_SetItem(): 4765. で書けます。

しかし実際には、タプルやリストを生成して値を入れる際には、上記のような方
法はほとんど使いません。より汎用性のある関数、 *note Py_BuildValue():
875. があり、ほとんどの主要なオブジェクトをフォーマット文字列 'format
string' の指定に基づいて C の値から生成できます。例えば、上の二種類のコ
ードブロックは、以下のように置き換えられます (エラーチェックにも配慮して
います):

     PyObject *tuple, *list;

     tuple = Py_BuildValue("(iis)", 1, 2, "three");
     list = Py_BuildValue("[iis]", 1, 2, "three");

It is much more common to use *note PyObject_SetItem(): 47da. and
friends with items whose references you are only borrowing, like
arguments that were passed in to the function you are writing.  In that
case, their behaviour regarding references is much saner, since you
don't have to take a new reference just so you can give that reference
away ("have it be stolen").  For example, this function sets all items
of a list (actually, any mutable sequence) to a given item:

     int
     set_all(PyObject *target, PyObject *item)
     {
         Py_ssize_t i, n;

         n = PyObject_Length(target);
         if (n < 0)
             return -1;
         for (i = 0; i < n; i++) {
             PyObject *index = PyLong_FromSsize_t(i);
             if (!index)
                 return -1;
             if (PyObject_SetItem(target, index, item) < 0) {
                 Py_DECREF(index);
                 return -1;
             }
             Py_DECREF(index);
         }
         return 0;
     }

関数の戻り値の場合には、状況は少し異なります。ほとんどの関数については、
参照を渡してもその参照に対する所有権が変わることがない一方で、あるオブジ
ェクトに対する参照を返すような多くの関数は、参照に対する所有権を呼び出し
側に与えます。理由は簡単です: 多くの場合、関数が返すオブジェクトはその場
で (on the fly) 生成されるため、呼び出し側が得る参照は生成されたオブジェ
クトに対する唯一の参照になるからです。従って、 *note PyObject_GetItem():
320. や *note PySequence_GetItem(): 19be. のように、オブジェクトに対する
参照を返す汎用の関数は、常に新たな参照を返します (呼び出し側が参照の所有
者になります)。

重要なのは、関数が返す参照の所有権を持てるかどうかは、どの関数を呼び出す
かだけによる、と理解することです -- 関数呼び出し時の 'お飾り' (関数に引
数として渡したオブジェクトの型) は 'この問題には関係ありません!'  従って
、 *note PyList_GetItem(): 335. を使ってリスト内の要素を得た場合には、参
照の所有者にはなりません -- が、同じ要素を同じリストから *note
PySequence_GetItem(): 19be. (図らずもこの関数は全く同じ引数をとります) を
使って取り出すと、返されたオブジェクトに対する参照を得ます。

以下は、整数からなるリストに対して各要素の合計を計算する関数をどのように
して書けるかを示した例です; 一つは *note PyList_GetItem(): 335. を使って
いて、もう一つは *note PySequence_GetItem(): 19be. を使っています。

     long
     sum_list(PyObject *list)
     {
         Py_ssize_t i, n;
         long total = 0, value;
         PyObject *item;

         n = PyList_Size(list);
         if (n < 0)
             return -1; /* Not a list */
         for (i = 0; i < n; i++) {
             item = PyList_GetItem(list, i); /* Can't fail */
             if (!PyLong_Check(item)) continue; /* Skip non-integers */
             value = PyLong_AsLong(item);
             if (value == -1 && PyErr_Occurred())
                 /* Integer too big to fit in a C long, bail out */
                 return -1;
             total += value;
         }
         return total;
     }

     long
     sum_sequence(PyObject *sequence)
     {
         Py_ssize_t i, n;
         long total = 0, value;
         PyObject *item;
         n = PySequence_Length(sequence);
         if (n < 0)
             return -1; /* Has no length */
         for (i = 0; i < n; i++) {
             item = PySequence_GetItem(sequence, i);
             if (item == NULL)
                 return -1; /* Not a sequence, or other failure */
             if (PyLong_Check(item)) {
                 value = PyLong_AsLong(item);
                 Py_DECREF(item);
                 if (value == -1 && PyErr_Occurred())
                     /* Integer too big to fit in a C long, bail out */
                     return -1;
                 total += value;
             }
             else {
                 Py_DECREF(item); /* Discard reference ownership */
             }
         }
         return total;
     }


File: python.info,  Node: 型,  Prev: 参照カウント法<2>,  Up: オブジェクト、型および参照カウント

7.1.4.3 型
..........

他にも Python/C API において重要な役割を持つデータ型がいくつかあります;
ほとんどは int, long, double, および char* といった、単なる C のデータ型
です。また、モジュールで公開している関数を列挙する際に用いられる静的なテ
ーブルや、新しいオブジェクト型におけるデータ属性を記述したり、複素数の値
を記述したりするために構造体をいくつか使っています。これらの型については
、その型を使う関数とともに説明してゆきます。

 -- C のデータ型: type Py_ssize_t
     ' 次に属します: *note Stable ABI: 51e.'  A signed integral type
     such that ‘sizeof(Py_ssize_t) == sizeof(size_t)’.  C99 doesn't
     define such a thing directly (size_t is an unsigned integral type).
     See PEP 353(1) for details.  ‘PY_SSIZE_T_MAX’ is the largest
     positive value of type *note Py_ssize_t: a2e.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0353/


File: python.info,  Node: 例外<21>,  Next: Python の埋め込み<2>,  Prev: オブジェクト、型および参照カウント,  Up: はじめに<11>

7.1.5 例外
----------

Python プログラマは、特定のエラー処理が必要なときだけしか例外を扱う必要
はありません; 処理しなかった例外は、処理の呼び出し側、そのまた呼び出し側
、といった具合に、トップレベルのインタプリタ層まで自動的に伝播します。イ
ンタプリタ層は、スタックトレースバックと合わせて例外をユーザに報告します
。

ところが、 C プログラマの場合、エラーチェックは常に明示的に行わねばなり
ません。 Python/C API の全ての関数は、関数のドキュメントで明確に説明がな
い限り例外を発行する可能性があります。一般的な話として、ある関数が何らか
のエラーに遭遇すると、関数は例外を設定して、関数内における参照の所有権を
全て放棄し、エラー値 (error indicator) を返します。ドキュメントに書かれ
てない場合、このエラー値は関数の戻り値の型によって、 ‘NULL’ か ‘-1’ のど
ちらかになります。いくつかの関数ではブール型で真/偽を返し、偽はエラーを
示します。きわめて少数の関数では明確なエラー指標を返さなかったり、あいま
いな戻り値を返したりするので、 *note PyErr_Occurred(): 185c. で明示的に
エラーテストを行う必要があります。これらの例外は常に明示的にドキュメント
化されます。

例外時の状態情報 (exception state)は、スレッド単位に用意された記憶領域
(per-thread storage) 内で管理されます (この記憶領域は、スレッドを使わな
いアプリケーションではグローバルな記憶領域と同じです)。一つのスレッドは
二つの状態のどちらか: 例外が発生したか、まだ発生していないか、をとります
。関数 *note PyErr_Occurred(): 185c. を使うと、この状態を調べられます: こ
の関数は例外が発生した際にはその例外型オブジェクトに対する借用参照
(borrowed reference) を返し、そうでないときには ‘NULL’ を返します。例外
状態を設定する関数は数多くあります: *note PyErr_SetString(): 548. はもっ
ともよく知られている (が、もっとも汎用性のない) 例外を設定するための関数
で、 *note PyErr_Clear(): ffb. は例外状態情報を消し去る関数です。

完全な例外状態情報は、3 つのオブジェクト: 例外の型、例外の値、そしてトレ
ースバック、からなります (どのオブジェクトも ‘NULL’ を取り得ます)。これ
らの情報は、 Python の ‘sys.exc_info()’ の結果と同じ意味を持ちます; とは
いえ、 C と Python の例外状態情報は全く同じではありません: Python におけ
る例外オブジェクトは、Python の *note try: 6b4. ...  *note except: 170.
文で最近処理したオブジェクトを表す一方、 C レベルの例外状態情報が存続す
るのは、渡された例外情報を ‘sys.exc_info()’ その他に転送するよう取り計ら
う Python のバイトコードインタプリタのメインループに到達するまで、例外が
関数の間で受け渡しされている間だけです。

Python 1.5 からは、Python で書かれたコードから例外状態情報にアクセスする
方法として、推奨されていてスレッドセーフな方法は *note sys.exc_info():
656. になっているので注意してください。この関数は Python コードの実行さ
れているスレッドにおける例外状態情報を返します。また、これらの例外状態情
報に対するアクセス手段は、両方とも意味づけ (semantics) が変更され、ある
関数が例外を捕捉すると、その関数を実行しているスレッドの例外状態情報を保
存して、呼び出し側の例外状態情報を維持するようになりました。この変更によ
って、無害そうに見える関数が現在扱っている例外を上書きすることで引き起こ
される、例外処理コードでよくおきていたバグを抑止しています; また、トレー
スバック内のスタックフレームで参照されているオブジェクトがしばしば不必要
に寿命を永らえていたのをなくしています。

一般的な原理として、ある関数が別の関数を呼び出して何らかの作業をさせると
き、呼び出し先の関数が例外を送出していないか調べなくてはならず、もし送出
していれば、その例外状態情報は呼び出し側に渡されなければなりません。呼び
出し元の関数はオブジェクト参照の所有権をすべて放棄し、エラー指標を返さな
くてはなりませんが、余計に例外を設定する必要は 'ありません' -- そんなこ
とをすれば、たった今送出されたばかりの例外を上書きしてしまい、エラーの原
因そのものに関する重要な情報を失うことになります。

A simple example of detecting exceptions and passing them on is shown in
the ‘sum_sequence()’ example above.  It so happens that this example
doesn't need to clean up any owned references when it detects an error.
The following example function shows some error cleanup.  First, to
remind you why you like Python, we show the equivalent Python code:

     def incr_item(dict, key):
         try:
             item = dict[key]
         except KeyError:
             item = 0
         dict[key] = item + 1

以下は対応するコードを C で完璧に書いたものです:

     int
     incr_item(PyObject *dict, PyObject *key)
     {
         /* Objects all initialized to NULL for Py_XDECREF */
         PyObject *item = NULL, *const_one = NULL, *incremented_item = NULL;
         int rv = -1; /* Return value initialized to -1 (failure) */

         item = PyObject_GetItem(dict, key);
         if (item == NULL) {
             /* Handle KeyError only: */
             if (!PyErr_ExceptionMatches(PyExc_KeyError))
                 goto error;

             /* Clear the error and use zero: */
             PyErr_Clear();
             item = PyLong_FromLong(0L);
             if (item == NULL)
                 goto error;
         }
         const_one = PyLong_FromLong(1L);
         if (const_one == NULL)
             goto error;

         incremented_item = PyNumber_Add(item, const_one);
         if (incremented_item == NULL)
             goto error;

         if (PyObject_SetItem(dict, key, incremented_item) < 0)
             goto error;
         rv = 0; /* Success */
         /* Continue with cleanup code */

      error:
         /* Cleanup code, shared by success and failure path */

         /* Use Py_XDECREF() to ignore NULL references */
         Py_XDECREF(item);
         Py_XDECREF(const_one);
         Py_XDECREF(incremented_item);

         return rv; /* -1 for error, 0 for success */
     }

なんとこの例は C で ‘goto’ 文を使うお勧めの方法まで示していますね!  この
例では、特定の例外を処理するために *note PyErr_ExceptionMatches(): 47e0.
および *note PyErr_Clear(): ffb. をどう使うかを示しています。また、所有
権を持っている参照で、値が ‘NULL’ になるかもしれないものを捨てるために
*note Py_XDECREF(): 75a. をどう使うかも示しています (関数名に ‘'X'’ が付
いていることに注意してください; *note Py_DECREF(): 53b. は ‘NULL’ 参照に
出くわすとクラッシュします)。正しく動作させるためには、所有権を持つ参照
を保持するための変数を ‘NULL’ で初期化することが重要です; 同様に、あらか
じめ戻り値を定義する際には値を ‘-1’ (失敗) で初期化しておいて、最後の関
数呼び出しまでうまくいった場合にのみ ‘0’ (成功) に設定します。


File: python.info,  Node: Python の埋め込み<2>,  Next: デバッグ版ビルド Debugging Builds,  Prev: 例外<21>,  Up: はじめに<11>

7.1.6 Python の埋め込み
-----------------------

Python インタプリタの埋め込みを行う人 (いわば拡張モジュールの書き手の対
極) が気にかけなければならない重要なタスクは、Python インタプリタの初期
化処理 (initialization)、そしておそらくは終了処理 (finalization) です。
インタプリタのほとんどの機能は、インタプリタの起動後しか使えません。

基本的な初期化処理を行う関数は *note Py_Initialize(): 87a. です。この関
数はロード済みのモジュールからなるテーブルを作成し、土台となるモジュール
*note builtins: e, *note __main__: 1, および *note sys: c3. を作成します
。また、モジュール検索パス (‘sys.path’) の初期化も行います。

*note Py_Initialize(): 87a. does not set the "script argument list"
(‘sys.argv’).  If this variable is needed by Python code that will be
executed later, setting *note PyConfig.argv: 39d. and *note
PyConfig.parse_argv: 1893. must be set: see *note Python Initialization
Configuration: 381.

ほとんどのシステムでは (特に Unix と Windows は、詳細がわずかに異なりは
しますが)、 *note Py_Initialize(): 87a. は標準の Python インタプリタ実行
形式の場所に対する推定結果に基づいて、 Python のライブラリが Python イン
タプリタ実行形式からの相対パスで見つかるという仮定の下にモジュール検索パ
スを計算します。とりわけこの検索では、シェルコマンド検索パス (環境変数
‘PATH’) 上に見つかった ‘python’ という名前の実行ファイルの置かれているデ
ィレクトリの親ディレクトリからの相対で、 ‘lib/python`X.Y'’ という名前の
ディレクトリを探します。

例えば、 Python 実行形式が ‘/usr/local/bin/python’ で見つかったとすると
、ライブラリが ‘/usr/local/lib/python`X.Y'’ にあるものと仮定します。 (実
際には、このパスは "フォールバック (fallback)" のライブラリ位置でもあり
、 ‘python’ が ‘PATH’ 上に無い場合に使われます。) ユーザは *note
PYTHONHOME: 396. を設定することでこの動作をオーバーライドしたり、 *note
PYTHONPATH: fe8. を設定して追加のディレクトリを標準モジュール検索パスの
前に挿入したりできます。

The embedding application can steer the search by setting *note
PyConfig.program_name: 39e. 'before' calling *note
Py_InitializeFromConfig(): 39f.  Note that *note PYTHONHOME: 396. still
overrides this and *note PYTHONPATH: fe8. is still inserted in front of
the standard path.  An application that requires total control has to
provide its own implementation of *note Py_GetPath(): 38d, *note
Py_GetPrefix(): 38f, *note Py_GetExecPrefix(): 38b, and *note
Py_GetProgramFullPath(): 391. (all defined in ‘Modules/getpath.c’).

たまに、 Python を初期化前の状態にもどしたいことがあります。例えば、ある
アプリケーションでは実行を最初からやりなおし (start over) させる (*note
Py_Initialize(): 87a. をもう一度呼び出させる) ようにしたいかもしれません
。あるいは、アプリケーションが Python を一旦使い終えて、Python が確保し
たメモリを解放させたいかもしれません。 *note Py_FinalizeEx(): ce3. を使
うとこうした処理を実現できます。また、関数 *note Py_IsInitialized():
47e3. は、Python が現在初期化済みの状態にある場合に真を返します。これら
の関数についてのさらなる情報は、後の章で説明します。 *note
Py_FinalizeEx(): ce3. がPythonインタプリタに確保された全てのメモリを '解
放するわけではない' ことに注意してください。例えば、拡張モジュールによっ
て確保されたメモリは、現在のところ解放する事ができません。


File: python.info,  Node: デバッグ版ビルド Debugging Builds,  Prev: Python の埋め込み<2>,  Up: はじめに<11>

7.1.7 デバッグ版ビルド (Debugging Builds)
-----------------------------------------

インタプリタと拡張モジュールに対しての追加チェックをするためのいくつかの
マクロを有効にしてPythonをビルドすることができます。これらのチェックは、
実行時に大きなオーバーヘッドを生じる傾向があります。なので、デフォルトで
は有効にされていません。

Pythonデバッグ版ビルドの全ての種類のリストが、Pythonソース配布(source
distribution)の中の ‘Misc/SpecialBuilds.txt’ にあります。参照カウントの
トレース、メモリアロケータのデバッグ、インタプリタのメインループの低レベ
ルプロファイリングが利用可能です。よく使われるビルドについてのみ、この節
の残りの部分で説明します。

 -- C のマクロ: Py_DEBUG

Compiling the interpreter with the ‘Py_DEBUG’ macro defined produces
what is generally meant by *note a debug build of Python: 1da.
‘Py_DEBUG’ is enabled in the Unix build by adding *note -with-pydebug:
3fb. to the ‘./configure’ command.  It is also implied by the presence
of the not-Python-specific ‘_DEBUG’ macro.  When ‘Py_DEBUG’ is enabled
in the Unix build, compiler optimization is disabled.

In addition to the reference count debugging described below, extra
checks are performed, see *note Python Debug Build: 1da.

‘Py_TRACE_REFS’ を宣言すると、参照トレースが有効になります (*note
configure -with-trace-refs オプション: 36e. を参照してください)。全ての
*note PyObject: 312. に二つのフィールドを追加することで、使用中のオブジ
ェクトの循環二重連結リストが管理されます。全ての割り当て(allocation)がト
レースされます。終了時に、全ての残っているオブジェクトが表示されます。
(インタラクティブモードでは、インタプリタによる文の実行のたびに表示され
ます。)

より詳しい情報については、Pythonのソース配布(source distribution)の中の
‘Misc/SpecialBuilds.txt’ を参照してください。


File: python.info,  Node: C API の安定性,  Next: 超高水準レイヤ,  Prev: はじめに<11>,  Up: Python/C API リファレンスマニュアル

7.2 C API の安定性
==================

Unless documented otherwise, Python's C API is covered by the Backwards
Compatibility Policy, PEP 387(1).  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.

CPython's Application Binary Interface (ABI) is forward- and
backwards-compatible across a minor release (if these are compiled the
same way; see *note プラットフォームで考慮すべき点: 47e8. below).  So,
code compiled for Python 3.10.0 will work on 3.10.8 and vice versa, but
will need to be compiled separately for 3.9.x and 3.11.x.

There are two tiers of C API with different stability expectations:

   - *note Unstable API: 512, may change in minor versions without a
     deprecation period.  It is marked by the ‘PyUnstable’ prefix in
     names.

   - *note Limited API: 36f, is compatible across several minor
     releases.  When *note Py_LIMITED_API: 3f7. is defined, only this
     subset is exposed from ‘Python.h’.

These are discussed in more detail below.

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 use this API, consider reaching out to CPython developers(2)
to discuss adding public API for your use case.

* Menu:

* Unstable C API::
* 安定 ABI (Stable Appliction Binary Interface): 安定 ABI Stable Appliction Binary Interface.
* プラットフォームで考慮すべき点::
* 限定版APIの内容::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0387/

   (2) https://discuss.python.org/c/core-dev/c-api/30


File: python.info,  Node: Unstable C API,  Next: 安定 ABI Stable Appliction Binary Interface,  Up: C API の安定性

7.2.1 Unstable C API
--------------------

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).

It is generally intended for specialized, low-level tools like
debuggers.

Projects that use this API are expected to follow CPython development
and spend extra effort adjusting to changes.


File: python.info,  Node: 安定 ABI Stable Appliction Binary Interface,  Next: プラットフォームで考慮すべき点,  Prev: Unstable C API,  Up: C API の安定性

7.2.2 安定 ABI (Stable Appliction Binary Interface)
---------------------------------------------------

For simplicity, this document talks about 'extensions', but the Limited
API and Stable ABI work the same way for all uses of the API – for
example, embedding Python.

* Menu:

* Limited C API::
* Stable ABI::
* APIスコープとパフォーマンスの制限::
* 制限付きAPIの注意点::


File: python.info,  Node: Limited C API,  Next: Stable ABI,  Up: 安定 ABI Stable Appliction Binary Interface

7.2.2.1 Limited C API
.....................

Python 3.2 introduced the 'Limited API', a subset of Python's C API.
Extensions that only use the Limited API can be compiled once and work
with multiple versions of Python.  Contents of the Limited API are *note
listed below: 765.

 -- C のマクロ: Py_LIMITED_API

     このマクロを ‘Python.h’ をインクルードする前に定義することで、
     Limited API のみを使用することを選択し、 Limited API バージョンを選
     択することができます。

     Define ‘Py_LIMITED_API’ to the value of *note PY_VERSION_HEX: 722.
     corresponding to the lowest Python version your extension supports.
     The extension will work without recompilation with all Python 3
     releases from the specified one onward, and can use Limited API
     introduced up to that version.

     ‘PY_VERSION_HEX’ マクロを直接使うのではなく、将来の Python のバージ
     ョンでコンパイルするときの安定性のために、最小のマイナーバージョン
     (例えば、 Python 3.10なら ‘0x030A0000’ )をハードコードします。

     また、 ‘Py_LIMITED_API’ を ‘3’ に定義することができます。これは
     ‘0x03020000’ (Python 3.2, Limited API が導入されたバージョン)と同じ
     ように動作します。


File: python.info,  Node: Stable ABI,  Next: APIスコープとパフォーマンスの制限,  Prev: Limited C API,  Up: 安定 ABI Stable Appliction Binary Interface

7.2.2.2 Stable ABI
..................

To enable this, Python provides a 'Stable ABI': a set of symbols that
will remain compatible across Python 3.x versions.

The Stable ABI contains symbols exposed in the *note Limited API: 36f,
but also other ones – for example, functions necessary to support older
versions of the Limited API.

Windows では、 Stable ABI を使用する拡張機能は、 ‘python39.dll’ のような
バージョン固有のライブラリではなく、 ‘python3.dll’ に対してリンクする必
要があります。

いくつかのプラットフォームでは、 Python は ‘abi3’ タグで名付けられた共有
ライブラリファイルを探して読み込みます(例: ‘mymodule.abi3.so’)。このよう
な拡張モジュールが Stable ABI に適合しているかどうかはチェックされません
。ユーザー(またはそのパッケージングツール)は、たとえば 3.10+ Limited API
でビルドされた拡張モジュールが、それ以下のバージョンの Python にインスト
ールされないことを確認する必要があります。

Stable ABI に含まれるすべての関数は、マクロとしてだけでなく、 Python の
共有ライブラリの関数として存在します。そのため、Cプリプロセッサを使用し
ない言語から使用することができます。


File: python.info,  Node: APIスコープとパフォーマンスの制限,  Next: 制限付きAPIの注意点,  Prev: Stable ABI,  Up: 安定 ABI Stable Appliction Binary Interface

7.2.2.3 APIスコープとパフォーマンスの制限
.........................................

Limited API の目標は、フル C API で可能なすべてのことを実現することです
が、おそらく性能上の制約があります。

例えば、 *note PyList_GetItem(): 335. は利用可能ですが、その “unsafe” マ
クロの変種 *note PyList_GET_ITEM(): 47ef. は利用できません。このマクロは
、リストオブジェクトのバージョン固有の実装の詳細に依存することができるた
め、より高速に処理することができます。

‘Py_LIMITED_API’ を定義しないと、いくつかの C API 関数がインライン化され
たり、マクロに置き換わったりします。‘Py_LIMITED_API’ を定義すると、この
インライン化が無効になり、 Python のデータ構造が改善されても安定した動作
が可能になりますが、性能が低下する可能性があります。

‘Py_LIMITED_API’ の定義を省くことで、 Limited API 拡張をバージョン固有の
ABI でコンパイルすることが可能です。これにより、その Python のバージョン
でパフォーマンスを向上させることができますが、互換性は制限されます。
‘Py_LIMITED_API’ でコンパイルすると、バージョンに依存しない拡張機能が利
用できない場合、例えば、次期 Python バージョンのプレリリースに対応した拡
張モジュールを配布することができるようになります。


File: python.info,  Node: 制限付きAPIの注意点,  Prev: APIスコープとパフォーマンスの制限,  Up: 安定 ABI Stable Appliction Binary Interface

7.2.2.4 制限付きAPIの注意点
...........................

Note that compiling with ‘Py_LIMITED_API’ is 'not' a complete guarantee
that code conforms to the *note Limited API: 36f. or the *note Stable
ABI: 47ed.  ‘Py_LIMITED_API’ only covers definitions, but an API also
includes other issues, such as expected semantics.

‘Py_LIMITED_API’ が防げない問題の1つは、 Python の下位バージョンでは無効
な引数を持つ関数を呼び出すことです。例えば、引数に ‘NULL’ を受け取る関数
を考えてみましょう。Python 3.9 では ‘NULL’ はデフォルトの挙動を選択しま
すが、Python 3.8 ではこの引数は直接使用され、 ‘NULL’ の参照外れを起こし
クラッシュします。同様の引数は、構造体のフィールドに対しても機能します。

もう一つの問題は、一部の構造体フィールドがLimited APIの一部であるにもか
かわらず、 ‘Py_LIMITED_API’ が定義されたときに現在非表示になっていないこ
とです。

これらの理由から、私たちは拡張モジュールがサポートする 'すべての' マイナ
ーな Python バージョンでテストすること、そしてできれば '最も低い' バージ
ョンでビルドすることを推奨します。

また、使用するすべての API のドキュメントを確認し、それが明示的に
Limited API の一部であるかどうかをチェックすることをお勧めします。
‘Py_LIMITED_API’ が定義されていても、技術的な理由で(あるいはバグとして意
図せず)いくつかのプライベート宣言が公開されることがあります。

Python 3.8 で ‘Py_LIMITED_API’ をコンパイルすると、その拡張モジュールは
Python 3.12 で動作しますが、必ずしも Python 3.12 で 'コンパイル' できる
とは限らないことに注意してください。特に、Limited API の一部は、 Stable
ABI が安定している限り、非推奨で削除されるかもしれません。


File: python.info,  Node: プラットフォームで考慮すべき点,  Next: 限定版APIの内容,  Prev: 安定 ABI Stable Appliction Binary Interface,  Up: C API の安定性

7.2.3 プラットフォームで考慮すべき点
------------------------------------

ABI stability depends not only on Python, but also on the compiler used,
lower-level libraries and compiler options.  For the purposes of the
*note Stable ABI: 47ed, these details define a “platform”.  They usually
depend on the OS type and processor architecture

特定のプラットフォーム上のすべての Python バージョンが安定版 ABI を破壊
しない方法でビルドされていることを保証するのは、 Python の各特定配布者の
責任です。これは ‘python.org’ や多くのサードパーティーの配布元からの
Windows と macOS のリリースの場合です。


File: python.info,  Node: 限定版APIの内容,  Prev: プラットフォームで考慮すべき点,  Up: C API の安定性

7.2.4 限定版APIの内容
---------------------

Currently, the *note Limited API: 36f. includes the following items:

   * *note PY_VECTORCALL_ARGUMENTS_OFFSET: 529.

   * *note PyAIter_Check(): 47f3.

   * *note PyArg_Parse(): 194f.

   * *note PyArg_ParseTuple(): 53d.

   * *note PyArg_ParseTupleAndKeywords(): 35c.

   * *note PyArg_UnpackTuple(): 14b1.

   * *note PyArg_VaParse(): 47f4.

   * *note PyArg_VaParseTupleAndKeywords(): 35d.

   * *note PyArg_ValidateKeywordArguments(): 47f5.

   * ‘PyBaseObject_Type’

   * *note PyBool_FromLong(): 47f6.

   * *note PyBool_Type: 47f7.

   * *note PyBuffer_FillContiguousStrides(): 72a.

   * *note PyBuffer_FillInfo(): 72b.

   * *note PyBuffer_FromContiguous(): 727.

   * *note PyBuffer_GetPointer(): 724.

   * *note PyBuffer_IsContiguous(): 729.

   * *note PyBuffer_Release(): 374.

   * *note PyBuffer_SizeFromFormat(): 725.

   * *note PyBuffer_ToContiguous(): 726.

   * ‘PyByteArrayIter_Type’

   * *note PyByteArray_AsString(): 47f8.

   * *note PyByteArray_Concat(): 47f9.

   * *note PyByteArray_FromObject(): 135e.

   * *note PyByteArray_FromStringAndSize(): 135f.

   * *note PyByteArray_Resize(): 47fa.

   * *note PyByteArray_Size(): 47fb.

   * *note PyByteArray_Type: 47fc.

   * ‘PyBytesIter_Type’

   * *note PyBytes_AsString(): 854.

   * *note PyBytes_AsStringAndSize(): 47fd.

   * *note PyBytes_Concat(): 47fe.

   * *note PyBytes_ConcatAndDel(): 47ff.

   * ‘PyBytes_DecodeEscape()’

   * *note PyBytes_FromFormat(): 1994.

   * *note PyBytes_FromFormatV(): 4800.

   * *note PyBytes_FromObject(): 4801.

   * *note PyBytes_FromString(): 4802.

   * *note PyBytes_FromStringAndSize(): 135d.

   * ‘PyBytes_Repr()’

   * *note PyBytes_Size(): 4803.

   * *note PyBytes_Type: 4804.

   * *note PyCFunction: 141c.

   * *note PyCFunctionFast: 4805.

   * *note PyCFunctionFastWithKeywords: 4806.

   * *note PyCFunctionWithKeywords: 4807.

   * ‘PyCFunction_GetFlags()’

   * ‘PyCFunction_GetFunction()’

   * ‘PyCFunction_GetSelf()’

   * *note PyCFunction_New(): 185e.

   * *note PyCFunction_NewEx(): 18f8.

   * ‘PyCFunction_Type’

   * *note PyCMethod_New(): 1858.

   * *note PyCallIter_New(): 4808.

   * *note PyCallIter_Type: 4809.

   * *note PyCallable_Check(): 480a.

   * *note PyCapsule_Destructor: 480b.

   * *note PyCapsule_GetContext(): 480c.

   * *note PyCapsule_GetDestructor(): 480d.

   * *note PyCapsule_GetName(): 480e.

   * *note PyCapsule_GetPointer(): 480f.

   * *note PyCapsule_Import(): 17d8.

   * *note PyCapsule_IsValid(): 1324.

   * *note PyCapsule_New(): 476f.

   * *note PyCapsule_SetContext(): 4810.

   * *note PyCapsule_SetDestructor(): 4811.

   * *note PyCapsule_SetName(): 4812.

   * *note PyCapsule_SetPointer(): 4813.

   * ‘PyCapsule_Type’

   * ‘PyClassMethodDescr_Type’

   * *note PyCodec_BackslashReplaceErrors(): 4814.

   * *note PyCodec_Decode(): 3d8.

   * *note PyCodec_Decoder(): 4815.

   * *note PyCodec_Encode(): 3d9.

   * *note PyCodec_Encoder(): 4816.

   * *note PyCodec_IgnoreErrors(): 4817.

   * *note PyCodec_IncrementalDecoder(): 4818.

   * *note PyCodec_IncrementalEncoder(): 4819.

   * *note PyCodec_KnownEncoding(): 481a.

   * *note PyCodec_LookupError(): 481b.

   * *note PyCodec_NameReplaceErrors(): e78.

   * *note PyCodec_Register(): 481c.

   * *note PyCodec_RegisterError(): 481d.

   * *note PyCodec_ReplaceErrors(): 481e.

   * *note PyCodec_StreamReader(): 481f.

   * *note PyCodec_StreamWriter(): 4820.

   * *note PyCodec_StrictErrors(): 4821.

   * *note PyCodec_Unregister(): 864.

   * *note PyCodec_XMLCharRefReplaceErrors(): 4822.

   * *note PyComplex_FromDoubles(): 4823.

   * *note PyComplex_ImagAsDouble(): 15fc.

   * *note PyComplex_RealAsDouble(): 15fb.

   * *note PyComplex_Type: 4824.

   * *note PyDescr_NewClassMethod(): 4825.

   * *note PyDescr_NewGetSet(): 4826.

   * *note PyDescr_NewMember(): 4827.

   * *note PyDescr_NewMethod(): 18f7.

   * ‘PyDictItems_Type’

   * ‘PyDictIterItem_Type’

   * ‘PyDictIterKey_Type’

   * ‘PyDictIterValue_Type’

   * ‘PyDictKeys_Type’

   * *note PyDictProxy_New(): 4828.

   * ‘PyDictProxy_Type’

   * ‘PyDictRevIterItem_Type’

   * ‘PyDictRevIterKey_Type’

   * ‘PyDictRevIterValue_Type’

   * ‘PyDictValues_Type’

   * *note PyDict_Clear(): 4829.

   * *note PyDict_Contains(): 311.

   * *note PyDict_Copy(): 3f9.

   * *note PyDict_DelItem(): 482a.

   * *note PyDict_DelItemString(): 482b.

   * *note PyDict_GetItem(): 360.

   * *note PyDict_GetItemRef(): 313.

   * *note PyDict_GetItemString(): 361.

   * *note PyDict_GetItemStringRef(): 314.

   * *note PyDict_GetItemWithError(): 315.

   * *note PyDict_Items(): 482c.

   * *note PyDict_Keys(): 482d.

   * *note PyDict_Merge(): 482e.

   * *note PyDict_MergeFromSeq2(): 482f.

   * *note PyDict_New(): 4830.

   * *note PyDict_Next(): 1575.

   * *note PyDict_SetItem(): 4766.

   * *note PyDict_SetItemString(): 1563.

   * *note PyDict_Size(): 4831.

   * *note PyDict_Type: 4832.

   * *note PyDict_Update(): 4833.

   * *note PyDict_Values(): 4834.

   * ‘PyEllipsis_Type’

   * ‘PyEnum_Type’

   * *note PyErr_BadArgument(): 4835.

   * *note PyErr_BadInternalCall(): 4836.

   * *note PyErr_CheckSignals(): 433.

   * *note PyErr_Clear(): ffb.

   * ‘PyErr_Display()’

   * *note PyErr_DisplayException(): 3db.

   * *note PyErr_ExceptionMatches(): 47e0.

   * *note PyErr_Fetch(): 3cc.

   * *note PyErr_Format(): e7a.

   * *note PyErr_FormatV(): e79.

   * *note PyErr_GetExcInfo(): 73d.

   * *note PyErr_GetHandledException(): 73a.

   * *note PyErr_GetRaisedException(): 3cd.

   * *note PyErr_GivenExceptionMatches(): 4837.

   * *note PyErr_NewException(): 123b.

   * *note PyErr_NewExceptionWithDoc(): 123a.

   * *note PyErr_NoMemory(): 4749.

   * *note PyErr_NormalizeException(): 3ce.

   * *note PyErr_Occurred(): 185c.

   * *note PyErr_Print(): 18af.

   * *note PyErr_PrintEx(): 4838.

   * ‘PyErr_ProgramText()’

   * *note PyErr_ResourceWarning(): ce5.

   * *note PyErr_Restore(): 3cf.

   * *note PyErr_SetExcFromWindowsErr(): 4839.

   * *note PyErr_SetExcFromWindowsErrWithFilename(): 167e.

   * *note PyErr_SetExcFromWindowsErrWithFilenameObject(): 483a.

   * *note PyErr_SetExcFromWindowsErrWithFilenameObjects(): 483b.

   * *note PyErr_SetExcInfo(): 73c.

   * *note PyErr_SetFromErrno(): 4748.

   * *note PyErr_SetFromErrnoWithFilename(): 167d.

   * *note PyErr_SetFromErrnoWithFilenameObject(): 483c.

   * *note PyErr_SetFromErrnoWithFilenameObjects(): 483d.

   * *note PyErr_SetFromWindowsErr(): 483e.

   * *note PyErr_SetFromWindowsErrWithFilename(): 167f.

   * *note PyErr_SetHandledException(): 73b.

   * *note PyErr_SetImportError(): d0c.

   * *note PyErr_SetImportErrorSubclass(): ce4.

   * *note PyErr_SetInterrupt(): 483f.

   * *note PyErr_SetInterruptEx(): 86b.

   * *note PyErr_SetNone(): 4840.

   * *note PyErr_SetObject(): 547.

   * *note PyErr_SetRaisedException(): 3d0.

   * *note PyErr_SetString(): 548.

   * *note PyErr_SyntaxLocation(): 4841.

   * *note PyErr_SyntaxLocationEx(): 4842.

   * *note PyErr_WarnEx(): 13f2.

   * *note PyErr_WarnExplicit(): 1686.

   * *note PyErr_WarnFormat(): 4843.

   * *note PyErr_WriteUnraisable(): 328.

   * *note PyEval_AcquireThread(): 384.

   * *note PyEval_EvalCode(): 853.

   * *note PyEval_EvalCodeEx(): 16d4.

   * *note PyEval_EvalFrame(): 4844.

   * *note PyEval_EvalFrameEx(): ff8.

   * *note PyEval_GetBuiltins(): 32a.

   * *note PyEval_GetFrame(): 1727.

   * *note PyEval_GetFrameBuiltins(): 329.

   * *note PyEval_GetFrameGlobals(): 32b.

   * *note PyEval_GetFrameLocals(): 32d.

   * *note PyEval_GetFuncDesc(): 4845.

   * *note PyEval_GetFuncName(): 4846.

   * *note PyEval_GetGlobals(): 32c.

   * *note PyEval_GetLocals(): 32e.

   * *note PyEval_InitThreads(): 15a5.

   * *note PyEval_ReleaseThread(): 4847.

   * *note PyEval_RestoreThread(): 383.

   * *note PyEval_SaveThread(): 382.

   * ‘PyExc_ArithmeticError’

   * ‘PyExc_AssertionError’

   * ‘PyExc_AttributeError’

   * ‘PyExc_BaseException’

   * ‘PyExc_BaseExceptionGroup’

   * ‘PyExc_BlockingIOError’

   * ‘PyExc_BrokenPipeError’

   * ‘PyExc_BufferError’

   * ‘PyExc_BytesWarning’

   * ‘PyExc_ChildProcessError’

   * ‘PyExc_ConnectionAbortedError’

   * ‘PyExc_ConnectionError’

   * ‘PyExc_ConnectionRefusedError’

   * ‘PyExc_ConnectionResetError’

   * ‘PyExc_DeprecationWarning’

   * ‘PyExc_EOFError’

   * ‘PyExc_EncodingWarning’

   * ‘PyExc_EnvironmentError’

   * ‘PyExc_Exception’

   * ‘PyExc_FileExistsError’

   * ‘PyExc_FileNotFoundError’

   * ‘PyExc_FloatingPointError’

   * ‘PyExc_FutureWarning’

   * ‘PyExc_GeneratorExit’

   * ‘PyExc_IOError’

   * ‘PyExc_ImportError’

   * ‘PyExc_ImportWarning’

   * ‘PyExc_IndentationError’

   * ‘PyExc_IndexError’

   * ‘PyExc_InterruptedError’

   * ‘PyExc_IsADirectoryError’

   * ‘PyExc_KeyError’

   * ‘PyExc_KeyboardInterrupt’

   * ‘PyExc_LookupError’

   * ‘PyExc_MemoryError’

   * ‘PyExc_ModuleNotFoundError’

   * ‘PyExc_NameError’

   * ‘PyExc_NotADirectoryError’

   * ‘PyExc_NotImplementedError’

   * ‘PyExc_OSError’

   * ‘PyExc_OverflowError’

   * ‘PyExc_PendingDeprecationWarning’

   * ‘PyExc_PermissionError’

   * ‘PyExc_ProcessLookupError’

   * ‘PyExc_RecursionError’

   * ‘PyExc_ReferenceError’

   * ‘PyExc_ResourceWarning’

   * ‘PyExc_RuntimeError’

   * ‘PyExc_RuntimeWarning’

   * ‘PyExc_StopAsyncIteration’

   * ‘PyExc_StopIteration’

   * ‘PyExc_SyntaxError’

   * ‘PyExc_SyntaxWarning’

   * ‘PyExc_SystemError’

   * ‘PyExc_SystemExit’

   * ‘PyExc_TabError’

   * ‘PyExc_TimeoutError’

   * ‘PyExc_TypeError’

   * ‘PyExc_UnboundLocalError’

   * ‘PyExc_UnicodeDecodeError’

   * ‘PyExc_UnicodeEncodeError’

   * ‘PyExc_UnicodeError’

   * ‘PyExc_UnicodeTranslateError’

   * ‘PyExc_UnicodeWarning’

   * ‘PyExc_UserWarning’

   * ‘PyExc_ValueError’

   * ‘PyExc_Warning’

   * ‘PyExc_WindowsError’

   * ‘PyExc_ZeroDivisionError’

   * ‘PyExceptionClass_Name()’

   * *note PyException_GetArgs(): 536.

   * *note PyException_GetCause(): 4848.

   * *note PyException_GetContext(): 4849.

   * *note PyException_GetTraceback(): 484a.

   * *note PyException_SetArgs(): 537.

   * *note PyException_SetCause(): 484b.

   * *note PyException_SetContext(): 484c.

   * *note PyException_SetTraceback(): 1955.

   * *note PyFile_FromFd(): 484d.

   * *note PyFile_GetLine(): 484e.

   * *note PyFile_WriteObject(): 484f.

   * *note PyFile_WriteString(): 4850.

   * ‘PyFilter_Type’

   * *note PyFloat_AsDouble(): a37.

   * *note PyFloat_FromDouble(): 4851.

   * *note PyFloat_FromString(): 4852.

   * *note PyFloat_GetInfo(): 1398.

   * *note PyFloat_GetMax(): 1396.

   * *note PyFloat_GetMin(): 1397.

   * *note PyFloat_Type: 4853.

   * *note PyFrameObject: 754.

   * *note PyFrame_GetCode(): 755.

   * *note PyFrame_GetLineNumber(): 756.

   * *note PyFrozenSet_New(): 13ed.

   * *note PyFrozenSet_Type: 4854.

   * *note PyGC_Collect(): 95c.

   * *note PyGC_Disable(): 872.

   * *note PyGC_Enable(): 871.

   * *note PyGC_IsEnabled(): 873.

   * *note PyGILState_Ensure(): 385.

   * *note PyGILState_GetThisThreadState(): 4855.

   * *note PyGILState_Release(): 386.

   * ‘PyGILState_STATE’

   * *note PyGetSetDef: b86.

   * ‘PyGetSetDescr_Type’

   * *note PyImport_AddModule(): 332.

   * *note PyImport_AddModuleObject(): 4856.

   * *note PyImport_AddModuleRef(): 331.

   * *note PyImport_AppendInittab(): 170e.

   * *note PyImport_ExecCodeModule(): 4857.

   * *note PyImport_ExecCodeModuleEx(): 4858.

   * *note PyImport_ExecCodeModuleObject(): 4859.

   * *note PyImport_ExecCodeModuleWithPathnames(): 485a.

   * *note PyImport_GetImporter(): 167c.

   * *note PyImport_GetMagicNumber(): 1174.

   * *note PyImport_GetMagicTag(): 485b.

   * *note PyImport_GetModule(): b81.

   * *note PyImport_GetModuleDict(): 485c.

   * *note PyImport_Import(): 13a4.

   * *note PyImport_ImportFrozenModule(): 485d.

   * *note PyImport_ImportFrozenModuleObject(): 485e.

   * *note PyImport_ImportModule(): 398.

   * *note PyImport_ImportModuleLevel(): 1175.

   * *note PyImport_ImportModuleLevelObject(): 485f.

   * *note PyImport_ImportModuleNoBlock(): 397.

   * *note PyImport_ReloadModule(): 4860.

   * *note PyIndex_Check(): 958.

   * *note PyInterpreterState: 88b.

   * *note PyInterpreterState_Clear(): 405d.

   * *note PyInterpreterState_Delete(): 4861.

   * *note PyInterpreterState_Get(): 387.

   * *note PyInterpreterState_GetDict(): 4862.

   * *note PyInterpreterState_GetID(): b94.

   * *note PyInterpreterState_New(): 405e.

   * *note PyIter_Check(): 185f.

   * *note PyIter_Next(): 4863.

   * *note PyIter_Send(): 865.

   * ‘PyListIter_Type’

   * ‘PyListRevIter_Type’

   * *note PyList_Append(): 4864.

   * *note PyList_AsTuple(): 4865.

   * *note PyList_GetItem(): 335.

   * *note PyList_GetItemRef(): 334.

   * *note PyList_GetSlice(): 4866.

   * *note PyList_Insert(): 4867.

   * *note PyList_New(): 47db.

   * *note PyList_Reverse(): 4868.

   * *note PyList_SetItem(): 4765.

   * *note PyList_SetSlice(): 4869.

   * *note PyList_Size(): 13c1.

   * *note PyList_Sort(): 486a.

   * *note PyList_Type: 4787.

   * *note PyLongObject: 554.

   * ‘PyLongRangeIter_Type’

   * *note PyLong_AsDouble(): 486b.

   * *note PyLong_AsInt(): 338.

   * *note PyLong_AsLong(): 339.

   * *note PyLong_AsLongAndOverflow(): 1237.

   * *note PyLong_AsLongLong(): 486c.

   * *note PyLong_AsLongLongAndOverflow(): 1238.

   * *note PyLong_AsSize_t(): 486d.

   * *note PyLong_AsSsize_t(): 486e.

   * *note PyLong_AsUnsignedLong(): 486f.

   * *note PyLong_AsUnsignedLongLong(): 1265.

   * *note PyLong_AsUnsignedLongLongMask(): 1951.

   * *note PyLong_AsUnsignedLongMask(): 4870.

   * *note PyLong_AsVoidPtr(): 4871.

   * *note PyLong_FromDouble(): 910.

   * *note PyLong_FromLong(): 17a4.

   * *note PyLong_FromLongLong(): 17a5.

   * *note PyLong_FromSize_t(): 192e.

   * *note PyLong_FromSsize_t(): 4872.

   * *note PyLong_FromString(): 4873.

   * *note PyLong_FromUnsignedLong(): 192c.

   * *note PyLong_FromUnsignedLongLong(): 192d.

   * *note PyLong_FromVoidPtr(): 4874.

   * *note PyLong_GetInfo(): 4875.

   * *note PyLong_Type: 4876.

   * ‘PyMap_Type’

   * *note PyMapping_Check(): 4877.

   * *note PyMapping_GetItemString(): 321.

   * *note PyMapping_GetOptionalItem(): 31e.

   * *note PyMapping_GetOptionalItemString(): 31f.

   * *note PyMapping_HasKey(): 358.

   * *note PyMapping_HasKeyString(): 35a.

   * *note PyMapping_HasKeyStringWithError(): 359.

   * *note PyMapping_HasKeyWithError(): 357.

   * *note PyMapping_Items(): b8c.

   * *note PyMapping_Keys(): b8a.

   * *note PyMapping_Length(): 4878.

   * *note PyMapping_SetItemString(): 4879.

   * *note PyMapping_Size(): 19c1.

   * *note PyMapping_Values(): b8b.

   * *note PyMem_Calloc(): e76.

   * *note PyMem_Free(): 13ea.

   * *note PyMem_Malloc(): c33.

   * *note PyMem_RawCalloc(): 36a.

   * *note PyMem_RawFree(): 36c.

   * *note PyMem_RawMalloc(): 369.

   * *note PyMem_RawRealloc(): 36b.

   * *note PyMem_Realloc(): ffc.

   * *note PyMemberDef: 51a.

   * ‘PyMemberDescr_Type’

   * *note PyMember_GetOne(): 559.

   * *note PyMember_SetOne(): 55a.

   * *note PyMemoryView_FromBuffer(): 72c.

   * *note PyMemoryView_FromMemory(): 1143.

   * *note PyMemoryView_FromObject(): 487a.

   * *note PyMemoryView_GetContiguous(): 487b.

   * ‘PyMemoryView_Type’

   * *note PyMethodDef: 1480.

   * ‘PyMethodDescr_Type’

   * *note PyModuleDef: 94b.

   * ‘PyModuleDef_Base’

   * *note PyModuleDef_Init(): 487c.

   * ‘PyModuleDef_Type’

   * *note PyModule_Add(): 33d.

   * *note PyModule_AddFunctions(): 487d.

   * *note PyModule_AddIntConstant(): 14e4.

   * *note PyModule_AddObject(): 33f.

   * *note PyModule_AddObjectRef(): 33e.

   * *note PyModule_AddStringConstant(): 14e5.

   * *note PyModule_AddType(): 943.

   * *note PyModule_Create2(): 487e.

   * *note PyModule_ExecDef(): e7d.

   * *note PyModule_FromDefAndSpec2(): e7c.

   * *note PyModule_GetDef(): 487f.

   * *note PyModule_GetDict(): 4880.

   * *note PyModule_GetFilename(): 3d1.

   * *note PyModule_GetFilenameObject(): 3d2.

   * *note PyModule_GetName(): 4881.

   * *note PyModule_GetNameObject(): 4882.

   * *note PyModule_GetState(): 94e.

   * *note PyModule_New(): 4883.

   * *note PyModule_NewObject(): 4884.

   * *note PyModule_SetDocString(): 4885.

   * *note PyModule_Type: 4886.

   * *note PyNumber_Absolute(): 4887.

   * *note PyNumber_Add(): 4888.

   * *note PyNumber_And(): 4889.

   * *note PyNumber_AsSsize_t(): 488a.

   * *note PyNumber_Check(): a34.

   * *note PyNumber_Divmod(): 488b.

   * *note PyNumber_Float(): a36.

   * *note PyNumber_FloorDivide(): 488c.

   * *note PyNumber_InPlaceAdd(): 488d.

   * *note PyNumber_InPlaceAnd(): 488e.

   * *note PyNumber_InPlaceFloorDivide(): 488f.

   * *note PyNumber_InPlaceLshift(): 4890.

   * *note PyNumber_InPlaceMatrixMultiply(): e7f.

   * *note PyNumber_InPlaceMultiply(): 4891.

   * *note PyNumber_InPlaceOr(): 4892.

   * *note PyNumber_InPlacePower(): 4893.

   * *note PyNumber_InPlaceRemainder(): 4894.

   * *note PyNumber_InPlaceRshift(): 4895.

   * *note PyNumber_InPlaceSubtract(): 4896.

   * *note PyNumber_InPlaceTrueDivide(): 4897.

   * *note PyNumber_InPlaceXor(): 4898.

   * *note PyNumber_Index(): 860.

   * *note PyNumber_Invert(): 4899.

   * *note PyNumber_Long(): a35.

   * *note PyNumber_Lshift(): 489a.

   * *note PyNumber_MatrixMultiply(): e7e.

   * *note PyNumber_Multiply(): 489b.

   * *note PyNumber_Negative(): 489c.

   * *note PyNumber_Or(): 489d.

   * *note PyNumber_Positive(): 489e.

   * *note PyNumber_Power(): 489f.

   * *note PyNumber_Remainder(): 48a0.

   * *note PyNumber_Rshift(): 48a1.

   * *note PyNumber_Subtract(): 48a2.

   * *note PyNumber_ToBase(): 1755.

   * *note PyNumber_TrueDivide(): 48a3.

   * *note PyNumber_Xor(): 48a4.

   * *note PyOS_AfterFork(): 3d3.

   * *note PyOS_AfterFork_Child(): 3d4.

   * *note PyOS_AfterFork_Parent(): b8e.

   * *note PyOS_BeforeFork(): b8d.

   * *note PyOS_CheckStack(): 1781.

   * *note PyOS_FSPath(): ce6.

   * *note PyOS_InputHook: 551.

   * ‘PyOS_InterruptOccurred()’

   * *note PyOS_double_to_string(): 48a5.

   * *note PyOS_getsig(): 14e6.

   * ‘PyOS_mystricmp()’

   * ‘PyOS_mystrnicmp()’

   * *note PyOS_setsig(): 14e7.

   * *note PyOS_sighandler_t: 48a6.

   * *note PyOS_snprintf(): 14b4.

   * *note PyOS_string_to_double(): 1266.

   * *note PyOS_strtol(): 48a7.

   * *note PyOS_strtoul(): 48a8.

   * *note PyOS_vsnprintf(): 14b5.

   * *note PyObject: 312.

   * *note PyObject.ob_refcnt: 86c.

   * *note PyObject.ob_type: 4778.

   * *note PyObject_ASCII(): 48a9.

   * *note PyObject_AsFileDescriptor(): 48aa.

   * *note PyObject_Bytes(): 48ab.

   * *note PyObject_Call(): 376.

   * *note PyObject_CallFunction(): 378.

   * *note PyObject_CallFunctionObjArgs(): 48ac.

   * *note PyObject_CallMethod(): 379.

   * *note PyObject_CallMethodObjArgs(): 1968.

   * *note PyObject_CallNoArgs(): 375.

   * *note PyObject_CallObject(): 4758.

   * *note PyObject_Calloc(): e77.

   * *note PyObject_CheckBuffer(): 372.

   * *note PyObject_ClearWeakRefs(): 542.

   * *note PyObject_CopyData(): 728.

   * *note PyObject_DelAttr(): 1683.

   * *note PyObject_DelAttrString(): 1565.

   * *note PyObject_DelItem(): 48ad.

   * ‘PyObject_DelItemString()’

   * *note PyObject_Dir(): 48ae.

   * *note PyObject_Format(): 48af.

   * *note PyObject_Free(): c34.

   * *note PyObject_GC_Del(): 14ae.

   * *note PyObject_GC_IsFinalized(): 945.

   * *note PyObject_GC_IsTracked(): 944.

   * *note PyObject_GC_Track(): 14af.

   * *note PyObject_GC_UnTrack(): 14b0.

   * *note PyObject_GenericGetAttr(): 48b0.

   * *note PyObject_GenericGetDict(): 18a4.

   * *note PyObject_GenericSetAttr(): 48b1.

   * *note PyObject_GenericSetDict(): 48b2.

   * *note PyObject_GetAIter(): 48b3.

   * *note PyObject_GetAttr(): 324.

   * *note PyObject_GetAttrString(): 325.

   * *note PyObject_GetBuffer(): 373.

   * *note PyObject_GetItem(): 320.

   * *note PyObject_GetIter(): 48b4.

   * *note PyObject_GetOptionalAttr(): 322.

   * *note PyObject_GetOptionalAttrString(): 323.

   * *note PyObject_GetTypeData(): 514.

   * *note PyObject_HasAttr(): 354.

   * *note PyObject_HasAttrString(): 356.

   * *note PyObject_HasAttrStringWithError(): 355.

   * *note PyObject_HasAttrWithError(): 353.

   * *note PyObject_Hash(): 3dc.

   * *note PyObject_HashNotImplemented(): 136e.

   * *note PyObject_Init(): a38.

   * *note PyObject_InitVar(): 18bf.

   * *note PyObject_IsInstance(): e6f.

   * *note PyObject_IsSubclass(): e70.

   * *note PyObject_IsTrue(): 48b5.

   * *note PyObject_Length(): 48b6.

   * *note PyObject_Malloc(): c36.

   * *note PyObject_Not(): 48b7.

   * *note PyObject_Realloc(): 13eb.

   * *note PyObject_Repr(): ff9.

   * *note PyObject_RichCompare(): 479c.

   * *note PyObject_RichCompareBool(): 190e.

   * ‘PyObject_SelfIter()’

   * *note PyObject_SetAttr(): 48b8.

   * *note PyObject_SetAttrString(): 1564.

   * *note PyObject_SetItem(): 47da.

   * *note PyObject_Size(): 48b9.

   * *note PyObject_Str(): ffa.

   * *note PyObject_Type(): 48ba.

   * *note PyObject_Vectorcall(): 527.

   * *note PyObject_VectorcallMethod(): 528.

   * *note PyProperty_Type: 48bb.

   * ‘PyRangeIter_Type’

   * ‘PyRange_Type’

   * ‘PyReversed_Type’

   * *note PySeqIter_New(): 48bc.

   * *note PySeqIter_Type: 48bd.

   * *note PySequence_Check(): 48be.

   * *note PySequence_Concat(): 48bf.

   * *note PySequence_Contains(): 48c0.

   * *note PySequence_Count(): 48c1.

   * *note PySequence_DelItem(): 19c0.

   * *note PySequence_DelSlice(): 48c2.

   * *note PySequence_Fast(): 48c3.

   * *note PySequence_GetItem(): 19be.

   * *note PySequence_GetSlice(): 48c4.

   * ‘PySequence_In()’

   * *note PySequence_InPlaceConcat(): 48c5.

   * *note PySequence_InPlaceRepeat(): 48c6.

   * *note PySequence_Index(): 48c7.

   * *note PySequence_Length(): 48c8.

   * *note PySequence_List(): 48c9.

   * *note PySequence_Repeat(): 48ca.

   * *note PySequence_SetItem(): 19bf.

   * *note PySequence_SetSlice(): 48cb.

   * *note PySequence_Size(): 19bd.

   * *note PySequence_Tuple(): 48cc.

   * ‘PySetIter_Type’

   * *note PySet_Add(): 13ee.

   * *note PySet_Clear(): 48cd.

   * *note PySet_Contains(): 13f0.

   * *note PySet_Discard(): 13ef.

   * *note PySet_New(): 13ec.

   * *note PySet_Pop(): 48ce.

   * *note PySet_Size(): 13f1.

   * *note PySet_Type: 48cf.

   * *note PySlice_AdjustIndices(): 3d7.

   * *note PySlice_GetIndices(): 48d0.

   * *note PySlice_GetIndicesEx(): 3d5.

   * *note PySlice_New(): 48d1.

   * *note PySlice_Type: 48d2.

   * *note PySlice_Unpack(): 3d6.

   * *note PyState_AddModule(): 48d3.

   * *note PyState_FindModule(): 48d4.

   * *note PyState_RemoveModule(): 48d5.

   * *note PyStructSequence_Desc: b88.

   * *note PyStructSequence_Field: b87.

   * *note PyStructSequence_GetItem(): 48d6.

   * *note PyStructSequence_New(): 48d7.

   * *note PyStructSequence_NewType(): 48d8.

   * *note PyStructSequence_SetItem(): 48d9.

   * *note PyStructSequence_UnnamedField: 950.

   * ‘PySuper_Type’

   * *note PySys_Audit(): 348.

   * *note PySys_AuditTuple(): 347.

   * *note PySys_FormatStderr(): 48da.

   * *note PySys_FormatStdout(): 48db.

   * *note PySys_GetObject(): 362.

   * *note PySys_GetXOptions(): 48dc.

   * *note PySys_ResetWarnOptions(): 389.

   * *note PySys_SetArgv(): 15a4.

   * *note PySys_SetArgvEx(): 15a3.

   * *note PySys_SetObject(): 48dd.

   * *note PySys_WriteStderr(): 48de.

   * *note PySys_WriteStdout(): 48df.

   * *note PyThreadState: 758.

   * *note PyThreadState_Clear(): 1585.

   * *note PyThreadState_Delete(): 190b.

   * *note PyThreadState_Get(): 34b.

   * *note PyThreadState_GetDict(): 48e0.

   * *note PyThreadState_GetFrame(): 759.

   * *note PyThreadState_GetID(): 940.

   * *note PyThreadState_GetInterpreter(): 93f.

   * *note PyThreadState_New(): 48e1.

   * *note PyThreadState_SetAsyncExc(): b92.

   * *note PyThreadState_Swap(): 48e2.

   * ‘PyThread_GetInfo()’

   * *note PyThread_ReInitTLS(): 3e7.

   * ‘PyThread_acquire_lock()’

   * ‘PyThread_acquire_lock_timed()’

   * ‘PyThread_allocate_lock()’

   * *note PyThread_create_key(): 3dd.

   * *note PyThread_delete_key(): 3df.

   * *note PyThread_delete_key_value(): 3e5.

   * ‘PyThread_exit_thread()’

   * ‘PyThread_free_lock()’

   * *note PyThread_get_key_value(): 3e3.

   * ‘PyThread_get_stacksize()’

   * ‘PyThread_get_thread_ident()’

   * ‘PyThread_get_thread_native_id()’

   * ‘PyThread_init_thread()’

   * ‘PyThread_release_lock()’

   * *note PyThread_set_key_value(): 3e1.

   * ‘PyThread_set_stacksize()’

   * ‘PyThread_start_new_thread()’

   * *note PyThread_tss_alloc(): 3de.

   * *note PyThread_tss_create(): 48e3.

   * *note PyThread_tss_delete(): 3e6.

   * *note PyThread_tss_free(): 3e0.

   * *note PyThread_tss_get(): 3e4.

   * *note PyThread_tss_is_created(): 48e4.

   * *note PyThread_tss_set(): 3e2.

   * ‘PyTraceBack_Here()’

   * ‘PyTraceBack_Print()’

   * ‘PyTraceBack_Type’

   * ‘PyTupleIter_Type’

   * *note PyTuple_GetItem(): 4763.

   * *note PyTuple_GetSlice(): 48e5.

   * *note PyTuple_New(): 377.

   * *note PyTuple_Pack(): 48e6.

   * *note PyTuple_SetItem(): 4764.

   * *note PyTuple_Size(): 48e7.

   * *note PyTuple_Type: 48e8.

   * *note PyTypeObject: a73.

   * *note PyType_ClearCache(): 48e9.

   * *note PyType_FromMetaclass(): 51b.

   * *note PyType_FromModuleAndSpec(): 51c.

   * *note PyType_FromSpec(): 549.

   * *note PyType_FromSpecWithBases(): 54a.

   * *note PyType_GenericAlloc(): a39.

   * *note PyType_GenericNew(): 4777.

   * *note PyType_GetFlags(): 18be.

   * *note PyType_GetFullyQualifiedName(): 34c.

   * *note PyType_GetModule(): 93c.

   * *note PyType_GetModuleByDef(): 36d.

   * *note PyType_GetModuleName(): 34e.

   * *note PyType_GetModuleState(): 93d.

   * *note PyType_GetName(): 71d.

   * *note PyType_GetQualName(): 71e.

   * *note PyType_GetSlot(): 869.

   * *note PyType_GetTypeDataSize(): 515.

   * *note PyType_IsSubtype(): 48ea.

   * *note PyType_Modified(): 175d.

   * *note PyType_Ready(): 747.

   * *note PyType_Slot: 48eb.

   * *note PyType_Spec: 1681.

   * *note PyType_Type: 518.

   * *note PyUnicodeDecodeError_Create(): 48ec.

   * *note PyUnicodeDecodeError_GetEncoding(): 48ed.

   * *note PyUnicodeDecodeError_GetEnd(): 48ee.

   * *note PyUnicodeDecodeError_GetObject(): 48ef.

   * *note PyUnicodeDecodeError_GetReason(): 48f0.

   * *note PyUnicodeDecodeError_GetStart(): 48f1.

   * *note PyUnicodeDecodeError_SetEnd(): 48f2.

   * *note PyUnicodeDecodeError_SetReason(): 48f3.

   * *note PyUnicodeDecodeError_SetStart(): 48f4.

   * *note PyUnicodeEncodeError_GetEncoding(): 48f5.

   * *note PyUnicodeEncodeError_GetEnd(): 48f6.

   * *note PyUnicodeEncodeError_GetObject(): 48f7.

   * *note PyUnicodeEncodeError_GetReason(): 48f8.

   * *note PyUnicodeEncodeError_GetStart(): 48f9.

   * *note PyUnicodeEncodeError_SetEnd(): 48fa.

   * *note PyUnicodeEncodeError_SetReason(): 48fb.

   * *note PyUnicodeEncodeError_SetStart(): 48fc.

   * ‘PyUnicodeIter_Type’

   * *note PyUnicodeTranslateError_GetEnd(): 48fd.

   * *note PyUnicodeTranslateError_GetObject(): 48fe.

   * *note PyUnicodeTranslateError_GetReason(): 48ff.

   * *note PyUnicodeTranslateError_GetStart(): 4900.

   * *note PyUnicodeTranslateError_SetEnd(): 4901.

   * *note PyUnicodeTranslateError_SetReason(): 4902.

   * *note PyUnicodeTranslateError_SetStart(): 4903.

   * ‘PyUnicode_Append()’

   * ‘PyUnicode_AppendAndDel()’

   * *note PyUnicode_AsASCIIString(): 1165.

   * *note PyUnicode_AsCharmapString(): 4904.

   * ‘PyUnicode_AsDecodedObject()’

   * ‘PyUnicode_AsDecodedUnicode()’

   * ‘PyUnicode_AsEncodedObject()’

   * *note PyUnicode_AsEncodedString(): 4905.

   * ‘PyUnicode_AsEncodedUnicode()’

   * *note PyUnicode_AsLatin1String(): 1164.

   * *note PyUnicode_AsMBCSString(): 1166.

   * *note PyUnicode_AsRawUnicodeEscapeString(): 1163.

   * *note PyUnicode_AsUCS4(): 114b.

   * *note PyUnicode_AsUCS4Copy(): 889.

   * *note PyUnicode_AsUTF16String(): 4906.

   * *note PyUnicode_AsUTF32String(): 4907.

   * *note PyUnicode_AsUTF8AndSize(): 866.

   * *note PyUnicode_AsUTF8String(): 1161.

   * *note PyUnicode_AsUnicodeEscapeString(): 1162.

   * *note PyUnicode_AsWideChar(): 19c2.

   * *note PyUnicode_AsWideCharString(): 88a.

   * ‘PyUnicode_BuildEncodingMap()’

   * *note PyUnicode_Compare(): 885.

   * *note PyUnicode_CompareWithASCIIString(): 1239.

   * *note PyUnicode_Concat(): 1172.

   * *note PyUnicode_Contains(): 4908.

   * *note PyUnicode_Count(): 4909.

   * *note PyUnicode_Decode(): 194d.

   * *note PyUnicode_DecodeASCII(): 490a.

   * *note PyUnicode_DecodeCharmap(): 490b.

   * ‘PyUnicode_DecodeCodePageStateful()’

   * *note PyUnicode_DecodeFSDefault(): 1680.

   * *note PyUnicode_DecodeFSDefaultAndSize(): 490c.

   * *note PyUnicode_DecodeLatin1(): 490d.

   * *note PyUnicode_DecodeLocale(): 490e.

   * *note PyUnicode_DecodeLocaleAndSize(): b97.

   * *note PyUnicode_DecodeMBCS(): 490f.

   * *note PyUnicode_DecodeMBCSStateful(): 4910.

   * *note PyUnicode_DecodeRawUnicodeEscape(): 4911.

   * *note PyUnicode_DecodeUTF16(): 4912.

   * *note PyUnicode_DecodeUTF16Stateful(): 4913.

   * *note PyUnicode_DecodeUTF32(): 4914.

   * *note PyUnicode_DecodeUTF32Stateful(): 4915.

   * *note PyUnicode_DecodeUTF7(): 4916.

   * *note PyUnicode_DecodeUTF7Stateful(): 4917.

   * *note PyUnicode_DecodeUTF8(): 4918.

   * *note PyUnicode_DecodeUTF8Stateful(): 170a.

   * *note PyUnicode_DecodeUnicodeEscape(): 4919.

   * *note PyUnicode_EncodeCodePage(): 1167.

   * *note PyUnicode_EncodeFSDefault(): 19bc.

   * *note PyUnicode_EncodeLocale(): b98.

   * *note PyUnicode_EqualToUTF8(): 350.

   * *note PyUnicode_EqualToUTF8AndSize(): 34f.

   * *note PyUnicode_FSConverter(): ce7.

   * *note PyUnicode_FSDecoder(): 543.

   * *note PyUnicode_Find(): 491a.

   * *note PyUnicode_FindChar(): 887.

   * *note PyUnicode_Format(): 491b.

   * *note PyUnicode_FromEncodedObject(): 491c.

   * *note PyUnicode_FromFormat(): 363.

   * *note PyUnicode_FromFormatV(): 540.

   * *note PyUnicode_FromObject(): 491d.

   * ‘PyUnicode_FromOrdinal()’

   * *note PyUnicode_FromString(): 47be.

   * *note PyUnicode_FromStringAndSize(): 491e.

   * *note PyUnicode_FromWideChar(): 115f.

   * ‘PyUnicode_GetDefaultEncoding()’

   * *note PyUnicode_GetLength(): 881.

   * *note PyUnicode_InternFromString(): 1562.

   * *note PyUnicode_InternInPlace(): 87f.

   * *note PyUnicode_IsIdentifier(): 1908.

   * *note PyUnicode_Join(): 1173.

   * ‘PyUnicode_Partition()’

   * ‘PyUnicode_RPartition()’

   * ‘PyUnicode_RSplit()’

   * *note PyUnicode_ReadChar(): 1144.

   * *note PyUnicode_Replace(): 491f.

   * ‘PyUnicode_Resize()’

   * *note PyUnicode_RichCompare(): 4920.

   * *note PyUnicode_Split(): 4921.

   * *note PyUnicode_Splitlines(): 4922.

   * *note PyUnicode_Substring(): 884.

   * *note PyUnicode_Tailmatch(): 886.

   * *note PyUnicode_Translate(): 4923.

   * *note PyUnicode_Type: 4924.

   * *note PyUnicode_WriteChar(): 1145.

   * *note PyVarObject: 3fe2.

   * ‘PyVarObject.ob_base’

   * *note PyVarObject.ob_size: 4925.

   * *note PyVectorcall_Call(): 521.

   * *note PyVectorcall_NARGS(): 520.

   * ‘PyWeakReference’

   * *note PyWeakref_GetObject(): 352.

   * *note PyWeakref_GetRef(): 351.

   * *note PyWeakref_NewProxy(): 4926.

   * *note PyWeakref_NewRef(): 17b9.

   * ‘PyWrapperDescr_Type’

   * *note PyWrapper_New(): 4927.

   * ‘PyZip_Type’

   * *note Py_AddPendingCall(): 94f.

   * *note Py_AtExit(): 4928.

   * *note Py_BEGIN_ALLOW_THREADS: 4769.

   * *note Py_BLOCK_THREADS: 4929.

   * *note Py_BuildValue(): 875.

   * *note Py_BytesMain(): 98f.

   * *note Py_CompileString(): 852.

   * *note Py_DecRef(): 492a.

   * *note Py_DecodeLocale(): b95.

   * *note Py_END_ALLOW_THREADS: a5c.

   * *note Py_EncodeLocale(): b96.

   * *note Py_EndInterpreter(): 17ca.

   * *note Py_EnterRecursiveCall(): 941.

   * *note Py_Exit(): d1c.

   * *note Py_FatalError(): 951.

   * ‘Py_FileSystemDefaultEncodeErrors’

   * ‘Py_FileSystemDefaultEncoding’

   * *note Py_Finalize(): 1321.

   * *note Py_FinalizeEx(): ce3.

   * *note Py_GenericAlias(): 492b.

   * *note Py_GenericAliasType: 492c.

   * *note Py_GetBuildInfo(): 13d9.

   * *note Py_GetCompiler(): 492d.

   * *note Py_GetConstant(): 32f.

   * *note Py_GetConstantBorrowed(): 330.

   * *note Py_GetCopyright(): 492e.

   * *note Py_GetExecPrefix(): 38b.

   * *note Py_GetPath(): 38d.

   * *note Py_GetPlatform(): 492f.

   * *note Py_GetPrefix(): 38f.

   * *note Py_GetProgramFullPath(): 391.

   * *note Py_GetProgramName(): 393.

   * *note Py_GetPythonHome(): 394.

   * ‘Py_GetRecursionLimit()’

   * *note Py_GetVersion(): 4930.

   * ‘Py_HasFileSystemDefaultEncoding’

   * *note Py_IncRef(): 4931.

   * *note Py_Initialize(): 87a.

   * *note Py_InitializeEx(): 4932.

   * *note Py_Is(): 86d.

   * *note Py_IsFalse(): 870.

   * *note Py_IsFinalizing(): 333.

   * *note Py_IsInitialized(): 47e3.

   * *note Py_IsNone(): 86e.

   * *note Py_IsTrue(): 86f.

   * *note Py_LeaveRecursiveCall(): 942.

   * *note Py_Main(): bf3.

   * ‘Py_MakePendingCalls()’

   * *note Py_NewInterpreter(): 1721.

   * *note Py_NewRef(): 867.

   * *note Py_ReprEnter(): 4933.

   * *note Py_ReprLeave(): 4934.

   * *note Py_SetProgramName(): 15a2.

   * *note Py_SetPythonHome(): 15a1.

   * ‘Py_SetRecursionLimit()’

   * *note Py_UCS4: 27b.

   * *note Py_UNBLOCK_THREADS: 4935.

   * ‘Py_UTF8Mode’

   * *note Py_VaBuildValue(): 4936.

   * *note Py_Version: 721.

   * *note Py_XNewRef(): 868.

   * *note Py_buffer: 723.

   * ‘Py_intptr_t’

   * *note Py_ssize_t: a2e.

   * ‘Py_uintptr_t’

   * *note allocfunc: 4937.

   * *note binaryfunc: 4938.

   * *note descrgetfunc: 4939.

   * *note descrsetfunc: 493a.

   * *note destructor: 493b.

   * *note getattrfunc: 493c.

   * *note getattrofunc: 493d.

   * *note getbufferproc: 493e.

   * *note getiterfunc: 493f.

   * *note getter: 4940.

   * *note hashfunc: 4941.

   * *note initproc: 4942.

   * *note inquiry: 4943.

   * *note iternextfunc: 4944.

   * *note lenfunc: 4945.

   * *note newfunc: 4946.

   * *note objobjargproc: 4947.

   * *note objobjproc: 4948.

   * *note releasebufferproc: 4949.

   * *note reprfunc: 494a.

   * *note richcmpfunc: 494b.

   * *note setattrfunc: 494c.

   * *note setattrofunc: 494d.

   * *note setter: 494e.

   * *note ssizeargfunc: 494f.

   * *note ssizeobjargproc: 4950.

   * ‘ssizessizeargfunc’

   * ‘ssizessizeobjargproc’

   * ‘symtable’

   * *note ternaryfunc: 4951.

   * *note traverseproc: 4952.

   * *note unaryfunc: 4953.

   * *note vectorcallfunc: 522.

   * *note visitproc: 4954.


File: python.info,  Node: 超高水準レイヤ,  Next: 参照カウント,  Prev: C API の安定性,  Up: Python/C API リファレンスマニュアル

7.3 超高水準レイヤ
==================

この章の関数を使うとファイルまたはバッファにある Python ソースコードを実
行できますが、より詳細なやり取りをインタプリタとすることはできないでしょ
う。

Several of these functions accept a start symbol from the grammar as a
parameter.  The available start symbols are *note Py_eval_input: 4958,
*note Py_file_input: 4959, and *note Py_single_input: 495a.  These are
described following the functions which accept them as parameters.

Note also that several of these functions take FILE* parameters.  One
particular issue which needs to be handled carefully is that the ‘FILE’
structure for different C libraries can be different and incompatible.
Under Windows (at least), it is possible for dynamically linked
extensions to actually use different libraries, so care should be taken
that FILE* parameters are only passed to these functions if it is
certain that they were created by the same library that the Python
runtime is using.

 -- C の関数: int PyRun_AnyFile (FILE *fp, const char *filename)

     下記の *note PyRun_AnyFileExFlags(): 495c. の 'closeit' を ‘0’ に、
     'flags' を ‘NULL’ にして単純化したインターフェースです。

 -- C の関数: int PyRun_AnyFileFlags (FILE *fp, const char *filename,
          PyCompilerFlags *flags)

     下記の *note PyRun_AnyFileExFlags(): 495c. の 'closeit' を ‘0’ にし
     て単純化したインターフェースです。

 -- C の関数: int PyRun_AnyFileEx (FILE *fp, const char *filename, int
          closeit)

     下記の *note PyRun_AnyFileExFlags(): 495c. の 'flags' を ‘NULL’ に
     して単純化したインターフェースです。

 -- C の関数: int PyRun_AnyFileExFlags (FILE *fp, const char *filename,
          int closeit, PyCompilerFlags *flags)

     'fp' が対話的デバイス (コンソールや端末入力あるいは Unix 仮想端末)
     と関連づけられたファイルを参照している場合は、 *note
     PyRun_InteractiveLoop(): 495f. の値を返します。それ以外の場合は、
     *note PyRun_SimpleFile(): 47b6. の結果を返します。 'filename' はフ
     ァイルシステムのエンコーディング (*note
     sys.getfilesystemencoding(): c27.) でデコードされます。 'filename'
     が ‘NULL’ ならば、この関数はファイル名として ‘"???"’ を使います。
     'closeit' が真なら、ファイルは ‘PyRun_SimpleFileExFlags()’ が処理を
     戻す前に閉じられます。

 -- C の関数: int PyRun_SimpleString (const char *command)

     下記の *note PyRun_SimpleStringFlags(): 4960. の *note
     PyCompilerFlags: a6f.* を ‘NULL’ にして単純化したインタフェースです
     。

 -- C の関数: int PyRun_SimpleStringFlags (const char *command,
          PyCompilerFlags *flags)

     *note __main__: 1. モジュールの中で 'flags' に従って 'command' に含
     まれる Python ソースコードを実行します。 *note __main__: 1. がまだ
     存在しない場合は作成されます。正常終了の場合は ‘0’ を返し、また例外
     が発生した場合は ‘-1’ を返します。エラーがあっても、例外情報を得る
     方法はありません。 'flags' の意味については、後述します。

     Note that if an otherwise unhandled *note SystemExit: d0e. is
     raised, this function will not return ‘-1’, but exit the process,
     as long as *note PyConfig.inspect: 3a9. is zero.

 -- C の関数: int PyRun_SimpleFile (FILE *fp, const char *filename)

     下記の *note PyRun_SimpleFileExFlags(): 1873. の 'closeit' を ‘0’ に
     、 'flags' を ‘NULL’ にして単純化したインターフェースです。

 -- C の関数: int PyRun_SimpleFileEx (FILE *fp, const char *filename,
          int closeit)

     下記の *note PyRun_SimpleFileExFlags(): 1873. の 'flags' を ‘NULL’
     にして単純化したインターフェースです。

 -- C の関数: int PyRun_SimpleFileExFlags (FILE *fp, const char
          *filename, int closeit, PyCompilerFlags *flags)

     *note PyRun_SimpleStringFlags(): 4960. と似ていますが、Pythonソース
     コードをメモリ内の文字列ではなく 'fp' から読み込みます。 'filename'
     はそのファイルの名前でなければならず、 *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されます。 'closeit' に真を指定した場合は、
     ‘PyRun_SimpleFileExFlags()’ が処理を戻す前にファイルを閉じます。

          注釈: Windowsでは、 'fp' はバイナリモードで開くべきです (例え
          ば ‘fopen(filename, "rb")’)。 そうしない場合は、 Python は行末
          が LF のスクリプトを正しく扱えないでしょう。

 -- C の関数: int PyRun_InteractiveOne (FILE *fp, const char *filename)

     下記の *note PyRun_InteractiveOneFlags(): 4963. の 'flags' を
     ‘NULL’ にして単純化したインターフェースです。

 -- C の関数: int PyRun_InteractiveOneFlags (FILE *fp, const char
          *filename, PyCompilerFlags *flags)

     対話的デバイスに関連付けられたファイルから文を一つ読み込み、
     'flags' に従って実行します。 ‘sys.ps1’ と ‘sys.ps2’ を使って、ユー
     ザにプロンプトを表示します。 'filename' は *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されます。

     入力が正常に実行されたときは ‘0’ を返します。例外が発生した場合は
     ‘-1’ を返します。パースエラーの場合はPythonの一部として配布されてい
     る ‘errcode.h’ インクルードファイルにあるエラーコードを返します。
     (‘Python.h’ は ‘errcode.h’ をインクルードしません。従って、 必要な
     場合はその都度インクルードしなければならないことに注意してください
     。)

 -- C の関数: int PyRun_InteractiveLoop (FILE *fp, const char *filename)

     下記の *note PyRun_InteractiveLoopFlags(): 4964. の 'flags' を
     ‘NULL’ にして単純化したインターフェースです。

 -- C の関数: int PyRun_InteractiveLoopFlags (FILE *fp, const char
          *filename, PyCompilerFlags *flags)

     対話的デバイスに関連付けられたファイルから EOF に達するまで文を読み
     込み実行します。 ‘sys.ps1’ と ‘sys.ps2’ を使って、ユーザにプロンプ
     トを表示します。 'filename' は *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されます。 EOFに達すると ‘0’ を返すか、失敗したら負の数を返します。

 -- C 変数: int (*PyOS_InputHook)(void)
     ' 次に属します: *note Stable ABI: 51e.'  ‘int func(void)’ というプ
     ロトタイプの関数へのポインタが設定できます。 この関数は、 Python の
     インタプリタのプロンプトがアイドル状態になりターミナルからのユーザ
     の入力を待つようになったときに呼び出されます。 返り値は無視されます
     。 このフックを上書きすることで、 Python のソースコードの中で
     ‘Modules/_tkinter.c’ がやっているように、インタプリタのプロンプトと
     他のイベントループを統合できます。

     バージョン 3.12 で変更: This function is only called from the *note
     main interpreter: 553.

 -- C 変数: char *(*PyOS_ReadlineFunctionPointer)(FILE*, FILE*, const
          char*)

     ‘char *func(FILE *stdin, FILE *stdout, char *prompt)’ というプロト
     タイプの関数へのポインタが設定でき、デフォルトの関数を上書きするこ
     とでインタプリタのプロンプトへの入力を1行だけ読めます。 この関数は
     、文字列 'prompt' が ‘NULL’ でない場合は 'prompt' を出力し、与えら
     れた標準入力ファイルから入力を1行読み、結果の文字列を返すという動作
     が期待されています。 例えば、 *note readline: a8. モジュールはこの
     フックを設定して、行編集機能やタブ補完機能を提供しています。

     返り値は *note PyMem_RawMalloc(): 369. または *note
     PyMem_RawRealloc(): 36b. でメモリ確保した文字列、あるいはエラーが起
     きた場合には ‘NULL’ でなければなりません。

     バージョン 3.4 で変更: 返り値は、 *note PyMem_Malloc(): c33. や
     *note PyMem_Realloc(): ffc. ではなく、 *note PyMem_RawMalloc():
     369. または *note PyMem_RawRealloc(): 36b. でメモリ確保したものでな
     ければなりません。

     バージョン 3.12 で変更: This function is only called from the *note
     main interpreter: 553.

 -- C の関数: *note PyObject: 312. *PyRun_String (const char *str, int
          start, PyObject *globals, PyObject *locals)
     '戻り値: 新しい参照。' 下記の *note PyRun_StringFlags(): 4965. の
     'flags' を ‘NULL’ にして単純化したインターフェースです。

 -- C の関数: *note PyObject: 312. *PyRun_StringFlags (const char *str,
          int start, PyObject *globals, PyObject *locals,
          PyCompilerFlags *flags)
     '戻り値: 新しい参照。' オブジェクトの 'globals' と 'locals' で指定
     されるコンテキストで、コンパイラフラグに 'flags' を設定した状態で、
     'str' にある Python ソースコードを実行します。 'globals' は辞書でな
     ければなりません; 'locals' はマッピングプロトコルを実装したオブジェ
     クトなら何でも構いません。 引数 'start' はソースコードをパースする
     ために使われるべき開始トークンを指定します。

     コードを実行した結果をPythonオブジェクトとして返します。または、例
     外が発生したならば ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyRun_File (FILE *fp, const char
          *filename, int start, PyObject *globals, PyObject *locals)
     '戻り値: 新しい参照。' 下記の *note PyRun_FileExFlags(): 4967. の
     'closeit' を ‘0’ にし、 'flags' を ‘NULL’ にして単純化したインター
     フェースです。

 -- C の関数: *note PyObject: 312. *PyRun_FileEx (FILE *fp, const char
          *filename, int start, PyObject *globals, PyObject *locals, int
          closeit)
     '戻り値: 新しい参照。' 下記の *note PyRun_FileExFlags(): 4967. の
     'flags' を ‘NULL’ にして単純化したインターフェースです。

 -- C の関数: *note PyObject: 312. *PyRun_FileFlags (FILE *fp, const
          char *filename, int start, PyObject *globals, PyObject
          *locals, PyCompilerFlags *flags)
     '戻り値: 新しい参照。' 下記の *note PyRun_FileExFlags(): 4967. の
     'closeit' を ‘0’ にして単純化したインターフェースです。

 -- C の関数: *note PyObject: 312. *PyRun_FileExFlags (FILE *fp, const
          char *filename, int start, PyObject *globals, PyObject
          *locals, int closeit, PyCompilerFlags *flags)
     '戻り値: 新しい参照。' *note PyRun_StringFlags(): 4965. と似ていま
     すが、Pythonソースコードをメモリ内の文字列ではなく 'fp' から読み込
     みます。 'filename' はそのファイルの名前でなければならず、 *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されます。 'closeit' に真を指定した場合は、*note
     PyRun_FileExFlags(): 4967. が処理を戻す前にファイルを閉じます。

 -- C の関数: *note PyObject: 312. *Py_CompileString (const char *str,
          const char *filename, int start)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  下記
     の *note Py_CompileStringFlags(): 496a. の 'flags' を ‘NULL’ にして
     単純化したインターフェースです。

 -- C の関数: *note PyObject: 312. *Py_CompileStringFlags (const char
          *str, const char *filename, int start, PyCompilerFlags *flags)
     '戻り値: 新しい参照。' 下記の *note Py_CompileStringExFlags():
     496b. の 'optimize' を ‘-1’ にして単純化したインターフェースです。

 -- C の関数: *note PyObject: 312. *Py_CompileStringObject (const char
          *str, PyObject *filename, int start, PyCompilerFlags *flags,
          int optimize)
     '戻り値: 新しい参照。' Parse and compile the Python source code in
     'str', returning the resulting code object.  The start token is
     given by 'start'; this can be used to constrain the code which can
     be compiled and should be *note Py_eval_input: 4958, *note
     Py_file_input: 4959, or *note Py_single_input: 495a.  The filename
     specified by 'filename' is used to construct the code object and
     may appear in tracebacks or *note SyntaxError: 172. exception
     messages.  This returns ‘NULL’ if the code cannot be parsed or
     compiled.

     整数 'optimize' は、コンパイラの最適化レベルを指定します; ‘-1’ は、
     インタプリタの *note -O: d82. オプションで与えられるのと同じ最適化
     レベルを選びます。明示的なレベルは、 ‘0’ (最適化なし、 ‘__debug__’
     は真)、 ‘1’ (assert は取り除かれ、 ‘__debug__’ は偽)、 ‘2’
     (docstring も取り除かれる) です。

     Added in version 3.4.

 -- C の関数: *note PyObject: 312. *Py_CompileStringExFlags (const char
          *str, const char *filename, int start, PyCompilerFlags *flags,
          int optimize)
     '戻り値: 新しい参照。' *note Py_CompileStringObject(): 496c. と似て
     いますが、 'filename' は *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されたバイト文字列です。

     Added in version 3.2.

 -- C の関数: *note PyObject: 312. *PyEval_EvalCode (PyObject *co,
          PyObject *globals, PyObject *locals)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     *note PyEval_EvalCodeEx(): 16d4. のシンプルなインターフェースで、コ
     ードオブジェクトと、グローバル変数とローカル変数だけを受け取ります
     。 他の引数には ‘NULL’ が渡されます。

 -- C の関数: *note PyObject: 312. *PyEval_EvalCodeEx (PyObject *co,
          PyObject *globals, PyObject *locals, PyObject *const *args,
          int argcount, PyObject *const *kws, int kwcount, PyObject
          *const *defs, int defcount, PyObject *kwdefs, PyObject
          *closure)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた特定の環境で、コンパイル済みのコードオブジェクトを評価します
     。この環境はグローバル変数の辞書と、ローカル変数のマッピングオブジ
     ェクト、引数の配列、キーワードとデフォルト値、*note キーワード専用:
     285. 引数のデフォルト値の辞書と、セルのクロージャタプルで構成されま
     す。

 -- C の関数: *note PyObject: 312. *PyEval_EvalFrame (PyFrameObject *f)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  実行
     フレームを評価します。これは *note PyEval_EvalFrameEx(): ff8. に対
     するシンプルなインターフェースで、後方互換性のためのものです。

 -- C の関数: *note PyObject: 312. *PyEval_EvalFrameEx (PyFrameObject
          *f, int throwflag)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Python のインタープリタの主要な、直接的な関数です。実行フレーム 'f'
     に関連付けられたコードオブジェクトを実行します。 バイトコードを解釈
     して、必要に応じて呼び出しを実行します。 追加の 'throwflag' 引数は
     ほとんど無視できます。 - もし true なら、 すぐに例外を発生させます
     。これはジェネレータオブジェクトの *note throw(): 4c5. メソッドで利
     用されます。

     バージョン 3.4 で変更: アクティブな例外を黙って捨てないことを保証す
     るのに便利なように、この関数はデバッグアサーションを含むようになり
     ました。

 -- C の関数: int PyEval_MergeCompilerFlags (PyCompilerFlags *cf)

     現在の評価フレームのフラグを変更します。成功したら true を、失敗し
     たら false を返します。

 -- C 変数: int Py_eval_input

     単独の式に対するPython文法の開始記号で、 *note Py_CompileString():
     852. と一緒に使います。

 -- C 変数: int Py_file_input

     ファイルあるいは他のソースから読み込まれた文の並びに対するPython文
     法の開始記号で、 *note Py_CompileString(): 852. と一緒に使います。
     これは任意の長さのPythonソースコードをコンパイルするときに使う記号
     です。

 -- C 変数: int Py_single_input

     単一の文に対するPython文法の開始記号で、 *note Py_CompileString():
     852. と一緒に使います。これは対話式のインタプリタループのための記号
     です。

 -- C Struct: struct PyCompilerFlags

     コンパイラフラグを収めておくための構造体です。コードをコンパイルす
     るだけの場合、この構造体が ‘int flags’ として渡されます。コードを実
     行する場合には ‘PyCompilerFlags *flags’ として渡されます。この場合
     、‘from __future__ import’ は 'flags' の内容を変更できます。

     Whenever ‘PyCompilerFlags *flags’ is ‘NULL’, *note cf_flags: 496e.
     is treated as equal to ‘0’, and any modification due to ‘from
     __future__ import’ is discarded.

      -- C のメンバ変数: int cf_flags

          コンパイラフラグ。

      -- C のメンバ変数: int cf_feature_version

          'cf_feature_version' is the minor Python version.  It should
          be initialized to ‘PY_MINOR_VERSION’.

          The field is ignored by default, it is used if and only if
          ‘PyCF_ONLY_AST’ flag is set in *note cf_flags: 496e.

     バージョン 3.8 で変更: Added 'cf_feature_version' field.

 -- C 変数: int CO_FUTURE_DIVISION

     このビットを 'flags' にセットすると、除算演算子 ‘/’ は PEP 238(1) に
     よる「真の除算 (true division)」として扱われます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0238/


File: python.info,  Node: 参照カウント,  Next: 例外処理,  Prev: 超高水準レイヤ,  Up: Python/C API リファレンスマニュアル

7.4 参照カウント
================

このセクションにある関数とマクロは、 Python オブジェクトの参照カウントの
管理に使用されます。

 -- C の関数: *note Py_ssize_t: a2e. Py_REFCNT (PyObject *o)

     Python オブジェクト 'o' の参照カウントを取得します。

     戻り値は、実際に保持されているオブジェクトの参照の数を実際に反映し
     ているとは限らないことに注意してください。例えば、一部のオブジェク
     トは永続 (*note immortal: 41f8.) であり、実際の参照の数を反映しない
     非常に高い参照数を持ちます。したがって、 0 か 1 の値以外では、正確
     な戻り値に頼らないでください。

     オブジェクトの参照カウントを設定するためには、 *note
     Py_SET_REFCNT(): 878. 関数を使用してください。

     バージョン 3.10 で変更: *note Py_REFCNT(): 877. は static なインラ
     イン関数に変更されました。

     バージョン 3.11 で変更: 引数の型は const *note PyObject: 312.* では
     なくなりました。

 -- C の関数: void Py_SET_REFCNT (PyObject *o, Py_ssize_t refcnt)

     オブジェクト 'o' の参照カウントを 'refcnt' に設定します。

     *note フリースレッドな Python ビルド: 1ce2. では、 'refcnt' が
     ‘UINT32_MAX’ より大きい場合、オブジェクトは永続 (*note immortal:
     41f8.) となります。

     この関数は永続 (*note immortal: 41f8.) オブジェクトには何もしません
     。

     Added in version 3.9.

     バージョン 3.12 で変更: 永続オブジェクトは変更されません。

 -- C の関数: void Py_INCREF (PyObject *o)

     オブジェクト 'o' への新しい *note 強参照: 316. を取得し、それが使用
     中で破棄されてはならないことを示します。

     この関数は永続 (*note immortal: 41f8.) オブジェクトには何もしません
     。

     This function is usually used to convert a *note borrowed
     reference: 317. to a *note strong reference: 316. in-place.  The
     *note Py_NewRef(): 867. function can be used to create a new *note
     strong reference: 316.

     When done using the object, release is by calling *note
     Py_DECREF(): 53b.

     オブジェクトが ‘NULL’ であってはいけません。それが ‘NULL’ ではない
     と確信が持てないならば、 *note Py_XINCREF(): a33. を使ってください
     。

     Do not expect this function to actually modify 'o' in any way.  For
     at least some objects(1), this function has no effect.

     バージョン 3.12 で変更: 永続オブジェクトは変更されません。

 -- C の関数: void Py_XINCREF (PyObject *o)

     Similar to *note Py_INCREF(): 53a, but the object 'o' can be
     ‘NULL’, in which case this has no effect.

     See also *note Py_XNewRef(): 868.

 -- C の関数: *note PyObject: 312. *Py_NewRef (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Create a new *note strong reference: 316. to an object: call *note
     Py_INCREF(): 53a. on 'o' and return the object 'o'.

     When the *note strong reference: 316. is no longer needed, *note
     Py_DECREF(): 53b. should be called on it to release the reference.

     The object 'o' must not be ‘NULL’; use *note Py_XNewRef(): 868. if
     'o' can be ‘NULL’.

     例えば:

          Py_INCREF(obj);
          self->attr = obj;

     can be written as:

          self->attr = Py_NewRef(obj);

     See also *note Py_INCREF(): 53a.

     Added in version 3.10.

 -- C の関数: *note PyObject: 312. *Py_XNewRef (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Similar to *note Py_NewRef(): 867, but the object 'o' can be NULL.

     If the object 'o' is ‘NULL’, the function just returns ‘NULL’.

     Added in version 3.10.

 -- C の関数: void Py_DECREF (PyObject *o)

     Release a *note strong reference: 316. to object 'o', indicating
     the reference is no longer used.

     この関数は永続 (*note immortal: 41f8.) オブジェクトには何もしません
     。

     Once the last *note strong reference: 316. 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.

     This function is usually used to delete a *note strong reference:
     316. before exiting its scope.

     オブジェクトが ‘NULL’ であってはいけません。それが ‘NULL’ ではない
     と確信が持てないならば、 *note Py_XDECREF(): 75a. を使ってください
     。

     Do not expect this function to actually modify 'o' in any way.  For
     at least some objects(2), this function has no effect.

          警告: The deallocation function can cause arbitrary Python
          code to be invoked (e.g.  when a class instance with a *note
          __del__(): 1ec1. method is deallocated).  While exceptions in
          such code are not propagated, the executed code has free
          access to all Python global variables.  This means that any
          object that is reachable from a global variable should be in a
          consistent state before *note Py_DECREF(): 53b. is invoked.
          For example, code to delete an object from a list should copy
          a reference to the deleted object in a temporary variable,
          update the list data structure, and then call *note
          Py_DECREF(): 53b. for the temporary variable.

     バージョン 3.12 で変更: 永続オブジェクトは変更されません。

 -- C の関数: void Py_XDECREF (PyObject *o)

     Similar to *note Py_DECREF(): 53b, but the object 'o' can be
     ‘NULL’, in which case this has no effect.  The same warning from
     *note Py_DECREF(): 53b. applies here as well.

 -- C の関数: void Py_CLEAR (PyObject *o)

     Release a *note strong reference: 316. for object 'o'.  The object
     may be ‘NULL’, in which case the macro has no effect; otherwise the
     effect is the same as for *note Py_DECREF(): 53b, except that the
     argument is also set to ‘NULL’.  The warning for *note Py_DECREF():
     53b. does not apply with respect to the object passed because the
     macro carefully uses a temporary variable and sets the argument to
     ‘NULL’ before releasing the reference.

     It is a good idea to use this macro whenever releasing a reference
     to an object that might be traversed during garbage collection.

     バージョン 3.12 で変更: The macro argument is now only evaluated
     once.  If the argument has side effects, these are no longer
     duplicated.

 -- C の関数: void Py_IncRef (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  Indicate taking a new
     *note strong reference: 316. to object 'o'.  A function version of
     *note Py_XINCREF(): a33.  It can be used for runtime dynamic
     embedding of Python.

 -- C の関数: void Py_DecRef (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  Release a *note strong
     reference: 316. to object 'o'.  A function version of *note
     Py_XDECREF(): 75a.  It can be used for runtime dynamic embedding of
     Python.

 -- C のマクロ: Py_SETREF (dst, src)

     Macro safely releasing a *note strong reference: 316. to object
     'dst' and setting 'dst' to 'src'.

     As in case of *note Py_CLEAR(): 544, "the obvious" code can be
     deadly:

          Py_DECREF(dst);
          dst = src;

     The safe way is:

          Py_SETREF(dst, src);

     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.

     Added in version 3.6.

     バージョン 3.12 で変更: The macro arguments are now only evaluated
     once.  If an argument has side effects, these are no longer
     duplicated.

 -- C のマクロ: Py_XSETREF (dst, src)

     Variant of *note Py_SETREF: 545. macro that uses *note
     Py_XDECREF(): 75a. instead of *note Py_DECREF(): 53b.

     Added in version 3.6.

     バージョン 3.12 で変更: The macro arguments are now only evaluated
     once.  If an argument has side effects, these are no longer
     duplicated.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0683/

   (2) https://peps.python.org/pep-0683/


File: python.info,  Node: 例外処理,  Next: ユーティリティ<2>,  Prev: 参照カウント,  Up: Python/C API リファレンスマニュアル

7.5 例外処理
============

この章で説明する関数を使うと、 Python の例外の処理や例外の送出ができるよ
うになります。 Python の例外処理の基本をいくらか理解することが大切です。
例外は POSIX ‘errno’ 変数にやや似た機能を果たします: 発生した中で最も新
しいエラーの (スレッド毎の) グローバルなインジケータがあります。実行に成
功した場合にはほとんどの C API 関数がこれをクリアしませんが、失敗したと
きにはエラーの原因を示すために設定します。ほとんどの C API 関数はエラー
インジケータも返し、通常は関数がポインタを返すことになっている場合は
‘NULL’ であり、関数が整数を返す場合は ‘-1’ です。(例外: ‘PyArg_*’ 関数は
実行に成功したときに ‘1’ を返し、失敗したときに ‘0’ を返します).

具体的には、エラーインジケータは、例外の型、例外の値、トレースバックオブ
ジェクトの３つのオブジェクトポインタで構成されます。これらのポインタはど
れでも、設定されない場合は ‘NULL’ になりえます（ただし、いくつかの組み合
わせは禁止されており、例えば、例外の型が ‘NULL’ の場合は、トレースバック
は非 ‘NULL’ の値になりません）

ある関数が呼び出した関数がいくつか失敗したために、その関数が失敗しなけれ
ばならないとき、一般的にエラーインジケータを設定しません。呼び出した関数
がすでに設定しています。エラーを処理して例外をクリアするか、あるいは (オ
ブジェクト参照またはメモリ割り当てのような)それが持つどんなリソースも取
り除いた後に戻るかのどちらか一方を行う責任があります。エラーを処理する準
備をしていなければ、普通に続けるべきでは 'ありません'。エラーのために戻
る場合は、エラーが設定されていると呼び出し元に知らせることが大切です。エ
ラーが処理されていない場合または丁寧に伝えられている場合には、Python/C
APIのさらなる呼び出しは意図した通りには動かない可能性があり、不可解な形
で失敗するかもしれません。

     注釈: The error indicator is 'not' the result of *note
     sys.exc_info(): 656.  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).

* Menu:

* 出力とクリア::
* 例外の送出::
* 警告: 警告<3>.
* エラーインジケータの問い合わせ::
* シグナルハンドリング: シグナルハンドリング<2>.
* 例外クラス: 例外クラス<2>.
* 例外オブジェクト::
* Unicode 例外オブジェクト::
* 再帰の管理::
* 標準例外::
* 標準警告カテゴリ::


File: python.info,  Node: 出力とクリア,  Next: 例外の送出,  Up: 例外処理

7.5.1 出力とクリア
------------------

 -- C の関数: void PyErr_Clear ()
     ' 次に属します: *note Stable ABI: 51e.'  エラーインジケータをクリア
     します。エラーインジケータが設定されていないならば、効果はありませ
     ん。

 -- C の関数: void PyErr_PrintEx (int set_sys_last_vars)
     ' 次に属します: *note Stable ABI: 51e.'  標準のトレースバックを
     ‘sys.stderr’ に出力し、エラーインジケータをクリアします。 ただし、
     エラーが ‘SystemExit’ 'である場合を除いて' です。 その場合、トレー
     スバックは出力されず、 Python プロセスは ‘SystemExit’ インスタンス
     で指定されたエラーコードで終了します。

     エラーインジケータが設定されているときに 'だけ'、この関数を呼び出し
     てください。 それ以外の場合、致命的なエラーを引き起こすでしょう!

     If 'set_sys_last_vars' is nonzero, the variable *note sys.last_exc:
     48a. is set to the printed exception.  For backwards compatibility,
     the deprecated variables *note sys.last_type: 48b, *note
     sys.last_value: 48c. and *note sys.last_traceback: 48d. are also
     set to the type, value and traceback of this exception,
     respectively.

     バージョン 3.12 で変更: The setting of *note sys.last_exc: 48a. was
     added.

 -- C の関数: void PyErr_Print ()
     ' 次に属します: *note Stable ABI: 51e.'  ‘PyErr_PrintEx(1)’ のエイ
     リアスです。

 -- C の関数: void PyErr_WriteUnraisable (PyObject *obj)
     ' 次に属します: *note Stable ABI: 51e.'  現在の例外と 'obj' 引数で
     *note sys.unraisablehook(): 1d8. を呼び出します。

     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 *note __del__(): 1ec1. method.

     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.

     この関数を呼び出すときには、例外がセットされていなければなりません
     。

     バージョン 3.4 で変更: Print a traceback.  Print only traceback if
     'obj' is ‘NULL’.

     バージョン 3.8 で変更: Use *note sys.unraisablehook(): 1d8.

 -- C の関数: void PyErr_FormatUnraisable (const char *format, ...)

     Similar to *note PyErr_WriteUnraisable(): 328, but the 'format' and
     subsequent parameters help format the warning message; they have
     the same meaning and values as in *note PyUnicode_FromFormat():
     363.  ‘PyErr_WriteUnraisable(obj)’ is roughly equivalent to
     ‘PyErr_FormatUnraisable("Exception ignored in: %R", obj)’.  If
     'format' is ‘NULL’, only the traceback is printed.

     Added in version 3.13.

 -- C の関数: void PyErr_DisplayException (PyObject *exc)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Print the standard traceback display of ‘exc’ to ‘sys.stderr’,
     including chained exceptions and notes.

     Added in version 3.12.


File: python.info,  Node: 例外の送出,  Next: 警告<3>,  Prev: 出力とクリア,  Up: 例外処理

7.5.2 例外の送出
----------------

以下の関数は、現在のスレッドのエラーインジケータの設定を補助します。利便
性のため、これらの関数のいくつかは、 ‘return’ 文で利用できるように常に
‘NULL’ ポインタを返します。

 -- C の関数: void PyErr_SetString (PyObject *type, const char *message)
     ' 次に属します: *note Stable ABI: 51e.'  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, e.g.
     ‘PyExc_RuntimeError’.  You need not create a new *note strong
     reference: 316. to it (e.g.  with *note Py_INCREF(): 53a.).  The
     second argument is an error message; it is decoded from ‘'utf-8'’.

 -- C の関数: void PyErr_SetObject (PyObject *type, PyObject *value)
     ' 次に属します: *note Stable ABI: 51e.'  この関数は *note
     PyErr_SetString(): 548. に似ていますが、例外の "値(value)" として任
     意のPythonオブジェクトを指定することができます。

 -- C の関数: *note PyObject: 312. *PyErr_Format (PyObject *exception,
          const char *format, ...)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e.'  この
     関数はエラーインジケータを設定し ‘NULL’ を返します。 'exception' は
     Python例外クラスであるべきです。 'format' と以降の引数はエラーメッ
     セージを作るためのもので, *note PyUnicode_FromFormat(): 363. の引数
     と同じ意味を持っています。 'format' は ASCII エンコードされた文字列
     です。

 -- C の関数: *note PyObject: 312. *PyErr_FormatV (PyObject *exception,
          const char *format, va_list vargs)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.5 より).'  *note PyErr_Format(): e7a. と同じですが、可変長
     引数の代わりに ‘va_list’ 引数を受け取ります。

     Added in version 3.5.

 -- C の関数: void PyErr_SetNone (PyObject *type)
     ' 次に属します: *note Stable ABI: 51e.'  これは
     ‘PyErr_SetObject(type, Py_None)’ を省略したものです。

 -- C の関数: int PyErr_BadArgument ()
     ' 次に属します: *note Stable ABI: 51e.'  これは
     ‘PyErr_SetString(PyExc_TypeError, message)’ を省略したもので、ここ
     で 'message' は組み込み操作が不正な引数で呼び出されたということを表
     しています。主に内部で使用するためのものです。

 -- C の関数: *note PyObject: 312. *PyErr_NoMemory ()
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e.'  これ
     は ‘PyErr_SetNone(PyExc_MemoryError)’ を省略したもので、‘NULL’ を返
     します。したがって、メモリ不足になったとき、オブジェクト割り当て関
     数は ‘return PyErr_NoMemory();’ と書くことができます。

 -- C の関数: *note PyObject: 312. *PyErr_SetFromErrno (PyObject *type)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e.'

     This is a convenience function to raise an exception when a C
     library function has returned an error and set the C variable
     ‘errno’.  It constructs a tuple object whose first item is the
     integer ‘errno’ value and whose second item is the corresponding
     error message (gotten from ‘strerror()’), and then calls
     ‘PyErr_SetObject(type, object)’.  On Unix, when the ‘errno’ value
     is ‘EINTR’, indicating an interrupted system call, this calls *note
     PyErr_CheckSignals(): 433, and if that set the error indicator,
     leaves it set to that.  The function always returns ‘NULL’, so a
     wrapper function around a system call can write ‘return
     PyErr_SetFromErrno(type);’ when the system call returns an error.

 -- C の関数: *note PyObject: 312. *PyErr_SetFromErrnoWithFilenameObject
          (PyObject *type, PyObject *filenameObject)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e.'
     Similar to *note PyErr_SetFromErrno(): 4748, 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
     *note OSError: 3f0. exception, this is used to define the
     ‘filename’ attribute of the exception instance.

 -- C の関数: *note PyObject: 312.
          *PyErr_SetFromErrnoWithFilenameObjects (PyObject *type,
          PyObject *filenameObject, PyObject *filenameObject2)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  *note PyErr_SetFromErrnoWithFilenameObject():
     483c. に似てますが、ファイル名を2つ取る関数が失敗したときに例外を送
     出するために、2つ目のファイル名オブジェクトを受け取ります。

     Added in version 3.4.

 -- C の関数: *note PyObject: 312. *PyErr_SetFromErrnoWithFilename
          (PyObject *type, const char *filename)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e.'
     *note PyErr_SetFromErrnoWithFilenameObject(): 483c. に似ていますが
     、ファイル名は C 文字列として与えられます。 'filename' は *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されます。

 -- C の関数: *note PyObject: 312. *PyErr_SetFromWindowsErr (int ierr)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  This is a convenience function to
     raise *note OSError: 3f0.  If called with 'ierr' of ‘0’, the error
     code returned by a call to ‘GetLastError()’ is used instead.  It
     calls the Win32 function ‘FormatMessage()’ to retrieve the Windows
     description of error code given by 'ierr' or ‘GetLastError()’, then
     it constructs a *note OSError: 3f0. object with the *note winerror:
     21ea. attribute set to the error code, the *note strerror: 21eb.
     attribute set to the corresponding error message (gotten from
     ‘FormatMessage()’), and then calls ‘PyErr_SetObject(PyExc_OSError,
     object)’.  This function always returns ‘NULL’.

     *note Availability: 1cbe.: Windows.

 -- C の関数: *note PyObject: 312. *PyErr_SetExcFromWindowsErr (PyObject
          *type, int ierr)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  *note PyErr_SetFromWindowsErr():
     483e. に似ていますが、送出する例外の型を指定する引数が追加されてい
     ます。

     *note Availability: 1cbe.: Windows.

 -- C の関数: *note PyObject: 312. *PyErr_SetFromWindowsErrWithFilename
          (int ierr, const char *filename)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  Similar to *note
     PyErr_SetFromWindowsErr(): 483e, with the additional behavior that
     if 'filename' is not ‘NULL’, it is decoded from the filesystem
     encoding (*note os.fsdecode(): c22.) and passed to the constructor
     of *note OSError: 3f0. as a third parameter to be used to define
     the ‘filename’ attribute of the exception instance.

     *note Availability: 1cbe.: Windows.

 -- C の関数: *note PyObject: 312.
          *PyErr_SetExcFromWindowsErrWithFilenameObject (PyObject *type,
          int ierr, PyObject *filename)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  Similar to *note
     PyErr_SetExcFromWindowsErr(): 4839, with the additional behavior
     that if 'filename' is not ‘NULL’, it is passed to the constructor
     of *note OSError: 3f0. as a third parameter to be used to define
     the ‘filename’ attribute of the exception instance.

     *note Availability: 1cbe.: Windows.

 -- C の関数: *note PyObject: 312.
          *PyErr_SetExcFromWindowsErrWithFilenameObjects (PyObject
          *type, int ierr, PyObject *filename, PyObject *filename2)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  *note
     PyErr_SetExcFromWindowsErrWithFilenameObject(): 483a. に似てますが
     、2つ目のファイル名オブジェクトを受け取ります。

     *note Availability: 1cbe.: Windows.

     Added in version 3.4.

 -- C の関数: *note PyObject: 312.
          *PyErr_SetExcFromWindowsErrWithFilename (PyObject *type, int
          ierr, const char *filename)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  *note
     PyErr_SetFromWindowsErrWithFilename(): 167f. に似ていますが、送出す
     る例外の型を指定する引数が追加されています。

     *note Availability: 1cbe.: Windows.

 -- C の関数: *note PyObject: 312. *PyErr_SetImportError (PyObject *msg,
          PyObject *name, PyObject *path)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  *note ImportError: 3f2. を簡単に送出するための
     関数です。 'msg' は例外のメッセージ文字列としてセットされます。
     'name' と 'path' はどちらも ‘NULL’ にしてよく、それぞれ *note
     ImportError: 3f2. の ‘name’ 属性と ‘path’ 属性としてセットされます
     。

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyErr_SetImportErrorSubclass
          (PyObject *exception, PyObject *msg, PyObject *name, PyObject
          *path)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.6 より).'  *note PyErr_SetImportError(): d0c. とよく似てい
     ますが、この関数は送出する例外として、 *note ImportError: 3f2. のサ
     ブクラスを指定できます。

     Added in version 3.6.

 -- C の関数: void PyErr_SyntaxLocationObject (PyObject *filename, int
          lineno, int col_offset)

     現在の例外のファイル、行、オフセットの情報をセットします。 現在の例
     外が *note SyntaxError: 172. でない場合は、例外を表示するサブシステ
     ムが、例外が *note SyntaxError: 172. であると思えるように属性を追加
     します。

     Added in version 3.4.

 -- C の関数: void PyErr_SyntaxLocationEx (const char *filename, int
          lineno, int col_offset)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     *note PyErr_SyntaxLocationObject(): 4978. と似ていますが、
     'filename' は *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されたバイト文字列です。

     Added in version 3.2.

 -- C の関数: void PyErr_SyntaxLocation (const char *filename, int
          lineno)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PyErr_SyntaxLocationEx(): 4842. と似ていますが、 'col_offset' 引数
     が除去されています。

 -- C の関数: void PyErr_BadInternalCall ()
     ' 次に属します: *note Stable ABI: 51e.'
     ‘PyErr_SetString(PyExc_SystemError, message)’ を省略したものです。
     ここで 'message' は内部操作(例えば、Python/C API関数)が不正な引数と
     ともに呼び出されたということを示しています。主に内部で使用するため
     のものです。


File: python.info,  Node: 警告<3>,  Next: エラーインジケータの問い合わせ,  Prev: 例外の送出,  Up: 例外処理

7.5.3 警告
----------

以下の関数を使い、 C コードで起きた警告を報告します。 Python の *note
warnings: fa. モジュールで公開されている同様の関数とよく似てます。 これ
らの関数は通常警告メッセージを 'sys.stderr' へ出力しますが、ユーザが警告
をエラーへ変更するように指定することもでき、その場合は、関数は例外を送出
します。 警告機構がもつ問題のためにその関数が例外を送出するということも
有り得ます。 例外が送出されない場合は戻り値は ‘0’ で、例外が送出された場
合は ‘-1’ です。 (警告メッセージが実際に出力されるか、およびその例外の原
因が何かについては判断できません; これは意図的なものです。) 例外が送出さ
れた場合、呼び出し元は通常の例外処理を行います (例えば、保持していた参照
に対し *note Py_DECREF(): 53b. を行い、エラー値を返します)。

 -- C の関数: int PyErr_WarnEx (PyObject *category, const char *message,
          Py_ssize_t stack_level)
     ' 次に属します: *note Stable ABI: 51e.'  警告メッセージを発行します
     。 'category' 引数は警告カテゴリ(以下を参照) かまたは ‘NULL’ で、
     'message' 引数は UTF-8 エンコードされた文字列です。 'stacklevel' は
     スタックフレームの数を示す正の整数です; 警告はそのスタックフレーム
     の中の実行している行から発行されます。 'stacklevel' が 1 だと *note
     PyErr_WarnEx(): 13f2. を呼び出している関数が、2 だとその上の関数が
     Warning の発行元になります。

     警告カテゴリは ‘PyExc_Warning’ のサブクラスでなければなりません。
     ‘PyExc_Warning’ は ‘PyExc_Exception’ のサブクラスです。 デフォルト
     の警告カテゴリは ‘PyExc_RuntimeWarning’ です。 標準の Python 警告カ
     テゴリは、 *note 標準警告カテゴリ: 497a. で名前が列挙されているグロ
     ーバル変数として利用可能です。

     警告をコントロールするための情報については、 *note warnings: fa. モ
     ジュールのドキュメンテーションとコマンドライン・ドキュメンテーショ
     ンの *note -W: 896. オプションを参照してください。警告コントロール
     のためのC APIはありません。

 -- C の関数: int PyErr_WarnExplicitObject (PyObject *category, PyObject
          *message, PyObject *filename, int lineno, PyObject *module,
          PyObject *registry)

     すべての警告の属性を明示的に制御した警告メッセージを出します。これ
     は Python 関数 *note warnings.warn_explicit(): cce. の直接的なラッ
     パーで、さらに情報を得るにはそちらを参照してください。そこに説明さ
     れているデフォルトの効果を得るために、 'module' と 'registry' 引数
     は ‘NULL’ に設定することができます。

     Added in version 3.4.

 -- C の関数: int PyErr_WarnExplicit (PyObject *category, const char
          *message, const char *filename, int lineno, const char
          *module, PyObject *registry)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PyErr_WarnExplicitObject(): 497b. に似ていますが、 'message' と
     'module' が UTF-8 エンコードされた文字列であるところが異なり、
     'filename' は *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. でデコード
     されます。

 -- C の関数: int PyErr_WarnFormat (PyObject *category, Py_ssize_t
          stack_level, const char *format, ...)
     ' 次に属します: *note Stable ABI: 51e.'  *note PyErr_WarnEx():
     13f2. に似たような関数ですが、警告メッセージをフォーマットするのに
     *note PyUnicode_FromFormat(): 363. を使用します。 'format' は ASCII
     にエンコードされた文字列です。

     Added in version 3.2.

 -- C の関数: int PyErr_ResourceWarning (PyObject *source, Py_ssize_t
          stack_level, const char *format, ...)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.6 より).'
     Function similar to *note PyErr_WarnFormat(): 4843, but 'category'
     is *note ResourceWarning: 225. and it passes 'source' to
     ‘warnings.WarningMessage’.

     Added in version 3.6.


File: python.info,  Node: エラーインジケータの問い合わせ,  Next: シグナルハンドリング<2>,  Prev: 警告<3>,  Up: 例外処理

7.5.4 エラーインジケータの問い合わせ
------------------------------------

 -- C の関数: *note PyObject: 312. *PyErr_Occurred ()
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  エラー
     インジケータが設定されているかテストします。設定されている場合は、
     例外の '型' (‘PyErr_Set*’ 関数の一つあるいは *note PyErr_Restore():
     3cf. への最も新しい呼び出しに対する第一引数)を返します。設定されて
     いない場合は ‘NULL’ を返します。あなたは戻り値への参照を持っていま
     せんので、それに *note Py_DECREF(): 53b. する必要はありません。

     呼び出し側はGILを獲得する必要があります

          注釈: 戻り値を特定の例外と比較しないでください。その代わりに、
          下に示す *note PyErr_ExceptionMatches(): 47e0. を使ってくださ
          い。(比較は簡単に失敗するでしょう。なぜなら、例外はクラスでは
          なくインスタンスかもしれないし、あるいは、クラス例外の場合は期
          待される例外のサブクラスかもしれないからです。)

 -- C の関数: int PyErr_ExceptionMatches (PyObject *exc)
     ' 次に属します: *note Stable ABI: 51e.'
     ‘PyErr_GivenExceptionMatches(PyErr_Occurred(), exc)’ と同じ。例外が
     実際に設定されたときにだけ、これを呼び出だすべきです。例外が発生し
     ていないならば、メモリアクセス違反が起きるでしょう。

 -- C の関数: int PyErr_GivenExceptionMatches (PyObject *given, PyObject
          *exc)
     ' 次に属します: *note Stable ABI: 51e.'  例外 'given' が 'exc' の例
     外型と適合する場合に真を返します。 'exc' がクラスオブジェクトである
     場合も、 'given' がサブクラスのインスタンスであるときに真を返します
     。 'exc' がタプルの場合は、タプルにある (およびそのサブタプルに再帰
     的にある) すべての例外型が適合するか調べられます。

 -- C の関数: *note PyObject: 312. *PyErr_GetRaisedException (void)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.12 より).'  Return the exception currently being raised,
     clearing the error indicator at the same time.  Return ‘NULL’ if
     the error indicator is not set.

     This function is used by code that needs to catch exceptions, or
     code that needs to save and restore the error indicator
     temporarily.

     例えば:

          {
             PyObject *exc = PyErr_GetRaisedException();

             /* ... code that might produce other errors ... */

             PyErr_SetRaisedException(exc);
          }

     参考
     ....

     *note PyErr_GetHandledException(): 73a, to save the exception
     currently being handled.

     Added in version 3.12.

 -- C の関数: void PyErr_SetRaisedException (PyObject *exc)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Set 'exc' as the exception currently being raised, clearing the
     existing exception if one is set.

          警告: This call steals a reference to 'exc', which must be a
          valid exception.

     Added in version 3.12.

 -- C の関数: void PyErr_Fetch (PyObject **ptype, PyObject **pvalue,
          PyObject **ptraceback)
     ' 次に属します: *note Stable ABI: 51e.'

     バージョン 3.12 で非推奨: Use *note PyErr_GetRaisedException():
     3cd. instead.

     エラーインジケータをアドレスを渡す三つの変数の中へ取り出します。エ
     ラーインジケータが設定されていない場合は、三つすべての変数を ‘NULL’
     に設定します。エラーインジケータが設定されている場合はクリアされ、
     あなたは取り出されたそれぞれのオブジェクトへの参照を持つことになり
     ます。型オブジェクトが ‘NULL’ でないときでさえ、その値とトレースバ
     ックオブジェクトは ‘NULL’ かもしれません。

          注釈: This function is normally only used by legacy code that
          needs to catch exceptions or save and restore the error
          indicator temporarily.

          例えば:

               {
                  PyObject *type, *value, *traceback;
                  PyErr_Fetch(&type, &value, &traceback);

                  /* ... code that might produce other errors ... */

                  PyErr_Restore(type, value, traceback);
               }

 -- C の関数: void PyErr_Restore (PyObject *type, PyObject *value,
          PyObject *traceback)
     ' 次に属します: *note Stable ABI: 51e.'

     バージョン 3.12 で非推奨: Use *note PyErr_SetRaisedException():
     3d0. instead.

     Set the error indicator from the three objects, 'type', 'value',
     and 'traceback', clearing the existing exception if one is set.  If
     the objects are ‘NULL’, the error indicator is cleared.  Do not
     pass a ‘NULL’ type and non-‘NULL’ value or traceback.  The
     exception type should be a class.  Do not pass an invalid exception
     type or value.  (Violating these rules will cause subtle problems
     later.)  This call takes away a reference to each object: you must
     own a reference to each object before the call and after the call
     you no longer own these references.  (If you don't understand this,
     don't use this function.  I warned you.)

          注釈: This function is normally only used by legacy code that
          needs to save and restore the error indicator temporarily.
          Use *note PyErr_Fetch(): 3cc. to save the current error
          indicator.

 -- C の関数: void PyErr_NormalizeException (PyObject **exc, PyObject
          **val, PyObject **tb)
     ' 次に属します: *note Stable ABI: 51e.'

     バージョン 3.12 で非推奨: Use *note PyErr_GetRaisedException():
     3cd. instead, to avoid any possible de-normalization.

     ある状況では、以下の *note PyErr_Fetch(): 3cc. が返す値は "正規化さ
     れていない" 可能性があります。つまり、 ‘*exc’ はクラスオブジェクト
     だが ‘*val’ は同じクラスのインスタンスではないという意味です。この
     関数はそのような場合にそのクラスをインスタンス化するために使われま
     す。その値がすでに正規化されている場合は何も起きません。遅延正規化
     はパフォーマンスを改善するために実装されています。

          注釈: This function 'does not' implicitly set the *note
          __traceback__: 1296. attribute on the exception value.  If
          setting the traceback appropriately is desired, the following
          additional snippet is needed:

               if (tb != NULL) {
                 PyException_SetTraceback(val, tb);
               }

 -- C の関数: *note PyObject: 312. *PyErr_GetHandledException (void)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     Retrieve the active exception instance, as would be returned by
     *note sys.exception(): 657.  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.

          注釈: この関数は、通常は例外を扱うコードでは使用されません。正
          確に言うと、これは例外の状態を一時的に保存し、元に戻す必要があ
          るコードで使用することができます。例外の状態を元に戻す、もしく
          はクリアするには *note PyErr_SetHandledException(): 73b. を使
          ってください。

     Added in version 3.11.

 -- C の関数: void PyErr_SetHandledException (PyObject *exc)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     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’.

          注釈: この関数は、通常は例外を扱うコードでは使用されません。正
          確に言うと、これは例外の状態を一時的に保存し、元に戻す必要があ
          るコードで使用することができます。例外の状態を取得するには
          *note PyErr_GetHandledException(): 73a. を使ってください。

     Added in version 3.11.

 -- C の関数: void PyErr_GetExcInfo (PyObject **ptype, PyObject
          **pvalue, PyObject **ptraceback)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     Retrieve the old-style representation of the exception info, as
     known from *note sys.exc_info(): 656.  This refers to an exception
     that was 'already caught', not to an exception that was freshly
     raised.  Returns new references for the three objects, any of which
     may be ‘NULL’.  Does not modify the exception info state.  This
     function is kept for backwards compatibility.  Prefer using *note
     PyErr_GetHandledException(): 73a.

          注釈: この関数は、通常は例外を扱うコードでは使用されません。正
          確に言うと、これは例外の状態を一時的に保存し、元に戻す必要があ
          るコードで使用することができます。例外の状態を元に戻す、もしく
          はクリアするには *note PyErr_SetExcInfo(): 73c. を使ってくださ
          い。

     Added in version 3.3.

 -- C の関数: void PyErr_SetExcInfo (PyObject *type, PyObject *value,
          PyObject *traceback)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  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 raised.  This function steals the references of the
     arguments.  To clear the exception state, pass ‘NULL’ for all three
     arguments.  This function is kept for backwards compatibility.
     Prefer using *note PyErr_SetHandledException(): 73b.

          注釈: この関数は、通常は例外を扱うコードでは使用されません。正
          確に言うと、これは例外の状態を一時的に保存し、元に戻す必要があ
          るコードで使用することができます。例外の状態を取得するには
          *note PyErr_GetExcInfo(): 73d. を使ってください。

     Added in version 3.3.

     バージョン 3.11 で変更: 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
     steals references of all three arguments.


File: python.info,  Node: シグナルハンドリング<2>,  Next: 例外クラス<2>,  Prev: エラーインジケータの問い合わせ,  Up: 例外処理

7.5.5 シグナルハンドリング
--------------------------

 -- C の関数: int PyErr_CheckSignals ()
     ' 次に属します: *note Stable ABI: 51e.'

     This function interacts with Python's signal handling.

     If the function is called from the main thread and under the main
     Python interpreter, it checks whether a signal has been sent to the
     processes and if so, invokes the corresponding signal handler.  If
     the *note signal: b4. module is supported, this can invoke a signal
     handler written in Python.

     The function attempts to handle all pending signals, and then
     returns ‘0’.  However, if a Python signal handler raises an
     exception, the error indicator is set and the function returns ‘-1’
     immediately (such that other pending signals may not have been
     handled yet: they will be on the next *note PyErr_CheckSignals():
     433. invocation).

     If the function is called from a non-main thread, or under a
     non-main Python interpreter, it does nothing and returns ‘0’.

     This function can be called by long-running C code that wants to be
     interruptible by user requests (such as by pressing Ctrl-C).

          注釈: The default Python signal handler for ‘SIGINT’ raises
          the *note KeyboardInterrupt: 99f. exception.

 -- C の関数: void PyErr_SetInterrupt ()
     ' 次に属します: *note Stable ABI: 51e.'

     Simulate the effect of a ‘SIGINT’ signal arriving.  This is
     equivalent to ‘PyErr_SetInterruptEx(SIGINT)’.

          注釈: This function is async-signal-safe.  It can be called
          without the *note GIL: 13f. and from a C signal handler.

 -- C の関数: int PyErr_SetInterruptEx (int signum)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'

     シグナルが到達した効果をシミュレートします。 次に *note
     PyErr_CheckSignals(): 433. が呼ばれたとき、与えられたシグナル番号用
     の Python のシグナルハンドラが呼び出されます。

     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).

     If the given signal isn't handled by Python (it was set to *note
     signal.SIG_DFL: 178c. or *note signal.SIG_IGN: 178b.), it will be
     ignored.

     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.

          注釈: This function is async-signal-safe.  It can be called
          without the *note GIL: 13f. and from a C signal handler.

     Added in version 3.10.

 -- C の関数: int PySignal_SetWakeupFd (int fd)

     このユーティリティ関数は、シグナルを受け取ったときにシグナル番号を
     バイトとして書き込むファイル記述子を指定します。 'fd' はノンブロッ
     キングでなければなりません。 この関数は、1つ前のファイル記述子を返
     します。

     値 ‘-1’ を渡すと、この機能を無効にします; これが初期状態です。 この
     関数は Python の *note signal.set_wakeup_fd(): b3e. と同等ですが、
     どんなエラーチェックも行いません。 'fd' は有効なファイル記述子であ
     るべきです。 この関数はメインスレッドからのみ呼び出されるべきです。

     バージョン 3.5 で変更: Windowsで、この関数はソケットハンドルをサポ
     ートするようになりました。


File: python.info,  Node: 例外クラス<2>,  Next: 例外オブジェクト,  Prev: シグナルハンドリング<2>,  Up: 例外処理

7.5.6 例外クラス
----------------

 -- C の関数: *note PyObject: 312. *PyErr_NewException (const char
          *name, PyObject *base, PyObject *dict)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  この
     ユーティリティ関数は新しい例外クラスを作成して返します。 'name' 引
     数は新しい例外の名前、 ‘module.classname’ 形式の C文字列でなければ
     ならない。 'base' と 'dict' 引数は通常 ‘NULL’ です。これはすべての
     例外のためのルート、組み込み名 *note Exception: 9a7. (Cでは
     ‘PyExc_Exception’ としてアクセス可能)をルートとして派生したクラスオ
     ブジェクトを作成します。

     The *note __module__: 34d. 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 to the last part (after the last dot).  The
     'base' argument can be used to specify alternate base classes; it
     can either be only one class or a tuple of classes.  The 'dict'
     argument can be used to specify a dictionary of class variables and
     methods.

 -- C の関数: *note PyObject: 312. *PyErr_NewExceptionWithDoc (const
          char *name, const char *doc, PyObject *base, PyObject *dict)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     *note PyErr_NewException(): 123b. とほぼ同じですが、新しい例外クラ
     スに簡単に docstring を設定できます。 'doc' が ‘NULL’ で無い場合、
     それが例外クラスの docstring になります。

     Added in version 3.2.


File: python.info,  Node: 例外オブジェクト,  Next: Unicode 例外オブジェクト,  Prev: 例外クラス<2>,  Up: 例外処理

7.5.7 例外オブジェクト
----------------------

 -- C の関数: *note PyObject: 312. *PyException_GetTraceback (PyObject
          *ex)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Python で *note __traceback__: 1296. 属性からアクセスできるものと同
     じ、例外に関する traceback の新しい参照を返します。関係する
     traceback が無い場合は、 ‘NULL’ を返します。

 -- C の関数: int PyException_SetTraceback (PyObject *ex, PyObject *tb)
     ' 次に属します: *note Stable ABI: 51e.'  その例外に関する traceback
     に 'tb' をセットします。クリアするには ‘Py_None’ を使用してください
     。

 -- C の関数: *note PyObject: 312. *PyException_GetContext (PyObject
          *ex)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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 *note __context__:
     1297. attribute.  If there is no context associated, this returns
     ‘NULL’.

 -- C の関数: void PyException_SetContext (PyObject *ex, PyObject *ctx)
     ' 次に属します: *note Stable ABI: 51e.'  例外に関するコンテキストに
     'ctx' をセットします。クリアするには ‘NULL’ を使用してください。
     'ctx' が例外インスタンスかどうかを確かめる型チェックは行われません
     。これは 'ctx' への参照を盗みます。

 -- C の関数: *note PyObject: 312. *PyException_GetCause (PyObject *ex)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return the cause (either an exception instance, or ‘None’, set by
     ‘raise ... from ...’) associated with the exception as a new
     reference, as accessible from Python through the *note __cause__:
     1298. attribute.

 -- C の関数: void PyException_SetCause (PyObject *ex, PyObject *cause)
     ' 次に属します: *note Stable ABI: 51e.'  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 steals a reference to 'cause'.

     The *note __suppress_context__: 2013. attribute is implicitly set
     to ‘True’ by this function.

 -- C の関数: *note PyObject: 312. *PyException_GetArgs (PyObject *ex)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.12 より).'  Return *note args: 538. of exception 'ex'.

 -- C の関数: void PyException_SetArgs (PyObject *ex, PyObject *args)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Set *note args: 538. of exception 'ex' to 'args'.

 -- C の関数: *note PyObject: 312. *PyUnstable_Exc_PrepReraiseStar
          (PyObject *orig, PyObject *excs)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Implement part of the interpreter's implementation of ‘except*’.
     'orig' is the original exception that was caught, and 'excs' is the
     list of the exceptions that need to be raised.  This list contains
     the unhandled part of 'orig', if any, as well as the exceptions
     that were raised from the ‘except*’ clauses (so they have a
     different traceback from 'orig') and those that were reraised (and
     have the same traceback as 'orig').  Return the *note
     ExceptionGroup: 19b. that needs to be reraised in the end, or
     ‘None’ if there is nothing to reraise.

     Added in version 3.12.


File: python.info,  Node: Unicode 例外オブジェクト,  Next: 再帰の管理,  Prev: 例外オブジェクト,  Up: 例外処理

7.5.8 Unicode 例外オブジェクト
------------------------------

以下の関数は C言語から Unicode 例外を作ったり修正したりするために利用し
ます。

 -- C の関数: *note PyObject: 312. *PyUnicodeDecodeError_Create (const
          char *encoding, const char *object, Py_ssize_t length,
          Py_ssize_t start, Py_ssize_t end, const char *reason)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'encoding', 'object', 'length', 'start', 'end', 'reason' 属性をもっ
     た *note UnicodeDecodeError: 9e1. オブジェクトを作成します。
     'encoding' および 'reason' は UTF-8 エンコードされた文字列です。

 -- C の関数: *note PyObject: 312. *PyUnicodeDecodeError_GetEncoding
          (PyObject *exc)
 -- C の関数: *note PyObject: 312. *PyUnicodeEncodeError_GetEncoding
          (PyObject *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた例外オブジェクトの 'encoding' 属性を返します。

 -- C の関数: *note PyObject: 312. *PyUnicodeDecodeError_GetObject
          (PyObject *exc)
 -- C の関数: *note PyObject: 312. *PyUnicodeEncodeError_GetObject
          (PyObject *exc)
 -- C の関数: *note PyObject: 312. *PyUnicodeTranslateError_GetObject
          (PyObject *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた例外オブジェクトの 'object' 属性を返します。

 -- C の関数: int PyUnicodeDecodeError_GetStart (PyObject *exc,
          Py_ssize_t *start)
 -- C の関数: int PyUnicodeEncodeError_GetStart (PyObject *exc,
          Py_ssize_t *start)
 -- C の関数: int PyUnicodeTranslateError_GetStart (PyObject *exc,
          Py_ssize_t *start)
     ' 次に属します: *note Stable ABI: 51e.'  渡された例外オブジェクトか
     ら 'start' 属性を取得して '*start' に格納します。'start' は ‘NULL’
     であってはなりません。成功したら ‘0’ を、失敗したら ‘-1’ を返します
     。

 -- C の関数: int PyUnicodeDecodeError_SetStart (PyObject *exc,
          Py_ssize_t start)
 -- C の関数: int PyUnicodeEncodeError_SetStart (PyObject *exc,
          Py_ssize_t start)
 -- C の関数: int PyUnicodeTranslateError_SetStart (PyObject *exc,
          Py_ssize_t start)
     ' 次に属します: *note Stable ABI: 51e.'  渡された例外オブジェクトの
     'start' 属性を 'start' に設定します。成功したら ‘0’ を、失敗したら
     ‘-1’ を返します。

 -- C の関数: int PyUnicodeDecodeError_GetEnd (PyObject *exc, Py_ssize_t
          *end)
 -- C の関数: int PyUnicodeEncodeError_GetEnd (PyObject *exc, Py_ssize_t
          *end)
 -- C の関数: int PyUnicodeTranslateError_GetEnd (PyObject *exc,
          Py_ssize_t *end)
     ' 次に属します: *note Stable ABI: 51e.'  渡された例外オブジェクトか
     ら 'end' 属性を取得して '*end' に格納します。'end' は ‘NULL’ であっ
     てはなりません。成功したら ‘0’ を、失敗したら ‘-1’ を返します。

 -- C の関数: int PyUnicodeDecodeError_SetEnd (PyObject *exc, Py_ssize_t
          end)
 -- C の関数: int PyUnicodeEncodeError_SetEnd (PyObject *exc, Py_ssize_t
          end)
 -- C の関数: int PyUnicodeTranslateError_SetEnd (PyObject *exc,
          Py_ssize_t end)
     ' 次に属します: *note Stable ABI: 51e.'  渡された例外オブジェクトの
     'end' 属性を 'end' に設定します。成功したら ‘0’ を、失敗したら ‘-1’
     を返します。

 -- C の関数: *note PyObject: 312. *PyUnicodeDecodeError_GetReason
          (PyObject *exc)
 -- C の関数: *note PyObject: 312. *PyUnicodeEncodeError_GetReason
          (PyObject *exc)
 -- C の関数: *note PyObject: 312. *PyUnicodeTranslateError_GetReason
          (PyObject *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  渡さ
     れた例外オブジェクトの 'reason' 属性を返します。

 -- C の関数: int PyUnicodeDecodeError_SetReason (PyObject *exc, const
          char *reason)
 -- C の関数: int PyUnicodeEncodeError_SetReason (PyObject *exc, const
          char *reason)
 -- C の関数: int PyUnicodeTranslateError_SetReason (PyObject *exc,
          const char *reason)
     ' 次に属します: *note Stable ABI: 51e.'  渡された例外オブジェクトの
     'reason' 属性を 'reason' に設定します。成功したら ‘0’ を、失敗した
     ら ‘-1’ を返します。


File: python.info,  Node: 再帰の管理,  Next: 標準例外,  Prev: Unicode 例外オブジェクト,  Up: 例外処理

7.5.9 再帰の管理
----------------

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 recursive code does not necessarily invoke Python code (which tracks
its recursion depth automatically).  They are also not needed for
'tp_call' implementations because the *note call protocol: 54f. takes
care of recursion handling.

 -- C の関数: int Py_EnterRecursiveCall (const char *where)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.9 より).'  C レ
     ベルの再帰呼び出しをしようとしているところに印を付けます。

     If ‘USE_STACKCHECK’ is defined, this function checks if the OS
     stack overflowed using *note PyOS_CheckStack(): 1781.  If this is
     the case, it sets a *note MemoryError: 1627. and returns a nonzero
     value.

     次にこの関数は再帰の上限に達していないかをチェックします。 上限に達
     している場合、 *note RecursionError: d39. をセットしゼロでない値を
     返します。 そうでない場合はゼロを返します。

     'where' は ‘" in instance check"’ のような UTF-8 エンコードされた文
     字列にして、再帰の深さの限界に達したことで送出される *note
     RecursionError: d39. のメッセージに連結できるようにすべきです。

     バージョン 3.9 で変更: This function is now also available in the
     *note limited API: 36f.

 -- C の関数: void Py_LeaveRecursiveCall (void)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.9 より).'
     *note Py_EnterRecursiveCall(): 941. を終了させます。 *note
     Py_EnterRecursiveCall(): 941. の '成功した' 呼び出しに対し 1 回呼ば
     なければなりません。

     バージョン 3.9 で変更: This function is now also available in the
     *note limited API: 36f.

コンテナ型に対し *note tp_repr: 478f. を適切に実装するには、特殊な再帰の
処理が求められます。スタックの防護に加え、 *note tp_repr: 478f. は循環処
理を避けるためにオブジェクトを辿っていく必要があります。次の 2 つの関数
はその機能を容易にします。実質的には、これらは *note
reprlib.recursive_repr(): 11c4. と同等な C の実装です。

 -- C の関数: int Py_ReprEnter (PyObject *object)
     ' 次に属します: *note Stable ABI: 51e.'  循環処理を検知するために、
     *note tp_repr: 478f. の実装の先頭で呼び出します。

     そのオブジェクトが既に処理されたものだった場合、この関数は正の整数
     を返します。その場合、 *note tp_repr: 478f. の実装は、循環を示す文
     字列オブジェクトを返すべきです。例えば、 *note dict: 237. オブジェ
     クトは ‘{...}’ を返しますし、 *note list: 5dc. オブジェクトは
     ‘[...]’ を返します。

     再帰回数の上限に達した場合は、この関数は負の整数を返します。この場
     合、 *note tp_repr: 478f. の実装は一般的には ‘NULL’ を返すべきです
     。

     それ以外の場合は、関数はゼロを返し、 *note tp_repr: 478f. の実装は
     通常どおり処理を続けてかまいません。

 -- C の関数: void Py_ReprLeave (PyObject *object)
     ' 次に属します: *note Stable ABI: 51e.'  *note Py_ReprEnter():
     4933. を終了させます。 0 を返した *note Py_ReprEnter(): 4933. の呼
     び出しに対し 1 回呼ばなければなりません。


File: python.info,  Node: 標準例外,  Next: 標準警告カテゴリ,  Prev: 再帰の管理,  Up: 例外処理

7.5.10 標準例外
---------------

‘PyExc_’ の後ろにPythonの例外名が続く名前をもつグローバル変数として、す
べての標準Python例外が利用可能です。これらは型 *note PyObject: 312.* を
持ち、すべてクラスオブジェクトです。完璧を期するために、すべての変数を以
下に列挙します:

C名                                           Python名                              注釈
                                                                                    
---------------------------------------------------------------------------------------------------
                                                                                    
‘PyExc_BaseException’                         *note BaseException: 584.             (1)
                                                                                    
                                                                                    
‘PyExc_Exception’                             *note Exception: 9a7.                 (2)
                                                                                    
                                                                                    
‘PyExc_ArithmeticError’                       *note ArithmeticError: 21e2.          (3)
                                                                                    
                                                                                    
‘PyExc_AssertionError’                        *note AssertionError: 675.
                                              
                                                                                    
‘PyExc_AttributeError’                        *note AttributeError: 326.
                                              
                                                                                    
‘PyExc_BlockingIOError’                       *note BlockingIOError: 102b.
                                              
                                                                                    
‘PyExc_BrokenPipeError’                       *note BrokenPipeError: 1030.
                                              
                                                                                    
‘PyExc_BufferError’                           *note BufferError: 178f.
                                              
                                                                                    
‘PyExc_ChildProcessError’                     *note ChildProcessError: 102c.
                                              
                                                                                    
‘PyExc_ConnectionAbortedError’                *note ConnectionAbortedError: 1031.
                                              
                                                                                    
‘PyExc_ConnectionError’                       *note ConnectionError: dd7.
                                              
                                                                                    
‘PyExc_ConnectionRefusedError’                *note ConnectionRefusedError: 1032.
                                              
                                                                                    
‘PyExc_ConnectionResetError’                  *note ConnectionResetError: 1033.
                                              
                                                                                    
‘PyExc_EOFError’                              *note EOFError: 12a7.
                                              
                                                                                    
‘PyExc_FileExistsError’                       *note FileExistsError: fea.
                                              
                                                                                    
‘PyExc_FileNotFoundError’                     *note FileNotFoundError: e8f.
                                              
                                                                                    
‘PyExc_FloatingPointError’                    *note FloatingPointError: 21e3.
                                              
                                                                                    
‘PyExc_GeneratorExit’                         *note GeneratorExit: 136f.
                                              
                                                                                    
‘PyExc_ImportError’                           *note ImportError: 3f2.
                                              
                                                                                    
‘PyExc_IndentationError’                      *note IndentationError: 773.
                                              
                                                                                    
‘PyExc_IndexError’                            *note IndexError: 14de.
                                              
                                                                                    
‘PyExc_InterruptedError’                      *note InterruptedError: d55.
                                              
                                                                                    
‘PyExc_IsADirectoryError’                     *note IsADirectoryError: 102d.
                                              
                                                                                    
‘PyExc_KeyError’                              *note KeyError: 31d.
                                              
                                                                                    
‘PyExc_KeyboardInterrupt’                     *note KeyboardInterrupt: 99f.
                                              
                                                                                    
‘PyExc_LookupError’                           *note LookupError: 2131.              (4)
                                                                                    
                                                                                    
‘PyExc_MemoryError’                           *note MemoryError: 1627.
                                              
                                                                                    
‘PyExc_ModuleNotFoundError’                   *note ModuleNotFoundError: b15.
                                              
                                                                                    
‘PyExc_NameError’                             *note NameError: 40b.
                                              
                                                                                    
‘PyExc_NotADirectoryError’                    *note NotADirectoryError: 102e.
                                              
                                                                                    
‘PyExc_NotImplementedError’                   *note NotImplementedError: 209.
                                              
                                                                                    
‘PyExc_OSError’                               *note OSError: 3f0.                   (5)
                                                                                    
                                                                                    
‘PyExc_OverflowError’                         *note OverflowError: 84e.
                                              
                                                                                    
‘PyExc_PermissionError’                       *note PermissionError: d10.
                                              
                                                                                    
‘PyExc_ProcessLookupError’                    *note ProcessLookupError: 102f.
                                              
                                                                                    
‘PyExc_PythonFinalizationError’               *note PythonFinalizationError: 133.
                                              
                                                                                    
‘PyExc_RecursionError’                        *note RecursionError: d39.
                                              
                                                                                    
‘PyExc_ReferenceError’                        *note ReferenceError: 14b8.
                                              
                                                                                    
‘PyExc_RuntimeError’                          *note RuntimeError: 17a.
                                              
                                                                                    
‘PyExc_StopAsyncIteration’                    *note StopAsyncIteration: 1998.
                                              
                                                                                    
‘PyExc_StopIteration’                         *note StopIteration: bc8.
                                              
                                                                                    
‘PyExc_SyntaxError’                           *note SyntaxError: 172.
                                              
                                                                                    
‘PyExc_SystemError’                           *note SystemError: 541.
                                              
                                                                                    
‘PyExc_SystemExit’                            *note SystemExit: d0e.
                                              
                                                                                    
‘PyExc_TabError’                              *note TabError: 50e.
                                              
                                                                                    
‘PyExc_TimeoutError’                          *note TimeoutError: 800.
                                              
                                                                                    
‘PyExc_TypeError’                             *note TypeError: 502.
                                              
                                                                                    
‘PyExc_UnboundLocalError’                     *note UnboundLocalError: 14df.
                                              
                                                                                    
‘PyExc_UnicodeDecodeError’                    *note UnicodeDecodeError: 9e1.
                                              
                                                                                    
‘PyExc_UnicodeEncodeError’                    *note UnicodeEncodeError: 643.
                                              
                                                                                    
‘PyExc_UnicodeError’                          *note UnicodeError: 1275.
                                              
                                                                                    
‘PyExc_UnicodeTranslateError’                 *note UnicodeTranslateError: 21f9.
                                              
                                                                                    
‘PyExc_ValueError’                            *note ValueError: 1e3.
                                              
                                                                                    
‘PyExc_ZeroDivisionError’                     *note ZeroDivisionError: 913.
                                              

Added in version 3.3: ‘PyExc_BlockingIOError’ 、 ‘PyExc_BrokenPipeError’
、 ‘PyExc_ChildProcessError’ 、 ‘PyExc_ConnectionError’ 、
‘PyExc_ConnectionAbortedError’ 、 ‘PyExc_ConnectionRefusedError’ 、
‘PyExc_ConnectionResetError’ 、 ‘PyExc_FileExistsError’ 、
‘PyExc_FileNotFoundError’ 、 ‘PyExc_InterruptedError’ 、
‘PyExc_IsADirectoryError’ 、 ‘PyExc_NotADirectoryError’ 、
‘PyExc_PermissionError’ 、 ‘PyExc_ProcessLookupError’ 、
‘PyExc_TimeoutError’ は PEP 3151(6) により導入されました。

Added in version 3.5: ‘PyExc_StopAsyncIteration’ および
‘PyExc_RecursionError’ 。

Added in version 3.6: ‘PyExc_ModuleNotFoundError’.

これらは互換性のある ‘PyExc_OSError’ のエイリアスです:

C名                                       注釈
                                          
---------------------------------------------------------
                                          
‘PyExc_EnvironmentError’

‘PyExc_IOError’

‘PyExc_WindowsError’                      (7)
                                          

バージョン 3.3 で変更: これらのエイリアスは例外の種類を分けるために使わ
れます。

注釈:

   ---------- Footnotes ----------

   (1) これは別の標準例外のためのベースクラスです。

   (2) これは別の標準例外のためのベースクラスです。

   (3) これは別の標準例外のためのベースクラスです。

   (4) これは別の標準例外のためのベースクラスです。

   (5) これは別の標準例外のためのベースクラスです。

   (6) https://peps.python.org/pep-3151/

   (7) Windowsでのみ定義されています。プリプロセッサマクロ ‘MS_WINDOWS’
が定義されているかテストすることで、これを使うコードを保護してください。


File: python.info,  Node: 標準警告カテゴリ,  Prev: 標準例外,  Up: 例外処理

7.5.11 標準警告カテゴリ
-----------------------

‘PyExc_’ の後ろにPythonの例外名が続く名前をもつグローバル変数として、す
べての標準Python警告カテゴリが利用可能です。これらは型 *note PyObject:
312.* を持ち、すべてクラスオブジェクトです。完璧を期するために、すべての
変数を以下に列挙します:

C名                                            Python名                              注釈
                                                                                     
----------------------------------------------------------------------------------------------------
                                                                                     
‘PyExc_Warning’                                *note Warning: 220f.                  (1)
                                                                                     
                                                                                     
‘PyExc_BytesWarning’                           *note BytesWarning: bf1.
                                               
                                                                                     
‘PyExc_DeprecationWarning’                     *note DeprecationWarning: 18a.
                                               
                                                                                     
‘PyExc_FutureWarning’                          *note FutureWarning: 3ee.
                                               
                                                                                     
‘PyExc_ImportWarning’                          *note ImportWarning: 4c7.
                                               
                                                                                     
‘PyExc_PendingDeprecationWarning’              *note PendingDeprecationWarning: 895.
                                               
                                                                                     
‘PyExc_ResourceWarning’                        *note ResourceWarning: 225.
                                               
                                                                                     
‘PyExc_RuntimeWarning’                         *note RuntimeWarning: 1a2.
                                               
                                                                                     
‘PyExc_SyntaxWarning’                          *note SyntaxWarning: 432.
                                               
                                                                                     
‘PyExc_UnicodeWarning’                         *note UnicodeWarning: 13cb.
                                               
                                                                                     
‘PyExc_UserWarning’                            *note UserWarning: 2210.
                                               

Added in version 3.2: ‘PyExc_ResourceWarning’.

注釈:

   ---------- Footnotes ----------

   (1) これは別の標準警告カテゴリのためのベースクラスです。


File: python.info,  Node: ユーティリティ<2>,  Next: 抽象オブジェクトレイヤ Abstract Objects Layer,  Prev: 例外処理,  Up: Python/C API リファレンスマニュアル

7.6 ユーティリティ
==================

この章の関数は、C で書かれたコードをプラットフォーム間で可搬性のあるもの
にする上で役立つものから、C から Python モジュールを使うもの、そして関数
の引数を解釈したり、C の値から Python の値を構築するものまで、様々なユー
ティリティ的タスクを行います。

* Menu:

* オペレーティングシステム関連のユーティリティ::
* システム関数::
* プロセス制御::
* モジュールのインポート: モジュールのインポート<2>.
* データ整列化 (data marshalling) のサポート: データ整列化 data marshalling のサポート.
* 引数の解釈と値の構築::
* 文字列の変換と書式化::
* PyHash API::
* リフレクション::
* codec レジストリとサポート関数::
* PyTime C API::
* Support for Perf Maps::


File: python.info,  Node: オペレーティングシステム関連のユーティリティ,  Next: システム関数,  Up: ユーティリティ<2>

7.6.1 オペレーティングシステム関連のユーティリティ
--------------------------------------------------

 -- C の関数: *note PyObject: 312. *PyOS_FSPath (PyObject *path)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.6 より).'  Return the file system representation for
     'path'.  If the object is a *note str: 418. or *note bytes: 1a4.
     object, then a new *note strong reference: 316. is returned.  If
     the object implements the *note os.PathLike: c1f. interface, then
     *note __fspath__(): c20. is returned as long as it is a *note str:
     418. or *note bytes: 1a4. object.  Otherwise *note TypeError: 502.
     is raised and ‘NULL’ is returned.

     Added in version 3.6.

 -- C の関数: int Py_FdIsInteractive (FILE *fp, const char *filename)

     Return true (nonzero) if the standard I/O file 'fp' with name
     'filename' is deemed interactive.  This is the case for files for
     which ‘isatty(fileno(fp))’ is true.  If the *note
     PyConfig.interactive: 3a7. is non-zero, this function also returns
     true if the 'filename' pointer is ‘NULL’ or if the name is equal to
     one of the strings ‘'<stdin>'’ or ‘'???'’.

     This function must not be called before Python is initialized.

 -- C の関数: void PyOS_BeforeFork ()
     ' 次に属します: *note Stable ABI: 51e. on platforms with fork() (バ
     ージョン 3.7 より).'  プロセスがフォークする前に、いくつかの内部状
     態を準備するための関数です。‘fork()’ や現在のプロセスを複製するその
     他の類似の関数を呼び出す前にこの関数を呼びださなければなりません。
     ‘fork()’ が定義されているシステムでのみ利用できます。

          警告: The C ‘fork()’ call should only be made from the *note
          "main" thread: 498f. (of the *note "main" interpreter: 553.).
          The same is true for ‘PyOS_BeforeFork()’.

     Added in version 3.7.

 -- C の関数: void PyOS_AfterFork_Parent ()
     ' 次に属します: *note Stable ABI: 51e. on platforms with fork() (バ
     ージョン 3.7 より).'  プロセスがフォークした後に内部状態を更新する
     ための関数です。 ‘fork()’ や、現在のプロセスを複製するその他の類似
     の関数を呼び出した後に、プロセスの複製が成功したかどうかにかかわら
     ず、親プロセスからこの関数を呼び出さなければなりません。‘fork()’ が
     定義されているシステムでのみ利用できます。

          警告: The C ‘fork()’ call should only be made from the *note
          "main" thread: 498f. (of the *note "main" interpreter: 553.).
          The same is true for ‘PyOS_AfterFork_Parent()’.

     Added in version 3.7.

 -- C の関数: void PyOS_AfterFork_Child ()
     ' 次に属します: *note Stable ABI: 51e. on platforms with fork() (バ
     ージョン 3.7 より).'  Function to update internal interpreter state
     after a process fork.  This must be called from the child process
     after calling ‘fork()’, or any similar function that clones the
     current process, if there is any chance the process will call back
     into the Python interpreter.  Only available on systems where
     ‘fork()’ is defined.

          警告: The C ‘fork()’ call should only be made from the *note
          "main" thread: 498f. (of the *note "main" interpreter: 553.).
          The same is true for ‘PyOS_AfterFork_Child()’.

     Added in version 3.7.

     参考
     ....

     *note os.register_at_fork(): 2d7. を利用すると *note
     PyOS_BeforeFork(): b8d.、*note PyOS_AfterFork_Parent(): b8e. *note
     PyOS_AfterFork_Child(): 3d4. によって呼び出されるカスタムのPython関
     数を登録できます。

 -- C の関数: void PyOS_AfterFork ()
     ' 次に属します: *note Stable ABI: 51e. on platforms with fork().'  プ
     ロセスが fork した後の内部状態を更新するための関数です; fork 後
     Python インタプリタを使い続ける場合、新たなプロセス内でこの関数を呼
     び出さねばなりません。新たなプロセスに新たな実行可能物をロードする
     場合、この関数を呼び出す必要はありません。

     バージョン 3.7 で非推奨: この関数は *note PyOS_AfterFork_Child():
     3d4. によって置き換えられました。

 -- C の関数: int PyOS_CheckStack ()
     ' 次に属します: *note Stable ABI: 51e. on platforms with
     USE_STACKCHECK (バージョン 3.7 より).'

     Return true when the interpreter runs out of stack space.  This is
     a reliable check, but is only available when ‘USE_STACKCHECK’ is
     defined (currently on certain versions of Windows using the
     Microsoft Visual C++ compiler).  ‘USE_STACKCHECK’ will be defined
     automatically; you should never change the definition in your own
     code.

 -- C のデータ型: typedef void (*PyOS_sighandler_t)(int)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: *note PyOS_sighandler_t: 48a6. PyOS_getsig (int i)
     ' 次に属します: *note Stable ABI: 51e.'  Return the current signal
     handler for signal 'i'.  This is a thin wrapper around either
     ‘sigaction()’ or ‘signal()’.  Do not call those functions directly!

 -- C の関数: *note PyOS_sighandler_t: 48a6. PyOS_setsig (int i,
          PyOS_sighandler_t h)
     ' 次に属します: *note Stable ABI: 51e.'  Set the signal handler for
     signal 'i' to be 'h'; return the old signal handler.  This is a
     thin wrapper around either ‘sigaction()’ or ‘signal()’.  Do not
     call those functions directly!

 -- C の関数: wchar_t *Py_DecodeLocale (const char *arg, size_t *size)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
          警告: This function should not be called directly: use the
          *note PyConfig: 380. API with the *note
          PyConfig_SetBytesString(): 982. function which ensures that
          *note Python is preinitialized: 3bcb.

          This function must not be called before *note Python is
          preinitialized: 3bcb. and so that the LC_CTYPE locale is
          properly configured: see the *note Py_PreInitialize(): 3c5.
          function.

     *note ファイルシステムのエンコーディングとエラーハンドラ: 505. から
     バイト文字列をデコードします。エラーハンドラが *note
     surrogateescape エラーハンドラ: 233f. なら、 デコードできないバイト
     は U+DC80 から U+DCFF までの範囲の文字としてデコードされ、バイト列
     がサロゲート文字としてデコードできる場合は、デコードするのではなく
     surrogateescape エラーハンドラを使ってバイト列がエスケープされます
     。

     新しくメモリ確保されたワイドキャラクター文字列へのポインタを返しま
     す。 このメモリを解放するのには *note PyMem_RawFree(): 36c. を使っ
     てください。 引数 size が ‘NULL’ でない場合は、 null 文字以外のワイ
     ドキャラクターの数を ‘*size’ へ書き込みます。

     デコードもしくはメモリ確保でエラーが起きると ‘NULL’ を返します。
     'size' が ‘NULL’ でない場合は、メモリエラーのときは ‘(size_t)-1’ を
     、デコードでのエラーのときは ‘(size_t)-2’ を ‘*size’ に設定します。

     The *note filesystem encoding and error handler: 505. are selected
     by *note PyConfig_Read(): 75b.: see *note filesystem_encoding: 3c2.
     and *note filesystem_errors: 3c3. members of *note PyConfig: 380.

     C ライブラリーにバグがない限り、デコードでのエラーは起こりえません
     。

     キャラクター文字列をバイト文字列に戻すには *note Py_EncodeLocale():
     b96. 関数を使ってください。

     参考
     ....

     *note PyUnicode_DecodeFSDefaultAndSize(): 490c. および *note
     PyUnicode_DecodeLocaleAndSize(): b97. 関数。

     Added in version 3.5.

     バージョン 3.7 で変更: この関数は、*note Python UTF-8 Mode: 622. で
     はUTF-8エンコーディングを利用するようになりました。

     バージョン 3.8 で変更: The function now uses the UTF-8 encoding on
     Windows if *note PyPreConfig.legacy_windows_fs_encoding: 3c0. is
     zero;

 -- C の関数: char *Py_EncodeLocale (const wchar_t *text, size_t
          *error_pos)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  ワ
     イドキャラクター文字列を *note
     ファイルシステムのエンコーディングとエラーハンドラ: 505. にエンコー
     ドします。エラーハンドラが *note surrogateescape エラーハンドラ:
     233f. なら、 U+DC80 から U+DCFF までの範囲のサロゲート文字は 0x80 か
     ら 0xFF までのバイトに変換されます。

     新しくメモリ確保されたバイト文字列へのポインタを返します。 このメモ
     リを解放するのには *note PyMem_Free(): 13ea. を使ってください。 エ
     ンコードエラーかメモリ確保エラーのときは ‘NULL’ を返します。

     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.

     The *note filesystem encoding and error handler: 505. are selected
     by *note PyConfig_Read(): 75b.: see *note filesystem_encoding: 3c2.
     and *note filesystem_errors: 3c3. members of *note PyConfig: 380.

     バイト文字列をワイドキャラクター文字列に戻すには *note
     Py_DecodeLocale(): b95. 関数を使ってください。

          警告: This function must not be called before *note Python is
          preinitialized: 3bcb. and so that the LC_CTYPE locale is
          properly configured: see the *note Py_PreInitialize(): 3c5.
          function.

     参考
     ....

     *note PyUnicode_EncodeFSDefault(): 19bc. および *note
     PyUnicode_EncodeLocale(): b98. 関数。

     Added in version 3.5.

     バージョン 3.7 で変更: この関数は、*note Python UTF-8 Mode: 622. で
     はUTF-8エンコーディングを利用するようになりました。

     バージョン 3.8 で変更: The function now uses the UTF-8 encoding on
     Windows if *note PyPreConfig.legacy_windows_fs_encoding: 3c0. is
     zero.


File: python.info,  Node: システム関数,  Next: プロセス制御,  Prev: オペレーティングシステム関連のユーティリティ,  Up: ユーティリティ<2>

7.6.2 システム関数
------------------

*note sys: c3. モジュールが提供している機能にCのコードからアクセスする関
数です。すべての関数は現在のインタプリタスレッドの *note sys: c3. モジュ
ールの辞書に対して動作します。この辞書は内部のスレッド状態構造体に格納さ
れています。

 -- C の関数: *note PyObject: 312. *PySys_GetObject (const char *name)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  *note
     sys: c3. モジュールの 'name' オブジェクトを返すか、存在しなければ例
     外を設定せずに ‘NULL’ を返します。

 -- C の関数: int PySys_SetObject (const char *name, PyObject *v)
     ' 次に属します: *note Stable ABI: 51e.'  'v' が ‘NULL’ で無い場合、
     *note sys: c3. モジュールの 'name' に 'v' を設定します。 'v' が
     ‘NULL’ なら、 sys モジュールから 'name' を削除します。成功したら
     ‘0’ を、エラー時は ‘-1’ を返します。

 -- C の関数: void PySys_ResetWarnOptions ()
     ' 次に属します: *note Stable ABI: 51e.'  Reset *note
     sys.warnoptions: 38a. to an empty list.  This function may be
     called prior to *note Py_Initialize(): 87a.

     Deprecated since version 3.13, will be removed in version 3.15:
     Clear *note sys.warnoptions: 38a. and ‘warnings.filters’ instead.

 -- C の関数: void PySys_WriteStdout (const char *format, ...)
     ' 次に属します: *note Stable ABI: 51e.'  'format' で指定された出力
     文字列を *note sys.stdout: aa4. に出力します。切り詰めが起こった場
     合を含め、例外は一切発生しません (後述)。

     'format' は、フォーマット後の出力文字列のトータルの大きさを1000バイ
     ト以下に抑えるべきです。- 1000 バイト以降の出力文字列は切り詰められ
     ます。特に、制限のない "%s" フォーマットを使うべきではありません。
     "%.<N>s" のようにして N に10進数の値を指定し、<N> + その他のフォー
     マット後の最大サイズが1000を超えないように設定するべきです。同じよ
     うに "%f" にも気を付ける必要があります。非常に大きい数値に対して、
     数百の数字を出力する可能性があります。

     問題が発生したり、 *note sys.stdout: aa4. が設定されていなかった場
     合、フォーマット後のメッセージは本物の(Cレベルの) 'stdout' に出力さ
     れます。

 -- C の関数: void PySys_WriteStderr (const char *format, ...)
     ' 次に属します: *note Stable ABI: 51e.'  *note PySys_WriteStdout():
     48df. と同じですが、 *note sys.stderr: 907. もしくは 'stderr' に出
     力します。

 -- C の関数: void PySys_FormatStdout (const char *format, ...)
     ' 次に属します: *note Stable ABI: 51e.'  PySys_WriteStdout() に似た
     関数ですが、 *note PyUnicode_FromFormatV(): 540. を使ってメッセージ
     をフォーマットし、メッセージを任意の長さに切り詰めたりはしません。

     Added in version 3.2.

 -- C の関数: void PySys_FormatStderr (const char *format, ...)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PySys_FormatStdout(): 48db. と同じですが、 *note sys.stderr: 907. も
     しくは 'stderr' に出力します。

     Added in version 3.2.

 -- C の関数: *note PyObject: 312. *PySys_GetXOptions ()
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e. (バージ
     ョン 3.7 より).'  *note sys._xoptions: 1ca9. と同様、 *note -X:
     15c. オプションの現在の辞書を返します。エラーが起きると、 ‘NULL’ が
     返され、例外がセットされます。

     Added in version 3.2.

 -- C の関数: int PySys_Audit (const char *event, const char *format,
          ...)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Raise an auditing event with any active hooks.  Return zero for
     success and non-zero with an exception set on failure.

     The 'event' string argument must not be 'NULL'.

     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 *note Py_BuildValue(): 875. are available.
     If the built value is not a tuple, it will be added into a
     single-element tuple.

     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.

     Note that ‘#’ format characters should always be treated as *note
     Py_ssize_t: a2e, regardless of whether ‘PY_SSIZE_T_CLEAN’ was
     defined.

     *note sys.audit(): 151a. performs the same function from Python
     code.

     See also *note PySys_AuditTuple(): 347.

     Added in version 3.8.

     バージョン 3.8.2 で変更: Require *note Py_ssize_t: a2e. for ‘#’
     format characters.  Previously, an unavoidable deprecation warning
     was raised.

 -- C の関数: int PySys_AuditTuple (const char *event, PyObject *args)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Similar to *note PySys_Audit(): 348, but pass arguments as a Python
     object.  'args' must be a *note tuple: 349.  To pass no arguments,
     'args' can be 'NULL'.

     Added in version 3.13.

 -- C の関数: int PySys_AddAuditHook (Py_AuditHookFunction hook, void
          *userData)

     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.

     'userData' ポインタはフック関数に渡されます。 フック関数は別なラン
     タイムから呼び出されるかもしれないので、このポインタは直接 Python の
     状態を参照すべきではありません。

     This function is safe to call before *note Py_Initialize(): 87a.
     When called after runtime initialization, existing audit hooks are
     notified and may silently abort the operation by raising an error
     subclassed from *note Exception: 9a7. (other errors will not be
     silenced).

     The hook function is always called with the GIL held by the Python
     interpreter that raised the event.

     See PEP 578(1) for a detailed description of auditing.  Functions
     in the runtime and standard library that raise events are listed in
     the *note audit events table: 17db.  Details are in each function's
     documentation.

     If the interpreter is initialized, this function raises an auditing
     event ‘sys.addaudithook’ with no arguments.  If any existing hooks
     raise an exception derived from *note Exception: 9a7, the new hook
     will not be added and the exception is cleared.  As a result,
     callers cannot assume that their hook has been added unless they
     control all existing hooks.

      -- C のデータ型: typedef int (*Py_AuditHookFunction)(const char
               *event, *note PyObject: 312. *args, void *userData)

          The type of the hook function.  'event' is the C string event
          argument passed to *note PySys_Audit(): 348. or *note
          PySys_AuditTuple(): 347.  'args' is guaranteed to be a *note
          PyTupleObject: 4993.  'userData' is the argument passed to
          PySys_AddAuditHook().

     Added in version 3.8.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0578/


File: python.info,  Node: プロセス制御,  Next: モジュールのインポート<2>,  Prev: システム関数,  Up: ユーティリティ<2>

7.6.3 プロセス制御
------------------

 -- C の関数: void Py_FatalError (const char *message)
     ' 次に属します: *note Stable ABI: 51e.'

     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 make it dangerous to continue using the
     Python interpreter; e.g., when the object administration appears to
     be corrupted.  On Unix, the standard C library function ‘abort()’
     is called which will attempt to produce a ‘core’ file.

     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.

     バージョン 3.9 で変更: Log the function name automatically.

 -- C の関数: void Py_Exit (int status)
     ' 次に属します: *note Stable ABI: 51e.'

     現在のプロセスを終了します。*note Py_FinalizeEx(): ce3. を呼び出し
     た後、標準Cライブラリ関数の ‘exit(status)’ を呼び出します。*note
     Py_FinalizeEx(): ce3. がエラーになった場合、終了ステータスは 120に
     設定されます。

     バージョン 3.6 で変更: 終了処理のエラーは無視されなくなりました。

 -- C の関数: int Py_AtExit (void (*func)())
     ' 次に属します: *note Stable ABI: 51e.'

     *note Py_FinalizeEx(): ce3. から呼び出される後始末処理を行う関数
     (cleanup function) を登録します。後始末関数は引数無しで呼び出され、
     値を返しません。最大で 32 の後始末処理関数を登録できます。登録に成
     功すると、 *note Py_AtExit(): 4928. は ‘0’ を返します; 失敗すると
     ‘-1’ を返します。最後に登録した後始末処理関数から先に呼び出されます
     。各関数は高々一度しか呼び出されません。 Python の内部的な終了処理
     は後始末処理関数より以前に完了しているので、 'func' からはいかなる
     Python API も呼び出してはなりません。


File: python.info,  Node: モジュールのインポート<2>,  Next: データ整列化 data marshalling のサポート,  Prev: プロセス制御,  Up: ユーティリティ<2>

7.6.4 モジュールのインポート
----------------------------

 -- C の関数: *note PyObject: 312. *PyImport_ImportModule (const char
          *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     This is a wrapper around *note PyImport_Import(): 13a4. which takes
     a const char* as an argument instead of a *note PyObject: 312.*.

 -- C の関数: *note PyObject: 312. *PyImport_ImportModuleNoBlock (const
          char *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  この
     関数は、 *note PyImport_ImportModule(): 398. の廃止予定のエイリアス
     です。

     バージョン 3.3 で変更: この関数は、従来は別のスレッドによってインポ
     ートロックが行われていた場合は即座に失敗していました。しかし Python
     3.3 では、大部分の目的でロックスキームがモジュールごとのロックに移
     行したので、この関数の特別な振る舞いはもはや必要ではありません。

     Deprecated since version 3.13, will be removed in version 3.15: Use
     *note PyImport_ImportModule(): 398. instead.

 -- C の関数: *note PyObject: 312. *PyImport_ImportModuleEx (const char
          *name, PyObject *globals, PyObject *locals, PyObject
          *fromlist)
     '戻り値: 新しい参照。'

     モジュールをインポートします。モジュールのインポートについては組み
     込みの Python 関数 *note __import__(): 8a2. を読むとよくわかります
     。

     戻り値は、インポートされたモジュールかトップレベルパッケージへの新
     しい参照か、失敗した場合は例外を設定して ‘NULL’ を返します。 *note
     __import__(): 8a2. と同じように、パッケージのサブモジュールが要求さ
     れたときは、空でない 'fromlist' を渡された時以外は、トップレベルの
     パッケージを返します。

     インポートが失敗した場合は、*note PyImport_ImportModule(): 398. と
     同様に不完全なモジュールのオブジェクトを削除します。

 -- C の関数: *note PyObject: 312. *PyImport_ImportModuleLevelObject
          (PyObject *name, PyObject *globals, PyObject *locals, PyObject
          *fromlist, int level)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  モジュールをインポートします。モジュールのイン
     ポートについては組み込みの Python 関数 *note __import__(): 8a2. を
     読むとよく分かります。というのも、標準の *note __import__(): 8a2. は
     この関数を直接呼び出しているからです。

     戻り値は、インポートされたモジュールかトップレベルパッケージへの新
     しい参照か、失敗した場合は例外を設定して ‘NULL’ を返します。 *note
     __import__(): 8a2. と同じように、パッケージのサブモジュールが要求さ
     れたときは、空でない 'fromlist' を渡された時以外は、トップレベルの
     パッケージを返します。

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyImport_ImportModuleLevel (const
          char *name, PyObject *globals, PyObject *locals, PyObject
          *fromlist, int level)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     *note PyImport_ImportModuleLevelObject(): 485f. と似ていますが、
     name が Unicode オブジェクトではなく UTF-8 でエンコードされた文字列
     である点で異なります。

     バージョン 3.3 で変更: 'level' にはもはや負の値は使用できません。

 -- C の関数: *note PyObject: 312. *PyImport_Import (PyObject *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  現在
     の "インポートフック関数" を呼び出すための高水準のインターフェース
     です ('level' に 0 を明示すると、絶対インポートを意味します)。 この
     関数は現在のグローバル変数辞書内の ‘__builtins__’ から *note
     __import__(): 8a2. 関数を呼び出します。すなわち、現在の環境にインス
     トールされているインポートフック使ってインポートを行います。

     この関数は常に絶対インポートを使用します。

 -- C の関数: *note PyObject: 312. *PyImport_ReloadModule (PyObject *m)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  モジ
     ュールを再ロード (reload) します。戻り値は再ロードしたモジュールか
     トップレベルパッケージへの新たな参照になります。 失敗した場合には例
     外をセットし、‘NULL’ を返します (その場合でも、モジュールは生成され
     ている場合があります)。

 -- C の関数: *note PyObject: 312. *PyImport_AddModuleRef (const char
          *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.13 より).'  Return the module object corresponding to a
     module name.

     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.

     Return a *note strong reference: 316. to the module on success.
     Return ‘NULL’ with an exception set on failure.

     The module name 'name' is decoded from UTF-8.

     This function does not load or import the module; if the module
     wasn't already loaded, you will get an empty module object.  Use
     *note PyImport_ImportModule(): 398. or one of its variants to
     import a module.  Package structures implied by a dotted name for
     'name' are not created if not already present.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyImport_AddModuleObject (PyObject
          *name)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e. (バージ
     ョン 3.7 より).'  Similar to *note PyImport_AddModuleRef(): 331,
     but return a *note borrowed reference: 317. and 'name' is a Python
     *note str: 418. object.

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyImport_AddModule (const char
          *name)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'
     Similar to *note PyImport_AddModuleRef(): 331, but return a *note
     borrowed reference: 317.

 -- C の関数: *note PyObject: 312. *PyImport_ExecCodeModule (const char
          *name, PyObject *co)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     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 function *note compile(): 177, load the module.  Return a
     new reference to the module object, or ‘NULL’ with an exception set
     if an error occurred.  'name' is removed from *note sys.modules:
     18d6. in error cases, even if 'name' was already in *note
     sys.modules: 18d6. on entry to *note PyImport_ExecCodeModule():
     4857.  Leaving incompletely initialized modules in *note
     sys.modules: 18d6. is dangerous, as imports of such modules have no
     way to know that the module object is an unknown (and probably
     damaged with respect to the module author's intents) state.

     The module's *note __spec__: 1e77. and *note __loader__: 2c3. will
     be set, if not set already, with the appropriate values.  The
     spec's loader will be set to the module's ‘__loader__’ (if set) and
     to an instance of *note SourceFileLoader: 1049. otherwise.

     The module's *note __file__: 1e7d. attribute will be set to the
     code object's *note co_filename: 1335.  If applicable, *note
     __cached__: 2b7. will also be set.

     この関数は、すでにインポートされているモジュールの場合には再ロード
     を行います。意図的にモジュールの再ロードを行う方法は *note
     PyImport_ReloadModule(): 4860. を参照してください。

     'name' が ‘package.module’ 形式のドット名表記であった場合、まだ作成
     されていないパッケージ構造はその作成されないままになります。

     *note PyImport_ExecCodeModuleEx(): 4858. と *note
     PyImport_ExecCodeModuleWithPathnames(): 485a. も参照してください。

     バージョン 3.12 で変更: The setting of *note __cached__: 2b7. and
     *note __loader__: 2c3. is deprecated.  See *note ModuleSpec: 1dcb.
     for alternatives.

 -- C の関数: *note PyObject: 312. *PyImport_ExecCodeModuleEx (const
          char *name, PyObject *co, const char *pathname)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  Like
     *note PyImport_ExecCodeModule(): 4857, but the *note __file__:
     1e7d. attribute of the module object is set to 'pathname' if it is
     non-‘NULL’.

     *note PyImport_ExecCodeModuleWithPathnames(): 485a. も参照してくだ
     さい。

 -- C の関数: *note PyObject: 312. *PyImport_ExecCodeModuleObject
          (PyObject *name, PyObject *co, PyObject *pathname, PyObject
          *cpathname)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  Like *note PyImport_ExecCodeModuleEx(): 4858,
     but the *note __cached__: 2b7. attribute of the module object is
     set to 'cpathname' if it is non-‘NULL’.  Of the three functions,
     this is the preferred one to use.

     Added in version 3.3.

     バージョン 3.12 で変更: Setting *note __cached__: 2b7. is
     deprecated.  See *note ModuleSpec: 1dcb. for alternatives.

 -- C の関数: *note PyObject: 312. *PyImport_ExecCodeModuleWithPathnames
          (const char *name, PyObject *co, const char *pathname, const
          char *cpathname)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     *note PyImport_ExecCodeModuleObject(): 4859. と似ていますが、
     'name' と 'pathname'、 'cpathname' が UTF-8 でエンコードされた文字
     列である点が異なります。もし 'pathname' が ‘NULL’ の場合、
     'cpathname' から、'pathname' どのような値になるべきかを知る試みもな
     されます。

     Added in version 3.2.

     バージョン 3.3 で変更: Uses ‘imp.source_from_cache()’ in
     calculating the source path if only the bytecode path is provided.

     バージョン 3.12 で変更: No longer uses the removed ‘imp’ module.

 -- C の関数: long PyImport_GetMagicNumber ()
     ' 次に属します: *note Stable ABI: 51e.'  Python バイトコードファイ
     ル (別名 ‘.pyc’ ファイル) のマジックナンバーを返します。マジックナ
     ンバーはバイトコードファイルの最初の4バイトに、リトルエンディアンバ
     イトオーダーで現れるべきです。エラーの場合は ‘-1’ を返します。

     バージョン 3.3 で変更: 失敗した場合は ‘-1’ の値を返します。

 -- C の関数: const char *PyImport_GetMagicTag ()
     ' 次に属します: *note Stable ABI: 51e.'  マジックタグ文字列を
     Python バイトコードファイル名の PEP 3147(1) フォーマットで返します
     。‘sys.implementation.cache_tag’ の値が信頼でき、かつこの関数の代わ
     りに使用すべきであることを肝に命じましょう。

     Added in version 3.2.

 -- C の関数: *note PyObject: 312. *PyImport_GetModuleDict ()
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  モジュ
     ール管理のための辞書 (いわゆる ‘sys.modules’)を返します。この辞書は
     インタプリタごとに一つだけある変数なので注意してください。

 -- C の関数: *note PyObject: 312. *PyImport_GetModule (PyObject *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.8 より).'  与えられた名前の既にインポート済みのモジュール
     を返します。 モジュールがインポートされていなかった場合は、 ‘NULL’
     を返しますが、エラーはセットしません。 モジュールの検索に失敗した場
     合は、 ‘NULL’ を返し、エラーをセットします。

     Added in version 3.7.

 -- C の関数: *note PyObject: 312. *PyImport_GetImporter (PyObject
          *path)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return a finder object for a *note sys.path: 38e./‘pkg.__path__’
     item 'path', possibly by fetching it from the *note
     sys.path_importer_cache: 5ae. dict.  If it wasn't yet cached,
     traverse *note sys.path_hooks: fee. until a hook is found that can
     handle the path item.  Return ‘None’ if no hook could; this tells
     our caller that the *note path based finder: 1f59. could not find a
     finder for this path item.  Cache the result in *note
     sys.path_importer_cache: 5ae.  Return a new reference to the finder
     object.

 -- C の関数: int PyImport_ImportFrozenModuleObject (PyObject *name)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     'name' という名前のフリーズ (freeze) されたモジュールをロードします
     。成功すると ‘1’ を、モジュールが見つからなかった場合には ‘0’ を、
     初期化が失敗した場合には例外をセットして ‘-1’ を返します。ロードに
     成功したモジュールにアクセスするには *note PyImport_ImportModule():
     398. を使ってください。 (Note この関数はいささか誤解を招く名前です
     -- この関数はモジュールがすでにインポートされていたらリロードしてし
     まいます。)

     Added in version 3.3.

     バージョン 3.4 で変更: ‘__file__’ 属性はもうモジュールにセットされ
     ません。

 -- C の関数: int PyImport_ImportFrozenModule (const char *name)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PyImport_ImportFrozenModuleObject(): 485e. と似ていますが、name は
     UTF-8 でエンコードされた文字列の代わりに、 Unicode オブジェクトを使
     用する点が異なります。

 -- C Struct: struct _frozen

     ‘freeze’ ユーティリティが生成するようなフリーズ化モジュールデスクリ
     プタの構造体型定義です。 (Python ソース配布物の ‘Tools/freeze/’ を
     参照してください) この構造体の定義は ‘Include/import.h’ にあり、以
     下のようになっています:

          struct _frozen {
              const char *name;
              const unsigned char *code;
              int size;
              bool is_package;
          };

     バージョン 3.11 で変更: The new ‘is_package’ field indicates
     whether the module is a package or not.  This replaces setting the
     ‘size’ field to a negative value.

 -- C 変数: const struct *note _frozen: 740. *PyImport_FrozenModules

     このポインタは *note _frozen: 740. のレコードからなり、終端の要素の
     メンバが ‘NULL’ かゼロになっているような配列を指すよう初期化されま
     す。 フリーズされたモジュールをインポートするとき、このテーブルを検
     索します。 サードパーティ製のコードからこのポインタに仕掛けを講じて
     、動的に生成されたフリーズ化モジュールの集合を提供するようにできま
     す。

 -- C の関数: int PyImport_AppendInittab (const char *name, PyObject
          *(*initfunc)(void))
     ' 次に属します: *note Stable ABI: 51e.'  既存の組み込みモジュールテ
     ーブルに単一のモジュールを追加します。この関数は利便性を目的とした
     *note PyImport_ExtendInittab(): 170f. のラッパー関数で、テーブルが
     拡張できないときには ‘-1’ を返します。新たなモジュールは 'name' で
     インポートでき、最初にインポートを試みた際に呼び出される関数として
     'initfunc' を使います。 *note Py_Initialize(): 87a. よりも前に呼び
     出さなければなりません。

 -- C Struct: struct _inittab

     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 *note PyImport_ExtendInittab():
     170f. to provide additional built-in modules.  The structure
     consists of two members:

      -- C のメンバ変数: const char *name

          The module name, as an ASCII encoded string.

      -- C のメンバ変数: *note PyObject: 312. *(*initfunc)(void)

          Initialization function for a module built into the
          interpreter.

 -- C の関数: int PyImport_ExtendInittab (struct _inittab *newtab)

     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 *note name: 499a. field; failure to provide the sentinel
     value can result in a memory fault.  Returns ‘0’ on success or ‘-1’
     if insufficient memory could be allocated to extend the internal
     table.  In the event of failure, no modules are added to the
     internal table.  This must be called before *note Py_Initialize():
     87a.

     Python が複数回初期化される場合、*note PyImport_AppendInittab():
     170e. または *note PyImport_ExtendInittab(): 170f. は、それぞれの初
     期化の前に呼び出される必要があります。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3147/


File: python.info,  Node: データ整列化 data marshalling のサポート,  Next: 引数の解釈と値の構築,  Prev: モジュールのインポート<2>,  Up: ユーティリティ<2>

7.6.5 データ整列化 (data marshalling) のサポート
------------------------------------------------

以下のルーチン群は、 *note marshal: 80. モジュールと同じ形式を使った整列
化オブジェクトを C コードから使えるようにします。整列化形式でデータを書
き出す関数に加えて、データを読み戻す関数もあります。整列化されたデータを
記録するファイルはバイナリモードで開かれていなければなりません。

数値は最小桁が先にくるように記録されます。

The module supports two versions of the data format: version 0 is the
historical version, version 1 shares interned strings in the file, and
upon unmarshalling.  Version 2 uses a binary format for floating-point
numbers.  ‘Py_MARSHAL_VERSION’ indicates the current file format
(currently 2).

 -- C の関数: void PyMarshal_WriteLongToFile (long value, FILE *file,
          int version)

     long 型の整数値 'value' を 'file' へ整列化します。この関数は
     'value' の下桁 32 ビットを書き込むだけです; ネイティブの long 型サ
     イズには関知しません。 'version' はファイルフォーマットを示します。

     この関数は失敗することがあり、その場合はエラー指示子を設定します。
     それを確認するために *note PyErr_Occurred(): 185c. を使います。

 -- C の関数: void PyMarshal_WriteObjectToFile (PyObject *value, FILE
          *file, int version)

     Python オブジェクト 'value' を 'file' へ整列化します。'version' は
     ファイルフォーマットを示します。

     この関数は失敗することがあり、その場合はエラー指示子を設定します。
     それを確認するために *note PyErr_Occurred(): 185c. を使います。

 -- C の関数: *note PyObject: 312. *PyMarshal_WriteObjectToString
          (PyObject *value, int version)
     '戻り値: 新しい参照。' 'value' の整列化表現が入ったバイト列オブジェ
     クトを返します。'version' はファイルフォーマットを示します。

以下の関数を使うと、整列化された値を読み戻せます。

 -- C の関数: long PyMarshal_ReadLongFromFile (FILE *file)

     読み出し用に開かれた FILE* 内のデータストリームから、 C の long 型
     データを読み出して返します。この関数は、ネイティブの long のサイズ
     に関係なく、 32 ビットの値だけを読み出せます。

     エラーの場合、適切な例外 (*note EOFError: 12a7.) を設定し ‘-1’ を返
     します。

 -- C の関数: int PyMarshal_ReadShortFromFile (FILE *file)

     読み出し用に開かれた FILE* 内のデータストリームから、 C の short 型
     データを読み出して返します。この関数は、ネイティブの short のサイズ
     に関係なく、 16 ビットの値だけを読み出せます。

     エラーの場合、適切な例外 (*note EOFError: 12a7.) を設定し ‘-1’ を返
     します。

 -- C の関数: *note PyObject: 312. *PyMarshal_ReadObjectFromFile (FILE
          *file)
     '戻り値: 新しい参照。' 読み出し用に開かれた FILE* 内のデータストリ
     ームから Python オブジェクトを返します。

     エラーの場合、適切な例外 (*note EOFError: 12a7, *note ValueError:
     1e3, *note TypeError: 502.) を設定し ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyMarshal_ReadLastObjectFromFile
          (FILE *file)
     '戻り値: 新しい参照。' 読み出し用に開かれた FILE* 内のデータストリ
     ームから、 Python オブジェクトを読み出して返します。 *note
     PyMarshal_ReadObjectFromFile(): 49a1. と違い、この関数はファイル中
     に後続のオブジェクトが存在しないと仮定し、ファイルからメモリ上にフ
     ァイルデータを一気にメモリにロードして、逆整列化機構がファイルから
     一バイトづつ読み出す代わりにメモリ上のデータを操作できるようにしま
     す。対象のファイルから他に何も読み出さないと分かっている場合にのみ
     、この関数を使ってください。

     エラーの場合、適切な例外 (*note EOFError: 12a7, *note ValueError:
     1e3, *note TypeError: 502.) を設定し ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyMarshal_ReadObjectFromString
          (const char *data, Py_ssize_t len)
     '戻り値: 新しい参照。' 'data' が指す 'len' バイトのバイト列バッファ
     内のデータストリームから Python オブジェクトを返します。

     エラーの場合、適切な例外 (*note EOFError: 12a7, *note ValueError:
     1e3, *note TypeError: 502.) を設定し ‘NULL’ を返します。


File: python.info,  Node: 引数の解釈と値の構築,  Next: 文字列の変換と書式化,  Prev: データ整列化 data marshalling のサポート,  Up: ユーティリティ<2>

7.6.6 引数の解釈と値の構築
--------------------------

これらの関数は独自の拡張モジュール用の関数やメソッドを作成する際に便利で
す。詳しい情報や用例は *note Python インタプリタの拡張と埋め込み: 1b46.
にあります。

最初に説明する 3 つの関数、 *note PyArg_ParseTuple(): 53d, *note
PyArg_ParseTupleAndKeywords(): 35c,および *note PyArg_Parse(): 194f. は
いずれも '書式文字列 (format string)' を使います。書式文字列は、関数が受
け取るはずの引数に関する情報を伝えるのに用いられます。いずれの関数におけ
る書式文字列も、同じ書式を使っています。

* Menu:

* 引数を解析する: 引数を解析する<2>.
* 値の構築::


File: python.info,  Node: 引数を解析する<2>,  Next: 値の構築,  Up: 引数の解釈と値の構築

7.6.6.1 引数を解析する
......................

書式文字列は、ゼロ個またはそれ以上の "書式単位 (format unit)" から成り立
ちます。 1つの書式単位は1つの Python オブジェクトを表します; 通常は単一
の文字か、書式単位からなる文字列を括弧で囲ったものになります。例外として
、括弧で囲われていない書式単位文字列が単一のアドレス引数に対応する場合が
いくつかあります。以下の説明では、引用符のついた形式は書式単位です; (丸
)括弧で囲った部分は書式単位に対応する Python のオブジェクト型です; [角]
括弧は値をアドレス渡しする際に使う C の変数型です。

* Menu:

* 文字列とバッファ::
* 数: 数<2>.
* その他のオブジェクト::
* API 関数::


File: python.info,  Node: 文字列とバッファ,  Next: 数<2>,  Up: 引数を解析する<2>

7.6.6.2 文字列とバッファ
........................

     注釈: Python 3.12 以前では、以下で説明された全ての ‘#’ の種類
     (‘s#’, ‘y#’ など) を使用するために ‘PY_SSIZE_T_CLEAN’ マクロを
     ‘Python.h’ のインクルードの前に定義しなければなりません。これは
     Python 3.13 以降では不要です。

以下のフォーマットはオブジェクトに連続したメモリチャンクとしてアクセスす
るためのものです。返される unicode や bytes のために生のストレージを用意
する必要はありません。

特に言及されていない場合、バッファーは NUL 終端されていません。

There are three ways strings and buffers can be converted to C:

   * Formats such as ‘y*’ and ‘s*’ fill a *note Py_buffer: 723.
     structure.  This locks the underlying buffer so that the caller can
     subsequently use the buffer even inside a *note
     Py_BEGIN_ALLOW_THREADS: 4769. block without the risk of mutable
     data being resized or destroyed.  As a result, 'you have to call'
     *note PyBuffer_Release(): 374. after you have finished processing
     the data (or in any early abort case).

   * The ‘es’, ‘es#’, ‘et’ and ‘et#’ formats allocate the result buffer.
     'You have to call' *note PyMem_Free(): 13ea. after you have
     finished processing the data (or in any early abort case).

   * Other formats take a *note str: 418. or a read-only *note
     bytes-like object: cfb, such as *note bytes: 1a4, and provide a
     ‘const char *’ pointer to its buffer.  In this case the buffer is
     "borrowed": it is managed by the corresponding Python object, and
     shares the lifetime of this object.  You won't have to release any
     memory yourself.

     To ensure that the underlying buffer may be safely borrowed, the
     object's *note PyBufferProcs.bf_releasebuffer: 72e. field must be
     ‘NULL’.  This disallows common mutable objects such as *note
     bytearray: 508, but also some read-only objects such as *note
     memoryview: 435. of *note bytes: 1a4.

     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).

‘s’ (*note str: 418.) [const char *]

     Unicode オブジェクトを、キャラクタ文字列を指す C のポインタに変換し
     ます。キャラクタ型ポインタ変数のアドレスを渡すと、すでに存在してい
     る文字列へのポインタをその変数に記録します。C 文字列は NUL で終端さ
     れています。Python の文字列型は、 null コードポイントが途中に埋め込
     まれていてはなりません; もし埋め込まれていれば *note ValueError:
     1e3. 例外を送出します。Unicode オブジェクトは ‘'utf-8'’ を使って C
     文字列に変換されます。変換に失敗すると *note UnicodeError: 1275. を
     送出します。

          注釈: このフォーマットは *note bytes-like objects: cfb. をサポ
          ートしません。 ファイルシステムパスを受け取って C 言語の文字列
          に変換したい場合は、 ‘O&’ フォーマットを、 'converter' に
          *note PyUnicode_FSConverter(): ce7. を指定して利用すると良いで
          す。

     バージョン 3.5 で変更: 以前は Python 文字列に null コードポイントが
     埋め込まれていたときに *note TypeError: 502. を送出していました。

‘s*’ (*note str: 418. または *note bytes-like object: cfb.) [Py_buffer]

     このフォーマットは Unicode オブジェクトと bytes-like object を受け
     付けて、呼び出し元から渡された *note Py_buffer: 723. 構造体に値を格
     納します。 結果の C 文字列は NUL バイトを含むかもしれません。
     Unicode オブジェクトは ‘'utf-8'’ エンコーディングで C 文字列に変換
     されます。

‘s#’ (*note str: 418, 読み取り専用の *note bytes-like object: cfb.) [const char *, *note Py_ssize_t: a2e.]

     Like ‘s*’, except that it provides a *note borrowed buffer: 49a7.
     The result is stored into two C variables, the first one a pointer
     to a C string, the second one its length.  The string may contain
     embedded null bytes.  Unicode objects are converted to C strings
     using ‘'utf-8'’ encoding.

‘z’ (*note str: 418. または ‘None’) [const char *]

     ‘s’ に似ていますが、Python オブジェクトは ‘None’ でもよく、その場合
     には C のポインタは ‘NULL’ にセットされます。

‘z*’ (*note str: 418, *note bytes-like object: cfb. または ‘None’) [Py_buffer]

     ‘s*’ と同じですが、 Python の ‘None’ オブジェクトを受け取ることがで
     きます。その場合、 *note Py_buffer: 723. 構造体の ‘buf’ メンバーは
     ‘NULL’ になります。

‘z#’ (*note str: 418, 読み出し専用の *note bytes-like object: cfb. または ‘None’) [const char *, *note Py_ssize_t: a2e.]

     ‘s#’ に似ていますが、Python オブジェクトは ‘None’ でもよく、その場
     合には C のポインタは ‘NULL’ にセットされます。

‘y’ (読み出し専用の *note bytes-like object: cfb.) [const char *]

     This format converts a bytes-like object to a C pointer to a *note
     borrowed: 49a7. character string; it does not accept Unicode
     objects.  The bytes buffer must not contain embedded null bytes; if
     it does, a *note ValueError: 1e3. exception is raised.

     バージョン 3.5 で変更: 以前は bytes バッファにヌルバイトが埋め込ま
     れていたときに *note TypeError: 502. を送出していました。

‘y*’ (*note bytes-like object: cfb.) [Py_buffer]

     ‘s*’ の変形で、 Unicode オブジェクトを受け付けず、 bytes-like
     object のみを受け付けます。 'バイナリデータを受け付ける目的には、こ
     のフォーマットを使うことを推奨します。'

‘y#’ (読み出し専用の *note bytes-like object: cfb.) [const char *, *note Py_ssize_t: a2e.]

     ‘s#’ の変形で、 Unicode オブジェクトを受け付けず、bytes-like object
     だけを受け付けます。

‘S’ (*note bytes: 1a4.) [PyBytesObject *]

     Pythonオブジェクトとして、 *note bytes: 1a4. オブジェクトを要求し、
     いかなる変換も行いません。オブジェクトが bytes オブジェクトでなけれ
     ば、 *note TypeError: 502. を送出します。C 変数は *note PyObject:
     312.* と宣言しても構いません。

‘Y’ (*note bytearray: 508.) [PyByteArrayObject *]

     Python オブジェクトとして *note bytearray: 508. オブジェクトを要求
     し、いかなる変換もおこないません。 もしオブジェクトが *note
     bytearray: 508. でなければ、 *note TypeError: 502. を送出します。C
     変数は *note PyObject: 312.* として宣言しても構いません。

‘U’ (*note str: 418.) [PyObject *]

     Python オブジェクトとして Unicode オブジェクトを要求し、いかなる変
     換も行いません。オブジェクトが Unicode オブジェクトではない場合、
     *note TypeError: 502. が送出されます。C変数は *note PyObject: 312.*
     として宣言しても構いません。

‘w*’ (読み書き可能な *note bytes-like object: cfb.) [Py_buffer]

     このフォーマットは、読み書き可能な buffer interface を実装したオブ
     ジェクトを受け付けます。 呼び出し元から渡された *note Py_buffer:
     723. 構造体に値を格納します。バッファは nullバイトを含むかもしれず
     、呼び出し元はバッファを使い終わったら *note PyBuffer_Release():
     374. を呼び出さなければなりません。

‘es’ (*note str: 418.) [const char *encoding, char **buffer]

     これは ‘s’ の変化形で、Unicodeをキャラクタ型バッファにエンコードす
     るために用いられます。NULバイトが埋め込まれていないデータでのみ動作
     します。

     この書式には二つの引数が必要です。一つ目は入力にのみ用いられ、 NUL
     で終端されたエンコード名文字列を指す const char* 型または、
     ‘'utf-8'’ が使われることを表す ‘NULL’ でなければなりません。指定し
     たエンコード名を Python が理解できない場合には例外を送出します。第
     二の引数は char** でなければなりません; この引数が参照しているポイ
     ンタの値は、引数に指定したテキストの内容が入ったバッファへのポイン
     タになります。テキストは最初の引数に指定したエンコード方式でエンコ
     ードされます。

     *note PyArg_ParseTuple(): 53d. を使うと、必要なサイズのバッファを確
     保し、そのバッファにエンコード後のデータをコピーして、 '*buffer' が
     この新たに確保された記憶領域を指すように変更します。呼び出し側には
     、確保されたバッファを使い終わった後に *note PyMem_Free(): 13ea. で
     解放する責任があります。

‘et’ (*note str: 418, *note bytes: 1a4. または *note bytearray: 508.) [const char *encoding, char **buffer]

     ‘es’ と同じです。ただし、バイト文字列オブジェクトをエンコードし直さ
     ずに渡します。その代わり、実装ではバイト文字列オブジェクトがパラメ
     タに渡したエンコードを使っているものと仮定します。

‘es#’ (*note str: 418.) [const char *encoding, char **buffer, *note Py_ssize_t: a2e. *buffer_length]

     ‘s#’ の変化形で、Unicode をキャラクタ型バッファにエンコードするため
     に用いられます。‘es’ 書式違って、この変化形はバイトが埋め込まれてい
     てもかまいません。

     この書式には三つの引数が必要です。一つ目は入力にのみ用いられ、 NUL
     で終端されたエンコード名文字列を指す const char* 型か ‘NULL’ でなけ
     ればなりません。 ‘NULL’ の場合には ‘'utf-8'’ を使います。指定したエ
     ンコード名を Python が理解できない場合には例外を送出します。第二の
     引数は char** でなければなりません; この引数が参照しているポインタ
     の値は、引数に指定したテキストの内容が入ったバッファへのポインタに
     なります。テキストは最初の引数に指定したエンコード方式でエンコード
     されます。第三の引数は整数へのポインタでなければなりません; ポイン
     タが参照している整数の値は出力バッファ内のバイト数にセットされます
     。

     この書式の処理には二つのモードがあります:

     '*buffer' が ‘NULL’ ポインタを指している場合、関数は必要なサイズの
     バッファを確保し、そのバッファにエンコード後のデータをコピーして、
     '*buffer' がこの新たに確保された記憶領域を指すように変更します。呼
     び出し側には、確保されたバッファを使い終わった後に *note
     PyMem_Free(): 13ea. で解放する責任があります。

     '*buffer' が非 ‘NULL’ のポインタ (すでにメモリ確保済みのバッファ) を
     指している場合、 *note PyArg_ParseTuple(): 53d. はこのメモリ位置を
     バッファとして用い、 '*buffer_length' の初期値をバッファサイズとし
     て用います。 PyArg_ParseTuple は次にエンコード済みのデータをバッフ
     ァにコピーして、NUL で終端します。バッファの大きさが足りなければ
     *note ValueError: 1e3. がセットされます。

     どちらの場合も、 '*buffer_length' は終端の NUL バイトを含まないエン
     コード済みデータの長さにセットされます。

‘et#’ (*note str: 418, *note bytes: 1a4. または *note bytearray: 508.) [const char *encoding, char **buffer, *note Py_ssize_t: a2e. *buffer_length]

     ‘es#’ と同じです。ただし、バイト文字列オブジェクトをエンコードし直
     さずに渡します。その代わり、実装ではバイト文字列オブジェクトがパラ
     メタに渡したエンコードを使っているものと仮定します。

バージョン 3.12 で変更: ‘u’, ‘u#’, ‘Z’, and ‘Z#’ are removed because
they used a legacy ‘Py_UNICODE*’ representation.


File: python.info,  Node: 数<2>,  Next: その他のオブジェクト,  Prev: 文字列とバッファ,  Up: 引数を解析する<2>

7.6.6.3 数
..........

‘b’ (*note int: 238.) [unsigned char]

     Python の非負の整数を、 C の unsigned char 型の小さな符号無し整数に
     変換します。

‘B’ (*note int: 238.) [unsigned char]

     Python の整数を、オーバフローチェックを行わずに、 C の unsigned
     char 型の小さな整数に変換します。

‘h’ (*note int: 238.) [short int]

     Python の整数を、 C の short int 型に変換します。

‘H’ (*note int: 238.) [unsigned short int]

     Python の整数を、オーバフローチェックを行わずに、 C の unsigned
     short int 型に変換します。

‘i’ (*note int: 238.) [int]

     Python の整数を、 C の int 型に変換します。

‘I’ (*note int: 238.) [unsigned int]

     Python の整数を、オーバフローチェックを行わずに、 C の unsigned int
     型に変換します。

‘l’ (*note int: 238.) [long int]

     Python の整数を、 C の long int 型に変換します。

‘k’ (*note int: 238.) [unsigned long]

     Python の整数を、オーバフローチェックを行わずに、 C の unsigned
     long 型に変換します。

‘L’ (*note int: 238.) [long long]

     Python の整数を、 C の long long 型に変換します。

‘K’ (*note int: 238.) [unsigned long long]

     PythonのintをC unsigned long long へオーバーフローの確認をせず変換
     する

‘n’ (*note int: 238.) [*note Py_ssize_t: a2e.]

     Python の整数をCの *note Py_ssize_t: a2e. 型に変換します。

‘c’ (長さ 1 の、 *note bytes: 1a4. または *note bytearray: 508.) [char]

     長さ 1 の *note bytes: 1a4. または *note bytearray: 508. オブジェク
     トとして表現されている Python バイトを C の char 型に変換します。

     バージョン 3.3 で変更: *note bytearray: 508. を受け付けるようになり
     ました。

‘C’ (長さ 1 の *note str: 418.) [int]

     長さ 1 の *note str: 418. オブジェクトとして表現されている Python キ
     ャラクタを C の int 型に変換します。

‘f’ (*note float: 2ce.) [float]

     Convert a Python floating-point number to a C float.

‘d’ (*note float: 2ce.) [double]

     Convert a Python floating-point number to a C double.

‘D’ (*note complex: 2cf.) [Py_complex]

     Python の複素数型を、 C の *note Py_complex: 49a9. 構造体に変換しま
     す。


File: python.info,  Node: その他のオブジェクト,  Next: API 関数,  Prev: 数<2>,  Up: 引数を解析する<2>

7.6.6.4 その他のオブジェクト
............................

‘O’ (object) [PyObject *]

     Store a Python object (without any conversion) in a C object
     pointer.  The C program thus receives the actual object that was
     passed.  A new *note strong reference: 316. to the object is not
     created (i.e.  its reference count is not increased).  The pointer
     stored is not ‘NULL’.

‘O!’ (object) ['typeobject', PyObject *]

     Python オブジェクトを C の Python オブジェクト型ポインタに保存しま
     す。 ‘O’ に似ていますが、二つの C の引数をとります: 一つ目の引数は
     Python の型オブジェクトへのアドレスで、二つ目の引数はオブジェクトへ
     のポインタが保存されている (*note PyObject: 312.* の) C の変数への
     アドレスです。Python オブジェクトが指定した型ではない場合、 *note
     TypeError: 502. を送出します。

‘O&’ (object) ['converter', 'anything']

     Python オブジェクトを 'converter' 関数を介して C の変数に変換します
     。二つの引数をとります: 一つ目は関数で、二つ目は (任意の型の) C 変
     数へのアドレスを void* 型に変換したものです。 'converter' は以下の
     ようにして呼び出されます:

          status = converter(object, address);

     ここで 'object' は変換対象の Python オブジェクトで、 'address' は
     ‘PyArg_Parse*’ に渡した void* 型の引数です。戻り値 'status' は変換
     に成功した際に ‘1’,失敗した場合には ‘0’ になります。変換に失敗した
     場合、 'converter' 関数は 'address' の内容を変更せずに例外を送出し
     なくてはなりません。

     もし 'converter' が ‘Py_CLEANUP_SUPPORTED’ を返すと、引数のパースが
     失敗した際に、コンバーターをもう一度呼び出し、すでに割り当てたメモ
     リを開放するチャンスを与えます。二度目の呼び出しでは 'object' 引数
     は ‘NULL’ になり、'address' は最初の呼び出しと同じ値になります。

     バージョン 3.1 で変更: ‘Py_CLEANUP_SUPPORTED’ の追加。

‘p’ (*note bool: 434.) [int]

     真偽値が求められる箇所 (a boolean 'p'redicate) に渡された値を判定し
     、その結果を等価な C の true/false 整数値に変換します。 もし式が真
     なら int には ‘1’ が、偽なら ‘0’ が設定されます。この関数は任意の有
     効なPython値を受け付けます。 Pythonが値の真偽をどのように判定するか
     を知りたければ、 *note 真理値判定: 20c0. を参照してください。

     Added in version 3.3.

‘(items)’ (*note tuple: 349.) ['matching-items']

     オブジェクトは 'items' に入っている書式単位の数だけの長さを持つ
     Python のシーケンス型でなければなりません。各 C 引数は 'items' 内の
     個々の書式単位に対応づけできなければなりません。シーケンスの書式単
     位は入れ子構造にできます。

It is possible to pass "long" integers (integers whose value exceeds the
platform's ‘LONG_MAX’) however no proper range checking is done -- the
most significant bits are silently truncated when the receiving field is
too small to receive the value (actually, the semantics are inherited
from downcasts in C -- your mileage may vary).

その他、書式文字列において意味を持つ文字がいくつかあります。それらの文字
は括弧による入れ子内には使えません。以下に文字を示します:

‘|’

     Python 引数リスト中で、この文字以降の引数がオプションであることを示
     します。オプションの引数に対応する C の変数はデフォルトの値で初期化
     しておかなければなりません -- オプションの引数が省略された場合、
     *note PyArg_ParseTuple(): 53d. は対応する C 変数の内容に手を加えま
     せん。

‘$’

     *note PyArg_ParseTupleAndKeywords(): 35c. でのみ使用可能: 後続の
     Python引数がキーワード専用であることを示します。 現在、すべてのキー
     ワード専用引数は任意の引数でなければならず、そのため フォーマット文
     字列中の ‘|’ は常に ‘$’ より前に指定されなければなりません。

     Added in version 3.3.

‘:’

     この文字があると、書式単位の記述はそこで終わります; コロン以降の文
     字列は、エラーメッセージにおける関数名 (*note PyArg_ParseTuple():
     53d. が送出する例外の "付属値 (associated value)") として使われます
     。

‘;’

     この文字があると、書式単位の記述はそこで終わります; セミコロン以降
     の文字列は、デフォルトエラーメッセージを '置き換える' エラーメッセ
     ージとして使われます。 ‘:’ と ‘;’ は相互に排他の文字です。

Note that any Python object references which are provided to the caller
are 'borrowed' references; do not release them (i.e.  do not decrement
their reference count)!

以下の関数に渡す補助引数 (additional argument) は、書式文字列から決定さ
れる型へのアドレスでなければなりません; 補助引数に指定したアドレスは、タ
プルから入力された値を保存するために使います。上の書式単位のリストで説明
したように、補助引数を入力値として使う場合がいくつかあります; その場合、
対応する書式単位の指定する形式に従うようにしなければなりません。

変換を正しく行うためには、 'arg' オブジェクトは書式文字に一致しなければ
ならず、かつ書式文字列内の書式単位に全て値が入るようにしなければなりませ
ん。成功すると、 ‘PyArg_Parse*’ 関数は真を返します。それ以外の場合には偽
を返し、適切な例外を送出します。書式単位のどれかの変換失敗により
‘PyArg_Parse*’ が失敗した場合、失敗した書式単位に対応するアドレスとそれ
以降のアドレスの内容は変更されません。


File: python.info,  Node: API 関数,  Prev: その他のオブジェクト,  Up: 引数を解析する<2>

7.6.6.5 API 関数
................

 -- C の関数: int PyArg_ParseTuple (PyObject *args, const char *format,
          ...)
     ' 次に属します: *note Stable ABI: 51e.'  位置引数のみを引数にとる関
     数のパラメタを解釈して、ローカルな変数に変換します。成功すると真を
     返します;失敗すると偽を返し、適切な例外を送出します。

 -- C の関数: int PyArg_VaParse (PyObject *args, const char *format,
          va_list vargs)
     ' 次に属します: *note Stable ABI: 51e.'  *note PyArg_ParseTuple():
     53d. と同じですが、可変長の引数ではなく 'va_list' を引数にとります
     。

 -- C の関数: int PyArg_ParseTupleAndKeywords (PyObject *args, PyObject
          *kw, const char *format, char *const *keywords, ...)
     ' 次に属します: *note Stable ABI: 51e.'  Parse the parameters of a
     function that takes both positional and keyword parameters into
     local variables.  The 'keywords' argument is a ‘NULL’-terminated
     array of keyword parameter names specified as null-terminated ASCII
     or UTF-8 encoded C strings.  Empty names denote *note
     positional-only parameters: a53.  Returns true on success; on
     failure, it returns false and raises the appropriate exception.

          注釈: The 'keywords' parameter declaration is char *const* in
          C and const char *const* in C++.  This can be overridden with
          the *note PY_CXX_CONST: 35e. macro.

     バージョン 3.6 で変更: *note 位置専用引数: a53. を追加した。

     バージョン 3.13 で変更: The 'keywords' parameter has now type char
     *const* in C and const char *const* in C++, instead of char**.
     Added support for non-ASCII keyword parameter names.

 -- C の関数: int PyArg_VaParseTupleAndKeywords (PyObject *args,
          PyObject *kw, const char *format, char *const *keywords,
          va_list vargs)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PyArg_ParseTupleAndKeywords(): 35c. と同じですが、可変長の引数では
     なく 'va_list' を引数にとります。

 -- C の関数: int PyArg_ValidateKeywordArguments (PyObject*)
     ' 次に属します: *note Stable ABI: 51e.'  キーワード引数を格納した辞
     書のキーが文字列であることを確認します。この関数は *note
     PyArg_ParseTupleAndKeywords(): 35c. を使用しないときにのみ必要で、
     その理由は後者の関数は同様のチェックを実施するためです。

     Added in version 3.2.

 -- C の関数: int PyArg_Parse (PyObject *args, const char *format, ...)
     ' 次に属します: *note Stable ABI: 51e.'  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.

     以下はプログラム例です:

          // Function using METH_O calling convention
          static PyObject*
          my_function(PyObject *module, PyObject *arg)
          {
              int value;
              if (!PyArg_Parse(arg, "i:my_function", &value)) {
                  return NULL;
              }
              // ... use value ...
          }

 -- C の関数: int PyArg_UnpackTuple (PyObject *args, const char *name,
          Py_ssize_t min, Py_ssize_t max, ...)
     ' 次に属します: *note Stable ABI: 51e.'  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
     retrieve their parameters should be declared as *note METH_VARARGS:
     14b3. in function or method tables.  The tuple containing the
     actual parameters should be passed as 'args'; it must actually be a
     tuple.  The length of the tuple must be at least 'min' and no more
     than 'max'; 'min' and 'max' may be equal.  Additional arguments
     must be passed to the function, each of which should be a pointer
     to a *note PyObject: 312.* variable; these will be filled in with
     the values from 'args'; they will contain *note borrowed
     references: 317.  The variables which correspond to optional
     parameters not given by 'args' will not be filled in; these should
     be initialized by the caller.  This function returns true on
     success and false if 'args' is not a tuple or contains the wrong
     number of elements; an exception will be set if there was a
     failure.

     This is an example of the use of this function, taken from the
     sources for the ‘_weakref’ helper module for weak references:

          static PyObject *
          weakref_ref(PyObject *self, PyObject *args)
          {
              PyObject *object;
              PyObject *callback = NULL;
              PyObject *result = NULL;

              if (PyArg_UnpackTuple(args, "ref", 1, 2, &object, &callback)) {
                  result = PyWeakref_NewRef(object, callback);
              }
              return result;
          }

     この例における *note PyArg_UnpackTuple(): 14b1. 呼び出しは、 *note
     PyArg_ParseTuple(): 53d. を使った以下の呼び出しと全く等価です:

          PyArg_ParseTuple(args, "O|O:ref", &object, &callback)

 -- C のマクロ: PY_CXX_CONST

     The value to be inserted, if any, before char *const* in the
     'keywords' parameter declaration of *note
     PyArg_ParseTupleAndKeywords(): 35c. and *note
     PyArg_VaParseTupleAndKeywords(): 35d.  Default empty for C and
     ‘const’ for C++ (const char *const*).  To override, define it to
     the desired value before including ‘Python.h’.

     Added in version 3.13.


File: python.info,  Node: 値の構築,  Prev: 引数を解析する<2>,  Up: 引数の解釈と値の構築

7.6.6.6 値の構築
................

 -- C の関数: *note PyObject: 312. *Py_BuildValue (const char *format,
          ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     ‘PyArg_Parse*’ ファミリの関数が受け取るのと似た形式の書式文字列およ
     び値列に基づいて、新たな値を生成します。生成した値を返します。エラ
     ーの場合には ‘NULL’ を返します; ‘NULL’ を返す場合、例外を送出するで
     しょう。

     *note Py_BuildValue(): 875. は常にタプルを生成するとは限りません。
     この関数がタプルを生成するのは、書式文字列に二つ以上の書式単位が入
     っているときだけです。書式文字列が空の場合 ‘None’ を返します; 書式
     単位が厳密に一つだけ入っている場合、書式単位で指定されている何らか
     のオブジェクト単体を返します。サイズがゼロや 1 のタプルを返すように
     強制するには、丸括弧で囲われた書式文字列を使います。

     書式単位 ‘s’ や ‘s#’ の場合のように、オブジェクトを構築する際にデー
     タを供給するためにメモリバッファをパラメタとして渡す場合には、指定
     したデータはコピーされます。 *note Py_BuildValue(): 875. が生成した
     オブジェクトは、呼び出し側が提供したバッファを決して参照しません。
     別の言い方をすれば、 ‘malloc()’ を呼び出してメモリを確保し、それを
     *note Py_BuildValue(): 875. に渡した場合、コード内で *note
     Py_BuildValue(): 875. が返った後で ‘free()’ を呼び出す責任があると
     いうことです。

     以下の説明では、引用符のついた形式は書式単位です; (丸)括弧で囲った
     部分は書式単位が返す Python のオブジェクト型です; [角] 括弧は関数に
     渡す値の C 変数型です。

     書式文字列内では、(‘s#’ のような書式単位を除いて) スペース、タブ、
     コロンおよびコンマは無視されます。これらの文字を使うと、長い書式文
     字列をちょっとだけ読みやすくできます。

     ‘s’ (*note str: 418. または ‘None’) [const char *]

          null終端された C 文字列を、 ‘'utf-8'’ エンコーディングを用いて
          、 Python *note str: 418. オブジェクトに変換します。もし C 文
          字列ポインタが ‘NULL’ の場合、 ‘None’ になります。

     ‘s#’ (*note str: 418. or ‘None’) [const char *, *note Py_ssize_t: a2e.]

          C 文字列とその長さを ‘'utf-8'’ エンコーディングを使って Python
          *note str: 418. オブジェクトに変換します。C 文字列ポインタが
          ‘NULL’ の場合、長さは無視され、 ‘None’ になります。

     ‘y’ (*note bytes: 1a4.) [const char *]

          C 文字列をPython *note bytes: 1a4. オブジェクトに変換します。
          もしC 文字列ポインタが ‘NULL’ だった場合、‘None’ を返します。

     ‘y#’ (*note bytes: 1a4.) [const char *, *note Py_ssize_t: a2e.]

          これは C 文字列とその長さから Python オブジェクトに変換します
          。C 文字列ポインタが ‘NULL’ の場合、長さは無視され ‘None’ にな
          ります。

     ‘z’ (*note str: 418. または ‘None’) [const char *]

          ‘s’ と同じです。

     ‘z#’ (*note str: 418. または ‘None’) [const char *, *note Py_ssize_t: a2e.]

          ‘s#’ と同じです。

     ‘u’ (*note str: 418.) [const wchar_t *]

          null 終端された Unicode (UTF-16 または UCS-4) データの
          ‘wchar_t’ バッファから Python Unicode オブジェクトに変換します
          。 Unicode バッファポインタが ‘NULL’ の場合、 ‘None’ になりま
          す。

     ‘u#’ (*note str: 418.) [const wchar_t *, *note Py_ssize_t: a2e.]

          Unicode (UTF-16 または UCS-4) データのバッファとその長さから
          Python Unicode オブジェクトに変換します。 Unicode バッファポイ
          ンタが ‘NULL’ の場合、長さは無視され ‘None’ になります。

     ‘U’ (*note str: 418. または ‘None’) [const char *]

          ‘s’ と同じです。

     ‘U#’ (*note str: 418. または ‘None’) [const char *, *note Py_ssize_t: a2e.]

          ‘s#’ と同じです。

     ‘i’ (*note int: 238.) [int]

          通常の C の int を Python の整数オブジェクトに変換します。

     ‘b’ (*note int: 238.) [char]

          通常のC の char を Python の整数オブジェクトに変換します。

     ‘h’ (*note int: 238.) [short int]

          通常のC の short int を Python の整数オブジェクトに変換します
          。

     ‘l’ (*note int: 238.) [long int]

          C の long int を Python の整数オブジェクトに変換します。

     ‘B’ (*note int: 238.) [unsigned char]

          C の unsigned char を Python の整数オブジェクトに変換します。

     ‘H’ (*note int: 238.) [unsigned short int]

          C の unsigned short int を Python の整数オブジェクトに変換しま
          す。

     ‘I’ (*note int: 238.) [unsigned int]

          C の unsigned int を Python の整数オブジェクトに変換します。

     ‘k’ (*note int: 238.) [unsigned long]

          C の unsigned long を Python の整数オブジェクトに変換します。

     ‘L’ (*note int: 238.) [long long]

          C の long long を Python の整数オブジェクトに変換します。

     ‘K’ (*note int: 238.) [unsigned long long]

          C unsigned long long をPythonのintオブジェクトへ変換する。

     ‘n’ (*note int: 238.) [*note Py_ssize_t: a2e.]

          C の *note Py_ssize_t: a2e. を Python の整数オブジェクトに変換
          します。

     ‘c’ (長さが 1 の *note bytes: 1a4.) [char]

          バイトを表す通常の C の int を、長さ 1 の Python の *note
          bytes: 1a4. オブジェクトに変換します。

     ‘C’ (長さ 1 の *note str: 418.) [int]

          文字を表す通常の C の int を、長さ 1 の Python の *note str:
          418. オブジェクトに変換します。

     ‘d’ (*note float: 2ce.) [double]

          Convert a C double to a Python floating-point number.

     ‘f’ (*note float: 2ce.) [float]

          Convert a C float to a Python floating-point number.

     ‘D’ (*note complex: 2cf.) [Py_complex *]

          C の *note Py_complex: 49a9. 構造体を Python の複素数型に変換
          します。

     ‘O’ (object) [PyObject *]

          Pass a Python object untouched but create a new *note strong
          reference: 316. to it (i.e.  its reference count is
          incremented by one).  If the object passed in is a ‘NULL’
          pointer, it is assumed that this was caused because the call
          producing the argument found an error and set an exception.
          Therefore, *note Py_BuildValue(): 875. will return ‘NULL’ but
          won't raise an exception.  If no exception has been raised
          yet, *note SystemError: 541. is set.

     ‘S’ (object) [PyObject *]

          ‘O’ と同じです。

     ‘N’ (object) [PyObject *]

          Same as ‘O’, except it doesn't create a new *note strong
          reference: 316.  Useful when the object is created by a call
          to an object constructor in the argument list.

     ‘O&’ (object) ['converter', 'anything']

          'anything' を 'converter' 関数を介して Python オブジェクトに変
          換します。この関数は 'anything' (void* と互換の型でなければな
          りません) を引数にして呼び出され、"新たな" オブジェクトを返す
          か、失敗した場合には ‘NULL’ を返すようにしなければなりません。

     ‘(items)’ (*note tuple: 349.) ['matching-items']

          C の値からなる配列を、同じ要素数を持つ Python のタプルに変換し
          ます。

     ‘[items]’ (*note list: 5dc.) ['matching-items']

          C の値からなる配列を、同じ要素数を持つ Python のリストに変換し
          ます。

     ‘{items}’ (*note dict: 237.) ['matching-items']

          C の値からなる配列を Python の辞書に変換します。一連のペアから
          なる C の値が、それぞれキーおよび値となって辞書に追加されます
          。

     書式文字列に関するエラーが生じると、 *note SystemError: 541. 例外を
     セットして ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *Py_VaBuildValue (const char *format,
          va_list vargs)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     *note Py_BuildValue(): 875. と同じですが、可変長引数の代わりに
     va_list を受け取ります。


File: python.info,  Node: 文字列の変換と書式化,  Next: PyHash API,  Prev: 引数の解釈と値の構築,  Up: ユーティリティ<2>

7.6.7 文字列の変換と書式化
--------------------------

数値変換と、書式化文字列出力のための関数群。

 -- C の関数: int PyOS_snprintf (char *str, size_t size, const char
          *format, ...)
     ' 次に属します: *note Stable ABI: 51e.'  書式文字列 'format' と追加
     の引数から、 'size' バイトを超えない文字列を 'str' に出力します。
     Unix man page の ‘snprintf(3)(1)’ を参照してください。

 -- C の関数: int PyOS_vsnprintf (char *str, size_t size, const char
          *format, va_list va)
     ' 次に属します: *note Stable ABI: 51e.'  書式文字列 'format' と可変
     長引数リスト 'va' から、 'size' バイトを超えない文字列を 'str' に出
     力します。 Unix man page の ‘vsnprintf(3)(2)’ を参照してください。

*note PyOS_snprintf(): 14b4. と *note PyOS_vsnprintf(): 14b5. は標準Cラ
イブラリの ‘snprintf()’ と ‘vsnprintf()’ 関数をラップします。これらの関
数の目的は、C標準ライブラリが保証していないコーナーケースでの動作を保証
することです。

The wrappers ensure that ‘str[size-1]’ is always ‘'\0'’ upon return.
They never write more than 'size' bytes (including the trailing ‘'\0'’)
into str.  Both functions require that ‘str != NULL’, ‘size > 0’,
‘format != NULL’ and ‘size < INT_MAX’.  Note that this means there is no
equivalent to the C99 ‘n = snprintf(NULL, 0, ...)’ which would determine
the necessary buffer size.

これらの関数の戻り値 (以下では 'rv' とします) は以下の意味を持ちます:

   * ‘0 <= rv < size’ のとき、変換出力は成功して、(最後の ‘str[rv]’ にあ
     る ‘'\0'’ を除いて) 'rv' 文字が 'str' に出力された。

   * ‘rv >= size’ のとき、変換出力は切り詰められており、成功するためには
     ‘rv + 1’ バイトが必要だったことを示します。‘str[size-1]’ は ‘'\0'’
     です。

   * ‘rv < 0’ のときは、何か悪いことが起こった時です。この場合でも
     ‘str[size-1]’ は ‘'\0'’ ですが、'str' のそれ以外の部分は未定義です
     。エラーの正確な原因はプラットフォーム依存です。

以下の関数は locale 非依存な文字列から数値への変換を行ないます。

 -- C の関数: unsigned long PyOS_strtoul (const char *str, char **ptr,
          int base)
     ' 次に属します: *note Stable ABI: 51e.'  Convert the initial part
     of the string in ‘str’ to an unsigned long value according to the
     given ‘base’, which must be between ‘2’ and ‘36’ inclusive, or be
     the special value ‘0’.

     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 these are absent it defaults to ‘10’.  Base must be 0 or
     between 2 and 36 (inclusive).  If ‘ptr’ is non-‘NULL’ it will
     contain a pointer to the end of the scan.

     If the converted value falls out of range of corresponding return
     type, range error occurs (‘errno’ is set to ‘ERANGE’) and
     ‘ULONG_MAX’ is returned.  If no conversion can be performed, ‘0’ is
     returned.

     See also the Unix man page ‘strtoul(3)(3)’.

     Added in version 3.2.

 -- C の関数: long PyOS_strtol (const char *str, char **ptr, int base)
     ' 次に属します: *note Stable ABI: 51e.'  Convert the initial part
     of the string in ‘str’ to an long value according to the given
     ‘base’, which must be between ‘2’ and ‘36’ inclusive, or be the
     special value ‘0’.

     Same as *note PyOS_strtoul(): 48a8, but return a long value instead
     and ‘LONG_MAX’ on overflows.

     See also the Unix man page ‘strtol(3)(4)’.

     Added in version 3.2.

 -- C の関数: double PyOS_string_to_double (const char *s, char
          **endptr, PyObject *overflow_exception)
     ' 次に属します: *note Stable ABI: 51e.'  文字列 ‘s’ を double に変
     換します。失敗したときは Python の例外を発生させます。受け入れられ
     る文字列は、 Python の *note float(): 2ce. コンストラクタが受け付け
     る文字列に準拠しますが、 ‘s’ の先頭と末尾に空白文字があってはならな
     いという部分が異なります。この変換は現在のロケールに依存しません。

     ‘endptr’ が ‘NULL’ の場合、変換は文字列全体に対して行われます。文字
     列が正しい浮動小数点数の表現になっていない場合は ‘-1.0’ を返して
     *note ValueError: 1e3. を発生させます。

     endptr が ‘NULL’ で無い場合、文字列を可能な範囲で変換して、
     ‘*endptr’ に最初の変換されなかった文字へのポインタを格納します。文
     字列の先頭に正しい浮動小数点数の表現が無かった場合、‘*endptr’ を文
     字列の先頭に設定して、ValueError を発生させ、‘-1.0’ を返します。

     ‘s’ が float に格納し切れないほど大きい値を表現していた場合、(例え
     ば、‘"1e500"’ は多くのプラットフォームで表現できません)
     ‘overflow_exception’ が ‘NULL’ なら ‘Py_HUGE_VAL’ に適切な符号を付
     けて返します。他の場合は ‘overflow_exception’ は Python の例外オブ
     ジェクトへのポインタでなければならず、その例外を発生させて ‘-1.0’ を
     返します。どちらの場合でも、‘*endptr’ には変換された値の直後の最初
     の文字へのポインタが設定されます。

     それ以外のエラーが変換中に発生した場合(例えば out-of-memory エラー
     )、適切な Python の例外を設定して ‘-1.0’ を返します。

     Added in version 3.1.

 -- C の関数: char *PyOS_double_to_string (double val, char format_code,
          int precision, int flags, int *ptype)
     ' 次に属します: *note Stable ABI: 51e.'  double 'val' を指定された
     'format_code', 'precision', 'flags' に基づいて文字列に変換します。

     'format_code' は ‘'e'’, ‘'E'’, ‘'f'’, ‘'F'’, ‘'g'’, ‘'G'’, ‘'r'’ の
     どれかでなければなりません。 ‘'r'’ の場合、 'precision' は 0 でなけ
     ればならず、無視されます。 ‘'r'’ フォーマットコードは標準の *note
     repr(): 7c8. フォーマットを指定しています。

     'flags' は 0 か、 ‘Py_DTSF_SIGN’, ‘Py_DTSF_ADD_DOT_0’,
     ‘Py_DTSF_ALT’ か、これらの or を取ったものです:

        * ‘Py_DTSF_SIGN’ は、'val' が負で無いときも常に符号文字を先頭に
          つけることを意味します。

        * ‘Py_DTSF_ADD_DOT_0’ は文字列が整数のように見えないことを保証し
          ます。

        * ‘Py_DTSF_ALT’ は "alternate" フォーマットルールを適用すること
          を意味します。 詳細は *note PyOS_snprintf(): 14b4. の ‘'#'’ 指
          定を参照してください。

     'ptype' が ‘NULL’ で無い場合、'val' が有限数、無限数、NaNのどれかに
     合わせて、‘Py_DTST_FINITE’, ‘Py_DTST_INFINITE’, ‘Py_DTST_NAN’ のい
     ずれかに設定されます。

     戻り値は変換後の文字列が格納された 'buffer' へのポインタか、変換が
     失敗した場合は ‘NULL’ です。 呼び出し側は、返された文字列を *note
     PyMem_Free(): 13ea. を使って解放する責任があります。

     Added in version 3.1.

 -- C の関数: int PyOS_stricmp (const char *s1, const char *s2)

     Case insensitive comparison of strings.  The function works almost
     identically to ‘strcmp()’ except that it ignores the case.

 -- C の関数: int PyOS_strnicmp (const char *s1, const char *s2,
          Py_ssize_t size)

     Case insensitive comparison of strings.  The function works almost
     identically to ‘strncmp()’ except that it ignores the case.

   ---------- Footnotes ----------

   (1) https://manpages.debian.org/snprintf(3)

   (2) https://manpages.debian.org/vsnprintf(3)

   (3) https://manpages.debian.org/strtoul(3)

   (4) https://manpages.debian.org/strtol(3)


File: python.info,  Node: PyHash API,  Next: リフレクション,  Prev: 文字列の変換と書式化,  Up: ユーティリティ<2>

7.6.8 PyHash API
----------------

See also the *note PyTypeObject.tp_hash: 47a1. member and *note
数値型のハッシュ化: 2105.

 -- C のデータ型: type Py_hash_t

     Hash value type: signed integer.

     Added in version 3.2.

 -- C のデータ型: type Py_uhash_t

     Hash value type: unsigned integer.

     Added in version 3.2.

 -- C のマクロ: PyHASH_MODULUS

     The Mersenne prime(1) ‘P = 2**n -1’, used for numeric hash scheme.

     Added in version 3.13.

 -- C のマクロ: PyHASH_BITS

     The exponent ‘n’ of ‘P’ in *note PyHASH_MODULUS: 15cd.

     Added in version 3.13.

 -- C のマクロ: PyHASH_MULTIPLIER

     Prime multiplier used in string and various other hashes.

     Added in version 3.13.

 -- C のマクロ: PyHASH_INF

     The hash value returned for a positive infinity.

     Added in version 3.13.

 -- C のマクロ: PyHASH_IMAG

     The multiplier used for the imaginary part of a complex number.

     Added in version 3.13.

 -- C のデータ型: type PyHash_FuncDef

     Hash function definition used by *note PyHash_GetFuncDef(): 49b7.

      -- C のメンバ変数: const char *name

          Hash function name (UTF-8 encoded string).

      -- C のメンバ変数: const int hash_bits

          Internal size of the hash value in bits.

      -- C のメンバ変数: const int seed_bits

          Size of seed input in bits.

     Added in version 3.4.

 -- C の関数: *note PyHash_FuncDef: 49b6. *PyHash_GetFuncDef (void)

     Get the hash function definition.

     参考
     ....

     PEP 456(2) "Secure and interchangeable hash algorithm".

     Added in version 3.4.

 -- C の関数: *note Py_hash_t: 1235. Py_HashPointer (const void *ptr)

     Hash a pointer value: process the pointer value as an integer (cast
     it to ‘uintptr_t’ internally).  The pointer is not dereferenced.

     The function cannot fail: it cannot return ‘-1’.

     Added in version 3.13.

 -- C の関数: *note Py_hash_t: 1235. PyObject_GenericHash (PyObject
          *obj)

     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.

     'CPython 実装の詳細:' In CPython, it is equivalent to *note
     Py_HashPointer(): 341.

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Mersenne_prime

   (2) https://peps.python.org/pep-0456/


File: python.info,  Node: リフレクション,  Next: codec レジストリとサポート関数,  Prev: PyHash API,  Up: ユーティリティ<2>

7.6.9 リフレクション
--------------------

 -- C の関数: *note PyObject: 312. *PyEval_GetBuiltins (void)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'

     バージョン 3.13 で非推奨: Use *note PyEval_GetFrameBuiltins(): 329.
     instead.

     現在の実行フレーム内のビルトインの辞書か、もし実行中のフレームがな
     ければスレッド状態のインタプリタのビルトイン辞書を返します。

 -- C の関数: *note PyObject: 312. *PyEval_GetLocals (void)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'

     バージョン 3.13 で非推奨: Use either *note PyEval_GetFrameLocals():
     32d. to obtain the same behaviour as calling *note locals(): 127.
     in Python code, or else call *note PyFrame_GetLocals(): 3f8. on the
     result of *note PyEval_GetFrame(): 1727. to access the *note
     f_locals: 167. attribute of the currently executing frame.

     Return a mapping providing access to the local variables in the
     current execution frame, or ‘NULL’ if no frame is currently
     executing.

     Refer to *note locals(): 127. for details of the mapping returned
     at different scopes.

     As this function returns a *note borrowed reference: 317, the
     dictionary returned for *note optimized scopes: 163. is cached on
     the frame object and will remain alive as long as the frame object
     does.  Unlike *note PyEval_GetFrameLocals(): 32d. and *note
     locals(): 127, subsequent calls to this function in the same frame
     will update the contents of the cached dictionary to reflect
     changes in the state of the local variables rather than returning a
     new snapshot.

     バージョン 3.13 で変更: As part of PEP 667(1), *note
     PyFrame_GetLocals(): 3f8, *note locals(): 127, and *note
     FrameType.f_locals: 167. no longer make use of the shared cache
     dictionary.  Refer to the *note What's New entry: 128. for
     additional details.

 -- C の関数: *note PyObject: 312. *PyEval_GetGlobals (void)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'

     バージョン 3.13 で非推奨: Use *note PyEval_GetFrameGlobals(): 32b.
     instead.

     現在の実行フレーム内のグローバル変数の辞書か、実行中のフレームがな
     ければ ‘NULL’ を返します。

 -- C の関数: *note PyFrameObject: 754. *PyEval_GetFrame (void)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  現在の
     スレッド状態のフレームを返します。現在実行中のフレームがなければ
     ‘NULL’ を返します。

     See also *note PyThreadState_GetFrame(): 759.

 -- C の関数: *note PyObject: 312. *PyEval_GetFrameBuiltins (void)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.13 より).'  現在の実行フレーム内のビルトインの辞書か、もし
     実行中のフレームがなければスレッド状態のインタプリタのビルトイン辞
     書を返します。

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyEval_GetFrameLocals (void)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.13 より).'  Return a dictionary of the local variables in
     the current execution frame, or ‘NULL’ if no frame is currently
     executing.  Equivalent to calling *note locals(): 127. in Python
     code.

     To access *note f_locals: 167. on the current frame without making
     an independent snapshot in *note optimized scopes: 163, call *note
     PyFrame_GetLocals(): 3f8. on the result of *note PyEval_GetFrame():
     1727.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyEval_GetFrameGlobals (void)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.13 より).'  Return a dictionary of the global variables in
     the current execution frame, or ‘NULL’ if no frame is currently
     executing.  Equivalent to calling *note globals(): 17d2. in Python
     code.

     Added in version 3.13.

 -- C の関数: const char *PyEval_GetFuncName (PyObject *func)
     ' 次に属します: *note Stable ABI: 51e.'  'func' が関数、クラス、イ
     ンスタンスオブジェクトであればその名前を、そうでなければ 'func' の
     型を返します。

 -- C の関数: const char *PyEval_GetFuncDesc (PyObject *func)
     ' 次に属します: *note Stable ABI: 51e.'  'func' の型に依存する、解
     説文字列(description string)を返します。戻り値は、関数とメソッドに
     対しては "()", " constructor", " instance", " object" です。 *note
     PyEval_GetFuncName(): 4846. と連結された結果、 'func' の解説になり
     ます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0667/


File: python.info,  Node: codec レジストリとサポート関数,  Next: PyTime C API,  Prev: リフレクション,  Up: ユーティリティ<2>

7.6.10 codec レジストリとサポート関数
-------------------------------------

 -- C の関数: int PyCodec_Register (PyObject *search_function)
     ' 次に属します: *note Stable ABI: 51e.'  新しい codec 検索関数を登
     録します。

     副作用として、この関数は ‘encodings’ パッケージが常に検索関数の先頭
     に来るように、まだロードされていない場合はロードします。

 -- C の関数: int PyCodec_Unregister (PyObject *search_function)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Unregister a codec search function and clear the registry's cache.
     If the search function is not registered, do nothing.  Return 0 on
     success.  Raise an exception and return -1 on error.

     Added in version 3.10.

 -- C の関数: int PyCodec_KnownEncoding (const char *encoding)
     ' 次に属します: *note Stable ABI: 51e.'  'encoding' のための登録さ
     れた codec が存在するかどうかに応じて ‘1’ か ‘0’ を返します。 この
     関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyCodec_Encode (PyObject *object,
          const char *encoding, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  汎用
     の codec ベースの encode API.

     'encoding' に応じて見つかったエンコーダ関数に対して 'object' を渡し
     ます。 エラーハンドリングメソッドは 'errors' で指定します。
     'errors' は ‘NULL’ でもよく、その場合はその codec のデフォルトのメ
     ソッドが利用されます。 エンコーダが見つからなかった場合は *note
     LookupError: 2131. を発生させます。

 -- C の関数: *note PyObject: 312. *PyCodec_Decode (PyObject *object,
          const char *encoding, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  汎用
     の codec ベースのデコード API.

     'encoding' に応じて見つかったデコーダ関数に対して 'object' を渡しま
     す。 エラーハンドリングメソッドは 'errors' で指定します。 'errors'
     は ‘NULL’ でもよく、その場合はその codec のデフォルトのメソッドが利
     用されます。 デコーダが見つからなかった場合は *note LookupError:
     2131. を発生させます。

* Menu:

* コーデック検索API::
* Unicode エラーハンドラ用レジストリ API::


File: python.info,  Node: コーデック検索API,  Next: Unicode エラーハンドラ用レジストリ API,  Up: codec レジストリとサポート関数

7.6.10.1 コーデック検索API
..........................

次の関数では、文字列 'encoding' は全て小文字に変換することで、効率的に、
大文字小文字を無視した検索をします。 コーデックが見つからない場合、
*note KeyError: 31d. を設定して ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyCodec_Encoder (const char
          *encoding)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた 'encoding' のエンコーダ関数を返します。

 -- C の関数: *note PyObject: 312. *PyCodec_Decoder (const char
          *encoding)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた 'encoding' のデコーダ関数を返します。

 -- C の関数: *note PyObject: 312. *PyCodec_IncrementalEncoder (const
          char *encoding, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた 'encoding' の *note IncrementalEncoder: 2323. オブジェクトを
     返します。

 -- C の関数: *note PyObject: 312. *PyCodec_IncrementalDecoder (const
          char *encoding, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた 'encoding' の *note IncrementalDecoder: 2324. オブジェクトを
     返します。

 -- C の関数: *note PyObject: 312. *PyCodec_StreamReader (const char
          *encoding, PyObject *stream, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた 'encoding' の *note StreamReader: 2328. ファクトリ関数を返し
     ます。

 -- C の関数: *note PyObject: 312. *PyCodec_StreamWriter (const char
          *encoding, PyObject *stream, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた 'encoding' の *note StreamWriter: 2327. ファクトリ関数を返し
     ます。


File: python.info,  Node: Unicode エラーハンドラ用レジストリ API,  Prev: コーデック検索API,  Up: codec レジストリとサポート関数

7.6.10.2 Unicode エラーハンドラ用レジストリ API
...............................................

 -- C の関数: int PyCodec_RegisterError (const char *name, PyObject
          *error)
     ' 次に属します: *note Stable ABI: 51e.'  エラーハンドルのためのコー
     ルバック関数 'error' を 'name' で登録します。このコールバック関数は
     、コーデックがエンコードできない文字/デコードできないバイトに遭遇し
     た時に、そのエンコード/デコード関数の呼び出しで 'name' が指定されて
     いたら呼び出されます。

     コールバックは1つの引数として、 *note UnicodeEncodeError: 643,
     *note UnicodeDecodeError: 9e1, *note UnicodeTranslateError: 21f9. の
     どれかのインスタンスを受け取ります。このインスタンスは問題のある文
     字列やバイト列に関する情報と、その元の文字列中のオフセットを持って
     います。(その情報を取得するための関数については *note Unicode
     例外オブジェクト: 4982. を参照してください。) コールバックは渡され
     た例外を発生させるか、2要素のタプルに問題のシーケンスの代替と、
     encode/decode を再開する元の文字列中のオフセットとなる整数を格納し
     て返します。

     成功したら ‘0’ を、エラー時は ‘-1’ を返します。

 -- C の関数: *note PyObject: 312. *PyCodec_LookupError (const char
          *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'name' で登録されたエラーハンドリングコールバック関数を検索します。
     特別な場合として、‘NULL’ が渡された場合、"strict" のエラーハンドリ
     ングコールバック関数を返します。

 -- C の関数: *note PyObject: 312. *PyCodec_StrictErrors (PyObject *exc)
     '戻り値: 常に NULL 。'' 次に属します: *note Stable ABI: 51e.'
     'exc' を例外として発生させます。

 -- C の関数: *note PyObject: 312. *PyCodec_IgnoreErrors (PyObject *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     unicode エラーを無視し、問題の入力をスキップします。

 -- C の関数: *note PyObject: 312. *PyCodec_ReplaceErrors (PyObject
          *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     unicode エラーを ‘?’ か ‘U+FFFD’ で置き換えます。

 -- C の関数: *note PyObject: 312. *PyCodec_XMLCharRefReplaceErrors
          (PyObject *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     unicode encode エラーを XML文字参照で置き換えます。

 -- C の関数: *note PyObject: 312. *PyCodec_BackslashReplaceErrors
          (PyObject *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     unicode encode エラーをバックスラッシュエスケープ (‘\x’, ‘\u’,
     ‘\U’) で置き換えます。

 -- C の関数: *note PyObject: 312. *PyCodec_NameReplaceErrors (PyObject
          *exc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  unicode encode エラーを ‘\N{...}’ で置き換えま
     す。

     Added in version 3.5.


File: python.info,  Node: PyTime C API,  Next: Support for Perf Maps,  Prev: codec レジストリとサポート関数,  Up: ユーティリティ<2>

7.6.11 PyTime C API
-------------------

Added in version 3.13.

The clock C API provides access to system clocks.  It is similar to the
Python *note time: d7. module.

For C API related to the *note datetime: 28. module, see *note DateTime
オブジェクト: 49c3.

* Menu:

* Types::
* Clock Functions::
* Raw Clock Functions::
* Conversion functions::


File: python.info,  Node: Types,  Next: Clock Functions,  Up: PyTime C API

7.6.11.1 Types
..............

 -- C のデータ型: type PyTime_t

     A timestamp or duration in nanoseconds, represented as a signed
     64-bit integer.

     The reference point for timestamps depends on the clock used.  For
     example, *note PyTime_Time(): 30e. returns timestamps relative to
     the UNIX epoch.

     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:

 -- C 変数: *note PyTime_t: 306. PyTime_MIN

     Minimum value of *note PyTime_t: 306.

 -- C 変数: *note PyTime_t: 306. PyTime_MAX

     Maximum value of *note PyTime_t: 306.


File: python.info,  Node: Clock Functions,  Next: Raw Clock Functions,  Prev: Types,  Up: PyTime C API

7.6.11.2 Clock Functions
........................

The following functions take a pointer to a *note PyTime_t: 306. that
they set to the value of a particular clock.  Details of each clock are
given in the documentation of the corresponding Python function.

The functions return ‘0’ on success, or ‘-1’ (with an exception set) on
failure.

On integer overflow, they set the ‘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.)

As any other C API (unless otherwise specified), the functions must be
called with the *note GIL: 13f. held.

 -- C の関数: int PyTime_Monotonic (PyTime_t *result)

     Read the monotonic clock.  See *note time.monotonic(): 234. for
     important details on this clock.

 -- C の関数: int PyTime_PerfCounter (PyTime_t *result)

     Read the performance counter.  See *note time.perf_counter(): a56.
     for important details on this clock.

 -- C の関数: int PyTime_Time (PyTime_t *result)

     Read the “wall clock” time.  See *note time.time(): 235. for
     details important on this clock.


File: python.info,  Node: Raw Clock Functions,  Next: Conversion functions,  Prev: Clock Functions,  Up: PyTime C API

7.6.11.3 Raw Clock Functions
............................

Similar to clock functions, but don't set an exception on error and
don't require the caller to hold the GIL.

On success, the functions return ‘0’.

On failure, they set ‘*result’ to ‘0’ and return ‘-1’, 'without' setting
an exception.  To get the cause of the error, acquire the GIL and call
the regular (non-‘Raw’) function.  Note that the regular function may
succeed after the ‘Raw’ one failed.

 -- C の関数: int PyTime_MonotonicRaw (PyTime_t *result)

     Similar to *note PyTime_Monotonic(): 30a, but don't set an
     exception on error and don't require holding the GIL.

 -- C の関数: int PyTime_PerfCounterRaw (PyTime_t *result)

     Similar to *note PyTime_PerfCounter(): 30c, but don't set an
     exception on error and don't require holding the GIL.

 -- C の関数: int PyTime_TimeRaw (PyTime_t *result)

     Similar to *note PyTime_Time(): 30e, but don't set an exception on
     error and don't require holding the GIL.


File: python.info,  Node: Conversion functions,  Prev: Raw Clock Functions,  Up: PyTime C API

7.6.11.4 Conversion functions
.............................

 -- C の関数: double PyTime_AsSecondsDouble (PyTime_t t)

     Convert a timestamp to a number of seconds as a C double.

     The function cannot fail, but note that double has limited accuracy
     for large values.


File: python.info,  Node: Support for Perf Maps,  Prev: PyTime C API,  Up: ユーティリティ<2>

7.6.12 Support for Perf Maps
----------------------------

On supported platforms (as of this writing, only Linux), the runtime can
take advantage of 'perf map files' to make Python functions visible to
an external profiling tool (such as perf(1)).  A running process may
create a file in the ‘/tmp’ directory, which contains entries that can
map a section of executable code to a name.  This interface is described
in the documentation of the Linux Perf tool(2).

In Python, these helper APIs can be used by libraries and features that
rely on generating machine code on the fly.

Note that holding the Global Interpreter Lock (GIL) is not required for
these APIs.

 -- C の関数: int PyUnstable_PerfMapState_Init (void)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     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 done through *note PyUnstable_WritePerfMapEntry():
     16a1.).  Normally, there's no need to call this explicitly; just
     use *note PyUnstable_WritePerfMapEntry(): 16a1. and it will
     initialize the state on first call.

     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.

 -- C の関数: int PyUnstable_WritePerfMapEntry (const void *code_addr,
          unsigned int code_size, const char *entry_name)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Write one single entry to the ‘/tmp/perf-$pid.map’ file.  This
     function is thread safe.  Here is what an example entry looks like:

          # address      size  name
          7f3529fcf759 b     py::bar:/run/t.py

     Will call *note PyUnstable_PerfMapState_Init(): 16a2. before
     writing the entry, if the perf map file is not already opened.
     Returns ‘0’ on success, or the same error codes as *note
     PyUnstable_PerfMapState_Init(): 16a2. on failure.

 -- C の関数: void PyUnstable_PerfMapState_Fini (void)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Close the perf map file opened by *note
     PyUnstable_PerfMapState_Init(): 16a2.  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.

   ---------- Footnotes ----------

   (1) https://perf.wiki.kernel.org/index.php/Main_Page

   (2) 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/Documentation/jit-interface.txt


File: python.info,  Node: 抽象オブジェクトレイヤ Abstract Objects Layer,  Next: 具象オブジェクト concrete object レイヤ,  Prev: ユーティリティ<2>,  Up: Python/C API リファレンスマニュアル

7.7 抽象オブジェクトレイヤ (Abstract Objects Layer)
===================================================

この章で説明する関数は、オブジェクトの型に依存しないような Python オブジ
ェクトの操作や、(数値型全て、シーケンス型全てといった) 大まかな型のオブ
ジェクトに対する操作を行ないます。関数を適用対象でないオブジェクトに対し
て使った場合、Python の例外が送出されることになります。

これらの関数は、 *note PyList_New(): 47db. で作成された後に ‘NULL’ 以外
の値を設定されていないリストのような、適切に初期化されていないオブジェク
トに対して使うことはできません。

* Menu:

* オブジェクトプロトコル (object protocol): オブジェクトプロトコル object protocol.
* Call プロトコル::
* 数値型プロトコル (number protocol): 数値型プロトコル number protocol.
* シーケンス型プロトコル (sequence protocol): シーケンス型プロトコル sequence protocol.
* マップ型プロトコル (mapping protocol): マップ型プロトコル mapping protocol.
* イテレータプロトコル (iterator protocol): イテレータプロトコル iterator protocol.
* バッファプロトコル (buffer Protocol): バッファプロトコル buffer Protocol.


File: python.info,  Node: オブジェクトプロトコル object protocol,  Next: Call プロトコル,  Up: 抽象オブジェクトレイヤ Abstract Objects Layer

7.7.1 オブジェクトプロトコル (object protocol)
----------------------------------------------

 -- C の関数: *note PyObject: 312. *Py_GetConstant (unsigned int
          constant_id)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Get a *note strong reference: 316. to a constant.

     Set an exception and return ‘NULL’ if 'constant_id' is invalid.

     'constant_id' must be one of these constant identifiers:

     Constant Identifier                          値        Returned object
                                                            
     -------------------------------------------------------------------------------------
                                                            
      -- C のマクロ: Py_CONSTANT_NONE             ‘0’       *note None: 641.
                                                            
                                                            
      -- C のマクロ: Py_CONSTANT_FALSE            ‘1’       *note False: b05.
                                                            
                                                            
      -- C のマクロ: Py_CONSTANT_TRUE             ‘2’       *note True: bdb.
                                                            
                                                            
      -- C のマクロ: Py_CONSTANT_ELLIPSIS         ‘3’       *note Ellipsis: 20ea.
                                                            
                                                            
      -- C のマクロ:                              ‘4’       *note NotImplemented: 79d.
               Py_CONSTANT_NOT_IMPLEMENTED                  

      -- C のマクロ: Py_CONSTANT_ZERO             ‘5’       ‘0’
                                                            
                                                            
      -- C のマクロ: Py_CONSTANT_ONE              ‘6’       ‘1’
                                                            
                                                            
      -- C のマクロ: Py_CONSTANT_EMPTY_STR        ‘7’       ‘''’
                                                            
                                                            
      -- C のマクロ: Py_CONSTANT_EMPTY_BYTES      ‘8’       ‘b''’
                                                            
                                                            
      -- C のマクロ: Py_CONSTANT_EMPTY_TUPLE      ‘9’       ‘()’
                                                            

     Numeric values are only given for projects which cannot use the
     constant identifiers.

     Added in version 3.13.

     'CPython 実装の詳細:' In CPython, all of these constants are *note
     immortal: 41f8.

 -- C の関数: *note PyObject: 312. *Py_GetConstantBorrowed (unsigned int
          constant_id)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Similar to *note Py_GetConstant(): 32f, but return a *note borrowed
     reference: 317.

     This function is primarily intended for backwards compatibility:
     using *note Py_GetConstant(): 32f. is recommended for new code.

     The reference is borrowed from the interpreter, and is valid until
     the interpreter finalization.

     Added in version 3.13.

 -- C 変数: *note PyObject: 312. *Py_NotImplemented

     与えられたオブジェクトとメソッドの引数の型の組み合わせの処理が未実
     装である印として使われる、 ‘未実装 (NotImplemented)’ シングルトン。

 -- C のマクロ: Py_RETURN_NOTIMPLEMENTED

     Properly handle returning *note Py_NotImplemented: 49da. from
     within a C function (that is, create a new *note strong reference:
     316. to *note NotImplemented: 79d. and return it).

 -- C のマクロ: Py_PRINT_RAW

     Flag to be used with multiple functions that print the object (like
     *note PyObject_Print(): 1554. and *note PyFile_WriteObject():
     484f.).  If passed, these function would use the *note str(): 418.
     of the object instead of the *note repr(): 7c8.

 -- C の関数: int PyObject_Print (PyObject *o, FILE *fp, int flags)

     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 *note Py_PRINT_RAW: 49dc.; if
     given, the *note str(): 418. of the object is written instead of
     the *note repr(): 7c8.

 -- C の関数: int PyObject_HasAttrWithError (PyObject *o, const char
          *attr_name)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     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’.

     Added in version 3.13.

 -- C の関数: int PyObject_HasAttrStringWithError (PyObject *o, const
          char *attr_name)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     This is the same as *note PyObject_HasAttrWithError(): 353, but
     'attr_name' is specified as a const char* UTF-8 encoded bytes
     string, rather than a *note PyObject: 312.*.

     Added in version 3.13.

 -- C の関数: int PyObject_HasAttr (PyObject *o, PyObject *attr_name)
     ' 次に属します: *note Stable ABI: 51e.'  Returns ‘1’ if 'o' has the
     attribute 'attr_name', and ‘0’ otherwise.  This function always
     succeeds.

          注釈: Exceptions that occur when this calls *note
          __getattr__(): 49f. and *note __getattribute__(): ba0. methods
          are silently ignored.  For proper error handling, use *note
          PyObject_HasAttrWithError(): 353, *note
          PyObject_GetOptionalAttr(): 322. or *note PyObject_GetAttr():
          324. instead.

 -- C の関数: int PyObject_HasAttrString (PyObject *o, const char
          *attr_name)
     ' 次に属します: *note Stable ABI: 51e.'  This is the same as *note
     PyObject_HasAttr(): 354, but 'attr_name' is specified as a const
     char* UTF-8 encoded bytes string, rather than a *note PyObject:
     312.*.

          注釈: Exceptions that occur when this calls *note
          __getattr__(): 49f. and *note __getattribute__(): ba0. methods
          or while creating the temporary *note str: 418. object are
          silently ignored.  For proper error handling, use *note
          PyObject_HasAttrStringWithError(): 355, *note
          PyObject_GetOptionalAttrString(): 323. or *note
          PyObject_GetAttrString(): 325. instead.

 -- C の関数: *note PyObject: 312. *PyObject_GetAttr (PyObject *o,
          PyObject *attr_name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  オブ
     ジェクト 'o' から、名前 'attr_name' の属性を取得します。成功すると
     属性値を返し失敗すると ‘NULL’ を返します。この関数は Python の式
     ‘o.attr_name’ と同じです。

     If the missing attribute should not be treated as a failure, you
     can use *note PyObject_GetOptionalAttr(): 322. instead.

 -- C の関数: *note PyObject: 312. *PyObject_GetAttrString (PyObject *o,
          const char *attr_name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  This
     is the same as *note PyObject_GetAttr(): 324, but 'attr_name' is
     specified as a const char* UTF-8 encoded bytes string, rather than
     a *note PyObject: 312.*.

     If the missing attribute should not be treated as a failure, you
     can use *note PyObject_GetOptionalAttrString(): 323. instead.

 -- C の関数: int PyObject_GetOptionalAttr (PyObject *obj, PyObject
          *attr_name, PyObject **result);
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Variant of *note PyObject_GetAttr(): 324. which doesn't raise *note
     AttributeError: 326. if the attribute is not found.

     If the attribute is found, return ‘1’ and set '*result' to a new
     *note strong reference: 316. to the attribute.  If the attribute is
     not found, return ‘0’ and set '*result' to ‘NULL’; the *note
     AttributeError: 326. is silenced.  If an error other than *note
     AttributeError: 326. is raised, return ‘-1’ and set '*result' to
     ‘NULL’.

     Added in version 3.13.

 -- C の関数: int PyObject_GetOptionalAttrString (PyObject *obj, const
          char *attr_name, PyObject **result);
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     This is the same as *note PyObject_GetOptionalAttr(): 322, but
     'attr_name' is specified as a const char* UTF-8 encoded bytes
     string, rather than a *note PyObject: 312.*.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyObject_GenericGetAttr (PyObject
          *o, PyObject *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  型オ
     ブジェクトの ‘tp_getattro’ スロットに置かれる、属性を取得する総称的
     な関数です。この関数は、 (もし存在すれば) オブジェクトの属性 *note
     __dict__: 526. に加え、オブジェクトの MRO にあるクラスの辞書にある
     デスクリプタを探します。 *note デスクリプタ (descriptor) の実装:
     c1d. で概要が述べられている通り、データのデスクリプタはインスタンス
     の属性より優先され、非データデスクリプタは後回しにされます。見付か
     らなかった場合は *note AttributeError: 326. を送出します。

 -- C の関数: int PyObject_SetAttr (PyObject *o, PyObject *attr_name,
          PyObject *v)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'o' の
     'attr_name' という名の属性に、値 'v' を設定します。 失敗すると例外
     を送出し ‘-1’ を返します; 成功すると ‘0’ を返します。 この関数は
     Python の式 ‘o.attr_name = v’ と同じです。

     'v' が ‘NULL’ のとき、アトリビュートは削除されます。この動作は
     *note PyObject_DelAttr(): 1683. のため、非推奨となっていますが、削
     除される予定はありません。

 -- C の関数: int PyObject_SetAttrString (PyObject *o, const char
          *attr_name, PyObject *v)
     ' 次に属します: *note Stable ABI: 51e.'  This is the same as *note
     PyObject_SetAttr(): 48b8, but 'attr_name' is specified as a const
     char* UTF-8 encoded bytes string, rather than a *note PyObject:
     312.*.

     'v' が ‘NULL’ の場合は属性が削除されますが、この機能は非推奨であり
     *note PyObject_DelAttrString(): 1565. を使うのが望ましいです。

     The number of different attribute names passed to this function
     should be kept small, usually by using a statically allocated
     string as 'attr_name'.  For attribute names that aren't known at
     compile time, prefer calling *note PyUnicode_FromString(): 47be.
     and *note PyObject_SetAttr(): 48b8. directly.  For more details,
     see *note PyUnicode_InternFromString(): 1562, which may be used
     internally to create a key object.

 -- C の関数: int PyObject_GenericSetAttr (PyObject *o, PyObject *name,
          PyObject *value)
     ' 次に属します: *note Stable ABI: 51e.'  属性の設定と削除を行う汎用
     的な関数で、型オブジェクトの *note tp_setattro: 4793. スロットに置
     かれます。 オブジェクトの MRO にあるクラスの辞書からデータディスク
     リプタを探し、見付かった場合はインスタンスの辞書にある属性の設定や
     削除よりも優先されます。 そうでない場合は、(もし存在すれば) オブジ
     ェクトの *note __dict__: 526. に属性を設定もしくは削除します。 成功
     すると ‘0’ が返され、そうでない場合は *note AttributeError: 326. が
     送出され ‘-1’ が返されます。

 -- C の関数: int PyObject_DelAttr (PyObject *o, PyObject *attr_name)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'  オ
     ブジェクト 'o' の 'attr_name' という名の属性を削除します。失敗する
     と ‘-1’ を返します。この関数は Python の文 ‘del o.attr_name’ と同じ
     です。

 -- C の関数: int PyObject_DelAttrString (PyObject *o, const char
          *attr_name)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     This is the same as *note PyObject_DelAttr(): 1683, but 'attr_name'
     is specified as a const char* UTF-8 encoded bytes string, rather
     than a *note PyObject: 312.*.

     The number of different attribute names passed to this function
     should be kept small, usually by using a statically allocated
     string as 'attr_name'.  For attribute names that aren't known at
     compile time, prefer calling *note PyUnicode_FromString(): 47be.
     and *note PyObject_DelAttr(): 1683. directly.  For more details,
     see *note PyUnicode_InternFromString(): 1562, which may be used
     internally to create a key object for lookup.

 -- C の関数: *note PyObject: 312. *PyObject_GenericGetDict (PyObject
          *o, void *context)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.10 より).'  ‘__dict__’ デスクリプタの getter の総称的な実
     装です。必要な場合は、辞書を作成します。

     This function may also be called to get the *note __dict__: 526. of
     the object 'o'.  Pass ‘NULL’ for 'context' when calling it.  Since
     this function may need to allocate memory for the dictionary, it
     may be more efficient to call *note PyObject_GetAttr(): 324. when
     accessing an attribute on the object.

     On failure, returns ‘NULL’ with an exception set.

     Added in version 3.3.

 -- C の関数: int PyObject_GenericSetDict (PyObject *o, PyObject *value,
          void *context)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     ‘__dict__’ デスクリプタの setter の総称的な実装です。この実装では辞
     書を削除することは許されていません。

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. **_PyObject_GetDictPtr (PyObject
          *obj)

     Return a pointer to *note __dict__: 526. of the object 'obj'.  If
     there is no ‘__dict__’, return ‘NULL’ without setting an exception.

     This function may need to allocate memory for the dictionary, so it
     may be more efficient to call *note PyObject_GetAttr(): 324. when
     accessing an attribute on the object.

 -- C の関数: *note PyObject: 312. *PyObject_RichCompare (PyObject *o1,
          PyObject *o2, int opid)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Compare the values of 'o1' and 'o2' using the operation specified
     by 'opid', which must be one of *note Py_LT: 49de, *note Py_LE:
     49df, *note Py_EQ: 49e0, *note Py_NE: 49e1, *note Py_GT: 49e2, or
     *note Py_GE: 49e3, corresponding to ‘<’, ‘<=’, ‘==’, ‘!=’, ‘>’, or
     ‘>=’ respectively.  This is the equivalent of the Python expression
     ‘o1 op o2’, where ‘op’ is the operator corresponding to 'opid'.
     Returns the value of the comparison on success, or ‘NULL’ on
     failure.

 -- C の関数: int PyObject_RichCompareBool (PyObject *o1, PyObject *o2,
          int opid)
     ' 次に属します: *note Stable ABI: 51e.'  Compare the values of 'o1'
     and 'o2' using the operation specified by 'opid', like *note
     PyObject_RichCompare(): 479c, but returns ‘-1’ on error, ‘0’ if the
     result is false, ‘1’ otherwise.

     注釈: If 'o1' and 'o2' are the same object, *note
     PyObject_RichCompareBool(): 190e. will always return ‘1’ for *note
     Py_EQ: 49e0. and ‘0’ for *note Py_NE: 49e1.

 -- C の関数: *note PyObject: 312. *PyObject_Format (PyObject *obj,
          PyObject *format_spec)
     ' 次に属します: *note Stable ABI: 51e.'  Format 'obj' using
     'format_spec'.  This is equivalent to the Python expression
     ‘format(obj, format_spec)’.

     'format_spec' may be ‘NULL’.  In this case the call is equivalent
     to ‘format(obj)’.  Returns the formatted string on success, ‘NULL’
     on failure.

 -- C の関数: *note PyObject: 312. *PyObject_Repr (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     オブジェクト 'o' の文字列表現を計算します。成功すると文字列表現を返
     し、失敗すると ‘NULL’ を返します。 Python 式 ‘repr(o)’ と同じです。
     この関数は組み込み関数 *note repr(): 7c8. の処理で呼び出されます。

     バージョン 3.4 で変更: アクティブな例外を黙って捨てないことを保証す
     るのに便利なように、この関数はデバッグアサーションを含むようになり
     ました。

 -- C の関数: *note PyObject: 312. *PyObject_ASCII (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     *note PyObject_Repr(): ff9. と同様、オブジェクト 'o' の文字列表現を
     計算しますが、 *note PyObject_Repr(): ff9. によって返された文字列に
     含まれる非 ASCII 文字を、エスケープ文字 ‘\x’ 、 ‘\u’ 、 ‘\U’ でエス
     ケープします。この関数は Pythoh 2 の *note PyObject_Repr(): ff9. が
     返す文字列と同じ文字列を生成します。 *note ascii(): 138e. によって
     呼び出されます。

 -- C の関数: *note PyObject: 312. *PyObject_Str (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  オブ
     ジェクト 'o' の文字列表現を計算します。成功すると文字列表現を返し、
     失敗すると ‘NULL’ を返します。 Python 式 ‘str(o)’ と同じです。この
     関数は組み込み関数 *note str(): 418. や、 *note print(): f42. 関数
     の処理で呼び出されます。

     バージョン 3.4 で変更: アクティブな例外を黙って捨てないことを保証す
     るのに便利なように、この関数はデバッグアサーションを含むようになり
     ました。

 -- C の関数: *note PyObject: 312. *PyObject_Bytes (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     オブジェクト 'o' のバイト列表現を計算します。失敗すると ‘NULL’ を返
     し、成功すると bytes オブジェクトを返します。 'o' が整数でないとき
     の、 Python 式 ‘bytes(o)’ と同じです。 ‘bytes(o)’ と違って、 'o' が
     整数のときには、ゼロで初期化された bytes オブジェクトを返すのではな
     く TypeError が送出されます。

 -- C の関数: int PyObject_IsSubclass (PyObject *derived, PyObject *cls)
     ' 次に属します: *note Stable ABI: 51e.'  クラス 'derived' がクラス
     'cls' と同一であるか、そこから派生したクラスである場合は ‘1’ を返し
     、そうでない場合は ‘0’ を返します。 エラーが起きた場合は ‘-1’ を返
     します。

     'cls' がタプルの場合、 'cls' の全ての要素に対してチェックします。 少
     なくとも1つのチェックで ‘1’ が返ったとき、結果は ‘1’ となり、それ以
     外のとき ‘0’ になります。

     If 'cls' has a *note __subclasscheck__(): 1ede. method, it will be
     called to determine the subclass status as described in PEP
     3119(1).  Otherwise, 'derived' is a subclass of 'cls' if it is a
     direct or indirect subclass, i.e.  contained in *note cls.__mro__:
     1e89.

     Normally only class objects, i.e.  instances of *note type: d16. or
     a derived class, are considered classes.  However, objects can
     override this by having a *note __bases__: 1451. attribute (which
     must be a tuple of base classes).

 -- C の関数: int PyObject_IsInstance (PyObject *inst, PyObject *cls)
     ' 次に属します: *note Stable ABI: 51e.'  'inst' がクラス 'cls' もし
     くは 'cls' の子クラスのインスタンスである場合に ‘1’ を返し、そうで
     ない場合に ‘0’ を返します。 エラーが起きると ‘-1’ を返し例外を設定
     します。

     'cls' がタプルの場合、 'cls' の全ての要素に対してチェックします。 少
     なくとも1つのチェックで ‘1’ が返ったとき、結果は ‘1’ となり、それ以
     外のとき ‘0’ になります。

     If 'cls' has a *note __instancecheck__(): 1edd. method, it will be
     called to determine the subclass status as described in PEP
     3119(2).  Otherwise, 'inst' is an instance of 'cls' if its class is
     a subclass of 'cls'.

     An instance 'inst' can override what is considered its class by
     having a *note __class__: 1452. attribute.

     An object 'cls' can override if it is considered a class, and what
     its base classes are, by having a *note __bases__: 1451. attribute
     (which must be a tuple of base classes).

 -- C の関数: *note Py_hash_t: 1235. PyObject_Hash (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'

     オブジェクト 'o' のハッシュ値を計算して返します。失敗すると ‘-1’ を
     返します。 Python の式 ‘hash(o)’ と同じです。

     バージョン 3.2 で変更: 返り値の型が Py_hash_t になりました。この型
     は、 *note Py_ssize_t: a2e. と同じサイズをもつ符号付き整数です。

 -- C の関数: *note Py_hash_t: 1235. PyObject_HashNotImplemented
          (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  Set a *note TypeError:
     502. indicating that ‘type(o)’ is not *note hashable: 5db. 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.

 -- C の関数: int PyObject_IsTrue (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  'o' が真を表すとみなせる場
     合には ‘1’ を、そうでないときには ‘0’ を返します。 Python の式 ‘not
     not o’ と同じです。失敗すると ‘-1’ を返します。

 -- C の関数: int PyObject_Not (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  'o' が真を表すとみなせる場
     合には ‘0’ を、そうでないときには ‘1’ を返します。 Python の式 ‘not
     o’ と同じです。失敗すると ‘-1’ を返します。

 -- C の関数: *note PyObject: 312. *PyObject_Type (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     When 'o' is non-‘NULL’, returns a type object corresponding to the
     object type of object 'o'.  On failure, raises *note SystemError:
     541. and returns ‘NULL’.  This is equivalent to the Python
     expression ‘type(o)’.  This function creates a new *note strong
     reference: 316. to the return value.  There's really no reason to
     use this function instead of the *note Py_TYPE(): 74b. function,
     which returns a pointer of type *note PyTypeObject: a73.*, except
     when a new *note strong reference: 316. is needed.

 -- C の関数: int PyObject_TypeCheck (PyObject *o, PyTypeObject *type)

     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’.

 -- C の関数: *note Py_ssize_t: a2e. PyObject_Size (PyObject *o)
 -- C の関数: *note Py_ssize_t: a2e. PyObject_Length (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'

     'o' の長さを返します。ただしオブジェクト 'o' がシーケンス型プロトコ
     ルとマップ型プロトコルの両方を提供している場合、シーケンスとしての
     長さを返します。エラーが生じると ‘-1’ を返します。 Python の式
     ‘len(o)’ と同じです。

 -- C の関数: *note Py_ssize_t: a2e. PyObject_LengthHint (PyObject *o,
          Py_ssize_t defaultvalue)

     オブジェクト 'o' の概算の長さを返します。 最初に実際の長さを、次に
     *note __length_hint__(): ed7. を使って概算の長さを、そして最後にデ
     フォルトの値を返そうとします。 この関数は Python の式
     ‘operator.length_hint(o, defaultvalue)’ と同じです。

     Added in version 3.4.

 -- C の関数: *note PyObject: 312. *PyObject_GetItem (PyObject *o,
          PyObject *key)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  オブ
     ジェクト 'key' に対応する 'o' の要素を返します。失敗すると ‘NULL’ を
     返します。Python の式 ‘o[key]’ と同じです。

 -- C の関数: int PyObject_SetItem (PyObject *o, PyObject *key, PyObject
          *v)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'key' を値
     'v' に対応付けます。 失敗すると、例外を送出し ‘-1’ を返します。成功
     すると ‘0’ を返します。 これは Python の文 ‘o[key] = v’ と同等です
     。 この関数は 'v' への参照を '盗み取りません' 。

 -- C の関数: int PyObject_DelItem (PyObject *o, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'o' から
     'key' に関する対応付けを削除します。失敗すると ‘-1’ を返します。
     Python の文 ‘del o[key]’ と同じです。

 -- C の関数: *note PyObject: 312. *PyObject_Dir (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  この
     関数は Python の式 ‘dir(o)’ と同じで、オブジェクトの変数名に割り当
     てている文字列からなるリスト (空の場合もあります) を返します。エラ
     ーの場合には ‘NULL’ を返します。引数を ‘NULL’ にすると、Python にお
     ける ‘dir()’ と同様に、現在のローカルな名前を返します; この場合、ア
     クティブな実行フレームがなければ ‘NULL’ を返しますが、 *note
     PyErr_Occurred(): 185c. は偽を返します。

 -- C の関数: *note PyObject: 312. *PyObject_GetIter (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Python の式 ‘iter(o)’ と同じです。引数にとったオブジェクトに対する
     新たなイテレータか、オブジェクトがすでにイテレータの場合にはオブジ
     ェクト自身を返します。オブジェクトが反復処理不可能であった場合には
     *note TypeError: 502. を送出して ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyObject_GetAIter (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.10 より).'  This is the equivalent to the Python
     expression ‘aiter(o)’.  Takes an ‘AsyncIterable’ object and returns
     an ‘AsyncIterator’ for it.  This is typically a new iterator but if
     the argument is an ‘AsyncIterator’, this returns itself.  Raises
     *note TypeError: 502. and returns ‘NULL’ if the object cannot be
     iterated.

     Added in version 3.10.

 -- C の関数: void *PyObject_GetTypeData (PyObject *o, PyTypeObject
          *cls)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Get a pointer to subclass-specific data reserved for 'cls'.

     The object 'o' must be an instance of 'cls', and 'cls' must have
     been created using negative *note PyType_Spec.basicsize: 513.
     Python does not check this.

     On error, set an exception and return ‘NULL’.

     Added in version 3.12.

 -- C の関数: *note Py_ssize_t: a2e. PyType_GetTypeDataSize
          (PyTypeObject *cls)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Return the size of the instance memory space reserved for 'cls',
     i.e.  the size of the memory *note PyObject_GetTypeData(): 514.
     returns.

     This may be larger than requested using *note
     -PyType_Spec.basicsize: 513.; it is safe to use this larger size
     (e.g.  with ‘memset()’).

     The type 'cls' 'must' have been created using negative *note
     PyType_Spec.basicsize: 513.  Python does not check this.

     On error, set an exception and return a negative value.

     Added in version 3.12.

 -- C の関数: void *PyObject_GetItemData (PyObject *o)

     Get a pointer to per-item data for a class with *note
     Py_TPFLAGS_ITEMS_AT_END: 516.

     On error, set an exception and return ‘NULL’.  *note TypeError:
     502. is raised if 'o' does not have *note Py_TPFLAGS_ITEMS_AT_END:
     516. set.

     Added in version 3.12.

 -- C の関数: int PyObject_VisitManagedDict (PyObject *obj, visitproc
          visit, void *arg)

     Visit the managed dictionary of 'obj'.

     This function must only be called in a traverse function of the
     type which has the *note Py_TPFLAGS_MANAGED_DICT: 344. flag set.

     Added in version 3.13.

 -- C の関数: void PyObject_ClearManagedDict (PyObject *obj)

     Clear the managed dictionary of 'obj'.

     This function must only be called in a traverse function of the
     type which has the *note Py_TPFLAGS_MANAGED_DICT: 344. flag set.

     Added in version 3.13.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3119/

   (2) https://peps.python.org/pep-3119/


File: python.info,  Node: Call プロトコル,  Next: 数値型プロトコル number protocol,  Prev: オブジェクトプロトコル object protocol,  Up: 抽象オブジェクトレイヤ Abstract Objects Layer

7.7.2 Call プロトコル
---------------------

CPython supports two different calling protocols: 'tp_call' and
vectorcall.

* Menu:

* The tp_call Protocol::
* The Vectorcall Protocol::
* Object Calling API::
* Call Support API::


File: python.info,  Node: The tp_call Protocol,  Next: The Vectorcall Protocol,  Up: Call プロトコル

7.7.2.1 The 'tp_call' Protocol
..............................

Instances of classes that set *note tp_call: 524. are callable.  The
signature of the slot is:

     PyObject *tp_call(PyObject *callable, PyObject *args, PyObject *kwargs);

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.

This convention is not only used by 'tp_call': *note tp_new: 54b. and
*note tp_init: 54d. also pass arguments this way.

To call an object, use *note PyObject_Call(): 376. or another *note call
API: 49e7.


File: python.info,  Node: The Vectorcall Protocol,  Next: Object Calling API,  Prev: The tp_call Protocol,  Up: Call プロトコル

7.7.2.2 The Vectorcall Protocol
...............................

Added in version 3.9.

The vectorcall protocol was introduced in PEP 590(1) as an additional
protocol for making calls more efficient.

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, some third-party extensions use 'tp_call' directly (rather
than using *note PyObject_Call(): 376.).  Therefore, a class supporting
vectorcall must also implement *note tp_call: 524.  Moreover, the
callable must behave the same regardless of which protocol is used.  The
recommended way to achieve this is by setting *note tp_call: 524. to
*note PyVectorcall_Call(): 521.  This bears repeating:

     警告: A class supporting vectorcall 'must' also implement *note
     tp_call: 524. with the same semantics.

バージョン 3.12 で変更: The *note Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag
is now removed from a class when the class's *note __call__(): 523.
method is reassigned.  (This internally sets *note tp_call: 524. only,
and thus may make it behave differently than the vectorcall function.)
In earlier Python versions, vectorcall should only be used with *note
immutable: 39c. or static types.

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.

Classes can implement the vectorcall protocol by enabling the *note
Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag and setting *note
tp_vectorcall_offset: 49e9. to the offset inside the object structure
where a 'vectorcallfunc' appears.  This is a pointer to a function with
the following signature:

 -- C のデータ型: typedef *note PyObject: 312. *(*vectorcallfunc)(*note
          PyObject: 312. *callable, *note PyObject: 312. *const *args,
          size_t nargsf, *note PyObject: 312. *kwnames)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'

   - 'callable' is the object being called.

   - 
     'args' is a C array consisting of the positional arguments followed by the

          values of the keyword arguments.  This can be 'NULL' if there
          are no arguments.

   - 
     'nargsf' is the number of positional arguments plus possibly the

          *note PY_VECTORCALL_ARGUMENTS_OFFSET: 529. flag.  To get the
          actual number of positional arguments from 'nargsf', use *note
          PyVectorcall_NARGS(): 520.

   - 
     'kwnames' is a tuple containing the names of the keyword arguments;

          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'.

 -- C のマクロ: PY_VECTORCALL_ARGUMENTS_OFFSET
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'  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.

     For *note PyObject_VectorcallMethod(): 528, this flag means instead
     that ‘args[0]’ may be changed.

     Whenever they can do so cheaply (without additional allocation),
     callers are encouraged to use *note PY_VECTORCALL_ARGUMENTS_OFFSET:
     529.  Doing so will allow callables such as bound methods to make
     their onward calls (which include a prepended 'self' argument) very
     efficiently.

     Added in version 3.8.

To call an object that implements vectorcall, use a *note call API:
49e7. function as with any other callable.  *note PyObject_Vectorcall():
527. will usually be most efficient.

* Menu:

* 再帰の管理: 再帰の管理<2>.
* Vectorcall Support API::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0590/


File: python.info,  Node: 再帰の管理<2>,  Next: Vectorcall Support API,  Up: The Vectorcall Protocol

7.7.2.3 再帰の管理
..................

When using 'tp_call', callees do not need to worry about *note
recursion: 4983.: CPython uses *note Py_EnterRecursiveCall(): 941. and
*note Py_LeaveRecursiveCall(): 942. for calls made using 'tp_call'.

For efficiency, this is not the case for calls done using vectorcall:
the callee should use 'Py_EnterRecursiveCall' and
'Py_LeaveRecursiveCall' if needed.


File: python.info,  Node: Vectorcall Support API,  Prev: 再帰の管理<2>,  Up: The Vectorcall Protocol

7.7.2.4 Vectorcall Support API
..............................

 -- C の関数: *note Py_ssize_t: a2e. PyVectorcall_NARGS (size_t nargsf)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Given a vectorcall 'nargsf' argument, return the actual number of
     arguments.  Currently equivalent to:

          (Py_ssize_t)(nargsf & ~PY_VECTORCALL_ARGUMENTS_OFFSET)

     However, the function ‘PyVectorcall_NARGS’ should be used to allow
     for future extensions.

     Added in version 3.8.

 -- C の関数: *note vectorcallfunc: 522. PyVectorcall_Function (PyObject
          *op)

     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.

     This is mostly useful to check whether or not 'op' supports
     vectorcall, which can be done by checking
     ‘PyVectorcall_Function(op) != NULL’.

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyVectorcall_Call (PyObject
          *callable, PyObject *tuple, PyObject *dict)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Call 'callable"s *note vectorcallfunc: 522. with positional and
     keyword arguments given in a tuple and dict, respectively.

     This is a specialized function, intended to be put in the *note
     tp_call: 524. slot or be used in an implementation of ‘tp_call’.
     It does not check the *note Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag
     and it does not fall back to ‘tp_call’.

     Added in version 3.8.


File: python.info,  Node: Object Calling API,  Next: Call Support API,  Prev: The Vectorcall Protocol,  Up: Call プロトコル

7.7.2.5 Object Calling API
..........................

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.

The following table summarizes the available functions; please see
individual documentation for details.

関数                                           callable               ‘args’                   ‘kwargs’
                                                                                               
-------------------------------------------------------------------------------------------------------------------
                                                                                               
*note PyObject_Call(): 376.                    ‘PyObject *’           tuple                    dict/‘NULL’
                                                                                               
                                                                                               
*note PyObject_CallNoArgs(): 375.              ‘PyObject *’           --                       --
                                                                                               
                                                                                               
*note PyObject_CallOneArg(): 946.              ‘PyObject *’           1 object                 --
                                                                                               
                                                                                               
*note PyObject_CallObject(): 4758.             ‘PyObject *’           tuple/‘NULL’             --
                                                                                               
                                                                                               
*note PyObject_CallFunction(): 378.            ‘PyObject *’           format                   --
                                                                                               
                                                                                               
*note PyObject_CallMethod(): 379.              obj + ‘char*’          format                   --
                                                                                               
                                                                                               
*note PyObject_CallFunctionObjArgs(): 48ac.    ‘PyObject *’           variadic                 --
                                                                                               
                                                                                               
*note PyObject_CallMethodObjArgs(): 1968.      obj + name             variadic                 --
                                                                                               
                                                                                               
*note PyObject_CallMethodNoArgs(): 49ee.       obj + name             --                       --
                                                                                               
                                                                                               
*note PyObject_CallMethodOneArg(): 49ef.       obj + name             1 object                 --
                                                                                               
                                                                                               
*note PyObject_Vectorcall(): 527.              ‘PyObject *’           vectorcall               vectorcall
                                                                                               
                                                                                               
*note PyObject_VectorcallDict(): 49f0.         ‘PyObject *’           vectorcall               dict/‘NULL’
                                                                                               
                                                                                               
*note PyObject_VectorcallMethod(): 528.        arg + name             vectorcall               vectorcall
                                                                                               

 -- C の関数: *note PyObject: 312. *PyObject_Call (PyObject *callable,
          PyObject *args, PyObject *kwargs)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  呼び
     出し可能な Python のオブジェクト 'callable' を、タプル 'args' とし
     て与えられる引数と辞書 'kwargs' として与えられる名前付き引数ととも
     に呼び出します。

     'args' は 'NULL' であってはならず、引数を必要としない場合は空のタプ
     ルを使ってください。 'kwargs' は 'NULL' でも構いません。

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     これは次の Python の式と同等です: ‘callable(*args, **kwargs)’ 。

 -- C の関数: *note PyObject: 312. *PyObject_CallNoArgs (PyObject
          *callable)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.10 より).'  Call a callable Python object 'callable'
     without any arguments.  It is the most efficient way to call a
     callable Python object without any argument.

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyObject_CallOneArg (PyObject
          *callable, PyObject *arg)
     '戻り値: 新しい参照。' Call a callable Python object 'callable'
     with exactly 1 positional argument 'arg' and no keyword arguments.

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyObject_CallObject (PyObject
          *callable, PyObject *args)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  呼び
     出し可能な Python のオブジェクト 'callable' を、タプル 'args' とし
     て与えられる引数とともに呼び出します。 引数が必要な場合は、 'args'
     は 'NULL' で構いません。

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     これは次の Python の式と同等です: ‘callable(*args)’ 。

 -- C の関数: *note PyObject: 312. *PyObject_CallFunction (PyObject
          *callable, const char *format, ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  呼び
     出し可能な Python オブジェクト 'callable' を可変数個の C 引数ととも
     に呼び出します。 C 引数は *note Py_BuildValue(): 875. 形式のフォー
     マット文字列を使って記述します。 'format' は 'NULL' かもしれず、与
     える引数がないことを表します。

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     これは次の Python の式と同等です: ‘callable(*args)’ 。

     *note PyObject: 312.* args だけを引数に渡す場合は、 *note
     PyObject_CallFunctionObjArgs(): 48ac. がより速い方法であることを覚
     えておいてください。

     バージョン 3.4 で変更: 'format' の型が ‘char *’ から変更されました
     。

 -- C の関数: *note PyObject: 312. *PyObject_CallMethod (PyObject *obj,
          const char *name, const char *format, ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  オブ
     ジェクト 'obj' の 'name' という名前のメソッドを、いくつかの C 引数
     とともに呼び出します。 C 引数はタプルを生成する *note
     Py_BuildValue(): 875. 形式のフォーマット文字列で記述されています。

     'format' は 'NULL' でもよく、引数が与えられないことを表します。

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     これは次の Python の式と同等です: ‘obj.name(arg1, arg2, ...)’ 。

     *note PyObject: 312.* args だけを引数に渡す場合は、 *note
     PyObject_CallMethodObjArgs(): 1968. がより速い方法であることを覚え
     ておいてください。

     バージョン 3.4 で変更: 'name' と 'format' の型が ‘char *’ から変更
     されました。

 -- C の関数: *note PyObject: 312. *PyObject_CallFunctionObjArgs
          (PyObject *callable, ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  呼び
     出し可能な Python オブジェクト 'callable' を可変数個の *note
     PyObject: 312.* 引数とともに呼び出します。引数列は末尾に 'NULL' が
     ついた可変数個のパラメタとして与えます。

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     これは次の Python の式と同等です: ‘callable(arg1, arg2, ...)’ 。

 -- C の関数: *note PyObject: 312. *PyObject_CallMethodObjArgs (PyObject
          *obj, PyObject *name, ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Python オブジェクト 'obj' のメソッドを呼び出します、メソッド名は
     Python 文字列オブジェクト 'name' で与えます。可変数個の *note
     PyObject: 312.* 引数と共に呼び出されます.  引数列は末尾に 'NULL' が
     ついた可変数個のパラメタとして与えます。

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

 -- C の関数: *note PyObject: 312. *PyObject_CallMethodNoArgs (PyObject
          *obj, PyObject *name)

     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'.

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyObject_CallMethodOneArg (PyObject
          *obj, PyObject *name, PyObject *arg)

     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'.

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyObject_Vectorcall (PyObject
          *callable, PyObject *const *args, size_t nargsf, PyObject
          *kwnames)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Call a callable Python object 'callable'.  The arguments are the
     same as for *note vectorcallfunc: 522.  If 'callable' supports
     *note vectorcall: 51d, this directly calls the vectorcall function
     stored in 'callable'.

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyObject_VectorcallDict (PyObject
          *callable, PyObject *const *args, size_t nargsf, PyObject
          *kwdict)

     Call 'callable' with positional arguments passed exactly as in the
     *note vectorcall: 51d. protocol, but with keyword arguments passed
     as a dictionary 'kwdict'.  The 'args' array contains only the
     positional arguments.

     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.

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyObject_VectorcallMethod (PyObject
          *name, PyObject *const *args, size_t nargsf, PyObject
          *kwnames)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     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 is 'args[0]', and the 'args' array starting at
     'args[1]' represents the arguments of the call.  There must be at
     least one positional argument.  'nargsf' is the number of
     positional arguments including 'args[0]', plus *note
     PY_VECTORCALL_ARGUMENTS_OFFSET: 529. if the value of ‘args[0]’ may
     temporarily be changed.  Keyword arguments can be passed just like
     in *note PyObject_Vectorcall(): 527.

     If the object has the *note Py_TPFLAGS_METHOD_DESCRIPTOR: 49f1.
     feature, this will call the unbound method object with the full
     'args' vector as arguments.

     成功したら呼び出しの結果を返し、失敗したら例外を送出し 'NULL' を返
     します。

     Added in version 3.9.


File: python.info,  Node: Call Support API,  Prev: Object Calling API,  Up: Call プロトコル

7.7.2.6 Call Support API
........................

 -- C の関数: int PyCallable_Check (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'o' が呼び出
     し可能オブジェクトかどうか調べます。オブジェクトが呼び出し可能であ
     るときに ‘1’ を返し、そうでないときには ‘0’ を返します。この関数呼
     び出しは常に成功します。


File: python.info,  Node: 数値型プロトコル number protocol,  Next: シーケンス型プロトコル sequence protocol,  Prev: Call プロトコル,  Up: 抽象オブジェクトレイヤ Abstract Objects Layer

7.7.3 数値型プロトコル (number protocol)
----------------------------------------

 -- C の関数: int PyNumber_Check (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'o' が数値型
     プロトコルを提供している場合に ‘1’ を返し、そうでないときには偽を返
     します。この関数呼び出しは常に成功します。

     バージョン 3.8 で変更: 'o' がインデックス整数だった場合、 ‘1’ を返
     します。

 -- C の関数: *note PyObject: 312. *PyNumber_Add (PyObject *o1, PyObject
          *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' を加算した結果を返し、失敗すると ‘NULL’ を返し
     ます。Python の式 ‘o1 + o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Subtract (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' から 'o2' を減算した結果を返し、失敗すると ‘NULL’ を返
     します。Python の式 ‘o1 - o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Multiply (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' を乗算した結果を返し、失敗すると ‘NULL’ を返し
     ます。Python の式 ‘o1 * o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_MatrixMultiply (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  成功すると 'o1' と 'o2' を行列乗算した結果を返
     し、失敗すると ‘NULL’ を返します。 Python の式 ‘o1 @ o2’ と同じです
     。

     Added in version 3.5.

 -- C の関数: *note PyObject: 312. *PyNumber_FloorDivide (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return the floor of 'o1' divided by 'o2', or ‘NULL’ on failure.
     This is the equivalent of the Python expression ‘o1 // o2’.

 -- C の関数: *note PyObject: 312. *PyNumber_TrueDivide (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return a reasonable approximation for the mathematical value of
     'o1' divided by 'o2', or ‘NULL’ on failure.  The return value is
     "approximate" because binary floating-point numbers are
     approximate; it is not possible to represent all real numbers in
     base two.  This function can return a floating-point value when
     passed two integers.  This is the equivalent of the Python
     expression ‘o1 / o2’.

 -- C の関数: *note PyObject: 312. *PyNumber_Remainder (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' を 'o2' で除算した剰余を返し、失敗すると ‘NULL’ を返し
     ます。Python の式 ‘o1 % o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Divmod (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     組み込み関数 *note divmod(): 96f. を参照してください。失敗すると
     ‘NULL’ を返します。 Python の式 ‘divmod(o1, o2)’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Power (PyObject *o1,
          PyObject *o2, PyObject *o3)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     組み込み関数 *note pow(): 9a0. を参照してください。失敗すると
     ‘NULL’ を返します。 Python の式 ‘pow(o1, o2, o3)’ と同じです。 'o3'
     はオプションです。 'o3' を無視させたいなら、 *note Py_None: 474c. を
     入れてください ('o3' に ‘NULL’ を渡すと、不正なメモリアクセスを引き
     起こすことがあります)。

 -- C の関数: *note PyObject: 312. *PyNumber_Negative (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o' の符号反転を返し、失敗すると ‘NULL’ を返します。Python の
     式 ‘-o’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Positive (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o' を返し、失敗すると ‘NULL’ を返します。Python の式 ‘+o’ と
     同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Absolute (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     成功すると 'o' の絶対値を返し、失敗すると ‘NULL’ を返します。Python
     の式 ‘abs(o)’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Invert (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o' のビット単位反転 (bitwise negation) を返し、失敗すると
     ‘NULL’ を返します。Python の式 ‘~o’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Lshift (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' を 'o2' だけ左シフトした結果を返し、失敗すると ‘NULL’ を
     返します。Python の式 ‘o1 << o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Rshift (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' を 'o2' だけ右シフトした結果を返し、失敗すると ‘NULL’ を
     返します。Python の式 ‘o1 >> o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_And (PyObject *o1, PyObject
          *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の "ビット単位論理積 (bitwise and)" を返し、失
     敗すると ‘NULL’ を返します。Python の式 ‘o1 & o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Xor (PyObject *o1, PyObject
          *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の "ビット単位排他的論理和 (bitwise exclusive
     or)" を返し、失敗すると ‘NULL’ を返します。Python の式 ‘o1 ^ o2’ と
     同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Or (PyObject *o1, PyObject
          *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の "ビット単位論理和 (bitwise or)" を返し失敗す
     ると ‘NULL’ を返します。Python の式 ‘o1 | o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceAdd (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' を加算した結果を返し、失敗すると ‘NULL’ を返し
     ます。'o1' が 'in-place' 演算をサポートする場合、in-place 演算を行
     います。Python の文 ‘o1 += o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceSubtract (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' から 'o2' を減算した結果を返し、失敗すると ‘NULL’ を返
     します。'o1' が 'in-place' 演算をサポートする場合、in-place 演算を
     行います。Python の文 ‘o1 -= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceMultiply (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' を乗算した結果を返し、失敗すると ‘NULL’ を返し
     ます。'o1' が 'in-place' 演算をサポートする場合、in-place 演算を行
     います。Python の文 ‘o1 *= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceMatrixMultiply
          (PyObject *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  成功すると 'o1' と 'o2' を行列乗算した結果を返
     し、失敗すると ‘NULL’ を返します。 'o1' が 'in-place' 演算をサポー
     トする場合、 in-place 演算を行います。 Python の文 ‘o1 @= o2’ と同
     じです。

     Added in version 3.5.

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceFloorDivide
          (PyObject *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' を 'o2' で除算した切捨て値を返し、失敗すると ‘NULL’ を
     返します。'o1' が 'in-place' 演算をサポートする場合、in-place 演算
     を行います。Python の文 ‘o1 //= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceTrueDivide (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return a reasonable approximation for the mathematical value of
     'o1' divided by 'o2', or ‘NULL’ on failure.  The return value is
     "approximate" because binary floating-point numbers are
     approximate; it is not possible to represent all real numbers in
     base two.  This function can return a floating-point value when
     passed two integers.  The operation is done 'in-place' when 'o1'
     supports it.  This is the equivalent of the Python statement ‘o1 /=
     o2’.

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceRemainder (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' を 'o2' で除算した剰余を返し、, 失敗すると ‘NULL’ を返
     します。'o1' が 'in-place' 演算をサポートする場合、in-place 演算を
     行います。Python の文 ‘o1 %= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlacePower (PyObject *o1,
          PyObject *o2, PyObject *o3)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     組み込み関数 *note pow(): 9a0. を参照してください。失敗すると
     ‘NULL’ を返します。 'o1' が 'in-place' 演算をサポートする場合、
     in-place 演算を行います。この関数は 'o3' が *note Py_None: 474c. の
     場合は Python 文 ‘o1 **= o2’ と同じで、それ以外の場合は ‘pow(o1,
     o2, o3)’ の in-place 版です。 'o3' を無視させたいなら、 *note
     Py_None: 474c. を入れてください ('o3' に ‘NULL’ を渡すと、不正なメ
     モリアクセスを引き起こすことがあります)。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceLshift (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' を 'o2' だけ左シフトした結果を返し、失敗すると ‘NULL’ を
     返します。'o1' が 'in-place' 演算をサポートする場合、in-place 演算
     を行います。Python の文 ‘o1 <<= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceRshift (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' を 'o2' だけ右シフトした結果を返し、失敗すると ‘NULL’ を
     返します。'o1' が 'in-place' 演算をサポートする場合、in-place 演算
     を行います。Python の文 ‘o1 >>= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceAnd (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の "ビット単位論理積 (bitwise and)" を返し、失
     敗すると ‘NULL’ を返します。'o1' が 'in-place' 演算をサポートする場
     合、in-place 演算を行います。Python の文 ‘o1 &= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceXor (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の "ビット単位排他的論理和 (bitwise exclusive
     or)" を返し、失敗すると ‘NULL’ を返します。'o1' が 'in-place' 演算
     をサポートする場合、in-place 演算を行います。Python の文 ‘o1 ^= o2’
     と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_InPlaceOr (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の "ビット単位論理和 (bitwise or)" を返し失敗す
     ると ‘NULL’ を返します。'o1' が 'in-place' 演算をサポートする場合、
     in-place 演算を行います。Python の文 ‘o1 |= o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Long (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     成功すると 'o' を整数に変換したものを返し、失敗すると ‘NULL’ を返し
     ます。Python の式 ‘int(o)’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Float (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     成功すると 'o' を浮動小数点数に変換したものを返し、失敗すると
     ‘NULL’ を返します。Python の式 ‘float(o)’ と同じです。

 -- C の関数: *note PyObject: 312. *PyNumber_Index (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  'o'
     をPythonのint型に変換し、成功したらその値を返します。失敗したら
     ‘NULL’ が返され、 *note TypeError: 502. 例外が送出されます。

     バージョン 3.10 で変更: 結果は常に厳密な *note int: 238. 型です。 以
     前は、結果は ‘int’ のサブクラスのインスタンスのこともありました。

 -- C の関数: *note PyObject: 312. *PyNumber_ToBase (PyObject *n, int
          base)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'base' 進数に変換された整数 'n' を文字列として返します。 'base' 引
     数は2, 8, 10または16のいずれかでなければなりません。 基数2、8、16に
     ついて、返される文字列の先頭には基数マーカー ‘'0b'’ 、 ‘'0o'’ また
     は ‘'0x'’ が、それぞれ付与されます。 もし 'n' が Python のint型でな
     ければ、まず *note PyNumber_Index(): 860. で変換されます。

 -- C の関数: *note Py_ssize_t: a2e. PyNumber_AsSsize_t (PyObject *o,
          PyObject *exc)
     ' 次に属します: *note Stable ABI: 51e.'  'o' を整数として解釈可能だ
     った場合、*note Py_ssize_t: a2e. 型の値に変換して返します。呼び出し
     が失敗したら、例外が送出され、 ‘-1’ が返されます。

     もし 'o' がPythonのintに変換できたのに、*note Py_ssize_t: a2e. への
     変換が *note OverflowError: 84e. になる場合は、 'exc' 引数で渡され
     た型 (普通は *note IndexError: 14de. か *note OverflowError: 84e.)
     の例外を送出します。もし、 'exc' が ‘NULL’ なら、例外はクリアされて
     、値が負の場合は ‘PY_SSIZE_T_MIN’ へ、正の場合は ‘PY_SSIZE_T_MAX’ へ
     と制限されます。

 -- C の関数: int PyIndex_Check (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.8 より).'  'o'
     がインデックス整数である場合 (‘tp_as_number’ 構造体の ‘nb_index’ ス
     ロットが埋まっている場合) に ‘1’ を返し、そうでない場合に ‘0’ を返
     します。 この関数は常に成功します。


File: python.info,  Node: シーケンス型プロトコル sequence protocol,  Next: マップ型プロトコル mapping protocol,  Prev: 数値型プロトコル number protocol,  Up: 抽象オブジェクトレイヤ Abstract Objects Layer

7.7.4 シーケンス型プロトコル (sequence protocol)
------------------------------------------------

 -- C の関数: int PySequence_Check (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  Return ‘1’ if the object
     provides the sequence protocol, and ‘0’ otherwise.  Note that it
     returns ‘1’ for Python classes with a *note __getitem__(): 264.
     method, unless they are *note dict: 237. subclasses, since in
     general it is impossible to determine what type of keys the class
     supports.  This function always succeeds.

 -- C の関数: *note Py_ssize_t: a2e. PySequence_Size (PyObject *o)
 -- C の関数: *note Py_ssize_t: a2e. PySequence_Length (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'

     成功するとシーケンス 'o' 中のオブジェクトの数を返し、失敗すると
     ‘-1’ を返します。これは、Python の式 ‘len(o)’ と同じになります。

 -- C の関数: *note PyObject: 312. *PySequence_Concat (PyObject *o1,
          PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の連結 (concatenation) を返し、失敗すると
     ‘NULL’ を返します。Python の式 ‘o1 + o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PySequence_Repeat (PyObject *o,
          Py_ssize_t count)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     するとオブジェクト 'o' の 'count' 回繰り返しを返し、失敗すると
     ‘NULL’ を返します。Python の式 ‘o * count’ と同じです。

 -- C の関数: *note PyObject: 312. *PySequence_InPlaceConcat (PyObject
          *o1, PyObject *o2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o1' と 'o2' の連結 (concatenation) を返し、失敗すると
     ‘NULL’ を返します。'o1' が 'in-place' 演算をサポートする場合、
     in-place 演算を行います。Python の式 ‘o1 += o2’ と同じです。

 -- C の関数: *note PyObject: 312. *PySequence_InPlaceRepeat (PyObject
          *o, Py_ssize_t count)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     するとオブジェクト 'o' の 'count' 回繰り返しを返し、失敗すると
     ‘NULL’ を返します。'o' が 'in-place' 演算をサポートする場合、
     in-place 演算を行います。Python の式 ‘o *= count’ と同じです。

 -- C の関数: *note PyObject: 312. *PySequence_GetItem (PyObject *o,
          Py_ssize_t i)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o' の 'i' 番目の要素を返し、失敗すると ‘NULL’ を返します。
     Python の式 ‘o[i]’ と同じです。

 -- C の関数: *note PyObject: 312. *PySequence_GetSlice (PyObject *o,
          Py_ssize_t i1, Py_ssize_t i2)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     すると 'o' の 'i1' から 'i2' までの間のスライスを返し、失敗すると
     ‘NULL’ を返します。Python の式 ‘o[i1:i2]’ と同じです。

 -- C の関数: int PySequence_SetItem (PyObject *o, Py_ssize_t i,
          PyObject *v)
     ' 次に属します: *note Stable ABI: 51e.'  'o' の 'i' 番目の要素に
     'v' を代入します。 失敗すると、例外を送出し ‘-1’ を返します; 成功す
     ると ‘0’ を返します。 これは Python の文 ‘o[i] = v’ と同じです。 こ
     の関数は 'v' への参照を '盗み取りません' 。

     'v' が ‘NULL’ の場合はその要素が削除されますが、この機能は非推奨で
     あり、 *note PyObject_DelAttr(): 1683. を使うのが望ましいです。

 -- C の関数: int PySequence_DelItem (PyObject *o, Py_ssize_t i)
     ' 次に属します: *note Stable ABI: 51e.'  'o' の 'i' 番目の要素を削
     除します。失敗すると ‘-1’ を返します。Python の文 ‘del o[i]’ と同じ
     です。

 -- C の関数: int PySequence_SetSlice (PyObject *o, Py_ssize_t i1,
          Py_ssize_t i2, PyObject *v)
     ' 次に属します: *note Stable ABI: 51e.'  'o' の 'i1' から 'i2' まで
     の間のスライスに 'v' を代入します。Python の文 ‘o[i1:i2] = v’ と同
     じです。

 -- C の関数: int PySequence_DelSlice (PyObject *o, Py_ssize_t i1,
          Py_ssize_t i2)
     ' 次に属します: *note Stable ABI: 51e.'  シーケンスオブジェクト 'o'
     の 'i1' から 'i2' までの間のスライスを削除します。失敗すると ‘-1’ を
     返します。Python の文 ‘del o[i1:i2]’ と同じです。

 -- C の関数: *note Py_ssize_t: a2e. PySequence_Count (PyObject *o,
          PyObject *value)
     ' 次に属します: *note Stable ABI: 51e.'  'o' における 'value' の出
     現回数、すなわち ‘o[key] == value’ となる 'key' の個数を返します。
     失敗すると ‘-1’ を返します。Python の式 ‘o.count(value)’ と同じです
     。

 -- C の関数: int PySequence_Contains (PyObject *o, PyObject *value)
     ' 次に属します: *note Stable ABI: 51e.'  'o' に 'value' が入ってい
     るか判定します。'o' のある要素が 'value' と等価 (equal) ならば ‘1’
     を返し、それ以外の場合には ‘0’ を返します。エラーが発生すると ‘-1’
     を返します。Python の式 ‘value in o’ と同じです。

 -- C の関数: *note Py_ssize_t: a2e. PySequence_Index (PyObject *o,
          PyObject *value)
     ' 次に属します: *note Stable ABI: 51e.'  ‘o[i] == value’ となる最初
     に見つかったインデクス 'i' を返します。エラーが発生すると ‘-1’ を返
     します。Python の式 ‘o.index(value)’ と同じです。

 -- C の関数: *note PyObject: 312. *PySequence_List (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  シー
     ケンスもしくはイテラブル 'o' と同じ内容を持つリストオブジェクトを返
     します。 失敗したら ‘NULL’ を返します。 返されるリストは新しく作ら
     れたことが保証されています。 これは Python の式 ‘list(o)’ と同等で
     す。

 -- C の関数: *note PyObject: 312. *PySequence_Tuple (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     シーケンスあるいはイテラブルである 'o' と同じ内容を持つタプルオブジ
     ェクトを返します。 失敗したら ‘NULL’ を返します。'o' がタプルの場合
     、新たな参照を返します。 それ以外の場合、適切な内容が入ったタプルを
     構築して返します。 Pythonの式 ‘tuple(o)’ と同等です。

 -- C の関数: *note PyObject: 312. *PySequence_Fast (PyObject *o, const
          char *m)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  シー
     ケンスまたはイテラブルの 'o' を ‘PySequence_Fast*’ ファミリの関数で
     利用できるオブジェクトとして返します。オブジェクトがシーケンスでも
     イテラブルでもない場合は、メッセージ 'm' を持つ、 *note TypeError:
     502. を送出します。失敗したら ‘NULL’ を返します。

     ‘PySequence_Fast*’ ファミリの関数は、'o' が *note PyTupleObject:
     4993. または *note PyListObject: 49f9. と仮定し、'o' のデータフィー
     ルドに直接アクセスするため、そのように名付けられています。

     CPythonの実装では、もし 'o' が 既にシーケンスかタプルであれば、'o'
     そのものを返します。

 -- C の関数: *note Py_ssize_t: a2e. PySequence_Fast_GET_SIZE (PyObject
          *o)

     'o' が ‘NULL’ でなく、 *note PySequence_Fast(): 48c3. が返したオブ
     ジェクトであると仮定して、 'o' の長さを返します。 'o' のサイズは
     *note PySequence_Size(): 19bd. を呼び出しても得られますが、 *note
     PySequence_Fast_GET_SIZE(): 49fa. の方が 'o' をリストかタプルである
     と仮定して処理するため、より高速です。

 -- C の関数: *note PyObject: 312. *PySequence_Fast_GET_ITEM (PyObject
          *o, Py_ssize_t i)
     '戻り値: 借用参照。' 'o' が ‘NULL’ でなく、 *note
     PySequence_Fast(): 48c3. が返したオブジェクトであり、かつ 'i' がイ
     ンデクスの範囲内にあると仮定して、 'o' の 'i' 番目の要素を返します
     。

 -- C の関数: *note PyObject: 312. **PySequence_Fast_ITEMS (PyObject *o)

     PyObject ポインタの背後にあるアレイを返します。この関数では、 'o' は
     *note PySequence_Fast(): 48c3. の返したオブジェクトであり、 ‘NULL’
     でないものと仮定しています。

     リストのサイズが変更されるとき、メモリ再確保が要素の配列を再配置す
     るかもしれないことに注意してください。そのため、シーケンスの変更が
     発生しないコンテキストでのみ背後にあるポインタを使ってください。

 -- C の関数: *note PyObject: 312. *PySequence_ITEM (PyObject *o,
          Py_ssize_t i)
     '戻り値: 新しい参照。' 'o' の 'i' 番目の要素を返し、失敗すると
     ‘NULL’ を返します。 *note PySequence_GetItem(): 19be. の高速版であ
     り、*note PySequence_Check(): 48be. で 'o' が真を返すかどうかの検証
     や、負の添え字の調整を行いません。


File: python.info,  Node: マップ型プロトコル mapping protocol,  Next: イテレータプロトコル iterator protocol,  Prev: シーケンス型プロトコル sequence protocol,  Up: 抽象オブジェクトレイヤ Abstract Objects Layer

7.7.5 マップ型プロトコル (mapping protocol)
-------------------------------------------

*note PyObject_GetItem(): 320, *note PyObject_SetItem(): 47da, *note
PyObject_DelItem(): 48ad. も参照してください。

 -- C の関数: int PyMapping_Check (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  Return ‘1’ if the object
     provides the mapping protocol or supports slicing, and ‘0’
     otherwise.  Note that it returns ‘1’ for Python classes with a
     *note __getitem__(): 264. method, since in general it is impossible
     to determine what type of keys the class supports.  This function
     always succeeds.

 -- C の関数: *note Py_ssize_t: a2e. PyMapping_Size (PyObject *o)
 -- C の関数: *note Py_ssize_t: a2e. PyMapping_Length (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'

     成功するとオブジェクト 'o' 中のキーの数を返し、失敗すると ‘-1’ を返
     します。これは、Python の式 ‘len(o)’ と同じになります。

 -- C の関数: *note PyObject: 312. *PyMapping_GetItemString (PyObject
          *o, const char *key)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  This
     is the same as *note PyObject_GetItem(): 320, but 'key' is
     specified as a const char* UTF-8 encoded bytes string, rather than
     a *note PyObject: 312.*.

 -- C の関数: int PyMapping_GetOptionalItem (PyObject *obj, PyObject
          *key, PyObject **result)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Variant of *note PyObject_GetItem(): 320. which doesn't raise *note
     KeyError: 31d. if the key is not found.

     If the key is found, return ‘1’ and set '*result' to a new *note
     strong reference: 316. to the corresponding value.  If the key is
     not found, return ‘0’ and set '*result' to ‘NULL’; the *note
     KeyError: 31d. is silenced.  If an error other than *note KeyError:
     31d. is raised, return ‘-1’ and set '*result' to ‘NULL’.

     Added in version 3.13.

 -- C の関数: int PyMapping_GetOptionalItemString (PyObject *obj, const
          char *key, PyObject **result)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     This is the same as *note PyMapping_GetOptionalItem(): 31e, but
     'key' is specified as a const char* UTF-8 encoded bytes string,
     rather than a *note PyObject: 312.*.

     Added in version 3.13.

 -- C の関数: int PyMapping_SetItemString (PyObject *o, const char *key,
          PyObject *v)
     ' 次に属します: *note Stable ABI: 51e.'  This is the same as *note
     PyObject_SetItem(): 47da, but 'key' is specified as a const char*
     UTF-8 encoded bytes string, rather than a *note PyObject: 312.*.

 -- C の関数: int PyMapping_DelItem (PyObject *o, PyObject *key)

     This is an alias of *note PyObject_DelItem(): 48ad.

 -- C の関数: int PyMapping_DelItemString (PyObject *o, const char *key)

     This is the same as *note PyObject_DelItem(): 48ad, but 'key' is
     specified as a const char* UTF-8 encoded bytes string, rather than
     a *note PyObject: 312.*.

 -- C の関数: int PyMapping_HasKeyWithError (PyObject *o, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     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’.

     Added in version 3.13.

 -- C の関数: int PyMapping_HasKeyStringWithError (PyObject *o, const
          char *key)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     This is the same as *note PyMapping_HasKeyWithError(): 357, but
     'key' is specified as a const char* UTF-8 encoded bytes string,
     rather than a *note PyObject: 312.*.

     Added in version 3.13.

 -- C の関数: int PyMapping_HasKey (PyObject *o, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e.'  マップ型オブジェクトがキー
     'key' を持つ場合に ‘1’ を返し、そうでないときには ‘0’ を返します。
     これは、Python の式 ‘key in o’ と等価です。この関数呼び出しは常に成
     功します。

          注釈: Exceptions which occur when this calls *note
          __getitem__(): 264. method are silently ignored.  For proper
          error handling, use *note PyMapping_HasKeyWithError(): 357,
          *note PyMapping_GetOptionalItem(): 31e. or *note
          PyObject_GetItem(): 320. instead.

 -- C の関数: int PyMapping_HasKeyString (PyObject *o, const char *key)
     ' 次に属します: *note Stable ABI: 51e.'  This is the same as *note
     PyMapping_HasKey(): 358, but 'key' is specified as a const char*
     UTF-8 encoded bytes string, rather than a *note PyObject: 312.*.

          注釈: Exceptions that occur when this calls *note
          __getitem__(): 264. method or while creating the temporary
          *note str: 418. object are silently ignored.  For proper error
          handling, use *note PyMapping_HasKeyStringWithError(): 359,
          *note PyMapping_GetOptionalItemString(): 31f. or *note
          PyMapping_GetItemString(): 321. instead.

 -- C の関数: *note PyObject: 312. *PyMapping_Keys (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     するとオブジェクト 'o' のキーからなるリストを返します。 失敗すると
     ‘NULL’ を返します。

     バージョン 3.7 で変更: 以前は、関数はリストもしくはタプルを返してい
     ました。

 -- C の関数: *note PyObject: 312. *PyMapping_Values (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     するとオブジェクト 'o' の値からなるリストを返します。 失敗すると
     ‘NULL’ を返します。

     バージョン 3.7 で変更: 以前は、関数はリストもしくはタプルを返してい
     ました。

 -- C の関数: *note PyObject: 312. *PyMapping_Items (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     するとオブジェクト 'o' の要素からなるリストを返し、各要素はキーと値
     のペアが入ったタプルになっています。 失敗すると ‘NULL’ を返します。

     バージョン 3.7 で変更: 以前は、関数はリストもしくはタプルを返してい
     ました。


File: python.info,  Node: イテレータプロトコル iterator protocol,  Next: バッファプロトコル buffer Protocol,  Prev: マップ型プロトコル mapping protocol,  Up: 抽象オブジェクトレイヤ Abstract Objects Layer

7.7.6 イテレータプロトコル (iterator protocol)
----------------------------------------------

イテレータを扱うための固有の関数は二つあります。

 -- C の関数: int PyIter_Check (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.8 より).'
     Return non-zero if the object 'o' can be safely passed to *note
     PyIter_Next(): 4863, and ‘0’ otherwise.  This function always
     succeeds.

 -- C の関数: int PyAIter_Check (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Return non-zero if the object 'o' provides the ‘AsyncIterator’
     protocol, and ‘0’ otherwise.  This function always succeeds.

     Added in version 3.10.

 -- C の関数: *note PyObject: 312. *PyIter_Next (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return the next value from the iterator 'o'.  The object must be an
     iterator according to *note PyIter_Check(): 185f. (it is up to the
     caller to check this).  If there are no remaining values, returns
     ‘NULL’ with no exception set.  If an error occurs while retrieving
     the item, returns ‘NULL’ and passes along the exception.

イテレータの返す要素にわたって反復処理を行うループを書くと、C のコードは
以下のようになるはずです:

     PyObject *iterator = PyObject_GetIter(obj);
     PyObject *item;

     if (iterator == NULL) {
         /* propagate error */
     }

     while ((item = PyIter_Next(iterator))) {
         /* do something with item */
         ...
         /* release reference when done */
         Py_DECREF(item);
     }

     Py_DECREF(iterator);

     if (PyErr_Occurred()) {
         /* propagate error */
     }
     else {
         /* continue doing useful work */
     }

 -- C のデータ型: type PySendResult

     The enum value used to represent different results of *note
     PyIter_Send(): 865.

     Added in version 3.10.

 -- C の関数: *note PySendResult: 4a06. PyIter_Send (PyObject *iter,
          PyObject *arg, PyObject **presult)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Sends the 'arg' value into the iterator 'iter'.  Returns:

        - ‘PYGEN_RETURN’ if iterator returns.  Return value is returned
          via 'presult'.

        - ‘PYGEN_NEXT’ if iterator yields.  Yielded value is returned
          via 'presult'.

        - ‘PYGEN_ERROR’ if iterator has raised and exception.  'presult'
          is set to ‘NULL’.

     Added in version 3.10.


File: python.info,  Node: バッファプロトコル buffer Protocol,  Prev: イテレータプロトコル iterator protocol,  Up: 抽象オブジェクトレイヤ Abstract Objects Layer

7.7.7 バッファプロトコル (buffer Protocol)
------------------------------------------

Pythonで利用可能ないくつかのオブジェクトは、下層にあるメモリ配列または
'buffer' へのアクセスを提供します。このようなオブジェクトとして、組み込
みの *note bytes: 1a4. や *note bytearray: 508. 、 *note array.array:
185. のようないくつかの拡張型が挙げられます。サードバーティのライブラリ
は画像処理や数値解析のような特別な目的のために、それら自身の型を定義する
ことができます。

それぞれの型はそれ自身のセマンティクスを持ちますが、おそらく大きなメモリ
バッファからなるという共通の特徴を共有します。いくつかの状況では仲介する
コピーを行うことなく直接バッファにアクセスすることが望まれます。

Pythonは *note buffer protocol: 371. の形式で C レベルの仕組みを提供しま
す。このプロトコルには二つの側面があります:

   - 提供する側では、ある型は、そのオブジェクトの下層にあるバッファに関
     する情報を提供できる "buffer インターフェース" をエクスポートするこ
     とができます。このインターフェースは *note
     バッファオブジェクト構造体 (buffer object structure): 1010. の節で
     説明します。

   - 利用する側では、オブジェクトの下層にある生データへのポインタを得る
     いくつかの手段が利用できます（たとえばメソッド引数）。

*note bytes: 1a4. や *note bytearray: 508. などのシンプルなオブジェクト
は、内部のバッファーをバイト列の形式で公開します。 バイト列以外の形式も
利用可能です。例えば、 *note array.array: 185. が公開する要素はマルチバ
イト値になることがあります。

bufferインターフェースの利用者の一例は、ファイルオブジェクトの *note
write(): ca9. メソッドです: bufferインターフェースを通して一連のバイト列
を提供できるどんなオブジェクトでもファイルに書き込むことができます。
‘write()’ は、その引数として渡されたオブジェクトの内部要素に対する読み出
し専用アクセスのみを必要としますが、 *note readinto(): 2b7b. のような他
のメソッドでは、その引数の内容に対する書き込みアクセスが必要です。
bufferインターフェースにより、オブジェクトは読み書き両方、読み出し専用バ
ッファへのアクセスを許可するかそれとも拒否するか選択することができます。

bufferインターフェースの利用者には、対象となるオブジェクトのバッファを得
る二つの方法があります:

   * 正しい引数で *note PyObject_GetBuffer(): 373. を呼び出す;

   * *note PyArg_ParseTuple(): 53d. (またはその同族のひとつ) を ‘y*’ 、
     ‘w*’ または ‘s*’ *note format codes: 876. のいずれかとともに呼び出
     す。

どちらのケースでも、bufferが必要なくなった時に *note PyBuffer_Release():
374. を呼び出さなければなりません。これを怠ると、リソースリークのような
様々な問題につながる恐れがあります。

* Menu:

* buffer 構造体::
* バッファリクエストのタイプ::
* 複雑な配列::
* バッファ関連の関数::


File: python.info,  Node: buffer 構造体,  Next: バッファリクエストのタイプ,  Up: バッファプロトコル buffer Protocol

7.7.7.1 buffer 構造体
.....................

バッファ構造体（または単純に "buffers"）は別のオブジェクトのバイナリデー
タをPythonプログラマに提供するのに便利です。これはまた、ゼロコピースライ
シング機構としても使用できます。このメモリブロックを参照する機能を使うこ
とで、どんなデータでもとても簡単にPythonプログラマに提供することができま
す。メモリは、C 拡張の大きな配列定数かもしれませんし、オペレーティングシ
ステムライブラリに渡す前のメモリブロックかもしれませんし、構造化データを
ネイティブのインメモリ形式受け渡すのに使用されるかもしれません。

Pythonインタプリタによって提供される多くのデータ型とは異なり、バッファは
*note PyObject: 312. ポインタではなく、シンプルなC 構造体です。そのため
、作成とコピーが非常に簡単に行えます。バッファの一般的なラッパーが必要な
ときは、 *note memoryview: 4a0b. オブジェクトが作成されます。

エクスポートされるオブジェクトを書く方法の短い説明には、 *note Buffer
Object Structures: 1010. を参照してください。バッファを取得するには、
*note PyObject_GetBuffer(): 373. を参照してください。

 -- C のデータ型: type Py_buffer
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む) (バ
     ージョン 3.11 より).'
      -- C のメンバ変数: void *buf

          バッファフィールドが表している論理構造の先頭を指すポインタ。 バ
          ッファを提供するオブジェクトの下層物理メモリブロック中のどの位
          置にもなりえます。 例えば *note strides: 4a0d. が負だと、この
          値はメモリブロックの末尾かもしれません。

          *note 連続: 1016. 配列の場合この値はメモリブロックの先頭を指し
          ます。

      -- C のメンバ変数: *note PyObject: 312. *obj

          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 *note
          PyBuffer_Release(): 374.  The field is the equivalent of the
          return value of any standard C-API function.

          *note PyMemoryView_FromBuffer(): 72c. または *note
          PyBuffer_FillInfo(): 72b. によってラップされた '一時的な' バッ
          ファである特別なケースでは、このフィールドは ‘NULL’ です。一般
          的に、エクスポートオブジェクトはこの方式を使用してはなりません
          。

      -- C のメンバ変数: *note Py_ssize_t: a2e. len

          ‘product(shape) * itemsize’。contiguous配列では、下層のメモリ
          ブロックの長さになります。非contiguous 配列では、contiguous表
          現にコピーされた場合に論理構造がもつ長さです。

          ‘((char *)buf)[0]’ から ‘((char *)buf)[len-1]’ の範囲へのアク
          セスは、連続性 (contiguity) を保証するリクエストによって取得さ
          れたバッファに対してのみ許されます。 多くの場合に、そのような
          リクエストは *note PyBUF_SIMPLE: 4a10. または *note
          PyBUF_WRITABLE: 1362. です。

      -- C のメンバ変数: int readonly

          バッファが読み出し専用であるか示します。このフィールドは *note
          PyBUF_WRITABLE: 1362. フラグで制御できます。

      -- C のメンバ変数: *note Py_ssize_t: a2e. itemsize

          要素一つ分のbyte単位のサイズ。 *note struct.calcsize(): 192f.
          を非 ‘NULL’ の *note format: 4a13. 値に対して呼び出した結果と
          同じです。

          重要な例外: 消費者が *note PyBUF_FORMAT: 4a14. フラグを設定す
          ることなくバッファを要求した場合、 ‘format’ は ‘NULL’ に設定さ
          れます。 しかし *note itemsize: 4a12. は元のフォーマットに従っ
          た値を保持します。

          *note shape: 4a15. が存在する場合、 ‘product(shape) * itemsize
          == len’ の等式が守られ、利用者は *note itemsize: 4a12. を
          buffer を読むために利用できます。

          *note PyBUF_SIMPLE: 4a10. または *note PyBUF_WRITABLE: 1362. で
          要求した結果、 *note shape: 4a15. が ‘NULL’ であれば、消費者は
          *note itemsize: 4a12. を無視して ‘itemsize == 1’ と見なさなけ
          ればなりません。

      -- C のメンバ変数: char *format

          A 'NULL' terminated string in *note struct: c0. module style
          syntax describing the contents of a single item.  If this is
          ‘NULL’, ‘"B"’ (unsigned bytes) is assumed.

          このフィールドは *note PyBUF_FORMAT: 4a14. フラグによって制御
          されます。

      -- C のメンバ変数: int ndim

          The number of dimensions the memory represents as an
          n-dimensional array.  If it is ‘0’, *note buf: 4a0c. points to
          a single item representing a scalar.  In this case, *note
          shape: 4a15, *note strides: 4a0d. and *note suboffsets: 4a17.
          MUST be ‘NULL’.  The maximum number of dimensions is given by
          *note PyBUF_MAX_NDIM: 4a18.

      -- C のメンバ変数: *note Py_ssize_t: a2e. *shape

          メモリ上のN次元配列の形を示す、長さが *note ndim: 4a16. である
          *note Py_ssize_t: a2e. の配列です。 ‘shape[0] * ... *
          shape[ndim-1] * itemsize’ は *note len: 4a0f. と等しくなければ
          なりません。

          shape の値は ‘shape[n] >= 0’ に制限されます。 ‘shape[n] == 0’
          の場合に特に注意が必要です。 詳細は *note complex arrays:
          4a19. を参照してください。

          shepe (形状) 配列は利用者からは読み出し専用です。

      -- C のメンバ変数: *note Py_ssize_t: a2e. *strides

          各次元において新しい値を得るためにスキップするバイト数を示す、
          長さ *note ndim: 4a16. の *note Py_ssize_t: a2e. の配列。

          ストライド値は、任意の整数を指定できます。規定の配列では、スト
          ライドは通常でいけば有効です。しかし利用者は、‘strides[n] <=
          0’ のケースを処理することができる必要があります。詳細について
          は *note complex arrays: 4a19. を参照してください。

          消費者にとって、この strides 配列は読み出し専用です。

      -- C のメンバ変数: *note Py_ssize_t: a2e. *suboffsets

          *note Py_ssize_t: a2e. 型の要素を持つ長さ *note ndim: 4a16. の
          配列。 ‘suboffsets[n] >= 0’ の場合は、 n 番目の次元に沿って保
          存されている値はポインタで、 suboffset 値は各ポインタの参照を
          解決した後に何バイト加えればいいかを示しています。 suboffset の
          値が負の数の場合は、ポインタの参照解決は不要 (連続したメモリブ
          ロック内に直接配置されいる) ということになります。

          全ての suboffset が負数の場合 (つまり参照解決が不要) な場合、
          このフィールドは ‘NULL’ (デフォルト値) でなければなりません。

          この種の配列表現は Python Imaging Library (PIL) で使われていま
          す。 このような配列で要素にアクセスする方法についてさらに詳し
          ことは *note complex arrays: 4a19. を参照してください。

          消費者にとって、suboffsets 配列は読み出し専用です。

      -- C のメンバ変数: void *internal

          バッファを提供する側のオブジェクトが内部的に利用するための変数
          です。例えば、提供側はこの変数に整数型をキャストして、shape,
          strides, suboffsets といった配列をバッファを開放するときに同時
          に解放するべきかどうかを管理するフラグに使うことができるでしょ
          う。バッファを受け取る側は、この値を決して変更してはなりません
          。

Constants:

 -- C のマクロ: PyBUF_MAX_NDIM

     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 ‘PyBUF_MAX_NDIM’ dimensions.
     Currently set to 64.


File: python.info,  Node: バッファリクエストのタイプ,  Next: 複雑な配列,  Prev: buffer 構造体,  Up: バッファプロトコル buffer Protocol

7.7.7.2 バッファリクエストのタイプ
..................................

バッファは通常、 *note PyObject_GetBuffer(): 373. を使うことで、エクスポ
ートするオブジェクトにバッファリクエストを送ることで得られます。メモリの
論理的な構造の複雑性は多岐にわたるため、消費者は 'flags' 引数を使って、
自身が扱えるバッファの種類を指定します。

*note Py_buffer: 723. の全フィールドは、リクエストの種類によって曖昧さを
残さずに定義されます。

* Menu:

* リクエストに依存しないフィールド::
* readonly, format: readonly format.
* shape, strides, suboffsets: shape strides suboffsets.
* 隣接性のリクエスト::
* 複合リクエスト::


File: python.info,  Node: リクエストに依存しないフィールド,  Next: readonly format,  Up: バッファリクエストのタイプ

7.7.7.3 リクエストに依存しないフィールド
........................................

下記のフィールドは 'flags' の影響を受けずに、常に正しい値で設定されます
。: *note obj: 4a0e, *note buf: 4a0c, *note len: 4a0f, *note itemsize:
4a12, *note ndim: 4a16.


File: python.info,  Node: readonly format,  Next: shape strides suboffsets,  Prev: リクエストに依存しないフィールド,  Up: バッファリクエストのタイプ

7.7.7.4 readonly, format
........................

      -- C のマクロ: PyBUF_WRITABLE

          Controls the *note readonly: 4a11. field.  If set, the
          exporter MUST provide a writable buffer or else report
          failure.  Otherwise, the exporter MAY provide either a
          read-only or writable buffer, but the choice MUST be
          consistent for all consumers.  For example, *note
          PyBUF_SIMPLE: 4a10. | *note PyBUF_WRITABLE: 1362. can be used
          to request a simple writable buffer.

      -- C のマクロ: PyBUF_FORMAT

          *note format: 4a13. フィールドを制御します。もしフラグが設定さ
          れていれば、このフィールドを正しく埋めなければなりません。フラ
          グが設定されていなければ、このフィールドを ‘NULL’ に設定しなけ
          ればなりません。

*note PyBUF_WRITABLE: 1362. は、次の節に出てくるどのフラグとも | を取っ
てかまいません。 *note PyBUF_SIMPLE: 4a10. は 0 と定義されているので、
*note PyBUF_WRITABLE: 1362. は単純な書き込み可能なバッファを要求する単独
のフラグとして使えます。

*note PyBUF_FORMAT: 4a14. must be |'d to any of the flags except *note
PyBUF_SIMPLE: 4a10, because the latter already implies format ‘B’
(unsigned bytes).  ‘PyBUF_FORMAT’ cannot be used on its own.


File: python.info,  Node: shape strides suboffsets,  Next: 隣接性のリクエスト,  Prev: readonly format,  Up: バッファリクエストのタイプ

7.7.7.5 shape, strides, suboffsets
..................................

このフラグは、以下で複雑性が大きい順に並べたメモリの論理的な構造を制御し
ます。個々のフラグは、それより下に記載されたフラグのすべてのビットを含む
ことに注意してください。

リクエスト                        shape       strides       suboffsets
                                                            
-----------------------------------------------------------------------------
                                                            
 -- C のマクロ: PyBUF_INDIRECT    yes         yes           必要な場合
                                                            
                                                            
 -- C のマクロ: PyBUF_STRIDES     yes         yes           NULL
                                                            
                                                            
 -- C のマクロ: PyBUF_ND          yes         NULL          NULL
                                                            
                                                            
 -- C のマクロ: PyBUF_SIMPLE      NULL        NULL          NULL
                                                            


File: python.info,  Node: 隣接性のリクエスト,  Next: 複合リクエスト,  Prev: shape strides suboffsets,  Up: バッファリクエストのタイプ

7.7.7.6 隣接性のリクエスト
..........................

ストライドの情報があってもなくても、C または Fortran の *note 連続性:
1016. が明確に要求される可能性があります。 ストライド情報なしに、バッフ
ァーは C と隣接している必要があります。

リクエスト                              shape       strides       suboffsets       contig
                                                                                   
------------------------------------------------------------------------------------------------
                                                                                   
 -- C のマクロ: PyBUF_C_CONTIGUOUS      yes         yes           NULL             C
                                                                                   
                                                                                   
 -- C のマクロ: PyBUF_F_CONTIGUOUS      yes         yes           NULL             F
                                                                                   
                                                                                   
 -- C のマクロ: PyBUF_ANY_CONTIGUOUS    yes         yes           NULL             C か F
                                                                                   
                                                                                   
*note PyBUF_ND: 4a21.                   yes         NULL          NULL             C
                                                                                   


File: python.info,  Node: 複合リクエスト,  Prev: 隣接性のリクエスト,  Up: バッファリクエストのタイプ

7.7.7.7 複合リクエスト
......................

有り得る全てのリクエストの値は、前の節でのフラグの組み合わせで網羅的に定
義されています。 便利なように、バッファープロトコルでは頻繁に使用される
組み合わせを単一のフラグとして提供してます。

次のテーブルの 'U' は連続性が未定義であることを表します。 利用者は *note
PyBuffer_IsContiguous(): 729. を呼び出して連続性を判定する必要があるでし
ょう。

リクエスト                          shape       strides       suboffsets       contig       readonly       format
                                                                                                           
------------------------------------------------------------------------------------------------------------------------
                                                                                                           
 -- C のマクロ: PyBUF_FULL          yes         yes           必要な場合       U            0              yes
                                                                                                           
                                                                                                           
 -- C のマクロ: PyBUF_FULL_RO       yes         yes           必要な場合       U            1 か 0         yes
                                                                                                           
                                                                                                           
 -- C のマクロ: PyBUF_RECORDS       yes         yes           NULL             U            0              yes
                                                                                                           
                                                                                                           
 -- C のマクロ: PyBUF_RECORDS_RO    yes         yes           NULL             U            1 か 0         yes
                                                                                                           
                                                                                                           
 -- C のマクロ: PyBUF_STRIDED       yes         yes           NULL             U            0              NULL
                                                                                                           
                                                                                                           
 -- C のマクロ: PyBUF_STRIDED_RO    yes         yes           NULL             U            1 か 0         NULL
                                                                                                           
                                                                                                           
 -- C のマクロ: PyBUF_CONTIG        yes         NULL          NULL             C            0              NULL
                                                                                                           
                                                                                                           
 -- C のマクロ: PyBUF_CONTIG_RO     yes         NULL          NULL             C            1 か 0         NULL
                                                                                                           


File: python.info,  Node: 複雑な配列,  Next: バッファ関連の関数,  Prev: バッファリクエストのタイプ,  Up: バッファプロトコル buffer Protocol

7.7.7.8 複雑な配列
..................

* Menu:

* NumPy スタイル; shape, strides: NumPy スタイル shape strides.
* PIL スタイル; shape, strides, suboffsets: PIL スタイル shape strides suboffsets.


File: python.info,  Node: NumPy スタイル shape strides,  Next: PIL スタイル shape strides suboffsets,  Up: 複雑な配列

7.7.7.9 NumPy スタイル: shape, strides
......................................

NumPy スタイルの配列の論理的構造は *note itemsize: 4a12, *note ndim:
4a16, *note shape: 4a15, *note strides: 4a0d. で定義されます。

‘ndim == 0’ の場合は、 *note buf: 4a0c. が指すメモリの場所は、サイズが
*note itemsize: 4a12. のスカラ値として解釈されます。 この場合、 *note
shape: 4a15. と *note strides: 4a0d. の両方とも ‘NULL’ です。

*note strides: 4a0d. が ‘NULL’ の場合は、配列は標準の n 次元 C 配列とし
て解釈されます。 そうでない場合は、利用者は次のように n 次元配列にアクセ
スしなければなりません:

     ptr = (char *)buf + indices[0] * strides[0] + ... + indices[n-1] * strides[n-1];
     item = *((typeof(item) *)ptr);

上記のように、 *note buf: 4a0c. はメモリブロック内のどの場所でも指すこと
が可能です。エクスポーターはこの関数を使用することによってバッファの妥当
性を確認出来ます。

     def verify_structure(memlen, itemsize, ndim, shape, strides, offset):
         """Verify that the parameters represent a valid array within
            the bounds of the allocated memory:
                char *mem: start of the physical memory block
                memlen: length of the physical memory block
                offset: (char *)buf - mem
         """
         if offset % itemsize:
             return False
         if offset < 0 or offset+itemsize > memlen:
             return False
         if any(v % itemsize for v in strides):
             return False

         if ndim <= 0:
             return ndim == 0 and not shape and not strides
         if 0 in shape:
             return True

         imin = sum(strides[j]*(shape[j]-1) for j in range(ndim)
                    if strides[j] <= 0)
         imax = sum(strides[j]*(shape[j]-1) for j in range(ndim)
                    if strides[j] > 0)

         return 0 <= offset+imin and offset+imax+itemsize <= memlen


File: python.info,  Node: PIL スタイル shape strides suboffsets,  Prev: NumPy スタイル shape strides,  Up: 複雑な配列

7.7.7.10 PIL スタイル: shape, strides, suboffsets
.................................................

PIL スタイルの配列では通常の要素の他に、ある次元の上で次の要素を取得する
ために辿るポインタを持てます。 例えば、通常の3次元 C 配列 ‘char
v[2][2][3]’ は、2次元配列への 2 つのポインタからなる配列 ‘char
(*v[2])[2][3]’ と見ることもできます。 suboffset 表現では、これらの 2 つ
のポインタは *note buf: 4a0c. の先頭に埋め込め、メモリのどこにでも配置で
きる 2 つの ‘char x[2][3]’ 配列を指します。

次の例は、 strides も suboffsets も ‘NULL’ でない場合の、N 次元インデッ
クスによって指されている N 次元配列内の要素へのポインタを返す関数です:

     void *get_item_pointer(int ndim, void *buf, Py_ssize_t *strides,
                            Py_ssize_t *suboffsets, Py_ssize_t *indices) {
         char *pointer = (char*)buf;
         int i;
         for (i = 0; i < ndim; i++) {
             pointer += strides[i] * indices[i];
             if (suboffsets[i] >=0 ) {
                 pointer = *((char**)pointer) + suboffsets[i];
             }
         }
         return (void*)pointer;
     }


File: python.info,  Node: バッファ関連の関数,  Prev: 複雑な配列,  Up: バッファプロトコル buffer Protocol

7.7.7.11 バッファ関連の関数
...........................

 -- C の関数: int PyObject_CheckBuffer (PyObject *obj)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     'obj' がbuffer インターフェースをサポートしている場合は ‘1’ を返し
     、そうでない場合は ‘0’ を返します。 ‘1’ を返したとしても、 *note
     PyObject_GetBuffer(): 373. が成功することは保証されません。 この関
     数は常に成功します。

 -- C の関数: int PyObject_GetBuffer (PyObject *exporter, Py_buffer
          *view, int flags)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     'exporter' に 'flags' で指定された方法で 'view' を埋めるように要求
     します。もし exporter が指定されたとおりにバッファを提供できない場
     合、 *note BufferError: 178f. を送出し、 ‘view->obj’ を ‘NULL’ に設
     定した上で、 ‘-1’ を返さなければなりません。

     成功したときは、 'view' を埋め、 ‘view->obj’ に 'exporter' への新し
     い参照を設定し、0を返します。チェイン状のバッファプロバイダがリクエ
     ストを単一のオブジェクトにリダイレクトするケースでは、 ‘view->obj’
     は 'exporter' の代わりにこのオブジェクトを参照します (*note
     バッファオブジェクト構造体: 1010. を参照してください)。

     ‘malloc()’ と ‘free()’ のように、呼び出しに成功した *note
     PyObject_GetBuffer(): 373. と対になる *note PyBuffer_Release():
     374. の呼び出しがなけれなればなりません。 従って、バッファの利用が
     済んだら *note PyBuffer_Release(): 374. が厳密に1回だけ呼び出されな
     ければなりません。

 -- C の関数: void PyBuffer_Release (Py_buffer *view)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     Release the buffer 'view' and release the *note strong reference:
     316. (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.

     *note PyObject_GetBuffer(): 373. を通して取得していないバッファに対
     してこの関数を呼び出すのは間違いです。

 -- C の関数: *note Py_ssize_t: a2e. PyBuffer_SizeFromFormat (const char
          *format)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     Return the implied *note itemsize: 4a12. from *note format: 4a13.
     On error, raise an exception and return -1.

     Added in version 3.9.

 -- C の関数: int PyBuffer_IsContiguous (const Py_buffer *view, char
          order)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     'view' で定義されているメモリが、 C スタイル ('order' == ‘'C'’) の
     ときか、 Fortran スタイル ('order' == ‘'F'’) *note 連続: 1016. のと
     きか、そのいずれか ('order' == ‘'A'’) であれば ‘1’ を返します。 そ
     れ以外の場合は ‘0’ を返します。 この関数は常に成功します。

 -- C の関数: void *PyBuffer_GetPointer (const Py_buffer *view, const
          Py_ssize_t *indices)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'  与
     えられた 'view' 内にある 'indices' が指すメモリ領域を取得します。
     'indices' は ‘view->ndim’ 個のインデックスからなる配列を指していな
     ければなりません。

 -- C の関数: int PyBuffer_FromContiguous (const Py_buffer *view, const
          void *buf, Py_ssize_t len, char fort)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'  連
     続する 'len' バイトを 'buf' から 'view' にコピーします。'fort' には
     ‘'C'’ か ‘'F'’ を指定できます（それぞれC言語スタイルとFortranスタイ
     ルの順序を表します)。成功時には ‘0’、エラー時には ‘-1’ を返します。

 -- C の関数: int PyBuffer_ToContiguous (void *buf, const Py_buffer
          *src, Py_ssize_t len, char order)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     'src' から 'len' バイトを連続表現で 'buf' 上にコピーします。
     'order' は ‘'C'’ または ‘'F'’ または ‘'A'’ (C スタイル順序または
     Fortran スタイル順序またはそれ以外) が指定できます。 成功したら ‘0’
     が返り、エラーなら ‘-1’ が返ります。

     'len' != 'src->len' の場合、この関数は失敗します。

 -- C の関数: int PyObject_CopyData (PyObject *dest, PyObject *src)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     Copy data from 'src' to 'dest' buffer.  Can convert between C-style
     and or Fortran-style buffers.

     成功したら ‘0’ が、エラー時には ‘-1’ が返されます。

 -- C の関数: void PyBuffer_FillContiguousStrides (int ndims, Py_ssize_t
          *shape, Py_ssize_t *strides, int itemsize, char order)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     'strides' 配列を、 'itemsize' の大きさの要素がバイト単位の、
     'shape' の形をした *note 連続な: 1016. ('order' が ‘'C'’ なら
     C-style 、 ‘'F'’ なら Fortran-style の) 多次元配列として埋める。

 -- C の関数: int PyBuffer_FillInfo (Py_buffer *view, PyObject
          *exporter, void *buf, Py_ssize_t len, int readonly, int flags)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'  サ
     イズが 'len' の 'buf' を 'readonly' に従った書き込み可/不可の設定で
     公開するバッファリクエストを処理します。 'buf' は符号無しバイトの列
     として解釈されます。

     'flags' 引数はリクエストのタイプを示します。 この関数は、 'buf' が
     読み出し専用と指定されていて、 'flags' に *note PyBUF_WRITABLE:
     1362. が設定されていない限り、常にフラグに指定された通りに 'view' を
     埋めます。

     On success, set ‘view->obj’ to a new reference to 'exporter' and
     return 0.  Otherwise, raise *note BufferError: 178f, set
     ‘view->obj’ to ‘NULL’ and return ‘-1’;

     この関数を *note getbufferproc: 1010. の一部として使う場合には、
     'exporter' はエクスポートするオブジェクトに設定しなければならず、さ
     らに 'flags' は変更せずに渡さなければなりません。 そうでない場合は
     、 'exporter' は ‘NULL’ でなければなりません。


File: python.info,  Node: 具象オブジェクト concrete object レイヤ,  Next: 初期化 initialization 、終了処理 finalization 、スレッド,  Prev: 抽象オブジェクトレイヤ Abstract Objects Layer,  Up: Python/C API リファレンスマニュアル

7.8 具象オブジェクト (concrete object) レイヤ
=============================================

この章では、特定の Python オブジェクト型固有の関数について述べています。
これらの関数に間違った型のオブジェクトを渡すのは良い考えではありません;
Python プログラムから何らかのオブジェクトを受け取ったとき、そのオブジェ
クトが正しい型になっているか確信をもてないのなら、まず型チェックを行わな
ければなりません; 例えば、あるオブジェクトが辞書型か調べるには、 *note
PyDict_Check(): 4a33. を使います。この章は Python のオブジェクト型におけ
る "家計図" に従って構成されています。

     警告: この章で述べている関数は、渡されたオブジェクトの型を注意深く
     チェックしはするものの、多くの関数は渡されたオブジェクトが有効な
     ‘NULL’ なのか有効なオブジェクトなのかをチェックしません。これらの関
     数に ‘NULL’ を渡させてしまうと、関数はメモリアクセス違反を起こして
     、インタプリタを即座に終了させてしまうはずです。

* Menu:

* 基本オブジェクト (fundamental object): 基本オブジェクト fundamental object.
* 数値型オブジェクト (numeric object): 数値型オブジェクト numeric object.
* シーケンスオブジェクト (sequence object): シーケンスオブジェクト sequence object.
* Container オブジェクト::
* Function オブジェクト: Function オブジェクト<2>.
* その他のオブジェクト: その他のオブジェクト<2>.


File: python.info,  Node: 基本オブジェクト fundamental object,  Next: 数値型オブジェクト numeric object,  Up: 具象オブジェクト concrete object レイヤ

7.8.1 基本オブジェクト (fundamental object)
-------------------------------------------

この節では、Python の型オブジェクトとシングルトン(singleton)オブジェクト
‘None’ について述べます。

* Menu:

* 型オブジェクト: 型オブジェクト<2>.
* None オブジェクト::


File: python.info,  Node: 型オブジェクト<2>,  Next: None オブジェクト,  Up: 基本オブジェクト fundamental object

7.8.1.1 型オブジェクト
......................

 -- C のデータ型: type PyTypeObject
     ' 次に属します: *note Limited API: 51e. (不透明な構造体として).'  組
     み込み型を記述する際に用いられる、オブジェクトを表す C 構造体です。

 -- C 変数: *note PyTypeObject: a73. PyType_Type
     ' 次に属します: *note Stable ABI: 51e.'  型オブジェクト自身の型オブ
     ジェクトです。Python レイヤにおける *note type: d16. と同じオブジェ
     クトです。

 -- C の関数: int PyType_Check (PyObject *o)

     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.

 -- C の関数: int PyType_CheckExact (PyObject *o)

     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.

 -- C の関数: unsigned int PyType_ClearCache ()
     ' 次に属します: *note Stable ABI: 51e.'  内部の検索キャッシュをクリ
     アします。現在のバージョンタグを返します。

 -- C の関数: unsigned long PyType_GetFlags (PyTypeObject *type)
     ' 次に属します: *note Stable ABI: 51e.'  Return the *note tp_flags:
     1828. member of 'type'.  This function is primarily meant for use
     with ‘Py_LIMITED_API’; the individual flag bits are guaranteed to
     be stable across Python releases, but access to *note tp_flags:
     1828. itself is not part of the *note limited API: 36f.

     Added in version 3.2.

     バージョン 3.4 で変更: 返り値の型が ‘long’ ではなく ‘unsigned long’
     になりました。

 -- C の関数: *note PyObject: 312. *PyType_GetDict (PyTypeObject *type)

     Return the type object's internal namespace, which is otherwise
     only exposed via a read-only proxy (*note cls.__dict__: c2b.).
     This is a replacement for accessing *note tp_dict: 1685. directly.
     The returned dictionary must be treated as read-only.

     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 *note PyObject_GetAttr(): 324.)
     isn't adequate.

     Extension modules should continue to use ‘tp_dict’, directly or
     indirectly, when setting up their own types.

     Added in version 3.12.

 -- C の関数: void PyType_Modified (PyTypeObject *type)
     ' 次に属します: *note Stable ABI: 51e.'  内部の検索キャッシュを、そ
     の type とすべてのサブタイプに対して無効にします。この関数は type の
     属性や基底クラス列を変更したあとに手動で呼び出さなければなりません
     。

 -- C の関数: int PyType_AddWatcher (PyType_WatchCallback callback)

     Register 'callback' as a type watcher.  Return a non-negative
     integer ID which must be passed to future calls to *note
     PyType_Watch(): 531.  In case of error (e.g.  no more watcher IDs
     available), return ‘-1’ and set an exception.

     Added in version 3.12.

 -- C の関数: int PyType_ClearWatcher (int watcher_id)

     Clear watcher identified by 'watcher_id' (previously returned from
     *note PyType_AddWatcher(): 530.).  Return ‘0’ on success, ‘-1’ on
     error (e.g.  if 'watcher_id' was never registered.)

     An extension should never call ‘PyType_ClearWatcher’ with a
     'watcher_id' that was not returned to it by a previous call to
     *note PyType_AddWatcher(): 530.

     Added in version 3.12.

 -- C の関数: int PyType_Watch (int watcher_id, PyObject *type)

     Mark 'type' as watched.  The callback granted 'watcher_id' by *note
     PyType_AddWatcher(): 530. will be called whenever *note
     PyType_Modified(): 175d. reports a change to 'type'.  (The callback
     may be called only once for a series of consecutive modifications
     to 'type', if ‘_PyType_Lookup()’ is not called on 'type' between
     the modifications; this is an implementation detail and subject to
     change.)

     An extension should never call ‘PyType_Watch’ with a 'watcher_id'
     that was not returned to it by a previous call to *note
     PyType_AddWatcher(): 530.

     Added in version 3.12.

 -- C のデータ型: typedef int (*PyType_WatchCallback)(*note PyObject:
          312. *type)

     Type of a type-watcher callback function.

     The callback must not modify 'type' or cause *note
     PyType_Modified(): 175d. to be called on 'type' or any type in its
     MRO; violating this rule could cause infinite recursion.

     Added in version 3.12.

 -- C の関数: int PyType_HasFeature (PyTypeObject *o, int feature)

     Return non-zero if the type object 'o' sets the feature 'feature'.
     Type features are denoted by single bit flags.

 -- C の関数: int PyType_IS_GC (PyTypeObject *o)

     Return true if the type object includes support for the cycle
     detector; this tests the type flag *note Py_TPFLAGS_HAVE_GC: 748.

 -- C の関数: int PyType_IsSubtype (PyTypeObject *a, PyTypeObject *b)
     ' 次に属します: *note Stable ABI: 51e.'  'a' が 'b' のサブタイプの
     場合に真を返します。

     This function only checks for actual subtypes, which means that
     *note __subclasscheck__(): 1ede. is not called on 'b'.  Call *note
     PyObject_IsSubclass(): e70. to do the same check that *note
     issubclass(): 78c. would do.

 -- C の関数: *note PyObject: 312. *PyType_GenericAlloc (PyTypeObject
          *type, Py_ssize_t nitems)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  型オ
     ブジェクトの *note tp_alloc: 477c. に対するジェネリックハンドラです
     。 Python のデフォルトのメモリアロケートメカニズムを使って新しいイ
     ンスタンスをアロケートし、すべての内容を ‘NULL’ で初期化します。

 -- C の関数: *note PyObject: 312. *PyType_GenericNew (PyTypeObject
          *type, PyObject *args, PyObject *kwds)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  型オ
     ブジェクトの *note tp_new: 54b. に対するジェネリックハンドラです。
     型の *note tp_alloc: 477c. スロットを使って新しいインスタンスを作成
     します。

 -- C の関数: int PyType_Ready (PyTypeObject *type)
     ' 次に属します: *note Stable ABI: 51e.'  型オブジェクトのファイナラ
     イズを行います。この関数は全てのオブジェクトで初期化を完了するため
     に呼び出されなくてはなりません。この関数は、基底クラス型から継承し
     たスロットを型オブジェクトに追加する役割があります。成功した場合に
     は ‘0’ を返し、エラーの場合には ‘-1’ を返して例外情報を設定します。

          注釈: If some of the base classes implements the GC protocol
          and the provided type does not include the *note
          Py_TPFLAGS_HAVE_GC: 748. in its flags, then the GC protocol
          will be automatically implemented from its parents.  On the
          contrary, if the type being created does include *note
          Py_TPFLAGS_HAVE_GC: 748. in its flags then it 'must' implement
          the GC protocol itself by at least implementing the *note
          tp_traverse: 749. handle.

 -- C の関数: *note PyObject: 312. *PyType_GetName (PyTypeObject *type)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.11 より).'  Return the type's name.  Equivalent to getting
     the type's *note __name__: 1450. attribute.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyType_GetQualName (PyTypeObject
          *type)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.11 より).'  Return the type's qualified name.  Equivalent
     to getting the type's *note __qualname__: 1e86. attribute.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyType_GetFullyQualifiedName
          (PyTypeObject *type)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Return the type's fully qualified name.  Equivalent to
     ‘f"{type.__module__}.{type.__qualname__}"’, or *note
     type.__qualname__: 1e86. if *note type.__module__: 34d. is not a
     string or is equal to ‘"builtins"’.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyType_GetModuleName (PyTypeObject
          *type)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Return the type's module name.  Equivalent to getting the *note
     type.__module__: 34d. attribute.

     Added in version 3.13.

 -- C の関数: void *PyType_GetSlot (PyTypeObject *type, int slot)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.4 より).'  与
     えられたスロットに格納されている関数ポインタを返します。返り値が
     ‘NULL’ の場合は、スロットが ‘NULL’ か、関数が不正な引数で呼ばれたこ
     とを示します。通常、呼び出し側は返り値のポインタを適切な関数型にキ
     ャストします。

     See *note PyType_Slot.slot: 4a3c. for possible values of the 'slot'
     argument.

     Added in version 3.4.

     バージョン 3.10 で変更: *note PyType_GetSlot(): 869. can now accept
     all types.  Previously, it was limited to *note heap types: 933.

 -- C の関数: *note PyObject: 312. *PyType_GetModule (PyTypeObject
          *type)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Return the module object associated with the given type when the
     type was created using *note PyType_FromModuleAndSpec(): 51c.

     If no module is associated with the given type, sets *note
     TypeError: 502. and returns ‘NULL’.

     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 not return the intended
     result.  ‘Py_TYPE(self)’ may be a 'subclass' of the intended class,
     and subclasses are not necessarily defined in the same module as
     their superclass.  See *note PyCMethod: 72f. to get the class that
     defines the method.  See *note PyType_GetModuleByDef(): 36d. for
     cases when ‘PyCMethod’ cannot be used.

     Added in version 3.9.

 -- C の関数: void *PyType_GetModuleState (PyTypeObject *type)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Return the state of the module object associated with the given
     type.  This is a shortcut for calling *note PyModule_GetState():
     94e. on the result of *note PyType_GetModule(): 93c.

     If no module is associated with the given type, sets *note
     TypeError: 502. and returns ‘NULL’.

     If the 'type' has an associated module but its state is ‘NULL’,
     returns ‘NULL’ without setting an exception.

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyType_GetModuleByDef (PyTypeObject
          *type, struct PyModuleDef *def)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Find the first superclass whose module was created from the given
     *note PyModuleDef: 94b. 'def', and return that module.

     If no module is found, raises a *note TypeError: 502. and returns
     ‘NULL’.

     This function is intended to be used together with *note
     PyModule_GetState(): 94e. to get module state from slot methods
     (such as *note tp_init: 54d. or *note nb_add: 4a3d.) and other
     places where a method's defining class cannot be passed using the
     *note PyCMethod: 72f. calling convention.

     Added in version 3.11.

 -- C の関数: int PyUnstable_Type_AssignVersionTag (PyTypeObject *type)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Attempt to assign a version tag to the given type.

     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.

     Added in version 3.12.

* Menu:

* Creating Heap-Allocated Types::


File: python.info,  Node: Creating Heap-Allocated Types,  Up: 型オブジェクト<2>

7.8.1.2 Creating Heap-Allocated Types
.....................................

The following functions and structs are used to create *note heap types:
933.

 -- C の関数: *note PyObject: 312. *PyType_FromMetaclass (PyTypeObject
          *metaclass, PyObject *module, PyType_Spec *spec, PyObject
          *bases)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'
     Create and return a *note heap type: 933. from the 'spec' (see
     *note Py_TPFLAGS_HEAPTYPE: 87d.).

     The metaclass 'metaclass' is used to construct the resulting type
     object.  When 'metaclass' is ‘NULL’, the metaclass is derived from
     'bases' (or 'Py_tp_base[s]' slots if 'bases' is ‘NULL’, see below).

     Metaclasses that override *note tp_new: 54b. are not supported,
     except if ‘tp_new’ is ‘NULL’.  (For backwards compatibility, other
     ‘PyType_From*’ functions allow such metaclasses.  They ignore
     ‘tp_new’, which may result in incomplete initialization.  This is
     deprecated and in Python 3.14+ such metaclasses will not be
     supported.)

     The 'bases' argument can be used to specify base classes; it can
     either be only one class or a tuple of classes.  If 'bases' is
     ‘NULL’, the 'Py_tp_bases' slot is used instead.  If that also is
     ‘NULL’, the 'Py_tp_base' slot is used instead.  If that also is
     ‘NULL’, the new type derives from *note object: a5a.

     The 'module' argument can be used to record the module in which the
     new class is defined.  It must be a module object or ‘NULL’.  If
     not ‘NULL’, the module is associated with the new type and can
     later be retrieved with *note PyType_GetModule(): 93c.  The
     associated module is not inherited by subclasses; it must be
     specified for each class individually.

     This function calls *note PyType_Ready(): 747. on the new type.

     Note that this function does 'not' fully match the behavior of
     calling *note type(): d16. or using the *note class: 12a5.
     statement.  With user-provided base types or metaclasses, prefer
     *note calling: 49e7. *note type: d16. (or the metaclass) over
     ‘PyType_From*’ functions.  Specifically:

        * *note __new__(): 54c. is not called on the new class (and it
          must be set to ‘type.__new__’).

        * *note __init__(): 67c. is not called on the new class.

        * *note __init_subclass__(): 5fd. is not called on any bases.

        * *note __set_name__(): c1c. is not called on new descriptors.

     Added in version 3.12.

 -- C の関数: *note PyObject: 312. *PyType_FromModuleAndSpec (PyObject
          *module, PyType_Spec *spec, PyObject *bases)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.10 より).'  Equivalent to ‘PyType_FromMetaclass(NULL,
     module, spec, bases)’.

     Added in version 3.9.

     バージョン 3.10 で変更: The function now accepts a single class as
     the 'bases' argument and ‘NULL’ as the ‘tp_doc’ slot.

     バージョン 3.12 で変更: The function now finds and uses a metaclass
     corresponding to the provided base classes.  Previously, only *note
     type: d16. instances were returned.

     The *note tp_new: 54b. of the metaclass is 'ignored'.  which may
     result in incomplete initialization.  Creating classes whose
     metaclass overrides *note tp_new: 54b. is deprecated and in Python
     3.14+ it will be no longer allowed.

 -- C の関数: *note PyObject: 312. *PyType_FromSpecWithBases
          (PyType_Spec *spec, PyObject *bases)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.3 より).'  Equivalent to ‘PyType_FromMetaclass(NULL, NULL,
     spec, bases)’.

     Added in version 3.3.

     バージョン 3.12 で変更: The function now finds and uses a metaclass
     corresponding to the provided base classes.  Previously, only *note
     type: d16. instances were returned.

     The *note tp_new: 54b. of the metaclass is 'ignored'.  which may
     result in incomplete initialization.  Creating classes whose
     metaclass overrides *note tp_new: 54b. is deprecated and in Python
     3.14+ it will be no longer allowed.

 -- C の関数: *note PyObject: 312. *PyType_FromSpec (PyType_Spec *spec)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Equivalent to ‘PyType_FromMetaclass(NULL, NULL, spec, NULL)’.

     バージョン 3.12 で変更: The function now finds and uses a metaclass
     corresponding to the base classes provided in 'Py_tp_base[s]'
     slots.  Previously, only *note type: d16. instances were returned.

     The *note tp_new: 54b. of the metaclass is 'ignored'.  which may
     result in incomplete initialization.  Creating classes whose
     metaclass overrides *note tp_new: 54b. is deprecated and in Python
     3.14+ it will be no longer allowed.

 -- C のデータ型: type PyType_Spec
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'
     Structure defining a type's behavior.

      -- C のメンバ変数: const char *name

          Name of the type, used to set *note PyTypeObject.tp_name:
          185d.

      -- C のメンバ変数: int basicsize

          If positive, specifies the size of the instance in bytes.  It
          is used to set *note PyTypeObject.tp_basicsize: 955.

          If zero, specifies that *note tp_basicsize: 955. should be
          inherited.

          If negative, the absolute value specifies how much space
          instances of the class need 'in addition' to the superclass.
          Use *note PyObject_GetTypeData(): 514. to get a pointer to
          subclass-specific memory reserved this way.

          バージョン 3.12 で変更: Previously, this field could not be
          negative.

      -- C のメンバ変数: int itemsize

          Size of one element of a variable-size type, in bytes.  Used
          to set *note PyTypeObject.tp_itemsize: 1ed0.  See
          ‘tp_itemsize’ documentation for caveats.

          If zero, *note tp_itemsize: 1ed0. is inherited.  Extending
          arbitrary variable-sized classes is dangerous, since some
          types use a fixed offset for variable-sized memory, which can
          then overlap fixed-sized memory used by a subclass.  To help
          prevent mistakes, inheriting ‘itemsize’ is only possible in
          the following situations:

             - The base is not variable-sized (its *note tp_itemsize:
               1ed0.).

             - The requested *note PyType_Spec.basicsize: 513. is
               positive, suggesting that the memory layout of the base
               class is known.

             - The requested *note PyType_Spec.basicsize: 513. is zero,
               suggesting that the subclass does not access the
               instance's memory directly.

             - With the *note Py_TPFLAGS_ITEMS_AT_END: 516. flag.

      -- C のメンバ変数: unsigned int flags

          Type flags, used to set *note PyTypeObject.tp_flags: 1828.

          If the ‘Py_TPFLAGS_HEAPTYPE’ flag is not set, *note
          PyType_FromSpecWithBases(): 54a. sets it automatically.

      -- C のメンバ変数: *note PyType_Slot: 48eb. *slots

          Array of *note PyType_Slot: 48eb. structures.  Terminated by
          the special slot value ‘{0, NULL}’.

          Each slot ID should be specified at most once.

 -- C のデータ型: type PyType_Slot
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'
     Structure defining optional functionality of a type, containing a
     slot ID and a value pointer.

      -- C のメンバ変数: int slot

               A slot ID.

               Slot IDs are named like the field names of the structures
               *note PyTypeObject: a73, *note PyNumberMethods: 13c5,
               *note PySequenceMethods: 479f, *note PyMappingMethods:
               47a0. and *note PyAsyncMethods: 4a44. with an added ‘Py_’
               prefix.  For example, use:

                  * ‘Py_tp_dealloc’ to set *note
                    PyTypeObject.tp_dealloc: 477a.

                  * ‘Py_nb_add’ to set *note PyNumberMethods.nb_add:
                    4a3d.

                  * ‘Py_sq_length’ to set *note
                    PySequenceMethods.sq_length: 4a45.

               The following “offset” fields cannot be set using *note
               PyType_Slot: 48eb.:

                       * *note tp_weaklistoffset: 956. (use *note
                         Py_TPFLAGS_MANAGED_WEAKREF: 525. instead if
                         possible)

                       * *note tp_dictoffset: 4a46. (use *note
                         Py_TPFLAGS_MANAGED_DICT: 344. instead if
                         possible)

                       * *note tp_vectorcall_offset: 49e9. (use
                         ‘"__vectorcalloffset__"’ in *note PyMemberDef:
                         4a47.)

                    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 *note
                    Py_tp_members: 477d.  See *note PyMemberDef
                    documentation: 4a47. for details.

               The following fields cannot be set at all when creating a
               heap type:

                  * *note tp_vectorcall: 4a48. (use *note tp_new: 54b.
                    and/or *note tp_init: 54d.)

                  * Internal fields: *note tp_dict: 1685, *note tp_mro:
                    4a49, *note tp_cache: 4a4a, *note tp_subclasses:
                    53e, and *note tp_weaklist: 4a4b.

               Setting ‘Py_tp_bases’ or ‘Py_tp_base’ may be problematic
               on some platforms.  To avoid issues, use the 'bases'
               argument of *note PyType_FromSpecWithBases(): 54a.
               instead.

          バージョン 3.9 で変更: Slots in *note PyBufferProcs: 4a4c. may
          be set in the unlimited API.

          バージョン 3.11 で変更: *note bf_getbuffer: 72d. and *note
          bf_releasebuffer: 72e. are now available under the *note
          limited API: 36f.

      -- C のメンバ変数: void *pfunc

          The desired value of the slot.  In most cases, this is a
          pointer to a function.

          Slots other than ‘Py_tp_doc’ may not be ‘NULL’.


File: python.info,  Node: None オブジェクト,  Prev: 型オブジェクト<2>,  Up: 基本オブジェクト fundamental object

7.8.1.3 ‘None’ オブジェクト
...........................

‘None’ に対する *note PyTypeObject: a73. は、 Python/C API では直接公開
されていないので注意してください。 ‘None’ は単量子 (singleton) なので、
オブジェクトの同一性テスト (C では ‘==’) を使うだけで十分だからです。同
じ理由から、 ‘PyNone_Check()’ 関数はありません。

 -- C 変数: *note PyObject: 312. *Py_None

     値の欠如を示す、 Python の ‘None’ オブジェクト。このオブジェクトは
     メソッドを持たず、 *note immortal: 41f8. です。

     バージョン 3.12 で変更: *note Py_None: 474c. は *note immortal:
     41f8. です。

 -- C のマクロ: Py_RETURN_NONE

     関数から *note Py_None: 474c. を返します。


File: python.info,  Node: 数値型オブジェクト numeric object,  Next: シーケンスオブジェクト sequence object,  Prev: 基本オブジェクト fundamental object,  Up: 具象オブジェクト concrete object レイヤ

7.8.2 数値型オブジェクト (numeric object)
-----------------------------------------

* Menu:

* 整数型オブジェクト (integer object): 整数型オブジェクト integer object.
* Boolean オブジェクト::
* Floating-Point Objects::
* 複素数オブジェクト::


File: python.info,  Node: 整数型オブジェクト integer object,  Next: Boolean オブジェクト,  Up: 数値型オブジェクト numeric object

7.8.2.1 整数型オブジェクト (integer object)
...........................................

すべての整数は任意の長さをもつ "long" 整数として実装されます。

エラーが起きると、ほとんどの ‘PyLong_As*’ API は ‘(return type)-1’ を返
しますが、これは数値と見分けが付きません。 見分けを付けるためには *note
PyErr_Occurred(): 185c. を使ってください。

 -- C のデータ型: type PyLongObject
     ' 次に属します: *note Limited API: 51e. (不透明な構造体として).'  こ
     の *note PyObject: 312. のサブタイプは整数型を表現します。

 -- C 変数: *note PyTypeObject: a73. PyLong_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは Python 整数型を表現します。これは Python レイ
     ヤにおける *note int: 238. と同じオブジェクトです。

 -- C の関数: int PyLong_Check (PyObject *p)

     引数が *note PyLongObject: 554. か *note PyLongObject: 554. のサブ
     タイプであるときに真を返します。この関数は常に成功します。

 -- C の関数: int PyLong_CheckExact (PyObject *p)

     引数が *note PyLongObject: 554. であるが *note PyLongObject: 554. の
     サブタイプでないときに真を返します。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyLong_FromLong (long v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  'v'
     から新たな *note PyLongObject: 554. オブジェクトを生成して返します
     。失敗のときには ‘NULL’ を返します。

     現在の実装では、‘-5’ から ‘256’ までの全ての整数に対する整数オブジ
     ェクトの配列を保持します。この範囲の数を生成すると、実際には既存の
     オブジェクトに対する参照が返るようになっています。

 -- C の関数: *note PyObject: 312. *PyLong_FromUnsignedLong (unsigned
          long v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  Cの
     unsigned long から新たな *note PyLongObject: 554. オブジェクトを生
     成して返します。失敗した際には ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyLong_FromSsize_t (Py_ssize_t v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  C の
     *note Py_ssize_t: a2e. 型から新たな *note PyLongObject: 554. オブジ
     ェクトを生成して返します。 失敗のときには ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyLong_FromSize_t (size_t v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  C の
     ‘size_t’ 型から新たな *note PyLongObject: 554. オブジェクトを生成し
     て返します。 失敗のときには ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyLong_FromLongLong (long long v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  C の
     long long 型から新たな *note PyLongObject: 554. オブジェクトを生成
     して返します。失敗のときには ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyLong_FromUnsignedLongLong
          (unsigned long long v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  C の
     unsigned long long 型から新たな *note PyLongObject: 554. オブジェク
     トを生成して返します。失敗のときには ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyLong_FromDouble (double v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  'v'
     の整数部から新たな *note PyLongObject: 554. オブジェクトを生成して
     返します。失敗のときには ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyLong_FromString (const char *str,
          char **pend, int base)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return a new *note PyLongObject: 554. based on the string value in
     'str', which is interpreted according to the radix in 'base', or
     ‘NULL’ on failure.  If 'pend' is non-‘NULL’, '*pend' will point to
     the end of 'str' on success or to the first character that could
     not be processed on error.  If 'base' is ‘0’, 'str' is interpreted
     using the *note 整数リテラル: 1e27. definition; in this case,
     leading zeros in a non-zero decimal number raises a *note
     ValueError: 1e3.  If 'base' is not ‘0’, it must be between ‘2’ and
     ‘36’, inclusive.  Leading and trailing whitespace and single
     underscores after a base specifier and between digits are ignored.
     If there are no digits or 'str' is not NULL-terminated following
     the digits and trailing whitespace, *note ValueError: 1e3. will be
     raised.

     参考
     ....

     Python methods *note int.to_bytes(): 17fa. and *note
     int.from_bytes(): 17ba. to convert a *note PyLongObject: 554.
     to/from an array of bytes in base ‘256’.  You can call those from C
     using *note PyObject_CallMethod(): 379.

 -- C の関数: *note PyObject: 312. *PyLong_FromUnicodeObject (PyObject
          *u, int base)
     '戻り値: 新しい参照。' Convert a sequence of Unicode digits in the
     string 'u' to a Python integer value.

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyLong_FromVoidPtr (void *p)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  ポイ
     ンタ 'p' から Python 整数値を生成します。ポインタの値は *note
     PyLong_AsVoidPtr(): 4871. を適用した結果から取得されます。

 -- C の関数: *note PyObject: 312. *PyLong_FromNativeBytes (const void
          *buffer, size_t n_bytes, int flags)

     Create a Python integer from the value contained in the first
     'n_bytes' of 'buffer', interpreted as a two's-complement signed
     number.

     'flags' are as for *note PyLong_AsNativeBytes(): 33a.  Passing ‘-1’
     will select the native endian that CPython was compiled with and
     assume that the most-significant bit is a sign bit.  Passing
     ‘Py_ASNATIVEBYTES_UNSIGNED_BUFFER’ will produce the same result as
     calling *note PyLong_FromUnsignedNativeBytes(): 33c.  Other flags
     are ignored.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyLong_FromUnsignedNativeBytes
          (const void *buffer, size_t n_bytes, int flags)

     Create a Python integer from the value contained in the first
     'n_bytes' of 'buffer', interpreted as an unsigned number.

     'flags' are as for *note PyLong_AsNativeBytes(): 33a.  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.

     Added in version 3.13.

 -- C の関数: long PyLong_AsLong (PyObject *obj)
     ' 次に属します: *note Stable ABI: 51e.'

     Return a C long representation of 'obj'.  If 'obj' is not an
     instance of *note PyLongObject: 554, first call its *note
     __index__(): 6e8. method (if present) to convert it to a *note
     PyLongObject: 554.

     もし 'obj' の値が long の範囲外であれば、 *note OverflowError: 84e.
     を送出します。

     エラーが起きたときに ‘-1’ を返します。 見分けを付けるためには *note
     PyErr_Occurred(): 185c. を使ってください。

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。

     バージョン 3.10 で変更: This function will no longer use *note
     __int__(): 6e7.

      -- C の関数: long PyLong_AS_LONG (PyObject *obj)

          A *note soft deprecated: 1ea. alias.  Exactly equivalent to
          the preferred ‘PyLong_AsLong’.  In particular, it can fail
          with *note OverflowError: 84e. or another exception.

          バージョン 3.14 で非推奨: The function is soft deprecated.

 -- C の関数: int PyLong_AsInt (PyObject *obj)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Similar to *note PyLong_AsLong(): 339, but store the result in a C
     int instead of a C long.

     Added in version 3.13.

 -- C の関数: long PyLong_AsLongAndOverflow (PyObject *obj, int
          *overflow)
     ' 次に属します: *note Stable ABI: 51e.'  Return a C long
     representation of 'obj'.  If 'obj' is not an instance of *note
     PyLongObject: 554, first call its *note __index__(): 6e8. method
     (if present) to convert it to a *note PyLongObject: 554.

     If the value of 'obj' is greater than ‘LONG_MAX’ or less than
     ‘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.

     エラーが起きたときに ‘-1’ を返します。 見分けを付けるためには *note
     PyErr_Occurred(): 185c. を使ってください。

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。

     バージョン 3.10 で変更: This function will no longer use *note
     __int__(): 6e7.

 -- C の関数: long long PyLong_AsLongLong (PyObject *obj)
     ' 次に属します: *note Stable ABI: 51e.'

     Return a C long long representation of 'obj'.  If 'obj' is not an
     instance of *note PyLongObject: 554, first call its *note
     __index__(): 6e8. method (if present) to convert it to a *note
     PyLongObject: 554.

     もし 'obj' の値が long long の範囲外であれば、 *note OverflowError:
     84e. を送出します。

     エラーが起きたときに ‘-1’ を返します。 見分けを付けるためには *note
     PyErr_Occurred(): 185c. を使ってください。

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。

     バージョン 3.10 で変更: This function will no longer use *note
     __int__(): 6e7.

 -- C の関数: long long PyLong_AsLongLongAndOverflow (PyObject *obj, int
          *overflow)
     ' 次に属します: *note Stable ABI: 51e.'  Return a C long long
     representation of 'obj'.  If 'obj' is not an instance of *note
     PyLongObject: 554, first call its *note __index__(): 6e8. method
     (if present) to convert it to a *note PyLongObject: 554.

     If the value of 'obj' is greater than ‘LLONG_MAX’ or less than
     ‘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.

     エラーが起きたときに ‘-1’ を返します。 見分けを付けるためには *note
     PyErr_Occurred(): 185c. を使ってください。

     Added in version 3.2.

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。

     バージョン 3.10 で変更: This function will no longer use *note
     __int__(): 6e7.

 -- C の関数: *note Py_ssize_t: a2e. PyLong_AsSsize_t (PyObject *pylong)
     ' 次に属します: *note Stable ABI: 51e.'

     'pylong' を表す C の *note Py_ssize_t: a2e. を返します。 'pylong' は
     *note PyLongObject: 554. のインスタンスでなければなりません。

     もし 'pylong' の値が *note Py_ssize_t: a2e. の範囲外であれば、
     *note OverflowError: 84e. を送出します。

     エラーが起きたときに ‘-1’ を返します。 見分けを付けるためには *note
     PyErr_Occurred(): 185c. を使ってください。

 -- C の関数: unsigned long PyLong_AsUnsignedLong (PyObject *pylong)
     ' 次に属します: *note Stable ABI: 51e.'

     'pylong' を表す C の unsigned long を返します。 'pylong' は *note
     PyLongObject: 554. のインスタンスでなければなりません。

     もし 'pylong' の値が unsigned long の範囲外であれば、 *note
     OverflowError: 84e. を送出します。

     エラーが起きたときに ‘(unsigned long)-1’ を返します。 見分けを付け
     るためには *note PyErr_Occurred(): 185c. を使ってください。

 -- C の関数: size_t PyLong_AsSize_t (PyObject *pylong)
     ' 次に属します: *note Stable ABI: 51e.'

     'pylong' を表す C の ‘size_t’ を返します。 'pylong' は *note
     PyLongObject: 554. のインスタンスでなければなりません。

     もし 'pylong' の値が ‘size_t’ の範囲外であれば、 *note
     OverflowError: 84e. を送出します。

     エラーが起きたときに ‘(size_t)-1’ を返します。 見分けを付けるために
     は *note PyErr_Occurred(): 185c. を使ってください。

 -- C の関数: unsigned long long PyLong_AsUnsignedLongLong (PyObject
          *pylong)
     ' 次に属します: *note Stable ABI: 51e.'

     'pylong' を表す C の unsigned long long を返します。 'pylong' は
     *note PyLongObject: 554. のインスタンスでなければなりません。

     もし 'pylong' の値が unsigned long long の範囲外であれば、 *note
     OverflowError: 84e. を送出します。

     エラーが起きたときに ‘(unsigned long long)-1’ を返します。 見分けを
     付けるためには *note PyErr_Occurred(): 185c. を使ってください。

     バージョン 3.1 で変更: 負 'pylong' を指定した際に *note TypeError:
     502. ではなく、 *note OverflowError: 84e. を送出するようになりまし
     た。

 -- C の関数: unsigned long PyLong_AsUnsignedLongMask (PyObject *obj)
     ' 次に属します: *note Stable ABI: 51e.'  Return a C unsigned long
     representation of 'obj'.  If 'obj' is not an instance of *note
     PyLongObject: 554, first call its *note __index__(): 6e8. method
     (if present) to convert it to a *note PyLongObject: 554.

     'obj' の値が unsigned long の範囲から外れていた場合は、 ‘ULONG_MAX
     + 1’ を法とした剰余を返します。

     エラーが起きたときに ‘(unsigned long)-1’ を返します。 見分けを付け
     るためには *note PyErr_Occurred(): 185c. を使ってください。

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。

     バージョン 3.10 で変更: This function will no longer use *note
     __int__(): 6e7.

 -- C の関数: unsigned long long PyLong_AsUnsignedLongLongMask (PyObject
          *obj)
     ' 次に属します: *note Stable ABI: 51e.'  Return a C unsigned long
     long representation of 'obj'.  If 'obj' is not an instance of *note
     PyLongObject: 554, first call its *note __index__(): 6e8. method
     (if present) to convert it to a *note PyLongObject: 554.

     'obj' の値が unsigned long long の範囲から外れていた場合は、
     ‘ULLONG_MAX + 1’ を法とした剰余を返します。

     エラーが起きたときに ‘(unsigned long long)-1’ を返します。 見分けを
     付けるためには *note PyErr_Occurred(): 185c. を使ってください。

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。

     バージョン 3.10 で変更: This function will no longer use *note
     __int__(): 6e7.

 -- C の関数: double PyLong_AsDouble (PyObject *pylong)
     ' 次に属します: *note Stable ABI: 51e.'  'pylong' を表す C の
     double を返します。 'pylong' は *note PyLongObject: 554. のインスタ
     ンスでなければなりません。

     もし 'pylong' の値が double の範囲外であれば、 *note OverflowError:
     84e. を送出します。

     エラーが起きたときに ‘-1.0’ を返します。 見分けを付けるためには
     *note PyErr_Occurred(): 185c. を使ってください。

 -- C の関数: void *PyLong_AsVoidPtr (PyObject *pylong)
     ' 次に属します: *note Stable ABI: 51e.'  Python の整数型を指す
     'pylong' を、 C の void ポインタに変換します。 'pylong' を変換でき
     なければ、 *note OverflowError: 84e. を送出します。この関数は *note
     PyLong_FromVoidPtr(): 4874. で値を生成するときに使うような void ポ
     インタ型を生成できるだけです。

     エラーが起きたときに ‘NULL’ を返します。 見分けを付けるためには
     *note PyErr_Occurred(): 185c. を使ってください。

 -- C の関数: *note Py_ssize_t: a2e. PyLong_AsNativeBytes (PyObject
          *pylong, void *buffer, Py_ssize_t n_bytes, int flags)

     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.

     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.

     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: large buffers are
     padded with zeroes.

     If the returned value is greater than 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.

          注釈: Overflow is not considered an error.  If the returned
          value is larger than 'n_bytes', most significant bits were
          discarded.

     ‘0’ will never be returned.

     Values are always copied as two's-complement.

     Usage example:

          int32_t value;
          Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, &value, sizeof(value), -1);
          if (bytes < 0) {
              // Failed. A Python exception was set with the reason.
              return NULL;
          }
          else if (bytes <= (Py_ssize_t)sizeof(value)) {
              // Success!
          }
          else {
              // Overflow occurred, but 'value' contains the truncated
              // lowest bits of pylong.
          }

     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’.

          注釈: Passing 'n_bytes=0' to this function is not an accurate
          way to determine the bit length of the value.

     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:

          // Ask how much space we need.
          Py_ssize_t expected = PyLong_AsNativeBytes(pylong, NULL, 0, -1);
          if (expected < 0) {
              // Failed. A Python exception was set with the reason.
              return NULL;
          }
          assert(expected != 0);  // Impossible per the API definition.
          uint8_t *bignum = malloc(expected);
          if (!bignum) {
              PyErr_SetString(PyExc_MemoryError, "bignum malloc failed.");
              return NULL;
          }
          // Safely get the entire value.
          Py_ssize_t bytes = PyLong_AsNativeBytes(pylong, bignum, expected, -1);
          if (bytes < 0) {  // Exception has been set.
              free(bignum);
              return NULL;
          }
          else if (bytes > expected) {  // This should not be possible.
              PyErr_SetString(PyExc_RuntimeError,
                  "Unexpected bignum truncation after a size check.");
              free(bignum);
              return NULL;
          }
          // The expected success given the above pre-check.
          // ... use bignum ...
          free(bignum);

     '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.

     Currently, ‘-1’ corresponds to ‘Py_ASNATIVEBYTES_NATIVE_ENDIAN |
     Py_ASNATIVEBYTES_UNSIGNED_BUFFER’.

     Flag                                              値
                                                       
     -------------------------------------------------------------
                                                       
      -- C のマクロ: Py_ASNATIVEBYTES_DEFAULTS         ‘-1’
                                                       
                                                       
      -- C のマクロ: Py_ASNATIVEBYTES_BIG_ENDIAN       ‘0’
                                                       
                                                       
      -- C のマクロ: Py_ASNATIVEBYTES_LITTLE_ENDIAN    ‘1’
                                                       
                                                       
      -- C のマクロ: Py_ASNATIVEBYTES_NATIVE_ENDIAN    ‘3’
                                                       
                                                       
      -- C のマクロ:                                   ‘4’
               Py_ASNATIVEBYTES_UNSIGNED_BUFFER        

      -- C のマクロ:                                   ‘8’
               Py_ASNATIVEBYTES_REJECT_NEGATIVE        

      -- C のマクロ: Py_ASNATIVEBYTES_ALLOW_INDEX      ‘16’
                                                       

     Specifying ‘Py_ASNATIVEBYTES_NATIVE_ENDIAN’ will override any other
     endian flags.  Passing ‘2’ is reserved.

     By default, sufficient buffer will be requested to include a sign
     bit.  For example, when converting 128 with 'n_bytes=1', the
     function will return 2 (or more) in order to store a zero sign bit.

     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 single-byte buffer.  If the destination buffer is
     later treated as signed, a positive input value may become
     negative.  Note that the flag does not affect handling of negative
     values: for those, space for a sign bit is always requested.

     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.

     If ‘Py_ASNATIVEBYTES_ALLOW_INDEX’ is specified and a non-integer
     value is passed, its *note __index__(): 6e8. method will be called
     first.  This may result in Python code executing and other threads
     being allowed to run, which could cause changes to other objects or
     values in use.  When 'flags' is ‘-1’, this option is not set, and
     non-integer values will raise *note TypeError: 502.

          注釈: 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.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyLong_GetInfo (void)
     ' 次に属します: *note Stable ABI: 51e.'  On success, return a read
     only *note named tuple: 61a, that holds information about Python's
     internal representation of integers.  See *note sys.int_info: 1264.
     for description of individual fields.

     On failure, return ‘NULL’ with an exception set.

     Added in version 3.1.

 -- C の関数: int PyUnstable_Long_IsCompact (const PyLongObject *op)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Return 1 if 'op' is compact, 0 otherwise.

     This function makes it possible for performance-critical code to
     implement a “fast path” for small integers.  For compact values use
     *note PyUnstable_Long_CompactValue(): 556.; for others fall back to
     a *note PyLong_As*: 486d. function or *note PyLong_AsNativeBytes():
     33a.

     The speedup is expected to be negligible for most users.

     Exactly what values are considered compact is an implementation
     detail and is subject to change.

     Added in version 3.12.

 -- C の関数: *note Py_ssize_t: a2e. PyUnstable_Long_CompactValue (const
          PyLongObject *op)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     If 'op' is compact, as determined by *note
     PyUnstable_Long_IsCompact(): 555, return its value.

     Otherwise, the return value is undefined.

     Added in version 3.12.


File: python.info,  Node: Boolean オブジェクト,  Next: Floating-Point Objects,  Prev: 整数型オブジェクト integer object,  Up: 数値型オブジェクト numeric object

7.8.2.2 Boolean オブジェクト
............................

Python の Bool 型は整数のサブクラスとして実装されています。ブール型の値
は、 *note Py_False: 4a63. と *note Py_True: 4a64. の 2 つしかありません
。従って、通常の生成／削除関数はブール型にはあてはまりません。とはいえ、
以下のマクロが利用できます。

 -- C 変数: *note PyTypeObject: a73. PyBool_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは Python の boolean 型を表現します; Python レイ
     ヤにおける *note bool: 434. と同じオブジェクトです。

 -- C の関数: int PyBool_Check (PyObject *o)

     'o' が *note PyBool_Type: 47f7. 型の場合に真を返します。この関数は
     常に成功します。

 -- C 変数: *note PyObject: 312. *Py_False

     Python の ‘False’ オブジェクト。このオブジェクトはメソッドを持たず
     、 *note immortal: 41f8. です。

     バージョン 3.12 で変更: *note Py_False: 4a63. は *note immortal:
     41f8. です。

 -- C 変数: *note PyObject: 312. *Py_True

     Python の ‘True’ オブジェクト。このオブジェクトはメソッドを持たず、
     *note immortal: 41f8. です。

     バージョン 3.12 で変更: *note Py_True: 4a64. は *note immortal:
     41f8. です。

 -- C のマクロ: Py_RETURN_FALSE

     関数から *note Py_False: 4a63. を返します。

 -- C のマクロ: Py_RETURN_TRUE

     関数から *note Py_True: 4a64. を返します。

 -- C の関数: *note PyObject: 312. *PyBool_FromLong (long v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  'v'
     の真理値に応じて *note Py_True: 4a64. または *note Py_False: 4a63.
     を返します。


File: python.info,  Node: Floating-Point Objects,  Next: 複素数オブジェクト,  Prev: Boolean オブジェクト,  Up: 数値型オブジェクト numeric object

7.8.2.3 Floating-Point Objects
..............................

 -- C のデータ型: type PyFloatObject

     This subtype of *note PyObject: 312. represents a Python
     floating-point object.

 -- C 変数: *note PyTypeObject: a73. PyFloat_Type
     ' 次に属します: *note Stable ABI: 51e.'  This instance of *note
     PyTypeObject: a73. represents the Python floating-point type.  This
     is the same object as *note float: 2ce. in the Python layer.

 -- C の関数: int PyFloat_Check (PyObject *p)

     引数が *note PyFloatObject: 4a69. か *note PyFloatObject: 4a69. の
     サブタイプであるときに真を返します。この関数は常に成功します。

 -- C の関数: int PyFloat_CheckExact (PyObject *p)

     引数が *note PyFloatObject: 4a69. であるが *note PyFloatObject:
     4a69. のサブタイプでないときに真を返します。この関数は常に成功しま
     す。

 -- C の関数: *note PyObject: 312. *PyFloat_FromString (PyObject *str)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'str' の文字列値をもとに *note PyFloatObject: 4a69. オブジェクトを
     生成します。失敗すると ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyFloat_FromDouble (double v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  'v'
     から *note PyFloatObject: 4a69. オブジェクトを生成して返します。 失
     敗すると ‘NULL’ を返します。

 -- C の関数: double PyFloat_AsDouble (PyObject *pyfloat)
     ' 次に属します: *note Stable ABI: 51e.'  Return a C double
     representation of the contents of 'pyfloat'.  If 'pyfloat' is not a
     Python floating-point object but has a *note __float__(): 99a.
     method, this method will first be called to convert 'pyfloat' into
     a float.  If ‘__float__()’ is not defined then it falls back to
     *note __index__(): 6e8.  This method returns ‘-1.0’ upon failure,
     so one should call *note PyErr_Occurred(): 185c. to check for
     errors.

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。

 -- C の関数: double PyFloat_AS_DOUBLE (PyObject *pyfloat)

     'pyfloat' の指す値を、 C の double 型表現で返しますが、エラーチェッ
     クを行いません。

 -- C の関数: *note PyObject: 312. *PyFloat_GetInfo (void)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     float の精度、最小値、最大値に関する情報を含む structseq インスタン
     スを返します。これは、 ‘float.h’ ファイルの薄いラッパーです。

 -- C の関数: double PyFloat_GetMax ()
     ' 次に属します: *note Stable ABI: 51e.'  float の表現できる最大限解
     値 'DBL_MAX' を C の double 型で返します。

 -- C の関数: double PyFloat_GetMin ()
     ' 次に属します: *note Stable ABI: 51e.'  float の正規化された最小の
     正の値 'DBL_MIN' を C の double 型で返します。

* Menu:

* Pack and Unpack functions::


File: python.info,  Node: Pack and Unpack functions,  Up: Floating-Point Objects

7.8.2.4 Pack and Unpack functions
.................................

The pack and unpack functions provide an efficient platform-independent
way to store floating-point values as byte strings.  The Pack routines
produce a bytes string from a C double, and the Unpack routines produce
a C double from such a bytes string.  The suffix (2, 4 or 8) specifies
the number of bytes in the bytes string.

On platforms that appear to use IEEE 754 formats these functions work by
copying bits.  On other platforms, the 2-byte format is identical to the
IEEE 754 binary16 half-precision format, the 4-byte format (32-bit) is
identical to the IEEE 754 binary32 single precision format, and the
8-byte format to the IEEE 754 binary64 double precision format, although
the packing of INFs and NaNs (if such things exist on the platform)
isn't handled correctly, and attempting to unpack a bytes string
containing an IEEE INF or NaN will raise an exception.

On non-IEEE platforms with more precision, or larger dynamic range, than
IEEE 754 supports, not all values can be packed; on non-IEEE platforms
with less precision, or smaller dynamic range, not all values can be
unpacked.  What happens in such cases is partly accidental (alas).

Added in version 3.11.

* Menu:

* Pack functions::
* Unpack functions::


File: python.info,  Node: Pack functions,  Next: Unpack functions,  Up: Pack and Unpack functions

7.8.2.5 Pack functions
......................

The pack routines write 2, 4 or 8 bytes, starting at 'p'.  'le' is an
int argument, non-zero if you want the bytes string in little-endian
format (exponent last, at ‘p+1’, ‘p+3’, or ‘p+6’ ‘p+7’), zero if you
want big-endian format (exponent first, at 'p').  The ‘PY_BIG_ENDIAN’
constant can be used to use the native endian: it is equal to ‘1’ on big
endian processor, or ‘0’ on little endian processor.

Return value: ‘0’ if all is OK, ‘-1’ if error (and an exception is set,
most likely *note OverflowError: 84e.).

There are two problems on non-IEEE platforms:

   * What this does is undefined if 'x' is a NaN or infinity.

   * ‘-0.0’ and ‘+0.0’ produce the same bytes string.

 -- C の関数: int PyFloat_Pack2 (double x, unsigned char *p, int le)

     Pack a C double as the IEEE 754 binary16 half-precision format.

 -- C の関数: int PyFloat_Pack4 (double x, unsigned char *p, int le)

     Pack a C double as the IEEE 754 binary32 single precision format.

 -- C の関数: int PyFloat_Pack8 (double x, unsigned char *p, int le)

     Pack a C double as the IEEE 754 binary64 double precision format.


File: python.info,  Node: Unpack functions,  Prev: Pack functions,  Up: Pack and Unpack functions

7.8.2.6 Unpack functions
........................

The unpack routines read 2, 4 or 8 bytes, starting at 'p'.  'le' is an
int argument, non-zero if the bytes string is in little-endian format
(exponent last, at ‘p+1’, ‘p+3’ or ‘p+6’ and ‘p+7’), zero if big-endian
(exponent first, at 'p').  The ‘PY_BIG_ENDIAN’ constant can be used to
use the native endian: it is equal to ‘1’ on big endian processor, or
‘0’ on little endian processor.

Return value: The unpacked double.  On error, this is ‘-1.0’ and *note
PyErr_Occurred(): 185c. is true (and an exception is set, most likely
*note OverflowError: 84e.).

Note that on a non-IEEE platform this will refuse to unpack a bytes
string that represents a NaN or infinity.

 -- C の関数: double PyFloat_Unpack2 (const unsigned char *p, int le)

     Unpack the IEEE 754 binary16 half-precision format as a C double.

 -- C の関数: double PyFloat_Unpack4 (const unsigned char *p, int le)

     Unpack the IEEE 754 binary32 single precision format as a C double.

 -- C の関数: double PyFloat_Unpack8 (const unsigned char *p, int le)

     Unpack the IEEE 754 binary64 double precision format as a C double.


File: python.info,  Node: 複素数オブジェクト,  Prev: Floating-Point Objects,  Up: 数値型オブジェクト numeric object

7.8.2.7 複素数オブジェクト
..........................

Python の複素数オブジェクトは、C API 側から見ると二つの別個の型として実
装されています: 一方は Python プログラムに対して公開されている Python の
オブジェクトで、他方は実際の複素数値を表現する C の構造体です。API では
、これら双方を扱う関数を提供しています。

* Menu:

* C 構造体としての複素数::
* Python オブジェクトとしての複素数型::


File: python.info,  Node: C 構造体としての複素数,  Next: Python オブジェクトとしての複素数型,  Up: 複素数オブジェクト

7.8.2.8 C 構造体としての複素数
..............................

複素数の C 構造体を引数として受理したり、戻り値として返したりする関数は
、ポインタ渡しを行うのではなく '値渡し' を行うので注意してください。これ
は API 全体を通して一貫しています。

 -- C のデータ型: type Py_complex

     The C structure which corresponds to the value portion of a Python
     complex number object.  Most of the functions for dealing with
     complex number objects use structures of this type as input or
     output values, as appropriate.

      -- C のメンバ変数: double real
      -- C のメンバ変数: double imag

     The structure is defined as:

          typedef struct {
              double real;
              double imag;
          } Py_complex;

 -- C の関数: *note Py_complex: 49a9. _Py_c_sum (Py_complex left,
          Py_complex right)

     二つの複素数の和を C の *note Py_complex: 49a9. 型で返します。

 -- C の関数: *note Py_complex: 49a9. _Py_c_diff (Py_complex left,
          Py_complex right)

     二つの複素数の差を C の *note Py_complex: 49a9. 型で返します。

 -- C の関数: *note Py_complex: 49a9. _Py_c_neg (Py_complex num)

     複素数 'num' の符号反転 C の *note Py_complex: 49a9. 型で返します。

 -- C の関数: *note Py_complex: 49a9. _Py_c_prod (Py_complex left,
          Py_complex right)

     二つの複素数の積を C の *note Py_complex: 49a9. 型で返します。

 -- C の関数: *note Py_complex: 49a9. _Py_c_quot (Py_complex dividend,
          Py_complex divisor)

     二つの複素数の商を C の *note Py_complex: 49a9. 型で返します。

     'divisor' が null の場合は、このメソッドはゼロを返し、 ‘errno’ に
     ‘EDOM’ をセットします。

 -- C の関数: *note Py_complex: 49a9. _Py_c_pow (Py_complex num,
          Py_complex exp)

     指数 'exp' の 'num' 乗を C の *note Py_complex: 49a9. 型で返します
     。

     'num' が null で 'exp' が正の実数でない場合は、このメソッドはゼロを
     返し、 ‘errno’ に ‘EDOM’ をセットします。


File: python.info,  Node: Python オブジェクトとしての複素数型,  Prev: C 構造体としての複素数,  Up: 複素数オブジェクト

7.8.2.9 Python オブジェクトとしての複素数型
...........................................

 -- C のデータ型: type PyComplexObject

     この *note PyObject: 312. のサブタイプは Python の複素数型を表現し
     ます。

 -- C 変数: *note PyTypeObject: a73. PyComplex_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは Python の複素数型を表現します。 Pythonレイヤ
     の *note complex: 2cf. と同じオブジェクトです。

 -- C の関数: int PyComplex_Check (PyObject *p)

     引数が *note PyComplexObject: 4a7d. か *note PyComplexObject: 4a7d.
     のサブタイプであるときに真を返します。この関数は常に成功します。

 -- C の関数: int PyComplex_CheckExact (PyObject *p)

     引数が *note PyComplexObject: 4a7d. であるが *note PyComplexObject:
     4a7d. のサブタイプでないときに真を返します。この関数は常に成功しま
     す。

 -- C の関数: *note PyObject: 312. *PyComplex_FromCComplex (Py_complex
          v)
     '戻り値: 新しい参照。' Create a new Python complex number object
     from a C *note Py_complex: 49a9. value.  Return ‘NULL’ with an
     exception set on error.

 -- C の関数: *note PyObject: 312. *PyComplex_FromDoubles (double real,
          double imag)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return a new *note PyComplexObject: 4a7d. object from 'real' and
     'imag'.  Return ‘NULL’ with an exception set on error.

 -- C の関数: double PyComplex_RealAsDouble (PyObject *op)
     ' 次に属します: *note Stable ABI: 51e.'  'op' の実数部分を C の
     double 型で返します。

     If 'op' is not a Python complex number object but has a *note
     __complex__(): 5b1. method, this method will first be called to
     convert 'op' to a Python complex number object.  If ‘__complex__()’
     is not defined then it falls back to call *note PyFloat_AsDouble():
     a37. and returns its result.

     Upon failure, this method returns ‘-1.0’ with an exception set, so
     one should call *note PyErr_Occurred(): 185c. to check for errors.

     バージョン 3.13 で変更: Use *note __complex__(): 5b1. if available.

 -- C の関数: double PyComplex_ImagAsDouble (PyObject *op)
     ' 次に属します: *note Stable ABI: 51e.'  'op' の虚数部分を C の
     double 型で返します。

     If 'op' is not a Python complex number object but has a *note
     __complex__(): 5b1. method, this method will first be called to
     convert 'op' to a Python complex number object.  If ‘__complex__()’
     is not defined then it falls back to call *note PyFloat_AsDouble():
     a37. and returns ‘0.0’ on success.

     Upon failure, this method returns ‘-1.0’ with an exception set, so
     one should call *note PyErr_Occurred(): 185c. to check for errors.

     バージョン 3.13 で変更: Use *note __complex__(): 5b1. if available.

 -- C の関数: *note Py_complex: 49a9. PyComplex_AsCComplex (PyObject
          *op)

     複素数値 'op' から *note Py_complex: 49a9. 型を生成します。

     If 'op' is not a Python complex number object but has a *note
     __complex__(): 5b1. method, this method will first be called to
     convert 'op' to a Python complex number object.  If ‘__complex__()’
     is not defined then it falls back to *note __float__(): 99a.  If
     ‘__float__()’ is not defined then it falls back to *note
     __index__(): 6e8.

     Upon failure, this method returns *note Py_complex: 49a9. with
     *note real: 4a74. set to ‘-1.0’ and with an exception set, so one
     should call *note PyErr_Occurred(): 185c. to check for errors.

     バージョン 3.8 で変更: 可能であれば *note __index__(): 6e8. を使う
     ようになりました。


File: python.info,  Node: シーケンスオブジェクト sequence object,  Next: Container オブジェクト,  Prev: 数値型オブジェクト numeric object,  Up: 具象オブジェクト concrete object レイヤ

7.8.3 シーケンスオブジェクト (sequence object)
----------------------------------------------

シーケンスオブジェクトに対する一般的な操作については前の章ですでに述べま
した; この節では、Python 言語にもともと備わっている特定のシーケンスオブ
ジェクトについて扱います。

* Menu:

* バイトオブジェクト: バイトオブジェクト<2>.
* bytearray オブジェクト: bytearray オブジェクト<2>.
* Unicode オブジェクトと codec::
* タプルオブジェクト (tuple object): タプルオブジェクト tuple object.
* Struct Sequence オブジェクト::
* リストオブジェクト::


File: python.info,  Node: バイトオブジェクト<2>,  Next: bytearray オブジェクト<2>,  Up: シーケンスオブジェクト sequence object

7.8.3.1 バイトオブジェクト
..........................

下記の関数は、バイトオブジェクトを期待している引数にバイトオブジェクトで
ないパラメタを指定して呼び出されると、 *note TypeError: 502. を送出しま
す。

 -- C のデータ型: type PyBytesObject

     この *note PyObject: 312. のサブタイプは、Python バイトオブジェクト
     を表します。

 -- C 変数: *note PyTypeObject: a73. PyBytes_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは、Python バイト型を表します; Pythonレイヤの
     *note bytes: 1a4. と同じオブジェクトです。

 -- C の関数: int PyBytes_Check (PyObject *o)

     オブジェクト 'o' が bytes オブジェクトか bytes 型のサブタイプのイン
     スタンスである場合に真を返します。この関数は常に成功します。

 -- C の関数: int PyBytes_CheckExact (PyObject *o)

     オブジェクト 'o' が bytes オブジェクトだが bytes 型のサブタイプのイ
     ンスタンスでない場合に真を返します。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyBytes_FromString (const char *v)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     時に、文字列 'v' のコピーを値とする新しいバイトオブジェクトを返し、
     失敗時に ‘NULL’ を返します。 引数 'v' は ‘NULL’ であってはなりませ
     ん; そのチェックは行われません。

 -- C の関数: *note PyObject: 312. *PyBytes_FromStringAndSize (const
          char *v, Py_ssize_t len)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  成功
     時に、文字列 'v' のコピーを値とする長さ 'len' の新しいバイトオブジ
     ェクトを返し、失敗時に ‘NULL’ を返します。 引数 'v' が ‘NULL’ の場
     合、バイトオブジェクトの中身は初期化されていません。

 -- C の関数: *note PyObject: 312. *PyBytes_FromFormat (const char
          *format, ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  C 関
     数の ‘printf()’ スタイルの 'format' 文字列と可変長の引数を取り、結
     果のPython バイトオブジェクトのサイズを計算し、値を指定した書式にし
     たがって変換したバイトオブジェクトを返します。可変長の引数は C のデ
     ータ型でなければならず、 'format' 文字列中のフォーマット文字と厳密
     に関連付けられていなければなりません。下記のフォーマット文字が使用
     できます:

     書式指定文字            型                  備考
                                                 
     ---------------------------------------------------------------------------------
                                                 
     ‘%%’                    'n/a'               リテラルの % 文字
                                                 
                                                 
     ‘%c’                    int                 C の整数型で表現される単一のバイト
                                                 。
                                                 
                                                 
     ‘%d’                    int                 ‘printf("%d")’ と同等。 (1)
                                                 
                                                 
     ‘%u’                    unsigned int        ‘printf("%u")’ と同等。 (2)
                                                 
                                                 
     ‘%ld’                   long                ‘printf("%ld")’ と同等。 (3)
                                                 
                                                 
     ‘%lu’                   unsigned long       ‘printf("%lu")’ と同等。 (4)
                                                 
                                                 
     ‘%zd’                   *note Py_ssize_t: a2e.‘printf("%zd")’ と同等。 (5)
                                                 
                                                 
     ‘%zu’                   size_t              ‘printf("%zu")’ と同等。 (6)
                                                 
                                                 
     ‘%i’                    int                 ‘printf("%i")’ と同等。 (7)
                                                 
                                                 
     ‘%x’                    int                 ‘printf("%x")’ と同等。 (8)
                                                 
                                                 
     ‘%s’                    const char*         null で終端された C の文字列。
                                                 
                                                 
     ‘%p’                    const void*         C ポインタの 16 進表記。
                                                 ‘printf("%p")’ とほとんど同じです
                                                 が、プラットフォームにおける
                                                 ‘printf’ の定義に関わりなく先頭に
                                                 リテラル ‘0x’ が付きます。
                                                 

     識別できない書式指定文字があった場合、残りの書式文字列はそのまま結
     果のオブジェクトにコピーされ、残りの引数は無視されます。

 -- C の関数: *note PyObject: 312. *PyBytes_FromFormatV (const char
          *format, va_list vargs)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  ちょ
     うど２つの引数を取ることを除いて、 *note PyBytes_FromFormat():
     1994. と同じです。

 -- C の関数: *note PyObject: 312. *PyBytes_FromObject (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  バッ
     ファプロトコルを実装するオブジェクト 'o' のバイト表現を返します。

 -- C の関数: *note Py_ssize_t: a2e. PyBytes_Size (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  バイトオブジェクト 'o' の
     バイト単位の長さを返します。

 -- C の関数: *note Py_ssize_t: a2e. PyBytes_GET_SIZE (PyObject *o)

     *note PyBytes_Size(): 4803. に似ていますが、エラーチェックを行いま
     せん。

 -- C の関数: char *PyBytes_AsString (PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  'o' の中身へのポインタを返
     します。 ポインタは、 ‘len(o) + 1’ バイトからなる 'o' の内部バッフ
     ァを参照します。 他に null のバイトがあるかどうかにかかわらず、バッ
     ファの最後のバイトは必ず null になります。
     ‘PyBytes_FromStringAndSize(NULL, size)’ で生成された場合を除いて、
     データを修正してはなりません。 またポインタを解放（deallocated）し
     てはなりません。 もし、 'o' が bytes オブジェクトでなければ、 *note
     PyBytes_AsString(): 854. は ‘NULL’ を返し *note TypeError: 502. を
     送出します。

 -- C の関数: char *PyBytes_AS_STRING (PyObject *string)

     *note PyBytes_AsString(): 854. に似ていますが、エラーチェックを行い
     ません。

 -- C の関数: int PyBytes_AsStringAndSize (PyObject *obj, char **buffer,
          Py_ssize_t *length)
     ' 次に属します: *note Stable ABI: 51e.'  Return the null-terminated
     contents of the object 'obj' through the output variables 'buffer'
     and 'length'.  Returns ‘0’ on success.

     'length' の値が ‘NULL’ の場合、バイトオブジェクトが null バイトを含
     まない可能性があります。その場合、関数は ‘-1’ を返し、 *note
     ValueError: 1e3. を送出します。

     buffer は 'obj' の内部バッファを参照していて、これには末尾の null バ
     イトも含んでいます (これは 'length' には数えられません)。 オブジェ
     クトが ‘PyBytes_FromStringAndSize(NULL, size)’ で生成された場合を除
     いて、何があってもデータを改変してはいけません。 オブジェクトを解放
     (deallocate) してもいけません。 'obj' が bytes オブジェクトでなかっ
     た場合は、 *note PyBytes_AsStringAndSize(): 47fd. は ‘-1’ を返し
     *note TypeError: 502. を送出します。

     バージョン 3.5 で変更: 以前は bytes オブジェクトにヌルバイトが埋め
     込まれていたときに *note TypeError: 502. を送出していました。

 -- C の関数: void PyBytes_Concat (PyObject **bytes, PyObject *newpart)
     ' 次に属します: *note Stable ABI: 51e.'  'newpart' の内容を 'bytes'
     の後ろに連結した新しいバイトオブジェクトを '*bytes' に生成します。
     呼び出し側は新しい参照を所有します。 'bytes' の古い値の参照は盗まれ
     ます。 もし新しいオブジェクトが生成できない場合、古い 'bytes' の参
     照は放棄され、 '*bytes' の値は ‘NULL’ に設定されます; 適切な例外が
     設定されます。

 -- C の関数: void PyBytes_ConcatAndDel (PyObject **bytes, PyObject
          *newpart)
     ' 次に属します: *note Stable ABI: 51e.'  Create a new bytes object
     in '*bytes' containing the contents of 'newpart' appended to
     'bytes'.  This version releases the *note strong reference: 316. to
     'newpart' (i.e.  decrements its reference count).

 -- C の関数: int _PyBytes_Resize (PyObject **bytes, Py_ssize_t newsize)

     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 one, only more efficiently.  Pass the
     address of an existing bytes object as an lvalue (it may be written
     into), and the new size desired.  On success, '*bytes' holds the
     resized bytes object and ‘0’ is returned; the address in '*bytes'
     may differ from its input value.  If the reallocation fails, the
     original bytes object at '*bytes' is deallocated, '*bytes' is set
     to ‘NULL’, *note MemoryError: 1627. is set, and ‘-1’ is returned.

   ---------- Footnotes ----------

   (1) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。

   (2) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。

   (3) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。

   (4) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。

   (5) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。

   (6) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。

   (7) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。

   (8) 整数指定子 (d, u, ld, lu, zd, zu, i, x): 精度が与えられていても、
0指定子は有効です。


File: python.info,  Node: bytearray オブジェクト<2>,  Next: Unicode オブジェクトと codec,  Prev: バイトオブジェクト<2>,  Up: シーケンスオブジェクト sequence object

7.8.3.2 bytearray オブジェクト
..............................

 -- C のデータ型: type PyByteArrayObject

     この *note PyObject: 312. のサブタイプは Python の bytearray オブジ
     ェクトを表します。

 -- C 変数: *note PyTypeObject: a73. PyByteArray_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは、 Python bytearray 型を示します。 Python レイ
     ヤでの *note bytearray: 508. と同じオブジェクトです。

* Menu:

* 型チェックマクロ::
* ダイレクト API 関数::
* マクロ::


File: python.info,  Node: 型チェックマクロ,  Next: ダイレクト API 関数,  Up: bytearray オブジェクト<2>

7.8.3.3 型チェックマクロ
........................

 -- C の関数: int PyByteArray_Check (PyObject *o)

     オブジェクト 'o' が bytearray オブジェクトか bytearray 型のサブタイ
     プのインスタンスである場合に真を返します。この関数は常に成功します
     。

 -- C の関数: int PyByteArray_CheckExact (PyObject *o)

     オブジェクト 'o' が bytearray オブジェクトだが bytearray 型のサブタ
     イプのインスタンスでない場合に真を返します。この関数は常に成功しま
     す。


File: python.info,  Node: ダイレクト API 関数,  Next: マクロ,  Prev: 型チェックマクロ,  Up: bytearray オブジェクト<2>

7.8.3.4 ダイレクト API 関数
...........................

 -- C の関数: *note PyObject: 312. *PyByteArray_FromObject (PyObject *o)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     *note buffer protocol: 371. を実装した任意のオブジェクト 'o' から、
     新しいbytearrayオブジェクトを作成し、返します。

     On failure, return ‘NULL’ with an exception set.

 -- C の関数: *note PyObject: 312. *PyByteArray_FromStringAndSize (const
          char *string, Py_ssize_t len)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Create a new bytearray object from 'string' and its length, 'len'.

     On failure, return ‘NULL’ with an exception set.

 -- C の関数: *note PyObject: 312. *PyByteArray_Concat (PyObject *a,
          PyObject *b)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     bytearray 'a' と 'b' を連結した結果を新しい bytearray として返しま
     す。

     On failure, return ‘NULL’ with an exception set.

 -- C の関数: *note Py_ssize_t: a2e. PyByteArray_Size (PyObject
          *bytearray)
     ' 次に属します: *note Stable ABI: 51e.'  ‘NULL’ ポインタチェックの
     後に 'bytearray' のサイズを返します。

 -- C の関数: char *PyByteArray_AsString (PyObject *bytearray)
     ' 次に属します: *note Stable ABI: 51e.'  ‘NULL’ ポインタチェックの
     後に 'bytearray' の内容を char 配列として返します。 返される配列に
     は、常に余分な null バイトが追加されます。

 -- C の関数: int PyByteArray_Resize (PyObject *bytearray, Py_ssize_t
          len)
     ' 次に属します: *note Stable ABI: 51e.'  'bytearray' の内部バッファ
     を 'len' へリサイズします。


File: python.info,  Node: マクロ,  Prev: ダイレクト API 関数,  Up: bytearray オブジェクト<2>

7.8.3.5 マクロ
..............

以下のマクロは、ポインタのチェックをしないことにより安全性を犠牲にしてス
ピードを優先しています。

 -- C の関数: char *PyByteArray_AS_STRING (PyObject *bytearray)

     *note PyByteArray_AsString(): 47f8. に似ていますが、エラーチェック
     を行いません。

 -- C の関数: *note Py_ssize_t: a2e. PyByteArray_GET_SIZE (PyObject
          *bytearray)

     *note PyByteArray_Size(): 47fb. に似ていますが、エラーチェックを行
     いません。


File: python.info,  Node: Unicode オブジェクトと codec,  Next: タプルオブジェクト tuple object,  Prev: bytearray オブジェクト<2>,  Up: シーケンスオブジェクト sequence object

7.8.3.6 Unicode オブジェクトと codec
....................................

* Menu:

* Unicode オブジェクト::
* 組み込み codec (built-in codec): 組み込み codec built-in codec.
* メソッドおよびスロット関数 (slot function): メソッドおよびスロット関数 slot function.


File: python.info,  Node: Unicode オブジェクト,  Next: 組み込み codec built-in codec,  Up: Unicode オブジェクトと codec

7.8.3.7 Unicode オブジェクト
............................

Python3.3 の PEP 393(1) 実装から、メモリ効率を維持しながらUnicode文字の
完全な範囲を扱えるように、Unicodeオブジェクトは内部的に多様な表現形式を
用いています。すべてのコードポイントが128、256または65536以下の文字列に
対して特別なケースが存在しますが、それ以外ではコードポイントは1114112以
下 (これはすべてのUnicode範囲です) でなければなりません。

UTF-8 representation is created on demand and cached in the Unicode
object.

     注釈: The *note Py_UNICODE: 3c7. representation has been removed
     since Python 3.12 with deprecated APIs.  See PEP 623(2) for more
     information.

* Menu:

* Unicode 型::
* Unicode 文字プロパティ::
* Unicode 文字列の生成とアクセス::
* ロケールエンコーディング::
* ファイルシステムエンコーディング::
* wchar_t サポート::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0393/

   (2) https://peps.python.org/pep-0623/


File: python.info,  Node: Unicode 型,  Next: Unicode 文字プロパティ,  Up: Unicode オブジェクト

7.8.3.8 Unicode 型
..................

以下は Python の Unicode 実装に用いられている基本 Unicode オブジェクト型
です:

 -- C のデータ型: type Py_UCS4
 -- C のデータ型: type Py_UCS2
 -- C のデータ型: type Py_UCS1
     ' 次に属します: *note Stable ABI: 51e.'  これらの型は、それぞれ、
     32ビット、16ビット、そして8ビットの文字を保持するのに充分な幅を持つ
     符号なしの整数型のtypedefです。単一のUnicode文字を扱う場合は、
     *note Py_UCS4: 27b. を用いてください。

     Added in version 3.3.

 -- C のデータ型: type Py_UNICODE

     これは、‘wchar_t’ のtypedef で、プラットフォームに依存して16ビット
     か32ビットの型になります。

     バージョン 3.3 で変更: 以前のバージョンでは、Pythonをビルドした際に
     "narrow" または "wide" Unicode バージョンのどちらを選択したかによっ
     て、 16ビットか32ビットのどちらかの型になっていました。

     Deprecated since version 3.13, will be removed in version 3.15.

 -- C のデータ型: type PyASCIIObject
 -- C のデータ型: type PyCompactUnicodeObject
 -- C のデータ型: type PyUnicodeObject

     これらの *note PyObject: 312. のサブタイプは Python Unicode オブジ
     ェクトを表現します。 Unicode オブジェクトを扱う全ての API 関数は
     *note PyObject: 312. へのポインタを受け取って PyObject へのポインタ
     を返すので、ほとんどの場合、これらの型を直接使うべきではありません
     。

     Added in version 3.3.

 -- C 変数: *note PyTypeObject: a73. PyUnicode_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは、Python Unicode型を表します。これは、Pythonコ
     ードに ‘str’ として露出されます。

The following APIs are C macros and static inlined functions for fast
checks and access to internal read-only data of Unicode objects:

 -- C の関数: int PyUnicode_Check (PyObject *obj)

     オブジェクト 'obj' が Unicode オブジェクトか Unicode 型のサブタイプ
     のインスタンスである場合に真を返します。この関数は常に成功します。

 -- C の関数: int PyUnicode_CheckExact (PyObject *obj)

     オブジェクト 'obj' が Unicode オブジェクトだがサブタイプのインスタ
     ンスでない場合に真を返します。この関数は常に成功します。

 -- C の関数: int PyUnicode_READY (PyObject *unicode)

     Returns ‘0’.  This API is kept only for backward compatibility.

     Added in version 3.3.

     バージョン 3.10 で非推奨: This API does nothing since Python 3.12.

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_GET_LENGTH (PyObject
          *unicode)

     Unicode 文字列のコードポイントでの長さを返します。 'unicode' は "正
     統な" 表現形式の Unicode オブジェクトでなければなりません (ただしチ
     ェックはしません)。

     Added in version 3.3.

 -- C の関数: *note Py_UCS1: 1146. *PyUnicode_1BYTE_DATA (PyObject
          *unicode)
 -- C の関数: *note Py_UCS2: 1147. *PyUnicode_2BYTE_DATA (PyObject
          *unicode)
 -- C の関数: *note Py_UCS4: 27b. *PyUnicode_4BYTE_DATA (PyObject
          *unicode)

     文字に直接アクセスするために、 UCS1, UCS2, UCS4 のいずれかの整数型
     にキャストされた正統な表現形式へのポインタを返します。 正統な表現が
     適正な文字サイズになっているかどうかのチェックはしません; *note
     PyUnicode_KIND(): 1150. を使って正しい関数を選んでください。

     Added in version 3.3.

 -- C のマクロ: PyUnicode_1BYTE_KIND
 -- C のマクロ: PyUnicode_2BYTE_KIND
 -- C のマクロ: PyUnicode_4BYTE_KIND

     *note PyUnicode_KIND(): 1150. マクロの返り値です。

     Added in version 3.3.

     バージョン 3.12 で変更: ‘PyUnicode_WCHAR_KIND’ は削除されました。

 -- C の関数: int PyUnicode_KIND (PyObject *unicode)

     この Unicode がデータを保存するのに1文字あたり何バイト使っているか
     を示す PyUnicode 種別の定数 (上を読んでください) のうち1つを返しま
     す。 'unicode' は "正統な" 表現形式の Unicode オブジェクトでなけれ
     ばなりません (ただしチェックはしません)。

     Added in version 3.3.

 -- C の関数: void *PyUnicode_DATA (PyObject *unicode)

     生の Unicode バッファへの void ポインタを返します。 'unicode' は "正
     統な" 表現形式の Unicode オブジェクトでなければなりません (ただしチ
     ェックはしません)。

     Added in version 3.3.

 -- C の関数: void PyUnicode_WRITE (int kind, void *data, Py_ssize_t
          index, Py_UCS4 value)

     正統な表現形式となっている (*note PyUnicode_DATA(): 114c. で取得し
     た) 'data' に書き込みます。 この関数は正常性のチェックを行わない、
     ループで使われるためのものです。 呼び出し側は、他の呼び出しで取得し
     た 'kind' 値と 'data' ポインタをキャッシュすべきです。 'index' は文
     字列の (0始まりの) インデックスで、 'value' はその場所に書き込まれ
     ることになる新しいコードポイントの値です。

     Added in version 3.3.

 -- C の関数: *note Py_UCS4: 27b. PyUnicode_READ (int kind, void *data,
          Py_ssize_t index)

     正統な表現形式となっている (*note PyUnicode_DATA(): 114c. で取得し
     た) 'data' からコードポイントを読み取ります。 チェックや事前確認の
     マクロ呼び出しは一切行われません。

     Added in version 3.3.

 -- C の関数: *note Py_UCS4: 27b. PyUnicode_READ_CHAR (PyObject
          *unicode, Py_ssize_t index)

     Unicode オブジェクト 'unicode' から文字を読み取ります。 この
     Unicode オブジェクトは "正統な" 表現形式でなければなりません。 何度
     も連続して読み取る場合には、このマクロは *note PyUnicode_READ():
     1154. よりも非効率的です。

     Added in version 3.3.

 -- C の関数: *note Py_UCS4: 27b. PyUnicode_MAX_CHAR_VALUE (PyObject
          *unicode)

     'unicode' に基づいて他の文字列を作るのに適した最大のコードポイント
     を返します。 この Unicode オブジェクトは "正統な" 表現形式でなけれ
     ばなりません。 この値は常に概算値ですが、文字列全体を調べるよりも効
     率的です。

     Added in version 3.3.

 -- C の関数: int PyUnicode_IsIdentifier (PyObject *unicode)
     ' 次に属します: *note Stable ABI: 51e.'  文字列が、 *note 識別子
     (identifier) およびキーワード (keyword): 1df6. 節の言語定義における
     有効な識別子であれば ‘1’ を返します。それ以外の場合は ‘0’ を返しま
     す。

     バージョン 3.9 で変更: The function does not call *note
     Py_FatalError(): 951. anymore if the string is not ready.


File: python.info,  Node: Unicode 文字プロパティ,  Next: Unicode 文字列の生成とアクセス,  Prev: Unicode 型,  Up: Unicode オブジェクト

7.8.3.9 Unicode 文字プロパティ
..............................

Unicode は数多くの異なる文字プロパティ (character property) を提供してい
ます。よく使われる文字プロパティは、以下のマクロで利用できます。これらの
マクロは Python の設定に応じて、各々 C の関数に対応付けられています。

 -- C の関数: int Py_UNICODE_ISSPACE (Py_UCS4 ch)

     'ch' が空白文字かどうかに応じて ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISLOWER (Py_UCS4 ch)

     'ch' が小文字かどうかに応じて ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISUPPER (Py_UCS4 ch)

     'ch' が大文字かどうかに応じて ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISTITLE (Py_UCS4 ch)

     'ch' がタイトルケース文字 (titlecase character) かどうかに応じて
     ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISLINEBREAK (Py_UCS4 ch)

     'ch' が改行文字かどうかに応じて ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISDECIMAL (Py_UCS4 ch)

     'ch' が decimal 文字かどうかに応じて ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISDIGIT (Py_UCS4 ch)

     'ch' が digit 文字かどうかに応じて ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISNUMERIC (Py_UCS4 ch)

     'ch' が数字 (numeric) 文字かどうかに応じて ‘1’ または ‘0’ を返しま
     す。

 -- C の関数: int Py_UNICODE_ISALPHA (Py_UCS4 ch)

     'ch' がアルファベット文字かどうかに応じて ‘1’ または ‘0’ を返します
     。

 -- C の関数: int Py_UNICODE_ISALNUM (Py_UCS4 ch)

     'ch' が英数文字かどうかに応じて ‘1’ または ‘0’ を返します。

 -- C の関数: int Py_UNICODE_ISPRINTABLE (Py_UCS4 ch)

     'ch' が文字が印字可能な文字かどうかに基づいて ‘1’ または ‘0’ を返し
     ます。 非印字可能文字は、 Unicode 文字データベースで "Other" または
     "Separator" と定義されている文字の、印字可能と見なされる ASCII
     space (0x20) 以外のものです。 (なお、この文脈での印字可能文字は、文
     字列に *note repr(): 7c8. が呼び出されるときにエスケープすべきでな
     い文字のことです。これは *note sys.stdout: aa4. や *note
     sys.stderr: 907. に書き込まれる文字列の操作とは関係ありません。)

以下の API は、高速に直接文字変換を行うために使われます:

 -- C の関数: *note Py_UCS4: 27b. Py_UNICODE_TOLOWER (Py_UCS4 ch)

     'ch' を小文字に変換したものを返します。

 -- C の関数: *note Py_UCS4: 27b. Py_UNICODE_TOUPPER (Py_UCS4 ch)

     'ch' を大文字に変換したものを返します。

 -- C の関数: *note Py_UCS4: 27b. Py_UNICODE_TOTITLE (Py_UCS4 ch)

     'ch' をタイトルケース文字に変換したものを返します。

 -- C の関数: int Py_UNICODE_TODECIMAL (Py_UCS4 ch)

     Return the character 'ch' converted to a decimal positive integer.
     Return ‘-1’ if this is not possible.  This function does not raise
     exceptions.

 -- C の関数: int Py_UNICODE_TODIGIT (Py_UCS4 ch)

     Return the character 'ch' converted to a single digit integer.
     Return ‘-1’ if this is not possible.  This function does not raise
     exceptions.

 -- C の関数: double Py_UNICODE_TONUMERIC (Py_UCS4 ch)

     'ch' を double に変換したものを返します。不可能ならば ‘-1.0’ を返し
     ます。この関数は例外を送出しません。

これらの API はサロゲートにも使えます:

 -- C の関数: int Py_UNICODE_IS_SURROGATE (Py_UCS4 ch)

     'ch' がサロゲートかどうか (‘0xD800 <= ch <= 0xDFFF’) をチェックしま
     す。

 -- C の関数: int Py_UNICODE_IS_HIGH_SURROGATE (Py_UCS4 ch)

     'ch' が上位サロゲートかどうか (‘0xD800 <= ch <= 0xDBFF’) をチェック
     します。

 -- C の関数: int Py_UNICODE_IS_LOW_SURROGATE (Py_UCS4 ch)

     'ch' が下位サロゲートかどうか (‘0xDC00 <= ch <= 0xDFFF’) をチェック
     します。

 -- C の関数: *note Py_UCS4: 27b. Py_UNICODE_JOIN_SURROGATES (Py_UCS4
          high, Py_UCS4 low)

     Join two surrogate code points and return a single *note Py_UCS4:
     27b. 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].


File: python.info,  Node: Unicode 文字列の生成とアクセス,  Next: ロケールエンコーディング,  Prev: Unicode 文字プロパティ,  Up: Unicode オブジェクト

7.8.3.10 Unicode 文字列の生成とアクセス
.......................................

Unicode オブジェクトを生成したり、Unicode のシーケンスとしての基本的なプ
ロパティにアクセスしたりするには、以下の API を使ってください:

 -- C の関数: *note PyObject: 312. *PyUnicode_New (Py_ssize_t size,
          Py_UCS4 maxchar)
     '戻り値: 新しい参照。' 新しい Unicode オブジェクトを生成します。
     'maxchar' は文字列に並べるコードポイントの正しい最大値にすべきです
     。 その値は概算値として 127, 255, 65535, 1114111 の一番近い値に切り
     上げられます。

     これは新しい Unicode オブジェクトを生成する推奨された方法です。 こ
     の関数を使って生成されたオブジェクトはサイズ変更は不可能です。

     On error, set an exception and return ‘NULL’.

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyUnicode_FromKindAndData (int kind,
          const void *buffer, Py_ssize_t size)
     '戻り値: 新しい参照。' 与えられた 'kind' (取り得る値は *note
     PyUnicode_1BYTE_KIND: 1151. などの *note PyUnicode_KIND(): 1150. が
     返す値です) の Unicode オブジェクトを生成します。 'buffer' は、与え
     られた kind に従って1文字あたり 1, 2, 4 バイトのいずれかを単位とし
     て、長さ 'size' の配列へのポインタでなければなりません。

     If necessary, the input 'buffer' is copied and transformed into the
     canonical representation.  For example, if the 'buffer' is a UCS4
     string (*note PyUnicode_4BYTE_KIND: 1153.) and it consists only of
     codepoints in the UCS1 range, it will be transformed into UCS1
     (*note PyUnicode_1BYTE_KIND: 1151.).

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyUnicode_FromStringAndSize (const
          char *str, Py_ssize_t size)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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.

     This function raises *note SystemError: 541. when:

        * 'size' < 0,

        * 'str' is ‘NULL’ and 'size' > 0

     バージョン 3.12 で変更: 'str' == ‘NULL’ with 'size' > 0 is not
     allowed anymore.

 -- C の関数: *note PyObject: 312. *PyUnicode_FromString (const char
          *str)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     UTF-8 エンコードされたnull終端のchar 型バッファ 'str' から Unicode
     オブジェクトを生成します。

 -- C の関数: *note PyObject: 312. *PyUnicode_FromFormat (const char
          *format, ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  Take
     a C ‘printf()’-style 'format' string and a variable number of
     arguments, calculate the size of the resulting Python Unicode
     string and return a string with the values formatted into it.  The
     variable arguments must be C types and must correspond exactly to
     the format characters in the 'format' ASCII-encoded string.

     一つの変換指定子は 2 またはそれ以上の文字を含み、その構成要素は以下
     からなりますが、示した順に出現しなければなりません:

       1. 指定子の開始を示す文字 ‘'%'’ 。

       2. 変換フラグ (オプション)。一部の変換型の結果に影響します。

       3. Minimum field width (optional).  If specified as an ‘'*'’
          (asterisk), the actual width is given in the next argument,
          which must be of type int, and the object to convert comes
          after the minimum field width and optional precision.

       4. 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
          int, and the value to convert comes after the precision.

       5. 精度長変換子 (オプション)。

       6. 変換型。

     変換フラグ文字を以下に示します:

     Flag        意味
                 
     ------------------------------------------------------------------------------
                 
     ‘0’         数値型に対してゼロによるパディングを行います。
                 
                 
     ‘-’         The converted value is left adjusted (overrides the ‘0’ flag if
                 both are given).
                 

     The length modifiers for following integer conversions (‘d’, ‘i’,
     ‘o’, ‘u’, ‘x’, or ‘X’) specify the type of the argument (int by
     default):

     修飾子         型
                    
     -------------------------------------------------------------------------
                    
     ‘l’            long または unsigned long
                    
                    
     ‘ll’           long long または unsigned long long
                    
                    
     ‘j’            ‘intmax_t’ or ‘uintmax_t’
                    
                    
     ‘z’            ‘size_t’ or ‘ssize_t’
                    
                    
     ‘t’            ‘ptrdiff_t’
                    

     The length modifier ‘l’ for following conversions ‘s’ or ‘V’
     specify that the type of the argument is const wchar_t*.

     The conversion specifiers are:

     Conversion Specifier                  型                                    備考
                                                                                 
     ------------------------------------------------------------------------------------------------------------------
                                                                                 
     ‘%’                                   'n/a'                                 The literal ‘%’ character.
                                                                                 
                                                                                 
     ‘d’, ‘i’                              Specified by the length modifier      The decimal representation of a
                                                                                 signed C integer.
                                                                                 
                                                                                 
     ‘u’                                   Specified by the length modifier      The decimal representation of an
                                                                                 unsigned C integer.
                                                                                 
                                                                                 
     ‘o’                                   Specified by the length modifier      The octal representation of an
                                                                                 unsigned C integer.
                                                                                 
                                                                                 
     ‘x’                                   Specified by the length modifier      The hexadecimal representation of
                                                                                 an unsigned C integer (lowercase).
                                                                                 
                                                                                 
     ‘X’                                   Specified by the length modifier      The hexadecimal representation of
                                                                                 an unsigned C integer (uppercase).
                                                                                 
                                                                                 
     ‘c’                                   int                                   A single character.
                                                                                 
                                                                                 
     ‘s’                                   const char* または const wchar_t*     null で終端された C の文字列。
                                                                                 
                                                                                 
     ‘p’                                   const void*                           C ポインタの 16 進表記。
                                                                                 ‘printf("%p")’ とほとんど同じですが
                                                                                 、プラットフォームにおける ‘printf’
                                                                                 の定義に関わりなく先頭にリテラル
                                                                                 ‘0x’ が付きます。
                                                                                 
                                                                                 
     ‘A’                                   *note PyObject: 312.*                 *note ascii(): 138e. の戻り値。
                                                                                 
                                                                                 
     ‘U’                                   *note PyObject: 312.*                 Unicode オブジェクト。
                                                                                 
                                                                                 
     ‘V’                                   *note PyObject: 312.*, const char*    A Unicode object (which may be
                                           or const wchar_t*                     ‘NULL’) and a null-terminated C
                                                                                 character array as a second
                                                                                 parameter (which will be used, if
                                                                                 the first parameter is ‘NULL’).
                                                                                 
                                                                                 
     ‘S’                                   *note PyObject: 312.*                 *note PyObject_Str(): ffa. の戻り値
                                                                                 。
                                                                                 
                                                                                 
     ‘R’                                   *note PyObject: 312.*                 *note PyObject_Repr(): ff9. の戻り
                                                                                 値。
                                                                                 
                                                                                 
     ‘T’                                   *note PyObject: 312.*                 Get the fully qualified name of an
                                                                                 object type; call
                                                                                 *note PyType_GetFullyQualifiedName(): 34c.
                                                                                 
                                                                                 
     ‘#T’                                  *note PyObject: 312.*                 Similar to ‘T’ format, but use a
                                                                                 colon (‘:’) as separator between
                                                                                 the module name and the qualified
                                                                                 name.
                                                                                 
                                                                                 
     ‘N’                                   *note PyTypeObject: a73.*             Get the fully qualified name of a
                                                                                 type; call
                                                                                 *note PyType_GetFullyQualifiedName(): 34c.
                                                                                 
                                                                                 
     ‘#N’                                  *note PyTypeObject: a73.*             Similar to ‘N’ format, but use a
                                                                                 colon (‘:’) as separator between
                                                                                 the module name and the qualified
                                                                                 name.
                                                                                 

          注釈: The width formatter unit is number of characters rather
          than bytes.  The precision formatter unit is number of bytes
          or ‘wchar_t’ items (if the length modifier ‘l’ is used) for
          ‘"%s"’ and ‘"%V"’ (if the ‘PyObject*’ argument is ‘NULL’), and
          a number of characters for ‘"%A"’, ‘"%U"’, ‘"%S"’, ‘"%R"’ and
          ‘"%V"’ (if the ‘PyObject*’ argument is not ‘NULL’).

          注釈: Unlike to C ‘printf()’ the ‘0’ flag has effect even when
          a precision is given for integer conversions (‘d’, ‘i’, ‘u’,
          ‘o’, ‘x’, or ‘X’).

     バージョン 3.2 で変更: ‘"%lld"’, ‘"%llu"’ のサポートが追加されまし
     た。

     バージョン 3.3 で変更: ‘"%li"’, ‘"%lli"’, ‘"%zi"’ のサポートが追加
     されました。

     バージョン 3.4 で変更: ‘"%s"’, ‘"%A"’, ‘"%U"’, ‘"%V"’, ‘"%S"’,
     ‘"%R"’ での幅フォーマッタおよび精度フォーマッタのサポートが追加され
     ました。

     バージョン 3.12 で変更: Support for conversion specifiers ‘o’ and
     ‘X’.  Support for length modifiers ‘j’ and ‘t’.  Length modifiers
     are now applied to all integer conversions.  Length modifier ‘l’ is
     now applied to conversion specifiers ‘s’ and ‘V’.  Support for
     variable width and precision ‘*’.  Support for flag ‘-’.

     An unrecognized format character now sets a *note SystemError: 541.
     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.

     バージョン 3.13 で変更: Support for ‘%T’, ‘%#T’, ‘%N’ and ‘%#N’
     formats added.

 -- C の関数: *note PyObject: 312. *PyUnicode_FromFormatV (const char
          *format, va_list vargs)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  ちょ
     うど２つの引数を取ることを除いて、 *note PyUnicode_FromFormat():
     363. と同じです。

 -- C の関数: *note PyObject: 312. *PyUnicode_FromObject (PyObject *obj)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  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 *note strong reference: 316. to the object.

     Unicode やそのサブタイプ以外のオブジェクトでは *note TypeError:
     502. が引き起こされます。

 -- C の関数: *note PyObject: 312. *PyUnicode_FromEncodedObject
          (PyObject *obj, const char *encoding, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  エン
     コードされている 'obj' を Unicode オブジェクトにデコードします。

     *note bytes: 1a4. や *note bytearray: 508. や他の *note bytes-like
     objects: cfb. は、与えられた 'encoding' に従ってデコードされ、
     'errors' で定義されたエラーハンドリングが使われます。 これらの引数
     は両方とも ‘NULL’ にでき、その場合この API はデフォルト値を使います
     (詳しことは *note 組み込み codec (built-in codec): 4ab0. を参照して
     ください)。

     その他のUnicodeオブジェクトを含むオブジェクトは *note TypeError:
     502. 例外を引き起こします。

     この API は、エラーが生じたときには ‘NULL’ を返します。呼び出し側は
     返されたオブジェクトに対し参照カウンタを 1 つ減らす (decref) する責
     任があります。

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_GetLength (PyObject
          *unicode)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     Unicode オブジェクトの長さをコードポイントで返します。

     On error, set an exception and return ‘-1’.

     Added in version 3.3.

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_CopyCharacters (PyObject
          *to, Py_ssize_t to_start, PyObject *from, Py_ssize_t
          from_start, Py_ssize_t how_many)

     ある Unicode オブジェクトから他へ文字をコピーします。 この関数は必
     要なときに文字変換を行い、可能な場合は ‘memcpy()’ へ差し戻します。
     失敗のときには ‘-1’ を返し、例外を設定します。そうでない場合は、コ
     ピーした文字数を返します。

     Added in version 3.3.

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_Fill (PyObject *unicode,
          Py_ssize_t start, Py_ssize_t length, Py_UCS4 fill_char)

     文字列を文字で埋めます: ‘unicode[start:start+length]’ で
     'fill_char' を埋めることになります。

     'fill_char' が文字列の最大文字よりも大きい場合や、文字列2つ以上の参
     照を持ってた場合は失敗します。

     書き込んだ文字数を返すか、失敗のときには ‘-1’ を返し例外を送出しま
     す。

     Added in version 3.3.

 -- C の関数: int PyUnicode_WriteChar (PyObject *unicode, Py_ssize_t
          index, Py_UCS4 character)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  文
     字列に文字を書き込みます。 文字列は *note PyUnicode_New(): 879. で
     作成しなければなりません。 Unicode 文字列は不変とされているので、こ
     の文字列は共有されていたり、これまでにハッシュ化されていてはいけま
     せん。

     この関数は 'unicode' が Unicode オブジェクトであること、インデック
     スが範囲内であること、オブジェクトが安全に変更できる (つまり参照カ
     ウントが1である) ことをチェックします。

     Return ‘0’ on success, ‘-1’ on error with an exception set.

     Added in version 3.3.

 -- C の関数: *note Py_UCS4: 27b. PyUnicode_ReadChar (PyObject *unicode,
          Py_ssize_t index)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  文
     字列から文字を読み取ります。 エラーチェックを行わない *note
     PyUnicode_READ_CHAR(): 1155. とは対照的に、この関数は 'unicode' が
     Unicode オブジェクトであること、インデックスが範囲内であることをチ
     ェックします。

     Return character on success, ‘-1’ on error with an exception set.

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyUnicode_Substring (PyObject
          *unicode, Py_ssize_t start, Py_ssize_t end)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  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’.

     Added in version 3.3.

 -- C の関数: *note Py_UCS4: 27b. *PyUnicode_AsUCS4 (PyObject *unicode,
          Py_UCS4 *buffer, Py_ssize_t buflen, int copy_null)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     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 *note SystemError: 541. if
     'buflen' is smaller than the length of 'unicode').  'buffer' is
     returned on success.

     Added in version 3.3.

 -- C の関数: *note Py_UCS4: 27b. *PyUnicode_AsUCS4Copy (PyObject
          *unicode)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  文
     字列 'unicode' を *note PyMem_Malloc(): c33. でメモリ確保された新し
     い UCS4 型のバッファにコピーします。 これが失敗した場合は、 ‘NULL’
     を返し *note MemoryError: 1627. をセットします。 返されたバッファは
     必ず null コードポイントが追加されています。

     Added in version 3.3.


File: python.info,  Node: ロケールエンコーディング,  Next: ファイルシステムエンコーディング,  Prev: Unicode 文字列の生成とアクセス,  Up: Unicode オブジェクト

7.8.3.11 ロケールエンコーディング
.................................

現在のロケールエンコーディングはオペレーティングシステムのテキストをデコ
ードするのに使えます。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeLocaleAndSize (const
          char *str, Py_ssize_t length, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  Decode a string from UTF-8 on Android and
     VxWorks, or from the current locale encoding on other platforms.
     The supported error handlers are ‘"strict"’ and ‘"surrogateescape"’
     ( PEP 383(1)).  The decoder uses ‘"strict"’ error handler if
     'errors' is ‘NULL’.  'str' must end with a null character but
     cannot contain embedded null characters.

     Use *note PyUnicode_DecodeFSDefaultAndSize(): 490c. to decode a
     string from the *note filesystem encoding and error handler: 505.

     This function ignores the *note Python UTF-8 Mode: 622.

     参考
     ....

     *note Py_DecodeLocale(): b95. 関数。

     Added in version 3.3.

     バージョン 3.7 で変更: この関数は、 Android 以外では現在のロケール
     エンコーディングを ‘surrogateescape’ エラーハンドラで使うようになり
     ました。 以前は、 *note Py_DecodeLocale(): b95. が
     ‘surrogateescape’ で使われ、現在のロケールエンコーディングは
     ‘strict’ で使われていました。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeLocale (const char
          *str, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  Similar to *note
     PyUnicode_DecodeLocaleAndSize(): b97, but compute the string length
     using ‘strlen()’.

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyUnicode_EncodeLocale (PyObject
          *unicode, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  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 ‘"strict"’ and ‘"surrogateescape"’ (
     PEP 383(2)).  The encoder uses ‘"strict"’ error handler if 'errors'
     is ‘NULL’.  Return a *note bytes: 1a4. object.  'unicode' cannot
     contain embedded null characters.

     Use *note PyUnicode_EncodeFSDefault(): 19bc. to encode a string to
     the *note filesystem encoding and error handler: 505.

     This function ignores the *note Python UTF-8 Mode: 622.

     参考
     ....

     *note Py_EncodeLocale(): b96. 関数。

     Added in version 3.3.

     バージョン 3.7 で変更: この関数は、 Android 以外では現在のロケール
     エンコーディングを ‘surrogateescape’ エラーハンドラで使うようになり
     ました。 以前は、 *note Py_EncodeLocale(): b96. が
     ‘surrogateescape’ で使われ、現在のロケールエンコーディングは
     ‘strict’ で使われていました。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0383/

   (2) https://peps.python.org/pep-0383/


File: python.info,  Node: ファイルシステムエンコーディング,  Next: wchar_t サポート,  Prev: ロケールエンコーディング,  Up: Unicode オブジェクト

7.8.3.12 ファイルシステムエンコーディング
.........................................

Functions encoding to and decoding from the *note filesystem encoding
and error handler: 505. ( PEP 383(1) and PEP 529(2)).

To encode file names to *note bytes: 1a4. during argument parsing, the
‘"O&"’ converter should be used, passing *note PyUnicode_FSConverter():
ce7. as the conversion function:

 -- C の関数: int PyUnicode_FSConverter (PyObject *obj, void *result)
     ' 次に属します: *note Stable ABI: 51e.'  ParseTuple converter:
     encode *note str: 418. objects - obtained directly or through the
     *note os.PathLike: c1f. interface - to *note bytes: 1a4. using
     *note PyUnicode_EncodeFSDefault(): 19bc.; *note bytes: 1a4. objects
     are output as-is.  'result' must be a *note PyBytesObject: 75d.*
     which must be released when it is no longer used.

     Added in version 3.1.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

引数の構文解析中にファイル名を *note str: 418. にデコードするには、
‘"O&"’ コンバーターを使い、 *note PyUnicode_FSDecoder(): 543. を変換関数
として渡すのがよいです:

 -- C の関数: int PyUnicode_FSDecoder (PyObject *obj, void *result)
     ' 次に属します: *note Stable ABI: 51e.'  ParseTuple converter:
     decode *note bytes: 1a4. objects - obtained either directly or
     indirectly through the *note os.PathLike: c1f. interface - to *note
     str: 418. using *note PyUnicode_DecodeFSDefaultAndSize(): 490c.;
     *note str: 418. objects are output as-is.  'result' must be a *note
     PyUnicodeObject: 75f.* which must be released when it is no longer
     used.

     Added in version 3.2.

     バージョン 3.6 で変更: *note path-like object: 280. を受け入れるよ
     うになりました。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeFSDefaultAndSize
          (const char *str, Py_ssize_t size)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Decode a string from the *note filesystem encoding and error
     handler: 505.

     If you need to decode a string from the current locale encoding,
     use *note PyUnicode_DecodeLocaleAndSize(): b97.

     参考
     ....

     *note Py_DecodeLocale(): b95. 関数。

     バージョン 3.6 で変更: The *note filesystem error handler: 505. is
     now used.

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeFSDefault (const
          char *str)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Decode a null-terminated string from the *note filesystem encoding
     and error handler: 505.

     If the string length is known, use *note
     PyUnicode_DecodeFSDefaultAndSize(): 490c.

     バージョン 3.6 で変更: The *note filesystem error handler: 505. is
     now used.

 -- C の関数: *note PyObject: 312. *PyUnicode_EncodeFSDefault (PyObject
          *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Encode a Unicode object to the *note filesystem encoding and error
     handler: 505, and return *note bytes: 1a4.  Note that the resulting
     *note bytes: 1a4. object can contain null bytes.

     If you need to encode a string to the current locale encoding, use
     *note PyUnicode_EncodeLocale(): b98.

     参考
     ....

     *note Py_EncodeLocale(): b96. 関数。

     Added in version 3.2.

     バージョン 3.6 で変更: The *note filesystem error handler: 505. is
     now used.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0383/

   (2) https://peps.python.org/pep-0529/


File: python.info,  Node: wchar_t サポート,  Prev: ファイルシステムエンコーディング,  Up: Unicode オブジェクト

7.8.3.13 wchar_t サポート
.........................

‘wchar_t’ をサポートするプラットフォームでの wchar_t サポート:

 -- C の関数: *note PyObject: 312. *PyUnicode_FromWideChar (const
          wchar_t *wstr, Py_ssize_t size)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Create a Unicode object from the ‘wchar_t’ buffer 'wstr' of the
     given 'size'.  Passing ‘-1’ as the 'size' indicates that the
     function must itself compute the length, using ‘wcslen()’.  Return
     ‘NULL’ on failure.

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_AsWideChar (PyObject
          *unicode, wchar_t *wstr, Py_ssize_t size)
     ' 次に属します: *note Stable ABI: 51e.'  Copy the Unicode object
     contents into the ‘wchar_t’ buffer 'wstr'.  At most 'size'
     ‘wchar_t’ characters are copied (excluding a possibly trailing null
     termination character).  Return the number of ‘wchar_t’ characters
     copied or ‘-1’ in case of an error.

     When 'wstr' is ‘NULL’, instead return the 'size' that would be
     required to store all of 'unicode' including a terminating null.

     Note that the resulting wchar_t* string may or may not be
     null-terminated.  It is the responsibility of the caller to make
     sure that the wchar_t* string is null-terminated in case this is
     required by the application.  Also, note that the wchar_t* string
     might contain null characters, which would cause the string to be
     truncated when used with most C functions.

 -- C の関数: wchar_t *PyUnicode_AsWideCharString (PyObject *unicode,
          Py_ssize_t *size)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     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 number of wide characters (excluding the trailing null
     termination character) into '*size'.  Note that the resulting
     ‘wchar_t’ string might contain null characters, which would cause
     the string to be truncated when used with most C functions.  If
     'size' is ‘NULL’ and the wchar_t* string contains null characters a
     *note ValueError: 1e3. is raised.

     Returns a buffer allocated by *note PyMem_New: 14ce. (use *note
     PyMem_Free(): 13ea. to free it) on success.  On error, returns
     ‘NULL’ and '*size' is undefined.  Raises a *note MemoryError: 1627.
     if memory allocation is failed.

     Added in version 3.2.

     バージョン 3.7 で変更: Raises a *note ValueError: 1e3. if 'size' is
     ‘NULL’ and the wchar_t* string contains null characters.


File: python.info,  Node: 組み込み codec built-in codec,  Next: メソッドおよびスロット関数 slot function,  Prev: Unicode オブジェクト,  Up: Unicode オブジェクトと codec

7.8.3.14 組み込み codec (built-in codec)
........................................

Python には、処理速度を高めるために C で書かれた codec が揃えてあります
。これら全ての codec は以下の関数を介して直接利用できます。

以下の API の多くが、 'encoding' と 'errors' という二つの引数をとります
。これらのパラメータは、組み込みの文字列コンストラクタである *note
str(): 418. における同名のパラメータと同じ意味を持ちます。

Setting encoding to ‘NULL’ causes the default encoding to be used which
is UTF-8.  The file system calls should use *note
PyUnicode_FSConverter(): ce7. for encoding file names.  This uses the
*note filesystem encoding and error handler: 505. internally.

'errors' で指定するエラー処理もまた、 ‘NULL’ を指定できます。 ‘NULL’ を
指定すると、codec で定義されているデフォルト処理の使用を意味します。全て
の組み込み codec で、デフォルトのエラー処理は "strict" (*note
ValueError: 1e3. を送出する) になっています。

個々の codec は全て同様のインターフェースを使っています。個別の codec の
説明では、説明を簡単にするために以下の汎用のインターフェースとの違いだけ
を説明しています。

* Menu:

* 汎用 codec::
* UTF-8 Codecs::
* UTF-32 Codecs::
* UTF-16 Codecs::
* UTF-7 Codecs::
* Unicode-Escape Codecs::
* Raw-Unicode-Escape Codecs::
* Latin-1 Codecs::
* ASCII Codecs::
* Character Map Codecs::
* Windows 用の MBCS codec::
* メソッドとスロット::


File: python.info,  Node: 汎用 codec,  Next: UTF-8 Codecs,  Up: 組み込み codec built-in codec

7.8.3.15 汎用 codec
...................

以下は汎用 codec の API です:

 -- C の関数: *note PyObject: 312. *PyUnicode_Decode (const char *str,
          Py_ssize_t size, const char *encoding, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Create a Unicode object by decoding 'size' bytes of the encoded
     string 'str'.  'encoding' and 'errors' have the same meaning as the
     parameters of the same name in the *note str(): 418. built-in
     function.  The codec to be used is looked up using the Python codec
     registry.  Return ‘NULL’ if an exception was raised by the codec.

 -- C の関数: *note PyObject: 312. *PyUnicode_AsEncodedString (PyObject
          *unicode, const char *encoding, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Unicode オブジェクトをエンコードし、その結果を Python の bytes オブ
     ジェクトとして返します。 'encoding' および 'errors' は Unicode 型の
     *note encode(): 8a3. メソッドに与える同名のパラメータと同じ意味を持
     ちます。 使用する codec の検索は、 Python の codec レジストリを使っ
     て行います。 codec が例外を送出した場合には ‘NULL’ を返します。


File: python.info,  Node: UTF-8 Codecs,  Next: UTF-32 Codecs,  Prev: 汎用 codec,  Up: 組み込み codec built-in codec

7.8.3.16 UTF-8 Codecs
.....................

以下は UTF-8 codec の APIです:

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF8 (const char
          *str, Py_ssize_t size, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     UTF-8 でエンコードされた 'size' バイトの文字列 'str' から Unicode オ
     ブジェクトを生成します。codec が例外を送出した場合には ‘NULL’ を返
     します。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF8Stateful (const
          char *str, Py_ssize_t size, const char *errors, Py_ssize_t
          *consumed)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'consumed' が ‘NULL’ の場合、 *note PyUnicode_DecodeUTF8(): 4918. と
     同じように動作します。 'consumed' が ‘NULL’ でない場合、末尾の不完
     全な UTF-8 バイト列はエラーとみなされません。これらのバイト列はデコ
     ードされず、デコードされたバイト数は 'consumed' に格納されます。

 -- C の関数: *note PyObject: 312. *PyUnicode_AsUTF8String (PyObject
          *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     UTF-8 で Unicode オブジェクトをエンコードし、結果を Python バイト列
     オブジェクトとして返します。エラー処理は "strict" です。 codec が例
     外を送出した場合には ‘NULL’ を返します。

     The function fails if the string contains surrogate code points
     (‘U+D800’ - ‘U+DFFF’).

 -- C の関数: const char *PyUnicode_AsUTF8AndSize (PyObject *unicode,
          Py_ssize_t *size)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Unicode オブジェクトを UTF-8 でエンコードしたものへのポインタを返し
     、エンコードされた表現形式でのサイズ (バイト単位) を 'size' に格納
     します。 'size' 引数は ‘NULL’ でも構いません; その場合はサイズは格
     納されません。 返されるバッファには、 null コードポイントがあるかど
     うかに関わらず、常に null バイトが終端に付加されています (これは
     'size' には勘定されません)。

     On error, set an exception, set 'size' to ‘-1’ (if it's not NULL)
     and return ‘NULL’.

     The function fails if the string contains surrogate code points
     (‘U+D800’ - ‘U+DFFF’).

     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 is not responsible for deallocating the buffer.
     The buffer is deallocated and pointers to it become invalid when
     the Unicode object is garbage collected.

     Added in version 3.3.

     バージョン 3.7 で変更: 返り値の型が ‘char *’ ではなく ‘const char
     *’ になりました。

     バージョン 3.10 で変更: This function is a part of the *note
     limited API: 36f.

 -- C の関数: const char *PyUnicode_AsUTF8 (PyObject *unicode)

     *note PyUnicode_AsUTF8AndSize(): 866. とほぼ同じですが、サイズを格
     納しません。

     Added in version 3.3.

     バージョン 3.7 で変更: 返り値の型が ‘char *’ ではなく ‘const char
     *’ になりました。


File: python.info,  Node: UTF-32 Codecs,  Next: UTF-16 Codecs,  Prev: UTF-8 Codecs,  Up: 組み込み codec built-in codec

7.8.3.17 UTF-32 Codecs
......................

以下は UTF-32 codec API です:

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF32 (const char
          *str, Py_ssize_t size, const char *errors, int *byteorder)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     UTF-32 でエンコードされたバッファ文字列から 'size' バイトをデコード
     し、 Unicodeオブジェクトとして返します。 'errors' は (‘NULL’ でない
     なら) エラーハンドラを指定します。デフォルトは "strict" です。

     'byteorder' が ‘NULL’ でない時、デコーダは与えられたバイトオーダー
     でデコードを開始します。

          *byteorder == -1: little endian
          *byteorder == 0:  native order
          *byteorder == 1:  big endian

     ‘*byteorder’ が 0 で、入力データの最初の 4 バイトが byte order mark
     (BOM) ならば、デコーダはこのバイトオーダーに切り替え、BOM は結果の
     Unicode 文字列にコピーされません。 ‘*byteorder’ が ‘-1’ または ‘1’
     ならば、全ての byte order mark は出力にコピーされます。

     デコードが完了した後、入力データの終端に来た時点でのバイトオーダー
     を '*byteorder' にセットします。

     'byteorder' が ‘NULL’ のとき、 codec は native order モードで開始し
     ます。

     codec が例外を発生させたときは ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF32Stateful (const
          char *str, Py_ssize_t size, const char *errors, int
          *byteorder, Py_ssize_t *consumed)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'consumed' が ‘NULL’ のとき、 *note PyUnicode_DecodeUTF32(): 4914.
     と同じように振る舞います。 'consumed' が ‘NULL’ でないとき、 *note
     PyUnicode_DecodeUTF32Stateful(): 4915. は末尾の不完全な (4 で割り切
     れない長さのバイト列などの) UTF-32 バイト列をエラーとして扱いません
     。末尾の不完全なバイト列はデコードされず、デコードされたバイト数が
     'consumed' に格納されます。

 -- C の関数: *note PyObject: 312. *PyUnicode_AsUTF32String (PyObject
          *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  ネイ
     ティブバイトオーダーで UTF-32 エンコーディングされた Python バイト
     文字列を返します。 文字列は常に BOM マークで始まります。 エラーハン
     ドラは "strict" です。 codec が例外を発生させたときは ‘NULL’ を返し
     ます。


File: python.info,  Node: UTF-16 Codecs,  Next: UTF-7 Codecs,  Prev: UTF-32 Codecs,  Up: 組み込み codec built-in codec

7.8.3.18 UTF-16 Codecs
......................

以下は UTF-16 codec の APIです:

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF16 (const char
          *str, Py_ssize_t size, const char *errors, int *byteorder)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     UTF-16 でエンコードされたバッファ 's' から 'size' バイトだけデコー
     ドして、結果を Unicode オブジェクトで返します。 'errors' は (‘NULL’
     でない場合) エラー処理方法を定義します。デフォルト値は "strict" で
     す。

     'byteorder' が ‘NULL’ でない時、デコーダは与えられたバイトオーダー
     でデコードを開始します。

          *byteorder == -1: little endian
          *byteorder == 0:  native order
          *byteorder == 1:  big endian

     ‘*byteorder’ が 0 で、入力データの先頭2バイトがバイトオーダーマーク
     (BOM) だった場合、デコーダは BOM が示すバイトオーダーに切り替え、そ
     のBOMを結果の Unicode 文字列にコピーしません。 ‘*byteorder’ が ‘-1’
     か ‘1’ だった場合、すべてのBOMは出力へコピーされます (出力では
     ‘\ufeff’ か ‘\ufffe’ のどちらかになるでしょう)。

     デコードが完了した後、入力データの終端に来た時点でのバイトオーダー
     を ‘*byteorder’ にセットします。

     'byteorder' が ‘NULL’ のとき、 codec は native order モードで開始し
     ます。

     codec が例外を発生させたときは ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF16Stateful (const
          char *str, Py_ssize_t size, const char *errors, int
          *byteorder, Py_ssize_t *consumed)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'consumed' が ‘NULL’ の場合、 *note PyUnicode_DecodeUTF16(): 4912.
     と同じように動作します。 'consumed' が ‘NULL’ でない場合、 *note
     PyUnicode_DecodeUTF16Stateful(): 4913. は末尾の不完全な UTF-16 バイ
     ト列 (奇数長のバイト列や分割されたサロゲートペア) をエラーとみなし
     ません。これらのバイト列はデコードされず、デコードされたバイト数を
     'consumed' に返します。

 -- C の関数: *note PyObject: 312. *PyUnicode_AsUTF16String (PyObject
          *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  ネイ
     ティブバイトオーダーで UTF-16 エンコーディングされた Python バイト
     文字列を返します。 文字列は常に BOM マークで始まります。 エラーハン
     ドラは "strict" です。 codec が例外を発生させたときは ‘NULL’ を返し
     ます。


File: python.info,  Node: UTF-7 Codecs,  Next: Unicode-Escape Codecs,  Prev: UTF-16 Codecs,  Up: 組み込み codec built-in codec

7.8.3.19 UTF-7 Codecs
.....................

以下は UTF-7 codec の API です:

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF7 (const char
          *str, Py_ssize_t size, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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.

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUTF7Stateful (const
          char *str, Py_ssize_t size, const char *errors, Py_ssize_t
          *consumed)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'consumed' が ‘NULL’ のとき、 *note PyUnicode_DecodeUTF7(): 4916. と
     同じように動作します。 'consumed' が ‘NULL’ でないとき、末尾の不完
     全な UTF-7 base-64 部分をエラーとしません。不完全な部分のバイト列は
     デコードせずに、デコードしたバイト数を 'consumed' に格納します。


File: python.info,  Node: Unicode-Escape Codecs,  Next: Raw-Unicode-Escape Codecs,  Prev: UTF-7 Codecs,  Up: 組み込み codec built-in codec

7.8.3.20 Unicode-Escape Codecs
..............................

以下は "Unicode Escape" codec の API です:

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeUnicodeEscape (const
          char *str, Py_ssize_t size, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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.

 -- C の関数: *note PyObject: 312. *PyUnicode_AsUnicodeEscapeString
          (PyObject *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Unicode-Escape を使い Unicode オブジェクトをエンコードし、結果を
     bytes オブジェクトとして返します。 エラー処理は "strict" です。
     codec が例外を送出した場合には ‘NULL’ を返します。


File: python.info,  Node: Raw-Unicode-Escape Codecs,  Next: Latin-1 Codecs,  Prev: Unicode-Escape Codecs,  Up: 組み込み codec built-in codec

7.8.3.21 Raw-Unicode-Escape Codecs
..................................

以下は "Raw Unicode Escape" codec の APIです:

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeRawUnicodeEscape
          (const char *str, Py_ssize_t size, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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.

 -- C の関数: *note PyObject: 312. *PyUnicode_AsRawUnicodeEscapeString
          (PyObject *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Raw-Unicode-Escape を使い Unicode オブジェクトをエンコードし、結果
     を bytes オブジェクトとして返します。 エラー処理は "strict" です。
     codec が例外を送出した場合には ‘NULL’ を返します。


File: python.info,  Node: Latin-1 Codecs,  Next: ASCII Codecs,  Prev: Raw-Unicode-Escape Codecs,  Up: 組み込み codec built-in codec

7.8.3.22 Latin-1 Codecs
.......................

以下は Latin-1 codec の APIです: Latin-1 は、 Unicode 序数の最初の 256 個
に対応し、エンコード時にはこの 256 個だけを受理します。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeLatin1 (const char
          *str, Py_ssize_t size, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Latin-1 でエンコードされた 'size' バイトの文字列 'str' から Unicode
     オブジェクトを生成します。codec が例外を送出した場合には ‘NULL’ を
     返します。

 -- C の関数: *note PyObject: 312. *PyUnicode_AsLatin1String (PyObject
          *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Latin-1 で Unicode オブジェクトをエンコードし、結果を Python bytes
     オブジェクトとして返します。 エラー処理は "strict" です。 codec が
     例外を送出した場合には ‘NULL’ を返します。


File: python.info,  Node: ASCII Codecs,  Next: Character Map Codecs,  Prev: Latin-1 Codecs,  Up: 組み込み codec built-in codec

7.8.3.23 ASCII Codecs
.....................

以下は ASCII codec の APIです。 7 ビットの ASCII データだけを受理します
。その他のコードはエラーになります。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeASCII (const char
          *str, Py_ssize_t size, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Create a Unicode object by decoding 'size' bytes of the ASCII
     encoded string 'str'.  Return ‘NULL’ if an exception was raised by
     the codec.

 -- C の関数: *note PyObject: 312. *PyUnicode_AsASCIIString (PyObject
          *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     ASCII で Unicode オブジェクトをエンコードし、結果を Python bytes オ
     ブジェクトとして返します。 エラー処理は "strict" です。 codec が例
     外を送出した場合には ‘NULL’ を返します。


File: python.info,  Node: Character Map Codecs,  Next: Windows 用の MBCS codec,  Prev: ASCII Codecs,  Up: 組み込み codec built-in codec

7.8.3.24 Character Map Codecs
.............................

この codec は、多くの様々な codec を実装する際に使われるという点で特殊な
codec です (実際、 ‘encodings’ パッケージに入っている標準 codecs のほと
んどは、この codec を使っています)。 この codec は、文字のエンコードやデ
コードに対応表を使います。 提供される対応表のオブジェクトは *note
__getitem__(): 264. マッピングインターフェースをサポートしていなければな
りません; 辞書やシーケンスがそれに適しています。

以下は mapping codec の APIです:

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeCharmap (const char
          *str, Py_ssize_t length, PyObject *mapping, const char
          *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  与え
     られた 'mapping' オブジェクトを使って、 'size' バイトのエンコードさ
     れた文字列 'str' をデコードして Unicode オブジェクトを作成します。
     codec が例外を発生させたときは ‘NULL’ を返します。

     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 strings, integers (which are then interpreted as
     Unicode ordinals) or ‘None’.  Unmapped data bytes - ones which
     cause a *note LookupError: 2131, as well as ones which get mapped
     to ‘None’, ‘0xFFFE’ or ‘'\ufffe'’, are treated as undefined
     mappings and cause an error.

 -- C の関数: *note PyObject: 312. *PyUnicode_AsCharmapString (PyObject
          *unicode, PyObject *mapping)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Unicode オブジェクトを 'mapping' に指定されたオブジェクトを使ってエ
     ンコードし、結果を bytes オブジェクトとして返します。エラー処理は
     "strict" です。 codec が例外を送出した場合には ‘NULL’ を返します。

     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 *note LookupError: 2131.) as
     well as mapped to ‘None’ are treated as "undefined mapping" and
     cause an error.

以下の codec API は Unicode から Unicode への対応付けを行う特殊なもので
す。

 -- C の関数: *note PyObject: 312. *PyUnicode_Translate (PyObject
          *unicode, PyObject *table, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  文字
     列に文字対応表 'table' を適用して変換し、変換結果を Unicode オブジ
     ェクトで返します。codec が例外を発行した場合には ‘NULL’ を返します
     。

     対応表は、Unicode 序数を表す整数を Unicode 序数を表す整数または
     ‘None’ (その文字を削除する) に対応付けなければなりません。

     Mapping tables need only provide the *note __getitem__(): 264.
     interface; dictionaries and sequences work well.  Unmapped
     character ordinals (ones which cause a *note LookupError: 2131.)
     are left untouched and are copied as-is.

     'errors' は codecs で通常使われるのと同じ意味を持ちます。 'errors'
     は ‘NULL’ にしてもよく、デフォルトエラー処理の使用を意味します。


File: python.info,  Node: Windows 用の MBCS codec,  Next: メソッドとスロット,  Prev: Character Map Codecs,  Up: 組み込み codec built-in codec

7.8.3.25 Windows 用の MBCS codec
................................

以下は MBCS codec の API です。この codec は現在のところ、 Windows 上だ
けで利用でき、変換の実装には Win32 MBCS 変換機構 (Win32 MBCS converter)
を使っています。 MBCS (または DBCS) はエンコード方式の種類 (class) を表
す言葉で、単一のエンコード方式を表すわけでなないので注意してください。利
用されるエンコード方式 (target encoding) は、 codec を動作させているマシ
ン上のユーザ設定で定義されています。

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeMBCS (const char
          *str, Py_ssize_t size, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  Create a Unicode object by
     decoding 'size' bytes of the MBCS encoded string 'str'.  Return
     ‘NULL’ if an exception was raised by the codec.

 -- C の関数: *note PyObject: 312. *PyUnicode_DecodeMBCSStateful (const
          char *str, Py_ssize_t size, const char *errors, Py_ssize_t
          *consumed)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  'consumed' が ‘NULL’ のとき、
     *note PyUnicode_DecodeMBCS(): 490f. と同じ動作をします。 'consumed'
     が ‘NULL’ でないとき、 *note PyUnicode_DecodeMBCSStateful(): 4910.
     は文字列の最後にあるマルチバイト文字の前半バイトをデコードせず、
     'consumed' にデコードしたバイト数を格納します。

 -- C の関数: *note PyObject: 312. *PyUnicode_AsMBCSString (PyObject
          *unicode)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  MBCS で Unicode オブジェクトをエン
     コードし、結果を Python バイト列オブジェクトとして返します。エラー
     処理は "strict" です。 codec が例外を送出した場合には ‘NULL’ を返し
     ます。

 -- C の関数: *note PyObject: 312. *PyUnicode_EncodeCodePage (int
          code_page, PyObject *unicode, const char *errors)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. on
     Windows (バージョン 3.7 より).'  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 ‘CP_ACP’ code
     page to get the MBCS encoder.

     Added in version 3.3.


File: python.info,  Node: メソッドとスロット,  Prev: Windows 用の MBCS codec,  Up: 組み込み codec built-in codec

7.8.3.26 メソッドとスロット
...........................


File: python.info,  Node: メソッドおよびスロット関数 slot function,  Prev: 組み込み codec built-in codec,  Up: Unicode オブジェクトと codec

7.8.3.27 メソッドおよびスロット関数 (slot function)
...................................................

以下の API は Unicode オブジェクトおよび文字列を入力に取り (説明では、ど
ちらも文字列と表記しています)、場合に応じて Unicode オブジェクトか整数を
返す機能を持っています。

これらの関数は全て、例外が発生した場合には ‘NULL’ または ‘-1’ を返します
。

 -- C の関数: *note PyObject: 312. *PyUnicode_Concat (PyObject *left,
          PyObject *right)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  二つ
     の文字列を結合して、新たな Unicode 文字列を生成します。

 -- C の関数: *note PyObject: 312. *PyUnicode_Split (PyObject *unicode,
          PyObject *sep, Py_ssize_t maxsplit)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Unicode 文字列のリストを分割して、 Unicode 文字列からなるリストを返
     します。 'sep' が ‘NULL’ の場合、全ての空白文字を使って分割を行いま
     す。それ以外の場合、指定された文字を使って分割を行います。最大で
     'maxsplit' 個までの分割を行います。 'maxsplit' が負ならば分割数に制
     限を設けません。分割結果のリスト内には分割文字は含みません。

 -- C の関数: *note PyObject: 312. *PyUnicode_Splitlines (PyObject
          *unicode, int keepends)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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.

 -- C の関数: *note PyObject: 312. *PyUnicode_Join (PyObject *separator,
          PyObject *seq)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  指定
     した 'separator' で文字列からなるシーケンスを連結 (join) し、連結結
     果を Unicode 文字列で返します。

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_Tailmatch (PyObject
          *unicode, PyObject *substr, Py_ssize_t start, Py_ssize_t end,
          int direction)
     ' 次に属します: *note Stable ABI: 51e.'  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.

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_Find (PyObject *unicode,
          PyObject *substr, Py_ssize_t start, Py_ssize_t end, int
          direction)
     ' 次に属します: *note Stable ABI: 51e.'  ‘unicode[start:end]’ 中に
     'substr' が最初に出現する場所を返します。 このとき指定された検索方
     向 'direction' ('direction' == ‘1’ は順方向検索、 'direction' ==
     ‘-1’ は逆方向検索) で検索します。 戻り値は最初にマッチが見つかった
     場所のインデックスです; 戻り値 ‘-1’ はマッチが見つからなかったこと
     を表し、 ‘-2’ はエラーが発生して例外情報が設定されていることを表し
     ます。

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_FindChar (PyObject
          *unicode, Py_UCS4 ch, Py_ssize_t start, Py_ssize_t end, int
          direction)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     ‘unicode[start:end]’ 中に文字 'ch' が最初に出現する場所を返します。
     このとき指定された検索方向 'direction' ('direction' == ‘1’ は順方向
     検索、 'direction' == ‘-1’ は逆方向検索) で検索します。 戻り値は最
     初にマッチが見つかった場所のインデックスです; 戻り値 ‘-1’ はマッチ
     が見つからなかったことを表し、 ‘-2’ はエラーが発生して例外情報が設
     定されていることを表します。

     Added in version 3.3.

     バージョン 3.7 で変更: 'start' and 'end' are now adjusted to behave
     like ‘unicode[start:end]’.

 -- C の関数: *note Py_ssize_t: a2e. PyUnicode_Count (PyObject *unicode,
          PyObject *substr, Py_ssize_t start, Py_ssize_t end)
     ' 次に属します: *note Stable ABI: 51e.'  ‘unicode[start:end]’ に
     'substr' が重複することなく出現する回数を返します。エラーが発生した
     場合には ‘-1’ を返します。

 -- C の関数: *note PyObject: 312. *PyUnicode_Replace (PyObject
          *unicode, PyObject *substr, PyObject *replstr, Py_ssize_t
          maxcount)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'unicode' 中に出現する 'substr' を最大で 'maxcount' 個 'replstr' に
     置換し、置換結果である Unicode オブジェクトを返します。 'maxcount'
     == ‘-1’ にすると、文字列中に現れる全ての 'substr' を置換します。

 -- C の関数: int PyUnicode_Compare (PyObject *left, PyObject *right)
     ' 次に属します: *note Stable ABI: 51e.'  二つの文字列を比較して、左
     引数が右引数より小さい場合、左右引数が等価の場合、左引数が右引数よ
     り大きい場合に対して、それぞれ ‘-1’, ‘0’, ‘1’ を返します。

     この関数は、失敗したときに ‘-1’ を返すので、 *note
     PyErr_Occurred(): 185c. を呼び出して、エラーをチェックすべきです。

 -- C の関数: int PyUnicode_EqualToUTF8AndSize (PyObject *unicode, const
          char *string, Py_ssize_t size)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     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 (‘0’) otherwise.  If the Unicode object contains
     surrogate code points (‘U+D800’ - ‘U+DFFF’) or the C string is not
     valid UTF-8, false (‘0’) is returned.

     この関数は例外を送出しません。

     Added in version 3.13.

 -- C の関数: int PyUnicode_EqualToUTF8 (PyObject *unicode, const char
          *string)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Similar to *note PyUnicode_EqualToUTF8AndSize(): 34f, but compute
     'string' length using ‘strlen()’.  If the Unicode object contains
     null characters, false (‘0’) is returned.

     Added in version 3.13.

 -- C の関数: int PyUnicode_CompareWithASCIIString (PyObject *unicode,
          const char *string)
     ' 次に属します: *note Stable ABI: 51e.'  Unicode オブジェクト
     'unicode' と 'string' を比較して、左引数が右引数より小さい場合、左
     右引数が等価の場合、左引数が右引数より大きい場合に対して、それぞれ
     ‘-1’, ‘0’, ‘1’ を返します。 ASCII エンコードされた文字列だけを渡す
     のが最も良いですが、入力文字列に非 ASCII 文字が含まれている場合は
     ISO-8859-1 として解釈します。

     この関数は例外を送出しません。

 -- C の関数: *note PyObject: 312. *PyUnicode_RichCompare (PyObject
          *left, PyObject *right, int op)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  二つ
     のUnicode文字列を比較して、下のうちの一つを返します:

        * ‘NULL’ を、例外が発生したときに返します。

        * *note Py_True: 4a64. もしくは *note Py_False: 4a63. を、正しく
          比較できた時に返します。

        * *note Py_NotImplemented: 49da. in case the type combination is
          unknown

     Possible values for 'op' are *note Py_GT: 49e2, *note Py_GE: 49e3,
     *note Py_EQ: 49e0, *note Py_NE: 49e1, *note Py_LT: 49de, and *note
     Py_LE: 49df.

 -- C の関数: *note PyObject: 312. *PyUnicode_Format (PyObject *format,
          PyObject *args)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  新た
     な文字列オブジェクトを 'format' および 'args' から生成して返します;
     このメソッドは ‘format % args’ のようなものです。

 -- C の関数: int PyUnicode_Contains (PyObject *unicode, PyObject
          *substr)
     ' 次に属します: *note Stable ABI: 51e.'  'substr' が 'unicode' 内に
     あるか調べ、その結果に応じて真または偽を返します。

     'substr' は単要素の Unicode 文字に型強制できなければなりません。エ
     ラーが生じた場合には ‘-1’ を返します。

 -- C の関数: void PyUnicode_InternInPlace (PyObject **p_unicode)
     ' 次に属します: *note Stable ABI: 51e.'  Intern the argument **note
     p_unicode: 87f. in place.  The argument must be the address of a
     pointer variable pointing to a Python Unicode string object.  If
     there is an existing interned string that is the same as **note
     p_unicode: 87f, it sets **note p_unicode: 87f. to it (releasing the
     reference to the old string object and creating a new *note strong
     reference: 316. to the interned string object), otherwise it leaves
     **note p_unicode: 87f. alone and interns it.

     (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.)

     This function never raises an exception.  On error, it leaves its
     argument unchanged without interning it.

     Instances of subclasses of *note str: 418. may not be interned,
     that is, *note PyUnicode_CheckExact: 4a99.(**note p_unicode: 87f.)
     must be true.  If it is not, then - as with any other error - the
     argument is left unchanged.

     Note that interned strings are not “immortal”.  You must keep a
     reference to the result to benefit from interning.

 -- C の関数: *note PyObject: 312. *PyUnicode_InternFromString (const
          char *str)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  A
     combination of *note PyUnicode_FromString(): 47be. and *note
     PyUnicode_InternInPlace(): 87f, meant for statically allocated
     strings.

     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.

     Python may keep a reference to the result, or make it *note
     immortal: 41f8, preventing it from being garbage-collected
     promptly.  For interning an unbounded number of different strings,
     such as ones coming from user input, prefer calling *note
     PyUnicode_FromString(): 47be. and *note PyUnicode_InternInPlace():
     87f. directly.

     'CPython 実装の詳細:' Strings interned this way are made *note
     immortal: 41f8.


File: python.info,  Node: タプルオブジェクト tuple object,  Next: Struct Sequence オブジェクト,  Prev: Unicode オブジェクトと codec,  Up: シーケンスオブジェクト sequence object

7.8.3.28 タプルオブジェクト (tuple object)
..........................................

 -- C のデータ型: type PyTupleObject

     この *note PyObject: 312. のサブタイプは Python のタプルオブジェク
     トを表現します。

 -- C 変数: *note PyTypeObject: a73. PyTuple_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは Python のタプル型を表現します; Python レイヤ
     における *note tuple: 349. と同じオブジェクトです。

 -- C の関数: int PyTuple_Check (PyObject *p)

     'p' がタプルオブジェクトかタプル型のサブタイプのインスタンスである
     場合に真を返します。この関数は常に成功します。

 -- C の関数: int PyTuple_CheckExact (PyObject *p)

     'p' がタプルオブジェクトだがタプル型のサブタイプのインスタンスでな
     い場合に真を返します。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyTuple_New (Py_ssize_t len)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return a new tuple object of size 'len', or ‘NULL’ with an
     exception set on failure.

 -- C の関数: *note PyObject: 312. *PyTuple_Pack (Py_ssize_t n, ...)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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)’.

 -- C の関数: *note Py_ssize_t: a2e. PyTuple_Size (PyObject *p)
     ' 次に属します: *note Stable ABI: 51e.'  Take a pointer to a tuple
     object, and return the size of that tuple.  On error, return ‘-1’
     and with an exception set.

 -- C の関数: *note Py_ssize_t: a2e. PyTuple_GET_SIZE (PyObject *p)

     Like *note PyTuple_Size(): 48e7, but without error checking.

 -- C の関数: *note PyObject: 312. *PyTuple_GetItem (PyObject *p,
          Py_ssize_t pos)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  'p' の
     指すタプルオブジェクト内の、位置 'pos' にあるオブジェクトを返します
     。 'pos' が負であるか範囲を超えている場合、 ‘NULL’ を返して *note
     IndexError: 14de. 例外をセットします。

     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
     *note strong reference: 316, use *note
     Py_NewRef(PyTuple_GetItem(...)): 867. or *note
     PySequence_GetItem(): 19be.

 -- C の関数: *note PyObject: 312. *PyTuple_GET_ITEM (PyObject *p,
          Py_ssize_t pos)
     '戻り値: 借用参照。' *note PyTuple_GetItem(): 4763. に似ていますが
     、引数に対するエラーチェックを行いません。

 -- C の関数: *note PyObject: 312. *PyTuple_GetSlice (PyObject *p,
          Py_ssize_t low, Py_ssize_t high)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return the slice of the tuple pointed to by 'p' between 'low' and
     'high', or ‘NULL’ with an exception set on failure.

     This is the equivalent of the Python expression ‘p[low:high]’.
     Indexing from the end of the tuple is not supported.

 -- C の関数: int PyTuple_SetItem (PyObject *p, Py_ssize_t pos, PyObject
          *o)
     ' 次に属します: *note Stable ABI: 51e.'  'p' の指すタプルオブジェク
     ト内の、位置 'pos' にあるオブジェクトへの参照を入れます。成功すれば
     ‘0’ を返します。 'pos' が範囲を超えている場合、 ‘-1’ を返して *note
     IndexError: 14de. 例外をセットします。

          注釈: この関数は 'o' への参照を "盗み取り" ます。また、変更先
          のインデクスにすでに別の要素が入っている場合、その要素に対する
          参照を放棄します。

 -- C の関数: void PyTuple_SET_ITEM (PyObject *p, Py_ssize_t pos,
          PyObject *o)

     *note PyTuple_SetItem(): 4764. に似ていますが、エラーチェックを行わ
     ず、新たなタプルに値を入れるとき '以外には使ってはなりません' 。

     Bounds checking is performed as an assertion if Python is built in
     *note debug mode: 1da. or *note with assertions: 365.

          注釈: この関数は 'o' への参照を "盗み取り" ます。また、 *note
          PyTuple_SetItem(): 4764. と違って、要素の置き換えが生じても置
          き換えられるオブジェクトへの参照を放棄 'しません' ; その結果、
          タプル中の位置 'pos' で参照されていたオブジェクトがメモリリー
          クを引き起こします。

 -- C の関数: int _PyTuple_Resize (PyObject **p, Py_ssize_t newsize)

     タプルをリサイズする際に使えます。 'newsize' はタプルの新たな長さで
     す。タプルは変更不能なオブジェクト 'ということになっている' ので、
     この関数はこのオブジェクトに対してただ一つしか参照がない時以外には
     使ってはなりません。タプルがコード中の他の部分ですでに参照されてい
     る場合には、この関数を '使ってはなりません' 。タプルは常に指定サイ
     ズの末尾まで伸縮します。成功した場合には ‘0’ を返します。クライアン
     トコードは、 ‘*p’ の値が呼び出し前と同じになると期待してはなりませ
     ん。 ‘*p’ が置き換えられた場合、オリジナルの ‘*p’ は破壊されます。
     失敗すると ‘-1’ を返し、 ‘*p’ を ‘NULL’ に設定して、 *note
     MemoryError: 1627. または *note SystemError: 541. を送出します。


File: python.info,  Node: Struct Sequence オブジェクト,  Next: リストオブジェクト,  Prev: タプルオブジェクト tuple object,  Up: シーケンスオブジェクト sequence object

7.8.3.29 Struct Sequence オブジェクト
.....................................

struct sequence オブジェクトは *note namedtuple(): 1ac. オブジェクトと等
価なC オブジェクトです。 つまり、その要素に属性を通してアクセスすること
ができるシーケンスです。 struct sequence を生成するには、まず特定の
struct sequence 型を生成しなければなりません。

 -- C の関数: *note PyTypeObject: a73. *PyStructSequence_NewType
          (PyStructSequence_Desc *desc)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  後述
     の 'desc' 中のデータから新しい struct sequence 型を生成します。返さ
     れる型のインスタンスは *note PyStructSequence_New(): 48d7. で生成で
     きます。

     Return ‘NULL’ with an exception set on failure.

 -- C の関数: void PyStructSequence_InitType (PyTypeObject *type,
          PyStructSequence_Desc *desc)

     struct sequence 型である 'type' を 'desc' をもとにその場で初期化し
     ます。

 -- C の関数: int PyStructSequence_InitType2 (PyTypeObject *type,
          PyStructSequence_Desc *desc)

     Like *note PyStructSequence_InitType(): fcd, but returns ‘0’ on
     success and ‘-1’ with an exception set on failure.

     Added in version 3.4.

 -- C のデータ型: type PyStructSequence_Desc
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'  生
     成するstruct sequence 型のメタデータを保持します。

      -- C のメンバ変数: const char *name

          Fully qualified name of the type; null-terminated UTF-8
          encoded.  The name must contain the module name.

      -- C のメンバ変数: const char *doc

          Pointer to docstring for the type or ‘NULL’ to omit.

      -- C のメンバ変数: *note PyStructSequence_Field: b87. *fields

          Pointer to ‘NULL’-terminated array with field names of the new
          type.

      -- C のメンバ変数: int n_in_sequence

          Number of fields visible to the Python side (if used as
          tuple).

 -- C のデータ型: type PyStructSequence_Field
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'
     Describes a field of a struct sequence.  As a struct sequence is
     modeled as a tuple, all fields are typed as *note PyObject: 312.*.
     The index in the *note fields: 4acd. array of the *note
     PyStructSequence_Desc: b88. determines which field of the struct
     sequence is described.

      -- C のメンバ変数: const char *name

          Name for the field or ‘NULL’ to end the list of named fields,
          set to *note PyStructSequence_UnnamedField: 950. to leave
          unnamed.

      -- C のメンバ変数: const char *doc

          Field docstring or ‘NULL’ to omit.

 -- C 変数: const char *const PyStructSequence_UnnamedField
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'  フ
     ィールド名を名前がないままするための特殊な値。

     バージョン 3.9 で変更: 型が ‘char *’ から変更されました。

 -- C の関数: *note PyObject: 312. *PyStructSequence_New (PyTypeObject
          *type)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'type' のインスタンスを生成します。 'type' は *note
     PyStructSequence_NewType(): 48d8. によって事前に生成していなければ
     なりません。

     Return ‘NULL’ with an exception set on failure.

 -- C の関数: *note PyObject: 312. *PyStructSequence_GetItem (PyObject
          *p, Py_ssize_t pos)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  Return
     the object at position 'pos' in the struct sequence pointed to by
     'p'.

     Bounds checking is performed as an assertion if Python is built in
     *note debug mode: 1da. or *note with assertions: 365.

 -- C の関数: *note PyObject: 312. *PyStructSequence_GET_ITEM (PyObject
          *p, Py_ssize_t pos)
     '戻り値: 借用参照。' Alias to *note PyStructSequence_GetItem():
     48d6.

     バージョン 3.13 で変更: Now implemented as an alias to *note
     PyStructSequence_GetItem(): 48d6.

 -- C の関数: void PyStructSequence_SetItem (PyObject *p, Py_ssize_t
          pos, PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  struct sequence 'p' の
     'pos' の位置にあるフィールドに値 'o' を設定します。*note
     PyTuple_SET_ITEM(): 366. のように、生成したてのインスタンスに対して
     のみ使用すべきです。

     Bounds checking is performed as an assertion if Python is built in
     *note debug mode: 1da. or *note with assertions: 365.

          注釈: この関数は 'o' への参照を "盗み取り" ます。

 -- C の関数: void PyStructSequence_SET_ITEM (PyObject *p, Py_ssize_t
          *pos, PyObject *o)

     Alias to *note PyStructSequence_SetItem(): 48d9.

     バージョン 3.13 で変更: Now implemented as an alias to *note
     PyStructSequence_SetItem(): 48d9.


File: python.info,  Node: リストオブジェクト,  Prev: Struct Sequence オブジェクト,  Up: シーケンスオブジェクト sequence object

7.8.3.30 リストオブジェクト
...........................

 -- C のデータ型: type PyListObject

     この *note PyObject: 312. のサブタイプは Python のリストオブジェク
     トを表現します。

 -- C 変数: *note PyTypeObject: a73. PyList_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは Python のリスト型を表現します。これは Python
     レイヤにおける *note list: 5dc. と同じオブジェクトです。

 -- C の関数: int PyList_Check (PyObject *p)

     'p' がリストオブジェクトかリスト型のサブタイプのインスタンスである
     場合に真を返します。この関数は常に成功します。

 -- C の関数: int PyList_CheckExact (PyObject *p)

     'p' がリストオブジェクトだがリスト型のサブタイプのインスタンスでな
     い場合に真を返します。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyList_New (Py_ssize_t len)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  サイ
     ズが 'len' 新たなリストオブジェクトを返します。 失敗すると ‘NULL’ を
     返します。

          注釈: 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 *note PySequence_SetItem():
          19bf. or expose the object to Python code before setting all
          items to a real object with *note PyList_SetItem(): 4765. or
          *note PyList_SET_ITEM(): 367.  The following APIs are safe
          APIs before the list is fully initialized: *note
          PyList_SetItem(): 4765. and *note PyList_SET_ITEM(): 367.

 -- C の関数: *note Py_ssize_t: a2e. PyList_Size (PyObject *list)
     ' 次に属します: *note Stable ABI: 51e.'

     リストオブジェクト 'list' の長さを返します; リストオブジェクトにお
     ける ‘len(list)’ と同じです。

 -- C の関数: *note Py_ssize_t: a2e. PyList_GET_SIZE (PyObject *list)

     *note PyList_Size(): 13c1. に似ていますが、エラーチェックを行いませ
     ん。

 -- C の関数: *note PyObject: 312. *PyList_GetItemRef (PyObject *list,
          Py_ssize_t index)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.13 より).'  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 (‘<0 or >=len(list)’), return ‘NULL’ and set an *note
     IndexError: 14de. exception.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyList_GetItem (PyObject *list,
          Py_ssize_t index)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  Like
     *note PyList_GetItemRef(): 334, but returns a *note borrowed
     reference: 317. instead of a *note strong reference: 316.

 -- C の関数: *note PyObject: 312. *PyList_GET_ITEM (PyObject *list,
          Py_ssize_t i)
     '戻り値: 借用参照。' *note PyList_GetItem(): 335. に似ていますが、
     エラーチェックを行いません。

 -- C の関数: int PyList_SetItem (PyObject *list, Py_ssize_t index,
          PyObject *item)
     ' 次に属します: *note Stable ABI: 51e.'  リストオブジェクト内の位置
     'index' に、オブジェクト 'item' を挿入します。 成功した場合には ‘0’
     を返します。 'index' が範囲を越えている場合、 ‘-1’ を返して *note
     IndexError: 14de. をセットします。

          注釈: この関数は 'item' への参照を "盗み取り" ます。また、変更
          先のインデクスにすでに別の要素が入っている場合、その要素に対す
          る参照を放棄します。

 -- C の関数: void PyList_SET_ITEM (PyObject *list, Py_ssize_t i,
          PyObject *o)

     *note PyList_SetItem(): 4765. をマクロによる実装で、エラーチェック
     を行いません。このマクロは、新たなリストのまだ要素を入れたことのな
     い位置に要素を入れるときにのみ使います。

     Bounds checking is performed as an assertion if Python is built in
     *note debug mode: 1da. or *note with assertions: 365.

          注釈: このマクロは 'item' への参照を "盗み取り" ます。また、
          *note PyList_SetItem(): 4765. と違って、要素の置き換えが生じて
          も置き換えられるオブジェクトへの参照を放棄 'しません' ; その結
          果、 'list' 中の位置 'i' で参照されていたオブジェクトがメモリ
          リークを引き起こします。

 -- C の関数: int PyList_Insert (PyObject *list, Py_ssize_t index,
          PyObject *item)
     ' 次に属します: *note Stable ABI: 51e.'  要素 'item' をリスト
     'list' のインデックス 'index' の前に挿入します。成功すると ‘0’ を返
     します。失敗すると ‘-1’ を返し、例外をセットします。
     ‘list.insert(index, item)’ に類似した機能です。

 -- C の関数: int PyList_Append (PyObject *list, PyObject *item)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'item' を
     'list' の末尾に追加します。成功すると ‘0’ を返します; 失敗すると
     ‘-1’ を返し、例外をセットします。‘list.append(item)’ に類似した機能
     です。

 -- C の関数: *note PyObject: 312. *PyList_GetSlice (PyObject *list,
          Py_ssize_t low, Py_ssize_t high)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'list' 内の、'low' から 'high' 'までの' オブジェクトからなるリスト
     を返します。 失敗すると ‘NULL’ を返し、例外をセットします。
     ‘list[low:high]’ に類似した機能です。 ただし、リストの末尾からのイ
     ンデックスはサポートされていません。

 -- C の関数: int PyList_SetSlice (PyObject *list, Py_ssize_t low,
          Py_ssize_t high, PyObject *itemlist)
     ' 次に属します: *note Stable ABI: 51e.'  'low' から 'high' までの
     'list' のスライスを、 'itemlist' の内容にします。 ‘list[low:high] =
     itemlist’ と類似の機能です。 'itemlist' は ‘NULL’ でもよく、空リス
     トの代入 (指定スライスの削除) になります。 成功した場合には ‘0’ を
     、失敗した場合には ‘-1’ を返します。 ただし、リストの末尾からのイン
     デックスはサポートされていません。

 -- C の関数: int PyList_Extend (PyObject *list, PyObject *iterable)

     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’.

     Raise an exception and return ‘-1’ if 'list' is not a *note list:
     5dc. object.  Return 0 on success.

     Added in version 3.13.

 -- C の関数: int PyList_Clear (PyObject *list)

     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[:]’.

     Raise an exception and return ‘-1’ if 'list' is not a *note list:
     5dc. object.  Return 0 on success.

     Added in version 3.13.

 -- C の関数: int PyList_Sort (PyObject *list)
     ' 次に属します: *note Stable ABI: 51e.'  'list' の内容をインプレー
     スでソートします。成功した場合には ‘0’ を、失敗した場合には ‘-1’ を
     返します。‘list.sort()’ と同じです。

 -- C の関数: int PyList_Reverse (PyObject *list)
     ' 次に属します: *note Stable ABI: 51e.'  'list' の要素をインプレー
     スで反転します。成功した場合には ‘0’ を、失敗した場合には ‘-1’ を返
     します。‘list.reverse()’ と同じです。

 -- C の関数: *note PyObject: 312. *PyList_AsTuple (PyObject *list)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     'list' の内容が入った新たなタプルオブジェクトを返します;
     ‘tuple(list)’ と同じです。


File: python.info,  Node: Container オブジェクト,  Next: Function オブジェクト<2>,  Prev: シーケンスオブジェクト sequence object,  Up: 具象オブジェクト concrete object レイヤ

7.8.4 Container オブジェクト
----------------------------

* Menu:

* 辞書オブジェクト (dictionary object): 辞書オブジェクト dictionary object.
* Set オブジェクト::


File: python.info,  Node: 辞書オブジェクト dictionary object,  Next: Set オブジェクト,  Up: Container オブジェクト

7.8.4.1 辞書オブジェクト (dictionary object)
............................................

 -- C のデータ型: type PyDictObject

     この *note PyObject: 312. のサブタイプは Python の辞書オブジェクト
     を表現します。

 -- C 変数: *note PyTypeObject: a73. PyDict_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは Python の辞書を表現します。このオブジェクトは
     、Python レイヤにおける *note dict: 237. と同じオブジェクトです。

 -- C の関数: int PyDict_Check (PyObject *p)

     'p' が辞書オブジェクトか辞書型のサブタイプのインスタンスである場合
     に真を返します。この関数は常に成功します。

 -- C の関数: int PyDict_CheckExact (PyObject *p)

     'p' が辞書オブジェクトだが辞書型のサブタイプのインスタンスでない場
     合に真を返します。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyDict_New ()
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  空の
     新たな辞書を返します。 失敗すると ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyDictProxy_New (PyObject *mapping)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  ある
     マップ型オブジェクトに対して、読み出し専用に制限された *note
     types.MappingProxyType: 43a. オブジェクトを返します。通常、この関数
     は動的でないクラス型 (non-dynamic class type) のクラス辞書が変更さ
     れないようにビューを作成するために使われます。

 -- C の関数: void PyDict_Clear (PyObject *p)
     ' 次に属します: *note Stable ABI: 51e.'  現在辞書に入っている全ての
     キーと値のペアを除去して空にします。

 -- C の関数: int PyDict_Contains (PyObject *p, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e.'  辞書 'p' に 'key' が入って
     いるか判定します。'p' の要素が 'key' に一致した場合は ‘1’ を返し、
     それ以外の場合には ‘0’ を返します。エラーの場合 ‘-1’ を返します。こ
     の関数は Python の式 ‘key in p’ と等価です。

 -- C の関数: int PyDict_ContainsString (PyObject *p, const char *key)

     This is the same as *note PyDict_Contains(): 311, but 'key' is
     specified as a const char* UTF-8 encoded bytes string, rather than
     a *note PyObject: 312.*.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyDict_Copy (PyObject *p)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  'p'
     と同じキーと値のペアが入った新たな辞書を返します。

 -- C の関数: int PyDict_SetItem (PyObject *p, PyObject *key, PyObject
          *val)
     ' 次に属します: *note Stable ABI: 51e.'  辞書 'p' に、 'key' をキー
     として値 'val' を挿入します。 'key' はハッシュ可能(*note hashable:
     5db.)でなければなりません。ハッシュ可能でない場合、 *note
     TypeError: 502. を送出します。 成功した場合には ‘0’ を、失敗した場
     合には ‘-1’ を返します。 この関数は 'val' への参照を盗み取り 'ませ
     ん'。

 -- C の関数: int PyDict_SetItemString (PyObject *p, const char *key,
          PyObject *val)
     ' 次に属します: *note Stable ABI: 51e.'  This is the same as *note
     PyDict_SetItem(): 4766, but 'key' is specified as a const char*
     UTF-8 encoded bytes string, rather than a *note PyObject: 312.*.

 -- C の関数: int PyDict_DelItem (PyObject *p, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e.'  辞書 'p' から 'key' をキー
     とするエントリを除去します。 'key' は *note ハッシュ可能: 5db. でな
     ければなりません; ハッシュ可能でない場合、 *note TypeError: 502. を
     送出します。'key' が辞書になければ、*note KeyError: 31d. を送出しま
     す。成功した場合には ‘0’ を、失敗した場合には ‘-1’ を返します。

 -- C の関数: int PyDict_DelItemString (PyObject *p, const char *key)
     ' 次に属します: *note Stable ABI: 51e.'  This is the same as *note
     PyDict_DelItem(): 482a, but 'key' is specified as a const char*
     UTF-8 encoded bytes string, rather than a *note PyObject: 312.*.

 -- C の関数: int PyDict_GetItemRef (PyObject *p, PyObject *key,
          PyObject **result)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Return a new *note strong reference: 316. to the object from
     dictionary 'p' which has a key 'key':

        * If the key is present, set '*result' to a new *note strong
          reference: 316. to the value and return ‘1’.

        * If the key is missing, set '*result' to ‘NULL’ and return ‘0’.

        * エラーの場合例外を送出し ‘-1’ を返します。

     Added in version 3.13.

     See also the *note PyObject_GetItem(): 320. function.

 -- C の関数: *note PyObject: 312. *PyDict_GetItem (PyObject *p,
          PyObject *key)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  Return
     a *note borrowed reference: 317. to the object from dictionary 'p'
     which has a key 'key'.  Return ‘NULL’ if the key 'key' is missing
     'without' setting an exception.

          注釈: Exceptions that occur while this calls *note __hash__():
          ac9. and *note __eq__(): ac8. methods are silently ignored.
          Prefer the *note PyDict_GetItemWithError(): 315. function
          instead.

     バージョン 3.10 で変更: Calling this API without *note GIL: 13f.
     held had been allowed for historical reason.  It is no longer
     allowed.

 -- C の関数: *note PyObject: 312. *PyDict_GetItemWithError (PyObject
          *p, PyObject *key)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  *note
     PyDict_GetItem(): 360. の変種で例外を隠しません。 例外が発生した場
     合は、例外をセット 'した上で' ‘NULL’ を返します。 キーが存在しなか
     った場合は、例外をセット 'せずに' ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyDict_GetItemString (PyObject *p,
          const char *key)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  This
     is the same as *note PyDict_GetItem(): 360, but 'key' is specified
     as a const char* UTF-8 encoded bytes string, rather than a *note
     PyObject: 312.*.

          注釈: Exceptions that occur while this calls *note __hash__():
          ac9. and *note __eq__(): ac8. methods or while creating the
          temporary *note str: 418. object are silently ignored.  Prefer
          using the *note PyDict_GetItemWithError(): 315. function with
          your own *note PyUnicode_FromString(): 47be. 'key' instead.

 -- C の関数: int PyDict_GetItemStringRef (PyObject *p, const char *key,
          PyObject **result)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Similar than *note PyDict_GetItemRef(): 313, but 'key' is specified
     as a const char* UTF-8 encoded bytes string, rather than a *note
     PyObject: 312.*.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyDict_SetDefault (PyObject *p,
          PyObject *key, PyObject *defaultobj)
     '戻り値: 借用参照。' これは Python レベルの *note
     dict.setdefault(): 104e. と同じです。 もしあれば、辞書 'p' から
     'key' に対応する値を返します。 キーが辞書になければ、値
     'defaultobj' を挿入し 'defaultobj' を返します。 この関数は、 'key'
     のハッシュ値を検索と挿入ごとに別々に評価するのではなく、一度だけし
     か評価しません。

     Added in version 3.4.

 -- C の関数: int PyDict_SetDefaultRef (PyObject *p, PyObject *key,
          PyObject *default_value, PyObject **result)

     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’, then '*result' is set to a *note strong reference:
     316. to either 'default_value', if the key was not present, or the
     existing value, if 'key' was already present in the dictionary.
     Returns ‘1’ if the key was present and 'default_value' was not
     inserted, or ‘0’ if the key was not present and 'default_value' was
     inserted.  On failure, returns ‘-1’, sets an exception, and sets
     ‘*result’ to ‘NULL’.

     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.

     Added in version 3.13.

 -- C の関数: int PyDict_Pop (PyObject *p, PyObject *key, PyObject
          **result)

     Remove 'key' from dictionary 'p' and optionally return the removed
     value.  Do not raise *note KeyError: 31d. if the key missing.

        - If the key is present, set '*result' to a new reference to the
          removed value if 'result' is not ‘NULL’, and return ‘1’.

        - If the key is missing, set '*result' to ‘NULL’ if 'result' is
          not ‘NULL’, and return ‘0’.

        - エラーの場合例外を送出し ‘-1’ を返します。

     This is similar to *note dict.pop(): 31c, but without the default
     value and not raising *note KeyError: 31d. if the key missing.

     Added in version 3.13.

 -- C の関数: int PyDict_PopString (PyObject *p, const char *key,
          PyObject **result)

     Similar to *note PyDict_Pop(): 31a, but 'key' is specified as a
     const char* UTF-8 encoded bytes string, rather than a *note
     PyObject: 312.*.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyDict_Items (PyObject *p)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  辞書
     内の全ての要素対が入った *note PyListObject: 49f9. を返します。

 -- C の関数: *note PyObject: 312. *PyDict_Keys (PyObject *p)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  辞書
     内の全てのキーが入った *note PyListObject: 49f9. を返します。

 -- C の関数: *note PyObject: 312. *PyDict_Values (PyObject *p)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  辞書
     'p' 内の全ての値が入った *note PyListObject: 49f9. を返します。

 -- C の関数: *note Py_ssize_t: a2e. PyDict_Size (PyObject *p)
     ' 次に属します: *note Stable ABI: 51e.'

     辞書内の要素の数を返します。辞書に対して ‘len(p)’ を実行するのと同
     じです。

 -- C の関数: int PyDict_Next (PyObject *p, Py_ssize_t *ppos, PyObject
          **pkey, PyObject **pvalue)
     ' 次に属します: *note Stable ABI: 51e.'  辞書 'p' 内の全てのキー/値
     のペアにわたる反復処理を行います。 'ppos' が参照している *note
     Py_ssize_t: a2e. 型は、この関数で反復処理を開始する際に、最初に関数
     を呼び出すよりも前に ‘0’ に初期化しておかなければなりません。この関
     数は辞書内の各ペアを取り上げるごとに真を返し、全てのペアを取り上げ
     たことが分かると偽を返します。 パラメーター 'pkey' および 'pvalue'
     には、それぞれ辞書の各々のキーと値が埋められた *note PyObject:
     312.* 変数を指すポインタか、または ‘NULL’ が入ります。 この関数から
     返される参照はすべて借用参照になります。 反復処理中に 'ppos' を変更
     してはなりません。 この値は内部的な辞書構造体のオフセットを表現して
     おり、構造体はスパースなので、オフセットの値に一貫性がないためです
     。

     例えば:

          PyObject *key, *value;
          Py_ssize_t pos = 0;

          while (PyDict_Next(self->dict, &pos, &key, &value)) {
              /* do something interesting with the values... */
              ...
          }

     反復処理中に辞書 'p' を変更してはなりません。辞書を反復処理する際に
     、キーに対応する値を変更しても大丈夫になりましたが、キーの集合を変
     更しないことが前提です。以下に例を示します:

          PyObject *key, *value;
          Py_ssize_t pos = 0;

          while (PyDict_Next(self->dict, &pos, &key, &value)) {
              long i = PyLong_AsLong(value);
              if (i == -1 && PyErr_Occurred()) {
                  return -1;
              }
              PyObject *o = PyLong_FromLong(i + 1);
              if (o == NULL)
                  return -1;
              if (PyDict_SetItem(self->dict, key, o) < 0) {
                  Py_DECREF(o);
                  return -1;
              }
              Py_DECREF(o);
          }

     The function is not thread-safe in the *note free-threaded: 433e.
     build without external synchronization.  You can use *note
     Py_BEGIN_CRITICAL_SECTION: 4adf. to lock the dictionary while
     iterating over it:

          Py_BEGIN_CRITICAL_SECTION(self->dict);
          while (PyDict_Next(self->dict, &pos, &key, &value)) {
              ...
          }
          Py_END_CRITICAL_SECTION();

 -- C の関数: int PyDict_Merge (PyObject *a, PyObject *b, int override)
     ' 次に属します: *note Stable ABI: 51e.'  マップ型オブジェクト 'b' の
     全ての要素にわたって、反復的にキー/値のペアを辞書 'a' に追加します
     。 'b' は辞書か、 *note PyMapping_Keys(): b8a. または *note
     PyObject_GetItem(): 320. をサポートする何らかのオブジェクトにできま
     す。 'override' が真ならば、 'a' のキーと一致するキーが 'b' にある
     際に、既存のペアを置き換えます。それ以外の場合は、 'b' のキーに一致
     するキーが 'a' にないときのみ追加を行います。成功した場合には ‘0’ を
     返し、例外が送出された場合には ‘-1’ を返します。

 -- C の関数: int PyDict_Update (PyObject *a, PyObject *b)
     ' 次に属します: *note Stable ABI: 51e.'  C で表せば
     ‘PyDict_Merge(a, b, 1)’ と同じで、また Python の ‘a.update(b)’ と似
     ていますが、 *note PyDict_Update(): 4833. は第二引数が "keys" 属性
     を持たない場合にキー/値ペアのシーケンスを反復することはありません。
     成功した場合には ‘0’ を返し、例外が送出された場合には ‘-1’ を返しま
     す。

 -- C の関数: int PyDict_MergeFromSeq2 (PyObject *a, PyObject *seq2, int
          override)
     ' 次に属します: *note Stable ABI: 51e.'  'seq2' 内のキー/値ペアを使
     って、辞書 'a' の内容を更新したり統合したりします。'seq2' は、キー
     /値のペアとみなせる長さ 2 の反復可能オブジェクト(iterable object) を
     生成する反復可能オブジェクトでなければなりません。重複するキーが存
     在する場合、'override' が真ならば先に出現したキーを使い、そうでない
     場合は後に出現したキーを使います。成功した場合には ‘0’ を返し、例外
     が送出された場合には ‘-1’ を返します。(戻り値以外は) 等価な Python
     コードを書くと、以下のようになります:

          def PyDict_MergeFromSeq2(a, seq2, override):
              for key, value in seq2:
                  if override or key not in a:
                      a[key] = value

 -- C の関数: int PyDict_AddWatcher (PyDict_WatchCallback callback)

     Register 'callback' as a dictionary watcher.  Return a non-negative
     integer id which must be passed to future calls to *note
     PyDict_Watch(): 52f.  In case of error (e.g.  no more watcher IDs
     available), return ‘-1’ and set an exception.

     Added in version 3.12.

 -- C の関数: int PyDict_ClearWatcher (int watcher_id)

     Clear watcher identified by 'watcher_id' previously returned from
     *note PyDict_AddWatcher(): 52e.  Return ‘0’ on success, ‘-1’ on
     error (e.g.  if the given 'watcher_id' was never registered.)

     Added in version 3.12.

 -- C の関数: int PyDict_Watch (int watcher_id, PyObject *dict)

     Mark dictionary 'dict' as watched.  The callback granted
     'watcher_id' by *note PyDict_AddWatcher(): 52e. will be called when
     'dict' is modified or deallocated.  Return ‘0’ on success or ‘-1’
     on error.

     Added in version 3.12.

 -- C の関数: int PyDict_Unwatch (int watcher_id, PyObject *dict)

     Mark dictionary 'dict' as no longer watched.  The callback granted
     'watcher_id' by *note PyDict_AddWatcher(): 52e. 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.

     Added in version 3.12.

 -- C のデータ型: type PyDict_WatchEvent

     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’.

     Added in version 3.12.

 -- C のデータ型: typedef int (*PyDict_WatchCallback)(*note
          PyDict_WatchEvent: 4ae2. event, *note PyObject: 312. *dict,
          *note PyObject: 312. *key, *note PyObject: 312. *new_value)

     Type of a dict watcher callback function.

     If 'event' is ‘PyDict_EVENT_CLEARED’ or ‘PyDict_EVENT_DEALLOCATED’,
     both 'key' and 'new_value' will be ‘NULL’.  If 'event' is
     ‘PyDict_EVENT_ADDED’ or ‘PyDict_EVENT_MODIFIED’, 'new_value' will
     be the new value for 'key'.  If 'event' is ‘PyDict_EVENT_DELETED’,
     'key' is being deleted from the dictionary and 'new_value' will be
     ‘NULL’.

     ‘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.

     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.

     If 'event' is ‘PyDict_EVENT_DEALLOCATED’, taking a new reference in
     the callback to the about-to-be-destroyed dictionary 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.

     Callbacks occur before the notified modification to 'dict' takes
     place, so the prior state of 'dict' can be inspected.

     If the callback sets an exception, it must return ‘-1’; this
     exception will be printed as an unraisable exception using *note
     PyErr_WriteUnraisable(): 328.  Otherwise it should return ‘0’.

     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 set.  This means the callback may not call any
     other API that can set an exception unless it saves and clears the
     exception state first, and restores it before returning.

     Added in version 3.12.


File: python.info,  Node: Set オブジェクト,  Prev: 辞書オブジェクト dictionary object,  Up: Container オブジェクト

7.8.4.2 Set オブジェクト
........................

このセクションでは *note set: 5a3. と *note frozenset: 5a4. の公開 API に
ついて詳しく述べます。以降で説明していない機能は、抽象オブジェクトプロト
コル (*note PyObject_CallMethod(): 379, *note
PyObject_RichCompareBool(): 190e, *note PyObject_Hash(): 3dc, *note
PyObject_Repr(): ff9, *note PyObject_IsTrue(): 48b5, *note
PyObject_Print(): 1554, *note PyObject_GetIter(): 48b4. を含む) か抽象数
値プロトコル (*note PyNumber_And(): 4889, *note PyNumber_Subtract():
48a2, *note PyNumber_Or(): 489d, *note PyNumber_Xor(): 48a4, *note
PyNumber_InPlaceAnd(): 488e, *note PyNumber_InPlaceSubtract(): 4896,
*note PyNumber_InPlaceOr(): 4892, *note PyNumber_InPlaceXor(): 4898. を
含む) を使って利用できます。

 -- C のデータ型: type PySetObject

     この *note PyObject: 312. を継承した型は、 *note set: 5a3. と *note
     frozenset: 5a4. 両方の内部データを保存するのに用いられます。 *note
     PyDictObject: 39b. と同じように、小さい集合(set)に対しては(タプルの
     ように)固定サイズであり、そうでない集合に対しては(リストと同じよう
     に)可変長のメモリブロックを用います。この構造体のどのフィールドも、
     公開されていると考えるべきではなく、変更される可能性があります。す
     べてのアクセスは、構造体の中の値を直接操作するのではなく、ドキュメ
     ントされた API を用いて行うべきです。

 -- C 変数: *note PyTypeObject: a73. PySet_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは、Python の *note set: 5a3. 型を表します。

 -- C 変数: *note PyTypeObject: a73. PyFrozenSet_Type
     ' 次に属します: *note Stable ABI: 51e.'  この *note PyTypeObject:
     a73. のインスタンスは、Python の *note frozenset: 5a4. 型を表します
     。

以降の型チェックマクロはすべての Python オブジェクトに対するポインタに対
して動作します。同様に、コンストラクタはすべてのイテレート可能な Python
オブジェクトに対して動作します。

 -- C の関数: int PySet_Check (PyObject *p)

     'p' が *note set: 5a3. かそのサブタイプのオブジェクトであるときに
     true を返します。この関数は常に成功します。

 -- C の関数: int PyFrozenSet_Check (PyObject *p)

     'p' が *note frozenset: 5a4. かそのサブタイプのオブジェクトであると
     きに true を返します。この関数は常に成功します。

 -- C の関数: int PyAnySet_Check (PyObject *p)

     'p' が *note set: 5a3. か *note frozenset: 5a4. 、あるいはそのサブ
     タイプのオブジェクトであれば、true を返します。この関数は常に成功し
     ます。

 -- C の関数: int PySet_CheckExact (PyObject *p)

     'p' が *note set: 5a3. オブジェクトだがサブタイプのインスタンスでな
     い場合に真を返します。この関数は常に成功します。

     Added in version 3.10.

 -- C の関数: int PyAnySet_CheckExact (PyObject *p)

     'p' が *note set: 5a3. か *note frozenset: 5a4. のどちらかのオブジ
     ェクトであるときに true を返します。サブタイプのオブジェクトは含み
     ません。この関数は常に成功します。

 -- C の関数: int PyFrozenSet_CheckExact (PyObject *p)

     'p' が *note frozenset: 5a4. オブジェクトだがサブタイプのインスタン
     スでない場合に真を返します。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PySet_New (PyObject *iterable)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'iterable' が返すオブジェクトを含む新しい *note set: 5a3. を返しま
     す。 'iterable' が ‘NULL’ のときは、空の set を返します。 成功した
     ら新しい set を、失敗したら ‘NULL’ を返します。 'iterable' がイテレ
     ート可能でない場合は、 *note TypeError: 502. を送出します。 このコ
     ンストラクタは set をコピーするときにも使えます (‘c=set(s)’)。

 -- C の関数: *note PyObject: 312. *PyFrozenSet_New (PyObject *iterable)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'iterable' が返すオブジェクトを含む新しい *note frozenset: 5a4. を
     返します。 'iterable' が ‘NULL’ のときは、空の frozenset を返します
     。 成功時には新しい set を、失敗時には ‘NULL’ を返します。
     'iterable' がイテレート可能でない場合は、 *note TypeError: 502. を
     送出します。

以降の関数やマクロは、 *note set: 5a3. と *note frozenset: 5a4. とそのサ
ブタイプのインスタンスに対して利用できます。

 -- C の関数: *note Py_ssize_t: a2e. PySet_Size (PyObject *anyset)
     ' 次に属します: *note Stable ABI: 51e.'

     Return the length of a *note set: 5a3. or *note frozenset: 5a4.
     object.  Equivalent to ‘len(anyset)’.  Raises a *note SystemError:
     541. if 'anyset' is not a *note set: 5a3, *note frozenset: 5a4, or
     an instance of a subtype.

 -- C の関数: *note Py_ssize_t: a2e. PySet_GET_SIZE (PyObject *anyset)

     エラーチェックを行わない、 *note PySet_Size(): 13f1. のマクロ形式。

 -- C の関数: int PySet_Contains (PyObject *anyset, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e.'  Return ‘1’ if found, ‘0’
     if not found, and ‘-1’ if an error is encountered.  Unlike the
     Python *note __contains__(): 1ebe. method, this function does not
     automatically convert unhashable sets into temporary frozensets.
     Raise a *note TypeError: 502. if the 'key' is unhashable.  Raise
     *note SystemError: 541. if 'anyset' is not a *note set: 5a3, *note
     frozenset: 5a4, or an instance of a subtype.

 -- C の関数: int PySet_Add (PyObject *set, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e.'  *note set: 5a3. のインスタ
     ンスに 'key' を追加します。 *note frozenset: 5a4. に対しても動作し
     ます (*note PyTuple_SetItem(): 4764. のように、他のコードに見える前
     の新しい frozenset の値を埋めるために使用できます)。 成功したら ‘0’
     を、失敗したら ‘-1’ を返します。 'key' がハッシュ可能でない場合は、
     *note TypeError: 502. を送出します。 'set' を大きくする余裕がない場
     合は、 *note MemoryError: 1627. を送出します。 'set' が *note set:
     5a3. かそのサブタイプのインスタンスでない場合は、 *note
     SystemError: 541. を送出します。

以降の関数は、 *note set: 5a3. とそのサブタイプに対して利用可能です。
*note frozenset: 5a4. とそのサブタイプには利用できません。

 -- C の関数: int PySet_Discard (PyObject *set, PyObject *key)
     ' 次に属します: *note Stable ABI: 51e.'  Return ‘1’ if found and
     removed, ‘0’ if not found (no action taken), and ‘-1’ if an error
     is encountered.  Does not raise *note KeyError: 31d. for missing
     keys.  Raise a *note TypeError: 502. if the 'key' is unhashable.
     Unlike the Python *note discard(): 219a. method, this function does
     not automatically convert unhashable sets into temporary
     frozensets.  Raise *note SystemError: 541. if 'set' is not an
     instance of *note set: 5a3. or its subtype.

 -- C の関数: *note PyObject: 312. *PySet_Pop (PyObject *set)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'set' の中の要素のどれかに対する新しい参照を返し、そのオブジェクト
     を 'set' から削除します。 失敗したら ‘NULL’ を返します。 set が空の
     場合には *note KeyError: 31d. を送出します。 'set' が *note set:
     5a3. とそのサブタイプのインスタンスでない場合は、 *note
     SystemError: 541. を送出します。

 -- C の関数: int PySet_Clear (PyObject *set)
     ' 次に属します: *note Stable ABI: 51e.'  Empty an existing set of
     all elements.  Return ‘0’ on success.  Return ‘-1’ and raise *note
     SystemError: 541. if 'set' is not an instance of *note set: 5a3. or
     its subtype.


File: python.info,  Node: Function オブジェクト<2>,  Next: その他のオブジェクト<2>,  Prev: Container オブジェクト,  Up: 具象オブジェクト concrete object レイヤ

7.8.5 Function オブジェクト
---------------------------

* Menu:

* Function オブジェクト: Function オブジェクト<3>.
* インスタンスメソッドオブジェクト(Instance Method Objects): インスタンスメソッドオブジェクト Instance Method Objects.
* メソッドオブジェクト: メソッドオブジェクト<2>.
* セルオブジェクト (cell object): セルオブジェクト cell object.
* コードオブジェクト: コードオブジェクト<3>.
* Extra information::


File: python.info,  Node: Function オブジェクト<3>,  Next: インスタンスメソッドオブジェクト Instance Method Objects,  Up: Function オブジェクト<2>

7.8.5.1 Function オブジェクト
.............................

Functionオブジェクト固有の関数はわずかです。

 -- C のデータ型: type PyFunctionObject

     関数に使われるCの構造体。

 -- C 変数: *note PyTypeObject: a73. PyFunction_Type

     *note PyTypeObject: a73. 型のインスタンスで、 Python の関数型を表し
     ます。これは Python プログラムに ‘types.FunctionType’ として公開さ
     れています。

 -- C の関数: int PyFunction_Check (PyObject *o)

     'o' が関数オブジェクト (*note PyFunction_Type: 4af3. 型である) 場合
     に真を返します。パラメータは ‘NULL’ にできません。この関数は常に成
     功します。

 -- C の関数: *note PyObject: 312. *PyFunction_New (PyObject *code,
          PyObject *globals)
     '戻り値: 新しい参照。' コードオブジェクト 'code' に関連付けられた新
     しい関数オブジェクトを返します。'globals' はこの関数からアクセスで
     きるグローバル変数の辞書でなければなりません。

     関数のドキュメント文字列と名前はコードオブジェクトから取得されます
     。 *note __module__: 1e5d. は 'globals' から取得されます。 引数のデ
     フォルト値やアノテーション、クロージャは ‘NULL’ に設定されます。
     *note __qualname__: 1e5c. はコードオブジェクトの *note co_qualname:
     1e97. フィールドと同じ値に設定されます。

 -- C の関数: *note PyObject: 312. *PyFunction_NewWithQualName (PyObject
          *code, PyObject *globals, PyObject *qualname)
     '戻り値: 新しい参照。' *note PyFunction_New(): 4af5. に似ていますが
     、関数オブジェクトの *note __qualname__: 1e5c. 属性に値をセットでき
     ます。 'qualname' はユニコードオブジェクトか ‘NULL’ でなくてはなり
     ません。‘NULL’ だった場合、 ‘__qualname__’ 属性にはコードオブジェク
     トの *note co_qualname: 1e97. フィールドと同じ値がセットされます。

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyFunction_GetCode (PyObject *op)
     '戻り値: 借用参照。' 関数オブジェクト 'op' に関連付けられたコードオ
     ブジェクトを返します。

 -- C の関数: *note PyObject: 312. *PyFunction_GetGlobals (PyObject *op)
     '戻り値: 借用参照。' 関数オブジェクト 'op' に関連付けられた
     globals辞書を返します。

 -- C の関数: *note PyObject: 312. *PyFunction_GetModule (PyObject *op)
     '戻り値: 借用参照。' Return a *note borrowed reference: 317. to the
     *note __module__: 1e5d. attribute of the *note function object:
     279. 'op'.  It can be 'NULL'.

     This is normally a *note string: 418. containing the module name,
     but can be set to any other object by Python code.

 -- C の関数: *note PyObject: 312. *PyFunction_GetDefaults (PyObject
          *op)
     '戻り値: 借用参照。' 関数オブジェクト 'op' の引数のデフォルト値を返
     します。 引数のタプルか ‘NULL’ になります。

 -- C の関数: int PyFunction_SetDefaults (PyObject *op, PyObject
          *defaults)

     関数オブジェクト 'op' の引数のデフォルト値を設定します。 'defaults'
     は ‘Py_None’ かタプルでなければいけません。

     失敗した時は、 *note SystemError: 541. を発生させ、 ‘-1’ を返します
     。

 -- C の関数: void PyFunction_SetVectorcall (PyFunctionObject *func,
          vectorcallfunc vectorcall)

     Set the vectorcall field of a given function object 'func'.

     Warning: extensions using this API must preserve the behavior of
     the unaltered (default) vectorcall function!

     Added in version 3.12.

 -- C の関数: *note PyObject: 312. *PyFunction_GetClosure (PyObject *op)
     '戻り値: 借用参照。' 関数オブジェクト 'op' に設定されたクロージャを
     返します。 ‘NULL’ か cell オブジェクトのタプルです。

 -- C の関数: int PyFunction_SetClosure (PyObject *op, PyObject
          *closure)

     関数オブジェクト 'op' にクロージャを設定します。 'closure' は、
     ‘Py_None’ もしくは cell オブジェクトのタプルでなければなりません。

     失敗した時は、 *note SystemError: 541. を発生させ、 ‘-1’ を返します
     。

 -- C の関数: *note PyObject: 312. *PyFunction_GetAnnotations (PyObject
          *op)
     '戻り値: 借用参照。' 関数オブジェクト 'op' のアノテーションを返しま
     す。 返り値は修正可能な辞書か ‘NULL’ になります。

 -- C の関数: int PyFunction_SetAnnotations (PyObject *op, PyObject
          *annotations)

     関数オブジェクト 'op' のアノテーションを設定します。 'annotations'
     は辞書か、‘Py_None’ でなければなりません。

     失敗した時は、 *note SystemError: 541. を発生させ、 ‘-1’ を返します
     。

 -- C の関数: int PyFunction_AddWatcher (PyFunction_WatchCallback
          callback)

     Register 'callback' as a function watcher for the current
     interpreter.  Return an ID which may be passed to *note
     PyFunction_ClearWatcher(): 4b00.  In case of error (e.g.  no more
     watcher IDs available), return ‘-1’ and set an exception.

     Added in version 3.12.

 -- C の関数: int PyFunction_ClearWatcher (int watcher_id)

     Clear watcher identified by 'watcher_id' previously returned from
     *note PyFunction_AddWatcher(): 4aff. 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.)

     Added in version 3.12.

 -- C のデータ型: type PyFunction_WatchEvent

     Enumeration of possible function watcher events: -
     ‘PyFunction_EVENT_CREATE’ - ‘PyFunction_EVENT_DESTROY’ -
     ‘PyFunction_EVENT_MODIFY_CODE’ - ‘PyFunction_EVENT_MODIFY_DEFAULTS’
     - ‘PyFunction_EVENT_MODIFY_KWDEFAULTS’

     Added in version 3.12.

 -- C のデータ型: typedef int (*PyFunction_WatchCallback)(*note
          PyFunction_WatchEvent: 4b01. event, *note PyFunctionObject:
          52d. *func, *note PyObject: 312. *new_value)

     Type of a function watcher callback function.

     If 'event' is ‘PyFunction_EVENT_CREATE’ or
     ‘PyFunction_EVENT_DESTROY’ then 'new_value' will be ‘NULL’.
     Otherwise, 'new_value' will hold a *note borrowed reference: 317.
     to the new value that is about to be stored in 'func' for the
     attribute that is being modified.

     The callback may inspect but must not modify 'func'; doing so could
     have unpredictable effects, including infinite recursion.

     If 'event' is ‘PyFunction_EVENT_CREATE’, then the callback is
     invoked after ‘func’ has been fully initialized.  Otherwise, the
     callback is invoked before the modification to 'func' takes place,
     so the prior state of 'func' can be inspected.  The runtime is
     permitted to optimize away the creation of function objects when
     possible.  In such cases no event will be emitted.  Although this
     creates the possibility of an observable difference of runtime
     behavior depending on optimization decisions, it does not change
     the semantics of the Python code being executed.

     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.

     If the callback sets an exception, it must return ‘-1’; this
     exception will be printed as an unraisable exception using *note
     PyErr_WriteUnraisable(): 328.  Otherwise it should return ‘0’.

     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 set.  This means the callback may not call any
     other API that can set an exception unless it saves and clears the
     exception state first, and restores it before returning.

     Added in version 3.12.


File: python.info,  Node: インスタンスメソッドオブジェクト Instance Method Objects,  Next: メソッドオブジェクト<2>,  Prev: Function オブジェクト<3>,  Up: Function オブジェクト<2>

7.8.5.2 インスタンスメソッドオブジェクト(Instance Method Objects)
.................................................................

An instance method is a wrapper for a *note PyCFunction: 141c. and the
new way to bind a *note PyCFunction: 141c. to a class object.  It
replaces the former call ‘PyMethod_New(func, NULL, class)’.

 -- C 変数: *note PyTypeObject: a73. PyInstanceMethod_Type

     *note PyTypeObject: a73. のインスタンスは Python のインスタンスメソ
     ッドの型を表現します。これは Python のプログラムには公開されません
     。

 -- C の関数: int PyInstanceMethod_Check (PyObject *o)

     'o' がインスタンスメソッドオブジェクト (*note
     PyInstanceMethod_Type: 4b06. 型である) 場合に真を返します。パラメー
     タは ‘NULL’ にできません。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyInstanceMethod_New (PyObject
          *func)
     '戻り値: 新しい参照。' 任意の呼び出し可能オブジェクト 'func' を使っ
     た新たなインスタンスメソッドオブジェクトを返します。'func' はインス
     タンスメソッドが呼び出されたときに呼び出される関数です。

 -- C の関数: *note PyObject: 312. *PyInstanceMethod_Function (PyObject
          *im)
     '戻り値: 借用参照。' インスタンスメソッド 'im' に関連付けられた関数
     オブジェクトを返します。

 -- C の関数: *note PyObject: 312. *PyInstanceMethod_GET_FUNCTION
          (PyObject *im)
     '戻り値: 借用参照。' *note PyInstanceMethod_Function(): 4b09. のマ
     クロ版で、エラーチェックを行いません。


File: python.info,  Node: メソッドオブジェクト<2>,  Next: セルオブジェクト cell object,  Prev: インスタンスメソッドオブジェクト Instance Method Objects,  Up: Function オブジェクト<2>

7.8.5.3 メソッドオブジェクト
............................

メソッドは関数オブジェクトに束縛されています。メソッドは常にあるユーザー
定義のクラスに束縛されているのです。束縛されていないメソッド(クラスオブ
ジェクトに束縛されたメソッド)は利用することができません。

 -- C 変数: *note PyTypeObject: a73. PyMethod_Type

     この *note PyTypeObject: a73. のインスタンスは Python のメソッド型
     を表現します。このオブジェクトは、 ‘types.MethodType’ として Python
     プログラムに公開されています。

 -- C の関数: int PyMethod_Check (PyObject *o)

     'o' がメソッドオブジェクト (*note PyMethod_Type: 4b0d. 型である) 場
     合に真を返します。パラメータは ‘NULL’ にできません。この関数は常に
     成功します。

 -- C の関数: *note PyObject: 312. *PyMethod_New (PyObject *func,
          PyObject *self)
     '戻り値: 新しい参照。' 任意の呼び出し可能オブジェクト 'func' とメソ
     ッドが束縛されるべきインスタンス 'self' を使った新たなメソッドオブ
     ジェクトを返します。 関数 'func' は、メソッドが呼び出された時に呼び
     出されるオブジェクトです。 'self' は ‘NULL’ にできません。

 -- C の関数: *note PyObject: 312. *PyMethod_Function (PyObject *meth)
     '戻り値: 借用参照。' メソッド 'meth' に関連付けられている関数オブジ
     ェクトを返します。

 -- C の関数: *note PyObject: 312. *PyMethod_GET_FUNCTION (PyObject
          *meth)
     '戻り値: 借用参照。' *note PyMethod_Function(): 4b10. のマクロ版で
     、エラーチェックを行いません。

 -- C の関数: *note PyObject: 312. *PyMethod_Self (PyObject *meth)
     '戻り値: 借用参照。' メソッド 'meth' に関連付けられたインスタンスを
     返します。

 -- C の関数: *note PyObject: 312. *PyMethod_GET_SELF (PyObject *meth)
     '戻り値: 借用参照。' *note PyMethod_Self(): 4b12. のマクロ版で、エ
     ラーチェックを行いません。


File: python.info,  Node: セルオブジェクト cell object,  Next: コードオブジェクト<3>,  Prev: メソッドオブジェクト<2>,  Up: Function オブジェクト<2>

7.8.5.4 セルオブジェクト (cell object)
......................................

"セル (cell)" オブジェクトは、複数のスコープから参照される変数群を実装す
るために使われます。セルは各変数について作成され、各々の値を記憶します;
この値を参照する各スタックフレームにおけるローカル変数には、そのスタック
フレームの外側で同じ値を参照しているセルに対する参照が入ります。セルで表
現された値にアクセスすると、セルオブジェクト自体の代わりにセル内の値が使
われます。このセルオブジェクトを使った間接参照 (dereference) は、インタ
プリタによって生成されたバイトコード内でサポートされている必要があります
; セルオブジェクトにアクセスした際に、自動的に間接参照は起こりません。上
記以外の状況では、セルオブジェクトは役に立たないはずです。

 -- C のデータ型: type PyCellObject

     セルオブジェクトに使われる C 構造体です。

 -- C 変数: *note PyTypeObject: a73. PyCell_Type

     セルオブジェクトに対応する型オブジェクトです。

 -- C の関数: int PyCell_Check (PyObject *ob)

     'ob' がセルオブジェクトの場合に真を返します; 'ob' は ‘NULL’ であっ
     てはなりません。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyCell_New (PyObject *ob)
     '戻り値: 新しい参照。' 値 'ob' の入った新たなセルオブジェクトを生成
     して返します。 引数を ‘NULL’ にしてもかまいません。

 -- C の関数: *note PyObject: 312. *PyCell_Get (PyObject *cell)
     '戻り値: 新しい参照。' Return the contents of the cell 'cell',
     which can be ‘NULL’.  If 'cell' is not a cell object, returns
     ‘NULL’ with an exception set.

 -- C の関数: *note PyObject: 312. *PyCell_GET (PyObject *cell)
     '戻り値: 借用参照。' 'cell' の内容を返しますが、'cell' が非 ‘NULL’
     かつセルオブジェクトであるかどうかはチェックしません。

 -- C の関数: int PyCell_Set (PyObject *cell, PyObject *value)

     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’.

     On success, return ‘0’.  If 'cell' is not a cell object, set an
     exception and return ‘-1’.

 -- C の関数: void PyCell_SET (PyObject *cell, PyObject *value)

     セルオブジェクト 'cell' の値を 'value' に設定します。 参照カウント
     に対する変更はなく、安全のためのチェックは何も行いません。'cell' は
     非 ‘NULL’ でなければならず、かつセルオブジェクトでなければなりませ
     ん。


File: python.info,  Node: コードオブジェクト<3>,  Next: Extra information,  Prev: セルオブジェクト cell object,  Up: Function オブジェクト<2>

7.8.5.5 コードオブジェクト
..........................

コードオブジェクト(Code objects)は CPython 実装の低レベルな詳細部分です
。各オブジェクトは関数に束縛されていない実行可能コードの塊を表現していま
す。

 -- C のデータ型: type PyCodeObject

     コードオブジェクトを表現するために利用されるC構造体。この型のフィー
     ルドは何時でも変更され得ます。

 -- C 変数: *note PyTypeObject: a73. PyCode_Type

     This is an instance of *note PyTypeObject: a73. representing the
     Python *note code object: 1b4.

 -- C の関数: int PyCode_Check (PyObject *co)

     Return true if 'co' is a *note code object: 1b4.  This function
     always succeeds.

 -- C の関数: *note Py_ssize_t: a2e. PyCode_GetNumFree (PyCodeObject
          *co)

     Return the number of *note free (closure) variables: 1e9f. in a
     code object.

 -- C の関数: int PyUnstable_Code_GetFirstFree (PyCodeObject *co)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Return the position of the first *note free (closure) variable:
     1e9f. in a code object.

     バージョン 3.13 で変更: Renamed from ‘PyCode_GetFirstFree’ as part
     of *note Unstable C API: 512.  The old name is deprecated, but will
     remain available until the signature changes again.

 -- C の関数: *note PyCodeObject: 742. *PyUnstable_Code_New (int
          argcount, int kwonlyargcount, int nlocals, int stacksize, int
          flags, PyObject *code, PyObject *consts, PyObject *names,
          PyObject *varnames, PyObject *freevars, PyObject *cellvars,
          PyObject *filename, PyObject *name, PyObject *qualname, int
          firstlineno, PyObject *linetable, PyObject *exceptiontable)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Return a new code object.  If you need a dummy code object to
     create a frame, use *note PyCode_NewEmpty(): 1320. instead.

     Since the definition of the bytecode changes often, calling *note
     PyUnstable_Code_New(): 4b22. directly can bind you to a precise
     Python version.

     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.

     バージョン 3.11 で変更: Added ‘qualname’ and ‘exceptiontable’
     parameters.

     バージョン 3.12 で変更: Renamed from ‘PyCode_New’ as part of *note
     Unstable C API: 512.  The old name is deprecated, but will remain
     available until the signature changes again.

 -- C の関数: *note PyCodeObject: 742.
          *PyUnstable_Code_NewWithPosOnlyArgs (int argcount, int
          posonlyargcount, int kwonlyargcount, int nlocals, int
          stacksize, int flags, PyObject *code, PyObject *consts,
          PyObject *names, PyObject *varnames, PyObject *freevars,
          PyObject *cellvars, PyObject *filename, PyObject *name,
          PyObject *qualname, int firstlineno, PyObject *linetable,
          PyObject *exceptiontable)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Similar to *note PyUnstable_Code_New(): 4b22, but with an extra
     "posonlyargcount" for positional-only arguments.  The same caveats
     that apply to ‘PyUnstable_Code_New’ also apply to this function.

     Added in version 3.8: as ‘PyCode_NewWithPosOnlyArgs’

     バージョン 3.11 で変更: Added ‘qualname’ and ‘exceptiontable’
     parameters.

     バージョン 3.12 で変更: Renamed to
     ‘PyUnstable_Code_NewWithPosOnlyArgs’.  The old name is deprecated,
     but will remain available until the signature changes again.

 -- C の関数: *note PyCodeObject: 742. *PyCode_NewEmpty (const char
          *filename, const char *funcname, int firstlineno)
     '戻り値: 新しい参照。' 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.

 -- C の関数: int PyCode_Addr2Line (PyCodeObject *co, int byte_offset)

     Return the line number of the instruction that occurs on or before
     ‘byte_offset’ and ends after it.  If you just need the line number
     of a frame, use *note PyFrame_GetLineNumber(): 756. instead.

     For efficiently iterating over the line numbers in a code object,
     use the API described in PEP 626(1).

 -- C の関数: int PyCode_Addr2Location (PyObject *co, int byte_offset,
          int *start_line, int *start_column, int *end_line, int
          *end_column)

     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.

     Returns ‘1’ if the function succeeds and 0 otherwise.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyCode_GetCode (PyCodeObject *co)

     Equivalent to the Python code ‘getattr(co, 'co_code')’.  Returns a
     strong reference to a *note PyBytesObject: 75d. representing the
     bytecode in a code object.  On error, ‘NULL’ is returned and an
     exception is raised.

     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.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyCode_GetVarnames (PyCodeObject
          *co)

     Equivalent to the Python code ‘getattr(co, 'co_varnames')’.
     Returns a new reference to a *note PyTupleObject: 4993. containing
     the names of the local variables.  On error, ‘NULL’ is returned and
     an exception is raised.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyCode_GetCellvars (PyCodeObject
          *co)

     Equivalent to the Python code ‘getattr(co, 'co_cellvars')’.
     Returns a new reference to a *note PyTupleObject: 4993. containing
     the names of the local variables that are referenced by nested
     functions.  On error, ‘NULL’ is returned and an exception is
     raised.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyCode_GetFreevars (PyCodeObject
          *co)

     Equivalent to the Python code ‘getattr(co, 'co_freevars')’.
     Returns a new reference to a *note PyTupleObject: 4993. containing
     the names of the *note free (closure) variables: 1e9f.  On error,
     ‘NULL’ is returned and an exception is raised.

     Added in version 3.11.

 -- C の関数: int PyCode_AddWatcher (PyCode_WatchCallback callback)

     Register 'callback' as a code object watcher for the current
     interpreter.  Return an ID which may be passed to *note
     PyCode_ClearWatcher(): 533.  In case of error (e.g.  no more
     watcher IDs available), return ‘-1’ and set an exception.

     Added in version 3.12.

 -- C の関数: int PyCode_ClearWatcher (int watcher_id)

     Clear watcher identified by 'watcher_id' previously returned from
     *note PyCode_AddWatcher(): 532. 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.)

     Added in version 3.12.

 -- C のデータ型: type PyCodeEvent

     Enumeration of possible code object watcher events: -
     ‘PY_CODE_EVENT_CREATE’ - ‘PY_CODE_EVENT_DESTROY’

     Added in version 3.12.

 -- C のデータ型: typedef int (*PyCode_WatchCallback)(*note PyCodeEvent:
          4b24. event, *note PyCodeObject: 742. *co)

     Type of a code object watcher callback function.

     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.

     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.

     Users of this API should not rely on internal runtime
     implementation details.  Such details may include, but are not
     limited to, the exact order and timing of creation and destruction
     of code objects.  While changes in these details may result in
     differences observable by watchers (including whether a callback is
     invoked or not), it does not change the semantics of the Python
     code being executed.

     If the callback sets an exception, it must return ‘-1’; this
     exception will be printed as an unraisable exception using *note
     PyErr_WriteUnraisable(): 328.  Otherwise it should return ‘0’.

     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 set.  This means the callback may not call any
     other API that can set an exception unless it saves and clears the
     exception state first, and restores it before returning.

     Added in version 3.12.

   ---------- Footnotes ----------

   (1) 
https://peps.python.org/pep-0626/#out-of-process-debuggers-and-profilers


File: python.info,  Node: Extra information,  Prev: コードオブジェクト<3>,  Up: Function オブジェクト<2>

7.8.5.6 Extra information
.........................

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.

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.

 -- C の関数: *note Py_ssize_t: a2e.
          PyUnstable_Eval_RequestCodeExtraIndex (freefunc free)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Return a new an opaque index value used to adding data to code
     objects.

     You generally call this function once (per interpreter) and use the
     result with ‘PyCode_GetExtra’ and ‘PyCode_SetExtra’ to manipulate
     data on individual code objects.

     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
     *note Py_DecRef(): 492a. when storing *note PyObject: 312.

     Added in version 3.6: as ‘_PyEval_RequestCodeExtraIndex’

     バージョン 3.12 で変更: Renamed to
     ‘PyUnstable_Eval_RequestCodeExtraIndex’.  The old private name is
     deprecated, but will be available until the API changes.

 -- C の関数: int PyUnstable_Code_GetExtra (PyObject *code, Py_ssize_t
          index, void **extra)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Set 'extra' to the extra data stored under the given index.  Return
     0 on success.  Set an exception and return -1 on failure.

     If no data was set under the index, set 'extra' to ‘NULL’ and
     return 0 without setting an exception.

     Added in version 3.6: as ‘_PyCode_GetExtra’

     バージョン 3.12 で変更: Renamed to ‘PyUnstable_Code_GetExtra’.  The
     old private name is deprecated, but will be available until the API
     changes.

 -- C の関数: int PyUnstable_Code_SetExtra (PyObject *code, Py_ssize_t
          index, void *extra)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Set the extra data stored under the given index to 'extra'.  Return
     0 on success.  Set an exception and return -1 on failure.

     Added in version 3.6: as ‘_PyCode_SetExtra’

     バージョン 3.12 で変更: Renamed to ‘PyUnstable_Code_SetExtra’.  The
     old private name is deprecated, but will be available until the API
     changes.


File: python.info,  Node: その他のオブジェクト<2>,  Prev: Function オブジェクト<2>,  Up: 具象オブジェクト concrete object レイヤ

7.8.6 その他のオブジェクト
--------------------------

* Menu:

* ファイルオブジェクト::
* モジュールオブジェクト (module object): モジュールオブジェクト module object.
* イテレータオブジェクト (iterator object): イテレータオブジェクト iterator object.
* デスクリプタオブジェクト (descriptor object): デスクリプタオブジェクト descriptor object.
* スライスオブジェクト (slice object): スライスオブジェクト slice object.
* memoryview オブジェクト::
* 弱参照オブジェクト: 弱参照オブジェクト<2>.
* カプセル: カプセル<2>.
* フレーム (frame) オブジェクト: フレーム frame オブジェクト<2>.
* ジェネレータオブジェクト::
* コルーチンオブジェクト: コルーチンオブジェクト<2>.
* コンテキスト変数オブジェクト::
* DateTime オブジェクト: DateTime オブジェクト<2>.
* 型ヒントのためのオブジェクト::


File: python.info,  Node: ファイルオブジェクト,  Next: モジュールオブジェクト module object,  Up: その他のオブジェクト<2>

7.8.6.1 ファイルオブジェクト
............................

これらの API は、 Python 2 の組み込みのファイルオブジェクトの C API を最
低限エミュレートするためのものです。それらは、標準 C ライブラリでサポー
トされているバッファ付き I/O (FILE*) に頼るために使われます。 Python 3 で
は、ファイルとストリームは新しい *note io: 73. モジュールを使用され、そ
こに OS の低レベルなバッファ付き I/O の上にいくつかの層が定義されていま
す。下で解説されている関数は、それらの新しい API の便利な C ラッパーであ
り、インタプリタでの内部的なエラー通知に向いています; サードパーティーの
コードは代わりに *note io: 73. の API を使うことが推奨されます。

 -- C の関数: *note PyObject: 312. *PyFile_FromFd (int fd, const char
          *name, const char *mode, int buffering, const char *encoding,
          const char *errors, const char *newline, int closefd)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  既に
     開かれているファイル 'fd' のファイルディスクリプタから Python のフ
     ァイルオブジェクトを作成します。 引数 'name' 、 'encoding' 、
     'errors' 、 'newline' には、デフォルトの値として ‘NULL’ が使えます
     。 'buffering' には '-1' を指定してデフォルトの値を使うことができま
     す。 'name' は無視されるのですが、後方互換性のために残されています
     。 失敗すると ‘NULL’ を返します。 より包括的な引数の解説は、 *note
     io.open(): 4e6. 関数のドキュメントを参照してください。

          警告: Python ストリームは自身のバッファリング層を持つため、フ
          ァイル記述子のOSレベルのバッファリングと併用すると、様々な問題
          (予期せぬデータ順) などを引き起こします。

     バージョン 3.2 で変更: 'name' 属性の無視。

 -- C の関数: int PyObject_AsFileDescriptor (PyObject *p)
     ' 次に属します: *note Stable ABI: 51e.'  'p' に関連づけられる ファ
     イルディスクリプタを int として返します。オブジェクトが整数なら、そ
     の値を返します。 整数でない場合、オブジェクトに *note fileno():
     27a6. メソッドがあれば呼び出します; このメソッドの返り値は、ファイ
     ル記述子の値として返される整数でなければなりません。失敗すると例外
     を設定して ‘-1’ を返します。

 -- C の関数: *note PyObject: 312. *PyFile_GetLine (PyObject *p, int n)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     ‘p.readline([n])’ と同じで、この関数はオブジェクト 'p' の各行を読み
     出します。 'p' はファイルオブジェクトか、 *note readline(): 12f8. メ
     ソッドを持つ何らかのオブジェクトでかまいません。 'n' が ‘0’ の場合
     、行の長さに関係なく正確に 1 行だけ読み出します。 'n' が ‘0’ より大
     きければ、 'n' バイト以上のデータは読み出しません; 従って、行の一部
     だけが返される場合があります。 どちらの場合でも、読み出し後すぐにフ
     ァイルの終端に到達した場合には空文字列を 返します。 'n' が ‘0’ より
     小さければ、長さに関わらず 1 行だけを 読み出しますが、すぐにファイ
     ルの終端に到達した場合には *note EOFError: 12a7. を送出します。

 -- C の関数: int PyFile_SetOpenCodeHook (Py_OpenCodeHookFunction
          handler)

     *note io.open_code(): 168e. の通常の振る舞いを上書きして、そのパラ
     メーターを提供されたハンドラで渡します。

     ハンドラーは次の型の関数です。

      -- C のデータ型: typedef *note PyObject: 312.
               *(*Py_OpenCodeHookFunction)(*note PyObject: 312.*, void*)

          *note PyObject: 312. *(*)(*note PyObject: 312. *path, void
          *userData) と等価で、 'path' は *note PyUnicodeObject: 75f. で
          あることが保証されています。

     'userData' ポインタはフック関数に渡されます。 フック関数は別なラン
     タイムから呼び出されるかもしれないので、このポインタは直接 Python の
     状態を参照すべきではありません。

     このフック関数はインポート中に使われることを意図しているため、モジ
     ュールが frozen なモジュールであるか ‘sys.modules’ にある利用可能な
     モジュールであることが分かっている場合を除いては、フック関数の実行
     中に新しいモジュールをインポートするのは避けてください。

     いったんフック関数が設定されたら、削除や置き換えもできず、後からの
     *note PyFile_SetOpenCodeHook(): 1690. の呼び出しは失敗します。 この
     関数が失敗したときは、インタープリタが初期化されていた場合、 -1 を
     返して例外をセットします。

     この関数は *note Py_Initialize(): 87a. より前に呼び出しても安全です
     。

     引数無しで *note 監査イベント: 1825. ‘setopencodehook’ を送出します
     。

     Added in version 3.8.

 -- C の関数: int PyFile_WriteObject (PyObject *obj, PyObject *p, int
          flags)
     ' 次に属します: *note Stable ABI: 51e.'

     オブジェクト 'obj' をファイルオブジェクト 'p' に書き込みます。
     'flags' がサポートするフラグは *note Py_PRINT_RAW: 49dc. だけです;
     このフラグを指定すると、オブジェクトに *note repr(): 7c8. ではなく
     *note str(): 418. を適用した結果をファイルに書き出します。成功した
     場合には ‘0’ を返し、失敗すると ‘-1’ を返して適切な例外をセットしま
     す。

 -- C の関数: int PyFile_WriteString (const char *s, PyObject *p)
     ' 次に属します: *note Stable ABI: 51e.'  文字列 's' をファイルオブ
     ジェクト 'p' に書き出します。成功した場合には ‘0’ を返し、失敗する
     と ‘-1’ を返して適切な例外をセットします。


File: python.info,  Node: モジュールオブジェクト module object,  Next: イテレータオブジェクト iterator object,  Prev: ファイルオブジェクト,  Up: その他のオブジェクト<2>

7.8.6.2 モジュールオブジェクト (module object)
..............................................

 -- C 変数: *note PyTypeObject: a73. PyModule_Type
     ' 次に属します: *note Stable ABI: 51e.'

     この *note PyTypeObject: a73. のインスタンスは Python のモジュール
     オブジェクト型を表現します。このオブジェクトは、Python プログラムに
     は ‘types.ModuleType’ として公開されています。

 -- C の関数: int PyModule_Check (PyObject *p)

     'p' がモジュールオブジェクトかモジュールオブジェクトのサブタイプで
     あるときに真を返します。この関数は常に成功します。

 -- C の関数: int PyModule_CheckExact (PyObject *p)

     'p' がモジュールオブジェクトで、かつ *note PyModule_Type: 4886. の
     サブタイプでないときに真を返します。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyModule_NewObject (PyObject *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'

     Return a new module object with *note module.__name__: 1350. set to
     'name'.  The module's ‘__name__’, *note __doc__: 17bd, *note
     __package__: 2b9. and *note __loader__: 2c3. attributes are filled
     in (all but ‘__name__’ are set to ‘None’).  The caller is
     responsible for setting a *note __file__: 1e7d. attribute.

     Return ‘NULL’ with an exception set on error.

     Added in version 3.3.

     バージョン 3.4 で変更: *note __package__: 2b9. and *note
     __loader__: 2c3. are now set to ‘None’.

 -- C の関数: *note PyObject: 312. *PyModule_New (const char *name)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     *note PyModule_NewObject(): 4884. に似ていますが、 name は Unicode
     オブジェクトではなく UTF-8 でエンコードされた文字列です。

 -- C の関数: *note PyObject: 312. *PyModule_GetDict (PyObject *module)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'

     'module' の名前空間を実装する辞書オブジェクトを返します; このオブジ
     ェクトは、モジュールオブジェクトの *note __dict__: 526. 属性と同じ
     ものです。 'module' がモジュールオブジェクト (もしくはモジュールオ
     ブジェクトのサブタイプ) でない場合は、 *note SystemError: 541. が送
     出され ‘NULL’ が返されます。

     拡張モジュールでは、モジュールの *note __dict__: 526. を直接操作す
     るよりも、 ‘PyModule_*’ および ‘PyObject_*’ 関数を使う方が推奨され
     ます。

 -- C の関数: *note PyObject: 312. *PyModule_GetNameObject (PyObject
          *module)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'

     Return 'module"s *note __name__: 1350. value.  If the module does
     not provide one, or if it is not a string, *note SystemError: 541.
     is raised and ‘NULL’ is returned.

     Added in version 3.3.

 -- C の関数: const char *PyModule_GetName (PyObject *module)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PyModule_GetNameObject(): 4882. に似ていますが、 ‘'utf-8'’ でエンコ
     ードされた name を返します。

 -- C の関数: void *PyModule_GetState (PyObject *module)
     ' 次に属します: *note Stable ABI: 51e.'  モジュールの "state"(モジ
     ュールを生成したタイミングで確保されるメモリブロックへのポインター)
     か、なければ ‘NULL’ を返します。 *note PyModuleDef.m_size: 94d. を
     参照してください。

 -- C の関数: *note PyModuleDef: 94b. *PyModule_GetDef (PyObject
          *module)
     ' 次に属します: *note Stable ABI: 51e.'  モジュールが作られる元とな
     った *note PyModuleDef: 94b. 構造体へのポインタを返します。 モジュ
     ールが定義によって作られていなかった場合は ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyModule_GetFilenameObject (PyObject
          *module)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

     Return the name of the file from which 'module' was loaded using
     'module"s *note __file__: 1e7d. attribute.  If this is not defined,
     or if it is not a string, raise *note SystemError: 541. and return
     ‘NULL’; otherwise return a reference to a Unicode object.

     Added in version 3.2.

 -- C の関数: const char *PyModule_GetFilename (PyObject *module)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PyModule_GetFilenameObject(): 3d2. と似ていますが、 'utf-8' でエン
     コードされたファイル名を返します。

     バージョン 3.2 で非推奨: *note PyModule_GetFilename(): 3d1. はエン
     コードできないファイル名に対しては *note UnicodeEncodeError: 643. を
     送出します。これの代わりに *note PyModule_GetFilenameObject(): 3d2.
     を使用してください。

* Menu:

* Cモジュールの初期化::
* モジュール検索::


File: python.info,  Node: Cモジュールの初期化,  Next: モジュール検索,  Up: モジュールオブジェクト module object

7.8.6.3 Cモジュールの初期化
...........................

通常、モジュールオブジェクトは拡張モジュール (初期化関数をエクスポートし
ている共有ライブラリ) または組み込まれたモジュール (*note
PyImport_AppendInittab(): 170e. を使って初期化関数が追加されているモジュ
ール) から作られます。 詳細については *note C および C++ 拡張のビルド:
4753. または *note 埋め込まれた Python の拡張: 47c0. を見てください。

初期化関数は、モジュール定義のインスタンスを *note PyModule_Create():
4750. に渡して出来上がったモジュールオブジェクトを返してもよいですし、も
しくは定義構造体そのものを返し"多段階初期化"を要求しても構いません。

 -- C のデータ型: type PyModuleDef
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'  モ
     ジュール定義構造体はモジュールオブジェクトを生成するのに必要なすべ
     ての情報を保持します。 通常は、それぞれのモジュールごとに静的に初期
     化されたこの型の変数が1つだけ存在します。

      -- C のメンバ変数: PyModuleDef_Base m_base

          このメンバーは常に ‘PyModuleDef_HEAD_INIT’ で初期化してくださ
          い。

      -- C のメンバ変数: const char *m_name

          新しいモジュールの名前。

      -- C のメンバ変数: const char *m_doc

          モジュールの docstring。たいてい docstring は *note
          PyDoc_STRVAR: 18dd. を利用して生成されます。

      -- C のメンバ変数: *note Py_ssize_t: a2e. m_size

          モジュールの状態は、静的なグローバルな領域ではなく *note
          PyModule_GetState(): 94e. で取得できるモジュールごとのメモリ領
          域に保持されていることがあります。 これによってモジュールは複
          数のサブ・インタプリターで安全に使えます。

          このメモリ領域は 'm_size' に基づいてモジュール作成時に確保され
          、モジュールオブジェクトが破棄されるときに、 *note m_free:
          94a. 関数があればそれが呼ばれた後で解放されます。

          ‘m_size’ に ‘-1’ を設定すると、そのモジュールはグローバルな状
          態を持つためにサブ・インタープリターをサポートしていないという
          ことになります。

          ‘m_size’ を非負の値に設定すると、モジュールは再初期化でき、そ
          の状態のために必要となる追加のメモリ量を指定できるということに
          なります。 非負の ‘m_size’ は多段階初期化で必要になります。

          詳細は PEP 3121(1) を参照。

      -- C のメンバ変数: *note PyMethodDef: 1480. *m_methods

          *note PyMethodDef: 1480. で定義される、モジュールレベル関数の
          テーブルへのポインター。関数が存在しない場合は ‘NULL’ を設定す
          ることが可能。

      -- C のメンバ変数: *note PyModuleDef_Slot: 4b3a. *m_slots

          多段階初期化のためのスロット定義の配列で、 ‘{0, NULL}’ 要素が
          終端となります。 一段階初期化を使うときは、 'm_slots' は
          ‘NULL’ でなければなりません。

          バージョン 3.5 で変更: バージョン 3.5 より前は、このメンバは常
          に ‘NULL’ に設定されていて、次のものとして定義されていました:

                -- C のメンバ変数: *note inquiry: 4943. m_reload

      -- C のメンバ変数: *note traverseproc: 4952. m_traverse

          GC走査がモジュールオブジェクトを走査する際に呼び出される走査関
          数。必要ない場合は ‘NULL’.

          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 before the module is executed (*note
          Py_mod_exec: 94c. function).  More precisely, this function is
          not called if *note m_size: 94d. is greater than 0 and the
          module state (as returned by *note PyModule_GetState(): 94e.)
          is ‘NULL’.

          バージョン 3.9 で変更: No longer called before the module
          state is allocated.

      -- C のメンバ変数: *note inquiry: 4943. m_clear

          GCがこのモジュールオブジェクトをクリアーする時に呼び出されるク
          リアー関数。必要ない場合は、‘NULL’.

          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 before the module is executed (*note
          Py_mod_exec: 94c. function).  More precisely, this function is
          not called if *note m_size: 94d. is greater than 0 and the
          module state (as returned by *note PyModule_GetState(): 94e.)
          is ‘NULL’.

          Like *note PyTypeObject.tp_clear: 478d, this function is not
          'always' called before a module is deallocated.  For example,
          when reference counting is enough to determine that an object
          is no longer used, the cyclic garbage collector is not
          involved and *note m_free: 94a. is called directly.

          バージョン 3.9 で変更: No longer called before the module
          state is allocated.

      -- C のメンバ変数: *note freefunc: 4b3c. m_free

          GCがこのモジュールオブジェクトを解放するときに呼び出される関数
          。必要ない場合は ‘NULL’.

          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 before the module is executed (*note
          Py_mod_exec: 94c. function).  More precisely, this function is
          not called if *note m_size: 94d. is greater than 0 and the
          module state (as returned by *note PyModule_GetState(): 94e.)
          is ‘NULL’.

          バージョン 3.9 で変更: No longer called before the module
          state is allocated.

* Menu:

* 一段階初期化::
* 多段階初期化::
* 低水準モジュール作成関数::
* サポート関数::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3121/


File: python.info,  Node: 一段階初期化,  Next: 多段階初期化,  Up: Cモジュールの初期化

7.8.6.4 一段階初期化
....................

モジュールの初期化関数が直接モジュールオブジェクトを生成して返す場合があ
ります。 これは"一段階初期化"と呼ばれ、次の2つのモジュール生成関数のどち
らか1つを使います:

 -- C の関数: *note PyObject: 312. *PyModule_Create (PyModuleDef *def)
     '戻り値: 新しい参照。' Create a new module object, given the
     definition in 'def'.  This behaves like *note PyModule_Create2():
     487e. with 'module_api_version' set to ‘PYTHON_API_VERSION’.

 -- C の関数: *note PyObject: 312. *PyModule_Create2 (PyModuleDef *def,
          int module_api_version)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  APIバ
     ージョンを 'module_api_version' として 'def' での定義に従って新しい
     モジュールオブジェクトを生成します。 もし指定されたバージョンが実行
     しているインタープリターのバージョンと異なる場合は、 *note
     RuntimeWarning: 1a2. を発生させます。

     Return ‘NULL’ with an exception set on error.

          注釈: ほとんどの場合、この関数ではなく *note
          PyModule_Create(): 4750. を利用するべきです。この関数は、この
          関数の必要性を理解しているときにだけ利用してください。

モジュールオブジェクトが初期化関数から返される前に、たいていは *note
PyModule_AddObjectRef(): 33e. などの関数を使ってモジュールオブジェクトに
メンバを所属させます。


File: python.info,  Node: 多段階初期化,  Next: 低水準モジュール作成関数,  Prev: 一段階初期化,  Up: Cモジュールの初期化

7.8.6.5 多段階初期化
....................

An alternate way to specify extensions is to request "multi-phase
initialization".  Extension modules created this way behave more like
Python modules: the initialization is split between the 'creation
phase', when the module object is created, and the 'execution phase',
when it is populated.  The distinction is similar to the ‘__new__()’ and
‘__init__()’ methods of classes.

Unlike modules created using single-phase initialization, these modules
are not singletons: if the 'sys.modules' entry is removed and the module
is re-imported, a new module object is created, and the old module is
subject to normal garbage collection - as with Python modules.  By
default, multiple modules created from the same definition should be
independent: changes to one should not affect the others.  This means
that all state should be specific to the module object (using e.g.
using *note PyModule_GetState(): 94e.), or its contents (such as the
module's *note __dict__: 526. or individual classes created with *note
PyType_FromSpec(): 549.).

多段階初期化を使って生成される全てのモジュールは *note
サブ・インタプリター: 553. をサポートすることが求められます。 複数のモジ
ュールが独立していることを保証するのには、たいていはこのサポートをするだ
けで十分です。

多段階初期化を要求するために、初期化関数 (PyInit_modulename) は空でない
*note m_slots: 4b39. を持つ *note PyModuleDef: 94b. を返します。 これを
返す前に、 ‘PyModuleDef’ インスタンスは次の関数で初期化されなくてはいけ
ません:

 -- C の関数: *note PyObject: 312. *PyModuleDef_Init (PyModuleDef *def)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e. (バージ
     ョン 3.5 より).'  モジュール定義が型と参照カウントを正しく報告する
     、適切に初期化された Python オブジェクトであること保証します。

     ‘PyObject*’ にキャストされた 'def' を返します。エラーが発生した場合
     ‘NULL’ を返します。

     Added in version 3.5.

モジュール定義の 'm_slots' メンバは ‘PyModuleDef_Slot’ 構造体の配列を指
さなければなりません:

 -- C のデータ型: type PyModuleDef_Slot

      -- C のメンバ変数: int slot

          スロット ID で、以下で説明されている利用可能な値から選ばれます
          。

      -- C のメンバ変数: void *value

          スロットの値で、意味はスロット ID に依存します。

     Added in version 3.5.

'm_slots' 配列はID 0 のスロットで終端されていなければなりません。

利用可能なスロットの型は以下です:

 -- C のマクロ: Py_mod_create

     モジュールオブジェクト自身を生成するために呼ばれる関数を指定します
     。 このスロットの 'value' ポインタは次のシグネチャを持つ関数を指し
     ていなくてはいけません:

      -- C の関数: *note PyObject: 312. *create_module (PyObject *spec,
               PyModuleDef *def)

     PEP 451(1) で定義された *note ModuleSpec: 1dcb. インスタンスと、モ
     ジュール定義を受け取る関数です。 これは新しいモジュールオブジェクト
     を返すか、エラーを設定して ‘NULL’ を返すべきです。

     この関数は最小限に留めておくべきです。 特に任意のPythonコードを呼び
     出すべきではなく、同じモジュールをインポートしようとすると無限ルー
     プに陥るでしょう。

     複数の ‘Py_mod_create’ スロットを1つのモジュール定義に設定しない方
     がよいです。

     ‘Py_mod_create’ が設定されていない場合は、インポート機構は *note
     PyModule_New(): 4883. を使って通常のモジュールオブジェクトを生成し
     ます。 モジュールの名前は定義ではなく 'spec' から取得され、これによ
     って拡張モジュールが動的にモジュール階層における位置を調整できたり
     、シンボリックリンクを通して同一のモジュール定義を共有しつつ別の名
     前でインポートできたりします。

     返されるオブジェクトが *note PyModule_Type: 4886. のインスタンスで
     ある必要はありません。 インポートに関連する属性の設定と取得ができる
     限りは、どんな型でも使えます。 しかし、 ‘PyModuleDef’ が ‘NULL’ で
     ない ‘m_traverse’, ‘m_clear’, ‘m_free’ 、もしくはゼロでない
     ‘m_size’ 、もしくは ‘Py_mod_create’ 以外のスロットを持つ場合は、
     ‘PyModule_Type’ インスタンスのみが返されるでしょう。

 -- C のマクロ: Py_mod_exec

     モジュールを '実行する' ときに呼ばれる関数を指定します。 これは
     Pythonモジュールのコードを実行するのと同等です: この関数はたいてい
     はクラスと定数をモジュールにします。 この関数のシグネチャは以下です
     :

      -- C の関数: int exec_module (PyObject *module)

     複数の ‘Py_mod_exec’ スロットが設定されていた場合は、 'm_slots' 配
     列に現れた順に処理されていきます。

 -- C のマクロ: Py_mod_multiple_interpreters

     Specifies one of the following values:

      -- C のマクロ: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED

          The module does not support being imported in subinterpreters.

      -- C のマクロ: Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED

          The module supports being imported in subinterpreters, but
          only when they share the main interpreter's GIL. (See *note
          拡張モジュールを分離する: 4b47.)

      -- C のマクロ: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

          The module supports being imported in subinterpreters, even
          when they have their own GIL. (See *note
          拡張モジュールを分離する: 4b47.)

     This slot determines whether or not importing this module in a
     subinterpreter will fail.

     Multiple ‘Py_mod_multiple_interpreters’ slots may not be specified
     in one module definition.

     If ‘Py_mod_multiple_interpreters’ is not specified, the import
     machinery defaults to ‘Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED’.

     Added in version 3.12.

 -- C のマクロ: Py_mod_gil

     Specifies one of the following values:

      -- C のマクロ: Py_MOD_GIL_USED

          The module depends on the presence of the global interpreter
          lock (GIL), and may access global state without
          synchronization.

      -- C のマクロ: Py_MOD_GIL_NOT_USED

          The module is safe to run without an active GIL.

     This slot is ignored by Python builds not configured with *note
     -disable-gil: 15a.  Otherwise, it determines whether or not
     importing this module will cause the GIL to be automatically
     enabled.  See *note Free-threaded CPython: 125. for more detail.

     Multiple ‘Py_mod_gil’ slots may not be specified in one module
     definition.

     If ‘Py_mod_gil’ is not specified, the import machinery defaults to
     ‘Py_MOD_GIL_USED’.

     Added in version 3.13.

多段階初期化についてより詳しくは PEP 489(2) を見てください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0451/

   (2) https://peps.python.org/pep-0489/


File: python.info,  Node: 低水準モジュール作成関数,  Next: サポート関数,  Prev: 多段階初期化,  Up: Cモジュールの初期化

7.8.6.6 低水準モジュール作成関数
................................

以下の関数は、多段階初期化を使うときに裏側で呼び出されます。 例えばモジ
ュールオブジェクトを動的に生成するときに、これらの関数を直接使えます。
‘PyModule_FromDefAndSpec’ および ‘PyModule_ExecDef’ のどちらも、呼び出し
た後にはモジュールが完全に初期化されていなければなりません。

 -- C の関数: *note PyObject: 312. *PyModule_FromDefAndSpec (PyModuleDef
          *def, PyObject *spec)
     '戻り値: 新しい参照。' Create a new module object, given the
     definition in 'def' and the ModuleSpec 'spec'.  This behaves like
     *note PyModule_FromDefAndSpec2(): e7c. with 'module_api_version'
     set to ‘PYTHON_API_VERSION’.

     Added in version 3.5.

 -- C の関数: *note PyObject: 312. *PyModule_FromDefAndSpec2
          (PyModuleDef *def, PyObject *spec, int module_api_version)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  APIバージョンを 'module_api_version' として、
     'def' と ModuleSpec オブジェクトの 'spec' で定義されたとおりに新し
     いモジュールオブジェクトを生成します。 もし指定されたバージョンが実
     行しているインタープリターのバージョンと異なる場合は、 *note
     RuntimeWarning: 1a2. を発生させます。

     Return ‘NULL’ with an exception set on error.

          注釈: ほとんどの場合、この関数ではなく *note
          PyModule_FromDefAndSpec(): e7b. を利用するべきです。 この関数
          は、この関数の必要性を理解しているときにだけ利用してください。

     Added in version 3.5.

 -- C の関数: int PyModule_ExecDef (PyObject *module, PyModuleDef *def)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     'def' で与えられた任意の実行スロット (*note Py_mod_exec: 94c.) を実
     行します。

     Added in version 3.5.

 -- C の関数: int PyModule_SetDocString (PyObject *module, const char
          *docstring)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     'module' の docstring を 'docstring' に設定します。 この関数は、
     ‘PyModuleDef’ から ‘PyModule_Create’ もしくは
     ‘PyModule_FromDefAndSpec’ を使ってモジュールを生成するときに自動的
     に呼び出されます。

     Added in version 3.5.

 -- C の関数: int PyModule_AddFunctions (PyObject *module, PyMethodDef
          *functions)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  終
     端が ‘NULL’ になっている 'functions' 配列にある関数を 'module' に追
     加します。 *note PyMethodDef: 1480. 構造体の個々のエントリについて
     は PyMethodDef の説明を参照してください (モジュールの名前空間が共有
     されていないので、 C で実装されたモジュールレベル "関数" はたいてい
     モジュールを1つ目の引数として受け取り、 Python クラスのインスタンス
     メソッドに似た形にします)。 この関数は、 ‘PyModuleDef’ から
     ‘PyModule_Create’ もしくは ‘PyModule_FromDefAndSpec’ を使ってモジュ
     ールを生成するときに自動的に呼び出されます。

     Added in version 3.5.


File: python.info,  Node: サポート関数,  Prev: 低水準モジュール作成関数,  Up: Cモジュールの初期化

7.8.6.7 サポート関数
....................

モジュールの初期化関数 (一段階初期化を使う場合) 、あるいはモジュールの実
行スロットから呼び出される関数 (多段階初期化を使う場合) は次の関数を使う
と、モジュールの state の初期化を簡単にできます:

 -- C の関数: int PyModule_AddObjectRef (PyObject *module, const char
          *name, PyObject *value)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     'module' にオブジェクトを 'name' として追加します。 この関数はモジ
     ュールの初期化関数から利用される便利関数です。

     成功すると ‘0’ を返し、エラーになると例外を送出して ‘-1’ を返します
     。

     Return ‘-1’ if 'value' is ‘NULL’.  It must be called with an
     exception raised in this case.

     使用例:

          static int
          add_spam(PyObject *module, int value)
          {
              PyObject *obj = PyLong_FromLong(value);
              if (obj == NULL) {
                  return -1;
              }
              int res = PyModule_AddObjectRef(module, "spam", obj);
              Py_DECREF(obj);
              return res;
           }

     この例は、明示的に 'obj' が ‘NULL’ であることを確認せずに書くことも
     できます:

          static int
          add_spam(PyObject *module, int value)
          {
              PyObject *obj = PyLong_FromLong(value);
              int res = PyModule_AddObjectRef(module, "spam", obj);
              Py_XDECREF(obj);
              return res;
           }

     この場合は、 'obj' が ‘NULL’ でありうるため、 ‘Py_DECREF()’ の代わ
     りに ‘Py_XDECREF()’ を呼び出す必要があることに注意してください。

     The number of different 'name' strings passed to this function
     should be kept small, usually by only using statically allocated
     strings as 'name'.  For names that aren't known at compile time,
     prefer calling *note PyUnicode_FromString(): 47be. and *note
     PyObject_SetAttr(): 48b8. directly.  For more details, see *note
     PyUnicode_InternFromString(): 1562, which may be used internally to
     create a key object.

     Added in version 3.10.

 -- C の関数: int PyModule_Add (PyObject *module, const char *name,
          PyObject *value)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Similar to *note PyModule_AddObjectRef(): 33e, but "steals" a
     reference to 'value'.  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.

     使用例:

          if (PyModule_Add(module, "spam", PyBytes_FromString(value)) < 0) {
              goto error;
          }

     Added in version 3.13.

 -- C の関数: int PyModule_AddObject (PyObject *module, const char
          *name, PyObject *value)
     ' 次に属します: *note Stable ABI: 51e.'  Similar to *note
     PyModule_AddObjectRef(): 33e, but steals a reference to 'value' on
     success (if it returns ‘0’).

     The new *note PyModule_Add(): 33d. or *note
     PyModule_AddObjectRef(): 33e. functions are recommended, since it
     is easy to introduce reference leaks by misusing the *note
     PyModule_AddObject(): 33f. function.

          注釈: Unlike other functions that steal references,
          ‘PyModule_AddObject()’ only releases the reference to 'value'
          'on success'.

          This means that its return value must be checked, and calling
          code must *note Py_XDECREF(): 75a. 'value' manually on error.

     使用例:

          PyObject *obj = PyBytes_FromString(value);
          if (PyModule_AddObject(module, "spam", obj) < 0) {
              // If 'obj' is not NULL and PyModule_AddObject() failed,
              // 'obj' strong reference must be deleted with Py_XDECREF().
              // If 'obj' is NULL, Py_XDECREF() does nothing.
              Py_XDECREF(obj);
              goto error;
          }
          // PyModule_AddObject() stole a reference to obj:
          // Py_XDECREF(obj) is not needed here.

     バージョン 3.13 で非推奨: *note PyModule_AddObject(): 33f. is *note
     soft deprecated: 1ea.

 -- C の関数: int PyModule_AddIntConstant (PyObject *module, const char
          *name, long value)
     ' 次に属します: *note Stable ABI: 51e.'  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.

     This is a convenience function that calls *note PyLong_FromLong():
     17a4. and *note PyModule_AddObjectRef(): 33e.; see their
     documentation for details.

 -- C の関数: int PyModule_AddStringConstant (PyObject *module, const
          char *name, const char *value)
     ' 次に属します: *note Stable ABI: 51e.'  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.

     This is a convenience function that calls *note
     PyUnicode_InternFromString(): 1562. and *note
     PyModule_AddObjectRef(): 33e.; see their documentation for details.

 -- C のマクロ: PyModule_AddIntMacro (module, macro)

     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.

 -- C のマクロ: PyModule_AddStringMacro (module, macro)

     文字列定数を 'module' に追加します。

 -- C の関数: int PyModule_AddType (PyObject *module, PyTypeObject
          *type)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Add a type object to 'module'.  The type object is finalized by
     calling internally *note PyType_Ready(): 747.  The name of the type
     object is taken from the last component of *note tp_name: 185d.
     after dot.  Return ‘-1’ with an exception set on error, ‘0’ on
     success.

     Added in version 3.9.

 -- C の関数: int PyUnstable_Module_SetGIL (PyObject *module, void *gil)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Indicate that 'module' does or does not support running without the
     global interpreter lock (GIL), using one of the values from *note
     Py_mod_gil: 13e.  It must be called during 'module"s initialization
     function.  If this function is not called during module
     initialization, the import machinery assumes the module does not
     support running without the GIL. This function is only available in
     Python builds configured with *note -disable-gil: 15a.  Return ‘-1’
     with an exception set on error, ‘0’ on success.

     Added in version 3.13.


File: python.info,  Node: モジュール検索,  Prev: Cモジュールの初期化,  Up: モジュールオブジェクト module object

7.8.6.8 モジュール検索
......................

一段階初期化は、現在のインタプリタのコンテキストから探せるシングルトンの
モジュールを生成します。 これによって、後からモジュール定義への参照だけ
でモジュールオブジェクトが取得できます。

多段階初期化を使うと単一の定義から複数のモジュールが作成できるので、これ
らの関数は多段階初期化を使って作成されたモジュールには使えません。

 -- C の関数: *note PyObject: 312. *PyState_FindModule (PyModuleDef
          *def)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  現在の
     インタプリタの 'def' から作られたモジュールオブジェクトを返します。
     このメソッドの前提条件として、前もって *note PyState_AddModule():
     48d3. でインタプリタの state にモジュールオブジェクトを連結しておく
     ことを要求します。対応するモジュールオブジェクトが見付からない、も
     しくは事前にインタプリタの state に連結されていない場合は、 ‘NULL’
     を返します。

 -- C の関数: int PyState_AddModule (PyObject *module, PyModuleDef *def)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.3 より).'  関
     数に渡されたモジュールオブジェクトを、インタプリタの state に連結し
     ます。この関数を使うことで *note PyState_FindModule(): 48d4. からモ
     ジュールオブジェクトにアクセスできるようになります。

     一段階初期化を使って作成されたモジュールにのみ有効です。

     Python calls ‘PyState_AddModule’ automatically after importing a
     module, so it is unnecessary (but harmless) to call it from module
     initialization code.  An explicit call is needed only if the
     module's own init code subsequently calls ‘PyState_FindModule’.
     The function is mainly intended for implementing alternative import
     mechanisms (either by calling it directly, or by referring to its
     implementation for details of the required state updates).

     呼び出し側はGILを獲得しなければなりません。

     Return ‘-1’ with an exception set on error, ‘0’ on success.

     Added in version 3.3.

 -- C の関数: int PyState_RemoveModule (PyModuleDef *def)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.3 より).'
     Removes the module object created from 'def' from the interpreter
     state.  Return ‘-1’ with an exception set on error, ‘0’ on success.

     呼び出し側はGILを獲得しなければなりません。

     Added in version 3.3.


File: python.info,  Node: イテレータオブジェクト iterator object,  Next: デスクリプタオブジェクト descriptor object,  Prev: モジュールオブジェクト module object,  Up: その他のオブジェクト<2>

7.8.6.9 イテレータオブジェクト (iterator object)
................................................

Python では二種類のイテレータオブジェクトを提供しています。一つ目はシー
ケンスイテレータで、 *note __getitem__(): 264. メソッドをサポートする任
意のシーケンスを取り扱います。二つ目は呼び出し可能オブジェクトと番兵
(sentinel value) を扱い、シーケンス内の要素ごとに呼び出し可能オブジェク
トを呼び出して、センチネル値が返されたときに反復処理を終了します。

 -- C 変数: *note PyTypeObject: a73. PySeqIter_Type
     ' 次に属します: *note Stable ABI: 51e.'  *note PySeqIter_New():
     48bc. や、組み込みシーケンス型に対して 1 引数形式の組み込み関数
     *note iter(): 7a2. を呼び出したときに返される、イテレータオブジェク
     トの型オブジェクトです。

 -- C の関数: int PySeqIter_Check (PyObject *op)

     'op' の型が ‘PySeqlter_Type’ 型の場合に真を返します。この関数は常に
     成功します。

 -- C の関数: *note PyObject: 312. *PySeqIter_New (PyObject *seq)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  一般
     的なシーケンスオブジェクト 'seq' を扱うイテレータを返します。反復処
     理は、シーケンスが添字指定操作の際に *note IndexError: 14de. を返し
     たときに終了します。

 -- C 変数: *note PyTypeObject: a73. PyCallIter_Type
     ' 次に属します: *note Stable ABI: 51e.'  *note PyCallIter_New():
     4808. や、組み込み関数 *note iter(): 7a2. の 2 引数形式が返すイテレ
     ータオブジェクトの型オブジェクトです。

 -- C の関数: int PyCallIter_Check (PyObject *op)

     'op' の型が *note PyCallIter_Type: 4809. 型の場合に真を返します。こ
     の関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyCallIter_New (PyObject *callable,
          PyObject *sentinel)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  新た
     なイテレータを返します。最初のパラメタ 'callable' は引数なしで呼び
     出せる Python の呼び出し可能オブジェクトならなんでもかまいません;
     'callable' は、呼び出されるたびに次の反復処理対象オブジェクトを返さ
     なければなりません。生成されたイテレータは、'callable' が
     'sentinel' に等しい値を返すと反復処理を終了します。


File: python.info,  Node: デスクリプタオブジェクト descriptor object,  Next: スライスオブジェクト slice object,  Prev: イテレータオブジェクト iterator object,  Up: その他のオブジェクト<2>

7.8.6.10 デスクリプタオブジェクト (descriptor object)
.....................................................

"デスクリプタ (descriptor)" は、あるオブジェクトのいくつかの属性について
記述したオブジェクトです。デスクリプタオブジェクトは型オブジェクトの辞書
内にあります。

 -- C 変数: *note PyTypeObject: a73. PyProperty_Type
     ' 次に属します: *note Stable ABI: 51e.'  組み込みデスクリプタ型の型
     オブジェクトです。

 -- C の関数: *note PyObject: 312. *PyDescr_NewGetSet (PyTypeObject
          *type, struct PyGetSetDef *getset)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: *note PyObject: 312. *PyDescr_NewMember (PyTypeObject
          *type, struct PyMemberDef *meth)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: *note PyObject: 312. *PyDescr_NewMethod (PyTypeObject
          *type, struct PyMethodDef *meth)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: *note PyObject: 312. *PyDescr_NewWrapper (PyTypeObject
          *type, struct wrapperbase *wrapper, void *wrapped)
     '戻り値: 新しい参照。'

 -- C の関数: *note PyObject: 312. *PyDescr_NewClassMethod (PyTypeObject
          *type, PyMethodDef *method)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: int PyDescr_IsData (PyObject *descr)

     デスクリプタオブジェクト 'descr' がデータ属性のデスクリプタの場合に
     は非ゼロ値を、メソッドデスクリプタの場合には ‘0’ を返します。
     'descr' はデスクリプタオブジェクトでなければなりません。エラーチェ
     ックは行いません。

 -- C の関数: *note PyObject: 312. *PyWrapper_New (PyObject*, PyObject*)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'


File: python.info,  Node: スライスオブジェクト slice object,  Next: memoryview オブジェクト,  Prev: デスクリプタオブジェクト descriptor object,  Up: その他のオブジェクト<2>

7.8.6.11 スライスオブジェクト (slice object)
............................................

 -- C 変数: *note PyTypeObject: a73. PySlice_Type
     ' 次に属します: *note Stable ABI: 51e.'  スライスオブジェクトの型オ
     ブジェクトです。これは、Pythonレイヤにおける *note slice: 436. と同
     じオブジェクトです。

 -- C の関数: int PySlice_Check (PyObject *ob)

     'ob' がスライスオブジェクトの場合に真を返します; 'ob' は ‘NULL’ で
     あってはなりません。この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PySlice_New (PyObject *start,
          PyObject *stop, PyObject *step)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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.

     Return ‘NULL’ with an exception set if the new object could not be
     allocated.

 -- C の関数: int PySlice_GetIndices (PyObject *slice, Py_ssize_t
          length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
     ' 次に属します: *note Stable ABI: 51e.'  スライスオブジェクト
     'slice' における 'start', 'stop', および 'step' のインデクス値を取
     得します。このときシーケンスの長さを 'length' と仮定します。
     'length' よりも大きなインデクスになるとエラーとして扱います。

     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).

     おそらく、あなたはこの関数を使いたくないでしょう。

     バージョン 3.2 で変更: 以前は、'slice' 引数の型は ‘PySliceObject*’
     でした。

 -- C の関数: int PySlice_GetIndicesEx (PyObject *slice, Py_ssize_t
          length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
          Py_ssize_t *slicelength)
     ' 次に属します: *note Stable ABI: 51e.'  *note
     PySlice_GetIndices(): 48d0. の便利な代替です。 'slice' における、
     'start', 'stop' および 'step' のインデクス値を取得をします。シーケ
     ンスの長さを 'length' 、スライスの長さを 'slicelength' に格納します
     。境界外のインデクスは通常のスライスと一貫した方法でクリップされま
     す。

     Return ‘0’ on success and ‘-1’ on error with an exception set.

          注釈: This function is considered not safe for resizable
          sequences.  Its invocation should be replaced by a combination
          of *note PySlice_Unpack(): 3d6. and *note
          PySlice_AdjustIndices(): 3d7. where

               if (PySlice_GetIndicesEx(slice, length, &start, &stop, &step, &slicelength) < 0) {
                   // return error
               }

          is replaced by

               if (PySlice_Unpack(slice, &start, &stop, &step) < 0) {
                   // return error
               }
               slicelength = PySlice_AdjustIndices(length, &start, &stop, step);

     バージョン 3.2 で変更: 以前は、'slice' 引数の型は ‘PySliceObject*’
     でした。

     バージョン 3.6.1 で変更: If ‘Py_LIMITED_API’ is not set or set to
     the value between ‘0x03050400’ and ‘0x03060000’ (not including) or
     ‘0x03060100’ or higher ‘PySlice_GetIndicesEx()’ is implemented as a
     macro using ‘PySlice_Unpack()’ and ‘PySlice_AdjustIndices()’.
     Arguments 'start', 'stop' and 'step' are evaluated more than once.

     バージョン 3.6.1 で非推奨: If ‘Py_LIMITED_API’ is set to the value
     less than ‘0x03050400’ or between ‘0x03060000’ and ‘0x03060100’
     (not including) ‘PySlice_GetIndicesEx()’ is a deprecated function.

 -- C の関数: int PySlice_Unpack (PyObject *slice, Py_ssize_t *start,
          Py_ssize_t *stop, Py_ssize_t *step)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     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 ‘PY_SSIZE_T_MAX’, silently boost the start and stop values less
     than ‘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’.

     Return ‘-1’ with an exception set on error, ‘0’ on success.

     Added in version 3.6.1.

 -- C の関数: *note Py_ssize_t: a2e. PySlice_AdjustIndices (Py_ssize_t
          length, Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t step)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     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.

     Return the length of the slice.  Always successful.  Doesn't call
     Python code.

     Added in version 3.6.1.

* Menu:

* Ellipsis オブジェクト: Ellipsis オブジェクト<2>.


File: python.info,  Node: Ellipsis オブジェクト<2>,  Up: スライスオブジェクト slice object

7.8.6.12 Ellipsis オブジェクト
..............................

 -- C 変数: *note PyObject: 312. *Py_Ellipsis

     The Python ‘Ellipsis’ object.  This object has no methods.  Like
     *note Py_None: 474c, it is an *note immortal: 41f8. singleton
     object.

     バージョン 3.12 で変更: *note Py_Ellipsis: 4b5c. is immortal.


File: python.info,  Node: memoryview オブジェクト,  Next: 弱参照オブジェクト<2>,  Prev: スライスオブジェクト slice object,  Up: その他のオブジェクト<2>

7.8.6.13 memoryview オブジェクト
................................

*note memoryview: 435. オブジェクトは、他のオブジェクトと同じように扱え
る Python オブジェクトの形をした C 言語レベルの *note
バッファのインターフェース: 371. です。

 -- C の関数: *note PyObject: 312. *PyMemoryView_FromObject (PyObject
          *obj)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'  バッ
     ファインターフェースを提供するオブジェクトからmemoryview オブジェク
     トを生成します。もし 'obj' が書き込み可能なバッファのエクスポートを
     サポートするなら、その memoryview オブジェクトは読み書き可能です。
     そうでなければ読出しのみになるか、エクスポーターの分別にもとづいて
     読み書きが可能となります。

 -- C のマクロ: PyBUF_READ

     Flag to request a readonly buffer.

 -- C のマクロ: PyBUF_WRITE

     Flag to request a writable buffer.

 -- C の関数: *note PyObject: 312. *PyMemoryView_FromMemory (char *mem,
          Py_ssize_t size, int flags)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.7 より).'  'mem' を配下のバッファとしてmemoryview オブジェ
     クトを作成します。 'flags' は *note PyBUF_READ: 15f4. か *note
     PyBUF_WRITE: 15f5. のどちらかになります。

     Added in version 3.3.

 -- C の関数: *note PyObject: 312. *PyMemoryView_FromBuffer (const
          Py_buffer *view)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.11 より).'  'view' として与えられたバッファ構造をラップす
     る memoryview オブジェクトを作成します。単なるバイトバッファ向けに
     は、 *note PyMemoryView_FromMemory(): 1143. のほうが望ましいです。

 -- C の関数: *note PyObject: 312. *PyMemoryView_GetContiguous (PyObject
          *obj, int buffertype, char order)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     buffer インターフェースを定義しているオブジェクトから ('C' か
     'F'ortran の 'order' で) *note 連続した: 1016. メモリチャンクへの
     memoryview オブジェクトを作ります。メモリが連続している場合、
     memoryview オブジェクトは元のメモリを参照します。それ以外の場合、メ
     モリはコピーされて、 memoryview オブジェクトは新しい bytes オブジェ
     クトを参照します。

     'buffertype' can be one of *note PyBUF_READ: 15f4. or *note
     PyBUF_WRITE: 15f5.

 -- C の関数: int PyMemoryView_Check (PyObject *obj)

     'obj' が memoryview オブジェクトの場合に真を返します。現在のところ
     、 *note memoryview: 435. のサブクラスの作成は許可されていません。
     この関数は常に成功します。

 -- C の関数: *note Py_buffer: 723. *PyMemoryView_GET_BUFFER (PyObject
          *mview)

     書きだされたバッファーの memoryview のプライベート コピーに、ポイン
     ターを返します。 'mview' は memoryview インスタンスでなければなりま
     せん; このマクロは型をチェックしないので自前で型チェックしなければ
     ならず、それを怠るとクラッシュする恐れがあります。

 -- C の関数: *note PyObject: 312. *PyMemoryView_GET_BASE (PyObject
          *mview)

     memoryview をエクスポートしているオブジェクトへのポインタを返します
     。 memoryview が *note PyMemoryView_FromMemory(): 1143. か *note
     PyMemoryView_FromBuffer(): 72c. のどちらかで作成されていた場合、
     ‘NULL’ を返します。


File: python.info,  Node: 弱参照オブジェクト<2>,  Next: カプセル<2>,  Prev: memoryview オブジェクト,  Up: その他のオブジェクト<2>

7.8.6.14 弱参照オブジェクト
...........................

Python は '弱参照' を第一級オブジェクト (first-class object) としてサポ
ートします。弱参照を直接実装する二種類の固有のオブジェクト型があります。
第一は単純な参照オブジェクトで、第二はオリジナルのオブジェクトに対して可
能な限りプロキシとして振舞うオブジェクトです。

 -- C の関数: int PyWeakref_Check (PyObject *ob)

     Return non-zero if 'ob' is either a reference or proxy object.
     This function always succeeds.

 -- C の関数: int PyWeakref_CheckRef (PyObject *ob)

     Return non-zero if 'ob' is a reference object.  This function
     always succeeds.

 -- C の関数: int PyWeakref_CheckProxy (PyObject *ob)

     Return non-zero if 'ob' is a proxy object.  This function always
     succeeds.

 -- C の関数: *note PyObject: 312. *PyWeakref_NewRef (PyObject *ob,
          PyObject *callback)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     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 reference object may be returned.  The
     second parameter, 'callback', can be a callable object that
     receives notification when 'ob' is garbage collected; it should
     accept a single parameter, which will be the weak reference object
     itself.  'callback' may also be ‘None’ or ‘NULL’.  If 'ob' is not a
     weakly referenceable object, or if 'callback' is not callable,
     ‘None’, or ‘NULL’, this will return ‘NULL’ and raise *note
     TypeError: 502.

 -- C の関数: *note PyObject: 312. *PyWeakref_NewProxy (PyObject *ob,
          PyObject *callback)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Return a weak reference proxy object for the object 'ob'.  This
     will always return a new reference, but is not guaranteed to create
     a new object; an existing proxy object may be returned.  The second
     parameter, 'callback', can be a callable object that receives
     notification when 'ob' is garbage collected; it should accept a
     single parameter, which will be the weak reference object itself.
     'callback' may also be ‘None’ or ‘NULL’.  If 'ob' is not a weakly
     referenceable object, or if 'callback' is not callable, ‘None’, or
     ‘NULL’, this will return ‘NULL’ and raise *note TypeError: 502.

 -- C の関数: int PyWeakref_GetRef (PyObject *ref, PyObject **pobj)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Get a *note strong reference: 316. to the referenced object from a
     weak reference, 'ref', into '*pobj'.

        * On success, set '*pobj' to a new *note strong reference: 316.
          to the referenced object and return 1.

        * If the reference is dead, set '*pobj' to ‘NULL’ and return 0.

        * On error, raise an exception and return -1.

     Added in version 3.13.

 -- C の関数: *note PyObject: 312. *PyWeakref_GetObject (PyObject *ref)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  Return
     a *note borrowed reference: 317. to the referenced object from a
     weak reference, 'ref'.  If the referent is no longer live, returns
     ‘Py_None’.

          注釈: This function returns a *note borrowed reference: 317.
          to the referenced object.  This means that you should always
          call *note Py_INCREF(): 53a. on the object except when it
          cannot be destroyed before the last usage of the borrowed
          reference.

     Deprecated since version 3.13, will be removed in version 3.15: Use
     *note PyWeakref_GetRef(): 351. instead.

 -- C の関数: *note PyObject: 312. *PyWeakref_GET_OBJECT (PyObject *ref)
     '戻り値: 借用参照。' Similar to *note PyWeakref_GetObject(): 352,
     but does no error checking.

     Deprecated since version 3.13, will be removed in version 3.15: Use
     *note PyWeakref_GetRef(): 351. instead.

 -- C の関数: void PyObject_ClearWeakRefs (PyObject *object)
     ' 次に属します: *note Stable ABI: 51e.'  This function is called by
     the *note tp_dealloc: 477a. handler to clear weak references.

     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.

 -- C の関数: void PyUnstable_Object_ClearWeakRefsNoCallbacks (PyObject
          *object)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Clears the weakrefs for 'object' without calling the callbacks.

     This function is called by the *note tp_dealloc: 477a. handler for
     types with finalizers (i.e., *note __del__(): 1ec1.).  The handler
     for those objects first calls *note PyObject_ClearWeakRefs(): 542.
     to clear weakrefs and call their callbacks, then the finalizer, and
     finally this function to clear any weakrefs that may have been
     created by the finalizer.

     In most circumstances, it's more appropriate to use *note
     PyObject_ClearWeakRefs(): 542. to clear weakrefs instead of this
     function.

     Added in version 3.13.


File: python.info,  Node: カプセル<2>,  Next: フレーム frame オブジェクト<2>,  Prev: 弱参照オブジェクト<2>,  Up: その他のオブジェクト<2>

7.8.6.15 カプセル
.................

‘using-capsules’ 以下のオブジェクトを使う方法については *note
拡張モジュールに C API を提供する: 1325. を参照してください。

Added in version 3.1.

 -- C のデータ型: type PyCapsule

     この *note PyObject: 312. のサブタイプは、任意の値を表し、C拡張モジ
     ュールから Pythonコードを経由して他のC言語のコードに任意の値を
     (void* ポインタの形で)渡す必要があるときに有用です。あるモジュール
     内で定義されているC言語関数のポインタを、他のモジュールに渡してそこ
     から呼び出せるようにするためによく使われます。これにより、動的にロ
     ードされるモジュールの中の C API に通常の import 機構を通してアクセ
     スすることができます。

 -- C のデータ型: type PyCapsule_Destructor
     ' 次に属します: *note Stable ABI: 51e.'  カプセルに対するデストラク
     タコールバック型.  次のように定義されます:

          typedef void (*PyCapsule_Destructor)(PyObject *);

     PyCapsule_Destructor コールバックの動作については *note
     PyCapsule_New(): 476f. を参照してください。

 -- C の関数: int PyCapsule_CheckExact (PyObject *p)

     引数が *note PyCapsule: 1244. の場合に真を返します。この関数は常に
     成功します。

 -- C の関数: *note PyObject: 312. *PyCapsule_New (void *pointer, const
          char *name, PyCapsule_Destructor destructor)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     'pointer' を格納する *note PyCapsule: 1244. を作成します。
     'pointer' 引数は ‘NULL’ であってはなりません。

     失敗した場合、例外を設定して ‘NULL’ を返します。

     'name' 文字列は ‘NULL’ か、有効なC文字列へのポインタです。‘NULL’ で
     無い場合、この文字列は少なくともカプセルより長く生存する必要があり
     ます。('destructor' の中で解放することは許可されています)

     'destructor' が ‘NULL’ で無い場合、カプセルが削除されるときにそのカ
     プセルを引数として呼び出されます。

     このカプセルがモジュールの属性として保存される場合、 'name' は
     ‘modulename.attributename’ と指定されるべきです。こうすると、他のモ
     ジュールがそのカプセルを *note PyCapsule_Import(): 17d8. でインポー
     トすることができます。

 -- C の関数: void *PyCapsule_GetPointer (PyObject *capsule, const char
          *name)
     ' 次に属します: *note Stable ABI: 51e.'  カプセルに保存されている
     'pointer' を取り出します。失敗した場合は例外を設定して ‘NULL’ を返
     します。

     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
     ‘strcmp()’ to compare capsule names.

 -- C の関数: *note PyCapsule_Destructor: 480b. PyCapsule_GetDestructor
          (PyObject *capsule)
     ' 次に属します: *note Stable ABI: 51e.'  カプセルに保存されている現
     在のデストラクタを返します。失敗した場合、例外を設定して ‘NULL’ を
     返します。

     カプセルは ‘NULL’ をデストラクタとして持つことができます。従って、
     戻り値の ‘NULL’ がエラーを指してない可能性があります。 *note
     PyCapsule_IsValid(): 1324. か *note PyErr_Occurred(): 185c. を利用
     して確認してください。

 -- C の関数: void *PyCapsule_GetContext (PyObject *capsule)
     ' 次に属します: *note Stable ABI: 51e.'  カプセルに保存されている現
     在のコンテキスト(context)を返します。失敗した場合、例外を設定して
     ‘NULL’ を返します。

     カプセルは ‘NULL’ をコンテキストとして持つことができます。従って、
     戻り値の ‘NULL’ がエラーを指してない可能性があります。 *note
     PyCapsule_IsValid(): 1324. か *note PyErr_Occurred(): 185c. を利用
     して確認してください。

 -- C の関数: const char *PyCapsule_GetName (PyObject *capsule)
     ' 次に属します: *note Stable ABI: 51e.'  カプセルに保存されている現
     在の name を返します。失敗した場合、例外を設定して ‘NULL’ を返しま
     す。

     カプセルは ‘NULL’ を name として持つことができます。従って、戻り値
     の ‘NULL’ がエラーを指してない可能性があります。 *note
     PyCapsule_IsValid(): 1324. か *note PyErr_Occurred(): 185c. を利用
     して確認してください。

 -- C の関数: void *PyCapsule_Import (const char *name, int no_block)
     ' 次に属します: *note Stable ABI: 51e.'  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.

     成功した場合、カプセルの内部 'ポインタ' を返します。失敗した場合、
     例外を設定して ‘NULL’ を返します。

     バージョン 3.3 で変更: 'no_block' has no effect anymore.

 -- C の関数: int PyCapsule_IsValid (PyObject *capsule, const char
          *name)
     ' 次に属します: *note Stable ABI: 51e.'  'capsule' が有効なカプセル
     であるかどうかをチェックします。有効な 'capsule' は、非 ‘NULL’ で、
     *note PyCapsule_CheckExact(): 4b6a. をパスし、非 ‘NULL’ なポインタ
     を格納していて、内部の name が引数 'name' とマッチします。 (name の
     比較方法については *note PyCapsule_GetPointer(): 480f. を参照)

     In other words, if *note PyCapsule_IsValid(): 1324. returns a true
     value, calls to any of the accessors (any function starting with
     ‘PyCapsule_Get’) are guaranteed to succeed.

     オブジェクトが有効で name がマッチした場合に非 ‘0’ を、それ以外の場
     合に ‘0’ を返します。この関数は絶対に失敗しません。

 -- C の関数: int PyCapsule_SetContext (PyObject *capsule, void
          *context)
     ' 次に属します: *note Stable ABI: 51e.'  'capsule' 内部のコンテキス
     トポインタを 'context' に設定します。

     成功したら ‘0’ を、失敗したら例外を設定して非 ‘0’ を返します。

 -- C の関数: int PyCapsule_SetDestructor (PyObject *capsule,
          PyCapsule_Destructor destructor)
     ' 次に属します: *note Stable ABI: 51e.'  'capsule' 内部のデストラク
     タを 'destructor' に設定します。

     成功したら ‘0’ を、失敗したら例外を設定して非 ‘0’ を返します。

 -- C の関数: int PyCapsule_SetName (PyObject *capsule, const char
          *name)
     ' 次に属します: *note Stable ABI: 51e.'  'capsule' 内部の name を
     'name' に設定します。'name' が非 ‘NULL’ のとき、それは 'capsule' よ
     りも長い寿命を持つ必要があります。もしすでに 'capsule' に非 ‘NULL’
     の 'name' が保存されていた場合、それに対する解放は行われません。

     成功したら ‘0’ を、失敗したら例外を設定して非 ‘0’ を返します。

 -- C の関数: int PyCapsule_SetPointer (PyObject *capsule, void
          *pointer)
     ' 次に属します: *note Stable ABI: 51e.'  'capsule' 内部のポインタを
     'pointer' に設定します。'pointer' は ‘NULL’ であってはなりません。

     成功したら ‘0’ を、失敗したら例外を設定して非 ‘0’ を返します。


File: python.info,  Node: フレーム frame オブジェクト<2>,  Next: ジェネレータオブジェクト,  Prev: カプセル<2>,  Up: その他のオブジェクト<2>

7.8.6.16 フレーム (frame) オブジェクト
......................................

 -- C のデータ型: type PyFrameObject
     ' 次に属します: *note Limited API: 51e. (不透明な構造体として).'  フ
     レームオブジェクトを記述する際に用いられる、オブジェクトを表す C 構
     造体です。

     There are no public members in this structure.

     バージョン 3.11 で変更: The members of this structure were removed
     from the public C API. Refer to the *note What's New entry: 753.
     for details.

The *note PyEval_GetFrame(): 1727. and *note PyThreadState_GetFrame():
759. functions can be used to get a frame object.

See also *note Reflection: 49bd.

 -- C 変数: *note PyTypeObject: a73. PyFrame_Type

     The type of frame objects.  It is the same object as *note
     types.FrameType: 17bc. in the Python layer.

     バージョン 3.11 で変更: Previously, this type was only available
     after including ‘<frameobject.h>’.

 -- C の関数: int PyFrame_Check (PyObject *obj)

     Return non-zero if 'obj' is a frame object.

     バージョン 3.11 で変更: Previously, this function was only
     available after including ‘<frameobject.h>’.

 -- C の関数: *note PyFrameObject: 754. *PyFrame_GetBack (PyFrameObject
          *frame)
     '戻り値: 新しい参照。' Get the 'frame' next outer frame.

     Return a *note strong reference: 316, or ‘NULL’ if 'frame' has no
     outer frame.

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyFrame_GetBuiltins (PyFrameObject
          *frame)
     '戻り値: 新しい参照。' Get the 'frame"s *note f_builtins: 1ead.
     attribute.

     Return a *note strong reference: 316.  The result cannot be ‘NULL’.

     Added in version 3.11.

 -- C の関数: *note PyCodeObject: 742. *PyFrame_GetCode (PyFrameObject
          *frame)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.10 より).'  Get the 'frame' code.

     Return a *note strong reference: 316.

     The result (frame code) cannot be ‘NULL’.

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyFrame_GetGenerator (PyFrameObject
          *frame)
     '戻り値: 新しい参照。' 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’.

     Return a *note strong reference: 316, or ‘NULL’.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyFrame_GetGlobals (PyFrameObject
          *frame)
     '戻り値: 新しい参照。' Get the 'frame"s *note f_globals: 1eac.
     attribute.

     Return a *note strong reference: 316.  The result cannot be ‘NULL’.

     Added in version 3.11.

 -- C の関数: int PyFrame_GetLasti (PyFrameObject *frame)

     Get the 'frame"s *note f_lasti: 855. attribute.

     Returns -1 if ‘frame.f_lasti’ is ‘None’.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyFrame_GetVar (PyFrameObject
          *frame, PyObject *name)
     '戻り値: 新しい参照。' Get the variable 'name' of 'frame'.

        * Return a *note strong reference: 316. to the variable value on
          success.

        * Raise *note NameError: 40b. and return ‘NULL’ if the variable
          does not exist.

        * Raise an exception and return ‘NULL’ on error.

     'name' type must be a *note str: 418.

     Added in version 3.12.

 -- C の関数: *note PyObject: 312. *PyFrame_GetVarString (PyFrameObject
          *frame, const char *name)
     '戻り値: 新しい参照。' Similar to *note PyFrame_GetVar(): 534, but
     the variable name is a C string encoded in UTF-8.

     Added in version 3.12.

 -- C の関数: *note PyObject: 312. *PyFrame_GetLocals (PyFrameObject
          *frame)
     '戻り値: 新しい参照。' Get the 'frame"s *note f_locals: 167.
     attribute.  If the frame refers to an *note optimized scope: 163,
     this returns a write-through proxy object that allows modifying the
     locals.  In all other cases (classes, modules, *note exec(): 164,
     *note eval(): 165.) it returns the mapping representing the frame
     locals directly (as described for *note locals(): 127.).

     Return a *note strong reference: 316.

     Added in version 3.11.

     バージョン 3.13 で変更: As part of PEP 667(1), return a proxy
     object for optimized scopes.

 -- C の関数: int PyFrame_GetLineNumber (PyFrameObject *frame)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     'frame' が現在実行している行番号を返します。

* Menu:

* Internal Frames::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0667/


File: python.info,  Node: Internal Frames,  Up: フレーム frame オブジェクト<2>

7.8.6.17 Internal Frames
........................

Unless using PEP 523(1), you will not need this.

 -- C Struct: struct _PyInterpreterFrame

     The interpreter's internal frame representation.

     Added in version 3.11.

 -- C の関数: *note PyObject: 312. *PyUnstable_InterpreterFrame_GetCode
          (struct _PyInterpreterFrame *frame);

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
          Return a *note strong reference: 316. to the code object for
          the frame.

     Added in version 3.12.

 -- C の関数: int PyUnstable_InterpreterFrame_GetLasti (struct
          _PyInterpreterFrame *frame);

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Return the byte offset into the last executed instruction.

     Added in version 3.12.

 -- C の関数: int PyUnstable_InterpreterFrame_GetLine (struct
          _PyInterpreterFrame *frame);

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Return the currently executing line number, or -1 if there is no
     line number.

     Added in version 3.12.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0523/


File: python.info,  Node: ジェネレータオブジェクト,  Next: コルーチンオブジェクト<2>,  Prev: フレーム frame オブジェクト<2>,  Up: その他のオブジェクト<2>

7.8.6.18 ジェネレータオブジェクト
.................................

ジェネレータオブジェクトは、 Python がジェネレータイテレータを実装するの
に使っているオブジェクトです。ジェネレータオブジェクトは通常、 *note
PyGen_New(): 4b75. や *note PyGen_NewWithQualName(): 4b76. の明示的な呼
び出しではなく、値を yield する関数のイテレーションにより生成されます。

 -- C のデータ型: type PyGenObject

     ジェネレータオブジェクトに使われている C 構造体です。

 -- C 変数: *note PyTypeObject: a73. PyGen_Type

     ジェネレータオブジェクトに対応する型オブジェクトです。

 -- C の関数: int PyGen_Check (PyObject *ob)

     'ob' がジェネレータオブジェクトの場合に真を返ます、 'ob' は ‘NULL’
     であってはなりません。この関数は常に成功します。

 -- C の関数: int PyGen_CheckExact (PyObject *ob)

     'ob' が *note PyGen_Type: 4b78. の場合に真を返します。 'o' は
     ‘NULL’ であってはなりません。 この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyGen_New (PyFrameObject *frame)
     '戻り値: 新しい参照。' 'frame' オブジェクトに基づいて新たなジェネレ
     ータオブジェクトを生成して返します。 この関数は 'frame' への参照を
     盗みます。 引数が ‘NULL’ であってはなりません。

 -- C の関数: *note PyObject: 312. *PyGen_NewWithQualName (PyFrameObject
          *frame, PyObject *name, PyObject *qualname)
     '戻り値: 新しい参照。' 'frame' オブジェクトから新たなジェネレータオ
     ブジェクトを生成し、 ‘__name__’ と ‘__qualname__’ を 'name' と
     'qualname' に設定して返します。 この関数は 'frame' への参照を盗みま
     す。 'frame' 引数は ‘NULL’ であってはなりません。


File: python.info,  Node: コルーチンオブジェクト<2>,  Next: コンテキスト変数オブジェクト,  Prev: ジェネレータオブジェクト,  Up: その他のオブジェクト<2>

7.8.6.19 コルーチンオブジェクト
...............................

Added in version 3.5.

コルーチンオブジェクトは ‘async’ キーワードを使って定義した関数が返すオ
ブジェクトです。

 -- C のデータ型: type PyCoroObject

     コルーチンオブジェクトのための C 構造体。

 -- C 変数: *note PyTypeObject: a73. PyCoro_Type

     コルーチンオブジェクトに対応する型オブジェクト。

 -- C の関数: int PyCoro_CheckExact (PyObject *ob)

     'ob' が *note PyCoro_Type: 4b7e. の場合に真を返します。 'ob' は
     ‘NULL’ であってはなりません。 この関数は常に成功します。

 -- C の関数: *note PyObject: 312. *PyCoro_New (PyFrameObject *frame,
          PyObject *name, PyObject *qualname)
     '戻り値: 新しい参照。' 'frame' オブジェクトから新しいコルーチンオブ
     ジェクトを生成して、 ‘__name__’ と ‘__qualname__’ を 'name' と
     'qualname' に設定して返します。 この関数は 'frame' への参照を奪いま
     す。 'frame' 引数は ‘NULL’ であってはなりません。


File: python.info,  Node: コンテキスト変数オブジェクト,  Next: DateTime オブジェクト<2>,  Prev: コルーチンオブジェクト<2>,  Up: その他のオブジェクト<2>

7.8.6.20 コンテキスト変数オブジェクト
.....................................

Added in version 3.7.

バージョン 3.7.1 で変更:

     注釈: Python 3.7.1 で全てのコンテキスト変数の C API のシグネチャは
     、 *note PyContext: 4b83, *note PyContextVar: 4b84, *note
     PyContextToken: 4b85. の代わりに *note PyObject: 312. ポインタを使
     うように '変更' されました。例えば:

          // in 3.7.0:
          PyContext *PyContext_New(void);

          // in 3.7.1+:
          PyObject *PyContext_New(void);

     詳細は bpo-34762(1) を参照してください。

この節では、 *note contextvars: 1d. モジュールの公開 C API の詳細につい
て説明します。

 -- C のデータ型: type PyContext

     *note contextvars.Context: 150d. オブジェクトを表現するための C 構
     造体。

 -- C のデータ型: type PyContextVar

     *note contextvars.ContextVar: 30fe. オブジェクトを表現するための C
     構造体。

 -- C のデータ型: type PyContextToken

     *note contextvars.Token: 3104. オブジェクトを表現するための C 構造
     体。

 -- C 変数: *note PyTypeObject: a73. PyContext_Type

     'コンテキスト' 型を表現する型オブジェクト。

 -- C 変数: *note PyTypeObject: a73. PyContextVar_Type

     'コンテキスト変数' 型を表現する型オブジェクト。

 -- C 変数: *note PyTypeObject: a73. PyContextToken_Type

     'コンテキスト変数トークン' 型を表現する型オブジェクト。

型チェックマクロ:

 -- C の関数: int PyContext_CheckExact (PyObject *o)

     'o' が *note PyContext_Type: 4b86. の場合に真を返します。 'o' は
     ‘NULL’ であってはなりません。 この関数は常に成功します。

 -- C の関数: int PyContextVar_CheckExact (PyObject *o)

     'o' が *note PyContextVar_Type: 4b87. の場合に真を返します。 'o' は
     ‘NULL’ であってはなりません。 この関数は常に成功します。

 -- C の関数: int PyContextToken_CheckExact (PyObject *o)

     'o' が *note PyContextToken_Type: 4b88. の場合に真を返します。 'o'
     は ‘NULL’ であってはなりません。 この関数は常に成功します。

コンテキストオブジェクトを取り扱う関数:

 -- C の関数: *note PyObject: 312. *PyContext_New (void)
     '戻り値: 新しい参照。' 新しい空のコンテキストオブジェクトを作成しま
     す。 エラーが起きた場合は ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyContext_Copy (PyObject *ctx)
     '戻り値: 新しい参照。' 渡された 'ctx' コンテキストオブジェクトの浅
     いコピーを作成します。 エラーが起きた場合は ‘NULL’ を返します。

 -- C の関数: *note PyObject: 312. *PyContext_CopyCurrent (void)
     '戻り値: 新しい参照。' 現在のコンテキストオブジェクトの浅いコピーを
     作成します。 エラーが起きた場合は ‘NULL’ を返します。

 -- C の関数: int PyContext_Enter (PyObject *ctx)

     'ctx' を現在のスレッドの現在のコンテキストに設定します。 成功したら
     ‘0’ を、失敗したら ‘-1’ を返します。

 -- C の関数: int PyContext_Exit (PyObject *ctx)

     'ctx' コンテキストを無効にし、1 つ前のコンテキストを現在のスレッド
     の現在のコンテキストに復元します。 成功したら ‘0’ を、失敗したら
     ‘-1’ を返します。

コンテキスト変数の関数:

 -- C の関数: *note PyObject: 312. *PyContextVar_New (const char *name,
          PyObject *def)
     '戻り値: 新しい参照。' 新しい ‘ContextVar’ オブジェクトを作成します
     。'name' 引数は内部走査とデバッグの目的で使われます。'def' 引数はコ
     ンテキスト変数のデフォルト値を指定するか、デフォルトがない場合は
     ‘NULL’ です。エラーが起きた場合は、関数は ‘NULL’ を返します。

 -- C の関数: int PyContextVar_Get (PyObject *var, PyObject
          *default_value, PyObject **value)

     コンテキスト変数の値を取得します。 取得中にエラーが起きた場合は
     ‘-1’ を、値が見付かっても見付からなくてもエラーが起きなかった場合は
     ‘0’ を返します。

     コンテキスト変数が見付かった場合、 'value' はそれを指すポインタにな
     っています。 コンテキスト変数が見付から 'なかった' 場合は、 'value'
     が指すものは次のようになっています:

        - (‘NULL’ でなければ) 'default_value'

        - (‘NULL’ でなければ) 'var' のデフォルト値

        - ‘NULL’

     ‘NULL’ を除けば、この関数は新しい参照を返します。

 -- C の関数: *note PyObject: 312. *PyContextVar_Set (PyObject *var,
          PyObject *value)
     '戻り値: 新しい参照。' 現在のコンテキストにおいて 'var' の値を
     'value' にセットします。この変更による新しいトークンオブジェクトか
     、エラーが起こった場合は''NULL''を返します。

 -- C の関数: int PyContextVar_Reset (PyObject *var, PyObject *token)

     'var' コンテキスト変数の状態をリセットし、 'token' を返した *note
     PyContextVar_Set(): 4b93. が呼ばれる前の状態に戻します。 この関数は
     成功したら ‘0’ 、失敗したら ‘-1’ を返します。

   ---------- Footnotes ----------

   (1) https://bugs.python.org/issue?@action=redirect&bpo=34762


File: python.info,  Node: DateTime オブジェクト<2>,  Next: 型ヒントのためのオブジェクト,  Prev: コンテキスト変数オブジェクト,  Up: その他のオブジェクト<2>

7.8.6.21 DateTime オブジェクト
..............................

*note datetime: 28. モジュールでは、様々な日付オブジェクトや時刻オブジェ
クトを提供しています。以下に示す関数を使う場合には、あらかじめヘッダファ
イル ‘datetime.h’ をソースに include し (‘Python.h’ はこのファイルを
include しません)、 ‘PyDateTime_IMPORT’ マクロを、通常はモジュール初期化
関数から、起動しておく必要があります。このマクロは以下のマクロで使われる
静的変数 ‘PyDateTimeAPI’ に C 構造体へのポインタを入れます。

 -- C のデータ型: type PyDateTime_Date

     この *note PyObject: 312. のサブタイプは、Pythonの日付オブジェクト
     を表します。

 -- C のデータ型: type PyDateTime_DateTime

     この *note PyObject: 312. のサブタイプは Python の datetime オブジ
     ェクトを表します。

 -- C のデータ型: type PyDateTime_Time

     この *note PyObject: 312. のサブタイプは Python の time オブジェク
     トを表現します。

 -- C のデータ型: type PyDateTime_Delta

     この *note PyObject: 312. のサブタイプは二つの datetime の値の差分
     を表します。

 -- C 変数: *note PyTypeObject: a73. PyDateTime_DateType

     この *note PyTypeObject: a73. のインスタンスは Python の date 型を
     表します; Python レイヤにおける *note datetime.date: 1af. と同じオ
     ブジェクトです。

 -- C 変数: *note PyTypeObject: a73. PyDateTime_DateTimeType

     この *note PyTypeObject: a73. のインスタンスは Python の datetime 型
     を表現します; Python レイヤにおける *note datetime.datetime: 1ae. と
     同じオブジェクトです。

 -- C 変数: *note PyTypeObject: a73. PyDateTime_TimeType

     この *note PyTypeObject: a73. のインスタンスは Python の time 型を
     表します; Python レイヤにおける *note datetime.time: 1b0. と同じオ
     ブジェクトです。

 -- C 変数: *note PyTypeObject: a73. PyDateTime_DeltaType

     This instance of *note PyTypeObject: a73. represents Python type
     for the difference between two datetime values; it is the same
     object as *note datetime.timedelta: 99d. in the Python layer.

 -- C 変数: *note PyTypeObject: a73. PyDateTime_TZInfoType

     この *note PyTypeObject: a73. のインスタンスは Python の タイムゾー
     ン情報型を表します; Python レイヤにおける *note datetime.tzinfo:
     5a8. と同じオブジェクトです。

UTCシングルトンにアクセスするためのマクロ:

 -- C 変数: *note PyObject: 312. *PyDateTime_TimeZone_UTC

     UTCタイムゾーンに相当するシングルトンを返します。これは *note
     datetime.timezone.utc: 5df. と同じオブジェクトです。

     Added in version 3.7.

型チェックマクロ:

 -- C の関数: int PyDate_Check (PyObject *ob)

     'ob' が *note PyDateTime_DateType: 4b9b. 型か ‘PyDateTime_DateType’
     型のサブタイプのオブジェクトの場合に真を返します; 'ob' は ‘NULL’ で
     あってはなりません。この関数は常に成功します。

 -- C の関数: int PyDate_CheckExact (PyObject *ob)

     'ob' が *note PyDateTime_DateType: 4b9b. の場合に真を返します。
     'ob' は ‘NULL’ であってはなりません。この関数は常に成功します。

 -- C の関数: int PyDateTime_Check (PyObject *ob)

     'ob' が *note PyDateTime_DateTimeType: 4b9c. 型か
     ‘PyDateTime_DateTimeType’ 型のサブタイプのオブジェクトの場合に真を
     返します; 'ob' は ‘NULL’ であってはなりません。この関数は常に成功し
     ます。

 -- C の関数: int PyDateTime_CheckExact (PyObject *ob)

     'ob' が *note PyDateTime_DateTimeType: 4b9c. の場合に真を返します。
     'ob' は ‘NULL’ であってはなりません。この関数は常に成功します。

 -- C の関数: int PyTime_Check (PyObject *ob)

     'ob' が *note PyDateTime_TimeType: 4b9d. 型か ‘PyDateTime_TimeType’
     型のサブタイプのオブジェクトの場合に真を返します; 'ob' は ‘NULL’ で
     あってはなりません。この関数は常に成功します。

 -- C の関数: int PyTime_CheckExact (PyObject *ob)

     'ob' が *note PyDateTime_TimeType: 4b9d. の場合に真を返します。
     'ob' は ‘NULL’ であってはなりません。この関数は常に成功します。

 -- C の関数: int PyDelta_Check (PyObject *ob)

     'ob' が *note PyDateTime_DeltaType: 4b9e. 型か
     ‘PyDateTime_DeltaType’ 型のサブタイプのオブジェクトの場合に真を返し
     ます; 'ob' は ‘NULL’ であってはなりません。この関数は常に成功します
     。

 -- C の関数: int PyDelta_CheckExact (PyObject *ob)

     'ob' が *note PyDateTime_DeltaType: 4b9e. の場合に真を返します。
     'ob' は ‘NULL’ であってはなりません。この関数は常に成功します。

 -- C の関数: int PyTZInfo_Check (PyObject *ob)

     'ob' が *note PyDateTime_TZInfoType: 4b9f. 型か
     ‘PyDateTime_TZInfoType’ 型のサブタイプのオブジェクトの場合に真を返
     します; 'ob' は ‘NULL’ であってはなりません。この関数は常に成功しま
     す。

 -- C の関数: int PyTZInfo_CheckExact (PyObject *ob)

     'ob' が *note PyDateTime_TZInfoType: 4b9f. の場合に真を返します。
     'ob' は ‘NULL’ であってはなりません。この関数は常に成功します。

以下はオブジェクトを作成するためのマクロです:

 -- C の関数: *note PyObject: 312. *PyDate_FromDate (int year, int
          month, int day)
     '戻り値: 新しい参照。' 指定した年、月、日の *note datetime.date:
     1af. オブジェクトを返します。

 -- C の関数: *note PyObject: 312. *PyDateTime_FromDateAndTime (int
          year, int month, int day, int hour, int minute, int second,
          int usecond)
     '戻り値: 新しい参照。' 指定した年、月、日、時、分、秒、マイクロ秒の
     *note datetime.datetime: 1ae. オブジェクトを返します。

 -- C の関数: *note PyObject: 312. *PyDateTime_FromDateAndTimeAndFold
          (int year, int month, int day, int hour, int minute, int
          second, int usecond, int fold)
     '戻り値: 新しい参照。' 指定された年、月、日、時、分、秒、マイクロ秒
     、fold の *note datetime.datetime: 1ae. オブジェクトを返します。

     Added in version 3.6.

 -- C の関数: *note PyObject: 312. *PyTime_FromTime (int hour, int
          minute, int second, int usecond)
     '戻り値: 新しい参照。' 指定された時、分、秒、マイクロ秒の *note
     datetime.time: 1b0. オブジェクトを返します。

 -- C の関数: *note PyObject: 312. *PyTime_FromTimeAndFold (int hour,
          int minute, int second, int usecond, int fold)
     '戻り値: 新しい参照。' 指定された時、分、秒、マイクロ秒、fold の
     *note datetime.time: 1b0. オブジェクトを返します。

     Added in version 3.6.

 -- C の関数: *note PyObject: 312. *PyDelta_FromDSU (int days, int
          seconds, int useconds)
     '戻り値: 新しい参照。' 指定された日、秒、マイクロ秒の *note
     datetime.timedelta: 99d. オブジェクトを返します。マイクロ秒と秒が
     *note datetime.timedelta: 99d. オブジェクトで定義されている範囲に入
     るように正規化を行います。

 -- C の関数: *note PyObject: 312. *PyTimeZone_FromOffset (PyObject
          *offset)
     '戻り値: 新しい参照。' 'offset' 引数で指定した固定オフセットを持つ
     、名前のない *note datetime.timezone: 1091. オブジェクトを返します
     。

     Added in version 3.7.

 -- C の関数: *note PyObject: 312. *PyTimeZone_FromOffsetAndName
          (PyObject *offset, PyObject *name)
     '戻り値: 新しい参照。' 'offset*引数で指定した固定のオフセットと、
     *name' のタイムゾーン名を持つ *note datetime.timezone: 1091. オブジ
     ェクトを返します。

     Added in version 3.7.

以下のマクロは date オブジェクトからフィールド値を取り出すためのものです
。引数は *note PyDateTime_Date: 4b97. またはそのサブクラス (例えば *note
PyDateTime_DateTime: 4b98.)の インスタンスでなければなりません。引数を
‘NULL’ にしてはならず、型チェックは行いません:

 -- C の関数: int PyDateTime_GET_YEAR (PyDateTime_Date *o)

     年を正の整数で返します。

 -- C の関数: int PyDateTime_GET_MONTH (PyDateTime_Date *o)

     月を 1 から 12 の間の整数で返します。

 -- C の関数: int PyDateTime_GET_DAY (PyDateTime_Date *o)

     日を 1 から 31 の間の整数で返します。

以下のマクロは datetime オブジェクトからフィールド値を取り出すためのもの
です。引数は *note PyDateTime_DateTime: 4b98. またはそのサブクラスのイン
スタンスでなければなりません。引数を ‘NULL’ にしてはならず、型チェックは
行いません:

 -- C の関数: int PyDateTime_DATE_GET_HOUR (PyDateTime_DateTime *o)

     時を 0 から 23 の間の整数で返します。

 -- C の関数: int PyDateTime_DATE_GET_MINUTE (PyDateTime_DateTime *o)

     分を 0 から 59 の間の整数で返します。

 -- C の関数: int PyDateTime_DATE_GET_SECOND (PyDateTime_DateTime *o)

     秒を 0 から 59 の間の整数で返します。

 -- C の関数: int PyDateTime_DATE_GET_MICROSECOND (PyDateTime_DateTime
          *o)

     マイクロ秒を 0 から 999999 の間の整数で返します。

 -- C の関数: int PyDateTime_DATE_GET_FOLD (PyDateTime_DateTime *o)

     フォールド(訳注: サマータイムによる時間のずれのこと)を 0 から 1 ま
     での整数で返します。

     Added in version 3.6.

 -- C の関数: *note PyObject: 312. *PyDateTime_DATE_GET_TZINFO
          (PyDateTime_DateTime *o)

     Return the tzinfo (which may be ‘None’).

     Added in version 3.10.

以下のマクロは time オブジェクトからフィールド値を取り出すためのものです
。引数は *note PyDateTime_Time: 4b99. またはそのサブクラスのインスタンス
でなければなりません。引数を ‘NULL’ にしてはならず、型チェックは行いませ
ん:

 -- C の関数: int PyDateTime_TIME_GET_HOUR (PyDateTime_Time *o)

     時を 0 から 23 の間の整数で返します。

 -- C の関数: int PyDateTime_TIME_GET_MINUTE (PyDateTime_Time *o)

     分を 0 から 59 の間の整数で返します。

 -- C の関数: int PyDateTime_TIME_GET_SECOND (PyDateTime_Time *o)

     秒を 0 から 59 の間の整数で返します。

 -- C の関数: int PyDateTime_TIME_GET_MICROSECOND (PyDateTime_Time *o)

     マイクロ秒を 0 から 999999 の間の整数で返します。

 -- C の関数: int PyDateTime_TIME_GET_FOLD (PyDateTime_Time *o)

     フォールド(訳注: サマータイムによる時間のずれのこと)を 0 から 1 ま
     での整数で返します。

     Added in version 3.6.

 -- C の関数: *note PyObject: 312. *PyDateTime_TIME_GET_TZINFO
          (PyDateTime_Time *o)

     Return the tzinfo (which may be ‘None’).

     Added in version 3.10.

以下のマクロは time delta オブジェクトからフィールド値をとりだすためのも
のです。引数は *note PyDateTime_Delta: 4b9a. かそのサブクラスのインスタ
ンスでなければなりません。引数を ‘NULL’ にしてはならず、型チェックは行い
ません:

 -- C の関数: int PyDateTime_DELTA_GET_DAYS (PyDateTime_Delta *o)

     日数を -999999999 から 999999999 の間の整数で返します。

     Added in version 3.3.

 -- C の関数: int PyDateTime_DELTA_GET_SECONDS (PyDateTime_Delta *o)

     秒数を 0 から 86399 の間の整数で返します。

     Added in version 3.3.

 -- C の関数: int PyDateTime_DELTA_GET_MICROSECONDS (PyDateTime_Delta
          *o)

     マイクロ秒を 0 から 999999 の間の整数で返します。

     Added in version 3.3.

以下のマクロは DB API を実装する上での便宜用です:

 -- C の関数: *note PyObject: 312. *PyDateTime_FromTimestamp (PyObject
          *args)
     '戻り値: 新しい参照。' Create and return a new *note
     datetime.datetime: 1ae. object given an argument tuple suitable for
     passing to *note datetime.datetime.fromtimestamp(): 4ba.

 -- C の関数: *note PyObject: 312. *PyDate_FromTimestamp (PyObject
          *args)
     '戻り値: 新しい参照。' Create and return a new *note datetime.date:
     1af. object given an argument tuple suitable for passing to *note
     datetime.date.fromtimestamp(): 156d.


File: python.info,  Node: 型ヒントのためのオブジェクト,  Prev: DateTime オブジェクト<2>,  Up: その他のオブジェクト<2>

7.8.6.22 型ヒントのためのオブジェクト
.....................................

Various built-in types for type hinting are provided.  Currently, two
types exist - *note GenericAlias: 67e. and *note Union: 78d.  Only
‘GenericAlias’ is exposed to C.

 -- C の関数: *note PyObject: 312. *Py_GenericAlias (PyObject *origin,
          PyObject *args)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.9 より).'
     *note GenericAlias: 67e. オブジェクトを生成します。Pythonクラス
     *note types.GenericAlias: 7b6. を呼び出すことと同等です。引数
     'origin' と 'args' は ‘GenericAlias’ の ‘__origin__’ および
     ‘__args__’ 属性をそれぞれ設定します。 'origin' は *note
     PyTypeObject: a73.* でなければならず、 'args' は *note
     PyTupleObject: 4993.* または任意の ‘PyObject*’ です。 'args' がタプ
     ルでない場合には1タプルが自動的に生成され、‘__args__’ には
     ‘(args,)’ が設定されます。引数チェックは最小限なため、たとえ
     'origin' が型を示すオブジェクトでなくても関数呼び出しは成功します。
     ‘GenericAlias’ の ‘__parameters__’ 属性は ‘__args__’ から必要に応じ
     て遅延生成されます。失敗した場合、例外が送出されて ‘NULL’ を返しま
     す。

     以下は拡張の型をジェネリックにする例です。

          ...
          static PyMethodDef my_obj_methods[] = {
              // Other methods.
              ...
              {"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"}
              ...
          }

     参考
     ....

     The data model method *note __class_getitem__(): 706.

     Added in version 3.9.

 -- C 変数: *note PyTypeObject: a73. Py_GenericAliasType
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.9 より).'
     *note Py_GenericAlias(): 492b. により返されるCの型オブジェクトです
     。Pythonの *note types.GenericAlias: 7b6. と同等です。

     Added in version 3.9.


File: python.info,  Node: 初期化 initialization 、終了処理 finalization 、スレッド,  Next: Python 初期化設定,  Prev: 具象オブジェクト concrete object レイヤ,  Up: Python/C API リファレンスマニュアル

7.9 初期化 (initialization)、終了処理 (finalization)、スレッド
==============================================================

See *note Python Initialization Configuration: 381. for details on how
to configure the interpreter prior to initialization.

* Menu:

* Python 初期化以前::
* グローバルな設定変数::
* インタープリタの初期化と終了処理::
* プロセスワイドのパラメータ::
* スレッド状態 (thread state) とグローバルインタプリタロック (global interpreter lock): スレッド状態 thread state とグローバルインタプリタロック global interpreter lock.
* サブインタプリタサポート::
* 非同期通知::
* プロファイルとトレース (profiling and tracing): プロファイルとトレース profiling and tracing.
* Reference tracing::
* 高度なデバッガサポート (advanced debugger support): 高度なデバッガサポート advanced debugger support.
* スレッドローカルストレージのサポート::
* 同期プリミティブ: 同期プリミティブ<3>.


File: python.info,  Node: Python 初期化以前,  Next: グローバルな設定変数,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.1 Python 初期化以前
-----------------------

Python が埋め込まれているアプリケーションでは、他の Python/C API 関数を
使う前に *note Py_Initialize(): 87a. 関数を呼ばなければなりません。これ
には例外として、いくつかの関数と *note グローバルな設定変数: 4bc8. があ
ります。

次の関数は Python の初期化の前でも安全に呼び出せます:

   * Functions that initialize the interpreter:

        * *note Py_Initialize(): 87a.

        * *note Py_InitializeEx(): 4932.

        * *note Py_InitializeFromConfig(): 39f.

        * *note Py_BytesMain(): 98f.

        * *note Py_Main(): bf3.

        * the runtime pre-initialization functions covered in *note
          Python 初期化設定: 381.

   * 設定関数:

        * *note PyImport_AppendInittab(): 170e.

        * *note PyImport_ExtendInittab(): 170f.

        * ‘PyInitFrozenExtensions()’

        * *note PyMem_SetAllocator(): 557.

        * *note PyMem_SetupDebugHooks(): c38.

        * *note PyObject_SetArenaAllocator(): 4bc9.

        * *note Py_SetProgramName(): 15a2.

        * *note Py_SetPythonHome(): 15a1.

        * *note PySys_ResetWarnOptions(): 389.

        * the configuration functions covered in *note Python
          初期化設定: 381.

   * 情報取得の関数:

        * *note Py_IsInitialized(): 47e3.

        * *note PyMem_GetAllocator(): 4bca.

        * *note PyObject_GetArenaAllocator(): 4bcb.

        * *note Py_GetBuildInfo(): 13d9.

        * *note Py_GetCompiler(): 492d.

        * *note Py_GetCopyright(): 492e.

        * *note Py_GetPlatform(): 492f.

        * *note Py_GetVersion(): 4930.

        * *note Py_IsInitialized(): 47e3.

   * ユーティリティ:

        * *note Py_DecodeLocale(): b95.

        * the status reporting and utility functions covered in *note
          Python 初期化設定: 381.

   * メモリアロケータ:

        * *note PyMem_RawMalloc(): 369.

        * *note PyMem_RawRealloc(): 36b.

        * *note PyMem_RawCalloc(): 36a.

        * *note PyMem_RawFree(): 36c.

   * Synchronization:

        * *note PyMutex_Lock(): 303.

        * *note PyMutex_Unlock(): 304.

     注釈: Despite their apparent similarity to some of the functions
     listed above, the following functions 'should not be called' before
     the interpreter has been initialized: *note Py_EncodeLocale(): b96,
     *note Py_GetPath(): 38d, *note Py_GetPrefix(): 38f, *note
     Py_GetExecPrefix(): 38b, *note Py_GetProgramFullPath(): 391, *note
     Py_GetPythonHome(): 394, *note Py_GetProgramName(): 393, *note
     PyEval_InitThreads(): 15a5, and *note Py_RunMain(): 993.


File: python.info,  Node: グローバルな設定変数,  Next: インタープリタの初期化と終了処理,  Prev: Python 初期化以前,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.2 グローバルな設定変数
--------------------------

Python には、様々な機能やオプションを制御するグローバルな設定のための変
数があります。 デフォルトでは、これらのフラグは *note
コマンドラインオプション: 1c93. で制御されます。

オプションでフラグがセットされると、フラグの値はそのオプションがセットさ
れた回数になります。 例えば、 ‘-b’ では *note Py_BytesWarningFlag: 3ae.
が 1 に設定され、 ‘-bb’ では *note Py_BytesWarningFlag: 3ae. が 2 に設定
されます。

 -- C 変数: int Py_BytesWarningFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.bytes_warning: 3af. should be used instead, see *note
     Python Initialization Configuration: 381.

     *note bytes: 1a4. または *note bytearray: 508. を *note str: 418. と
     比較した場合、または、 *note bytes: 1a4. を *note int: 238. と比較
     した場合に警告を発生させます。 ‘2’ 以上の値を設定している場合は、エ
     ラーを発生させます。

     *note -b: 5ad. オプションで設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_DebugFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.parser_debug: 3a1. should be used instead, see *note
     Python Initialization Configuration: 381.

     パーサーのデバッグ出力を有効にします。(専門家専用です。コンパイルオ
     プションに依存します)。

     *note -d: 1c9b. オプションと *note PYTHONDEBUG: 1c9c. 環境変数で設
     定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_DontWriteBytecodeFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.write_bytecode: 3b5. should be used instead, see *note
     Python Initialization Configuration: 381.

     非ゼロに設定した場合、Python はソースモジュールのインポート時に
     ‘.pyc’ ファイルの作成を試みません。

     *note -B: 1375. オプションと *note PYTHONDONTWRITEBYTECODE: 1376. 環
     境変数で設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_FrozenFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.pathconfig_warnings: 3b1. should be used instead, see
     *note Python Initialization Configuration: 381.

     *note Py_GetPath(): 38d. の中でモジュール検索パスを割り出していると
     きのエラーメッセージを抑制します。

     ‘_freeze_module’ プログラムと ‘frozenmain’ プログラムが使用する非公
     開フラグです。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_HashRandomizationFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.hash_seed: 3bc. and *note PyConfig.use_hash_seed: 3bb.
     should be used instead, see *note Python Initialization
     Configuration: 381.

     *note PYTHONHASHSEED: 1052. 環境変数が空でない文字列に設定された場
     合に、 ‘1’ が設定されます。

     フラグがゼロでない場合、 *note PYTHONHASHSEED: 1052. 環境変数を読み
     シークレットハッシュシードを初期化します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_IgnoreEnvironmentFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.use_environment: 3b3. should be used instead, see *note
     Python Initialization Configuration: 381.

     Ignore all ‘PYTHON*’ environment variables, e.g.  *note PYTHONPATH:
     fe8. and *note PYTHONHOME: 396, that might be set.

     *note -E: 92b. オプションと *note -I: 92c. オプションで設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_InspectFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.inspect: 3a9. should be used instead, see *note Python
     Initialization Configuration: 381.

     最初の引数にスクリプトが指定されたときや *note -c: 5aa. オプション
     が利用された際に、 *note sys.stdin: 507. がターミナルに出力されない
     ときであっても、スクリプトかコマンドを実行した後にインタラクティブ
     モードに入ります。

     *note -i: 1484. オプションと *note PYTHONINSPECT: 1483. 環境変数で
     設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_InteractiveFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.interactive: 3a7. should be used instead, see *note Python
     Initialization Configuration: 381.

     *note -i: 1484. オプションで設定します。

     バージョン 3.12 で非推奨.

 -- C 変数: int Py_IsolatedFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.isolated: 3be. should be used instead, see *note Python
     Initialization Configuration: 381.

     Python を隔離モードで実行します。 隔離モードでは *note sys.path:
     38e. はスクリプトのディレクトリやユーザのサイトパッケージのディレク
     トリを含みません。

     *note -I: 92c. オプションで設定します。

     Added in version 3.4.

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_LegacyWindowsFSEncodingFlag

     This API is kept for backward compatibility: setting *note
     PyPreConfig.legacy_windows_fs_encoding: 3c0. should be used
     instead, see *note Python Initialization Configuration: 381.

     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 *note filesystem encoding and error handler:
     505.

     *note PYTHONLEGACYWINDOWSFSENCODING: 28f. 環境変数が空でない文字列
     に設定された場合に、 ‘1’ に設定されます。

     より詳しくは PEP 529(1) を参照してください。

     *note Availability: 1cbe.: Windows.

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_LegacyWindowsStdioFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.legacy_windows_stdio: 37e. should be used instead, see
     *note Python Initialization Configuration: 381.

     If the flag is non-zero, use *note io.FileIO: 12df. instead of
     ‘io._WindowsConsoleIO’ for *note sys: c3. standard streams.

     *note PYTHONLEGACYWINDOWSSTDIO: c29. 環境変数が空でない文字列に設定
     された場合に、 ‘1’ に設定されます。

     より詳しくは PEP 528(2) を参照してください。

     *note Availability: 1cbe.: Windows.

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_NoSiteFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.site_import: 3ad. should be used instead, see *note Python
     Initialization Configuration: 381.

     *note site: b5. モジュールの import と、そのモジュールが行なってい
     た site ごとの *note sys.path: 38e. への操作を無効にします。後で
     *note site: b5. を明示的に import しても、これらの操作は実行されま
     せん (実行したい場合は、 *note site.main(): 1ca0. を呼び出してくだ
     さい)。

     *note -S: 1179. オプションで設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_NoUserSiteDirectory

     This API is kept for backward compatibility: setting *note
     PyConfig.user_site_directory: 3b7. should be used instead, see
     *note Python Initialization Configuration: 381.

     *note ユーザのサイトパッケージのディレクトリ: 1c9f. を *note
     sys.path: 38e. に追加しません。

     *note -s: 1353. オプション、 *note -I: 92c. 、 *note
     PYTHONNOUSERSITE: 1354. 環境変数で設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_OptimizeFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.optimization_level: 3ab. should be used instead, see *note
     Python Initialization Configuration: 381.

     *note -O: d82. オプションと *note PYTHONOPTIMIZE: 1c9d. 環境変数で
     設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_QuietFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.quiet: 3a5. should be used instead, see *note Python
     Initialization Configuration: 381.

     インタラクティブモードでも copyright とバージョンのメッセージを表示
     しません。

     *note -q: 1c9e. オプションで設定します。

     Added in version 3.2.

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_UnbufferedStdioFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.buffered_stdio: 3b9. should be used instead, see *note
     Python Initialization Configuration: 381.

     標準出力と標準エラーをバッファリングしないように強制します。

     *note -u: 190f. オプションと *note PYTHONUNBUFFERED: 1910. 環境変数
     で設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

 -- C 変数: int Py_VerboseFlag

     This API is kept for backward compatibility: setting *note
     PyConfig.verbose: 3a3. should be used instead, see *note Python
     Initialization Configuration: 381.

     モジュールが初期化されるたびにメッセージを出力し、それがどこ (ファ
     イル名やビルトインモジュール) からロードされたのかを表示します。 値
     が 2 以上の場合は、モジュールを検索するときにチェックしたファイルご
     とにメッセージを出力します。また、終了時のモジュールクリーンアップ
     に関する情報も提供します。

     *note -v: 13cc. オプションと *note PYTHONVERBOSE: 1ca1. 環境変数で
     設定します。

     Deprecated since version 3.12, will be removed in version 3.14.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0529/

   (2) https://peps.python.org/pep-0528/


File: python.info,  Node: インタープリタの初期化と終了処理,  Next: プロセスワイドのパラメータ,  Prev: グローバルな設定変数,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.3 インタープリタの初期化と終了処理
--------------------------------------

 -- C の関数: void Py_Initialize ()
     ' 次に属します: *note Stable ABI: 51e.'

     Python インタープリタを初期化します。 Python の埋め込みを行うアプリ
     ケーションでは、他のあらゆる Python/C API を使用するよりも前にこの
     関数を呼び出さなければなりません。いくつかの例外については *note
     Python 初期化以前: b93. を参照してください。

     This initializes the table of loaded modules (‘sys.modules’), and
     creates the fundamental modules *note builtins: e, *note __main__:
     1. and *note sys: c3.  It also initializes the module search path
     (‘sys.path’).  It does not set ‘sys.argv’; use the *note Python
     Initialization Configuration: 381. API for that.  This is a no-op
     when called for a second time (without calling *note
     Py_FinalizeEx(): ce3. first).  There is no return value; it is a
     fatal error if the initialization fails.

     Use *note Py_InitializeFromConfig(): 39f. to customize the *note
     Python Initialization Configuration: 381.

          注釈: Windows では ‘O_TEXT’ から ‘O_BINARY’ へコンソールモード
          が変更されますが、これはその C ランタイムを使っているコンソー
          ルでの Python 以外の使い勝手にも影響を及ぼします。

 -- C の関数: void Py_InitializeEx (int initsigs)
     ' 次に属します: *note Stable ABI: 51e.'  This function works like
     *note Py_Initialize(): 87a. 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.

     Use *note Py_InitializeFromConfig(): 39f. to customize the *note
     Python Initialization Configuration: 381.

 -- C の関数: *note PyStatus: 97b. Py_InitializeFromConfig (const
          PyConfig *config)

     Initialize Python from 'config' configuration, as described in
     *note Initialization with PyConfig: 4bce.

     See the *note Python 初期化設定: 381. section for details on
     pre-initializing the interpreter, populating the runtime
     configuration structure, and querying the returned status
     structure.

 -- C の関数: int Py_IsInitialized ()
     ' 次に属します: *note Stable ABI: 51e.'  Python インタプリタが初期
     化済みであれば真(非ゼロ)を、さもなければ偽(ゼロ)を返します。*note
     Py_FinalizeEx(): ce3. を呼び出した後は、*note Py_Initialize(): 87a.
     を再び呼び出すまで、この関数は偽を返します。

 -- C の関数: int Py_IsFinalizing ()
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Return true (non-zero) if the main Python interpreter is *note
     shutting down: 134.  Return false (zero) otherwise.

     Added in version 3.13.

 -- C の関数: int Py_FinalizeEx ()
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.6 より).'
     Undo all initializations made by *note Py_Initialize(): 87a. and
     subsequent use of Python/C API functions, and destroy all
     sub-interpreters (see *note Py_NewInterpreter(): 1721. below) that
     were created and not yet destroyed since the last call to *note
     Py_Initialize(): 87a.  Ideally, this frees all memory allocated by
     the Python interpreter.  This is a no-op when called for a second
     time (without calling *note Py_Initialize(): 87a. again first).

     Since this is the reverse of *note Py_Initialize(): 87a, 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 *note Py_RunMain(): 993. is running.

     Normally the return value is ‘0’.  If there were errors during
     finalization (flushing buffered data), ‘-1’ is returned.

     この関数が提供されている理由はいくつかあります。Python の埋め込みを
     行っているアプリケーションでは、アプリケーションを再起動することな
     く Python を再起動したいことがあります。また、動的ロード可能イブラ
     リ (あるいは DLL) から Python インタプリタをロードするアプリケーシ
     ョンでは、DLL をアンロードする前に Python が確保したメモリを全て解
     放したいと考えるかもしれません。アプリケーション内で起きているメモ
     リリークを追跡する際に、開発者は Python が確保したメモリをアプリケ
     ーションの終了前に解放させたいと思う場合もあります。

     'Bugs and caveats:' The destruction of modules and objects in
     modules is done in random order; this may cause destructors (*note
     __del__(): 1ec1. methods) to fail when they depend on other objects
     (even functions) or modules.  Dynamically loaded extension modules
     loaded by Python are not unloaded.  Small amounts of memory
     allocated by the Python interpreter may not be freed (if you find a
     leak, please report it).  Memory tied up in circular references
     between objects is not freed.  Some memory allocated by extension
     modules may not be freed.  Some extensions may not work properly if
     their initialization routine is called more than once; this can
     happen if an application calls *note Py_Initialize(): 87a. and
     *note Py_FinalizeEx(): ce3. more than once.

     引数無しで *note 監査イベント: 1825.
     ‘cpython._PySys_ClearAuditHooks’ を送出します。

     Added in version 3.6.

 -- C の関数: void Py_Finalize ()
     ' 次に属します: *note Stable ABI: 51e.'  この関数は *note
     Py_FinalizeEx(): ce3. の後方互換性バージョンで、戻り値がありません
     。

 -- C の関数: int Py_BytesMain (int argc, char **argv)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.8 より).'
     Similar to *note Py_Main(): bf3. but 'argv' is an array of bytes
     strings, allowing the calling application to delegate the text
     decoding step to the CPython runtime.

     Added in version 3.8.

 -- C の関数: int Py_Main (int argc, wchar_t **argv)
     ' 次に属します: *note Stable ABI: 51e.'  The main program for the
     standard interpreter, encapsulating a full
     initialization/finalization cycle, as well as additional behaviour
     to implement reading configurations settings from the environment
     and command line, and then executing ‘__main__’ in accordance with
     *note コマンドライン: fd2.

     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.

     The 'argc' and 'argv' parameters are similar to those which are
     passed to a C program's ‘main()’ function, except that the 'argv'
     entries are first converted to ‘wchar_t’ using *note
     Py_DecodeLocale(): b95.  It is also important to note that the
     argument list entries may be modified to point to strings other
     than those passed in (however, the contents of the strings pointed
     to by the argument list are not modified).

     The return value will be ‘0’ if the interpreter exits normally
     (i.e., without an exception), ‘1’ if the interpreter exits due to
     an exception, or ‘2’ if the argument list does not represent a
     valid Python command line.

     Note that if an otherwise unhandled *note SystemExit: d0e. is
     raised, this function will not return ‘1’, but exit the process, as
     long as ‘Py_InspectFlag’ is not set.  If ‘Py_InspectFlag’ is set,
     execution will drop into the interactive Python prompt, at which
     point a second otherwise unhandled *note SystemExit: d0e. will
     still exit the process, while any other means of exiting will set
     the return value as described above.

     In terms of the CPython runtime configuration APIs documented in
     the *note runtime configuration: 381. section (and without
     accounting for error handling), ‘Py_Main’ is approximately
     equivalent to:

          PyConfig config;
          PyConfig_InitPythonConfig(&config);
          PyConfig_SetArgv(&config, argc, argv);
          Py_InitializeFromConfig(&config);
          PyConfig_Clear(&config);

          Py_RunMain();

     In normal usage, an embedding application will call this function
     'instead' of calling *note Py_Initialize(): 87a, *note
     Py_InitializeEx(): 4932. or *note Py_InitializeFromConfig(): 39f.
     directly, and all settings will be applied as described elsewhere
     in this documentation.  If this function is instead called 'after'
     a preceding runtime initialization API call, then exactly which
     environmental and command line configuration settings will be
     updated is version dependent (as it depends on which settings
     correctly support being modified after they have already been set
     once when the runtime was first initialized).

 -- C の関数: int Py_RunMain (void)

     Executes the main module in a fully configured CPython runtime.

     Executes the command (*note PyConfig.run_command: 4bcf.), the
     script (*note PyConfig.run_filename: 4bd0.) or the module (*note
     PyConfig.run_module: 4bd1.) specified on the command line or in the
     configuration.  If none of these values are set, runs the
     interactive Python prompt (REPL) using the ‘__main__’ module's
     global namespace.

     If *note PyConfig.inspect: 3a9. is not set (the default), the
     return value will be ‘0’ if the interpreter exits normally (that
     is, without raising an exception), or ‘1’ if the interpreter exits
     due to an exception.  If an otherwise unhandled *note SystemExit:
     d0e. is raised, the function will immediately exit the process
     instead of returning ‘1’.

     If *note PyConfig.inspect: 3a9. is set (such as when the *note -i:
     1484. option is used), rather than returning when the interpreter
     exits, execution will instead resume in an interactive Python
     prompt (REPL) using the ‘__main__’ module's global namespace.  If
     the interpreter exited with an exception, it is immediately raised
     in the REPL session.  The function return value is then determined
     by the way the 'REPL session' terminates: returning ‘0’ if the
     session terminates without raising an unhandled exception, exiting
     immediately for an unhandled *note SystemExit: d0e, and returning
     ‘1’ for any other unhandled exception.

     This function always finalizes the Python interpreter regardless of
     whether it returns a value or immediately exits the process due to
     an unhandled *note SystemExit: d0e. exception.

     See *note Python Configuration: 4bd2. for an example of a
     customized Python that always runs in isolated mode using *note
     Py_RunMain(): 993.


File: python.info,  Node: プロセスワイドのパラメータ,  Next: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock,  Prev: インタープリタの初期化と終了処理,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.4 プロセスワイドのパラメータ
--------------------------------

 -- C の関数: void Py_SetProgramName (const wchar_t *name)
     ' 次に属します: *note Stable ABI: 51e.'

     This API is kept for backward compatibility: setting *note
     PyConfig.program_name: 39e. should be used instead, see *note
     Python Initialization Configuration: 381.

     この関数を呼び出すなら、最初に *note Py_Initialize(): 87a. を呼び出
     すよりも前に呼び出さなければなりません。この関数はインタプリタにプ
     ログラムの ‘main()’ 関数に指定した ‘argv[0]’ 引数の値を教えます (ワ
     イドキャラクタに変換されます)。この引数値は、 *note Py_GetPath():
     38d. や、以下に示すその他の関数が、インタプリタの実行可能形式から
     Python ランタイムライブラリへの相対パスを取得するために使われます。
     デフォルトの値は ‘'python'’ です。引数はゼロ終端されたワイドキャラ
     クタ文字列で、静的な記憶領域に入っていなければならず、その内容はプ
     ログラムの実行中に変更してはなりません。 Python インタプリタ内のコ
     ードで、この記憶領域の内容を変更するものは一切ありません。

     バイト文字列を wchar_* 文字列にデコードするには *note
     Py_DecodeLocale(): b95. を使ってください。

     バージョン 3.11 で非推奨.

 -- C の関数: wchar_t *Py_GetProgramName ()
     ' 次に属します: *note Stable ABI: 51e.'  Return the program name
     set with *note PyConfig.program_name: 39e, or the default.  The
     returned string points into static storage; the caller should not
     modify its value.

     This function should not be called before *note Py_Initialize():
     87a, otherwise it returns ‘NULL’.

     バージョン 3.10 で変更: It now returns ‘NULL’ if called before
     *note Py_Initialize(): 87a.

     Deprecated since version 3.13, will be removed in version 3.15: Get
     *note sys.executable: 392. instead.

 -- C の関数: wchar_t *Py_GetPrefix ()
     ' 次に属します: *note Stable ABI: 51e.'  Return the 'prefix' for
     installed platform-independent files.  This is derived through a
     number of complicated rules from the program name set with *note
     PyConfig.program_name: 39e. and some environment variables; for
     example, if the program name is ‘'/usr/local/bin/python'’, the
     prefix is ‘'/usr/local'’.  The returned string points into static
     storage; the caller should not modify its value.  This corresponds
     to the ‘prefix’ variable in the top-level ‘Makefile’ and the *note
     -prefix: 1cca. argument to the ‘configure’ script at build time.
     The value is available to Python code as ‘sys.base_prefix’.  It is
     only useful on Unix.  See also the next function.

     This function should not be called before *note Py_Initialize():
     87a, otherwise it returns ‘NULL’.

     バージョン 3.10 で変更: It now returns ‘NULL’ if called before
     *note Py_Initialize(): 87a.

     Deprecated since version 3.13, will be removed in version 3.15: Get
     *note sys.base_prefix: 3c9. instead, or *note sys.prefix: 390. if
     *note virtual environments: 41a0. need to be handled.

 -- C の関数: wchar_t *Py_GetExecPrefix ()
     ' 次に属します: *note Stable ABI: 51e.'  Return the 'exec-prefix'
     for installed platform-'dependent' files.  This is derived through
     a number of complicated rules from the program name set with *note
     PyConfig.program_name: 39e. and some environment variables; for
     example, if the program name is ‘'/usr/local/bin/python'’, the
     exec-prefix is ‘'/usr/local'’.  The returned string points into
     static storage; the caller should not modify its value.  This
     corresponds to the ‘exec_prefix’ variable in the top-level
     ‘Makefile’ and the ‘--exec-prefix’ argument to the ‘configure’
     script at build time.  The value is available to Python code as
     ‘sys.base_exec_prefix’.  It is only useful on Unix.

     背景: プラットフォーム依存のファイル (実行形式や共有ライブラリ) が
     別のディレクトリツリー内にインストールされている場合、 exec-prefix
     は prefix と異なります。典型的なインストール形態では、プラットフォ
     ーム非依存のファイルが ‘/usr/local’ に収められる一方、プラットフォ
     ーム依存のファイルは ‘/usr/local/plat’ サブツリーに収められます。

     一般的に、プラットフォームとは、ハードウェアとソフトウェアファミリ
     の組み合わせを指します。例えば、Solaris 2.x を動作させている Sparc
     マシンは全て同じプラットフォームであるとみなしますが、Solaris 2.x を
     動作させている Intel マシンは違うプラットフォームになりますし、同じ
     Intel マシンでも Linux を動作させているならまた別のプラットフォーム
     です。一般的には、同じオペレーティングシステムでも、メジャーリビジ
     ョンの違うものは異なるプラットフォームです。非 Unix のオペレーティ
     ングシステムの場合は話はまた別です; 非 Unix のシステムでは、インス
     トール方法はとても異なっていて、prefix や exec-prefix には意味がな
     く、空文字列が設定されています。コンパイル済みの Python バイトコー
     ドはプラットフォームに依存しないので注意してください (ただし、どの
     バージョンの Python でコンパイルされたかには依存します!)。

     システム管理者は、 ‘mount’ や ‘automount’ プログラムを使って、各プ
     ラットフォーム用の ‘/usr/local/plat’ を異なったファイルシステムに置
     き、プラットフォーム間で ‘/usr/local’ を共有するための設定方法を知
     っているでしょう。

     This function should not be called before *note Py_Initialize():
     87a, otherwise it returns ‘NULL’.

     バージョン 3.10 で変更: It now returns ‘NULL’ if called before
     *note Py_Initialize(): 87a.

     Deprecated since version 3.13, will be removed in version 3.15: Get
     *note sys.base_exec_prefix: 3c8. instead, or *note sys.exec_prefix:
     38c. if *note virtual environments: 41a0. need to be handled.

 -- C の関数: wchar_t *Py_GetProgramFullPath ()
     ' 次に属します: *note Stable ABI: 51e.'

     Return the full program name of the Python executable; this is
     computed as a side-effect of deriving the default module search
     path from the program name (set by *note PyConfig.program_name:
     39e.).  The returned string points into static storage; the caller
     should not modify its value.  The value is available to Python code
     as ‘sys.executable’.

     This function should not be called before *note Py_Initialize():
     87a, otherwise it returns ‘NULL’.

     バージョン 3.10 で変更: It now returns ‘NULL’ if called before
     *note Py_Initialize(): 87a.

     Deprecated since version 3.13, will be removed in version 3.15: Get
     *note sys.executable: 392. instead.

 -- C の関数: wchar_t *Py_GetPath ()
     ' 次に属します: *note Stable ABI: 51e.'

     Return the default module search path; this is computed from the
     program name (set by *note PyConfig.program_name: 39e.) and some
     environment variables.  The returned string consists of a series of
     directory names separated by a platform dependent delimiter
     character.  The delimiter character is ‘':'’ on Unix and macOS,
     ‘';'’ on Windows.  The returned string points into static storage;
     the caller should not modify its value.  The list *note sys.path:
     38e. is initialized with this value on interpreter startup; it can
     be (and usually is) modified later to change the search path for
     loading modules.

     This function should not be called before *note Py_Initialize():
     87a, otherwise it returns ‘NULL’.

     バージョン 3.10 で変更: It now returns ‘NULL’ if called before
     *note Py_Initialize(): 87a.

     Deprecated since version 3.13, will be removed in version 3.15: Get
     *note sys.path: 38e. instead.

 -- C の関数: const char *Py_GetVersion ()
     ' 次に属します: *note Stable ABI: 51e.'  Python インタプリタのバー
     ジョンを返します。バージョンは、次のような形式の文字列です

          "3.0a5+ (py3k:63103M, May 12 2008, 00:53:55) \n[GCC 4.2.3]"

     第一ワード (最初のスペース文字まで) は、現在の Python のバージョン
     です; 最初の文字は、ピリオドで区切られたメジャーバージョンとマイナ
     ーバージョンです。関数が返す文字列ポインタは静的な記憶領域を返しま
     す; 関数の呼び出し側はこの値を変更できません。この値は Python コー
     ドからは *note sys.version: 15e. として利用できます。

     See also the *note Py_Version: 721. constant.

 -- C の関数: const char *Py_GetPlatform ()
     ' 次に属します: *note Stable ABI: 51e.'

     現在のプラットフォームのプラットフォーム識別文字列を返します。
     Unixでは、オペレーティングシステムの "公式の" 名前を小文字に変換し
     、後ろにメジャーリビジョン番号を付けた構成になっています。例えば
     Solaris 2.x は、SunOS 5.x, としても知られていますが、‘'sunos5'’ に
     なります。macOS では ‘'darwin'’ です。Windows では ‘'win'’ です。関
     数が返す文字列ポインタは静的な記憶領域を返します; 関数の呼び出し側
     はこの値を変更できません。この値は Python コードからは
     ‘sys.platform’ として利用できます。

 -- C の関数: const char *Py_GetCopyright ()
     ' 次に属します: *note Stable ABI: 51e.'  現在の Python バージョンに
     対する公式の著作権表示文字列を返します。例えば

     ‘'Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam'’

     関数が返す文字列ポインタは静的な記憶領域を返します; 関数の呼び出し
     側はこの値を変更できません。この値は Python コードからは
     ‘sys.copyright’ として利用できます。

 -- C の関数: const char *Py_GetCompiler ()
     ' 次に属します: *note Stable ABI: 51e.'  現在使っているバージョンの
     Python をビルドする際に用いたコンパイラを示す文字列を、角括弧で囲っ
     た文字列を返します。例えば:

          "[GCC 2.7.2.2]"

     関数が返す文字列ポインタは静的な記憶領域を返します; 関数の呼び出し
     側はこの値を変更できません。この値は Python コードからは
     ‘sys.version’ の一部として取り出せます。

 -- C の関数: const char *Py_GetBuildInfo ()
     ' 次に属します: *note Stable ABI: 51e.'  現在使っている Python イン
     タプリタインスタンスの、シーケンス番号とビルド日時に関する情報を返
     します。例えば

          "#67, Aug  1 1997, 22:34:28"

     関数が返す文字列ポインタは静的な記憶領域を返します; 関数の呼び出し
     側はこの値を変更できません。この値は Python コードからは
     ‘sys.version’ の一部として取り出せます。

 -- C の関数: void PySys_SetArgvEx (int argc, wchar_t **argv, int
          updatepath)
     ' 次に属します: *note Stable ABI: 51e.'

     This API is kept for backward compatibility: setting *note
     PyConfig.argv: 39d, *note PyConfig.parse_argv: 1893. and *note
     PyConfig.safe_path: 73e. should be used instead, see *note Python
     Initialization Configuration: 381.

     'argc' および 'argv' に基づいて *note sys.argv: 1236. を設定します
     。これらの引数はプログラムの ‘main()’ に渡した引数に似ていますが、
     最初の要素が Python インタプリタの宿主となっている実行形式の名前で
     はなく、実行されるスクリプト名を参照しなければならない点が違います
     。実行するスクリプトがない場合、 'argv' の最初の要素は空文字列にし
     てもかまいません。この関数が *note sys.argv: 1236. の初期化に失敗し
     た場合、致命的エラーを *note Py_FatalError(): 951. で知らせます。

     'updatepath' が 0 の場合、ここまでの動作がこの関数がすることの全て
     です。 'updatepath' が 0 でない場合、この関数は *note sys.path:
     38e. を以下のアルゴリズムに基づいて修正します:

        - 存在するスクリプトの名前が ‘argv[0]’ に渡された場合、そのスク
          リプトがある場所の絶対パスを *note sys.path: 38e. の先頭に追加
          します。

        - それ以外の場合 ('argc' が ‘0’ だったり、 ‘argv[0]’ が存在する
          ファイル名を指していない場合)、 *note sys.path: 38e. の先頭に
          空の文字列を追加します。 これは現在の作業ディレクトリ (‘"."’)
          を先頭に追加するのと同じです。

     バイト文字列を wchar_* 文字列にデコードするには *note
     Py_DecodeLocale(): b95. を使ってください。

     See also *note PyConfig.orig_argv: 861. and *note PyConfig.argv:
     39d. members of the *note Python Initialization Configuration: 381.

          注釈: It is recommended that applications embedding the Python
          interpreter for purposes other than executing a single script
          pass ‘0’ as 'updatepath', and update *note sys.path: 38e.
          themselves if desired.  See CVE 2008-5983(1).

          3.1.3 より前のバージョンでは、 *note PySys_SetArgv(): 15a4. の
          呼び出しが完了した後に *note sys.path: 38e. の先頭の要素を取り
          出すことで、同じ効果が得られます。例えばこのように使います:

               PyRun_SimpleString("import sys; sys.path.pop(0)\n");

     Added in version 3.1.3.

     バージョン 3.11 で非推奨.

 -- C の関数: void PySys_SetArgv (int argc, wchar_t **argv)
     ' 次に属します: *note Stable ABI: 51e.'  This API is kept for
     backward compatibility: setting *note PyConfig.argv: 39d. and *note
     PyConfig.parse_argv: 1893. should be used instead, see *note Python
     Initialization Configuration: 381.

     この関数は、 ‘python’ インタプリタが *note -I: 92c. オプション付き
     で実行されている場合を除き *note PySys_SetArgvEx(): 15a3. の
     'updatepath' に ‘1’ を設定したのと同じように動作します。

     バイト文字列を wchar_* 文字列にデコードするには *note
     Py_DecodeLocale(): b95. を使ってください。

     See also *note PyConfig.orig_argv: 861. and *note PyConfig.argv:
     39d. members of the *note Python Initialization Configuration: 381.

     バージョン 3.4 で変更: 'updatepath' の値は *note -I: 92c. オプショ
     ンに依存します。

     バージョン 3.11 で非推奨.

 -- C の関数: void Py_SetPythonHome (const wchar_t *home)
     ' 次に属します: *note Stable ABI: 51e.'  This API is kept for
     backward compatibility: setting *note PyConfig.home: 395. should be
     used instead, see *note Python Initialization Configuration: 381.

     Python の標準ライブラリがある、デフォルトの "home" ディレクトリを設
     定します。引数の文字列の意味については *note PYTHONHOME: 396. を参
     照してください。

     引数は静的なストレージに置かれてプログラム実行中に書き換えられない
     ようなゼロ終端の文字列であるべきです。Python インタプリタはこのスト
     レージの内容を変更しません。

     バイト文字列を wchar_* 文字列にデコードするには *note
     Py_DecodeLocale(): b95. を使ってください。

     バージョン 3.11 で非推奨.

 -- C の関数: wchar_t *Py_GetPythonHome ()
     ' 次に属します: *note Stable ABI: 51e.'  Return the default "home",
     that is, the value set by *note PyConfig.home: 395, or the value of
     the *note PYTHONHOME: 396. environment variable if it is set.

     This function should not be called before *note Py_Initialize():
     87a, otherwise it returns ‘NULL’.

     バージョン 3.10 で変更: It now returns ‘NULL’ if called before
     *note Py_Initialize(): 87a.

     Deprecated since version 3.13, will be removed in version 3.15: Get
     *note PyConfig.home: 395. or *note PYTHONHOME: 396. environment
     variable instead.

   ---------- Footnotes ----------

   (1) https://www.cve.org/CVERecord?id=CVE-2008-5983


File: python.info,  Node: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock,  Next: サブインタプリタサポート,  Prev: プロセスワイドのパラメータ,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.5 スレッド状態 (thread state) とグローバルインタプリタロック (global interpreter lock)
------------------------------------------------------------------------------------------

Python インタプリタは完全にはスレッドセーフではありません。マルチスレッ
ドの Python プログラムをサポートするために、 *note
グローバルインタプリタロック: 12e. あるいは *note GIL: 13f. と呼ばれるグ
ローバルなロックが存在していて、現在のスレッドが Python オブジェクトに安
全にアクセスする前に必ずロックを獲得しなければならなくなっています。ロッ
ク機構がなければ、単純な操作でさえ、マルチスレッドプログラムの実行に問題
を引き起こす可能性があります。たとえば、二つのスレッドが同じオブジェクト
の参照カウントを同時にインクリメントすると、結果的に参照カウントは二回で
なく一回だけしかインクリメントされないかもしれません。

このため、 *note GIL: 13f. を獲得したスレッドだけが Python オブジェクト
を操作したり、 Python/C API 関数を呼び出したりできるというルールがありま
す。並行処理をエミュレートするために、インタプリタは定期的にロックを解放
したり獲得したりします。 (*note sys.setswitchinterval(): 918. を参照) こ
のロックはブロックが起こりうる I/O 操作の付近でも解放・獲得され、 I/O を
要求するスレッドが I/O 操作の完了を待つ間、他のスレッドが動作できるよう
にしています。

Python インタプリタはスレッドごとに必要な情報を *note PyThreadState:
758. と呼ばれるデータ構造の中に保存します。そしてグローバル変数として現
在の *note PyThreadState: 758. を指すポインタを1つ持ちます。このグローバ
ル変数は *note PyThreadState_Get(): 34b. を使って取得できます。

* Menu:

* 拡張コード内で GIL を解放する::
* Python 以外で作られたスレッド::
* Cautions about fork(): Cautions about fork.
* 高レベルAPI::
* 低レベルAPI::


File: python.info,  Node: 拡張コード内で GIL を解放する,  Next: Python 以外で作られたスレッド,  Up: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock

7.9.5.1 拡張コード内で GIL を解放する
.....................................

*note GIL: 13f. を操作するほとんどのコードは、次のような単純な構造になり
ます:

     Save the thread state in a local variable.
     Release the global interpreter lock.
     ... Do some blocking I/O operation ...
     Reacquire the global interpreter lock.
     Restore the thread state from the local variable.

この構造は非常に一般的なので、作業を単純にするために2つのマクロが用意さ
れています:

     Py_BEGIN_ALLOW_THREADS
     ... Do some blocking I/O operation ...
     Py_END_ALLOW_THREADS

*note Py_BEGIN_ALLOW_THREADS: 4769. マクロは新たなブロックを開始し、隠し
ローカル変数を宣言します; *note Py_END_ALLOW_THREADS: a5c. はブロックを
閉じます。

上のブロックは次のコードに展開されます:

     PyThreadState *_save;

     _save = PyEval_SaveThread();
     ... Do some blocking I/O operation ...
     PyEval_RestoreThread(_save);

これらの関数の動作を説明します。GIL は現在のスレッド状態を指すポインタを
保護するために使われます。ロックを解放してスレッド状態を退避する際、ロッ
クを解放する前に現在のスレッド状態ポインタを取得しておかなければなりませ
ん (他のスレッドがすぐさまロックを獲得して、自らのスレッド状態をグローバ
ル変数に保存してしまうかもしれないからです)。逆に、ロックを獲得してスレ
ッド状態を復帰する際には、グローバル変数にスレッド状態ポインタを保存する
前にロックを獲得しておかなければなりません。

     注釈: GIL を解放するのはほとんどがシステムのI/O関数を呼び出す時です
     が、メモリバッファに対する圧縮や暗号化のように、 Python のオブジェ
     クトにアクセスしない長時間かかる計算処理を呼び出すときも GIL を解放
     することは有益です。例えば、 *note zlib: 119. や *note hashlib: 5e.
     モジュールは圧縮やハッシュ計算の前に GIL を解放します。


File: python.info,  Node: Python 以外で作られたスレッド,  Next: Cautions about fork,  Prev: 拡張コード内で GIL を解放する,  Up: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock

7.9.5.2 Python 以外で作られたスレッド
.....................................

Python API を通して作られたスレッド (*note threading: d6. モジュールなど
) では自動的にスレッド状態が割り当てられて、上記のコードは正しく動きます
。しかし、(自前でスレッド管理を行う外部のライブラリなどにより)C言語でス
レッドを生成した場合、そのスレッドには GIL がなく、スレッド状態データ構
造体もないことに注意する必要があります。

このようなスレッドから Python コードを呼び出す必要がある場合 (外部のライ
ブラリからコールバックするAPIなどがよくある例です)、Python/C API を呼び
出す前に、スレッド状態データ構造体を生成し、GIL を獲得し、スレッド状態ポ
インタを保存することで、スレッドをインタプリタに登録しなければなりません
。スレッドが作業を終えたら、スレッド状態ポインタをリセットして、ロックを
解放し、最後にスレッド状態データ構造体のメモリを解放しなければなりません
。

*note PyGILState_Ensure(): 385. と *note PyGILState_Release(): 386. はこ
の処理を自動的に行います。 Cのスレッドから Python を呼び出す典型的な方法
は以下のとおりです:

     PyGILState_STATE gstate;
     gstate = PyGILState_Ensure();

     /* Perform Python actions here. */
     result = CallSomeFunction();
     /* evaluate result or handle exception */

     /* Release the thread. No Python API allowed beyond this point. */
     PyGILState_Release(gstate);

‘PyGILState_*’ 関数は、(*note Py_Initialize(): 87a. によって自動的に作ら
れる) グローバルインタプリタ1つだけが存在すると仮定する事に気をつけて下
さい。 Python は (*note Py_NewInterpreter(): 1721. を使って) 追加のイン
タプリタを作成できることに変わりはありませんが、複数インタプリタと
‘PyGILState_*’ API を混ぜて使うことはサポートされていません。


File: python.info,  Node: Cautions about fork,  Next: 高レベルAPI,  Prev: Python 以外で作られたスレッド,  Up: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock

7.9.5.3 Cautions about fork()
.............................

Another important thing to note about threads is their behaviour in the
face of the C ‘fork()’ call.  On most systems with ‘fork()’, after a
process forks only the thread that issued the fork will exist.  This has
a concrete impact both on how locks must be handled and on all stored
state in CPython's runtime.

The fact that only the "current" thread remains means any locks held by
other threads will never be released.  Python solves this for *note
os.fork(): 17c. by acquiring the locks it uses internally before the
fork, and releasing them afterwards.  In addition, it resets any *note
Lock オブジェクト: 2fb8. in the child.  When extending or embedding
Python, there is no way to inform Python of additional (non-Python)
locks that need to be acquired before or reset after a fork.  OS
facilities such as ‘pthread_atfork()’ would need to be used to
accomplish the same thing.  Additionally, when extending or embedding
Python, calling ‘fork()’ directly rather than through *note os.fork():
17c. (and returning to or calling into Python) may result in a deadlock
by one of Python's internal locks being held by a thread that is defunct
after the fork.  *note PyOS_AfterFork_Child(): 3d4. tries to reset the
necessary locks, but is not always able to.

The fact that all other threads go away also means that CPython's
runtime state there must be cleaned up properly, which *note os.fork():
17c. does.  This means finalizing all other *note PyThreadState: 758.
objects belonging to the current interpreter and all other *note
PyInterpreterState: 88b. objects.  Due to this and the special nature of
the *note "main" interpreter: 553, ‘fork()’ should only be called in
that interpreter's "main" thread, where the CPython global runtime was
originally initialized.  The only exception is if ‘exec()’ will be
called immediately after.


File: python.info,  Node: 高レベルAPI,  Next: 低レベルAPI,  Prev: Cautions about fork,  Up: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock

7.9.5.4 高レベルAPI
...................

C拡張を書いたりPythonインタプリタを埋め込むときに最も一般的に使われる型
や関数は次のとおりです:

 -- C のデータ型: type PyInterpreterState
     ' 次に属します: *note Limited API: 51e. (不透明な構造体として).'  こ
     のデータ構造体は、協調動作する多数のスレッド間で共有されている状態
     を表現します。同じインタプリタに属するスレッドはモジュール管理情報
     やその他いくつかの内部的な情報を共有しています。この構造体には公開
     (public) のメンバはありません。

     異なるインタプリタに属するスレッド間では、利用可能なメモリ、開かれ
     ているファイルデスクリプタなどといったプロセス状態を除いて、初期状
     態では何も共有されていません。GILもまた、スレッドがどのインタプリタ
     に属しているかに関わらずすべてのスレッドで共有されています。

 -- C のデータ型: type PyThreadState
     ' 次に属します: *note Limited API: 51e. (不透明な構造体として).'
     This data structure represents the state of a single thread.  The
     only public data member is:

      -- C のメンバ変数: *note PyInterpreterState: 88b. *interp

          This thread's interpreter state.

 -- C の関数: void PyEval_InitThreads ()
     ' 次に属します: *note Stable ABI: 51e.'

     Deprecated function which does nothing.

     In Python 3.6 and older, this function created the GIL if it didn't
     exist.

     バージョン 3.9 で変更: The function now does nothing.

     バージョン 3.7 で変更: この関数は *note Py_Initialize(): 87a. から
     呼び出されるようになり、わざわざ呼び出す必要はもう無くなりました。

     バージョン 3.2 で変更: この関数は *note Py_Initialize(): 87a. より
     前に呼び出すことができなくなりました。

     バージョン 3.9 で非推奨.

 -- C の関数: *note PyThreadState: 758. *PyEval_SaveThread ()
     ' 次に属します: *note Stable ABI: 51e.'  (GIL が生成されている場合)
     GILを解放して、スレッドの状態を ‘NULL’ にし、以前のスレッド状態
     (‘NULL’ にはなりません) を返します。 ロックがすでに生成されている場
     合、現在のスレッドがロックを獲得していなければなりません。

 -- C の関数: void PyEval_RestoreThread (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e.'  (GIL が生成されている場合)
     GIL を獲得して、現在のスレッド状態を 'tstate' に設定します。
     'tstate' は ‘NULL’ であってはなりません。 GIL が生成されていて、こ
     の関数を呼び出したスレッドがすでにロックを獲得している場合、デッド
     ロックに陥ります。

          注釈: Calling this function from a thread when the runtime is
          finalizing will terminate the thread, even if the thread was
          not created by Python.  You can use *note Py_IsFinalizing():
          333. or *note sys.is_finalizing(): a5d. to check if the
          interpreter is in process of being finalized before calling
          this function to avoid unwanted termination.

 -- C の関数: *note PyThreadState: 758. *PyThreadState_Get ()
     ' 次に属します: *note Stable ABI: 51e.'  現在のスレッド状態を返しま
     す。GIL を保持していなければなりません。現在のスレッド状態が ‘NULL’
     なら、(呼び出し側が ‘NULL’ チェックをしなくてすむように) この関数は
     致命的エラーを起こすようになっています。

     See also *note PyThreadState_GetUnchecked(): 34a.

 -- C の関数: *note PyThreadState: 758. *PyThreadState_GetUnchecked ()

     Similar to *note PyThreadState_Get(): 34b, 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.

     Added in version 3.13: In Python 3.5 to 3.12, the function was
     private and known as ‘_PyThreadState_UncheckedGet()’.

 -- C の関数: *note PyThreadState: 758. *PyThreadState_Swap
          (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e.'  現在のスレッド状態を
     'tstate' に指定したスレッド状態と入れ変えます。'tstate' は ‘NULL’ の
     場合があります。GIL を保持していなければならず、解放しません。

以下の関数はスレッドローカルストレージを利用していて、サブインタプリタと
の互換性がありません:

 -- C の関数: PyGILState_STATE PyGILState_Ensure ()
     ' 次に属します: *note Stable ABI: 51e.'  Pythonの状態やGILに関わら
     ず、実行中スレッドでPython C APIの呼び出しが可能となるようにします
     。この関数はスレッド内で何度でも呼び出すことができますが、必ず全て
     の呼び出しに対応して *note PyGILState_Release(): 386. を呼び出す必
     要があります。通常、 *note PyGILState_Ensure(): 385. 呼び出しと
     *note PyGILState_Release(): 386. 呼び出しの間でこれ以外のスレッド関
     連API を使用することができますが、Release()の前にスレッド状態は復元
     されていなければなりません。例えば、通常の *note
     Py_BEGIN_ALLOW_THREADS: 4769. マクロと *note Py_END_ALLOW_THREADS:
     a5c. は使用することができます。

     戻り値は *note PyGILState_Ensure(): 385. 呼び出し時のスレッド状態を
     隠蔽した"ハンドル"で、 *note PyGILState_Release(): 386. に渡して
     Pythonを同じ状態に保たなければなりません。再起呼び出しも可能ですが
     、ハンドルを共有することは 'できません' - それぞれの *note
     PyGILState_Ensure(): 385. 呼び出しでハンドルを保存し、対応する
     *note PyGILState_Release(): 386. 呼び出しで渡してください。

     関数から復帰したとき、実行中のスレッドはGILを所有していて、任意の
     Python コードを実行できます。処理の失敗は致命的なエラーです。

          注釈: Calling this function from a thread when the runtime is
          finalizing will terminate the thread, even if the thread was
          not created by Python.  You can use *note Py_IsFinalizing():
          333. or *note sys.is_finalizing(): a5d. to check if the
          interpreter is in process of being finalized before calling
          this function to avoid unwanted termination.

 -- C の関数: void PyGILState_Release (PyGILState_STATE)
     ' 次に属します: *note Stable ABI: 51e.'  獲得したすべてのリソースを
     解放します。この関数を呼び出すと、Pythonの状態は対応する *note
     PyGILState_Ensure(): 385. を呼び出す前と同じとなります (通常、この
     状態は呼び出し元でははわかりませんので、GILState APIを利用するよう
     にしてください)。

     *note PyGILState_Ensure(): 385. を呼び出す場合は、必ず同一スレッド
     内で対応する *note PyGILState_Release(): 386. を呼び出してください
     。

 -- C の関数: *note PyThreadState: 758. *PyGILState_GetThisThreadState
          ()
     ' 次に属します: *note Stable ABI: 51e.'  このスレッドの現在のスレッ
     ドの状態を取得します。これまで現在のスレッドで GILState API を使っ
     たことが無い場合は、‘NULL’ が返ります。メインスレッドで自身のスレッ
     ド状態に関する呼び出しを全くしないとしても、メインスレッドは常にス
     レッド状態の情報を持っていることに注意してください。こうなっている
     目的は主にヘルパ機能もしくは診断機能のためです。

 -- C の関数: int PyGILState_Check ()

     現在のスレッドが GILを保持しているならば ‘1’ を、そうでなければ ‘0’
     を返します。この関数はいつでもどのスレッドからでも呼び出すことがで
     きます。 Python スレッドの状態が初期化されており、現在 GIL を保持し
     ている場合にのみ ‘1’ を返します。これは主にヘルパー/診断用の関数で
     す。この関数は、例えばコールバックのコンテキストやメモリ割り当て機
     能で有益でしょう。なぜなら、 GIL がロックされていると知っていれば、
     呼び出し元は sensitive な行動を実行することができ、そうでなければ異
     なるやりかたで振る舞うことができるからです。

     Added in version 3.4.

以下のマクロは、通常末尾にセミコロンを付けずに使います; Python ソース配
布物内の使用例を見てください。

 -- C のマクロ: Py_BEGIN_ALLOW_THREADS
     ' 次に属します: *note Stable ABI: 51e.'  このマクロを展開すると ‘{
     PyThreadState *_save; _save = PyEval_SaveThread();’ になります。マ
     クロに開き波括弧が入っていることに注意してください; この波括弧は後
     で *note Py_END_ALLOW_THREADS: a5c. マクロと対応させなければなりま
     せん。マクロについての詳しい議論は上記を参照してください。

 -- C のマクロ: Py_END_ALLOW_THREADS
     ' 次に属します: *note Stable ABI: 51e.'  このマクロを展開すると
     ‘PyEval_RestoreThread(_save); }’ になります。マクロに開き波括弧が入
     っていることに注意してください; この波括弧は事前の *note
     Py_BEGIN_ALLOW_THREADS: 4769. マクロと対応していなければなりません
     。マクロについての詳しい議論は上記を参照してください。

 -- C のマクロ: Py_BLOCK_THREADS
     ' 次に属します: *note Stable ABI: 51e.'  このマクロを展開すると
     ‘PyEval_RestoreThread(_save);’ になります: 閉じ波括弧のない *note
     Py_END_ALLOW_THREADS: a5c. と同じです。

 -- C のマクロ: Py_UNBLOCK_THREADS
     ' 次に属します: *note Stable ABI: 51e.'  このマクロを展開すると
     ‘_save = PyEval_SaveThread();’ になります: 開き波括弧のない *note
     Py_BEGIN_ALLOW_THREADS: 4769. と同じです。


File: python.info,  Node: 低レベルAPI,  Prev: 高レベルAPI,  Up: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock

7.9.5.5 低レベルAPI
...................

次の全ての関数は *note Py_Initialize(): 87a. の後に呼び出さなければなり
ません。

バージョン 3.7 で変更: *note Py_Initialize(): 87a. は *note GIL: 13f. を
初期化するようになりました。

 -- C の関数: *note PyInterpreterState: 88b. *PyInterpreterState_New ()
     ' 次に属します: *note Stable ABI: 51e.'  新しいインタプリタ状態オブ
     ジェクトを生成します。GIL を保持しておく必要はありませんが、この関
     数を次々に呼び出す必要がある場合には保持しておいたほうがよいでしょ
     う。

     引数無しで *note 監査イベント: 1825.
     ‘cpython.PyInterpreterState_New’ を送出します。

 -- C の関数: void PyInterpreterState_Clear (PyInterpreterState *interp)
     ' 次に属します: *note Stable ABI: 51e.'  インタプリタ状態オブジェク
     ト内の全ての情報をリセットします。GIL を保持していなければなりませ
     ん。

     引数無しで *note 監査イベント: 1825.
     ‘cpython.PyInterpreterState_Clear’ を送出します。

 -- C の関数: void PyInterpreterState_Delete (PyInterpreterState
          *interp)
     ' 次に属します: *note Stable ABI: 51e.'  インタプリタ状態オブジェク
     トを破壊します。GIL を保持しておく必要はありません。インタプリタ状
     態は *note PyInterpreterState_Clear(): 405d. であらかじめリセットし
     ておかなければなりません。

 -- C の関数: *note PyThreadState: 758. *PyThreadState_New
          (PyInterpreterState *interp)
     ' 次に属します: *note Stable ABI: 51e.'  指定したインタプリタオブジ
     ェクトに属する新たなスレッド状態オブジェクトを生成します。GIL を保
     持しておく必要はありませんが、この関数を次々に呼び出す必要がある場
     合には保持しておいたほうがよいでしょう。

 -- C の関数: void PyThreadState_Clear (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e.'  スレッド状態オブジェクト内
     の全ての情報をリセットします。GIL を保持していなければなりません。

     バージョン 3.9 で変更: This function now calls the
     ‘PyThreadState.on_delete’ callback.  Previously, that happened in
     *note PyThreadState_Delete(): 190b.

 -- C の関数: void PyThreadState_Delete (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e.'  スレッド状態オブジェクトを
     破壊します。GIL を保持する必要はありません。スレッド状態は *note
     PyThreadState_Clear(): 1585. であらかじめリセットしておかなければな
     りません。

 -- C の関数: void PyThreadState_DeleteCurrent (void)

     Destroy the current thread state and release the global interpreter
     lock.  Like *note PyThreadState_Delete(): 190b, the global
     interpreter lock must be held.  The thread state must have been
     reset with a previous call to *note PyThreadState_Clear(): 1585.

 -- C の関数: *note PyFrameObject: 754. *PyThreadState_GetFrame
          (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Get the current frame of the Python thread state 'tstate'.

     Return a *note strong reference: 316.  Return ‘NULL’ if no frame is
     currently executing.

     See also *note PyEval_GetFrame(): 1727.

     'tstate' must not be ‘NULL’.

     Added in version 3.9.

 -- C の関数: uint64_t PyThreadState_GetID (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Get the unique thread state identifier of the Python thread state
     'tstate'.

     'tstate' must not be ‘NULL’.

     Added in version 3.9.

 -- C の関数: *note PyInterpreterState: 88b.
          *PyThreadState_GetInterpreter (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Get the interpreter of the Python thread state 'tstate'.

     'tstate' must not be ‘NULL’.

     Added in version 3.9.

 -- C の関数: void PyThreadState_EnterTracing (PyThreadState *tstate)

     Suspend tracing and profiling in the Python thread state 'tstate'.

     Resume them using the *note PyThreadState_LeaveTracing(): 720.
     function.

     Added in version 3.11.

 -- C の関数: void PyThreadState_LeaveTracing (PyThreadState *tstate)

     Resume tracing and profiling in the Python thread state 'tstate'
     suspended by the *note PyThreadState_EnterTracing(): 71f. function.

     See also *note PyEval_SetTrace(): 14a7. and *note
     PyEval_SetProfile(): 14a6. functions.

     Added in version 3.11.

 -- C の関数: *note PyInterpreterState: 88b. *PyInterpreterState_Get
          (void)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.9 より).'  Get
     the current interpreter.

     Issue a fatal error if there no current Python thread state or no
     current interpreter.  It cannot return NULL.

     呼び出し側はGILを獲得する必要があります

     Added in version 3.9.

 -- C の関数: int64_t PyInterpreterState_GetID (PyInterpreterState
          *interp)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  イ
     ンタプリタの一意な ID を返します。 処理中に何かエラーが起きたら、
     ‘-1’ が返され、エラーがセットされます。

     呼び出し側はGILを獲得する必要があります

     Added in version 3.7.

 -- C の関数: *note PyObject: 312. *PyInterpreterState_GetDict
          (PyInterpreterState *interp)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.8 より).'  イ
     ンタプリタ固有のデータを保持している辞書を返します。 この関数が
     ‘NULL’ を返した場合は、ここまでで例外は送出されておらず、呼び出し側
     はインタプリタ固有の辞書は利用できないと考えなければなりません。

     この関数は *note PyModule_GetState(): 94e. を置き換えるものではなく
     、拡張モジュールがインタプリタ固有の状態情報を格納するのに使うべき
     ものです。

     Added in version 3.8.

 -- C のデータ型: typedef *note PyObject: 312.
          *(*_PyFrameEvalFunction)(*note PyThreadState: 758. *tstate,
          *note _PyInterpreterFrame: 4b6e. *frame, int throwflag)

     Type of a frame evaluation function.

     The 'throwflag' parameter is used by the ‘throw()’ method of
     generators: if non-zero, handle the current exception.

     バージョン 3.9 で変更: The function now takes a 'tstate' parameter.

     バージョン 3.11 で変更: The 'frame' parameter changed from
     ‘PyFrameObject*’ to ‘_PyInterpreterFrame*’.

 -- C の関数: *note _PyFrameEvalFunction: 741.
          _PyInterpreterState_GetEvalFrameFunc (PyInterpreterState
          *interp)

     Get the frame evaluation function.

     See the PEP 523(1) "Adding a frame evaluation API to CPython".

     Added in version 3.9.

 -- C の関数: void _PyInterpreterState_SetEvalFrameFunc
          (PyInterpreterState *interp, _PyFrameEvalFunction eval_frame)

     Set the frame evaluation function.

     See the PEP 523(2) "Adding a frame evaluation API to CPython".

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyThreadState_GetDict ()
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  拡張モ
     ジュールがスレッド固有の状態情報を保存できるような辞書を返します。
     各々の拡張モジュールが辞書に状態情報を保存するためには唯一のキーを
     使わなければなりません。現在のスレッド状態がない時にこの関数を呼び
     出してもかまいません。この関数が ‘NULL’ を返す場合、例外はまったく
     送出されず、呼び出し側は現在のスレッド状態が利用できないと考えなけ
     ればなりません。

 -- C の関数: int PyThreadState_SetAsyncExc (unsigned long id, PyObject
          *exc)
     ' 次に属します: *note Stable ABI: 51e.'  Asynchronously raise an
     exception in a thread.  The 'id' argument is the thread id of the
     target thread; 'exc' is the exception object to be raised.  This
     function does not steal any references to 'exc'.  To prevent naive
     misuse, you must write your own C extension to call this.  Must be
     called with the GIL held.  Returns the number of thread states
     modified; this is normally one, but will be zero if the thread id
     isn't found.  If 'exc' is ‘NULL’, the pending exception (if any)
     for the thread is cleared.  This raises no exceptions.

     バージョン 3.7 で変更: 'id' 引数の型が long から unsigned long へ変
     更されました。

 -- C の関数: void PyEval_AcquireThread (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e.'  GIL を獲得し、現在のスレッ
     ド状態を 'tstate' に設定します。 'tstate' は ‘NULL’ であってはなり
     ません。ロックはあらかじめ作成されていなければなりません。この関数
     を呼び出したスレッドがすでにロックを獲得している場合、デッドロック
     に陥ります。

          注釈: Calling this function from a thread when the runtime is
          finalizing will terminate the thread, even if the thread was
          not created by Python.  You can use *note Py_IsFinalizing():
          333. or *note sys.is_finalizing(): a5d. to check if the
          interpreter is in process of being finalized before calling
          this function to avoid unwanted termination.

     バージョン 3.8 で変更: Updated to be consistent with *note
     PyEval_RestoreThread(): 383, *note Py_END_ALLOW_THREADS(): a5c, and
     *note PyGILState_Ensure(): 385, and terminate the current thread if
     called while the interpreter is finalizing.

     *note PyEval_RestoreThread(): 383. はいつでも (スレッドが初期化され
     たいないときでも) 利用可能な高レベル関数です。

 -- C の関数: void PyEval_ReleaseThread (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e.'  現在のスレッド状態をリセッ
     トして ‘NULL’ にし、GIL を解放します。ロックはあらかじめ作成されて
     いなければならず、かつ現在のスレッドが保持していなければなりません
     。'tstate' は ‘NULL’ であってはなりませんが、その値が現在のスレッド
     状態を表現しているかどうかを調べるためにだけ使われます -- もしそう
     でなければ、致命的エラーが報告されます。

     *note PyEval_SaveThread(): 382. はより高レベルな関数で常に (スレッ
     ドが初期化されていないときでも) 利用できます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0523/

   (2) https://peps.python.org/pep-0523/


File: python.info,  Node: サブインタプリタサポート,  Next: 非同期通知,  Prev: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.6 サブインタプリタサポート
------------------------------

ほとんどの場合は埋め込む Python インタプリタは1つだけですが、いくつかの
場合に同一プロセス内、あるいは同一スレッド内で、複数の独立したインタプリ
タを作成する必要があります。 これを可能にするのがサブインタプリタです。

"メイン" インタプリタとは、ランタイムが初期化を行ったときに最初に作成さ
れたインタプリタのことです。 サブインタプリタと違い、メインインタプリタ
にはシグナルハンドリングのような、プロセス全域で唯一な責務があります。 メ
インインタプリタにはランタイムの初期化中の処理実行という責務もあり、通常
はランタイムの終了処理中に動いているランタイムでもあります。 *note
PyInterpreterState_Main(): 4bdf. 関数は、メインインタプリタの状態へのポ
インタを返します。

サブインタプリタを切り替えが *note PyThreadState_Swap(): 48e2. 関数でで
きます。 次の関数を使ってサブインタプリタの作成と削除が行えます:

 -- C のデータ型: type PyInterpreterConfig

     Structure containing most parameters to configure a
     sub-interpreter.  Its values are used only in *note
     Py_NewInterpreterFromConfig(): 428. and never modified by the
     runtime.

     Added in version 3.12.

     構造体フィールド:

      -- C のメンバ変数: int use_main_obmalloc

          If this is ‘0’ then the sub-interpreter will use its own
          "object" allocator state.  Otherwise it will use (share) the
          main interpreter's.

          If this is ‘0’ then *note check_multi_interp_extensions: 4be0.
          must be ‘1’ (non-zero).  If this is ‘1’ then *note gil: 4be1.
          must not be *note PyInterpreterConfig_OWN_GIL: 4be2.

      -- C のメンバ変数: int allow_fork

          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.

          Note that the *note subprocess: c1. module still works when
          fork is disallowed.

      -- C のメンバ変数: int allow_exec

          If this is ‘0’ then the runtime will not support replacing the
          current process via exec (e.g.  *note os.execv(): 2a77.) in
          any thread where the sub-interpreter is currently active.
          Otherwise exec is unrestricted.

          Note that the *note subprocess: c1. module still works when
          exec is disallowed.

      -- C のメンバ変数: int allow_threads

          If this is ‘0’ then the sub-interpreter's *note threading: d6.
          module won't create threads.  Otherwise threads are allowed.

      -- C のメンバ変数: int allow_daemon_threads

          If this is ‘0’ then the sub-interpreter's *note threading: d6.
          module won't create daemon threads.  Otherwise daemon threads
          are allowed (as long as *note allow_threads: 4be5. is
          non-zero).

      -- C のメンバ変数: int check_multi_interp_extensions

          If this is ‘0’ then all extension modules may be imported,
          including legacy (single-phase init) modules, in any thread
          where the sub-interpreter is currently active.  Otherwise only
          multi-phase init extension modules (see PEP 489(1)) may be
          imported.  (Also see *note Py_mod_multiple_interpreters:
          4b44.)

          This must be ‘1’ (non-zero) if *note use_main_obmalloc: 41f9.
          is ‘0’.

      -- C のメンバ変数: int gil

          This determines the operation of the GIL for the
          sub-interpreter.  It may be one of the following:

           -- C のマクロ: PyInterpreterConfig_DEFAULT_GIL

               Use the default selection (*note
               PyInterpreterConfig_SHARED_GIL: 4be8.).

           -- C のマクロ: PyInterpreterConfig_SHARED_GIL

               Use (share) the main interpreter's GIL.

           -- C のマクロ: PyInterpreterConfig_OWN_GIL

               Use the sub-interpreter's own GIL.

          If this is *note PyInterpreterConfig_OWN_GIL: 4be2. then *note
          PyInterpreterConfig.use_main_obmalloc: 41f9. must be ‘0’.

 -- C の関数: *note PyStatus: 97b. Py_NewInterpreterFromConfig
          (PyThreadState **tstate_p, const PyInterpreterConfig *config)

     新しいサブインタプリタ (sub-interpreter) を生成します。サブインタプ
     リタとは、(ほぼ完全に) 個別に分割された Python コードの実行環境です
     。特に、新しいサブインタプリタは、 import されるモジュール全てにつ
     いて個別のバージョンを持ち、これには基盤となるモジュール *note
     builtins: e, *note __main__: 1. および *note sys: c3. も含まれます
     。ロード済みのモジュールからなるテーブル (‘sys.modules’) およびモジ
     ュール検索パス (‘sys.path’) もサブインタプリタ毎に別個のものになり
     ます。新たなサブインタプリタ環境には ‘sys.argv’ 変数がありません。
     また、サブインタプリタは新たな標準 I/O ストリーム ‘sys.stdin’,
     ‘sys.stdout’, ‘sys.stderr’ を持ちます (とはいえ、これらのストリーム
     は根底にある同じファイル記述子を参照しています)。

     The given 'config' controls the options with which the interpreter
     is initialized.

     Upon success, 'tstate_p' will be set to the first thread state
     created in the new sub-interpreter.  This thread state is made in
     the current thread state.  Note that no actual thread is created;
     see the discussion of thread states below.  If creation of the new
     interpreter is unsuccessful, 'tstate_p' is set to ‘NULL’; no
     exception is set since the exception state is stored in the current
     thread state and there may not be a current thread state.

     Like all other Python/C API functions, the global interpreter lock
     must be held before calling this function and is still held when it
     returns.  Likewise a current thread state must be set on entry.  On
     success, the returned thread state will be set as current.  If the
     sub-interpreter is created with its own GIL then the GIL of the
     calling interpreter will be released.  When the function returns,
     the new interpreter's GIL will be held by the current thread and
     the previously interpreter's GIL will remain released here.

     Added in version 3.12.

     Sub-interpreters are most effective when isolated from each other,
     with certain functionality restricted:

          PyInterpreterConfig config = {
              .use_main_obmalloc = 0,
              .allow_fork = 0,
              .allow_exec = 0,
              .allow_threads = 1,
              .allow_daemon_threads = 0,
              .check_multi_interp_extensions = 1,
              .gil = PyInterpreterConfig_OWN_GIL,
          };
          PyThreadState *tstate = Py_NewInterpreterFromConfig(&config);

     Note that the config is used only briefly and does not get
     modified.  During initialization the config's values are converted
     into various *note PyInterpreterState: 88b. values.  A read-only
     copy of the config may be stored internally on the *note
     PyInterpreterState: 88b.

     Extension modules are shared between (sub-)interpreters as follows:

        * For modules using multi-phase initialization, e.g.  *note
          PyModule_FromDefAndSpec(): e7b, a separate module object is
          created and initialized for each interpreter.  Only C-level
          static and global variables are shared between these module
          objects.

        * For modules using single-phase initialization, e.g.  *note
          PyModule_Create(): 4750, the first time a particular extension
          is imported, it is initialized normally, and a (shallow) copy
          of its module's dictionary is squirreled away.  When the same
          extension is imported by another (sub-)interpreter, a new
          module is initialized and filled with the contents of this
          copy; the extension's ‘init’ function is not called.  Objects
          in the module's dictionary thus end up shared across
          (sub-)interpreters, which might cause unwanted behavior (see
          *note Bugs and caveats: 4be9. below).

          Note that this is different from what happens when an
          extension is imported after the interpreter has been
          completely re-initialized by calling *note Py_FinalizeEx():
          ce3. and *note Py_Initialize(): 87a.; in that case, the
          extension's ‘initmodule’ function 'is' called again.  As with
          multi-phase initialization, this means that only C-level
          static and global variables are shared between these modules.

 -- C の関数: *note PyThreadState: 758. *Py_NewInterpreter (void)
     ' 次に属します: *note Stable ABI: 51e.'

     Create a new sub-interpreter.  This is essentially just a wrapper
     around *note Py_NewInterpreterFromConfig(): 428. with a config that
     preserves the existing behavior.  The result is an unisolated
     sub-interpreter that shares the main interpreter's GIL, allows
     fork/exec, allows daemon threads, and allows single-phase init
     modules.

 -- C の関数: void Py_EndInterpreter (PyThreadState *tstate)
     ' 次に属します: *note Stable ABI: 51e.'

     Destroy the (sub-)interpreter represented by the given thread
     state.  The given thread state must be the current thread state.
     See the discussion of thread states below.  When the call returns,
     the current thread state is ‘NULL’.  All thread states associated
     with this interpreter are destroyed.  The global interpreter lock
     used by the target interpreter must be held before calling this
     function.  No GIL is held when it returns.

     *note Py_FinalizeEx(): ce3. will destroy all sub-interpreters that
     haven't been explicitly destroyed at that point.

* Menu:

* A Per-Interpreter GIL::
* バグと注意事項::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0489/


File: python.info,  Node: A Per-Interpreter GIL,  Next: バグと注意事項,  Up: サブインタプリタサポート

7.9.6.1 A Per-Interpreter GIL
.............................

Using *note Py_NewInterpreterFromConfig(): 428. you can create a
sub-interpreter that is completely isolated from other interpreters,
including having its own GIL. The most important benefit of this
isolation is that such an interpreter can execute Python code without
being blocked by other interpreters or blocking any others.  Thus a
single Python process can truly take advantage of multiple CPU cores
when running Python code.  The isolation also encourages a different
approach to concurrency than that of just using threads.  (See PEP
554(1).)

Using an isolated interpreter requires vigilance in preserving that
isolation.  That especially means not sharing any objects or mutable
state without guarantees about thread-safety.  Even objects that are
otherwise immutable (e.g.  ‘None’, ‘(1, 5)’) can't normally be shared
because of the refcount.  One simple but less-efficient approach around
this is to use a global lock around all use of some state (or object).
Alternately, effectively immutable objects (like integers or strings)
can be made safe in spite of their refcounts by making them *note
immortal: 41f8.  In fact, this has been done for the builtin singletons,
small integers, and a number of other builtin objects.

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.

Aside from that, one of the main challenges of using multiple isolated
interpreters is how to communicate between them safely (not break
isolation) and efficiently.  The runtime and stdlib do not provide any
standard approach to this yet.  A future stdlib module would help
mitigate the effort of preserving isolation and expose effective tools
for communicating (and sharing) data between interpreters.

Added in version 3.12.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0554/


File: python.info,  Node: バグと注意事項,  Prev: A Per-Interpreter GIL,  Up: サブインタプリタサポート

7.9.6.2 バグと注意事項
......................

Because sub-interpreters (and the main interpreter) are part of the same
process, the insulation between them isn't perfect -- for example, using
low-level file operations like *note os.close(): b42. they can
(accidentally or maliciously) affect each other's open files.  Because
of the way extensions are shared between (sub-)interpreters, some
extensions may not work properly; this is especially likely when using
single-phase initialization or (static) global variables.  It is
possible to insert objects created in one sub-interpreter into a
namespace of another (sub-)interpreter; this should be avoided if
possible.

Special care should be taken to avoid sharing user-defined functions,
methods, instances or classes between sub-interpreters, since import
operations executed by such objects may affect the wrong
(sub-)interpreter's dictionary of loaded modules.  It is equally
important to avoid sharing objects from which the above are reachable.

サブインタプリタを ‘PyGILState_*’ API と組み合わせるのが難しいことにも注
意してください。これらのAPIはPythonのスレッド状態とOSレベルスレッドが1対
1で対応していることを前提にしていて、サブインタプリタが存在するとその前
提が崩れるからです。対応する *note PyGILState_Ensure(): 385. と *note
PyGILState_Release(): 386. の呼び出しのペアの間では、サブインタプリタの
切り替えを行わないことを強く推奨します。さらに、(*note ctypes: 22. のよ
うな)これらのAPIを使ってPythonの外で作られたスレッドから Pythonコードを
実行している拡張モジュールはサブインタプリタを使うと壊れる可能性がありま
す。


File: python.info,  Node: 非同期通知,  Next: プロファイルとトレース profiling and tracing,  Prev: サブインタプリタサポート,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.7 非同期通知
----------------

インタプリタのメインスレッドに非同期な通知を行うために提供されている仕組
みです。これらの通知は関数ポインタと void ポインタ引数という形態を取りま
す。

 -- C の関数: int Py_AddPendingCall (int (*func)(void*), void *arg)
     ' 次に属します: *note Stable ABI: 51e.'  インタプリタのメインスレッ
     ドから関数が呼び出される予定を組みます。成功すると ‘0’ が返り、
     'func' はメインスレッドの呼び出しキューに詰められます。失敗すると、
     例外をセットせずに ‘-1’ が返ります。

     無事にキューに詰められると、'func' は 'いつかは必ず' インタプリタの
     メインスレッドから、'arg' を引数として呼び出されます。この関数は、
     通常の実行中の Python コードに対して非同期に呼び出されますが、次の
     両方の条件に合致したときに呼び出されます:

        * *note bytecode: 16c. 境界上にいるとき、

        * メインスレッドが *note global interpreter lock: 12e. を保持し
          ている (すなわち 'func' が全ての C API を呼び出せる) とき。

     成功したら 'func' は ‘0’ を返さねばならず、失敗したら ‘-1’ を返し例
     外をセットしなければいけません。'func' は、他の非同期通知を行うため
     に、さらに割り込まれることはありませんが、グローバルインタプリタロ
     ックが解放された場合は、スレッドの切り替えによって割り込まれる可能
     性が残っています。

     この関数は実行するのに現在のスレッド状態を必要とせず、グローバルイ
     ンタプリタロックも必要としません。

     To call this function in a subinterpreter, the caller must hold the
     GIL. Otherwise, the function 'func' can be scheduled to be called
     from the wrong interpreter.

          警告: これは、非常に特別な場合にのみ役立つ、低レベルな関数です
          。 'func' が可能な限り早く呼び出される保証はありません。メイン
          スレッドがシステムコールを実行するのに忙しい場合は、 'func' は
          システムコールが返ってくるまで呼び出されないでしょう。この関数
          は一般的には、任意の C スレッドから Python コードを呼び出すの
          には '向きません' 。これの代わりに、 *note PyGILState API:
          4bd7. を使用してください。

     Added in version 3.1.

     バージョン 3.9 で変更: 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.


File: python.info,  Node: プロファイルとトレース profiling and tracing,  Next: Reference tracing,  Prev: 非同期通知,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.8 プロファイルとトレース (profiling and tracing)
----------------------------------------------------

Python インタプリタは、プロファイル: 分析 (profile) や実行のトレース: 追
跡 (trace) といった機能を組み込むために低水準のサポートを提供しています
。このサポートは、プロファイルやデバッグ、適用範囲分析 (coverage
analysis) ツールなどに使われます。

この C インターフェースは、プロファイルやトレース作業時に、Python レベル
の呼び出し可能オブジェクトが呼び出されることによるオーバヘッドを避け、直
接 C 関数呼び出しが行えるようにしています。プロファイルやトレース機能の
本質的な特性は変わっていません; インターフェースではトレース関数をスレッ
ドごとにインストールでき、トレース関数に報告される基本イベント (basic
event) は以前のバージョンにおいて Python レベルのトレース関数で報告され
ていたものと同じです。

 -- C のデータ型: typedef int (*Py_tracefunc)(*note PyObject: 312. *obj,
          *note PyFrameObject: 754. *frame, int what, *note PyObject:
          312. *arg)

     The type of the trace function registered using *note
     PyEval_SetProfile(): 14a6. and *note PyEval_SetTrace(): 14a7.  The
     first parameter is the object passed to the registration function
     as 'obj', 'frame' is the frame object to which the event pertains,
     'what' is one of the constants *note PyTrace_CALL: 4bef, *note
     PyTrace_EXCEPTION: 4bf0, *note PyTrace_LINE: 4bf1, *note
     PyTrace_RETURN: 4bf2, *note PyTrace_C_CALL: 4bf3, *note
     PyTrace_C_EXCEPTION: 4bf4, *note PyTrace_C_RETURN: 4bf5, or *note
     PyTrace_OPCODE: 4bf6, and 'arg' depends on the value of 'what':

     'what' の値                         'arg' の意味
                                         
     ---------------------------------------------------------------------------------
                                         
     *note PyTrace_CALL: 4bef.           常に *note Py_None: 474c. 。
                                         
                                         
     *note PyTrace_EXCEPTION: 4bf0.      *note sys.exc_info(): 656. の返す例外情報
                                         です。
                                         
                                         
     *note PyTrace_LINE: 4bf1.           常に *note Py_None: 474c. 。
                                         
                                         
     *note PyTrace_RETURN: 4bf2.         呼び出し側に返される予定の値か、例外によっ
                                         て関数を抜ける場合は ‘NULL’ です。
                                         
                                         
     *note PyTrace_C_CALL: 4bf3.         呼び出される関数オブジェクト。
                                         
                                         
     *note PyTrace_C_EXCEPTION: 4bf4.    呼び出される関数オブジェクト。
                                         
                                         
     *note PyTrace_C_RETURN: 4bf5.       呼び出される関数オブジェクト。
                                         
                                         
     *note PyTrace_OPCODE: 4bf6.         常に *note Py_None: 474c. 。
                                         

 -- C 変数: int PyTrace_CALL

     関数やメソッドが新たに呼び出されたり、ジェネレータが新たなエントリ
     の処理に入ったことを報告する際の、 *note Py_tracefunc: 4bee. の
     'what' の値です。イテレータやジェネレータ関数の生成は、対応するフレ
     ーム内の Python バイトコードに制御の委譲 (control transfer) が起こ
     らないため報告されないので注意してください。

 -- C 変数: int PyTrace_EXCEPTION

     例外が送出された際の *note Py_tracefunc: 4bee. の 'what' の値です。
     現在実行されているフレームで例外がセットされ、何らかのバイトコード
     が処理された後に、 'what' にこの値がセットされた状態でコールバック
     関数が呼び出されます。この結果、例外の伝播によって Python が呼び出
     しスタックを逆戻りする際に、各フレームから処理が戻るごとにコールバ
     ック関数が呼び出されます。トレース関数だけがこれらのイベントを受け
     取ります; プロファイラはこの種のイベントを必要としません。

 -- C 変数: int PyTrace_LINE

     The value passed as the 'what' parameter to a *note Py_tracefunc:
     4bee. function (but not a profiling function) when a line-number
     event is being reported.  It may be disabled for a frame by setting
     *note f_trace_lines: ba9. to '0' on that frame.

 -- C 変数: int PyTrace_RETURN

     呼び出しが返るときに *note Py_tracefunc: 4bee. 関数に 'what' 引数と
     して渡す値です。

 -- C 変数: int PyTrace_C_CALL

     C関数を呼び出す直前に *note Py_tracefunc: 4bee. 関数の 'what' 引数
     として渡す値です。

 -- C 変数: int PyTrace_C_EXCEPTION

     C関数が例外を送出したときに *note Py_tracefunc: 4bee. 関数の 'what'
     引数として渡す値です。

 -- C 変数: int PyTrace_C_RETURN

     C関数から戻るときに *note Py_tracefunc: 4bee. 関数の 'what' 引数と
     して渡す値です。

 -- C 変数: int PyTrace_OPCODE

     The value for the 'what' parameter to *note Py_tracefunc: 4bee.
     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 *note f_trace_opcodes: baa. to '1'
     on the frame.

 -- C の関数: void PyEval_SetProfile (Py_tracefunc func, PyObject *obj)

     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’.  If the profile function needs to maintain
     state, using a different value for 'obj' for each thread provides a
     convenient and thread-safe place to store it.  The profile function
     is called for all monitored events except *note PyTrace_LINE: 4bf1.
     *note PyTrace_OPCODE: 4bf6. and *note PyTrace_EXCEPTION: 4bf0.

     *note sys.setprofile(): 14a8. 関数も参照してください。

     呼び出し側は *note GIL: 13f. を獲得しなければなりません。

 -- C の関数: void PyEval_SetProfileAllThreads (Py_tracefunc func,
          PyObject *obj)

     Like *note PyEval_SetProfile(): 14a6. but sets the profile function
     in all running threads belonging to the current interpreter instead
     of the setting it only on the current thread.

     呼び出し側は *note GIL: 13f. を獲得しなければなりません。

     As *note PyEval_SetProfile(): 14a6, this function ignores any
     exceptions raised while setting the profile functions in all
     threads.

Added in version 3.12.

 -- C の関数: void PyEval_SetTrace (Py_tracefunc func, PyObject *obj)

     Set the tracing function to 'func'.  This is similar to *note
     PyEval_SetProfile(): 14a6, except the tracing function does receive
     line-number events and per-opcode events, but does not receive any
     event related to C function objects being called.  Any trace
     function registered using *note PyEval_SetTrace(): 14a7. will not
     receive *note PyTrace_C_CALL: 4bf3, *note PyTrace_C_EXCEPTION:
     4bf4. or *note PyTrace_C_RETURN: 4bf5. as a value for the 'what'
     parameter.

     *note sys.settrace(): 14a9. 関数も参照してください。

     呼び出し側は *note GIL: 13f. を獲得しなければなりません。

 -- C の関数: void PyEval_SetTraceAllThreads (Py_tracefunc func,
          PyObject *obj)

     Like *note PyEval_SetTrace(): 14a7. but sets the tracing function
     in all running threads belonging to the current interpreter instead
     of the setting it only on the current thread.

     呼び出し側は *note GIL: 13f. を獲得しなければなりません。

     As *note PyEval_SetTrace(): 14a7, this function ignores any
     exceptions raised while setting the trace functions in all threads.

Added in version 3.12.


File: python.info,  Node: Reference tracing,  Next: 高度なデバッガサポート advanced debugger support,  Prev: プロファイルとトレース profiling and tracing,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.9 Reference tracing
-----------------------

Added in version 3.13.

 -- C のデータ型: typedef int (*PyRefTracer)(*note PyObject: 312.*, int
          event, void *data)

     The type of the trace function registered using *note
     PyRefTracer_SetTracer(): 345.  The first parameter is a Python
     object that has been just created (when 'event' is set to *note
     PyRefTracer_CREATE: 4bf9.) or about to be destroyed (when 'event'
     is set to *note PyRefTracer_DESTROY: 4bfa.).  The 'data' argument
     is the opaque pointer that was provided when *note
     PyRefTracer_SetTracer(): 345. was called.

Added in version 3.13.

 -- C 変数: int PyRefTracer_CREATE

     The value for the 'event' parameter to *note PyRefTracer: 4bf8.
     functions when a Python object has been created.

 -- C 変数: int PyRefTracer_DESTROY

     The value for the 'event' parameter to *note PyRefTracer: 4bf8.
     functions when a Python object has been destroyed.

 -- C の関数: int PyRefTracer_SetTracer (PyRefTracer tracer, void *data)

     Register a reference tracer function.  The function will be called
     when a new Python has been created or when an object is going to be
     destroyed.  If 'data' is provided it must be an opaque pointer that
     will be provided when the tracer function is called.  Return ‘0’ on
     success.  Set an exception and return ‘-1’ on error.

     Not 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.  The GIL
     will be held every time the tracer function is called.

     The GIL must be held when calling this function.

Added in version 3.13.

 -- C の関数: *note PyRefTracer: 4bf8. PyRefTracer_GetTracer (void
          **data)

     Get the registered reference tracer function and the value of the
     opaque data pointer that was registered when *note
     PyRefTracer_SetTracer(): 345. was called.  If no tracer was
     registered this function will return NULL and will set the 'data'
     pointer to NULL.

     The GIL must be held when calling this function.

Added in version 3.13.


File: python.info,  Node: 高度なデバッガサポート advanced debugger support,  Next: スレッドローカルストレージのサポート,  Prev: Reference tracing,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.10 高度なデバッガサポート (advanced debugger support)
---------------------------------------------------------

以下の関数は高度なデバッグツールでの使用のためだけのものです。

 -- C の関数: *note PyInterpreterState: 88b. *PyInterpreterState_Head ()

     インタプリタ状態オブジェクトからなるリストのうち、先頭にあるものを
     返します。

 -- C の関数: *note PyInterpreterState: 88b. *PyInterpreterState_Main ()

     メインインタプリタの状態オブジェクトを返します。

 -- C の関数: *note PyInterpreterState: 88b. *PyInterpreterState_Next
          (PyInterpreterState *interp)

     インタプリタ状態オブジェクトからなるリストのうち、'interp' の次にあ
     るものを返します。

 -- C の関数: *note PyThreadState: 758. *PyInterpreterState_ThreadHead
          (PyInterpreterState *interp)

     インタプリタ 'interp' に関連付けられているスレッドからなるリストの
     うち、先頭にある *note PyThreadState: 758. オブジェクトを返します。

 -- C の関数: *note PyThreadState: 758. *PyThreadState_Next
          (PyThreadState *tstate)

     'tstate' と同じ *note PyInterpreterState: 88b. オブジェクトに属して
     いるスレッド状態オブジェクトのうち、 'tstate' の次にあるものを返し
     ます。


File: python.info,  Node: スレッドローカルストレージのサポート,  Next: 同期プリミティブ<3>,  Prev: 高度なデバッガサポート advanced debugger support,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.11 スレッドローカルストレージのサポート
-------------------------------------------

Python インタプリタは、スレッドローカルストレージ (thread-local storage,
TLS) の低レベルサポートを提供していて、ネイティブの TLS 実装を内部にラッ
プして Python レベルのスレッドローカルストレージ API (*note
threading.local: 16d6.) をサポートしています。 CPython の C レベル API は
pthreads や Windows で与えられる TLS と同様です: スレッドキーとスレッド
ごとに void* 値を関係付ける関数を使います。

API で使われる関数を呼ぶときは、 GIL を取得する必要は 'ありません' 。関
数自身のロックがサポートされています。

‘Python.h’ は TLS API の宣言を include せず、スレッドローカルストレージ
を使うには ‘pythread.h’ を include する必要があることに注意してください
。

     注釈: この API 関数はどれも void* 値の代わりにメモリ管理を行うこと
     はしません。 メモリの確保と解放は自前で行う必要があります。 void* 値
     がたまたま *note PyObject: 312.* だった場合は、 API 関数はそれぞれ
     の値の参照カウントの操作は行いません。

* Menu:

* スレッド固有ストレージ (Thread Specific Storage, TSS) API: スレッド固有ストレージ Thread Specific Storage TSS API.
* スレッドローカルストレージ (TLS) API: スレッドローカルストレージ TLS API.


File: python.info,  Node: スレッド固有ストレージ Thread Specific Storage TSS API,  Next: スレッドローカルストレージ TLS API,  Up: スレッドローカルストレージのサポート

7.9.11.1 スレッド固有ストレージ (Thread Specific Storage, TSS) API
..................................................................

TSS API は、 CPython インタプリタに含まれている既存の TLS API を置き換え
るために導入されました。 この API は、スレッドキーの表現に int の代わり
に新しい型 *note Py_tss_t: aad. を使います。

Added in version 3.7.

参考
....

"CPython のスレッドローカルストレージのための新しい C API" ( PEP 539(1))

 -- C のデータ型: type Py_tss_t

     このデータ構造体はスレッドキーの状態を表現しています。この構造体の
     定義は、根底の TLS 実装に依存し、キーの初期化状態を表現する内部フィ
     ールドを持ちます。 この構造体には公開 (public) のメンバはありません
     。

     *note Py_LIMITED_API: 51e. が定義されていないときは、この型の *note
     Py_tss_NEEDS_INIT: 4c00. による静的メモリ確保ができます。

 -- C のマクロ: Py_tss_NEEDS_INIT

     このマクロは *note Py_tss_t: aad. 変数の初期化子に展開されます。 こ
     のマクロは *note Py_LIMITED_API: 51e. があるときは定義されません。

* Menu:

* 動的メモリ確保::
* メソッド: メソッド<2>.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0539/


File: python.info,  Node: 動的メモリ確保,  Next: メソッド<2>,  Up: スレッド固有ストレージ Thread Specific Storage TSS API

7.9.11.2 動的メモリ確保
.......................

動的な *note Py_tss_t: aad. のメモリ確保は *note Py_LIMITED_API: 51e. で
ビルドされた拡張モジュールで必要になりますが、その実装がビルド時に不透明
なために、この型の静的なメモリ確保は不可能です。

 -- C の関数: *note Py_tss_t: aad. *PyThread_tss_alloc ()
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     Return a value which is the same state as a value initialized with
     *note Py_tss_NEEDS_INIT: 4c00, or ‘NULL’ in the case of dynamic
     allocation failure.

 -- C の関数: void PyThread_tss_free (Py_tss_t *key)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     Free the given 'key' allocated by *note PyThread_tss_alloc(): 3de,
     after first calling *note PyThread_tss_delete(): 3e6. to ensure any
     associated thread locals have been unassigned.  This is a no-op if
     the 'key' argument is ‘NULL’.

          注釈: A freed key becomes a dangling pointer.  You should
          reset the key to ‘NULL’.


File: python.info,  Node: メソッド<2>,  Prev: 動的メモリ確保,  Up: スレッド固有ストレージ Thread Specific Storage TSS API

7.9.11.3 メソッド
.................

The parameter 'key' of these functions must not be ‘NULL’.  Moreover,
the behaviors of *note PyThread_tss_set(): 3e2. and *note
PyThread_tss_get(): 3e4. are undefined if the given *note Py_tss_t: aad.
has not been initialized by *note PyThread_tss_create(): 48e3.

 -- C の関数: int PyThread_tss_is_created (Py_tss_t *key)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     Return a non-zero value if the given *note Py_tss_t: aad. has been
     initialized by *note PyThread_tss_create(): 48e3.

 -- C の関数: int PyThread_tss_create (Py_tss_t *key)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     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 initialized by *note Py_tss_NEEDS_INIT: 4c00.  This function
     can be called repeatedly on the same key - calling it on an already
     initialized key is a no-op and immediately returns success.

 -- C の関数: void PyThread_tss_delete (Py_tss_t *key)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     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 destroyed key is able to be initialized again by
     *note PyThread_tss_create(): 48e3.  This function can be called
     repeatedly on the same key - calling it on an already destroyed key
     is a no-op.

 -- C の関数: int PyThread_tss_set (Py_tss_t *key, void *value)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     Return a zero value to indicate successfully associating a void*
     value with a TSS key in the current thread.  Each thread has a
     distinct mapping of the key to a void* value.

 -- C の関数: void *PyThread_tss_get (Py_tss_t *key)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'
     Return the 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.


File: python.info,  Node: スレッドローカルストレージ TLS API,  Prev: スレッド固有ストレージ Thread Specific Storage TSS API,  Up: スレッドローカルストレージのサポート

7.9.11.4 スレッドローカルストレージ (TLS) API
.............................................

バージョン 3.7 で非推奨: This API is superseded by *note Thread Specific
Storage (TSS) API: aac.

     注釈: 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 platforms, *note PyThread_create_key(): 3dd. will
     return immediately with a failure status, and the other TLS
     functions will all be no-ops on such platforms.

前述の互換性の問題により、このバージョンのAPIは新規のコードで利用すべき
ではありません。

 -- C の関数: int PyThread_create_key ()
     ' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: void PyThread_delete_key (int key)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: int PyThread_set_key_value (int key, void *value)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: void *PyThread_get_key_value (int key)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: void PyThread_delete_key_value (int key)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C の関数: void PyThread_ReInitTLS ()
     ' 次に属します: *note Stable ABI: 51e.'


File: python.info,  Node: 同期プリミティブ<3>,  Prev: スレッドローカルストレージのサポート,  Up: 初期化 initialization 、終了処理 finalization 、スレッド

7.9.12 同期プリミティブ
-----------------------

The C-API provides a basic mutual exclusion lock.

 -- C のデータ型: type PyMutex

     A mutual exclusion lock.  The ‘PyMutex’ should be initialized to
     zero to represent the unlocked state.  For example:

          PyMutex mutex = {0};

     Instances of ‘PyMutex’ should not be copied or moved.  Both the
     contents and address of a ‘PyMutex’ are meaningful, and it must
     remain at a fixed, writable location in memory.

          注釈: A ‘PyMutex’ currently occupies one byte, but the size
          should be considered unstable.  The size may change in future
          Python releases without a deprecation period.

     Added in version 3.13.

 -- C の関数: void PyMutex_Lock (PyMutex *m)

     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 release the *note GIL: 13f. if
     it is held.

     Added in version 3.13.

 -- C の関数: void PyMutex_Unlock (PyMutex *m)

     Unlock mutex 'm'.  The mutex must be locked -- otherwise, the
     function will issue a fatal error.

     Added in version 3.13.

* Menu:

* Python Critical Section API::


File: python.info,  Node: Python Critical Section API,  Up: 同期プリミティブ<3>

7.9.12.1 Python Critical Section API
....................................

The critical section API provides a deadlock avoidance layer on top of
per-object locks for *note free-threaded: 433e. CPython.  They are
intended to replace reliance on the *note global interpreter lock: 12e,
and are no-ops in versions of Python with the global interpreter lock.

Critical sections avoid deadlocks by implicitly suspending active
critical sections and releasing the locks during calls to *note
PyEval_SaveThread(): 382.  When *note PyEval_RestoreThread(): 383. is
called, the most recent critical section is resumed, and its locks
reacquired.  This means the critical section API provides weaker
guarantees than traditional locks - they are useful because their
behavior is similar to the *note GIL: 13f.

The functions and structs used by the macros are exposed for cases where
C macros are not available.  They should only be used as in the given
macro expansions.  Note that the sizes and contents of the structures
may change in future Python versions.

     注釈: Operations that need to lock two objects at once must use
     *note Py_BEGIN_CRITICAL_SECTION2: 4c07.  You 'cannot' use nested
     critical sections to lock more than one object at once, because the
     inner critical section may suspend the outer critical sections.
     This API does not provide a way to lock more than two objects at
     once.

使用例:

     static PyObject *
     set_field(MyObject *self, PyObject *value)
     {
        Py_BEGIN_CRITICAL_SECTION(self);
        Py_SETREF(self->field, Py_XNewRef(value));
        Py_END_CRITICAL_SECTION();
        Py_RETURN_NONE;
     }

In the above example, *note Py_SETREF: 545. calls *note Py_DECREF: 53b,
which can call arbitrary code through an object's deallocation function.
The critical section API avoids potential deadlocks due to reentrancy
and lock ordering by allowing the runtime to temporarily suspend the
critical section if the code triggered by the finalizer blocks and calls
*note PyEval_SaveThread(): 382.

 -- C のマクロ: Py_BEGIN_CRITICAL_SECTION (op)

     Acquires the per-object lock for the object 'op' and begins a
     critical section.

     In the free-threaded build, this macro expands to:

          {
              PyCriticalSection _py_cs;
              PyCriticalSection_Begin(&_py_cs, (PyObject*)(op))

     In the default build, this macro expands to ‘{’.

     Added in version 3.13.

 -- C のマクロ: Py_END_CRITICAL_SECTION ()

     Ends the critical section and releases the per-object lock.

     In the free-threaded build, this macro expands to:

              PyCriticalSection_End(&_py_cs);
          }

     In the default build, this macro expands to ‘}’.

     Added in version 3.13.

 -- C のマクロ: Py_BEGIN_CRITICAL_SECTION2 (a, b)

     Acquires the per-objects 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.

     In the free-threaded build, this macro expands to:

          {
              PyCriticalSection2 _py_cs2;
              PyCriticalSection_Begin2(&_py_cs2, (PyObject*)(a), (PyObject*)(b))

     In the default build, this macro expands to ‘{’.

     Added in version 3.13.

 -- C のマクロ: Py_END_CRITICAL_SECTION2 ()

     Ends the critical section and releases the per-object locks.

     In the free-threaded build, this macro expands to:

              PyCriticalSection_End2(&_py_cs2);
          }

     In the default build, this macro expands to ‘}’.

     Added in version 3.13.


File: python.info,  Node: Python 初期化設定,  Next: メモリ管理,  Prev: 初期化 initialization 、終了処理 finalization 、スレッド,  Up: Python/C API リファレンスマニュアル

7.10 Python 初期化設定
======================

Added in version 3.8.

Pythonは *note Py_InitializeFromConfig(): 39f. と *note PyConfig: 380. 構
造体を使って初期化できます。*note Py_PreInitialize(): 3c5. と *note
PyPreConfig: 97a. 構造体によって事前に初期化できます。

設定には二つの種類があります:

   * *note Python Configuration: 4bd2. は、通常の Python と同じ振る舞い
     をするカスタマイズされた Python を構築するために使用されます。例え
     ば、環境変数やコマンドライン引数がPythonを設定するために使用されま
     す。

   * The *note Isolated Configuration: 4c0c. 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.

The *note Py_RunMain(): 993. function can be used to write a customized
Python program.

*note Initialization, Finalization, and Threads: 4bc5. も参照してくださ
い。

参考
....

PEP 587(1) "Python 初期化設定"

* Menu:

* 使用例: 使用例<53>.
* PyWideStringList::
* PyStatus::
* PyPreConfig::
* Preinitialize Python with PyPreConfig::
* PyConfig::
* Initialization with PyConfig::
* Isolated Configuration::
* Python Configuration::
* Python Path Configuration::
* Py_GetArgcArgv(): Py_GetArgcArgv.
* Multi-Phase Initialization Private Provisional API::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0587/


File: python.info,  Node: 使用例<53>,  Next: PyWideStringList,  Up: Python 初期化設定

7.10.1 使用例
-------------

Example of customized Python always running in isolated mode:

     int main(int argc, char **argv)
     {
         PyStatus status;

         PyConfig config;
         PyConfig_InitPythonConfig(&config);
         config.isolated = 1;

         /* Decode command line arguments.
            Implicitly preinitialize Python (in isolated mode). */
         status = PyConfig_SetBytesArgv(&config, argc, argv);
         if (PyStatus_Exception(status)) {
             goto exception;
         }

         status = Py_InitializeFromConfig(&config);
         if (PyStatus_Exception(status)) {
             goto exception;
         }
         PyConfig_Clear(&config);

         return Py_RunMain();

     exception:
         PyConfig_Clear(&config);
         if (PyStatus_IsExit(status)) {
             return status.exitcode;
         }
         /* Display the error message and exit the process with
            non-zero exit code */
         Py_ExitStatusException(status);
     }


File: python.info,  Node: PyWideStringList,  Next: PyStatus,  Prev: 使用例<53>,  Up: Python 初期化設定

7.10.2 PyWideStringList
-----------------------

 -- C のデータ型: type PyWideStringList

     ‘wchar_t*’ 文字列のリスト。

     'length' が非ゼロの場合は、'items' は非 ‘NULL’ かつすべての文字列は
     非 ‘NULL’ でなければなりません。

     メソッド:

      -- C の関数: *note PyStatus: 97b. PyWideStringList_Append
               (PyWideStringList *list, const wchar_t *item)

          'item' を 'list' に追加します。

          Python must be preinitialized to call this function.

      -- C の関数: *note PyStatus: 97b. PyWideStringList_Insert
               (PyWideStringList *list, Py_ssize_t index, const wchar_t
               *item)

          'item' を 'list' の 'index' の位置に挿入します。

          'index' が 'list' の長さ以上の場合、'item' を 'list' の末尾に
          追加します。

          'index' must be greater than or equal to ‘0’.

          Python must be preinitialized to call this function.

     構造体フィールド:

      -- C のメンバ変数: *note Py_ssize_t: a2e. length

          リストの長さ。

      -- C のメンバ変数: wchar_t **items

          リストの要素。


File: python.info,  Node: PyStatus,  Next: PyPreConfig,  Prev: PyWideStringList,  Up: Python 初期化設定

7.10.3 PyStatus
---------------

 -- C のデータ型: type PyStatus

     初期化関数のステータス(成功、エラー、終了)を格納する構造体です。

     エラー時には、エラーを生成したC関数の名前を格納できます。

     構造体フィールド:

      -- C のメンバ変数: int exitcode

          終了コード。‘exit()’ の引数として渡されます。

      -- C のメンバ変数: const char *err_msg

          エラーメッセージ。

      -- C のメンバ変数: const char *func

          エラーを生成した関数の名前で、‘NULL’ になりえます。

     ステータスを生成する関数:

      -- C の関数: *note PyStatus: 97b. PyStatus_Ok (void)

          成功。

      -- C の関数: *note PyStatus: 97b. PyStatus_Error (const char
               *err_msg)

          メッセージとともにエラーを初期化します。

          'err_msg' must not be ‘NULL’.

      -- C の関数: *note PyStatus: 97b. PyStatus_NoMemory (void)

          メモリ割り当ての失敗(メモリ不足)。

      -- C の関数: *note PyStatus: 97b. PyStatus_Exit (int exitcode)

          指定した終了コードでPythonを終了します。

     ステータスを扱う関数:

      -- C の関数: int PyStatus_Exception (PyStatus status)

          Is the status an error or an exit?  If true, the exception
          must be handled; by calling *note Py_ExitStatusException():
          990. for example.

      -- C の関数: int PyStatus_IsError (PyStatus status)

          Is the result an error?

      -- C の関数: int PyStatus_IsExit (PyStatus status)

          Is the result an exit?

      -- C の関数: void Py_ExitStatusException (PyStatus status)

          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.

     注釈: Internally, Python uses macros which set ‘PyStatus.func’,
     whereas functions to create a status set ‘func’ to ‘NULL’.

以下はプログラム例です:

     PyStatus alloc(void **ptr, size_t size)
     {
         *ptr = PyMem_RawMalloc(size);
         if (*ptr == NULL) {
             return PyStatus_NoMemory();
         }
         return PyStatus_Ok();
     }

     int main(int argc, char **argv)
     {
         void *ptr;
         PyStatus status = alloc(&ptr, 16);
         if (PyStatus_Exception(status)) {
             Py_ExitStatusException(status);
         }
         PyMem_Free(ptr);
         return 0;
     }


File: python.info,  Node: PyPreConfig,  Next: Preinitialize Python with PyPreConfig,  Prev: PyStatus,  Up: Python 初期化設定

7.10.4 PyPreConfig
------------------

 -- C のデータ型: type PyPreConfig

     Structure used to preinitialize Python.

     Function to initialize a preconfiguration:

      -- C の関数: void PyPreConfig_InitPythonConfig (PyPreConfig
               *preconfig)

          Initialize the preconfiguration with *note Python
          Configuration: 4bd2.

      -- C の関数: void PyPreConfig_InitIsolatedConfig (PyPreConfig
               *preconfig)

          Initialize the preconfiguration with *note Isolated
          Configuration: 4c0c.

     構造体フィールド:

      -- C のメンバ変数: int allocator

          Name of the Python memory allocators:

             * ‘PYMEM_ALLOCATOR_NOT_SET’ (‘0’): don't change memory
               allocators (use defaults).

             * ‘PYMEM_ALLOCATOR_DEFAULT’ (‘1’): *note default memory
               allocators: 1cba.

             * ‘PYMEM_ALLOCATOR_DEBUG’ (‘2’): *note default memory
               allocators: 1cba. with *note debug hooks: 1cbd.

             * ‘PYMEM_ALLOCATOR_MALLOC’ (‘3’): use ‘malloc()’ of the C
               library.

             * ‘PYMEM_ALLOCATOR_MALLOC_DEBUG’ (‘4’): force usage of
               ‘malloc()’ with *note debug hooks: 1cbd.

             * ‘PYMEM_ALLOCATOR_PYMALLOC’ (‘5’): *note Python pymalloc
               memory allocator: cdd.

             * ‘PYMEM_ALLOCATOR_PYMALLOC_DEBUG’ (‘6’): *note Python
               pymalloc memory allocator: cdd. with *note debug hooks:
               1cbd.

             * ‘PYMEM_ALLOCATOR_MIMALLOC’ (‘6’): use ‘mimalloc’, a fast
               malloc replacement.

             * ‘PYMEM_ALLOCATOR_MIMALLOC_DEBUG’ (‘7’): use ‘mimalloc’, a
               fast malloc replacement with *note debug hooks: 1cbd.

          ‘PYMEM_ALLOCATOR_PYMALLOC’ and
          ‘PYMEM_ALLOCATOR_PYMALLOC_DEBUG’ are not supported if Python
          is *note configured using -without-pymalloc: 1d18.

          ‘PYMEM_ALLOCATOR_MIMALLOC’ and
          ‘PYMEM_ALLOCATOR_MIMALLOC_DEBUG’ are not supported if Python
          is *note configured using -without-mimalloc: 1d17. or if the
          underlying atomic support isn't available.

          See *note Memory Management: 4c17.

          Default: ‘PYMEM_ALLOCATOR_NOT_SET’.

      -- C のメンバ変数: int configure_locale

          Set the LC_CTYPE locale to the user preferred locale.

          If equals to ‘0’, set *note coerce_c_locale: 4c19. and *note
          coerce_c_locale_warn: 4c1a. members to ‘0’.

          See the *note locale encoding: 223.

          Default: ‘1’ in Python config, ‘0’ in isolated config.

      -- C のメンバ変数: int coerce_c_locale

          If equals to ‘2’, coerce the C locale.

          If equals to ‘1’, read the LC_CTYPE locale to decide if it
          should be coerced.

          See the *note locale encoding: 223.

          Default: ‘-1’ in Python config, ‘0’ in isolated config.

      -- C のメンバ変数: int coerce_c_locale_warn

          If non-zero, emit a warning if the C locale is coerced.

          Default: ‘-1’ in Python config, ‘0’ in isolated config.

      -- C のメンバ変数: int dev_mode

          *note Python Development Mode: 1d9.: see *note
          PyConfig.dev_mode: 4c1c.

          Default: ‘-1’ in Python mode, ‘0’ in isolated mode.

      -- C のメンバ変数: int isolated

          Isolated mode: see *note PyConfig.isolated: 3be.

          Default: ‘0’ in Python mode, ‘1’ in isolated mode.

      -- C のメンバ変数: int legacy_windows_fs_encoding

          If non-zero:

             * Set *note PyPreConfig.utf8_mode: 3c4. to ‘0’,

             * Set *note PyConfig.filesystem_encoding: 3c2. to ‘"mbcs"’,

             * Set *note PyConfig.filesystem_errors: 3c3. to
               ‘"replace"’.

          Initialized from the *note PYTHONLEGACYWINDOWSFSENCODING: 28f.
          environment variable value.

          Only available on Windows.  ‘#ifdef MS_WINDOWS’ macro can be
          used for Windows specific code.

          Default: ‘0’.

      -- C のメンバ変数: int parse_argv

          If non-zero, *note Py_PreInitializeFromArgs(): 991. and *note
          Py_PreInitializeFromBytesArgs(): 992. parse their ‘argv’
          argument the same way the regular Python parses command line
          arguments: see *note Command Line Arguments: fd2.

          Default: ‘1’ in Python config, ‘0’ in isolated config.

      -- C のメンバ変数: int use_environment

          Use *note environment variables: 5bb.?  See *note
          PyConfig.use_environment: 3b3.

          Default: ‘1’ in Python config and ‘0’ in isolated config.

      -- C のメンバ変数: int utf8_mode

          If non-zero, enable the *note Python UTF-8 Mode: 622.

          Set to ‘0’ or ‘1’ by the *note -X utf8: 15c. command line
          option and the *note PYTHONUTF8: aa6. environment variable.

          Also set to ‘1’ if the ‘LC_CTYPE’ locale is ‘C’ or ‘POSIX’.

          Default: ‘-1’ in Python config and ‘0’ in isolated config.


File: python.info,  Node: Preinitialize Python with PyPreConfig,  Next: PyConfig,  Prev: PyPreConfig,  Up: Python 初期化設定

7.10.5 Preinitialize Python with PyPreConfig
--------------------------------------------

The preinitialization of Python:

   * Set the Python memory allocators (*note PyPreConfig.allocator:
     4c16.)

   * Configure the LC_CTYPE locale (*note locale encoding: 223.)

   * Set the *note Python UTF-8 Mode: 622. (*note PyPreConfig.utf8_mode:
     3c4.)

The current preconfiguration (‘PyPreConfig’ type) is stored in
‘_PyRuntime.preconfig’.

Functions to preinitialize Python:

 -- C の関数: *note PyStatus: 97b. Py_PreInitialize (const PyPreConfig
          *preconfig)

     Preinitialize Python from 'preconfig' preconfiguration.

     'preconfig' must not be ‘NULL’.

 -- C の関数: *note PyStatus: 97b. Py_PreInitializeFromBytesArgs (const
          PyPreConfig *preconfig, int argc, char *const *argv)

     Preinitialize Python from 'preconfig' preconfiguration.

     Parse 'argv' command line arguments (bytes strings) if *note
     parse_argv: 4c1e. of 'preconfig' is non-zero.

     'preconfig' must not be ‘NULL’.

 -- C の関数: *note PyStatus: 97b. Py_PreInitializeFromArgs (const
          PyPreConfig *preconfig, int argc, wchar_t *const *argv)

     Preinitialize Python from 'preconfig' preconfiguration.

     Parse 'argv' command line arguments (wide strings) if *note
     parse_argv: 4c1e. of 'preconfig' is non-zero.

     'preconfig' must not be ‘NULL’.

The caller is responsible to handle exceptions (error or exit) using
*note PyStatus_Exception(): 987. and *note Py_ExitStatusException():
990.

For *note Python Configuration: 4bd2. (*note
PyPreConfig_InitPythonConfig(): 985.), if Python is initialized with
command line arguments, the command line arguments must also be passed
to preinitialize Python, since they have an effect on the
pre-configuration like encodings.  For example, the *note -X utf8: 15c.
command line option enables the *note Python UTF-8 Mode: 622.

‘PyMem_SetAllocator()’ can be called after *note Py_PreInitialize():
3c5. and before *note Py_InitializeFromConfig(): 39f. to install a
custom memory allocator.  It can be called before *note
Py_PreInitialize(): 3c5. if *note PyPreConfig.allocator: 4c16. is set to
‘PYMEM_ALLOCATOR_NOT_SET’.

Python memory allocation functions like *note PyMem_RawMalloc(): 369.
must not be used before the Python preinitialization, whereas calling
directly ‘malloc()’ and ‘free()’ is always safe.  *note
Py_DecodeLocale(): b95. must not be called before the Python
preinitialization.

Example using the preinitialization to enable the *note Python UTF-8
Mode: 622.:

     PyStatus status;
     PyPreConfig preconfig;
     PyPreConfig_InitPythonConfig(&preconfig);

     preconfig.utf8_mode = 1;

     status = Py_PreInitialize(&preconfig);
     if (PyStatus_Exception(status)) {
         Py_ExitStatusException(status);
     }

     /* at this point, Python speaks UTF-8 */

     Py_Initialize();
     /* ... use Python API here ... */
     Py_Finalize();


File: python.info,  Node: PyConfig,  Next: Initialization with PyConfig,  Prev: Preinitialize Python with PyPreConfig,  Up: Python 初期化設定

7.10.6 PyConfig
---------------

 -- C のデータ型: type PyConfig

     Structure containing most parameters to configure Python.

     When done, the *note PyConfig_Clear(): 97d. function must be used
     to release the configuration memory.

     Structure methods:

      -- C の関数: void PyConfig_InitPythonConfig (PyConfig *config)

          Initialize configuration with the *note Python Configuration:
          4bd2.

      -- C の関数: void PyConfig_InitIsolatedConfig (PyConfig *config)

          Initialize configuration with the *note Isolated
          Configuration: 4c0c.

      -- C の関数: *note PyStatus: 97b. PyConfig_SetString (PyConfig
               *config, wchar_t *const *config_str, const wchar_t *str)

          Copy the wide character string 'str' into ‘*config_str’.

          *note Preinitialize Python: 3bcb. if needed.

      -- C の関数: *note PyStatus: 97b. PyConfig_SetBytesString
               (PyConfig *config, wchar_t *const *config_str, const char
               *str)

          Decode 'str' using *note Py_DecodeLocale(): b95. and set the
          result into ‘*config_str’.

          *note Preinitialize Python: 3bcb. if needed.

      -- C の関数: *note PyStatus: 97b. PyConfig_SetArgv (PyConfig
               *config, int argc, wchar_t *const *argv)

          Set command line arguments (*note argv: 39d. member of
          'config') from the 'argv' list of wide character strings.

          *note Preinitialize Python: 3bcb. if needed.

      -- C の関数: *note PyStatus: 97b. PyConfig_SetBytesArgv (PyConfig
               *config, int argc, char *const *argv)

          Set command line arguments (*note argv: 39d. member of
          'config') from the 'argv' list of bytes strings.  Decode bytes
          using *note Py_DecodeLocale(): b95.

          *note Preinitialize Python: 3bcb. if needed.

      -- C の関数: *note PyStatus: 97b. PyConfig_SetWideStringList
               (PyConfig *config, PyWideStringList *list, Py_ssize_t
               length, wchar_t **items)

          Set the list of wide strings 'list' to 'length' and 'items'.

          *note Preinitialize Python: 3bcb. if needed.

      -- C の関数: *note PyStatus: 97b. PyConfig_Read (PyConfig *config)

          Read all Python configuration.

          Fields which are already initialized are left unchanged.

          Fields for *note path configuration: 87b. are no longer
          calculated or modified when calling this function, as of
          Python 3.11.

          The *note PyConfig_Read(): 75b. function only parses *note
          PyConfig.argv: 39d. arguments once: *note PyConfig.parse_argv:
          1893. is set to ‘2’ after arguments are parsed.  Since Python
          arguments are stripped from *note PyConfig.argv: 39d, parsing
          arguments twice would parse the application options as Python
          options.

          *note Preinitialize Python: 3bcb. if needed.

          バージョン 3.10 で変更: The *note PyConfig.argv: 39d.
          arguments are now only parsed once, *note PyConfig.parse_argv:
          1893. is set to ‘2’ after arguments are parsed, and arguments
          are only parsed if *note PyConfig.parse_argv: 1893. equals
          ‘1’.

          バージョン 3.11 で変更: *note PyConfig_Read(): 75b. no longer
          calculates all paths, and so fields listed under *note Python
          Path Configuration: 87b. may no longer be updated until *note
          Py_InitializeFromConfig(): 39f. is called.

      -- C の関数: void PyConfig_Clear (PyConfig *config)

          Release configuration memory.

     Most ‘PyConfig’ methods *note preinitialize Python: 3bcb. if
     needed.  In that case, the Python preinitialization configuration
     (*note PyPreConfig: 97a.) in based on the *note PyConfig: 380.  If
     configuration fields which are in common with *note PyPreConfig:
     97a. are tuned, they must be set before calling a *note PyConfig:
     380. method:

        * *note PyConfig.dev_mode: 4c1c.

        * *note PyConfig.isolated: 3be.

        * *note PyConfig.parse_argv: 1893.

        * *note PyConfig.use_environment: 3b3.

     Moreover, if *note PyConfig_SetArgv(): 980. or *note
     PyConfig_SetBytesArgv(): 981. is used, this method must be called
     before other methods, since the preinitialization configuration
     depends on command line arguments (if *note parse_argv: 1893. is
     non-zero).

     The caller of these methods is responsible to handle exceptions
     (error or exit) using ‘PyStatus_Exception()’ and
     ‘Py_ExitStatusException()’.

     構造体フィールド:

      -- C のメンバ変数: *note PyWideStringList: 97c. argv

          Set *note sys.argv: 1236. command line arguments based on
          *note argv: 39d.  These parameters are similar to those passed
          to the program's ‘main()’ function with the difference that
          the first entry should refer to the script file to be executed
          rather than the executable hosting the Python interpreter.  If
          there isn't a script that will be run, the first entry in
          *note argv: 39d. can be an empty string.

          Set *note parse_argv: 1893. to ‘1’ to parse *note argv: 39d.
          the same way the regular Python parses Python command line
          arguments and then to strip Python arguments from *note argv:
          39d.

          If *note argv: 39d. is empty, an empty string is added to
          ensure that *note sys.argv: 1236. always exists and is never
          empty.

          Default: ‘NULL’.

          See also the *note orig_argv: 861. member.

      -- C のメンバ変数: int safe_path

          If equals to zero, ‘Py_RunMain()’ prepends a potentially
          unsafe path to *note sys.path: 38e. at startup:

             * If *note argv[0]: 39d. is equal to ‘L"-m"’ (‘python -m
               module’), prepend the current working directory.

             * If running a script (‘python script.py’), prepend the
               script's directory.  If it's a symbolic link, resolve
               symbolic links.

             * Otherwise (‘python -c code’ and ‘python’), prepend an
               empty string, which means the current working directory.

          Set to ‘1’ by the *note -P: 56e. command line option and the
          *note PYTHONSAFEPATH: 56f. environment variable.

          Default: ‘0’ in Python config, ‘1’ in isolated config.

          Added in version 3.11.

      -- C のメンバ変数: wchar_t *base_exec_prefix

          *note sys.base_exec_prefix: 3c8.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. output.

          See also *note PyConfig.exec_prefix: 4c23.

      -- C のメンバ変数: wchar_t *base_executable

          Python base executable: ‘sys._base_executable’.

          Set by the ‘__PYVENV_LAUNCHER__’ environment variable.

          Set from *note PyConfig.executable: 37f. if ‘NULL’.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. output.

          See also *note PyConfig.executable: 37f.

      -- C のメンバ変数: wchar_t *base_prefix

          *note sys.base_prefix: 3c9.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. output.

          See also *note PyConfig.prefix: 4c26.

      -- C のメンバ変数: int buffered_stdio

          If equals to ‘0’ and *note configure_c_stdio: 4c27. is
          non-zero, disable buffering on the C streams stdout and
          stderr.

          Set to ‘0’ by the *note -u: 190f. command line option and the
          *note PYTHONUNBUFFERED: 1910. environment variable.

          stdin is always opened in buffered mode.

          Default: ‘1’.

      -- C のメンバ変数: int bytes_warning

          If equals to ‘1’, issue a warning when comparing *note bytes:
          1a4. or *note bytearray: 508. with *note str: 418, or
          comparing *note bytes: 1a4. with *note int: 238.

          If equal or greater to ‘2’, raise a *note BytesWarning: bf1.
          exception in these cases.

          Incremented by the *note -b: 5ad. command line option.

          Default: ‘0’.

      -- C のメンバ変数: int warn_default_encoding

          If non-zero, emit a *note EncodingWarning: 1ca7. warning when
          *note io.TextIOWrapper: 786. uses its default encoding.  See
          *note Opt-in EncodingWarning: 1cbf. for details.

          Default: ‘0’.

          Added in version 3.10.

      -- C のメンバ変数: int code_debug_ranges

          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.

          Set to ‘0’ by the *note PYTHONNODEBUGRANGES: 580. environment
          variable and by the *note -X no_debug_ranges: 15c. command
          line option.

          Default: ‘1’.

          Added in version 3.11.

      -- C のメンバ変数: wchar_t *check_hash_pycs_mode

          Control the validation behavior of hash-based ‘.pyc’ files:
          value of the *note -check-hash-based-pycs: 1c9a. command line
          option.

          Valid values:

             - ‘L"always"’: Hash the source file for invalidation
               regardless of value of the 'check_source' flag.

             - ‘L"never"’: Assume that hash-based pycs always are valid.

             - ‘L"default"’: The 'check_source' flag in hash-based pycs
               determines invalidation.

          Default: ‘L"default"’.

          See also PEP 552(1) "Deterministic pycs".

      -- C のメンバ変数: int configure_c_stdio

          If non-zero, configure C standard streams:

             * On Windows, set the binary mode (‘O_BINARY’) on stdin,
               stdout and stderr.

             * If *note buffered_stdio: 3b9. equals zero, disable
               buffering of stdin, stdout and stderr streams.

             * If *note interactive: 3a7. is non-zero, enable stream
               buffering on stdin and stdout (only stdout on Windows).

          Default: ‘1’ in Python config, ‘0’ in isolated config.

      -- C のメンバ変数: int dev_mode

          If non-zero, enable the *note Python Development Mode: 1d9.

          Set to ‘1’ by the *note -X dev: 15c. option and the *note
          PYTHONDEVMODE: abb. environment variable.

          Default: ‘-1’ in Python mode, ‘0’ in isolated mode.

      -- C のメンバ変数: int dump_refs

          Dump Python references?

          If non-zero, dump all objects which are still alive at exit.

          Set to ‘1’ by the *note PYTHONDUMPREFS: 974. environment
          variable.

          Needs a special build of Python with the ‘Py_TRACE_REFS’ macro
          defined: see the *note configure -with-trace-refs option: 36e.

          Default: ‘0’.

      -- C のメンバ変数: wchar_t *exec_prefix

          The site-specific directory prefix where the
          platform-dependent Python files are installed: *note
          sys.exec_prefix: 38c.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. output.

          See also *note PyConfig.base_exec_prefix: 4c22.

      -- C のメンバ変数: wchar_t *executable

          The absolute path of the executable binary for the Python
          interpreter: *note sys.executable: 392.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. output.

          See also *note PyConfig.base_executable: 4c24.

      -- C のメンバ変数: int faulthandler

          Enable faulthandler?

          If non-zero, call *note faulthandler.enable(): c6c. at
          startup.

          Set to ‘1’ by *note -X faulthandler: 15c. and the *note
          PYTHONFAULTHANDLER: 1055. environment variable.

          Default: ‘-1’ in Python mode, ‘0’ in isolated mode.

      -- C のメンバ変数: wchar_t *filesystem_encoding

          *note Filesystem encoding: 505.: *note
          sys.getfilesystemencoding(): c27.

          On macOS, Android and VxWorks: use ‘"utf-8"’ by default.

          On Windows: use ‘"utf-8"’ by default, or ‘"mbcs"’ if *note
          legacy_windows_fs_encoding: 3c0. of *note PyPreConfig: 97a. is
          non-zero.

          Default encoding on other platforms:

             * ‘"utf-8"’ if *note PyPreConfig.utf8_mode: 3c4. is
               non-zero.

             * ‘"ascii"’ if Python detects that ‘nl_langinfo(CODESET)’
               announces the ASCII encoding, whereas the ‘mbstowcs()’
               function decodes from a different encoding (usually
               Latin1).

             * ‘"utf-8"’ if ‘nl_langinfo(CODESET)’ returns an empty
               string.

             * Otherwise, use the *note locale encoding: 223.:
               ‘nl_langinfo(CODESET)’ result.

          At Python startup, the encoding name is normalized to the
          Python codec name.  For example, ‘"ANSI_X3.4-1968"’ is
          replaced with ‘"ascii"’.

          See also the *note filesystem_errors: 3c3. member.

      -- C のメンバ変数: wchar_t *filesystem_errors

          *note Filesystem error handler: 505.: *note
          sys.getfilesystemencodeerrors(): cb4.

          On Windows: use ‘"surrogatepass"’ by default, or ‘"replace"’
          if *note legacy_windows_fs_encoding: 3c0. of *note
          PyPreConfig: 97a. is non-zero.

          On other platforms: use ‘"surrogateescape"’ by default.

          Supported error handlers:

             * ‘"strict"’

             * ‘"surrogateescape"’

             * ‘"surrogatepass"’ (only supported with the UTF-8
               encoding)

          See also the *note filesystem_encoding: 3c2. member.

      -- C のメンバ変数: unsigned long hash_seed

      -- C のメンバ変数: int use_hash_seed

          Randomized hash function seed.

          If *note use_hash_seed: 3bb. is zero, a seed is chosen
          randomly at Python startup, and *note hash_seed: 3bc. is
          ignored.

          Set by the *note PYTHONHASHSEED: 1052. environment variable.

          Default 'use_hash_seed' value: ‘-1’ in Python mode, ‘0’ in
          isolated mode.

      -- C のメンバ変数: wchar_t *home

          Set the default Python "home" directory, that is, the location
          of the standard Python libraries (see *note PYTHONHOME: 396.).

          Set by the *note PYTHONHOME: 396. environment variable.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. input.

      -- C のメンバ変数: int import_time

          If non-zero, profile import time.

          Set the ‘1’ by the *note -X importtime: 15c. option and the
          *note PYTHONPROFILEIMPORTTIME: ac3. environment variable.

          Default: ‘0’.

      -- C のメンバ変数: int inspect

          Enter interactive mode after executing a script or a command.

          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
          *note sys.stdin: 507. does not appear to be a terminal.

          Incremented by the *note -i: 1484. command line option.  Set
          to ‘1’ if the *note PYTHONINSPECT: 1483. environment variable
          is non-empty.

          Default: ‘0’.

      -- C のメンバ変数: int install_signal_handlers

          Install Python signal handlers?

          Default: ‘1’ in Python mode, ‘0’ in isolated mode.

      -- C のメンバ変数: int interactive

          If greater than ‘0’, enable the interactive mode (REPL).

          Incremented by the *note -i: 1484. command line option.

          Default: ‘0’.

      -- C のメンバ変数: int int_max_str_digits

          Configures the *note integer string conversion length
          limitation: 5bf.  An initial value of ‘-1’ means the value
          will be taken from the command line or environment or
          otherwise default to 4300 (*note
          sys.int_info.default_max_str_digits: 21d9.).  A value of ‘0’
          disables the limitation.  Values greater than zero but less
          than 640 (*note sys.int_info.str_digits_check_threshold:
          4206.) are unsupported and will produce an error.

          Configured by the *note -X int_max_str_digits: 15c. command
          line flag or the *note PYTHONINTMAXSTRDIGITS: 1728.
          environment variable.

          Default: ‘-1’ in Python mode.  4300 (*note
          sys.int_info.default_max_str_digits: 21d9.) in isolated mode.

          Added in version 3.12.

      -- C のメンバ変数: int cpu_count

          If the value of *note cpu_count: 4c2f. is not ‘-1’ then it
          will override the return values of *note os.cpu_count(): 1a7,
          *note os.process_cpu_count(): 1a6, and *note
          multiprocessing.cpu_count(): f3c.

          Configured by the ‘-X cpu_count=N|DEFAULT’ command line flag
          or the *note PYTHON_CPU_COUNT: 1f1. environment variable.

          Default: ‘-1’.

          Added in version 3.13.

      -- C のメンバ変数: int isolated

          If greater than ‘0’, enable isolated mode:

             * Set *note safe_path: 73e. to ‘1’: don't prepend a
               potentially unsafe path to *note sys.path: 38e. at Python
               startup, such as the current directory, the script's
               directory or an empty string.

             * Set *note use_environment: 3b3. to ‘0’: ignore ‘PYTHON’
               environment variables.

             * Set *note user_site_directory: 3b7. to ‘0’: don't add the
               user site directory to *note sys.path: 38e.

             * Python REPL doesn't import *note readline: a8. nor enable
               default readline configuration on interactive prompts.

          Set to ‘1’ by the *note -I: 92c. command line option.

          Default: ‘0’ in Python mode, ‘1’ in isolated mode.

          See also the *note Isolated Configuration: 4c0c. and *note
          PyPreConfig.isolated: 4c1d.

      -- C のメンバ変数: int legacy_windows_stdio

          If non-zero, use *note io.FileIO: 12df. instead of
          ‘io._WindowsConsoleIO’ for *note sys.stdin: 507, *note
          sys.stdout: aa4. and *note sys.stderr: 907.

          *note PYTHONLEGACYWINDOWSSTDIO: c29. 環境変数が空でない文字列
          に設定された場合に、 ‘1’ に設定されます。

          Only available on Windows.  ‘#ifdef MS_WINDOWS’ macro can be
          used for Windows specific code.

          Default: ‘0’.

          See also the PEP 528(2) (Change Windows console encoding to
          UTF-8).

      -- C のメンバ変数: int malloc_stats

          If non-zero, dump statistics on *note Python pymalloc memory
          allocator: cdd. at exit.

          Set to ‘1’ by the *note PYTHONMALLOCSTATS: 1ac1. environment
          variable.

          The option is ignored if Python is *note configured using the
          -without-pymalloc option: 1d18.

          Default: ‘0’.

      -- C のメンバ変数: wchar_t *platlibdir

          Platform library directory name: *note sys.platlibdir: 906.

          Set by the *note PYTHONPLATLIBDIR: 18aa. environment variable.

          Default: value of the ‘PLATLIBDIR’ macro which is set by the
          *note configure -with-platlibdir option: 1ce0. (default:
          ‘"lib"’, or ‘"DLLs"’ on Windows).

          Part of the *note Python Path Configuration: 87b. input.

          Added in version 3.9.

          バージョン 3.11 で変更: 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.

      -- C のメンバ変数: wchar_t *pythonpath_env

          Module search paths (*note sys.path: 38e.) as a string
          separated by ‘DELIM’ (*note os.pathsep: 1cae.).

          Set by the *note PYTHONPATH: fe8. environment variable.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. input.

      -- C のメンバ変数: *note PyWideStringList: 97c.
               module_search_paths

      -- C のメンバ変数: int module_search_paths_set

          Module search paths: *note sys.path: 38e.

          If *note module_search_paths_set: 5b9. is equal to ‘0’, *note
          Py_InitializeFromConfig(): 39f. will replace *note
          module_search_paths: 37c. and sets *note
          module_search_paths_set: 5b9. to ‘1’.

          Default: empty list (‘module_search_paths’) and ‘0’
          (‘module_search_paths_set’).

          Part of the *note Python Path Configuration: 87b. output.

      -- C のメンバ変数: int optimization_level

          Compilation optimization level:

             * ‘0’: Peephole optimizer, set ‘__debug__’ to ‘True’.

             * ‘1’: Level 0, remove assertions, set ‘__debug__’ to
               ‘False’.

             * ‘2’: Level 1, strip docstrings.

          Incremented by the *note -O: d82. command line option.  Set to
          the *note PYTHONOPTIMIZE: 1c9d. environment variable value.

          Default: ‘0’.

      -- C のメンバ変数: *note PyWideStringList: 97c. orig_argv

          The list of the original command line arguments passed to the
          Python executable: *note sys.orig_argv: 80b.

          If *note orig_argv: 861. list is empty and *note argv: 39d. is
          not a list only containing an empty string, *note
          PyConfig_Read(): 75b. copies *note argv: 39d. into *note
          orig_argv: 861. before modifying *note argv: 39d. (if *note
          parse_argv: 1893. is non-zero).

          See also the *note argv: 39d. member and the *note
          Py_GetArgcArgv(): 18c0. function.

          Default: empty list.

          Added in version 3.10.

      -- C のメンバ変数: int parse_argv

          Parse command line arguments?

          If equals to ‘1’, parse *note argv: 39d. the same way the
          regular Python parses *note command line arguments: fd2, and
          strip Python arguments from *note argv: 39d.

          The *note PyConfig_Read(): 75b. function only parses *note
          PyConfig.argv: 39d. arguments once: *note PyConfig.parse_argv:
          1893. is set to ‘2’ after arguments are parsed.  Since Python
          arguments are stripped from *note PyConfig.argv: 39d, parsing
          arguments twice would parse the application options as Python
          options.

          Default: ‘1’ in Python mode, ‘0’ in isolated mode.

          バージョン 3.10 で変更: The *note PyConfig.argv: 39d.
          arguments are now only parsed if *note PyConfig.parse_argv:
          1893. equals to ‘1’.

      -- C のメンバ変数: int parser_debug

          Parser debug mode.  If greater than ‘0’, turn on parser
          debugging output (for expert only, depending on compilation
          options).

          Incremented by the *note -d: 1c9b. command line option.  Set
          to the *note PYTHONDEBUG: 1c9c. environment variable value.

          Needs a *note debug build of Python: 1da. (the ‘Py_DEBUG’
          macro must be defined).

          Default: ‘0’.

      -- C のメンバ変数: int pathconfig_warnings

          If non-zero, calculation of path configuration is allowed to
          log warnings into ‘stderr’.  If equals to ‘0’, suppress these
          warnings.

          Default: ‘1’ in Python mode, ‘0’ in isolated mode.

          Part of the *note Python Path Configuration: 87b. input.

          バージョン 3.11 で変更: Now also applies on Windows.

      -- C のメンバ変数: wchar_t *prefix

          The site-specific directory prefix where the platform
          independent Python files are installed: *note sys.prefix: 390.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. output.

          See also *note PyConfig.base_prefix: 4c25.

      -- C のメンバ変数: wchar_t *program_name

          Program name used to initialize *note executable: 37f. and in
          early error messages during Python initialization.

             * On macOS, use *note PYTHONEXECUTABLE: 1cb2. environment
               variable if set.

             * If the ‘WITH_NEXT_FRAMEWORK’ macro is defined, use
               ‘__PYVENV_LAUNCHER__’ environment variable if set.

             * Use ‘argv[0]’ of *note argv: 39d. if available and
               non-empty.

             * Otherwise, use ‘L"python"’ on Windows, or ‘L"python3"’ on
               other platforms.

          Default: ‘NULL’.

          Part of the *note Python Path Configuration: 87b. input.

      -- C のメンバ変数: wchar_t *pycache_prefix

          Directory where cached ‘.pyc’ files are written: *note
          sys.pycache_prefix: 972.

          Set by the *note -X pycache_prefix=PATH: 15c. command line
          option and the *note PYTHONPYCACHEPREFIX: 971. environment
          variable.  The command-line option takes precedence.

          If ‘NULL’, *note sys.pycache_prefix: 972. is set to ‘None’.

          Default: ‘NULL’.

      -- C のメンバ変数: int quiet

          Quiet mode.  If greater than ‘0’, don't display the copyright
          and version at Python startup in interactive mode.

          Incremented by the *note -q: 1c9e. command line option.

          Default: ‘0’.

      -- C のメンバ変数: wchar_t *run_command

          Value of the *note -c: 5aa. command line option.

          Used by *note Py_RunMain(): 993.

          Default: ‘NULL’.

      -- C のメンバ変数: wchar_t *run_filename

          Filename passed on the command line: trailing command line
          argument without *note -c: 5aa. or *note -m: 5ab.  It is used
          by the *note Py_RunMain(): 993. function.

          For example, it is set to ‘script.py’ by the ‘python3
          script.py arg’ command line.

          See also the *note PyConfig.skip_source_first_line: 4c33.
          option.

          Default: ‘NULL’.

      -- C のメンバ変数: wchar_t *run_module

          Value of the *note -m: 5ab. command line option.

          Used by *note Py_RunMain(): 993.

          Default: ‘NULL’.

      -- C のメンバ変数: wchar_t *run_presite

          ‘package.module’ path to module that should be imported before
          ‘site.py’ is run.

          Set by the *note -X presite=package.module: 15c. command-line
          option and the *note PYTHON_PRESITE: 1ca8. environment
          variable.  The command-line option takes precedence.

          Needs a *note debug build of Python: 1da. (the ‘Py_DEBUG’
          macro must be defined).

          Default: ‘NULL’.

      -- C のメンバ変数: int show_ref_count

          Show total reference count at exit (excluding *note immortal:
          41f8. objects)?

          Set to ‘1’ by *note -X showrefcount: 15c. command line option.

          Needs a *note debug build of Python: 1da. (the ‘Py_REF_DEBUG’
          macro must be defined).

          Default: ‘0’.

      -- C のメンバ変数: int site_import

          Import the *note site: b5. module at startup?

          If equal to zero, disable the import of the module site and
          the site-dependent manipulations of *note sys.path: 38e. that
          it entails.

          Also disable these manipulations if the *note site: b5. module
          is explicitly imported later (call *note site.main(): 1ca0. if
          you want them to be triggered).

          Set to ‘0’ by the *note -S: 1179. command line option.

          *note sys.flags.no_site: 658. is set to the inverted value of
          *note site_import: 3ad.

          Default: ‘1’.

      -- C のメンバ変数: int skip_source_first_line

          If non-zero, skip the first line of the *note
          PyConfig.run_filename: 4bd0. source.

          It allows the usage of non-Unix forms of ‘#!cmd’.  This is
          intended for a DOS specific hack only.

          Set to ‘1’ by the *note -x: 1ca4. command line option.

          Default: ‘0’.

      -- C のメンバ変数: wchar_t *stdio_encoding

      -- C のメンバ変数: wchar_t *stdio_errors

          Encoding and encoding errors of *note sys.stdin: 507, *note
          sys.stdout: aa4. and *note sys.stderr: 907. (but *note
          sys.stderr: 907. always uses ‘"backslashreplace"’ error
          handler).

          Use the *note PYTHONIOENCODING: fd5. environment variable if
          it is non-empty.

          Default encoding:

             * ‘"UTF-8"’ if *note PyPreConfig.utf8_mode: 3c4. is
               non-zero.

             * Otherwise, use the *note locale encoding: 223.

          Default error handler:

             * On Windows: use ‘"surrogateescape"’.

             * ‘"surrogateescape"’ if *note PyPreConfig.utf8_mode: 3c4.
               is non-zero, or if the LC_CTYPE locale is "C" or "POSIX".

             * ‘"strict"’ otherwise.

          See also *note PyConfig.legacy_windows_stdio: 37e.

      -- C のメンバ変数: int tracemalloc

          Enable tracemalloc?

          If non-zero, call *note tracemalloc.start(): 1ca5. at startup.

          Set by *note -X tracemalloc=N: 15c. command line option and by
          the *note PYTHONTRACEMALLOC: 1ca6. environment variable.

          Default: ‘-1’ in Python mode, ‘0’ in isolated mode.

      -- C のメンバ変数: int perf_profiling

          Enable compatibility mode with the perf profiler?

          If non-zero, initialize the perf trampoline.  See *note Python
          support for the Linux perf profiler: 174. for more
          information.

          Set by *note -X perf: 15c. command-line option and by the
          *note PYTHON_PERF_JIT_SUPPORT: 175. environment variable for
          perf support with stack pointers and *note -X perf_jit: 15c.
          command-line option and by the *note PYTHON_PERF_JIT_SUPPORT:
          175. environment variable for perf support with DWARF JIT
          information.

          Default: ‘-1’.

          Added in version 3.12.

      -- C のメンバ変数: int use_environment

          Use *note environment variables: 5bb.?

          If equals to zero, ignore the *note environment variables:
          5bb.

          Set to ‘0’ by the *note -E: 92b. environment variable.

          Default: ‘1’ in Python config and ‘0’ in isolated config.

      -- C のメンバ変数: int user_site_directory

          If non-zero, add the user site directory to *note sys.path:
          38e.

          Set to ‘0’ by the *note -s: 1353. and *note -I: 92c. command
          line options.

          Set to ‘0’ by the *note PYTHONNOUSERSITE: 1354. environment
          variable.

          Default: ‘1’ in Python mode, ‘0’ in isolated mode.

      -- C のメンバ変数: int verbose

          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.

          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.

          Incremented by the *note -v: 13cc. command line option.

          Set by the *note PYTHONVERBOSE: 1ca1. environment variable
          value.

          Default: ‘0’.

      -- C のメンバ変数: *note PyWideStringList: 97c. warnoptions

          Options of the *note warnings: fa. module to build warnings
          filters, lowest to highest priority: *note sys.warnoptions:
          38a.

          The *note warnings: fa. module adds *note sys.warnoptions:
          38a. in the reverse order: the last *note
          PyConfig.warnoptions: 37a. item becomes the first item of
          ‘warnings.filters’ which is checked first (highest priority).

          The *note -W: 896. command line options adds its value to
          *note warnoptions: 37a, it can be used multiple times.

          The *note PYTHONWARNINGS: b78. environment variable can also
          be used to add warning options.  Multiple options can be
          specified, separated by commas (‘,’).

          Default: empty list.

      -- C のメンバ変数: int write_bytecode

          If equal to ‘0’, Python won't try to write ‘.pyc’ files on the
          import of source modules.

          Set to ‘0’ by the *note -B: 1375. command line option and the
          *note PYTHONDONTWRITEBYTECODE: 1376. environment variable.

          *note sys.dont_write_bytecode: 41d1. is initialized to the
          inverted value of *note write_bytecode: 3b5.

          Default: ‘1’.

      -- C のメンバ変数: *note PyWideStringList: 97c. xoptions

          Values of the *note -X: 15c. command line options: *note
          sys._xoptions: 1ca9.

          Default: empty list.

If *note parse_argv: 1893. is non-zero, *note argv: 39d. arguments are
parsed the same way the regular Python parses *note command line
arguments: fd2, and Python arguments are stripped from *note argv: 39d.

The *note xoptions: 37b. options are parsed to set other options: see
the *note -X: 15c. command line option.

バージョン 3.9 で変更: The ‘show_alloc_count’ field has been removed.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0552/

   (2) https://peps.python.org/pep-0528/


File: python.info,  Node: Initialization with PyConfig,  Next: Isolated Configuration,  Prev: PyConfig,  Up: Python 初期化設定

7.10.7 Initialization with PyConfig
-----------------------------------

Initializing the interpreter from a populated configuration struct is
handled by calling *note Py_InitializeFromConfig(): 39f.

The caller is responsible to handle exceptions (error or exit) using
*note PyStatus_Exception(): 987. and *note Py_ExitStatusException():
990.

If *note PyImport_FrozenModules(): 2f63, *note PyImport_AppendInittab():
170e. or *note PyImport_ExtendInittab(): 170f. are used, they must be
set or called after Python preinitialization and before the Python
initialization.  If Python is initialized multiple times, *note
PyImport_AppendInittab(): 170e. or *note PyImport_ExtendInittab(): 170f.
must be called before each Python initialization.

The current configuration (‘PyConfig’ type) is stored in
‘PyInterpreterState.config’.

Example setting the program name:

     void init_python(void)
     {
         PyStatus status;

         PyConfig config;
         PyConfig_InitPythonConfig(&config);

         /* Set the program name. Implicitly preinitialize Python. */
         status = PyConfig_SetString(&config, &config.program_name,
                                     L"/path/to/my_program");
         if (PyStatus_Exception(status)) {
             goto exception;
         }

         status = Py_InitializeFromConfig(&config);
         if (PyStatus_Exception(status)) {
             goto exception;
         }
         PyConfig_Clear(&config);
         return;

     exception:
         PyConfig_Clear(&config);
         Py_ExitStatusException(status);
     }

More complete example modifying the default configuration, read the
configuration, and then override some parameters.  Note that since 3.11,
many parameters are not calculated until initialization, and so values
cannot be read from the configuration structure.  Any values set before
initialize is called will be left unchanged by initialization:

     PyStatus init_python(const char *program_name)
     {
         PyStatus status;

         PyConfig config;
         PyConfig_InitPythonConfig(&config);

         /* Set the program name before reading the configuration
            (decode byte string from the locale encoding).

            Implicitly preinitialize Python. */
         status = PyConfig_SetBytesString(&config, &config.program_name,
                                          program_name);
         if (PyStatus_Exception(status)) {
             goto done;
         }

         /* Read all configuration at once */
         status = PyConfig_Read(&config);
         if (PyStatus_Exception(status)) {
             goto done;
         }

         /* Specify sys.path explicitly */
         /* If you want to modify the default set of paths, finish
            initialization first and then use PySys_GetObject("path") */
         config.module_search_paths_set = 1;
         status = PyWideStringList_Append(&config.module_search_paths,
                                          L"/path/to/stdlib");
         if (PyStatus_Exception(status)) {
             goto done;
         }
         status = PyWideStringList_Append(&config.module_search_paths,
                                          L"/path/to/more/modules");
         if (PyStatus_Exception(status)) {
             goto done;
         }

         /* Override executable computed by PyConfig_Read() */
         status = PyConfig_SetString(&config, &config.executable,
                                     L"/path/to/my_executable");
         if (PyStatus_Exception(status)) {
             goto done;
         }

         status = Py_InitializeFromConfig(&config);

     done:
         PyConfig_Clear(&config);
         return status;
     }


File: python.info,  Node: Isolated Configuration,  Next: Python Configuration,  Prev: Initialization with PyConfig,  Up: Python 初期化設定

7.10.8 Isolated Configuration
-----------------------------

*note PyPreConfig_InitIsolatedConfig(): 984. and *note
PyConfig_InitIsolatedConfig(): 97e. functions create a configuration to
isolate Python from the system.  For example, to embed Python into an
application.

This configuration ignores global configuration variables, environment
variables, command line arguments (*note PyConfig.argv: 39d. 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.

Configuration files are still used with this configuration to determine
paths that are unspecified.  Ensure *note PyConfig.home: 395. is
specified to avoid computing the default path configuration.


File: python.info,  Node: Python Configuration,  Next: Python Path Configuration,  Prev: Isolated Configuration,  Up: Python 初期化設定

7.10.9 Python Configuration
---------------------------

*note PyPreConfig_InitPythonConfig(): 985. and *note
PyConfig_InitPythonConfig(): 97f. functions create a configuration to
build a customized Python which behaves as the regular Python.

Environments variables and command line arguments are used to configure
Python, whereas global configuration variables are ignored.

This function enables C locale coercion ( PEP 538(1)) and *note Python
UTF-8 Mode: 622. ( PEP 540(2)) depending on the LC_CTYPE locale, *note
PYTHONUTF8: aa6. and *note PYTHONCOERCECLOCALE: aa3. environment
variables.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0538/

   (2) https://peps.python.org/pep-0540/


File: python.info,  Node: Python Path Configuration,  Next: Py_GetArgcArgv,  Prev: Python Configuration,  Up: Python 初期化設定

7.10.10 Python Path Configuration
---------------------------------

*note PyConfig: 380. contains multiple fields for the path
configuration:

   * Path configuration inputs:

        * *note PyConfig.home: 395.

        * *note PyConfig.platlibdir: 18a8.

        * *note PyConfig.pathconfig_warnings: 3b1.

        * *note PyConfig.program_name: 39e.

        * *note PyConfig.pythonpath_env: 4c31.

        * current working directory: to get absolute paths

        * ‘PATH’ environment variable to get the program full path (from
          *note PyConfig.program_name: 39e.)

        * ‘__PYVENV_LAUNCHER__’ environment variable

        * (Windows only) Application paths in the registry under
          "SoftwarePythonPythonCoreX.YPythonPath" of HKEY_CURRENT_USER
          and HKEY_LOCAL_MACHINE (where X.Y is the Python version).

   * Path configuration output fields:

        * *note PyConfig.base_exec_prefix: 4c22.

        * *note PyConfig.base_executable: 4c24.

        * *note PyConfig.base_prefix: 4c25.

        * *note PyConfig.exec_prefix: 4c23.

        * *note PyConfig.executable: 37f.

        * *note PyConfig.module_search_paths_set: 5b9, *note
          PyConfig.module_search_paths: 37c.

        * *note PyConfig.prefix: 4c26.

If at least one "output field" is not set, Python calculates the path
configuration to fill unset fields.  If *note module_search_paths_set:
5b9. is equal to ‘0’, *note module_search_paths: 37c. is overridden and
*note module_search_paths_set: 5b9. is set to ‘1’.

It is possible to completely ignore the function calculating the default
path configuration by setting explicitly all path configuration output
fields listed above.  A string is considered as set even if it is
non-empty.  ‘module_search_paths’ is considered as set if
‘module_search_paths_set’ is set to ‘1’.  In this case,
‘module_search_paths’ will be used without modification.

Set *note pathconfig_warnings: 3b1. to ‘0’ to suppress warnings when
calculating the path configuration (Unix only, Windows does not log any
warning).

If *note base_prefix: 4c25. or *note base_exec_prefix: 4c22. fields are
not set, they inherit their value from *note prefix: 4c26. and *note
exec_prefix: 4c23. respectively.

*note Py_RunMain(): 993. and *note Py_Main(): bf3. modify *note
sys.path: 38e.:

   * If *note run_filename: 4bd0. is set and is a directory which
     contains a ‘__main__.py’ script, prepend *note run_filename: 4bd0.
     to *note sys.path: 38e.

   * If *note isolated: 3be. is zero:

        * If *note run_module: 4bd1. is set, prepend the current
          directory to *note sys.path: 38e.  Do nothing if the current
          directory cannot be read.

        * If *note run_filename: 4bd0. is set, prepend the directory of
          the filename to *note sys.path: 38e.

        * Otherwise, prepend an empty string to *note sys.path: 38e.

If *note site_import: 3ad. is non-zero, *note sys.path: 38e. can be
modified by the *note site: b5. module.  If *note user_site_directory:
3b7. is non-zero and the user's site-package directory exists, the *note
site: b5. module appends the user's site-package directory to *note
sys.path: 38e.

The following configuration files are used by the path configuration:

   * ‘pyvenv.cfg’

   * ‘._pth’ file (ex: ‘python._pth’)

   * ‘pybuilddir.txt’ (Unix only)

If a ‘._pth’ file is present:

   * Set *note isolated: 3be. to ‘1’.

   * Set *note use_environment: 3b3. to ‘0’.

   * Set *note site_import: 3ad. to ‘0’.

   * Set *note safe_path: 73e. to ‘1’.

The ‘__PYVENV_LAUNCHER__’ environment variable is used to set *note
PyConfig.base_executable: 4c24.


File: python.info,  Node: Py_GetArgcArgv,  Next: Multi-Phase Initialization Private Provisional API,  Prev: Python Path Configuration,  Up: Python 初期化設定

7.10.11 Py_GetArgcArgv()
------------------------

 -- C の関数: void Py_GetArgcArgv (int *argc, wchar_t ***argv)

     Get the original command line arguments, before Python modified
     them.

     See also *note PyConfig.orig_argv: 861. member.


File: python.info,  Node: Multi-Phase Initialization Private Provisional API,  Prev: Py_GetArgcArgv,  Up: Python 初期化設定

7.10.12 Multi-Phase Initialization Private Provisional API
----------------------------------------------------------

This section is a private provisional API introducing multi-phase
initialization, the core feature of PEP 432(1):

   * "Core" initialization phase, "bare minimum Python":

        * Builtin types;

        * Builtin exceptions;

        * Builtin and frozen modules;

        * The *note sys: c3. module is only partially initialized (ex:
          *note sys.path: 38e. doesn't exist yet).

   * "Main" initialization phase, Python is fully initialized:

        * Install and configure *note importlib: 6b.;

        * Apply the *note Path Configuration: 87b.;

        * Install signal handlers;

        * Finish *note sys: c3. module initialization (ex: create *note
          sys.stdout: aa4. and *note sys.path: 38e.);

        * Enable optional features like *note faulthandler: 4e. and
          *note tracemalloc: e8.;

        * Import the *note site: b5. module;

        * etc.

Private provisional API:

   * ‘PyConfig._init_main’: if set to ‘0’, *note
     Py_InitializeFromConfig(): 39f. stops at the "Core" initialization
     phase.

 -- C の関数: *note PyStatus: 97b. _Py_InitializeMain (void)

     Move to the "Main" initialization phase, finish the Python
     initialization.

No module is imported during the "Core" phase and the ‘importlib’ module
is not configured: the *note Path Configuration: 87b. is only applied
during the "Main" phase.  It may allow to customize Python in Python to
override or tune the *note Path Configuration: 87b, maybe install a
custom *note sys.meta_path: cf9. importer or an import hook, etc.

It may become possible to calculate the *note Path Configuration: 87b.
in Python, after the Core phase and before the Main phase, which is one
of the PEP 432(2) motivation.

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.

Example running Python code between "Core" and "Main" initialization
phases:

     void init_python(void)
     {
         PyStatus status;

         PyConfig config;
         PyConfig_InitPythonConfig(&config);
         config._init_main = 0;

         /* ... customize 'config' configuration ... */

         status = Py_InitializeFromConfig(&config);
         PyConfig_Clear(&config);
         if (PyStatus_Exception(status)) {
             Py_ExitStatusException(status);
         }

         /* Use sys.stderr because sys.stdout is only created
            by _Py_InitializeMain() */
         int res = PyRun_SimpleString(
             "import sys; "
             "print('Run Python code before _Py_InitializeMain', "
                    "file=sys.stderr)");
         if (res < 0) {
             exit(1);
         }

         /* ... put more configuration code here ... */

         status = _Py_InitializeMain();
         if (PyStatus_Exception(status)) {
             Py_ExitStatusException(status);
         }
     }

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0432/

   (2) https://peps.python.org/pep-0432/


File: python.info,  Node: メモリ管理,  Next: オブジェクト実装サポート object implementation support,  Prev: Python 初期化設定,  Up: Python/C API リファレンスマニュアル

7.11 メモリ管理
===============

* Menu:

* 概要: 概要<4>.
* Allocator Domains::
* 生メモリインターフェース::
* メモリインターフェース::
* オブジェクトアロケータ::
* Default Memory Allocators::
* メモリアロケータをカスタマイズする::
* Debug hooks on the Python memory allocators::
* pymalloc アロケータ::
* The mimalloc allocator::
* tracemalloc C API::
* 使用例: 使用例<54>.


File: python.info,  Node: 概要<4>,  Next: Allocator Domains,  Up: メモリ管理

7.11.1 概要
-----------

Python におけるメモリ管理には、全ての Python オブジェクトとデータ構造が
入ったプライベートヒープ (private heap) が必須です。プライベートヒープの
管理は、内部的には 'Python メモリマネージャ (Python memory manager)' が
確実に行います。Python メモリマネージャには、共有 (sharing)、セグメント
分割 (segmentation)、事前割り当て (preallocation)、キャッシュ化
(caching) といった、様々な動的記憶管理の側面を扱うために、個別のコンポー
ネントがあります。

最低水準層では、素のメモリ操作関数 (raw memory allocator) がオペレーティ
ングシステムのメモリ管理機構とやりとりして、プライベートヒープ内にPython
関連の全てのデータを記憶するのに十分な空きがあるかどうか確認します。素の
メモリ操作関数の上には、いくつかのオブジェクト固有のメモリ操作関数があり
ます。これらは同じヒープを操作し、各オブジェクト型固有の事情に合ったメモ
リ管理ポリシを実装しています。例えば、整数オブジェクトは文字列やタプル、
辞書とは違ったやり方でヒープ内で管理されます。というのも、整数には値を記
憶する上で特別な要件があり、速度/容量のトレードオフが存在するからです。
このように、Python メモリマネジャは作業のいくつかをオブジェクト固有のメ
モリ操作関数に委譲しますが、これらの関数がプライベートヒープからはみ出し
てメモリ管理を行わないようにしています。

重要なのは、たとえユーザがいつもヒープ内のメモリブロックを指すようなオブ
ジェクトポインタを操作しているとしても、Python 用ヒープの管理はインタプ
リタ自体が行うもので、ユーザがそれを制御する余地はないと理解することです
。Python オブジェクトや内部使用されるバッファを入れるためのヒープ空間の
メモリ確保は、必要に応じて、Python メモリマネージャがこのドキュメント内
で列挙しているPython/C API 関数群を介して行います。

メモリ管理の崩壊を避けるため、拡張モジュールの作者は決して Python オブジ
ェクトを C ライブラリが公開している関数: ‘malloc()’ 、 ‘calloc()’ 、
‘realloc()’ および ‘free()’ で操作しようとしてはなりません。こうした関数
を使うと、C のメモリ操作関数と Python メモリマネージャとの間で関数呼び出
しが交錯します。 C のメモリ操作関数とPython メモリマネージャは異なるアル
ゴリズムで実装されていて、異なるヒープを操作するため、呼び出しの交錯は致
命的な結果を招きます。とはいえ、個別の目的のためなら、 C ライブラリのメ
モリ操作関数を使って安全にメモリを確保したり解放したりできます。例えば、
以下がそのような例です:

     PyObject *res;
     char *buf = (char *) malloc(BUFSIZ); /* for I/O */

     if (buf == NULL)
         return PyErr_NoMemory();
     ...Do some I/O operation involving buf...
     res = PyBytes_FromString(buf);
     free(buf); /* malloc'ed */
     return res;

この例では、I/O バッファに対するメモリ要求は C ライブラリのメモリ操作関
数を使っています。Python メモリマネージャーは戻り値として返される bytes
オブジェクトを確保する時にだけ必要です。

とはいえ、ほとんどの状況では、メモリの操作は Python ヒープに固定して行う
よう勧めます。なぜなら、Python ヒープは Python メモリマネジャの管理下に
あるからです。例えば、インタプリタを C で書かれた新たなオブジェクト型で
拡張する際には、ヒープでのメモリ管理が必要です。Python ヒープを使った方
がよいもう一つの理由として、拡張モジュールが必要としているメモリについて
Python メモリマネージャに '情報を提供' してほしいということがあります。
たとえ必要なメモリが内部的かつ非常に特化した用途に対して排他的に用いられ
るものだとしても、全てのメモリ操作要求を Python メモリマネージャに委譲す
れば、インタプリタはより正確なメモリフットプリントの全体像を把握できます
。その結果、特定の状況では、Python メモリマネージャがガベージコレクショ
ンやメモリのコンパクト化、その他何らかの予防措置といった、適切な動作をト
リガできることがあります。上の例で示したように C ライブラリのメモリ操作
関数を使うと、I/O バッファ用に確保したメモリは Python メモリマネージャの
管理から完全に外れることに注意してください。

参考
....

環境変数 *note PYTHONMALLOC: c32. を使用して Python が利用するメモリアロ
ケータを制御することができます。

環境変数 *note PYTHONMALLOCSTATS: 1ac1. を使用して、新たなオブジェクトア
リーナが生成される時と、シャットダウン時に *note pymalloc
メモリアロケータ: cdd. の統計情報を表示できます。


File: python.info,  Node: Allocator Domains,  Next: 生メモリインターフェース,  Prev: 概要<4>,  Up: メモリ管理

7.11.2 Allocator Domains
------------------------

All allocating functions belong to one of three different "domains" (see
also *note PyMemAllocatorDomain: 4c45.).  These domains represent
different allocation strategies and are optimized for different
purposes.  The specific details on how every domain allocates memory or
what internal functions each domain calls is considered an
implementation detail, but for debugging purposes a simplified table can
be found at *note here: 1cba.  The APIs used to allocate and free a
block of memory must be from the same domain.  For example, *note
PyMem_Free(): 13ea. must be used to free memory allocated using *note
PyMem_Malloc(): c33.

The three allocation domains are:

   * Raw domain: intended for allocating memory for general-purpose
     memory buffers where the allocation 'must' go to the system
     allocator or where the allocator can operate without the *note GIL:
     13f.  The memory is requested directly from the system.  See *note
     Raw Memory Interface: 4c46.

   * "Mem" domain: intended for allocating memory for Python buffers and
     general-purpose memory buffers where the allocation must be
     performed with the *note GIL: 13f. held.  The memory is taken from
     the Python private heap.  See *note Memory Interface: 4c47.

   * Object domain: intended for allocating memory for Python objects.
     The memory is taken from the Python private heap.  See *note Object
     allocators: 4c48.

     注釈: The *note free-threaded: 433e. 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.

     For example, buffers (non-Python objects) should be allocated using
     *note PyMem_Malloc(): c33, *note PyMem_RawMalloc(): 369, or
     ‘malloc()’, but not *note PyObject_Malloc(): c36.

     See *note Memory Allocation APIs: 4c49.


File: python.info,  Node: 生メモリインターフェース,  Next: メモリインターフェース,  Prev: Allocator Domains,  Up: メモリ管理

7.11.3 生メモリインターフェース
-------------------------------

以下の関数群はシステムのアロケータをラップします。 これらの関数はスレッ
ドセーフで、 *note GIL: 12e. を保持していなくても呼び出すことができます
。

The *note default raw memory allocator: 1cba. uses the following
functions: ‘malloc()’, ‘calloc()’, ‘realloc()’ and ‘free()’; call
‘malloc(1)’ (or ‘calloc(1, 1)’) when requesting zero bytes.

Added in version 3.4.

 -- C の関数: void *PyMem_RawMalloc (size_t n)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     'n' バイトを割り当て、そのメモリを指す void* 型のポインタを返します
     。要求が失敗した場合 ‘NULL’ を返します。

     0バイトを要求すると、 ‘PyMem_RawMalloc(1)’ が呼ばれたときと同じよう
     に、可能なら ‘NULL’ でないユニークなポインタを返します。確保された
     メモリーにはいかなる初期化も行われません。

 -- C の関数: void *PyMem_RawCalloc (size_t nelem, size_t elsize)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'  各
     要素が 'elsize' バイトの要素 'nelem' 個分のメモリーを確保し、そのメ
     モリーを指す void* 型のポインタを返します。アロケートに失敗した場合
     は ‘NULL’ を返します。確保されたメモリー領域はゼロで初期化されます
     。

     要素数か要素のサイズが0バイトの要求に対しては、可能なら
     ‘PyMem_RawCalloc(1, 1)’ が呼ばれたのと同じように、ユニークな ‘NULL’
     でないポインタを返します。

     Added in version 3.5.

 -- C の関数: void *PyMem_RawRealloc (void *p, size_t n)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     'p' が指すメモリブロックを 'n' バイトにリサイズします。古いサイズと
     新しいサイズの小さい方までの内容は変更されません。

     'p' が ‘NULL’ の場合呼び出しは ‘PyMem_RawMalloc(n)’ と等価です。そ
     うでなく、 'n' がゼロに等しい場合、メモリブロックはリサイズされます
     が解放されません。返されたポインタは非 ‘NULL’ です。

     'p' が ‘NULL’ でない限り、'p' はそれより前の *note
     PyMem_RawMalloc(): 369, *note PyMem_RawRealloc(): 36b, *note
     PyMem_RawCalloc(): 36a. の呼び出しにより返されなければなりません。

     要求が失敗した場合 *note PyMem_RawRealloc(): 36b. は ‘NULL’ を返し
     、 'p' は前のメモリエリアをさす有効なポインタのままです。

 -- C の関数: void PyMem_RawFree (void *p)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     'p' が指すメモリブロックを解放します。 'p' は以前呼び出した *note
     PyMem_RawMalloc(): 369, *note PyMem_RawRealloc(): 36b, *note
     PyMem_RawCalloc(): 36a. の返した値でなければなりません。それ以外の
     場合や ‘PyMem_RawFree(p)’ を呼び出した後だった場合、未定義の動作に
     なります。

     'p' が ‘NULL’ の場合何もしません。


File: python.info,  Node: メモリインターフェース,  Next: オブジェクトアロケータ,  Prev: 生メモリインターフェース,  Up: メモリ管理

7.11.4 メモリインターフェース
-----------------------------

以下の関数群が利用して Python ヒープに対してメモリを確保したり解放したり
出来ます。これらの関数は ANSI C 標準に従ってモデル化されていますが、0 バ
イトを要求した際の動作についても定義しています:

The *note default memory allocator: 1cba. uses the *note pymalloc memory
allocator: cdd.

     警告: これらの関数を呼ぶときには、 *note GIL: 12e. を保持しておく必
     要があります。

バージョン 3.6 で変更: デフォルトのアロケータがシステムの ‘malloc()’ か
ら pymalloc になりました。

 -- C の関数: void *PyMem_Malloc (size_t n)
     ' 次に属します: *note Stable ABI: 51e.'  'n' バイトを割り当て、その
     メモリを指す void* 型のポインタを返します。要求が失敗した場合
     ‘NULL’ を返します。

     0バイトを要求すると、 ‘PyMem_Malloc(1)’ が呼ばれたときと同じように
     、可能なら ‘NULL’ でないユニークなポインタを返します。 確保されたメ
     モリーにはいかなる初期化も行われません。

 -- C の関数: void *PyMem_Calloc (size_t nelem, size_t elsize)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  各
     要素が 'elsize' バイトの要素 'nelem' 個分のメモリーを確保し、そのメ
     モリーを指す void* 型のポインタを返します。アロケートに失敗した場合
     は ‘NULL’ を返します。確保されたメモリー領域はゼロで初期化されます
     。

     要素数か要素のサイズが0バイトの要求に対しては、可能なら
     ‘PyMem_Calloc(1, 1)’ が呼ばれたのと同じように、ユニークな ‘NULL’ で
     ないポインタを返します。

     Added in version 3.5.

 -- C の関数: void *PyMem_Realloc (void *p, size_t n)
     ' 次に属します: *note Stable ABI: 51e.'  'p' が指すメモリブロックを
     'n' バイトにリサイズします。古いサイズと新しいサイズの小さい方まで
     の内容は変更されません。

     'p' が ‘NULL’ の場合呼び出しは ‘PyMem_Malloc(n)’ と等価です。そうで
     なく、 'n' がゼロに等しい場合、メモリブロックはリサイズされますが解
     放されません。返されたポインタは非 ‘NULL’ です。

     'p' が ‘NULL’ でない限り、'p' はそれより前の *note PyMem_Malloc():
     c33, *note PyMem_Realloc(): ffc. または *note PyMem_Calloc(): e76.
     の呼び出しにより返されなければなりません。

     要求が失敗した場合 *note PyMem_Realloc(): ffc. は ‘NULL’ を返し、
     'p' は前のメモリエリアをさす有効なポインタのままです。

 -- C の関数: void PyMem_Free (void *p)
     ' 次に属します: *note Stable ABI: 51e.'  'p' が指すメモリブロックを
     解放します。 'p' は以前呼び出した *note PyMem_Malloc(): c33.、
     *note PyMem_Realloc(): ffc.、または *note PyMem_Calloc(): e76. の返
     した値でなければなりません。それ以外の場合や ‘PyMem_Free(p)’ を呼び
     出した後だった場合、未定義の動作になります。

     'p' が ‘NULL’ の場合何もしません。

以下に挙げる型対象のマクロは利便性のために提供されているものです。'TYPE'
は任意の C の型を表します。

 -- C のマクロ: PyMem_New (TYPE, n)

     Same as *note PyMem_Malloc(): c33, but allocates ‘(n *
     sizeof(TYPE))’ bytes of memory.  Returns a pointer cast to ‘TYPE*’.
     The memory will not have been initialized in any way.

 -- C のマクロ: PyMem_Resize (p, TYPE, n)

     Same as *note PyMem_Realloc(): ffc, 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.

     これは C プリプロセッサマクロです。'p' は常に再代入されます。エラー
     処理時にメモリを失うのを避けるには 'p' の元の値を保存してください。

 -- C の関数: void PyMem_Del (void *p)

     *note PyMem_Free(): 13ea. と同じです。

上記に加えて、C API 関数を介することなく Python メモリ操作関数を直接呼び
出すための以下のマクロセットが提供されています。ただし、これらのマクロは
Python バージョン間でのバイナリ互換性を保てず、それゆえに拡張モジュール
では撤廃されているので注意してください。

   * ‘PyMem_MALLOC(size)’

   * ‘PyMem_NEW(type, size)’

   * ‘PyMem_REALLOC(ptr, size)’

   * ‘PyMem_RESIZE(ptr, type, size)’

   * ‘PyMem_FREE(ptr)’

   * ‘PyMem_DEL(ptr)’


File: python.info,  Node: オブジェクトアロケータ,  Next: Default Memory Allocators,  Prev: メモリインターフェース,  Up: メモリ管理

7.11.5 オブジェクトアロケータ
-----------------------------

以下の関数群が利用して Python ヒープに対してメモリを確保したり解放したり
出来ます。これらの関数は ANSI C 標準に従ってモデル化されていますが、0 バ
イトを要求した際の動作についても定義しています:

     注釈: 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 *note Customize Memory Allocators: 4c4e. section.

The *note default object allocator: 1cba. uses the *note pymalloc memory
allocator: cdd.

     警告: これらの関数を呼ぶときには、 *note GIL: 12e. を保持しておく必
     要があります。

 -- C の関数: void *PyObject_Malloc (size_t n)
     ' 次に属します: *note Stable ABI: 51e.'  'n' バイトを割り当て、その
     メモリを指す void* 型のポインタを返します。要求が失敗した場合
     ‘NULL’ を返します。

     0バイトを要求すると、 ‘PyObject_Malloc(1)’ が呼ばれたときと同じよう
     に、可能なら ‘NULL’ でないユニークなポインタを返します。 確保された
     メモリーにはいかなる初期化も行われません。

 -- C の関数: void *PyObject_Calloc (size_t nelem, size_t elsize)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.7 より).'  各
     要素が 'elsize' バイトの要素 'nelem' 個分のメモリーを確保し、そのメ
     モリーを指す void* 型のポインタを返します。アロケートに失敗した場合
     は ‘NULL’ を返します。確保されたメモリー領域はゼロで初期化されます
     。

     要素数か要素のサイズが0バイトの要求に対しては、可能なら
     ‘PyObject_Calloc(1, 1)’ が呼ばれたのと同じように、ユニークな ‘NULL’
     でないポインタを返します。

     Added in version 3.5.

 -- C の関数: void *PyObject_Realloc (void *p, size_t n)
     ' 次に属します: *note Stable ABI: 51e.'  'p' が指すメモリブロックを
     'n' バイトにリサイズします。古いサイズと新しいサイズの小さい方まで
     の内容は変更されません。

     'p' が ‘NULL’ の場合呼び出しは ‘PyObject_Malloc(n)’ と等価です。そ
     うでなく、 'n' がゼロに等しい場合、メモリブロックはリサイズされます
     が解放されません。返されたポインタは非 ‘NULL’ です。

     'p' が ‘NULL’ でない限り、'p' はそれより前の *note
     PyObject_Malloc(): c36, *note PyObject_Realloc(): 13eb. または
     *note PyObject_Calloc(): e77. の呼び出しにより返されなければなりま
     せん。

     要求が失敗した場合 *note PyObject_Realloc(): 13eb. は ‘NULL’ を返し
     、 'p' は前のメモリエリアをさす有効なポインタのままです。

 -- C の関数: void PyObject_Free (void *p)
     ' 次に属します: *note Stable ABI: 51e.'  'p' が指すメモリブロックを
     解放します。 'p' は以前呼び出した *note PyObject_Malloc(): c36.、
     *note PyObject_Realloc(): 13eb.、または *note PyObject_Calloc():
     e77. の返した値でなければなりません。それ以外の場合や
     ‘PyObject_Free(p)’ を呼び出した後だった場合、未定義の動作になります
     。

     'p' が ‘NULL’ の場合何もしません。


File: python.info,  Node: Default Memory Allocators,  Next: メモリアロケータをカスタマイズする,  Prev: オブジェクトアロケータ,  Up: メモリ管理

7.11.6 Default Memory Allocators
--------------------------------

Default memory allocators:

Configuration                       名前                     PyMem_RawMalloc        PyMem_Malloc              PyObject_Malloc
                                                                                                              
---------------------------------------------------------------------------------------------------------------------------------------
                                                                                                              
リリースビルド                      ‘"pymalloc"’             ‘malloc’               ‘pymalloc’                ‘pymalloc’
                                                                                                              
                                                                                                              
デバッグビルド                      ‘"pymalloc_debug"’       ‘malloc’ + debug       ‘pymalloc’ + debug        ‘pymalloc’ + debug
                                                                                                              
                                                                                                              
pymalloc 無しのリリースビルド       ‘"malloc"’               ‘malloc’               ‘malloc’                  ‘malloc’
                                                                                                              
                                                                                                              
pymalloc 無しのデバッグビルド       ‘"malloc_debug"’         ‘malloc’ + debug       ‘malloc’ + debug          ‘malloc’ + debug
                                                                                                              

説明:

   * Name: value for *note PYTHONMALLOC: c32. environment variable.

   * ‘malloc’: system allocators from the standard C library, C
     functions: ‘malloc()’, ‘calloc()’, ‘realloc()’ and ‘free()’.

   * ‘pymalloc’: *note pymalloc memory allocator: cdd.

   * ‘mimalloc’: *note mimalloc memory allocator: 1cbc.  The pymalloc
     allocator will be used if mimalloc support isn't available.

   * "+ debug": with *note debug hooks on the Python memory allocators:
     1cbd.

   * "Debug build": *note Python build in debug mode: 1da.


File: python.info,  Node: メモリアロケータをカスタマイズする,  Next: Debug hooks on the Python memory allocators,  Prev: Default Memory Allocators,  Up: メモリ管理

7.11.7 メモリアロケータをカスタマイズする
-----------------------------------------

Added in version 3.4.

 -- C のデータ型: type PyMemAllocatorEx

     Structure used to describe a memory block allocator.  The structure
     has the following fields:

     フィールド                                                     意味
                                                                    
     -----------------------------------------------------------------------------------------------------------
                                                                    
     ‘void *ctx’                                                    第一引数として渡されるユーザコンテキスト
                                                                    
                                                                    
     ‘void* malloc(void *ctx, size_t size)’                         メモリブロックを割り当てます
                                                                    
                                                                    
     ‘void* calloc(void *ctx, size_t nelem, size_t elsize)’         0で初期化されたメモリブロックを割り当てま
                                                                    す
                                                                    
                                                                    
     ‘void* realloc(void *ctx, void *ptr, size_t new_size)’         メモリブロックを割り当てるかリサイズしま
                                                                    す
                                                                    
                                                                    
     ‘void free(void *ctx, void *ptr)’                              メモリブロックを解放する
                                                                    

     バージョン 3.5 で変更: The ‘PyMemAllocator’ structure was renamed
     to *note PyMemAllocatorEx: e97. and a new ‘calloc’ field was added.

 -- C のデータ型: type PyMemAllocatorDomain

     アロケータドメインを同定するための列挙型です。ドメインは:

      -- C のマクロ: PYMEM_DOMAIN_RAW

          関数:

             * *note PyMem_RawMalloc(): 369.

             * *note PyMem_RawRealloc(): 36b.

             * *note PyMem_RawCalloc(): 36a.

             * *note PyMem_RawFree(): 36c.

      -- C のマクロ: PYMEM_DOMAIN_MEM

          関数:

             * *note PyMem_Malloc(): c33,

             * *note PyMem_Realloc(): ffc.

             * *note PyMem_Calloc(): e76.

             * *note PyMem_Free(): 13ea.

      -- C のマクロ: PYMEM_DOMAIN_OBJ

          関数:

             * *note PyObject_Malloc(): c36.

             * *note PyObject_Realloc(): 13eb.

             * *note PyObject_Calloc(): e77.

             * *note PyObject_Free(): c34.

 -- C の関数: void PyMem_GetAllocator (PyMemAllocatorDomain domain,
          PyMemAllocatorEx *allocator)

     指定されたドメインのメモリブロックアロケータを取得します。

 -- C の関数: void PyMem_SetAllocator (PyMemAllocatorDomain domain,
          PyMemAllocatorEx *allocator)

     指定されたドメインのメモリブロックアロケータを設定します。

     新しいアロケータは、0バイトを要求されたときユニークな ‘NULL’ でない
     ポインタを返さなければなりません。

     For the *note PYMEM_DOMAIN_RAW: 1cbb. domain, the allocator must be
     thread-safe: the *note GIL: 12e. is not held when the allocator is
     called.

     For the remaining domains, the allocator must also be thread-safe:
     the allocator may be called in different interpreters that do not
     share a ‘GIL’.

     新しいアロケータがフックでない (1つ前のアロケータを呼び出さない) 場
     合、 *note PyMem_SetupDebugHooks(): c38. 関数を呼び出して、新しいア
     ロケータの上にデバッグフックを再度設置しなければなりません。

     See also *note PyPreConfig.allocator: 4c16. and *note Preinitialize
     Python with PyPreConfig: 3bcb.

          警告: *note PyMem_SetAllocator(): 557. does have the following
          contract:

             * It can be called after *note Py_PreInitialize(): 3c5. and
               before *note Py_InitializeFromConfig(): 39f. to install a
               custom memory allocator.  There are no restrictions over
               the installed allocator other than the ones imposed by
               the domain (for instance, the Raw Domain allows the
               allocator to be called without the GIL held).  See *note
               the section on allocator domains: 4c44. for more
               information.

             * If called after Python has finish initializing (after
               *note Py_InitializeFromConfig(): 39f. has been called)
               the allocator 'must' wrap the existing allocator.
               Substituting the current allocator for some other
               arbitrary one is 'not supported'.

     バージョン 3.12 で変更: All allocators must be thread-safe.

 -- C の関数: void PyMem_SetupDebugHooks (void)

     Setup *note debug hooks in the Python memory allocators: 1cbd. to
     detect memory errors.


File: python.info,  Node: Debug hooks on the Python memory allocators,  Next: pymalloc アロケータ,  Prev: メモリアロケータをカスタマイズする,  Up: メモリ管理

7.11.8 Debug hooks on the Python memory allocators
--------------------------------------------------

When *note Python is built in debug mode: 1da, the *note
PyMem_SetupDebugHooks(): c38. function is called at the *note Python
preinitialization: 3bcb. to setup debug hooks on Python memory
allocators to detect memory errors.

The *note PYTHONMALLOC: c32. environment variable can be used to install
debug hooks on a Python compiled in release mode (ex:
‘PYTHONMALLOC=debug’).

The *note PyMem_SetupDebugHooks(): c38. function can be used to set
debug hooks after calling *note PyMem_SetAllocator(): 557.

These debug hooks fill dynamically allocated memory blocks with special,
recognizable bit patterns.  Newly allocated memory is filled with the
byte ‘0xCD’ (‘PYMEM_CLEANBYTE’), freed memory is filled with the byte
‘0xDD’ (‘PYMEM_DEADBYTE’).  Memory blocks are surrounded by "forbidden
bytes" filled with the byte ‘0xFD’ (‘PYMEM_FORBIDDENBYTE’).  Strings of
these bytes are unlikely to be valid addresses, floats, or ASCII
strings.

実行時チェック:

   - Detect API violations.  For example, detect if *note
     PyObject_Free(): c34. is called on a memory block allocated by
     *note PyMem_Malloc(): c33.

   - Detect write before the start of the buffer (buffer underflow).

   - Detect write after the end of the buffer (buffer overflow).

   - Check that the *note GIL: 12e. is held when allocator functions of
     *note PYMEM_DOMAIN_OBJ: c35. (ex: *note PyObject_Malloc(): c36.)
     and *note PYMEM_DOMAIN_MEM: c37. (ex: *note PyMem_Malloc(): c33.)
     domains are called.

On error, the debug hooks use the *note tracemalloc: e8. module to get
the traceback where a memory block was allocated.  The traceback is only
displayed if *note tracemalloc: e8. is tracing Python memory allocations
and the memory block was traced.

Let 'S' = ‘sizeof(size_t)’.  ‘2*S’ bytes are added at each end of each
block of 'N' bytes requested.  The memory layout is like so, where p
represents the address returned by a malloc-like or realloc-like
function (‘p[i:j]’ means the slice of bytes from ‘*(p+i)’ inclusive up
to ‘*(p+j)’ exclusive; note that the treatment of negative indices
differs from a Python slice):

‘p[-2*S:-S]’

     Number of bytes originally asked for.  This is a size_t, big-endian
     (easier to read in a memory dump).

‘p[-S]’

     API identifier (ASCII character):

        * ‘'r'’ for *note PYMEM_DOMAIN_RAW: 1cbb.

        * ‘'m'’ for *note PYMEM_DOMAIN_MEM: c37.

        * ‘'o'’ for *note PYMEM_DOMAIN_OBJ: c35.

‘p[-S+1:0]’

     Copies of PYMEM_FORBIDDENBYTE. Used to catch under- writes and
     reads.

‘p[0:N]’

     The requested memory, filled with copies of PYMEM_CLEANBYTE, used
     to catch reference to uninitialized memory.  When a realloc-like
     function is called requesting a larger memory block, the new excess
     bytes are also filled with PYMEM_CLEANBYTE. When a free-like
     function is called, these are overwritten with PYMEM_DEADBYTE, to
     catch reference to freed memory.  When a realloc- like function is
     called requesting a smaller memory block, the excess old bytes are
     also filled with PYMEM_DEADBYTE.

‘p[N:N+S]’

     Copies of PYMEM_FORBIDDENBYTE. Used to catch over- writes and
     reads.

‘p[N+S:N+2*S]’

     Only used if the ‘PYMEM_DEBUG_SERIALNO’ macro is defined (not
     defined by default).

     A serial number, incremented by 1 on each call to a malloc-like or
     realloc-like function.  Big-endian ‘size_t’.  If "bad memory" is
     detected later, the serial number gives an excellent way to set a
     breakpoint on the next run, to capture the instant at which this
     block was passed out.  The 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.

A realloc-like or free-like function first checks that the
PYMEM_FORBIDDENBYTE bytes at each end are intact.  If they've been
altered, diagnostic output is written to stderr, and the program is
aborted via Py_FatalError().  The other main failure mode is provoking a
memory error when a program reads up one of the special bit patterns and
tries to use it as an address.  If you get in a debugger then and look
at the object, you're likely to see that it's entirely filled with
PYMEM_DEADBYTE (meaning freed memory is getting used) or PYMEM_CLEANBYTE
(meaning uninitialized memory is getting used).

バージョン 3.6 で変更: The *note PyMem_SetupDebugHooks(): c38. function
now also works on Python compiled in release mode.  On error, the debug
hooks now use *note tracemalloc: e8. to get the traceback where a memory
block was allocated.  The debug hooks now also check if the GIL is held
when functions of *note PYMEM_DOMAIN_OBJ: c35. and *note
PYMEM_DOMAIN_MEM: c37. domains are called.

バージョン 3.8 で変更: 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()’.


File: python.info,  Node: pymalloc アロケータ,  Next: The mimalloc allocator,  Prev: Debug hooks on the Python memory allocators,  Up: メモリ管理

7.11.9 pymalloc アロケータ
--------------------------

Python has a 'pymalloc' allocator optimized for small objects (smaller
or equal to 512 bytes) with a short lifetime.  It uses memory mappings
called "arenas" with a fixed size of either 256 KiB on 32-bit platforms
or 1 MiB on 64-bit platforms.  It falls back to *note PyMem_RawMalloc():
369. and *note PyMem_RawRealloc(): 36b. for allocations larger than 512
bytes.

'pymalloc' is the *note default allocator: 1cba. of the *note
PYMEM_DOMAIN_MEM: c37. (ex: *note PyMem_Malloc(): c33.) and *note
PYMEM_DOMAIN_OBJ: c35. (ex: *note PyObject_Malloc(): c36.) domains.

アリーナアロケータは、次の関数を使います:

   * ‘VirtualAlloc()’ and ‘VirtualFree()’ on Windows,

   * ‘mmap()’ and ‘munmap()’ if available,

   * それ以外の場合は ‘malloc()’ と ‘free()’。

This allocator is disabled if Python is configured with the *note
-without-pymalloc: 1d18. option.  It can also be disabled at runtime
using the *note PYTHONMALLOC: c32. environment variable (ex:
‘PYTHONMALLOC=malloc’).

* Menu:

* pymalloc アリーナアロケータのカスタマイズ::


File: python.info,  Node: pymalloc アリーナアロケータのカスタマイズ,  Up: pymalloc アロケータ

7.11.9.1 pymalloc アリーナアロケータのカスタマイズ
..................................................

Added in version 3.4.

 -- C のデータ型: type PyObjectArenaAllocator

     アリーナアロケータを記述するための構造体です。3つのフィールドを持ち
     ます:

     フィールド                                             意味
                                                            
     ---------------------------------------------------------------------------------------------------
                                                            
     ‘void *ctx’                                            第一引数として渡されるユーザコンテキスト
                                                            
                                                            
     ‘void* alloc(void *ctx, size_t size)’                  size バイトのアリーナを割り当てます
                                                            
                                                            
     ‘void free(void *ctx, void *ptr, size_t size)’         アリーナを解放します
                                                            

 -- C の関数: void PyObject_GetArenaAllocator (PyObjectArenaAllocator
          *allocator)

     アリーナアロケータを取得します。

 -- C の関数: void PyObject_SetArenaAllocator (PyObjectArenaAllocator
          *allocator)

     アリーナアロケータを設定します。


File: python.info,  Node: The mimalloc allocator,  Next: tracemalloc C API,  Prev: pymalloc アロケータ,  Up: メモリ管理

7.11.10 The mimalloc allocator
------------------------------

Added in version 3.13.

Python supports the mimalloc allocator when the underlying platform
support is available.  mimalloc "is a general purpose allocator with
excellent performance characteristics.  Initially developed by Daan
Leijen for the runtime systems of the Koka and Lean languages."


File: python.info,  Node: tracemalloc C API,  Next: 使用例<54>,  Prev: The mimalloc allocator,  Up: メモリ管理

7.11.11 tracemalloc C API
-------------------------

Added in version 3.7.

 -- C の関数: int PyTraceMalloc_Track (unsigned int domain, uintptr_t
          ptr, size_t size)

     Track an allocated memory block in the *note tracemalloc: e8.
     module.

     Return ‘0’ on success, return ‘-1’ on error (failed to allocate
     memory to store the trace).  Return ‘-2’ if tracemalloc is
     disabled.

     If memory block is already tracked, update the existing trace.

 -- C の関数: int PyTraceMalloc_Untrack (unsigned int domain, uintptr_t
          ptr)

     Untrack an allocated memory block in the *note tracemalloc: e8.
     module.  Do nothing if the block was not tracked.

     Return ‘-2’ if tracemalloc is disabled, otherwise return ‘0’.


File: python.info,  Node: 使用例<54>,  Prev: tracemalloc C API,  Up: メモリ管理

7.11.12 使用例
--------------

最初に述べた関数セットを使って、 *note 概要: 4c41. 節の例を Python ヒー
プに I/O バッファをメモリ確保するように書き換えたものを以下に示します:

     PyObject *res;
     char *buf = (char *) PyMem_Malloc(BUFSIZ); /* for I/O */

     if (buf == NULL)
         return PyErr_NoMemory();
     /* ...Do some I/O operation involving buf... */
     res = PyBytes_FromString(buf);
     PyMem_Free(buf); /* allocated with PyMem_Malloc */
     return res;

同じコードを型対象の関数セットで書いたものを以下に示します:

     PyObject *res;
     char *buf = PyMem_New(char, BUFSIZ); /* for I/O */

     if (buf == NULL)
         return PyErr_NoMemory();
     /* ...Do some I/O operation involving buf... */
     res = PyBytes_FromString(buf);
     PyMem_Del(buf); /* allocated with PyMem_New */
     return res;

上の二つの例では、バッファを常に同じ関数セットに属する関数で操作している
ことに注意してください。実際、あるメモリブロックに対する操作は、異なるメ
モリ操作機構を混用する危険を減らすために、同じメモリ API ファミリを使っ
て行うことが必要です。以下のコードには二つのエラーがあり、そのうちの一つ
には異なるヒープを操作する別のメモリ操作関数を混用しているので '致命的
(Fatal)' とラベルづけをしています。

     char *buf1 = PyMem_New(char, BUFSIZ);
     char *buf2 = (char *) malloc(BUFSIZ);
     char *buf3 = (char *) PyMem_Malloc(BUFSIZ);
     ...
     PyMem_Del(buf3);  /* Wrong -- should be PyMem_Free() */
     free(buf2);       /* Right -- allocated via malloc() */
     free(buf1);       /* Fatal -- should be PyMem_Del()  */

In addition to the functions aimed at handling raw memory blocks from
the Python heap, objects in Python are allocated and released with *note
PyObject_New: 953, *note PyObject_NewVar: 954. and *note PyObject_Del():
147a.

これらの関数については、次章の C による新しいオブジェクト型の定義や実装
に関する記述の中で説明します。


File: python.info,  Node: オブジェクト実装サポート object implementation support,  Next: API と ABI のバージョニング,  Prev: メモリ管理,  Up: Python/C API リファレンスマニュアル

7.12 オブジェクト実装サポート (object implementation support)
=============================================================

この章では、新しいオブジェクトの型を定義する際に使われる関数、型、および
マクロについて説明します。

* Menu:

* オブジェクトをヒープ上にメモリ確保する::
* 共通のオブジェクト構造体 (common object structure): 共通のオブジェクト構造体 common object structure.
* 型オブジェクト: 型オブジェクト<3>.
* 循環参照ガベージコレクションをサポートする::


File: python.info,  Node: オブジェクトをヒープ上にメモリ確保する,  Next: 共通のオブジェクト構造体 common object structure,  Up: オブジェクト実装サポート object implementation support

7.12.1 オブジェクトをヒープ上にメモリ確保する
---------------------------------------------

 -- C の関数: *note PyObject: 312. *_PyObject_New (PyTypeObject *type)
     '戻り値: 新しい参照。'

 -- C の関数: *note PyVarObject: 3fe2. *_PyObject_NewVar (PyTypeObject
          *type, Py_ssize_t size)
     '戻り値: 新しい参照。'

 -- C の関数: *note PyObject: 312. *PyObject_Init (PyObject *op,
          PyTypeObject *type)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'
     Initialize a newly allocated object 'op' with its type and initial
     reference.  Returns the initialized object.  Other fields of the
     object are not affected.

 -- C の関数: *note PyVarObject: 3fe2. *PyObject_InitVar (PyVarObject
          *op, PyTypeObject *type, Py_ssize_t size)
     '戻り値: 借用参照。'' 次に属します: *note Stable ABI: 51e.'  *note
     PyObject_Init(): a38. の全ての処理を行い、可変サイズオブジェクトの
     場合には長さ情報も初期化します。

 -- C のマクロ: PyObject_New (TYPE, typeobj)

     C の構造体型 'TYPE' と Python の型オブジェクト 'typeobj' (
     ‘PyTypeObject*’ ) を用いて Python オブジェクトの領域を新規確保しま
     す。Python のオブジェクトヘッダに定義されていないフィールドは初期化
     されません。呼び出し元がオブジェクトへの唯一の参照を持ちます（つま
     り、参照カウントは１になります）。メモリ割り当ての大きさは型オブジ
     ェクトの *note tp_basicsize: 955. フィールドによって定められます。

 -- C のマクロ: PyObject_NewVar (TYPE, typeobj, size)

     C の構造体型 'TYPE' と Python の型オブジェクト 'typeobj' (
     ‘PyTypeObject*’ ) を用いて Python オブジェクトの領域を新規確保しま
     す。Python のオブジェクトヘッダに定義されていないフィールドは初期化
     されません。確保されたメモリには、 'TYPE' 構造体に加え、 'typeobj'
     の *note tp_itemsize: 1ed0. フィールドによって定められた大きさのフ
     ィールドを 'size' ( ‘Py_ssize_t’ ) 個分格納できます。これはタプルな
     どの、生成時に大きさを決定できるオブジェクトを実装する際に便利です
     。同じメモリ割当にフィールドの配列も埋め込むことで、メモリ割当の回
     数を減らし、メモリ管理効率を上げることができます。

 -- C の関数: void PyObject_Del (void *op)

     *note PyObject_New: 953. または *note PyObject_NewVar: 954. によっ
     て、オブジェクトのために確保されたメモリを解放します。これは通常オ
     ブジェクトの型に指定されている *note tp_dealloc: 477a. ハンドラから
     呼び出されます。これの呼び出し後のメモリは既に有効な Python オブジ
     ェクトではなくなっているため、オブジェクトのフィールドはアクセスさ
     れるべきではありません。

 -- C 変数: *note PyObject: 312. _Py_NoneStruct

     Python からは ‘None’ に見えるオブジェクトです。この値へのアクセスは
     、このオブジェクトへのポインタを評価する *note Py_None: 474c. マク
     ロを使わなければなりません。

参考
....

*note PyModule_Create(): 4750.

     拡張モジュールのアロケートと生成。


File: python.info,  Node: 共通のオブジェクト構造体 common object structure,  Next: 型オブジェクト<3>,  Prev: オブジェクトをヒープ上にメモリ確保する,  Up: オブジェクト実装サポート object implementation support

7.12.2 共通のオブジェクト構造体 (common object structure)
---------------------------------------------------------

Python では、オブジェクト型を定義する上で数多くの構造体が使われます。こ
の節では三つの構造体とその利用方法について説明します。

* Menu:

* Base object types and macros::
* Implementing functions and methods::
* Accessing attributes of extension types::


File: python.info,  Node: Base object types and macros,  Next: Implementing functions and methods,  Up: 共通のオブジェクト構造体 common object structure

7.12.2.1 Base object types and macros
.....................................

All Python objects ultimately share a small number of fields at the
beginning of the object's representation in memory.  These are
represented by the *note PyObject: 312. and *note PyVarObject: 3fe2.
types, which are defined, in turn, by the expansions of some macros also
used, whether directly or indirectly, in the definition of all other
Python objects.  Additional macros can be found under *note reference
counting: 4972.

 -- C のデータ型: type PyObject
     ' 次に属します: *note Limited API: 51e.  (いくつかのメンバーのみが
     安定 ABI です。)' 全てのオブジェクト型はこの型を拡張したものです。
     この型には、あるオブジェクトを指すポインタをオブジェクトとして
     Python から扱うのに必要な情報が入っています。 通常の "リリース" ビ
     ルドでは、この構造体にはオブジェクトの参照カウントとオブジェクトに
     対応する型オブジェクトだけが入っています。 実際には *note PyObject:
     312. であることは宣言されていませんが、全ての Python オブジェクトへ
     のポインタは *note PyObject: 312.* へキャストできます。 メンバにア
     クセスするには *note Py_REFCNT: 877. マクロと *note Py_TYPE: 74b. マ
     クロを使わなければなりません。

 -- C のデータ型: type PyVarObject
     ' 次に属します: *note Limited API: 51e.  (いくつかのメンバーのみが
     安定 ABI です。)' This is an extension of *note PyObject: 312. that
     adds the *note ob_size: 4925. field.  This is only used for objects
     that have some notion of 'length'.  This type does not often appear
     in the Python/C API. Access to the members must be done by using
     the macros *note Py_REFCNT: 877, *note Py_TYPE: 74b, and *note
     Py_SIZE: 74d.

 -- C のマクロ: PyObject_HEAD

     可変な長さを持たないオブジェクトを表現する新しい型を宣言するときに
     使うマクロです。 PyObject_HEAD マクロは次のように展開されます:

          PyObject ob_base;

     上にある *note PyObject: 312. のドキュメントを参照してください。

 -- C のマクロ: PyObject_VAR_HEAD

     インスタンスごとに異なる長さを持つオブジェクトを表現する新しい型を
     宣言するときに使うマクロです。 PyObject_VAR_HEAD マクロは次のように
     展開されます:

          PyVarObject ob_base;

     上にある *note PyVarObject: 3fe2. のドキュメントを参照してください
     。

 -- C の関数: int Py_Is (PyObject *x, PyObject *y)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Test if the 'x' object is the 'y' object, the same as ‘x is y’ in
     Python.

     Added in version 3.10.

 -- C の関数: int Py_IsNone (PyObject *x)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Test if an object is the ‘None’ singleton, the same as ‘x is None’
     in Python.

     Added in version 3.10.

 -- C の関数: int Py_IsTrue (PyObject *x)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Test if an object is the ‘True’ singleton, the same as ‘x is True’
     in Python.

     Added in version 3.10.

 -- C の関数: int Py_IsFalse (PyObject *x)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Test if an object is the ‘False’ singleton, the same as ‘x is
     False’ in Python.

     Added in version 3.10.

 -- C の関数: *note PyTypeObject: a73. *Py_TYPE (PyObject *o)
     '戻り値: 借用参照。' Get the type of the Python object 'o'.

     Return a *note borrowed reference: 317.

     Use the *note Py_SET_TYPE(): 74c. function to set an object type.

     バージョン 3.11 で変更: *note Py_TYPE(): 74b. is changed to an
     inline static function.  The parameter type is no longer const
     *note PyObject: 312.*.

 -- C の関数: int Py_IS_TYPE (PyObject *o, PyTypeObject *type)

     Return non-zero if the object 'o' type is 'type'.  Return zero
     otherwise.  Equivalent to: ‘Py_TYPE(o) == type’.

     Added in version 3.9.

 -- C の関数: void Py_SET_TYPE (PyObject *o, PyTypeObject *type)

     Set the object 'o' type to 'type'.

     Added in version 3.9.

 -- C の関数: *note Py_ssize_t: a2e. Py_SIZE (PyVarObject *o)

     Get the size of the Python object 'o'.

     Use the *note Py_SET_SIZE(): 74e. function to set an object size.

     バージョン 3.11 で変更: *note Py_SIZE(): 74d. is changed to an
     inline static function.  The parameter type is no longer const
     *note PyVarObject: 3fe2.*.

 -- C の関数: void Py_SET_SIZE (PyVarObject *o, Py_ssize_t size)

     Set the object 'o' size to 'size'.

     Added in version 3.9.

 -- C のマクロ: PyObject_HEAD_INIT (type)

     新しい *note PyObject: 312. 型のための初期値に展開するマクロです。
     このマクロは次のように展開されます。

          _PyObject_EXTRA_INIT
          1, type,

 -- C のマクロ: PyVarObject_HEAD_INIT (type, size)

     This is a macro which expands to initialization values for a new
     *note PyVarObject: 3fe2. type, including the *note ob_size: 4925.
     field.  This macro expands to:

          _PyObject_EXTRA_INIT
          1, type, size,


File: python.info,  Node: Implementing functions and methods,  Next: Accessing attributes of extension types,  Prev: Base object types and macros,  Up: 共通のオブジェクト構造体 common object structure

7.12.2.2 Implementing functions and methods
...........................................

 -- C のデータ型: type PyCFunction
     ' 次に属します: *note Stable ABI: 51e.'  Type of the functions used
     to implement most Python callables in C. Functions of this type
     take two *note PyObject: 312.* parameters and return one such
     value.  If the return value is ‘NULL’, an exception shall have been
     set.  If not ‘NULL’, the return value is interpreted as the return
     value of the function as exposed in Python.  The function must
     return a new reference.

     関数のシグネチャは次のとおりです

          PyObject *PyCFunction(PyObject *self,
                                PyObject *args);

 -- C のデータ型: type PyCFunctionWithKeywords
     ' 次に属します: *note Stable ABI: 51e.'  Type of the functions used
     to implement Python callables in C with signature *note
     METH_VARARGS | METH_KEYWORDS: 4c6a.  The function signature is:

          PyObject *PyCFunctionWithKeywords(PyObject *self,
                                            PyObject *args,
                                            PyObject *kwargs);

 -- C のデータ型: type PyCFunctionFast
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Type of the functions used to implement Python callables in C with
     signature *note METH_FASTCALL: 158b.  The function signature is:

          PyObject *PyCFunctionFast(PyObject *self,
                                    PyObject *const *args,
                                    Py_ssize_t nargs);

 -- C のデータ型: type PyCFunctionFastWithKeywords
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.13 より).'
     Type of the functions used to implement Python callables in C with
     signature *note METH_FASTCALL | METH_KEYWORDS: 4c6b.  The function
     signature is:

          PyObject *PyCFunctionFastWithKeywords(PyObject *self,
                                                PyObject *const *args,
                                                Py_ssize_t nargs,
                                                PyObject *kwnames);

 -- C のデータ型: type PyCMethod

     Type of the functions used to implement Python callables in C with
     signature *note METH_METHOD | METH_FASTCALL | METH_KEYWORDS: 15f2.
     The function signature is:

          PyObject *PyCMethod(PyObject *self,
                              PyTypeObject *defining_class,
                              PyObject *const *args,
                              Py_ssize_t nargs,
                              PyObject *kwnames)

     Added in version 3.9.

 -- C のデータ型: type PyMethodDef
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'  拡
     張型のメソッドを記述する際に用いる構造体です。この構造体には 4 つの
     フィールドがあります:

      -- C のメンバ変数: const char *ml_name

          Name of the method.

      -- C のメンバ変数: *note PyCFunction: 141c. ml_meth

          Pointer to the C implementation.

      -- C のメンバ変数: int ml_flags

          Flags bits indicating how the call should be constructed.

      -- C のメンバ変数: const char *ml_doc

          Points to the contents of the docstring.

The *note ml_meth: 4c6c. is a C function pointer.  The functions may be
of different types, but they always return *note PyObject: 312.*.  If
the function is not of the *note PyCFunction: 141c, the compiler will
require a cast in the method table.  Even though *note PyCFunction:
141c. defines the first parameter as *note PyObject: 312.*, it is common
that the method implementation uses the specific C type of the 'self'
object.

The *note ml_flags: 4c6d. field is a bitfield which can include the
following flags.  The individual flags indicate either a calling
convention or a binding convention.

There are these calling conventions:

 -- C のマクロ: METH_VARARGS

     *note PyCFunction: 141c. 型のメソッドで典型的に使われる呼び出し規約
     です。関数は *note PyObject: 312.* 型の引数値を二つ要求します。最初
     の引数はメソッドの 'self' オブジェクトです; モジュール関数の場合、
     これはモジュールオブジェクトです。第二のパラメタ (よく 'args' と呼
     ばれます) は、全ての引数を表現するタプルオブジェクトです。パラメタ
     は通常、 *note PyArg_ParseTuple(): 53d. や *note
     PyArg_UnpackTuple(): 14b1. で処理されます。

 -- C のマクロ: METH_KEYWORDS

     Can only be used in certain combinations with other flags: *note
     METH_VARARGS | METH_KEYWORDS: 4c6a, *note METH_FASTCALL |
     METH_KEYWORDS: 4c6b. and *note METH_METHOD | METH_FASTCALL |
     METH_KEYWORDS: 15f2.

*note METH_VARARGS: 14b3. | *note METH_KEYWORDS: 474f.

     Methods with these flags must be of type *note
     PyCFunctionWithKeywords: 4807.  The function expects three
     parameters: 'self', 'args', 'kwargs' where 'kwargs' is a dictionary
     of all the keyword arguments or possibly ‘NULL’ if there are no
     keyword arguments.  The parameters are typically processed using
     *note PyArg_ParseTupleAndKeywords(): 35c.

 -- C のマクロ: METH_FASTCALL

     Fast calling convention supporting only positional arguments.  The
     methods have the type *note PyCFunctionFast: 4805.  The first
     parameter is 'self', the second parameter is a C array of *note
     PyObject: 312.* values indicating the arguments and the third
     parameter is the number of arguments (the length of the array).

     Added in version 3.7.

     バージョン 3.10 で変更: ‘METH_FASTCALL’ is now part of the *note
     stable ABI: 47ed.

*note METH_FASTCALL: 158b. | *note METH_KEYWORDS: 474f.

     Extension of *note METH_FASTCALL: 158b. supporting also keyword
     arguments, with methods of type *note PyCFunctionFastWithKeywords:
     4806.  Keyword arguments are passed the same way as in the *note
     vectorcall protocol: 51d.: there is an additional fourth *note
     PyObject: 312.* parameter which is a tuple representing the names
     of the keyword arguments (which are guaranteed to be strings) or
     possibly ‘NULL’ if there are no keywords.  The values of the
     keyword arguments are stored in the 'args' array, after the
     positional arguments.

     Added in version 3.7.

 -- C のマクロ: METH_METHOD

     Can only be used in the combination with other flags: *note
     METH_METHOD | METH_FASTCALL | METH_KEYWORDS: 15f2.

*note METH_METHOD: 93e. | *note METH_FASTCALL: 158b. | *note METH_KEYWORDS: 474f.

     Extension of *note METH_FASTCALL | METH_KEYWORDS: 4c6b. 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)’.

     The method needs to be of type *note PyCMethod: 72f, the same as
     for ‘METH_FASTCALL | METH_KEYWORDS’ with ‘defining_class’ argument
     added after ‘self’.

     Added in version 3.9.

 -- C のマクロ: METH_NOARGS

     Methods without parameters don't need to check whether arguments
     are given if they are listed with the *note METH_NOARGS: 147d.
     flag.  They need to be of type *note PyCFunction: 141c.  The first
     parameter is typically named 'self' and will hold a reference to
     the module or object instance.  In all cases the second parameter
     will be ‘NULL’.

     The function must have 2 parameters.  Since the second parameter is
     unused, *note Py_UNUSED: 1682. can be used to prevent a compiler
     warning.

 -- C のマクロ: METH_O

     Methods with a single object argument can be listed with the *note
     METH_O: 14b2. flag, instead of invoking *note PyArg_ParseTuple():
     53d. with a ‘"O"’ argument.  They have the type *note PyCFunction:
     141c, with the 'self' parameter, and a *note PyObject: 312.*
     parameter representing the single argument.

以下の二つの定数は、呼び出し規約を示すものではなく、クラスのメソッドとし
て使う際の束縛方式を示すものです。モジュールに対して定義された関数で用い
てはなりません。メソッドに対しては、最大で一つしかこのフラグをセットでき
ません。

 -- C のマクロ: METH_CLASS

     メソッドの最初の引数には、型のインスタンスではなく型オブジェクトが
     渡されます。このフラグは組み込み関数 *note classmethod(): 14c. を使
     って生成するのと同じ 'クラスメソッド (class method)' を生成するため
     に使われます。

 -- C のマクロ: METH_STATIC

     メソッドの最初の引数には、型のインスタンスではなく ‘NULL’ が渡され
     ます。このフラグは、 *note staticmethod(): 3ef. を使って生成するの
     と同じ '静的メソッド (static method)' を生成するために使われます。

もう一つの定数は、あるメソッドを同名の別のメソッド定義と置き換えるかどう
かを制御します。

 -- C のマクロ: METH_COEXIST

     The method will be loaded in place of existing definitions.
     Without 'METH_COEXIST', the default is to skip repeated
     definitions.  Since slot wrappers are loaded before the method
     table, the existence of a 'sq_contains' slot, for example, would
     generate a wrapped method named *note __contains__(): 1ebe. and
     preclude the loading of a corresponding PyCFunction with the same
     name.  With the flag defined, the PyCFunction will be loaded in
     place of the wrapper object and will co-exist with the slot.  This
     is helpful because calls to PyCFunctions are optimized more than
     wrapper object calls.

 -- C の関数: *note PyObject: 312. *PyCMethod_New (PyMethodDef *ml,
          PyObject *self, PyObject *module, PyTypeObject *cls)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.9 より).'  Turn 'ml' into a Python *note callable: 2847.
     object.  The caller must ensure that 'ml' outlives the *note
     callable: 2847.  Typically, 'ml' is defined as a static variable.

     The 'self' parameter will be passed as the 'self' argument to the C
     function in ‘ml->ml_meth’ when invoked.  'self' can be ‘NULL’.

     The *note callable: 2847. 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 *note None: 641. or
     ‘NULL’.

     参考
     ....

     *note function.__module__: 1e5d.

     The 'cls' parameter will be passed as the 'defining_class' argument
     to the C function.  Must be set if *note METH_METHOD: 93e. is set
     on ‘ml->ml_flags’.

     Added in version 3.9.

 -- C の関数: *note PyObject: 312. *PyCFunction_NewEx (PyMethodDef *ml,
          PyObject *self, PyObject *module)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e.'
     Equivalent to ‘PyCMethod_New(ml, self, module, NULL)’.

 -- C の関数: *note PyObject: 312. *PyCFunction_New (PyMethodDef *ml,
          PyObject *self)
     '戻り値: 新しい参照。'' 次に属します: *note Stable ABI: 51e. (バー
     ジョン 3.4 より).'  Equivalent to ‘PyCMethod_New(ml, self, NULL,
     NULL)’.


File: python.info,  Node: Accessing attributes of extension types,  Prev: Implementing functions and methods,  Up: 共通のオブジェクト構造体 common object structure

7.12.2.3 Accessing attributes of extension types
................................................

 -- C のデータ型: type PyMemberDef
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'
     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 *note tp_members: 477d. slot.

     Its fields are, in order:

      -- C のメンバ変数: const char *name

          Name of the member.  A NULL value marks the end of a
          ‘PyMemberDef[]’ array.

          The string should be static, no copy is made of it.

      -- C のメンバ変数: int type

          The type of the member in the C struct.  See *note Member
          types: 15d7. for the possible values.

      -- C のメンバ変数: *note Py_ssize_t: a2e. offset

          The offset in bytes that the member is located on the type’s
          object struct.

      -- C のメンバ変数: int flags

          Zero or more of the *note Member flags: 4c72, combined using
          bitwise OR.

      -- C のメンバ変数: const char *doc

          The docstring, or NULL. The string should be static, no copy
          is made of it.  Typically, it is defined using *note
          PyDoc_STR: 1776.

     By default (when *note flags: 4796. is ‘0’), members allow both
     read and write access.  Use the *note Py_READONLY: 55d. flag for
     read-only access.  Certain types, like *note Py_T_STRING: 4c74,
     imply *note Py_READONLY: 55d.  Only *note Py_T_OBJECT_EX: 560. (and
     legacy *note T_OBJECT: 55f.) members can be deleted.  For
     heap-allocated types (created using *note PyType_FromSpec(): 549.
     or similar), ‘PyMemberDef’ may contain a definition for the special
     member ‘"__vectorcalloffset__"’, corresponding to *note
     tp_vectorcall_offset: 49e9. in type objects.  These must be defined
     with ‘Py_T_PYSSIZET’ and ‘Py_READONLY’, for example:

          static PyMemberDef spam_type_members[] = {
              {"__vectorcalloffset__", Py_T_PYSSIZET,
               offsetof(Spam_object, vectorcall), Py_READONLY},
              {NULL}  /* Sentinel */
          };

     (You may need to ‘#include <stddef.h>’ for ‘offsetof()’.)

     The legacy offsets *note tp_dictoffset: 4a46. and *note
     tp_weaklistoffset: 956. can be defined similarly using
     ‘"__dictoffset__"’ and ‘"__weaklistoffset__"’ members, but
     extensions are strongly encouraged to use *note
     Py_TPFLAGS_MANAGED_DICT: 344. and *note Py_TPFLAGS_MANAGED_WEAKREF:
     525. instead.

     バージョン 3.12 で変更: ‘PyMemberDef’ is always available.
     Previously, it required including ‘"structmember.h"’.

 -- C の関数: *note PyObject: 312. *PyMember_GetOne (const char
          *obj_addr, struct PyMemberDef *m)
     ' 次に属します: *note Stable ABI: 51e.'  Get an attribute belonging
     to the object at address 'obj_addr'.  The attribute is described by
     ‘PyMemberDef’ 'm'.  Returns ‘NULL’ on error.

     バージョン 3.12 で変更: ‘PyMember_GetOne’ is always available.
     Previously, it required including ‘"structmember.h"’.

 -- C の関数: int PyMember_SetOne (char *obj_addr, struct PyMemberDef
          *m, PyObject *o)
     ' 次に属します: *note Stable ABI: 51e.'  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.

     バージョン 3.12 で変更: ‘PyMember_SetOne’ is always available.
     Previously, it required including ‘"structmember.h"’.

* Menu:

* Member flags::
* Member types::
* Defining Getters and Setters::


File: python.info,  Node: Member flags,  Next: Member types,  Up: Accessing attributes of extension types

7.12.2.4 Member flags
.....................

The following flags can be used with *note PyMemberDef.flags: 4796.:

 -- C のマクロ: Py_READONLY

     Not writable.

 -- C のマクロ: Py_AUDIT_READ

     Emit an ‘object.__getattr__’ *note audit event: 17db. before
     reading.

 -- C のマクロ: Py_RELATIVE_OFFSET

     Indicates that the *note offset: 4c71. of this ‘PyMemberDef’ entry
     indicates an offset from the subclass-specific data, rather than
     from ‘PyObject’.

     Can only be used as part of *note Py_tp_members: 477d. *note slot:
     48eb. when creating a class using negative *note basicsize: 513.
     It is mandatory in that case.

     This flag is only used in *note PyType_Slot: 48eb.  When setting
     *note tp_members: 477d. during class creation, Python clears it and
     sets *note PyMemberDef.offset: 4c71. to the offset from the
     ‘PyObject’ struct.

バージョン 3.10 で変更: The ‘RESTRICTED’, ‘READ_RESTRICTED’ and
‘WRITE_RESTRICTED’ macros available with ‘#include "structmember.h"’ are
deprecated.  ‘READ_RESTRICTED’ and ‘RESTRICTED’ are equivalent to *note
Py_AUDIT_READ: 55e.; ‘WRITE_RESTRICTED’ does nothing.

バージョン 3.12 で変更: The ‘READONLY’ macro was renamed to *note
Py_READONLY: 55d.  The ‘PY_AUDIT_READ’ macro was renamed with the ‘Py_’
prefix.  The new names are now always available.  Previously, these
required ‘#include "structmember.h"’.  The header is still available and
it provides the old names.


File: python.info,  Node: Member types,  Next: Defining Getters and Setters,  Prev: Member flags,  Up: Accessing attributes of extension types

7.12.2.5 Member types
.....................

*note PyMemberDef.type: 4795. can be one of the following macros
corresponding to various C types.  When the member is accessed in
Python, it will be converted to the equivalent Python type.  When it is
set from Python, it will be converted back to the C type.  If that is
not possible, an exception such as *note TypeError: 502. or *note
ValueError: 1e3. is raised.

Unless marked (D), attributes defined this way cannot be deleted using
e.g.  *note del: 1711. or *note delattr(): 20b6.

マクロ名                             C の型                            Python の型
                                                                       
--------------------------------------------------------------------------------------------------
                                                                       
 -- C のマクロ: Py_T_BYTE            char                              *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_SHORT           short                             *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_INT             int                               *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_LONG            long                              *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_LONGLONG        long long                         *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_UBYTE           unsigned char                     *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_UINT            unsigned int                      *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_USHORT          unsigned short                    *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_ULONG           unsigned long                     *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_ULONGLONG       unsigned long long                *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_PYSSIZET        *note Py_ssize_t: a2e.            *note int: 238.
                                                                       
                                                                       
 -- C のマクロ: Py_T_FLOAT           float                             *note float: 2ce.
                                                                       
                                                                       
 -- C のマクロ: Py_T_DOUBLE          double                            *note float: 2ce.
                                                                       
                                                                       
 -- C のマクロ: Py_T_BOOL            char (written as 0 or 1)          *note bool: 434.
                                                                       
                                                                       
 -- C のマクロ: Py_T_STRING          const char* (*)                   *note str: 418. (RO)
                                                                       
                                                                       
 -- C のマクロ:                      const char[] (*)                  *note str: 418. (RO)
          Py_T_STRING_INPLACE                                          

 -- C のマクロ: Py_T_CHAR            char (0-127)                      *note str: 418. (**)
                                                                       
                                                                       
 -- C のマクロ: Py_T_OBJECT_EX       *note PyObject: 312.*             *note object: a5a. (D)
                                                                       

     (*): Zero-terminated, UTF8-encoded C string.  With ‘Py_T_STRING’
     the C representation is a pointer; with ‘Py_T_STRING_INPLACE’ the
     string is stored directly in the structure.

     (**): String of length 1.  Only ASCII is accepted.

     (RO): Implies *note Py_READONLY: 55d.

     (D): Can be deleted, in which case the pointer is set to ‘NULL’.
     Reading a ‘NULL’ pointer raises *note AttributeError: 326.

Added in version 3.12: 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:

 -- C のマクロ: T_OBJECT

     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’.

 -- C のマクロ: T_NONE

     Always ‘None’.  Must be used with *note Py_READONLY: 55d.


File: python.info,  Node: Defining Getters and Setters,  Prev: Member types,  Up: Accessing attributes of extension types

7.12.2.6 Defining Getters and Setters
.....................................

 -- C のデータ型: type PyGetSetDef
     ' 次に属します: *note Stable ABI: 51e. (すべてのメンバーを含む).'  型
     のプロパティのようなアクセスを定義するための構造体です。 *note
     PyTypeObject.tp_getset: 4782. スロットの説明も参照してください。

      -- C のメンバ変数: const char *name

          属性名

      -- C のメンバ変数: *note getter: 4940. get

          C function to get the attribute.

      -- C のメンバ変数: *note setter: 494e. set

          Optional C function to set or delete the attribute.  If
          ‘NULL’, the attribute is read-only.

      -- C のメンバ変数: const char *doc

          任意のドキュメンテーション文字列

      -- C のメンバ変数: void *closure

          Optional user data pointer, providing additional data for
          getter and setter.

 -- C のデータ型: typedef *note PyObject: 312. *(*getter)(*note
          PyObject: 312.*, void*)
     ' 次に属します: *note Stable ABI: 51e.'  The ‘get’ function takes
     one *note PyObject: 312.* parameter (the instance) and a user data
     pointer (the associated ‘closure’):

     成功または失敗時に ‘NULL’ と例外の集合にされたときは新しい参照を返
     します。

 -- C のデータ型: typedef int (*setter)(*note PyObject: 312.*, *note
          PyObject: 312.*, void*)
     ' 次に属します: *note Stable ABI: 51e.'  ‘set’ functions take two
     *note PyObject: 312.* parameters (the instance and the value to be
     set) and a user data pointer (the associated ‘closure’):

     属性を削除する場合は、2 番目のパラメータに ‘NULL’ を指定します。成
     功した場合は ‘0’ を、失敗した場合は ‘-1’ を例外として返します。


File: python.info,  Node: 型オブジェクト<3>,  Next: 循環参照ガベージコレクションをサポートする,  Prev: 共通のオブジェクト構造体 common object structure,  Up: オブジェクト実装サポート object implementation support

7.12.3 型オブジェクト
---------------------

新スタイルの型を定義する構造体: *note PyTypeObject: a73. 構造体は、おそ
らく Python オブジェクトシステムの中で最も重要な構造体の1つでしょう。型
オブジェクトは ‘PyObject_*’ 系や ‘PyType_*’ 系の関数で扱えますが、ほとん
どの Python アプリケーションにとって、さして面白みのある機能を提供しませ
ん。型オブジェクトはオブジェクトがどのように振舞うかを決める基盤ですから
、インタプリタ自体や新たな型を定義する拡張モジュールでは非常に重要な存在
です。

型オブジェクトは標準の型 (standard type) に比べるとかなり大きな構造体で
す。各型オブジェクトは多くの値を保持しており、そのほとんどは C 関数への
ポインタで、それぞれの関数はその型の機能の小さい部分を実装しています。こ
の節では、型オブジェクトの各フィールドについて詳細を説明します。各フィー
ルドは、構造体内で出現する順番に説明されています。

以下のクイックリファレンスに加えて、 *note 使用例: 4c8d. 節では *note
PyTypeObject: a73. の意味と使い方を一目で理解できる例を載せています。

* Menu:

* クイックリファレンス::
* PyTypeObject 定義::
* PyObject スロット::
* PyVarObject スロット::
* PyTypeObject スロット::
* Static Types::
* Heap Types::
* 数値オブジェクト構造体::
* マップオブジェクト構造体::
* シーケンスオブジェクト構造体::
* バッファオブジェクト構造体 (buffer object structure): バッファオブジェクト構造体 buffer object structure.
* async オブジェクト構造体::
* Slot Type typedefs::
* 使用例: 使用例<55>.


File: python.info,  Node: クイックリファレンス,  Next: PyTypeObject 定義,  Up: 型オブジェクト<3>

7.12.3.1 クイックリファレンス
.............................

* Menu:

* tp スロット::
* sub-slots::
* スロットの定義型 (typedef): スロットの定義型 typedef.


File: python.info,  Node: tp スロット,  Next: sub-slots,  Up: クイックリファレンス

7.12.3.2 tp スロット
....................

PyTypeObject スロッ    *note 型: 4c91.        特殊メソッド/特殊属    Info
ト (1)                                        性                     (2)
                                                                     
---------------------------------------------------------------------------------------------
                                                                     
O                      T                      D                      I
                                                                     
                                                                                       
<R>                    const char *           __name__               X     X
*note tp_name: 185d.                                                       

*note tp_basicsize: 955.*note Py_ssize_t: a2e.                       X     X           X
                                                                                       
                                                                                       
*note tp_itemsize: 1ed0.*note Py_ssize_t: a2e.                             X           X
                                                                                       
                                                                                       
*note tp_dealloc: 477a.*note destructor: 493b.                       X     X           X
                                                                                       
                                                                                       
*note tp_vectorcall_offset: 49e9.*note Py_ssize_t: a2e.                    X           X
                                                                                       
                                                                                       
(*note tp_getattr: 4798.)*note getattrfunc: 493c.__getattribute__,                     G
                                              __getattr__                              
                                              
                                                                                       
(*note tp_setattr: 4799.)*note setattrfunc: 494c.__setattr__,                          G
                                              __delattr__                              
                                              
                                                                                       
*note tp_as_async: e98.*note PyAsyncMethods: 4a44.*note sub-slots: 4c92.               %
                       *                                                               
                       
                                                                                       
*note tp_repr: 478f.   *note reprfunc: 494a.  __repr__               X     X           X
                                                                                       
                                                                                       
*note tp_as_number: 959.*note PyNumberMethods: 13c5.*note sub-slots: 4c92.             %
                       *                                                               
                       
                                                                                       
*note tp_as_sequence: 4c93.*note PySequenceMethods: 479f.*note sub-slots: 4c92.        %
                       *                                                               
                       
                                                                                       
*note tp_as_mapping: 4c94.*note PyMappingMethods: 47a0.*note sub-slots: 4c92.          %
                       *                                                               
                       
                                                                                       
*note tp_hash: 47a1.   *note hashfunc: 4941.  __hash__               X                 G
                                                                                       
                                                                                       
*note tp_call: 524.    *note ternaryfunc: 4951.__call__                    X           X
                                                                                       
                                                                                       
*note tp_str: 4790.    *note reprfunc: 494a.  __str__                X                 X
                                                                                       
                                                                                       
*note tp_getattro: 1657.*note getattrofunc: 493d.__getattribute__,   X     X           G
                                              __getattr__                              
                                              
                                                                                       
*note tp_setattro: 4793.*note setattrofunc: 494d.__setattr__,        X     X           G
                                              __delattr__                              
                                              
                                                                                       
*note tp_as_buffer: 957.*note PyBufferProcs: 4a4c.                                     %
                       *                                                               
                       
                                                                                       
*note tp_flags: 1828.  unsigned long                                 X     X           ?
                                                                                       
                                                                                       
*note tp_doc: 4776.    const char *           __doc__                X     X
                                                                           
                                                                                       
*note tp_traverse: 749.*note traverseproc: 4952.                           X           G
                                                                                       
                                                                                       
*note tp_clear: 478d.  *note inquiry: 4943.                                X           G
                                                                                       
                                                                                       
*note tp_richcompare: 479b.*note richcmpfunc: 494b.__lt__, __le__,   X                 G
                                              __eq__, __ne__,                          
                                              __gt__, __ge__
                                              
                                                                                       
(*note tp_weaklistoffset: 956.)*note Py_ssize_t: a2e.                      X           ?
                                                                                       
                                                                                       
*note tp_iter: 1497.   *note getiterfunc: 493f.__iter__                                X
                                                                                       
                                                                                       
*note tp_iternext: 1498.*note iternextfunc: 4944.__next__                              X
                                                                                       
                                                                                       
*note tp_methods: 477f.*note PyMethodDef: 1480.                      X     X
                       []                                                  
                       
                                                                                       
*note tp_members: 477d.*note PyMemberDef: 51a.                             X
                       []                                                  
                       
                                                                                       
*note tp_getset: 4782. *note PyGetSetDef: b86.                       X     X
                       []                                                  
                       
                                                                                       
*note tp_base: 4786.   *note PyTypeObject: a73.__base__                          X
                       *                                                         
                       
                                                                                       
*note tp_dict: 1685.   *note PyObject: 312.   __dict__                           ?
                       *                                                         
                       
                                                                                       
*note tp_descr_get: 4c95.*note descrgetfunc: 4939.__get__                              X
                                                                                       
                                                                                       
*note tp_descr_set: 1861.*note descrsetfunc: 493a.__set__, __delete__                  X
                                                                                       
                                                                                       
(*note tp_dictoffset: 4a46.)*note Py_ssize_t: a2e.                         X           ?
                                                                                       
                                                                                       
*note tp_init: 54d.    *note initproc: 4942.  __init__               X     X           X
                                                                                       
                                                                                       
*note tp_alloc: 477c.  *note allocfunc: 4937.                        X           ?     ?
                                                                                       
                                                                                       
*note tp_new: 54b.     *note newfunc: 4946.   __new__                X     X     ?     ?
                                                                                       
                                                                                       
*note tp_free: 477b.   *note freefunc: 4b3c.                         X     X     ?     ?
                                                                                       
                                                                                       
*note tp_is_gc: 4c96.  *note inquiry: 4943.                                X           X
                                                                                       
                                                                                       
<*note tp_bases: 4c97.>*note PyObject: 312.   __bases__                          ~
                       *                                                         
                       
                                                                                       
<*note tp_mro: 4a49.>  *note PyObject: 312.   __mro__                            ~
                       *                                                         
                       
                                                                                       
[*note tp_cache: 4a4a.]*note PyObject: 312.
                       *
                       
                                                                                       
[*note tp_subclasses: 53e.]void *             __subclasses__
                                              
                                                                                       
[*note tp_weaklist: 4a4b.]*note PyObject: 312.
                       *
                       
                                                                                       
(*note tp_del: 4c98.)  *note destructor: 493b.
                       
                                                                                       
[*note tp_version_tag: 4c99.]unsigned int
                       
                                                                                       
*note tp_finalize: a74.*note destructor: 493b.__del__                                  X
                                                                                       
                                                                                       
*note tp_vectorcall: 4a48.*note vectorcallfunc: 522.
                       
                                                                                       
[*note tp_watched: 4c9a.]unsigned char
                       

   ---------- Footnotes ----------

   (1) '()': A slot name in parentheses indicates it is (effectively)
deprecated.

'<>': Names in angle brackets should be initially set to ‘NULL’ and
treated as read-only.

'[]': Names in square brackets are for internal use only.

'<R>' (as a prefix) means the field is required (must be non-‘NULL’).

   (2) 列:

'"O"': set on ‘PyBaseObject_Type’

'"T"': set on *note PyType_Type: 518.

'"D"': default (if slot is set to ‘NULL’)

     X - PyType_Ready sets this value if it is NULL
     ~ - PyType_Ready always sets this value (it should be NULL)
     ? - PyType_Ready may set this value depending on other slots

     Also see the inheritance column ("I").

'"I"': inheritance

     X - type slot is inherited via *PyType_Ready* if defined with a *NULL* value
     % - the slots of the sub-struct are inherited individually
     G - inherited, but only in combination with other slots; see the slot's description
     ? - it's complicated; see the slot's description

Note that some slots are effectively inherited through the normal
attribute lookup chain.


File: python.info,  Node: sub-slots,  Next: スロットの定義型 typedef,  Prev: tp スロット,  Up: クイックリファレンス

7.12.3.3 sub-slots
..................

Slot                           *note 型: 4c91.       特殊メソッド
                                                     
----------------------------------------------------------------------
                                                     
*note am_await: 4c9c.          *note unaryfunc: 4953.__await__
                                                     
                                                     
*note am_aiter: 4c9d.          *note unaryfunc: 4953.__aiter__
                                                     
                                                     
*note am_anext: 4c9e.          *note unaryfunc: 4953.__anext__
                                                     
                                                     
*note am_send: 4c9f.           *note sendfunc: 4ca0.
                               
                                                     
                                                     
*note nb_add: 4a3d.            *note binaryfunc: 4938.__add__
                                                     __radd__
                                                     
                                                     
*note nb_inplace_add: 4ca1.    *note binaryfunc: 4938.__iadd__
                                                     
                                                     
*note nb_subtract: 4ca2.       *note binaryfunc: 4938.__sub__
                                                     __rsub__
                                                     
                                                     
*note nb_inplace_subtract: 4ca3.*note binaryfunc: 4938.__isub__
                                                     
                                                     
*note nb_multiply: 4ca4.       *note binaryfunc: 4938.__mul__
                                                     __rmul__
                                                     
                                                     
*note nb_inplace_multiply: 4ca5.*note binaryfunc: 4938.__imul__
                                                     
                                                     
*note nb_remainder: 4ca6.      *note binaryfunc: 4938.__mod__
                                                     __rmod__
                                                     
                                                     
*note nb_inplace_remainder: 4ca7.*note binaryfunc: 4938.__imod__
                                                     
                                                     
*note nb_divmod: 4ca8.         *note binaryfunc: 4938.__divmod__
                                                     __rdivmod__
                                                     
                                                     
*note nb_power: 4ca9.          *note ternaryfunc: 4951.__pow__
                                                     __rpow__
                                                     
                                                     
*note nb_inplace_power: 4caa.  *note ternaryfunc: 4951.__ipow__
                                                     
                                                     
*note nb_negative: 4cab.       *note unaryfunc: 4953.__neg__
                                                     
                                                     
*note nb_positive: 4cac.       *note unaryfunc: 4953.__pos__
                                                     
                                                     
*note nb_absolute: 4cad.       *note unaryfunc: 4953.__abs__
                                                     
                                                     
*note nb_bool: 4cae.           *note inquiry: 4943.  __bool__
                                                     
                                                     
*note nb_invert: 4caf.         *note unaryfunc: 4953.__invert__
                                                     
                                                     
*note nb_lshift: 4cb0.         *note binaryfunc: 4938.__lshift__
                                                     __rlshift__
                                                     
                                                     
*note nb_inplace_lshift: 4cb1. *note binaryfunc: 4938.__ilshift__
                                                     
                                                     
*note nb_rshift: 4cb2.         *note binaryfunc: 4938.__rshift__
                                                     __rrshift__
                                                     
                                                     
*note nb_inplace_rshift: 4cb3. *note binaryfunc: 4938.__irshift__
                                                     
                                                     
*note nb_and: 4cb4.            *note binaryfunc: 4938.__and__
                                                     __rand__
                                                     
                                                     
*note nb_inplace_and: 4cb5.    *note binaryfunc: 4938.__iand__
                                                     
                                                     
*note nb_xor: 4cb6.            *note binaryfunc: 4938.__xor__
                                                     __rxor__
                                                     
                                                     
*note nb_inplace_xor: 4cb7.    *note binaryfunc: 4938.__ixor__
                                                     
                                                     
*note nb_or: 4cb8.             *note binaryfunc: 4938.__or__ __ror__
                                                     
                                                     
*note nb_inplace_or: 4cb9.     *note binaryfunc: 4938.__ior__
                                                     
                                                     
*note nb_int: 4cba.            *note unaryfunc: 4953.__int__
                                                     
                                                     
*note nb_reserved: 4cbb.       void *
                               
                                                     
*note nb_float: 4cbc.          *note unaryfunc: 4953.__float__
                                                     
                                                     
*note nb_floor_divide: 4cbd.   *note binaryfunc: 4938.__floordiv__
                                                     
                                                     
*note nb_inplace_floor_divide: 4cbe.*note binaryfunc: 4938.__ifloordiv__
                                                     
                                                     
*note nb_true_divide: 4cbf.    *note binaryfunc: 4938.__truediv__
                                                     
                                                     
*note nb_inplace_true_divide: 4cc0.*note binaryfunc: 4938.__itruediv__
                                                     
                                                     
*note nb_index: 13c4.          *note unaryfunc: 4953.__index__
                                                     
                                                     
*note nb_matrix_multiply: 4cc1.*note binaryfunc: 4938.__matmul__
                                                     __rmatmul__
                                                     
                                                     
*note nb_inplace_matrix_multiply: 4cc2.*note binaryfunc: 4938.__imatmul__
                                                     
                                                     
                                                     
*note mp_length: 4cc3.         *note lenfunc: 4945.  __len__
                                                     
                                                     
*note mp_subscript: 1898.      *note binaryfunc: 4938.__getitem__
                                                     
                                                     
*note mp_ass_subscript: 4cc4.  *note objobjargproc: 4947.__setitem__,
                                                     __delitem__
                                                     
                                                     
                                                     
*note sq_length: 4a45.         *note lenfunc: 4945.  __len__
                                                     
                                                     
*note sq_concat: 4cc5.         *note binaryfunc: 4938.__add__
                                                     
                                                     
*note sq_repeat: 4cc6.         *note ssizeargfunc: 494f.__mul__
                                                     
                                                     
*note sq_item: 1897.           *note ssizeargfunc: 494f.__getitem__
                                                     
                                                     
*note sq_ass_item: 4cc7.       *note ssizeobjargproc: 4950.__setitem__
                                                     __delitem__
                                                     
                                                     
*note sq_contains: 4cc8.       *note objobjproc: 4948.__contains__
                                                     
                                                     
*note sq_inplace_concat: 4cc9. *note binaryfunc: 4938.__iadd__
                                                     
                                                     
*note sq_inplace_repeat: 4cca. *note ssizeargfunc: 494f.__imul__
                                                     
                                                     
                                                     
*note bf_getbuffer: 72d.       *note getbufferproc(): 493e.
                               
                                                     
*note bf_releasebuffer: 72e.   *note releasebufferproc(): 4949.
                               


File: python.info,  Node: スロットの定義型 typedef,  Prev: sub-slots,  Up: クイックリファレンス

7.12.3.4 スロットの定義型 (typedef)
...................................

定義型 (typedef)                  引数型                            返り値型
                                                                    
-----------------------------------------------------------------------------------------------
                                                                    
*note allocfunc: 4937.                 *note PyTypeObject: a73. *   *note PyObject: 312. *
                                       *note Py_ssize_t: a2e.       
                                  
                                                                    
*note destructor: 493b.           *note PyObject: 312. *            void
                                                                    
                                                                    
*note freefunc: 4b3c.             void *                            void
                                                                    
                                                                    
*note traverseproc: 4952.              *note PyObject: 312. *       int
                                       *note visitproc: 4954.       
                                       void *
                                  
                                                                    
*note newfunc: 4946.                   *note PyObject: 312. *       *note PyObject: 312. *
                                       *note PyObject: 312. *       
                                       *note PyObject: 312. *
                                  
                                                                    
*note initproc: 4942.                  *note PyObject: 312. *       int
                                       *note PyObject: 312. *       
                                       *note PyObject: 312. *
                                  
                                                                    
*note reprfunc: 494a.             *note PyObject: 312. *            *note PyObject: 312. *
                                                                    
                                                                    
*note getattrfunc: 493c.               *note PyObject: 312. *       *note PyObject: 312. *
                                       const char *                 
                                  
                                                                    
*note setattrfunc: 494c.               *note PyObject: 312. *       int
                                       const char *                 
                                       *note PyObject: 312. *
                                  
                                                                    
*note getattrofunc: 493d.              *note PyObject: 312. *       *note PyObject: 312. *
                                       *note PyObject: 312. *       
                                  
                                                                    
*note setattrofunc: 494d.              *note PyObject: 312. *       int
                                       *note PyObject: 312. *       
                                       *note PyObject: 312. *
                                  
                                                                    
*note descrgetfunc: 4939.              *note PyObject: 312. *       *note PyObject: 312. *
                                       *note PyObject: 312. *       
                                       *note PyObject: 312. *
                                  
                                                                    
*note descrsetfunc: 493a.              *note PyObject: 312. *       int
                                       *note PyObject: 312. *       
                                       *note PyObject: 312. *
                                  
                                                                    
*note hashfunc: 4941.             *note PyObject: 312. *            Py_hash_t
                                                                    
                                                                    
*note richcmpfunc: 494b.               *note PyObject: 312. *       *note PyObject: 312. *
                                       *note PyObject: 312. *       
                                       int
                                  
                                                                    
*note getiterfunc: 493f.          *note PyObject: 312. *            *note PyObject: 312. *
                                                                    
                                                                    
*note iternextfunc: 4944.         *note PyObject: 312. *            *note PyObject: 312. *
                                                                    
                                                                    
*note lenfunc: 4945.              *note PyObject: 312. *            *note Py_ssize_t: a2e.
                                                                    
                                                                    
*note getbufferproc: 493e.             *note PyObject: 312. *       int
                                       *note Py_buffer: 723. *      
                                       int
                                  
                                                                    
*note releasebufferproc: 4949.         *note PyObject: 312. *       void
                                       *note Py_buffer: 723. *      
                                  
                                                                    
*note inquiry: 4943.              *note PyObject: 312. *            int
                                                                    
                                                                    
*note unaryfunc: 4953.                 *note PyObject: 312. *       *note PyObject: 312. *
                                                                    
                                                                    
*note binaryfunc: 4938.                *note PyObject: 312. *       *note PyObject: 312. *
                                       *note PyObject: 312. *       
                                  
                                                                    
*note ternaryfunc: 4951.               *note PyObject: 312. *       *note PyObject: 312. *
                                       *note PyObject: 312. *       
                                       *note PyObject: 312. *
                                  
                                                                    
*note ssizeargfunc: 494f.              *note PyObject: 312. *       *note PyObject: 312. *
                                       *note Py_ssize_t: a2e.       
                                  
                                                                    
*note ssizeobjargproc: 4950.           *note PyObject: 312. *       int
                                       *note Py_ssize_t: a2e.       
                                       *note PyObject: 312. *
                                  
                                                                    
*note objobjproc: 4948.                *note PyObject: 312. *       int
                                       *note PyObject: 312. *       
                                  
                                                                    
*note objobjargproc: 4947.             *note PyObject: 312. *       int
                                       *note PyObject: 312. *       
                                       *note PyObject: 312. *
                                  

See *note Slot Type typedefs: 4ccc. below for more detail.


File: python.info,  Node: PyTypeObject 定義,  Next: PyObject スロット,  Prev: クイックリファレンス,  Up: 型オブジェクト<3>

7.12.3.5 PyTypeObject 定義
..........................

*note PyTypeObject: a73. の構造体定義は ‘Include/object.h’ で見つけられ
るはずです。参照の手間を省くために、ここでは定義を繰り返します:

     typedef struct _typeobject {
         PyObject_VAR_HEAD
         const char *tp_name; /* For printing, in format "<module>.<name>" */
         Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */

         /* Methods to implement standard operations */

         destructor tp_dealloc;
         Py_ssize_t tp_vectorcall_offset;
         getattrfunc tp_getattr;
         setattrfunc tp_setattr;
         PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
                                         or tp_reserved (Python 3) */
         reprfunc tp_repr;

         /* Method suites for standard classes */

         PyNumberMethods *tp_as_number;
         PySequenceMethods *tp_as_sequence;
         PyMappingMethods *tp_as_mapping;

         /* More standard operations (here for binary compatibility) */

         hashfunc tp_hash;
         ternaryfunc tp_call;
         reprfunc tp_str;
         getattrofunc tp_getattro;
         setattrofunc tp_setattro;

         /* Functions to access object as input/output buffer */
         PyBufferProcs *tp_as_buffer;

         /* Flags to define presence of optional/expanded features */
         unsigned long tp_flags;

         const char *tp_doc; /* Documentation string */

         /* Assigned meaning in release 2.0 */
         /* call function for all accessible objects */
         traverseproc tp_traverse;

         /* delete references to contained objects */
         inquiry tp_clear;

         /* Assigned meaning in release 2.1 */
         /* rich comparisons */
         richcmpfunc tp_richcompare;

         /* weak reference enabler */
         Py_ssize_t tp_weaklistoffset;

         /* Iterators */
         getiterfunc tp_iter;
         iternextfunc tp_iternext;

         /* Attribute descriptor and subclassing stuff */
         struct PyMethodDef *tp_methods;
         struct PyMemberDef *tp_members;
         struct PyGetSetDef *tp_getset;
         // Strong reference on a heap type, borrowed reference on a static type
         struct _typeobject *tp_base;
         PyObject *tp_dict;
         descrgetfunc tp_descr_get;
         descrsetfunc tp_descr_set;
         Py_ssize_t tp_dictoffset;
         initproc tp_init;
         allocfunc tp_alloc;
         newfunc tp_new;
         freefunc tp_free; /* Low-level free-memory routine */
         inquiry tp_is_gc; /* For PyObject_IS_GC */
         PyObject *tp_bases;
         PyObject *tp_mro; /* method resolution order */
         PyObject *tp_cache;
         PyObject *tp_subclasses;
         PyObject *tp_weaklist;
         destructor tp_del;

         /* Type attribute cache version tag. Added in version 2.6 */
         unsigned int tp_version_tag;

         destructor tp_finalize;
         vectorcallfunc tp_vectorcall;

         /* bitset of which type-watchers care about this type */
         unsigned char tp_watched;
     } PyTypeObject;


File: python.info,  Node: PyObject スロット,  Next: PyVarObject スロット,  Prev: PyTypeObject 定義,  Up: 型オブジェクト<3>

7.12.3.6 PyObject スロット
..........................

The type object structure extends the *note PyVarObject: 3fe2.
structure.  The *note ob_size: 4925. field is used for dynamic types
(created by ‘type_new()’, usually called from a class statement).  Note
that *note PyType_Type: 518. (the metatype) initializes *note
tp_itemsize: 1ed0, which means that its instances (i.e.  type objects)
'must' have the *note ob_size: 4925. field.

 -- C のメンバ変数: *note Py_ssize_t: a2e. *note PyObject: 312.ob_refcnt
     ' 次に属します: *note Stable ABI: 51e.'  This is the type object's
     reference count, initialized to ‘1’ by the ‘PyObject_HEAD_INIT’
     macro.  Note that for *note statically allocated type objects: 74a,
     the type's instances (objects whose *note ob_type: 4778. points
     back to the type) do 'not' count as references.  But for *note
     dynamically allocated type objects: 933, the instances 'do' count
     as references.

     '継承:'

     サブタイプはこのフィールドを継承しません。

 -- C のメンバ変数: *note PyTypeObject: a73. **note PyObject:
          312.ob_type
     ' 次に属します: *note Stable ABI: 51e.'  型自体の型、別の言い方をす
     るとメタタイプです。 ‘PyObject_HEAD_INIT’ マクロで初期化され、通常
     は ‘&PyType_Type’ になります。しかし、(少なくとも) Windows で利用で
     きる動的ロード可能な拡張モジュールでは、コンパイラは有効な初期化で
     はないと文句をつけます。そこで、ならわしとして、
     ‘PyObject_HEAD_INIT’ には ‘NULL’ を渡して初期化しておき、他の操作を
     行う前にモジュールの初期化関数で明示的にこのフィールドを初期化する
     ことになっています。この操作は以下のように行います:

          Foo_Type.ob_type = &PyType_Type;

     This should be done before any instances of the type are created.
     *note PyType_Ready(): 747. checks if *note ob_type: 4778. is
     ‘NULL’, and if so, initializes it to the *note ob_type: 4778. field
     of the base class.  *note PyType_Ready(): 747. will not change this
     field if it is non-zero.

     '継承:'

     サブタイプはこのフィールドを継承します。


File: python.info,  Node: PyVarObject スロット,  Next: PyTypeObject スロット,  Prev: PyObject スロット,  Up: 型オブジェクト<3>

7.12.3.7 PyVarObject スロット
.............................

 -- C のメンバ変数: *note Py_ssize_t: a2e. *note PyVarObject:
          3fe2.ob_size
     ' 次に属します: *note Stable ABI: 51e.'  *note
     静的にメモリ確保されている型オブジェクト: 74a. の場合、このフィール
     ドはゼロに初期化されます。*note
     動的にメモリ確保されている型オブジェクト: 933. の場合、このフィール
     ドは内部使用される特殊な意味を持ちます。

     '継承:'

     サブタイプはこのフィールドを継承しません。


File: python.info,  Node: PyTypeObject スロット,  Next: Static Types,  Prev: PyVarObject スロット,  Up: 型オブジェクト<3>

7.12.3.8 PyTypeObject スロット
..............................

Each slot has a section describing inheritance.  If *note
PyType_Ready(): 747. 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 ‘PyBaseObject_Type’ and *note PyType_Type: 518. effectively act as
defaults.)

 -- C のメンバ変数: const char **note PyTypeObject: a73.tp_name

     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 module name, followed by a dot, followed by the type
     name; for built-in types, it should be just the type name.  If the
     module is a submodule of a package, the full package name is part
     of the full module name.  For example, a type named ‘T’ defined in
     module ‘M’ in subpackage ‘Q’ in package ‘P’ should have the *note
     tp_name: 185d. initializer ‘"P.Q.M.T"’.

     *note 動的にメモリ確保される型オブジェクト: 933. の場合、このフィー
     ルドは単に型の名前になり、モジュール名は型の辞書内でキー
     ‘'__module__'’ に対する値として明示的に保存されます。

     For *note statically allocated type objects: 74a, the 'tp_name'
     field should contain a dot.  Everything before the last dot is made
     accessible as the *note __module__: 34d. attribute, and everything
     after the last dot is made accessible as the *note __name__: 1450.
     attribute.

     If no dot is present, the entire *note tp_name: 185d. field is made
     accessible as the *note __name__: 1450. attribute, and the *note
     __module__: 34d. attribute is undefined (unless explicitly set in
     the dictionary, as explained above).  This means your type will be
     impossible to pickle.  Additionally, it will not be listed in
     module documentations created with pydoc.

     This field must not be ‘NULL’.  It is the only required field in
     *note PyTypeObject(): a73. (other than potentially *note
     tp_itemsize: 1ed0.).

     '継承:'

     サブタイプはこのフィールドを継承しません。

 -- C のメンバ変数: *note Py_ssize_t: a2e. *note PyTypeObject:
          a73.tp_basicsize
 -- C のメンバ変数: *note Py_ssize_t: a2e. *note PyTypeObject:
          a73.tp_itemsize

     これらのフィールドは、型インスタンスのバイトサイズを計算できるよう
     にします。

     型には二つの種類があります: 固定長インスタンスの型は、 *note
     tp_itemsize: 1ed0. フィールドがゼロで、可変長インスタンスの方は
     *note tp_itemsize: 1ed0. フィールドが非ゼロの値になります。固定長イ
     ンスタンスの型の場合、全てのインスタンスは等しく *note
     tp_basicsize: 955. で与えられたサイズになります。

     For a type with variable-length instances, the instances must have
     an *note ob_size: 4925. field, and the instance size is *note
     tp_basicsize: 955. plus N times *note tp_itemsize: 1ed0, where N is
     the "length" of the object.  The value of N is typically stored in
     the instance's *note ob_size: 4925. field.  There are exceptions:
     for example, ints use a negative *note ob_size: 4925. to indicate a
     negative number, and N is ‘abs(ob_size)’ there.  Also, the presence
     of an *note ob_size: 4925. field in the instance layout doesn't
     mean that the instance structure is variable-length (for example,
     the structure for the list type has fixed-length instances, yet
     those instances have a meaningful *note ob_size: 4925. field).

     The basic size includes the fields in the instance declared by the
     macro *note PyObject_HEAD: 12ac. or *note PyObject_VAR_HEAD: 4c66.
     (whichever is used to declare the instance struct) and this in turn
     includes the ‘_ob_prev’ and ‘_ob_next’ fields if they are present.
     This means that the only correct way to get an initializer for the
     *note tp_basicsize: 955. is to use the ‘sizeof’ operator on the
     struct used to declare the instance layout.  The basic size does
     not include the GC header size.

     アラインメントに関する注釈: 変数の各要素を配置する際に特定のアライ
     ンメントが必要となる場合、 *note tp_basicsize: 955. の値に気をつけ
     なければなりません。例: ある型が ‘double’ の配列を実装しているとし
     ます。 *note tp_itemsize: 1ed0. は ‘sizeof(double)’ です。 *note
     tp_basicsize: 955. が ‘sizeof(double)’ (ここではこれを ‘double’ の
     アラインメントが要求するサイズと仮定する) の個数分のサイズになるよ
     うにするのはプログラマの責任です。

     For any type with variable-length instances, this field must not be
     ‘NULL’.

     '継承:'

     これらのフィールドはサブタイプに別々に継承されます。基底タイプが 0
     でない *note tp_itemsize: 1ed0. を持っていた場合、基底タイプの実装
     に依存しますが、一般的にはサブタイプで別の 0 で無い値を *note
     tp_itemsize: 1ed0. に設定するのは安全ではありません。

 -- C のメンバ変数: *note destructor: 493b. *note PyTypeObject:
          a73.tp_dealloc

     インスタンスのデストラクタ関数へのポインタです。この関数は (単量子
     ‘None’ や ‘Ellipsis’ の場合のように) インスタンスが決してメモリ解放
     されない型でない限り必ず定義しなければなりません。シグネチャは次の
     通りです:

          void tp_dealloc(PyObject *self);

     The destructor function is called by the *note Py_DECREF(): 53b.
     and *note Py_XDECREF(): 75a. macros when the new reference count is
     zero.  At this point, the instance is still in existence, but there
     are no references to it.  The destructor function should free all
     references which the instance owns, free all memory buffers owned
     by the instance (using the freeing function corresponding to the
     allocation function used to allocate the buffer), and call the
     type's *note tp_free: 477b. function.  If the type is not
     subtypable (doesn't have the *note Py_TPFLAGS_BASETYPE: 4780. flag
     bit set), it is permissible to call the object deallocator directly
     instead of via *note tp_free: 477b.  The object deallocator should
     be the one used to allocate the instance; this is normally *note
     PyObject_Del(): 147a. if the instance was allocated using *note
     PyObject_New: 953. or *note PyObject_NewVar: 954, or *note
     PyObject_GC_Del(): 14ae. if the instance was allocated using *note
     PyObject_GC_New: a70. or *note PyObject_GC_NewVar: a71.

     If the type supports garbage collection (has the *note
     Py_TPFLAGS_HAVE_GC: 748. flag bit set), the destructor should call
     *note PyObject_GC_UnTrack(): 14b0. before clearing any member
     fields.

          static void foo_dealloc(foo_object *self) {
              PyObject_GC_UnTrack(self);
              Py_CLEAR(self->ref);
              Py_TYPE(self)->tp_free((PyObject *)self);
          }

     Finally, if the type is heap allocated (*note Py_TPFLAGS_HEAPTYPE:
     87d.), the deallocator should release the owned reference to its
     type object (via *note Py_DECREF(): 53b.) after calling the type
     deallocator.  In order to avoid dangling pointers, the recommended
     way to achieve this is:

          static void foo_dealloc(foo_object *self) {
              PyTypeObject *tp = Py_TYPE(self);
              // free references and buffers here
              tp->tp_free(self);
              Py_DECREF(tp);
          }

          警告: In a garbage collected Python, ‘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
          cycle, that cycle might be collected by a garbage collection
          on any thread).  This is not a problem for Python API calls,
          since the thread on which ‘tp_dealloc’ is called will own the
          Global Interpreter Lock (GIL). However, if the object being
          destroyed in turn destroys objects from some other C or C++
          library, care should be taken to ensure that destroying those
          objects on the thread which called ‘tp_dealloc’ will not
          violate any assumptions of the library.

     '継承:'

     サブタイプはこのフィールドを継承します。

 -- C のメンバ変数: *note Py_ssize_t: a2e. *note PyTypeObject:
          a73.tp_vectorcall_offset

     An optional offset to a per-instance function that implements
     calling the object using the *note vectorcall protocol: 51d, a more
     efficient alternative of the simpler *note tp_call: 524.

     This field is only used if the flag *note
     Py_TPFLAGS_HAVE_VECTORCALL: 51f. is set.  If so, this must be a
     positive integer containing the offset in the instance of a *note
     vectorcallfunc: 522. pointer.

     The 'vectorcallfunc' pointer may be ‘NULL’, in which case the
     instance behaves as if *note Py_TPFLAGS_HAVE_VECTORCALL: 51f. was
     not set: calling the instance falls back to *note tp_call: 524.

     Any class that sets ‘Py_TPFLAGS_HAVE_VECTORCALL’ must also set
     *note tp_call: 524. and make sure its behaviour is consistent with
     the 'vectorcallfunc' function.  This can be done by setting
     'tp_call' to *note PyVectorcall_Call(): 521.

     バージョン 3.8 で変更: 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.

     バージョン 3.12 で変更: Before version 3.12, it was not recommended
     for *note mutable heap types: 933. to implement the vectorcall
     protocol.  When a user sets *note __call__: 523. in Python code,
     only 'tp_call' is updated, likely making it inconsistent with the
     vectorcall function.  Since 3.12, setting ‘__call__’ will disable
     vectorcall optimization by clearing the *note
     Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag.

     '継承:'

     This field is always inherited.  However, the *note
     Py_TPFLAGS_HAVE_VECTORCALL: 51f. flag is not always inherited.  If
     it's not set, then the subclass won't use *note vectorcall: 51d,
     except when *note PyVectorcall_Call(): 521. is explicitly called.

 -- C のメンバ変数: *note getattrfunc: 493c. *note PyTypeObject:
          a73.tp_getattr

     オプションのポインタで、get-attribute-string を行う関数を指します。

     このフィールドは非推奨です。 このフィールドを定義するときは、 *note
     tp_getattro: 1657. 関数と同じように動作し、属性名は Python 文字列 オ
     ブジェクトではなく C 文字列で指定するような関数を指すようにしなけれ
     ばなりません。

     '継承:'

     Group: *note tp_getattr: 4798, *note tp_getattro: 1657.

     このフィールドは *note tp_getattro: 1657. と共にサブタイプに継承さ
     れます: すなわち、サブタイプの *note tp_getattr: 4798. および *note
     tp_getattro: 1657. が共に ‘NULL’ の場合、サブタイプは基底タイプから
     *note tp_getattr: 4798. と *note tp_getattro: 1657. を両方とも継承
     します。

 -- C のメンバ変数: *note setattrfunc: 494c. *note PyTypeObject:
          a73.tp_setattr

     オプションのポインタで、属性の設定と削除を行う関数を指します。

     このフィールドは非推奨です。 このフィールドを定義するときは、 *note
     tp_setattro: 4793. 関数と同じように動作し、属性名は Python 文字列 オ
     ブジェクトではなく C 文字列で指定するような関数を指すようにしなけれ
     ばなりません。

     '継承:'

     Group: *note tp_setattr: 4799, *note tp_setattro: 4793.

     このフィールドは *note tp_setattro: 4793. と共にサブタイプに継承さ
     れます: すなわち、サブタイプの *note tp_setattr: 4799. および *note
     tp_setattro: 4793. が共に ‘NULL’ の場合、サブタイプは基底タイプから
     *note tp_setattr: 4799. と *note tp_setattro: 4793. を両方とも継承
     します。

 -- C のメンバ変数: *note PyAsyncMethods: 4a44. **note PyTypeObject:
          a73.tp_as_async

     追加の構造体を指すポインタです。 この構造体は、 C レベルで *note
     awaitable: 192. プロトコルと *note asynchronous iterator: 190. プロ
     トコルを実装するオブジェクトだけに関係するフィールドを持ちます。 詳
     しいことは *note async オブジェクト構造体: 4cd1. を参照してください
     。

     Added in version 3.5: 以前は ‘tp_compare’ や ‘tp_reserved’ として知
     られていました。

     '継承:'

     *note tp_as_async: e98. フィールドは継承されませんが、これに含まれ
     るフィールドが個別に継承されます。

 -- C のメンバ変数: *note reprfunc: 494a. *note PyTypeObject:
          a73.tp_repr

     オプションのポインタで、組み込み関数 *note repr(): 7c8. を実装して
     いる関数を指します。

     The signature is the same as for *note PyObject_Repr(): ff9.:

          PyObject *tp_repr(PyObject *self);

     この関数は文字列オブジェクトか Unicode オブジェクトを返さなければな
     りません。理想的には、この関数が返す文字列は、適切な環境で *note
     eval(): 165. に渡した場合、同じ値を持つオブジェクトになるような文字
     列でなければなりません。不可能な場合には、オブジェクトの型と値から
     導出した内容の入った ‘'<'’ から始まって ‘'>'’ で終わる文字列を返さ
     なければなりません。

     '継承:'

     サブタイプはこのフィールドを継承します。

     'デフォルト'

     このフィールドが設定されていない場合、 ‘<%s object at %p>’ の形式を
     とる文字列が返されます。 ‘%s’ は型の名前に、 ‘%p’ はオブジェクトの
     メモリアドレスに置き換えられます。

 -- C のメンバ変数: *note PyNumberMethods: 13c5. **note PyTypeObject:
          a73.tp_as_number

     数値プロトコルを実装した追加の構造体を指すポインタです。これらのフ
     ィールドについては *note 数値オブジェクト構造体: 4cd2. で説明されて
     います。

     '継承:'

     *note tp_as_number: 959. フィールドは継承されませんが、そこの含まれ
     るフィールドが個別に継承されます。

 -- C のメンバ変数: *note PySequenceMethods: 479f. **note PyTypeObject:
          a73.tp_as_sequence

     シーケンスプロトコルを実装した追加の構造体を指すポインタです。これ
     らのフィールドについては *note シーケンスオブジェクト構造体: 4cd3.
     で説明されています。

     '継承:'

     *note tp_as_sequence: 4c93. フィールドは継承されませんが、これに含
     まれるフィールドが個別に継承されます。

 -- C のメンバ変数: *note PyMappingMethods: 47a0. **note PyTypeObject:
          a73.tp_as_mapping

     マッピングプロトコルを実装した追加の構造体を指すポインタです。これ
     らのフィールドについては *note マップオブジェクト構造体: 4cd4. で説
     明されています。

     '継承:'

     *note tp_as_mapping: 4c94. フィールドは継承されませんが、これに含ま
     れるフィールドが個別に継承されます。

 -- C のメンバ変数: *note hashfunc: 4941. *note PyTypeObject:
          a73.tp_hash

     オプションのポインタで、組み込み関数 *note hash(): 5b5. を実装して
     いる関数を指します。

     The signature is the same as for *note PyObject_Hash(): 3dc.:

          Py_hash_t tp_hash(PyObject *);

     通常時には ‘-1’ を戻り値にしてはなりません; ハッシュ値の計算中にエ
     ラーが生じた場合、関数は例外をセットして ‘-1’ を返さねばなりません
     。

     When this field is not set ('and' *note tp_richcompare: 479b. is
     not set), an attempt to take the hash of the object raises *note
     TypeError: 502.  This is the same as setting it to *note
     PyObject_HashNotImplemented(): 136e.

     このフィールドは明示的に *note PyObject_HashNotImplemented(): 136e.
     に設定することで、親 type からのハッシュメソッドの継承をブロックす
     ることができます。これは Python レベルでの ‘__hash__ = None’ と同等
     に解釈され、 ‘isinstance(o, collections.Hashable)’ が正しく ‘False’
     を返すようになります。逆もまた可能であることに注意してください -
     Python レベルで ‘__hash__ = None’ を設定することで ‘tp_hash’ スロッ
     トは *note PyObject_HashNotImplemented(): 136e. に設定されます。

     '継承:'

     Group: *note tp_hash: 47a1, *note tp_richcompare: 479b.

     このフィールドは *note tp_richcompare: 479b. と共にサブタイプに継承
     されます: すなわち、サブタイプの *note tp_richcompare: 479b. および
     *note tp_hash: 47a1. が両方とも ‘NULL’ のとき、サブタイプは基底タイ
     プから *note tp_richcompare: 479b. と *note tp_hash: 47a1. を両方と
     も継承します。

     'デフォルト'

     ‘PyBaseObject_Type’ uses *note PyObject_GenericHash(): 340.

 -- C のメンバ変数: *note ternaryfunc: 4951. *note PyTypeObject:
          a73.tp_call

     オプションのポインタで、オブジェクトの呼び出しを実装している関数を
     指します。オブジェクトが呼び出し可能でない場合には ‘NULL’ にしなけ
     ればなりません。シグネチャは *note PyObject_Call(): 376. と同じです
     。

          PyObject *tp_call(PyObject *self, PyObject *args, PyObject *kwargs);

     '継承:'

     サブタイプはこのフィールドを継承します。

 -- C のメンバ変数: *note reprfunc: 494a. *note PyTypeObject: a73.tp_str

     オプションのポインタで、組み込みの演算 *note str(): 418. を実装して
     いる関数を指します。(*note str: 418. が型の一つになったため、 *note
     str(): 418. は *note str: 418. のコンストラクタを呼び出すことに注意
     してください。このコンストラクタは実際の処理を行う上で *note
     PyObject_Str(): ffa. を呼び出し、さらに *note PyObject_Str(): ffa.
     がこのハンドラを呼び出すことになります。)

     The signature is the same as for *note PyObject_Str(): ffa.:

          PyObject *tp_str(PyObject *self);

     この関数は文字列オブジェクトか Unicode オブジェクトを返さなければな
     りません。それはオブジェクトを "分かりやすく (friendly)" 表現した文
     字列でなければなりません。というのは、この文字列はとりわけ *note
     print(): f42. 関数で使われることになる表記だからです。

     '継承:'

     サブタイプはこのフィールドを継承します。

     'デフォルト'

     このフィールドが設定されていない場合、文字列表現を返すためには
     *note PyObject_Repr(): ff9. が呼び出されます。

 -- C のメンバ変数: *note getattrofunc: 493d. *note PyTypeObject:
          a73.tp_getattro

     オプションのポインタで、get-attribute を実装している関数を指します
     。

     The signature is the same as for *note PyObject_GetAttr(): 324.:

          PyObject *tp_getattro(PyObject *self, PyObject *attr);

     通常の属性検索を実装している *note PyObject_GenericGetAttr(): 48b0.
     をこのフィールドに設定しておくとたいていの場合は便利です。

     '継承:'

     Group: *note tp_getattr: 4798, *note tp_getattro: 1657.

     このフィールドは *note tp_getattr: 4798. と共にサブタイプに継承され
     ます: すなわち、サブタイプの *note tp_getattr: 4798. および *note
     tp_getattro: 1657. が共に ‘NULL’ の場合、サブタイプは基底タイプから
     *note tp_getattr: 4798. と *note tp_getattro: 1657. を両方とも継承
     します。

     'デフォルト'

     ‘PyBaseObject_Type’ uses *note PyObject_GenericGetAttr(): 48b0.

 -- C のメンバ変数: *note setattrofunc: 494d. *note PyTypeObject:
          a73.tp_setattro

     オプションのポインタで、属性の設定と削除を行う関数を指します。

     The signature is the same as for *note PyObject_SetAttr(): 48b8.:

          int tp_setattro(PyObject *self, PyObject *attr, PyObject *value);

     さらに、'value' に ‘NULL’ を指定して属性を削除できるようにしなけれ
     ばなりません。 通常のオブジェクト属性設定を実装している *note
     PyObject_GenericSetAttr(): 48b1. をこのフィールドに設定しておくとた
     いていの場合は便利です。

     '継承:'

     Group: *note tp_setattr: 4799, *note tp_setattro: 4793.

     このフィールドは *note tp_setattr: 4799. と共にサブタイプに継承され
     ます: すなわち、サブタイプの *note tp_setattr: 4799. および *note
     tp_setattro: 4793. が共に ‘NULL’ の場合、サブタイプは基底タイプから
     *note tp_setattr: 4799. と *note tp_setattro: 4793. を両方とも継承
     します。

     'デフォルト'

     ‘PyBaseObject_Type’ uses *note PyObject_GenericSetAttr(): 48b1.

 -- C のメンバ変数: *note PyBufferProcs: 4a4c. **note PyTypeObject:
          a73.tp_as_buffer

     バッファインターフェースを実装しているオブジェクトにのみ関連する、
     一連のフィールド群が入った別の構造体を指すポインタです。構造体内の
     各フィールドは *note バッファオブジェクト構造体 (buffer object
     structure): 1010. で説明します。

     '継承:'

     *note tp_as_buffer: 957. フィールド自体は継承されませんが、これに含
     まれるフィールドは個別に継承されます。

 -- C のメンバ変数: unsigned long *note PyTypeObject: a73.tp_flags

     このフィールドは様々なフラグからなるビットマスクです。いくつかのフ
     ラグは、特定の状況において変則的なセマンティクスが適用されることを
     示します; その他のフラグは、型オブジェクト (あるいは *note
     tp_as_number: 959. 、 *note tp_as_sequence: 4c93. 、 *note
     tp_as_mapping: 4c94. 、 および *note tp_as_buffer: 957. が参照して
     いる拡張機能構造体) の特定のフィールドのうち、過去から現在までずっ
     と存在していたわけではないものが有効になっていることを示すために使
     われます; フラグビットがクリアされていれば、フラグが保護しているフ
     ィールドにはアクセスしない代わりに、その値はゼロか ‘NULL’ になって
     いるとみなさなければなりません。

     '継承:'

     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 this flag bit.  The flag bits that pertain to
     extension structures are strictly inherited if the extension
     structure is inherited, i.e.  the base type's value of the flag bit
     is copied into the subtype together with a pointer to the extension
     structure.  The *note Py_TPFLAGS_HAVE_GC: 748. flag bit is
     inherited together with the *note tp_traverse: 749. and *note
     tp_clear: 478d. fields, i.e.  if the *note Py_TPFLAGS_HAVE_GC: 748.
     flag bit is clear in the subtype and the *note tp_traverse: 749.
     and *note tp_clear: 478d. fields in the subtype exist and have
     ‘NULL’ values.  ..  XXX are most flag bits 'really' inherited
     individually?

     'デフォルト'

     ‘PyBaseObject_Type’ uses ‘Py_TPFLAGS_DEFAULT |
     Py_TPFLAGS_BASETYPE’.

     'Bit Masks:'

     以下に挙げるビットマスクは現在定義されているものです; フラグは ‘|’
     演算子で論理和を取って *note tp_flags: 1828. フィールドの値を作成で
     きます。 *note PyType_HasFeature(): 18bd. マクロは型とフラグ値、
     'tp' および 'f' をとり、 ‘tp->tp_flags & f’ が非ゼロかどうか調べま
     す。

      -- C のマクロ: Py_TPFLAGS_HEAPTYPE

          This bit is set when the type object itself is allocated on
          the heap, for example, types created dynamically using *note
          PyType_FromSpec(): 549.  In this case, the *note ob_type:
          4778. field of its instances is considered a reference to the
          type, and the type object is INCREF'ed when a new instance is
          created, and DECREF'ed when an instance is destroyed (this
          does not apply to instances of subtypes; only the type
          referenced by the instance's ob_type gets INCREF'ed or
          DECREF'ed).  Heap types should also *note support garbage
          collection: 4cd5. as they can form a reference cycle with
          their own module object.

          '継承:'

          ???

      -- C のマクロ: Py_TPFLAGS_BASETYPE

          型を別の型の基底タイプとして使える場合にセットされるビットです
          。このビットがクリアならば、この型のサブタイプは生成できません
          (Java における "final" クラスに似たクラスになります)。

          '継承:'

          ???

      -- C のマクロ: Py_TPFLAGS_READY

          型オブジェクトが *note PyType_Ready(): 747. で完全に初期化され
          るとセットされるビットです。

          '継承:'

          ???

      -- C のマクロ: Py_TPFLAGS_READYING

          *note PyType_Ready(): 747. による型オブジェクトの初期化処理中
          にセットされるビットです。

          '継承:'

          ???

      -- C のマクロ: Py_TPFLAGS_HAVE_GC

          This bit is set when the object supports garbage collection.
          If this bit is set, instances must be created using *note
          PyObject_GC_New: a70. and destroyed using *note
          PyObject_GC_Del(): 14ae.  More information in section *note
          循環参照ガベージコレクションをサポートする: 4cd5.  This bit
          also implies that the GC-related fields *note tp_traverse:
          749. and *note tp_clear: 478d. are present in the type object.

          '継承:'

          Group: *note Py_TPFLAGS_HAVE_GC: 748, *note tp_traverse: 749,
          *note tp_clear: 478d.

          The *note Py_TPFLAGS_HAVE_GC: 748. flag bit is inherited
          together with the *note tp_traverse: 749. and *note tp_clear:
          478d. fields, i.e.  if the *note Py_TPFLAGS_HAVE_GC: 748. flag
          bit is clear in the subtype and the *note tp_traverse: 749.
          and *note tp_clear: 478d. fields in the subtype exist and have
          ‘NULL’ values.

      -- C のマクロ: Py_TPFLAGS_DEFAULT

          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: ‘Py_TPFLAGS_HAVE_STACKLESS_EXTENSION’.

          '継承:'

          ???

      -- C のマクロ: Py_TPFLAGS_METHOD_DESCRIPTOR

          This bit indicates that objects behave like unbound methods.

          If this flag is set for ‘type(meth)’, then:

             - ‘meth.__get__(obj, cls)(*args, **kwds)’ (with ‘obj’ not
               None) must be equivalent to ‘meth(obj, *args, **kwds)’.

             - ‘meth.__get__(None, cls)(*args, **kwds)’ must be
               equivalent to ‘meth(*args, **kwds)’.

          This flag enables an optimization for typical method calls
          like ‘obj.meth()’: it avoids creating a temporary "bound
          method" object for ‘obj.meth’.

          Added in version 3.8.

          '継承:'

          This flag is never inherited by types without the *note
          Py_TPFLAGS_IMMUTABLETYPE: 39c. flag set.  For extension types,
          it is inherited whenever *note tp_descr_get: 4c95. is
          inherited.

      -- C のマクロ: Py_TPFLAGS_MANAGED_DICT

          This bit indicates that instances of the class have a
          ‘~object.__dict__’ attribute, and that the space for the
          dictionary is managed by the VM.

          If this flag is set, *note Py_TPFLAGS_HAVE_GC: 748. should
          also be set.

          The type traverse function must call *note
          PyObject_VisitManagedDict(): 342. and its clear function must
          call *note PyObject_ClearManagedDict(): 343.

          Added in version 3.12.

          '継承:'

          This flag is inherited unless the *note tp_dictoffset: 4a46.
          field is set in a superclass.

      -- C のマクロ: Py_TPFLAGS_MANAGED_WEAKREF

          This bit indicates that instances of the class should be
          weakly referenceable.

          Added in version 3.12.

          '継承:'

          This flag is inherited unless the *note tp_weaklistoffset:
          956. field is set in a superclass.

      -- C のマクロ: Py_TPFLAGS_ITEMS_AT_END

          Only usable with variable-size types, i.e.  ones with non-zero
          *note tp_itemsize: 1ed0.

          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).

          When setting this flag, be sure that all superclasses either
          use this memory layout, or are not variable-sized.  Python
          does not check this.

          Added in version 3.12.

          '継承:'

          This flag is inherited.

      -- C のマクロ: Py_TPFLAGS_LONG_SUBCLASS

      -- C のマクロ: Py_TPFLAGS_LIST_SUBCLASS

      -- C のマクロ: Py_TPFLAGS_TUPLE_SUBCLASS

      -- C のマクロ: Py_TPFLAGS_BYTES_SUBCLASS

      -- C のマクロ: Py_TPFLAGS_UNICODE_SUBCLASS

      -- C のマクロ: Py_TPFLAGS_DICT_SUBCLASS

      -- C のマクロ: Py_TPFLAGS_BASE_EXC_SUBCLASS

      -- C のマクロ: Py_TPFLAGS_TYPE_SUBCLASS

          これらのフラグは *note PyLong_Check(): 4a56. のような関数が、
          型がとある組み込み型のサブクラスかどうかを素早く判断するのに使
          われます; この専用のチェックは *note PyObject_IsInstance():
          e6f. のような汎用的なチェックよりも高速です。 組み込み型を継承
          した独自の型では *note tp_flags: 1828. を適切に設定すべきで、
          そうしないとその型が関わるコードでは、どんなチェックの方法が使
          われるかによって振る舞いが異なってしまうでしょう。

      -- C のマクロ: Py_TPFLAGS_HAVE_FINALIZE

          型構造体に *note tp_finalize: a74. スロットが存在しているとき
          にセットされるビットです。

          Added in version 3.4.

          バージョン 3.8 で非推奨: This flag isn't necessary anymore, as
          the interpreter assumes the *note tp_finalize: a74. slot is
          always present in the type structure.

      -- C のマクロ: Py_TPFLAGS_HAVE_VECTORCALL

          This bit is set when the class implements the *note vectorcall
          protocol: 51d.  See *note tp_vectorcall_offset: 49e9. for
          details.

          '継承:'

          This bit is inherited if *note tp_call: 524. is also
          inherited.

          Added in version 3.9.

          バージョン 3.12 で変更: This flag is now removed from a class
          when the class's *note __call__(): 523. method is reassigned.

          This flag can now be inherited by mutable classes.

      -- C のマクロ: Py_TPFLAGS_IMMUTABLETYPE

          This bit is set for type objects that are immutable: type
          attributes cannot be set nor deleted.

          *note PyType_Ready(): 747. automatically applies this flag to
          *note static types: 74a.

          '継承:'

          This flag is not inherited.

          Added in version 3.10.

      -- C のマクロ: Py_TPFLAGS_DISALLOW_INSTANTIATION

          Disallow creating instances of the type: set *note tp_new:
          54b. to NULL and don't create the ‘__new__’ key in the type
          dictionary.

          The flag must be set before creating the type, not after.  For
          example, it must be set before *note PyType_Ready(): 747. is
          called on the type.

          The flag is set automatically on *note static types: 74a. if
          *note tp_base: 4786. is NULL or ‘&PyBaseObject_Type’ and *note
          tp_new: 54b. is NULL.

          '継承:'

          This flag is not inherited.  However, subclasses will not be
          instantiable unless they provide a non-NULL *note tp_new: 54b.
          (which is only possible via the C API).

               注釈: To disallow instantiating a class directly but
               allow instantiating its subclasses (e.g.  for an *note
               abstract base class: 1186.), do not use this flag.
               Instead, make *note tp_new: 54b. only succeed for
               subclasses.

          Added in version 3.10.

      -- C のマクロ: Py_TPFLAGS_MAPPING

          This bit indicates that instances of the class may match
          mapping patterns when used as the subject of a *note match:
          7d8. block.  It is automatically set when registering or
          subclassing *note collections.abc.Mapping: 898, and unset when
          registering *note collections.abc.Sequence: 1194.

               注釈: *note Py_TPFLAGS_MAPPING: 180e. and *note
               Py_TPFLAGS_SEQUENCE: 180f. are mutually exclusive; it is
               an error to enable both flags simultaneously.

          '継承:'

          This flag is inherited by types that do not already set *note
          Py_TPFLAGS_SEQUENCE: 180f.

          参考
          ....

          PEP 634(1) - 構造的パターンマッチ: 仕様

          Added in version 3.10.

      -- C のマクロ: Py_TPFLAGS_SEQUENCE

          This bit indicates that instances of the class may match
          sequence patterns when used as the subject of a *note match:
          7d8. block.  It is automatically set when registering or
          subclassing *note collections.abc.Sequence: 1194, and unset
          when registering *note collections.abc.Mapping: 898.

               注釈: *note Py_TPFLAGS_MAPPING: 180e. and *note
               Py_TPFLAGS_SEQUENCE: 180f. are mutually exclusive; it is
               an error to enable both flags simultaneously.

          '継承:'

          This flag is inherited by types that do not already set *note
          Py_TPFLAGS_MAPPING: 180e.

          参考
          ....

          PEP 634(2) - 構造的パターンマッチ: 仕様

          Added in version 3.10.

      -- C のマクロ: Py_TPFLAGS_VALID_VERSION_TAG

          Internal.  Do not set or unset this flag.  To indicate that a
          class has changed call *note PyType_Modified(): 175d.

               警告: This flag is present in header files, but is not be
               used.  It will be removed in a future version of CPython

 -- C のメンバ変数: const char **note PyTypeObject: a73.tp_doc

     An optional pointer to a NUL-terminated C string giving the
     docstring for this type object.  This is exposed as the *note
     __doc__: 1c16. attribute on the type and instances of the type.

     '継承:'

     サブタイプはこのフィールドを継承 'しません' 。

 -- C のメンバ変数: *note traverseproc: 4952. *note PyTypeObject:
          a73.tp_traverse

     An optional pointer to a traversal function for the garbage
     collector.  This is only used if the *note Py_TPFLAGS_HAVE_GC: 748.
     flag bit is set.  The signature is:

          int tp_traverse(PyObject *self, visitproc visit, void *arg);

     Pythonのガベージコレクションの仕組みについての詳細は、 *note
     循環参照ガベージコレクションをサポートする: 4cd5. にあります。

     The *note tp_traverse: 749. pointer is used by the garbage
     collector to detect reference cycles.  A typical implementation of
     a *note tp_traverse: 749. function simply calls *note Py_VISIT():
     4784. on each of the instance's members that are Python objects
     that the instance owns.  For example, this is function
     ‘local_traverse()’ from the ‘_thread’ extension module:

          static int
          local_traverse(localobject *self, visitproc visit, void *arg)
          {
              Py_VISIT(self->args);
              Py_VISIT(self->kw);
              Py_VISIT(self->dict);
              return 0;
          }

     *note Py_VISIT(): 4784. が循環参照になる恐れのあるメンバにだけ呼び
     出されていることに注目してください。 ‘self->key’ メンバもありますが
     、それは ‘NULL’ か Python文字列なので、循環参照の一部になることはあ
     りません。

     一方、メンバが循環参照の一部になり得ないと判っていても、デバッグ目
     的で巡回したい場合があるかもしれないので、 *note gc: 56. モジュール
     の *note get_referents(): 7d0. 関数は循環参照になり得ないメンバも返
     します。

     Heap types (*note Py_TPFLAGS_HEAPTYPE: 87d.) must visit their type
     with:

          Py_VISIT(Py_TYPE(self));

     It is only needed since Python 3.9.  To support Python 3.8 and
     older, this line must be conditional:

          #if PY_VERSION_HEX >= 0x03090000
              Py_VISIT(Py_TYPE(self));
          #endif

     If the *note Py_TPFLAGS_MANAGED_DICT: 344. bit is set in the *note
     tp_flags: 1828. field, the traverse function must call *note
     PyObject_VisitManagedDict(): 342. like this:

          PyObject_VisitManagedDict((PyObject*)self, visit, arg);

          警告: When implementing *note tp_traverse: 749, only the
          members that the instance 'owns' (by having *note strong
          references: 316. to them) must be visited.  For instance, if
          an object supports weak references via the *note tp_weaklist:
          4a4b. slot, the pointer supporting the linked list (what
          'tp_weaklist' points to) must 'not' be visited as the instance
          does not directly own the weak references to itself (the
          weakreference list is there to support the weak reference
          machinery, but the instance has no strong reference to the
          elements inside it, as they are allowed to be removed even if
          the instance is still alive).

     Note that *note Py_VISIT(): 4784. requires the 'visit' and 'arg'
     parameters to ‘local_traverse()’ to have these specific names;
     don't name them just anything.

     Instances of *note heap-allocated types: 933. hold a reference to
     their type.  Their traversal function must therefore either visit
     *note Py_TYPE(self): 74b, or delegate this responsibility by
     calling ‘tp_traverse’ of another heap-allocated type (such as a
     heap-allocated superclass).  If they do not, the type object may
     not be garbage-collected.

     バージョン 3.9 で変更: Heap-allocated types are expected to visit
     ‘Py_TYPE(self)’ in ‘tp_traverse’.  In earlier versions of Python,
     due to bug 40217(3), doing this may lead to crashes in subclasses.

     '継承:'

     Group: *note Py_TPFLAGS_HAVE_GC: 748, *note tp_traverse: 749, *note
     tp_clear: 478d.

     This field is inherited by subtypes together with *note tp_clear:
     478d. and the *note Py_TPFLAGS_HAVE_GC: 748. flag bit: the flag
     bit, *note tp_traverse: 749, and *note tp_clear: 478d. are all
     inherited from the base type if they are all zero in the subtype.

 -- C のメンバ変数: *note inquiry: 4943. *note PyTypeObject:
          a73.tp_clear

     An optional pointer to a clear function for the garbage collector.
     This is only used if the *note Py_TPFLAGS_HAVE_GC: 748. flag bit is
     set.  The signature is:

          int tp_clear(PyObject *);

     *note tp_clear: 478d. メンバ関数は GC が検出した循環しているゴミの
     循環参照を壊すために用いられます。総合的な視点で考えると、システム
     内の全ての *note tp_clear: 478d. 関数が連携して、全ての循環参照を破
     壊しなければなりません。 (訳注: ある型が *note tp_clear: 478d. を実
     装しなくても全ての循環参照が破壊できるのであれば実装しなくても良い)
     これはとても繊細で、もし少しでも不確かな部分があるのであれば、
     *note tp_clear: 478d. 関数を提供するべきです。例えば、タプルは
     *note tp_clear: 478d. を実装しません。なぜなら、タプルだけで構成さ
     れた循環参照がみつかることは無いからです。従って、タプル以外の型の
     *note tp_clear: 478d. 関数だけで、タプルを含むどんな循環参照も必ず
     破壊できることになります。これは簡単に判ることではなく、 *note
     tp_clear: 478d. の実装を避ける良い理由はめったにありません。

     次の例にあるように、 *note tp_clear: 478d. の実装は、インスタンスか
     ら Python オブジェクトだと思われるメンバへの参照を外し、それらのメ
     ンバへのポインタに ‘NULL’ をセットすべきです:

          static int
          local_clear(localobject *self)
          {
              Py_CLEAR(self->key);
              Py_CLEAR(self->args);
              Py_CLEAR(self->kw);
              Py_CLEAR(self->dict);
              return 0;
          }

     The *note Py_CLEAR(): 544. macro should be used, because clearing
     references is delicate: the reference to the contained object must
     not be released (via *note Py_DECREF(): 53b.) until after the
     pointer to the contained object is set to ‘NULL’.  This is because
     releasing the reference may cause the contained object to become
     trash, triggering a chain of reclamation activity that may include
     invoking arbitrary Python code (due to finalizers, or weakref
     callbacks, associated with the contained object).  If it's possible
     for such code to reference 'self' again, it's important that the
     pointer to the contained object be ‘NULL’ at that time, so that
     'self' knows the contained object can no longer be used.  The *note
     Py_CLEAR(): 544. macro performs the operations in a safe order.

     If the *note Py_TPFLAGS_MANAGED_DICT: 344. bit is set in the *note
     tp_flags: 1828. field, the traverse function must call *note
     PyObject_ClearManagedDict(): 343. like this:

          PyObject_ClearManagedDict((PyObject*)self);

     Note that *note tp_clear: 478d. is not 'always' called before an
     instance is deallocated.  For example, when reference counting is
     enough to determine that an object is no longer used, the cyclic
     garbage collector is not involved and *note tp_dealloc: 477a. is
     called directly.

     *note tp_clear: 478d. 関数の目的は参照カウントを破壊することなので
     、 Python 文字列や Python 整数のような、循環参照に含むことのできな
     いオブジェクトをクリアする必要はありません。一方、所有する全ての
     Python オブジェクトをクリアするようにし、その型の *note tp_dealloc:
     477a. 関数が *note tp_clear: 478d. 関数を実行するようにすると実装が
     楽になるでしょう。

     Pythonのガベージコレクションの仕組みについての詳細は、 *note
     循環参照ガベージコレクションをサポートする: 4cd5. にあります。

     '継承:'

     Group: *note Py_TPFLAGS_HAVE_GC: 748, *note tp_traverse: 749, *note
     tp_clear: 478d.

     This field is inherited by subtypes together with *note
     tp_traverse: 749. and the *note Py_TPFLAGS_HAVE_GC: 748. flag bit:
     the flag bit, *note tp_traverse: 749, and *note tp_clear: 478d. are
     all inherited from the base type if they are all zero in the
     subtype.

 -- C のメンバ変数: *note richcmpfunc: 494b. *note PyTypeObject:
          a73.tp_richcompare

     オプションのポインタで、拡張比較関数を指します。シグネチャは次の通
     りです:

          PyObject *tp_richcompare(PyObject *self, PyObject *other, int op);

     The first parameter is guaranteed to be an instance of the type
     that is defined by *note PyTypeObject: a73.

     この関数は、比較結果を返すべきです。(普通は ‘Py_True’ か ‘Py_False’
     です。) 比較が未定義の場合は、‘Py_NotImplemented’ を、それ以外のエ
     ラーが発生した場合には例外状態をセットして ‘NULL’ を返さなければな
     りません。

     *note tp_richcompare: 479b. および *note PyObject_RichCompare():
     479c. 関数の第三引数に使うための定数としては以下が定義されています:

     定数                     比較
                              
     ------------------------------------------
                              
      -- C のマクロ: Py_LT    ‘<’
                              
                              
      -- C のマクロ: Py_LE    ‘<=’
                              
                              
      -- C のマクロ: Py_EQ    ‘==’
                              
                              
      -- C のマクロ: Py_NE    ‘!=’
                              
                              
      -- C のマクロ: Py_GT    ‘>’
                              
                              
      -- C のマクロ: Py_GE    ‘>=’
                              

     拡張比較関数(rich comparison functions)を簡単に記述するためのマクロ
     が定義されています:

      -- C のマクロ: Py_RETURN_RICHCOMPARE (VAL_A, VAL_B, op)

          比較した結果に応じて ‘Py_True’ か ‘Py_False’ を返します。
          VAL_A と VAL_B は C の比較演算によって順序付け可能でなければな
          りません（例えばこれらは C言語の整数か浮動小数点数になるでしょ
          う）。三番目の引数には *note PyObject_RichCompare(): 479c. と
          同様に要求された演算を指定します。

          The returned value is a new *note strong reference: 316.

          エラー時には例外を設定して、関数から ‘NULL’ でリターンします。

          Added in version 3.7.

     '継承:'

     Group: *note tp_hash: 47a1, *note tp_richcompare: 479b.

     このフィールドは *note tp_hash: 47a1. と共にサブタイプに継承されま
     す: すなわち、サブタイプの *note tp_richcompare: 479b. および *note
     tp_hash: 47a1. が両方とも ‘NULL’ のとき、サブタイプは基底タイプから
     *note tp_richcompare: 479b. と *note tp_hash: 47a1. を両方とも継承
     します。

     'デフォルト'

     ‘PyBaseObject_Type’ provides a *note tp_richcompare: 479b.
     implementation, which may be inherited.  However, if only *note
     tp_hash: 47a1. is defined, not even the inherited function is used
     and instances of the type will not be able to participate in any
     comparisons.

 -- C のメンバ変数: *note Py_ssize_t: a2e. *note PyTypeObject:
          a73.tp_weaklistoffset

     While this field is still supported, *note
     Py_TPFLAGS_MANAGED_WEAKREF: 525. should be used instead, if at all
     possible.

     型のインスタンスが弱参照可能な場合、このフィールドはゼロよりも大き
     な数になり、インスタンス構造体における弱参照リストの先頭を示すオフ
     セットが入ります (GC ヘッダがある場合には無視します); このオフセッ
     ト値は *note PyObject_ClearWeakRefs(): 542. および ‘PyWeakref_*’ 関
     数が利用します。インスタンス構造体には、 ‘NULL’ に初期化された
     *note PyObject: 312.* 型のフィールドが入っていなければなりません。

     このフィールドを *note tp_weaklist: 4a4b. と混同しないようにしてく
     ださい; これは型オブジェクト自身への弱参照からなるリストの先頭です
     。

     It is an error to set both the *note Py_TPFLAGS_MANAGED_WEAKREF:
     525. bit and *note tp_weaklistoffset: 956.

     '継承:'

     このフィールドはサブタイプに継承されますが、以下の規則を読んでくだ
     さい。サブタイプはこのオフセット値をオーバライドすることがあります;
     従って、サブタイプでは弱参照リストの先頭が基底タイプとは異なる場合
     があります。リストの先頭は常に *note tp_weaklistoffset: 956. で分か
     るはずなので、このことは問題にはならないはずです。

     'デフォルト'

     If the *note Py_TPFLAGS_MANAGED_WEAKREF: 525. bit is set in the
     *note tp_flags: 1828. field, then *note tp_weaklistoffset: 956.
     will be set to a negative value, to indicate that it is unsafe to
     use this field.

 -- C のメンバ変数: *note getiterfunc: 493f. *note PyTypeObject:
          a73.tp_iter

     オプションの変数で、そのオブジェクトの *note イテレータ: 191. を返
     す関数へのポインタです。この値が存在することは、通常この型のインス
     タンスが *note イテレート可能: 10ad. であることを示しています (しか
     し、シーケンスはこの関数がなくてもイテレート可能です)。

     この関数は *note PyObject_GetIter(): 48b4. と同じシグネチャを持って
     います:

          PyObject *tp_iter(PyObject *self);

     '継承:'

     サブタイプはこのフィールドを継承します。

 -- C のメンバ変数: *note iternextfunc: 4944. *note PyTypeObject:
          a73.tp_iternext

     オプションのポインタで、*note イテレーター: 191. の次の要素を返す関
     数を指します。シグネチャは次の通りです:

          PyObject *tp_iternext(PyObject *self);

     イテレータの要素がなくなると、この関数は ‘NULL’ を返さなければなり
     ません。 *note StopIteration: bc8. 例外は設定してもしなくても良いで
     す。その他のエラーが発生したときも、 ‘NULL’ を返さなければなりませ
     ん。このフィールドがあると、この型のインスタンスがイテレータである
     ことを示します。

     イテレータ型では、 *note tp_iter: 1497. 関数も定義されていなければ
     ならず、その関数は (新たなイテレータインスタンスではなく) イテレー
     タインスタンス自体を返さねばなりません。

     この関数のシグネチャは *note PyIter_Next(): 4863. と同じです。

     '継承:'

     サブタイプはこのフィールドを継承します。

 -- C のメンバ変数: struct *note PyMethodDef: 1480. **note PyTypeObject:
          a73.tp_methods

     オプションのポインタで、この型の正規 (regular) のメソッドを宣言して
     いる *note PyMethodDef: 1480. 構造体からなる、 ‘NULL’ で終端された
     静的な配列を指します。

     配列の各要素ごとに、メソッドデスクリプタの入った、要素が型の辞書 (下
     記の *note tp_dict: 1685. 参照) に追加されます。

     '継承:'

     サブタイプはこのフィールドを継承しません (メソッドは別個のメカニズ
     ムで継承されています)。

 -- C のメンバ変数: struct *note PyMemberDef: 51a. **note PyTypeObject:
          a73.tp_members

     オプションのポインタで、型の正規 (regular) のデータメンバ (フィール
     ドおよびスロット) を宣言している *note PyMemberDef: 51a. 構造体から
     なる、 ‘NULL’ で終端された静的な配列を指します。

     配列の各要素ごとに、メンバデスクリプタの入った要素が型の辞書 (下記
     の *note tp_dict: 1685. 参照) に追加されます。

     '継承:'

     サブタイプはこのフィールドを継承しません (メンバは別個のメカニズム
     で継承されています)。

 -- C のメンバ変数: struct *note PyGetSetDef: b86. **note PyTypeObject:
          a73.tp_getset

     オプションのポインタで、インスタンスの算出属性 (computed attribute)
     を宣言している *note PyGetSetDef: b86. 構造体からなる、 ‘NULL’ で終
     端された静的な配列を指します。

     配列の各要素ごとに、 getter/setter デスクリプタの入った、要素が型の
     辞書 (下記の *note tp_dict: 1685. 参照) に追加されます。

     '継承:'

     サブタイプはこのフィールドを継承しません (算出属性は別個のメカニズ
     ムで継承されています)。

 -- C のメンバ変数: *note PyTypeObject: a73. **note PyTypeObject:
          a73.tp_base

     オプションのポインタで、型に関するプロパティを継承する基底タイプを
     指します。このフィールドのレベルでは、単継承 (single inheritance) だ
     けがサポートされています; 多重継承はメタタイプの呼び出しによる動的
     な型オブジェクトの生成を必要とします。

          注釈: 
          Slot initialization is subject to the rules of initializing
          globals.  C99 requires the initializers to be "address
          constants".  Function designators like *note
          PyType_GenericNew(): 4777, with implicit conversion to a
          pointer, are valid C99 address constants.

          However, the unary '&' operator applied to a non-static
          variable like ‘PyBaseObject_Type’ is not required to produce
          an address constant.  Compilers may support this (gcc does),
          MSVC does not.  Both compilers are strictly standard
          conforming in this particular behavior.

          Consequently, *note tp_base: 4786. should be set in the
          extension module's init function.

     '継承:'

     (当たり前ですが) サブタイプはこのフィールドを継承しません。

     'デフォルト'

     このフィールドのデフォルト値は (Python プログラマは *note object:
     a5a. 型として知っている) ‘&PyBaseObject_Type’ になります。

 -- C のメンバ変数: *note PyObject: 312. **note PyTypeObject:
          a73.tp_dict

     型の辞書は *note PyType_Ready(): 747. によってこのフィールドに収め
     られます。

     This field should normally be initialized to ‘NULL’ before
     PyType_Ready is called; it may also be initialized to a dictionary
     containing initial attributes for the type.  Once *note
     PyType_Ready(): 747. has initialized the type, extra attributes for
     the type may be added to this dictionary only if they don't
     correspond to overloaded operations (like *note __add__(): 1eed.).
     Once initialization for the type has finished, this field should be
     treated as read-only.

     Some types may not store their dictionary in this slot.  Use *note
     PyType_GetDict(): 1684. to retrieve the dictionary for an arbitrary
     type.

     バージョン 3.12 で変更: Internals detail: For static builtin types,
     this is always ‘NULL’.  Instead, the dict for such types is stored
     on ‘PyInterpreterState’.  Use *note PyType_GetDict(): 1684. to get
     the dict for an arbitrary type.

     '継承:'

     サブタイプはこのフィールドを継承しません (が、この辞書内で定義され
     ている属性は異なるメカニズムで継承されます)。

     'デフォルト'

     If this field is ‘NULL’, *note PyType_Ready(): 747. will assign a
     new dictionary to it.

          警告: *note tp_dict: 1685. に *note PyDict_SetItem(): 4766. を
          使ったり、辞書 C-API で編集するのは安全ではありません。

 -- C のメンバ変数: *note descrgetfunc: 4939. *note PyTypeObject:
          a73.tp_descr_get

     オプションのポインタで、デスクリプタの get 関数を指します。

     関数のシグネチャは次のとおりです

          PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type);

     '継承:'

     サブタイプはこのフィールドを継承します。

 -- C のメンバ変数: *note descrsetfunc: 493a. *note PyTypeObject:
          a73.tp_descr_set

     オプションのポインタで、デスクリプタの値の設定と削除を行う関数を指
     します。

     関数のシグネチャは次のとおりです

          int tp_descr_set(PyObject *self, PyObject *obj, PyObject *value);

     値を削除するには、'value' 引数に ‘NULL’ を設定します。

     '継承:'

     サブタイプはこのフィールドを継承します。

 -- C のメンバ変数: *note Py_ssize_t: a2e. *note PyTypeObject:
          a73.tp_dictoffset

     While this field is still supported, *note Py_TPFLAGS_MANAGED_DICT:
     344. should be used instead, if at all possible.

     型のインスタンスにインスタンス変数の入った辞書がある場合、このフィ
     ールドは非ゼロの値になり、型のインスタンスデータ構造体におけるイン
     スタンス変数辞書へのオフセットが入ります; このオフセット値は *note
     PyObject_GenericGetAttr(): 48b0. が使います。

     このフィールドを *note tp_dict: 1685. と混同しないようにしてくださ
     い; これは型オブジェクト自身の属性の辞書です。

     The value specifies the offset of the dictionary from the start of
     the instance structure.

     The *note tp_dictoffset: 4a46. should be regarded as write-only.
     To get the pointer to the dictionary call *note
     PyObject_GenericGetDict(): 18a4.  Calling *note
     PyObject_GenericGetDict(): 18a4. may need to allocate memory for
     the dictionary, so it is may be more efficient to call *note
     PyObject_GetAttr(): 324. when accessing an attribute on the object.

     It is an error to set both the *note Py_TPFLAGS_MANAGED_WEAKREF:
     525. bit and *note tp_dictoffset: 4a46.

     '継承:'

     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 *note Py_TPFLAGS_MANAGED_DICT: 344.

     'デフォルト'

     This slot has no default.  For *note static types: 74a, if the
     field is ‘NULL’ then no *note __dict__: 526. gets created for
     instances.

     If the *note Py_TPFLAGS_MANAGED_DICT: 344. bit is set in the *note
     tp_flags: 1828. field, then *note tp_dictoffset: 4a46. will be set
     to ‘-1’, to indicate that it is unsafe to use this field.

 -- C のメンバ変数: *note initproc: 4942. *note PyTypeObject:
          a73.tp_init

     オプションのポインタで、インスタンス初期化関数を指します。

     This function corresponds to the *note __init__(): 67c. method of
     classes.  Like ‘__init__()’, it is possible to create an instance
     without calling ‘__init__()’, and it is possible to reinitialize an
     instance by calling its ‘__init__()’ method again.

     関数のシグネチャは次のとおりです

          int tp_init(PyObject *self, PyObject *args, PyObject *kwds);

     The self argument is the instance to be initialized; the 'args' and
     'kwds' arguments represent positional and keyword arguments of the
     call to *note __init__(): 67c.

     *note tp_init: 54d. 関数のフィールドが ‘NULL’ でない場合、通常の型
     を呼び出す方法のインスタンス生成において、型の *note tp_new: 54b. 関
     数がインスタンスを返した後に呼び出されます。 *note tp_new: 54b. が
     元の型のサブタイプでない別の型を返す場合、 *note tp_init: 54d. は全
     く呼び出されません; *note tp_new: 54b. が元の型のサブタイプのインス
     タンスを返す場合、サブタイプの *note tp_init: 54d. が呼び出されます
     。

     成功のときには ‘0’ を、エラー時には例外をセットして ‘-1’ を返します
     。

     '継承:'

     サブタイプはこのフィールドを継承します。

     'デフォルト'

     For *note static types: 74a. this field does not have a default.

 -- C のメンバ変数: *note allocfunc: 4937. *note PyTypeObject:
          a73.tp_alloc

     オプションのポインタで、インスタンスのメモリ確保関数を指します。

     関数のシグネチャは次のとおりです

          PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems);

     '継承:'

     This field is inherited by static subtypes, but not by dynamic
     subtypes (subtypes created by a class statement).

     'デフォルト'

     For dynamic subtypes, this field is always set to *note
     PyType_GenericAlloc(): a39, to force a standard heap allocation
     strategy.

     For static subtypes, ‘PyBaseObject_Type’ uses *note
     PyType_GenericAlloc(): a39.  That is the recommended value for all
     statically defined types.

 -- C のメンバ変数: *note newfunc: 4946. *note PyTypeObject: a73.tp_new

     オプションのポインタで、インスタンス生成関数を指します。

     関数のシグネチャは次のとおりです

          PyObject *tp_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds);

     'subtype' 引数は生成するオブジェクトの型です; 'args' および 'kwds'
     引数は、型を呼び出すときの位置引数およびキーワード引数です。
     'subtype' は *note tp_new: 54b. 関数を呼び出すときに使う型と同じで
     ある必要はないことに注意してください; その型の (無関係ではない) サ
     ブタイプのこともあります。

     *note tp_new: 54b. 関数は ‘subtype->tp_alloc(subtype, nitems)’ を呼
     び出してオブジェクトのメモリ領域を確保し、初期化で絶対に必要とされ
     る処理だけを行います。省略したり繰り返したりしても問題のない初期化
     処理は *note tp_init: 54d. ハンドラ内に配置しなければなりません。だ
     いたいの目安としては、変更不能な型では初期化は全て *note tp_new:
     54b. で行い、一方、変更可能な型ではほとんどの初期化を *note
     tp_init: 54d. に回すべきです。

     Set the *note Py_TPFLAGS_DISALLOW_INSTANTIATION: 54e. flag to
     disallow creating instances of the type in Python.

     '継承:'

     サブタイプはこのフィールドを継承します。例外として、 *note tp_base:
     4786. が ‘NULL’ か ‘&PyBaseObject_Type’ になっている *note
     静的な型: 74a. では継承しません。

     'デフォルト'

     For *note static types: 74a. 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.

 -- C のメンバ変数: *note freefunc: 4b3c. *note PyTypeObject:
          a73.tp_free

     オプションのポインタで、インスタンスのメモリ解放関数を指します。シ
     グネチャは以下の通りです:

          void tp_free(void *self);

     このシグネチャと互換性のある初期化子は *note PyObject_Free(): c34.
     です。

     '継承:'

     This field is inherited by static subtypes, but not by dynamic
     subtypes (subtypes created by a class statement)

     'デフォルト'

     In dynamic subtypes, this field is set to a deallocator suitable to
     match *note PyType_GenericAlloc(): a39. and the value of the *note
     Py_TPFLAGS_HAVE_GC: 748. flag bit.

     For static subtypes, ‘PyBaseObject_Type’ uses *note PyObject_Del():
     147a.

 -- C のメンバ変数: *note inquiry: 4943. *note PyTypeObject:
          a73.tp_is_gc

     オプションのポインタで、ガベージコレクタから呼び出される関数を指し
     ます。

     The garbage collector needs to know whether a particular object is
     collectible or not.  Normally, it is sufficient to look at the
     object's type's *note tp_flags: 1828. field, and check the *note
     Py_TPFLAGS_HAVE_GC: 748. flag bit.  But some types have a mixture
     of statically and dynamically allocated instances, and the
     statically allocated instances are not collectible.  Such types
     should define this function; it should return ‘1’ for a collectible
     instance, and ‘0’ for a non-collectible instance.  The signature
     is:

          int tp_is_gc(PyObject *self);

     (上記のような型の例は、型オブジェクト自体です。メタタイプ *note
     PyType_Type: 518. は、型のメモリ確保が静的か *note 動的: 933. かを
     区別するためにこの関数を定義しています。)

     '継承:'

     サブタイプはこのフィールドを継承します。

     'デフォルト'

     This slot has no default.  If this field is ‘NULL’, *note
     Py_TPFLAGS_HAVE_GC: 748. is used as the functional equivalent.

 -- C のメンバ変数: *note PyObject: 312. **note PyTypeObject:
          a73.tp_bases

     基底型からなるタプルです。

     This field should be set to ‘NULL’ and treated as read-only.
     Python will fill it in when the type is *note initialized: 747.

     For dynamically created classes, the ‘Py_tp_bases’ *note slot:
     48eb. can be used instead of the 'bases' argument of *note
     PyType_FromSpecWithBases(): 54a.  The argument form is preferred.

          警告: 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.

     '継承:'

     このフィールドは継承されません。

 -- C のメンバ変数: *note PyObject: 312. **note PyTypeObject: a73.tp_mro

     基底タイプ群を展開した集合が入っているタプルです。集合は該当する型
     自体からはじまり、 *note object: a5a. で終わります。メソッド解決順
     序 (Method Resolution Order) に従って並んでいます。

     This field should be set to ‘NULL’ and treated as read-only.
     Python will fill it in when the type is *note initialized: 747.

     '継承:'

     このフィールドは継承されません; フィールドの値は *note
     PyType_Ready(): 747. で毎回計算されます。

 -- C のメンバ変数: *note PyObject: 312. **note PyTypeObject:
          a73.tp_cache

     未使用のフィールドです。内部でのみ利用されます。

     '継承:'

     このフィールドは継承されません。

 -- C のメンバ変数: void **note PyTypeObject: a73.tp_subclasses

     A collection of subclasses.  Internal use only.  May be an invalid
     pointer.

     To get a list of subclasses, call the Python method *note
     __subclasses__(): 53f.

     バージョン 3.12 で変更: For some types, this field does not hold a
     valid *note PyObject: 312.*.  The type was changed to void* to
     indicate this.

     '継承:'

     このフィールドは継承されません。

 -- C のメンバ変数: *note PyObject: 312. **note PyTypeObject:
          a73.tp_weaklist

     この型オブジェクトに対する弱参照からなるリストの先頭です。

     バージョン 3.12 で変更: 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.

     '継承:'

     このフィールドは継承されません。

 -- C のメンバ変数: *note destructor: 493b. *note PyTypeObject:
          a73.tp_del

     このフィールドは廃止されました。*note tp_finalize: a74. を代わりに
     利用してください。

 -- C のメンバ変数: unsigned int *note PyTypeObject: a73.tp_version_tag

     メソッドキャッシュへのインデックスとして使われます。内部使用だけの
     ための関数です。

     '継承:'

     このフィールドは継承されません。

 -- C のメンバ変数: *note destructor: 493b. *note PyTypeObject:
          a73.tp_finalize

     オプションのポインタで、インスタンスの終了処理関数を指します。シグ
     ネチャは以下の通りです:

          void tp_finalize(PyObject *self);

     *note tp_finalize: a74. が設定されている場合、インスタンスをファイ
     ナライズするときに、インタプリタがこの関数を1回呼び出します。 ガベ
     ージコレクタ (このインスタンスが孤立した循環参照の一部だった場合) や
     オブジェクトが破棄される直前にもこの関数は呼び出されます。 どちらの
     場合でも、循環参照を破壊しようとする前に呼び出されることが保証され
     ていて、確実にオブジェクトが正常な状態にあるようにします。

     *note tp_finalize: a74. は現在の例外状態を変更すべきではありません;
     従って、単純でないファイナライザを書くには次の方法が推奨されます:

          static void
          local_finalize(PyObject *self)
          {
              PyObject *error_type, *error_value, *error_traceback;

              /* Save the current exception, if any. */
              PyErr_Fetch(&error_type, &error_value, &error_traceback);

              /* ... */

              /* Restore the saved exception. */
              PyErr_Restore(error_type, error_value, error_traceback);
          }

     '継承:'

     サブタイプはこのフィールドを継承します。

     Added in version 3.4.

     バージョン 3.8 で変更: Before version 3.8 it was necessary to set
     the *note Py_TPFLAGS_HAVE_FINALIZE: 3cb. flags bit in order for
     this field to be used.  This is no longer required.

     参考
     ....

     "オブジェクトの安全な終了処理" ( PEP 442(4))

 -- C のメンバ変数: *note vectorcallfunc: 522. *note PyTypeObject:
          a73.tp_vectorcall

     Vectorcall function to use for calls of this type object.  In other
     words, it is used to implement *note vectorcall: 51d. for
     ‘type.__call__’.  If ‘tp_vectorcall’ is ‘NULL’, the default call
     implementation using *note __new__(): 54c. and *note __init__():
     67c. is used.

     '継承:'

     このフィールドは決して継承されません。

     Added in version 3.9: （このフィールドは3.8から存在していますが、
     3.9以降でしか利用できません）

 -- C のメンバ変数: unsigned char *note PyTypeObject: a73.tp_watched

     Internal.  Do not use.

     Added in version 3.12.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0634/

   (2) https://peps.python.org/pep-0634/

   (3) https://bugs.python.org/issue40217

   (4) https://peps.python.org/pep-0442/


File: python.info,  Node: Static Types,  Next: Heap Types,  Prev: PyTypeObject スロット,  Up: 型オブジェクト<3>

7.12.3.9 Static Types
.....................

Traditionally, types defined in C code are 'static', that is, a static
*note PyTypeObject: a73. structure is defined directly in code and
initialized using *note PyType_Ready(): 747.

This results in types that are limited relative to types defined in
Python:

   * Static types are limited to one base, i.e.  they cannot use
     multiple inheritance.

   * 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.

   * Static type objects are shared across *note sub-interpreters: 553,
     so they should not include any subinterpreter-specific state.

Also, since *note PyTypeObject: a73. is only part of the *note Limited
API: 36f. as an opaque struct, any extension modules using static types
must be compiled for a specific Python minor version.


File: python.info,  Node: Heap Types,  Next: 数値オブジェクト構造体,  Prev: Static Types,  Up: 型オブジェクト<3>

7.12.3.10 Heap Types
....................

An alternative to *note static types: 74a. is 'heap-allocated types', or
'heap types' for short, which correspond closely to classes created by
Python's ‘class’ statement.  Heap types have the *note
Py_TPFLAGS_HEAPTYPE: 87d. flag set.

This is done by filling a *note PyType_Spec: 1681. structure and calling
*note PyType_FromSpec(): 549, *note PyType_FromSpecWithBases(): 54a,
*note PyType_FromModuleAndSpec(): 51c, or *note PyType_FromMetaclass():
51b.


File: python.info,  Node: 数値オブジェクト構造体,  Next: マップオブジェクト構造体,  Prev: Heap Types,  Up: 型オブジェクト<3>

7.12.3.11 数値オブジェクト構造体
................................

 -- C のデータ型: type PyNumberMethods

     この構造体は数値型プロトコルを実装するために使われる関数群へのポイ
     ンタを保持しています。 以下のそれぞれの関数は *note 数値型プロトコル
     (number protocol): 49f4. で解説されている似た名前の関数から利用され
     ます。

     以下は構造体の定義です:

          typedef struct {
               binaryfunc nb_add;
               binaryfunc nb_subtract;
               binaryfunc nb_multiply;
               binaryfunc nb_remainder;
               binaryfunc nb_divmod;
               ternaryfunc nb_power;
               unaryfunc nb_negative;
               unaryfunc nb_positive;
               unaryfunc nb_absolute;
               inquiry nb_bool;
               unaryfunc nb_invert;
               binaryfunc nb_lshift;
               binaryfunc nb_rshift;
               binaryfunc nb_and;
               binaryfunc nb_xor;
               binaryfunc nb_or;
               unaryfunc nb_int;
               void *nb_reserved;
               unaryfunc nb_float;

               binaryfunc nb_inplace_add;
               binaryfunc nb_inplace_subtract;
               binaryfunc nb_inplace_multiply;
               binaryfunc nb_inplace_remainder;
               ternaryfunc nb_inplace_power;
               binaryfunc nb_inplace_lshift;
               binaryfunc nb_inplace_rshift;
               binaryfunc nb_inplace_and;
               binaryfunc nb_inplace_xor;
               binaryfunc nb_inplace_or;

               binaryfunc nb_floor_divide;
               binaryfunc nb_true_divide;
               binaryfunc nb_inplace_floor_divide;
               binaryfunc nb_inplace_true_divide;

               unaryfunc nb_index;

               binaryfunc nb_matrix_multiply;
               binaryfunc nb_inplace_matrix_multiply;
          } PyNumberMethods;

          注釈: 二項関数と三項関数は、すべてのオペランドの型をチェックし
          なければならず、必要な変換を実装しなければなりません (すくなく
          ともオペランドの一つは定義している型のインスタンスです).  もし
          与えられたオペランドに対して操作が定義されなければ、二項関数と
          三項関数は ‘Py_NotImplemented’ を返さなければならず、他のエラ
          ーが起こった場合は、‘NULL’ を返して例外を設定しなければなりま
          せん。

          注釈: The *note nb_reserved: 4cbb. field should always be
          ‘NULL’.  It was previously called ‘nb_long’, and was renamed
          in Python 3.0.1.

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_add

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_subtract

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_multiply

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_remainder

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_divmod

 -- C のメンバ変数: *note ternaryfunc: 4951. *note PyNumberMethods:
          13c5.nb_power

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyNumberMethods:
          13c5.nb_negative

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyNumberMethods:
          13c5.nb_positive

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyNumberMethods:
          13c5.nb_absolute

 -- C のメンバ変数: *note inquiry: 4943. *note PyNumberMethods:
          13c5.nb_bool

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyNumberMethods:
          13c5.nb_invert

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_lshift

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_rshift

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_and

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_xor

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_or

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyNumberMethods:
          13c5.nb_int

 -- C のメンバ変数: void **note PyNumberMethods: 13c5.nb_reserved

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyNumberMethods:
          13c5.nb_float

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_add

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_subtract

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_multiply

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_remainder

 -- C のメンバ変数: *note ternaryfunc: 4951. *note PyNumberMethods:
          13c5.nb_inplace_power

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_lshift

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_rshift

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_and

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_xor

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_or

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_floor_divide

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_true_divide

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_floor_divide

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_true_divide

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyNumberMethods:
          13c5.nb_index

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_matrix_multiply

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyNumberMethods:
          13c5.nb_inplace_matrix_multiply


File: python.info,  Node: マップオブジェクト構造体,  Next: シーケンスオブジェクト構造体,  Prev: 数値オブジェクト構造体,  Up: 型オブジェクト<3>

7.12.3.12 マップオブジェクト構造体
..................................

 -- C のデータ型: type PyMappingMethods

     この構造体はマップ型プロトコルを実装するために使われる関数群へのポ
     インタを保持しています。 以下の3つのメンバを持っています:

 -- C のメンバ変数: *note lenfunc: 4945. *note PyMappingMethods:
          47a0.mp_length

     この関数は *note PyMapping_Size(): 19c1. や *note PyObject_Size():
     48b9. から利用され、それらと同じシグネチャを持っています。オブジェ
     クトが定義された長さを持たない場合は、このスロットは ‘NULL’ に設定
     されることがあります。

 -- C のメンバ変数: *note binaryfunc: 4938. *note PyMappingMethods:
          47a0.mp_subscript

     この関数は *note PyObject_GetItem(): 320. および *note
     PySequence_GetSlice(): 48c4. から利用され、‘PyObject_GetItem()’ と
     同じシグネチャを持っています。このスロットは *note
     PyMapping_Check(): 4877. が ‘1’ を返すためには必要で、そうでなけれ
     ば ‘NULL’ の場合があります。

 -- C のメンバ変数: *note objobjargproc: 4947. *note PyMappingMethods:
          47a0.mp_ass_subscript

     This function is used by *note PyObject_SetItem(): 47da, *note
     PyObject_DelItem(): 48ad, *note PySequence_SetSlice(): 48cb. and
     *note PySequence_DelSlice(): 48c2.  It has the same signature as
     ‘PyObject_SetItem()’, but 'v' can also be set to ‘NULL’ to delete
     an item.  If this slot is ‘NULL’, the object does not support item
     assignment and deletion.


File: python.info,  Node: シーケンスオブジェクト構造体,  Next: バッファオブジェクト構造体 buffer object structure,  Prev: マップオブジェクト構造体,  Up: 型オブジェクト<3>

7.12.3.13 シーケンスオブジェクト構造体
......................................

 -- C のデータ型: type PySequenceMethods

     この構造体はシーケンス型プロトコルを実装するために使われる関数群へ
     のポインタを保持しています。

 -- C のメンバ変数: *note lenfunc: 4945. *note PySequenceMethods:
          479f.sq_length

     This function is used by *note PySequence_Size(): 19bd. and *note
     PyObject_Size(): 48b9, and has the same signature.  It is also used
     for handling negative indices via the *note sq_item: 1897. and the
     *note sq_ass_item: 4cc7. slots.

 -- C のメンバ変数: *note binaryfunc: 4938. *note PySequenceMethods:
          479f.sq_concat

     この関数は *note PySequence_Concat(): 48bf. で利用され、同じシグネ
     チャを持っています。また、 ‘+’ 演算子でも、 *note nb_add: 4a3d. ス
     ロットによる数値加算を試した後に利用されます。

 -- C のメンバ変数: *note ssizeargfunc: 494f. *note PySequenceMethods:
          479f.sq_repeat

     この関数は *note PySequence_Repeat(): 48ca. で利用され、同じシグネ
     チャを持っています。また、 ‘*’ 演算でも、 *note nb_multiply: 4ca4.
     スロットによる数値乗算を試したあとに利用されます。

 -- C のメンバ変数: *note ssizeargfunc: 494f. *note PySequenceMethods:
          479f.sq_item

     This function is used by *note PySequence_GetItem(): 19be. and has
     the same signature.  It is also used by *note PyObject_GetItem():
     320, after trying the subscription via the *note mp_subscript:
     1898. slot.  This slot must be filled for the *note
     PySequence_Check(): 48be. function to return ‘1’, it can be ‘NULL’
     otherwise.

     Negative indexes are handled as follows: if the *note sq_length:
     4a45. slot is filled, it is called and the sequence length is used
     to compute a positive index which is passed to *note sq_item: 1897.
     If ‘sq_length’ is ‘NULL’, the index is passed as is to the
     function.

 -- C のメンバ変数: *note ssizeobjargproc: 4950. *note
          PySequenceMethods: 479f.sq_ass_item

     This function is used by *note PySequence_SetItem(): 19bf. and has
     the same signature.  It is also used by *note PyObject_SetItem():
     47da. and *note PyObject_DelItem(): 48ad, after trying the item
     assignment and deletion via the *note mp_ass_subscript: 4cc4. slot.
     This slot may be left to ‘NULL’ if the object does not support item
     assignment and deletion.

 -- C のメンバ変数: *note objobjproc: 4948. *note PySequenceMethods:
          479f.sq_contains

     この関数は *note PySequence_Contains(): 48c0. から利用され、同じシ
     グネチャを持っています。このスロットは ‘NULL’ の場合があり、その時
     ‘PySequence_Contains()’ はシンプルにマッチするオブジェクトを見つけ
     るまでシーケンスを巡回します。

 -- C のメンバ変数: *note binaryfunc: 4938. *note PySequenceMethods:
          479f.sq_inplace_concat

     This function is used by *note PySequence_InPlaceConcat(): 48c5.
     and has the same signature.  It should modify its first operand,
     and return it.  This slot may be left to ‘NULL’, in this case
     ‘PySequence_InPlaceConcat()’ will fall back to *note
     PySequence_Concat(): 48bf.  It is also used by the augmented
     assignment ‘+=’, after trying numeric in-place addition via the
     *note nb_inplace_add: 4ca1. slot.

 -- C のメンバ変数: *note ssizeargfunc: 494f. *note PySequenceMethods:
          479f.sq_inplace_repeat

     This function is used by *note PySequence_InPlaceRepeat(): 48c6.
     and has the same signature.  It should modify its first operand,
     and return it.  This slot may be left to ‘NULL’, in this case
     ‘PySequence_InPlaceRepeat()’ will fall back to *note
     PySequence_Repeat(): 48ca.  It is also used by the augmented
     assignment ‘*=’, after trying numeric in-place multiplication via
     the *note nb_inplace_multiply: 4ca5. slot.


File: python.info,  Node: バッファオブジェクト構造体 buffer object structure,  Next: async オブジェクト構造体,  Prev: シーケンスオブジェクト構造体,  Up: 型オブジェクト<3>

7.12.3.14 バッファオブジェクト構造体 (buffer object structure)
..............................................................

 -- C のデータ型: type PyBufferProcs

     この構造体は *note buffer プロトコル: 371. が要求する関数群へのポイ
     ンタを保持しています。 そのプロトコルは、エクスポーターオブジェクト
     が如何にして、その内部データをコンシューマオブジェクトに渡すかを定
     義します。

 -- C のメンバ変数: *note getbufferproc: 493e. *note PyBufferProcs:
          4a4c.bf_getbuffer

     この関数のシグネチャは以下の通りです:

          int (PyObject *exporter, Py_buffer *view, int flags);

     'flags' で指定された方法で 'view' を埋めてほしいという 'exporter' に
     対する要求を処理します。ステップ(3) を除いて、この関数の実装では以
     下のステップを行わなければなりません:

       1. Check if the request can be met.  If not, raise *note
          BufferError: 178f, set view->obj to ‘NULL’ and return ‘-1’.

       2. 要求されたフィールドを埋めます。

       3. エクスポートした回数を保持する内部カウンタをインクリメントしま
          す。

       4. view->obj に 'exporter' を設定し、 view->obj をインクリメント
          します。

       5. ‘0’ を返します。

     'exporter' がバッファプロバイダのチェインかツリーの一部であれば、２
     つの主要な方式が使用できます:

        * 再エクスポート: ツリーの各要素がエクスポートされるオブジェクト
          として振る舞い、自身への新しい参照を view->obj へセットします
          。

        * リダイレクト: バッファ要求がツリーのルートオブジェクトにリダイ
          レクトされます。ここでは、 view->obj はルートオブジェクトへの
          新しい参照になります。

     'view' の個別のフィールドは *note バッファ構造体: 4a09. の節で説明
     されており、エクスポートが特定の要求に対しどう対応しなければならな
     いかの規則は、 *note バッファ要求のタイプ: 1011. の節にあります。

     *note Py_buffer: 723. 構造体の中から参照している全てのメモリはエク
     スポータに属し、コンシューマがいなくなるまで有効でなくてはなりませ
     ん。 *note format: 4a13. 、 *note shape: 4a15. 、 *note strides:
     4a0d. 、 *note suboffsets: 4a17. 、 *note internal: 4a1a. はコンシ
     ューマからは読み出し専用です。

     *note PyBuffer_FillInfo(): 72b. は、全てのリクエストタイプを正しく
     扱う際に、単純なバイトバッファを公開する簡単な方法を提供します。

     *note PyObject_GetBuffer(): 373. は、この関数をラップするコンシュー
     マ向けのインターフェースです。

 -- C のメンバ変数: *note releasebufferproc: 4949. *note PyBufferProcs:
          4a4c.bf_releasebuffer

     この関数のシグネチャは以下の通りです:

          void (PyObject *exporter, Py_buffer *view);

     バッファのリソースを開放する要求を処理します。もし開放する必要のあ
     るリソースがない場合、 *note PyBufferProcs.bf_releasebuffer: 72e. は
     ‘NULL’ にしても構いません。そうでない場合は、この関数の標準的な実装
     は、以下の任意の処理手順 (optional step) を行います:

       1. エクスポートした回数を保持する内部カウンタをデクリメントします
          。

       2. カウンタが ‘0’ の場合は、'view' に関連付けられた全てのメモリを
          解放します。

     エクスポータは、バッファ固有のリソースを監視し続けるために *note
     internal: 4a1a. フィールドを使わなければなりません。このフィールド
     は、コンシューマが 'view' 引数としてオリジナルのバッファのコピーを
     渡しているであろう間、変わらないことが保証されています。

     この関数は、view->obj をデクリメントしてはいけません、なぜならそれ
     は *note PyBuffer_Release(): 374. で自動的に行われるからです(この方
     式は参照の循環を防ぐのに有用です)。

     *note PyBuffer_Release(): 374. は、この関数をラップするコンシューマ
     向けのインターフェースです。


File: python.info,  Node: async オブジェクト構造体,  Next: Slot Type typedefs,  Prev: バッファオブジェクト構造体 buffer object structure,  Up: 型オブジェクト<3>

7.12.3.15 async オブジェクト構造体
..................................

Added in version 3.5.

 -- C のデータ型: type PyAsyncMethods

     この構造体は *note awaitable: 192. オブジェクトと *note
     asynchronous iterator: 190. オブジェクトを実装するのに必要な関数へ
     のポインタを保持しています。

     以下は構造体の定義です:

          typedef struct {
              unaryfunc am_await;
              unaryfunc am_aiter;
              unaryfunc am_anext;
              sendfunc am_send;
          } PyAsyncMethods;

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyAsyncMethods:
          4a44.am_await

     この関数のシグネチャは以下の通りです:

          PyObject *am_await(PyObject *self);

     返されるオブジェクトは *note イテレータ: 191. でなければなりません
     。 つまりこのオブジェクトに対して *note PyIter_Check(): 185f. が
     ‘1’ を返さなければなりません。

     オブジェクトが *note awaitable: 192. でない場合、このスロットを
     ‘NULL’ に設定します。

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyAsyncMethods:
          4a44.am_aiter

     この関数のシグネチャは以下の通りです:

          PyObject *am_aiter(PyObject *self);

     Must return an *note asynchronous iterator: 190. object.  See *note
     __anext__(): 1e6a. for details.

     オブジェクトが非同期反復処理のプロトコルを実装していない場合、この
     スロットを ‘NULL’ に設定します。

 -- C のメンバ変数: *note unaryfunc: 4953. *note PyAsyncMethods:
          4a44.am_anext

     この関数のシグネチャは以下の通りです:

          PyObject *am_anext(PyObject *self);

     Must return an *note awaitable: 192. object.  See *note
     __anext__(): 1e6a. for details.  This slot may be set to ‘NULL’.

 -- C のメンバ変数: *note sendfunc: 4ca0. *note PyAsyncMethods:
          4a44.am_send

     この関数のシグネチャは以下の通りです:

          PySendResult am_send(PyObject *self, PyObject *arg, PyObject **result);

     See *note PyIter_Send(): 865. for details.  This slot may be set to
     ‘NULL’.

     Added in version 3.10.


File: python.info,  Node: Slot Type typedefs,  Next: 使用例<55>,  Prev: async オブジェクト構造体,  Up: 型オブジェクト<3>

7.12.3.16 Slot Type typedefs
............................

 -- C のデータ型: typedef *note PyObject: 312. *(*allocfunc)(*note
          PyTypeObject: a73. *cls, *note Py_ssize_t: a2e. nitems)
     ' 次に属します: *note Stable ABI: 51e.'  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 length for the instance, suitably aligned, and initialized
     to zeros, but with *note ob_refcnt: 86c. set to ‘1’ and *note
     ob_type: 4778. set to the type argument.  If the type's *note
     tp_itemsize: 1ed0. is non-zero, the object's *note ob_size: 4925.
     field should be initialized to 'nitems' and the length of the
     allocated memory block should be ‘tp_basicsize +
     nitems*tp_itemsize’, rounded up to a multiple of ‘sizeof(void*)’;
     otherwise, 'nitems' is not used and the length of the block should
     be *note tp_basicsize: 955.

     この関数では他のいかなるインスタンス初期化も行ってはなりません。追
     加のメモリ割り当てすらも行ってはなりません。そのような処理は *note
     tp_new: 54b. で行われるべきです。

 -- C のデータ型: typedef void (*destructor)(*note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef void (*freefunc)(void*)

     *note tp_free: 477b. を参照してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*newfunc)(*note
          PyObject: 312.*, *note PyObject: 312.*, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_new: 54b. を参照
     してください。

 -- C のデータ型: typedef int (*initproc)(*note PyObject: 312.*, *note
          PyObject: 312.*, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_init: 54d. を参照
     してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*reprfunc)(*note
          PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_repr: 478f. を参
     照してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*getattrfunc)(*note
          PyObject: 312. *self, char *attr)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクトの属性の値を返
     します。

 -- C のデータ型: typedef int (*setattrfunc)(*note PyObject: 312. *self,
          char *attr, *note PyObject: 312. *value)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクトの属性に値を設
     定します。属性を削除するには、 value (実) 引数に ‘NULL’ を設定しま
     す。

 -- C のデータ型: typedef *note PyObject: 312. *(*getattrofunc)(*note
          PyObject: 312. *self, *note PyObject: 312. *attr)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクトの属性の値を返
     します。

     *note tp_getattro: 1657. を参照してください。

 -- C のデータ型: typedef int (*setattrofunc)(*note PyObject: 312.
          *self, *note PyObject: 312. *attr, *note PyObject: 312.
          *value)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクトの属性に値を設
     定します。属性を削除するには、 value (実) 引数に ‘NULL’ を設定しま
     す。

     *note tp_setattro: 4793. を参照してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*descrgetfunc)(*note
          PyObject: 312.*, *note PyObject: 312.*, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_descr_get: 4c95.
     を参照してください。

 -- C のデータ型: typedef int (*descrsetfunc)(*note PyObject: 312.*,
          *note PyObject: 312.*, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_descr_set: 1861.
     を参照してください。

 -- C のデータ型: typedef *note Py_hash_t: 1235. (*hashfunc)(*note
          PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_hash: 47a1. を参
     照してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*richcmpfunc)(*note
          PyObject: 312.*, *note PyObject: 312.*, int)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_richcompare:
     479b. を参照してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*getiterfunc)(*note
          PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_iter: 1497. を参
     照してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*iternextfunc)(*note
          PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_iternext: 1498. を
     参照してください。

 -- C のデータ型: typedef *note Py_ssize_t: a2e. (*lenfunc)(*note
          PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef int (*getbufferproc)(*note PyObject: 312.*,
          *note Py_buffer: 723.*, int)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'

 -- C のデータ型: typedef void (*releasebufferproc)(*note PyObject:
          312.*, *note Py_buffer: 723.*)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.12 より).'

 -- C のデータ型: typedef *note PyObject: 312. *(*unaryfunc)(*note
          PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef *note PyObject: 312. *(*binaryfunc)(*note
          PyObject: 312.*, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef *note PySendResult: 4a06. (*sendfunc)(*note
          PyObject: 312.*, *note PyObject: 312.*, *note PyObject:
          312.**)

     *note am_send: 4c9f. を参照してください。

 -- C のデータ型: typedef *note PyObject: 312. *(*ternaryfunc)(*note
          PyObject: 312.*, *note PyObject: 312.*, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef *note PyObject: 312. *(*ssizeargfunc)(*note
          PyObject: 312.*, *note Py_ssize_t: a2e.)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef int (*ssizeobjargproc)(*note PyObject: 312.*,
          *note Py_ssize_t: a2e, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef int (*objobjproc)(*note PyObject: 312.*, *note
          PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'

 -- C のデータ型: typedef int (*objobjargproc)(*note PyObject: 312.*,
          *note PyObject: 312.*, *note PyObject: 312.*)
     ' 次に属します: *note Stable ABI: 51e.'


File: python.info,  Node: 使用例<55>,  Prev: Slot Type typedefs,  Up: 型オブジェクト<3>

7.12.3.17 使用例
................

ここでは Python の型定義の簡単な例をいくつか挙げます。これらの例にはあな
たが遭遇する共通的な利用例を含んでいます。いくつかの例ではトリッキーなコ
ーナーケースを実演しています。より多くの例や実践的な情報、チュートリアル
が必要なら、*note 拡張の型の定義; チュートリアル: 4771. や *note
拡張の型の定義; 雑多なトピック: 478a. を参照してください。

A basic *note static type: 74a.:

     typedef struct {
         PyObject_HEAD
         const char *data;
     } MyObject;

     static PyTypeObject MyObject_Type = {
         PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "mymod.MyObject",
         .tp_basicsize = sizeof(MyObject),
         .tp_doc = PyDoc_STR("My objects"),
         .tp_new = myobj_new,
         .tp_dealloc = (destructor)myobj_dealloc,
         .tp_repr = (reprfunc)myobj_repr,
     };

より冗長な初期化子を用いた古いコードを（特にCPythonのコードベース中で）
見かけることがあるかもしれません:

     static PyTypeObject MyObject_Type = {
         PyVarObject_HEAD_INIT(NULL, 0)
         "mymod.MyObject",               /* tp_name */
         sizeof(MyObject),               /* tp_basicsize */
         0,                              /* tp_itemsize */
         (destructor)myobj_dealloc,      /* tp_dealloc */
         0,                              /* tp_vectorcall_offset */
         0,                              /* tp_getattr */
         0,                              /* tp_setattr */
         0,                              /* tp_as_async */
         (reprfunc)myobj_repr,           /* tp_repr */
         0,                              /* tp_as_number */
         0,                              /* tp_as_sequence */
         0,                              /* tp_as_mapping */
         0,                              /* tp_hash */
         0,                              /* tp_call */
         0,                              /* tp_str */
         0,                              /* tp_getattro */
         0,                              /* tp_setattro */
         0,                              /* tp_as_buffer */
         0,                              /* tp_flags */
         PyDoc_STR("My objects"),        /* tp_doc */
         0,                              /* tp_traverse */
         0,                              /* tp_clear */
         0,                              /* tp_richcompare */
         0,                              /* tp_weaklistoffset */
         0,                              /* tp_iter */
         0,                              /* tp_iternext */
         0,                              /* tp_methods */
         0,                              /* tp_members */
         0,                              /* tp_getset */
         0,                              /* tp_base */
         0,                              /* tp_dict */
         0,                              /* tp_descr_get */
         0,                              /* tp_descr_set */
         0,                              /* tp_dictoffset */
         0,                              /* tp_init */
         0,                              /* tp_alloc */
         myobj_new,                      /* tp_new */
     };

弱参照やインスタンス辞書、ハッシュをサポートする型:

     typedef struct {
         PyObject_HEAD
         const char *data;
     } MyObject;

     static PyTypeObject MyObject_Type = {
         PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "mymod.MyObject",
         .tp_basicsize = sizeof(MyObject),
         .tp_doc = PyDoc_STR("My objects"),
         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
              Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_MANAGED_DICT |
              Py_TPFLAGS_MANAGED_WEAKREF,
         .tp_new = myobj_new,
         .tp_traverse = (traverseproc)myobj_traverse,
         .tp_clear = (inquiry)myobj_clear,
         .tp_alloc = PyType_GenericNew,
         .tp_dealloc = (destructor)myobj_dealloc,
         .tp_repr = (reprfunc)myobj_repr,
         .tp_hash = (hashfunc)myobj_hash,
         .tp_richcompare = PyBaseObject_Type.tp_richcompare,
     };

A str subclass that cannot be subclassed and cannot be called to create
instances (e.g.  uses a separate factory func) using *note
Py_TPFLAGS_DISALLOW_INSTANTIATION: 54e. flag:

     typedef struct {
         PyUnicodeObject raw;
         char *extra;
     } MyStr;

     static PyTypeObject MyStr_Type = {
         PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "mymod.MyStr",
         .tp_basicsize = sizeof(MyStr),
         .tp_base = NULL,  // set to &PyUnicode_Type in module init
         .tp_doc = PyDoc_STR("my custom str"),
         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_DISALLOW_INSTANTIATION,
         .tp_repr = (reprfunc)myobj_repr,
     };

The simplest *note static type: 74a. with fixed-length instances:

     typedef struct {
         PyObject_HEAD
     } MyObject;

     static PyTypeObject MyObject_Type = {
         PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "mymod.MyObject",
     };

The simplest *note static type: 74a. with variable-length instances:

     typedef struct {
         PyObject_VAR_HEAD
         const char *data[1];
     } MyObject;

     static PyTypeObject MyObject_Type = {
         PyVarObject_HEAD_INIT(NULL, 0)
         .tp_name = "mymod.MyObject",
         .tp_basicsize = sizeof(MyObject) - sizeof(char *),
         .tp_itemsize = sizeof(char *),
     };


File: python.info,  Node: 循環参照ガベージコレクションをサポートする,  Prev: 型オブジェクト<3>,  Up: オブジェクト実装サポート object implementation support

7.12.4 循環参照ガベージコレクションをサポートする
-------------------------------------------------

Python が循環参照を含むガベージの検出とコレクションをサポートするには、
他のオブジェクトに対する "コンテナ" (他のオブジェクトには他のコンテナも
含みます) となるオブジェクト型によるサポートが必要です。他のオブジェクト
に対する参照を記憶しないオブジェクトや、(数値や文字列のような) アトム型
(atomic type) への参照だけを記憶するような型では、ガベージコレクションに
際して特別これといったサポートを提供する必要はありません。

To create a container type, the *note tp_flags: 1828. field of the type
object must include the *note Py_TPFLAGS_HAVE_GC: 748. and provide an
implementation of the *note tp_traverse: 749. handler.  If instances of
the type are mutable, a *note tp_clear: 478d. implementation must also
be provided.

*note Py_TPFLAGS_HAVE_GC: 748.

     このフラグをセットした型のオブジェクトは、この節に述べた規則に適合
     しなければなりません。簡単のため、このフラグをセットした型のオブジ
     ェクトをコンテナオブジェクトと呼びます。

コンテナ型のコンストラクタは以下の二つの規則に適合しなければなりません:

  1. The memory for the object must be allocated using *note
     PyObject_GC_New: a70. or *note PyObject_GC_NewVar: a71.

  2. 他のコンテナへの参照が入るかもしれないフィールドが全て初期化された
     ら、すぐに *note PyObject_GC_Track(): 14af. を呼び出さなければなり
     ません。

同様に、オブジェクトのメモリ解放関数も以下の二つの規則に適合しなければな
りません:

  1. 他のコンテナを参照しているフィールドを無効化する前に、 *note
     PyObject_GC_UnTrack(): 14b0. を呼び出さなければなりません。

  2. オブジェクトのメモリは *note PyObject_GC_Del(): 14ae. で解放しなけ
     ればなりません。

          警告: If a type adds the Py_TPFLAGS_HAVE_GC, then it 'must'
          implement at least a *note tp_traverse: 749. handler or
          explicitly use one from its subclass or subclasses.

          When calling *note PyType_Ready(): 747. or some of the APIs
          that indirectly call it like *note PyType_FromSpecWithBases():
          54a. or *note PyType_FromSpec(): 549. the interpreter will
          automatically populate the *note tp_flags: 1828, *note
          tp_traverse: 749. and *note tp_clear: 478d. fields if the type
          inherits from a class that implements the garbage collector
          protocol and the child class does 'not' include the *note
          Py_TPFLAGS_HAVE_GC: 748. flag.

 -- C のマクロ: PyObject_GC_New (TYPE, typeobj)

     Analogous to *note PyObject_New: 953. but for container objects
     with the *note Py_TPFLAGS_HAVE_GC: 748. flag set.

 -- C のマクロ: PyObject_GC_NewVar (TYPE, typeobj, size)

     Analogous to *note PyObject_NewVar: 954. but for container objects
     with the *note Py_TPFLAGS_HAVE_GC: 748. flag set.

 -- C の関数: *note PyObject: 312.
          *PyUnstable_Object_GC_NewWithExtraData (PyTypeObject *type,
          size_t extra_size)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Analogous to *note PyObject_GC_New: a70. but allocates 'extra_size'
     bytes at the end of the object (at offset *note tp_basicsize:
     955.).  The allocated memory is initialized to zeros, except for
     the *note Python object header: 312.

     The extra data will be deallocated with the object, but otherwise
     it is not managed by Python.

          警告: 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 *note PyVarObject: 3fe2. and *note tp_itemsize:
          1ed0. instead.

     Added in version 3.12.

 -- C のマクロ: PyObject_GC_Resize (TYPE, op, newsize)

     Resize an object allocated by *note PyObject_NewVar: 954.  Returns
     the resized object of type ‘TYPE*’ (refers to any C type) or ‘NULL’
     on failure.

     'op' must be of type *note PyVarObject: 3fe2.* and must not be
     tracked by the collector yet.  'newsize' must be of type *note
     Py_ssize_t: a2e.

 -- C の関数: void PyObject_GC_Track (PyObject *op)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'op' を、コレ
     クタによって追跡されるオブジェクトの集合に追加します。コレクタは何
     回動くのかは予想できないので、追跡されている間はオブジェクトは正し
     い状態でいなければなりません。 *note tp_traverse: 749. の対象となる
     全てのフィールドが正しい状態になってすぐに、たいていはコンストラク
     タの末尾付近で、呼び出すべきです。

 -- C の関数: int PyObject_IS_GC (PyObject *obj)

     Returns non-zero if the object implements the garbage collector
     protocol, otherwise returns 0.

     The object cannot be tracked by the garbage collector if this
     function returns 0.

 -- C の関数: int PyObject_GC_IsTracked (PyObject *op)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.9 より).'
     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.

     This is analogous to the Python function *note gc.is_tracked():
     12dd.

     Added in version 3.9.

 -- C の関数: int PyObject_GC_IsFinalized (PyObject *op)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.9 より).'
     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.

     This is analogous to the Python function *note gc.is_finalized():
     8cb.

     Added in version 3.9.

 -- C の関数: void PyObject_GC_Del (void *op)
     ' 次に属します: *note Stable ABI: 51e.'  Releases memory allocated
     to an object using *note PyObject_GC_New: a70. or *note
     PyObject_GC_NewVar: a71.

 -- C の関数: void PyObject_GC_UnTrack (void *op)
     ' 次に属します: *note Stable ABI: 51e.'  オブジェクト 'op' を、コレ
     クタによって追跡されるオブジェクトの集合から除去します。このオブジ
     ェクトに対して *note PyObject_GC_Track(): 14af. を再度呼び出して、
     追跡されるオブジェクトの集合に戻すことも可能です。 *note
     tp_traverse: 749. ハンドラの対象となるフィールドが正しくない状態に
     なる前に、デアロケータ (*note tp_dealloc: 477a. ハンドラ) はオブジ
     ェクトに対して、この関数を呼び出すべきです。

バージョン 3.8 で変更: The ‘_PyObject_GC_TRACK()’ and
‘_PyObject_GC_UNTRACK()’ macros have been removed from the public C API.

*note tp_traverse: 749. ハンドラはこの型の関数パラメータを受け取ります:

 -- C のデータ型: typedef int (*visitproc)(*note PyObject: 312. *object,
          void *arg)
     ' 次に属します: *note Stable ABI: 51e.'  *note tp_traverse: 749. ハ
     ンドラに渡されるビジター関数 (visitor function) の型です。この関数
     は、探索するオブジェクトを 'object' として、 *note tp_traverse:
     749. ハンドラの第 3 引数を 'arg' として呼び出します。 Python のコア
     はいくつかのビジター関数を使って、ゴミとなった循環参照を検出する仕
     組みを実装します; ユーザが自身のためにビジター関数を書く必要が出て
     くることはないでしょう。

*note tp_traverse: 749. ハンドラは次の型を持っていなければなりません:

 -- C のデータ型: typedef int (*traverseproc)(*note PyObject: 312.
          *self, *note visitproc: 4954. visit, void *arg)
     ' 次に属します: *note Stable ABI: 51e.'  コンテナオブジェクトのため
     のトラバーサル関数 (traversal function) です。 実装では、'self' に
     直接入っている各オブジェクトに対して 'visit' 関数を呼び出さなければ
     なりません。 このとき、'visit' へのパラメタはコンテナに入っている各
     オブジェクトと、このハンドラに渡された 'arg' の値です。 'visit' 関
     数は ‘NULL’ オブジェクトを引数に渡して呼び出してはなりません。
     'visit' が非ゼロの値を返す場合、エラーが発生し、戻り値をそのまま返
     すようにしなければなりません。

*note tp_traverse: 749. ハンドラを簡潔に書くために、 *note Py_VISIT():
4784. マクロが提供されています。このマクロを使うためには、 *note
tp_traverse: 749. の実装関数の引数は、一文字も違わず 'visit' と 'arg' で
なければなりません:

 -- C の関数: void Py_VISIT (PyObject *o)

     'o' が ‘NULL’ でなければ、 'o' と 'arg' を引数にして 'visit' コール
     バックを呼び出します。 'visit' がゼロでない値を返した場合、その値を
     返します。 このマクロを使うと、 *note tp_traverse: 749. ハンドラは
     次のようになります:

          static int
          my_traverse(Noddy *self, visitproc visit, void *arg)
          {
              Py_VISIT(self->foo);
              Py_VISIT(self->bar);
              return 0;
          }

*note tp_clear: 478d. ハンドラは *note inquiry: 4943. 型であるか、オブジ
ェクトが不変 (immutable) な場合は ‘NULL’ でなければなりません。

 -- C のデータ型: typedef int (*inquiry)(*note PyObject: 312. *self)
     ' 次に属します: *note Stable ABI: 51e.'  循環参照を形成しているとお
     ぼしき参照群を放棄します。変更不可能なオブジェクトは循環参照を直接
     形成することが決してないので、この関数を定義する必要はありません。
     このメソッドを呼び出した後でもオブジェクトは有効なままでなければな
     らないので注意してください (参照に対して *note Py_DECREF(): 53b. を
     呼ぶだけにしないでください)。ガベージコレクタは、オブジェクトが循環
     参照を形成していることを検出した際にこのメソッドを呼び出します。

* Menu:

* Controlling the Garbage Collector State::
* Querying Garbage Collector State::


File: python.info,  Node: Controlling the Garbage Collector State,  Next: Querying Garbage Collector State,  Up: 循環参照ガベージコレクションをサポートする

7.12.4.1 Controlling the Garbage Collector State
................................................

The C-API provides the following functions for controlling garbage
collection runs.

 -- C の関数: *note Py_ssize_t: a2e. PyGC_Collect (void)
     ' 次に属します: *note Stable ABI: 51e.'  Perform a full garbage
     collection, if the garbage collector is enabled.  (Note that *note
     gc.collect(): a08. runs it unconditionally.)

     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 *note sys.unraisablehook: 1d8.  This
     function does not raise exceptions.

 -- C の関数: int PyGC_Enable (void)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Enable the garbage collector: similar to *note gc.enable(): 42d3.
     Returns the previous state, 0 for disabled and 1 for enabled.

     Added in version 3.10.

 -- C の関数: int PyGC_Disable (void)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Disable the garbage collector: similar to *note gc.disable(): 42d4.
     Returns the previous state, 0 for disabled and 1 for enabled.

     Added in version 3.10.

 -- C の関数: int PyGC_IsEnabled (void)
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.10 より).'
     Query the state of the garbage collector: similar to *note
     gc.isenabled(): 42d5.  Returns the current state, 0 for disabled
     and 1 for enabled.

     Added in version 3.10.


File: python.info,  Node: Querying Garbage Collector State,  Prev: Controlling the Garbage Collector State,  Up: 循環参照ガベージコレクションをサポートする

7.12.4.2 Querying Garbage Collector State
.........................................

The C-API provides the following interface for querying information
about the garbage collector.

 -- C の関数: void PyUnstable_GC_VisitObjects (gcvisitobjects_t
          callback, void *arg)

          これは Unstable APIです。マイナーリリースで予告なく変更されることがあります。 'これは *note Unstable API: 512.です。マイナーリリースで予告なく変更されることがあります。': 
     Run supplied 'callback' on all live GC-capable objects.  'arg' is
     passed through to all invocations of 'callback'.

          警告: If new objects are (de)allocated by the callback it is
          undefined if they will be visited.

          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.

     Added in version 3.12.

 -- C のデータ型: typedef int (*gcvisitobjects_t)(*note PyObject: 312.
          *object, void *arg)

     Type of the visitor function to be passed to *note
     PyUnstable_GC_VisitObjects(): 4cee.  'arg' is the same as the 'arg'
     passed to ‘PyUnstable_GC_VisitObjects’.  Return ‘0’ to continue
     iteration, return ‘1’ to stop iteration.  Other return values are
     reserved for now so behavior on returning anything else is
     undefined.

     Added in version 3.12.


File: python.info,  Node: API と ABI のバージョニング,  Next: Monitoring C API,  Prev: オブジェクト実装サポート object implementation support,  Up: Python/C API リファレンスマニュアル

7.13 API と ABI のバージョニング
================================

CPython は以下のマクロでバージョン番号を公開しています。これらはコードが
'ビルドされた' バージョンに対応しており、必ずしも '実行時' に使われるバ
ージョンではないことに注意してください。

バージョン間の API と ABI の安定性については *note C API の安定性: 51e.
を参照してください。

 -- C のマクロ: PY_MAJOR_VERSION

     ‘3.4.1a2’ の ‘3’ 。

 -- C のマクロ: PY_MINOR_VERSION

     ‘3.4.1a2’ の ‘4’ 。

 -- C のマクロ: PY_MICRO_VERSION

     ‘3.4.1a2’ の ‘1’ 。

 -- C のマクロ: PY_RELEASE_LEVEL

     ‘3.4.1a2’ の ‘a’ 。アルファでは ‘0xA’ 、ベータでは ‘0xB’ 、リリース
     候補では ‘0xC’ 、最終版では ‘0xF’ となります。

 -- C のマクロ: PY_RELEASE_SERIAL

     ‘3.4.1a2’ の ‘2’ 。最終リリースでは 0 になります。

 -- C のマクロ: PY_VERSION_HEX

     Python のバージョン番号を単一の整数に符号化したものです。

     下記のように32ビットの値として扱うことで、バージョン情報を得ること
     ができます:

     bytes       ビット (ビッグエンディアン    意味                          ‘3.4.1a2’ の値
                 オーダ)                                                     
                 
     -------------------------------------------------------------------------------------------------------
                                                                             
     1           1-8                           ‘PY_MAJOR_VERSION’            ‘0x03’
                                                                             
                                                                             
     2           9-16                          ‘PY_MINOR_VERSION’            ‘0x04’
                                                                             
                                                                             
     3           17-24                         ‘PY_MICRO_VERSION’            ‘0x01’
                                                                             
                                                                             
     4           25-28                         ‘PY_RELEASE_LEVEL’            ‘0xA’
                                                                             
                                               
     29-32       ‘PY_RELEASE_SERIAL’           ‘0x2’
                                               

     したがって、 ‘3.4.1a2’ は16進数で ‘0x030401a2’ であり、 ‘3.10.0’ は
     16進数で ‘0x030a00f0’ です。

     これを数値比較に使用します。例えば、 ‘#if PY_VERSION_HEX >= ...’ 。

     このバージョンはシンボル *note Py_Version: 721. からも入手できます
     。

 -- C 変数: const unsigned long Py_Version
     ' 次に属します: *note Stable ABI: 51e. (バージョン 3.11 より).'
     *note PY_VERSION_HEX: 722. マクロと同じ書式で、単一の定数整数でエン
     コードされた Python の実行時のバージョン番号です。これは実行時に使
     用される Python のバージョンを含んでいます。

     Added in version 3.11.

これらのマクロは Include/patchlevel.h(1) で定義されています。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Include/patchlevel.h


File: python.info,  Node: Monitoring C API,  Next: Generating Execution Events,  Prev: API と ABI のバージョニング,  Up: Python/C API リファレンスマニュアル

7.14 Monitoring C API
=====================

Added in version 3.13.

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 *note sys.monitoring: c4.


File: python.info,  Node: Generating Execution Events,  Prev: Monitoring C API,  Up: Python/C API リファレンスマニュアル

7.15 Generating Execution Events
================================

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 accepts a ‘PyMonitoringState’ struct which contains concise
information about the activation state of events, as well as the event
arguments, which include a ‘PyObject*’ representing the code object, the
instruction offset and sometimes additional, event-specific arguments
(see *note sys.monitoring: c4. for details about the signatures of the
different event callbacks).  The ‘codelike’ argument should be an
instance of *note types.CodeType: 2c0. or of a type that emulates it.

The VM disables tracing when firing an event, so there is no need for
user code to do that.

Monitoring functions should not be called with an exception set, except
those listed below as working with the current exception.

 -- C のデータ型: type PyMonitoringState

     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.

All of the functions below return 0 on success and -1 (with an exception
set) on error.

See *note sys.monitoring: c4. for descriptions of the events.

 -- C の関数: int PyMonitoring_FirePyStartEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset)

     Fire a ‘PY_START’ event.

 -- C の関数: int PyMonitoring_FirePyResumeEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset)

     Fire a ‘PY_RESUME’ event.

 -- C の関数: int PyMonitoring_FirePyReturnEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset, PyObject *retval)

     Fire a ‘PY_RETURN’ event.

 -- C の関数: int PyMonitoring_FirePyYieldEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset, PyObject *retval)

     Fire a ‘PY_YIELD’ event.

 -- C の関数: int PyMonitoring_FireCallEvent (PyMonitoringState *state,
          PyObject *codelike, int32_t offset, PyObject *callable,
          PyObject *arg0)

     Fire a ‘CALL’ event.

 -- C の関数: int PyMonitoring_FireLineEvent (PyMonitoringState *state,
          PyObject *codelike, int32_t offset, int lineno)

     Fire a ‘LINE’ event.

 -- C の関数: int PyMonitoring_FireJumpEvent (PyMonitoringState *state,
          PyObject *codelike, int32_t offset, PyObject *target_offset)

     Fire a ‘JUMP’ event.

 -- C の関数: int PyMonitoring_FireBranchEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset, PyObject
          *target_offset)

     Fire a ‘BRANCH’ event.

 -- C の関数: int PyMonitoring_FireCReturnEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset, PyObject *retval)

     Fire a ‘C_RETURN’ event.

 -- C の関数: int PyMonitoring_FirePyThrowEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset)

     Fire a ‘PY_THROW’ event with the current exception (as returned by
     *note PyErr_GetRaisedException(): 3cd.).

 -- C の関数: int PyMonitoring_FireRaiseEvent (PyMonitoringState *state,
          PyObject *codelike, int32_t offset)

     Fire a ‘RAISE’ event with the current exception (as returned by
     *note PyErr_GetRaisedException(): 3cd.).

 -- C の関数: int PyMonitoring_FireCRaiseEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset)

     Fire a ‘C_RAISE’ event with the current exception (as returned by
     *note PyErr_GetRaisedException(): 3cd.).

 -- C の関数: int PyMonitoring_FireReraiseEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset)

     Fire a ‘RERAISE’ event with the current exception (as returned by
     *note PyErr_GetRaisedException(): 3cd.).

 -- C の関数: int PyMonitoring_FireExceptionHandledEvent
          (PyMonitoringState *state, PyObject *codelike, int32_t offset)

     Fire an ‘EXCEPTION_HANDLED’ event with the current exception (as
     returned by *note PyErr_GetRaisedException(): 3cd.).

 -- C の関数: int PyMonitoring_FirePyUnwindEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset)

     Fire a ‘PY_UNWIND’ event with the current exception (as returned by
     *note PyErr_GetRaisedException(): 3cd.).

 -- C の関数: int PyMonitoring_FireStopIterationEvent (PyMonitoringState
          *state, PyObject *codelike, int32_t offset, PyObject *value)

     Fire a ‘STOP_ITERATION’ event.  If ‘value’ is an instance of *note
     StopIteration: bc8, it is used.  Otherwise, a new *note
     StopIteration: bc8. instance is created with ‘value’ as its
     argument.

* Menu:

* Managing the Monitoring State::


File: python.info,  Node: Managing the Monitoring State,  Up: Generating Execution Events

7.15.1 Managing the Monitoring State
------------------------------------

Monitoring states can be managed with the help of monitoring scopes.  A
scope would typically correspond to a python function.

 -- C の関数: int PyMonitoring_EnterScope (PyMonitoringState
          *state_array, uint64_t *version, const uint8_t *event_types,
          Py_ssize_t length)

     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 ‘PY_START’ event is the value
     ‘PY_MONITORING_EVENT_PY_START’, which is numerically equal to the
     base-2 logarithm of ‘sys.monitoring.events.PY_START’.
     ‘state_array’ is an array with a monitoring state entry for each
     event in ‘event_types’, it is allocated by the user but populated
     by ‘PyMonitoring_EnterScope()’ with information about the
     activation state of the event.  The size of ‘event_types’ (and
     hence also of ‘state_array’) is given in ‘length’.

     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 only by ‘PyMonitoring_EnterScope()’ itself.  It
     allows this function to determine whether event states have changed
     since the previous call, and to return quickly if they have not.

     The scopes referred to here are lexical scopes: a function, class
     or method.  ‘PyMonitoring_EnterScope()’ should be called whenever
     the lexical scope is entered.  Scopes can be reentered, reusing the
     same 'state_array' and 'version', in situations like when emulating
     a recursive 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.

     The macros for 'event_types' are:

     Macro                                                  Event
                                                            
     -------------------------------------------------------------------------------------------------
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_BRANCH             *note BRANCH: 4218.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_CALL               *note CALL: 15aa.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_C_RAISE            *note C_RAISE: 4219.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_C_RETURN           *note C_RETURN: 421a.
                                                            
                                                            
      -- C のマクロ:                                        *note EXCEPTION_HANDLED: 421b.
               PY_MONITORING_EVENT_EXCEPTION_HANDLED        

      -- C のマクロ: PY_MONITORING_EVENT_INSTRUCTION        *note INSTRUCTION: 421c.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_JUMP               *note JUMP: 421d.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_LINE               *note LINE: 421e.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_PY_RESUME          *note PY_RESUME: 421f.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_PY_RETURN          *note PY_RETURN: 4220.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_PY_START           *note PY_START: 4221.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_PY_THROW           *note PY_THROW: 4222.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_PY_UNWIND          *note PY_UNWIND: 4223.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_PY_YIELD           *note PY_YIELD: 4224.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_RAISE              *note RAISE: 1552.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_RERAISE            *note RERAISE: 4226.
                                                            
                                                            
      -- C のマクロ: PY_MONITORING_EVENT_STOP_ITERATION     *note STOP_ITERATION: 4225.
                                                            

 -- C の関数: int PyMonitoring_ExitScope (void)

     Exit the last scope that was entered with
     ‘PyMonitoring_EnterScope()’.


File: python.info,  Node: Python モジュールのインストール,  Next: Python HOWTO,  Prev: Python/C API リファレンスマニュアル,  Up: Top

8 Python モジュールのインストール
*********************************


Email: <distutils-sig@python.org>

人気のあるオープンソース開発プロジェクトがそうであるように、Python には
貢献者たちとユーザたちの活発なサポートコミュニティがあり、またこれらはほ
かの Python 開発者たちに、彼らのソフトウェアのオープンソースライセンスの
もとでの利用も可能にしてくれています。

これはほかの人が既に挙げた共通の(あるいは時折極めて稀有な!)問題や、彼ら
自身の解法による潜在的な貢献が共通の場所に蓄えられることによる恩恵によっ
て、Python ユーザに共有と協調を効果的に行なうことの助けとなっています。

このガイドはこれらプロセスのうち、インストールについてをカバーします。あ
なた自身の Python プロジェクトを作成し、共有するためのガイドについては
Python packaging user guide(1) を参照してください。

     注釈: あなたが企業や組織のユーザであれば、多くの組織がオープンソー
     スソフトウェアの利用と貢献に関する彼ら独自のポリシーを持っているこ
     とに気をつけてください。Python によって提供される配布とインストール
     のツールを利用する際には、そのようなポリシーを考慮に入れてください
     。

* Menu:

* 重要用語集::
* 基本的な使い方: 基本的な使い方<3>.
* どうすればいいの...？: どうすればいいの ？.
* よくあるインストールに関する問題::

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/tutorials/packaging-projects/


File: python.info,  Node: 重要用語集,  Next: 基本的な使い方<3>,  Up: Python モジュールのインストール

8.1 重要用語集
==============

   * ‘pip’ は推奨されるインストーラ・プログラムです。 Python 3.4 からは
     、 Python バイナリ・インストーラに最初から付属するようになりました
     。

   * '仮想環境' は、システム全体にインストールするのではなく、特定のアプ
     リケーションで使用するためにパッケージをインストールできるようにす
     る半独立型のPython環境です。

   * ‘venv’ は仮想環境をつくるための標準ツールです。 Python 3.3 から
     Python の一部になりました。 Python 3.4 以降では、仮想環境をつくる際
     はそのすべてで ‘pip’ をインストールするように、あらかじめ設定されて
     います。

   * ‘virtualenv’ は ‘venv’ のサードパーティの代替案 (で前身) です。
     ‘virtualenv’ により仮想環境を Python 3.4 より前のバージョンで使うこ
     とが出来ます。 以前のバージョンは ‘venv’ を提供していませんし、作成
     された環境に ‘pip’ を自動的にインストールすることも出来ません。

   * Python Package Index(1) は Python パッケージのパブリック・リポジト
     リです。このリポジトリのパッケージは、他の Python ユーザが利用でき
     るように、オープンソースでライセンスされています。

   * Python Packaging Authority(2) は、標準のパッケージングツール、関連
     するメタデータとファイルフォーマット標準の保守と発展を担っている、
     開発者・ドキュメントの著者のグループです。彼らは様々なツールやドキ
     ュメント、issue tracker を GitHub(3) で管理しています。

   * ‘distutils’ はオリジナルのビルド・配布システムで、 Python 標準ライ
     ブラリに 1998 年に最初に追加されました。 ‘distutils’ の直接的な利用
     は段階的に取り払われていきますが、それは今でも現時点でのパッケージ
     ングと配布のインフラストラクチャの基礎として鎮座していて、標準ライ
     ブラリの一部として残っているだけでなく、その名前はほかの文脈でも生
     き続けています(Python のパッケージング標準の開発をまとめるのに使わ
     れているメーリングリストの名前のように)。

バージョン 3.5 で変更: 仮想環境の作成には、 ‘venv’ の使用をお勧めします
。

参考
....

Python Packaging User Guide: Creating and using virtual environments(4)

   ---------- Footnotes ----------

   (1) https://pypi.org

   (2) https://www.pypa.io/

   (3) https://github.com/pypa

   (4) 
https://packaging.python.org/installing/#creating-virtual-environments


File: python.info,  Node: 基本的な使い方<3>,  Next: どうすればいいの ？,  Prev: 重要用語集,  Up: Python モジュールのインストール

8.2 基本的な使い方
==================

パッケージングのための標準ツールはすべてコマンドラインから使われることを
想定しています。

以下のコマンドは、モジュールの最新バージョンとそれが依存するモジュールを
、 Python Package Index からインストールします。

     python -m pip install SomePackage

     注釈: POSIX ユーザ(macOS と Linux ユーザを含みます)向けには、このガ
     イド内の例は、 *note virtual environment: 1c6c. の利用を前提にして
     います。

     Windows ユーザ向けには、このガイド内の例は、Python インストール時に
     システムの PATH 環境変数が調整されていることを前提にしています。

正確なバージョンや最小のバージョンをコマンドライン上で直接指定することも
できます。‘>’ や ‘<’ などの比較演算子など、シェルが解釈する特殊文字を使
う場合、パッケージ名とバージョンを二重引用符で囲んでください:

     python -m pip install SomePackage==1.0.4    # specific version
     python -m pip install "SomePackage>=1.0.4"  # minimum version

通常、適合するモジュールがインストール済である場合にそれを再度 install 実
行を試みても効果はありません。既に存在しているモジュールのアップグレード
には、明示的にそれを要求しなければなりません:

     python -m pip install --upgrade SomePackage

‘pip’ とその機能についての詳しい情報とリソースは Python Packaging User
Guide(1) にあります。

仮想環境の作成は *note venv: f9. モジュールを通して行われます。 有効な仮
想環境にインストールするには 上記のコマンドを使います。

参考
....

Python Packaging User Guide: Installing Python Distribution Packages(2)

   ---------- Footnotes ----------

   (1) https://packaging.python.org

   (2) https://packaging.python.org/installing/


File: python.info,  Node: どうすればいいの ？,  Next: よくあるインストールに関する問題,  Prev: 基本的な使い方<3>,  Up: Python モジュールのインストール

8.3 どうすればいいの...？
=========================

以下はよくある課題への簡単な回答もしくは回答へのリンクです。

* Menu:

* ... pip を 3.4 より前のバージョンの Python でインストールするには？: pip を 3 4 より前のバージョンの Python でインストールするには？.
* ... パッケージを現在のユーザ用のみにインストールするには？: パッケージを現在のユーザ用のみにインストールするには？.
* ... 科学技術計算用の Python パッケージをインストールするには？: 科学技術計算用の Python パッケージをインストールするには？.
* ... インストールされた複数のバージョンの Python を並行して使うには？: インストールされた複数のバージョンの Python を並行して使うには？.


File: python.info,  Node: pip を 3 4 より前のバージョンの Python でインストールするには？,  Next: パッケージを現在のユーザ用のみにインストールするには？,  Up: どうすればいいの ？

8.3.1 ... pip を 3.4 より前のバージョンの Python でインストールするには？
-------------------------------------------------------------------------

‘pip’ が Python に付属するのは 3.4 以降です。それ以前のバージョンでは、
"Python Packaging User Guide" の記載にしたがって ‘pip’ 自体をインストー
ルする必要があります。

参考
....

Python Packaging User Guide: Requirements for Installing Packages(1)

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/installing/#requirements-for-installing-packages


File: python.info,  Node: パッケージを現在のユーザ用のみにインストールするには？,  Next: 科学技術計算用の Python パッケージをインストールするには？,  Prev: pip を 3 4 より前のバージョンの Python でインストールするには？,  Up: どうすればいいの ？

8.3.2 ... パッケージを現在のユーザ用のみにインストールするには？
----------------------------------------------------------------

‘python -m pip install’ に ‘--user’ オプションを付けてください。パッケー
ジはシステムのすべてのユーザ用にではなく、現在のユーザ用のみにインストー
ルされます。


File: python.info,  Node: 科学技術計算用の Python パッケージをインストールするには？,  Next: インストールされた複数のバージョンの Python を並行して使うには？,  Prev: パッケージを現在のユーザ用のみにインストールするには？,  Up: どうすればいいの ？

8.3.3 ... 科学技術計算用の Python パッケージをインストールするには？
--------------------------------------------------------------------

科学技術計算用の Python パッケージの多くがバイナリモジュールに複雑に依存
しており、現在のところ ‘pip’ を直接使ってインストールすることは容易では
ありません。現時点では ‘pip’ を使ってインストールしようとするよりも、 別
の手段(1) を用いてインストールするほうが、多くの場合簡単でしょう。

参考
....

Python Packaging User Guide: Installing Scientific Packages(2)

   ---------- Footnotes ----------

   (1) https://packaging.python.org/science/

   (2) https://packaging.python.org/science/


File: python.info,  Node: インストールされた複数のバージョンの Python を並行して使うには？,  Prev: 科学技術計算用の Python パッケージをインストールするには？,  Up: どうすればいいの ？

8.3.4 ... インストールされた複数のバージョンの Python を並行して使うには？
--------------------------------------------------------------------------

Linux や macOS、その他の POSIX システムでは、バージョン番号付きの Python
コマンドと ‘-m’ スイッチを組み合わせて用いて、適切なバージョンの ‘pip’ を
実行してください。

     python2   -m pip install SomePackage  # default Python 2
     python2.7 -m pip install SomePackage  # specifically Python 2.7
     python3   -m pip install SomePackage  # default Python 3
     python3.4 -m pip install SomePackage  # specifically Python 3.4

適切にバージョン番号が付された ‘pip’ コマンドが使えることもあります。

Windows では、 Python ランチャーの ‘py’ を ‘-m’ スイッチとの組み合わせで
使ってください。

     py -2   -m pip install SomePackage  # default Python 2
     py -2.7 -m pip install SomePackage  # specifically Python 2.7
     py -3   -m pip install SomePackage  # default Python 3
     py -3.4 -m pip install SomePackage  # specifically Python 3.4


File: python.info,  Node: よくあるインストールに関する問題,  Prev: どうすればいいの ？,  Up: Python モジュールのインストール

8.4 よくあるインストールに関する問題
====================================

* Menu:

* Linux で、システムの Python 内にインストールする::
* pip がインストールされていない::
* バイナリの拡張のインストール::


File: python.info,  Node: Linux で、システムの Python 内にインストールする,  Next: pip がインストールされていない,  Up: よくあるインストールに関する問題

8.4.1 Linux で、システムの Python 内にインストールする
------------------------------------------------------

Linux システムでは、 Python のインストールは典型的には linux ディストリ
ビューションの一部に含まれています。この Python インストールへのインスト
ールには、システムに対する root 権限が必要で、また、 ‘pip’ によって期待
されているものとは異なるコンポーネントにアップグレードすることで、システ
ムのパッケージマネージャのオペレーションやシステムのほかのコンポーネント
の邪魔をするかもしれません。

そのようなシステムでは、 ‘pip’ でパッケージをインストールする際には仮想
環境を使うか、ユーザごとのインストールを行うのが、大抵良い方法です。


File: python.info,  Node: pip がインストールされていない,  Next: バイナリの拡張のインストール,  Prev: Linux で、システムの Python 内にインストールする,  Up: よくあるインストールに関する問題

8.4.2 pip がインストールされていない
------------------------------------

‘pip’ がデフォルトでインストールされていないことがあります。 次のコマン
ドで問題の解決が見込めます:

     python -m ensurepip --default-pip

他にも pip のインストール(1) についての資料があります。

   ---------- Footnotes ----------

   (1) 
https://packaging.python.org/en/latest/tutorials/installing-packages/#ensure-pip-setuptools-and-wheel-are-up-to-date


File: python.info,  Node: バイナリの拡張のインストール,  Prev: pip がインストールされていない,  Up: よくあるインストールに関する問題

8.4.3 バイナリの拡張のインストール
----------------------------------

Python プロジェクトの多くはソースに基いた配布に強く依存しており、インス
トールプロセスの一環として、エンドユーザ環境でソースから拡張モジュールを
コンパイルすることを期待します。

バイナリ ‘wheel’ フォーマットのサポートが導入されたことで、また、少なく
とも Windows と macOS についての wheels の公開が Python Package Index を
通して出来るようになったことで、この問題についての開発者の時間の節約と、
ユーザにとっては自身でビルドせずにビルド済み拡張をインストールするさらな
る標準化に繋がるかもしれません。

ビルド済み ‘wheel’ ファイルが未だ入手出来ない scientific software(1) イ
ンストールにおけるいくつかの解法が、ローカルにビルドすることなく他のバイ
ナリ拡張を得る助けになるかもしれません。

参考
....

Python Packaging User Guide: Binary Extensions(2)

   ---------- Footnotes ----------

   (1) https://packaging.python.org/science/

   (2) https://packaging.python.org/extensions/


File: python.info,  Node: Python HOWTO,  Next: Python よくある質問,  Prev: Python モジュールのインストール,  Up: Top

9 Python HOWTO
**************

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.

* Menu:

* Python 3 への拡張モジュール移植::
* Python で Curses プログラミング::
* デスクリプタ ガイド::
* Debugging C API extensions and CPython Internals with GDB::
* 列挙型 HOWTO::
* 関数型プログラミング HOWTO::
* Logging HOWTO::
* Logging クックブック::
* 正規表現 HOWTO::
* ソケットプログラミング HOWTO::
* ソートのテクニック::
* Unicode HOWTO::
* urllib パッケージを使ってインターネット上のリソースを取得するには::
* ipaddressモジュールの紹介::
* DTrace と SystemTap で CPython を測定する::
* Python support for the Linux perf profiler::
* Annotations Best Practices::
* 拡張モジュールを分離する::
* timer file descriptor HOWTO::
* The Python 2.3 Method Resolution Order: The Python 2 3 Method Resolution Order.
* Python experimental support for free threading::
* C API Extension Support for Free Threading::


File: python.info,  Node: Python 3 への拡張モジュール移植,  Next: Python で Curses プログラミング,  Up: Python HOWTO

9.1 Python 3 への拡張モジュール移植
===================================

Python 3 への拡張モジュール移植には、以下のリソースを推奨します:

   * 'Supporting Python 3: An in-depth guide' の Migrating C
     extensions(1) 章。本は Python 2 から Python 3 への移行全般を扱い、
     拡張モジュールの移植を読者にガイドします。

   * Porting guide(2) は 'py3c' プロジェクトにより提供される、補助コード
     付きの見解提案です。

   * Cython(3) と CFFI(4) のライブラリは Python の C API 抽象化を提案し
     ます。拡張はたいてい使用時に書き換えが求められますが、これらのライ
     ブラリは Python のバージョンや実装にまたがる違いを処理します。

   ---------- Footnotes ----------

   (1) http://python3porting.com/cextensions.html

   (2) https://py3c.readthedocs.io/en/latest/guide.html

   (3) https://cython.org/

   (4) https://cffi.readthedocs.io/en/latest/


File: python.info,  Node: Python で Curses プログラミング,  Next: デスクリプタ ガイド,  Prev: Python 3 への拡張モジュール移植,  Up: Python HOWTO

9.2 Python で Curses プログラミング
===================================


著者: A.M. Kuchling, Eric S. Raymond


リリース: 2.04

概要
....

このドキュメントでは *note curses: 23. 拡張モジュールでテキストモードデ
ィスプレイを制御する方法について記述します。

* Menu:

* curses ってなに?::
* curses アプリケーションの起動と終了::
* ウィンドウとパッド::
* テキストの表示::
* ユーザ入力::
* より多くの情報::


File: python.info,  Node: curses ってなに?,  Next: curses アプリケーションの起動と終了,  Up: Python で Curses プログラミング

9.2.1 curses ってなに?
----------------------

curses ライブラリは、VT100s や Linux コンソール、さまざまなプログラムが
提供するエミュレーション端末といったテキストベースの端末（ターミナル）の
ために、端末に依存しないスクリーン描画や、キーボードの処理を提供します。
端末はカーソルの移動や、画面のスクロール、領域の消去といった共通の操作を
行うための様々な制御コードをサポートします。端末の種類によって大きく異な
る制御コードを使うことがあり、しばしば独特の癖があります。

グラフィカルなディスプレイが当たり前の今となっては、「なんでわざわざ？」
と疑問に思うかもしれません。確かに文字表示端末は時代遅れな技術ではありま
すが、ニッチな領域が存在していて、意匠を凝らすことができるため、いまだに
価値のあるものとなっています。そのような領域の一つは、例えば X サーバー
を持たない組み込みのUnixです。ほかにも、OSのインストーラや、カーネル設定
などのツールで、これらはグラフィカルサポートが利用可能になる前に動作する
必要があります。

The curses library provides fairly basic functionality, providing the
programmer with an abstraction of a display containing multiple
non-overlapping windows of text.  The contents of a window can be
changed in various ways--adding text, erasing it, changing its
appearance--and the curses library will figure out what control codes
need to be sent to the terminal to produce the right output.  curses
doesn't provide many user-interface concepts such as buttons,
checkboxes, or dialogs; if you need such features, consider a user
interface library such as Urwid(1).

curses ライブラリは元々 BSD UNIX 向けに書かれました; 後の AT&T から出た
Unix System V バージョンで多くの機能と新機能が追加されました。BSD curses
はいまやメンテナンスされておらず、これは AT&T インターフェースのオープン
ソース実装である ncurses にとって置き換えられました。Linux や FreeBSD の
ようなオープンソース Unix を利用している場合は、おそらくシステムは
ncurses を利用しています。現在のほとんどの商用 Unix は System V のコード
を基にしているため、ここで述べる全ての関数が利用できるはずです。しかし、
古いバージョンの curses を持ついくつかのプロプライエタリ Unix は全てには
対応していないでしょう。

The Windows version of Python doesn't include the *note curses: 23.
module.  A ported version called UniCurses(2) is available.

* Menu:

* Python の curses module::

   ---------- Footnotes ----------

   (1) https://pypi.org/project/Urwid/

   (2) https://pypi.org/project/UniCurses/


File: python.info,  Node: Python の curses module,  Up: curses ってなに?

9.2.1.1 Python の curses module
...............................

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 really easy to transfer that knowledge to Python.  The
biggest difference is that the Python interface makes things simpler by
merging different C functions such as ‘addstr()’, ‘mvaddstr()’, and
‘mvwaddstr()’ into a single *note addstr(): 2d14. method.  You'll see
this covered in more detail later.

この HOWTO は curses と Python を使ってテキストプログラムを書くための入
門記事です。 curses API に対する完全な解説をすることは意図していません;
その目的のためには Python ライブラリガイドの ncurses 節と C 言語マニュア
ルのncurses のページを参照してください。とはいえ、この文章は基本的な考え
を提供してくれるでしょう。


File: python.info,  Node: curses アプリケーションの起動と終了,  Next: ウィンドウとパッド,  Prev: curses ってなに?,  Up: Python で Curses プログラミング

9.2.2 curses アプリケーションの起動と終了
-----------------------------------------

Before doing anything, curses must be initialized.  This is done by
calling the *note initscr(): 1508. function, which will determine the
terminal type, send any required setup codes to the terminal, and create
various internal data structures.  If successful, ‘initscr()’ returns a
window object representing the entire screen; this is usually called
‘stdscr’ after the name of the corresponding C variable.

     import curses
     stdscr = curses.initscr()

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 *note noecho(): 2d3e.
function.

     curses.noecho()

通常アプリケーションはまた、Enter キーを押すことなく、キーに対してすぐに
反応する必要があります; これは cbreak モードと呼ばれ、通常の入力がバッフ
ァされるモードと逆に動作します。

     curses.cbreak()

端末は通常、カーソルキーや Page Up や Home といった操作キーなどの特別な
キーをマルチバイトエスケープシーケンスとして返します。それらのシーケンス
を想定して対応する処理を行うアプリケーションを書けるように、 curses はそ
れを *note curses.KEY_LEFT: 2db9. のような特別な値を返して行ってくれます
。 curses にその仕事をさせるには、キーパッドモードを有効にする必要があり
ます。

     stdscr.keypad(True)

curses アプリケーションを終了させるのは起動よりも簡単です。 以下を呼び出
す必要があります:

     curses.nocbreak()
     stdscr.keypad(False)
     curses.echo()

cursesに親和性の高い設定をもとに戻します。そして、*note endwin(): 2d17.
関数を呼び出し、端末を通常の操作モードに復旧します。

     curses.endwin()

curses アプリケーションをデバッグするときの一般的な問題は、アプリケーシ
ョンが端末を以前の状態に復旧することなく異常終了したときに端末がめちゃめ
ちゃになることです。Python ではこの問題はコードにバグがあって、捕捉でき
ない例外が発生したときによく起きます。タイプしたキーはもはやエコーされま
せん、例えば、シェルを使うのが難しくなります。

Pythonでは、これらの複雑さを避けデバッグをより容易にするために、 *note
curses.wrapper(): a4e. 関数をインポートして、このように使います:

     from curses import wrapper

     def main(stdscr):
         # Clear screen
         stdscr.clear()

         # This raises ZeroDivisionError when i == 10.
         for i in range(0, 11):
             v = i-10
             stdscr.addstr(i, 0, '10 divided by {} is {}'.format(v, 10/v))

         stdscr.refresh()
         stdscr.getkey()

     wrapper(main)

The *note wrapper(): a4e. function takes a callable object and does the
initializations described above, also initializing colors if color
support is present.  ‘wrapper()’ then runs your provided callable.  Once
the callable returns, ‘wrapper()’ will restore the original state of the
terminal.  The callable is called inside a *note try: 6b4...*note
except: 170. that catches exceptions, restores the state of the
terminal, and then re-raises the exception.  Therefore your terminal
won't be left in a funny state on exception and you'll be able to read
the exception's message and traceback.


File: python.info,  Node: ウィンドウとパッド,  Next: テキストの表示,  Prev: curses アプリケーションの起動と終了,  Up: Python で Curses プログラミング

9.2.3 ウィンドウとパッド
------------------------

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.

The ‘stdscr’ object returned by the *note initscr(): 1508. function is a
window object that covers the entire screen.  Many programs may need
only this single window, but you might wish to divide the screen into
smaller windows, in order to redraw or clear them separately.  The *note
newwin(): 2d3c. function creates a new window of a given size, returning
the new window object.

     begin_x = 20; begin_y = 7
     height = 5; width = 40
     win = curses.newwin(height, width, begin_y, begin_x)

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 coordinate (0,0).  This breaks the normal convention for
handling coordinates where the 'x' coordinate comes first.  This is an
unfortunate 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.

Your application can determine the size of the screen by using the *note
curses.LINES: 1671. and *note curses.COLS: 1672. variables to obtain the
'y' and 'x' sizes.  Legal coordinates will then extend from ‘(0,0)’ to
‘(curses.LINES - 1, curses.COLS - 1)’.

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 *note
refresh(): 2d3b. method of window objects to update the screen.

This is because curses was originally written with slow 300-baud
terminal connections in mind; with these terminals, minimizing the time
required to redraw the screen was very important.  Instead curses
accumulates changes to the screen and displays them in the most
efficient manner when you call ‘refresh()’.  For example, if your
program displays some text in a window and then clears the window,
there's no need to send the original text because they're never visible.

In practice, explicitly telling curses to redraw a window doesn't really
complicate programming with curses much.  Most programs go into a flurry
of activity, and then pause waiting for a keypress or some other action
on the part of the user.  All you have to do is to be sure that the
screen has been redrawn before pausing to wait for user input, by first
calling ‘stdscr.refresh()’ or the ‘refresh()’ method of some other
relevant window.

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 a pad requires the pad's height and width, while refreshing a
pad requires giving the coordinates of the on-screen area where a
subsection of the pad will be displayed.

     pad = curses.newpad(100, 100)
     # These loops fill the pad with letters; addch() is
     # explained in the next section
     for y in range(0, 99):
         for x in range(0, 99):
             pad.addch(y,x, ord('a') + (x*x+y*y) % 26)

     # Displays a section of the pad in the middle of the screen.
     # (0,0) : coordinate of upper-left corner of pad area to display.
     # (5,5) : coordinate of upper-left corner of window area to be filled
     #         with pad content.
     # (20, 75) : coordinate of lower-right corner of window area to be
     #          : filled with pad content.
     pad.refresh( 0,0, 5,5, 20,75)

The ‘refresh()’ call displays a section of the pad in the rectangle
extending from coordinate (5,5) to coordinate (20,75) on the screen; the
upper left corner of the displayed section is coordinate (0,0) on the
pad.  Beyond that difference, pads are exactly like ordinary windows and
support the same methods.

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.  ‘refresh()’ actually does two
things:

  1. それぞれのウィンドウの *note noutrefresh(): 2d15. メソッドを呼び出
     して、配下にある、スクリーンの望ましい状態を表すデータ構造を更新し
     ます。

  2. *note doupdate(): 2d13. 関数を呼び出して、データ構造に記録された望
     ましい状態に合致するように、物理スクリーンを更新します。

Instead you can call ‘noutrefresh()’ on a number of windows to update
the data structure, and then call ‘doupdate()’ to update the screen.


File: python.info,  Node: テキストの表示,  Next: ユーザ入力,  Prev: ウィンドウとパッド,  Up: Python で Curses プログラミング

9.2.4 テキストの表示
--------------------

From a C programmer's point of view, curses may sometimes look like a
twisty maze of functions, all subtly different.  For example, ‘addstr()’
displays a string at the current cursor location in the ‘stdscr’ window,
while ‘mvaddstr()’ moves to a given y,x coordinate first before
displaying the string.  ‘waddstr()’ is just like ‘addstr()’, but allows
specifying a window to use instead of using ‘stdscr’ by default.
‘mvwaddstr()’ allows specifying both a window and a coordinate.

幸運にも、Python インターフェースはこれらの詳細を全て隠蔽してくれます。
‘stdscr’ は他のものと同様のウィンドウオブジェクトであり、 *note
addstr(): 2d14. のようなメソッドは複数の引数形式を許容してくれます。通常
それらは4つの形式です。

形式                                  説明
                                      
------------------------------------------------------------------------------------------
                                      
'str' または 'ch'                     文字列 'str' または文字 'ch' を現在位置に表示しま
                                      す
                                      
                                      
'str' または 'ch', 'attr'             文字列 'str' または文字 'ch' を属性 'attr' を利用
                                      して現在位置に表示します
                                      
                                      
'y', 'x', 'str' または 'ch'           ウィンドウ内の位置 'y,x' に移動し 'str' または
                                      'ch' を表示します
                                      
                                      
'y', 'x', 'str' または 'ch', 'attr'   ウィンドウ内の位置 'y,x' に移動し属性 'attr' を利
                                      用して 'str' または 'ch' を表示します
                                      

属性によって表示するテキストをハイライトすることができます、ボールド体、
アンダーライン、反転、カラーなど。より詳しくは次の小節で説明します。

The *note addstr(): 2d14. method takes a Python string or bytestring as
the value to be displayed.  The contents of bytestrings are sent to the
terminal as-is.  Strings are encoded to bytes using the value of the
window's *note encoding: 106b. attribute; this defaults to the default
system encoding as returned by *note locale.getencoding(): 2be.

The *note addch(): 2d57. methods take a character, which can be either a
string of length 1, a bytestring of length 1, or an integer.

Constants are provided for extension characters; these constants are
integers greater than 255.  For example, *note ACS_PLMINUS: 2e26. is a
+/- symbol, and *note ACS_ULCORNER: 2d61. is the upper left corner of a
box (handy for drawing borders).  You can also use the appropriate
Unicode character.

ウィンドウは最後の操作の後のカーソル位置を覚えているため、 'y,x' 座標を
うっかり忘れてしまっても、文字列や文字は最後の操作位置に表示されます。
‘move(y,x)’ メソッドでカーソルを移動させることもできます。常に点滅するカ
ーソルを表示する端末もあるため、カーソルが特定の位置にいることを保証して
注意が反れないようにしたいと思うかもしれません; ランダムに見える位置でカ
ーソルが点滅すると面を食らってしまいます。

If your application doesn't need a blinking cursor at all, you can call
‘curs_set(False)’ to make it invisible.  For compatibility with older
curses versions, there's a ‘leaveok(bool)’ function that's a synonym for
*note curs_set(): 2d0d.  When 'bool' is true, the curses library will
attempt to suppress the flashing cursor, and you won't need to worry
about leaving it in odd locations.

* Menu:

* 属性とカラー::


File: python.info,  Node: 属性とカラー,  Up: テキストの表示

9.2.4.1 属性とカラー
....................

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.

属性は整数値で、それぞれのビットが異なる属性を表わします。複数の属性ビッ
トをセットしてテキストの表示を試みることができますが、curses は全ての組
み合わせが利用可能であるかや視覚的に区別できるかどうかは保証してくれませ
ん、それらは利用している端末の能力に依存しているため、最も安全なのは、最
も一般的に利用可能な属性を設定する方法です、ここに列挙します。

属性                       説明
                           
----------------------------------------------------------------------
                           
*note A_BLINK: 2da5.       テキストを点滅
                           
                           
*note A_BOLD: 2da6.        高輝度またはボールドテキスト
                           
                           
*note A_DIM: 2da7.         低輝度テキスト
                           
                           
*note A_REVERSE: 2d0b.     反転テキスト
                           
                           
*note A_STANDOUT: 2d0a.    利用できる最良のハイライトモード
                           
                           
*note A_UNDERLINE: 2dab.   下線付きテキスト
                           

つまり、反転するステータスラインを画面の最上部に表示するには、コードをこ
うします:

     stdscr.addstr(0, 0, "Current mode: Typing mode",
                   curses.A_REVERSE)
     stdscr.refresh()

curses ライブラリはカラー機能を提供している端末でのカラーもサポートして
います。そんな端末の中で最も一般的なものは Linux コンソールで、color
xterm もそれに続きます。

To use color, you must call the *note start_color(): 2d48. function soon
after calling *note initscr(): 1508, to initialize the default color set
(the *note curses.wrapper(): a4e. function does this automatically).
Once that's done, the *note has_colors(): 2d2a. function returns TRUE if
the terminal in use can actually display color.  (Note: curses uses the
American spelling 'color', instead of the Canadian/British spelling
'colour'.  If you're used to the British spelling, you'll have to resign
yourself to misspelling it for the sake of these functions.)

The curses library maintains a finite number of color pairs, containing
a foreground (or text) color and a background color.  You can get the
attribute value corresponding to a color pair with the *note
color_pair(): 2d09. function; this can be bitwise-OR'ed with other
attributes such as *note A_REVERSE: 2d0b, but again, such combinations
are not guaranteed to work on all terminals.

例として、テキスト行をカラーペア 1 を使って表示します:

     stdscr.addstr("Pretty text", curses.color_pair(1))
     stdscr.refresh()

As I said before, a color pair consists of a foreground and background
color.  The ‘init_pair(n, f, b)’ function changes the definition of
color pair 'n', to foreground color f and background color b.  Color
pair 0 is hard-wired to white on black, and cannot be changed.

Colors are numbered, and *note start_color(): 2d48. initializes 8 basic
colors when it activates color mode.  They are: 0:black, 1:red, 2:green,
3:yellow, 4:blue, 5:magenta, 6:cyan, and 7:white.  The *note curses: 23.
module defines named constants for each of these colors: *note
curses.COLOR_BLACK: 2e38, *note curses.COLOR_RED: 2e3d, and so forth.

やってみましょう。カラー 1 を白背景に赤に変更してみましょう、こうして呼
び出します:

     curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)

カラーペアを変更するときには、既に表示された任意のテキストが利用するカラ
ーペアを新しい色に変更します。新しいテキストをこの色で使うこともできます
:

     stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1))

Very fancy terminals can change the definitions of the actual colors to
a given RGB value.  This lets you change color 1, which is usually red,
to purple or blue or any other color you like.  Unfortunately, the Linux
console doesn't support this, so I'm unable to try it out, and can't
provide any examples.  You can check if your terminal can do this by
calling *note can_change_color(): 2d06, which returns ‘True’ if the
capability is there.  If you're lucky enough to have such a talented
terminal, consult your system's man pages for more information.


File: python.info,  Node: ユーザ入力,  Next: より多くの情報,  Prev: テキストの表示,  Up: Python で Curses プログラミング

9.2.5 ユーザ入力
----------------

The C curses library offers only very simple input mechanisms.  Python's
*note curses: 23. module adds a basic text-input widget.  (Other
libraries such as Urwid(1) have more extensive collections of widgets.)

ウィンドウから入力を得るための2つのメソッドがあります。

   * *note getch(): 2d1d. refreshes the screen and then waits for the
     user to hit a key, displaying the key if *note echo(): 2d16. has
     been called earlier.  You can optionally specify a coordinate to
     which the cursor should be moved before pausing.

   * *note getkey(): 2d75. does the same thing but converts the integer
     to a string.  Individual characters are returned as 1-character
     strings, and special keys such as function keys return longer
     strings containing a key name such as ‘KEY_UP’ or ‘^G’.

It's possible to not wait for the user using the *note nodelay(): 2d8c.
window method.  After ‘nodelay(True)’, ‘getch()’ and ‘getkey()’ for the
window become non-blocking.  To signal that no input is ready, ‘getch()’
returns ‘curses.ERR’ (a value of -1) and ‘getkey()’ raises an exception.
There's also a *note halfdelay(): 2d2e. function, which can be used to
(in effect) set a timer on each ‘getch()’; if no input becomes available
within a specified delay (measured in tenths of a second), curses raises
an exception.

The ‘getch()’ method returns an integer; if it's between 0 and 255, it
represents the ASCII code of the key pressed.  Values greater than 255
are special keys such as Page Up, Home, or the cursor keys.  You can
compare the value returned to constants such as *note curses.KEY_PPAGE:
2dca, *note curses.KEY_HOME: 2dbb, or *note curses.KEY_LEFT: 2db9.  The
main loop of your program may look something like this:

     while True:
         c = stdscr.getch()
         if c == ord('p'):
             PrintDocument()
         elif c == ord('q'):
             break  # Exit the while loop
         elif c == curses.KEY_HOME:
             x = y = 0

The *note curses.ascii: 24. module supplies ASCII class membership
functions that take either integer or 1-character string arguments;
these may be useful in writing more readable tests for such loops.  It
also supplies conversion functions that take either integer or
1-character-string arguments and return the same type.  For example,
*note curses.ascii.ctrl(): 2e7f. returns the control character
corresponding to its argument.

There's also a method to retrieve an entire string, *note getstr():
2d78.  It isn't used very often, because its functionality is quite
limited; the only editing keys available are the backspace key and the
Enter key, which terminates the string.  It can optionally be limited to
a fixed number of characters.

     curses.echo()            # Enable echoing of characters

     # Get a 15-character string, with the cursor on the top line
     s = stdscr.getstr(0,0, 15)

The *note curses.textpad: 26. module supplies a text box that supports
an Emacs-like set of keybindings.  Various methods of the *note Textbox:
2e41. class support editing with input validation and gathering the edit
results either with or without trailing spaces.  Here's an example:

     import curses
     from curses.textpad import Textbox, rectangle

     def main(stdscr):
         stdscr.addstr(0, 0, "Enter IM message: (hit Ctrl-G to send)")

         editwin = curses.newwin(5,30, 2,1)
         rectangle(stdscr, 1,0, 1+5+1, 1+30+1)
         stdscr.refresh()

         box = Textbox(editwin)

         # Let the user edit until Ctrl-G is struck.
         box.edit()

         # Get resulting contents
         message = box.gather()

さらなる詳細についてはライブラリのドキュメント *note curses.textpad: 26.
を参照してください。

   ---------- Footnotes ----------

   (1) https://pypi.org/project/Urwid/


File: python.info,  Node: より多くの情報,  Prev: ユーザ入力,  Up: Python で Curses プログラミング

9.2.6 より多くの情報
--------------------

この HOWTO ではいくつかの進んだ話題、スクリーンスクレイピングや xterm イ
ンスタンスからマウスイベントを捉えるなど、については扱っていません。しか
し、Python の *note curses: 23. モジュールのライブラリページはいまやかな
り充実しています。次はこれを見るべきです。

If you're in doubt about the detailed behavior of the curses functions,
consult the manual pages for your curses implementation, whether it's
ncurses or a proprietary Unix vendor's.  The manual pages will document
any quirks, and provide complete lists of all the functions, attributes,
and *note ACS_*: 2e12. characters available to you.

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, but because no one has needed them yet.  Also, Python doesn't
yet support the menu library associated with ncurses.  Patches adding
support for these would be welcome; see the Python Developer's Guide(1)
to learn more about submitting patches to Python.

   * Writing Programs with NCURSES(2): a lengthy tutorial for C
     programmers.

   * The ncurses man page(3)

   * The ncurses FAQ(4)

   * "Use curses...  don't swear"(5): curses または Urwid を使って端末を
     制御する PyCon 2013 講演ビデオです。

   * "Console Applications with Urwid"(6): video of a PyCon CA 2012 talk
     demonstrating some applications written using Urwid.

   ---------- Footnotes ----------

   (1) https://devguide.python.org/

   (2) https://invisible-island.net/ncurses/ncurses-intro.html

   (3) https://linux.die.net/man/3/ncurses

   (4) https://invisible-island.net/ncurses/ncurses.faq.html

   (5) https://www.youtube.com/watch?v=eN1eZtjLEnU

   (6) https://pyvideo.org/video/1568/console-applications-with-urwid


File: python.info,  Node: デスクリプタ ガイド,  Next: Debugging C API extensions and CPython Internals with GDB,  Prev: Python で Curses プログラミング,  Up: Python HOWTO

9.3 デスクリプタ ガイド
=======================


著者: Raymond Hettinger


問い合わせ先: <python at rcn dot com>

*note デスクリプタ: 1ed1. を使うと、オブジェクトの属性検索、保存、削除を
カスタマイズできます。

本ガイドは4つの大項目から構成されています。

  1. 最初の「入門」では基本の紹介をして、シンプルな例から少しずつ概念を
     説明していきます。もしデスクリプタに触れるのが初めての場合はここか
     ら学んでいきましょう。

  2. 2つ目のセクションでは完全で実践的なデスクリプタのサンプルを紹介しま
     す。もしデスクリプタの基本を理解しているのであれば、ここから読み始
     めても良いでしょう。

  3. 3番目のセクションはより技巧的なチュートリアルを通じて、デスクリプタ
     がどのようなメカニズムで動作しているのかを紹介します。多くの人はこ
     のレベルの理解は不要でしょう。

  4. 最後のセクションは、Cで書かれた組み込みのデスクリプタをピュア
     Pythonで実現する方法を紹介します。このセクションがどのように関数が
     束縛メソッドになるのか、 *note classmethod(): 14c. や *note
     staticmethod(): 3ef, *note property(): 179, *note __slots__: 5a9. と
     いった一般的なツールの実装がどのようになっているのか興味を持ったら
     読んでください。

* Menu:

* 入門::
* 実践的なサンプル::
* 技術的なチュートリアル::
* ピュアPythonの等価実装::


File: python.info,  Node: 入門,  Next: 実践的なサンプル,  Up: デスクリプタ ガイド

9.3.1 入門
----------

この入門では、なるべく基礎的なところから開始し、新しい要素を一つずつ紹介
していきます。

* Menu:

* シンプルな例; 定数を返すデスクリプタ: シンプルな例 定数を返すデスクリプタ.
* 動的なルックアップ::
* 管理された属性::
* 名前のカスタマイズ::
* まとめ::


File: python.info,  Node: シンプルな例 定数を返すデスクリプタ,  Next: 動的なルックアップ,  Up: 入門

9.3.1.1 シンプルな例: 定数を返すデスクリプタ
............................................

‘Ten’ クラスはデスクリプタで、その ‘__get__()’ メソッドは常に定数の ‘10’
を返します。

     class Ten:
         def __get__(self, obj, objtype=None):
             return 10

このデスクリプタを使うには他のクラスのクラス変数として保存します:

     class A:
         x = 5                       # Regular class attribute
         y = Ten()                   # Descriptor instance

インタラクティブセッションを使って、通常の属性ルックアップと、デスクリプ
タのルックアップの違いを見てみましょう。

     >>> a = A()                     # Make an instance of class A
     >>> a.x                         # Normal attribute lookup
     5
     >>> a.y                         # Descriptor lookup
     10

‘a.x’ 属性ルックアップではドット演算子がクラス辞書の中から ‘'x': 5’ を見
つけます。 ‘a.y’ ルックアップではドット演算子は ‘__get__’ メソッドを持つ
デスクリプタインスタンスを取得します。そのメソッドを呼び出すと、 ‘10’ を
返します。

‘10’ はクラスの辞書にも、インスタンスの辞書にも格納されていません。その
代わり、 ‘10’ はオンデマンドに計算されます。

このサンプルは、シンプルなデスクリプタがどのように動作するかを説明するた
めのものですが、実用的ではありません。定数を返す場合、通常の属性アクセス
の方が良いでしょう。

次のセクションでは、より実践的な動的なルックアップを作成します。


File: python.info,  Node: 動的なルックアップ,  Next: 管理された属性,  Prev: シンプルな例 定数を返すデスクリプタ,  Up: 入門

9.3.1.2 動的なルックアップ
..........................

単に定数を返すよりも、なにか処理を実行するデスクリプタの方が面白いでしょ
う。

     import os

     class DirectorySize:

         def __get__(self, obj, objtype=None):
             return len(os.listdir(obj.dirname))

     class Directory:

         size = DirectorySize()              # Descriptor instance

         def __init__(self, dirname):
             self.dirname = dirname          # Regular instance attribute

インタラクティブセッションで見たように、この探索は動的です。実行ごとに異
なる計算を行い、毎回答えが更新されます。

     >>> s = Directory('songs')
     >>> g = Directory('games')
     >>> s.size                              # The songs directory has twenty files
     20
     >>> g.size                              # The games directory has three files
     3
     >>> os.remove('games/chess')            # Delete a game
     >>> g.size                              # File count is automatically updated
     2

このサンプルはデスクリプタの中でどのように処理を行うかだけではなく、
‘__get__()’ の引数の目的も示しています。 'self' パラメータは 'size' で、
'DirectorySize' のインスタンスです。 'obj' パラメータは 'g' や 's' とい
った 'Directory' のインスタンスです。 'obj' により、 ‘__get__()’ はター
ゲットのディレクトリを知れます。 'objtype' パラメータは 'Directory' クラ
スです。


File: python.info,  Node: 管理された属性,  Next: 名前のカスタマイズ,  Prev: 動的なルックアップ,  Up: 入門

9.3.1.3 管理された属性
......................

デスクリプタで広く使われる用途がインスタンスのデータへのアクセスの管理で
す。このデスクリプタはクラス辞書のパブリックな属性に割り当てられますが、
実際のデータはインスタンス辞書のプライベートな属性に保存します。パブリッ
クなアクセスが行われると、デスクリプタの ‘__get__()’ と ‘__set__()’ メソ
ッドが実行されます。

このサンプルでは 'age' はパブリックな属性で、 '_age' はプライベートな属
性です。パブリックな属性がアクセスされると、デスクリプタはルックアップや
更新のログ出力をします。

     import logging

     logging.basicConfig(level=logging.INFO)

     class LoggedAgeAccess:

         def __get__(self, obj, objtype=None):
             value = obj._age
             logging.info('Accessing %r giving %r', 'age', value)
             return value

         def __set__(self, obj, value):
             logging.info('Updating %r to %r', 'age', value)
             obj._age = value

     class Person:

         age = LoggedAgeAccess()             # Descriptor instance

         def __init__(self, name, age):
             self.name = name                # Regular instance attribute
             self.age = age                  # Calls __set__()

         def birthday(self):
             self.age += 1                   # Calls both __get__() and __set__()

インタラクティブセッションの結果で見てわかるように、管理された属性の
'age' のログ出力が行われますが、通常の属性の 'name' はログ出力されません
。

     >>> mary = Person('Mary M', 30)         # The initial age update is logged
     INFO:root:Updating 'age' to 30
     >>> dave = Person('David D', 40)
     INFO:root:Updating 'age' to 40

     >>> vars(mary)                          # The actual data is in a private attribute
     {'name': 'Mary M', '_age': 30}
     >>> vars(dave)
     {'name': 'David D', '_age': 40}

     >>> mary.age                            # Access the data and log the lookup
     INFO:root:Accessing 'age' giving 30
     30
     >>> mary.birthday()                     # Updates are logged as well
     INFO:root:Accessing 'age' giving 30
     INFO:root:Updating 'age' to 31

     >>> dave.name                           # Regular attribute lookup isn't logged
     'David D'
     >>> dave.age                            # Only the managed attribute is logged
     INFO:root:Accessing 'age' giving 40
     40

このサンプル実装には大きな問題があります。プライベートな名前の '_age' が
'LoggedAgeAccess' クラスの中でハードコードされています。そのため、どのイ
ンスタンスも1つしかこのログ出力される属性が作れず、名前を変更できません
。次のサンプルでこの問題を解決していきます。


File: python.info,  Node: 名前のカスタマイズ,  Next: まとめ,  Prev: 管理された属性,  Up: 入門

9.3.1.4 名前のカスタマイズ
..........................

クラスがデスクリプタを使うときに、クラスはそれぞれのデスクリプタにどのよ
うな変数名を使うかを通知します。

このサンプルでは ‘Person’ クラスは、 'name' と 'age' という2つのデスクリ
プタインスタンスを持っています。 ‘Person’ が定義されると、
'LoggedAccess' の ‘__set_name__()’ にコールバックを行うため、フィールド
名を記録できます。それぞれのデスクリプタは、 'public_name' と
'private_name' を持ちます。

     import logging

     logging.basicConfig(level=logging.INFO)

     class LoggedAccess:

         def __set_name__(self, owner, name):
             self.public_name = name
             self.private_name = '_' + name

         def __get__(self, obj, objtype=None):
             value = getattr(obj, self.private_name)
             logging.info('Accessing %r giving %r', self.public_name, value)
             return value

         def __set__(self, obj, value):
             logging.info('Updating %r to %r', self.public_name, value)
             setattr(obj, self.private_name, value)

     class Person:

         name = LoggedAccess()                # First descriptor instance
         age = LoggedAccess()                 # Second descriptor instance

         def __init__(self, name, age):
             self.name = name                 # Calls the first descriptor
             self.age = age                   # Calls the second descriptor

         def birthday(self):
             self.age += 1

インタラクティブセッション上で試すと、 ‘Person’ クラスが
‘__set_name__()’ を呼び出し、フィールド名が記録されることが分かるでしょ
う。 *note vars(): 19ad. を呼んで、デスクリプタを起動しないでデスクリプ
タを取得してみましょう。

     >>> vars(vars(Person)['name'])
     {'public_name': 'name', 'private_name': '_name'}
     >>> vars(vars(Person)['age'])
     {'public_name': 'age', 'private_name': '_age'}

新しいクラスは 'name' と 'age' の両方でログを出力します。

     >>> pete = Person('Peter P', 10)
     INFO:root:Updating 'name' to 'Peter P'
     INFO:root:Updating 'age' to 10
     >>> kate = Person('Catherine C', 20)
     INFO:root:Updating 'name' to 'Catherine C'
     INFO:root:Updating 'age' to 20

2つの 'Person' のインスタンスは、プライベート名しか保持していません。

     >>> vars(pete)
     {'_name': 'Peter P', '_age': 10}
     >>> vars(kate)
     {'_name': 'Catherine C', '_age': 20}


File: python.info,  Node: まとめ,  Prev: 名前のカスタマイズ,  Up: 入門

9.3.1.5 まとめ
..............

‘__get__()’ 、 ‘__set__()’ 、あるいは ‘__delete__()’ メソッドを定義した
あらゆるオブジェクトが、我々が *note descriptor: 1ed1. と呼ぶものです。

それに追加して、デスクリプタは ‘__set_name__()’ メソッドを持つこともでき
ます。このメソッドは、デスクリプタが設定されるクラス、あるいはアサインさ
れたクラス変数を知る必要がある場合に利用されます。もし存在していれば、ク
ラスがデスクリプタでなくても呼ばれます。

デスクリプタは属性のルックアップ中に、ドット演算子によって呼び出されます
。 ‘vars(some_class)[descriptor_name]’ という書き方によって間接的にデス
クリプタがアクセスされると、デスクリプタを実行することなく、デスクリプタ
のインスタンスが返されます。

デスクリプタはクラス変数として利用したときにだけ動作します。インスタンス
に設定しても効果はありません。

デスクリプタは、クラス変数として格納されているオブジェクトが属性ルックア
ップ中に発生することを制御できるように、フックを提供することが主なモチベ
ーションとなっています。

伝統的には、呼び出し側のクラスが、ルックアップ中に発生することを制御して
きましたが、デスクリプタはその関係を逆転させ、検索されているデータが問題
に介入できるようにします。

デスクリプタは、Pythonのさまざまなところで利用されています。これにより、
単なる関数は、インスタンスに束縛されたメソッドになります。 *note
classmethod(): 14c, *note staticmethod(): 3ef, *note property(): 179,
*note functools.cached_property(): 50c. といったツールもすべて、デスクリ
プタとして実装されています。


File: python.info,  Node: 実践的なサンプル,  Next: 技術的なチュートリアル,  Prev: 入門,  Up: デスクリプタ ガイド

9.3.2 実践的なサンプル
----------------------

このサンプルでは、発見が極めて難しいデータ破損バグを特定するのに利用可能
な、実践的でパワフルなツールを紹介します。

* Menu:

* バリデータクラス::
* カスタムバリデータ::
* 実践的なアプリケーション::


File: python.info,  Node: バリデータクラス,  Next: カスタムバリデータ,  Up: 実践的なサンプル

9.3.2.1 バリデータクラス
........................

バリデータは管理された属性アクセスのためのデスクリプタです。データを格納
する前に、新しい値が型が適合しているか、値の範囲制限に適合しているかを検
証します。もし制限に合わなければ、例外を送出し、データが不正な状態になる
のを防ぎます。

‘Validator’ クラスは *note abstract base class: 1186. であり、属性管理デ
スクリプタでもあります。

     from abc import ABC, abstractmethod

     class Validator(ABC):

         def __set_name__(self, owner, name):
             self.private_name = '_' + name

         def __get__(self, obj, objtype=None):
             return getattr(obj, self.private_name)

         def __set__(self, obj, value):
             self.validate(value)
             setattr(obj, self.private_name, value)

         @abstractmethod
         def validate(self, value):
             pass

カスタムバリデータを作成するには ‘Validator’ を継承し、 ‘validate()’ メ
ソッドを作成して必要に応じてさまざまな制約の検証を行います。


File: python.info,  Node: カスタムバリデータ,  Next: 実践的なアプリケーション,  Prev: バリデータクラス,  Up: 実践的なサンプル

9.3.2.2 カスタムバリデータ
..........................

ここでは3つの実践的なバリデーションのユーティリティのサンプルを紹介しま
す。

  1. ‘OneOf’ は制限された候補の集合に含まれる値かどうかを検証します。

  2. ‘Number’ は値が *note int: 238. か *note float: 2ce. かどうかを検証
     します。オプションで、値が指定された最小値と最大値に含まれるかも検
     証します。

  3. ‘String’ は値が *note str: 418. かどうか検証します。オプションで、
     指定された最小、最大の長さの検証をします。ユーザー定義の 術語(1) 検
     証も行えます。

     class OneOf(Validator):

         def __init__(self, *options):
             self.options = set(options)

         def validate(self, value):
             if value not in self.options:
                 raise ValueError(
                     f'Expected {value!r} to be one of {self.options!r}'
                 )

     class Number(Validator):

         def __init__(self, minvalue=None, maxvalue=None):
             self.minvalue = minvalue
             self.maxvalue = maxvalue

         def validate(self, value):
             if not isinstance(value, (int, float)):
                 raise TypeError(f'Expected {value!r} to be an int or float')
             if self.minvalue is not None and value < self.minvalue:
                 raise ValueError(
                     f'Expected {value!r} to be at least {self.minvalue!r}'
                 )
             if self.maxvalue is not None and value > self.maxvalue:
                 raise ValueError(
                     f'Expected {value!r} to be no more than {self.maxvalue!r}'
                 )

     class String(Validator):

         def __init__(self, minsize=None, maxsize=None, predicate=None):
             self.minsize = minsize
             self.maxsize = maxsize
             self.predicate = predicate

         def validate(self, value):
             if not isinstance(value, str):
                 raise TypeError(f'Expected {value!r} to be an str')
             if self.minsize is not None and len(value) < self.minsize:
                 raise ValueError(
                     f'Expected {value!r} to be no smaller than {self.minsize!r}'
                 )
             if self.maxsize is not None and len(value) > self.maxsize:
                 raise ValueError(
                     f'Expected {value!r} to be no bigger than {self.maxsize!r}'
                 )
             if self.predicate is not None and not self.predicate(value):
                 raise ValueError(
                     f'Expected {self.predicate} to be true for {value!r}'
                 )

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Predicate_(mathematical_logic)


File: python.info,  Node: 実践的なアプリケーション,  Prev: カスタムバリデータ,  Up: 実践的なサンプル

9.3.2.3 実践的なアプリケーション
................................

次のコードは実際のクラスでデータバリデータを使う方法のサンプルです。

     class Component:

         name = String(minsize=3, maxsize=10, predicate=str.isupper)
         kind = OneOf('wood', 'metal', 'plastic')
         quantity = Number(minvalue=0)

         def __init__(self, name, kind, quantity):
             self.name = name
             self.kind = kind
             self.quantity = quantity

これらのデスクリプタは、不正インスタンスが作成されるのを防ぎます。

     >>> Component('Widget', 'metal', 5)      # Blocked: 'Widget' is not all uppercase
     Traceback (most recent call last):
         ...
     ValueError: Expected <method 'isupper' of 'str' objects> to be true for 'Widget'

     >>> Component('WIDGET', 'metle', 5)      # Blocked: 'metle' is misspelled
     Traceback (most recent call last):
         ...
     ValueError: Expected 'metle' to be one of {'metal', 'plastic', 'wood'}

     >>> Component('WIDGET', 'metal', -5)     # Blocked: -5 is negative
     Traceback (most recent call last):
         ...
     ValueError: Expected -5 to be at least 0

     >>> Component('WIDGET', 'metal', 'V')    # Blocked: 'V' isn't a number
     Traceback (most recent call last):
         ...
     TypeError: Expected 'V' to be an int or float

     >>> c = Component('WIDGET', 'metal', 5)  # Allowed:  The inputs are valid


File: python.info,  Node: 技術的なチュートリアル,  Next: ピュアPythonの等価実装,  Prev: 実践的なサンプル,  Up: デスクリプタ ガイド

9.3.3 技術的なチュートリアル
----------------------------

これから先はデスクリプタのメカニズムや動作の詳細について、よりテクニカル
なチュートリアルになります。

* Menu:

* 概要: 概要<5>.
* 定義と導入::
* デスクリプタプロトコル::
* デスクリプタ呼び出しの概要::
* インスタンスからの呼び出し::
* クラスからの呼び出し::
* superからの呼び出し::
* 呼び出しロジックのまとめ::
* 自動的の名前の伝達::
* ORMのサンプル::


File: python.info,  Node: 概要<5>,  Next: 定義と導入,  Up: 技術的なチュートリアル

9.3.3.1 概要
............

デスクリプタの定義、プロトコルのサマリー、デスクリプタがどのように呼び出
されるかの説明、ORマッパーがどのように動作するかのサンプルを提示します。

デスクリプタについて学ぶことにより、新しいツールセットが使えるようになる
だけでなく、Python の仕組みについてのより深い理解が得られます。


File: python.info,  Node: 定義と導入,  Next: デスクリプタプロトコル,  Prev: 概要<5>,  Up: 技術的なチュートリアル

9.3.3.2 定義と導入
..................

一般に、デスクリプタは、デスクリプタプロトコルで定義されたメソッドを持つ
属性値です。このメソッドは、 ‘__get__()’, ‘__set__()’, および
‘__delete__()’ です。これらのメソッドのいずれかが、オブジェクトに定義さ
れていれば、それは *note デスクリプタ: 1ed1. と呼ばれます。

属性アクセスのデフォルトの振る舞いは、オブジェクトの辞書の属性の取得、設
定、削除です。例えば ‘a.x’ は、まず ‘a.__dict__['x']’、それから
‘type(a).__dict__['x']’、さらに ‘type(a)’ のメソッド探索順序に従ったさら
なる探索へと連鎖します。見つかった値が、デスクリプタメソッドのいずれかを
定義しているオブジェクトなら、Python はそのデフォルトの振る舞いをオーバ
ーライドし、代わりにデスクリプタメソッドを呼び出します。これがどの連鎖順
位で行われるかは、どのデスクリプタメソッドが定義されているかに依ります。

Descriptors are a powerful, general purpose protocol.  They are the
mechanism behind properties, methods, static methods, class methods, and
*note super(): 4a8.  They are used throughout Python itself.
Descriptors simplify the underlying C code and offer a flexible set of
new tools for everyday Python programs.


File: python.info,  Node: デスクリプタプロトコル,  Next: デスクリプタ呼び出しの概要,  Prev: 定義と導入,  Up: 技術的なチュートリアル

9.3.3.3 デスクリプタプロトコル
..............................

‘descr.__get__(self, obj, type=None)’

‘descr.__set__(self, obj, value)’

‘descr.__delete__(self, obj)’

これで全てです。これらのメソッドのいずれかを定義すれば、オブジェクトはデ
スクリプタとみなされ、探索された際のデフォルトの振る舞いをオーバーライド
できます。

あるオブジェクトが ‘__set__()’ と ‘__delete__()’ の両方を定義していたら
、それはデータデスクリプタとみなされます。 ‘__get__()’ だけを定義してい
るデスクリプタは、非データデスクリプタと呼ばれます (これらはよくメソッド
に使われますが、他の使い方も出来ます)。

データデスクリプタと非データデスクリプタでは、オーバーライドがインスタン
スの辞書のエントリに関してどのように計算されるかが異なります。インスタン
スの辞書に、データデスクリプタと同名の項目があれば、データデスクリプタの
方が優先されます。インスタンスの辞書に、非データデスクリプタと同名の項目
があれば、辞書の項目の方が優先されます。

読み出し専用のデータデスクリプタを作るには、 ‘__get__()’ と ‘__set__()’
の両方を定義し、 ‘__set__()’ が呼び出されたときに *note AttributeError:
326. が送出されるようにしてください。例外を送出する ‘__set__()’ メソッド
をプレースホルダとして定義すれば、データデスクリプタにするのに十分です。


File: python.info,  Node: デスクリプタ呼び出しの概要,  Next: インスタンスからの呼び出し,  Prev: デスクリプタプロトコル,  Up: 技術的なチュートリアル

9.3.3.4 デスクリプタ呼び出しの概要
..................................

‘desc.__get__(obj)’ や ‘desc.__get__(None, cls)’ を使うとデスクリプタを
直接呼び出すことができます。

しかし、属性アクセスの際に自動的に呼び出されるのが、一般的なデスクリプタ
の呼び出し方法です。

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 *note __dict__: 526, its *note __get__(): 1490. method is
invoked according to the precedence rules listed below.

呼び出しの詳細は、‘obj’ がオブジェクトかクラスか、superのインスタンスか
に依ります。


File: python.info,  Node: インスタンスからの呼び出し,  Next: クラスからの呼び出し,  Prev: デスクリプタ呼び出しの概要,  Up: 技術的なチュートリアル

9.3.3.5 インスタンスからの呼び出し
..................................

名前空間のチェーンの中で行われるインスタンスルックアップでは、データデス
クリプタが最優先で、次にインスタンス変数、その次にノンデータデスクリプタ
、クラス変数、最後に存在したら ‘__getattr__()’ が呼ばれます。

‘a.x’ に対するデスクリプタが見つかった場合、 ‘desc.__get__(a, type(a))’
という形式で呼び出されます。

ドットによるルックアップのロジックは*note object.__getattribute__():
ba0. の中で行われます。ピュアPythonで表した等価なロジックは次の通りです
。

     def find_name_in_mro(cls, name, default):
         "Emulate _PyType_Lookup() in Objects/typeobject.c"
         for base in cls.__mro__:
             if name in vars(base):
                 return vars(base)[name]
         return default

     def object_getattribute(obj, name):
         "Emulate PyObject_GenericGetAttr() in Objects/object.c"
         null = object()
         objtype = type(obj)
         cls_var = find_name_in_mro(objtype, name, null)
         descr_get = getattr(type(cls_var), '__get__', null)
         if descr_get is not null:
             if (hasattr(type(cls_var), '__set__')
                 or hasattr(type(cls_var), '__delete__')):
                 return descr_get(cls_var, obj, objtype)     # data descriptor
         if hasattr(obj, '__dict__') and name in vars(obj):
             return vars(obj)[name]                          # instance variable
         if descr_get is not null:
             return descr_get(cls_var, obj, objtype)         # non-data descriptor
         if cls_var is not null:
             return cls_var                                  # class variable
         raise AttributeError(name)

‘__getattribute__()’ のコードには ‘__getattr__()’ のフックが無いことに注
意してください。このため、直接 ‘__getattribute__()’ を呼び出すか、
‘super().__getattribute__’ で呼び出すと、 ‘__getattr__()’ が完全にバイパ
スされます。

その代わりに、 ‘__getattribute__()’ が *note AttributeError: 326. を発出
したときに ‘__getattr__()’ を呼び出すのは、ドット演算子と *note
getattr(): b9f. の責任です。これらのロジックはヘルパー関数にカプセル化さ
れています:

     def getattr_hook(obj, name):
         "Emulate slot_tp_getattr_hook() in Objects/typeobject.c"
         try:
             return obj.__getattribute__(name)
         except AttributeError:
             if not hasattr(type(obj), '__getattr__'):
                 raise
         return type(obj).__getattr__(obj, name)             # __getattr__


File: python.info,  Node: クラスからの呼び出し,  Next: superからの呼び出し,  Prev: インスタンスからの呼び出し,  Up: 技術的なチュートリアル

9.3.3.6 クラスからの呼び出し
............................

‘A.x’ のようなドットを使ったルックアップのロジックは
‘type.__getattribute__()’ の中にあります。ロジックのステップは *note
object.__getattribute__(): ba0. と似ていますが、インスタンス辞書のルック
アップはクラスの *note method resolution order: 20e5. を通じた探索と置き
換えられています。

‘a.x’ に対するデスクリプタが見つかった場合、 ‘desc.__get__(None, A)’ と
いう形式で呼び出されます。

完全な C での実装は Objects/typeobject.c(1) の中の
:c:func:‘!type_getattro’ と ‘_PyType_Lookup()’ を参照してください。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Objects/typeobject.c


File: python.info,  Node: superからの呼び出し,  Next: 呼び出しロジックのまとめ,  Prev: クラスからの呼び出し,  Up: 技術的なチュートリアル

9.3.3.7 superからの呼び出し
...........................

The logic for super's dotted lookup is in the ‘__getattribute__()’
method for object returned by *note super(): 4a8.

‘super(A, obj).m’ のようなドットを使ったルックアップは
‘obj.__class__.__mro__’ を探索して、 ‘A’ の直前のクラス ‘B’ をまず探し、
‘B.__dict__['m'].__get__(obj, A)’ を返します。もしデスクリプタでなければ
‘m’ を変更せずに返します。

完全な C での実装は Objects/typeobject.c(1) の中の ‘super_getattro()’ を
参照してください。純粋な Python での同等なコードは Guido's Tutorial(2) を
参照してください。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Objects/typeobject.c

   (2) 
https://www.python.org/download/releases/2.2.3/descrintro/#cooperation


File: python.info,  Node: 呼び出しロジックのまとめ,  Next: 自動的の名前の伝達,  Prev: superからの呼び出し,  Up: 技術的なチュートリアル

9.3.3.8 呼び出しロジックのまとめ
................................

The mechanism for descriptors is embedded in the ‘__getattribute__()’
methods for *note object: a5a, *note type: d16, and *note super(): 4a8.

憶えておくべき重要な点は:

   * デスクリプタは ‘__getattribute__()’ メソッドによって呼び出される

   * クラスはこの機構を *note object: a5a. 、 *note type: d16. 、 *note
     super(): 4a8. から継承する

   * すべてのデスクリプタのロジックが ‘__getattribute__()’ にあるため、
     このメソッドをオーバーライドすると、すべての自動的なデスクリプタ呼
     び出しは抑制される

   * *note object.__getattribute__(): ba0. と ‘type.__getattribute__()’
     は ‘__get__()’ の呼び出し方が異なる。前者はインスタンスとおそらくメ
     ソッドを含む。後者はインスタンスとして ‘None’ を渡し、クラスは常に
     渡される

   * データデスクリプタは、必ずインスタンス辞書をオーバーライドする

   * 非データデスクリプタは、インスタンス辞書にオーバーライドされること
     がある


File: python.info,  Node: 自動的の名前の伝達,  Next: ORMのサンプル,  Prev: 呼び出しロジックのまとめ,  Up: 技術的なチュートリアル

9.3.3.9 自動的の名前の伝達
..........................

デスクリプタにとって、自分がアサインされるクラス変数名が知りたいことがあ
ります。新しいクラスが作られると、 *note type: d16. メタクラスは新しいク
ラスの辞書をスキャンします。もし、要素がデスクリプタで、なおかつ
‘__set_name__()’ メソッドを持っている場合、このメソッドは2つの引数を伴っ
て呼び出されます。 'owner' はデスクリプタが使用されたクラスで、 'name' は
デスクリプタがアサインされたクラス変数の名前です。

実装の詳細は Objects/typeobject.c(1) の中の ‘type_new()’ と
‘set_names()’ を参照してください。

更新のロジックは ‘type.__new__()’ にあり、通知はクラス作成のタイミングに
しかありません。もしデスクリプタが後からクラスに追加された場合は、
‘__set_name__()’ を手動で呼び出す必要があるでしょう。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Objects/typeobject.c


File: python.info,  Node: ORMのサンプル,  Prev: 自動的の名前の伝達,  Up: 技術的なチュートリアル

9.3.3.10 ORMのサンプル
......................

以下のコードは、 オブジェクト関係マッピング(1) を実装するのにデータディ
スクリプタを使う方法を示した、簡略化された骨格です。

基本的な考え方は、データが外部のデータベースに保存することです。 Pythonイ
ンスタンスは、データベースのテーブルへのキーのみを保持します。デスクリプ
タがルックアップや更新をします。

     class Field:

         def __set_name__(self, owner, name):
             self.fetch = f'SELECT {name} FROM {owner.table} WHERE {owner.key}=?;'
             self.store = f'UPDATE {owner.table} SET {name}=? WHERE {owner.key}=?;'

         def __get__(self, obj, objtype=None):
             return conn.execute(self.fetch, [obj.key]).fetchone()[0]

         def __set__(self, obj, value):
             conn.execute(self.store, [value, obj.key])
             conn.commit()

‘Field’ クラスを使って、データベースのテーブルごとのスキーマを説明するた
めの モデル(2) を定義します。

     class Movie:
         table = 'Movies'                    # Table name
         key = 'title'                       # Primary key
         director = Field()
         year = Field()

         def __init__(self, key):
             self.key = key

     class Song:
         table = 'Music'
         key = 'title'
         artist = Field()
         year = Field()
         genre = Field()

         def __init__(self, key):
             self.key = key

モデルを使用するにはまずデータベースに接続します:

     >>> import sqlite3
     >>> conn = sqlite3.connect('entertainment.db')

次のインタラクティブセッションでは、データベースからのデータの取得と、更
新方法を示しています。

     >>> Movie('Star Wars').director
     'George Lucas'
     >>> jaws = Movie('Jaws')
     >>> f'Released in {jaws.year} by {jaws.director}'
     'Released in 1975 by Steven Spielberg'

     >>> Song('Country Roads').artist
     'John Denver'

     >>> Movie('Star Wars').director = 'J.J. Abrams'
     >>> Movie('Star Wars').director
     'J.J. Abrams'

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping

   (2) 
https://ja.wikipedia.org/wiki/%E3%83%87%E3%83%BC%E3%82%BF%E3%83%A2%E3%83%87%E3%83%AB


File: python.info,  Node: ピュアPythonの等価実装,  Prev: 技術的なチュートリアル,  Up: デスクリプタ ガイド

9.3.4 ピュアPythonの等価実装
----------------------------

このプロトコルは単純ですが、ワクワクする可能性も秘めています。ユースケー
スの中には、あまりに一般的なので組み込みに追加されたものもあります。プロ
パティ、束縛のメソッド、静的メソッド、クラスメソッド、 __slots__ は、全
てデスクリプタプロトコルに基づいています。

* Menu:

* プロパティ::
* 関数とメソッド::
* メソッドの種類::
* 静的メソッド::
* クラスメソッド::
* メンバーオブジェクトと __slots__::


File: python.info,  Node: プロパティ,  Next: 関数とメソッド,  Up: ピュアPythonの等価実装

9.3.4.1 プロパティ
..................

*note property(): 179. を呼び出すことで、属性へアクセスすると関数の呼び
出しを引き起こす、データデスクリプタを簡潔に組み立てられます。シグネチャ
はこうです:

     property(fget=None, fset=None, fdel=None, doc=None) -> property

このドキュメントでは、管理された属性 ‘x’ を定義する典型的な使用法を示し
ます:

     class C:
         def getx(self): return self.__x
         def setx(self, value): self.__x = value
         def delx(self): del self.__x
         x = property(getx, setx, delx, "I'm the 'x' property.")

To see how *note property(): 179. is implemented in terms of the
descriptor protocol, here is a pure Python equivalent that implements
most of the core functionality:

     class Property:
         "Emulate PyProperty_Type() in Objects/descrobject.c"

         def __init__(self, fget=None, fset=None, fdel=None, doc=None):
             self.fget = fget
             self.fset = fset
             self.fdel = fdel
             if doc is None and fget is not None:
                 doc = fget.__doc__
             self.__doc__ = doc

         def __set_name__(self, owner, name):
             self.__name__ = name

         def __get__(self, obj, objtype=None):
             if obj is None:
                 return self
             if self.fget is None:
                 raise AttributeError
             return self.fget(obj)

         def __set__(self, obj, value):
             if self.fset is None:
                 raise AttributeError
             self.fset(obj, value)

         def __delete__(self, obj):
             if self.fdel is None:
                 raise AttributeError
             self.fdel(obj)

         def getter(self, fget):
             return type(self)(fget, self.fset, self.fdel, self.__doc__)

         def setter(self, fset):
             return type(self)(self.fget, fset, self.fdel, self.__doc__)

         def deleter(self, fdel):
             return type(self)(self.fget, self.fset, fdel, self.__doc__)

組み込みの *note property(): 179. 関数は、ユーザインターフェースへの属性
アクセスが与えられ、続く変更がメソッドの介入を要求するときに役立ちます。

例えば、スプレッドシートクラスが、‘Cell('b10').value’ でセルの値を取得で
きるとします。続く改良により、プログラムがアクセスの度にセルの再計算をす
ることを要求しました。しかしプログラマは、その属性に直接アクセスする既存
のクライアントコードに影響を与えたくありません。この解決策は、property デ
ータデスクリプタ内に値属性へのアクセスをラップすることです:

     class Cell:
         ...

         @property
         def value(self):
             "Recalculate the cell before returning value"
             self.recalc()
             return self._value

組み込みの *note property(): 179. も、この ‘Property()’ も、このサンプル
の中で同じように利用できます。


File: python.info,  Node: 関数とメソッド,  Next: メソッドの種類,  Prev: プロパティ,  Up: ピュアPythonの等価実装

9.3.4.2 関数とメソッド
......................

Python のオブジェクト指向機能は、関数に基づく環境の上に構築されています
。非データデスクリプタを使って、この 2 つはシームレスに組み合わされてい
ます。

クラス辞書に格納された関数は、実行時にメソッドに変換されます。メソッドと
通常の関数はオブジェクトのインスタンスが他の引数よりも前に渡される点だけ
が異なります。監修ではインスタンスは 'self' という名前が使われますが、
'this' や他の変数名も使えます。

メソッドは、ほぼ次のコードと同等な *note types.MethodType: 1764. を使え
ば手動で作れます。

     class MethodType:
         "Emulate PyMethod_Type in Objects/classobject.c"

         def __init__(self, func, obj):
             self.__func__ = func
             self.__self__ = obj

         def __call__(self, *args, **kwargs):
             func = self.__func__
             obj = self.__self__
             return func(obj, *args, **kwargs)

         def __getattribute__(self, name):
             "Emulate method_getset() in Objects/classobject.c"
             if name == '__doc__':
                 return self.__func__.__doc__
             return object.__getattribute__(self, name)

         def __getattr__(self, name):
             "Emulate method_getattro() in Objects/classobject.c"
             return getattr(self.__func__, name)

         def __get__(self, obj, objtype=None):
             "Emulate method_descr_get() in Objects/classobject.c"
             return self

メソッドの自動作成をサポートするには、関数に対し、属性アクセスでメソッド
の束縛に利用される ‘__get__()’ メソッドを追加します。これはつまり、この
関数はドットアクセスされたときに束縛されたメソッドを返す非データデスクリ
プタであることを意味します。次のように動作します。

     class Function:
         ...

         def __get__(self, obj, objtype=None):
             "Simulate func_descr_get() in Objects/funcobject.c"
             if obj is None:
                 return self
             return MethodType(self, obj)

次のクラスをインタプリタを起動すると、この関数デスクリプタが実際にどう働
くかを見られます:

     class D:
         def f(self):
              return self

     class D2:
         pass

この関数はイントロスペクションをサポートするために *note qualified name:
18ab. も持っています。

     >>> D.f.__qualname__
     'D.f'

クラス辞書を通じて関数にアクセスすると ‘__get__()’ が実行されません。そ
のため、裏にある関数オブジェクトをそのまま返します。

     >>> D.__dict__['f']
     <function D.f at 0x00C45070>

クラスのドットアクセスは ‘__get__()’ は呼び出しますが、これも裏にある関
数を変更せずに返します。

     >>> D.f
     <function D.f at 0x00C45070>

インスタンスに対してドットアクセスをすると面白い動作をします。ドットのル
ックアップは、束縛メソッドオブジェクトを返す ‘__get__()’ を呼び出します
。

     >>> d = D()
     >>> d.f
     <bound method D.f of <__main__.D object at 0x00B18C90>>

内部では、束縛メソッドはオリジナルの関数と束縛されたインスタンスを保持し
ています。

     >>> d.f.__func__
     <function D.f at 0x00C45070>

     >>> d.f.__self__
     <__main__.D object at 0x00B18C90>

もし、通常のメソッドの 'self' や、クラスメソッドの 'cls' がどこから来る
の疑問に思っている人がいるとしたら、これがその答えになります！


File: python.info,  Node: メソッドの種類,  Next: 静的メソッド,  Prev: 関数とメソッド,  Up: ピュアPythonの等価実装

9.3.4.3 メソッドの種類
......................

非データデスクリプタは、関数をメソッドに束縛する、各種の一般的なパターン
に、単純な機構を提供します。

まとめると、関数は ‘__get__()’ メソッドを持ち、属性としてアクセスされた
とき、メソッドに変換されます。この非データディスクリプタは、
‘obj.f(*args)’ の呼び出しを ‘f(obj, *args)’ に変換します。
‘cls.f(*args)’ を呼び出すと ‘f(*args)’ になります。

このチャートは、束縛と、その 2 つの異なる便利な形をまとめています:

     変換                  オブジェクトから呼び出さ   クラスから呼び出され
                           れる                       る
                                                      
     ------------------------------------------------------------------------
                                                      
     関数                  f(obj, *args)              f(*args)
                                                      
                                                      
     静的メソッド          f(*args)                   f(*args)
                                                      
                                                      
     クラスメソッド        f(type(obj), *args)        f(cls, *args)
                                                      


File: python.info,  Node: 静的メソッド,  Next: クラスメソッド,  Prev: メソッドの種類,  Up: ピュアPythonの等価実装

9.3.4.4 静的メソッド
....................

静的メソッドは、下にある関数をそのまま返します。 ‘c.f’ や ‘C.f’ は、
‘object.__getattribute__(c, "f")’ や ‘object.__getattribute__(C, "f")’ を
直接探索するのと同じです。結果として、関数はオブジェクトとクラスから同じ
ようにアクセスできます。

静的メソッドにすると良いのは、 ‘self’ 変数への参照を持たないメソッドです
。

For instance, a statistics package may include a container class for
experimental data.  The class provides normal methods for computing the
average, mean, median, and other descriptive statistics that depend on
the data.  However, there may be useful functions which are conceptually
related but do not depend on the data.  For instance, ‘erf(x)’ is handy
conversion routine that comes up in statistical work but does not
directly depend on a particular dataset.  It can be called either from
an object or the class: ‘s.erf(1.5) --> 0.9332’ or ‘Sample.erf(1.5) -->
0.9332’.

静的メソッドは下にある関数をそのまま返すので、呼び出しの例は面白くありま
せん:

     class E:
         @staticmethod
         def f(x):
             return x * 10

     >>> E.f(3)
     30
     >>> E().f(3)
     30

非データデスクリプタプロトコルを使うと、pure Python 版の *note
staticmethod(): 3ef. は以下のようになります:

     import functools

     class StaticMethod:
         "Emulate PyStaticMethod_Type() in Objects/funcobject.c"

         def __init__(self, f):
             self.f = f
             functools.update_wrapper(self, f)

         def __get__(self, obj, objtype=None):
             return self.f

         def __call__(self, *args, **kwds):
             return self.f(*args, **kwds)

*note functools.update_wrapper(): fec. の呼び出しは、根底にある関数を参
照する ‘__wrapped__’ 属性を追加します。また、ラッパーがそのラップされた
関数のように見えるよう、必要な属性を追加します: *note __name__: 12a2. 、
*note __qualname__: 1e5c. 、 *note __doc__: 11a9. 、 *note
__annotations__: 11a8. 。


File: python.info,  Node: クラスメソッド,  Next: メンバーオブジェクトと __slots__,  Prev: 静的メソッド,  Up: ピュアPythonの等価実装

9.3.4.5 クラスメソッド
......................

静的メソッドとは違って、クラスメソッドは関数を呼び出す前にクラス参照を引
数リストの先頭に加えます。このフォーマットは、呼び出し元がオブジェクトで
もクラスでも同じです:

     class F:
         @classmethod
         def f(cls, x):
             return cls.__name__, x

     >>> F.f(3)
     ('F', 3)
     >>> F().f(3)
     ('F', 3)

この振る舞いは、関数がクラス参照のみを必要とし、特定のインスタンスに保存
されたデータに依存しないときに便利です。クラスメソッドの使い方の一つは、
代わりのクラスコンストラクタを作ることです。例えば、クラスメソッド *note
dict.fromkeys(): 219f. は新しい辞書をキーのリストから生成します。等価な
pure Python 版は:

     class Dict(dict):
         @classmethod
         def fromkeys(cls, iterable, value=None):
             "Emulate dict_fromkeys() in Objects/dictobject.c"
             d = cls()
             for key in iterable:
                 d[key] = value
             return d

これで一意なキーを持つ新しい辞書が以下のように構成できます:

     >>> d = Dict.fromkeys('abracadabra')
     >>> type(d) is Dict
     True
     >>> d
     {'a': None, 'b': None, 'r': None, 'c': None, 'd': None}

非データデスクリプタプロトコルを使った、 *note classmethod(): 14c. の
pure Python 版はこのようになります:

     import functools

     class ClassMethod:
         "Emulate PyClassMethod_Type() in Objects/funcobject.c"

         def __init__(self, f):
             self.f = f
             functools.update_wrapper(self, f)

         def __get__(self, obj, cls=None):
             if cls is None:
                 cls = type(obj)
             return MethodType(self.f, cls)

‘ClassMethod’ 内の *note functools.update_wrapper(): fec. の呼び出しは、
根底にある関数を参照する ‘__wrapped__’ 属性を追加します。また、ラッパー
がそのラップされた関数のように見えるよう、必要な属性を追加します: *note
__name__: 12a2. 、 *note __qualname__: 1e5c. 、 *note __doc__: 11a9. 、
*note __annotations__: 11a8. 。


File: python.info,  Node: メンバーオブジェクトと __slots__,  Prev: クラスメソッド,  Up: ピュアPythonの等価実装

9.3.4.6 メンバーオブジェクトと __slots__
........................................

クラスが ‘__slots__’ を定義すると、インスタンスの辞書が固定超のスロット
の値の配列と置き換えられます。ユーザーの目線からみると、いくつかの変化が
あります。

1.  Provides immediate detection of bugs due to misspelled attribute
assignments.  Only attribute names specified in ‘__slots__’ are allowed:

     class Vehicle:
         __slots__ = ('id_number', 'make', 'model')

     >>> auto = Vehicle()
     >>> auto.id_nubmer = 'VYE483814LQEX'
     Traceback (most recent call last):
         ...
     AttributeError: 'Vehicle' object has no attribute 'id_nubmer'

2.  Helps create immutable objects where descriptors manage access to
private attributes stored in ‘__slots__’:

     class Immutable:

         __slots__ = ('_dept', '_name')          # Replace the instance dictionary

         def __init__(self, dept, name):
             self._dept = dept                   # Store to private attribute
             self._name = name                   # Store to private attribute

         @property                               # Read-only descriptor
         def dept(self):
             return self._dept

         @property
         def name(self):                         # Read-only descriptor
             return self._name

     >>> mark = Immutable('Botany', 'Mark Watney')
     >>> mark.dept
     'Botany'
     >>> mark.dept = 'Space Pirate'
     Traceback (most recent call last):
         ...
     AttributeError: property 'dept' of 'Immutable' object has no setter
     >>> mark.location = 'Mars'
     Traceback (most recent call last):
         ...
     AttributeError: 'Immutable' object has no attribute 'location'

3.  Saves memory.  On a 64-bit Linux build, an instance with two
attributes takes 48 bytes with ‘__slots__’ and 152 bytes without.  This
flyweight design pattern(1) likely only matters when a large number of
instances are going to be created.

4.  Improves speed.  Reading instance variables is 35% faster with
‘__slots__’ (as measured with Python 3.10 on an Apple M1 processor).

5.  Blocks tools like *note functools.cached_property(): 50c. which
require an instance dictionary to function correctly:

     from functools import cached_property

     class CP:
         __slots__ = ()                          # Eliminates the instance dict

         @cached_property                        # Requires an instance dict
         def pi(self):
             return 4 * sum((-1.0)**n / (2.0*n + 1.0)
                            for n in reversed(range(100_000)))

     >>> CP().pi
     Traceback (most recent call last):
       ...
     TypeError: No '__dict__' attribute on 'CP' instance to cache 'pi' property.

‘__slots__’ はC構造体に直接アクセスし、オブジェクトのメモリ確保を制御す
る必要があるため、ピュアPythonバージョンを作成することはできません。しか
し、プライベートの ‘__slotvalues’ リストを使ってC構造体のスロットをほぼ
忠実にエミュレートすることはできます。そのプライベートな構造体への読み書
きはメンバーのデスクリプタによって管理されます。

     null = object()

     class Member:

         def __init__(self, name, clsname, offset):
             'Emulate PyMemberDef in Include/structmember.h'
             # Also see descr_new() in Objects/descrobject.c
             self.name = name
             self.clsname = clsname
             self.offset = offset

         def __get__(self, obj, objtype=None):
             'Emulate member_get() in Objects/descrobject.c'
             # Also see PyMember_GetOne() in Python/structmember.c
             if obj is None:
                 return self
             value = obj._slotvalues[self.offset]
             if value is null:
                 raise AttributeError(self.name)
             return value

         def __set__(self, obj, value):
             'Emulate member_set() in Objects/descrobject.c'
             obj._slotvalues[self.offset] = value

         def __delete__(self, obj):
             'Emulate member_delete() in Objects/descrobject.c'
             value = obj._slotvalues[self.offset]
             if value is null:
                 raise AttributeError(self.name)
             obj._slotvalues[self.offset] = null

         def __repr__(self):
             'Emulate member_repr() in Objects/descrobject.c'
             return f'<Member {self.name!r} of {self.clsname!r}>'

‘type.__new__()’ メソッドはクラス変数へのメンバーオブジェクトの追加を処
理します。

     class Type(type):
         'Simulate how the type metaclass adds member objects for slots'

         def __new__(mcls, clsname, bases, mapping, **kwargs):
             'Emulate type_new() in Objects/typeobject.c'
             # type_new() calls PyTypeReady() which calls add_methods()
             slot_names = mapping.get('slot_names', [])
             for offset, name in enumerate(slot_names):
                 mapping[name] = Member(name, clsname, offset)
             return type.__new__(mcls, clsname, bases, mapping, **kwargs)

*note object.__new__(): 54c. メソッドはインスタンス辞書の代わりにスロッ
トを持つインスタンスの作成の処理をします。おおざっぱにピュアPythonでのシ
ミュレーションしたコードがこちらです。

     class Object:
         'Simulate how object.__new__() allocates memory for __slots__'

         def __new__(cls, *args, **kwargs):
             'Emulate object_new() in Objects/typeobject.c'
             inst = super().__new__(cls)
             if hasattr(cls, 'slot_names'):
                 empty_slots = [null] * len(cls.slot_names)
                 object.__setattr__(inst, '_slotvalues', empty_slots)
             return inst

         def __setattr__(self, name, value):
             'Emulate _PyObject_GenericSetAttrWithDict() Objects/object.c'
             cls = type(self)
             if hasattr(cls, 'slot_names') and name not in cls.slot_names:
                 raise AttributeError(
                     f'{cls.__name__!r} object has no attribute {name!r}'
                 )
             super().__setattr__(name, value)

         def __delattr__(self, name):
             'Emulate _PyObject_GenericSetAttrWithDict() Objects/object.c'
             cls = type(self)
             if hasattr(cls, 'slot_names') and name not in cls.slot_names:
                 raise AttributeError(
                     f'{cls.__name__!r} object has no attribute {name!r}'
                 )
             super().__delattr__(name)

実際のクラスでシミュレーションコードを利用するには、 ‘Object’ を継承し、
*note metaclass: 1ee7. を ‘Type’ にします。

     class H(Object, metaclass=Type):
         'Instance variables stored in slots'

         slot_names = ['x', 'y']

         def __init__(self, x, y):
             self.x = x
             self.y = y

この時点ではメタクラスは 'x' と 'y' のメンバーオブジェクトをロードします
。

     >>> from pprint import pp
     >>> pp(dict(vars(H)))
     {'__module__': '__main__',
      '__doc__': 'Instance variables stored in slots',
      'slot_names': ['x', 'y'],
      '__init__': <function H.__init__ at 0x7fb5d302f9d0>,
      'x': <Member 'x' of 'H'>,
      'y': <Member 'y' of 'H'>}

インスタンスが作成されると、属性が保持される ‘slot_values’ のリストをイ
ンスタンスが保持します:

     >>> h = H(10, 20)
     >>> vars(h)
     {'_slotvalues': [10, 20]}
     >>> h.x = 55
     >>> vars(h)
     {'_slotvalues': [55, 20]}

スペルミスや、未アサインの属性は例外を送出します。

     >>> h.xz
     Traceback (most recent call last):
         ...
     AttributeError: 'H' object has no attribute 'xz'

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Flyweight_pattern


File: python.info,  Node: Debugging C API extensions and CPython Internals with GDB,  Next: 列挙型 HOWTO,  Prev: デスクリプタ ガイド,  Up: Python HOWTO

9.4 Debugging C API extensions and CPython Internals with GDB
=============================================================

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.

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.

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 *note
PyObject: 312.* pointer, the extension surfaces the type and value of
the object.

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.

     注釈: This document assumes that you are familiar with the basics
     of GDB and the CPython C API. It consolidates guidance from the
     devguide(1) and the Python wiki(2).

* Menu:

* Prerequisites::
* Using the Debug build and Development mode::
* Using the python-gdb extension::
* Use with GDB commands::

   ---------- Footnotes ----------

   (1) https://devguide.python.org

   (2) https://wiki.python.org/moin/DebuggingWithGdb


File: python.info,  Node: Prerequisites,  Next: Using the Debug build and Development mode,  Up: Debugging C API extensions and CPython Internals with GDB

9.4.1 Prerequisites
-------------------

You need to have:

   - GDB 7 or later.  (For earlier versions of GDB, see ‘Misc/gdbinit’
     in the sources of Python 3.11 or earlier.)

   - GDB-compatible debugging information for Python and any extension
     you are debugging.

   - The ‘python-gdb.py’ extension.

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.

* Menu:

* Setup with Python built from source::
* Setup for Python from a Linux distro::


File: python.info,  Node: Setup with Python built from source,  Next: Setup for Python from a Linux distro,  Up: Prerequisites

9.4.1.1 Setup with Python built from source
...........................................

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.

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.

     注釈: If you do not see instructions for your version of GDB, put
     this in your configuration file (‘~/.gdbinit’ or
     ‘~/.config/gdb/gdbinit’):

          add-auto-load-safe-path /path/to/cpython

     You can also add multiple paths, separated by ‘:’.


File: python.info,  Node: Setup for Python from a Linux distro,  Prev: Setup with Python built from source,  Up: Prerequisites

9.4.1.2 Setup for Python from a Linux distro
............................................

Most Linux systems provide debug information for the system Python in a
package called ‘python-debuginfo’, ‘python-dbg’ or similar.  For
example:

   - Fedora:

               sudo dnf install gdb
               sudo dnf debuginfo-install python3

   - Ubuntu:

               sudo apt install gdb python3-dbg

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.


File: python.info,  Node: Using the Debug build and Development mode,  Next: Using the python-gdb extension,  Prev: Prerequisites,  Up: Debugging C API extensions and CPython Internals with GDB

9.4.2 Using the Debug build and Development mode
------------------------------------------------

For easier debugging, you might want to:

   - Use a *note debug build: 1da. 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.)

   - Use the runtime *note development mode: 1d9. (‘-X dev’).

Both enable extra assertions and disable some optimizations.  Sometimes
this hides the bug you are trying to find, but in most cases they make
the process easier.


File: python.info,  Node: Using the python-gdb extension,  Next: Use with GDB commands,  Prev: Using the Debug build and Development mode,  Up: Debugging C API extensions and CPython Internals with GDB

9.4.3 Using the ‘python-gdb’ extension
--------------------------------------

When the extension is loaded, it provides two main features: pretty
printers for Python values, and additional commands.

* Menu:

* Pretty-printers::
* py-list::
* py-up and py-down::
* py-bt::
* py-print::
* py-locals::


File: python.info,  Node: Pretty-printers,  Next: py-list,  Up: Using the python-gdb extension

9.4.3.1 Pretty-printers
.......................

This is what a GDB backtrace looks like (truncated) when this extension
is enabled:

     #0  0x000000000041a6b1 in PyObject_Malloc (nbytes=Cannot access memory at address 0x7fffff7fefe8
     ) at Objects/obmalloc.c:748
     #1  0x000000000041b7c0 in _PyObject_DebugMallocApi (id=111 'o', nbytes=24) at Objects/obmalloc.c:1445
     #2  0x000000000041b717 in _PyObject_DebugMalloc (nbytes=24) at Objects/obmalloc.c:1412
     #3  0x000000000044060a in _PyUnicode_New (length=11) at Objects/unicodeobject.c:346
     #4  0x00000000004466aa in PyUnicodeUCS2_DecodeUTF8Stateful (s=0x5c2b8d "__lltrace__", size=11, errors=0x0, consumed=
         0x0) at Objects/unicodeobject.c:2531
     #5  0x0000000000446647 in PyUnicodeUCS2_DecodeUTF8 (s=0x5c2b8d "__lltrace__", size=11, errors=0x0)
         at Objects/unicodeobject.c:2495
     #6  0x0000000000440d1b in PyUnicodeUCS2_FromStringAndSize (u=0x5c2b8d "__lltrace__", size=11)
         at Objects/unicodeobject.c:551
     #7  0x0000000000440d94 in PyUnicodeUCS2_FromString (u=0x5c2b8d "__lltrace__") at Objects/unicodeobject.c:569
     #8  0x0000000000584abd in PyDict_GetItemString (v=
         {'Yuck': <type at remote 0xad4730>, '__builtins__': <module at remote 0x7ffff7fd5ee8>, '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', '__package__': None, 'y': <Yuck(i=0) at remote 0xaacd80>, 'dict': {0: 0, 1: 1, 2: 2, 3: 3}, '__cached__': None, '__name__': '__main__', 'z': <Yuck(i=0) at remote 0xaace60>, '__doc__': None}, key=
         0x5c2b8d "__lltrace__") at Objects/dictobject.c:2171

Notice how the dictionary argument to ‘PyDict_GetItemString’ is
displayed as its ‘repr()’, rather than an opaque ‘PyObject *’ pointer.

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:

     (gdb) p globals
     $1 = {'__builtins__': <module at remote 0x7ffff7fb1868>, '__name__':
     '__main__', 'ctypes': <module at remote 0x7ffff7f14360>, '__doc__': None,
     '__package__': None}

     (gdb) p *(PyDictObject*)globals
     $2 = {ob_refcnt = 3, ob_type = 0x3dbdf85820, ma_fill = 5, ma_used = 5,
     ma_mask = 7, ma_table = 0x63d0f8, ma_lookup = 0x3dbdc7ea70
     <lookdict_string>, ma_smalltable = {{me_hash = 7065186196740147912,
     me_key = '__builtins__', me_value = <module at remote 0x7ffff7fb1868>},
     {me_hash = -368181376027291943, me_key = '__name__',
     me_value ='__main__'}, {me_hash = 0, me_key = 0x0, me_value = 0x0},
     {me_hash = 0, me_key = 0x0, me_value = 0x0},
     {me_hash = -9177857982131165996, me_key = 'ctypes',
     me_value = <module at remote 0x7ffff7f14360>},
     {me_hash = -8518757509529533123, me_key = '__doc__', me_value = None},
     {me_hash = 0, me_key = 0x0, me_value = 0x0}, {
       me_hash = 6614918939584953775, me_key = '__package__', me_value = None}}}

Note that the pretty-printers do not actually call ‘repr()’.  For basic
types, they try to match its result closely.

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 pretty-printer for a Python ‘int’ (*note PyLongObject: 554.*) gives
a representation that is not distinguishable from one of a regular
machine-level integer:

     (gdb) p some_machine_integer
     $3 = 42

     (gdb) p some_python_integer
     $4 = 42

The internal structure can be revealed with a cast to *note
PyLongObject: 554.*:

     (gdb) p '(PyLongObject')some_python_integer $5 = {ob_base =
     {ob_base = {ob_refcnt = 8, ob_type = 0x3dad39f5e0}, ob_size = 1},
     ob_digit = {42}}

A similar confusion can arise with the ‘str’ type, where the output
looks a lot like gdb's built-in printer for ‘char *’:

     (gdb) p ptr_to_python_str
     $6 = '__builtins__'

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:

     (gdb) p ptr_to_char_star
     $7 = 0x6d72c0 "hello world"

Again, the implementation details can be revealed with a cast to *note
PyUnicodeObject: 75f.*:

     (gdb) p *(PyUnicodeObject*)$6
     $8 = {ob_base = {ob_refcnt = 33, ob_type = 0x3dad3a95a0}, length = 12,
     str = 0x7ffff2128500, hash = 7065186196740147912, state = 1, defenc = 0x0}


File: python.info,  Node: py-list,  Next: py-up and py-down,  Prev: Pretty-printers,  Up: Using the python-gdb extension

9.4.3.2 ‘py-list’
.................

     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 ">":

          (gdb) py-list
           901        if options.profile:
           902            options.profile = False
           903            profile_me()
           904            return
           905
          >906        u = UI()
           907        if not u.quit:
           908            try:
           909                gtk.main()
           910            except KeyboardInterrupt:
           911                # properly quit on a keyboard interrupt...

     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.


File: python.info,  Node: py-up and py-down,  Next: py-bt,  Prev: py-list,  Up: Using the python-gdb extension

9.4.3.3 ‘py-up’ and ‘py-down’
.............................

     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.

     GDB is not always able to read the relevant frame information,
     depending on the optimization level with which CPython was
     compiled.  Internally, the commands look for C frames that are
     executing the default frame evaluation function (that is, the core
     bytecode interpreter loop within CPython) and look up the value of
     the related ‘PyFrameObject *’.

     They emit the frame number (at the C level) within the thread.

     例えば:

          (gdb) py-up
          #37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/
          gnome_sudoku/main.py, line 906, in start_game ()
              u = UI()
          (gdb) py-up
          #40 Frame 0x948e82c, for file /usr/lib/python2.6/site-packages/
          gnome_sudoku/gnome_sudoku.py, line 22, in start_game(main=<module at remote 0xb771b7f4>)
              main.start_game()
          (gdb) py-up
          Unable to find an older python frame

     so we're at the top of the Python stack.

     The frame numbers correspond to those displayed by GDB's standard
     ‘backtrace’ command.  The command skips C frames which are not
     executing Python code.

     Going back down:

          (gdb) py-down
          #37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/gnome_sudoku/main.py, line 906, in start_game ()
              u = UI()
          (gdb) py-down
          #34 (unable to read python frame information)
          (gdb) py-down
          #23 (unable to read python frame information)
          (gdb) py-down
          #19 (unable to read python frame information)
          (gdb) py-down
          #14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/game_selector.py, line 201, in run_swallowed_dialog (self=<NewOrSavedGameSelector(new_game_model=<gtk.ListStore at remote 0x98fab44>, 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__': <float at remote 0x984b474>, 'gsd.hints': 0, 'timer.active_time': <float at remote 0x984b494>, 'timer.total_time': <float at remote 0x984b464>}], dialog=<gtk.Dialog at remote 0x98faaa4>, saved_game_model=<gtk.ListStore at remote 0x98fad24>, sudoku_maker=<SudokuMaker(terminated=False, played=[], batch_siz...(truncated)
                      swallower.run_dialog(self.dialog)
          (gdb) py-down
          #11 Frame 0x9aead74, for file /usr/lib/python2.6/site-packages/gnome_sudoku/dialog_swallower.py, line 48, in run_dialog (self=<SwappableArea(running=<gtk.Dialog at remote 0x98faaa4>, main_page=0) at remote 0x98fa6e4>, d=<gtk.Dialog at remote 0x98faaa4>)
                      gtk.main()
          (gdb) py-down
          #8 (unable to read python frame information)
          (gdb) py-down
          Unable to find a newer python frame

     and we're at the bottom of the Python stack.

     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:

          (gdb) py-up
          #6 Frame 0x7ffff7fb62b0, for file /tmp/rec.py, line 5, in recursive_function (n=0)
             time.sleep(5)
          #6 Frame 0x7ffff7fb6240, for file /tmp/rec.py, line 7, in recursive_function (n=1)
             recursive_function(n-1)
          #6 Frame 0x7ffff7fb61d0, for file /tmp/rec.py, line 7, in recursive_function (n=2)
             recursive_function(n-1)
          #6 Frame 0x7ffff7fb6160, for file /tmp/rec.py, line 7, in recursive_function (n=3)
             recursive_function(n-1)
          #6 Frame 0x7ffff7fb60f0, for file /tmp/rec.py, line 7, in recursive_function (n=4)
             recursive_function(n-1)
          #6 Frame 0x7ffff7fb6080, for file /tmp/rec.py, line 7, in recursive_function (n=5)
             recursive_function(n-1)
          #6 Frame 0x7ffff7fb6020, for file /tmp/rec.py, line 9, in <module> ()
             recursive_function(5)
          (gdb) py-up
          Unable to find an older python frame


File: python.info,  Node: py-bt,  Next: py-print,  Prev: py-up and py-down,  Up: Using the python-gdb extension

9.4.3.4 ‘py-bt’
...............

     The ‘py-bt’ command attempts to display a Python-level backtrace of
     the current thread.

     例えば:

          (gdb) py-bt
          #8 (unable to read python frame information)
          #11 Frame 0x9aead74, for file /usr/lib/python2.6/site-packages/gnome_sudoku/dialog_swallower.py, line 48, in run_dialog (self=<SwappableArea(running=<gtk.Dialog at remote 0x98faaa4>, main_page=0) at remote 0x98fa6e4>, d=<gtk.Dialog at remote 0x98faaa4>)
                      gtk.main()
          #14 Frame 0x99262ac, for file /usr/lib/python2.6/site-packages/gnome_sudoku/game_selector.py, line 201, in run_swallowed_dialog (self=<NewOrSavedGameSelector(new_game_model=<gtk.ListStore at remote 0x98fab44>, 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__': <float at remote 0x984b474>, 'gsd.hints': 0, 'timer.active_time': <float at remote 0x984b494>, 'timer.total_time': <float at remote 0x984b464>}], dialog=<gtk.Dialog at remote 0x98faaa4>, saved_game_model=<gtk.ListStore at remote 0x98fad24>, sudoku_maker=<SudokuMaker(terminated=False, played=[], batch_siz...(truncated)
                      swallower.run_dialog(self.dialog)
          #19 (unable to read python frame information)
          #23 (unable to read python frame information)
          #34 (unable to read python frame information)
          #37 Frame 0x9420b04, for file /usr/lib/python2.6/site-packages/gnome_sudoku/main.py, line 906, in start_game ()
              u = UI()
          #40 Frame 0x948e82c, for file /usr/lib/python2.6/site-packages/gnome_sudoku/gnome_sudoku.py, line 22, in start_game (main=<module at remote 0xb771b7f4>)
              main.start_game()

     The frame numbers correspond to those displayed by GDB's standard
     ‘backtrace’ command.


File: python.info,  Node: py-print,  Next: py-locals,  Prev: py-bt,  Up: Using the python-gdb extension

9.4.3.5 ‘py-print’
..................

     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:

          (gdb) py-print self
          local 'self' = <SwappableArea(running=<gtk.Dialog at remote 0x98faaa4>,
          main_page=0) at remote 0x98fa6e4>
          (gdb) py-print __name__
          global '__name__' = 'gnome_sudoku.dialog_swallower'
          (gdb) py-print len
          builtin 'len' = <built-in function len>
          (gdb) py-print scarlet_pimpernel
          'scarlet_pimpernel' not found

     If the current C frame corresponds to multiple Python frames,
     ‘py-print’ only considers the first one.


File: python.info,  Node: py-locals,  Prev: py-print,  Up: Using the python-gdb extension

9.4.3.6 ‘py-locals’
...................

     The ‘py-locals’ command looks up all Python locals within the
     current Python frame in the selected thread, and prints their
     representations:

          (gdb) py-locals
          self = <SwappableArea(running=<gtk.Dialog at remote 0x98faaa4>,
          main_page=0) at remote 0x98fa6e4>
          d = <gtk.Dialog at remote 0x98faaa4>

     If the current C frame corresponds to multiple Python frames,
     locals from all of them will be shown:

          (gdb) py-locals
          Locals for recursive_function
          n = 0
          Locals for recursive_function
          n = 1
          Locals for recursive_function
          n = 2
          Locals for recursive_function
          n = 3
          Locals for recursive_function
          n = 4
          Locals for recursive_function
          n = 5
          Locals for <module>


File: python.info,  Node: Use with GDB commands,  Prev: Using the python-gdb extension,  Up: Debugging C API extensions and CPython Internals with GDB

9.4.4 Use with GDB commands
---------------------------

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:

     (gdb) py-bt
     (output snipped)
     #68 Frame 0xaa4560, for file Lib/test/regrtest.py, line 1548, in <module> ()
             main()
     (gdb) frame 68
     #68 0x00000000004cd1e6 in PyEval_EvalFrameEx (f=Frame 0xaa4560, for file Lib/test/regrtest.py, line 1548, in <module> (), throwflag=0) at Python/ceval.c:2665
     2665                            x = call_function(&sp, oparg);
     (gdb) py-list
     1543        # Run the tests in a context manager that temporary changes the CWD to a
     1544        # temporary and writable directory. If it's not possible to create or
     1545        # change the CWD, the original CWD will be used. The original CWD is
     1546        # available from test_support.SAVEDCWD.
     1547        with test_support.temp_cwd(TESTCWD, quiet=True):
     >1548            main()

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:

     (gdb) info threads
       105 Thread 0x7fffefa18710 (LWP 10260)  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
       104 Thread 0x7fffdf5fe710 (LWP 10259)  sem_wait () at ../nptl/sysdeps/unix/sysv/linux/x86_64/sem_wait.S:86
     * 1 Thread 0x7ffff7fe2700 (LWP 10145)  0x00000038e46d73e3 in select () at ../sysdeps/unix/syscall-template.S:82

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:

     (gdb) t a a py-bt

     Thread 105 (Thread 0x7fffefa18710 (LWP 10260)):
     #5 Frame 0x7fffd00019d0, 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=<thread.lock at remote 0x858770>, _RLock__count=1) at remote 0xd7ff40>, count_owner=(1, 140737213728528), count=1, owner=140737213728528)
             self.__block.acquire()
     #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=<thread.lock at remote 0x858770>, _RLock__count=1) at remote 0xd7ff40>, acquire=<instancemethod at remote 0xd80260>, _is_owned=<instancemethod at remote 0xd80160>, _release_save=<instancemethod at remote 0xd803e0>, release=<instancemethod at remote 0xd802e0>, _acquire_restore=<instancemethod at remote 0xd7ee60>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, timeout=None, waiter=<thread.lock at remote 0x858a90>, saved_state=(1, 140737213728528))
                 self._acquire_restore(saved_state)
     #12 Frame 0x7fffb8001a10, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 348, in f ()
                 cond.wait()
     #16 Frame 0x7fffb8001c40, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 37, in task (tid=140737213728528)
                     f()

     Thread 104 (Thread 0x7fffdf5fe710 (LWP 10259)):
     #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=<thread.lock at remote 0x858770>, _RLock__count=1) at remote 0xd7ff40>, count_owner=(1, 140736940992272), count=1, owner=140736940992272)
             self.__block.acquire()
     #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=<thread.lock at remote 0x858770>, _RLock__count=1) at remote 0xd7ff40>, acquire=<instancemethod at remote 0xd80260>, _is_owned=<instancemethod at remote 0xd80160>, _release_save=<instancemethod at remote 0xd803e0>, release=<instancemethod at remote 0xd802e0>, _acquire_restore=<instancemethod at remote 0xd7ee60>, _Verbose__verbose=False, _Condition__waiters=[]) at remote 0xd7fd10>, timeout=None, waiter=<thread.lock at remote 0x858860>, saved_state=(1, 140736940992272))
                 self._acquire_restore(saved_state)
     #12 Frame 0x7fffac001c90, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 348, in f ()
                 cond.wait()
     #16 Frame 0x7fffac0011c0, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 37, in task (tid=140736940992272)
                     f()

     Thread 1 (Thread 0x7ffff7fe2700 (LWP 10145)):
     #5 Frame 0xcb5380, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 16, in _wait ()
         time.sleep(0.01)
     #8 Frame 0x7fffd00024a0, for file /home/david/coding/python-svn/Lib/test/lock_tests.py, line 378, in _check_notify (self=<ConditionTests(_testMethodName='test_notify', _resultForDoCleanups=<TestResult(_original_stdout=<cStringIO.StringO at remote 0xc191e0>, skipped=[], _mirrorOutput=False, testsRun=39, buffer=False, _original_stderr=<file at remote 0x7ffff7fc6340>, _stdout_buffer=<cStringIO.StringO at remote 0xc9c7f8>, _stderr_buffer=<cStringIO.StringO at remote 0xc9c790>, _moduleSetUpFailed=False, expectedFailures=[], errors=[], _previousTestClass=<type at remote 0x928310>, unexpectedSuccesses=[], failures=[], shouldStop=False, failfast=False) at remote 0xc185a0>, _threads=(0,), _cleanups=[], _type_equality_funcs={<type at remote 0x7eba00>: <instancemethod at remote 0xd750e0>, <type at remote 0x7e7820>: <instancemethod at remote 0xd75160>, <type at remote 0x7e30e0>: <instancemethod at remote 0xd75060>, <type at remote 0x7e7d20>: <instancemethod at remote 0xd751e0>, <type at remote 0x7f19e0...(truncated)
             _wait()


File: python.info,  Node: 列挙型 HOWTO,  Next: 関数型プログラミング HOWTO,  Prev: Debugging C API extensions and CPython Internals with GDB,  Up: Python HOWTO

9.5 列挙型 HOWTO
================

*note Enum: 5fc. は、ユニークな値に束縛されたシンボル名の集合です。グロ
ーバル変数に似ていますが、 *note repr(): 7c8. がより便利だったり、グルー
ピングの機能、型安全などいくつかの機能があります。

これらは、限られた選択肢の値の一つを取る変数がある場合に便利です。例えば
、曜日情報があります:

     >>> from enum import Enum
     >>> class Weekday(Enum):
     ...     MONDAY = 1
     ...     TUESDAY = 2
     ...     WEDNESDAY = 3
     ...     THURSDAY = 4
     ...     FRIDAY = 5
     ...     SATURDAY = 6
     ...     SUNDAY = 7

あるいは、RGB三原色でも構いません:

     >>> from enum import Enum
     >>> class Color(Enum):
     ...     RED = 1
     ...     GREEN = 2
     ...     BLUE = 3

ご覧の通り、 *note Enum: 5fc. の作成は *note Enum: 5fc. 自体を継承するク
ラスを作成するのと同じくらい簡単です。

     注釈: Enumメンバーは大文字/小文字？

     列挙型は定数を表すために使われるため、また mixin クラスのメソッドや
     属性との名前の衝突の問題を回避するため、メンバには UPPER_CASE の名
     前を使うことが強く推奨されており、例でもこのスタイルを用います。

列挙型の性質によって、メンバの値は重要な場合とそうでない場合がありますが
、いずれの場合でも、その値は対応するメンバを取得するのに使えます:

     >>> Weekday(3)
     <Weekday.WEDNESDAY: 3>

ご覧の通り、メンバの ‘repr()’ は列挙型の名前、メンバの名前、そして値を表
示します。メンバの ‘str()’ は列挙型の名前とメンバの名前のみを表示します
。

     >>> print(Weekday.THURSDAY)
     Weekday.THURSDAY

列挙型のメンバの型はそのメンバの属する列挙型です:

     >>> type(Weekday.MONDAY)
     <enum 'Weekday'>
     >>> isinstance(Weekday.FRIDAY, Weekday)
     True

列挙型のメンバはその名前だけを含む属性 ‘name’ を持っています:

     >>> print(Weekday.TUESDAY.name)
     TUESDAY

同じように、値のための属性 ‘value’ もあります:

     >>> Weekday.WEDNESDAY.value
     3

多くの言語で列挙を名前と値のペアとしてのみ扱うのとは異なり、Pythonの列挙
は振る舞いを追加することができます。 例えば、 *note datetime.date: 1af.
には曜日を返すメソッドに ‘weekday()’ と ‘isoweekday()’ の2つがあります。
違いは、一方は0から6まで、もう一方は1から7まで数えることです。自分たちで
それらのメソッドの挙動を理解しておく代わりに、‘Weekday’ 列挙型にメソッド
を追加することで、 ‘date’ インスタンス から曜日を抽出し、それにマッチす
るenumメンバーを返すことができます:

     @classmethod
     def from_date(cls, date):
         return cls(date.isoweekday())

完全な ‘Weekday’ enumはこのようになります:

     >>> class Weekday(Enum):
     ...     MONDAY = 1
     ...     TUESDAY = 2
     ...     WEDNESDAY = 3
     ...     THURSDAY = 4
     ...     FRIDAY = 5
     ...     SATURDAY = 6
     ...     SUNDAY = 7
     ...     #
     ...     @classmethod
     ...     def from_date(cls, date):
     ...         return cls(date.isoweekday())

さて、これで今日が何曜日か調べることができます！ 見てみましょう:

     >>> from datetime import date
     >>> Weekday.from_date(date.today())
     <Weekday.TUESDAY: 2>

もちろん、あなたがこれを読んでいるのが他の曜日ならば、その曜日が代わりに
表示されます。

この ‘Weekday’ 列挙型は、変数が1つの曜日を必要とする場合には優れています
が、複数必要な場合はどうでしょうか？ 1週間の家事を記録する関数を作成して
いて、*note list: 5dc. は使いたくない場合、別の型の *note Enum: 5fc. を
使用することができます:

     >>> from enum import Flag
     >>> class Weekday(Flag):
     ...     MONDAY = 1
     ...     TUESDAY = 2
     ...     WEDNESDAY = 4
     ...     THURSDAY = 8
     ...     FRIDAY = 16
     ...     SATURDAY = 32
     ...     SUNDAY = 64

ここでは2つの変更が行われています。*note Flag: 5ef. を継承している点と、
値がすべて2の累乗である点です。

元々の ‘Weekday’ 列挙型と同じように、1つの要素を持つことができます:

     >>> first_week_day = Weekday.MONDAY
     >>> first_week_day
     <Weekday.MONDAY: 1>

ただし、*note Flag: 5ef. は複数のメンバーをひとつの変数にまとめることも
できます:

     >>> weekend = Weekday.SATURDAY | Weekday.SUNDAY
     >>> weekend
     <Weekday.SATURDAY|SUNDAY: 96>

*note Flag: 5ef. 変数は反復することもできます:

     >>> for day in weekend:
     ...     print(day)
     Weekday.SATURDAY
     Weekday.SUNDAY

さて、いくつかの家事を設定してみましょう:

     >>> chores_for_ethan = {
     ...     'feed the cat': Weekday.MONDAY | Weekday.WEDNESDAY | Weekday.FRIDAY,
     ...     'do the dishes': Weekday.TUESDAY | Weekday.THURSDAY,
     ...     'answer SO questions': Weekday.SATURDAY,
     ...     }

指定された日の家事を表示する関数も作成します:

     >>> def show_chores(chores, day):
     ...     for chore, days in chores.items():
     ...         if day in days:
     ...             print(chore)
     ...
     >>> show_chores(chores_for_ethan, Weekday.SATURDAY)
     answer SO questions

メンバーの実際の値が重要でない場合は、*note auto(): c6a. を使用すること
で手間を省くことができます:

     >>> from enum import auto
     >>> class Weekday(Flag):
     ...     MONDAY = auto()
     ...     TUESDAY = auto()
     ...     WEDNESDAY = auto()
     ...     THURSDAY = auto()
     ...     FRIDAY = auto()
     ...     SATURDAY = auto()
     ...     SUNDAY = auto()
     ...     WEEKEND = SATURDAY | SUNDAY

* Menu:

* 列挙型メンバーおよびそれらの属性へのプログラム的アクセス::
* 列挙型メンバーと値の重複::
* 番号付けの値が一意であることの確認::
* 値の自動設定を使う::
* イテレーション: イテレーション<2>.
* 比較: 比較<3>.
* 列挙型で許されるメンバーと属性::
* Enumのサブクラス化の制限::
* データクラスのサポート::
* Pickle 化::
* 関数 API: 関数 API<2>.
* 派生列挙型::
* __new__() と __init__() のどちらを使うべきか: __new__ と __init__ のどちらを使うべきか.
* EnumとFlagはどう違うのか？::
* Enum クックブック::
* EnumType のサブクラスを作る::


File: python.info,  Node: 列挙型メンバーおよびそれらの属性へのプログラム的アクセス,  Next: 列挙型メンバーと値の重複,  Up: 列挙型 HOWTO

9.5.1 列挙型メンバーおよびそれらの属性へのプログラム的アクセス
--------------------------------------------------------------

プログラム的にメンバーに番号でアクセスしたほうが便利な場合があります (す
なわち、プログラムを書いている時点で正確な色がまだわからなく、
‘Color.RED’ と書くのが無理な場合など)。 ‘Enum’ ではそのようなアクセスも
可能です:

     >>> Color(1)
     <Color.RED: 1>
     >>> Color(3)
     <Color.BLUE: 3>

列挙型メンバーに '名前' でアクセスしたい場合はアイテムとしてアクセスでき
ます:

     >>> Color['RED']
     <Color.RED: 1>
     >>> Color['GREEN']
     <Color.GREEN: 2>

列挙型メンバーの ‘name’ か ‘value’ が必要な場合:

     >>> member = Color.RED
     >>> member.name
     'RED'
     >>> member.value
     1


File: python.info,  Node: 列挙型メンバーと値の重複,  Next: 番号付けの値が一意であることの確認,  Prev: 列挙型メンバーおよびそれらの属性へのプログラム的アクセス,  Up: 列挙型 HOWTO

9.5.2 列挙型メンバーと値の重複
------------------------------

同じ名前の列挙型メンバーを複数持つことはできません:

     >>> class Shape(Enum):
     ...     SQUARE = 2
     ...     SQUARE = 3
     ...
     Traceback (most recent call last):
     ...
     TypeError: 'SQUARE' already defined as 2

しかし、列挙型メンバー は、別の名前を持つことができます。 同じ値を持つ
‘A’ と''B'' が与えられた場合（そして ‘A’ が先に定義されている場合）、
‘B’ はメンバー ‘A’ に対するエイリアスとなります。 ‘A’ の値での検索では、
メンバー ‘A’ が返されます。 ‘A’ の名前での検索ではメンバー ‘A’ を返しま
す。‘B’ の名前での検索も、メンバー ‘A’ を返します:

     >>> class Shape(Enum):
     ...     SQUARE = 2
     ...     DIAMOND = 1
     ...     CIRCLE = 3
     ...     ALIAS_FOR_SQUARE = 2
     ...
     >>> Shape.SQUARE
     <Shape.SQUARE: 2>
     >>> Shape.ALIAS_FOR_SQUARE
     <Shape.SQUARE: 2>
     >>> Shape(2)
     <Shape.SQUARE: 2>

     注釈: すでに定義されている属性と同じ名前のメンバー (一方がメンバー
     でもう一方がメソッド、など) の作成、あるいはメンバーと同じ名前の属
     性の作成はできません。


File: python.info,  Node: 番号付けの値が一意であることの確認,  Next: 値の自動設定を使う,  Prev: 列挙型メンバーと値の重複,  Up: 列挙型 HOWTO

9.5.3 番号付けの値が一意であることの確認
----------------------------------------

デフォルトでは、列挙型は同じ値のエイリアスとして複数の名前を許容します。
この振る舞いを望まない場合は、 *note unique(): 250c. デコレータを使用で
きます:

     >>> from enum import Enum, unique
     >>> @unique
     ... class Mistake(Enum):
     ...     ONE = 1
     ...     TWO = 2
     ...     THREE = 3
     ...     FOUR = 3
     ...
     Traceback (most recent call last):
     ...
     ValueError: duplicate values found in <enum 'Mistake'>: FOUR -> THREE


File: python.info,  Node: 値の自動設定を使う,  Next: イテレーション<2>,  Prev: 番号付けの値が一意であることの確認,  Up: 列挙型 HOWTO

9.5.4 値の自動設定を使う
------------------------

正確な値が重要でない場合、 *note auto: c6a. が使えます:

     >>> from enum import Enum, auto
     >>> class Color(Enum):
     ...     RED = auto()
     ...     BLUE = auto()
     ...     GREEN = auto()
     ...
     >>> [member.value for member in Color]
     [1, 2, 3]

その値は ‘_generate_next_value_()’ によって選ばれ、この関数はオーバーラ
イドできます:

     >>> class AutoName(Enum):
     ...     @staticmethod
     ...     def _generate_next_value_(name, start, count, last_values):
     ...         return name
     ...
     >>> class Ordinal(AutoName):
     ...     NORTH = auto()
     ...     SOUTH = auto()
     ...     EAST = auto()
     ...     WEST = auto()
     ...
     >>> [member.value for member in Ordinal]
     ['NORTH', 'SOUTH', 'EAST', 'WEST']

     注釈: ‘_generate_next_value_()’ メソッドは他のメンバーよりも前に定
     義される必要があります。


File: python.info,  Node: イテレーション<2>,  Next: 比較<3>,  Prev: 値の自動設定を使う,  Up: 列挙型 HOWTO

9.5.5 イテレーション
--------------------

列挙型のメンバーのイテレートは別名をサポートしていません:

     >>> list(Shape)
     [<Shape.SQUARE: 2>, <Shape.DIAMOND: 1>, <Shape.CIRCLE: 3>]
     >>> list(Weekday)
     [<Weekday.MONDAY: 1>, <Weekday.TUESDAY: 2>, <Weekday.WEDNESDAY: 4>, <Weekday.THURSDAY: 8>, <Weekday.FRIDAY: 16>, <Weekday.SATURDAY: 32>, <Weekday.SUNDAY: 64>]

エイリアスである ‘Shape.ALIAS_FOR_SQUARE’ と''Weekday.WEEKEND'' が表示さ
れていないことに注意してください。

特殊属性 ‘__members__’ は読み出し専用で、順序を保持した、対応する名前と
列挙型メンバーのマッピングです。これには別名も含め、列挙されたすべての名
前が入っています。

     >>> for name, member in Shape.__members__.items():
     ...     name, member
     ...
     ('SQUARE', <Shape.SQUARE: 2>)
     ('DIAMOND', <Shape.DIAMOND: 1>)
     ('CIRCLE', <Shape.CIRCLE: 3>)
     ('ALIAS_FOR_SQUARE', <Shape.SQUARE: 2>)

属性 ‘__members__’ は列挙型メンバーへの詳細なアクセスに使用できます。以
下はすべての別名を探す例です:

     >>> [name for name, member in Shape.__members__.items() if member.name != name]
     ['ALIAS_FOR_SQUARE']

     注釈: フラグのエイリアスには、 複数のフラグが設定された値（例えば
     ‘3’）や、 フラグが設定されていない値（例えば ‘0’）が含まれます。


File: python.info,  Node: 比較<3>,  Next: 列挙型で許されるメンバーと属性,  Prev: イテレーション<2>,  Up: 列挙型 HOWTO

9.5.6 比較
----------

列挙型メンバーは同一性を比較できます:

     >>> Color.RED is Color.RED
     True
     >>> Color.RED is Color.BLUE
     False
     >>> Color.RED is not Color.BLUE
     True

列挙型の値の順序の比較はサポートされて 'いません'。Enum メンバーは整数で
はありません (*note IntEnum: 4d5d. を参照してください):

     >>> Color.RED < Color.BLUE
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: '<' not supported between instances of 'Color' and 'Color'

ただし等価の比較は定義されています:

     >>> Color.BLUE == Color.RED
     False
     >>> Color.BLUE != Color.RED
     True
     >>> Color.BLUE == Color.BLUE
     True

非列挙型の値との比較は常に不等となります (繰り返しになりますが、*note
IntEnum: cad. はこれと異なる挙動になるよう設計されています):

     >>> Color.BLUE == 2
     False

     警告: モジュールは再読み込みすることが可能です。再読み込みされたモ
     ジュールに列挙型が含まれている場合、それらは再作成され、新しいメン
     バーは元のメンバーと同一でない/等しくない可能性があります。


File: python.info,  Node: 列挙型で許されるメンバーと属性,  Next: Enumのサブクラス化の制限,  Prev: 比較<3>,  Up: 列挙型 HOWTO

9.5.7 列挙型で許されるメンバーと属性
------------------------------------

これまでのほとんどの例では、列挙型の値に整数を使用しています。 整数を使
うのは短くて便利（そして、 *note 関数 API: 4d5f. ではデフォルトで設定さ
れる）ですが、これは強制されているわけではありません。大半の使用例では、
列挙値の実際の値が何であるかは意識しません。しかし、値が重要な場合、列挙
型は任意の値を持つことができます。

列挙型は Python のクラスであり、通常どおりメソッドや特殊メソッドを持つこ
とができます:

     >>> class Mood(Enum):
     ...     FUNKY = 1
     ...     HAPPY = 3
     ...
     ...     def describe(self):
     ...         # self is the member here
     ...         return self.name, self.value
     ...
     ...     def __str__(self):
     ...         return 'my custom str! {0}'.format(self.value)
     ...
     ...     @classmethod
     ...     def favorite_mood(cls):
     ...         # cls here is the enumeration
     ...         return cls.HAPPY
     ...

上記の結果が以下のようになります:

     >>> Mood.favorite_mood()
     <Mood.HAPPY: 3>
     >>> Mood.HAPPY.describe()
     ('HAPPY', 3)
     >>> str(Mood.FUNKY)
     'my custom str! 1'

何が許されているかのルールは次のとおりです。先頭と末尾が 1 個のアンダー
スコアの名前は列挙型により予約されているため、使用できません。列挙型内で
定義されたその他すべての名前は、その列挙型のメンバーとして使用できます。
特殊メソッド (‘__str__()’, ‘__add__()’ など) と、メソッドを含むデスクリ
プタ(記述子)、 ‘_ignore_’ に記載されている変数名は例外です。

注意：列挙型で ‘__new__()’ および/または ‘__init__()’ を定義している場合
、列挙型メンバーに与えられた値は、それらのメソッドに渡されます。例につい
ては *note Planet: 4d60. を参照してください。

     注釈: ‘__new__()’ メソッドが定義されていれば、Enum 番号の作成時に使
     用されます; これは Enum の ‘__new__()’ と置き換えられ、クラスが作成
     された後の既存の番号を取得に使用されます。詳細は *note __new__() と
     __init__() のどちらを使うべきか: 4d61. を参照してください。


File: python.info,  Node: Enumのサブクラス化の制限,  Next: データクラスのサポート,  Prev: 列挙型で許されるメンバーと属性,  Up: 列挙型 HOWTO

9.5.8 Enumのサブクラス化の制限
------------------------------

新しい *note Enum: 5fc. クラスは、ベースの enum クラスを1つ、具象データ
型を1つ、複数の *note object: a5a. ベースのミックスインクラスが許容され
ます。これらのベースクラスの順序は次の通りです:

     class EnumName([mix-in, ...,] [data-type,] base-enum):
         pass

列挙型のサブクラスの作成はその列挙型にメンバーが一つも定義されていない場
合のみ行なえます。従って以下は許されません:

     >>> class MoreColor(Color):
     ...     PINK = 17
     ...
     Traceback (most recent call last):
     ...
     TypeError: <enum 'MoreColor'> cannot extend <enum 'Color'>

以下のような場合は許されます:

     >>> class Foo(Enum):
     ...     def some_behavior(self):
     ...         pass
     ...
     >>> class Bar(Foo):
     ...     HAPPY = 1
     ...     SAD = 2
     ...

メンバーが定義された列挙型のサブクラス化を許可すると、いくつかのデータ型
およびインスタンスの重要な不変条件の違反を引き起こします。とはいえ、それ
が許可されると、列挙型のグループ間での共通の挙動を共有するという利点もあ
ります。 (*note OrderedEnum: 4d63. の例を参照してください。)


File: python.info,  Node: データクラスのサポート,  Next: Pickle 化,  Prev: Enumのサブクラス化の制限,  Up: 列挙型 HOWTO

9.5.9 データクラスのサポート
----------------------------

*note dataclass: 1ad. を継承する場合、 *note __repr__(): 16f0. は継承す
るクラス名を省略します。 例えば:

     >>> from dataclasses import dataclass, field
     >>> @dataclass
     ... class CreatureDataMixin:
     ...     size: str
     ...     legs: int
     ...     tail: bool = field(repr=False, default=True)
     ...
     >>> class Creature(CreatureDataMixin, Enum):
     ...     BEETLE = 'small', 6
     ...     DOG = 'medium', 4
     ...
     >>> Creature.DOG
     <Creature.DOG: size='medium', legs=4>

標準の *note repr(): 7c8. を使うには、*note dataclass(): 1ad. の引数
‘repr=False’ を使用してください。

バージョン 3.12 で変更: dataclass のフィールドだけが値の領域に表示され、
dataclassの名前は表示されなくなりました

     注釈: *note Enum: 5fc. やそのサブクラスに *note dataclass(): 1ad. デ
     コレータを加えることはサポートされていません。そうしてもエラーは送
     出されませんが、実行時にそれぞれのメンバが互いに等しいなど、非常に
     奇妙な結果が起こります:

          >>> @dataclass               # don't do this: it does not make any sense
          ... class Color(Enum):
          ...    RED = 1
          ...    BLUE = 2
          ...
          >>> Color.RED is Color.BLUE
          False
          >>> Color.RED == Color.BLUE  # problem is here: they should not be equal
          True


File: python.info,  Node: Pickle 化,  Next: 関数 API<2>,  Prev: データクラスのサポート,  Up: 列挙型 HOWTO

9.5.10 Pickle 化
----------------

列挙型は pickle 化と unpickle 化が行えます:

     >>> from test.test_enum import Fruit
     >>> from pickle import dumps, loads
     >>> Fruit.TOMATO is loads(dumps(Fruit.TOMATO))
     True

通常の pickle 化の制限事項が適用されます: pickle 可能な列挙型はモジュー
ルのトップレベルで定義されていなくてはならず、unpickle 化はモジュールか
らインポート可能でなければなりません。

     注釈: pickle プロトコルバージョン 4 では他のクラスで入れ子になった
     列挙型の pickle 化も容易です。

列挙型クラスの ‘__reduce_ex__()’ を定義することで、列挙型のメンバがどの
ように pickle 化や unpickle 化されるかを変更できます。デフォルトの方法は
値によってですが、複雑な値を持つ列挙型には名前によることを望むかもしれま
せん:

     >>> import enum
     >>> class MyEnum(enum.Enum):
     ...     __reduce_ex__ = enum.pickle_by_enum_name

     注釈: フラグに名前による pickle 化を使うことは、名前の無いエイリア
     スが unpickle 化されないため推奨されません。


File: python.info,  Node: 関数 API<2>,  Next: 派生列挙型,  Prev: Pickle 化,  Up: 列挙型 HOWTO

9.5.11 関数 API
---------------

*note Enum: 5fc. クラスは呼び出し可能で、以下の関数 API を提供しています
:

     >>> Animal = Enum('Animal', 'ANT BEE CAT DOG')
     >>> Animal
     <enum 'Animal'>
     >>> Animal.ANT
     <Animal.ANT: 1>
     >>> list(Animal)
     [<Animal.ANT: 1>, <Animal.BEE: 2>, <Animal.CAT: 3>, <Animal.DOG: 4>]

この API の動作は *note namedtuple: 1ac. と似ています。*note Enum: 5fc.
呼び出しの第 1 引数は列挙型の名前です。

第 2 引数は列挙型メンバー名の 'ソース' です。空白で区切った名前の文字列
、名前のシーケンス、キー/値のペアの 2 要素タプルのシーケンス、あるいは名
前と値のマッピング (例: 辞書) を指定できます。最後の 2 個のオプションで
は、列挙型へ任意の値を割り当てることができます。前の 2 つのオプションで
は、1 から始まり増加していく整数を自動的に割り当てます (別の開始値を指定
するには、‘start’ 引数を使用します)。*note Enum: 5fc. から派生した新しい
クラスが返されます。言い換えれば、上記の ‘Animal’ への割り当ては以下と等
価です:

     >>> class Animal(Enum):
     ...     ANT = 1
     ...     BEE = 2
     ...     CAT = 3
     ...     DOG = 4
     ...

‘0’ ではなく''1'' をデフォルトの開始番号とする理由は、‘0’ が真偽値として
は ‘False’ であり、デフォルトの列挙メンバーはすべて ‘True’ 評価されるよ
うにするためである。

機能 API による Enum の pickle 化は、その列挙型がどのモジュールで作成さ
れたかを見つけ出すためにフレームスタックの実装の詳細が使われるので、トリ
ッキーになることがあります (例えば別のモジュールのユーティリティ関数を使
うと失敗しますし、IronPython や Jython ではうまくいきません)。解決策は、
以下のようにモジュール名を明示的に指定することです:

     >>> Animal = Enum('Animal', 'ANT BEE CAT DOG', module=__name__)

     警告: ‘module’ が与えられない場合、Enum はそれがなにか決定できない
     ため、新しい Enum メンバーは unpickle 化できなくなります; エラーを
     ソースの近いところで発生させるため、pickle 化は無効になります。

The new pickle protocol 4 also, in some circumstances, relies on *note
__qualname__: 1e86. 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:

     >>> Animal = Enum('Animal', 'ANT BEE CAT DOG', qualname='SomeData.Animal')

完全な構文は以下のようになります:

     Enum(
         value='NewEnumName',
         names=<...>,
         *,
         module='...',
         qualname='...',
         type=<mixed-in class>,
         start=1,
         )

   * 'value': What the new enum class will record as its name.

   * 'names': enumのメンバー。 空白またはカンマで区切られた文字列 (値は
     特に指定がない限り1から始まります):

          'RED GREEN BLUE' | 'RED,GREEN,BLUE' | 'RED, GREEN, BLUE'

     または名前のイテレータで指定もできます:

          ['RED', 'GREEN', 'BLUE']

     または (名前, 値) のペアのイテレータでも指定できます:

          [('CYAN', 4), ('MAGENTA', 5), ('YELLOW', 6)]

     またはマッピングでも指定できます:

          {'CHARTREUSE': 7, 'SEA_GREEN': 11, 'ROSEMARY': 42}

   * 'module': 新しい enum クラスが属するモジュールの名前です。

   * 'qualname': 新しい enum クラスが属するモジュールの場所です。

   * 'type': 新しい列挙型クラスにミックスインする型。

   * 'start'：名前だけ渡された場合にカウントを開始する番号。

バージョン 3.5 で変更: 'start' 引数が追加されました。


File: python.info,  Node: 派生列挙型,  Next: __new__ と __init__ のどちらを使うべきか,  Prev: 関数 API<2>,  Up: 列挙型 HOWTO

9.5.12 派生列挙型
-----------------

* Menu:

* IntEnum::
* StrEnum::
* IntFlag::
* Flag::
* その他: その他<4>.


File: python.info,  Node: IntEnum,  Next: StrEnum,  Up: 派生列挙型

9.5.12.1 IntEnum
................

提供されている 1 つ目の *note Enum: 5fc. の派生型であり、 *note int:
238. のサブクラスでもあります。 *note IntEnum: cad. のメンバーは整数と比
較できます; さらに言うと、異なる整数列挙型どうしでも比較できます:

     >>> from enum import IntEnum
     >>> class Shape(IntEnum):
     ...     CIRCLE = 1
     ...     SQUARE = 2
     ...
     >>> class Request(IntEnum):
     ...     POST = 1
     ...     GET = 2
     ...
     >>> Shape == 1
     False
     >>> Shape.CIRCLE == 1
     True
     >>> Shape.CIRCLE == Request.POST
     True

ただし、これらも標準の *note Enum: 5fc. 列挙型とは比較できません:

     >>> class Shape(IntEnum):
     ...     CIRCLE = 1
     ...     SQUARE = 2
     ...
     >>> class Color(Enum):
     ...     RED = 1
     ...     GREEN = 2
     ...
     >>> Shape.CIRCLE == Color.RED
     False

*note IntEnum: cad. の値は他の用途では整数のように振る舞います:

     >>> int(Shape.CIRCLE)
     1
     >>> ['a', 'b', 'c'][Shape.CIRCLE]
     'b'
     >>> [i for i in range(Shape.SQUARE)]
     [0, 1]


File: python.info,  Node: StrEnum,  Next: IntFlag,  Prev: IntEnum,  Up: 派生列挙型

9.5.12.2 StrEnum
................

提供されている2つ目の *note Enum: 5fc. の派生型もまた、 *note str: 418.
のサブクラスでもあります。*note StrEnum: 5e6. のメンバーは、文字列と比較
できます; さらに言うと、異なる文字列列挙型どうしでも比較できます。

Added in version 3.11.


File: python.info,  Node: IntFlag,  Next: Flag,  Prev: StrEnum,  Up: 派生列挙型

9.5.12.3 IntFlag
................

次の *note Enum: 5fc. の派生型 *note IntFlag: 2255. も、*note int: 238.
を基底クラスとしています。 違いは、 *note IntFlag: 2255. のメンバーをビ
ット演算子 (&amp;, |, ^, ~) を使って組み合わせられ、その結果も *note
IntFlag: 2255. メンバーになることです。 *note IntEnum: cad. と同様、
*note IntFlag: 2255. のメンバーも整数であり、*note int: 238. が使用され
るところであればどこでも使えます。

     注釈: *note IntFlag: 2255. メンバーに対してビット演算以外のどんな演
     算をしても、その結果は *note IntFlag: 2255. メンバーではなくなりま
     す。

     ビット単位演算の結果が *note IntFlag: 2255. として不正な値な値の場
     合、値は *note IntFlag: 2255. メンバーではなくなります。 詳しくは
     *note FlagBoundary: 5f0. を参照してください。

Added in version 3.6.

バージョン 3.11 で変更.

*note IntFlag: 2255. クラスの例:

     >>> from enum import IntFlag
     >>> class Perm(IntFlag):
     ...     R = 4
     ...     W = 2
     ...     X = 1
     ...
     >>> Perm.R | Perm.W
     <Perm.R|W: 6>
     >>> Perm.R + Perm.W
     6
     >>> RW = Perm.R | Perm.W
     >>> Perm.R in RW
     True

組み合わせにも名前を付けられます:

     >>> class Perm(IntFlag):
     ...     R = 4
     ...     W = 2
     ...     X = 1
     ...     RWX = 7
     ...
     >>> Perm.RWX
     <Perm.RWX: 7>
     >>> ~Perm.RWX
     <Perm: 0>
     >>> Perm(7)
     <Perm.RWX: 7>

     注釈: 組み合わせに名前をつけたものはエイリアスとみなされます。エイ
     リアスはイテレーション中には表示されませんが、値による検索では返却
     されます。

バージョン 3.11 で変更.

*note IntFlag: 2255. と *note Enum: 5fc. のもう 1 つの重要な違いは、フラ
グが設定されていない (値が0である) 場合、その真偽値としての評価は *note
False: b05. になることです:

     >>> Perm.R & Perm.X
     <Perm: 0>
     >>> bool(Perm.R & Perm.X)
     False

*note IntFlag: 2255. メンバーも *note int: 238. のサブクラスであるため、
それらと組み合わせることができます（ただし、 *note IntFlag: 2255. 型では
なくなる可能性があります）:

     >>> Perm.X | 4
     <Perm.R|X: 5>

     >>> Perm.X + 8
     9

     注釈: 否定の演算子 ‘~’ は、常に正の値を持つ *note IntFlag: 2255. メ
     ンバー を返す:

          >>> (~Perm.X).value == (Perm.R|Perm.W).value == 6
          True

*note IntFlag: 2255. メンバーは反復処理することもできます:

     >>> list(RW)
     [<Perm.R: 4>, <Perm.W: 2>]

Added in version 3.11.


File: python.info,  Node: Flag,  Next: その他<4>,  Prev: IntFlag,  Up: 派生列挙型

9.5.12.4 Flag
.............

最後の派生型は *note Flag: 5ef. です。 *note IntFlag: 2255. と同様に、
*note Flag: 5ef. メンバーもビット演算子 (&, |, ^, ~) を使って組み合わせ
られます。 しかし *note IntFlag: 2255. とは違い、他のどの *note Flag:
5ef. 列挙型とも *note int: 238. とも組み合わせたり、比較したりできません
。 値を直接指定することも可能ですが、値として *note auto: c6a. を使い、
*note Flag: 5ef. に適切な値を選ばせることが推奨されています。

Added in version 3.6.

*note IntFlag: 2255. と同様に、 *note Flag: 5ef. メンバーの組み合わせが
どのフラグも設定されていない状態になった場合、その真偽値としての評価は
*note False: b05. となります:

     >>> from enum import Flag, auto
     >>> class Color(Flag):
     ...     RED = auto()
     ...     BLUE = auto()
     ...     GREEN = auto()
     ...
     >>> Color.RED & Color.GREEN
     <Color: 0>
     >>> bool(Color.RED & Color.GREEN)
     False

個別のフラグは 2 のべき乗 (1, 2, 4, 8, ...)  の値を持つべきですが、フラ
グの組み合わせはそうはなりません:

     >>> class Color(Flag):
     ...     RED = auto()
     ...     BLUE = auto()
     ...     GREEN = auto()
     ...     WHITE = RED | BLUE | GREEN
     ...
     >>> Color.WHITE
     <Color.WHITE: 7>

"フラグが設定されていない" 状態に名前を付けても、その真偽値は変わりませ
ん:

     >>> class Color(Flag):
     ...     BLACK = 0
     ...     RED = auto()
     ...     BLUE = auto()
     ...     GREEN = auto()
     ...
     >>> Color.BLACK
     <Color.BLACK: 0>
     >>> bool(Color.BLACK)
     False

*note Flag: 5ef. メンバーは反復処理することもできます:

     >>> purple = Color.RED | Color.BLUE
     >>> list(purple)
     [<Color.RED: 1>, <Color.BLUE: 2>]

Added in version 3.11.

     注釈: ほとんどの新しいコードでは、 *note Enum: 5fc. と *note Flag:
     5ef. が強く推奨されます。 というのは、 *note IntEnum: cad. と *note
     IntFlag: 2255. は (整数と比較でき、従って推移的に他の無関係な列挙型
     と比較できてしまうことにより) 列挙型の意味論的な約束に反するからで
     す。 *note IntEnum: cad. と *note IntFlag: 2255. は、 *note Enum:
     5fc. や *note Flag: 5ef. では上手くいかない場合のみに使うべきです;
     例えば、整数定数を列挙型で置き換えるときや、他のシステムとの相互運
     用性を持たせたいときです。


File: python.info,  Node: その他<4>,  Prev: Flag,  Up: 派生列挙型

9.5.12.5 その他
...............

*note IntEnum: cad. は *note enum: 4c. モジュールの一部ですが、単独での
実装もとても簡単に行なえます:

     class IntEnum(int, ReprEnum):   # or Enum instead of ReprEnum
         pass

ここでは似たような列挙型の派生を定義する方法を紹介します; 例えば、
‘FloatEnum’ は *note int: 238. ではなく *note float: 2ce. で複合させたも
のです。

いくつかのルール:

  1. *note Enum: 5fc. のサブクラスを作成するとき、複合させるデータ型は、
     基底クラスの並びで *note Enum: 5fc. クラス自身より先に記述しなけれ
     ばなりません (上記 *note IntEnum: cad. の例を参照)。

  2. 複合させる型はサブクラス化可能でなければいけません。例えば、 *note
     bool: 434. と *note range: 911. はサブクラス化できないため、複合さ
     せるとEnum作成時にエラーが発生します。

  3. *note Enum: 5fc. のメンバーはどんなデータ型でも構いませんが、追加の
     データ型 (例えば、上の例の *note int: 238.) と複合させてしまうと、
     すべてのメンバーの値はそのデータ型でなければならなくなります。この
     制限は、メソッドの追加するだけの、他のデータ型を指定しない複合には
     適用されません。

  4. 他のデータ型と複合された場合、 ‘value’ 属性は、たとえ等価であり等価
     であると比較が行えても、列挙型メンバー自身としては '同じではありま
     せん' 。

  5. A ‘data type’ is a mixin that defines ‘__new__()’, or a *note
     dataclass: 1ad.

  6. %-方式の書式: ‘%s’ および ‘%r’ はそれぞれ *note Enum: 5fc. クラスの
     ‘__str__()’ および ‘__repr__()’ を呼び出します; その他のコード
     (IntEnum の ‘%i’ や ‘%h’ など) は列挙型のメンバーを複合されたデータ
     型として扱います。

  7. *note フォーマット済み文字列リテラル: 977.、*note str.format():
     5ed.、および *note format(): 5eb. はenumの ‘__str__()’ メソッドを使
     います。

     注釈: *note IntEnum: cad. 、*note IntFlag: 2255. 、*note StrEnum:
     5e6. は、既存の定数のドロップイン置換として設計されているため、それ
     らの ‘__str__()’ メソッドは、それらのデータ型の ‘__str__()’ メソッ
     ドにリセットされている。


File: python.info,  Node: __new__ と __init__ のどちらを使うべきか,  Next: EnumとFlagはどう違うのか？,  Prev: 派生列挙型,  Up: 列挙型 HOWTO

9.5.13 ‘__new__()’ と ‘__init__()’ のどちらを使うべきか
-------------------------------------------------------

‘__new__()’ は *note Enum: 5fc. メンバーの実際の値をカスタマイズしたいと
きに利用します。他の変更を加える場合、 ‘__new__()’ と ‘__init__()’ のど
ちらを利用するかは、‘__init__()’ の方が望ましいでしょう。

例えば、複数の値をコンストラクタに渡すが、その中の1つだけを値として使い
たい場合は次のようにします:

     >>> class Coordinate(bytes, Enum):
     ...     """
     ...     Coordinate with binary codes that can be indexed by the int code.
     ...     """
     ...     def __new__(cls, value, label, unit):
     ...         obj = bytes.__new__(cls, [value])
     ...         obj._value_ = value
     ...         obj.label = label
     ...         obj.unit = unit
     ...         return obj
     ...     PX = (0, 'P.X', 'km')
     ...     PY = (1, 'P.Y', 'km')
     ...     VX = (2, 'V.X', 'km/s')
     ...     VY = (3, 'V.Y', 'km/s')
     ...

     >>> print(Coordinate['PY'])
     Coordinate.PY

     >>> print(Coordinate(3))
     Coordinate.VY

     警告: 'Do not' call ‘super().__new__()’, as the lookup-only
     ‘__new__’ is the one that is found; instead, use the data type
     directly.

* Menu:

* 細かい点::


File: python.info,  Node: 細かい点,  Up: __new__ と __init__ のどちらを使うべきか

9.5.13.1 細かい点
.................

* Menu:

* __dunder__ 名のサポート: __dunder__ 名のサポート<2>.
* _sunder_ 名のサポート: _sunder_ 名のサポート<2>.
* _Private__names::
* Enum メンバー型::
* Creating members that are mixed with other data types::
* Enum クラスとメンバーの真偽値::
* メソッド付きの Enum クラス::
* Flag のメンバーの組み合わせ::
* Flag and IntFlag minutia::


File: python.info,  Node: __dunder__ 名のサポート<2>,  Next: _sunder_ 名のサポート<2>,  Up: 細かい点

9.5.13.2 ‘__dunder__’ 名のサポート
..................................

‘__members__’ は読み込み専用の、 ‘member_name’:‘member’ を要素とする順序
付きマッピングです。これはクラスでのみ利用可能です。

‘__new__()’ が、もし指定されていた場合、列挙型のメンバーを作成し、返しま
す; そのメンバー の ‘_value_’ を適切に設定するのも非常によい考えです。 い
ったん全てのメンバーが作成されると、それ以降 ‘__new__()’ は使われません
。


File: python.info,  Node: _sunder_ 名のサポート<2>,  Next: _Private__names,  Prev: __dunder__ 名のサポート<2>,  Up: 細かい点

9.5.13.3 ‘_sunder_’ 名のサポート
................................

   - *note _name_: 251d. - メンバー名

   - *note _value_: 251e. - メンバーの値; ‘__new__’ で設定できます

   - *note _missing_(): 2525. - 値が見付からなかったときに使われる検索関
     数; オーバーライドされていることがあります

   - *note _ignore_: 2520. - 名前のリストで、 *note list: 5dc. もしくは
     *note str: 418. です。この名前の要素はメンバーへの変換が行われず、
     最終的なクラスから削除されます。

   - *note _generate_next_value_(): 2522. - 列挙型のメンバーの適切な値を
     取得するのに使われます。オーバーライドされます。

   - ‘_add_alias_()’ - 既存のメンバーのエイリアスとして新しい名前を加え
     ます。

   - ‘_add_value_alias_()’ - 既存のメンバーのエイリアスとして新しい値を
     加えます。例は *note MultiValueEnum: 4d6f. を参照してください。

          注釈: 標準の *note Enum: 5fc. クラスの場合、次の値として選択さ
          れるのは、定義された最大の値に1を加えたものです。

          *note Flag: 5ef. クラスでは、次に選ばれる値は、次の最大の2のべ
          き乗となります。

     バージョン 3.13 で変更: 以前のバージョンでは最大の値ではなく最後に
     定義された値を使っていました。

Added in version 3.6: ‘_missing_’, ‘_order_’, ‘_generate_next_value_’

Added in version 3.7: ‘_ignore_’

Added in version 3.13: ‘_add_alias_’, ‘_add_value_alias_’

Pythono 2 / Python 3のコードの同期を取りやすくするために ‘_order_’ 属性
を提供できます。実際の列挙値の順序と比較して一致してなければエラーを送出
します:

     >>> class Color(Enum):
     ...     _order_ = 'RED GREEN BLUE'
     ...     RED = 1
     ...     BLUE = 3
     ...     GREEN = 2
     ...
     Traceback (most recent call last):
     ...
     TypeError: member order does not match _order_:
       ['RED', 'BLUE', 'GREEN']
       ['RED', 'GREEN', 'BLUE']

     注釈: Python 2のコードでは ‘_order_’ 属性は定義順が記録される前消え
     てしまうため、重要です。


File: python.info,  Node: _Private__names,  Next: Enum メンバー型,  Prev: _sunder_ 名のサポート<2>,  Up: 細かい点

9.5.13.4 _Private__names
........................

*note Private names: 1c24. は列挙型メンバーには変換されず、通常の属性と
なります。

バージョン 3.11 で変更.


File: python.info,  Node: Enum メンバー型,  Next: Creating members that are mixed with other data types,  Prev: _Private__names,  Up: 細かい点

9.5.13.5 ‘Enum’ メンバー型
..........................

列挙型メンバーはその列挙型クラスのインスタンスであり、通常は
‘EnumClass.member’ としてアクセスされます。 振る舞い メンバー しかし、メ
ンバー の名前と、属性/methodsが混在しているクラスとの名前の衝突を避ける
ために、大文字の名前を使うことを強く推奨します。

バージョン 3.5 で変更.


File: python.info,  Node: Creating members that are mixed with other data types,  Next: Enum クラスとメンバーの真偽値,  Prev: Enum メンバー型,  Up: 細かい点

9.5.13.6 Creating members that are mixed with other data types
..............................................................

When subclassing other data types, such as *note int: 238. or *note str:
418, with an *note Enum: 5fc, all values after the ‘=’ are passed to
that data type's constructor.  For example:

     >>> class MyEnum(IntEnum):      # help(int) -> int(x, base=10) -> integer
     ...     example = '11', 16      # so x='11' and base=16
     ...
     >>> MyEnum.example.value        # and hex(11) is...
     17


File: python.info,  Node: Enum クラスとメンバーの真偽値,  Next: メソッド付きの Enum クラス,  Prev: Creating members that are mixed with other data types,  Up: 細かい点

9.5.13.7 ‘Enum’ クラスとメンバーの真偽値
........................................

(*note int: 238, *note str: 418. などのような) 非 *note Enum: 5fc. 型と
複合させた enum クラスは、その複合された型の規則に従って評価されます; そ
うでない場合は、全てのメンバーは *note True: bdb. と評価されます。 メン
バーの値に依存する独自の enum の真偽値評価を行うには、クラスに次のコード
を追加してください:

     def __bool__(self):
         return bool(self.value)

プレーンな *note Enum: 5fc. クラスは *note True: bdb. として評価されます
。


File: python.info,  Node: メソッド付きの Enum クラス,  Next: Flag のメンバーの組み合わせ,  Prev: Enum クラスとメンバーの真偽値,  Up: 細かい点

9.5.13.8 メソッド付きの ‘Enum’ クラス
.....................................

enum サブクラスに追加のメソッドを与えた場合、後述の *note Planet: 4d60.
クラスのように、そのメソッドはメンバーの *note dir(): 5fe. に表示されま
すが、クラスの *note dir(): 5fe. には表示されません:

     >>> dir(Planet)
     ['EARTH', 'JUPITER', 'MARS', 'MERCURY', 'NEPTUNE', 'SATURN', 'URANUS', 'VENUS', '__class__', '__doc__', '__members__', '__module__']
     >>> dir(Planet.EARTH)
     ['__class__', '__doc__', '__module__', 'mass', 'name', 'radius', 'surface_gravity', 'value']


File: python.info,  Node: Flag のメンバーの組み合わせ,  Next: Flag and IntFlag minutia,  Prev: メソッド付きの Enum クラス,  Up: 細かい点

9.5.13.9 ‘Flag’ のメンバーの組み合わせ
......................................

Iterating over a combination of *note Flag: 5ef. members will only
return the members that are comprised of a single bit:

     >>> class Color(Flag):
     ...     RED = auto()
     ...     GREEN = auto()
     ...     BLUE = auto()
     ...     MAGENTA = RED | BLUE
     ...     YELLOW = RED | GREEN
     ...     CYAN = GREEN | BLUE
     ...
     >>> Color(3)  # named combination
     <Color.YELLOW: 3>
     >>> Color(7)      # not named combination
     <Color.RED|GREEN|BLUE: 7>


File: python.info,  Node: Flag and IntFlag minutia,  Prev: Flag のメンバーの組み合わせ,  Up: 細かい点

9.5.13.10 ‘Flag’ and ‘IntFlag’ minutia
......................................

例として以下のスニペットを使用します:

     >>> class Color(IntFlag):
     ...     BLACK = 0
     ...     RED = 1
     ...     GREEN = 2
     ...     BLUE = 4
     ...     PURPLE = RED | BLUE
     ...     WHITE = RED | GREEN | BLUE
     ...

the following are true:

   - 単一ビットのフラグは正規形です

   - 複数ビットや0ビットのフラグはエイリアスです

   - 反復処理では正規形のフラグのみ返却されます:

          >>> list(Color.WHITE)
          [<Color.RED: 1>, <Color.GREEN: 2>, <Color.BLUE: 4>]

   - negating a flag or flag set returns a new flag/flag set with the
     corresponding positive integer value:

          >>> Color.BLUE
          <Color.BLUE: 4>

          >>> ~Color.BLUE
          <Color.RED|GREEN: 3>

   - 名前のないフラグについては、そのメンバーの名前から名前が生成されま
     す:

          >>> (Color.RED | Color.GREEN).name
          'RED|GREEN'

          >>> class Perm(IntFlag):
          ...     R = 4
          ...     W = 2
          ...     X = 1
          ...
          >>> (Perm.R & Perm.W).name is None  # effectively Perm(0)
          True

   - multi-bit flags, aka aliases, can be returned from operations:

          >>> Color.RED | Color.BLUE
          <Color.PURPLE: 5>

          >>> Color(7)  # or Color(-1)
          <Color.WHITE: 7>

          >>> Color(0)
          <Color.BLACK: 0>

   - メンバーシップ/包含 のチェックでは、値が0のフラグは常に含まれるもの
     として扱われます:

          >>> Color.BLACK in Color.WHITE
          True

     それ以外では、一方のフラグの全ビットが他方のフラグに含まれる場合の
     み、Trueが返されます:

          >>> Color.PURPLE in Color.WHITE
          True

          >>> Color.GREEN in Color.PURPLE
          False

There is a new boundary mechanism that controls how out-of-range /
invalid bits are handled: ‘STRICT’, ‘CONFORM’, ‘EJECT’, and ‘KEEP’:

   * STRICT -> 無効な値が指定された場合に例外を発生させる

   * CONFORM -> 無効なビットを破棄する

   * EJECT -> フラグのステータスを失い、指定された値を持つ通常の int と
     なります。

   * KEEP -> keep the extra bits

        - keeps Flag status and extra bits

        - extra bits do not show up in iteration

        - extra bits do show up in repr() and str()

The default for Flag is ‘STRICT’, the default for ‘IntFlag’ is ‘EJECT’,
and the default for ‘_convert_’ is ‘KEEP’ (see ‘ssl.Options’ for an
example of when ‘KEEP’ is needed).


File: python.info,  Node: EnumとFlagはどう違うのか？,  Next: Enum クックブック,  Prev: __new__ と __init__ のどちらを使うべきか,  Up: 列挙型 HOWTO

9.5.14 EnumとFlagはどう違うのか？
---------------------------------

Enum は *note Enum: 5fc. 派生クラスやそれらのインスタンス (メンバー) 双
方の多くの側面に影響を及ぼすカスタムメタクラスを持っています。

* Menu:

* Enum クラス::
* Flag クラス::
* Enum メンバー (インスタンス): Enum メンバー インスタンス.
* Flag メンバー::


File: python.info,  Node: Enum クラス,  Next: Flag クラス,  Up: EnumとFlagはどう違うのか？

9.5.14.1 Enum クラス
....................

*note EnumType: 5e5. メタクラスは、‘__contains__()’、‘__dir__()’、
‘__iter__()’ および標準的なクラスでは失敗するが *note Enum: 5fc. クラス
では動作するその他のメソッド (‘list(Color)’ や ‘some_enum_var in Color’
など) を責任を持って提供します。*note EnumType: 5e5. は最終的な *note
Enum: 5fc. クラスのさまざまなメソッド (‘__new__()’、‘__getnewargs__()’、
‘__str__()’ および ‘__repr__()’) が正しいことを責任を持って保証します。


File: python.info,  Node: Flag クラス,  Next: Enum メンバー インスタンス,  Prev: Enum クラス,  Up: EnumとFlagはどう違うのか？

9.5.14.2 Flag クラス
....................

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
addition to the *note Enum: 5fc. definition of alias, a flag with no
value (a.k.a.  ‘0’) or with more than one power-of-two value (e.g.  ‘3’)
is considered an alias.


File: python.info,  Node: Enum メンバー インスタンス,  Next: Flag メンバー,  Prev: Flag クラス,  Up: EnumとFlagはどう違うのか？

9.5.14.3 Enum メンバー (インスタンス)
.....................................

enum メンバーについて最も興味深いのは、それらがシングルトンであるという
ことです。*note EnumType: 5e5. は enum クラス自身を作成し、メンバーを作
成し、新しいインスタンスが作成されていないかどうかを確認するために既存の
メンバーインスタンスだけを返すカスタム ‘__new__()’ を追加します。


File: python.info,  Node: Flag メンバー,  Prev: Enum メンバー インスタンス,  Up: EnumとFlagはどう違うのか？

9.5.14.4 Flag メンバー
......................

フラグのメンバーは、*note Flag: 5ef. クラスと同様に反復処理することがで
き、正規のメンバーのみが返されます。 例えば:

     >>> list(Color)
     [<Color.RED: 1>, <Color.GREEN: 2>, <Color.BLUE: 4>]

（‘BLACK’ 、 ‘PURPLE’ 、 ‘WHITE’ は表示されないことに注意。）

フラグのメンバーを反転させると、負の値ではなく、対応する正の値が返されま
す:

     >>> ~Color.RED
     <Color.GREEN|BLUE: 6>

フラグのメンバーは、それが含む2のべき乗の値の数に対応するlengthを持ちま
す。 例えば:

     >>> len(Color.PURPLE)
     2


File: python.info,  Node: Enum クックブック,  Next: EnumType のサブクラスを作る,  Prev: EnumとFlagはどう違うのか？,  Up: 列挙型 HOWTO

9.5.15 Enum クックブック
------------------------

*note Enum: 5fc, *note IntEnum: cad, *note StrEnum: 5e6, *note Flag:
5ef, *note IntFlag: 2255. は用途の大部分をカバーすると予想されますが、そ
のすべてをカバーできているわけではありません。ここでは、そのまま、あるい
は独自の列挙型を作る例として使える、様々なタイプの列挙型を紹介します。

* Menu:

* 値の省略::
* OrderedEnum::
* DuplicateFreeEnum::
* MultiValueEnum::
* Planet::
* TimePeriod::


File: python.info,  Node: 値の省略,  Next: OrderedEnum,  Up: Enum クックブック

9.5.15.1 値の省略
.................

多くの用途では、列挙型の実際の値が何かは気にされません。 このタイプの単
純な列挙型を定義する方法はいくつかあります:

   - 値に *note auto: c6a. インスタンスを使用する

   - 値として *note object: a5a. インスタンスを使用する

   - 値として解説文字列を使用する

   - 値としてタプルを使用し、独自の ‘__new__()’ を使用してタプルを *note
     int: 238. 値で置き換える

これらのどの方法を使ってもユーザーに対して、値は重要ではなく、他のメンバ
ーの番号の振り直しをする必要無しに、メンバーの追加、削除、並べ替えが行え
るということを示せます。

* Menu:

* auto を使う::
* object を使う::
* 解説文字列を使う::
* 独自の __new__() を使う: 独自の __new__ を使う.


File: python.info,  Node: auto を使う,  Next: object を使う,  Up: 値の省略

9.5.15.2 ‘auto’ を使う
......................

*note auto: c6a. を使うと次のようになります:

     >>> class Color(Enum):
     ...     RED = auto()
     ...     BLUE = auto()
     ...     GREEN = auto()
     ...
     >>> Color.GREEN
     <Color.GREEN: 3>


File: python.info,  Node: object を使う,  Next: 解説文字列を使う,  Prev: auto を使う,  Up: 値の省略

9.5.15.3 ‘object’ を使う
........................

*note object: a5a. を使うと次のようになります:

     >>> class Color(Enum):
     ...     RED = object()
     ...     GREEN = object()
     ...     BLUE = object()
     ...
     >>> Color.GREEN
     <Color.GREEN: <object object at 0x...>>

また、これは自分で ‘__repr__()’ を書きたくなるケースの良い例でもあります
:

     >>> class Color(Enum):
     ...     RED = object()
     ...     GREEN = object()
     ...     BLUE = object()
     ...     def __repr__(self):
     ...         return "<%s.%s>" % (self.__class__.__name__, self._name_)
     ...
     >>> Color.GREEN
     <Color.GREEN>


File: python.info,  Node: 解説文字列を使う,  Next: 独自の __new__ を使う,  Prev: object を使う,  Up: 値の省略

9.5.15.4 解説文字列を使う
.........................

値として文字列を使うと次のようになります:

     >>> class Color(Enum):
     ...     RED = 'stop'
     ...     GREEN = 'go'
     ...     BLUE = 'too fast!'
     ...
     >>> Color.GREEN
     <Color.GREEN: 'go'>


File: python.info,  Node: 独自の __new__ を使う,  Prev: 解説文字列を使う,  Up: 値の省略

9.5.15.5 独自の ‘__new__()’ を使う
..................................

自動で番号を振る ‘__new__()’ を使うと次のようになります:

     >>> class AutoNumber(Enum):
     ...     def __new__(cls):
     ...         value = len(cls.__members__) + 1
     ...         obj = object.__new__(cls)
     ...         obj._value_ = value
     ...         return obj
     ...
     >>> class Color(AutoNumber):
     ...     RED = ()
     ...     GREEN = ()
     ...     BLUE = ()
     ...
     >>> Color.GREEN
     <Color.GREEN: 2>

‘AutoNumber’ をより広い用途で使うには、シグニチャに ‘*args’ を追加します
:

     >>> class AutoNumber(Enum):
     ...     def __new__(cls, *args):      # this is the only change from above
     ...         value = len(cls.__members__) + 1
     ...         obj = object.__new__(cls)
     ...         obj._value_ = value
     ...         return obj
     ...

‘AutoNumber’ を継承すると、追加の引数を取り扱える独自の ‘__init__’ が書
けます。

     >>> class Swatch(AutoNumber):
     ...     def __init__(self, pantone='unknown'):
     ...         self.pantone = pantone
     ...     AUBURN = '3497'
     ...     SEA_GREEN = '1246'
     ...     BLEACHED_CORAL = () # New color, no Pantone code yet!
     ...
     >>> Swatch.SEA_GREEN
     <Swatch.SEA_GREEN: 2>
     >>> Swatch.SEA_GREEN.pantone
     '1246'
     >>> Swatch.BLEACHED_CORAL.pantone
     'unknown'

     注釈: ‘__new__()’ メソッドが定義されていれば、Enum 番号の作成時に使
     用されます; これは Enum の ‘__new__()’ と置き換えられ、クラスが作成
     された後の既存の番号を取得に使用されます。

     警告: 'Do not' call ‘super().__new__()’, as the lookup-only
     ‘__new__’ is the one that is found; instead, use the data type
     directly - e.g.:

          obj = int.__new__(cls, value)


File: python.info,  Node: OrderedEnum,  Next: DuplicateFreeEnum,  Prev: 値の省略,  Up: Enum クックブック

9.5.15.6 OrderedEnum
....................

*note IntEnum: cad. をベースとしないため、通常の *note Enum: 5fc. の不変
条件 (他の列挙型と比較できないなど) のままで、メンバーを順序付けできる列
挙型です:

     >>> class OrderedEnum(Enum):
     ...     def __ge__(self, other):
     ...         if self.__class__ is other.__class__:
     ...             return self.value >= other.value
     ...         return NotImplemented
     ...     def __gt__(self, other):
     ...         if self.__class__ is other.__class__:
     ...             return self.value > other.value
     ...         return NotImplemented
     ...     def __le__(self, other):
     ...         if self.__class__ is other.__class__:
     ...             return self.value <= other.value
     ...         return NotImplemented
     ...     def __lt__(self, other):
     ...         if self.__class__ is other.__class__:
     ...             return self.value < other.value
     ...         return NotImplemented
     ...
     >>> class Grade(OrderedEnum):
     ...     A = 5
     ...     B = 4
     ...     C = 3
     ...     D = 2
     ...     F = 1
     ...
     >>> Grade.C < Grade.A
     True


File: python.info,  Node: DuplicateFreeEnum,  Next: MultiValueEnum,  Prev: OrderedEnum,  Up: Enum クックブック

9.5.15.7 DuplicateFreeEnum
..........................

値が重複するメンバーがある場合に、エイリアスを作成するのではなくエラーを
発生させます:

     >>> class DuplicateFreeEnum(Enum):
     ...     def __init__(self, *args):
     ...         cls = self.__class__
     ...         if any(self.value == e.value for e in cls):
     ...             a = self.name
     ...             e = cls(self.value).name
     ...             raise ValueError(
     ...                 "aliases not allowed in DuplicateFreeEnum:  %r --> %r"
     ...                 % (a, e))
     ...
     >>> class Color(DuplicateFreeEnum):
     ...     RED = 1
     ...     GREEN = 2
     ...     BLUE = 3
     ...     GRENE = 2
     ...
     Traceback (most recent call last):
       ...
     ValueError: aliases not allowed in DuplicateFreeEnum:  'GRENE' --> 'GREEN'

     注釈: これは Enum に別名を無効にするのと同様な振る舞いの追加や変更
     をおこなうためのサブクラス化に役立つ例です。単に別名を無効にしたい
     だけなら、 *note unique(): 250c. デコレーターを使用して行えます。


File: python.info,  Node: MultiValueEnum,  Next: Planet,  Prev: DuplicateFreeEnum,  Up: Enum クックブック

9.5.15.8 MultiValueEnum
.......................

Supports having more than one value per member:

     >>> class MultiValueEnum(Enum):
     ...     def __new__(cls, value, *values):
     ...         self = object.__new__(cls)
     ...         self._value_ = value
     ...         for v in values:
     ...             self._add_value_alias_(v)
     ...         return self
     ...
     >>> class DType(MultiValueEnum):
     ...     float32 = 'f', 8
     ...     double64 = 'd', 9
     ...
     >>> DType('f')
     <DType.float32: 'f'>
     >>> DType(9)
     <DType.double64: 'd'>


File: python.info,  Node: Planet,  Next: TimePeriod,  Prev: MultiValueEnum,  Up: Enum クックブック

9.5.15.9 Planet
...............

‘__new__()’ や ‘__init__()’ が定義されている場合、列挙型メンバーの値はこ
れらのメソッドに渡されます:

     >>> class Planet(Enum):
     ...     MERCURY = (3.303e+23, 2.4397e6)
     ...     VENUS   = (4.869e+24, 6.0518e6)
     ...     EARTH   = (5.976e+24, 6.37814e6)
     ...     MARS    = (6.421e+23, 3.3972e6)
     ...     JUPITER = (1.9e+27,   7.1492e7)
     ...     SATURN  = (5.688e+26, 6.0268e7)
     ...     URANUS  = (8.686e+25, 2.5559e7)
     ...     NEPTUNE = (1.024e+26, 2.4746e7)
     ...     def __init__(self, mass, radius):
     ...         self.mass = mass       # in kilograms
     ...         self.radius = radius   # in meters
     ...     @property
     ...     def surface_gravity(self):
     ...         # universal gravitational constant  (m3 kg-1 s-2)
     ...         G = 6.67300E-11
     ...         return G * self.mass / (self.radius * self.radius)
     ...
     >>> Planet.EARTH.value
     (5.976e+24, 6378140.0)
     >>> Planet.EARTH.surface_gravity
     9.802652743337129


File: python.info,  Node: TimePeriod,  Prev: Planet,  Up: Enum クックブック

9.5.15.10 TimePeriod
....................

‘_ignore_’ 属性の使用方法のサンプルです:

     >>> from datetime import timedelta
     >>> class Period(timedelta, Enum):
     ...     "different lengths of time"
     ...     _ignore_ = 'Period i'
     ...     Period = vars()
     ...     for i in range(367):
     ...         Period['day_%d' % i] = i
     ...
     >>> list(Period)[:2]
     [<Period.day_0: datetime.timedelta(0)>, <Period.day_1: datetime.timedelta(days=1)>]
     >>> list(Period)[-2:]
     [<Period.day_365: datetime.timedelta(days=365)>, <Period.day_366: datetime.timedelta(days=366)>]


File: python.info,  Node: EnumType のサブクラスを作る,  Prev: Enum クックブック,  Up: 列挙型 HOWTO

9.5.16 EnumType のサブクラスを作る
----------------------------------

While most enum needs can be met by customizing *note Enum: 5fc.
subclasses, either with class decorators or custom functions, *note
EnumType: 5e5. can be subclassed to provide a different Enum experience.


File: python.info,  Node: 関数型プログラミング HOWTO,  Next: Logging HOWTO,  Prev: 列挙型 HOWTO,  Up: Python HOWTO

9.6 関数型プログラミング HOWTO
==============================


著者: A. M. Kuchling


リリース: 0.32

この文書では、関数型スタイルでプログラムを実装するのにピッタリな Python
の機能を見てまわることにしましょう。まず関数型プログラミングという概念を
紹介したあと、 *note iterator: 191. や *note generator: 1035. のような言
語機能、および *note itertools: 75. や *note functools: 55. といった関連
するライブラリモジュールを見ることにします。

* Menu:

* はじめに: はじめに<12>.
* イテレータ (iterator): イテレータ iterator<2>.
* ジェネレータ式とリスト内包表記::
* ジェネレータ (generator): ジェネレータ generator<2>.
* 組み込み関数 (built-in function): 組み込み関数 built-in function<2>.
* itertools モジュール::
* functools モジュール::
* 小さな関数とラムダ式::
* 更新履歴と謝辞::
* 参考資料: 参考資料<2>.


File: python.info,  Node: はじめに<12>,  Next: イテレータ iterator<2>,  Up: 関数型プログラミング HOWTO

9.6.1 はじめに
--------------

この章は関数型プログラミングの基本概念を説明します; Python の言語機能に
ついてだけ知りたい人は、次の章の *note イテレータ (iterator): 4d89. まで
飛ばしてください。

プログラミング言語とは問題を分解するものですが、各言語がサポートする分解
方法にはいくつかの種類があります:

   * ほとんどのプログラミング言語は '手続き型' です: プログラムは、入力
     に対して行うべきことをコンピュータに教える指示リストとなります。 C,
     Pascal, さらには Unix シェルまでもが手続き型言語に入ります。

   * '宣言型' 言語で書くのは、解くべき問題を説明する仕様書であって、それ
     を効率的に計算処理する方法を見付けるのは言語実装の役目です。SQL は
     おそらく一番よく知られた宣言型言語です; SQL のクエリは取得したいデ
     ータセットを説明しているだけで、テーブルを走査するかインデックスを
     使うか、どのサブクローズから実行するか等々を決めるのは SQL エンジン
     なのです。

   * 'オブジェクト指向' プログラムはオブジェクトの集まりを操作します。オ
     ブジェクトには内部状態があり、その状態を調べたり色々と変更したりす
     るためのメソッドがあります。Smalltalk や Java はオブジェクト指向言
     語です。 C++ と Python はオブジェクト指向プログラミングをサポートし
     ていますが、関連する機能を使わなくても構わないようになっています。

   * '関数型' プログラミングは問題をいくつかの関数にわけて考えます。理想
     的に言うと、関数は入力を受けて出力を吐くだけで、同じ入力に対して異
     なる出力をするような内部状態を一切持ちません。有名な関数型言語には
     ML 一家 (Standard ML, OCaml 等々) と Haskell があります。

設計者が特定のアプローチを強調することにした言語もありますが、そうすると
大抵は、別のアプローチを使うプログラムを書きにくくなります。複数のアプロ
ーチに対応した言語もあり、Lisp, C++, Python はそうしたマルチパラダイム言
語です; この中のどれを使っても、基本的に手続き型な、または基本的にオブジ
ェクト指向な、とか、基本的に関数型なプログラムやライブラリを書くことがで
きます。大きなプログラムでは、各部で別々のアプローチを使って書くことがあ
るかもしれません; GUI はオブジェクト指向で、でも処理ロジックは手続き型や
関数型で、といったようにです。

関数型プログラムでは、入力は一連の関数を通って流れていきます。それぞれの
関数は入力に何らかの作業をして出力します。関数型スタイルにおいては、内部
状態を変えてしまったり、返り値に現れない変更をしたりといった副作用のある
関数はやめるように言われています。副作用のまったくない関数は '純粋関数型
' であるとされます。副作用をなくすということは、プログラムの実行中に順次
変化していくデータ構造を持たない、つまり各関数の出力はその入力にしか影響
を受けてはいけないということです。

ある言語では純粋さにとても厳しく ‘a=3’ や ‘c = a + b’ のような代入文すら
存在しないほどですが、画面への表示やディスクファイルへの書き込みなど、す
べての副作用を避けるのは難しいです。別の例として、 *note print(): f42. や
*note time.sleep(): 669. 関数の呼び出しもありますが、どちらも有用な値を
返しません。画面にテキストを送ったり、実行を 1 秒間停めたりといった副作
用のためだけに呼ばれるのです。

関数型スタイルで書いた Python プログラムはふつう、I/O や代入を完全になく
すといった極端なところまでは行かずに、関数型っぽく見えるインターフェース
を提供しつつも内部では非関数型の機能を使います。たとえば、関数内でローカ
ル変数の代入は使いますが、グローバル変数は変更せず、他の副作用もないよう
に実装するのです。

関数型プログラミングはオブジェクト指向プログラミングの反対と考えることも
できます。オブジェクト指向において、オブジェクトは内部状態とそれを変更す
るメソッドコールの入ったカプセルであり、プログラムはその状態を適正に変化
させていく手順です。一方で、関数型プログラミングは可能なかぎり状態の変更
を避け、関数どうしの間を流れるデータだけを扱おうとします。Python ではこ
の二つのアプローチを結び合わせることができます。アプリケーション内のオブ
ジェクト (メール、トランザクション、等々) を表現したインスタンスを、関数
が受け渡しするようにするのです。

関数型デザインは、わけのわからない制約に見えるかもしれません。どうしてオ
ブジェクトも副作用もないほうが良いのでしょうか。実は、関数型スタイルには
理論と実践に基づく次の利点があるのです:

   * 形式的証明可能性。

   * モジュラー性。

   * 結合性。

   * デバッグやテストの簡単さ。

* Menu:

* 形式的証明可能性::
* モジュラー性::
* デバッグやテストの簡単さ::
* 結合性::


File: python.info,  Node: 形式的証明可能性,  Next: モジュラー性,  Up: はじめに<12>

9.6.1.1 形式的証明可能性
........................

理論面の利点としては、プログラムが正しいことの数学的証明を他より簡単に構
築できるという点があります。

研究者たちは長いあいだ、プログラムが正しいことを数学的に証明する方法の発
見に血道をあげてきました。これは、色々な入力でテストして出力が正しかった
からまあ正しいだろう、と結論するのとも違いますし、ソースコードを読んで「
間違いはなさそうだ」と言うのとも別の話です; 目指すのは、出現しうる入力す
べてに対してプログラムが正しい結果を出すことの厳密な証明なのです。

プログラムを証明するために使われているのは '不変式' を書き出していくとい
うテクニックで、不変式とは入力データやプログラム変数のうち常に真である性
質のことです。コードの一行一行で、 '実行前' の不変式 X と Y が真なら '実
行後に' ちょっと違う不変式 X' と Y' が真になることを示していき、これをプ
ログラムの終わりまで続けるわけです。すると最終的な不変式はプログラムの出
力に合った条件になっているはずです。

関数型プログラミングが代入を嫌うのは、この不変式テクニックでは代入を扱い
にくいからです; 代入は、それまで真だった不変式を壊しておいて、自分は次の
行に伝えてゆける不変式を生み出さないことがあるのです。

残念ながら、プログラムの証明はだいたい実際的でもありませんし、Python ソ
フトウェアにも関係ありません。本当に簡単なプログラムでも、証明には数ペー
ジにわたる論文が必要なのです; ある程度の複雑なプログラムではもう尋常でな
い長さになってしまうので、日常で使っているプログラム (Python インタプリ
タ、XML パーサ、ウェブブラウザ) はほとんど、あるいはすべて、正しさを証明
するのは不可能でしょう。仮に証明を書き出したり生成したりしても、その証明
を検証するための疑いが残ります; 証明に間違いがあるかもしれず、その場合は
証明したと自分で勝手に思い込んでいただけになるのです。


File: python.info,  Node: モジュラー性,  Next: デバッグやテストの簡単さ,  Prev: 形式的証明可能性,  Up: はじめに<12>

9.6.1.2 モジュラー性
....................

より実用的には、関数型プログラミングをすると問題を細かく切り分けることに
なるという利点があります。結果としてプログラムはモジュラー化されます。複
雑な変形を施す大きな関数を書くより、一つのことに絞ってそれだけをする小さ
な関数のほうが書きやすいものです。それに、小さいほうが読むのもエラーをチ
ェックするのも簡単です。


File: python.info,  Node: デバッグやテストの簡単さ,  Next: 結合性,  Prev: モジュラー性,  Up: はじめに<12>

9.6.1.3 デバッグやテストの簡単さ
................................

テストやデバッグも関数型プログラムなら簡単です。

関数が一般的に小さくて明確に意味付けされているので、デバッグ方法は単純で
す。プログラムが正しく動かないときには、関数ひとつひとつがデータの正しさ
をチェックするポイントになるので、それぞれの時点における入力と出力を見て
いけば、バグの原因となる関数を素早く切り出すことができるのです。

ひとつひとつの関数がユニットテストの対象になり得るわけですから、テストも
簡単です。関数はシステムの状態に依存しませんので、テストの実行前にそうし
た状態を再現する必要はありません; 単に適切な入力を合成して、出力が期待ど
おりかどうかチェックするだけで良いのです。


File: python.info,  Node: 結合性,  Prev: デバッグやテストの簡単さ,  Up: はじめに<12>

9.6.1.4 結合性
..............

関数型スタイルのプログラムを作っていると、色々な入力や出力のために色々な
関数を書くことになります。仕方なく特定のアプリケーションに特化した関数を
書くこともあるでしょうけれど、広範なプログラムに使える関数もあることでし
ょう。たとえば、ディレクトリ名を受け取ってその中の XML ファイル一覧を返
す関数や、ファイル名を受け取って内容を返す関数などは、多様な場面に適用で
きそうです。

時たつうちに自分の特製ライブラリやユーティリティが充実してくると、新しい
プログラムも、既存の関数を調整して少し今回に特化した関数を書くだけで組み
立てられるようになります。


File: python.info,  Node: イテレータ iterator<2>,  Next: ジェネレータ式とリスト内包表記,  Prev: はじめに<12>,  Up: 関数型プログラミング HOWTO

9.6.2 イテレータ (iterator)
---------------------------

まずは関数型スタイルのプログラムを書く際の基礎となる重要な Python 機能か
ら見ていきましょう: イテレータです。

イテレータは連続データを表現するオブジェクトです; このオブジェクトは一度
に一つの要素ずつデータを返します。 Python のイテレータは *note
__next__(): 129b. という、引数を取らず次の要素を返すメソッドを必ずサポー
トしています。データストリームに要素が残っていない場合、 *note
__next__(): 129b. は必ず *note StopIteration: bc8. 例外を出します。ただ
し、イテレータの長さは有限である必要はありません; 無限のストリームを生成
するイテレータを書くというのもまったく理に適ったことです。

ビルトインの *note iter(): 7a2. 関数は任意のオブジェクトを受けて、 その
中身や要素を返すイテレータを返そうとします。引数のオブジェクトが イテレ
ータを作れないときは *note TypeError: 502. を投げます。Python の ビルト
インなデータ型にもいくつかイテレータ化のできるものがあり、 中でもよく使
われるのはリストと辞書です。イテレータを作れる オブジェクトは *note
iterable: 10ad. オブジェクトと呼ばれます。

手を動かしてイテレータ化の実験をしてみましょう:

     >>> L = [1, 2, 3]
     >>> it = iter(L)
     >>> it
     <...iterator object at ...>
     >>> it.__next__()  # same as next(it)
     1
     >>> next(it)
     2
     >>> next(it)
     3
     >>> next(it)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     StopIteration
     >>>

Python は色々な文脈でイテラブルなオブジェクトを期待しますが、 最も重要な
のは *note for: 2c9. 文です。 ‘for X in Y’ という文の Y は、 イテレータ
か、あるいは *note iter(): 7a2. でイテレータを作れるオブジェクトである必
要があります。次の二つは同じ意味になります:

     for i in iter(obj):
         print(i)

     for i in obj:
         print(i)

イテレータは *note list(): 5dc. や *note tuple(): 349. といったコンスト
ラクタ関数を使ってリストやタプルに具現化することができます:

     >>> L = [1, 2, 3]
     >>> iterator = iter(L)
     >>> t = tuple(iterator)
     >>> t
     (1, 2, 3)

シーケンスのアンパックもイテレータに対応しています: イテレータが N 個の
要素を返すということが事前にわかっていれば、N-タプルにアンパックすること
ができます:

     >>> L = [1, 2, 3]
     >>> iterator = iter(L)
     >>> a, b, c = iterator
     >>> a, b, c
     (1, 2, 3)

ビルトイン関数の *note max(): ed4. や *note min(): ed3. なども、イテレー
タ一つだけを引数に取って最大・最小の要素を返すことができます。 ‘"in"’ や
‘"not in"’ 演算子もイテレータに対応しています: ‘X in iterator’ は、その
イテレータから返るストリームに X があれば真です。ですからイテレータが無
限長だと、当然ながら問題に直面します; *note max(): ed4, *note min():
ed3. はいつまでも戻って来ませんし、 要素 X がストリームに出てこなければ
‘"in"’, ‘"not in"’ オペレータも戻りません。

イテレータは次に進むことしかできませんのでご注意ください; 前の要素を手に
入れたり、イテレータをリセットしたり、コピーを作ったりする方法はありませ
ん。イテレータがオブジェクトとしてそうした追加機能を 持つことはできます
が、プロトコルでは *note __next__(): 129b. メソッドのことしか指定されて
いません。ですから関数はイテレータの出力を使い尽くして しまうかもしれま
せんし、同じストリームに何か別のことをする 必要があるなら新しいイテレー
タを作らなくてはいけません。

* Menu:

* イテレータ対応のデータ型::


File: python.info,  Node: イテレータ対応のデータ型,  Up: イテレータ iterator<2>

9.6.2.1 イテレータ対応のデータ型
................................

リストやタプルがイテレータに対応している方法については既に見ましたが、実
のところ Python のシーケンス型はどれでも、たとえば文字列なども、自動でイ
テレータ生成に対応しています。

辞書に対して *note iter(): 7a2. すると、辞書のキーでループを回すイテレー
タが返されます:

     >>> m = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
     ...      'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
     >>> for key in m:
     ...     print(key, m[key])
     Jan 1
     Feb 2
     Mar 3
     Apr 4
     May 5
     Jun 6
     Jul 7
     Aug 8
     Sep 9
     Oct 10
     Nov 11
     Dec 12

Python 3.7 から、辞書の反復順序は挿入順序と同じであることが保証されてい
ることに注意してください。 以前のバージョンでは、その振る舞いは仕様が定
められておらず、実装ごとに異なることがありました。

辞書は *note iter(): 7a2. を適用するとキーでループを回しますが、辞書には
他のイテレータを返すメソッドもあります。明示的に値、あるいはキーと値のペ
アでイテレートしたければ、*note values(): 799, *note items(): 79a. とい
うメソッドでイテレータを作ることができます。

逆に *note dict(): 237. コンストラクタは、有限な ‘(key, value)’ タプルの
ストリームを返すイテレータを受け入れることができます:

     >>> L = [('Italy', 'Rome'), ('France', 'Paris'), ('US', 'Washington DC')]
     >>> dict(iter(L))
     {'Italy': 'Rome', 'France': 'Paris', 'US': 'Washington DC'}

ファイルも、最後の行まで *note readline(): 1c27. メソッドを呼んでいくこ
とでイテレータ化に対応しています。つまりこうやってファイルの各行を読んで
いくことができるわけです:

     for line in file:
         # do something for each line
         ...

セットはイテラブルを受け取れますし、そのセットの要素でイテレートすること
もできます:

     >>> S = {2, 3, 5, 7, 11, 13}
     >>> for i in S:
     ...     print(i)
     2
     3
     5
     7
     11
     13


File: python.info,  Node: ジェネレータ式とリスト内包表記,  Next: ジェネレータ generator<2>,  Prev: イテレータ iterator<2>,  Up: 関数型プログラミング HOWTO

9.6.3 ジェネレータ式とリスト内包表記
------------------------------------

イテレータの出力に対してよく使う操作トップ 2 は、(1) ひとつずつ全要素に
操作を実行する、および (2) 条件に合う要素でサブセットを作る、です。たと
えば文字列のリストなら、各行のうしろに付いた邪魔なホワイトスペースを削り
たいとか、特定の文字列を含む部分をピックアップしたいなどと思うかもしれま
せん。

リスト内包表記とジェネレータ式 (略して「listcomp」と「genexp」) は、そう
した操作向けの簡潔な表記方法です。これは関数型プログラミング言語 Haskell
(‘https://www.haskell.org/’) にインスパイアされました。文字列のストリー
ムからホワイトスペースをすべて削るのは次のコードでできます:

     >>> line_list = ['  line 1\n', 'line 2  \n', ' \n', '']

     >>> # Generator expression -- returns iterator
     >>> stripped_iter = (line.strip() for line in line_list)

     >>> # List comprehension -- returns list
     >>> stripped_list = [line.strip() for line in line_list]

特定の要素だけを選び出すのは ‘"if"’ 条件式を付けることで可能です:

     >>> stripped_list = [line.strip() for line in line_list
     ...                  if line != ""]

リスト内包表記を使うと Python リストが返って来ます; ‘stripped_list’ は実
行結果の行が入ったリストであって、イテレータではありません。ジェネレータ
式はイテレータを返し、これだと必要に応じてだけ値を算出しますので、すべて
の値を一度に出す必要がありません。つまりリスト内包表記のほうは、無限長ス
トリームや膨大なデータを返すようなイテレータを扱う際には、あまり役に立た
ないということです。そういった状況ではジェネレータ式のほうが好ましいと言
えます。

ジェネレータ式は丸括弧 "()" で囲まれ、リスト内包表記は角括弧 "[]" で囲ま
れます。ジェネレータ式の形式は次のとおりです:

     ( expression for expr in sequence1
                  if condition1
                  for expr2 in sequence2
                  if condition2
                  for expr3 in sequence3
                  ...
                  if condition3
                  for exprN in sequenceN
                  if conditionN )

リスト内包表記も、外側の括弧が違うだけ (丸ではなく角括弧) で、あとは同じ
です。

生成される出力は ‘expression’ 部分の値を要素として並べたものになります。
‘if’ 節はすべて、なくても大丈夫です; あれば ‘condition’ が真のときだけ
‘expression’ が評価されて出力に追加されます。

ジェネレータ式は常に括弧の中に書かなければなりませんが、関数コールの目印
になっている括弧でも大丈夫です。関数にすぐ渡すイテレータを作りたければこ
う書けるのです:

     obj_total = sum(obj.count for obj in list_all_objects())

‘for...in’ 節は複数つなげられますが、どれにも、イテレートするためのシー
ケンスが含まれています。それらのシーケンスは並行して 'ではなく' 、左から
右へ順番にイテレートされるので、長さが同じである必要はありません。
‘sequence1’ の各要素ごとに毎回最初から ‘sequence2’ をループで回すのです
。その後 ‘sequence1’ と ‘sequence2’ から出た要素ペアごとに、 ‘sequence3’
でループします。

別の書き方をすると、リスト内包表記やジェネレータ式は次の Python コードと
同じ意味になります:

     for expr1 in sequence1:
         if not (condition1):
             continue   # Skip this element
         for expr2 in sequence2:
             if not (condition2):
                 continue   # Skip this element
             ...
             for exprN in sequenceN:
                 if not (conditionN):
                     continue   # Skip this element

                 # Output the value of
                 # the expression.

つまり、複数の ‘for...in’ 節があって ‘if’ がないときの最終出力は、長さが
各シーケンス長の積に等しくなるということです。長さ 3 のリスト二つなら、
出力リストの長さは 9 要素です:

     >>> seq1 = 'abc'
     >>> seq2 = (1, 2, 3)
     >>> [(x, y) for x in seq1 for y in seq2]
     [('a', 1), ('a', 2), ('a', 3),
      ('b', 1), ('b', 2), ('b', 3),
      ('c', 1), ('c', 2), ('c', 3)]

Python の文法に曖昧さを紛れ込ませないように、 ‘expression’ でタプルを作
るなら括弧で囲わなくてはなりません。下にあるリスト内包表記で、最初のは構
文エラーですが、二番目は有効です:

     # Syntax error
     [x, y for x in seq1 for y in seq2]
     # Correct
     [(x, y) for x in seq1 for y in seq2]


File: python.info,  Node: ジェネレータ generator<2>,  Next: 組み込み関数 built-in function<2>,  Prev: ジェネレータ式とリスト内包表記,  Up: 関数型プログラミング HOWTO

9.6.4 ジェネレータ (generator)
------------------------------

ジェネレータは、イテレータを書く作業を簡単にする、特殊な関数です。標準的
な関数は値を計算して返しますが、ジェネレータが返すのは、一連の値を返すイ
テレータです。

Python や C の標準的な関数コールについては、よくご存じに違いありません。
関数を呼ぶと、ローカル変数を作るプライベートな名前空間ができますね。その
関数が ‘return’ 文まで来ると、ローカル変数が破壊されてから、返り値が呼び
出し元に返ります。次に同じ関数をもう一度呼ぶと、新しいプライベート名前空
間に新規のローカル変数が作られるのです。しかし、関数を出るときにローカル
変数を捨てなければどうなるでしょうか。その出ていったところから関数を続行
できたとしたら、どうでしょう。これこそジェネレータが提供する機能です; す
なわち、ジェネレータは続行できる関数と考えることができます。

ごく単純なジェネレータ関数の例がこちらにあります:

     >>> def generate_ints(N):
     ...    for i in range(N):
     ...        yield i

*note yield: 99b. キーワードを含む関数はすべてジェネレータ関数です;
Python の *note bytecode: 16c. コンパイラがこれを検出して、特別な方法で
コンパイルしてくれるのです。

ジェネレータ関数は、呼ばれたときに一回だけ値を返すのではなく、イテレータ
プロトコルに対応したオブジェクトを返します。上の例で ‘yield’ を実行した
とき、 ジェネレータは ‘return’ 文のようにして ‘i’ の値を出力します。
‘yield’ と ‘return’ 文の大きな違いは、 ‘yield’ に到達した段階でジェネレ
ータの実行状態が一時停止になって、ローカル変数が保存される点です。 次回
そのジェネレータの *note __next__(): 1c2f. を呼ぶと、そこから関数が実行
を再開します。

上記 ‘generate_ints()’ ジェネレータの使用例はこちらです:

     >>> gen = generate_ints(3)
     >>> gen
     <generator object generate_ints at ...>
     >>> next(gen)
     0
     >>> next(gen)
     1
     >>> next(gen)
     2
     >>> next(gen)
     Traceback (most recent call last):
       File "stdin", line 1, in <module>
       File "stdin", line 2, in generate_ints
     StopIteration

同じく ‘for i in generate_ints(5)’ や ‘a, b, c = generate_ints(3)’ とい
った書き方もできます。

ジェネレータ関数の中では、‘return value’ は *note __next__(): 1c2f. メソ
ッドから送出された ‘StopIteration(value)’ を引き起こします。これが発生し
た場合や、関数の終わりに到達した場合は、値の生成が終了してジェネレーター
がそれ以上の値を返さない。

自分でクラスを書いて、ジェネレータで言うところのローカル変数をインスタン
ス変数として全部保管しておけば、同じ効果を得ることは可能です。たとえば整
数のリストを返すのは、 ‘self.count’ を 0 にして、 *note __next__():
129b. メソッドが ‘self.count’ をインクリメントして返すようにすればできま
す。しかしながら、ある程度複雑なジェネレータになってくると、同じことをす
るクラスを書くのは格段にややこしいことになります。

Python のライブラリに含まれているテストスイート
Lib/test/test_generators.py(1) には、ほかにも興味深い例が数多く入ってい
ます。これは二分木の通りがけ順 (in-order) 探索を再帰で実装したジェネレー
タです。

     # A recursive generator that generates Tree leaves in in-order.
     def inorder(t):
         if t:
             for x in inorder(t.left):
                 yield x

             yield t.label

             for x in inorder(t.right):
                 yield x

ほかにも ‘test_generators.py’ には、N-Queens 問題 (N×N コマのチェス盤に
、互いに攻撃できないような配置で N 個のクイーンを置く) やナイト・ツアー
(N×N 盤の全コマをナイトが一度ずつ通るような経路を探す) の解を出す例が入
っています。

* Menu:

* ジェネレータに値を渡す::

   ---------- Footnotes ----------

   (1) 
https://github.com/python/cpython/tree/3.13/Lib/test/test_generators.py


File: python.info,  Node: ジェネレータに値を渡す,  Up: ジェネレータ generator<2>

9.6.4.1 ジェネレータに値を渡す
..............................

Python 2.4 までのジェネレータは出力することしかできませんでした。ジェネ
レータのコードを実行してイテレータを作ってしまったあとで、その関数を再開
するときに新しい情報を渡す手段はなかったのです。ジェネレータがグローバル
変数を見るようにしたり、ミュータブルなオブジェクトを渡しておいて呼び出し
元であとからそれを変更したり、といったハックは可能でしたが、どれもゴチャ
ゴチャしていますね。

Python 2.5 で、ジェネレータに値を渡す簡単な手段ができました。 *note
yield: 99b. が、変数に代入したり演算したりできる値を返す式になったのです
:

     val = (yield i)

上のように、返り値で何かをするときは ‘yield’ 式の前後に '必ず' 括弧を付
けるようお勧めします。括弧は常に必要なわけではありませんが、どんなとき付
けなくて良いのかを覚えておくより、いつも付けておくほうが楽ですから。

( PEP 342(1) がその規則を正確に説明していますが、それによると ‘yield’-式
は、代入式で右辺のトップレベルにあるとき以外はいつも括弧を付ける必要があ
ります。つまり ‘val = yield i’ とは書けますが、 ‘val = (yield i) + 12’ の
ように演算子があるときは括弧を使わなくてはいけません。)

ジェネレータに値を送るには *note send(value): 1036. メソッドを呼びます。
するとジェネレータのコードが実行を再開し、 ‘yield’ 式がその値を返すので
す。ふつうの *note __next__(): 1c2f. メソッドを呼ぶと、 ‘yield’ は
‘None’ を返します。

下にあるのは 1 ずつ増える単純なカウンタですが、内部カウンタの値を変更す
ることができるようになっています。

     def counter(maximum):
         i = 0
         while i < maximum:
             val = (yield i)
             # If value provided, change counter
             if val is not None:
                 i = val
             else:
                 i += 1

そしてカウンタ変更の例がこちらです:

     >>> it = counter(10)
     >>> next(it)
     0
     >>> next(it)
     1
     >>> it.send(8)
     8
     >>> next(it)
     9
     >>> next(it)
     Traceback (most recent call last):
       File "t.py", line 15, in <module>
         it.next()
     StopIteration

‘yield’ が ‘None’ を返すことはよくあるのですから、そうなっていないかどう
か必ずチェックしておくべきです。ジェネレータ関数を再開するために使うメソ
ッドが *note send(): 1036. しかないのだと確定してるのでない限り、式の値
をそのまま使ってはいけません。

ジェネレータには、 *note send(): 1036. のほかにもメソッドが二つあります:

   * *note throw(value): 4c5. はジェネレータ内で例外を投げるために使いま
     す; その例外はジェネレータの実行が停止したところの ‘yield’ 式によっ
     て投げられます。

   * *note close(): 1659. はジェネレータ内で *note GeneratorExit: 136f.
     例外を投げて、 イテレートを終了させます。この例外を受け取ったジェネ
     レータのコードは *note GeneratorExit: 136f. か *note StopIteration:
     bc8. を投げなくてはいけません; この例外を捕捉して何かほかのことをし
     ようとするのは規則違反であり、 *note RuntimeError: 17a. を引き起こ
     します。 *note close(): 1659. はジェネレータが GC されるときにも呼
     ばれます。

     *note GeneratorExit: 136f. が起こったときにクリーンアップ作業をする
     必要があるなら、 *note GeneratorExit: 136f. を捕捉するのではなく
     ‘try: ... finaly:’ するようお勧めします。

これらの変更の合わせ技で、ジェネレータは情報の一方的な生産者から、生産者
かつ消費者という存在に変貌を遂げたのです。

ジェネレータは 'コルーチン' という、より一般化された形式のサブルーチンに
もなります。サブルーチンは一カ所 (関数の冒頭) から入って別の一カ所
(‘return’ 文) から出るだけですが、コルーチンはいろいろな場所 (‘yield’ 文
) から入ったり出たり再開したりできるのです。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0342/


File: python.info,  Node: 組み込み関数 built-in function<2>,  Next: itertools モジュール,  Prev: ジェネレータ generator<2>,  Up: 関数型プログラミング HOWTO

9.6.5 組み込み関数 (built-in function)
--------------------------------------

よくイテレータと一緒に使うビルトイン関数について、もっと詳しく見ていきま
しょう。

Python のビルトイン関数 *note map(): 82f. と *note filter(): 830. は、機
能がジェネレータ式と重複しています:

*note map(f, iterA, iterB, ...): 82f. は以下のシーケンスのイテレータを返します

     ‘f(iterA[0], iterB[0]), f(iterA[1], iterB[1]), f(iterA[2],
     iterB[2]), ...’.

          >>> def upper(s):
          ...     return s.upper()

          >>> list(map(upper, ['sentence', 'fragment']))
          ['SENTENCE', 'FRAGMENT']
          >>> [upper(s) for s in ['sentence', 'fragment']]
          ['SENTENCE', 'FRAGMENT']

もちろん、リスト内包表記でも同じ結果が得られます。

*note filter(predicate, iter): 830. はある条件を満たす要素に渡るイテレー
タを返すので、同様にリスト内包表記で再現できます。 'predicate' は、ある
条件に対する真偽値を返す関数です; *note filter(): 830. で使うには、その
関数の引数は一つでなければなりません。

     >>> def is_even(x):
     ...     return (x % 2) == 0

     >>> list(filter(is_even, range(10)))
     [0, 2, 4, 6, 8]

これはリスト内包表記でも書けます:

     >>> list(x for x in range(10) if is_even(x))
     [0, 2, 4, 6, 8]

*note enumerate(iter, start=0): 1424. はイテラブルの要素に順番に番号を振
っていき、('start' から数え始めたときの) 番号とそれぞれの要素を含む 2 タ
プルを返します。

     >>> for item in enumerate(['subject', 'verb', 'object']):
     ...     print(item)
     (0, 'subject')
     (1, 'verb')
     (2, 'object')

*note enumerate(): 1424. はよく、リストに対してループさせて、条件に合う
所に印を付けていくときに使われます:

     f = open('data.txt', 'r')
     for i, line in enumerate(f):
         if line.strip() == '':
             print('Blank line at line #%i' % i)

*note sorted(iterable, key=None, reverse=False): b9c. はイテラブルの要素
をすべて集めたリストを作り、ソートして返します。 引数 'key' および
'reverse' は、リストの *note sort(): b9d. メソッドにそのまま渡されます。

     >>> import random
     >>> # Generate 8 random numbers between [0, 10000)
     >>> rand_list = random.sample(range(10000), 8)
     >>> rand_list
     [769, 7953, 9828, 6431, 8442, 9878, 6213, 2207]
     >>> sorted(rand_list)
     [769, 2207, 6213, 6431, 7953, 8442, 9828, 9878]
     >>> sorted(rand_list, reverse=True)
     [9878, 9828, 8442, 7953, 6431, 6213, 2207, 769]

(ソートに関する詳細な論議は *note ソートのテクニック: 11ab. を参照)

組み込みの *note any(iter): 13c8. および *note all(iter): 13c9. は
iterable の値の真偽を調べます。 *note any(): 13c8. は要素のどれかが真値
なら ‘True’ を返し、 *note all(): 13c9. は要素が全て真値なら ‘True’ を返
します:

     >>> any([0, 1, 0])
     True
     >>> any([0, 0, 0])
     False
     >>> any([1, 1, 1])
     True
     >>> all([0, 1, 0])
     False
     >>> all([0, 0, 0])
     False
     >>> all([1, 1, 1])
     True

*note zip(iterA, iterB, ...): 79b. はそれぞれの iterable から1つの要素を
取り、それらをタプルに入れて返します:

     zip(['a', 'b', 'c'], (1, 2, 3)) =>
       ('a', 1), ('b', 2), ('c', 3)

*note zip(): 79b. は結果を返す前に入力のイテレーターを全て消費してメモリ
上に list を作成しません。代わりに要求されるたびに tuple を生成して返し
ます。(この動作を技術的な用語で lazy evaluation(1) (訳: 遅延評価(2)) と
呼びます。)

このイテレータの用途には、すべて同じ長さのイテラブルを想定しています。長
さが違っていれば、出力されるストリームは一番短いイテラブルと同じ長さにな
ります。

     zip(['a', 'b'], (1, 2, 3)) =>
       ('a', 1), ('b', 2)

とは言え、これをやってしまうと長いイテレータから要素をひとつ無駄に多く取
って捨ててしまうかもしれませんので、やめておいたほうが良いです。その捨て
られた要素を抜かしてしまう危険があるので、もうそのイテレータはそれ以上使
えなくなってしまいます。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Lazy_evaluation

   (2) 
https://ja.wikipedia.org/wiki/%E9%81%85%E5%BB%B6%E8%A9%95%E4%BE%A1


File: python.info,  Node: itertools モジュール,  Next: functools モジュール,  Prev: 組み込み関数 built-in function<2>,  Up: 関数型プログラミング HOWTO

9.6.6 itertools モジュール
--------------------------

*note itertools: 75. モジュールには、よく使うイテレータや、イテレータ同
士の連結に使う関数がたくさん含まれています。この章では、そのモジュールの
内容を小さな例で紹介していきたいと思います。

このモジュールの関数を大まかに分けるとこうなります:

   * 既存のイテレータに基づいて新しいイテレータを作る関数。

   * イテレータの要素を引数として扱う関数。

   * イテレータの出力から一部を取り出す関数。

   * イテレータの出力をグループ分けする関数。

* Menu:

* 新しいイテレータを作る::
* 要素に対して関数を呼ぶ::
* 要素を選択する::
* 組合せ関数::
* 要素をグループ分けする::


File: python.info,  Node: 新しいイテレータを作る,  Next: 要素に対して関数を呼ぶ,  Up: itertools モジュール

9.6.6.1 新しいイテレータを作る
..............................

*note itertools.count(start, step): 1254. は値の間隔が一定の無限ストリー
ムを返します。 オプションで開始する数 (デフォルトは 0) や数どうしの間隔
(デフォルトは 1) を与えられます:

     itertools.count() =>
       0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...
     itertools.count(10) =>
       10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...
     itertools.count(10, 5) =>
       10, 15, 20, 25, 30, 35, 40, 45, 50, 55, ...

*note itertools.cycle(iter): 267b. は与えられたイテラブルの内容をコピー
して、 その要素を最初から最後まで無限に繰り返していくイテレータを返しま
す。

     itertools.cycle([1, 2, 3, 4, 5]) =>
       1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ...

*note itertools.repeat(elem, [n]): 267c. は、与えられた要素を 'n' 回返し
ますが、 'n' がなければ永遠に返し続けます。

     itertools.repeat('abc') =>
       abc, abc, abc, abc, abc, abc, abc, abc, abc, abc, ...
     itertools.repeat('abc', 5) =>
       abc, abc, abc, abc, abc

*note itertools.chain(iterA, iterB, ...): 20e4. は任意の数のイテラブルを
受け取って、最初のイテレータから要素をすべて返し、次に二番目から 要素を
すべて返し、ということを要素がなくなるまで続けます。

     itertools.chain(['a', 'b', 'c'], (1, 2, 3)) =>
       a, b, c, 1, 2, 3

*note itertools.islice(iter, [start], stop, [step]): b1a. は、イテレータ
の スライスをストリームで返します。 'stop' 引数だけだと、最初の 'stop' 個
の要素を返します。開始インデックスを渡すと 'stop-start' 個で、 'step' の
値も渡せばそれに応じて要素を抜かします。Python における文字列やリストの
スライスとは違って、マイナスの値は 'start', 'stop', 'step' に使えません
。

     itertools.islice(range(10), 8) =>
       0, 1, 2, 3, 4, 5, 6, 7
     itertools.islice(range(10), 2, 8) =>
       2, 3, 4, 5, 6, 7
     itertools.islice(range(10), 2, 8, 2) =>
       2, 4, 6

*note itertools.tee(iter, [n]): 2681. はイテレータを複製します; 元のイテ
レータの内容を同じように返す、独立した 'n' 個のイテレータを返すのです。
'n' の値は、指定しなければ既定が 2 になっています。複製するには元のイテ
レータの内容を一部保存しておく必要がありますから、大きなイテレータから複
製したうちの一つが他よりも進んでいってしまうと、大量のメモリを消費するこ
とがあります。

     itertools.tee( itertools.count() ) =>
        iterA, iterB

     where iterA ->
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...

     and   iterB ->
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ...


File: python.info,  Node: 要素に対して関数を呼ぶ,  Next: 要素を選択する,  Prev: 新しいイテレータを作る,  Up: itertools モジュール

9.6.6.2 要素に対して関数を呼ぶ
..............................

いま使った *note operator: 8f. モジュールには、Python の演算子に対応する
関数が入っています。いくつか例を挙げると、 *note operator.add(a, b):
26a4. (二つの値を加算)、 *note operator.ne(a, b): 2694. (‘a != b’ と同じ
)、 *note operator.attrgetter('id'): e00. (‘.id’ 属性を取得するコーラブ
ルを返す) といった関数です。

*note itertools.starmap(func, iter): 10b5. は、イテラブルがタプルのスト
リームを返すとみなして、 そのタプルを引数に使って 'func' を呼びます:

     itertools.starmap(os.path.join,
                       [('/bin', 'python'), ('/usr', 'bin', 'java'),
                        ('/usr', 'bin', 'perl'), ('/usr', 'bin', 'ruby')])
     =>
       /bin/python, /usr/bin/java, /usr/bin/perl, /usr/bin/ruby


File: python.info,  Node: 要素を選択する,  Next: 組合せ関数,  Prev: 要素に対して関数を呼ぶ,  Up: itertools モジュール

9.6.6.3 要素を選択する
......................

さらに別のグループとして、述語 (predicate) に基づいてイテレータの要素か
らサブセットを選び出す関数があります。

*note itertools.filterfalse(predicate, iter): 20cc. は *note filter():
830. とは反対に、 述語が偽を返す要素をすべて返します:

     itertools.filterfalse(is_even, itertools.count()) =>
       1, 3, 5, 7, 9, 11, 13, 15, ...

*note itertools.takewhile(predicate, iter): 2680. は述語が真を返している
間だけ要素を返します。一度でも述語が偽を返すと、イテレータは出力終了の合
図をします。

     def less_than_10(x):
         return x < 10

     itertools.takewhile(less_than_10, itertools.count()) =>
       0, 1, 2, 3, 4, 5, 6, 7, 8, 9

     itertools.takewhile(is_even, itertools.count()) =>
       0

*note itertools.dropwhile(predicate, iter): 267e. は、述語が真を返してい
るうちは要素を無視し、偽になってから残りの出力をすべて返します。

     itertools.dropwhile(less_than_10, itertools.count()) =>
       10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ...

     itertools.dropwhile(is_even, itertools.count()) =>
       1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...

*note itertools.compress(data, selectors): 1253. は 2つのイテレータを取
り、 どちらかのイテレータを使い果たすまでの、 'selectors' が真となる要素
に対応する 'data' 要素だけを返します:

     itertools.compress([1, 2, 3, 4, 5], [True, True, False, False, True]) =>
        1, 2, 5


File: python.info,  Node: 組合せ関数,  Next: 要素をグループ分けする,  Prev: 要素を選択する,  Up: itertools モジュール

9.6.6.4 組合せ関数
..................

*note itertools.combinations(iterable, r): 12e1. は、 'iterable' から
'r'-tuple 選択する全ての組み合わせを提供するイテレータを返します

     itertools.combinations([1, 2, 3, 4, 5], 2) =>
       (1, 2), (1, 3), (1, 4), (1, 5),
       (2, 3), (2, 4), (2, 5),
       (3, 4), (3, 5),
       (4, 5)

     itertools.combinations([1, 2, 3, 4, 5], 3) =>
       (1, 2, 3), (1, 2, 4), (1, 2, 5), (1, 3, 4), (1, 3, 5), (1, 4, 5),
       (2, 3, 4), (2, 3, 5), (2, 4, 5),
       (3, 4, 5)

それぞれのタプル内では、要素は 'iterable' がそれを返したのと同じ順序を保
ちます。例えば上の例であれば、 1 はいつでも 2, 3, 4, 5 の前に来ます。似
たような関数に *note itertools.permutations(iterable, r=None): 1885. が
あり、こちらはこの順序についての制約がなく、 'r' 個選択する全ての順列を
返します。

     itertools.permutations([1, 2, 3, 4, 5], 2) =>
       (1, 2), (1, 3), (1, 4), (1, 5),
       (2, 1), (2, 3), (2, 4), (2, 5),
       (3, 1), (3, 2), (3, 4), (3, 5),
       (4, 1), (4, 2), (4, 3), (4, 5),
       (5, 1), (5, 2), (5, 3), (5, 4)

     itertools.permutations([1, 2, 3, 4, 5]) =>
       (1, 2, 3, 4, 5), (1, 2, 3, 5, 4), (1, 2, 4, 3, 5),
       ...
       (5, 4, 3, 2, 1)

'r' を与えない場合は iterable の長さが使われます。つまり iterable の全て
の要素を選んだ順列を返します。

これらの関数が生成する組み合わせは、位置が基準ですので、 'iterable' の内
容が一意でなくとも良いことに注目してください:

     itertools.permutations('aba', 3) =>
       ('a', 'b', 'a'), ('a', 'a', 'b'), ('b', 'a', 'a'),
       ('b', 'a', 'a'), ('a', 'a', 'b'), ('a', 'b', 'a')

全く同じタプル ‘('a', 'a', 'b')’ が 2度現れていますが、これは 2つの 'a'
が別の位置からのものだからです。

*note itertools.combinations_with_replacement(iterable, r): 1252. 関数は
別の制約を取り払います: 一回の選択で同じ要素を繰り返し選んでも良い。概念
的には、それぞれのタプルの最初のものとして一つ要素が選ばれ、続いて 2つ目
の選択のかわりにそれで置き換わります

     itertools.combinations_with_replacement([1, 2, 3, 4, 5], 2) =>
       (1, 1), (1, 2), (1, 3), (1, 4), (1, 5),
       (2, 2), (2, 3), (2, 4), (2, 5),
       (3, 3), (3, 4), (3, 5),
       (4, 4), (4, 5),
       (5, 5)


File: python.info,  Node: 要素をグループ分けする,  Prev: 組合せ関数,  Up: itertools モジュール

9.6.6.5 要素をグループ分けする
..............................

最後に議題に上げる関数 *note itertools.groupby(iter, key_func=None):
267f. は、 これまでで最も複雑です。 ‘key_func(elem)’ は、イテラブルから
返ってきた要素それぞれのキー値を計算する関数です。この関数が指定されてい
なければ、 キーは単に各要素そのものになります。

*note groupby(): 267f. は、元になるイテラブルから同じキー値を持つ連続す
る要素を集めて、キー値とそのキーに対応する要素のイテレータの 2-タプルの
ストリームを返します。

     city_list = [('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL'),
                  ('Anchorage', 'AK'), ('Nome', 'AK'),
                  ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ'),
                  ...
                 ]

     def get_state(city_state):
         return city_state[1]

     itertools.groupby(city_list, get_state) =>
       ('AL', iterator-1),
       ('AK', iterator-2),
       ('AZ', iterator-3), ...

     where
     iterator-1 =>
       ('Decatur', 'AL'), ('Huntsville', 'AL'), ('Selma', 'AL')
     iterator-2 =>
       ('Anchorage', 'AK'), ('Nome', 'AK')
     iterator-3 =>
       ('Flagstaff', 'AZ'), ('Phoenix', 'AZ'), ('Tucson', 'AZ')

*note groupby(): 267f. は、元になるイテラブルの内容がキー値でソートされ
た状態で与えられることを想定しています。ここで、返されるイテレータ自体も
元のイテラブルを使うということに注意してください。そのため、 iterator-1
の結果を読み終わるまでは iterator-2 とそれに対応するキー値を要求すること
はできません。


File: python.info,  Node: functools モジュール,  Next: 小さな関数とラムダ式,  Prev: itertools モジュール,  Up: 関数型プログラミング HOWTO

9.6.7 functools モジュール
--------------------------

*note functools: 55. モジュールには、高階関数がいくつか入っています。 '高
階関数' とは、入力として関数を受け取って新たな関数を返す関数です。このモ
ジュールで一番便利なツールは *note functools.partial(): 3ed. 関数です。

関数型スタイルのプログラムでは時折、既存の関数から一部のパラメータを埋め
た変種を作りたくなることがあります。Python の関数 ‘f(a, b, c)’ というも
のがあるとしてください; ‘f(1, b, c)’ と同じ意味の ‘g(b, c)’ という関数を
作りたくなることがあります; つまり ‘f()’ のパラメータを一つ埋めるわけで
す。これは「関数の部分適用」と呼ばれています。

*note partial(): 3ed. のコンストラクタは ‘(function, arg1, arg2, ...,
kwarg1=value1, kwarg2=value2)’ という引数を取ります。できあがったオブジ
ェクトはコーラブルなので、それを呼べば、引数の埋まった状態で ‘function’
を実行したのと同じことになります。

以下にあるのは、小さいけれども現実的な一つの例です:

     import functools

     def log(message, subsystem):
         """Write the contents of 'message' to the specified subsystem."""
         print('%s: %s' % (subsystem, message))
         ...

     server_log = functools.partial(log, subsystem='server')
     server_log('Unable to open socket')

*note functools.reduce(func, iter, [initial_value]): 12aa. はイテラブル
の要素に対して次々に演算を実行していった最終結果を出すもので、それゆえ無
限長イテラブルには適用できません。 'func' には、要素を二つ取って値を一つ
返す関数が入ります。 *note functools.reduce(): 12aa. はイテレータが返す
最初の二要素 A と B を取って ‘func(A, B)’ を計算します。それから三番目の
要素 C を要求して ‘func(func(A, B), C)’ を計算すると、その結果をさらに四
番目の要素と組み合わせて……ということをイテラブルが尽きるまで続けるのです
。 もしイテラブルが一つも値を返さなければ *note TypeError: 502. が発生し
ます。 初期値 ‘initial_value’ があるときには、最初の計算で
‘func(initial_value, A)’ が実行されます。

     >>> import operator, functools
     >>> functools.reduce(operator.concat, ['A', 'BB', 'C'])
     'ABBC'
     >>> functools.reduce(operator.concat, [])
     Traceback (most recent call last):
       ...
     TypeError: reduce() of empty sequence with no initial value
     >>> functools.reduce(operator.mul, [1, 2, 3], 1)
     6
     >>> functools.reduce(operator.mul, [], 1)
     1

*note operator.add(): 26a4. を *note functools.reduce(): 12aa. で使うと
、 iterable の全要素を合計することになります。これは使用頻度が高いので、
そのための *note sum(): 437. というビルトイン関数があります:

     >>> import functools, operator
     >>> functools.reduce(operator.add, [1, 2, 3, 4], 0)
     10
     >>> sum([1, 2, 3, 4])
     10
     >>> sum([])
     0

とはいえ、多くの場合 *note functools.reduce(): 12aa. を使うよりは、単に
*note for: 2c9. ループを書いたほうがわかりやすくなります:

     import functools
     # Instead of:
     product = functools.reduce(operator.mul, [1, 2, 3], 1)

     # You can write:
     product = 1
     for i in [1, 2, 3]:
         product *= i

関連する関数は *note itertools.accumulate(iterable, func=operator.add):
9cb. です。この関数は同じ計算をしますが、最終結果を返すのではなく、
*note accumulate(): 9cb. はそれぞれの中間結果を生成するイテレータが返り
値となります。

     itertools.accumulate([1, 2, 3, 4, 5]) =>
       1, 3, 6, 10, 15

     itertools.accumulate([1, 2, 3, 4, 5], operator.mul) =>
       1, 2, 6, 24, 120

* Menu:

* operator モジュール::


File: python.info,  Node: operator モジュール,  Up: functools モジュール

9.6.7.1 operator モジュール
...........................

*note operator: 8f. モジュールは、既に取り上げましたが、Python の演算子
に対応する関数が入っているモジュールです。関数型スタイルのコードにおいて
、演算を一つ実行するだけのくだらない関数を書かずに済むので、よく世話にな
ります。

このモジュールの関数を一部だけ紹介しましょう:

   * 数学演算子: ‘add()’, ‘sub()’, ‘mul()’, ‘floordiv()’, ‘abs()’, ...

   * 論理演算子: ‘not_()’, ‘truth()’

   * ビット演算子: ‘and_()’, ‘or_()’, ‘invert()’

   * 比較: ‘eq()’, ‘ne()’, ‘lt()’, ‘le()’, ‘gt()’, ‘ge()’

   * オブジェクト識別: ‘is_()’, ‘is_not()’

ちゃんとした一覧は operator モジュールの文書でご覧ください。


File: python.info,  Node: 小さな関数とラムダ式,  Next: 更新履歴と謝辞,  Prev: functools モジュール,  Up: 関数型プログラミング HOWTO

9.6.8 小さな関数とラムダ式
--------------------------

関数型スタイルのプログラムを書いていると、述語として働いたり、何らかの形
で要素をつなぎ合わせたりするミニサイズの関数を必要とすることがよくありま
す。

ちょうど良い関数がビルトインやモジュールで存在していれば、新しい関数を定
義する必要はまったくありません:

     stripped_lines = [line.strip() for line in lines]
     existing_files = filter(os.path.exists, file_list)

しかし、欲しい関数がないなら書くしかありません。そうした小さな関数を書く
方法の 一つが *note lambda: 126d. 式です。 ‘lambda’ は引数として複数のパ
ラメータと それをつなぐ式を取り、その式の値を返す無名の関数を作ります:

     adder = lambda x, y: x+y

     print_assign = lambda name, value: name + '=' + str(value)

もう一つの選択肢は、ふつうに ‘def’ 文で関数を定義するだけです:

     def adder(x, y):
         return x + y

     def print_assign(name, value):
         return name + '=' + str(value)

どちらのほうが良いのでしょうか。それは好みの問題です; 著者のスタイルとし
てはできるだけ ‘lambda’ を使わないようにしています。

そのようにしている理由の一つに、‘lambda’ は定義できる関数が非常に限られ
ているという点があります。一つの式として算出できる結果にしなければいけま
せんので、‘if... elif... else’ や ‘try... except’ のような分岐を持つこと
ができないのです。‘lambda’ 文の中でたくさんのことをやろうとしすぎると、
ごちゃごちゃして読みにくい式になってしまいます。さて、次のコードは何をし
ているでしょうか、素早くお答えください!

     import functools
     total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]

わかるにはわかるでしょうが、何がどうなっているのか紐解いていくには時間が
かかるはずです。短い ‘def’ 文で入れ子にすると、少し見通しが良くなります
が:

     import functools
     def combine(a, b):
         return 0, a[1] + b[1]

     total = functools.reduce(combine, items)[1]

でも単純に ‘for’ ループにすれば良かったのです:

     total = 0
     for a, b in items:
         total += b

あるいは *note sum(): 437. ビルトインとジェネレータ式でも良いですね:

     total = sum(b for a, b in items)

多くの場合、 *note functools.reduce(): 12aa. を使っているところは ‘for’
ループに 書き直したほうが見やすいです。

Fredrik Lundh は以前 ‘lambda’ 利用のリファクタリングに関して以下の指針を
提案したことがあります:

  1. ラムダ関数を書く。

  2. そのラムダが一体ぜんたい何をしているのかコメントで説明する。

  3. そのコメントをしばらく研究して、本質をとらえた名前を考える。

  4. ラムダをその名前で def 文に書き換える。

  5. コメントを消す。

著者はこの指針を本当に気に入っていますが、こうしたラムダなしスタイルが他
より優れているかどうかについて、異論は認めます。


File: python.info,  Node: 更新履歴と謝辞,  Next: 参考資料<2>,  Prev: 小さな関数とラムダ式,  Up: 関数型プログラミング HOWTO

9.6.9 更新履歴と謝辞
--------------------

著者は提案の申し出や修正、様々なこの記事の草稿の助けをしてくれた以下の人
々に感謝します: Ian Bicking, Nick Coghlan, Nick Efford, Raymond
Hettinger, Jim Jewett, Mike Krell, Leandro Lameiro, Jussi Salmela,
Collin Winter, Blake Winton.

Version 0.1: posted June 30 2006.

Version 0.11: posted July 1 2006.  Typo fixes.

Version 0.2: posted July 10 2006.  Merged genexp and listcomp sections
into one.  Typo fixes.

Version 0.21: Added more references suggested on the tutor mailing list.

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.


File: python.info,  Node: 参考資料<2>,  Prev: 更新履歴と謝辞,  Up: 関数型プログラミング HOWTO

9.6.10 参考資料
---------------

* Menu:

* 一般論::
* Python 特有の話::
* Python 文書::


File: python.info,  Node: 一般論,  Next: Python 特有の話,  Up: 参考資料<2>

9.6.10.1 一般論
...............

'計算機プログラムの構造と解釈'、Harold AbelsonとGerald Jay Sussman、
Julie Sussman著。この本は ‘https://mitpress.mit.edu/sicp’ で見れます。こ
の計算機科学の古典的な教科書では、2章と3章でシーケンスとストリームを使っ
てプログラム内のデータフローを整理する方法について説明しています。この本
では例に Scheme を使っていますが、これらの章で説明されている設計アプロー
チの多くは、関数型スタイルの Python コードにも適用できます。

‘https://www.defmacro.org/ramblings/fp.html’: 関数プログラミングの一般的
な入門で Java での例を利用していて、長大な歴史の紹介があります。

‘https://en.wikipedia.org/wiki/Functional_programming’: 関数プログラミン
グに関する一般的な内容の記事。

‘https://en.wikipedia.org/wiki/Coroutine’: コルーチンに関する記事。

‘https://en.wikipedia.org/wiki/Partial_application’: 関数の部分適用の概
念についての記事。

‘https://en.wikipedia.org/wiki/Currying’: カリー化の概念に関する記事。


File: python.info,  Node: Python 特有の話,  Next: Python 文書,  Prev: 一般論,  Up: 参考資料<2>

9.6.10.2 Python 特有の話
........................

‘https://gnosis.cx/TPiP/’: David Mertz's の本の最初の章 ‘Text Processing
in Python’ では文書処理のための関数プログラミングについて議論しています
、この議論の節には "Utilizing Higher-Order Functions in Text Processing"
というタイトルがついています。

Mertz は IBM の DeveloperWorks サイトにも関数型プログラミングに関する 3
部構成の記事を書いています; part 1(1), part 2(2), part 3(3),

   ---------- Footnotes ----------

   (1) https://developer.ibm.com/articles/l-prog/

   (2) https://developer.ibm.com/tutorials/l-prog2/

   (3) https://developer.ibm.com/tutorials/l-prog3/


File: python.info,  Node: Python 文書,  Prev: Python 特有の話,  Up: 参考資料<2>

9.6.10.3 Python 文書
....................

*note itertools: 75. モジュールの文書。

*note functools: 55. モジュールについてのドキュメント。

*note operator: 8f. モジュールの文書。

PEP 289(1): "Generator Expressions"

PEP 342(2): "Coroutines via Enhanced Generators" describes the new
generator features in Python 2.5.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0289/

   (2) https://peps.python.org/pep-0342/


File: python.info,  Node: Logging HOWTO,  Next: Logging クックブック,  Prev: 関数型プログラミング HOWTO,  Up: Python HOWTO

9.7 Logging HOWTO
=================


著者: Vinay Sajip <vinay_sajip at red-dove dot com>

このページはチュートリアルです。レファレンスやロギングクックブックは、
*note その他のリソース: 4da5. を参照してください。

* Menu:

* 基本 logging チュートリアル::
* 上級ロギングチュートリアル::
* ロギングレベル: ロギングレベル<2>.
* 便利なハンドラ::
* ログ記録中に発生する例外::
* 任意のオブジェクトをメッセージに使用する::
* 最適化: 最適化<16>.
* その他のリソース::


File: python.info,  Node: 基本 logging チュートリアル,  Next: 上級ロギングチュートリアル,  Up: Logging HOWTO

9.7.1 基本 logging チュートリアル
---------------------------------

logging は、あるソフトウェアが実行されているときに起こったイベントを追跡
するための手段です。ソフトウェアの開発者は、特定のイベントが発生したこと
を示す logging の呼び出しをコードに加えます。イベントは、メッセージで記
述され、これに変数データ (すなわち、イベントが起こる度に異なるかもしれな
いデータ) を加えることもできます。イベントには、開発者がそのイベントに定
めた重要性も含まれます。重要性は、'レベル (level)' や '重大度
(severity)' とも呼ばれます。

* Menu:

* logging を使うとき::
* 簡単な例: 簡単な例<2>.
* ファイルへの logging::
* 変数データのロギング::
* 表示されるメッセージのフォーマットの変更::
* メッセージ内での日付と時刻の表示::
* 次のステップ::


File: python.info,  Node: logging を使うとき,  Next: 簡単な例<2>,  Up: 基本 logging チュートリアル

9.7.1.1 logging を使うとき
..........................

You can access logging functionality by creating a logger via ‘logger =
getLogger(__name__)’, and then calling the logger's *note debug(): df7,
*note info(): 1c5c, *note warning(): 1669, *note error(): 2c30. and
*note critical(): df6. methods.  To determine when to use logging, and
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.

行いたいタスク                            そのタスクに最適なツール
                                          
-------------------------------------------------------------------------------------
                                          
コマンドラインスクリプトやプログラムで    *note print(): f42.
普通に使う、コンソール出力の表示          

プログラムの通常の操作中に発生したイベ    A logger's *note info(): 1c5c. (or
ントの報告 (例えば、状態の監視や障害の    *note debug(): df7. method for very
分析)                                     detailed output for diagnostic purposes)
                                          
                                          
特定のランタイムイベントに関わる警告の    その発行が避けられるもので、クライアント
発行                                      アプリケーションを修正してその警告を排除
                                          するべきなら
                                          *note warnings.warn(): 14c3.
                                          
                                          A logger's *note warning(): 1669. method
                                          if there is nothing the client
                                          application can do about the situation,
                                          but the event should still be noted
                                          
                                          
特定のランタイムイベントに関わるエラー    例外の送出
の報告                                    

例外の送出をしないエラーの抑制 (例えば    A logger's *note error(): 2c30,
、長期のサーバプロセス中のエラーハンド    *note exception(): df5. or
ラ)                                       *note critical(): df6. method as
                                          appropriate for the specific error and
                                          application domain
                                          

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):

レベル             いつ使うか
                   
---------------------------------------------------------------------
                   
‘DEBUG’            おもに問題を診断するときにのみ関心があるような
                   、詳細な情報。
                   
                   
‘INFO’             想定された通りのことが起こったことの確認。
                   
                   
‘WARNING’          想定外のことが起こった、または問題が近く起こり
                   そうである (例えば、'disk space low') ことの表
                   示。
                   
                   
‘ERROR’            より重大な問題により、ソフトウェアがある機能を
                   実行できないこと。
                   
                   
‘CRITICAL’         プログラム自体が実行を続けられないことを表す、
                   重大なエラー。
                   

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.

追跡されるイベントは、異なる方法で処理されます。追跡されたイベントを処理
する最も単純な方法は、それをコンソールに表示することです。その他のよくあ
る方法は、それをディスクファイルに書き出すことです。


File: python.info,  Node: 簡単な例<2>,  Next: ファイルへの logging,  Prev: logging を使うとき,  Up: 基本 logging チュートリアル

9.7.1.2 簡単な例
................

ごく簡単な例は:

     import logging
     logging.warning('Watch out!')  # will print a message to the console
     logging.info('I told you so')  # will not print anything

これらの行をスクリプトにタイプして実行すると、次のようにコンソールに出力
されます:

     WARNING:root:Watch out!

printed out on the console.  The ‘INFO’ message doesn't appear because
the default level is ‘WARNING’.  The printed message includes the
indication of the level and the description of the event provided in the
logging call, i.e.  'Watch out!'.  The actual output can be formatted
quite flexibly if you need that; formatting options will also be
explained later.

Notice that in this example, we use functions directly on the ‘logging’
module, like ‘logging.debug’, rather than creating a logger and calling
functions on it.  These functions operation on the root logger, but can
be useful as they will call *note basicConfig(): 9ce. for you if it has
not been called yet, like in this example.  In larger programs you'll
usually want to control the logging configuration explicitly however -
so for that reason as well as others, it's better to create loggers and
call their methods.


File: python.info,  Node: ファイルへの logging,  Next: 変数データのロギング,  Prev: 簡単な例<2>,  Up: 基本 logging チュートリアル

9.7.1.3 ファイルへの logging
............................

logging イベントをファイルに記録するのは非常によくあるパターンなので次は
これを見て行きましょう。以下のサンプルを試すときは Python インタプリタを
新しく起動して、上のセッションの続きにならないようにしてください:

     import logging
     logger = logging.getLogger(__name__)
     logging.basicConfig(filename='example.log', encoding='utf-8', level=logging.DEBUG)
     logger.debug('This message should go to the log file')
     logger.info('So should this')
     logger.warning('And this, too')
     logger.error('And non-ASCII stuff, too, like Øresund and Malmö')

バージョン 3.9 で変更: 'encoding' 引数が追加されました。以前のバージョン
の Python では、あるいは指定されなかったら、エンコーディングには *note
open(): 4e5. が使うデフォルト値が使われます。上の例に出てきていませんが
、同じく渡せるようになった 'errors' 引数は、エンコーディングエラーの扱い
を決定します。利用可能な値およびデフォルト値については、 *note open():
4e5. のドキュメントを参照してください。

そして、ファイルの中身を確認すると、ログメッセージが確認できます:

     DEBUG:__main__:This message should go to the log file
     INFO:__main__:So should this
     WARNING:__main__:And this, too
     ERROR:__main__:And non-ASCII stuff, too, like Øresund and Malmö

この例はまた、追跡のしきい値となるロギングレベルを設定する方法も示してい
ます。この例では、しきい値を ‘DEBUG’ に設定しているので、全てのメッセー
ジが表示されています。

次のようなコマンドラインオプションでログレベルを設定したいと考え:

     --log=INFO

‘--log’ に渡されたパラメータの値を変数 'loglevel' に保存しているとしたら
、

     getattr(logging, loglevel.upper())

というコードを使い、 *note basicConfig(): 9ce. の 'level' 引数に渡すべき
値が得られます。ユーザの入力値をすべてエラーチェックしたくなり、次の例の
ように実装することもあるでしょう:

     # assuming loglevel is bound to the string value obtained from the
     # command line argument. Convert to upper case to allow the user to
     # specify --log=DEBUG or --log=debug
     numeric_level = getattr(logging, loglevel.upper(), None)
     if not isinstance(numeric_level, int):
         raise ValueError('Invalid log level: %s' % loglevel)
     logging.basicConfig(level=numeric_level, ...)

The call to *note basicConfig(): 9ce. should come 'before' any calls to
a logger's methods such as *note debug(): df7, *note info(): 1c5c, etc.
Otherwise, that logging event may not be handled in the desired manner.

上記のスクリプトを複数回実行すると、2 回目以降の実行によるメッセージは
'example.log' に加えられます。以前の実行によるメッセージを記憶せず、実行
ごとに新たに始めたいなら、上記の例での呼び出しを次のように変え、
'filemode' 引数を指定する方法がとれます:

     logging.basicConfig(filename='example.log', filemode='w', level=logging.DEBUG)

出力は先ほどと同じになりますが、ログファイルは追記されなくなり、以前の実
行によるメッセージは失われます。


File: python.info,  Node: 変数データのロギング,  Next: 表示されるメッセージのフォーマットの変更,  Prev: ファイルへの logging,  Up: 基本 logging チュートリアル

9.7.1.4 変数データのロギング
............................

変数データのログを取るには、イベント記述メッセージにフォーマット文字列を
使い、引数に変数データを加えてください。例えば:

     import logging
     logging.warning('%s before you %s', 'Look', 'leap!')

により、次のように表示されます:

     WARNING:root:Look before you leap!

ご覧の通り、イベント記述メッセージに変数データを統合するために、古い、%
スタイルの文字列フォーマットを使っています。これは後方互換性のためです。
logging パッケージは、 *note str.format(): 5ed. や *note
string.Template: 653. のような新しいフォーマットオプションよりも先に生ま
れました。新しいフォーマットオプションはサポートされて 'います' が、その
探求はこのチュートリアルでは対象としません。詳細は *note
固有の書式化スタイルをアプリケーション全体で使う: 2c4e. を参照してくださ
い。


File: python.info,  Node: 表示されるメッセージのフォーマットの変更,  Next: メッセージ内での日付と時刻の表示,  Prev: 変数データのロギング,  Up: 基本 logging チュートリアル

9.7.1.5 表示されるメッセージのフォーマットの変更
................................................

メッセージを表示するのに使われるフォーマットを変更するには、使いたいフォ
ーマットを指定する必要があります:

     import logging
     logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.DEBUG)
     logging.debug('This message should appear on the console')
     logging.info('So should this')
     logging.warning('And this, too')

により、次のように表示されます:

     DEBUG:This message should appear on the console
     INFO:So should this
     WARNING:And this, too

ご覧の通り、先の例に現れた 'root' が消失しています。フォーマット文字列に
含めることができるものの一覧は、 *note LogRecord 属性: 2c2e. のドキュメ
ントから参照できますが、単純な用途では、必要なものは 'levelname' (重大度
)、 'message' (変数データを含むイベント記述)、それともしかしたら、イベン
トがいつ起こったかという表示だけです。これは次の節で解説します。


File: python.info,  Node: メッセージ内での日付と時刻の表示,  Next: 次のステップ,  Prev: 表示されるメッセージのフォーマットの変更,  Up: 基本 logging チュートリアル

9.7.1.6 メッセージ内での日付と時刻の表示
........................................

イベントの日付と時刻を表示するには、フォーマット文字列に '%(asctime)s' を
置いてください:

     import logging
     logging.basicConfig(format='%(asctime)s %(message)s')
     logging.warning('is when this event was logged.')

これは以下の様なフォーマットで表示されます:

     2010-12-12 11:41:42,612 is when this event was logged.

デフォルトの日付と時間の表示フォーマット （上記の結果） は、ISO8601 や
RFC 3339(1) に似ています。日付と時間のフォーマットをより詳細に制御する必
要があるなら、以下の例の様に、 ‘basicConfig’ に 'datefmt' 引数を指定して
ください:

     import logging
     logging.basicConfig(format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
     logging.warning('is when this event was logged.')

これは次のように表示されます:

     12/12/2010 11:46:36 AM is when this event was logged.

'datefmt' 引数のフォーマットは、 *note time.strftime(): 11ba. でサポート
されているものと同じです。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc3339.html


File: python.info,  Node: 次のステップ,  Prev: メッセージ内での日付と時刻の表示,  Up: 基本 logging チュートリアル

9.7.1.7 次のステップ
....................

基本チュートリアルはこれで終わりです。あなたがロギングを使っていくために
は、これで十分でしょう。logging パッケージが提供するものはもっとあります
が、それを使いこなすためには、もうちょっと時間をかけて、以下のセクション
を読む必要があります。その用意ができたら、好きな飲み物を持って、次に進み
ましょう。

ロギングを簡潔に行いたいなら、上記の例を使って、ロギングをあなたのスクリ
プトに組み込んでください。問題があったり理解出来ないことがあったら、
comp.lang.python Usenet group
(‘https://groups.google.com/g/comp.lang.python’ から利用できます) に質問
を投稿してくだされば、そう遠くないうちに助けが得られるでしょう。

まだいますか？もう少し上級の、踏み込んだチュートリアルを綴った、幾つかの
節を読み続けることができます。その後で、 *note Logging クックブック:
11c8. もご覧ください。


File: python.info,  Node: 上級ロギングチュートリアル,  Next: ロギングレベル<2>,  Prev: 基本 logging チュートリアル,  Up: Logging HOWTO

9.7.2 上級ロギングチュートリアル
--------------------------------

logging ライブラリはモジュール方式のアプローチを取り、いくつかのカテゴリ
の部品を提供します。ロガー、ハンドラ、フィルタ、フォーマッタです。

   * ロガーは、アプリケーションコードが直接使うインターフェースを公開し
     ます。

   * ハンドラは、(ロガーによって生成された) ログ記録を適切な送信先に送り
     ます。

   * フィルタは、どのログ記録を出力するかを決定する、きめ細かい機能を提
     供します。

   * フォーマッタは、ログ記録が最終的に出力されるレイアウトを指定します
     。

ログイベント情報は *note LogRecord: fb3. インスタンスの形で、 logger,
handler, filter, formatter の間でやりとりされます。

ロギングは、 *note Logger: b1d. クラスのインスタンス (以下 'ロガー') に
メソッドを呼び出すことで実行されます。各インスタンスには名前があり、名前
空間階層構造に、ドット (ピリオド) をセパレータとして、概念的に並べられて
います。例えば、 'scan' という名前のロガーは、ロガー 'scan.text',
'scan.html' および 'scan.pdf'の親です。ロガー名は、何でも望むものにでき
、ロギングされたメッセージが発生した場所を指し示します。

ロガーに名前をつけるときの良い習慣は、ロギングを使う各モジュールに、以下
のように名付けられた、モジュールレベルロガーを使うことです:

     logger = logging.getLogger(__name__)

これにより、ロガー名はパッケージ/モジュール階層をなぞり、ロガー名だけで
、どこでイベントのログが取られたか、直感的に明らかになります。

ロガーの階層構造の根源は、ルートロガーと呼ばれます。それが、関数 *note
debug(): 2c2f, *note info(): 2c59, *note warning(): 2d6, *note error():
2c6d. および *note critical(): 2c6e. によって使われるロガーとなります。
これらの関数は単に、ルートロガーの同名のメソッドを呼び出します。これらの
関数とメソッドは、同じ署名をもっています。ルートロガーの名前は、ログ出力
では 'root' と表示されます。

もちろん、メッセージを異なる送信先に記録することも出来ます。このパッケー
ジでは、ファイルへ、 HTTP GET/POST 先へ、 SMTP 経由で電子メールへ、汎用
のソケットへ、キューへ、または Windows NT イベントログのような OS 毎のロ
グ記録機構への、ログメッセージの書きこみがサポートされています。送信先は
、 'handler' クラスによって取り扱われます。組み込みのハンドラクラスでは
満たせないような、特殊な要件があるなら、独自のログ送信先を生成できます。

デフォルトでは、どのロギングメッセージに対しても、送信先は設定されていま
せん。チュートリアルの例のように、 *note basicConfig(): 9ce. を使って、
送信先 (コンソールやファイルなど) を指定できます。関数 *note debug():
2c2f, *note info(): 2c59, *note warning(): 2d6, *note error(): 2c6d. お
よび *note critical(): 2c6e. を呼び出すと、それらは送信先が設定されてい
ないかを調べます。そして設定されていなければ、ルートロガーに委譲して実際
にメッセージを出力する前に、コンソール (‘sys.stderr’) を送信先に、デフォ
ルトのフォーマットを表示されるメッセージに設定します。

*note basicConfig(): 9ce. が設定するデフォルトのメッセージのフォーマット
は次のようになります:

     severity:logger name:message

*note basicConfig(): 9ce. の 'format' キーワード引数にフォーマット文字列
を渡すことで、これを変更できます。フォーマット文字列を構成するためのすべ
てのオプションは、 *note フォーマッタオブジェクト: 2c4b. を参照してくだ
さい。

* Menu:

* Logging Flow::
* ロガー::
* ハンドラ::
* フォーマッタ::
* ロギングの環境設定::
* 環境設定が与えられないとどうなるか::
* ライブラリのためのロギングの設定::


File: python.info,  Node: Logging Flow,  Next: ロガー,  Up: 上級ロギングチュートリアル

9.7.2.1 Logging Flow
....................

次の図はログイベントが logger と handler をどう流れるかを示しています。

[image src="python-figures/logging_flow.png"]



File: python.info,  Node: ロガー,  Next: ハンドラ,  Prev: Logging Flow,  Up: 上級ロギングチュートリアル

9.7.2.2 ロガー
..............

*note Logger: b1d. オブジェクトの仕事は大きく三つに分かれます。一つ目は
、アプリケーションが実行中にメッセージを記録できるように、いくつかのメソ
ッドをアプリケーションから呼べるようにしています。二つ目に、ロガーオブジ
ェクトはどのメッセージに対して作用するかを、深刻度 (デフォルトのフィルタ
機構) またはフィルタオブジェクトに基づいて決定します。三つ目に、ロガーオ
ブジェクトは関心を持っているすべてのログハンドラに関連するログメッセージ
を回送します。

とりわけ広く使われるロガーオブジェクトのメソッドは、二つのカテゴリーに分
類できます: 設定とメッセージ送信です。

これらが設定メソッドの中でよく使われます:

   * *note Logger.setLevel(): 1436. はロガーが扱うログメッセージの最も低
     い深刻度を指定します。組み込みの深刻度の中では DEBUG が一番低く、
     CRITICAL が一番高くなります。たとえば、深刻度が INFO と設定されたロ
     ガーは INFO, WARNING, ERROR, CRITICAL のメッセージしか扱わず、
     DEBUG メッセージは無視します。

   * *note Logger.addHandler(): 2c29. と *note Logger.removeHandler():
     2c2a. は、ハンドラオブジェクトをロガーオブジェクトから追加または削
     除します。ハンドラについては、 *note ハンドラ: 4db2. で詳しく述べま
     す。

   * *note Logger.addFilter(): 2c31. と *note Logger.removeFilter():
     2c32. はロガーオブジェクトにフィルタオブジェクトを追加または削除し
     ます。フィルタについては、 *note フィルタオブジェクト: 2c56. で詳し
     く述べます。

これらのメソッドを、生成したすべてのロガーに毎回呼び出さなければならない
わけではありません。この節の最後の 2 段落を参照してください。

ロガーオブジェクトが設定されれば、以下のメソッドがログメッセージを生成し
ます:

   * *note Logger.debug(): df7, *note Logger.info(): 1c5c, *note
     Logger.warning(): 1669, *note Logger.error(): 2c30, *note
     Logger.critical(): df6. はすべて、メッセージとメソッド名に対応した
     レベルでログ記録を作り出します。メッセージは実際にはフォーマット文
     字列であり、通常の文字列代入に使う ‘%s’, ‘%d’, ‘%f’ などを含むこと
     ができます。残りの引数はメッセージの代入される位置に対応するオブジ
     ェクトのリストです。 ‘**kwargs’ については、ログ記録メソッドが気に
     するキーワードは ‘exc_info’ だけで、例外の情報をログに記録するかを
     決定するのに使います。

   * *note Logger.exception(): df5. は *note Logger.error(): 2c30. と似
     たログメッセージを作成します。違いは *note Logger.exception(): df5.
     がスタックトレースを一緒にダンプすることです。このメソッドは例外ハ
     ンドラからだけ呼び出すようにしてください。

   * *note Logger.log(): df4. はログレベルを明示的な引数として受け取りま
     す。これは上に挙げた便宜的なログレベル毎のメソッドを使うより少しコ
     ード量が多くなりますが、独自のログレベルを使うことができます。

*note getLogger(): 92e. は、指定されればその特定の名前の、そうでなければ
‘root’ のロガーインスタンスへの参照を返します。ロガーの名前はピリオド区
切りの階層構造を表します。同じ名前で *note getLogger(): 92e. を複数回呼
び出した場合、同一のロガーオブジェクトへの参照が返されます。階層リストを
下ったロガーはリスト上位のロガーの子です。たとえば、名前が ‘foo’ である
ロガーがあったとして、 ‘foo.bar’, ‘foo.bar.baz’, ‘foo.bam’ といった名前
のロガーはすべて ‘foo’ の子孫になります。

ロガーには、'有効レベル (effective level)' の概念があります。ロガーにレ
ベルが明示的に設定されていなければ、代わりに親のレベルがその有効レベルと
して使われます。親のレベルが設定されなければ、'その' 親のレベルが確かめ
られ、明示的に設定されたレベルが見つかるまで祖先が探されます。ルートロガ
ーは、必ず明示的なレベルが設定されています (デフォルトでは ‘WARNING’ で
す)。イベントを処理するかを決定するとき、ロガーの有効レベルを使って、イ
ベントがロガーのハンドラに渡されるかが決められます。

子ロガーはメッセージを親ロガーのハンドラに伝えます。このため、アプリケー
ションが使っているすべてのロガーのためのハンドラを定義して設定する必要は
ありません。トップレベルのロガーのためのハンドラだけ設定しておいて必要に
応じて子ロガーを作成すれば十分です。(しかし、ロガーの 'propagate' 属性を
‘False’ に設定することで、伝播を抑制できます。)


File: python.info,  Node: ハンドラ,  Next: フォーマッタ,  Prev: ロガー,  Up: 上級ロギングチュートリアル

9.7.2.3 ハンドラ
................

*note Handler: 1439. オブジェクトは適切なログメッセージを (ログメッセー
ジの深刻度に基づいて) ハンドラの指定された出力先に振り分けることに責任を
持ちます。 *note Logger: b1d. オブジェクトには *note addHandler(): 2c29.
メソッドで 0 個以上のハンドラを追加することができます。例として、あるア
プリケーションがすべてのログメッセージをログファイルに、 error 以上のす
べてのログメッセージを標準出力に、 critical のメッセージはすべてメールア
ドレスに、それぞれ送りたいとします。この場合、 3 つの個別のハンドラがそ
れぞれの深刻度と宛先に応じて必要になります。

このライブラリには多くのハンドラが用意されています (*note
便利なハンドラ: 4db4. を参照してください) が、このチュートリアルでは
*note StreamHandler: 11c9. と *note FileHandler: 1809. だけを例に取り上
げます。

アプリケーション開発者にとってハンドラを扱う上で気にするべきメソッドは極
々限られています。組み込みのハンドラオブジェクトを使う (つまり自作ハンド
ラを作らない) 開発者に関係あるハンドラのメソッドは、次の設定用のメソッド
だけでしょう:

   * *note setLevel(): 2c3f. メソッドは、ロガーオブジェクトの場合と同様
     に、適切な出力先に振り分けられるべき最も低い深刻度を指定します。な
     ぜ 2 つも *note setLevel(): 2c3f. メソッドがあるのでしょうか?  ロガ
     ーで設定されるレベルは、付随するハンドラにどんな深刻度のメッセージ
     を渡すか決めます。それぞれのハンドラで設定されるレベルは、そのハン
     ドラがどのメッセージを転送するべきか決めます。

   * *note setFormatter(): 2c40. でこのハンドラが使用する Formatter オブ
     ジェクトを選択します。

   * *note addFilter(): 2c41. および *note removeFilter(): 2c42. はそれ
     ぞれハンドラへのフィルタオブジェクトの設定と解除を行います。

アプリケーションのコード中では *note Handler: 1439. のインスタンスを直接
インスタンス化して使ってはなりません。代わりに、 *note Handler: 1439. ク
ラスはすべてのハンドラが持つべきインターフェイスを定義する基底クラスであ
り、子クラスが使える (もしくはオーバライドできる) いくつかのデフォルトの
振る舞いを規定します。


File: python.info,  Node: フォーマッタ,  Next: ロギングの環境設定,  Prev: ハンドラ,  Up: 上級ロギングチュートリアル

9.7.2.4 フォーマッタ
....................

フォーマッタオブジェクトは最終的なログメッセージの順序、構造および内容を
設定します。基底クラスである *note logging.Handler: 1439. とは違って、ア
プリケーションのコードはフォーマッタクラスをインスタンス化しても構いませ
ん。特別な振る舞いをさせたいアプリケーションではフォーマッタのサブクラス
を使う可能性もあります。コンストラクタは三つのオプション引数を取ります -
メッセージのフォーマット文字列、日付のフォーマット文字列、スタイル標識で
す。

 -- メソッド: logging.Formatter.__init__ (fmt=None, datefmt=None,
          style='%')

フォーマット文字列に何も渡さない場合は、デフォルトで行メッセージが利用さ
れます。また、日付フォーマットに何も渡さない場合は、デフォルトで以下のフ
ォーマットが利用されます:

     %Y-%m-%d %H:%M:%S

時刻の末尾にはミリ秒が付きます。 ‘style’ は ‘'%'’, ‘'{'’, または
‘'{TX-PL-LABEL}#x27;’ のいずれかです。特に指定がなければ ‘'%'’ が使われ
ます。

‘style’ が ‘'%'’ の場合、メッセージフォーマット文字列では ‘%(<dictionary
key>)s’ 形式の置換文字列が使われます; キーに指定できる属性名は *note
LogRecord 属性: 2c2e. に文書化されています。 style が ‘'{'’ の場合、メッ
セージフォーマット文字列は (キーワード引数を使う) *note str.format():
5ed. と互換となります。 style が ‘'$'’ の場合、メッセージフォーマット文
字列は *note string.Template.substitute(): 1c54. で期待されているものと
一致します。

バージョン 3.2 で変更: ‘style’ パラメータが追加されました。

次のメッセージフォーマット文字列は、人が読みやすい形式の時刻、メッセージ
の深刻度、およびメッセージの内容を、順番に出力します:

     '%(asctime)s - %(levelname)s - %(message)s'

フォーマッタは、ユーザが設定できる関数を使って、生成時刻をタプルに記録し
ます。デフォルトでは、 *note time.localtime(): 14a2. が使われます。特定
のフォーマッタインスタンスに対してこれを変更するには、インスタンスの
‘converter’ 属性を *note time.localtime(): 14a2. や *note time.gmtime():
1190. と同じ署名をもつ関数に設定してください。すべてのフォーマッタインス
タンスに対してこれを変更するには、例えば全てのロギング時刻を GMT で表示
するには、フォーマッタクラスの ‘converter’ 属性を (GMT 表示の
‘time.gmtime’ に) 設定してください。


File: python.info,  Node: ロギングの環境設定,  Next: 環境設定が与えられないとどうなるか,  Prev: フォーマッタ,  Up: 上級ロギングチュートリアル

9.7.2.5 ロギングの環境設定
..........................

プログラマは、ロギングを 3 種類の方法で設定できます:

  1. 上述の設定メソッドを呼び出す Python コードを明示的に使って、ロガー
     、ハンドラ、そしてフォーマッタを生成する。

  2. ロギング設定ファイルを作り、それを *note fileConfig(): b1f. 関数を
     使って読み込む。

  3. 設定情報の辞書を作り、それを *note dictConfig(): 1180. 関数に渡す。

最後の2つの選択肢については、 *note 環境設定のための関数: 12bf. で解説し
ています。以下の例では、Python コードを使って、とても簡単なロガー、コン
ソールハンドラ、そして簡単なフォーマッタを設定しています:

     import logging

     # create logger
     logger = logging.getLogger('simple_example')
     logger.setLevel(logging.DEBUG)

     # create console handler and set level to debug
     ch = logging.StreamHandler()
     ch.setLevel(logging.DEBUG)

     # create formatter
     formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

     # add formatter to ch
     ch.setFormatter(formatter)

     # add ch to logger
     logger.addHandler(ch)

     # 'application' code
     logger.debug('debug message')
     logger.info('info message')
     logger.warning('warn message')
     logger.error('error message')
     logger.critical('critical message')

このモジュールを実行すると、コマンドラインによって以下の出力がなされます
:

     $ python simple_logging_module.py
     2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message
     2005-03-19 15:10:26,620 - simple_example - INFO - info message
     2005-03-19 15:10:26,695 - simple_example - WARNING - warn message
     2005-03-19 15:10:26,697 - simple_example - ERROR - error message
     2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message

以下の Python モジュールは、ロガー、ハンドラ、フォーマッタをほとんど上述
の例と同じように生成していますが、オブジェクト名だけが異なります:

     import logging
     import logging.config

     logging.config.fileConfig('logging.conf')

     # create logger
     logger = logging.getLogger('simpleExample')

     # 'application' code
     logger.debug('debug message')
     logger.info('info message')
     logger.warning('warn message')
     logger.error('error message')
     logger.critical('critical message')

これが logging.conf ファイルです:

     [loggers]
     keys=root,simpleExample

     [handlers]
     keys=consoleHandler

     [formatters]
     keys=simpleFormatter

     [logger_root]
     level=DEBUG
     handlers=consoleHandler

     [logger_simpleExample]
     level=DEBUG
     handlers=consoleHandler
     qualname=simpleExample
     propagate=0

     [handler_consoleHandler]
     class=StreamHandler
     level=DEBUG
     formatter=simpleFormatter
     args=(sys.stdout,)

     [formatter_simpleFormatter]
     format=%(asctime)s - %(name)s - %(levelname)s - %(message)s

出力は、設定ファイルに基づく例とだいたい同じです:

     $ python simple_logging_config.py
     2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message
     2005-03-19 15:38:55,979 - simpleExample - INFO - info message
     2005-03-19 15:38:56,054 - simpleExample - WARNING - warn message
     2005-03-19 15:38:56,055 - simpleExample - ERROR - error message
     2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message

この通り、設定ファイルの方法は、主に設定とコードが分かれ、非コーダがロギ
ングプロパティを変えやすくなるという点で、Python コードの方法より少し優
れています。

     警告: *note fileConfig(): b1f. 関数はデフォルト引数
     ‘disable_existing_loggers’ を取り、後方互換性のためにデフォルト値は
     ‘True’ になっています。 これはあなたの望むものかもしれませんし、そ
     うでないかもしれません。というのは、設定で明示的に指定したクラス (も
     しくはその親クラス) を除いて、 *note fileConfig(): b1f. が呼び出さ
     れる前に存在した非ルートロガーを無効化してしまうからです。 より詳細
     なことはリファレンスを参照し、望むならこの引数に ‘False’ を指定して
     ください。

     *note dictConfig(): 1180. に渡される辞書でも、キー
     ‘disable_existing_loggers’ で真偽値を指定することができ、辞書の中で
     明示的に指定しなかった場合はデフォルトで ‘True’ と解釈されます。こ
     れは上で説明したロガー無効化につながりますが、それを望まないことも
     あるでしょう - その場合は、明示的にキーを与えて値を ‘False’ にして
     ください。

なお、設定ファイルで参照されるクラス名は、logging モジュールに対して相対
であるか、通常のインポート機構を使って解決される絶対である値でなければな
りません。従って、(logging モジュールに相対な) *note WatchedFileHandler:
2cab. または (Python インポートパスとして ‘mypackage’ が使えるとき、パッ
ケージ ‘mypackage’ のモジュール ‘mymodule’ で定義されたクラスに)
‘mypackage.mymodule.MyHandler’ のどちらかが使えます。

Python 3.2 では、ロギングを設定するのに新しく、辞書に設定情報を持たせる
手段が導入されました。これは、上で概説した設定ファイルに基づく方法による
機能の上位版を提供し、新しいアプリケーションやデプロイにはこのメソッドが
推奨されます。Python の辞書を使って設定情報を保持し、辞書は他の用途にも
使えるので、設定の選択肢が広がります。例えば、JSON フォーマットの設定フ
ァイルや、YAML 処理機能が使えれば YAML フォーマットのファイルを使って、
設定辞書を構成できます。また、もちろん、Python コードで辞書を構成し、ソ
ケットを通して pickle 化された形式を受け取るなど、アプリケーションで意味
があるいかなるやり方でも使えます。

以下は、上記と同じ設定を辞書ベースの新しい手法で記載した YAML 形式の例で
す:

     version: 1
     formatters:
       simple:
         format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
     handlers:
       console:
         class: logging.StreamHandler
         level: DEBUG
         formatter: simple
         stream: ext://sys.stdout
     loggers:
       simpleExample:
         level: DEBUG
         handlers: [console]
         propagate: no
     root:
       level: DEBUG
       handlers: [console]

辞書を使ったロギングについて詳細は、 *note 環境設定のための関数: 12bf. を
参照してください。


File: python.info,  Node: 環境設定が与えられないとどうなるか,  Next: ライブラリのためのロギングの設定,  Prev: ロギングの環境設定,  Up: 上級ロギングチュートリアル

9.7.2.6 環境設定が与えられないとどうなるか
..........................................

ロギング環境設定を与えられないと、ロギングイベントを出力しなければならな
いのに、イベントを出力するハンドラが見つからないことがあります。

イベントは、 *note lastResort: 11cb. に格納された「最終手段ハンドラ」を
使用して出力されます。この内部的なハンドラはどんなロガーにも関係しておら
ず、イベント記述メッセージを現在の ‘sys.stderr’ に書く *note
StreamHandler: 11c9. のように動作します (したがって、あらゆるリダイレク
トの効果が反映されます)。メッセージに対してフォーマットは行われません。
イベント記述メッセージだけがそのまま表示されます。ハンドラのレベルは
‘WARNING’ にセットされ、重大度がこれ以上のすべてのイベントが出力されます
。

バージョン 3.2 で変更: Python 3.2 より前のバージョンでは、振る舞いは以下
の通りです:

   * *note raiseExceptions: 11ca. が ‘False’ (製品モード) なら、イベント
     は黙って捨てられます。

   * *note raiseExceptions: 11ca. が ‘True’ (開発モード) なら、メッセー
     ジ 'No handlers could be found for logger X.Y.Z' が一度表示されます
     。

3.2 より前の動作にするために、*note lastResort: 11cb. を ‘None’ に設定す
ることもできます。


File: python.info,  Node: ライブラリのためのロギングの設定,  Prev: 環境設定が与えられないとどうなるか,  Up: 上級ロギングチュートリアル

9.7.2.7 ライブラリのためのロギングの設定
........................................

ロギングを使うライブラリを開発するときは、ライブラリがどのようにロギング
を使うのか、例えば使われているロガーの名前などを、ドキュメントにしておく
べきです。ロギングの設定については、いくつか考えておくべきこともあります
。使っているアプリケーションがロギングを使っていなくて、ライブラリコード
がロギングを呼び出すと、(前の節で解説したように) 重大度 ‘WARNING’ 以上の
イベントが、‘sys.stderr’ に表示されます。これが最高のデフォルトの振る舞
いと見なされます。

何らかの理由でロギング設定がなされていないときにメッセージを表示 'させた
くない' のであれば、ライブラリのトップレベルのロガーに何もしないハンドラ
を取り付けられます。ライブラリの全てのイベントに対してそのハンドラが見つ
かるので、メッセージが表示されなくなります。ライブラリのユーザーがアプリ
ケーションのためにロギングを設定する場合、おそらくハンドラが追加され、そ
してレベルが適切に設定された場合に、ライブラリコード内でのロギングの呼び
出しは通常通りそのハンドラに出力を送るようになります。

何もしないハンドラ *note NullHandler: 1255. (Python 3.1 以降) は、
logging パッケージに含まれます。このハンドラのインスタンスを、 (ロギング
設定がなされていないときにライブラリのログイベントを ‘sys.stderr’ に出力
させたく 'ないなら') ライブラリの名前空間で使われるトップレベルロガーに
取り付けられます。ライブラリ 'foo' によるすべてのロギングが、 'foo.x',
'foo.x.y' その他に該当する名前のロガーによってなされるなら:

     import logging
     logging.getLogger('foo').addHandler(logging.NullHandler())

とすれば望んだ効果が得られるでしょう。組織が複数のライブラリを作り出すな
ら、指定されるロガー名は単に 'foo' ではなく、'orgname.foo' になります。

     注釈: あなたのライブラリから 'ルートロガーへ直接ログを記録しない' こ
     とを強く推奨します。代わりに、あなたのライブラリのトップレベルまた
     はモジュールレベルの ‘__name__’ を使うなど、固有で、簡単に識別でき
     る名前を持ったロガーを使ってください。ルートロガーに直接ログを記録
     することにより、あなたのライブラリを利用するアプリケーション開発者
     が、ロギングの詳細度 (verbosity) やハンドラを望みのとおりに設定する
     ことを困難にしたり、不可能にしてしまいます。

     注釈: 'ライブラリのロガーには、' *note NullHandler: 1255. '以外のハ
     ンドラを追加しない' ことを強く推奨します。これは、ハンドラの設定が
     、あなたのライブラリを使うアプリケーション開発者にも伝播するからで
     す。アプリケーション開発者は、対象となる聴衆と、そのアプリケーショ
     ンにどのハンドラが最も適しているかを知っています。ハンドラを 'ボン
     ネットの中で' 加えてしまうと、ユニットテストをして必要に応じたログ
     を送達する能力に干渉しかねません。


File: python.info,  Node: ロギングレベル<2>,  Next: 便利なハンドラ,  Prev: 上級ロギングチュートリアル,  Up: Logging HOWTO

9.7.3 ロギングレベル
--------------------

ログレベルの数値は以下の表のように与えられています。これらは基本的に自分
でレベルを定義したい人のためのもので、定義するレベルを既存のレベルの間に
位置づけるためには具体的な値が必要になります。もし数値が他のレベルと同じ
だったら、既存の値は上書きされその名前は失われます。

レベル             数値
                   
---------------------------------------
                   
‘CRITICAL’         50
                   
                   
‘ERROR’            40
                   
                   
‘WARNING’          30
                   
                   
‘INFO’             20
                   
                   
‘DEBUG’            10
                   
                   
‘NOTSET’           0
                   

レベルはロガーに関連付けることもでき、開発者が設定することも、保存された
ログ記録設定を読み込む際に設定することもできます。ロガーに対してログ記録
メソッドが呼び出されると、ロガーは自らのレベルとメソッド呼び出しに関連付
けられたレベルを比較します。ロガーのレベルがメソッド呼び出しのレベルより
も高い場合、実際のログメッセージは生成されません。これはログ出力の冗長性
を制御するための基本的なメカニズムです。

ログ記録されるメッセージは *note LogRecord: fb3. クラスのインスタンスと
してエンコードされます。ロガーがあるイベントを実際にログ出力すると決定し
た場合、ログメッセージから *note LogRecord: fb3. インスタンスが生成され
ます。

ログ記録されるメッセージは、ハンドラ ('handlers') を通してディスパッチ機
構にかけられます。ハンドラは *note Handler: 1439. クラスのサブクラスのイ
ンスタンスで、ログ記録された (*note LogRecord: fb3. 形式の) メッセージが
、そのメッセージの伝達対象となる相手 (エンドユーザ、サポートデスクのスタ
ッフ、システム管理者、開発者) に行き着くようにする役割を持ちます。ハンド
ラには特定の出力先を意図された *note LogRecord: fb3. インスタンスが渡さ
れます。各ロガーは 0 個以上のハンドラを (*note Logger: b1d. の *note
addHandler(): 2c29. メソッド) で関連付けることができます。ロガーに直接関
連付けられたハンドラに加えて、'ロガーの上位にあるロガーすべてに関連付け
られたハンドラ' がメッセージを処理する際に呼び出されます (ただしロガーの
'propagate' フラグが false 値にセットされている場合を除きます。その場合
は、祖先ハンドラへの伝搬はそこで止まります)。

ロガーと同様に、ハンドラは関連付けられたレベルを持つことができます。ハン
ドラのレベルはロガーのレベルと同じ方法で、フィルタとして働きます。ハンド
ラがあるイベントを実際に処理すると決定した場合、 *note emit(): 2c49. メ
ソッドが使われ、メッセージを出力先に送信します。ほとんどのユーザ定義の
*note Handler: 1439. のサブクラスで、この *note emit(): 2c49. をオーバラ
イドする必要があるでしょう。

* Menu:

* カスタムレベル::


File: python.info,  Node: カスタムレベル,  Up: ロギングレベル<2>

9.7.3.1 カスタムレベル
......................

独自のレベルを定義することは可能ですが、必須ではなく、実経験上は既存のレ
ベルが選ばれます。しかし、カスタムレベルが必要だと確信するなら、レベルの
定義には多大な注意を払うべきで、'ライブラリの開発の際、カスタムレベルを
定義することはとても悪いアイデア' になり得ます。これは、複数のライブラリ
の作者がみな独自のカスタムレベルを定義すると、与えられた数値が異なるライ
ブラリで異なる意味になりえるため、開発者がこれを制御または解釈するのが難
しくなるからです。


File: python.info,  Node: 便利なハンドラ,  Next: ログ記録中に発生する例外,  Prev: ロギングレベル<2>,  Up: Logging HOWTO

9.7.4 便利なハンドラ
--------------------

基底の *note Handler: 1439. クラスに加え、多くの便利なサブクラスが提供さ
れています:

  1. *note StreamHandler: 11c9. インスタンスは、メッセージをストリーム
     (ファイル風オブジェクト) に送ります。

  2. *note FileHandler: 1809. インスタンスは、メッセージをディスクファイ
     ルに送ります。

  3. *note BaseRotatingHandler: 2caf. は、ある地点でログファイルを循環さ
     せるハンドラの基底クラスです。これを直接インスタンス化することは意
     図されていません。代わりに、 *note RotatingFileHandler: 153b. や
     *note TimedRotatingFileHandler: f2e. を使用してください。

  4. *note RotatingFileHandler: 153b. インスタンスは、メッセージをディス
     クファイルに送り、最大ログファイル数とログファイル循環をサポートし
     ます。

  5. *note TimedRotatingFileHandler: f2e. インスタンスは、メッセージをデ
     ィスクファイルに送り、ログファイルを特定時間のインターバルで循環し
     ます。

  6. *note SocketHandler: f2f. インスタンスは、 TCP/IP ソケットにメッセ
     ージを送ります。バージョン3.4　から、 Unixドメインソケットもサポー
     トされます。

  7. *note DatagramHandler: f30. インスタンスは UDP ソケットにメッセージ
     を送ります。バージョン 3.4 から、Unix ドメインソケットもサポートさ
     れます。

  8. *note SMTPHandler: 2cdb. インスタンスは、メッセージを指示された
     email アドレスに送ります。

  9. *note SysLogHandler: 628. インスタンスは、メッセージを、必要ならば
     リモートマシンの、Unix syslog daemon に送ります。

  10. *note NTEventLogHandler: 2cd3. インスタンスは、メッセージを
     Windows NT/2000/XP イベントログに送ります。

  11. *note MemoryHandler: 2c8f. インスタンスは、メッセージを、特定の基
     準が満たされる度に流される、メモリ中のバッファに送ります。

  12. *note HTTPHandler: df8. インスタンスは、メッセージを、 ‘GET’ また
     は ‘POST’ セマンティクスを使って、HTTP サーバに送ります。

  13. *note WatchedFileHandler: 2cab. インスタンスは、ロギングする先のフ
     ァイルを監視します。ファイルが変更されると、そのファイルは閉じられ
     、ファイル名を使って再び開かれます。このハンドラは Unix 系のシステ
     ムにのみ便利です。Windows は、使われている基の機構をサポートしてい
     ません。

  14. *note QueueHandler: 1742. インスタンスは、 *note queue: a4. モジュ
     ールや *note multiprocessing: 86. モジュールなどで実装されているキ
     ューにメッセージを送ります。

  15. *note NullHandler: 1255. インスタンスは、エラーメッセージについて
     何もしません。このクラスはライブラリ開発者が、 logging は使いたいが
     、ライブラリのユーザーが logging の設定をしなかったときに表示されう
     る 'No handlers could be found for logger 'XXX" のようなメッセージ
     を回避したいときに使います。詳しくは、 *note
     ライブラリのためのロギングの設定: 2ca8. を参照してください。

Added in version 3.1: *note NullHandler: 1255. クラス。

Added in version 3.2: *note QueueHandler: 1742. クラス。

コア logging パッケージで、 *note NullHandler: 1255, *note
StreamHandler: 11c9. および *note FileHandler: 1809. クラスが定義されて
います。その他のハンドラは、サブモジュールの *note logging.handlers: 7d.
で定義されています。(環境設定機能のためのサブモジュール、 *note
logging.config: 7c. もあります。)

ログメッセージは、 *note Formatter: 143a. クラスのインスタンスを通してフ
ォーマット化してから表示されます。このインスタンスは、 % 演算子と辞書で
使うのに適切なフォーマット文字列で初期化されます。

複数のメッセージを一括してフォーマット化するには、 *note
BufferingFormatter: 2c52. が使えます。(一連の文字列のそれぞれに適用され
る) フォーマット文字列に加え、ヘッダとトレーラフォーマット文字列も提供さ
れています。

ロガーレベルおよび/またはハンドラレベルに基づくフィルタリングで十分でな
ければ、 *note Filter: 11cc. のインスタンスを *note Logger: b1d. と
*note Handler: 1439. インスタンスの両方に (*note addFilter(): 2c41. を通
して) 加えることができます。メッセージの処理を続ける前に、ロガーもハンド
ラも、全てのフィルタに許可を求めます。フィルタのいずれかが偽値を返したら
、メッセージの処理は続けられません。

基本の *note Filter: 11cc. 機能では、特定のロガー名でのフィルタリングを
できます。この機能が使われると、指名されたロガーに送られたメッセージとそ
の子だけがフィルタを通り、その他は落とされます。


File: python.info,  Node: ログ記録中に発生する例外,  Next: 任意のオブジェクトをメッセージに使用する,  Prev: 便利なハンドラ,  Up: Logging HOWTO

9.7.5 ログ記録中に発生する例外
------------------------------

logging パッケージは、ログを生成している間に起こる例外を飲み込むように設
計されています。これは、ログ記録イベントを扱っている間に発生するエラー
(ログ記録の設定ミス、ネットワークまたは他の同様のエラー) によってログ記
録を使用するアプリケーションが早期に終了しないようにするためです。

*note SystemExit: d0e. と *note KeyboardInterrupt: 99f. 例外は決して飲み
込まれません。 *note Handler: 1439. サブクラスの *note emit(): 2c49. メ
ソッドの間に起こる他の例外は、 *note handleError(): 2c48. メソッドに渡さ
れます。

*note Handler: 1439. の *note handleError(): 2c48. のデフォルト実装は、
モジュールレベル変数 *note raiseExceptions: 11ca. が設定されているかどう
かチェックします。設定されているなら、トレースバックが *note sys.stderr:
907. に出力されます。設定されていないなら、例外は飲み込まれます。

     注釈: *note raiseExceptions: 11ca. のデフォルト値は ‘True’ です。こ
     れは、開発の間に起こるどんな例外についても通常は通知してほしいから
     です。実運用環境では *note raiseExceptions: 11ca. を ‘False’ に設定
     することをお勧めします。


File: python.info,  Node: 任意のオブジェクトをメッセージに使用する,  Next: 最適化<16>,  Prev: ログ記録中に発生する例外,  Up: Logging HOWTO

9.7.6 任意のオブジェクトをメッセージに使用する
----------------------------------------------

前の節とそこで挙げた例では、イベントを記録するときに渡されたメッセージが
文字列であると仮定していました。しかし、これは唯一の可能性ではありません
。メッセージとして任意のオブジェクトを渡すことができます。そして、ロギン
グシステムがそのオブジェクトを文字列表現に変換する必要があるとき、オブジ
ェクトの *note __str__(): 5e9. メソッドが呼び出されます。実際、そうした
ければ、文字列表現を計算することを完全に避けることができます - 例えば、
*note SocketHandler: f2f. は、イベントを pickle してネットワーク上で送信
することでログ出力します。


File: python.info,  Node: 最適化<16>,  Next: その他のリソース,  Prev: 任意のオブジェクトをメッセージに使用する,  Up: Logging HOWTO

9.7.7 最適化
------------

message 引数の整形は、必要になるまで延期されます。しかしながら、ログ記録
メソッドに渡す引数を計算するだけでもコストがかかる場合があります。ロガー
が単にイベントを捨てるなら、その計算を避けたいと考えるかもしれません。ど
うするかを決定するために *note isEnabledFor(): 12c4. メソッドを呼ぶこと
ができます。このメソッドは引数にレベルを取って、そのレベルの呼び出しに対
して Logger がイベントを生成するなら true を返します。このようにコードを
書くことができます:

     if logger.isEnabledFor(logging.DEBUG):
         logger.debug('Message with %s, %s', expensive_func1(),
                                             expensive_func2())

このようにすると、ロガーの閾値が ‘DEBUG’ より上に設定されている場合、
‘expensive_func1’ と ‘expensive_func2’ の呼び出しは行われません。

     注釈: ある種のケースでは、 *note isEnabledFor(): 12c4. それ自身があ
     なたが期待するよりも高価になる場合があります(たとえば明示的なレベル
     指定がロガー階層の上位のみに設定されていて、ロガーが深くネストされ
     ているような場合です)。そのようなケース(あるいはタイトなループ内で
     メソッド呼び出しを避けたい場合)は、 *note isEnabledFor(): 12c4. 結
     果をローカルにもしくはインスタンス変数としてキャッシュし、メソッド
     を毎回呼び出すかわりに使えば良いです。そのようなキャッシュ値は、(ま
     ったく一般的ではありませんが)ロギング設定がアプリケーション実行中に
     動的に変更された場合にのみ再計算が必要でしょう。

これ以外にも、どんなログ情報が集められるかについてより正確なコントロール
を必要とする、特定のアプリケーションでできる最適化があります。これは、ロ
グ記録の間の不要な処理を避けるためにできることのリストです:

不要な情報                                                それを避ける方法
                                                          
------------------------------------------------------------------------------------------------------------------
                                                          
呼び出しがどこから行われたかに関する情報。                ‘logging._srcfile’ を ‘None’ にする。このことにより
                                                          *note sys._getframe(): 6ac. 呼び出しを避けることが出
                                                          来、PyPy のような環境(*note sys._getframe(): 6ac. の
                                                          高速化が出来ない)において高速化の役に立ちます。
                                                          
                                                          
スレッド情報。                                            ‘logging.logThreads’ を ‘False’ にする。
                                                          
                                                          
現在のプロセスID(*note os.getpid(): 2a5e.)                ‘logging.logProcesses’ を ‘False’ にする。
                                                          
                                                          
マルチプロセスの制御に ‘multiprocessing’ を使っていると   ‘logging.logMultiprocessing’ を ‘False’ にする。
きの、現在のプロセス名                                    

‘asyncio’ を使っているときの、現在の                      ‘logging.logAsyncioTasks’ を ‘False’ に設定する。
*note asyncio.Task: 4a5. の名前。                         

また、コア logging モジュールが基本的なハンドラだけを含んでいることに注
意してください。 *note logging.handlers: 7d. と *note logging.config:
7c. をインポートしなければ、余分なメモリを消費することはありません。


File: python.info,  Node: その他のリソース,  Prev: 最適化<16>,  Up: Logging HOWTO

9.7.8 その他のリソース
----------------------

参考
....

*note logging: 7b. モジュール

     logging モジュールの API リファレンス。

*note logging.config: 7c. モジュール

     logging モジュールの環境設定 API です。

*note logging.handlers: 7d. モジュール

     logging モジュールに含まれる、便利なハンドラです。

*note ロギングクックブック: 11c8.


File: python.info,  Node: Logging クックブック,  Next: 正規表現 HOWTO,  Prev: Logging HOWTO,  Up: Python HOWTO

9.8 Logging クックブック
========================


著者: Vinay Sajip <vinay_sajip at red-dove dot com>

このページは、過去に有用であるとされていた、logging に関連するいくつもの
レシピを含んでいます。チュートリアルやリファレンス情報へのリンクについて
は *note その他のリソース: 4dc4. を参照してください。

* Menu:

* 複数のモジュールで logging を使う::
* 複数のスレッドからのロギング::
* 複数の handler と formatter::
* 複数の出力先にログを出力する::
* ログレベルのカスタム処理::
* 設定サーバの例::
* ブロックする handler を扱う::
* ネットワーク越しの logging イベントの送受信::
* コンテキスト情報をログ記録出力に付加する::
* contextvars の利用::
* ハンドラ内でのコンテキスト情報の付与::
* 複数のプロセスからの単一ファイルへのログ記録::
* ファイルをローテートする::
* 別の format スタイルを利用する::
* LogRecord のカスタマイズ::
* Subclassing QueueHandler and QueueListener- a ZeroMQ example::
* Subclassing QueueHandler and QueueListener- a pynng example::
* 辞書ベースで構成する例::
* rotator と namer を使ってログローテートをカスタマイズする::
* より手の込んだ multiprocessing の例::
* SysLogHandler に送るメッセージに BOM を挿入する::
* 構造化ログを実装する::
* handler を dictConfig() を使ってカスタマイズする: handler を dictConfig を使ってカスタマイズする.
* 固有の書式化スタイルをアプリケーション全体で使う::
* filter を dictConfig() を使ってカスタマイズする: filter を dictConfig を使ってカスタマイズする.
* 例外の書式化をカスタマイズする::
* ロギングメッセージを喋る::
* ロギングメッセージをバッファリングし、条件に従って出力する::
* バッファリングしながらロギングメッセージを email で送信する::
* 設定によって時刻を UTC(GMT) で書式化する: 設定によって時刻を UTC GMT で書式化する.
* ロギングの選択にコンテキストマネージャを使う::
* CLIアプリケーションスターターテンプレート::
* Qt GUIのログ出力::
* RFC5424 をサポートする syslog へのロギング::
* ロガーを出力ストリームのように取り扱う方法::
* 避けるべきパターン::
* その他のリソース: その他のリソース<2>.


File: python.info,  Node: 複数のモジュールで logging を使う,  Next: 複数のスレッドからのロギング,  Up: Logging クックブック

9.8.1 複数のモジュールで logging を使う
---------------------------------------

‘logging.getLogger('someLogger')’ の複数回の呼び出しは同じ logger への参
照を返します。これは同じ Python インタプリタプロセス上で動いている限り、
一つのモジュールの中からに限らず、モジュールをまたいでも当てはまります。
同じオブジェクトへの参照という点でも正しいです。さらに、一つのモジュール
の中で親 logger を定義して設定し、別のモジュールで子 logger を定義する
(ただし設定はしない) ことが可能で、すべての子 logger への呼び出しは親に
まで渡されます。まずはメインのモジュールです:

     import logging
     import auxiliary_module

     # create logger with 'spam_application'
     logger = logging.getLogger('spam_application')
     logger.setLevel(logging.DEBUG)
     # create file handler which logs even debug messages
     fh = logging.FileHandler('spam.log')
     fh.setLevel(logging.DEBUG)
     # create console handler with a higher log level
     ch = logging.StreamHandler()
     ch.setLevel(logging.ERROR)
     # create formatter and add it to the handlers
     formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
     fh.setFormatter(formatter)
     ch.setFormatter(formatter)
     # add the handlers to the logger
     logger.addHandler(fh)
     logger.addHandler(ch)

     logger.info('creating an instance of auxiliary_module.Auxiliary')
     a = auxiliary_module.Auxiliary()
     logger.info('created an instance of auxiliary_module.Auxiliary')
     logger.info('calling auxiliary_module.Auxiliary.do_something')
     a.do_something()
     logger.info('finished auxiliary_module.Auxiliary.do_something')
     logger.info('calling auxiliary_module.some_function()')
     auxiliary_module.some_function()
     logger.info('done with auxiliary_module.some_function()')

そして補助モジュール (auxiliary module) がこちらです:

     import logging

     # create logger
     module_logger = logging.getLogger('spam_application.auxiliary')

     class Auxiliary:
         def __init__(self):
             self.logger = logging.getLogger('spam_application.auxiliary.Auxiliary')
             self.logger.info('creating an instance of Auxiliary')

         def do_something(self):
             self.logger.info('doing something')
             a = 1 + 1
             self.logger.info('done doing something')

     def some_function():
         module_logger.info('received a call to "some_function"')

出力はこのようになります:

     2005-03-23 23:47:11,663 - spam_application - INFO -
        creating an instance of auxiliary_module.Auxiliary
     2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO -
        creating an instance of Auxiliary
     2005-03-23 23:47:11,665 - spam_application - INFO -
        created an instance of auxiliary_module.Auxiliary
     2005-03-23 23:47:11,668 - spam_application - INFO -
        calling auxiliary_module.Auxiliary.do_something
     2005-03-23 23:47:11,668 - spam_application.auxiliary.Auxiliary - INFO -
        doing something
     2005-03-23 23:47:11,669 - spam_application.auxiliary.Auxiliary - INFO -
        done doing something
     2005-03-23 23:47:11,670 - spam_application - INFO -
        finished auxiliary_module.Auxiliary.do_something
     2005-03-23 23:47:11,671 - spam_application - INFO -
        calling auxiliary_module.some_function()
     2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO -
        received a call to 'some_function'
     2005-03-23 23:47:11,673 - spam_application - INFO -
        done with auxiliary_module.some_function()


File: python.info,  Node: 複数のスレッドからのロギング,  Next: 複数の handler と formatter,  Prev: 複数のモジュールで logging を使う,  Up: Logging クックブック

9.8.2 複数のスレッドからのロギング
----------------------------------

複数スレッドからのロギングでは特別に何かをする必要はありません。 次の例
はmain (初期) スレッドとそれ以外のスレッドからのロギングの例です:

     import logging
     import threading
     import time

     def worker(arg):
         while not arg['stop']:
             logging.debug('Hi from myfunc')
             time.sleep(0.5)

     def main():
         logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s')
         info = {'stop': False}
         thread = threading.Thread(target=worker, args=(info,))
         thread.start()
         while True:
             try:
                 logging.debug('Hello from main')
                 time.sleep(0.75)
             except KeyboardInterrupt:
                 info['stop'] = True
                 break
         thread.join()

     if __name__ == '__main__':
         main()

実行すると、出力は以下のようになるはずです:

        0 Thread-1 Hi from myfunc
        3 MainThread Hello from main
      505 Thread-1 Hi from myfunc
      755 MainThread Hello from main
     1007 Thread-1 Hi from myfunc
     1507 MainThread Hello from main
     1508 Thread-1 Hi from myfunc
     2010 Thread-1 Hi from myfunc
     2258 MainThread Hello from main
     2512 Thread-1 Hi from myfunc
     3009 MainThread Hello from main
     3013 Thread-1 Hi from myfunc
     3515 Thread-1 Hi from myfunc
     3761 MainThread Hello from main
     4017 Thread-1 Hi from myfunc
     4513 MainThread Hello from main
     4518 Thread-1 Hi from myfunc

予想した通りかもしれませんが、ログ出力が散らばっているのが分かります。 も
ちろん、この手法はより多くのスレッドでも上手くいきます。


File: python.info,  Node: 複数の handler と formatter,  Next: 複数の出力先にログを出力する,  Prev: 複数のスレッドからのロギング,  Up: Logging クックブック

9.8.3 複数の handler と formatter
---------------------------------

logger は通常の Python オブジェクトです。 *note addHandler(): 2c29. メソ
ッドは追加されるハンドラの個数について最小値も最大値も定めていません。時
にアプリケーションがすべての深刻度のすべてのメッセージをテキストファイル
に記録しつつ、同時にエラーやそれ以上のものをコンソールに出力することが役
に立ちます。これを実現する方法は、単に適切なハンドラを設定するだけです。
アプリケーションコードの中のログ記録の呼び出しは変更されずに残ります。少
し前に取り上げた単純なモジュール式の例を少し変えるとこうなります:

     import logging

     logger = logging.getLogger('simple_example')
     logger.setLevel(logging.DEBUG)
     # create file handler which logs even debug messages
     fh = logging.FileHandler('spam.log')
     fh.setLevel(logging.DEBUG)
     # create console handler with a higher log level
     ch = logging.StreamHandler()
     ch.setLevel(logging.ERROR)
     # create formatter and add it to the handlers
     formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
     ch.setFormatter(formatter)
     fh.setFormatter(formatter)
     # add the handlers to logger
     logger.addHandler(ch)
     logger.addHandler(fh)

     # 'application' code
     logger.debug('debug message')
     logger.info('info message')
     logger.warning('warn message')
     logger.error('error message')
     logger.critical('critical message')

'application' 部分のコードは複数の handler について何も気にしていないこ
とに注目してください。変更した箇所は新しい 'fh' という名の handler を追
加して設定したところがすべてです。

新しい handler を、異なる深刻度に対する filter と共に生成できることは、
アプリケーションを書いてテストを行うときとても助けになります。デバッグ用
にたくさんの ‘print’ 文を使う代わりに ‘logger.debug’ を使いましょう。あ
とで消したりコメントアウトしたりしなければならない print 文と違って、
logger.debug 命令はソースコードの中にそのまま残しておいて再び必要になる
まで休眠させておけます。その時必要になるのはただ logger および/または
handler の深刻度の設定をいじることだけです。


File: python.info,  Node: 複数の出力先にログを出力する,  Next: ログレベルのカスタム処理,  Prev: 複数の handler と formatter,  Up: Logging クックブック

9.8.4 複数の出力先にログを出力する
----------------------------------

コンソールとファイルに、別々のメッセージ書式で、別々の状況に応じたログ出
力を行わせたいとしましょう。例えば DEBUG よりも高いレベルのメッセージは
ファイルに記録し、INFO 以上のレベルのメッセージはコンソールに出力したい
という場合です。また、ファイルにはタイムスタンプを記録し、コンソールには
出力しないとします。以下のようにすれば、こうした挙動を実現できます:

     import logging

     # set up logging to file - see previous section for more details
     logging.basicConfig(level=logging.DEBUG,
                         format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
                         datefmt='%m-%d %H:%M',
                         filename='/tmp/myapp.log',
                         filemode='w')
     # define a Handler which writes INFO messages or higher to the sys.stderr
     console = logging.StreamHandler()
     console.setLevel(logging.INFO)
     # set a format which is simpler for console use
     formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
     # tell the handler to use this format
     console.setFormatter(formatter)
     # add the handler to the root logger
     logging.getLogger('').addHandler(console)

     # Now, we can log to the root logger, or any other logger. First the root...
     logging.info('Jackdaws love my big sphinx of quartz.')

     # Now, define a couple of other loggers which might represent areas in your
     # application:

     logger1 = logging.getLogger('myapp.area1')
     logger2 = logging.getLogger('myapp.area2')

     logger1.debug('Quick zephyrs blow, vexing daft Jim.')
     logger1.info('How quickly daft jumping zebras vex.')
     logger2.warning('Jail zesty vixen who grabbed pay from quack.')
     logger2.error('The five boxing wizards jump quickly.')

これを実行すると、コンソールには以下のように出力されます:

     root        : INFO     Jackdaws love my big sphinx of quartz.
     myapp.area1 : INFO     How quickly daft jumping zebras vex.
     myapp.area2 : WARNING  Jail zesty vixen who grabbed pay from quack.
     myapp.area2 : ERROR    The five boxing wizards jump quickly.

そして、ファイルには以下のように出力されるはずです:

     10-22 22:19 root         INFO     Jackdaws love my big sphinx of quartz.
     10-22 22:19 myapp.area1  DEBUG    Quick zephyrs blow, vexing daft Jim.
     10-22 22:19 myapp.area1  INFO     How quickly daft jumping zebras vex.
     10-22 22:19 myapp.area2  WARNING  Jail zesty vixen who grabbed pay from quack.
     10-22 22:19 myapp.area2  ERROR    The five boxing wizards jump quickly.

これを見て分かる通り、DEBUG メッセージはファイルだけに出力され、その他の
メッセージは両方に出力されます。

この例ではコンソールとファイルのハンドラだけを使っていますが、実際には任
意の数のハンドラや組み合わせを使えます。

ここでファイル名として ‘/tmp/myapp.log’ を選んだということは、一時ファイ
ルの標準的な場所として POSIX システムを想定していることに注意してくださ
い。 Windows の場合、ディレクトリが存在し、そのディレクトリに対してファ
イルを更新するための適切な権限を有することを保証するために、ログファイル
向けのディレクトリ名として異なる選択を取る必要があるでしょう。


File: python.info,  Node: ログレベルのカスタム処理,  Next: 設定サーバの例,  Prev: 複数の出力先にログを出力する,  Up: Logging クックブック

9.8.5 ログレベルのカスタム処理
------------------------------

しきい値以上のログレベル全てがハンドラによって処理される標準的な処理に対
して、ときにはわずかに異なる振る舞いを必要とすることもあるでしょう。その
ような場合はフィルタを使う必要があります。以下のような処理が必要なシナリ
オについて取り上げてみましょう:

   * 深刻度 ‘INFO’ と ‘WARNING’ のメッセージを ‘sys.stdout’ に送る

   * 深刻度 ‘ERROR’ 以上のメッセージを ‘sys.stderr’ に送る

   * 深刻度 ‘DEBUG’ 以上のメッセージをファイル ‘app.log’ に送る

logging モジュールを下記の JSON によって構成したとしましょう:

     {
         "version": 1,
         "disable_existing_loggers": false,
         "formatters": {
             "simple": {
                 "format": "%(levelname)-8s - %(message)s"
             }
         },
         "handlers": {
             "stdout": {
                 "class": "logging.StreamHandler",
                 "level": "INFO",
                 "formatter": "simple",
                 "stream": "ext://sys.stdout"
             },
             "stderr": {
                 "class": "logging.StreamHandler",
                 "level": "ERROR",
                 "formatter": "simple",
                 "stream": "ext://sys.stderr"
             },
             "file": {
                 "class": "logging.FileHandler",
                 "formatter": "simple",
                 "filename": "app.log",
                 "mode": "w"
             }
         },
         "root": {
             "level": "DEBUG",
             "handlers": [
                 "stderr",
                 "stdout",
                 "file"
             ]
         }
     }

This configuration does 'almost' what we want, except that ‘sys.stdout’
would show messages of severity ‘ERROR’ and only events of this severity
and higher will be tracked as well as ‘INFO’ and ‘WARNING’ messages.  To
prevent this, we can set up a filter which excludes those messages and
add it to the relevant handler.  This can be configured by adding a
‘filters’ section parallel to ‘formatters’ and ‘handlers’:

     {
         "filters": {
             "warnings_and_below": {
                 "()" : "__main__.filter_maker",
                 "level": "WARNING"
             }
         }
     }

そして ‘stdout’ のハンドラに関するセクションにフィルターを追加します:

     {
         "stdout": {
             "class": "logging.StreamHandler",
             "level": "INFO",
             "formatter": "simple",
             "stream": "ext://sys.stdout",
             "filters": ["warnings_and_below"]
         }
     }

フィルターは単なる関数なので、 ‘filter_maker’ (ファクトリ関数) は以下の
ように定義することができます:

     def filter_maker(level):
         level = getattr(logging, level)

         def filter(record):
             return record.levelno <= level

         return filter

この関数は引数として与えられた文字列をログレベルの数値に変換し、ログレコ
ード内のログレベルが指定されたレベル以下の場合に ‘True’ を返す関数を返し
ます。この例では ‘filter_maker’ をコマンドラインから実行するテストスクリ
プト ‘main.py’ で関数が定義されているため、フィルター設定上のモジュール
名は ‘__main__’ になります。そのためフィルター設定の中では
‘__main__.filter_maker’ となります。異なるモジュールで関数を定義した場合
、この部分を変更する必要があります。

フィルターを追加した ‘main.py’ の全体像は以下のようになり、これで実行で
きる状態になりました:

     import json
     import logging
     import logging.config

     CONFIG = '''
     {
         "version": 1,
         "disable_existing_loggers": false,
         "formatters": {
             "simple": {
                 "format": "%(levelname)-8s - %(message)s"
             }
         },
         "filters": {
             "warnings_and_below": {
                 "()" : "__main__.filter_maker",
                 "level": "WARNING"
             }
         },
         "handlers": {
             "stdout": {
                 "class": "logging.StreamHandler",
                 "level": "INFO",
                 "formatter": "simple",
                 "stream": "ext://sys.stdout",
                 "filters": ["warnings_and_below"]
             },
             "stderr": {
                 "class": "logging.StreamHandler",
                 "level": "ERROR",
                 "formatter": "simple",
                 "stream": "ext://sys.stderr"
             },
             "file": {
                 "class": "logging.FileHandler",
                 "formatter": "simple",
                 "filename": "app.log",
                 "mode": "w"
             }
         },
         "root": {
             "level": "DEBUG",
             "handlers": [
                 "stderr",
                 "stdout",
                 "file"
             ]
         }
     }
     '''

     def filter_maker(level):
         level = getattr(logging, level)

         def filter(record):
             return record.levelno <= level

         return filter

     logging.config.dictConfig(json.loads(CONFIG))
     logging.debug('A DEBUG message')
     logging.info('An INFO message')
     logging.warning('A WARNING message')
     logging.error('An ERROR message')
     logging.critical('A CRITICAL message')

これを以下のように実行します:

     python main.py 2>stderr.log >stdout.log

すると期待通りの結果を得ることができます:

     $ more *.log
     ::::::::::::::
     app.log
     ::::::::::::::
     DEBUG    - A DEBUG message
     INFO     - An INFO message
     WARNING  - A WARNING message
     ERROR    - An ERROR message
     CRITICAL - A CRITICAL message
     ::::::::::::::
     stderr.log
     ::::::::::::::
     ERROR    - An ERROR message
     CRITICAL - A CRITICAL message
     ::::::::::::::
     stdout.log
     ::::::::::::::
     INFO     - An INFO message
     WARNING  - A WARNING message


File: python.info,  Node: 設定サーバの例,  Next: ブロックする handler を扱う,  Prev: ログレベルのカスタム処理,  Up: Logging クックブック

9.8.6 設定サーバの例
--------------------

ログ記録設定サーバを使うモジュールの例です:

     import logging
     import logging.config
     import time
     import os

     # read initial config file
     logging.config.fileConfig('logging.conf')

     # create and start listener on port 9999
     t = logging.config.listen(9999)
     t.start()

     logger = logging.getLogger('simpleExample')

     try:
         # loop through logging calls to see the difference
         # new configurations make, until Ctrl+C is pressed
         while True:
             logger.debug('debug message')
             logger.info('info message')
             logger.warning('warn message')
             logger.error('error message')
             logger.critical('critical message')
             time.sleep(5)
     except KeyboardInterrupt:
         # cleanup
         logging.config.stopListening()
         t.join()

そしてファイル名を受け取ってそのファイルをサーバに送るスクリプトですが、
それに先だってバイナリエンコード長を新しいログ記録の設定として先に送って
おきます:

     #!/usr/bin/env python
     import socket, sys, struct

     with open(sys.argv[1], 'rb') as f:
         data_to_send = f.read()

     HOST = 'localhost'
     PORT = 9999
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     print('connecting...')
     s.connect((HOST, PORT))
     print('sending config...')
     s.send(struct.pack('>L', len(data_to_send)))
     s.send(data_to_send)
     s.close()
     print('complete')


File: python.info,  Node: ブロックする handler を扱う,  Next: ネットワーク越しの logging イベントの送受信,  Prev: 設定サーバの例,  Up: Logging クックブック

9.8.7 ブロックする handler を扱う
---------------------------------

ときどき、logging を行っているスレッドをブロックせずに、handler が動くよ
うにしないといけないときがあります。これは Web アプリケーションではよく
あることですし、もちろん他のシナリオでも起きる話です。

動作が鈍くなるときの元凶はたいてい、開発者のコントロール外にあるいくつも
の理由で (例えば、残念なパフォーマンスのメールやネットワークのインフラ)
、 *note SMTPHandler: 2cdb.: が電子メールを送るのに時間がかかることです
。しかし、ほとんどのネットワークをまたぐ handler はブロックする可能性が
あります: *note SocketHandler: f2f. による処理でさえ、裏で DNS への問い
合わせというとても遅い処理を行うことがあります (そしてこの問い合わせ処理
は、 Python の層より下のあなたの手の届かない、ソケットライブラリの深いと
ころにある可能性もあります)。

解決策の1つは、2パートに分離したアプローチを用いることです。最初のパート
は、パフォーマンスが重要なスレッドからアクセスされる、 *note
QueueHandler: 1742. だけをアタッチした logger です。この logger は単に、
十分大きい、あるいは無制限の容量を持ったキューに書き込むだけです。キュー
への書き込みは通常すぐに完了しますが、念の為に *note queue.Full: 3001. 例
外をキャッチする必要があるかもしれません。もしパフォーマンスクリティカル
なスレッドを持つライブラリの開発者であるなら、このことを (‘QueueHandler’
だけをアタッチした logger についての言及を添えて) ドキュメントに書いてお
きましょう。

2つ目のパートは *note QueueHandler: 1742. の対向として作られた *note
QueueListener: df9. です。 *note QueueListener: df9. はとてもシンプルで
、キューと handler を渡され、内部で ‘QueueHandler’ (もしくは他の
‘LogRecord’ の出力元) から送られた LogRecord をキューから受け取るスレッ
ドを起動します。 ‘LogRecord’ をキューから取り出して、 handler に渡して処
理させます。

分離した *note QueueListener: df9. クラスを持つメリットは、複数の
‘QueueHandler’ に対して1つのインスタンスで logging できることです。既存
の handler のスレッド利用版を使って handler ごとにスレッドを持つよりはず
っとリソースにやさしくなります。

この2つのクラスを利用する例です (import は省略):

     que = queue.Queue(-1)  # no limit on size
     queue_handler = QueueHandler(que)
     handler = logging.StreamHandler()
     listener = QueueListener(que, handler)
     root = logging.getLogger()
     root.addHandler(queue_handler)
     formatter = logging.Formatter('%(threadName)s: %(message)s')
     handler.setFormatter(formatter)
     listener.start()
     # The log output will display the thread which generated
     # the event (the main thread) rather than the internal
     # thread which monitors the internal queue. This is what
     # you want to happen.
     root.warning('Look out!')
     listener.stop()

実行すると次のように出力します:

     MainThread: Look out!

     注釈: 上述の議論は特に同期コードにについてのものではなく、むしろ遅
     いロギングハンドラについてでしたが、非同期コードやネットワーク、あ
     るいはファイルハンドラからのロギングでさえも (イベントループをブロ
     ックしてしまう) 問題につながる可能性があることには注意すべきでしょ
     う。これはいくつかのロギングが *note asyncio: 8. 内部で行われること
     が理由です。何らかの非同期コードがアプリケーションの中で使われてい
     る場合、ロギングには上記のアプローチを使っていかなるブロッキングコ
     ードも ‘QueueListener’ スレッド内だけで実行されるようにしておくこと
     が最も良いでしょう。

バージョン 3.5 で変更: Python 3.5 以前は、 *note QueueListener: df9. ク
ラスは常にキューから受け取ったメッセージを、初期化元となっているそれぞれ
のハンドラーに受け渡していました。 ( というのも、レベルフィルターリング
は別サイド、つまり、キューが満たされている場所で処理されるということが想
定されているからです) Python 3.5以降では、キーワードとなる引数
‘respect_handler_level=True’ をリスナーのコントラクターに受け渡すことで
、この挙動を変更することができるようになっています。これが行われると、各
メッセージのレベルをハンドラーのレベルと比較して、そうすることが適切な場
合のみ、メッセージをハンドラーに渡します。


File: python.info,  Node: ネットワーク越しの logging イベントの送受信,  Next: コンテキスト情報をログ記録出力に付加する,  Prev: ブロックする handler を扱う,  Up: Logging クックブック

9.8.8 ネットワーク越しの logging イベントの送受信
-------------------------------------------------

ログイベントをネットワーク越しに送信し、受信端でそれを処理したいとしまし
ょう。 *note SocketHandler: f2f. インスタンスを送信端の root logger にア
タッチすれば、簡単に実現できます:

     import logging, logging.handlers

     rootLogger = logging.getLogger('')
     rootLogger.setLevel(logging.DEBUG)
     socketHandler = logging.handlers.SocketHandler('localhost',
                         logging.handlers.DEFAULT_TCP_LOGGING_PORT)
     # don't bother with a formatter, since a socket handler sends the event as
     # an unformatted pickle
     rootLogger.addHandler(socketHandler)

     # Now, we can log to the root logger, or any other logger. First the root...
     logging.info('Jackdaws love my big sphinx of quartz.')

     # Now, define a couple of other loggers which might represent areas in your
     # application:

     logger1 = logging.getLogger('myapp.area1')
     logger2 = logging.getLogger('myapp.area2')

     logger1.debug('Quick zephyrs blow, vexing daft Jim.')
     logger1.info('How quickly daft jumping zebras vex.')
     logger2.warning('Jail zesty vixen who grabbed pay from quack.')
     logger2.error('The five boxing wizards jump quickly.')

受信端では *note socketserver: b9. モジュールを使って受信プログラムを作
成しておきます。簡単な実用プログラムを以下に示します:

     import pickle
     import logging
     import logging.handlers
     import socketserver
     import struct


     class LogRecordStreamHandler(socketserver.StreamRequestHandler):
         """Handler for a streaming logging request.

         This basically logs the record using whatever logging policy is
         configured locally.
         """

         def handle(self):
             """
             Handle multiple requests - each expected to be a 4-byte length,
             followed by the LogRecord in pickle format. Logs the record
             according to whatever policy is configured locally.
             """
             while True:
                 chunk = self.connection.recv(4)
                 if len(chunk) < 4:
                     break
                 slen = struct.unpack('>L', chunk)[0]
                 chunk = self.connection.recv(slen)
                 while len(chunk) < slen:
                     chunk = chunk + self.connection.recv(slen - len(chunk))
                 obj = self.unPickle(chunk)
                 record = logging.makeLogRecord(obj)
                 self.handleLogRecord(record)

         def unPickle(self, data):
             return pickle.loads(data)

         def handleLogRecord(self, record):
             # if a name is specified, we use the named logger rather than the one
             # implied by the record.
             if self.server.logname is not None:
                 name = self.server.logname
             else:
                 name = record.name
             logger = logging.getLogger(name)
             # N.B. EVERY record gets logged. This is because Logger.handle
             # is normally called AFTER logger-level filtering. If you want
             # to do filtering, do it at the client end to save wasting
             # cycles and network bandwidth!
             logger.handle(record)

     class LogRecordSocketReceiver(socketserver.ThreadingTCPServer):
         """
         Simple TCP socket-based logging receiver suitable for testing.
         """

         allow_reuse_address = True

         def __init__(self, host='localhost',
                      port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
                      handler=LogRecordStreamHandler):
             socketserver.ThreadingTCPServer.__init__(self, (host, port), handler)
             self.abort = 0
             self.timeout = 1
             self.logname = None

         def serve_until_stopped(self):
             import select
             abort = 0
             while not abort:
                 rd, wr, ex = select.select([self.socket.fileno()],
                                            [], [],
                                            self.timeout)
                 if rd:
                     self.handle_request()
                 abort = self.abort

     def main():
         logging.basicConfig(
             format='%(relativeCreated)5d %(name)-15s %(levelname)-8s %(message)s')
         tcpserver = LogRecordSocketReceiver()
         print('About to start TCP server...')
         tcpserver.serve_until_stopped()

     if __name__ == '__main__':
         main()

先にサーバを起動しておき、次にクライアントを起動します。クライアント側で
は、コンソールには何も出力されません; サーバ側では以下のようなメッセージ
を目にするはずです:

     About to start TCP server...
        59 root            INFO     Jackdaws love my big sphinx of quartz.
        59 myapp.area1     DEBUG    Quick zephyrs blow, vexing daft Jim.
        69 myapp.area1     INFO     How quickly daft jumping zebras vex.
        69 myapp.area2     WARNING  Jail zesty vixen who grabbed pay from quack.
        69 myapp.area2     ERROR    The five boxing wizards jump quickly.

注意： pickle にはいくつかのシナリオでセキュリティ上の問題があります。こ
れらが影響する場合は、 *note makePickle(): 2cc4. メソッドをオーバーライ
ドし代替シリアライズ手法を実装して、それを使うように上記のスクリプトを修
正することもできます。

* Menu:

* 作成中のロギングソケットのリスナーを実行する::


File: python.info,  Node: 作成中のロギングソケットのリスナーを実行する,  Up: ネットワーク越しの logging イベントの送受信

9.8.8.1 作成中のロギングソケットのリスナーを実行する
....................................................

作成中のロギングリスナーを実行するためには、 Supervisor(1) のようなプロ
セス管理ツールを使う必要があるかもしれません。 こちらの Gist(2) は
Supervisor を使って上記の機能を実行するための必要最低限のファイルを提供
しています。以下のファイルが必要になります:

ファイル                      目的
                              
---------------------------------------------------------------------------------------
                              
‘prepare.sh’                  試験用の環境を準備する Bash スクリプト
                              
                              
‘supervisor.conf’             リスナーとマルチプロセスの web アプリケーションのため
                              の設定を含む Supervisor の設定ファイル
                              
                              
‘ensure_app.sh’               Supervisor が上記の設定で実行されていることを保証する
                              ための Bash スクリプト
                              
                              
‘log_listener.py’             ログイベントを受信してファイルに記録するソケットリスナ
                              ープログラム
                              
                              
‘main.py’                     リスナーに接続されたソケットを通じてロギングを実行する
                              簡単な web アプリケーション
                              
                              
‘webapp.json’                 web アプリケーションのための JSON 設定ファイル
                              
                              
‘client.py’                   web アプリケーションを起動するための Python スクリプト
                              

この web アプリケーションは、リクエストを処理する複数のワーカープロセス
を起動する web アプリケーションサーバーである Gunicorn(3) を使っています
。ここに例として挙げた設定は、複数のワーカーがいかにして互いに衝突するこ
となく同じログファイルに書き込みを行うことができるかを示しています -- ワ
ーカーは全てソケットリスナーを通じてログを書き込むのです。

これらのファイルを試すためには、 POSIX 環境において以下を行なってくださ
い:

  1. Download ZIP ボタンを押して Gist(4) を ZIP アーカイブとしてダウンロ
     ードしてください。

  2. アーカイブファイルをスクラッチディレクトリに展開してください。

  3. 準備のために、スクラッチディレクトリにおいて ‘bash prepare.sh’ を実
     行してください。これにより Supervisor 関連のファイルおよびログファ
     イルのための ‘run’ サブディレクトリ、および ‘bottle’, ‘gunicorn’ そ
     して ‘supervisor’ がインストールされる仮想環境を含む ‘venv’ サブデ
     ィレクトリが生成されます。

  4. ‘bash ensure_app.sh’ を実行して Supervisor が上記の設定で実行されて
     いることを確認してください。

  5. ‘venv/bin/python client.py’ を実行して web アプリケーションを起動し
     てください。これによりログにレコードが書き込まれるはずです。

  6. ‘run’ サブディレクトリにあるログファイルを調べてください。最新のロ
     グは、パターン ‘app.log*’ に一致する名前のファイルにあるはずです。
     ログは異なるワーカープロセスによって非決定論的な形で並行に処理され
     るため、特定の決まった順番にはなりません。

  7. リスナーと web アプリケーションは ‘venv/bin/supervisorctl -c
     supervisor.conf shutdown’ を実行することでシャットダウンできます。

ありそうもないことですが、テスト環境で設定したポートが別の設定と衝突して
しまった場合、設定ファイルを修正する必要があるかもしれません。

   ---------- Footnotes ----------

   (1) http://supervisord.org/

   (2) https://gist.github.com/vsajip/4b227eeec43817465ca835ca66f75e2b

   (3) https://gunicorn.org/

   (4) https://gist.github.com/vsajip/4b227eeec43817465ca835ca66f75e2b


File: python.info,  Node: コンテキスト情報をログ記録出力に付加する,  Next: contextvars の利用,  Prev: ネットワーク越しの logging イベントの送受信,  Up: Logging クックブック

9.8.9 コンテキスト情報をログ記録出力に付加する
----------------------------------------------

時にはログ記録出力にログ関数の呼び出し時に渡されたパラメータに加えてコン
テキスト情報を含めたいこともあるでしょう。たとえば、ネットワークアプリケ
ーションで、クライアント固有の情報 (例: リモートクライアントの名前、 IP
アドレス) もログ記録に残しておきたいと思ったとしましょう。 'extra' パラ
メータをこの目的に使うこともできますが、いつでもこの方法で情報を渡すのが
便利なやり方とも限りません。また接続ごとに *note Logger: b1d. インスタン
スを生成する誘惑に駆られるかもしれませんが、生成した *note Logger: b1d.
インスタンスはガーベジコレクションで回収されないので、これは良いアイデア
とは言えません。この例は現実的な問題ではないかもしれませんが、 *note
Logger: b1d. インスタンスの個数がアプリケーションの中でログ記録が行われ
るレベルの粒度に依存する場合、 *note Logger: b1d. インスタンスの個数が事
実上無制限にならないと、管理が難しくなります。

* Menu:

* LoggerAdapter を使ったコンテキスト情報の伝達::
* Filter を使ったコンテキスト情報の伝達::


File: python.info,  Node: LoggerAdapter を使ったコンテキスト情報の伝達,  Next: Filter を使ったコンテキスト情報の伝達,  Up: コンテキスト情報をログ記録出力に付加する

9.8.9.1 LoggerAdapter を使ったコンテキスト情報の伝達
....................................................

logging イベントの情報と一緒に出力されるコンテキスト情報を渡す簡単な方法
は、 *note LoggerAdapter: 12c3. を使うことです。このクラスは *note
Logger: b1d. のように見えるように設計されていて、 *note debug(): 2c2f,
*note info(): 2c59, *note warning(): 2d6, *note error(): 2c6d, *note
exception(): 1437, *note critical(): 2c6e, *note log(): 2c6f. の各メソッ
ドを呼び出せるようになっています。これらのメソッドは対応する *note
Logger: b1d. のメソッドと同じ引数を取るので、二つの型を取り替えて使うこ
とができます。

*note LoggerAdapter: 12c3. のインスタンスを生成する際には、 *note
Logger: b1d. インスタンスとコンテキスト情報を収めた辞書風 (dict-like) の
オブジェクトを渡します。 *note LoggerAdapter: 12c3. のログ記録メソッドを
呼び出すと、呼び出しをコンストラクタに渡された配下の *note Logger: b1d.
インスタンスに委譲し、その際コンテキスト情報をその委譲された呼び出しに埋
め込みます。 *note LoggerAdapter: 12c3. のコードから少し抜き出してみます
:

     def debug(self, msg, /, *args, **kwargs):
         """
         Delegate a debug call to the underlying logger, after adding
         contextual information from this adapter instance.
         """
         msg, kwargs = self.process(msg, kwargs)
         self.logger.debug(msg, *args, **kwargs)

*note LoggerAdapter: 12c3. の *note process(): 2c66. メソッドがコンテキ
スト情報をログ出力に加える場所です。そこではログ記録呼び出しのメッセージ
とキーワード引数が渡され、加工された (可能性のある) それらの情報を配下の
ロガーへの呼び出しに渡し直します。このメソッドのデフォルト実装ではメッセ
ージは元のままですが、キーワード引数にはコンストラクタに渡された辞書風オ
ブジェクトを値として "extra" キーが挿入されます。もちろん、呼び出し時に
"extra" キーワードを使った場合には何事もなかったかのように上書きされます
。

"extra" を用いる利点は辞書風オブジェクトの中の値が *note LogRecord: fb3.
インスタンスの __dict__ にマージされることで、辞書風オブジェクトのキーを
知っている *note Formatter: 143a. を用意して文字列をカスタマイズするよう
にできることです。それ以外のメソッドが必要なとき、たとえばコンテキスト情
報をメッセージの前や後ろにつなげたい場合には、 *note LoggerAdapter:
12c3. から *note process(): 2c66. を望むようにオーバライドしたサブクラス
を作ることが必要なだけです。次に挙げるのはこのクラスを使った例で、コンス
トラクタで使われる「辞書風」オブジェクトにどの振る舞いが必要なのかも示し
ています:

     class CustomAdapter(logging.LoggerAdapter):
         """
         This example adapter expects the passed in dict-like object to have a
         'connid' key, whose value in brackets is prepended to the log message.
         """
         def process(self, msg, kwargs):
             return '[%s] %s' % (self.extra['connid'], msg), kwargs

これを次のように使うことができます:

     logger = logging.getLogger(__name__)
     adapter = CustomAdapter(logger, {'connid': some_conn_id})

これで、この adapter 経由でログした全てのイベントに対して、
‘some_conn_id’ の値がログメッセージの前に追加されます。

* Menu:

* コンテキスト情報を渡すために dict 以外のオブジェクトを使う::


File: python.info,  Node: コンテキスト情報を渡すために dict 以外のオブジェクトを使う,  Up: LoggerAdapter を使ったコンテキスト情報の伝達

9.8.9.2 コンテキスト情報を渡すために dict 以外のオブジェクトを使う
..................................................................

*note LoggerAdapter: 12c3. に渡すのは本物の dict でなくても構いません。
‘__getitem__’ と ‘__iter__’ を実装していて logging が辞書のように扱える
クラスのインスタンスを利用することができます。これは (dict の値が固定さ
れるのに対して) 値を動的に生成できるので便利です。


File: python.info,  Node: Filter を使ったコンテキスト情報の伝達,  Prev: LoggerAdapter を使ったコンテキスト情報の伝達,  Up: コンテキスト情報をログ記録出力に付加する

9.8.9.3 Filter を使ったコンテキスト情報の伝達
.............................................

ユーザ定義の *note Filter: 11cc. を使ってログ出力にコンテキスト情報を加
えることもできます。 ‘Filter’ インスタンスは、渡された ‘LogRecords’ を修
正することができます。これにより、適切なフォーマット文字列や必要なら
*note Formatter: 143a. を使って、出力となる属性を新しく追加することも出
来ます。

例えば、web アプリケーションで、処理されるリクエスト (または、少なくとも
その重要な部分) は、スレッドローカル (*note threading.local: 16d6.) な変
数に保存して、 ‘Filter’ からアクセスすることで、 ‘LogRecord’ にリクエス
トの情報を追加できます。例えば、リモート IP アドレスやリモートユーザのユ
ーザ名にアクセスしたいなら、上述の ‘LoggerAdapter’ の例のように属性名
'ip' や 'user' を使うといったようにです。その場合、同じフォーマット文字
列を使って以下に示すように似たような出力を得られます。これはスクリプトの
例です:

     import logging
     from random import choice

     class ContextFilter(logging.Filter):
         """
         This is a filter which injects contextual information into the log.

         Rather than use actual contextual information, we just use random
         data in this demo.
         """

         USERS = ['jim', 'fred', 'sheila']
         IPS = ['123.231.231.123', '127.0.0.1', '192.168.0.1']

         def filter(self, record):

             record.ip = choice(ContextFilter.IPS)
             record.user = choice(ContextFilter.USERS)
             return True

     if __name__ == '__main__':
         levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
         logging.basicConfig(level=logging.DEBUG,
                             format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s')
         a1 = logging.getLogger('a.b.c')
         a2 = logging.getLogger('d.e.f')

         f = ContextFilter()
         a1.addFilter(f)
         a2.addFilter(f)
         a1.debug('A debug message')
         a1.info('An info message with %s', 'some parameters')
         for x in range(10):
             lvl = choice(levels)
             lvlname = logging.getLevelName(lvl)
             a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters')

実行すると、以下のようになります:

     2010-09-06 22:38:15,292 a.b.c DEBUG    IP: 123.231.231.123 User: fred     A debug message
     2010-09-06 22:38:15,300 a.b.c INFO     IP: 192.168.0.1     User: sheila   An info message with some parameters
     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
     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
     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
     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
     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
     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
     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
     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
     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
     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


File: python.info,  Node: contextvars の利用,  Next: ハンドラ内でのコンテキスト情報の付与,  Prev: コンテキスト情報をログ記録出力に付加する,  Up: Logging クックブック

9.8.10 ‘contextvars’ の利用
---------------------------

Python 3.7 以降、 *note contextvars: 1d. モジュールは *note threading:
d6. と *note asyncio: 8. の両方の処理上のニーズを満たすコンテキストロー
カルな変数を提供しています。このタイプの変数はスレッドローカルな変数に適
しています。以下の例は、マルチスレッド環境において、 いかにして web アプ
リケーションによって処理されるリクエスト属性のような処理の文脈上の情報と
ともにログを投入できるかを示します。

説明のため、同じ Python プロセス上で共通のライブラリを使っている独立した
複数の web アプリケーションがあるとします。これらのアプリケーションが、
クライアントの IP アドレスや HTTP リクエストメソッド、およびクライアント
のユーザー名のようなコンテキスト依存の情報を追加情報として含んだ自身のロ
グを、共通のライブラリ (と他のリクエスト処理のためのコード) から各アプリ
ケーションのログファイルへ適切に振り向けるためにはどのようにしたら良いで
しょうか？

ここで、ライブラリは以下のコードで模することができるとします:

     # webapplib.py
     import logging
     import time

     logger = logging.getLogger(__name__)

     def useful():
         # Just a representative event logged from the library
         logger.debug('Hello from webapplib!')
         # Just sleep for a bit so other threads get to run
         time.sleep(0.01)

複数の web アプリケーションは2つの簡単なクラス, ‘Request’ と ‘WebApp’, に
よって模倣することができます。これらは実際のスレッド化された web アプリ
ケーションがどのように動作するかを模擬的にあらわしています - すなわち各
リクエストはスレッドで処理される状況です:

     # main.py
     import argparse
     from contextvars import ContextVar
     import logging
     import os
     from random import choice
     import threading
     import webapplib

     logger = logging.getLogger(__name__)
     root = logging.getLogger()
     root.setLevel(logging.DEBUG)

     class Request:
         """
         A simple dummy request class which just holds dummy HTTP request method,
         client IP address and client username
         """
         def __init__(self, method, ip, user):
             self.method = method
             self.ip = ip
             self.user = user

     # A dummy set of requests which will be used in the simulation - we'll just pick
     # from this list randomly. Note that all GET requests are from 192.168.2.XXX
     # addresses, whereas POST requests are from 192.16.3.XXX addresses. Three users
     # are represented in the sample requests.

     REQUESTS = [
         Request('GET', '192.168.2.20', 'jim'),
         Request('POST', '192.168.3.20', 'fred'),
         Request('GET', '192.168.2.21', 'sheila'),
         Request('POST', '192.168.3.21', 'jim'),
         Request('GET', '192.168.2.22', 'fred'),
         Request('POST', '192.168.3.22', 'sheila'),
     ]

     # Note that the format string includes references to request context information
     # such as HTTP method, client IP and username

     formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %(user)-6s %(ip)s %(method)-4s %(message)s')

     # Create our context variables. These will be filled at the start of request
     # processing, and used in the logging that happens during that processing

     ctx_request = ContextVar('request')
     ctx_appname = ContextVar('appname')

     class InjectingFilter(logging.Filter):
         """
         A filter which injects context-specific information into logs and ensures
         that only information for a specific webapp is included in its log
         """
         def __init__(self, app):
             self.app = app

         def filter(self, record):
             request = ctx_request.get()
             record.method = request.method
             record.ip = request.ip
             record.user = request.user
             record.appName = appName = ctx_appname.get()
             return appName == self.app.name

     class WebApp:
         """
         A dummy web application class which has its own handler and filter for a
         webapp-specific log.
         """
         def __init__(self, name):
             self.name = name
             handler = logging.FileHandler(name + '.log', 'w')
             f = InjectingFilter(self)
             handler.setFormatter(formatter)
             handler.addFilter(f)
             root.addHandler(handler)
             self.num_requests = 0

         def process_request(self, request):
             """
             This is the dummy method for processing a request. It's called on a
             different thread for every request. We store the context information into
             the context vars before doing anything else.
             """
             ctx_request.set(request)
             ctx_appname.set(self.name)
             self.num_requests += 1
             logger.debug('Request processing started')
             webapplib.useful()
             logger.debug('Request processing finished')

     def main():
         fn = os.path.splitext(os.path.basename(__file__))[0]
         adhf = argparse.ArgumentDefaultsHelpFormatter
         ap = argparse.ArgumentParser(formatter_class=adhf, prog=fn,
                                      description='Simulate a couple of web '
                                                  'applications handling some '
                                                  'requests, showing how request '
                                                  'context can be used to '
                                                  'populate logs')
         aa = ap.add_argument
         aa('--count', '-c', type=int, default=100, help='How many requests to simulate')
         options = ap.parse_args()

         # Create the dummy webapps and put them in a list which we can use to select
         # from randomly
         app1 = WebApp('app1')
         app2 = WebApp('app2')
         apps = [app1, app2]
         threads = []
         # Add a common handler which will capture all events
         handler = logging.FileHandler('app.log', 'w')
         handler.setFormatter(formatter)
         root.addHandler(handler)

         # Generate calls to process requests
         for i in range(options.count):
             try:
                 # Pick an app at random and a request for it to process
                 app = choice(apps)
                 request = choice(REQUESTS)
                 # Process the request in its own thread
                 t = threading.Thread(target=app.process_request, args=(request,))
                 threads.append(t)
                 t.start()
             except KeyboardInterrupt:
                 break

         # Wait for the threads to terminate
         for t in threads:
             t.join()

         for app in apps:
             print('%s processed %s requests' % (app.name, app.num_requests))

     if __name__ == '__main__':
         main()

上記のコードを実行すると、およそ半分のリクエストが ‘app1.log’ に、残り半
分が ‘app2.log’ にそれぞれ記録され、同時に全てのリクエストが ‘app.log’ に
記録されることがわかるでしょう。それぞれの web アプリケーション固有のロ
グはそれぞれのアプリケーションからのログエントリだけを含み、リクエスト情
報が矛盾なくログに表示されている (すなわち、各ダミーリクエストの情報は常
にログの行とともに現れる) はずです。このことは以下のシェルコマンドの出力
により例示されています:

     ~/logging-contextual-webapp$ python main.py
     app1 processed 51 requests
     app2 processed 49 requests
     ~/logging-contextual-webapp$ wc -l *.log
       153 app1.log
       147 app2.log
       300 app.log
       600 total
     ~/logging-contextual-webapp$ head -3 app1.log
     Thread-3 (process_request) app1 __main__  jim    192.168.3.21 POST Request processing started
     Thread-3 (process_request) app1 webapplib jim    192.168.3.21 POST Hello from webapplib!
     Thread-5 (process_request) app1 __main__  jim    192.168.3.21 POST Request processing started
     ~/logging-contextual-webapp$ head -3 app2.log
     Thread-1 (process_request) app2 __main__  sheila 192.168.2.21 GET  Request processing started
     Thread-1 (process_request) app2 webapplib sheila 192.168.2.21 GET  Hello from webapplib!
     Thread-2 (process_request) app2 __main__  jim    192.168.2.20 GET  Request processing started
     ~/logging-contextual-webapp$ head app.log
     Thread-1 (process_request) app2 __main__  sheila 192.168.2.21 GET  Request processing started
     Thread-1 (process_request) app2 webapplib sheila 192.168.2.21 GET  Hello from webapplib!
     Thread-2 (process_request) app2 __main__  jim    192.168.2.20 GET  Request processing started
     Thread-3 (process_request) app1 __main__  jim    192.168.3.21 POST Request processing started
     Thread-2 (process_request) app2 webapplib jim    192.168.2.20 GET  Hello from webapplib!
     Thread-3 (process_request) app1 webapplib jim    192.168.3.21 POST Hello from webapplib!
     Thread-4 (process_request) app2 __main__  fred   192.168.2.22 GET  Request processing started
     Thread-5 (process_request) app1 __main__  jim    192.168.3.21 POST Request processing started
     Thread-4 (process_request) app2 webapplib fred   192.168.2.22 GET  Hello from webapplib!
     Thread-6 (process_request) app1 __main__  jim    192.168.3.21 POST Request processing started
     ~/logging-contextual-webapp$ grep app1 app1.log | wc -l
     153
     ~/logging-contextual-webapp$ grep app2 app2.log | wc -l
     147
     ~/logging-contextual-webapp$ grep app1 app.log | wc -l
     153
     ~/logging-contextual-webapp$ grep app2 app.log | wc -l
     147


File: python.info,  Node: ハンドラ内でのコンテキスト情報の付与,  Next: 複数のプロセスからの単一ファイルへのログ記録,  Prev: contextvars の利用,  Up: Logging クックブック

9.8.11 ハンドラ内でのコンテキスト情報の付与
-------------------------------------------

*note Handler: 1439. はそれぞれ一連のフィルタを独自に持っています。コン
テキスト情報を、他のハンドラに漏らすことなく *note LogRecord: fb3. に付
加したい場合、以下に示すスクリプトのように、直接レコードを編集する代わり
に新しい *note LogRecord: fb3. を返すフィルタを使うことができます:

     import copy
     import logging

     def filter(record: logging.LogRecord):
         record = copy.copy(record)
         record.user = 'jim'
         return record

     if __name__ == '__main__':
         logger = logging.getLogger()
         logger.setLevel(logging.INFO)
         handler = logging.StreamHandler()
         formatter = logging.Formatter('%(message)s from %(user)-8s')
         handler.setFormatter(formatter)
         handler.addFilter(filter)
         logger.addHandler(handler)

         logger.info('A log message')


File: python.info,  Node: 複数のプロセスからの単一ファイルへのログ記録,  Next: ファイルをローテートする,  Prev: ハンドラ内でのコンテキスト情報の付与,  Up: Logging クックブック

9.8.12 複数のプロセスからの単一ファイルへのログ記録
---------------------------------------------------

ログ記録はスレッドセーフであり、単一プロセスの複数のスレッドからの単一フ
ァイルへのログ記録はサポート 'されています' が、 '複数プロセス' からの単
一ファイルへのログ記録はサポート 'されません' 。なぜなら、複数のプロセス
をまたいで単一のファイルへのアクセスを直列化する標準の方法が Python には
存在しないからです。複数のプロセスから単一ファイルへログ記録しなければな
らないなら、最も良い方法は、すべてのプロセスが *note SocketHandler: f2f.
に対してログ記録を行い、独立したプロセスとしてソケットサーバを動かすこと
です。ソケットサーバはソケットから読み取ってファイルにログを書き出します
。 (この機能を実行するために、既存のプロセスの 1 つのスレッドを割り当て
ることもできます) *note この節: 4dce. では、このアプローチをさらに詳細に
文書化しています。動作するソケット受信プログラムが含まれているので、アプ
リケーションに組み込むための出発点として使用できるでしょう。

You could also write your own handler which uses the *note Lock: 1504.
class from the *note multiprocessing: 86. module to serialize access to
the file from your processes.  The stdlib *note FileHandler: 1809. and
subclasses do not make use of *note multiprocessing: 86.

別の方法として、 ‘Queue’ と *note QueueHandler: 1742. を使って、マルチプ
ロセスアプリケーションの1つのプロセスに全ての logging イベントを送る事が
できます。次の例はこれを行う方法を示します。この例では独立した listener
プロセスが他のプロセスから送られた event を受け取り、それを独自の
logging 設定にしたがって保存します。この例は実装の方法の1つを示している
だけ (例えば、 listener プロセスを分離する代わりに listener スレッドを使
うこともできます) ですが、これは listener とアプリケーション内の他のプロ
セスで完全に異なる設定を使う例になっているので、各自の要求に応じたコード
を書く叩き台になるでしょう:

     # You'll need these imports in your own code
     import logging
     import logging.handlers
     import multiprocessing

     # Next two import lines for this demo only
     from random import choice, random
     import time

     #
     # Because you'll want to define the logging configurations for listener and workers, the
     # listener and worker process functions take a configurer parameter which is a callable
     # for configuring logging for that process. These functions are also passed the queue,
     # which they use for communication.
     #
     # In practice, you can configure the listener however you want, but note that in this
     # simple example, the listener does not apply level or filter logic to received records.
     # In practice, you would probably want to do this logic in the worker processes, to avoid
     # sending events which would be filtered out between processes.
     #
     # The size of the rotated files is made small so you can see the results easily.
     def listener_configurer():
         root = logging.getLogger()
         h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10)
         f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %(levelname)-8s %(message)s')
         h.setFormatter(f)
         root.addHandler(h)

     # This is the listener process top-level loop: wait for logging events
     # (LogRecords)on the queue and handle them, quit when you get a None for a
     # LogRecord.
     def listener_process(queue, configurer):
         configurer()
         while True:
             try:
                 record = queue.get()
                 if record is None:  # We send this as a sentinel to tell the listener to quit.
                     break
                 logger = logging.getLogger(record.name)
                 logger.handle(record)  # No level or filter logic applied - just do it!
             except Exception:
                 import sys, traceback
                 print('Whoops! Problem:', file=sys.stderr)
                 traceback.print_exc(file=sys.stderr)

     # Arrays used for random selections in this demo

     LEVELS = [logging.DEBUG, logging.INFO, logging.WARNING,
               logging.ERROR, logging.CRITICAL]

     LOGGERS = ['a.b.c', 'd.e.f']

     MESSAGES = [
         'Random message #1',
         'Random message #2',
         'Random message #3',
     ]

     # The worker configuration is done at the start of the worker process run.
     # Note that on Windows you can't rely on fork semantics, so each process
     # will run the logging configuration code when it starts.
     def worker_configurer(queue):
         h = logging.handlers.QueueHandler(queue)  # Just the one handler needed
         root = logging.getLogger()
         root.addHandler(h)
         # send all messages, for demo; no other level or filter logic applied.
         root.setLevel(logging.DEBUG)

     # This is the worker process top-level loop, which just logs ten events with
     # random intervening delays before terminating.
     # The print messages are just so you know it's doing something!
     def worker_process(queue, configurer):
         configurer(queue)
         name = multiprocessing.current_process().name
         print('Worker started: %s' % name)
         for i in range(10):
             time.sleep(random())
             logger = logging.getLogger(choice(LOGGERS))
             level = choice(LEVELS)
             message = choice(MESSAGES)
             logger.log(level, message)
         print('Worker finished: %s' % name)

     # Here's where the demo gets orchestrated. Create the queue, create and start
     # the listener, create ten workers and start them, wait for them to finish,
     # then send a None to the queue to tell the listener to finish.
     def main():
         queue = multiprocessing.Queue(-1)
         listener = multiprocessing.Process(target=listener_process,
                                            args=(queue, listener_configurer))
         listener.start()
         workers = []
         for i in range(10):
             worker = multiprocessing.Process(target=worker_process,
                                              args=(queue, worker_configurer))
             workers.append(worker)
             worker.start()
         for w in workers:
             w.join()
         queue.put_nowait(None)
         listener.join()

     if __name__ == '__main__':
         main()

上のスクリプトの亜種で、logging をメインプロセスの別スレッドで行う例:

     import logging
     import logging.config
     import logging.handlers
     from multiprocessing import Process, Queue
     import random
     import threading
     import time

     def logger_thread(q):
         while True:
             record = q.get()
             if record is None:
                 break
             logger = logging.getLogger(record.name)
             logger.handle(record)


     def worker_process(q):
         qh = logging.handlers.QueueHandler(q)
         root = logging.getLogger()
         root.setLevel(logging.DEBUG)
         root.addHandler(qh)
         levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,
                   logging.CRITICAL]
         loggers = ['foo', 'foo.bar', 'foo.bar.baz',
                    'spam', 'spam.ham', 'spam.ham.eggs']
         for i in range(100):
             lvl = random.choice(levels)
             logger = logging.getLogger(random.choice(loggers))
             logger.log(lvl, 'Message no. %d', i)

     if __name__ == '__main__':
         q = Queue()
         d = {
             'version': 1,
             'formatters': {
                 'detailed': {
                     'class': 'logging.Formatter',
                     'format': '%(asctime)s %(name)-15s %(levelname)-8s %(processName)-10s %(message)s'
                 }
             },
             'handlers': {
                 'console': {
                     'class': 'logging.StreamHandler',
                     'level': 'INFO',
                 },
                 'file': {
                     'class': 'logging.FileHandler',
                     'filename': 'mplog.log',
                     'mode': 'w',
                     'formatter': 'detailed',
                 },
                 'foofile': {
                     'class': 'logging.FileHandler',
                     'filename': 'mplog-foo.log',
                     'mode': 'w',
                     'formatter': 'detailed',
                 },
                 'errors': {
                     'class': 'logging.FileHandler',
                     'filename': 'mplog-errors.log',
                     'mode': 'w',
                     'level': 'ERROR',
                     'formatter': 'detailed',
                 },
             },
             'loggers': {
                 'foo': {
                     'handlers': ['foofile']
                 }
             },
             'root': {
                 'level': 'DEBUG',
                 'handlers': ['console', 'file', 'errors']
             },
         }
         workers = []
         for i in range(5):
             wp = Process(target=worker_process, name='worker %d' % (i + 1), args=(q,))
             workers.append(wp)
             wp.start()
         logging.config.dictConfig(d)
         lp = threading.Thread(target=logger_thread, args=(q,))
         lp.start()
         # At this point, the main process could do some useful work of its own
         # Once it's done that, it can wait for the workers to terminate...
         for wp in workers:
             wp.join()
         # And now tell the logging thread to finish up, too
         q.put(None)
         lp.join()

こちらは特定の logger に設定を適用する例になっています。‘foo’ logger は
‘foo’ サブシステムの中の全てのイベントを ‘mplog-foo.log’ に保存する特別
な handler を持っています。これはメインプロセス側の log 処理で使われ、
(logging イベントは worker プロセス側で生成されますが) 各メッセージを適
切な出力先に出力します。

* Menu:

* concurrent.futures.ProcessPoolExecutorの利用: concurrent futures ProcessPoolExecutorの利用.
* Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ::


File: python.info,  Node: concurrent futures ProcessPoolExecutorの利用,  Next: Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ,  Up: 複数のプロセスからの単一ファイルへのログ記録

9.8.12.1 concurrent.futures.ProcessPoolExecutorの利用
.....................................................

もし、ワーカープロセスを起動するために *note
concurrent.futures.ProcessPoolExecutor: 8bc. を使いたいのであれば、少し
違う方法でキューを作る必要があります。次のような方法の代わりに

     queue = multiprocessing.Queue(-1)

次のコードを利用する必要があります

     queue = multiprocessing.Manager().Queue(-1)  # also works with the examples above

そして、次のようなワーカー作成コードがあったとすると:

     workers = []
     for i in range(10):
         worker = multiprocessing.Process(target=worker_process,
                                          args=(queue, worker_configurer))
         workers.append(worker)
         worker.start()
     for w in workers:
         w.join()

次のように変更します（最初に *note concurrent.futures: 1a. をインポート
するのを忘れないようにしましょう）:

     with concurrent.futures.ProcessPoolExecutor(max_workers=10) as executor:
         for i in range(10):
             executor.submit(worker_process, queue, worker_configurer)


File: python.info,  Node: Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ,  Prev: concurrent futures ProcessPoolExecutorの利用,  Up: 複数のプロセスからの単一ファイルへのログ記録

9.8.12.2 Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ
..................................................................

Gunicorn(1) や uWSGI(2) (またはそれに類するもの) を使って Web アプリケー
ションをデプロイする場合、クライアントのリクエストを処理するために複数の
ワーカープロセスが作られます。そのような環境では、 web アプリケーション
に直接ファイルベースのハンドラを作ることは避けてください。 代わりに、
*note SocketHandler: f2f. を使って別のプロセスとして動作するリスナーに
web アプリケーションからログを送信するようにしてください。これは
Supervisor のようなプロセス管理ツールを使うことで設定できます - 詳しくは
*note 作成中のロギングソケットのリスナーを実行する: 4dd0. を参照してくだ
さい。

   ---------- Footnotes ----------

   (1) https://gunicorn.org/

   (2) https://uwsgi-docs.readthedocs.io/en/latest/


File: python.info,  Node: ファイルをローテートする,  Next: 別の format スタイルを利用する,  Prev: 複数のプロセスからの単一ファイルへのログ記録,  Up: Logging クックブック

9.8.13 ファイルをローテートする
-------------------------------

ログファイルがある大きさに達したら、新しいファイルを開いてそこにログを取
りたいことがあります。そのファイルをある数だけ残し、その数のファイルが生
成されたらファイルを循環し、ファイルの数も大きさも制限したいこともあるで
しょう。この利用パターンのために、 logging パッケージは *note
RotatingFileHandler: 153b. を提供しています:

     import glob
     import logging
     import logging.handlers

     LOG_FILENAME = 'logging_rotatingfile_example.out'

     # Set up a specific logger with our desired output level
     my_logger = logging.getLogger('MyLogger')
     my_logger.setLevel(logging.DEBUG)

     # Add the log message handler to the logger
     handler = logging.handlers.RotatingFileHandler(
                   LOG_FILENAME, maxBytes=20, backupCount=5)

     my_logger.addHandler(handler)

     # Log some messages
     for i in range(20):
         my_logger.debug('i = %d' % i)

     # See what files are created
     logfiles = glob.glob('%s*' % LOG_FILENAME)

     for filename in logfiles:
         print(filename)

この結果として、アプリケーションのログ履歴の一部である、6 つに別れたファ
イルが得られます:

     logging_rotatingfile_example.out
     logging_rotatingfile_example.out.1
     logging_rotatingfile_example.out.2
     logging_rotatingfile_example.out.3
     logging_rotatingfile_example.out.4
     logging_rotatingfile_example.out.5

最新のファイルはいつでも ‘logging_rotatingfile_example.out’ で、サイズの
上限に達するたびに拡張子 ‘.1’ を付けた名前に改名されます。既にあるバック
アップファイルはその拡張子がインクリメントされ (‘.1’ が ‘.2’ になるなど
)、 ‘.6’ ファイルは消去されます。

明らかに、ここでは極端な例示のためにファイルの大きさをかなり小さな値に設
定しています。実際に使うときは 'maxBytes' を適切な値に設定してください。


File: python.info,  Node: 別の format スタイルを利用する,  Next: LogRecord のカスタマイズ,  Prev: ファイルをローテートする,  Up: Logging クックブック

9.8.14 別の format スタイルを利用する
-------------------------------------

logging が Python 標準ライブラリに追加された時、メッセージを動的な内容で
フォーマットする唯一の方法は % を使ったフォーマットでした。その後、
Python には新しい文字列フォーマット機構として *note string.Template:
653. (Python 2.4 で追加) と *note str.format(): 5ed. (Python 2.6 で追加)
が加わりました。

logging は (3.2 から) この2つの追加されたフォーマット方法をサポートして
います。 *note Formatter: 143a. クラスが ‘style’ という名前のオプション
のキーワード引数を受け取ります。このデフォルト値は ‘'%'’ ですが、他に
‘'{'’ と ‘'$'’ が指定可能で、それぞれのフォーマット方法に対応しています
。後方互換性はデフォルト値によって維持されていますが、明示的に style 引
数を指定することで、 *note str.format(): 5ed. か *note string.Template:
653. を使った format を指定する事ができます。次の例はこの機能を使ってみ
ています:

     >>> import logging
     >>> root = logging.getLogger()
     >>> root.setLevel(logging.DEBUG)
     >>> handler = logging.StreamHandler()
     >>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}',
     ...                        style='{')
     >>> handler.setFormatter(bf)
     >>> root.addHandler(handler)
     >>> logger = logging.getLogger('foo.bar')
     >>> logger.debug('This is a DEBUG message')
     2010-10-28 15:11:55,341 foo.bar DEBUG    This is a DEBUG message
     >>> logger.critical('This is a CRITICAL message')
     2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message
     >>> df = logging.Formatter('$asctime $name ${levelname} $message',
     ...                        style='$')
     >>> handler.setFormatter(df)
     >>> logger.debug('This is a DEBUG message')
     2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message
     >>> logger.critical('This is a CRITICAL message')
     2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message
     >>>

最終的に出力されるログメッセージの format と、各メッセージを生成する部分
は完全に独立していることに注意してください。次の例でわかるように、メッセ
ージを生成する部分では % を使い続けています:

     >>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message')
     2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message
     >>>

logging の呼び出し (‘logger.debug()’ や ‘logger.info()’ など) は、ログメ
ッセージのために位置引数しか受け取らず、キーワード引数はそれを処理すると
きのオプションを指定するためだけに使われます。 (例えば、 ‘exc_info’ キー
ワード引数を使ってログを取るトレースバック情報を指定したり、 ‘extra’ キ
ーワード引数を使ってログに付与する追加のコンテキスト情報を指定します。)
logging パッケージは内部で % を使って format 文字列と引数をマージしてい
るので、 *note str.format(): 5ed. や *note string.Template: 653. を使っ
て logging を呼び出す事はできません。既存の logging 呼び出しは %-format
を使っているので、後方互換性のためにこの部分を変更することはできません。

しかし、{} や $ を使ってログメッセージをフォーマットする方法はあります。
ログメッセージには任意のオブジェクトを format 文字列として渡すことができ
、logging パッケージはそのオブジェクトに対して ‘str()’ を使って実際の
format 文字列を生成します。次の2つのクラスを見てください:

     class BraceMessage:
         def __init__(self, fmt, /, *args, **kwargs):
             self.fmt = fmt
             self.args = args
             self.kwargs = kwargs

         def __str__(self):
             return self.fmt.format(*self.args, **self.kwargs)

     class DollarMessage:
         def __init__(self, fmt, /, **kwargs):
             self.fmt = fmt
             self.kwargs = kwargs

         def __str__(self):
             from string import Template
             return Template(self.fmt).substitute(**self.kwargs)

どちらのクラスも format 文字列の代わりに利用して、 {} や $ を使って実際
のログの "%(message)s", "{message}", "$message" で指定された "message" 部
分を生成することができます。これは何かログを取りたいときに常に使うには使
いにくいクラス名ですが、 __ (アンダースコア2つ -- *note
gettext.gettext(): 140e. やその仲間によくエイリアスとして使われるアンダ
ースコア1つと混同しないように) などの使いやすいエイリアスを使うことがで
きます。

上のクラスは Python には含まれませんが、自分のコードにコピペして使うのは
簡単です。これらは次の例のようにして利用できます。(上のクラスが
‘wherever’ というモジュールで定義されていると仮定します):

     >>> from wherever import BraceMessage as __
     >>> print(__('Message with {0} {name}', 2, name='placeholders'))
     Message with 2 placeholders
     >>> class Point: pass
     ...
     >>> p = Point()
     >>> p.x = 0.5
     >>> p.y = 0.5
     >>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})',
     ...       point=p))
     Message with coordinates: (0.50, 0.50)
     >>> from wherever import DollarMessage as __
     >>> print(__('Message with $num $what', num=2, what='placeholders'))
     Message with 2 placeholders
     >>>

上の例ではフォーマットの動作を示すために ‘print()’ を使っていますが、も
ちろん実際にこの方法でログを出力するには ‘logger.debug()’ などを使います
。

注意点として、この方法には大きなパフォーマンスのペナルティはありません。
実際のフォーマット操作は logging の呼び出し時ではなくて、メッセージが実
際に handler によって出力されるときに起こります。(出力されないならフォー
マットもされません) そのため、この方法で注意しないといけないのは、追加の
括弧が書式文字列だけではなく引数も囲わないといけないことだけです。これは
__ が ‘XXXMessage’ クラスのコンストラクタ呼び出しのシンタックスシュガー
でしか無いからです。

次の例のように、 *note LoggerAdapter: 12c3. を利用して上と似たような効果
を実現する方法もあります:

     import logging

     class Message:
         def __init__(self, fmt, args):
             self.fmt = fmt
             self.args = args

         def __str__(self):
             return self.fmt.format(*self.args)

     class StyleAdapter(logging.LoggerAdapter):
         def log(self, level, msg, /, *args, stacklevel=1, **kwargs):
             if self.isEnabledFor(level):
                 msg, kwargs = self.process(msg, kwargs)
                 self.logger.log(level, Message(msg, args), **kwargs,
                                 stacklevel=stacklevel+1)

     logger = StyleAdapter(logging.getLogger(__name__))

     def main():
         logger.debug('Hello, {}', 'world!')

     if __name__ == '__main__':
         logging.basicConfig(level=logging.DEBUG)
         main()

上のスクリプトは Python 3.8 以降では ‘Hello, world!’ というメッセージを
ログするはずです。


File: python.info,  Node: LogRecord のカスタマイズ,  Next: Subclassing QueueHandler and QueueListener- a ZeroMQ example,  Prev: 別の format スタイルを利用する,  Up: Logging クックブック

9.8.15 ‘LogRecord’ のカスタマイズ
---------------------------------

全ての logging イベントは *note LogRecord: fb3. のインスタンスとして表現
されます。イベントのログが取られて logger のレベルでフィルタされなかった
場合、イベントの情報を含む *note LogRecord: fb3. が生成され、その logger
(と、 propagate が無効になるまでの上位 logger) の handler に渡されます。
Python 3.2 までは、この生成が行われているのは2箇所だけでした:

   * *note Logger.makeRecord(): 2c36.: 通常のイベント logging プロセスで
     呼ばれます。これは *note LogRecord: fb3. を直接読んでインスタンスを
     生成します。

   * *note makeLogRecord(): 2c5d.: LogRecord に追加される属性を含む辞書
     を渡して呼び出されます。これはネットワーク越しに (pickle 形式で
     *note SocketHandler: f2f. 経由で、あるいは JSON 形式で *note
     HTTPHandler: df8. 経由で) 辞書を受け取った場合などに利用されます。

そのために *note LogRecord: fb3. で何か特別なことをしたい場合は、次のど
ちらかをしなければなりません。

   * *note Logger.makeRecord(): 2c36. をオーバーライドした独自の *note
     Logger: b1d. のサブクラスを作り、利用したい logger のどれかがインス
     タンス化される前に、それを *note setLoggerClass(): 2c6c. を使って登
     録する。

   * *note filter(): 2c58. メソッドで必要な特殊な処理を行う *note
     Filter: 11cc. を logger か handler に追加する。

最初の方法は、複数の異なるライブラリが別々のことをしようとした場合にうま
く行きません。各ライブラリが独自の *note Logger: b1d. のサブクラスを登録
しようとして、最後に登録されたライブラリが生き残ります。

2つ目の方法はほとんどのケースでうまくいきますが、たとえば *note
LogRecord: fb3. を特殊化したサブクラスを使うことなどはできません。ライブ
ラリの開発者は利用している logger に適切な filter を設定できますが、新し
い logger を作るたびに忘れずに設定しないといけなくなります。 (新しいパッ
ケージやモジュールを追加し、モジュールレベルで次の式を実行することで、新
しい logger が作られます)

     logger = logging.getLogger(__name__)

これでは考えることが余計に1つ増えてしまうでしょう。開発者は、最も高いレ
ベルのロガーに取り付けられた *note NullHandler: 1255. に、フィルタを追加
することもできますが、アプリケーション開発者が、より低いレベルに対するラ
イブラリのロガーにハンドラを取り付けた場合、フィルタは呼び出されません
-- 従って、そのハンドラからの出力はライブラリ開発者の意図を反映したもの
にはなりません。

Python 3.2 以降では、 *note LogRecord: fb3. の生成は、指定できるファクト
リ経由になります。ファクトリは callable で、 *note
setLogRecordFactory(): 2c61. で登録でき、 *note getLogRecordFactory():
2c60. で現在のファクトリを取得できます。ファクトリは *note LogRecord:
fb3. コンストラクタと同じシグネチャで呼び出され、 *note LogRecord: fb3.
がデフォルトのファクトリとして設定されています。

このアプローチはカスタムのファクトリが LogRecord の生成のすべての面を制
御できるようにしています。たとえば、サブクラスを返したり、次のようなパタ
ーンを使って単に属性を追加することができます:

     old_factory = logging.getLogRecordFactory()

     def record_factory(*args, **kwargs):
         record = old_factory(*args, **kwargs)
         record.custom_attribute = 0xdecafbad
         return record

     logging.setLogRecordFactory(record_factory)

このアプローチでは複数の異なるライブラリがファクトリをチェインさせて、お
互いに同じ属性を上書きしたり、標準で提供されている属性を意図せず上書きし
ない限りはうまくいきます。しかし、チェインのつながり全てが、全ての
logging の操作に対しての実行時のオーバーヘッドになることを念頭に置き、こ
のテクニックは *note Filter: 11cc. を利用するだけでは望む結果が得られな
い場合にのみ使うべきです。


File: python.info,  Node: Subclassing QueueHandler and QueueListener- a ZeroMQ example,  Next: Subclassing QueueHandler and QueueListener- a pynng example,  Prev: LogRecord のカスタマイズ,  Up: Logging クックブック

9.8.16 Subclassing QueueHandler and QueueListener- a ZeroMQ example
-------------------------------------------------------------------

* Menu:

* Subclass QueueHandler::
* Subclass QueueListener::


File: python.info,  Node: Subclass QueueHandler,  Next: Subclass QueueListener,  Up: Subclassing QueueHandler and QueueListener- a ZeroMQ example

9.8.16.1 Subclass ‘QueueHandler’
................................

*note QueueHandler: 1742. のサブクラスを作ってメッセージを他のキュー、例
えば ZeroMQ の 'publish' ソケットに送信することができます。下の例では、
ソケットを別に作ってそれを handler に ('queue' として) 渡します:

     import zmq   # using pyzmq, the Python binding for ZeroMQ
     import json  # for serializing records portably

     ctx = zmq.Context()
     sock = zmq.Socket(ctx, zmq.PUB)  # or zmq.PUSH, or other suitable value
     sock.bind('tcp://*:5556')        # or wherever

     class ZeroMQSocketHandler(QueueHandler):
         def enqueue(self, record):
             self.queue.send_json(record.__dict__)


     handler = ZeroMQSocketHandler(sock)

もちろん同じことを別の設計でもできます。socket を作るのに必要な情報を
handler に渡す例です:

     class ZeroMQSocketHandler(QueueHandler):
         def __init__(self, uri, socktype=zmq.PUB, ctx=None):
             self.ctx = ctx or zmq.Context()
             socket = zmq.Socket(self.ctx, socktype)
             socket.bind(uri)
             super().__init__(socket)

         def enqueue(self, record):
             self.queue.send_json(record.__dict__)

         def close(self):
             self.queue.close()


File: python.info,  Node: Subclass QueueListener,  Prev: Subclass QueueHandler,  Up: Subclassing QueueHandler and QueueListener- a ZeroMQ example

9.8.16.2 Subclass ‘QueueListener’
.................................

*note QueueListener: df9. のサブクラスを作って、メッセージを他のキュー、
例えば ZeroMQ の 'subscribe' ソケットから取得する事もできます。サンプル
です:

     class ZeroMQSocketListener(QueueListener):
         def __init__(self, uri, /, *handlers, **kwargs):
             self.ctx = kwargs.get('ctx') or zmq.Context()
             socket = zmq.Socket(self.ctx, zmq.SUB)
             socket.setsockopt_string(zmq.SUBSCRIBE, '')  # subscribe to everything
             socket.connect(uri)
             super().__init__(socket, *handlers, **kwargs)

         def dequeue(self):
             msg = self.queue.recv_json()
             return logging.makeLogRecord(msg)


File: python.info,  Node: Subclassing QueueHandler and QueueListener- a pynng example,  Next: 辞書ベースで構成する例,  Prev: Subclassing QueueHandler and QueueListener- a ZeroMQ example,  Up: Logging クックブック

9.8.17 Subclassing QueueHandler and QueueListener- a ‘pynng’ example
--------------------------------------------------------------------

In a similar way to the above section, we can implement a listener and
handler using pynng(1), which is a Python binding to NNG(2), billed as a
spiritual successor to ZeroMQ. The following snippets illustrate - you
can test them in an environment which has ‘pynng’ installed.  Just for
variety, we present the listener first.

* Menu:

* Subclass QueueListener: Subclass QueueListener<2>.
* Subclass QueueHandler: Subclass QueueHandler<2>.

   ---------- Footnotes ----------

   (1) https://pypi.org/project/pynng/

   (2) https://nng.nanomsg.org/


File: python.info,  Node: Subclass QueueListener<2>,  Next: Subclass QueueHandler<2>,  Up: Subclassing QueueHandler and QueueListener- a pynng example

9.8.17.1 Subclass ‘QueueListener’
.................................

     # listener.py
     import json
     import logging
     import logging.handlers

     import pynng

     DEFAULT_ADDR = "tcp://localhost:13232"

     interrupted = False

     class NNGSocketListener(logging.handlers.QueueListener):

         def __init__(self, uri, /, *handlers, **kwargs):
             # Have a timeout for interruptability, and open a
             # subscriber socket
             socket = pynng.Sub0(listen=uri, recv_timeout=500)
             # The b'' subscription matches all topics
             topics = kwargs.pop('topics', None) or b''
             socket.subscribe(topics)
             # We treat the socket as a queue
             super().__init__(socket, *handlers, **kwargs)

         def dequeue(self, block):
             data = None
             # Keep looping while not interrupted and no data received over the
             # socket
             while not interrupted:
                 try:
                     data = self.queue.recv(block=block)
                     break
                 except pynng.Timeout:
                     pass
                 except pynng.Closed:  # sometimes happens when you hit Ctrl-C
                     break
             if data is None:
                 return None
             # Get the logging event sent from a publisher
             event = json.loads(data.decode('utf-8'))
             return logging.makeLogRecord(event)

         def enqueue_sentinel(self):
             # Not used in this implementation, as the socket isn't really a
             # queue
             pass

     logging.getLogger('pynng').propagate = False
     listener = NNGSocketListener(DEFAULT_ADDR, logging.StreamHandler(), topics=b'')
     listener.start()
     print('Press Ctrl-C to stop.')
     try:
         while True:
             pass
     except KeyboardInterrupt:
         interrupted = True
     finally:
         listener.stop()


File: python.info,  Node: Subclass QueueHandler<2>,  Prev: Subclass QueueListener<2>,  Up: Subclassing QueueHandler and QueueListener- a pynng example

9.8.17.2 Subclass ‘QueueHandler’
................................

     # sender.py
     import json
     import logging
     import logging.handlers
     import time
     import random

     import pynng

     DEFAULT_ADDR = "tcp://localhost:13232"

     class NNGSocketHandler(logging.handlers.QueueHandler):

         def __init__(self, uri):
             socket = pynng.Pub0(dial=uri, send_timeout=500)
             super().__init__(socket)

         def enqueue(self, record):
             # Send the record as UTF-8 encoded JSON
             d = dict(record.__dict__)
             data = json.dumps(d)
             self.queue.send(data.encode('utf-8'))

         def close(self):
             self.queue.close()

     logging.getLogger('pynng').propagate = False
     handler = NNGSocketHandler(DEFAULT_ADDR)
     # Make sure the process ID is in the output
     logging.basicConfig(level=logging.DEBUG,
                         handlers=[logging.StreamHandler(), handler],
                         format='%(levelname)-8s %(name)10s %(process)6s %(message)s')
     levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,
               logging.CRITICAL)
     logger_names = ('myapp', 'myapp.lib1', 'myapp.lib2')
     msgno = 1
     while True:
         # Just randomly select some loggers and levels and log away
         level = random.choice(levels)
         logger = logging.getLogger(random.choice(logger_names))
         logger.log(level, 'Message no. %5d' % msgno)
         msgno += 1
         delay = random.random() * 2 + 0.5
         time.sleep(delay)

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:

     $ python sender.py
     DEBUG         myapp    613 Message no.     1
     WARNING  myapp.lib2    613 Message no.     2
     CRITICAL myapp.lib2    613 Message no.     3
     WARNING  myapp.lib2    613 Message no.     4
     CRITICAL myapp.lib1    613 Message no.     5
     DEBUG         myapp    613 Message no.     6
     CRITICAL myapp.lib1    613 Message no.     7
     INFO     myapp.lib1    613 Message no.     8
     (and so on)

In the second sender shell:

     $ python sender.py
     INFO     myapp.lib2    657 Message no.     1
     CRITICAL myapp.lib2    657 Message no.     2
     CRITICAL      myapp    657 Message no.     3
     CRITICAL myapp.lib1    657 Message no.     4
     INFO     myapp.lib1    657 Message no.     5
     WARNING  myapp.lib2    657 Message no.     6
     CRITICAL      myapp    657 Message no.     7
     DEBUG    myapp.lib1    657 Message no.     8
     (and so on)

In the listener shell:

     $ python listener.py
     Press Ctrl-C to stop.
     DEBUG         myapp    613 Message no.     1
     WARNING  myapp.lib2    613 Message no.     2
     INFO     myapp.lib2    657 Message no.     1
     CRITICAL myapp.lib2    613 Message no.     3
     CRITICAL myapp.lib2    657 Message no.     2
     CRITICAL      myapp    657 Message no.     3
     WARNING  myapp.lib2    613 Message no.     4
     CRITICAL myapp.lib1    613 Message no.     5
     CRITICAL myapp.lib1    657 Message no.     4
     INFO     myapp.lib1    657 Message no.     5
     DEBUG         myapp    613 Message no.     6
     WARNING  myapp.lib2    657 Message no.     6
     CRITICAL      myapp    657 Message no.     7
     CRITICAL myapp.lib1    613 Message no.     7
     INFO     myapp.lib1    613 Message no.     8
     DEBUG    myapp.lib1    657 Message no.     8
     (and so on)

As you can see, the logging from the two sender processes is interleaved
in the listener's output.


File: python.info,  Node: 辞書ベースで構成する例,  Next: rotator と namer を使ってログローテートをカスタマイズする,  Prev: Subclassing QueueHandler and QueueListener- a pynng example,  Up: Logging クックブック

9.8.18 辞書ベースで構成する例
-----------------------------

次の例は辞書を使った logging の構成です。この例は Django プロジェクトの
ドキュメント(1) から持ってきました。この辞書を *note dictConfig(): 1180.
に渡して設定を有効にします:

     LOGGING = {
         'version': 1,
         'disable_existing_loggers': False,
         'formatters': {
             'verbose': {
                 'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
                 'style': '{',
             },
             'simple': {
                 'format': '{levelname} {message}',
                 'style': '{',
             },
         },
         'filters': {
             'special': {
                 '()': 'project.logging.SpecialFilter',
                 'foo': 'bar',
             },
         },
         'handlers': {
             'console': {
                 'level': 'INFO',
                 'class': 'logging.StreamHandler',
                 'formatter': 'simple',
             },
             'mail_admins': {
                 'level': 'ERROR',
                 'class': 'django.utils.log.AdminEmailHandler',
                 'filters': ['special']
             }
         },
         'loggers': {
             'django': {
                 'handlers': ['console'],
                 'propagate': True,
             },
             'django.request': {
                 'handlers': ['mail_admins'],
                 'level': 'ERROR',
                 'propagate': False,
             },
             'myproject.custom': {
                 'handlers': ['console', 'mail_admins'],
                 'level': 'INFO',
                 'filters': ['special']
             }
         }
     }

この構成方法についてのより詳しい情報は、 Django のドキュメントの 該当の
セクション(2) で見ることができます。

   ---------- Footnotes ----------

   (1) 
https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging

   (2) 
https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging


File: python.info,  Node: rotator と namer を使ってログローテートをカスタマイズする,  Next: より手の込んだ multiprocessing の例,  Prev: 辞書ベースで構成する例,  Up: Logging クックブック

9.8.19 rotator と namer を使ってログローテートをカスタマイズする
----------------------------------------------------------------

namer と rotator を定義する方法の例は以下の実行可能なスクリプトに示され
ています。ここではログファイルを gzip により圧縮する例を示しています:

     import gzip
     import logging
     import logging.handlers
     import os
     import shutil

     def namer(name):
         return name + ".gz"

     def rotator(source, dest):
         with open(source, 'rb') as f_in:
             with gzip.open(dest, 'wb') as f_out:
                 shutil.copyfileobj(f_in, f_out)
         os.remove(source)


     rh = logging.handlers.RotatingFileHandler('rotated.log', maxBytes=128, backupCount=5)
     rh.rotator = rotator
     rh.namer = namer

     root = logging.getLogger()
     root.setLevel(logging.INFO)
     root.addHandler(rh)
     f = logging.Formatter('%(asctime)s %(message)s')
     rh.setFormatter(f)
     for i in range(1000):
         root.info(f'Message no. {i + 1}')

このスクリプトを実行すると、6つの新しいファイルが生成され、そのうち5つは
圧縮されています:

     $ ls rotated.log*
     rotated.log       rotated.log.2.gz  rotated.log.4.gz
     rotated.log.1.gz  rotated.log.3.gz  rotated.log.5.gz
     $ zcat rotated.log.1.gz
     2023-01-20 02:28:17,767 Message no. 996
     2023-01-20 02:28:17,767 Message no. 997
     2023-01-20 02:28:17,767 Message no. 998


File: python.info,  Node: より手の込んだ multiprocessing の例,  Next: SysLogHandler に送るメッセージに BOM を挿入する,  Prev: rotator と namer を使ってログローテートをカスタマイズする,  Up: Logging クックブック

9.8.20 より手の込んだ multiprocessing の例
------------------------------------------

次の実際に動作する例は、logging を multiprocessing と設定ファイルを使っ
て利用する方法を示しています。設定内容はかなりシンプルですが、より複雑な
構成を実際の multiprocessing を利用するシナリオで実装する方法を示してい
ます。

この例では、メインプロセスは listener プロセスといくつかのワーカープロセ
スを起動します。メイン、listener、ワーカープロセスはそれぞれ分離した設定
を持っています (ワーカープロセス群は同じ設定を共有します)。この例から、
メインプロセスの logging, ワーカーが QueueHandler でログを送っているとこ
ろ、listener が利用する QueueListener の実装、複雑な設定、キューから受け
取ったイベントを設定された handler に分配する部分を見ることができます。
この設定は説明用のものですが、この例を自分のシナリオに適応させることがで
きるでしょう。

これがそのスクリプトです。docstring とコメントで動作を説明しています:

     import logging
     import logging.config
     import logging.handlers
     from multiprocessing import Process, Queue, Event, current_process
     import os
     import random
     import time

     class MyHandler:
         """
         A simple handler for logging events. It runs in the listener process and
         dispatches events to loggers based on the name in the received record,
         which then get dispatched, by the logging system, to the handlers
         configured for those loggers.
         """

         def handle(self, record):
             if record.name == "root":
                 logger = logging.getLogger()
             else:
                 logger = logging.getLogger(record.name)

             if logger.isEnabledFor(record.levelno):
                 # The process name is transformed just to show that it's the listener
                 # doing the logging to files and console
                 record.processName = '%s (for %s)' % (current_process().name, record.processName)
                 logger.handle(record)

     def listener_process(q, stop_event, config):
         """
         This could be done in the main process, but is just done in a separate
         process for illustrative purposes.

         This initialises logging according to the specified configuration,
         starts the listener and waits for the main process to signal completion
         via the event. The listener is then stopped, and the process exits.
         """
         logging.config.dictConfig(config)
         listener = logging.handlers.QueueListener(q, MyHandler())
         listener.start()
         if os.name == 'posix':
             # On POSIX, the setup logger will have been configured in the
             # parent process, but should have been disabled following the
             # dictConfig call.
             # On Windows, since fork isn't used, the setup logger won't
             # exist in the child, so it would be created and the message
             # would appear - hence the "if posix" clause.
             logger = logging.getLogger('setup')
             logger.critical('Should not appear, because of disabled logger ...')
         stop_event.wait()
         listener.stop()

     def worker_process(config):
         """
         A number of these are spawned for the purpose of illustration. In
         practice, they could be a heterogeneous bunch of processes rather than
         ones which are identical to each other.

         This initialises logging according to the specified configuration,
         and logs a hundred messages with random levels to randomly selected
         loggers.

         A small sleep is added to allow other processes a chance to run. This
         is not strictly needed, but it mixes the output from the different
         processes a bit more than if it's left out.
         """
         logging.config.dictConfig(config)
         levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,
                   logging.CRITICAL]
         loggers = ['foo', 'foo.bar', 'foo.bar.baz',
                    'spam', 'spam.ham', 'spam.ham.eggs']
         if os.name == 'posix':
             # On POSIX, the setup logger will have been configured in the
             # parent process, but should have been disabled following the
             # dictConfig call.
             # On Windows, since fork isn't used, the setup logger won't
             # exist in the child, so it would be created and the message
             # would appear - hence the "if posix" clause.
             logger = logging.getLogger('setup')
             logger.critical('Should not appear, because of disabled logger ...')
         for i in range(100):
             lvl = random.choice(levels)
             logger = logging.getLogger(random.choice(loggers))
             logger.log(lvl, 'Message no. %d', i)
             time.sleep(0.01)

     def main():
         q = Queue()
         # The main process gets a simple configuration which prints to the console.
         config_initial = {
             'version': 1,
             'handlers': {
                 'console': {
                     'class': 'logging.StreamHandler',
                     'level': 'INFO'
                 }
             },
             'root': {
                 'handlers': ['console'],
                 'level': 'DEBUG'
             }
         }
         # The worker process configuration is just a QueueHandler attached to the
         # root logger, which allows all messages to be sent to the queue.
         # We disable existing loggers to disable the "setup" logger used in the
         # parent process. This is needed on POSIX because the logger will
         # be there in the child following a fork().
         config_worker = {
             'version': 1,
             'disable_existing_loggers': True,
             'handlers': {
                 'queue': {
                     'class': 'logging.handlers.QueueHandler',
                     'queue': q
                 }
             },
             'root': {
                 'handlers': ['queue'],
                 'level': 'DEBUG'
             }
         }
         # The listener process configuration shows that the full flexibility of
         # logging configuration is available to dispatch events to handlers however
         # you want.
         # We disable existing loggers to disable the "setup" logger used in the
         # parent process. This is needed on POSIX because the logger will
         # be there in the child following a fork().
         config_listener = {
             'version': 1,
             'disable_existing_loggers': True,
             'formatters': {
                 'detailed': {
                     'class': 'logging.Formatter',
                     'format': '%(asctime)s %(name)-15s %(levelname)-8s %(processName)-10s %(message)s'
                 },
                 'simple': {
                     'class': 'logging.Formatter',
                     'format': '%(name)-15s %(levelname)-8s %(processName)-10s %(message)s'
                 }
             },
             'handlers': {
                 'console': {
                     'class': 'logging.StreamHandler',
                     'formatter': 'simple',
                     'level': 'INFO'
                 },
                 'file': {
                     'class': 'logging.FileHandler',
                     'filename': 'mplog.log',
                     'mode': 'w',
                     'formatter': 'detailed'
                 },
                 'foofile': {
                     'class': 'logging.FileHandler',
                     'filename': 'mplog-foo.log',
                     'mode': 'w',
                     'formatter': 'detailed'
                 },
                 'errors': {
                     'class': 'logging.FileHandler',
                     'filename': 'mplog-errors.log',
                     'mode': 'w',
                     'formatter': 'detailed',
                     'level': 'ERROR'
                 }
             },
             'loggers': {
                 'foo': {
                     'handlers': ['foofile']
                 }
             },
             'root': {
                 'handlers': ['console', 'file', 'errors'],
                 'level': 'DEBUG'
             }
         }
         # Log some initial events, just to show that logging in the parent works
         # normally.
         logging.config.dictConfig(config_initial)
         logger = logging.getLogger('setup')
         logger.info('About to create workers ...')
         workers = []
         for i in range(5):
             wp = Process(target=worker_process, name='worker %d' % (i + 1),
                          args=(config_worker,))
             workers.append(wp)
             wp.start()
             logger.info('Started worker: %s', wp.name)
         logger.info('About to create listener ...')
         stop_event = Event()
         lp = Process(target=listener_process, name='listener',
                      args=(q, stop_event, config_listener))
         lp.start()
         logger.info('Started listener')
         # We now hang around for the workers to finish their work.
         for wp in workers:
             wp.join()
         # Workers all done, listening can now stop.
         # Logging in the parent still works normally.
         logger.info('Telling listener to stop ...')
         stop_event.set()
         lp.join()
         logger.info('All done.')

     if __name__ == '__main__':
         main()


File: python.info,  Node: SysLogHandler に送るメッセージに BOM を挿入する,  Next: 構造化ログを実装する,  Prev: より手の込んだ multiprocessing の例,  Up: Logging クックブック

9.8.21 SysLogHandler に送るメッセージに BOM を挿入する
------------------------------------------------------

RFC 5424(1) は syslog デーモンに Unicode メッセージを送る時、次の構造を
要求しています: オプショナルなピュア ASCII部分、続けて UTF-8 の Byte
Order Mark (BOM)、続けて UTF-8 でエンコードされた Unicode.  ( 仕様の該当
セクション(2) を参照)

Python 3.1 で *note SysLogHandler: 628. に、 message に BOM を挿入するコ
ードが追加されました。しかし、そのときの実装が悪くて、 message の先頭に
BOM をつけてしまうのでピュアASCII 部分をその前に書くことができませんでし
た。

この動作は壊れているので、Python 3.2.4 以降では BOM を挿入するコードが、
削除されました。書き直されるのではなく削除されたので、 RFC 5424(3) 準拠
の、BOM と、オプションのピュア ASCII部分をBOMの前に、任意の Unicode を
BOM の後ろに持つ UTF-8 でエンコードされた message を生成したい場合、次の
手順に従う必要があります:

  1. *note SysLogHandler: 628. のインスタンスに、次のような format 文字
     列を持った *note Formatter: 143a. インスタンスをアタッチする:

          'ASCII section\ufeffUnicode section'

     Unicode のコードポイント U+FEFF は、UTF-8 でエンコードすると BOM -
     ‘b'\xef\xbb\xbf'’ - になります。

  2. ASCII セクションを好きなプレースホルダに変更する。ただしその部分の
     置換結果が常に ASCII になるように注意する(UTF-8 でエンコードされて
     もその部分が変化しないようにする)。

  3. Unicode セクションを任意のプレースホルダに置き換える。この部分を置
     換したデータに ASCII 外の文字が含まれていても、それは単に UTF-8 で
     エンコードされるだけです。

フォーマットされた message は ‘SysLogHandler’ によって UTF-8 でエンコー
ドされます。上のルールに従えば、RFC 5424 準拠のメッセージを生成できます
。上のルールに従わない場合、logging は何もエラーを起こしませんが、
message は RFC 5424(4) に準拠しない形で送られるので、syslog デーモン側で
何かエラーが起こる可能性があります。

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5424.html

   (2) https://datatracker.ietf.org/doc/html/rfc5424.html#section-6

   (3) https://datatracker.ietf.org/doc/html/rfc5424.html

   (4) https://datatracker.ietf.org/doc/html/rfc5424.html


File: python.info,  Node: 構造化ログを実装する,  Next: handler を dictConfig を使ってカスタマイズする,  Prev: SysLogHandler に送るメッセージに BOM を挿入する,  Up: Logging クックブック

9.8.22 構造化ログを実装する
---------------------------

多くのログメッセージは人間が読むために書かれるため、機械的に処理しにくく
なっていますが、場合によっては (複雑な正規表現を使ってログメッセージをパ
ースしなくても) プログラムがパース 'できる' 構造化されたフォーマットでメ
ッセージを出力したい場合があります。 logging パッケージを使うと、これを
簡単に実現できます。 実現する方法は幾つもありますが、次の例は JSON を使
ってイベントを、機械でパースできる形にシリアライズする単純な方法です:

     import json
     import logging

     class StructuredMessage:
         def __init__(self, message, /, **kwargs):
             self.message = message
             self.kwargs = kwargs

         def __str__(self):
             return '%s >>> %s' % (self.message, json.dumps(self.kwargs))

     _ = StructuredMessage   # optional, to improve readability

     logging.basicConfig(level=logging.INFO, format='%(message)s')
     logging.info(_('message 1', foo='bar', bar='baz', num=123, fnum=123.456))

上のスクリプトを実行すると次のように出力されます:

     message 1 >>> {"fnum": 123.456, "num": 123, "bar": "baz", "foo": "bar"}

要素の順序は Python のバージョンによって異なることに注意してください。

より特殊な処理が必要な場合、次の例のように、カスタムの JSON エンコーダを
作ることができます:

     import json
     import logging


     class Encoder(json.JSONEncoder):
         def default(self, o):
             if isinstance(o, set):
                 return tuple(o)
             elif isinstance(o, str):
                 return o.encode('unicode_escape').decode('ascii')
             return super().default(o)

     class StructuredMessage:
         def __init__(self, message, /, **kwargs):
             self.message = message
             self.kwargs = kwargs

         def __str__(self):
             s = Encoder().encode(self.kwargs)
             return '%s >>> %s' % (self.message, s)

     _ = StructuredMessage   # optional, to improve readability

     def main():
         logging.basicConfig(level=logging.INFO, format='%(message)s')
         logging.info(_('message 1', set_value={1, 2, 3}, snowman='\u2603'))

     if __name__ == '__main__':
         main()

上のスクリプトを実行すると次のように出力されます:

     message 1 >>> {"snowman": "\u2603", "set_value": [1, 2, 3]}

要素の順序は Python のバージョンによって異なることに注意してください。


File: python.info,  Node: handler を dictConfig を使ってカスタマイズする,  Next: 固有の書式化スタイルをアプリケーション全体で使う,  Prev: 構造化ログを実装する,  Up: Logging クックブック

9.8.23 handler を ‘dictConfig()’ を使ってカスタマイズする
---------------------------------------------------------

logging handler に特定のカスタマイズを何度もしたい場合で、 *note
dictConfig(): 1180. を使っているなら、サブクラスを作らなくてもカスタマイ
ズが可能です。例えば、ログファイルの owner を設定したいとします。これは
POSIX 環境では *note shutil.chown(): 221. を使って簡単に実現できますが、
標準ライブラリの file handler はこの機能を組み込みでサポートしていません
。 handler の生成を通常の関数を使ってカスタマイズすることができます:

     def owned_file_handler(filename, mode='a', encoding=None, owner=None):
         if owner:
             if not os.path.exists(filename):
                 open(filename, 'a').close()
             shutil.chown(filename, *owner)
         return logging.FileHandler(filename, mode, encoding)

そして、 *note dictConfig(): 1180. に渡される構成設定の中で、この関数を
使って logging handler を生成するように指定することができます:

     LOGGING = {
         'version': 1,
         'disable_existing_loggers': False,
         'formatters': {
             'default': {
                 'format': '%(asctime)s %(levelname)s %(name)s %(message)s'
             },
         },
         'handlers': {
             'file':{
                 # The values below are popped from this dictionary and
                 # used to create the handler, set the handler's level and
                 # its formatter.
                 '()': owned_file_handler,
                 'level':'DEBUG',
                 'formatter': 'default',
                 # The values below are passed to the handler creator callable
                 # as keyword arguments.
                 'owner': ['pulse', 'pulse'],
                 'filename': 'chowntest.log',
                 'mode': 'w',
                 'encoding': 'utf-8',
             },
         },
         'root': {
             'handlers': ['file'],
             'level': 'DEBUG',
         },
     }

この例は説明用のものですが、owner の user と group を ‘pulse’ に設定して
います。これを動くスクリプトに ‘chowntest.py’ に組み込んでみます:

     import logging, logging.config, os, shutil

     def owned_file_handler(filename, mode='a', encoding=None, owner=None):
         if owner:
             if not os.path.exists(filename):
                 open(filename, 'a').close()
             shutil.chown(filename, *owner)
         return logging.FileHandler(filename, mode, encoding)

     LOGGING = {
         'version': 1,
         'disable_existing_loggers': False,
         'formatters': {
             'default': {
                 'format': '%(asctime)s %(levelname)s %(name)s %(message)s'
             },
         },
         'handlers': {
             'file':{
                 # The values below are popped from this dictionary and
                 # used to create the handler, set the handler's level and
                 # its formatter.
                 '()': owned_file_handler,
                 'level':'DEBUG',
                 'formatter': 'default',
                 # The values below are passed to the handler creator callable
                 # as keyword arguments.
                 'owner': ['pulse', 'pulse'],
                 'filename': 'chowntest.log',
                 'mode': 'w',
                 'encoding': 'utf-8',
             },
         },
         'root': {
             'handlers': ['file'],
             'level': 'DEBUG',
         },
     }

     logging.config.dictConfig(LOGGING)
     logger = logging.getLogger('mylogger')
     logger.debug('A debug message')

これを実行するには、 ‘root’ 権限で実行する必要があるかもしれません:

     $ sudo python3.3 chowntest.py
     $ cat chowntest.log
     2013-11-05 09:34:51,128 DEBUG mylogger A debug message
     $ ls -l chowntest.log
     -rw-r--r-- 1 pulse pulse 55 2013-11-05 09:34 chowntest.log

*note shutil.chown(): 221. が追加されたのが Python 3.3 からなので、この
例は Python 3.3 を使っています。このアプローチ自体は *note dictConfig():
1180. をサポートした全ての Python バージョン - Python 2.7, 3.2 以降 - で
利用できます。 3.3 以前のバージョンでは、オーナーを変更するのに *note
os.chown(): 10bf. を利用する必要があるでしょう。

実際には、handler を生成する関数はプロジェクト内のどこかにあるユーティリ
ティモジュールに置くことになるでしょう。設定の中で直接関数を参照する代わ
りに:

     '()': owned_file_handler,

次のように書くこともできます:

     '()': 'ext://project.util.owned_file_handler',

‘project.util’ は関数がある実際の場所に置き換えてください。上のスクリプ
トでは ‘'ext://__main__.owned_file_handler'’ で動くはずです。 *note
dictConfig(): 1180. は ‘ext://’ から実際の callable を見つけます。

この例は他のファイルに対する変更を実装する例にもなっています。例えば
*note os.chmod(): 1fc. を使って、同じ方法で POSIX パーミッションを設定で
きるでしょう。

もちろん、このアプローチは *note FileHandler: 1809. 以外の handler 、ロ
ーテートする file handler のいずれかやその他の handler にも適用できます
。


File: python.info,  Node: 固有の書式化スタイルをアプリケーション全体で使う,  Next: filter を dictConfig を使ってカスタマイズする,  Prev: handler を dictConfig を使ってカスタマイズする,  Up: Logging クックブック

9.8.24 固有の書式化スタイルをアプリケーション全体で使う
-------------------------------------------------------

Python 3.2 では、*note Formatter: 143a. クラスが ‘style’ という名前のオ
プションのキーワード引数を受け取ります。このデフォルト値は後方互換性を維
持するために ‘%’ となっていますが、 ‘{’ か ‘$’ を指定することで、*note
str.format(): 5ed. か *note string.Template: 653. でサポートされているの
と同じ書式化のアプローチを採れます。これは最終的に出力されるログメッセー
ジの書式化に影響を与えますが、個々のログメッセージが構築される方法とは完
全に直交していることに注意してください。

ロギングの呼び出し (*note debug(): df7, *note info(): 1c5c. など) はログ
メッセージのためには位置引数しか取らず、ロギングの呼び出しを処理する方法
を決定するためだけにキーワード引数を指定できます (たとえば ‘exc_info’ キ
ーワード引数はトレースバックの情報をログに含めるかどうかを指定し、
‘extra’ キーワード引数はログに付加する追加のコンテキスト情報を指定します
)。ロギングパッケージは内部で %-format を使って書式文字列に可変長引数を
埋め込んでいるため、 *note str.format(): 5ed. や *note string.Template:
653. の構文を使って直接ロギングの呼び出しを行うことはできません。既存の
コードにおける全てのロギングの呼び出しは %-format 文字列を使っているため
、後方互換性を維持する限りこの部分が変更されることはないでしょう。

特定のロガーに関連付ける書式スタイルへの提案がなされてきましたが、そのア
プローチは同時に後方互換性の問題にぶち当たります。あらゆる既存のコードは
ロガーの名前を使っているでしょうし、 % 形式書式化を使っているでしょう。

あらゆるサードパーティのライブラリ、あらゆるあなたのコードの間で相互運用
可能なようにロギングを行うには、書式化についての決定は、個々のログ呼び出
しのレベルで行う必要があります。これは受け容れ可能な代替書式化スタイルに
様々な手段の可能性を広げます。

* Menu:

* LogRecord ファクトリを使う::
* カスタムなメッセージオブジェクトを使う::


File: python.info,  Node: LogRecord ファクトリを使う,  Next: カスタムなメッセージオブジェクトを使う,  Up: 固有の書式化スタイルをアプリケーション全体で使う

9.8.24.1 LogRecord ファクトリを使う
...................................

Python 3.2 において、上述した *note Formatter: 143a. の変更とともに、
*note setLogRecordFactory(): 2c61. 関数を使って *note LogRecord: fb3. の
サブクラスをユーザに指定することを可能にするロギングパッケージの機能拡張
がありました。これにより、 *note getMessage(): 2c5f. をオーバライドして
た　だ　し　い　ことをする、あなた自身の手による *note LogRecord: fb3. の
サブクラスをセットすることが出来ます。このメソッドの実装は基底クラスでは
‘msg % args’ 書式化をし、あなたの代替の書式化の置換が出来る場所ですが、
他のコードとの相互運用性を保障するために、全ての書式化スタイルをサポート
するよう注意深く行うべきであり、また、%-書式化をデフォルトで認めるべきで
す。基底クラスの実装がそうしているように、 ‘str(self.msg)’ 呼び出しもし
てください。

さらに詳しい情報は、リファレンスの *note setLogRecordFactory(): 2c61,
*note LogRecord: fb3. を参照してください。


File: python.info,  Node: カスタムなメッセージオブジェクトを使う,  Prev: LogRecord ファクトリを使う,  Up: 固有の書式化スタイルをアプリケーション全体で使う

9.8.24.2 カスタムなメッセージオブジェクトを使う
...............................................

あなた独自のログメッセージを構築するのに {}- および $- 書式化を使えるよ
うにするための、もうひとつの、おそらくもっと簡単な方法があります。ロギン
グの際には、あなたはメッセージ書式文字列として、任意のオブジェクトを使え
ることを(*note 任意のオブジェクトをメッセージに使用する: 2c5e. より)思い
出してみましょう、そしてロギングパッケージはそのオブジェクトに対して実際
の書式文字列を得るために *note str(): 418. を呼び出すことも。以下 2 つの
クラスを検討してみましょう:

     class BraceMessage:
         def __init__(self, fmt, /, *args, **kwargs):
             self.fmt = fmt
             self.args = args
             self.kwargs = kwargs

         def __str__(self):
             return self.fmt.format(*self.args, **self.kwargs)

     class DollarMessage:
         def __init__(self, fmt, /, **kwargs):
             self.fmt = fmt
             self.kwargs = kwargs

         def __str__(self):
             from string import Template
             return Template(self.fmt).substitute(**self.kwargs)

どちらのクラスも format 文字列の代わりに利用して、 {} や $ を使って実際
のログの “%(message)s”, “{message}”, “$message” で指定された "message" 部
分を生成することができます。これは何かログを取りたいときに常に使うには使
いにくいクラス名ですが、使いやすいようにエイリアスを作れば良いでしょう、
‘M’ であるとか ‘_’ のような(あるいは地域化のために既に ‘_’ を使っている
のであれば ‘__’ が良いかもしれません)。

このアプローチによる例をお見せします。最初は *note str.format(): 5ed. を
使ってフォーマットする例です:

     >>> __ = BraceMessage
     >>> print(__('Message with {0} {1}', 2, 'placeholders'))
     Message with 2 placeholders
     >>> class Point: pass
     ...
     >>> p = Point()
     >>> p.x = 0.5
     >>> p.y = 0.5
     >>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})', point=p))
     Message with coordinates: (0.50, 0.50)

2つめは *note string.Template: 653. でフォーマットする例です:

     >>> __ = DollarMessage
     >>> print(__('Message with $num $what', num=2, what='placeholders'))
     Message with 2 placeholders
     >>>

注意点として、この方法には大きなパフォーマンスのペナルティはありません。
実際のフォーマット操作は logging の呼び出し時ではなくて、メッセージが実
際に handler によって出力されるときに起こります。(出力されないならフォー
マットもされません) そのため、この方法で注意しないといけないのは、追加の
括弧が書式文字列だけではなく引数も囲わないといけないことだけです。これは
上記のとおり __ が ‘XXXMessage’ クラスのコンストラクタ呼び出しのシンタッ
クスシュガーでしか無いからです。


File: python.info,  Node: filter を dictConfig を使ってカスタマイズする,  Next: 例外の書式化をカスタマイズする,  Prev: 固有の書式化スタイルをアプリケーション全体で使う,  Up: Logging クックブック

9.8.25 filter を ‘dictConfig()’ を使ってカスタマイズする
--------------------------------------------------------

*note dictConfig(): 1180. によってフィルタを設定 '出来ます' が、どうやっ
てそれを行うのかが初見では明快とは言えないでしょう(そのためのこのレシピ
です)。 *note Filter: 11cc. のみが唯一標準ライブラリに含まれているだけで
すし、それは何の要求にも応えてはくれません(ただの基底クラスですから)ので
、典型的には *note filter(): 2c58. メソッドをオーバライドした *note
Filter: 11cc. のサブクラスをあなた自身で定義する必要があります。これをす
るには、設定辞書内のフィルタ指定部分に、 ‘()’ キーでそのフィルタを作るの
に使われる callable を指定してください(クラスを指定するのが最もわかりや
すいですが、 *note Filter: 11cc. インスタンスを返却する callable を提供
することでも出来ます)。以下に完全な例を示します:

     import logging
     import logging.config
     import sys

     class MyFilter(logging.Filter):
         def __init__(self, param=None):
             self.param = param

         def filter(self, record):
             if self.param is None:
                 allow = True
             else:
                 allow = self.param not in record.msg
             if allow:
                 record.msg = 'changed: ' + record.msg
             return allow

     LOGGING = {
         'version': 1,
         'filters': {
             'myfilter': {
                 '()': MyFilter,
                 'param': 'noshow',
             }
         },
         'handlers': {
             'console': {
                 'class': 'logging.StreamHandler',
                 'filters': ['myfilter']
             }
         },
         'root': {
             'level': 'DEBUG',
             'handlers': ['console']
         },
     }

     if __name__ == '__main__':
         logging.config.dictConfig(LOGGING)
         logging.debug('hello')
         logging.debug('hello - noshow')

どのようにして設定データとして、そのインスタンスを構築する callable をキ
ーワードパラメータの形で渡すのか、をこの例は教えてくれます。上記スクリプ
トは実行すると、このような出力をします:

     changed: hello

設定した通りに動いていますね。

ほかにもいくつか特筆すべき点があります:

   * 設定内で直接その callable を参照出来ない場合(例えばそれが異なるモジ
     ュール内にあり、設定辞書のある場所からそれを直接インポート出来ない
     、など)には、 *note 外部オブジェクトへのアクセス: 2c8c. に記述され
     ている ‘ext://...’ 形式を使えます。例えば、上記例のように
     ‘MyFilter’ と指定する代わりに、 ‘'ext://__main__.MyFilter'’ と記述
     することが出来ます。

   * フィルタについてとともに、このテクニックは、カスタムハンドラ、カス
     タムフォーマッタに対しても同様に使えます。ロギングが設定において、
     どのようにユーザ定義のオブジェクトをサポートするのかについてのさら
     なる詳細については、 *note ユーザ定義オブジェクト: 2c80. と、本クッ
     クブックの上の方のレシピ *note handler を dictConfig()
     を使ってカスタマイズする: 4ded. を参照してください。


File: python.info,  Node: 例外の書式化をカスタマイズする,  Next: ロギングメッセージを喋る,  Prev: filter を dictConfig を使ってカスタマイズする,  Up: Logging クックブック

9.8.26 例外の書式化をカスタマイズする
-------------------------------------

例外の書式化をカスタマイズしたいことがあるでしょう - わかりやすさのため
に、例外情報がある場合でもログイベントごとに一行に収まることを死守したい
と望むとしましょう。フォーマッタのクラスをカスタマイズして、このように出
来ます:

     import logging

     class OneLineExceptionFormatter(logging.Formatter):
         def formatException(self, exc_info):
             """
             Format an exception so that it prints on a single line.
             """
             result = super().formatException(exc_info)
             return repr(result)  # or format into one line however you want to

         def format(self, record):
             s = super().format(record)
             if record.exc_text:
                 s = s.replace('\n', '') + '|'
             return s

     def configure_logging():
         fh = logging.FileHandler('output.txt', 'w')
         f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',
                                       '%d/%m/%Y %H:%M:%S')
         fh.setFormatter(f)
         root = logging.getLogger()
         root.setLevel(logging.DEBUG)
         root.addHandler(fh)

     def main():
         configure_logging()
         logging.info('Sample message')
         try:
             x = 1 / 0
         except ZeroDivisionError as e:
             logging.exception('ZeroDivisionError: %s', e)

     if __name__ == '__main__':
         main()

実行してみましょう。このように正確に2行の出力を生成します:

     28/01/2015 07:21:23|INFO|Sample message|
     28/01/2015 07:21:23|ERROR|ZeroDivisionError: integer division or modulo by zero|'Traceback (most recent call last):\n  File "logtest7.py", line 30, in main\n    x = 1 / 0\nZeroDivisionError: integer division or modulo by zero'|

これは扱いとしては単純過ぎますが、例外情報をどのようにしてあなた好みの書
式化出来るかを示しています。さらに特殊なニーズが必要な場合には *note
traceback: e7. モジュールが有用です。


File: python.info,  Node: ロギングメッセージを喋る,  Next: ロギングメッセージをバッファリングし、条件に従って出力する,  Prev: 例外の書式化をカスタマイズする,  Up: Logging クックブック

9.8.27 ロギングメッセージを喋る
-------------------------------

ロギングメッセージを目で見る形式ではなく音で聴く形式として出力したい、と
いう状況があるかもしれません。これはあなたのシステムで text- to-speech
(TTS) 機能が利用可能であれば、容易です。それが Python バインディングを持
っていなくとも、です。ほとんどの TTS システムはあなたが実行出来るコマン
ドラインプログラムを持っていて、このことで、 *note subprocess: c1. を使
うことでハンドラが呼び出せます。ここでは、TTS コマンドラインプログラムは
ユーザとの対話を期待せず、完了には時間がかかり、そしてログメッセージの頻
度はユーザをメッセージで圧倒してしまうほどには高くはなく、そして並列で喋
るよりはメッセージ一つにつき一回喋ることが受け容れられる、としておきます
。ここでお見せする実装例では、次が処理される前に一つのメッセージを喋り終
わるまで待ち、結果としてほかのハンドラを待たせることになります。
‘espeak’ TTS パッケージが手許にあるとして、このアプローチによる短い例は
このようなものです:

     import logging
     import subprocess
     import sys

     class TTSHandler(logging.Handler):
         def emit(self, record):
             msg = self.format(record)
             # Speak slowly in a female English voice
             cmd = ['espeak', '-s150', '-ven+f3', msg]
             p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                  stderr=subprocess.STDOUT)
             # wait for the program to finish
             p.communicate()

     def configure_logging():
         h = TTSHandler()
         root = logging.getLogger()
         root.addHandler(h)
         # the default formatter just returns the message
         root.setLevel(logging.DEBUG)

     def main():
         logging.info('Hello')
         logging.debug('Goodbye')

     if __name__ == '__main__':
         configure_logging()
         sys.exit(main())

実行すれば、女性の声で "Hello" に続き "Goodbye" と喋るはずです。

このアプローチは、もちろんほかの TTS システムにも採用出来ますし、メッセ
ージをコマンドライン経由で外部プログラムに渡せるようなものであれば、ほか
のシステムであっても全く同じです。


File: python.info,  Node: ロギングメッセージをバッファリングし、条件に従って出力する,  Next: バッファリングしながらロギングメッセージを email で送信する,  Prev: ロギングメッセージを喋る,  Up: Logging クックブック

9.8.28 ロギングメッセージをバッファリングし、条件に従って出力する
-----------------------------------------------------------------

メッセージを一次領域に記録し、ある種の特定の状況になった場合にだけ出力し
たい、ということがあるかもしれません。たとえばある関数内でのデバッグのた
めのログ出力をしたくても、エラーなしで終了する限りにおいては収集されたデ
バッグ情報による混雑は喰らいたくはなく、エラーがあった場合にだけエラー出
力とともにデバッグ情報を見たいのだ、のようなことがあるでしょう。

このような振る舞いをするロギングをしたい関数に対して、デコレータを用いて
これを行う例をお見せします。それには *note
logging.handlers.MemoryHandler: 2c8f. を使います。これにより何か条件を満
たすまでロギングイベントを溜め込むことが出来、条件を満たせば溜め込まれた
イベントが ‘flushed’ として他のハンドラ (‘target’ のハンドラ)に渡されま
す。デフォルトでは、 ‘MemoryHandler’ はそのバッファが一杯になるか、指定
された閾値のレベル以上のイベントが起こるとフラッシュされます。何か特別な
フラッシュの振る舞いをしたければ、このレシピはさらに特殊化した
‘MemoryHandler’ とともに利用出来ます。

スクリプト例では、 ‘foo’ という、単に全てのログレベルについて、
‘sys.stderr’ にもどのレベルを出力したのかについて書き出しながら実際のロ
グ出力も行う、という単純な関数を使っています。 ‘foo’ に真を与えると
ERROR と CRITICAL の出力をし、そうでなければ DEBUG, INFO, WARNING だけを
出力します。

スクリプトが行うことは単に、 ‘foo’ を必要とされている特定の条件でのロギ
ングを行うようにするデコレータで修飾することだけです。このデコレータはパ
ラメータとしてロガーを取り、修飾された関数が呼ばれている間だけメモリハン
ドラをアタッチします。追加のパラメータとして、ターゲットのハンドラ、フラ
ッシュが発生すべきレベル、バッファの容量(バッファされたレコード数)も受け
取れます。これらのデフォルトは順に ‘sys.stderr’ へ書き出す *note
StreamHandler: 11c9, ‘logging.ERROR’, ‘100’ です。

スクリプトはこれです:

     import logging
     from logging.handlers import MemoryHandler
     import sys

     logger = logging.getLogger(__name__)
     logger.addHandler(logging.NullHandler())

     def log_if_errors(logger, target_handler=None, flush_level=None, capacity=None):
         if target_handler is None:
             target_handler = logging.StreamHandler()
         if flush_level is None:
             flush_level = logging.ERROR
         if capacity is None:
             capacity = 100
         handler = MemoryHandler(capacity, flushLevel=flush_level, target=target_handler)

         def decorator(fn):
             def wrapper(*args, **kwargs):
                 logger.addHandler(handler)
                 try:
                     return fn(*args, **kwargs)
                 except Exception:
                     logger.exception('call failed')
                     raise
                 finally:
                     super(MemoryHandler, handler).flush()
                     logger.removeHandler(handler)
             return wrapper

         return decorator

     def write_line(s):
         sys.stderr.write('%s\n' % s)

     def foo(fail=False):
         write_line('about to log at DEBUG ...')
         logger.debug('Actually logged at DEBUG')
         write_line('about to log at INFO ...')
         logger.info('Actually logged at INFO')
         write_line('about to log at WARNING ...')
         logger.warning('Actually logged at WARNING')
         if fail:
             write_line('about to log at ERROR ...')
             logger.error('Actually logged at ERROR')
             write_line('about to log at CRITICAL ...')
             logger.critical('Actually logged at CRITICAL')
         return fail

     decorated_foo = log_if_errors(logger)(foo)

     if __name__ == '__main__':
         logger.setLevel(logging.DEBUG)
         write_line('Calling undecorated foo with False')
         assert not foo(False)
         write_line('Calling undecorated foo with True')
         assert foo(True)
         write_line('Calling decorated foo with False')
         assert not decorated_foo(False)
         write_line('Calling decorated foo with True')
         assert decorated_foo(True)

実行すればこのような出力になるはずです:

     Calling undecorated foo with False
     about to log at DEBUG ...
     about to log at INFO ...
     about to log at WARNING ...
     Calling undecorated foo with True
     about to log at DEBUG ...
     about to log at INFO ...
     about to log at WARNING ...
     about to log at ERROR ...
     about to log at CRITICAL ...
     Calling decorated foo with False
     about to log at DEBUG ...
     about to log at INFO ...
     about to log at WARNING ...
     Calling decorated foo with True
     about to log at DEBUG ...
     about to log at INFO ...
     about to log at WARNING ...
     about to log at ERROR ...
     Actually logged at DEBUG
     Actually logged at INFO
     Actually logged at WARNING
     Actually logged at ERROR
     about to log at CRITICAL ...
     Actually logged at CRITICAL

見ての通り、実際のログ出力は重要度 ERROR かそれより大きい場合にのみ行っ
ていますが、この場合はそれよりも重要度の低い ERROR よりも前に発生したイ
ベントも出力されます。

当然のことですが、デコレーションはいつものやり方でどうぞ:

     @log_if_errors(logger)
     def foo(fail=False):
         ...


File: python.info,  Node: バッファリングしながらロギングメッセージを email で送信する,  Next: 設定によって時刻を UTC GMT で書式化する,  Prev: ロギングメッセージをバッファリングし、条件に従って出力する,  Up: Logging クックブック

9.8.29 バッファリングしながらロギングメッセージを email で送信する
------------------------------------------------------------------

ログメッセージをメールで、特に1つのメールにつき複数のログメッセージを、
送信する方法を例示するため、 *note BufferingHandler: 2ce0. を継承します
。以下の例は、必要に応じて改変することもできますが、 SMTP 経由でログを送
信するのに必要な情報をコマンドライン引数で指定してスクリプトを実行できる
ように簡単なテストハーネスも提供しています (必須の引数およびオプション引
数の詳細を見るためには、ダウンロードしたスクリプトを ‘-h’ 引数をつけて実
行してください)。

     import logging
     import logging.handlers
     import smtplib

     class BufferingSMTPHandler(logging.handlers.BufferingHandler):
         def __init__(self, mailhost, port, username, password, fromaddr, toaddrs,
                      subject, capacity):
             logging.handlers.BufferingHandler.__init__(self, capacity)
             self.mailhost = mailhost
             self.mailport = port
             self.username = username
             self.password = password
             self.fromaddr = fromaddr
             if isinstance(toaddrs, str):
                 toaddrs = [toaddrs]
             self.toaddrs = toaddrs
             self.subject = subject
             self.setFormatter(logging.Formatter("%(asctime)s %(levelname)-5s %(message)s"))

         def flush(self):
             if len(self.buffer) > 0:
                 try:
                     smtp = smtplib.SMTP(self.mailhost, self.mailport)
                     smtp.starttls()
                     smtp.login(self.username, self.password)
                     msg = "From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n" % (self.fromaddr, ','.join(self.toaddrs), self.subject)
                     for record in self.buffer:
                         s = self.format(record)
                         msg = msg + s + "\r\n"
                     smtp.sendmail(self.fromaddr, self.toaddrs, msg)
                     smtp.quit()
                 except Exception:
                     if logging.raiseExceptions:
                         raise
                 self.buffer = []

     if __name__ == '__main__':
         import argparse

         ap = argparse.ArgumentParser()
         aa = ap.add_argument
         aa('host', metavar='HOST', help='SMTP server')
         aa('--port', '-p', type=int, default=587, help='SMTP port')
         aa('user', metavar='USER', help='SMTP username')
         aa('password', metavar='PASSWORD', help='SMTP password')
         aa('to', metavar='TO', help='Addressee for emails')
         aa('sender', metavar='SENDER', help='Sender email address')
         aa('--subject', '-s',
            default='Test Logging email from Python logging module (buffering)',
            help='Subject of email')
         options = ap.parse_args()
         logger = logging.getLogger()
         logger.setLevel(logging.DEBUG)
         h = BufferingSMTPHandler(options.host, options.port, options.user,
                                  options.password, options.sender,
                                  options.to, options.subject, 10)
         logger.addHandler(h)
         for i in range(102):
             logger.info("Info index = %d", i)
         h.flush()
         h.close()

SMTP サーバーを正しく設定した上でスクリプトを実行すると、指定したアドレ
ス宛てに11通のメールを受け取るでしょう。最初の10通のメールはそれぞれ10個
のログメッセージを含み、11通目のメールは2つのログメッセージを含むはずで
す。これらのログメッセージはスクリプト内で指定された102個のログメッセー
ジから構成されています。


File: python.info,  Node: 設定によって時刻を UTC GMT で書式化する,  Next: ロギングの選択にコンテキストマネージャを使う,  Prev: バッファリングしながらロギングメッセージを email で送信する,  Up: Logging クックブック

9.8.30 設定によって時刻を UTC(GMT) で書式化する
-----------------------------------------------

時刻を UTC でフォーマットしたい場合もあるでしょう。以下に示すように、そ
のようなフォーマット処理は ‘UTCFormatter’ のようなクラスを使って行うこと
ができます:

     import logging
     import time

     class UTCFormatter(logging.Formatter):
         converter = time.gmtime

そしてコード中で ‘UTCFormatter’ を *note Formatter: 143a. の代わりに使え
ます。これを設定を通して行いたい場合、 *note dictConfig(): 1180. API を
以下の完全な例で示すようなアプローチで使うことが出来ます:

     import logging
     import logging.config
     import time

     class UTCFormatter(logging.Formatter):
         converter = time.gmtime

     LOGGING = {
         'version': 1,
         'disable_existing_loggers': False,
         'formatters': {
             'utc': {
                 '()': UTCFormatter,
                 'format': '%(asctime)s %(message)s',
             },
             'local': {
                 'format': '%(asctime)s %(message)s',
             }
         },
         'handlers': {
             'console1': {
                 'class': 'logging.StreamHandler',
                 'formatter': 'utc',
             },
             'console2': {
                 'class': 'logging.StreamHandler',
                 'formatter': 'local',
             },
         },
         'root': {
             'handlers': ['console1', 'console2'],
        }
     }

     if __name__ == '__main__':
         logging.config.dictConfig(LOGGING)
         logging.warning('The local time is %s', time.asctime())

実行すれば、このような出力になるはずです:

     2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015
     2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015

時刻をローカル時刻と UTC の両方に書式化するのに、それぞれのハンドラにそ
れぞれフォーマッタを与えています。


File: python.info,  Node: ロギングの選択にコンテキストマネージャを使う,  Next: CLIアプリケーションスターターテンプレート,  Prev: 設定によって時刻を UTC GMT で書式化する,  Up: Logging クックブック

9.8.31 ロギングの選択にコンテキストマネージャを使う
---------------------------------------------------

一時的にロギングの設定を変えて、作業をした後に設定を戻せると便利なときが
あります。 こういうときの、ロギングコンテキストの保存と復元をする方法で
はコンテキストマネージャを使うのが一番です。 以下にあるのがそのためのコ
ンテキストマネージャの簡単な例で、これを使うと、任意にロギングレベルを変
更し、コンテキストマネージャのスコープ内で他に影響を及ぼさずロギングハン
ドラを追加できるようになります:

     import logging
     import sys

     class LoggingContext:
         def __init__(self, logger, level=None, handler=None, close=True):
             self.logger = logger
             self.level = level
             self.handler = handler
             self.close = close

         def __enter__(self):
             if self.level is not None:
                 self.old_level = self.logger.level
                 self.logger.setLevel(self.level)
             if self.handler:
                 self.logger.addHandler(self.handler)

         def __exit__(self, et, ev, tb):
             if self.level is not None:
                 self.logger.setLevel(self.old_level)
             if self.handler:
                 self.logger.removeHandler(self.handler)
             if self.handler and self.close:
                 self.handler.close()
             # implicit return of None => don't swallow exceptions

レベル値を指定した場合、コンテキストマネージャがカバーする with ブロック
のスコープ内でロガーのレベルがその値に設定されます。 ハンドラーを指定し
た場合、ブロックに入るときにロガーに追加され、ブロックから抜けるときに取
り除かれます。 ブロックを抜けるときに、自分で追加したハンドラをクローズ
するようコンテキストマネージャに指示することもできます - そのハンドラが
それ以降必要無いのであればクローズしてしまって構いません。

どのように動作するのかを示すためには、次のコード群を上のコードに付け加え
るとよいです:

     if __name__ == '__main__':
         logger = logging.getLogger('foo')
         logger.addHandler(logging.StreamHandler())
         logger.setLevel(logging.INFO)
         logger.info('1. This should appear just once on stderr.')
         logger.debug('2. This should not appear.')
         with LoggingContext(logger, level=logging.DEBUG):
             logger.debug('3. This should appear once on stderr.')
         logger.debug('4. This should not appear.')
         h = logging.StreamHandler(sys.stdout)
         with LoggingContext(logger, level=logging.DEBUG, handler=h, close=True):
             logger.debug('5. This should appear twice - once on stderr and once on stdout.')
         logger.info('6. This should appear just once on stderr.')
         logger.debug('7. This should not appear.')

最初はロガーのレベルを ‘INFO’ に設定しているので、メッセージ #1 は現れ、
メッセージ #2 は現れません。 次に、その後の ‘with’ ブロック内で一時的に
レベルを ‘DEBUG’ に変更したため、メッセージ #3 が現れます。 そのブロック
を抜けた後、ロガーのレベルは ‘INFO’ に復元され、メッセージ #4 は現れませ
ん。 次の ‘with’ ブロック内では、再度レベルを ‘DEBUG’ に設定し、
‘sys.stdout’ に書き出すハンドラを追加します。 そのおかげでメッセージ #5
が 2 回 (1回は ‘stderr’ を通して、もう1回は ‘stdout’ を通して) コンソー
ルに出力されます。 ‘with’ 文が完了すると、前の状態になるので (メッセージ
#1 のように) メッセージ #6 が現れ、(まさにメッセージ #2 のように) メッセ
ージ #7 は現れません。

出来上がったスクリプトを実行すると、結果は次のようになります:

     $ python logctx.py
     1. This should appear just once on stderr.
     3. This should appear once on stderr.
     5. This should appear twice - once on stderr and once on stdout.
     5. This should appear twice - once on stderr and once on stdout.
     6. This should appear just once on stderr.

‘stderr’ を ‘/dev/null’ へパイプした状態でもう一度実行すると、次のように
なり、これは ‘stdout’ の方に書かれたメッセージだけが現れています:

     $ python logctx.py 2>/dev/null
     5. This should appear twice - once on stderr and once on stdout.

‘stdout’ を ‘/dev/null’ へパイプした状態でさらにもう一度実行すると、こう
なります:

     $ python logctx.py >/dev/null
     1. This should appear just once on stderr.
     3. This should appear once on stderr.
     5. This should appear twice - once on stderr and once on stdout.
     6. This should appear just once on stderr.

この場合では、 ‘stdout’ の方に出力されたメッセージ #5 は予想通り現れませ
ん。

もちろんここで説明した手法は、例えば一時的にロギングフィルターを取り付け
たりするのに一般化できます。 上のコードは Python 2 だけでなく Python 3 で
も動くことに注意してください。


File: python.info,  Node: CLIアプリケーションスターターテンプレート,  Next: Qt GUIのログ出力,  Prev: ロギングの選択にコンテキストマネージャを使う,  Up: Logging クックブック

9.8.32 CLIアプリケーションスターターテンプレート
------------------------------------------------

ここのサンプルでは次のことを説明します:

   * コマンドライン引数に応じてログレベルを使用する

   * 複数のファイルに分割されたサブコマンドにディスパッチする。すべて一
     貫して同じレベルでログ出力を行う

   * シンプルで最小限の設定で行えるようにする

サービスを停止したり、開始したり、再起動する役割を持ったコマンドラインア
プリケーションがあるとします。説明のために、アプリケーションのメインスク
リプトが ‘app.py’ 、個々のコマンドが ‘start.py’ 、 ‘stop.py’ 、
‘restart.py’ に実装されているものとします。デフォルトは ‘logging.INFO’ で
すが、コマンドライン引数を使ってアプリケーションのログの冗長性を制御した
いとします。 ‘app.py’ は次のコードのようになるでしょう:

     import argparse
     import importlib
     import logging
     import os
     import sys

     def main(args=None):
         scriptname = os.path.basename(__file__)
         parser = argparse.ArgumentParser(scriptname)
         levels = ('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL')
         parser.add_argument('--log-level', default='INFO', choices=levels)
         subparsers = parser.add_subparsers(dest='command',
                                            help='Available commands:')
         start_cmd = subparsers.add_parser('start', help='Start a service')
         start_cmd.add_argument('name', metavar='NAME',
                                help='Name of service to start')
         stop_cmd = subparsers.add_parser('stop',
                                          help='Stop one or more services')
         stop_cmd.add_argument('names', metavar='NAME', nargs='+',
                               help='Name of service to stop')
         restart_cmd = subparsers.add_parser('restart',
                                             help='Restart one or more services')
         restart_cmd.add_argument('names', metavar='NAME', nargs='+',
                                  help='Name of service to restart')
         options = parser.parse_args()
         # the code to dispatch commands could all be in this file. For the purposes
         # of illustration only, we implement each command in a separate module.
         try:
             mod = importlib.import_module(options.command)
             cmd = getattr(mod, 'command')
         except (ImportError, AttributeError):
             print('Unable to find the code for command \'%s\'' % options.command)
             return 1
         # Could get fancy here and load configuration from file or dictionary
         logging.basicConfig(level=options.log_level,
                             format='%(levelname)s %(name)s %(message)s')
         cmd(options)

     if __name__ == '__main__':
         sys.exit(main())

‘start’ 、 ‘stop’ 、 ‘restart’ コマンドは個別のモジュールとして実装され
ます。次は起動コマンドのソースです:

     # start.py
     import logging

     logger = logging.getLogger(__name__)

     def command(options):
         logger.debug('About to start %s', options.name)
         # actually do the command processing here ...
         logger.info('Started the \'%s\' service.', options.name)

停止コマンドのソースは次の通りです:

     # stop.py
     import logging

     logger = logging.getLogger(__name__)

     def command(options):
         n = len(options.names)
         if n == 1:
             plural = ''
             services = '\'%s\'' % options.names[0]
         else:
             plural = 's'
             services = ', '.join('\'%s\'' % name for name in options.names)
             i = services.rfind(', ')
             services = services[:i] + ' and ' + services[i + 2:]
         logger.debug('About to stop %s', services)
         # actually do the command processing here ...
         logger.info('Stopped the %s service%s.', services, plural)

同様に、再起動のコマンドは次の通りです:

     # restart.py
     import logging

     logger = logging.getLogger(__name__)

     def command(options):
         n = len(options.names)
         if n == 1:
             plural = ''
             services = '\'%s\'' % options.names[0]
         else:
             plural = 's'
             services = ', '.join('\'%s\'' % name for name in options.names)
             i = services.rfind(', ')
             services = services[:i] + ' and ' + services[i + 2:]
         logger.debug('About to restart %s', services)
         # actually do the command processing here ...
         logger.info('Restarted the %s service%s.', services, plural)

このアプリケーションをデフォルトのログレベルで実行すると、次のような出力
が得られます:

     $ python app.py start foo
     INFO start Started the 'foo' service.

     $ python app.py stop foo bar
     INFO stop Stopped the 'foo' and 'bar' services.

     $ python app.py restart foo bar baz
     INFO restart Restarted the 'foo', 'bar' and 'baz' services.

最初のワードはログレベルで、次のワードはイベントのログ出力が行われたモジ
ュールまたはパッケージ名です。

ログレベルを変更し、ログに出力する情報を変更できるようにしましょう。もし
、より詳細な情報が必要だとしましょう:

     $ python app.py --log-level DEBUG start foo
     DEBUG start About to start foo
     INFO start Started the 'foo' service.

     $ python app.py --log-level DEBUG stop foo bar
     DEBUG stop About to stop 'foo' and 'bar'
     INFO stop Stopped the 'foo' and 'bar' services.

     $ python app.py --log-level DEBUG restart foo bar baz
     DEBUG restart About to restart 'foo', 'bar' and 'baz'
     INFO restart Restarted the 'foo', 'bar' and 'baz' services.

あるいは情報を減らしたい場合もあるでしょう:

     $ python app.py --log-level WARNING start foo
     $ python app.py --log-level WARNING stop foo bar
     $ python app.py --log-level WARNING restart foo bar baz

この場合、コマンドはコンソールに何も出力しなくなります。


File: python.info,  Node: Qt GUIのログ出力,  Next: RFC5424 をサポートする syslog へのロギング,  Prev: CLIアプリケーションスターターテンプレート,  Up: Logging クックブック

9.8.33 Qt GUIのログ出力
-----------------------

A question that comes up from time to time is about how to log to a GUI
application.  The Qt(1) framework is a popular cross-platform UI
framework with Python bindings using PySide2(2) or PyQt5(3) libraries.

次のサンプルはQt GUIでログ出力を行うサンプルです。ここではシンプルな
‘QtHandler’ クラスを作成しています。これは呼び出し可能オブジェクトを受け
取ります。これはGUI更新を行うメインスレッドの中で利用されるスロットです
。ワーカースレッドも作成し、UI自身からボタンを使ってログを出力したり、バ
ックグラウンドのタスクを行うワーカースレッドからログ出力を行います（ここ
ではランダムな期間にランダムなレベルでメッセージを出しています）。

ワーカースレッドは *note threading: d6. モジュールではなく、Qtの
‘QThread’ クラスを使っています。これは他の ‘Qt’ コンポーネントとうまく統
合できるように、 ‘QThread’ を使う必要があるからです。

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.

     import datetime
     import logging
     import random
     import sys
     import time

     # Deal with minor differences between different Qt packages
     try:
         from PySide6 import QtCore, QtGui, QtWidgets
         Signal = QtCore.Signal
         Slot = QtCore.Slot
     except ImportError:
         try:
             from PyQt6 import QtCore, QtGui, QtWidgets
             Signal = QtCore.pyqtSignal
             Slot = QtCore.pyqtSlot
         except ImportError:
             try:
                 from PySide2 import QtCore, QtGui, QtWidgets
                 Signal = QtCore.Signal
                 Slot = QtCore.Slot
             except ImportError:
                 from PyQt5 import QtCore, QtGui, QtWidgets
                 Signal = QtCore.pyqtSignal
                 Slot = QtCore.pyqtSlot

     logger = logging.getLogger(__name__)


     #
     # Signals need to be contained in a QObject or subclass in order to be correctly
     # initialized.
     #
     class Signaller(QtCore.QObject):
         signal = Signal(str, logging.LogRecord)

     #
     # Output to a Qt GUI is only supposed to happen on the main thread. So, this
     # handler is designed to take a slot function which is set up to run in the main
     # thread. In this example, the function takes a string argument which is a
     # formatted log message, and the log record which generated it. The formatted
     # string is just a convenience - you could format a string for output any way
     # you like in the slot function itself.
     #
     # You specify the slot function to do whatever GUI updates you want. The handler
     # doesn't know or care about specific UI elements.
     #
     class QtHandler(logging.Handler):
         def __init__(self, slotfunc, *args, **kwargs):
             super().__init__(*args, **kwargs)
             self.signaller = Signaller()
             self.signaller.signal.connect(slotfunc)

         def emit(self, record):
             s = self.format(record)
             self.signaller.signal.emit(s, record)

     #
     # This example uses QThreads, which means that the threads at the Python level
     # are named something like "Dummy-1". The function below gets the Qt name of the
     # current thread.
     #
     def ctname():
         return QtCore.QThread.currentThread().objectName()


     #
     # Used to generate random levels for logging.
     #
     LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR,
               logging.CRITICAL)

     #
     # This worker class represents work that is done in a thread separate to the
     # main thread. The way the thread is kicked off to do work is via a button press
     # that connects to a slot in the worker.
     #
     # Because the default threadName value in the LogRecord isn't much use, we add
     # a qThreadName which contains the QThread name as computed above, and pass that
     # value in an "extra" dictionary which is used to update the LogRecord with the
     # QThread name.
     #
     # This example worker just outputs messages sequentially, interspersed with
     # random delays of the order of a few seconds.
     #
     class Worker(QtCore.QObject):
         @Slot()
         def start(self):
             extra = {'qThreadName': ctname() }
             logger.debug('Started work', extra=extra)
             i = 1
             # Let the thread run until interrupted. This allows reasonably clean
             # thread termination.
             while not QtCore.QThread.currentThread().isInterruptionRequested():
                 delay = 0.5 + random.random() * 2
                 time.sleep(delay)
                 try:
                     if random.random() < 0.1:
                         raise ValueError('Exception raised: %d' % i)
                     else:
                         level = random.choice(LEVELS)
                         logger.log(level, 'Message after delay of %3.1f: %d', delay, i, extra=extra)
                 except ValueError as e:
                     logger.exception('Failed: %s', e, extra=extra)
                 i += 1

     #
     # Implement a simple UI for this cookbook example. This contains:
     #
     # * A read-only text edit window which holds formatted log messages
     # * A button to start work and log stuff in a separate thread
     # * A button to log something from the main thread
     # * A button to clear the log window
     #
     class Window(QtWidgets.QWidget):

         COLORS = {
             logging.DEBUG: 'black',
             logging.INFO: 'blue',
             logging.WARNING: 'orange',
             logging.ERROR: 'red',
             logging.CRITICAL: 'purple',
         }

         def __init__(self, app):
             super().__init__()
             self.app = app
             self.textedit = te = QtWidgets.QPlainTextEdit(self)
             # Set whatever the default monospace font is for the platform
             f = QtGui.QFont('nosuchfont')
             if hasattr(f, 'Monospace'):
                 f.setStyleHint(f.Monospace)
             else:
                 f.setStyleHint(f.StyleHint.Monospace)  # for Qt6
             te.setFont(f)
             te.setReadOnly(True)
             PB = QtWidgets.QPushButton
             self.work_button = PB('Start background work', self)
             self.log_button = PB('Log a message at a random level', self)
             self.clear_button = PB('Clear log window', self)
             self.handler = h = QtHandler(self.update_status)
             # Remember to use qThreadName rather than threadName in the format string.
             fs = '%(asctime)s %(qThreadName)-12s %(levelname)-8s %(message)s'
             formatter = logging.Formatter(fs)
             h.setFormatter(formatter)
             logger.addHandler(h)
             # Set up to terminate the QThread when we exit
             app.aboutToQuit.connect(self.force_quit)

             # Lay out all the widgets
             layout = QtWidgets.QVBoxLayout(self)
             layout.addWidget(te)
             layout.addWidget(self.work_button)
             layout.addWidget(self.log_button)
             layout.addWidget(self.clear_button)
             self.setFixedSize(900, 400)

             # Connect the non-worker slots and signals
             self.log_button.clicked.connect(self.manual_update)
             self.clear_button.clicked.connect(self.clear_display)

             # Start a new worker thread and connect the slots for the worker
             self.start_thread()
             self.work_button.clicked.connect(self.worker.start)
             # Once started, the button should be disabled
             self.work_button.clicked.connect(lambda : self.work_button.setEnabled(False))

         def start_thread(self):
             self.worker = Worker()
             self.worker_thread = QtCore.QThread()
             self.worker.setObjectName('Worker')
             self.worker_thread.setObjectName('WorkerThread')  # for qThreadName
             self.worker.moveToThread(self.worker_thread)
             # This will start an event loop in the worker thread
             self.worker_thread.start()

         def kill_thread(self):
             # Just tell the worker to stop, then tell it to quit and wait for that
             # to happen
             self.worker_thread.requestInterruption()
             if self.worker_thread.isRunning():
                 self.worker_thread.quit()
                 self.worker_thread.wait()
             else:
                 print('worker has already exited.')

         def force_quit(self):
             # For use when the window is closed
             if self.worker_thread.isRunning():
                 self.kill_thread()

         # The functions below update the UI and run in the main thread because
         # that's where the slots are set up

         @Slot(str, logging.LogRecord)
         def update_status(self, status, record):
             color = self.COLORS.get(record.levelno, 'black')
             s = '<pre><font color="%s">%s</font></pre>' % (color, status)
             self.textedit.appendHtml(s)

         @Slot()
         def manual_update(self):
             # This function uses the formatted message passed in, but also uses
             # information from the record to format the message in an appropriate
             # color according to its severity (level).
             level = random.choice(LEVELS)
             extra = {'qThreadName': ctname() }
             logger.log(level, 'Manually logged!', extra=extra)

         @Slot()
         def clear_display(self):
             self.textedit.clear()


     def main():
         QtCore.QThread.currentThread().setObjectName('MainThread')
         logging.getLogger().setLevel(logging.DEBUG)
         app = QtWidgets.QApplication(sys.argv)
         example = Window(app)
         example.show()
         if hasattr(app, 'exec'):
             rc = app.exec()
         else:
             rc = app.exec_()
         sys.exit(rc)

     if __name__=='__main__':
         main()

   ---------- Footnotes ----------

   (1) https://www.qt.io/

   (2) https://pypi.org/project/PySide2/

   (3) https://pypi.org/project/PyQt5/


File: python.info,  Node: RFC5424 をサポートする syslog へのロギング,  Next: ロガーを出力ストリームのように取り扱う方法,  Prev: Qt GUIのログ出力,  Up: Logging クックブック

9.8.34 RFC5424 をサポートする syslog へのロギング
-------------------------------------------------

RFC 5424(1) は 2009 年から始まっていますが、ほとんどの syslog サーバーは
デフォルトで、 2001 年から使われている古い RFC 3164(2) を使って構成され
ています。2003年に ‘logging’ モジュールが Python に追加されたとき、モジ
ュールは古い (そして当時唯一存在した) プロトコルをサポートしていました。
RFC5424 は、それが登場して以来、 syslog サーバーにおいて広く使われること
がなかったために、 *note SysLogHandler: 628. の機能は更新されてきません
でした。

RFC 5424 は構造化データのサポートなど、いくつかの有用な機能を持っていま
す。その機能をサポートする syslog サーバーへのロギングを可能にする必要が
ある場合、以下のような派生ハンドラクラスを使うことで実現することができま
す:

     import datetime
     import logging.handlers
     import re
     import socket
     import time

     class SysLogHandler5424(logging.handlers.SysLogHandler):

         tz_offset = re.compile(r'([+-]\d{2})(\d{2})$')
         escaped = re.compile(r'([\]"\\])')

         def __init__(self, *args, **kwargs):
             self.msgid = kwargs.pop('msgid', None)
             self.appname = kwargs.pop('appname', None)
             super().__init__(*args, **kwargs)

         def format(self, record):
             version = 1
             asctime = datetime.datetime.fromtimestamp(record.created).isoformat()
             m = self.tz_offset.match(time.strftime('%z'))
             has_offset = False
             if m and time.timezone:
                 hrs, mins = m.groups()
                 if int(hrs) or int(mins):
                     has_offset = True
             if not has_offset:
                 asctime += 'Z'
             else:
                 asctime += f'{hrs}:{mins}'
             try:
                 hostname = socket.gethostname()
             except Exception:
                 hostname = '-'
             appname = self.appname or '-'
             procid = record.process
             msgid = '-'
             msg = super().format(record)
             sdata = '-'
             if hasattr(record, 'structured_data'):
                 sd = record.structured_data
                 # This should be a dict where the keys are SD-ID and the value is a
                 # dict mapping PARAM-NAME to PARAM-VALUE (refer to the RFC for what these
                 # mean)
                 # There's no error checking here - it's purely for illustration, and you
                 # can adapt this code for use in production environments
                 parts = []

                 def replacer(m):
                     g = m.groups()
                     return '\\' + g[0]

                 for sdid, dv in sd.items():
                     part = f'[{sdid}'
                     for k, v in dv.items():
                         s = str(v)
                         s = self.escaped.sub(replacer, s)
                         part += f' {k}="{s}"'
                     part += ']'
                     parts.append(part)
                 sdata = ''.join(parts)
             return f'{version} {asctime} {hostname} {appname} {procid} {msgid} {sdata} {msg}'

上記のコードを完全に理解するには RFC 5424 を熟知する必要があります。また
、上記の例とはやや異なる要求を持つこともあるでしょう (たとえば構造化デー
タをログに渡す方法について)。にもかかわらず、上記のコードは特有の要求に
対する順応性があります。上記のハンドラにより、構造化データは以下のように
渡すことができるでしょう:

     sd = {
         'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'},
         'foo@54321': {'rab': 'baz', 'zab': 'bozz', 'zzif': r'buzz'}
     }
     extra = {'structured_data': sd}
     i = 1
     logger.debug('Message %d', i, extra=extra)

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc5424.html

   (2) https://datatracker.ietf.org/doc/html/rfc3164.html


File: python.info,  Node: ロガーを出力ストリームのように取り扱う方法,  Next: 避けるべきパターン,  Prev: RFC5424 をサポートする syslog へのロギング,  Up: Logging クックブック

9.8.35 ロガーを出力ストリームのように取り扱う方法
-------------------------------------------------

書き込み先として file-like オブジェクトを期待するサードパーティの API に
接続する必要がある一方で、その API の出力を直接ロガーに送りたいというこ
とがときどきあります。これは file-like な API でロガーをラップするクラス
を使うことで実現できます。以下はそのようなクラスを例解する短いスクリプト
です:

     import logging

     class LoggerWriter:
         def __init__(self, logger, level):
             self.logger = logger
             self.level = level

         def write(self, message):
             if message != '\n':  # avoid printing bare newlines, if you like
                 self.logger.log(self.level, message)

         def flush(self):
             # doesn't actually do anything, but might be expected of a file-like
             # object - so optional depending on your situation
             pass

         def close(self):
             # doesn't actually do anything, but might be expected of a file-like
             # object - so optional depending on your situation. You might want
             # to set a flag so that later calls to write raise an exception
             pass

     def main():
         logging.basicConfig(level=logging.DEBUG)
         logger = logging.getLogger('demo')
         info_fp = LoggerWriter(logger, logging.INFO)
         debug_fp = LoggerWriter(logger, logging.DEBUG)
         print('An INFO message', file=info_fp)
         print('A DEBUG message', file=debug_fp)

     if __name__ == "__main__":
         main()

このスクリプトを実行すると、次のように出力されます。

     INFO:demo:An INFO message
     DEBUG:demo:A DEBUG message

また、 ‘sys.stdout’ や ‘sys.stderr’ をリダイレクトするには
‘LoggerWriter’ を使って以下のようにします:

     import sys

     sys.stdout = LoggerWriter(logger, logging.INFO)
     sys.stderr = LoggerWriter(logger, logging.WARNING)

上記の操作は、必要に応じてロギングを設定した '後に' 行うべきです。上記の
例では、 *note basicConfig(): 9ce. の呼び出しが (‘LoggerWriter’ インスタ
ンスで上書きされる '前の' ‘sys.stderr’ を使って) 設定を行います。そして
、以下のような結果を得るでしょう:

     >>> print('Foo')
     INFO:demo:Foo
     >>> print('Bar', file=sys.stderr)
     WARNING:demo:Bar
     >>>

言うまでもなく上記の例は *note basicConfig(): 9ce. で使われている書式に
もとづく出力を示していますが、ロギングの設定で異なるフォーマッタを使うこ
とができます。

上記の例では、バッファリングや奪取した書き込み呼び出しのシーケンスの扱い
についてはなすがままになっています。たとえば、上記の ‘LoggerWriter’ の定
義で、次のようなコードの断片があったとします。

     sys.stderr = LoggerWriter(logger, logging.WARNING)
     1 / 0

このスクリプトを実行すると以下のような結果が得られます。

     WARNING:demo:Traceback (most recent call last):

     WARNING:demo:  File "/home/runner/cookbook-loggerwriter/test.py", line 53, in <module>

     WARNING:demo:
     WARNING:demo:main()
     WARNING:demo:  File "/home/runner/cookbook-loggerwriter/test.py", line 49, in main

     WARNING:demo:
     WARNING:demo:1 / 0
     WARNING:demo:ZeroDivisionError
     WARNING:demo::
     WARNING:demo:division by zero

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 in a separate logged line (for example, the last three lines
above).  To get around this problem, you need to buffer things and only
output log lines when newlines are seen.  Let's use a slightly better
implementation of ‘LoggerWriter’:

     class BufferingLoggerWriter(LoggerWriter):
         def __init__(self, logger, level):
             super().__init__(logger, level)
             self.buffer = ''

         def write(self, message):
             if '\n' not in message:
                 self.buffer += message
             else:
                 parts = message.split('\n')
                 if self.buffer:
                     s = self.buffer + parts.pop(0)
                     self.logger.log(self.level, s)
                 self.buffer = parts.pop()
                 for part in parts:
                     self.logger.log(self.level, part)

この実装は改行があらわれるまでログをバッファリングし、行全体をログに出力
するだけです。このアプローチにより、より適切な出力が得られます:

     WARNING:demo:Traceback (most recent call last):
     WARNING:demo:  File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module>
     WARNING:demo:    main()
     WARNING:demo:  File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main
     WARNING:demo:    1/0
     WARNING:demo:ZeroDivisionError: division by zero


File: python.info,  Node: 避けるべきパターン,  Next: その他のリソース<2>,  Prev: ロガーを出力ストリームのように取り扱う方法,  Up: Logging クックブック

9.8.36 避けるべきパターン
-------------------------

これまでのセクションではログ出力を行うときに必要なこと、考慮すべきことな
どを説明してきました。このセクションでは、 '役に立たない' 利用パターンに
ついて触れます。これは多くの場合避けるべきことです。これらの説明はどこか
ら読んでも構いません。

* Menu:

* 同じログファイルを何度も開く::
* ロガーをクラスの属性にするか、パラメータで渡す::
* ライブラリ内でロガーに NullHandler 以外のハンドラーを追加する::
* 大量のロガーを作成する::


File: python.info,  Node: 同じログファイルを何度も開く,  Next: ロガーをクラスの属性にするか、パラメータで渡す,  Up: 避けるべきパターン

9.8.36.1 同じログファイルを何度も開く
.....................................

Windowsでは同じファイルを何度も開くことができず「このファイルは他のプロ
セスから利用されています」というエラーが表示されます。しかし、POSIXプラ
ットフォームではエラーがおきることなく、同じファイルを何度も開けます。こ
れは次のように間違って使われる可能性があります。

   * 同じファイルを指すファイルハンドラを1度以上追加する（例えばコピー＆
     ペーストして書き換え忘れによるエラー)。

   * 異なる名前を持つ、一見異なる2つのファイルを開くが、片方が他方へのシ
     ンボリックリンクとなっている。

   * プロセスをフォークするが、その後親プロセスと子プロセスが同じファイ
     ルへの参照を維持する。これは例えば、 *note multiprocessing: 86. モ
     ジュールなどを使うと発生する可能性があります。

ファイルを複数回開くことは、 '一見' 動作しているように見えますが、さまざ
まな問題を引き起こす可能性があります:

   * 複数のスレッドが同一ファイルに書き出そうとすると、ログ出力が文字化
     けする可能性があります。ログモジュールは同じハンドラーのインスタン
     スに対して並列で利用しても正しく動くようになっていますが、同じファ
     イルを参照する2つの異なるハンドラーのインスタンスに対し、2つのスレ
     ッドから同時に書き込みをした場合にはそのような保護は働きません。

   * (たとえばファイルのローテーションの間に) ファイルを削除しようとする
     と、そのファイルを指す別の参照が残っているために、何のエラーも発し
     ないまま失敗します。これは混乱や不要なデバッグの時間のもととなる可
     能性があります - ログが思いもしない場所に記録されたり、完全に失われ
     たりします。もしくは移動したと思われていたファイルが残っていたり、
     ファイルサイズにもとづくローテーションが行われているにもかかわらず
     ファイルサイズが予想外に増加したりすることもあります。

この問題を回避するには *note
複数のプロセスからの単一ファイルへのログ記録: 4dd8. で紹介したテクニック
を使用してください。


File: python.info,  Node: ロガーをクラスの属性にするか、パラメータで渡す,  Next: ライブラリ内でロガーに NullHandler 以外のハンドラーを追加する,  Prev: 同じログファイルを何度も開く,  Up: 避けるべきパターン

9.8.36.2 ロガーをクラスの属性にするか、パラメータで渡す
.......................................................

ロガーはシングルトンであるため、一般的には意味がなく、これを行う必要が出
てくることは滅多にありません。コードからは名前を使って
‘logging.getLogger(name)’ 経由でロガーインスタンスにアクセスできるため、
インスタンスを持って回って、インスタンス属性として保持することは意味があ
りません。JavaやC#といった他の言語ではよく静的クラス属性にしてます。しか
し、Pythonにおいてはこのパターンはクラスではなくモジュールがソフトウェア
分解の単位となっているため、無意味です。


File: python.info,  Node: ライブラリ内でロガーに NullHandler 以外のハンドラーを追加する,  Next: 大量のロガーを作成する,  Prev: ロガーをクラスの属性にするか、パラメータで渡す,  Up: 避けるべきパターン

9.8.36.3 ライブラリ内でロガーに ‘NullHandler’ 以外のハンドラーを追加する
........................................................................

ハンドラーやフォーマッター、フィルターを追加してログ出力をカスタマイズす
るのはライブラリ開発者ではなく、アプリケーション開発者の責務です。もしあ
なたがライブラリのメンテナンスをしているのであれば、 *note NullHandler:
1255. インスタンス以外のロガーを追加してはいけない、ということを意味しま
す。


File: python.info,  Node: 大量のロガーを作成する,  Prev: ライブラリ内でロガーに NullHandler 以外のハンドラーを追加する,  Up: 避けるべきパターン

9.8.36.4 大量のロガーを作成する
...............................

ロガーはシングルトンであり、スクリプトの実行中に解放されることがないため
、大量のロガーを作成すると、メモリが解放されることなく消費されます。ファ
イルの処理単位やネットワーク接続単位でロガーを作るのではなく、 *note
既存のメカニズム: 2c65. を使ってコンテキスト依存の情報をログに渡し、ロガ
ーはアプリケーション内の説明の単位（通常はモジュールだが、場合によっては
それよりも小さい可能性もある）で作るように制限してください。


File: python.info,  Node: その他のリソース<2>,  Prev: 避けるべきパターン,  Up: Logging クックブック

9.8.37 その他のリソース
-----------------------

参考
....

*note logging: 7b. モジュール

     logging モジュールの API リファレンス。

*note logging.config: 7c. モジュール

     logging モジュールの環境設定 API です。

*note logging.handlers: 7d. モジュール

     logging モジュールに含まれる、便利なハンドラです。

*note 基本チュートリアル: 11c6.

*note 上級チュートリアル: 11c7.


File: python.info,  Node: 正規表現 HOWTO,  Next: ソケットプログラミング HOWTO,  Prev: Logging クックブック,  Up: Python HOWTO

9.9 正規表現 HOWTO
==================


著者: A.M. Kuchling <<amk@amk.ca>>

概要
....

このドキュメントは *note re: a7. モジュールを使って Python で正規表現を
扱うための導入のチュートリアルです。ライブラリレファレンスの正規表現の節
よりもやさしい入門ドキュメントを用意しています。

* Menu:

* はじめに: はじめに<13>.
* 単純なパターン::
* 正規表現を使う::
* パターンの能力をさらに::
* 文字列を変更する::
* よくある問題::
* フィードバック::


File: python.info,  Node: はじめに<13>,  Next: 単純なパターン,  Up: 正規表現 HOWTO

9.9.1 はじめに
--------------

正規表現 regular expressions (REs や regexes または regex patterns と呼
ばれます) は本質的に小さく、Python 内部に埋め込まれた高度に特化したプロ
グラミング言語で *note re: a7. モジュールから利用可能です。この小さな言
語を利用することで、マッチさせたい文字列に適合するような文字列の集合を指
定することができます; この集合は英文や e-mail アドレスや TeX コマンドな
ど、どんなものでも構いません。「この文字列は指定したパターンにマッチしま
すか?」「このパターンはこの文字列のどの部分にマッチするのですか?」といっ
たことを問い合わせることができます。正規表現を使って文字列を変更したりい
ろいろな方法で別々の部分に分割したりすることもできます。

正規表現パターンは一連のバイトコードとしてコンパイルされ、C で書かれたマ
ッチングエンジンによって実行されます。より進んだ利用法では、エンジンがど
う与えられた正規表現を実行するかに注意することが必要になり、高速に実行で
きるバイトコードを生成するように正規表現を書くことになります。このドキュ
メントでは最適化までは扱いません、それにはマッチングエンジンの内部に対す
る十分な理解が必要だからです。

正規表現言語は相対的に小さく、制限されています、そのため正規表現を使って
あらゆる文字列処理作業を行なえるわけではありません。正規表現を使って行う
ことのできる作業もあります、ただ表現はとても複雑なものになります。それら
の場合では、Python コードを書いた方がいいでしょう; Python コードは念入り
に作られた正規表現より遅くなりますが、おそらくより読み易いでしょう。


File: python.info,  Node: 単純なパターン,  Next: 正規表現を使う,  Prev: はじめに<13>,  Up: 正規表現 HOWTO

9.9.2 単純なパターン
--------------------

まずはできるだけ簡単な正規表現を学ぶことから始めてみましょう。正規表現は
文字列の操作に使われるので、ますは最も一般的な作業である文字のマッチング
をしてみます。

正規表現の基礎を成す計算機科学 (決定、非決定有限オートマトン) の詳細な説
明については, コンパイラ作成に関するテキストブックをどれでもいいので参照
して下さい。

* Menu:

* 文字のマッチング::
* 繰り返し::


File: python.info,  Node: 文字のマッチング,  Next: 繰り返し,  Up: 単純なパターン

9.9.2.1 文字のマッチング
........................

多くの活字や文字は単純にそれ自身とマッチします。例えば、 ‘test’ という正
規表現は文字列 ‘test’ に厳密にマッチします。(大文字小文字を区別しないモ
ードでその正規表現が ‘Test’ や ‘TEST’ にも同様にマッチすることもできます
; 詳しくは後述します。)

この規則には例外が存在します; いくつかの文字は特別な '特殊文字
(metacharacters)' で、それら自身にマッチしません。代わりに通常のマッチす
るものとは違うという合図を出したり、正規表現の一部に対して繰り返したり、
意味を変えたりして影響を与えます。このドキュメントの中の多くは様々な特殊
文字とそれが何をするかについて論じることになります。

ここに特殊文字の完全な一覧があります; これらの意味はこの HOWTO の残りの
部分で説明します。

     . ^ $ * + ? { } [ ] \ | ( )

最初に扱う特殊文字は ‘[’ と ‘]’ です。これらは文字クラスを指定します、文
字クラスはマッチしたい文字の集合です。文字は個別にリストにしても構いませ
んし、二つの文字を ‘'-'’ でつなげて文字を範囲で与えてもかまいません。た
とえば ‘[abc]’ は ‘a’, ‘b’, または ‘c’ のどの文字列にもマッチします; こ
れは ‘[a-c]’ で同じ文字集合を範囲で表現しても全く同じです。小文字のアル
ファベットのみにマッチしたい場合、 ‘[a-z]’ の正規表現をつかうことになる
でしょう。

(‘\’ を除く) 特殊文字は文字クラスの内部では有効になりません。例えば、
‘[akm$]’ は ‘'a'’, ‘'k'’, ‘'m'’, または ‘'{TX-PL-LABEL}#x27;’ のいずれか
にマッチします; ‘'{TX-PL-LABEL}#x27;’ は通常は特殊文字ですが、文字クラス
内部ではその特別な性質は取り除かれます。

'補集合を取る' ことで、文字クラス内のリストにない文字に対してマッチさせ
られます。 補集合は、クラスの最初の文字として ‘'^'’ を含めることで表せま
す。 例えば、 ‘[^5]’ は ‘'5'’ 以外の文字にマッチします。 キャレットが文
字クラス以外の場所に現れた場合は、特別な意味は持ちません。 例えば、
‘[5^]’ は ‘'5'’ や ‘'^'’ にマッチします。

おそらく最も重要な特殊文字はバックスラッシュ ‘\’ でしょう。 Python の文
字列リテラルのようにバックスラッシュに続けていろいろな文字を入力すること
でいろいろな特殊シーケンスの合図を送ることができます。また、バックスラッ
シュはすべての特殊文字をエスケープするのにも利用されます、つまり、特殊文
字をマッチさせることができます; 例えば、 ‘[’ または ‘\’ にマッチさせたい
場合、それらをバックスラッシュに続けることで特殊な意味を除きます: ‘\[’ ま
たは ‘\\’ 。

‘'\'’ で始まるいくつかの特殊シーケンスは、数字、アルファベット、空白文字
以外など、よく使う文字集合を表しています。

一つ例をお見せしましょう: ‘\w’ は任意の英数字文字にマッチします。バイト
列パターンに対しては、これは文字クラス ‘[a-zA-Z0-9_]’ と等価です。ユニコ
ードパターンに対しては、 ‘\w’ は *note unicodedata: ee. モジュールで提供
されている Unicode データベースで letters としてマークされている全ての文
字とマッチします。正規表現のコンパイル時に *note re.ASCII: 5f8. フラグを
与えることにより、 ‘\w’ を、より制限された定義で使うことが出来ます。

以下に続く特別な文字列のリストは完全ではありません。特殊シーケンスと拡張
クラスについてのユニコードパターンの定義についての完全なリストは、標準ラ
イブラリリファレンスの *note 正規表現の構文: 6ef. の最後のパートを参照し
てください。一般的にユニコードバージョンは、ユニコードデータベース内で相
応しいカテゴリに属すればマッチします。

‘\d’

     任意の十進数とマッチします; これは集合 ‘[0-9]’ と同じ意味です。

‘\D’

     任意の非数字文字とマッチします; これは集合 ‘[^0-9]’ と同じ意味です
     。

‘\s’

     任意の空白文字とマッチします; これは集合 ‘[ \t\n\r\f\v]’ と同じ意味
     です。

‘\S’

     任意の非空白文字とマッチします; これは集合 ‘[^ \t\n\r\f\v]’ と同じ
     意味です。

‘\w’

     任意の英数文字および下線とマッチします; これは、集合 ‘[a-zA-Z0-9_]’
     と同じ意味です。

‘\W’

     任意の非英数文字とマッチします; これは集合 ‘[^a-zA-Z0-9_]’ と同じ意
     味です。

これらのシーケンスは文字クラス内に含めることができます。例えば、
‘[\s,.]’ は空白文字や ‘','’ または ‘'.'’ にマッチする文字クラスです。

この節での最後の特殊文字は ‘.’ です。 これは改行文字を除く任意の文字にマ
ッチし、さらに改行文字に対してもマッチさせる代替モード (*note re.DOTALL:
2248.) があります。 ‘.’ は「任意の文字」にマッチさせたい場合に利用されま
す。


File: python.info,  Node: 繰り返し,  Prev: 文字のマッチング,  Up: 単純なパターン

9.9.2.2 繰り返し
................

さまざまな文字集合をマッチさせることは正規表現で最初にできるようになるこ
とで、これは文字列に対するメソッドですぐにできることではありません。しか
し、正規表現がより力を発揮する場面がこれだけだとすると、正規表現はあまり
先進的とはいえません。正規表現の力をもう一つの能力は、正規表現の一部が何
度も繰り返されるようものを指定できることです。

最初にとりあげる繰り返しのための最初の特殊文字は ‘*’ です。 ‘*’ は文字リ
テラル ‘'*'’ とはマッチしません; その代わりに、前の文字がぴったり1回では
なく0回以上繰り返されるパターンを指定します。

例えば、 ‘ca*t’ は ‘'ct'’ (文字 ‘'a'’ が 0 個)、 ‘'cat'’ (‘'a'’ が 1 個
)、 ‘'caaat'’ (‘'a'’ が 3 個)、などにマッチします。

‘*’ のような繰り返しは '貪欲 (greedy)' です; 正規表現を繰り返したいとき
、マッチングエンジンは可能な限り何度も繰り返そうと試みます。パターンの後
ろの部分にマッチしない場合、マッチングエンジンは戻ってより少ない繰り返し
を再び試みます。

一歩ずつ例を進めていくとより明確にわかります。 正規表現 ‘a[bcd]*b’ を考
えましょう。 この正規表現は文字 ‘'a'’ 、文字クラス ‘[bcd]’ の 0 個以上の
文字、最後に来る ‘'b'’ にマッチします。 この正規表現が文字列 ‘'abcbd'’ に
対してマッチする流れを想像してみましょう。

ステップ   マッチした文    説明
           字列            
           
-----------------------------------------------------------------
                           
1          ‘a’             正規表現の ‘a’ がマッチ。
                           
                           
2          ‘abcbd’         正規表現エンジンが、文字列の終わり
                           に向かってできるだけ遠くまで
                           ‘[bcd]*’ をマッチさせる。
                           
                           
3          '失敗'          正規表現エンジンが ‘b’ でマッチを試
                           みるが、現在の位置が文字列の最後な
                           ので失敗。
                           
                           
4          ‘abcb’          ‘[bcd]*’ が一文字少なくマッチするよ
                           うに戻る。
                           
                           
5          '失敗'          再び ‘b’ にマッチするか試みるが、現
                           在の位置は最後の文字 ‘'d'’ 。
                           
                           
6          ‘abc’           ‘[bcd]*’ は ‘bc’ のみにマッチするよ
                           うに再び戻る。
                           
                           
6          ‘abcb’          再び ‘b’ を試みる。今回の現在位置の
                           文字は ‘'b'’ なので成功。
                           

正規表現の終端に達して、 ‘'abcd'’ にマッチしました。 この説明は、マッチ
ングエンジンが最初に到達できるところまで進みマッチしなかった場合、逐次戻
って再度残りの正規表現とのマッチを次々と試みること様子を示しています。 正
規表現エンジンは ‘[bcd]*’ の 0 回マッチを試すところまで戻り、その後続の
正規表現とのマッチに失敗した場合には、エンジンは正規表現と文字列が完全に
マッチしないと結論づけることになります。

別の繰り返しのメタ文字には ‘+’ があり、この特殊文字は 1 回以上の繰り返し
にマッチします。 ‘*’ と ‘+’ に違いに対しては十分注意して下さい; ‘*’ は
'0 回' 以上の繰り返しにマッチするので、繰り返す部分が全くなくても問題あ
りません。一方で ‘+’ は少なくとも '1 回' は表われる必要があります。 同様
の例を使うと ‘ca+t’ は ‘'cat'’ (‘'a'’ 1 文字)、 ‘'caaat'’ (‘'a'’ 3 文字
)、とマッチし、‘'ct'’ とはマッチしません。

繰り返しをあらわす演算子または数量子がさらに2つ存在します。クエスチョン
マーク ‘?’ は1回または0回の繰り返しにマッチします; これは、何らかの文字
やパターンがオプションであることをあらわすと考えられます。例えば、
‘home-?brew’ は ‘'homebrew'’ と ‘'home-brew'’ のいずれかにマッチします。

最も複雑な数量子は ‘{m,n}’ でしょう。ここで 'm' と 'n' は10進数の整数で
す。この数量子は繰り返しの回数が最小で 'm' 回、最大で 'n' 回であることを
意味します。例えば、 ‘a/{1,3}b’ は ‘'a/b'’, ‘'a//b'’, および ‘'a///b'’ に
マッチします。一方でスラッシュのない ‘'ab'’ やスラッシュが4つある
‘'a////b'’ にはマッチしません。

'm' か 'n' のどちらかは省略することができます; その場合は、省略された値
は合理的な値が仮定されます。 'm' の省略は下限は 0 と解釈され、'n' の省略
は上限は無限として解釈されます。

The simplest case ‘{m}’ matches the preceding item exactly 'm' times.
For example, ‘a/{2}b’ will only match ‘'a//b'’.

還元主義的傾向のある読者は、他の3つの数量子が全てこの表記を使って表現で
きることに気づくでしょう。 ‘{0,}’ は ‘*’ と同じであり、 ‘{1,}’ は ‘+’ と
等価です。また ‘{0,1}’ は ‘?’ と同じです。とはいえ、簡潔さと読みやすさの
観点から、可能であれば ‘*’, ‘+’, ‘?’ を使う方が望ましいです。


File: python.info,  Node: 正規表現を使う,  Next: パターンの能力をさらに,  Prev: 単純なパターン,  Up: 正規表現 HOWTO

9.9.3 正規表現を使う
--------------------

これまででいくつかの単純な正規表現に触れてきました、実際に Python ではこ
れらをどう使えばいいのでしょう?  *note re: a7. モジュールは正規表現エン
ジンに対するインターフェースを提供していて、それらを使うことで正規表現を
オブジェクトにコンパイルし、マッチを実行することができます。

* Menu:

* 正規表現をコンパイルする::
* バックスラッシュ感染症::
* マッチの実行::
* モジュールレベルの関数: モジュールレベルの関数<3>.
* コンパイルフラグ::


File: python.info,  Node: 正規表現をコンパイルする,  Next: バックスラッシュ感染症,  Up: 正規表現を使う

9.9.3.1 正規表現をコンパイルする
................................

正規表現はパターンオブジェクトにコンパイルされます、パターンオブジェクト
は多くの操作、パターンマッチの検索や文字列の置換の実行などのメソッドを持
っています。

     >>> import re
     >>> p = re.compile('ab*')
     >>> p
     re.compile('ab*')

*note re.compile(): ba1. はいくつかの 'flags' 引数を受け付けることができ
ます、この引数はさまざまな特別な機能を有効にしたり、構文を変化させたりし
ます。利用できる設定に何があるかは後に飛ばすことにして、簡単な例をやるこ
とにしましょう:

     >>> p = re.compile('ab*', re.IGNORECASE)

正規表現は文字列として *note re.compile(): ba1. に渡されます。正規表現は
文字列として扱われますが、それは正規表現が Python 言語のコアシステムに含
まれないためです、そのため正規表現を表わす特殊な構文はありません。 (正規
表現を全く必要としないアプリケーションも存在します、そのためそれらを含め
て言語仕様を無駄に大きくする必要はありません) その代わり、 *note re: a7.
モジュールは *note socket: b8. や *note zlib: 119. モジュールのような通
常の C 拡張モジュールとして Python に含まれています。

正規表現を文字列としておくことで Python 言語はより簡素に保たれていますが
、そのため1つの欠点があります、これについては次の節で話題とします。


File: python.info,  Node: バックスラッシュ感染症,  Next: マッチの実行,  Prev: 正規表現をコンパイルする,  Up: 正規表現を使う

9.9.3.2 バックスラッシュ感染症
..............................

先に述べたように、正規表現は特別な形式や特殊な文字の特別な意味を意味を除
くことを示すためにバックスラッシュ文字 (‘'\'’) を利用します。これは
Python が文字列リテラルに対して、同じ文字を同じ目的で使うことと衝突しま
す。

‘\section’ という文字列 (これは LaTeX ファイルでみかけます) にマッチする
正規表現を書きたいとします。どんなプログラムを書くか考え、マッチして欲し
い文字列をはじめに考えます。次に、バックスラッシュや他の特殊文字をバック
スラッシュに続けて書くことでエスケープしなければいけません、その結果
‘\\section’ のような文字列となります。こうしてできた *note re.compile():
ba1. に渡す文字列は ‘\\section’ でなければいけません。しかし、これを
Python の文字列リテラルとして扱うにはこの二つのバックスラッシュを '再び'
エスケープする必要があります。

文字                    段階
                        
-----------------------------------------------------------------------
                        
‘\section’              マッチさせるテキスト
                        
                        
‘\\section’             *note re.compile(): ba1. のためのバックスラ
                        ッシュエスケープ
                        
                        
‘"\\\\section"’         文字列リテラルのためのバックスラッシュエスケ
                        ープ
                        

要点だけをいえば、リテラルとしてのバックスラッシュにマッチさせるために、
正規表現文字列として ‘'\\\\'’ と書かなければいけません、なぜなら正規表現
は ‘\\’ であり、通常の Python の文字列リテラルとしてはそれぞれのバックス
ラッシュは ‘\\’ で表現しなければいけないからです。正規表現に関してこのバ
ックスラッシュの繰り返しの機能は、たくさんのバックスラッシュの繰り返しを
生むことになり、その結果として作られる文字列は理解することが難しくなりま
す。

この問題の解決策としては正規表現に対しては Python の raw string 記法を使
うことです; ‘'r'’ を文字列リテラルの先頭に書くことでバックスラッシュは特
別扱いされなくなります、つまり ‘"\n"’ は改行を含む1つの文字からなる文字
列であるのに対して、 ‘r"\n"’ は2つの文字 ‘'\'’ と ‘'n'’ を含む文字列とな
ります。多くの場合 Python コードの中の正規表現はこの raw string 記法を使
って書かれます。

それに加えて、正規表現では有効であるものの Python の文字列リテラルとして
は有効でない特殊文字のエスケープシーケンスは、現在では *note
DeprecationWarning: 18a. を引き起こし、最終的には *note SyntaxError:
172. となります。すなわち、そのようなシーケンスは raw string 記法を使う
か、バックスラッシュによるエスケープを使わないかぎり無効になることを意味
します。

通常の文字列            Raw string
                        
-----------------------------------------------
                        
‘"ab*"’                 ‘r"ab*"’
                        
                        
‘"\\\\section"’         ‘r"\\section"’
                        
                        
‘"\\w+\\s+\\1"’         ‘r"\w+\s+\1"’
                        


File: python.info,  Node: マッチの実行,  Next: モジュールレベルの関数<3>,  Prev: バックスラッシュ感染症,  Up: 正規表現を使う

9.9.3.3 マッチの実行
....................

一旦コンパイルした正規表現を表現するオブジェクトを作成したら、次に何をし
ますか?  パターンオブジェクトはいくつかのメソッドや属性を持っています。
ここでは、その中でも最も重要なものについて扱います; 完全なリストは *note
re: a7. ドキュメントを参照して下さい。

メソッド/属性          目的
                       
---------------------------------------------------------------------------
                       
‘match()’              文字列の先頭で正規表現とマッチするか判定します。
                       
                       
‘search()’             文字列を先頭から走査して、正規表現がどこにマッチ
                       するか調べます。
                       
                       
‘findall()’            正規表現にマッチする部分文字列を全て探しだしリス
                       トとして返します。
                       
                       
‘finditer()’           正規表現にマッチする部分文字列を全て探しだし
                       *note iterator: 191. として返します。
                       

*note match(): 225a. と *note search(): 225b. はマッチするものが見つから
なければ ‘None’ を返します。 成功すればそれらは *note Match
オブジェクト: f54. のインスタンスを返します。このオブジェクトにはマッチ
した情報が含まれます: マッチの開始と終了位置、マッチした部分文字列、など
。

You can learn about this by interactively experimenting with the *note
re: a7. module.

この HOWTO では例として標準の Python インタプリタを使います。最初に
Python インタプリタを起動して、 *note re: a7. モジュールをインポートし、
正規表現をコンパイルします:

     >>> import re
     >>> p = re.compile('[a-z]+')
     >>> p
     re.compile('[a-z]+')

さて、いろいろな文字列を使って正規表現 ‘[a-z]+’ に対するマッチングを試し
てみましょう。空の文字列は全くマッチしません、なぜなら ‘+’ は「1 回以上
の繰り返し」を意味するからです。この場合では *note match(): 225a. は
‘None’ を返すべきで、インタプタは何も出力しません。明確にするために
‘match()’ の結果を明示的に出力することもできます:

     >>> p.match("")
     >>> print(p.match(""))
     None

では、今度はマッチするはずの文字列、例えば ‘tempo’ を試してみましょう。
このケースでは、 *note match(): 225a. は *note match object: f54. を返す
ので、後で使うために結果を変数に記憶しておくべきです。

     >>> m = p.match('tempo')
     >>> m
     <re.Match object; span=(0, 5), match='tempo'>

これでマッチした文字列についての情報を *note Match オブジェクト: f54. に
問い合わせることが出来ます。 Match オブジェクトインスタンスはいくつかの
メソッドと属性も持っていて、最も重要なのは次のものです:

メソッド/属性          目的
                       
------------------------------------------------------------------------
                       
‘group()’              正規表現にマッチした文字列を返す
                       
                       
‘start()’              マッチの開始位置を返す
                       
                       
‘end()’                マッチの終了位置を返す
                       
                       
‘span()’               マッチの位置 (start, end) を含むタプルを返す
                       

これらのメソッドを試せば、その意味はすぐに理解できます:

     >>> m.group()
     'tempo'
     >>> m.start(), m.end()
     (0, 5)
     >>> m.span()
     (0, 5)

*note group(): 2270. は正規表現でマッチした部分文字列を返します。 *note
start(): 2274. と *note end(): 2275. はそれぞれ、マッチの開始インデクス
と終了インデクスを返します。 *note span(): 2276. は開始と終了のインデク
スを一つのタプルにして返します。 *note match(): 225a. メソッドは正規表現
が文字列の開始位置でマッチするかどうかだけをチェックするので、 ‘start()’
は必ずゼロを返します。 しかし、 *note search(): 225b. メソッドではパター
ンを文字列全体について走査するので、マッチの開始はゼロにならないかもしれ
ません。

     >>> print(p.match('::: message'))
     None
     >>> m = p.search('::: message'); print(m)
     <re.Match object; span=(4, 11), match='message'>
     >>> m.group()
     'message'
     >>> m.span()
     (4, 11)

実際のプログラムでは *note Match オブジェクト: f54. を変数に記憶しておき
, その次に ‘None’ なのか調べるのが一般的なスタイルです。普通このようにし
ます:

     p = re.compile( ... )
     m = p.match( 'string goes here' )
     if m:
         print('Match found: ', m.group())
     else:
         print('No match')

あるパターンにマッチするもの全てを返す Pattern インスタンスのメソッドが
2つあります。 *note findall(): 2266. はマッチした文字列のリストを返しま
す:

     >>> p = re.compile(r'\d+')
     >>> p.findall('12 drummers drumming, 11 pipers piping, 10 lords a-leaping')
     ['12', '11', '10']

この例では、文字列リテラルを raw string リテラルにするプレフィックス ‘r’
が必要です。これは、正規表現とは異なり、通常の "調理済み" 文字列リテラル
におけるエスケープシーケンスは Python では認識されないためであり、現在で
は *note DeprecationWarning: 18a. を引き起こし、最終的には *note
SyntaxError: 172. となります。詳しくは *note バックスラッシュ感染症:
4e15. を参照してください。

*note findall(): 2266. は結果を返す前に完全なリストを必ず生成してしまい
ます。いっぽう *note finditer(): 2267. メソッドは *note
マッチオブジェクト: f54. インスタンスのシーケンスを *note iterator: 191.
として返します:

     >>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')
     >>> iterator
     <callable_iterator object at 0x...>
     >>> for match in iterator:
     ...     print(match.span())
     ...
     (0, 2)
     (22, 24)
     (29, 31)


File: python.info,  Node: モジュールレベルの関数<3>,  Next: コンパイルフラグ,  Prev: マッチの実行,  Up: 正規表現を使う

9.9.3.4 モジュールレベルの関数
..............................

パターンオブジェクトを作ってそのメソッドを呼び出す、とする必要は必ずしも
ありません。 *note re: a7. モジュールはトップレベルの関数として *note
match(): 11fe, *note search(): 11fd, *note findall(): ff4, *note sub():
283. などを用意しています。これら関数は、対応するメソッドの最初の引数に
RE が追加されただけで後は同じで、 ‘None’ か *note Match オブジェクト:
f54. インスタンスを返すのも同じです:

     >>> print(re.match(r'From\s+', 'Fromage amk'))
     None
     >>> re.match(r'From\s+', 'From amk Thu May 14 19:12:10 1998')
     <re.Match object; span=(0, 5), match='From '>

内部的には、これら関数は単にあなたのためにパターンオブジェクトを生成し、
対応するメソッドを呼び出すだけのことです。とともに、将来の呼び出しで同じ
RE のパースが何度も何度も必要とならないよう、コンパイル済みオブジェクト
はキャッシュされます。

これらモジュールレベル関数を使うのと、パターンを自身で作って自身で呼び出
すのとでどちらを使うべきでしょう?  正規表現をループの内側で使うならば、
プリコンパイルは関数呼び出しを減らします。ループの外側であれば、内部キャ
ッシュのおかげで、どちらでも大差ありません。


File: python.info,  Node: コンパイルフラグ,  Prev: モジュールレベルの関数<3>,  Up: 正規表現を使う

9.9.3.5 コンパイルフラグ
........................

コンパイルフラグは正規表現の動作をいくつかの側面から変更します。フラグは
*note re: a7. モジュール下で二つの名前で利用することができます、例えば長
い名前は *note IGNORECASE: 168c. で短い名前は1文字で *note I: 224c. のよ
うになっています。 (1文字形式は Perl のパターン修飾子と同じ形式を使いま
す; 例えば *note re.VERBOSE: 2258. の短かい形式は *note re.X: 2251. です
。) 複数のフラグが OR ビット演算で指定することができます; 例えば ‘re.I |
re.M’ は *note I: 224c. と *note M: 224e. フラグの両方を設定します。

ここに利用可能なフラグの表があります、それぞれについてのより詳細な説明が
後に続きます。

Flag                                  意味
                                      
---------------------------------------------------------------------------------------
                                      
*note ASCII: 5f8, *note A: 224b.      ‘\w’, ‘\b’, ‘\s’, そして ‘\d’ などをそれぞれの
                                      プロパティをもつ ASCII 文字だけにマッチさせま
                                      す。
                                      
                                      
*note DOTALL: 2248, *note S: 224f.    ‘.’ を改行を含む任意の文字にマッチするようにし
                                      ます。
                                      
                                      
*note IGNORECASE: 168c,               大文字小文字を区別しないマッチを行います。
*note I: 224c.                        

*note LOCALE: b3a, *note L: 224d.     ロケールに対応したマッチを行います。
                                      
                                      
*note MULTILINE: 2249,                ‘^’ や ‘$’ の意味を変更し、複数行文字列に対す
*note M: 224e.                        るマッチングを行います。
                                      
                                      
*note VERBOSE: 2258, *note X: 2251.   冗長な正規表現を利用できるようにして、よりきれ
('X' は 'extended' の 'X')            いで理解しやすくまとめることができます。
                                      

 -- データ: re.I

 -- データ: re.IGNORECASE

     大文字と小文字を区別しないマッチングを実行します; 文字クラスと文字
     列リテラルは大文字か小文字かに関係なくパターンにマッチします。例え
     ば、 ‘[A-Z]’ は小文字のアルファベットにもマッチします。 *note
     ASCII: 5f8. フラグによって非 ASCII 文字のマッチングが無効化されてい
     なければ、完全なユニコードのマッチングも可能です。ユニコードで
     ‘[a-z]’ または ‘[A-Z]’ が *note IGNORECASE: 168c. フラグとともに使
     われると、 52個の ASCII 文字に加えて 次の4つの 非 ASCII 文字にマッ
     チします: 'İ' (U+0130, ラテン語の大文字 I で、上部に点がついたもの
     ), 'ı' (U+0131, ラテン語の小文字 i で上部に点がない), 'ſ' (U+017F,
     ラテン語の小文字 s), 'K' (U+212A, ケルビン記号)。 ‘Spam’ は
     ‘'Spam'’, ‘'spam'’, ‘'spAM'’, そして ‘'ſpam'’ にマッチします (ただ
     し最後の文字列はユニコードモードの場合のみマッチします)。この「小文
     字化」は現在のロケールを考慮しません; ただし *note LOCALE: b3a. フ
     ラグをセットした場合はロケールを考慮します。

 -- データ: re.L

 -- データ: re.LOCALE

     ‘\w’, ‘\W’, ‘\b’, ‘\B’ と小文字大文字の区別を無視したマッチングを、
     Unicode データベースではなく現在のロケールに従って行います。

     ロケールは言語の違いを考慮したプログラムを書くことを手助けすること
     を目的とした C ライブラリの機能です。例えば、エンコードされたフラン
     ス語のテキストを処理していて、‘\w+’ を使って単語のマッチを行いたい
     とします。ですがこの場合、 ‘\w’ はバイトパターンにおいて文字クラス
     ‘[A-Za-z]’ だけにマッチします; すなわち ‘é’ や ‘ç’ に対応するバイト
     列にはマッチしません。もしシステムが適切に設定されていて、ロケール
     がフランス語に設定されていれば、ある C 関数はプログラムに ‘é’ に対
     応するバイト列も文字として考慮するべきであると伝えます。正規表現を
     コンパイルするときに *note LOCALE: b3a. フラグを設定すると、コンパ
     イルされたオブジェクトが ‘\w’ に対してロケールを考慮する C 関数を使
     うようになります; これにより処理は遅くなりますが、 ‘\w+’ を期待通り
     フランス語の単語にマッチさせることが可能になります。このフラグを
     Python 3 で利用することは推奨されません。なぜならロケールの仕組みは
     非常に信頼性が低く、同時にひとつの "文化" しか扱うことができず、ま
     た8ビットのロケールでしか正しく動作しないからです。Python 3 ではユ
     ニコード (文字列の) パターンに対してユニコードのマッチングがデフォ
     ルトで有効化されており、これにより異なるロケールまたは言語を同時に
     扱うことができます。

 -- データ: re.M

 -- データ: re.MULTILINE

     (‘^’ と ‘$’ についてはまだ説明していません; これらは *note
     さらなる特殊文字: 4e19. の節で説明します。)

     通常 ‘^’ は文字列の先頭にマッチし、 ‘$’ は文字列の末尾と文字列の末
     尾に改行(があれば)その直前にマッチします。このフラグが指定されると
     、 ‘^’ は文字列の先頭と文字列の中の改行に続く各行の先頭にマッチしま
     す。同様に ‘$’ 特殊文字は文字列の末尾と各行の末尾(各改行の直前)のど
     ちらにもマッチします。

 -- データ: re.S

 -- データ: re.DOTALL

     特別な文字 ‘'.'’ を改行を含む全ての任意の文字とマッチするようにしま
     す; このフラグが無しでは、 ‘'.'’ は改行 '以外' の全てにマッチします
     。

 -- データ: re.A

 -- データ: re.ASCII

     ‘\w’, ‘\W’, ‘\b’, ‘\B’, ‘\s’, ‘\S’ が、完全な Unicode マッチングで
     はなく、ASCII のみのマッチングをするようにします。これは Unicode パ
     ターンにのみ意味があり、byte パターンには無視されます。

 -- データ: re.X

 -- データ: re.VERBOSE

     このフラグはより柔軟な形式で正規表現を読み易く書けるようにします。
     このフラグを指定すると、正規表現の中の空白は無視されます、ただし、
     文字クラス内やエスケープされていないバックスラッシュに続く空白の場
     合は例外として無視されません; これによって正規表現をまとめたり、イ
     ンデントしてより明確にすることができます。このフラグはさらにエンジ
     ンが無視するコメントを追加することもできます; コメントは ‘'#'’ で示
     します、これは文字クラスやエスケープされていないバックスラッシュに
     続くものであってはいけません。

     例えば、ここに *note re.VERBOSE: 2258. を利用した正規表現があります
     ; 読み易いと思いませんか?

          charref = re.compile(r"""
           &[#]                # Start of a numeric entity reference
           (
               0[0-7]+         # Octal form
             | [0-9]+          # Decimal form
             | x[0-9a-fA-F]+   # Hexadecimal form
           )
           ;                   # Trailing semicolon
          """, re.VERBOSE)

     冗長な表現を利用しない設定の場合、正規表現はこうなります:

          charref = re.compile("&#(0[0-7]+"
                               "|[0-9]+"
                               "|x[0-9a-fA-F]+);")

     上の例では、Python の文字列リテラルの自動結合によって正規表現を小さ
     な部分に分割しています、それでも *note re.VERBOSE: 2258. を使った場
     合に比べるとまだ難しくなっています。


File: python.info,  Node: パターンの能力をさらに,  Next: 文字列を変更する,  Prev: 正規表現を使う,  Up: 正規表現 HOWTO

9.9.4 パターンの能力をさらに
----------------------------

ここまでで、正規表現の機能のほんの一部を扱ってきました。この節では、新た
にいくつかの特殊文字とグループを使ってマッチしたテキストの一部をどう取得
するかについて扱います。

* Menu:

* さらなる特殊文字::
* グルーピング::
* 取り出さないグループと名前つきグループ::
* 先読みアサーション (Lookahead Assertions): 先読みアサーション Lookahead Assertions.


File: python.info,  Node: さらなる特殊文字,  Next: グルーピング,  Up: パターンの能力をさらに

9.9.4.1 さらなる特殊文字
........................

これまでで、まだ扱っていない特殊文字がいくつかありました。そのほとんどを
この節で扱っていきます。

残りの特殊文字の内いくつかは 'ゼロ幅アサーション zero-width-assertions'
に関するものです。これらは文字列に対してエンジンを進めません; 文字列を全
く利用しない代わりに、単純に成功か失敗かを利用します。例えば、 ‘\b’ は現
在位置が単語の境界であることを示します; ‘\b’ によってエンジンの読んでい
る位置は全く変化しません。つまり、これはゼロ幅アサーションは繰り返し使う
ことがありません、一度ある位置でマッチしたら、明らかに無限回マッチできま
す。

‘|’

     代替 (alternation) または "or" 演算子です。 'A' と 'B' が正規表現の
     場合、 ‘A|B’ は 'A' と 'B' のどちらかにマッチするような文字列にマッ
     チします。複数の文字からなる文字列による代替処理が適切に動作するた
     めに、 ‘|’ の優先度は非常に低く設定されています。 ‘Crow|Servo’ は
     ‘'Crow'’ か ‘'Servo'’ のどちらかにマッチするパターンであり、 「
     ‘'Cro'’ に続いて ‘'w'’ または ‘'S'’ があり、さらに ‘'ervo'’ が続く
     」という意味ではありません。

     リテラル ‘'|'’ にマッチするには、 ‘\|’ を利用するか、 ‘[|]’ のよう
     に文字クラス内に収めて下さい。

‘^’

     行の先頭にマッチします。 *note MULTILINE: 2249. フラグが設定されな
     い場合には、文字列の先頭にのみマッチします。 *note MULTILINE: 2249.
     モードでは文字列内の各改行の直後にマッチします。

     例えば、行の先頭の ‘From’ にのみマッチさせたい場合には ‘^From’ 正規
     表現を利用します。

          >>> print(re.search('^From', 'From Here to Eternity'))
          <re.Match object; span=(0, 4), match='From'>
          >>> print(re.search('^From', 'Reciting From Memory'))
          None

     リテラル ‘'^'’ にマッチするには ‘\^’ を利用してください。

‘$’

     行の末尾にマッチします、行の末尾は文字列の末尾と改行文字の直前とし
     て定義されます。

          >>> print(re.search('}$', '{block}'))
          <re.Match object; span=(6, 7), match='}'>
          >>> print(re.search('}$', '{block} '))
          None
          >>> print(re.search('}$', '{block}\n'))
          <re.Match object; span=(6, 7), match='}'>

     リテラル ‘'$'’ にマッチするには、 ‘\$’ を利用するか、 ‘[$]’ のよう
     に文字クラス内に収めて下さい。

‘\A’

     文字列の先頭にのみマッチします。 *note MULTILINE: 2249. モードでな
     い場合には ‘\A’ と ‘^’ は実質的に同じです。 *note MULTILINE: 2249.
     モードでのこれらの違いは: ‘\A’ は依然として文字列の先頭にのみマッチ
     しますが、 ‘^’ は文字列内に改行文字に続く部分があればそこにマッチす
     ることです。

‘\Z’

     文字列の末尾でのみマッチします。

‘\b’

     単語の境界。これはゼロ幅アサーションで、単語の始まりか終わりにのみ
     マッチします。単語は英数文字のシーケンスとして定義されます、つまり
     単語の終わりは空白か非英数文字として表われます。

     以下の例では ‘class’ がそのものの単語のときのみマッチします; 別の単
     語内に含まれている場合はマッチしません。

          >>> p = re.compile(r'\bclass\b')
          >>> print(p.search('no class at all'))
          <re.Match object; span=(3, 8), match='class'>
          >>> print(p.search('the declassified algorithm'))
          None
          >>> print(p.search('one subclass is'))
          None

     この特殊シーケンスを利用するときには二つの微妙な点を心にとめておく
     必要があります。まずひとつめは Python の文字列リテラルと表現の間の
     最悪の衝突を引き起すことです。Python の文字列リテラルでは ‘\b’ は
     ASCII 値8のバックスペース文字です。raw string を利用していない場合
     、Python は ‘\b’ をバックスペースに変換し、正規表現は期待するものと
     マッチしなくなります。以下の例はさきほどと同じ正規表現のように見え
     ますが、正規表現文字列の前の ‘'r'’ が省略されています。

          >>> p = re.compile('\bclass\b')
          >>> print(p.search('no class at all'))
          None
          >>> print(p.search('\b' + 'class' + '\b'))
          <re.Match object; span=(0, 7), match='\x08class\x08'>

     ふたつめはこのアサーションが利用できない文字列クラスの内部では
     Python の文字列リテラルとの互換性のために、 ‘\b’ はバックスペース文
     字を表わすことになるということです。

‘\B’

     別のゼロ幅アサーションで、 ‘\b’ と逆で、現在の位置が単語の境界でな
     いときにのみマッチします。


File: python.info,  Node: グルーピング,  Next: 取り出さないグループと名前つきグループ,  Prev: さらなる特殊文字,  Up: パターンの能力をさらに

9.9.4.2 グルーピング
....................

正規表現にマッチするかどうかだけでなく、より多くの情報を得なければいけな
い場合は多々あります。正規表現はしばしば、正規表現をいくつかのサブグルー
プに分けて興味ある部分にマッチするようにして、文字列を分割するのに使われ
ます。例えば、RFC-822 ヘッダ行は ‘':'’ を挟んでこのようにヘッダ名と値に
分割されます:

     From: author@example.com
     User-Agent: Thunderbird 1.5.0.9 (X11/20061227)
     MIME-Version: 1.0
     To: editor@example.com

これはヘッダ全体にマッチし、そしてヘッダ名にマッチするグループとヘッダの
値にマッチする別のグループを持つように正規表現を書くことで扱うことができ
ます。

グループはメタ文字 ‘'('’ と ‘')'’ であらわされます。 ‘'('’ と ‘')'’ は数
式における意味とほぼ同じ意味を持っています; その中に含まれる表現をひとま
とまりにし、それらに対して ‘*’, ‘+’, ‘?’, または ‘{m,n}’ のような数量子
を使った繰り返しを表現することもできます。例えば、 ‘(ab)*’ は ‘ab’ の0回
以上の繰り返しにマッチします。

     >>> p = re.compile('(ab)*')
     >>> print(p.match('ababababab').span())
     (0, 10)

‘'('’, ‘')'’ で指示されたグループは、マッチしたテキスト開始と終了位置も
キャプチャします; *note group(): 2270, *note start(): 2274, *note end():
2275, *note span(): 2276. に引数を与えて取り出せます。グループはゼロ始ま
りの数値です。グループ 0 は常に使えます; それは RE でマッチした全体で、
*note Match オブジェクト: f54. メソッドの全てはグループ 0 をデフォルト引
数にしています。マッチするテキストの範囲をキャプチャしないグループの書き
方はのちほど見ることにします。

     >>> p = re.compile('(a)b')
     >>> m = p.match('ab')
     >>> m.group()
     'ab'
     >>> m.group(0)
     'ab'

サブグループは左から右へ1づつ番号付けされます。グループはネストしてもか
まいません; 番号を決めるには、単に開き括弧を左から右へ数え上げます。

     >>> p = re.compile('(a(b)c)d')
     >>> m = p.match('abcd')
     >>> m.group(0)
     'abcd'
     >>> m.group(1)
     'abc'
     >>> m.group(2)
     'b'

*note group(): 2270. には一回に複数の引数を渡してもかまいません、その場
合にはそれらのグループに対応する値を含むタプルを返します。

     >>> m.group(2,1,2)
     ('b', 'abc', 'b')

*note groups(): 2272. メソッドは 1 から全てのサブグループの文字列を含む
タプルを返します。:

     >>> m.groups()
     ('abc', 'b')

パターン中で後方参照を利用することで、前に取り出されたグループが文字列の
中の現在位置で見つかるように指定できます。例えば、‘\1’ はグループ1の内容
が現在位置で見つかった場合成功し、それ以外の場合に失敗します。Python の
文字列リテラルでもバックスラッシュに続く数字は任意の文字を文字列に含める
ために使われるということを心に留めておいて下さい、そのため正規表現で後方
参照を含む場合には raw string を必ず利用して下さい。

例えば、以下の正規表現は二重になった単語を検出します。

     >>> p = re.compile(r'\b(\w+)\s+\1\b')
     >>> p.search('Paris in the the spring').group()
     'the the'

このような後方参照は文字列を検索するだけの用途では多くの場合役に立ちませ
ん。-- このように繰り返されるテキストフォーマットは少数です。-- しかし、
文字列の置換をする場合には 'とても' 有効であることに気づくでしょう。


File: python.info,  Node: 取り出さないグループと名前つきグループ,  Next: 先読みアサーション Lookahead Assertions,  Prev: グルーピング,  Up: パターンの能力をさらに

9.9.4.3 取り出さないグループと名前つきグループ
..............................................

念入りに作られた正規表現は多くのグループを利用します、その利用法には対象
となる部分文字列を取り出す、正規表現自身をグループ化したり構造化する、と
いう二つの方法があります。複雑な正規表現では、グループ番号を追っていくこ
とは困難になっていきます。この問題の解決を助ける二つの機能があります。そ
の両方が正規表現を拡張するための一般的な構文を利用します、まずはそれらを
みてみましょう。

Perl 5 は標準正規表現にパワフルな拡張を加えたことでよく知られています。
それらの新しい機能のために Perl 開発者たちは、Perl正規表現と標準正規表現
との混乱を招く違いなしには、新たな一文字メタキャラクタも ‘\’ ではじまる
新たな特殊シーケンスもどちらも選択出来ませんでした。たとえば彼らがもし
‘&’ を新たなメタキャラクタとして選んでいたら、 ‘&’ が通常文字とみなされ
ていた古い正規表現は ‘\&’ や ‘[&]’ のように書くことでエスケープされなけ
ればならなかったでしょう。

解決策として Perl 開発者が選んだものは ‘(?...)’ を正規表現構文として利用
することでした。括弧の直後の ‘?’ は構文エラーとなります、これは ‘?’ で繰
り返す対象がないためです、そのためこれは互換性の問題を持ち込みません。
‘?’ の直後の文字はどの拡張が利用されるかを示しています、つまり、
‘(?=foo)’ は一つの拡張を利用したもの (肯定先読みアサーション) となり、
‘(?:foo)’ は別の拡張を利用した表現(‘foo’ を含む取り込まないグループ)とな
ります。

Python は Perl の拡張のいくつかをサポートし、また、Perl の拡張に一つ拡張
を加えています。クエスチョンマークに続く最初の文字が ‘P’ のものは、そう
です、Python 固有の拡張です。

一般化された拡張構文についてはわかりましたので、いよいよ複雑な正規表現内
でのグループの扱いを単純化する機能に話を戻しましょう。

ときとしてあなたは、正規表現の一部として使いたいけれども、その内容を取り
出すことに興味がないようなグループを記述する必要に迫られます。このために
は、取り出さないグループ: ‘(?:...)’ を使います。 ‘...’ 部分は任意の正規
表現です。

     >>> m = re.match("([abc])+", "abc")
     >>> m.groups()
     ('c',)
     >>> m = re.match("(?:[abc])+", "abc")
     >>> m.groups()
     ()

マッチしたグループの内容を取得しないということを除けば、取り込まないグル
ープは厳密に取り込むグループと同様に振る舞います; この中に何を入れてもか
まいません、 ‘*’ のような繰り返しの特殊文字で繰り返したり、他のグループ
(取り込むまたは取り込まない) の入れ子にすることもでいます。 ‘(?:...)’ は
特に、既にあるパターンを変更する際に便利です、なぜなら他の番号づけ新しい
グループを変更することなく新しいグループを追加することができます。取り込
むグループと取り込まないグループで検索のパフォーマンスに差がないことにも
触れておくべきことです; どちらも同じ速度で動作します。

より重要な機能は名前つきグループです: 番号で参照する代わりに、グループに
対して名前で参照できます。

名前つきグループのための構文は、 Python 固有拡張の一つ: ‘(?P<name>...)’
を使います。 'name' は、もちろん、グループの名前です。名前つきグループは
取り込むグループと完全に同じに振る舞い、加えて名前が関連付けられます。
*note Match オブジェクト: f54. の取りこむグループを扱うメソッドは全て、
番号によるグループ参照のための整数、名前によるグループ参照のための文字列
、ともに許容しています。名前つきグループにも番号が振られますので、グルー
プについての情報を、2つの方法で取り出せます:

     >>> p = re.compile(r'(?P<word>\b\w+\b)')
     >>> m = p.search( '(((( Lots of punctuation )))' )
     >>> m.group('word')
     'Lots'
     >>> m.group(1)
     'Lots'

さらに、名前付きのグループを *note groupdict(): 2273. を使って辞書として
取り出すこともできます:

     >>> m = re.match(r'(?P<first>\w+) (?P<last>\w+)', 'Jane Doe')
     >>> m.groupdict()
     {'first': 'Jane', 'last': 'Doe'}

名前つきグループは、番号を覚える代わりに簡単に覚えられる名前で管理できる
ため、便利です。以下は *note imaplib: 6a. モジュールで使われている正規表
現の例です:

     InternalDate = re.compile(r'INTERNALDATE "'
             r'(?P<day>[ 123][0-9])-(?P<mon>[A-Z][a-z][a-z])-'
             r'(?P<year>[0-9][0-9][0-9][0-9])'
             r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'
             r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
             r'"')

取得する番号9を覚えるよりも、 ‘m.group('zonem')’ で取得した方が明らかに
簡単にすみます。

後方参照のための構文 ‘(...)\1’ はグループ番号への参照となっています。 グ
ループ番号の代わりに、グループ名を利用する変種があるのは当然でしょう。 こ
れはもう一つの Python 拡張です: ‘(?P=name)’ は、 'name' という名前のグル
ープの内容が、現在の位置で再びマッチすることを示しています。 同じ単語が
2つ連なっているのを見つける正規表現 ‘\b(\w+)\s+\1\b’ は
‘\b(?P<word>\w+)\s+(?P=word)\b’ のように書けます:

     >>> p = re.compile(r'\b(?P<word>\w+)\s+(?P=word)\b')
     >>> p.search('Paris in the the spring').group()
     'the the'


File: python.info,  Node: 先読みアサーション Lookahead Assertions,  Prev: 取り出さないグループと名前つきグループ,  Up: パターンの能力をさらに

9.9.4.4 先読みアサーション (Lookahead Assertions)
.................................................

他のゼロ幅アサーションは先読みアサーションです。先読みアサーションは肯定
、否定の両方の形式が利用可能です、これを見てください:

‘(?=...)’

     肯定先読みアサーション。 ‘...’ で表わす正規表現が現在位置でマッチす
     れば成功し、それ以外の場合失敗します。しかし、表現が試行された場合
     でもエンジンは先に進みません; パターンの残りの部分はアサーションの
     開始時点から右に試行します。

‘(?!...)’

     否定先読みアサーション。これは肯定アサーションの逆で、正規表現が文
     字列の現在位置にマッチ 'しなかった' 場合に成功します。

より具体的にするため、先読みが便利な場合をみてみましょう。ファイル名にマ
ッチし、 ‘.’ で分けられた基本部分と拡張子に分離する単純なパターンを考え
ましょう。例えば、 ‘news.rc’ は ‘news’ が基本部分で ‘rc’ がファイル名の
拡張子です。

マッチするパターンはとても単純です:

‘.*[.].*$’

‘.’ はメタキャラクタですので特別に扱わなければなりませんから、文字クラス
内に入れて、そのものとだけマッチするようにしていることに注目です。末尾の
‘$’ にも注目してください; これは残り全ての文字列が拡張子に含まれるべきで
あることを保障するために追加しています。この正規表現は ‘foo.bar’,
‘autoexec.bat’, ‘sendmail.cf’, ‘printers.conf’ にマッチします。

さて、問題を少し複雑にしてみましょう; 拡張子が ‘bat’ でないファイル名に
マッチしたい場合はどうでしょう？間違った試み:

‘.*[.][^b].*$’ この最初の ‘bat’ を除く試みは、最初の文字が ‘b’ でないこ
とを要求します。これは誤っています、なぜなら ‘foo.bar’ にもマッチしない
からです。

‘.*[.]([^b]..|.[^a].|..[^t])$’

正規表現が混乱してきました。最初の解決策を取り繕って、以下の場合に合わせ
ることを要求しています: 拡張子の最初の文字は ‘b’ でなく; 二番目の文字は
‘a’ でなく; 三番目の文字は ‘t’ でない。これは ‘foo.bar’ を受け付けますが
、 ‘autoexec.bat’ は拒否します。しかし、三文字の拡張子を要求し、
‘sendmail.cf’ のような二文字の拡張子を受け付けません。これを修正するのに
パターンを再び複雑にすることになります。

‘.*[.]([^b].?.?|.[^a]?.?|..?[^t]?)$’

三番目の試みでは、 ‘sendmail.cf’ のように三文字より短い拡張子とマッチす
るために第二第三の文字を全てオプションにしています。

パターンはさらに複雑さを増し、読みにくく、理解が難しくなりました。より悪
いことに、問題が ‘bat’ と ‘exe’ 両方を拡張子から除きたい場合に変わった場
合、パターンはより複雑で混乱しやすいものになります。

否定先読みはこの混乱全てを取り除きます:

‘.*[.](?!bat$)[^.]*$’ 否定先読みは以下を意味します: この位置で拡張子
‘bat’ にマッチしない場合、残りのパターンが試行されます; もし ‘bat$’ にマ
ッチすればパターン全体が失敗します。‘$’ を続けることで、‘sample.batch’ に
ように ‘bat’ で始まる拡張子を許容することを保証しています。 このパターン
で ‘[^.]*’ を使うことで、ファイル名に複数のドットがあったときにも上手く
いくようになります。

他のファイル名の拡張子を除くことも簡単です; 単純にアサーション内に拡張子
を代替 (or) で加えます。以下のパターンは ‘bat’ や ‘exe’ のどちらかで終わ
るファイル名を除外します:

‘.*[.](?!bat$|exe$)[^.]*$’


File: python.info,  Node: 文字列を変更する,  Next: よくある問題,  Prev: パターンの能力をさらに,  Up: 正規表現 HOWTO

9.9.5 文字列を変更する
----------------------

ここまででは単純に静的な文字列に対する検索を実行してきました。正規表現は
文字列を様々な方法で変更するのにもよく使われます。変更には以下のパターン
メソッドが利用されます:

メソッド/属性          目的
                       
---------------------------------------------------------------------------
                       
‘split()’              文字列をリストに分割する、正規表現がマッチした全
                       ての場所で分割を行う
                       
                       
‘sub()’                正規表現にマッチした全ての文字列を発見し、別の文
                       字列に置き換えます
                       
                       
‘subn()’               ‘sub()’ と同じことをしますが、新しい文字列と置き
                       換えの回数を返します
                       

* Menu:

* 文字列の分割::
* 検索と置換: 検索と置換<2>.


File: python.info,  Node: 文字列の分割,  Next: 検索と置換<2>,  Up: 文字列を変更する

9.9.5.1 文字列の分割
....................

‘split()’ メソッドは文字列を正規表現にマッチした場所で分割し、リストで返
却します。文字列の *note split(): e73. メソッドに似てはいますが、もっと
ずっと一般化したデリミタで分割出来ます; 文字列の ‘split()’ メソッドは単
に空白文字か固定文字列で分割出来るだけです。ご想像通り、モジュールレベル
の *note re.split(): 282. 関数もあります。

 -- メソッド: .split (string[, maxsplit=0])

     'string' を正規表現のマッチで分割します。正規表現内に取り込むための
     括弧が利用されている場合、その内容も結果のリストの一部として返され
     ます。 'maxsplit' が非ゼロの場合、最大で 'maxsplit' の分割が実行さ
     れます。

'maxsplit' に値を渡すことで、分割される回数を制限することができます。
'maxsplit' が非ゼロの場合、最大で 'maxsplit' の分割が行なわれ、文字列の
残りがリストの最終要素として返されます。以下の例では、デリミタは任意の英
数文字のシーケンスです。

     >>> p = re.compile(r'\W+')
     >>> p.split('This is a test, short and sweet, of split().')
     ['This', 'is', 'a', 'test', 'short', 'and', 'sweet', 'of', 'split', '']
     >>> p.split('This is a test, short and sweet, of split().', 3)
     ['This', 'is', 'a', 'test, short and sweet, of split().']

興味の対象がデリミタの間のテキストだけでなく、デリミタが何なのかというこ
とを知りたい場合はよくあります。取りこみ用の括弧を正規表現に使った場合、
その値もリストの一部として返されます。以下の呼び出しを比較してみましょう
:

     >>> p = re.compile(r'\W+')
     >>> p2 = re.compile(r'(\W+)')
     >>> p.split('This... is a test.')
     ['This', 'is', 'a', 'test', '']
     >>> p2.split('This... is a test.')
     ['This', '... ', 'is', ' ', 'a', ' ', 'test', '.', '']

モジュールレベル関数 *note re.split(): 282. は最初の引数に利用する正規表
現を追加しますが、それ以外は同じです。

     >>> re.split(r'[\W]+', 'Words, words, words.')
     ['Words', 'words', 'words', '']
     >>> re.split(r'([\W]+)', 'Words, words, words.')
     ['Words', ', ', 'words', ', ', 'words', '.', '']
     >>> re.split(r'[\W]+', 'Words, words, words.', 1)
     ['Words', 'words, words.']


File: python.info,  Node: 検索と置換<2>,  Prev: 文字列の分割,  Up: 文字列を変更する

9.9.5.2 検索と置換
..................

もう一つのよくある作業は、パターンにマッチする全ての文字列を探し、異なる
文字列に置換します。 *note sub(): 2268. メソッドは置換する値をとります、
文字列と関数の両方をとることができ、文字列を処理します。

 -- メソッド: .sub (replacement, string[, count=0])

     'string' 内で最も長く、他の部分と重複するところがない正規表現を
     'replacement' に置換した文字列を返します。パターンが見つからなかっ
     た場合 'string' は変更されずに返されます。

     オプション引数 'count' はパターンの出現の最大置換回数です; 'count'
     は非負の整数でなければいけません。デフォルト値 0 は全ての出現で置換
     することを意味します。

ここに *note sub(): 2268. メソッドを使った単純な例があります。これは色の
名前を ‘colour’ に置換します:

     >>> p = re.compile('(blue|white|red)')
     >>> p.sub('colour', 'blue socks and red shoes')
     'colour socks and colour shoes'
     >>> p.sub('colour', 'blue socks and red shoes', count=1)
     'colour socks and red shoes'

*note subn(): 2269. メソッドも同じ働きをしますが、新しい文字列と置換の実
行回数を含む 2-タプルを返します:

     >>> p = re.compile('(blue|white|red)')
     >>> p.subn('colour', 'blue socks and red shoes')
     ('colour socks and colour shoes', 2)
     >>> p.subn('colour', 'no colours at all')
     ('no colours at all', 0)

空文字列とのマッチは、直前の空文字列とマッチした部分と隣接していない場合
にのみ置換されます。

     >>> p = re.compile('x*')
     >>> p.sub('-', 'abxd')
     '-a-b--d-'

'replacement' が文字列の場合、文字列内のバックスラッシュエスケープは処理
されます。つまり、‘\n’ は改行文字に ‘\r’ はキャリッジリターンに、等とな
ります。‘\&’ のような未知のエスケープシーケンスはそのまま残されます。
‘\6’ のような後方参照は正規表現内の対応するグループにマッチする文字列に
置換されます。これを使うことで元のテキストの一部を、置換後の文字列に組み
込むことができます。

この例は単語 ‘section’ に続く ‘{’ と ‘}’ で閉じられた文字列にマッチし、
‘section’ を ‘subsection’ に変更します:

     >>> p = re.compile('section{ ( [^}]* ) }', re.VERBOSE)
     >>> p.sub(r'subsection{\1}','section{First} section{second}')
     'subsection{First} subsection{second}'

‘(?P<name>...)’ 構文で定義された名前つきグループを参照するための構文もあ
ります。 ‘\g<name>’ は ‘name’ で名前づけされたグループにマッチする文字列
を利用し、 ‘\g<number>’ は対応するグループ番号を利用します。つまり
‘\g<2>’ は ‘\2’ と等価ですが、 ‘\g<2>0’ のような置換文字列に対しては明確
に異なります。 (‘\20’ はグループ番号20への参照と解釈され、グループ2の後
にリテラル文字 ‘'0'’ が続くとは解釈されません。) 以下に示す置換は全て等
価ですが、これらは文字列置換に全部で3種の変種を利用しています。

     >>> p = re.compile('section{ (?P<name> [^}]* ) }', re.VERBOSE)
     >>> p.sub(r'subsection{\1}','section{First}')
     'subsection{First}'
     >>> p.sub(r'subsection{\g<1>}','section{First}')
     'subsection{First}'
     >>> p.sub(r'subsection{\g<name>}','section{First}')
     'subsection{First}'

より細かな制御を手中にするために 'replacement' として関数を使うことが出
来ます。 'replacement' が関数であれば、その関数は重なり合わない
'pattern' の発生のたびに呼び出されます。それぞれの呼び出しで、マッチした
*note Match オブジェクト: f54. が引数として渡されるので、望みの置換と返
却のためにこの情報を利用出来ます。

続く例では、置換関数は十進数文字列を十六進数文字列に変換しています:

     >>> def hexrepl(match):
     ...     "Return the hex string for a decimal number"
     ...     value = int(match.group())
     ...     return hex(value)
     ...
     >>> p = re.compile(r'\d+')
     >>> p.sub(hexrepl, 'Call 65490 for printing, 49152 for user code.')
     'Call 0xffd2 for printing, 0xc000 for user code.'

モジュールレベルの *note re.sub(): 283. 関数を使うときには、パターンが最
初の引数として渡されます。パターンはオブジェクトや文字列をとります; 正規
表現フラグを指定する必要がある場合、パターンオブジェクトを最初の引数とし
て使うか、修飾子を埋め込んだパターン文字列を使うかしなければいけません、
例えば ‘sub("(?i)b+", "x", "bbbb BBBB")’ は ‘'x x'’ を返します。


File: python.info,  Node: よくある問題,  Next: フィードバック,  Prev: 文字列を変更する,  Up: 正規表現 HOWTO

9.9.6 よくある問題
------------------

正規表現はいくつかの応用に対して強力なツールですが、いくつかの部分でそれ
らの振る舞いは直感的ではなく、期待通りに振る舞わないことがあります。この
節では最もよくある落とし穴を指摘します。

* Menu:

* 文字列メソッドを利用する::
* match() 対 search(): match 対 search.
* 貪欲 (greedy) 対非貪欲 (non-greedy): 貪欲 greedy 対非貪欲 non-greedy.
* re.VERBOSE の利用: re VERBOSE の利用.


File: python.info,  Node: 文字列メソッドを利用する,  Next: match 対 search,  Up: よくある問題

9.9.6.1 文字列メソッドを利用する
................................

いくつかの場合 *note re: a7. モジュールを利用することは間違いである場合
があります。固定文字列や単一の文字クラスにマッチさせる場合や、 *note
IGNORECASE: 168c. フラグのような *note re: a7. の機能を利用しない場合、
正規表現の全ての能力は必要とされていなでしょう。文字列は固定文字列に対す
る操作を実行するメソッドを持っていて、大きな汎用化された正規表現エンジン
ではなく、目的のために最適化された単一の小さな C loop で実装されているた
め、大抵の場合高速です.

一つの例としては、単一の固定文字列を別の固定文字列に置き換える作業がある
でしょう; 例えば ‘word’ を ‘deed’ で置換したい場合です。 *note re.sub():
283. はこの目的で使う関数のように思えますが、 *note replace(): 17f. メソ
ッドを利用することを考えた方がいいでしょう。 ‘replace()’ は単語内の
‘word’ も置換し、 ‘swordfish’ を ‘sdeedfish’ に変えますが、安直な正規表
現 ‘word’ も同様に動作することに注意して下さい。(単語の一部に対する置換
の実行を避けるには、パターンを ‘\bword\b’ として、 ‘word’ の両側に単語の
境界が要求されるようにします。これは ‘replace()’ の能力を越えた作業です
。)

別のよくある作業は、文字列の中に出現する文字を全て削除することと、別の文
字で置換することです。この作業を ‘re.sub('\n', ' ', S)’ のようにして行う
かもしれませんが、 *note translate(): 212d. は削除と置換の両方の作業をこ
なし、正規表現操作よりも高速に行うことができます。

要は、 *note re: a7. モジュールに向う前に問題が高速で単純な文字列メソッ
ドで解決できるか考えましょうということです。


File: python.info,  Node: match 対 search,  Next: 貪欲 greedy 対非貪欲 non-greedy,  Prev: 文字列メソッドを利用する,  Up: よくある問題

9.9.6.2 match() 対 search()
...........................

*note match(): 11fe. 関数は文字列の先頭に正規表現がマッチするかどうか調
べるだけですが、その一方 *note search(): 11fd. はマッチするために文字列
の先の方まで走査します。 この違いを覚えておくことは重要なことです。
‘match()’ は開始位置0でマッチが成功したときのみ報告する; もし開始位置0で
マッチしなければ、 ‘match()’ はそれを報告 'しない' 、ということを覚えて
おいてください。

     >>> print(re.match('super', 'superstition').span())
     (0, 5)
     >>> print(re.match('super', 'insuperable'))
     None

一方 *note search(): 11fd. は文字列の先の方まで走査し、最初にみつけたマ
ッチを報告します。:

     >>> print(re.search('super', 'superstition').span())
     (0, 5)
     >>> print(re.search('super', 'insuperable').span())
     (2, 7)

しばしば、 *note re.match(): 11fe. を使い、 ‘.*’ を正規表現の最初に付け
加える誘惑にからされることがあるでしょう。この誘惑に打ち克って、代わりに
*note re.search(): 11fd. を利用すべきです。正規表現コンパイラはマッチを
探す処理の高速化のためにいくつかの解析を行います。そのような解析のうちの
ひとつはマッチの最初の文字が何であるか評価することです; 例えば、 ‘Crow’
で始まるパターンは ‘'C'’ から始まらなければいけません。解析によってエン
ジンは速やかに開始文字を探して走査します、 ‘'C'’ が発見された場合にはじ
めて完全なマッチを試みます。

‘.*’ を追加することはこの最適化を無効にします、文字列の終端までの走査が
必要となり、走査後には残りの正規表現とのマッチ部分を見つけるために引き返
すことになります。代わりに *note re.search(): 11fd. を利用して下さい。


File: python.info,  Node: 貪欲 greedy 対非貪欲 non-greedy,  Next: re VERBOSE の利用,  Prev: match 対 search,  Up: よくある問題

9.9.6.3 貪欲 (greedy) 対非貪欲 (non-greedy)
...........................................

正規表現を繰り返す場合、たとえば ‘a*’ のように、できるだけパターンの多く
にマッチするように動作することになります。この動作は、例えば角括弧で囲ま
れた HTML タグのような左右対称のデリミタの対にマッチしようという場合に問
題となります。単一の HTML タグにマッチする素朴な正規表現はうまく動作しま
せん、なぜならば ‘.*’ は貪欲に動作するからです。

     >>> s = '<html><head><title>Title</title>'
     >>> len(s)
     32
     >>> print(re.match('<.*>', s).span())
     (0, 32)
     >>> print(re.match('<.*>', s).group())
     <html><head><title>Title</title>

正規表現は ‘'<html>'’ 内の ‘'<'’ にマッチし、 ‘.*’ は残りの文字列の全て
にマッチします。 しかし、正規表現には依然として残っている部分があって、
‘>’ は文字列の終端にマッチしないので、正規表現エンジンは一文字ずつ ‘>’ と
マッチするまで引き返すことになります。 最終的にマッチする領域は
‘'<html>'’ の ‘'<'’ から ‘'</title>'’ の ‘'>'’ まで広がりますが、これは
望んだ結果ではありません。

この場合の解決策は、非貪欲 (non-greedy) な数量子 ‘*?’, ‘+?’, ‘??’, ある
いは ‘{m,n}?’ を使うことです。これらはできるだけ '少ない' テキストにマッ
チしようとします。上記の例では、 ‘'>'’ は ‘'<'’ がマッチした直後の文字か
らマッチするかどうかを調べられ、失敗すると同時にエンジンは文字を先に進め
ながら、各ステップで ‘'>'’ のマッチを試みます。この動作は正しい結果を生
成します:

     >>> print(re.match('<.*?>', s).group())
     <html>

(HTML や XML を正規表現でパースすることは苦痛を伴うものであることは記憶
に留めておいて下さい。素早く、汚いパターンは大抵の場合うまく動作しますが
、HTML と XML は正規表現が破綻する特別な例です; 全ての可能な場合にうまく
動作する正規表現を書き上げたときには、パターンは '非常に' 複雑なものにな
ります。そのような作業をする場合には HTML や XML パーサを利用しましょう
。)


File: python.info,  Node: re VERBOSE の利用,  Prev: 貪欲 greedy 対非貪欲 non-greedy,  Up: よくある問題

9.9.6.4 re.VERBOSE の利用
.........................

ここまでで、正規表現がとても簡潔な表記であることに気づいたでしょう、また
、正規表現は読みやすいものでもないということにも気づいたことでしょう。そ
こそこに入り組んだ正規表現ははバックスラッシュ、括弧、特殊文字が長く続い
て、読みにくく、理解しづらいものになります。

そのような正規表現に対しては、正規表現をコンパイルする時に *note
re.VERBOSE: 2258. フラグを指定することが助けになります。なぜなら、より明
確な書式で正規表現を書けるからです。

‘re.VERBOSE’ の効果はいくつかあります。正規表現内の文字クラス内に '無い'
空白は無視されます。これは、 ‘dog | cat’ のような表現が少々可読性の落ち
る ‘dog|cat’ と等価となるということです、しかし、 ‘[a b]’ は依然として
‘'a'’, ‘'b'’, または空白にマッチします。加えて、正規表現にコメントを入れ
ることもできるようになります; ‘#’ 文字から次の改行までがコメントの範囲で
す。三重クォートを利用することで、正規表現をきちんとフォーマットすること
ができます:

     pat = re.compile(r"""
      \s*                 # Skip leading whitespace
      (?P<header>[^:]+)   # Header name
      \s* :               # Whitespace, and a colon
      (?P<value>.*?)      # The header's value -- *? used to
                          # lose the following trailing whitespace
      \s*$                # Trailing whitespace to end-of-line
     """, re.VERBOSE)

これは下よりはるかに読みやすいです:

     pat = re.compile(r"\s*(?P<header>[^:]+)\s*:(?P<value>.*?)\s*$")


File: python.info,  Node: フィードバック,  Prev: よくある問題,  Up: 正規表現 HOWTO

9.9.7 フィードバック
--------------------

正規表現は複雑な話題です。このドキュメントは助けになったでしょうか？わか
りにくかったところや、あなたが遭遇した問題が扱われていない等なかったでし
ょうか？もしそんな問題があれば、著者に改善の提案を送って下さい。

O'Reilly から出版されている Jeffrey Friedl の Mastering Regular
Expressions は正規表現に関するほぼ完璧な書籍です (訳注　日本語訳「詳説　
正規表現」が出版されています) 。不幸なことに、この本は Perl と Java の正
規表現を集中して扱っていて、 Python の正規表現については全く扱っていませ
ん、そのため Python プログラミングのためのレファレンスとして使うことはで
きません。 (第一版はいまや削除された Python の ‘regex’ モジュールについ
て扱っていましたが、これはあまり役に立たないでしょう。) 図書館で調べるの
を検討してみましょう。


File: python.info,  Node: ソケットプログラミング HOWTO,  Next: ソートのテクニック,  Prev: 正規表現 HOWTO,  Up: Python HOWTO

9.10 ソケットプログラミング HOWTO
=================================


著者: Gordon McMillan

概要
....

ソケットはそこかしこで使われているが、最大級に誤解されている技術でもある
。この文書はソケットの全体像を俯瞰しており、チュートリアルとしてはあまり
役に立たない。実際に動くモノを完成させるには、他にもやらなければいけない
ことがあるからだ。この文書はソケットの微妙なところ (たくさんある) までは
カバーしていないが、恥ずかしくない使い方ができるようになる程度の情報は得
られるはずだ。

* Menu:

* ソケット::
* ソケットの作成: ソケットの作成<3>.
* ソケットの利用::
* 切断::
* ノンブロッキングソケット::


File: python.info,  Node: ソケット,  Next: ソケットの作成<3>,  Up: ソケットプログラミング HOWTO

9.10.1 ソケット
---------------

INET (すなわち IPv4) ソケットのことしか語らないつもりだが、利用率でいう
とソケットの 99% 以上はこれだ。さらに中でも STREAM (すなわち TCP) ソケッ
トに話題を絞ろうと思う - 自分が何をしているのか分かっているのでない限り
(分かってるならこの HOWTO なんて要らないだろ!)、STREAM ソケットが一番分
かりやすく、一番性能が出るのだ。そうやって謎に包まれたソケットの正体を明
らかにしてゆくと共に、ブロッキングおよびノンブロッキングなソケットの扱い
に関するいくつかのヒントを提示しよう。だが、まずはブロッキングソケットか
ら始めることにする。ノンブロッキングを扱うより先に、ブロッキングの仕組み
を知っておかなくてはならないのだ。

話を理解しにくくしている要因として、「ソケット」という言葉が文脈によって
微妙に違うものを指すことが挙げられる。そこでまず、「クライアント」ソケッ
ト - 対話の両端 - と「サーバ」ソケット - 電話交換手みたいなもの - の区別
を付けておこう。クライアントアプリケーション (たとえばブラウザ) は「クラ
イアント」ソケットだけを使うが、話し相手のウェブサーバは「サーバ」ソケッ
トと「クライアント」ソケットの両方を使う。

* Menu:

* 歴史::


File: python.info,  Node: 歴史,  Up: ソケット

9.10.1.1 歴史
.............

各種 IPC (Inter Process Communication (プロセス間通信) の中でも、ソケッ
トは群を抜いて人気がある。どのプラットフォームにも、ソケットより速い IPC
はあるだろう。だが、プラットフォームをまたぐ通信はソケットの独擅場だ。

ソケットは BSD Unix の一部としてバークレイで発明され、インターネットの普
及と共に野火のごとく広まった。それももっともなことで、ソケットと INET の
コンビによって世界中どんなマシンとも、信じられないほど簡単 (少なくとも他
のスキームと比べて) に通信できるようになったのだ。


File: python.info,  Node: ソケットの作成<3>,  Next: ソケットの利用,  Prev: ソケット,  Up: ソケットプログラミング HOWTO

9.10.2 ソケットの作成
---------------------

あなたがリンクをクリックしてこのページに来たとき、ブラウザは大雑把に言っ
て次のようなことをしたのである:

     # create an INET, STREAMing socket
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     # now connect to the web server on port 80 - the normal http port
     s.connect(("www.python.org", 80))

この ‘connect’ が完了すると、ソケット ‘s’ を使ってこのページ文章への要求
を送ることができるようになる。その同じソケットが返答を読み、そして破壊さ
れる。そう、破壊される。クライアントソケットは通常、一回 (か少数の) やり
取りで使い捨てになるのだ。

ウェブサーバで起こる事柄はもう少し複雑だ。まず「サーバソケット」を作る:

     # create an INET, STREAMing socket
     serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     # bind the socket to a public host, and a well-known port
     serversocket.bind((socket.gethostname(), 80))
     # become a server socket
     serversocket.listen(5)

ここで注意すべき点がいくつかある: 今回はソケットが外界に見えるよう、
‘socket.gethostname()’ を使った。 ‘s.bind(('localhost', 80))’ や
‘s.bind(('127.0.0.1', 80))’ でも「サーバ」ソケットにはなるが、それだと同
じマシン内にしか見えないものになってしまう。 ‘s.bind(('', 80))’ はこのマ
シンが持っている全てのアドレスで接続可能になるようにという指定になる。

ふたつめ: 小さな番号のポートは大抵、「ウェルノウン (有名)」なサービス
(HTTP, SNMP 等々) のために取ってある。お遊びで使うのなら適当に大きな数
(4桁) を使おう。

最後に: ‘listen’ の引数はソケットライブラリに、接続要求を 5 個 (通常の最
大値) まで順番待ちさせるように命じている。これ以降の外部接続は拒否するの
だが、コードが適切に書かれていれば、それで十分すぎるほどだ。

よし、「サーバーソケット」ができて、80 番ポートで耳を澄ましているところ
まで来た。では、ウェブサーバのメインループに入ろう:

     while True:
         # accept connections from outside
         (clientsocket, address) = serversocket.accept()
         # now do something with the clientsocket
         # in this case, we'll pretend this is a threaded server
         ct = client_thread(clientsocket)
         ct.run()

このループには実際のところ、3 通りの一般的な動作方法がある -
‘clientsocket’ を扱うようにスレッドを割り当てたり、‘clientsocket’ を扱う
新しいプロセスを作ったり、あるいはノンブロッキングソケットを使うようにア
プリを作り直して ‘select’ で「サーバ」ソケットとアクティブな
‘clientsocket’ の間を多重化したりするのだ。最後のについてはまた後にしよ
う。ここで理解しておくべき要点はこれだ: 以上が「サーバ」ソケットの仕事の
'すべて' である。データは一切送信しないし、受信しない。「クライアント」
ソケットを生み出すだけ。我々のバインドされているホストとポートに
‘connect()’ してくる '他の' 「クライアント」ソケットに応える形で
‘clientsocket’ を作り、作るや否や、さらなる接続を聞きに戻っていくのだ。
このふたつの「クライアント」は、あとは勝手に喋っていればいい - 使うポー
トは動的に割り当てられ、会話が終わればリサイクルに廻される。

* Menu:

* IPC::


File: python.info,  Node: IPC,  Up: ソケットの作成<3>

9.10.2.1 IPC
............

1つのマシン上の2プロセス間で高速なIPCを行いたい場合は、pipe か共有メモリ
を検討するべきです。AF_INET ソケットを使用すると決めた場合、「サーバー」
ソケットは ‘'localhost'’ にバインドしましょう。ほとんどのプラットフォー
ムで、いくつかのネットワークレイヤーをショートカットすることでかなり高速
になります。

参考
....

*note multiprocessing: 86. はクロスプラットフォームなIPCの高級なAPIを提
供しています。


File: python.info,  Node: ソケットの利用,  Next: 切断,  Prev: ソケットの作成<3>,  Up: ソケットプログラミング HOWTO

9.10.3 ソケットの利用
---------------------

はじめに憶えておくべきなのは、ウェブブラウザの「クライアント」ソケットと
ウェブサーバの「クライアント」ソケットがまったく同じ種族だということだ。
つまり、これは「ピア・トゥ・ピア」(1 対 1) の会話である。別の言い方をす
ると、 '設計者として自分で会話のエチケット規則を決めなくてはいけない' と
いうことでもある。通常は、 ‘connect’ してくるソケットが要求あるいは宣言
をして会話を始める。だが、それはそう設計しただけのことだ - ソケットの規
則ではない。

さて、コミュニケーションに使う動詞は二組ある。 ‘send’ と ‘recv’ を使うこ
ともできるし、クライアントソケットをファイルっぽい種族に変形して ‘read’
と ‘write’ を使っても良い。後者は Java のソケットの表現方法だ。ここで詳
しく語るつもりはないが、その場合はソケットも ‘flush’ しなければいけない
、とだけ言っておく。これはバッファリングした「ファイル」なので、何かを
‘write’ してすぐに返答を ‘read’ するというのはよくある間違いだ。間に
‘flush’ を入れないと、要求がまだ出力バッファにあって永遠に返事が来ない、
という可能性がある。

さあ、ソケットの主要な難関に進もう - ‘send’ と ‘recv’ はネットワークバッ
ファに働きかけるものだ。だから、手渡したもの (や返してもらいたいもの) を
1 バイトも残さず実際に処理してくれているとは限らない。一般的に言って、
‘send’ はバッファが埋まるまで、‘recv’ はバッファが空になるまで処理をして
、そのバイト数を返す。メッセージが完全に処理されるまで繰り返し呼び出すの
は '自分の' 責任なのだ。

‘recv’ が 0 バイトを返したときは、向こう側が接続を閉じてしまった (または
閉じようとしている途中) という意味だ。もうこの接続でデータを受け取ること
はない。永遠にだ。ただ、データ送信は成功するかもしれない; これについては
あとで語ることにしよう。

HTTP のようなプロトコルでは、ひとつのソケットを1回の転送にしか使わない。
クライアントは要求を送り、返答を受ける。以上だ。これでソケットは破棄され
る。だからこの場合、クライアントは受信 0 バイトの時点で返答の末尾を検出
することができる。

だが、以降の転送にもそのソケットを使い回すつもりなら、ソケットに EOT
(End of Transfer) など '存在しない' ことを認識する必要がある。もう一度言
おう: ソケットの ‘send’ や ‘recv’ が 0 バイト処理で返ってきたなら、その
接続は終わっている。終わって 'いない' なら、いつまで ‘recv’ を待てばいい
かは分からない。ソケットは「もう読むものが (今のところ) ないぜ」などと
'言わない' のだから。このことを少し考えれば、ソケットの真実を悟ることに
なるだろう: 'メッセージは必ず固定長か' (うげぇ) '区切り文字を使うか' (や
れやれ) '長さ標識を付けておくか' (かなりマシ) '接続を閉じて終わらせるか
のいずれかでなければいけない' のだ。選ぶ権利と責任はまったくもって自分に
ある (が、正しさの程度に違いはある)。

毎回接続を終わらせるのはイヤだとして、最も単純な解決策は固定長メッセージ
だろう:

     class MySocket:
         """demonstration class only
           - coded for clarity, not efficiency
         """

         def __init__(self, sock=None):
             if sock is None:
                 self.sock = socket.socket(
                                 socket.AF_INET, socket.SOCK_STREAM)
             else:
                 self.sock = sock

         def connect(self, host, port):
             self.sock.connect((host, port))

         def mysend(self, msg):
             totalsent = 0
             while totalsent < MSGLEN:
                 sent = self.sock.send(msg[totalsent:])
                 if sent == 0:
                     raise RuntimeError("socket connection broken")
                 totalsent = totalsent + sent

         def myreceive(self):
             chunks = []
             bytes_recd = 0
             while bytes_recd < MSGLEN:
                 chunk = self.sock.recv(min(MSGLEN - bytes_recd, 2048))
                 if chunk == b'':
                     raise RuntimeError("socket connection broken")
                 chunks.append(chunk)
                 bytes_recd = bytes_recd + len(chunk)
             return b''.join(chunks)

この送信コードは、ほぼあらゆるメッセージ通信スキームで使える - 文字列を
送るとき、Python なら長さを ‘len()’ で見極めることができる (中に ‘\0’ が
埋め込まれていても大丈夫)。難しくしているのは、おもに受信コードである。
(なお、C でも事態はあまり悪くならないが、メッセージに ‘\0’ が埋め込まれ
ていると ‘strlen’ が使えないのは面倒だ。)

最も簡単な改良法は、メッセージの最初の一文字をタイプ標識にして、そのタイ
プで長さを決定するというものだ。この場合ふたつの ‘recv’ があることになる
- 一番目でその一文字 (だけじゃなくても可) を取って長さを調べ、二番目でル
ープして残りを取るのだ。あるいはもし区切り方式の道を行くのであれば、任意
のサイズ (4096 か 8192 がネットワークバッファには最適なことが多い) で受
信して区切り文字を走査していくことになる。

心に留めておくべき面倒な点がひとつ: 複数メッセージが次々に (何らかの返事
を待たずに) 返ってくることのある会話プロトコルなら、そして任意のサイズを
‘recv’ に渡しているなら、次のメッセージの冒頭部分まで読んでしまうことが
あるかもしれない。そのときは、必要になるまで脇によけて、大切に保管してお
く必要がある。

メッセージ冒頭に長さを (たとえば 5 桁の数字で) 付けるのは、それよりもさ
らに複雑になる。というのも、(信じられないかもしれないが) 一回の ‘recv’ で
5 文字を全部受け取ることができるとは限らないからだ。お遊びでやっている間
はごまかせても、高負荷ネットワークのもとでは、‘recv’ ループをふたつ使わ
ないコードは、あっと言う間にダメになってしまう - 一番目は長さを見定める
用で、二番目はデータ部分を受け取る用だ。うーむ、いやらしい。さらにこのと
き、‘send’ も一発で全部を出し切れるとは限らないことに気付くだろう。なお
、今こうやって読んでいても、いつか誰もが痛い目を見るのである!

紙面の都合および教育的配慮 (と著者の地位確保) のため、こうした改良は練習
問題として残しておく。さあ片付けてしまおう。

* Menu:

* バイナリデータ::


File: python.info,  Node: バイナリデータ,  Up: ソケットの利用

9.10.3.1 バイナリデータ
.......................

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 example, network byte order(1) is big-endian, with the most
significant byte first, so a 16 bit integer with the value ‘1’ would be
the two hex bytes ‘00 01’.  However, most common processors (x86/AMD64,
ARM, RISC-V), are little-endian, with the least significant byte first -
that same ‘1’ would be ‘01 00’.

Socket libraries have calls for converting 16 and 32 bit integers -
‘ntohl, htonl, ntohs, htons’ where "n" means 'network' and "h" means
'host', "s" means 'short' and "l" means 'long'.  Where network order is
host order, these do nothing, but where the machine is byte-reversed,
these swap the bytes around appropriately.

In these days of 64-bit machines, the ASCII representation of binary
data is frequently smaller than the binary representation.  That's
because a surprising amount of the time, most integers have the value 0,
or maybe 1.  The string ‘"0"’ would be two bytes, while a full 64-bit
integer would be 8.  Of course, this doesn't fit well with fixed-length
messages.  Decisions, decisions.

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Endianness#Networking


File: python.info,  Node: 切断,  Next: ノンブロッキングソケット,  Prev: ソケットの利用,  Up: ソケットプログラミング HOWTO

9.10.4 切断
-----------

厳密には、ソケットを ‘close’ する前には ‘shutdown’ することになっている
。 ‘shutdown’ は相手ソケットに対する報告であり、渡す引数によって「これ以
上こっちからは送らないけど、まだ聞いてるぜ」という意味になったり、「もう
聞かない。せいせいした!」だったりする。しかしほとんどのソケットライブラ
リは、このエチケットを怠るプログラマに慣れてしまって、通常 ‘close’ だけ
で ‘shutdown(); close()’ と同じことになる。だから大抵はわざわざ
‘shutdown’ しなくてもいい。

‘shutdown’ の効果的な使い方のひとつは、HTTP 風のやりとりだ。クライアント
は要求を出してすぐに ‘shutdown(1)’ する。これでサーバに、「クライアント
は送信完了ですが、まだ受信可能です」と伝わる。サーバは 0 バイト受信で
"EOF" を検出することができる。要求を残さず受け取ったことにして良いのだ。
対してサーバは返答を送る。その ‘send’ が成功したなら、クライアントは実際
にまだ受信していたことになる。

Python はこの自動 shutdown をもう一歩進めて、ソケットが GC されるときに
必要なら自動で ‘close’ してくれると言っている。しかしこれに頼るクセをつ
けてはいけない。もしソケットが ‘close’ せずに姿を消せば、相手ソケットは
こちらが遅いだけだと思ってハングしてしまうかもしれない。 'お願いだから'
終わったらちゃんと ‘close’ してくれ。

* Menu:

* ソケットが死ぬと::


File: python.info,  Node: ソケットが死ぬと,  Up: 切断

9.10.4.1 ソケットが死ぬと
.........................

ブロッキングソケットを使っていて一番いやなのは多分、相手側が意地悪く
(‘close’ せずに) ダウンするときに起こる事柄だ。自分側のソケットは高確率
でハングするだろう。TCP は信頼性の高いプロトコルなので、ずっとずっと待ち
続けて、なかなか見捨てないのだ。スレッドを使っているのであれば、そのスレ
ッド全体が根本から死んだ状態になる。こうなると、もう手の施しようがない。
まあ、ブロッキング読み出しの間ロックし続けるといった馬鹿げたことをしてい
ない限り、リソースの点ではたいして消費にならない。だから 'ぜったいに' そ
のスレッドを殺そうとしてはいけない - プロセスよりスレッドが効率的である
理由のひとつは、自動リソース回収にまつわるオーバヘッドを避けられるという
点にあるのだ。つまり別の言い方をすると、どうにかしてそのスレッドを殺した
なら、プロセス全体がぐちゃぐちゃになってしまうだろうということだ。


File: python.info,  Node: ノンブロッキングソケット,  Prev: 切断,  Up: ソケットプログラミング HOWTO

9.10.5 ノンブロッキングソケット
-------------------------------

ここまで理解してきたなら、もうソケットの仕組みについて必要なことはほとん
ど知っていることになる。これからも同じコールを、ほぼ同じように使っていく
だけ、それだけだ。これをちゃんとやっていれば、そのアプリはだいたい完璧で
あろう。

Python の場合、ノンブロッキングにするには ‘socket.setblocking(False)’ を
使う。 C ならもっと複雑だ (一例を挙げると、BSD 方式の ‘O_NONBLOCK’ およ
びほぼ違いのない POSIX 方式 ‘O_NDELAY’ のどちらを選ぶか決めなくてはなら
なくて、後者は ‘TCP_NODELAY’ とは全然別物だったりする) が、考え方はまっ
たく一緒だ。これは、ソケットを作成した後、使用する前に行う。(実際、常識
破りなら、切り替えることができます。)

構造上の大きな違いは、 ‘send’, ‘recv’, ‘connect’, ‘accept’ が何もしない
で戻ってくるかもしれないという点である。選択肢は (当然ながら) いくつかあ
る。返り値とエラーコードをチェックするという方法もある。が、発狂すること
請け合いだ。信じないなら、いつかやってみるといい。アプリは肥大化し、バグ
が増え、CPU を喰い尽くすだろう。だからそんな愚かな解法は飛ばして、正解に
進もう。

‘select’ を使え。

C において ‘select’ でコードを書くのはかなり面倒だが、Python なら造作も
ない。しかし Python で ‘select’ を理解しておけば C でもほとんど問題なく
書ける、という程度には似ている:

     ready_to_read, ready_to_write, in_error = \
                    select.select(
                       potential_readers,
                       potential_writers,
                       potential_errs,
                       timeout)

‘select’ に三つのリストを渡しているが、一番目にはあとで読みたくなるかも
しれないソケットすべて、二番目には書き込みたくなるかもしれないソケットす
べて、最後に (通常は空のままだが) エラーをチェックしたいソケットが入って
いる。ひとつのソケットが複数にまたがってリストされても構わないことを憶え
ておくと良い。なお、 ‘select’ コールはブロックするが、時間制限を与えるこ
とができる。これは、やっておいて損はない - 特に理由がなければ、かなり長
い (たとえば 1 分とかの) 時間制限を付けておくことだ。

戻り値として、三つのリストが手に入る。それぞれには、実際に読めるソケット
、書けるソケット、エラー中のソケットが入っていて、渡したリストの部分集合
(空集合かもしれない) になっている。

出力のうち、readable リストにあるソケットについては、 ‘recv’ がとりあえ
ず '何か' を返すであろう、ということは史上最高度に確信できる。 writable
リストも考え方は同じで、 '何か' は送れる。送りたいもの全体は無理かもしれ
ないが、 '何も' ないよりはマシだろう。 (実のところ、ふつうに健康なソケッ
トなら writable で返ってくることができる - それは外向きネットワークバッ
ファに空きがあるというだけの意味しかないのだから)

「サーバ」ソケットは potential_readers リストに入れておこう。それが
readable リストに入って出てきたら、 ‘accept’ は (ほぼ) 確実に成功するは
ずだ。どこかへ ‘connect’ するために作った新しいソケットは
potential_writers リストに入れる。それが writable リストに現れたら、接続
が成功している可能性は高いと言える。

じつは ‘select’ はブロッキングソケットにも便利に使える。それはブロックす
るかどうかを見極める方法のひとつである - バッファに何かがあれば readable
として返ってくるのだ。しかしこれも、相手の用事がもう済んでいるのか、それ
とも単に他のことで忙しいだけなのかを見極める役には立たない。

'非互換警報': Unix ではソケットにもファイルにも ‘select’ が使える。これ
を Windows でやろうとしてはいけない。Windows で ‘select’ はソケットにし
か使えない。また C の場合、高度なソケットオプションの多くは、やり方が
Windows では違っている。実際、Windows なら著者は通常、ソケットにスレッド
を使っている (これは実に、実にうまくいく)。


File: python.info,  Node: ソートのテクニック,  Next: Unicode HOWTO,  Prev: ソケットプログラミング HOWTO,  Up: Python HOWTO

9.11 ソートのテクニック
=======================


著者: Andrew Dalke and Raymond Hettinger

Python のリストにはリストをインプレースに変更する、組み込みメソッド
*note list.sort(): b9d. があります。他にもイテラブルからソートしたリスト
を作成する組み込み関数 *note sorted(): b9c. があります。

このドキュメントでは Python を使った様々なソートのテクニックを探索します
。

* Menu:

* ソートの基本::
* Key 関数::
* operator モジュールの関数や partial 関数による評価::
* 昇順と降順::
* ソートの安定性と複合的なソート::
* デコレート - ソート - アンデコレート (DSU): デコレート - ソート - アンデコレート DSU.
* 比較関数::
* 残りのはしばし: 残りのはしばし<2>.
* 部分的なソート::


File: python.info,  Node: ソートの基本,  Next: Key 関数,  Up: ソートのテクニック

9.11.1 ソートの基本
-------------------

単純な昇順のソートはとても簡単です: *note sorted(): b9c. 関数を呼ぶだけ
です。そうすれば、新たにソートされたリストが返されます:

     >>> sorted([5, 2, 3, 1, 4])
     [1, 2, 3, 4, 5]

*note list.sort(): b9d. メソッドを呼びだしても同じことができます。この方
法はリストをインプレースに変更します (そして sorted との混乱を避けるため
‘None’ を返します)。多くの場合、こちらの方法は *note sorted(): b9c. と比
べると不便です - ただし、元々のリストが不要な場合には、わずかですがより
効率的です。

     >>> a = [5, 2, 3, 1, 4]
     >>> a.sort()
     >>> a
     [1, 2, 3, 4, 5]

違いは他にもあります、 *note list.sort(): b9d. メソッドはリストにのみ定
義されています。一方 *note sorted(): b9c. 関数は任意のイテラブルを受け付
けます。

     >>> sorted({1: 'D', 2: 'B', 3: 'B', 4: 'E', 5: 'A'})
     [1, 2, 3, 4, 5]


File: python.info,  Node: Key 関数,  Next: operator モジュールの関数や partial 関数による評価,  Prev: ソートの基本,  Up: ソートのテクニック

9.11.2 Key 関数
---------------

*note list.sort(): b9d. と *note sorted(): b9c. には 'key' パラメータが
あります。 これは比較を行う前にリストの各要素に対して呼び出される関数 (ま
たは呼び出し可能オブジェクト) を指定するパラメータです。

例えば、大文字小文字を区別しない文字列比較の例:

     >>> sorted("This is a test string from Andrew".split(), key=str.casefold)
     ['a', 'Andrew', 'from', 'is', 'string', 'test', 'This']

'key' パラメータの値は関数または呼び出し可能オブジェクトであって、単一の
引数をとり、ソートに利用されるキー値を返すものでなければいけません。この
制約によりソートを高速に行えます、キー関数は各入力レコードに対してきっち
り一回だけ呼び出されるからです。

よくある利用パターンはいくつかの要素から成る対象をインデクスのどれかをキ
ーとしてソートすることです。例えば:

     >>> student_tuples = [
     ...     ('john', 'A', 15),
     ...     ('jane', 'B', 12),
     ...     ('dave', 'B', 10),
     ... ]
     >>> sorted(student_tuples, key=lambda student: student[2])   # sort by age
     [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

同じテクニックは名前づけされた属性 (named attributes) を使うことでオブジ
ェクトに対しても動作します。例えば:

     >>> class Student:
     ...     def __init__(self, name, grade, age):
     ...         self.name = name
     ...         self.grade = grade
     ...         self.age = age
     ...     def __repr__(self):
     ...         return repr((self.name, self.grade, self.age))

     >>> student_objects = [
     ...     Student('john', 'A', 15),
     ...     Student('jane', 'B', 12),
     ...     Student('dave', 'B', 10),
     ... ]
     >>> sorted(student_objects, key=lambda student: student.age)   # sort by age
     [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

名前づけされた属性を持つオブジェクトは上で示したとおり通常のクラスから作
れますし、*note dataclass: 1ad. や *note named tuple: 61a. のインスタン
スでもよいです。


File: python.info,  Node: operator モジュールの関数や partial 関数による評価,  Next: 昇順と降順,  Prev: Key 関数,  Up: ソートのテクニック

9.11.3 operator モジュールの関数や partial 関数による評価
---------------------------------------------------------

上で示した *note key function: dd2. パターンは非常に一般的なので、Python
はアクセサ関数を簡単に速く作れる便利な関数を提供しています。*note
operator: 8f. モジュールに *note itemgetter(): a30.、*note attrgetter():
e00.、および *note methodcaller(): e01. 関数があります。

これらの関数を利用すると、上の例はもっと簡単で高速になります:

     >>> from operator import itemgetter, attrgetter

     >>> sorted(student_tuples, key=itemgetter(2))
     [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

     >>> sorted(student_objects, key=attrgetter('age'))
     [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

operator モジュールの関数は複数の段階でのソートを可能にします。例えば、
'grade' でソートしてさらに 'age' でソートする場合:

     >>> sorted(student_tuples, key=itemgetter(1,2))
     [('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]

     >>> sorted(student_objects, key=attrgetter('grade', 'age'))
     [('john', 'A', 15), ('dave', 'B', 10), ('jane', 'B', 12)]

*note functools: 55. モジュールには他にもキー関数を作るための便利なツー
ルがあります。*note partial(): 3ed. 関数は複数引数の関数の アリティ(1) を
減らし、キー関数に適したものにできます。

     >>> from functools import partial
     >>> from unicodedata import normalize

     >>> names = 'Zoë Åbjørn Núñez Élana Zeke Abe Nubia Eloise'.split()

     >>> sorted(names, key=partial(normalize, 'NFD'))
     ['Abe', 'Åbjørn', 'Eloise', 'Élana', 'Nubia', 'Núñez', 'Zeke', 'Zoë']

     >>> sorted(names, key=partial(normalize, 'NFC'))
     ['Abe', 'Eloise', 'Nubia', 'Núñez', 'Zeke', 'Zoë', 'Åbjørn', 'Élana']

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Arity


File: python.info,  Node: 昇順と降順,  Next: ソートの安定性と複合的なソート,  Prev: operator モジュールの関数や partial 関数による評価,  Up: ソートのテクニック

9.11.4 昇順と降順
-----------------

*note list.sort(): b9d. と *note sorted(): b9c. の両方とも 'reverse' パ
ラメータを 真偽値として受け付けます。このパラメータは降順ソートを行うか
どうかの フラグとして利用されます。 例えば、学生のデータを 'age' の逆順
で得たい場合:

     >>> sorted(student_tuples, key=itemgetter(2), reverse=True)
     [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]

     >>> sorted(student_objects, key=attrgetter('age'), reverse=True)
     [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]


File: python.info,  Node: ソートの安定性と複合的なソート,  Next: デコレート - ソート - アンデコレート DSU,  Prev: 昇順と降順,  Up: ソートのテクニック

9.11.5 ソートの安定性と複合的なソート
-------------------------------------

ソートは、 安定 (stable)(1) であることが保証されています。これはレコード
の中に同じキーがある場合、元々の順序が維持されるということを意味します。

     >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]
     >>> sorted(data, key=itemgetter(0))
     [('blue', 1), ('blue', 2), ('red', 1), ('red', 2)]

二つの 'blue' のレコードが元々の順序を維持して、 ‘('blue', 1)’ が
‘('blue', 2)’ の前にあることに注意してください。

この素晴しい性質によって複数のソートを段階的に組み合わせることができます
。例えば、学生データを 'grade' の降順にソートし、さらに 'age' の昇順にソ
ートしたい場合には、まず 'age' でソートし、次に 'grade' でもう一度ソート
します:

     >>> s = sorted(student_objects, key=attrgetter('age'))     # sort on secondary key
     >>> sorted(s, key=attrgetter('grade'), reverse=True)       # now sort on primary key, descending
     [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

この処理は、リストおよびフィールド名とソート順序のタプルを複数受け取れる
ラッパー関数へ抽象化できます。

     >>> def multisort(xs, specs):
     ...     for key, reverse in reversed(specs):
     ...         xs.sort(key=attrgetter(key), reverse=reverse)
     ...     return xs

     >>> multisort(list(student_objects), (('grade', True), ('age', False)))
     [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

Python では Timsort(2) アルゴリズムが利用されていて、効率良く複数のソー
トを行うことができます、これは現在のデータセット中のあらゆる順序をそのま
ま利用できるからです。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Sorting_algorithm#Stability

   (2) https://en.wikipedia.org/wiki/Timsort


File: python.info,  Node: デコレート - ソート - アンデコレート DSU,  Next: 比較関数,  Prev: ソートの安定性と複合的なソート,  Up: ソートのテクニック

9.11.6 デコレート - ソート - アンデコレート (DSU)
-------------------------------------------------

このイディオムは以下の3つのステップにちなんでデコレート-ソート-アンデコ
レート (Decorate-Sort-Undecorate) と呼ばれています:

   * まず、元となるリストをソートしたい順序を制御する新しい値でデコレー
     トします。

   * 次に、デコレートしたリストをソートします。

   * 最後に、デコレートを取り除き、新しい順序で元々の値のみを持つリスト
     を作ります。

例えば、DSU アプローチを利用して学生データを 'grade' でソートする場合:

     >>> decorated = [(student.grade, i, student) for i, student in enumerate(student_objects)]
     >>> decorated.sort()
     >>> [student for grade, i, student in decorated]               # undecorate
     [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10)]

このイディオムはタブルが辞書編集的に比較されるため正しく動作します; 最初
の要素が比較され、同じ場合には第二の要素が比較され、以下も同様に動きます
。

デコレートしたリストのインデクス 'i' は全ての場合で含まれる必要はありま
せんが、そうすることで二つの利点があります:

   * ソートが安定になります - もし二つの要素が同じキーを持つ場合、それら
     の順序がソートされたリストでも維持されます。

   * 元々の要素が比較可能な要素を持つとは限りません、なぜならデコレート
     されたタブルの順序は多くの場合、最初の二つの要素で決定されるからで
     す。例として元のリストは直接比較できない複素数を含むことができます
     。

このイディオムの別名に Schwartzian transform(1) があります。これは Perl
プログラマの間で有名な Randal L. Schwartz にちなんでいます。

いまや Python のソートは key 関数による方法を提供しているので、このテク
ニックは不要でしょう。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Schwartzian_transform


File: python.info,  Node: 比較関数,  Next: 残りのはしばし<2>,  Prev: デコレート - ソート - アンデコレート DSU,  Up: ソートのテクニック

9.11.7 比較関数
---------------

ソートのための絶対的な値を返すキー関数と違って、2つの入力を受け取り、そ
の相対的な順序を計算するような関数を比較関数といいます。

例えば、 天秤(1) は2つのサンプルを比較し、より軽いか、同じか、より重いか
の相対的な順序を与えます。同じように、 ‘cmp(a, b)’ などの比較関数はより
小さいときは負の値を、入力が等しい場合は 0 を、より大きい場合は正の値を
返します。

他のプログラミング言語で書かれたアルゴリズムを Python に書き直すときに比
較関数を目にすることがよくあります。また、その API の一部として比較関数
を提供しているライブラリもあります。例えば、 *note locale.strcoll():
3bcd. は比較関数です。

このような場合に対処するため、Python は比較関数をラップしてキー関数とし
て使えるようにする関数 *note functools.cmp_to_key: 11aa. を提供していま
す。

     sorted(words, key=cmp_to_key(strcoll))  # locale-aware sort order

   ---------- Footnotes ----------

   (1) 
https://upload.wikimedia.org/wikipedia/commons/1/17/Balance_à_tabac_1850.JPG


File: python.info,  Node: 残りのはしばし<2>,  Next: 部分的なソート,  Prev: 比較関数,  Up: ソートのテクニック

9.11.8 残りのはしばし
---------------------

   * ロケールに対応したソートを行うには、キー関数に *note
     locale.strxfrm(): 3bcf. を使うか、比較関数に *note
     locale.strcoll(): 3bcd. を使ってください。これが必要なのは、同じア
     ルファベットを使っていたとしても、文化が違えば "アルファベット順" の
     意味するものが変わることがあるからです。

   * 'reverse' パラメータはソートの安定性を保ちます (ですから、レコード
     のキーが等しい場合元々の順序が維持されます)。面白いことにこの影響は
     パラメータ無しで *note reversed(): 831. 関数を二回使うことで模倣す
     ることができます:

          >>> data = [('red', 1), ('blue', 1), ('red', 2), ('blue', 2)]
          >>> standard_way = sorted(data, key=itemgetter(0), reverse=True)
          >>> double_reversed = list(reversed(sorted(reversed(data), key=itemgetter(0))))
          >>> assert standard_way == double_reversed
          >>> standard_way
          [('red', 1), ('red', 2), ('blue', 1), ('blue', 2)]

   * ソート関数は、2つのオブジェクトを比較する際 ‘<’ を用います。したが
     って、クラスに標準のソート順序を追加することは *note __lt__():
     12d9. メソッドを定義することで達成できます。

          >>> Student.__lt__ = lambda self, other: self.age < other.age
          >>> sorted(student_objects)
          [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]

     ただし、‘<’ は *note __lt__(): 12d9. が実装されていなければ *note
     __gt__(): 12db. を使って代替することに注意してください (この技法に
     ついて詳しくは *note object.__lt__(): 12d9. を参照してください)。驚
     きを防ぐため、 PEP 8(1) は6つの比較メソッドを全て実装することを推奨
     しています。この作業を簡単にするため、*note total_ordering(): f0f.
     デコレータが提供されています。

   * key 関数はソートするオブジェクトに依存する必要はありません。 key 関
     数は外部リソースにアクセスすることもできます。例えば学生の成績が辞
     書に保存されている場合、それを利用して別の学生の名前のリストをソー
     トすることができます:

          >>> students = ['dave', 'john', 'jane']
          >>> newgrades = {'john': 'F', 'jane':'A', 'dave': 'C'}
          >>> sorted(students, key=newgrades.__getitem__)
          ['jane', 'dave', 'john']

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0008/


File: python.info,  Node: 部分的なソート,  Prev: 残りのはしばし<2>,  Up: ソートのテクニック

9.11.9 部分的なソート
---------------------

アプリケーションには、データの一部のみが整列されていればよいものがありま
す。標準ライブラリは完全なソートより少ない作業をするいくつかのツールを提
供します。

   * *note min(): ed3. と *note max(): ed4. はそれぞれ最小値と最大値を返
     します。これらの関数は入力データを一度だけ通過し、補助的なメモリを
     ほとんど要求しません。

   * *note heapq.nsmallest(): 2489. と *note heapq.nlargest(): 2488. は
     それぞれ最小と最大の値 'n' 個を返します。これらの関数はデータを一度
     だけ通過し、一度に 'n' 要素だけを記憶します。入力の数に対して小さい
     'n' の値では、これらの関数は完全なソートより比較の回数がはるかに少
     なくなります。

   * *note heapq.heappush(): 1461. と *note heapq.heappop(): 1462. は最
     小の要素がつねに位置 ‘0’ になる、部分的にソートされたデータの配列を
     作り維持します。これらの関数はタスクスケジューリングに一般的に使わ
     れる優先度キューを実装するのに適しています。


File: python.info,  Node: Unicode HOWTO,  Next: urllib パッケージを使ってインターネット上のリソースを取得するには,  Prev: ソートのテクニック,  Up: Python HOWTO

9.12 Unicode HOWTO
==================


リリース: 1.12

この HOWTO 文書は、文字データの表現のための Unicode 仕様の Python におけ
るサポートについて論じ、さらに Unicode を使おうというときによく出喰わす
多くの問題について説明します。

* Menu:

* Unicode 入門::
* Python の Unicode サポート::
* Unicode データを読み書きする::
* 謝辞: 謝辞<10>.


File: python.info,  Node: Unicode 入門,  Next: Python の Unicode サポート,  Up: Unicode HOWTO

9.12.1 Unicode 入門
-------------------

* Menu:

* 定義::
* エンコーディング: エンコーディング<3>.
* 参考資料: 参考資料<3>.


File: python.info,  Node: 定義,  Next: エンコーディング<3>,  Up: Unicode 入門

9.12.1.1 定義
.............

今日のプログラムは広範囲の文字を扱える必要があります。 アプリケーション
は国際化され、ユーザーが選べる様々な言語でメッセージや出力を表示します;
同じプログラムが、英語、フランス語、日本語、ヘブライ語、ロシア語でエラー
メッセージを出力する必要があるかもしれません。 Webコンテンツはどんな言語
でも書かれる可能性がありますし、様々な絵文字が含まれることもあります。
Python の文字列型は文字表現のための Unicode 標準を使っていて、 Python プ
ログラムは有り得る様々な文字を全て扱えます。

Unicode (‘https://www.unicode.org/’) は、人類の言語で使われる全ての文字
を列挙し、それぞれの文字自身の一意な符号を与えるのを目的とした仕様です。
Unicode 仕様は継続的に改訂され、新しい言語や記号を追加する更新がなされて
います。

'文字' は文章の最小の構成要素です。 'A', 'B', 'C' などは全て異なる文字で
す。 'È' と 'Í' も同様に異なる文字です。 文字は、話している言語や文脈に
よって変わってきます。 例えば、「ローマ数字の 1」という文字 'Ⅰ' は大文字
の 'I' とは別の文字です。 両者は通常は同じに見えますが、異なる意味を持つ
別々の2つの文字です。

The Unicode standard describes how characters are represented by 'code
points'.  A code point value is an integer in the range 0 to 0x10FFFF
(about 1.1 million values, the actual number assigned(1) is less than
that).  In the standard and in this document, a code point is written
using the notation ‘U+265E’ to mean the character with value ‘0x265e’
(9,822 in decimal).

Unicode 標準は、文字とそれに対応するコードポイントを列挙した多くの表を含
んでいます:

     0061    'a'; LATIN SMALL LETTER A
     0062    'b'; LATIN SMALL LETTER B
     0063    'c'; LATIN SMALL LETTER C
     ...
     007B    '{'; LEFT CURLY BRACKET
     ...
     2167    'Ⅷ'; ROMAN NUMERAL EIGHT
     2168    'Ⅸ'; ROMAN NUMERAL NINE
     ...
     265E    '♞'; BLACK CHESS KNIGHT
     265F    '♟'; BLACK CHESS PAWN
     ...
     1F600   '😀'; GRINNING FACE
     1F609   '😉'; WINKING FACE
     ...

厳密には、この定義から「これは文字 ‘U+265E’ です」と言うのは意味の無いこ
とだと分かります。‘U+265E’ はコードポイントであり、それはある特定の文字
を表しているのです; この場合では、 'BLACK CHESS KNIGHT', '♞' という文字
を表しています。 形式ばらない文脈では、このコードポイントと文字の区別は
忘れ去られることもあります。

文字は画面や紙面上では 'グリフ (glyph)' と呼ばれるグラフィック要素の組で
表示されます。大文字の A のグリフは例えば、厳密な形は使っているフォント
によって異なりますが、斜めの線と水平の線です。たいていの Python コードで
はグリフの心配をする必要はありません; 一般的には表示する正しいグリフを見
付けることは GUI toolkit や端末のフォントレンダラーの仕事です。

   ---------- Footnotes ----------

   (1) https://www.unicode.org/versions/latest/#Summary


File: python.info,  Node: エンコーディング<3>,  Next: 参考資料<3>,  Prev: 定義,  Up: Unicode 入門

9.12.1.2 エンコーディング
.........................

前の節をまとめると: Unicode 文字列はコードポイントの列であり、コードポイ
ントとは 0 から ‘0x10FFFF’ (10 進表記で 1,114,111) までの数値です。この
コードポイント列はメモリ上では 'コードユニット' 列として表され、その 'コ
ードユニット' 列は 8-bit のバイト列にマップされます。Unicode 文字列をバ
イト列として翻訳する規則を '文字エンコーディング' または単に 'エンコーデ
ィング' と呼びます。

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:

        P           y           t           h           o           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
        0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23

この表現は直接的でわかりやすい方法ですが、この表現を使うにはいくつかの問
題があります。

  1. 可搬性がない; プロセッサが異なるとバイトの順序づけも変わってしまい
     ます。

  2. 無駄な領域が多いです。多くの文書では、コードポイントは 127 未満もし
     くは 255 未満が多数派を占め、そのため多くの領域が ‘0x00’ というバイ
     トで埋め尽くされます。上の文字列は、ASCII 表現では 6 バイトなのに対
     し、24 バイトのサイズになっています。RAM の使用量が増加するのはそれ
     ほど問題にはなりません (デスクトップコンピュータはギガバイト単位の
     RAM を持っており、通常、文字列はそんな大きさにはなりません) が、デ
     ィスクとネットワーク帯域が 4 倍多く使われてしまうのは我慢できるもの
     ではありません。

  3. ‘strlen()’ のような現存する C 関数と互換性がありません、そのためワ
     イド文字列関数一式が新たに必要となります。

Therefore this encoding isn't used very much, and people instead choose
other encodings that are more efficient and convenient, such as UTF-8.

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' means that 8-bit values are used in the encoding.  (There
are also UTF-16 and UTF-32 encodings, but they are less frequently used
than UTF-8.)  UTF-8 uses the following rules:

  1. コードポイントが 128 未満だった場合、対応するバイト値で表現します。

  2. コードポイントが 128 以上の場合、128 から 255 までのバイトからなる
     、2、3 または 4 バイトのシーケンスに変換します。

UTF-8 はいくつかの便利な性質を持っています:

  1. 任意の Unicode コードポイントを扱うことができる。

  2. 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 that UTF-8 strings can be processed by C
     functions such as ‘strcpy()’ and sent through protocols that can't
     handle zero bytes for anything other than end-of-string markers.

  3. ASCII テキストの文字列は UTF-8 テキストとしても有効です。

  4. UTF-8 はかなりコンパクトです; よく使われている文字の大多数は 1 バイ
     トか 2 バイトで表現できます。

  5. バイトが欠落したり、失われた場合、次の UTF-8 でエンコードされたコー
     ドポイントの開始を決定し、再同期することができる可能性があります。
     同様の理由でランダムな 8-bit データは正当な UTF-8 とみなされにくく
     なっています。

  6. 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 avoids the byte-ordering issues that can occur with
     integer and word oriented encodings, like UTF-16 and UTF-32, where
     the sequence of bytes varies depending on the hardware on which the
     string was encoded.


File: python.info,  Node: 参考資料<3>,  Prev: エンコーディング<3>,  Up: Unicode 入門

9.12.1.3 参考資料
.................

Unicode コンソーシアムのサイト(1) には文字の図表、用語辞典、PDF 版の
Unicode 仕様があります。これ読むのはそれなりに難しいので覚悟してください
。Unicode の起源と発展の 年表(2) もサイトにあります。

On the Computerphile Youtube channel, Tom Scott briefly discusses the
history of Unicode and UTF-8(3) (9 minutes 36 seconds).

標準を理解する助けにするために、Jukka Korpela が Unicode 文字表を読むた
めの 入門ガイド(4) を書いています。

Another good introductory article(5) was written by Joel Spolsky.  If
this introduction didn't make things clear to you, you should try
reading this alternate article before continuing.

Wikipedia の記事はしばしば役に立ちます; 例えば、"character encoding(6)"
や UTF-8(7) の記事を読んでみてください。

   ---------- Footnotes ----------

   (1) https://www.unicode.org

   (2) https://www.unicode.org/history/

   (3) https://www.youtube.com/watch?v=MijmeoH9LT4

   (4) https://jkorpela.fi/unicode/guide.html

   (5) 
https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/

   (6) https://en.wikipedia.org/wiki/Character_encoding

   (7) https://en.wikipedia.org/wiki/UTF-8


File: python.info,  Node: Python の Unicode サポート,  Next: Unicode データを読み書きする,  Prev: Unicode 入門,  Up: Unicode HOWTO

9.12.2 Python の Unicode サポート
---------------------------------

ここまでで Unicode の基礎を学びました、ここから Python の Unicode 機能に
触れます。

* Menu:

* 文字列型::
* バイト列への変換::
* Python ソースコード内の Unicode リテラル::
* Unicode プロパティ::
* Comparing Strings::
* Unicode 正規表現::
* 参考資料: 参考資料<4>.


File: python.info,  Node: 文字列型,  Next: バイト列への変換,  Up: Python の Unicode サポート

9.12.2.1 文字列型
.................

Since Python 3.0, the language's *note str: 418. type contains Unicode
characters, meaning any string created using ‘"unicode rocks!"’,
‘'unicode rocks!'’, or the triple-quoted string syntax is stored as
Unicode.

Python ソースコードのデフォルトエンコーディングは UTF-8 なので、文字列リ
テラルの中に Unicode 文字をそのまま含めることができます:

     try:
         with open('/tmp/input.txt', 'r') as f:
             ...
     except OSError:
         # 'File not found' error message.
         print("Fichier non trouvé")

追記: Python3 は Unicode 文字を使った識別子もサポートしています:

     répertoire = "/tmp/records.log"
     with open(répertoire, "w") as f:
         f.write("test\n")

エディタである特定の文字が入力できなかったり、とある理由でソースコードを
ASCII のみに保ちたい場合は、文字列リテラルでエスケープシーケンスが使えま
す。(使ってるシステムによっては、u でエスケープされた文字列ではなく、実
物の大文字のラムダのグリフが見えるかもしれません。):

     >>> "\N{GREEK CAPITAL LETTER DELTA}"  # Using the character name
     '\u0394'
     >>> "\u0394"                          # Using a 16-bit hex value
     '\u0394'
     >>> "\U00000394"                      # Using a 32-bit hex value
     '\u0394'

加えて、 *note bytes: 1a4. クラスの *note decode(): 8a4. メソッドを使っ
て文字列を作ることもできます。このメソッドは ‘UTF-8’ のような値を
'encoding' 引数に取り、オプションで 'errors' 引数を取ります。

'errors' 引数は、入力文字列に対しエンコーディングルールに従った変換がで
きなかったときの対応方法を指定します。この引数に使える値は ‘'strict'’
(*note UnicodeDecodeError: 9e1. を送出する)、 ‘'replace'’ (‘REPLACEMENT
CHARACTER’ である ‘U+FFFD’ を使う)、 ‘'ignore'’ (結果となる Unicode から
単に文字を除く) 、‘'backslashreplace'’ (エスケープシーケンス ‘\xNN’ を挿
入する) です。次の例はこれらの違いを示しています:

     >>> b'\x80abc'.decode("utf-8", "strict")
     Traceback (most recent call last):
         ...
     UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0:
       invalid start byte
     >>> b'\x80abc'.decode("utf-8", "replace")
     '\ufffdabc'
     >>> b'\x80abc'.decode("utf-8", "backslashreplace")
     '\\x80abc'
     >>> b'\x80abc'.decode("utf-8", "ignore")
     'abc'

エンコーディングはエンコーディングの名前を含んだ文字列で指定されます。
Python はおよそ 100 の異なるエンコーディングに対応しています; 一覧は
Python ライブラリリファレンスの *note 標準エンコーディング: d86. を参照
してください。いくつかのエンコーディングは複数の名前を持っています; 例え
ば、 ‘'latin-1'’ と ‘'iso_8859_1'’ と ‘'8859'’ は全て同じエンコーディン
グの別名です。

Unicode 文字列の一つの文字は *note chr(): 15d6. 組み込み関数で作成するこ
とができます、この関数は整数を引数にとり、対応するコードポイントを含む長
さ1の Unicode 文字列を返します。逆の操作は *note ord(): 1e51. 組み込み関
数です、この関数は一文字の Unicode 文字列を引数にとり、コードポイント値
を返します:

     >>> chr(57344)
     '\ue000'
     >>> ord('\ue000')
     57344


File: python.info,  Node: バイト列への変換,  Next: Python ソースコード内の Unicode リテラル,  Prev: 文字列型,  Up: Python の Unicode サポート

9.12.2.2 バイト列への変換
.........................

*note bytes.decode(): 8a4. とは処理が逆向きのメソッドが *note
str.encode(): 8a3. です。このメソッドは、 Unicode 文字列を指定された
'encoding' でエンコードして、 *note bytes: 1a4. による表現で返します。

'errors' 引数は *note decode(): 8a4. メソッドのパラメータと同じものです
が、サポートされているハンドラの数がもう少し多いです。 ‘'strict'’ 、
‘'ignore'’ 、 ‘'replace'’ (このメソッドでは、エンコードできなかった文字
の代わりに疑問符を挿入する) の他に、 ‘'xmlcharrefreplace'’ (XML 文字参照
を挿入する) と ‘backslashreplace’ (エスケープシーケンス ‘\nNNNN’ を挿入
する)、 ‘namereplace’ (エスケープシーケンス ‘\N{...}’ を挿入する) があり
ます。

次の例では、それぞれの異なる処理結果が示されています:

     >>> u = chr(40960) + 'abcd' + chr(1972)
     >>> u.encode('utf-8')
     b'\xea\x80\x80abcd\xde\xb4'
     >>> u.encode('ascii')
     Traceback (most recent call last):
         ...
     UnicodeEncodeError: 'ascii' codec can't encode character '\ua000' in
       position 0: ordinal not in range(128)
     >>> u.encode('ascii', 'ignore')
     b'abcd'
     >>> u.encode('ascii', 'replace')
     b'?abcd?'
     >>> u.encode('ascii', 'xmlcharrefreplace')
     b'&#40960;abcd&#1972;'
     >>> u.encode('ascii', 'backslashreplace')
     b'\\ua000abcd\\u07b4'
     >>> u.encode('ascii', 'namereplace')
     b'\\N{YI SYLLABLE IT}abcd\\u07b4'

利用可能なエンコーディングを登録したり、アクセスしたりする低レベルのルー
チンは *note codecs: 14. モジュールにあります。新しいエンコーディングを
実装するには、 *note codecs: 14. モジュールを理解していることも必要にな
ります。しかし、このモジュールのエンコードやデコードの関数は、使い勝手が
良いというより低レベルな関数で、新しいエンコーディングを書くのは特殊な作
業なので、この HOWTO では扱わないことにします。


File: python.info,  Node: Python ソースコード内の Unicode リテラル,  Next: Unicode プロパティ,  Prev: バイト列への変換,  Up: Python の Unicode サポート

9.12.2.3 Python ソースコード内の Unicode リテラル
.................................................

Python のソースコード内では、特定のコードポイントはエスケープシーケンス
‘\u’ を使い、続けてコードポイントを4桁の16進数を書きます。エスケープシー
ケンス ‘\U’ も同様です、ただし4桁ではなく8桁の16進数を使います:

     >>> s = "a\xac\u1234\u20ac\U00008000"
     ... #     ^^^^ two-digit hex escape
     ... #         ^^^^^^ four-digit Unicode escape
     ... #                     ^^^^^^^^^^ eight-digit Unicode escape
     >>> [ord(c) for c in s]
     [97, 172, 4660, 8364, 32768]

127 より大きいコードポイントに対してエスケープシーケンスを使うのは、エス
ケープシーケンスがあまり多くないうちは有効ですが、フランス語等のアクセン
トを使う言語でメッセージのような多くのアクセント文字を使う場合には邪魔に
なります。文字を *note chr(): 15d6. 組み込み関数を使って組み上げることも
できますが、それはさらに長くなってしまうでしょう。

理想的にはあなたの言語の自然なエンコーディングでリテラルを書くことでしょ
う。そうなれば、Python のソースコードをアクセント付きの文字を自然に表示
するお気に入りのエディタで編集し、実行時に正しい文字が得られます。

Python はデフォルトでは UTF-8 ソースコードを書くことができます、ただしど
のエンコーディングを使うかを宣言すればほとんどのエンコーディングを使えま
す。それはソースファイルの一行目や二行目に特別なコメントを含めることによ
ってできます:

     #!/usr/bin/env python
     # -*- coding: latin-1 -*-

     u = 'abcdé'
     print(ord(u[-1]))

この構文は Emacs のファイル固有の変数を指定する表記から影響を受けていま
す。Emacs は様々な変数をサポートしていますが、Python がサポートしている
のは 'coding' のみです。 ‘-*-’ の記法は Emacs に対してコメントが特別であ
ることを示します。これは Python にとって意味はありませんが慣習で使われて
います。 Python はコメント中に ‘coding: name’ または ‘coding=name’ を探
します。

このようなコメントを含んでいない場合、すでに述べた通り、使われるデフォル
トエンコーディングは UTF-8 になります。より詳しい情報は PEP 263(1) を参
照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0263/


File: python.info,  Node: Unicode プロパティ,  Next: Comparing Strings,  Prev: Python ソースコード内の Unicode リテラル,  Up: Python の Unicode サポート

9.12.2.4 Unicode プロパティ
...........................

The Unicode specification includes a database of information about code
points.  For each defined code point, the information includes the
character's name, its category, the numeric value if applicable (for
characters representing numeric concepts such as the Roman numerals,
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.

以下のプログラムはいくつかの文字に対する情報を表示し、特定の文字の数値を
印字します:

     import unicodedata

     u = chr(233) + chr(0x0bf2) + chr(3972) + chr(6000) + chr(13231)

     for i, c in enumerate(u):
         print(i, '%04x' % ord(c), unicodedata.category(c), end=" ")
         print(unicodedata.name(c))

     # Get numeric value of second character
     print(unicodedata.numeric(u[1]))

実行すると、このように出力されます:

     0 00e9 Ll LATIN SMALL LETTER E WITH ACUTE
     1 0bf2 No TAMIL NUMBER ONE THOUSAND
     2 0f84 Mn TIBETAN MARK HALANTA
     3 1770 Lo TAGBANWA LETTER SA
     4 33af So SQUARE RAD OVER S SQUARED
     1000.0

カテゴリーコードは文字の性質を略記で表したものです。カテゴリーコードは
"Letter"、"Number"、"Punctuation"、"Symbol" などのカテゴリーに分類され、
さらにサブカテゴリーに細分化されます。上記の出力からコードを拾うと、
‘'Ll'’ は 'Letter, lowercase'、‘'No'’ は "Number, other"、‘'Mn'’ は
"Mark, nonspacing"、‘'So'’ は "Symbol, other" を意味しています。カテゴリ
ーコードの一覧は Unicode Character Database 文書の General Category
Values 節(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://www.unicode.org/reports/tr44/#General_Category_Values


File: python.info,  Node: Comparing Strings,  Next: Unicode 正規表現,  Prev: Unicode プロパティ,  Up: Python の Unicode サポート

9.12.2.5 Comparing Strings
..........................

Unicode adds some complication to comparing strings, because the same
set of characters can be represented by different sequences of code
points.  For example, a letter like 'ê' can be represented as a single
code point U+00EA, or as U+0065 U+0302, which is the code point for 'e'
followed by a code 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.

One tool for a case-insensitive comparison is the *note casefold(): da3.
string method that converts a string to a case-insensitive form
following an algorithm described by the Unicode Standard.  This
algorithm has special handling for characters such as the German letter
'ß' (code point U+00DF), which becomes the pair of lowercase letters
'ss'.

     >>> street = 'Gürzenichstraße'
     >>> street.casefold()
     'gürzenichstrasse'

A second tool is the *note unicodedata: ee. module's *note normalize():
6a0. function that converts strings to one of several normal forms,
where letters followed by a combining character are replaced with single
characters.  *note normalize(): 6a0. can be used to perform string
comparisons that won't falsely report inequality if two strings use
combining characters differently:

     import unicodedata

     def compare_strs(s1, s2):
         def NFD(s):
             return unicodedata.normalize('NFD', s)

         return NFD(s1) == NFD(s2)

     single_char = 'ê'
     multiple_chars = '\N{LATIN SMALL LETTER E}\N{COMBINING CIRCUMFLEX ACCENT}'
     print('length of first string=', len(single_char))
     print('length of second string=', len(multiple_chars))
     print(compare_strs(single_char, multiple_chars))

実行すると、このように出力されます:

     $ python compare-strs.py
     length of first string= 1
     length of second string= 2
     True

The first argument to the *note normalize(): 6a0. function is a string
giving the desired normalization form, which can be one of 'NFC',
'NFKC', 'NFD', and 'NFKD'.

The Unicode Standard also specifies how to do caseless comparisons:

     import unicodedata

     def compare_caseless(s1, s2):
         def NFD(s):
             return unicodedata.normalize('NFD', s)

         return NFD(NFD(s1).casefold()) == NFD(NFD(s2).casefold())

     # Example usage
     single_char = 'ê'
     multiple_chars = '\N{LATIN CAPITAL LETTER E}\N{COMBINING CIRCUMFLEX ACCENT}'

     print(compare_caseless(single_char, multiple_chars))

This will print ‘True’.  (Why is ‘NFD()’ invoked twice?  Because there
are a few characters that make *note casefold(): da3. 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.)


File: python.info,  Node: Unicode 正規表現,  Next: 参考資料<4>,  Prev: Comparing Strings,  Up: Python の Unicode サポート

9.12.2.6 Unicode 正規表現
.........................

*note re: a7. モジュールがサポートしている正規表現はバイト列や文字列とし
て与えられます。 ‘\d’ や ‘\w’ などのいくつかの特殊な文字シーケンスは、そ
のパターンがバイト列として与えられたのか文字列として与えられたのかによっ
て、異なる意味を持ちます。例えば、 ‘\d’ はバイト列では ‘[0-9]’ の範囲の
文字と一致しますが、文字列では ‘'Nd'’ カテゴリーにある任意の文字と一致し
ます。

この例にある文字列には、タイ語の数字とアラビア数字の両方で数字の 57 が書
いてあります。

     import re
     p = re.compile(r'\d+')

     s = "Over \u0e55\u0e57 57 flavours"
     m = p.search(s)
     print(repr(m.group()))

実行すると、 ‘\d+’ はタイ語の数字と一致し、それを出力します。フラグ
*note re.ASCII: 5f8. を *note compile(): ba1. に渡した場合、 ‘\d+’ は先
程とは違って部分文字列 "57" に一致します。

同様に、 ‘\w’ は非常に多くの Unicode 文字に一致しますが、バイト列の場合
もしくは *note re.ASCII: 5f8. が渡された場合は ‘[a-zA-Z0-9_]’ にしか一致
しません。 ‘\s’ は文字列では Unicode 空白文字に、バイト列では ‘[
\t\n\r\f\v]’ に一致します。


File: python.info,  Node: 参考資料<4>,  Prev: Unicode 正規表現,  Up: Python の Unicode サポート

9.12.2.7 参考資料
.................

Python の Unicode サポートについての参考になる議論は以下の2つです:

   * Nick Coghlan による Processing Text Files in Python 3(1)

   * Ned Batchelder による PyCon 2012 での発表 Pragmatic Unicode(2)

*note str: 418. 型については Python ライブラリリファレンスの *note
テキストシーケンス型 -- str: 1b67. で解説されています。

*note unicodedata: ee. モジュールについてのドキュメント。

*note codecs: 14. モジュールについてのドキュメント。

Marc-André Lemburg は EuroPython 2002 で "Python and Unicode" というタイ
トルのプレゼンテーション (PDF スライド)(3) を行いました。このスライドは
Python 2 の Unicode 機能 (Unicode 文字列型が ‘unicode’ と呼ばれ、リテラ
ルは ‘u’ で始まります) の設計について概観する素晴しい資料です。

   ---------- Footnotes ----------

   (1) 
https://python-notes.curiousefficiency.org/en/latest/python3/text_file_processing.html

   (2) https://nedbatchelder.com/text/unipain.html

   (3) https://downloads.egenix.com/python/Unicode-EPC2002-Talk.pdf


File: python.info,  Node: Unicode データを読み書きする,  Next: 謝辞<10>,  Prev: Python の Unicode サポート,  Up: Unicode HOWTO

9.12.3 Unicode データを読み書きする
-----------------------------------

一旦 Unicode データに対してコードが動作するように書き終えたら、次の問題
は入出力です。プログラムは Unicode 文字列をどう受けとり、どう Unicode を
外部記憶装置や送受信装置に適した形式に変換するのでしょう?

入力ソースと出力先に依存しないような方法は可能です; アプリケーションに利
用されているライブラリが Unicode をそのままサポートしているかを調べなけ
ればいけません。例えば XML パーサーは大抵 Unicode データを返します。多く
のリレーショナルデータベースも Unicode 値の入ったコラムをサポートしてい
ますし、 SQL の問い合わせで Unicode 値を返すことができます。

Unicode のデータはディスクに書き込まれたり、ソケットを介して送信されたり
するにあたって、通常、特定のエンコーディングに変換されます。推奨はされま
せんが、これを手動で行うことも可能です。ファイルを開き、8バイトオブジェ
クトを読み込み、バイト列を ‘bytes.decode(encoding)’ で変換することにより
実現できます。

1つの問題はエンコーディングがマルチバイトに渡るという性質です; 1つの
Unicode 文字はいくつかのバイトで表現され得ます。任意のサイズのチャンク
(例えば、1024 もしくは 4096 バイト) にファイルの内容を読み込みたい場合、
ある1つの Unicode 文字をエンコードしたバイト列の一部だけがチャンクの末尾
まで読み込まれたケースに対応する、エラー処理コードを書く必要があります。
1つの解決策はファイル全体をメモリに読み込み、デコード処理を実行すること
ですが、こうしてしまうと非常に大きなファイルを処理するときの妨げになりま
す; 2 GiB のファイルを読み込む必要がある場合、2 GiB の RAM が必要になり
ます。(実際には、少なくともある瞬間では、エンコードされた文字列と
Unicode 文字列の両方をメモリに保持する必要があるため、より多くのメモリが
必要です。)

The solution would be to use the low-level decoding interface to catch
the case of partial coding sequences.  The work of implementing this has
already been done for you: the built-in *note open(): 4e5. function can
return a file-like object that assumes the file's contents are in a
specified encoding and accepts Unicode parameters for methods such as
*note read(): 1bef. and *note write(): 1bde.  This works through *note
open(): 4e5.'s 'encoding' and 'errors' parameters which are interpreted
just like those in *note str.encode(): 8a3. and *note bytes.decode():
8a4.

そのためファイルから Unicode を読むのは単純です:

     with open('unicode.txt', encoding='utf-8') as f:
         for line in f:
             print(repr(line))

読み書きの両方ができる update モードでファイルを開くことも可能です:

     with open('test', encoding='utf-8', mode='w+') as f:
         f.write('\u4500 blah blah blah\n')
         f.seek(0)
         print(repr(f.readline()[:1]))

Unicode 文字 ‘U+FEFF’ は byte-order mark (BOM) として使われ、ファイルの
バイト順の自動判定を支援するために、ファイルの最初の文字として書かれます
。UTF-16 のようないくつかのエンコーディングは、ファイルの先頭に BOM があ
ることを要求します; そのようなエンコーディングが使われるとき、自動的に
BOM が最初の文字として書かれ、ファイルを読むときに暗黙の内に取り除かれま
す。これらのエンコーディングには、リトルエンディアン (little-endian) 用
の 'utf-16-le' やビッグエンディアン (big-endian) 用の 'utf-16-be' という
ような変種があり、これらは特定の1つのバイト順を指定していて BOM をスキッ
プしません。

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 dependent.  The mark simply announces that the file is
encoded in UTF-8.  For reading such files, use the 'utf-8-sig' codec to
automatically skip the mark if present.

* Menu:

* Unicode ファイル名::
* Unicode 対応のプログラムを書くための Tips::
* 参考資料: 参考資料<5>.


File: python.info,  Node: Unicode ファイル名,  Next: Unicode 対応のプログラムを書くための Tips,  Up: Unicode データを読み書きする

9.12.3.1 Unicode ファイル名
...........................

Most of the operating systems in common use today support filenames that
contain arbitrary Unicode characters.  Usually this is implemented by
converting the Unicode string into some encoding that varies depending
on the system.  Today Python is converging on using UTF-8: Python on
MacOS has used UTF-8 for several versions, and Python 3.6 switched to
using UTF-8 on Windows as well.  On Unix systems, there will only be a
*note filesystem encoding: 505.  if you've set the ‘LANG’ or ‘LC_CTYPE’
environment variables; if you haven't, the default encoding is again
UTF-8.

*note sys.getfilesystemencoding(): c27. 関数は現在のシステムで利用するエ
ンコーディングを返し、エンコーディングを手動で設定したい場合利用します、
ただしわざわざそうする積極的な理由はありません。読み書きのためにファイル
を開く時には、ファイル名を Unicode 文字列として渡すだけで正しいエンコー
ディングに自動的に変更されます:

     filename = 'filename\u4500abc'
     with open(filename, 'w') as f:
         f.write('blah\n')

*note os.stat(): 46d. のような *note os: 91. モジュールの関数も Unicode
のファイル名を受け付けます。

The *note os.listdir(): 10cd. function returns filenames, which raises
an issue: should it return the Unicode version of filenames, or should
it return bytes containing the encoded versions?  *note os.listdir():
10cd. can do both, depending on whether you provided the directory path
as bytes or a Unicode string.  If you pass a Unicode string as the path,
filenames will be decoded using the filesystem's encoding and a list of
Unicode strings will be returned, while passing a byte path will return
the filenames as bytes.  For example, assuming the default *note
filesystem encoding: 505. is UTF-8, running the following program:

     fn = 'filename\u4500abc'
     f = open(fn, 'w')
     f.close()

     import os
     print(os.listdir(b'.'))
     print(os.listdir('.'))

以下の出力結果が生成されます:

     $ python listdir-test.py
     [b'filename\xe4\x94\x80abc', ...]
     ['filename\u4500abc', ...]

最初のリストは UTF-8 でエンコーディングされたファイル名を含み、第二のリ
ストは Unicode 版を含んでいます。

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.


File: python.info,  Node: Unicode 対応のプログラムを書くための Tips,  Next: 参考資料<5>,  Prev: Unicode ファイル名,  Up: Unicode データを読み書きする

9.12.3.2 Unicode 対応のプログラムを書くための Tips
..................................................

この章では Unicode を扱うプログラムを書くためのいくつかの提案を紹介しま
す。

最も重要な助言としては:

     ソフトウェアは内部では Unicode 文字列のみを利用し、入力データはでき
     るだけ早期にデコードし、出力の直前でエンコードすべきです。

If you attempt to write processing functions that accept both Unicode
and byte strings, you will find your program vulnerable to bugs wherever
you combine the two different kinds of strings.  There is no automatic
encoding or decoding: if you do e.g.  ‘str + bytes’, a *note TypeError:
502. will be raised.

web ブラウザから来るデータやその他の信頼できないところからのデータを利用
する場合、それらの文字列から生成したコマンド行の実行や、それらの文字列を
データベースに蓄える前に文字列の中に不正な文字が含まれていないか確認する
のが一般的です。もしそういう状況になった場合には、エンコードされたバイト
データではなく、デコードされた文字列のチェックを入念に行なって下さい; い
くつかのエンコーディングは問題となる性質を持っています、例えば全単射でな
かったり、完全に ASCII 互換でないなど。入力データがエンコーディングを指
定している場合でもそうして下さい、なぜなら攻撃者は巧みに悪意あるテキスト
をエンコードした文字列の中に隠すことができるからです。

* Menu:

* ファイルエンコーディングの変換::
* 不明なエンコーディングのファイル::


File: python.info,  Node: ファイルエンコーディングの変換,  Next: 不明なエンコーディングのファイル,  Up: Unicode 対応のプログラムを書くための Tips

9.12.3.3 ファイルエンコーディングの変換
.......................................

The *note StreamRecoder: 195c. 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.

For example, if you have an input file 'f' that's in Latin-1, you can
wrap it with a *note StreamRecoder: 195c. to return bytes encoded in
UTF-8:

     new_f = codecs.StreamRecoder(f,
         # en/decoder: used by read() to encode its results and
         # by write() to decode its input.
         codecs.getencoder('utf-8'), codecs.getdecoder('utf-8'),

         # reader/writer: used to read and write to the stream.
         codecs.getreader('latin-1'), codecs.getwriter('latin-1') )


File: python.info,  Node: 不明なエンコーディングのファイル,  Prev: ファイルエンコーディングの変換,  Up: Unicode 対応のプログラムを書くための Tips

9.12.3.4 不明なエンコーディングのファイル
.........................................

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:

     with open(fname, 'r', encoding="ascii", errors="surrogateescape") as f:
         data = f.read()

     # make changes to the string 'data'

     with open(fname + '.new', 'w',
               encoding="ascii", errors="surrogateescape") as f:
         f.write(data)

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.


File: python.info,  Node: 参考資料<5>,  Prev: Unicode 対応のプログラムを書くための Tips,  Up: Unicode データを読み書きする

9.12.3.5 参考資料
.................

One section of Mastering Python 3 Input/Output(1), a PyCon 2010 talk by
David Beazley, discusses text processing and binary data handling.

Marc-André Lemburg のプレゼンテーション "Writing Unicode-aware
Applications in Python" の PDF スライドが
<‘https://downloads.egenix.com/python/LSM2005-Developing-Unicode-aware-applications-in-Python.pdf’>
から入手可能です、そして文字エンコーディングの問題と同様にアプリケーショ
ンの国際化やローカライズについても議論されています。このスライドは
Python 2.x のみをカバーしています。

The Guts of Unicode in Python(2) is a PyCon 2013 talk by Benjamin
Peterson that discusses the internal Unicode representation in Python
3.3.

   ---------- Footnotes ----------

   (1) https://pyvideo.org/video/289/pycon-2010-mastering-python-3-i-o

   (2) https://pyvideo.org/video/1768/the-guts-of-unicode-in-python


File: python.info,  Node: 謝辞<10>,  Prev: Unicode データを読み書きする,  Up: Unicode HOWTO

9.12.4 謝辞
-----------

このドキュメントの最初の草稿は Andrew Kuchling によって書かれました。そ
れからさらに Alexander Belopolsky, Georg Brandl, Andrew Kuchling, Ezio
Melotti らで改訂が重ねられています。

この記事中の誤りの指摘や提案を申し出てくれた以下の人々に感謝します: Éric
Araujo, Nicholas Bastin, Nick Coghlan, Marius Gedminas, Kent Johnson,
Ken Krugler, Marc-André Lemburg, Martin von Löwis, Terry J. Reedy,
Serhiy Storchaka, Eryk Sun, Chad Whitacre, Graham Wideman.


File: python.info,  Node: urllib パッケージを使ってインターネット上のリソースを取得するには,  Next: ipaddressモジュールの紹介,  Prev: Unicode HOWTO,  Up: Python HOWTO

9.13 urllib パッケージを使ってインターネット上のリソースを取得するには
======================================================================


著者: Michael Foord(1)

* Menu:

* はじめに: はじめに<14>.
* URL を取得する::
* 例外を処理する: 例外を処理する<2>.
* info と geturl::
* Openers と Handlers::
* Basic 認証::
* プロキシ::
* ソケットとレイヤー::
* 脚注::

   ---------- Footnotes ----------

   (1) https://agileabstractions.com/


File: python.info,  Node: はじめに<14>,  Next: URL を取得する,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.1 はじめに
---------------

Related Articles
................

同じように Python でインターネットリソースを取得するのに以下の記事が役に
立ちます:

   * Basic Authentication(1)

          'Basic 認証' についてのチュートリアルで Python の例がついてい
          ます。

'urllib.request' は URLs (Uniform Resource Locators) を取得するための
Python モジュールです。このモジュールはとても簡単なインターフェースを
'urlopen' 関数の形式で提供しています。また、このモジュールは一般的な状況
で利用するためにいくらか複雑なインターフェースも提供しています - basic 認
証やクッキー、プロキシ等。これらは handler や opener と呼ばれるオブジェ
クトとして提供されます。

urllib.request は多くの "URL スキーム" (URL の ":" の前の文字列で識別さ
れるもの - 例えば "‘ftp://python.org/’" では "ftp") の URL を、関連する
ネットワークプロトコル(例えば FTP, HTTP) を利用することで、取得できます
。

単純な状況では 'urlopen' はとても簡単に使うことができます。しかし HTTP の
URL を開くときにエラーが起きたり、特殊なケースに遭遇すると、 HyperText
Transfer Protocol に関するいくつかのことを理解する必要があります。 HTTP
に関して最も包括的で信頼できる文献は RFC 2616(2) です。この文書は技術文
書なので簡単には読めません。この HOWTO の目的は 'urllib' の利用法を例示
することです、 HTTP についてはその助けになるのに十分に詳しく載せています
。このドキュメントは *note urllib.request: f4. のドキュメントの代わりに
はなりませんが、補完する役割を持っています。

   ---------- Footnotes ----------

   (1) 
https://web.archive.org/web/20201215133350/http://www.voidspace.org.uk/python/articles/authentication.shtml

   (2) https://datatracker.ietf.org/doc/html/rfc2616.html


File: python.info,  Node: URL を取得する,  Next: 例外を処理する<2>,  Prev: はじめに<14>,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.2 URL を取得する
---------------------

urllib.request を利用する最も簡単な方法は以下です:

     import urllib.request
     with urllib.request.urlopen('http://python.org/') as response:
        html = response.read()

URL によってリソースを取得し、それを一時的な場所に保存しておきたいときは
、 *note shutil.copyfileobj(): a2b. と *note
tempfile.NamedTemporaryFile(): 492. 関数を使って行うことができます:

     import shutil
     import tempfile
     import urllib.request

     with urllib.request.urlopen('http://python.org/') as response:
         with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
             shutil.copyfileobj(response, tmp_file)

     with open(tmp_file.name) as html:
         pass

多くの urllib の利用法はこのように簡単です ('http:' の代わりに URL を
'ftp:' や 'file:' 等で始めればできます)。しかし、このチュートリアルの目
的は、特に HTTP に絞って、より複雑な状況を説明することです。

HTTP はリクエスト (request) とレスポンス (response) が基本となっています
- クライアントがリクエストし、サーバーがレスポンスを送ります。
urllib.request はこれを真似て、作成する HTTP リクエストを表現する
‘Request’ オブジェクトを備えています。リクエストオブジェクトを作成する最
も簡単な方法は取得したい URL を指定することです。‘urlopen’ をこのオブジ
ェクトを使って呼び出すと、リクエストした URL のレスポンスオブジェクトが
返されます。このレスポンスはファイルライクオブジェクトで、これはつまりレ
スポンスに ‘.read()’ と呼び出せることを意味しています:

     import urllib.request

     req = urllib.request.Request('http://python.org/')
     with urllib.request.urlopen(req) as response:
        the_page = response.read()

urllib.request は同じリクエストインターフェースを全ての URL スキームに対
して利用できるようにしています。例えば、FTP リクエストの場合はこうできま
す:

     req = urllib.request.Request('ftp://example.com/')

HTTP の場合には、リクエストオブジェクトに対して二つの特別な操作ができま
す: 一つ目はサーバーに送るデータを渡すことができる、二つ目はサーバーに送
るデータやリクエスト自身に 'ついての' 特別な情報 ("metadata")を渡すこと
ができます - これらの送られる情報は HTTP 「ヘッダ」です。今度はこれらに
関してひとつひとつ見ていきましょう。

* Menu:

* データ::
* ヘッダ::


File: python.info,  Node: データ,  Next: ヘッダ,  Up: URL を取得する

9.13.2.1 データ
...............

URL にデータを送りたい場合はよくあります (しばしば、その URL は CGI
(Common Gateway Interface) スクリプトや他の web アプリケーションを参照す
ることになります)。これは HTTP では、 'POST' リクエストとして知られる方
法で行なわれます。これは web 上で HTML フォームを埋めて送信するときにブ
ラウザが行なっていることです。全ての POST がフォームから送られるとは限り
ません: 自身のアプリケーションに対して任意のデータを POST を使って送るこ
とができます。一般的な HTML フォームの場合、データは標準的な方法でエンコ
ードされている必要があり、リクエストオブジェクトに ‘data’ 引数として渡し
ます。エンコーディングは *note urllib.parse: f3. ライブラリの関数を使っ
て行います。

     import urllib.parse
     import urllib.request

     url = 'http://www.someserver.com/cgi-bin/register.cgi'
     values = {'name' : 'Michael Foord',
               'location' : 'Northampton',
               'language' : 'Python' }

     data = urllib.parse.urlencode(values)
     data = data.encode('ascii') # data should be bytes
     req = urllib.request.Request(url, data)
     with urllib.request.urlopen(req) as response:
        the_page = response.read()

他のエンコーディングが必要な場合があることに注意して下さい (例えば、
HTML フォームからファイルをアップロードするための詳細については HTML
Specification, Form Submission(1) を見て下さい)。

‘data’ 引数を渡さない場合、urllib は 'GET' リクエストを利用します。GET と
POST リクエストの一つの違いは、POST リクエストにしばしば、「副作用」があ
ることです: POST リクエストはいくつかの方法によってシステムの状態を変化
させます (例えば100ポンドのスパムの缶詰をドアの前まで配達する注文を web
サイトで行う)。とはいえ HTTP 標準で明確にされている内容では、POST は '常
に' 副作用を持ち、GET リクエストは '決して' 副作用を持たないことを意図す
るけれども、、GET リクエストが副作用を持つことも、POST リクエストが副作
用を持たないことも、妨げられません。HTTP の GET リクエストでもデータ自身
をエンコーディングすることでデータを渡すことができます。

以下のようにして行います:

     >>> import urllib.request
     >>> import urllib.parse
     >>> data = {}
     >>> data['name'] = 'Somebody Here'
     >>> data['location'] = 'Northampton'
     >>> data['language'] = 'Python'
     >>> url_values = urllib.parse.urlencode(data)
     >>> print(url_values)  # The order may differ from below.
     name=Somebody+Here&language=Python&location=Northampton
     >>> url = 'http://www.example.com/example.cgi'
     >>> full_url = url + '?' + url_values
     >>> data = urllib.request.urlopen(full_url)

‘?’ を URL に加え、それにエンコードされた値が続くことで、完全な URL が作
られていることに注意して下さい。

   ---------- Footnotes ----------

   (1) https://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13


File: python.info,  Node: ヘッダ,  Prev: データ,  Up: URL を取得する

9.13.2.2 ヘッダ
...............

ここでは特定の HTTP ヘッダについて議論します、 HTTP リクエストにヘッダを
追加する方法について例示します。

いくつかの web サイト (1) はプログラムからブラウズされることを嫌っていた
り、異なるブラウザに対して異なるバージョンを送ります (2)。デフォルトでは
urllib は自身の情報を ‘Python-urllib/x.y’ として扱います ( ‘x’ と ‘y’ は
Python のリリースバージョンのメジャーバージョンとマイナーバージョンです
、例えば ‘Python-urllib/2.5’ など)。これによって web サイト側が混乱した
り、動作しないかもしれません。ブラウザは自身の情報を ‘User-Agent’ ヘッダ
(3) を通して扱っています。リクエストオブジェクトを作るときに、ヘッダに辞
書を渡すことができます。以下の例は上の例と同じですが、自身を Internet
Explorer (4) のバージョンの一つとして扱っています。

     import urllib.parse
     import urllib.request

     url = 'http://www.someserver.com/cgi-bin/register.cgi'
     user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'
     values = {'name': 'Michael Foord',
               'location': 'Northampton',
               'language': 'Python' }
     headers = {'User-Agent': user_agent}

     data = urllib.parse.urlencode(values)
     data = data.encode('ascii')
     req = urllib.request.Request(url, data, headers)
     with urllib.request.urlopen(req) as response:
        the_page = response.read()

レスポンスは二つの便利なメソッドも持っています。 *note info と geturl:
4e59. の節を見て下さい、この節は後で問題が起きた場合に見ておくべき内容で
す。

   ---------- Footnotes ----------

   (1) Google を例題にする。

   (2) ブラウザを検知すること (browser sniffing) は web サイトのデザイン
におけるとても悪い習慣です - web 標準を利用する方が賢明でしょう。 不幸な
ことに未だに多くの web サイトが異なるブラウザに対して異なるバージョンを
返しています。

   (3) MSIE 6 のユーザエージェントは ''Mozilla/4.0 (compatible; MSIE
6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)" です。

   (4) HTTP リクエストヘッダの詳細については、 Quick Reference to HTTP
Headers (https://jkorpela.fi/http.html) を参照して下さい。


File: python.info,  Node: 例外を処理する<2>,  Next: info と geturl,  Prev: URL を取得する,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.3 例外を処理する
---------------------

'urlopen' raises *note URLError: 3830. when it cannot handle a response
(though as usual with Python APIs, built-in exceptions such as *note
ValueError: 1e3, *note TypeError: 502. etc.  may also be raised).

*note HTTPError: fab. is the subclass of *note URLError: 3830. raised in
the specific case of HTTP URLs.

例外クラスは *note urllib.error: f2. モジュールから提供されています。

* Menu:

* URLError::
* HTTPError::
* エラーをラップする::


File: python.info,  Node: URLError,  Next: HTTPError,  Up: 例外を処理する<2>

9.13.3.1 URLError
.................

URLError が送出されることはよく起こります、それはネットワーク接続が無い
場合や、指定したサーバが無い場合です。この場合、例外は 'reason' 属性を持
っていて、この属性はエラーコードとエラーメッセージのテキストを含むタプル
です。

例:

     >>> req = urllib.request.Request('http://www.pretend_server.org')
     >>> try: urllib.request.urlopen(req)
     ... except urllib.error.URLError as e:
     ...     print(e.reason)
     ...
     (4, 'getaddrinfo failed')


File: python.info,  Node: HTTPError,  Next: エラーをラップする,  Prev: URLError,  Up: 例外を処理する<2>

9.13.3.2 HTTPError
..................

Every HTTP response from the server contains a numeric "status code".
Sometimes the status code indicates that the server is unable to fulfil
the request.  The default handlers will handle some of these responses
for you (for example, if the response is a "redirection" that requests
the client fetch the document from a different URL, urllib will handle
that for you).  For those it can't handle, urlopen will raise an *note
HTTPError: fab.  Typical errors include '404' (page not found), '403'
(request forbidden), and '401' (authentication required).

HTTP のエラーコード全てについては RFC 2616(1) の10節を参照して下さい。

The *note HTTPError: fab. instance raised will have an integer 'code'
attribute, which corresponds to the error sent by the server.

* Menu:

* エラーコード::

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2616.html


File: python.info,  Node: エラーコード,  Up: HTTPError

9.13.3.3 エラーコード
.....................

デフォルトハンドラーはリダイレクト(コードは300番台にあります) を処理し、
100-299番台のコードは成功を意味しているので、たいていの場合は400-599番台
のエラーコードのみを見るだけですみます。

*note http.server.BaseHTTPRequestHandler.responses: 38ce. は RFC 2616(1)
で利用されるレスポンスコード全てを示す便利な辞書です。この辞書は便利なの
でここに載せておきます

     # Table mapping response codes to messages; entries have the
     # form {code: (shortmessage, longmessage)}.
     responses = {
         100: ('Continue', 'Request received, please continue'),
         101: ('Switching Protocols',
               'Switching to new protocol; obey Upgrade header'),

         200: ('OK', 'Request fulfilled, document follows'),
         201: ('Created', 'Document created, URL follows'),
         202: ('Accepted',
               'Request accepted, processing continues off-line'),
         203: ('Non-Authoritative Information', 'Request fulfilled from cache'),
         204: ('No Content', 'Request fulfilled, nothing follows'),
         205: ('Reset Content', 'Clear input form for further input.'),
         206: ('Partial Content', 'Partial content follows.'),

         300: ('Multiple Choices',
               'Object has several resources -- see URI list'),
         301: ('Moved Permanently', 'Object moved permanently -- see URI list'),
         302: ('Found', 'Object moved temporarily -- see URI list'),
         303: ('See Other', 'Object moved -- see Method and URL list'),
         304: ('Not Modified',
               'Document has not changed since given time'),
         305: ('Use Proxy',
               'You must use proxy specified in Location to access this '
               'resource.'),
         307: ('Temporary Redirect',
               'Object moved temporarily -- see URI list'),

         400: ('Bad Request',
               'Bad request syntax or unsupported method'),
         401: ('Unauthorized',
               'No permission -- see authorization schemes'),
         402: ('Payment Required',
               'No payment -- see charging schemes'),
         403: ('Forbidden',
               'Request forbidden -- authorization will not help'),
         404: ('Not Found', 'Nothing matches the given URI'),
         405: ('Method Not Allowed',
               'Specified method is invalid for this server.'),
         406: ('Not Acceptable', 'URI not available in preferred format.'),
         407: ('Proxy Authentication Required', 'You must authenticate with '
               'this proxy before proceeding.'),
         408: ('Request Timeout', 'Request timed out; try again later.'),
         409: ('Conflict', 'Request conflict.'),
         410: ('Gone',
               'URI no longer exists and has been permanently removed.'),
         411: ('Length Required', 'Client must specify Content-Length.'),
         412: ('Precondition Failed', 'Precondition in headers is false.'),
         413: ('Request Entity Too Large', 'Entity is too large.'),
         414: ('Request-URI Too Long', 'URI is too long.'),
         415: ('Unsupported Media Type', 'Entity body in unsupported format.'),
         416: ('Requested Range Not Satisfiable',
               'Cannot satisfy request range.'),
         417: ('Expectation Failed',
               'Expect condition could not be satisfied.'),

         500: ('Internal Server Error', 'Server got itself in trouble'),
         501: ('Not Implemented',
               'Server does not support this operation'),
         502: ('Bad Gateway', 'Invalid responses from another server/proxy.'),
         503: ('Service Unavailable',
               'The server cannot process the request due to a high load'),
         504: ('Gateway Timeout',
               'The gateway server did not receive a timely response'),
         505: ('HTTP Version Not Supported', 'Cannot fulfill request.'),
         }

エラーが起きた場合、サーバーは HTTP エラーコード 'および' エラーページを
返して応答します。 *note HTTPError: fab. インスタンスはエラーページのレ
スポンスとして扱えます。これは code 属性だけでなく、 ‘urllib.response’ モ
ジュールが返すような read, geturl, info メソッドも持つことを意味します:

     >>> req = urllib.request.Request('http://www.python.org/fish.html')
     >>> try:
     ...     urllib.request.urlopen(req)
     ... except urllib.error.HTTPError as e:
     ...     print(e.code)
     ...     print(e.read())
     ...
     404
     b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n\n<html
       ...
       <title>Page Not Found</title>\n
       ...

   ---------- Footnotes ----------

   (1) https://datatracker.ietf.org/doc/html/rfc2616.html


File: python.info,  Node: エラーをラップする,  Prev: HTTPError,  Up: 例外を処理する<2>

9.13.3.4 エラーをラップする
...........................

So if you want to be prepared for *note HTTPError: fab. 'or' *note
URLError: 3830. there are two basic approaches.  I prefer the second
approach.

* Menu:

* その1::
* その2::


File: python.info,  Node: その1,  Next: その2,  Up: エラーをラップする

9.13.3.5 その1
..............

     from urllib.request import Request, urlopen
     from urllib.error import URLError, HTTPError
     req = Request(someurl)
     try:
         response = urlopen(req)
     except HTTPError as e:
         print('The server couldn\'t fulfill the request.')
         print('Error code: ', e.code)
     except URLError as e:
         print('We failed to reach a server.')
         print('Reason: ', e.reason)
     else:
         # everything is fine

     注釈: The ‘except HTTPError’ 'must' come first, otherwise ‘except
     URLError’ will 'also' catch an *note HTTPError: fab.


File: python.info,  Node: その2,  Prev: その1,  Up: エラーをラップする

9.13.3.6 その2
..............

     from urllib.request import Request, urlopen
     from urllib.error import URLError
     req = Request(someurl)
     try:
         response = urlopen(req)
     except URLError as e:
         if hasattr(e, 'reason'):
             print('We failed to reach a server.')
             print('Reason: ', e.reason)
         elif hasattr(e, 'code'):
             print('The server couldn\'t fulfill the request.')
             print('Error code: ', e.code)
     else:
         # everything is fine


File: python.info,  Node: info と geturl,  Next: Openers と Handlers,  Prev: 例外を処理する<2>,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.4 info と geturl
---------------------

The response returned by urlopen (or the *note HTTPError: fab. instance)
has two useful methods ‘info()’ and ‘geturl()’ and is defined in the
module *note urllib.response: f5.

   * 'geturl' - これは取得したページの実際の URL を返します。 ‘urlopen’
     (または利用される opener オブジェクト) はリダイレクトに追従するため
     、有用です。取得したページの URL は要求した URL と同じとは限りませ
     ん。

   * 'info' - これは取得したページ (特にサーバからヘッダ)を表す辞書風オ
     ブジェクトを返します。これは現在では *note http.client.HTTPMessage:
     38e5. インスタンスです。

典型的なヘッダは 'Content-length', 'Content-type' 等を含んでいます。
HTTP ヘッダの意味と利用法について簡単な説明つきの便利な一覧 Quick
Reference to HTTP Headers(1) を参照して下さい。

   ---------- Footnotes ----------

   (1) https://jkorpela.fi/http.html


File: python.info,  Node: Openers と Handlers,  Next: Basic 認証,  Prev: info と geturl,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.5 Openers と Handlers
--------------------------

URL を取得する場合、opener (混乱を招きやすい名前ですが、 *note
urllib.request.OpenerDirector: 3831. のインスタンス) を利用します。標準
的にはデフォルトの opener を - ‘urlopen’ を通して - 利用していますが、カ
スタムの opener を作成することもできます。 opener は handler を利用しま
す。全ての「一番厄介な仕事」はハンドラによって行なわれます。各 handler は
特定の URL スキーム (http, ftp, 等) での URL の開き方を知っていたり、
URL を開く局面でどう処理するかを知っています、例えば HTTP リダイレクショ
ンや HTTP のクッキーなど。

インストール済みの特定のハンドラで URL を取得したい場合には、 opener を
作成したいと思うでしょう、例えばクッキーを処理する opener が得たい場合や
、リダイレクションを処理しない opener を得たい場合。

opener を作成するには、 ‘OpenerDirector’ をインスタンス化して、続けて、
‘.add_handler(some_handler_instance)’ を呼び出します。

それに代わる方法として、 ‘build_opener’ を利用することもできます、これは
opener オブジェクトを一回の関数呼び出しで作成できる便利な関数です。
‘build_opener’ はいくつかのハンドラをデフォルトで追加しますが、デフォル
トのハンドラに対して追加、継承のどちらかまたは両方を行うのに手っ取り早い
方法を提供してくれます。

追加したくなる可能性がある handler としては、プロキシ処理、認証など、一
般的ですがいくらか特定の状況に限られるものでしょう。

‘install_opener’ も (グローバルな) デフォルト ‘opener’ オブジェクトの作
成に利用できます。つまり、 ‘urlopen’ を呼び出すと、インストールした
opener が利用されます。

opener オブジェクトは ‘open’ メソッドを持っていて、 ‘urlopen’ 関数と同じ
様に、url を取得するのに直接呼び出すことができます: 利便性を除けば
‘install_opener’ を使う必要はありません。


File: python.info,  Node: Basic 認証,  Next: プロキシ,  Prev: Openers と Handlers,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.6 Basic 認証
-----------------

To illustrate creating and installing a handler we will use the
‘HTTPBasicAuthHandler’.  For a more detailed discussion of this subject
- including an explanation of how Basic Authentication works - see the
Basic Authentication Tutorial(1).

認証が必要な場合、サーバは認証を要求するヘッダ (401 のエラーコードととも
に) を送ります。これによって認証スキームと 'realm' が指定されます。ヘッ
ダはこのようになっています: ‘WWW-Authenticate: SCHEME realm="REALM"’ 。

例

     WWW-Authenticate: Basic realm="cPanel Users"

クライアントはリクエストヘッダに含まれる realm に対して適切な名前とパス
ワードとともにリクエストを再試行する必要があります。これが 'basic 認証'
です。一連の流れを簡単化するために、 ‘HTTPBasicAuthHandler’ のインスタン
スを作成し、 opener が handler を利用するようにします。

‘HTTPBasicAuthHandler’ はパスワードマネージャーと呼ばれる、 URL と realm
をパスワードとユーザ名への対応づけを処理する、オブジェクトを利用します。
realm が何なのか(サーバから返される認証ヘッダから) 知りたい場合には、
‘HTTPPasswordMgr’ を利用できます。多くの場合、realm が何なのかについて気
にすることはありません。そのような場合には
‘HTTPPasswordMgrWithDefaultRealm’ を使うと便利です。これは URL に対して
デフォルトのユーザ名とパスワードを指定できます。これによって特定の realm
に対する代替の組み合わせを提供することなしに利用できるようになります。こ
のことは ‘add_password’ メソッドの realm 引数として ‘None’ を与えること
で明示することができます。

トップレベルの URL が認証が必要なはじめに URL です。この URL よりも「深
い」URL を渡しても .add_password() は同様にマッチします。:

     # create a password manager
     password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()

     # Add the username and password.
     # If we knew the realm, we could use it instead of None.
     top_level_url = "http://example.com/foo/"
     password_mgr.add_password(None, top_level_url, username, password)

     handler = urllib.request.HTTPBasicAuthHandler(password_mgr)

     # create "opener" (OpenerDirector instance)
     opener = urllib.request.build_opener(handler)

     # use the opener to fetch a URL
     opener.open(a_url)

     # Install the opener.
     # Now all calls to urllib.request.urlopen use our opener.
     urllib.request.install_opener(opener)

     注釈: In the above example we only supplied our
     ‘HTTPBasicAuthHandler’ to ‘build_opener’.  By default openers have
     the handlers for normal situations - ‘ProxyHandler’ (if a proxy
     setting such as an ‘http_proxy’ environment variable is set),
     ‘UnknownHandler’, ‘HTTPHandler’, ‘HTTPDefaultErrorHandler’,
     ‘HTTPRedirectHandler’, ‘FTPHandler’, ‘FileHandler’, ‘DataHandler’,
     ‘HTTPErrorProcessor’.

‘top_level_url’ は実際には "‘http://example.com/’" のような完全な URL
('http:' スキームとホスト名、オプションとしてポート番号、含む) 'あるいは
' "example.com" や "example.com:8080" (後者はポート番号を含む) のような
"authority" (つまり、ホスト名とオプションとしてポート番号を含む) の 'ど
ちらでも' かまいません。authority の場合には "userinfo" 要素は含んではい
けません - 例えば "joe:password@example.com" は不適切です。

   ---------- Footnotes ----------

   (1) 
https://web.archive.org/web/20201215133350/http://www.voidspace.org.uk/python/articles/authentication.shtml


File: python.info,  Node: プロキシ,  Next: ソケットとレイヤー,  Prev: Basic 認証,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.7 プロキシ
---------------

'urllib' は自動でプロキシ設定を認識して使います。これは通常の handler の
組に含まれる ‘ProxyHandler’ を通して行なわれます。たいていの場合はこれで
うまくいきますが、役に立たない場合もあります (1)。この問題に対処する一つ
の方法はプロキシを定義しない ‘ProxyHandler’ を組み立てることです。この方
法は Basic Authentication(2) handler を設定したときと同じような流れで行
うことができます:

     >>> proxy_support = urllib.request.ProxyHandler({})
     >>> opener = urllib.request.build_opener(proxy_support)
     >>> urllib.request.install_opener(opener)

     注釈: 現在 ‘urllib.request’ はプロキシ経由で ‘https’ ロケーションを
     取得する機能をサポートしていません。しかし、urllib.request をこのレ
     シピ (3) で拡張することで可能にすることができます。

     注釈: 変数 ‘REQUEST_METHOD’ が設定されている場合、 ‘HTTP_PROXY’ は
     無視されます; *note getproxies(): 382d. のドキュメンテーションを参
     照してください。

   ---------- Footnotes ----------

   (1) 私の場合は仕事中にインターネットにアクセスするにはプロキシを利用
する必要があります。'localhost' の URL に対してこのプロキシを経由してア
クセスしようとすれば、ブロックされます。IE を proxy を利用するように設定
すれば、urllib はその情報を利用します。localhost のサーバでスクリプトを
テストしようとすると、urllib がプロキシを利用するのを止めなければいけま
せん。

   (2) 
https://web.archive.org/web/20201215133350/http://www.voidspace.org.uk/python/articles/authentication.shtml

   (3) urllib opener for SSL proxy (CONNECT method): ASPN Cookbook
Recipe
(https://code.activestate.com/recipes/456195-urrlib2-opener-for-ssl-proxy-connect-method/).


File: python.info,  Node: ソケットとレイヤー,  Next: 脚注,  Prev: プロキシ,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.8 ソケットとレイヤー
-------------------------

Web 上からリソースを取得する Python の機能はレイヤー化されています。
urllib は *note http.client: 65. ライブラリを利用していますが、そのライ
ブラリはさらに socket ライブラリを利用しています。

Python 2.3 ではレスポンスがタイムアウトするまでのソケットの待ち時間を指
定することができます。これは web ページを取得する場合に便利に使うことが
できます。socket モジュールのデフォルトでは 'タイムアウトが無く' ハング
してしまうかもしれません。現在では socket のタイムアウトは http.client や
urllib.request のレベルからは隠蔽されていています。しかし、以下を利用す
ることで全てのソケットに対してグローバルにデフォルトタイムアウトを設定す
ることができます

     import socket
     import urllib.request

     # timeout in seconds
     timeout = 10
     socket.setdefaulttimeout(timeout)

     # this call to urllib.request.urlopen now uses the default timeout
     # we have set in the socket module
     req = urllib.request.Request('http://www.voidspace.org.uk')
     response = urllib.request.urlopen(req)

__________________________________________________________________


File: python.info,  Node: 脚注,  Prev: ソケットとレイヤー,  Up: urllib パッケージを使ってインターネット上のリソースを取得するには

9.13.9 脚注
-----------

このドキュメントは John Lee によって査読、改訂されました。


File: python.info,  Node: ipaddressモジュールの紹介,  Next: DTrace と SystemTap で CPython を測定する,  Prev: urllib パッケージを使ってインターネット上のリソースを取得するには,  Up: Python HOWTO

9.14 ipaddressモジュールの紹介
==============================


author: Peter Moody


author: Nick Coghlan

概要
....

このドキュメントは *note ipaddress: 74. モジュールへのやさしい入門を提供
するのが目的です。これは主にまだIPネットワーキングの用語に詳しくないユー
ザーを対象としていますが、*note ipaddress: 74. がどのようにIPネットワー
クアドレス処理の概念を表現しているかをざっと見るのにも役立つかもしれませ
ん。

* Menu:

* アドレス/ネットワーク/インターフェースオブジェクトの作成::
* アドレス/ネットワーク/インターフェースオブジェクト::
* アドレスのリストとしてのネットワーク::
* 比較: 比較<4>.
* 他のモジュールでIPアドレスを使用する::
* インスタンスの生成に失敗した場合にさらに詳細を取得する::


File: python.info,  Node: アドレス/ネットワーク/インターフェースオブジェクトの作成,  Next: アドレス/ネットワーク/インターフェースオブジェクト,  Up: ipaddressモジュールの紹介

9.14.1 アドレス/ネットワーク/インターフェースオブジェクトの作成
---------------------------------------------------------------

*note ipaddress: 74. はIPアドレスを検査したり操作したりするためのモジュ
ールであるため、まずはオブジェクトを作成したほうが良いでしょう。文字列お
よび整数を使用して *note ipaddress: 74. を使用してオブジェクトを作成でき
ます。

* Menu:

* IPバージョンについての注意::
* IPホストアドレス::
* ネットワークを定義する::
* ホストインターフェース::


File: python.info,  Node: IPバージョンについての注意,  Next: IPホストアドレス,  Up: アドレス/ネットワーク/インターフェースオブジェクトの作成

9.14.1.1 IPバージョンについての注意
...................................

IPアドレッシングに詳しくない読者にとっては、インターネットプロトコル
(IP)が現在バージョン4プロトコルからバージョン6へと移行している途中である
ことを知っておくのが重要です。この移行はプロトコルのバージョン4が世界中
の需要に対応するために十分なアドレスを提供できないことが大きな理由で起こ
っており、特にインターネットへ直接接続する機器が増えている状況を踏まえた
ものです。

上述した2つのプロトコルバージョンの違いの詳細を説明するのはこの入門ドキ
ュメントの対象範囲を超えていますが、読者は少なくともこれらの2つのバージ
ョンが存在することと、どちらかのバージョンを強制的に使用することが必要に
なることもあるということを認識する必要があります。


File: python.info,  Node: IPホストアドレス,  Next: ネットワークを定義する,  Prev: IPバージョンについての注意,  Up: アドレス/ネットワーク/インターフェースオブジェクトの作成

9.14.1.2 IPホストアドレス
.........................

アドレスは多くの場合「ホストアドレス」と呼ばれ、IPアドレッシングを扱う場
合の最も基本的な単位です。アドレスを作成する単純な方法は *note
ipaddress.ip_address(): 3acd. ファクトリー関数を使用することで、この方法
では渡された値をもとにIPv4かIPv6アドレスのどちらかを自動的に決定します:

     >>> ipaddress.ip_address('192.0.2.1')
     IPv4Address('192.0.2.1')
     >>> ipaddress.ip_address('2001:DB8::1')
     IPv6Address('2001:db8::1')

アドレスは整数から直接作成することも可能です。32ビットに収まる値はIPv4ア
ドレスであるとみなされます:

     >>> ipaddress.ip_address(3221225985)
     IPv4Address('192.0.2.1')
     >>> ipaddress.ip_address(42540766411282592856903984951653826561)
     IPv6Address('2001:db8::1')

IPv4またはIPv6アドレスの使用を強制するには、適切なクラスを直接呼び出す必
要があります。これは特にIPv6アドレスを小さな整数で作成する場合に役立ちま
す:

     >>> ipaddress.ip_address(1)
     IPv4Address('0.0.0.1')
     >>> ipaddress.IPv4Address(1)
     IPv4Address('0.0.0.1')
     >>> ipaddress.IPv6Address(1)
     IPv6Address('::1')


File: python.info,  Node: ネットワークを定義する,  Next: ホストインターフェース,  Prev: IPホストアドレス,  Up: アドレス/ネットワーク/インターフェースオブジェクトの作成

9.14.1.3 ネットワークを定義する
...............................

ホストアドレスは通常IPネットワークへ統合され、 *note ipaddress: 74. はネ
ットワーク定義の作成、検査、操作の手段を提供します。IPネットワークオブジ
ェクトはネットワークの一部であるホストアドレスの範囲を定義する文字列から
生成されます。この情報の最も単純な形式は「ネットワークアドレス/ネットワ
ークプレフィックス」のペアであり、プレフィックスは先頭のビット数として定
義され、アドレスがネットワークの一部であるかどうか、それらのビットに期待
される値がネットワークアドレスに定義されているかを判断するために比較され
ます。

アドレスについては、正しいIPバージョンを自動的に判断するファクトリー関数
が提供されます:

     >>> ipaddress.ip_network('192.0.2.0/24')
     IPv4Network('192.0.2.0/24')
     >>> ipaddress.ip_network('2001:db8::0/96')
     IPv6Network('2001:db8::/96')

ネットワークオブジェクトにはホストビットを設定することができません。これ
についての実践的な効果は ‘192.0.2.1/24’ がネットワークを表さないというこ
とです。次の項でより詳しく説明しますが、ネットワーク内IP表記は一般的に特
定のネットワーク上のネットワークインターフェースを表すのに使用されるため
、このような定義はインターフェースオブジェクトと呼ばれます。

デフォルトでは、ホストビットセットの指定でネットワークオブジェクトを作成
しようとすると *note ValueError: 1e3. が発生する結果となります。
‘strict=False’ フラグをコンストラクタに渡すと、追加分のビットをゼロとし
て強制的に処理するように要求できます:

     >>> ipaddress.ip_network('192.0.2.1/24')
     Traceback (most recent call last):
        ...
     ValueError: 192.0.2.1/24 has host bits set
     >>> ipaddress.ip_network('192.0.2.1/24', strict=False)
     IPv4Network('192.0.2.0/24')

文字列形式では劇的に柔軟性を提供できる一方、ネットワークはちょうどホスト
アドレスのように整数で定義することもできます。この場合、ネットワークは整
数により特定できる単一のアドレスのみを含むものとして処理され、ネットワー
クプレフィックスはネットワークアドレスの全体を含みます:

     >>> ipaddress.ip_network(3221225984)
     IPv4Network('192.0.2.0/32')
     >>> ipaddress.ip_network(42540766411282592856903984951653826560)
     IPv6Network('2001:db8::/128')

アドレスについては、ファクトリー関数を呼ぶ代わりにクラスコンストラクタを
直接呼ぶことで、作成対象のネットワークを特定の種類に強制することができま
す。


File: python.info,  Node: ホストインターフェース,  Prev: ネットワークを定義する,  Up: アドレス/ネットワーク/インターフェースオブジェクトの作成

9.14.1.4 ホストインターフェース
...............................

直前に述べたように、特定のネットワーク上のアドレスを示したい場合には、ア
ドレスもネットワーククラスも十分ではありません。 ‘192.0.2.1/24’ のような
表記は「 ‘192.0.2.0/24’ のネットワーク上の ‘192.0.2.1’ のホスト」の短縮
形として通常ネットワークエンジニアやファイアウォールやルータ用のツールを
書く人が使用し、 *note ipaddress: 74. はそれに応じて特定のネットワークと
アドレスを関連づけるハイブリッドクラス集を提供します。アドレス部分がネッ
トワークアドレスであることに制限されないことを除き、作成用のインターフェ
ースはネットワーク定義用のインターフェースと同一です。

     >>> ipaddress.ip_interface('192.0.2.1/24')
     IPv4Interface('192.0.2.1/24')
     >>> ipaddress.ip_interface('2001:db8::1/96')
     IPv6Interface('2001:db8::1/96')

整数入力は(ネットワークと同様に)受け入れられ、適切なコンストラクタを直接
呼び出すことで特定のIPバージョンの使用を強制できます。


File: python.info,  Node: アドレス/ネットワーク/インターフェースオブジェクト,  Next: アドレスのリストとしてのネットワーク,  Prev: アドレス/ネットワーク/インターフェースオブジェクトの作成,  Up: ipaddressモジュールの紹介

9.14.2 アドレス/ネットワーク/インターフェースオブジェクト
---------------------------------------------------------

さて、IPv(4|6)(アドレス|ネットワーク|インターフェース)オブジェクトをわざ
わざ作成したので、多分それについて情報がほしいことでしょう。 *note
ipaddress: 74. はこの作業を簡単で直観的にできるようにします。

IPバージョンを抽出する:

     >>> addr4 = ipaddress.ip_address('192.0.2.1')
     >>> addr6 = ipaddress.ip_address('2001:db8::1')
     >>> addr6.version
     6
     >>> addr4.version
     4

インターフェースからネットワークを取得する:

     >>> host4 = ipaddress.ip_interface('192.0.2.1/24')
     >>> host4.network
     IPv4Network('192.0.2.0/24')
     >>> host6 = ipaddress.ip_interface('2001:db8::1/96')
     >>> host6.network
     IPv6Network('2001:db8::/96')

個別なアドレスがいくつネットワークに存在するかを調べる:

     >>> net4 = ipaddress.ip_network('192.0.2.0/24')
     >>> net4.num_addresses
     256
     >>> net6 = ipaddress.ip_network('2001:db8::0/96')
     >>> net6.num_addresses
     4294967296

「使用可能」なネットワーク上のアドレスを順番にたどる:

     >>> net4 = ipaddress.ip_network('192.0.2.0/24')
     >>> for x in net4.hosts():
     ...     print(x)
     192.0.2.1
     192.0.2.2
     192.0.2.3
     192.0.2.4
     ...
     192.0.2.252
     192.0.2.253
     192.0.2.254

ネットマスクを取得(例: ネットワークプレフィックスに応じてビットを設定)し
たりホストマスク(ネットマスクの一部ではない任意のビット)を取得する:

     >>> net4 = ipaddress.ip_network('192.0.2.0/24')
     >>> net4.netmask
     IPv4Address('255.255.255.0')
     >>> net4.hostmask
     IPv4Address('0.0.0.255')
     >>> net6 = ipaddress.ip_network('2001:db8::0/96')
     >>> net6.netmask
     IPv6Address('ffff:ffff:ffff:ffff:ffff:ffff::')
     >>> net6.hostmask
     IPv6Address('::ffff:ffff')

アドレスを展開したり圧縮したりする:

     >>> addr6.exploded
     '2001:0db8:0000:0000:0000:0000:0000:0001'
     >>> addr6.compressed
     '2001:db8::1'
     >>> net6.exploded
     '2001:0db8:0000:0000:0000:0000:0000:0000/96'
     >>> net6.compressed
     '2001:db8::/96'

IPv4は展開や圧縮には対応していませんが、それでも関連したオブジェクトが適
切なプロパティを提供し、バージョンに対して中立なコードがIPv4アドレスを正
しく処理する一方でIPv6向けには最も簡潔または最も詳細な形式が使用されるこ
とを保証します。


File: python.info,  Node: アドレスのリストとしてのネットワーク,  Next: 比較<4>,  Prev: アドレス/ネットワーク/インターフェースオブジェクト,  Up: ipaddressモジュールの紹介

9.14.3 アドレスのリストとしてのネットワーク
-------------------------------------------

ネットワークをリストとして扱うと便利な場合があります。これは、ネットワー
クを次のようにインデックス付けすることが可能なことを意味します:

     >>> net4[1]
     IPv4Address('192.0.2.1')
     >>> net4[-1]
     IPv4Address('192.0.2.255')
     >>> net6[1]
     IPv6Address('2001:db8::1')
     >>> net6[-1]
     IPv6Address('2001:db8::ffff:ffff')

以下のようなリストのメンバーシップの判定用文法が使用可能なように、ネット
ワークオブジェクト自身が適応します:

     if address in network:
         # do something

ネットワークプレフィックスに基づき、所属しているかどうかの判定が効果的に
できます:

     >>> addr4 = ipaddress.ip_address('192.0.2.1')
     >>> addr4 in ipaddress.ip_network('192.0.2.0/24')
     True
     >>> addr4 in ipaddress.ip_network('192.0.3.0/24')
     False


File: python.info,  Node: 比較<4>,  Next: 他のモジュールでIPアドレスを使用する,  Prev: アドレスのリストとしてのネットワーク,  Up: ipaddressモジュールの紹介

9.14.4 比較
-----------

*note ipaddress: 74. はオブジェクトの比較をするための単純で、かつ願わく
ば直観的な方法を意味が通じるように提供します:

     >>> ipaddress.ip_address('192.0.2.1') < ipaddress.ip_address('192.0.2.2')
     True

異なるバージョンや異なるタイプのオブジェクトを比較しようとすると *note
TypeError: 502. 例外が発生します。


File: python.info,  Node: 他のモジュールでIPアドレスを使用する,  Next: インスタンスの生成に失敗した場合にさらに詳細を取得する,  Prev: 比較<4>,  Up: ipaddressモジュールの紹介

9.14.5 他のモジュールでIPアドレスを使用する
-------------------------------------------

IPアドレスを使用する他のモジュール(*note socket: b8. など)は通常このモジ
ュールからオブジェクトを直接受け付けません。直接渡すのではなく、他のモジ
ュールが受け付ける整数や文字列に強制的に変換する必要があります:

     >>> addr4 = ipaddress.ip_address('192.0.2.1')
     >>> str(addr4)
     '192.0.2.1'
     >>> int(addr4)
     3221225985


File: python.info,  Node: インスタンスの生成に失敗した場合にさらに詳細を取得する,  Prev: 他のモジュールでIPアドレスを使用する,  Up: ipaddressモジュールの紹介

9.14.6 インスタンスの生成に失敗した場合にさらに詳細を取得する
-------------------------------------------------------------

上述したバージョンに関知しないファクトリー関数を使用してアドレス/ネット
ワーク/インターフェースオブジェクトを作成する場合、渡された値がそのタイ
プのオブジェクトとして認識されなかったと単純に通知する汎用的なメッセージ
とともに、どのエラーでも *note ValueError: 1e3. として報告されます。特定
のエラーが提供されないのは、拒否された理由をより詳細に提供するために、値
がIPv4またはIPv6である 'はず' かどうかを知る必要があるためです。

追加の詳細を得ると役立つ場合のユースケースに対応するため、個別のクラスの
コンストラクタは実際に *note ValueError: 1e3. のサブクラスである *note
ipaddress.AddressValueError: 3ad2. と *note ipaddress.NetmaskValueError:
3af4. を発生させて具体的に定義のどの部分のパースに失敗したのかを示します
。

クラスコンストラクタを直接使用する場合にはこれらのエラーメッセージはさら
に非常に詳細になっています。例えば:

     >>> ipaddress.ip_address("192.168.0.256")
     Traceback (most recent call last):
       ...
     ValueError: '192.168.0.256' does not appear to be an IPv4 or IPv6 address
     >>> ipaddress.IPv4Address("192.168.0.256")
     Traceback (most recent call last):
       ...
     ipaddress.AddressValueError: Octet 256 (> 255) not permitted in '192.168.0.256'

     >>> ipaddress.ip_network("192.168.0.1/64")
     Traceback (most recent call last):
       ...
     ValueError: '192.168.0.1/64' does not appear to be an IPv4 or IPv6 network
     >>> ipaddress.IPv4Network("192.168.0.1/64")
     Traceback (most recent call last):
       ...
     ipaddress.NetmaskValueError: '64' is not a valid netmask

しかし、モジュールについて固有の上記例外のどちらも *note ValueError:
1e3. を親クラスとして持ち、エラーの特定のタイプに興味がない場合でも、以
下のようにコードを記述できます:

     try:
         network = ipaddress.IPv4Network(address)
     except ValueError:
         print('address/netmask is invalid for IPv4:', address)


File: python.info,  Node: DTrace と SystemTap で CPython を測定する,  Next: Python support for the Linux perf profiler,  Prev: ipaddressモジュールの紹介,  Up: Python HOWTO

9.15 DTrace と SystemTap で CPython を測定する
==============================================


author: David Malcolm


author: Łukasz Langa

Dtrace と SystemTap はモニタリングツールで、コンピュータシステムのプロセ
スが何をしているかを調べる方法を提供します。 どちらもドメイン固有言語
(domain-specific language) を使用して、次のことができるスクリプトをユー
ザが書けます:

   - 観測対象のプロセスを絞り込む

   - 関心のあるプロセスからデータを収集する

   - 収集したデータからレポートを生成する

Python 3.6 では、 CPython は "プローブ" としても知られる "マーカー" を埋
め込んだビルドが行えます。 マーカーは DTrace や SystemTap のスクリプトか
ら観測でき、システムの CPython プロセスが何をしているかを観察するのが簡
単になります。

'CPython 実装の詳細:' DTrace マーカーは CPython インタプリタの実装詳細で
す。 CPython のバージョン間でプローブの互換性があるという保証はありませ
ん。 CPython のバージョンを変えると、 DTrace スクリプトは警告無しに動作
しなくなったり、おかしな動作をする可能性があります。

* Menu:

* 静的マーカーの有効化::
* 静的 DTrace プローブ::
* 静的 SystemTap マーカー::
* 利用可能な静的マーカー::
* SystemTap Tapset::
* 使用例: 使用例<56>.


File: python.info,  Node: 静的マーカーの有効化,  Next: 静的 DTrace プローブ,  Up: DTrace と SystemTap で CPython を測定する

9.15.1 静的マーカーの有効化
---------------------------

macOS には組み込みの DTrace サポートが備わっています。 Linux では
SystemTap 用のマーカーを埋め込んで CPython をビルドするためには、
SystemTap 開発ツールをインストールしなければなりません。

Linux マシンでは、 SystemTap 開発ツールのインストールは次のように行えま
す:

     $ yum install systemtap-sdt-devel

もしくは:

     $ sudo apt-get install systemtap-sdt-dev

CPython must then be *note configured with the -with-dtrace option:
1d1f.:

     checking for --with-dtrace... yes

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:

     $ python3.6 -q &
     $ sudo dtrace -l -P python$!  # or: dtrace -l -m python3.6

        ID   PROVIDER            MODULE                          FUNCTION NAME
     29564 python18035        python3.6          _PyEval_EvalFrameDefault function-entry
     29565 python18035        python3.6             dtrace_function_entry function-entry
     29566 python18035        python3.6          _PyEval_EvalFrameDefault function-return
     29567 python18035        python3.6            dtrace_function_return function-return
     29568 python18035        python3.6                           collect gc-done
     29569 python18035        python3.6                           collect gc-start
     29570 python18035        python3.6          _PyEval_EvalFrameDefault line
     29571 python18035        python3.6                 maybe_dtrace_line line

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.

     $ readelf -S ./python | grep .note.stapsdt
     [30] .note.stapsdt        NOTE         0000000000000000 00308d78

If you've built Python as a shared library (with the *note
-enable-shared: 82e. configure option), you need to look instead within
the shared library.  For example:

     $ readelf -S libpython3.3dm.so.1.0 | grep .note.stapsdt
     [29] .note.stapsdt        NOTE         0000000000000000 00365b68

十分に新しい readelf ではメタデータを出力できます:

     $ readelf -n ./python

     Displaying notes found at file offset 0x00000254 with length 0x00000020:
         Owner                 Data size          Description
         GNU                  0x00000010          NT_GNU_ABI_TAG (ABI version tag)
             OS: Linux, ABI: 2.6.32

     Displaying notes found at file offset 0x00000274 with length 0x00000024:
         Owner                 Data size          Description
         GNU                  0x00000014          NT_GNU_BUILD_ID (unique build ID bitstring)
             Build ID: df924a2b08a7e89f6e11251d4602022977af2670

     Displaying notes found at file offset 0x002d6c30 with length 0x00000144:
         Owner                 Data size          Description
         stapsdt              0x00000031          NT_STAPSDT (SystemTap probe descriptors)
             Provider: python
             Name: gc__start
             Location: 0x00000000004371c3, Base: 0x0000000000630ce2, Semaphore: 0x00000000008d6bf6
             Arguments: -4@%ebx
         stapsdt              0x00000030          NT_STAPSDT (SystemTap probe descriptors)
             Provider: python
             Name: gc__done
             Location: 0x00000000004374e1, Base: 0x0000000000630ce2, Semaphore: 0x00000000008d6bf8
             Arguments: -8@%rax
         stapsdt              0x00000045          NT_STAPSDT (SystemTap probe descriptors)
             Provider: python
             Name: function__entry
             Location: 0x000000000053db6c, Base: 0x0000000000630ce2, Semaphore: 0x00000000008d6be8
             Arguments: 8@%rbp 8@%r12 -4@%eax
         stapsdt              0x00000046          NT_STAPSDT (SystemTap probe descriptors)
             Provider: python
             Name: function__return
             Location: 0x000000000053dba8, Base: 0x0000000000630ce2, Semaphore: 0x00000000008d6bea
             Arguments: 8@%rbp 8@%r12 -4@%eax

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.


File: python.info,  Node: 静的 DTrace プローブ,  Next: 静的 SystemTap マーカー,  Prev: 静的マーカーの有効化,  Up: DTrace と SystemTap で CPython を測定する

9.15.2 静的 DTrace プローブ
---------------------------

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:

     self int indent;

     python$target:::function-entry
     /copyinstr(arg1) == "start"/
     {
             self->trace = 1;
     }

     python$target:::function-entry
     /self->trace/
     {
             printf("%d\t%*s:", timestamp, 15, probename);
             printf("%*s", self->indent, "");
             printf("%s:%s:%d\n", basename(copyinstr(arg0)), copyinstr(arg1), arg2);
             self->indent++;
     }

     python$target:::function-return
     /self->trace/
     {
             self->indent--;
             printf("%d\t%*s:", timestamp, 15, probename);
             printf("%*s", self->indent, "");
             printf("%s:%s:%d\n", basename(copyinstr(arg0)), copyinstr(arg1), arg2);
     }

     python$target:::function-return
     /copyinstr(arg1) == "start"/
     {
             self->trace = 0;
     }

この例は次のように実行できます:

     $ sudo dtrace -q -s call_stack.d -c "python3.6 script.py"

出力はこのようになります:

     156641360502280  function-entry:call_stack.py:start:23
     156641360518804  function-entry: call_stack.py:function_1:1
     156641360532797  function-entry:  call_stack.py:function_3:9
     156641360546807 function-return:  call_stack.py:function_3:10
     156641360563367 function-return: call_stack.py:function_1:2
     156641360578365  function-entry: call_stack.py:function_2:5
     156641360591757  function-entry:  call_stack.py:function_1:1
     156641360605556  function-entry:   call_stack.py:function_3:9
     156641360617482 function-return:   call_stack.py:function_3:10
     156641360629814 function-return:  call_stack.py:function_1:2
     156641360642285 function-return: call_stack.py:function_2:6
     156641360656770  function-entry: call_stack.py:function_3:9
     156641360669707 function-return: call_stack.py:function_3:10
     156641360687853  function-entry: call_stack.py:function_4:13
     156641360700719 function-return: call_stack.py:function_4:14
     156641360719640  function-entry: call_stack.py:function_5:18
     156641360732567 function-return: call_stack.py:function_5:21
     156641360747370 function-return:call_stack.py:start:28


File: python.info,  Node: 静的 SystemTap マーカー,  Next: 利用可能な静的マーカー,  Prev: 静的 DTrace プローブ,  Up: DTrace と SystemTap で CPython を測定する

9.15.3 静的 SystemTap マーカー
------------------------------

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.

例えば、この SystemTap スクリプトは Python の呼び出し/返却 (call/return)
階層を表示するのに使えます:

     probe process("python").mark("function__entry") {
          filename = user_string($arg1);
          funcname = user_string($arg2);
          lineno = $arg3;

          printf("%s => %s in %s:%d\\n",
                 thread_indent(1), funcname, filename, lineno);
     }

     probe process("python").mark("function__return") {
         filename = user_string($arg1);
         funcname = user_string($arg2);
         lineno = $arg3;

         printf("%s <= %s in %s:%d\\n",
                thread_indent(-1), funcname, filename, lineno);
     }

この例は次のように実行できます:

     $ stap \
       show-call-hierarchy.stp \
       -c "./python test.py"

出力はこのようになります:

     11408 python(8274):        => __contains__ in Lib/_abcoll.py:362
     11414 python(8274):         => __getitem__ in Lib/os.py:425
     11418 python(8274):          => encode in Lib/os.py:490
     11424 python(8274):          <= encode in Lib/os.py:493
     11428 python(8274):         <= __getitem__ in Lib/os.py:426
     11433 python(8274):        <= __contains__ in Lib/_abcoll.py:366

それぞれの列の内容は次の通りです:

   - スクリプトを起動してからのマイクロ秒単位の時間

   - 実行可能ファイルの名前

   - プロセスの PID

そして、残りの部分はスクリプトが実行していた呼び出し/返却階層を表示して
います。

For a *note -enable-shared: 82e. 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:

     probe process("python").mark("function__entry") {

should instead read:

     probe process("python").library("libpython3.6dm.so.1.0").mark("function__entry") {

(assuming a *note debug build: 1da. of CPython 3.6)


File: python.info,  Node: 利用可能な静的マーカー,  Next: SystemTap Tapset,  Prev: 静的 SystemTap マーカー,  Up: DTrace と SystemTap で CPython を測定する

9.15.4 利用可能な静的マーカー
-----------------------------

 -- Object: function__entry(str filename, str funcname, int lineno)

     このマーカーは Python の関数の実行が開始されたことを示しています。
     このマーカーは、ピュア Python (バイトコード) の関数でしか起動されま
     せん。

     トレーススクリプトには位置引数として、ファイル名、関数名、行番号が
     渡され、必ず ‘$arg1’, ‘$arg2’, ‘$arg3’ で渡されます:

             * ‘$arg1’ : ‘(const char *)’ ファイル名、
               ‘user_string($arg1)’ でアクセスできます

             * ‘$arg2’ : ‘(const char *)’ 関数名、 ‘user_string($arg2)’
               でアクセスできます

             * ‘$arg3’ : ‘int’ 行番号

 -- Object: function__return(str filename, str funcname, int lineno)

     This marker is the converse of ‘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.

     The arguments are the same as for ‘function__entry()’

 -- Object: line(str filename, str funcname, int lineno)

     このマーカーは、これから実行される Python の行を示しています。 これ
     は Python プロファイラによる行ごとのトレースと同等です。 このマーカ
     ーは C 関数の内部では起動されません。

     The arguments are the same as for ‘function__entry()’.

 -- Object: gc__start(int generation)

     Fires when the Python interpreter starts a garbage collection
     cycle.  ‘arg0’ is the generation to scan, like *note gc.collect():
     a08.

 -- Object: gc__done(long collected)

     Python インタプリタによる循環参照のガベージコレクションが完了したと
     きに発火します。 ‘arg0’ は回収したオブジェクトの数です。

 -- Object: import__find__load__start(str modulename)

     Fires before *note importlib: 6b. attempts to find and load the
     module.  ‘arg0’ is the module name.

     Added in version 3.7.

 -- Object: import__find__load__done(str modulename, int found)

     Fires after *note importlib: 6b.'s find_and_load function is
     called.  ‘arg0’ is the module name, ‘arg1’ indicates if module was
     successfully loaded.

     Added in version 3.7.

 -- Object: audit(str event, void *tuple)

     Fires when *note sys.audit(): 151a. or *note PySys_Audit(): 348. is
     called.  ‘arg0’ is the event name as C string, ‘arg1’ is a *note
     PyObject: 312. pointer to a tuple object.

     Added in version 3.8.


File: python.info,  Node: SystemTap Tapset,  Next: 使用例<56>,  Prev: 利用可能な静的マーカー,  Up: DTrace と SystemTap で CPython を測定する

9.15.5 SystemTap Tapset
-----------------------

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.

Here is a tapset file, based on a non-shared build of CPython:

     /*
        Provide a higher-level wrapping around the function__entry and
        function__return markers:
      \*/
     probe python.function.entry = process("python").mark("function__entry")
     {
         filename = user_string($arg1);
         funcname = user_string($arg2);
         lineno = $arg3;
         frameptr = $arg4
     }
     probe python.function.return = process("python").mark("function__return")
     {
         filename = user_string($arg1);
         funcname = user_string($arg2);
         lineno = $arg3;
         frameptr = $arg4
     }

If this file is installed in SystemTap's tapset directory (e.g.
‘/usr/share/systemtap/tapset’), then these additional probepoints become
available:

 -- Object: python.function.entry(str filename, str funcname, int
          lineno, frameptr)

     This probe point indicates that execution of a Python function has
     begun.  It is only triggered for pure-Python (bytecode) functions.

 -- Object: python.function.return(str filename, str funcname, int
          lineno, frameptr)

     This probe point is the converse of ‘python.function.return’, 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.


File: python.info,  Node: 使用例<56>,  Prev: SystemTap Tapset,  Up: DTrace と SystemTap で CPython を測定する

9.15.6 使用例
-------------

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:

     probe python.function.entry
     {
       printf("%s => %s in %s:%d\n",
              thread_indent(1), funcname, filename, lineno);
     }

     probe python.function.return
     {
       printf("%s <= %s in %s:%d\n",
              thread_indent(-1), funcname, filename, lineno);
     }

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:

     global fn_calls;

     probe python.function.entry
     {
         fn_calls[pid(), filename, funcname, lineno] += 1;
     }

     probe timer.ms(1000) {
         printf("\033[2J\033[1;1H") /* clear screen \*/
         printf("%6s %80s %6s %30s %6s\n",
                "PID", "FILENAME", "LINE", "FUNCTION", "CALLS")
         foreach ([pid, filename, funcname, lineno] in fn_calls- limit 20) {
             printf("%6d %80s %6d %30s %6d\n",
                 pid, filename, lineno, funcname,
                 fn_calls[pid, filename, funcname, lineno]);
         }
         delete fn_calls;
     }


File: python.info,  Node: Python support for the Linux perf profiler,  Next: Annotations Best Practices,  Prev: DTrace と SystemTap で CPython を測定する,  Up: Python HOWTO

9.16 Python support for the Linux ‘perf’ profiler
=================================================


author: Pablo Galindo

The Linux perf profiler(1) is a very powerful tool that allows you to
profile and obtain information about the performance of your
application.  ‘perf’ also has a very vibrant ecosystem of tools that aid
with the analysis of the data that it produces.

The main problem with using the ‘perf’ profiler with Python applications
is that ‘perf’ only gets information about native symbols, that is, the
names of functions and procedures written in C. This means that the
names and file names of Python functions in your code will not appear in
the output of ‘perf’.

Since Python 3.12, the interpreter can run in a special mode that allows
Python functions to appear in the output of the ‘perf’ profiler.  When
this mode is enabled, the interpreter will interpose a small piece of
code compiled on the fly before the execution of every Python function
and it will teach ‘perf’ the relationship between this piece of code and
the associated Python function using *note perf map files: 49c8.

     注釈: Support for the ‘perf’ profiler is currently only available
     for Linux on select architectures.  Check the output of the
     ‘configure’ build step or check the output of ‘python -m sysconfig
     | grep HAVE_PERF_TRAMPOLINE’ to see if your system is supported.

For example, consider the following script:

     def foo(n):
         result = 0
         for _ in range(n):
             result += 1
         return result

     def bar(n):
         foo(n)

     def baz(n):
         bar(n)

     if __name__ == "__main__":
         baz(1000000)

We can run ‘perf’ to sample CPU stack traces at 9999 hertz:

     $ perf record -F 9999 -g -o perf.data python my_script.py

Then we can use ‘perf report’ to analyze the data:

     $ perf report --stdio -n -g

     # Children      Self       Samples  Command     Shared Object       Symbol
     # ........  ........  ............  ..........  ..................  ..........................................
     #
         91.08%     0.00%             0  python.exe  python.exe          [.] _start
                 |
                 ---_start
                 |
                     --90.71%--__libc_start_main
                             Py_BytesMain
                             |
                             |--56.88%--pymain_run_python.constprop.0
                             |          |
                             |          |--56.13%--_PyRun_AnyFileObject
                             |          |          _PyRun_SimpleFileObject
                             |          |          |
                             |          |          |--55.02%--run_mod
                             |          |          |          |
                             |          |          |           --54.65%--PyEval_EvalCode
                             |          |          |                     _PyEval_EvalFrameDefault
                             |          |          |                     PyObject_Vectorcall
                             |          |          |                     _PyEval_Vector
                             |          |          |                     _PyEval_EvalFrameDefault
                             |          |          |                     PyObject_Vectorcall
                             |          |          |                     _PyEval_Vector
                             |          |          |                     _PyEval_EvalFrameDefault
                             |          |          |                     PyObject_Vectorcall
                             |          |          |                     _PyEval_Vector
                             |          |          |                     |
                             |          |          |                     |--51.67%--_PyEval_EvalFrameDefault
                             |          |          |                     |          |
                             |          |          |                     |          |--11.52%--_PyLong_Add
                             |          |          |                     |          |          |
                             |          |          |                     |          |          |--2.97%--_PyObject_Malloc
     ...

As you can see, the Python functions are not shown in the output, only
‘_PyEval_EvalFrameDefault’ (the function that evaluates the Python
bytecode) shows up.  Unfortunately that's not very useful because all
Python functions use the same C function to evaluate bytecode so we
cannot know which Python function corresponds to which
bytecode-evaluating function.

Instead, if we run the same experiment with ‘perf’ support enabled we
get:

     $ perf report --stdio -n -g

     # Children      Self       Samples  Command     Shared Object       Symbol
     # ........  ........  ............  ..........  ..................  .....................................................................
     #
         90.58%     0.36%             1  python.exe  python.exe          [.] _start
                 |
                 ---_start
                 |
                     --89.86%--__libc_start_main
                             Py_BytesMain
                             |
                             |--55.43%--pymain_run_python.constprop.0
                             |          |
                             |          |--54.71%--_PyRun_AnyFileObject
                             |          |          _PyRun_SimpleFileObject
                             |          |          |
                             |          |          |--53.62%--run_mod
                             |          |          |          |
                             |          |          |           --53.26%--PyEval_EvalCode
                             |          |          |                     py::<module>:/src/script.py
                             |          |          |                     _PyEval_EvalFrameDefault
                             |          |          |                     PyObject_Vectorcall
                             |          |          |                     _PyEval_Vector
                             |          |          |                     py::baz:/src/script.py
                             |          |          |                     _PyEval_EvalFrameDefault
                             |          |          |                     PyObject_Vectorcall
                             |          |          |                     _PyEval_Vector
                             |          |          |                     py::bar:/src/script.py
                             |          |          |                     _PyEval_EvalFrameDefault
                             |          |          |                     PyObject_Vectorcall
                             |          |          |                     _PyEval_Vector
                             |          |          |                     py::foo:/src/script.py
                             |          |          |                     |
                             |          |          |                     |--51.81%--_PyEval_EvalFrameDefault
                             |          |          |                     |          |
                             |          |          |                     |          |--13.77%--_PyLong_Add
                             |          |          |                     |          |          |
                             |          |          |                     |          |          |--3.26%--_PyObject_Malloc

* Menu:

* How to enable perf profiling support::
* How to obtain the best results::
* How to work without frame pointers::

   ---------- Footnotes ----------

   (1) https://perf.wiki.kernel.org


File: python.info,  Node: How to enable perf profiling support,  Next: How to obtain the best results,  Up: Python support for the Linux perf profiler

9.16.1 How to enable ‘perf’ profiling support
---------------------------------------------

‘perf’ profiling support can be enabled either from the start using the
environment variable *note PYTHONPERFSUPPORT: 43b. or the *note -X perf:
15c. option, or dynamically using *note sys.activate_stack_trampoline():
43c. and *note sys.deactivate_stack_trampoline(): 43d.

The ‘sys’ functions take precedence over the ‘-X’ option, the ‘-X’
option takes precedence over the environment variable.

Example, using the environment variable:

     $ PYTHONPERFSUPPORT=1 perf record -F 9999 -g -o perf.data python script.py
     $ perf report -g -i perf.data

Example, using the ‘-X’ option:

     $ perf record -F 9999 -g -o perf.data python -X perf script.py
     $ perf report -g -i perf.data

Example, using the *note sys: c3. APIs in file ‘example.py’:

     import sys

     sys.activate_stack_trampoline("perf")
     do_profiled_stuff()
     sys.deactivate_stack_trampoline()

     non_profiled_stuff()

...then:

     $ perf record -F 9999 -g -o perf.data python ./example.py
     $ perf report -g -i perf.data


File: python.info,  Node: How to obtain the best results,  Next: How to work without frame pointers,  Prev: How to enable perf profiling support,  Up: Python support for the Linux perf profiler

9.16.2 How to obtain the best results
-------------------------------------

For best results, Python should be compiled with
‘CFLAGS="-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer"’ as this
allows profilers to unwind using only the frame pointer and not on DWARF
debug information.  This is because as the code that is interposed to
allow ‘perf’ support is dynamically generated it doesn't have any DWARF
debugging information available.

You can check if your system has been compiled with this flag by
running:

     $ python -m sysconfig | grep 'no-omit-frame-pointer'

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’.


File: python.info,  Node: How to work without frame pointers,  Prev: How to obtain the best results,  Up: Python support for the Linux perf profiler

9.16.3 How to work without frame pointers
-----------------------------------------

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 will be a bit higher because Python needs to generate unwinding
information for every Python function call on the fly.  Additionally,
‘perf’ will take 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.

To enable this mode, you can use the environment variable *note
PYTHON_PERF_JIT_SUPPORT: 175. or the *note -X perf_jit: 15c. option,
which will enable the JIT mode for the ‘perf’ profiler.

     注釈: 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.

     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’.

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.:

     $ perf record -F 9999 -g --call-graph dwarf -o perf.data python -Xperf_jit my_script.py
     $ perf inject -i perf.data --jit --output perf.jit.data
     $ perf report -g -i perf.jit.data

or using the environment variable:

     $ PYTHON_PERF_JIT_SUPPORT=1 perf record -F 9999 -g --call-graph dwarf -o perf.data python my_script.py
     $ perf inject -i perf.data --jit --output perf.jit.data
     $ perf report -g -i perf.jit.data

‘perf inject --jit’ command will read ‘perf.data’, automatically pick up
the perf dump file that Python creates (in ‘/tmp/perf-$PID.dump’), and
then create ‘perf.jit.data’ which merges all the JIT information
together.  It should also create a lot of ‘jitted-XXXX-N.so’ files in
the current directory which are ELF images for all the JIT trampolines
that were created by Python.

     警告: Notice that 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 ‘perf.data’ file.  By default the size
     of the stack dump is 8192 bytes but the user can change the size by
     passing the size after comma like ‘--call-graph dwarf,4096’.  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 incomplete.  On the other hand, if the size is too big,
     then ‘perf’ won't be able to sample the process as frequently as it
     would like as the overhead will be higher.


File: python.info,  Node: Annotations Best Practices,  Next: 拡張モジュールを分離する,  Prev: Python support for the Linux perf profiler,  Up: Python HOWTO

9.17 Annotations Best Practices
===============================


author: Larry Hastings

概要
....

This document is designed to encapsulate the best practices for working
with annotations dicts.  If you write Python code that examines
‘__annotations__’ on Python objects, we encourage you to follow the
guidelines described below.

The document is organized into four sections: best practices for
accessing the annotations of an object in Python versions 3.10 and
newer, best practices for accessing the annotations of an object in
Python versions 3.9 and older, other best practices for
‘__annotations__’ that apply to any Python version, and quirks of
‘__annotations__’.

Note that this document is specifically about working with
‘__annotations__’, not uses 'for' annotations.  If you're looking for
information on how to use "type hints" in your code, please see the
*note typing: ed. module.

* Menu:

* Accessing The Annotations Dict Of An Object In Python 3.10 And Newer: Accessing The Annotations Dict Of An Object In Python 3 10 And Newer.
* Accessing The Annotations Dict Of An Object In Python 3.9 And Older: Accessing The Annotations Dict Of An Object In Python 3 9 And Older.
* Manually Un-Stringizing Stringized Annotations::
* Best Practices For __annotations__ In Any Python Version::
* __annotations__ Quirks::


File: python.info,  Node: Accessing The Annotations Dict Of An Object In Python 3 10 And Newer,  Next: Accessing The Annotations Dict Of An Object In Python 3 9 And Older,  Up: Annotations Best Practices

9.17.1 Accessing The Annotations Dict Of An Object In Python 3.10 And Newer
---------------------------------------------------------------------------

Python 3.10 adds a new function to the standard library: *note
inspect.get_annotations(): 7de.  In Python versions 3.10 and newer,
calling this function is the best practice for accessing the annotations
dict of any object that supports annotations.  This function can also
"un-stringize" stringized annotations for you.

If for some reason *note inspect.get_annotations(): 7de. isn't viable
for your use case, you may access the ‘__annotations__’ data member
manually.  Best practice for this changed in Python 3.10 as well: as of
Python 3.10, ‘o.__annotations__’ is guaranteed to 'always' work on
Python functions, classes, and modules.  If you're certain the object
you're examining is one of these three 'specific' objects, you may
simply use ‘o.__annotations__’ to get at the object's annotations dict.

However, other types of callables-for example, callables created by
*note functools.partial(): 3ed.-may not have an ‘__annotations__’
attribute defined.  When accessing the ‘__annotations__’ of a possibly
unknown object, best practice in Python versions 3.10 and newer is to
call *note getattr(): b9f. with three arguments, for example ‘getattr(o,
'__annotations__', None)’.

Before Python 3.10, accessing ‘__annotations__’ on a class that defines
no annotations but that has a parent class with annotations would return
the parent's ‘__annotations__’.  In Python 3.10 and newer, the child
class's annotations will be an empty dict instead.


File: python.info,  Node: Accessing The Annotations Dict Of An Object In Python 3 9 And Older,  Next: Manually Un-Stringizing Stringized Annotations,  Prev: Accessing The Annotations Dict Of An Object In Python 3 10 And Newer,  Up: Annotations Best Practices

9.17.2 Accessing The Annotations Dict Of An Object In Python 3.9 And Older
--------------------------------------------------------------------------

In Python 3.9 and older, accessing the annotations dict of an object is
much more complicated than in newer versions.  The problem is a design
flaw in these older versions of Python, specifically to do with class
annotations.

Best practice for accessing the annotations dict of other
objects-functions, other callables, and modules-is the same as best
practice for 3.10, assuming you aren't calling *note
inspect.get_annotations(): 7de.: you should use three-argument *note
getattr(): b9f. to access the object's ‘__annotations__’ attribute.

Unfortunately, this isn't best practice for classes.  The problem is
that, since ‘__annotations__’ is optional on classes, and because
classes can inherit attributes from their base classes, accessing the
‘__annotations__’ attribute of a class may inadvertently return the
annotations dict of a 'base class.'  As an example:

     class Base:
         a: int = 3
         b: str = 'abc'

     class Derived(Base):
         pass

     print(Derived.__annotations__)

This will print the annotations dict from ‘Base’, not ‘Derived’.

Your code will have to have a separate code path if the object you're
examining is a class (‘isinstance(o, type)’).  In that case, best
practice relies on an implementation detail of Python 3.9 and before: if
a class has annotations defined, they are stored in the class's *note
__dict__: c2b. dictionary.  Since the class may or may not have
annotations defined, best practice is to call the *note get(): 21a0.
method on the class dict.

To put it all together, here is some sample code that safely accesses
the ‘__annotations__’ attribute on an arbitrary object in Python 3.9 and
before:

     if isinstance(o, type):
         ann = o.__dict__.get('__annotations__', None)
     else:
         ann = getattr(o, '__annotations__', None)

After running this code, ‘ann’ should be either a dictionary or ‘None’.
You're encouraged to double-check the type of ‘ann’ using *note
isinstance(): 40e. before further examination.

Note that some exotic or malformed type objects may not have a *note
__dict__: c2b. attribute, so for extra safety you may also wish to use
*note getattr(): b9f. to access ‘__dict__’.


File: python.info,  Node: Manually Un-Stringizing Stringized Annotations,  Next: Best Practices For __annotations__ In Any Python Version,  Prev: Accessing The Annotations Dict Of An Object In Python 3 9 And Older,  Up: Annotations Best Practices

9.17.3 Manually Un-Stringizing Stringized Annotations
-----------------------------------------------------

In situations where some annotations may be "stringized", and you wish
to evaluate those strings to produce the Python values they represent,
it really is best to call *note inspect.get_annotations(): 7de. to do
this work for you.

If you're using Python 3.9 or older, or if for some reason you can't use
*note inspect.get_annotations(): 7de, you'll need to duplicate its
logic.  You're encouraged to examine the implementation of *note
inspect.get_annotations(): 7de. in the current Python version and follow
a similar approach.

In a nutshell, if you wish to evaluate a stringized annotation on an
arbitrary object ‘o’:

   * If ‘o’ is a module, use ‘o.__dict__’ as the ‘globals’ when calling
     *note eval(): 165.

   * If ‘o’ is a class, use ‘sys.modules[o.__module__].__dict__’ as the
     ‘globals’, and ‘dict(vars(o))’ as the ‘locals’, when calling *note
     eval(): 165.

   * If ‘o’ is a wrapped callable using *note
     functools.update_wrapper(): fec, *note functools.wraps(): f2a, or
     *note functools.partial(): 3ed, iteratively unwrap it by accessing
     either ‘o.__wrapped__’ or ‘o.func’ as appropriate, until you have
     found the root unwrapped function.

   * If ‘o’ is a callable (but not a class), use *note o.__globals__:
     12a1. as the globals when calling *note eval(): 165.

However, not all string values used as annotations can be successfully
turned into Python values by *note eval(): 165.  String values could
theoretically contain any valid string, and in practice there are valid
use cases for type hints that require annotating with string values that
specifically 'can't' be evaluated.  For example:

   * PEP 604(1) union types using ‘|’, before support for this was added
     to Python 3.10.

   * Definitions that aren't needed at runtime, only imported when *note
     typing.TYPE_CHECKING: cc2. is true.

If *note eval(): 165. attempts to evaluate such values, it will fail and
raise an exception.  So, when designing a library API that works with
annotations, it's recommended to only attempt to evaluate string values
when explicitly requested to by the caller.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0604/


File: python.info,  Node: Best Practices For __annotations__ In Any Python Version,  Next: __annotations__ Quirks,  Prev: Manually Un-Stringizing Stringized Annotations,  Up: Annotations Best Practices

9.17.4 Best Practices For ‘__annotations__’ In Any Python Version
-----------------------------------------------------------------

   * You should avoid assigning to the ‘__annotations__’ member of
     objects directly.  Let Python manage setting ‘__annotations__’.

   * If you do assign directly to the ‘__annotations__’ member of an
     object, you should always set it to a ‘dict’ object.

   * If you directly access the ‘__annotations__’ member of an object,
     you should ensure that it's a dictionary before attempting to
     examine its contents.

   * You should avoid modifying ‘__annotations__’ dicts.

   * You should avoid deleting the ‘__annotations__’ attribute of an
     object.


File: python.info,  Node: __annotations__ Quirks,  Prev: Best Practices For __annotations__ In Any Python Version,  Up: Annotations Best Practices

9.17.5 ‘__annotations__’ Quirks
-------------------------------

In all versions of Python 3, function objects lazy-create an annotations
dict if no annotations are defined on that object.  You can delete the
‘__annotations__’ attribute using ‘del fn.__annotations__’, but if you
then access ‘fn.__annotations__’ the object will create a new empty dict
that it will store and return as its annotations.  Deleting the
annotations on a function before it has lazily created its annotations
dict will throw an ‘AttributeError’; using ‘del fn.__annotations__’
twice in a row is guaranteed to always throw an ‘AttributeError’.

Everything in the above paragraph also applies to class and module
objects in Python 3.10 and newer.

In all versions of Python 3, you can set ‘__annotations__’ on a function
object to ‘None’.  However, subsequently accessing the annotations on
that object using ‘fn.__annotations__’ will lazy-create an empty
dictionary as per the first paragraph of this section.  This is 'not'
true of modules and classes, in any Python version; those objects permit
setting ‘__annotations__’ to any Python value, and will retain whatever
value is set.

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:

     from __future__ import annotations
     def foo(a: "str"): pass

     print(foo.__annotations__)

This prints ‘{'a': "'str'"}’.  This shouldn't really be considered a
"quirk"; it's mentioned here simply because it might be surprising.


File: python.info,  Node: 拡張モジュールを分離する,  Next: timer file descriptor HOWTO,  Prev: Annotations Best Practices,  Up: Python HOWTO

9.18 拡張モジュールを分離する
=============================

概要
....

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.

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.

* Menu:

* Who should read this::
* 背景: 背景<2>.
* Making Modules Safe with Multiple Interpreters::
* Heap Types: Heap Types<2>.
* 取り掛かり中の問題::


File: python.info,  Node: Who should read this,  Next: 背景<2>,  Up: 拡張モジュールを分離する

9.18.1 Who should read this
---------------------------

This guide is written for maintainers of *note C-API: 1b47. extensions
who would like to make that extension safer to use in applications where
Python itself is used as a library.


File: python.info,  Node: 背景<2>,  Next: Making Modules Safe with Multiple Interpreters,  Prev: Who should read this,  Up: 拡張モジュールを分離する

9.18.2 背景
-----------

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).

Python supports running multiple interpreters in one process.  There are
two cases to think about—users may run interpreters:

   - in sequence, with several *note Py_InitializeEx(): 4932./*note
     Py_FinalizeEx(): ce3. cycles, and

   - in parallel, managing "sub-interpreters" using *note
     Py_NewInterpreter(): 1721./*note Py_EndInterpreter(): 17ca.

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".

Historically, Python extension modules don't handle this use case well.
Many extension modules (and even some stdlib modules) use 'per-process'
global state, because C ‘static’ variables are extremely easy to use.
Thus, data that should be specific to an interpreter ends up being
shared between interpreters.  Unless the extension developer is careful,
it is very easy to introduce edge cases that lead to crashes when a
module is loaded in more than one interpreter in the same process.

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.

* Menu:

* Enter Per-Module State::
* Isolated Module Objects::
* Surprising Edge Cases::


File: python.info,  Node: Enter Per-Module State,  Next: Isolated Module Objects,  Up: 背景<2>

9.18.2.1 Enter Per-Module State
...............................

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 data should be attached to a 'module object'.  Each interpreter
creates its own module object, keeping the data separate.  For testing
the isolation, multiple module objects corresponding to a single
extension can even be loaded in a single interpreter.

Per-module state provides an easy way to think about lifetime and
resource ownership: the extension module will initialize when a module
object is created, and clean up when it's freed.  In this regard, a
module is just like any other *note PyObject: 312.*; there are no "on
interpreter shutdown" hooks to think—or forget—about.

Note that there are use cases for different kinds of "globals":
per-process, per-interpreter, per-thread or per-task state.  With
per-module state as the default, these are still possible, but you
should treat them as exceptional cases: if you need them, you should
give them additional care and testing.  (Note that this guide does not
cover them.)


File: python.info,  Node: Isolated Module Objects,  Next: Surprising Edge Cases,  Prev: Enter Per-Module State,  Up: 背景<2>

9.18.2.2 Isolated Module Objects
................................

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:

     >>> import sys
     >>> import binascii
     >>> old_binascii = binascii
     >>> del sys.modules['binascii']
     >>> import binascii  # create a new module object
     >>> old_binascii == binascii
     False

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 module object, not shared with other module objects, and
cleaned up when the module object is deallocated.  Since this just is a
rule of thumb, exceptions are possible (see *note Managing Global State:
4e8b.), but they will need more thought and attention to edge cases.

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.


File: python.info,  Node: Surprising Edge Cases,  Prev: Isolated Module Objects,  Up: 背景<2>

9.18.2.3 Surprising Edge Cases
..............................

Note that isolated modules do create some surprising edge cases.  Most
notably, each module object will typically not share its classes and
exceptions with other similar modules.  Continuing from the *note
example above: 4e8a, note that ‘old_binascii.Error’ and ‘binascii.Error’
are separate objects.  In the following code, the exception is 'not'
caught:

     >>> old_binascii.Error == binascii.Error
     False
     >>> try:
     ...     old_binascii.unhexlify(b'qwertyuiop')
     ... except binascii.Error:
     ...     print('boo')
     ...
     Traceback (most recent call last):
       File "<stdin>", line 2, in <module>
     binascii.Error: Non-hexadecimal digit found

This is expected.  Notice that pure-Python modules behave the same way:
it is a part of how Python works.

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.


File: python.info,  Node: Making Modules Safe with Multiple Interpreters,  Next: Heap Types<2>,  Prev: 背景<2>,  Up: 拡張モジュールを分離する

9.18.3 Making Modules Safe with Multiple Interpreters
-----------------------------------------------------

* Menu:

* Managing Global State::
* Managing Per-Module State::
* Opt-Out; Limiting to One Module Object per Process: Opt-Out Limiting to One Module Object per Process.
* Module State Access from Functions::


File: python.info,  Node: Managing Global State,  Next: Managing Per-Module State,  Up: Making Modules Safe with Multiple Interpreters

9.18.3.1 Managing Global State
..............................

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:

   - The ‘readline’ module manages 'the' terminal.

   - A module running on a circuit board wants to control 'the' on-board
     LED.

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 copies of it can access the state independently (along with
other libraries, whether for Python or other languages).  If that is not
possible, consider explicit locking.

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 *note Opt-Out;
Limiting to One Module Object per Process: 4e8e.


File: python.info,  Node: Managing Per-Module State,  Next: Opt-Out Limiting to One Module Object per Process,  Prev: Managing Global State,  Up: Making Modules Safe with Multiple Interpreters

9.18.3.2 Managing Per-Module State
..................................

To use per-module state, use *note multi-phase extension module
initialization: 47a8.  This signals that your module supports multiple
interpreters correctly.

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 some module-specific ‘struct’, which can store all of the module's
C-level state.  In particular, it is where you should put pointers to
classes (including exceptions, but excluding static types) and settings
(e.g.  ‘csv’'s *note field_size_limit: 1771.) which the C code needs to
function.

     注釈: 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.

     However, if module state is not needed in C code, storing it in
     ‘__dict__’ only is a good idea.

If the module state includes ‘PyObject’ pointers, the module object must
hold references to those objects and implement the module-level hooks
‘m_traverse’, ‘m_clear’ and ‘m_free’.  These work like ‘tp_traverse’,
‘tp_clear’ and ‘tp_free’ of a class.  Adding them will require some work
and make the code longer; this is the price for modules which can be
unloaded cleanly.

An example of a module with per-module state is currently available as
xxlimited(1); example module initialization shown at the bottom of the
file.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/blob/master/Modules/xxlimited.c


File: python.info,  Node: Opt-Out Limiting to One Module Object per Process,  Next: Module State Access from Functions,  Prev: Managing Per-Module State,  Up: Making Modules Safe with Multiple Interpreters

9.18.3.3 Opt-Out: Limiting to One Module Object per Process
...........................................................

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:

     static int loaded = 0;

     static int
     exec_module(PyObject* module)
     {
         if (loaded) {
             PyErr_SetString(PyExc_ImportError,
                             "cannot load module more than once per process");
             return -1;
         }
         loaded = 1;
         // ... rest of initialization
     }


File: python.info,  Node: Module State Access from Functions,  Prev: Opt-Out Limiting to One Module Object per Process,  Up: Making Modules Safe with Multiple Interpreters

9.18.3.4 Module State Access from Functions
...........................................

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’:

     static PyObject *
     func(PyObject *module, PyObject *args)
     {
         my_struct *state = (my_struct*)PyModule_GetState(module);
         if (state == NULL) {
             return NULL;
         }
         // ... rest of logic
     }

     注釈: ‘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.


File: python.info,  Node: Heap Types<2>,  Next: 取り掛かり中の問題,  Prev: Making Modules Safe with Multiple Interpreters,  Up: 拡張モジュールを分離する

9.18.4 Heap Types
-----------------

Traditionally, types defined in C code are 'static'; that is, ‘static
PyTypeObject’ structures defined directly in code and initialized using
‘PyType_Ready()’.

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’.

'CPython 実装の詳細:' Sharing truly immutable objects between
interpreters is fine, as long as they don't provide access to mutable
objects.  However, in CPython, every Python object has a mutable
implementation detail: the reference count.  Changes to the refcount are
guarded by the GIL. Thus, code that shares any Python objects across
interpreters implicitly depends on CPython's current, process-wide GIL.

Because they are immutable and process-global, static types cannot
access "their" module state.  If any method of such a type requires
access to module state, the type must be converted to a 'heap-allocated
type', or 'heap type' for short.  These correspond more closely to
classes created by Python's ‘class’ statement.

For new modules, using heap types by default is a good rule of thumb.

* Menu:

* Changing Static Types to Heap Types::
* Defining Heap Types::
* Garbage-Collection Protocol::
* Module State Access from Classes::
* Module State Access from Regular Methods::
* Module State Access from Slot Methods, Getters and Setters: Module State Access from Slot Methods Getters and Setters.
* Lifetime of the Module State::


File: python.info,  Node: Changing Static Types to Heap Types,  Next: Defining Heap Types,  Up: Heap Types<2>

9.18.4.1 Changing Static Types to Heap Types
............................................

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, creating a type that works exactly like a given static type.  So,
when rewriting the class definition in a new API, you are likely to
unintentionally change a few details (e.g.  pickleability or inherited
slots).  Always test the details that are important to you.

Watch out for the following two points in particular (but note that this
is not a comprehensive list):

   * Unlike static types, heap type objects are mutable by default.  Use
     the *note Py_TPFLAGS_IMMUTABLETYPE: 39c. flag to prevent
     mutability.

   * Heap types inherit *note tp_new: 54b. by default, so it may become
     possible to instantiate them from Python code.  You can prevent
     this with the *note Py_TPFLAGS_DISALLOW_INSTANTIATION: 54e. flag.


File: python.info,  Node: Defining Heap Types,  Next: Garbage-Collection Protocol,  Prev: Changing Static Types to Heap Types,  Up: Heap Types<2>

9.18.4.2 Defining Heap Types
............................

Heap types can be created by filling a *note PyType_Spec: 1681.
structure, a description or "blueprint" of a class, and calling *note
PyType_FromModuleAndSpec(): 51c. to construct a new class object.

     注釈: Other functions, like *note PyType_FromSpec(): 549, can also
     create heap types, but *note PyType_FromModuleAndSpec(): 51c.
     associates the module with the class, allowing access to the module
     state from methods.

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).


File: python.info,  Node: Garbage-Collection Protocol,  Next: Module State Access from Classes,  Prev: Defining Heap Types,  Up: Heap Types<2>

9.18.4.3 Garbage-Collection Protocol
....................................

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.

To avoid memory leaks, instances of heap types must implement the
garbage collection protocol.  That is, heap types should:

   - Have the *note Py_TPFLAGS_HAVE_GC: 748. flag.

   - Define a traverse function using ‘Py_tp_traverse’, which visits the
     type (e.g.  using ‘Py_VISIT(Py_TYPE(self))’).

Please refer to the documentation of *note Py_TPFLAGS_HAVE_GC: 748. and
*note tp_traverse: 749. for additional considerations.

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.

* Menu:

* tp_traverse in Python 3.8 and lower: tp_traverse in Python 3 8 and lower.
* Delegating tp_traverse::
* Defining tp_dealloc::
* Not overriding tp_free::
* Avoiding PyObject_New::


File: python.info,  Node: tp_traverse in Python 3 8 and lower,  Next: Delegating tp_traverse,  Up: Garbage-Collection Protocol

9.18.4.4 ‘tp_traverse’ in Python 3.8 and lower
..............................................

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:

     static int my_traverse(PyObject *self, visitproc visit, void *arg)
     {
         if (Py_Version >= 0x03090000) {
             Py_VISIT(Py_TYPE(self));
         }
         return 0;
     }

Unfortunately, *note Py_Version: 721. was only added in Python 3.11.  As
a replacement, use:

   * *note PY_VERSION_HEX: 722, if not using the stable ABI, or

   * *note sys.version_info: 66c. (via *note PySys_GetObject(): 362. and
     *note PyArg_ParseTuple(): 53d.).


File: python.info,  Node: Delegating tp_traverse,  Next: Defining tp_dealloc,  Prev: tp_traverse in Python 3 8 and lower,  Up: Garbage-Collection Protocol

9.18.4.5 Delegating ‘tp_traverse’
.................................

If your traverse function delegates to the *note tp_traverse: 749. 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’.

For example, if your traverse function includes:

     base->tp_traverse(self, visit, arg)

...and ‘base’ may be a static type, then it should also include:

     if (base->tp_flags & Py_TPFLAGS_HEAPTYPE) {
         // a heap type's tp_traverse already visited Py_TYPE(self)
     } else {
         if (Py_Version >= 0x03090000) {
             Py_VISIT(Py_TYPE(self));
         }
     }

It is not necessary to handle the type's reference count in *note
tp_new: 54b. and *note tp_clear: 478d.


File: python.info,  Node: Defining tp_dealloc,  Next: Not overriding tp_free,  Prev: Delegating tp_traverse,  Up: Garbage-Collection Protocol

9.18.4.6 Defining ‘tp_dealloc’
..............................

If your type has a custom *note tp_dealloc: 477a. function, it needs to:

   - call *note PyObject_GC_UnTrack(): 14b0. before any fields are
     invalidated, and

   - decrement the reference count of the type.

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:

     static void my_dealloc(PyObject *self)
     {
         PyObject_GC_UnTrack(self);
         ...
         PyTypeObject *type = Py_TYPE(self);
         type->tp_free(self);
         Py_DECREF(type);
     }

The default ‘tp_dealloc’ function does this, so if your type does 'not'
override ‘tp_dealloc’ you don't need to add it.


File: python.info,  Node: Not overriding tp_free,  Next: Avoiding PyObject_New,  Prev: Defining tp_dealloc,  Up: Garbage-Collection Protocol

9.18.4.7 Not overriding ‘tp_free’
.................................

The *note tp_free: 477b. slot of a heap type must be set to *note
PyObject_GC_Del(): 14ae.  This is the default; do not override it.


File: python.info,  Node: Avoiding PyObject_New,  Prev: Not overriding tp_free,  Up: Garbage-Collection Protocol

9.18.4.8 Avoiding ‘PyObject_New’
................................

GC-tracked objects need to be allocated using GC-aware functions.

If you use use *note PyObject_New(): 953. or *note PyObject_NewVar():
954.:

   - Get and call type's *note tp_alloc: 477c. slot, if possible.  That
     is, replace ‘TYPE *o = PyObject_New(TYPE, typeobj)’ with:

          TYPE *o = typeobj->tp_alloc(typeobj, 0);

     Replace ‘o = PyObject_NewVar(TYPE, typeobj, size)’ with the same,
     but use size instead of the 0.

   - If the above is not possible (e.g.  inside a custom ‘tp_alloc’),
     call *note PyObject_GC_New(): a70. or *note PyObject_GC_NewVar():
     a71.:

          TYPE *o = PyObject_GC_New(TYPE, typeobj);

          TYPE *o = PyObject_GC_NewVar(TYPE, typeobj, size);


File: python.info,  Node: Module State Access from Classes,  Next: Module State Access from Regular Methods,  Prev: Garbage-Collection Protocol,  Up: Heap Types<2>

9.18.4.9 Module State Access from Classes
.........................................

If you have a type object defined with *note PyType_FromModuleAndSpec():
51c, you can call *note PyType_GetModule(): 93c. to get the associated
module, and then *note PyModule_GetState(): 94e. to get the module's
state.

To save a some tedious error-handling boilerplate code, you can combine
these two steps with *note PyType_GetModuleState(): 93d, resulting in:

     my_struct *state = (my_struct*)PyType_GetModuleState(type);
     if (state == NULL) {
         return NULL;
     }


File: python.info,  Node: Module State Access from Regular Methods,  Next: Module State Access from Slot Methods Getters and Setters,  Prev: Module State Access from Classes,  Up: Heap Types<2>

9.18.4.10 Module State Access from Regular Methods
..................................................

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.

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.

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.

     注釈: The following Python code can illustrate the concept.
     ‘Base.get_defining_class’ returns ‘Base’ even if ‘type(self) ==
     Sub’:

          class Base:
              def get_type_of_self(self):
                  return type(self)

              def get_defining_class(self):
                  return __class__

          class Sub(Base):
              pass

For a method to get its "defining class", it must use the *note
METH_METHOD | METH_FASTCALL | METH_KEYWORDS: 15f2. *note calling
convention: 1480. and the corresponding *note PyCMethod: 72f. signature:

     PyObject *PyCMethod(
         PyObject *self,               // object the method was called on
         PyTypeObject *defining_class, // defining class
         PyObject *const *args,        // C array of arguments
         Py_ssize_t nargs,             // length of "args"
         PyObject *kwnames)            // NULL, or dict of keyword arguments

Once you have the defining class, call *note PyType_GetModuleState():
93d. to get the state of its associated module.

例えば:

     static PyObject *
     example_method(PyObject *self,
             PyTypeObject *defining_class,
             PyObject *const *args,
             Py_ssize_t nargs,
             PyObject *kwnames)
     {
         my_struct *state = (my_struct*)PyType_GetModuleState(defining_class);
         if (state == NULL) {
             return NULL;
         }
         ... // rest of logic
     }

     PyDoc_STRVAR(example_method_doc, "...");

     static PyMethodDef my_methods[] = {
         {"example_method",
           (PyCFunction)(void(*)(void))example_method,
           METH_METHOD|METH_FASTCALL|METH_KEYWORDS,
           example_method_doc}
         {NULL},
     }


File: python.info,  Node: Module State Access from Slot Methods Getters and Setters,  Next: Lifetime of the Module State,  Prev: Module State Access from Regular Methods,  Up: Heap Types<2>

9.18.4.11 Module State Access from Slot Methods, Getters and Setters
....................................................................

     注釈: これは Python 3.11 の新機能です。

Slot methods—the fast C equivalents for special methods, such as *note
nb_add: 4a3d. for *note __add__: 1eed. or *note tp_new: 54b. for
initialization—have a very simple API that doesn't allow passing in the
defining class, unlike with *note PyCMethod: 72f.  The same goes for
getters and setters defined with *note PyGetSetDef: b86.

To access the module state in these cases, use the *note
PyType_GetModuleByDef(): 36d. function, and pass in the module
definition.  Once you have the module, call *note PyModule_GetState():
94e. to get the state:

     PyObject *module = PyType_GetModuleByDef(Py_TYPE(self), &module_def);
     my_struct *state = (my_struct*)PyModule_GetState(module);
     if (state == NULL) {
         return NULL;
     }

‘PyType_GetModuleByDef()’ works by searching the *note method resolution
order: 20e5. (i.e.  all superclasses) for the first superclass that has
a corresponding module.

     注釈: In very exotic cases (inheritance chains spanning multiple
     modules created from the same definition),
     ‘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.


File: python.info,  Node: Lifetime of the Module State,  Prev: Module State Access from Slot Methods Getters and Setters,  Up: Heap Types<2>

9.18.4.12 Lifetime of the Module State
......................................

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.

Usually this is not an issue, because types created with *note
PyType_FromModuleAndSpec(): 51c, and their instances, hold a reference
to the module.  However, you must be careful in reference counting when
you reference module state from other places, such as callbacks for
external libraries.


File: python.info,  Node: 取り掛かり中の問題,  Prev: Heap Types<2>,  Up: 拡張モジュールを分離する

9.18.5 取り掛かり中の問題
-------------------------

Several issues around per-module state and heap types are still open.

Discussions about improving the situation are best held on the capi-sig
mailing list(1).

* Menu:

* Per-Class Scope::
* Lossless Conversion to Heap Types::

   ---------- Footnotes ----------

   (1) https://mail.python.org/mailman3/lists/capi-sig.python.org/


File: python.info,  Node: Per-Class Scope,  Next: Lossless Conversion to Heap Types,  Up: 取り掛かり中の問題

9.18.5.1 Per-Class Scope
........................

It is currently (as of Python 3.11) not possible to attach state to
individual 'types' without relying on CPython implementation details
(which may change in the future—perhaps, ironically, to allow a proper
solution for per-class scope).


File: python.info,  Node: Lossless Conversion to Heap Types,  Prev: Per-Class Scope,  Up: 取り掛かり中の問題

9.18.5.2 Lossless Conversion to Heap Types
..........................................

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.


File: python.info,  Node: timer file descriptor HOWTO,  Next: The Python 2 3 Method Resolution Order,  Prev: 拡張モジュールを分離する,  Up: Python HOWTO

9.19 timer file descriptor HOWTO
================================


Release: 1.13

This HOWTO discusses Python's support for the linux timer file
descriptor.

* Menu:

* Examples::


File: python.info,  Node: Examples,  Up: timer file descriptor HOWTO

9.19.1 Examples
---------------

The following example shows how to use a timer file descriptor to
execute a function twice a second:

     # Practical scripts should use really use a non-blocking timer,
     # we use a blocking timer here for simplicity.
     import os, time

     # Create the timer file descriptor
     fd = os.timerfd_create(time.CLOCK_REALTIME)

     # Start the timer in 1 second, with an interval of half a second
     os.timerfd_settime(fd, initial=1, interval=0.5)

     try:
         # Process timer events four times.
         for _ in range(4):
             # read() will block until the timer expires
             _ = os.read(fd, 8)
             print("Timer expired")
     finally:
         # Remember to close the timer file descriptor!
         os.close(fd)

To avoid the precision loss caused by the *note float: 2ce. type, timer
file descriptors allow specifying initial expiration and interval in
integer nanoseconds with ‘_ns’ variants of the functions.

This example shows how *note epoll(): f60. can be used with timer file
descriptors to wait until the file descriptor is ready for reading:

     import os, time, select, socket, sys

     # Create an epoll object
     ep = select.epoll()

     # In this example, use loopback address to send "stop" command to the server.
     #
     # $ telnet 127.0.0.1 1234
     # Trying 127.0.0.1...
     # Connected to 127.0.0.1.
     # Escape character is '^]'.
     # stop
     # Connection closed by foreign host.
     #
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.bind(("127.0.0.1", 1234))
     sock.setblocking(False)
     sock.listen(1)
     ep.register(sock, select.EPOLLIN)

     # Create timer file descriptors in non-blocking mode.
     num = 3
     fds = []
     for _ in range(num):
         fd = os.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)
         fds.append(fd)
         # Register the timer file descriptor for read events
         ep.register(fd, select.EPOLLIN)

     # Start the timer with os.timerfd_settime_ns() in nanoseconds.
     # Timer 1 fires every 0.25 seconds; timer 2 every 0.5 seconds; etc
     for i, fd in enumerate(fds, start=1):
         one_sec_in_nsec = 10**9
         i = i * one_sec_in_nsec
         os.timerfd_settime_ns(fd, initial=i//4, interval=i//4)

     timeout = 3
     try:
         conn = None
         is_active = True
         while is_active:
             # Wait for the timer to expire for 3 seconds.
             # epoll.poll() returns a list of (fd, event) pairs.
             # fd is a file descriptor.
             # sock and conn[=returned value of socket.accept()] are socket objects, not file descriptors.
             # So use sock.fileno() and conn.fileno() to get the file descriptors.
             events = ep.poll(timeout)

             # If more than one timer file descriptors are ready for reading at once,
             # epoll.poll() returns a list of (fd, event) pairs.
             #
             # In this example settings,
             #    1st timer fires every 0.25 seconds in 0.25 seconds. (0.25, 0.5, 0.75, 1.0, ...)
             #    2nd timer every 0.5 seconds in 0.5 seconds. (0.5, 1.0, 1.5, 2.0, ...)
             #    3rd timer every 0.75 seconds in 0.75 seconds. (0.75, 1.5, 2.25, 3.0, ...)
             #
             #    In 0.25 seconds, only 1st timer fires.
             #    In 0.5 seconds, 1st timer and 2nd timer fires at once.
             #    In 0.75 seconds, 1st timer and 3rd timer fires at once.
             #    In 1.5 seconds, 1st timer, 2nd timer and 3rd timer fires at once.
             #
             # If a timer file descriptor is signaled more than once since
             # the last os.read() call, os.read() returns the number of signaled
             # as host order of class bytes.
             print(f"Signaled events={events}")
             for fd, event in events:
                 if event & select.EPOLLIN:
                     if fd == sock.fileno():
                         # Check if there is a connection request.
                         print(f"Accepting connection {fd}")
                         conn, addr = sock.accept()
                         conn.setblocking(False)
                         print(f"Accepted connection {conn} from {addr}")
                         ep.register(conn, select.EPOLLIN)
                     elif conn and fd == conn.fileno():
                         # Check if there is data to read.
                         print(f"Reading data {fd}")
                         data = conn.recv(1024)
                         if data:
                             # You should catch UnicodeDecodeError exception for safety.
                             cmd = data.decode()
                             if cmd.startswith("stop"):
                                 print(f"Stopping server")
                                 is_active = False
                             else:
                                 print(f"Unknown command: {cmd}")
                         else:
                             # No more data, close connection
                             print(f"Closing connection {fd}")
                             ep.unregister(conn)
                             conn.close()
                             conn = None
                     elif fd in fds:
                         print(f"Reading timer {fd}")
                         count = int.from_bytes(os.read(fd, 8), byteorder=sys.byteorder)
                         print(f"Timer {fds.index(fd) + 1} expired {count} times")
                     else:
                         print(f"Unknown file descriptor {fd}")
     finally:
         for fd in fds:
             ep.unregister(fd)
             os.close(fd)
         ep.close()

This example shows how *note select(): d6d. can be used with timer file
descriptors to wait until the file descriptor is ready for reading:

     import os, time, select, socket, sys

     # In this example, use loopback address to send "stop" command to the server.
     #
     # $ telnet 127.0.0.1 1234
     # Trying 127.0.0.1...
     # Connected to 127.0.0.1.
     # Escape character is '^]'.
     # stop
     # Connection closed by foreign host.
     #
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.bind(("127.0.0.1", 1234))
     sock.setblocking(False)
     sock.listen(1)

     # Create timer file descriptors in non-blocking mode.
     num = 3
     fds = [os.timerfd_create(time.CLOCK_REALTIME, flags=os.TFD_NONBLOCK)
            for _ in range(num)]
     select_fds = fds + [sock]

     # Start the timers with os.timerfd_settime() in seconds.
     # Timer 1 fires every 0.25 seconds; timer 2 every 0.5 seconds; etc
     for i, fd in enumerate(fds, start=1):
        os.timerfd_settime(fd, initial=i/4, interval=i/4)

     timeout = 3
     try:
         conn = None
         is_active = True
         while is_active:
            # Wait for the timer to expire for 3 seconds.
            # select.select() returns a list of file descriptors or objects.
            rfd, wfd, xfd = select.select(select_fds, select_fds, select_fds, timeout)
            for fd in rfd:
                if fd == sock:
                    # Check if there is a connection request.
                    print(f"Accepting connection {fd}")
                    conn, addr = sock.accept()
                    conn.setblocking(False)
                    print(f"Accepted connection {conn} from {addr}")
                    select_fds.append(conn)
                elif conn and fd == conn:
                    # Check if there is data to read.
                    print(f"Reading data {fd}")
                    data = conn.recv(1024)
                    if data:
                        # You should catch UnicodeDecodeError exception for safety.
                        cmd = data.decode()
                        if cmd.startswith("stop"):
                            print(f"Stopping server")
                            is_active = False
                        else:
                            print(f"Unknown command: {cmd}")
                    else:
                        # No more data, close connection
                        print(f"Closing connection {fd}")
                        select_fds.remove(conn)
                        conn.close()
                        conn = None
                elif fd in fds:
                    print(f"Reading timer {fd}")
                    count = int.from_bytes(os.read(fd, 8), byteorder=sys.byteorder)
                    print(f"Timer {fds.index(fd) + 1} expired {count} times")
                else:
                    print(f"Unknown file descriptor {fd}")
     finally:
         for fd in fds:
            os.close(fd)
         sock.close()
         sock = None


File: python.info,  Node: The Python 2 3 Method Resolution Order,  Next: Python experimental support for free threading,  Prev: timer file descriptor HOWTO,  Up: Python HOWTO

9.20 The Python 2.3 Method Resolution Order
===========================================

     注釈: 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.

By Michele Simionato(1).


Abstract: '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 for newbies, it is quite pedagogical with many worked
out examples.  I am not aware of other publicly available documents with
the same scope, therefore it should be useful.'

Disclaimer:

     '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!'

Acknowledgments:

     '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 local precedence ordering.  David Goodger for
     help with the formatting in reStructuredText.  David Mertz for help
     with the editing.  Finally, Guido van Rossum who enthusiastically
     added this document to the official Python 2.3 home-page.'

* Menu:

* The beginning::
* The C3 Method Resolution Order::
* Examples: Examples<2>.
* Bad Method Resolution Orders::
* The end::
* Resources::

   ---------- Footnotes ----------

   (1) https://www.phyast.pitt.edu/~micheles/


File: python.info,  Node: The beginning,  Next: The C3 Method Resolution Order,  Up: The Python 2 3 Method Resolution Order

9.20.1 The beginning
--------------------

     'Felix qui potuit rerum cognoscere causas' - Virgilius

Everything started with a post by Samuele Pedroni to the Python
development mailing list (1).  In his post, Samuele showed that the
Python 2.2 method resolution order is not monotonic and he proposed to
replace it with the C3 method resolution order.  Guido agreed with his
arguments and therefore now Python 2.3 uses C3.  The C3 method itself
has nothing to do with Python, since it was invented by people working
on Dylan and it is described in a paper intended for lispers (2).  The
present paper gives a (hopefully) readable discussion of the C3
algorithm for Pythonistas who want to understand the reasons for the
change.

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'
maintain their old method resolution order, depth first and then left to
right.  Therefore, there is no breaking of old code for classic classes;
and even if in principle there could be breaking of code for Python 2.2
new style classes, in practice the cases in which the C3 resolution
order differs from the Python 2.2 method resolution order are so rare
that no real breaking of code is expected.  Therefore:

     'Don't be scared!'

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 you can easily skip this paper.  On the other hand, if
you really want to 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.

Let me begin with some basic definitions.

  1. 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.

  2. 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.

  3. 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.

  4. 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 simply the list [C, C1 , C2].  However, with
     multiple inheritance hierarchies, the construction of the
     linearization is more cumbersome, since it is more difficult to
     construct a linearization that respects 'local precedence ordering'
     and 'monotonicity'.

  5. 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 true: 'if C1 precedes C2 in the linearization of C,
     then C1 precedes C2 in the linearization of any subclass of C'.
     Otherwise, the innocuous operation of deriving a new class could
     change the resolution order of methods, potentially introducing
     very subtle bugs.  Examples where this happens will be shown later.

  6. 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.

Here I give an example of this situation.  Consider the hierarchy

     >>> O = object
     >>> class X(O): pass
     >>> class Y(O): pass
     >>> class A(X,Y): pass
     >>> class B(Y,X): pass

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:

           -----------
          |           |
          |    O      |
          |  /   \    |
           - X    Y  /
             |  / | /
             | /  |/
             A    B
             \   /
               ?

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.

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).

   ---------- Footnotes ----------

   (1) The thread on python-dev started by Samuele Pedroni:
‘https://mail.python.org/pipermail/python-dev/2002-October/029035.html’

   (2) The paper 'A Monotonic Superclass Linearization for Dylan':
‘https://doi.org/10.1145/236337.236343’


File: python.info,  Node: The C3 Method Resolution Order,  Next: Examples<2>,  Prev: The beginning,  Up: The Python 2 3 Method Resolution Order

9.20.2 The C3 Method Resolution Order
-------------------------------------

Let me introduce a few simple notations which will be useful for the
following discussion.  I will use the shortcut notation:

     C1 C2 ... CN

to indicate the list of classes [C1, C2, ...  , CN].

The 'head' of the list is its first element:

     head = C1

whereas the 'tail' is the rest of the list:

     tail = C2 ... CN.

I shall also use the notation:

     C + (C1 C2 ... CN) = C C1 C2 ... CN

to denote the sum of the lists [C] + [C1, C2, ...  ,CN].

Now I can explain how the MRO works in Python 2.3.

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:

     'the linearization of C is the sum of C plus the merge of the
     linearizations of the parents and the list of the parents.'

In symbolic notation:

     L[C(B1 ... BN)] = C + merge(L[B1] ... L[BN], B1 ... BN)

In particular, if C is the ‘object’ class, which has no parents, the
linearization is trivial:

     L[object] = object.

However, in general one has to compute the merge according to the
following prescription:

     '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 remove it from the lists in the merge,
     otherwise look at the head of the next list and take it, if it is a
     good head.  Then repeat the operation until all the class are
     removed or it is impossible to find good heads.  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.'

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.

The computation of the merge is trivial if C has only one parent (single
inheritance); in this case:

     L[C(B)] = C + merge(L[B],B) = C + L[B]

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 ;-)


File: python.info,  Node: Examples<2>,  Next: Bad Method Resolution Orders,  Prev: The C3 Method Resolution Order,  Up: The Python 2 3 Method Resolution Order

9.20.3 Examples
---------------

First example.  Consider the following hierarchy:

     >>> O = object
     >>> class F(O): pass
     >>> class E(O): pass
     >>> class D(O): pass
     >>> class C(D,F): pass
     >>> class B(D,E): pass
     >>> class A(B,C): pass

In this case the inheritance graph can be drawn as:

                                    6
                                   ---
          Level 3                 | O |                  (more general)
                                /  ---  \
                               /    |    \                      |
                              /     |     \                     |
                             /      |      \                    |
                            ---    ---    ---                   |
          Level 2        3 | D | 4| E |  | F | 5                |
                            ---    ---    ---                   |
                             \  \ _ /       |                   |
                              \    / \ _    |                   |
                               \  /      \  |                   |
                                ---      ---                    |
          Level 1            1 | B |    | C | 2                 |
                                ---      ---                    |
                                  \      /                      |
                                   \    /                      \ /
                                     ---
          Level 0                 0 | A |                (more specialized)
                                     ---

The linearizations of O,D,E and F are trivial:

     L[O] = O
     L[D] = D O
     L[E] = E O
     L[F] = F O

The linearization of B can be computed as:

     L[B] = B + merge(DO, EO, DE)

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
tail of the sequence EO. In this case the rule says that we have to skip
to 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:

     L[B] =  B D E O

Using the same procedure one finds:

     L[C] = C + merge(DO,FO,DF)
          = C + D + merge(O,FO,F)
          = C + D + F + merge(O,O)
          = C D F O

Now we can compute:

     L[A] = A + merge(BDEO,CDFO,BC)
          = A + B + merge(DEO,CDFO,C)
          = A + B + C + merge(DEO,DFO)
          = A + B + C + D + merge(EO,FO)
          = A + B + C + D + E + merge(O,FO)
          = A + B + C + D + E + F + merge(O,O)
          = A B C D E F O

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.

I leave as an exercise for the reader to compute the linearization for
my second example:

     >>> O = object
     >>> class F(O): pass
     >>> class E(O): pass
     >>> class D(O): pass
     >>> class C(D,F): pass
     >>> class B(E,D): pass
     >>> class A(B,C): pass

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:

                                     6
                                    ---
          Level 3                  | O |
                                 /  ---  \
                                /    |    \
                               /     |     \
                              /      |      \
                            ---     ---    ---
          Level 2        2 | E | 4 | D |  | F | 5
                            ---     ---    ---
                             \      / \     /
                              \    /   \   /
                               \  /     \ /
                                ---     ---
          Level 1            1 | B |   | C | 3
                                ---     ---
                                 \       /
                                  \     /
                                    ---
          Level 0                0 | A |
                                    ---

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.

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 *note mro(): 1e8b. method of class A:

     >>> A.mro()
     [<class 'A'>, <class 'B'>, <class 'E'>,
     <class 'C'>, <class 'D'>, <class 'F'>,
     <class 'object'>]

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:

          L[O] = 0
          L[X] = X O
          L[Y] = Y O
          L[A] = A X Y O
          L[B] = B Y X O

However, it is impossible to compute the linearization for a class C
that inherits from A and B:

     L[C] = C + merge(AXYO, BYXO, AB)
          = C + A + merge(XYO, BYXO, B)
          = C + A + B + merge(XYO, YXO)

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.


File: python.info,  Node: Bad Method Resolution Orders,  Next: The end,  Prev: Examples<2>,  Up: The Python 2 3 Method Resolution Order

9.20.4 Bad Method Resolution Orders
-----------------------------------

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.

It is easier to start with the local precedence ordering.  Consider the
following example:

     >>> F=type('Food',(),{'remember2buy':'spam'})
     >>> E=type('Eggs',(F,),{'remember2buy':'eggs'})
     >>> G=type('GoodFood',(F,E),{}) # under Python 2.3 this is an error!

with inheritance diagram

                       O
                       |
          (buy spam)   F
                       | \
                       | E   (buy eggs)
                       | /
                       G

                (buy eggs or spam ?)

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.rembermer2buy' and not by 'E.remember2buy': nevertheless Python 2.2
gives

     >>> G.remember2buy
     'eggs'

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:

     L[G,P22]= G E F object   # F *follows* E

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
superclass of E; nevertheless the breaking of local precedence ordering
is quite non-intuitive and error prone.  This is particularly true since
it is a different from old style classes:

     >>> class F: remember2buy='spam'
     >>> class E(F): remember2buy='eggs'
     >>> class G(F,E): pass
     >>> G.remember2buy
     'spam'

In this case the MRO is GFEF and the local precedence ordering is
preserved.

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 the ambiguity by raising an exception in the creation
of class G, effectively stopping the programmer from generating
ambiguous hierarchies.  The reason for that is that the C3 algorithm
fails when the merge:

     merge(FO,EFO,FE)

cannot be computed, because F is in the tail of EFO and E is in the tail
of FE.

The real solution is to design a non-ambiguous hierarchy, i.e.  to
derive G from E and F (the more specific first) and not from F and E; in
this case the MRO is GEF without any doubt.

                     O
                     |
                     F (spam)
                   / |
          (eggs)   E |
                   \ |
                     G
                       (eggs, no doubt)

Python 2.3 forces the programmer to write good hierarchies (or, at
least, less error-prone ones).

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:

     >>> class A(object): pass
     >>> class C(A,A): pass # error
     Traceback (most recent call last):
       File "<stdin>", line 1, in ?
     TypeError: duplicate base class A

Python 2.2 (both for classic classes and new style classes) in this
situation, would not raise any exception.

Finally, I would like to point out two lessons we have learned from this
example:

  1. despite the name, the MRO determines the resolution order of
     attributes, not only of methods;

  2. the default food for Pythonistas is spam !  (but you already knew
     that ;-)

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.

To prove that the MRO for classic classes is non-monotonic is rather
trivial, it is enough to look at the diamond diagram:

             C
            / \
           /   \
          A     B
           \   /
            \ /
             D

One easily discerns the inconsistency:

     L[B,P21] = B C        # B precedes C : B's methods win
     L[D,P21] = D A C B C  # B follows C  : C's methods win!

On the other hand, there are no problems with the Python 2.2 and 2.3
MROs, they give both:

     L[D] = D A B C

Guido points out in his essay (1) 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.

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:

     >>> class A(object): pass
     >>> class B(object): pass
     >>> class C(object): pass
     >>> class D(object): pass
     >>> class E(object): pass
     >>> class K1(A,B,C): pass
     >>> class K2(D,B,E): pass
     >>> class K3(D,A):   pass
     >>> class Z(K1,K2,K3): pass

Here are the linearizations according to the C3 MRO (the reader should
verify these linearizations as an exercise and draw the inheritance
diagram ;-)

     L[A] = A O
     L[B] = B O
     L[C] = C O
     L[D] = D O
     L[E] = E O
     L[K1]= K1 A B C O
     L[K2]= K2 D B E O
     L[K3]= K3 D A O
     L[Z] = Z K1 K2 K3 D A B C E O

Python 2.2 gives exactly the same linearizations for A, B, C, D, E, K1,
K2 and K3, but a different linearization for Z:

     L[Z,P22] = Z K1 K3 A K2 D B C E O

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 methods derived by D override methods derived by A, but in Z, which
still is a subclass of K3, methods derived by A override methods derived
by D! This is a violation of monotonicity.  Moreover, the Python 2.2
linearization of Z is also inconsistent with local precedence ordering,
since the local precedence list of the class Z is [K1, K2, K3] (K2
precedes K3), whereas in the linearization of Z K2 'follows' K3.  These
problems explain why the 2.2 rule has been dismissed in favor of the C3
rule.

   ---------- Footnotes ----------

   (1) 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’


File: python.info,  Node: The end,  Next: Resources,  Prev: Bad Method Resolution Orders,  Up: The Python 2 3 Method Resolution Order

9.20.5 The end
--------------

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 programmer too, who didn't want to exercise her/his brain.
Finally, it is for the programmer with some hubris, otherwise s/he would
not be reading a paper on the C3 method resolution order in multiple
inheritance hierarchies ;-) These three virtues taken all together (and
'not' separately) deserve a prize: the prize is a short Python 2.2
script that allows you to compute the 2.3 MRO without risk to your
brain.  Simply change the last line to play with the various examples I
have discussed in this paper.:

     #<mro.py>

     """C3 algorithm by Samuele Pedroni (with readability enhanced by me)."""

     class __metaclass__(type):
         "All classes are metamagically modified to be nicely printed"
         __repr__ = lambda cls: cls.__name__

     class ex_2:
         "Serious order disagreement" #From Guido
         class O: pass
         class X(O): pass
         class Y(O): pass
         class A(X,Y): pass
         class B(Y,X): pass
         try:
             class Z(A,B): pass #creates Z(A,B) in Python 2.2
         except TypeError:
             pass # Z(A,B) cannot be created in Python 2.3

     class ex_5:
         "My first example"
         class O: pass
         class F(O): pass
         class E(O): pass
         class D(O): pass
         class C(D,F): pass
         class B(D,E): pass
         class A(B,C): pass

     class ex_6:
         "My second example"
         class O: pass
         class F(O): pass
         class E(O): pass
         class D(O): pass
         class C(D,F): pass
         class B(E,D): pass
         class A(B,C): pass

     class ex_9:
         "Difference between Python 2.2 MRO and C3" #From Samuele
         class O: pass
         class A(O): pass
         class B(O): pass
         class C(O): pass
         class D(O): pass
         class E(O): pass
         class K1(A,B,C): pass
         class K2(D,B,E): pass
         class K3(D,A): pass
         class Z(K1,K2,K3): pass

     def merge(seqs):
         print '\n\nCPL[%s]=%s' % (seqs[0][0],seqs),
         res = []; i=0
         while 1:
           nonemptyseqs=[seq for seq in seqs if seq]
           if not nonemptyseqs: return res
           i+=1; print '\n',i,'round: candidates...',
           for seq in nonemptyseqs: # find merge candidates among seq heads
               cand = seq[0]; print ' ',cand,
               nothead=[s for s in nonemptyseqs if cand in s[1:]]
               if nothead: cand=None #reject candidate
               else: break
           if not cand: raise "Inconsistent hierarchy"
           res.append(cand)
           for seq in nonemptyseqs: # remove cand
               if seq[0] == cand: del seq[0]

     def mro(C):
         "Compute the class precedence list (mro) according to C3"
         return merge([[C]]+map(mro,C.__bases__)+[list(C.__bases__)])

     def print_mro(C):
         print '\nMRO[%s]=%s' % (C,mro(C))
         print '\nP22 MRO[%s]=%s' % (C,C.mro())

     print_mro(ex_9.Z)

     #</mro.py>

That's all folks,

     enjoy !


File: python.info,  Node: Resources,  Prev: The end,  Up: The Python 2 3 Method Resolution Order

9.20.6 Resources
----------------


File: python.info,  Node: Python experimental support for free threading,  Next: C API Extension Support for Free Threading,  Prev: The Python 2 3 Method Resolution Order,  Up: Python HOWTO

9.21 Python experimental support for free threading
===================================================

Starting with the 3.13 release, CPython has experimental support for a
build of Python called *note free threading: 433e. where the *note
global interpreter lock: 12e. (GIL) is disabled.  Free-threaded
execution allows for full utilization of the available processing power
by running threads in parallel on available CPU cores.  While not all
software will benefit from this automatically, programs designed with
threading in mind will run faster on multi-core hardware.

'The free-threaded mode is experimental' and work is ongoing to improve
it: expect some bugs and a substantial single-threaded performance hit.

This document describes the implications of free threading for Python
code.  See *note C API Extension Support for Free Threading: 4eb0. for
information on how to write C extensions that support the free-threaded
build.

参考
....

PEP 703(1) – Making the Global Interpreter Lock Optional in CPython for
an overall description of free-threaded Python.

* Menu:

* Installation::
* Identifying free-threaded Python::
* The global interpreter lock in free-threaded Python::
* Thread safety::
* Known limitations::

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0703/


File: python.info,  Node: Installation,  Next: Identifying free-threaded Python,  Up: Python experimental support for free threading

9.21.1 Installation
-------------------

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/’.

For information on other platforms, see the Installing a Free-Threaded
Python(1), a community-maintained installation guide for installing
free-threaded Python.

When building CPython from source, the *note -disable-gil: 15a.
configure option should be used to build a free-threaded Python
interpreter.

   ---------- Footnotes ----------

   (1) https://py-free-threading.github.io/installing_cpython/


File: python.info,  Node: Identifying free-threaded Python,  Next: The global interpreter lock in free-threaded Python,  Prev: Installation,  Up: Python experimental support for free threading

9.21.2 Identifying free-threaded Python
---------------------------------------

To check if the current interpreter supports free-threading, *note
python -VV: 15d. and *note sys.version: 15e. contain "experimental
free-threading build".  The new *note sys._is_gil_enabled(): 4207.
function can be used to check whether the GIL is actually disabled in
the running process.

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.


File: python.info,  Node: The global interpreter lock in free-threaded Python,  Next: Thread safety,  Prev: Identifying free-threaded Python,  Up: Python experimental support for free threading

9.21.3 The global interpreter lock in free-threaded Python
----------------------------------------------------------

Free-threaded builds of CPython support optionally running with the GIL
enabled at runtime using the environment variable *note PYTHON_GIL: 15b.
or the command-line option *note -X gil: 15c.

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.

In addition to individual package documentation, the following websites
track the status of popular packages support for free threading:

   * ‘https://py-free-threading.github.io/tracking/’

   * ‘https://hugovk.github.io/free-threaded-wheels/’


File: python.info,  Node: Thread safety,  Next: Known limitations,  Prev: The global interpreter lock in free-threaded Python,  Up: Python experimental support for free threading

9.21.4 Thread safety
--------------------

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
types like *note dict: 237, *note list: 5dc, and *note set: 5a3. use
internal locks to protect against concurrent modifications in ways that
behave similarly to the GIL. However, Python has not historically
guaranteed specific behavior for concurrent modifications to these
built-in types, so this should be treated as a description of the
current implementation, not a guarantee of current or future behavior.

     注釈: It's recommended to use the *note threading.Lock: 15db. or
     other synchronization primitives instead of relying on the internal
     locks of built-in types, when possible.


File: python.info,  Node: Known limitations,  Prev: Thread safety,  Up: Python experimental support for free threading

9.21.5 Known limitations
------------------------

This section describes known limitations of the free-threaded CPython
build.

* Menu:

* Immortalization::
* Frame objects::
* Iterators::
* Single-threaded performance::


File: python.info,  Node: Immortalization,  Next: Frame objects,  Up: Known limitations

9.21.5.1 Immortalization
........................

The free-threaded build of the 3.13 release makes some objects *note
immortal: 41f8.  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.

An object will be made immortal when a new thread is started for the
first time after the main thread is running.  The following objects are
immortalized:

   * *note function: 279. objects declared at the module level

   * *note method: 1c28. descriptors

   * *note code: 1b4. objects

   * *note module: 15c3. objects and their dictionaries

   * *note classes: 1e6e. (type objects)

Because immortal objects are never deallocated, applications that create
many objects of these types may see increased memory usage.  This is
expected to be addressed in the 3.14 release.

Additionally, numeric and string literals in the code as well as strings
returned by *note sys.intern(): 12a9. are also immortalized.  This
behavior is expected to remain in the 3.14 free-threaded build.


File: python.info,  Node: Frame objects,  Next: Iterators,  Prev: Immortalization,  Up: Known limitations

9.21.5.2 Frame objects
......................

It is not safe to access *note frame: 6ab. objects from other threads
and doing so may cause your program to crash .  This means that *note
sys._current_frames(): 13da. is generally not safe to use in a
free-threaded build.  Functions like *note inspect.currentframe(): 6ad.
and *note sys._getframe(): 6ac. are generally safe as long as the
resulting frame object is not passed to another thread.


File: python.info,  Node: Iterators,  Next: Single-threaded performance,  Prev: Frame objects,  Up: Known limitations

9.21.5.3 Iterators
..................

Sharing the same iterator object between multiple threads is generally
not safe and threads may see duplicate or missing elements when
iterating or crash the interpreter.


File: python.info,  Node: Single-threaded performance,  Prev: Iterators,  Up: Known limitations

9.21.5.4 Single-threaded performance
....................................

The free-threaded build has additional overhead when executing Python
code compared to the default GIL-enabled build.  In 3.13, this overhead
is about 40% on the pyperformance(1) suite.  Programs that spend most of
their time in C extensions or I/O will see less of an impact.  The
largest impact is because the specializing adaptive interpreter ( PEP
659(2)) is disabled in the free-threaded build.  We expect to re-enable
it in a thread-safe way in the 3.14 release.  This overhead is expected
to be reduced in upcoming Python release.  We are aiming for an overhead
of 10% or less on the pyperformance suite compared to the default
GIL-enabled build.

   ---------- Footnotes ----------

   (1) https://pyperformance.readthedocs.io/

   (2) https://peps.python.org/pep-0659/


File: python.info,  Node: C API Extension Support for Free Threading,  Prev: Python experimental support for free threading,  Up: Python HOWTO

9.22 C API Extension Support for Free Threading
===============================================

Starting with the 3.13 release, CPython has experimental support for
running with the *note global interpreter lock: 12e. (GIL) disabled in a
configuration called *note free threading: 433e.  This document
describes how to adapt C API extensions to support free threading.

* Menu:

* Identifying the Free-Threaded Build in C::
* Module Initialization::
* General API Guidelines::
* Borrowed References::
* Memory Allocation APIs::
* Thread State and GIL APIs::
* Protecting Internal Extension State::
* Building Extensions for the Free-Threaded Build::


File: python.info,  Node: Identifying the Free-Threaded Build in C,  Next: Module Initialization,  Up: C API Extension Support for Free Threading

9.22.1 Identifying the Free-Threaded Build in C
-----------------------------------------------

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:

     #ifdef Py_GIL_DISABLED
     /* code that only runs in the free-threaded build */
     #endif


File: python.info,  Node: Module Initialization,  Next: General API Guidelines,  Prev: Identifying the Free-Threaded Build in C,  Up: C API Extension Support for Free Threading

9.22.2 Module Initialization
----------------------------

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.

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.

* Menu:

* Multi-Phase Initialization::
* Single-Phase Initialization::


File: python.info,  Node: Multi-Phase Initialization,  Next: Single-Phase Initialization,  Up: Module Initialization

9.22.2.1 Multi-Phase Initialization
...................................

Extensions that use multi-phase initialization (i.e., *note
PyModuleDef_Init(): 487c.) should add a *note Py_mod_gil: 13e. slot in
the module definition.  If your extension supports older versions of
CPython, you should guard the slot with a *note PY_VERSION_HEX: 722.
check.

     static struct PyModuleDef_Slot module_slots[] = {
         ...
     #if PY_VERSION_HEX >= 0x030D0000
         {Py_mod_gil, Py_MOD_GIL_NOT_USED},
     #endif
         {0, NULL}
     };

     static struct PyModuleDef moduledef = {
         PyModuleDef_HEAD_INIT,
         .m_slots = module_slots,
         ...
     };


File: python.info,  Node: Single-Phase Initialization,  Prev: Multi-Phase Initialization,  Up: Module Initialization

9.22.2.2 Single-Phase Initialization
....................................

Extensions that use single-phase initialization (i.e., *note
PyModule_Create(): 4750.) should call *note PyUnstable_Module_SetGIL():
15f. to indicate that they support running with the GIL disabled.  The
function is only defined in the free-threaded build, so you should guard
the call with ‘#ifdef Py_GIL_DISABLED’ to avoid compilation errors in
the regular build.

     static struct PyModuleDef moduledef = {
         PyModuleDef_HEAD_INIT,
         ...
     };

     PyMODINIT_FUNC
     PyInit_mymodule(void)
     {
         PyObject *m = PyModule_Create(&moduledef);
         if (m == NULL) {
             return NULL;
         }
     #ifdef Py_GIL_DISABLED
         PyUnstable_Module_SetGIL(m, Py_MOD_GIL_NOT_USED);
     #endif
         return m;
     }


File: python.info,  Node: General API Guidelines,  Next: Borrowed References,  Prev: Module Initialization,  Up: C API Extension Support for Free Threading

9.22.3 General API Guidelines
-----------------------------

Most of the C API is thread-safe, but there are some exceptions.

   * 'Struct Fields': Accessing fields in Python C API objects or
     structs directly is not thread-safe if the field may be
     concurrently modified.

   * 'Macros': Accessor macros like *note PyList_GET_ITEM: 47ef. and
     *note PyList_SET_ITEM: 367. do not perform any error checking or
     locking.  These macros are not thread-safe if the container object
     may be modified concurrently.

   * 'Borrowed References': C API functions that return *note borrowed
     references: 317. may not be thread-safe if the containing object is
     modified concurrently.  See the section on *note borrowed
     references: 4ec1. for more information.

* Menu:

* Container Thread Safety::


File: python.info,  Node: Container Thread Safety,  Up: General API Guidelines

9.22.3.1 Container Thread Safety
................................

Containers like *note PyListObject: 49f9, *note PyDictObject: 39b, and
*note PySetObject: 4ae7. perform internal locking in the free-threaded
build.  For example, the *note PyList_Append(): 4864. will lock the list
before appending an item.

* Menu:

* PyDict_Next::


File: python.info,  Node: PyDict_Next,  Up: Container Thread Safety

9.22.3.2 ‘PyDict_Next’
......................

A notable exception is *note PyDict_Next(): 1575, which does not lock
the dictionary.  You should use *note Py_BEGIN_CRITICAL_SECTION: 4adf.
to protect the dictionary while iterating over it if the dictionary may
be concurrently modified:

     Py_BEGIN_CRITICAL_SECTION(dict);
     PyObject *key, *value;
     Py_ssize_t pos = 0;
     while (PyDict_Next(dict, &pos, &key, &value)) {
         ...
     }
     Py_END_CRITICAL_SECTION();


File: python.info,  Node: Borrowed References,  Next: Memory Allocation APIs,  Prev: General API Guidelines,  Up: C API Extension Support for Free Threading

9.22.4 Borrowed References
--------------------------

Some C API functions return *note borrowed references: 317.  These APIs
are not thread-safe if the containing object is modified concurrently.
For example, it's not safe to use *note PyList_GetItem(): 335. if the
list may be modified concurrently.

The following table lists some borrowed reference APIs and their
replacements that return *note strong references: 316.

Borrowed reference API                  Strong reference API
                                        
--------------------------------------------------------------------------------
                                        
*note PyList_GetItem(): 335.            *note PyList_GetItemRef(): 334.
                                        
                                        
*note PyDict_GetItem(): 360.            *note PyDict_GetItemRef(): 313.
                                        
                                        
*note PyDict_GetItemWithError(): 315.   *note PyDict_GetItemRef(): 313.
                                        
                                        
*note PyDict_GetItemString(): 361.      *note PyDict_GetItemStringRef(): 314.
                                        
                                        
*note PyDict_SetDefault(): 319.         *note PyDict_SetDefaultRef(): 318.
                                        
                                        
*note PyDict_Next(): 1575.              none (see *note PyDict_Next: 4ec4.)
                                        
                                        
*note PyWeakref_GetObject(): 352.       *note PyWeakref_GetRef(): 351.
                                        
                                        
*note PyWeakref_GET_OBJECT(): 399.      *note PyWeakref_GetRef(): 351.
                                        
                                        
*note PyImport_AddModule(): 332.        *note PyImport_AddModuleRef(): 331.
                                        

Not all APIs that return borrowed references are problematic.  For
example, *note PyTuple_GetItem(): 4763. is safe because tuples are
immutable.  Similarly, not all uses of the above APIs are problematic.
For example, *note PyDict_GetItem(): 360. is often used for parsing
keyword argument dictionaries in function calls; those keyword argument
dictionaries are effectively private (not accessible by other threads),
so using borrowed references in that context is safe.

Some of these functions were added in Python 3.13.  You can use the
pythoncapi-compat(1) package to provide implementations of these
functions for older Python versions.

   ---------- Footnotes ----------

   (1) https://github.com/python/pythoncapi-compat


File: python.info,  Node: Memory Allocation APIs,  Next: Thread State and GIL APIs,  Prev: Borrowed References,  Up: C API Extension Support for Free Threading

9.22.5 Memory Allocation APIs
-----------------------------

Python's memory management C API provides functions in three different
*note allocation domains: 4c44.: "raw", "mem", and "object".  For
thread-safety, the free-threaded build requires that only Python objects
are allocated using the object domain, and that all Python object are
allocated using that domain.  This differs from the prior Python
versions, where this was only a best practice and not a hard
requirement.

     注釈: Search for uses of *note PyObject_Malloc(): c36. in your
     extension and check that the allocated memory is used for Python
     objects.  Use *note PyMem_Malloc(): c33. to allocate buffers
     instead of *note PyObject_Malloc(): c36.


File: python.info,  Node: Thread State and GIL APIs,  Next: Protecting Internal Extension State,  Prev: Memory Allocation APIs,  Up: C API Extension Support for Free Threading

9.22.6 Thread State and GIL APIs
--------------------------------

Python provides a set of functions and macros to manage thread state and
the GIL, such as:

   * *note PyGILState_Ensure(): 385. and *note PyGILState_Release():
     386.

   * *note PyEval_SaveThread(): 382. and *note PyEval_RestoreThread():
     383.

   * *note Py_BEGIN_ALLOW_THREADS: 4769. and *note Py_END_ALLOW_THREADS:
     a5c.

These functions should still be used in the free-threaded build to
manage thread state even when the *note GIL: 13f. is disabled.  For
example, if you create a thread outside of Python, you must call *note
PyGILState_Ensure(): 385. before calling into the Python API to ensure
that the thread has a valid Python thread state.

You should continue to call *note PyEval_SaveThread(): 382. or *note
Py_BEGIN_ALLOW_THREADS: 4769. around blocking operations, such as I/O or
lock acquisitions, to allow other threads to run the *note cyclic
garbage collector: 1884.


File: python.info,  Node: Protecting Internal Extension State,  Next: Building Extensions for the Free-Threaded Build,  Prev: Thread State and GIL APIs,  Up: C API Extension Support for Free Threading

9.22.7 Protecting Internal Extension State
------------------------------------------

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:

   * '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.

   * '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(1).

   ---------- Footnotes ----------

   (1) https://en.cppreference.com/w/c/language/storage_duration


File: python.info,  Node: Building Extensions for the Free-Threaded Build,  Prev: Protecting Internal Extension State,  Up: C API Extension Support for Free Threading

9.22.8 Building Extensions for the Free-Threaded Build
------------------------------------------------------

C API extensions need to be built specifically for the free-threaded
build.  The wheels, shared libraries, and binaries are indicated by a
‘t’ suffix.

   * pypa/manylinux(1) supports the free-threaded build, with the ‘t’
     suffix, such as ‘python3.13t’.

   * pypa/cibuildwheel(2) supports the free-threaded build if you set
     CIBW_FREE_THREADED_SUPPORT(3).

* Menu:

* Limited C API and Stable ABI::
* Windows: Windows<75>.

   ---------- Footnotes ----------

   (1) https://github.com/pypa/manylinux

   (2) https://github.com/pypa/cibuildwheel

   (3) 
https://cibuildwheel.pypa.io/en/stable/options/#free-threaded-support


File: python.info,  Node: Limited C API and Stable ABI,  Next: Windows<75>,  Up: Building Extensions for the Free-Threaded Build

9.22.8.1 Limited C API and Stable ABI
.....................................

The free-threaded build does not currently support the *note Limited C
API: 36f. or the stable ABI. If you use setuptools(1) to build your
extension and currently set ‘py_limited_api=True’ you can use
‘py_limited_api=not sysconfig.get_config_var("Py_GIL_DISABLED")’ to opt
out of the limited API when building with the free-threaded build.

     注釈: You will need to build separate wheels specifically for the
     free-threaded build.  If you currently use the stable ABI, you can
     continue to build a single wheel for multiple non-free-threaded
     Python versions.

   ---------- Footnotes ----------

   (1) https://setuptools.pypa.io/en/latest/setuptools.html


File: python.info,  Node: Windows<75>,  Prev: Limited C API and Stable ABI,  Up: Building Extensions for the Free-Threaded Build

9.22.8.2 Windows
................

Due to a limitation of the official Windows installer, you will need to
manually define ‘Py_GIL_DISABLED=1’ when building extensions from
source.

参考
....

Porting Extension Modules to Support Free-Threading(1): A
community-maintained porting guide for extension authors.

General:

   * *note Annotations Best Practices: 7a4.

   * *note Argparse チュートリアル: 2bb6.

   * *note デスクリプタ ガイド: 1495.

   * *note 列挙型 HOWTO: 4d55.

   * *note 関数型プログラミング HOWTO: 4d86.

   * *note ipaddressモジュールの紹介: 3acb.

   * *note Logging HOWTO: 4da4.

   * *note Logging クックブック: 11c8.

   * *note 正規表現 HOWTO: 2247.

   * *note ソートのテクニック: 11ab.

   * *note Unicode HOWTO: 1276.

   * *note urllib
     パッケージを使ってインターネット上のリソースを取得するには: 38a5.

Advanced development:

   * *note Python で Curses プログラミング: 2cff.

   * *note Python experimental support for free threading: 4eae.

   * *note C API Extension Support for Free Threading: 4eb0.

   * *note 拡張モジュールを分離する: 4b47.

   * *note The Python 2.3 Method Resolution Order: 144f.

   * *note ソケットプログラミング HOWTO: 32f1.

   * *note timer file descriptor HOWTO: 4ea3.

   * *note Python 3 への拡張モジュール移植: 12af.

Debugging and profiling:

   * *note Debugging C API extensions and CPython Internals with GDB:
     4d47.

   * *note DTrace と SystemTap で CPython を測定する: c3a.

   * *note Python support for the Linux perf profiler: 174.

   ---------- Footnotes ----------

   (1) https://py-free-threading.github.io/porting/


File: python.info,  Node: Python よくある質問,  Next: Deprecations,  Prev: Python HOWTO,  Up: Top

10 Python よくある質問
**********************

* Menu:

* 一般 Python FAQ::
* プログラミング FAQ::
* デザインと歴史 FAQ::
* ライブラリと拡張 FAQ::
* 拡張と埋め込み FAQ::
* Windows 上の Python FAQ::
* グラフィックユーザインターフェース FAQ::
* "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ::


File: python.info,  Node: 一般 Python FAQ,  Next: プログラミング FAQ,  Up: Python よくある質問

10.1 一般 Python FAQ
====================

* Menu:

* 一般情報::
* 現実世界での Python::


File: python.info,  Node: 一般情報,  Next: 現実世界での Python,  Up: 一般 Python FAQ

10.1.1 一般情報
---------------

* Menu:

* Python とは何ですか？::
* Python Software Foundation とは何ですか？::
* Python を使うのに著作権の制限はありますか？::
* そもそも Python は何故創られたのですか？::
* Python は何をするのに向いていますか？::
* Python のバージョン番号の仕組みはどうなっているのですか？::
* Python のソースのコピーはどこで手に入りますか？::
* Python のドキュメントはどこで手に入りますか？::
* プログラミングをしたことがないのですが、Python のチュートリアルはありますか？::
* Python のためのニュースグループやメーリングリストはありますか？::
* Python のベータテスト版はどこで手に入りますか？::
* Python のバグ報告やパッチを上げるにはどうしたら良いですか？::
* Python について発行された記事を何か参照できますか？::
* Python の本はありますか？::
* www.python.org は世界のどこにあるのですか？: www python org は世界のどこにあるのですか？.
* なぜ Python という名前なのですか？::
* 『空飛ぶモンティ・パイソン』を好きでなくてはいけませんか？::


File: python.info,  Node: Python とは何ですか？,  Next: Python Software Foundation とは何ですか？,  Up: 一般情報

10.1.1.1 Python とは何ですか？
..............................

Python は、インタプリタ形式の、対話的な、オブジェクト指向プログラミング
言語です。この言語には、モジュール、例外、動的な型付け、超高水準の動的な
データ型、およびクラスが取り入れられています。 Pythonは、オブジェクト指
向プログラミングを越えて、手続き型プログラミングや関数型プログラミングな
ど複数のプログラミングパラダイムをサポートしています。 Python は驚くべき
パワーと非常に分かりやすい文法を持ち合わせています。そして、多くのシステ
ムコールやライブラリへだけでなく、様々なウィンドウシステムへのインターフ
ェースがあり、C や C++ で拡張することもできます。また、プログラム可能な
インターフェースが必要なアプリケーションのための拡張言語としても利用でき
ます。最後に、Python はポータブルです。Linux や macOS を含む多くの Unix
の派生システムで動き、Windows でも動きます。

さらに知りたければ、 *note Python チュートリアル: 1b45. から始めましょう
。他にも、 Beginner's Guide to Python(1) から、Python 学習のための入門用
チュートリアルやリソースを参照できます。

   ---------- Footnotes ----------

   (1) https://wiki.python.org/moin/BeginnersGuide


File: python.info,  Node: Python Software Foundation とは何ですか？,  Next: Python を使うのに著作権の制限はありますか？,  Prev: Python とは何ですか？,  Up: 一般情報

10.1.1.2 Python Software Foundation とは何ですか？
..................................................

Python Software Foundation は、Python バージョン 2.1 以降の著作権を保持
する独立の非営利組織です。PSF の任務は、Python プログラミング言語に関す
るオープンソース技術を進め、Python の使用を広めることです。PSF のホーム
ページが ‘https://www.python.org/psf/’ にあります。

PSF への寄付は米国で免税されています。Python を利用して役立ったと感じた
ら、the PSF donation page(1) で貢献をお願いします。

   ---------- Footnotes ----------

   (1) https://www.python.org/psf/donations/


File: python.info,  Node: Python を使うのに著作権の制限はありますか？,  Next: そもそも Python は何故創られたのですか？,  Prev: Python Software Foundation とは何ですか？,  Up: 一般情報

10.1.1.3 Python を使うのに著作権の制限はありますか？
....................................................

あなたが作成する Python に関するドキュメントのすべてに著作権を残し、それ
らの著作権を表示する限り、ソースコードをどのように扱ってもかまいません。
この著作権規則を尊重する限り、商用に Python を利用しても、ソースあるいは
バイナリ形式で(変更の有無にかかわらず) Python のコピーを販売しても、
Python が何らかの形で組み込まれた製品を販売してかまいません。もちろん、
Python のあらゆる商業用途についても同様です。

PSF License のより詳しい説明と全文へのリンクは the license page(1) を参
照してください。

Python のロゴは商標登録されていて、使用に許可が必要な場合があります。詳
しい情報は the Trademark Usage Policy(2) を参照してください。

   ---------- Footnotes ----------

   (1) https://docs.python.org/3/license.html

   (2) https://www.python.org/psf/trademarks/


File: python.info,  Node: そもそも Python は何故創られたのですか？,  Next: Python は何をするのに向いていますか？,  Prev: Python を使うのに著作権の制限はありますか？,  Up: 一般情報

10.1.1.4 そもそも Python は何故創られたのですか？
.................................................

Guido van Rossum によると、すべての始まりについての '非常に' 簡潔な概要
は以下のとおりです:

     私は CWI の ABC グループでインタプリタ言語を実装する幅広い経験をし
     ていて、そこで共に働くことで言語設計に関して大いに学びました。これ
     は文のグループ化にインデントを使用することや超高水準のデータ型の包
     含など、(詳細は Python とは全く異なりますが) Python の多くの特徴の
     もととなっています。

     私は ABC 言語に対して多くの不満を持っていましたが、同時に特徴の多く
     が好きでもありました。ABC 言語 (やその実装)を拡張して私の不満を解消
     することは不可能でした (実際、拡張性の欠如は大きな問題だったのです
     )。私は Modula-2+ を使用することでいくらかの経験を積み、Modula-3 の
     デザイナーと話して Modula-3 のレポートを読みました。Modula-3 は例外
     処理に使う構文や語義、その他いくつかの Python の特徴の起源です。

     私は CWI で Amoeba 分散オペレーティングシステムのグループで働いてい
     ました。Amoeba のシステムコールインターフェースには Bourne シェルか
     らアクセスしにくかったので、C プログラムや Bourne シェルスクリプト
     を書くよりも良いシステム管理の方法が必要でした。Amoeba のエラー処理
     の経験から、プログラミング言語の機能としての例外の重要さを強く意識
     するようになりました。

     ABC のような構文と Amoeba のようなシステムコールを合わせ持ったスク
     リプト言語が必要だろうと思いつきました。Amoeba 専用の言語を書くのは
     愚かであるだろうと気づき、一般に拡張できるような言語を求めることに
     決めました。

     1989 年のクリスマス休暇の間、自由な時間がたくさんできたので、その言
     語を実際に作ってみることにしました。翌年の間、勤務時間以外はほとん
     どその開発に費やし、Python は Amoeba プロジェクトのなかで成果を重ね
     、同僚からのフィードバックは私の開発を大いに加速させてくれました。

     1991 年 2 月、1 年間と少しの開発を経て、USENET に投稿することにしま
     した。それは ‘Misc/HISTORY’ ファイルに残っています。


File: python.info,  Node: Python は何をするのに向いていますか？,  Next: Python のバージョン番号の仕組みはどうなっているのですか？,  Prev: そもそも Python は何故創られたのですか？,  Up: 一般情報

10.1.1.5 Python は何をするのに向いていますか？
..............................................

Python は、多岐にわたる問題に適用できる高水準な汎用プログラム言語です。

この言語は、文字列処理(正規表現、Unicode、ファイル間の差分の計算)、イン
ターネットプロトコル(HTTP、FTP、SMTP、XML-RPC、POP、IMAP)、ソフトウェア
エンジニアリング(Python コードのユニットテスト、ロギング、プロファイリン
グ、解析)、オペレーティングシステムインターフェース(システムコール、ファ
イルシステム、 TCP/IP ソケット) のような領域をカバーする大規模な標準ライ
ブラリから成り立っています。何ができるかを知るには *note Python
標準ライブラリ: 12a. の一覧を参照してください。また、様々なサードパーテ
ィの拡張も使えます。 the Python Package Index(1) から興味のあるパッケー
ジを探してみましょう。

   ---------- Footnotes ----------

   (1) https://pypi.org


File: python.info,  Node: Python のバージョン番号の仕組みはどうなっているのですか？,  Next: Python のソースのコピーはどこで手に入りますか？,  Prev: Python は何をするのに向いていますか？,  Up: 一般情報

10.1.1.6 Python のバージョン番号の仕組みはどうなっているのですか？
..................................................................

Python のバージョン番号は "A.B.C" または "A.B" が付けられます :

   * 'A' はメジャーバージョン番号です - 言語に本当に大きな変更があった場
     合に増やされます。

   * 'B' はマイナーバージョン番号です - 驚きの少ない変更があった場合に増
     やされます。

   * 'C' はマイクロバージョン番号です - バグフィックスリリースごとに増や
     されます。

すべてのリリースがバグフィックスリリースであるというわけではありません。
フィーチャーリリースへの準備段階では、一連の開発リリースが作られ、アルフ
ァ版、ベータ版、またはリリース候補と名付けられます。アルファ版はインター
フェースが確定されないうちにリリースされる早期リリースで、２つのアルファ
リリース間でインターフェースが変わるかもしれません。ベータ版はもっと安定
していて、現存のインターフェースは保存されますが新しいモジュールが追加さ
れるかもしれません。リリース候補は固まったもので、致命的なバグを直すので
なければ変更されません。

アルファ、ベータとリリース候補のバージョンは、追加の接尾辞を持ちます:

   * アルファバージョンの接尾辞は、ある小さな数 'N' に対して "aN "となり
     ます。

   * ベータバージョンの接尾辞は、ある小さな数 'N' に対して "bN" となりま
     す。

   * リリース候補バージョンの接尾辞は、ある小さな数 'N' に対して "rcN" と
     なります。

つまり、 '2.0aN' と付けられたバージョンはすべて '2.0bN' に先立ち、
'2.0bN' は '2.0rcN' に先立ち、そして 'これら' は 2.0 に先立ちます。

また、"2.2+" のように "+" 接尾語が付いたバージョン番号もあります。これは
未発表のバージョンで、 CPython 開発リポジトリから直接ビルドされています
。実際、最後のマイナーリリースが行われた後、バージョンは "2.4a0" のよう
に "a0" がつく次のマイナーバージョンになります。

開発サイクルの詳細は Developer's Guide(1) を、 Python の後方互換性ポリシ
ーについては PEP 387(2) を参照してください。 ドキュメント *note
sys.version: 15e. 、 *note sys.hexversion: 4202. 、 *note
sys.version_info: 66c. も参照してください。

   ---------- Footnotes ----------

   (1) https://devguide.python.org/developer-workflow/development-cycle/

   (2) https://peps.python.org/pep-0387/


File: python.info,  Node: Python のソースのコピーはどこで手に入りますか？,  Next: Python のドキュメントはどこで手に入りますか？,  Prev: Python のバージョン番号の仕組みはどうなっているのですか？,  Up: 一般情報

10.1.1.7 Python のソースのコピーはどこで手に入りますか？
........................................................

最新の Python ソースは python.org (‘https://www.python.org/downloads/’)
からいつでも手に入れることができます。最新の開発版ソースは
‘https://github.com/python/cpython/’ にアクセスして手に入れることができ
ます。

ソースは gzip された tar ファイルで配布され、完全な C のソース、Sphinx に
よりフォーマットされたドキュメント、Python ライブラリモジュール、サンプ
ルプログラム、そしていくつかの役立つ配布自由なソフトウェアを含んでいます
。このソースはほとんどの UNIX プラットフォームでそのままコンパイルして動
かせます。

ソースコードの入手とコンパイルについて、より詳しい情報は Getting Started
section of the Python Developer's Guide(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://devguide.python.org/setup/


File: python.info,  Node: Python のドキュメントはどこで手に入りますか？,  Next: プログラミングをしたことがないのですが、Python のチュートリアルはありますか？,  Prev: Python のソースのコピーはどこで手に入りますか？,  Up: 一般情報

10.1.1.8 Python のドキュメントはどこで手に入りますか？
......................................................

Python の現行の安定バージョンの標準ドキュメントは
‘https://docs.python.org/3/’ から利用できます。また、PDF、プレーンテキス
ト、ダウンロードできる HTML 版も
‘https://docs.python.org/3/download.html’ から利用できます。

このドキュメントは reStructuredText で書かれ、the Sphinx documentation
tool(1) で構成されました。このドキュメントに使われた reStructuredText の
ソースは Python のソース配布に含まれます。

   ---------- Footnotes ----------

   (1) https://www.sphinx-doc.org/


File: python.info,  Node: プログラミングをしたことがないのですが、Python のチュートリアルはありますか？,  Next: Python のためのニュースグループやメーリングリストはありますか？,  Prev: Python のドキュメントはどこで手に入りますか？,  Up: 一般情報

10.1.1.9 プログラミングをしたことがないのですが、Python のチュートリアルはありますか？
......................................................................................

膨大な量の役に立つチュートリアルや書籍があります。標準のドキュメントには
*note Python チュートリアル: 1b45. などがあります。

Python プログラム初心者のための情報のチュートリアルのリストは the
Beginner's Guide(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://wiki.python.org/moin/BeginnersGuide


File: python.info,  Node: Python のためのニュースグループやメーリングリストはありますか？,  Next: Python のベータテスト版はどこで手に入りますか？,  Prev: プログラミングをしたことがないのですが、Python のチュートリアルはありますか？,  Up: 一般情報

10.1.1.10 Python のためのニュースグループやメーリングリストはありますか？
.........................................................................

ニュースグループ ‘comp.lang.python’ やメーリングリスト python-list(1) が
あります。ニュースグループとメーリングリストは互いに接続されていて、ニュ
ースを購読すればメーリングリストに参加する必要はありません。
‘comp.lang.python’ は一日に数百のポスティングを受ける高いトラフィックで
、USENET 読者は多くの場合、このボリュームに応えることができます。

新しいソフトウェアリリースとイベントの告知は comp.lang.python.announce で
見つけられます。これは一日に 5 ポスティング程度を受ける低トラフィックの
手頃なメーリングリストです。the python-announce mailing list(2) から利用
可能です。

その他のメーリングリストやニュースグループについての詳しい情報は
‘https://www.python.org/community/lists/’ にあります。

   ---------- Footnotes ----------

   (1) https://mail.python.org/mailman/listinfo/python-list

   (2) 
https://mail.python.org/mailman3/lists/python-announce-list.python.org/


File: python.info,  Node: Python のベータテスト版はどこで手に入りますか？,  Next: Python のバグ報告やパッチを上げるにはどうしたら良いですか？,  Prev: Python のためのニュースグループやメーリングリストはありますか？,  Up: 一般情報

10.1.1.11 Python のベータテスト版はどこで手に入りますか？
.........................................................

アルファ/ベータリリースは ‘https://www.python.org/downloads/’ で手に入り
ます。リリースはすべて comp.lang.python や comp.lang.python.announce の
ニュースグループと Python ホームページ ‘https://www.python.org/’ で告知
され、RSS ニュースフィードが利用できます。

Git から開発版を手に入れることもできます。詳細は The Python Developer's
guide(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://devguide.python.org/


File: python.info,  Node: Python のバグ報告やパッチを上げるにはどうしたら良いですか？,  Next: Python について発行された記事を何か参照できますか？,  Prev: Python のベータテスト版はどこで手に入りますか？,  Up: 一般情報

10.1.1.12 Python のバグ報告やパッチを上げるにはどうしたら良いですか？
.....................................................................

バグの報告やパッチの提出には、issue tracker
‘https://github.com/python/CPython/issues’ をご利用ください。

Python 開発の工程について、詳しくは the Python Developer's Guide(1) を参
照してください。

   ---------- Footnotes ----------

   (1) https://devguide.python.org/


File: python.info,  Node: Python について発行された記事を何か参照できますか？,  Next: Python の本はありますか？,  Prev: Python のバグ報告やパッチを上げるにはどうしたら良いですか？,  Up: 一般情報

10.1.1.13 Python について発行された記事を何か参照できますか？
.............................................................

Python に関するあなたの愛読書を引用するのが一番でしょう。

Python に関する 一番初めの記事(1) はとても古く、1991年に書かれています。

     Guido van Rossum and Jelke de Boer, "Interactively Testing Remote
     Servers Using the Python Programming Language", CWI Quarterly,
     Volume 4, Issue 4 (December 1991), Amsterdam, pp 283-303.

   ---------- Footnotes ----------

   (1) https://ir.cwi.nl/pub/18204


File: python.info,  Node: Python の本はありますか？,  Next: www python org は世界のどこにあるのですか？,  Prev: Python について発行された記事を何か参照できますか？,  Up: 一般情報

10.1.1.14 Python の本はありますか？
...................................

はい、たくさんあり、そのほとんどは現在も出版されています。リストは
python.org wiki ‘https://wiki.python.org/moin/PythonBooks’ にあります。

また、オンライン書店で "Python" で検索し、Monty Python をフィルタで除外
してもいいです (または、"Python" と "言語" で検索してください)。


File: python.info,  Node: www python org は世界のどこにあるのですか？,  Next: なぜ Python という名前なのですか？,  Prev: Python の本はありますか？,  Up: 一般情報

10.1.1.15 www.python.org は世界のどこにあるのですか？
.....................................................

Pythonプロジェクトのインフラは世界中にあり、Pythonインフラストラクチャチ
ームによって管理されています。詳細は こちら(1).

   ---------- Footnotes ----------

   (1) https://infra.psf.io


File: python.info,  Node: なぜ Python という名前なのですか？,  Next: 『空飛ぶモンティ・パイソン』を好きでなくてはいけませんか？,  Prev: www python org は世界のどこにあるのですか？,  Up: 一般情報

10.1.1.16 なぜ Python という名前なのですか？
............................................

Python の開発が始まった頃、Guido van Rossum は 1970 年代に始まった BBC の
コメディシリーズ "Monty Python's Flying Circus"(1) の台本を読んでいまし
た。Van Rossum は、短くて、ユニークで、少しミステリアスな名前が欲しかっ
たので、この言語の名前を Python と呼ぶことにしたのです。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/Monty_Python


File: python.info,  Node: 『空飛ぶモンティ・パイソン』を好きでなくてはいけませんか？,  Prev: なぜ Python という名前なのですか？,  Up: 一般情報

10.1.1.17 『空飛ぶモンティ・パイソン』を好きでなくてはいけませんか？
....................................................................

いいえ。でも、好きになってくれるといいな。: ）


File: python.info,  Node: 現実世界での Python,  Prev: 一般情報,  Up: 一般 Python FAQ

10.1.2 現実世界での Python
--------------------------

* Menu:

* Python はどれくらい安定していますか？::
* どれくらいの人が Python を使っていますか？::
* Python で行われた大きなプロジェクトはありますか？::
* 将来 Python にどのような新しい開発が期待されますか？::
* Python の互換性を無くすような提案をしてもいいのですか？::
* Python は初心者プログラマに向いている言語ですか？::


File: python.info,  Node: Python はどれくらい安定していますか？,  Next: どれくらいの人が Python を使っていますか？,  Up: 現実世界での Python

10.1.2.1 Python はどれくらい安定していますか？
..............................................

とても安定しています。1991 年以来新しい安定リリースはおよそ 6 から 18 ヶ
月毎に出されていて、このペースが続きそうです。バージョン3.9の時点では、
Pythonは12ヶ月に一度のペースで新しいフィーチャーリリースを行っています (
PEP 602(1)) 。

開発者が旧バージョンのバグフィックスリリースを公開するので、既存リリース
の安定性は徐々に向上していきます。バグフィックスリリースは、バージョン番
号の 3 番目の要素によって示され(例: 3.5.3、3.6.2)、安定性のために管理さ
れています。バグフィックスリリースには既知の問題への修正だけが含まれ、一
連のバグフィックスリリースを通じて同じインターフェースが保たれることが保
証されているのです。

The latest stable releases can always be found on the Python download
page(2).  Python 3.x is the recommended version and supported by most
widely used libraries.  Python 2.x is not maintained anymore(3).

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0602/

   (2) https://www.python.org/downloads/

   (3) https://peps.python.org/pep-0373/


File: python.info,  Node: どれくらいの人が Python を使っていますか？,  Next: Python で行われた大きなプロジェクトはありますか？,  Prev: Python はどれくらい安定していますか？,  Up: 現実世界での Python

10.1.2.2 どれくらいの人が Python を使っていますか？
...................................................

正確な人数を調べるのは難しいですが、おそらく何百万人ものユーザーがいるで
しょう。

Python は自由にダウンロード可能なので、売上高がなく、多数のサイトから利
用でき、多くの Linux ディストーションに同梱されているので、ダウンロード
統計から全体の状況を知ることはできません。

comp.lang.python ニュースグループはとても活発ですが、すべての Python ユ
ーザーが投稿するわけではなく、読みすらしない人もいます。


File: python.info,  Node: Python で行われた大きなプロジェクトはありますか？,  Next: 将来 Python にどのような新しい開発が期待されますか？,  Prev: どれくらいの人が Python を使っていますか？,  Up: 現実世界での Python

10.1.2.3 Python で行われた大きなプロジェクトはありますか？
..........................................................

Python を利用しているプロジェクトのリストは
‘https://www.python.org/about/success’ を参照してください。past Python
conferences(1) から議事録を参照すると、多くの会社や組織の貢献がわかるで
しょう。

注目されている Python のプロジェクトは the Mailman mailing list
manager(2) や the Zope application server(3) などです。Red Hat(4) をはじ
めとするいくつかの Linux ディストーションのインストーラやシステムアドミ
ニストレーションソフトウェアは、一部や全部が Python で書かれています。内
部で Python を利用している企業には、Google、Yahoo、Lucasfilm Ltd.  など
があります。

   ---------- Footnotes ----------

   (1) https://www.python.org/community/workshops/

   (2) https://www.list.org

   (3) https://www.zope.dev

   (4) https://www.redhat.com


File: python.info,  Node: 将来 Python にどのような新しい開発が期待されますか？,  Next: Python の互換性を無くすような提案をしてもいいのですか？,  Prev: Python で行われた大きなプロジェクトはありますか？,  Up: 現実世界での Python

10.1.2.4 将来 Python にどのような新しい開発が期待されますか？
.............................................................

Python Enhancement Proposals (PEP) ‘https://peps.python.org/’ を参照して
ください。PEP は Python に提案された新機能について書かれた設計書で、簡潔
な技術仕様と原理が提供されています。"Python X.Y Release Schedule" (X.Y は
まだリリースされていないバージョン) を探してください。

新しい開発については the python-dev mailing list(1) で議論されています。

   ---------- Footnotes ----------

   (1) https://mail.python.org/mailman3/lists/python-dev.python.org/


File: python.info,  Node: Python の互換性を無くすような提案をしてもいいのですか？,  Next: Python は初心者プログラマに向いている言語ですか？,  Prev: 将来 Python にどのような新しい開発が期待されますか？,  Up: 現実世界での Python

10.1.2.5 Python の互換性を無くすような提案をしてもいいのですか？
................................................................

一般的には、してはいけません。世界中にすでに何百万行もの Python コードが
あるので、既存のプログラムのどんなに僅かな部分でも無効にしてしまうような
言語仕様の変更も認められてはなりません。コンバートするプログラムが出来て
さえ、すべてのドキュメントをアップデートしなければならないという問題があ
ります。 Python に関する多くの本が出版されているので、それらを一発で不適
切にするようなことはしたくないです。

仕様を変えなければならないのなら、緩やかなアップグレード計画が組まれなく
てはなりません。 PEP 5(1) で、ユーザーの受ける分裂を最小限にしながら後方
互換性のない変更を行うために従うべき手順について説明しています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0005/


File: python.info,  Node: Python は初心者プログラマに向いている言語ですか？,  Prev: Python の互換性を無くすような提案をしてもいいのですか？,  Up: 現実世界での Python

10.1.2.6 Python は初心者プログラマに向いている言語ですか？
..........................................................

はい。

未だにプログラミング初学者にとって一般的なのは、Pascal、C、C++ のサブセ
ット、 Java など、手続き型の静的型付けの言語です。生徒にとっては、第一の
言語として Python を学ぶのが役に立つでしょう。Python には非常に簡潔で一
貫した構文と大きな標準ライブラリがあります。そして一番重要なことに、初心
者プログラミングのコースで Python を学ぶことで、生徒は問題の分析やデータ
型の設計など、重要なプログラミングスキルに集中することができるのです。
Python なら、生徒はループや手続きなどの基本概念をすぐに取り入れられます
。最初の課程でいきなりユーザ定義のオブジェクトを操ることさえできるでしょ
う。

プログラミングをしたことがない初心者にとって、静的型付け言語を使うのは不
自然に思われます。習得すべき内容はより複雑になり、学習のペースが遅くなっ
てしまいます。生徒は、コンピュータのように思考し、問題を分析し、一貫した
インターフェースを設計して、データをカプセル化することを学ぶことになりま
す。長期的に見れば静的型付け言語を学ぶことは重要ですが、それが最初のプロ
グラミングの授業で学ぶべき最高の話題とは限りません。

Python の良いところは他にもたくさんあります。Python には、Java のように
大きな標準ライブラリがあり、生徒が何かを 'する' 段階で非常に早くプログラ
ミングプロジェクトに参加できるようになります。宿題は標準の四則演算機や平
均を求めるプログラムに限定されません。標準ライブラリを使用することで、生
徒はプログラミングの原理を学びながら現実的なアプリケーションに取り組む満
足感を得ることができます。また、標準ライブラリの使用からコードの再利用を
学ぶことができます。 PyGame などのサードパーティモジュールもまた手が届く
範囲を広げるのに役立ちます。

Python のインタラクティブインタプリタによって、プログラミングをしながら
、言語機能を確認することができます。別のウィンドウでプログラムのソースに
入っている間、ウィンドウでインタプリタを起動させたままにしておくことがで
きます。リストのメソッドを思い出せないときは、例えばこのようにできます:

     >>> L = []
     >>> dir(L)
     ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
     '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
     '__getattribute__', '__getitem__', '__gt__', '__hash__', '__iadd__',
     '__imul__', '__init__', '__iter__', '__le__', '__len__', '__lt__',
     '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__',
     '__repr__', '__reversed__', '__rmul__', '__setattr__', '__setitem__',
     '__sizeof__', '__str__', '__subclasshook__', 'append', 'clear',
     'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
     'reverse', 'sort']
     >>> [d for d in dir(L) if '__' not in d]
     ['append', 'clear', 'copy', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']

     >>> help(L.append)
     Help on built-in function append:

     append(...)
         L.append(object) -> None -- append object to end

     >>> L.append(1)
     >>> L
     [1]

インタプリタがあれば、プログラミングをしている間にドキュメントは生徒のそ
ばを離れません。

Python のための良い IDE もあります。IDLE は Python で Tkinter を使って書
かれたクロスプラットフォーム IDE です。Emacs には、ユーザにとって幸運な
ことに、素晴らしい Python モードがあります。これらすべてのプログラミング
環境から、シンタックスハイライト、オートインデント、コーディング中のイン
タラクティブインタプリタへのアクセスが使えます。the Python wiki(1) から
Python 編集環境の一覧を参照してください。

Python の教育における利用についての議論がしたいなら、the edu-sig mailing
list(2) に参加するとよいでしょう。

   ---------- Footnotes ----------

   (1) https://wiki.python.org/moin/PythonEditors

   (2) https://www.python.org/community/sigs/current/edu-sig


File: python.info,  Node: プログラミング FAQ,  Next: デザインと歴史 FAQ,  Prev: 一般 Python FAQ,  Up: Python よくある質問

10.2 プログラミング FAQ
=======================

* Menu:

* 一般的な質問::
* コア言語::
* 数と文字列::
* 性能: 性能<4>.
* シーケンス(タプル/リスト): シーケンス タプル/リスト.
* オブジェクト::
* モジュール: モジュール<5>.


File: python.info,  Node: 一般的な質問,  Next: コア言語,  Up: プログラミング FAQ

10.2.1 一般的な質問
-------------------

* Menu:

* ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？::
* バグの発見や静的解析に役立つツールはありますか？::
* どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？::
* Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？::


File: python.info,  Node: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？,  Next: バグの発見や静的解析に役立つツールはありますか？,  Up: 一般的な質問

10.2.1.1 ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？
...................................................................................................

はい。

Python 用のデバッガについては次に解説してあり、組み込みの *note
breakpoint(): 215. 関数でそれらのデバッガに処理を移せます。

pdb モジュールは簡素にして十分な Python のコンソールモードデバッガです。
これは Python の標準ライブラリに含まれているもので、 *note
ライブラリリファレンスマニュアルにドキュメントがあります: 94. 。 pdb の
コードを手本にして自分用のデバッガを書くこともできます。

Python に同梱されている統合開発環境の IDLE は通常の Python の配布形態の
一部 (普通は Tools/scripts/idle3(1) から利用可能) であり、グラフィカルな
デバッガを含んでいます。

PythonWin は、pdb をベースとした GUI デバッガを含む Python IDE です。
Pythonwin デバッガは、ブレークポイントの色付けや非 PythonWin プログラム
のデバッグなどの素敵な機能をたくさん持っています。PythonWin は
pywin32(2) プロジェクトの一部、あるいは ActivePython(3) ディストリビュー
ションの一部として利用可能です。

Eric(4) は PyQt や Scintilla editing component をもとにした IDE です。

trepan3k(5) は gdbライクなデバッガです。

Visual Studio Code(6) はバージョン管理ソフトと一緒になったデバッグツール
を備えた IDE です

商業のグラフィカルデバッガ付き Python IDE もあります。例えば:

   * Wing IDE(7)

   * Komodo IDE(8)

   * PyCharm(9)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/blob/main/Tools/scripts/idle3

   (2) https://github.com/mhammond/pywin32

   (3) https://www.activestate.com/products/python/

   (4) https://eric-ide.python-projects.org/

   (5) https://github.com/rocky/python3-trepan/

   (6) https://code.visualstudio.com/

   (7) https://wingware.com/

   (8) https://www.activestate.com/products/komodo-ide/

   (9) https://www.jetbrains.com/pycharm/


File: python.info,  Node: バグの発見や静的解析に役立つツールはありますか？,  Next: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？,  Prev: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？,  Up: 一般的な質問

10.2.1.2 バグの発見や静的解析に役立つツールはありますか？
.........................................................

はい。

Pylint(1) と Pyflakes(2) は、バグの早期発見に役立つ基本的なチェックを行
います。

Mypy(3), Pyre(4), Pytype(5) などの静的型チェッカーは、 Python ソースコー
ドにある型ヒントをチェックできます。

   ---------- Footnotes ----------

   (1) https://pylint.pycqa.org/en/latest/index.html

   (2) https://github.com/PyCQA/pyflakes

   (3) https://mypy-lang.org/

   (4) https://pyre-check.org/

   (5) https://github.com/google/pytype


File: python.info,  Node: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？,  Next: Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？,  Prev: バグの発見や静的解析に役立つツールはありますか？,  Up: 一般的な質問

10.2.1.3 どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？
.............................................................................

ユーザがダウンロードでき、Python ディストリビューションをインストールせ
ずに実行できるようなスタンドアロンプログラムだけでいいなら、Python を C
コードにコンパイルできなくても構いません。プログラムに対して必要なモジュ
ールを選び、そのモジュールを Python バイナリに束縛して一つの実行可能ファ
イルにまとめる多くのツールがあります。

一つは freeze ツールで、Python ソースツリーに Tools/freeze(1) として含ま
れています。これは Python バイトコードを C 配列に変換します。すべてのモ
ジュールを新しいプログラムに埋め込む C コンパイラで、そのプログラムは
Python モジュールにリンクされます。

これはあなたのソースの (両方の形式の) import 文を再帰的にスキャンし、
import されたモジュールを標準の Python パスと (組み込みモジュールのある)
ソースディレクトリから探します。そして Python で書かれたモジュールのバイ
トコードを C コード (marshal モジュールでコードオブジェクトに変換できる
配列) に変換し、実際にそのプログラム内で使われている組み込みモジュールだ
けが含まれたカスタムメイドの設定ファイルを作成します。そして生成された C
コードをコンパイルして Python インタプリタの残りとリンクし、元のスクリプ
トと全く同じように動作する自己完結的なバイナリを形成します。

以下のパッケージはコンソールやGUIの実行ファイル作成に役立ちます。

   * Nuitka(2) (Cross-platform)

   * PyInstaller(3) (Cross-platform)

   * PyOxidizer(4) (Cross-platform)

   * cx_Freeze(5) (Cross-platform)

   * py2app(6) (macOS only)

   * py2exe(7) (Windows only)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/main/Tools/freeze

   (2) https://nuitka.net/

   (3) https://pyinstaller.org/

   (4) https://pyoxidizer.readthedocs.io/en/stable/

   (5) https://marcelotduarte.github.io/cx_Freeze/

   (6) https://github.com/ronaldoussoren/py2app

   (7) https://www.py2exe.org/


File: python.info,  Node: Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？,  Prev: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？,  Up: 一般的な質問

10.2.1.4 Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？
........................................................................................

はい。標準ライブラリモジュールに求められるコーディングスタイルは PEP
8(1) として文書化されています。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0008/


File: python.info,  Node: コア言語,  Next: 数と文字列,  Prev: 一般的な質問,  Up: プログラミング FAQ

10.2.2 コア言語
---------------

* Menu:

* なぜ変数に値があるのに UnboundLocalError が出るのですか？::
* Python のローカルとグローバル変数のルールは何ですか？::
* ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか？::
* グローバル変数をモジュール間で共有するにはどうしたらいいですか？::
* モジュールで import を使う際の「ベストプラクティス」は何ですか？::
* なぜオブジェクト間でデフォルト値が共有されるのですか？::
* オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？::
* 実引数と仮引数の違いは何ですか?::
* なぜ list 'y' を変更すると list 'x' も変更されるのですか?::
* 出力引数のある関数 (参照渡し) はどのように書きますか？: 出力引数のある関数 参照渡し はどのように書きますか？.
* Python で高次関数はどのようにつくりますか？::
* Python のオブジェクトはどのようにコピーしますか？::
* オブジェクトのメソッドや属性はどのように見つけますか？::
* コードはどのようにオブジェクトの名前を見つけるのですか？::
* カンマ演算子はなぜ優先されるのですか？::
* C の "?;" 三項演算子と等価なものはありますか？: C の "? " 三項演算子と等価なものはありますか？.
* Python で解し難いワンライナーを書くことはできますか？::
* 関数の引数リストにあるスラッシュ (/) は何を意味しますか？: 関数の引数リストにあるスラッシュ / は何を意味しますか？.


File: python.info,  Node: なぜ変数に値があるのに UnboundLocalError が出るのですか？,  Next: Python のローカルとグローバル変数のルールは何ですか？,  Up: コア言語

10.2.2.1 なぜ変数に値があるのに UnboundLocalError が出るのですか？
..................................................................

もともと動いていたコードが、関数の本体のどこかに代入文を加えるという変更
をしたら *note UnboundLocalError: 14df. を出すのには驚くかもしれません。

このコード:

     >>> x = 10
     >>> def bar():
     ...     print(x)
     ...
     >>> bar()
     10

は動きますが、このコード:

     >>> x = 10
     >>> def foo():
     ...     print(x)
     ...     x += 1

は ‘UnboundLocalError’ になります:

     >>> foo()
     Traceback (most recent call last):
       ...
     UnboundLocalError: local variable 'x' referenced before assignment

これは、あるスコープの中で変数に代入を行うとき、その変数はそのスコープに
対してローカルになり、外のスコープにある同じ名前の変数を隠すからです。
foo の最後の文が ‘x’ に新しい値を代入しているので、コンパイラはこれをロ
ーカル変数であると認識します。その結果、先の ‘print(x)’ が初期化されてい
ないローカル変数を表示しようとして結果はエラーとなります。

上の例では、グローバルであると宣言することで外のスコープにアクセスできま
す:

     >>> x = 10
     >>> def foobar():
     ...     global x
     ...     print(x)
     ...     x += 1
     ...
     >>> foobar()
     10

この明示的な宣言は (表面的には似ているクラスとインスタンス変数の例とは違
って) あなたは実際は他のスコープの変数の値を変えようとしているのだ、とい
うことを知らせるのに必要です:

     >>> print(x)
     11

同様のことを、ネストされたスコープで *note nonlocal: 1279. 予約語を使う
ことでもできます:

     >>> def foo():
     ...    x = 10
     ...    def bar():
     ...        nonlocal x
     ...        print(x)
     ...        x += 1
     ...    bar()
     ...    print(x)
     ...
     >>> foo()
     10
     11


File: python.info,  Node: Python のローカルとグローバル変数のルールは何ですか？,  Next: ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか？,  Prev: なぜ変数に値があるのに UnboundLocalError が出るのですか？,  Up: コア言語

10.2.2.2 Python のローカルとグローバル変数のルールは何ですか？
..............................................................

Python では、関数内で参照されるだけの変数は暗黙的にグローバルとなります
。 関数の本体のどこかで値が変数に代入されたなら、それは明示的にグローバ
ルであると宣言されない限り、ローカルであるとみなされます。

最初はちょっと驚くでしょうが、少し考えると納得できます。一方では、代入さ
れた変数に *note global: 16f. を要求することで、意図しない副作用を防げま
す。他方では、グローバルな参照の度に ‘global’ が要求されてしまうと、
‘global’ を使ってばかりになってしまいます。ビルトイン関数やインポートさ
れたモジュールの内容を参照するたびにグローバル宣言をしなければならないの
です。その乱雑さは副作用を特定するための ‘global’ 宣言の便利さよりも重大
です。


File: python.info,  Node: ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか？,  Next: グローバル変数をモジュール間で共有するにはどうしたらいいですか？,  Prev: Python のローカルとグローバル変数のルールは何ですか？,  Up: コア言語

10.2.2.3 ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか？
.................................................................................

for ループを使って、少しずつ異なるラムダを定義 (もしくは簡単な関数) する
とします。例えば:

     >>> squares = []
     >>> for x in range(5):
     ...     squares.append(lambda: x**2)

これで ‘x**2’ を計算する 5 つのラムダのリストが得られます。それらを呼び
出したとき、それぞれ ‘0’、‘1’、‘4’、‘9’、‘16’ を返すと予想するかもしれま
せん。しかし実際にやってみると、全て ‘16’ が返ってくるのを目にするでしょ
う:

     >>> squares[2]()
     16
     >>> squares[4]()
     16

これは、‘x’ がラムダにとってのローカル変数ではなく外側のスコープで定義さ
れていて、ラムダが定義されたときでなく呼び出されたときにアクセスされるた
めに起こります。ループが終わった時点では ‘x’ は ‘4’ であり、従って、全て
の関数は ‘4**2’ つまり ‘16’ を返します。このことは ‘x’ の値を変えてみる
ことで検証でき、ラムダの返り値がどのように変わるのか観察できます:

     >>> x = 8
     >>> squares[2]()
     64

これを避けるためには、グローバルの ‘x’ の値に依存しないために、ラムダに
とってのローカル変数に値を保存する必要があります:

     >>> squares = []
     >>> for x in range(5):
     ...     squares.append(lambda n=x: n**2)

ここで、‘n=x’ は新しいラムダにとってのローカル変数 ‘n’ を作成し、ラムダ
が定義されるときに計算されるので、ループのその時点での ‘x’ と同じ値を持
っています。これは、1 つ目のラムダでは ‘n’ の値は ‘0’ になり、2 つ目では
‘1’、3 つ目では ‘2’ 以下同様、となることを意味します。従って、それぞれの
ラムダは今や正しい値を返すようになりました:

     >>> squares[2]()
     4
     >>> squares[4]()
     16

この動作はラムダに特有なものではなく、通常の関数にも適用されることに注意
してください。


File: python.info,  Node: グローバル変数をモジュール間で共有するにはどうしたらいいですか？,  Next: モジュールで import を使う際の「ベストプラクティス」は何ですか？,  Prev: ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか？,  Up: コア言語

10.2.2.4 グローバル変数をモジュール間で共有するにはどうしたらいいですか？
.........................................................................

一つのプログラムのモジュール間で情報を共有する正準な方法は、特別なモジュ
ール (しばしば config や cfg と呼ばれる) を作ることです。単に設定モジュ
ールをアプリケーションのすべてのモジュールにインポートしてください。この
モジュールはグローバルな名前として使えます。それぞれのモジュールのただ一
つのインスタンスがあるので、設定モジュールオブジェクトに対するいかなる変
更も全体に反映されます。例えば:

config.py:

     x = 0   # Default value of the 'x' configuration setting

mod.py:

     import config
     config.x = 1

main.py:

     import config
     import mod
     print(config.x)

なお、同じ理由から、モジュールを使うということは、シングルトンデザインパ
ターンを実装することの基礎でもあります。


File: python.info,  Node: モジュールで import を使う際の「ベストプラクティス」は何ですか？,  Next: なぜオブジェクト間でデフォルト値が共有されるのですか？,  Prev: グローバル変数をモジュール間で共有するにはどうしたらいいですか？,  Up: コア言語

10.2.2.5 モジュールで import を使う際の「ベストプラクティス」は何ですか？
.........................................................................

一般的に ‘from modulename import *’ を使ってはいけません。そのようにする
とインポータの名前空間は汚染され、linter が未定義の名前を発見することが
難しくなります。

モジュールはファイルの先頭でインポートしてください。これによってコードが
必要とする他のモジュールが明確になり、モジュール名がスコープに含まれるか
どうかに迷わなくなります。行に一つのインポートにすると、モジュールのイン
ポートの追加と削除が容易になりますが、行に複数のインポートにすると画面の
領域が少なく済みます。

次の手順でモジュールをインポートするのが、良い習慣になります:

  1. 標準ライブラリモジュール - 例 *note sys: c3.、*note os: 91.、*note
     argparse: 5.、*note re: a7.

  2. サードパーティのライブラリモジュール (Python の site-packages ディ
     レクトリにあるもの) - 例 ‘dateutil’、‘requests’、‘PIL.Image’、など

  3. 自前で開発したモジュール

循環参照の問題を避けるために、インポートを関数やクラスに移すことが必要な
ときもあります。Gordon McMillan によれば:

     循環参照は両方のモジュールが "import <module>" 形式のインポートを使
     っていれば大丈夫です。二つ目のモジュールが最初のモジュールから名前
     を確保しようとして ("from module import name")、そのインポートがト
     ップレベルにあると駄目です。最初のモジュールが二つ目のモジュールを
     インポートするのに忙しくて、最初のモジュールの名前が利用可能になっ
     ていないからです。

この状況では、二つ目のモジュールが一つの関数の中でのみ使われているならば
、そのインポートは簡単に関数の中に移せます。インポートが呼ばれたとき、最
初のモジュールは初期化を完了していて、二つ目のモジュールは自分のインポー
トをできます。

プラットフォーム依存のモジュールがあるときには、インポートをトップレベル
の外に動かすことも必要です。この場合、ファイルの先頭ではすべてのモジュー
ルをインポートすることさえできないかもしれません。この場合は、対応するプ
ラットフォームに合わせたコードで正しいモジュールをインポートすることを選
ぶと良いです。

循環参照の問題を避けたりモジュールの初期化にかかる時間を減らしたりしたい
なら、単にインポートを関数定義の中などのローカルなスコープに移してくださ
い。この手法は多くのインポートがプログラムがどのように実行されるかに依存
しなくてよいときに特に有効です。ある関数の中でのみモジュールが使われるの
なら、インポートをその関数の中に移すことを考えてもいいでしょう。なお、モ
ジュールを読み込む最初の回はモジュールの初期化の時間のために高価になりえ
ますが、複数回目にモジュールを読み込むのは事実上無料、辞書探索の数回のコ
ストだけで済みます。モジュール名がスコープから外れてさえ、そのモジュール
はおそらく *note sys.modules: 18d6. から利用できるでしょう。


File: python.info,  Node: なぜオブジェクト間でデフォルト値が共有されるのですか？,  Next: オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？,  Prev: モジュールで import を使う際の「ベストプラクティス」は何ですか？,  Up: コア言語

10.2.2.6 なぜオブジェクト間でデフォルト値が共有されるのですか？
...............................................................

この種のバグがよく初心者プログラマに噛み付きます。この関数を考えてみてく
ださい:

     def foo(mydict={}):  # Danger: shared reference to one dict for all calls
         ... compute something ...
         mydict[key] = value
         return mydict

初めてこの関数を呼び出した時、‘mydict’ には一つの要素があります。二回目
には、‘foo()’ が実行されるときに ‘mydict’ には初めから一つの要素をすでに
持っているので、‘mydict’ には二つの要素があります。

関数の呼び出しによって、デフォルトの値に対する新しいオブジェクトが作られ
るのだと予想しがちです。実はそうなりません。デフォルト値は、関数が定義さ
れたときに一度だけ生成されます。この例の辞書のように、そのオブジェクトが
変更されたとき、その後の関数の呼び出しは変更後のオブジェクトを参照します
。

定義の時に、数、文字列、タプル、‘None’ など、イミュータブルなオブジェク
トを使うと変更される危険がありません。辞書、リスト、クラスインスタンスな
どのミュータブルなオブジェクトは混乱のもとです。

この性質から、ミュータブルなオブジェクトをデフォルト値として使わないプロ
グラミング手法がいいです。代わりに、‘None’ をデフォルト値に使い、そのパ
ラメタが ‘None’ である時にだけ、関数の内部で新しいリスト/辞書/その他をつ
くるようにしてください。例えば、こう書かずに:

     def foo(mydict={}):
         ...

代わりに:

     def foo(mydict=None):
         if mydict is None:
             mydict = {}  # create a new dict for local namespace

この性質が便利なこともあります。時間のかかる計算を行う関数があるときに使
われる一般的な技法は、関数が呼び出されるごとにパラメタと結果の値をキャッ
シュし、再び同じ値が要求されたらキャッシュされた値を返すというものです。
これは "memoizing" と呼ばれ、このように実装されます:

     # Callers can only provide two parameters and optionally pass _cache by keyword
     def expensive(arg1, arg2, *, _cache={}):
         if (arg1, arg2) in _cache:
             return _cache[(arg1, arg2)]

         # Calculate the value
         result = ... expensive computation ...
         _cache[(arg1, arg2)] = result           # Store result in the cache
         return result

デフォルト値の代わりに、辞書を含むグローバル変数も使えます。これは好みの
問題です。


File: python.info,  Node: オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？,  Next: 実引数と仮引数の違いは何ですか?,  Prev: なぜオブジェクト間でデフォルト値が共有されるのですか？,  Up: コア言語

10.2.2.7 オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？
.................................................................................................

関数のパラメータリストに引数を ‘*’ と ‘**’ 指定子 (specifier) で集めてく
ださい。そうすれば、位置引数をタプルとして、キーワード引数を辞書として得
られます。これで、他の関数を呼び出すときに ‘*’ と ‘**’ を使ってそれらの
引数を渡せます:

     def f(x, *args, **kwargs):
         ...
         kwargs['width'] = '14.3c'
         ...
         g(x, *args, **kwargs)


File: python.info,  Node: 実引数と仮引数の違いは何ですか?,  Next: なぜ list 'y' を変更すると list 'x' も変更されるのですか?,  Prev: オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？,  Up: コア言語

10.2.2.8 実引数と仮引数の違いは何ですか?
........................................

*note 仮引数 (parameter): 1e5e. は関数定義に表れる名前で定義されるのに対
し、 *note 実引数 (argument): 415. は関数を呼び出すときに実際に渡す値の
ことです。仮引数は関数が受け取ることの出来る *note 実引数の型: 1e5e. を
定義します。例えば、以下のような関数定義があったとして:

     def func(foo, bar=None, **kwargs):
         pass

'foo'、'bar'、'kwargs' は ‘func’ の仮引数です。一方、‘func’ を呼び出すと
きには、例えば:

     func(42, bar=314, extra=somevar)

‘42’、‘314’、‘somevar’ という値は実引数です。


File: python.info,  Node: なぜ list 'y' を変更すると list 'x' も変更されるのですか?,  Next: 出力引数のある関数 参照渡し はどのように書きますか？,  Prev: 実引数と仮引数の違いは何ですか?,  Up: コア言語

10.2.2.9 なぜ list 'y' を変更すると list 'x' も変更されるのですか?
..................................................................

次のようなコードを書いたとします:

     >>> x = []
     >>> y = x
     >>> y.append(10)
     >>> y
     [10]
     >>> x
     [10]

どうして ‘y’ への要素の追加が ‘x’ も変更してしまうのか疑問に思うかもしれ
ません。

このような結果になる2つの要因があります:

  1. 変数とは、単にオブジェクトを参照するための名前に過ぎません。 ‘y =
     x’ とすることは、リストのコピーを作りません - それは ‘x’ が参照する
     のと同じオブジェクトを参照する新しい変数 ‘y’ を作ります。つまり、あ
     るのは一つのオブジェクト(この場合リスト)だけであって、 ‘x’ と ‘y’ の
     両方がそれを参照しているのです。

  2. リストは *note mutable: 1273. です。内容を変更出来る、ということで
     す。

‘append()’ 呼び出しの後、ミュータブルオブジェクトの内容が ‘[]’ から
‘[10]’ に変わります。 変数が同じオブジェクトを参照しているので、どちらの
名前であっても変更された値 ‘[10]’ にアクセスします。

代わりに ‘x’ にイミュータブルを代入すると:

     >>> x = 5  # ints are immutable
     >>> y = x
     >>> x = x + 1  # 5 can't be mutated, we are creating a new object here
     >>> x
     6
     >>> y
     5

この場合ご覧の通り ‘x’ と ‘y’ はまったく同じではありませんね。これは整数
が *note immutable: 1272. だからで、 ‘x = x + 1’ は整数の ‘5’ の値を変更
しているのではありません; 代わりに新しいオブジェクト(整数 ‘6’)を作って
‘x’ に代入しています (つまり ‘x’ が参照するオブジェクトが変わります)。こ
の代入の後では私たちは 2 つのオブジェクト(整数の ‘6’ と ‘5’)を持っていて
、2 つの変数はそれらを参照しています(‘x’ はいまや ‘6’ を参照していますが
‘y’ は ‘5’ を参照したままです)。

ある演算 (たとえば ‘y.append(10)’, ‘y.sort()’) がオブジェクトを変更する
一方で、外見上は似た演算 (たとえば ‘y = y + [10]’, *note sorted(y):
b9c.) は新しいオブジェクトを作ります。Python では一般に (そして標準ライ
ブラリの全てのケースで)、このような 2 つのタイプの演算にまつわる混乱を避
けるために、オブジェクトを変更するメソッドは ‘None’ を返します。ですから
もしあなたが誤って ‘y’ の複製の並び替えをするつもりで ‘y.sort()’ と書い
た場合に結果手にするのは ‘None’ でしょうから、あなたのプログラムは簡単に
診断出来るエラーを起こすでしょう。

しかしながら、同じ操作が型ごとに異なる振る舞いをする演算の種類が一つあり
ます: 累算代入演算です。例えば ‘+=’ はリストを変更しますが、タプルや整数
は変更しません(‘a_list += [1, 2, 3]’ は ‘a_list.extend([1, 2, 3])’ と同
じ意味で、そして ‘a_list’ を変更しますが、 ‘some_tuple += (1, 2, 3)’ と
‘some_int += 1’ は新しいオブジェクトを作ります)。

言い換えると:

   * ミュータブルなオブジェクト(*note list: 5dc, *note dict: 237, *note
     set: 5a3, 等)を持っている場合、私たちはその内容を変更するある種の演
     算を使うことが出来、それを参照している全ての変数はその変化を見るこ
     とになるでしょう。

   * イミュータブルなオブジェクト(*note str: 418, *note int: 238, *note
     tuple: 349, 等)を持っている場合、それを参照している全ての変数は同じ
     値を参照しているでしょうが、持っている値を新しい値に変換する演算は
     いつでも新しいオブジェクトを返します。

2つの変数が同じオブジェクトを参照しているかどうかが知りたければ、 *note
is: 2cc. 演算子や組み込み関数 *note id(): 13ca. が使えます。


File: python.info,  Node: 出力引数のある関数 参照渡し はどのように書きますか？,  Next: Python で高次関数はどのようにつくりますか？,  Prev: なぜ list 'y' を変更すると list 'x' も変更されるのですか?,  Up: コア言語

10.2.2.10 出力引数のある関数 (参照渡し) はどのように書きますか？
................................................................

前提として、Python では引数は代入によって渡されます。代入はオブジェクト
への参照を作るだけなので、呼び出し元と呼び出し先にある引数名の間にエイリ
アスはありませんし、参照渡しそれ自体はありません。望む効果を得るためには
幾つかの方法があります。

  1. 結果のタプルを返すことによって:

          >>> def func1(a, b):
          ...     a = 'new-value'        # a and b are local names
          ...     b = b + 1              # assigned to new objects
          ...     return a, b            # return new values
          ...
          >>> x, y = 'old-value', 99
          >>> func1(x, y)
          ('new-value', 100)

     これはたいてい一番明確な方法です。

  2. グローバル変数を使って。これはスレッドセーフでないので、推奨されま
     せん。

  3. ミュータブルな (インプレースに変更可能な) オブジェクトを渡すことに
     よって:

          >>> def func2(a):
          ...     a[0] = 'new-value'     # 'a' references a mutable list
          ...     a[1] = a[1] + 1        # changes a shared object
          ...
          >>> args = ['old-value', 99]
          >>> func2(args)
          >>> args
          ['new-value', 100]

  4. 変更される辞書に渡すことによって:

          >>> def func3(args):
          ...     args['a'] = 'new-value'     # args is a mutable dictionary
          ...     args['b'] = args['b'] + 1   # change it in-place
          ...
          >>> args = {'a': 'old-value', 'b': 99}
          >>> func3(args)
          >>> args
          {'a': 'new-value', 'b': 100}

  5. または、クラスインスタンスに値を同梱することによって:

          >>> class Namespace:
          ...     def __init__(self, /, **args):
          ...         for key, value in args.items():
          ...             setattr(self, key, value)
          ...
          >>> def func4(args):
          ...     args.a = 'new-value'        # args is a mutable Namespace
          ...     args.b = args.b + 1         # change object in-place
          ...
          >>> args = Namespace(a='old-value', b=99)
          >>> func4(args)
          >>> vars(args)
          {'a': 'new-value', 'b': 100}

     このような複雑なことをする理由はめったに無いでしょう。

一番の選択は、複数の結果を含むタプルを返すことです。


File: python.info,  Node: Python で高次関数はどのようにつくりますか？,  Next: Python のオブジェクトはどのようにコピーしますか？,  Prev: 出力引数のある関数 参照渡し はどのように書きますか？,  Up: コア言語

10.2.2.11 Python で高次関数はどのようにつくりますか？
.....................................................

二つの方法があります: ネストされたスコープを使う方法と、呼び出し可能オブ
ジェクトを使う方法です。例えば、‘a*x+b’ の値を計算する ‘f(x)’ 関数を返す
‘linear(a,b)’ を定義したいとします。ネストされたスコープを使うと:

     def linear(a, b):
         def result(x):
             return a * x + b
         return result

また、呼び出し可能オブジェクトを使うと:

     class linear:

         def __init__(self, a, b):
             self.a, self.b = a, b

         def __call__(self, x):
             return self.a * x + self.b

どちらの場合でも、

     taxes = linear(0.3, 2)

とすれば、‘taxes(10e6) == 0.3 * 10e6 + 2’ となるような呼び出し可能オブジ
ェクトを得られます。

呼び出し可能オブジェクトを使う方法は、少し遅くなり、わずかにコードが長く
なるという短所があります。ですが、継承を使って呼び出し可能オブジェクト同
士で記号を共有することもできます:

     class exponential(linear):
         # __init__ inherited
         def __call__(self, x):
             return self.a * (x ** self.b)

オブジェクトはいくつかのメソッドに状態をカプセル化できます:

     class counter:

         value = 0

         def set(self, x):
             self.value = x

         def up(self):
             self.value = self.value + 1

         def down(self):
             self.value = self.value - 1

     count = counter()
     inc, dec, reset = count.up, count.down, count.set

ここで、‘inc()’、‘dec()’、‘reset()’ は同じカウント変数を共有する関数のよ
うにふるまいます。


File: python.info,  Node: Python のオブジェクトはどのようにコピーしますか？,  Next: オブジェクトのメソッドや属性はどのように見つけますか？,  Prev: Python で高次関数はどのようにつくりますか？,  Up: コア言語

10.2.2.12 Python のオブジェクトはどのようにコピーしますか？
...........................................................

一般的に、普通は *note copy.copy(): 4fd. や *note copy.deepcopy(): b3c.
を試してください。何でもコピーできるとは限りませんが、たいていはできます
。

もっと簡単にコピーできるオブジェクトもあります。辞書には *note copy():
b9e. メソッドがあります:

     newdict = olddict.copy()

シーケンスはスライシングでコピーできます:

     new_l = l[:]


File: python.info,  Node: オブジェクトのメソッドや属性はどのように見つけますか？,  Next: コードはどのようにオブジェクトの名前を見つけるのですか？,  Prev: Python のオブジェクトはどのようにコピーしますか？,  Up: コア言語

10.2.2.13 オブジェクトのメソッドや属性はどのように見つけますか？
................................................................

ユーザー定義クラスのインスタンス ‘x’ で、*note dir(x): 5fe,< はインスタ
ンス属性とそのクラスで定義されたメソッドや属性を含む名前のアルファベット
順リストを返します。


File: python.info,  Node: コードはどのようにオブジェクトの名前を見つけるのですか？,  Next: カンマ演算子はなぜ優先されるのですか？,  Prev: オブジェクトのメソッドや属性はどのように見つけますか？,  Up: コア言語

10.2.2.14 コードはどのようにオブジェクトの名前を見つけるのですか？
..................................................................

概して、オブジェクトは本当は名前を持たないので、見つけることはできません
。本質的には、代入とはいつも値に名前を束縛することです。‘def’ と ‘class’
文も同じですが、この場合は値はコーラブルです。以下のコードを考えてみまし
ょう:

     >>> class A:
     ...     pass
     ...
     >>> B = A
     >>> a = B()
     >>> b = a
     >>> print(b)
     <__main__.A object at 0x16D07CC>
     >>> print(a)
     <__main__.A object at 0x16D07CC>

おそらく、このクラスには名前があります。このクラスは二つの名前に縛られて
、名前 ‘B’ を通して呼び出されますが、それでもクラス ‘A’ のインスタンスと
して報告されるのです。しかし、両方の名前が同じ値に束縛されている以上、こ
のインスタンスの名前が ‘a’ か ‘b’ か決めることはできないのです。

概して、コードにとってある値の「名前を知っている」事は重要ではありません
。あなたがわざと内省的なコードを書いているのでない限り、方針を変えた方が
いいかもしれないということになるでしょう。

comp.lang.python で、Fredrik Lundh はこの問題の答えとして素晴らしい喩え
をしてくれました:

     玄関にいた猫の名前を知るのと同じ方法です: その猫 (オブジェクト) 自
     体はその名前を言うことができないし、それは実は問題ではありません -
     その猫が何と呼ばれているかを知る唯一の方法は、すべての隣人 (名前空
     間) にその猫 (オブジェクト) が何と呼ばれているかを聞くことです。

     ……そして、その猫が沢山の名前で知られていたり、逆に全く名前が無かっ
     たりしても驚かないでください！


File: python.info,  Node: カンマ演算子はなぜ優先されるのですか？,  Next: C の "? " 三項演算子と等価なものはありますか？,  Prev: コードはどのようにオブジェクトの名前を見つけるのですか？,  Up: コア言語

10.2.2.15 カンマ演算子はなぜ優先されるのですか？
................................................

カンマは Python では演算子ではありません。このセッションを考えてください
:

     >>> "a" in "b", "a"
     (False, 'a')

カンマは演算子ではなく、式の分離子なので、上の式は次の式と同じように評価
されます:

     ("a" in "b"), "a"

こうではありません:

     "a" in ("b", "a")

他のさまざまな演算子(‘=’、‘+=’ など)も同じです。これらは真の演算子ではあ
りませんが、代入文の構文上のデリミタです。


File: python.info,  Node: C の "? " 三項演算子と等価なものはありますか？,  Next: Python で解し難いワンライナーを書くことはできますか？,  Prev: カンマ演算子はなぜ優先されるのですか？,  Up: コア言語

10.2.2.16 C の "?:" 三項演算子と等価なものはありますか？
........................................................

はい、あります。構文は以下のようになります:

     [on_true] if [expression] else [on_false]

     x, y = 50, 25
     small = x if x < y else y

この構文が導入された 2.5 以前のバージョンに関しては、論理演算子を使った
このイディオムが一般的でした:

     [expression] and [on_true] or [on_false]

しかし、このイディオムは安全ではありません。'on_true' のブール値が偽であ
るときに間違った結果を与えることがあります。ですから、いつでも ‘... if
... else ...’ 形式を使ったほうが良いです。


File: python.info,  Node: Python で解し難いワンライナーを書くことはできますか？,  Next: 関数の引数リストにあるスラッシュ / は何を意味しますか？,  Prev: C の "? " 三項演算子と等価なものはありますか？,  Up: コア言語

10.2.2.17 Python で解し難いワンライナーを書くことはできますか？
...............................................................

はい。そういうものはたいてい、 ‘lambda’ の中に *note lambda: 126d. がネ
ストされています。Ulf Bartelt によるものを少しアレンジした下の３つの例を
見てください:

     from functools import reduce

     # Primes < 1000
     print(list(filter(None,map(lambda y:y*reduce(lambda x,y:x*y!=0,
     map(lambda x,y=y:y%x,range(2,int(pow(y,0.5)+1))),1),range(2,1000)))))

     # First 10 Fibonacci numbers
     print(list(map(lambda x,f=lambda x,f:(f(x-1,f)+f(x-2,f)) if x>1 else 1:
     f(x,f), range(10))))

     # Mandelbrot set
     print((lambda Ru,Ro,Iu,Io,IM,Sx,Sy:reduce(lambda x,y:x+'\n'+y,map(lambda y,
     Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,Sy=Sy,L=lambda yc,Iu=Iu,Io=Io,Ru=Ru,Ro=Ro,i=IM,
     Sx=Sx,Sy=Sy:reduce(lambda x,y:x+y,map(lambda x,xc=Ru,yc=yc,Ru=Ru,Ro=Ro,
     i=i,Sx=Sx,F=lambda xc,yc,x,y,k,f=lambda xc,yc,x,y,k,f:(k<=0)or (x*x+y*y
     >=4.0) or 1+f(xc,yc,x*x-y*y+xc,2.0*x*y+yc,k-1,f):f(xc,yc,x,y,k,f):chr(
     64+F(Ru+x*(Ro-Ru)/Sx,yc,0,0,i)),range(Sx))):L(Iu+y*(Io-Iu)/Sy),range(Sy
     ))))(-2.1, 0.7, -1.2, 1.2, 30, 80, 24))
     #    \___ ___/  \___ ___/  |   |   |__ lines on screen
     #        V          V      |   |______ columns on screen
     #        |          |      |__________ maximum of "iterations"
     #        |          |_________________ range on y axis
     #        |____________________________ range on x axis

よい子はまねしないでね！


File: python.info,  Node: 関数の引数リストにあるスラッシュ / は何を意味しますか？,  Prev: Python で解し難いワンライナーを書くことはできますか？,  Up: コア言語

10.2.2.18 関数の引数リストにあるスラッシュ (/) は何を意味しますか？
...................................................................

パラメータ関数の仮引数にあるスラッシュは、それより前にある仮引数は位置専
用引数であることを示します。 位置専用引数は、外で使える名前を持たない仮
引数です。 位置専用引数を受け付ける関数の呼び出しにおいて、実引数はその
位置だけに基づいて仮引数に対応付けられます。 例えば、 *note divmod():
96f. は位置専用引数を受け付けます。 そのドキュメントは次のようになります
:

     >>> help(divmod)
     Help on built-in function divmod in module builtins:

     divmod(x, y, /)
         Return the tuple (x//y, x%y).  Invariant: div*y + mod == x.

この引数リストの末尾にスラッシュは、この2つの仮引数が両方とも位置専用引
数であることを意味します。 したがって、*note divmod(): 96f. をキーワード
引数を使って呼び出すとエラーになります:

     >>> divmod(x=3, y=4)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
     TypeError: divmod() takes no keyword arguments


File: python.info,  Node: 数と文字列,  Next: 性能<4>,  Prev: コア言語,  Up: プログラミング FAQ

10.2.3 数と文字列
-----------------

* Menu:

* 十六進数や八進数を指定するにはどうしたらいいですか？::
* なぜ -22 // 10 は -3 を返すのですか？::
* どうすれば SyntaxError を起こさずに整数リテラルの属性を得られますか？::
* 文字列を数に変換するにはどうしたらいいですか？::
* 数を文字列に変換するにはどうしたらいいですか？::
* 文字列をインプレースに変更するにはどうしたらいいですか？::
* 関数やメソッドを呼ぶのに文字列を使うにはどうしたらいいですか？::
* 文字列から後端の改行を取り除く Perl の chomp() に相当するものはありますか？: 文字列から後端の改行を取り除く Perl の chomp に相当するものはありますか？.
* scanf() や sscanf() と同等なものはありますか？: scanf や sscanf と同等なものはありますか？.
* 'UnicodeDecodeError' や 'UnicodeEncodeError' はどういう意味ですか？::
* raw string を奇数個のバックスラッシュで終えることはできますか？::


File: python.info,  Node: 十六進数や八進数を指定するにはどうしたらいいですか？,  Next: なぜ -22 // 10 は -3 を返すのですか？,  Up: 数と文字列

10.2.3.1 十六進数や八進数を指定するにはどうしたらいいですか？
.............................................................

八進数を指定するには、八進数での値の先頭に 0 と "o" (小文字または大文字)
を加えてください。たとえば、変数 "a" に八進数での "10" (十進数での"8") を
代入するには、こう打ってください:

     >>> a = 0o10
     >>> a
     8

十六進数も簡単です。ただ十六進数での値の先頭に 0 と "x" (小文字または大
文字) を加えてください。十六進数は小文字でも大文字でも指定できます。たと
えば、Python インタプリタで:

     >>> a = 0xa5
     >>> a
     165
     >>> b = 0XB2
     >>> b
     178


File: python.info,  Node: なぜ -22 // 10 は -3 を返すのですか？,  Next: どうすれば SyntaxError を起こさずに整数リテラルの属性を得られますか？,  Prev: 十六進数や八進数を指定するにはどうしたらいいですか？,  Up: 数と文字列

10.2.3.2 なぜ -22 // 10 は -3 を返すのですか？
..............................................

‘i % j’ が ‘j’ と同じ符号であってほしいことに基づいています。それに加え
て以下のようにもしたいとすると:

     i == (i // j) * j + (i % j)

整数除算は床を返すことになります。C にも C の一貫性があって、‘i % j’ が
‘i’ と同じ符号を持つように ‘i // j’ を丸めています。

‘i % j’ は、‘j’ が負の時には実際にはほとんど使いません。‘j’ が正なら、た
くさん使います。その事実上すべての場合、‘i % j’ は ‘>= 0’ となる方が便利
です。時計が 10 時を指している時、その 200 時間前は何時でしょうか。‘-190
% 12 == 2’ となるのが便利です。‘-190 % 12 == -10’ は噛み付きかねないバグ
です。


File: python.info,  Node: どうすれば SyntaxError を起こさずに整数リテラルの属性を得られますか？,  Next: 文字列を数に変換するにはどうしたらいいですか？,  Prev: なぜ -22 // 10 は -3 を返すのですか？,  Up: 数と文字列

10.2.3.3 どうすれば SyntaxError を起こさずに整数リテラルの属性を得られますか？
..............................................................................

ふつうの方法で ‘int’ リテラルの属性を探そうとすると、ピリオドが小数点と
みなされ、*note SyntaxError: 172. となります:

     >>> 1.__class__
       File "<stdin>", line 1
       1.__class__
        ^
     SyntaxError: invalid decimal literal

解決策は、リテラルとピリオドを スペースや括弧で分けることです。

     >>> 1 .__class__
     <class 'int'>
     >>> (1).__class__
     <class 'int'>


File: python.info,  Node: 文字列を数に変換するにはどうしたらいいですか？,  Next: 数を文字列に変換するにはどうしたらいいですか？,  Prev: どうすれば SyntaxError を起こさずに整数リテラルの属性を得られますか？,  Up: 数と文字列

10.2.3.4 文字列を数に変換するにはどうしたらいいですか？
.......................................................

For integers, use the built-in *note int(): 238. type constructor, e.g.
‘int('144') == 144’.  Similarly, *note float(): 2ce. converts to a
floating-point number, e.g.  ‘float('144') == 144.0’.

デフォルトでは、これらは数を十進数として解釈するので、 ‘int('0144') ==
144’ は成立しますが ‘int('0x144')’ は *note ValueError: 1e3. を送出しま
す。 ‘int(string, base)’ はオプションの第二引数をとって変換元の基数にし
ます。つまり ‘int( '0x144', 16) == 324’ です。基数が 0 と指定された場合
、その数は Python の基準によって解釈されます。先頭が '0o' なら八進数で、
'0x' なら十六進数を表します。

文字列を数に変換するだけのために *note eval(): 165. を使わないでください
。 *note eval(): 165. は特に遅いですし、セキュリティ上のリスクもあります
。求められない副作用を持つような Python の式を渡そうとする人がいるかも知
れません。例えば、あなたのホームディレクトリを消去する
‘__import__('os').system("rm -rf $HOME")’ を渡そうとする人がいるかも知れ
ません。

*note eval(): 165. にも数を Python の式として解釈する機能があります。だ
から例えば、 ‘eval('09')’ は構文エラー起こします。Python は ('0' 以外の)
十進数を '0' で始めてはならないからです。


File: python.info,  Node: 数を文字列に変換するにはどうしたらいいですか？,  Next: 文字列をインプレースに変更するにはどうしたらいいですか？,  Prev: 文字列を数に変換するにはどうしたらいいですか？,  Up: 数と文字列

10.2.3.5 数を文字列に変換するにはどうしたらいいですか？
.......................................................

例えば、‘144’ という数を ‘'144'’ という文字列に変換したいなら、組み込み
型のコンストラクタ *note str(): 418. を使ってください。 十六進数や八進数
にしたければ、組み込み関数の *note hex(): 129d. や *note oct(): 129c. を
使ってください。 手の込んだフォーマット形式を使うなら、 *note f-strings:
977. と *note 書式指定文字列の文法: 1358. の節を参照してください。 例え
ば、 ‘"{:04d}".format(144)’ は ‘'0144'’ になり、
‘"{:.3f}".format(1.0/3.0)’ は ‘'0.333'’ になります。


File: python.info,  Node: 文字列をインプレースに変更するにはどうしたらいいですか？,  Next: 関数やメソッドを呼ぶのに文字列を使うにはどうしたらいいですか？,  Prev: 数を文字列に変換するにはどうしたらいいですか？,  Up: 数と文字列

10.2.3.6 文字列をインプレースに変更するにはどうしたらいいですか？
.................................................................

文字列はイミュータブルなので、それはできません。殆どの場合、組み立てたい
個別の部品から単純に新しい文字列を構成するべきです。しかし、Unicode デー
タをインプレースに変更できるオブジェクトが必要なら、 *note array: 6. モ
ジュールの *note io.StringIO: ef3. オブジェクトを試してください:

     >>> import io
     >>> s = "Hello, world"
     >>> sio = io.StringIO(s)
     >>> sio.getvalue()
     'Hello, world'
     >>> sio.seek(7)
     7
     >>> sio.write("there!")
     6
     >>> sio.getvalue()
     'Hello, there!'

     >>> import array
     >>> a = array.array('w', s)
     >>> print(a)
     array('w', 'Hello, world')
     >>> a[0] = 'y'
     >>> print(a)
     array('w', 'yello, world')
     >>> a.tounicode()
     'yello, world'


File: python.info,  Node: 関数やメソッドを呼ぶのに文字列を使うにはどうしたらいいですか？,  Next: 文字列から後端の改行を取り除く Perl の chomp に相当するものはありますか？,  Prev: 文字列をインプレースに変更するにはどうしたらいいですか？,  Up: 数と文字列

10.2.3.7 関数やメソッドを呼ぶのに文字列を使うにはどうしたらいいですか？
.......................................................................

様々なテクニックがあります。

   * 一番いいのは、文字列を関数に対応させる辞書を使うことです。このテク
     ニックの一番の利点は、文字列が関数の名前と同じ必要がないことです。
     この方法は case 構造をエミュレートするための一番のテクニックでもあ
     ります:

          def a():
              pass

          def b():
              pass

          dispatch = {'go': a, 'stop': b}  # Note lack of parens for funcs

          dispatch[get_input()]()  # Note trailing parens to call function

   * 組み込み関数の *note getattr(): b9f. を使う方法:

          import foo
          getattr(foo, 'bar')()

     なお、 *note getattr(): b9f. はクラス、クラスインスタンス、モジュー
     ルなど、どんなオブジェクトにも使えます。

     これは標準ライブラリでも何箇所か使われています。このように:

          class Foo:
              def do_foo(self):
                  ...

              def do_bar(self):
                  ...

          f = getattr(foo_instance, 'do_' + opname)
          f()

   * *note locals(): 127. を使って関数名を決める方法:

          def myFunc():
              print("hello")

          fname = "myFunc"

          f = locals()[fname]
          f()


File: python.info,  Node: 文字列から後端の改行を取り除く Perl の chomp に相当するものはありますか？,  Next: scanf や sscanf と同等なものはありますか？,  Prev: 関数やメソッドを呼ぶのに文字列を使うにはどうしたらいいですか？,  Up: 数と文字列

10.2.3.8 文字列から後端の改行を取り除く Perl の chomp() に相当するものはありますか？
....................................................................................

‘S.rstrip("\r\n")’ を使って文字列 ‘S’ の終端から他の空白文字を取り除くこ
となくすべての行末記号を取り除くことができます。文字列 ‘S’ が複数行を表
し、終端に空行があるとき、そのすべての空行も取り除かれます:

     >>> lines = ("line 1 \r\n"
     ...          "\r\n"
     ...          "\r\n")
     >>> lines.rstrip("\n\r")
     'line 1 '

これは典型的に一度に一行ずつテキストを読みたい時にのみ使われるので、
‘S.rstrip()’ をこの方法で使うとうまくいきます。


File: python.info,  Node: scanf や sscanf と同等なものはありますか？,  Next: 'UnicodeDecodeError' や 'UnicodeEncodeError' はどういう意味ですか？,  Prev: 文字列から後端の改行を取り除く Perl の chomp に相当するものはありますか？,  Up: 数と文字列

10.2.3.9 scanf() や sscanf() と同等なものはありますか？
.......................................................

そのようなものはありません。

For simple input parsing, the easiest approach is usually to split the
line into whitespace-delimited words using the *note split(): e73.
method of string objects and then convert decimal strings to numeric
values using *note int(): 238. or *note float(): 2ce.  ‘split()’
supports an optional "sep" parameter which is useful if the line uses
something other than whitespace as a separator.

もっと複雑な入力解析をしたいなら、C の ‘sscanf’ よりも正規表現の方が便利
ですし、この処理に向いています。


File: python.info,  Node: 'UnicodeDecodeError' や 'UnicodeEncodeError' はどういう意味ですか？,  Next: raw string を奇数個のバックスラッシュで終えることはできますか？,  Prev: scanf や sscanf と同等なものはありますか？,  Up: 数と文字列

10.2.3.10 'UnicodeDecodeError' や 'UnicodeEncodeError' はどういう意味ですか？
.............................................................................

*note Unicode HOWTO: 1276. を参照して下さい。


File: python.info,  Node: raw string を奇数個のバックスラッシュで終えることはできますか？,  Prev: 'UnicodeDecodeError' や 'UnicodeEncodeError' はどういう意味ですか？,  Up: 数と文字列

10.2.3.11 raw string を奇数個のバックスラッシュで終えることはできますか？
.........................................................................

奇数個のバックスラッシュで終わる raw string は文字列のクォートをエスケー
プします:

     >>> r'C:\this\will\not\work\'
       File "<stdin>", line 1
         r'C:\this\will\not\work\'
              ^
     SyntaxError: unterminated string literal (detected at line 1)

これにはいくつかの回避策があります。ひとつは通常文字列と二重バックスラッ
シュを使うことです:

     >>> 'C:\\this\\will\\work\\'
     'C:\\this\\will\\work\\'

もうひとつは、エスケープされたバックスラッシュを含む通常の文字列を、 raw
string に連結します:

     >>> r'C:\this\will\work' '\\'
     'C:\\this\\will\\work\\'

Windowsでは、 *note os.path.join(): 1597. を使ってバックスラッシュを追加
することもできます:

     >>> os.path.join(r'C:\this\will\work', '')
     'C:\\this\\will\\work\\'

注意点として、バックスラッシュは raw string 終端のクォートを「エスケープ
」しますが、 raw string の値を解釈する際にはエスケープが生じません。つま
り、バックスラッシュは raw string 値の中に残ったままになります:

     >>> r'backslash\'preserved'
     "backslash\\'preserved"

*note 言語リファレンス: 1e06. の仕様も参照してください。


File: python.info,  Node: 性能<4>,  Next: シーケンス タプル/リスト,  Prev: 数と文字列,  Up: プログラミング FAQ

10.2.4 性能
-----------

* Menu:

* プログラムが遅すぎます。どうしたら速くなりますか？::
* 多くの文字列を結合するのに最も効率的な方法は何ですか？::


File: python.info,  Node: プログラムが遅すぎます。どうしたら速くなりますか？,  Next: 多くの文字列を結合するのに最も効率的な方法は何ですか？,  Up: 性能<4>

10.2.4.1 プログラムが遅すぎます。どうしたら速くなりますか？
...........................................................

これは、一般的に難しい問題です。まず、先に進む前に覚えておいて欲しいこと
をここに挙げます:

   * 性能の傾向は Python 実装によって変わります。この FAQ では *note
     CPython: 6c1. に焦点を当てます。

   * 振る舞いはオペレーティングシステムによって変わりえます。特に、I/O や
     マルチスレッドに関しては顕著です。

   * 常に、コードの最適化を始める '前に' プログラムのホットスポットを見
     つけるべきです (*note profile: 9d. モジュールを参照してください)。

   * ベンチマークスクリプトを書くことで、改善箇所の捜索を素早く繰り返せ
     ます (*note timeit: d8. モジュールを参照してください)。

   * 洗練された最適化に隠れたリグレッションの可能性を生む前に、(ユニット
     テストやその他の技法で) コードカバレッジを上げることを強く推奨しま
     す。

とは言っても、Python コードを高速化する技法はたくさんあります。ここでは
、満足な性能のレベルにたどり着くまでの長い道のりを進む、一般的な方針を示
します:

   * コード中に細かい最適化の技法をばらまこうとするよりも、アルゴリズム
     を高速化 (または高速なアルゴリズムに変更) するほうが、大きな利益を
     生むことがあります。

   * 適切なデータ構造を使ってください。*note 組み込み型: 20f3. や *note
     collections: 16. を調べてください。

   * 何かをするための基本要素が標準ライブラリにあるなら、自分で発明した
     代用品よりもそちらのほうが、(絶対にとは言えませんが) おそらく速いで
     す。 それが組み込み型やある種の拡張型のように C で書かれたものなら
     なおさらです。 たとえば、ソートするには、必ず *note list.sort():
     b9d. 組み込みメソッドか *note sorted(): b9c. 関数を使ってください
     (また、中程度に高度な例は、 *note ソートのテクニック: 11ab. を参照
     してください)。

   * 抽象化は、遠回りにしがちで、インタプリタの作業を増やすことになりま
     す。この遠回りさが、なされる作業の量より重大になると、プログラムが
     遅くなってしまいます。過度な抽象化、特に細かい関数やメソッドの形で
     現れるもの (これは読みにくさも落とします) は防ぐべきです。

pure Python にできる限界に達したなら、更に進むためのツールがあります。例
えば、Cython(1) は、Python コードのわずかに変形した版を C 拡張にコンパイ
ルし、多種のプラットフォームで使えます。Cython は、コンパイル (と任意の
型アノテーション) を利用し、コードの解釈を大幅に速くします。C プログラミ
ングに自信があるなら、自分で *note write a C extension module: 1b46. こ
ともできます。

参考
....

パフォーマンス tips(2) が載っている wiki のページ。

   ---------- Footnotes ----------

   (1) https://cython.org

   (2) https://wiki.python.org/moin/PythonSpeed/PerformanceTips


File: python.info,  Node: 多くの文字列を結合するのに最も効率的な方法は何ですか？,  Prev: プログラムが遅すぎます。どうしたら速くなりますか？,  Up: 性能<4>

10.2.4.2 多くの文字列を結合するのに最も効率的な方法は何ですか？
...............................................................

*note str: 418. および *note bytes: 1a4. オブジェクトはイミュータブルな
ので、多くの文字列の結合は結合ごとに新しいオブジェクトを作成し、効率が悪
いです。 一般的に、全体の実行時間のコストは文字列の長さの二乗に比例しま
す。

多くの *note str: 418. オブジェクトを累積するのにおすすめのイディオムは
、すべてをリストに配置してから最後に *note str.join(): 2110. を呼び出す
ことです:

     chunks = []
     for s in my_strings:
         chunks.append(s)
     result = ''.join(chunks)

(他の割と効率的なイディオムは、 *note io.StringIO: ef3. を使うことです)

多くの *note bytes: 1a4. オブジェクトを累積するのにおすすめのイディオム
は、 *note bytearray: 508. オブジェクトをインプレース結合 (‘+=’ 演算子)
で拡張することです:

     result = bytearray()
     for b in my_bytes_objects:
         result += b


File: python.info,  Node: シーケンス タプル/リスト,  Next: オブジェクト,  Prev: 性能<4>,  Up: プログラミング FAQ

10.2.5 シーケンス(タプル/リスト)
--------------------------------

* Menu:

* タプル、リスト間の変更はどのようにするのですか？::
* 負の添え字は何ですか？::
* シーケンスを逆順にイテレートするにはどうしたらいいですか？::
* リストから重複を取り除くにはどうしますか？::
* リストから複数のアイテムを取り除く方法::
* Python で配列を作るにはどうしますか？::
* 多次元のリストを作るにはどうしますか？::
* オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか？::
* なぜ加算はされるのに a_tuple[i] += ['item'] は例外を送出するのですか?::
* 複雑なソートがしたいのですが、Python でシュワルツ変換はできますか？::
* リストを別のリストの値によってソートするにはどうしますか？::


File: python.info,  Node: タプル、リスト間の変更はどのようにするのですか？,  Next: 負の添え字は何ですか？,  Up: シーケンス タプル/リスト

10.2.5.1 タプル、リスト間の変更はどのようにするのですか？
.........................................................

型コンストラクタ ‘tuple(seq)’ はすべてのシーケンス (実際には、すべてのイ
テラブル) を同じ要素、同じ順序のタプルに変換します。

例えば、 ‘tuple([1, 2, 3])’ は ‘(1, 2, 3)’ を与え、 ‘tuple('abc')’ は
‘('a', 'b', 'c')’ を与えます。引数がタプルなら、コピーを作らずに引数のオ
ブジェクトそのものを返すので、あるオブジェクトが既にタプルになっているか
確信が持てないのなら、 *note tuple(): 349. を呼ぶのが手軽です。

型コンストラクタ ‘list(seq)’ はすべてのシーケンスあるいはイテラブルを同
じ要素、同じ順序のリストに変換します。例えば、‘list((1, 2, 3))’ は ‘[1,
2, 3]’ を与え、‘list('abc')’ は ‘['a', 'b', 'c']’ を与えます。引数がリス
トなら、‘seq[:]’ と同様にコピーを作ります。


File: python.info,  Node: 負の添え字は何ですか？,  Next: シーケンスを逆順にイテレートするにはどうしたらいいですか？,  Prev: タプル、リスト間の変更はどのようにするのですか？,  Up: シーケンス タプル/リスト

10.2.5.2 負の添え字は何ですか？
...............................

Python のシーケンスは正の数と負の数でインデクスされます。正の数では、0 が
最初のインデクス、1 が 2 番目のインデクス、以下も同様です。負のインデク
スでは、-1 が最後のインデクス、-2 が最後から 2 番目のインデクス、以下も
同様です。‘seq[-n]’ は ‘seq[len(seq)-n]’ と同じだと考えてください。

負のインデクスを使うと便利なことがあります。例えば、‘S[:-1]’ は文字列の
最後以外のすべての文字を表すので、文字列の末尾の改行を取り除くときに便利
です。


File: python.info,  Node: シーケンスを逆順にイテレートするにはどうしたらいいですか？,  Next: リストから重複を取り除くにはどうしますか？,  Prev: 負の添え字は何ですか？,  Up: シーケンス タプル/リスト

10.2.5.3 シーケンスを逆順にイテレートするにはどうしたらいいですか？
...................................................................

組み込み関数 *note reversed(): 831. を使ってください。

     for x in reversed(sequence):
         ...  # do something with x ...

これは元のシーケンスをいじるのではなく、逆順の新しいコピーを作ってイテレ
ートさせます。


File: python.info,  Node: リストから重複を取り除くにはどうしますか？,  Next: リストから複数のアイテムを取り除く方法,  Prev: シーケンスを逆順にイテレートするにはどうしたらいいですか？,  Up: シーケンス タプル/リスト

10.2.5.4 リストから重複を取り除くにはどうしますか？
...................................................

Python Cookbook の長い議論に多くの方法があるので参照してください:

     ‘https://code.activestate.com/recipes/52560/’

リストを並び替えて構わないのなら、ソートした上でリストの最初から最後まで
を調べ、次のように重複を削除してください:

     if mylist:
         mylist.sort()
         last = mylist[-1]
         for i in range(len(mylist)-2, -1, -1):
             if last == mylist[i]:
                 del mylist[i]
             else:
                 last = mylist[i]

リストのすべての要素が集合のキーとして使える (つまり、すべての要素が
*note hashable: 5db.) なら、おそらくこのほうが速いです

     mylist = list(set(mylist))

リストを集合に変換するときに重複は取り除かれるので、それをリストに戻せば
いいのです。


File: python.info,  Node: リストから複数のアイテムを取り除く方法,  Next: Python で配列を作るにはどうしますか？,  Prev: リストから重複を取り除くにはどうしますか？,  Up: シーケンス タプル/リスト

10.2.5.5 リストから複数のアイテムを取り除く方法
...............................................

重複除去と同様に、削除条件を付けて明示的に逆回すのも一つの方法です。です
が、明示的/暗黙的な反復でスライス置換する方が速くて簡単です。こちらは３
つのバリエーションです。:

     mylist[:] = filter(keep_function, mylist)
     mylist[:] = (x for x in mylist if keep_condition)
     mylist[:] = [x for x in mylist if keep_condition]

リスト内包表記がおそらく最も高速です。


File: python.info,  Node: Python で配列を作るにはどうしますか？,  Next: 多次元のリストを作るにはどうしますか？,  Prev: リストから複数のアイテムを取り除く方法,  Up: シーケンス タプル/リスト

10.2.5.6 Python で配列を作るにはどうしますか？
..............................................

リストを使ってください:

     ["this", 1, "is", "an", "array"]

リストの時間計算量は C や Pascal の配列と同じです。大きな違いは、Python
のリストは多くの異なる型のオブジェクトを含めることです。

‘array’ モジュールにも固定された型を簡潔に表現する配列を作るためのメソッ
ドがありますが、リストよりもインデクスが遅いです。また、NumPy(1) やその
他のサードパーティー拡張でも、様々な特徴をもつ配列的な構造体が定義されて
います。

Lisp 方式の連結リストを得るのに、タプルを使って 'cons cells' をエミュレ
ートできます:

     lisp_list = ("like",  ("this",  ("example", None) ) )

ミュータブルな必要があるなら、タプルではなくリストを使いましょう。Lisp の
'car' にあたるものが ‘lisp_list[0]’ で、cdr にあたるものが
‘lisp_list[1]’ です。本当に必要だと確信できるとき以外はこれはしないでく
ださい。たいてい、これは Python のリストを使うよりも非常に遅いですから。

   ---------- Footnotes ----------

   (1) https://numpy.org/


File: python.info,  Node: 多次元のリストを作るにはどうしますか？,  Next: オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか？,  Prev: Python で配列を作るにはどうしますか？,  Up: シーケンス タプル/リスト

10.2.5.7 多次元のリストを作るにはどうしますか？
...............................................

このようにして多次元の配列を作ろうとしてしまったことがあるでしょう:

     >>> A = [[None] * 2] * 3

これを表示したときには問題なさそうに見えます:

     >>> A
     [[None, None], [None, None], [None, None]]

しかし値を代入すると、その値が複数の場所に現れてしまいます:

     >>> A[0][0] = 5
     >>> A
     [[5, None], [5, None], [5, None]]

これは、‘*’ を使ったリストの複製がコピーを作らず、存在するオブジェクトへ
の参照を作るだけだからです。この ‘*3’ は長さ 2 の同じリストへの参照を含
むリストを作ります。一つの列に対する変更はすべての列に現れますが、これが
望んだ結果であることはまずないでしょう。

おすすめの方法は、最初に望んだ長さのリストを作り、それから新しく作ったリ
ストでそれぞれの要素を埋めていくことです:

     A = [None] * 3
     for i in range(3):
         A[i] = [None] * 2

これは長さ 2 の異なるリスト 3 つを含むリストを生成します。リスト内包表記
も使えます:

     w, h = 2, 3
     A = [[None] * w for i in range(h)]

あるいは、行列データ型を提供している拡張を使用することもできます;
NumPy(1) が最もよく知られています。

   ---------- Footnotes ----------

   (1) https://numpy.org/


File: python.info,  Node: オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか？,  Next: なぜ加算はされるのに a_tuple[i] += ['item'] は例外を送出するのですか?,  Prev: 多次元のリストを作るにはどうしますか？,  Up: シーケンス タプル/リスト

10.2.5.8 オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか？
.............................................................................

メソッドや関数を呼び出して結果を蓄積するのには、 *note list
comprehension: 699. （リスト内包表記） がエレガントな解決策です:

     result = [obj.method() for obj in mylist]

     result = [function(obj) for obj in mylist]

戻り値を保存せずにメソッドや関数を実行するだけなら、ただの *note for:
2c9. ループで十分です:

     for obj in mylist:
         obj.method()

     for obj in mylist:
         function(obj)


File: python.info,  Node: なぜ加算はされるのに a_tuple[i] += ['item'] は例外を送出するのですか?,  Next: 複雑なソートがしたいのですが、Python でシュワルツ変換はできますか？,  Prev: オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか？,  Up: シーケンス タプル/リスト

10.2.5.9 なぜ加算はされるのに a_tuple[i] += ['item'] は例外を送出するのですか?
..............................................................................

これは、累算代入演算子は '代入' 演算子だ、という事実と、Python での可変
オブジェクトと不変オブジェクトの違いが組み合わさって起きるのです。

この議論は一般的に、可変オブジェクトを指すタプルの要素に、累算代入演算子
が適用されたときにも適用できますが、例として ‘list’ と ‘+=’ を使います。

次のように書いたとします:

     >>> a_tuple = (1, 2)
     >>> a_tuple[0] += 1
     Traceback (most recent call last):
        ...
     TypeError: 'tuple' object does not support item assignment

例外が送出された理由は明らかです: ‘1’ が (‘1’) を指すオブジェクト
‘a_tuple[0]’ に加えられ、結果のオブジェクト ‘2’ が生成されますが、計算結
果 ‘2’ をタプルの第 ‘0’ 要素に代入しようとしたときに、エラーが発生します
。なぜならば、タプルの要素が何を指すかは変えられないからです。

このような裏事情の元、累算代入文はだいたい次のようなことをしています:

     >>> result = a_tuple[0] + 1
     >>> a_tuple[0] = result
     Traceback (most recent call last):
       ...
     TypeError: 'tuple' object does not support item assignment

タプルは不変なので、例外を生み出しているのは操作の代入部分なのです。

次のように書いたとします:

     >>> a_tuple = (['foo'], 'bar')
     >>> a_tuple[0] += ['item']
     Traceback (most recent call last):
       ...
     TypeError: 'tuple' object does not support item assignment

この例外にはちょっと驚きますが、もっと驚くべきことは、エラーがあったとし
ても追記はきちんと動いている、という事実です:

     >>> a_tuple[0]
     ['foo', 'item']

なぜこれが起きるかを調べるためには、次の 2 点を知っている必要があります
。(a) オブジェクトに *note __iadd__(): 1eef. 特殊メソッドが実装されてい
る場合、拡張代入 ‘+=’ が実行されるときにそれが呼び出され、その返り値が代
入文で使われます; (b) リストでは、‘__iadd__()’ は ‘extend()’ の呼び出し
と等価で、リストを返します。こんな理由で、リストでは ‘+=’ は
‘list.extend()’ の "略記" だと言ったのでした:

     >>> a_list = []
     >>> a_list += [1]
     >>> a_list
     [1]

これは次と等価です:

     >>> result = a_list.__iadd__([1])
     >>> a_list = result

a_list が指していたオブジェクトは更新され、更新されたオブジェクトへのポ
インタは再度 ‘a_list’ に代入されます。代入しているのは、‘a_list’ が更新
前まで指していた同じオブジェクトへのポインタなので、代入は最終的には何も
していないのですが、代入処理自体は起きています。

従って、今のタプルの例では、次のと同じことが起きています:

     >>> result = a_tuple[0].__iadd__(['item'])
     >>> a_tuple[0] = result
     Traceback (most recent call last):
       ...
     TypeError: 'tuple' object does not support item assignment

‘__iadd__()’ は成功し、リストは拡張 (extend) されますが、‘result’ が
‘a_tuple[0]’ が既に指しているオブジェクトと同じオブジェクトを指していた
としても、タプルは不変なので、その最後の代入はやはりエラーとなります。


File: python.info,  Node: 複雑なソートがしたいのですが、Python でシュワルツ変換はできますか？,  Next: リストを別のリストの値によってソートするにはどうしますか？,  Prev: なぜ加算はされるのに a_tuple[i] += ['item'] は例外を送出するのですか?,  Up: シーケンス タプル/リスト

10.2.5.10 複雑なソートがしたいのですが、Python でシュワルツ変換はできますか？
.............................................................................

Perl コミュニティの Randal Schwartz の作とされるこのテクニックは、リスト
の要素を、それぞれの要素をその「ソート値」に対応付けるメトリックによって
ソートします。Python では、 *note list.sort(): b9d. メソッドに ‘key’ 引
数を使ってください:

     Isorted = L[:]
     Isorted.sort(key=lambda s: int(s[10:15]))


File: python.info,  Node: リストを別のリストの値によってソートするにはどうしますか？,  Prev: 複雑なソートがしたいのですが、Python でシュワルツ変換はできますか？,  Up: シーケンス タプル/リスト

10.2.5.11 リストを別のリストの値によってソートするにはどうしますか？
....................................................................

二つのイテレータを混ぜあわせてタプルのイテレータにしてから、必要な要素を
選んでください。

     >>> list1 = ["what", "I'm", "sorting", "by"]
     >>> list2 = ["something", "else", "to", "sort"]
     >>> pairs = zip(list1, list2)
     >>> pairs = sorted(pairs)
     >>> pairs
     [("I'm", 'else'), ('by', 'sort'), ('sorting', 'to'), ('what', 'something')]
     >>> result = [x[1] for x in pairs]
     >>> result
     ['else', 'sort', 'to', 'something']


File: python.info,  Node: オブジェクト,  Next: モジュール<5>,  Prev: シーケンス タプル/リスト,  Up: プログラミング FAQ

10.2.6 オブジェクト
-------------------

* Menu:

* クラスとは何ですか？::
* メソッドとは何ですか？::
* self とは何ですか？::
* あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを調べるにはどうしますか？::
* 委譲とは何ですか？::
* 基底クラスで定義されたメソッドを、そのクラスを継承した派生クラスから呼び出すにはどうしますか？::
* 基底クラスの名前を変えやすいコードを書くにはどうしますか？::
* 静的なクラスデータや静的なクラスメソッドを作るにはどうしますか？::
* Python でコンストラクタ(やメソッド)をオーバーロードするにはどうしたらいいですか？: Python でコンストラクタ やメソッド をオーバーロードするにはどうしたらいいですか？.
* __spam を使おうとしたら _SomeClassName__spam からエラーがでました。::
* クラスに __del__ メソッドを定義しているのですが、オブジェクトを削除したときに呼ばれません。::
* 与えられたクラスのすべてのインスタンスのリストを得るにはどうしますか？::
* なぜ id() の結果は一意でないように見えるのですか?: なぜ id の結果は一意でないように見えるのですか?.
* いつ is 演算子での同一性テストが頼れますか？::
* どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御できますか？::
* メソッド呼び出しをキャッシュするには どうしたらいいですか？::


File: python.info,  Node: クラスとは何ですか？,  Next: メソッドとは何ですか？,  Up: オブジェクト

10.2.6.1 クラスとは何ですか？
.............................

クラスは、class 文の実行で生成される特殊なオブジェクトです。クラスオブジ
ェクトはインスタンスオブジェクトを生成するためのテンプレートとして使われ
、あるデータ型に特有のデータ (attribute/属性) とコード (メソッド) の両方
を内蔵しています。

新しいクラスを一つ以上の他のクラス (新しいクラスの基底クラスと呼ばれます
) に基づいて作ることもできます。この新しいクラスは、基底クラスから属性と
メソッドを継承します。これにより、オブジェクトモデルを継承で連続的に洗練
できます。メールボックスへの基本的なアクセサを提供する一般的な ‘Mailbox’
クラスを作って、それからいろいろな特定のメールボックスの形式を扱う
‘MboxMailbox’、‘MaildirMailbox’、‘OutlookMailbox’ のようなサブクラスを作
れるのです。


File: python.info,  Node: メソッドとは何ですか？,  Next: self とは何ですか？,  Prev: クラスとは何ですか？,  Up: オブジェクト

10.2.6.2 メソッドとは何ですか？
...............................

メソッドは、オブジェクト ‘x’ が持つ関数で、通常 ‘x.name(arguments...)’ と
して呼び出されるものです。メソッドはクラス定義の中で関数として定義されま
す:

     class C:
         def meth(self, arg):
             return arg * 2 + self.attribute


File: python.info,  Node: self とは何ですか？,  Next: あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを調べるにはどうしますか？,  Prev: メソッドとは何ですか？,  Up: オブジェクト

10.2.6.3 self とは何ですか？
............................

self はメソッドの第一引数に慣習的につけられる名前にすぎません。
‘meth(self, a, b, c)’ として定義されたメソッドは、その定義がなされたクラ
スのインスタンス ‘x’ に対して ‘x.meth(a, b, c)’ として呼び出されます。呼
び出されたメソッドは、‘meth(x, a, b, c)’ が呼ばれたものと考えます。

*note なぜメソッドの定義や呼び出しにおいて 'self'
を明示しなければならないのですか？: 4f25. も参照してください。


File: python.info,  Node: あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを調べるにはどうしますか？,  Next: 委譲とは何ですか？,  Prev: self とは何ですか？,  Up: オブジェクト

10.2.6.4 あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを調べるにはどうしますか？
.............................................................................................................

ビルトイン関数 *note isinstance(obj, cls): 40e. を使ってください。クラス
のタプルを与えて ‘isinstance(obj, (class1, class2, ...))’ のようにすれば
、あるオブジェクトが任意の数のクラスのオブジェクトであるかを調べられます
し、‘isinstance(obj, str)’ や ‘isinstance(obj, (int, float, complex))’ の
ようにすれば、Python のビルトイン型のオブジェクトであるかも調べられます
。

注意： *note isinstance(): 40e. は *note abstract base class: 1186. (抽
象基底クラス)からの仮想継承もチェックします。そのため、登録 (register) さ
れたクラスが直接/間接的にそれを継承していなくても ‘True’ を返します。「
真のインスタンス」をテストする場合は、クラスの *note MRO: 34a5. を調べま
す:

     from collections.abc import Mapping

     class P:
          pass

     class C(P):
         pass

     Mapping.register(P)

     >>> c = C()
     >>> isinstance(c, C)        # direct
     True
     >>> isinstance(c, P)        # indirect
     True
     >>> isinstance(c, Mapping)  # virtual
     True

     # Actual inheritance chain
     >>> type(c).__mro__
     (<class 'C'>, <class 'P'>, <class 'object'>)

     # Test for "true inheritance"
     >>> Mapping in type(c).__mro__
     False

なお、大部分のプログラムでは、 *note isinstance(): 40e. をユーザー定義の
クラスに何度も使うべきではありません。クラスを自分で開発するときに、適切
なオブジェクト指向スタイルは、特定の振る舞いをカプセル化するクラスのメソ
ッドを定義するものであって、オブジェクトのクラスを調べてそのクラスに応じ
て違うことをするものではありません。例えば、何かをする関数があったとして
:

     def search(obj):
         if isinstance(obj, Mailbox):
             ...  # code to search a mailbox
         elif isinstance(obj, Document):
             ...  # code to search a document
         elif ...

よりよいアプローチは、‘search()’ メソッドをすべてのクラスに定義して、そ
れをただ呼び出すことです:

     class Mailbox:
         def search(self):
             ...  # code to search a mailbox

     class Document:
         def search(self):
             ...  # code to search a document

     obj.search()


File: python.info,  Node: 委譲とは何ですか？,  Next: 基底クラスで定義されたメソッドを、そのクラスを継承した派生クラスから呼び出すにはどうしますか？,  Prev: あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを調べるにはどうしますか？,  Up: オブジェクト

10.2.6.5 委譲とは何ですか？
...........................

委譲 (delegation) とは、オブジェクト指向のテクニック (デザインパターンと
も呼ばれる) の一つです。オブジェクト ‘x’ があって、そのメソッドのうちた
だ一つの振る舞いを変えたいとしましょう。新しいクラスを作成し、変えたいメ
ソッドだけを新しく実装し、他のすべてのメソッドを ‘x’ の対応するメソッド
に委譲する新しいクラスを作れます。

Python プログラマは簡単に委譲を実装できます。例えば、以下のクラスは、フ
ァイルのように振る舞いながらすべての文字を大文字に変換するクラスを実装し
ます:

     class UpperOut:

         def __init__(self, outfile):
             self._outfile = outfile

         def write(self, s):
             self._outfile.write(s.upper())

         def __getattr__(self, name):
             return getattr(self._outfile, name)

ここで ‘UpperOut’ クラスは ‘write()’ メソッドを定義しなおして、引数の文
字列を大文字に変換してから基礎となる ‘self._outfile.write()’ メソッドを
呼び出すようにします。その他すべてのメソッドは基礎となる ‘self._outfile’
オブジェクトに移譲されます。この委譲は *note __getattr__(): 49f. メソッ
ドを通してなされます。属性の制御の詳細は *note 言語リファレンス: 1ec4. を
参照してください。

なお、一般的に委譲はトリッキーになりがちです。属性が設定される時には読み
出される時と同様に、そのクラスに *note __setattr__(): 1e8d. メソッドを定
義する必要があり、それには細心の注意が必要です。 ‘__setattr__()’ の基本
的な実装はおおよそ以下のようになります:

     class X:
         ...
         def __setattr__(self, name, value):
             self.__dict__[name] = value
         ...

Many *note __setattr__(): 1e8d. implementations call
‘object.__setattr__()’ to set an attribute on self without causing
infinite recursion:

     class X:
         def __setattr__(self, name, value):
             # Custom logic here...
             object.__setattr__(self, name, value)

Alternatively, it is possible to set attributes by inserting entries
into *note self.__dict__: 526. directly.


File: python.info,  Node: 基底クラスで定義されたメソッドを、そのクラスを継承した派生クラスから呼び出すにはどうしますか？,  Next: 基底クラスの名前を変えやすいコードを書くにはどうしますか？,  Prev: 委譲とは何ですか？,  Up: オブジェクト

10.2.6.6 基底クラスで定義されたメソッドを、そのクラスを継承した派生クラスから呼び出すにはどうしますか？
.......................................................................................................

組み込みの *note super(): 4a8. 関数を使ってください:

     class Derived(Base):
         def meth(self):
             super().meth()  # calls Base.meth

この例では、 *note super(): 4a8. は呼ばれたインスタンス (‘self’ の値) を
自動判断し、 ‘type(self).__mro__’ で *note method resolution order:
20e5. (MRO メソッド解決順) を検索し、そしてMRO内で ‘Derived’ の次行を返
します: ‘Base’ 。


File: python.info,  Node: 基底クラスの名前を変えやすいコードを書くにはどうしますか？,  Next: 静的なクラスデータや静的なクラスメソッドを作るにはどうしますか？,  Prev: 基底クラスで定義されたメソッドを、そのクラスを継承した派生クラスから呼び出すにはどうしますか？,  Up: オブジェクト

10.2.6.7 基底クラスの名前を変えやすいコードを書くにはどうしますか？
...................................................................

基底クラスをエイリアス (alias) に代入しておいてから、そのエイリアスを継
承するといいかもしれません。そうすればエイリアスに代入する値を変えるだけ
で済みます。ちなみに、この手法は使用する基底クラスを動的に選びたいとき、
例えば使えるリソースによって選びたいときなどにも便利です。例:

     class Base:
         ...

     BaseAlias = Base

     class Derived(BaseAlias):
         ...


File: python.info,  Node: 静的なクラスデータや静的なクラスメソッドを作るにはどうしますか？,  Next: Python でコンストラクタ やメソッド をオーバーロードするにはどうしたらいいですか？,  Prev: 基底クラスの名前を変えやすいコードを書くにはどうしますか？,  Up: オブジェクト

10.2.6.8 静的なクラスデータや静的なクラスメソッドを作るにはどうしますか？
.........................................................................

(C++ や Java の意味で) 静的なデータも静的なメソッドも Python でサポート
されています。

静的なデータを作るには、単純にクラス属性を定義してください。その属性に新
しい値を代入するには、代入するクラス名を明示する必要があります:

     class C:
         count = 0   # number of times C.__init__ called

         def __init__(self):
             C.count = C.count + 1

         def getcount(self):
             return C.count  # or return self.count

‘c’ そのものや ‘c.__class__’ から ‘C’ にいたるパス探索経路上のクラスによ
ってオーバーライドされない限り、‘c.count’ も ‘isinstance(c, C)’ であるす
べての ‘c’ に対する ‘C.count’ を参照します。

注意: C のメソッド内では、‘self.count = 42’ のような代入は ‘self’ 自身の
辞書に "count" という名前の新しくて関係ないインスタンスを作ります。クラ
スの静的なデータの再束縛には、メソッド内であるか否かにかかわらず、いつも
クラスを指定しなければなりません:

     C.count = 314

静的メソッドが使えます:

     class C:
         @staticmethod
         def static(arg1, arg2, arg3):
             # No 'self' parameter!
             ...

しかし、静的メソッドの効果を得るもっと簡単な方法は、単にモジュールレベル
関数を使うことです:

     def getcount():
         return C.count

モジュールあたりに一つのクラスを定義するように (あるいはクラス組織を厳密
に関連させるように) コードが構成されているなら、これで必要なカプセル化が
できます。


File: python.info,  Node: Python でコンストラクタ やメソッド をオーバーロードするにはどうしたらいいですか？,  Next: __spam を使おうとしたら _SomeClassName__spam からエラーがでました。,  Prev: 静的なクラスデータや静的なクラスメソッドを作るにはどうしますか？,  Up: オブジェクト

10.2.6.9 Python でコンストラクタ(やメソッド)をオーバーロードするにはどうしたらいいですか？
..........................................................................................

この質問の答えはすべてのメソッドについて言えることですが、この質問はだい
たい以下の構造の文脈から出てきます。

C++ では、このように書けます

     class C {
         C() { cout << "No arguments\n"; }
         C(int i) { cout << "Argument is " << i << "\n"; }
     }

Python では、一つのコンストラクタでデフォルトの引数を使ってすべての場合
に対応するように書かなければなりません。例えば:

     class C:
         def __init__(self, i=None):
             if i is None:
                 print("No arguments")
             else:
                 print("Argument is", i)

これで完全に等価とは言えませんが、実用上は十分に近いです。

長さが変えられる引数のリストを試すには、例えば

     def __init__(self, *args):
         ...

これと同じやり方がすべてのメソッド定義で使えます。


File: python.info,  Node: __spam を使おうとしたら _SomeClassName__spam からエラーがでました。,  Next: クラスに __del__ メソッドを定義しているのですが、オブジェクトを削除したときに呼ばれません。,  Prev: Python でコンストラクタ やメソッド をオーバーロードするにはどうしたらいいですか？,  Up: オブジェクト

10.2.6.10 __spam を使おうとしたら _SomeClassName__spam からエラーがでました。
.............................................................................

先頭にアンダースコアが二つ付いた変数名は、クラスのプライベートな変数を、
"マングル化" という単純かつ効率のいい方法で定義します。‘__spam’ のような
形式 (先頭に二つ以上、末尾にもしあっても一つのアンダースコアがある) のす
べての識別子は、‘classname’ が先頭のアンダースコアをすべて削除した現在の
クラス名とすれば、‘_classname__spam’ のように文字上で置換えられます。

The identifier can be used unchanged within the class, but to access it
outside the class, the mangled name must be used:

     class A:
         def __one(self):
             return 1
         def two(self):
             return 2 * self.__one()

     class B(A):
         def three(self):
             return 3 * self._A__one()

     four = 4 * A()._A__one()

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.

参考
....

詳細と特例は、 *note private name mangling specifications: 1c24. 。


File: python.info,  Node: クラスに __del__ メソッドを定義しているのですが、オブジェクトを削除したときに呼ばれません。,  Next: 与えられたクラスのすべてのインスタンスのリストを得るにはどうしますか？,  Prev: __spam を使おうとしたら _SomeClassName__spam からエラーがでました。,  Up: オブジェクト

10.2.6.11 クラスに __del__ メソッドを定義しているのですが、オブジェクトを削除したときに呼ばれません。
.....................................................................................................

いくつかの可能性があります。

*note del: 1711. 文は必ずしも *note __del__(): 1ec1. を呼び出すとは限り
ません - これは単純にオブジェクトの参照カウントを減らすもので、カウント
がゼロになったときに ‘__del__()’ が呼び出されます。

データ構造が循環リンク (子のそれぞれが親の参照を持ち、親のそれぞれが子の
リストを持つツリーなど) を含む場合、その参照カウントは決して 0 にはなり
ません。時々、Python はこのようなサイクルを検出するアルゴリズムを実行し
ますが、データ構造への参照がなくなってからこのガベージコレクタが実行され
るまでいくらか時間が掛かるかもしれないので、 ‘__del__()’ メソッドは不都
合な予期できないタイミングで呼び出されるかもしれません。これは問題を再現
しようとするときに不便です。さらに悪いことに、オブジェクトの ‘__del__()’
メソッドが実行される順序は任意です。 *note gc.collect(): a08. を起動して
収集を強制することができますが、オブジェクトが決して回収されないような本
当に病的な場合も 'あります' 。

循環参照コレクタがあるとはいえ、オブジェクトに ‘close()’ メソッドを明示
的に定義し、使い終わったらいつでも呼び出せるようにするのはいいことです。
‘close()’ メソッドを使うと、サブオブジェクトを参照している属性を取り除け
ます。 ‘__del__()’ を直接呼び出さないでください - ‘__del__()’ は
‘close()’ を呼び出すでしょうし、 ‘close()’ なら同じオブジェクトに対して
複数回呼ばれてもいいことが保証されているでしょう。

循環参照を避ける他の方法は、 *note weakref: fc. モジュールを使って、参照
カウントを増やすことなくオブジェクトを示すことです。例えばツリー構造は、
親と (必要なら！) 兄弟に弱参照を使うべきです。

最後に、 ‘__del__()’ メソッドが例外を発生させた場合、警告のメッセージが
*note sys.stderr: 907. に書きこまれます。


File: python.info,  Node: 与えられたクラスのすべてのインスタンスのリストを得るにはどうしますか？,  Next: なぜ id の結果は一意でないように見えるのですか?,  Prev: クラスに __del__ メソッドを定義しているのですが、オブジェクトを削除したときに呼ばれません。,  Up: オブジェクト

10.2.6.12 与えられたクラスのすべてのインスタンスのリストを得るにはどうしますか？
................................................................................

Python はクラス (やビルトイン型) のすべてのインスタンスをたどりません。
クラスのコンストラクタにそれぞれのインスタンスへの弱参照のリストを作らせ
ることですべてのインスタンスをたどらせられます。


File: python.info,  Node: なぜ id の結果は一意でないように見えるのですか?,  Next: いつ is 演算子での同一性テストが頼れますか？,  Prev: 与えられたクラスのすべてのインスタンスのリストを得るにはどうしますか？,  Up: オブジェクト

10.2.6.13 なぜ ‘id()’ の結果は一意でないように見えるのですか?
.............................................................

組み込みの *note id(): 13ca. は、オブジェクトが生存している間は一意なこ
とが保証されている整数値を返します。 CPython では、それはオブジェクトの
メモリアドレスなので、オブジェクトがメモリから削除された後に、次に新しく
生成されたオブジェクトはメモリの同じ場所にメモリ領域を確保されていること
が、しばしば起きます。この現象を次の例で示しましょう:

     >>> id(1000)
     13901272
     >>> id(2000)
     13901272

2 つの同じ値を持つ id は ‘id()’ の実行の前に作られてすぐさま削除された異
なる整数オブジェクトによるものです。id を調べたいオブジェクトがまだ生き
てることを保証したいなら、オブジェクトへの別の参照を作ってください:

     >>> a = 1000; b = 2000
     >>> id(a)
     13901272
     >>> id(b)
     13891296


File: python.info,  Node: いつ is 演算子での同一性テストが頼れますか？,  Next: どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御できますか？,  Prev: なぜ id の結果は一意でないように見えるのですか?,  Up: オブジェクト

10.2.6.14 いつ 'is' 演算子での同一性テストが頼れますか？
........................................................

‘is’ 演算子はオブジェクトの同一性をテストします。 テスト ‘a is b’ は
‘id(a) == id(b)’ と同等です。

同一性テストの最も重要な特性は、オブジェクトは常にそれ自身と同一であり、
‘a is a’ は常に ‘True’ を返すということです。 同一性テストは通常、等価性
テストよりも高速です。 また、等価性テストとは異なり、同一性テストは真偽
値 ‘True’ または''False'' を返すことが保証されています。

ただし、同一性テストを等価性テストの代用とできるのは、オブジェクトの同一
性が保証されている場合 'のみ' です。 一般的に、同一性が保証される状況は
3つあります:

1） 代入は新しい名前を作りますが、オブジェクトIDは変えません。 ‘new =
old’ 代入の後、 ‘new is old’ が保証されます。

2） オブジェクト参照を格納するコンテナにオブジェクトを入れても、オブジェ
クトIDは変わりません。 ‘s[0] = x’ リスト代入の後、 ‘s[0] is x’ が保証さ
れます。

3） オブジェクトがシングルトンなら、それはそのオブジェクトのインスタンス
は１つだけ存在できることを意味します。 ‘a = None’ と ‘b = None’ 代入の後
、 ‘a is b’ が保証されます。‘None’ がシングルトンのためです。

多くの他の状況では、同一性テストは賢明でなく、等価性テストをお勧めします
。 特に、シングルトンであることが保証されていない *note int: 238. や
*note str: 418. などの定数をチェックするために同一性テストを使わないでく
ださい。

     >>> a = 1000
     >>> b = 500
     >>> c = b + 500
     >>> a is c
     False

     >>> a = 'Python'
     >>> b = 'Py'
     >>> c = b + 'thon'
     >>> a is c
     False

同様に、ミュータブルなコンテナの新しいインスタンスは同一ではありません:

     >>> a = []
     >>> b = []
     >>> a is b
     False

標準ライブラリのコードには、同一性テストを正しく使うための一般的なパター
ンがあります:

1） PEP 8(1) で推奨されるように、同一性テストは ‘None’ のチェックの良い
方法です。 コードの中で平易な英語のように読めますし、 false と評価される
真偽値を持ちうる他のオブジェクトとの混同を避けます。

2） ‘None’ が有効な入力値である場合、省略された引数を検出にはコツがいり
ます。 そのような状況では、他のオブジェクトと区別されることが保証された
シングルトンの番兵オブジェクトを作れます。 例えば、これは *note
dict.pop(): 31c. のように振る舞うメソッドを実装する方法です:

     _sentinel = object()

     def pop(self, key, default=_sentinel):
         if key in self:
             value = self[key]
             del self[key]
             return value
         if default is _sentinel:
             raise KeyError(key)
         return default

3） コンテナの実装では、等価性テストを同一性テストで補強しないといけない
場合があります。 これは、 ‘float('NaN')’ のような自分自身と等価でないオ
ブジェクトによってコードが混乱するのを防ぐためです。

例えば、これは ‘collections.abc.Sequence.__contains__()’: の実装です:

     def __contains__(self, value):
         for v in self:
             if v is value or v == value:
                 return True
         return False

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0008/


File: python.info,  Node: どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御できますか？,  Next: メソッド呼び出しをキャッシュするには どうしたらいいですか？,  Prev: いつ is 演算子での同一性テストが頼れますか？,  Up: オブジェクト

10.2.6.15 どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御できますか？
................................................................................................

イミュータブル型をサブクラス化する場合、 *note __init__(): 67c. ではなく
*note __new__(): 54c. メソッドを継承します。 前者はインスタンスが生成さ
れた '後' に動くため、イミュータブルなインスタンスのデータを変えるには遅
すぎます。

これらのイミュータブルクラスはすべて、親クラスと異なるシグネチャを持ちま
す:

     from datetime import date

     class FirstOfMonthDate(date):
         "Always choose the first day of the month"
         def __new__(cls, year, month, day):
             return super().__new__(cls, year, month, 1)

     class NamedInt(int):
         "Allow text names for some numbers"
         xlat = {'zero': 0, 'one': 1, 'ten': 10}
         def __new__(cls, value):
             value = cls.xlat.get(value, value)
             return super().__new__(cls, value)

     class TitleStr(str):
         "Convert str to name suitable for a URL path"
         def __new__(cls, s):
             s = s.lower().replace(' ', '-')
             s = ''.join([c for c in s if c.isalnum() or c == '-'])
             return super().__new__(cls, s)

クラスはこのように使えます:

     >>> FirstOfMonthDate(2012, 2, 14)
     FirstOfMonthDate(2012, 2, 1)
     >>> NamedInt('ten')
     10
     >>> NamedInt(20)
     20
     >>> TitleStr('Blog: Why Python Rocks')
     'blog-why-python-rocks'


File: python.info,  Node: メソッド呼び出しをキャッシュするには どうしたらいいですか？,  Prev: どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御できますか？,  Up: オブジェクト

10.2.6.16 メソッド呼び出しをキャッシュするには どうしたらいいですか？
.....................................................................

メソッドキャッシュの主な道具は２つあり、 *note
functools.cached_property(): 50c. と *note functools.lru_cache(): 9bd. で
す。前者はインスタンスレベル、後者はクラスレベルで結果を保存します。

'cached_property' アプローチは、引数を取らないメソッドでのみ働きます。こ
れはインスタンスへの参照を作りません。キャッシュされたメソッドの結果は、
インスタンスが生きている間だけ保持されます。

利点は、インスタンスが使われなくなった場合、キャッシュされたメソッドの結
果がすぐに解放されることです。欠点は、インスタンスが溜まると、溜められた
メソッドの結果も増えてしまうことです。それらは際限なく増える恐れがありま
す。

'lru_cache' アプローチは、 *note hashable: 5db. な引数を持つメソッドで働
きます。 weak references を渡すための特別な努力がない限り、インスタンス
への参照を作ります。

least recently used アルゴリズム（訳注：LRU 直近に使われたものを残す）の
利点は、キャッシュが指定された 'maxsize' で制限されることです。欠点は、
キャッシュから期限切れで追い出されるかクリアされるまで、インスタンスが生
き続けることです。

この例は各種テクニックを示します:

     class Weather:
         "Lookup weather information on a government website"

         def __init__(self, station_id):
             self._station_id = station_id
             # The _station_id is private and immutable

         def current_temperature(self):
             "Latest hourly observation"
             # Do not cache this because old results
             # can be out of date.

         @cached_property
         def location(self):
             "Return the longitude/latitude coordinates of the station"
             # Result only depends on the station_id

         @lru_cache(maxsize=20)
         def historic_rainfall(self, date, units='mm'):
             "Rainfall on a given date"
             # Depends on the station_id, date, and units.

上の例では、 'station_id' が常に変わらないことを前提としています。関連す
るインスタンスの属性が可変である場合、 'cached_property' アプローチは属
性の変更を検出できないため、機能しなくなります。

'station_id' が可変の場合に 'lru_cache' アプローチを機能させるには、クラ
スで *note __eq__(): ac8. と *note __hash__(): ac9. メソッドを定義する必
要があります。これにより、キャッシュは関連する属性の更新を検出できます:

     class Weather:
         "Example with a mutable station identifier"

         def __init__(self, station_id):
             self.station_id = station_id

         def change_station(self, station_id):
             self.station_id = station_id

         def __eq__(self, other):
             return self.station_id == other.station_id

         def __hash__(self):
             return hash(self.station_id)

         @lru_cache(maxsize=20)
         def historic_rainfall(self, date, units='cm'):
             'Rainfall on a given date'
             # Depends on the station_id, date, and units.


File: python.info,  Node: モジュール<5>,  Prev: オブジェクト,  Up: プログラミング FAQ

10.2.7 モジュール
-----------------

* Menu:

* .pyc ファイルを作るにはどうしますか？: pyc ファイルを作るにはどうしますか？.
* 現在のモジュール名を知るにはどうしますか？::
* 相互にインポートしあうモジュールを作るにはどうしたらいいですか？::
* __import__('x.y.z') は <module 'x'> を返しますが、z を得るためにはどうしますか？: __import__ 'x y z' は <module 'x'> を返しますが、z を得るためにはどうしますか？.
* インポートされたモジュールを編集してから再インポートしましたが、変化が現れません。なぜですか？::


File: python.info,  Node: pyc ファイルを作るにはどうしますか？,  Next: 現在のモジュール名を知るにはどうしますか？,  Up: モジュール<5>

10.2.7.1 .pyc ファイルを作るにはどうしますか？
..............................................

モジュールが初めてインポートされたとき (もしくは、現在のコンパイルされた
ファイルが作られてから、ソースファイルが変更されたとき) 、コンパイルされ
たコードが入っている ‘.pyc’ ファイルが、 ‘.py’ ファイルのあるディレクト
リのサブディレクトリ ‘__pycache__’ に作成されます。 ‘.pyc’ ファイルのフ
ァイル名は、 ‘.py’ ファイルの名前で始まり、 ‘.pyc’ で終わり、中間部分は
このファイルを作った ‘python’ バイナリに依存した文字列になります。 (詳細
は PEP 3147(1) を参照してください。)

‘.pyc’ が作られない理由の 1 つは、ソースファイルがあるディレクトリの権限
の問題、つまり ‘__pycache__’ サブディレクトリが作れない問題です。これは
、例えば、ウェブサーバーでテストを行っているときのような、開発者のユーザ
と実行者のユーザが別な場合に、起こり得ます。

*note PYTHONDONTWRITEBYTECODE: 1376. 環境変数がセットされない限り、モジ
ュールをインポートしていて、 Python に ‘__pycache__’ サブディレクトリを
作り、そこにコンパイルされたモジュールが置ける能力 (権限、ディスクの空き
スペース、など) がある場合は、 .pyc ファイルは自動的に作られます。

最上位のスクリプトを Python で実行するのはインポートとはみなされず、
‘.pyc’ は作成されません。例えば、最上位のモジュール ‘foo.py’ が別のモジ
ュール ‘xyz.py’ をインポートしている場合、(シェルコマンドとして ‘python
foo.py’ と打ち込んで) ‘foo’ を実行すると、‘xyz’ はインポートされるので
‘xyz’ の ‘.pyc’ は作成されますが、‘foo.py’ はインポートされたわけではな
いので ‘foo’ の ‘.pyc’ は作られません。

‘foo’ の ‘.pyc’ ファイルを作成する - つまり、インポートされていないモジ
ュールの ‘.pyc’ ファイルを作成する - 必要がある場合、 *note py_compile:
a1. モジュールと *note compileall: 19. モジュールを使えば可能です。

*note py_compile: a1. モジュールは手動で任意のモジュールをコンパイルでき
ます。やり方の一つは、このモジュールの ‘compile()’ 関数をインタラクティ
ブに実行することです:

     >>> import py_compile
     >>> py_compile.compile('foo.py')

このように実行すると、‘foo.py’ と同じ場所の ‘__pycache__’ サブディレクト
リに ‘.pyc’ が書き出されます (出力ファイルの位置は、オプション引数
‘cfile’ で上書きすることもできます)。

*note compileall: 19. モジュールを使えば自動的に一つや複数のディレクトリ
のすべてのファイルをコンパイルできます。シェルプロンプトから
‘compileall.py’ を起動して、コンパイルしたいファイルを含むディレクトリの
パスを指定してください:

     python -m compileall .

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-3147/


File: python.info,  Node: 現在のモジュール名を知るにはどうしますか？,  Next: 相互にインポートしあうモジュールを作るにはどうしたらいいですか？,  Prev: pyc ファイルを作るにはどうしますか？,  Up: モジュール<5>

10.2.7.2 現在のモジュール名を知るにはどうしますか？
...................................................

モジュールは前もって定義されたグローバル変数 ‘__name__’ を検索することで
自身の名前を決定できます。この値が ‘'__main__'’ であるとき、そのプログラ
ムはスクリプトとして実行されています。インポートされることによって使われ
る大抵のモジュールはコマンドラインインターフェースや自己テストも提供して
いて、‘__name__’ をチェックしてからそのコードだけを実行します:

     def main():
         print('Running test...')
         ...

     if __name__ == '__main__':
         main()


File: python.info,  Node: 相互にインポートしあうモジュールを作るにはどうしたらいいですか？,  Next: __import__ 'x y z' は <module 'x'> を返しますが、z を得るためにはどうしますか？,  Prev: 現在のモジュール名を知るにはどうしますか？,  Up: モジュール<5>

10.2.7.3 相互にインポートしあうモジュールを作るにはどうしたらいいですか？
.........................................................................

以下のモジュールがあったとしましょう:

‘foo.py’:

     from bar import bar_var
     foo_var = 1

‘bar.py’:

     from foo import foo_var
     bar_var = 2

問題はインタプリタが以下の段階を実行することです:

   * main が ‘foo’ をインポートする

   * ‘foo’ の空のグローバルが生成される

   * ‘foo’ がコンパイルされ実行を始める

   * ‘foo’ が ‘bar’ をインポートする

   * ‘bar’ の空のグローバルが生成される

   * ‘bar’ がコンパイルされ実行を始める

   * ‘bar’ が ‘foo’ をインポートする(すでに ‘foo’ という名前のモジュール
     があるので no-op となる)

   * インポートメカニズムは ‘foo’ のグローバルから ‘foo_var’ を読んで、
     ‘bar.foo_var = foo.foo_var’ に設定しようとします。

この最後の段階は失敗します。Python が ‘foo’ を解釈し終わっていなくて、
‘foo’ のグローバルなシンボルの辞書はまだ空ですから。

‘import foo’ を使って、グローバルコードの ‘foo.foo_var’ にアクセスしよう
としたときにも、これと同じことが起こります。

この問題には (少なくとも) 三つの解決策があります。

Guido van Rossum は ‘from <module> import ...’ を全く使わないで、すべて
のコードを関数の中に入れることを勧めています。グローバル変数とクラス変数
の初期化は定数とビルトイン関数のみで行われるべきです。これでインポートさ
れたすべてのモジュールは ‘<module>.<name>’ として参照されることになりま
す。

Jim Roskind はそれぞれのモジュールに対して以下の順に進めることを提案して
います:

   * エクスポート (インポートされた基底クラスを必要としないグローバル、
     関数、クラス)

   * ‘import’ 文

   * アクティブなコード (インポートされた値によって初期化されるグローバ
     ルを含む)。

インポートが奇妙な場所に現れることから Van Rossum はこの方法をそれほど好
みませんが、これは有効です。

Matthias Urlichs は第一に再帰インポートが必要ないようにコードを構築しな
おすことを推奨しています。

これらの解決策はそれぞれ両立させることもできます。


File: python.info,  Node: __import__ 'x y z' は <module 'x'> を返しますが、z を得るためにはどうしますか？,  Next: インポートされたモジュールを編集してから再インポートしましたが、変化が現れません。なぜですか？,  Prev: 相互にインポートしあうモジュールを作るにはどうしたらいいですか？,  Up: モジュール<5>

10.2.7.4 __import__('x.y.z') は <module 'x'> を返しますが、z を得るためにはどうしますか？
.........................................................................................

*note importlib: 6b. に *note import_module(): 4e1. という便利な関数があ
るので、代わりにそちらを使用することを検討してください。

     z = importlib.import_module('x.y.z')


File: python.info,  Node: インポートされたモジュールを編集してから再インポートしましたが、変化が現れません。なぜですか？,  Prev: __import__ 'x y z' は <module 'x'> を返しますが、z を得るためにはどうしますか？,  Up: モジュール<5>

10.2.7.5 インポートされたモジュールを編集してから再インポートしましたが、変化が現れません。なぜですか？
.......................................................................................................

効率と一貫性上の理由から、Python はモジュールが最初にインポートされた時
にのみモジュールファイルを読み込みます。そうしないと、たくさんのモジュー
ルでできていて、それぞれが同じ基本モジュールをインポートしているようなプ
ログラムでは、その基本モジュールの解析と再解析が繰り返されることになりま
す。変更されさたモジュールの再読込を強制するには、こうしてください:

     import importlib
     import modname
     importlib.reload(modname)

注意:この手法は 100%安全とは言えません。とりわけ

     from modname import some_objects

のような文を含むモジュールは、インポートされたオブジェクトの古いバージョ
ンを使い続けます。そのモジュールにクラス定義が含まれていたら、存在するク
ラスインスタンスは新しいクラス定義を使うようにアップデート 'されません
'。これによって以下の矛盾した振舞いがなされえます:

     >>> import importlib
     >>> import cls
     >>> c = cls.C()                # Create an instance of C
     >>> importlib.reload(cls)
     <module 'cls' from 'cls.py'>
     >>> isinstance(c, cls.C)       # isinstance is false?!?
     False

この問題の本質は、クラスオブジェクトの "固有値" を印字することで明らかに
なります:

     >>> hex(id(c.__class__))
     '0x7352a0'
     >>> hex(id(cls.C))
     '0x4198d0'


File: python.info,  Node: デザインと歴史 FAQ,  Next: ライブラリと拡張 FAQ,  Prev: プログラミング FAQ,  Up: Python よくある質問

10.3 デザインと歴史 FAQ
=======================

* Menu:

* Python はなぜ文のグループ化にインデントを使うのですか？::
* なぜ単純な算術演算が奇妙な結果になるのですか？::
* なぜ浮動小数点数の計算はこんなに不正確なんですか？::
* なぜ Python の文字列はイミュータブルなのですか？::
* なぜメソッドの定義や呼び出しにおいて 'self' を明示しなければならないのですか？::
* 式中で代入ができないのはなぜですか？::
* Python にメソッドを使う機能 (list.index() 等) と関数を使う機能 (len(list) 等) があるのはなぜですか？: Python にメソッドを使う機能 list index 等 と関数を使う機能 len list 等 があるのはなぜですか？.
* join() がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？: join がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？.
* 例外はどれくらい速いのですか？::
* Python に switch や case 文がないのはなぜですか？::
* OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？::
* なぜラムダ式は文を含むことができないのですか?::
* Python は C やその他の言語のように機械語にコンパイルできますか？::
* Python はメモリをどのように管理するのですか？::
* CPython はなぜ伝統的なガベージコレクションスキームを使わないのですか？::
* なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか？::
* なぜタプルとリストという別のデータ型が用意されているのですか？::
* CPythonでリストはどのように実装されているのですか？::
* CPythonで辞書はどのように実装されていますか？::
* なぜ辞書のキーはイミュータブルでなくてはならないのですか？::
* なぜ list.sort() はソートされたリストを返さないのですか？: なぜ list sort はソートされたリストを返さないのですか？.
* Python ではどのようにインターフェース仕様を特定し適用するのですか？::
* なぜ goto が無いのですか？::
* なぜ raw 文字列 (r-strings) はバックスラッシュで終わってはいけないのですか？: なぜ raw 文字列 r-strings はバックスラッシュで終わってはいけないのですか？.
* 属性の代入に "with" 文が使えないのはなぜですか？::
* なぜジェネレータは with 文をサポートしないのですか？::
* if/while/def/class 文にコロンが必要なのはなぜですか？::
* なぜ Python ではリストやタプルの最後にカンマがあっても良いのですか？::


File: python.info,  Node: Python はなぜ文のグループ化にインデントを使うのですか？,  Next: なぜ単純な算術演算が奇妙な結果になるのですか？,  Up: デザインと歴史 FAQ

10.3.1 Python はなぜ文のグループ化にインデントを使うのですか？
--------------------------------------------------------------

Guido van Rossum の信じるところによれば、インデントによるグループ化は非
常にエレガントで、普通の Python プログラムを大いに読みやすくします。しば
らくすればほとんどの人はこの仕様を気に入るようになります。

開始/終了の括弧がないので、構文解析器と人間の読者の間にグループ化の解釈
の違いは起こりえません。時折、C のプログラマはこのようなコード片に出くわ
します:

     if (x <= y)
             x++;
             y--;
     z++;

条件式が真のとき、 ‘x++’ 行のみが実行されます。しかしインデントによって
、多くの人が別のことを考えてしまいます。経験豊富なCプログラマでさえ、 ‘x
> y’ なのに ‘y’ がデクリメントされるのはなぜだろうと、このコードをしばら
く凝視することがあります。

Python は開始/終了の括弧がないので、コーディングスタイルの争いに余り影響
されません。C言語では中括弧の置き方についてさまざまな流儀があります。特
定のスタイルを使ってコードを読み書きするのに慣れたあと、別のスタイルでコ
ードを読んだり(あるいは書く必要に迫られたり)するときに、何となく心配にな
るのはよくあることです。

多くのコーディングスタイルは begin/end の括弧にそれぞれ一行を使います。
これではプログラムは冗長になって画面を浪費し、プログラムの見通しが悪くな
ります。一つの関数は一画面 (例えば 20 から 30 行) に収めるのが理想です。
20 行の Python は 20 行の C よりもはるかに多くの作業ができます。これは
begin/end の括弧がないからだけではありません - 宣言が不要なことや高レベ
ルなデータ型もその理由です - が、インデントに基づく構文は確かに役に立っ
ています。


File: python.info,  Node: なぜ単純な算術演算が奇妙な結果になるのですか？,  Next: なぜ浮動小数点数の計算はこんなに不正確なんですか？,  Prev: Python はなぜ文のグループ化にインデントを使うのですか？,  Up: デザインと歴史 FAQ

10.3.2 なぜ単純な算術演算が奇妙な結果になるのですか？
-----------------------------------------------------

次の質問を参照してください。


File: python.info,  Node: なぜ浮動小数点数の計算はこんなに不正確なんですか？,  Next: なぜ Python の文字列はイミュータブルなのですか？,  Prev: なぜ単純な算術演算が奇妙な結果になるのですか？,  Up: デザインと歴史 FAQ

10.3.3 なぜ浮動小数点数の計算はこんなに不正確なんですか？
---------------------------------------------------------

ユーザーはよく次のような結果に驚きます:

     >>> 1.2 - 1.0
     0.19999999999999996

そしてこれが Python のバグだと考えます。が、これはバグではありません。こ
の結果に Python はほとんど関与しておらず、むしろ基底のプラットフォームに
よる浮動小数点数の扱い方が関与しています。

CPython における *note float: 2ce. 型は記憶に C 言語の ‘double’ 型を使い
ます。 *note float: 2ce. オブジェクトの値は固定精度 (典型的には 53 bit)
の 2 進浮動小数点数として格納され、 Python はプロセッサのハードウェアが
実装している C 言語上の演算を使います。つまり、浮動小数点数に関して
Python は C 言語や Java のような多くの一般的な言語と同じように振る舞いま
す。

Many numbers that can be written easily in decimal notation cannot be
expressed exactly in binary floating point.  For example, after:

     >>> x = 1.2

‘x’ に保存された値は 10 進数の ‘1.2’ の (とても高い精度の) 近似値であっ
て、厳密な ‘1.2’ ではありません。一般的なコンピューターでは、実際に格納
される値は:

     1.0011001100110011001100110011001100110011001100110011 (binary)

で、正確には次の値です:

     1.1999999999999999555910790149937383830547332763671875 (decimal)

53bit の典型的な精度は、Python の float に 10 進数で 15〜16桁の精度を与
えます。

For a fuller explanation, please see the *note floating-point
arithmetic: 1c7b. chapter in the Python tutorial.


File: python.info,  Node: なぜ Python の文字列はイミュータブルなのですか？,  Next: なぜメソッドの定義や呼び出しにおいて 'self' を明示しなければならないのですか？,  Prev: なぜ浮動小数点数の計算はこんなに不正確なんですか？,  Up: デザインと歴史 FAQ

10.3.4 なぜ Python の文字列はイミュータブルなのですか？
-------------------------------------------------------

これにはいくつかの利点があります。

一つはパフォーマンスです。文字列がイミュータブルなら、生成時に領域を割り
当てることができるので、必要な記憶域は固定されて、変更されません。これは
タプルとリストを区別する理由の一つでもあります。

他の利点は、Python の文字列は数と同じくらい "基本的" なものと考えられる
ことです。8 という値を他の何かに変える手段が無いように、文字列 "eight" を
他の何かに変える手段も無いのです。


File: python.info,  Node: なぜメソッドの定義や呼び出しにおいて 'self' を明示しなければならないのですか？,  Next: 式中で代入ができないのはなぜですか？,  Prev: なぜ Python の文字列はイミュータブルなのですか？,  Up: デザインと歴史 FAQ

10.3.5 なぜメソッドの定義や呼び出しにおいて 'self' を明示しなければならないのですか？
-------------------------------------------------------------------------------------

このアイデアは Modula-3 から取り入れられました。これは様々な理由からとて
も便利だと言えます。

まず、ローカル変数ではなく、メソッドやインスタンス属性を扱っていることが
より明確になります。 ‘self.x’ や ‘self.meth()’ と書いてあれば、そのクラ
スの定義を憶えていなくても、それがインスタンス変数やメソッドであることは
明らかです。C++ では、(グローバルが滅多になかったり、簡単に見分けがつく
なら) ローカル変数宣言がないことからある程度わかるでしょう。- しかし
Python にはローカル変数宣言がないので、クラス定義を調べて確かめなくては
なりません。C++ や Java のコーディングスタンダードに、インスタンス属性に
‘m_’ 接頭辞をつけるものがあるので、この明示性はそれらの言語においても有
用です。

第二に、特定のクラスからメソッドを明示的に参照または呼び出ししたい時に、
特別な構文が必要なくなります。C++ では、派生クラスでオーバーライドされた
基底クラスからメソッドを使うには、 ‘::’ 演算子を使わなければなりません。
- Python では、 ‘baseclass.methodname(self, <argument list>)’ と書けます
。これは特に、 *note __init__(): 67c. メソッドに便利ですし、派生クラスの
メソッドが、基底クラスにある同じ名前のメソッドを拡張するために、基底クラ
スのメソッドをどうにかして呼び出したい時にも便利です。

最後に、インスタンス変数に対する、代入の構文の問題を解決できます。Python
のローカル変数は、関数の中で (global が明示的に宣言されることなく) 値が
代入された変数 (と定義されています！) です。なので、ある代入が意図するの
が、ローカル変数へではなくインスタンス変数への代入であると、インタプリタ
が判断する手段が必要です。そしてそれは構文を見るだけで分かる方が (効率が
) 良いのです。C++ ではその区別を宣言時に行いますが、Python では宣言がな
いので、この方法でしか区別できなかったら残念です。 ‘self.var’ を明示すれ
ばうまく解決できます。同様に、インスタンス変数を使うのにも ‘self.var’ と
書かなければならないので、メソッドの中の self が付いていない名前への参照
は、そのインスタンスのディレクトリを検索するまでもなくローカル変数とわか
ります。別の言い方をすれば、ローカル変数とインスタンス変数は二つの異なる
名前空間に存在し、Python にどちらの名前空間を使うかを伝えなくてはならな
いのです。


File: python.info,  Node: 式中で代入ができないのはなぜですか？,  Next: Python にメソッドを使う機能 list index 等 と関数を使う機能 len list 等 があるのはなぜですか？,  Prev: なぜメソッドの定義や呼び出しにおいて 'self' を明示しなければならないのですか？,  Up: デザインと歴史 FAQ

10.3.6 式中で代入ができないのはなぜですか？
-------------------------------------------

Python 3.8 以降ならできるよ!

セイウチ演算子 ‘:=’ を使った代入式は、式の中で変数に代入します:

     while chunk := fp.read(200):
        print(chunk)

より詳しくは PEP 572(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0572/


File: python.info,  Node: Python にメソッドを使う機能 list index 等 と関数を使う機能 len list 等 があるのはなぜですか？,  Next: join がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？,  Prev: 式中で代入ができないのはなぜですか？,  Up: デザインと歴史 FAQ

10.3.7 Python にメソッドを使う機能 (list.index() 等) と関数を使う機能 (len(list) 等) があるのはなぜですか？
-----------------------------------------------------------------------------------------------------------

Guidoいわく：

     (a) 幾つかの演算では、接頭辞は接尾辞よりも単純に読みやすいからです
     。接頭辞（そして接中辞！）による演算は数学において長い歴史があり、
     そこでは課題に対する数学者の思考を視覚的に助けるような記法が好まれ
     ます。x*(a+b)をx*a + x*bに書き換える容易さと、それと同じことを純粋
     なオブジェクト指向の記法で行う煩わしさを比較してみてください。

     (b) len(x)というコードを読んだ時、私はそれが何かの長さを問うている
     のだなと知ることができます。これは私に2つの事を知らせています。一つ
     は結果が整数であること、そして引数は何らかのコンテナであることです
     。対して、x.len()を目にした場合、私はその時点でxが何らかのコンテナ
     であり、それが標準のlen()を持っているクラスを継承しているか、インタ
     ーフェースを実装していることを知っている必要があります。mappingを実
     装していないクラスがget()やkeys()メソッドを持っていたり、fileでない
     何かがwrite()メソッドを持っているような混乱は時折見かけます。

-- ‘https://mail.python.org/pipermail/python-3000/2006-November/004643.html’


File: python.info,  Node: join がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？,  Next: 例外はどれくらい速いのですか？,  Prev: Python にメソッドを使う機能 list index 等 と関数を使う機能 len list 等 があるのはなぜですか？,  Up: デザインと歴史 FAQ

10.3.8 join() がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？
----------------------------------------------------------------------------------

文字列は Python 1.6 から他の標準型に大きく近づきました。それ以前は常に
string モジュールの関数を使ってできていたことと同等の機能を持つメソッド
がこの時に追加されました。その新しいメソッドの多くは広く受け入れられまし
たが、一部のプログラマに不快を感じさせていると思われるものがこれで:

     ", ".join(['1', '2', '4', '8', '16'])

結果はこうなります:

     "1, 2, 4, 8, 16"

この使い方には二つの議論があります。

一つ目は、「文字列リテラル (文字列定数) のメソッドを使うのは醜すぎる」と
いうようなものです。確かにそうかも知れませんが、文字列リテラルは単なる固
定された値に過ぎないというのが答えです。文字列に束縛された名前にメソッド
が許されるなら、リテラルに使えないようにする論理的な理由はないでしょう。

二つ目の反対理由は、典型的には「私は実際、要素を文字列定数とともに結合さ
せるよう、シーケンスに命じているのだ」というものです。残念ながら、そうで
はないのです。いくつかの理由から *note split(): e73. を文字列のメソッド
としておいた方がはるかに簡単です。これを見ると分かりやすいでしょう

     "1, 2, 4, 8, 16".split(", ")

これは文字列リテラルに対する、与えられたセパレータ (または、デフォルトで
は任意の空白文字の連続) で区切られた部分文字列を返せという指示です。

*note join(): 2110. は、セパレータ文字列に、文字列のシーケンスをイテレー
トして隣り合う要素の間に自身を挿入するように指示しているので、文字列のメ
ソッドです。このメソッドは、独自に定義された新しいクラスを含め、シーケン
スの規則を満たすいかなる引数にも使えます。バイト列やバイト配列にも同様の
メソッドがあります。


File: python.info,  Node: 例外はどれくらい速いのですか？,  Next: Python に switch や case 文がないのはなぜですか？,  Prev: join がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？,  Up: デザインと歴史 FAQ

10.3.9 例外はどれくらい速いのですか？
-------------------------------------

*note try: 6b4./*note except: 170. ブロックは例外が送出されなければ極端
に効率的です。実際に例外を捕捉するのは高価です。Python 2.0 より前のバー
ジョンでは、このイディオムを使うのが一般的でした:

     try:
         value = mydict[key]
     except KeyError:
         mydict[key] = getvalue(key)
         value = mydict[key]

これは、辞書がほとんどの場合にキーを持っていると予想できるときにのみ意味
をなします。そうでなければ、このように書きます:

     if key in mydict:
         value = mydict[key]
     else:
         value = mydict[key] = getvalue(key)

この特殊な場合では ‘value = dict.setdefault(key, getvalue(key))’ も使え
ますが、これは ‘getvalue()’ 呼び出しが十分安価な場合に限ります。なぜなら
それが全ての場合に評価されるからです。


File: python.info,  Node: Python に switch や case 文がないのはなぜですか？,  Next: OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？,  Prev: 例外はどれくらい速いのですか？,  Up: デザインと歴史 FAQ

10.3.10 Python に switch や case 文がないのはなぜですか？
---------------------------------------------------------

一般的に、構造化された switch 文は、式が特定の値または値の集合を持つとき
、１つのコードブロックを実行します。 Python 3.10 以降では、リテラル値や
名前空間内の定数を、 ‘match ... case’ 文で簡単にマッチさせることができま
す。より古い手段は一連の ‘if... elif... elif... else’ です。

非常に大きな数の選択肢から選ぶとき、値を呼び出す関数に対応づける辞書を作
れます。例えば:

     functions = {'a': function_1,
                  'b': function_2,
                  'c': self.method_1}

     func = functions[value]
     func()

オブジェクトのメソッドを呼び出すには、さらに単純に *note getattr(): b9f.
組み込み関数で特定の名前のメソッドを検索できます:

     class MyVisitor:
         def visit_a(self):
             ...

         def dispatch(self, value):
             method_name = 'visit_' + str(value)
             method = getattr(self, method_name)
             method()

メソッドの名前にこの例の ‘visit_’ のような接頭辞を使うことを勧めます。こ
のような接頭辞がないと、信頼できないソースから値が与えられたときに、オブ
ジェクトの任意のメソッドを呼び出す攻撃をされる可能性があります。

C の switch-case-default のような、フォールスルーのある switch を模倣す
ることもできますが、はるかに難しいうえに必要性も少ないでしょう。


File: python.info,  Node: OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？,  Next: なぜラムダ式は文を含むことができないのですか?,  Prev: Python に switch や case 文がないのはなぜですか？,  Up: デザインと歴史 FAQ

10.3.11 OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？
-------------------------------------------------------------------------------------------------------

答 1: 残念なことに、インタプリタは Python のスタックフレームごとに少なく
とも一つの C のスタックフレームを push します。同様に、拡張もほとんどラ
ンダムなときに Python にコールバックすることがあります。よって、完全なス
レッド実装には C のスレッドサポートが必要です。

答 2: 幸運なことに、Stackless Python(1) があります。これは完全に再デザイ
ンされたインタープリタで、Cのスタックを回避しています。

   ---------- Footnotes ----------

   (1) https://github.com/stackless-dev/stackless/wiki


File: python.info,  Node: なぜラムダ式は文を含むことができないのですか?,  Next: Python は C やその他の言語のように機械語にコンパイルできますか？,  Prev: OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？,  Up: デザインと歴史 FAQ

10.3.12 なぜラムダ式は文を含むことができないのですか?
-----------------------------------------------------

Python のラムダ式が文を含むことができないのは、Python の文法的な枠組みが
式の中にネストされた文を扱うことができないからです。しかし、Python では
、これは深刻な問題ではありません。他の言語のラムダに機能が追加されている
のと違い、Python のラムダは単なる、関数を定義するのが面倒すぎる場合のた
めの簡略な記法に過ぎないのです。

関数は既に Python の第一級オブジェクトで、ローカルスコープ内で宣言できま
す。従って、ローカルで定義された関数ではなくラムダを使う利点は、関数の名
前を考える必要が無いことだけです - しかし、(ラムダ式が生み出すオブジェク
トと厳密に同じ型の) 関数オブジェクトが代入される先はただのローカル変数で
す！


File: python.info,  Node: Python は C やその他の言語のように機械語にコンパイルできますか？,  Next: Python はメモリをどのように管理するのですか？,  Prev: なぜラムダ式は文を含むことができないのですか?,  Up: デザインと歴史 FAQ

10.3.13 Python は C やその他の言語のように機械語にコンパイルできますか？
------------------------------------------------------------------------

Cython(1) compiles a modified version of Python with optional
annotations into C extensions.  Nuitka(2) is an up-and-coming compiler
of Python into C++ code, aiming to support the full Python language.

   ---------- Footnotes ----------

   (1) https://cython.org/

   (2) https://nuitka.net/


File: python.info,  Node: Python はメモリをどのように管理するのですか？,  Next: CPython はなぜ伝統的なガベージコレクションスキームを使わないのですか？,  Prev: Python は C やその他の言語のように機械語にコンパイルできますか？,  Up: デザインと歴史 FAQ

10.3.14 Python はメモリをどのように管理するのですか？
-----------------------------------------------------

Python のメモリ管理の詳細は実装に依ります。Python の標準の C 実装 *note
CPython: 6c1. は参照カウントを使って、アクセスできないオブジェクトを探し
ます。また別のメカニズムを使って参照サイクルを集めます。これはサイクル検
出アルゴリズムを定期的に実行し、アクセスできないサイクルを探し、巻き込ま
れたオブジェクトを削除します。 *note gc: 56. モジュールの関数で、ガベー
ジコレクションを実行し、デバッグ統計を取得し、コレクタのパラメタを変更で
きます。

Other implementations (such as Jython(1) or PyPy(2)), however, can rely
on a different mechanism such as a full-blown garbage collector.  This
difference can cause some subtle porting problems if your Python code
depends on the behavior of the reference counting implementation.

Python の実装によっては、以下の (CPython では通る) コードはおそらく、フ
ァイルディスクリプタを使い果たすでしょう:

     for file in very_long_list_of_files:
         f = open(file)
         c = f.read(1)

実際、CPython の参照カウントとデストラクタのスキームを使えば ‘f’ への新
しい代入ごとにファイルは閉じられます。しかし、伝統的な GC を使うと、これ
らのファイルオブジェクトが回収され (て閉じられる) までに不定な、場合によ
っては長い、間隔が空くことがあります。

Python の実装に依らずに動くコードを書くには、ファイルを明示的に閉じるか
、 *note with: 59c. 文を使ってください。これでメモリ管理のスキームに関係
なく動きます:

     for file in very_long_list_of_files:
         with open(file) as f:
             c = f.read(1)

   ---------- Footnotes ----------

   (1) https://www.jython.org

   (2) https://pypy.org


File: python.info,  Node: CPython はなぜ伝統的なガベージコレクションスキームを使わないのですか？,  Next: なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか？,  Prev: Python はメモリをどのように管理するのですか？,  Up: デザインと歴史 FAQ

10.3.15 CPython はなぜ伝統的なガベージコレクションスキームを使わないのですか？
------------------------------------------------------------------------------

まず、それは C の標準的な機能ではないのでポータブルではありません。(確か
に Boehm GC ライブラリはあります。しかし、これにはアセンブリコードが含ま
れ、'ほとんどの' 有名なプラットフォームに対応していますが全てではありま
せん。また、ほとんど透過的ですが、完全に透過的ではありません。Python を
対応させるにはパッチが必要です。)

伝統的な GC は Python が他のアプリケーションに組み込まれるときにも問題と
なります。スタンドアロンの Python で動く限りでは、標準の ‘malloc()’ と
‘free()’ を GC ライブラリから提供されるものに置き換えても問題ありません
が、Python を実装したアプリケーションは Python のものではない '独自の' 代
替品を使おうとするかもしれません。現在のようにすることで、CPython は
‘malloc()’ と ‘free()’ が適切に実装されている限りどんなものにも対応させ
られます。


File: python.info,  Node: なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか？,  Next: なぜタプルとリストという別のデータ型が用意されているのですか？,  Prev: CPython はなぜ伝統的なガベージコレクションスキームを使わないのですか？,  Up: デザインと歴史 FAQ

10.3.16 なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか？
-------------------------------------------------------------------------------

Python モジュールのグローバルな名前空間から参照されるオブジェクトは、
Python の終了時にメモリの割り当てを解除されるとは限りません。これは、循
環参照があるときに起こりえます。解放できない C ライブラリ (例えば、
Purify のようなツールなどが当てはまります) によって割り当てられたいくら
かのメモリも含まれます。しかし、Python は終了時にメモリをクリーンアップ
することには積極的で、全ての単一のオブジェクトを破棄しようとします。

再割り当て時に Python が特定のものを削除するように強制したいときは、
*note atexit: 9. モジュールを使って削除を強制する関数を実行してください
。


File: python.info,  Node: なぜタプルとリストという別のデータ型が用意されているのですか？,  Next: CPythonでリストはどのように実装されているのですか？,  Prev: なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか？,  Up: デザインと歴史 FAQ

10.3.17 なぜタプルとリストという別のデータ型が用意されているのですか？
----------------------------------------------------------------------

リストとタプルは、多くの点で似ていますが、一般には本質的に異なる方法で使
われます。タプルは、Pascal の ‘レコード’ や C の　‘構造体’ と同様なもの
と考えられます。型が異なっても良い関連するデータの小さな集合で、グループ
として演算されます。例えば、デカルト座標は 2 つや 3 つの数のタプルとして
適切に表せます。

一方、リストは、もっと他の言語の配列に近いものです。全て同じ型の可変数の
オブジェクトを持ち、それらが一つ一つ演算される傾向にあります。例えば、
*note os.listdir('.'): 10cd. はカレントディレクトリ内にあるファイルの文
字列表現のリストを返します。この出力を演算する関数は一般に、ディレクトリ
に一つや二つの別のファイルを加えても壊れません。

タプルはイミュータブルなので、一度タプルが生成されたら、そのどの要素も新
しい値に置き換えられません。リストはミュータブルなので、リストの要素はい
つでも変更できます。イミュータブルな要素だけが辞書のキーとして使えるので
、リストではなくタプルだけがキーとして使えます。


File: python.info,  Node: CPythonでリストはどのように実装されているのですか？,  Next: CPythonで辞書はどのように実装されていますか？,  Prev: なぜタプルとリストという別のデータ型が用意されているのですか？,  Up: デザインと歴史 FAQ

10.3.18 CPythonでリストはどのように実装されているのですか？
-----------------------------------------------------------

CPythonのリストは実際に変数分の長さの配列で、Lispスタイルの連結リストで
はありません。この実装は他のオブジェクトへの参照の連続した配列を使用して
いて、この配列へのポインタおよび配列長はリストの先頭の構造体に保存されて
います。

これにより、リストのインデクシング ‘a[i]’ は、リストの大きさやインデクス
の値に依存しないコストで演算できます。

要素が追加または挿入されるとき、この参照の配列は大きさが変更されます。要
素追加の繰り返しのパフォーマンスを上げるために、少し工夫されています。配
列が大きくなるとき、次の何回かは実際に大きさを変更する必要がないように、
いくらかの追加の領域が割り当てられます。


File: python.info,  Node: CPythonで辞書はどのように実装されていますか？,  Next: なぜ辞書のキーはイミュータブルでなくてはならないのですか？,  Prev: CPythonでリストはどのように実装されているのですか？,  Up: デザインと歴史 FAQ

10.3.19 CPythonで辞書はどのように実装されていますか？
-----------------------------------------------------

CPython の辞書は大きさを変更できるハッシュテーブルとして実装されています
。B 木と比べて、ほとんどの条件下で (特に一般的な演算である) 探索のパフォ
ーマンスが良いですし、実装も単純です。

辞書は、辞書に保存されているそれぞれのキーに対応するハッシュコードを
*note hash(): 5b5. ビルトイン関数で計算することで機能します。このハッシ
ュコードはキーやプロセスごとのシードによって大きく変化します。例えば、
‘'Python'’ のハッシュ値は ‘-539294296’ ですが、ビットが一つ違うだけの文
字列 ‘'python'’ のハッシュ値は ‘1142331976’ です。そしてこのハッシュコー
ドは、値が保存される内部配列での位置を計算するために使われます。保存して
いるキーのハッシュ値が全て異なるとすれば、一定の時間 − Big-O 記法では
'O'(1) − でキーを検索できることになります。


File: python.info,  Node: なぜ辞書のキーはイミュータブルでなくてはならないのですか？,  Next: なぜ list sort はソートされたリストを返さないのですか？,  Prev: CPythonで辞書はどのように実装されていますか？,  Up: デザインと歴史 FAQ

10.3.20 なぜ辞書のキーはイミュータブルでなくてはならないのですか？
------------------------------------------------------------------

辞書のハッシュテーブルの実装は、キーを見つけるために、キー値から計算され
たハッシュ値を使います。もしキーがミュータブルなオブジェクトだったら、そ
の値は変えられ、それによりハッシュ値も変わってしまいます。しかし、キーオ
ブジェクトを変更したのが何者であれ、値が辞書のキーとして使われていたと気
付けないので、辞書の中のエントリを適切な場所に動かせません。そして、同じ
オブジェクトを探そうとしても、ハッシュ値が違うため見つかりません。古い値
を探そうとしても、そのハッシュバイナリから見つかるオブジェクトの値は異な
るでしょうから、これも見つかりません。

リストでインデクシングされた辞書が必要なら、まず単純にリストをタプルに変
換してください。関数 ‘tuple(L)’ は、リスト ‘L’ と同じエントリのタプルを
生成します。タプルはイミュータブルなので、辞書のキーとして使えます。

いくつかの受け入れられなかった提案:

   - アドレス (オブジェクト ID) のハッシュリスト。これは、同じ値の新しい
     リストを作っても見つからないので駄目です。例えば:

          mydict = {[1, 2]: '12'}
          print(mydict[[1, 2]])

     ‘[1, 2]’ の2行目のidは1行目のそれと異なってしまうために *note
     KeyError: 31d. 例外を送出するでしょう。言い換えれば、辞書のキーは
     ‘==’ を使って比較されるべきであり、 *note is: 2cc. ではないというこ
     とです。

   - リストをキーとして使うときにコピーを作る。リストはミュータブルなの
     で、自分自身への参照を含むことができ、コードをコピーするときに無限
     ループにハマる可能性があるので、これは駄目です。

   - リストをキーとして使うことを認めるが、ユーザにそれを変更させないよ
     うに伝える。もしユーザが忘れたり、偶然にリストが変更されてしまった
     りしたら、追跡困難なバグの可能性を生じてしまいます。またこれは、
     ‘d.keys()’ のすべての値は辞書のキーとして使えるという、辞書の重要な
     不変性も潰してしまいます。

   - リストが一旦辞書のキーとして使われたら、読み出し専用のマークを付け
     る。問題は、値を変えられるのはトップレベルオブジェクトだけではない
     ことです。リストを含むタプルもキーとして使えます。全てを辞書のキー
     として導入すると、そこから到達可能な全てのオブジェクトに読み出し専
     用のマークを付ける必要があります - そして再び、自己参照オブジェクト
     が無限ループを引き起こします。

必要ならばこれを回避する方法がありますが、自己責任のもとで行ってください
。ミュータブルな構造を、 *note __eq__(): ac8. と *note __hash__(): ac9.
メソッドの両方を持つクラスインスタンスに含めることができます。その時、辞
書 (またはハッシュに基づく別の構造体) に属するような全てのラッパーオブジ
ェクトのハッシュ値が、そのオブジェクトが辞書 (その他の構造体) 中にある間
固定され続けることを確実にしてください。

     class ListWrapper:
         def __init__(self, the_list):
             self.the_list = the_list

         def __eq__(self, other):
             return self.the_list == other.the_list

         def __hash__(self):
             l = self.the_list
             result = 98767 - len(l)*555
             for i, el in enumerate(l):
                 try:
                     result = result + (hash(el) % 9999999) * 1001 + i
                 except Exception:
                     result = (result % 7777777) + i * 333
             return result

なお、リストのメンバーの中にハッシュ化できないものがある可能性や、算術オ
ーバーフローの可能性から、ハッシュ計算は複雑になります。

さらに、そのオブジェクトが辞書に含まれるか否かにかかわらず、 ‘o1 == o2’
(すなわち ‘o1.__eq__(o2) is True’) ならばいつでも ‘hash(o1) == hash(o2)’
(すなわち ‘o1.__hash__() == o2.__hash__()’) でなくてはなりません。その制
限に適合できなければ、辞書やその他のハッシュに基づく構造体は間違いを起こ
します。

この ‘ListWrapper’ の例では、異常を避けるため、ラッパオブジェクトが辞書
内にある限りラップされたリストが変更されてはなりません。この条件と満たせ
なかった時の結果について知恵を絞る覚悟がない限り、これをしてはいけません
。よく考えてください。


File: python.info,  Node: なぜ list sort はソートされたリストを返さないのですか？,  Next: Python ではどのようにインターフェース仕様を特定し適用するのですか？,  Prev: なぜ辞書のキーはイミュータブルでなくてはならないのですか？,  Up: デザインと歴史 FAQ

10.3.21 なぜ list.sort() はソートされたリストを返さないのですか？
-----------------------------------------------------------------

パフォーマンスが問題となる状況では、ソートするためだけにリストのコピーを
作るのは無駄が多いです。そこで、 *note list.sort(): b9d. はインプレース
にリストをソートします。このことを忘れないため、この関数はソートされたリ
ストを返しません。こうすることで、ソートされたコピーが必要で、ソートされ
ていないものも残しておきたいときに、うっかり上書きしてしまうようなことが
なくなります。

新しいリストを返したいなら、代わりに組み込みの *note sorted(): b9c. 関数
を使ってください。この関数は、与えられたイテレート可能オブジェクトから新
しいリストを生成し、ソートして返します。例えば、辞書のキーをソートされた
順序でイテレートする方法は:

     for key in sorted(mydict):
         ...  # do whatever with mydict[key]...


File: python.info,  Node: Python ではどのようにインターフェース仕様を特定し適用するのですか？,  Next: なぜ goto が無いのですか？,  Prev: なぜ list sort はソートされたリストを返さないのですか？,  Up: デザインと歴史 FAQ

10.3.22 Python ではどのようにインターフェース仕様を特定し適用するのですか？
---------------------------------------------------------------------------

C++ や Java のような言語が提供するような、モジュールに対するインターフェ
ース仕様の特定は、モジュールのメソッドや関数の原型を表現します。インター
フェースの特定がコンパイル時に適用されることが、大きなプログラムの構成に
役立つと、広く感じられています。

Python 2.6 で、抽象基底クラス (Abstract Base Class, ABC) が定義できるよ
うになる *note abc: 4. モジュールが追加されました。なので *note
isinstance(): 40e. と *note issubclass(): 78c. を使って、インスタンスや
クラスが、ある ABC を実装しているかどうかチェックできます。*note
collections.abc: 17. モジュールでは、 *note Iterable: 21ab. 、 *note
Container: 21ad. 、 *note MutableMapping: 107e. などの便利な ABC が定義
されています。

Pythonでは、インターフェース仕様の多くの利点は、コンポーネントへの適切な
テスト規律により得られます。

モジュールのための適切なテストスイートは、回帰テストを提供し、モジュール
のインターフェース仕様や用例集としても役立ちます。多くの Python モジュー
ルは、簡単な「自己テスト」を提供するスクリプトとして実行できます。複雑な
外部インターフェースを使うモジュールさえ、外部インターフェースの細かい「
スタブ」エミュレーションで単独にテストできることが多いです。 *note
doctest: 31. や *note unittest: ef. モジュール、あるいはサードパーティの
テストフレームワークで、モジュールのコードの全ての行に及ぶ徹底的なテスト
スイートを構成できます。

Python で大きくて複雑なアプリケーションを構築するとき、インターフェース
仕様と同様に、適切なテスト規律も役立ちます。実際には、インターフェース仕
様ではテストできないプログラムの属性もあるので、それ以上にもなりえます。
例えば、 ‘list.append()’ メソッドは新しい要素をある内部リストの終わりに
加えます。インターフェース仕様ではこの ‘list.append()’ の実装が実際にこ
れを行うかをテストできませんが、テストスイートならこの機能を簡単に確かめ
られます。

テストスイートを書くことはとても有用ですし、簡単にテストできるコード設計
を心がけると良いでしょう。人気を博している開発手法の一つ、テスト駆動開発
は、実際のコードを記述するよりも先に、まずテストスイートの部分を記述する
よう求めています。ご心配なく、Python は、あなたがいい加減でもテストケー
スを全く書かなくても構いません。


File: python.info,  Node: なぜ goto が無いのですか？,  Next: なぜ raw 文字列 r-strings はバックスラッシュで終わってはいけないのですか？,  Prev: Python ではどのようにインターフェース仕様を特定し適用するのですか？,  Up: デザインと歴史 FAQ

10.3.23 なぜ goto が無いのですか？
----------------------------------

1970年代、人々は気付きました。秩序なき goto は、理解するのも手直しするの
も困難という厄介な"スパゲッティ"コードに陥りがちであると。 高水準言語で
は、分岐とループの手段があれば goto は不要です。 (Pythonだと、分岐には
*note if: 2ca. 文及び *note or: 2cd. ・ *note and: 2c8. ・ *note if:
2ca./*note else: 171. 式を使います。ループには *note while: 1b6e. 文と
*note for: 2c9. 文を使い、 ループ内に *note continue: 998. ・ *note
break: a77. を含むことがあります)

関数の呼び出しをまたいでも動作する "構造化された goto" をまかなうものと
して例外を使えます。C、Fortran、その他の言語での ‘go’ あるいは ‘goto’ 構
造の適切な用途は全て、例外で同じようなことをすれば便利であると、広く感じ
られています。例えば:

     class label(Exception): pass  # declare a label

     try:
         ...
         if condition: raise label()  # goto label
         ...
     except label:  # where to goto
         pass
     ...

例外ではループ内へ跳ぶことはできませんが、どちらにしてもそれは ‘goto’ の
乱用と見なされるものです。使うのは控えてください。


File: python.info,  Node: なぜ raw 文字列 r-strings はバックスラッシュで終わってはいけないのですか？,  Next: 属性の代入に "with" 文が使えないのはなぜですか？,  Prev: なぜ goto が無いのですか？,  Up: デザインと歴史 FAQ

10.3.24 なぜ raw 文字列 (r-strings) はバックスラッシュで終わってはいけないのですか？
------------------------------------------------------------------------------------

正確には、奇数個のバックスラッシュで終わってはいけません。終わりの対にな
っていないバックスラッシュは、閉じ引用文字をエスケープし、終っていない文
字列を残してしまいます。

raw 文字列は、独自にバックスラッシュの処理をしようとするプロセッサ (主に
正規表現エンジン) への入力を生成しやすいように設計されたものです。このよ
うなプロセッサは、終端の対になっていないバックスラッシュを結局エラーとみ
なすので、raw 文字列はそれを認めません。その代わりに、バックスラッシュで
エスケープすることで、引用文字を文字列として渡すことができます。r-string
が意図された目的に使われるときに、この規則が役に立つのです。

Windows のパス名を構築するときには、Windows のシステムコールは普通のスラ
ッシュも受け付けることを憶えておいてください:

     f = open("/mydir/file.txt")  # works fine!

DOS コマンドのパス名を構築するときには、例えばこの中のどれかを試してくだ
さい:

     dir = r"\this\is\my\dos\dir" "\\"
     dir = r"\this\is\my\dos\dir\ "[:-1]
     dir = "\\this\\is\\my\\dos\\dir\\"


File: python.info,  Node: 属性の代入に "with" 文が使えないのはなぜですか？,  Next: なぜジェネレータは with 文をサポートしないのですか？,  Prev: なぜ raw 文字列 r-strings はバックスラッシュで終わってはいけないのですか？,  Up: デザインと歴史 FAQ

10.3.25 属性の代入に "with" 文が使えないのはなぜですか？
--------------------------------------------------------

Python には、ブロックの実行を包む *note with: 59c. 文があり、ブロックに
入るときとブロックから出るときに、コードを呼び出します。以下のような構造
を持つ言語があります:

     with obj:
         a = 1               # equivalent to obj.a = 1
         total = total + 1   # obj.total = obj.total + 1

Python では、このような構造は曖昧になるでしょう。

Object Pascal、Delphi、C++のような他の言語では、静的な型を使うので、曖昧
な方法でも、どのメンバに代入されているのか分かります。これが静的型付けの
要点です - コンパイラは 'いつでも' コンパイル時にすべての変数のスコープ
を知るのです。

Python は動的な型を使います。実行時にどの属性が参照されるか事前に分かり
ません。動作中にメンバ属性が追加あるいは除去されるかもしれません。これで
は、単純に読むだけではどのアトリビュートが参照されているか分かりません。
ローカルなのか、グローバルなのか、メンバ属性なのか？

例えば、以下の不完全なコード片を考えましょう:

     def foo(a):
         with a:
             print(x)

このコード片では、‘a’ は ‘x’.  というメンバ属性を持っていると仮定されて
います。しかし、Python ではインタプリタにはこの仮定を伝えられる仕組みは
ありません。 ‘a’ が、例えば整数だったら、どうなってしまうでしょうか。
‘x’ という名前のグローバル変数があったら、それが *note with: 59c. ブロッ
クの中で使われるのでしょうか。この通り、Python の動的な特質から、このよ
うな選択はとても難しい物になっています。

しかし、*note with: 59c. やそれに類する言語の機能の一番の利点 (コード量
の削減) は、 Python では代入により簡単に手に入れられます:

     function(args).mydict[index][index].a = 21
     function(args).mydict[index][index].b = 42
     function(args).mydict[index][index].c = 63

こう書いてください:

     ref = function(args).mydict[index][index]
     ref.a = 21
     ref.b = 42
     ref.c = 63

Python では実行時に名前束縛が解決され、後者はその解決が一度で済むため、
これには実行速度をあげる副作用もあります。

似た提案として、「先頭のドット」を使うなどして さらにコード量を減らす構
文は、明白さを優先をして却下されました
(‘https://mail.python.org/pipermail/python-ideas/2016-May/040070.html’ 参
照)。


File: python.info,  Node: なぜジェネレータは with 文をサポートしないのですか？,  Next: if/while/def/class 文にコロンが必要なのはなぜですか？,  Prev: 属性の代入に "with" 文が使えないのはなぜですか？,  Up: デザインと歴史 FAQ

10.3.26 なぜジェネレータは with 文をサポートしないのですか？
------------------------------------------------------------

技術的な理由で、ジェネレータは直接コンテキストマネージャとして使ってもう
まく動きません。最も一般的なように、ジェネレータが最後まで回りきるイテレ
ータとして使われる場合、クローズ処理は不要です。必要な場合は、 *note
with: 59c. 文で *note contextlib.closing(generator): 289d. のようにラッ
プします。


File: python.info,  Node: if/while/def/class 文にコロンが必要なのはなぜですか？,  Next: なぜ Python ではリストやタプルの最後にカンマがあっても良いのですか？,  Prev: なぜジェネレータは with 文をサポートしないのですか？,  Up: デザインと歴史 FAQ

10.3.27 if/while/def/class 文にコロンが必要なのはなぜですか？
-------------------------------------------------------------

主に可読性を高めるため (実験的な ABC 言語の結果の一つ) に、コロンが必要
です:

     if a == b
         print(a)

と:

     if a == b:
         print(a)

を考えれば、後者のほうが少し読みやすいでしょう。さらに言えば、この FAQ の
解答例は次のようになるでしょう。これは、英語の標準的な用法です。

他の小さな理由は、コロンによってエディタがシンタックスハイライトをしやす
くなることです。プログラムテキストの手の込んだ解析をしなくても、コロンを
探せばいつインデントを増やすべきかを決められます。


File: python.info,  Node: なぜ Python ではリストやタプルの最後にカンマがあっても良いのですか？,  Prev: if/while/def/class 文にコロンが必要なのはなぜですか？,  Up: デザインと歴史 FAQ

10.3.28 なぜ Python ではリストやタプルの最後にカンマがあっても良いのですか？
----------------------------------------------------------------------------

Python では、リスト、タプル、辞書の最後の要素の後端にカンマをつけても良
いことになっています:

     [1, 2, 3,]
     ('a', 'b', 'c',)
     d = {
         "A": [1, 5],
         "B": [6, 7],  # last trailing comma is optional but good style
     }

これを許すのには、いくつかの理由があります。

リストやタプルや辞書のリテラルが複数行に渡っているときに、前の行にカンマ
を追加するのを覚えておく必要が無いため、要素を追加するのが楽になります。
また、文法エラーを起こすこと無く、行の並べ替えを行うことができます。

間違えてカンマを落としてしまうと、診断しづらいエラーにつながります。例え
ば:

     x = [
       "fee",
       "fie"
       "foo",
       "fum"
     ]

このリストには4つの要素があるように見えますが、実際には3つしかありません
。 "fee"、"fiefoo"、"fum" です。 常にカンマを付けるようにすれば、この種
のエラーが避けられます。

後端にカンマをつけても良いことにすれば、プログラムによるコード生成も簡単
になります。


File: python.info,  Node: ライブラリと拡張 FAQ,  Next: 拡張と埋め込み FAQ,  Prev: デザインと歴史 FAQ,  Up: Python よくある質問

10.4 ライブラリと拡張 FAQ
=========================

* Menu:

* ライブラリ一般の質問::
* よくある作業::
* スレッド::
* 入力と出力: 入力と出力<2>.
* ネットワーク/インターネットプログラミング::
* データベース::
* 数学と数::


File: python.info,  Node: ライブラリ一般の質問,  Next: よくある作業,  Up: ライブラリと拡張 FAQ

10.4.1 ライブラリ一般の質問
---------------------------

* Menu:

* 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？::
* math.py (socket.py, regex.py, etc.) のソースファイルはどこにありますか？: math py socket py regex py etc のソースファイルはどこにありますか？.
* Python のスクリプトを Unix で実行可能にするにはどうしますか？::
* Python には curses/termcap パッケージはありますか？::
* Python には C の onexit() に相当するものはありますか？: Python には C の onexit に相当するものはありますか？.
* シグナルハンドラが動かないのですがなぜですか？::


File: python.info,  Node: 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？,  Next: math py socket py regex py etc のソースファイルはどこにありますか？,  Up: ライブラリ一般の質問

10.4.1.1 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？
................................................................................

*note ライブラリリファンレス: 12a. から関係がありそうな標準ライブラリモ
ジュールがあるかどうか調べてください。 (標準ライブラリに何があるかが分か
るようになると、この段階をスキップすることができます。)

サードパーティのパッケージについては、Python Package Index(1) を探したり
、Google(2) その他の web サーチエンジンを試してください。"Python" に加え
て一つか二つのキーワードで興味のある話題を検索すれば、たいてい役に立つも
のが見つかるでしょう。

   ---------- Footnotes ----------

   (1) https://pypi.org

   (2) https://www.google.com


File: python.info,  Node: math py socket py regex py etc のソースファイルはどこにありますか？,  Next: Python のスクリプトを Unix で実行可能にするにはどうしますか？,  Prev: 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？,  Up: ライブラリ一般の質問

10.4.1.2 math.py (socket.py, regex.py, etc.) のソースファイルはどこにありますか？
.................................................................................

モジュールのソースファイルが見付けられない場合は、それは C 、 C++ かもし
くは別のコンパイル言語で実装された、ビルトインもしくは動的に読み込まれる
モジュールかもしれません。この場合、ソースは手に入らないかもしれませんし
、 ‘mathmodule.c’ のようなものが (Python の読み込みパスに無い) C ソース
ディレクトリのどこかにあるかもしれません。

Python のモジュールには、(少なくとも) 3 種類あります:

  1. Python で書かれたモジュール (.py)。

  2. C で書かれ、動的にロードされるモジュール (.dll, .pyd, .so, .sl,
     etc)。

  3. C で書かれ、インタプリタにリンクされているモジュール。このリストを
     得るには、こうタイプしてください:

          import sys
          print(sys.builtin_module_names)


File: python.info,  Node: Python のスクリプトを Unix で実行可能にするにはどうしますか？,  Next: Python には curses/termcap パッケージはありますか？,  Prev: math py socket py regex py etc のソースファイルはどこにありますか？,  Up: ライブラリ一般の質問

10.4.1.3 Python のスクリプトを Unix で実行可能にするにはどうしますか？
......................................................................

二つの条件があります :スクリプトファイルのモードが実行可能で、最初の行が
‘#!’ で始まり Python インタプリタのパスが続いていなければなりません。

前者は、‘chmod +x scriptfile’ 、場合によっては ‘chmod 755 scriptfile’ を
実行すればできます。

後者は、いくつかの方法でできます。最も直接的な方法はこのように

     #!/usr/local/bin/python

のようにファイルの一番最初の行に、プラットフォーム上の Python がインスト
ールされているパス名を書くことです。

スクリプトを Python インタプリタの場所に依存させたくない場合は、 ‘env’ プ
ログラムが使えます。 Python インタプリタがユーザの ‘PATH’ のディレクトリ
にあることを前提とすれば、ほとんど全ての Unix 系 OS では次の書き方をサポ
ートしています:

     #!/usr/bin/env python

CGI スクリプトでこれをやっては 'いけません' 。 CGI スクリプトの ‘PATH’ 変
数はたいてい最小限のものになっているので、実際のインタプリタの絶対パスを
使う必要があります。

ときおり、ユーザ環境に余裕が無く ‘/usr/bin/env’ プログラムが失敗すること
があります; もしくは、 env プログラム自体が無いことがあります。そのよう
な場合は、次の (Alex Rezinsky による) ハックが試せます:

     #! /bin/sh
     """:"
     exec python $0 ${1+"$@"}
     """

これには、スクリプトの __doc__ 文字列を定義するというちょっとした欠点が
あります。しかし、これを付け足せば直せます:

     __doc__ = """...Whatever..."""


File: python.info,  Node: Python には curses/termcap パッケージはありますか？,  Next: Python には C の onexit に相当するものはありますか？,  Prev: Python のスクリプトを Unix で実行可能にするにはどうしますか？,  Up: ライブラリ一般の質問

10.4.1.4 Python には curses/termcap パッケージはありますか？
............................................................

Unix 系 OS において: 標準の Python ソースディストリビューションには
Modules(1) サブディレクトリに curses モジュールが付いてきますが、デフォ
ルトではコンパイルされていません。 (これは Windows 用ディストリビューシ
ョンでは利用できないことに注意してください - Windows には curses モジュ
ールはありません。)

*note curses: 23. モジュールは基本的な curses の機能や、色付きの表示、別
の文字集合サポート、パッド、マウスサポートなどの ncurses や SYSV curses
の多くの機能をサポートしています。このことは、モジュールが BSD curses だ
けしか持っていない OS とは互換性が無いことを意味しますが、現在メンテナン
スされている OS でそういう類のものは無さそうです。

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Modules


File: python.info,  Node: Python には C の onexit に相当するものはありますか？,  Next: シグナルハンドラが動かないのですがなぜですか？,  Prev: Python には curses/termcap パッケージはありますか？,  Up: ライブラリ一般の質問

10.4.1.5 Python には C の onexit() に相当するものはありますか？
...............................................................

*note atexit: 9. モジュールは、 C の ‘onexit()’ と同じような関数登録を提
供します。


File: python.info,  Node: シグナルハンドラが動かないのですがなぜですか？,  Prev: Python には C の onexit に相当するものはありますか？,  Up: ライブラリ一般の質問

10.4.1.6 シグナルハンドラが動かないのですがなぜですか？
.......................................................

最もありがちな問題は、シグナルハンドラが間違った引数リストで宣言されてい
ることです。これは次のように呼び出されます

     handler(signum, frame)

だから、これは二つの仮引数で宣言されるべきです:

     def handler(signum, frame):
         ...


File: python.info,  Node: よくある作業,  Next: スレッド,  Prev: ライブラリ一般の質問,  Up: ライブラリと拡張 FAQ

10.4.2 よくある作業
-------------------

* Menu:

* Python のプログラムやコンポーネントをテストするにはどうしますか？::
* Python のドキュメント文字列からドキュメントを生成するにはどうしますか？::
* 一度に一つの押鍵を取得するにはどうしますか？::


File: python.info,  Node: Python のプログラムやコンポーネントをテストするにはどうしますか？,  Next: Python のドキュメント文字列からドキュメントを生成するにはどうしますか？,  Up: よくある作業

10.4.2.1 Python のプログラムやコンポーネントをテストするにはどうしますか？
..........................................................................

Python には二つのテストフレームワークがついています。*note doctest: 31.
モジュールは、モジュールの docstring から使用例を見つけてそれらを実行し
、出力を docstring によって与えられた望まれる出力と比較します。

*note unittest: ef. モジュールは、Java や Smalltalk のテストフレームワー
クを模した装飾されたテストフレームワークです。

テスト作業を簡単にするために、プログラムにおいてモジュール性の良い設計を
使うべきです。プログラムでは、ほぼ全ての処理を関数やクラスのメソッドで包
むべきです - こうすることで、プログラムが速くなるという驚くような愉快な
効果がときおり得られることがあります (というのも、ローカル変数へのアクセ
スはグローバルなアクセスよりも速いからです)。さらに言うと、テストを行う
のがより難しくなってしまうため、プログラムは可変なグローバル変数に依存す
るのを避けるべきです。

プログラムの "global main logic" は

     if __name__ == "__main__":
         main_logic()

のように main モジュールの最後に出来る限りシンプルなものを書くのが良いで
しょう。

プログラムが整理され、関数やクラスの動作が追いやすい状態になったら、その
動作を試すテスト関数を書くべきです。一連のテストを自動化するテストスイー
トは、それぞれのモジュールに関連付けることができます。これは手間が掛かり
そうに思えますが、Python は簡素で融通が効くので、驚くほど簡単です。"製品
コード (production code)" と並行でテスト関数を書くことで、バグや設計の不
備でさえも早い段階で簡単に見付かるようになるので、コーディング作業をより
心地良く楽しいものにできます。

プログラムのメインモジュールとして設計されたのではない "補助モジュール"
には、モジュールの自己テストを含めるといいでしょう。

     if __name__ == "__main__":
         self_test()

複雑な外部インターフェースと作用し合うプログラムでさえ、外部インターフェ
ースが使えない時でも、Python で実装された "fake" インターフェースを使っ
てテストできます。


File: python.info,  Node: Python のドキュメント文字列からドキュメントを生成するにはどうしますか？,  Next: 一度に一つの押鍵を取得するにはどうしますか？,  Prev: Python のプログラムやコンポーネントをテストするにはどうしますか？,  Up: よくある作業

10.4.2.2 Python のドキュメント文字列からドキュメントを生成するにはどうしますか？
................................................................................

*note pydoc: a3. モジュールで Python ソースコード内のドキュメント文字列
から HTML を生成できます。純粋に docstring から API ドキュメントを生成す
るには、他に epydoc(1) という選択肢もあります。 Sphinx(2) も docstring の
内容を含めることができます。

   ---------- Footnotes ----------

   (1) https://epydoc.sourceforge.net/

   (2) https://www.sphinx-doc.org


File: python.info,  Node: 一度に一つの押鍵を取得するにはどうしますか？,  Prev: Python のドキュメント文字列からドキュメントを生成するにはどうしますか？,  Up: よくある作業

10.4.2.3 一度に一つの押鍵を取得するにはどうしますか？
.....................................................

Unix 系 OS ではいくつか解決方法があります。curses を使うのが素直なやり方
ですが、curses は学ぶには少し大き過ぎるモジュールです。


File: python.info,  Node: スレッド,  Next: 入力と出力<2>,  Prev: よくある作業,  Up: ライブラリと拡張 FAQ

10.4.3 スレッド
---------------

* Menu:

* スレッドを使ったプログラムを書くにはどうしますか？::
* スレッドが一つも実行されていないようです。なぜですか？::
* たくさんのワーカースレッドに作業を割り振るにはどうしますか？::
* グローバルな値のどんな種類の変更がスレッドセーフになるのですか？::
* グローバルインタプリタロック (Global Interpreter Lock) を取り除くことはできないのですか？: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？.


File: python.info,  Node: スレッドを使ったプログラムを書くにはどうしますか？,  Next: スレッドが一つも実行されていないようです。なぜですか？,  Up: スレッド

10.4.3.1 スレッドを使ったプログラムを書くにはどうしますか？
...........................................................

*note _thread: 2. モジュールではなく、必ず *note threading: d6. モジュー
ルを使ってください。 *note threading: d6. モジュールは、 *note _thread:
2. モジュールで提供される低レベルな基本要素の、便利な抽象化を構成します
。


File: python.info,  Node: スレッドが一つも実行されていないようです。なぜですか？,  Next: たくさんのワーカースレッドに作業を割り振るにはどうしますか？,  Prev: スレッドを使ったプログラムを書くにはどうしますか？,  Up: スレッド

10.4.3.2 スレッドが一つも実行されていないようです。なぜですか？
...............................................................

メインスレッドが終了するとともに、全てのスレッドは終了されます。メインス
レッドは速く働きすぎるので、スレッドには何をする時間も与えられません。

簡単な解決策は、プログラムの終わりに、スレッドが完了するのに十分な時間の
スリープを加えることです:

     import threading, time

     def thread_task(name, n):
         for i in range(n):
             print(name, i)

     for i in range(10):
         T = threading.Thread(target=thread_task, args=(str(i), i))
         T.start()

     time.sleep(10)  # <---------------------------!

しかし、実際は (ほとんどのプラットフォームでは) スレッドは並行して実行さ
れるのではなく、一つづつ実行されるのです！なぜなら、OS のスレッドスケジ
ューラは、前のスレッドがブロックされるまで新しいスレッドを開始しないから
です。

簡単に直すには、関数の実行の最初にちょっとスリープを加えることです:

     def thread_task(name, n):
         time.sleep(0.001)  # <--------------------!
         for i in range(n):
             print(name, i)

     for i in range(10):
         T = threading.Thread(target=thread_task, args=(str(i), i))
         T.start()

     time.sleep(10)

*note time.sleep(): 669. の良い遅延時間を推測しようとするよりも、セマフ
ォのような仕組みを使う方が良いでしょう。 1 つのアイディアは *note queue:
a4. モジュールを使って、キューオブジェクトを作り、各スレッドが完了したと
きにキューにトークンを追加し、メインスレッドにスレッドと同じ数のトークン
をキューから読み出させることです。


File: python.info,  Node: たくさんのワーカースレッドに作業を割り振るにはどうしますか？,  Next: グローバルな値のどんな種類の変更がスレッドセーフになるのですか？,  Prev: スレッドが一つも実行されていないようです。なぜですか？,  Up: スレッド

10.4.3.3 たくさんのワーカースレッドに作業を割り振るにはどうしますか？
.....................................................................

最も簡単な方法は、新しい *note concurrent.futures: 1a. モジュール、特に
*note ThreadPoolExecutor: 70d. クラスを使うことです。

もしくは、実行アルゴリズムを上手にコントロールしたい場合は、自身の手でロ
ジックを書くこともできます。 *note queue: a4. モジュールを使って、ジョブ
のリストを含むキューを作ってください。 *note Queue: 1356. クラスはオブジ
ェクトのリストを保持し、キューに要素を追加する ‘.put(obj)’ メソッド、そ
れら要素を返す ‘.get()’ メソッドを持っています。このクラスは、それぞれの
ジョブがきっちり 1 回だけ取り出されることを保証するのに必要なロック処理
にも配慮します。

ここにちょっとした例があります:

     import threading, queue, time

     # The worker thread gets jobs off the queue.  When the queue is empty, it
     # assumes there will be no more work and exits.
     # (Realistically workers will run until terminated.)
     def worker():
         print('Running worker')
         time.sleep(0.1)
         while True:
             try:
                 arg = q.get(block=False)
             except queue.Empty:
                 print('Worker', threading.current_thread(), end=' ')
                 print('queue empty')
                 break
             else:
                 print('Worker', threading.current_thread(), end=' ')
                 print('running with argument', arg)
                 time.sleep(0.5)

     # Create queue
     q = queue.Queue()

     # Start a pool of 5 workers
     for i in range(5):
         t = threading.Thread(target=worker, name='worker %i' % (i+1))
         t.start()

     # Begin adding work to the queue
     for i in range(50):
         q.put(i)

     # Give threads time to run
     print('Main thread sleeping')
     time.sleep(5)

実行時には、以下のように出力されます:

     Running worker
     Running worker
     Running worker
     Running worker
     Running worker
     Main thread sleeping
     Worker <Thread(worker 1, started 130283832797456)> running with argument 0
     Worker <Thread(worker 2, started 130283824404752)> running with argument 1
     Worker <Thread(worker 3, started 130283816012048)> running with argument 2
     Worker <Thread(worker 4, started 130283807619344)> running with argument 3
     Worker <Thread(worker 5, started 130283799226640)> running with argument 4
     Worker <Thread(worker 1, started 130283832797456)> running with argument 5
     ...

より詳しいことはモジュールのドキュメントを調べてください; *note Queue:
1356. クラスは多機能なインターフェースを提供しています。


File: python.info,  Node: グローバルな値のどんな種類の変更がスレッドセーフになるのですか？,  Next: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？,  Prev: たくさんのワーカースレッドに作業を割り振るにはどうしますか？,  Up: スレッド

10.4.3.4 グローバルな値のどんな種類の変更がスレッドセーフになるのですか？
.........................................................................

*note global interpreter lock: 12e. (GIL) が内部で使われ、Python VM で一
度に一つだけのスレッドが実行されることが保証されています。一般に、Python
ではスレッド間の切り替えをバイトコード命令の間でのみ行います。切り替えの
周期は、 *note sys.setswitchinterval(): 918. で設定できます。したがって
、それぞれのバイトコード命令、そしてそれぞれの命令が届く全ての C 実装コ
ードは、 Python プログラムの観点からは、アトミックです。

このことから、理論上は、正確な勘定のためには PVM バイトコードの実装を理
解することが必要です。実際上は、組み込みデータ型(整数、リスト、辞書、等
)の、変数を共有する "アトミックそうな" 演算は、実際にアトミックです。

例えば、以下の演算は全てアトミックです (L、L1、L2 はリスト、 D、D1、D2 は
辞書、x、y はオブジェクト、i、j は整数です):

     L.append(x)
     L1.extend(L2)
     x = L[i]
     x = L.pop()
     L1[i:j] = L2
     L.sort()
     x = y
     x.field = y
     D[x] = y
     D1.update(D2)
     D.keys()

これらは、アトミックではありません:

     i = i+1
     L.append(L[-1])
     L[i] = L[j]
     D[x] = D[x] + 1

他のオブジェクトを置き換えるような演算は、そのオブジェクトの参照カウント
がゼロになったときに *note __del__(): 1ec1. メソッドを呼び出すことがあり
、これが影響を及ぼすかもしれません。これは特に、辞書やリストの大規模な更
新に当てはまります。疑わしければ、mutex を使ってください！


File: python.info,  Node: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？,  Prev: グローバルな値のどんな種類の変更がスレッドセーフになるのですか？,  Up: スレッド

10.4.3.5 グローバルインタプリタロック (Global Interpreter Lock) を取り除くことはできないのですか？
..................................................................................................

マルチスレッド Python プログラムは事実上一つの CPU しか使えず、 (ほとん
ど) 全ての Python コードが *note グローバルインタプリタロック: 12e.
(GIL) が保持されている間しか作動しなくなるということで、GIL は、 Python
をハイエンドなマルチプロセッササーバマシン上に配備する上で邪魔であると見
なされがちです。

With the approval of PEP 703(1) work is now underway to remove the GIL
from the CPython implementation of Python.  Initially it will be
implemented as an optional compiler flag when building the interpreter,
and so separate builds will be available with and without the GIL.
Long-term, the hope is to settle on a single build, once the performance
implications of removing the GIL are fully understood.  Python 3.13 is
likely to be the first release containing this work, although it may not
be completely functional in this release.

The current work to remove the GIL is based on a fork of Python 3.9 with
the GIL removed(2) by Sam Gross.  Prior to that, in the days of Python
1.5, Greg Stein actually implemented a comprehensive patch set (the
"free threading" patches) that removed the GIL and replaced it with
fine-grained locking.  Adam Olsen did a similar experiment in his
python-safethread(3) project.  Unfortunately, both of these earlier
experiments exhibited a sharp drop in single-thread performance (at
least 30% slower), due to the amount of fine-grained locking necessary
to compensate for the removal of the GIL. The Python 3.9 fork is the
first attempt at removing the GIL with an acceptable performance impact.

The presence of the GIL in current Python releases doesn't mean that you
can't make good use of Python on multi-CPU machines!  You just have to
be creative with dividing the work up between multiple 'processes'
rather than multiple 'threads'.  The *note ProcessPoolExecutor: 8bc.
class in the new *note concurrent.futures: 1a. module provides an easy
way of doing so; the *note multiprocessing: 86. module provides a
lower-level API in case you want more control over dispatching of tasks.

C 拡張をうまく使うことも役立ちます。C 拡張を時間のかかるタスクの実行に使
えば、その拡張は実行が C コードで行われている間 GIL を解放でき、その間に
他のスレッドで作業が進められます。 *note zlib: 119. や *note hashlib:
5e. など、すでにこれを行なっている標準ライブラリモジュールもあります。

An alternative approach to reducing the impact of the GIL is to make the
GIL a per-interpreter-state lock rather than truly global.  This was
*note first implemented in Python 3.12: 408. and is available in the C
API. A Python interface to it is expected in Python 3.13.  The main
limitation to it at the moment is likely to be 3rd party extension
modules, since these must be written with multiple interpreters in mind
in order to be usable, so many older extension modules will not be
usable.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0703/

   (2) https://github.com/colesbury/nogil

   (3) https://code.google.com/archive/p/python-safethread


File: python.info,  Node: 入力と出力<2>,  Next: ネットワーク/インターネットプログラミング,  Prev: スレッド,  Up: ライブラリと拡張 FAQ

10.4.4 入力と出力
-----------------

* Menu:

* ファイルを削除するにはどうしますか？ (その他、ファイルに関する質問...): ファイルを削除するにはどうしますか？ その他、ファイルに関する質問.
* ファイルをコピーするにはどうしますか？::
* バイナリデータを読み書きするにはどうしますか？::
* os.popen() によって作られたパイプで os.read() が使われていないようです。なぜですか？: os popen によって作られたパイプで os read が使われていないようです。なぜですか？.
* シリアル (RS232) ポートにアクセスするにはどうしますか？: シリアル RS232 ポートにアクセスするにはどうしますか？.
* sys.stdout (stdin, stderr) を閉じようとしても実際に閉じられないのはなぜですか？: sys stdout stdin stderr を閉じようとしても実際に閉じられないのはなぜですか？.


File: python.info,  Node: ファイルを削除するにはどうしますか？ その他、ファイルに関する質問,  Next: ファイルをコピーするにはどうしますか？,  Up: 入力と出力<2>

10.4.4.1 ファイルを削除するにはどうしますか？ (その他、ファイルに関する質問...)
...............................................................................

‘os.remove(filename)’ または ‘os.unlink(filename)’ を使ってください。ド
キュメントは、 *note os: 91. モジュールを参照してください。この二つの関
数は同じものです。 *note unlink(): 10c6. は単に、この関数の Unix システ
ムコールの名称です。

ディレクトリを削除するには、*note os.rmdir(): 10c4. を使ってください。作
成には *note os.mkdir(): 1fe. を使ってください。‘os.makedirs(path)’ は
‘path’ の中間のディレクトリの、存在しないものを作成します。
‘os.removedirs(path)’ は中間のディレクトリが空である限り、それらを削除し
ます。ディレクトリツリー全体とその中身全てを削除したいなら、*note
shutil.rmtree(): 2d8. を使ってください。

ファイルの名前を変更するには、‘os.rename(old_path, new_path)’ を使ってく
ださい。

ファイルを切り詰めるには、 ‘f = open(filename, "rb+")’ を使ってファイル
を開き、 ‘f.truncate(offset)’ を使ってください; offset はデフォルトでは
現在のシーク位置です。 *note os.open(): d5f. で開かれたファイル用の
‘os.ftruncate(fd, offset)’ もあります。 'fd' はファイルディスクリプタ (小
さい整数値) です。

*note shutil: b3. モジュールにも、*note copyfile(): a27.、 *note
copytree(): 9f7.、*note rmtree(): 2d8. 等、ファイルに作用する関数がいく
つか含まれます。


File: python.info,  Node: ファイルをコピーするにはどうしますか？,  Next: バイナリデータを読み書きするにはどうしますか？,  Prev: ファイルを削除するにはどうしますか？ その他、ファイルに関する質問,  Up: 入力と出力<2>

10.4.4.2 ファイルをコピーするにはどうしますか？
...............................................

*note shutil: b3. モジュールに *note copyfile(): a27. 関数があります。注
意点として、これは Windows NTFS ボリューム上の alternate data streams(1)
も macOS HFS+ 上の resource forks(2) もコピーしません。ただし現在ではど
ちらも使われることは ほとんどありません。またファイルのパーミッションや
メタデータもコピーされませんが、この代わりに *note shutil.copy2(): a29.
を使うとそのほとんど (すべてではありませんが) が保持されます。

   ---------- Footnotes ----------

   (1) https://en.wikipedia.org/wiki/NTFS#Alternate_data_stream_(ADS)

   (2) https://en.wikipedia.org/wiki/Resource_fork


File: python.info,  Node: バイナリデータを読み書きするにはどうしますか？,  Next: os popen によって作られたパイプで os read が使われていないようです。なぜですか？,  Prev: ファイルをコピーするにはどうしますか？,  Up: 入力と出力<2>

10.4.4.3 バイナリデータを読み書きするにはどうしますか？
.......................................................

複雑なバイナリデータ形式の読み書きには、*note struct: c0. モジュールを使
うのが一番です。これでバイナリデータ (通常は数) を含む文字列を取って、
Python オブジェクトに変換することができますし、その逆もできます。

例えば、以下のコードはファイルから 2 バイトの整数 2 個と 4 バイトの整数
1 個をビッグエンディアンフォーマットで読み込みます:

     import struct

     with open(filename, "rb") as f:
         s = f.read(8)
         x, y, z = struct.unpack(">hhl", s)

フォーマット中の '>' はデータを強制的にビッグエンディアンにします。ファ
イルから、文字 'h' は一つの"整数"(2 バイト)を読み込み、文字 'l' は一つの
"long 整数"を読み込みます。

より規則的なデータ (例えば、整数や浮動小数点数の中身の型が揃ったリスト)
に対しては、 *note array: 6. モジュールを使うこともできます。

     注釈: バイナリデータを読み書きするには、 (ここにあるように ‘"rb"’ を
     *note open(): 4e5. に渡して) ファイルをバイナリモードで開く義務があ
     ります。代わりに (デフォルトの) ‘"r"’ を使った場合は、ファイルはテ
     キストモードで開かれ、 ‘f.read()’ は *note bytes: 1a4. オブジェクト
     ではなく *note str: 418. オブジェクトを返します。


File: python.info,  Node: os popen によって作られたパイプで os read が使われていないようです。なぜですか？,  Next: シリアル RS232 ポートにアクセスするにはどうしますか？,  Prev: バイナリデータを読み書きするにはどうしますか？,  Up: 入力と出力<2>

10.4.4.4 os.popen() によって作られたパイプで os.read() が使われていないようです。なぜですか？
.............................................................................................

*note os.read(): d62. は、開かれたファイルを表す小さな整数、ファイルディ
スクリプタを引数に取る、低レベルの関数です。 *note os.popen(): a55. は、
組み込みの *note open(): 4e5. 関数の返り値と同じ型の、高レベルなファイル
オブジェクトを作成します。従って、 *note os.popen(): a55. によって作成さ
れたパイプ 'p' から 'n' バイト分だけ読み取るには、 ‘p.read(n)’ を使う必
要があります。


File: python.info,  Node: シリアル RS232 ポートにアクセスするにはどうしますか？,  Next: sys stdout stdin stderr を閉じようとしても実際に閉じられないのはなぜですか？,  Prev: os popen によって作られたパイプで os read が使われていないようです。なぜですか？,  Up: 入力と出力<2>

10.4.4.5 シリアル (RS232) ポートにアクセスするにはどうしますか？
................................................................

Win32、OSX、Linux、BSD、Jython、IronPython では:

     pyserial(1)

Unix では、Mitch Chapman による Usenet の投稿を参照してください:

     ‘https://groups.google.com/groups?selm=34A04430.CF9@ohioee.com’

   ---------- Footnotes ----------

   (1) https://pypi.org/project/pyserial/


File: python.info,  Node: sys stdout stdin stderr を閉じようとしても実際に閉じられないのはなぜですか？,  Prev: シリアル RS232 ポートにアクセスするにはどうしますか？,  Up: 入力と出力<2>

10.4.4.6 sys.stdout (stdin, stderr) を閉じようとしても実際に閉じられないのはなぜですか？
........................................................................................

Python の *note file object: 1193. は、低水準の C ファイルディスクリプタ
上の、抽象の高水準レイヤです。

組み込みの *note open(): 4e5. 関数によって生成されたほとんどのファイルオ
ブジェクトでは、 ‘f.close()’ は Python ファイルオブジェクトが Python の
視点からは閉じられているものとする印をつけ、その下にある C ファイルディ
スクリプタを閉じるように手配します。これは、 ‘f’ がガベージとなったとき
にも、 ‘f’ のデストラクタで自動的に起こります。

しかし、stdin、stdout、stderr は C で特別な立場が与えられていることから
、Python でも同様に特別に扱われます。‘sys.stdout.close()’ を実行すると、
Python レベルのファイルオブジェクトには閉じられているものとする印がつけ
られますが、C ファイルディスクリプタは '閉じられません'。

下にある C ファイルディスクリプタのうち、この三つのどれかを閉じるには、
まず本当に閉じる必要があることを確かめるべきです (例えば、拡張モジュール
の I/O を混乱させてしまうかもしれません)。本当に必要ならば、 *note
os.close(): b42. を使ってください:

     os.close(stdin.fileno())
     os.close(stdout.fileno())
     os.close(stderr.fileno())

または、数の定数としてそれぞれ 0, 1, 2 も使えます。


File: python.info,  Node: ネットワーク/インターネットプログラミング,  Next: データベース,  Prev: 入力と出力<2>,  Up: ライブラリと拡張 FAQ

10.4.5 ネットワーク/インターネットプログラミング
------------------------------------------------

* Menu:

* Python の WWW ツールには何がありますか？::
* どのモジュールが HTML の生成の役に立ちますか？::
* Python のスクリプトからメールを送るにはどうしますか？::
* ソケットの connect() メソッドでブロッキングされなくするにはどうしますか？: ソケットの connect メソッドでブロッキングされなくするにはどうしますか？.


File: python.info,  Node: Python の WWW ツールには何がありますか？,  Next: どのモジュールが HTML の生成の役に立ちますか？,  Up: ネットワーク/インターネットプログラミング

10.4.5.1 Python の WWW ツールには何がありますか？
.................................................

ライブラリリファレンスマニュアルの *note
インターネットプロトコルとサポート: 37de. と *note
インターネット上のデータの操作: 33f9. という章を参照してください。Python
には、サーバサイドとクライアントサイドの web システムを構築するのに便利
な多くのモジュールがあります。

利用可能なフレームワークの概要は Paul Boddie によって、
‘https://wiki.python.org/moin/WebProgramming’ でメンテナンスされています
。


File: python.info,  Node: どのモジュールが HTML の生成の役に立ちますか？,  Next: Python のスクリプトからメールを送るにはどうしますか？,  Prev: Python の WWW ツールには何がありますか？,  Up: ネットワーク/インターネットプログラミング

10.4.5.2 どのモジュールが HTML の生成の役に立ちますか？
.......................................................

Web Programming についての wiki のページ(1) から役に立つリンクが見付けら
れます。

   ---------- Footnotes ----------

   (1) https://wiki.python.org/moin/WebProgramming


File: python.info,  Node: Python のスクリプトからメールを送るにはどうしますか？,  Next: ソケットの connect メソッドでブロッキングされなくするにはどうしますか？,  Prev: どのモジュールが HTML の生成の役に立ちますか？,  Up: ネットワーク/インターネットプログラミング

10.4.5.3 Python のスクリプトからメールを送るにはどうしますか？
..............................................................

標準ライブラリモジュール *note smtplib: b7. を使ってください。

以下に示すのが、これを使ったごく単純な対話型のメール送信器です。このメソ
ッドは SMTP リスナをサポートするホストならどこででも作動します。

     import sys, smtplib

     fromaddr = input("From: ")
     toaddrs  = input("To: ").split(',')
     print("Enter message, end with ^D:")
     msg = ''
     while True:
         line = sys.stdin.readline()
         if not line:
             break
         msg += line

     # The actual mail send
     server = smtplib.SMTP('localhost')
     server.sendmail(fromaddr, toaddrs, msg)
     server.quit()

Unix 限定の代わりの選択肢は sendmail を使うことです。sendmail プログラム
の場所はシステムによって様々です; あるときは ‘/usr/lib/sendmail’ だった
り、あるときは ‘/usr/sbin/sendmail’ だったり。sendmail のマニュアルペー
ジが助けになるでしょう。サンプルコードはこのようになります:

     import os

     SENDMAIL = "/usr/sbin/sendmail"  # sendmail location
     p = os.popen("%s -t -i" % SENDMAIL, "w")
     p.write("To: receiver@example.com\n")
     p.write("Subject: test\n")
     p.write("\n")  # blank line separating headers from body
     p.write("Some text\n")
     p.write("some more text\n")
     sts = p.close()
     if sts != 0:
         print("Sendmail exit status", sts)


File: python.info,  Node: ソケットの connect メソッドでブロッキングされなくするにはどうしますか？,  Prev: Python のスクリプトからメールを送るにはどうしますか？,  Up: ネットワーク/インターネットプログラミング

10.4.5.4 ソケットの connect() メソッドでブロッキングされなくするにはどうしますか？
..................................................................................

主に *note select: af. モジュールがソケットの非同期の I/O を扱うのに使わ
れます。

TCP 接続がブロッキングされないようにするために、ソケットをノンブロッキン
グモードに設定することが出来ます。そして *note connect(): d70. したとき
に、即座に接続できるか、エラー番号を ‘.errno’ として含む例外を受け取るか
のどちらかになります。‘errno.EINPROGRESS’ は、接続が進行中であるが、まだ
完了していないということを示します。異なる OS では異なる値が返されるので
、あなたのシステムで何が返されるかを確かめておく必要があります。

*note connect_ex(): 14e2. メソッドを使えば例外を生成しなくて済みます。こ
れは単に errno の値を返すでしょう。ポーリングのためには、後でまた *note
connect_ex(): 14e2. を呼び出すことができます - ‘0’ または
‘errno.EISCONN’ は接続されたことを表します - または、このソケットを
*note select.select(): d6d. に渡して書き込み可能か調べることができます。

     注釈: *note asyncio: 8. モジュールは、ノンブロッキングのネットワー
     クコードを書く作業のためにフレームワークのような方法を提供します。
     その他の選択肢として、Twisted(1) は多機能で著名なサードパーティのラ
     イブラリです。

   ---------- Footnotes ----------

   (1) https://twisted.org/


File: python.info,  Node: データベース,  Next: 数学と数,  Prev: ネットワーク/インターネットプログラミング,  Up: ライブラリと拡張 FAQ

10.4.6 データベース
-------------------

* Menu:

* Python にはデータベースパッケージへのインターフェースはありますか？::
* Python で永続的なオブジェクトを実装するにはどうしますか？::


File: python.info,  Node: Python にはデータベースパッケージへのインターフェースはありますか？,  Next: Python で永続的なオブジェクトを実装するにはどうしますか？,  Up: データベース

10.4.6.1 Python にはデータベースパッケージへのインターフェースはありますか？
............................................................................

はい。

標準の Python には、 *note DBM: 2c. や *note GDBM: 2b. などの、ディスク
ベースのハッシュへのインターフェースも含まれています。また、 *note
sqlite3: ba. モジュールは、軽量なディスクベースの関係データベースを提供
します。

ほとんどの関係データベースがサポートされています。詳細は
DatabaseProgramming wiki page(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://wiki.python.org/moin/DatabaseProgramming


File: python.info,  Node: Python で永続的なオブジェクトを実装するにはどうしますか？,  Prev: Python にはデータベースパッケージへのインターフェースはありますか？,  Up: データベース

10.4.6.2 Python で永続的なオブジェクトを実装するにはどうしますか？
..................................................................

*note pickle: 95. ライブラリモジュールで、ごく一般的な方法でこれを解決で
きます (開かれたファイル、ソケット、ウィンドウのようなものを保管すること
はできませんが)。 *note shelve: b1. ライブラリモジュールは pickle と
(g)dbm を使い、任意の Python オブジェクトを含む永続的なマッピングを生成
します。


File: python.info,  Node: 数学と数,  Prev: データベース,  Up: ライブラリと拡張 FAQ

10.4.7 数学と数
---------------

* Menu:

* Python で乱数を生成するにはどうしますか？::


File: python.info,  Node: Python で乱数を生成するにはどうしますか？,  Up: 数学と数

10.4.7.1 Python で乱数を生成するにはどうしますか？
..................................................

標準モジュールの *note random: a6. が乱数生成器を実装しています。使い方
は単純です:

     import random
     random.random()

This returns a random floating-point number in the range [0, 1).

このモジュールにはその他多くの特化した生成器もあります。例えば:

   * ‘randrange(a, b)’ は区間 [a, b) から整数を選びます。

   * ‘uniform(a, b)’ chooses a floating-point number in the range [a,
     b).

   * ‘normalvariate(mean, sdev)’ は正規 (ガウス) 分布をサンプリングしま
     す。

シーケンスに直接作用する高水準な関数もあります。例えば:

   * ‘choice(S)’ は与えられたシーケンスからランダムな要素を選びます。

   * ‘shuffle(L)’ はリストをインプレースにシャッフルします。すなわち、ラ
     ンダムに並び替えます。

‘Random’ クラスのインスタンスを生成して、複数の独立な乱数生成器をつくる
こともできます。


File: python.info,  Node: 拡張と埋め込み FAQ,  Next: Windows 上の Python FAQ,  Prev: ライブラリと拡張 FAQ,  Up: Python よくある質問

10.5 拡張と埋め込み FAQ
=======================

* Menu:

* C で独自の関数を作ることはできますか？::
* C++ で独自の関数を作ることはできますか？::
* C を書くのは大変です。他の方法はありませんか？::
* C から任意の Python 文を実行するにはどうしますか？::
* C から任意の Python 式を評価するにはどうしますか？::
* Python オブジェクトから C の値を取り出すにはどうしますか？::
* Py_BuildValue() で任意長のタプルを作るにはどうしますか？: Py_BuildValue で任意長のタプルを作るにはどうしますか？.
* C からオブジェクトのメソッドを呼び出すにはどうしますか？::
* PyErr_Print() (その他 stdout/stderr に印字するもの) からの出力を受け取るにはどうしますか？: PyErr_Print その他 stdout/stderr に印字するもの からの出力を受け取るにはどうしますか？.
* C から Python で書かれたモジュールにアクセスするにはどうしますか？::
* Python から C++ へインターフェースするにはどうしますか？::
* セットアップファイルでモジュールを追加しようとしたらメイクに失敗しました。なぜですか？::
* 拡張をデバッグするにはどうしますか？::
* Linux システムで Python モジュールをコンパイルしたいのですが、見つからないファイルがあります。なぜですか？::
* "不完全 (incomplete) な入力" を "不適切 (invalid) な入力" から区別するにはどうしますか？: "不完全 incomplete な入力" を "不適切 invalid な入力" から区別するにはどうしますか？.
* 未定義の g++ シンボル __builtin_new や __pure_virtual を見つけるにはどうしますか？::
* メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを (継承などで) 作ることはできますか？: メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを 継承などで 作ることはできますか？.


File: python.info,  Node: C で独自の関数を作ることはできますか？,  Next: C++ で独自の関数を作ることはできますか？,  Up: 拡張と埋め込み FAQ

10.5.1 C で独自の関数を作ることはできますか？
---------------------------------------------

はい。関数、変数、例外、そして新しいタイプまで含んだビルトインモジュール
を C で作れます。これはドキュメント *note Python
インタプリタの拡張と埋め込み: 1b46. で説明されています。

ほとんどの中級から上級の Python 本もこの話題を扱っています。


File: python.info,  Node: C++ で独自の関数を作ることはできますか？,  Next: C を書くのは大変です。他の方法はありませんか？,  Prev: C で独自の関数を作ることはできますか？,  Up: 拡張と埋め込み FAQ

10.5.2 C++ で独自の関数を作ることはできますか？
-----------------------------------------------

はい。C++ 内にある C 互換機能を使ってできます。 ‘extern "C" { ... }’ で
Python のインクルードファイルを囲み、 ‘extern "C"’ を Python インタプリ
タから呼ぶ各関数の前に置いてください。グローバルや静的な C++ オブジェク
トの構造体を持つものは良くないでしょう。


File: python.info,  Node: C を書くのは大変です。他の方法はありませんか？,  Next: C から任意の Python 文を実行するにはどうしますか？,  Prev: C++ で独自の関数を作ることはできますか？,  Up: 拡張と埋め込み FAQ

10.5.3 C を書くのは大変です。他の方法はありませんか？
-----------------------------------------------------

独自の C 拡張を書くための別のやり方は、目的によっていくつかあります。

Cython(1) とその親戚 Pyrex(2) は、わずかに変形した Python を受け取り、対
応する C コードを生成します。Cython や Pyrex を使えば Python の C API を
習得することなく拡張を書けます。

現時点で Python 拡張が存在しない C や C++ ライブラリへのインターフェース
が必要な場合、SWIG(3) のようなツールを使ってそのライブラリのデータ型や関
数をラッピングできます。 SIP(4) 、CXX(5) 、Boost(6) 、Weave(7) でも C++
ライブラリをラッピングできます。

   ---------- Footnotes ----------

   (1) https://cython.org

   (2) https://www.csse.canterbury.ac.nz/greg.ewing/python/Pyrex/

   (3) https://www.swig.org

   (4) https://github.com/Python-SIP/sip

   (5) https://cxx.sourceforge.net/

   (6) https://www.boost.org/libs/python/doc/index.html

   (7) https://github.com/scipy/weave


File: python.info,  Node: C から任意の Python 文を実行するにはどうしますか？,  Next: C から任意の Python 式を評価するにはどうしますか？,  Prev: C を書くのは大変です。他の方法はありませんか？,  Up: 拡張と埋め込み FAQ

10.5.4 C から任意の Python 文を実行するにはどうしますか？
---------------------------------------------------------

これを行う最高水準の関数は *note PyRun_SimpleString(): 47b5. で、一つの
文字列引数を取り、モジュール ‘__main__’ のコンテキストでそれを実行し、成
功なら ‘0’、例外 (*note SyntaxError: 172. を含む) が発生したら ‘-1’ を返
します。更に制御したければ、 *note PyRun_String(): 1946. を使ってくださ
い。ソースは ‘Python/pythonrun.c’ の '*note PyRun_SimpleString(): 47b5.
を参照してください。


File: python.info,  Node: C から任意の Python 式を評価するにはどうしますか？,  Next: Python オブジェクトから C の値を取り出すにはどうしますか？,  Prev: C から任意の Python 文を実行するにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.5 C から任意の Python 式を評価するにはどうしますか？
---------------------------------------------------------

先の質問の *note PyRun_String(): 1946. を、スタートシンボル *note
Py_eval_input: 4958. を渡して呼び出してください。これは式を解析し、評価
してその値を返します。


File: python.info,  Node: Python オブジェクトから C の値を取り出すにはどうしますか？,  Next: Py_BuildValue で任意長のタプルを作るにはどうしますか？,  Prev: C から任意の Python 式を評価するにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.6 Python オブジェクトから C の値を取り出すにはどうしますか？
-----------------------------------------------------------------

オブジェクトの型に依ります。タプルなら、 *note PyTuple_Size(): 48e7. が
長さを返し、 *note PyTuple_GetItem(): 4763. が指定されたインデックスの要
素を返します。リストにも同様の関数 *note PyList_Size(): 13c1. と *note
PyList_GetItem(): 335. があります。

bytes では、 *note PyBytes_Size(): 4803. がその長さを返し、 *note
PyBytes_AsStringAndSize(): 47fd. がその値へのポインタと長さを提供します
。 Python の bytes オブジェクトは null を含むこともできるので、 C の
‘strlen()’ を使うべきではないことに注意してください。

オブジェクトの型を検査するには、まず最初にそれが ‘NULL’ でないことを確か
めた上で、 *note PyBytes_Check(): 135c. 、 *note PyTuple_Check(): 4ac6.
、 *note PyList_Check(): 4ad6. などを使います。

いわゆる 'abstract' インターフェースから提供される、 Python オブジェクト
に対する高レベル API もあります - より詳しいことは ‘Include/abstract.h’
を読んでください。これを使うと、数値型プロトコル (*note
PyNumber_Index(): 860. など) や PyMapping API のマップ型プロトコルなどの
役に立つプロトコルに加え、 *note PySequence_Length(): 48c8. や *note
PySequence_GetItem(): 19be. などの任意の種類の Python シーケンスへのイン
ターフェースにアクセスできます。


File: python.info,  Node: Py_BuildValue で任意長のタプルを作るにはどうしますか？,  Next: C からオブジェクトのメソッドを呼び出すにはどうしますか？,  Prev: Python オブジェクトから C の値を取り出すにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.7 Py_BuildValue() で任意長のタプルを作るにはどうしますか？
---------------------------------------------------------------

できません。代わりに *note PyTuple_Pack(): 48e6. を使ってください。


File: python.info,  Node: C からオブジェクトのメソッドを呼び出すにはどうしますか？,  Next: PyErr_Print その他 stdout/stderr に印字するもの からの出力を受け取るにはどうしますか？,  Prev: Py_BuildValue で任意長のタプルを作るにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.8 C からオブジェクトのメソッドを呼び出すにはどうしますか？
---------------------------------------------------------------

*note PyObject_CallMethod(): 379. 関数でオブジェクトの任意のメソッドを呼
び出せます。パラメタは、オブジェクト、呼び出すメソッドの名前、 *note
Py_BuildValue(): 875. で使われるようなフォーマット文字列、そして引数です
:

     PyObject *
     PyObject_CallMethod(PyObject *object, const char *method_name,
                         const char *arg_format, ...);

これはメソッドを持ついかなるオブジェクトにも有効で、組み込みかユーザ定義
かは関係ありません。返り値に対して *note Py_DECREF(): 53b. する必要があ
ることもあります。

例えば、あるファイルオブジェクトの "seek" メソッドを 10, 0 を引数として
呼ぶとき (ファイルオブジェクトのポインタを "f" とします):

     res = PyObject_CallMethod(f, "seek", "(ii)", 10, 0);
     if (res == NULL) {
             ... an exception occurred ...
     }
     else {
             Py_DECREF(res);
     }

なお、 *note PyObject_CallObject(): 4758. の引数リストには '常に' タプル
が必要です。関数を引数なしで呼び出すには、フォーマットに "()" を渡し、関
数を一つの引数で呼び出すには、関数を括弧でくくって例えば "(i)" としてく
ださい。


File: python.info,  Node: PyErr_Print その他 stdout/stderr に印字するもの からの出力を受け取るにはどうしますか？,  Next: C から Python で書かれたモジュールにアクセスするにはどうしますか？,  Prev: C からオブジェクトのメソッドを呼び出すにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.9 PyErr_Print() (その他 stdout/stderr に印字するもの) からの出力を受け取るにはどうしますか？
-------------------------------------------------------------------------------------------------

Python コード内で、 ‘write()’ メソッドをサポートするオブジェクトを定義し
てください。そのオブジェクトを *note sys.stdout: aa4. と *note
sys.stderr: 907. に代入してください。print_error を呼び出すか、単に標準
のトレースバック機構を作動させてください。そうすれば、出力は ‘write()’ が
送る任意の所に行きます。

最も簡単な方法は、 *note io.StringIO: ef3. クラスを使うことです:

     >>> import io, sys
     >>> sys.stdout = io.StringIO()
     >>> print('foo')
     >>> print('hello world!')
     >>> sys.stderr.write(sys.stdout.getvalue())
     foo
     hello world!

これと同じことをするカスタムオブジェクトは次のようになるでしょう:

     >>> import io, sys
     >>> class StdoutCatcher(io.TextIOBase):
     ...     def __init__(self):
     ...         self.data = []
     ...     def write(self, stuff):
     ...         self.data.append(stuff)
     ...
     >>> import sys
     >>> sys.stdout = StdoutCatcher()
     >>> print('foo')
     >>> print('hello world!')
     >>> sys.stderr.write(''.join(sys.stdout.data))
     foo
     hello world!


File: python.info,  Node: C から Python で書かれたモジュールにアクセスするにはどうしますか？,  Next: Python から C++ へインターフェースするにはどうしますか？,  Prev: PyErr_Print その他 stdout/stderr に印字するもの からの出力を受け取るにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.10 C から Python で書かれたモジュールにアクセスするにはどうしますか？
--------------------------------------------------------------------------

以下のようにモジュールオブジェクトへのポインタを得られます:

     module = PyImport_ImportModule("<modulename>");

そのモジュールがまだインポートされていない (つまり、まだ *note
sys.modules: 18d6. に現れていない) なら、これはモジュールを初期化します
。そうでなければ、単純に ‘sys.modules["<modulename>"]’ の値を返します。
なお、これはモジュールをいかなる名前空間にも代入しません。これはモジュー
ルが初期化されて '*note sys.modules: 18d6. に保管されていることを保証す
るだけです。

これで、モジュールの属性 (つまり、モジュールで定義された任意の名前) に以
下のようにアクセスできるようになります:

     attr = PyObject_GetAttrString(module, "<attrname>");

*note PyObject_SetAttrString(): 1564. を呼んでモジュールの変数に代入する
こともできます。


File: python.info,  Node: Python から C++ へインターフェースするにはどうしますか？,  Next: セットアップファイルでモジュールを追加しようとしたらメイクに失敗しました。なぜですか？,  Prev: C から Python で書かれたモジュールにアクセスするにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.11 Python から C++ へインターフェースするにはどうしますか？
----------------------------------------------------------------

やりたいことに応じて、いろいろな方法があります。手動でやるなら、 *note
"拡張と埋め込み" ドキュメント: 1b46. を読むことから始めてください。なお
、Python ランタイムシステムにとっては、 C と C++ はあまり変わりません。
だから、C 構造体 (ポインタ)型に基づいて新しい Python の型を構築する方針
は C++ オブジェクトに対しても有効です。

C++ ライブラリに関しては、 *note C
を書くのは大変です。他の方法はありませんか？: 4f7f. を参照してください。


File: python.info,  Node: セットアップファイルでモジュールを追加しようとしたらメイクに失敗しました。なぜですか？,  Next: 拡張をデバッグするにはどうしますか？,  Prev: Python から C++ へインターフェースするにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.12 セットアップファイルでモジュールを追加しようとしたらメイクに失敗しました。なぜですか？
----------------------------------------------------------------------------------------------

セットアップは改行で終わらなければならなくて、改行がないと、ビルド工程は
失敗します。(これを直すには、ある種の醜いシェルスクリプトハックが必要で
すが、このバグは小さいものですから努力に見合う価値はないでしょう。)


File: python.info,  Node: 拡張をデバッグするにはどうしますか？,  Next: Linux システムで Python モジュールをコンパイルしたいのですが、見つからないファイルがあります。なぜですか？,  Prev: セットアップファイルでモジュールを追加しようとしたらメイクに失敗しました。なぜですか？,  Up: 拡張と埋め込み FAQ

10.5.13 拡張をデバッグするにはどうしますか？
--------------------------------------------

動的にロードされた拡張に GDB を使うとき、拡張がロードされるまでブレーク
ポイントを設定してはいけません。

‘.gdbinit’ ファイルに(または対話的に)、このコマンドを加えてください:

     br _PyImport_LoadDynamicModule

そして、GDB を起動するときに:

     $ gdb /local/bin/python
     gdb) run myscript.py
     gdb) continue # repeat until your extension is loaded
     gdb) finish   # so that your extension is loaded
     gdb) br myfunction.c:50
     gdb) continue


File: python.info,  Node: Linux システムで Python モジュールをコンパイルしたいのですが、見つからないファイルがあります。なぜですか？,  Next: "不完全 incomplete な入力" を "不適切 invalid な入力" から区別するにはどうしますか？,  Prev: 拡張をデバッグするにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.14 Linux システムで Python モジュールをコンパイルしたいのですが、見つからないファイルがあります。なぜですか？
------------------------------------------------------------------------------------------------------------------

Most packaged versions of Python omit some files required for compiling
Python extensions.

For Red Hat, install the python3-devel RPM to get the necessary files.

For Debian, run ‘apt-get install python3-dev’.


File: python.info,  Node: "不完全 incomplete な入力" を "不適切 invalid な入力" から区別するにはどうしますか？,  Next: 未定義の g++ シンボル __builtin_new や __pure_virtual を見つけるにはどうしますか？,  Prev: Linux システムで Python モジュールをコンパイルしたいのですが、見つからないファイルがあります。なぜですか？,  Up: 拡張と埋め込み FAQ

10.5.15 "不完全 (incomplete) な入力" を "不適切 (invalid) な入力" から区別するにはどうしますか？
------------------------------------------------------------------------------------------------

Python インタラクティブインタプリタでは、入力が不完全なとき (例えば、
"if" 文の始まりをタイプした時や、カッコや三重文字列引用符を閉じていない
時など) には継続プロンプトを与えられますが、入力が不適切であるときには即
座に構文エラーメッセージが与えられます。このようなふるまいを模倣したいこ
とがあります。

Python では構文解析器のふるまいに十分に近い *note codeop: 15. モジュール
が使えます。例えば IDLE がこれを使っています。

これを C で行う最も簡単な方法は、 *note PyRun_InteractiveLoop(): 495f. を
(おそらく別のスレッドで) 呼び出し、Python インタプリタにあなたの入力を扱
わせることです。独自の入力関数を指定するのに *note
PyOS_ReadlineFunctionPointer(): 552. を設定することもできます。詳しいヒ
ントは、 ‘Modules/readline.c’ や ‘Parser/myreadline.c’ を参照してくださ
い。


File: python.info,  Node: 未定義の g++ シンボル __builtin_new や __pure_virtual を見つけるにはどうしますか？,  Next: メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを 継承などで 作ることはできますか？,  Prev: "不完全 incomplete な入力" を "不適切 invalid な入力" から区別するにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.16 未定義の g++ シンボル __builtin_new や __pure_virtual を見つけるにはどうしますか？
------------------------------------------------------------------------------------------

g++ モジュールを動的にロードするには、Python を再コンパイルし、それを
g++ で再リンク (Python Modules Makefile 内の LINKCC を変更) し、拡張を
g++ でリンク (例えば ‘g++ -shared -o mymodule.so mymodule.o’) しなければ
なりません。


File: python.info,  Node: メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを 継承などで 作ることはできますか？,  Prev: 未定義の g++ シンボル __builtin_new や __pure_virtual を見つけるにはどうしますか？,  Up: 拡張と埋め込み FAQ

10.5.17 メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを (継承などで) 作ることはできますか？
-----------------------------------------------------------------------------------------------------------------------

はい、 *note int: 238. 、 *note list: 5dc. 、 *note dict: 237. などのビ
ルトインクラスから継承できます。

The Boost Python Library (BPL,
‘https://www.boost.org/libs/python/doc/index.html’) を使えば、これを C++
からできます。 (すなわち、BPL を使って C++ で書かれた拡張クラスを継承で
きます).


File: python.info,  Node: Windows 上の Python FAQ,  Next: グラフィックユーザインターフェース FAQ,  Prev: 拡張と埋め込み FAQ,  Up: Python よくある質問

10.6 Windows 上の Python FAQ
============================

* Menu:

* Python プログラムを Windows で動かすにはどうしますか？::
* Python スクリプトを実行可能にするにはどうしますか？::
* Python の起動に時間がかかることがあるのはなぜですか？::
* どうすれば Python スクリプトを EXE に出来ますか?::
* *.pyd ファイルは DLL と同じですか？: * pyd ファイルは DLL と同じですか？.
* Python を Windows アプリケーションに埋め込むにはどうしたらいいですか？::
* エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？::
* ブロックすることなく押鍵を検出するにはどうしますか？::
* missing api-ms-win-crt-runtime-l1-1-0.dll エラーを解決するにはどうしますか？: missing api-ms-win-crt-runtime-l1-1-0 dll エラーを解決するにはどうしますか？.


File: python.info,  Node: Python プログラムを Windows で動かすにはどうしますか？,  Next: Python スクリプトを実行可能にするにはどうしますか？,  Up: Windows 上の Python FAQ

10.6.1 Python プログラムを Windows で動かすにはどうしますか？
-------------------------------------------------------------

これは必ずしも単純な質問ではありません。Windows コマンドラインからプログ
ラムを実行するのに慣れてしまっている場合は、全て明らかなことに思えるでし
ょう; そうでない場合は、もう少し手引きが必要でしょう。

ある種の統合開発環境を使っているのでなければ、最終的には "コマンドプロン
プト" などと呼ばれているものに、 Windows コマンドをタイプすることになる
でしょう。 通常そういうウィンドウは検索バーで ‘cmd’ を検索して起動します
。 通常は次のような見た目の Windows の "コマンド プロンプト" が現れるの
で、ウィンドウが起動したのが分かるはずです:

     C:\>

この文字は異なっていたり、続きがあったりするので、コンピュータの設定や、
あなたが最近何をしたかに依って、このようになっていることもあるでしょう:

     D:\YourName\Projects\Python>

このようなウィンドウさえ開けば、Python プログラムを動かす手順は順調に進
みます。

Python スクリプトは Python 'インタプリタ' と呼ばれる別のプログラムで処理
されなければならないということを、理解する必要があります。インタプリタは
スクリプトを読み込み、バイトコードにコンパイルし、バイトコードを実行しプ
ログラムを走らせます。では、インタプリタが Python スクリプトを取り扱うた
めには、どんな用意をするのでしょうか?

まず最初に、コマンドウィンドウに "py" という単語がインタプリタを起動する
指示であると認識させる必要があります。 コマンドウィンドウを開いたら、
‘py’ というコマンドを入力し、リターンキーを叩いてください。:

     C:\Users\YourName> py

次のような出力が見えるでしょう:

     Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
     Type "help", "copyright", "credits" or "license" for more information.
     >>>

インタプリタの"対話モード"が始まりました。これで Python の文や式を対話的
に入力して、待っている間に実行や評価させることができます。これが Python
の最強の機能のひとつです。いくつかの式を選んで入力し、結果を見て確かめて
みましょう:

     >>> print("Hello")
     Hello
     >>> "Hello" * 3
     'HelloHelloHello'

多くの人が対話モードを便利で高度なプログラム可能計算機として使っています
。対話式 Python セッションを終わらせたいなら、 *note exit(): 20ee. 関数
を呼び出すか、 ‘Ctrl’ キーを押しながら ‘Z’ を入力し "‘Enter’" キーを押し
て、 Windows コマンドプロンプトに戻ってください。

スタート ‣ すべてのプログラム ‣ Python 3.x ‣ Python (command line) のよ
うな項目がスタートメニューに見付かるかもしれません。 これを起動すると、
新しいウィンドウに ‘>>>’ というプロンプトが見られるでしょう。その場合、
*note exit(): 20ee. 関数を呼び出すか ‘Ctrl-Z’ を入力するとウィンドウは閉
じます; Windows は 1 つの "python" コマンドをウィンドウで実行していて、
インタプリタを終了させたときに、そのウィンドウを閉じます。

‘py’ コマンドが認識されていることが確認できたので、 Python スクリプトを
与えられるようになりました。 そのためには Python スクリプトの絶対パスあ
るいは相対パスを与える必要があります。 Python スクリプトがデスクトップに
あり、 ‘hellp.py’ という名前で、ちょうど良いことにコマンドプロンプトがホ
ームディレクトリを開いていると仮定しましょう。そうすると次のような表示が
見られます:

     C:\Users\YourName>

ここまで来れば ‘py’ の後ろにスクリプトのパスを入力することで、 Python に
スクリプトを渡すよう ‘py’ コマンドに命令できます:

     C:\Users\YourName> py Desktop\hello.py
     hello


File: python.info,  Node: Python スクリプトを実行可能にするにはどうしますか？,  Next: Python の起動に時間がかかることがあるのはなぜですか？,  Prev: Python プログラムを Windows で動かすにはどうしますか？,  Up: Windows 上の Python FAQ

10.6.2 Python スクリプトを実行可能にするにはどうしますか？
----------------------------------------------------------

Windows では、標準の Python インストーラはすでに .py 拡張子をあるファイ
ル型 (Python.File) に関連付け、そのファイル型にインタプリタを実行するオ
ープンコマンド (‘D:\Program Files\Python\python.exe "%1" %*’) を与えます
。コマンドプロンプトから 'foo.py' としてスクリプトを実行可能にするにはこ
れで十分です。スクリプトを拡張子なしで 'foo' とだけタイプして実行したい
のなら、PATHEXT 環境変数に .py を加えてください。


File: python.info,  Node: Python の起動に時間がかかることがあるのはなぜですか？,  Next: どうすれば Python スクリプトを EXE に出来ますか?,  Prev: Python スクリプトを実行可能にするにはどうしますか？,  Up: Windows 上の Python FAQ

10.6.3 Python の起動に時間がかかることがあるのはなぜですか？
------------------------------------------------------------

通常 Python は Windows でとても早く起動しますが、ときどき Python が急に
スタートアップに時間がかかるようになったというバグレポートがあります。更
に複雑なことに、Python は同様に設定された他の Windows システムではきちん
と動くのです。

この問題はそのマシンのウイルス対策ソフトウェアの設定ミスによって起こされ
ることがあります。ウイルススキャナの中には、ファイルシステムからの全ての
読み込みを監視するように設定した場合に、二桁のスタートアップオーバーヘッ
ドを引き起すことが知られているものがあります。あなたのシステムのウイルス
スキャンソフトウェアの設定を確かめて、本当に同様に設定されていることを確
実にしてください。


File: python.info,  Node: どうすれば Python スクリプトを EXE に出来ますか?,  Next: * pyd ファイルは DLL と同じですか？,  Prev: Python の起動に時間がかかることがあるのはなぜですか？,  Up: Windows 上の Python FAQ

10.6.4 どうすれば Python スクリプトを EXE に出来ますか?
-------------------------------------------------------

実行可能ファイルを作れるツールの一覧 *note どうしたら Python
スクリプトからスタンドアロンバイナリを作れますか？: 4eee. を参照してくだ
さい。


File: python.info,  Node: * pyd ファイルは DLL と同じですか？,  Next: Python を Windows アプリケーションに埋め込むにはどうしたらいいですか？,  Prev: どうすれば Python スクリプトを EXE に出来ますか?,  Up: Windows 上の Python FAQ

10.6.5 ‘*.pyd’ ファイルは DLL と同じですか？
--------------------------------------------

はい、.pyd ファイルは dll と同じようなものですが、少し違いがあります。
‘foo.pyd’ という名前の DLL があったとしたら、それには関数 ‘PyInit_foo()’
が含まれていなければなりません。そうすれば Python で "import foo" を書け
て、Python は foo.pyd (や foo.py、foo.pyc) を探して、あれば、
‘PyInit_foo()’ を呼び出して初期化しようとします。Windows が DLL の存在を
必要とするのと違い、.exe ファイルを foo.lib にリンクするわけではありませ
ん。

なお、foo.pyd を検索するパスは PYTHONPATH であり、Windows が foo.dll を
検索するパスと同じではありません。また、プログラムを dll にリンクしたと
きはプログラムの実行に dll が必要ですが、foo.pyd は実行には必要はありま
せん。もちろん、 ‘import foo’ したいなら foo.pyd は必要です。DLL では、
リンクはソースコード内で ‘__declspec(dllexport)’ によって宣言されます。
.pyd では、リンクは使える関数のリストで定義されます。


File: python.info,  Node: Python を Windows アプリケーションに埋め込むにはどうしたらいいですか？,  Next: エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？,  Prev: * pyd ファイルは DLL と同じですか？,  Up: Windows 上の Python FAQ

10.6.6 Python を Windows アプリケーションに埋め込むにはどうしたらいいですか？
-----------------------------------------------------------------------------

Python インタプリタを Windows app に埋め込む方法は、次のように要約できま
す:

  1. あなたの .exe 内に直接 Python を取り込んでビルド 'しないで' 下さい
     。Windows では、それ自身が DLL になっているようなモジュールのインポ
     ートを処理するために、Python は DLL でなければなりません。(ドキュメ
     ント化されていない重大な事実の一つ目です。)代わりに、
     ‘python`NN'.dll’ とリンクしてください; 普通はそれは
     ‘C:\Windows\System’ にインストールされています。 'NN' は Python バ
     ージョンで Python 3.3 であれば "33" のような数字です。

     Python には、load-time に、または run-time にリンクできます。
     load-time なリンクは、 ‘python`NN'.lib’ に対してリンクするもので、
     run-time なリンクは ‘python`NN'.dll’ に対してリンクするものです。
     (一般的な注意: ‘python`NN'.lib’ は ‘python`NN'.dll’ に対するいわゆ
     る "インポートライブラリ" です。これは単にリンカに対するシンボルを
     定義します。)

     run-time なリンクは、リンクの選択を大いに単純化します。全ては実行時
     に行われます。コードは Windows の ‘LoadLibraryEx()’ ルーチンで
     ‘python`NN'.dll’ をロードしなければなりません。コードはまた、
     Windows の ‘GetProcAddress()’ ルーチンで得られるポインタで、
     ‘python`NN'.dll’ (すなわち、Python の C API)のルーチンとデータへア
     クセスしていなければなりません。マクロによって、このポインタを
     Python の C API のルーチンを呼び出す任意の C コードに通して使えます
     。

  2. SWIG を使えば、app のデータとメソッドを Python で使えるようにする
     Python "拡張モジュール"を簡単に作れます。SWIG は雑用を殆どやってく
     れるでしょう。結果として、.exe ファイル 'の中に' リンクする C コー
     ドができます(！)。DLL を作 'らなくてもよく'、リンクも簡潔になります
     。

  3. SWIG は拡張の名前に依る名前の init 関数 (C 関数) を作ります。例えば
     、モジュールの名前が leo なら、init 関数の名前は initleo() になりま
     す。SWIG shadow クラスを使ったほうがよく、そうすると init 関数の名
     前は initleoc() になります。これは shadow クラスが使うほとんど隠れ
     た helper クラスを初期化します。

     ステップ 2 の C コードを .exe ファイルにリンクできるのは、初期化関
     数の呼び出しと Python へのモジュールのインポートが同等だからです！
     (ドキュメント化されていない重大な事実の二つ目です)

  4. 要するに、以下のコードを使って Python インタプリタを拡張モジュール
     込みで初期化することができます。

          #include <Python.h>
          ...
          Py_Initialize();  // Initialize Python.
          initmyAppc();  // Initialize (import) the helper class.
          PyRun_SimpleString("import myApp");  // Import the shadow class.

  5. Python の C API には、pythonNN.dll をビルドするのに使われたコンパイ
     ラ MSVC 以外のコンパイラを使うと現れる二つの問題があります。

     問題 1: コンパイラによって ‘struct FILE’ に対する概念が異なるため、
     ‘FILE *’ 引数を取るいわゆる "超高水準" 関数は、多コンパイラ環境で働
     きません。実装の観点から、これらは超低水準関数になっています。

     問題 2: SWIG は void 関数へのラッパを生成するときに以下のコードを生
     成します:

          Py_INCREF(Py_None);
          _resultobj = Py_None;
          return _resultobj;

     ああ、Py_none は pythonNN.dll 内の _Py_NoneStruct という複雑なデー
     タ構造に展開するマクロです。また、このコードは他コンパイラ環境では
     失敗します。このコードを次のように置き換えてください:

          return Py_BuildValue("");

     これで、SWIG をまだ仕事に使えない (私は SWIG の完全な初心者です) 私
     でも、SWIG の ‘%typemap’ コマンドを使って自動的に変更できるようにな
     ります。

  6. Python シェルスクリプトを使って Windows app 内から Python インタプ
     リタウィンドウを掲示するのはいい方法ではありません。そのように表示
     されるウィンドウは app のウィンドウシステムとは関係ありません。むし
     ろ "ネイティブな" インタプリタウィンドウを (wxPythonWindow を使った
     りして) 作るべきです。そのウィンドウを Python インタプリタにつなぐ
     のは簡単です。Python の i/o は読み書きをサポートする _どんな_ オブ
     ジェクトにもリダイレクトできるので、read() と write() メソッドを含
     む (拡張モジュールで定義された) Python オブジェクトさえあればいいの
     です。


File: python.info,  Node: エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？,  Next: ブロックすることなく押鍵を検出するにはどうしますか？,  Prev: Python を Windows アプリケーションに埋め込むにはどうしたらいいですか？,  Up: Windows 上の Python FAQ

10.6.7 エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？
-----------------------------------------------------------------------------------

この FAQ ではタブを使うことを勧めません。Python スタイルガイド PEP 8(1)
では、配布される Python コードにはスペース 4 つを使うことを推奨していま
す。これは Emacs の python-mode のデフォルトでも同じです。

いかなるエディタでも、タブとスペースを混ぜるのは良くないです。 MSVC も全
く同じ立場であり、スペースを使うようにする設定が簡単にできます。 Tools ‣
Options ‣ Tabs を選択し、ファイルタイプの "デフォルト" の "タブ幅" と "イ
ンデント幅" に 4 を設定して、 "スペースを挿入する" のラジオボタンを選択
してください。

Python は、もしタブとスペースが混在していることで先頭の空白に問題がある
場合、*note IndentationError: 773. または *note TabError: 50e. を送出し
ます。 *note tabnanny: c7. モジュールを実行することで、ディレクトリーツ
リーをバッチモードでチェックすることができます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0008/


File: python.info,  Node: ブロックすることなく押鍵を検出するにはどうしますか？,  Next: missing api-ms-win-crt-runtime-l1-1-0 dll エラーを解決するにはどうしますか？,  Prev: エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？,  Up: Windows 上の Python FAQ

10.6.8 ブロックすることなく押鍵を検出するにはどうしますか？
-----------------------------------------------------------

*note msvcrt: 85. モジュールを使ってください。これは標準の Windows 専用
拡張モジュールです。これはキーボードが打たれているかを調べる関数
‘kbhit()’ と、反響することなく一文字を得る ‘getch()’ を定義します。


File: python.info,  Node: missing api-ms-win-crt-runtime-l1-1-0 dll エラーを解決するにはどうしますか？,  Prev: ブロックすることなく押鍵を検出するにはどうしますか？,  Up: Windows 上の Python FAQ

10.6.9 missing api-ms-win-crt-runtime-l1-1-0.dll エラーを解決するにはどうしますか？
-----------------------------------------------------------------------------------

この問題は更新がインストールされていない Windows 8.1 以前を使っていると
Python 3.5 以降で発生することがあります。まずはあなたのオペレーティング
システムがサポートされており最新であることを確認してください。それでも解
決しない場合は、 C ランタイムアップデートの手動インストール方法について
Microsoft support page(1) を参照してください。

   ---------- Footnotes ----------

   (1) https://support.microsoft.com/en-us/help/3118401/


File: python.info,  Node: グラフィックユーザインターフェース FAQ,  Next: "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ,  Prev: Windows 上の Python FAQ,  Up: Python よくある質問

10.7 グラフィックユーザインターフェース FAQ
===========================================

* Menu:

* 一般的な GUI の質問::
* Python の GUI ツールキットには何がありますか？::
* Tkinter の質問::


File: python.info,  Node: 一般的な GUI の質問,  Next: Python の GUI ツールキットには何がありますか？,  Up: グラフィックユーザインターフェース FAQ

10.7.1 一般的な GUI の質問
--------------------------


File: python.info,  Node: Python の GUI ツールキットには何がありますか？,  Next: Tkinter の質問,  Prev: 一般的な GUI の質問,  Up: グラフィックユーザインターフェース FAQ

10.7.2 Python の GUI ツールキットには何がありますか？
-----------------------------------------------------

Python の標準的なビルドには、 *note tkinter: 3cc8. という Tcl/Tk ウィジ
ェットセットのオブジェクト指向インターフェースが含まれています。これは最
も簡単にインストールして使えるでしょう (なぜなら、これは Python のほとん
どの バイナリディストリビューション(1) に同梱されているからです)。ソース
へのポインタなど、 Tk に関する詳しい情報は、 Tcl/Tk ホームページ(2) を参
照してください。 Tcl/Tk は、 macOS 、Windows 、 Unix プラットフォームに
完全にポータブルです。

対象とするプラットフォームによっては他の選択肢もあります。プラットフォー
ム互換(3) および プラットフォーム固有(4) の GUI フレームワークのリストを
python wiki で参照できます。

   ---------- Footnotes ----------

   (1) https://www.python.org/downloads/

   (2) https://www.tcl.tk

   (3) 
https://wiki.python.org/moin/GuiProgramming#Cross-Platform_Frameworks

   (4) 
https://wiki.python.org/moin/GuiProgramming#Platform-specific_Frameworks


File: python.info,  Node: Tkinter の質問,  Prev: Python の GUI ツールキットには何がありますか？,  Up: グラフィックユーザインターフェース FAQ

10.7.3 Tkinter の質問
---------------------

* Menu:

* Tkinter アプリケーションを凍結するにはどうしますか？::
* I/O を待つ間に扱われる Tk イベントを作れますか？::
* Tkinter で働くキーバインディングが得られません。なぜですか？::


File: python.info,  Node: Tkinter アプリケーションを凍結するにはどうしますか？,  Next: I/O を待つ間に扱われる Tk イベントを作れますか？,  Up: Tkinter の質問

10.7.3.1 Tkinter アプリケーションを凍結するにはどうしますか？
.............................................................

Freeze はスタンドアロンアプリケーションを生成するツールです。Tkinter ア
プリケーションを凍結するとき、それは Tcl と Tk ライブラリを必要とするの
で、真のスタンドアロンにはなりません。

一つの解決策は、アプリケーションに Tcl と Tk ライブラリを同梱し、環境変
数 ‘TCL_LIBRARY’ と ‘TK_LIBRARY’ でランタイムに指定することです。

Various third-party freeze libraries such as py2exe and cx_Freeze have
handling for Tkinter applications built-in.


File: python.info,  Node: I/O を待つ間に扱われる Tk イベントを作れますか？,  Next: Tkinter で働くキーバインディングが得られません。なぜですか？,  Prev: Tkinter アプリケーションを凍結するにはどうしますか？,  Up: Tkinter の質問

10.7.3.2 I/O を待つ間に扱われる Tk イベントを作れますか？
.........................................................

Windows 以外のプラットフォームについては、はい、スレッドさえ必要ありませ
ん！ ただし、I/O コードを少し再構成しなければなりません。Tk には Xt の
‘XtAddInput()’ コールと同等なものがあるので、ファイルディスクリプタ上で
I/O が可能なときに Tk メインループから呼ばれるコールバック関数を登録でき
ます。 *note ファイルハンドラ: 3ce5. を参照してください。


File: python.info,  Node: Tkinter で働くキーバインディングが得られません。なぜですか？,  Prev: I/O を待つ間に扱われる Tk イベントを作れますか？,  Up: Tkinter の質問

10.7.3.3 Tkinter で働くキーバインディングが得られません。なぜですか？
.....................................................................

‘bind()’ メソッドでイベントに *note 結び付けられた: 3ce0. イベントハンド
ラが、適切なキーが押されたときにさえハンドルされないという苦情がよく聞か
れます。

最も一般的な原因は、バインディングが適用されるウィジェットが "キーボード
フォーカス" を持たないことです。Tk ドキュメントでフォーカスコマンドを確
認してください。通常はウィジェットの中をクリックすることでキーボードフォ
ーカスを与えられます (ただしラベルには与えられません。takefocus オプショ
ンを参照してください)。


File: python.info,  Node: "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ,  Prev: グラフィックユーザインターフェース FAQ,  Up: Python よくある質問

10.8 "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ
===========================================================================

* Menu:

* Python とは何ですか？: Python とは何ですか？<2>.
* なぜ Python が私のマシンにインストールされているのですか？::
* Python を削除してもいいですか？::


File: python.info,  Node: Python とは何ですか？<2>,  Next: なぜ Python が私のマシンにインストールされているのですか？,  Up: "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ

10.8.1 Python とは何ですか？
----------------------------

Python はプログラミング言語の一つです。Python は様々なアプリケーションに
使われています。Python は習得しやすいので、一部の高校や大学で入門用のプ
ログラミング言語として使われています。一方で、Google、NASA、Lucasfilm
Ltd.  のような組織でプロフェッショナルなソフトウェア開発者にも使われてい
ます。

Python についてもっと詳しく知りたいなら、Beginner's Guide to Python(1) か
ら始めましょう。

   ---------- Footnotes ----------

   (1) https://wiki.python.org/moin/BeginnersGuide


File: python.info,  Node: なぜ Python が私のマシンにインストールされているのですか？,  Next: Python を削除してもいいですか？,  Prev: Python とは何ですか？<2>,  Up: "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ

10.8.2 なぜ Python が私のマシンにインストールされているのですか？
-----------------------------------------------------------------

インストールした覚えがないのに Python があなたのシステムにインストールさ
れているとしたら、その理由にはいくつかの可能性があります。

   * もしかしたら、コンピュータの他のユーザがプログラミングを学ぶために
     インストールしたのかもしれません。誰がそのマシンを使っていて Python
     をインストールしたか知る必要があります。

   * マシンにインストールされているサードパーティのアプリケーションが、
     Python で書かれていて Python のインストールを含んでいるかもしれませ
     ん。そのようなアプリケーションは、GUI プログラムからネットワーク・
     サーバや管理スクリプトまで、たくさんあります。

   * Windows マシンにも Python がインストールされたものがあります。この
     執筆時点で Hewlett-Packard や Compaq が Python を組み込んでいること
     を確認しています。 HP/Compaq の管理ツールの中には、Python で書かれ
     たものもあるようです。

   * macOS や一部の Linux ディストリビューションなど、多くの Unix 互換オ
     ペレーティングシステムシステムには、Python がデフォルトでインストー
     ルされています。標準インストールに Python が含まれているのです。


File: python.info,  Node: Python を削除してもいいですか？,  Prev: なぜ Python が私のマシンにインストールされているのですか？,  Up: "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ

10.8.3 Python を削除してもいいですか？
--------------------------------------

Python をどこから手に入れたかによります。

誰かが Python を意図してダウンロードしたのであれば、何の問題もなく削除す
ることができます。Windows では、コントロールパネルのプログラムの追加と削
除を使ってください。

Python がサードパーティのアプリケーションによってインストールされたなら
、同様に削除できますが、そのアプリケーションは動作しなくなります。
Python のディレクトリを削除するのではなく、そのアプリケーションのアンイ
ンストーラーを使うべきです。

Python がオペレーティングシステムに含まれて来たなら、削除はお勧めできま
せん。削除してしまうと、Python で書かれたプログラムは全く動かなくなり、
その中には重要なものが含まれているかもしれません。その場合、修復にはシス
テム全体の再インストールが必要になるでしょう。


File: python.info,  Node: Deprecations,  Next: 用語集<2>,  Prev: Python よくある質問,  Up: Top

11 Deprecations
***************

* Menu:

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<5>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<5>.
* Pending removal in Python 3.16: Pending removal in Python 3 16<3>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<5>.
* C API Deprecations::


File: python.info,  Node: Pending Removal in Python 3 14<5>,  Next: Pending Removal in Python 3 15<5>,  Up: Deprecations

11.1 Pending Removal in Python 3.14
===================================

   * *note argparse: 5.: The 'type', 'choices', and 'metavar' parameters
     of ‘argparse.BooleanOptionalAction’ are deprecated and will be
     removed in 3.14.  (Contributed by Nikita Sobolev in gh-92248(1).)

   * *note ast: 7.: The following features have been deprecated in
     documentation since Python 3.8, now cause a *note
     DeprecationWarning: 18a. to be emitted at runtime when they are
     accessed or used, and will be removed in Python 3.14:

        * ‘ast.Num’

        * ‘ast.Str’

        * ‘ast.Bytes’

        * ‘ast.NameConstant’

        * ‘ast.Ellipsis’

     Use *note ast.Constant: 299. instead.  (Contributed by Serhiy
     Storchaka in gh-90953(2).)

   * *note asyncio: 8.:

        * The child watcher classes *note MultiLoopChildWatcher: 29a,
          *note FastChildWatcher: 29b, *note AbstractChildWatcher: 29c.
          and *note SafeChildWatcher: 29d. are deprecated and will be
          removed in Python 3.14.  (Contributed by Kumar Aditya in
          gh-94597(3).)

        * *note asyncio.set_child_watcher(): 29e, *note
          asyncio.get_child_watcher(): 29f, *note
          asyncio.AbstractEventLoopPolicy.set_child_watcher(): 2a0. and
          *note asyncio.AbstractEventLoopPolicy.get_child_watcher():
          2a1. are deprecated and will be removed in Python 3.14.
          (Contributed by Kumar Aditya in gh-94597(4).)

        * The *note get_event_loop(): 2a2. method of the default event
          loop policy now emits a *note DeprecationWarning: 18a. 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(5).)

   * *note collections.abc: 17.: Deprecated *note ByteString: 2a3.
     Prefer ‘Sequence’ or *note Buffer: 2a4.  For use in typing, prefer
     a union, like ‘bytes | bytearray’, or *note collections.abc.Buffer:
     2a4.  (Contributed by Shantanu Jain in gh-91896(6).)

   * *note email: 32.: Deprecated the 'isdst' parameter in *note
     email.utils.localtime(): 2a5.  (Contributed by Alan Williams in
     gh-72346(7).)

   * *note importlib.abc: 6c. deprecated classes:

        * ‘importlib.abc.ResourceReader’

        * ‘importlib.abc.Traversable’

        * ‘importlib.abc.TraversableResources’

     Use *note importlib.resources.abc: 70. classes instead:

        * *note importlib.resources.abc.Traversable: 1d4.

        * *note importlib.resources.abc.TraversableResources: 2a6.

     (Contributed by Jason R. Coombs and Hugo van Kemenade in
     gh-93963(8).)

   * *note itertools: 75. 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(9).)

   * *note multiprocessing: 86.: The default start method will change to
     a safer one on Linux, BSDs, and other non-macOS POSIX platforms
     where ‘'fork'’ is currently the default (gh-84559(10)).  Adding a
     runtime warning about this was deemed too disruptive as the
     majority of code is not expected to care.  Use the *note
     get_context(): 2a7. or *note set_start_method(): 2a8. APIs to
     explicitly specify when your code 'requires' ‘'fork'’.  See *note
     コンテキストと開始方式: 2a9.

   * *note pathlib: 93.: *note is_relative_to(): 2aa. and *note
     relative_to(): 2ab.: passing additional arguments is deprecated.

   * *note pkgutil: 97.: *note find_loader(): 2ac. and *note
     get_loader(): 2ad. now raise *note DeprecationWarning: 18a.; use
     *note importlib.util.find_spec(): 2ae. instead.  (Contributed by
     Nikita Sobolev in gh-97850(11).)

   * *note pty: 9f.:

        * ‘master_open()’: use *note pty.openpty(): 2af.

        * ‘slave_open()’: use *note pty.openpty(): 2af.

   * *note sqlite3: ba.:

        * *note version: 2b0. and *note version_info: 2b1.

        * *note execute(): 2b2. and *note executemany(): 2b3. if *note
          named placeholders: 2b4. are used and 'parameters' is a
          sequence instead of a *note dict: 237.

   * *note typing: ed.: *note ByteString: 2b5, deprecated since Python
     3.9, now causes a *note DeprecationWarning: 18a. to be emitted when
     it is used.

   * *note urllib: f1.: ‘urllib.parse.Quoter’ is deprecated: it was not
     intended to be a public API. (Contributed by Gregory P. Smith in
     gh-88168(12).)

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/92248

   (2) https://github.com/python/cpython/issues/90953

   (3) https://github.com/python/cpython/issues/94597

   (4) https://github.com/python/cpython/issues/94597

   (5) https://github.com/python/cpython/issues/100160

   (6) https://github.com/python/cpython/issues/91896

   (7) https://github.com/python/cpython/issues/72346

   (8) https://github.com/python/cpython/issues/93963

   (9) https://github.com/python/cpython/issues/101588

   (10) https://github.com/python/cpython/issues/84559

   (11) https://github.com/python/cpython/issues/97850

   (12) https://github.com/python/cpython/issues/88168


File: python.info,  Node: Pending Removal in Python 3 15<5>,  Next: Pending removal in Python 3 16<3>,  Prev: Pending Removal in Python 3 14<5>,  Up: Deprecations

11.2 Pending Removal in Python 3.15
===================================

   * The import system:

        * Setting *note __cached__: 2b7. on a module while failing to
          set *note __spec__.cached: 2b8. 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(1))

        * Setting *note __package__: 2b9. on a module while failing to
          set *note __spec__.parent: 2ba. is deprecated.  In Python
          3.15, ‘__package__’ will cease to be set or take into
          consideration by the import system or standard library.
          (gh-97879(2))

   * *note ctypes: 22.:

        * The undocumented ‘ctypes.SetPointerType()’ function has been
          deprecated since Python 3.13.

   * *note http.server: 68.:

        * The obsolete and rarely used *note CGIHTTPRequestHandler: 281.
          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.

        * The ‘--cgi’ flag to the ‘python -m http.server’ command-line
          interface has been deprecated since Python 3.13.

   * *note locale: 7a.:

        * The *note getdefaultlocale(): 2bb. function has been
          deprecated since Python 3.11.  Its removal was originally
          planned for Python 3.13 (gh-90817(3)), but has been postponed
          to Python 3.15.  Use *note getlocale(): 2bc, *note
          setlocale(): 2bd, and *note getencoding(): 2be. instead.
          (Contributed by Hugo van Kemenade in gh-111187(4).)

   * *note pathlib: 93.:

        * *note PurePath.is_reserved(): 286. has been deprecated since
          Python 3.13.  Use *note os.path.isreserved(): 204. to detect
          reserved paths on Windows.

   * *note platform: 98.:

        * *note java_ver(): 287. has been deprecated since Python 3.13.
          This function is only useful for Jython support, has a
          confusing API, and is largely untested.

   * *note threading: d6.:

        * *note RLock(): 2bf. 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.

   * *note types: ec.:

        * *note types.CodeType: 2c0.: Accessing *note co_lnotab: 2c1.
          was deprecated in PEP 626(5) since 3.10 and was planned to be
          removed in 3.12, but it only got a proper *note
          DeprecationWarning: 18a. in 3.12.  May be removed in 3.15.
          (Contributed by Nikita Sobolev in gh-101866(6).)

   * *note typing: ed.:

        * The undocumented keyword argument syntax for creating *note
          NamedTuple: 290. classes (e.g.  ‘Point = NamedTuple("Point",
          x=int, y=int)’) has been deprecated since Python 3.13.  Use
          the class-based syntax or the functional syntax instead.

        * The *note typing.no_type_check_decorator(): 291. decorator
          function has been deprecated since Python 3.13.  After eight
          years in the *note typing: ed. module, it has yet to be
          supported by any major type checker.

   * *note wave: fb.:

        * The *note getmark(): 294, ‘setmark()’, and *note getmarkers():
          295. methods of the *note Wave_read: 296. and *note
          Wave_write: 297. classes have been deprecated since Python
          3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/97879

   (2) https://github.com/python/cpython/issues/97879

   (3) https://github.com/python/cpython/issues/90817

   (4) https://github.com/python/cpython/issues/111187

   (5) https://peps.python.org/pep-0626/

   (6) https://github.com/python/cpython/issues/101866


File: python.info,  Node: Pending removal in Python 3 16<3>,  Next: Pending Removal in Future Versions<5>,  Prev: Pending Removal in Python 3 15<5>,  Up: Deprecations

11.3 Pending removal in Python 3.16
===================================

   * The import system:

        * Setting *note __loader__: 2c3. on a module while failing to
          set *note __spec__.loader: 2c4. is deprecated.  In Python
          3.16, ‘__loader__’ will cease to be set or taken into
          consideration by the import system or the standard library.

   * *note array: 6.:

        * The ‘'u'’ format code (‘wchar_t’) has been deprecated in
          documentation since Python 3.3 and at runtime since Python
          3.13.  Use the ‘'w'’ format code (*note Py_UCS4: 27b.) for
          Unicode characters instead.

   * *note asyncio: 8.:

        * ‘asyncio.iscoroutinefunction()’ is deprecated and will be
          removed in Python 3.16, use *note
          inspect.iscoroutinefunction(): 2c5. instead.  (Contributed by
          Jiahao Li and Kumar Aditya in gh-122875(1).)

   * *note builtins: e.:

        * Bitwise inversion on boolean types, ‘~True’ or ‘~False’ has
          been deprecated since Python 3.12, as it produces surprising
          and unintuitive results (‘-2’ and ‘-1’).  Use ‘not x’ instead
          for the logical negation of a Boolean.  In the rare case that
          you need the bitwise inversion of the underlying integer,
          convert to ‘int’ explicitly (‘~int(x)’).

   * *note shutil: b3.:

        * The ‘ExecError’ exception has been deprecated since Python
          3.14.  It has not been used by any function in ‘shutil’ since
          Python 3.4, and is now an alias of *note RuntimeError: 17a.

   * *note symtable: c2.:

        * The *note Class.get_methods: 2c6. method has been deprecated
          since Python 3.14.

   * *note sys: c3.:

        * The *note _enablelegacywindowsfsencoding(): 28e. function has
          been deprecated since Python 3.13.  Use the *note
          PYTHONLEGACYWINDOWSFSENCODING: 28f. environment variable
          instead.

   * *note tarfile: c8.:

        * The undocumented and unused ‘TarFile.tarfile’ attribute has
          been deprecated since Python 3.13.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/122875


File: python.info,  Node: Pending Removal in Future Versions<5>,  Next: C API Deprecations,  Prev: Pending removal in Python 3 16<3>,  Up: Deprecations

11.4 Pending Removal in Future Versions
=======================================

The following APIs will be removed in the future, although there is
currently no date scheduled for their removal.

   * *note argparse: 5.: Nesting argument groups and nesting mutually
     exclusive groups are deprecated.

   * *note array: 6.'s ‘'u'’ format code (gh-57281(1))

   * *note builtins: e.:

        * ‘bool(NotImplemented)’.

        * Generators: ‘throw(type, exc, tb)’ and ‘athrow(type, exc, tb)’
          signature is deprecated: use ‘throw(exc)’ and ‘athrow(exc)’
          instead, the single argument signature.

        * Currently Python accepts numeric literals immediately followed
          by keywords, for example ‘0in x’, ‘1or x’, ‘0if 1else 2’.  It
          allows confusing and ambiguous expressions like ‘[0x1for x in
          y]’ (which can be interpreted as ‘[0x1 for x in y]’ or ‘[0x1f
          or x in y]’).  A syntax warning is raised if the numeric
          literal is immediately followed by one of keywords *note and:
          2c8, *note else: 171, *note for: 2c9, *note if: 2ca, *note in:
          2cb, *note is: 2cc. and *note or: 2cd.  In a future release it
          will be changed to a syntax error.  (gh-87999(2))

        * Support for ‘__index__()’ and ‘__int__()’ method returning
          non-int type: these methods will be required to return an
          instance of a strict subclass of *note int: 238.

        * Support for ‘__float__()’ method returning a strict subclass
          of *note float: 2ce.: these methods will be required to return
          an instance of *note float: 2ce.

        * Support for ‘__complex__()’ method returning a strict subclass
          of *note complex: 2cf.: these methods will be required to
          return an instance of *note complex: 2cf.

        * Delegation of ‘int()’ to ‘__trunc__()’ method.

        * Passing a complex number as the 'real' or 'imag' argument in
          the *note complex(): 2cf. constructor is now deprecated; it
          should only be passed as a single positional argument.
          (Contributed by Serhiy Storchaka in gh-109218(3).)

   * *note calendar: 10.: ‘calendar.January’ and ‘calendar.February’
     constants are deprecated and replaced by *note calendar.JANUARY:
     2d0. and *note calendar.FEBRUARY: 2d1.  (Contributed by Prince
     Roshan in gh-103636(4).)

   * *note codeobject.co_lnotab: 2c1.: use the *note
     codeobject.co_lines(): 2d2. method instead.

   * *note datetime: 28.:

        * *note utcnow(): 2d3.: use
          ‘datetime.datetime.now(tz=datetime.UTC)’.

        * *note utcfromtimestamp(): 2d4.: use
          ‘datetime.datetime.fromtimestamp(timestamp, tz=datetime.UTC)’.

   * *note gettext: 59.: Plural value must be an integer.

   * *note importlib: 6b.:

        * ‘load_module()’ method: use ‘exec_module()’ instead.

        * *note cache_from_source(): 2d5. 'debug_override' parameter is
          deprecated: use the 'optimization' parameter instead.

   * *note importlib.metadata: 6e.:

        * ‘EntryPoints’ tuple interface.

        * Implicit ‘None’ on return values.

   * *note logging: 7b.: the ‘warn()’ method has been deprecated since
     Python 3.3, use *note warning(): 2d6. instead.

   * *note mailbox: 7f.: Use of StringIO input and text mode is
     deprecated, use BytesIO and binary mode instead.

   * *note os: 91.: Calling *note os.register_at_fork(): 2d7. in
     multi-threaded process.

   * ‘pydoc.ErrorDuringImport’: A tuple value for 'exc_info' parameter
     is deprecated, use an exception instance.

   * *note re: a7.: More strict rules are now applied for numerical
     group references and group names in regular expressions.  Only
     sequence of ASCII digits is now accepted as a numerical reference.
     The group name in bytes patterns and replacement strings can now
     only contain ASCII letters and digits and underscore.  (Contributed
     by Serhiy Storchaka in gh-91760(5).)

   * ‘sre_compile’, ‘sre_constants’ and ‘sre_parse’ modules.

   * *note shutil: b3.: *note rmtree(): 2d8.'s 'onerror' parameter is
     deprecated in Python 3.12; use the 'onexc' parameter instead.

   * *note ssl: bb. options and protocols:

        * *note ssl.SSLContext: 274. without protocol argument is
          deprecated.

        * *note ssl.SSLContext: 274.: *note set_npn_protocols(): 2d9.
          and ‘selected_npn_protocol()’ are deprecated: use ALPN
          instead.

        * ‘ssl.OP_NO_SSL*’ options

        * ‘ssl.OP_NO_TLS*’ options

        * ‘ssl.PROTOCOL_SSLv3’

        * ‘ssl.PROTOCOL_TLS’

        * ‘ssl.PROTOCOL_TLSv1’

        * ‘ssl.PROTOCOL_TLSv1_1’

        * ‘ssl.PROTOCOL_TLSv1_2’

        * ‘ssl.TLSVersion.SSLv3’

        * ‘ssl.TLSVersion.TLSv1’

        * ‘ssl.TLSVersion.TLSv1_1’

   * *note sysconfig.is_python_build(): 2da. 'check_home' parameter is
     deprecated and ignored.

   * *note threading: d6. methods:

        * ‘threading.Condition.notifyAll()’: use *note notify_all():
          2db.

        * ‘threading.Event.isSet()’: use *note is_set(): 2dc.

        * ‘threading.Thread.isDaemon()’, *note
          threading.Thread.setDaemon(): 2dd.: use *note
          threading.Thread.daemon: 2de. attribute.

        * ‘threading.Thread.getName()’, *note
          threading.Thread.setName(): 2df.: use *note
          threading.Thread.name: 2e0. attribute.

        * ‘threading.currentThread()’: use *note
          threading.current_thread(): 2e1.

        * ‘threading.activeCount()’: use *note threading.active_count():
          2e2.

   * *note typing.Text: 2e3. (gh-92332(6)).

   * *note unittest.IsolatedAsyncioTestCase: 2e4.: it is deprecated to
     return a value that is not ‘None’ from a test case.

   * *note urllib.parse: f3. deprecated functions: *note urlparse():
     2e5. instead

        * ‘splitattr()’

        * ‘splithost()’

        * ‘splitnport()’

        * ‘splitpasswd()’

        * ‘splitport()’

        * ‘splitquery()’

        * ‘splittag()’

        * ‘splittype()’

        * ‘splituser()’

        * ‘splitvalue()’

        * ‘to_bytes()’

   * *note urllib.request: f4.: *note URLopener: 2e6. and *note
     FancyURLopener: 2e7. style of invoking requests is deprecated.  Use
     newer *note urlopen(): 273. functions and methods.

   * *note wsgiref: 100.: ‘SimpleHandler.stdout.write()’ should not do
     partial writes.

   * *note xml.etree.ElementTree: 10c.: Testing the truth value of an
     *note Element: 2e8. is deprecated.  In a future release it will
     always return ‘True’.  Prefer explicit ‘len(elem)’ or ‘elem is not
     None’ tests instead.

   * *note zipimport.zipimporter.load_module(): 2e9. is deprecated: use
     *note exec_module(): 2ea. instead.

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/issues/57281

   (2) https://github.com/python/cpython/issues/87999

   (3) https://github.com/python/cpython/issues/109218

   (4) https://github.com/python/cpython/issues/103636

   (5) https://github.com/python/cpython/issues/91760

   (6) https://github.com/python/cpython/issues/92332


File: python.info,  Node: C API Deprecations,  Prev: Pending Removal in Future Versions<5>,  Up: Deprecations

11.5 C API Deprecations
=======================

* Menu:

* Pending Removal in Python 3.14: Pending Removal in Python 3 14<6>.
* Pending Removal in Python 3.15: Pending Removal in Python 3 15<6>.
* Pending Removal in Future Versions: Pending Removal in Future Versions<6>.


File: python.info,  Node: Pending Removal in Python 3 14<6>,  Next: Pending Removal in Python 3 15<6>,  Up: C API Deprecations

11.5.1 Pending Removal in Python 3.14
-------------------------------------

   * The ‘ma_version_tag’ field in *note PyDictObject: 39b. for
     extension modules ( PEP 699(1); gh-101193(2)).

   * Creating *note immutable types: 39c. with mutable bases
     (gh-95388(3)).

   * Functions to configure Python's initialization, deprecated in
     Python 3.11:

        * ‘PySys_SetArgvEx()’: Set *note PyConfig.argv: 39d. instead.

        * ‘PySys_SetArgv()’: Set *note PyConfig.argv: 39d. instead.

        * ‘Py_SetProgramName()’: Set *note PyConfig.program_name: 39e.
          instead.

        * ‘Py_SetPythonHome()’: Set *note PyConfig.home: 395. instead.

     The *note Py_InitializeFromConfig(): 39f. API should be used with
     *note PyConfig: 380. instead.

   * Global configuration variables:

        * *note Py_DebugFlag: 3a0.: Use *note PyConfig.parser_debug:
          3a1. instead.

        * *note Py_VerboseFlag: 3a2.: Use *note PyConfig.verbose: 3a3.
          instead.

        * *note Py_QuietFlag: 3a4.: Use *note PyConfig.quiet: 3a5.
          instead.

        * *note Py_InteractiveFlag: 3a6.: Use *note
          PyConfig.interactive: 3a7. instead.

        * *note Py_InspectFlag: 3a8.: Use *note PyConfig.inspect: 3a9.
          instead.

        * *note Py_OptimizeFlag: 3aa.: Use *note
          PyConfig.optimization_level: 3ab. instead.

        * *note Py_NoSiteFlag: 3ac.: Use *note PyConfig.site_import:
          3ad. instead.

        * *note Py_BytesWarningFlag: 3ae.: Use *note
          PyConfig.bytes_warning: 3af. instead.

        * *note Py_FrozenFlag: 3b0.: Use *note
          PyConfig.pathconfig_warnings: 3b1. instead.

        * *note Py_IgnoreEnvironmentFlag: 3b2.: Use *note
          PyConfig.use_environment: 3b3. instead.

        * *note Py_DontWriteBytecodeFlag: 3b4.: Use *note
          PyConfig.write_bytecode: 3b5. instead.

        * *note Py_NoUserSiteDirectory: 3b6.: Use *note
          PyConfig.user_site_directory: 3b7. instead.

        * *note Py_UnbufferedStdioFlag: 3b8.: Use *note
          PyConfig.buffered_stdio: 3b9. instead.

        * *note Py_HashRandomizationFlag: 3ba.: Use *note
          PyConfig.use_hash_seed: 3bb. and *note PyConfig.hash_seed:
          3bc. instead.

        * *note Py_IsolatedFlag: 3bd.: Use *note PyConfig.isolated: 3be.
          instead.

        * *note Py_LegacyWindowsFSEncodingFlag: 3bf.: Use *note
          PyPreConfig.legacy_windows_fs_encoding: 3c0. instead.

        * *note Py_LegacyWindowsStdioFlag: 3c1.: Use *note
          PyConfig.legacy_windows_stdio: 37e. instead.

        * ‘Py_FileSystemDefaultEncoding’: Use *note
          PyConfig.filesystem_encoding: 3c2. instead.

        * ‘Py_HasFileSystemDefaultEncoding’: Use *note
          PyConfig.filesystem_encoding: 3c2. instead.

        * ‘Py_FileSystemDefaultEncodeErrors’: Use *note
          PyConfig.filesystem_errors: 3c3. instead.

        * ‘Py_UTF8Mode’: Use *note PyPreConfig.utf8_mode: 3c4. instead.
          (see *note Py_PreInitialize(): 3c5.)

     The *note Py_InitializeFromConfig(): 39f. API should be used with
     *note PyConfig: 380. instead.

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0699/

   (2) https://github.com/python/cpython/issues/101193

   (3) https://github.com/python/cpython/issues/95388


File: python.info,  Node: Pending Removal in Python 3 15<6>,  Next: Pending Removal in Future Versions<6>,  Prev: Pending Removal in Python 3 14<6>,  Up: C API Deprecations

11.5.2 Pending Removal in Python 3.15
-------------------------------------

   * The bundled copy of ‘libmpdecimal’.

   * The *note PyImport_ImportModuleNoBlock(): 397.: Use *note
     PyImport_ImportModule(): 398. instead.

   * *note PyWeakref_GetObject(): 352. and *note PyWeakref_GET_OBJECT():
     399.: Use *note PyWeakref_GetRef(): 351. instead.

   * *note Py_UNICODE: 3c7. type and the ‘Py_UNICODE_WIDE’ macro: Use
     ‘wchar_t’ instead.

   * Python initialization functions:

        * *note PySys_ResetWarnOptions(): 389.: Clear *note
          sys.warnoptions: 38a. and ‘warnings.filters’ instead.

        * *note Py_GetExecPrefix(): 38b.: Get *note
          sys.base_exec_prefix: 3c8. and *note sys.exec_prefix: 38c.
          instead.

        * *note Py_GetPath(): 38d.: Get *note sys.path: 38e. instead.

        * *note Py_GetPrefix(): 38f.: Get *note sys.base_prefix: 3c9.
          and *note sys.prefix: 390. instead.

        * *note Py_GetProgramFullPath(): 391.: Get *note sys.executable:
          392. instead.

        * *note Py_GetProgramName(): 393.: Get *note sys.executable:
          392. instead.

        * *note Py_GetPythonHome(): 394.: Get *note PyConfig.home: 395.
          or the *note PYTHONHOME: 396. environment variable instead.


File: python.info,  Node: Pending Removal in Future Versions<6>,  Prev: Pending Removal in Python 3 15<6>,  Up: C API Deprecations

11.5.3 Pending Removal in Future Versions
-----------------------------------------

The following APIs are deprecated and will be removed, although there is
currently no date scheduled for their removal.

   * *note Py_TPFLAGS_HAVE_FINALIZE: 3cb.: Unneeded since Python 3.8.

   * *note PyErr_Fetch(): 3cc.: Use *note PyErr_GetRaisedException():
     3cd. instead.

   * *note PyErr_NormalizeException(): 3ce.: Use *note
     PyErr_GetRaisedException(): 3cd. instead.

   * *note PyErr_Restore(): 3cf.: Use *note PyErr_SetRaisedException():
     3d0. instead.

   * *note PyModule_GetFilename(): 3d1.: Use *note
     PyModule_GetFilenameObject(): 3d2. instead.

   * *note PyOS_AfterFork(): 3d3.: Use *note PyOS_AfterFork_Child():
     3d4. instead.

   * *note PySlice_GetIndicesEx(): 3d5.: Use *note PySlice_Unpack():
     3d6. and *note PySlice_AdjustIndices(): 3d7. instead.

   * ‘PyUnicode_AsDecodedObject()’: Use *note PyCodec_Decode(): 3d8.
     instead.

   * ‘PyUnicode_AsDecodedUnicode()’: Use *note PyCodec_Decode(): 3d8.
     instead.

   * ‘PyUnicode_AsEncodedObject()’: Use *note PyCodec_Encode(): 3d9.
     instead.

   * ‘PyUnicode_AsEncodedUnicode()’: Use *note PyCodec_Encode(): 3d9.
     instead.

   * *note PyUnicode_READY(): 3da.: Unneeded since Python 3.12

   * ‘PyErr_Display()’: Use *note PyErr_DisplayException(): 3db.
     instead.

   * ‘_PyErr_ChainExceptions()’: Use ‘_PyErr_ChainExceptions1()’
     instead.

   * ‘PyBytesObject.ob_shash’ member: call *note PyObject_Hash(): 3dc.
     instead.

   * ‘PyDictObject.ma_version_tag’ member.

   * Thread Local Storage (TLS) API:

        * *note PyThread_create_key(): 3dd.: Use *note
          PyThread_tss_alloc(): 3de. instead.

        * *note PyThread_delete_key(): 3df.: Use *note
          PyThread_tss_free(): 3e0. instead.

        * *note PyThread_set_key_value(): 3e1.: Use *note
          PyThread_tss_set(): 3e2. instead.

        * *note PyThread_get_key_value(): 3e3.: Use *note
          PyThread_tss_get(): 3e4. instead.

        * *note PyThread_delete_key_value(): 3e5.: Use *note
          PyThread_tss_delete(): 3e6. instead.

        * *note PyThread_ReInitTLS(): 3e7.: Unneeded since Python 3.7.


File: python.info,  Node: 用語集<2>,  Next: このドキュメントについて,  Prev: Deprecations,  Up: Top

12 用語集
*********

‘>>>’

     対話型 (*note interactive: 14f.) シェルにおけるデフォルトの Python
     プロンプトです。インタープリターで対話的に実行されるコード例でよく
     見られます。

‘...’

     次のものが考えられます:

        * 対話型 (*note interactive: 14f.) シェルにおいて、インデントさ
          れたコードブロック、対応する左右の区切り文字の組 (丸括弧、角括
          弧、波括弧、三重引用符) の内側、デコレーターの後に、コードを入
          力する際に表示されるデフォルトの Python プロンプトです。

        * 組み込みの定数 *note Ellipsis: 20ea. 。

abstract base class

     (抽象基底クラス) 抽象基底クラスは *note duck-typing: 4fb5. を補完す
     るもので、 *note hasattr(): 49e. などの別のテクニックでは不恰好であ
     ったり微妙に誤る (例えば *note magic methods: 1ec6. の場合) 場合に
     インターフェースを定義する方法を提供します。ABC は仮想 (virtual) サ
     ブクラスを導入します。これは親クラスから継承しませんが、それでも
     *note isinstance(): 40e. や *note issubclass(): 78c. に認識されます
     ; *note abc: 4. モジュールのドキュメントを参照してください。Python
     には、多くの組み込み ABC が同梱されています。その対象は、(*note
     collections.abc: 17. モジュールで) データ構造、(*note numbers: 8e.
     モジュールで) 数、(*note io: 73. モジュールで) ストリーム、(*note
     importlib.abc: 6c. モジュールで) インポートファインダ及びローダーで
     す。 *note abc: 4. モジュールを利用して独自の ABC を作成できます。

annotation

     (アノテーション) 変数、クラス属性、関数のパラメータや返り値に関係す
     るラベルです。 慣例により *note type hint: 1ee2. として使われていま
     す。

     ローカル変数のアノテーションは実行時にはアクセスできませんが、グロ
     ーバル変数、クラス属性、関数のアノテーションはそれぞれモジュール、
     クラス、関数の ‘__annotations__’ 特殊属性に保持されています。

     機能の説明がある *note variable annotation: d23, *note function
     annotation: 1ba1, PEP 484(1), PEP 526(2) を参照してください。また、
     アノテーションを利用するベストプラクティスとして *note Annotations
     Best Practices: 7a4. も参照してください。

引数 (argument)

     (実引数) 関数を呼び出す際に、 *note 関数: 1fb4. (または *note
     メソッド: 4fb6.) に渡す値です。実引数には２種類あります:

        * 'キーワード引数': 関数呼び出しの際に引数の前に識別子がついたも
          の (例: ‘name=’) や、 ‘**’ に続けた辞書の中の値として渡された
          引数。例えば、次の *note complex(): 2cf. の呼び出しでは、 ‘3’
          と ‘5’ がキーワード引数です:

               complex(real=3, imag=5)
               complex(**{'real': 3, 'imag': 5})

        * '位置引数': キーワード引数以外の引数。位置引数は引数リストの先
          頭に書くことができ、また ‘*’ に続けた *note iterable: 10ad. の
          要素として渡すことができます。例えば、次の例では ‘3’ と ‘5’ は
          両方共位置引数です:

               complex(3, 5)
               complex(*(3, 5))

     実引数は関数の実体において名前付きのローカル変数に割り当てられます
     。割り当てを行う規則については *note 呼び出し (call): d4a. を参照し
     てください。シンタックスにおいて実引数を表すためにあらゆる式を使う
     ことが出来ます。評価された値はローカル変数に割り当てられます。

     *note 仮引数: 1e5e. 、FAQ の *note 実引数と仮引数の違いは何ですか?:
     4ef9. 、 PEP 362(3) を参照してください。

asynchronous context manager

     (非同期コンテキストマネージャ) *note __aenter__(): 1f30. と *note
     __aexit__(): 158e. メソッドを定義することで *note async with: 59f.
     文内の環境を管理するオブジェクトです。 PEP 492(4) で導入されました
     。

asynchronous generator

     (非同期ジェネレータ) *note asynchronous generator iterator: 41fa. を
     返す関数です。 *note async def: 59b. で定義されたコルーチン関数に似
     ていますが、 *note yield: 99b. 式を持つ点で異なります。 *note
     yield: 99b. 式は *note async for: a79. ループで使用できる値の並びを
     生成するのに使用されます。

     通常は非同期ジェネレータ関数を指しますが、文脈によっては '非同期ジ
     ェネレータイテレータ' を指す場合があります。 意図された意味が明らか
     でない場合、 明瞭化のために完全な単語を使用します。

     非同期ジェネレータ関数には、 *note async for: a79. 文や *note async
     with: 59f. 文だけでなく *note await: 19e. 式もあることがあります。

asynchronous generator iterator

     (非同期ジェネレータイテレータ) *note asynchronous generator: 1f99.
     関数で生成されるオブジェクトです。

     これは *note asynchronous iterator: 190. で、 *note __anext__():
     1e6a. メソッドを使って呼ばれると awaitable オブジェクトを返します。
     この awaitable オブジェクトは、次の *note yield: 99b. 式まで非同期
     ジェネレータ関数の本体を実行します。

     各 *note yield: 99b. では一時的に処理を中断し、その場の実行状態 (ロ
     ーカル変数や保留中の try 文を含む) を記憶します。 '非同期ジェネレー
     タイテレータ' が *note __anext__(): 1e6a. で返された他の awaitable
     で実際に再開する時には、その中断箇所が選ばれます。 PEP 492(5) およ
     び PEP 525(6) を参照してください。

asynchronous iterable

     (非同期イテラブル) *note async for: a79. 文の中で使用できるオブジェ
     クトです。 自身の *note __aiter__(): bc9. メソッドから *note
     asynchronous iterator: 190. を返さなければなりません。 PEP 492(7) で
     導入されました。

asynchronous iterator

     (非同期イテレータ) *note __aiter__(): bc9. と *note __anext__():
     1e6a. メソッドを実装したオブジェクトです。 *note __anext__(): 1e6a.
     は *note awaitable: 192. オブジェクトを返さなければなりません。
     *note async for: a79. は *note StopAsyncIteration: 1998. 例外を送出
     するまで、非同期イテレータの *note __anext__(): 1e6a. メソッドが返
     す awaitable を解決します。 PEP 492(8) で導入されました。

属性

     (属性) オブジェクトに関連付けられ、ドット表記式によって名前で通常参
     照される値です。例えば、オブジェクト 'o' が属性 'a' を持っていると
     き、その属性は 'o.a' で参照されます。

     オブジェクトには、 *note 識別子 (identifier) およびキーワード
     (keyword): 1df6. で定義される識別子ではない名前の属性を与えることが
     できます。たとえば *note setattr(): 20bd. を使い、オブジェクトがそ
     れを許可している場合に行えます。このような属性はドット表記式ではア
     クセスできず、代わりに *note getattr(): b9f. を使って取る必要があり
     ます。

awaitable

     (待機可能) *note await: 19e. 式で使用することが出来るオブジェクトで
     す。 *note coroutine: 45e. か、 *note __await__(): 1f28. メソッドが
     あるオブジェクトです。 PEP 492(9) を参照してください。

BDFL

     慈悲深き終身独裁者 (Benevolent Dictator For Life) の略です。Python
     の作者、Guido van Rossum(10) のことです。

binary file

     (バイナリファイル) *note bytes-like オブジェクト: cfb. の読み込みお
     よび書き込みができる *note ファイルオブジェクト: 1193. です。 バイ
     ナリファイルの例は、バイナリモード (‘'rb'’, ‘'wb'’ or ‘'rb+'’) で開
     かれたファイル、*note sys.stdin.buffer: 507.、*note
     sys.stdout.buffer: aa4.、 *note io.BytesIO: e6d. や *note
     gzip.GzipFile: 3f3.  のインスタンスです。

     *note str: 418. オブジェクトの読み書きができるファイルオブジェクト
     については、 *note text file: 1bf0. も参照してください。

borrowed reference

     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 *note strong
     reference: 316. to the object and so destroy it.

     Calling *note Py_INCREF(): 53a. on the *note borrowed reference:
     317. is recommended to convert it to a *note strong reference: 316.
     in-place, except when the object cannot be destroyed before the
     last usage of the borrowed reference.  The *note Py_NewRef(): 867.
     function can be used to create a new *note strong reference: 316.

bytes-like object

     *note バッファプロトコル (buffer Protocol): 371. をサポートしていて
     、 C 言語の意味で *note 連続した: 1016. バッファーを提供可能なオブ
     ジェクト。 *note bytes: 1a4, *note bytearray: 508, *note
     array.array: 185. や、多くの一般的な *note memoryview: 435. オブジ
     ェクトがこれに当たります。 bytes-like オブジェクトは、データ圧縮、
     バイナリファイルへの保存、ソケットを経由した送信など、バイナリデー
     タを要求するいろいろな操作に利用することができます。

     幾つかの操作ではバイナリデータを変更する必要があります。 その操作の
     ドキュメントではよく "読み書き可能な bytes-like オブジェクト" に言
     及しています。 変更可能なバッファーオブジェクトには、 *note
     bytearray: 508. と *note bytearray: 508. の *note memoryview: 435.
     などが含まれます。 また、他の幾つかの操作では不変なオブジェクト内の
     バイナリデータ ("読み出し専用の bytes-like オブジェクト") を必要し
     ます。それには *note bytes: 1a4. と *note bytes: 1a4. の *note
     memoryview: 435. オブジェクトが含まれます。

bytecode

     (バイトコード) Python のソースコードは、 Python プログラムの
     CPython インタプリタの内部表現であるバイトコードへとコンパイルされ
     ます。 バイトコードは ‘.pyc’ ファイルにキャッシュされ、同じファイル
     が二度目に実行されるときはより高速になります (ソースコードからバイ
     トコードへの再度のコンパイルは回避されます)。 この "中間言語
     (intermediate language)" は、各々のバイトコードに対応する機械語を実
     行する *note 仮想マシン: 33a7. で動作するといえます。 重要な注意と
     して、バイトコードは異なる Python 仮想マシン間で動作することや、
     Python リリース間で安定であることは期待されていません。

     バイトコードの命令一覧は *note dis モジュール: 57c. にあります。

callable

     A callable is an object that can be called, possibly with a set of
     arguments (see *note argument: 415.), with the following syntax:

          callable(argument1, argument2, argumentN)

     A *note function: 1fb4, and by extension a *note method: 4fb6, is a
     callable.  An instance of a class that implements the *note
     __call__(): 523. method is also a callable.

callback

     (コールバック) 将来のある時点で実行されるために引数として渡される関
     数

クラス

     (クラス) ユーザー定義オブジェクトを作成するためのテンプレートです。
     クラス定義は普通、そのクラスのインスタンス上の操作をするメソッドの
     定義を含みます。

class variable

     (クラス変数) クラス上に定義され、クラスレベルで (つまり、クラスのイ
     ンスタンス上ではなしに) 変更されることを目的としている変数です。

closure variable

     A *note free variable: 1f3a. referenced from a *note nested scope:
     1e9e. that is defined in an outer scope rather than being resolved
     at runtime from the globals or builtin namespaces.  May be
     explicitly defined with the *note nonlocal: 1279. keyword to allow
     write access, or implicitly defined if the variable is only being
     read.

     For example, in the ‘inner’ function in the following code, both
     ‘x’ and ‘print’ are *note free variables: 1f3a, but only ‘x’ is a
     'closure variable':

          def outer():
              x = 0
              def inner():
                  nonlocal x
                  x += 1
                  print(x)
              return inner

     Due to the *note codeobject.co_freevars: 1e5a. attribute (which,
     despite its name, only includes the names of closure variables
     rather than listing all referenced free variables), the more
     general *note free variable: 1f3a. term is sometimes used even when
     the intended meaning is to refer specifically to closure variables.

complex number

     (複素数) よく知られている実数系を拡張したもので、すべての数は実部と
     虚部の和として表されます。虚数は虚数単位 (‘-1’ の平方根) に実数を掛
     けたもので、一般に数学では ‘i’ と書かれ、工学では ‘j’ と書かれます
     。Python は複素数に組み込みで対応し、後者の表記を取っています。虚部
     は末尾に ‘j’ をつけて書きます。例えば ‘3+1j’ です。 *note math: 81.
     モジュールの複素数版を利用するには、 *note cmath: 11. を使います。
     複素数の使用はかなり高度な数学の機能です。必要性を感じなければ、ほ
     ぼ間違いなく無視してしまってよいでしょう。

context

     This term has different meanings depending on where and how it is
     used.  Some common meanings:

        * The temporary state or environment established by a *note
          context manager: 59e. via a *note with: 59c. statement.

        * The collection of key­value bindings associated with a
          particular *note contextvars.Context: 150d. object and
          accessed via *note ContextVar: 30fe. objects.  Also see *note
          context variable: 4fba.

        * A *note contextvars.Context: 150d. object.  Also see *note
          current context: 1516.

コンテキスト管理プロトコル

     The *note __enter__(): 592. and *note __exit__(): 12ce. methods
     called by the *note with: 59c. statement.  See PEP 343(11).

context manager

     An object which implements the *note context management protocol:
     1517. and controls the environment seen in a *note with: 59c.
     statement.  See PEP 343(12).

context variable

     A variable whose value depends on which context is the *note
     current context: 1516.  Values are accessed via *note
     contextvars.ContextVar: 30fe. objects.  Context variables are
     primarily used to isolate state between concurrent asynchronous
     tasks.

contiguous

     (隣接、連続) バッファが厳密に 'C-連続' または 'Fortran 連続' である
     場合に、そのバッファは連続しているとみなせます。 ゼロ次元バッファは
     C 連続であり Fortran 連続です。 一次元の配列では、その要素は必ずメ
     モリ上で隣接するように配置され、添字がゼロから始まり増えていく順序
     で並びます。 多次元の C-連続な配列では、メモリアドレス順に要素を巡
     る際には最後の添え字が最初に変わるのに対し、 Fortran 連続な配列では
     最初の添え字が最初に動きます。

コルーチン

     (コルーチン) コルーチンはサブルーチンのより一般的な形式です。 サブ
     ルーチンには決められた地点から入り、別の決められた地点から出ます。
     コルーチンには多くの様々な地点から入る、出る、再開することができま
     す。 コルーチンは *note async def: 59b. 文で実装できます。 PEP
     492(13) を参照してください。

coroutine function

     (コルーチン関数) *note coroutine: 45e. オブジェクトを返す関数です。
     コルーチン関数は *note async def: 59b. 文で実装され、*note await:
     19e.、*note async for: a79.、 および *note async with: 59f. キーワ
     ードを持つことが出来ます。 これらは PEP 492(14) で導入されました。

CPython

     python.org(15) で配布されている、Python プログラミング言語の標準的
     な実装です。"CPython" という単語は、この実装を Jython や IronPython
     といった他の実装と区別する必要が有る場合に利用されます。

current context

     The *note context: 1515. (*note contextvars.Context: 150d. object)
     that is currently used by *note ContextVar: 30fe. objects to access
     (get or set) the values of *note context variables: 4fba.  Each
     thread has its own current context.  Frameworks for executing
     asynchronous tasks (see *note asyncio: 8.) associate each task with
     a context which becomes the current context whenever the task
     starts or resumes execution.

decorator

     (デコレータ) 別の関数を返す関数で、通常、 ‘@wrapper’ 構文で関数変換
     として適用されます。デコレータの一般的な利用例は、 *note
     classmethod(): 14c. と *note staticmethod(): 3ef. です。

     デコレータの文法はシンタックスシュガーです。次の2つの関数定義は意味
     的に同じものです:

          def f(arg):
              ...
          f = staticmethod(f)

          @staticmethod
          def f(arg):
              ...

     同じ概念がクラスにも存在しますが、あまり使われません。デコレータに
     ついて詳しくは、 *note 関数定義: 1ba0. および *note クラス定義:
     12a5. のドキュメントを参照してください。

descriptor

     Any object which defines the methods *note __get__(): 1490, *note
     __set__(): 1eca, or *note __delete__(): 156c.  When a class
     attribute is a descriptor, its special binding behavior is
     triggered upon attribute lookup.  Normally, using 'a.b' to get, set
     or delete an attribute looks up the object named 'b' in the class
     dictionary for 'a', but if 'b' is a descriptor, the respective
     descriptor method gets called.  Understanding descriptors is a key
     to a deep understanding of Python because they are the basis for
     many features including functions, methods, properties, class
     methods, static methods, and reference to super classes.

     デスクリプタのメソッドに関しての詳細は、 *note デスクリプタ
     (descriptor) の実装: c1d. や *note Descriptor How To Guide: 1495. を
     参照してください。

dictionary

     An associative array, where arbitrary keys are mapped to values.
     The keys can be any object with *note __hash__(): ac9. and *note
     __eq__(): ac8. methods.  Called a hash in Perl.

dictionary comprehension

     (辞書内包表記) iterable 内の全てあるいは一部の要素を処理して、その
     結果からなる辞書を返すコンパクトな書き方です。 ‘results = {n: n **
     2 for n in range(10)}’ とすると、キー ‘n’ を値 ‘n ** 2’ に対応付け
     る辞書を生成します。 *note リスト、集合、辞書の表示: 59a. を参照し
     てください。

dictionary view

     (辞書ビュー) *note dict.keys(): 798.、*note dict.values(): 799.、
     *note dict.items(): 79a. が返すオブジェクトです。 辞書の項目の動的
     なビューを提供します。 すなわち、辞書が変更されるとビューはそれを反
     映します。 辞書ビューを強制的に完全なリストにするには
     ‘list(dictview)’ を使用してください。 *note 辞書ビューオブジェクト:
     21a1. を参照してください。

docstring

     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 the compiler and put into the *note __doc__: 8f6.
     attribute of the enclosing class, function or module.  Since it is
     available via introspection, it is the canonical place for
     documentation of the object.

duck-typing

     あるオブジェクトが正しいインターフェースを持っているかを決定するの
     にオブジェクトの型を見ないプログラミングスタイルです。代わりに、単
     純にオブジェクトのメソッドや属性が呼ばれたり使われたりします。（「
     アヒルのように見えて、アヒルのように鳴けば、それはアヒルである。」
     ）インターフェースを型より重視することで、上手くデザインされたコー
     ドは、ポリモーフィックな代替を許して柔軟性を向上させます。ダックタ
     イピングは *note type(): d16. や *note isinstance(): 40e. による判
     定を避けます。 (ただし、ダックタイピングを *note 抽象基底クラス:
     1186. で補完することもできます。) その代わり、典型的に *note
     hasattr(): 49e. 判定や *note EAFP: 2ad9. プログラミングを利用します
     。

EAFP

     「認可をとるより許しを請う方が容易 (easier to ask for forgiveness
     than permission、マーフィーの法則)」の略です。この Python で広く使
     われているコーディングスタイルでは、通常は有効なキーや属性が存在す
     るものと仮定し、その仮定が誤っていた場合に例外を捕捉します。この簡
     潔で手早く書けるコーディングスタイルには、 *note try: 6b4. 文および
     *note except: 170. 文がたくさんあるのが特徴です。このテクニックは、
     C のような言語でよく使われている *note LBYL: 4fbc. スタイルと対照的
     なものです。

expression

     (式) 何かの値と評価される、一まとまりの構文 (a piece of syntax) で
     す。言い換えると、式とはリテラル、名前、属性アクセス、演算子や関数
     呼び出しなど、値を返す式の要素の積み重ねです。他の多くの言語と違い
     、Python では言語の全ての構成要素が式というわけではありません。
     *note while: 1b6e. のように、式としては使えない *note 文: 26d2. も
     あります。代入も式ではなく文です。

extension module

     (拡張モジュール) C や C++ で書かれたモジュールで、Python の C API を
     利用して Python コアやユーザーコードとやりとりします。

f-string

     ‘'f'’ や ‘'F'’ が先頭に付いた文字列リテラルは "f-string" と呼ばれ、
     これは *note フォーマット済み文字列リテラル: 977. の短縮形の名称で
     す。 PEP 498(16) も参照してください。

file object

     An object exposing a file-oriented API (with methods such as
     ‘read()’ or ‘write()’) to an underlying resource.  Depending on the
     way it was created, a file object can mediate access to a real
     on-disk file or to another type of storage or communication device
     (for example standard input/output, in-memory buffers, sockets,
     pipes, etc.).  File objects are also called 'file-like objects' or
     'streams'.

     ファイルオブジェクトには実際には 3 種類あります: 生の *note
     バイナリーファイル: 1bf1.、バッファされた *note バイナリーファイル:
     1bf1.、そして *note テキストファイル: 1bf0. です。インターフェイス
     は *note io: 73. モジュールで定義されています。ファイルオブジェクト
     を作る標準的な方法は *note open(): 4e5. 関数を使うことです。

file-like object

     *note file object: 1193. と同義です。

filesystem encoding and error handler

     Encoding and error handler used by Python to decode bytes from the
     operating system and encode Unicode to the operating system.

     ファイルシステムのエンコーディングでは、すべてが 128 バイト以下に正
     常にデコードされることが保証されなくてはなりません。ファイルシステ
     ムのエンコーディングでこれが保証されなかった場合は、API 関数が
     *note UnicodeError: 1275. を送出することがあります。

     The *note sys.getfilesystemencoding(): c27. and *note
     sys.getfilesystemencodeerrors(): cb4. functions can be used to get
     the filesystem encoding and error handler.

     The *note filesystem encoding and error handler: 505. are
     configured at Python startup by the *note PyConfig_Read(): 75b.
     function: see *note filesystem_encoding: 3c2. and *note
     filesystem_errors: 3c3. members of *note PyConfig: 380.

     See also the *note locale encoding: 223.

finder

     (ファインダ) インポートされているモジュールの *note loader: 1614. の
     発見を試行するオブジェクトです。

     There are two types of finder: *note meta path finders: 1045. for
     use with *note sys.meta_path: cf9, and *note path entry finders:
     1046. for use with *note sys.path_hooks: fee.

     See *note ファインダーとローダー: 1f52. and *note importlib: 6b.
     for much more detail.

floor division

     (切り捨て除算) 一番近い整数に切り捨てる数学的除算。 切り捨て除算演
     算子は ‘//’ です。 例えば、 ‘11 // 4’ は ‘2’ になり、それとは対称に
     浮動小数点数の真の除算では ‘2.75’ が 返ってきます。 ‘(-11) // 4’ は
     ‘-2.75’ を '小さい方に' 丸める (訳注: 負の無限大への丸めを行う) の
     で ‘-3’ になることに注意してください。 PEP 238(17) を参照してくださ
     い。

free threading

     A threading model where multiple threads can run Python bytecode
     simultaneously within the same interpreter.  This is in contrast to
     the *note global interpreter lock: 12e. which allows only one
     thread to execute Python bytecode at a time.  See PEP 703(18).

free variable

     Formally, as defined in the *note language execution model: 1f37, a
     free variable is any variable used in a namespace which is not a
     local variable in that namespace.  See *note closure variable:
     1e9f. for an example.  Pragmatically, due to the name of the *note
     codeobject.co_freevars: 1e5a. attribute, the term is also sometimes
     used as a synonym for *note closure variable: 1e9f.

関数

     (関数) 呼び出し側に値を返す一連の文のことです。関数には0以上の
     *note 実引数: 415. を渡すことが出来ます。実体の実行時に引数を使用す
     ることが出来ます。 *note 仮引数: 1e5e.、*note メソッド: 4fb6.、
     *note 関数定義: 1ba0. を参照してください。

function annotation

     (関数アノテーション) 関数のパラメータや返り値の *note annotation:
     424. です。

     関数アノテーションは、通常は *note 型ヒント: 1ee2. のために使われま
     す: 例えば、この関数は 2 つの *note int: 238. 型の引数を取ると期待
     され、また *note int: 238. 型の返り値を持つと期待されています。

          def sum_two_numbers(a: int, b: int) -> int:
             return a + b

     関数アノテーションの文法は *note 関数定義: 1ba0. の節で解説されてい
     ます。

     機能の説明がある *note variable annotation: d23, PEP 484(19),を参照
     してください。また、アノテーションを利用するベストプラクティスとし
     て *note Annotations Best Practices: 7a4. も参照してください。

__future__

     ‘from __future__ import <feature>’ という *note future 文: 16e. は
     、コンパイラーに将来の Python リリースで標準となる構文や意味を使用
     して現在のモジュールをコンパイルするよう指示します。 *note
     __future__: 0. モジュールでは、 'feature' のとりうる値をドキュメン
     ト化しています。このモジュールをインポートし、その変数を評価するこ
     とで、新機能が最初に言語に追加されたのはいつかや、いつデフォルトに
     なるか (またはなったか) を見ることができます:

          >>> import __future__
          >>> __future__.division
          _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)

garbage collection

     (ガベージコレクション) これ以降使われることのないメモリを解放する処
     理です。 Pythonは、参照カウントと、循環参照を検出し破壊する循環ガベ
     ージコレクタを使ってガベージコレクションを行います。 ガベージコレク
     タは *note gc: 56. モジュールを使って操作できます。

ジェネレータ

     (ジェネレータ) *note generator iterator: bac. を返す関数です。 通常
     の関数に似ていますが、 *note yield: 99b. 式を持つ点で異なります。
     *note yield: 99b. 式は、 for ループで使用できたり、*note next():
     7a3. 関数で値を 1 つずつ取り出したりできる、値の並びを生成するのに
     使用されます。

     通常はジェネレータ関数を指しますが、文脈によっては 'ジェネレータイ
     テレータ' を指す場合があります。 意図された意味が明らかでない場合、
     明瞭化のために完全な単語を使用します。

generator iterator

     (ジェネレータイテレータ) *note generator: 1035. 関数で生成されるオ
     ブジェクトです。

     *note yield: 99b. のたびに局所実行状態 (局所変数や未処理の try 文な
     どを含む) を記憶して、処理は一時的に中断されます。 'ジェネレータイ
     テレータ' が再開されると、中断した位置を取得します (通常の関数が実
     行のたびに新しい状態から開始するのと対照的です)。

generator expression

     An *note expression: 1ee6. that returns an *note iterator: 191.  It
     looks like a normal expression followed by a ‘for’ clause defining
     a loop variable, range, and an optional ‘if’ clause.  The combined
     expression generates values for an enclosing function:

          >>> sum(i*i for i in range(10))         # sum of squares 0, 1, 4, ... 81
          285

generic function

     (ジェネリック関数) 異なる型に対し同じ操作をする関数群から構成される
     関数です。呼び出し時にどの実装を用いるかはディスパッチアルゴリズム
     により決定されます。

     *note single dispatch: 9be.、*note functools.singledispatch(): 605.
     デコレータ、 PEP 443(20) を参照してください。

generic type

     A *note type: 189d. that can be parameterized; typically a *note
     container class: 1eeb. such as *note list: 5dc. or *note dict: 237.
     Used for *note type hints: 1ee2. and *note annotations: 424.

     For more details, see *note generic alias types: 67e, PEP 483(21),
     PEP 484(22), PEP 585(23), and the *note typing: ed. module.

GIL

     *note global interpreter lock: 12e. を参照してください。

global interpreter lock

     (グローバルインタプリタロック) *note CPython: 6c1. インタプリタが利
     用している、一度に Python の *note バイトコード: 16c. を実行するス
     レッドは一つだけであることを保証する仕組みです。これにより (*note
     dict: 237. などの重要な組み込み型を含む) オブジェクトモデルが同時ア
     クセスに対して暗黙的に安全になるので、 CPython の実装がシンプルにな
     ります。インタプリタ全体をロックすることで、マルチプロセッサマシン
     が生じる並列化のコストと引き換えに、インタプリタを簡単にマルチスレ
     ッド化できるようになります。

     ただし、標準あるいは外部のいくつかの拡張モジュールは、圧縮やハッシ
     ュ計算などの計算の重い処理をするときに GIL を解除するように設計され
     ています。また、I/O 処理をする場合 GIL は常に解除されます。

     As of Python 3.13, the GIL can be disabled using the *note
     -disable-gil: 15a. build configuration.  After building Python with
     this option, code must be run with *note -X gil=0: 15c. or after
     setting the *note PYTHON_GIL=0: 15b. environment variable.  This
     feature enables improved performance for multi-threaded
     applications and makes it easier to use multi-core CPUs
     efficiently.  For more details, see PEP 703(24).

hash-based pyc

     (ハッシュベース pyc ファイル) 正当性を判別するために、対応するソー
     スファイルの最終更新時刻ではなくハッシュ値を使用するバイトコードの
     キャッシュファイルです。*note キャッシュされたバイトコードの無効化:
     5b6. を参照してください。

hashable

     An object is 'hashable' if it has a hash value which never changes
     during its lifetime (it needs a *note __hash__(): ac9. method), and
     can be compared to other objects (it needs an *note __eq__(): ac8.
     method).  Hashable objects which compare equal must have the same
     hash value.

     ハッシュ可能なオブジェクトは辞書のキーや集合のメンバーとして使えま
     す。辞書や集合のデータ構造は内部でハッシュ値を使っているからです。

     Python のイミュータブルな組み込みオブジェクトは、ほとんどがハッシュ
     可能です。(リストや辞書のような) ミュータブルなコンテナはハッシュ不
     可能です。(タプルや frozenset のような) イミュータブルなコンテナは
     、要素がハッシュ可能であるときのみハッシュ可能です。 ユーザー定義の
     クラスのインスタンスであるようなオブジェクトはデフォルトでハッシュ
     可能です。 それらは全て (自身を除いて) 比較結果は非等価であり、ハッ
     シュ値は *note id(): 13ca. より得られます。

IDLE

     Python の統合開発環境 (Integrated DeveLopment Environment)及び学習
     環境 (Learning Environment) です。*note IDLE: fe0. は Python の標準
     的な配布に同梱されている基本的な機能のエディタとインタプリタ環境で
     す。

永続オブジェクト (immortal)

     'Immortal objects' are a CPython implementation detail introduced
     in PEP 683(25).

     If an object is immortal, its *note reference count: 4774. is never
     modified, and therefore it is never deallocated while the
     interpreter is running.  For example, *note True: bdb. and *note
     None: 641. are immortal in CPython.

immutable

     (イミュータブル) 固定の値を持ったオブジェクトです。イミュータブルな
     オブジェクトには、数値、文字列、およびタプルなどがあります。これら
     のオブジェクトは値を変えられません。別の値を記憶させる際には、新た
     なオブジェクトを作成しなければなりません。イミュータブルなオブジェ
     クトは、固定のハッシュ値が必要となる状況で重要な役割を果たします。
     辞書のキーがその例です。

import path

     *note path based finder: 1f59. が import するモジュールを検索する場
     所 (または *note path entry: 1f64.) のリスト。 import 中、このリス
     トは通常 *note sys.path: 38e. から来ますが、サブパッケージの場合は
     親パッケージの ‘__path__’ 属性からも来ます。

importing

     あるモジュールの Python コードが別のモジュールの Python コードで使
     えるようにする処理です。

importer

     モジュールを探してロードするオブジェクト。 *note finder: 1e7e. と
     *note loader: 1614. のどちらでもあるオブジェクト。

interactive

     Python has an interactive interpreter which means you can enter
     statements and expressions at the interpreter prompt, immediately
     execute them and see their results.  Just launch ‘python’ with no
     arguments (possibly by selecting it from your computer's main
     menu).  It is a very powerful way to test out new ideas or inspect
     modules and packages (remember ‘help(x)’).  For more on interactive
     mode, see *note 対話モード: 155.

interpreted

     Python はインタプリタ形式の言語であり、コンパイラ言語の対極に位置し
     ます。 (バイトコードコンパイラがあるために、この区別は曖昧ですが。)
     ここでのインタプリタ言語とは、ソースコードのファイルを、まず実行可
     能形式にしてから実行させるといった操作なしに、直接実行できることを
     意味します。インタプリタ形式の言語は通常、コンパイラ形式の言語より
     も開発／デバッグのサイクルは短いものの、プログラムの実行は一般に遅
     いです。 *note 対話的: 14f. も参照してください。

interpreter shutdown

     Python インタープリターはシャットダウンを要請された時に、モジュール
     やすべてのクリティカルな内部構造をなどの、すべての確保したリソース
     を段階的に開放する、特別なフェーズに入ります。 このフェーズは *note
     ガベージコレクタ: 1884. を複数回呼び出します。 これによりユーザー定
     義のデストラクターや weakref コールバックが呼び出されることがありま
     す。 シャットダウンフェーズ中に実行されるコードは、それが依存するリ
     ソースがすでに機能しない(よくある例はライブラリーモジュールや
     warning 機構です) ために様々な例外に直面します。

     インタープリタがシャットダウンする主な理由は ‘__main__’ モジュール
     や実行されていたスクリプトの実行が終了したことです。

iterable

     An object capable of returning its members one at a time.  Examples
     of iterables include all sequence types (such as *note list: 5dc,
     *note str: 418, and *note tuple: 349.) and some non-sequence types
     like *note dict: 237, *note file objects: 1193, and objects of any
     classes you define with an *note __iter__(): 1c2e. method or with a
     *note __getitem__(): 264. method that implements *note sequence:
     4be. semantics.

     Iterables can be used in a *note for: 2c9. loop and in many other
     places where a sequence is needed (*note zip(): 79b, *note map():
     82f, ...).  When an iterable object is passed as an argument to the
     built-in function *note iter(): 7a2, it returns an iterator for the
     object.  This iterator is good for one pass over the set of values.
     When using iterables, it is usually not necessary to call *note
     iter(): 7a2. or deal with iterator objects yourself.  The *note
     for: 2c9. statement does that automatically for you, creating a
     temporary unnamed variable to hold the iterator for the duration of
     the loop.  See also *note iterator: 191, *note sequence: 4be, and
     *note generator: 1035.

iterator

     データの流れを表現するオブジェクトです。イテレータの *note
     __next__(): 129b. メソッドを繰り返し呼び出す (または組み込み関数
     *note next(): 7a3. に渡す) と、流れの中の要素を一つずつ返します。デ
     ータがなくなると、代わりに *note StopIteration: bc8. 例外を送出しま
     す。その時点で、イテレータオブジェクトは尽きており、それ以降は
     ‘__next__()’ を何度呼んでも *note StopIteration: bc8. を送出します
     。イテレータは、そのイテレータオブジェクト自体を返す *note
     __iter__(): 1c2e. メソッドを実装しなければならないので、イテレータ
     は他の iterable を受理するほとんどの場所で利用できます。はっきりと
     した例外は複数の反復を行うようなコードです。 (*note list: 5dc. のよ
     うな) コンテナオブジェクトは、自身を *note iter(): 7a2. 関数にオブ
     ジェクトに渡したり *note for: 2c9. ループ内で使うたびに、新たな未使
     用のイテレータを生成します。これをイテレータで行おうとすると、前回
     のイテレーションで使用済みの同じイテレータオブジェクトを単純に返す
     ため、空のコンテナのようになってしまします。

     詳細な情報は *note イテレータ型: 20d9. にあります。

     'CPython 実装の詳細:' CPython does not consistently apply the
     requirement that an iterator define *note __iter__(): 1c2e.  And
     also please note that the free-threading CPython does not guarantee
     the thread-safety of iterator operations.

key function

     (キー関数) キー関数、あるいは照合関数とは、ソートや順序比較のための
     値を返す呼び出し可能オブジェクト(callable)です。例えば、 *note
     locale.strxfrm(): 3bcf. をキー関数に使えば、ロケール依存のソートの
     慣習にのっとったソートキーを返します。

     Python の多くのツールはキー関数を受け取り要素の並び順やグループ化を
     管理します。 *note min(): ed3, *note max(): ed4, *note sorted():
     b9c, *note list.sort(): b9d, *note heapq.merge(): dd1, *note
     heapq.nsmallest(): 2489, *note heapq.nlargest(): 2488, *note
     itertools.groupby(): 267f. 等があります。

     キー関数を作る方法はいくつかあります。 例えば *note str.lower():
     1758. メソッドを大文字小文字を区別しないソートを行うキー関数として
     使うことが出来ます。 あるいは、‘lambda r: (r[0], r[2])’ のような
     *note lambda: 126d. 式からキー関数を作ることができます。 また、
     *note operator.attrgetter(): e00, *note operator.itemgetter(): a30,
     *note operator.methodcaller(): e01. の 3 つのキー関数コンストラクタ
     があります。 キー関数の作り方と使い方の例は *note Sorting HOW TO:
     11ab. を参照してください。

keyword argument

     *note 実引数: 415. を参照してください。

lambda

     (ラムダ) 無名のインライン関数で、関数が呼び出されたときに評価される
     1 つの *note 式: 1ee6. を含みます。ラムダ関数を作る構文は ‘lambda
     [parameters]: expression’ です。

LBYL

     「ころばぬ先の杖 (look before you leap)」 の略です。このコーディン
     グスタイルでは、呼び出しや検索を行う前に、明示的に前提条件
     (pre-condition) 判定を行います。 *note EAFP: 2ad9. アプローチと対照
     的で、 *note if: 2ca. 文がたくさん使われるのが特徴的です。

     マルチスレッド化された環境では、LBYL アプローチは "見る" 過程と "飛
     ぶ" 過程の競合状態を引き起こすリスクがあります。例えば、‘if key in
     mapping: return mapping[key]’ というコードは、判定の後、別のスレッ
     ドが探索の前に 'mapping' から 'key' を取り除くと失敗します。この問
     題は、ロックするか EAFP アプローチを使うことで解決できます。

list

     A built-in Python *note sequence: 4be.  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).

list comprehension

     (リスト内包表記) シーケンス中の全てあるいは一部の要素を処理して、そ
     の結果からなるリストを返す、コンパクトな方法です。 ‘result =
     ['{:#04x}'.format(x) for x in range(256) if x % 2 == 0]’ とすると、
     0 から 255 までの偶数を 16進数表記 (0x..)  した文字列からなるリスト
     を生成します。 *note if: 2ca. 節はオプションです。 *note if: 2ca. 節
     がない場合、 ‘range(256)’ の全ての要素が処理されます。

loader

     An object that loads a module.  It must define a method named
     ‘load_module()’.  A loader is typically returned by a *note finder:
     1e7e.  See also:

        * *note ファインダーとローダー: 1f52.

        * *note importlib.abc.Loader: e90.

        * PEP 302(26)

ロケールエンコーディング

     On Unix, it is the encoding of the LC_CTYPE locale.  It can be set
     with *note locale.setlocale(locale.LC_CTYPE, new_locale): 2bd.

     On Windows, it is the ANSI code page (ex: ‘"cp1252"’).

     On Android and VxWorks, Python uses ‘"utf-8"’ as the locale
     encoding.

     *note locale.getencoding(): 2be. can be used to get the locale
     encoding.

     See also the *note filesystem encoding and error handler: 505.

magic method

     *note special method: 1816. のくだけた同義語です。

mapping

     (マッピング) 任意のキー探索をサポートしていて、 *note
     collections.abc.Mapping: 898. か *note
     collections.abc.MutableMapping: 107e. の *note 抽象基底クラス: 844.
     で指定されたメソッドを実装しているコンテナオブジェクトです。例えば
     、 *note dict: 237, *note collections.defaultdict: 118d, *note
     collections.OrderedDict: 5a5, *note collections.Counter: 1067. など
     です。

meta path finder

     *note sys.meta_path: cf9. を検索して得られた *note finder: 1e7e.
     meta path finder は *note path entry finder: 1046. と関係はあります
     が、別物です。

     meta path finder が実装するメソッドについては *note
     importlib.abc.MetaPathFinder: 83a. を参照してください。

metaclass

     (メタクラス) クラスのクラスです。クラス定義は、クラス名、クラスの辞
     書と、基底クラスのリストを作ります。メタクラスは、それら 3 つを引数
     として受け取り、クラスを作る責任を負います。ほとんどのオブジェクト
     指向言語は(訳注:メタクラスの)デフォルトの実装を提供しています。
     Python が特別なのはカスタムのメタクラスを作成できる点です。ほとんど
     のユーザーに取って、メタクラスは全く必要のないものです。しかし、一
     部の場面では、メタクラスは強力でエレガントな方法を提供します。たと
     えば属性アクセスのログを取ったり、スレッドセーフ性を追加したり、オ
     ブジェクトの生成を追跡したり、シングルトンを実装するなど、多くの場
     面で利用されます。

     詳細は *note メタクラス: 1ed4. を参照してください。

メソッド

     (メソッド) クラス本体の中で定義された関数。そのクラスのインスタンス
     の属性として呼び出された場合、メソッドはインスタンスオブジェクトを
     第一 *note 引数: 415. として受け取ります (この第一引数は通常 ‘self’
     と呼ばれます)。 *note 関数: 1fb4. と *note ネストされたスコープ:
     1e9e. も参照してください。

method resolution order

     Method Resolution Order is the order in which base classes are
     searched for a member during lookup.  See *note The Python 2.3
     Method Resolution Order: 144f. for details of the algorithm used by
     the Python interpreter since the 2.3 release.

module

     (モジュール) Python コードの組織単位としてはたらくオブジェクトです
     。モジュールは任意の Python オブジェクトを含む名前空間を持ちます。
     モジュールは *note importing: 1f49. の処理によって Python に読み込
     まれます。

     *note パッケージ: 1e7a. を参照してください。

module spec

     モジュールをロードするのに使われるインポート関連の情報を含む名前空
     間です。 *note importlib.machinery.ModuleSpec: 1dcb. のインスタンス
     です。

     See also *note Module specs: 1e79.

MRO

     *note method resolution order: 20e5. を参照してください。

mutable

     (ミュータブル) ミュータブルなオブジェクトは、 *note id(): 13ca. を
     変えることなく値を変更できます。 *note イミュータブル: 1272.) も参
     照してください。

named tuple

     "名前付きタプル" という用語は、タプルを継承していて、インデックスが
     付く要素に対し属性を使ってのアクセスもできる任意の型やクラスに応用
     されています。 その型やクラスは他の機能も持っていることもあります。

     *note time.localtime(): 14a2. や *note os.stat(): 46d. の返り値を含
     むいくつかの組み込み型は名前付きタプルです。 他の例は *note
     sys.float_info: 1956. です:

          >>> sys.float_info[1]                   # indexed access
          1024
          >>> sys.float_info.max_exp              # named field access
          1024
          >>> isinstance(sys.float_info, tuple)   # kind of tuple
          True

     Some named tuples are built-in types (such as the above examples).
     Alternatively, a named tuple can be created from a regular class
     definition that inherits from *note tuple: 349. and that defines
     named fields.  Such a class can be written by hand, or it can be
     created by inheriting *note typing.NamedTuple: 290, or with the
     factory function *note collections.namedtuple(): 1ac.  The latter
     techniques also add some extra methods that may not be found in
     hand-written or built-in named tuples.

namespace

     (名前空間) 変数が格納される場所です。名前空間は辞書として実装されま
     す。名前空間にはオブジェクトの (メソッドの) 入れ子になったものだけ
     でなく、局所的なもの、大域的なもの、そして組み込みのものがあります
     。名前空間は名前の衝突を防ぐことによってモジュール性をサポートする
     。例えば関数 *note builtins.open: 4e5. と *note os.open(): d5f. は
     名前空間で区別されています。また、どのモジュールが関数を実装してい
     るか明示することによって名前空間は可読性と保守性を支援します。例え
     ば、*note random.seed(): 1245. や *note itertools.islice(): b1a. と
     書くと、それぞれモジュール *note random: a6. や *note itertools:
     75. で実装されていることが明らかです。

namespace package

     (名前空間パッケージ) サブパッケージのコンテナとしてのみ提供される
     PEP 420(27) で定義された *note package: 1e7a. です。名前空間パッケ
     ージは物理的な表現を持たないことができ、 ‘__init__.py’ ファイルを持
     たないため、 *note regular package: 1f4d. とは異なります。

     *note module: 15c3. を参照してください。

nested scope

     (ネストされたスコープ) 外側で定義されている変数を参照する機能です。
     例えば、ある関数が別の関数の中で定義されている場合、内側の関数は外
     側の関数中の変数を参照できます。ネストされたスコープはデフォルトで
     は変数の参照だけができ、変数の代入はできないので注意してください。
     ローカル変数は、最も内側のスコープで変数を読み書きします。同様に、
     グローバル変数を使うとグローバル名前空間の値を読み書きします。
     *note nonlocal: 1279. で外側の変数に書き込めます。

new-style class

     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 *note __slots__: 1493,
     descriptors, properties, *note __getattribute__(): ba0, class
     methods, and static methods.

object

     (オブジェクト) 状態 (属性や値) と定義された振る舞い (メソッド) をも
     つ全てのデータ。もしくは、全ての *note 新スタイルクラス: 27e0. の究
     極の基底クラスのこと。

optimized scope

     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 these names.  The local namespaces for
     functions, generators, coroutines, comprehensions, and generator
     expressions are optimized in this fashion.  Note: most interpreter
     optimizations are applied to all scopes, only those relying on a
     known set of local and nonlocal variable names are restricted to
     optimized scopes.

package

     (パッケージ) サブモジュールや再帰的にサブパッケージを含むことの出来
     る *note module: 15c3. のことです。専門的には、パッケージは
     ‘__path__’ 属性を持つ Python オブジェクトです。

     *note regular package: 1f4d. と *note namespace package: 1bd2. を参
     照してください。

parameter

     (仮引数) 名前付の実体で *note 関数: 1fb4. (や *note メソッド: 4fb6.
     ) の定義において関数が受ける *note 実引数: 415. を指定します。仮引
     数には5種類あります:

        * '位置またはキーワード': *note 位置: 415. であるいは *note
          キーワード引数: 415. として渡すことができる引数を指定します。
          これはたとえば以下の 'foo' や 'bar' のように、デフォルトの仮引
          数の種類です:

               def func(foo, bar=None): ...

        * 位置専用: 位置によってのみ与えられる引数を指定します。位置専用
          の引数は 関数定義の引数のリストの中でそれらの後ろに ‘/’ を含め
          ることで定義できます。例えば下記の 'posonly1' と 'posonly2' は
          位置専用引数になります:

               def func(posonly1, posonly2, /, positional_or_keyword): ...

        * 'キーワード専用': キーワードによってのみ与えられる引数を指定し
          ます。キーワード専用の引数を定義できる場所は、例えば以下の
          'kw_only1' や 'kw_only2' のように、関数定義の仮引数リストに含
          めた可変長位置引数または裸の ‘*’ の後です:

               def func(arg, *, kw_only1, kw_only2): ...

        * '可変長位置': (他の仮引数で既に受けられた任意の位置引数に加え
          て) 任意の個数の位置引数が与えられることを指定します。このよう
          な仮引数は、以下の 'args' のように仮引数名の前に ‘*’ をつける
          ことで定義できます:

               def func(*args, **kwargs): ...

        * '可変長キーワード': (他の仮引数で既に受けられた任意のキーワー
          ド引数に加えて) 任意の個数のキーワード引数が与えられることを指
          定します。このような仮引数は、上の例の 'kwargs' のように仮引数
          名の前に ‘**’ をつけることで定義できます。

     仮引数はオプションと必須の引数のどちらも指定でき、オプションの引数
     にはデフォルト値も指定できます。

     *note 仮引数: 1e5e. 、FAQ の *note 実引数と仮引数の違いは何ですか?:
     4ef9. 、*note inspect.Parameter: 1b2. クラス、 *note 関数定義:
     1ba0. セクション、 PEP 362(28) を参照してください。

path entry

     *note path based finder: 1f59. が import するモジュールを探す *note
     import path: 1f56. 上の1つの場所です。

path entry finder

     *note sys.path_hooks: fee. にある callable (つまり *note path entry
     hook: 1f66.) が返した *note finder: 1e7e. です。与えられた *note
     path entry: 1f64. にあるモジュールを見つける方法を知っています。

     パスエントリーファインダが実装するメソッドについては *note
     importlib.abc.PathEntryFinder: 83b. を参照してください。

path entry hook

     A callable on the *note sys.path_hooks: fee. list which returns a
     *note path entry finder: 1046. if it knows how to find modules on a
     specific *note path entry: 1f64.

path based finder

     デフォルトの *note meta path finder: 1045. の1つは、モジュールの
     *note import path: 1f56. を検索します。

path-like object

     (path-like オブジェクト) ファイルシステムパスを表します。 path-like
     オブジェクトは、パスを表す *note str: 418. オブジェクトや *note
     bytes: 1a4. オブジェクト、または *note os.PathLike: c1f. プロトコル
     を実装したオブジェクトのどれかです。 *note os.PathLike: c1f. プロト
     コルをサポートしているオブジェクトは *note os.fspath(): c21. を呼び
     出すことで *note str: 418. または *note bytes: 1a4. のファイルシス
     テムパスに変換できます。 *note os.fsdecode(): c22. と *note
     os.fsencode(): c23. はそれぞれ *note str: 418. あるいは *note
     bytes: 1a4. になるのを保証するのに使えます。 PEP 519(29) で導入され
     ました。

PEP

     Python Enhancement Proposal。PEP は、Python コミュニティに対して情
     報を提供する、あるいは Python の新機能やその過程や環境について記述
     する設計文書です。 PEP は、機能についての簡潔な技術的仕様と提案する
     機能の論拠 (理論) を伝えるべきです。

     PEP は、新機能の提案にかかる、コミュニティによる問題提起の集積と
     Python になされる設計決断の文書化のための最上位の機構となることを意
     図しています。PEP の著者にはコミュニティ内の合意形成を行うこと、反
     対意見を文書化することの責務があります。

     PEP 1(30) を参照してください。

portion

     PEP 420(31) で定義されている、namespace package に属する、複数のフ
     ァイルが (zipファイルに格納されている場合もある) 1つのディレクトリ
     に格納されたもの。

位置引数 (positional argument)

     *note 実引数: 415. を参照してください。

provisional API

     (暫定 API) 標準ライブラリの後方互換性保証から計画的に除外されたもの
     です。そのようなインターフェースへの大きな変更は、暫定であるとされ
     ている間は期待されていませんが、コア開発者によって必要とみなされれ
     ば、後方非互換な変更 (インターフェースの削除まで含まれる) が行われ
     えます。このような変更はむやみに行われるものではありません - これは
     API を組み込む前には見落とされていた重大な欠陥が露呈したときにのみ
     行われます。

     暫定 API についても、後方互換性のない変更は「最終手段」とみなされて
     います。問題点が判明した場合でも後方互換な解決策を探すべきです。

     このプロセスにより、標準ライブラリは問題となるデザインエラーに長い
     間閉じ込められることなく、時代を超えて進化を続けられます。詳細は
     PEP 411(32) を参照してください。

provisional package

     *note provisional API: ad1. を参照してください。

Python 3000

     Python 3.x リリースラインのニックネームです。(Python 3 が遠い将来の
     話だった頃に作られた言葉です。) "Py3k" と略されることもあります。

Pythonic

     他の言語で一般的な考え方で書かれたコードではなく、Python の特に一般
     的なイディオムに従った考え方やコード片。例えば、Python の一般的なイ
     ディオムでは *note for: 2c9. 文を使ってイテラブルのすべての要素に渡
     ってループします。他の多くの言語にはこの仕組みはないので、Python に
     慣れていない人は代わりに数値のカウンターを使うかもしれません:

          for i in range(len(food)):
              print(food[i])

     これに対し、きれいな Pythonic な方法は:

          for piece in food:
              print(piece)

qualified name

     (修飾名) モジュールのグローバルスコープから、そのモジュールで定義さ
     れたクラス、関数、メソッドへの、 "パス" を表すドット名表記です。
     PEP 3155(33) で定義されています。トップレベルの関数やクラスでは、修
     飾名はオブジェクトの名前と同じです:

          >>> class C:
          ...     class D:
          ...         def meth(self):
          ...             pass
          ...
          >>> C.__qualname__
          'C'
          >>> C.D.__qualname__
          'C.D'
          >>> C.D.meth.__qualname__
          'C.D.meth'

     モジュールへの参照で使われると、'完全修飾名 (fully qualified name)'
     はすべての親パッケージを含む全体のドット名表記、例えば
     ‘email.mime.text’ を意味します:

          >>> import email.mime.text
          >>> email.mime.text.__name__
          'email.mime.text'

reference count

     (参照カウント) あるオブジェクトに対する参照の数。参照カウントが0に
     なったとき、そのオブジェクトは破棄されます。 *note 永続: 41f8. であ
     り、参照カウントが決して変更されないために割り当てが解除されないオ
     ブジェクトもあります。参照カウントは通常は Python のコード上には現
     れませんが、 *note CPython: 6c1. 実装の重要な要素です。プログラマー
     は、 任意のオブジェクトの参照カウントを知るために *note
     sys.getrefcount(): 41f7. 関数を呼び出すことが出来ます。

regular package

     伝統的な、 ‘__init__.py’ ファイルを含むディレクトリとしての *note
     package: 1e7a.。

     *note namespace package: 1bd2. を参照してください。

REPL

     "read–eval–print loop" の頭字語で、 *note 対話型: 14f. インタープリ
     ターシェルの別名。

__slots__

     クラス内での宣言で、インスタンス属性の領域をあらかじめ定義しておき
     、インスタンス辞書を排除することで、メモリを節約します。これはよく
     使われるテクニックですが、正しく扱うには少しトリッキーなので、稀な
     ケース、例えばメモリが死活問題となるアプリケーションでインスタンス
     が大量に存在する、といったときを除き、使わないのがベストです。

sequence

     An *note iterable: 10ad. which supports efficient element access
     using integer indices via the *note __getitem__(): 264. special
     method and defines a *note __len__(): 1ec3. method that returns the
     length of the sequence.  Some built-in sequence types are *note
     list: 5dc, *note str: 418, *note tuple: 349, and *note bytes: 1a4.
     Note that *note dict: 237. also supports *note __getitem__(): 264.
     and ‘__len__()’, but is considered a mapping rather than a sequence
     because the lookups use arbitrary *note hashable: 5db. keys rather
     than integers.

     The *note collections.abc.Sequence: 1194. abstract base class
     defines a much richer interface that goes beyond just *note
     __getitem__(): 264. and *note __len__(): 1ec3, adding ‘count()’,
     ‘index()’, *note __contains__(): 1ebe, and *note __reversed__():
     1ebd.  Types that implement this expanded interface can be
     registered explicitly using *note register(): 105e.  For more
     documentation on sequence methods generally, see *note Common
     Sequence Operations: 210e.

set comprehension

     (集合内包表記) iterable 内の全てあるいは一部の要素を処理して、その
     結果からなる集合を返すコンパクトな書き方です。 ‘results = {c for c
     in 'abracadabra' if c not in 'abc'}’ とすると、‘{'r', 'd'}’ という
     文字列の辞書を生成します。 *note リスト、集合、辞書の表示: 59a. を
     参照してください。

single dispatch

     *note generic function: 9bf. の一種で実装は一つの引数の型により選択
     されます。

slice

     (スライス) 一般に *note シーケンス: 4be. の一部を含むオブジェクト。
     スライスは、添字表記 ‘[]’ で与えられた複数の数の間にコロンを書くこ
     とで作られます。例えば、 ‘variable_name[1:3:5]’ です。角括弧 (添字)
     記号は *note slice: 436. オブジェクトを内部で利用しています。

soft deprecated

     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.

     Soft deprecation, unlike normal deprecation, does not plan on
     removing the API and will not emit warnings.

     See PEP 387: Soft Deprecation(34).

special method

     (特殊メソッド) ある型に特定の操作、例えば加算をするために Python か
     ら暗黙に呼び出されるメソッド。この種類のメソッドは、メソッド名の最
     初と最後にアンダースコア 2 つがついています。特殊メソッドについては
     *note 特殊メソッド名: c3c. で解説されています。

statement

     (文) 文はスイート (コードの"ブロック") に不可欠な要素です。文は
     *note 式: 1ee6. かキーワードから構成されるもののどちらかです。後者
     には *note if: 2ca.、*note while: 1b6e.、*note for: 2c9. があります
     。

static type checker

     An external tool that reads Python code and analyzes it, looking
     for issues such as incorrect types.  See also *note type hints:
     1ee2. and the *note typing: ed. module.

strong reference

     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 *note Py_INCREF(): 53a. when the
     reference is created and released with *note Py_DECREF(): 53b. when
     the reference is deleted.

     The *note Py_NewRef(): 867. function can be used to create a strong
     reference to an object.  Usually, the *note Py_DECREF(): 53b.
     function must be called on the strong reference before exiting the
     scope of the strong reference, to avoid leaking one reference.

     See also *note borrowed reference: 317.

text encoding

     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.

     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".

     There are a variety of different text serialization *note codecs:
     d86, which are collectively referred to as "text encodings".

text file

     (テキストファイル) *note str: 418. オブジェクトを読み書きできる
     *note file object: 1193. です。 しばしば、テキストファイルは実際に
     バイト指向のデータストリームにアクセスし、 *note
     テキストエンコーディング: 20de. を自動的に行います。 テキストファイ
     ルの例は、 *note sys.stdin: 507, *note sys.stdout: aa4, *note
     io.StringIO: ef3. インスタンスなどをテキストモード (‘'r'’ or ‘'w'’)
     で開いたファイルです。

     *note bytes-like オブジェクト: cfb. を読み書きできるファイルオブジ
     ェクトについては、 *note バイナリファイル: 1bf1. も参照してください
     。

triple-quoted string

     (三重クォート文字列) 3つの連続したクォート記号(")かアポストロフィー
     (')で囲まれた文字列。通常の(一重)クォート文字列に比べて表現できる文
     字列に違いはありませんが、幾つかの理由で有用です。1つか2つの連続し
     たクォート記号をエスケープ無しに書くことができますし、行継続文字
     (\)を使わなくても複数行にまたがることができるので、ドキュメンテーシ
     ョン文字列を書く時に特に便利です。

type

     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
     *note __class__: 1452. attribute or can be retrieved with
     ‘type(obj)’.

type alias

     (型エイリアス) 型の別名で、型を識別子に代入して作成します。

     型エイリアスは *note 型ヒント: 1ee2. を単純化するのに有用です。例え
     ば:

          def remove_gray_shades(
                  colors: list[tuple[int, int, int]]) -> list[tuple[int, int, int]]:
              pass

     これは次のようにより読みやすくできます:

          Color = tuple[int, int, int]

          def remove_gray_shades(colors: list[Color]) -> list[Color]:
              pass

     機能の説明がある *note typing: ed. と PEP 484(35) を参照してくださ
     い。

type hint

     (型ヒント) 変数、クラス属性、関数のパラメータや返り値の期待される型
     を指定する *note annotation: 424. です。

     Type hints are optional and are not enforced by Python but they are
     useful to *note static type checkers: 24e.  They can also aid IDEs
     with code completion and refactoring.

     グローバル変数、クラス属性、関数で、ローカル変数でないものの型ヒン
     トは *note typing.get_type_hints(): 67d. で取得できます。

     機能の説明がある *note typing: ed. と PEP 484(36) を参照してくださ
     い。

universal newlines

     テキストストリームの解釈法の一つで、以下のすべてを行末と認識します:
     Unix の行末規定 ‘'\n'’、Windows の規定 ‘'\r\n'’、古い Macintosh の
     規定 ‘'\r'’。利用法について詳しくは、 PEP 278(37) と PEP 3116(38) 、
     さらに *note bytes.splitlines(): 2179. も参照してください。

variable annotation

     (変数アノテーション) 変数あるいはクラス属性の *note annotation:
     424. 。

     変数あるいはクラス属性に注釈を付けたときは、代入部分は任意です:

          class C:
              field: 'annotation'

     変数アノテーションは通常は *note 型ヒント: 1ee2. のために使われます
     : 例えば、この変数は *note int: 238. の値を取ることを期待されていま
     す:

          count: int = 0

     変数アノテーションの構文については *note 注釈付き代入文 (annotated
     assignment statements): 2003. 節で解説しています。

     機能の説明がある *note function annotation: 1ba1, PEP 484(39) , PEP
     526(40) を参照してください。また、アノテーションを利用するベストプ
     ラクティスとして *note Annotations Best Practices: 7a4. も参照して
     ください。

virtual environment

     (仮想環境) 協調的に切り離された実行環境です。これにより Python ユー
     ザとアプリケーションは同じシステム上で動いている他の Python アプリ
     ケーションの挙動に干渉することなく Python パッケージのインストール
     と更新を行うことができます。

     *note venv: f9. を参照してください。

virtual machine

     (仮想マシン) 完全にソフトウェアにより定義されたコンピュータ。
     Python の仮想マシンは、バイトコードコンパイラが出力した *note
     バイトコード: 16c. を実行します。

Zen of Python

     (Pythonの悟り) Python を理解し利用する上での導きとなる、Python の設
     計原則と哲学をリストにしたものです。対話プロンプトで "‘import
     this’" とするとこのリストを読めます。

   ---------- Footnotes ----------

   (1) https://peps.python.org/pep-0484/

   (2) https://peps.python.org/pep-0526/

   (3) https://peps.python.org/pep-0362/

   (4) https://peps.python.org/pep-0492/

   (5) https://peps.python.org/pep-0492/

   (6) https://peps.python.org/pep-0525/

   (7) https://peps.python.org/pep-0492/

   (8) https://peps.python.org/pep-0492/

   (9) https://peps.python.org/pep-0492/

   (10) https://gvanrossum.github.io/

   (11) https://peps.python.org/pep-0343/

   (12) https://peps.python.org/pep-0343/

   (13) https://peps.python.org/pep-0492/

   (14) https://peps.python.org/pep-0492/

   (15) https://www.python.org

   (16) https://peps.python.org/pep-0498/

   (17) https://peps.python.org/pep-0238/

   (18) https://peps.python.org/pep-0703/

   (19) https://peps.python.org/pep-0484/

   (20) https://peps.python.org/pep-0443/

   (21) https://peps.python.org/pep-0483/

   (22) https://peps.python.org/pep-0484/

   (23) https://peps.python.org/pep-0585/

   (24) https://peps.python.org/pep-0703/

   (25) https://peps.python.org/pep-0683/

   (26) https://peps.python.org/pep-0302/

   (27) https://peps.python.org/pep-0420/

   (28) https://peps.python.org/pep-0362/

   (29) https://peps.python.org/pep-0519/

   (30) https://peps.python.org/pep-0001/

   (31) https://peps.python.org/pep-0420/

   (32) https://peps.python.org/pep-0411/

   (33) https://peps.python.org/pep-3155/

   (34) https://peps.python.org/pep-0387/#soft-deprecation

   (35) https://peps.python.org/pep-0484/

   (36) https://peps.python.org/pep-0484/

   (37) https://peps.python.org/pep-0278/

   (38) https://peps.python.org/pep-3116/

   (39) https://peps.python.org/pep-0484/

   (40) https://peps.python.org/pep-0526/


File: python.info,  Node: このドキュメントについて,  Next: バグへの対処,  Prev: 用語集<2>,  Up: Top

13 このドキュメントについて
***************************

このドキュメントは、 Python のドキュメントを主要な目的として作られた ド
キュメントプロセッサの Sphinx(1) を利用して、 reStructuredText(2) 形式の
ソースから生成されました。

ドキュメントとそのツール群の開発は、Python 自身と同様に完全にボランティ
アの努力です。 もしあなたが貢献したいなら、どのようにすればよいかについ
て *note バグへの対処: 47c4. ページをご覧下さい。 新しいボランティアはい
つでも歓迎です!  （訳注: 日本語訳の問題については、 GitHub 上の Issue
Tracker(3) で報告をお願いします。）

多大な感謝を:

   * Fred L. Drake, Jr., オリジナルの Python ドキュメントツールセットの
     作成者で、ドキュメントの多くを書きました。

   * Docutils(4) プロジェクト reStructuredText と Docutils ツールセット
     を作成しました。

   * Fredrik Lundh の Alternative Python Reference プロジェクトから
     Sphinx は多くのアイデアを得ました。

* Menu:

* Pythonドキュメント 貢献者::

   ---------- Footnotes ----------

   (1) https://www.sphinx-doc.org/

   (2) https://docutils.sourceforge.io/rst.html

   (3) https://github.com/python-doc-ja/python-doc-ja/issues

   (4) http://docutils.sourceforge.net/


File: python.info,  Node: Pythonドキュメント 貢献者,  Up: このドキュメントについて

13.1 Pythonドキュメント 貢献者
==============================

多くの方々が Python 言語、Python 標準ライブラリ、そして Python ドキュメ
ンテーションに貢献してくれています。ソース配布物の Misc/ACKS(1) に、それ
ら貢献してくれた人々を部分的にではありますがリストアップしてあります。

Python コミュニティからの情報提供と貢献がなければこの素晴らしいドキュメ
ンテーションは生まれませんでした - ありがとう!

   ---------- Footnotes ----------

   (1) https://github.com/python/cpython/tree/3.13/Misc/ACKS


File: python.info,  Node: バグへの対処,  Next: Copyright,  Prev: このドキュメントについて,  Up: Top

14 バグへの対処
***************

Python は安定性について高い評価を得た、成熟した言語です。この評価を守る
ために、開発者たちはあなたが見つけた Python の不備を知りたいと思っていま
す。

バグを自分で直して Python にパッチを送る方が、やり取りに無駄が無く関わる
人数も少なく済むこともあります。 ぜひ *note 貢献: 4fce. する方法を学んで
ください。

* Menu:

* ドキュメントの不備::
* Python の課題管理システムを使う::
* Python への貢献をはじめる::


File: python.info,  Node: ドキュメントの不備,  Next: Python の課題管理システムを使う,  Up: バグへの対処

14.1 ドキュメントの不備
=======================

このドキュメントの不備を発見したとき、または、改善を提案したいときは、問
題点を *note tracker: 22f. に報告してください。修正方法の案があるならば
、それも含めて。 （訳注: 日本語訳の問題については、 GitHub 上の Issue
Tracker(1) で報告をお願いします。）

または Documentation Discourse forum(2) でディスカッションを行うこともで
きます。

ドキュメントのテーマ (HTML / CSS / JavaScript) に不備を見つけたときは、
python-doc-theme bug tracker(3) に報告してください。

時間がない場合、ドキュメントの問題を <docs@python.org> 宛て、メールで報
告することもできます。 (Python の動作に関するバグ報告は
<python-list@python.org> 宛になります。) 'docs@' はボランティアで運営さ
れているメーリングリストです。 報告が伝わっていても、対応への時間がかか
ることもあります。

参考
....

ドキュメントのバグ(4)

     Python issue tracker に出されたドキュメントバグのリスト。

イシュートラッカー(5)

     issue tracker への改善報告に関する作業過程の概観。

ドキュメントを手伝う(6)

     Python ドキュメントへの貢献に興味がある個人へ向けた包括的なガイド。

ドキュメントの翻訳(7)

     ドキュメントの翻訳とその連絡先の載った GitHub pages のリスト。

   ---------- Footnotes ----------

   (1) https://github.com/python-doc-ja/python-doc-ja/issues

   (2) https://discuss.python.org/c/documentation/26

   (3) https://github.com/python/python-docs-theme

   (4) 
https://github.com/python/cpython/issues?q=is%3Aissue+is%3Aopen+label%3Adocs

   (5) https://devguide.python.org/tracker/

   (6) 
https://devguide.python.org/docquality/#helping-with-documentation

   (7) https://devguide.python.org/documentation/translating/


File: python.info,  Node: Python の課題管理システムを使う,  Next: Python への貢献をはじめる,  Prev: ドキュメントの不備,  Up: バグへの対処

14.2 Python の課題管理システムを使う
====================================

Python 自体に関する問題は Githubのissue tracker
(‘https://github.com/python/cpython/issues’) で報告してください。この
Github issue trackerは、関連情報を入力して開発者に報告するための Web フ
ォームを提供しています。

レポートを書くには、初めにその問題が既にレポートされていないか確認します
。これにより、開発者の時間が無駄にならないだけでなく、あなたが、問題に対
して為された対処について知ることもできます。次のリリースに向けて問題が修
正されたのかもしれませんし、追加の情報が必要とされているのかもしれません
（この場合は是非情報を提供してください）。確認のためにはページの上の検索
ボックスを利用してください。

報告しようとしている問題がまだリストにない場合は、GitHub にログインして
ください。GitHubのアカウントをまだお持ちでない場合は、「Sign up」リンク
から新しいアカウントを作成してください。匿名でバグレポートを提出すること
はできません。

ログインした状態で、課題を送信することができます。トップバーの「New
issue」ボタンをクリックして、新しい課題を報告してください。

報告のフォームには、「Title」と「Comment」の2つのフィールドがあります。

「Title」フィールドには、問題の 'とても' 短い説明を（訳注: 英語で）入力
してください。10語以内が望ましいです。

"Comment" フィールドで、あなたが期待した結果と実際の結果も含め、問題の詳
細を説明してください。拡張モジュールが関与しているかどうかと、使用してい
るハードウェアとソフトウェアプラットフォームも (必要に応じてバージョン情
報も) 必ず報告に含めてください。

各問題レポートは開発者によってレビューされ、問題を修正するために何が必要
かを判断します。issueで何らかの行動があるたびに、最新情報を通知します。

参考
....

How to Report Bugs Effectively(1)

     有益なバグ報告について詳しく説明した記事です。どんな情報が、なぜ有
     益なのかを説明しています。

Bug Writing Guidelines(2)

     良いバグ報告を書くための情報です。この情報の一部はMozillaプロジェク
     ト独自のものですが、一般的に良い習慣を解説しています。

   ---------- Footnotes ----------

   (1) https://www.chiark.greenend.org.uk/~sgtatham/bugs.html

   (2) http://developer.mozilla.org/en/docs/Bug_writing_guidelines


File: python.info,  Node: Python への貢献をはじめる,  Prev: Python の課題管理システムを使う,  Up: バグへの対処

14.3 Python への貢献をはじめる
==============================

見つけたバグの報告だけでなく、修正パッチの提出も歓迎します。Python
Developer's Guide(1) には Python へのパッチの始め方について詳しい情報が
あります。疑問があれば、core-mentorship mailing list(2) は Python の問題
解決の過程に関するありとあらゆる疑問への答えを得ることが出来るフレンドリ
ーな場所です。

   ---------- Footnotes ----------

   (1) https://devguide.python.org/

   (2) 
https://mail.python.org/mailman3/lists/core-mentorship.python.org/


File: python.info,  Node: Copyright,  Next: 歴史とライセンス,  Prev: バグへの対処,  Up: Top

15 Copyright
************

Python and this documentation is:

Copyright © 2001-2024 Python Software Foundation.  All rights reserved.

Copyright © 2000 BeOpen.com.  All rights reserved.

Copyright © 1995-2000 Corporation for National Research Initiatives.
All rights reserved.

Copyright © 1991-1995 Stichting Mathematisch Centrum.  All rights
reserved.

__________________________________________________________________

ライセンスおよび許諾に関する完全な情報は、 *note 歴史とライセンス: 4fd4.
を参照してください。


File: python.info,  Node: 歴史とライセンス,  Next: Pythonモジュール索引,  Prev: Copyright,  Up: Top

16 歴史とライセンス
*******************

* Menu:

* Python の歴史::
* Terms and conditions for accessing or otherwise using Python::
* Licenses and Acknowledgements for Incorporated Software::


File: python.info,  Node: Python の歴史,  Next: Terms and conditions for accessing or otherwise using Python,  Up: 歴史とライセンス

16.1 Python の歴史
==================

Python は 1990 年代の始め、オランダにある Stichting Mathematisch Centrum
(CWI, ‘https://www.cwi.nl/’ 参照) で Guido van Rossum によって ABC と呼
ばれる言語の後継言語として生み出されました。その後多くの人々が Python に
貢献していますが、 Guido は今日でも Python 製作者の先頭に立っています。

1995 年、 Guido は米国ヴァージニア州レストンにある Corporation for
National Reserch Initiatives (CNRI, ‘https://www.cnri.reston.va.us/’ 参
照) で Python の開発に携わり、いくつかのバージョンをリリースしました。

2000 年 3 月、 Guido と Python のコア開発チームは BeOpen.com に移り、
BeOpen PythonLabs チームを結成しました。同年 10 月、 PythonLabs チームは
Digital Creations (現在の Zope Corporation, ‘https://www.zope.org/’ 参照
) に移りました。そして 2001 年、 Python に関する知的財産を保有するための
非営利組織 Python Software Foundation (PSF、
‘https://www.python.org/psf/’ 参照) を立ち上げました。このとき Zope
Corporation は PSF の賛助会員になりました。

Python のリリースは全てオープンソース (オープンソースの定義は
‘https://opensource.org/’ を参照してください) です。歴史的にみて、ごく一
部を除くほとんどの Python リリースは GPL 互換になっています; 各リリース
については下表にまとめてあります。

リリース             ベース             西暦年           権利             GPL 互換
                                                                          
------------------------------------------------------------------------------------------------
                                                                          
0.9.0 - 1.2          n/a                1991-1995        CWI              yes
                                                                          
                                                                          
1.3 - 1.5.2          1.2                1995-1999        CNRI             yes
                                                                          
                                                                          
1.6                  1.5.2              2000             CNRI             no
                                                                          
                                                                          
2.0                  1.6                2000             BeOpen.com       no
                                                                          
                                                                          
1.6.1                1.6                2001             CNRI             no
                                                                          
                                                                          
2.1                  2.0+1.6.1          2001             PSF              no
                                                                          
                                                                          
2.0.1                2.0+1.6.1          2001             PSF              yes
                                                                          
                                                                          
2.1.1                2.1+2.0.1          2001             PSF              yes
                                                                          
                                                                          
2.1.2                2.1.1              2002             PSF              yes
                                                                          
                                                                          
2.1.3                2.1.2              2002             PSF              yes
                                                                          
                                                                          
2.2 以降             2.1.1              2001-現在        PSF              yes
                                                                          

     注釈: 「GPL 互換」という表現は、Python が GPL で配布されているとい
     う意味ではありません。Python のライセンスは全て、GPL と違い、変更し
     たバージョンを配布する際に変更をオープンソースにしなくてもかまいま
     せん。GPL 互換のライセンスの下では、GPL でリリースされている他のソ
     フトウェアと Python を組み合わせられますが、それ以外のライセンスで
     はそうではありません。

Guido の指示の下、これらのリリースを可能にしてくださった多くのボランティ
アのみなさんに感謝します。


File: python.info,  Node: Terms and conditions for accessing or otherwise using Python,  Next: Licenses and Acknowledgements for Incorporated Software,  Prev: Python の歴史,  Up: 歴史とライセンス

16.2 Terms and conditions for accessing or otherwise using Python
=================================================================

Python software and documentation are licensed under the *note PSF
License Agreement: 4fd9.

Starting with Python 3.8.6, examples, recipes, and other code in the
documentation are dual licensed under the PSF License Agreement and the
*note Zero-Clause BSD license: 4fda.

Some software incorporated into Python is under different licenses.  The
licenses are listed with code falling under that license.  See *note
Licenses and Acknowledgements for Incorporated Software: 4fdb. for an
incomplete list of these licenses.

* Menu:

* PSF LICENSE AGREEMENT FOR PYTHON 3.13.0: PSF LICENSE AGREEMENT FOR PYTHON 3 13 0.
* BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0: BEOPEN COM LICENSE AGREEMENT FOR PYTHON 2 0.
* CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1: CNRI LICENSE AGREEMENT FOR PYTHON 1 6 1.
* CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2: CWI LICENSE AGREEMENT FOR PYTHON 0 9 0 THROUGH 1 2.
* ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3.13.0 DOCUMENTATION: ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3 13 0 DOCUMENTATION.


File: python.info,  Node: PSF LICENSE AGREEMENT FOR PYTHON 3 13 0,  Next: BEOPEN COM LICENSE AGREEMENT FOR PYTHON 2 0,  Up: Terms and conditions for accessing or otherwise using Python

16.2.1 PSF LICENSE AGREEMENT FOR PYTHON 3.13.0
----------------------------------------------

     1. This LICENSE AGREEMENT is between the Python Software Foundation ("PSF"), and
        the Individual or Organization ("Licensee") accessing and otherwise using Python
        3.13.0 software in source or binary form and its associated documentation.

     2. Subject to the terms and conditions of this License Agreement, PSF hereby
        grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
        analyze, test, perform and/or display publicly, prepare derivative works,
        distribute, and otherwise use Python 3.13.0 alone or in any derivative
        version, provided, however, that PSF's License Agreement and PSF's notice of
        copyright, i.e., "Copyright © 2001-2024 Python Software Foundation; All Rights
        Reserved" are retained in Python 3.13.0 alone or in any derivative version
        prepared by Licensee.

     3. In the event Licensee prepares a derivative work that is based on or
        incorporates Python 3.13.0 or any part thereof, and wants to make the
        derivative work available to others as provided herein, then Licensee hereby
        agrees to include in any such work a brief summary of the changes made to Python
        3.13.0.

     4. PSF is making Python 3.13.0 available to Licensee on an "AS IS" basis.
        PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY OF
        EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
        WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
        USE OF PYTHON 3.13.0 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.

     5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 3.13.0
        FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
        MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 3.13.0, OR ANY DERIVATIVE
        THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

     6. This License Agreement will automatically terminate upon a material breach of
        its terms and conditions.

     7. Nothing in this License Agreement shall be deemed to create any relationship
        of agency, partnership, or joint venture between PSF and Licensee.  This License
        Agreement does not grant permission to use PSF trademarks or trade name in a
        trademark sense to endorse or promote products or services of Licensee, or any
        third party.

     8. By copying, installing or otherwise using Python 3.13.0, Licensee agrees
        to be bound by the terms and conditions of this License Agreement.


File: python.info,  Node: BEOPEN COM LICENSE AGREEMENT FOR PYTHON 2 0,  Next: CNRI LICENSE AGREEMENT FOR PYTHON 1 6 1,  Prev: PSF LICENSE AGREEMENT FOR PYTHON 3 13 0,  Up: Terms and conditions for accessing or otherwise using Python

16.2.2 BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
--------------------------------------------------

BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1

     1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an office at
        160 Saratoga Avenue, Santa Clara, CA 95051, and the Individual or Organization
        ("Licensee") accessing and otherwise using this software in source or binary
        form and its associated documentation ("the Software").

     2. Subject to the terms and conditions of this BeOpen Python License Agreement,
        BeOpen hereby grants Licensee a non-exclusive, royalty-free, world-wide license
        to reproduce, analyze, test, perform and/or display publicly, prepare derivative
        works, distribute, and otherwise use the Software alone or in any derivative
        version, provided, however, that the BeOpen Python License is retained in the
        Software, alone or in any derivative version prepared by Licensee.

     3. BeOpen is making the Software available to Licensee on an "AS IS" basis.
        BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY OF
        EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND DISCLAIMS ANY REPRESENTATION OR
        WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE
        USE OF THE SOFTWARE WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.

     4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE SOFTWARE FOR
        ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF USING,
        MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY DERIVATIVE THEREOF, EVEN IF
        ADVISED OF THE POSSIBILITY THEREOF.

     5. This License Agreement will automatically terminate upon a material breach of
        its terms and conditions.

     6. This License Agreement shall be governed by and interpreted in all respects
        by the law of the State of California, excluding conflict of law provisions.
        Nothing in this License Agreement shall be deemed to create any relationship of
        agency, partnership, or joint venture between BeOpen and Licensee.  This License
        Agreement does not grant permission to use BeOpen trademarks or trade names in a
        trademark sense to endorse or promote products or services of Licensee, or any
        third party.  As an exception, the "BeOpen Python" logos available at
        ‘http://www.pythonlabs.com/logos.html’ may be used according to the permissions
        granted on that web page.

     7. By copying, installing or otherwise using the software, Licensee agrees to be
        bound by the terms and conditions of this License Agreement.


File: python.info,  Node: CNRI LICENSE AGREEMENT FOR PYTHON 1 6 1,  Next: CWI LICENSE AGREEMENT FOR PYTHON 0 9 0 THROUGH 1 2,  Prev: BEOPEN COM LICENSE AGREEMENT FOR PYTHON 2 0,  Up: Terms and conditions for accessing or otherwise using Python

16.2.3 CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
----------------------------------------------

     1. This LICENSE AGREEMENT is between the Corporation for National Research
        Initiatives, having an office at 1895 Preston White Drive, Reston, VA 20191
        ("CNRI"), and the Individual or Organization ("Licensee") accessing and
        otherwise using Python 1.6.1 software in source or binary form and its
        associated documentation.

     2. Subject to the terms and conditions of this License Agreement, CNRI hereby
        grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
        analyze, test, perform and/or display publicly, prepare derivative works,
        distribute, and otherwise use Python 1.6.1 alone or in any derivative version,
        provided, however, that CNRI's License Agreement and CNRI's notice of copyright,
        i.e., "Copyright © 1995-2001 Corporation for National Research Initiatives; All
        Rights Reserved" are retained in Python 1.6.1 alone or in any derivative version
        prepared by Licensee.  Alternately, in lieu of CNRI's License Agreement,
        Licensee may substitute the following text (omitting the quotes): "Python 1.6.1
        is made available subject to the terms and conditions in CNRI's License
        Agreement.  This Agreement together with Python 1.6.1 may be located on the
        internet using the following unique, persistent identifier (known as a handle):
        1895.22/1013.  This Agreement may also be obtained from a proxy server on the
        internet using the following URL: ‘http://hdl.handle.net/1895.22/1013’."

     3. In the event Licensee prepares a derivative work that is based on or
        incorporates Python 1.6.1 or any part thereof, and wants to make the derivative
        work available to others as provided herein, then Licensee hereby agrees to
        include in any such work a brief summary of the changes made to Python 1.6.1.

     4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" basis.  CNRI
        MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.  BY WAY OF EXAMPLE,
        BUT NOT LIMITATION, CNRI MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY
        OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF
        PYTHON 1.6.1 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS.

     5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON 1.6.1 FOR
        ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF
        MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, OR ANY DERIVATIVE
        THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

     6. This License Agreement will automatically terminate upon a material breach of
        its terms and conditions.

     7. This License Agreement shall be governed by the federal intellectual property
        law of the United States, including without limitation the federal copyright
        law, and, to the extent such U.S. federal law does not apply, by the law of the
        Commonwealth of Virginia, excluding Virginia's conflict of law provisions.
        Notwithstanding the foregoing, with regard to derivative works based on Python
        1.6.1 that incorporate non-separable material that was previously distributed
        under the GNU General Public License (GPL), the law of the Commonwealth of
        Virginia shall govern this License Agreement only as to issues arising under or
        with respect to Paragraphs 4, 5, and 7 of this License Agreement.  Nothing in
        this License Agreement shall be deemed to create any relationship of agency,
        partnership, or joint venture between CNRI and Licensee.  This License Agreement
        does not grant permission to use CNRI trademarks or trade name in a trademark
        sense to endorse or promote products or services of Licensee, or any third
        party.

     8. By clicking on the "ACCEPT" button where indicated, or by copying, installing
        or otherwise using Python 1.6.1, Licensee agrees to be bound by the terms and
        conditions of this License Agreement.


File: python.info,  Node: CWI LICENSE AGREEMENT FOR PYTHON 0 9 0 THROUGH 1 2,  Next: ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3 13 0 DOCUMENTATION,  Prev: CNRI LICENSE AGREEMENT FOR PYTHON 1 6 1,  Up: Terms and conditions for accessing or otherwise using Python

16.2.4 CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
---------------------------------------------------------

     Copyright © 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, The
     Netherlands.  All rights reserved.

     Permission to use, copy, modify, and distribute this software and its
     documentation for any purpose and without fee is hereby granted, provided that
     the above copyright notice appear in all copies and that both that copyright
     notice and this permission notice appear in supporting documentation, and that
     the name of Stichting Mathematisch Centrum or CWI not be used in advertising or
     publicity pertaining to distribution of the software without specific, written
     prior permission.

     STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
     SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
     EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE FOR ANY SPECIAL, INDIRECT
     OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
     DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     SOFTWARE.


File: python.info,  Node: ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3 13 0 DOCUMENTATION,  Prev: CWI LICENSE AGREEMENT FOR PYTHON 0 9 0 THROUGH 1 2,  Up: Terms and conditions for accessing or otherwise using Python

16.2.5 ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3.13.0 DOCUMENTATION
--------------------------------------------------------------------------

     Permission to use, copy, modify, and/or distribute this software for any
     purpose with or without fee is hereby granted.

     THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
     REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
     AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
     INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
     LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
     OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     PERFORMANCE OF THIS SOFTWARE.


File: python.info,  Node: Licenses and Acknowledgements for Incorporated Software,  Prev: Terms and conditions for accessing or otherwise using Python,  Up: 歴史とライセンス

16.3 Licenses and Acknowledgements for Incorporated Software
============================================================

This section is an incomplete, but growing list of licenses and
acknowledgements for third-party software incorporated in the Python
distribution.

* Menu:

* Mersenne Twister::
* ソケット: ソケット<2>.
* Asynchronous socket services::
* Cookie management::
* Execution tracing::
* UUencode and UUdecode functions::
* XML Remote Procedure Calls::
* test_epoll::
* Select kqueue::
* SipHash24::
* strtod と dtoa::
* OpenSSL: OpenSSL<2>.
* expat::
* libffi::
* zlib: zlib<3>.
* cfuhash::
* libmpdec::
* W3C C14N test suite::
* mimalloc::
* asyncio: asyncio<12>.
* Global Unbounded Sequences (GUS): Global Unbounded Sequences GUS.


File: python.info,  Node: Mersenne Twister,  Next: ソケット<2>,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.1 Mersenne Twister
-----------------------

The ‘_random’ C extension underlying the *note random: a6. module
includes code based on a download from
‘http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html’.
The following are the verbatim comments from the original code:

     A C-program for MT19937, with initialization improved 2002/1/26.
     Coded by Takuji Nishimura and Makoto Matsumoto.

     Before using, initialize the state by using init_genrand(seed)
     or init_by_array(init_key, key_length).

     Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
     All rights reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:

      1. Redistributions of source code must retain the above copyright
         notice, this list of conditions and the following disclaimer.

      2. Redistributions in binary form must reproduce the above copyright
         notice, this list of conditions and the following disclaimer in the
         documentation and/or other materials provided with the distribution.

      3. The names of its contributors may not be used to endorse or promote
         products derived from this software without specific prior written
         permission.

     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
     NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


     Any feedback is very welcome.
     http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
     email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)


File: python.info,  Node: ソケット<2>,  Next: Asynchronous socket services,  Prev: Mersenne Twister,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.2 ソケット
---------------

The *note socket: b8. module uses the functions, ‘getaddrinfo()’, and
‘getnameinfo()’, which are coded in separate source files from the WIDE
Project, ‘https://www.wide.ad.jp/’.

     Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
     All rights reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
     1. Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
     2. Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
     3. Neither the name of the project nor the names of its contributors
        may be used to endorse or promote products derived from this software
        without specific prior written permission.

     THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     SUCH DAMAGE.


File: python.info,  Node: Asynchronous socket services,  Next: Cookie management,  Prev: ソケット<2>,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.3 Asynchronous socket services
-----------------------------------

The ‘test.support.asynchat’ and ‘test.support.asyncore’ modules contain
the following notice:

     Copyright 1996 by Sam Rushing

                             All Rights Reserved

     Permission to use, copy, modify, and distribute this software and
     its documentation for any purpose and without fee is hereby
     granted, provided that the above copyright notice appear in all
     copies and that both that copyright notice and this permission
     notice appear in supporting documentation, and that the name of Sam
     Rushing not be used in advertising or publicity pertaining to
     distribution of the software without specific, written prior
     permission.

     SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
     NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
     OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
     NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
     CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


File: python.info,  Node: Cookie management,  Next: Execution tracing,  Prev: Asynchronous socket services,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.4 Cookie management
------------------------

The *note http.cookies: 67. module contains the following notice:

     Copyright 2000 by Timothy O'Malley <timo@alum.mit.edu>

                    All Rights Reserved

     Permission to use, copy, modify, and distribute this software
     and its documentation for any purpose and without fee is hereby
     granted, provided that the above copyright notice appear in all
     copies and that both that copyright notice and this permission
     notice appear in supporting documentation, and that the name of
     Timothy O'Malley  not be used in advertising or publicity
     pertaining to distribution of the software without specific, written
     prior permission.

     Timothy O'Malley DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
     SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
     AND FITNESS, IN NO EVENT SHALL Timothy O'Malley BE LIABLE FOR
     ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     PERFORMANCE OF THIS SOFTWARE.


File: python.info,  Node: Execution tracing,  Next: UUencode and UUdecode functions,  Prev: Cookie management,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.5 Execution tracing
------------------------

The *note trace: e6. module contains the following notice:

     portions copyright 2001, Autonomous Zones Industries, Inc., all rights...
     err...  reserved and offered to the public under the terms of the
     Python 2.2 license.
     Author: Zooko O'Whielacronx
     http://zooko.com/
     mailto:zooko@zooko.com

     Copyright 2000, Mojam Media, Inc., all rights reserved.
     Author: Skip Montanaro

     Copyright 1999, Bioreason, Inc., all rights reserved.
     Author: Andrew Dalke

     Copyright 1995-1997, Automatrix, Inc., all rights reserved.
     Author: Skip Montanaro

     Copyright 1991-1995, Stichting Mathematisch Centrum, all rights reserved.


     Permission to use, copy, modify, and distribute this Python software and
     its associated documentation for any purpose without fee is hereby
     granted, provided that the above copyright notice appears in all copies,
     and that both that copyright notice and this permission notice appear in
     supporting documentation, and that the name of neither Automatrix,
     Bioreason or Mojam Media be used in advertising or publicity pertaining to
     distribution of the software without specific, written prior permission.


File: python.info,  Node: UUencode and UUdecode functions,  Next: XML Remote Procedure Calls,  Prev: Execution tracing,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.6 UUencode and UUdecode functions
--------------------------------------

The ‘uu’ codec contains the following notice:

     Copyright 1994 by Lance Ellinghouse
     Cathedral City, California Republic, United States of America.
                            All Rights Reserved
     Permission to use, copy, modify, and distribute this software and its
     documentation for any purpose and without fee is hereby granted,
     provided that the above copyright notice appear in all copies and that
     both that copyright notice and this permission notice appear in
     supporting documentation, and that the name of Lance Ellinghouse
     not be used in advertising or publicity pertaining to distribution
     of the software without specific, written prior permission.
     LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO
     THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
     FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE CENTRUM BE LIABLE
     FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
     OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

     Modified by Jack Jansen, CWI, July 1995:
     - Use binascii module to do the actual line-by-line conversion
       between ascii and binary. This results in a 1000-fold speedup. The C
       version is still 5 times faster, though.
     - Arguments more compliant with Python standard


File: python.info,  Node: XML Remote Procedure Calls,  Next: test_epoll,  Prev: UUencode and UUdecode functions,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.7 XML Remote Procedure Calls
---------------------------------

The *note xmlrpc.client: 114. module contains the following notice:

         The XML-RPC client interface is

     Copyright (c) 1999-2002 by Secret Labs AB
     Copyright (c) 1999-2002 by Fredrik Lundh

     By obtaining, using, and/or copying this software and/or its
     associated documentation, you agree that you have read, understood,
     and will comply with the following terms and conditions:

     Permission to use, copy, modify, and distribute this software and
     its associated documentation for any purpose and without fee is
     hereby granted, provided that the above copyright notice appears in
     all copies, and that both that copyright notice and this permission
     notice appear in supporting documentation, and that the name of
     Secret Labs AB or the author not be used in advertising or publicity
     pertaining to distribution of the software without specific, written
     prior permission.

     SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
     TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
     ABILITY AND FITNESS.  IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
     BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
     DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
     WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
     OF THIS SOFTWARE.


File: python.info,  Node: test_epoll,  Next: Select kqueue,  Prev: XML Remote Procedure Calls,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.8 test_epoll
-----------------

The ‘test.test_epoll’ module contains the following notice:

     Copyright (c) 2001-2006 Twisted Matrix Laboratories.

     Permission is hereby granted, free of charge, to any person obtaining
     a copy of this software and associated documentation files (the
     "Software"), to deal in the Software without restriction, including
     without limitation the rights to use, copy, modify, merge, publish,
     distribute, sublicense, and/or sell copies of the Software, and to
     permit persons to whom the Software is furnished to do so, subject to
     the following conditions:

     The above copyright notice and this permission notice shall be
     included in all copies or substantial portions of the Software.

     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


File: python.info,  Node: Select kqueue,  Next: SipHash24,  Prev: test_epoll,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.9 Select kqueue
--------------------

*note select: af. モジュールは kqueue インターフェースについての次の告知
を含んでいます:

     Copyright (c) 2000 Doug White, 2006 James Knight, 2007 Christian Heimes
     All rights reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
     1. Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
     2. Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.

     THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     SUCH DAMAGE.


File: python.info,  Node: SipHash24,  Next: strtod と dtoa,  Prev: Select kqueue,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.10 SipHash24
-----------------

The file ‘Python/pyhash.c’ contains Marek Majkowski' implementation of
Dan Bernstein's SipHash24 algorithm.  It contains the following note:

     <MIT License>
     Copyright (c) 2013  Marek Majkowski <marek@popcount.org>

     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
     in the Software without restriction, including without limitation the rights
     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     copies of the Software, and to permit persons to whom the Software is
     furnished to do so, subject to the following conditions:

     The above copyright notice and this permission notice shall be included in
     all copies or substantial portions of the Software.
     </MIT License>

     Original location:
        https://github.com/majek/csiphash/

     Solution inspired by code from:
        Samuel Neves (supercop/crypto_auth/siphash24/little)
        djb (supercop/crypto_auth/siphash24/little2)
        Jean-Philippe Aumasson (https://131002.net/siphash/siphash24.c)


File: python.info,  Node: strtod と dtoa,  Next: OpenSSL<2>,  Prev: SipHash24,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.11 strtod と dtoa
----------------------

The file ‘Python/dtoa.c’, which supplies C functions dtoa and strtod for
conversion of C doubles to and from strings, is derived from the file of
the same name by David M. Gay, currently available from
‘https://web.archive.org/web/20220517033456/http://www.netlib.org/fp/dtoa.c’.
The original file, as retrieved on March 16, 2009, contains the
following copyright and licensing notice:

     /****************************************************************
      *
      * The author of this software is David M. Gay.
      *
      * Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
      *
      * Permission to use, copy, modify, and distribute this software for any
      * purpose without fee is hereby granted, provided that this entire notice
      * is included in all copies of any software which is or includes a copy
      * or modification of this software and in all copies of the supporting
      * documentation for such software.
      *
      * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
      * WARRANTY.  IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
      * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
      * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
      *
      ***************************************************************/


File: python.info,  Node: OpenSSL<2>,  Next: expat,  Prev: strtod と dtoa,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.12 OpenSSL
---------------

The modules *note hashlib: 5e, *note posix: 9b. and *note ssl: bb. use
the OpenSSL library for added performance if made available by the
operating system.  Additionally, the Windows and macOS installers for
Python may include a copy of the OpenSSL libraries, so we include a copy
of the OpenSSL license here.  For the OpenSSL 3.0 release, and later
releases derived from that, the Apache License v2 applies:

                                   Apache License
                             Version 2.0, January 2004
                          https://www.apache.org/licenses/

     TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

     1. Definitions.

        "License" shall mean the terms and conditions for use, reproduction,
        and distribution as defined by Sections 1 through 9 of this document.

        "Licensor" shall mean the copyright owner or entity authorized by
        the copyright owner that is granting the License.

        "Legal Entity" shall mean the union of the acting entity and all
        other entities that control, are controlled by, or are under common
        control with that entity. For the purposes of this definition,
        "control" means (i) the power, direct or indirect, to cause the
        direction or management of such entity, whether by contract or
        otherwise, or (ii) ownership of fifty percent (50%) or more of the
        outstanding shares, or (iii) beneficial ownership of such entity.

        "You" (or "Your") shall mean an individual or Legal Entity
        exercising permissions granted by this License.

        "Source" form shall mean the preferred form for making modifications,
        including but not limited to software source code, documentation
        source, and configuration files.

        "Object" form shall mean any form resulting from mechanical
        transformation or translation of a Source form, including but
        not limited to compiled object code, generated documentation,
        and conversions to other media types.

        "Work" shall mean the work of authorship, whether in Source or
        Object form, made available under the License, as indicated by a
        copyright notice that is included in or attached to the work
        (an example is provided in the Appendix below).

        "Derivative Works" shall mean any work, whether in Source or Object
        form, that is based on (or derived from) the Work and for which the
        editorial revisions, annotations, elaborations, or other modifications
        represent, as a whole, an original work of authorship. For the purposes
        of this License, Derivative Works shall not include works that remain
        separable from, or merely link (or bind by name) to the interfaces of,
        the Work and Derivative Works thereof.

        "Contribution" shall mean any work of authorship, including
        the original version of the Work and any modifications or additions
        to that Work or Derivative Works thereof, that is intentionally
        submitted to Licensor for inclusion in the Work by the copyright owner
        or by an individual or Legal Entity authorized to submit on behalf of
        the copyright owner. For the purposes of this definition, "submitted"
        means any form of electronic, verbal, or written communication sent
        to the Licensor or its representatives, including but not limited to
        communication on electronic mailing lists, source code control systems,
        and issue tracking systems that are managed by, or on behalf of, the
        Licensor for the purpose of discussing and improving the Work, but
        excluding communication that is conspicuously marked or otherwise
        designated in writing by the copyright owner as "Not a Contribution."

        "Contributor" shall mean Licensor and any individual or Legal Entity
        on behalf of whom a Contribution has been received by Licensor and
        subsequently incorporated within the Work.

     2. Grant of Copyright License. Subject to the terms and conditions of
        this License, each Contributor hereby grants to You a perpetual,
        worldwide, non-exclusive, no-charge, royalty-free, irrevocable
        copyright license to reproduce, prepare Derivative Works of,
        publicly display, publicly perform, sublicense, and distribute the
        Work and such Derivative Works in Source or Object form.

     3. Grant of Patent License. Subject to the terms and conditions of
        this License, each Contributor hereby grants to You a perpetual,
        worldwide, non-exclusive, no-charge, royalty-free, irrevocable
        (except as stated in this section) patent license to make, have made,
        use, offer to sell, sell, import, and otherwise transfer the Work,
        where such license applies only to those patent claims licensable
        by such Contributor that are necessarily infringed by their
        Contribution(s) alone or by combination of their Contribution(s)
        with the Work to which such Contribution(s) was submitted. If You
        institute patent litigation against any entity (including a
        cross-claim or counterclaim in a lawsuit) alleging that the Work
        or a Contribution incorporated within the Work constitutes direct
        or contributory patent infringement, then any patent licenses
        granted to You under this License for that Work shall terminate
        as of the date such litigation is filed.

     4. Redistribution. You may reproduce and distribute copies of the
        Work or Derivative Works thereof in any medium, with or without
        modifications, and in Source or Object form, provided that You
        meet the following conditions:

        (a) You must give any other recipients of the Work or
            Derivative Works a copy of this License; and

        (b) You must cause any modified files to carry prominent notices
            stating that You changed the files; and

        (c) You must retain, in the Source form of any Derivative Works
            that You distribute, all copyright, patent, trademark, and
            attribution notices from the Source form of the Work,
            excluding those notices that do not pertain to any part of
            the Derivative Works; and

        (d) If the Work includes a "NOTICE" text file as part of its
            distribution, then any Derivative Works that You distribute must
            include a readable copy of the attribution notices contained
            within such NOTICE file, excluding those notices that do not
            pertain to any part of the Derivative Works, in at least one
            of the following places: within a NOTICE text file distributed
            as part of the Derivative Works; within the Source form or
            documentation, if provided along with the Derivative Works; or,
            within a display generated by the Derivative Works, if and
            wherever such third-party notices normally appear. The contents
            of the NOTICE file are for informational purposes only and
            do not modify the License. You may add Your own attribution
            notices within Derivative Works that You distribute, alongside
            or as an addendum to the NOTICE text from the Work, provided
            that such additional attribution notices cannot be construed
            as modifying the License.

        You may add Your own copyright statement to Your modifications and
        may provide additional or different license terms and conditions
        for use, reproduction, or distribution of Your modifications, or
        for any such Derivative Works as a whole, provided Your use,
        reproduction, and distribution of the Work otherwise complies with
        the conditions stated in this License.

     5. Submission of Contributions. Unless You explicitly state otherwise,
        any Contribution intentionally submitted for inclusion in the Work
        by You to the Licensor shall be under the terms and conditions of
        this License, without any additional terms or conditions.
        Notwithstanding the above, nothing herein shall supersede or modify
        the terms of any separate license agreement you may have executed
        with Licensor regarding such Contributions.

     6. Trademarks. This License does not grant permission to use the trade
        names, trademarks, service marks, or product names of the Licensor,
        except as required for reasonable and customary use in describing the
        origin of the Work and reproducing the content of the NOTICE file.

     7. Disclaimer of Warranty. Unless required by applicable law or
        agreed to in writing, Licensor provides the Work (and each
        Contributor provides its Contributions) on an "AS IS" BASIS,
        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
        implied, including, without limitation, any warranties or conditions
        of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
        PARTICULAR PURPOSE. You are solely responsible for determining the
        appropriateness of using or redistributing the Work and assume any
        risks associated with Your exercise of permissions under this License.

     8. Limitation of Liability. In no event and under no legal theory,
        whether in tort (including negligence), contract, or otherwise,
        unless required by applicable law (such as deliberate and grossly
        negligent acts) or agreed to in writing, shall any Contributor be
        liable to You for damages, including any direct, indirect, special,
        incidental, or consequential damages of any character arising as a
        result of this License or out of the use or inability to use the
        Work (including but not limited to damages for loss of goodwill,
        work stoppage, computer failure or malfunction, or any and all
        other commercial damages or losses), even if such Contributor
        has been advised of the possibility of such damages.

     9. Accepting Warranty or Additional Liability. While redistributing
        the Work or Derivative Works thereof, You may choose to offer,
        and charge a fee for, acceptance of support, warranty, indemnity,
        or other liability obligations and/or rights consistent with this
        License. However, in accepting such obligations, You may act only
        on Your own behalf and on Your sole responsibility, not on behalf
        of any other Contributor, and only if You agree to indemnify,
        defend, and hold each Contributor harmless for any liability
        incurred by, or claims asserted against, such Contributor by reason
        of your accepting any such warranty or additional liability.

     END OF TERMS AND CONDITIONS


File: python.info,  Node: expat,  Next: libffi,  Prev: OpenSSL<2>,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.13 expat
-------------

The *note pyexpat: 10d. extension is built using an included copy of the
expat sources unless the build is configured ‘--with-system-expat’:

     Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
                                    and Clark Cooper

     Permission is hereby granted, free of charge, to any person obtaining
     a copy of this software and associated documentation files (the
     "Software"), to deal in the Software without restriction, including
     without limitation the rights to use, copy, modify, merge, publish,
     distribute, sublicense, and/or sell copies of the Software, and to
     permit persons to whom the Software is furnished to do so, subject to
     the following conditions:

     The above copyright notice and this permission notice shall be included
     in all copies or substantial portions of the Software.

     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
     IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
     CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
     TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
     SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


File: python.info,  Node: libffi,  Next: zlib<3>,  Prev: expat,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.14 libffi
--------------

The ‘_ctypes’ C extension underlying the *note ctypes: 22. module is
built using an included copy of the libffi sources unless the build is
configured ‘--with-system-libffi’:

     Copyright (c) 1996-2008  Red Hat, Inc and others.

     Permission is hereby granted, free of charge, to any person obtaining
     a copy of this software and associated documentation files (the
     ``Software''), to deal in the Software without restriction, including
     without limitation the rights to use, copy, modify, merge, publish,
     distribute, sublicense, and/or sell copies of the Software, and to
     permit persons to whom the Software is furnished to do so, subject to
     the following conditions:

     The above copyright notice and this permission notice shall be included
     in all copies or substantial portions of the Software.

     THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     DEALINGS IN THE SOFTWARE.


File: python.info,  Node: zlib<3>,  Next: cfuhash,  Prev: libffi,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.15 zlib
------------

The *note zlib: 119. extension is built using an included copy of the
zlib sources if the zlib version found on the system is too old to be
used for the build:

     Copyright (C) 1995-2011 Jean-loup Gailly and Mark Adler

     This software is provided 'as-is', without any express or implied
     warranty.  In no event will the authors be held liable for any damages
     arising from the use of this software.

     Permission is granted to anyone to use this software for any purpose,
     including commercial applications, and to alter it and redistribute it
     freely, subject to the following restrictions:

     1. The origin of this software must not be misrepresented; you must not
        claim that you wrote the original software. If you use this software
        in a product, an acknowledgment in the product documentation would be
        appreciated but is not required.

     2. Altered source versions must be plainly marked as such, and must not be
        misrepresented as being the original software.

     3. This notice may not be removed or altered from any source distribution.

     Jean-loup Gailly        Mark Adler
     jloup@gzip.org          madler@alumni.caltech.edu


File: python.info,  Node: cfuhash,  Next: libmpdec,  Prev: zlib<3>,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.16 cfuhash
---------------

The implementation of the hash table used by the *note tracemalloc: e8.
で使用しているハッシュテーブルの実装は、cfuhashプロジェクトのものに基づ
きます:

     Copyright (c) 2005 Don Owens
     All rights reserved.

     This code is released under the BSD license:

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:

       * Redistributions of source code must retain the above copyright
         notice, this list of conditions and the following disclaimer.

       * Redistributions in binary form must reproduce the above
         copyright notice, this list of conditions and the following
         disclaimer in the documentation and/or other materials provided
         with the distribution.

       * Neither the name of the author nor the names of its
         contributors may be used to endorse or promote products derived
         from this software without specific prior written permission.

     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
     OF THE POSSIBILITY OF SUCH DAMAGE.


File: python.info,  Node: libmpdec,  Next: W3C C14N test suite,  Prev: cfuhash,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.17 libmpdec
----------------

The ‘_decimal’ C extension underlying the *note decimal: 2e. module is
built using an included copy of the libmpdec library unless the build is
configured ‘--with-system-libmpdec’:

     Copyright (c) 2008-2020 Stefan Krah. All rights reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:

     1. Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.

     2. Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.

     THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     SUCH DAMAGE.


File: python.info,  Node: W3C C14N test suite,  Next: mimalloc,  Prev: libmpdec,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.18 W3C C14N test suite
---------------------------

The C14N 2.0 test suite in the *note test: cb. package
(‘Lib/test/xmltestdata/c14n-20/’) was retrieved from the W3C website at
‘https://www.w3.org/TR/xml-c14n2-testcases/’ and is distributed under
the 3-clause BSD license:

     Copyright (c) 2013 W3C(R) (MIT, ERCIM, Keio, Beihang),
     All Rights Reserved.

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:

     * Redistributions of works must retain the original copyright notice,
       this list of conditions and the following disclaimer.
     * Redistributions in binary form must reproduce the original copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
     * Neither the name of the W3C nor the names of its contributors may be
       used to endorse or promote products derived from this work without
       specific prior written permission.

     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


File: python.info,  Node: mimalloc,  Next: asyncio<12>,  Prev: W3C C14N test suite,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.19 mimalloc
----------------

MIT License:

     Copyright (c) 2018-2021 Microsoft Corporation, Daan Leijen

     Permission is hereby granted, free of charge, to any person obtaining a copy
     of this software and associated documentation files (the "Software"), to deal
     in the Software without restriction, including without limitation the rights
     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     copies of the Software, and to permit persons to whom the Software is
     furnished to do so, subject to the following conditions:

     The above copyright notice and this permission notice shall be included in all
     copies or substantial portions of the Software.

     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     SOFTWARE.


File: python.info,  Node: asyncio<12>,  Next: Global Unbounded Sequences GUS,  Prev: mimalloc,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.20 asyncio
---------------

Parts of the *note asyncio: 8. module are incorporated from uvloop
0.16(1), which is distributed under the MIT license:

     Copyright (c) 2015-2021 MagicStack Inc.  http://magic.io

     Permission is hereby granted, free of charge, to any person obtaining
     a copy of this software and associated documentation files (the
     "Software"), to deal in the Software without restriction, including
     without limitation the rights to use, copy, modify, merge, publish,
     distribute, sublicense, and/or sell copies of the Software, and to
     permit persons to whom the Software is furnished to do so, subject to
     the following conditions:

     The above copyright notice and this permission notice shall be
     included in all copies or substantial portions of the Software.

     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

   ---------- Footnotes ----------

   (1) https://github.com/MagicStack/uvloop/tree/v0.16.0


File: python.info,  Node: Global Unbounded Sequences GUS,  Prev: asyncio<12>,  Up: Licenses and Acknowledgements for Incorporated Software

16.3.21 Global Unbounded Sequences (GUS)
----------------------------------------

The file ‘Python/qsbr.c’ is adapted from FreeBSD's "Global Unbounded
Sequences" safe memory reclamation scheme in subr_smr.c(1).  The file is
distributed under the 2-Clause BSD License:

     Copyright (c) 2019,2020 Jeffrey Roberson <jeff@FreeBSD.org>

     Redistribution and use in source and binary forms, with or without
     modification, are permitted provided that the following conditions
     are met:
     1. Redistributions of source code must retain the above copyright
        notice unmodified, this list of conditions, and the following
        disclaimer.
     2. Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.

     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

   ---------- Footnotes ----------

   (1) 
https://github.com/freebsd/freebsd-src/blob/main/sys/kern/subr_smr.c


File: python.info,  Node: Pythonモジュール索引,  Next: 索引,  Prev: 歴史とライセンス,  Up: Top

Pythonモジュール索引
********************

* Menu:

* __future__: 0. Future statement definitions
* __main__: 1. The environment where top-level code is run. Covers
                        command-line interfaces, import-time
                        behavior, and ''__name__ ==
                        '__main__'''.
* _thread: 2. Low-level threading API.
* _tkinter: 3. A binary module that contains the low-level interface
                        to Tcl/Tk.
* abc: 4. Abstract base classes according to :pep:'3119'.
* argparse: 5. Command-line option and argument parsing library.
* array: 6. Space efficient arrays of uniformly typed numeric
                        values.
* ast: 7. Abstract Syntax Tree classes and manipulation.
* asyncio: 8. Asynchronous I/O.
* atexit: 9. Register and execute cleanup functions.
* base64: a. RFC 4648: Base16, Base32, Base64 Data
                        Encodings; Base85 and Ascii85
* bdb: b. Debugger framework.
* binascii: c. Tools for converting between binary and various ASCII-
                        encoded binary representations.
* bisect: d. Array bisection algorithms for binary searching.
* builtins: e. The module that provides the built-in namespace.
* bz2: f. Interfaces for bzip2 compression and decompression.
* calendar: 10. Functions for working with calendars, including
                        some emulation of the Unix cal program.
* cmath: 11. Mathematical functions for complex numbers.
* cmd: 12. Build line-oriented command interpreters.
* code: 13. Facilities to implement read-eval-print loops.
* codecs: 14. Encode and decode data and streams.
* codeop: 15. Compile (possibly incomplete) Python code.
* collections: 16. Container datatypes
* collections.abc: 17. Abstract base classes for containers
* colorsys: 18. Conversion functions between RGB and other color
                        systems.
* compileall: 19. Tools for byte-compiling all Python source files in a
                        directory tree.
* concurrent.futures: 1a. Execute computations concurrently using threads or
                        processes.
* configparser: 1b. Configuration file parser.
* contextlib: 1c. Utilities for with-statement contexts.
* contextvars: 1d. Context Variables
* copy: 1e. Shallow and deep copy operations.
* copyreg: 1f. Register pickle support functions.
* cProfile: 20.
* csv: 21. Write and read tabular data to and from delimited
                        files.
* ctypes: 22. A foreign function library for Python.
* curses: 23. An interface to the curses library, providing
                        portable terminal handling.
* curses.ascii: 24. Constants and set-membership functions for ASCII
                        characters.
* curses.panel: 25. A panel stack extension that adds depth to curses
                        windows.
* curses.textpad: 26. Emacs-like input editing in a curses window.
* dataclasses: 27. Generate special methods on user-defined classes.
* datetime: 28. Basic date and time types.
* dbm: 29. Interfaces to various Unix "database" formats.
* dbm.dumb: 2a. Portable implementation of the simple DBM interface.
* dbm.gnu: 2b. GNU database manager
* dbm.ndbm: 2c. The New Database Manager
* dbm.sqlite3: 2d. SQLite backend for dbm
* decimal: 2e. Implementation of the General Decimal Arithmetic
                        Specification.
* difflib: 2f. Helpers for computing differences between objects.
* dis: 30. Disassembler for Python bytecode.
* doctest: 31. Test pieces of code within docstrings.
* email: 32. Package supporting the parsing,
                        manipulating, and generating email messages.
* email.charset: 33. Character Sets
* email.contentmanager: 34. Storing and Retrieving Content from MIME Parts
* email.encoders: 35. Encoders for email message payloads.
* email.errors: 36. The exception classes used by the email package.
* email.generator: 37. Generate flat text email messages from a message
                        structure.
* email.header: 38. Representing non-ASCII headers
* email.headerregistry: 39. Automatic Parsing of headers based on the field name
* email.iterators: 3a. Iterate over a message object tree.
* email.message: 3b. The base class representing email messages.
* email.mime: 3c. Build MIME messages.
* email.mime.application: 3d.
* email.mime.audio: 3e.
* email.mime.base: 3f.
* email.mime.image: 40.
* email.mime.message: 41.
* email.mime.multipart: 42.
* email.mime.nonmultipart: 43.
* email.mime.text: 44.
* email.parser: 45. Parse flat text email messages to produce a message
                        object structure.
* email.policy: 46. Controlling the parsing and generating of messages
* email.utils: 47. Miscellaneous email package utilities.
* encodings.idna: 48. Internationalized Domain Names implementation
* encodings.mbcs: 49. Windows ANSI codepage
* encodings.utf_8_sig: 4a. UTF-8 codec with BOM signature
* ensurepip: 4b. Bootstrapping the "pip" installer into an existing
                        Python installation or virtual environment.
* enum: 4c. Implementation of an enumeration class.
* errno: 4d. Standard errno system symbols.
* faulthandler: 4e. Dump the Python traceback.
* fcntl: 4f. The fcntl() and ioctl() system calls.
* filecmp: 50. Compare files efficiently.
* fileinput: 51. Loop over standard input or a list of files.
* fnmatch: 52. Unix shell style filename pattern matching.
* fractions: 53. Rational numbers.
* ftplib: 54. FTP protocol client (requires sockets).
* functools: 55. Higher-order functions and operations on callable
                        objects.
* gc: 56. Interface to the cycle-detecting garbage collector.
* getopt: 57. Portable parser for command line options; support both
                        short and long option names.
* getpass: 58. Portable reading of passwords and retrieval of the
                        userid.
* gettext: 59. Multilingual internationalization services.
* glob: 5a. Unix shell style pathname pattern expansion.
* graphlib: 5b. Functionality to operate with graph-like structures
* grp: 5c. The group database (getgrnam() and friends).
* gzip: 5d. Interfaces for gzip compression and decompression
                        using file objects.
* hashlib: 5e. Secure hash and message digest algorithms.
* heapq: 5f. Heap queue algorithm (a.k.a. priority queue).
* hmac: 60. Keyed-Hashing for Message Authentication (HMAC)
                        implementation
* html: 61. Helpers for manipulating HTML.
* html.entities: 62. Definitions of HTML general entities.
* html.parser: 63. A simple parser that can handle HTML and XHTML.
* http: 64. HTTP status codes and messages
* http.client: 65. HTTP and HTTPS protocol client (requires sockets).
* http.cookiejar: 66. Classes for automatic handling of HTTP cookies.
* http.cookies: 67. Support for HTTP state management (cookies).
* http.server: 68. HTTP server and request handlers.
* idlelib: 69. Implementation package for the IDLE shell/editor.
* imaplib: 6a. IMAP4 protocol client (requires sockets).
* importlib: 6b. The implementation of the import machinery.
* importlib.abc: 6c. Abstract base classes related to import
* importlib.machinery: 6d. Importers and path hooks
* importlib.metadata: 6e. Accessing package metadata
* importlib.resources: 6f. Package resource reading, opening, and
                        access
* importlib.resources.abc: 70. Abstract base classes for resources
* importlib.util: 71. Utility code for importers
* inspect: 72. Extract information and source code from live objects.
* io: 73. Core tools for working with streams.
* ipaddress: 74. IPv4/IPv6 manipulation library.
* itertools: 75. Functions creating iterators for efficient looping.
* json: 76. Encode and decode the JSON format.
* json.tool: 77. A command line to validate and pretty-print JSON.
* keyword: 78. Test whether a string is a keyword in Python.
* linecache: 79. Provides random access to individual lines from text
                        files.
* locale: 7a. Internationalization services.
* logging: 7b. Flexible event logging system for applications.
* logging.config: 7c. Configuration of the logging module.
* logging.handlers: 7d. Handlers for the logging module.
* lzma: 7e. A Python wrapper for the liblzma compression library.
* mailbox: 7f. Manipulate mailboxes in various formats
* marshal: 80. Convert Python objects to streams of bytes and back
                        (with different constraints).
* math: 81. Mathematical functions (sin() etc.).
* mimetypes: 82. Mapping of filename extensions to MIME types.
* mmap: 83. Interface to memory-mapped files for Unix and Windows.
* modulefinder: 84. Find modules used by a script.
* msvcrt: 85. Miscellaneous useful routines from the MS VC++
                        runtime.
* multiprocessing: 86. Process-based parallelism.
* multiprocessing.connection: 87. API for dealing with sockets.
* multiprocessing.dummy: 88. Dumb wrapper around threading.
* multiprocessing.managers: 89. Share data between process with shared objects.
* multiprocessing.pool: 8a. Create pools of processes.
* multiprocessing.shared_memory: 8b. Provides shared memory for direct access
                                 across processes.
* multiprocessing.sharedctypes: 8c. Allocate ctypes objects from shared memory.
* netrc: 8d. Loading of .netrc files.
* numbers: 8e. Numeric abstract base classes (Complex,
                        Real, Integral, etc.).
* operator: 8f. Functions corresponding to the standard operators.
* optparse: 90. Command-line option parsing library.
* os: 91. Miscellaneous operating system interfaces.
* os.path: 92. Operations on pathnames.
* pathlib: 93. Object-oriented filesystem paths
* pdb: 94. The Python debugger for interactive interpreters.
* pickle: 95. Convert Python objects to streams of bytes and back.
* pickletools: 96. Contains extensive comments about the pickle protocols
                        and pickle-machine opcodes, as well as some
                        useful functions.
* pkgutil: 97. Utilities for the import system.
* platform: 98. Retrieves as much platform identifying data as
                        possible.
* plistlib: 99. Generate and parse Apple plist files.
* poplib: 9a. POP3 protocol client (requires sockets).
* posix: 9b. The most common POSIX system calls (normally used via
                        module os).
* pprint: 9c. Data pretty printer.
* profile: 9d. Python source profiler.
* pstats: 9e. Statistics object for use with the profiler.
* pty: 9f. Pseudo-Terminal Handling for Unix.
* pwd: a0. The password database (getpwnam() and friends).
* py_compile: a1. Generate byte-code files from Python source files.
* pyclbr: a2. Supports information extraction for a Python module
                        browser.
* pydoc: a3. Documentation generator and online help system.
* queue: a4. A synchronized queue class.
* quopri: a5. Encode and decode files using the MIME quoted-
                        printable encoding.
* random: a6. Generate pseudo-random numbers with various common
                        distributions.
* re: a7. Regular expression operations.
* readline: a8. GNU readline support for Python.
* reprlib: a9. Alternate repr() implementation with size limits.
* resource: aa. An interface to provide resource usage information on
                        the current process.
* rlcompleter: ab. Python identifier completion, suitable for the
                        GNU readline library.
* runpy: ac. Locate and run Python modules without importing them
                        first.
* sched: ad. General purpose event scheduler.
* secrets: ae. Generate secure random numbers for managing secrets.
* select: af. Wait for I/O completion on multiple streams.
* selectors: b0. High-level I/O multiplexing.
* shelve: b1. Python object persistence.
* shlex: b2. Simple lexical analysis for Unix shell-like languages.
* shutil: b3. High-level file operations, including copying.
* signal: b4. Set handlers for asynchronous events.
* site: b5. Module responsible for site-specific configuration.
* sitecustomize: b6.
* smtplib: b7. SMTP protocol client (requires sockets).
* socket: b8. Low-level networking interface.
* socketserver: b9. A framework for network servers.
* sqlite3: ba. A DB-API 2.0 implementation using SQLite 3.x.
* ssl: bb. TLS/SSL wrapper for socket objects
* stat: bc. Utilities for interpreting the results of
                        os.stat(), os.lstat() and os.fstat().
* statistics: bd. Mathematical statistics functions
* string: be. Common string operations.
* stringprep: bf. String preparation, as per RFC 3453
* struct: c0. Interpret bytes as packed binary data.
* subprocess: c1. Subprocess management.
* symtable: c2. Interface to the compiler's internal symbol tables.
* sys: c3. Access system-specific parameters and functions.
* sys.monitoring: c4. Access and control event monitoring
* sysconfig: c5. Python's configuration information
* syslog: c6. An interface to the Unix syslog library routines.
* tabnanny: c7. Tool for detecting white space related problems in
                        Python source files in a directory tree.
* tarfile: c8. Read and write tar-format archive files.
* tempfile: c9. Generate temporary files and directories.
* termios: ca. POSIX style tty control.
* test: cb. Regression tests package containing the testing suite
                        for Python.
* test.regrtest: cc. Drives the regression test suite.
* test.support: cd. Support for Python's regression test suite.
* test.support.bytecode_helper: ce. Support tools for testing correct bytecode
                                generation.
* test.support.import_helper: cf. Support for import tests.
* test.support.os_helper: d0. Support for os tests.
* test.support.script_helper: d1. Support for Python's script execution tests.
* test.support.socket_helper: d2. Support for socket tests.
* test.support.threading_helper: d3. Support for threading tests.
* test.support.warnings_helper: d4. Support for warnings tests.
* textwrap: d5. Text wrapping and filling
* threading: d6. Thread-based parallelism.
* time: d7. Time access and conversions.
* timeit: d8. Measure the execution time of small code snippets.
* tkinter: d9. Interface to Tcl/Tk for graphical user interfaces
* tkinter.colorchooser: da. Color choosing dialog
* tkinter.commondialog: db. Tkinter base class for dialogs
* tkinter.dnd: dc. Tkinter drag-and-drop interface
* tkinter.filedialog: dd. Dialog classes for file selection
* tkinter.font: de. Tkinter font-wrapping class
* tkinter.messagebox: df. Various types of alert dialogs
* tkinter.scrolledtext: e0. Text widget with a vertical scroll bar.
* tkinter.simpledialog: e1. Simple dialog windows
* tkinter.ttk: e2. Tk themed widget set
* token: e3. Constants representing terminal nodes of the parse
                        tree.
* tokenize: e4. Lexical scanner for Python source code.
* tomllib: e5. Parse TOML files.
* trace: e6. Trace or track Python statement execution.
* traceback: e7. Print or retrieve a stack traceback.
* tracemalloc: e8. Trace memory allocations.
* tty: e9. Utility functions that perform common terminal control
                        operations.
* turtle: ea. An educational framework for simple graphics
                        applications
* turtledemo: eb. A viewer for example turtle scripts
* types: ec. Names for built-in types.
* typing: ed. Support for type hints (see :pep:'484').
* unicodedata: ee. Access the Unicode Database.
* unittest: ef. Unit testing framework for Python.
* unittest.mock: f0. Mock object library.
* urllib: f1.
* urllib.error: f2. Exception classes raised by urllib.request.
* urllib.parse: f3. Parse URLs into or assemble them from components.
* urllib.request: f4. Extensible library for opening URLs.
* urllib.response: f5. Response classes used by urllib.
* urllib.robotparser: f6. Load a robots.txt file and answer questions about
                        fetchability of other URLs.
* usercustomize: f7.
* uuid: f8. UUID objects (universally unique identifiers)
                        according to RFC 4122
* venv: f9. Creation of virtual environments.
* warnings: fa. Issue warning messages and control their disposition.
* wave: fb. Provide an interface to the WAV sound format.
* weakref: fc. Support for weak references and weak dictionaries.
* webbrowser: fd. Easy-to-use controller for web browsers.
* winreg: fe. Routines and objects for manipulating the Windows
                        registry.
* winsound: ff. Access to the sound-playing machinery for Windows.
* wsgiref: 100. WSGI Utilities and Reference Implementation.
* wsgiref.handlers: 101. WSGI server/gateway base classes.
* wsgiref.headers: 102. WSGI response header tools.
* wsgiref.simple_server: 103. A simple WSGI HTTP server.
* wsgiref.types: 104. WSGI types for static type checking
* wsgiref.util: 105. WSGI environment utilities.
* wsgiref.validate: 106. WSGI conformance checker.
* xml: 107. Package containing XML processing modules
* xml.dom: 108. Document Object Model API for Python.
* xml.dom.minidom: 109. Minimal Document Object Model (DOM) implementation.
* xml.dom.pulldom: 10a. Support for building partial DOM trees from SAX
                        events.
* xml.etree.ElementInclude: 10b.
* xml.etree.ElementTree: 10c. Implementation of the ElementTree API.
* xml.parsers.expat: 10d. An interface to the Expat non-validating XML parser.
* xml.parsers.expat.errors: 10e.
* xml.parsers.expat.model: 10f.
* xml.sax: 110. Package containing SAX2 base classes and convenience
                        functions.
* xml.sax.handler: 111. Base classes for SAX event handlers.
* xml.sax.saxutils: 112. Convenience functions and classes for use with SAX.
* xml.sax.xmlreader: 113. Interface which SAX-compliant XML parsers must
                        implement.
* xmlrpc.client: 114. XML-RPC client access.
* xmlrpc.server: 115. Basic XML-RPC server implementations.
* zipapp: 116. Manage executable Python zip archives
* zipfile: 117. Read and write ZIP-format archive files.
* zipimport: 118. Support for importing Python modules from ZIP
                        archives.
* zlib: 119. Low-level interface to compression and decompression
                        routines compatible with gzip.
* zoneinfo: 11a. IANA time zone support


File: python.info,  Node: 索引,  Prev: Pythonモジュール索引,  Up: Top

索引
****

[index]
* Menu:

* _ (下線);gettext:                      GNU gettext API.    (line   33)
* _ (下線);in numeric literal:           数値リテラル.       (line   13)
* _ (下線);in numeric literal <1>:       整数リテラル.       (line   39)
* _ (下線);文字列のフォーマットで:       書式指定ミニ言語仕様.
                                                             (line  109)
* __, identifiers:                       ソフトキーワード.   (line   21)
* __abs__() (object のメソッド):         数値型をエミュレートする.
                                                             (line  108)
* __abs__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line   70)
* __add__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   11)
* __add__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line   75)
* __aenter__() (object のメソッド):      非同期コンテキストマネージャ Asynchronous Context Manager.
                                                             (line   13)
* __aexit__() (object のメソッド):       非同期コンテキストマネージャ Asynchronous Context Manager.
                                                             (line   18)
* __aiter__() (object のメソッド):       非同期イテレータ Asynchronous Iterator.
                                                             (line   13)
* __all__:                               パッケージから * を import する.
                                                             (line    6)
* __all__ (package variable):            モジュールのインポート<2>.
                                                             (line    8)
* __all__ (オプションの module 属性):    import 文.          (line   85)
* __and__() (enum.Flag のメソッド):      データ型<2>.        (line  470)
* __and__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   11)
* __and__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line   80)
* __anext__() (agen のメソッド):         非同期ジェネレータイテレータメソッド.
                                                             (line    9)
* __anext__() (object のメソッド):       非同期イテレータ Asynchronous Iterator.
                                                             (line   17)
* __annotations__ (class attribute):     Special attributes. (line    6)
* __annotations__ (function の属性):     Special writable attributes.
                                                             (line   45)
* __annotations__ (module attribute):    モジュール<3>.      (line   21)
* __annotations__ (module の属性):       Other writable attributes on module objects.
                                                             (line   14)
* __annotations__ (type の属性):         Special attributes. (line   36)
* __annotations__ (関数属性):            Special writable attributes.
                                                             (line    6)
* __args__ (genericalias の属性):        GenericAlias オブジェクトの特別な属性.
                                                             (line   17)
* __await__() (object のメソッド):       待機可能オブジェクト Awaitable Object.
                                                             (line   15)
* __bases__ (type の属性):               Special attributes. (line   26)
* __bases__ (クラス属性):                Special attributes. (line    6)
* __bool__() (object のメソッド):        基本的なカスタマイズ.
                                                             (line  317)
* __bool__() (オブジェクトメソッド):     コンテナをエミュレートする.
                                                             (line   41)
* __bound__ (typing.TypeVar の属性):     Building generic types and type aliases.
                                                             (line  175)
* __breakpointhook__ (sys モジュール):   sys --- システム固有のパラメーターと関数.
                                                             (line  409)
* __buffer__() (object のメソッド):      Emulating buffer types.
                                                             (line   15)
* __bytes__() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  129)
* __bytes__() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  139)
* __bytes__() (object のメソッド):       基本的なカスタマイズ.
                                                             (line  142)
* __cached__ (module attribute):         モジュール<3>.      (line   21)
* __cached__ (module の属性):            Import-related attributes on module objects.
                                                             (line  137)
* __call__() (argparse.Action のメソッド): Action クラス.    (line   28)
* __call__() (email.headerregistry.HeaderRegistry のメソッド): email headerregistry Custom Header Objects.
                                                             (line  384)
* __call__() (enum.EnumType のメソッド): データ型<2>.        (line   17)
* __call__() (object のメソッド):        呼び出し可能オブジェクトをエミュレートする.
                                                             (line    6)
* __call__() (operator モジュール):      operator --- 関数形式の標準演算子.
                                                             (line  215)
* __call__() (weakref.finalize のメソッド): weakref --- 弱参照.
                                                             (line  285)
* __call__() (オブジェクトメソッド):     呼び出し call.      (line  155)
* __callback__ (weakref.ref の属性):     weakref --- 弱参照. (line  119)
* __cause__ (BaseException の属性):      例外コンテキスト.   (line    9)
* __cause__ (exception の属性):          raise 文.           (line   30)
* __cause__ (exception の属性) <1>:      例外コンテキスト.   (line    6)
* __cause__ (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   44)
* __ceil__() (fractions.Fraction のメソッド): fractions --- 有理数.
                                                             (line  182)
* __ceil__() (object のメソッド):        数値型をエミュレートする.
                                                             (line  138)
* __class__ (method cell):               クラスオブジェクトの作成.
                                                             (line    6)
* __class__ (module attribute):          モジュールの属性値アクセスをカスタマイズする.
                                                             (line    6)
* __class__ (object の属性):             Special attributes<2>.
                                                             (line    6)
* __class__ (unittest.mock.Mock の属性): Mock クラス.        (line  533)
* __class__ (インスタンス属性):          Special attributes<2>.
                                                             (line    6)
* __class_getitem__() (object のクラスメソッド): ジェネリック型をエミュレートする.
                                                             (line   32)
* __classcell__ (class namespace entry): クラスオブジェクトの作成.
                                                             (line    6)
* __closure__ (function の属性):         Special read-only attributes.
                                                             (line   16)
* __closure__ (関数属性):                Special read-only attributes.
                                                             (line    6)
* __code__ (function の属性):            Special writable attributes.
                                                             (line   36)
* __code__ (関数オブジェクトの属性):     コードオブジェクト<2>.
                                                             (line    6)
* __code__ (関数属性):                   Special writable attributes.
                                                             (line    6)
* __complex__() (object のメソッド):     数値型をエミュレートする.
                                                             (line  116)
* __concat__() (operator モジュール):    operator --- 関数形式の標準演算子.
                                                             (line  171)
* __constraints__ (typing.TypeVar の属性): Building generic types and type aliases.
                                                             (line  184)
* __contains__() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  179)
* __contains__() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  299)
* __contains__() (enum.EnumType のメソッド): データ型<2>.    (line   61)
* __contains__() (enum.Flag のメソッド): データ型<2>.        (line  407)
* __contains__() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  199)
* __contains__() (object のメソッド):    コンテナをエミュレートする.
                                                             (line  149)
* __contains__() (operator モジュール):  operator --- 関数形式の標準演算子.
                                                             (line  176)
* __context__ (BaseException の属性):    例外コンテキスト.   (line    9)
* __context__ (exception の属性):        raise 文.           (line   30)
* __context__ (exception の属性) <1>:    例外コンテキスト.   (line    6)
* __context__ (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   48)
* __contravariant__ (typing.TypeVar の属性): Building generic types and type aliases.
                                                             (line  163)
* __copy__() (コピープロトコル):         copy --- 浅いコピーおよび深いコピー操作.
                                                             (line   82)
* __covariant__ (typing.TypeVar の属性): Building generic types and type aliases.
                                                             (line  159)
* __debug__:                             assert 文.          (line   22)
* __debug__ (組み込み変数):              組み込み定数.       (line   62)
* __deepcopy__() (コピープロトコル):     copy --- 浅いコピーおよび深いコピー操作.
                                                             (line   82)
* __default__ (typing.ParamSpec の属性): Building generic types and type aliases.
                                                             (line  427)
* __default__ (typing.TypeVar の属性):   Building generic types and type aliases.
                                                             (line  194)
* __default__ (typing.TypeVarTuple の属性): Building generic types and type aliases.
                                                             (line  326)
* __defaults__ (function の属性):        Special writable attributes.
                                                             (line   30)
* __defaults__ (関数属性):               Special writable attributes.
                                                             (line    6)
* __del__() (io.IOBase のメソッド):      I/O 基底クラス.     (line  164)
* __del__() (object のメソッド):         基本的なカスタマイズ.
                                                             (line   51)
* __delattr__() (object のメソッド):     属性値アクセスをカスタマイズする.
                                                             (line   69)
* __delete__() (object のメソッド):      デスクリプタ descriptor の実装.
                                                             (line   42)
* __delitem__() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  226)
* __delitem__() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  334)
* __delitem__() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line   76)
* __delitem__() (mailbox.MH のメソッド): MH オブジェクト.    (line   81)
* __delitem__() (object のメソッド):     コンテナをエミュレートする.
                                                             (line  108)
* __delitem__() (operator モジュール):   operator --- 関数形式の標準演算子.
                                                             (line  186)
* __dict__ (function の属性):            Special writable attributes.
                                                             (line   40)
* __dict__ (module の属性):              Module dictionaries.
                                                             (line    8)
* __dict__ (object の属性):              Special attributes<2>.
                                                             (line   10)
* __dict__ (type の属性):                Special attributes. (line   21)
* __dict__ (インスタンス属性):           Special attributes<2>.
                                                             (line    6)
* __dict__ (クラス属性):                 Special attributes. (line    6)
* __dict__ (モジュール属性):             Module dictionaries.
                                                             (line    8)
* __dict__ (モジュール属性) <1>:         モジュールオブジェクト module object.
                                                             (line   46)
* __dict__ (関数属性):                   Special writable attributes.
                                                             (line    6)
* __dir__ (module attribute):            モジュールの属性値アクセスをカスタマイズする.
                                                             (line    6)
* __dir__() (enum.Enum のメソッド):      データ型<2>.        (line  186)
* __dir__() (enum.EnumType のメソッド):  データ型<2>.        (line   74)
* __dir__() (object のメソッド):         属性値アクセスをカスタマイズする.
                                                             (line   79)
* __dir__() (unittest.mock.Mock のメソッド): Mock クラス.    (line  276)
* __displayhook__ (sys モジュール):      sys --- システム固有のパラメーターと関数.
                                                             (line  409)
* __divmod__() (object のメソッド):      数値型をエミュレートする.
                                                             (line   11)
* __doc__ (definition の属性):           特殊属性.           (line   26)
* __doc__ (function の属性):             Special writable attributes.
                                                             (line   12)
* __doc__ (method の属性):               インスタンスメソッド.
                                                             (line   18)
* __doc__ (module の属性):               Other writable attributes on module objects.
                                                             (line    9)
* __doc__ (type の属性):                 Special attributes. (line   32)
* __doc__ (クラス属性):                  Special attributes. (line    6)
* __doc__ (メソッド属性):                インスタンスメソッド.
                                                             (line    9)
* __doc__ (モジュール属性):              モジュール<3>.      (line   21)
* __doc__ (モジュール属性) <1>:          モジュールオブジェクト module object.
                                                             (line   25)
* __doc__ (関数属性):                    Special writable attributes.
                                                             (line    6)
* __enter__() (contextmanager のメソッド): コンテキストマネージャ型.
                                                             (line   11)
* __enter__() (object のメソッド):       with文とコンテキストマネージャ.
                                                             (line   21)
* __enter__() (winreg.PyHKEY のメソッド): レジストリハンドルオブジェクト.
                                                             (line   57)
* __eq__() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line  156)
* __eq__() (email.header.Header のメソッド): email header 国際化されたヘッダー.
                                                             (line  163)
* __eq__() (memoryview のメソッド):      メモリビュー.       (line  111)
* __eq__() (object のメソッド):          基本的なカスタマイズ.
                                                             (line  175)
* __eq__() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   23)
* __eq__() (インスタンスメソッド):       比較<2>.            (line   49)
* __excepthook__ (sys モジュール):       sys --- システム固有のパラメーターと関数.
                                                             (line  409)
* __excepthook__ (threading モジュール): threading --- スレッドベースの並列処理.
                                                             (line  107)
* __exit__() (contextmanager のメソッド): コンテキストマネージャ型.
                                                             (line   30)
* __exit__() (object のメソッド):        with文とコンテキストマネージャ.
                                                             (line   27)
* __exit__() (winreg.PyHKEY のメソッド): レジストリハンドルオブジェクト.
                                                             (line   57)
* __file__ (module の属性):              Import-related attributes on module objects.
                                                             (line  135)
* __file__ (モジュール属性):             モジュール<3>.      (line   21)
* __file__ (モジュール属性) <1>:         モジュールオブジェクト module object.
                                                             (line   25)
* __file__ (モジュール属性) <2>:         モジュールオブジェクト module object.
                                                             (line   88)
* __firstlineno__ (class attribute):     Special attributes. (line    6)
* __firstlineno__ (type の属性):         Special attributes. (line   65)
* __float__() (object のメソッド):       数値型をエミュレートする.
                                                             (line  116)
* __floor__() (fractions.Fraction のメソッド): fractions --- 有理数.
                                                             (line  173)
* __floor__() (object のメソッド):       数値型をエミュレートする.
                                                             (line  138)
* __floordiv__() (object のメソッド):    数値型をエミュレートする.
                                                             (line   11)
* __floordiv__() (operator モジュール):  operator --- 関数形式の標準演算子.
                                                             (line   85)
* __format__:                            組み込み関数.       (line  767)
* __format__() (datetime.date のメソッド): date オブジェクト.
                                                             (line  300)
* __format__() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  757)
* __format__() (datetime.time のメソッド): time オブジェクト.
                                                             (line  223)
* __format__() (enum.Enum のメソッド):   データ型<2>.        (line  326)
* __format__() (fractions.Fraction のメソッド): fractions --- 有理数.
                                                             (line  197)
* __format__() (ipaddress.IPv4Address のメソッド): Address オブジェクト.
                                                             (line  181)
* __format__() (ipaddress.IPv6Address のメソッド): Address オブジェクト.
                                                             (line  311)
* __format__() (object のメソッド):      基本的なカスタマイズ.
                                                             (line  149)
* __fspath__() (os.PathLike のメソッド): プロセスのパラメーター.
                                                             (line  127)
* __func__ (method の属性):              インスタンスメソッド.
                                                             (line   15)
* __func__ (メソッド属性):               インスタンスメソッド.
                                                             (line    9)
* __future__:                            用語集<2>.          (line  577)
* __future__;future statement:           future 文 future statement.
                                                             (line    6)
* __ge__() (object のメソッド):          基本的なカスタマイズ.
                                                             (line  175)
* __ge__() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   23)
* __ge__() (インスタンスメソッド):       比較<2>.            (line   49)
* __get__() (object のメソッド):         デスクリプタ descriptor の実装.
                                                             (line   15)
* __getattr__ (module attribute):        モジュールの属性値アクセスをカスタマイズする.
                                                             (line    6)
* __getattr__() (object のメソッド):     属性値アクセスをカスタマイズする.
                                                             (line   10)
* __getattribute__() (object のメソッド): 属性値アクセスをカスタマイズする.
                                                             (line   33)
* __getitem__() (email.headerregistry.HeaderRegistry のメソッド): email headerregistry Custom Header Objects.
                                                             (line  379)
* __getitem__() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  189)
* __getitem__() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  309)
* __getitem__() (enum.EnumType のメソッド): データ型<2>.     (line   82)
* __getitem__() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  146)
* __getitem__() (object のメソッド):     コンテナをエミュレートする.
                                                             (line   77)
* __getitem__() (operator モジュール):   operator --- 関数形式の標準演算子.
                                                             (line  191)
* __getitem__() (re.Match のメソッド):   マッチオブジェクト. (line   85)
* __getitem__() (マップオブジェクトのメソッド): 特殊メソッド名.
                                                             (line    6)
* __getnewargs__() (object のメソッド):  クラスインスタンスの pickle 化.
                                                             (line   44)
* __getnewargs_ex__() (object のメソッド): クラスインスタンスの pickle 化.
                                                             (line   28)
* __getstate__() (copy プロトコル):      状態を持つオブジェクトの扱い.
                                                             (line    6)
* __getstate__() (object のメソッド):    クラスインスタンスの pickle 化.
                                                             (line   58)
* __globals__ (function の属性):         Special read-only attributes.
                                                             (line   10)
* __globals__ (関数属性):                Special read-only attributes.
                                                             (line    6)
* __gt__() (object のメソッド):          基本的なカスタマイズ.
                                                             (line  175)
* __gt__() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   23)
* __gt__() (インスタンスメソッド):       比較<2>.            (line   49)
* __hash__() (object のメソッド):        基本的なカスタマイズ.
                                                             (line  236)
* __iadd__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   77)
* __iadd__() (operator モジュール):      インプレース in-place 演算子.
                                                             (line   34)
* __iand__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   77)
* __iand__() (operator モジュール):      インプレース in-place 演算子.
                                                             (line   39)
* __iconcat__() (operator モジュール):   インプレース in-place 演算子.
                                                             (line   44)
* __ifloordiv__() (object のメソッド):   数値型をエミュレートする.
                                                             (line   77)
* __ifloordiv__() (operator モジュール): インプレース in-place 演算子.
                                                             (line   50)
* __ilshift__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   77)
* __ilshift__() (operator モジュール):   インプレース in-place 演算子.
                                                             (line   55)
* __imatmul__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   77)
* __imatmul__() (operator モジュール):   インプレース in-place 演算子.
                                                             (line   70)
* __imod__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   77)
* __imod__() (operator モジュール):      インプレース in-place 演算子.
                                                             (line   60)
* __import__() (importlib モジュール):   関数<12>.           (line    6)
* __imul__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   77)
* __imul__() (operator モジュール):      インプレース in-place 演算子.
                                                             (line   65)
* __index__() (object のメソッド):       数値型をエミュレートする.
                                                             (line  124)
* __index__() (operator モジュール):     operator --- 関数形式の標準演算子.
                                                             (line   90)
* __infer_variance__ (typing.TypeVar の属性): Building generic types and type aliases.
                                                             (line  168)
* __init__() (asyncio.Future のメソッド): Future and Task private constructors.
                                                             (line   17)
* __init__() (asyncio.Task のメソッド):  Future and Task private constructors.
                                                             (line   23)
* __init__() (difflib.HtmlDiff のメソッド): difflib --- 差分の計算の補助.
                                                             (line   89)
* __init__() (enum.Enum のメソッド):     データ型<2>.        (line  236)
* __init__() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   14)
* __init__() (logging.logging.Formatter のメソッド): フォーマッタ.
                                                             (line   14)
* __init__() (object のメソッド):        基本的なカスタマイズ.
                                                             (line   35)
* __init_subclass__() (enum.Enum のメソッド): データ型<2>.   (line  248)
* __init_subclass__() (object のクラスメソッド): クラス生成をカスタマイズする.
                                                             (line   13)
* __instancecheck__() (type のメソッド): インスタンスのカスタマイズとサブクラスチェック.
                                                             (line   14)
* __int__() (object のメソッド):         数値型をエミュレートする.
                                                             (line  116)
* __interactivehook__ (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line 1145)
* __inv__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line   98)
* __invert__() (object のメソッド):      数値型をエミュレートする.
                                                             (line  108)
* __invert__() (operator モジュール):    operator --- 関数形式の標準演算子.
                                                             (line   98)
* __ior__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   77)
* __ior__() (operator モジュール):       インプレース in-place 演算子.
                                                             (line   77)
* __ipow__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   77)
* __ipow__() (operator モジュール):      インプレース in-place 演算子.
                                                             (line   82)
* __irshift__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   77)
* __irshift__() (operator モジュール):   インプレース in-place 演算子.
                                                             (line   87)
* __isub__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   77)
* __isub__() (operator モジュール):      インプレース in-place 演算子.
                                                             (line   92)
* __iter__() (container のメソッド):     イテレータ型.       (line   14)
* __iter__() (enum.EnumType のメソッド): データ型<2>.        (line   90)
* __iter__() (iterator のメソッド):      イテレータ型.       (line   29)
* __iter__() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  115)
* __iter__() (object のメソッド):        コンテナをエミュレートする.
                                                             (line  123)
* __iter__() (unittest.TestSuite のメソッド): テストのグループ化.
                                                             (line   59)
* __itruediv__() (object のメソッド):    数値型をエミュレートする.
                                                             (line   77)
* __itruediv__() (operator モジュール):  インプレース in-place 演算子.
                                                             (line   97)
* __ixor__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   77)
* __ixor__() (operator モジュール):      インプレース in-place 演算子.
                                                             (line  102)
* __kwdefaults__ (function の属性):      Special writable attributes.
                                                             (line   52)
* __kwdefaults__ (関数属性):             Special writable attributes.
                                                             (line    6)
* __le__() (object のメソッド):          基本的なカスタマイズ.
                                                             (line  175)
* __le__() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   23)
* __le__() (インスタンスメソッド):       比較<2>.            (line   49)
* __len__() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  175)
* __len__() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  295)
* __len__() (enum.EnumType のメソッド):  データ型<2>.        (line   97)
* __len__() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  204)
* __len__() (object のメソッド):         コンテナをエミュレートする.
                                                             (line   39)
* __len__() (マップオブジェクトのメソッド): 基本的なカスタマイズ.
                                                             (line  319)
* __length_hint__() (object のメソッド): コンテナをエミュレートする.
                                                             (line   54)
* __loader__ (module attribute):         モジュール<3>.      (line   21)
* __loader__ (module attribute) <1>:     モジュールオブジェクト module object.
                                                             (line   25)
* __loader__ (module の属性):            Import-related attributes on module objects.
                                                             (line   97)
* __lshift__() (object のメソッド):      数値型をエミュレートする.
                                                             (line   11)
* __lshift__() (operator モジュール):    operator --- 関数形式の標準演算子.
                                                             (line  105)
* __lt__() (object のメソッド):          基本的なカスタマイズ.
                                                             (line  175)
* __lt__() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   23)
* __lt__() (インスタンスメソッド):       比較<2>.            (line   49)
* __matmul__() (object のメソッド):      数値型をエミュレートする.
                                                             (line   11)
* __matmul__() (operator モジュール):    operator --- 関数形式の標準演算子.
                                                             (line  120)
* __members__ (enum.EnumType の属性):    データ型<2>.        (line  104)
* __missing__():                         マッピング型 --- dict.
                                                             (line   87)
* __missing__() (collections.defaultdict のメソッド): defaultdict オブジェクト.
                                                             (line   21)
* __missing__() (object のメソッド):     コンテナをエミュレートする.
                                                             (line  117)
* __mod__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   11)
* __mod__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  110)
* __module__ (definition の属性):        特殊属性.           (line   22)
* __module__ (function の属性):          Special writable attributes.
                                                             (line   26)
* __module__ (method の属性):            インスタンスメソッド.
                                                             (line   28)
* __module__ (type の属性):              Special attributes. (line   18)
* __module__ (typing.NewType の属性):    Other special directives.
                                                             (line  113)
* __module__ (typing.TypeAliasType の属性): Building generic types and type aliases.
                                                             (line  513)
* __module__ (クラス属性):               Special attributes. (line    6)
* __module__ (メソッド属性):             インスタンスメソッド.
                                                             (line    9)
* __module__ (関数属性):                 Special writable attributes.
                                                             (line    6)
* __mro__ (type の属性):                 Special attributes. (line   73)
* __mro_entries__() (object のメソッド): MRO エントリの解決. (line    6)
* __mul__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   11)
* __mul__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  115)
* __mutable_keys__ (typing.TypedDict の属性): Other special directives.
                                                             (line  443)
* __name__ (definition の属性):          特殊属性.           (line   10)
* __name__ (function の属性):            Special writable attributes.
                                                             (line   16)
* __name__ (method の属性):              インスタンスメソッド.
                                                             (line   24)
* __name__ (module の属性):              Import-related attributes on module objects.
                                                             (line   36)
* __name__ (property の属性):            組み込み関数.       (line 1660)
* __name__ (type の属性):                Special attributes. (line   10)
* __name__ (typing.NewType の属性):      Other special directives.
                                                             (line  117)
* __name__ (typing.ParamSpec の属性):    Building generic types and type aliases.
                                                             (line  423)
* __name__ (typing.TypeAliasType の属性): Building generic types and type aliases.
                                                             (line  505)
* __name__ (typing.TypeVar の属性):      Building generic types and type aliases.
                                                             (line  155)
* __name__ (typing.TypeVarTuple の属性): Building generic types and type aliases.
                                                             (line  322)
* __name__ (クラス属性):                 Special attributes. (line    6)
* __name__ (メソッド属性):               インスタンスメソッド.
                                                             (line    9)
* __name__ (モジュール属性):             モジュール<3>.      (line   21)
* __name__ (モジュール属性) <1>:         モジュールオブジェクト module object.
                                                             (line   25)
* __name__ (モジュール属性) <2>:         モジュールオブジェクト module object.
                                                             (line   61)
* __name__ (関数属性):                   Special writable attributes.
                                                             (line    6)
* __ne__() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line  161)
* __ne__() (email.header.Header のメソッド): email header 国際化されたヘッダー.
                                                             (line  168)
* __ne__() (object のメソッド):          基本的なカスタマイズ.
                                                             (line  175)
* __ne__() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   23)
* __ne__() (インスタンスメソッド):       比較<2>.            (line   49)
* __neg__() (object のメソッド):         数値型をエミュレートする.
                                                             (line  108)
* __neg__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  127)
* __new__() (enum.Enum のメソッド):      データ型<2>.        (line  276)
* __new__() (object のメソッド):         基本的なカスタマイズ.
                                                             (line    6)
* __next__() (csv.csvreader のメソッド): reader オブジェクト.
                                                             (line   10)
* __next__() (generator のメソッド):     ジェネレータ-イテレータメソッド.
                                                             (line   12)
* __next__() (iterator のメソッド):      イテレータ型.       (line   37)
* __not__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line   46)
* __notes__ (BaseException の属性):      基底クラス.         (line   56)
* __notes__ (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   66)
* __objclass__ (object の属性):          デスクリプタ descriptor の実装.
                                                             (line   50)
* __optional_keys__ (typing.TypedDict の属性): Other special directives.
                                                             (line  394)
* __or__() (enum.Flag のメソッド):       データ型<2>.        (line  463)
* __or__() (object のメソッド):          数値型をエミュレートする.
                                                             (line   11)
* __or__() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line  132)
* __origin__ (genericalias の属性):      GenericAlias オブジェクトの特別な属性.
                                                             (line    9)
* __package__ (module attribute):        モジュール<3>.      (line   21)
* __package__ (module attribute) <1>:    モジュールオブジェクト module object.
                                                             (line   25)
* __package__ (module の属性):           Import-related attributes on module objects.
                                                             (line   54)
* __parameters__ (genericalias の属性):  GenericAlias オブジェクトの特別な属性.
                                                             (line   25)
* __path__ (module attribute):           モジュール<3>.      (line   21)
* __path__ (module の属性):              Import-related attributes on module objects.
                                                             (line  124)
* __pos__() (object のメソッド):         数値型をエミュレートする.
                                                             (line  108)
* __pos__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  137)
* __post_init__() (dataclasses モジュール): 初期化後の処理.  (line    6)
* __pow__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   11)
* __pow__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  142)
* __prepare__ (metaclass method):        クラスの名前空間の準備.
                                                             (line    6)
* __PYVENV_LAUNCHER__:                   PyConfig.           (line  186)
* __PYVENV_LAUNCHER__ <1>:               PyConfig.           (line  705)
* __qualname__ (definition の属性):      特殊属性.           (line   15)
* __qualname__ (function の属性):        Special writable attributes.
                                                             (line   20)
* __qualname__ (type の属性):            Special attributes. (line   14)
* __radd__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   41)
* __rand__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   41)
* __rdivmod__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   41)
* __readonly_keys__ (typing.TypedDict の属性): Other special directives.
                                                             (line  435)
* __reduce__() (object のメソッド):      クラスインスタンスの pickle 化.
                                                             (line  123)
* __reduce_ex__() (object のメソッド):   クラスインスタンスの pickle 化.
                                                             (line  179)
* __release_buffer__() (object のメソッド): Emulating buffer types.
                                                             (line   25)
* __replace__() (replace protocol):      copy --- 浅いコピーおよび深いコピー操作.
                                                             (line  100)
* __repr__() (enum.Enum のメソッド):     データ型<2>.        (line  293)
* __repr__() (multiprocessing.managers.BaseProxy のメソッド): Proxy オブジェクト.
                                                             (line  141)
* __repr__() (netrc.netrc のメソッド):   netrc オブジェクト. (line   16)
* __repr__() (object のメソッド):        基本的なカスタマイズ.
                                                             (line  112)
* __required_keys__ (typing.TypedDict の属性): Other special directives.
                                                             (line  390)
* __reversed__() (enum.EnumType のメソッド): データ型<2>.    (line  109)
* __reversed__() (object のメソッド):    コンテナをエミュレートする.
                                                             (line  131)
* __rfloordiv__() (object のメソッド):   数値型をエミュレートする.
                                                             (line   41)
* __rlshift__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   41)
* __rmatmul__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   41)
* __rmod__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   41)
* __rmul__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   41)
* __ror__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   41)
* __round__() (fractions.Fraction のメソッド): fractions --- 有理数.
                                                             (line  187)
* __round__() (object のメソッド):       数値型をエミュレートする.
                                                             (line  138)
* __rpow__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   41)
* __rrshift__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   41)
* __rshift__() (object のメソッド):      数値型をエミュレートする.
                                                             (line   11)
* __rshift__() (operator モジュール):    operator --- 関数形式の標準演算子.
                                                             (line  147)
* __rsub__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   41)
* __rtruediv__() (object のメソッド):    数値型をエミュレートする.
                                                             (line   41)
* __rxor__() (object のメソッド):        数値型をエミュレートする.
                                                             (line   41)
* __self__ (method の属性):              インスタンスメソッド.
                                                             (line   11)
* __self__ (メソッド属性):               インスタンスメソッド.
                                                             (line    9)
* __set__() (object のメソッド):         デスクリプタ descriptor の実装.
                                                             (line   33)
* __set_name__() (object のメソッド):    クラス生成をカスタマイズする.
                                                             (line   47)
* __setattr__() (object のメソッド):     属性値アクセスをカスタマイズする.
                                                             (line   55)
* __setitem__() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  204)
* __setitem__() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  320)
* __setitem__() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line   90)
* __setitem__() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  191)
* __setitem__() (object のメソッド):     コンテナをエミュレートする.
                                                             (line   98)
* __setitem__() (operator モジュール):   operator --- 関数形式の標準演算子.
                                                             (line  200)
* __setstate__() (copy プロトコル):      状態を持つオブジェクトの扱い.
                                                             (line    6)
* __setstate__() (object のメソッド):    クラスインスタンスの pickle 化.
                                                             (line   85)
* __slots__:                             用語集<2>.          (line 1283)
* __spec__ (module attribute):           モジュール<3>.      (line   21)
* __spec__ (module の属性):              Import-related attributes on module objects.
                                                             (line   45)
* __static_attributes__ (class attribute): Special attributes.
                                                             (line    6)
* __static_attributes__ (type の属性):   Special attributes. (line   58)
* __stderr__ (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1836)
* __stdin__ (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line 1836)
* __stdout__ (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1836)
* __str__() (datetime.date のメソッド):  date オブジェクト.  (line  273)
* __str__() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  727)
* __str__() (datetime.time のメソッド):  time オブジェクト.  (line  213)
* __str__() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line  151)
* __str__() (email.header.Header のメソッド): email header 国際化されたヘッダー.
                                                             (line  152)
* __str__() (email.headerregistry.Address のメソッド): email headerregistry Custom Header Objects.
                                                             (line  440)
* __str__() (email.headerregistry.Group のメソッド): email headerregistry Custom Header Objects.
                                                             (line  475)
* __str__() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line   95)
* __str__() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  102)
* __str__() (enum.Enum のメソッド):      データ型<2>.        (line  310)
* __str__() (multiprocessing.managers.BaseProxy のメソッド): Proxy オブジェクト.
                                                             (line  145)
* __str__() (object のメソッド):         基本的なカスタマイズ.
                                                             (line  128)
* __sub__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   11)
* __sub__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  152)
* __subclasscheck__() (type のメソッド): インスタンスのカスタマイズとサブクラスチェック.
                                                             (line   20)
* __subclasses__() (type のメソッド):    Special methods.    (line   15)
* __subclasshook__() (abc.ABCMeta のメソッド): abc --- 抽象基底クラス.
                                                             (line   91)
* __supertype__ (typing.NewType の属性): Other special directives.
                                                             (line  121)
* __suppress_context__ (BaseException の属性): 例外コンテキスト.
                                                             (line    9)
* __suppress_context__ (exception の属性): 例外コンテキスト. (line    6)
* __suppress_context__ (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   61)
* __total__ (typing.TypedDict の属性):   Other special directives.
                                                             (line  365)
* __traceback__ (BaseException の属性):  基底クラス.         (line   42)
* __traceback__ (exception の属性):      raise 文.           (line    6)
* __truediv__() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  533)
* __truediv__() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  136)
* __truediv__() (object のメソッド):     数値型をエミュレートする.
                                                             (line   11)
* __truediv__() (operator モジュール):   operator --- 関数形式の標準演算子.
                                                             (line  157)
* __trunc__() (object のメソッド):       数値型をエミュレートする.
                                                             (line  138)
* __type_params__ (class attribute):     Special attributes. (line    6)
* __type_params__ (definition の属性):   特殊属性.           (line   31)
* __type_params__ (function attribute):  Special writable attributes.
                                                             (line    6)
* __type_params__ (function の属性):     Special writable attributes.
                                                             (line   56)
* __type_params__ (type の属性):         Special attributes. (line   51)
* __type_params__ (typing.TypeAliasType の属性): Building generic types and type aliases.
                                                             (line  521)
* __unpacked__ (genericalias の属性):    GenericAlias オブジェクトの特別な属性.
                                                             (line   41)
* __unraisablehook__ (sys モジュール):   sys --- システム固有のパラメーターと関数.
                                                             (line  409)
* __value__ (typing.TypeAliasType の属性): Building generic types and type aliases.
                                                             (line  533)
* __version__ (curses モジュール):       定数<6>.            (line   20)
* __xor__() (enum.Flag のメソッド):      データ型<2>.        (line  479)
* __xor__() (object のメソッド):         数値型をエミュレートする.
                                                             (line   11)
* __xor__() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  163)
* _, identifiers:                        ソフトキーワード.   (line   22)
* _add_alias_() (enum.EnumType のメソッド): データ型<2>.     (line  116)
* _add_value_alias_() (enum.EnumType のメソッド): データ型<2>.
                                                             (line  122)
* _align_ (ctypes.Structure の属性):     構造化データ型.     (line   92)
* _anonymous_ (ctypes.Structure の属性): 構造化データ型.     (line  101)
* _asdict() (collections.somenamedtuple のメソッド): namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
                                                             (line  109)
* _b_base_ (ctypes._CData の属性):       データ型<3>.        (line   74)
* _b_needsfree_ (ctypes._CData の属性):  データ型<3>.        (line   81)
* _callmethod() (multiprocessing.managers.BaseProxy のメソッド): Proxy オブジェクト.
                                                             (line   96)
* _CData (ctypes のクラス):              データ型<3>.        (line    6)
* _CFuncPtr (ctypes のクラス):           外部関数.           (line   22)
* _clear_internal_caches() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  185)
* _clear_type_cache() (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line  174)
* _current_exceptions() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  212)
* _current_frames() (sys モジュール):    sys --- システム固有のパラメーターと関数.
                                                             (line  193)
* _debugmallocstats() (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line  268)
* _emscripten_info (sys モジュール):     sys --- システム固有のパラメーターと関数.
                                                             (line  333)
* _enablelegacywindowsfsencoding() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line 1744)
* _enter_task() (asyncio モジュール):    Task lifetime support.
                                                             (line   22)
* _exit() (os モジュール):               プロセス管理.       (line  124)
* _Feature (__future__ のクラス):        モジュールコンテンツ<5>.
                                                             (line   44)
* _field_defaults (collections.somenamedtuple の属性): namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
                                                             (line  159)
* _field_types (ast.AST の属性):         Node クラス.        (line   38)
* _fields (ast.AST の属性):              Node クラス.        (line   21)
* _fields (collections.somenamedtuple の属性): namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
                                                             (line  145)
* _fields_ (ctypes.Structure の属性):    構造化データ型.     (line   48)
* _flush() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  117)
* _frozen (C struct):                    モジュールのインポート<2>.
                                                             (line  271)
* _generate_next_value_() (enum.Enum のメソッド): データ型<2>.
                                                             (line  207)
* _get_child_mock() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  285)
* _get_preferred_schemes() (sysconfig モジュール): Installation path functions.
                                                             (line   41)
* _getframe() (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line  863)
* _getframemodulename() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  878)
* _getvalue() (multiprocessing.managers.BaseProxy のメソッド): Proxy オブジェクト.
                                                             (line  135)
* _handle (ctypes.PyDLL の属性):         共有ライブラリをロードする.
                                                             (line  150)
* _ignore_ (enum.Enum の属性):           データ型<2>.        (line  177)
* _incompatible_extension_module_restrictions() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line  172)
* _inittab (C struct):                   モジュールのインポート<2>.
                                                             (line  308)
* _inittab.initfunc (C member):          モジュールのインポート<2>.
                                                             (line  320)
* _inittab.name (C member):              モジュールのインポート<2>.
                                                             (line  316)
* _is_gil_enabled() (sys モジュール):    sys --- システム固有のパラメーターと関数.
                                                             (line 1174)
* _is_interned() (sys モジュール):       sys --- システム固有のパラメーターと関数.
                                                             (line 1203)
* _leave_task() (asyncio モジュール):    Task lifetime support.
                                                             (line   30)
* _length_ (ctypes.Array の属性):        配列とポインタ.     (line   18)
* _log (logging.LoggerAdapter の属性):   LoggerAdapter オブジェクト.
                                                             (line   34)
* _make() (collections.somenamedtuple のクラスメソッド): namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
                                                             (line  100)
* _makeResult() (unittest.TextTestRunner のメソッド): テストのロードと起動.
                                                             (line  483)
* _missing_() (enum.Enum のメソッド):    データ型<2>.        (line  253)
* _name (ctypes.PyDLL の属性):           共有ライブラリをロードする.
                                                             (line  154)
* _name_ (enum.Enum の属性):             データ型<2>.        (line  164)
* _numeric_repr_() (enum.Flag のメソッド): データ型<2>.      (line  499)
* _objects (ctypes._CData の属性):       データ型<3>.        (line   87)
* _order_ (enum.Enum の属性):            データ型<2>.        (line  172)
* _pack_ (ctypes.Structure の属性):      構造化データ型.     (line   84)
* _parse() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   22)
* _Pointer (ctypes のクラス):            配列とポインタ.     (line   39)
* _Py_c_diff (C function):               C 構造体としての複素数.
                                                             (line   32)
* _Py_c_neg (C function):                C 構造体としての複素数.
                                                             (line   37)
* _Py_c_pow (C function):                C 構造体としての複素数.
                                                             (line   54)
* _Py_c_prod (C function):               C 構造体としての複素数.
                                                             (line   41)
* _Py_c_quot (C function):               C 構造体としての複素数.
                                                             (line   46)
* _Py_c_sum (C function):                C 構造体としての複素数.
                                                             (line   27)
* _Py_InitializeMain (C function):       Multi-Phase Initialization Private Provisional API.
                                                             (line   44)
* _Py_NoneStruct (C var):                オブジェクトをヒープ上にメモリ確保する.
                                                             (line   56)
* _PyBytes_Resize (C function):          バイトオブジェクト<2>.
                                                             (line  172)
* _PyCode_GetExtra (C 関数):             Extra information.  (line   45)
* _PyCode_SetExtra (C 関数):             Extra information.  (line   58)
* _PyEval_RequestCodeExtraIndex (C 関数): Extra information. (line   29)
* _PyFrameEvalFunction (C type):         低レベルAPI.        (line  150)
* _PyInterpreterFrame (C struct):        Internal Frames.    (line    8)
* _PyInterpreterState_GetEvalFrameFunc (C function): 低レベルAPI.
                                                             (line  164)
* _PyInterpreterState_SetEvalFrameFunc (C function): 低レベルAPI.
                                                             (line  174)
* _PyObject_GetDictPtr (C function):     オブジェクトプロトコル object protocol.
                                                             (line  282)
* _PyObject_New (C function):            オブジェクトをヒープ上にメモリ確保する.
                                                             (line    6)
* _PyObject_NewVar (C function):         オブジェクトをヒープ上にメモリ確保する.
                                                             (line    9)
* _PyTuple_Resize (C function):          タプルオブジェクト tuple object.
                                                             (line  100)
* _register_task() (asyncio モジュール): Task lifetime support.
                                                             (line   10)
* _replace() (collections.somenamedtuple のメソッド): namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
                                                             (line  127)
* _setroot() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   14)
* _SimpleCData (ctypes のクラス):        基本データ型<2>.    (line    6)
* _structure() (email.iterators モジュール): email iterators イテレータ.
                                                             (line   45)
* _type_ (ctypes._Pointer の属性):       配列とポインタ.     (line   54)
* _type_ (ctypes.Array の属性):          配列とポインタ.     (line   24)
* _unregister_task() (asyncio モジュール): Task lifetime support.
                                                             (line   16)
* _value_ (enum.Enum の属性):            データ型<2>.        (line  168)
* _write() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  109)
* _xoptions (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line 2014)
* - (負符号);glob 形式のワイルドカード:  glob --- Unix 形式のパス名のパターン展開.
                                                             (line   10)
* - (負符号);glob 形式のワイルドカード <1>: fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   15)
* - (負符号);in doctests:                オプションフラグ.   (line  170)
* - (負符号);in printf-style formatting: printf 形式の文字列書式化.
                                                             (line   67)
* - (負符号);in printf-style formatting <1>: printf 形式での bytes の書式化.
                                                             (line   61)
* - (負符号);in regular expressions:     正規表現のシンタックス.
                                                             (line  173)
* - (負符号);二項演算子:                 二項算術演算 binary arithmetic operation.
                                                             (line   78)
* - (負符号);二項演算子 <1>:             数値型 int float complex.
                                                             (line   24)
* - (負符号);単項演算子:                 単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   10)
* - (負符号);単項演算子 <1>:             数値型 int float complex.
                                                             (line   24)
* - (負符号);文字列のフォーマットで:     書式指定ミニ言語仕様.
                                                             (line   71)
* -=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* ->;関数のアノテーション:               関数のアノテーション.
                                                             (line    6)
* ->;関数のアノテーション <1>:           関数定義.           (line  104)
* , (comma):                             丸括弧形式 parenthesized form.
                                                             (line   19)
* , (comma);argument list:               スライス表記 slicing.
                                                             (line   37)
* , (comma);expression list:             リスト表示.         (line    6)
* , (comma);expression list <1>:         集合表示.           (line    6)
* , (comma);expression list <2>:         式のリスト.         (line    6)
* , (comma);expression list <3>:         assert 文.          (line    6)
* , (comma);expression list <4>:         クラス定義.         (line    6)
* , (comma);identifier list:             global 文.          (line    6)
* , (comma);identifier list <1>:         nonlocal 文.        (line    6)
* , (comma);import statement:            import 文.          (line    6)
* , (comma);in dictionary displays:      辞書表示.           (line    6)
* , (comma);in target list:              代入文 assignment statement.
                                                             (line   35)
* , (comma);parameter list:              関数定義.           (line    6)
* , (comma);with statement:              with 文.            (line    6)
* , (comma);スライス:                    スライス表記 slicing.
                                                             (line    6)
* , (カンマ);文字列のフォーマットで:     書式指定ミニ言語仕様.
                                                             (line  102)
* ; (semicolon):                         複合文 compound statement.
                                                             (line   17)
* ; (semicolon) <1>:                     雑多なシステム情報. (line  135)
* ; (コロン);annotated variable:         注釈付き代入文 annotated assignment statements.
                                                             (line    6)
* ; (コロン);compound statement:         if 文<2>.           (line    6)
* ; (コロン);compound statement <1>:     while 文.           (line    6)
* ; (コロン);compound statement <2>:     for 文<2>.          (line    6)
* ; (コロン);compound statement <3>:     try 文.             (line    6)
* ; (コロン);compound statement <4>:     with 文.            (line    6)
* ; (コロン);compound statement <5>:     match 文<2>.        (line    6)
* ; (コロン);compound statement <6>:     関数定義.           (line    6)
* ; (コロン);compound statement <7>:     クラス定義.         (line    6)
* ; (コロン);in dictionary expressions:  辞書表示.           (line    6)
* ; (コロン);in formatted string literal: 文字列リテラルの結合 concatenation.
                                                             (line   24)
* ; (コロン);in SQL statements:          Cursor オブジェクト.
                                                             (line   24)
* ; (コロン);lambda expression:          ラムダ lambda.      (line    6)
* ; (コロン);path separator (POSIX):     雑多なシステム情報. (line  135)
* ; (コロン);スライス:                   スライス表記 slicing.
                                                             (line    6)
* ; (コロン);文字列のフォーマットで:     書式指定文字列の文法.
                                                             (line   12)
* ; (コロン);関数のアノテーション:       関数のアノテーション.
                                                             (line    6)
* ; (コロン);関数のアノテーション <1>:   関数定義.           (line  104)
* ;= (colon equals):                     ブール演算 boolean operation.
                                                             (line   34)
* ! (pdb command):                       デバッガコマンド.   (line  397)
* ! (エクスクラメーション);curses モジュール内: curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  226)
* ! (エクスクラメーション);glob 形式のワイルドカード: glob --- Unix 形式のパス名のパターン展開.
                                                             (line   10)
* ! (エクスクラメーション);glob 形式のワイルドカード <1>: fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   15)
* ! (エクスクラメーション);in a command interpreter: Cmdオブジェクト.
                                                             (line   26)
* ! (エクスクラメーション);in formatted string literal: 文字列リテラルの結合 concatenation.
                                                             (line   24)
* ! (エクスクラメーション);in struct format strings: バイトオーダ、サイズ、アラインメント.
                                                             (line   13)
* ! (エクスクラメーション);文字列のフォーマットで: 書式指定文字列の文法.
                                                             (line   12)
* ! patterns:                            パターン.           (line    6)
* ? (クエスチョンマーク);argparse モジュール内: nargs.       (line   24)
* ? (クエスチョンマーク);glob 形式のワイルドカード: glob --- Unix 形式のパス名のパターン展開.
                                                             (line   10)
* ? (クエスチョンマーク);glob 形式のワイルドカード <1>: fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   15)
* ? (クエスチョンマーク);in a command interpreter: Cmdオブジェクト.
                                                             (line   26)
* ? (クエスチョンマーク);in AST grammar: Node クラス.        (line   21)
* ? (クエスチョンマーク);in regular expressions: 正規表現のシンタックス.
                                                             (line   77)
* ? (クエスチョンマーク);in SQL statements: Cursor オブジェクト.
                                                             (line   24)
* ? (クエスチョンマーク);in struct format strings: 書式指定文字.
                                                             (line   88)
* ? (クエスチョンマーク);in struct format strings <1>: 書式指定文字.
                                                             (line  170)
* ? (クエスチョンマーク);replacement character: エラーハンドラ.
                                                             (line   14)
* ??;in regular expressions:             正規表現のシンタックス.
                                                             (line   82)
* ?+;in regular expressions:             正規表現のシンタックス.
                                                             (line   92)
* . (ドット);attribute reference:        属性参照.           (line    6)
* . (ドット);glob 形式のワイルドカード:  glob --- Unix 形式のパス名のパターン展開.
                                                             (line   10)
* . (ドット);in numeric literal:         整数リテラル.       (line   40)
* . (ドット);in pathnames:               雑多なシステム情報. (line  100)
* . (ドット);in pathnames <1>:           雑多なシステム情報. (line  130)
* . (ドット);in printf-style formatting: printf 形式の文字列書式化.
                                                             (line   29)
* . (ドット);in printf-style formatting <1>: printf 形式での bytes の書式化.
                                                             (line   23)
* . (ドット);in regular expressions:     正規表現のシンタックス.
                                                             (line   42)
* . (ドット);文字列のフォーマットで:     書式指定文字列の文法.
                                                             (line   12)
* ..;in pathnames:                       雑多なシステム情報. (line  106)
* ...:                                   用語集<2>.          (line   10)
* ...;ellipsisリテラル:                  Ellipsis.           (line    6)
* ...;ellipsisリテラル <1>:              組み込み定数.       (line   56)
* ...;ellipsisリテラル <2>:              ヌルオブジェクト.   (line   12)
* ...;in doctests:                       オプションフラグ.   (line   48)
* ...;interpreter prompt:                docstring 内の実行例をどのように認識するのか?.
                                                             (line   26)
* ...;interpreter prompt <1>:            sys --- システム固有のパラメーターと関数.
                                                             (line 1452)
* ...;placeholder:                       textwrap --- テキストの折り返しと詰め込み.
                                                             (line  268)
* ...;placeholder <1>:                   PrettyPrinter オブジェクト.
                                                             (line    6)
* ...;placeholder <2>:                   reprlib --- もう一つの repr の実装.
                                                             (line   59)
* .ini;ファイル:                         configparser --- 設定ファイルのパーサー.
                                                             (line    8)
* .pdbrc;ファイル:                       デバッガコマンド.   (line   56)
* ' (single quote);文字列リテラル:       リテラル.           (line    8)
* ''';文字列リテラル:                    文字列およびバイト列リテラル.
                                                             (line   36)
* " (double quote);文字列リテラル:       リテラル.           (line    8)
* """;文字列リテラル:                    文字列およびバイト列リテラル.
                                                             (line   36)
* (?;;in regular expressions:            正規表現のシンタックス.
                                                             (line  270)
* (?;in regular expressions:             正規表現のシンタックス.
                                                             (line  232)
* (?!;in regular expressions:            正規表現のシンタックス.
                                                             (line  387)
* (?(;in regular expressions:            正規表現のシンタックス.
                                                             (line  430)
* (?#;in regular expressions:            正規表現のシンタックス.
                                                             (line  376)
* (?<!;in regular expressions:           正規表現のシンタックス.
                                                             (line  421)
* (?<=;in regular expressions:           正規表現のシンタックス.
                                                             (line  394)
* (?=;in regular expressions:            正規表現のシンタックス.
                                                             (line  380)
* (?P<;in regular expressions:           正規表現のシンタックス.
                                                             (line  332)
* (?P=;in regular expressions:           正規表現のシンタックス.
                                                             (line  371)
* () (丸括弧);call:                      スライス表記 slicing.
                                                             (line   37)
* () (丸括弧);class definition:          クラス定義.         (line    6)
* () (丸括弧);function definition:       関数定義.           (line    6)
* () (丸括弧);generator expression:      ジェネレータ式<2>.  (line    6)
* () (丸括弧);in assignment target list: 代入文 assignment statement.
                                                             (line   35)
* () (丸括弧);in printf-style formatting: printf 形式の文字列書式化.
                                                             (line   29)
* () (丸括弧);in printf-style formatting <1>: printf 形式での bytes の書式化.
                                                             (line   23)
* () (丸括弧);in regular expressions:    正規表現のシンタックス.
                                                             (line  224)
* () (丸括弧);tuple display:             丸括弧形式 parenthesized form.
                                                             (line    6)
* [] (角カッコ);glob 形式のワイルドカード: glob --- Unix 形式のパス名のパターン展開.
                                                             (line   10)
* [] (角カッコ);glob 形式のワイルドカード <1>: fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   15)
* [] (角カッコ);in assignment target list: 代入文 assignment statement.
                                                             (line   35)
* [] (角カッコ);in regular expressions:  正規表現のシンタックス.
                                                             (line  166)
* [] (角カッコ);list expression:         リスト表示.         (line    6)
* [] (角カッコ);文字列のフォーマットで:  書式指定文字列の文法.
                                                             (line   12)
* [] (角カッコ);添字表記:                添字表記 subscription.
                                                             (line    6)
* {} (波括弧);dictionary expression:     辞書表示.           (line    6)
* {} (波括弧);in formatted string literal: 文字列リテラルの結合 concatenation.
                                                             (line   24)
* {} (波括弧);in regular expressions:    正規表現のシンタックス.
                                                             (line  111)
* {} (波括弧);set expression:            集合表示.           (line    6)
* {} (波括弧);文字列のフォーマットで:    書式指定文字列の文法.
                                                             (line   12)
* @ (at);class definition:               クラス定義.         (line   44)
* @ (at);function definition:            関数定義.           (line   33)
* @ (at);in struct format strings:       バイトオーダ、サイズ、アラインメント.
                                                             (line   13)
* * (アスタリスク);argparse モジュール内: nargs.             (line   56)
* * (アスタリスク);function definition:  関数定義.           (line   89)
* * (アスタリスク);glob 形式のワイルドカード: glob --- Unix 形式のパス名のパターン展開.
                                                             (line   10)
* * (アスタリスク);glob 形式のワイルドカード <1>: fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   15)
* * (アスタリスク);import statement:     import 文.          (line   81)
* * (アスタリスク);in assignment target list: 代入文 assignment statement.
                                                             (line   35)
* * (アスタリスク);in AST grammar:       Node クラス.        (line   21)
* * (アスタリスク);in expression lists:  式のリスト.         (line   17)
* * (アスタリスク);in printf-style formatting: printf 形式の文字列書式化.
                                                             (line   29)
* * (アスタリスク);in printf-style formatting <1>: printf 形式での bytes の書式化.
                                                             (line   23)
* * (アスタリスク);in regular expressions: 正規表現のシンタックス.
                                                             (line   65)
* * (アスタリスク);関数呼び出しの中の:   任意引数リスト.     (line    6)
* * (アスタリスク);関数呼び出しの中の <1>: 呼び出し call.    (line   71)
* *?;in regular expressions:             正規表現のシンタックス.
                                                             (line   82)
* **;function definition:                関数定義.           (line   89)
* **;glob 形式のワイルドカード:          glob --- Unix 形式のパス名のパターン展開.
                                                             (line   51)
* **;in dictionary displays:             辞書表示.           (line   23)
* **;関数呼び出しの中の:                 引数リストのアンパック.
                                                             (line   18)
* **;関数呼び出しの中の <1>:             呼び出し call.      (line   98)
* **=;augmented assignment:              累算代入文 augmented assignment statement.
                                                             (line    6)
* *+;in regular expressions:             正規表現のシンタックス.
                                                             (line   92)
* *=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* / (スラッシュ);function definition:    関数定義.           (line   89)
* / (スラッシュ);in pathnames:           雑多なシステム情報. (line  112)
* / (スラッシュ);in pathnames <1>:       雑多なシステム情報. (line  122)
* //=;augmented assignment:              累算代入文 augmented assignment statement.
                                                             (line    6)
* /=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* \ (backslash);in pathnames (Windows):  雑多なシステム情報. (line  112)
* \ (backslash);in regular expressions:  正規表現のシンタックス.
                                                             (line  151)
* \ (backslash);in regular expressions <1>: 正規表現のシンタックス.
                                                             (line  185)
* \ (backslash);in regular expressions <2>: 正規表現のシンタックス.
                                                             (line  448)
* \ (backslash);エスケープシーケンス:    文字列およびバイト列リテラル.
                                                             (line   77)
* \ (backslash);エスケープシーケンス <1>: エラーハンドラ.    (line   14)
* \\;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \\;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \A;in regular expressions:             正規表現のシンタックス.
                                                             (line  460)
* \a;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \a;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \b;in regular expressions:             正規表現のシンタックス.
                                                             (line  464)
* \B;in regular expressions:             正規表現のシンタックス.
                                                             (line  481)
* \b;in regular expressions <1>:         正規表現のシンタックス.
                                                             (line  576)
* \b;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \d;in regular expressions:             正規表現のシンタックス.
                                                             (line  496)
* \D;in regular expressions:             正規表現のシンタックス.
                                                             (line  510)
* \f;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \f;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \g;in regular expressions:             関数<2>.            (line  206)
* \n;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \N;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \n;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \N;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \N;エスケープシーケンス <1>:           エラーハンドラ.     (line   52)
* \r;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \r;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \s;in regular expressions:             正規表現のシンタックス.
                                                             (line  517)
* \S;in regular expressions:             正規表現のシンタックス.
                                                             (line  534)
* \t;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \t;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \u;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \U;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \u;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \U;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \u;エスケープシーケンス <1>:           エラーハンドラ.     (line   14)
* \U;エスケープシーケンス <1>:           エラーハンドラ.     (line   14)
* \v;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \v;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \w;in regular expressions:             正規表現のシンタックス.
                                                             (line  542)
* \W;in regular expressions:             正規表現のシンタックス.
                                                             (line  560)
* \x;in regular expressions:             正規表現のシンタックス.
                                                             (line  576)
* \x;エスケープシーケンス:               文字列およびバイト列リテラル.
                                                             (line   77)
* \x;エスケープシーケンス <1>:           エラーハンドラ.     (line   14)
* \Z;in regular expressions:             正規表現のシンタックス.
                                                             (line  572)
* &=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* # (hash);in doctests:                  オプションフラグ.   (line  171)
* # (hash);in printf-style formatting:   printf 形式の文字列書式化.
                                                             (line   67)
* # (hash);in printf-style formatting <1>: printf 形式での bytes の書式化.
                                                             (line   61)
* # (hash);in regular expressions:       フラグ.             (line  125)
* # (hash);source encoding declaration:  エンコード宣言 encoding declaration.
                                                             (line    6)
* # (hash);コメント:                     形式ばらない Python の紹介.
                                                             (line   10)
* # (hash);コメント <1>:                 コメント Comments.  (line    6)
* # (hash);コメント <2>:                 site --- サイト固有の設定フック.
                                                             (line   51)
* # (hash);文字列のフォーマットで:       書式指定ミニ言語仕様.
                                                             (line   93)
* % (パーセント);datetime format:        timezone オブジェクト.
                                                             (line   72)
* % (パーセント);datetime format <1>:    関数<5>.            (line  304)
* % (パーセント);datetime format <2>:    関数<5>.            (line  461)
* % (パーセント);environment variables expansion (Windows): os path --- 一般的なパス名操作.
                                                             (line  160)
* % (パーセント);environment variables expansion (Windows) <1>: 関数<13>.
                                                             (line  226)
* % (パーセント);interpolation in configuration files: 値の補間.
                                                             (line   10)
* % (パーセント);printf 形式の書式化:    printf 形式の文字列書式化.
                                                             (line    6)
* % (パーセント);printf 形式の書式化 <1>: printf 形式での bytes の書式化.
                                                             (line    6)
* %=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* %APPDATA%:                             Redirection of local data registry and temporary paths.
                                                             (line   12)
* ''parser'':                            字句解析.           (line    6)
* ^ (キャレット);curses モジュール内:    curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  226)
* ^ (キャレット);in regular expressions: 正規表現のシンタックス.
                                                             (line   49)
* ^ (キャレット);in regular expressions <1>: 正規表現のシンタックス.
                                                             (line  189)
* ^ (キャレット);marker:                 例外はどう扱えばよいか?.
                                                             (line   92)
* ^ (キャレット);marker <1>:             モジュールレベルの関数<2>.
                                                             (line   36)
* ^ (キャレット);文字列のフォーマットで: 書式指定ミニ言語仕様.
                                                             (line   41)
* ^=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* + (プラス記号);argparse モジュール内:  nargs.              (line   67)
* + (プラス記号);in doctests:            オプションフラグ.   (line  171)
* + (プラス記号);in printf-style formatting: printf 形式の文字列書式化.
                                                             (line   67)
* + (プラス記号);in printf-style formatting <1>: printf 形式での bytes の書式化.
                                                             (line   61)
* + (プラス記号);in regular expressions: 正規表現のシンタックス.
                                                             (line   71)
* + (プラス記号);二項演算子:             二項算術演算 binary arithmetic operation.
                                                             (line   70)
* + (プラス記号);二項演算子 <1>:         数値型 int float complex.
                                                             (line   24)
* + (プラス記号);単項演算子:             単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   14)
* + (プラス記号);単項演算子 <1>:         数値型 int float complex.
                                                             (line   24)
* + (プラス記号);文字列のフォーマットで: 書式指定ミニ言語仕様.
                                                             (line   71)
* +?;in regular expressions:             正規表現のシンタックス.
                                                             (line   82)
* ++;in regular expressions:             正規表現のシンタックス.
                                                             (line   92)
* +=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* < (小さい);in struct format strings:   バイトオーダ、サイズ、アラインメント.
                                                             (line   13)
* < (小さい);文字列のフォーマットで:     書式指定ミニ言語仕様.
                                                             (line   41)
* <<=;augmented assignment:              累算代入文 augmented assignment statement.
                                                             (line    6)
* <BLANKLINE>:                           オプションフラグ.   (line   30)
* = (等号);assignment statement:         代入文 assignment statement.
                                                             (line    6)
* = (等号);class definition:             メタクラス.         (line    6)
* = (等号);for help in debugging using string literals: 文字列リテラルの結合 concatenation.
                                                             (line   24)
* = (等号);function definition:          関数定義.           (line   65)
* = (等号);in struct format strings:     バイトオーダ、サイズ、アラインメント.
                                                             (line   13)
* = (等号);文字列のフォーマットで:       書式指定ミニ言語仕様.
                                                             (line   41)
* = (等号);関数呼び出しの中の:           スライス表記 slicing.
                                                             (line   36)
* > (大きい);in struct format strings:   バイトオーダ、サイズ、アラインメント.
                                                             (line   13)
* > (大きい);文字列のフォーマットで:     書式指定ミニ言語仕様.
                                                             (line   41)
* >>=;augmented assignment:              累算代入文 augmented assignment statement.
                                                             (line    6)
* >>>:                                   用語集<2>.          (line    6)
* >>>;interpreter prompt:                docstring 内の実行例をどのように認識するのか?.
                                                             (line   26)
* >>>;interpreter prompt <1>:            sys --- システム固有のパラメーターと関数.
                                                             (line 1452)
* | (縦棒);in regular expressions:       正規表現のシンタックス.
                                                             (line  211)
* |=;augmented assignment:               累算代入文 augmented assignment statement.
                                                             (line    6)
* ~ (チルダ);home directory expansion:   os path --- 一般的なパス名操作.
                                                             (line  134)
* $ (ダラー);environment variables expansion: os path --- 一般的なパス名操作.
                                                             (line  160)
* $ (ダラー);in regular expressions:     正規表現のシンタックス.
                                                             (line   54)
* $ (ダラー);interpolation in configuration files: 値の補間. (line   39)
* $ (ダラー);テンプレート文字列の中で:   テンプレート文字列. (line   13)
* 0b;整数リテラル:                       数値リテラル.       (line   14)
* 0o;整数リテラル:                       数値リテラル.       (line   14)
* 0x;整数リテラル:                       数値リテラル.       (line   14)
* 10進数リテラル:                        数値リテラル.       (line    6)
* 16進数;リテラル:                       数値型 int float complex.
                                                             (line   17)
* 16進数リテラル:                        数値リテラル.       (line    6)
* 2-digit years:                         time --- 時刻データへのアクセスと変換.
                                                             (line   34)
* 2038年:                                time --- 時刻データへのアクセスと変換.
                                                             (line   29)
* 2進数;ビット単位;演算:                 ビット単位演算の二項演算 binary bitwise operation.
                                                             (line    6)
* 2進数;リテラル:                        数値型 int float complex.
                                                             (line   17)
* 2進数;算術;演算:                       二項算術演算 binary arithmetic operation.
                                                             (line    6)
* 2進数リテラル:                         数値リテラル.       (line    6)
* 8進数;リテラル:                        数値型 int float complex.
                                                             (line   17)
* 8進数リテラル:                         数値リテラル.       (line    6)
* A (re モジュール):                     フラグ.             (line   16)
* A_ALTCHARSET (curses モジュール):      定数<6>.            (line   67)
* A_ATTRIBUTES (curses モジュール):      定数<6>.            (line  128)
* A_BLINK (curses モジュール):           定数<6>.            (line   70)
* A_BOLD (curses モジュール):            定数<6>.            (line   73)
* A_CHARTEXT (curses モジュール):        定数<6>.            (line  131)
* A_COLOR (curses モジュール):           定数<6>.            (line  134)
* A_DIM (curses モジュール):             定数<6>.            (line   76)
* A_HORIZONTAL (curses モジュール):      定数<6>.            (line  101)
* A_INVIS (curses モジュール):           定数<6>.            (line   79)
* A_ITALIC (curses モジュール):          定数<6>.            (line   82)
* A_LEFT (curses モジュール):            定数<6>.            (line  104)
* A_LOW (curses モジュール):             定数<6>.            (line  107)
* A_NORMAL (curses モジュール):          定数<6>.            (line   85)
* A_PROTECT (curses モジュール):         定数<6>.            (line   88)
* A_REVERSE (curses モジュール):         定数<6>.            (line   91)
* A_RIGHT (curses モジュール):           定数<6>.            (line  110)
* A_STANDOUT (curses モジュール):        定数<6>.            (line   95)
* A_TOP (curses モジュール):             定数<6>.            (line  113)
* A_UNDERLINE (curses モジュール):       定数<6>.            (line   98)
* A_VERTICAL (curses モジュール):        定数<6>.            (line  116)
* a2b_base64() (binascii モジュール):    binascii --- バイナリ と ASCII 間の変換.
                                                             (line   40)
* a2b_hex() (binascii モジュール):       binascii --- バイナリ と ASCII 間の変換.
                                                             (line  144)
* a2b_qp() (binascii モジュール):        binascii --- バイナリ と ASCII 間の変換.
                                                             (line   70)
* a2b_uu() (binascii モジュール):        binascii --- バイナリ と ASCII 間の変換.
                                                             (line   24)
* a85decode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  196)
* a85encode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  173)
* ABC (abc のクラス):                    abc --- 抽象基底クラス.
                                                             (line   27)
* ABCMeta (abc のクラス):                abc --- 抽象基底クラス.
                                                             (line   52)
* ABDAY_1 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  213)
* ABDAY_2 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  213)
* ABDAY_3 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  213)
* ABDAY_4 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  213)
* ABDAY_5 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  213)
* ABDAY_6 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  213)
* ABDAY_7 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  213)
* abiflags (sys モジュール):             sys --- システム固有のパラメーターと関数.
                                                             (line   12)
* ABMON_1 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_10 (locale モジュール):          locale --- 国際化サービス.
                                                             (line  238)
* ABMON_11 (locale モジュール):          locale --- 国際化サービス.
                                                             (line  238)
* ABMON_12 (locale モジュール):          locale --- 国際化サービス.
                                                             (line  238)
* ABMON_2 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_3 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_4 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_5 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_6 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_7 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_8 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* ABMON_9 (locale モジュール):           locale --- 国際化サービス.
                                                             (line  238)
* abort (C function):                    プロセス制御.       (line    7)
* ABORT (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  147)
* abort_clients() (asyncio.Server のメソッド): Serverオブジェクト.
                                                             (line   56)
* abort() (asyncio.Barrier のメソッド):  Barrier.            (line   88)
* abort() (asyncio.DatagramTransport のメソッド): データグラムトランスポート.
                                                             (line   20)
* abort() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line    6)
* abort() (ftplib.FTP のメソッド):       FTP オブジェクト.   (line  151)
* abort() (os モジュール):               プロセス管理.       (line   16)
* abort() (threading.Barrier のメソッド): バリアオブジェクト.
                                                             (line   80)
* ABORTRETRYIGNORE (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  162)
* ABOVE_NORMAL_PRIORITY_CLASS (subprocess モジュール): Windows Constants.
                                                             (line   68)
* above() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   13)
* abs() (decimal.Context のメソッド):    Context オブジェクト.
                                                             (line  243)
* abs() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line   70)
* absolute() (pathlib.Path のメソッド):  パスの展開と解決.   (line   38)
* AbsoluteLinkError:                     tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  260)
* AbsolutePathError:                     tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  246)
* abspath() (os.path モジュール):        os path --- 一般的なパス名操作.
                                                             (line   47)
* abstract base class:                   用語集<2>.          (line   22)
* AbstractAsyncContextManager (contextlib のクラス): ユーティリティ.
                                                             (line   19)
* AbstractBasicAuthHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  335)
* AbstractChildWatcher (asyncio のクラス): プロセスのウオッチャー.
                                                             (line   44)
* abstractclassmethod() (abc モジュール): abc --- 抽象基底クラス.
                                                             (line  235)
* AbstractContextManager (contextlib のクラス): ユーティリティ.
                                                             (line    8)
* AbstractDigestAuthHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  373)
* AbstractEventLoop (asyncio のクラス):  イベントループの実装.
                                                             (line   53)
* AbstractEventLoopPolicy (asyncio のクラス): ポリシーオブジェクト.
                                                             (line    8)
* abstractmethod() (abc モジュール):     abc --- 抽象基底クラス.
                                                             (line  159)
* abstractproperty() (abc モジュール):   abc --- 抽象基底クラス.
                                                             (line  279)
* AbstractSet (typing のクラス):         Aliases to container ABCs in collections abc.
                                                             (line    6)
* abstractstaticmethod() (abc モジュール): abc --- 抽象基底クラス.
                                                             (line  257)
* accept() (multiprocessing.connection.Listener のメソッド): リスナーとクライアント.
                                                             (line   84)
* accept() (socket.socket のメソッド):   socket オブジェクト.
                                                             (line   13)
* access() (os モジュール):              ファイルとディレクトリ.
                                                             (line   50)
* accumulate() (itertools モジュール):   Itertool関数.       (line   10)
* ACK (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   36)
* aclose() (agen のメソッド):            非同期ジェネレータイテレータメソッド.
                                                             (line   60)
* aclose() (contextlib.AsyncExitStack のメソッド): ユーティリティ.
                                                             (line  651)
* aclosing() (contextlib モジュール):    ユーティリティ.     (line  191)
* acos() (cmath モジュール):             三角関数<2>.        (line    6)
* acos() (math モジュール):              三角関数.           (line    6)
* acosh() (cmath モジュール):            双曲線関数<2>.      (line    6)
* acosh() (math モジュール):             双曲線関数.         (line    9)
* acquire() (_thread.lock のメソッド):   _thread --- 低水準なスレッド API.
                                                             (line  141)
* acquire() (asyncio.Condition のメソッド): Condition.       (line   46)
* acquire() (asyncio.Lock のメソッド):   Lock.               (line   36)
* acquire() (asyncio.Semaphore のメソッド): Semaphore.       (line   44)
* acquire() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   27)
* acquire() (multiprocessing.Lock のメソッド): 同期プリミティブ.
                                                             (line   64)
* acquire() (multiprocessing.RLock のメソッド): 同期プリミティブ.
                                                             (line  113)
* acquire() (threading.Condition のメソッド): Condition オブジェクト.
                                                             (line   85)
* acquire() (threading.Lock のメソッド): Lock オブジェクト.  (line   45)
* acquire() (threading.RLock のメソッド): RLock オブジェクト.
                                                             (line   45)
* acquire() (threading.Semaphore のメソッド): Semaphore オブジェクト.
                                                             (line   35)
* ACS_BBSS (curses モジュール):          定数<6>.            (line  472)
* ACS_BLOCK (curses モジュール):         定数<6>.            (line  475)
* ACS_BOARD (curses モジュール):         定数<6>.            (line  478)
* ACS_BSBS (curses モジュール):          定数<6>.            (line  481)
* ACS_BSSB (curses モジュール):          定数<6>.            (line  484)
* ACS_BSSS (curses モジュール):          定数<6>.            (line  487)
* ACS_BTEE (curses モジュール):          定数<6>.            (line  490)
* ACS_BULLET (curses モジュール):        定数<6>.            (line  493)
* ACS_CKBOARD (curses モジュール):       定数<6>.            (line  496)
* ACS_DARROW (curses モジュール):        定数<6>.            (line  499)
* ACS_DEGREE (curses モジュール):        定数<6>.            (line  502)
* ACS_DIAMOND (curses モジュール):       定数<6>.            (line  505)
* ACS_GEQUAL (curses モジュール):        定数<6>.            (line  508)
* ACS_HLINE (curses モジュール):         定数<6>.            (line  511)
* ACS_LANTERN (curses モジュール):       定数<6>.            (line  514)
* ACS_LARROW (curses モジュール):        定数<6>.            (line  517)
* ACS_LEQUAL (curses モジュール):        定数<6>.            (line  520)
* ACS_LLCORNER (curses モジュール):      定数<6>.            (line  523)
* ACS_LRCORNER (curses モジュール):      定数<6>.            (line  526)
* ACS_LTEE (curses モジュール):          定数<6>.            (line  529)
* ACS_NEQUAL (curses モジュール):        定数<6>.            (line  532)
* ACS_PI (curses モジュール):            定数<6>.            (line  535)
* ACS_PLMINUS (curses モジュール):       定数<6>.            (line  538)
* ACS_PLUS (curses モジュール):          定数<6>.            (line  541)
* ACS_RARROW (curses モジュール):        定数<6>.            (line  544)
* ACS_RTEE (curses モジュール):          定数<6>.            (line  547)
* ACS_S1 (curses モジュール):            定数<6>.            (line  550)
* ACS_S3 (curses モジュール):            定数<6>.            (line  553)
* ACS_S7 (curses モジュール):            定数<6>.            (line  556)
* ACS_S9 (curses モジュール):            定数<6>.            (line  559)
* ACS_SBBS (curses モジュール):          定数<6>.            (line  562)
* ACS_SBSB (curses モジュール):          定数<6>.            (line  565)
* ACS_SBSS (curses モジュール):          定数<6>.            (line  568)
* ACS_SSBB (curses モジュール):          定数<6>.            (line  571)
* ACS_SSBS (curses モジュール):          定数<6>.            (line  574)
* ACS_SSSB (curses モジュール):          定数<6>.            (line  577)
* ACS_SSSS (curses モジュール):          定数<6>.            (line  580)
* ACS_STERLING (curses モジュール):      定数<6>.            (line  583)
* ACS_TTEE (curses モジュール):          定数<6>.            (line  586)
* ACS_UARROW (curses モジュール):        定数<6>.            (line  589)
* ACS_ULCORNER (curses モジュール):      定数<6>.            (line  592)
* ACS_URCORNER (curses モジュール):      定数<6>.            (line  595)
* ACS_VLINE (curses モジュール):         定数<6>.            (line  598)
* Action (argparse のクラス):            Action クラス.      (line   11)
* action (optparse.Option の属性):       オプション属性.     (line   19)
* ACTIONS (optparse.Option の属性):      新しいアクションの追加.
                                                             (line   32)
* activate_stack_trampoline() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line 1710)
* active_children() (multiprocessing モジュール): その他<3>. (line    6)
* active_count() (threading モジュール): threading --- スレッドベースの並列処理.
                                                             (line   52)
* actual() (tkinter.font.Font のメソッド): tkinter font --- Tkinter フォントラッパー.
                                                             (line   47)
* Add (ast のクラス):                    式 expression<2>.   (line   55)
* add_alias() (email.charset モジュール): email charset 文字集合の表現.
                                                             (line  200)
* add_alternative() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  641)
* add_argument_group() (argparse.ArgumentParser のメソッド): 引数グループ.
                                                             (line    6)
* add_argument() (argparse.ArgumentParser のメソッド): add_argument メソッド.
                                                             (line    6)
* add_attachment() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  653)
* add_cgi_vars() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  135)
* add_charset() (email.charset モジュール): email charset 文字集合の表現.
                                                             (line  170)
* add_child_handler() (asyncio.AbstractChildWatcher のメソッド): プロセスのウオッチャー.
                                                             (line   46)
* add_codec() (email.charset モジュール): email charset 文字集合の表現.
                                                             (line  209)
* add_cookie_header() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   12)
* add_dll_directory() (os モジュール):   プロセス管理.       (line   24)
* add_done_callback() (asyncio.Future のメソッド): Future オブジェクト<2>.
                                                             (line   83)
* add_done_callback() (asyncio.Task のメソッド): Task オブジェクト.
                                                             (line  102)
* add_done_callback() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   67)
* add_fallback() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   31)
* add_flag() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  127)
* add_flag() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line   81)
* add_flag() (mailbox.mboxMessage のメソッド): mboxMessage オブジェクト.
                                                             (line   78)
* add_flag() (mailbox.MMDFMessage のメソッド): MMDFMessage オブジェクト.
                                                             (line   77)
* add_folder() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line   73)
* add_folder() (mailbox.MH のメソッド):  MH オブジェクト.    (line   47)
* add_get_handler() (email.contentmanager.ContentManager のメソッド): email contentmanager Managing MIME Content.
                                                             (line   74)
* add_handler() (urllib.request.OpenerDirector のメソッド): OpenerDirector オブジェクト.
                                                             (line    8)
* add_header() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  261)
* add_header() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  368)
* add_header() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line   79)
* add_header() (wsgiref.headers.Headers のメソッド): wsgiref headers -- WSGI レスポンスヘッダツール群.
                                                             (line   60)
* add_history() (readline モジュール):   履歴リスト.         (line   36)
* add_label() (mailbox.BabylMessage のメソッド): BabylMessage オブジェクト.
                                                             (line   55)
* add_mutually_exclusive_group() (argparse.ArgumentParser のメソッド): 相互排他.
                                                             (line    6)
* add_note() (BaseException のメソッド): 基底クラス.         (line   48)
* add_option() (optparse.OptionParser のメソッド): オプションの定義.
                                                             (line   14)
* add_parent() (urllib.request.BaseHandler のメソッド): BaseHandler オブジェクト.
                                                             (line   10)
* add_password() (urllib.request.HTTPPasswordMgr のメソッド): HTTPPasswordMgr オブジェクト.
                                                             (line    9)
* add_password() (urllib.request.HTTPPasswordMgrWithPriorAuth のメソッド): HTTPPasswordMgrWithPriorAuth オブジェクト.
                                                             (line   10)
* add_reader() (asyncio.loop のメソッド): ファイル記述子の監視.
                                                             (line    6)
* add_related() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  628)
* add_section() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  117)
* add_section() (configparser.RawConfigParser のメソッド): RawConfigParser オブジェクト.
                                                             (line   36)
* add_sequence() (mailbox.MHMessage のメソッド): MHMessage オブジェクト.
                                                             (line   40)
* add_set_handler() (email.contentmanager.ContentManager のメソッド): email contentmanager Managing MIME Content.
                                                             (line   79)
* add_signal_handler() (asyncio.loop のメソッド): Unix シグナル.
                                                             (line    6)
* add_subparsers() (argparse.ArgumentParser のメソッド): サブコマンド.
                                                             (line    6)
* add_type() (mimetypes モジュール):     mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  121)
* add_type() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line  106)
* add_unredirected_header() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line   92)
* add_writer() (asyncio.loop のメソッド): ファイル記述子の監視.
                                                             (line   17)
* add() (decimal.Context のメソッド):    Context オブジェクト.
                                                             (line  247)
* add() (frozenset のメソッド):          set（集合）型 --- set frozenset.
                                                             (line  193)
* add() (graphlib.TopologicalSorter のメソッド): graphlib --- グラフ構造を操作する機能.
                                                             (line   79)
* add() (mailbox.Mailbox のメソッド):    Mailbox オブジェクト.
                                                             (line   58)
* add() (mailbox.Maildir のメソッド):    Maildir オブジェクト.
                                                             (line  191)
* add() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line   75)
* add() (pstats.Stats のメソッド):       Stats クラス.       (line   44)
* add() (tarfile.TarFile のメソッド):    TarFile オブジェクト.
                                                             (line  276)
* add() (tkinter.ttk.Notebook のメソッド): ttk Notebook.     (line    8)
* addAsyncCleanup() (unittest.IsolatedAsyncioTestCase のメソッド): テストクラス.
                                                             (line  885)
* addaudithook() (sys モジュール):       sys --- システム固有のパラメーターと関数.
                                                             (line   24)
* addch() (curses.window のメソッド):    Window オブジェクト.
                                                             (line    9)
* addClassCleanup() (unittest.TestCase のクラスメソッド): テストクラス.
                                                             (line  808)
* addCleanup() (unittest.TestCase のメソッド): テストクラス. (line  769)
* addcomponent() (turtle.Shape のメソッド): Public classes.  (line   67)
* addDuration() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  428)
* addError() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  359)
* addExpectedFailure() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  395)
* addFailure() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  370)
* addfile() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  296)
* addFilter() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   54)
* addFilter() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  315)
* addHandler() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  332)
* addinfourl (urllib.response のクラス): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   12)
* addLevelName() (logging モジュール):   モジュールレベルの関数.
                                                             (line  124)
* addModuleCleanup() (unittest モジュール): setUpModule と tearDownModule.
                                                             (line   22)
* addnstr() (curses.window のメソッド):  Window オブジェクト.
                                                             (line   22)
* AddPackagePath() (modulefinder モジュール): modulefinder --- スクリプト中で使用されているモジュールの検索.
                                                             (line   16)
* addr_spec (email.headerregistry.Address の属性): email headerregistry Custom Header Objects.
                                                             (line  434)
* Address (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  397)
* address (email.headerregistry.SingleAddressHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  217)
* address (multiprocessing.connection.Listener の属性): リスナーとクライアント.
                                                             (line  100)
* address (multiprocessing.managers.BaseManager の属性): マネージャー.
                                                             (line  137)
* address_exclude() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  159)
* address_exclude() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  342)
* address_family (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line   65)
* address_string() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  333)
* addresses (email.headerregistry.AddressHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  192)
* addresses (email.headerregistry.Group の属性): email headerregistry Custom Header Objects.
                                                             (line  470)
* AddressHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  177)
* addressof() (ctypes モジュール):       ユーティリティー関数.
                                                             (line    6)
* AddressValueError:                     Custom Exceptions.  (line    9)
* addshape() (turtle モジュール):        設定と特殊なメソッド.
                                                             (line   71)
* addsitedir() (site モジュール):        モジュールの内容<5>.
                                                             (line   52)
* addSkip() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  387)
* addstr() (curses.window のメソッド):   Window オブジェクト.
                                                             (line   29)
* addSubTest() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  413)
* addSuccess() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  381)
* addTest() (unittest.TestSuite のメソッド): テストのグループ化.
                                                             (line   25)
* addTests() (unittest.TestSuite のメソッド): テストのグループ化.
                                                             (line   30)
* addTypeEqualityFunc() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  591)
* addUnexpectedSuccess() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  405)
* adjust_int_max_str_digits() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  741)
* adjusted() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  110)
* adler32() (zlib モジュール):           zlib --- gzip 互換の圧縮.
                                                             (line   30)
* AF_ALG (socket モジュール):            定数<8>.            (line  263)
* AF_CAN (socket モジュール):            定数<8>.            (line  128)
* AF_DIVERT (socket モジュール):         定数<8>.            (line  202)
* AF_HYPERV (socket モジュール):         定数<8>.            (line  345)
* AF_INET (socket モジュール):           定数<8>.            (line   11)
* AF_INET6 (socket モジュール):          定数<8>.            (line   11)
* AF_LINK (socket モジュール):           定数<8>.            (line  287)
* AF_PACKET (socket モジュール):         定数<8>.            (line  212)
* AF_QIPCRTR (socket モジュール):        定数<8>.            (line  315)
* AF_RDS (socket モジュール):            定数<8>.            (line  234)
* AF_UNIX (socket モジュール):           定数<8>.            (line   11)
* AF_UNSPEC (socket モジュール):         定数<8>.            (line   21)
* AF_VSOCK (socket モジュール):          定数<8>.            (line  274)
* alarm() (signal モジュール):           モジュールの内容<2>.
                                                             (line  267)
* ALERT_DESCRIPTION_HANDSHAKE_FAILURE (ssl モジュール): 定数<9>.
                                                             (line  511)
* ALERT_DESCRIPTION_INTERNAL_ERROR (ssl モジュール): 定数<9>.
                                                             (line  511)
* AlertDescription (ssl のクラス):       定数<9>.            (line  525)
* algorithm (sys.hash_info の属性):      sys --- システム固有のパラメーターと関数.
                                                             (line 1035)
* algorithms_available (hashlib モジュール): 属性.           (line   18)
* algorithms_guaranteed (hashlib モジュール): 属性.          (line    8)
* alias (ast のクラス):                  インポート.         (line   39)
* alias (pdb command):                   デバッガコマンド.   (line  369)
* alignment() (ctypes モジュール):       ユーティリティー関数.
                                                             (line   14)
* alive (weakref.finalize の属性):       weakref --- 弱参照. (line  302)
* ALL_COMPLETED (asyncio モジュール):    要素の終了待機.     (line   45)
* ALL_COMPLETED (concurrent.futures モジュール): モジュール関数<2>.
                                                             (line   39)
* all_errors (ftplib モジュール):        モジュール変数.     (line   25)
* all_features (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   94)
* all_frames (tracemalloc.Filter の属性): Filter.            (line   59)
* all_properties (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line  126)
* all_suffixes() (importlib.machinery モジュール): importlib machinery -- インポータおよびパスフック.
                                                             (line   57)
* all_tasks() (asyncio モジュール):      イントロスペクション.
                                                             (line   16)
* allocate_lock() (_thread モジュール):  _thread --- 低水準なスレッド API.
                                                             (line   81)
* allocfunc (C type):                    Slot Type typedefs. (line    6)
* allow_reuse_address (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line   90)
* allowed_domains() (http.cookiejar.DefaultCookiePolicy のメソッド): DefaultCookiePolicy オブジェクト.
                                                             (line   64)
* ALT_DIGITS (locale モジュール):        locale --- 国際化サービス.
                                                             (line  316)
* alt() (curses.ascii モジュール):       curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  218)
* altsep (os モジュール):                雑多なシステム情報. (line  122)
* altzone (time モジュール):             Timezone Constants. (line    6)
* ALWAYS_EQ (test.support モジュール):   test support --- テストのためのユーティリティ関数.
                                                             (line  178)
* ALWAYS_TYPED_ACTIONS (optparse.Option の属性): 新しいアクションの追加.
                                                             (line   44)
* AmbiguousOptionError:                  例外<20>.           (line   25)
* AMPER (token モジュール):              token --- Python 解析木で使われる定数.
                                                             (line   99)
* AMPEREQUAL (token モジュール):         token --- Python 解析木で使われる定数.
                                                             (line  187)
* Anchor (importlib.resources のクラス): importlib resources -- パッケージリソースの読み取り、オープン、アクセス.
                                                             (line   46)
* anchor (pathlib.PurePath の属性):      メソッドとプロパティ.
                                                             (line   65)
* And (ast のクラス):                    式 expression<2>.   (line   89)
* and_() (operator モジュール):          operator --- 関数形式の標準演算子.
                                                             (line   80)
* android_ver() (platform モジュール):   Android プラットフォーム.
                                                             (line    6)
* AnnAssign (ast のクラス):              文 Statements.      (line   41)
* Annotated (typing モジュール):         特殊形式.           (line  257)
* annotated;代入:                        注釈付き代入文 annotated assignment statements.
                                                             (line    6)
* annotation:                            用語集<2>.          (line   36)
* annotation (inspect.Parameter の属性): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  223)
* ANNOTATION (symtable.SymbolTableType の属性): 記号表の検査.
                                                             (line   26)
* answer_challenge() (multiprocessing.connection モジュール): リスナーとクライアント.
                                                             (line   25)
* anticipate_failure() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  455)
* Any (typing モジュール):               特殊型.             (line    9)
* ANY (unittest.mock モジュール):        ANY.                (line    6)
* ANY_CONTIGUOUS (inspect.BufferFlags の属性): Buffer flags. (line   29)
* AnyStr (typing モジュール):            特殊型.             (line   21)
* api_version (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line 1974)
* apilevel (sqlite3 モジュール):         モジュール定数.     (line   58)
* apop() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   40)
* APPDATA:                               PEP 370 ユーザごとの site-packages ディレクトリ.
                                                             (line   25)
* append_history_file() (readline モジュール): 履歴ファイル. (line   20)
* append() (array.array のメソッド):     array --- 効率的な数値配列.
                                                             (line  120)
* append() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   35)
* append() (email.header.Header のメソッド): email header 国際化されたヘッダー.
                                                             (line   93)
* append() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line   31)
* append() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   83)
* append() (シーケンスのメソッド):       ミュータブルなシーケンス型.
                                                             (line   16)
* appendChild() (xml.dom.Node のメソッド): Node オブジェクト.
                                                             (line  114)
* appendleft() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   39)
* AppleFrameworkLoader (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  441)
* application_uri() (wsgiref.util モジュール): wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line   33)
* apply_async() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line   75)
* apply_defaults() (inspect.BoundArguments のメソッド): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  363)
* apply() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line   67)
* APRIL (calendar モジュール):           calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* architecture() (platform モジュール):  クロスプラットフォーム.
                                                             (line    6)
* archive (zipimport.zipimporter の属性): zipimporter オブジェクト.
                                                             (line   96)
* AREGTYPE (tarfile モジュール):         tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  276)
* aRepr (reprlib モジュール):            reprlib --- もう一つの repr の実装.
                                                             (line   42)
* arg (ast のクラス):                    関数およびクラス定義.
                                                             (line   67)
* args (BaseException の属性):           基底クラス.         (line   16)
* args (functools.partial の属性):       partial オブジェクト.
                                                             (line   16)
* args (inspect.BoundArguments の属性):  Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  348)
* args (pdb command):                    デバッガコマンド.   (line  257)
* args (subprocess.CompletedProcess の属性): subprocess モジュールを使う.
                                                             (line  104)
* args (subprocess.Popen の属性):        Popen オブジェクト. (line  103)
* args (typing.ParamSpec の属性):        Building generic types and type aliases.
                                                             (line  408)
* args_from_interpreter_flags() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  322)
* argtypes (ctypes._CFuncPtr の属性):    外部関数.           (line   45)
* ArgumentDefaultsHelpFormatter (argparse のクラス): formatter_class.
                                                             (line   10)
* ArgumentError:                         例外<9>.            (line    6)
* ArgumentError <1>:                     外部関数.           (line   90)
* ArgumentParser (argparse のクラス):    ArgumentParser オブジェクト.
                                                             (line    6)
* arguments (ast のクラス):              関数およびクラス定義.
                                                             (line   49)
* arguments (inspect.BoundArguments の属性): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  329)
* ArgumentTypeError:                     例外<9>.            (line   14)
* argv (in module sys):                  プロセスワイドのパラメータ.
                                                             (line  216)
* argv (in module sys) <1>:              PyConfig.           (line  129)
* argv (sys モジュール):                 sys --- システム固有のパラメーターと関数.
                                                             (line   68)
* ArithmeticError:                       基底クラス.         (line   68)
* array (array のクラス):                array --- 効率的な数値配列.
                                                             (line   87)
* Array (ctypes のクラス):               配列とポインタ.     (line    6)
* ARRAY() (ctypes モジュール):           配列とポインタ.     (line   31)
* Array() (multiprocessing モジュール):  共有 ctypes オブジェクト.
                                                             (line   42)
* Array() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  215)
* Array() (multiprocessing.sharedctypes モジュール): multiprocessing sharedctypes モジュール.
                                                             (line   51)
* arrays:                                array --- 効率的な数値配列.
                                                             (line    6)
* arraysize (sqlite3.Cursor の属性):     Cursor オブジェクト.
                                                             (line  170)
* AS pattern, OR pattern, capture pattern, wildcard pattern: パターン.
                                                             (line    6)
* as_bytes() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  107)
* as_bytes() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  107)
* as_completed() (asyncio モジュール):   要素の終了待機.     (line   60)
* as_completed() (concurrent.futures モジュール): モジュール関数<2>.
                                                             (line   43)
* as_file() (importlib.resources モジュール): importlib resources -- パッケージリソースの読み取り、オープン、アクセス.
                                                             (line   74)
* as_integer_ratio() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  117)
* as_integer_ratio() (float のメソッド): 浮動小数点数に対する追加のメソッド.
                                                             (line    9)
* as_integer_ratio() (fractions.Fraction のメソッド): fractions --- 有理数.
                                                             (line  119)
* as_integer_ratio() (int のメソッド):   整数型における追加のメソッド.
                                                             (line  158)
* as_posix() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  172)
* as_string() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line   61)
* as_string() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line   60)
* as_tuple() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  130)
* as_uri() (pathlib.Path のメソッド):    URIのパースと生成.  (line   42)
* as;except clause:                      except 節.          (line   28)
* as;import statement:                   import 文.          (line   39)
* as;match statement:                    match 文<2>.        (line    6)
* as;with statement:                     with 文.            (line    6)
* ASCII:                                 本マニュアルにおける表記法.
                                                             (line   31)
* ASCII <1>:                             リテラル.           (line    8)
* ASCII (re モジュール):                 フラグ.             (line   16)
* ascii_letters (string モジュール):     文字列定数.         (line    8)
* ascii_lowercase (string モジュール):   文字列定数.         (line   13)
* ascii_uppercase (string モジュール):   文字列定数.         (line   18)
* ascii() (curses.ascii モジュール):     curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  209)
* asctime() (time モジュール):           関数<5>.            (line    6)
* asdict() (dataclasses モジュール):     モジュールの内容<4>.
                                                             (line  327)
* asend() (agen のメソッド):             非同期ジェネレータイテレータメソッド.
                                                             (line   27)
* asin() (cmath モジュール):             三角関数<2>.        (line   12)
* asin() (math モジュール):              三角関数.           (line   10)
* asinh() (cmath モジュール):            双曲線関数<2>.      (line   11)
* asinh() (math モジュール):             双曲線関数.         (line   13)
* askcolor() (tkinter.colorchooser モジュール): tkinter colorchooser --- カラー選択ダイアログ.
                                                             (line   17)
* askdirectory() (tkinter.filedialog モジュール): ネイティブの読み込み/保存ダイアログ.
                                                             (line   53)
* askfloat() (tkinter.simpledialog モジュール): tkinter simpledialog --- 標準 Tkinter 入力ダイアログ.
                                                             (line   13)
* askinteger() (tkinter.simpledialog モジュール): tkinter simpledialog --- 標準 Tkinter 入力ダイアログ.
                                                             (line   13)
* askokcancel() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  119)
* askopenfile() (tkinter.filedialog モジュール): ネイティブの読み込み/保存ダイアログ.
                                                             (line   30)
* askopenfilename() (tkinter.filedialog モジュール): ネイティブの読み込み/保存ダイアログ.
                                                             (line   41)
* askopenfilenames() (tkinter.filedialog モジュール): ネイティブの読み込み/保存ダイアログ.
                                                             (line   41)
* askopenfiles() (tkinter.filedialog モジュール): ネイティブの読み込み/保存ダイアログ.
                                                             (line   30)
* askquestion() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  113)
* askretrycancel() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  126)
* asksaveasfile() (tkinter.filedialog モジュール): ネイティブの読み込み/保存ダイアログ.
                                                             (line   36)
* asksaveasfilename() (tkinter.filedialog モジュール): ネイティブの読み込み/保存ダイアログ.
                                                             (line   48)
* askstring() (tkinter.simpledialog モジュール): tkinter simpledialog --- 標準 Tkinter 入力ダイアログ.
                                                             (line   13)
* askyesno() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  133)
* askyesnocancel() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  139)
* Assert (ast のクラス):                 文 Statements.      (line  127)
* assert_any_await() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  815)
* assert_any_call() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  148)
* assert_awaited_once_with() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  798)
* assert_awaited_once() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  765)
* assert_awaited_with() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  781)
* assert_awaited() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  745)
* assert_called_once_with() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  133)
* assert_called_once() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  105)
* assert_called_with() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  123)
* assert_called() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line   94)
* assert_has_awaits() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  832)
* assert_has_calls() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  164)
* assert_never() (typing モジュール):    Functions and decorators.
                                                             (line   43)
* assert_not_awaited() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  859)
* assert_not_called() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  187)
* assert_python_failure() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   57)
* assert_python_ok() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   40)
* assert_type() (typing モジュール):     Functions and decorators.
                                                             (line   14)
* assertAlmostEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  514)
* assertCountEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  570)
* assertDictEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  679)
* assertEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  178)
* assertFalse() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  201)
* assertGreater() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  538)
* assertGreaterEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  538)
* assertIn() (unittest.TestCase のメソッド): テストクラス.   (line  230)
* assertInBytecode() (test.support.bytecode_helper.BytecodeTestCase のメソッド): test support bytecode_helper --- Support tools for testing correct bytecode generation.
                                                             (line   22)
* AssertionError:                        具象例外.           (line    8)
* assertIs() (unittest.TestCase のメソッド): テストクラス.   (line  214)
* assertIsInstance() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  238)
* assertIsNone() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  222)
* assertIsNot() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  214)
* assertIsNotNone() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  222)
* assertLess() (unittest.TestCase のメソッド): テストクラス. (line  538)
* assertLessEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  538)
* assertListEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  656)
* assertLogs() (unittest.TestCase のメソッド): テストクラス. (line  415)
* assertMultiLineEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  632)
* assertNoLogs() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  459)
* assertNotAlmostEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  514)
* assertNotEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  196)
* assertNotIn() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  230)
* assertNotInBytecode() (test.support.bytecode_helper.BytecodeTestCase のメソッド): test support bytecode_helper --- Support tools for testing correct bytecode generation.
                                                             (line   28)
* assertNotIsInstance() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  238)
* assertNotRegex() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  552)
* assertRaises() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  280)
* assertRaisesRegex() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  322)
* assertRegex() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  552)
* assertSequenceEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  642)
* assertSetEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  667)
* assertTrue() (unittest.TestCase のメソッド): テストクラス. (line  201)
* assertTupleEqual() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  656)
* assertWarns() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  349)
* assertWarnsRegex() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  391)
* Assign (ast のクラス):                 文 Statements.      (line    6)
* assignment expression:                 ブール演算 boolean operation.
                                                             (line   34)
* AST (ast のクラス):                    Node クラス.        (line    6)
* ast コマンドラインオプション; -a:      コマンドラインからの使用<4>.
                                                             (line   29)
* ast コマンドラインオプション; -h:      コマンドラインからの使用<4>.
                                                             (line   15)
* ast コマンドラインオプション; -help:   コマンドラインからの使用<4>.
                                                             (line   15)
* ast コマンドラインオプション; -i:      コマンドラインからの使用<4>.
                                                             (line   33)
* ast コマンドラインオプション; -include-attributes: コマンドラインからの使用<4>.
                                                             (line   29)
* ast コマンドラインオプション; -indent: コマンドラインからの使用<4>.
                                                             (line   33)
* ast コマンドラインオプション; -m:      コマンドラインからの使用<4>.
                                                             (line   19)
* ast コマンドラインオプション; -mode:   コマンドラインからの使用<4>.
                                                             (line   19)
* ast コマンドラインオプション; -no-type-comments: コマンドラインからの使用<4>.
                                                             (line   25)
* astimezone() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  477)
* astuple() (dataclasses モジュール):    モジュールの内容<4>.
                                                             (line  359)
* async for;in comprehensions:           リスト、集合、辞書の表示.
                                                             (line   14)
* AsyncContextDecorator (contextlib のクラス): ユーティリティ.
                                                             (line  470)
* AsyncContextManager (typing のクラス): Aliases to contextlib ABCs.
                                                             (line   25)
* asynccontextmanager() (contextlib モジュール): ユーティリティ.
                                                             (line   94)
* AsyncExitStack (contextlib のクラス):  ユーティリティ.     (line  622)
* AsyncFor (ast のクラス):               async と await.     (line   34)
* AsyncFunctionDef (ast のクラス):       async と await.     (line    6)
* AsyncGenerator (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  167)
* AsyncGenerator (typing のクラス):      Aliases to asynchronous ABCs in collections abc.
                                                             (line   21)
* AsyncGeneratorType (types モジュール): 標準的なインタプリタ型.
                                                             (line   48)
* asynchronous context manager:          用語集<2>.          (line   80)
* asynchronous generator:                用語集<2>.          (line   87)
* asynchronous generator iterator:       用語集<2>.          (line  102)
* asynchronous generator;asynchronous iterator: 非同期ジェネレータ関数 asynchronous generator function.
                                                             (line    6)
* asynchronous generator;関数:           非同期ジェネレータ関数 asynchronous generator function.
                                                             (line    6)
* asynchronous iterable:                 用語集<2>.          (line  118)
* asynchronous iterator:                 用語集<2>.          (line  125)
* asyncio.subprocess.DEVNULL (組み込み変数): 定数<7>.        (line   22)
* asyncio.subprocess.PIPE (組み込み変数): 定数<7>.           (line    6)
* asyncio.subprocess.Process (組み込みクラス): サブプロセスとやりとりする.
                                                             (line   11)
* asyncio.subprocess.STDOUT (組み込み変数): 定数<7>.         (line   17)
* AsyncIterable (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  153)
* AsyncIterable (typing のクラス):       Aliases to asynchronous ABCs in collections abc.
                                                             (line   38)
* AsyncIterator (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  160)
* AsyncIterator (typing のクラス):       Aliases to asynchronous ABCs in collections abc.
                                                             (line   48)
* AsyncMock (unittest.mock のクラス):    Mock クラス.        (line  673)
* AsyncResult (multiprocessing.pool のクラス): プロセスプール.
                                                             (line  197)
* asyncSetUp() (unittest.IsolatedAsyncioTestCase のメソッド): テストクラス.
                                                             (line  863)
* asyncTearDown() (unittest.IsolatedAsyncioTestCase のメソッド): テストクラス.
                                                             (line  872)
* AsyncWith (ast のクラス):              async と await.     (line   34)
* AT (token モジュール):                 token --- Python 解析木で使われる定数.
                                                             (line  219)
* at_eof() (asyncio.StreamReader のメソッド): StreamReader.  (line   84)
* atan() (cmath モジュール):             三角関数<2>.        (line   17)
* atan() (math モジュール):              三角関数.           (line   15)
* atan2() (math モジュール):             三角関数.           (line   20)
* atanh() (cmath モジュール):            双曲線関数<2>.      (line   17)
* atanh() (math モジュール):             双曲線関数.         (line   17)
* ATEQUAL (token モジュール):            token --- Python 解析木で使われる定数.
                                                             (line  223)
* atexit (weakref.finalize の属性):      weakref --- 弱参照. (line  307)
* athrow() (agen のメソッド):            非同期ジェネレータイテレータメソッド.
                                                             (line   42)
* atof() (locale モジュール):            locale --- 国際化サービス.
                                                             (line  479)
* atoi() (locale モジュール):            locale --- 国際化サービス.
                                                             (line  485)
* atom:                                  アトム、原子的要素 atom.
                                                             (line    6)
* attach_loop() (asyncio.AbstractChildWatcher のメソッド): プロセスのウオッチャー.
                                                             (line   66)
* attach_mock() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  237)
* attach() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  168)
* attempted (doctest.TestResults の属性): TestResults objects.
                                                             (line   12)
* AttlistDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  239)
* attrgetter() (operator モジュール):    operator --- 関数形式の標準演算子.
                                                             (line  227)
* attrib (xml.etree.ElementTree.Element の属性): Element オブジェクト.
                                                             (line   46)
* Attribute (ast のクラス):              式 expression<2>.   (line  172)
* AttributeError:                        具象例外.           (line   12)
* attributes (xml.dom.Node の属性):      Node オブジェクト.  (line   26)
* AttributesImpl (xml.sax.xmlreader のクラス): xml sax xmlreader --- XML パーサーのインターフェース.
                                                             (line   67)
* AttributesNSImpl (xml.sax.xmlreader のクラス): xml sax xmlreader --- XML パーサーのインターフェース.
                                                             (line   77)
* attroff() (curses.window のメソッド):  Window オブジェクト.
                                                             (line   51)
* attron() (curses.window のメソッド):   Window オブジェクト.
                                                             (line   56)
* attrset() (curses.window のメソッド):  Window オブジェクト.
                                                             (line   61)
* audit() (sys モジュール):              sys --- システム固有のパラメーターと関数.
                                                             (line   88)
* auditing:                              sys --- システム固有のパラメーターと関数.
                                                             (line   90)
* AugAssign (ast のクラス):              文 Statements.      (line   95)
* augmented;代入:                        累算代入文 augmented assignment statement.
                                                             (line    6)
* AUGUST (calendar モジュール):          calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* auth() (ftplib.FTP_TLS のメソッド):    FTP_TLS オブジェクト.
                                                             (line   89)
* auth() (smtplib.SMTP のメソッド):      SMTP オブジェクト.  (line  136)
* authenticate() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line   35)
* AuthenticationError:                   Process クラスと例外.
                                                             (line  239)
* authenticators() (netrc.netrc のメソッド): netrc オブジェクト.
                                                             (line    8)
* authkey (multiprocessing.Process の属性): Process クラスと例外.
                                                             (line  142)
* auto (enum のクラス):                  ユーティリティとデコレータ.
                                                             (line    6)
* autocommit (sqlite3.Connection の属性): Connection オブジェクト.
                                                             (line  745)
* autorange() (timeit.Timer のメソッド): Python インターフェイス.
                                                             (line   87)
* available_timezones() (zoneinfo モジュール): 関数<3>.      (line    6)
* avoids_symlink_attacks (shutil.rmtree の属性): ディレクトリとファイルの操作.
                                                             (line  326)
* Await (ast のクラス):                  async と await.     (line   14)
* await_args (unittest.mock.AsyncMock の属性): Mock クラス.  (line  888)
* await_args_list (unittest.mock.AsyncMock の属性): Mock クラス.
                                                             (line  906)
* await_count (unittest.mock.AsyncMock の属性): Mock クラス. (line  872)
* await;in comprehensions:               リスト、集合、辞書の表示.
                                                             (line   41)
* awaitable:                             用語集<2>.          (line  147)
* Awaitable (collections.abc のクラス):  コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  111)
* Awaitable (typing のクラス):           Aliases to asynchronous ABCs in collections abc.
                                                             (line   58)
* b';バイト列リテラル:                   文字列およびバイト列リテラル.
                                                             (line   46)
* b";バイト列リテラル:                   文字列およびバイト列リテラル.
                                                             (line   46)
* b16decode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  159)
* b16encode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  154)
* b2a_base64() (binascii モジュール):    binascii --- バイナリ と ASCII 間の変換.
                                                             (line   62)
* b2a_hex() (binascii モジュール):       binascii --- バイナリ と ASCII 間の変換.
                                                             (line  115)
* b2a_qp() (binascii モジュール):        binascii --- バイナリ と ASCII 間の変換.
                                                             (line   77)
* b2a_uu() (binascii モジュール):        binascii --- バイナリ と ASCII 間の変換.
                                                             (line   31)
* b32decode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  112)
* b32encode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  107)
* b32hexdecode() (base64 モジュール):    base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  142)
* b32hexencode() (base64 モジュール):    base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  135)
* b64decode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   57)
* b64encode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   42)
* b85decode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  228)
* b85encode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  217)
* Babyl (mailbox のクラス):              Babyl オブジェクト. (line    6)
* BabylMessage (mailbox のクラス):       BabylMessage オブジェクト.
                                                             (line    6)
* back() (turtle モジュール):            Turtle の動き.      (line   24)
* backend (readline モジュール):         readline --- GNU readline のインターフェース.
                                                             (line   49)
* backslashreplace_errors() (codecs モジュール): エラーハンドラ.
                                                             (line  154)
* backslashreplace;error handler's name: エラーハンドラ.     (line   14)
* backup() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  539)
* backward() (turtle モジュール):        Turtle の動き.      (line   24)
* BadGzipFile:                           gzip --- gzip ファイルのサポート.
                                                             (line   63)
* BadOptionError:                        例外<20>.           (line   21)
* BadStatusLine:                         http client --- HTTP プロトコルクライアント.
                                                             (line  183)
* BadZipFile:                            zipfile --- ZIP アーカイブの処理.
                                                             (line   25)
* BadZipfile:                            zipfile --- ZIP アーカイブの処理.
                                                             (line   31)
* Barrier (asyncio のクラス):            Barrier.            (line    6)
* Barrier (multiprocessing のクラス):    同期プリミティブ.   (line   13)
* Barrier (threading のクラス):          バリアオブジェクト. (line   34)
* Barrier() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  162)
* base_exec_prefix (sys モジュール):     sys --- システム固有のパラメーターと関数.
                                                             (line  119)
* base_prefix (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line  131)
* base64;encoding:                       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line    8)
* BaseCGIHandler (wsgiref.handlers のクラス): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line   54)
* BaseCookie (http.cookies のクラス):    http cookies --- HTTP の状態管理.
                                                             (line   38)
* BaseException:                         基底クラス.         (line    8)
* BaseExceptionGroup:                    例外グループ.       (line   13)
* BaseHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  274)
* BaseHandler (wsgiref.handlers のクラス): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line   89)
* BaseHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line   39)
* BaseHTTPRequestHandler (http.server のクラス): http server --- HTTP サーバー.
                                                             (line   51)
* BaseManager (multiprocessing.managers のクラス): マネージャー.
                                                             (line   24)
* basename() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line   56)
* BaseProtocol (asyncio のクラス):       基底プロトコル.     (line    6)
* BaseProxy (multiprocessing.managers のクラス): Proxy オブジェクト.
                                                             (line   91)
* BaseRequestHandler (socketserver のクラス): Request Handler Objects.
                                                             (line    6)
* BaseRotatingHandler (logging.handlers のクラス): BaseRotatingHandler.
                                                             (line   12)
* BaseSelector (selectors のクラス):     クラス<4>.          (line   54)
* BaseServer (socketserver のクラス):    Serverオブジェクト<2>.
                                                             (line    6)
* BaseTransport (asyncio のクラス):      トランスポートのクラス階層構造.
                                                             (line    6)
* basicConfig() (logging モジュール):    モジュールレベルの関数.
                                                             (line  196)
* BasicContext (decimal のクラス):       Context オブジェクト.
                                                             (line   63)
* BasicInterpolation (configparser のクラス): 値の補間.      (line   10)
* batched() (itertools モジュール):      Itertool関数.       (line   71)
* baudrate() (curses モジュール):        関数<6>.            (line   18)
* bbox() (tkinter.ttk.Treeview のメソッド): ttk Treeview.    (line    8)
* BDADDR_ANY (socket モジュール):        定数<8>.            (line  298)
* BDADDR_LOCAL (socket モジュール):      定数<8>.            (line  298)
* Bdb (bdb のクラス):                    bdb --- デバッガーフレームワーク.
                                                             (line  130)
* BdbQuit:                               bdb --- デバッガーフレームワーク.
                                                             (line   15)
* BDFL:                                  用語集<2>.          (line  153)
* beep() (curses モジュール):            関数<6>.            (line   26)
* Beep() (winsound モジュール):          winsound --- Windows 用の音声再生インターフェース.
                                                             (line   12)
* BEFORE_ASYNC_WITH (opcode):            Python バイトコード命令.
                                                             (line  352)
* BEFORE_WITH (opcode):                  Python バイトコード命令.
                                                             (line  504)
* begin_fill() (turtle モジュール):      塗りつぶし.         (line   16)
* begin_poly() (turtle モジュール):      特別な Turtle のメソッド.
                                                             (line    6)
* BEL (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   39)
* BELOW_NORMAL_PRIORITY_CLASS (subprocess モジュール): Windows Constants.
                                                             (line   75)
* below() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   17)
* betavariate() (random モジュール):     実数分布.           (line   29)
* bgcolor() (turtle モジュール):         ウィンドウの制御.   (line    6)
* bgpic() (turtle モジュール):           ウィンドウの制御.   (line   21)
* bidirectional() (unicodedata モジュール): unicodedata --- Unicode データベース.
                                                             (line   53)
* bigaddrspacetest() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  569)
* BigEndianStructure (ctypes のクラス):  構造化データ型.     (line   24)
* BigEndianUnion (ctypes のクラス):      構造化データ型.     (line   10)
* bigmemtest() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  553)
* Binary (xmlrpc.client のクラス):       Binary オブジェクト.
                                                             (line    6)
* binary file:                           用語集<2>.          (line  158)
* binary semaphores:                     _thread --- 低水準なスレッド API.
                                                             (line    6)
* BINARY_OP (opcode):                    Python バイトコード命令.
                                                             (line  233)
* BINARY_SLICE (opcode):                 Python バイトコード命令.
                                                             (line  269)
* BINARY_SUBSCR (opcode):                Python バイトコード命令.
                                                             (line  244)
* binaryfunc (C type):                   Slot Type typedefs. (line  120)
* BinaryIO (typing のクラス):            ABCs for working with IO.
                                                             (line    6)
* bind (widgets):                        バインドとイベント. (line    6)
* bind_partial() (inspect.Signature のメソッド): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  129)
* bind_port() (test.support.socket_helper モジュール): test support socket_helper --- Utilities for socket tests.
                                                             (line   37)
* bind_textdomain_codeset() (locale モジュール): メッセージカタログへのアクセス.
                                                             (line   16)
* bind_unix_socket() (test.support.socket_helper モジュール): test support socket_helper --- Utilities for socket tests.
                                                             (line   54)
* bind() (inspect.Signature のメソッド): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  122)
* bind() (socket.socket のメソッド):     socket オブジェクト.
                                                             (line   30)
* bindtextdomain() (gettext モジュール): GNU gettext API.    (line   14)
* bindtextdomain() (locale モジュール):  メッセージカタログへのアクセス.
                                                             (line   14)
* binomialvariate() (random モジュール): Discrete distributions.
                                                             (line    8)
* BinOp (ast のクラス):                  式 expression<2>.   (line   43)
* bisect_left() (bisect モジュール):     bisect --- 配列二分法アルゴリズム.
                                                             (line   24)
* bisect_right() (bisect モジュール):    bisect --- 配列二分法アルゴリズム.
                                                             (line   48)
* bisect() (bisect モジュール):          bisect --- 配列二分法アルゴリズム.
                                                             (line   48)
* bit_count() (int のメソッド):          整数型における追加のメソッド.
                                                             (line   34)
* bit_length() (int のメソッド):         整数型における追加のメソッド.
                                                             (line    9)
* BitAnd (ast のクラス):                 式 expression<2>.   (line   55)
* BitOr (ast のクラス):                  式 expression<2>.   (line   55)
* bits_per_digit (sys.int_info の属性):  sys --- システム固有のパラメーターと関数.
                                                             (line 1119)
* BitXor (ast のクラス):                 式 expression<2>.   (line   55)
* bk() (turtle モジュール):              Turtle の動き.      (line   24)
* bkgd() (curses.window のメソッド):     Window オブジェクト.
                                                             (line   66)
* bkgdset() (curses.window のメソッド):  Window オブジェクト.
                                                             (line   77)
* blake2b, blake2s:                      BLAKE2.             (line    6)
* blake2b.MAX_DIGEST_SIZE (hashlib モジュール): 定数<5>.     (line   24)
* blake2b.MAX_KEY_SIZE (hashlib モジュール): 定数<5>.        (line   18)
* blake2b.PERSON_SIZE (hashlib モジュール): 定数<5>.         (line   12)
* blake2b.SALT_SIZE (hashlib モジュール): 定数<5>.           (line    6)
* blake2b() (hashlib モジュール):        ハッシュオブジェクトの作成.
                                                             (line    9)
* blake2s.MAX_DIGEST_SIZE (hashlib モジュール): 定数<5>.     (line   26)
* blake2s.MAX_KEY_SIZE (hashlib モジュール): 定数<5>.        (line   20)
* blake2s.PERSON_SIZE (hashlib モジュール): 定数<5>.         (line   14)
* blake2s.SALT_SIZE (hashlib モジュール): 定数<5>.           (line    8)
* blake2s() (hashlib モジュール):        ハッシュオブジェクトの作成.
                                                             (line   14)
* BLKTYPE (tarfile モジュール):          tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  293)
* Blob (sqlite3 のクラス):               Blob オブジェクト.  (line    6)
* blobopen() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line   35)
* block_on_close (socketserver.ThreadingMixIn の属性): サーバ生成に関するノート.
                                                             (line   45)
* block_size (hmac.HMAC の属性):         hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   94)
* blocked_domains() (http.cookiejar.DefaultCookiePolicy のメソッド): DefaultCookiePolicy オブジェクト.
                                                             (line   51)
* BlockingIOError:                       OS 例外.            (line    9)
* BlockingIOError <1>:                   高水準のモジュールインターフェイス.
                                                             (line   67)
* blocksize (http.client.HTTPConnection の属性): HTTPConnection オブジェクト.
                                                             (line  158)
* BNF:                                   本マニュアルにおける表記法.
                                                             (line    6)
* BNF <1>:                               式 expression.      (line    6)
* body_encode() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line  141)
* body_encoding (email.charset.Charset の属性): email charset 文字集合の表現.
                                                             (line   69)
* body_line_iterator() (email.iterators モジュール): email iterators イテレータ.
                                                             (line   15)
* body() (tkinter.simpledialog.Dialog のメソッド): tkinter simpledialog --- 標準 Tkinter 入力ダイアログ.
                                                             (line   24)
* BOLD (tkinter.font モジュール):        tkinter font --- Tkinter フォントラッパー.
                                                             (line   15)
* BOM (codecs モジュール):               codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_BE (codecs モジュール):            codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_LE (codecs モジュール):            codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_UTF16 (codecs モジュール):         codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_UTF16_BE (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_UTF16_LE (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_UTF32 (codecs モジュール):         codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_UTF32_BE (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_UTF32_LE (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* BOM_UTF8 (codecs モジュール):          codecs --- codec レジストリと基底クラス.
                                                             (line  253)
* bool (組み込みクラス):                 組み込み関数.       (line  131)
* BOOLEAN_STATES (configparser.ConfigParser の属性): パーサーの振る舞いをカスタマイズする.
                                                             (line  234)
* Boolean;''values'':                    ブーリアン型 - bool.
                                                             (line    9)
* Boolean;type:                          組み込み関数.       (line  142)
* Boolean;操作:                          真理値判定.         (line    6)
* Boolean;操作 <1>:                      ブール演算 --- and or not.
                                                             (line    6)
* Boolean;演算:                          ブール演算 boolean operation.
                                                             (line    6)
* BooleanOptionalAction (argparse のクラス): action.         (line  104)
* BoolOp (ast のクラス):                 式 expression<2>.   (line   71)
* bootstrap() (ensurepip モジュール):    モジュール API.     (line   14)
* border() (curses.window のメソッド):   Window オブジェクト.
                                                             (line   86)
* borrowed reference:                    用語集<2>.          (line  170)
* bottom_panel() (curses.panel モジュール): 関数<7>.         (line    8)
* bottom() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   21)
* BoundArguments (inspect のクラス):     Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  323)
* BoundaryError:                         email errors Exception and Defect classes.
                                                             (line   38)
* BoundedSemaphore (asyncio のクラス):   BoundedSemaphore.   (line    6)
* BoundedSemaphore (multiprocessing のクラス): 同期プリミティブ.
                                                             (line   20)
* BoundedSemaphore (threading のクラス): Semaphore オブジェクト.
                                                             (line   73)
* BoundedSemaphore() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  169)
* box() (curses.window のメソッド):      Window オブジェクト.
                                                             (line  125)
* bpbynumber (bdb.Breakpoint の属性):    bdb --- デバッガーフレームワーク.
                                                             (line  111)
* bpformat() (bdb.Breakpoint のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line   57)
* bplist (bdb.Breakpoint の属性):        bdb --- デバッガーフレームワーク.
                                                             (line  116)
* bpprint() (bdb.Breakpoint のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line   76)
* BRANCH (monitoring event):             Events.             (line    8)
* Break (ast のクラス):                  制御フロー.         (line   99)
* break (pdb command):                   デバッガコマンド.   (line   94)
* break_anywhere() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  264)
* break_here() (bdb.Bdb のメソッド):     bdb --- デバッガーフレームワーク.
                                                             (line  255)
* break_long_words (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  241)
* break_on_hyphens (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  250)
* Breakpoint (bdb のクラス):             bdb --- デバッガーフレームワーク.
                                                             (line   21)
* breakpointhook() (sys モジュール):     sys --- システム固有のパラメーターと関数.
                                                             (line  230)
* breakpoints:                           Help メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   31)
* broadcast_address (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   88)
* broadcast_address (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  311)
* broken (asyncio.Barrier の属性):       Barrier.            (line  104)
* broken (threading.Barrier の属性):     バリアオブジェクト. (line  100)
* BrokenBarrierError:                    バリアオブジェクト. (line  104)
* BrokenBarrierError <1>:                Barrier.            (line  108)
* BrokenExecutor:                        例外クラス.         (line   18)
* BrokenPipeError:                       OS 例外.            (line   38)
* BrokenProcessPool:                     例外クラス.         (line   41)
* BrokenThreadPool:                      例外クラス.         (line   33)
* BROWSER:                               webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   20)
* BROWSER <1>:                           webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   32)
* BROWSER <2>:                           webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line  118)
* BS (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   42)
* BsdDbShelf (shelve のクラス):          制限事項.           (line   61)
* buf (multiprocessing.shared_memory.SharedMemory の属性): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  115)
* Buffer (collections.abc のクラス):     コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  177)
* buffer (io.TextIOBase の属性):         テキスト I/O<2>.    (line   30)
* buffer (unittest.TestResult の属性):   テストのロードと起動.
                                                             (line  289)
* buffer interface;(see buffer protocol): イテレータプロトコル iterator protocol.
                                                             (line   78)
* buffer object;(see buffer protocol):   イテレータプロトコル iterator protocol.
                                                             (line   77)
* buffer protocol:                       イテレータプロトコル iterator protocol.
                                                             (line   78)
* buffer protocol;str (組み込みクラス):  テキストシーケンス型 --- str.
                                                             (line   60)
* buffer protocol;バイナリシーケンス型:  printf 形式の文字列書式化.
                                                             (line  184)
* buffer size, I/O:                      組み込み関数.       (line 1455)
* buffer_info() (array.array のメソッド): array --- 効率的な数値配列.
                                                             (line  124)
* buffer_size (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  118)
* buffer_text (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  124)
* buffer_updated() (asyncio.BufferedProtocol のメソッド): バッファリングされたストリーミングプロトコル.
                                                             (line   34)
* buffer_used (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  135)
* BufferedIOBase (io のクラス):          I/O 基底クラス.     (line  223)
* BufferedProtocol (asyncio のクラス):   基底プロトコル.     (line   16)
* BufferedRandom (io のクラス):          バッファ付きストリーム.
                                                             (line  140)
* BufferedReader (io のクラス):          バッファ付きストリーム.
                                                             (line   57)
* BufferedRWPair (io のクラス):          バッファ付きストリーム.
                                                             (line  156)
* BufferedWriter (io のクラス):          バッファ付きストリーム.
                                                             (line   99)
* BufferError:                           基底クラス.         (line   74)
* BufferFlags (inspect のクラス):        Buffer flags.       (line    6)
* BufferingFormatter (logging のクラス): フォーマッタオブジェクト.
                                                             (line  128)
* BufferingHandler (logging.handlers のクラス): MemoryHandler.
                                                             (line   19)
* BufferTooShort:                        Process クラスと例外.
                                                             (line  231)
* BUILD_CONST_KEY_MAP (opcode):          Python バイトコード命令.
                                                             (line  688)
* BUILD_LIST (opcode):                   Python バイトコード命令.
                                                             (line  668)
* BUILD_MAP (opcode):                    Python バイトコード命令.
                                                             (line  678)
* build_opener() (urllib.request モジュール): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  124)
* BUILD_SET (opcode):                    Python バイトコード命令.
                                                             (line  673)
* BUILD_SLICE (opcode):                  Python バイトコード命令.
                                                             (line 1122)
* BUILD_STRING (opcode):                 Python バイトコード命令.
                                                             (line  697)
* BUILD_TUPLE (opcode):                  Python バイトコード命令.
                                                             (line  655)
* built-in function; __import__():       組み込み関数.       (line 2155)
* built-in function; abs():              組み込み関数.       (line   43)
* built-in function; aiter():            組み込み関数.       (line   49)
* built-in function; all():              組み込み関数.       (line   59)
* built-in function; anext():            組み込み関数.       (line   70)
* built-in function; any():              組み込み関数.       (line   90)
* built-in function; ascii():            組み込み関数.       (line  101)
* built-in function; bin():              組み込み関数.       (line  109)
* built-in function; breakpoint():       組み込み関数.       (line  144)
* built-in function; callable():         組み込み関数.       (line  228)
* built-in function; chr():              組み込み関数.       (line  241)
* built-in function; classmethod():      組み込み関数.       (line  250)
* built-in function; compile():          組み込み関数.       (line  289)
* built-in function; delattr():          組み込み関数.       (line  434)
* built-in function; dir():              組み込み関数.       (line  457)
* built-in function; divmod():           組み込み関数.       (line  516)
* built-in function; enumerate():        組み込み関数.       (line  527)
* built-in function; eval():             組み込み関数.       (line  550)
* built-in function; exec():             組み込み関数.       (line  623)
* built-in function; filter():           組み込み関数.       (line  688)
* built-in function; format():           組み込み関数.       (line  767)
* built-in function; getattr():          組み込み関数.       (line  800)
* built-in function; globals():          組み込み関数.       (line  819)
* built-in function; hasattr():          組み込み関数.       (line  825)
* built-in function; hash():             組み込み関数.       (line  832)
* built-in function; help():             組み込み関数.       (line  843)
* built-in function; hex():              組み込み関数.       (line  867)
* built-in function; id():               組み込み関数.       (line  897)
* built-in function; input():            組み込み関数.       (line  909)
* built-in function; isinstance():       組み込み関数.       (line 1008)
* built-in function; issubclass():       組み込み関数.       (line 1025)
* built-in function; iter():             組み込み関数.       (line 1038)
* built-in function; len():              組み込み関数.       (line 1068)
* built-in function; locals():           組み込み関数.       (line 1086)
* built-in function; map():              組み込み関数.       (line 1135)
* built-in function; max():              組み込み関数.       (line 1146)
* built-in function; min():              組み込み関数.       (line 1181)
* built-in function; multiprocessing.Manager(): マネージャー.
                                                             (line   12)
* built-in function; next():             組み込み関数.       (line 1211)
* built-in function; oct():              組み込み関数.       (line 1231)
* built-in function; open():             組み込み関数.       (line 1255)
* built-in function; ord():              組み込み関数.       (line 1502)
* built-in function; pow():              組み込み関数.       (line 1509)
* built-in function; print():            組み込み関数.       (line 1550)
* built-in function; property.deleter(): 組み込み関数.       (line 1626)
* built-in function; property.getter():  組み込み関数.       (line 1622)
* built-in function; property.setter():  組み込み関数.       (line 1624)
* built-in function; repr():             組み込み関数.       (line 1675)
* built-in function; reversed():         組み込み関数.       (line 1697)
* built-in function; round():            組み込み関数.       (line 1705)
* built-in function; setattr():          組み込み関数.       (line 1742)
* built-in function; sorted():           組み込み関数.       (line 1793)
* built-in function; staticmethod():     組み込み関数.       (line 1828)
* built-in function; sum():              組み込み関数.       (line 1883)
* built-in function; vars():             組み込み関数.       (line 2036)
* built-in function; zip():              組み込み関数.       (line 2059)
* builtin_module_names (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  149)
* BuiltinFunctionType (types モジュール): 標準的なインタプリタ型.
                                                             (line   80)
* BuiltinImporter (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line   67)
* BuiltinMethodType (types モジュール):  標準的なインタプリタ型.
                                                             (line   80)
* busy_retry() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  200)
* BUTTON_ALT (curses モジュール):        定数<6>.            (line  629)
* BUTTON_CTRL (curses モジュール):       定数<6>.            (line  626)
* BUTTON_SHIFT (curses モジュール):      定数<6>.            (line  623)
* buttonbox() (tkinter.simpledialog.Dialog のメソッド): tkinter simpledialog --- 標準 Tkinter 入力ダイアログ.
                                                             (line   29)
* BUTTONn_CLICKED (curses モジュール):   定数<6>.            (line  614)
* BUTTONn_DOUBLE_CLICKED (curses モジュール): 定数<6>.       (line  617)
* BUTTONn_PRESSED (curses モジュール):   定数<6>.            (line  608)
* BUTTONn_RELEASED (curses モジュール):  定数<6>.            (line  611)
* BUTTONn_TRIPLE_CLICKED (curses モジュール): 定数<6>.       (line  620)
* bye() (turtle モジュール):             Screen 独自のメソッド、TurtleScreen から継承したもの以外.
                                                             (line    6)
* byref() (ctypes モジュール):           ユーティリティー関数.
                                                             (line   19)
* bytearray:                             変更可能なシーケンス型 mutable sequence.
                                                             (line   27)
* bytearray (組み込みクラス):            bytearray オブジェクト.
                                                             (line    9)
* bytearray;メソッド:                    bytes と bytearray の操作.
                                                             (line    6)
* bytearray;書式化:                      printf 形式での bytes の書式化.
                                                             (line    6)
* bytearray;補間:                        printf 形式での bytes の書式化.
                                                             (line    6)
* bytecode:                              コードオブジェクト. (line    6)
* bytecode <1>:                          用語集<2>.          (line  203)
* Bytecode (dis のクラス):               バイトコード解析.   (line   12)
* BYTECODE_SUFFIXES (importlib.machinery モジュール): importlib machinery -- インポータおよびパスフック.
                                                             (line   40)
* Bytecode.codeobj (dis モジュール):     バイトコード解析.   (line   49)
* Bytecode.first_line (dis モジュール):  バイトコード解析.   (line   53)
* BytecodeTestCase (test.support.bytecode_helper のクラス): test support bytecode_helper --- Support tools for testing correct bytecode generation.
                                                             (line   13)
* byteorder (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line  143)
* bytes:                                 変更不能なシーケンス immutable sequence.
                                                             (line   40)
* bytes (uuid.UUID の属性):              uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   85)
* bytes (組み込みクラス):                バイトオブジェクト. (line   11)
* bytes_le (uuid.UUID の属性):           uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   90)
* bytes_warning (sys.flags の属性):      sys --- システム固有のパラメーターと関数.
                                                             (line  542)
* bytes-like object:                     用語集<2>.          (line  184)
* bytes;str (組み込みクラス):            テキストシーケンス型 --- str.
                                                             (line   60)
* bytes;メソッド:                        bytes と bytearray の操作.
                                                             (line    6)
* bytes;書式化:                          printf 形式での bytes の書式化.
                                                             (line    6)
* bytes;補間:                            printf 形式での bytes の書式化.
                                                             (line    6)
* BytesFeedParser (email.parser のクラス): FeedParser API.   (line   29)
* BytesGenerator (email.generator のクラス): email generator Generating MIME documents.
                                                             (line   42)
* BytesHeaderParser (email.parser のクラス): Parser API.     (line   68)
* BytesIO (io のクラス):                 バッファ付きストリーム.
                                                             (line    9)
* BytesParser (email.parser のクラス):   Parser API.         (line   18)
* ByteString (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   68)
* ByteString (typing のクラス):          Aliases to container ABCs in collections abc.
                                                             (line   14)
* byteswap() (array.array のメソッド):   array --- 効率的な数値配列.
                                                             (line  144)
* BytesWarning:                          警告.               (line   75)
* BZ2Compressor (bz2 のクラス):          逐次圧縮および展開. (line    6)
* BZ2Decompressor (bz2 のクラス):        逐次圧縮および展開. (line   33)
* BZ2File (bz2 のクラス):                ファイルの圧縮/解凍.
                                                             (line   40)
* C:                                     文字列およびバイト列リテラル.
                                                             (line   77)
* c_bool (ctypes のクラス):              基本データ型<2>.    (line  206)
* c_byte (ctypes のクラス):              基本データ型<2>.    (line   45)
* c_char (ctypes のクラス):              基本データ型<2>.    (line   51)
* c_char_p (ctypes のクラス):            基本データ型<2>.    (line   57)
* C_CONTIGUOUS (inspect.BufferFlags の属性): Buffer flags.   (line   25)
* c_contiguous (memoryview の属性):      メモリビュー.       (line  469)
* c_double (ctypes のクラス):            基本データ型<2>.    (line   64)
* c_float (ctypes のクラス):             基本データ型<2>.    (line   76)
* c_int (ctypes のクラス):               基本データ型<2>.    (line   81)
* c_int16 (ctypes のクラス):             基本データ型<2>.    (line   93)
* c_int32 (ctypes のクラス):             基本データ型<2>.    (line   98)
* c_int64 (ctypes のクラス):             基本データ型<2>.    (line  103)
* c_int8 (ctypes のクラス):              基本データ型<2>.    (line   88)
* c_long (ctypes のクラス):              基本データ型<2>.    (line  108)
* c_longdouble (ctypes のクラス):        基本データ型<2>.    (line   69)
* c_longlong (ctypes のクラス):          基本データ型<2>.    (line  113)
* C_RAISE (monitoring event):            Events.             (line   16)
* C_RETURN (monitoring event):           Events.             (line   21)
* c_short (ctypes のクラス):             基本データ型<2>.    (line  119)
* c_size_t (ctypes のクラス):            基本データ型<2>.    (line  124)
* c_ssize_t (ctypes のクラス):           基本データ型<2>.    (line  128)
* c_time_t (ctypes のクラス):            基本データ型<2>.    (line  134)
* c_ubyte (ctypes のクラス):             基本データ型<2>.    (line  140)
* c_uint (ctypes のクラス):              基本データ型<2>.    (line  146)
* c_uint16 (ctypes のクラス):            基本データ型<2>.    (line  158)
* c_uint32 (ctypes のクラス):            基本データ型<2>.    (line  163)
* c_uint64 (ctypes のクラス):            基本データ型<2>.    (line  168)
* c_uint8 (ctypes のクラス):             基本データ型<2>.    (line  153)
* c_ulong (ctypes のクラス):             基本データ型<2>.    (line  173)
* c_ulonglong (ctypes のクラス):         基本データ型<2>.    (line  178)
* c_ushort (ctypes のクラス):            基本データ型<2>.    (line  184)
* c_void_p (ctypes のクラス):            基本データ型<2>.    (line  189)
* c_wchar (ctypes のクラス):             基本データ型<2>.    (line  194)
* c_wchar_p (ctypes のクラス):           基本データ型<2>.    (line  200)
* C-contiguous:                          shape strides suboffsets.
                                                             (line   26)
* C-contiguous <1>:                      用語集<2>.          (line  321)
* C;構造体:                              struct --- バイト列をパックされたバイナリデータとして解釈する.
                                                             (line    8)
* C;言語:                                標準型の階層.       (line    6)
* C;言語 <1>:                            numbers Real float 実数.
                                                             (line    6)
* C;言語 <2>:                            組み込み関数 built-in function.
                                                             (line    6)
* C;言語 <3>:                            比較.               (line    6)
* C;言語 <4>:                            数値型 int float complex.
                                                             (line    6)
* C14NWriterTarget (xml.etree.ElementTree のクラス): TreeBuilder オブジェクト.
                                                             (line   92)
* CACHE (opcode):                        Python バイトコード命令.
                                                             (line  168)
* cache_from_source() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line   21)
* cache() (functools モジュール):        functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line   16)
* cached (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  420)
* cached_property() (functools モジュール): functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line   49)
* CacheFTPHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  432)
* calcobjsize() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  438)
* calcsize() (struct モジュール):        関数と例外.         (line   53)
* calcvobjsize() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  444)
* Calendar (calendar のクラス):          calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   25)
* calendar コマンドラインオプション; -c: コマンドラインからの使用.
                                                             (line  117)
* calendar コマンドラインオプション; -css: コマンドラインからの使用.
                                                             (line  117)
* calendar コマンドラインオプション; -e: コマンドラインからの使用.
                                                             (line   66)
* calendar コマンドラインオプション; -encoding: コマンドラインからの使用.
                                                             (line   66)
* calendar コマンドラインオプション; -f: コマンドラインからの使用.
                                                             (line   75)
* calendar コマンドラインオプション; -first-weekday: コマンドラインからの使用.
                                                             (line   75)
* calendar コマンドラインオプション; -h: コマンドラインからの使用.
                                                             (line   57)
* calendar コマンドラインオプション; -help: コマンドラインからの使用.
                                                             (line   57)
* calendar コマンドラインオプション; -L: コマンドラインからの使用.
                                                             (line   61)
* calendar コマンドラインオプション; -l: コマンドラインからの使用.
                                                             (line  100)
* calendar コマンドラインオプション; -lines: コマンドラインからの使用.
                                                             (line  100)
* calendar コマンドラインオプション; -locale: コマンドラインからの使用.
                                                             (line   61)
* calendar コマンドラインオプション; -m: コマンドラインからの使用.
                                                             (line  111)
* calendar コマンドラインオプション; -months: コマンドラインからの使用.
                                                             (line  111)
* calendar コマンドラインオプション; -s: コマンドラインからの使用.
                                                             (line  106)
* calendar コマンドラインオプション; -spacing: コマンドラインからの使用.
                                                             (line  106)
* calendar コマンドラインオプション; -t: コマンドラインからの使用.
                                                             (line   71)
* calendar コマンドラインオプション; -type: コマンドラインからの使用.
                                                             (line   71)
* calendar コマンドラインオプション; -w: コマンドラインからの使用.
                                                             (line   94)
* calendar コマンドラインオプション; -width: コマンドラインからの使用.
                                                             (line   94)
* calendar コマンドラインオプション; month: コマンドラインからの使用.
                                                             (line   86)
* calendar コマンドラインオプション; year: コマンドラインからの使用.
                                                             (line   82)
* calendar() (calendar モジュール):      calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  345)
* call:                                  スライス表記 slicing.
                                                             (line   37)
* Call (ast のクラス):                   式 expression<2>.   (line  123)
* CALL (monitoring event):               Events.             (line   12)
* CALL (opcode):                         Python バイトコード命令.
                                                             (line 1016)
* call_args (unittest.mock.Mock の属性): Mock クラス.        (line  409)
* call_args_list (unittest.mock.Mock の属性): Mock クラス.   (line  454)
* call_at() (asyncio.loop のメソッド):   遅延コールバックのスケジューリング.
                                                             (line   39)
* call_count (unittest.mock.Mock の属性): Mock クラス.       (line  306)
* call_exception_handler() (asyncio.loop のメソッド): エラーハンドリング API.
                                                             (line   46)
* CALL_FUNCTION_EX (opcode):             Python バイトコード命令.
                                                             (line 1068)
* CALL_INTRINSIC_1 (opcode):             Python バイトコード命令.
                                                             (line 1272)
* CALL_INTRINSIC_2 (opcode):             Python バイトコード命令.
                                                             (line 1333)
* CALL_KW (opcode):                      Python バイトコード命令.
                                                             (line 1041)
* call_later() (asyncio.loop のメソッド): 遅延コールバックのスケジューリング.
                                                             (line   10)
* call_list() (unittest.mock.call のメソッド): call.         (line   20)
* call_soon_threadsafe() (asyncio.loop のメソッド): コールバックのスケジューリング.
                                                             (line   25)
* call_soon() (asyncio.loop のメソッド): コールバックのスケジューリング.
                                                             (line    6)
* call_tracing() (sys モジュール):       sys --- システム固有のパラメーターと関数.
                                                             (line  158)
* call;instance:                         呼び出し可能オブジェクトをエミュレートする.
                                                             (line    8)
* call() (operator モジュール):          operator --- 関数形式の標準演算子.
                                                             (line  215)
* call() (subprocess モジュール):        古い高水準 API.     (line   11)
* call() (unittest.mock モジュール):     call.               (line    6)
* callable:                              用語集<2>.          (line  217)
* Callable (collections.abc のクラス):   コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   18)
* Callable (typing モジュール):          Aliases to other ABCs in collections abc.
                                                             (line   22)
* CallableProxyType (weakref モジュール): weakref --- 弱参照.
                                                             (line  330)
* callback:                              用語集<2>.          (line  228)
* callback (optparse.Option の属性):     オプション属性.     (line   68)
* callback_args (optparse.Option の属性): オプション属性.    (line   75)
* callback_kwargs (optparse.Option の属性): オプション属性.  (line   75)
* callback() (contextlib.ExitStack のメソッド): ユーティリティ.
                                                             (line  585)
* callbacks (gc モジュール):             gc --- ガベージコレクターインターフェース.
                                                             (line  251)
* called (unittest.mock.Mock の属性):    Mock クラス.        (line  295)
* CalledProcessError:                    subprocess モジュールを使う.
                                                             (line  205)
* calloc (C function):                   概要<4>.            (line   33)
* CAN (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   96)
* CAN_BCM (socket モジュール):           定数<8>.            (line  144)
* can_change_color() (curses モジュール): 関数<6>.           (line   30)
* can_fetch() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   33)
* CAN_ISOTP (socket モジュール):         定数<8>.            (line  184)
* CAN_J1939 (socket モジュール):         定数<8>.            (line  193)
* CAN_RAW_FD_FRAMES (socket モジュール): 定数<8>.            (line  159)
* CAN_RAW_JOIN_FILTERS (socket モジュール): 定数<8>.         (line  173)
* can_symlink() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   73)
* can_write_eof() (asyncio.StreamWriter のメソッド): StreamWriter.
                                                             (line   48)
* can_write_eof() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line   14)
* can_xattr() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   78)
* CANCEL (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  155)
* cancel_command() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line   81)
* cancel_dump_traceback_later() (faulthandler モジュール): タイムアウト後にtracebackをダンプする.
                                                             (line   29)
* cancel_join_thread() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  192)
* cancel() (asyncio.Future のメソッド):  Future オブジェクト<2>.
                                                             (line  118)
* cancel() (asyncio.Handle のメソッド):  コールバックのハンドル.
                                                             (line   18)
* cancel() (asyncio.Task のメソッド):    Task オブジェクト.  (line  201)
* cancel() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   16)
* cancel() (sched.scheduler のメソッド): スケジューラオブジェクト.
                                                             (line   40)
* cancel() (threading.Timer のメソッド): Timer オブジェクト. (line   33)
* cancel() (tkinter.dnd.DndHandler のメソッド): tkinter dnd --- ドラッグアンドドロップのサポート.
                                                             (line   48)
* cancelled() (asyncio.Future のメソッド): Future オブジェクト<2>.
                                                             (line   72)
* cancelled() (asyncio.Handle のメソッド): コールバックのハンドル.
                                                             (line   23)
* cancelled() (asyncio.Task のメソッド): Task オブジェクト.  (line  262)
* cancelled() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   23)
* CancelledError:                        例外クラス.         (line    6)
* CancelledError <1>:                    例外<12>.           (line   18)
* cancelling() (asyncio.Task のメソッド): Task オブジェクト. (line  320)
* CannotSendHeader:                      http client --- HTTP プロトコルクライアント.
                                                             (line  175)
* CannotSendRequest:                     http client --- HTTP プロトコルクライアント.
                                                             (line  171)
* canonic() (bdb.Bdb のメソッド):        bdb --- デバッガーフレームワーク.
                                                             (line  150)
* canonical() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  251)
* canonical() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  135)
* canonicalize() (xml.etree.ElementTree モジュール): 関数<9>.
                                                             (line    6)
* capa() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   23)
* capitalize() (bytearray のメソッド):   bytes と bytearray の操作.
                                                             (line  474)
* capitalize() (bytes のメソッド):       bytes と bytearray の操作.
                                                             (line  474)
* capitalize() (str のメソッド):         文字列メソッド<2>.  (line   20)
* CapsuleType (types のクラス):          標準的なインタプリタ型.
                                                             (line  293)
* captured_stderr() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  332)
* captured_stdin() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  332)
* captured_stdout() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  332)
* captureWarnings() (logging モジュール): warnings モジュールとの統合.
                                                             (line    9)
* capwords() (string モジュール):        ヘルパー関数.       (line    6)
* case block:                            論駁不可能なケースブロック.
                                                             (line    6)
* casefold() (str のメソッド):           文字列メソッド<2>.  (line   30)
* cast() (ctypes モジュール):            ユーティリティー関数.
                                                             (line   34)
* cast() (memoryview のメソッド):        メモリビュー.       (line  269)
* cast() (typing モジュール):            Functions and decorators.
                                                             (line    6)
* catch_threading_exception() (test.support.threading_helper モジュール): test support threading_helper --- Utilities for threading tests.
                                                             (line   47)
* catch_unraisable_exception() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  599)
* catch_warnings (warnings のクラス):    利用可能なコンテキストマネージャー.
                                                             (line    6)
* category() (unicodedata モジュール):   unicodedata --- Unicode データベース.
                                                             (line   49)
* cbreak() (curses モジュール):          関数<6>.            (line   35)
* cbrt() (math モジュール):              指数関数と対数関数. (line    6)
* CC:                                    新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   56)
* ccc() (ftplib.FTP_TLS のメソッド):     FTP_TLS オブジェクト.
                                                             (line   99)
* cdf() (statistics.NormalDist のメソッド): NormalDist オブジェクト.
                                                             (line   86)
* CDLL (ctypes のクラス):                共有ライブラリをロードする.
                                                             (line    9)
* ceil() (math モジュール):              数値型 int float complex.
                                                             (line  102)
* ceil() (math モジュール) <1>:          数論および数表現の関数.
                                                             (line    6)
* CellType (types モジュール):           標準的なインタプリタ型.
                                                             (line   69)
* center() (bytearray のメソッド):       bytes と bytearray の操作.
                                                             (line  291)
* center() (bytes のメソッド):           bytes と bytearray の操作.
                                                             (line  291)
* center() (str のメソッド):             文字列メソッド<2>.  (line   46)
* CERT_NONE (ssl モジュール):            定数<9>.            (line   11)
* CERT_OPTIONAL (ssl モジュール):        定数<9>.            (line   25)
* CERT_REQUIRED (ssl モジュール):        定数<9>.            (line   41)
* cert_store_stats() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line   89)
* cert_time_to_seconds() (ssl モジュール): 証明書の取り扱い. (line    6)
* CertificateError:                      例外<15>.           (line   92)
* certificates:                          SSL コンテキスト.   (line  760)
* CFLAGS:                                新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   57)
* CFLAGS <1>:                            パフォーマンスに関するオプション.
                                                             (line   28)
* CFLAGS <2>:                            Compiler flags.     (line   26)
* CFLAGS <3>:                            Compiler flags.     (line   28)
* CFLAGS <4>:                            Compiler flags.     (line   32)
* CFLAGS <5>:                            Compiler flags.     (line   54)
* CFLAGS <6>:                            Linker flags.       (line   18)
* CFLAGS_NODIST:                         Compiler flags.     (line   24)
* CFLAGS_NODIST <1>:                     Compiler flags.     (line   61)
* CFLAGS_NODIST <2>:                     Linker flags.       (line   26)
* cfmakecbreak() (tty モジュール):       tty --- 端末制御用の関数群.
                                                             (line   28)
* cfmakeraw() (tty モジュール):          tty --- 端末制御用の関数群.
                                                             (line   20)
* CFUNCTYPE() (ctypes モジュール):       関数プロトタイプ.   (line   14)
* cget() (tkinter.font.Font のメソッド): tkinter font --- Tkinter フォントラッパー.
                                                             (line   51)
* cgi_directories (http.server.CGIHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  505)
* CGIHandler (wsgiref.handlers のクラス): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line   11)
* CGIHTTPRequestHandler (http.server のクラス): http server --- HTTP サーバー.
                                                             (line  480)
* CGIXMLRPCRequestHandler (xmlrpc.server のクラス): xmlrpc server --- 基本的な XML-RPC サーバー.
                                                             (line   51)
* chain() (itertools モジュール):        Itertool関数.       (line  105)
* ChainMap (collections のクラス):       ChainMap オブジェクト.
                                                             (line   15)
* ChainMap (typing のクラス):            Aliases to types in collections.
                                                             (line   28)
* change_cwd() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   82)
* CHANNEL_BINDING_TYPES (ssl モジュール): 定数<9>.           (line  473)
* CHAR_MAX (locale モジュール):          locale --- 国際化サービス.
                                                             (line  548)
* CharacterDataHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  268)
* characters_written (BlockingIOError の属性): OS 例外.      (line   19)
* characters() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line  120)
* Charset (email.charset のクラス):      email charset 文字集合の表現.
                                                             (line   24)
* charset() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   73)
* chdir() (contextlib モジュール):       ユーティリティ.     (line  372)
* chdir() (os モジュール):               ファイルとディレクトリ.
                                                             (line  118)
* check (lzma.LZMADecompressor の属性):  メモリ上での圧縮と展開.
                                                             (line  147)
* check__all__() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  679)
* check_call() (subprocess モジュール):  古い高水準 API.     (line   45)
* check_disallow_instantiation() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  733)
* CHECK_EG_MATCH (opcode):               Python バイトコード命令.
                                                             (line  467)
* CHECK_EXC_MATCH (opcode):              Python バイトコード命令.
                                                             (line  459)
* check_free_after_iterating() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  667)
* check_hostname (ssl.SSLContext の属性): SSL コンテキスト.  (line  492)
* check_impl_detail() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  296)
* check_no_resource_warning() (test.support.warnings_helper モジュール): test support warnings_helper --- Utilities for warnings tests.
                                                             (line   25)
* check_output() (doctest.OutputChecker のメソッド): OutputChecker オブジェクト.
                                                             (line   17)
* check_output() (subprocess モジュール): 古い高水準 API.    (line   83)
* check_returncode() (subprocess.CompletedProcess のメソッド): subprocess モジュールを使う.
                                                             (line  135)
* check_syntax_error() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  573)
* check_syntax_warning() (test.support.warnings_helper モジュール): test support warnings_helper --- Utilities for warnings tests.
                                                             (line   32)
* check_unused_args() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line   88)
* check_warnings() (test.support.warnings_helper モジュール): test support warnings_helper --- Utilities for warnings tests.
                                                             (line   48)
* check() (imaplib.IMAP4 のメソッド):    IMAP4 オブジェクト. (line   56)
* check() (tabnanny モジュール):         tabnanny --- あいまいなインデントの検出.
                                                             (line   17)
* checkcache() (linecache モジュール):   linecache --- テキストラインへのランダムアクセス.
                                                             (line   43)
* CHECKED_HASH (py_compile.PycInvalidationMode の属性): py_compile --- Python ソースファイルをコンパイルする.
                                                             (line  110)
* checkfuncname() (bdb モジュール):      bdb --- デバッガーフレームワーク.
                                                             (line  458)
* checksizeof() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  450)
* chflags() (os モジュール):             ファイルとディレクトリ.
                                                             (line  139)
* chgat() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  131)
* childNodes (xml.dom.Node の属性):      Node オブジェクト.  (line   48)
* ChildProcessError:                     OS 例外.            (line   25)
* children (pyclbr.Class の属性):        クラスオブジェクト<2>.
                                                             (line   35)
* children (pyclbr.Function の属性):     Function オブジェクト.
                                                             (line   34)
* children (tkinter.Tk の属性):          Tkinter モジュール. (line   88)
* chksum (tarfile.TarInfo の属性):       TarInfo オブジェクト.
                                                             (line  139)
* chmod() (os モジュール):               ファイルとディレクトリ.
                                                             (line  182)
* chmod() (pathlib.Path のメソッド):     パーミッションと所有者.
                                                             (line   40)
* choice() (random モジュール):          シーケンス用の関数. (line    6)
* choice() (secrets モジュール):         乱数.               (line   15)
* choices (optparse.Option の属性):      オプション属性.     (line   63)
* choices() (random モジュール):         シーケンス用の関数. (line   11)
* Chooser (tkinter.colorchooser のクラス): tkinter colorchooser --- カラー選択ダイアログ.
                                                             (line   15)
* chown() (os モジュール):               ファイルとディレクトリ.
                                                             (line  252)
* chown() (shutil モジュール):           ディレクトリとファイルの操作.
                                                             (line  400)
* chroot() (os モジュール):              ファイルとディレクトリ.
                                                             (line  281)
* CHRTYPE (tarfile モジュール):          tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  289)
* cipher() (ssl.SSLSocket のメソッド):   SSL ソケット.       (line  226)
* circle() (turtle モジュール):          Turtle の動き.      (line  209)
* CIRCUMFLEX (token モジュール):         token --- Python 解析木で使われる定数.
                                                             (line  151)
* CIRCUMFLEXEQUAL (token モジュール):    token --- Python 解析木で使われる定数.
                                                             (line  195)
* Clamped (decimal のクラス):            シグナル.           (line   19)
* Class (pyclbr のクラス):               クラスオブジェクト<2>.
                                                             (line    6)
* Class (symtable のクラス):             記号表の検査.       (line  151)
* CLASS (symtable.SymbolTableType の属性): 記号表の検査.     (line   19)
* class variable:                        用語集<2>.          (line  239)
* ClassDef (ast のクラス):               関数およびクラス定義.
                                                             (line  168)
* ClassMethodDescriptorType (types モジュール): 標準的なインタプリタ型.
                                                             (line  115)
* ClassVar (typing モジュール):          特殊形式.           (line  159)
* clause:                                複合文 compound statement.
                                                             (line   17)
* CLD_CONTINUED (os モジュール):         プロセス管理.       (line 1046)
* CLD_DUMPED (os モジュール):            プロセス管理.       (line 1046)
* CLD_EXITED (os モジュール):            プロセス管理.       (line 1046)
* CLD_KILLED (os モジュール):            プロセス管理.       (line 1046)
* CLD_STOPPED (os モジュール):           プロセス管理.       (line 1046)
* CLD_TRAPPED (os モジュール):           プロセス管理.       (line 1046)
* clean() (mailbox.Maildir のメソッド):  Maildir オブジェクト.
                                                             (line   84)
* cleandoc() (inspect モジュール):       ソースコードの情報取得.
                                                             (line   71)
* CleanImport (test.support.import_helper のクラス): test support import_helper --- Utilities for import tests.
                                                             (line   87)
* cleanup functions:                     プロセス制御.       (line   33)
* CLEANUP_THROW (opcode):                Python バイトコード命令.
                                                             (line  342)
* cleanup() (tempfile.TemporaryDirectory のメソッド): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  201)
* clear (pdb command):                   デバッガコマンド.   (line  124)
* Clear Breakpoint [ブレークポイントのクリア]: Help メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   32)
* clear_all_breaks() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  373)
* clear_all_file_breaks() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  368)
* clear_bpbynumber() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  362)
* clear_break() (bdb.Bdb のメソッド):    bdb --- デバッガーフレームワーク.
                                                             (line  356)
* clear_cache() (filecmp モジュール):    filecmp --- ファイルとディレクトリの比較.
                                                             (line   57)
* clear_cache() (zoneinfo.ZoneInfo のクラスメソッド): ZoneInfo クラス.
                                                             (line   58)
* clear_content() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  673)
* clear_flags() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  163)
* clear_frames() (traceback モジュール): モジュールレベルの関数<2>.
                                                             (line  167)
* clear_history() (readline モジュール): 履歴リスト.         (line    8)
* clear_overloads() (typing モジュール): Functions and decorators.
                                                             (line  301)
* clear_session_cookies() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   94)
* clear_traces() (tracemalloc モジュール): 関数<11>.         (line    6)
* clear_traps() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  167)
* clear() (array.array のメソッド):      array --- 効率的な数値配列.
                                                             (line  224)
* clear() (asyncio.Event のメソッド):    Event.              (line   59)
* clear() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   43)
* clear() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  147)
* clear() (dbm.gnu.gdbm のメソッド):     dbm gnu --- GNU database manager.
                                                             (line  121)
* clear() (dbm.ndbm.ndbm のメソッド):    dbm ndbm --- New Database Manager.
                                                             (line   75)
* clear() (dict のメソッド):             マッピング型 --- dict.
                                                             (line  135)
* clear() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  669)
* clear() (frame のメソッド):            Frame object methods.
                                                             (line    8)
* clear() (frozenset のメソッド):        set（集合）型 --- set frozenset.
                                                             (line  211)
* clear() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   81)
* clear() (mailbox.Mailbox のメソッド):  Mailbox オブジェクト.
                                                             (line  208)
* clear() (threading.Event のメソッド):  Event オブジェクト. (line   38)
* clear() (turtle モジュール):           さらなる描画の制御. (line   23)
* clear() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   56)
* clear() (シーケンスのメソッド):        ミュータブルなシーケンス型.
                                                             (line   16)
* clearcache() (linecache モジュール):   linecache --- テキストラインへのランダムアクセス.
                                                             (line   37)
* clearok() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  152)
* clearscreen() (turtle モジュール):     ウィンドウの制御.   (line   45)
* clearstamp() (turtle モジュール):      Turtle の動き.      (line  279)
* clearstamps() (turtle モジュール):     Turtle の動き.      (line  298)
* client_address (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line   72)
* client_address (socketserver.BaseRequestHandler の属性): Request Handler Objects.
                                                             (line   46)
* Client() (multiprocessing.connection モジュール): リスナーとクライアント.
                                                             (line   34)
* CLOCK_BOOTTIME (time モジュール):      Clock ID Constants. (line    9)
* clock_getres() (time モジュール):      関数<5>.            (line   40)
* clock_gettime_ns() (time モジュール):  関数<5>.            (line   63)
* clock_gettime() (time モジュール):     関数<5>.            (line   50)
* CLOCK_HIGHRES (time モジュール):       Clock ID Constants. (line   23)
* CLOCK_MONOTONIC (time モジュール):     Clock ID Constants. (line   33)
* CLOCK_MONOTONIC_RAW (time モジュール): Clock ID Constants. (line   42)
* CLOCK_MONOTONIC_RAW_APPROX (time モジュール): Clock ID Constants.
                                                             (line   51)
* CLOCK_PROCESS_CPUTIME_ID (time モジュール): Clock ID Constants.
                                                             (line   60)
* CLOCK_PROF (time モジュール):          Clock ID Constants. (line   68)
* CLOCK_REALTIME (time モジュール):      Clock ID Constants. (line  128)
* clock_seq (uuid.UUID の属性):          uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  124)
* clock_seq_hi_variant (uuid.UUID の属性): uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  112)
* clock_seq_low (uuid.UUID の属性):      uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  115)
* clock_settime_ns() (time モジュール):  関数<5>.            (line   84)
* clock_settime() (time モジュール):     関数<5>.            (line   72)
* CLOCK_TAI (time モジュール):           Clock ID Constants. (line   76)
* CLOCK_THREAD_CPUTIME_ID (time モジュール): Clock ID Constants.
                                                             (line   88)
* CLOCK_UPTIME (time モジュール):        Clock ID Constants. (line   96)
* CLOCK_UPTIME_RAW (time モジュール):    Clock ID Constants. (line  106)
* CLOCK_UPTIME_RAW_APPROX (time モジュール): Clock ID Constants.
                                                             (line  116)
* CLONE_FILES (os モジュール):           プロセスのパラメーター.
                                                             (line  623)
* CLONE_FS (os モジュール):              プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWCGROUP (os モジュール):       プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWIPC (os モジュール):          プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWNET (os モジュール):          プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWNS (os モジュール):           プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWPID (os モジュール):          プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWTIME (os モジュール):         プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWUSER (os モジュール):         プロセスのパラメーター.
                                                             (line  623)
* CLONE_NEWUTS (os モジュール):          プロセスのパラメーター.
                                                             (line  623)
* CLONE_SIGHAND (os モジュール):         プロセスのパラメーター.
                                                             (line  623)
* CLONE_SYSVSEM (os モジュール):         プロセスのパラメーター.
                                                             (line  623)
* CLONE_THREAD (os モジュール):          プロセスのパラメーター.
                                                             (line  623)
* CLONE_VM (os モジュール):              プロセスのパラメーター.
                                                             (line  623)
* clone() (email.generator.BytesGenerator のメソッド): email generator Generating MIME documents.
                                                             (line  111)
* clone() (email.generator.Generator のメソッド): email generator Generating MIME documents.
                                                             (line  207)
* clone() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  221)
* clone() (turtle モジュール):           特別な Turtle のメソッド.
                                                             (line   31)
* cloneNode() (xml.dom.Node のメソッド): Node オブジェクト.  (line  147)
* close (in module os):                  サブインタプリタサポート.
                                                             (line  190)
* close_clients() (asyncio.Server のメソッド): Serverオブジェクト.
                                                             (line   44)
* close_connection (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line   81)
* close() (asyncio.AbstractChildWatcher のメソッド): プロセスのウオッチャー.
                                                             (line   86)
* close() (asyncio.BaseTransport のメソッド): 基底トランスポート.
                                                             (line    6)
* close() (asyncio.loop のメソッド):     ループの開始と停止. (line   46)
* close() (asyncio.Runner のメソッド):   Runner context manager.
                                                             (line   50)
* close() (asyncio.Server のメソッド):   Serverオブジェクト. (line   32)
* close() (asyncio.StreamWriter のメソッド): StreamWriter.   (line   38)
* close() (asyncio.SubprocessTransport のメソッド): サブプロセス化されたトランスポート.
                                                             (line   59)
* close() (contextlib.ExitStack のメソッド): ユーティリティ. (line  615)
* close() (coroutine のメソッド):        コルーチンオブジェクト.
                                                             (line   48)
* close() (dbm.dumb.dumbdbm のメソッド): dbm dumb --- 可搬性のある DBM 実装.
                                                             (line   85)
* close() (dbm.gnu.gdbm のメソッド):     dbm gnu --- GNU database manager.
                                                             (line  117)
* close() (dbm.ndbm.ndbm のメソッド):    dbm ndbm --- New Database Manager.
                                                             (line   71)
* close() (email.parser.BytesFeedParser のメソッド): FeedParser API.
                                                             (line   66)
* close() (fileinput モジュール):        fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  128)
* close() (ftplib.FTP のメソッド):       FTP オブジェクト.   (line  366)
* close() (generator のメソッド):        ジェネレータ-イテレータメソッド.
                                                             (line   63)
* close() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   15)
* close() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line  154)
* close() (imaplib.IMAP4 のメソッド):    IMAP4 オブジェクト. (line   60)
* close() (io.IOBase のメソッド):        I/O 基底クラス.     (line   47)
* close() (logging.FileHandler のメソッド): FileHandler.     (line   27)
* close() (logging.Handler のメソッド):  ハンドラオブジェクト.
                                                             (line   75)
* close() (logging.handlers.MemoryHandler のメソッド): MemoryHandler.
                                                             (line   58)
* close() (logging.handlers.NTEventLogHandler のメソッド): NTEventLogHandler.
                                                             (line   28)
* close() (logging.handlers.SocketHandler のメソッド): SocketHandler.
                                                             (line   20)
* close() (logging.handlers.SysLogHandler のメソッド): SysLogHandler.
                                                             (line   46)
* close() (mailbox.Mailbox のメソッド):  Mailbox オブジェクト.
                                                             (line  264)
* close() (mailbox.Maildir のメソッド):  Maildir オブジェクト.
                                                             (line  212)
* close() (mailbox.MH のメソッド):       MH オブジェクト.    (line  108)
* close() (mmap.mmap のメソッド):        mmap --- メモリマップファイルのサポート.
                                                             (line  184)
* close() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   35)
* close() (multiprocessing.connection.Listener のメソッド): リスナーとクライアント.
                                                             (line   91)
* close() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  174)
* close() (multiprocessing.Process のメソッド): Process クラスと例外.
                                                             (line  196)
* close() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  173)
* close() (multiprocessing.shared_memory.SharedMemory のメソッド): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line   92)
* close() (multiprocessing.SimpleQueue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  219)
* close() (os モジュール):               ファイル記述子の操作.
                                                             (line   22)
* close() (os.scandir のメソッド):       ファイルとディレクトリ.
                                                             (line  894)
* close() (select.devpoll のメソッド):   /dev/poll ポーリングオブジェクト.
                                                             (line   12)
* close() (select.epoll のメソッド):     エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   66)
* close() (select.kqueue のメソッド):    kqueue オブジェクト.
                                                             (line    6)
* close() (selectors.BaseSelector のメソッド): クラス<4>.    (line  141)
* close() (shelve.Shelf のメソッド):     shelve --- Python オブジェクトの永続化.
                                                             (line   77)
* close() (socket モジュール):           その他の関数<2>.    (line    9)
* close() (socket.socket のメソッド):    socket オブジェクト.
                                                             (line   41)
* close() (sqlite3.Blob のメソッド):     Blob オブジェクト.  (line   38)
* close() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line   90)
* close() (sqlite3.Cursor のメソッド):   Cursor オブジェクト.
                                                             (line  153)
* close() (tarfile.TarFile のメソッド):  TarFile オブジェクト.
                                                             (line  329)
* close() (urllib.request.BaseHandler のメソッド): BaseHandler オブジェクト.
                                                             (line   14)
* close() (wave.Wave_read のメソッド):   Wave_read オブジェクト.
                                                             (line   13)
* close() (wave.Wave_write のメソッド):  Wave_write オブジェクト.
                                                             (line   30)
* Close() (winreg.PyHKEY のメソッド):    レジストリハンドルオブジェクト.
                                                             (line   35)
* close() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   27)
* close() (xml.etree.ElementTree.XMLParser のメソッド): XMLParser オブジェクト.
                                                             (line   21)
* close() (xml.etree.ElementTree.XMLPullParser のメソッド): XMLPullParser オブジェクト.
                                                             (line   41)
* close() (xml.sax.xmlreader.IncrementalParser のメソッド): IncrementalParser オブジェクト.
                                                             (line   13)
* close() (zipfile.ZipFile のメソッド):  ZipFile オブジェクト.
                                                             (line  111)
* closed (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   76)
* closed (io.IOBase の属性):             I/O 基底クラス.     (line   57)
* closed (mmap.mmap の属性):             mmap --- メモリマップファイルのサポート.
                                                             (line  191)
* closed (select.devpoll の属性):        /dev/poll ポーリングオブジェクト.
                                                             (line   18)
* closed (select.epoll の属性):          エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   70)
* closed (select.kqueue の属性):         kqueue オブジェクト.
                                                             (line   10)
* CloseKey() (winreg モジュール):        関数<13>.           (line    8)
* closelog() (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line   79)
* closerange() (os モジュール):          ファイル記述子の操作.
                                                             (line   33)
* closing() (contextlib モジュール):     ユーティリティ.     (line  156)
* closure variable:                      用語集<2>.          (line  244)
* clrtobot() (curses.window のメソッド): Window オブジェクト.
                                                             (line  157)
* clrtoeol() (curses.window のメソッド): Window オブジェクト.
                                                             (line  162)
* Cmd (cmd のクラス):                    cmd --- 行指向のコマンドインタープリターのサポート.
                                                             (line   15)
* cmd (subprocess.CalledProcessError の属性): subprocess モジュールを使う.
                                                             (line  217)
* cmd (subprocess.TimeoutExpired の属性): subprocess モジュールを使う.
                                                             (line  172)
* cmdloop() (cmd.Cmd のメソッド):        Cmdオブジェクト.    (line    8)
* cmdqueue (cmd.Cmd の属性):             Cmdオブジェクト.    (line  140)
* cmp_op (dis モジュール):               命令コードコレクション.
                                                             (line   22)
* cmp_to_key() (functools モジュール):   functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  120)
* cmp() (filecmp モジュール):            filecmp --- ファイルとディレクトリの比較.
                                                             (line   17)
* cmpfiles() (filecmp モジュール):       filecmp --- ファイルとディレクトリの比較.
                                                             (line   37)
* CMSG_LEN() (socket モジュール):        その他の関数<2>.    (line  333)
* CMSG_SPACE() (socket モジュール):      その他の関数<2>.    (line  351)
* co_argcount (codeobject の属性):       Special read-only attributes<2>.
                                                             (line   14)
* co_argcount (コードオブジェクトの属性): コードオブジェクト.
                                                             (line   16)
* CO_ASYNC_GENERATOR (inspect モジュール): Code Objects Bit Flags.
                                                             (line   52)
* co_cellvars (codeobject の属性):       Special read-only attributes<2>.
                                                             (line   39)
* co_cellvars (コードオブジェクトの属性): コードオブジェクト.
                                                             (line   16)
* co_code (codeobject の属性):           Special read-only attributes<2>.
                                                             (line   54)
* co_code (コードオブジェクトの属性):    コードオブジェクト. (line   16)
* co_consts (codeobject の属性):         Special read-only attributes<2>.
                                                             (line   58)
* co_consts (コードオブジェクトの属性):  コードオブジェクト. (line   16)
* CO_COROUTINE (inspect モジュール):     Code Objects Bit Flags.
                                                             (line   35)
* co_filename (codeobject の属性):       Special read-only attributes<2>.
                                                             (line   66)
* co_filename (コードオブジェクトの属性): コードオブジェクト.
                                                             (line   16)
* co_firstlineno (codeobject の属性):    Special read-only attributes<2>.
                                                             (line   70)
* co_firstlineno (コードオブジェクトの属性): コードオブジェクト.
                                                             (line   16)
* co_flags (codeobject の属性):          Special read-only attributes<2>.
                                                             (line   85)
* co_flags (コードオブジェクトの属性):   コードオブジェクト. (line   16)
* co_freevars (codeobject の属性):       Special read-only attributes<2>.
                                                             (line   45)
* co_freevars (コードオブジェクトの属性): コードオブジェクト.
                                                             (line   16)
* CO_FUTURE_DIVISION (C var):            超高水準レイヤ.     (line  342)
* CO_GENERATOR (inspect モジュール):     Code Objects Bit Flags.
                                                             (line   30)
* CO_ITERABLE_COROUTINE (inspect モジュール): Code Objects Bit Flags.
                                                             (line   43)
* co_kwonlyargcount (code object attribute): コードオブジェクト.
                                                             (line   16)
* co_kwonlyargcount (codeobject の属性): Special read-only attributes<2>.
                                                             (line   25)
* co_lines() (codeobject のメソッド):    Methods on code objects.
                                                             (line   43)
* co_lnotab (codeobject の属性):         Special read-only attributes<2>.
                                                             (line   73)
* co_lnotab (コードオブジェクトの属性):  コードオブジェクト. (line   16)
* co_name (codeobject の属性):           Special read-only attributes<2>.
                                                             (line    6)
* co_name (コードオブジェクトの属性):    コードオブジェクト. (line   16)
* co_names (codeobject の属性):          Special read-only attributes<2>.
                                                             (line   62)
* co_names (コードオブジェクトの属性):   コードオブジェクト. (line   16)
* CO_NESTED (inspect モジュール):        Code Objects Bit Flags.
                                                             (line   26)
* CO_NEWLOCALS (inspect モジュール):     Code Objects Bit Flags.
                                                             (line   13)
* co_nlocals (codeobject の属性):        Special read-only attributes<2>.
                                                             (line   30)
* co_nlocals (コードオブジェクトの属性): コードオブジェクト. (line   16)
* CO_OPTIMIZED (inspect モジュール):     Code Objects Bit Flags.
                                                             (line    9)
* co_positions() (codeobject のメソッド): Methods on code objects.
                                                             (line    6)
* co_posonlyargcount (code object attribute): コードオブジェクト.
                                                             (line   16)
* co_posonlyargcount (codeobject の属性): Special read-only attributes<2>.
                                                             (line   20)
* co_qualname (code object attribute):   コードオブジェクト. (line   16)
* co_qualname (codeobject の属性):       Special read-only attributes<2>.
                                                             (line    9)
* co_stacksize (codeobject の属性):      Special read-only attributes<2>.
                                                             (line   82)
* co_stacksize (コードオブジェクトの属性): コードオブジェクト.
                                                             (line   16)
* CO_VARARGS (inspect モジュール):       Code Objects Bit Flags.
                                                             (line   18)
* CO_VARKEYWORDS (inspect モジュール):   Code Objects Bit Flags.
                                                             (line   22)
* co_varnames (codeobject の属性):       Special read-only attributes<2>.
                                                             (line   34)
* co_varnames (コードオブジェクトの属性): コードオブジェクト.
                                                             (line   16)
* code (SystemExit の属性):              具象例外.           (line  376)
* code (urllib.error.HTTPError の属性):  urllib error --- urllib request によって送出される例外クラス.
                                                             (line   42)
* code (urllib.response.addinfourl の属性): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   40)
* code (xml.etree.ElementTree.ParseError の属性): 例外<18>.  (line   12)
* code (xml.parsers.expat.ExpatError の属性): ExpatError 例外.
                                                             (line    8)
* code_context (inspect.FrameInfo の属性): インタープリタスタック.
                                                             (line   32)
* code_context (inspect.Traceback の属性): インタープリタスタック.
                                                             (line   72)
* code_info() (dis モジュール):          解析関数.           (line   10)
* Codec (codecs のクラス):               ステートレスなエンコードとデコード.
                                                             (line   10)
* CodecInfo (codecs のクラス):           codecs --- codec レジストリと基底クラス.
                                                             (line   59)
* Codecs:                                codecs --- codec レジストリと基底クラス.
                                                             (line    8)
* Codecs;decode:                         codecs --- codec レジストリと基底クラス.
                                                             (line    8)
* Codecs;encode:                         codecs --- codec レジストリと基底クラス.
                                                             (line    8)
* coded_value (http.cookies.Morsel の属性): Morselオブジェクト.
                                                             (line   49)
* codepoint2name (html.entities モジュール): html entities --- HTML 一般実体の定義.
                                                             (line   33)
* codes (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   15)
* CODESET (locale モジュール):           locale --- 国際化サービス.
                                                             (line  170)
* CodeType (types のクラス):             標準的なインタプリタ型.
                                                             (line   55)
* coding;style:                          間奏曲 コーディングスタイル.
                                                             (line    6)
* col_offset (ast.AST の属性):           Node クラス.        (line   49)
* collapse_addresses() (ipaddress モジュール): その他のモジュールレベル関数.
                                                             (line   43)
* collapse_rfc2231_value() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  200)
* collect() (gc モジュール):             gc --- ガベージコレクターインターフェース.
                                                             (line   33)
* collectedDurations (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  273)
* Collection (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   37)
* Collection (typing のクラス):          Aliases to container ABCs in collections abc.
                                                             (line   23)
* colno (json.JSONDecodeError の属性):   例外<16>.           (line   26)
* colno (re.PatternError の属性):        例外<3>.            (line   32)
* colon (mailbox.Maildir の属性):        Maildir オブジェクト.
                                                             (line   43)
* COLON (token モジュール):              token --- Python 解析木で使われる定数.
                                                             (line   67)
* COLONEQUAL (token モジュール):         token --- Python 解析木で使われる定数.
                                                             (line  235)
* COLOR_BLACK (curses モジュール):       定数<6>.            (line  641)
* COLOR_BLUE (curses モジュール):        定数<6>.            (line  644)
* color_content() (curses モジュール):   関数<6>.            (line   45)
* COLOR_CYAN (curses モジュール):        定数<6>.            (line  647)
* COLOR_GREEN (curses モジュール):       定数<6>.            (line  650)
* COLOR_MAGENTA (curses モジュール):     定数<6>.            (line  653)
* color_pair() (curses モジュール):      関数<6>.            (line   53)
* COLOR_PAIRS (curses モジュール):       定数<6>.            (line   41)
* COLOR_RED (curses モジュール):         定数<6>.            (line  656)
* COLOR_WHITE (curses モジュール):       定数<6>.            (line  659)
* COLOR_YELLOW (curses モジュール):      定数<6>.            (line  662)
* color() (turtle モジュール):           色の制御<2>.        (line  103)
* colormode() (turtle モジュール):       設定と特殊なメソッド.
                                                             (line   34)
* COLORS (curses モジュール):            定数<6>.            (line   36)
* COLS (curses モジュール):              定数<6>.            (line   46)
* column() (tkinter.ttk.Treeview のメソッド): ttk Treeview.  (line   35)
* columnize() (cmd.Cmd のメソッド):      Cmdオブジェクト.    (line   87)
* COLUMNS:                               関数<6>.            (line  578)
* COLUMNS <1>:                           関数<6>.            (line  579)
* columns (os.terminal_size の属性):     ターミナルのサイズの問い合わせ.
                                                             (line   29)
* comb() (math モジュール):              数論および数表現の関数.
                                                             (line   12)
* combinations_with_replacement() (itertools モジュール): Itertool関数.
                                                             (line  169)
* combinations() (itertools モジュール): Itertool関数.       (line  128)
* combine() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line  180)
* combining() (unicodedata モジュール):  unicodedata --- Unicode データベース.
                                                             (line   58)
* Combobox (tkinter.ttk のクラス):       ttk Combobox.       (line    6)
* COMMA (token モジュール):              token --- Python 解析木で使われる定数.
                                                             (line   71)
* command (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line   94)
* CommandCompiler (codeop のクラス):     codeop --- Python コードをコンパイルする.
                                                             (line   65)
* commands (pdb command):                デバッガコマンド.   (line  158)
* comment (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   63)
* comment (http.cookies.Morsel の属性):  Morselオブジェクト. (line   13)
* COMMENT (token モジュール):            token --- Python 解析木で使われる定数.
                                                             (line  257)
* comment (zipfile.ZipFile の属性):      ZipFile オブジェクト.
                                                             (line  370)
* comment (zipfile.ZipInfo の属性):      ZipInfo オブジェクト.
                                                             (line   89)
* comment_url (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   68)
* Comment() (xml.etree.ElementTree モジュール): 関数<9>.     (line   72)
* comment() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   47)
* comment() (xml.sax.handler.LexicalHandler のメソッド): LexicalHandler Objects.
                                                             (line   18)
* commenters (shlex.shlex の属性):       shlex オブジェクト. (line   84)
* CommentHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  327)
* commit() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line   73)
* common (filecmp.dircmp の属性):        dircmp クラス.      (line   62)
* Common Vulnerabilities and Exposures; CVE 2008-5983: ビルドならびに C API の変更<8>.
                                                             (line   77)
* Common Vulnerabilities and Exposures; CVE 2008-5983 <1>: ビルドならびに C API の変更<9>.
                                                             (line   48)
* Common Vulnerabilities and Exposures; CVE 2008-5983 <2>: プロセスワイドのパラメータ.
                                                             (line  253)
* Common Vulnerabilities and Exposures; CVE 2012-0876: Security<37>.
                                                             (line   23)
* Common Vulnerabilities and Exposures; CVE 2012-0876 <1>: Security<40>.
                                                             (line   14)
* Common Vulnerabilities and Exposures; CVE 2012-0876 <2>: Security<46>.
                                                             (line   14)
* Common Vulnerabilities and Exposures; CVE 2013-0340: Security<17>.
                                                             (line   22)
* Common Vulnerabilities and Exposures; CVE 2013-1753: Library<95>.
                                                             (line  193)
* Common Vulnerabilities and Exposures; CVE 2014-0224: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張.
                                                             (line   30)
* Common Vulnerabilities and Exposures; CVE 2014-4616: Library<95>.
                                                             (line 1122)
* Common Vulnerabilities and Exposures; CVE 2015-1283: Security<43>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2015-1283 <1>: Security<48>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2016-0718: Security<37>.
                                                             (line   22)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <1>: Security<37>.
                                                             (line   23)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <2>: Security<37>.
                                                             (line   35)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <3>: Security<40>.
                                                             (line   13)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <4>: Security<40>.
                                                             (line   14)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <5>: Security<41>.
                                                             (line    7)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <6>: Security<46>.
                                                             (line   13)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <7>: Security<46>.
                                                             (line   14)
* Common Vulnerabilities and Exposures; CVE 2016-0718 <8>: Security<46>.
                                                             (line   26)
* Common Vulnerabilities and Exposures; CVE 2016-0772: Security<43>.
                                                             (line    8)
* Common Vulnerabilities and Exposures; CVE 2016-0772 <1>: Security<48>.
                                                             (line    8)
* Common Vulnerabilities and Exposures; CVE 2016-1000110: Library<74>.
                                                             (line   82)
* Common Vulnerabilities and Exposures; CVE 2016-1000110 <1>: Library<81>.
                                                             (line  267)
* Common Vulnerabilities and Exposures; CVE 2016-2183: Library<73>.
                                                             (line  178)
* Common Vulnerabilities and Exposures; CVE 2016-2183 <1>: Library<81>.
                                                             (line  205)
* Common Vulnerabilities and Exposures; CVE 2016-3189: Windows<21>.
                                                             (line   25)
* Common Vulnerabilities and Exposures; CVE 2016-4472: Security<37>.
                                                             (line   35)
* Common Vulnerabilities and Exposures; CVE 2016-4472 <1>: Security<41>.
                                                             (line    7)
* Common Vulnerabilities and Exposures; CVE 2016-4472 <2>: Security<46>.
                                                             (line   26)
* Common Vulnerabilities and Exposures; CVE 2016-5300: Security<37>.
                                                             (line   24)
* Common Vulnerabilities and Exposures; CVE 2016-5300 <1>: Security<40>.
                                                             (line   15)
* Common Vulnerabilities and Exposures; CVE 2016-5300 <2>: Security<46>.
                                                             (line   15)
* Common Vulnerabilities and Exposures; CVE 2016-9063: Security<37>.
                                                             (line   21)
* Common Vulnerabilities and Exposures; CVE 2016-9063 <1>: Security<40>.
                                                             (line   12)
* Common Vulnerabilities and Exposures; CVE 2016-9063 <2>: Security<46>.
                                                             (line   12)
* Common Vulnerabilities and Exposures; CVE 2017-1000158: Security<45>.
                                                             (line   21)
* Common Vulnerabilities and Exposures; CVE 2017-9233: Security<37>.
                                                             (line   20)
* Common Vulnerabilities and Exposures; CVE 2017-9233 <1>: Security<40>.
                                                             (line   11)
* Common Vulnerabilities and Exposures; CVE 2017-9233 <2>: Security<46>.
                                                             (line   11)
* Common Vulnerabilities and Exposures; CVE 2018-1060: Security<34>.
                                                             (line   48)
* Common Vulnerabilities and Exposures; CVE 2018-1060 <1>: Security<35>.
                                                             (line   15)
* Common Vulnerabilities and Exposures; CVE 2018-1060 <2>: Security<38>.
                                                             (line   11)
* Common Vulnerabilities and Exposures; CVE 2018-1061: Security<34>.
                                                             (line   49)
* Common Vulnerabilities and Exposures; CVE 2018-1061 <1>: Security<35>.
                                                             (line   16)
* Common Vulnerabilities and Exposures; CVE 2018-1061 <2>: Security<38>.
                                                             (line   12)
* Common Vulnerabilities and Exposures; CVE 2018-14647: Security<34>.
                                                             (line   26)
* Common Vulnerabilities and Exposures; CVE 2018-25032: Windows<21>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2018-8970: Security<34>.
                                                             (line   38)
* Common Vulnerabilities and Exposures; CVE 2018-8970 <1>: Security<35>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2019-12900: Windows<21>.
                                                             (line   26)
* Common Vulnerabilities and Exposures; CVE 2019-15903: Security<30>.
                                                             (line   20)
* Common Vulnerabilities and Exposures; CVE 2019-18348: Security<27>.
                                                             (line    7)
* Common Vulnerabilities and Exposures; CVE 2019-20907: Library<38>.
                                                             (line  186)
* Common Vulnerabilities and Exposures; CVE 2019-5010: Security<34>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2019-9740: Security<32>.
                                                             (line    9)
* Common Vulnerabilities and Exposures; CVE 2019-9948: Security<31>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2020-10735: その他の CPython の実装の変更.
                                                             (line   56)
* Common Vulnerabilities and Exposures; CVE 2020-10735 <1>: Notable security feature in 3 10 7.
                                                             (line   10)
* Common Vulnerabilities and Exposures; CVE 2020-10735 <2>: Notable security feature in 3 9 14.
                                                             (line   10)
* Common Vulnerabilities and Exposures; CVE 2020-10735 <3>: Notable security feature in 3 8 14.
                                                             (line   10)
* Common Vulnerabilities and Exposures; CVE 2020-10735 <4>: Notable security feature in 3 7 14.
                                                             (line   10)
* Common Vulnerabilities and Exposures; CVE 2020-10735 <5>: 整数と文字列の変換での長さ制限.
                                                             (line   19)
* Common Vulnerabilities and Exposures; CVE 2020-15523: Security<24>.
                                                             (line   13)
* Common Vulnerabilities and Exposures; CVE 2020-15801: Security<24>.
                                                             (line    7)
* Common Vulnerabilities and Exposures; CVE 2020-8492: Security<26>.
                                                             (line   11)
* Common Vulnerabilities and Exposures; CVE 2021-3426: Security<19>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2022-26488: Windows<21>.
                                                             (line   28)
* Common Vulnerabilities and Exposures; CVE 2022-37434: Windows<18>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2022-42919: Security<15>.
                                                             (line   24)
* Common Vulnerabilities and Exposures; CVE 2022-4303: Security<11>.
                                                             (line   10)
* Common Vulnerabilities and Exposures; CVE 2022-4303 <1>: Security<11>.
                                                             (line   11)
* Common Vulnerabilities and Exposures; CVE 2023-0286: Security<11>.
                                                             (line   10)
* Common Vulnerabilities and Exposures; CVE 2023-24329: Security<10>.
                                                             (line   19)
* Common Vulnerabilities and Exposures; CVE 2023-27043: email.
                                                             (line   22)
* Common Vulnerabilities and Exposures; CVE 2023-27043 <1>: Library<12>.
                                                             (line  429)
* Common Vulnerabilities and Exposures; CVE 2023-40217: Security<9>.
                                                             (line   10)
* Common Vulnerabilities and Exposures; CVE 2023-52425: xml. (line    6)
* Common Vulnerabilities and Exposures; CVE 2023-52425 <1>: Security<6>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2023-52425 <2>: Documentation<6>.
                                                             (line    6)
* Common Vulnerabilities and Exposures; CVE 2023-52425 <3>: XML の脆弱性.
                                                             (line   99)
* Common Vulnerabilities and Exposures; CVE 2024-4030: os.   (line   38)
* Common Vulnerabilities and Exposures; CVE 2024-4030 <1>: tempfile.
                                                             (line    8)
* Common Vulnerabilities and Exposures; CVE 2024-4030 <2>: Security<4>.
                                                             (line   11)
* Common Weakness Enumeration; CWE 257:  レシピとベストプラクティス.
                                                             (line   16)
* Common Weakness Enumeration; CWE 295:  ssl<2>.             (line   21)
* Common Weakness Enumeration; CWE 295 <1>: Library<22>.     (line  516)
* common_dirs (filecmp.dircmp の属性):   dircmp クラス.      (line   75)
* common_files (filecmp.dircmp の属性):  dircmp クラス.      (line   79)
* common_funny (filecmp.dircmp の属性):  dircmp クラス.      (line   83)
* common_types (mimetypes モジュール):   mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  157)
* commonpath() (os.path モジュール):     os path --- 一般的なパス名操作.
                                                             (line   67)
* commonprefix() (os.path モジュール):   os path --- 一般的なパス名操作.
                                                             (line   83)
* communicate() (asyncio.subprocess.Process のメソッド): サブプロセスとやりとりする.
                                                             (line   49)
* communicate() (subprocess.Popen のメソッド): Popen オブジェクト.
                                                             (line   37)
* Compare (ast のクラス):                式 expression<2>.   (line   94)
* compare_digest() (hmac モジュール):    hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line  111)
* compare_digest() (secrets モジュール): その他の関数.       (line    6)
* compare_networks() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  238)
* compare_networks() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  352)
* COMPARE_OP (opcode):                   Python バイトコード命令.
                                                             (line  792)
* compare_signal() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  259)
* compare_signal() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  152)
* compare_to() (tracemalloc.Snapshot のメソッド): Snapshot.  (line   13)
* compare_total_mag() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  267)
* compare_total_mag() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  181)
* compare_total() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  263)
* compare_total() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  159)
* compare() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  255)
* compare() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  141)
* compare() (difflib.Differ のメソッド): Differ オブジェクト.
                                                             (line   36)
* COMPARISON_FLAGS (doctest モジュール): オプションフラグ.   (line  102)
* Compat32 (email.policy のクラス):      email policy Policy Objects.
                                                             (line  561)
* compat32 (email.policy モジュール):    email policy Policy Objects.
                                                             (line  615)
* Compile (codeop のクラス):             codeop --- Python コードをコンパイルする.
                                                             (line   56)
* compile_command() (code モジュール):   code --- インタープリター基底クラス.
                                                             (line   56)
* compile_command() (codeop モジュール): codeop --- Python コードをコンパイルする.
                                                             (line   30)
* compile_dir() (compileall モジュール): パブリックな関数.   (line    6)
* compile_file() (compileall モジュール): パブリックな関数.  (line   96)
* compile_path() (compileall モジュール): パブリックな関数.  (line  160)
* compile() (py_compile モジュール):     py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   23)
* compile() (re モジュール):             関数<2>.            (line    6)
* compileall コマンドラインオプション; -b: コマンドラインでの使用<2>.
                                                             (line   57)
* compileall コマンドラインオプション; -d: コマンドラインでの使用<2>.
                                                             (line   31)
* compileall コマンドラインオプション; -e: コマンドラインでの使用<2>.
                                                             (line   97)
* compileall コマンドラインオプション; -f: コマンドラインでの使用<2>.
                                                             (line   21)
* compileall コマンドラインオプション; -hardlink-dupes: コマンドラインでの使用<2>.
                                                             (line  101)
* compileall コマンドラインオプション; -i: コマンドラインでの使用<2>.
                                                             (line   51)
* compileall コマンドラインオプション; -invalidation-mode: コマンドラインでの使用<2>.
                                                             (line   77)
* compileall コマンドラインオプション; -j: コマンドラインでの使用<2>.
                                                             (line   71)
* compileall コマンドラインオプション; -l: コマンドラインでの使用<2>.
                                                             (line   16)
* compileall コマンドラインオプション; -o: コマンドラインでの使用<2>.
                                                             (line   91)
* compileall コマンドラインオプション; -p: コマンドラインでの使用<2>.
                                                             (line   41)
* compileall コマンドラインオプション; -q: コマンドラインでの使用<2>.
                                                             (line   25)
* compileall コマンドラインオプション; -r: コマンドラインでの使用<2>.
                                                             (line   64)
* compileall コマンドラインオプション; -s: コマンドラインでの使用<2>.
                                                             (line   39)
* compileall コマンドラインオプション; -x: コマンドラインでの使用<2>.
                                                             (line   46)
* compileall コマンドラインオプション; directory: コマンドラインでの使用<2>.
                                                             (line    9)
* compileall コマンドラインオプション; file: コマンドラインでの使用<2>.
                                                             (line    9)
* compiler_flag (__future__._Feature の属性): モジュールコンテンツ<5>.
                                                             (line   80)
* complete_statement() (sqlite3 モジュール): モジュール関数. (line  106)
* complete() (rlcompleter.Completer のメソッド): rlcompleter --- GNU readline の補完機能.
                                                             (line   43)
* completedefault() (cmd.Cmd のメソッド): Cmdオブジェクト.   (line   81)
* CompletedProcess (subprocess のクラス): subprocess モジュールを使う.
                                                             (line  100)
* Completer (rlcompleter のクラス):      rlcompleter --- GNU readline の補完機能.
                                                             (line   39)
* Complex (numbers のクラス):            数値塔.             (line    6)
* complex (組み込みクラス):              組み込み関数.       (line  365)
* complex number:                        用語集<2>.          (line  272)
* complex number;リテラル:               数値型 int float complex.
                                                             (line   17)
* compound;statement:                    複合文 compound statement.
                                                             (line    6)
* comprehension (ast のクラス):          内包表記 Comprehension.
                                                             (line   58)
* compress_size (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line  140)
* compress_type (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line   85)
* compress() (bz2 モジュール):           一括圧縮/解凍.      (line    6)
* compress() (bz2.BZ2Compressor のメソッド): 逐次圧縮および展開.
                                                             (line   15)
* compress() (gzip モジュール):          gzip --- gzip ファイルのサポート.
                                                             (line  192)
* compress() (itertools モジュール):     Itertool関数.       (line  210)
* compress() (lzma モジュール):          メモリ上での圧縮と展開.
                                                             (line  171)
* compress() (lzma.LZMACompressor のメソッド): メモリ上での圧縮と展開.
                                                             (line   75)
* compress() (zlib モジュール):          zlib --- gzip 互換の圧縮.
                                                             (line   45)
* compress() (zlib.Compress のメソッド): zlib --- gzip 互換の圧縮.
                                                             (line  201)
* compressed (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   56)
* compressed (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line  106)
* compressed (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  236)
* compressed (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  319)
* compression() (ssl.SSLSocket のメソッド): SSL ソケット.    (line  243)
* CompressionError:                      tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  216)
* compressobj() (zlib モジュール):       zlib --- gzip 互換の圧縮.
                                                             (line   82)
* COMSPEC:                               プロセス管理.       (line  775)
* COMSPEC <1>:                           Popen コンストラクター.
                                                             (line  111)
* concat() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line  171)
* Concatenate (typing モジュール):       特殊形式.           (line   68)
* cond (bdb.Breakpoint の属性):          bdb --- デバッガーフレームワーク.
                                                             (line   97)
* Condition (asyncio のクラス):          Condition.          (line    6)
* Condition (multiprocessing のクラス):  同期プリミティブ.   (line   32)
* condition (pdb command):               デバッガコマンド.   (line  151)
* Condition (threading のクラス):        Condition オブジェクト.
                                                             (line   71)
* Condition() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  174)
* config() (tkinter.font.Font のメソッド): tkinter font --- Tkinter フォントラッパー.
                                                             (line   55)
* ConfigParser (configparser のクラス):  ConfigParser オブジェクト.
                                                             (line    6)
* configuration information:             sysconfig --- Python の構成情報へのアクセスを提供する.
                                                             (line   10)
* configure_mock() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  243)
* configure() (tkinter.ttk.Style のメソッド): Ttk スタイル.  (line   25)
* CONFORM (enum.FlagBoundary の属性):    データ型<2>.        (line  660)
* confstr_names (os モジュール):         雑多なシステム情報. (line   26)
* confstr() (os モジュール):             雑多なシステム情報. (line    6)
* conjugate() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  193)
* conjugate() (numbers.Complex のメソッド): 数値塔.          (line   23)
* conjugate() (複素数のメソッド):        数値型 int float complex.
                                                             (line   89)
* connect_accepted_socket() (asyncio.loop のメソッド): ネットワークサーバの生成.
                                                             (line  150)
* connect_ex() (socket.socket のメソッド): socket オブジェクト.
                                                             (line   86)
* connect_read_pipe() (asyncio.loop のメソッド): パイプとやりとりする.
                                                             (line    6)
* connect_write_pipe() (asyncio.loop のメソッド): パイプとやりとりする.
                                                             (line   23)
* connect() (ftplib.FTP のメソッド):     FTP オブジェクト.   (line   89)
* connect() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line  145)
* connect() (multiprocessing.managers.BaseManager のメソッド): マネージャー.
                                                             (line   78)
* connect() (smtplib.SMTP のメソッド):   SMTP オブジェクト.  (line   34)
* connect() (socket.socket のメソッド):  socket オブジェクト.
                                                             (line   62)
* connect() (sqlite3 モジュール):        モジュール関数.     (line    6)
* Connection (multiprocessing.connection のクラス): Connection オブジェクト<2>.
                                                             (line   13)
* Connection (sqlite3 のクラス):         Connection オブジェクト.
                                                             (line    6)
* connection (sqlite3.Cursor の属性):    Cursor オブジェクト.
                                                             (line  176)
* connection_lost() (asyncio.BaseProtocol のメソッド): 基底プロトコル<2>.
                                                             (line   23)
* connection_made() (asyncio.BaseProtocol のメソッド): 基底プロトコル<2>.
                                                             (line   16)
* ConnectionAbortedError:                OS 例外.            (line   45)
* ConnectionError:                       OS 例外.            (line   30)
* ConnectionRefusedError:                OS 例外.            (line   51)
* ConnectionResetError:                  OS 例外.            (line   57)
* ConnectRegistry() (winreg モジュール): 関数<13>.           (line   17)
* const (optparse.Option の属性):        オプション属性.     (line   59)
* Constant (ast のクラス):               リテラル<3>.        (line    6)
* constructor() (copyreg モジュール):    copyreg --- pickle サポート関数を登録する.
                                                             (line   17)
* consumed (asyncio.LimitOverrunError の属性): 例外<12>.     (line   68)
* Container (collections.abc のクラス):  コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line    6)
* Container (typing のクラス):           Aliases to container ABCs in collections abc.
                                                             (line   33)
* CONTAINS_OP (opcode):                  Python バイトコード命令.
                                                             (line  807)
* contains() (operator モジュール):      operator --- 関数形式の標準演算子.
                                                             (line  176)
* content (urllib.error.ContentTooShortError の属性): urllib error --- urllib request によって送出される例外クラス.
                                                             (line   71)
* content_disposition (email.headerregistry.ContentDispositionHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  279)
* content_manager (email.policy.EmailPolicy の属性): email policy Policy Objects.
                                                             (line  417)
* content_type (email.headerregistry.ContentTypeHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  266)
* ContentDispositionHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  274)
* ContentHandler (xml.sax.handler のクラス): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   18)
* ContentManager (email.contentmanager のクラス): email contentmanager Managing MIME Content.
                                                             (line   12)
* contents (ctypes._Pointer の属性):     配列とポインタ.     (line   58)
* contents() (importlib.abc.ResourceReader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  481)
* contents() (importlib.resources モジュール): 関数 API.     (line  150)
* contents() (importlib.resources.abc.ResourceReader のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   68)
* ContentTooShortError:                  urllib error --- urllib request によって送出される例外クラス.
                                                             (line   65)
* ContentTransferEncoding (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  284)
* ContentTypeHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  261)
* context:                               用語集<2>.          (line  282)
* Context (contextvars のクラス):        マニュアルでのコンテキスト管理.
                                                             (line   20)
* Context (decimal のクラス):            Context オブジェクト.
                                                             (line  110)
* context (ssl.SSLSocket の属性):        SSL ソケット.       (line  334)
* context manager:                       with文とコンテキストマネージャ.
                                                             (line   13)
* context manager <1>:                   コンテキストマネージャ型.
                                                             (line    6)
* context manager <2>:                   用語集<2>.          (line  303)
* context variable:                      用語集<2>.          (line  309)
* context_diff() (difflib モジュール):   difflib --- 差分の計算の補助.
                                                             (line  150)
* ContextDecorator (contextlib のクラス): ユーティリティ.    (line  391)
* ContextManager (typing のクラス):      Aliases to contextlib ABCs.
                                                             (line    6)
* contextmanager() (contextlib モジュール): ユーティリティ.  (line   31)
* ContextVar (contextvars のクラス):     コンテキスト変数.   (line    6)
* CONTIG (inspect.BufferFlags の属性):   Buffer flags.       (line   33)
* CONTIG_RO (inspect.BufferFlags の属性): Buffer flags.      (line   35)
* contiguous:                            shape strides suboffsets.
                                                             (line   26)
* contiguous <1>:                        用語集<2>.          (line  317)
* contiguous (memoryview の属性):        メモリビュー.       (line  483)
* Continue (ast のクラス):               制御フロー.         (line   99)
* continue (pdb command):                デバッガコマンド.   (line  222)
* CONTINUOUS (enum.EnumCheck の属性):    データ型<2>.        (line  599)
* control() (select.kqueue のメソッド):  kqueue オブジェクト.
                                                             (line   22)
* controlnames (curses.ascii モジュール): curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  236)
* CONTTYPE (tarfile モジュール):         tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  305)
* convert_arg_line_to_args() (argparse.ArgumentParser のメソッド): ファイル解析のカスタマイズ.
                                                             (line    6)
* convert_field() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line  104)
* CONVERT_VALUE (opcode):                Python バイトコード命令.
                                                             (line 1148)
* Cookie (http.cookiejar のクラス):      http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  113)
* CookieError:                           http cookies --- HTTP の状態管理.
                                                             (line   33)
* CookieJar (http.cookiejar のクラス):   http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line   45)
* cookiejar (urllib.request.HTTPCookieProcessor の属性): HTTPCookieProcessor オブジェクト.
                                                             (line    8)
* CookiePolicy (http.cookiejar のクラス): http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line   77)
* COPY (opcode):                         Python バイトコード命令.
                                                             (line  150)
* Copy [コピー]:                         Help メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   32)
* copy_abs() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  271)
* copy_abs() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  198)
* copy_context() (contextvars モジュール): マニュアルでのコンテキスト管理.
                                                             (line    6)
* copy_decimal() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  177)
* copy_file_range() (os モジュール):     ファイル記述子の操作.
                                                             (line   44)
* COPY_FREE_VARS (opcode):               Python バイトコード命令.
                                                             (line  995)
* copy_location() (ast モジュール):      ast ヘルパー.       (line  162)
* copy_negate() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  275)
* copy_negate() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  203)
* copy_sign() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  279)
* copy_sign() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  208)
* copy;プロトコル:                       クラスインスタンスの pickle 化.
                                                             (line  109)
* copy() (collections.deque のメソッド): deque オブジェクト. (line   47)
* copy() (contextvars.Context のメソッド): マニュアルでのコンテキスト管理.
                                                             (line  103)
* copy() (copy モジュール):              copy --- 浅いコピーおよび深いコピー操作.
                                                             (line   19)
* copy() (decimal.Context のメソッド):   Context オブジェクト.
                                                             (line  173)
* copy() (dict のメソッド):              マッピング型 --- dict.
                                                             (line  139)
* copy() (frozenset のメソッド):         set（集合）型 --- set frozenset.
                                                             (line  122)
* copy() (hashlib.hash のメソッド):      Hash Objects.       (line   49)
* copy() (hmac.HMAC のメソッド):         hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   82)
* copy() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   92)
* copy() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line   66)
* copy() (multiprocessing.sharedctypes モジュール): multiprocessing sharedctypes モジュール.
                                                             (line   83)
* copy() (shutil モジュール):            ディレクトリとファイルの操作.
                                                             (line  122)
* copy() (tkinter.font.Font のメソッド): tkinter font --- Tkinter フォントラッパー.
                                                             (line   59)
* copy() (types.MappingProxyType のメソッド): 標準的なインタプリタ型.
                                                             (line  255)
* copy() (zlib.Compress のメソッド):     zlib --- gzip 互換の圧縮.
                                                             (line  222)
* copy() (zlib.Decompress のメソッド):   zlib --- gzip 互換の圧縮.
                                                             (line  287)
* copy() (シーケンスのメソッド):         ミュータブルなシーケンス型.
                                                             (line   16)
* copy2() (shutil モジュール):           ディレクトリとファイルの操作.
                                                             (line  155)
* copyfile() (shutil モジュール):        ディレクトリとファイルの操作.
                                                             (line   17)
* copyfileobj() (shutil モジュール):     ディレクトリとファイルの操作.
                                                             (line    6)
* copymode() (shutil モジュール):        ディレクトリとファイルの操作.
                                                             (line   60)
* copyright (in module sys):             プロセスワイドのパラメータ.
                                                             (line  188)
* copyright (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line  170)
* copyright (組み込み変数):              site モジュールで追加される定数.
                                                             (line   24)
* copysign() (math モジュール):          数論および数表現の関数.
                                                             (line   28)
* copystat() (shutil モジュール):        ディレクトリとファイルの操作.
                                                             (line   78)
* copytree() (shutil モジュール):        ディレクトリとファイルの操作.
                                                             (line  196)
* Coroutine (collections.abc のクラス):  コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  130)
* Coroutine (typing のクラス):           Aliases to asynchronous ABCs in collections abc.
                                                             (line    6)
* coroutine function:                    用語集<2>.          (line  335)
* coroutine() (types モジュール):        コルーチンユーティリティ関数.
                                                             (line    6)
* CoroutineType (types モジュール):      標準的なインタプリタ型.
                                                             (line   41)
* correlation() (statistics モジュール): 関数の詳細.         (line  562)
* cos() (cmath モジュール):              三角関数<2>.        (line   23)
* cos() (math モジュール):               三角関数.           (line   29)
* cosh() (cmath モジュール):             双曲線関数<2>.      (line   23)
* cosh() (math モジュール):              双曲線関数.         (line   21)
* count (tracemalloc.Statistic の属性):  Statistic.          (line   15)
* count (tracemalloc.StatisticDiff の属性): StatisticDiff.   (line   15)
* count_diff (tracemalloc.StatisticDiff の属性): StatisticDiff.
                                                             (line   21)
* count() (array.array のメソッド):      array --- 効率的な数値配列.
                                                             (line  153)
* count() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line   36)
* count() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line   36)
* count() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   53)
* count() (itertools モジュール):        Itertool関数.       (line  223)
* count() (multiprocessing.shared_memory.ShareableList のメソッド): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  331)
* count() (str のメソッド):              文字列メソッド<2>.  (line   52)
* count() (シーケンスのメソッド):        共通のシーケンス演算.
                                                             (line   18)
* Counter (collections のクラス):        Counter オブジェクト.
                                                             (line   23)
* Counter (typing のクラス):             Aliases to types in collections.
                                                             (line   39)
* countOf() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  182)
* countTestCases() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  736)
* countTestCases() (unittest.TestSuite のメソッド): テストのグループ化.
                                                             (line   54)
* covariance() (statistics モジュール):  関数の詳細.         (line  540)
* CoverageResults (trace のクラス):      プログラミングインターフェース.
                                                             (line   46)
* CPPFLAGS:                              新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   57)
* CPPFLAGS <1>:                          Preprocessor flags. (line    8)
* CPPFLAGS <2>:                          Preprocessor flags. (line   18)
* CPPFLAGS <3>:                          Linker flags.       (line   50)
* CPU 時間:                              関数<5>.            (line  244)
* CPU 時間 <1>:                          関数<5>.            (line  594)
* cpu_count() (multiprocessing モジュール): その他<3>.       (line   14)
* cpu_count() (os モジュール):           雑多なシステム情報. (line   34)
* CPython:                               用語集<2>.          (line  342)
* cpython_only() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  531)
* CR (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   63)
* crawl_delay() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   50)
* CRC:                                   zlib --- gzip 互換の圧縮.
                                                             (line  122)
* CRC (zipfile.ZipInfo の属性):          ZipInfo オブジェクト.
                                                             (line  136)
* crc_hqx() (binascii モジュール):       binascii --- バイナリ と ASCII 間の変換.
                                                             (line   92)
* crc32() (binascii モジュール):         binascii --- バイナリ と ASCII 間の変換.
                                                             (line   99)
* crc32() (zlib モジュール):             zlib --- gzip 互換の圧縮.
                                                             (line  120)
* create_aggregate() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  163)
* create_archive() (zipapp モジュール):  Python API.         (line    8)
* create_autospec() (unittest.mock モジュール): create_autospec.
                                                             (line    6)
* CREATE_BREAKAWAY_FROM_JOB (subprocess モジュール): Windows Constants.
                                                             (line  140)
* create_collation() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  305)
* create_configuration() (venv.EnvBuilder のメソッド): API<2>.
                                                             (line  144)
* create_connection() (asyncio.loop のメソッド): ネットワーク接続の確立.
                                                             (line    6)
* create_connection() (socket モジュール): ソケットの作成.   (line   82)
* create_datagram_endpoint() (asyncio.loop のメソッド): ネットワーク接続の確立.
                                                             (line  156)
* create_decimal_from_float() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  206)
* create_decimal() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  181)
* create_default_context() (ssl モジュール): コンテキストの作成.
                                                             (line    9)
* CREATE_DEFAULT_ERROR_MODE (subprocess モジュール): Windows Constants.
                                                             (line  130)
* create_eager_task_factory() (asyncio モジュール): Eager Task Factory.
                                                             (line   32)
* create_empty_file() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   91)
* create_function() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  118)
* create_future() (asyncio.loop のメソッド): フューチャーとタスクの生成.
                                                             (line    6)
* create_git_ignore_file() (venv.EnvBuilder のメソッド): API<2>.
                                                             (line  209)
* create_module() (importlib.abc.Loader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  103)
* create_module() (importlib.machinery.ExtensionFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  310)
* create_module() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   23)
* CREATE_NEW_CONSOLE (subprocess モジュール): Windows Constants.
                                                             (line   54)
* CREATE_NEW_PROCESS_GROUP (subprocess モジュール): Windows Constants.
                                                             (line   59)
* CREATE_NO_WINDOW (subprocess モジュール): Windows Constants.
                                                             (line  115)
* create_server() (asyncio.loop のメソッド): ネットワークサーバの生成.
                                                             (line    6)
* create_server() (socket モジュール):   ソケットの作成.     (line  112)
* create_stats() (profile.Profile のメソッド): リファレンスマニュアル -- profile と cProfile.
                                                             (line   84)
* create_string_buffer() (ctypes モジュール): ユーティリティー関数.
                                                             (line   41)
* create_subprocess_exec() (asyncio モジュール): サブプロセスの生成.
                                                             (line    6)
* create_subprocess_shell() (asyncio モジュール): サブプロセスの生成.
                                                             (line   23)
* create_system (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line  100)
* create_task() (asyncio モジュール):    Task の作成.        (line   10)
* create_task() (asyncio.loop のメソッド): フューチャーとタスクの生成.
                                                             (line   18)
* create_task() (asyncio.TaskGroup のメソッド): Task Groups. (line   17)
* create_unicode_buffer() (ctypes モジュール): ユーティリティー関数.
                                                             (line   57)
* create_unix_connection() (asyncio.loop のメソッド): ネットワーク接続の確立.
                                                             (line  239)
* create_unix_server() (asyncio.loop のメソッド): ネットワークサーバの生成.
                                                             (line  119)
* create_version (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line  104)
* create_window_function() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  216)
* create() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line   71)
* create() (venv モジュール):            API<2>.             (line  230)
* create() (venv.EnvBuilder のメソッド): API<2>.             (line   61)
* createAttribute() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   45)
* createAttributeNS() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   52)
* createComment() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   33)
* createDocument() (xml.dom.DOMImplementation のメソッド): DOMImplementation オブジェクト.
                                                             (line   17)
* createDocumentType() (xml.dom.DOMImplementation のメソッド): DOMImplementation オブジェクト.
                                                             (line   28)
* createElement() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   14)
* createElementNS() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   20)
* createfilehandler() (_tkinter.Widget.tk のメソッド): ファイルハンドラ.
                                                             (line   28)
* CreateKey() (winreg モジュール):       関数<13>.           (line   36)
* CreateKeyEx() (winreg モジュール):     関数<13>.           (line   63)
* createLock() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   21)
* createLock() (logging.NullHandler のメソッド): NullHandler.
                                                             (line   24)
* createProcessingInstruction() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   39)
* createSocket() (logging.handlers.SocketHandler のメソッド): SocketHandler.
                                                             (line   71)
* createSocket() (logging.handlers.SysLogHandler のメソッド): SysLogHandler.
                                                             (line   50)
* createTextNode() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   27)
* credits (組み込み変数):                site モジュールで追加される定数.
                                                             (line   24)
* CRITICAL (logging モジュール):         ロギングレベル.     (line   44)
* critical() (logging モジュール):       モジュールレベルの関数.
                                                             (line   85)
* critical() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  297)
* CRNCYSTR (locale モジュール):          locale --- 国際化サービス.
                                                             (line  278)
* CRT_ASSEMBLY_VERSION (msvcrt モジュール): その多の関数.    (line   89)
* CRT_ASSERT (msvcrt モジュール):        その多の関数.       (line   66)
* CRT_ERROR (msvcrt モジュール):         その多の関数.       (line   61)
* CRT_WARN (msvcrt モジュール):          その多の関数.       (line   56)
* CRTDBG_MODE_DEBUG (msvcrt モジュール): その多の関数.       (line   70)
* CRTDBG_MODE_FILE (msvcrt モジュール):  その多の関数.       (line   74)
* CRTDBG_MODE_WNDW (msvcrt モジュール):  その多の関数.       (line   80)
* CRTDBG_REPORT_MODE (msvcrt モジュール): その多の関数.      (line   85)
* CrtSetReportFile() (msvcrt モジュール): その多の関数.      (line   48)
* CrtSetReportMode() (msvcrt モジュール): その多の関数.      (line   40)
* cryptography:                          暗号関連のサービス. (line    6)
* cssclass_month (calendar.HTMLCalendar の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  226)
* cssclass_month_head (calendar.HTMLCalendar の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  219)
* cssclass_noday (calendar.HTMLCalendar の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  205)
* cssclass_year (calendar.HTMLCalendar の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  233)
* cssclass_year_head (calendar.HTMLCalendar の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  240)
* cssclasses (calendar.HTMLCalendar の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  192)
* cssclasses_weekday_head (calendar.HTMLCalendar の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  212)
* csv:                                   csv --- CSV ファイルの読み書き.
                                                             (line    8)
* cte (email.headerregistry.ContentTransferEncoding の属性): email headerregistry Custom Header Objects.
                                                             (line  288)
* cte_type (email.policy.Policy の属性): email policy Policy Objects.
                                                             (line  158)
* ctermid() (os モジュール):             プロセスのパラメーター.
                                                             (line    9)
* ctime() (datetime.date のメソッド):    date オブジェクト.  (line  277)
* ctime() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  732)
* ctime() (time モジュール):             関数<5>.            (line   93)
* CTRL_BREAK_EVENT (signal モジュール):  モジュールの内容<2>.
                                                             (line  199)
* CTRL_C_EVENT (signal モジュール):      モジュールの内容<2>.
                                                             (line  190)
* ctrl() (curses.ascii モジュール):      curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  213)
* curdir (os モジュール):                雑多なシステム情報. (line  100)
* currency() (locale モジュール):        locale --- 国際化サービス.
                                                             (line  444)
* current context:                       用語集<2>.          (line  348)
* current_process() (multiprocessing モジュール): その他<3>. (line   36)
* current_task() (asyncio モジュール):   イントロスペクション.
                                                             (line    6)
* current_thread() (threading モジュール): threading --- スレッドベースの並列処理.
                                                             (line   59)
* current() (tkinter.ttk.Combobox のメソッド): ttk Combobox. (line    8)
* CurrentByteIndex (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  190)
* CurrentColumnNumber (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  194)
* currentframe() (inspect モジュール):   インタープリタスタック.
                                                             (line  157)
* CurrentLineNumber (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  198)
* curs_set() (curses モジュール):        関数<6>.            (line   61)
* Cursor (sqlite3 のクラス):             Cursor オブジェクト.
                                                             (line   20)
* cursor() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line   27)
* cursyncup() (curses.window のメソッド): Window オブジェクト.
                                                             (line  166)
* Cut [切り取り]:                        Help メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   32)
* cwd() (ftplib.FTP のメソッド):         FTP オブジェクト.   (line  334)
* cwd() (pathlib.Path のクラスメソッド): パスの展開と解決.   (line   30)
* cycle() (itertools モジュール):        Itertool関数.       (line  245)
* CycleError:                            例外<4>.            (line    8)
* D_FMT (locale モジュール):             locale --- 国際化サービス.
                                                             (line  181)
* D_T_FMT (locale モジュール):           locale --- 国際化サービス.
                                                             (line  175)
* daemon (multiprocessing.Process の属性): Process クラスと例外.
                                                             (line  101)
* daemon (threading.Thread の属性):      Thread オブジェクト.
                                                             (line  208)
* daemon_threads (socketserver.ThreadingMixIn の属性): サーバ生成に関するノート.
                                                             (line   55)
* dangling;else:                         複合文 compound statement.
                                                             (line   52)
* data (collections.UserDict の属性):    UserDict オブジェクト.
                                                             (line   22)
* data (collections.UserList の属性):    UserList オブジェクト.
                                                             (line   27)
* data (collections.UserString の属性):  UserString オブジェクト.
                                                             (line   22)
* data (select.kevent の属性):           kevent オブジェクト.
                                                             (line  174)
* data (selectors.SelectorKey の属性):   クラス<4>.          (line   48)
* data (urllib.request.Request の属性):  Request オブジェクト.
                                                             (line   39)
* data (xml.dom.Comment の属性):         Comment オブジェクト.
                                                             (line    9)
* data (xml.dom.ProcessingInstruction の属性): ProcessingInstruction オブジェクト.
                                                             (line   13)
* data (xml.dom.Text の属性):            Text オブジェクトおよび CDATASection オブジェクト.
                                                             (line   15)
* data (xmlrpc.client.Binary の属性):    Binary オブジェクト.
                                                             (line   11)
* data_filter() (tarfile モジュール):    Default named filters.
                                                             (line   36)
* data_open() (urllib.request.DataHandler のメソッド): DataHandler オブジェクト.
                                                             (line    6)
* data_received() (asyncio.Protocol のメソッド): ストリーミングプロトコル.
                                                             (line   13)
* data() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   32)
* DatabaseError:                         例外<7>.            (line   42)
* dataclass_transform() (typing モジュール): Functions and decorators.
                                                             (line  113)
* dataclass() (dataclasses モジュール):  モジュールの内容<4>.
                                                             (line    6)
* DataError:                             例外<7>.            (line   49)
* datagram_received() (asyncio.DatagramProtocol のメソッド): データグラムプロトコル.
                                                             (line   10)
* DatagramHandler (logging.handlers のクラス): DatagramHandler.
                                                             (line   10)
* DatagramProtocol (asyncio のクラス):   基底プロトコル.     (line   21)
* DatagramRequestHandler (socketserver のクラス): Request Handler Objects.
                                                             (line   55)
* DatagramTransport (asyncio のクラス):  トランスポートのクラス階層構造.
                                                             (line   44)
* DataHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  422)
* date (datetime のクラス):              date オブジェクト.  (line   12)
* date_time (zipfile.ZipInfo の属性):    ZipInfo オブジェクト.
                                                             (line   55)
* date_time_string() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  320)
* date() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  440)
* DateHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  134)
* datetime (datetime のクラス):          datetime オブジェクト.
                                                             (line   17)
* datetime (email.headerregistry.DateHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  143)
* DateTime (xmlrpc.client のクラス):     DateTime オブジェクト.
                                                             (line    6)
* Day (calendar のクラス):               calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  394)
* day (datetime.date の属性):            date オブジェクト.  (line  122)
* day (datetime.datetime の属性):        datetime オブジェクト.
                                                             (line  311)
* DAY_1 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  199)
* DAY_2 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  199)
* DAY_3 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  199)
* DAY_4 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  199)
* DAY_5 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  199)
* DAY_6 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  199)
* DAY_7 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  199)
* day_abbr (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  372)
* day_name (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  363)
* daylight (time モジュール):            Timezone Constants. (line   13)
* days (datetime.timedelta の属性):      timedelta オブジェクト.
                                                             (line   92)
* DbfilenameShelf (shelve のクラス):     制限事項.           (line   74)
* DC1 (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   75)
* DC2 (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   78)
* DC3 (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   81)
* DC4 (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   84)
* dcgettext() (locale モジュール):       メッセージカタログへのアクセス.
                                                             (line   10)
* deactivate_stack_trampoline() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line 1726)
* deallocation, object:                  ファイナライズとメモリ解放.
                                                             (line    6)
* debug (imaplib.IMAP4 の属性):          IMAP4 オブジェクト. (line  406)
* DEBUG (logging モジュール):            ロギングレベル.     (line   24)
* debug (pdb command):                   デバッガコマンド.   (line  425)
* DEBUG (re モジュール):                 フラグ.             (line   31)
* debug (shlex.shlex の属性):            shlex オブジェクト. (line  161)
* debug (sys.flags の属性):              sys --- システム固有のパラメーターと関数.
                                                             (line  512)
* debug (zipfile.ZipFile の属性):        ZipFile オブジェクト.
                                                             (line  364)
* DEBUG_BYTECODE_SUFFIXES (importlib.machinery モジュール): importlib machinery -- インポータおよびパスフック.
                                                             (line   20)
* DEBUG_COLLECTABLE (gc モジュール):     gc --- ガベージコレクターインターフェース.
                                                             (line  293)
* DEBUG_LEAK (gc モジュール):            gc --- ガベージコレクターインターフェース.
                                                             (line  313)
* DEBUG_SAVEALL (gc モジュール):         gc --- ガベージコレクターインターフェース.
                                                             (line  307)
* debug_src() (doctest モジュール):      デバッグ.           (line  144)
* DEBUG_STATS (gc モジュール):           gc --- ガベージコレクターインターフェース.
                                                             (line  288)
* DEBUG_UNCOLLECTABLE (gc モジュール):   gc --- ガベージコレクターインターフェース.
                                                             (line  297)
* debug() (doctest モジュール):          デバッグ.           (line  123)
* debug() (logging モジュール):          モジュールレベルの関数.
                                                             (line   45)
* debug() (logging.Logger のメソッド):   ロガーオブジェクト. (line  182)
* debug() (unittest.TestCase のメソッド): テストクラス.      (line  123)
* debug() (unittest.TestSuite のメソッド): テストのグループ化.
                                                             (line   48)
* debugger:                              threading --- スレッドベースの並列処理.
                                                             (line  174)
* debugger <1>:                          Debug メニュー Shell ウィンドウのみ.
                                                             (line   15)
* debugger <2>:                          sys --- システム固有のパラメーターと関数.
                                                             (line  925)
* debugger <3>:                          sys --- システム固有のパラメーターと関数.
                                                             (line 1568)
* debugger;設定;ファイル:                デバッガコマンド.   (line   56)
* debuglevel (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   70)
* DebugRunner (doctest のクラス):        デバッグ.           (line  164)
* DECEMBER (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* Decimal (decimal のクラス):            Decimal オブジェクト.
                                                             (line    6)
* decimal() (unicodedata モジュール):    unicodedata --- Unicode データベース.
                                                             (line   31)
* DecimalException (decimal のクラス):   シグナル.           (line   28)
* decode (codecs.CodecInfo の属性):      codecs --- codec レジストリと基底クラス.
                                                             (line   70)
* decode_header() (email.header モジュール): email header 国際化されたヘッダー.
                                                             (line  176)
* decode_params() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  219)
* decode_rfc2231() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  187)
* decode_source() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line   74)
* decode() (base64 モジュール):          base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  254)
* decode() (bytearray のメソッド):       bytes と bytearray の操作.
                                                             (line   92)
* decode() (bytes のメソッド):           bytes と bytearray の操作.
                                                             (line   92)
* decode() (codecs モジュール):          codecs --- codec レジストリと基底クラス.
                                                             (line   34)
* decode() (codecs.Codec のメソッド):    ステートレスなエンコードとデコード.
                                                             (line   32)
* decode() (codecs.IncrementalDecoder のメソッド): IncrementalDecoder オブジェクト.
                                                             (line   28)
* decode() (json.JSONDecoder のメソッド): エンコーダとデコーダ.
                                                             (line   88)
* decode() (quopri モジュール):          quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   19)
* decode() (xmlrpc.client.Binary のメソッド): Binary オブジェクト.
                                                             (line   19)
* decode() (xmlrpc.client.DateTime のメソッド): DateTime オブジェクト.
                                                             (line   14)
* decodebytes() (base64 モジュール):     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  261)
* DecodedGenerator (email.generator のクラス): email generator Generating MIME documents.
                                                             (line  231)
* decodestring() (quopri モジュール):    quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   42)
* decomposition() (unicodedata モジュール): unicodedata --- Unicode データベース.
                                                             (line   74)
* decompress() (bz2 モジュール):         一括圧縮/解凍.      (line   16)
* decompress() (bz2.BZ2Decompressor のメソッド): 逐次圧縮および展開.
                                                             (line   46)
* decompress() (gzip モジュール):        gzip --- gzip ファイルのサポート.
                                                             (line  214)
* decompress() (lzma モジュール):        メモリ上での圧縮と展開.
                                                             (line  180)
* decompress() (lzma.LZMADecompressor のメソッド): メモリ上での圧縮と展開.
                                                             (line  121)
* decompress() (zlib モジュール):        zlib --- gzip 互換の圧縮.
                                                             (line  134)
* decompress() (zlib.Decompress のメソッド): zlib --- gzip 互換の圧縮.
                                                             (line  258)
* decompressobj() (zlib モジュール):     zlib --- gzip 互換の圧縮.
                                                             (line  179)
* decorator:                             用語集<2>.          (line  358)
* DEDENT (token モジュール):             token --- Python 解析木で使われる定数.
                                                             (line   49)
* DEDENT トークン:                       インデント.         (line   31)
* DEDENT トークン <1>:                   複合文 compound statement.
                                                             (line   52)
* dedent() (textwrap モジュール):        textwrap --- テキストの折り返しと詰め込み.
                                                             (line   76)
* deepcopy() (copy モジュール):          copy --- 浅いコピーおよび深いコピー操作.
                                                             (line   23)
* def_prog_mode() (curses モジュール):   関数<6>.            (line   70)
* def_shell_mode() (curses モジュール):  関数<6>.            (line   77)
* default (email.policy モジュール):     email policy Policy Objects.
                                                             (line  502)
* default (inspect.Parameter の属性):    Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  218)
* default (optparse.Option の属性):      オプション属性.     (line   45)
* DEFAULT (unittest.mock モジュール):    DEFAULT.            (line    6)
* DEFAULT_BUFFER_SIZE (io モジュール):   高水準のモジュールインターフェイス.
                                                             (line    6)
* default_bufsize (xml.dom.pulldom モジュール): xml dom pulldom --- 部分的な DOM ツリー構築のサポート.
                                                             (line  102)
* default_exception_handler() (asyncio.loop のメソッド): エラーハンドリング API.
                                                             (line   35)
* default_factory (collections.defaultdict の属性): defaultdict オブジェクト.
                                                             (line   48)
* DEFAULT_FORMAT (tarfile モジュール):   tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  337)
* DEFAULT_IGNORES (filecmp モジュール):  dircmp クラス.      (line  113)
* default_loader() (xml.etree.ElementInclude モジュール): 関数<10>.
                                                             (line    6)
* default_max_str_digits (sys.int_info の属性): sys --- システム固有のパラメーターと関数.
                                                             (line 1128)
* default_open() (urllib.request.BaseHandler のメソッド): BaseHandler オブジェクト.
                                                             (line   30)
* DEFAULT_PROTOCOL (pickle モジュール):  モジュールインターフェース.
                                                             (line   21)
* DEFAULT_TIMEOUT (unittest.mock.ThreadingMock の属性): Mock クラス.
                                                             (line  970)
* default_timer() (timeit モジュール):   Python インターフェイス.
                                                             (line   31)
* default;parameter;value:               関数定義.           (line   65)
* default() (cmd.Cmd のメソッド):        Cmdオブジェクト.    (line   75)
* default() (json.JSONEncoder のメソッド): エンコーダとデコーダ.
                                                             (line  203)
* DefaultContext (decimal のクラス):     Context オブジェクト.
                                                             (line   86)
* DefaultCookiePolicy (http.cookiejar のクラス): http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line   82)
* defaultdict (collections のクラス):    defaultdict オブジェクト.
                                                             (line    6)
* DefaultDict (typing のクラス):         Aliases to types in collections.
                                                             (line    6)
* DefaultEventLoopPolicy (asyncio のクラス): ポリシーオブジェクト.
                                                             (line   55)
* DefaultHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  342)
* DefaultHandlerExpand() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  349)
* defaults() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  108)
* DefaultSelector (selectors のクラス):  クラス<4>.          (line  164)
* defaultTestLoader (unittest モジュール): テストのロードと起動.
                                                             (line  447)
* defaultTestResult() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  741)
* defects (email.headerregistry.BaseHeader の属性): email headerregistry Custom Header Objects.
                                                             (line   53)
* defects (email.message.EmailMessage の属性): email message Representing an email message.
                                                             (line  714)
* defects (email.message.Message の属性): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  730)
* defpath (os モジュール):               雑多なシステム情報. (line  142)
* DefragResult (urllib.parse のクラス):  構造化された解析結果.
                                                             (line   39)
* DefragResultBytes (urllib.parse のクラス): 構造化された解析結果.
                                                             (line   64)
* degrees() (math モジュール):           角度変換.           (line    6)
* degrees() (turtle モジュール):         設定と計測.         (line    6)
* Del (ast のクラス):                    変数.               (line   11)
* DEL (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  123)
* del_param() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  384)
* del_param() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  547)
* delay_output() (curses モジュール):    関数<6>.            (line   85)
* delay() (turtle モジュール):           アニメーションの制御.
                                                             (line    6)
* delayload (http.cookiejar.FileCookieJar の属性): CookieJar および FileCookieJar オブジェクト.
                                                             (line  166)
* delch() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  171)
* dele() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   67)
* Delete (ast のクラス):                 文 Statements.      (line  139)
* DELETE_ATTR (opcode):                  Python バイトコード命令.
                                                             (line  606)
* DELETE_DEREF (opcode):                 Python バイトコード命令.
                                                             (line  985)
* DELETE_FAST (opcode):                  Python バイトコード命令.
                                                             (line  946)
* DELETE_GLOBAL (opcode):                Python バイトコード命令.
                                                             (line  621)
* DELETE_NAME (opcode):                  Python バイトコード命令.
                                                             (line  560)
* DELETE_SUBSCR (opcode):                Python バイトコード命令.
                                                             (line  261)
* delete() (ftplib.FTP のメソッド):      FTP オブジェクト.   (line  327)
* delete() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line   75)
* delete() (tkinter.ttk.Treeview のメソッド): ttk Treeview.  (line   74)
* deleteacl() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line   79)
* deletefilehandler() (_tkinter.Widget.tk のメソッド): ファイルハンドラ.
                                                             (line   38)
* DeleteKey() (winreg モジュール):       関数<13>.           (line  101)
* DeleteKeyEx() (winreg モジュール):     関数<13>.           (line  123)
* deleteln() (curses.window のメソッド): Window オブジェクト.
                                                             (line  175)
* deleteMe() (bdb.Breakpoint のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line   42)
* DeleteValue() (winreg モジュール):     関数<13>.           (line  159)
* deletion;target:                       del 文<2>.          (line    6)
* deletion;target;list:                  del 文<2>.          (line    6)
* delimiter (csv.Dialect の属性):        Dialect クラスと書式化パラメータ.
                                                             (line   19)
* delitem() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  186)
* deliver_challenge() (multiprocessing.connection モジュール): リスナーとクライアント.
                                                             (line   15)
* delocalize() (locale モジュール):      locale --- 国際化サービス.
                                                             (line  465)
* demo_app() (wsgiref.simple_server モジュール): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   36)
* denominator (fractions.Fraction の属性): fractions --- 有理数.
                                                             (line  115)
* denominator (numbers.Rational の属性): 数値塔.             (line   55)
* deprecated() (warnings モジュール):    利用可能な関数.     (line  132)
* DeprecationWarning:                    警告.               (line   17)
* deque (collections のクラス):          deque オブジェクト. (line    6)
* Deque (typing のクラス):               Aliases to types in collections.
                                                             (line   49)
* dequeue() (logging.handlers.QueueListener のメソッド): QueueListener.
                                                             (line   49)
* DER_cert_to_PEM_cert() (ssl モジュール): 証明書の取り扱い. (line   53)
* derive() (BaseExceptionGroup のメソッド): 例外グループ.    (line   71)
* derwin() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  180)
* descrgetfunc (C type):                 Slot Type typedefs. (line   74)
* description (inspect.Parameter.kind の属性): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  278)
* description (sqlite3.Cursor の属性):   Cursor オブジェクト.
                                                             (line  189)
* descriptor:                            用語集<2>.          (line  379)
* descrsetfunc (C type):                 Slot Type typedefs. (line   79)
* deserialize() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  712)
* dest (optparse.Option の属性):         オプション属性.     (line   35)
* destructor (C type):                   Slot Type typedefs. (line   25)
* detach() (io.BufferedIOBase のメソッド): I/O 基底クラス.   (line  257)
* detach() (io.TextIOBase のメソッド):   テキスト I/O<2>.    (line   37)
* detach() (socket.socket のメソッド):   socket オブジェクト.
                                                             (line  100)
* detach() (tkinter.ttk.Treeview のメソッド): ttk Treeview.  (line   80)
* detach() (weakref.finalize のメソッド): weakref --- 弱参照.
                                                             (line  291)
* Detach() (winreg.PyHKEY のメソッド):   レジストリハンドルオブジェクト.
                                                             (line   41)
* DETACHED_PROCESS (subprocess モジュール): Windows Constants.
                                                             (line  122)
* detect_api_mismatch() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  641)
* detect_encoding() (tokenize モジュール): 入力のトークナイズ.
                                                             (line   77)
* deterministic profiling:               プロファイラとは.   (line    6)
* dev_mode (sys.flags の属性):           sys --- システム固有のパラメーターと関数.
                                                             (line  551)
* device_encoding() (os モジュール):     ファイル記述子の操作.
                                                             (line   81)
* devmajor (tarfile.TarInfo の属性):     TarInfo オブジェクト.
                                                             (line  143)
* devminor (tarfile.TarInfo の属性):     TarInfo オブジェクト.
                                                             (line  147)
* devnull (os モジュール):               雑多なシステム情報. (line  157)
* DEVNULL (subprocess モジュール):       subprocess モジュールを使う.
                                                             (line  142)
* devpoll() (select モジュール):         select --- I/O 完了の待機.
                                                             (line   36)
* DevpollSelector (selectors のクラス):  クラス<4>.          (line  187)
* dgettext() (gettext モジュール):       GNU gettext API.    (line   40)
* dgettext() (locale モジュール):        メッセージカタログへのアクセス.
                                                             (line    8)
* Dialect (csv のクラス):                モジュールコンテンツ<3>.
                                                             (line  182)
* dialect (csv.csvreader の属性):        reader オブジェクト.
                                                             (line   20)
* dialect (csv.csvwriter の属性):        writer オブジェクト.
                                                             (line   33)
* Dialog (tkinter.commondialog のクラス): tkinter commondialog --- Dialog window templates.
                                                             (line   14)
* Dialog (tkinter.simpledialog のクラス): tkinter simpledialog --- 標準 Tkinter 入力ダイアログ.
                                                             (line   20)
* Dict (ast のクラス):                   リテラル<3>.        (line  103)
* Dict (typing のクラス):                Aliases to built-in types.
                                                             (line    6)
* dict (組み込みクラス):                 マッピング型 --- dict.
                                                             (line   20)
* DICT_MERGE (opcode):                   Python バイトコード命令.
                                                             (line  737)
* DICT_UPDATE (opcode):                  Python バイトコード命令.
                                                             (line  726)
* dict() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  224)
* DictComp (ast のクラス):               内包表記 Comprehension.
                                                             (line    6)
* dictConfig() (logging.config モジュール): 環境設定のための関数.
                                                             (line   13)
* dictionary:                            用語集<2>.          (line  396)
* dictionary comprehension:              用語集<2>.          (line  402)
* dictionary view:                       用語集<2>.          (line  410)
* dictionary;内包表記:                   辞書表示.           (line    6)
* dictionary;表示:                       辞書表示.           (line    6)
* DictReader (csv のクラス):             モジュールコンテンツ<3>.
                                                             (line  101)
* DictWriter (csv のクラス):             モジュールコンテンツ<3>.
                                                             (line  148)
* diff_bytes() (difflib モジュール):     difflib --- 差分の計算の補助.
                                                             (line  330)
* diff_files (filecmp.dircmp の属性):    dircmp クラス.      (line   93)
* Differ (difflib のクラス):             difflib --- 差分の計算の補助.
                                                             (line   49)
* difference_update() (frozenset のメソッド): set（集合）型 --- set frozenset.
                                                             (line  180)
* difference() (frozenset のメソッド):   set（集合）型 --- set frozenset.
                                                             (line  108)
* dig (sys.float_info の属性):           sys --- システム固有のパラメーターと関数.
                                                             (line  612)
* digest_size (hmac.HMAC の属性):        hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   90)
* digest() (hashlib.hash のメソッド):    Hash Objects.       (line   37)
* digest() (hashlib.shake のメソッド):   SHAKE 可変長ダイジェスト.
                                                             (line   15)
* digest() (hmac モジュール):            hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   31)
* digest() (hmac.HMAC のメソッド):       hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   57)
* digit() (unicodedata モジュール):      unicodedata --- Unicode データベース.
                                                             (line   37)
* digits (string モジュール):            文字列定数.         (line   23)
* dir() (ftplib.FTP のメソッド):         FTP オブジェクト.   (line  308)
* dircmp (filecmp のクラス):             dircmp クラス.      (line    6)
* Directory (tkinter.filedialog のクラス): ネイティブの読み込み/保存ダイアログ.
                                                             (line   70)
* DirEntry (os のクラス):                ファイルとディレクトリ.
                                                             (line  932)
* dirname() (os.path モジュール):        os path --- 一般的なパス名操作.
                                                             (line  102)
* dirs_double_event() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line   85)
* dirs_select_event() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line   89)
* DirsOnSysPath (test.support.import_helper のクラス): test support import_helper --- Utilities for import tests.
                                                             (line   97)
* DIRTYPE (tarfile モジュール):          tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  297)
* dis コマンドラインオプション; -C:      コマンドライン・インターフェース<2>.
                                                             (line   17)
* dis コマンドラインオプション; -h:      コマンドライン・インターフェース<2>.
                                                             (line   13)
* dis コマンドラインオプション; -help:   コマンドライン・インターフェース<2>.
                                                             (line   13)
* dis コマンドラインオプション; -O:      コマンドライン・インターフェース<2>.
                                                             (line   21)
* dis コマンドラインオプション; -show-caches: コマンドライン・インターフェース<2>.
                                                             (line   17)
* dis コマンドラインオプション; -show-offsets: コマンドライン・インターフェース<2>.
                                                             (line   21)
* dis() (dis モジュール):                解析関数.           (line   37)
* dis() (dis.Bytecode のメソッド):       バイトコード解析.   (line   57)
* dis() (pickletools モジュール):        プログラミングインターフェース<2>.
                                                             (line    6)
* disable (pdb command):                 デバッガコマンド.   (line  132)
* DISABLE (sys.monitoring モジュール):   Disabling events.   (line    6)
* disable_faulthandler() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  356)
* disable_gc() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  368)
* disable_interspersed_args() (optparse.OptionParser のメソッド): オプション解析器への問い合わせと操作.
                                                             (line   10)
* disable() (bdb.Breakpoint のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line   53)
* disable() (faulthandler モジュール):   フォールトハンドラの状態.
                                                             (line   26)
* disable() (gc モジュール):             gc --- ガベージコレクターインターフェース.
                                                             (line   25)
* disable() (logging モジュール):        モジュールレベルの関数.
                                                             (line  104)
* disable() (profile.Profile のメソッド): リファレンスマニュアル -- profile と cProfile.
                                                             (line   80)
* disabled (logging.Logger の属性):      ロガーオブジェクト. (line   96)
* DisableReflectionKey() (winreg モジュール): 関数<13>.      (line  477)
* disassemble() (dis モジュール):        解析関数.           (line   96)
* discard (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   59)
* discard() (frozenset のメソッド):      set（集合）型 --- set frozenset.
                                                             (line  202)
* discard() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line   76)
* discard() (mailbox.MH のメソッド):     MH オブジェクト.    (line   81)
* discover() (unittest.TestLoader のメソッド): テストのロードと起動.
                                                             (line  115)
* disk_usage() (shutil モジュール):      ディレクトリとファイルの操作.
                                                             (line  381)
* dispatch_call() (bdb.Bdb のメソッド):  bdb --- デバッガーフレームワーク.
                                                             (line  212)
* dispatch_exception() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  232)
* dispatch_line() (bdb.Bdb のメソッド):  bdb --- デバッガーフレームワーク.
                                                             (line  202)
* dispatch_return() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  222)
* dispatch_table (pickle.Pickler の属性): モジュールインターフェース.
                                                             (line  181)
* DISPLAY:                               Tkinter モジュール. (line   27)
* display (pdb command):                 デバッガコマンド.   (line  286)
* display_name (email.headerregistry.Address の属性): email headerregistry Custom Header Objects.
                                                             (line  420)
* display_name (email.headerregistry.Group の属性): email headerregistry Custom Header Objects.
                                                             (line  464)
* displayhook() (sys モジュール):        sys --- システム固有のパラメーターと関数.
                                                             (line  288)
* dist() (math モジュール):              三角関数.           (line   33)
* distance() (turtle モジュール):        Turtle の状態を知る.
                                                             (line   66)
* Distribution (importlib.metadata のクラス): Distributions. (line   14)
* distribution() (importlib.metadata モジュール): Distributions.
                                                             (line    6)
* Div (ast のクラス):                    式 expression<2>.   (line   55)
* divide_int() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  287)
* divide() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  283)
* division:                              二項算術演算 binary arithmetic operation.
                                                             (line   33)
* DivisionByZero (decimal のクラス):     シグナル.           (line   33)
* divmod() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  291)
* DLE (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   72)
* DllCanUnloadNow() (ctypes モジュール): ユーティリティー関数.
                                                             (line   73)
* DllGetClassObject() (ctypes モジュール): ユーティリティー関数.
                                                             (line   79)
* dllhandle (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line  282)
* dnd_start() (tkinter.dnd モジュール):  tkinter dnd --- ドラッグアンドドロップのサポート.
                                                             (line   65)
* DndHandler (tkinter.dnd のクラス):     tkinter dnd --- ドラッグアンドドロップのサポート.
                                                             (line   43)
* dngettext() (gettext モジュール):      GNU gettext API.    (line   59)
* dnpgettext() (gettext モジュール):     GNU gettext API.    (line   70)
* do_clear() (bdb.Bdb のメソッド):       bdb --- デバッガーフレームワーク.
                                                             (line  295)
* do_command() (curses.textpad.Textbox のメソッド): Textbox オブジェクト.
                                                             (line   31)
* do_GET() (http.server.SimpleHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  385)
* do_handshake() (ssl.SSLSocket のメソッド): SSL ソケット.   (line  127)
* do_HEAD() (http.server.SimpleHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  378)
* do_help() (cmd.Cmd のメソッド):        Cmdオブジェクト.    (line   48)
* do_POST() (http.server.CGIHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  512)
* doc (json.JSONDecodeError の属性):     例外<16>.           (line   14)
* doc_header (cmd.Cmd の属性):           Cmdオブジェクト.    (line  153)
* DocCGIXMLRPCRequestHandler (xmlrpc.server のクラス): XMLRPC サーバの文書化.
                                                             (line   22)
* DocFileSuite() (doctest モジュール):   単体テスト API.     (line   25)
* doClassCleanups() (unittest.TestCase のクラスメソッド): テストクラス.
                                                             (line  832)
* doCleanups() (unittest.TestCase のメソッド): テストクラス. (line  792)
* docmd() (smtplib.SMTP のメソッド):     SMTP オブジェクト.  (line   17)
* docstring:                             クラス定義.         (line    6)
* docstring <1>:                         用語集<2>.          (line  419)
* docstring (doctest.DocTest の属性):    DocTest オブジェクト.
                                                             (line   47)
* docstrings:                            関数を定義する.     (line   21)
* docstrings <1>:                        ドキュメンテーション文字列.
                                                             (line    6)
* DocTest (doctest のクラス):            DocTest オブジェクト.
                                                             (line    6)
* DocTestFailure:                        デバッグ.           (line  182)
* DocTestFinder (doctest のクラス):      DocTestFinder オブジェクト.
                                                             (line    6)
* DocTestParser (doctest のクラス):      DocTestParser オブジェクト.
                                                             (line    6)
* DocTestRunner (doctest のクラス):      DocTestRunner オブジェクト.
                                                             (line    6)
* DocTestSuite() (doctest モジュール):   単体テスト API.     (line  103)
* doctype() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   65)
* documentation strings:                 関数を定義する.     (line   21)
* documentation strings <1>:             ドキュメンテーション文字列.
                                                             (line    6)
* documentation;generation:              pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line    8)
* documentation;online:                  pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line    8)
* documentElement (xml.dom.Document の属性): Document オブジェクト.
                                                             (line   10)
* DocXMLRPCRequestHandler (xmlrpc.server のクラス): XMLRPC サーバの文書化.
                                                             (line   27)
* DocXMLRPCServer (xmlrpc.server のクラス): XMLRPC サーバの文書化.
                                                             (line   11)
* domain (email.headerregistry.Address の属性): email headerregistry Custom Header Objects.
                                                             (line  430)
* domain (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   40)
* domain (http.cookies.Morsel の属性):   Morselオブジェクト. (line   13)
* domain (tracemalloc.DomainFilter の属性): DomainFilter.    (line   20)
* domain (tracemalloc.Filter の属性):    Filter.             (line   31)
* domain (tracemalloc.Trace の属性):     Trace.              (line   15)
* domain_initial_dot (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   91)
* domain_return_ok() (http.cookiejar.CookiePolicy のメソッド): CookiePolicy オブジェクト.
                                                             (line   27)
* domain_specified (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   87)
* DomainFilter (tracemalloc のクラス):   DomainFilter.       (line    6)
* DomainLiberal (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  158)
* DomainRFC2965Match (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  150)
* DomainStrict (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  163)
* DomainStrictNoDots (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  136)
* DomainStrictNonDomain (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  143)
* DOMEventStream (xml.dom.pulldom のクラス): DOMEventStream オブジェクト.
                                                             (line    6)
* DOMException:                          例外<19>.           (line   17)
* doModuleCleanups() (unittest モジュール): setUpModule と tearDownModule.
                                                             (line   44)
* DomstringSizeErr:                      例外<19>.           (line   22)
* done() (asyncio.Future のメソッド):    Future オブジェクト<2>.
                                                             (line   64)
* done() (asyncio.Task のメソッド):      Task オブジェクト.  (line   67)
* done() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   32)
* done() (graphlib.TopologicalSorter のメソッド): graphlib --- グラフ構造を操作する機能.
                                                             (line  132)
* done() (turtle モジュール):            スクリーンイベントを利用する.
                                                             (line  105)
* DONT_ACCEPT_BLANKLINE (doctest モジュール): オプションフラグ.
                                                             (line   30)
* DONT_ACCEPT_TRUE_FOR_1 (doctest モジュール): オプションフラグ.
                                                             (line   18)
* dont_write_bytecode (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line  325)
* dont_write_bytecode (sys.flags の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  527)
* doRollover() (logging.handlers.RotatingFileHandler のメソッド): RotatingFileHandler.
                                                             (line   45)
* doRollover() (logging.handlers.TimedRotatingFileHandler のメソッド): TimedRotatingFileHandler.
                                                             (line  102)
* DOT (token モジュール):                token --- Python 解析木で使われる定数.
                                                             (line  115)
* dot() (turtle モジュール):             Turtle の動き.      (line  248)
* DOTALL (re モジュール):                フラグ.             (line  103)
* doublequote (csv.Dialect の属性):      Dialect クラスと書式化パラメータ.
                                                             (line   24)
* DOUBLESLASH (token モジュール):        token --- Python 解析木で使われる定数.
                                                             (line  211)
* DOUBLESLASHEQUAL (token モジュール):   token --- Python 解析木で使われる定数.
                                                             (line  215)
* DOUBLESTAR (token モジュール):         token --- Python 解析木で使われる定数.
                                                             (line  163)
* DOUBLESTAREQUAL (token モジュール):    token --- Python 解析木で使われる定数.
                                                             (line  207)
* doupdate() (curses モジュール):        関数<6>.            (line   89)
* down (pdb command):                    デバッガコマンド.   (line   84)
* down() (turtle モジュール):            描画状態.           (line    6)
* dpgettext() (gettext モジュール):      GNU gettext API.    (line   66)
* drain() (asyncio.StreamWriter のメソッド): StreamWriter.   (line   68)
* drive (pathlib.PurePath の属性):       メソッドとプロパティ.
                                                             (line   15)
* drop_whitespace (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  198)
* dropwhile() (itertools モジュール):    Itertool関数.       (line  266)
* dst() (datetime.datetime のメソッド):  datetime オブジェクト.
                                                             (line  539)
* dst() (datetime.time のメソッド):      time オブジェクト.  (line  241)
* dst() (datetime.timezone のメソッド):  timezone オブジェクト.
                                                             (line   57)
* dst() (datetime.tzinfo のメソッド):    tzinfo オブジェクト.
                                                             (line   66)
* DTDHandler (xml.sax.handler のクラス): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   24)
* duck-typing:                           用語集<2>.          (line  428)
* dump_stats() (profile.Profile のメソッド): リファレンスマニュアル -- profile と cProfile.
                                                             (line  102)
* dump_stats() (pstats.Stats のメソッド): Stats クラス.      (line   53)
* dump_traceback_later() (faulthandler モジュール): タイムアウト後にtracebackをダンプする.
                                                             (line    6)
* dump_traceback() (faulthandler モジュール): tracebackのダンプ.
                                                             (line    6)
* dump() (ast モジュール):               ast ヘルパー.       (line  269)
* dump() (json モジュール):              基本的な使い方<2>.  (line    6)
* dump() (marshal モジュール):           marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line   51)
* dump() (pickle モジュール):            モジュールインターフェース.
                                                             (line   35)
* dump() (pickle.Pickler のメソッド):    モジュールインターフェース.
                                                             (line  157)
* dump() (plistlib モジュール):          plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line   92)
* dump() (tracemalloc.Snapshot のメソッド): Snapshot.        (line   29)
* dump() (xml.etree.ElementTree モジュール): 関数<9>.        (line   85)
* dumps() (json モジュール):             基本的な使い方<2>.  (line   81)
* dumps() (marshal モジュール):          marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line   93)
* dumps() (pickle モジュール):           モジュールインターフェース.
                                                             (line   47)
* dumps() (plistlib モジュール):         plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line  129)
* dumps() (xmlrpc.client モジュール):    補助関数.           (line    6)
* dup() (os モジュール):                 ファイル記述子の操作.
                                                             (line   93)
* dup() (socket.socket のメソッド):      socket オブジェクト.
                                                             (line  108)
* dup2() (os モジュール):                ファイル記述子の操作.
                                                             (line  106)
* DuplicateOptionError:                  例外<8>.            (line   24)
* DuplicateSectionError:                 例外<8>.            (line   14)
* dwFlags (subprocess.STARTUPINFO の属性): Windows Popen ヘルパー.
                                                             (line   20)
* DynamicClassAttribute() (types モジュール): 追加のユーティリティクラスと関数.
                                                             (line   55)
* e (cmath モジュール):                  定数<3>.            (line   10)
* e (math モジュール):                   定数<2>.            (line   10)
* e;in numeric literal:                  整数リテラル.       (line   40)
* E2BIG (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line   56)
* EACCES (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line   82)
* EADDRINUSE (errno モジュール):         errno --- 標準の errno システムシンボル.
                                                             (line  450)
* EADDRNOTAVAIL (errno モジュール):      errno --- 標準の errno システムシンボル.
                                                             (line  454)
* EADV (errno モジュール):               errno --- 標準の errno システムシンボル.
                                                             (line  313)
* EAFNOSUPPORT (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  445)
* EAFP:                                  用語集<2>.          (line  442)
* EAGAIN (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line   73)
* eager_task_factory() (asyncio モジュール): Eager Task Factory.
                                                             (line    6)
* EALREADY (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  523)
* east_asian_width() (unicodedata モジュール): unicodedata --- Unicode データベース.
                                                             (line   63)
* EBADE (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  248)
* EBADF (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line   64)
* EBADFD (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  350)
* EBADMSG (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  337)
* EBADR (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  252)
* EBADRQC (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  264)
* EBADSLT (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  268)
* EBFONT (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  277)
* EBUSY (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line   95)
* ECANCELED (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  576)
* ECHILD (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line   68)
* echo() (curses モジュール):            関数<6>.            (line  105)
* echochar() (curses.window のメソッド): Window オブジェクト.
                                                             (line  189)
* ECHRNG (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  215)
* ECOMM (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  321)
* ECONNABORTED (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  472)
* ECONNREFUSED (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  510)
* ECONNRESET (errno モジュール):         errno --- 標準の errno システムシンボル.
                                                             (line  477)
* EDEADLK (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  177)
* EDEADLOCK (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  272)
* EDESTADDRREQ (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  404)
* edit() (curses.textpad.Textbox のメソッド): Textbox オブジェクト.
                                                             (line   20)
* EDOM (errno モジュール):               errno --- 標準の errno システムシンボル.
                                                             (line  167)
* EDOTDOT (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  333)
* EDQUOT (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  557)
* EEXIST (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line   99)
* EFAULT (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line   87)
* EFBIG (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  142)
* EFD_CLOEXEC (os モジュール):           ファイルとディレクトリ.
                                                             (line 1948)
* EFD_NONBLOCK (os モジュール):          ファイルとディレクトリ.
                                                             (line 1957)
* EFD_SEMAPHORE (os モジュール):         ファイルとディレクトリ.
                                                             (line 1966)
* effective() (bdb モジュール):          bdb --- デバッガーフレームワーク.
                                                             (line  469)
* ehlo_or_helo_if_needed() (smtplib.SMTP のメソッド): SMTP オブジェクト.
                                                             (line   71)
* ehlo() (smtplib.SMTP のメソッド):      SMTP オブジェクト.  (line   56)
* EHOSTDOWN (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  515)
* EHOSTUNREACH (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  519)
* EIDRM (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  211)
* EILSEQ (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  383)
* EINPROGRESS (errno モジュール):        errno --- 標準の errno システムシンボル.
                                                             (line  528)
* EINTR (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line   42)
* EINVAL (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  122)
* EIO (errno モジュール):                errno --- 標準の errno システムシンボル.
                                                             (line   47)
* EISCONN (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  486)
* EISDIR (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  117)
* EISNAM (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  549)
* EJECT (enum.FlagBoundary の属性):      データ型<2>.        (line  674)
* EL2HLT (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  244)
* EL2NSYNC (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  219)
* EL3HLT (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  223)
* EL3RST (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  227)
* Element (xml.etree.ElementTree のクラス): Element オブジェクト.
                                                             (line    6)
* element_create() (tkinter.ttk.Style のメソッド): Ttk スタイル.
                                                             (line  133)
* element_names() (tkinter.ttk.Style のメソッド): Ttk スタイル.
                                                             (line  252)
* element_options() (tkinter.ttk.Style のメソッド): Ttk スタイル.
                                                             (line  256)
* ElementDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  234)
* elements() (collections.Counter のメソッド): Counter オブジェクト.
                                                             (line   65)
* ElementTree (xml.etree.ElementTree のクラス): ElementTree オブジェクト.
                                                             (line    6)
* ELIBACC (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  358)
* ELIBBAD (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  363)
* ELIBEXEC (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  378)
* ELIBMAX (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  373)
* ELIBSCN (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  368)
* ELLIPSIS (doctest モジュール):         オプションフラグ.   (line   48)
* ELLIPSIS (token モジュール):           token --- Python 解析木で使われる定数.
                                                             (line  231)
* Ellipsis (組み込み変数):               組み込み定数.       (line   56)
* EllipsisType (types モジュール):       標準的なインタプリタ型.
                                                             (line  143)
* ELNRNG (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  231)
* ELOOP (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  197)
* else;conditional expression:           条件式 Conditional Expressions.
                                                             (line    6)
* EM (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   99)
* EmailMessage (email.message のクラス): email message Representing an email message.
                                                             (line   52)
* EmailPolicy (email.policy のクラス):   email policy Policy Objects.
                                                             (line  358)
* EMFILE (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  130)
* emit() (logging.FileHandler のメソッド): FileHandler.      (line   31)
* emit() (logging.Handler のメソッド):   ハンドラオブジェクト.
                                                             (line  109)
* emit() (logging.handlers.BufferingHandler のメソッド): MemoryHandler.
                                                             (line   24)
* emit() (logging.handlers.DatagramHandler のメソッド): DatagramHandler.
                                                             (line   29)
* emit() (logging.handlers.HTTPHandler のメソッド): HTTPHandler.
                                                             (line   35)
* emit() (logging.handlers.NTEventLogHandler のメソッド): NTEventLogHandler.
                                                             (line   37)
* emit() (logging.handlers.QueueHandler のメソッド): QueueHandler.
                                                             (line   35)
* emit() (logging.handlers.RotatingFileHandler のメソッド): RotatingFileHandler.
                                                             (line   49)
* emit() (logging.handlers.SMTPHandler のメソッド): SMTPHandler.
                                                             (line   34)
* emit() (logging.handlers.SocketHandler のメソッド): SocketHandler.
                                                             (line   24)
* emit() (logging.handlers.SysLogHandler のメソッド): SysLogHandler.
                                                             (line   61)
* emit() (logging.handlers.TimedRotatingFileHandler のメソッド): TimedRotatingFileHandler.
                                                             (line  106)
* emit() (logging.handlers.WatchedFileHandler のメソッド): WatchedFileHandler.
                                                             (line   50)
* emit() (logging.NullHandler のメソッド): NullHandler.      (line   16)
* emit() (logging.StreamHandler のメソッド): StreamHandler.  (line   18)
* EMLINK (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  158)
* Empty:                                 queue --- 同期キュークラス.
                                                             (line   77)
* empty (inspect.Parameter の属性):      Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  201)
* empty (inspect.Signature の属性):      Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  100)
* EMPTY_NAMESPACE (xml.dom モジュール):  モジュールコンテンツ<4>.
                                                             (line   34)
* empty() (asyncio.Queue のメソッド):    Queue.              (line   26)
* empty() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  116)
* empty() (multiprocessing.SimpleQueue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  229)
* empty() (queue.Queue のメソッド):      キューオブジェクト. (line   15)
* empty() (queue.SimpleQueue のメソッド): SimpleQueue オブジェクト.
                                                             (line   15)
* empty() (sched.scheduler のメソッド):  スケジューラオブジェクト.
                                                             (line   46)
* emptyline() (cmd.Cmd のメソッド):      Cmdオブジェクト.    (line   69)
* emscripten_version (sys._emscripten_info の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  339)
* EMSGSIZE (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  408)
* EMULTIHOP (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  329)
* enable (pdb command):                  デバッガコマンド.   (line  139)
* enable_callback_tracebacks() (sqlite3 モジュール): モジュール関数.
                                                             (line  128)
* enable_interspersed_args() (optparse.OptionParser のメソッド): オプション解析器への問い合わせと操作.
                                                             (line   33)
* enable_load_extension() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  435)
* enable_traversal() (tkinter.ttk.Notebook のメソッド): ttk Notebook.
                                                             (line   74)
* ENABLE_USER_SITE (site モジュール):    モジュールの内容<5>.
                                                             (line   10)
* enable() (bdb.Breakpoint のメソッド):  bdb --- デバッガーフレームワーク.
                                                             (line   49)
* enable() (faulthandler モジュール):    フォールトハンドラの状態.
                                                             (line    6)
* enable() (gc モジュール):              gc --- ガベージコレクターインターフェース.
                                                             (line   21)
* enable() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line   83)
* enable() (profile.Profile のメソッド): リファレンスマニュアル -- profile と cProfile.
                                                             (line   76)
* EnableControlFlowGuard:                Build<30>.          (line   47)
* enabled (bdb.Breakpoint の属性):       bdb --- デバッガーフレームワーク.
                                                             (line  107)
* EnableReflectionKey() (winreg モジュール): 関数<13>.       (line  495)
* ENAMETOOLONG (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  181)
* ENAVAIL (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  545)
* enclose() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  194)
* encode (codecs.CodecInfo の属性):      codecs --- codec レジストリと基底クラス.
                                                             (line   70)
* encode_7or8bit() (email.encoders モジュール): email encoders エンコーダー.
                                                             (line   58)
* encode_base64() (email.encoders モジュール): email encoders エンコーダー.
                                                             (line   49)
* encode_noop() (email.encoders モジュール): email encoders エンコーダー.
                                                             (line   64)
* encode_quopri() (email.encoders モジュール): email encoders エンコーダー.
                                                             (line   41)
* encode_rfc2231() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  191)
* encode() (base64 モジュール):          base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  269)
* encode() (codecs モジュール):          codecs --- codec レジストリと基底クラス.
                                                             (line   23)
* encode() (codecs.Codec のメソッド):    ステートレスなエンコードとデコード.
                                                             (line   12)
* encode() (codecs.IncrementalEncoder のメソッド): IncrementalEncoder オブジェクト.
                                                             (line   28)
* encode() (email.header.Header のメソッド): email header 国際化されたヘッダー.
                                                             (line  121)
* encode() (json.JSONEncoder のメソッド): エンコーダとデコーダ.
                                                             (line  222)
* encode() (quopri モジュール):          quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   30)
* encode() (str のメソッド):             文字列メソッド<2>.  (line   61)
* encode() (xmlrpc.client.Binary のメソッド): Binary オブジェクト.
                                                             (line   24)
* encode() (xmlrpc.client.DateTime のメソッド): DateTime オブジェクト.
                                                             (line   18)
* encodebytes() (base64 モジュール):     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  279)
* EncodedFile() (codecs モジュール):     codecs --- codec レジストリと基底クラス.
                                                             (line  205)
* encodePriority() (logging.handlers.SysLogHandler のメソッド): SysLogHandler.
                                                             (line   93)
* encodestring() (quopri モジュール):    quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   47)
* encoding (curses.window の属性):       Window オブジェクト.
                                                             (line  204)
* encoding (io.TextIOBase の属性):       テキスト I/O<2>.    (line   15)
* ENCODING (tarfile モジュール):         tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  271)
* ENCODING (token モジュール):           token --- Python 解析木で使われる定数.
                                                             (line  281)
* encoding (UnicodeError の属性):        具象例外.           (line  413)
* encoding declarations (source file):   エンコード宣言 encoding declaration.
                                                             (line    6)
* encodings_map (mimetypes モジュール):  mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  149)
* encodings_map (mimetypes.MimeTypes の属性): Mime 型オブジェクト.
                                                             (line   32)
* EncodingWarning:                       警告.               (line   67)
* end (UnicodeError の属性):             具象例外.           (line  430)
* END_ASYNC_FOR (opcode):                Python バイトコード命令.
                                                             (line  329)
* end_col_offset (ast.AST の属性):       Node クラス.        (line   49)
* end_fill() (turtle モジュール):        塗りつぶし.         (line   20)
* END_FOR (opcode):                      Python バイトコード命令.
                                                             (line  136)
* end_headers() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  276)
* end_lineno (ast.AST の属性):           Node クラス.        (line   49)
* end_lineno (SyntaxError の属性):       具象例外.           (line  313)
* end_lineno (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   99)
* end_ns() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   84)
* end_offset (SyntaxError の属性):       具象例外.           (line  318)
* end_offset (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line  114)
* end_poly() (turtle モジュール):        特別な Turtle のメソッド.
                                                             (line   11)
* END_SEND (opcode):                     Python バイトコード命令.
                                                             (line  143)
* end() (re.Match のメソッド):           マッチオブジェクト. (line  140)
* end() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   37)
* endCDATA() (xml.sax.handler.LexicalHandler のメソッド): LexicalHandler Objects.
                                                             (line   39)
* EndCdataSectionHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  338)
* EndDoctypeDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  229)
* endDocument() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   38)
* endDTD() (xml.sax.handler.LexicalHandler のメソッド): LexicalHandler Objects.
                                                             (line   28)
* endElement() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   89)
* EndElementHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  260)
* endElementNS() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line  113)
* endheaders() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line  185)
* ENDMARKER (token モジュール):          token --- Python 解析木で使われる定数.
                                                             (line   37)
* EndNamespaceDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  318)
* endpos (re.Match の属性):              マッチオブジェクト. (line  177)
* endPrefixMapping() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   68)
* endswith() (bytearray のメソッド):     bytes と bytearray の操作.
                                                             (line  122)
* endswith() (bytes のメソッド):         bytes と bytearray の操作.
                                                             (line  122)
* endswith() (str のメソッド):           文字列メソッド<2>.  (line   86)
* endwin() (curses モジュール):          関数<6>.            (line  110)
* ENETDOWN (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  459)
* ENETRESET (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  467)
* ENETUNREACH (errno モジュール):        errno --- 標準の errno システムシンボル.
                                                             (line  463)
* ENFILE (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  126)
* ENOANO (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  260)
* ENOBUFS (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  482)
* ENOCSI (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  240)
* ENODATA (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  285)
* ENODEV (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  108)
* ENOENT (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line   32)
* ENOEXEC (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line   60)
* ENOLCK (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  185)
* ENOLINK (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  309)
* ENOMEM (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line   78)
* ENOMSG (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  207)
* ENONET (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  297)
* ENOPKG (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  301)
* ENOPROTOOPT (errno モジュール):        errno --- 標準の errno システムシンボル.
                                                             (line  417)
* ENOSPC (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  146)
* ENOSR (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  293)
* ENOSTR (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  281)
* ENOSYS (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  189)
* ENOTBLK (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line   91)
* ENOTCAPABLE (errno モジュール):        errno --- 標準の errno システムシンボル.
                                                             (line  567)
* ENOTCONN (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  491)
* ENOTDIR (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  112)
* ENOTEMPTY (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  193)
* ENOTNAM (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  541)
* ENOTRECOVERABLE (errno モジュール):    errno --- 標準の errno システムシンボル.
                                                             (line  588)
* ENOTSOCK (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  400)
* ENOTSUP (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  434)
* ENOTTY (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  134)
* ENOTUNIQ (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  346)
* ENQ (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   33)
* enqueue_sentinel() (logging.handlers.QueueListener のメソッド): QueueListener.
                                                             (line   91)
* enqueue() (logging.handlers.QueueHandler のメソッド): QueueHandler.
                                                             (line   81)
* ensure_directories() (venv.EnvBuilder のメソッド): API<2>. (line   88)
* ensure_future() (asyncio モジュール):  Future の関数.      (line   19)
* enter_async_context() (contextlib.AsyncExitStack のメソッド): ユーティリティ.
                                                             (line  632)
* enter_context() (contextlib.ExitStack のメソッド): ユーティリティ.
                                                             (line  550)
* enter() (sched.scheduler のメソッド):  スケジューラオブジェクト.
                                                             (line   29)
* enterabs() (sched.scheduler のメソッド): スケジューラオブジェクト.
                                                             (line    8)
* enterAsyncContext() (unittest.IsolatedAsyncioTestCase のメソッド): テストクラス.
                                                             (line  890)
* enterClassContext() (unittest.TestCase のクラスメソッド): テストクラス.
                                                             (line  823)
* enterContext() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  783)
* enterModuleContext() (unittest モジュール): setUpModule と tearDownModule.
                                                             (line   35)
* entities (xml.dom.DocumentType の属性): DocumentType オブジェクト.
                                                             (line   38)
* EntityDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  289)
* entitydefs (html.entities モジュール): html entities --- HTML 一般実体の定義.
                                                             (line   24)
* EntityResolver (xml.sax.handler のクラス): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   31)
* entry_points() (importlib.metadata モジュール): エントリポイント.
                                                             (line    6)
* EntryPoint (importlib.metadata のクラス): エントリポイント.
                                                             (line   26)
* EntryPoints (importlib.metadata のクラス): エントリポイント.
                                                             (line   18)
* Enum (enum のクラス):                  データ型<2>.        (line  131)
* enum_certificates() (ssl モジュール):  証明書の取り扱い.   (line   86)
* enum_crls() (ssl モジュール):          証明書の取り扱い.   (line  109)
* EnumCheck (enum のクラス):             データ型<2>.        (line  578)
* enumerate() (threading モジュール):    threading --- スレッドベースの並列処理.
                                                             (line  140)
* EnumKey() (winreg モジュール):         関数<13>.           (line  171)
* EnumType (enum のクラス):              データ型<2>.        (line    6)
* EnumValue() (winreg モジュール):       関数<13>.           (line  189)
* EnvBuilder (venv のクラス):            API<2>.             (line   10)
* environ (os モジュール):               プロセスのパラメーター.
                                                             (line   15)
* environ (posix モジュール):            注目すべきモジュールの内容.
                                                             (line    9)
* environb (os モジュール):              プロセスのパラメーター.
                                                             (line   57)
* EnvironmentError:                      具象例外.           (line  463)
* EnvironmentVarGuard (test.support.os_helper のクラス): test support os_helper --- Utilities for os tests.
                                                             (line   49)
* ENXIO (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line   51)
* eof (bz2.BZ2Decompressor の属性):      逐次圧縮および展開. (line   72)
* eof (lzma.LZMADecompressor の属性):    メモリ上での圧縮と展開.
                                                             (line  154)
* eof (shlex.shlex の属性):              shlex オブジェクト. (line  177)
* eof (ssl.MemoryBIO の属性):            メモリ BIO サポート<2>.
                                                             (line  141)
* eof (zlib.Decompress の属性):          zlib --- gzip 互換の圧縮.
                                                             (line  249)
* eof_received() (asyncio.BufferedProtocol のメソッド): バッファリングされたストリーミングプロトコル.
                                                             (line   40)
* eof_received() (asyncio.Protocol のメソッド): ストリーミングプロトコル.
                                                             (line   30)
* EOFError:                              具象例外.           (line   24)
* EOFError (組み込み例外):               ファイルオブジェクト.
                                                             (line   42)
* EOPNOTSUPP (errno モジュール):         errno --- 標準の errno システムシンボル.
                                                             (line  429)
* EOT (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   30)
* EOVERFLOW (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  341)
* EOWNERDEAD (errno モジュール):         errno --- 標準の errno システムシンボル.
                                                             (line  582)
* EPERM (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line   27)
* EPFNOSUPPORT (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  440)
* epilogue (email.message.EmailMessage の属性): email message Representing an email message.
                                                             (line  706)
* epilogue (email.message.Message の属性): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  721)
* EPIPE (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  162)
* epoll() (select モジュール):           select --- I/O 完了の待機.
                                                             (line   54)
* EpollSelector (selectors のクラス):    クラス<4>.          (line  178)
* EPROTO (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  325)
* EPROTONOSUPPORT (errno モジュール):    errno --- 標準の errno システムシンボル.
                                                             (line  421)
* EPROTOTYPE (errno モジュール):         errno --- 標準の errno システムシンボル.
                                                             (line  412)
* epsilon (sys.float_info の属性):       sys --- システム固有のパラメーターと関数.
                                                             (line  604)
* Eq (ast のクラス):                     式 expression<2>.   (line  110)
* eq() (operator モジュール):            operator --- 関数形式の標準演算子.
                                                             (line   23)
* EQEQUAL (token モジュール):            token --- Python 解析木で使われる定数.
                                                             (line  131)
* EQFULL (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  561)
* EQUAL (token モジュール):              token --- Python 解析木で使われる定数.
                                                             (line  111)
* ERA (locale モジュール):               locale --- 国際化サービス.
                                                             (line  284)
* ERA_D_FMT (locale モジュール):         locale --- 国際化サービス.
                                                             (line  304)
* ERA_D_T_FMT (locale モジュール):       locale --- 国際化サービス.
                                                             (line  298)
* ERA_T_FMT (locale モジュール):         locale --- 国際化サービス.
                                                             (line  310)
* ERANGE (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  172)
* erase() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  214)
* erasechar() (curses モジュール):       関数<6>.            (line  114)
* EREMCHG (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  354)
* EREMOTE (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  305)
* EREMOTEIO (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  553)
* ERESTART (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  387)
* erf() (math モジュール):               特殊関数.           (line    6)
* erfc() (math モジュール):              特殊関数.           (line   20)
* EROFS (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  154)
* ERR (curses モジュール):               定数<6>.            (line    8)
* errcheck (ctypes._CFuncPtr の属性):    外部関数.           (line   67)
* errcode (xmlrpc.client.ProtocolError の属性): ProtocolError オブジェクト.
                                                             (line   16)
* errmsg (xmlrpc.client.ProtocolError の属性): ProtocolError オブジェクト.
                                                             (line   20)
* errno (OSError の属性):                具象例外.           (line  156)
* error:                                 関数と例外.         (line    8)
* Error:                                 copy --- 浅いコピーおよび深いコピー操作.
                                                             (line   34)
* Error <1>:                             ディレクトリとファイルの操作.
                                                             (line  476)
* error <1>:                             dbm --- Unix "データベース" へのインターフェース.
                                                             (line   22)
* error <2>:                             dbm gnu --- GNU database manager.
                                                             (line   22)
* error <3>:                             dbm ndbm --- New Database Manager.
                                                             (line   28)
* error <4>:                             dbm dumb --- 可搬性のある DBM 実装.
                                                             (line   23)
* Error <2>:                             例外<7>.            (line   15)
* error <5>:                             zlib --- gzip 互換の圧縮.
                                                             (line   26)
* Error <3>:                             モジュールコンテンツ<3>.
                                                             (line  322)
* Error <4>:                             例外<8>.            (line    6)
* error <6>:                             os --- 雑多なオペレーティングシステムインターフェース.
                                                             (line   50)
* error <7>:                             関数<6>.            (line    8)
* error <8>:                             _thread --- 低水準なスレッド API.
                                                             (line   20)
* error <9>:                             例外<14>.           (line    6)
* error <10>:                            select --- I/O 完了の待機.
                                                             (line   29)
* Error <5>:                             例外<17>.           (line    8)
* Error <6>:                             binascii --- バイナリ と ASCII 間の変換.
                                                             (line  156)
* error <11>:                            xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line   33)
* Error <7>:                             webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   57)
* Error <8>:                             wave --- WAV ファイルの読み書き.
                                                             (line   53)
* Error <9>:                             locale --- 国際化サービス.
                                                             (line   20)
* error <12>:                            resource --- リソース使用情報.
                                                             (line   18)
* error <13>:                            getopt --- C-style parser for command line options.
                                                             (line   84)
* ERROR (logging モジュール):            ロギングレベル.     (line   40)
* ERROR (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  192)
* error_body (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  258)
* error_content_type (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  158)
* error_headers (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  251)
* error_leader() (shlex.shlex のメソッド): shlex オブジェクト.
                                                             (line   69)
* error_message_format (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  150)
* error_output() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  224)
* error_perm:                            モジュール変数.     (line   15)
* error_proto:                           モジュール変数.     (line   20)
* error_proto <1>:                       poplib --- POP3 プロトコルクライアント.
                                                             (line   89)
* error_received() (asyncio.DatagramProtocol のメソッド): データグラムプロトコル.
                                                             (line   16)
* error_reply:                           モジュール変数.     (line    6)
* error_status (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  245)
* error_temp:                            モジュール変数.     (line   10)
* error() (argparse.ArgumentParser のメソッド): 終了メソッド.
                                                             (line   19)
* error() (logging モジュール):          モジュールレベルの関数.
                                                             (line   79)
* error() (logging.Logger のメソッド):   ロガーオブジェクト. (line  292)
* error() (urllib.request.OpenerDirector のメソッド): OpenerDirector オブジェクト.
                                                             (line   58)
* error() (xml.sax.handler.ErrorHandler のメソッド): ErrorHandler オブジェクト.
                                                             (line   16)
* ErrorByteIndex (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  166)
* errorcode (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line   13)
* ErrorCode (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  170)
* ErrorColumnNumber (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  176)
* ErrorHandler (xml.sax.handler のクラス): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   37)
* errorlevel (tarfile.TarFile の属性):   TarFile オブジェクト.
                                                             (line  227)
* ErrorLineNumber (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  180)
* errors (io.TextIOBase の属性):         テキスト I/O<2>.    (line   20)
* errors (unittest.TestLoader の属性):   テストのロードと起動.
                                                             (line   17)
* errors (unittest.TestResult の属性):   テストのロードと起動.
                                                             (line  242)
* ErrorStream (wsgiref.types のクラス):  wsgiref types -- WSGI types for static type checking.
                                                             (line   28)
* ErrorString() (xml.parsers.expat モジュール): xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line   44)
* ERRORTOKEN (token モジュール):         token --- Python 解析木で使われる定数.
                                                             (line  261)
* ESC (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  105)
* escape (shlex.shlex の属性):           shlex オブジェクト. (line  109)
* escape() (glob モジュール):            glob --- Unix 形式のパス名のパターン展開.
                                                             (line  106)
* escape() (html モジュール):            html --- HyperText Markup Language のサポート.
                                                             (line   12)
* escape() (re モジュール):              関数<2>.            (line  248)
* escape() (xml.sax.saxutils モジュール): xml sax saxutils --- SAX ユーティリティー.
                                                             (line   14)
* escapechar (csv.Dialect の属性):       Dialect クラスと書式化パラメータ.
                                                             (line   36)
* escapedquotes (shlex.shlex の属性):    shlex オブジェクト. (line  121)
* ESHUTDOWN (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  495)
* ESOCKTNOSUPPORT (errno モジュール):    errno --- 標準の errno システムシンボル.
                                                             (line  425)
* ESPIPE (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  150)
* ESRCH (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line   37)
* ESRMNT (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  317)
* ESTALE (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  533)
* ESTRPIPE (errno モジュール):           errno --- 標準の errno システムシンボル.
                                                             (line  392)
* ETB (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   93)
* ETH_P_ALL (socket モジュール):         定数<8>.            (line  222)
* ETHERTYPE_ARP (socket モジュール):     定数<8>.            (line  365)
* ETHERTYPE_IP (socket モジュール):      定数<8>.            (line  365)
* ETHERTYPE_IPV6 (socket モジュール):    定数<8>.            (line  365)
* ETHERTYPE_VLAN (socket モジュール):    定数<8>.            (line  365)
* ETIME (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  289)
* ETIMEDOUT (errno モジュール):          errno --- 標準の errno システムシンボル.
                                                             (line  505)
* Etiny() (decimal.Context のメソッド):  Context オブジェクト.
                                                             (line  225)
* ETOOMANYREFS (errno モジュール):       errno --- 標準の errno システムシンボル.
                                                             (line  500)
* Etop() (decimal.Context のメソッド):   Context オブジェクト.
                                                             (line  231)
* ETX (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   27)
* ETXTBSY (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  138)
* EUCLEAN (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  537)
* EUNATCH (errno モジュール):            errno --- 標準の errno システムシンボル.
                                                             (line  235)
* EUSERS (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  396)
* Event (asyncio のクラス):              Event.              (line    6)
* Event (multiprocessing のクラス):      同期プリミティブ.   (line   42)
* Event (threading のクラス):            Event オブジェクト. (line   14)
* EVENT_READ (selectors モジュール):     クラス<4>.          (line   23)
* EVENT_WRITE (selectors モジュール):    クラス<4>.          (line   26)
* Event() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  185)
* eventfd_read() (os モジュール):        ファイルとディレクトリ.
                                                             (line 1928)
* eventfd_write() (os モジュール):       ファイルとディレクトリ.
                                                             (line 1938)
* eventfd() (os モジュール):             ファイルとディレクトリ.
                                                             (line 1875)
* EventLoop (asyncio のクラス):          イベントループの実装.
                                                             (line   43)
* events (selectors.SelectorKey の属性): クラス<4>.          (line   44)
* events (widgets):                      バインドとイベント. (line    6)
* EWOULDBLOCK (errno モジュール):        errno --- 標準の errno システムシンボル.
                                                             (line  202)
* EX_CANTCREAT (os モジュール):          プロセス管理.       (line  208)
* EX_CONFIG (os モジュール):             プロセス管理.       (line  243)
* EX_DATAERR (os モジュール):            プロセス管理.       (line  157)
* EX_IOERR (os モジュール):              プロセス管理.       (line  215)
* EX_NOHOST (os モジュール):             プロセス管理.       (line  176)
* EX_NOINPUT (os モジュール):            プロセス管理.       (line  163)
* EX_NOPERM (os モジュール):             プロセス管理.       (line  236)
* EX_NOTFOUND (os モジュール):           プロセス管理.       (line  249)
* EX_NOUSER (os モジュール):             プロセス管理.       (line  170)
* EX_OK (os モジュール):                 プロセス管理.       (line  142)
* EX_OSERR (os モジュール):              プロセス管理.       (line  194)
* EX_OSFILE (os モジュール):             プロセス管理.       (line  201)
* EX_PROTOCOL (os モジュール):           プロセス管理.       (line  229)
* EX_SOFTWARE (os モジュール):           プロセス管理.       (line  188)
* EX_TEMPFAIL (os モジュール):           プロセス管理.       (line  221)
* EX_UNAVAILABLE (os モジュール):        プロセス管理.       (line  182)
* EX_USAGE (os モジュール):              プロセス管理.       (line  150)
* Example (doctest のクラス):            Example オブジェクト.
                                                             (line    6)
* example (doctest.DocTestFailure の属性): デバッグ.         (line  195)
* example (doctest.UnexpectedException の属性): デバッグ.    (line  216)
* examples (doctest.DocTest の属性):     DocTest オブジェクト.
                                                             (line   16)
* exc_info (doctest.UnexpectedException の属性): デバッグ.   (line  220)
* exc_info (sys モジュール):             トレースバック traceback オブジェクト.
                                                             (line    6)
* exc_info (sys モジュール) <1>:         例外<21>.           (line   45)
* exc_info() (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line  436)
* exc_msg (doctest.Example の属性):      Example オブジェクト.
                                                             (line   30)
* exc_type (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   79)
* exc_type_str (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   85)
* excel (csv のクラス):                  モジュールコンテンツ<3>.
                                                             (line  201)
* excel_tab (csv のクラス):              モジュールコンテンツ<3>.
                                                             (line  207)
* ExceptHandler (ast のクラス):          制御フロー.         (line  201)
* excepthook() (sys モジュール):         sys --- システム固有のパラメーターと関数.
                                                             (line  382)
* excepthook() (threading モジュール):   threading --- スレッドベースの並列処理.
                                                             (line   68)
* Exception:                             基底クラス.         (line   63)
* EXCEPTION (_tkinter モジュール):       ファイルハンドラ.   (line   42)
* EXCEPTION_HANDLED (monitoring event):  Events.             (line   26)
* exception() (asyncio.Future のメソッド): Future オブジェクト<2>.
                                                             (line  129)
* exception() (asyncio.Task のメソッド): Task オブジェクト.  (line   88)
* exception() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   52)
* exception() (logging モジュール):      モジュールレベルの関数.
                                                             (line   91)
* exception() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  308)
* exception() (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line  424)
* ExceptionGroup:                        例外グループ.       (line   11)
* exceptions (BaseExceptionGroup の属性): 例外グループ.      (line   34)
* exceptions (pdb command):              デバッガコマンド.   (line  435)
* exceptions (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   53)
* EXCLAMATION (token モジュール):        token --- Python 解析木で使われる定数.
                                                             (line  239)
* EXDEV (errno モジュール):              errno --- 標準の errno システムシンボル.
                                                             (line  104)
* exec_module() (importlib.abc.InspectLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  257)
* exec_module() (importlib.abc.Loader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  115)
* exec_module() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  397)
* exec_module() (importlib.machinery.ExtensionFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  317)
* exec_module() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   31)
* exec_prefix (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line  456)
* execl() (os モジュール):               プロセス管理.       (line   53)
* execle() (os モジュール):              プロセス管理.       (line   53)
* execlp() (os モジュール):              プロセス管理.       (line   53)
* execlpe() (os モジュール):             プロセス管理.       (line   53)
* executable (in module sys):            プロセスワイドのパラメータ.
                                                             (line  115)
* executable (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line  471)
* Executable Zip Files:                  zipapp --- 実行可能な Python zip アーカイブを管理する.
                                                             (line   10)
* execute() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  100)
* execute() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line   24)
* executemany() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  106)
* executemany() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line   60)
* executescript() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  112)
* executescript() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line  101)
* ExecutionLoader (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  270)
* Executor (concurrent.futures のクラス): Executor オブジェクト.
                                                             (line    6)
* execv() (os モジュール):               プロセス管理.       (line   53)
* execve() (os モジュール):              プロセス管理.       (line   53)
* execvp() (os モジュール):              プロセス管理.       (line   53)
* execvpe() (os モジュール):             プロセス管理.       (line   53)
* EXFULL (errno モジュール):             errno --- 標準の errno システムシンボル.
                                                             (line  256)
* exists() (os.path モジュール):         os path --- 一般的なパス名操作.
                                                             (line  110)
* exists() (pathlib.Path のメソッド):    ファイルの種類とステータスを問い合わせる.
                                                             (line   38)
* exists() (tkinter.ttk.Treeview のメソッド): ttk Treeview.  (line   90)
* exists() (zipfile.Path のメソッド):    Path オブジェクト.  (line   64)
* exit (C function):                     プロセス制御.       (line   23)
* exit (組み込み変数):                   site モジュールで追加される定数.
                                                             (line   11)
* exit() (_thread モジュール):           _thread --- 低水準なスレッド API.
                                                             (line   76)
* exit() (argparse.ArgumentParser のメソッド): 終了メソッド. (line    6)
* exit() (sys モジュール):               sys --- システム固有のパラメーターと関数.
                                                             (line  478)
* exitcode (multiprocessing.Process の属性): Process クラスと例外.
                                                             (line  127)
* exitonclick() (turtle モジュール):     Screen 独自のメソッド、TurtleScreen から継承したもの以外.
                                                             (line   10)
* ExitStack (contextlib のクラス):       ユーティリティ.     (line  511)
* exp() (cmath モジュール):              指数関数と対数関数<2>.
                                                             (line    6)
* exp() (decimal.Context のメソッド):    Context オブジェクト.
                                                             (line  295)
* exp() (decimal.Decimal のメソッド):    Decimal オブジェクト.
                                                             (line  221)
* exp() (math モジュール):               指数関数と対数関数. (line   12)
* exp2() (math モジュール):              指数関数と対数関数. (line   18)
* expand_tabs (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  167)
* expand() (re.Match のメソッド):        マッチオブジェクト. (line   22)
* ExpandEnvironmentStrings() (winreg モジュール): 関数<13>.  (line  226)
* expandNode() (xml.dom.pulldom.DOMEventStream のメソッド): DOMEventStream オブジェクト.
                                                             (line   20)
* expandtabs() (bytearray のメソッド):   bytes と bytearray の操作.
                                                             (line  485)
* expandtabs() (bytes のメソッド):       bytes と bytearray の操作.
                                                             (line  485)
* expandtabs() (str のメソッド):         文字列メソッド<2>.  (line   93)
* expanduser() (os.path モジュール):     os path --- 一般的なパス名操作.
                                                             (line  134)
* expanduser() (pathlib.Path のメソッド): パスの展開と解決.  (line   18)
* expandvars() (os.path モジュール):     os path --- 一般的なパス名操作.
                                                             (line  160)
* Expat:                                 xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line   13)
* ExpatError:                            xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line   27)
* expected (asyncio.IncompleteReadError の属性): 例外<12>.   (line   53)
* expectedFailure() (unittest モジュール): テストのスキップと予期された失敗.
                                                             (line   99)
* expectedFailures (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  262)
* expired() (asyncio.Timeout のメソッド): タイムアウト.      (line   72)
* expires (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   53)
* expires (http.cookies.Morsel の属性):  Morselオブジェクト. (line   13)
* exploded (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   58)
* exploded (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line  108)
* exploded (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  244)
* exploded (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  321)
* expm1() (math モジュール):             指数関数と対数関数. (line   24)
* expovariate() (random モジュール):     実数分布.           (line   34)
* Expr (ast のクラス):                   式 expression<2>.   (line    6)
* expression:                            式 expression.      (line    6)
* expression <1>:                        用語集<2>.          (line  453)
* Expression (ast のクラス):             Root nodes.         (line   26)
* expression;list:                       式のリスト.         (line    6)
* expression;list <1>:                   式文 expression statement.
                                                             (line    6)
* expression;list <2>:                   式文 expression statement.
                                                             (line    6)
* expression;statement:                  式文 expression statement.
                                                             (line    6)
* expunge() (imaplib.IMAP4 のメソッド):  IMAP4 オブジェクト. (line   92)
* extend_path() (pkgutil モジュール):    pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   19)
* extend() (array.array のメソッド):     array --- 効率的な数値配列.
                                                             (line  157)
* extend() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   59)
* extend() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   89)
* extend() (シーケンスのメソッド):       ミュータブルなシーケンス型.
                                                             (line   16)
* EXTENDED_ARG (opcode):                 Python バイトコード命令.
                                                             (line 1140)
* ExtendedContext (decimal のクラス):    Context オブジェクト.
                                                             (line   74)
* ExtendedInterpolation (configparser のクラス): 値の補間.   (line   39)
* extendleft() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   64)
* extension module:                      用語集<2>.          (line  462)
* EXTENSION_SUFFIXES (importlib.machinery モジュール): importlib machinery -- インポータおよびパスフック.
                                                             (line   50)
* ExtensionFileLoader (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  285)
* extensions_map (http.server.SimpleHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  365)
* external_attr (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line  128)
* ExternalClashError:                    例外<17>.           (line   26)
* ExternalEntityParserCreate() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   43)
* ExternalEntityRefHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  364)
* extra (zipfile.ZipInfo の属性):        ZipInfo オブジェクト.
                                                             (line   94)
* extract_cookies() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   32)
* extract_stack() (traceback モジュール): モジュールレベルの関数<2>.
                                                             (line   92)
* extract_tb() (traceback モジュール):   モジュールレベルの関数<2>.
                                                             (line   80)
* extract_version (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line  108)
* extract() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  178)
* extract() (traceback.StackSummary のクラスメソッド): StackSummary オブジェクト.
                                                             (line   12)
* extract() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  192)
* extractall() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  141)
* extractall() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  220)
* ExtractError:                          tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  226)
* extractfile() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  211)
* extraction_filter (tarfile.TarFile の属性): TarFile オブジェクト.
                                                             (line  247)
* extsep (os モジュール):                雑多なシステム情報. (line  130)
* f_back (frame の属性):                 Special read-only attributes<3>.
                                                             (line    6)
* f_back (フレーム属性):                 フレーム frame オブジェクト.
                                                             (line   10)
* f_builtins (frame の属性):             Special read-only attributes<3>.
                                                             (line   29)
* f_builtins (フレーム属性):             フレーム frame オブジェクト.
                                                             (line   10)
* f_code (frame の属性):                 Special read-only attributes<3>.
                                                             (line   10)
* f_code (フレーム属性):                 フレーム frame オブジェクト.
                                                             (line   10)
* F_CONTIGUOUS (inspect.BufferFlags の属性): Buffer flags.   (line   27)
* f_contiguous (memoryview の属性):      メモリビュー.       (line  476)
* f_globals (frame の属性):              Special read-only attributes<3>.
                                                             (line   25)
* f_globals (フレーム属性):              フレーム frame オブジェクト.
                                                             (line   10)
* f_lasti (frame の属性):                Special read-only attributes<3>.
                                                             (line   33)
* f_lasti (フレーム属性):                フレーム frame オブジェクト.
                                                             (line   10)
* f_lineno (frame の属性):               Special writable attributes<2>.
                                                             (line   23)
* f_lineno (フレーム属性):               Special read-only attributes<3>.
                                                             (line   37)
* f_locals (frame の属性):               Special read-only attributes<3>.
                                                             (line   16)
* f_locals (フレーム属性):               フレーム frame オブジェクト.
                                                             (line   10)
* F_LOCK (os モジュール):                ファイル記述子の操作.
                                                             (line  279)
* F_OK (os モジュール):                  ファイルとディレクトリ.
                                                             (line  109)
* F_TEST (os モジュール):                ファイル記述子の操作.
                                                             (line  279)
* F_TLOCK (os モジュール):               ファイル記述子の操作.
                                                             (line  279)
* f_trace (frame の属性):                Special writable attributes<2>.
                                                             (line    6)
* f_trace (フレーム属性):                Special read-only attributes<3>.
                                                             (line   38)
* f_trace_lines (frame attribute):       Special read-only attributes<3>.
                                                             (line   38)
* f_trace_lines (frame の属性):          Special writable attributes<2>.
                                                             (line   12)
* f_trace_opcodes (frame attribute):     Special read-only attributes<3>.
                                                             (line   38)
* f_trace_opcodes (frame の属性):        Special writable attributes<2>.
                                                             (line   16)
* F_ULOCK (os モジュール):               ファイル記述子の操作.
                                                             (line  279)
* f-string:                              出力を見やすくフォーマットする.
                                                             (line   88)
* f-string <1>:                          文字列リテラルの結合 concatenation.
                                                             (line   24)
* f-string <2>:                          用語集<2>.          (line  467)
* f';formatted string literal:           文字列およびバイト列リテラル.
                                                             (line   64)
* f";formatted string literal:           文字列およびバイト列リテラル.
                                                             (line   64)
* fabs() (math モジュール):              数論および数表現の関数.
                                                             (line   34)
* factorial() (math モジュール):         数論および数表現の関数.
                                                             (line   38)
* factory() (importlib.util.LazyLoader のクラスメソッド): importlib util -- インポータのためのユーティリティコード.
                                                             (line  226)
* FAIL_FAST (doctest モジュール):        オプションフラグ.   (line  140)
* fail() (unittest.TestCase のメソッド): テストクラス.       (line  690)
* failed (doctest.TestResults の属性):   TestResults objects.
                                                             (line    8)
* failfast (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  300)
* failureException:                      単体テスト API.     (line  144)
* failureException (unittest.TestCase の属性): テストクラス. (line  695)
* failures (doctest.DocTestRunner の属性): DocTestRunner オブジェクト.
                                                             (line  140)
* failures (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  248)
* FakePath (test.support.os_helper のクラス): test support os_helper --- Utilities for os tests.
                                                             (line   59)
* False:                                 numbers Integral 整数.
                                                             (line   24)
* false:                                 真理値判定.         (line    6)
* False <1>:                             真理値判定.         (line   22)
* False <2>:                             ブーリアン型 - bool.
                                                             (line    9)
* False (組み込みオブジェクト):          真理値判定.         (line   14)
* False (組み込み変数):                  組み込み定数.       (line    8)
* families() (tkinter.font モジュール):  tkinter font --- Tkinter フォントラッパー.
                                                             (line   88)
* family (socket.socket の属性):         socket オブジェクト.
                                                             (line  613)
* FancyURLopener (urllib.request のクラス): レガシーインターフェース.
                                                             (line  148)
* fast (pickle.Pickler の属性):          モジュールインターフェース.
                                                             (line  221)
* FastChildWatcher (asyncio のクラス):   プロセスのウオッチャー.
                                                             (line  149)
* fatalError() (xml.sax.handler.ErrorHandler のメソッド): ErrorHandler オブジェクト.
                                                             (line   24)
* Fault (xmlrpc.client のクラス):        Fault オブジェクト. (line    6)
* faultCode (xmlrpc.client.Fault の属性): Fault オブジェクト.
                                                             (line   11)
* faultString (xmlrpc.client.Fault の属性): Fault オブジェクト.
                                                             (line   15)
* fchdir() (os モジュール):              ファイルとディレクトリ.
                                                             (line  290)
* fchmod() (os モジュール):              ファイル記述子の操作.
                                                             (line  121)
* fchown() (os モジュール):              ファイル記述子の操作.
                                                             (line  137)
* fcntl() (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line   67)
* fd (selectors.SelectorKey の属性):     クラス<4>.          (line   40)
* fd_count() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   96)
* fd() (turtle モジュール):              Turtle の動き.      (line    6)
* fdatasync() (os モジュール):           ファイル記述子の操作.
                                                             (line  152)
* fdopen() (os モジュール):              ファイルオブジェクトの生成.
                                                             (line    9)
* feature_external_ges (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   80)
* feature_external_pes (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   87)
* feature_namespace_prefixes (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   59)
* feature_namespaces (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   52)
* feature_string_interning (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   66)
* feature_validation (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   73)
* FEBRUARY (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* feed_eof() (asyncio.StreamReader のメソッド): StreamReader.
                                                             (line   16)
* feed() (email.parser.BytesFeedParser のメソッド): FeedParser API.
                                                             (line   57)
* feed() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line    8)
* feed() (xml.etree.ElementTree.XMLParser のメソッド): XMLParser オブジェクト.
                                                             (line   27)
* feed() (xml.etree.ElementTree.XMLPullParser のメソッド): XMLPullParser オブジェクト.
                                                             (line   18)
* feed() (xml.sax.xmlreader.IncrementalParser のメソッド): IncrementalParser オブジェクト.
                                                             (line    9)
* FeedParser (email.parser のクラス):    FeedParser API.     (line   72)
* fetch() (imaplib.IMAP4 のメソッド):    IMAP4 オブジェクト. (line   99)
* fetchall() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line  146)
* fetchmany() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line  130)
* fetchone() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line  123)
* FF (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   60)
* fflags (select.kevent の属性):         kevent オブジェクト.
                                                             (line   89)
* Field (dataclasses のクラス):          モジュールの内容<4>.
                                                             (line  300)
* field_size_limit() (csv モジュール):   モジュールコンテンツ<3>.
                                                             (line   94)
* field() (dataclasses モジュール):      モジュールの内容<4>.
                                                             (line  207)
* fieldnames (csv.DictReader の属性):    reader オブジェクト.
                                                             (line   31)
* fields (uuid.UUID の属性):             uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   95)
* fields() (dataclasses モジュール):     モジュールの内容<4>.
                                                             (line  319)
* FIFOTYPE (tarfile モジュール):         tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  301)
* file (bdb.Breakpoint の属性):          bdb --- デバッガーフレームワーク.
                                                             (line   83)
* file (pyclbr.Class の属性):            クラスオブジェクト<2>.
                                                             (line   12)
* file (pyclbr.Function の属性):         Function オブジェクト.
                                                             (line   11)
* file object:                           用語集<2>.          (line  473)
* file object;io module:                 概要<2>.            (line    6)
* file object;open() built-in function:  組み込み関数.       (line 1255)
* FILE_ATTRIBUTE_ARCHIVE (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_COMPRESSED (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_DEVICE (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_DIRECTORY (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_ENCRYPTED (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_HIDDEN (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_INTEGRITY_STREAM (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_NO_SCRUB_DATA (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_NORMAL (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_NOT_CONTENT_INDEXED (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_OFFLINE (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_READONLY (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_REPARSE_POINT (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_SPARSE_FILE (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_SYSTEM (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_TEMPORARY (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* FILE_ATTRIBUTE_VIRTUAL (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  459)
* file_digest() (hashlib モジュール):    File hashing.       (line    9)
* file_open() (urllib.request.FileHandler のメソッド): FileHandler オブジェクト.
                                                             (line    6)
* file_size (zipfile.ZipInfo の属性):    ZipInfo オブジェクト.
                                                             (line  144)
* file-like object:                      用語集<2>.          (line  489)
* fileConfig() (logging.config モジュール): 環境設定のための関数.
                                                             (line   60)
* FileCookieJar (http.cookiejar のクラス): http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line   57)
* FileDialog (tkinter.filedialog のクラス): ネイティブの読み込み/保存ダイアログ.
                                                             (line   77)
* FileExistsError:                       OS 例外.            (line   63)
* FileFinder (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  154)
* FileHandler (logging のクラス):        FileHandler.        (line   10)
* FileHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  418)
* FileInput (fileinput のクラス):        fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  135)
* FileIO (io のクラス):                  生ファイルI/O.      (line    6)
* filelineno() (fileinput モジュール):   fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  102)
* FileLoader (importlib.abc のクラス):   importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  289)
* filemode() (stat モジュール):          stat --- stat の結果を解釈する.
                                                             (line  126)
* filename (doctest.DocTest の属性):     DocTest オブジェクト.
                                                             (line   35)
* filename (http.cookiejar.FileCookieJar の属性): CookieJar および FileCookieJar オブジェクト.
                                                             (line  161)
* filename (inspect.FrameInfo の属性):   インタープリタスタック.
                                                             (line   17)
* filename (inspect.Traceback の属性):   インタープリタスタック.
                                                             (line   57)
* filename (netrc.NetrcParseError の属性): netrc --- netrc ファイルの処理.
                                                             (line   56)
* filename (OSError の属性):             具象例外.           (line  177)
* filename (SyntaxError の属性):         具象例外.           (line  295)
* filename (traceback.FrameSummary の属性): FrameSummary オブジェクト.
                                                             (line   27)
* filename (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   91)
* filename (tracemalloc.Frame の属性):   Frame.              (line   13)
* filename (zipfile.ZipFile の属性):     ZipFile オブジェクト.
                                                             (line  360)
* filename (zipfile.ZipInfo の属性):     ZipInfo オブジェクト.
                                                             (line   51)
* filename_only (tabnanny モジュール):   tabnanny --- あいまいなインデントの検出.
                                                             (line   31)
* filename_pattern (tracemalloc.Filter の属性): Filter.      (line   54)
* filename() (fileinput モジュール):     fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line   85)
* filename2 (OSError の属性):            具象例外.           (line  177)
* filenames;pathname expansion:          glob --- Unix 形式のパス名のパターン展開.
                                                             (line    8)
* filenames;ワイルドカード展開:          fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line    8)
* fileno() (bz2.BZ2File のメソッド):     ファイルの圧縮/解凍.
                                                             (line   86)
* fileno() (fileinput モジュール):       fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line   90)
* fileno() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   37)
* fileno() (io.IOBase のメソッド):       I/O 基底クラス.     (line   61)
* fileno() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   31)
* fileno() (select.devpoll のメソッド):  /dev/poll ポーリングオブジェクト.
                                                             (line   24)
* fileno() (select.epoll のメソッド):    エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   74)
* fileno() (select.kqueue のメソッド):   kqueue オブジェクト.
                                                             (line   14)
* fileno() (selectors.DevpollSelector のメソッド): クラス<4>.
                                                             (line  191)
* fileno() (selectors.EpollSelector のメソッド): クラス<4>.  (line  182)
* fileno() (selectors.KqueueSelector のメソッド): クラス<4>. (line  202)
* fileno() (socket.socket のメソッド):   socket オブジェクト.
                                                             (line  119)
* fileno() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line   15)
* FileNotFoundError:                     OS 例外.            (line   68)
* fileobj (selectors.SelectorKey の属性): クラス<4>.         (line   36)
* files_double_event() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line   93)
* files_select_event() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line   97)
* files() (importlib.abc.TraversableResources のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  573)
* files() (importlib.metadata モジュール): 配布物ファイル.   (line    6)
* files() (importlib.resources モジュール): importlib resources -- パッケージリソースの読み取り、オープン、アクセス.
                                                             (line   52)
* files() (importlib.resources.abc.TraversableResources のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  169)
* filesystem encoding and error handler: 用語集<2>.          (line  493)
* FileType (argparse のクラス):          FileType オブジェクト.
                                                             (line    6)
* FileWrapper (wsgiref.types のクラス):  wsgiref types -- WSGI types for static type checking.
                                                             (line   32)
* FileWrapper (wsgiref.util のクラス):   wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line  116)
* fill() (textwrap モジュール):          textwrap --- テキストの折り返しと詰め込み.
                                                             (line   33)
* fill() (textwrap.TextWrapper のメソッド): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  286)
* fillcolor() (turtle モジュール):       色の制御<2>.        (line   57)
* filling() (turtle モジュール):         塗りつぶし.         (line    6)
* fillvalue (reprlib.Repr の属性):       Reprオブジェクト.   (line   10)
* Filter (logging のクラス):             フィルタオブジェクト.
                                                             (line   14)
* filter (select.kevent の属性):         kevent オブジェクト.
                                                             (line   15)
* Filter (tracemalloc のクラス):         Filter.             (line    6)
* filter_command() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  101)
* FILTER_DIR (unittest.mock モジュール): FILTER_DIR.         (line    6)
* filter_traces() (tracemalloc.Snapshot のメソッド): Snapshot.
                                                             (line   36)
* filter() (curses モジュール):          関数<6>.            (line  121)
* filter() (fnmatch モジュール):         fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   71)
* filter() (logging.Filter のメソッド):  フィルタオブジェクト.
                                                             (line   21)
* filter() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   62)
* filter() (logging.Logger のメソッド):  ロガーオブジェクト. (line  323)
* FilterError:                           tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  237)
* filterfalse() (itertools モジュール):  Itertool関数.       (line  287)
* filterwarnings() (warnings モジュール): 利用可能な関数.    (line  105)
* Final (typing モジュール):             特殊形式.           (line  190)
* final() (typing モジュール):           Functions and decorators.
                                                             (line  309)
* finalization, of objects:              ファイナライズとメモリ解放.
                                                             (line    6)
* finalize (weakref のクラス):           weakref --- 弱参照. (line  258)
* finalizer:                             基本的なカスタマイズ.
                                                             (line   53)
* find_class() (pickle プロトコル):      グローバル変数を制限する.
                                                             (line    6)
* find_class() (pickle.Unpickler のメソッド): モジュールインターフェース.
                                                             (line  297)
* find_library() (ctypes.util モジュール): ユーティリティー関数.
                                                             (line   85)
* find_loader() (pkgutil モジュール):    pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   53)
* find_longest_match() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line   64)
* find_msvcrt() (ctypes.util モジュール): ユーティリティー関数.
                                                             (line   95)
* find_spec() (importlib.abc.MetaPathFinder のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   34)
* find_spec() (importlib.abc.PathEntryFinder のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   70)
* find_spec() (importlib.machinery.FileFinder のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  182)
* find_spec() (importlib.machinery.PathFinder のクラスメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  117)
* find_spec() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line  104)
* find_spec() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   37)
* find_unused_port() (test.support.socket_helper モジュール): test support socket_helper --- Utilities for socket tests.
                                                             (line   15)
* find_user_password() (urllib.request.HTTPPasswordMgr のメソッド): HTTPPasswordMgr オブジェクト.
                                                             (line   16)
* find_user_password() (urllib.request.HTTPPasswordMgrWithPriorAuth のメソッド): HTTPPasswordMgrWithPriorAuth オブジェクト.
                                                             (line   20)
* find() (bytearray のメソッド):         bytes と bytearray の操作.
                                                             (line  134)
* find() (bytes のメソッド):             bytes と bytearray の操作.
                                                             (line  134)
* find() (doctest.DocTestFinder のメソッド): DocTestFinder オブジェクト.
                                                             (line   32)
* find() (gettext モジュール):           クラス形式の API.   (line   14)
* find() (mmap.mmap のメソッド):         mmap --- メモリマップファイルのサポート.
                                                             (line  197)
* find() (str のメソッド):               文字列メソッド<2>.  (line  112)
* find() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   97)
* find() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   20)
* findall() (re モジュール):             関数<2>.            (line  127)
* findall() (re.Pattern のメソッド):     正規表現オブジェクト.
                                                             (line   82)
* findall() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  106)
* findall() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   25)
* findCaller() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  340)
* finder:                                ファインダーとローダー.
                                                             (line    6)
* finder <1>:                            用語集<2>.          (line  514)
* finder;find_spec:                      メタパス.           (line    6)
* findfile() (test.support モジュール):  test support --- テストのためのユーティリティ関数.
                                                             (line  274)
* finditer() (re モジュール):            関数<2>.            (line  153)
* finditer() (re.Pattern のメソッド):    正規表現オブジェクト.
                                                             (line   88)
* findlabels() (dis モジュール):         解析関数.           (line  178)
* findlinestarts() (dis モジュール):     解析関数.           (line  161)
* findtext() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  115)
* findtext() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   30)
* finish_request() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  122)
* finish() (socketserver.BaseRequestHandler のメソッド): Request Handler Objects.
                                                             (line   34)
* finish() (tkinter.dnd.DndHandler のメソッド): tkinter dnd --- ドラッグアンドドロップのサポート.
                                                             (line   52)
* FIRST_COMPLETED (asyncio モジュール):  要素の終了待機.     (line   35)
* FIRST_COMPLETED (concurrent.futures モジュール): モジュール関数<2>.
                                                             (line   29)
* FIRST_EXCEPTION (asyncio モジュール):  要素の終了待機.     (line   39)
* FIRST_EXCEPTION (concurrent.futures モジュール): モジュール関数<2>.
                                                             (line   33)
* firstChild (xml.dom.Node の属性):      Node オブジェクト.  (line   53)
* firstkey() (dbm.gnu.gdbm のメソッド):  dbm gnu --- GNU database manager.
                                                             (line   84)
* firstweekday() (calendar モジュール):  calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  294)
* fix_missing_locations() (ast モジュール): ast ヘルパー.    (line  146)
* fix_sentence_endings (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  218)
* Flag (enum のクラス):                  データ型<2>.        (line  400)
* flag_bits (zipfile.ZipInfo の属性):    ZipInfo オブジェクト.
                                                             (line  116)
* FlagBoundary (enum のクラス):          データ型<2>.        (line  637)
* flags (re.Pattern の属性):             正規表現オブジェクト.
                                                             (line  104)
* flags (select.kevent の属性):          kevent オブジェクト.
                                                             (line   51)
* flags (sys モジュール):                sys --- システム固有のパラメーターと関数.
                                                             (line  507)
* flash() (curses モジュール):           関数<6>.            (line  132)
* flatten() (email.generator.BytesGenerator のメソッド): email generator Generating MIME documents.
                                                             (line   79)
* flatten() (email.generator.Generator のメソッド): email generator Generating MIME documents.
                                                             (line  174)
* float (組み込みクラス):                組み込み関数.       (line  705)
* float_info (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line  591)
* float_repr_style (sys モジュール):     sys --- システム固有のパラメーターと関数.
                                                             (line  698)
* floating-point literal:                数値リテラル.       (line    6)
* FloatingPointError:                    具象例外.           (line   31)
* FloatOperation (decimal のクラス):     シグナル.           (line  106)
* flock() (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line  145)
* floor division:                        用語集<2>.          (line  526)
* floor() (math モジュール):             数値型 int float complex.
                                                             (line  102)
* floor() (math モジュール) <1>:         数論および数表現の関数.
                                                             (line   46)
* FloorDiv (ast のクラス):               式 expression<2>.   (line   55)
* floordiv() (operator モジュール):      operator --- 関数形式の標準演算子.
                                                             (line   85)
* flush_headers() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  285)
* flush_std_streams() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  407)
* flush() (bz2.BZ2Compressor のメソッド): 逐次圧縮および展開.
                                                             (line   25)
* flush() (io.BufferedWriter のメソッド): バッファ付きストリーム.
                                                             (line  127)
* flush() (io.IOBase のメソッド):        I/O 基底クラス.     (line   67)
* flush() (logging.Handler のメソッド):  ハンドラオブジェクト.
                                                             (line   70)
* flush() (logging.handlers.BufferingHandler のメソッド): MemoryHandler.
                                                             (line   30)
* flush() (logging.handlers.MemoryHandler のメソッド): MemoryHandler.
                                                             (line   63)
* flush() (logging.StreamHandler のメソッド): StreamHandler. (line   26)
* flush() (lzma.LZMACompressor のメソッド): メモリ上での圧縮と展開.
                                                             (line   84)
* flush() (mailbox.Mailbox のメソッド):  Mailbox オブジェクト.
                                                             (line  245)
* flush() (mailbox.Maildir のメソッド):  Maildir オブジェクト.
                                                             (line  201)
* flush() (mailbox.MH のメソッド):       MH オブジェクト.    (line  103)
* flush() (mmap.mmap のメソッド):        mmap --- メモリマップファイルのサポート.
                                                             (line  207)
* flush() (xml.etree.ElementTree.XMLParser のメソッド): XMLParser オブジェクト.
                                                             (line   32)
* flush() (xml.etree.ElementTree.XMLPullParser のメソッド): XMLPullParser オブジェクト.
                                                             (line   22)
* flush() (zlib.Compress のメソッド):    zlib --- gzip 互換の圧縮.
                                                             (line  209)
* flush() (zlib.Decompress のメソッド):  zlib --- gzip 互換の圧縮.
                                                             (line  278)
* flushinp() (curses モジュール):        関数<6>.            (line  138)
* FlushKey() (winreg モジュール):        関数<13>.           (line  237)
* fma() (decimal.Context のメソッド):    Context オブジェクト.
                                                             (line  299)
* fma() (decimal.Decimal のメソッド):    Decimal オブジェクト.
                                                             (line  258)
* fma() (math モジュール):               数論および数表現の関数.
                                                             (line   52)
* fmean() (statistics モジュール):       関数の詳細.         (line   45)
* fmod() (math モジュール):              数論および数表現の関数.
                                                             (line   67)
* FMT_BINARY (plistlib モジュール):      plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line  160)
* FMT_XML (plistlib モジュール):         plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line  154)
* fnmatch() (fnmatch モジュール):        fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   46)
* fnmatchcase() (fnmatch モジュール):    fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   65)
* focus() (tkinter.ttk.Treeview のメソッド): ttk Treeview.   (line   94)
* fold (datetime.datetime の属性):       datetime オブジェクト.
                                                             (line  336)
* fold (datetime.time の属性):           time オブジェクト.  (line   71)
* fold_binary() (email.policy.Compat32 のメソッド): email policy Policy Objects.
                                                             (line  605)
* fold_binary() (email.policy.EmailPolicy のメソッド): email policy Policy Objects.
                                                             (line  485)
* fold_binary() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  349)
* fold() (email.headerregistry.BaseHeader のメソッド): email headerregistry Custom Header Objects.
                                                             (line   72)
* fold() (email.policy.Compat32 のメソッド): email policy Policy Objects.
                                                             (line  597)
* fold() (email.policy.EmailPolicy のメソッド): email policy Policy Objects.
                                                             (line  465)
* fold() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  334)
* Font (tkinter.font のクラス):          tkinter font --- Tkinter フォントラッパー.
                                                             (line   20)
* For (ast のクラス):                    制御フロー.         (line   44)
* FOR_ITER (opcode):                     Python バイトコード命令.
                                                             (line  899)
* for;in comprehensions:                 リスト、集合、辞書の表示.
                                                             (line   14)
* forget() (test.support.import_helper モジュール): test support import_helper --- Utilities for import tests.
                                                             (line   11)
* forget() (tkinter.ttk.Notebook のメソッド): ttk Notebook.  (line   18)
* fork() (os モジュール):                プロセス管理.       (line  255)
* fork() (pty モジュール):               pty --- 擬似端末ユーティリティ.
                                                             (line   21)
* ForkingMixIn (socketserver のクラス):  サーバ生成に関するノート.
                                                             (line   26)
* ForkingTCPServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* ForkingUDPServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* ForkingUnixDatagramServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* ForkingUnixStreamServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* forkpty() (os モジュール):             プロセス管理.       (line  300)
* FORMAT (inspect.BufferFlags の属性):   Buffer flags.       (line   19)
* format (memoryview の属性):            メモリビュー.       (line  418)
* format (multiprocessing.shared_memory.ShareableList の属性): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  340)
* format (struct.Struct の属性):         クラス<3>.          (line   56)
* format_datetime() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  173)
* format_exc() (traceback モジュール):   モジュールレベルの関数<2>.
                                                             (line  154)
* format_exception_only() (traceback モジュール): モジュールレベルの関数<2>.
                                                             (line  109)
* format_exception_only() (traceback.TracebackException のメソッド): TracebackException オブジェクト.
                                                             (line  153)
* format_exception() (traceback モジュール): モジュールレベルの関数<2>.
                                                             (line  139)
* format_field() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line   98)
* format_frame_summary() (traceback.StackSummary のメソッド): StackSummary オブジェクト.
                                                             (line   53)
* format_help() (argparse.ArgumentParser のメソッド): ヘルプの表示.
                                                             (line   30)
* format_list() (traceback モジュール):  モジュールレベルの関数<2>.
                                                             (line   99)
* format_map() (str のメソッド):         文字列メソッド<2>.  (line  154)
* FORMAT_SIMPLE (opcode):                Python バイトコード命令.
                                                             (line 1166)
* format_stack_entry() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  418)
* format_stack() (traceback モジュール): モジュールレベルの関数<2>.
                                                             (line  163)
* format_string() (locale モジュール):   locale --- 国際化サービス.
                                                             (line  427)
* format_tb() (traceback モジュール):    モジュールレベルの関数<2>.
                                                             (line  159)
* format_usage() (argparse.Action のメソッド): Action クラス.
                                                             (line   57)
* format_usage() (argparse.ArgumentParser のメソッド): ヘルプの表示.
                                                             (line   25)
* FORMAT_WITH_SPEC (opcode):             Python バイトコード命令.
                                                             (line 1178)
* format() (inspect.Signature のメソッド): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  157)
* format() (logging.BufferingFormatter のメソッド): フォーマッタオブジェクト.
                                                             (line  151)
* format() (logging.Formatter のメソッド): フォーマッタオブジェクト.
                                                             (line   53)
* format() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line  103)
* format() (pprint.PrettyPrinter のメソッド): PrettyPrinter オブジェクト.
                                                             (line   80)
* format() (str のメソッド):             文字列メソッド<2>.  (line  126)
* format() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line   17)
* format() (traceback.StackSummary のメソッド): StackSummary オブジェクト.
                                                             (line   38)
* format() (traceback.TracebackException のメソッド): TracebackException オブジェクト.
                                                             (line  142)
* format() (tracemalloc.Traceback のメソッド): Traceback.    (line   37)
* format() (組み込み関数);__str__() (オブジェクトメソッド): 基本的なカスタマイズ.
                                                             (line  128)
* formataddr() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line   71)
* formatargvalues() (inspect モジュール): クラスと関数<2>.   (line   71)
* formatdate() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  151)
* FormatError:                           例外<17>.           (line   33)
* FormatError() (ctypes モジュール):     ユーティリティー関数.
                                                             (line  105)
* formatException() (logging.Formatter のメソッド): フォーマッタオブジェクト.
                                                             (line  114)
* formatFooter() (logging.BufferingFormatter のメソッド): フォーマッタオブジェクト.
                                                             (line  144)
* formatHeader() (logging.BufferingFormatter のメソッド): フォーマッタオブジェクト.
                                                             (line  136)
* formatmonth() (calendar.HTMLCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  160)
* formatmonth() (calendar.TextCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  127)
* formatmonthname() (calendar.HTMLCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  183)
* formatStack() (logging.Formatter のメソッド): フォーマッタオブジェクト.
                                                             (line  121)
* formatted string literal:              出力を見やすくフォーマットする.
                                                             (line   88)
* formatted string literal <1>:          文字列リテラルの結合 concatenation.
                                                             (line   24)
* FormattedValue (ast のクラス):         リテラル<3>.        (line   17)
* Formatter (logging のクラス):          フォーマッタオブジェクト.
                                                             (line    6)
* Formatter (string のクラス):           カスタムの文字列書式化.
                                                             (line   13)
* formatTime() (logging.Formatter のメソッド): フォーマッタオブジェクト.
                                                             (line   76)
* formatwarning() (warnings モジュール): 利用可能な関数.     (line   96)
* formatyear() (calendar.HTMLCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  166)
* formatyear() (calendar.TextCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  140)
* formatyearpage() (calendar.HTMLCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  172)
* Fortran contiguous:                    shape strides suboffsets.
                                                             (line   25)
* Fortran contiguous <1>:                用語集<2>.          (line  321)
* forward() (turtle モジュール):         Turtle の動き.      (line    6)
* ForwardRef (typing のクラス):          Introspection helpers.
                                                             (line  148)
* fp (urllib.error.HTTPError の属性):    urllib error --- urllib request によって送出される例外クラス.
                                                             (line   60)
* fpathconf() (os モジュール):           ファイル記述子の操作.
                                                             (line  161)
* Fraction (fractions のクラス):         fractions --- 有理数.
                                                             (line   15)
* frame (inspect.FrameInfo の属性):      インタープリタスタック.
                                                             (line   13)
* frame (tkinter.scrolledtext.ScrolledText の属性): tkinter scrolledtext --- スクロール可能なテキストウィジェット.
                                                             (line   25)
* Frame (tracemalloc のクラス):          Frame.              (line    6)
* FrameInfo (inspect のクラス):          インタープリタスタック.
                                                             (line   11)
* FrameSummary (traceback のクラス):     FrameSummary オブジェクト.
                                                             (line   11)
* FrameType (types モジュール):          標準的なインタプリタ型.
                                                             (line  194)
* free (C function):                     概要<4>.            (line   33)
* free threading:                        用語集<2>.          (line  535)
* free variable:                         用語集<2>.          (line  542)
* free_tool_id() (sys.monitoring モジュール): Registering and using tools.
                                                             (line   13)
* freedesktop_os_release() (platform モジュール): Linux プラットフォーム.
                                                             (line    6)
* freefunc (C type):                     Slot Type typedefs. (line   28)
* freeze_support() (multiprocessing モジュール): その他<3>.  (line   51)
* freeze() (gc モジュール):              gc --- ガベージコレクターインターフェース.
                                                             (line  197)
* frexp() (math モジュール):             数論および数表現の関数.
                                                             (line   82)
* FRIDAY (calendar モジュール):          calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  381)
* from_address() (ctypes._CData のメソッド): データ型<3>.    (line   43)
* from_buffer_copy() (ctypes._CData のメソッド): データ型<3>.
                                                             (line   32)
* from_buffer() (ctypes._CData のメソッド): データ型<3>.     (line   19)
* from_bytes() (int のクラスメソッド):   整数型における追加のメソッド.
                                                             (line  108)
* from_callable() (inspect.Signature のクラスメソッド): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  169)
* from_decimal() (fractions.Fraction のクラスメソッド): fractions --- 有理数.
                                                             (line  144)
* from_exception() (traceback.TracebackException のクラスメソッド): TracebackException オブジェクト.
                                                             (line  125)
* from_file() (zipfile.ZipInfo のクラスメソッド): ZipInfo オブジェクト.
                                                             (line   14)
* from_file() (zoneinfo.ZoneInfo のクラスメソッド): ZoneInfo クラス.
                                                             (line   28)
* from_float() (decimal.Decimal のクラスメソッド): Decimal オブジェクト.
                                                             (line  231)
* from_float() (fractions.Fraction のクラスメソッド): fractions --- 有理数.
                                                             (line  133)
* from_iterable() (itertools.chain のクラスメソッド): Itertool関数.
                                                             (line  117)
* from_list() (traceback.StackSummary のクラスメソッド): StackSummary オブジェクト.
                                                             (line   31)
* from_param() (ctypes._CData のメソッド): データ型<3>.      (line   53)
* from_samples() (statistics.NormalDist のクラスメソッド): NormalDist オブジェクト.
                                                             (line   45)
* from_traceback() (dis.Bytecode のクラスメソッド): バイトコード解析.
                                                             (line   43)
* from_uri() (pathlib.Path のクラスメソッド): URIのパースと生成.
                                                             (line   12)
* from;import statement:                 名前の束縛.         (line    9)
* from;import statement <1>:             import 文.          (line   51)
* from;yield from expression:            Yield 式.           (line   62)
* frombuf() (tarfile.TarInfo のクラスメソッド): TarInfo オブジェクト.
                                                             (line   37)
* frombytes() (array.array のメソッド):  array --- 効率的な数値配列.
                                                             (line  166)
* fromfd() (select.epoll のメソッド):    エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   78)
* fromfd() (select.kqueue のメソッド):   kqueue オブジェクト.
                                                             (line   18)
* fromfd() (socket モジュール):          ソケットの作成.     (line  156)
* fromfile() (array.array のメソッド):   array --- 効率的な数値配列.
                                                             (line  176)
* fromhex() (bytearray のクラスメソッド): bytearray オブジェクト.
                                                             (line   35)
* fromhex() (bytes のクラスメソッド):    バイトオブジェクト. (line   61)
* fromhex() (float のクラスメソッド):    浮動小数点数に対する追加のメソッド.
                                                             (line   38)
* fromisocalendar() (datetime.date のクラスメソッド): date オブジェクト.
                                                             (line   89)
* fromisocalendar() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line  243)
* fromisoformat() (datetime.date のクラスメソッド): date オブジェクト.
                                                             (line   62)
* fromisoformat() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line  196)
* fromisoformat() (datetime.time のクラスメソッド): time オブジェクト.
                                                             (line  106)
* fromkeys() (collections.Counter のメソッド): Counter オブジェクト.
                                                             (line  113)
* fromkeys() (dict のクラスメソッド):    マッピング型 --- dict.
                                                             (line  143)
* fromlist() (array.array のメソッド):   array --- 効率的な数値配列.
                                                             (line  184)
* fromordinal() (datetime.date のクラスメソッド): date オブジェクト.
                                                             (line   53)
* fromordinal() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line  172)
* fromshare() (socket モジュール):       ソケットの作成.     (line  173)
* fromstring() (xml.etree.ElementTree モジュール): 関数<9>.  (line   98)
* fromstringlist() (xml.etree.ElementTree モジュール): 関数<9>.
                                                             (line  106)
* fromtarfile() (tarfile.TarInfo のクラスメソッド): TarInfo オブジェクト.
                                                             (line   44)
* fromtimestamp() (datetime.date のクラスメソッド): date オブジェクト.
                                                             (line   34)
* fromtimestamp() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line  100)
* fromunicode() (array.array のメソッド): array --- 効率的な数値配列.
                                                             (line  190)
* fromutc() (datetime.timezone のメソッド): timezone オブジェクト.
                                                             (line   61)
* fromutc() (datetime.tzinfo のメソッド): tzinfo オブジェクト.
                                                             (line  166)
* FrozenImporter (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line   81)
* FrozenInstanceError:                   モジュールの内容<4>.
                                                             (line  495)
* FrozenSet (typing のクラス):           Aliases to built-in types.
                                                             (line   42)
* frozenset (組み込みクラス):            set（集合）型 --- set frozenset.
                                                             (line   32)
* FS (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  108)
* fs_is_case_insensitive() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  100)
* FS_NONASCII (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   11)
* fsdecode() (os モジュール):            プロセスのパラメーター.
                                                             (line   95)
* fsencode() (os モジュール):            プロセスのパラメーター.
                                                             (line   82)
* fspath() (os モジュール):              プロセスのパラメーター.
                                                             (line  108)
* fstat() (os モジュール):               ファイル記述子の操作.
                                                             (line  181)
* fstatvfs() (os モジュール):            ファイル記述子の操作.
                                                             (line  193)
* fstring:                               出力を見やすくフォーマットする.
                                                             (line   88)
* fstring <1>:                           文字列リテラルの結合 concatenation.
                                                             (line   24)
* FSTRING_END (token モジュール):        token --- Python 解析木で使われる定数.
                                                             (line  255)
* FSTRING_MIDDLE (token モジュール):     token --- Python 解析木で使われる定数.
                                                             (line  253)
* FSTRING_START (token モジュール):      token --- Python 解析木で使われる定数.
                                                             (line  251)
* fsum() (math モジュール):              数論および数表現の関数.
                                                             (line   90)
* fsync() (os モジュール):               ファイル記述子の操作.
                                                             (line  201)
* FTP:                                   urllib request の制限事項.
                                                             (line   37)
* FTP (ftplib のクラス):                 FTP オブジェクト.   (line    6)
* ftp_open() (urllib.request.FTPHandler のメソッド): FTPHandler オブジェクト.
                                                             (line    6)
* FTP_TLS (ftplib のクラス):             FTP_TLS オブジェクト.
                                                             (line    6)
* FTP;ftplib (standard module):          ftplib --- FTP プロトコルクライアント.
                                                             (line    8)
* FTP;プロトコル:                        urllib request の制限事項.
                                                             (line    6)
* FTP;プロトコル <1>:                    ftplib --- FTP プロトコルクライアント.
                                                             (line    8)
* FTPHandler (urllib.request のクラス):  urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  428)
* ftruncate() (os モジュール):           ファイル記述子の操作.
                                                             (line  213)
* Full:                                  queue --- 同期キュークラス.
                                                             (line   83)
* FULL (inspect.BufferFlags の属性):     Buffer flags.       (line   45)
* full_match() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  254)
* FULL_RO (inspect.BufferFlags の属性):  Buffer flags.       (line   47)
* full_url (urllib.request.Request の属性): Request オブジェクト.
                                                             (line   11)
* full() (asyncio.Queue のメソッド):     Queue.              (line   31)
* full() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  125)
* full() (queue.Queue のメソッド):       キューオブジェクト. (line   22)
* fullmatch() (re モジュール):           関数<2>.            (line   65)
* fullmatch() (re.Pattern のメソッド):   正規表現オブジェクト.
                                                             (line   60)
* fully_trusted_filter() (tarfile モジュール): Default named filters.
                                                             (line    9)
* func (functools.partial の属性):       partial オブジェクト.
                                                             (line   10)
* funcname (bdb.Breakpoint の属性):      bdb --- デバッガーフレームワーク.
                                                             (line  102)
* function (inspect.FrameInfo の属性):   インタープリタスタック.
                                                             (line   27)
* function (inspect.Traceback の属性):   インタープリタスタック.
                                                             (line   67)
* Function (pyclbr のクラス):            Function オブジェクト.
                                                             (line    6)
* Function (symtable のクラス):          記号表の検査.       (line  124)
* FUNCTION (symtable.SymbolTableType の属性): 記号表の検査.  (line   15)
* function annotation:                   用語集<2>.          (line  558)
* FunctionDef (ast のクラス):            関数およびクラス定義.
                                                             (line    6)
* FunctionTestCase (unittest のクラス):  テストクラス.       (line  949)
* FunctionType (ast のクラス):           Root nodes.         (line   57)
* FunctionType (types モジュール):       標準的なインタプリタ型.
                                                             (line   24)
* funny_files (filecmp.dircmp の属性):   dircmp クラス.      (line   98)
* Future (asyncio のクラス):             Future オブジェクト<2>.
                                                             (line    6)
* Future (concurrent.futures のクラス):  Future オブジェクト.
                                                             (line   10)
* future;statement:                      future 文 future statement.
                                                             (line    6)
* FutureWarning:                         警告.               (line   50)
* fwalk() (os モジュール):               ファイルとディレクトリ.
                                                             (line 1771)
* gaierror:                              例外<14>.           (line   26)
* gamma() (math モジュール):             特殊関数.           (line   28)
* gammavariate() (random モジュール):    実数分布.           (line   43)
* garbage (gc モジュール):               gc --- ガベージコレクターインターフェース.
                                                             (line  231)
* garbage collection:                    オブジェクト、値、および型.
                                                             (line   38)
* garbage collection <1>:                用語集<2>.          (line  592)
* gather() (asyncio モジュール):         並行な Task 実行.   (line    6)
* gather() (curses.textpad.Textbox のメソッド): Textbox オブジェクト.
                                                             (line  112)
* gauss() (random モジュール):           実数分布.           (line   56)
* gc_collect() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  360)
* gcd() (math モジュール):               数論および数表現の関数.
                                                             (line  105)
* gcvisitobjects_t (C type):             Querying Garbage Collector State.
                                                             (line   26)
* ge() (operator モジュール):            operator --- 関数形式の標準演算子.
                                                             (line   23)
* generate_tokens() (tokenize モジュール): 入力のトークナイズ.
                                                             (line   36)
* Generator (collections.abc のクラス):  コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   56)
* Generator (email.generator のクラス):  email generator Generating MIME documents.
                                                             (line  139)
* Generator (typing のクラス):           Aliases to other ABCs in collections abc.
                                                             (line   38)
* generator expression:                  用語集<2>.          (line  622)
* generator expression <1>:              用語集<2>.          (line  622)
* generator iterator:                    用語集<2>.          (line  610)
* GeneratorExit:                         具象例外.           (line   35)
* GeneratorExp (ast のクラス):           内包表記 Comprehension.
                                                             (line    6)
* GeneratorType (types モジュール):      標準的なインタプリタ型.
                                                             (line   36)
* Generic (typing のクラス):             Building generic types and type aliases.
                                                             (line   15)
* generic function:                      用語集<2>.          (line  631)
* generic type:                          用語集<2>.          (line  639)
* generic_visit() (ast.NodeVisitor のメソッド): ast ヘルパー.
                                                             (line  201)
* Generic;Alias:                         ジェネリックエイリアス型.
                                                             (line    6)
* GenericAlias (types のクラス):         標準的なインタプリタ型.
                                                             (line  149)
* genops() (pickletools モジュール):     プログラミングインターフェース<2>.
                                                             (line   21)
* geometric_mean() (statistics モジュール): 関数の詳細.      (line   73)
* GET_AITER (opcode):                    Python バイトコード命令.
                                                             (line  313)
* get_all_breaks() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  402)
* get_all_start_methods() (multiprocessing モジュール): その他<3>.
                                                             (line   77)
* get_all() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  255)
* get_all() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  362)
* get_all() (wsgiref.headers.Headers のメソッド): wsgiref headers -- WSGI レスポンスヘッダツール群.
                                                             (line   50)
* GET_ANEXT (opcode):                    Python バイトコード命令.
                                                             (line  322)
* get_annotations() (inspect モジュール): クラスと関数<2>.   (line  153)
* get_app() (wsgiref.simple_server.WSGIServer のメソッド): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   65)
* get_archive_formats() (shutil モジュール): アーカイブ化操作.
                                                             (line   71)
* get_args() (typing モジュール):        Introspection helpers.
                                                             (line   81)
* get_asyncgen_hooks() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  985)
* get_attribute() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  594)
* GET_AWAITABLE (opcode):                Python バイトコード命令.
                                                             (line  294)
* get_begidx() (readline モジュール):    補完.               (line   41)
* get_blocking() (os モジュール):        ファイル記述子の操作.
                                                             (line  226)
* get_body_encoding() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line   99)
* get_body() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  519)
* get_boundary() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  404)
* get_boundary() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  584)
* get_bpbynumber() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  378)
* get_break() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  387)
* get_breaks() (bdb.Bdb のメソッド):     bdb --- デバッガーフレームワーク.
                                                             (line  392)
* get_buffer() (asyncio.BufferedProtocol のメソッド): バッファリングされたストリーミングプロトコル.
                                                             (line   21)
* get_bytes() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  165)
* get_ca_certs() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  179)
* get_cache_token() (abc モジュール):    abc --- 抽象基底クラス.
                                                             (line  324)
* get_channel_binding() (ssl.SSLSocket のメソッド): SSL ソケット.
                                                             (line  254)
* get_charset() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  265)
* get_charsets() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  433)
* get_charsets() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  619)
* get_child_watcher() (asyncio モジュール): プロセスのウオッチャー.
                                                             (line   25)
* get_child_watcher() (asyncio.AbstractEventLoopPolicy のメソッド): ポリシーオブジェクト.
                                                             (line   33)
* get_children() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line  120)
* get_children() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line   19)
* get_ciphers() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  194)
* get_clock_info() (time モジュール):    関数<5>.            (line  105)
* get_close_matches() (difflib モジュール): difflib --- 差分の計算の補助.
                                                             (line  199)
* get_code() (importlib.abc.InspectLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  204)
* get_code() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  393)
* get_code() (importlib.machinery.ExtensionFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  330)
* get_code() (importlib.machinery.SourcelessFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  267)
* get_code() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   44)
* get_completer_delims() (readline モジュール): 補完.        (line   51)
* get_completer() (readline モジュール): 補完.               (line   30)
* get_completion_type() (readline モジュール): 補完.         (line   35)
* get_config_h_filename() (sysconfig モジュール): その他の関数<3>.
                                                             (line   68)
* get_config_var() (sysconfig モジュール): 構成変数.         (line   26)
* get_config_vars() (sysconfig モジュール): 構成変数.        (line   16)
* get_content_charset() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  426)
* get_content_charset() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  607)
* get_content_disposition() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  455)
* get_content_disposition() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  632)
* get_content_maintype() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  324)
* get_content_maintype() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  433)
* get_content_subtype() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  330)
* get_content_subtype() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  439)
* get_content_type() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  308)
* get_content_type() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  415)
* get_content() (email.contentmanager モジュール): Content Manager Instances.
                                                             (line   24)
* get_content() (email.contentmanager.ContentManager のメソッド): email contentmanager Managing MIME Content.
                                                             (line   19)
* get_content() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  583)
* get_context() (asyncio.Handle のメソッド): コールバックのハンドル.
                                                             (line   11)
* get_context() (asyncio.Task のメソッド): Task オブジェクト.
                                                             (line  172)
* get_context() (multiprocessing モジュール): その他<3>.     (line   86)
* get_coro() (asyncio.Task のメソッド):  Task オブジェクト.  (line  158)
* get_coroutine_origin_tracking_depth() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  999)
* get_count() (gc モジュール):           gc --- ガベージコレクターインターフェース.
                                                             (line  106)
* get_current_history_length() (readline モジュール): 履歴リスト.
                                                             (line   15)
* get_data() (importlib.abc.FileLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  320)
* get_data() (importlib.abc.ResourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  185)
* get_data() (pkgutil モジュール):       pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  187)
* get_data() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   50)
* get_date() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line   95)
* get_debug() (asyncio.loop のメソッド): デバッグモードの有効化.
                                                             (line    6)
* get_debug() (gc モジュール):           gc --- ガベージコレクターインターフェース.
                                                             (line   54)
* get_default_scheme() (sysconfig モジュール): Installation path functions.
                                                             (line   14)
* get_default_type() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  336)
* get_default_type() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  445)
* get_default_verify_paths() (ssl モジュール): 証明書の取り扱い.
                                                             (line   63)
* get_default() (argparse.ArgumentParser のメソッド): パーサーのデフォルト値.
                                                             (line   32)
* get_dialect() (csv モジュール):        モジュールコンテンツ<3>.
                                                             (line   84)
* get_disassembly_as_string() (test.support.bytecode_helper.BytecodeTestCase のメソッド): test support bytecode_helper --- Support tools for testing correct bytecode generation.
                                                             (line   18)
* get_docstring() (ast モジュール):      ast ヘルパー.       (line  122)
* get_doctest() (doctest.DocTestParser のメソッド): DocTestParser オブジェクト.
                                                             (line   13)
* get_endidx() (readline モジュール):    補完.               (line   41)
* get_environ() (wsgiref.simple_server.WSGIRequestHandler のメソッド): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   88)
* get_errno() (ctypes モジュール):       ユーティリティー関数.
                                                             (line  118)
* get_escdelay() (curses モジュール):    関数<6>.            (line  433)
* get_event_loop_policy() (asyncio モジュール): ポリシーの取得と設定.
                                                             (line    9)
* get_event_loop() (asyncio モジュール): イベントループ.     (line   38)
* get_event_loop() (asyncio.AbstractEventLoopPolicy のメソッド): ポリシーオブジェクト.
                                                             (line   12)
* get_events() (sys.monitoring モジュール): Setting events globally.
                                                             (line    9)
* get_examples() (doctest.DocTestParser のメソッド): DocTestParser オブジェクト.
                                                             (line   22)
* get_exception_handler() (asyncio.loop のメソッド): エラーハンドリング API.
                                                             (line   28)
* get_exec_path() (os モジュール):       プロセスのパラメーター.
                                                             (line  166)
* get_extra_info() (asyncio.BaseTransport のメソッド): 基底トランスポート.
                                                             (line   21)
* get_extra_info() (asyncio.StreamWriter のメソッド): StreamWriter.
                                                             (line   63)
* get_field() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line   53)
* get_file_breaks() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  397)
* get_file() (mailbox.Babyl のメソッド): Babyl オブジェクト. (line   47)
* get_file() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  179)
* get_file() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  218)
* get_file() (mailbox.mbox のメソッド):  mbox オブジェクト.  (line   32)
* get_file() (mailbox.MH のメソッド):    MH オブジェクト.    (line   98)
* get_file() (mailbox.MMDF のメソッド):  MMDF オブジェクト.  (line   28)
* get_filename() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  395)
* get_filename() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  575)
* get_filename() (importlib.abc.ExecutionLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  276)
* get_filename() (importlib.abc.FileLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  316)
* get_filename() (importlib.machinery.ExtensionFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  339)
* get_filename() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   58)
* get_filter() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  105)
* get_flags() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line   90)
* get_flags() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line   68)
* get_flags() (mailbox.mboxMessage のメソッド): mboxMessage オブジェクト.
                                                             (line   66)
* get_flags() (mailbox.MMDFMessage のメソッド): MMDFMessage オブジェクト.
                                                             (line   65)
* get_folder() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line   67)
* get_folder() (mailbox.MH のメソッド):  MH オブジェクト.    (line   41)
* get_frees() (symtable.Function のメソッド): 記号表の検査.  (line  146)
* get_freeze_count() (gc モジュール):    gc --- ガベージコレクターインターフェース.
                                                             (line  222)
* get_from() (mailbox.mboxMessage のメソッド): mboxMessage オブジェクト.
                                                             (line   49)
* get_from() (mailbox.MMDFMessage のメソッド): MMDFMessage オブジェクト.
                                                             (line   48)
* get_full_url() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line  108)
* get_globals() (symtable.Function のメソッド): 記号表の検査.
                                                             (line  137)
* get_grouped_opcodes() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line  166)
* get_handle_inheritable() (os モジュール): ファイル記述子の継承.
                                                             (line   36)
* get_header() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line  122)
* get_history_item() (readline モジュール): 履歴リスト.      (line   20)
* get_history_length() (readline モジュール): 履歴ファイル.  (line   30)
* get_id() (symtable.SymbolTable のメソッド): 記号表の検査.  (line   70)
* get_ident() (_thread モジュール):      _thread --- 低水準なスレッド API.
                                                             (line   86)
* get_ident() (threading モジュール):    threading --- スレッドベースの並列処理.
                                                             (line  115)
* get_identifiers() (string.Template のメソッド): テンプレート文字列.
                                                             (line   76)
* get_identifiers() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line  105)
* get_importer() (pkgutil モジュール):   pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   73)
* get_info() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  153)
* get_info() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line  105)
* get_inheritable() (os モジュール):     ファイル記述子の継承.
                                                             (line   26)
* get_inheritable() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  129)
* get_instructions() (dis モジュール):   解析関数.           (line  134)
* get_int_max_str_digits() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  804)
* get_interpreter() (zipapp モジュール): Python API.         (line   79)
* GET_ITER (opcode):                     Python バイトコード命令.
                                                             (line  205)
* get_key() (selectors.BaseSelector のメソッド): クラス<4>.  (line  148)
* get_labels() (mailbox.Babyl のメソッド): Babyl オブジェクト.
                                                             (line   34)
* get_labels() (mailbox.BabylMessage のメソッド): BabylMessage オブジェクト.
                                                             (line   46)
* get_last_error() (ctypes モジュール):  ユーティリティー関数.
                                                             (line  126)
* GET_LEN (opcode):                      Python バイトコード命令.
                                                             (line  515)
* get_line_buffer() (readline モジュール): 行バッファ.       (line    8)
* get_lineno() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line   86)
* get_loader() (pkgutil モジュール):     pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   87)
* get_local_events() (sys.monitoring モジュール): Per code object events.
                                                             (line   11)
* get_locals() (symtable.Function のメソッド): 記号表の検査. (line  133)
* get_logger() (multiprocessing モジュール): ログ記録<2>.    (line   11)
* get_loop() (asyncio.Future のメソッド): Future オブジェクト<2>.
                                                             (line  142)
* get_loop() (asyncio.Runner のメソッド): Runner context manager.
                                                             (line   58)
* get_loop() (asyncio.Server のメソッド): Serverオブジェクト.
                                                             (line   69)
* get_makefile_filename() (sysconfig モジュール): その他の関数<3>.
                                                             (line   72)
* get_map() (selectors.BaseSelector のメソッド): クラス<4>.  (line  156)
* get_matching_blocks() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line  106)
* get_message() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  158)
* get_method() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line   68)
* get_methods() (symtable.Class のメソッド): 記号表の検査.   (line  156)
* get_mixed_type_key() (ipaddress モジュール): その他のモジュールレベル関数.
                                                             (line   56)
* get_name() (asyncio.Task のメソッド):  Task オブジェクト.  (line  179)
* get_name() (symtable.Symbol のメソッド): 記号表の検査.     (line  197)
* get_name() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line   74)
* get_namespace() (symtable.Symbol のメソッド): 記号表の検査.
                                                             (line  268)
* get_namespaces() (symtable.Symbol のメソッド): 記号表の検査.
                                                             (line  264)
* get_native_id() (_thread モジュール):  _thread --- 低水準なスレッド API.
                                                             (line   94)
* get_native_id() (threading モジュール): threading --- スレッドベースの並列処理.
                                                             (line  125)
* get_nonlocals() (symtable.Function のメソッド): 記号表の検査.
                                                             (line  141)
* get_nonstandard_attr() (http.cookiejar.Cookie のメソッド): Cookieオブジェクト<2>.
                                                             (line  104)
* get_nowait() (asyncio.Queue のメソッド): Queue.            (line   48)
* get_nowait() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  165)
* get_nowait() (queue.Queue のメソッド): キューオブジェクト. (line   66)
* get_nowait() (queue.SimpleQueue のメソッド): SimpleQueue オブジェクト.
                                                             (line   52)
* get_object_traceback() (tracemalloc モジュール): 関数<11>. (line   12)
* get_objects() (gc モジュール):         gc --- ガベージコレクターインターフェース.
                                                             (line   58)
* get_opcodes() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line  123)
* get_option_group() (optparse.OptionParser のメソッド): オプションをグループ化する.
                                                             (line  102)
* get_option() (optparse.OptionParser のメソッド): オプション解析器への問い合わせと操作.
                                                             (line   39)
* get_origin() (typing モジュール):      Introspection helpers.
                                                             (line   58)
* get_original_bases() (types モジュール): 動的な型生成.     (line   66)
* get_original_stdout() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  317)
* get_osfhandle() (msvcrt モジュール):   ファイル操作関連.   (line   58)
* get_output_charset() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line  116)
* get_overloads() (typing モジュール):   Functions and decorators.
                                                             (line  284)
* get_pagesize() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  284)
* get_param() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  480)
* get_parameters() (symtable.Function のメソッド): 記号表の検査.
                                                             (line  129)
* get_params() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  459)
* get_path_names() (sysconfig モジュール): Installation path functions.
                                                             (line   57)
* get_path() (sysconfig モジュール):     Installation path functions.
                                                             (line   62)
* get_paths() (sysconfig モジュール):    Installation path functions.
                                                             (line   92)
* get_payload() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  182)
* get_pid() (asyncio.SubprocessTransport のメソッド): サブプロセス化されたトランスポート.
                                                             (line    6)
* get_pipe_transport() (asyncio.SubprocessTransport のメソッド): サブプロセス化されたトランスポート.
                                                             (line   10)
* get_platform() (sysconfig モジュール): その他の関数<3>.    (line   11)
* get_poly() (turtle モジュール):        特別な Turtle のメソッド.
                                                             (line   16)
* get_preferred_scheme() (sysconfig モジュール): Installation path functions.
                                                             (line   24)
* get_protocol_members() (typing モジュール): Introspection helpers.
                                                             (line   99)
* get_protocol() (asyncio.BaseTransport のメソッド): 基底トランスポート.
                                                             (line   89)
* get_proxy_response_headers() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line  136)
* get_python_version() (sysconfig モジュール): その他の関数<3>.
                                                             (line    6)
* get_ready() (graphlib.TopologicalSorter のメソッド): graphlib --- グラフ構造を操作する機能.
                                                             (line  147)
* get_referents() (gc モジュール):       gc --- ガベージコレクターインターフェース.
                                                             (line  136)
* get_referrers() (gc モジュール):       gc --- ガベージコレクターインターフェース.
                                                             (line  115)
* get_request() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  127)
* get_returncode() (asyncio.SubprocessTransport のメソッド): サブプロセス化されたトランスポート.
                                                             (line   29)
* get_running_loop() (asyncio モジュール): イベントループ.   (line   28)
* get_scheme_names() (sysconfig モジュール): Installation path functions.
                                                             (line    9)
* get_scheme() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  188)
* get_selection() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  109)
* get_sequences() (mailbox.MH のメソッド): MH オブジェクト.  (line   58)
* get_sequences() (mailbox.MHMessage のメソッド): MHMessage オブジェクト.
                                                             (line   32)
* get_server_certificate() (ssl モジュール): 証明書の取り扱い.
                                                             (line   30)
* get_server() (multiprocessing.managers.BaseManager のメソッド): マネージャー.
                                                             (line   65)
* get_shapepoly() (turtle モジュール):   見た目.             (line  167)
* get_source_segment() (ast モジュール): ast ヘルパー.       (line  134)
* get_source() (importlib.abc.InspectLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  218)
* get_source() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  410)
* get_source() (importlib.machinery.ExtensionFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  335)
* get_source() (importlib.machinery.SourcelessFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  272)
* get_source() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   66)
* get_stack() (asyncio.Task のメソッド): Task オブジェクト.  (line  122)
* get_stack() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  409)
* get_start_method() (multiprocessing モジュール): その他<3>.
                                                             (line   98)
* get_starttag_text() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   33)
* get_stats_profile() (pstats.Stats のメソッド): Stats クラス.
                                                             (line  209)
* get_stats() (gc モジュール):           gc --- ガベージコレクターインターフェース.
                                                             (line   69)
* get_stderr() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  129)
* get_stderr() (wsgiref.simple_server.WSGIRequestHandler のメソッド): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   97)
* get_stdin() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  123)
* get_string() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  172)
* get_subdir() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line   51)
* get_symbols() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line  115)
* get_tabsize() (curses モジュール):     関数<6>.            (line  448)
* get_task_factory() (asyncio.loop のメソッド): フューチャーとタスクの生成.
                                                             (line   52)
* get_terminal_size() (os モジュール):   ターミナルのサイズの問い合わせ.
                                                             (line    8)
* get_terminal_size() (shutil モジュール): 出力ターミナルのサイズの取得.
                                                             (line    6)
* get_threshold() (gc モジュール):       gc --- ガベージコレクターインターフェース.
                                                             (line  110)
* get_token() (shlex.shlex のメソッド):  shlex オブジェクト. (line    8)
* get_tool() (sys.monitoring モジュール): Registering and using tools.
                                                             (line   22)
* get_traceback_limit() (tracemalloc モジュール): 関数<11>.  (line   22)
* get_traced_memory() (tracemalloc モジュール): 関数<11>.    (line   33)
* get_tracemalloc_memory() (tracemalloc モジュール): 関数<11>.
                                                             (line   57)
* get_type_hints() (typing モジュール):  Introspection helpers.
                                                             (line    6)
* get_type() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line   54)
* get_unixfrom() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  152)
* get_unixfrom() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  163)
* get_unpack_formats() (shutil モジュール): アーカイブ化操作.
                                                             (line  199)
* get_unverified_chain() (ssl.SSLSocket のメソッド): SSL ソケット.
                                                             (line  219)
* get_usage() (optparse.OptionParser のメソッド): その他のメソッド.
                                                             (line   22)
* get_value() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line   63)
* get_verified_chain() (ssl.SSLSocket のメソッド): SSL ソケット.
                                                             (line  210)
* get_version() (optparse.OptionParser のメソッド): バージョン番号の出力.
                                                             (line   34)
* get_visible() (mailbox.BabylMessage のメソッド): BabylMessage オブジェクト.
                                                             (line   64)
* get_wch() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  234)
* get_write_buffer_limits() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line   25)
* get_write_buffer_size() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line   20)
* GET_YIELD_FROM_ITER (opcode):          Python バイトコード命令.
                                                             (line  209)
* get() (asyncio.Queue のメソッド):      Queue.              (line   39)
* get() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  221)
* get() (contextvars.Context のメソッド): マニュアルでのコンテキスト管理.
                                                             (line  118)
* get() (contextvars.ContextVar のメソッド): コンテキスト変数.
                                                             (line   30)
* get() (dict のメソッド):               マッピング型 --- dict.
                                                             (line  155)
* get() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  246)
* get() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  354)
* get() (mailbox.Mailbox のメソッド):    Mailbox オブジェクト.
                                                             (line  146)
* get() (multiprocessing.pool.AsyncResult のメソッド): プロセスプール.
                                                             (line  202)
* get() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  151)
* get() (multiprocessing.SimpleQueue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  237)
* get() (queue.Queue のメソッド):        キューオブジェクト. (line   46)
* get() (queue.SimpleQueue のメソッド):  SimpleQueue オブジェクト.
                                                             (line   41)
* get() (tkinter.ttk.Combobox のメソッド): ttk Combobox.     (line   15)
* get() (tkinter.ttk.Spinbox のメソッド): ttk Spinbox.       (line    8)
* get() (types.MappingProxyType のメソッド): 標準的なインタプリタ型.
                                                             (line  259)
* get() (webbrowser モジュール):         webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line  100)
* get() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   61)
* getacl() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  106)
* getaddresses() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line   85)
* getaddrinfo() (asyncio.loop のメソッド): DNS.              (line    6)
* getaddrinfo() (socket モジュール):     その他の関数<2>.    (line   17)
* getallocatedblocks() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  709)
* getandroidapilevel() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  730)
* getannotation() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  111)
* getargvalues() (inspect モジュール):   クラスと関数<2>.    (line   60)
* getasyncgenlocals() (inspect モジュール): Current State of Generators Coroutines and Asynchronous Generators.
                                                             (line   99)
* getasyncgenstate() (inspect モジュール): Current State of Generators Coroutines and Asynchronous Generators.
                                                             (line   47)
* getatime() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  173)
* getattr_static() (inspect モジュール): 属性の静的なフェッチ.
                                                             (line   16)
* getattrfunc (C type):                  Slot Type typedefs. (line   47)
* getAttribute() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   32)
* getAttributeNode() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   38)
* getAttributeNodeNS() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   48)
* getAttributeNS() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   42)
* getattrofunc (C type):                 Slot Type typedefs. (line   58)
* GetBase() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   30)
* getbegyx() (curses.window のメソッド): Window オブジェクト.
                                                             (line  218)
* getbkgd() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  222)
* getblocking() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  165)
* getboolean() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  251)
* getbuffer() (io.BytesIO のメソッド):   バッファ付きストリーム.
                                                             (line   22)
* getbufferproc (C type):                Slot Type typedefs. (line  108)
* getByteStream() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   48)
* getcallargs() (inspect モジュール):    クラスと関数<2>.    (line   89)
* getcanvas() (turtle モジュール):       設定と特殊なメソッド.
                                                             (line   55)
* getch() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  226)
* getch() (msvcrt モジュール):           コンソール I/O 関連.
                                                             (line   11)
* getCharacterStream() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   63)
* getche() (msvcrt モジュール):          コンソール I/O 関連.
                                                             (line   25)
* getChild() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  158)
* getChildren() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  169)
* getclasstree() (inspect モジュール):   クラスと関数<2>.    (line    6)
* getclosurevars() (inspect モジュール): クラスと関数<2>.    (line  120)
* getcode() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   90)
* getcode() (urllib.response.addinfourl のメソッド): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   45)
* getColumnNumber() (xml.sax.xmlreader.Locator のメソッド): Locator オブジェクト.
                                                             (line    8)
* getcomments() (inspect モジュール):    ソースコードの情報取得.
                                                             (line   18)
* getcompname() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   41)
* getcomptype() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   36)
* getconfig() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  662)
* getContentHandler() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   22)
* getcontext() (decimal モジュール):     Context オブジェクト.
                                                             (line   14)
* getcoroutinelocals() (inspect モジュール): Current State of Generators Coroutines and Asynchronous Generators.
                                                             (line   91)
* getcoroutinestate() (inspect モジュール): Current State of Generators Coroutines and Asynchronous Generators.
                                                             (line   28)
* getctime() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  190)
* getcwd() (os モジュール):              ファイルとディレクトリ.
                                                             (line  302)
* getcwdb() (os モジュール):             ファイルとディレクトリ.
                                                             (line  306)
* getdecoder() (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  110)
* getdefaultencoding() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  741)
* getdefaultlocale() (locale モジュール): locale --- 国際化サービス.
                                                             (line  322)
* getdefaulttimeout() (socket モジュール): その他の関数<2>.  (line  372)
* getdlopenflags() (sys モジュール):     sys --- システム固有のパラメーターと関数.
                                                             (line  746)
* getdoc() (inspect モジュール):         ソースコードの情報取得.
                                                             (line    6)
* getDOMImplementation() (xml.dom モジュール): モジュールコンテンツ<4>.
                                                             (line   17)
* getDTDHandler() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   32)
* getEffectiveLevel() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  148)
* getegid() (os モジュール):             プロセスのパラメーター.
                                                             (line  175)
* getElementsByTagName() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   60)
* getElementsByTagName() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   14)
* getElementsByTagNameNS() (xml.dom.Document のメソッド): Document オブジェクト.
                                                             (line   65)
* getElementsByTagNameNS() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   18)
* getencoder() (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  102)
* getencoding() (locale モジュール):     locale --- 国際化サービス.
                                                             (line  381)
* getEncoding() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   32)
* getEntityResolver() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   41)
* getenv() (os モジュール):              プロセスのパラメーター.
                                                             (line  134)
* getenvb() (os モジュール):             プロセスのパラメーター.
                                                             (line  149)
* getErrorHandler() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   52)
* geteuid() (os モジュール):             プロセスのパラメーター.
                                                             (line  182)
* getEvent() (xml.dom.pulldom.DOMEventStream のメソッド): DOMEventStream オブジェクト.
                                                             (line   11)
* getEventCategory() (logging.handlers.NTEventLogHandler のメソッド): NTEventLogHandler.
                                                             (line   42)
* getEventType() (logging.handlers.NTEventLogHandler のメソッド): NTEventLogHandler.
                                                             (line   48)
* getException() (xml.sax.SAXException のメソッド): SAXException オブジェクト.
                                                             (line   13)
* getFeature() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   70)
* getfile() (inspect モジュール):        ソースコードの情報取得.
                                                             (line   27)
* getFilesToDelete() (logging.handlers.TimedRotatingFileHandler のメソッド): TimedRotatingFileHandler.
                                                             (line  111)
* getfilesystemencodeerrors() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  786)
* getfilesystemencoding() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  755)
* getfloat() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  244)
* getfqdn() (socket モジュール):         その他の関数<2>.    (line   97)
* getframeinfo() (inspect モジュール):   インタープリタスタック.
                                                             (line  119)
* getframerate() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   28)
* getfullargspec() (inspect モジュール): クラスと関数<2>.    (line   15)
* getgeneratorlocals() (inspect モジュール): Current State of Generators Coroutines and Asynchronous Generators.
                                                             (line   72)
* getgeneratorstate() (inspect モジュール): Current State of Generators Coroutines and Asynchronous Generators.
                                                             (line   12)
* getgid() (os モジュール):              プロセスのパラメーター.
                                                             (line  188)
* getgrall() (grp モジュール):           grp --- グループデータベース.
                                                             (line   60)
* getgrgid() (grp モジュール):           grp --- グループデータベース.
                                                             (line   45)
* getgrnam() (grp モジュール):           grp --- グループデータベース.
                                                             (line   54)
* getgrouplist() (os モジュール):        プロセスのパラメーター.
                                                             (line  197)
* getgroups() (os モジュール):           プロセスのパラメーター.
                                                             (line  208)
* getHandlerByName() (logging モジュール): モジュールレベルの関数.
                                                             (line  176)
* getHandlerNames() (logging モジュール): モジュールレベルの関数.
                                                             (line  183)
* getheader() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   25)
* getheaders() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   33)
* gethostbyaddr() (socket モジュール):   プロセスのパラメーター.
                                                             (line  548)
* gethostbyaddr() (socket モジュール) <1>: その他の関数<2>.  (line  155)
* gethostbyname_ex() (socket モジュール): その他の関数<2>.   (line  124)
* gethostbyname() (socket モジュール):   その他の関数<2>.    (line  109)
* gethostname() (socket モジュール):     プロセスのパラメーター.
                                                             (line  548)
* gethostname() (socket モジュール) <1>: その他の関数<2>.    (line  141)
* getincrementaldecoder() (codecs モジュール): codecs --- codec レジストリと基底クラス.
                                                             (line  126)
* getincrementalencoder() (codecs モジュール): codecs --- codec レジストリと基底クラス.
                                                             (line  118)
* getinfo() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  117)
* getinnerframes() (inspect モジュール): インタープリタスタック.
                                                             (line  142)
* GetInputContext() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   36)
* getint() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  237)
* getitem() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  191)
* getiterfunc (C type):                  Slot Type typedefs. (line   94)
* getitimer() (signal モジュール):       モジュールの内容<2>.
                                                             (line  433)
* getkey() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  242)
* GetLastError() (ctypes モジュール):    ユーティリティー関数.
                                                             (line  111)
* getLength() (xml.sax.xmlreader.Attributes のメソッド): Attributes インターフェース.
                                                             (line   11)
* getLevelName() (logging モジュール):   モジュールレベルの関数.
                                                             (line  146)
* getLevelNamesMapping() (logging モジュール): モジュールレベルの関数.
                                                             (line  137)
* getlimit() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  603)
* getline() (linecache モジュール):      linecache --- テキストラインへのランダムアクセス.
                                                             (line   23)
* getLineNumber() (xml.sax.xmlreader.Locator のメソッド): Locator オブジェクト.
                                                             (line   12)
* getloadavg() (os モジュール):          雑多なシステム情報. (line   49)
* getlocale() (locale モジュール):       locale --- 国際化サービス.
                                                             (line  346)
* getLogger() (logging モジュール):      モジュールレベルの関数.
                                                             (line    8)
* getLoggerClass() (logging モジュール): モジュールレベルの関数.
                                                             (line   22)
* getlogin() (os モジュール):            プロセスのパラメーター.
                                                             (line  230)
* getLogRecordFactory() (logging モジュール): モジュールレベルの関数.
                                                             (line   33)
* getMandatoryRelease() (__future__._Feature のメソッド): モジュールコンテンツ<5>.
                                                             (line   67)
* getmark() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   72)
* getmarkers() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   64)
* getmaxyx() (curses.window のメソッド): Window オブジェクト.
                                                             (line  249)
* getmember() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  106)
* getmembers_static() (inspect モジュール): 型とメンバー.    (line  322)
* getmembers() (inspect モジュール):     型とメンバー.       (line  309)
* getmembers() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  115)
* getMessage() (logging.LogRecord のメソッド): LogRecord オブジェクト.
                                                             (line   61)
* getMessage() (xml.sax.SAXException のメソッド): SAXException オブジェクト.
                                                             (line    9)
* getMessageID() (logging.handlers.NTEventLogHandler のメソッド): NTEventLogHandler.
                                                             (line   58)
* getmodule() (inspect モジュール):      ソースコードの情報取得.
                                                             (line   33)
* getmodulename() (inspect モジュール):  型とメンバー.       (line  338)
* getmouse() (curses モジュール):        関数<6>.            (line  144)
* getmro() (inspect モジュール):         クラスと関数<2>.    (line   81)
* getmtime() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  180)
* getName() (threading.Thread のメソッド): Thread オブジェクト.
                                                             (line  165)
* getNameByQName() (xml.sax.xmlreader.AttributesNS のメソッド): AttributesNS インターフェース.
                                                             (line   17)
* getnameinfo() (asyncio.loop のメソッド): DNS.              (line   11)
* getnameinfo() (socket モジュール):     その他の関数<2>.    (line  171)
* getnames() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  120)
* getNames() (xml.sax.xmlreader.Attributes のメソッド): Attributes インターフェース.
                                                             (line   15)
* getnchannels() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   19)
* getnframes() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   32)
* getnode:                               uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  176)
* getnode() (uuid モジュール):           uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  159)
* getobjects() (sys モジュール):         sys --- システム固有のパラメーターと関数.
                                                             (line  893)
* getopt() (getopt モジュール):          getopt --- C-style parser for command line options.
                                                             (line   29)
* GetoptError:                           getopt --- C-style parser for command line options.
                                                             (line   73)
* getOptionalRelease() (__future__._Feature のメソッド): モジュールコンテンツ<5>.
                                                             (line   62)
* getouterframes() (inspect モジュール): インタープリタスタック.
                                                             (line  127)
* getoutput() (subprocess モジュール):   レガシーなシェル呼び出し関数.
                                                             (line   45)
* getpagesize() (resource モジュール):   リソースの使用状態. (line  102)
* getparams() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   46)
* getparyx() (curses.window のメソッド): Window オブジェクト.
                                                             (line  253)
* getpass() (getpass モジュール):        getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   17)
* GetPassWarning:                        getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   33)
* getpeercert() (ssl.SSLSocket のメソッド): SSL ソケット.    (line  145)
* getpeername() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  137)
* getpen() (turtle モジュール):          特別な Turtle のメソッド.
                                                             (line   39)
* getpgid() (os モジュール):             プロセスのパラメーター.
                                                             (line  240)
* getpgrp() (os モジュール):             プロセスのパラメーター.
                                                             (line  247)
* getpid() (os モジュール):              プロセスのパラメーター.
                                                             (line  253)
* getpos() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   29)
* getppid() (os モジュール):             プロセスのパラメーター.
                                                             (line  260)
* getpreferredencoding() (locale モジュール): locale --- 国際化サービス.
                                                             (line  357)
* getpriority() (os モジュール):         プロセスのパラメーター.
                                                             (line  271)
* getprofile() (sys モジュール):         sys --- システム固有のパラメーターと関数.
                                                             (line  918)
* getprofile() (threading モジュール):   threading --- スレッドベースの並列処理.
                                                             (line  196)
* getProperty() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   83)
* getprotobyname() (socket モジュール):  その他の関数<2>.    (line  191)
* getproxies() (urllib.request モジュール): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  158)
* getPublicId() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   10)
* getPublicId() (xml.sax.xmlreader.Locator のメソッド): Locator オブジェクト.
                                                             (line   16)
* getpwall() (pwd モジュール):           pwd --- パスワードデータベース.
                                                             (line   67)
* getpwnam() (pwd モジュール):           pwd --- パスワードデータベース.
                                                             (line   62)
* getpwuid() (pwd モジュール):           pwd --- パスワードデータベース.
                                                             (line   58)
* getQNameByName() (xml.sax.xmlreader.AttributesNS のメソッド): AttributesNS インターフェース.
                                                             (line   22)
* getQNames() (xml.sax.xmlreader.AttributesNS のメソッド): AttributesNS インターフェース.
                                                             (line   26)
* getquota() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  116)
* getquotaroot() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  121)
* getrandbits() (random モジュール):     整数用の関数.       (line   36)
* getrandbits() (random.Random のメソッド): 他の生成器.      (line   42)
* getrandom() (os モジュール):           乱数<2>.            (line    6)
* getreader() (codecs モジュール):       codecs --- codec レジストリと基底クラス.
                                                             (line  134)
* getrecursionlimit() (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line  827)
* getrefcount() (sys モジュール):        sys --- システム固有のパラメーターと関数.
                                                             (line  812)
* GetReparseDeferralEnabled() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  109)
* getresgid() (os モジュール):           プロセスのパラメーター.
                                                             (line  318)
* getresponse() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line   76)
* getresuid() (os モジュール):           プロセスのパラメーター.
                                                             (line  309)
* getrlimit() (resource モジュール):     リソースの制限.     (line   26)
* getroot() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   35)
* getrusage() (resource モジュール):     リソースの使用状態. (line    8)
* getsampwidth() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   24)
* getscreen() (turtle モジュール):       特別な Turtle のメソッド.
                                                             (line   50)
* getservbyname() (socket モジュール):   その他の関数<2>.    (line  202)
* getservbyport() (socket モジュール):   その他の関数<2>.    (line  214)
* GetSetDescriptorType (types モジュール): 標準的なインタプリタ型.
                                                             (line  199)
* getshapes() (turtle モジュール):       設定と特殊なメソッド.
                                                             (line   64)
* getsid() (os モジュール):              プロセスのパラメーター.
                                                             (line  506)
* getsignal() (signal モジュール):       モジュールの内容<2>.
                                                             (line  282)
* getsitepackages() (site モジュール):   モジュールの内容<5>.
                                                             (line   58)
* getsize() (os.path モジュール):        os path --- 一般的なパス名操作.
                                                             (line  201)
* getsizeof() (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line  835)
* getsockname() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  144)
* getsockopt() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  150)
* getsource() (inspect モジュール):      ソースコードの情報取得.
                                                             (line   59)
* getsourcefile() (inspect モジュール):  ソースコードの情報取得.
                                                             (line   38)
* getsourcelines() (inspect モジュール): ソースコードの情報取得.
                                                             (line   45)
* getstate() (codecs.IncrementalDecoder のメソッド): IncrementalDecoder オブジェクト.
                                                             (line   44)
* getstate() (codecs.IncrementalEncoder のメソッド): IncrementalEncoder オブジェクト.
                                                             (line   42)
* getstate() (random モジュール):        保守 bookkeeping 関数.
                                                             (line   32)
* getstate() (random.Random のメソッド): 他の生成器.         (line   24)
* getstatusoutput() (subprocess モジュール): レガシーなシェル呼び出し関数.
                                                             (line   11)
* getstr() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  258)
* getSubject() (logging.handlers.SMTPHandler のメソッド): SMTPHandler.
                                                             (line   38)
* getswitchinterval() (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line  856)
* getSystemId() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   18)
* getSystemId() (xml.sax.xmlreader.Locator のメソッド): Locator オブジェクト.
                                                             (line   20)
* getsyx() (curses モジュール):          関数<6>.            (line  163)
* gettarinfo() (tarfile.TarFile のメソッド): TarFile オブジェクト.
                                                             (line  308)
* gettempdir() (tempfile モジュール):    tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  316)
* gettempdirb() (tempfile モジュール):   tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  347)
* gettempprefix() (tempfile モジュール): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  353)
* gettempprefixb() (tempfile モジュール): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  358)
* getter (C type):                       Defining Getters and Setters.
                                                             (line   33)
* getTestCaseNames() (unittest.TestLoader のメソッド): テストのロードと起動.
                                                             (line  109)
* gettext() (gettext モジュール):        GNU gettext API.    (line   33)
* gettext() (gettext.GNUTranslations のメソッド): GNUTranslations クラス.
                                                             (line   37)
* gettext() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   38)
* gettext() (locale モジュール):         メッセージカタログへのアクセス.
                                                             (line    6)
* gettimeout() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  174)
* gettrace() (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line  923)
* gettrace() (threading モジュール):     threading --- スレッドベースの並列処理.
                                                             (line  172)
* getturtle() (turtle モジュール):       特別な Turtle のメソッド.
                                                             (line   39)
* getType() (xml.sax.xmlreader.Attributes のメソッド): Attributes インターフェース.
                                                             (line   19)
* getuid() (os モジュール):              プロセスのパラメーター.
                                                             (line  327)
* getunicodeinternedsize() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line  724)
* geturl() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   80)
* geturl() (urllib.parse.urllib.parse.SplitResult のメソッド): 構造化された解析結果.
                                                             (line   12)
* geturl() (urllib.response.addinfourl のメソッド): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   30)
* getuser() (getpass モジュール):        getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   38)
* getuserbase() (site モジュール):       モジュールの内容<5>.
                                                             (line   64)
* getusersitepackages() (site モジュール): モジュールの内容<5>.
                                                             (line   72)
* getvalue() (io.BytesIO のメソッド):    バッファ付きストリーム.
                                                             (line   39)
* getvalue() (io.StringIO のメソッド):   テキスト I/O<2>.    (line  259)
* getValue() (xml.sax.xmlreader.Attributes のメソッド): Attributes インターフェース.
                                                             (line   23)
* getValueByQName() (xml.sax.xmlreader.AttributesNS のメソッド): AttributesNS インターフェース.
                                                             (line   13)
* getwch() (msvcrt モジュール):          コンソール I/O 関連.
                                                             (line   21)
* getwche() (msvcrt モジュール):         コンソール I/O 関連.
                                                             (line   30)
* getweakrefcount() (weakref モジュール): weakref --- 弱参照.
                                                             (line  149)
* getweakrefs() (weakref モジュール):    weakref --- 弱参照. (line  153)
* getwelcome() (ftplib.FTP のメソッド):  FTP オブジェクト.   (line  121)
* getwelcome() (poplib.POP3 のメソッド): POP3 オブジェクト.  (line   19)
* getwin() (curses モジュール):          関数<6>.            (line  169)
* getwindowsversion() (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line  932)
* getwriter() (codecs モジュール):       codecs --- codec レジストリと基底クラス.
                                                             (line  142)
* getxattr() (os モジュール):            Linux 拡張属性.     (line   10)
* getyx() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  269)
* gid (tarfile.TarInfo の属性):          TarInfo オブジェクト.
                                                             (line  115)
* GIL:                                   用語集<2>.          (line  648)
* glob() (glob モジュール):              glob --- Unix 形式のパス名のパターン展開.
                                                             (line   28)
* glob() (pathlib.Path のメソッド):      ディレクトリを読む. (line   30)
* Global (ast のクラス):                 関数およびクラス定義.
                                                             (line  144)
* global interpreter lock:               スレッド状態 thread state とグローバルインタプリタロック global interpreter lock.
                                                             (line    6)
* global interpreter lock <1>:           用語集<2>.          (line  652)
* global_enum() (enum モジュール):       ユーティリティとデコレータ.
                                                             (line   92)
* globs (doctest.DocTest の属性):        DocTest オブジェクト.
                                                             (line   22)
* gmtime() (time モジュール):            関数<5>.            (line  139)
* gname (tarfile.TarInfo の属性):        TarInfo オブジェクト.
                                                             (line  131)
* GNOME:                                 Catalog コンストラクタ.
                                                             (line    6)
* GNU_FORMAT (tarfile モジュール):       tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  329)
* gnu_getopt() (getopt モジュール):      getopt --- C-style parser for command line options.
                                                             (line   62)
* GNUTranslations (gettext のクラス):    GNUTranslations クラス.
                                                             (line   33)
* GNUTYPE_LONGLINK (tarfile モジュール): tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  313)
* GNUTYPE_LONGNAME (tarfile モジュール): tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  309)
* GNUTYPE_SPARSE (tarfile モジュール):   tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  317)
* go() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  113)
* got (doctest.DocTestFailure の属性):   デバッグ.           (line  199)
* goto() (turtle モジュール):            Turtle の動き.      (line   74)
* grantpt() (os モジュール):             ファイル記述子の操作.
                                                             (line  246)
* GREATER (token モジュール):            token --- Python 解析木で使われる定数.
                                                             (line  107)
* GREATEREQUAL (token モジュール):       token --- Python 解析木で使われる定数.
                                                             (line  143)
* GRND_NONBLOCK (os モジュール):         乱数<2>.            (line   77)
* GRND_RANDOM (os モジュール):           乱数<2>.            (line   90)
* Group (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  450)
* group() (pathlib.Path のメソッド):     パーミッションと所有者.
                                                             (line   23)
* group() (re.Match のメソッド):         マッチオブジェクト. (line   35)
* groupby() (itertools モジュール):      Itertool関数.       (line  304)
* groupdict() (re.Match のメソッド):     マッチオブジェクト. (line  130)
* groupindex (re.Pattern の属性):        正規表現オブジェクト.
                                                             (line  115)
* groups (email.headerregistry.AddressHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  185)
* groups (re.Pattern の属性):            正規表現オブジェクト.
                                                             (line  111)
* groups() (re.Match のメソッド):        マッチオブジェクト. (line  108)
* GS (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  111)
* Gt (ast のクラス):                     式 expression<2>.   (line  110)
* gt() (operator モジュール):            operator --- 関数形式の標準演算子.
                                                             (line   23)
* GtE (ast のクラス):                    式 expression<2>.   (line  110)
* guard:                                 ガード.             (line    6)
* guess_all_extensions() (mimetypes モジュール): mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line   64)
* guess_all_extensions() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line   69)
* guess_extension() (mimetypes モジュール): mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line   76)
* guess_extension() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line   52)
* guess_file_type() (mimetypes モジュール): mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line   55)
* guess_file_type() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line   62)
* guess_scheme() (wsgiref.util モジュール): wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line   13)
* guess_type() (mimetypes モジュール):   mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line   24)
* guess_type() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line   57)
* GUI:                                   Tk を用いたグラフィカルユーザーインターフェース.
                                                             (line    6)
* gzip コマンドラインオプション; -best:  コマンドラインオプション.
                                                             (line   14)
* gzip コマンドラインオプション; -d:     コマンドラインオプション.
                                                             (line   18)
* gzip コマンドラインオプション; -decompress: コマンドラインオプション.
                                                             (line   18)
* gzip コマンドラインオプション; -fast:  コマンドラインオプション.
                                                             (line   10)
* gzip コマンドラインオプション; -h:     コマンドラインオプション.
                                                             (line   22)
* gzip コマンドラインオプション; -help:  コマンドラインオプション.
                                                             (line   22)
* gzip コマンドラインオプション; file:   コマンドラインオプション.
                                                             (line    6)
* GzipFile (gzip のクラス):              gzip --- gzip ファイルのサポート.
                                                             (line   71)
* halfdelay() (curses モジュール):       関数<6>.            (line  209)
* Handle (asyncio のクラス):             コールバックのハンドル.
                                                             (line    6)
* handle_charref() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   90)
* handle_comment() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   98)
* handle_data() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   77)
* handle_decl() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line  111)
* handle_defect() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  233)
* handle_endtag() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   62)
* handle_entityref() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   83)
* handle_error() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  133)
* handle_expect_100() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  207)
* handle_one_request() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  201)
* handle_pi() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line  119)
* handle_request() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line   21)
* handle_request() (xmlrpc.server.CGIXMLRPCRequestHandler のメソッド): CGIXMLRPCRequestHandler.
                                                             (line   49)
* handle_startendtag() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   69)
* handle_starttag() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   45)
* handle_timeout() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  143)
* handle() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  194)
* handle() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   83)
* handle() (logging.handlers.QueueListener のメソッド): QueueListener.
                                                             (line   67)
* handle() (logging.Logger のメソッド):  ロガーオブジェクト. (line  355)
* handle() (logging.NullHandler のメソッド): NullHandler.    (line   20)
* handle() (socketserver.BaseRequestHandler のメソッド): Request Handler Objects.
                                                             (line   19)
* handle() (wsgiref.simple_server.WSGIRequestHandler のメソッド): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line  102)
* handleError() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   89)
* handleError() (logging.handlers.SocketHandler のメソッド): SocketHandler.
                                                             (line   33)
* Handler (logging のクラス):            ハンドラオブジェクト.
                                                             (line   12)
* handlers (logging.Logger の属性):      ロガーオブジェクト. (line   85)
* Handlers (signal のクラス):            モジュールの内容<2>.
                                                             (line   24)
* hardlink_to() (pathlib.Path のメソッド): ファイルとディレクトリの作成.
                                                             (line   72)
* harmonic_mean() (statistics モジュール): 関数の詳細.       (line   93)
* HAS_ALPN (ssl モジュール):             定数<9>.            (line  384)
* has_children() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line   99)
* has_colors() (curses モジュール):      関数<6>.            (line  176)
* has_default() (typing.ParamSpec のメソッド): Building generic types and type aliases.
                                                             (line  434)
* has_default() (typing.TypeVar のメソッド): Building generic types and type aliases.
                                                             (line  201)
* has_default() (typing.TypeVarTuple のメソッド): Building generic types and type aliases.
                                                             (line  333)
* has_dualstack_ipv6() (socket モジュール): ソケットの作成.  (line  149)
* HAS_ECDH (ssl モジュール):             定数<9>.            (line  400)
* has_extended_color_support() (curses モジュール): 関数<6>. (line  181)
* has_extn() (smtplib.SMTP のメソッド):  SMTP オブジェクト.  (line   82)
* has_header() (csv.Sniffer のメソッド): モジュールコンテンツ<3>.
                                                             (line  236)
* has_header() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line   96)
* has_ic() (curses モジュール):          関数<6>.            (line  192)
* has_il() (curses モジュール):          関数<6>.            (line  198)
* has_ipv6 (socket モジュール):          定数<8>.            (line  293)
* has_key() (curses モジュール):         関数<6>.            (line  204)
* has_location (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  434)
* HAS_NEVER_CHECK_COMMON_NAME (ssl モジュール): 定数<9>.     (line  392)
* has_nonstandard_attr() (http.cookiejar.Cookie のメソッド): Cookieオブジェクト<2>.
                                                             (line   99)
* HAS_NPN (ssl モジュール):              定数<9>.            (line  415)
* has_option() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  139)
* has_option() (optparse.OptionParser のメソッド): オプション解析器への問い合わせと操作.
                                                             (line   44)
* HAS_PSK (ssl モジュール):              定数<9>.            (line  467)
* has_section() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  129)
* HAS_SNI (ssl モジュール):              定数<9>.            (line  408)
* HAS_SSLv2 (ssl モジュール):            定数<9>.            (line  425)
* HAS_SSLv3 (ssl モジュール):            定数<9>.            (line  432)
* has_ticket (ssl.SSLSession の属性):    SSL セッション.     (line   20)
* HAS_TLSv1 (ssl モジュール):            定数<9>.            (line  439)
* HAS_TLSv1_1 (ssl モジュール):          定数<9>.            (line  446)
* HAS_TLSv1_2 (ssl モジュール):          定数<9>.            (line  453)
* HAS_TLSv1_3 (ssl モジュール):          定数<9>.            (line  460)
* hasarg (dis モジュール):               命令コードコレクション.
                                                             (line   26)
* hasAttribute() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   22)
* hasAttributeNS() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   27)
* hasAttributes() (xml.dom.Node のメソッド): Node オブジェクト.
                                                             (line   92)
* hasChildNodes() (xml.dom.Node のメソッド): Node オブジェクト.
                                                             (line   96)
* hascompare (dis モジュール):           命令コードコレクション.
                                                             (line   59)
* hasconst (dis モジュール):             命令コードコレクション.
                                                             (line   32)
* hasexc (dis モジュール):               命令コードコレクション.
                                                             (line   63)
* hasFeature() (xml.dom.DOMImplementation のメソッド): DOMImplementation オブジェクト.
                                                             (line   12)
* hasfree (dis モジュール):              命令コードコレクション.
                                                             (line   36)
* hash_bits (sys.hash_info の属性):      sys --- システム固有のパラメーターと関数.
                                                             (line 1040)
* hash_info (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line 1009)
* hash_randomization (sys.flags の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  548)
* hash-based pyc:                        用語集<2>.          (line  675)
* hash.block_size (hashlib モジュール):  Hash Objects.       (line   13)
* hash.digest_size (hashlib モジュール): Hash Objects.       (line    9)
* hashable:                              辞書表示.           (line   35)
* hashable <1>:                          用語集<2>.          (line  682)
* Hashable (collections.abc のクラス):   コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   10)
* Hashable (typing のクラス):            Aliases to other ABCs in collections abc.
                                                             (line   54)
* hasHandlers() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  371)
* hashfunc (C type):                     Slot Type typedefs. (line   84)
* hasjabs (dis モジュール):              命令コードコレクション.
                                                             (line   76)
* hasjrel (dis モジュール):              命令コードコレクション.
                                                             (line   69)
* hasjump (dis モジュール):              命令コードコレクション.
                                                             (line   48)
* haslocal (dis モジュール):             命令コードコレクション.
                                                             (line   55)
* hasname (dis モジュール):              命令コードコレクション.
                                                             (line   44)
* HAVE_ARGUMENT (opcode):                Python バイトコード命令.
                                                             (line 1252)
* HAVE_CONTEXTVAR (decimal モジュール):  定数<4>.            (line   32)
* HAVE_DOCSTRINGS (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  166)
* HAVE_THREADS (decimal モジュール):     定数<4>.            (line   25)
* HCI_DATA_DIR (socket モジュール):      定数<8>.            (line  306)
* HCI_FILTER (socket モジュール):        定数<8>.            (line  306)
* HCI_TIME_STAMP (socket モジュール):    定数<8>.            (line  306)
* Header (email.header のクラス):        email header 国際化されたヘッダー.
                                                             (line   58)
* header_encode_lines() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line  130)
* header_encode() (email.charset.Charset のメソッド): email charset 文字集合の表現.
                                                             (line  123)
* header_encoding (email.charset.Charset の属性): email charset 文字集合の表現.
                                                             (line   60)
* header_factory (email.policy.EmailPolicy の属性): email policy Policy Objects.
                                                             (line  406)
* header_fetch_parse() (email.policy.Compat32 のメソッド): email policy Policy Objects.
                                                             (line  591)
* header_fetch_parse() (email.policy.EmailPolicy のメソッド): email policy Policy Objects.
                                                             (line  456)
* header_fetch_parse() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  317)
* header_items() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line  127)
* header_max_count() (email.policy.EmailPolicy のメソッド): email policy Policy Objects.
                                                             (line  433)
* header_max_count() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  258)
* header_offset (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line  132)
* header_source_parse() (email.policy.Compat32 のメソッド): email policy Policy Objects.
                                                             (line  579)
* header_source_parse() (email.policy.EmailPolicy のメソッド): email policy Policy Objects.
                                                             (line  439)
* header_source_parse() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  279)
* header_store_parse() (email.policy.Compat32 のメソッド): email policy Policy Objects.
                                                             (line  587)
* header_store_parse() (email.policy.EmailPolicy のメソッド): email policy Policy Objects.
                                                             (line  447)
* header_store_parse() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  301)
* HeaderDefect:                          email errors Exception and Defect classes.
                                                             (line   67)
* HeaderError:                           tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  232)
* HeaderParseError:                      email errors Exception and Defect classes.
                                                             (line   26)
* HeaderParser (email.parser のクラス):  Parser API.         (line  110)
* HeaderRegistry (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  293)
* headers (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   57)
* headers (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  111)
* headers (urllib.error.HTTPError の属性): urllib error --- urllib request によって送出される例外クラス.
                                                             (line   53)
* headers (urllib.response.addinfourl の属性): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   19)
* Headers (wsgiref.headers のクラス):    wsgiref headers -- WSGI レスポンスヘッダツール群.
                                                             (line    9)
* headers (xmlrpc.client.ProtocolError の属性): ProtocolError オブジェクト.
                                                             (line   24)
* HeaderWriteError:                      email errors Exception and Defect classes.
                                                             (line   57)
* heading() (tkinter.ttk.Treeview のメソッド): ttk Treeview. (line  100)
* heading() (turtle モジュール):         Turtle の状態を知る.
                                                             (line   56)
* heapify() (heapq モジュール):          heapq --- ヒープキューアルゴリズム.
                                                             (line   55)
* heapmin() (msvcrt モジュール):         その多の関数.       (line    6)
* heappop() (heapq モジュール):          heapq --- ヒープキューアルゴリズム.
                                                             (line   42)
* heappush() (heapq モジュール):         heapq --- ヒープキューアルゴリズム.
                                                             (line   38)
* heappushpop() (heapq モジュール):      heapq --- ヒープキューアルゴリズム.
                                                             (line   49)
* heapreplace() (heapq モジュール):      heapq --- ヒープキューアルゴリズム.
                                                             (line   59)
* helo() (smtplib.SMTP のメソッド):      SMTP オブジェクト.  (line   47)
* help (optparse.Option の属性):         オプション属性.     (line   81)
* help (pdb command):                    デバッガコマンド.   (line   70)
* help;online:                           pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line    8)
* herror:                                例外<14>.           (line   13)
* hex (uuid.UUID の属性):                uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  127)
* hex() (bytearray のメソッド):          bytearray オブジェクト.
                                                             (line   52)
* hex() (bytes のメソッド):              バイトオブジェクト. (line   78)
* hex() (float のメソッド):              浮動小数点数に対する追加のメソッド.
                                                             (line   33)
* hex() (memoryview のメソッド):         メモリビュー.       (line  185)
* hexdigest() (hashlib.hash のメソッド): Hash Objects.       (line   43)
* hexdigest() (hashlib.shake のメソッド): SHAKE 可変長ダイジェスト.
                                                             (line   21)
* hexdigest() (hmac.HMAC のメソッド):    hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   70)
* hexdigits (string モジュール):         文字列定数.         (line   27)
* hexlify() (binascii モジュール):       binascii --- バイナリ と ASCII 間の変換.
                                                             (line  115)
* hexversion (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1052)
* hidden() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   25)
* hide_cookie2 (http.cookiejar.CookiePolicy の属性): CookiePolicy オブジェクト.
                                                             (line   79)
* hide() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   30)
* hide() (tkinter.ttk.Notebook のメソッド): ttk Notebook.    (line   23)
* hideturtle() (turtle モジュール):      可視性.             (line    6)
* HierarchyRequestErr:                   例外<19>.           (line   28)
* HIGH_PRIORITY_CLASS (subprocess モジュール): Windows Constants.
                                                             (line   82)
* HIGHEST_PROTOCOL (pickle モジュール):  モジュールインターフェース.
                                                             (line   14)
* hits (bdb.Breakpoint の属性):          bdb --- デバッガーフレームワーク.
                                                             (line  125)
* HKEY_CLASSES_ROOT (winreg モジュール): HKEY_* 定数.        (line    6)
* HKEY_CURRENT_CONFIG (winreg モジュール): HKEY_* 定数.      (line   37)
* HKEY_CURRENT_USER (winreg モジュール): HKEY_* 定数.        (line   12)
* HKEY_DYN_DATA (winreg モジュール):     HKEY_* 定数.        (line   42)
* HKEY_LOCAL_MACHINE (winreg モジュール): HKEY_* 定数.       (line   19)
* HKEY_PERFORMANCE_DATA (winreg モジュール): HKEY_* 定数.    (line   31)
* HKEY_USERS (winreg モジュール):        HKEY_* 定数.        (line   25)
* hline() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  274)
* hls_to_rgb() (colorsys モジュール):    colorsys --- 色体系間の変換.
                                                             (line   40)
* HOME:                                  os path<4>.         (line   15)
* HOME <1>:                              Python API の変更<3>.
                                                             (line  117)
* HOME <2>:                              Windows<38>.        (line   15)
* HOME <3>:                              Windows<38>.        (line   18)
* HOME <4>:                              os path --- 一般的なパス名操作.
                                                             (line  140)
* HOME <5>:                              os path --- 一般的なパス名操作.
                                                             (line  158)
* HOME <6>:                              Tkinter モジュール. (line   66)
* home() (pathlib.Path のクラスメソッド): パスの展開と解決.  (line    6)
* home() (turtle モジュール):            Turtle の動き.      (line  193)
* HOMEDRIVE:                             os path --- 一般的なパス名操作.
                                                             (line  147)
* HOMEPATH:                              os path --- 一般的なパス名操作.
                                                             (line  147)
* hook_compressed() (fileinput モジュール): fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  194)
* hook_encoded() (fileinput モジュール): fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  214)
* hooks;import:                          インポートフック.   (line    6)
* hooks;meta:                            インポートフック.   (line    6)
* hooks;パス:                            インポートフック.   (line    6)
* host (urllib.request.Request の属性):  Request オブジェクト.
                                                             (line   25)
* hostmask (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   94)
* hostmask (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  313)
* hostname_checks_common_name (ssl.SSLContext の属性): SSL コンテキスト.
                                                             (line  612)
* hosts (netrc.netrc の属性):            netrc オブジェクト. (line   25)
* hosts() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  135)
* hosts() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  331)
* hour (datetime.datetime の属性):       datetime オブジェクト.
                                                             (line  315)
* hour (datetime.time の属性):           time オブジェクト.  (line   50)
* HRESULT (ctypes のクラス):             基本データ型<2>.    (line  212)
* hStdError (subprocess.STARTUPINFO の属性): Windows Popen ヘルパー.
                                                             (line   42)
* hStdInput (subprocess.STARTUPINFO の属性): Windows Popen ヘルパー.
                                                             (line   28)
* hStdOutput (subprocess.STARTUPINFO の属性): Windows Popen ヘルパー.
                                                             (line   35)
* hsv_to_rgb() (colorsys モジュール):    colorsys --- 色体系間の変換.
                                                             (line   48)
* HT (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   48)
* ht() (turtle モジュール):              可視性.             (line    6)
* HTML:                                  html parser --- HTML と XHTML のシンプルなパーサー.
                                                             (line    8)
* HTML <1>:                              urllib request の制限事項.
                                                             (line   29)
* html5 (html.entities モジュール):      html entities --- HTML 一般実体の定義.
                                                             (line   14)
* HTMLCalendar (calendar のクラス):      calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  154)
* HtmlDiff (difflib のクラス):           difflib --- 差分の計算の補助.
                                                             (line   80)
* HTMLParser (html.parser のクラス):     html parser --- HTML と XHTML のシンプルなパーサー.
                                                             (line   14)
* htonl() (socket モジュール):           その他の関数<2>.    (line  243)
* htons() (socket モジュール):           その他の関数<2>.    (line  250)
* HTTP (email.policy モジュール):        email policy Policy Objects.
                                                             (line  523)
* http_error_301() (urllib.request.HTTPRedirectHandler のメソッド): HTTPRedirectHandler オブジェクト.
                                                             (line   35)
* http_error_302() (urllib.request.HTTPRedirectHandler のメソッド): HTTPRedirectHandler オブジェクト.
                                                             (line   42)
* http_error_303() (urllib.request.HTTPRedirectHandler のメソッド): HTTPRedirectHandler オブジェクト.
                                                             (line   48)
* http_error_307() (urllib.request.HTTPRedirectHandler のメソッド): HTTPRedirectHandler オブジェクト.
                                                             (line   54)
* http_error_308() (urllib.request.HTTPRedirectHandler のメソッド): HTTPRedirectHandler オブジェクト.
                                                             (line   61)
* http_error_401() (urllib.request.HTTPBasicAuthHandler のメソッド): HTTPBasicAuthHandler オブジェクト.
                                                             (line    6)
* http_error_401() (urllib.request.HTTPDigestAuthHandler のメソッド): HTTPDigestAuthHandler オブジェクト.
                                                             (line    6)
* http_error_407() (urllib.request.ProxyBasicAuthHandler のメソッド): ProxyBasicAuthHandler オブジェクト.
                                                             (line    6)
* http_error_407() (urllib.request.ProxyDigestAuthHandler のメソッド): ProxyDigestAuthHandler オブジェクト.
                                                             (line    6)
* http_error_auth_reqed() (urllib.request.AbstractBasicAuthHandler のメソッド): AbstractBasicAuthHandler オブジェクト.
                                                             (line    6)
* http_error_auth_reqed() (urllib.request.AbstractDigestAuthHandler のメソッド): AbstractDigestAuthHandler オブジェクト.
                                                             (line    6)
* http_error_default() (urllib.request.BaseHandler のメソッド): BaseHandler オブジェクト.
                                                             (line   67)
* http_open() (urllib.request.HTTPHandler のメソッド): HTTPHandler オブジェクト.
                                                             (line    6)
* HTTP_PORT (http.client モジュール):    http client --- HTTP プロトコルクライアント.
                                                             (line  206)
* http_response() (urllib.request.HTTPErrorProcessor のメソッド): HTTPErrorProcessor オブジェクト.
                                                             (line    6)
* http_version (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  297)
* HTTP;http (標準モジュール):            http --- HTTP モジュール群.
                                                             (line    8)
* HTTP;http.client (標準モジュール):     http client --- HTTP プロトコルクライアント.
                                                             (line    8)
* HTTP;プロトコル:                       urllib request の制限事項.
                                                             (line    6)
* HTTP;プロトコル <1>:                   urllib request の制限事項.
                                                             (line   29)
* HTTP;プロトコル <2>:                   http --- HTTP モジュール群.
                                                             (line    8)
* HTTP;プロトコル <3>:                   http client --- HTTP プロトコルクライアント.
                                                             (line    8)
* HTTP;プロトコル <4>:                   http server --- HTTP サーバー.
                                                             (line    8)
* http.server;セキュリティ:              セキュリティで考慮すべき点<5>.
                                                             (line    6)
* HTTPBasicAuthHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  356)
* HTTPConnection (http.client のクラス): http client --- HTTP プロトコルクライアント.
                                                             (line   32)
* HTTPCookieProcessor (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  289)
* httpd:                                 http server --- HTTP サーバー.
                                                             (line    8)
* HTTPDefaultErrorHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  280)
* HTTPDigestAuthHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  382)
* HTTPError:                             urllib error --- urllib request によって送出される例外クラス.
                                                             (line   30)
* HTTPErrorProcessor (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  441)
* HTTPException:                         http client --- HTTP プロトコルクライアント.
                                                             (line  136)
* HTTPHandler (logging.handlers のクラス): HTTPHandler.      (line   10)
* HTTPHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  405)
* HTTPMessage (http.client のクラス):    HTTPMessage オブジェクト.
                                                             (line    6)
* HTTPMethod (http のクラス):            HTTP ステータスコードカテゴリ.
                                                             (line   38)
* httponly (http.cookies.Morsel の属性): Morselオブジェクト. (line   13)
* HTTPPasswordMgr (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  315)
* HTTPPasswordMgrWithDefaultRealm (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  320)
* HTTPPasswordMgrWithPriorAuth (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  326)
* HTTPRedirectHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  285)
* HTTPResponse (http.client のクラス):   http client --- HTTP プロトコルクライアント.
                                                             (line  103)
* https_open() (urllib.request.HTTPSHandler のメソッド): HTTPSHandler オブジェクト.
                                                             (line    6)
* HTTPS_PORT (http.client モジュール):   http client --- HTTP プロトコルクライアント.
                                                             (line  210)
* https_response() (urllib.request.HTTPErrorProcessor のメソッド): HTTPErrorProcessor オブジェクト.
                                                             (line   18)
* HTTPSConnection (http.client のクラス): http client --- HTTP プロトコルクライアント.
                                                             (line   64)
* HTTPServer (http.server のクラス):     http server --- HTTP サーバー.
                                                             (line   30)
* HTTPSHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  409)
* HTTPStatus (http のクラス):            http --- HTTP モジュール群.
                                                             (line   28)
* HV_GUID_BROADCAST (socket モジュール): 定数<8>.            (line  345)
* HV_GUID_CHILDREN (socket モジュール):  定数<8>.            (line  345)
* HV_GUID_LOOPBACK (socket モジュール):  定数<8>.            (line  345)
* HV_GUID_PARENT (socket モジュール):    定数<8>.            (line  345)
* HV_GUID_WILDCARD (socket モジュール):  定数<8>.            (line  345)
* HV_GUID_ZERO (socket モジュール):      定数<8>.            (line  345)
* HV_PROTOCOL_RAW (socket モジュール):   定数<8>.            (line  345)
* HVSOCKET_ADDRESS_FLAG_PASSTHRU (socket モジュール): 定数<8>.
                                                             (line  345)
* HVSOCKET_CONNECT_TIMEOUT (socket モジュール): 定数<8>.     (line  345)
* HVSOCKET_CONNECT_TIMEOUT_MAX (socket モジュール): 定数<8>. (line  345)
* HVSOCKET_CONNECTED_SUSPEND (socket モジュール): 定数<8>.   (line  345)
* hypot() (math モジュール):             三角関数.           (line   45)
* I (re モジュール):                     フラグ.             (line   37)
* I/O control;buffering:                 組み込み関数.       (line 1455)
* I/O control;buffering <1>:             socket オブジェクト.
                                                             (line  215)
* iadd() (operator モジュール):          インプレース in-place 演算子.
                                                             (line   34)
* iand() (operator モジュール):          インプレース in-place 演算子.
                                                             (line   39)
* iconcat() (operator モジュール):       インプレース in-place 演算子.
                                                             (line   44)
* id (ssl.SSLSession の属性):            SSL セッション.     (line   12)
* id() (unittest.TestCase のメソッド):   テストクラス.       (line  752)
* idcok() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  281)
* ident (select.kevent の属性):          kevent オブジェクト.
                                                             (line    8)
* ident (threading.Thread の属性):       Thread オブジェクト.
                                                             (line  173)
* identchars (cmd.Cmd の属性):           Cmdオブジェクト.    (line  132)
* identify_column() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  146)
* identify_element() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  175)
* identify_region() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  153)
* identify_row() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  142)
* identify() (tkinter.ttk.Notebook のメソッド): ttk Notebook.
                                                             (line   31)
* identify() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  132)
* identify() (tkinter.ttk.Widget のメソッド): ttk Widget.    (line   12)
* IDLE:                                  IDLE<64>.           (line    8)
* IDLE <1>:                              用語集<2>.          (line  701)
* IDLE_PRIORITY_CLASS (subprocess モジュール): Windows Constants.
                                                             (line   89)
* IDLESTARTUP:                           IDLE<37>.           (line  176)
* IDLESTARTUP <1>:                       IDLE<41>.           (line    9)
* IDLESTARTUP <2>:                       IDLE<47>.           (line    9)
* IDLESTARTUP <3>:                       Startup and Code Execution.
                                                             (line    6)
* idlok() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  288)
* If (ast のクラス):                     制御フロー.         (line    9)
* if_indextoname() (socket モジュール):  その他の関数<2>.    (line  442)
* if_nameindex() (socket モジュール):    その他の関数<2>.    (line  398)
* if_nametoindex() (socket モジュール):  その他の関数<2>.    (line  424)
* if;conditional expression:             条件式 Conditional Expressions.
                                                             (line    6)
* if;in comprehensions:                  リスト、集合、辞書の表示.
                                                             (line   14)
* IfExp (ast のクラス):                  式 expression<2>.   (line  159)
* ifloordiv() (operator モジュール):     インプレース in-place 演算子.
                                                             (line   50)
* iglob() (glob モジュール):             glob --- Unix 形式のパス名のパターン展開.
                                                             (line   81)
* ignorableWhitespace() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line  141)
* ignore (bdb.Breakpoint の属性):        bdb --- デバッガーフレームワーク.
                                                             (line  121)
* ignore (pdb command):                  デバッガコマンド.   (line  143)
* IGNORE (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  151)
* ignore_environment (sys.flags の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  536)
* ignore_errors() (codecs モジュール):   エラーハンドラ.     (line  140)
* IGNORE_EXCEPTION_DETAIL (doctest モジュール): オプションフラグ.
                                                             (line   57)
* ignore_patterns() (shutil モジュール): ディレクトリとファイルの操作.
                                                             (line  189)
* ignore_warnings() (test.support.warnings_helper モジュール): test support warnings_helper --- Utilities for warnings tests.
                                                             (line   11)
* ignore;error handler's name:           エラーハンドラ.     (line   14)
* IGNORECASE (re モジュール):            フラグ.             (line   37)
* IISCGIHandler (wsgiref.handlers のクラス): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line   25)
* IllegalMonthError:                     calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  452)
* IllegalWeekdayError:                   calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  461)
* ilshift() (operator モジュール):       インプレース in-place 演算子.
                                                             (line   55)
* imag (numbers.Complex の属性):         数値塔.             (line   19)
* imag (sys.hash_info の属性):           sys --- システム固有のパラメーターと関数.
                                                             (line 1031)
* imap_unordered() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  147)
* imap() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  132)
* IMAP4 (imaplib のクラス):              imaplib --- IMAP4 プロトコルクライアント.
                                                             (line   25)
* IMAP4_SSL (imaplib のクラス):          imaplib --- IMAP4 プロトコルクライアント.
                                                             (line   76)
* IMAP4_SSL;プロトコル:                  imaplib --- IMAP4 プロトコルクライアント.
                                                             (line    8)
* IMAP4_stream (imaplib のクラス):       imaplib --- IMAP4 プロトコルクライアント.
                                                             (line  109)
* IMAP4_stream;プロトコル:               imaplib --- IMAP4 プロトコルクライアント.
                                                             (line    8)
* IMAP4;プロトコル:                      imaplib --- IMAP4 プロトコルクライアント.
                                                             (line    8)
* IMAP4.abort:                           imaplib --- IMAP4 プロトコルクライアント.
                                                             (line   58)
* IMAP4.error:                           imaplib --- IMAP4 プロトコルクライアント.
                                                             (line   53)
* IMAP4.readonly:                        imaplib --- IMAP4 プロトコルクライアント.
                                                             (line   65)
* imatmul() (operator モジュール):       インプレース in-place 演算子.
                                                             (line   70)
* immedok() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  293)
* immutable:                             用語集<2>.          (line  718)
* immutable;object:                      リテラル<2>.        (line   18)
* immutable;object <1>:                  辞書表示.           (line   35)
* immutable;sequence;types:              イミュータブルなシーケンス型.
                                                             (line    6)
* immutable;データ;type:                 リテラル<2>.        (line   18)
* imod() (operator モジュール):          インプレース in-place 演算子.
                                                             (line   60)
* impl_detail() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  535)
* implementation (sys モジュール):       sys --- システム固有のパラメーターと関数.
                                                             (line 1074)
* Import (ast のクラス):                 インポート.         (line    6)
* import hooks:                          インポートフック.   (line    6)
* import machinery:                      インポートシステム. (line    6)
* import path:                           用語集<2>.          (line  727)
* import_fresh_module() (test.support.import_helper モジュール): test support import_helper --- Utilities for import tests.
                                                             (line   16)
* IMPORT_FROM (opcode):                  Python バイトコード命令.
                                                             (line  822)
* import_module() (importlib モジュール): 関数<12>.          (line   14)
* import_module() (test.support.import_helper モジュール): test support import_helper --- Utilities for import tests.
                                                             (line   52)
* IMPORT_NAME (opcode):                  Python バイトコード命令.
                                                             (line  813)
* importer:                              用語集<2>.          (line  739)
* ImportError:                           具象例外.           (line   43)
* ImportFrom (ast のクラス):             インポート.         (line   20)
* importing:                             用語集<2>.          (line  734)
* ImportWarning:                         警告.               (line   55)
* ImproperConnectionState:               http client --- HTTP プロトコルクライアント.
                                                             (line  167)
* imul() (operator モジュール):          インプレース in-place 演算子.
                                                             (line   65)
* In (ast のクラス):                     式 expression<2>.   (line  110)
* in_dll() (ctypes._CData のメソッド):   データ型<3>.        (line   65)
* in_table_a1() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   40)
* in_table_b1() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   45)
* in_table_c11_c12() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   69)
* in_table_c11() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   60)
* in_table_c12() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   64)
* in_table_c21_c22() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   82)
* in_table_c21() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   74)
* in_table_c22() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   78)
* in_table_c3() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   87)
* in_table_c4() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   91)
* in_table_c5() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   96)
* in_table_c6() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line  100)
* in_table_c7() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line  105)
* in_table_c8() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line  110)
* in_table_c9() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line  115)
* in_table_d1() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line  119)
* in_table_d2() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line  124)
* in_transaction (sqlite3.Connection の属性): Connection オブジェクト.
                                                             (line  781)
* inch() (curses.window のメソッド):     Window オブジェクト.
                                                             (line  301)
* include() (xml.etree.ElementInclude モジュール): 関数<10>. (line   17)
* inclusive (tracemalloc.DomainFilter の属性): DomainFilter. (line   12)
* inclusive (tracemalloc.Filter の属性): Filter.             (line   39)
* Incomplete:                            binascii --- バイナリ と ASCII 間の変換.
                                                             (line  161)
* IncompleteRead:                        http client --- HTTP プロトコルクライアント.
                                                             (line  163)
* IncompleteReadError:                   例外<12>.           (line   45)
* incr_item():                           例外<21>.           (line   78)
* incr_item() <1>:                       例外<21>.           (line  123)
* increment_lineno() (ast モジュール):   ast ヘルパー.       (line  156)
* IncrementalDecoder (codecs のクラス):  IncrementalDecoder オブジェクト.
                                                             (line   11)
* incrementaldecoder (codecs.CodecInfo の属性): codecs --- codec レジストリと基底クラス.
                                                             (line   80)
* IncrementalEncoder (codecs のクラス):  IncrementalEncoder オブジェクト.
                                                             (line   11)
* incrementalencoder (codecs.CodecInfo の属性): codecs --- codec レジストリと基底クラス.
                                                             (line   80)
* IncrementalNewlineDecoder (io のクラス): テキスト I/O<2>.  (line  281)
* IncrementalParser (xml.sax.xmlreader のクラス): xml sax xmlreader --- XML パーサーのインターフェース.
                                                             (line   19)
* indent (doctest.Example の属性):       Example オブジェクト.
                                                             (line   44)
* indent (reprlib.Repr の属性):          Reprオブジェクト.   (line   52)
* INDENT (token モジュール):             token --- Python 解析木で使われる定数.
                                                             (line   47)
* INDENT トークン:                       インデント.         (line   31)
* indent() (textwrap モジュール):        textwrap --- テキストの折り返しと詰め込み.
                                                             (line  102)
* indent() (xml.etree.ElementTree モジュール): 関数<9>.      (line  116)
* IndentationError:                      具象例外.           (line  332)
* index (inspect.FrameInfo の属性):      インタープリタスタック.
                                                             (line   37)
* index (inspect.Traceback の属性):      インタープリタスタック.
                                                             (line   77)
* index() (array.array のメソッド):      array --- 効率的な数値配列.
                                                             (line  198)
* index() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  156)
* index() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  156)
* index() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   70)
* index() (multiprocessing.shared_memory.ShareableList のメソッド): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  335)
* index() (operator モジュール):         operator --- 関数形式の標準演算子.
                                                             (line   90)
* index() (str のメソッド):              文字列メソッド<2>.  (line  169)
* index() (tkinter.ttk.Notebook のメソッド): ttk Notebook.   (line   36)
* index() (tkinter.ttk.Treeview のメソッド): ttk Treeview.   (line  181)
* index() (シーケンスのメソッド):        共通のシーケンス演算.
                                                             (line   18)
* IndexError:                            具象例外.           (line   71)
* indexOf() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  196)
* IndexSizeErr:                          例外<19>.           (line   32)
* indices() (slice のメソッド):          スライス slice オブジェクト.
                                                             (line   16)
* INDIRECT (inspect.BufferFlags の属性): Buffer flags.       (line   31)
* inet_aton() (socket モジュール):       その他の関数<2>.    (line  260)
* inet_ntoa() (socket モジュール):       その他の関数<2>.    (line  278)
* inet_ntop() (socket モジュール):       その他の関数<2>.    (line  311)
* inet_pton() (socket モジュール):       その他の関数<2>.    (line  295)
* Inexact (decimal のクラス):            シグナル.           (line   42)
* inf (cmath モジュール):                定数<3>.            (line   20)
* inf (math モジュール):                 定数<2>.            (line   23)
* inf (sys.hash_info の属性):            sys --- システム固有のパラメーターと関数.
                                                             (line 1023)
* infile (shlex.shlex の属性):           shlex オブジェクト. (line  139)
* Infinity:                              組み込み関数.       (line  709)
* infj (cmath モジュール):               定数<3>.            (line   26)
* INFO (logging モジュール):             ロギングレベル.     (line   29)
* INFO (tkinter.messagebox モジュール):  tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  194)
* info() (dis.Bytecode のメソッド):      バイトコード解析.   (line   62)
* info() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   68)
* info() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   85)
* info() (logging モジュール):           モジュールレベルの関数.
                                                             (line   63)
* info() (logging.Logger のメソッド):    ロガーオブジェクト. (line  278)
* info() (urllib.response.addinfourl のメソッド): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   35)
* infolist() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  124)
* inheritance:                           クラス定義.         (line    6)
* ini ファイル:                          configparser --- 設定ファイルのパーサー.
                                                             (line    8)
* init_color() (curses モジュール):      関数<6>.            (line  217)
* init_pair() (curses モジュール):       関数<6>.            (line  227)
* init() (mimetypes モジュール):         mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line   92)
* inited (mimetypes モジュール):         mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  131)
* initgroups() (os モジュール):          プロセスのパラメーター.
                                                             (line  336)
* initial_indent (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  206)
* initproc (C type):                     Slot Type typedefs. (line   37)
* initscr() (curses モジュール):         関数<6>.            (line  238)
* inode() (os.DirEntry のメソッド):      ファイルとディレクトリ.
                                                             (line  983)
* input_charset (email.charset.Charset の属性): email charset 文字集合の表現.
                                                             (line   53)
* input_codec (email.charset.Charset の属性): email charset 文字集合の表現.
                                                             (line   84)
* input() (fileinput モジュール):        fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line   56)
* InputSource (xml.sax.xmlreader のクラス): xml sax xmlreader --- XML パーサーのインターフェース.
                                                             (line   49)
* InputStream (wsgiref.types のクラス):  wsgiref types -- WSGI types for static type checking.
                                                             (line   24)
* inquiry (C type):                      循環参照ガベージコレクションをサポートする.
                                                             (line  200)
* insch() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  306)
* insdelln() (curses.window のメソッド): Window オブジェクト.
                                                             (line  313)
* insert_text() (readline モジュール):   行バッファ.         (line   13)
* insert() (array.array のメソッド):     array --- 効率的な数値配列.
                                                             (line  209)
* insert() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   78)
* insert() (tkinter.ttk.Notebook のメソッド): ttk Notebook.  (line   41)
* insert() (tkinter.ttk.Treeview のメソッド): ttk Treeview.  (line  185)
* insert() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  126)
* insert() (シーケンスのメソッド):       ミュータブルなシーケンス型.
                                                             (line   16)
* insertBefore() (xml.dom.Node のメソッド): Node オブジェクト.
                                                             (line  120)
* insertln() (curses.window のメソッド): Window オブジェクト.
                                                             (line  321)
* insnstr() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  326)
* insort_left() (bisect モジュール):     bisect --- 配列二分法アルゴリズム.
                                                             (line   62)
* insort_right() (bisect モジュール):    bisect --- 配列二分法アルゴリズム.
                                                             (line   79)
* insort() (bisect モジュール):          bisect --- 配列二分法アルゴリズム.
                                                             (line   79)
* inspect (sys.flags の属性):            sys --- システム固有のパラメーターと関数.
                                                             (line  515)
* inspect コマンドラインオプション; -details: コマンドラインインターフェイス<9>.
                                                             (line   13)
* InspectLoader (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  199)
* insstr() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  336)
* install_opener() (urllib.request モジュール): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  113)
* install_scripts() (venv.EnvBuilder のメソッド): API<2>.    (line  178)
* install() (gettext モジュール):        クラス形式の API.   (line   68)
* install() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   77)
* installHandler() (unittest モジュール): シグナルハンドリング.
                                                             (line   28)
* instance;call:                         呼び出し call.      (line  155)
* instate() (tkinter.ttk.Widget のメソッド): ttk Widget.     (line   19)
* instr() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  345)
* instream (shlex.shlex の属性):         shlex オブジェクト. (line  145)
* Instruction (dis のクラス):            Python バイトコード命令.
                                                             (line   10)
* INSTRUCTION (monitoring event):        Events.             (line   30)
* Instruction.arg (dis モジュール):      Python バイトコード命令.
                                                             (line   33)
* Instruction.argrepr (dis モジュール):  Python バイトコード命令.
                                                             (line   45)
* Instruction.argval (dis モジュール):   Python バイトコード命令.
                                                             (line   41)
* Instruction.baseopcode (dis モジュール): Python バイトコード命令.
                                                             (line   23)
* Instruction.baseopname (dis モジュール): Python バイトコード命令.
                                                             (line   28)
* Instruction.cache_offset (dis モジュール): Python バイトコード命令.
                                                             (line   60)
* Instruction.end_offset (dis モジュール): Python バイトコード命令.
                                                             (line   64)
* Instruction.is_jump_target (dis モジュール): Python バイトコード命令.
                                                             (line   77)
* Instruction.jump_target (dis モジュール): Python バイトコード命令.
                                                             (line   82)
* Instruction.line_number (dis モジュール): Python バイトコード命令.
                                                             (line   72)
* Instruction.offset (dis モジュール):   Python バイトコード命令.
                                                             (line   50)
* Instruction.oparg (dis モジュール):    Python バイトコード命令.
                                                             (line   37)
* Instruction.opcode (dis モジュール):   Python バイトコード命令.
                                                             (line   14)
* Instruction.opname (dis モジュール):   Python バイトコード命令.
                                                             (line   19)
* Instruction.positions (dis モジュール): Python バイトコード命令.
                                                             (line   87)
* Instruction.start_offset (dis モジュール): Python バイトコード命令.
                                                             (line   54)
* Instruction.starts_line (dis モジュール): Python バイトコード命令.
                                                             (line   68)
* int (uuid.UUID の属性):                uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  131)
* int (組み込みクラス):                  組み込み関数.       (line  932)
* int_info (sys モジュール):             sys --- システム固有のパラメーターと関数.
                                                             (line 1114)
* int_max_str_digits (sys.flags の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  561)
* Int2AP() (imaplib モジュール):         imaplib --- IMAP4 プロトコルクライアント.
                                                             (line  123)
* Integral (numbers のクラス):           数値塔.             (line   59)
* Integrated Development Environment:    IDLE<64>.           (line    8)
* IntegrityError:                        例外<7>.            (line   62)
* IntEnum (enum のクラス):               データ型<2>.        (line  347)
* interact (pdb command):                デバッガコマンド.   (line  348)
* interact() (code モジュール):          code --- インタープリター基底クラス.
                                                             (line   37)
* interact() (code.InteractiveConsole のメソッド): 対話的なコンソールオブジェクト.
                                                             (line   10)
* interactive:                           用語集<2>.          (line  744)
* Interactive (ast のクラス):            Root nodes.         (line   37)
* interactive (sys.flags の属性):        sys --- システム固有のパラメーターと関数.
                                                             (line  518)
* InteractiveConsole (code のクラス):    code --- インタープリター基底クラス.
                                                             (line   25)
* InteractiveInterpreter (code のクラス): code --- インタープリター基底クラス.
                                                             (line   15)
* InterfaceError:                        例外<7>.            (line   36)
* intern() (sys モジュール):             sys --- システム固有のパラメーターと関数.
                                                             (line 1159)
* internal_attr (zipfile.ZipInfo の属性): ZipInfo オブジェクト.
                                                             (line  124)
* Internaldate2tuple() (imaplib モジュール): imaplib --- IMAP4 プロトコルクライアント.
                                                             (line  117)
* InternalError:                         例外<7>.            (line   68)
* internalSubset (xml.dom.DocumentType の属性): DocumentType オブジェクト.
                                                             (line   27)
* Internet:                              インターネットプロトコルとサポート.
                                                             (line    6)
* INTERNET_TIMEOUT (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line   65)
* interpolated string literal:           出力を見やすくフォーマットする.
                                                             (line   88)
* interpolated string literal <1>:       文字列リテラルの結合 concatenation.
                                                             (line   24)
* InterpolationDepthError:               例外<8>.            (line   40)
* InterpolationError:                    例外<8>.            (line   36)
* InterpolationMissingOptionError:       例外<8>.            (line   46)
* InterpolationSyntaxError:              例外<8>.            (line   51)
* interpreted:                           用語集<2>.          (line  754)
* interpreter lock:                      スレッド状態 thread state とグローバルインタプリタロック global interpreter lock.
                                                             (line    6)
* interpreter prompts:                   sys --- システム固有のパラメーターと関数.
                                                             (line 1452)
* interpreter shutdown:                  用語集<2>.          (line  764)
* interpreter_requires_environment() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line    9)
* interrupt_main() (_thread モジュール): _thread --- 低水準なスレッド API.
                                                             (line   54)
* interrupt() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  347)
* InterruptedError:                      OS 例外.            (line   73)
* intersection_update() (frozenset のメソッド): set（集合）型 --- set frozenset.
                                                             (line  173)
* intersection() (frozenset のメソッド): set（集合）型 --- set frozenset.
                                                             (line  101)
* IntFlag (enum のクラス):               データ型<2>.        (line  514)
* intro (cmd.Cmd の属性):                Cmdオブジェクト.    (line  147)
* InuseAttributeErr:                     例外<19>.           (line   37)
* inv_cdf() (statistics.NormalDist のメソッド): NormalDist オブジェクト.
                                                             (line   92)
* inv() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line   98)
* InvalidAccessErr:                      例外<19>.           (line   42)
* invalidate_caches() (importlib モジュール): 関数<12>.      (line   38)
* invalidate_caches() (importlib.abc.MetaPathFinder のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   48)
* invalidate_caches() (importlib.abc.PathEntryFinder のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   83)
* invalidate_caches() (importlib.machinery.FileFinder のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  189)
* invalidate_caches() (importlib.machinery.PathFinder のクラスメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  140)
* invalidate_caches() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   89)
* InvalidCharacterErr:                   例外<19>.           (line   47)
* InvalidModificationErr:                例外<19>.           (line   54)
* InvalidOperation (decimal のクラス):   シグナル.           (line   50)
* InvalidStateErr:                       例外<19>.           (line   58)
* InvalidStateError:                     例外クラス.         (line   26)
* InvalidStateError <1>:                 例外<12>.           (line   30)
* InvalidTZPathWarning:                  例外と警告.         (line   12)
* InvalidURL:                            http client --- HTTP プロトコルクライアント.
                                                             (line  145)
* Invert (ast のクラス):                 式 expression<2>.   (line   28)
* invert() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   98)
* IO (typing のクラス):                  ABCs for working with IO.
                                                             (line    6)
* IO_REPARSE_TAG_APPEXECLINK (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  483)
* IO_REPARSE_TAG_MOUNT_POINT (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  483)
* IO_REPARSE_TAG_SYMLINK (stat モジュール): stat --- stat の結果を解釈する.
                                                             (line  483)
* IOBase (io のクラス):                  I/O 基底クラス.     (line    6)
* IOCTL_VM_SOCKETS_GET_LOCAL_CID (socket モジュール): 定数<8>.
                                                             (line  274)
* ioctl() (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line   91)
* ioctl() (socket.socket のメソッド):    socket オブジェクト.
                                                             (line  182)
* IOError:                               具象例外.           (line  465)
* ior() (operator モジュール):           インプレース in-place 演算子.
                                                             (line   77)
* ios_ver() (platform モジュール):       iOS プラットフォーム.
                                                             (line    6)
* ip (ipaddress.IPv4Interface の属性):   インターフェイスオブジェクト.
                                                             (line   19)
* ip (ipaddress.IPv6Interface の属性):   インターフェイスオブジェクト.
                                                             (line   74)
* ip_address() (ipaddress モジュール):   便利なファクトリ関数.
                                                             (line    9)
* ip_interface() (ipaddress モジュール): 便利なファクトリ関数.
                                                             (line   37)
* ip_network() (ipaddress モジュール):   便利なファクトリ関数.
                                                             (line   22)
* ipow() (operator モジュール):          インプレース in-place 演算子.
                                                             (line   82)
* ipv4_mapped (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  284)
* IPv4Address (ipaddress のクラス):      Address オブジェクト.
                                                             (line   12)
* IPv4Interface (ipaddress のクラス):    インターフェイスオブジェクト.
                                                             (line    9)
* IPv4Network (ipaddress のクラス):      Network オブジェクト.
                                                             (line   13)
* IPV6_ENABLED (test.support.socket_helper モジュール): test support socket_helper --- Utilities for socket tests.
                                                             (line   11)
* ipv6_mapped (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line  174)
* IPv6Address (ipaddress のクラス):      Address オブジェクト.
                                                             (line  206)
* IPv6Interface (ipaddress のクラス):    インターフェイスオブジェクト.
                                                             (line   64)
* IPv6Network (ipaddress のクラス):      Network オブジェクト.
                                                             (line  254)
* irrefutable case block:                論駁不可能なケースブロック.
                                                             (line    6)
* irshift() (operator モジュール):       インプレース in-place 演算子.
                                                             (line   87)
* Is (ast のクラス):                     式 expression<2>.   (line  110)
* is_() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line   60)
* is_absolute() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  182)
* is_active() (asyncio.AbstractChildWatcher のメソッド): プロセスのウオッチャー.
                                                             (line   76)
* is_active() (graphlib.TopologicalSorter のメソッド): graphlib --- グラフ構造を操作する機能.
                                                             (line  107)
* is_alive() (multiprocessing.Process のメソッド): Process クラスと例外.
                                                             (line   93)
* is_alive() (threading.Thread のメソッド): Thread オブジェクト.
                                                             (line  199)
* is_android (test.support モジュール):  test support --- テストのためのユーティリティ関数.
                                                             (line   40)
* is_annotated() (symtable.Symbol のメソッド): 記号表の検査. (line  230)
* is_assigned() (symtable.Symbol のメソッド): 記号表の検査.  (line  241)
* is_async (pyclbr.Function の属性):     Function オブジェクト.
                                                             (line   41)
* is_attachment() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  446)
* is_authenticated() (urllib.request.HTTPPasswordMgrWithPriorAuth のメソッド): HTTPPasswordMgrWithPriorAuth オブジェクト.
                                                             (line   32)
* is_block_device() (pathlib.Path のメソッド): ファイルの種類とステータスを問い合わせる.
                                                             (line  142)
* is_blocked() (http.cookiejar.DefaultCookiePolicy のメソッド): DefaultCookiePolicy オブジェクト.
                                                             (line   59)
* is_canonical() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  303)
* is_canonical() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  266)
* is_char_device() (pathlib.Path のメソッド): ファイルの種類とステータスを問い合わせる.
                                                             (line  152)
* IS_CHARACTER_JUNK() (difflib モジュール): difflib --- 差分の計算の補助.
                                                             (line  357)
* is_check_supported() (lzma モジュール): その他<2>.         (line    6)
* is_closed() (asyncio.loop のメソッド): ループの開始と停止. (line   42)
* is_closing() (asyncio.BaseTransport のメソッド): 基底トランスポート.
                                                             (line   17)
* is_closing() (asyncio.StreamWriter のメソッド): StreamWriter.
                                                             (line  110)
* is_dataclass() (dataclasses モジュール): モジュールの内容<4>.
                                                             (line  452)
* is_declared_global() (symtable.Symbol のメソッド): 記号表の検査.
                                                             (line  221)
* is_dir() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  521)
* is_dir() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  103)
* is_dir() (os.DirEntry のメソッド):     ファイルとディレクトリ.
                                                             (line  994)
* is_dir() (pathlib.Path のメソッド):    ファイルの種類とステータスを問い合わせる.
                                                             (line   74)
* is_dir() (zipfile.Path のメソッド):    Path オブジェクト.  (line   47)
* is_dir() (zipfile.ZipInfo のメソッド): ZipInfo オブジェクト.
                                                             (line   43)
* is_enabled() (faulthandler モジュール): フォールトハンドラの状態.
                                                             (line   31)
* is_expired() (http.cookiejar.Cookie のメソッド): Cookieオブジェクト<2>.
                                                             (line  115)
* is_fifo() (pathlib.Path のメソッド):   ファイルの種類とステータスを問い合わせる.
                                                             (line  132)
* is_file() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  525)
* is_file() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  107)
* is_file() (os.DirEntry のメソッド):    ファイルとディレクトリ.
                                                             (line 1025)
* is_file() (pathlib.Path のメソッド):   ファイルの種類とステータスを問い合わせる.
                                                             (line   59)
* is_file() (zipfile.Path のメソッド):   Path オブジェクト.  (line   51)
* is_finalized() (gc モジュール):        gc --- ガベージコレクターインターフェース.
                                                             (line  177)
* is_finalizing() (sys モジュール):      sys --- システム固有のパラメーターと関数.
                                                             (line 1181)
* is_finite() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  308)
* is_finite() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  273)
* is_free() (symtable.Symbol のメソッド): 記号表の検査.      (line  236)
* is_global (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line  132)
* is_global (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  264)
* is_global() (symtable.Symbol のメソッド): 記号表の検査.    (line  213)
* is_hop_by_hop() (wsgiref.util モジュール): wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line  111)
* is_imported() (symtable.Symbol のメソッド): 記号表の検査.  (line  205)
* is_infinite() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  313)
* is_infinite() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  278)
* is_integer() (float のメソッド):       浮動小数点数に対する追加のメソッド.
                                                             (line   16)
* is_integer() (fractions.Fraction のメソッド): fractions --- 有理数.
                                                             (line  127)
* is_integer() (int のメソッド):         整数型における追加のメソッド.
                                                             (line  166)
* is_junction() (os.DirEntry のメソッド): ファイルとディレクトリ.
                                                             (line 1061)
* is_junction() (pathlib.Path のメソッド): ファイルの種類とステータスを問い合わせる.
                                                             (line   98)
* is_jython (test.support モジュール):   test support --- テストのためのユーティリティ関数.
                                                             (line   36)
* IS_LINE_JUNK() (difflib モジュール):   difflib --- 差分の計算の補助.
                                                             (line  350)
* is_linetouched() (curses.window のメソッド): Window オブジェクト.
                                                             (line  355)
* is_link_local (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line  169)
* is_link_local (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   77)
* is_link_local (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  274)
* is_link_local (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  307)
* is_local() (symtable.Symbol のメソッド): 記号表の検査.     (line  226)
* is_loopback (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line  164)
* is_loopback (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   75)
* is_loopback (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  272)
* is_loopback (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  305)
* is_mount() (pathlib.Path のメソッド):  ファイルの種類とステータスを問い合わせる.
                                                             (line  106)
* is_multicast (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   89)
* is_multicast (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   67)
* is_multicast (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  260)
* is_multicast (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  297)
* is_multipart() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  134)
* is_multipart() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  146)
* is_namespace() (symtable.Symbol のメソッド): 記号表の検査. (line  246)
* is_nan() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  318)
* is_nan() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  283)
* is_nested() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line   95)
* is_nonlocal() (symtable.Symbol のメソッド): 記号表の検査.  (line  217)
* is_normal() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  323)
* is_normal() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  288)
* is_normalized() (unicodedata モジュール): unicodedata --- Unicode データベース.
                                                             (line  111)
* is_not_allowed() (http.cookiejar.DefaultCookiePolicy のメソッド): DefaultCookiePolicy オブジェクト.
                                                             (line   73)
* is_not() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line   64)
* IS_OP (opcode):                        Python バイトコード命令.
                                                             (line  801)
* is_optimized() (symtable.SymbolTable のメソッド): 記号表の検査.
                                                             (line   90)
* is_package() (importlib.abc.InspectLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  230)
* is_package() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  414)
* is_package() (importlib.machinery.ExtensionFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  324)
* is_package() (importlib.machinery.SourceFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  219)
* is_package() (importlib.machinery.SourcelessFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  262)
* is_package() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   73)
* is_parameter() (symtable.Symbol のメソッド): 記号表の検査. (line  209)
* is_private (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   94)
* is_private (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   69)
* is_private (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  262)
* is_private (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  299)
* is_protocol() (typing モジュール):     Introspection helpers.
                                                             (line  114)
* is_python_build() (sysconfig モジュール): その他の関数<3>. (line   50)
* is_qnan() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  328)
* is_qnan() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  294)
* is_reading() (asyncio.ReadTransport のメソッド): 読み出し専用のトランスポート.
                                                             (line    6)
* is_referenced() (symtable.Symbol のメソッド): 記号表の検査.
                                                             (line  201)
* is_relative_to() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  201)
* is_reserved (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line  160)
* is_reserved (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   73)
* is_reserved (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  270)
* is_reserved (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  303)
* is_reserved() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  226)
* is_resource_enabled() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  248)
* is_resource() (importlib.abc.ResourceReader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  475)
* is_resource() (importlib.resources モジュール): 関数 API.  (line  136)
* is_resource() (importlib.resources.abc.ResourceReader のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   62)
* is_running() (asyncio.loop のメソッド): ループの開始と停止.
                                                             (line   38)
* is_safe (uuid.UUID の属性):            uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  150)
* is_serving() (asyncio.Server のメソッド): Serverオブジェクト.
                                                             (line  118)
* is_set() (asyncio.Event のメソッド):   Event.              (line   67)
* is_set() (threading.Event のメソッド): Event オブジェクト. (line   25)
* is_signed() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  333)
* is_signed() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  299)
* is_site_local (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  276)
* is_site_local (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  357)
* is_skipped_line() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  246)
* is_snan() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  338)
* is_snan() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  305)
* is_socket() (pathlib.Path のメソッド): ファイルの種類とステータスを問い合わせる.
                                                             (line  122)
* is_stack_trampoline_active() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line 1736)
* is_subnormal() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  343)
* is_subnormal() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  310)
* is_symlink() (os.DirEntry のメソッド): ファイルとディレクトリ.
                                                             (line 1041)
* is_symlink() (pathlib.Path のメソッド): ファイルの種類とステータスを問い合わせる.
                                                             (line   90)
* is_symlink() (zipfile.Path のメソッド): Path オブジェクト. (line   55)
* is_tarfile() (tarfile モジュール):     tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  196)
* is_term_resized() (curses モジュール): 関数<6>.            (line  246)
* is_tracing() (tracemalloc モジュール): 関数<11>.           (line   63)
* is_tracked() (gc モジュール):          gc --- ガベージコレクターインターフェース.
                                                             (line  151)
* is_typeddict() (typing モジュール):    Introspection helpers.
                                                             (line  129)
* is_unspecified (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line  155)
* is_unspecified (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   71)
* is_unspecified (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  268)
* is_unspecified (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  301)
* is_valid() (string.Template のメソッド): テンプレート文字列.
                                                             (line   68)
* is_wintouched() (curses.window のメソッド): Window オブジェクト.
                                                             (line  362)
* is_zero() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  348)
* is_zero() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  315)
* is_zipfile() (zipfile モジュール):     zipfile --- ZIP アーカイブの処理.
                                                             (line   78)
* isabs() (os.path モジュール):          os path --- 一般的なパス名操作.
                                                             (line  209)
* isabstract() (inspect モジュール):     型とメンバー.       (line  513)
* IsADirectoryError:                     OS 例外.            (line   83)
* isalnum() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  511)
* isalnum() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  511)
* isalnum() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  133)
* isalnum() (str のメソッド):            文字列メソッド<2>.  (line  174)
* isalpha() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  528)
* isalpha() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  528)
* isalpha() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  138)
* isalpha() (str のメソッド):            文字列メソッド<2>.  (line  181)
* isascii() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  544)
* isascii() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  544)
* isascii() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  143)
* isascii() (str のメソッド):            文字列メソッド<2>.  (line  191)
* isasyncgen() (inspect モジュール):     型とメンバー.       (line  473)
* isasyncgenfunction() (inspect モジュール): 型とメンバー.   (line  452)
* isatty() (io.IOBase のメソッド):       I/O 基底クラス.     (line   72)
* isatty() (os モジュール):              ファイル記述子の操作.
                                                             (line  258)
* isawaitable() (inspect モジュール):    型とメンバー.       (line  431)
* isblank() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  147)
* isblk() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line  211)
* isbuiltin() (inspect モジュール):      型とメンバー.       (line  493)
* ischr() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line  207)
* isclass() (inspect モジュール):        型とメンバー.       (line  358)
* isclose() (cmath モジュール):          類別関数.           (line   23)
* isclose() (math モジュール):           数論および数表現の関数.
                                                             (line  116)
* iscntrl() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  151)
* iscode() (inspect モジュール):         型とメンバー.       (line  489)
* iscoroutine() (asyncio モジュール):    イントロスペクション.
                                                             (line   26)
* iscoroutine() (inspect モジュール):    型とメンバー.       (line  424)
* iscoroutinefunction() (inspect モジュール): 型とメンバー.  (line  388)
* isctrl() (curses.ascii モジュール):    curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  191)
* isDaemon() (threading.Thread のメソッド): Thread オブジェクト.
                                                             (line  221)
* isdatadescriptor() (inspect モジュール): 型とメンバー.     (line  540)
* isdecimal() (str のメソッド):          文字列メソッド<2>.  (line  199)
* isdev() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line  219)
* isdevdrive() (os.path モジュール):     os path --- 一般的なパス名操作.
                                                             (line  278)
* isdigit() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  553)
* isdigit() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  553)
* isdigit() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  156)
* isdigit() (str のメソッド):            文字列メソッド<2>.  (line  207)
* isdir() (os.path モジュール):          os path --- 一般的なパス名操作.
                                                             (line  231)
* isdir() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line  195)
* isdisjoint() (frozenset のメソッド):   set（集合）型 --- set frozenset.
                                                             (line   67)
* isdown() (turtle モジュール):          描画状態.           (line   85)
* iselement() (xml.etree.ElementTree モジュール): 関数<9>.   (line  128)
* isenabled() (gc モジュール):           gc --- ガベージコレクターインターフェース.
                                                             (line   29)
* isEnabledFor() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  140)
* isendwin() (curses モジュール):        関数<6>.            (line  251)
* ISEOF() (token モジュール):            token --- Python 解析木で使われる定数.
                                                             (line   31)
* isfifo() (tarfile.TarInfo のメソッド): TarInfo オブジェクト.
                                                             (line  215)
* isfile() (os.path モジュール):         os path --- 一般的なパス名操作.
                                                             (line  221)
* isfile() (tarfile.TarInfo のメソッド): TarInfo オブジェクト.
                                                             (line  186)
* isfinite() (cmath モジュール):         類別関数.           (line    6)
* isfinite() (math モジュール):          数論および数表現の関数.
                                                             (line  150)
* isfirstline() (fileinput モジュール):  fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  108)
* isframe() (inspect モジュール):        型とメンバー.       (line  485)
* isfunction() (inspect モジュール):     型とメンバー.       (line  367)
* isfuture() (asyncio モジュール):       Future の関数.      (line    6)
* isgenerator() (inspect モジュール):    型とメンバー.       (line  384)
* isgeneratorfunction() (inspect モジュール): 型とメンバー.  (line  372)
* isgetsetdescriptor() (inspect モジュール): 型とメンバー.   (line  553)
* isgraph() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  161)
* isidentifier() (str のメソッド):       文字列メソッド<2>.  (line  216)
* isinf() (cmath モジュール):            類別関数.           (line   13)
* isinf() (math モジュール):             数論および数表現の関数.
                                                             (line  157)
* isjunction() (os.path モジュール):     os path --- 一般的なパス名操作.
                                                             (line  241)
* iskeyword() (keyword モジュール):      keyword --- Python キーワードのテスト.
                                                             (line   13)
* isleap() (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  298)
* islice() (itertools モジュール):       Itertool関数.       (line  366)
* islink() (os.path モジュール):         os path --- 一般的なパス名操作.
                                                             (line  249)
* islnk() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line  203)
* islower() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  567)
* islower() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  567)
* islower() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  165)
* islower() (str のメソッド):            文字列メソッド<2>.  (line  234)
* ismemberdescriptor() (inspect モジュール): 型とメンバー.   (line  562)
* ismeta() (curses.ascii モジュール):    curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  195)
* ismethod() (inspect モジュール):       型とメンバー.       (line  363)
* ismethoddescriptor() (inspect モジュール): 型とメンバー.   (line  517)
* ismethodwrapper() (inspect モジュール): 型とメンバー.      (line  498)
* ismodule() (inspect モジュール):       型とメンバー.       (line  354)
* ismount() (os.path モジュール):        os path --- 一般的なパス名操作.
                                                             (line  258)
* isnan() (cmath モジュール):            類別関数.           (line   18)
* isnan() (math モジュール):             数論および数表現の関数.
                                                             (line  162)
* ISNONTERMINAL() (token モジュール):    token --- Python 解析木で使われる定数.
                                                             (line   27)
* IsNot (ast のクラス):                  式 expression<2>.   (line  110)
* isnumeric() (str のメソッド):          文字列メソッド<2>.  (line  240)
* isocalendar() (datetime.date のメソッド): date オブジェクト.
                                                             (line  240)
* isocalendar() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  649)
* isoformat() (datetime.date のメソッド): date オブジェクト. (line  265)
* isoformat() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  654)
* isoformat() (datetime.time のメソッド): time オブジェクト. (line  162)
* isolated (sys.flags の属性):           sys --- システム固有のパラメーターと関数.
                                                             (line  521)
* IsolatedAsyncioTestCase (unittest のクラス): テストクラス. (line  848)
* isolation_level (sqlite3.Connection の属性): Connection オブジェクト.
                                                             (line  791)
* isoweekday() (datetime.date のメソッド): date オブジェクト.
                                                             (line  233)
* isoweekday() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  643)
* isprint() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  169)
* isprintable() (str のメソッド):        文字列メソッド<2>.  (line  249)
* ispunct() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  173)
* isqrt() (math モジュール):             数論および数表現の関数.
                                                             (line  167)
* isreadable() (pprint モジュール):      関数<4>.            (line   85)
* isreadable() (pprint.PrettyPrinter のメソッド): PrettyPrinter オブジェクト.
                                                             (line   64)
* isrecursive() (pprint モジュール):     関数<4>.            (line   94)
* isrecursive() (pprint.PrettyPrinter のメソッド): PrettyPrinter オブジェクト.
                                                             (line   72)
* isreg() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line  191)
* isreserved() (os.path モジュール):     os path --- 一般的なパス名操作.
                                                             (line  297)
* isReservedKey() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   61)
* isroutine() (inspect モジュール):      型とメンバー.       (line  508)
* isSameNode() (xml.dom.Node のメソッド): Node オブジェクト. (line  100)
* issoftkeyword() (keyword モジュール):  keyword --- Python キーワードのテスト.
                                                             (line   24)
* isspace() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  585)
* isspace() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  585)
* isspace() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  177)
* isspace() (str のメソッド):            文字列メソッド<2>.  (line  260)
* isstdin() (fileinput モジュール):      fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  113)
* issubset() (frozenset のメソッド):     set（集合）型 --- set frozenset.
                                                             (line   73)
* issuperset() (frozenset のメソッド):   set（集合）型 --- set frozenset.
                                                             (line   84)
* issym() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line  199)
* ISTERMINAL() (token モジュール):       token --- Python 解析木で使われる定数.
                                                             (line   23)
* istitle() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  594)
* istitle() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  594)
* istitle() (str のメソッド):            文字列メソッド<2>.  (line  270)
* istraceback() (inspect モジュール):    型とメンバー.       (line  481)
* isub() (operator モジュール):          インプレース in-place 演算子.
                                                             (line   92)
* isupper() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  609)
* isupper() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  609)
* isupper() (curses.ascii モジュール):   curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  182)
* isupper() (str のメソッド):            文字列メソッド<2>.  (line  277)
* isvisible() (turtle モジュール):       可視性.             (line   22)
* isxdigit() (curses.ascii モジュール):  curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  186)
* ITALIC (tkinter.font モジュール):      tkinter font --- Tkinter フォントラッパー.
                                                             (line   15)
* item() (tkinter.ttk.Treeview のメソッド): ttk Treeview.    (line  201)
* item() (xml.dom.NamedNodeMap のメソッド): NamedNodeMap Objects.
                                                             (line   12)
* item() (xml.dom.NodeList のメソッド):  NodeList オブジェクト.
                                                             (line   16)
* itemgetter() (operator モジュール):    operator --- 関数形式の標準演算子.
                                                             (line  263)
* items() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  262)
* items() (contextvars.Context のメソッド): マニュアルでのコンテキスト管理.
                                                             (line  142)
* items() (dict のメソッド):             マッピング型 --- dict.
                                                             (line  162)
* items() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  241)
* items() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  349)
* items() (mailbox.Mailbox のメソッド):  Mailbox オブジェクト.
                                                             (line  140)
* items() (types.MappingProxyType のメソッド): 標準的なインタプリタ型.
                                                             (line  267)
* items() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   67)
* itemsize (array.array の属性):         array --- 効率的な数値配列.
                                                             (line  116)
* itemsize (memoryview の属性):          メモリビュー.       (line  430)
* ItemsView (collections.abc のクラス):  コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  104)
* ItemsView (typing のクラス):           Aliases to container ABCs in collections abc.
                                                             (line   41)
* iter_attachments() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  561)
* iter_child_nodes() (ast モジュール):   ast ヘルパー.       (line  173)
* iter_fields() (ast モジュール):        ast ヘルパー.       (line  168)
* iter_importers() (pkgutil モジュール): pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  108)
* iter_modules() (pkgutil モジュール):   pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  127)
* iter_parts() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  577)
* iter_unpack() (struct モジュール):     関数と例外.         (line   41)
* iter_unpack() (struct.Struct のメソッド): クラス<3>.       (line   48)
* iter() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  132)
* iter() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   39)
* iterable:                              用語集<2>.          (line  778)
* Iterable (collections.abc のクラス):   コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   26)
* Iterable (typing のクラス):            Aliases to other ABCs in collections abc.
                                                             (line    6)
* iterable;unpacking:                    式のリスト.         (line   17)
* iterator:                              用語集<2>.          (line  800)
* Iterator (collections.abc のクラス):   コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   43)
* Iterator (typing のクラス):            Aliases to other ABCs in collections abc.
                                                             (line   14)
* iterdecode() (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  237)
* iterdir() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  517)
* iterdir() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   99)
* iterdir() (pathlib.Path のメソッド):   ディレクトリを読む. (line    6)
* iterdir() (zipfile.Path のメソッド):   Path オブジェクト.  (line   43)
* iterdump() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  510)
* iterencode() (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  225)
* iterencode() (json.JSONEncoder のメソッド): エンコーダとデコーダ.
                                                             (line  229)
* iterfind() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  143)
* iterfind() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   45)
* iteritems() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  132)
* iterkeys() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  106)
* itermonthdates() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   43)
* itermonthdays() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   50)
* itermonthdays2() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   58)
* itermonthdays3() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   66)
* itermonthdays4() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   76)
* iternextfunc (C type):                 Slot Type typedefs. (line   99)
* iterparse() (xml.etree.ElementTree モジュール): 関数<9>.   (line  134)
* itertext() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  152)
* itervalues() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  115)
* iterweekdays() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   37)
* ITIMER_PROF (signal モジュール):       モジュールの内容<2>.
                                                             (line  223)
* ITIMER_REAL (signal モジュール):       モジュールの内容<2>.
                                                             (line  213)
* ITIMER_VIRTUAL (signal モジュール):    モジュールの内容<2>.
                                                             (line  218)
* ItimerError:                           モジュールの内容<2>.
                                                             (line  254)
* itruediv() (operator モジュール):      インプレース in-place 演算子.
                                                             (line   97)
* ixor() (operator モジュール):          インプレース in-place 演算子.
                                                             (line  102)
* j;in numeric literal:                  Floating-point literals.
                                                             (line   28)
* JANUARY (calendar モジュール):         calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* java_ver() (platform モジュール):      Java プラットフォーム.
                                                             (line    6)
* Java;言語:                             numbers Real float 実数.
                                                             (line    6)
* join_thread() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  180)
* join_thread() (test.support.threading_helper モジュール): test support threading_helper --- Utilities for threading tests.
                                                             (line   11)
* join() (asyncio.Queue のメソッド):     Queue.              (line   53)
* join() (bytearray のメソッド):         bytes と bytearray の操作.
                                                             (line  168)
* join() (bytes のメソッド):             bytes と bytearray の操作.
                                                             (line  168)
* join() (multiprocessing.JoinableQueue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  267)
* join() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  185)
* join() (multiprocessing.Process のメソッド): Process クラスと例外.
                                                             (line   66)
* join() (os.path モジュール):           os path --- 一般的なパス名操作.
                                                             (line  319)
* join() (queue.Queue のメソッド):       キューオブジェクト. (line   90)
* join() (shlex モジュール):             shlex --- 単純な字句解析.
                                                             (line   28)
* join() (str のメソッド):               文字列メソッド<2>.  (line  292)
* join() (threading.Thread のメソッド):  Thread オブジェクト.
                                                             (line  134)
* JoinableQueue (multiprocessing のクラス): パイプ Pipe とキュー Queue.
                                                             (line  245)
* JoinedStr (ast のクラス):              リテラル<3>.        (line   41)
* joinpath() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  529)
* joinpath() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  111)
* joinpath() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  240)
* joinpath() (zipfile.Path のメソッド):  Path オブジェクト.  (line  104)
* js_output() (http.cookies.BaseCookie のメソッド): Cookieオブジェクト.
                                                             (line   32)
* js_output() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   72)
* json.tool コマンドラインオプション; -compact: コマンドラインオプション<4>.
                                                             (line   49)
* json.tool コマンドラインオプション; -h: コマンドラインオプション<4>.
                                                             (line   55)
* json.tool コマンドラインオプション; -help: コマンドラインオプション<4>.
                                                             (line   55)
* json.tool コマンドラインオプション; -indent: コマンドラインオプション<4>.
                                                             (line   49)
* json.tool コマンドラインオプション; -json-lines: コマンドラインオプション<4>.
                                                             (line   43)
* json.tool コマンドラインオプション; -no-ensure-ascii: コマンドラインオプション<4>.
                                                             (line   36)
* json.tool コマンドラインオプション; -no-indent: コマンドラインオプション<4>.
                                                             (line   49)
* json.tool コマンドラインオプション; -sort-keys: コマンドラインオプション<4>.
                                                             (line   30)
* json.tool コマンドラインオプション; -tab: コマンドラインオプション<4>.
                                                             (line   49)
* json.tool コマンドラインオプション; infile: コマンドラインオプション<4>.
                                                             (line    6)
* json.tool コマンドラインオプション; outfile: コマンドラインオプション<4>.
                                                             (line   25)
* JSONDecodeError:                       例外<16>.           (line    6)
* JSONDecoder (json のクラス):           エンコーダとデコーダ.
                                                             (line    6)
* JSONEncoder (json のクラス):           エンコーダとデコーダ.
                                                             (line  105)
* JULY (calendar モジュール):            calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* JUMP (monitoring event):               Events.             (line   34)
* JUMP (opcode):                         Python バイトコード命令.
                                                             (line 1407)
* jump (pdb command):                    デバッガコマンド.   (line  226)
* JUMP_BACKWARD (opcode):                Python バイトコード命令.
                                                             (line  832)
* JUMP_BACKWARD_NO_INTERRUPT (opcode):   Python バイトコード命令.
                                                             (line  838)
* JUMP_FORWARD (opcode):                 Python バイトコード命令.
                                                             (line  828)
* JUMP_NO_INTERRUPT (opcode):            Python バイトコード命令.
                                                             (line 1409)
* JUNE (calendar モジュール):            calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* kbhit() (msvcrt モジュール):           コンソール I/O 関連.
                                                             (line    6)
* kde_random() (statistics モジュール):  関数の詳細.         (line  179)
* kde() (statistics モジュール):         関数の詳細.         (line  131)
* KEEP (enum.FlagBoundary の属性):       データ型<2>.        (line  688)
* kevent() (select モジュール):          select --- I/O 完了の待機.
                                                             (line  108)
* key (http.cookies.Morsel の属性):      Morselオブジェクト. (line   53)
* key (zoneinfo.ZoneInfo の属性):        ZoneInfo クラス.    (line   75)
* key function:                          用語集<2>.          (line  825)
* KEY_A1 (curses モジュール):            定数<6>.            (line  237)
* KEY_A3 (curses モジュール):            定数<6>.            (line  240)
* KEY_ALL_ACCESS (winreg モジュール):    アクセス権限.       (line    9)
* KEY_B2 (curses モジュール):            定数<6>.            (line  243)
* KEY_BACKSPACE (curses モジュール):     定数<6>.            (line  166)
* KEY_BEG (curses モジュール):           定数<6>.            (line  255)
* KEY_BREAK (curses モジュール):         定数<6>.            (line  148)
* KEY_BTAB (curses モジュール):          定数<6>.            (line  252)
* KEY_C1 (curses モジュール):            定数<6>.            (line  246)
* KEY_C3 (curses モジュール):            定数<6>.            (line  249)
* KEY_CANCEL (curses モジュール):        定数<6>.            (line  258)
* KEY_CATAB (curses モジュール):         定数<6>.            (line  218)
* KEY_CLEAR (curses モジュール):         定数<6>.            (line  191)
* KEY_CLOSE (curses モジュール):         定数<6>.            (line  261)
* KEY_COMMAND (curses モジュール):       定数<6>.            (line  264)
* KEY_COPY (curses モジュール):          定数<6>.            (line  267)
* KEY_CREATE (curses モジュール):        定数<6>.            (line  270)
* KEY_CREATE_LINK (winreg モジュール):   アクセス権限.       (line   51)
* KEY_CREATE_SUB_KEY (winreg モジュール): アクセス権限.      (line   39)
* KEY_CTAB (curses モジュール):          定数<6>.            (line  215)
* KEY_DC (curses モジュール):            定数<6>.            (line  182)
* KEY_DL (curses モジュール):            定数<6>.            (line  176)
* KEY_DOWN (curses モジュール):          定数<6>.            (line  151)
* KEY_EIC (curses モジュール):           定数<6>.            (line  188)
* KEY_END (curses モジュール):           定数<6>.            (line  273)
* KEY_ENTER (curses モジュール):         定数<6>.            (line  221)
* KEY_ENUMERATE_SUB_KEYS (winreg モジュール): アクセス権限.  (line   43)
* KEY_EOL (curses モジュール):           定数<6>.            (line  197)
* KEY_EOS (curses モジュール):           定数<6>.            (line  194)
* KEY_EXECUTE (winreg モジュール):       アクセス権限.       (line   27)
* KEY_EXIT (curses モジュール):          定数<6>.            (line  276)
* KEY_F0 (curses モジュール):            定数<6>.            (line  169)
* KEY_FIND (curses モジュール):          定数<6>.            (line  279)
* KEY_Fn (curses モジュール):            定数<6>.            (line  173)
* KEY_HELP (curses モジュール):          定数<6>.            (line  282)
* KEY_HOME (curses モジュール):          定数<6>.            (line  163)
* KEY_IC (curses モジュール):            定数<6>.            (line  185)
* KEY_IL (curses モジュール):            定数<6>.            (line  179)
* KEY_LEFT (curses モジュール):          定数<6>.            (line  157)
* KEY_LL (curses モジュール):            定数<6>.            (line  234)
* KEY_MARK (curses モジュール):          定数<6>.            (line  285)
* KEY_MAX (curses モジュール):           定数<6>.            (line  426)
* KEY_MESSAGE (curses モジュール):       定数<6>.            (line  288)
* KEY_MIN (curses モジュール):           定数<6>.            (line  145)
* KEY_MOUSE (curses モジュール):         定数<6>.            (line  420)
* KEY_MOVE (curses モジュール):          定数<6>.            (line  291)
* KEY_NEXT (curses モジュール):          定数<6>.            (line  294)
* KEY_NOTIFY (winreg モジュール):        アクセス権限.       (line   47)
* KEY_NPAGE (curses モジュール):         定数<6>.            (line  206)
* KEY_OPEN (curses モジュール):          定数<6>.            (line  297)
* KEY_OPTIONS (curses モジュール):       定数<6>.            (line  300)
* KEY_PPAGE (curses モジュール):         定数<6>.            (line  209)
* KEY_PREVIOUS (curses モジュール):      定数<6>.            (line  303)
* KEY_PRINT (curses モジュール):         定数<6>.            (line  231)
* KEY_QUERY_VALUE (winreg モジュール):   アクセス権限.       (line   31)
* KEY_READ (winreg モジュール):          アクセス権限.       (line   21)
* KEY_REDO (curses モジュール):          定数<6>.            (line  306)
* KEY_REFERENCE (curses モジュール):     定数<6>.            (line  309)
* KEY_REFRESH (curses モジュール):       定数<6>.            (line  312)
* KEY_REPLACE (curses モジュール):       定数<6>.            (line  315)
* KEY_RESET (curses モジュール):         定数<6>.            (line  228)
* KEY_RESIZE (curses モジュール):        定数<6>.            (line  423)
* KEY_RESTART (curses モジュール):       定数<6>.            (line  318)
* KEY_RESUME (curses モジュール):        定数<6>.            (line  321)
* KEY_RIGHT (curses モジュール):         定数<6>.            (line  160)
* KEY_SAVE (curses モジュール):          定数<6>.            (line  324)
* KEY_SBEG (curses モジュール):          定数<6>.            (line  327)
* KEY_SCANCEL (curses モジュール):       定数<6>.            (line  330)
* KEY_SCOMMAND (curses モジュール):      定数<6>.            (line  333)
* KEY_SCOPY (curses モジュール):         定数<6>.            (line  336)
* KEY_SCREATE (curses モジュール):       定数<6>.            (line  339)
* KEY_SDC (curses モジュール):           定数<6>.            (line  342)
* KEY_SDL (curses モジュール):           定数<6>.            (line  345)
* KEY_SELECT (curses モジュール):        定数<6>.            (line  348)
* KEY_SEND (curses モジュール):          定数<6>.            (line  351)
* KEY_SEOL (curses モジュール):          定数<6>.            (line  354)
* KEY_SET_VALUE (winreg モジュール):     アクセス権限.       (line   35)
* KEY_SEXIT (curses モジュール):         定数<6>.            (line  357)
* KEY_SF (curses モジュール):            定数<6>.            (line  200)
* KEY_SFIND (curses モジュール):         定数<6>.            (line  360)
* KEY_SHELP (curses モジュール):         定数<6>.            (line  363)
* KEY_SHOME (curses モジュール):         定数<6>.            (line  366)
* KEY_SIC (curses モジュール):           定数<6>.            (line  369)
* KEY_SLEFT (curses モジュール):         定数<6>.            (line  372)
* KEY_SMESSAGE (curses モジュール):      定数<6>.            (line  375)
* KEY_SMOVE (curses モジュール):         定数<6>.            (line  378)
* KEY_SNEXT (curses モジュール):         定数<6>.            (line  381)
* KEY_SOPTIONS (curses モジュール):      定数<6>.            (line  384)
* KEY_SPREVIOUS (curses モジュール):     定数<6>.            (line  387)
* KEY_SPRINT (curses モジュール):        定数<6>.            (line  390)
* KEY_SR (curses モジュール):            定数<6>.            (line  203)
* KEY_SREDO (curses モジュール):         定数<6>.            (line  393)
* KEY_SREPLACE (curses モジュール):      定数<6>.            (line  396)
* KEY_SRESET (curses モジュール):        定数<6>.            (line  224)
* KEY_SRIGHT (curses モジュール):        定数<6>.            (line  399)
* KEY_SRSUME (curses モジュール):        定数<6>.            (line  402)
* KEY_SSAVE (curses モジュール):         定数<6>.            (line  405)
* KEY_SSUSPEND (curses モジュール):      定数<6>.            (line  408)
* KEY_STAB (curses モジュール):          定数<6>.            (line  212)
* KEY_SUNDO (curses モジュール):         定数<6>.            (line  411)
* KEY_SUSPEND (curses モジュール):       定数<6>.            (line  414)
* KEY_UNDO (curses モジュール):          定数<6>.            (line  417)
* KEY_UP (curses モジュール):            定数<6>.            (line  154)
* KEY_WOW64_32KEY (winreg モジュール):   64-bit 特有のアクセス権.
                                                             (line   15)
* KEY_WOW64_64KEY (winreg モジュール):   64-bit 特有のアクセス権.
                                                             (line    9)
* KEY_WRITE (winreg モジュール):         アクセス権限.       (line   16)
* key/value pair:                        辞書表示.           (line    6)
* KeyboardInterrupt:                     具象例外.           (line   82)
* KeyboardInterrupt (組み込み例外):      シグナルハンドリング<2>.
                                                             (line    7)
* KeyboardInterrupt (組み込み例外) <1>:  シグナルハンドリング<2>.
                                                             (line   34)
* KeyboardInterrupt (組み込み例外) <2>:  シグナルハンドリング<2>.
                                                             (line   43)
* KeyError:                              具象例外.           (line   77)
* keylog_filename (ssl.SSLContext の属性): SSL コンテキスト. (line  527)
* keyname() (curses モジュール):         関数<6>.            (line  256)
* keypad() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  368)
* keyrefs() (weakref.WeakKeyDictionary のメソッド): weakref --- 弱参照.
                                                             (line  201)
* keys() (contextvars.Context のメソッド): マニュアルでのコンテキスト管理.
                                                             (line  133)
* keys() (dict のメソッド):              マッピング型 --- dict.
                                                             (line  167)
* keys() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  232)
* keys() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  340)
* keys() (mailbox.Mailbox のメソッド):   Mailbox オブジェクト.
                                                             (line  110)
* keys() (sqlite3.Row のメソッド):       Row オブジェクト.   (line   20)
* keys() (types.MappingProxyType のメソッド): 標準的なインタプリタ型.
                                                             (line  272)
* keys() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   72)
* KeysView (collections.abc のクラス):   コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  104)
* KeysView (typing のクラス):            Aliases to container ABCs in collections abc.
                                                             (line   50)
* keyword (ast のクラス):                式 expression<2>.   (line  153)
* keyword argument:                      用語集<2>.          (line  847)
* keywords (functools.partial の属性):   partial オブジェクト.
                                                             (line   21)
* kill_python() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   77)
* kill() (asyncio.subprocess.Process のメソッド): サブプロセスとやりとりする.
                                                             (line  107)
* kill() (asyncio.SubprocessTransport のメソッド): サブプロセス化されたトランスポート.
                                                             (line   35)
* kill() (multiprocessing.Process のメソッド): Process クラスと例外.
                                                             (line  189)
* kill() (os モジュール):                プロセス管理.       (line  324)
* kill() (subprocess.Popen のメソッド):  Popen オブジェクト. (line   94)
* killchar() (curses モジュール):        関数<6>.            (line  266)
* killpg() (os モジュール):              プロセス管理.       (line  346)
* kind (inspect.Parameter の属性):       Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  228)
* knownfiles (mimetypes モジュール):     mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  136)
* kqueue() (select モジュール):          select --- I/O 完了の待機.
                                                             (line   98)
* KqueueSelector (selectors のクラス):   クラス<4>.          (line  198)
* KW_ONLY (dataclasses モジュール):      モジュールの内容<4>.
                                                             (line  469)
* kwargs (inspect.BoundArguments の属性): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  353)
* kwargs (typing.ParamSpec の属性):      Building generic types and type aliases.
                                                             (line  410)
* kwlist (keyword モジュール):           keyword --- Python キーワードのテスト.
                                                             (line   18)
* L (re モジュール):                     フラグ.             (line   57)
* lambda:                                用語集<2>.          (line  851)
* Lambda (ast のクラス):                 関数およびクラス定義.
                                                             (line   32)
* lambda;expression:                     ラムダ lambda.      (line    6)
* lambda;expression <1>:                 関数定義.           (line  123)
* lambda;形式:                           ラムダ lambda.      (line    6)
* LambdaType (types モジュール):         標準的なインタプリタ型.
                                                             (line   24)
* LANG:                                  GNU gettext API.    (line   21)
* LANG <1>:                              クラス形式の API.   (line   25)
* LANG <2>:                              locale --- 国際化サービス.
                                                             (line   45)
* LANG <3>:                              locale --- 国際化サービス.
                                                             (line  329)
* LANG <4>:                              locale --- 国際化サービス.
                                                             (line  333)
* LANGUAGE:                              GNU gettext API.    (line   20)
* LANGUAGE <1>:                          クラス形式の API.   (line   25)
* large files:                           ラージファイルのサポート.
                                                             (line    6)
* LARGEST (test.support モジュール):     test support --- テストのためのユーティリティ関数.
                                                             (line  188)
* LargeZipFile:                          zipfile --- ZIP アーカイブの処理.
                                                             (line   38)
* last_accepted (multiprocessing.connection.Listener の属性): リスナーとクライアント.
                                                             (line  104)
* last_exc (sys モジュール):             sys --- システム固有のパラメーターと関数.
                                                             (line 1190)
* last_traceback (sys モジュール):       トレースバック traceback オブジェクト.
                                                             (line    6)
* last_traceback (sys モジュール) <1>:   sys --- システム固有のパラメーターと関数.
                                                             (line 1213)
* last_type (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line 1213)
* last_value (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1213)
* lastChild (xml.dom.Node の属性):       Node オブジェクト.  (line   58)
* lastcmd (cmd.Cmd の属性):              Cmdオブジェクト.    (line  136)
* lastgroup (re.Match の属性):           マッチオブジェクト. (line  191)
* lastindex (re.Match の属性):           マッチオブジェクト. (line  183)
* lastResort (logging モジュール):       モジュールレベル属性.
                                                             (line    6)
* lastrowid (sqlite3.Cursor の属性):     Cursor オブジェクト.
                                                             (line  198)
* layout() (tkinter.ttk.Style のメソッド): Ttk スタイル.     (line   97)
* lazycache() (linecache モジュール):    linecache --- テキストラインへのランダムアクセス.
                                                             (line   50)
* LazyLoader (importlib.util のクラス):  importlib util -- インポータのためのユーティリティコード.
                                                             (line  196)
* LBRACE (token モジュール):             token --- Python 解析木で使われる定数.
                                                             (line  123)
* LBYL:                                  用語集<2>.          (line  857)
* LC_ALL:                                GNU gettext API.    (line   20)
* LC_ALL <1>:                            クラス形式の API.   (line   25)
* LC_ALL (locale モジュール):            locale --- 国際化サービス.
                                                             (line  539)
* LC_COLLATE (locale モジュール):        locale --- 国際化サービス.
                                                             (line  504)
* LC_CTYPE (locale モジュール):          locale --- 国際化サービス.
                                                             (line  490)
* LC_MESSAGES:                           GNU gettext API.    (line   21)
* LC_MESSAGES <1>:                       クラス形式の API.   (line   25)
* LC_MESSAGES (locale モジュール):       locale --- 国際化サービス.
                                                             (line  520)
* LC_MONETARY (locale モジュール):       locale --- 国際化サービス.
                                                             (line  515)
* LC_NUMERIC (locale モジュール):        locale --- 国際化サービス.
                                                             (line  531)
* LC_TIME (locale モジュール):           locale --- 国際化サービス.
                                                             (line  510)
* lchflags() (os モジュール):            ファイルとディレクトリ.
                                                             (line  315)
* lchmod() (os モジュール):              ファイルとディレクトリ.
                                                             (line  329)
* lchmod() (pathlib.Path のメソッド):    パーミッションと所有者.
                                                             (line   60)
* lchown() (os モジュール):              ファイルとディレクトリ.
                                                             (line  351)
* lcm() (math モジュール):               数論および数表現の関数.
                                                             (line  178)
* LDCXXSHARED:                           ビルドならびに C API の変更<8>.
                                                             (line  149)
* ldexp() (math モジュール):             数論および数表現の関数.
                                                             (line  187)
* LDFLAGS:                               新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   57)
* LDFLAGS <1>:                           Preprocessor flags. (line   18)
* LDFLAGS <2>:                           Linker flags.       (line   15)
* LDFLAGS <3>:                           Linker flags.       (line   18)
* LDFLAGS <4>:                           Linker flags.       (line   28)
* LDFLAGS <5>:                           Linker flags.       (line   31)
* LDFLAGS <6>:                           Linker flags.       (line   35)
* LDFLAGS <7>:                           Linker flags.       (line   50)
* LDFLAGS_NODIST:                        Linker flags.       (line   26)
* LDFLAGS_NODIST <1>:                    Linker flags.       (line   40)
* le() (operator モジュール):            operator --- 関数形式の標準演算子.
                                                             (line   23)
* leapdays() (calendar モジュール):      calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  303)
* leaveok() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  375)
* left (filecmp.dircmp の属性):          dircmp クラス.      (line   44)
* left_list (filecmp.dircmp の属性):     dircmp クラス.      (line   52)
* left_only (filecmp.dircmp の属性):     dircmp クラス.      (line   67)
* left() (turtle モジュール):            Turtle の動き.      (line   57)
* LEFTSHIFT (token モジュール):          token --- Python 解析木で使われる定数.
                                                             (line  155)
* LEFTSHIFTEQUAL (token モジュール):     token --- Python 解析木で使われる定数.
                                                             (line  199)
* LEGACY_TRANSACTION_CONTROL (sqlite3 モジュール): モジュール定数.
                                                             (line    6)
* lenfunc (C type):                      Slot Type typedefs. (line  104)
* length (xml.dom.NamedNodeMap の属性):  NamedNodeMap Objects.
                                                             (line    8)
* length (xml.dom.NodeList の属性):      NodeList オブジェクト.
                                                             (line   22)
* length_hint() (operator モジュール):   operator --- 関数形式の標準演算子.
                                                             (line  205)
* LESS (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line  103)
* LESSEQUAL (token モジュール):          token --- Python 解析木で使われる定数.
                                                             (line  139)
* level (logging.Logger の属性):         ロガーオブジェクト. (line   32)
* LexicalHandler (xml.sax.handler のクラス): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   44)
* lexists() (os.path モジュール):        os path --- 一般的なパス名操作.
                                                             (line  125)
* LF (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   51)
* lgamma() (math モジュール):            特殊関数.           (line   34)
* libc_ver() (platform モジュール):      Unix プラットフォーム.
                                                             (line    6)
* LIBRARIES_ASSEMBLY_NAME_PREFIX (msvcrt モジュール): その多の関数.
                                                             (line   98)
* library (dbm.ndbm モジュール):         dbm ndbm --- New Database Manager.
                                                             (line   34)
* library (ssl.SSLError の属性):         例外<15>.           (line   18)
* LibraryLoader (ctypes のクラス):       共有ライブラリをロードする.
                                                             (line  163)
* license (組み込み変数):                site モジュールで追加される定数.
                                                             (line   30)
* LifoQueue (asyncio のクラス):          LIFO キュー.        (line    6)
* LifoQueue (queue のクラス):            queue --- 同期キュークラス.
                                                             (line   40)
* light-weight processes:                _thread --- 低水準なスレッド API.
                                                             (line    6)
* limit_denominator() (fractions.Fraction のメソッド): fractions --- 有理数.
                                                             (line  153)
* LimitOverrunError:                     例外<12>.           (line   62)
* line (bdb.Breakpoint の属性):          bdb --- デバッガーフレームワーク.
                                                             (line   87)
* LINE (monitoring event):               Events.             (line   38)
* line (traceback.FrameSummary の属性):  FrameSummary オブジェクト.
                                                             (line   42)
* line_buffering (io.TextIOWrapper の属性): テキスト I/O<2>. (line  166)
* line_num (csv.csvreader の属性):       reader オブジェクト.
                                                             (line   24)
* line-buffered I/O:                     組み込み関数.       (line 1455)
* linear_regression() (statistics モジュール): 関数の詳細.   (line  610)
* lineno (ast.AST の属性):               Node クラス.        (line   49)
* lineno (doctest.DocTest の属性):       DocTest オブジェクト.
                                                             (line   41)
* lineno (doctest.Example の属性):       Example オブジェクト.
                                                             (line   39)
* lineno (inspect.FrameInfo の属性):     インタープリタスタック.
                                                             (line   22)
* lineno (inspect.Traceback の属性):     インタープリタスタック.
                                                             (line   62)
* lineno (json.JSONDecodeError の属性):  例外<16>.           (line   22)
* lineno (netrc.NetrcParseError の属性): netrc --- netrc ファイルの処理.
                                                             (line   60)
* lineno (pyclbr.Class の属性):          クラスオブジェクト<2>.
                                                             (line   24)
* lineno (pyclbr.Function の属性):       Function オブジェクト.
                                                             (line   23)
* lineno (re.PatternError の属性):       例外<3>.            (line   28)
* lineno (shlex.shlex の属性):           shlex オブジェクト. (line  168)
* lineno (SyntaxError の属性):           具象例外.           (line  299)
* lineno (traceback.FrameSummary の属性): FrameSummary オブジェクト.
                                                             (line   33)
* lineno (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   95)
* lineno (tracemalloc.Filter の属性):    Filter.             (line   49)
* lineno (tracemalloc.Frame の属性):     Frame.              (line   17)
* lineno (xml.parsers.expat.ExpatError の属性): ExpatError 例外.
                                                             (line   26)
* lineno() (fileinput モジュール):       fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line   96)
* LINES:                                 関数<6>.            (line  125)
* LINES <1>:                             関数<6>.            (line  577)
* LINES <2>:                             関数<6>.            (line  579)
* LINES (curses モジュール):             定数<6>.            (line   53)
* lines (os.terminal_size の属性):       ターミナルのサイズの問い合わせ.
                                                             (line   33)
* linesep (email.policy.Policy の属性):  email policy Policy Objects.
                                                             (line  151)
* linesep (os モジュール):               雑多なシステム情報. (line  148)
* lineterminator (csv.Dialect の属性):   Dialect クラスと書式化パラメータ.
                                                             (line   47)
* LineTooLong:                           http client --- HTTP プロトコルクライアント.
                                                             (line  188)
* link() (os モジュール):                ファイルとディレクトリ.
                                                             (line  366)
* linkname (tarfile.TarInfo の属性):     TarInfo オブジェクト.
                                                             (line   97)
* LinkOutsideDestinationError:           tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  264)
* list:                                  用語集<2>.          (line  870)
* List (ast のクラス):                   リテラル<3>.        (line   65)
* list (pdb command):                    デバッガコマンド.   (line  235)
* List (typing のクラス):                Aliases to built-in types.
                                                             (line   18)
* list (組み込みクラス):                 リスト型 list<2>.   (line   10)
* list comprehension:                    用語集<2>.          (line  876)
* LIST_APPEND (opcode):                  Python バイトコード命令.
                                                             (line  372)
* list_dialects() (csv モジュール):      モジュールコンテンツ<3>.
                                                             (line   90)
* LIST_EXTEND (opcode):                  Python バイトコード命令.
                                                             (line  704)
* list_folders() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line   63)
* list_folders() (mailbox.MH のメソッド): MH オブジェクト.   (line   37)
* list;内包表記:                         リスト表示.         (line    6)
* list;表示:                             リスト表示.         (line    6)
* list() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line  127)
* list() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  233)
* list() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   55)
* list() (tarfile.TarFile のメソッド):   TarFile オブジェクト.
                                                             (line  125)
* ListComp (ast のクラス):               内包表記 Comprehension.
                                                             (line    6)
* listdir() (os モジュール):             ファイルとディレクトリ.
                                                             (line  388)
* listdrives() (os モジュール):          ファイルとディレクトリ.
                                                             (line  424)
* listen() (logging.config モジュール):  環境設定のための関数.
                                                             (line  115)
* listen() (socket.socket のメソッド):   socket オブジェクト.
                                                             (line  200)
* listen() (turtle モジュール):          スクリーンイベントを利用する.
                                                             (line    6)
* listener (logging.handlers.QueueHandler の属性): QueueHandler.
                                                             (line   87)
* Listener (multiprocessing.connection のクラス): リスナーとクライアント.
                                                             (line   50)
* listMethods() (xmlrpc.client.ServerProxy.system のメソッド): ServerProxy オブジェクト.
                                                             (line   16)
* listmounts() (os モジュール):          ファイルとディレクトリ.
                                                             (line  443)
* listvolumes() (os モジュール):         ファイルとディレクトリ.
                                                             (line  467)
* listxattr() (os モジュール):           Linux 拡張属性.     (line   26)
* Literal (typing モジュール):           特殊形式.           (line  126)
* literal_eval() (ast モジュール):       ast ヘルパー.       (line   84)
* LiteralString (typing モジュール):     特殊型.             (line   67)
* LittleEndianStructure (ctypes のクラス): 構造化データ型.   (line   29)
* LittleEndianUnion (ctypes のクラス):   構造化データ型.     (line   17)
* ljust() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  303)
* ljust() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  303)
* ljust() (str のメソッド):              文字列メソッド<2>.  (line  299)
* LK_LOCK (msvcrt モジュール):           ファイル操作関連.   (line   19)
* LK_NBLCK (msvcrt モジュール):          ファイル操作関連.   (line   27)
* LK_NBRLCK (msvcrt モジュール):         ファイル操作関連.   (line   27)
* LK_RLCK (msvcrt モジュール):           ファイル操作関連.   (line   19)
* LK_UNLCK (msvcrt モジュール):          ファイル操作関連.   (line   33)
* ll (pdb command):                      デバッガコマンド.   (line  250)
* LMTP (smtplib のクラス):               smtplib --- SMTP プロトコルクライアント.
                                                             (line  105)
* ln() (decimal.Context のメソッド):     Context オブジェクト.
                                                             (line  353)
* ln() (decimal.Decimal のメソッド):     Decimal オブジェクト.
                                                             (line  320)
* LNKTYPE (tarfile モジュール):          tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  281)
* Load (ast のクラス):                   変数.               (line   11)
* LOAD_ASSERTION_ERROR (opcode):         Python バイトコード命令.
                                                             (line  492)
* LOAD_ATTR (opcode):                    Python バイトコード命令.
                                                             (line  744)
* LOAD_BUILD_CLASS (opcode):             Python バイトコード命令.
                                                             (line  499)
* load_cert_chain() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  101)
* LOAD_CLOSURE (opcode):                 Python バイトコード命令.
                                                             (line 1414)
* LOAD_CONST (opcode):                   Python バイトコード命令.
                                                             (line  626)
* load_default_certs() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  130)
* LOAD_DEREF (opcode):                   Python バイトコード命令.
                                                             (line  957)
* load_dh_params() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  351)
* load_extension() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  482)
* LOAD_FAST (opcode):                    Python バイトコード命令.
                                                             (line  917)
* LOAD_FAST_AND_CLEAR (opcode):          Python バイトコード命令.
                                                             (line  934)
* LOAD_FAST_CHECK (opcode):              Python バイトコード命令.
                                                             (line  926)
* LOAD_FROM_DICT_OR_DEREF (opcode):      Python バイトコード命令.
                                                             (line  965)
* LOAD_FROM_DICT_OR_GLOBALS (opcode):    Python バイトコード命令.
                                                             (line  645)
* LOAD_GLOBAL (opcode):                  Python バイトコード命令.
                                                             (line  909)
* LOAD_LOCALS (opcode):                  Python バイトコード命令.
                                                             (line  636)
* LOAD_METHOD (opcode):                  Python バイトコード命令.
                                                             (line 1424)
* load_module() (importlib.abc.FileLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  309)
* load_module() (importlib.abc.InspectLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  263)
* load_module() (importlib.abc.Loader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  128)
* load_module() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  403)
* load_module() (importlib.machinery.SourceFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  233)
* load_module() (importlib.machinery.SourcelessFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  277)
* load_module() (zipimport.zipimporter のメソッド): zipimporter オブジェクト.
                                                             (line   79)
* LOAD_NAME (opcode):                    Python バイトコード命令.
                                                             (line  630)
* load_package_tests() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  626)
* LOAD_SUPER_ATTR (opcode):              Python バイトコード命令.
                                                             (line  762)
* load_verify_locations() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  149)
* load() (http.cookiejar.FileCookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line  132)
* load() (http.cookies.BaseCookie のメソッド): Cookieオブジェクト.
                                                             (line   39)
* load() (json モジュール):              基本的な使い方<2>.  (line   96)
* load() (marshal モジュール):           marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line   72)
* load() (pickle モジュール):            モジュールインターフェース.
                                                             (line   58)
* load() (pickle.Unpickler のメソッド):  モジュールインターフェース.
                                                             (line  275)
* load() (plistlib モジュール):          plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line   46)
* load() (tomllib モジュール):           tomllib --- TOML ファイルの解析.
                                                             (line   32)
* load() (tracemalloc.Snapshot のクラスメソッド): Snapshot.  (line   51)
* loader:                                ファインダーとローダー.
                                                             (line    6)
* loader <1>:                            用語集<2>.          (line  885)
* Loader (importlib.abc のクラス):       importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   91)
* loader (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  385)
* loader_state (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  414)
* LoadError:                             http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line   33)
* LoadFileDialog (tkinter.filedialog のクラス): ネイティブの読み込み/保存ダイアログ.
                                                             (line  134)
* LoadKey() (winreg モジュール):         関数<13>.           (line  256)
* LoadLibrary() (ctypes.LibraryLoader のメソッド): 共有ライブラリをロードする.
                                                             (line  174)
* loads() (json モジュール):             基本的な使い方<2>.  (line  159)
* loads() (marshal モジュール):          marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line  110)
* loads() (pickle モジュール):           モジュールインターフェース.
                                                             (line   76)
* loads() (plistlib モジュール):         plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line   81)
* loads() (tomllib モジュール):          tomllib --- TOML ファイルの解析.
                                                             (line   49)
* loads() (xmlrpc.client モジュール):    補助関数.           (line   19)
* loadTestsFromModule() (unittest.TestLoader のメソッド): テストのロードと起動.
                                                             (line   41)
* loadTestsFromName() (unittest.TestLoader のメソッド): テストのロードと起動.
                                                             (line   71)
* loadTestsFromNames() (unittest.TestLoader のメソッド): テストのロードと起動.
                                                             (line  102)
* loadTestsFromTestCase() (unittest.TestLoader のメソッド): テストのロードと起動.
                                                             (line   29)
* local (threading のクラス):            スレッドローカルデータ.
                                                             (line   15)
* LOCAL_CREDS (socket モジュール):       定数<8>.            (line  322)
* LOCAL_CREDS_PERSISTENT (socket モジュール): 定数<8>.       (line  322)
* localcontext() (decimal モジュール):   Context オブジェクト.
                                                             (line   25)
* LOCALE (re モジュール):                フラグ.             (line   57)
* localeconv() (locale モジュール):      locale --- 国際化サービス.
                                                             (line   49)
* LocaleHTMLCalendar (calendar のクラス): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  269)
* LocaleTextCalendar (calendar のクラス): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  263)
* localize() (locale モジュール):        locale --- 国際化サービス.
                                                             (line  472)
* localName (xml.dom.Attr の属性):       Attr オブジェクト.  (line   13)
* localName (xml.dom.Node の属性):       Node オブジェクト.  (line   63)
* localtime() (email.utils モジュール):  email utils Miscellaneous utilities.
                                                             (line   13)
* localtime() (time モジュール):         関数<5>.            (line  149)
* Locator (xml.sax.xmlreader のクラス):  xml sax xmlreader --- XML パーサーのインターフェース.
                                                             (line   42)
* Lock (asyncio のクラス):               Lock.               (line    6)
* Lock (multiprocessing のクラス):       同期プリミティブ.   (line   46)
* lock (sys.thread_info の属性):         sys --- システム固有のパラメーターと関数.
                                                             (line 1893)
* Lock (threading のクラス):             Lock オブジェクト.  (line   34)
* LOCK_EX (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line  174)
* LOCK_NB (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line  178)
* LOCK_SH (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line  170)
* LOCK_UN (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line  166)
* lock, interpreter:                     スレッド状態 thread state とグローバルインタプリタロック global interpreter lock.
                                                             (line    6)
* lock() (mailbox.Babyl のメソッド):     Babyl オブジェクト. (line   56)
* lock() (mailbox.Mailbox のメソッド):   Mailbox オブジェクト.
                                                             (line  252)
* lock() (mailbox.Maildir のメソッド):   Maildir オブジェクト.
                                                             (line  206)
* lock() (mailbox.mbox のメソッド):      mbox オブジェクト.  (line   39)
* lock() (mailbox.MH のメソッド):        MH オブジェクト.    (line   89)
* lock() (mailbox.MMDF のメソッド):      MMDF オブジェクト.  (line   35)
* Lock() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  190)
* locked() (_thread.lock のメソッド):    _thread --- 低水準なスレッド API.
                                                             (line  173)
* locked() (asyncio.Condition のメソッド): Condition.        (line   63)
* locked() (asyncio.Lock のメソッド):    Lock.               (line   60)
* locked() (asyncio.Semaphore のメソッド): Semaphore.        (line   53)
* locked() (threading.Lock のメソッド):  Lock オブジェクト.  (line   88)
* lockf() (fcntl モジュール):            fcntl --- fcntl および ioctl システムコール.
                                                             (line  159)
* lockf() (os モジュール):               ファイル記述子の操作.
                                                             (line  264)
* locking() (msvcrt モジュール):         ファイル操作関連.   (line    6)
* LockType (_thread モジュール):         _thread --- 低水準なスレッド API.
                                                             (line   27)
* LOG_ALERT (syslog モジュール):         syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* LOG_AUTH (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_AUTHPRIV (syslog モジュール):      syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_CONS (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  159)
* LOG_CRIT (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* LOG_CRON (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_DAEMON (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* log_date_time_string() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  329)
* LOG_DEBUG (syslog モジュール):         syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* LOG_EMERG (syslog モジュール):         syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* LOG_ERR (syslog モジュール):           syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* log_error() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  299)
* log_exception() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  208)
* LOG_FTP (syslog モジュール):           syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_INFO (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* LOG_INSTALL (syslog モジュール):       syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_KERN (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LAUNCHD (syslog モジュール):       syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL0 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL1 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL2 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL3 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL4 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL5 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL6 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LOCAL7 (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_LPR (syslog モジュール):           syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_MAIL (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* log_message() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  305)
* LOG_NDELAY (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  159)
* LOG_NETINFO (syslog モジュール):       syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_NEWS (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_NOTICE (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* LOG_NOWAIT (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  159)
* LOG_ODELAY (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  159)
* LOG_PERROR (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  159)
* LOG_PID (syslog モジュール):           syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  159)
* LOG_RAS (syslog モジュール):           syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_REMOTEAUTH (syslog モジュール):    syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* log_request() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  292)
* LOG_SYSLOG (syslog モジュール):        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* log_to_stderr() (multiprocessing モジュール): ログ記録<2>. (line   24)
* LOG_USER (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_UUCP (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  124)
* LOG_WARNING (syslog モジュール):       syslog --- Unix syslog ライブラリルーチン群.
                                                             (line  113)
* log() (cmath モジュール):              指数関数と対数関数<2>.
                                                             (line   10)
* log() (logging モジュール):            モジュールレベルの関数.
                                                             (line   98)
* log() (logging.Logger のメソッド):     ロガーオブジェクト. (line  302)
* log() (math モジュール):               指数関数と対数関数. (line   40)
* log10() (cmath モジュール):            指数関数と対数関数<2>.
                                                             (line   16)
* log10() (decimal.Context のメソッド):  Context オブジェクト.
                                                             (line  357)
* log10() (decimal.Decimal のメソッド):  Decimal オブジェクト.
                                                             (line  325)
* log10() (math モジュール):             指数関数と対数関数. (line   65)
* log1p() (math モジュール):             指数関数と対数関数. (line   47)
* log2() (math モジュール):              指数関数と対数関数. (line   52)
* logb() (decimal.Context のメソッド):   Context オブジェクト.
                                                             (line  361)
* logb() (decimal.Decimal のメソッド):   Decimal オブジェクト.
                                                             (line  330)
* Logger (logging のクラス):             ロガーオブジェクト. (line   23)
* LoggerAdapter (logging のクラス):      LoggerAdapter オブジェクト.
                                                             (line   10)
* logical_and() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  365)
* logical_and() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  338)
* logical_invert() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  369)
* logical_invert() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  344)
* logical_or() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  373)
* logical_or() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  349)
* logical_xor() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  377)
* logical_xor() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  355)
* login_cram_md5() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  139)
* login_tty() (os モジュール):           ファイル記述子の操作.
                                                             (line  290)
* login() (ftplib.FTP のメソッド):       FTP オブジェクト.   (line  127)
* login() (imaplib.IMAP4 のメソッド):    IMAP4 オブジェクト. (line  134)
* login() (smtplib.SMTP のメソッド):     SMTP オブジェクト.  (line   98)
* LOGNAME:                               プロセスのパラメーター.
                                                             (line  235)
* LOGNAME <1>:                           getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   42)
* lognormvariate() (random モジュール):  実数分布.           (line   72)
* logout() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  145)
* LogRecord (logging のクラス):          LogRecord オブジェクト.
                                                             (line   11)
* LONG_MAX (C macro):                    整数型オブジェクト integer object.
                                                             (line  139)
* LONG_TIMEOUT (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line   93)
* longMessage (unittest.TestCase の属性): テストクラス.      (line  702)
* longname() (curses モジュール):        関数<6>.            (line  273)
* lookup_error() (codecs モジュール):    エラーハンドラ.     (line  125)
* lookup() (codecs モジュール):          codecs --- codec レジストリと基底クラス.
                                                             (line   47)
* lookup() (symtable.SymbolTable のメソッド): 記号表の検査.  (line  110)
* lookup() (tkinter.ttk.Style のメソッド): Ttk スタイル.     (line   82)
* lookup() (unicodedata モジュール):     unicodedata --- Unicode データベース.
                                                             (line   16)
* LookupError:                           基底クラス.         (line   79)
* loop control;target:                   break 文.           (line   12)
* loop_factory (unittest.IsolatedAsyncioTestCase の属性): テストクラス.
                                                             (line  855)
* loop;over mutable sequence:            共通のシーケンス演算.
                                                             (line   69)
* loop;statement:                        break 文.           (line    6)
* loop;statement <1>:                    continue 文.        (line    6)
* loop;statement <2>:                    while 文.           (line    6)
* loop;statement <3>:                    for 文<2>.          (line    6)
* LOOPBACK_TIMEOUT (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line   48)
* lower() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  627)
* lower() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  627)
* lower() (str のメソッド):              文字列メソッド<2>.  (line  305)
* LPAR (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   51)
* lpAttributeList (subprocess.STARTUPINFO の属性): Windows Popen ヘルパー.
                                                             (line   60)
* lru_cache() (functools モジュール):    functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  144)
* lseek() (os モジュール):               ファイル記述子の操作.
                                                             (line  301)
* LShift (ast のクラス):                 式 expression<2>.   (line   55)
* lshift() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line  105)
* LSQB (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   59)
* lstat() (os モジュール):               ファイルとディレクトリ.
                                                             (line  488)
* lstat() (pathlib.Path のメソッド):     ファイルの種類とステータスを問い合わせる.
                                                             (line   32)
* lstrip() (bytearray のメソッド):       bytes と bytearray の操作.
                                                             (line  315)
* lstrip() (bytes のメソッド):           bytes と bytearray の操作.
                                                             (line  315)
* lstrip() (str のメソッド):             文字列メソッド<2>.  (line  313)
* lsub() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line  152)
* Lt (ast のクラス):                     式 expression<2>.   (line  110)
* lt() (operator モジュール):            operator --- 関数形式の標準演算子.
                                                             (line   23)
* lt() (turtle モジュール):              Turtle の動き.      (line   57)
* LtE (ast のクラス):                    式 expression<2>.   (line  110)
* LWPCookieJar (http.cookiejar のクラス): FileCookieJar のサブクラスと web ブラウザとの連携.
                                                             (line   28)
* LZMACompressor (lzma のクラス):        メモリ上での圧縮と展開.
                                                             (line    6)
* LZMADecompressor (lzma のクラス):      メモリ上での圧縮と展開.
                                                             (line   91)
* LZMAError:                             lzma --- LZMA アルゴリズムを使用した圧縮.
                                                             (line   23)
* LZMAFile (lzma のクラス):              圧縮ファイルへの読み書き.
                                                             (line   45)
* M (re モジュール):                     フラグ.             (line   80)
* mac_ver() (platform モジュール):       macOS プラットフォーム.
                                                             (line    6)
* machine() (platform モジュール):       クロスプラットフォーム.
                                                             (line   34)
* macros (netrc.netrc の属性):           netrc オブジェクト. (line   31)
* MADV_AUTOSYNC (mmap モジュール):       MADV_* 定数.        (line    6)
* MADV_CORE (mmap モジュール):           MADV_* 定数.        (line    6)
* MADV_DODUMP (mmap モジュール):         MADV_* 定数.        (line    6)
* MADV_DOFORK (mmap モジュール):         MADV_* 定数.        (line    6)
* MADV_DONTDUMP (mmap モジュール):       MADV_* 定数.        (line    6)
* MADV_DONTFORK (mmap モジュール):       MADV_* 定数.        (line    6)
* MADV_DONTNEED (mmap モジュール):       MADV_* 定数.        (line    6)
* MADV_FREE (mmap モジュール):           MADV_* 定数.        (line    6)
* MADV_FREE_REUSABLE (mmap モジュール):  MADV_* 定数.        (line    6)
* MADV_FREE_REUSE (mmap モジュール):     MADV_* 定数.        (line    6)
* MADV_HUGEPAGE (mmap モジュール):       MADV_* 定数.        (line    6)
* MADV_HWPOISON (mmap モジュール):       MADV_* 定数.        (line    6)
* MADV_MERGEABLE (mmap モジュール):      MADV_* 定数.        (line    6)
* MADV_NOCORE (mmap モジュール):         MADV_* 定数.        (line    6)
* MADV_NOHUGEPAGE (mmap モジュール):     MADV_* 定数.        (line    6)
* MADV_NORMAL (mmap モジュール):         MADV_* 定数.        (line    6)
* MADV_NOSYNC (mmap モジュール):         MADV_* 定数.        (line    6)
* MADV_PROTECT (mmap モジュール):        MADV_* 定数.        (line    6)
* MADV_RANDOM (mmap モジュール):         MADV_* 定数.        (line    6)
* MADV_REMOVE (mmap モジュール):         MADV_* 定数.        (line    6)
* MADV_SEQUENTIAL (mmap モジュール):     MADV_* 定数.        (line    6)
* MADV_SOFT_OFFLINE (mmap モジュール):   MADV_* 定数.        (line    6)
* MADV_UNMERGEABLE (mmap モジュール):    MADV_* 定数.        (line    6)
* MADV_WILLNEED (mmap モジュール):       MADV_* 定数.        (line    6)
* madvise() (mmap.mmap のメソッド):      mmap --- メモリマップファイルのサポート.
                                                             (line  225)
* magic method:                          用語集<2>.          (line  912)
* MAGIC_NUMBER (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line   13)
* magic;メソッド:                        用語集<2>.          (line  916)
* MagicMock (unittest.mock のクラス):    Magic Mock.         (line    9)
* Mailbox (mailbox のクラス):            Mailbox オブジェクト.
                                                             (line    6)
* Maildir (mailbox のクラス):            Maildir オブジェクト.
                                                             (line    6)
* MaildirMessage (mailbox のクラス):     MaildirMessage オブジェクト.
                                                             (line    6)
* main_thread() (threading モジュール):  threading --- スレッドベースの並列処理.
                                                             (line  148)
* main():                                プロセスワイドのパラメータ.
                                                             (line    7)
* main() <1>:                            プロセスワイドのパラメータ.
                                                             (line  216)
* main() <2>:                            PyConfig.           (line  129)
* main() (site モジュール):              モジュールの内容<5>.
                                                             (line   43)
* main() (unittest モジュール):          テストのロードと起動.
                                                             (line  506)
* mainloop() (turtle モジュール):        スクリーンイベントを利用する.
                                                             (line  105)
* maintype (email.headerregistry.ContentTypeHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  270)
* major (email.headerregistry.MIMEVersionHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  241)
* major() (os モジュール):               ファイルとディレクトリ.
                                                             (line  641)
* make_alternative() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  608)
* make_archive() (shutil モジュール):    アーカイブ化操作.   (line   14)
* make_bad_fd() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  105)
* MAKE_CELL (opcode):                    Python バイトコード命令.
                                                             (line  950)
* make_cookies() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   63)
* make_dataclass() (dataclasses モジュール): モジュールの内容<4>.
                                                             (line  379)
* make_file() (difflib.HtmlDiff のメソッド): difflib --- 差分の計算の補助.
                                                             (line  109)
* MAKE_FUNCTION (opcode):                Python バイトコード命令.
                                                             (line 1089)
* make_header() (email.header モジュール): email header 国際化されたヘッダー.
                                                             (line  193)
* make_legacy_pyc() (test.support.import_helper モジュール): test support import_helper --- Utilities for import tests.
                                                             (line   80)
* make_mixed() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  618)
* make_msgid() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line   27)
* make_parser() (xml.sax モジュール):    xml sax --- SAX2 バーサーのサポート.
                                                             (line   30)
* make_pkg() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   97)
* make_related() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  599)
* make_script() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   82)
* make_server() (wsgiref.simple_server モジュール): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   14)
* make_table() (difflib.HtmlDiff のメソッド): difflib --- 差分の計算の補助.
                                                             (line  140)
* make_zip_pkg() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line  103)
* make_zip_script() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   89)
* makedev() (os モジュール):             ファイルとディレクトリ.
                                                             (line  651)
* makedirs() (os モジュール):            ファイルとディレクトリ.
                                                             (line  556)
* makeelement() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  160)
* makefile() (socket のメソッド):        I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* makefile() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  212)
* makeLogRecord() (logging モジュール):  モジュールレベルの関数.
                                                             (line  189)
* makePickle() (logging.handlers.SocketHandler のメソッド): SocketHandler.
                                                             (line   45)
* makeRecord() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  364)
* makeSocket() (logging.handlers.DatagramHandler のメソッド): DatagramHandler.
                                                             (line   38)
* makeSocket() (logging.handlers.SocketHandler のメソッド): SocketHandler.
                                                             (line   39)
* maketrans() (bytearray の静的メソッド): bytes と bytearray の操作.
                                                             (line  177)
* maketrans() (bytes の静的メソッド):    bytes と bytearray の操作.
                                                             (line  177)
* maketrans() (str の静的メソッド):      文字列メソッド<2>.  (line  334)
* malloc (C function):                   概要<4>.            (line   33)
* manager (logging.LoggerAdapter の属性): LoggerAdapter オブジェクト.
                                                             (line   29)
* mangle_from_ (email.policy.Compat32 の属性): email policy Policy Objects.
                                                             (line  572)
* mangle_from_ (email.policy.Policy の属性): email policy Policy Objects.
                                                             (line  185)
* MANPAGER:                              pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line   46)
* MANPAGER <1>:                          pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line   48)
* mant_dig (sys.float_info の属性):      sys --- システム固有のパラメーターと関数.
                                                             (line  617)
* MAP_32BIT (mmap モジュール):           MAP_* 定数.         (line    6)
* MAP_ADD (opcode):                      Python バイトコード命令.
                                                             (line  381)
* MAP_ALIGNED_SUPER (mmap モジュール):   MAP_* 定数.         (line    6)
* MAP_ANON (mmap モジュール):            MAP_* 定数.         (line    6)
* MAP_ANONYMOUS (mmap モジュール):       MAP_* 定数.         (line    6)
* map_async() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  112)
* MAP_CONCEAL (mmap モジュール):         MAP_* 定数.         (line    6)
* MAP_DENYWRITE (mmap モジュール):       MAP_* 定数.         (line    6)
* MAP_EXECUTABLE (mmap モジュール):      MAP_* 定数.         (line    6)
* MAP_HASSEMAPHORE (mmap モジュール):    MAP_* 定数.         (line    6)
* MAP_JIT (mmap モジュール):             MAP_* 定数.         (line    6)
* MAP_NOCACHE (mmap モジュール):         MAP_* 定数.         (line    6)
* MAP_NOEXTEND (mmap モジュール):        MAP_* 定数.         (line    6)
* MAP_NORESERVE (mmap モジュール):       MAP_* 定数.         (line    6)
* MAP_POPULATE (mmap モジュール):        MAP_* 定数.         (line    6)
* MAP_PRIVATE (mmap モジュール):         MAP_* 定数.         (line    6)
* MAP_RESILIENT_CODESIGN (mmap モジュール): MAP_* 定数.      (line    6)
* MAP_RESILIENT_MEDIA (mmap モジュール): MAP_* 定数.         (line    6)
* MAP_SHARED (mmap モジュール):          MAP_* 定数.         (line    6)
* MAP_STACK (mmap モジュール):           MAP_* 定数.         (line    6)
* map_table_b2() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   50)
* map_table_b3() (stringprep モジュール): stringprep --- インターネットの文字列調製.
                                                             (line   55)
* map_to_type() (email.headerregistry.HeaderRegistry のメソッド): email headerregistry Custom Header Objects.
                                                             (line  371)
* MAP_TPRO (mmap モジュール):            MAP_* 定数.         (line    6)
* MAP_TRANSLATED_ALLOW_EXECUTE (mmap モジュール): MAP_* 定数.
                                                             (line    6)
* MAP_UNIX03 (mmap モジュール):          MAP_* 定数.         (line    6)
* map() (concurrent.futures.Executor のメソッド): Executor オブジェクト.
                                                             (line   21)
* map() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line   95)
* map() (tkinter.ttk.Style のメソッド):  Ttk スタイル.       (line   49)
* mapLogRecord() (logging.handlers.HTTPHandler のメソッド): HTTPHandler.
                                                             (line   26)
* mapping:                               用語集<2>.          (line  916)
* Mapping (collections.abc のクラス):    コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   98)
* Mapping (typing のクラス):             Aliases to container ABCs in collections abc.
                                                             (line   58)
* MappingProxyType (types のクラス):     標準的なインタプリタ型.
                                                             (line  223)
* MappingView (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  104)
* MappingView (typing のクラス):         Aliases to container ABCs in collections abc.
                                                             (line   66)
* mapPriority() (logging.handlers.SysLogHandler のメソッド): SysLogHandler.
                                                             (line  199)
* maps (collections.ChainMap の属性):    ChainMap オブジェクト.
                                                             (line   37)
* MARCH (calendar モジュール):           calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* markcoroutinefunction() (inspect モジュール): 型とメンバー.
                                                             (line  408)
* master (tkinter.Tk の属性):            Tkinter モジュール. (line   77)
* Match (ast のクラス):                  Pattern matching.   (line    6)
* Match (re のクラス):                   マッチオブジェクト. (line   14)
* Match (typing のクラス):               Aliases to other concrete types.
                                                             (line    6)
* match_case (ast のクラス):             Pattern matching.   (line   15)
* MATCH_CLASS (opcode):                  Python バイトコード命令.
                                                             (line 1191)
* MATCH_KEYS (opcode):                   Python バイトコード命令.
                                                             (line  541)
* MATCH_MAPPING (opcode):                Python バイトコード命令.
                                                             (line  522)
* MATCH_SEQUENCE (opcode):               Python バイトコード命令.
                                                             (line  531)
* match_value() (test.support.Matcher のメソッド): test support --- テストのためのユーティリティ関数.
                                                             (line  789)
* match;case:                            match 文<2>.        (line    6)
* match() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  286)
* match() (re モジュール):               関数<2>.            (line   46)
* match() (re.Pattern のメソッド):       正規表現オブジェクト.
                                                             (line   41)
* MatchAs (ast のクラス):                Pattern matching.   (line  293)
* MatchClass (ast のクラス):             Pattern matching.   (line  230)
* Matcher (test.support のクラス):       test support --- テストのためのユーティリティ関数.
                                                             (line  783)
* matches() (test.support.Matcher のメソッド): test support --- テストのためのユーティリティ関数.
                                                             (line  785)
* MatchMapping (ast のクラス):           Pattern matching.   (line  184)
* MatchOr (ast のクラス):                Pattern matching.   (line  333)
* MatchSequence (ast のクラス):          Pattern matching.   (line  114)
* MatchSingleton (ast のクラス):         Pattern matching.   (line   90)
* MatchStar (ast のクラス):              Pattern matching.   (line  144)
* MatchValue (ast のクラス):             Pattern matching.   (line   63)
* matmul() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line  120)
* MatMult (ast のクラス):                式 expression<2>.   (line   55)
* matrix multiplication:                 二項算術演算 binary arithmetic operation.
                                                             (line   25)
* max (datetime.date の属性):            date オブジェクト.  (line  102)
* max (datetime.datetime の属性):        datetime オブジェクト.
                                                             (line  290)
* max (datetime.time の属性):            time オブジェクト.  (line   37)
* max (datetime.timedelta の属性):       timedelta オブジェクト.
                                                             (line   75)
* max (sys.float_info の属性):           sys --- システム固有のパラメーターと関数.
                                                             (line  622)
* max_10_exp (sys.float_info の属性):    sys --- システム固有のパラメーターと関数.
                                                             (line  631)
* max_count (email.headerregistry.BaseHeader の属性): email headerregistry Custom Header Objects.
                                                             (line   61)
* MAX_EMAX (decimal モジュール):         定数<4>.            (line   16)
* max_exp (sys.float_info の属性):       sys --- システム固有のパラメーターと関数.
                                                             (line  626)
* MAX_INTERPOLATION_DEPTH (configparser モジュール): ConfigParser オブジェクト.
                                                             (line  334)
* max_line_length (email.policy.Policy の属性): email policy Policy Objects.
                                                             (line  144)
* max_lines (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  260)
* max_mag() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  385)
* max_mag() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  368)
* max_memuse (test.support モジュール):  test support --- テストのためのユーティリティ関数.
                                                             (line  146)
* MAX_PREC (decimal モジュール):         定数<4>.            (line   13)
* max_prefixlen (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   48)
* max_prefixlen (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   62)
* max_prefixlen (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  258)
* max_prefixlen (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  295)
* MAX_Py_ssize_t (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  141)
* max() (decimal.Context のメソッド):    Context オブジェクト.
                                                             (line  381)
* max() (decimal.Decimal のメソッド):    Decimal オブジェクト.
                                                             (line  361)
* maxarray (reprlib.Repr の属性):        Reprオブジェクト.   (line   21)
* maxdeque (reprlib.Repr の属性):        Reprオブジェクト.   (line   21)
* maxdict (reprlib.Repr の属性):         Reprオブジェクト.   (line   21)
* maxDiff (unittest.TestCase の属性):    テストクラス.       (line  720)
* maxfrozenset (reprlib.Repr の属性):    Reprオブジェクト.   (line   21)
* MAXIMUM_SUPPORTED (ssl.TLSVersion の属性): 定数<9>.        (line  566)
* maximum_version (ssl.SSLContext の属性): SSL コンテキスト. (line  538)
* maxlen (collections.deque の属性):     deque オブジェクト. (line  121)
* maxlevel (reprlib.Repr の属性):        Reprオブジェクト.   (line   17)
* maxlist (reprlib.Repr の属性):         Reprオブジェクト.   (line   21)
* maxlong (reprlib.Repr の属性):         Reprオブジェクト.   (line   33)
* maxother (reprlib.Repr の属性):        Reprオブジェクト.   (line   45)
* maxset (reprlib.Repr の属性):          Reprオブジェクト.   (line   21)
* maxsize (asyncio.Queue の属性):        Queue.              (line   22)
* maxsize (sys モジュール):              sys --- システム固有のパラメーターと関数.
                                                             (line 1221)
* maxstring (reprlib.Repr の属性):       Reprオブジェクト.   (line   38)
* maxtuple (reprlib.Repr の属性):        Reprオブジェクト.   (line   21)
* maxunicode (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1227)
* MAXYEAR (datetime モジュール):         定数.               (line   13)
* MAY (calendar モジュール):             calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* MB_ICONASTERISK (winsound モジュール): winsound --- Windows 用の音声再生インターフェース.
                                                             (line  134)
* MB_ICONEXCLAMATION (winsound モジュール): winsound --- Windows 用の音声再生インターフェース.
                                                             (line  138)
* MB_ICONHAND (winsound モジュール):     winsound --- Windows 用の音声再生インターフェース.
                                                             (line  142)
* MB_ICONQUESTION (winsound モジュール): winsound --- Windows 用の音声再生インターフェース.
                                                             (line  146)
* MB_OK (winsound モジュール):           winsound --- Windows 用の音声再生インターフェース.
                                                             (line  150)
* mbox (mailbox のクラス):               mbox オブジェクト.  (line    6)
* mboxMessage (mailbox のクラス):        mboxMessage オブジェクト.
                                                             (line    6)
* md5() (hashlib モジュール):            Constructors.       (line   20)
* mean (statistics.NormalDist の属性):   NormalDist オブジェクト.
                                                             (line   21)
* mean() (statistics モジュール):        関数の詳細.         (line    9)
* measure() (tkinter.font.Font のメソッド): tkinter font --- Tkinter フォントラッパー.
                                                             (line   63)
* median (statistics.NormalDist の属性): NormalDist オブジェクト.
                                                             (line   26)
* median_grouped() (statistics モジュール): 関数の詳細.      (line  265)
* median_high() (statistics モジュール): 関数の詳細.         (line  248)
* median_low() (statistics モジュール):  関数の詳細.         (line  231)
* median() (statistics モジュール):      関数の詳細.         (line  205)
* member() (enum モジュール):            ユーティリティとデコレータ.
                                                             (line   80)
* MemberDescriptorType (types モジュール): 標準的なインタプリタ型.
                                                             (line  207)
* memfd_create() (os モジュール):        ファイルとディレクトリ.
                                                             (line 1831)
* memmove() (ctypes モジュール):         ユーティリティー関数.
                                                             (line  134)
* MemoryBIO (ssl のクラス):              メモリ BIO サポート<2>.
                                                             (line  132)
* MemoryError:                           具象例外.           (line   98)
* MemoryHandler (logging.handlers のクラス): MemoryHandler.  (line   42)
* memoryview (組み込みクラス):           メモリビュー.       (line   10)
* memset() (ctypes モジュール):          ユーティリティー関数.
                                                             (line  140)
* merge() (heapq モジュール):            heapq --- ヒープキューアルゴリズム.
                                                             (line   77)
* message (BaseExceptionGroup の属性):   例外グループ.       (line   30)
* Message (email.message のクラス):      email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line   49)
* Message (mailbox のクラス):            Message オブジェクト.
                                                             (line    6)
* Message (tkinter.messagebox のクラス): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line   21)
* message digest, MD5:                   hashlib --- セキュアハッシュとメッセージダイジェスト.
                                                             (line    8)
* message_factory (email.policy.Policy の属性): email policy Policy Objects.
                                                             (line  194)
* message_from_binary_file() (email モジュール): Parser API. (line  133)
* message_from_bytes() (email モジュール): Parser API.       (line  120)
* message_from_file() (email モジュール): Parser API.        (line  156)
* message_from_string() (email モジュール): Parser API.      (line  146)
* MessageBeep() (winsound モジュール):   winsound --- Windows 用の音声再生インターフェース.
                                                             (line   31)
* MessageClass (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  174)
* MessageDefect:                         email errors Exception and Defect classes.
                                                             (line   62)
* MessageError:                          email errors Exception and Defect classes.
                                                             (line   13)
* MessageParseError:                     email errors Exception and Defect classes.
                                                             (line   19)
* messages (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   21)
* meta hooks:                            インポートフック.   (line    6)
* meta path finder:                      用語集<2>.          (line  926)
* meta_path (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line 1236)
* meta() (curses モジュール):            関数<6>.            (line  280)
* metaclass:                             メタクラス.         (line    6)
* metaclass <1>:                         用語集<2>.          (line  935)
* metaclass hint:                        適切なメタクラスの決定.
                                                             (line    6)
* metadata() (importlib.metadata モジュール): 配布物メタデータ.
                                                             (line    6)
* MetaPathFinder (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   26)
* metavar (optparse.Option の属性):      オプション属性.     (line   89)
* MetavarTypeHelpFormatter (argparse のクラス): formatter_class.
                                                             (line   10)
* METH_CLASS (C macro):                  Implementing functions and methods.
                                                             (line  195)
* METH_COEXIST (C macro):                Implementing functions and methods.
                                                             (line  211)
* METH_FASTCALL (C macro):               Implementing functions and methods.
                                                             (line  124)
* METH_KEYWORDS (C macro):               Implementing functions and methods.
                                                             (line  108)
* METH_METHOD (C macro):                 Implementing functions and methods.
                                                             (line  151)
* METH_NOARGS (C macro):                 Implementing functions and methods.
                                                             (line  169)
* METH_O (C macro):                      Implementing functions and methods.
                                                             (line  182)
* METH_STATIC (C macro):                 Implementing functions and methods.
                                                             (line  202)
* METH_VARARGS (C macro):                Implementing functions and methods.
                                                             (line   98)
* method (urllib.request.Request の属性): Request オブジェクト.
                                                             (line   53)
* method resolution order:               用語集<2>.          (line  958)
* method_calls (unittest.mock.Mock の属性): Mock クラス.     (line  478)
* methodcaller() (operator モジュール):  operator --- 関数形式の標準演算子.
                                                             (line  314)
* MethodDescriptorType (types モジュール): 標準的なインタプリタ型.
                                                             (line  108)
* methodHelp() (xmlrpc.client.ServerProxy.system のメソッド): ServerProxy オブジェクト.
                                                             (line   38)
* methods (pyclbr.Class の属性):         クラスオブジェクト<2>.
                                                             (line   50)
* methodSignature() (xmlrpc.client.ServerProxy.system のメソッド): ServerProxy オブジェクト.
                                                             (line   21)
* MethodType (in module types):          Function オブジェクト<3>.
                                                             (line   14)
* MethodType (in module types) <1>:      メソッドオブジェクト<2>.
                                                             (line   12)
* MethodType (types モジュール):         標準的なインタプリタ型.
                                                             (line   76)
* MethodWrapperType (types モジュール):  標準的なインタプリタ型.
                                                             (line   95)
* metrics() (tkinter.font.Font のメソッド): tkinter font --- Tkinter フォントラッパー.
                                                             (line   69)
* MFD_ALLOW_SEALING (os モジュール):     ファイルとディレクトリ.
                                                             (line 1849)
* MFD_CLOEXEC (os モジュール):           ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_16GB (os モジュール):         ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_16MB (os モジュール):         ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_1GB (os モジュール):          ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_1MB (os モジュール):          ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_256MB (os モジュール):        ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_2GB (os モジュール):          ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_2MB (os モジュール):          ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_32MB (os モジュール):         ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_512KB (os モジュール):        ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_512MB (os モジュール):        ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_64KB (os モジュール):         ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_8MB (os モジュール):          ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_MASK (os モジュール):         ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGE_SHIFT (os モジュール):        ファイルとディレクトリ.
                                                             (line 1849)
* MFD_HUGETLB (os モジュール):           ファイルとディレクトリ.
                                                             (line 1849)
* MH (mailbox のクラス):                 MH オブジェクト.    (line    6)
* MHMessage (mailbox のクラス):          MHMessage オブジェクト.
                                                             (line    6)
* microsecond (datetime.datetime の属性): datetime オブジェクト.
                                                             (line  327)
* microsecond (datetime.time の属性):    time オブジェクト.  (line   62)
* microseconds (datetime.timedelta の属性): timedelta オブジェクト.
                                                             (line  111)
* MIME;base64 encoding:                  base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line    8)
* MIME;content type:                     mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line    8)
* MIME;quoted-printable encoding:        quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line    8)
* MIME;ヘッダー:                         mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line   26)
* MIME;ヘッダー <1>:                     mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line   57)
* MIMEApplication (email.mime.application のクラス): email mime Creating email and MIME objects from scratch.
                                                             (line  101)
* MIMEAudio (email.mime.audio のクラス): email mime Creating email and MIME objects from scratch.
                                                             (line  131)
* MIMEBase (email.mime.base のクラス):   email mime Creating email and MIME objects from scratch.
                                                             (line   33)
* MIMEImage (email.mime.image のクラス): email mime Creating email and MIME objects from scratch.
                                                             (line  164)
* MIMEMessage (email.mime.message のクラス): email mime Creating email and MIME objects from scratch.
                                                             (line  197)
* MIMEMultipart (email.mime.multipart のクラス): email mime Creating email and MIME objects from scratch.
                                                             (line   71)
* MIMENonMultipart (email.mime.nonmultipart のクラス): email mime Creating email and MIME objects from scratch.
                                                             (line   60)
* MIMEPart (email.message のクラス):     email message Representing an email message.
                                                             (line  721)
* MIMEText (email.mime.text のクラス):   email mime Creating email and MIME objects from scratch.
                                                             (line  217)
* MimeTypes (mimetypes のクラス):        Mime 型オブジェクト.
                                                             (line   10)
* MIMEVersionHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  229)
* min (datetime.date の属性):            date オブジェクト.  (line   98)
* min (datetime.datetime の属性):        datetime オブジェクト.
                                                             (line  285)
* min (datetime.time の属性):            time オブジェクト.  (line   33)
* min (datetime.timedelta の属性):       timedelta オブジェクト.
                                                             (line   70)
* min (sys.float_info の属性):           sys --- システム固有のパラメーターと関数.
                                                             (line  636)
* min_10_exp (sys.float_info の属性):    sys --- システム固有のパラメーターと関数.
                                                             (line  649)
* MIN_EMIN (decimal モジュール):         定数<4>.            (line   19)
* MIN_ETINY (decimal モジュール):        定数<4>.            (line   22)
* min_exp (sys.float_info の属性):       sys --- システム固有のパラメーターと関数.
                                                             (line  644)
* min_mag() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  393)
* min_mag() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  380)
* min() (decimal.Context のメソッド):    Context オブジェクト.
                                                             (line  389)
* min() (decimal.Decimal のメソッド):    Decimal オブジェクト.
                                                             (line  373)
* MINEQUAL (token モジュール):           token --- Python 解析木で使われる定数.
                                                             (line  171)
* MINIMUM_SUPPORTED (ssl.TLSVersion の属性): 定数<9>.        (line  564)
* minimum_version (ssl.SSLContext の属性): SSL コンテキスト. (line  556)
* minor (email.headerregistry.MIMEVersionHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  245)
* minor() (os モジュール):               ファイルとディレクトリ.
                                                             (line  646)
* MINUS (token モジュール):              token --- Python 解析木で使われる定数.
                                                             (line   83)
* minus() (decimal.Context のメソッド):  Context オブジェクト.
                                                             (line  397)
* minute (datetime.datetime の属性):     datetime オブジェクト.
                                                             (line  319)
* minute (datetime.time の属性):         time オブジェクト.  (line   54)
* MINYEAR (datetime モジュール):         定数.               (line    8)
* mirrored() (unicodedata モジュール):   unicodedata --- Unicode データベース.
                                                             (line   68)
* misc_header (cmd.Cmd の属性):          Cmdオブジェクト.    (line  158)
* MISSING (contextvars.Token の属性):    コンテキスト変数.   (line   92)
* MISSING (dataclasses モジュール):      モジュールの内容<4>.
                                                             (line  464)
* MISSING (sys.monitoring モジュール):   Callback function arguments.
                                                             (line    6)
* MISSING_C_DOCSTRINGS (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  158)
* missing_compiler_executable() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  672)
* MissingSectionHeaderError:             例外<8>.            (line   56)
* mkd() (ftplib.FTP のメソッド):         FTP オブジェクト.   (line  338)
* mkdir() (os モジュール):               ファイルとディレクトリ.
                                                             (line  521)
* mkdir() (pathlib.Path のメソッド):     ファイルとディレクトリの作成.
                                                             (line   21)
* mkdir() (zipfile.ZipFile のメソッド):  ZipFile オブジェクト.
                                                             (line  346)
* mkdtemp() (tempfile モジュール):       tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  286)
* mkfifo() (os モジュール):              ファイルとディレクトリ.
                                                             (line  596)
* mknod() (os モジュール):               ファイルとディレクトリ.
                                                             (line  619)
* mkstemp() (tempfile モジュール):       tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  229)
* mktemp() (tempfile モジュール):        非推奨の関数と変数. (line   14)
* mktime_tz() (email.utils モジュール):  email utils Miscellaneous utilities.
                                                             (line  145)
* mktime() (time モジュール):            関数<5>.            (line  162)
* mlsd() (ftplib.FTP のメソッド):        FTP オブジェクト.   (line  283)
* mmap (mmap のクラス):                  mmap --- メモリマップファイルのサポート.
                                                             (line   54)
* MMDF (mailbox のクラス):               MMDF オブジェクト.  (line    6)
* MMDFMessage (mailbox のクラス):        MMDFMessage オブジェクト.
                                                             (line    6)
* Mock (unittest.mock のクラス):         Mock クラス.        (line   23)
* mock_add_spec() (unittest.mock.Mock のメソッド): Mock クラス.
                                                             (line  229)
* mock_calls (unittest.mock.Mock の属性): Mock クラス.       (line  495)
* mock_open() (unittest.mock モジュール): mock_open.         (line    6)
* Mod (ast のクラス):                    式 expression<2>.   (line   55)
* mod() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  110)
* mode (bz2.BZ2File の属性):             ファイルの圧縮/解凍.
                                                             (line  128)
* mode (gzip.GzipFile の属性):           gzip --- gzip ファイルのサポート.
                                                             (line  144)
* mode (io.FileIO の属性):               生ファイルI/O.      (line   55)
* mode (lzma.LZMAFile の属性):           圧縮ファイルへの読み書き.
                                                             (line   98)
* mode (statistics.NormalDist の属性):   NormalDist オブジェクト.
                                                             (line   31)
* mode (tarfile.TarInfo の属性):         TarInfo オブジェクト.
                                                             (line   79)
* mode() (statistics モジュール):        関数の詳細.         (line  314)
* mode() (turtle モジュール):            設定と特殊なメソッド.
                                                             (line    6)
* modf() (math モジュール):              数論および数表現の関数.
                                                             (line  192)
* modified() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   45)
* modify() (select.devpoll のメソッド):  /dev/poll ポーリングオブジェクト.
                                                             (line   49)
* modify() (select.epoll のメソッド):    エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   86)
* modify() (select.poll のメソッド):     ポーリングオブジェクト.
                                                             (line   60)
* modify() (selectors.BaseSelector のメソッド): クラス<4>.   (line   97)
* module:                                用語集<2>.          (line  965)
* Module (ast のクラス):                 Root nodes.         (line    6)
* module (pyclbr.Class の属性):          クラスオブジェクト<2>.
                                                             (line   16)
* module (pyclbr.Function の属性):       Function オブジェクト.
                                                             (line   15)
* MODULE (symtable.SymbolTableType の属性): 記号表の検査.    (line   11)
* Module browser:                        File メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   23)
* module spec:                           ファインダーとローダー.
                                                             (line    6)
* module spec <1>:                       用語集<2>.          (line  974)
* module_from_spec() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line  125)
* module; __future__:                    __future__ --- future 文の定義.
                                                             (line    6)
* module; __main__:                      __main__ --- トップレベルのコード環境.
                                                             (line    6)
* module; _thread:                       _thread --- 低水準なスレッド API.
                                                             (line    6)
* module; _tkinter:                      Tkinter モジュール. (line  150)
* module; abc:                           abc --- 抽象基底クラス.
                                                             (line    6)
* module; argparse:                      argparse --- Parser for command-line options arguments and subcommands.
                                                             (line    6)
* module; array:                         array --- 効率的な数値配列.
                                                             (line    6)
* module; ast:                           ast --- 抽象構文木. (line    6)
* module; asyncio:                       asyncio --- 非同期 I/O.
                                                             (line    6)
* module; atexit:                        atexit --- 終了ハンドラー.
                                                             (line    6)
* module; base64:                        base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line    6)
* module; bdb:                           bdb --- デバッガーフレームワーク.
                                                             (line    6)
* module; binascii:                      binascii --- バイナリ と ASCII 間の変換.
                                                             (line    6)
* module; bisect:                        bisect --- 配列二分法アルゴリズム.
                                                             (line    6)
* module; builtins:                      builtins --- 組み込みオブジェクト.
                                                             (line    6)
* module; bz2:                           bz2 --- bzip2 圧縮のサポート.
                                                             (line    6)
* module; calendar:                      calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line    6)
* module; cmath:                         cmath --- 複素数用の数学関数.
                                                             (line    6)
* module; cmd:                           cmd --- 行指向のコマンドインタープリターのサポート.
                                                             (line    6)
* module; code:                          code --- インタープリター基底クラス.
                                                             (line    6)
* module; codecs:                        codecs --- codec レジストリと基底クラス.
                                                             (line    6)
* module; codeop:                        codeop --- Python コードをコンパイルする.
                                                             (line    6)
* module; collections:                   collections --- コンテナデータ型.
                                                             (line    6)
* module; collections.abc:               collections abc --- コンテナの抽象基底クラス.
                                                             (line    6)
* module; colorsys:                      colorsys --- 色体系間の変換.
                                                             (line    6)
* module; compileall:                    compileall --- Python ライブラリをバイトコンパイルする.
                                                             (line    6)
* module; concurrent.futures:            concurrent futures --- 並列タスク実行.
                                                             (line    6)
* module; configparser:                  configparser --- 設定ファイルのパーサー.
                                                             (line    6)
* module; contextlib:                    contextlib --- with 文コンテキスト用ユーティリティ.
                                                             (line    6)
* module; contextvars:                   contextvars --- コンテキスト変数.
                                                             (line    6)
* module; copy:                          copy --- 浅いコピーおよび深いコピー操作.
                                                             (line    6)
* module; copyreg:                       copyreg --- pickle サポート関数を登録する.
                                                             (line    6)
* module; cProfile:                      リファレンスマニュアル -- profile と cProfile.
                                                             (line    6)
* module; csv:                           csv --- CSV ファイルの読み書き.
                                                             (line    6)
* module; ctypes:                        ctypes --- Python 用の外部関数ライブラリ.
                                                             (line    6)
* module; curses:                        curses --- 文字セル表示のターミナル処理.
                                                             (line    6)
* module; curses.ascii:                  curses ascii --- ASCII 文字のユーティリティー.
                                                             (line    6)
* module; curses.panel:                  curses panel --- curses のためのパネルスタック拡張.
                                                             (line    6)
* module; curses.textpad:                curses textpad --- curses プログラムのためのテキスト入力ウィジェット.
                                                             (line    6)
* module; dataclasses:                   dataclasses --- データクラス.
                                                             (line    6)
* module; datetime:                      datetime --- 基本的な日付と時間の型.
                                                             (line    6)
* module; dbm:                           dbm --- Unix "データベース" へのインターフェース.
                                                             (line    6)
* module; dbm.dumb:                      dbm dumb --- 可搬性のある DBM 実装.
                                                             (line    6)
* module; dbm.gnu:                       dbm gnu --- GNU database manager.
                                                             (line    6)
* module; dbm.ndbm:                      dbm ndbm --- New Database Manager.
                                                             (line    6)
* module; dbm.sqlite3:                   dbm sqlite3 --- SQLite backend for dbm.
                                                             (line    6)
* module; decimal:                       decimal --- 10進固定小数点と浮動小数点の演算.
                                                             (line    6)
* module; difflib:                       difflib --- 差分の計算の補助.
                                                             (line    6)
* module; dis:                           dis --- Python バイトコードの逆アセンブラー.
                                                             (line    6)
* module; doctest:                       doctest --- 対話型の Python の例をテストする.
                                                             (line    6)
* module; email:                         email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line    6)
* module; email.charset:                 email charset 文字集合の表現.
                                                             (line    6)
* module; email.contentmanager:          email contentmanager Managing MIME Content.
                                                             (line    6)
* module; email.encoders:                email encoders エンコーダー.
                                                             (line    6)
* module; email.errors:                  email errors Exception and Defect classes.
                                                             (line    6)
* module; email.generator:               email generator Generating MIME documents.
                                                             (line    6)
* module; email.header:                  email header 国際化されたヘッダー.
                                                             (line    6)
* module; email.headerregistry:          email headerregistry Custom Header Objects.
                                                             (line    6)
* module; email.iterators:               email iterators イテレータ.
                                                             (line    6)
* module; email.message:                 email message Representing an email message.
                                                             (line    6)
* module; email.mime:                    email mime Creating email and MIME objects from scratch.
                                                             (line    6)
* module; email.mime.application:        email mime Creating email and MIME objects from scratch.
                                                             (line  101)
* module; email.mime.audio:              email mime Creating email and MIME objects from scratch.
                                                             (line  131)
* module; email.mime.base:               email mime Creating email and MIME objects from scratch.
                                                             (line   33)
* module; email.mime.image:              email mime Creating email and MIME objects from scratch.
                                                             (line  164)
* module; email.mime.message:            email mime Creating email and MIME objects from scratch.
                                                             (line  197)
* module; email.mime.multipart:          email mime Creating email and MIME objects from scratch.
                                                             (line   71)
* module; email.mime.nonmultipart:       email mime Creating email and MIME objects from scratch.
                                                             (line   60)
* module; email.mime.text:               email mime Creating email and MIME objects from scratch.
                                                             (line  217)
* module; email.parser:                  email parser Parsing email messages.
                                                             (line    6)
* module; email.policy:                  email policy Policy Objects.
                                                             (line    6)
* module; email.utils:                   email utils Miscellaneous utilities.
                                                             (line    6)
* module; encodings.idna:                encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line    6)
* module; encodings.mbcs:                encodings mbcs --- Windows ANSI コードページ.
                                                             (line    6)
* module; encodings.utf_8_sig:           encodings utf_8_sig --- BOM 印付き UTF-8.
                                                             (line    6)
* module; ensurepip:                     ensurepip --- pip インストーラーのブートストラップ.
                                                             (line    6)
* module; enum:                          enum --- 列挙型のサポート.
                                                             (line    6)
* module; errno:                         errno --- 標準の errno システムシンボル.
                                                             (line    6)
* module; faulthandler:                  faulthandler --- Python トレースバックをダンプする.
                                                             (line    6)
* module; fcntl:                         fcntl --- fcntl および ioctl システムコール.
                                                             (line    6)
* module; filecmp:                       filecmp --- ファイルとディレクトリの比較.
                                                             (line    6)
* module; fileinput:                     fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line    6)
* module; fnmatch:                       fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line    6)
* module; fractions:                     fractions --- 有理数.
                                                             (line    6)
* module; ftplib:                        ftplib --- FTP プロトコルクライアント.
                                                             (line    6)
* module; functools:                     functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line    6)
* module; gc:                            gc --- ガベージコレクターインターフェース.
                                                             (line    6)
* module; getopt:                        getopt --- C-style parser for command line options.
                                                             (line    6)
* module; getpass:                       getpass --- 可搬性のあるパスワード入力機構.
                                                             (line    6)
* module; gettext:                       gettext --- 多言語国際化サービス.
                                                             (line    6)
* module; glob:                          glob --- Unix 形式のパス名のパターン展開.
                                                             (line    6)
* module; graphlib:                      graphlib --- グラフ構造を操作する機能.
                                                             (line    6)
* module; grp:                           grp --- グループデータベース.
                                                             (line    6)
* module; gzip:                          gzip --- gzip ファイルのサポート.
                                                             (line    6)
* module; hashlib:                       hashlib --- セキュアハッシュとメッセージダイジェスト.
                                                             (line    6)
* module; heapq:                         heapq --- ヒープキューアルゴリズム.
                                                             (line    6)
* module; hmac:                          hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line    6)
* module; html:                          html --- HyperText Markup Language のサポート.
                                                             (line    6)
* module; html.entities:                 html entities --- HTML 一般実体の定義.
                                                             (line    6)
* module; html.parser:                   html parser --- HTML と XHTML のシンプルなパーサー.
                                                             (line    6)
* module; http:                          http --- HTTP モジュール群.
                                                             (line    6)
* module; http.client:                   http client --- HTTP プロトコルクライアント.
                                                             (line    6)
* module; http.cookiejar:                http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line    6)
* module; http.cookies:                  http cookies --- HTTP の状態管理.
                                                             (line    6)
* module; http.server:                   http server --- HTTP サーバー.
                                                             (line    6)
* module; idlelib:                       idlelib.            (line    6)
* module; imaplib:                       imaplib --- IMAP4 プロトコルクライアント.
                                                             (line    6)
* module; importlib:                     importlib --- import の実装.
                                                             (line    6)
* module; importlib.abc:                 importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line    6)
* module; importlib.machinery:           importlib machinery -- インポータおよびパスフック.
                                                             (line    6)
* module; importlib.metadata:            importlib metadata -- パッケージメタデータへのアクセス.
                                                             (line    6)
* module; importlib.resources:           importlib resources -- パッケージリソースの読み取り、オープン、アクセス.
                                                             (line    6)
* module; importlib.resources.abc:       importlib resources abc -- リソースの抽象基底クラス.
                                                             (line    6)
* module; importlib.util:                importlib util -- インポータのためのユーティリティコード.
                                                             (line    6)
* module; inspect:                       inspect --- 活動中のオブジェクトを調査する.
                                                             (line    6)
* module; io:                            io --- ストリームを扱うコアツール.
                                                             (line    6)
* module; ipaddress:                     ipaddress --- IPv4/IPv6 操作ライブラリ.
                                                             (line    6)
* module; itertools:                     itertools --- 効率的なループ用のイテレータ生成関数群.
                                                             (line    6)
* module; json:                          json --- JSON エンコーダーとデコーダー.
                                                             (line    6)
* module; json.tool:                     コマンドラインインターフェイス<4>.
                                                             (line    6)
* module; keyword:                       keyword --- Python キーワードのテスト.
                                                             (line    6)
* module; linecache:                     linecache --- テキストラインへのランダムアクセス.
                                                             (line    6)
* module; locale:                        locale --- 国際化サービス.
                                                             (line    6)
* module; logging:                       logging --- Python 用のログ記録手段.
                                                             (line    6)
* module; logging.config:                logging config --- ログ記録の環境設定.
                                                             (line    6)
* module; logging.handlers:              logging handlers --- ログ記録ハンドラー.
                                                             (line    6)
* module; lzma:                          lzma --- LZMA アルゴリズムを使用した圧縮.
                                                             (line    6)
* module; mailbox:                       mailbox --- 様々な形式のメールボックスを操作する.
                                                             (line    6)
* module; marshal:                       marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line    6)
* module; math:                          math --- 数学関数.  (line    6)
* module; mimetypes:                     mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line    6)
* module; mmap:                          mmap --- メモリマップファイルのサポート.
                                                             (line    6)
* module; modulefinder:                  modulefinder --- スクリプト中で使用されているモジュールの検索.
                                                             (line    6)
* module; msvcrt:                        msvcrt --- MS VC++ ランタイムの有用なルーチン群.
                                                             (line    6)
* module; multiprocessing:               multiprocessing --- プロセスベースの並列処理.
                                                             (line    6)
* module; multiprocessing.connection:    リスナーとクライアント.
                                                             (line    6)
* module; multiprocessing.dummy:         multiprocessing dummy モジュール.
                                                             (line    6)
* module; multiprocessing.managers:      マネージャー.       (line   20)
* module; multiprocessing.pool:          プロセスプール.     (line    6)
* module; multiprocessing.shared_memory: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line    6)
* module; multiprocessing.sharedctypes:  multiprocessing sharedctypes モジュール.
                                                             (line    6)
* module; netrc:                         netrc --- netrc ファイルの処理.
                                                             (line    6)
* module; numbers:                       numbers --- 数の抽象基底クラス.
                                                             (line    6)
* module; operator:                      operator --- 関数形式の標準演算子.
                                                             (line    6)
* module; optparse:                      optparse --- Parser for command line options.
                                                             (line    6)
* module; os:                            os --- 雑多なオペレーティングシステムインターフェース.
                                                             (line    6)
* module; os.path:                       os path --- 一般的なパス名操作.
                                                             (line    6)
* module; pathlib:                       pathlib --- オブジェクト指向のファイルシステムパス.
                                                             (line    6)
* module; pdb:                           pdb --- Python デバッガ.
                                                             (line    6)
* module; pickle:                        pickle --- Python オブジェクトの直列化.
                                                             (line    6)
* module; pickletools:                   pickletools --- pickle 開発者用のツール群.
                                                             (line    6)
* module; pkgutil:                       pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line    6)
* module; platform:                      platform --- 実行中プラットフォームの固有情報を参照する.
                                                             (line    6)
* module; plistlib:                      plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line    6)
* module; poplib:                        poplib --- POP3 プロトコルクライアント.
                                                             (line    6)
* module; posix:                         posix --- 最も一般的な POSIX システムコール群.
                                                             (line    6)
* module; pprint:                        pprint --- データの整形表示.
                                                             (line    6)
* module; profile:                       リファレンスマニュアル -- profile と cProfile.
                                                             (line    6)
* module; pstats:                        Stats クラス.       (line    8)
* module; pty:                           pty --- 擬似端末ユーティリティ.
                                                             (line    6)
* module; pwd:                           pwd --- パスワードデータベース.
                                                             (line    6)
* module; py_compile:                    py_compile --- Python ソースファイルをコンパイルする.
                                                             (line    6)
* module; pyclbr:                        pyclbr --- Python モジュールブラウザーサポート.
                                                             (line    6)
* module; pydoc:                         pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line    6)
* module; queue:                         queue --- 同期キュークラス.
                                                             (line    6)
* module; quopri:                        quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line    6)
* module; random:                        random --- 疑似乱数を生成する.
                                                             (line    6)
* module; re:                            re --- 正規表現操作.
                                                             (line    6)
* module; readline:                      readline --- GNU readline のインターフェース.
                                                             (line    6)
* module; reprlib:                       reprlib --- もう一つの repr の実装.
                                                             (line    6)
* module; resource:                      resource --- リソース使用情報.
                                                             (line    6)
* module; rlcompleter:                   rlcompleter --- GNU readline の補完機能.
                                                             (line    6)
* module; runpy:                         runpy --- Python モジュールの位置特定と実行.
                                                             (line    6)
* module; sched:                         sched --- イベントスケジューラー.
                                                             (line    6)
* module; secrets:                       secrets --- 機密を扱うために安全な乱数を生成する.
                                                             (line    6)
* module; select:                        select --- I/O 完了の待機.
                                                             (line    6)
* module; selectors:                     selectors --- 高水準の I/O 多重化.
                                                             (line    6)
* module; shelve:                        shelve --- Python オブジェクトの永続化.
                                                             (line    6)
* module; shlex:                         shlex --- 単純な字句解析.
                                                             (line    6)
* module; shutil:                        shutil --- 高水準のファイル操作.
                                                             (line    6)
* module; signal:                        signal --- 非同期イベントにハンドラーを設定する.
                                                             (line    6)
* module; site:                          site --- サイト固有の設定フック.
                                                             (line    6)
* module; sitecustomize:                 sitecustomize.      (line    6)
* module; smtplib:                       smtplib --- SMTP プロトコルクライアント.
                                                             (line    6)
* module; socket:                        socket --- 低水準ネットワークインターフェース.
                                                             (line    6)
* module; socketserver:                  socketserver --- ネットワークサーバーのフレームワーク.
                                                             (line    6)
* module; sqlite3:                       sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース.
                                                             (line    6)
* module; ssl:                           ssl --- ソケットオブジェクト用の TLS/SSL ラッパー.
                                                             (line    6)
* module; stat:                          stat --- stat の結果を解釈する.
                                                             (line    6)
* module; statistics:                    statistics --- 数学的統計関数.
                                                             (line    6)
* module; string:                        string --- 一般的な文字列操作.
                                                             (line    6)
* module; stringprep:                    stringprep --- インターネットの文字列調製.
                                                             (line    6)
* module; struct:                        struct --- バイト列をパックされたバイナリデータとして解釈する.
                                                             (line    6)
* module; subprocess:                    subprocess --- サブプロセス管理.
                                                             (line    6)
* module; symtable:                      symtable --- コンパイラーの記号表へのアクセス.
                                                             (line    6)
* module; sys:                           sys --- システム固有のパラメーターと関数.
                                                             (line    6)
* module; sys.monitoring:                sys monitoring --- Execution event monitoring.
                                                             (line    6)
* module; sysconfig:                     sysconfig --- Python の構成情報へのアクセスを提供する.
                                                             (line    6)
* module; syslog:                        syslog --- Unix syslog ライブラリルーチン群.
                                                             (line    6)
* module; tabnanny:                      tabnanny --- あいまいなインデントの検出.
                                                             (line    6)
* module; tarfile:                       tarfile --- tar アーカイブファイルの読み書き.
                                                             (line    6)
* module; tempfile:                      tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line    6)
* module; termios:                       termios --- POSIX スタイルの端末制御.
                                                             (line    6)
* module; test:                          test --- Regression tests package for Python.
                                                             (line    6)
* module; test.regrtest:                 コマンドラインインターフェースを利用してテストを実行する.
                                                             (line    6)
* module; test.support:                  test support --- テストのためのユーティリティ関数.
                                                             (line    6)
* module; test.support.bytecode_helper:  test support bytecode_helper --- Support tools for testing correct bytecode generation.
                                                             (line    6)
* module; test.support.import_helper:    test support import_helper --- Utilities for import tests.
                                                             (line    6)
* module; test.support.os_helper:        test support os_helper --- Utilities for os tests.
                                                             (line    6)
* module; test.support.script_helper:    test support script_helper --- Utilities for the Python execution tests.
                                                             (line    6)
* module; test.support.socket_helper:    test support socket_helper --- Utilities for socket tests.
                                                             (line    6)
* module; test.support.threading_helper: test support threading_helper --- Utilities for threading tests.
                                                             (line    6)
* module; test.support.warnings_helper:  test support warnings_helper --- Utilities for warnings tests.
                                                             (line    6)
* module; textwrap:                      textwrap --- テキストの折り返しと詰め込み.
                                                             (line    6)
* module; threading:                     threading --- スレッドベースの並列処理.
                                                             (line    6)
* module; time:                          time --- 時刻データへのアクセスと変換.
                                                             (line    6)
* module; timeit:                        timeit --- 小さなコードスニペットの実行時間計測.
                                                             (line    6)
* module; tkinter:                       tkinter --- Tcl/Tk の Python インターフェース.
                                                             (line    6)
* module; tkinter.colorchooser:          tkinter colorchooser --- カラー選択ダイアログ.
                                                             (line    6)
* module; tkinter.commondialog:          tkinter commondialog --- Dialog window templates.
                                                             (line    6)
* module; tkinter.dnd:                   tkinter dnd --- ドラッグアンドドロップのサポート.
                                                             (line    6)
* module; tkinter.filedialog:            tkinter filedialog --- ファイル選択ダイアログ.
                                                             (line    6)
* module; tkinter.font:                  tkinter font --- Tkinter フォントラッパー.
                                                             (line    6)
* module; tkinter.messagebox:            tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line    6)
* module; tkinter.scrolledtext:          tkinter scrolledtext --- スクロール可能なテキストウィジェット.
                                                             (line    6)
* module; tkinter.simpledialog:          tkinter simpledialog --- 標準 Tkinter 入力ダイアログ.
                                                             (line    6)
* module; tkinter.ttk:                   tkinter ttk --- Tk のテーマ付きウィジェット.
                                                             (line    6)
* module; token:                         token --- Python 解析木で使われる定数.
                                                             (line    6)
* module; tokenize:                      tokenize --- Python ソース用のトークナイザー.
                                                             (line    6)
* module; tomllib:                       tomllib --- TOML ファイルの解析.
                                                             (line    6)
* module; trace:                         trace --- Python 文実行のトレースと追跡.
                                                             (line    6)
* module; traceback:                     traceback --- スタックトレースの表示または取得.
                                                             (line    6)
* module; tracemalloc:                   tracemalloc --- メモリ割り当ての追跡.
                                                             (line    6)
* module; tty:                           tty --- 端末制御用の関数群.
                                                             (line    6)
* module; turtle:                        turtle --- タートルグラフィックス.
                                                             (line    6)
* module; turtledemo:                    turtledemo --- デモスクリプト.
                                                             (line    6)
* module; types:                         types --- 動的な型生成と組み込み型の名前.
                                                             (line    6)
* module; typing:                        typing --- 型ヒントのサポート.
                                                             (line    6)
* module; unicodedata:                   unicodedata --- Unicode データベース.
                                                             (line    6)
* module; unittest:                      unittest --- ユニットテストフレームワーク.
                                                             (line    6)
* module; unittest.mock:                 unittest mock --- モックオブジェクトライブラリ.
                                                             (line    6)
* module; urllib:                        urllib --- URL を扱うモジュール群.
                                                             (line    6)
* module; urllib.error:                  urllib error --- urllib request によって送出される例外クラス.
                                                             (line    6)
* module; urllib.parse:                  urllib parse --- URL を構成要素に解析する.
                                                             (line    6)
* module; urllib.request:                urllib request --- URL を開くための大規模なライブラリ.
                                                             (line    6)
* module; urllib.response:               urllib response --- urllib で使用するレスポンスクラス.
                                                             (line    6)
* module; urllib.robotparser:            urllib robotparser --- robots txt 用のパーサー.
                                                             (line    6)
* module; usercustomize:                 usercustomize.      (line    6)
* module; uuid:                          uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line    8)
* module; venv:                          venv --- 仮想環境の作成.
                                                             (line    6)
* module; warnings:                      warnings --- 警告の制御.
                                                             (line    6)
* module; wave:                          wave --- WAV ファイルの読み書き.
                                                             (line    6)
* module; weakref:                       weakref --- 弱参照. (line    6)
* module; webbrowser:                    webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line    6)
* module; winreg:                        winreg --- Windows レジストリへのアクセス.
                                                             (line    6)
* module; winsound:                      winsound --- Windows 用の音声再生インターフェース.
                                                             (line    6)
* module; wsgiref:                       wsgiref --- WSGI ユーティリティとリファレンス実装.
                                                             (line    6)
* module; wsgiref.handlers:              wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line    6)
* module; wsgiref.headers:               wsgiref headers -- WSGI レスポンスヘッダツール群.
                                                             (line    6)
* module; wsgiref.simple_server:         wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line    6)
* module; wsgiref.types:                 wsgiref types -- WSGI types for static type checking.
                                                             (line    6)
* module; wsgiref.util:                  wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line    6)
* module; wsgiref.validate:              wsgiref validate --- WSGI 準拠チェッカー.
                                                             (line    6)
* module; xml:                           XMLを扱うモジュール群.
                                                             (line    6)
* module; xml.dom:                       xml dom --- ドキュメントオブジェクトモデル API.
                                                             (line    6)
* module; xml.dom.minidom:               xml dom minidom --- 最小限の DOM の実装.
                                                             (line    6)
* module; xml.dom.pulldom:               xml dom pulldom --- 部分的な DOM ツリー構築のサポート.
                                                             (line    6)
* module; xml.etree.ElementInclude:      関数<10>.           (line    6)
* module; xml.etree.ElementTree:         xml etree ElementTree --- ElementTree XML API.
                                                             (line    6)
* module; xml.parsers.expat:             xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line    6)
* module; xml.parsers.expat.errors:      Expat エラー定数.   (line    6)
* module; xml.parsers.expat.model:       内容モデルの記述.   (line    6)
* module; xml.sax:                       xml sax --- SAX2 バーサーのサポート.
                                                             (line    6)
* module; xml.sax.handler:               xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line    6)
* module; xml.sax.saxutils:              xml sax saxutils --- SAX ユーティリティー.
                                                             (line    6)
* module; xml.sax.xmlreader:             xml sax xmlreader --- XML パーサーのインターフェース.
                                                             (line    6)
* module; xmlrpc.client:                 xmlrpc client --- XML-RPC クライアントアクセス.
                                                             (line    6)
* module; xmlrpc.server:                 xmlrpc server --- 基本的な XML-RPC サーバー.
                                                             (line    6)
* module; zipapp:                        zipapp --- 実行可能な Python zip アーカイブを管理する.
                                                             (line    6)
* module; zipfile:                       zipfile --- ZIP アーカイブの処理.
                                                             (line    6)
* module; zipimport:                     zipimport --- Zip アーカイブからモジュールをインポートする.
                                                             (line    6)
* module; zlib:                          zlib --- gzip 互換の圧縮.
                                                             (line    6)
* module; zoneinfo:                      zoneinfo --- IANA タイムゾーンのサポート.
                                                             (line    6)
* module;__main__:                       名前解決.           (line   52)
* module;__main__ <1>:                   完全な Python プログラム.
                                                             (line    6)
* module;__main__ <2>:                   完全な Python プログラム.
                                                             (line   18)
* module;__main__ <3>:                   runpy --- Python モジュールの位置特定と実行.
                                                             (line   30)
* module;__main__ <4>:                   runpy --- Python モジュールの位置特定と実行.
                                                             (line  100)
* module;__main__ <5>:                   Python の埋め込み<2>.
                                                             (line   11)
* module;__main__ <6>:                   インタープリタの初期化と終了処理.
                                                             (line    7)
* module;__main__ <7>:                   サブインタプリタサポート.
                                                             (line  109)
* module;__main__ <8>:                   サブインタプリタサポート.
                                                             (line  191)
* module;_locale:                        locale --- 国際化サービス.
                                                             (line   15)
* module;_thread:                        高レベルAPI.        (line   48)
* module;array:                          変更可能なシーケンス型 mutable sequence.
                                                             (line   11)
* module;array <1>:                      バイナリシーケンス型 --- bytes bytearray memoryview.
                                                             (line    6)
* module;base64:                         binascii --- バイナリ と ASCII 間の変換.
                                                             (line    6)
* module;bdb:                            pdb --- Python デバッガ.
                                                             (line   17)
* module;builtins:                       dir 関数.           (line   47)
* module;builtins <1>:                   完全な Python プログラム.
                                                             (line    6)
* module;builtins <2>:                   組み込み関数.       (line 2158)
* module;builtins <3>:                   Python の埋め込み<2>.
                                                             (line   11)
* module;builtins <4>:                   インタープリタの初期化と終了処理.
                                                             (line    7)
* module;builtins <5>:                   サブインタプリタサポート.
                                                             (line  109)
* module;builtins <6>:                   サブインタプリタサポート.
                                                             (line  191)
* module;cmd:                            pdb --- Python デバッガ.
                                                             (line   17)
* module;collections:                    変更可能なシーケンス型 mutable sequence.
                                                             (line   12)
* module;copy:                           copyreg --- pickle サポート関数を登録する.
                                                             (line    8)
* module;dbm.gnu:                        辞書型 dictionary<2>.
                                                             (line   21)
* module;dbm.gnu <1>:                    制限事項.           (line    6)
* module;dbm.ndbm:                       辞書型 dictionary<2>.
                                                             (line   21)
* module;dbm.ndbm <1>:                   制限事項.           (line    6)
* module;errno:                          具象例外.           (line  140)
* module;glob:                           fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   34)
* module;importing:                      import 文.          (line    6)
* module;io:                             I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* module;json:                           json による構造化されたデータの保存.
                                                             (line    6)
* module;math:                           数値型 int float complex.
                                                             (line  102)
* module;math <1>:                       定数<3>.            (line   47)
* module;namespace:                      モジュール<3>.      (line   21)
* module;os:                             posix --- 最も一般的な POSIX システムコール群.
                                                             (line   14)
* module;pickle:                         copy --- 浅いコピーおよび深いコピー操作.
                                                             (line   76)
* module;pickle <1>:                     copyreg --- pickle サポート関数を登録する.
                                                             (line    8)
* module;pickle <2>:                     shelve --- Python オブジェクトの永続化.
                                                             (line    8)
* module;pickle <3>:                     marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line   15)
* module;pty:                            ファイル記述子の操作.
                                                             (line  481)
* module;pwd:                            os path --- 一般的なパス名操作.
                                                             (line  140)
* module;pyexpat:                        xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line   21)
* module;re:                             文字列メソッド<2>.  (line    6)
* module;re <1>:                         fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line    8)
* module;shelve:                         marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line   15)
* module;signal:                         _thread --- 低水準なスレッド API.
                                                             (line  190)
* module;signal <1>:                     シグナルハンドリング<2>.
                                                             (line    7)
* module;signal <2>:                     シグナルハンドリング<2>.
                                                             (line   34)
* module;signal <3>:                     シグナルハンドリング<2>.
                                                             (line   43)
* module;socket:                         インターネットプロトコルとサポート.
                                                             (line    6)
* module;stat:                           ファイルとディレクトリ.
                                                             (line 1136)
* module;struct:                         socket オブジェクト.
                                                             (line  563)
* module;sys:                            標準モジュール.     (line    6)
* module;sys <1>:                        except 節.          (line   56)
* module;sys <2>:                        完全な Python プログラム.
                                                             (line    6)
* module;sys <3>:                        組み込み関数.       (line 1455)
* module;sys <4>:                        Python の埋め込み<2>.
                                                             (line   11)
* module;sys <5>:                        インタープリタの初期化と終了処理.
                                                             (line    7)
* module;sys <6>:                        サブインタプリタサポート.
                                                             (line  109)
* module;sys <7>:                        サブインタプリタサポート.
                                                             (line  191)
* module;types:                          型オブジェクト.     (line    6)
* module;urllib.request:                 http client --- HTTP プロトコルクライアント.
                                                             (line    8)
* module;検索;パス:                      モジュール検索パス. (line    6)
* module;検索;パス <1>:                  linecache --- テキストラインへのランダムアクセス.
                                                             (line   29)
* module;検索;パス <2>:                  sys --- システム固有のパラメーターと関数.
                                                             (line 1296)
* module;検索;パス <3>:                  site --- サイト固有の設定フック.
                                                             (line   13)
* module;検索;パス <4>:                  Python の埋め込み<2>.
                                                             (line   11)
* module;検索;パス <5>:                  インタープリタの初期化と終了処理.
                                                             (line    7)
* module;検索;パス <6>:                  プロセスワイドのパラメータ.
                                                             (line  134)
* ModuleFinder (modulefinder のクラス):  modulefinder --- スクリプト中で使用されているモジュールの検索.
                                                             (line   26)
* ModuleInfo (pkgutil のクラス):         pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   13)
* ModuleNotFoundError:                   具象例外.           (line   63)
* modules (in module sys):               モジュールのインポート<2>.
                                                             (line    8)
* modules (in module sys) <1>:           インタープリタの初期化と終了処理.
                                                             (line    7)
* modules (modulefinder.ModuleFinder の属性): modulefinder --- スクリプト中で使用されているモジュールの検索.
                                                             (line   51)
* modules (sys モジュール):              sys --- システム固有のパラメーターと関数.
                                                             (line 1269)
* modules_cleanup() (test.support.import_helper モジュール): test support import_helper --- Utilities for import tests.
                                                             (line   71)
* modules_setup() (test.support.import_helper モジュール): test support import_helper --- Utilities for import tests.
                                                             (line   67)
* ModuleSpec (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  363)
* ModuleType (in module types):          モジュールオブジェクト module object.
                                                             (line    7)
* ModuleType (types のクラス):           標準的なインタプリタ型.
                                                             (line  122)
* modulus (sys.hash_info の属性):        sys --- システム固有のパラメーターと関数.
                                                             (line 1019)
* MON_1 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_10 (locale モジュール):            locale --- 国際化サービス.
                                                             (line  223)
* MON_11 (locale モジュール):            locale --- 国際化サービス.
                                                             (line  223)
* MON_12 (locale モジュール):            locale --- 国際化サービス.
                                                             (line  223)
* MON_2 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_3 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_4 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_5 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_6 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_7 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_8 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MON_9 (locale モジュール):             locale --- 国際化サービス.
                                                             (line  223)
* MONDAY (calendar モジュール):          calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  381)
* monotonic_ns() (time モジュール):      関数<5>.            (line  206)
* monotonic() (time モジュール):         関数<5>.            (line  175)
* Month (calendar のクラス):             calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  442)
* month (calendar.IllegalMonthError の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  457)
* month (datetime.date の属性):          date オブジェクト.  (line  118)
* month (datetime.datetime の属性):      datetime オブジェクト.
                                                             (line  307)
* month_abbr (calendar モジュール):      calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  413)
* month_name (calendar モジュール):      calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  402)
* month() (calendar モジュール):         calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  335)
* monthcalendar() (calendar モジュール): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  324)
* monthdatescalendar() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   86)
* monthdays2calendar() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   91)
* monthdayscalendar() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line   96)
* monthrange() (calendar モジュール):    calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  320)
* Morsel (http.cookies のクラス):        Morselオブジェクト. (line    6)
* most_common() (collections.Counter のメソッド): Counter オブジェクト.
                                                             (line   75)
* mouseinterval() (curses モジュール):   関数<6>.            (line  285)
* mousemask() (curses モジュール):       関数<6>.            (line  291)
* move_to_end() (collections.OrderedDict のメソッド): OrderedDict オブジェクト.
                                                             (line   71)
* move() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   35)
* move() (curses.window のメソッド):     Window オブジェクト.
                                                             (line  384)
* move() (mmap.mmap のメソッド):         mmap --- メモリマップファイルのサポート.
                                                             (line  238)
* move() (shutil モジュール):            ディレクトリとファイルの操作.
                                                             (line  335)
* move() (tkinter.ttk.Treeview のメソッド): ttk Treeview.    (line  211)
* MozillaCookieJar (http.cookiejar のクラス): FileCookieJar のサブクラスと web ブラウザとの連携.
                                                             (line    9)
* MRO:                                   用語集<2>.          (line  982)
* mro() (type のメソッド):               Special methods.    (line    9)
* msg (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   41)
* msg (json.JSONDecodeError の属性):     例外<16>.           (line   10)
* msg (netrc.NetrcParseError の属性):    netrc --- netrc ファイルの処理.
                                                             (line   52)
* msg (re.PatternError の属性):          例外<3>.            (line   15)
* msg (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line  121)
* mtime (gzip.GzipFile の属性):          gzip --- gzip ファイルのサポート.
                                                             (line  151)
* mtime (tarfile.TarInfo の属性):        TarInfo オブジェクト.
                                                             (line   70)
* mtime() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   39)
* mul() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  115)
* Mult (ast のクラス):                   式 expression<2>.   (line   55)
* MultiCall (xmlrpc.client のクラス):    MultiCall オブジェクト.
                                                             (line    9)
* MULTILINE (re モジュール):             フラグ.             (line   80)
* MultilineContinuationError:            例外<8>.            (line   69)
* MultiLoopChildWatcher (asyncio のクラス): プロセスのウオッチャー.
                                                             (line  111)
* multimode() (statistics モジュール):   関数の詳細.         (line  348)
* MultipartConversionError:              email errors Exception and Defect classes.
                                                             (line   42)
* multiply() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  401)
* mutable:                               用語集<2>.          (line  986)
* mutable;sequence;types:                ミュータブルなシーケンス型.
                                                             (line    6)
* MutableMapping (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   98)
* MutableMapping (typing のクラス):      Aliases to container ABCs in collections abc.
                                                             (line   74)
* MutableSequence (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   68)
* MutableSequence (typing のクラス):     Aliases to container ABCs in collections abc.
                                                             (line   82)
* MutableSet (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   93)
* MutableSet (typing のクラス):          Aliases to container ABCs in collections abc.
                                                             (line   90)
* mvderwin() (curses.window のメソッド): Window オブジェクト.
                                                             (line  388)
* mvwin() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  394)
* myrights() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  160)
* N_TOKENS (token モジュール):           token --- Python 解析木で使われる定数.
                                                             (line  263)
* n_waiting (asyncio.Barrier の属性):    Barrier.            (line   99)
* n_waiting (threading.Barrier の属性):  バリアオブジェクト. (line   96)
* NAK (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   87)
* name:                                  識別子 identifier およびキーワード keyword.
                                                             (line    6)
* name <1>:                              名前の束縛.         (line    6)
* name <2>:                              識別子 identifier、または名前 name.
                                                             (line    6)
* Name (ast のクラス):                   変数.               (line    6)
* name (bz2.BZ2File の属性):             ファイルの圧縮/解凍.
                                                             (line  134)
* name (codecs.CodecInfo の属性):        codecs --- codec レジストリと基底クラス.
                                                             (line   66)
* name (contextvars.ContextVar の属性):  コンテキスト変数.   (line   24)
* name (doctest.DocTest の属性):         DocTest オブジェクト.
                                                             (line   30)
* name (email.headerregistry.BaseHeader の属性): email headerregistry Custom Header Objects.
                                                             (line   47)
* name (enum.Enum の属性):               データ型<2>.        (line  135)
* name (gzip.GzipFile の属性):           gzip --- gzip ファイルのサポート.
                                                             (line  159)
* name (hashlib.hash の属性):            Hash Objects.       (line   19)
* name (hmac.HMAC の属性):               hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line  100)
* name (http.cookiejar.Cookie の属性):   Cookieオブジェクト<2>.
                                                             (line   27)
* name (ImportError の属性):             具象例外.           (line   52)
* name (importlib.abc.FileLoader の属性): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  301)
* name (importlib.abc.Traversable の属性): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  512)
* name (importlib.machinery.AppleFrameworkLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  500)
* name (importlib.machinery.ExtensionFileLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  302)
* name (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  379)
* name (importlib.machinery.SourceFileLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  211)
* name (importlib.machinery.SourcelessFileLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  254)
* name (importlib.resources.abc.Traversable の属性): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   94)
* name (inspect.Parameter の属性):       Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  206)
* name (io.FileIO の属性):               生ファイルI/O.      (line   59)
* name (logging.Logger の属性):          ロガーオブジェクト. (line   25)
* name (lzma.LZMAFile の属性):           圧縮ファイルへの読み書き.
                                                             (line  104)
* name (multiprocessing.Process の属性): Process クラスと例外.
                                                             (line   82)
* name (multiprocessing.shared_memory.SharedMemory の属性): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  119)
* name (os モジュール):                  os --- 雑多なオペレーティングシステムインターフェース.
                                                             (line   54)
* name (os.DirEntry の属性):             ファイルとディレクトリ.
                                                             (line  958)
* name (pathlib.PurePath の属性):        メソッドとプロパティ.
                                                             (line  122)
* name (pyclbr.Class の属性):            クラスオブジェクト<2>.
                                                             (line   20)
* name (pyclbr.Function の属性):         Function オブジェクト.
                                                             (line   19)
* name (sys.thread_info の属性):         sys --- システム固有のパラメーターと関数.
                                                             (line 1880)
* name (tarfile.TarInfo の属性):         TarInfo オブジェクト.
                                                             (line   62)
* name (tempfile.TemporaryDirectory の属性): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  193)
* name (threading.Thread の属性):        Thread オブジェクト.
                                                             (line  159)
* NAME (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   39)
* name (traceback.FrameSummary の属性):  FrameSummary オブジェクト.
                                                             (line   37)
* name (webbrowser.controller の属性):   ブラウザコントローラーオブジェクト.
                                                             (line    9)
* name (xml.dom.Attr の属性):            Attr オブジェクト.  (line    8)
* name (xml.dom.DocumentType の属性):    DocumentType オブジェクト.
                                                             (line   33)
* name (zipfile.Path の属性):            Path オブジェクト.  (line   21)
* name;束縛:                             import 文.          (line    6)
* name;束縛 <1>:                         import 文.          (line   51)
* name;束縛 <2>:                         関数定義.           (line    6)
* name;束縛 <3>:                         関数定義.           (line    6)
* name;束縛 <4>:                         クラス定義.         (line    6)
* name;難号化:                           プライベート変数.   (line   12)
* name;難号化 <1>:                       識別子 identifier、または名前 name.
                                                             (line   15)
* name() (unicodedata モジュール):       unicodedata --- Unicode データベース.
                                                             (line   25)
* name2codepoint (html.entities モジュール): html entities --- HTML 一般実体の定義.
                                                             (line   29)
* named expression:                      ブール演算 boolean operation.
                                                             (line   34)
* Named Shared Memory:                   multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line   10)
* named tuple:                           用語集<2>.          (line  992)
* NAMED_FLAGS (enum.EnumCheck の属性):   データ型<2>.        (line  614)
* NamedExpr (ast のクラス):              式 expression<2>.   (line  186)
* NamedTemporaryFile() (tempfile モジュール): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line   73)
* NamedTuple (typing のクラス):          Other special directives.
                                                             (line   10)
* namedtuple() (collections モジュール): namedtuple 名前付きフィールドを持つタプルのファクトリ関数.
                                                             (line   11)
* NameError:                             具象例外.           (line  108)
* NameError (組み込み例外):              名前解決.           (line   17)
* namelist() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  130)
* nameprep() (encodings.idna モジュール): encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   48)
* namer (logging.handlers.BaseRotatingHandler の属性): BaseRotatingHandler.
                                                             (line   17)
* namereplace_errors() (codecs モジュール): エラーハンドラ.  (line  174)
* namereplace;error handler's name:      エラーハンドラ.     (line   52)
* names() (tkinter.font モジュール):     tkinter font --- Tkinter フォントラッパー.
                                                             (line   92)
* namespace:                             名前づけと束縛 naming and binding.
                                                             (line    6)
* namespace <1>:                         用語集<2>.          (line 1018)
* Namespace (argparse のクラス):         Namespace オブジェクト.
                                                             (line    6)
* Namespace (multiprocessing.managers のクラス): マネージャー.
                                                             (line  245)
* namespace package:                     用語集<2>.          (line 1031)
* NAMESPACE_DNS (uuid モジュール):       uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  203)
* NAMESPACE_OID (uuid モジュール):       uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  212)
* NAMESPACE_URL (uuid モジュール):       uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  208)
* NAMESPACE_X500 (uuid モジュール):      uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  216)
* namespace() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  165)
* Namespace() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  195)
* NamespaceErr:                          例外<19>.           (line   63)
* NamespaceLoader (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  345)
* namespaceURI (xml.dom.Node の属性):    Node オブジェクト.  (line   73)
* nametofont() (tkinter.font モジュール): tkinter font --- Tkinter フォントラッパー.
                                                             (line   96)
* NaN:                                   組み込み関数.       (line  709)
* nan (cmath モジュール):                定数<3>.            (line   33)
* nan (math モジュール):                 定数<2>.            (line   30)
* nan (sys.hash_info の属性):            sys --- システム固有のパラメーターと関数.
                                                             (line 1027)
* nanj (cmath モジュール):               定数<3>.            (line   40)
* NannyNag:                              tabnanny --- あいまいなインデントの検出.
                                                             (line   37)
* napms() (curses モジュール):           関数<6>.            (line  300)
* nargs (optparse.Option の属性):        オプション属性.     (line   51)
* native_id (threading.Thread の属性):   Thread オブジェクト.
                                                             (line  181)
* nbytes (memoryview の属性):            メモリビュー.       (line  378)
* ncurses_version (curses モジュール):   定数<6>.            (line   24)
* ND (inspect.BufferFlags の属性):       Buffer flags.       (line   21)
* ndiff() (difflib モジュール):          difflib --- 差分の計算の補助.
                                                             (line  227)
* ndim (memoryview の属性):              メモリビュー.       (line  443)
* ne() (operator モジュール):            operator --- 関数形式の標準演算子.
                                                             (line   23)
* needs_input (bz2.BZ2Decompressor の属性): 逐次圧縮および展開.
                                                             (line   85)
* needs_input (lzma.LZMADecompressor の属性): メモリ上での圧縮と展開.
                                                             (line  164)
* neg() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  127)
* nested scope:                          用語集<2>.          (line 1040)
* netmask (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   99)
* netmask (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  315)
* NetmaskValueError:                     Custom Exceptions.  (line   13)
* netrc (netrc のクラス):                netrc --- netrc ファイルの処理.
                                                             (line   14)
* NetrcParseError:                       netrc --- netrc ファイルの処理.
                                                             (line   46)
* netscape (http.cookiejar.CookiePolicy の属性): CookiePolicy オブジェクト.
                                                             (line   71)
* network (ipaddress.IPv4Interface の属性): インターフェイスオブジェクト.
                                                             (line   28)
* network (ipaddress.IPv6Interface の属性): インターフェイスオブジェクト.
                                                             (line   76)
* network_address (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   83)
* network_address (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  309)
* Never (typing モジュール):             特殊型.             (line   99)
* NEVER_EQ (test.support モジュール):    test support --- テストのためのユーティリティ関数.
                                                             (line  183)
* new_child() (collections.ChainMap のメソッド): ChainMap オブジェクト.
                                                             (line   45)
* new_class() (types モジュール):        動的な型生成.       (line    6)
* new_event_loop() (asyncio モジュール): イベントループ.     (line   66)
* new_event_loop() (asyncio.AbstractEventLoopPolicy のメソッド): ポリシーオブジェクト.
                                                             (line   27)
* new_panel() (curses.panel モジュール): 関数<7>.            (line   12)
* new-style class:                       用語集<2>.          (line 1050)
* new() (hashlib モジュール):            Constructors.       (line    6)
* new() (hmac モジュール):               hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   13)
* newfunc (C type):                      Slot Type typedefs. (line   32)
* NEWLINE (token モジュール):            token --- Python 解析木で使われる定数.
                                                             (line   45)
* NEWLINE トークン:                      論理行 logical line.
                                                             (line    6)
* NEWLINE トークン <1>:                  複合文 compound statement.
                                                             (line   52)
* newlines (io.TextIOBase の属性):       テキスト I/O<2>.    (line   24)
* newpad() (curses モジュール):          関数<6>.            (line  304)
* NewType (typing のクラス):             Other special directives.
                                                             (line  100)
* newwin() (curses モジュール):          関数<6>.            (line  321)
* next (pdb command):                    デバッガコマンド.   (line  200)
* next_minus() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  405)
* next_minus() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  385)
* next_plus() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  409)
* next_plus() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  391)
* next_toward() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  413)
* next_toward() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  397)
* next() (tarfile.TarFile のメソッド):   TarFile オブジェクト.
                                                             (line  135)
* next() (tkinter.ttk.Treeview のメソッド): ttk Treeview.    (line  221)
* nextafter() (math モジュール):         数論および数表現の関数.
                                                             (line  197)
* nextfile() (fileinput モジュール):     fileinput --- 複数の入力ストリームをまたいだ行を反復する.
                                                             (line  118)
* nextkey() (dbm.gnu.gdbm のメソッド):   dbm gnu --- GNU database manager.
                                                             (line   92)
* nextSibling (xml.dom.Node の属性):     Node オブジェクト.  (line   41)
* ngettext() (gettext モジュール):       GNU gettext API.    (line   45)
* ngettext() (gettext.GNUTranslations のメソッド): GNUTranslations クラス.
                                                             (line   46)
* ngettext() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   45)
* nice() (os モジュール):                プロセス管理.       (line  355)
* NL (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   54)
* NL (token モジュール):                 token --- Python 解析木で使われる定数.
                                                             (line  259)
* nl_langinfo() (locale モジュール):     locale --- 国際化サービス.
                                                             (line  159)
* nl() (curses モジュール):              関数<6>.            (line  331)
* nlargest() (heapq モジュール):         heapq --- ヒープキューアルゴリズム.
                                                             (line  103)
* nlst() (ftplib.FTP のメソッド):        FTP オブジェクト.   (line  298)
* NO (tkinter.messagebox モジュール):    tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  159)
* no_cache() (zoneinfo.ZoneInfo のクラスメソッド): ZoneInfo クラス.
                                                             (line   41)
* NO_EVENTS (monitoring event):          Events.             (line   94)
* no_proxy:                              urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  306)
* no_site (sys.flags の属性):            sys --- システム固有のパラメーターと関数.
                                                             (line  533)
* no_tracing() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  541)
* no_type_check_decorator() (typing モジュール): Functions and decorators.
                                                             (line  358)
* no_type_check() (typing モジュール):   Functions and decorators.
                                                             (line  346)
* no_user_site (sys.flags の属性):       sys --- システム固有のパラメーターと関数.
                                                             (line  530)
* nocbreak() (curses モジュール):        関数<6>.            (line  337)
* NoDataAllowedErr:                      例外<19>.           (line   79)
* node (uuid.UUID の属性):               uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  118)
* node() (platform モジュール):          クロスプラットフォーム.
                                                             (line   39)
* NoDefault (typing モジュール):         Introspection helpers.
                                                             (line  164)
* nodelay() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  398)
* nodeName (xml.dom.Node の属性):        Node オブジェクト.  (line   78)
* NodeTransformer (ast のクラス):        ast ヘルパー.       (line  225)
* nodeType (xml.dom.Node の属性):        Node オブジェクト.  (line    8)
* nodeValue (xml.dom.Node の属性):       Node オブジェクト.  (line   86)
* NodeVisitor (ast のクラス):            ast ヘルパー.       (line  185)
* noecho() (curses モジュール):          関数<6>.            (line  342)
* NOEXPR (locale モジュール):            locale --- 国際化サービス.
                                                             (line  267)
* NOFLAG (re モジュール):                フラグ.             (line   91)
* NoModificationAllowedErr:              例外<19>.           (line   84)
* NonCallableMagicMock (unittest.mock のクラス): Magic Mock. (line   21)
* NonCallableMock (unittest.mock のクラス): Mock クラス.     (line  554)
* None (組み込みオブジェクト):           真理値判定.         (line   14)
* None (組み込み変数):                   組み込み定数.       (line   18)
* NoneType (types モジュール):           標準的なインタプリタ型.
                                                             (line   18)
* nonl() (curses モジュール):            関数<6>.            (line  346)
* Nonlocal (ast のクラス):               関数およびクラス定義.
                                                             (line  144)
* nonmember() (enum モジュール):         ユーティリティとデコレータ.
                                                             (line   86)
* noop() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line  169)
* noop() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   78)
* NoOptionError:                         例外<8>.            (line   31)
* NOP (opcode):                          Python バイトコード命令.
                                                             (line  125)
* noqiflush() (curses モジュール):       関数<6>.            (line  355)
* noraw() (curses モジュール):           関数<6>.            (line  363)
* NoReturn (typing モジュール):          特殊型.             (line   99)
* NORMAL (tkinter.font モジュール):      tkinter font --- Tkinter フォントラッパー.
                                                             (line   15)
* NORMAL_PRIORITY_CLASS (subprocess モジュール): Windows Constants.
                                                             (line   96)
* NormalDist (statistics のクラス):      NormalDist オブジェクト.
                                                             (line   13)
* NORMALIZE_WHITESPACE (doctest モジュール): オプションフラグ.
                                                             (line   39)
* normalize() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  417)
* normalize() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  403)
* normalize() (locale モジュール):       locale --- 国際化サービス.
                                                             (line  403)
* normalize() (unicodedata モジュール):  unicodedata --- Unicode データベース.
                                                             (line   80)
* normalize() (xml.dom.Node のメソッド): Node オブジェクト.  (line  141)
* normalvariate() (random モジュール):   実数分布.           (line   78)
* normcase() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  341)
* normpath() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  350)
* NoSectionError:                        例外<8>.            (line   10)
* NoSuchMailboxError:                    例外<17>.           (line   12)
* Not (ast のクラス):                    式 expression<2>.   (line   28)
* not_() (operator モジュール):          operator --- 関数形式の標準演算子.
                                                             (line   46)
* NotADirectoryError:                    OS 例外.            (line   89)
* notationDecl() (xml.sax.handler.DTDHandler のメソッド): DTDHandler オブジェクト.
                                                             (line    8)
* NotationDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  304)
* notations (xml.dom.DocumentType の属性): DocumentType オブジェクト.
                                                             (line   46)
* NotConnected:                          http client --- HTTP プロトコルクライアント.
                                                             (line  141)
* Notebook (tkinter.ttk のクラス):       ttk Notebook.       (line    6)
* NotEmptyError:                         例外<17>.           (line   20)
* NotEq (ast のクラス):                  式 expression<2>.   (line  110)
* NOTEQUAL (token モジュール):           token --- Python 解析木で使われる定数.
                                                             (line  135)
* NotFoundErr:                           例外<19>.           (line   68)
* notify_all() (asyncio.Condition のメソッド): Condition.    (line   67)
* notify_all() (threading.Condition のメソッド): Condition オブジェクト.
                                                             (line  171)
* notify() (asyncio.Condition のメソッド): Condition.        (line   53)
* notify() (threading.Condition のメソッド): Condition オブジェクト.
                                                             (line  152)
* notimeout() (curses.window のメソッド): Window オブジェクト.
                                                             (line  403)
* NotImplemented (組み込み変数):         組み込み定数.       (line   25)
* NotImplementedError:                   具象例外.           (line  120)
* NotImplementedType (types モジュール): 標準的なインタプリタ型.
                                                             (line  102)
* NotIn (ast のクラス):                  式 expression<2>.   (line  110)
* NotRequired (typing モジュール):       特殊形式.           (line  226)
* NOTSET (logging モジュール):           ロギングレベル.     (line   15)
* NotStandaloneHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  355)
* NotSupportedErr:                       例外<19>.           (line   74)
* NotSupportedError:                     例外<7>.            (line   82)
* noutrefresh() (curses.window のメソッド): Window オブジェクト.
                                                             (line  411)
* NOVEMBER (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* now() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line   61)
* npgettext() (gettext モジュール):      GNU gettext API.    (line   68)
* npgettext() (gettext.GNUTranslations のメソッド): GNUTranslations クラス.
                                                             (line   79)
* npgettext() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   60)
* NSIG (signal モジュール):              モジュールの内容<2>.
                                                             (line  208)
* nsmallest() (heapq モジュール):        heapq --- ヒープキューアルゴリズム.
                                                             (line  111)
* NT_OFFSET (token モジュール):          token --- Python 解析木で使われる定数.
                                                             (line  265)
* NTEventLogHandler (logging.handlers のクラス): NTEventLogHandler.
                                                             (line   12)
* ntohl() (socket モジュール):           その他の関数<2>.    (line  226)
* ntohs() (socket モジュール):           その他の関数<2>.    (line  233)
* ntransfercmd() (ftplib.FTP のメソッド): FTP オブジェクト.  (line  276)
* NUL (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   18)
* null;演算:                             pass 文<2>.         (line    6)
* null;演算 <1>:                         pass 文<2>.         (line    6)
* nullcontext() (contextlib モジュール): ユーティリティ.     (line  224)
* NullHandler (logging のクラス):        NullHandler.        (line   12)
* NullTranslations (gettext のクラス):   NullTranslations クラス.
                                                             (line   12)
* num_addresses (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line  127)
* num_addresses (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  327)
* num_tickets (ssl.SSLContext の属性):   SSL コンテキスト.   (line  563)
* number:                                数値リテラル.       (line    6)
* Number (numbers のクラス):             numbers --- 数の抽象基底クラス.
                                                             (line   15)
* NUMBER (token モジュール):             token --- Python 解析木で使われる定数.
                                                             (line   41)
* number_class() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  421)
* number_class() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  426)
* numerator (fractions.Fraction の属性): fractions --- 有理数.
                                                             (line  111)
* numerator (numbers.Rational の属性):   数値塔.             (line   51)
* numeric() (unicodedata モジュール):    unicodedata --- Unicode データベース.
                                                             (line   43)
* numinput() (turtle モジュール):        入力メソッド.       (line   22)
* O_APPEND (os モジュール):              ファイル記述子の操作.
                                                             (line  418)
* O_ASYNC (os モジュール):               ファイル記述子の操作.
                                                             (line  462)
* O_BINARY (os モジュール):              ファイル記述子の操作.
                                                             (line  441)
* O_CLOEXEC (os モジュール):             ファイル記述子の操作.
                                                             (line  428)
* O_CREAT (os モジュール):               ファイル記述子の操作.
                                                             (line  418)
* O_DIRECT (os モジュール):              ファイル記述子の操作.
                                                             (line  462)
* O_DIRECTORY (os モジュール):           ファイル記述子の操作.
                                                             (line  462)
* O_DSYNC (os モジュール):               ファイル記述子の操作.
                                                             (line  428)
* O_EVTONLY (os モジュール):             ファイル記述子の操作.
                                                             (line  451)
* O_EXCL (os モジュール):                ファイル記述子の操作.
                                                             (line  418)
* O_EXLOCK (os モジュール):              ファイル記述子の操作.
                                                             (line  462)
* O_FSYNC (os モジュール):               ファイル記述子の操作.
                                                             (line  451)
* O_NDELAY (os モジュール):              ファイル記述子の操作.
                                                             (line  428)
* O_NOATIME (os モジュール):             ファイル記述子の操作.
                                                             (line  462)
* O_NOCTTY (os モジュール):              ファイル記述子の操作.
                                                             (line  428)
* O_NOFOLLOW (os モジュール):            ファイル記述子の操作.
                                                             (line  462)
* O_NOFOLLOW_ANY (os モジュール):        ファイル記述子の操作.
                                                             (line  451)
* O_NOINHERIT (os モジュール):           ファイル記述子の操作.
                                                             (line  441)
* O_NONBLOCK (os モジュール):            ファイル記述子の操作.
                                                             (line  428)
* O_PATH (os モジュール):                ファイル記述子の操作.
                                                             (line  462)
* O_RANDOM (os モジュール):              ファイル記述子の操作.
                                                             (line  441)
* O_RDONLY (os モジュール):              ファイル記述子の操作.
                                                             (line  418)
* O_RDWR (os モジュール):                ファイル記述子の操作.
                                                             (line  418)
* O_RSYNC (os モジュール):               ファイル記述子の操作.
                                                             (line  428)
* O_SEQUENTIAL (os モジュール):          ファイル記述子の操作.
                                                             (line  441)
* O_SHLOCK (os モジュール):              ファイル記述子の操作.
                                                             (line  462)
* O_SHORT_LIVED (os モジュール):         ファイル記述子の操作.
                                                             (line  441)
* O_SYMLINK (os モジュール):             ファイル記述子の操作.
                                                             (line  451)
* O_SYNC (os モジュール):                ファイル記述子の操作.
                                                             (line  428)
* O_TEMPORARY (os モジュール):           ファイル記述子の操作.
                                                             (line  441)
* O_TEXT (os モジュール):                ファイル記述子の操作.
                                                             (line  441)
* O_TMPFILE (os モジュール):             ファイル記述子の操作.
                                                             (line  462)
* O_TRUNC (os モジュール):               ファイル記述子の操作.
                                                             (line  418)
* O_WRONLY (os モジュール):              ファイル記述子の操作.
                                                             (line  418)
* obj (memoryview の属性):               メモリビュー.       (line  367)
* object:                                オブジェクト、値、および型.
                                                             (line    6)
* object <1>:                            用語集<2>.          (line 1058)
* object (UnicodeError の属性):          具象例外.           (line  421)
* object (組み込みクラス):               組み込み関数.       (line 1220)
* object;asynchronous-generator:         非同期ジェネレータ関数 asynchronous generator function<2>.
                                                             (line   63)
* object;Boolean:                        numbers Integral 整数.
                                                             (line   24)
* object;Boolean <1>:                    数値型 int float complex.
                                                             (line    6)
* object;bytearray:                      ミュータブルなシーケンス型.
                                                             (line    6)
* object;bytearray <1>:                  バイナリシーケンス型 --- bytes bytearray memoryview.
                                                             (line    6)
* object;bytearray <2>:                  bytearray オブジェクト.
                                                             (line    6)
* object;bytearray <3>:                  bytearray オブジェクト<2>.
                                                             (line    6)
* object;bytes:                          バイナリシーケンス型 --- bytes bytearray memoryview.
                                                             (line    6)
* object;bytes <1>:                      バイトオブジェクト. (line    6)
* object;bytes <2>:                      バイトオブジェクト<2>.
                                                             (line   10)
* object;callable:                       呼び出し可能型 callable type.
                                                             (line    6)
* object;callable <1>:                   スライス表記 slicing.
                                                             (line   37)
* object;complex number:                 数値型 int float complex.
                                                             (line    6)
* object;complex number <1>:             複素数オブジェクト. (line    6)
* object;deallocation:                   ファイナライズとメモリ解放.
                                                             (line    6)
* object;dictionary:                     辞書型 dictionary<2>.
                                                             (line    6)
* object;dictionary <1>:                 カスタムクラス型.   (line   19)
* object;dictionary <2>:                 基本的なカスタマイズ.
                                                             (line  238)
* object;dictionary <3>:                 辞書表示.           (line    6)
* object;dictionary <4>:                 添字表記 subscription.
                                                             (line    6)
* object;dictionary <5>:                 代入文 assignment statement.
                                                             (line  113)
* object;dictionary <6>:                 マッピング型 --- dict.
                                                             (line    6)
* object;dictionary <7>:                 辞書オブジェクト dictionary object.
                                                             (line    6)
* object;Ellipsis:                       Ellipsis.           (line    6)
* object;finalization:                   ファイナライズとメモリ解放.
                                                             (line    6)
* object;frozenset:                      集合型<2>.          (line   27)
* object;frozenset <1>:                  Set オブジェクト.   (line    6)
* object;GenericAlias:                   ジェネリックエイリアス型.
                                                             (line    6)
* object;immutable:                      変更不能なシーケンス immutable sequence.
                                                             (line    6)
* object;instance:                       カスタムクラス型.   (line   19)
* object;instance <1>:                   クラスインスタンス class instance.
                                                             (line    6)
* object;instance <2>:                   呼び出し call.      (line  149)
* object;instancemethod:                 インスタンスメソッドオブジェクト Instance Method Objects.
                                                             (line    6)
* object;io.StringIO:                    テキストシーケンス型 --- str.
                                                             (line   36)
* object;list:                           変更可能なシーケンス型 mutable sequence.
                                                             (line   20)
* object;list <1>:                       リスト表示.         (line    6)
* object;list <2>:                       属性参照.           (line   10)
* object;list <3>:                       添字表記 subscription.
                                                             (line    6)
* object;list <4>:                       スライス表記 slicing.
                                                             (line    6)
* object;list <5>:                       代入文 assignment statement.
                                                             (line  104)
* object;list <6>:                       ミュータブルなシーケンス型.
                                                             (line    6)
* object;list <7>:                       リスト型 list<2>.   (line    6)
* object;list <8>:                       リストオブジェクト. (line    6)
* object;long integer:                   整数型オブジェクト integer object.
                                                             (line    6)
* object;mapping:                        マッピング型 mapping.
                                                             (line    6)
* object;mapping <1>:                    クラスインスタンス class instance.
                                                             (line   26)
* object;mapping <2>:                    添字表記 subscription.
                                                             (line    6)
* object;mapping <3>:                    代入文 assignment statement.
                                                             (line  113)
* object;mapping <4>:                    マッピング型 --- dict.
                                                             (line    6)
* object;mapping <5>:                    Container オブジェクト.
                                                             (line    6)
* object;memoryview:                     バイナリシーケンス型 --- bytes bytearray memoryview.
                                                             (line    6)
* object;memoryview <1>:                 Ellipsis オブジェクト<2>.
                                                             (line   14)
* object;module:                         モジュール<3>.      (line    6)
* object;module <1>:                     属性参照.           (line   10)
* object;module <2>:                     モジュールオブジェクト module object.
                                                             (line    6)
* object;mutable:                        変更可能なシーケンス型 mutable sequence.
                                                             (line    6)
* object;mutable <1>:                    代入文 assignment statement.
                                                             (line    6)
* object;mutable <2>:                    代入文 assignment statement.
                                                             (line   99)
* object;None:                           None.               (line    6)
* object;None <1>:                       式文 expression statement.
                                                             (line   16)
* object;NotImplemented:                 NotImplemented.     (line    6)
* object;range:                          range.              (line    6)
* object;sequence:                       シーケンス型 sequence.
                                                             (line    6)
* object;sequence <1>:                   クラスインスタンス class instance.
                                                             (line   26)
* object;sequence <2>:                   添字表記 subscription.
                                                             (line    6)
* object;sequence <3>:                   スライス表記 slicing.
                                                             (line    6)
* object;sequence <4>:                   所属検査演算.       (line   36)
* object;sequence <5>:                   代入文 assignment statement.
                                                             (line  104)
* object;sequence <6>:                   for 文<2>.          (line    6)
* object;sequence <7>:                   共通のシーケンス演算.
                                                             (line    6)
* object;sequence <8>:                   シーケンスオブジェクト sequence object.
                                                             (line    6)
* object;slice:                          コンテナをエミュレートする.
                                                             (line   66)
* object;socket:                         socket --- 低水準ネットワークインターフェース.
                                                             (line   22)
* object;string:                         添字表記 subscription.
                                                             (line    6)
* object;string <1>:                     スライス表記 slicing.
                                                             (line    6)
* object;string <2>:                     range.              (line  118)
* object;traceback:                      トレースバック traceback オブジェクト.
                                                             (line    6)
* object;traceback <1>:                  raise 文.           (line   21)
* object;traceback <2>:                  except 節.          (line   56)
* object;traceback <3>:                  sys --- システム固有のパラメーターと関数.
                                                             (line  447)
* object;traceback <4>:                  traceback --- スタックトレースの表示または取得.
                                                             (line   19)
* object;tuple:                          変更不能なシーケンス immutable sequence.
                                                             (line   30)
* object;tuple <1>:                      添字表記 subscription.
                                                             (line    6)
* object;tuple <2>:                      スライス表記 slicing.
                                                             (line    6)
* object;tuple <3>:                      式のリスト.         (line   13)
* object;tuple <4>:                      イミュータブルなシーケンス型.
                                                             (line    6)
* object;tuple <5>:                      タプル型 tuple.     (line    6)
* object;tuple <6>:                      タプルオブジェクト tuple object.
                                                             (line    6)
* object;type:                           組み込み関数.       (line 1996)
* object;type <1>:                       オブジェクト、型および参照カウント.
                                                             (line    6)
* object;type <2>:                       型オブジェクト<2>.  (line    6)
* object;Union:                          Union 型.           (line    6)
* object;クラス:                         カスタムクラス型.   (line   19)
* object;クラス <1>:                     呼び出し call.      (line  145)
* object;クラス <2>:                     クラス定義.         (line    6)
* object;クラスインスタンス:             カスタムクラス型.   (line   19)
* object;クラスインスタンス <1>:         クラスインスタンス class instance.
                                                             (line    6)
* object;クラスインスタンス <2>:         呼び出し call.      (line  149)
* object;コード:                         コードオブジェクト. (line    6)
* object;コード <1>:                     メソッド.           (line   44)
* object;コード <2>:                     marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line   33)
* object;ジェネレータ:                   Special read-only attributes<2>.
                                                             (line   89)
* object;ジェネレータ <1>:               ジェネレータ式<2>.  (line    6)
* object;ジェネレータ <2>:               Yield 式.           (line  103)
* object;ファイル:                       ファイルを読み書きする.
                                                             (line    6)
* object;ファイル <1>:                   ファイルオブジェクト.
                                                             (line    6)
* object;フレーム:                       フレーム frame オブジェクト.
                                                             (line    6)
* object;メソッド:                       インスタンスオブジェクト.
                                                             (line   25)
* object;メソッド <1>:                   インスタンスメソッド.
                                                             (line    6)
* object;メソッド <2>:                   組み込みメソッド built-in method.
                                                             (line    6)
* object;メソッド <3>:                   呼び出し call.      (line  140)
* object;メソッド <4>:                   メソッド.           (line    6)
* object;メソッド <5>:                   メソッドオブジェクト<2>.
                                                             (line    6)
* object;ユーザ定義メソッド:             インスタンスメソッド.
                                                             (line    6)
* object;ユーザ定義関数:                 ユーザ定義関数 user-defined function.
                                                             (line    6)
* object;ユーザ定義関数 <1>:             呼び出し call.      (line  129)
* object;ユーザ定義関数 <2>:             関数定義.           (line    6)
* object;変更不能なシーケンス:           変更不能なシーケンス immutable sequence.
                                                             (line    6)
* object;変更可能なシーケンス:           変更可能なシーケンス型 mutable sequence.
                                                             (line    6)
* object;数値:                           numbers Number.     (line    6)
* object;数値 <1>:                       クラスインスタンス class instance.
                                                             (line   26)
* object;数値 <2>:                       比較<2>.            (line   42)
* object;数値 <3>:                       数値型 int float complex.
                                                             (line    6)
* object;数値 <4>:                       数値型オブジェクト numeric object.
                                                             (line    6)
* object;整数:                           numbers Integral 整数.
                                                             (line    6)
* object;整数 <1>:                       数値型 int float complex.
                                                             (line    6)
* object;整数 <2>:                       整数型オブジェクト integer object.
                                                             (line    6)
* object;浮動小数点:                     numbers Real float 実数.
                                                             (line    6)
* object;浮動小数点 <1>:                 数値型 int float complex.
                                                             (line    6)
* object;浮動小数点 <2>:                 Floating-Point Objects.
                                                             (line    6)
* object;組み込みメソッド:               組み込みメソッド built-in method.
                                                             (line    6)
* object;組み込みメソッド <1>:           呼び出し call.      (line  140)
* object;組み込み関数:                   組み込み関数 built-in function.
                                                             (line    6)
* object;組み込み関数 <1>:               呼び出し call.      (line  140)
* object;複素数:                         numbers Complex complex.
                                                             (line    6)
* object;関数:                           ユーザ定義関数 user-defined function.
                                                             (line    6)
* object;関数 <1>:                       組み込み関数 built-in function.
                                                             (line    6)
* object;関数 <2>:                       呼び出し call.      (line  129)
* object;関数 <3>:                       呼び出し call.      (line  140)
* object;関数 <4>:                       関数定義.           (line    6)
* object;関数 <5>:                       Function オブジェクト<3>.
                                                             (line    6)
* object;集合:                           集合型<2>.          (line   22)
* object;集合 <1>:                       集合表示.           (line    6)
* object;集合 <2>:                       set（集合）型 --- set frozenset.
                                                             (line    6)
* object;集合 <3>:                       Set オブジェクト.   (line    6)
* object;集合型:                         集合型<2>.          (line    6)
* object.__match_args__ (組み込み変数):  クラスパターンマッチの位置引数のカスタマイズ.
                                                             (line   11)
* object.__slots__ (組み込み変数):       __slots__<2>.       (line   13)
* objobjargproc (C type):                Slot Type typedefs. (line  146)
* objobjproc (C type):                   Slot Type typedefs. (line  142)
* octdigits (string モジュール):         文字列定数.         (line   31)
* OCTOBER (calendar モジュール):         calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* offset (SyntaxError の属性):           具象例外.           (line  304)
* offset (tarfile.TarInfo の属性):       TarInfo オブジェクト.
                                                             (line  151)
* offset (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line  110)
* offset (xml.parsers.expat.ExpatError の属性): ExpatError 例外.
                                                             (line   30)
* offset_data (tarfile.TarInfo の属性):  TarInfo オブジェクト.
                                                             (line  155)
* OK (curses モジュール):                定数<6>.            (line   13)
* OK (tkinter.messagebox モジュール):    tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  153)
* ok_command() (tkinter.filedialog.LoadFileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  139)
* ok_command() (tkinter.filedialog.SaveFileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  149)
* ok_event() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  118)
* OKCANCEL (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  171)
* old_value (contextvars.Token の属性):  コンテキスト変数.   (line   85)
* OleDLL (ctypes のクラス):              共有ライブラリをロードする.
                                                             (line   35)
* on_motion() (tkinter.dnd.DndHandler のメソッド): tkinter dnd --- ドラッグアンドドロップのサポート.
                                                             (line   56)
* on_release() (tkinter.dnd.DndHandler のメソッド): tkinter dnd --- ドラッグアンドドロップのサポート.
                                                             (line   61)
* onclick() (turtle モジュール):         スクリーンイベントを利用する.
                                                             (line   56)
* ondrag() (turtle モジュール):          イベントを利用する. (line   56)
* onecmd() (cmd.Cmd のメソッド):         Cmdオブジェクト.    (line   58)
* onkey() (turtle モジュール):           スクリーンイベントを利用する.
                                                             (line   12)
* onkeypress() (turtle モジュール):      スクリーンイベントを利用する.
                                                             (line   35)
* onkeyrelease() (turtle モジュール):    スクリーンイベントを利用する.
                                                             (line   12)
* onrelease() (turtle モジュール):       イベントを利用する. (line   29)
* onscreenclick() (turtle モジュール):   スクリーンイベントを利用する.
                                                             (line   56)
* ontimer() (turtle モジュール):         スクリーンイベントを利用する.
                                                             (line   85)
* OP (token モジュール):                 token --- Python 解析木で使われる定数.
                                                             (line  243)
* OP_ALL (ssl モジュール):               定数<9>.            (line  211)
* OP_CIPHER_SERVER_PREFERENCE (ssl モジュール): 定数<9>.     (line  301)
* OP_ENABLE_KTLS (ssl モジュール):       定数<9>.            (line  360)
* OP_ENABLE_MIDDLEBOX_COMPAT (ssl モジュール): 定数<9>.      (line  325)
* OP_IGNORE_UNEXPECTED_EOF (ssl モジュール): 定数<9>.        (line  352)
* OP_LEGACY_SERVER_CONNECT (ssl モジュール): 定数<9>.        (line  377)
* OP_NO_COMPRESSION (ssl モジュール):    定数<9>.            (line  334)
* OP_NO_RENEGOTIATION (ssl モジュール):  定数<9>.            (line  291)
* OP_NO_SSLv2 (ssl モジュール):          定数<9>.            (line  220)
* OP_NO_SSLv3 (ssl モジュール):          定数<9>.            (line  230)
* OP_NO_TICKET (ssl モジュール):         定数<9>.            (line  345)
* OP_NO_TLSv1 (ssl モジュール):          定数<9>.            (line  240)
* OP_NO_TLSv1_1 (ssl モジュール):        定数<9>.            (line  252)
* OP_NO_TLSv1_2 (ssl モジュール):        定数<9>.            (line  264)
* OP_NO_TLSv1_3 (ssl モジュール):        定数<9>.            (line  276)
* OP_SINGLE_DH_USE (ssl モジュール):     定数<9>.            (line  309)
* OP_SINGLE_ECDH_USE (ssl モジュール):   定数<9>.            (line  317)
* Open (tkinter.filedialog のクラス):    ネイティブの読み込み/保存ダイアログ.
                                                             (line   59)
* open_binary() (importlib.resources モジュール): 関数 API.  (line   35)
* open_code() (io モジュール):           高水準のモジュールインターフェイス.
                                                             (line   22)
* open_connection() (asyncio モジュール): ストリーム.        (line   42)
* open_flags (dbm.gnu モジュール):       dbm gnu --- GNU database manager.
                                                             (line   75)
* open_new_tab() (webbrowser モジュール): webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   91)
* open_new_tab() (webbrowser.controller のメソッド): ブラウザコントローラーオブジェクト.
                                                             (line   26)
* open_new() (webbrowser モジュール):    webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   82)
* open_new() (webbrowser.controller のメソッド): ブラウザコントローラーオブジェクト.
                                                             (line   20)
* open_osfhandle() (msvcrt モジュール):  ファイル操作関連.   (line   44)
* open_resource() (importlib.abc.ResourceReader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  460)
* open_resource() (importlib.resources.abc.ResourceReader のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   47)
* open_text() (importlib.resources モジュール): 関数 API.    (line   51)
* open_unix_connection() (asyncio モジュール): ストリーム.   (line  115)
* open_unknown() (urllib.request.URLopener のメソッド): レガシーインターフェース.
                                                             (line  110)
* open_urlresource() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  583)
* open() (bz2 モジュール):               ファイルの圧縮/解凍.
                                                             (line    6)
* open() (codecs モジュール):            codecs --- codec レジストリと基底クラス.
                                                             (line  176)
* open() (dbm モジュール):               dbm --- Unix "データベース" へのインターフェース.
                                                             (line   50)
* open() (dbm.dumb モジュール):          dbm dumb --- 可搬性のある DBM 実装.
                                                             (line   29)
* open() (dbm.gnu モジュール):           dbm gnu --- GNU database manager.
                                                             (line   28)
* open() (dbm.ndbm モジュール):          dbm ndbm --- New Database Manager.
                                                             (line   38)
* open() (dbm.sqlite3 モジュール):       dbm sqlite3 --- SQLite backend for dbm.
                                                             (line   22)
* open() (gzip モジュール):              gzip --- gzip ファイルのサポート.
                                                             (line   27)
* open() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line  173)
* open() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  537)
* open() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  141)
* open() (io モジュール):                高水準のモジュールインターフェイス.
                                                             (line   12)
* open() (lzma モジュール):              圧縮ファイルへの読み書き.
                                                             (line    6)
* open() (os モジュール):                ファイル記述子の操作.
                                                             (line  373)
* open() (pathlib.Path のメソッド):      ファイルを読み書きする<2>.
                                                             (line    6)
* open() (shelve モジュール):            shelve --- Python オブジェクトの永続化.
                                                             (line   17)
* open() (tarfile モジュール):           tarfile --- tar アーカイブファイルの読み書き.
                                                             (line   41)
* open() (tarfile.TarFile のクラスメソッド): TarFile オブジェクト.
                                                             (line  100)
* open() (tokenize モジュール):          入力のトークナイズ. (line   99)
* open() (urllib.request.OpenerDirector のメソッド): OpenerDirector オブジェクト.
                                                             (line   46)
* open() (urllib.request.URLopener のメソッド): レガシーインターフェース.
                                                             (line   99)
* open() (wave モジュール):              wave --- WAV ファイルの読み書き.
                                                             (line   19)
* open() (webbrowser モジュール):        webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   63)
* open() (webbrowser.controller のメソッド): ブラウザコントローラーオブジェクト.
                                                             (line   13)
* open() (zipfile.Path のメソッド):      Path オブジェクト.  (line   25)
* open() (zipfile.ZipFile のメソッド):   ZipFile オブジェクト.
                                                             (line  134)
* OpenerDirector (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  268)
* OpenKey() (winreg モジュール):         関数<13>.           (line  284)
* OpenKeyEx() (winreg モジュール):       関数<13>.           (line  284)
* openlog() (syslog モジュール):         syslog --- Unix syslog ライブラリルーチン群.
                                                             (line   52)
* openpty() (os モジュール):             ファイル記述子の操作.
                                                             (line  479)
* openpty() (pty モジュール):            pty --- 擬似端末ユーティリティ.
                                                             (line   33)
* OPENSSL_VERSION (ssl モジュール):      定数<9>.            (line  481)
* OPENSSL_VERSION_INFO (ssl モジュール): 定数<9>.            (line  491)
* OPENSSL_VERSION_NUMBER (ssl モジュール): 定数<9>.          (line  500)
* OpenSSL;(use in module hashlib):       ハッシュアルゴリズム.
                                                             (line   18)
* OpenSSL;(use in module ssl):           ssl --- ソケットオブジェクト用の TLS/SSL ラッパー.
                                                             (line    8)
* OperationalError:                      例外<7>.            (line   55)
* operator;- (負符号):                   単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   10)
* operator;- (負符号) <1>:               二項算術演算 binary arithmetic operation.
                                                             (line   78)
* operator;- (負符号) <2>:               数値型 int float complex.
                                                             (line   24)
* operator;!=:                           比較.               (line    6)
* operator;!= <1>:                       比較<2>.            (line    6)
* operator;@ (at):                       二項算術演算 binary arithmetic operation.
                                                             (line   25)
* operator;* (アスタリスク):             二項算術演算 binary arithmetic operation.
                                                             (line   16)
* operator;* (アスタリスク) <1>:         数値型 int float complex.
                                                             (line   24)
* operator;**:                           べき乗演算 power operator.
                                                             (line    6)
* operator;** <1>:                       数値型 int float complex.
                                                             (line   24)
* operator;/ (スラッシュ):               二項算術演算 binary arithmetic operation.
                                                             (line   33)
* operator;/ (スラッシュ) <1>:           数値型 int float complex.
                                                             (line   24)
* operator;//:                           二項算術演算 binary arithmetic operation.
                                                             (line   33)
* operator;// <1>:                       数値型 int float complex.
                                                             (line   24)
* operator;& (アンパサンド):             ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   12)
* operator;& (アンパサンド) <1>:         整数型におけるビット単位演算.
                                                             (line    6)
* operator;% (パーセント):               二項算術演算 binary arithmetic operation.
                                                             (line   44)
* operator;% (パーセント) <1>:           数値型 int float complex.
                                                             (line   24)
* operator;^ (キャレット):               ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   16)
* operator;^ (キャレット) <1>:           整数型におけるビット単位演算.
                                                             (line    6)
* operator;+ (プラス記号):               単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   14)
* operator;+ (プラス記号) <1>:           二項算術演算 binary arithmetic operation.
                                                             (line   70)
* operator;+ (プラス記号) <2>:           数値型 int float complex.
                                                             (line   24)
* operator;< (小さい):                   比較.               (line    6)
* operator;< (小さい) <1>:               比較<2>.            (line    6)
* operator;<<:                           シフト演算 shifting operation.
                                                             (line    6)
* operator;<< <1>:                       整数型におけるビット単位演算.
                                                             (line    6)
* operator;<=:                           比較.               (line    6)
* operator;<= <1>:                       比較<2>.            (line    6)
* operator;==:                           比較.               (line    6)
* operator;== <1>:                       比較<2>.            (line    6)
* operator;> (大きい):                   比較.               (line    6)
* operator;> (大きい) <1>:               比較<2>.            (line    6)
* operator;>=:                           比較.               (line    6)
* operator;>= <1>:                       比較<2>.            (line    6)
* operator;>>:                           シフト演算 shifting operation.
                                                             (line    6)
* operator;>> <1>:                       整数型におけるビット単位演算.
                                                             (line    6)
* operator;| (縦棒):                     ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   20)
* operator;| (縦棒) <1>:                 整数型におけるビット単位演算.
                                                             (line    6)
* operator;~ (チルダ):                   単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   18)
* operator;~ (チルダ) <1>:               整数型におけるビット単位演算.
                                                             (line    6)
* operator;and:                          ブール演算 boolean operation.
                                                             (line   21)
* operator;and <1>:                      真理値判定.         (line   22)
* operator;and <2>:                      ブール演算 --- and or not.
                                                             (line   24)
* operator;in:                           所属検査演算.       (line   36)
* operator;in <1>:                       比較<2>.            (line   63)
* operator;in <2>:                       共通のシーケンス演算.
                                                             (line   18)
* operator;is:                           所属検査演算.       (line   39)
* operator;is <1>:                       比較<2>.            (line    6)
* operator;is not:                       所属検査演算.       (line   39)
* operator;is not <1>:                   比較<2>.            (line    6)
* operator;not:                          ブール演算 boolean operation.
                                                             (line   18)
* operator;not <1>:                      ブール演算 --- and or not.
                                                             (line   24)
* operator;not in:                       所属検査演算.       (line   36)
* operator;not in <1>:                   比較<2>.            (line   63)
* operator;not in <2>:                   共通のシーケンス演算.
                                                             (line   18)
* operator;or:                           ブール演算 boolean operation.
                                                             (line   24)
* operator;or <1>:                       真理値判定.         (line   22)
* operator;or <2>:                       ブール演算 --- and or not.
                                                             (line   24)
* operator;オーバーロード:               特殊メソッド名.     (line    6)
* operator;優先順位:                     演算子の優先順位.   (line    6)
* operator;比較:                         比較<2>.            (line    6)
* opmap (dis モジュール):                命令コードコレクション.
                                                             (line   18)
* opname (dis モジュール):               命令コードコレクション.
                                                             (line   13)
* OPT:                                   Debug options.      (line   39)
* optim_args_from_interpreter_flags() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  327)
* optimize (sys.flags の属性):           sys --- システム固有のパラメーターと関数.
                                                             (line  524)
* optimize() (pickletools モジュール):   プログラミングインターフェース<2>.
                                                             (line   30)
* optimized scope:                       用語集<2>.          (line 1064)
* OPTIMIZED_BYTECODE_SUFFIXES (importlib.machinery モジュール): importlib machinery -- インポータおよびパスフック.
                                                             (line   30)
* Option (optparse のクラス):            オプション属性.     (line    6)
* Optional (typing モジュール):          特殊形式.           (line   46)
* OptionConflictError:                   例外<20>.           (line   11)
* OptionError:                           例外<20>.           (line    6)
* OptionGroup (optparse のクラス):       オプションをグループ化する.
                                                             (line   12)
* OptionParser (optparse のクラス):      parserを作る.       (line    9)
* options (doctest.Example の属性):      Example オブジェクト.
                                                             (line   49)
* Options (ssl のクラス):                定数<9>.            (line  341)
* options (ssl.SSLContext の属性):       SSL コンテキスト.   (line  571)
* options() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  134)
* OptionValueError:                      例外<20>.           (line   16)
* optionxform() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  310)
* Or (ast のクラス):                     式 expression<2>.   (line   89)
* or_() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  132)
* ordered_attributes (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  142)
* OrderedDict (collections のクラス):    OrderedDict オブジェクト.
                                                             (line   58)
* OrderedDict (typing のクラス):         Aliases to types in collections.
                                                             (line   17)
* orig_argv (sys モジュール):            sys --- システム固有のパラメーターと関数.
                                                             (line 1281)
* origin (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  391)
* origin_req_host (urllib.request.Request の属性): Request オブジェクト.
                                                             (line   30)
* origin_server (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  286)
* os_environ (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  167)
* OSError:                               具象例外.           (line  136)
* OUT_TO_DEFAULT (msvcrt モジュール):    その多の関数.       (line   20)
* OUT_TO_MSGBOX (msvcrt モジュール):     その多の関数.       (line   30)
* OUT_TO_STDERR (msvcrt モジュール):     その多の関数.       (line   25)
* output:                                式文 expression statement.
                                                             (line   16)
* output (subprocess.CalledProcessError の属性): subprocess モジュールを使う.
                                                             (line  221)
* output (subprocess.TimeoutExpired の属性): subprocess モジュールを使う.
                                                             (line  180)
* output (unittest.TestCase の属性):     テストクラス.       (line  444)
* output_charset (email.charset.Charset の属性): email charset 文字集合の表現.
                                                             (line   76)
* output_codec (email.charset.Charset の属性): email charset 文字集合の表現.
                                                             (line   90)
* output_difference() (doctest.OutputChecker のメソッド): OutputChecker オブジェクト.
                                                             (line   26)
* output() (http.cookies.BaseCookie のメソッド): Cookieオブジェクト.
                                                             (line   24)
* output() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   65)
* OutputChecker (doctest のクラス):      OutputChecker オブジェクト.
                                                             (line    6)
* OutputString() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   79)
* OutsideDestinationError:               tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  250)
* Overflow (decimal のクラス):           シグナル.           (line   68)
* OverflowError:                         具象例外.           (line  196)
* OverflowError (組み込み例外):          整数型オブジェクト integer object.
                                                             (line  139)
* OverflowError (組み込み例外) <1>:      整数型オブジェクト integer object.
                                                             (line  195)
* OverflowError (組み込み例外) <2>:      整数型オブジェクト integer object.
                                                             (line  238)
* OverflowError (組み込み例外) <3>:      整数型オブジェクト integer object.
                                                             (line  250)
* OverflowError (組み込み例外) <4>:      整数型オブジェクト integer object.
                                                             (line  262)
* OverflowError (組み込み例外) <5>:      整数型オブジェクト integer object.
                                                             (line  275)
* overlap() (statistics.NormalDist のメソッド): NormalDist オブジェクト.
                                                             (line  102)
* overlaps() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  154)
* overlaps() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  340)
* overlay() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  418)
* overload() (typing モジュール):        Functions and decorators.
                                                             (line  246)
* override() (typing モジュール):        Functions and decorators.
                                                             (line  370)
* overwrite() (curses.window のメソッド): Window オブジェクト.
                                                             (line  430)
* owner() (pathlib.Path のメソッド):     パーミッションと所有者.
                                                             (line    6)
* p (pdb command):                       デバッガコマンド.   (line  262)
* P_ALL (os モジュール):                 プロセス管理.       (line  959)
* P_DETACH (os モジュール):              プロセス管理.       (line  692)
* P_NOWAIT (os モジュール):              プロセス管理.       (line  672)
* P_NOWAITO (os モジュール):             プロセス管理.       (line  672)
* P_OVERLAY (os モジュール):             プロセス管理.       (line  692)
* P_PGID (os モジュール):                プロセス管理.       (line  959)
* P_PID (os モジュール):                 プロセス管理.       (line  959)
* P_PIDFD (os モジュール):               プロセス管理.       (line  959)
* P_WAIT (os モジュール):                プロセス管理.       (line  682)
* pack_into() (struct モジュール):       関数と例外.         (line   19)
* pack_into() (struct.Struct のメソッド): クラス<3>.         (line   30)
* pack() (mailbox.MH のメソッド):        MH オブジェクト.    (line   69)
* pack() (struct モジュール):            関数と例外.         (line   13)
* pack() (struct.Struct のメソッド):     クラス<3>.          (line   24)
* package:                               パッケージ<2>.      (line    6)
* package <1>:                           site --- サイト固有の設定フック.
                                                             (line   71)
* package <2>:                           用語集<2>.          (line 1075)
* package variable;__all__:              モジュールのインポート<2>.
                                                             (line    8)
* package;namespace:                     名前空間パッケージ. (line    6)
* package;portion:                       名前空間パッケージ. (line    6)
* package;regular:                       通常のパッケージ.   (line    6)
* PackageMetadata (importlib.metadata のクラス): 配布物メタデータ.
                                                             (line   14)
* PackageNotFoundError:                  概要<3>.            (line   37)
* PackagePath (importlib.metadata のクラス): 配布物ファイル. (line   18)
* packages_distributions() (importlib.metadata モジュール): Mapping import to distribution packages.
                                                             (line    6)
* packed (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   68)
* packed (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  252)
* packing (widgets):                     Packer.             (line    6)
* PAGER:                                 pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line   46)
* pair_content() (curses モジュール):    関数<6>.            (line  368)
* pair_number() (curses モジュール):     関数<6>.            (line  374)
* pairwise() (itertools モジュール):     Itertool関数.       (line  411)
* parameter:                             用語集<2>.          (line 1084)
* Parameter (inspect のクラス):          Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  191)
* parameter;call の意味付け:             呼び出し call.      (line   26)
* parameter;difference from argument:    オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？.
                                                             (line   16)
* parameter;function definition:         クラスパターン.     (line  139)
* ParameterizedMIMEHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  249)
* parameters (inspect.Signature の属性): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  105)
* params (email.headerregistry.ParameterizedMIMEHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  257)
* ParamSpec (ast のクラス):              Type parameters.    (line   36)
* ParamSpec (typing のクラス):           Building generic types and type aliases.
                                                             (line  351)
* ParamSpecArgs (typing モジュール):     Building generic types and type aliases.
                                                             (line  471)
* ParamSpecKwargs (typing モジュール):   Building generic types and type aliases.
                                                             (line  471)
* paramstyle (sqlite3 モジュール):       モジュール定数.     (line   63)
* pardir (os モジュール):                雑多なシステム情報. (line  106)
* parent (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  427)
* parent (logging.Logger の属性):        ロガーオブジェクト. (line   42)
* parent (pathlib.PurePath の属性):      メソッドとプロパティ.
                                                             (line   94)
* parent (pyclbr.Class の属性):          クラスオブジェクト<2>.
                                                             (line   28)
* parent (pyclbr.Function の属性):       Function オブジェクト.
                                                             (line   27)
* parent (urllib.request.BaseHandler の属性): BaseHandler オブジェクト.
                                                             (line   25)
* parent_process() (multiprocessing モジュール): その他<3>.  (line   43)
* parent() (tkinter.ttk.Treeview のメソッド): ttk Treeview.  (line  226)
* parentNode (xml.dom.Node の属性):      Node オブジェクト.  (line   17)
* parents (collections.ChainMap の属性): ChainMap オブジェクト.
                                                             (line   62)
* parents (pathlib.PurePath の属性):     メソッドとプロパティ.
                                                             (line   78)
* paretovariate() (random モジュール):   実数分布.           (line   92)
* parse_and_bind() (readline モジュール): 初期化ファイル.    (line    8)
* parse_args() (argparse.ArgumentParser のメソッド): parse_args メソッド.
                                                             (line    6)
* parse_args() (optparse.OptionParser のメソッド): 引数を解析する.
                                                             (line    9)
* PARSE_COLNAMES (sqlite3 モジュール):   モジュール定数.     (line   13)
* parse_config_h() (sysconfig モジュール): その他の関数<3>.  (line   57)
* PARSE_DECLTYPES (sqlite3 モジュール):  モジュール定数.     (line   25)
* parse_headers() (http.client モジュール): http client --- HTTP プロトコルクライアント.
                                                             (line  115)
* parse_intermixed_args() (argparse.ArgumentParser のメソッド): 混在した引数の解析.
                                                             (line    6)
* parse_known_args() (argparse.ArgumentParser のメソッド): 部分解析.
                                                             (line    6)
* parse_known_intermixed_args() (argparse.ArgumentParser のメソッド): 混在した引数の解析.
                                                             (line    9)
* parse_qs() (urllib.parse モジュール):  URL の解析.         (line  151)
* parse_qsl() (urllib.parse モジュール): URL の解析.         (line  197)
* parse() (ast モジュール):              ast ヘルパー.       (line    9)
* parse() (doctest.DocTestParser のメソッド): DocTestParser オブジェクト.
                                                             (line   30)
* parse() (email.parser.BytesParser のメソッド): Parser API. (line   35)
* parse() (email.parser.Parser のメソッド): Parser API.      (line   87)
* parse() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line   39)
* parse() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   29)
* parse() (xml.dom.minidom モジュール):  xml dom minidom --- 最小限の DOM の実装.
                                                             (line   37)
* parse() (xml.dom.pulldom モジュール):  xml dom pulldom --- 部分的な DOM ツリー構築のサポート.
                                                             (line   84)
* parse() (xml.etree.ElementTree モジュール): 関数<9>.       (line  173)
* parse() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   52)
* Parse() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line    8)
* parse() (xml.sax モジュール):          xml sax --- SAX2 バーサーのサポート.
                                                             (line   41)
* parse() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line    8)
* parseaddr() (email.utils モジュール):  email utils Miscellaneous utilities.
                                                             (line   58)
* parsebytes() (email.parser.BytesParser のメソッド): Parser API.
                                                             (line   55)
* parsedate_to_datetime() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  129)
* parsedate_tz() (email.utils モジュール): email utils Miscellaneous utilities.
                                                             (line  118)
* parsedate() (email.utils モジュール):  email utils Miscellaneous utilities.
                                                             (line  107)
* ParseError (xml.etree.ElementTree のクラス): 例外<18>.     (line    6)
* ParseFile() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   16)
* ParseFlags() (imaplib モジュール):     imaplib --- IMAP4 プロトコルクライアント.
                                                             (line  128)
* Parser (email.parser のクラス):        Parser API.         (line   76)
* parser (pathlib.PurePath の属性):      メソッドとプロパティ.
                                                             (line    8)
* ParserCreate() (xml.parsers.expat モジュール): xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line   48)
* ParseResult (urllib.parse のクラス):   構造化された解析結果.
                                                             (line   47)
* ParseResultBytes (urllib.parse のクラス): 構造化された解析結果.
                                                             (line   72)
* parsestr() (email.parser.Parser のメソッド): Parser API.   (line   99)
* parseString() (xml.dom.minidom モジュール): xml dom minidom --- 最小限の DOM の実装.
                                                             (line   50)
* parseString() (xml.dom.pulldom モジュール): xml dom pulldom --- 部分的な DOM ツリー構築のサポート.
                                                             (line   97)
* parseString() (xml.sax モジュール):    xml sax --- SAX2 バーサーのサポート.
                                                             (line   54)
* ParsingError:                          例外<8>.            (line   61)
* partial (asyncio.IncompleteReadError の属性): 例外<12>.    (line   57)
* partial() (functools モジュール):      functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  320)
* partial() (imaplib.IMAP4 のメソッド):  IMAP4 オブジェクト. (line  192)
* partialmethod (functools のクラス):    functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  350)
* parties (asyncio.Barrier の属性):      Barrier.            (line   95)
* parties (threading.Barrier の属性):    バリアオブジェクト. (line   92)
* partition() (bytearray のメソッド):    bytes と bytearray の操作.
                                                             (line  188)
* partition() (bytes のメソッド):        bytes と bytearray の操作.
                                                             (line  188)
* partition() (str のメソッド):          文字列メソッド<2>.  (line  349)
* parts (pathlib.PurePath の属性):       個別の構成要素へのアクセス.
                                                             (line    9)
* Pass (ast のクラス):                   文 Statements.      (line  153)
* pass_() (poplib.POP3 のメソッド):      POP3 オブジェクト.  (line   34)
* Paste [貼り付け]:                      Help メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   32)
* patch.dict() (unittest.mock モジュール): patch dict.       (line    6)
* patch.multiple() (unittest.mock モジュール): patch multiple.
                                                             (line    6)
* patch.object() (unittest.mock モジュール): patch object.   (line    6)
* patch.stopall() (unittest.mock モジュール): patch のメソッド start と stop.
                                                             (line   69)
* patch() (test.support モジュール):     test support --- テストのためのユーティリティ関数.
                                                             (line  654)
* patch() (unittest.mock モジュール):    patch.              (line    9)
* PATH:                                  Python API の変更<3>.
                                                             (line  144)
* PATH <1>:                              'python' コマンドの挙動の変更<2>.
                                                             (line    6)
* PATH <2>:                              'python' コマンドの挙動の変更<2>.
                                                             (line   10)
* PATH <3>:                              'python' コマンドの挙動の変更<2>.
                                                             (line   11)
* PATH <4>:                              macOS<4>.           (line   14)
* PATH <5>:                              Windows<19>.        (line   56)
* PATH <6>:                              Windows<23>.        (line   14)
* PATH <7>:                              Security<32>.       (line   16)
* PATH <8>:                              Security<32>.       (line   20)
* PATH <9>:                              モジュール検索パス. (line   16)
* PATH <10>:                             実行可能な Python スクリプト.
                                                             (line   11)
* PATH <11>:                             環境変数.           (line   26)
* PATH <12>:                             その他.             (line   15)
* PATH <13>:                             インストール手順.   (line   36)
* PATH <14>:                             インストール手順.   (line   59)
* PATH <15>:                             インストーラの GUI なしでインストールする.
                                                             (line   77)
* PATH <16>:                             インストーラの GUI なしでインストールする.
                                                             (line   82)
* PATH <17>:                             Python を構成する<2>.
                                                             (line    7)
* PATH <18>:                             補足 環境変数の設定.
                                                             (line   22)
* PATH <19>:                             補足 環境変数の設定.
                                                             (line   33)
* PATH <20>:                             Python 実行ファイルを見つける.
                                                             (line   13)
* PATH <21>:                             Python 実行ファイルを見つける.
                                                             (line   22)
* PATH <22>:                             Python 実行ファイルを見つける.
                                                             (line   23)
* PATH <23>:                             Windows の Python ランチャ.
                                                             (line   13)
* PATH <24>:                             コマンドラインから起動する.
                                                             (line    8)
* PATH <25>:                             シェバン shebang 行.
                                                             (line   55)
* PATH <26>:                             シェバン shebang 行.
                                                             (line   61)
* PATH <27>:                             シェバン shebang 行.
                                                             (line   63)
* PATH <28>:                             シェバン shebang 行.
                                                             (line   68)
* PATH <29>:                             os と os path モジュールの比較.
                                                             (line   41)
* PATH <30>:                             ディレクトリとファイルの操作.
                                                             (line  431)
* PATH <31>:                             プロセス管理.       (line   45)
* PATH <32>:                             プロセス管理.       (line   87)
* PATH <33>:                             プロセス管理.       (line   90)
* PATH <34>:                             プロセス管理.       (line   93)
* PATH <35>:                             プロセス管理.       (line  543)
* PATH <36>:                             プロセス管理.       (line  631)
* PATH <37>:                             プロセス管理.       (line  633)
* PATH <38>:                             プロセス管理.       (line  635)
* PATH <39>:                             雑多なシステム情報. (line  137)
* PATH <40>:                             Popen コンストラクター.
                                                             (line   35)
* PATH <41>:                             webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line  235)
* PATH <42>:                             仮想環境のしくみ.   (line   15)
* PATH <43>:                             仮想環境のしくみ.   (line   61)
* PATH <44>:                             仮想環境のしくみ.   (line   66)
* PATH <45>:                             site --- サイト固有の設定フック.
                                                             (line   63)
* PATH <46>:                             Python の埋め込み<2>.
                                                             (line   26)
* PATH <47>:                             Python の埋め込み<2>.
                                                             (line   34)
* PATH <48>:                             Python のスクリプトを Unix で実行可能にするにはどうしますか？.
                                                             (line   20)
* PATH <49>:                             Python のスクリプトを Unix で実行可能にするにはどうしますか？.
                                                             (line   26)
* path (http.cookiejar.Cookie の属性):   Cookieオブジェクト<2>.
                                                             (line   44)
* path (http.cookies.Morsel の属性):     Morselオブジェクト. (line   13)
* path (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line   99)
* path (ImportError の属性):             具象例外.           (line   56)
* path (importlib.abc.FileLoader の属性): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  305)
* path (importlib.machinery.AppleFrameworkLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  504)
* path (importlib.machinery.ExtensionFileLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  306)
* path (importlib.machinery.FileFinder の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  178)
* path (importlib.machinery.SourceFileLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  215)
* path (importlib.machinery.SourcelessFileLoader の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  258)
* path (os.DirEntry の属性):             ファイルとディレクトリ.
                                                             (line  968)
* Path (pathlib のクラス):               具象パス.           (line   10)
* path (sys モジュール):                 sys --- システム固有のパラメーターと関数.
                                                             (line 1294)
* path (sys モジュール) <1>:             Python の埋め込み<2>.
                                                             (line   11)
* path (sys モジュール) <2>:             インタープリタの初期化と終了処理.
                                                             (line    7)
* path (sys モジュール) <3>:             プロセスワイドのパラメータ.
                                                             (line  134)
* Path (zipfile のクラス):               Path オブジェクト.  (line    6)
* path based finder:                     パスベース・ファインダー.
                                                             (line    6)
* path based finder <1>:                 用語集<2>.          (line 1150)
* Path browser:                          File メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   23)
* path entry:                            用語集<2>.          (line 1130)
* path entry finder:                     用語集<2>.          (line 1135)
* path entry hook:                       用語集<2>.          (line 1144)
* path hooks:                            インポートフック.   (line    6)
* path_hook() (importlib.machinery.FileFinder のクラスメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  193)
* path_hooks (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1327)
* path_importer_cache (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line 1336)
* path_mtime() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  368)
* path_return_ok() (http.cookiejar.CookiePolicy のメソッド): CookiePolicy オブジェクト.
                                                             (line   59)
* path_stats() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  349)
* path_stats() (importlib.machinery.SourceFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  223)
* path-like object:                      用語集<2>.          (line 1155)
* Path.stem (zipfile モジュール):        Path オブジェクト.  (line   76)
* Path.suffix (zipfile モジュール):      Path オブジェクト.  (line   69)
* Path.suffixes (zipfile モジュール):    Path オブジェクト.  (line   82)
* path() (importlib.resources モジュール): 関数 API.         (line  110)
* pathconf_names (os モジュール):        ファイルとディレクトリ.
                                                             (line  678)
* pathconf() (os モジュール):            ファイルとディレクトリ.
                                                             (line  656)
* PathEntryFinder (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   58)
* PATHEXT:                               その他の改善<2>.    (line   30)
* PATHEXT <1>:                           Library<37>.        (line  138)
* PATHEXT <2>:                           インストーラの GUI なしでインストールする.
                                                             (line   78)
* PATHEXT <3>:                           インストーラの GUI なしでインストールする.
                                                             (line   83)
* PATHEXT <4>:                           Python を構成する<2>.
                                                             (line    8)
* PATHEXT <5>:                           ディレクトリとファイルの操作.
                                                             (line  442)
* PathFinder (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  108)
* PathLike (os のクラス):                プロセスのパラメーター.
                                                             (line  120)
* pathname2url() (urllib.request モジュール): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  145)
* pathsep (os モジュール):               雑多なシステム情報. (line  135)
* Pattern (re のクラス):                 正規表現オブジェクト.
                                                             (line    6)
* pattern (re.Pattern の属性):           正規表現オブジェクト.
                                                             (line  121)
* pattern (re.PatternError の属性):      例外<3>.            (line   19)
* Pattern (typing のクラス):             Aliases to other concrete types.
                                                             (line    6)
* pattern matching:                      match 文<2>.        (line    6)
* PatternError:                          例外<3>.            (line    6)
* pause_reading() (asyncio.ReadTransport のメソッド): 読み出し専用のトランスポート.
                                                             (line   12)
* pause_writing() (asyncio.BaseProtocol のメソッド): 基底プロトコル<2>.
                                                             (line   41)
* pause() (signal モジュール):           モジュールの内容<2>.
                                                             (line  310)
* PAX_FORMAT (tarfile モジュール):       tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  333)
* pax_headers (tarfile.TarFile の属性):  TarFile オブジェクト.
                                                             (line  334)
* pax_headers (tarfile.TarInfo の属性):  TarInfo オブジェクト.
                                                             (line  163)
* pbkdf2_hmac() (hashlib モジュール):    鍵導出.             (line   11)
* pd() (turtle モジュール):              描画状態.           (line    6)
* Pdb (class in pdb):                    pdb --- Python デバッガ.
                                                             (line   17)
* Pdb (pdb のクラス):                    pdb --- Python デバッガ.
                                                             (line  182)
* pdf() (statistics.NormalDist のメソッド): NormalDist オブジェクト.
                                                             (line   74)
* peek() (bz2.BZ2File のメソッド):       ファイルの圧縮/解凍.
                                                             (line   72)
* peek() (gzip.GzipFile のメソッド):     gzip --- gzip ファイルのサポート.
                                                             (line  130)
* peek() (io.BufferedReader のメソッド): バッファ付きストリーム.
                                                             (line   77)
* peek() (lzma.LZMAFile のメソッド):     圧縮ファイルへの読み書き.
                                                             (line   85)
* peek() (weakref.finalize のメソッド):  weakref --- 弱参照. (line  297)
* PEM_cert_to_DER_cert() (ssl モジュール): 証明書の取り扱い. (line   58)
* pen() (turtle モジュール):             描画状態.           (line   32)
* pencolor() (turtle モジュール):        色の制御<2>.        (line    6)
* pending (ssl.MemoryBIO の属性):        メモリ BIO サポート<2>.
                                                             (line  137)
* pending() (ssl.SSLSocket のメソッド):  SSL ソケット.       (line  329)
* PendingDeprecationWarning:             警告.               (line   28)
* pendown() (turtle モジュール):         描画状態.           (line    6)
* pensize() (turtle モジュール):         描画状態.           (line   18)
* penup() (turtle モジュール):           描画状態.           (line   12)
* PEP:                                   用語集<2>.          (line 1168)
* PERCENT (token モジュール):            token --- Python 解析木で使われる定数.
                                                             (line  119)
* PERCENTEQUAL (token モジュール):       token --- Python 解析木で使われる定数.
                                                             (line  183)
* perf_counter_ns() (time モジュール):   関数<5>.            (line  235)
* perf_counter() (time モジュール):      関数<5>.            (line  213)
* perm() (math モジュール):              数論および数表現の関数.
                                                             (line  223)
* PermissionError:                       OS 例外.            (line   97)
* permutations() (itertools モジュール): Itertool関数.       (line  434)
* persistent_id (pickle プロトコル):     外部オブジェクトの永続化.
                                                             (line    6)
* persistent_id() (pickle.Pickler のメソッド): モジュールインターフェース.
                                                             (line  162)
* persistent_load (pickle プロトコル):   外部オブジェクトの永続化.
                                                             (line    6)
* persistent_load() (pickle.Unpickler のメソッド): モジュールインターフェース.
                                                             (line  282)
* PF_CAN (socket モジュール):            定数<8>.            (line  128)
* PF_DIVERT (socket モジュール):         定数<8>.            (line  202)
* PF_PACKET (socket モジュール):         定数<8>.            (line  212)
* PF_RDS (socket モジュール):            定数<8>.            (line  234)
* pformat() (pprint モジュール):         関数<4>.            (line   76)
* pformat() (pprint.PrettyPrinter のメソッド): PrettyPrinter オブジェクト.
                                                             (line   50)
* pgettext() (gettext モジュール):       GNU gettext API.    (line   64)
* pgettext() (gettext.GNUTranslations のメソッド): GNUTranslations クラス.
                                                             (line   68)
* pgettext() (gettext.NullTranslations のメソッド): NullTranslations クラス.
                                                             (line   52)
* PGO (test.support モジュール):         test support --- テストのためのユーティリティ関数.
                                                             (line  107)
* phase() (cmath モジュール):            極座標変換.         (line   18)
* Philbrick, Geoff:                      拡張モジュール関数のキーワードパラメタ.
                                                             (line   24)
* pi (cmath モジュール):                 定数<3>.            (line    6)
* pi (math モジュール):                  定数<2>.            (line    6)
* pi() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   54)
* pickle 化;オブジェクト:                pickle --- Python オブジェクトの直列化.
                                                             (line    8)
* pickle() (copyreg モジュール):         copyreg --- pickle サポート関数を登録する.
                                                             (line   23)
* PickleBuffer (pickle のクラス):        モジュールインターフェース.
                                                             (line  313)
* PickleError:                           モジュールインターフェース.
                                                             (line   94)
* Pickler (pickle のクラス):             モジュールインターフェース.
                                                             (line  120)
* pickletools コマンドラインオプション; -a: コマンドラインオプション<6>.
                                                             (line    6)
* pickletools コマンドラインオプション; -annotate: コマンドラインオプション<6>.
                                                             (line    6)
* pickletools コマンドラインオプション; -indentlevel: コマンドラインオプション<6>.
                                                             (line   14)
* pickletools コマンドラインオプション; -l: コマンドラインオプション<6>.
                                                             (line   14)
* pickletools コマンドラインオプション; -m: コマンドラインオプション<6>.
                                                             (line   18)
* pickletools コマンドラインオプション; -memo: コマンドラインオプション<6>.
                                                             (line   18)
* pickletools コマンドラインオプション; -o: コマンドラインオプション<6>.
                                                             (line   10)
* pickletools コマンドラインオプション; -output: コマンドラインオプション<6>.
                                                             (line   10)
* pickletools コマンドラインオプション; -p: コマンドラインオプション<6>.
                                                             (line   23)
* pickletools コマンドラインオプション; -preamble: コマンドラインオプション<6>.
                                                             (line   23)
* PicklingError:                         モジュールインターフェース.
                                                             (line   99)
* pid (asyncio.subprocess.Process の属性): サブプロセスとやりとりする.
                                                             (line  139)
* pid (multiprocessing.Process の属性):  Process クラスと例外.
                                                             (line  122)
* pid (subprocess.Popen の属性):         Popen オブジェクト. (line  144)
* PIDFD_NONBLOCK (os モジュール):        プロセス管理.       (line  375)
* pidfd_open() (os モジュール):          プロセス管理.       (line  362)
* pidfd_send_signal() (signal モジュール): モジュールの内容<2>.
                                                             (line  328)
* PidfdChildWatcher (asyncio のクラス):  プロセスのウオッチャー.
                                                             (line  163)
* PIP_USER:                              Windows<40>.        (line  102)
* PIPE (subprocess モジュール):          subprocess モジュールを使う.
                                                             (line  150)
* PIPE_BUF (select モジュール):          select --- I/O 完了の待機.
                                                             (line  164)
* pipe_connection_lost() (asyncio.SubprocessProtocol のメソッド): サブプロセスプロトコル.
                                                             (line   19)
* pipe_data_received() (asyncio.SubprocessProtocol のメソッド): サブプロセスプロトコル.
                                                             (line   10)
* PIPE_MAX_SIZE (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  112)
* Pipe() (multiprocessing モジュール):   パイプ Pipe とキュー Queue.
                                                             (line   80)
* pipe() (os モジュール):                ファイル記述子の操作.
                                                             (line  490)
* pipe2() (os モジュール):               ファイル記述子の操作.
                                                             (line  500)
* placeholder (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  268)
* platform (in module sys):              プロセスワイドのパラメータ.
                                                             (line  171)
* platform (sys モジュール):             sys --- システム固有のパラメーターと関数.
                                                             (line 1346)
* platform() (platform モジュール):      クロスプラットフォーム.
                                                             (line   44)
* platlibdir (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1411)
* PlaySound() (winsound モジュール):     winsound --- Windows 用の音声再生インターフェース.
                                                             (line   20)
* plist;ファイル:                        plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line    8)
* plock() (os モジュール):               プロセス管理.       (line  387)
* PLUS (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   79)
* plus() (decimal.Context のメソッド):   Context オブジェクト.
                                                             (line  425)
* PLUSEQUAL (token モジュール):          token --- Python 解析木で使われる定数.
                                                             (line  167)
* pm() (pdb モジュール):                 pdb --- Python デバッガ.
                                                             (line  173)
* POINTER() (ctypes モジュール):         ユーティリティー関数.
                                                             (line  147)
* pointer() (ctypes モジュール):         ユーティリティー関数.
                                                             (line  153)
* polar() (cmath モジュール):            極座標変換.         (line   35)
* Policy (email.policy のクラス):        email policy Policy Objects.
                                                             (line  127)
* poll() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   42)
* poll() (select モジュール):            select --- I/O 完了の待機.
                                                             (line   89)
* poll() (select.devpoll のメソッド):    /dev/poll ポーリングオブジェクト.
                                                             (line   64)
* poll() (select.epoll のメソッド):      エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   97)
* poll() (select.poll のメソッド):       ポーリングオブジェクト.
                                                             (line   77)
* poll() (subprocess.Popen のメソッド):  Popen オブジェクト. (line    9)
* PollSelector (selectors のクラス):     クラス<4>.          (line  174)
* Pool (multiprocessing.pool のクラス):  プロセスプール.     (line    9)
* pop_all() (contextlib.ExitStack のメソッド): ユーティリティ.
                                                             (line  595)
* POP_BLOCK (opcode):                    Python バイトコード命令.
                                                             (line 1402)
* POP_EXCEPT (opcode):                   Python バイトコード命令.
                                                             (line  432)
* POP_JUMP_IF_FALSE (opcode):            Python バイトコード命令.
                                                             (line  860)
* POP_JUMP_IF_NONE (opcode):             Python バイトコード命令.
                                                             (line  887)
* POP_JUMP_IF_NOT_NONE (opcode):         Python バイトコード命令.
                                                             (line  875)
* POP_JUMP_IF_TRUE (opcode):             Python バイトコード命令.
                                                             (line  845)
* pop_source() (shlex.shlex のメソッド): shlex オブジェクト. (line   63)
* POP_TOP (opcode):                      Python バイトコード命令.
                                                             (line  130)
* pop() (array.array のメソッド):        array --- 効率的な数値配列.
                                                             (line  214)
* pop() (collections.deque のメソッド):  deque オブジェクト. (line   87)
* pop() (dict のメソッド):               マッピング型 --- dict.
                                                             (line  172)
* pop() (frozenset のメソッド):          set（集合）型 --- set frozenset.
                                                             (line  206)
* pop() (mailbox.Mailbox のメソッド):    Mailbox オブジェクト.
                                                             (line  212)
* pop() (シーケンスのメソッド):          ミュータブルなシーケンス型.
                                                             (line   16)
* POP3 (poplib のクラス):                poplib --- POP3 プロトコルクライアント.
                                                             (line   34)
* POP3_SSL (poplib のクラス):            poplib --- POP3 プロトコルクライアント.
                                                             (line   53)
* POP3;プロトコル:                       poplib --- POP3 プロトコルクライアント.
                                                             (line    8)
* Popen (subprocess のクラス):           Popen コンストラクター.
                                                             (line   11)
* popen() (os モジュール):               I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* popen() (os モジュール) <1>:           プロセス管理.       (line  395)
* popen() (os モジュール) <2>:           select --- I/O 完了の待機.
                                                             (line  144)
* popitem() (collections.OrderedDict のメソッド): OrderedDict オブジェクト.
                                                             (line   65)
* popitem() (dict のメソッド):           マッピング型 --- dict.
                                                             (line  179)
* popitem() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  220)
* popleft() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   93)
* port (http.cookiejar.Cookie の属性):   Cookieオブジェクト<2>.
                                                             (line   35)
* port_specified (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   81)
* portion:                               用語集<2>.          (line 1182)
* pos (json.JSONDecodeError の属性):     例外<16>.           (line   18)
* pos (re.Match の属性):                 マッチオブジェクト. (line  171)
* pos (re.PatternError の属性):          例外<3>.            (line   23)
* pos() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  137)
* pos() (turtle モジュール):             Turtle の状態を知る.
                                                             (line    6)
* position (xml.etree.ElementTree.ParseError の属性): 例外<18>.
                                                             (line   18)
* position() (turtle モジュール):        Turtle の状態を知る.
                                                             (line    6)
* Positions (dis のクラス):              Python バイトコード命令.
                                                             (line  102)
* positions (inspect.FrameInfo の属性):  インタープリタスタック.
                                                             (line   42)
* positions (inspect.Traceback の属性):  インタープリタスタック.
                                                             (line   82)
* Positions.col_offset (dis モジュール): Python バイトコード命令.
                                                             (line  111)
* Positions.end_col_offset (dis モジュール): Python バイトコード命令.
                                                             (line  113)
* Positions.end_lineno (dis モジュール): Python バイトコード命令.
                                                             (line  109)
* Positions.lineno (dis モジュール):     Python バイトコード命令.
                                                             (line  107)
* POSIX Shared Memory:                   multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line   10)
* POSIX_FADV_DONTNEED (os モジュール):   ファイル記述子の操作.
                                                             (line  534)
* POSIX_FADV_NOREUSE (os モジュール):    ファイル記述子の操作.
                                                             (line  534)
* POSIX_FADV_NORMAL (os モジュール):     ファイル記述子の操作.
                                                             (line  534)
* POSIX_FADV_RANDOM (os モジュール):     ファイル記述子の操作.
                                                             (line  534)
* POSIX_FADV_SEQUENTIAL (os モジュール): ファイル記述子の操作.
                                                             (line  534)
* POSIX_FADV_WILLNEED (os モジュール):   ファイル記述子の操作.
                                                             (line  534)
* posix_fadvise() (os モジュール):       ファイル記述子の操作.
                                                             (line  520)
* posix_fallocate() (os モジュール):     ファイル記述子の操作.
                                                             (line  511)
* posix_openpt() (os モジュール):        ファイル記述子の操作.
                                                             (line  560)
* POSIX_SPAWN_CLOSE (os モジュール):     プロセス管理.       (line  462)
* POSIX_SPAWN_CLOSEFROM (os モジュール): プロセス管理.       (line  474)
* POSIX_SPAWN_DUP2 (os モジュール):      プロセス管理.       (line  468)
* POSIX_SPAWN_OPEN (os モジュール):      プロセス管理.       (line  456)
* posix_spawn() (os モジュール):         プロセス管理.       (line  432)
* posix_spawnp() (os モジュール):        プロセス管理.       (line  535)
* POSIX;I/O control:                     termios --- POSIX スタイルの端末制御.
                                                             (line    6)
* PosixPath (pathlib のクラス):          具象パス.           (line   21)
* post_handshake_auth (ssl.SSLContext の属性): SSL コンテキスト.
                                                             (line  588)
* post_mortem() (pdb モジュール):        pdb --- Python デバッガ.
                                                             (line  166)
* post_setup() (venv.EnvBuilder のメソッド): API<2>.         (line  172)
* postcmd() (cmd.Cmd のメソッド):        Cmdオブジェクト.    (line  103)
* postloop() (cmd.Cmd のメソッド):       Cmdオブジェクト.    (line  119)
* Pow (ast のクラス):                    式 expression<2>.   (line   55)
* pow() (math モジュール):               指数関数と対数関数. (line   70)
* pow() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  142)
* power;演算:                            べき乗演算 power operator.
                                                             (line    6)
* power() (decimal.Context のメソッド):  Context オブジェクト.
                                                             (line  431)
* pp (pdb command):                      デバッガコマンド.   (line  271)
* pp() (pprint モジュール):              関数<4>.            (line    6)
* pprint() (pprint モジュール):          関数<4>.            (line   67)
* pprint() (pprint.PrettyPrinter のメソッド): PrettyPrinter オブジェクト.
                                                             (line   55)
* prcal() (calendar モジュール):         calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  340)
* pread() (os モジュール):               ファイル記述子の操作.
                                                             (line  548)
* preadv() (os モジュール):              ファイル記述子の操作.
                                                             (line  578)
* preamble (email.message.EmailMessage の属性): email message Representing an email message.
                                                             (line  681)
* preamble (email.message.Message の属性): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  696)
* precmd() (cmd.Cmd のメソッド):         Cmdオブジェクト.    (line   93)
* prefix (sys モジュール):               sys --- システム固有のパラメーターと関数.
                                                             (line 1436)
* prefix (xml.dom.Attr の属性):          Attr オブジェクト.  (line   18)
* prefix (xml.dom.Node の属性):          Node オブジェクト.  (line   68)
* prefix (zipimport.zipimporter の属性): zipimporter オブジェクト.
                                                             (line  101)
* PREFIXES (site モジュール):            モジュールの内容<5>.
                                                             (line    6)
* prefixlen (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line  131)
* prefixlen (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  329)
* preloop() (cmd.Cmd のメソッド):        Cmdオブジェクト.    (line  113)
* prepare_class() (types モジュール):    動的な型生成.       (line   21)
* prepare_input_source() (xml.sax.saxutils モジュール): xml sax saxutils --- SAX ユーティリティー.
                                                             (line   78)
* prepare() (graphlib.TopologicalSorter のメソッド): graphlib --- グラフ構造を操作する機能.
                                                             (line   97)
* prepare() (logging.handlers.QueueHandler のメソッド): QueueHandler.
                                                             (line   45)
* prepare() (logging.handlers.QueueListener のメソッド): QueueListener.
                                                             (line   58)
* PrepareProtocol (sqlite3 のクラス):    PrepareProtocol オブジェクト.
                                                             (line    6)
* PrettyPrinter (pprint のクラス):       PrettyPrinter オブジェクト.
                                                             (line    6)
* prev() (tkinter.ttk.Treeview のメソッド): ttk Treeview.    (line  231)
* previousSibling (xml.dom.Node の属性): Node オブジェクト.  (line   32)
* print_callees() (pstats.Stats のメソッド): Stats クラス.   (line  202)
* print_callers() (pstats.Stats のメソッド): Stats クラス.   (line  183)
* print_exc() (timeit.Timer のメソッド): Python インターフェイス.
                                                             (line  125)
* print_exc() (traceback モジュール):    モジュールレベルの関数<2>.
                                                             (line   57)
* print_exception() (traceback モジュール): モジュールレベルの関数<2>.
                                                             (line   24)
* print_help() (argparse.ArgumentParser のメソッド): ヘルプの表示.
                                                             (line   16)
* print_last() (traceback モジュール):   モジュールレベルの関数<2>.
                                                             (line   62)
* print_stack() (asyncio.Task のメソッド): Task オブジェクト.
                                                             (line  143)
* print_stack() (traceback モジュール):  モジュールレベルの関数<2>.
                                                             (line   68)
* print_stats() (profile.Profile のメソッド): リファレンスマニュアル -- profile と cProfile.
                                                             (line   89)
* print_stats() (pstats.Stats のメソッド): Stats クラス.     (line  155)
* print_tb() (traceback モジュール):     モジュールレベルの関数<2>.
                                                             (line    6)
* print_usage() (argparse.ArgumentParser のメソッド): ヘルプの表示.
                                                             (line   10)
* print_usage() (optparse.OptionParser のメソッド): その他のメソッド.
                                                             (line   15)
* print_version() (optparse.OptionParser のメソッド): バージョン番号の出力.
                                                             (line   26)
* print_warning() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  415)
* print() (traceback.TracebackException のメソッド): TracebackException オブジェクト.
                                                             (line  135)
* print() (組み込み関数);__str__() (オブジェクトメソッド): 基本的なカスタマイズ.
                                                             (line  128)
* printable (string モジュール):         文字列定数.         (line   40)
* printdir() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  242)
* printf 形式の書式化:                   printf 形式の文字列書式化.
                                                             (line    6)
* printf 形式の書式化 <1>:               printf 形式での bytes の書式化.
                                                             (line    6)
* PRIO_DARWIN_BG (os モジュール):        プロセスのパラメーター.
                                                             (line  297)
* PRIO_DARWIN_NONUI (os モジュール):     プロセスのパラメーター.
                                                             (line  297)
* PRIO_DARWIN_PROCESS (os モジュール):   プロセスのパラメーター.
                                                             (line  297)
* PRIO_DARWIN_THREAD (os モジュール):    プロセスのパラメーター.
                                                             (line  297)
* PRIO_PGRP (os モジュール):             プロセスのパラメーター.
                                                             (line  286)
* PRIO_PROCESS (os モジュール):          プロセスのパラメーター.
                                                             (line  286)
* PRIO_USER (os モジュール):             プロセスのパラメーター.
                                                             (line  286)
* PriorityQueue (asyncio のクラス):      優先度付きのキュー. (line    6)
* PriorityQueue (queue のクラス):        queue --- 同期キュークラス.
                                                             (line   47)
* prlimit() (resource モジュール):       リソースの制限.     (line   57)
* prmonth() (calendar モジュール):       calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  330)
* prmonth() (calendar.TextCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  135)
* ProactorEventLoop (asyncio のクラス):  イベントループの実装.
                                                             (line   31)
* procedure;call:                        式文 expression statement.
                                                             (line   16)
* Process (multiprocessing のクラス):    Process クラスと例外.
                                                             (line    6)
* process_cpu_count() (os モジュール):   雑多なシステム情報. (line   57)
* process_exited() (asyncio.SubprocessProtocol のメソッド): サブプロセスプロトコル.
                                                             (line   26)
* process_request() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  151)
* process_time_ns() (time モジュール):   関数<5>.            (line  254)
* process_time() (time モジュール):      関数<5>.            (line  242)
* process_tokens() (tabnanny モジュール): tabnanny --- あいまいなインデントの検出.
                                                             (line   43)
* process;id:                            プロセスのパラメーター.
                                                             (line  255)
* process;kill:                          プロセス管理.       (line  326)
* process;kill <1>:                      プロセス管理.       (line  348)
* process;グループ:                      プロセスのパラメーター.
                                                             (line  190)
* process;グループ <1>:                  プロセスのパラメーター.
                                                             (line  249)
* process;シグナル:                      プロセス管理.       (line  326)
* process;シグナル <1>:                  プロセス管理.       (line  348)
* process;スケジューリング優先度:        プロセスのパラメーター.
                                                             (line  273)
* process;スケジューリング優先度 <1>:    プロセスのパラメーター.
                                                             (line  461)
* process;親の ID:                       プロセスのパラメーター.
                                                             (line  262)
* process() (logging.LoggerAdapter のメソッド): LoggerAdapter オブジェクト.
                                                             (line   20)
* ProcessError:                          Process クラスと例外.
                                                             (line  227)
* processes, light-weight:               _thread --- 低水準なスレッド API.
                                                             (line    6)
* ProcessingInstruction() (xml.etree.ElementTree モジュール): 関数<9>.
                                                             (line  181)
* processingInstruction() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line  155)
* ProcessingInstructionHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  264)
* ProcessLookupError:                    OS 例外.            (line  106)
* processor() (platform モジュール):     クロスプラットフォーム.
                                                             (line   65)
* ProcessPoolExecutor (concurrent.futures のクラス): ProcessPoolExecutor.
                                                             (line   21)
* prod() (math モジュール):              数論および数表現の関数.
                                                             (line  238)
* product() (itertools モジュール):      Itertool関数.       (line  485)
* Profile (profile のクラス):            リファレンスマニュアル -- profile と cProfile.
                                                             (line   34)
* profile function:                      threading --- スレッドベースの並列処理.
                                                             (line  180)
* profile function <1>:                  threading --- スレッドベースの並列処理.
                                                             (line  198)
* profile function <2>:                  sys --- システム固有のパラメーターと関数.
                                                             (line  920)
* profile function <3>:                  sys --- システム固有のパラメーターと関数.
                                                             (line 1481)
* PROFILE_TASK:                          Build<14>.          (line   13)
* PROFILE_TASK <1>:                      パフォーマンスに関するオプション.
                                                             (line   12)
* profiler:                              sys --- システム固有のパラメーターと関数.
                                                             (line  920)
* profiler <1>:                          sys --- システム固有のパラメーターと関数.
                                                             (line 1481)
* profiling, deterministic:              プロファイラとは.   (line    6)
* ProgrammingError:                      例外<7>.            (line   75)
* Progressbar (tkinter.ttk のクラス):    ttk Progressbar.    (line    6)
* prompt (cmd.Cmd の属性):               Cmdオブジェクト.    (line  128)
* prompt_user_passwd() (urllib.request.FancyURLopener のメソッド): レガシーインターフェース.
                                                             (line  185)
* prompts, interpreter:                  sys --- システム固有のパラメーターと関数.
                                                             (line 1452)
* propagate (logging.Logger の属性):     ロガーオブジェクト. (line   50)
* property (組み込みクラス):             組み込み関数.       (line 1575)
* property list:                         plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line    8)
* property_declaration_handler (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line  105)
* property_dom_node (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line  112)
* property_lexical_handler (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line   98)
* property_xml_string (xml.sax.handler モジュール): xml sax handler --- SAX ハンドラーの基底クラス.
                                                             (line  119)
* property() (enum モジュール):          ユーティリティとデコレータ.
                                                             (line   40)
* PropertyMock (unittest.mock のクラス): Mock クラス.        (line  621)
* prot_c() (ftplib.FTP_TLS のメソッド):  FTP_TLS オブジェクト.
                                                             (line  111)
* prot_p() (ftplib.FTP_TLS のメソッド):  FTP_TLS オブジェクト.
                                                             (line  107)
* proto (socket.socket の属性):          socket オブジェクト.
                                                             (line  621)
* Protocol (asyncio のクラス):           基底プロトコル.     (line   11)
* protocol (ssl.SSLContext の属性):      SSL コンテキスト.   (line  607)
* Protocol (typing のクラス):            Other special directives.
                                                             (line  130)
* PROTOCOL_SSLv23 (ssl モジュール):      定数<9>.            (line  161)
* PROTOCOL_SSLv3 (ssl モジュール):       定数<9>.            (line  168)
* PROTOCOL_TLS (ssl モジュール):         定数<9>.            (line  131)
* PROTOCOL_TLS_CLIENT (ssl モジュール):  定数<9>.            (line  144)
* PROTOCOL_TLS_SERVER (ssl モジュール):  定数<9>.            (line  153)
* PROTOCOL_TLSv1 (ssl モジュール):       定数<9>.            (line  184)
* PROTOCOL_TLSv1_1 (ssl モジュール):     定数<9>.            (line  191)
* PROTOCOL_TLSv1_2 (ssl モジュール):     定数<9>.            (line  201)
* protocol_version (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  163)
* PROTOCOL_VERSION (imaplib.IMAP4 の属性): IMAP4 オブジェクト.
                                                             (line  401)
* ProtocolError (xmlrpc.client のクラス): ProtocolError オブジェクト.
                                                             (line    6)
* provisional API:                       用語集<2>.          (line 1192)
* provisional package:                   用語集<2>.          (line 1209)
* proxy() (weakref モジュール):          weakref --- 弱参照. (line  128)
* proxyauth() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  197)
* ProxyBasicAuthHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  365)
* ProxyDigestAuthHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  397)
* ProxyHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  293)
* ProxyType (weakref モジュール):        weakref --- 弱参照. (line  326)
* ProxyTypes (weakref モジュール):       weakref --- 弱参照. (line  334)
* pryear() (calendar.TextCalendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  149)
* ps1 (sys モジュール):                  sys --- システム固有のパラメーターと関数.
                                                             (line 1449)
* ps2 (sys モジュール):                  sys --- システム固有のパラメーターと関数.
                                                             (line 1449)
* pstdev() (statistics モジュール):      関数の詳細.         (line  362)
* pthread_getcpuclockid() (time モジュール): 関数<5>.        (line   21)
* pthread_kill() (signal モジュール):    モジュールの内容<2>.
                                                             (line  343)
* pthread_sigmask() (signal モジュール): モジュールの内容<2>.
                                                             (line  373)
* pthreads:                              _thread --- 低水準なスレッド API.
                                                             (line   15)
* pthreads (sys._emscripten_info の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  349)
* ptsname() (os モジュール):             ファイル記述子の操作.
                                                             (line  637)
* pu() (turtle モジュール):              描画状態.           (line   12)
* publicId (xml.dom.DocumentType の属性): DocumentType オブジェクト.
                                                             (line   16)
* PullDom (xml.dom.pulldom のクラス):    xml dom pulldom --- 部分的な DOM ツリー構築のサポート.
                                                             (line   76)
* punctuation (string モジュール):       文字列定数.         (line   35)
* punctuation_chars (shlex.shlex の属性): shlex オブジェクト.
                                                             (line  182)
* PurePath (pathlib のクラス):           純粋パス.           (line   10)
* PurePosixPath (pathlib のクラス):      純粋パス.           (line   74)
* PureWindowsPath (pathlib のクラス):    純粋パス.           (line   84)
* purge() (re モジュール):               関数<2>.            (line  280)
* Purpose.CLIENT_AUTH (ssl モジュール):  定数<9>.            (line  541)
* Purpose.SERVER_AUTH (ssl モジュール):  定数<9>.            (line  532)
* push_async_callback() (contextlib.AsyncExitStack のメソッド): ユーティリティ.
                                                             (line  646)
* push_async_exit() (contextlib.AsyncExitStack のメソッド): ユーティリティ.
                                                             (line  641)
* PUSH_EXC_INFO (opcode):                Python バイトコード命令.
                                                             (line  451)
* PUSH_NULL (opcode):                    Python バイトコード命令.
                                                             (line 1082)
* push_source() (shlex.shlex のメソッド): shlex オブジェクト.
                                                             (line   56)
* push_token() (shlex.shlex のメソッド): shlex オブジェクト. (line   16)
* push() (code.InteractiveConsole のメソッド): 対話的なコンソールオブジェクト.
                                                             (line   29)
* push() (contextlib.ExitStack のメソッド): ユーティリティ.  (line  564)
* put_nowait() (asyncio.Queue のメソッド): Queue.            (line   72)
* put_nowait() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  147)
* put_nowait() (queue.Queue のメソッド): キューオブジェクト. (line   42)
* put_nowait() (queue.SimpleQueue のメソッド): SimpleQueue オブジェクト.
                                                             (line   36)
* put() (asyncio.Queue のメソッド):      Queue.              (line   64)
* put() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  131)
* put() (multiprocessing.SimpleQueue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  241)
* put() (queue.Queue のメソッド):        キューオブジェクト. (line   29)
* put() (queue.SimpleQueue のメソッド):  SimpleQueue オブジェクト.
                                                             (line   21)
* putch() (msvcrt モジュール):           コンソール I/O 関連.
                                                             (line   34)
* putenv() (os モジュール):              プロセスのパラメーター.
                                                             (line  346)
* putheader() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line  178)
* putp() (curses モジュール):            関数<6>.            (line  379)
* putrequest() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line  168)
* putwch() (msvcrt モジュール):          コンソール I/O 関連.
                                                             (line   39)
* putwin() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  442)
* pvariance() (statistics モジュール):   関数の詳細.         (line  370)
* pwd() (ftplib.FTP のメソッド):         FTP オブジェクト.   (line  342)
* pwrite() (os モジュール):              ファイル記述子の操作.
                                                             (line  651)
* pwritev() (os モジュール):             ファイル記述子の操作.
                                                             (line  662)
* Py_ABS (C macro):                      便利なマクロ.       (line   35)
* Py_AddPendingCall (C function):        非同期通知.         (line   10)
* Py_ALWAYS_INLINE (C macro):            便利なマクロ.       (line   41)
* Py_ASNATIVEBYTES_ALLOW_INDEX (C macro): 整数型オブジェクト integer object.
                                                             (line  463)
* Py_ASNATIVEBYTES_BIG_ENDIAN (C macro): 整数型オブジェクト integer object.
                                                             (line  448)
* Py_ASNATIVEBYTES_DEFAULTS (C macro):   整数型オブジェクト integer object.
                                                             (line  445)
* Py_ASNATIVEBYTES_LITTLE_ENDIAN (C macro): 整数型オブジェクト integer object.
                                                             (line  451)
* Py_ASNATIVEBYTES_NATIVE_ENDIAN (C macro): 整数型オブジェクト integer object.
                                                             (line  454)
* Py_ASNATIVEBYTES_REJECT_NEGATIVE (C macro): 整数型オブジェクト integer object.
                                                             (line  460)
* Py_ASNATIVEBYTES_UNSIGNED_BUFFER (C macro): 整数型オブジェクト integer object.
                                                             (line  457)
* Py_AtExit (C function):                プロセス制御.       (line   32)
* Py_AUDIT_READ (C macro):               Member flags.       (line   12)
* Py_AuditHookFunction (C type):         システム関数.       (line  149)
* Py_BEGIN_ALLOW_THREADS (C macro):      拡張コード内で GIL を解放する.
                                                             (line   22)
* Py_BEGIN_ALLOW_THREADS (C macro) <1>:  高レベルAPI.        (line  159)
* Py_BEGIN_CRITICAL_SECTION (C macro):   Python Critical Section API.
                                                             (line   49)
* Py_BEGIN_CRITICAL_SECTION2 (C macro):  Python Critical Section API.
                                                             (line   77)
* Py_BLOCK_THREADS (C macro):            高レベルAPI.        (line  173)
* Py_buffer (C type):                    buffer 構造体.      (line   23)
* Py_buffer.buf (C member):              buffer 構造体.      (line   25)
* Py_buffer.format (C member):           buffer 構造体.      (line   87)
* Py_buffer.internal (C member):         buffer 構造体.      (line  148)
* Py_buffer.itemsize (C member):         buffer 構造体.      (line   67)
* Py_buffer.len (C member):              buffer 構造体.      (line   50)
* Py_buffer.ndim (C member):             buffer 構造体.      (line   96)
* Py_buffer.obj (C member):              buffer 構造体.      (line   36)
* Py_buffer.readonly (C member):         buffer 構造体.      (line   62)
* Py_buffer.shape (C member):            buffer 構造体.      (line  105)
* Py_buffer.strides (C member):          buffer 構造体.      (line  118)
* Py_buffer.suboffsets (C member):       buffer 構造体.      (line  130)
* Py_BuildValue (C function):            値の構築.           (line    6)
* Py_BytesMain (C function):             インタープリタの初期化と終了処理.
                                                             (line  114)
* Py_BytesWarningFlag (C var):           グローバルな設定変数.
                                                             (line   15)
* Py_CHARMASK (C macro):                 便利なマクロ.       (line   66)
* Py_CLEAR (C function):                 参照カウント.       (line  149)
* Py_CompileString (C function):         超高水準レイヤ.     (line  214)
* Py_CompileString (C function) <1>:     超高水準レイヤ.     (line  301)
* Py_CompileString (C function) <2>:     超高水準レイヤ.     (line  306)
* Py_CompileString (C function) <3>:     超高水準レイヤ.     (line  313)
* Py_CompileStringExFlags (C function):  超高水準レイヤ.     (line  246)
* Py_CompileStringFlags (C function):    超高水準レイヤ.     (line  220)
* Py_CompileStringObject (C function):   超高水準レイヤ.     (line  225)
* Py_complex (C type):                   C 構造体としての複素数.
                                                             (line   10)
* Py_complex.imag (C member):            C 構造体としての複素数.
                                                             (line   17)
* Py_complex.real (C member):            C 構造体としての複素数.
                                                             (line   17)
* Py_CONSTANT_ELLIPSIS (C macro):        オブジェクトプロトコル object protocol.
                                                             (line   28)
* Py_CONSTANT_EMPTY_BYTES (C macro):     オブジェクトプロトコル object protocol.
                                                             (line   43)
* Py_CONSTANT_EMPTY_STR (C macro):       オブジェクトプロトコル object protocol.
                                                             (line   40)
* Py_CONSTANT_EMPTY_TUPLE (C macro):     オブジェクトプロトコル object protocol.
                                                             (line   46)
* Py_CONSTANT_FALSE (C macro):           オブジェクトプロトコル object protocol.
                                                             (line   22)
* Py_CONSTANT_NONE (C macro):            オブジェクトプロトコル object protocol.
                                                             (line   19)
* Py_CONSTANT_NOT_IMPLEMENTED (C macro): オブジェクトプロトコル object protocol.
                                                             (line   31)
* Py_CONSTANT_ONE (C macro):             オブジェクトプロトコル object protocol.
                                                             (line   37)
* Py_CONSTANT_TRUE (C macro):            オブジェクトプロトコル object protocol.
                                                             (line   25)
* Py_CONSTANT_ZERO (C macro):            オブジェクトプロトコル object protocol.
                                                             (line   34)
* PY_CXX_CONST (C macro):                API 関数.           (line  113)
* Py_DEBUG (C macro):                    デバッグ版ビルド Debugging Builds.
                                                             (line   17)
* Py_DEBUG (test.support モジュール):    test support --- テストのためのユーティリティ関数.
                                                             (line  117)
* Py_DebugFlag (C var):                  グローバルな設定変数.
                                                             (line   30)
* Py_DecodeLocale (C function):          オペレーティングシステム関連のユーティリティ.
                                                             (line  115)
* Py_DECREF (C function):                参照カウント法<2>.  (line   18)
* Py_DECREF (C function) <1>:            参照カウント.       (line  107)
* Py_DecRef (C function):                参照カウント.       (line  172)
* Py_DEPRECATED (C macro):               便利なマクロ.       (line   72)
* Py_DontWriteBytecodeFlag (C var):      グローバルな設定変数.
                                                             (line   44)
* Py_Ellipsis (C var):                   Ellipsis オブジェクト<2>.
                                                             (line    6)
* Py_EncodeLocale (C function):          オペレーティングシステム関連のユーティリティ.
                                                             (line  169)
* Py_END_ALLOW_THREADS (C macro):        拡張コード内で GIL を解放する.
                                                             (line   22)
* Py_END_ALLOW_THREADS (C macro) <1>:    高レベルAPI.        (line  166)
* Py_END_CRITICAL_SECTION (C macro):     Python Critical Section API.
                                                             (line   64)
* Py_END_CRITICAL_SECTION2 (C macro):    Python Critical Section API.
                                                             (line   93)
* Py_EndInterpreter (C function):        サブインタプリタサポート.
                                                             (line  200)
* Py_EnterRecursiveCall (C function):    再帰の管理.         (line   13)
* Py_EQ (C macro):                       PyTypeObject スロット.
                                                             (line 1041)
* Py_eval_input (C var):                 超高水準レイヤ.     (line  299)
* Py_Exit (C function):                  プロセス制御.       (line   22)
* Py_ExitStatusException (C function):   PyStatus.           (line   63)
* Py_False (C var):                      Boolean オブジェクト.
                                                             (line   21)
* Py_FatalError (C function):            プロセス制御.       (line    6)
* Py_FatalError():                       プロセスワイドのパラメータ.
                                                             (line  216)
* Py_FdIsInteractive (C function):       オペレーティングシステム関連のユーティリティ.
                                                             (line   18)
* Py_file_input (C var):                 超高水準レイヤ.     (line  304)
* Py_Finalize (C function):              インタープリタの初期化と終了処理.
                                                             (line  109)
* Py_FinalizeEx (C function):            プロセス制御.       (line   23)
* Py_FinalizeEx (C function) <1>:        プロセス制御.       (line   33)
* Py_FinalizeEx (C function) <2>:        インタープリタの初期化と終了処理.
                                                             (line    7)
* Py_FinalizeEx (C function) <3>:        インタープリタの初期化と終了処理.
                                                             (line   64)
* Py_FinalizeEx (C function) <4>:        サブインタプリタサポート.
                                                             (line  163)
* Py_FinalizeEx (C function) <5>:        サブインタプリタサポート.
                                                             (line  201)
* Py_FrozenFlag (C var):                 グローバルな設定変数.
                                                             (line   58)
* Py_GE (C macro):                       PyTypeObject スロット.
                                                             (line 1050)
* Py_GenericAlias (C function):          型ヒントのためのオブジェクト.
                                                             (line   10)
* Py_GenericAliasType (C var):           型ヒントのためのオブジェクト.
                                                             (line   43)
* Py_GetArgcArgv (C function):           Py_GetArgcArgv.     (line    6)
* Py_GetBuildInfo (C function):          プロセスワイドのパラメータ.
                                                             (line  203)
* Py_GetCompiler (C function):           プロセスワイドのパラメータ.
                                                             (line  192)
* Py_GetConstant (C function):           オブジェクトプロトコル object protocol.
                                                             (line    6)
* Py_GetConstantBorrowed (C function):   オブジェクトプロトコル object protocol.
                                                             (line   57)
* Py_GetCopyright (C function):          プロセスワイドのパラメータ.
                                                             (line  182)
* Py_GETENV (C macro):                   便利なマクロ.       (line   83)
* Py_GetExecPrefix (C function):         Python の埋め込み<2>.
                                                             (line   39)
* Py_GetExecPrefix (C function) <1>:     プロセスワイドのパラメータ.
                                                             (line   67)
* Py_GetPath (C function):               Python の埋め込み<2>.
                                                             (line   39)
* Py_GetPath (C function) <1>:           プロセスワイドのパラメータ.
                                                             (line  133)
* Py_GetPath():                          プロセスワイドのパラメータ.
                                                             (line    7)
* Py_GetPlatform (C function):           プロセスワイドのパラメータ.
                                                             (line  170)
* Py_GetPrefix (C function):             Python の埋め込み<2>.
                                                             (line   39)
* Py_GetPrefix (C function) <1>:         プロセスワイドのパラメータ.
                                                             (line   44)
* Py_GetProgramFullPath (C function):    Python の埋め込み<2>.
                                                             (line   39)
* Py_GetProgramFullPath (C function) <1>: プロセスワイドのパラメータ.
                                                             (line  114)
* Py_GetProgramName (C function):        プロセスワイドのパラメータ.
                                                             (line   29)
* Py_GetPythonHome (C function):         プロセスワイドのパラメータ.
                                                             (line  304)
* Py_GetVersion (C function):            プロセスワイドのパラメータ.
                                                             (line  156)
* Py_GT (C macro):                       PyTypeObject スロット.
                                                             (line 1047)
* Py_hash_t (C type):                    PyHash API.         (line    9)
* Py_HashPointer (C function):           PyHash API.         (line   80)
* Py_HashRandomizationFlag (C var):      グローバルな設定変数.
                                                             (line   72)
* Py_IgnoreEnvironmentFlag (C var):      グローバルな設定変数.
                                                             (line   87)
* Py_INCREF (C function):                参照カウント法<2>.  (line   18)
* Py_INCREF (C function) <1>:            参照カウント.       (line   43)
* Py_IncRef (C function):                参照カウント.       (line  166)
* Py_Initialize (C function):            Python の埋め込み<2>.
                                                             (line   11)
* Py_Initialize (C function) <1>:        インタープリタの初期化と終了処理.
                                                             (line    6)
* Py_Initialize (C function) <2>:        サブインタプリタサポート.
                                                             (line  163)
* Py_Initialize():                       プロセスワイドのパラメータ.
                                                             (line    7)
* Py_InitializeEx (C function):          インタープリタの初期化と終了処理.
                                                             (line   30)
* Py_InitializeFromConfig (C function):  インタープリタの初期化と終了処理.
                                                             (line   40)
* Py_InspectFlag (C var):                グローバルな設定変数.
                                                             (line  100)
* Py_InteractiveFlag (C var):            グローバルな設定変数.
                                                             (line  116)
* Py_Is (C function):                    Base object types and macros.
                                                             (line   55)
* Py_IS_TYPE (C function):               Base object types and macros.
                                                             (line   94)
* Py_IsFalse (C function):               Base object types and macros.
                                                             (line   76)
* Py_IsFinalizing (C function):          インタープリタの初期化と終了処理.
                                                             (line   57)
* Py_IsInitialized (C function):         Python の埋め込み<2>.
                                                             (line   48)
* Py_IsInitialized (C function) <1>:     インタープリタの初期化と終了処理.
                                                             (line   51)
* Py_IsNone (C function):                Base object types and macros.
                                                             (line   62)
* Py_IsolatedFlag (C var):               グローバルな設定変数.
                                                             (line  126)
* Py_IsTrue (C function):                Base object types and macros.
                                                             (line   69)
* Py_LE (C macro):                       PyTypeObject スロット.
                                                             (line 1038)
* Py_LeaveRecursiveCall (C function):    再帰の管理.         (line   33)
* Py_LegacyWindowsFSEncodingFlag (C var): グローバルな設定変数.
                                                             (line  142)
* Py_LegacyWindowsStdioFlag (C var):     グローバルな設定変数.
                                                             (line  162)
* Py_LIMITED_API (C macro):              Limited C API.      (line   11)
* Py_LT (C macro):                       PyTypeObject スロット.
                                                             (line 1035)
* Py_Main (C function):                  インタープリタの初期化と終了処理.
                                                             (line  122)
* PY_MAJOR_VERSION (C macro):            API と ABI のバージョニング.
                                                             (line   13)
* Py_MAX (C macro):                      便利なマクロ.       (line   88)
* Py_MEMBER_SIZE (C macro):              便利なマクロ.       (line   94)
* PY_MICRO_VERSION (C macro):            API と ABI のバージョニング.
                                                             (line   21)
* Py_MIN (C macro):                      便利なマクロ.       (line  100)
* PY_MINOR_VERSION (C macro):            API と ABI のバージョニング.
                                                             (line   17)
* Py_mod_create (C macro):               多段階初期化.       (line   64)
* Py_mod_exec (C macro):                 多段階初期化.       (line   98)
* Py_mod_gil (C macro):                  多段階初期化.       (line  141)
* Py_MOD_GIL_NOT_USED (C macro):         多段階初期化.       (line  151)
* Py_MOD_GIL_USED (C macro):             多段階初期化.       (line  145)
* Py_mod_multiple_interpreters (C macro): 多段階初期化.      (line  110)
* Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED (C macro): 多段階初期化.
                                                             (line  114)
* Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED (C macro): 多段階初期化.
                                                             (line  118)
* Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (C macro): 多段階初期化.
                                                             (line  124)
* PY_MONITORING_EVENT_BRANCH (C macro):  Managing the Monitoring State.
                                                             (line   44)
* PY_MONITORING_EVENT_C_RAISE (C macro): Managing the Monitoring State.
                                                             (line   50)
* PY_MONITORING_EVENT_C_RETURN (C macro): Managing the Monitoring State.
                                                             (line   53)
* PY_MONITORING_EVENT_CALL (C macro):    Managing the Monitoring State.
                                                             (line   47)
* PY_MONITORING_EVENT_EXCEPTION_HANDLED (C macro): Managing the Monitoring State.
                                                             (line   56)
* PY_MONITORING_EVENT_INSTRUCTION (C macro): Managing the Monitoring State.
                                                             (line   59)
* PY_MONITORING_EVENT_JUMP (C macro):    Managing the Monitoring State.
                                                             (line   62)
* PY_MONITORING_EVENT_LINE (C macro):    Managing the Monitoring State.
                                                             (line   65)
* PY_MONITORING_EVENT_PY_RESUME (C macro): Managing the Monitoring State.
                                                             (line   68)
* PY_MONITORING_EVENT_PY_RETURN (C macro): Managing the Monitoring State.
                                                             (line   71)
* PY_MONITORING_EVENT_PY_START (C macro): Managing the Monitoring State.
                                                             (line   74)
* PY_MONITORING_EVENT_PY_THROW (C macro): Managing the Monitoring State.
                                                             (line   77)
* PY_MONITORING_EVENT_PY_UNWIND (C macro): Managing the Monitoring State.
                                                             (line   80)
* PY_MONITORING_EVENT_PY_YIELD (C macro): Managing the Monitoring State.
                                                             (line   83)
* PY_MONITORING_EVENT_RAISE (C macro):   Managing the Monitoring State.
                                                             (line   86)
* PY_MONITORING_EVENT_RERAISE (C macro): Managing the Monitoring State.
                                                             (line   89)
* PY_MONITORING_EVENT_STOP_ITERATION (C macro): Managing the Monitoring State.
                                                             (line   92)
* Py_NE (C macro):                       PyTypeObject スロット.
                                                             (line 1044)
* Py_NewInterpreter (C function):        サブインタプリタサポート.
                                                             (line  190)
* Py_NewInterpreterFromConfig (C function): サブインタプリタサポート.
                                                             (line  106)
* Py_NewRef (C function):                参照カウント.       (line   75)
* Py_NO_INLINE (C macro):                便利なマクロ.       (line  106)
* Py_None (C var):                       None オブジェクト.  (line   11)
* Py_NoSiteFlag (C var):                 グローバルな設定変数.
                                                             (line  180)
* Py_NotImplemented (C var):             オブジェクトプロトコル object protocol.
                                                             (line   71)
* Py_NoUserSiteDirectory (C var):        グローバルな設定変数.
                                                             (line  196)
* py_object (ctypes のクラス):           基本データ型<2>.    (line  217)
* Py_OpenCodeHookFunction (C type):      ファイルオブジェクト.
                                                             (line   62)
* Py_OptimizeFlag (C var):               グローバルな設定変数.
                                                             (line  210)
* Py_PreInitialize (C function):         Preinitialize Python with PyPreConfig.
                                                             (line   21)
* Py_PreInitializeFromArgs (C function): Preinitialize Python with PyPreConfig.
                                                             (line   38)
* Py_PreInitializeFromBytesArgs (C function): Preinitialize Python with PyPreConfig.
                                                             (line   28)
* Py_PRINT_RAW (C macro):                オブジェクトプロトコル object protocol.
                                                             (line   82)
* Py_PRINT_RAW (Cのマクロ):              ファイルオブジェクト.
                                                             (line   93)
* PY_PYTHON:                             デフォルトのPythonバージョンのカスタマイズ.
                                                             (line   15)
* Py_QuietFlag (C var):                  グローバルな設定変数.
                                                             (line  221)
* Py_READONLY (C macro):                 Member flags.       (line    8)
* Py_REFCNT (C function):                参照カウント.       (line    9)
* Py_RELATIVE_OFFSET (C macro):          Member flags.       (line   17)
* PY_RELEASE_LEVEL (C macro):            API と ABI のバージョニング.
                                                             (line   25)
* PY_RELEASE_SERIAL (C macro):           API と ABI のバージョニング.
                                                             (line   30)
* Py_ReprEnter (C function):             再帰の管理.         (line   48)
* Py_ReprLeave (C function):             再帰の管理.         (line   65)
* PY_RESUME (monitoring event):          Events.             (line   43)
* PY_RETURN (monitoring event):          Events.             (line   48)
* Py_RETURN_FALSE (C macro):             Boolean オブジェクト.
                                                             (line   37)
* Py_RETURN_NONE (C macro):              None オブジェクト.  (line   19)
* Py_RETURN_NOTIMPLEMENTED (C macro):    オブジェクトプロトコル object protocol.
                                                             (line   76)
* Py_RETURN_RICHCOMPARE (C macro):       PyTypeObject スロット.
                                                             (line 1056)
* Py_RETURN_TRUE (C macro):              Boolean オブジェクト.
                                                             (line   41)
* Py_RunMain (C function):               インタープリタの初期化と終了処理.
                                                             (line  179)
* Py_SET_REFCNT (C function):            参照カウント.       (line   28)
* Py_SET_SIZE (C function):              Base object types and macros.
                                                             (line  117)
* Py_SET_TYPE (C function):              Base object types and macros.
                                                             (line  101)
* Py_SetProgramName (C function):        プロセスワイドのパラメータ.
                                                             (line    6)
* Py_SetPythonHome (C function):         プロセスワイドのパラメータ.
                                                             (line  286)
* Py_SETREF (C macro):                   参照カウント.       (line  178)
* Py_single_input (C var):               超高水準レイヤ.     (line  311)
* Py_SIZE (C function):                  Base object types and macros.
                                                             (line  107)
* Py_ssize_t (C type):                   型.                 (line   13)
* PY_SSIZE_T_MAX (C macro):              整数型オブジェクト integer object.
                                                             (line  238)
* PY_START (monitoring event):           Events.             (line   53)
* Py_STRINGIFY (C macro):                便利なマクロ.       (line  118)
* Py_T_BOOL (C macro):                   Member types.       (line   59)
* Py_T_BYTE (C macro):                   Member types.       (line   20)
* Py_T_CHAR (C macro):                   Member types.       (line   68)
* Py_T_DOUBLE (C macro):                 Member types.       (line   56)
* Py_T_FLOAT (C macro):                  Member types.       (line   53)
* Py_T_INT (C macro):                    Member types.       (line   26)
* Py_T_LONG (C macro):                   Member types.       (line   29)
* Py_T_LONGLONG (C macro):               Member types.       (line   32)
* Py_T_OBJECT_EX (C macro):              Member types.       (line   71)
* Py_T_PYSSIZET (C macro):               Member types.       (line   50)
* Py_T_SHORT (C macro):                  Member types.       (line   23)
* Py_T_STRING (C macro):                 Member types.       (line   62)
* Py_T_STRING_INPLACE (C macro):         Member types.       (line   65)
* Py_T_UBYTE (C macro):                  Member types.       (line   35)
* Py_T_UINT (C macro):                   Member types.       (line   38)
* Py_T_ULONG (C macro):                  Member types.       (line   44)
* Py_T_ULONGLONG (C macro):              Member types.       (line   47)
* Py_T_USHORT (C macro):                 Member types.       (line   41)
* PY_THROW (monitoring event):           Events.             (line   58)
* Py_TPFLAGS_BASE_EXC_SUBCLASS (C macro): PyTypeObject スロット.
                                                             (line  688)
* Py_TPFLAGS_BASETYPE (C macro):         PyTypeObject スロット.
                                                             (line  538)
* Py_TPFLAGS_BYTES_SUBCLASS (C macro):   PyTypeObject スロット.
                                                             (line  682)
* Py_TPFLAGS_DEFAULT (C macro):          PyTypeObject スロット.
                                                             (line  588)
* Py_TPFLAGS_DICT_SUBCLASS (C macro):    PyTypeObject スロット.
                                                             (line  686)
* Py_TPFLAGS_DISALLOW_INSTANTIATION (C macro): PyTypeObject スロット.
                                                             (line  743)
* Py_TPFLAGS_HAVE_FINALIZE (C macro):    PyTypeObject スロット.
                                                             (line  700)
* Py_TPFLAGS_HAVE_GC (C macro):          PyTypeObject スロット.
                                                             (line  566)
* Py_TPFLAGS_HAVE_VECTORCALL (C macro):  PyTypeObject スロット.
                                                             (line  711)
* Py_TPFLAGS_HEAPTYPE (C macro):         PyTypeObject スロット.
                                                             (line  520)
* Py_TPFLAGS_IMMUTABLETYPE (C macro):    PyTypeObject スロット.
                                                             (line  729)
* Py_TPFLAGS_ITEMS_AT_END (C macro):     PyTypeObject スロット.
                                                             (line  656)
* Py_TPFLAGS_LIST_SUBCLASS (C macro):    PyTypeObject スロット.
                                                             (line  678)
* Py_TPFLAGS_LONG_SUBCLASS (C macro):    PyTypeObject スロット.
                                                             (line  676)
* Py_TPFLAGS_MANAGED_DICT (C macro):     PyTypeObject スロット.
                                                             (line  624)
* Py_TPFLAGS_MANAGED_WEAKREF (C macro):  PyTypeObject スロット.
                                                             (line  644)
* Py_TPFLAGS_MAPPING (C macro):          PyTypeObject スロット.
                                                             (line  771)
* Py_TPFLAGS_METHOD_DESCRIPTOR (C macro): PyTypeObject スロット.
                                                             (line  599)
* Py_TPFLAGS_READY (C macro):            PyTypeObject スロット.
                                                             (line  548)
* Py_TPFLAGS_READYING (C macro):         PyTypeObject スロット.
                                                             (line  557)
* Py_TPFLAGS_SEQUENCE (C macro):         PyTypeObject スロット.
                                                             (line  795)
* Py_TPFLAGS_TUPLE_SUBCLASS (C macro):   PyTypeObject スロット.
                                                             (line  680)
* Py_TPFLAGS_TYPE_SUBCLASS (C macro):    PyTypeObject スロット.
                                                             (line  690)
* Py_TPFLAGS_UNICODE_SUBCLASS (C macro): PyTypeObject スロット.
                                                             (line  684)
* Py_TPFLAGS_VALID_VERSION_TAG (C macro): PyTypeObject スロット.
                                                             (line  819)
* Py_tracefunc (C type):                 プロファイルとトレース profiling and tracing.
                                                             (line   19)
* Py_True (C var):                       Boolean オブジェクト.
                                                             (line   29)
* Py_tss_NEEDS_INIT (C macro):           スレッド固有ストレージ Thread Specific Storage TSS API.
                                                             (line   27)
* Py_tss_t (C type):                     スレッド固有ストレージ Thread Specific Storage TSS API.
                                                             (line   17)
* Py_TYPE (C function):                  Base object types and macros.
                                                             (line   83)
* Py_UCS1 (C type):                      Unicode 型.         (line    9)
* Py_UCS2 (C type):                      Unicode 型.         (line    9)
* Py_UCS4 (C type):                      Unicode 型.         (line    9)
* Py_uhash_t (C type):                   PyHash API.         (line   15)
* Py_UNBLOCK_THREADS (C macro):          高レベルAPI.        (line  178)
* Py_UnbufferedStdioFlag (C var):        グローバルな設定変数.
                                                             (line  236)
* Py_UNICODE (C type):                   Unicode 型.         (line   19)
* Py_UNICODE_IS_HIGH_SURROGATE (C function): Unicode 文字プロパティ.
                                                             (line  101)
* Py_UNICODE_IS_LOW_SURROGATE (C function): Unicode 文字プロパティ.
                                                             (line  106)
* Py_UNICODE_IS_SURROGATE (C function):  Unicode 文字プロパティ.
                                                             (line   96)
* Py_UNICODE_ISALNUM (C function):       Unicode 文字プロパティ.
                                                             (line   49)
* Py_UNICODE_ISALPHA (C function):       Unicode 文字プロパティ.
                                                             (line   44)
* Py_UNICODE_ISDECIMAL (C function):     Unicode 文字プロパティ.
                                                             (line   31)
* Py_UNICODE_ISDIGIT (C function):       Unicode 文字プロパティ.
                                                             (line   35)
* Py_UNICODE_ISLINEBREAK (C function):   Unicode 文字プロパティ.
                                                             (line   27)
* Py_UNICODE_ISLOWER (C function):       Unicode 文字プロパティ.
                                                             (line   14)
* Py_UNICODE_ISNUMERIC (C function):     Unicode 文字プロパティ.
                                                             (line   39)
* Py_UNICODE_ISPRINTABLE (C function):   Unicode 文字プロパティ.
                                                             (line   53)
* Py_UNICODE_ISSPACE (C function):       Unicode 文字プロパティ.
                                                             (line   10)
* Py_UNICODE_ISTITLE (C function):       Unicode 文字プロパティ.
                                                             (line   22)
* Py_UNICODE_ISUPPER (C function):       Unicode 文字プロパティ.
                                                             (line   18)
* Py_UNICODE_JOIN_SURROGATES (C function): Unicode 文字プロパティ.
                                                             (line  111)
* Py_UNICODE_TODECIMAL (C function):     Unicode 文字プロパティ.
                                                             (line   77)
* Py_UNICODE_TODIGIT (C function):       Unicode 文字プロパティ.
                                                             (line   83)
* Py_UNICODE_TOLOWER (C function):       Unicode 文字プロパティ.
                                                             (line   65)
* Py_UNICODE_TONUMERIC (C function):     Unicode 文字プロパティ.
                                                             (line   89)
* Py_UNICODE_TOTITLE (C function):       Unicode 文字プロパティ.
                                                             (line   73)
* Py_UNICODE_TOUPPER (C function):       Unicode 文字プロパティ.
                                                             (line   69)
* Py_UNREACHABLE (C macro):              便利なマクロ.       (line  125)
* Py_UNUSED (C macro):                   便利なマクロ.       (line  150)
* PY_UNWIND (monitoring event):          Events.             (line   62)
* Py_VaBuildValue (C function):          値の構築.           (line  207)
* PY_VECTORCALL_ARGUMENTS_OFFSET (C macro): The Vectorcall Protocol.
                                                             (line   69)
* Py_VerboseFlag (C var):                グローバルな設定変数.
                                                             (line  249)
* Py_Version (C var):                    API と ABI のバージョニング.
                                                             (line   69)
* PY_VERSION_HEX (C macro):              API と ABI のバージョニング.
                                                             (line   34)
* Py_VISIT (C function):                 循環参照ガベージコレクションをサポートする.
                                                             (line  182)
* Py_XDECREF (C function):               例外<21>.           (line  123)
* Py_XDECREF (C function) <1>:           参照カウント.       (line  143)
* Py_XINCREF (C function):               参照カウント.       (line   68)
* Py_XNewRef (C function):               参照カウント.       (line   99)
* Py_XSETREF (C macro):                  参照カウント.       (line  204)
* PY_YIELD (monitoring event):           Events.             (line   66)
* PyAIter_Check (C function):            イテレータプロトコル iterator protocol.
                                                             (line   14)
* PyAnySet_Check (C function):           Set オブジェクト.   (line   52)
* PyAnySet_CheckExact (C function):      Set オブジェクト.   (line   65)
* PyArg_Parse (C function):              API 関数.           (line   53)
* PyArg_ParseTuple (C function):         拡張モジュール関数でのパラメタ展開.
                                                             (line    6)
* PyArg_ParseTuple (C function) <1>:     API 関数.           (line    6)
* PyArg_ParseTupleAndKeywords (C function): 拡張モジュール関数のキーワードパラメタ.
                                                             (line    6)
* PyArg_ParseTupleAndKeywords (C function) <1>: API 関数.    (line   18)
* PyArg_UnpackTuple (C function):        API 関数.           (line   72)
* PyArg_ValidateKeywordArguments (C function): API 関数.     (line   45)
* PyArg_VaParse (C function):            API 関数.           (line   12)
* PyArg_VaParseTupleAndKeywords (C function): API 関数.      (line   38)
* PyASCIIObject (C type):                Unicode 型.         (line   30)
* PyAsyncMethods (C type):               async オブジェクト構造体.
                                                             (line    8)
* PyAsyncMethods.am_aiter (C member):    async オブジェクト構造体.
                                                             (line   37)
* PyAsyncMethods.am_anext (C member):    async オブジェクト構造体.
                                                             (line   50)
* PyAsyncMethods.am_await (C member):    async オブジェクト構造体.
                                                             (line   23)
* PyAsyncMethods.am_send (C member):     async オブジェクト構造体.
                                                             (line   60)
* PyBool_Check (C function):             Boolean オブジェクト.
                                                             (line   16)
* PyBool_FromLong (C function):          Boolean オブジェクト.
                                                             (line   45)
* PyBool_Type (C var):                   Boolean オブジェクト.
                                                             (line   11)
* PyBUF_ANY_CONTIGUOUS (C macro):        隣接性のリクエスト. (line   20)
* PyBUF_C_CONTIGUOUS (C macro):          隣接性のリクエスト. (line   14)
* PyBUF_CONTIG (C macro):                複合リクエスト.     (line   36)
* PyBUF_CONTIG_RO (C macro):             複合リクエスト.     (line   39)
* PyBUF_F_CONTIGUOUS (C macro):          隣接性のリクエスト. (line   17)
* PyBUF_FORMAT (C macro):                readonly format.    (line   16)
* PyBUF_FULL (C macro):                  複合リクエスト.     (line   18)
* PyBUF_FULL_RO (C macro):               複合リクエスト.     (line   21)
* PyBUF_INDIRECT (C macro):              shape strides suboffsets.
                                                             (line   14)
* PyBUF_MAX_NDIM (C macro):              buffer 構造体.      (line  159)
* PyBUF_ND (C macro):                    shape strides suboffsets.
                                                             (line   20)
* PyBUF_READ (C macro):                  memoryview オブジェクト.
                                                             (line   19)
* PyBUF_RECORDS (C macro):               複合リクエスト.     (line   24)
* PyBUF_RECORDS_RO (C macro):            複合リクエスト.     (line   27)
* PyBUF_SIMPLE (C macro):                shape strides suboffsets.
                                                             (line   23)
* PyBUF_STRIDED (C macro):               複合リクエスト.     (line   30)
* PyBUF_STRIDED_RO (C macro):            複合リクエスト.     (line   33)
* PyBUF_STRIDES (C macro):               shape strides suboffsets.
                                                             (line   17)
* PyBUF_WRITABLE (C macro):              readonly format.    (line    6)
* PyBUF_WRITE (C macro):                 memoryview オブジェクト.
                                                             (line   23)
* PyBuffer_FillContiguousStrides (C function): バッファ関連の関数.
                                                             (line   90)
* PyBuffer_FillInfo (C function):        バッファ関連の関数. (line   97)
* PyBuffer_FromContiguous (C function):  バッファ関連の関数. (line   66)
* PyBuffer_GetPointer (C function):      バッファ関連の関数. (line   59)
* PyBuffer_IsContiguous (C function):    バッファ関連の関数. (line   51)
* PyBuffer_Release (C function):         バッファ関連の関数. (line   33)
* PyBuffer_SizeFromFormat (C function):  バッファ関連の関数. (line   43)
* PyBuffer_ToContiguous (C function):    バッファ関連の関数. (line   73)
* PyBufferProcs (C type):                バッファプロトコル buffer Protocol.
                                                             (line   20)
* PyBufferProcs (C type) <1>:            バッファオブジェクト構造体 buffer object structure.
                                                             (line    6)
* PyBufferProcs.bf_getbuffer (C member): バッファオブジェクト構造体 buffer object structure.
                                                             (line   13)
* PyBufferProcs.bf_releasebuffer (C member): バッファオブジェクト構造体 buffer object structure.
                                                             (line   64)
* PyByteArray_AS_STRING (C function):    マクロ.             (line    9)
* PyByteArray_AsString (C function):     ダイレクト API 関数.
                                                             (line   33)
* PyByteArray_Check (C function):        型チェックマクロ.   (line    6)
* PyByteArray_CheckExact (C function):   型チェックマクロ.   (line   12)
* PyByteArray_Concat (C function):       ダイレクト API 関数.
                                                             (line   20)
* PyByteArray_FromObject (C function):   ダイレクト API 関数.
                                                             (line    6)
* PyByteArray_FromStringAndSize (C function): ダイレクト API 関数.
                                                             (line   13)
* PyByteArray_GET_SIZE (C function):     マクロ.             (line   14)
* PyByteArray_Resize (C function):       ダイレクト API 関数.
                                                             (line   38)
* PyByteArray_Size (C function):         ダイレクト API 関数.
                                                             (line   28)
* PyByteArray_Type (C var):              bytearray オブジェクト<2>.
                                                             (line   11)
* PyByteArrayObject (C type):            bytearray オブジェクト<2>.
                                                             (line    6)
* PyBytes_AS_STRING (C function):        バイトオブジェクト<2>.
                                                             (line  131)
* PyBytes_AsString (C function):         バイトオブジェクト<2>.
                                                             (line  120)
* PyBytes_AsStringAndSize (C function):  バイトオブジェクト<2>.
                                                             (line  136)
* PyBytes_Check (C function):            バイトオブジェクト<2>.
                                                             (line   20)
* PyBytes_CheckExact (C function):       バイトオブジェクト<2>.
                                                             (line   25)
* PyBytes_Concat (C function):           バイトオブジェクト<2>.
                                                             (line  157)
* PyBytes_ConcatAndDel (C function):     バイトオブジェクト<2>.
                                                             (line  165)
* PyBytes_FromFormat (C function):       バイトオブジェクト<2>.
                                                             (line   43)
* PyBytes_FromFormatV (C function):      バイトオブジェクト<2>.
                                                             (line  101)
* PyBytes_FromObject (C function):       バイトオブジェクト<2>.
                                                             (line  107)
* PyBytes_FromString (C function):       バイトオブジェクト<2>.
                                                             (line   30)
* PyBytes_FromStringAndSize (C function): バイトオブジェクト<2>.
                                                             (line   36)
* PyBytes_GET_SIZE (C function):         バイトオブジェクト<2>.
                                                             (line  115)
* PyBytes_Size (C function):             バイトオブジェクト<2>.
                                                             (line  111)
* PyBytes_Type (C var):                  バイトオブジェクト<2>.
                                                             (line   15)
* PyBytesObject (C type):                バイトオブジェクト<2>.
                                                             (line   10)
* pycache_prefix (sys モジュール):       sys --- システム固有のパラメーターと関数.
                                                             (line  361)
* PyCallable_Check (C function):         Call Support API.   (line    6)
* PyCallIter_Check (C function):         イテレータオブジェクト iterator object.
                                                             (line   34)
* PyCallIter_New (C function):           イテレータオブジェクト iterator object.
                                                             (line   39)
* PyCallIter_Type (C var):               イテレータオブジェクト iterator object.
                                                             (line   29)
* PyCapsule (C type):                    カプセル<2>.        (line   11)
* PyCapsule_CheckExact (C function):     カプセル<2>.        (line   30)
* PyCapsule_Destructor (C type):         カプセル<2>.        (line   21)
* PyCapsule_GetContext (C function):     カプセル<2>.        (line   77)
* PyCapsule_GetDestructor (C function):  カプセル<2>.        (line   66)
* PyCapsule_GetName (C function):        カプセル<2>.        (line   87)
* PyCapsule_GetPointer (C function):     カプセル<2>.        (line   55)
* PyCapsule_Import (C function):         カプセル<2>.        (line   97)
* PyCapsule_IsValid (C function):        カプセル<2>.        (line  109)
* PyCapsule_New (C function):            カプセル<2>.        (line   35)
* PyCapsule_SetContext (C function):     カプセル<2>.        (line  124)
* PyCapsule_SetDestructor (C function):  カプセル<2>.        (line  131)
* PyCapsule_SetName (C function):        カプセル<2>.        (line  138)
* PyCapsule_SetPointer (C function):     カプセル<2>.        (line  147)
* PyCell_Check (C function):             セルオブジェクト cell object.
                                                             (line   24)
* PyCell_Get (C function):               セルオブジェクト cell object.
                                                             (line   33)
* PyCell_GET (C function):               セルオブジェクト cell object.
                                                             (line   38)
* PyCell_New (C function):               セルオブジェクト cell object.
                                                             (line   29)
* PyCell_Set (C function):               セルオブジェクト cell object.
                                                             (line   42)
* PyCell_SET (C function):               セルオブジェクト cell object.
                                                             (line   51)
* PyCell_Type (C var):                   セルオブジェクト cell object.
                                                             (line   20)
* PyCellObject (C type):                 セルオブジェクト cell object.
                                                             (line   16)
* PyCF_ALLOW_TOP_LEVEL_AWAIT (ast モジュール): コンパイラフラグ.
                                                             (line    9)
* PyCF_ONLY_AST (ast モジュール):        コンパイラフラグ.   (line   16)
* PyCF_OPTIMIZED_AST (ast モジュール):   コンパイラフラグ.   (line   21)
* PyCF_TYPE_COMMENTS (ast モジュール):   コンパイラフラグ.   (line   28)
* PyCFunction (C type):                  Implementing functions and methods.
                                                             (line    6)
* PyCFunction_New (C function):          Implementing functions and methods.
                                                             (line  256)
* PyCFunction_NewEx (C function):        Implementing functions and methods.
                                                             (line  251)
* PyCFunctionFast (C type):              Implementing functions and methods.
                                                             (line   29)
* PyCFunctionFastWithKeywords (C type):  Implementing functions and methods.
                                                             (line   38)
* PyCFunctionWithKeywords (C type):      Implementing functions and methods.
                                                             (line   20)
* PycInvalidationMode (py_compile のクラス): py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   93)
* PyCMethod (C type):                    Implementing functions and methods.
                                                             (line   49)
* PyCMethod_New (C function):            Implementing functions and methods.
                                                             (line  224)
* PyCode_Addr2Line (C function):         コードオブジェクト<3>.
                                                             (line   97)
* PyCode_Addr2Location (C function):     コードオブジェクト<3>.
                                                             (line  106)
* PyCode_AddWatcher (C function):        コードオブジェクト<3>.
                                                             (line  163)
* PyCode_Check (C function):             コードオブジェクト<3>.
                                                             (line   20)
* PyCode_ClearWatcher (C function):      コードオブジェクト<3>.
                                                             (line  172)
* PyCode_GetCellvars (C function):       コードオブジェクト<3>.
                                                             (line  142)
* PyCode_GetCode (C function):           コードオブジェクト<3>.
                                                             (line  118)
* PyCode_GetFreevars (C function):       コードオブジェクト<3>.
                                                             (line  153)
* PyCode_GetNumFree (C function):        コードオブジェクト<3>.
                                                             (line   25)
* PyCode_GetVarnames (C function):       コードオブジェクト<3>.
                                                             (line  132)
* PyCode_New (C 関数):                   コードオブジェクト<3>.
                                                             (line   64)
* PyCode_NewEmpty (C function):          コードオブジェクト<3>.
                                                             (line   91)
* PyCode_NewWithPosOnlyArgs (C 関数):    コードオブジェクト<3>.
                                                             (line   82)
* PyCode_Type (C var):                   コードオブジェクト<3>.
                                                             (line   15)
* PyCode_WatchCallback (C type):         コードオブジェクト<3>.
                                                             (line  188)
* PyCodec_BackslashReplaceErrors (C function): Unicode エラーハンドラ用レジストリ API.
                                                             (line   51)
* PyCodec_Decode (C function):           codec レジストリとサポート関数.
                                                             (line   37)
* PyCodec_Decoder (C function):          コーデック検索API.  (line   15)
* PyCodec_Encode (C function):           codec レジストリとサポート関数.
                                                             (line   26)
* PyCodec_Encoder (C function):          コーデック検索API.  (line   10)
* PyCodec_IgnoreErrors (C function):     Unicode エラーハンドラ用レジストリ API.
                                                             (line   37)
* PyCodec_IncrementalDecoder (C function): コーデック検索API.
                                                             (line   26)
* PyCodec_IncrementalEncoder (C function): コーデック検索API.
                                                             (line   20)
* PyCodec_KnownEncoding (C function):    codec レジストリとサポート関数.
                                                             (line   21)
* PyCodec_LookupError (C function):      Unicode エラーハンドラ用レジストリ API.
                                                             (line   26)
* PyCodec_NameReplaceErrors (C function): Unicode エラーハンドラ用レジストリ API.
                                                             (line   57)
* PyCodec_Register (C function):         codec レジストリとサポート関数.
                                                             (line    6)
* PyCodec_RegisterError (C function):    Unicode エラーハンドラ用レジストリ API.
                                                             (line    6)
* PyCodec_ReplaceErrors (C function):    Unicode エラーハンドラ用レジストリ API.
                                                             (line   41)
* PyCodec_StreamReader (C function):     コーデック検索API.  (line   32)
* PyCodec_StreamWriter (C function):     コーデック検索API.  (line   38)
* PyCodec_StrictErrors (C function):     Unicode エラーハンドラ用レジストリ API.
                                                             (line   33)
* PyCodec_Unregister (C function):       codec レジストリとサポート関数.
                                                             (line   13)
* PyCodec_XMLCharRefReplaceErrors (C function): Unicode エラーハンドラ用レジストリ API.
                                                             (line   46)
* PyCodeEvent (C type):                  コードオブジェクト<3>.
                                                             (line  181)
* PyCodeObject (C type):                 コードオブジェクト<3>.
                                                             (line   10)
* PyCompactUnicodeObject (C type):       Unicode 型.         (line   30)
* PyCompileError:                        py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   19)
* PyCompilerFlags (C struct):            超高水準レイヤ.     (line  317)
* PyCompilerFlags.cf_feature_version (C member): 超高水準レイヤ.
                                                             (line  332)
* PyCompilerFlags.cf_flags (C member):   超高水準レイヤ.     (line  328)
* PyComplex_AsCComplex (C function):     Python オブジェクトとしての複素数型.
                                                             (line   69)
* PyComplex_Check (C function):          Python オブジェクトとしての複素数型.
                                                             (line   16)
* PyComplex_CheckExact (C function):     Python オブジェクトとしての複素数型.
                                                             (line   21)
* PyComplex_FromCComplex (C function):   Python オブジェクトとしての複素数型.
                                                             (line   27)
* PyComplex_FromDoubles (C function):    Python オブジェクトとしての複素数型.
                                                             (line   33)
* PyComplex_ImagAsDouble (C function):   Python オブジェクトとしての複素数型.
                                                             (line   54)
* PyComplex_RealAsDouble (C function):   Python オブジェクトとしての複素数型.
                                                             (line   39)
* PyComplex_Type (C var):                Python オブジェクトとしての複素数型.
                                                             (line   11)
* PyComplexObject (C type):              Python オブジェクトとしての複素数型.
                                                             (line    6)
* PyConfig (C type):                     PyConfig.           (line    6)
* PyConfig_Clear (C function):           PyConfig.           (line   96)
* PyConfig_InitIsolatedConfig (C function): PyConfig.        (line   20)
* PyConfig_InitPythonConfig (C function): PyConfig.          (line   15)
* PyConfig_Read (C function):            PyConfig.           (line   66)
* PyConfig_SetArgv (C function):         PyConfig.           (line   41)
* PyConfig_SetBytesArgv (C function):    PyConfig.           (line   49)
* PyConfig_SetBytesString (C function):  PyConfig.           (line   32)
* PyConfig_SetString (C function):       PyConfig.           (line   25)
* PyConfig_SetWideStringList (C function): PyConfig.         (line   58)
* PyConfig.argv (C member):              PyConfig.           (line  127)
* PyConfig.base_exec_prefix (C member):  PyConfig.           (line  172)
* PyConfig.base_executable (C member):   PyConfig.           (line  182)
* PyConfig.base_prefix (C member):       PyConfig.           (line  196)
* PyConfig.buffered_stdio (C member):    PyConfig.           (line  206)
* PyConfig.bytes_warning (C member):     PyConfig.           (line  219)
* PyConfig.check_hash_pycs_mode (C member): PyConfig.        (line  256)
* PyConfig.code_debug_ranges (C member): PyConfig.           (line  242)
* PyConfig.configure_c_stdio (C member): PyConfig.           (line  276)
* PyConfig.cpu_count (C member):         PyConfig.           (line  488)
* PyConfig.dev_mode (C member):          PyConfig.           (line  291)
* PyConfig.dump_refs (C member):         PyConfig.           (line  300)
* PyConfig.exec_prefix (C member):       PyConfig.           (line  314)
* PyConfig.executable (C member):        PyConfig.           (line  326)
* PyConfig.faulthandler (C member):      PyConfig.           (line  337)
* PyConfig.filesystem_encoding (C member): PyConfig.         (line  349)
* PyConfig.filesystem_errors (C member): PyConfig.           (line  382)
* PyConfig.hash_seed (C member):         PyConfig.           (line  404)
* PyConfig.home (C member):              PyConfig.           (line  419)
* PyConfig.import_time (C member):       PyConfig.           (line  430)
* PyConfig.inspect (C member):           PyConfig.           (line  439)
* PyConfig.install_signal_handlers (C member): PyConfig.     (line  454)
* PyConfig.int_max_str_digits (C member): PyConfig.          (line  468)
* PyConfig.interactive (C member):       PyConfig.           (line  460)
* PyConfig.isolated (C member):          PyConfig.           (line  502)
* PyConfig.legacy_windows_stdio (C member): PyConfig.        (line  527)
* PyConfig.malloc_stats (C member):      PyConfig.           (line  544)
* PyConfig.module_search_paths (C member): PyConfig.         (line  588)
* PyConfig.module_search_paths_set (C member): PyConfig.     (line  591)
* PyConfig.optimization_level (C member): PyConfig.          (line  605)
* PyConfig.orig_argv (C member):         PyConfig.           (line  621)
* PyConfig.parse_argv (C member):        PyConfig.           (line  639)
* PyConfig.parser_debug (C member):      PyConfig.           (line  660)
* PyConfig.pathconfig_warnings (C member): PyConfig.         (line  674)
* PyConfig.perf_profiling (C member):    PyConfig.           (line  868)
* PyConfig.platlibdir (C member):        PyConfig.           (line  557)
* PyConfig.prefix (C member):            PyConfig.           (line  686)
* PyConfig.program_name (C member):      PyConfig.           (line  697)
* PyConfig.pycache_prefix (C member):    PyConfig.           (line  718)
* PyConfig.pythonpath_env (C member):    PyConfig.           (line  577)
* PyConfig.quiet (C member):             PyConfig.           (line  731)
* PyConfig.run_command (C member):       PyConfig.           (line  740)
* PyConfig.run_filename (C member):      PyConfig.           (line  748)
* PyConfig.run_module (C member):        PyConfig.           (line  762)
* PyConfig.run_presite (C member):       PyConfig.           (line  770)
* PyConfig.safe_path (C member):         PyConfig.           (line  150)
* PyConfig.show_ref_count (C member):    PyConfig.           (line  784)
* PyConfig.site_import (C member):       PyConfig.           (line  796)
* PyConfig.skip_source_first_line (C member): PyConfig.      (line  815)
* PyConfig.stdio_encoding (C member):    PyConfig.           (line  827)
* PyConfig.stdio_errors (C member):      PyConfig.           (line  829)
* PyConfig.tracemalloc (C member):       PyConfig.           (line  857)
* PyConfig.use_environment (C member):   PyConfig.           (line  887)
* PyConfig.use_hash_seed (C member):     PyConfig.           (line  406)
* PyConfig.user_site_directory (C member): PyConfig.         (line  898)
* PyConfig.verbose (C member):           PyConfig.           (line  911)
* PyConfig.warn_default_encoding (C member): PyConfig.       (line  232)
* PyConfig.warnoptions (C member):       PyConfig.           (line  928)
* PyConfig.write_bytecode (C member):    PyConfig.           (line  948)
* PyConfig.xoptions (C member):          PyConfig.           (line  961)
* PyContext (C type):                    コンテキスト変数オブジェクト.
                                                             (line   26)
* PyContext_CheckExact (C function):     コンテキスト変数オブジェクト.
                                                             (line   55)
* PyContext_Copy (C function):           コンテキスト変数オブジェクト.
                                                             (line   76)
* PyContext_CopyCurrent (C function):    コンテキスト変数オブジェクト.
                                                             (line   80)
* PyContext_Enter (C function):          コンテキスト変数オブジェクト.
                                                             (line   84)
* PyContext_Exit (C function):           コンテキスト変数オブジェクト.
                                                             (line   89)
* PyContext_New (C function):            コンテキスト変数オブジェクト.
                                                             (line   72)
* PyContext_Type (C var):                コンテキスト変数オブジェクト.
                                                             (line   41)
* PyContextToken (C type):               コンテキスト変数オブジェクト.
                                                             (line   36)
* PyContextToken_CheckExact (C function): コンテキスト変数オブジェクト.
                                                             (line   65)
* PyContextToken_Type (C var):           コンテキスト変数オブジェクト.
                                                             (line   49)
* PyContextVar (C type):                 コンテキスト変数オブジェクト.
                                                             (line   31)
* PyContextVar_CheckExact (C function):  コンテキスト変数オブジェクト.
                                                             (line   60)
* PyContextVar_Get (C function):         コンテキスト変数オブジェクト.
                                                             (line  104)
* PyContextVar_New (C function):         コンテキスト変数オブジェクト.
                                                             (line   97)
* PyContextVar_Reset (C function):       コンテキスト変数オブジェクト.
                                                             (line  129)
* PyContextVar_Set (C function):         コンテキスト変数オブジェクト.
                                                             (line  123)
* PyContextVar_Type (C var):             コンテキスト変数オブジェクト.
                                                             (line   45)
* PyCoro_CheckExact (C function):        コルーチンオブジェクト<2>.
                                                             (line   19)
* PyCoro_New (C function):               コルーチンオブジェクト<2>.
                                                             (line   24)
* PyCoro_Type (C var):                   コルーチンオブジェクト<2>.
                                                             (line   15)
* PyCoroObject (C type):                 コルーチンオブジェクト<2>.
                                                             (line   11)
* PyDate_Check (C function):             DateTime オブジェクト<2>.
                                                             (line   74)
* PyDate_CheckExact (C function):        DateTime オブジェクト<2>.
                                                             (line   80)
* PyDate_FromDate (C function):          DateTime オブジェクト<2>.
                                                             (line  134)
* PyDate_FromTimestamp (C function):     DateTime オブジェクト<2>.
                                                             (line  308)
* PyDateTime_Check (C function):         DateTime オブジェクト<2>.
                                                             (line   85)
* PyDateTime_CheckExact (C function):    DateTime オブジェクト<2>.
                                                             (line   92)
* PyDateTime_Date (C type):              DateTime オブジェクト<2>.
                                                             (line   13)
* PyDateTime_DATE_GET_FOLD (C function): DateTime オブジェクト<2>.
                                                             (line  227)
* PyDateTime_DATE_GET_HOUR (C function): DateTime オブジェクト<2>.
                                                             (line  210)
* PyDateTime_DATE_GET_MICROSECOND (C function): DateTime オブジェクト<2>.
                                                             (line  222)
* PyDateTime_DATE_GET_MINUTE (C function): DateTime オブジェクト<2>.
                                                             (line  214)
* PyDateTime_DATE_GET_SECOND (C function): DateTime オブジェクト<2>.
                                                             (line  218)
* PyDateTime_DATE_GET_TZINFO (C function): DateTime オブジェクト<2>.
                                                             (line  234)
* PyDateTime_DateTime (C type):          DateTime オブジェクト<2>.
                                                             (line   18)
* PyDateTime_DateTimeType (C var):       DateTime オブジェクト<2>.
                                                             (line   39)
* PyDateTime_DateType (C var):           DateTime オブジェクト<2>.
                                                             (line   33)
* PyDateTime_Delta (C type):             DateTime オブジェクト<2>.
                                                             (line   28)
* PyDateTime_DELTA_GET_DAYS (C function): DateTime オブジェクト<2>.
                                                             (line  281)
* PyDateTime_DELTA_GET_MICROSECONDS (C function): DateTime オブジェクト<2>.
                                                             (line  293)
* PyDateTime_DELTA_GET_SECONDS (C function): DateTime オブジェクト<2>.
                                                             (line  287)
* PyDateTime_DeltaType (C var):          DateTime オブジェクト<2>.
                                                             (line   51)
* PyDateTime_FromDateAndTime (C function): DateTime オブジェクト<2>.
                                                             (line  139)
* PyDateTime_FromDateAndTimeAndFold (C function): DateTime オブジェクト<2>.
                                                             (line  145)
* PyDateTime_FromTimestamp (C function): DateTime オブジェクト<2>.
                                                             (line  302)
* PyDateTime_GET_DAY (C function):       DateTime オブジェクト<2>.
                                                             (line  201)
* PyDateTime_GET_MONTH (C function):     DateTime オブジェクト<2>.
                                                             (line  197)
* PyDateTime_GET_YEAR (C function):      DateTime オブジェクト<2>.
                                                             (line  193)
* PyDateTime_Time (C type):              DateTime オブジェクト<2>.
                                                             (line   23)
* PyDateTime_TIME_GET_FOLD (C function): DateTime オブジェクト<2>.
                                                             (line  262)
* PyDateTime_TIME_GET_HOUR (C function): DateTime オブジェクト<2>.
                                                             (line  246)
* PyDateTime_TIME_GET_MICROSECOND (C function): DateTime オブジェクト<2>.
                                                             (line  258)
* PyDateTime_TIME_GET_MINUTE (C function): DateTime オブジェクト<2>.
                                                             (line  250)
* PyDateTime_TIME_GET_SECOND (C function): DateTime オブジェクト<2>.
                                                             (line  254)
* PyDateTime_TIME_GET_TZINFO (C function): DateTime オブジェクト<2>.
                                                             (line  269)
* PyDateTime_TimeType (C var):           DateTime オブジェクト<2>.
                                                             (line   45)
* PyDateTime_TimeZone_UTC (C var):       DateTime オブジェクト<2>.
                                                             (line   65)
* PyDateTime_TZInfoType (C var):         DateTime オブジェクト<2>.
                                                             (line   57)
* PyDelta_Check (C function):            DateTime オブジェクト<2>.
                                                             (line  108)
* PyDelta_CheckExact (C function):       DateTime オブジェクト<2>.
                                                             (line  115)
* PyDelta_FromDSU (C function):          DateTime オブジェクト<2>.
                                                             (line  165)
* PyDescr_IsData (C function):           デスクリプタオブジェクト descriptor object.
                                                             (line   34)
* PyDescr_NewClassMethod (C function):   デスクリプタオブジェクト descriptor object.
                                                             (line   30)
* PyDescr_NewGetSet (C function):        デスクリプタオブジェクト descriptor object.
                                                             (line   14)
* PyDescr_NewMember (C function):        デスクリプタオブジェクト descriptor object.
                                                             (line   18)
* PyDescr_NewMethod (C function):        デスクリプタオブジェクト descriptor object.
                                                             (line   22)
* PyDescr_NewWrapper (C function):       デスクリプタオブジェクト descriptor object.
                                                             (line   26)
* PyDict_AddWatcher (C function):        辞書オブジェクト dictionary object.
                                                             (line  318)
* PyDict_Check (C function):             辞書オブジェクト dictionary object.
                                                             (line   16)
* PyDict_CheckExact (C function):        辞書オブジェクト dictionary object.
                                                             (line   21)
* PyDict_Clear (C function):             辞書オブジェクト dictionary object.
                                                             (line   37)
* PyDict_ClearWatcher (C function):      辞書オブジェクト dictionary object.
                                                             (line  327)
* PyDict_Contains (C function):          辞書オブジェクト dictionary object.
                                                             (line   41)
* PyDict_ContainsString (C function):    辞書オブジェクト dictionary object.
                                                             (line   47)
* PyDict_Copy (C function):              辞書オブジェクト dictionary object.
                                                             (line   55)
* PyDict_DelItem (C function):           辞書オブジェクト dictionary object.
                                                             (line   74)
* PyDict_DelItemString (C function):     辞書オブジェクト dictionary object.
                                                             (line   81)
* PyDict_GetItem (C function):           辞書オブジェクト dictionary object.
                                                             (line  103)
* PyDict_GetItemRef (C function):        辞書オブジェクト dictionary object.
                                                             (line   86)
* PyDict_GetItemString (C function):     辞書オブジェクト dictionary object.
                                                             (line  126)
* PyDict_GetItemStringRef (C function):  辞書オブジェクト dictionary object.
                                                             (line  139)
* PyDict_GetItemWithError (C function):  辞書オブジェクト dictionary object.
                                                             (line  119)
* PyDict_Items (C function):             辞書オブジェクト dictionary object.
                                                             (line  208)
* PyDict_Keys (C function):              辞書オブジェクト dictionary object.
                                                             (line  212)
* PyDict_Merge (C function):             辞書オブジェクト dictionary object.
                                                             (line  284)
* PyDict_MergeFromSeq2 (C function):     辞書オブジェクト dictionary object.
                                                             (line  302)
* PyDict_New (C function):               辞書オブジェクト dictionary object.
                                                             (line   26)
* PyDict_Next (C function):              辞書オブジェクト dictionary object.
                                                             (line  226)
* PyDict_Pop (C function):               辞書オブジェクト dictionary object.
                                                             (line  180)
* PyDict_PopString (C function):         辞書オブジェクト dictionary object.
                                                             (line  199)
* PyDict_SetDefault (C function):        辞書オブジェクト dictionary object.
                                                             (line  148)
* PyDict_SetDefaultRef (C function):     辞書オブジェクト dictionary object.
                                                             (line  159)
* PyDict_SetItem (C function):           辞書オブジェクト dictionary object.
                                                             (line   59)
* PyDict_SetItemString (C function):     辞書オブジェクト dictionary object.
                                                             (line   68)
* PyDict_Size (C function):              辞書オブジェクト dictionary object.
                                                             (line  220)
* PyDict_Type (C var):                   辞書オブジェクト dictionary object.
                                                             (line   11)
* PyDict_Unwatch (C function):           辞書オブジェクト dictionary object.
                                                             (line  344)
* PyDict_Update (C function):            辞書オブジェクト dictionary object.
                                                             (line  294)
* PyDict_Values (C function):            辞書オブジェクト dictionary object.
                                                             (line  216)
* PyDict_Watch (C function):             辞書オブジェクト dictionary object.
                                                             (line  335)
* PyDict_WatchCallback (C type):         辞書オブジェクト dictionary object.
                                                             (line  363)
* PyDict_WatchEvent (C type):            辞書オブジェクト dictionary object.
                                                             (line  354)
* PyDictObject (C type):                 辞書オブジェクト dictionary object.
                                                             (line    6)
* PyDictProxy_New (C function):          辞書オブジェクト dictionary object.
                                                             (line   30)
* PyDLL (ctypes のクラス):               共有ライブラリをロードする.
                                                             (line   65)
* PyDoc_STR (C macro):                   便利なマクロ.       (line  176)
* PyDoc_STRVAR (C macro):                便利なマクロ.       (line  158)
* PyErr_BadArgument (C function):        例外の送出.         (line   44)
* PyErr_BadInternalCall (C function):    例外の送出.         (line  215)
* PyErr_CheckSignals (C function):       シグナルハンドリング<2>.
                                                             (line    6)
* PyErr_Clear (C function):              例外<21>.           (line   24)
* PyErr_Clear (C function) <1>:          例外<21>.           (line  123)
* PyErr_Clear (C function) <2>:          出力とクリア.       (line    6)
* PyErr_DisplayException (C function):   出力とクリア.       (line   68)
* PyErr_ExceptionMatches (C function):   例外<21>.           (line  123)
* PyErr_ExceptionMatches (C function) <1>: エラーインジケータの問い合わせ.
                                                             (line   22)
* PyErr_Fetch (C function):              ファイナライズとメモリ解放.
                                                             (line   33)
* PyErr_Fetch (C function) <1>:          エラーインジケータの問い合わせ.
                                                             (line   74)
* PyErr_Format (C function):             例外の送出.         (line   23)
* PyErr_FormatUnraisable (C function):   出力とクリア.       (line   57)
* PyErr_FormatV (C function):            例外の送出.         (line   32)
* PyErr_GetExcInfo (C function):         エラーインジケータの問い合わせ.
                                                             (line  179)
* PyErr_GetHandledException (C function): エラーインジケータの問い合わせ.
                                                             (line  149)
* PyErr_GetRaisedException (C function): エラーインジケータの問い合わせ.
                                                             (line   36)
* PyErr_GivenExceptionMatches (C function): エラーインジケータの問い合わせ.
                                                             (line   28)
* PyErr_NewException (C function):       例外クラス<2>.      (line    6)
* PyErr_NewExceptionWithDoc (C function): 例外クラス<2>.     (line   24)
* PyErr_NoMemory (C function):           例外の送出.         (line   50)
* PyErr_NormalizeException (C function): エラーインジケータの問い合わせ.
                                                             (line  126)
* PyErr_Occurred (C function):           例外<21>.           (line   12)
* PyErr_Occurred (C function) <1>:       エラーインジケータの問い合わせ.
                                                             (line    6)
* PyErr_Print (C function):              出力とクリア.       (line   31)
* PyErr_PrintEx (C function):            出力とクリア.       (line   11)
* PyErr_ResourceWarning (C function):    警告<3>.            (line   69)
* PyErr_Restore (C function):            ファイナライズとメモリ解放.
                                                             (line   33)
* PyErr_Restore (C function) <1>:        エラーインジケータの問い合わせ.
                                                             (line  103)
* PyErr_SetExcFromWindowsErr (C function): 例外の送出.       (line  113)
* PyErr_SetExcFromWindowsErrWithFilename (C function): 例外の送出.
                                                             (line  158)
* PyErr_SetExcFromWindowsErrWithFilenameObject (C function): 例外の送出.
                                                             (line  134)
* PyErr_SetExcFromWindowsErrWithFilenameObjects (C function): 例外の送出.
                                                             (line  146)
* PyErr_SetExcInfo (C function):         エラーインジケータの問い合わせ.
                                                             (line  198)
* PyErr_SetFromErrno (C function):       例外の送出.         (line   56)
* PyErr_SetFromErrnoWithFilename (C function): 例外の送出.   (line   90)
* PyErr_SetFromErrnoWithFilenameObject (C function): 例外の送出.
                                                             (line   71)
* PyErr_SetFromErrnoWithFilenameObjects (C function): 例外の送出.
                                                             (line   80)
* PyErr_SetFromWindowsErr (C function):  例外の送出.         (line   98)
* PyErr_SetFromWindowsErrWithFilename (C function): 例外の送出.
                                                             (line  122)
* PyErr_SetHandledException (C function): エラーインジケータの問い合わせ.
                                                             (line  165)
* PyErr_SetImportError (C function):     例外の送出.         (line  168)
* PyErr_SetImportErrorSubclass (C function): 例外の送出.     (line  179)
* PyErr_SetInterrupt (C function):       シグナルハンドリング<2>.
                                                             (line   33)
* PyErr_SetInterruptEx (C function):     シグナルハンドリング<2>.
                                                             (line   42)
* PyErr_SetNone (C function):            例外の送出.         (line   40)
* PyErr_SetObject (C function):          例外の送出.         (line   18)
* PyErr_SetRaisedException (C function): エラーインジケータの問い合わせ.
                                                             (line   64)
* PyErr_SetString (C function):          例外<21>.           (line   24)
* PyErr_SetString (C function) <1>:      例外の送出.         (line   10)
* PyErr_SyntaxLocation (C function):     例外の送出.         (line  209)
* PyErr_SyntaxLocationEx (C function):   例外の送出.         (line  199)
* PyErr_SyntaxLocationObject (C function): 例外の送出.       (line  189)
* PyErr_WarnEx (C function):             警告<3>.            (line   17)
* PyErr_WarnExplicit (C function):       警告<3>.            (line   50)
* PyErr_WarnExplicitObject (C function): 警告<3>.            (line   38)
* PyErr_WarnFormat (C function):         警告<3>.            (line   60)
* PyErr_WriteUnraisable (C function):    出力とクリア.       (line   35)
* PyEval_AcquireThread (C function):     低レベルAPI.        (line  207)
* PyEval_AcquireThread():                高レベルAPI.        (line   31)
* PyEval_EvalCode (C function):          超高水準レイヤ.     (line  256)
* PyEval_EvalCodeEx (C function):        超高水準レイヤ.     (line  263)
* PyEval_EvalFrame (C function):         超高水準レイヤ.     (line  275)
* PyEval_EvalFrameEx (C function):       超高水準レイヤ.     (line  280)
* PyEval_GetBuiltins (C function):       リフレクション.     (line    6)
* PyEval_GetFrame (C function):          リフレクション.     (line   55)
* PyEval_GetFrameBuiltins (C function):  リフレクション.     (line   62)
* PyEval_GetFrameGlobals (C function):   リフレクション.     (line   84)
* PyEval_GetFrameLocals (C function):    リフレクション.     (line   70)
* PyEval_GetFuncDesc (C function):       リフレクション.     (line   98)
* PyEval_GetFuncName (C function):       リフレクション.     (line   93)
* PyEval_GetGlobals (C function):        リフレクション.     (line   46)
* PyEval_GetLocals (C function):         リフレクション.     (line   15)
* PyEval_InitThreads (C function):       高レベルAPI.        (line   30)
* PyEval_InitThreads():                  インタープリタの初期化と終了処理.
                                                             (line    7)
* PyEval_MergeCompilerFlags (C function): 超高水準レイヤ.    (line  294)
* PyEval_ReleaseThread (C function):     低レベルAPI.        (line  229)
* PyEval_ReleaseThread():                高レベルAPI.        (line   31)
* PyEval_RestoreThread (C function):     拡張コード内で GIL を解放する.
                                                             (line   34)
* PyEval_RestoreThread (C function) <1>: 高レベルAPI.        (line   54)
* PyEval_RestoreThread():                高レベルAPI.        (line   31)
* PyEval_SaveThread (C function):        拡張コード内で GIL を解放する.
                                                             (line   34)
* PyEval_SaveThread (C function) <1>:    高レベルAPI.        (line   48)
* PyEval_SaveThread():                   高レベルAPI.        (line   31)
* PyEval_SetProfile (C function):        プロファイルとトレース profiling and tracing.
                                                             (line  116)
* PyEval_SetProfileAllThreads (C function): プロファイルとトレース profiling and tracing.
                                                             (line  130)
* PyEval_SetTrace (C function):          プロファイルとトレース profiling and tracing.
                                                             (line  145)
* PyEval_SetTraceAllThreads (C function): プロファイルとトレース profiling and tracing.
                                                             (line  160)
* PyExc_ArithmeticError (C var):         標準例外.           (line   11)
* PyExc_AssertionError (C var):          標準例外.           (line   11)
* PyExc_AttributeError (C var):          標準例外.           (line   11)
* PyExc_BaseException (C var):           標準例外.           (line   11)
* PyExc_BlockingIOError (C var):         標準例外.           (line   11)
* PyExc_BrokenPipeError (C var):         標準例外.           (line   11)
* PyExc_BufferError (C var):             標準例外.           (line   11)
* PyExc_BytesWarning (C var):            標準警告カテゴリ.   (line   11)
* PyExc_ChildProcessError (C var):       標準例外.           (line   11)
* PyExc_ConnectionAbortedError (C var):  標準例外.           (line   11)
* PyExc_ConnectionError (C var):         標準例外.           (line   11)
* PyExc_ConnectionRefusedError (C var):  標準例外.           (line   11)
* PyExc_ConnectionResetError (C var):    標準例外.           (line   11)
* PyExc_DeprecationWarning (C var):      標準警告カテゴリ.   (line   11)
* PyExc_EnvironmentError (C var):        標準例外.           (line  193)
* PyExc_EOFError (C var):                標準例外.           (line   11)
* PyExc_Exception (C var):               標準例外.           (line   11)
* PyExc_FileExistsError (C var):         標準例外.           (line   11)
* PyExc_FileNotFoundError (C var):       標準例外.           (line   11)
* PyExc_FloatingPointError (C var):      標準例外.           (line   11)
* PyExc_FutureWarning (C var):           標準警告カテゴリ.   (line   11)
* PyExc_GeneratorExit (C var):           標準例外.           (line   11)
* PyExc_ImportError (C var):             標準例外.           (line   11)
* PyExc_ImportWarning (C var):           標準警告カテゴリ.   (line   11)
* PyExc_IndentationError (C var):        標準例外.           (line   11)
* PyExc_IndexError (C var):              標準例外.           (line   11)
* PyExc_InterruptedError (C var):        標準例外.           (line   11)
* PyExc_IOError (C var):                 標準例外.           (line  193)
* PyExc_IsADirectoryError (C var):       標準例外.           (line   11)
* PyExc_KeyboardInterrupt (C var):       標準例外.           (line   11)
* PyExc_KeyError (C var):                標準例外.           (line   11)
* PyExc_LookupError (C var):             標準例外.           (line   11)
* PyExc_MemoryError (C var):             標準例外.           (line   11)
* PyExc_ModuleNotFoundError (C var):     標準例外.           (line   11)
* PyExc_NameError (C var):               標準例外.           (line   11)
* PyExc_NotADirectoryError (C var):      標準例外.           (line   11)
* PyExc_NotImplementedError (C var):     標準例外.           (line   11)
* PyExc_OSError (C var):                 標準例外.           (line   11)
* PyExc_OverflowError (C var):           標準例外.           (line   11)
* PyExc_PendingDeprecationWarning (C var): 標準警告カテゴリ. (line   11)
* PyExc_PermissionError (C var):         標準例外.           (line   11)
* PyExc_ProcessLookupError (C var):      標準例外.           (line   11)
* PyExc_PythonFinalizationError (C var): 標準例外.           (line   11)
* PyExc_RecursionError (C var):          標準例外.           (line   11)
* PyExc_ReferenceError (C var):          標準例外.           (line   11)
* PyExc_ResourceWarning (C var):         標準警告カテゴリ.   (line   11)
* PyExc_RuntimeError (C var):            標準例外.           (line   11)
* PyExc_RuntimeWarning (C var):          標準警告カテゴリ.   (line   11)
* PyExc_StopAsyncIteration (C var):      標準例外.           (line   11)
* PyExc_StopIteration (C var):           標準例外.           (line   11)
* PyExc_SyntaxError (C var):             標準例外.           (line   11)
* PyExc_SyntaxWarning (C var):           標準警告カテゴリ.   (line   11)
* PyExc_SystemError (C var):             標準例外.           (line   11)
* PyExc_SystemExit (C var):              標準例外.           (line   11)
* PyExc_TabError (C var):                標準例外.           (line   11)
* PyExc_TimeoutError (C var):            標準例外.           (line   11)
* PyExc_TypeError (C var):               標準例外.           (line   11)
* PyExc_UnboundLocalError (C var):       標準例外.           (line   11)
* PyExc_UnicodeDecodeError (C var):      標準例外.           (line   11)
* PyExc_UnicodeEncodeError (C var):      標準例外.           (line   11)
* PyExc_UnicodeError (C var):            標準例外.           (line   11)
* PyExc_UnicodeTranslateError (C var):   標準例外.           (line   11)
* PyExc_UnicodeWarning (C var):          標準警告カテゴリ.   (line   11)
* PyExc_UserWarning (C var):             標準警告カテゴリ.   (line   11)
* PyExc_ValueError (C var):              標準例外.           (line   11)
* PyExc_Warning (C var):                 標準警告カテゴリ.   (line   11)
* PyExc_WindowsError (C var):            標準例外.           (line  193)
* PyExc_ZeroDivisionError (C var):       標準例外.           (line   11)
* PyException_GetArgs (C function):      例外オブジェクト.   (line   49)
* PyException_GetCause (C function):     例外オブジェクト.   (line   33)
* PyException_GetContext (C function):   例外オブジェクト.   (line   18)
* PyException_GetTraceback (C function): 例外オブジェクト.   (line    6)
* PyException_SetArgs (C function):      例外オブジェクト.   (line   53)
* PyException_SetCause (C function):     例外オブジェクト.   (line   40)
* PyException_SetContext (C function):   例外オブジェクト.   (line   27)
* PyException_SetTraceback (C function): 例外オブジェクト.   (line   13)
* PyFile_FromFd (C function):            ファイルオブジェクト.
                                                             (line   15)
* PyFile_GetLine (C function):           ファイルオブジェクト.
                                                             (line   41)
* PyFile_SetOpenCodeHook (C function):   ファイルオブジェクト.
                                                             (line   54)
* PyFile_WriteObject (C function):       ファイルオブジェクト.
                                                             (line   91)
* PyFile_WriteString (C function):       ファイルオブジェクト.
                                                             (line  102)
* PyFloat_AS_DOUBLE (C function):        Floating-Point Objects.
                                                             (line   50)
* PyFloat_AsDouble (C function):         Floating-Point Objects.
                                                             (line   37)
* PyFloat_Check (C function):            Floating-Point Objects.
                                                             (line   16)
* PyFloat_CheckExact (C function):       Floating-Point Objects.
                                                             (line   21)
* PyFloat_FromDouble (C function):       Floating-Point Objects.
                                                             (line   32)
* PyFloat_FromString (C function):       Floating-Point Objects.
                                                             (line   27)
* PyFloat_GetInfo (C function):          Floating-Point Objects.
                                                             (line   55)
* PyFloat_GetMax (C function):           Floating-Point Objects.
                                                             (line   60)
* PyFloat_GetMin (C function):           Floating-Point Objects.
                                                             (line   64)
* PyFloat_Pack2 (C function):            Pack functions.     (line   22)
* PyFloat_Pack4 (C function):            Pack functions.     (line   26)
* PyFloat_Pack8 (C function):            Pack functions.     (line   30)
* PyFloat_Type (C var):                  Floating-Point Objects.
                                                             (line   11)
* PyFloat_Unpack2 (C function):          Unpack functions.   (line   20)
* PyFloat_Unpack4 (C function):          Unpack functions.   (line   24)
* PyFloat_Unpack8 (C function):          Unpack functions.   (line   28)
* PyFloatObject (C type):                Floating-Point Objects.
                                                             (line    6)
* PyFrame_Check (C function):            フレーム frame オブジェクト<2>.
                                                             (line   30)
* PyFrame_GetBack (C function):          フレーム frame オブジェクト<2>.
                                                             (line   37)
* PyFrame_GetBuiltins (C function):      フレーム frame オブジェクト<2>.
                                                             (line   46)
* PyFrame_GetCode (C function):          フレーム frame オブジェクト<2>.
                                                             (line   55)
* PyFrame_GetGenerator (C function):     フレーム frame オブジェクト<2>.
                                                             (line   66)
* PyFrame_GetGlobals (C function):       フレーム frame オブジェクト<2>.
                                                             (line   77)
* PyFrame_GetLasti (C function):         フレーム frame オブジェクト<2>.
                                                             (line   86)
* PyFrame_GetLineNumber (C function):    フレーム frame オブジェクト<2>.
                                                             (line  133)
* PyFrame_GetLocals (C function):        フレーム frame オブジェクト<2>.
                                                             (line  117)
* PyFrame_GetVar (C function):           フレーム frame オブジェクト<2>.
                                                             (line   94)
* PyFrame_GetVarString (C function):     フレーム frame オブジェクト<2>.
                                                             (line  110)
* PyFrame_Type (C var):                  フレーム frame オブジェクト<2>.
                                                             (line   22)
* PyFrameObject (C type):                フレーム frame オブジェクト<2>.
                                                             (line    6)
* PyFrozenSet_Check (C function):        Set オブジェクト.   (line   47)
* PyFrozenSet_CheckExact (C function):   Set オブジェクト.   (line   71)
* PyFrozenSet_New (C function):          Set オブジェクト.   (line   84)
* PyFrozenSet_Type (C var):              Set オブジェクト.   (line   33)
* PyFunction_AddWatcher (C function):    Function オブジェクト<3>.
                                                             (line  113)
* PyFunction_Check (C function):         Function オブジェクト<3>.
                                                             (line   18)
* PyFunction_ClearWatcher (C function):  Function オブジェクト<3>.
                                                             (line  123)
* PyFunction_GetAnnotations (C function): Function オブジェクト<3>.
                                                             (line   99)
* PyFunction_GetClosure (C function):    Function オブジェクト<3>.
                                                             (line   86)
* PyFunction_GetCode (C function):       Function オブジェクト<3>.
                                                             (line   46)
* PyFunction_GetDefaults (C function):   Function オブジェクト<3>.
                                                             (line   62)
* PyFunction_GetGlobals (C function):    Function オブジェクト<3>.
                                                             (line   50)
* PyFunction_GetModule (C function):     Function オブジェクト<3>.
                                                             (line   54)
* PyFunction_New (C function):           Function オブジェクト<3>.
                                                             (line   24)
* PyFunction_NewWithQualName (C function): Function オブジェクト<3>.
                                                             (line   36)
* PyFunction_SetAnnotations (C function): Function オブジェクト<3>.
                                                             (line  104)
* PyFunction_SetClosure (C function):    Function オブジェクト<3>.
                                                             (line   90)
* PyFunction_SetDefaults (C function):   Function オブジェクト<3>.
                                                             (line   67)
* PyFunction_SetVectorcall (C function): Function オブジェクト<3>.
                                                             (line   76)
* PyFunction_Type (C var):               Function オブジェクト<3>.
                                                             (line   12)
* PyFunction_WatchCallback (C type):     Function オブジェクト<3>.
                                                             (line  141)
* PyFunction_WatchEvent (C type):        Function オブジェクト<3>.
                                                             (line  132)
* PyFunctionObject (C type):             Function オブジェクト<3>.
                                                             (line    8)
* PYFUNCTYPE() (ctypes モジュール):      関数プロトタイプ.   (line   30)
* PyGC_Collect (C function):             Controlling the Garbage Collector State.
                                                             (line    9)
* PyGC_Disable (C function):             Controlling the Garbage Collector State.
                                                             (line   27)
* PyGC_Enable (C function):              Controlling the Garbage Collector State.
                                                             (line   20)
* PyGC_IsEnabled (C function):           Controlling the Garbage Collector State.
                                                             (line   34)
* PyGen_Check (C function):              ジェネレータオブジェクト.
                                                             (line   19)
* PyGen_CheckExact (C function):         ジェネレータオブジェクト.
                                                             (line   24)
* PyGen_New (C function):                ジェネレータオブジェクト.
                                                             (line   29)
* PyGen_NewWithQualName (C function):    ジェネレータオブジェクト.
                                                             (line   34)
* PyGen_Type (C var):                    ジェネレータオブジェクト.
                                                             (line   15)
* PyGenObject (C type):                  ジェネレータオブジェクト.
                                                             (line   11)
* PyGetSetDef (C type):                  Defining Getters and Setters.
                                                             (line    6)
* PyGetSetDef.closure (C member):        Defining Getters and Setters.
                                                             (line   28)
* PyGetSetDef.doc (C member):            Defining Getters and Setters.
                                                             (line   24)
* PyGetSetDef.get (C member):            Defining Getters and Setters.
                                                             (line   15)
* PyGetSetDef.name (C member):           Defining Getters and Setters.
                                                             (line   11)
* PyGetSetDef.set (C member):            Defining Getters and Setters.
                                                             (line   19)
* PyGILState_Check (C function):         高レベルAPI.        (line  143)
* PyGILState_Ensure (C function):        高レベルAPI.        (line   94)
* PyGILState_GetThisThreadState (C function): 高レベルAPI.   (line  134)
* PyGILState_Release (C function):       高レベルAPI.        (line  123)
* PyHASH_BITS (C macro):                 PyHash API.         (line   27)
* PyHash_FuncDef (C type):               PyHash API.         (line   51)
* PyHash_FuncDef.hash_bits (C member):   PyHash API.         (line   59)
* PyHash_FuncDef.name (C member):        PyHash API.         (line   55)
* PyHash_FuncDef.seed_bits (C member):   PyHash API.         (line   63)
* PyHash_GetFuncDef (C function):        PyHash API.         (line   69)
* PyHASH_IMAG (C macro):                 PyHash API.         (line   45)
* PyHASH_INF (C macro):                  PyHash API.         (line   39)
* PyHASH_MODULUS (C macro):              PyHash API.         (line   21)
* PyHASH_MULTIPLIER (C macro):           PyHash API.         (line   33)
* PyImport_AddModule (C function):       モジュールのインポート<2>.
                                                             (line  121)
* PyImport_AddModuleObject (C function): モジュールのインポート<2>.
                                                             (line  112)
* PyImport_AddModuleRef (C function):    モジュールのインポート<2>.
                                                             (line   89)
* PyImport_AppendInittab (C function):   モジュールのインポート<2>.
                                                             (line  298)
* PyImport_ExecCodeModule (C function):  モジュールのインポート<2>.
                                                             (line  127)
* PyImport_ExecCodeModuleEx (C function): モジュールのインポート<2>.
                                                             (line  166)
* PyImport_ExecCodeModuleObject (C function): モジュールのインポート<2>.
                                                             (line  176)
* PyImport_ExecCodeModuleWithPathnames (C function): モジュールのインポート<2>.
                                                             (line  190)
* PyImport_ExtendInittab (C function):   モジュールのインポート<2>.
                                                             (line  325)
* PyImport_FrozenModules (C var):        モジュールのインポート<2>.
                                                             (line  289)
* PyImport_GetImporter (C function):     モジュールのインポート<2>.
                                                             (line  237)
* PyImport_GetMagicNumber (C function):  モジュールのインポート<2>.
                                                             (line  207)
* PyImport_GetMagicTag (C function):     モジュールのインポート<2>.
                                                             (line  215)
* PyImport_GetModule (C function):       モジュールのインポート<2>.
                                                             (line  228)
* PyImport_GetModuleDict (C function):   モジュールのインポート<2>.
                                                             (line  223)
* PyImport_Import (C function):          モジュールのインポート<2>.
                                                             (line   72)
* PyImport_ImportFrozenModule (C function): モジュールのインポート<2>.
                                                             (line  265)
* PyImport_ImportFrozenModuleObject (C function): モジュールのインポート<2>.
                                                             (line  250)
* PyImport_ImportModule (C function):    モジュールのインポート<2>.
                                                             (line    6)
* PyImport_ImportModuleEx (C function):  モジュールのインポート<2>.
                                                             (line   27)
* PyImport_ImportModuleLevel (C function): モジュールのインポート<2>.
                                                             (line   62)
* PyImport_ImportModuleLevelObject (C function): モジュールのインポート<2>.
                                                             (line   45)
* PyImport_ImportModuleNoBlock (C function): モジュールのインポート<2>.
                                                             (line   13)
* PyImport_ReloadModule (C function):    モジュールのインポート<2>.
                                                             (line   82)
* PyIndex_Check (C function):            数値型プロトコル number protocol.
                                                             (line  280)
* PyInit_modulename (C function):        C および C++ 拡張のビルド.
                                                             (line   16)
* PyInstanceMethod_Check (C function):   インスタンスメソッドオブジェクト Instance Method Objects.
                                                             (line   16)
* PyInstanceMethod_Function (C function): インスタンスメソッドオブジェクト Instance Method Objects.
                                                             (line   28)
* PyInstanceMethod_GET_FUNCTION (C function): インスタンスメソッドオブジェクト Instance Method Objects.
                                                             (line   33)
* PyInstanceMethod_New (C function):     インスタンスメソッドオブジェクト Instance Method Objects.
                                                             (line   22)
* PyInstanceMethod_Type (C var):         インスタンスメソッドオブジェクト Instance Method Objects.
                                                             (line   10)
* PyInterpreterConfig (C type):          サブインタプリタサポート.
                                                             (line   21)
* PyInterpreterConfig_DEFAULT_GIL (C macro): サブインタプリタサポート.
                                                             (line   90)
* PyInterpreterConfig_OWN_GIL (C macro): サブインタプリタサポート.
                                                             (line   99)
* PyInterpreterConfig_SHARED_GIL (C macro): サブインタプリタサポート.
                                                             (line   95)
* PyInterpreterConfig.allow_daemon_threads (C member): サブインタプリタサポート.
                                                             (line   66)
* PyInterpreterConfig.allow_exec (C member): サブインタプリタサポート.
                                                             (line   51)
* PyInterpreterConfig.allow_fork (C member): サブインタプリタサポート.
                                                             (line   42)
* PyInterpreterConfig.allow_threads (C member): サブインタプリタサポート.
                                                             (line   61)
* PyInterpreterConfig.check_multi_interp_extensions (C member): サブインタプリタサポート.
                                                             (line   73)
* PyInterpreterConfig.gil (C member):    サブインタプリタサポート.
                                                             (line   85)
* PyInterpreterConfig.use_main_obmalloc (C member): サブインタプリタサポート.
                                                             (line   32)
* PyInterpreterState (C type):           高レベルAPI.        (line    9)
* PyInterpreterState_Clear (C function): 低レベルAPI.        (line   21)
* PyInterpreterState_Delete (C function): 低レベルAPI.       (line   29)
* PyInterpreterState_Get (C function):   低レベルAPI.        (line  115)
* PyInterpreterState_GetDict (C function): 低レベルAPI.      (line  137)
* PyInterpreterState_GetID (C function): 低レベルAPI.        (line  127)
* PyInterpreterState_Head (C function):  高度なデバッガサポート advanced debugger support.
                                                             (line    8)
* PyInterpreterState_Main (C function):  高度なデバッガサポート advanced debugger support.
                                                             (line   13)
* PyInterpreterState_New (C function):   低レベルAPI.        (line   12)
* PyInterpreterState_Next (C function):  高度なデバッガサポート advanced debugger support.
                                                             (line   17)
* PyInterpreterState_ThreadHead (C function): 高度なデバッガサポート advanced debugger support.
                                                             (line   23)
* PyIter_Check (C function):             イテレータプロトコル iterator protocol.
                                                             (line    8)
* PyIter_Next (C function):              イテレータプロトコル iterator protocol.
                                                             (line   21)
* PyIter_Send (C function):              イテレータプロトコル iterator protocol.
                                                             (line   62)
* PYLAUNCHER_ALLOW_INSTALL:              Windows<7>.         (line   24)
* PYLAUNCHER_ALLOW_INSTALL <1>:          Windows<21>.        (line   15)
* PYLAUNCHER_ALLOW_INSTALL <2>:          Install on demand.  (line    6)
* PYLAUNCHER_ALWAYS_INSTALL:             Install on demand.  (line   12)
* PYLAUNCHER_DEBUG:                      診断.               (line    6)
* PYLAUNCHER_DRYRUN:                     Dry Run.            (line    6)
* PYLAUNCHER_DRYRUN <1>:                 Install on demand.  (line   14)
* PYLAUNCHER_NO_SEARCH_PATH:             シェバン shebang 行.
                                                             (line   66)
* PyList_Append (C function):            リストオブジェクト. (line  107)
* PyList_AsTuple (C function):           リストオブジェクト. (line  162)
* PyList_Check (C function):             リストオブジェクト. (line   16)
* PyList_CheckExact (C function):        リストオブジェクト. (line   21)
* PyList_Clear (C function):             リストオブジェクト. (line  141)
* PyList_Extend (C function):            リストオブジェクト. (line  130)
* PyList_GET_ITEM (C function):          リストオブジェクト. (line   68)
* PyList_GET_SIZE (C function):          リストオブジェクト. (line   46)
* PyList_GetItem (C function):           参照カウントの詳細. (line  115)
* PyList_GetItem (C function) <1>:       リストオブジェクト. (line   62)
* PyList_GetItemRef (C function):        リストオブジェクト. (line   51)
* PyList_GetSlice (C function):          リストオブジェクト. (line  113)
* PyList_Insert (C function):            リストオブジェクト. (line  100)
* PyList_New (C function):               リストオブジェクト. (line   26)
* PyList_Reverse (C function):           リストオブジェクト. (line  157)
* PyList_SET_ITEM (C function):          リストオブジェクト. (line   84)
* PyList_SetItem (C function):           参照カウントの詳細. (line   26)
* PyList_SetItem (C function) <1>:       リストオブジェクト. (line   73)
* PyList_SetSlice (C function):          リストオブジェクト. (line  121)
* PyList_Size (C function):              リストオブジェクト. (line   40)
* PyList_Sort (C function):              リストオブジェクト. (line  152)
* PyList_Type (C var):                   リストオブジェクト. (line   11)
* PyListObject (C type):                 リストオブジェクト. (line    6)
* PyLong_AS_LONG (C function):           整数型オブジェクト integer object.
                                                             (line  158)
* PyLong_AsDouble (C function):          整数型オブジェクト integer object.
                                                             (line  327)
* PyLong_AsInt (C function):             整数型オブジェクト integer object.
                                                             (line  166)
* PyLong_AsLong (C function):            整数型オブジェクト integer object.
                                                             (line  138)
* PyLong_AsLongAndOverflow (C function): 整数型オブジェクト integer object.
                                                             (line  173)
* PyLong_AsLongLong (C function):        整数型オブジェクト integer object.
                                                             (line  194)
* PyLong_AsLongLongAndOverflow (C function): 整数型オブジェクト integer object.
                                                             (line  214)
* PyLong_AsNativeBytes (C function):     整数型オブジェクト integer object.
                                                             (line  348)
* PyLong_AsSize_t (C function):          整数型オブジェクト integer object.
                                                             (line  261)
* PyLong_AsSsize_t (C function):         整数型オブジェクト integer object.
                                                             (line  237)
* PyLong_AsUnsignedLong (C function):    整数型オブジェクト integer object.
                                                             (line  249)
* PyLong_AsUnsignedLongLong (C function): 整数型オブジェクト integer object.
                                                             (line  273)
* PyLong_AsUnsignedLongLongMask (C function): 整数型オブジェクト integer object.
                                                             (line  308)
* PyLong_AsUnsignedLongMask (C function): 整数型オブジェクト integer object.
                                                             (line  290)
* PyLong_AsVoidPtr (C function):         整数型オブジェクト integer object.
                                                             (line  338)
* PyLong_Check (C function):             整数型オブジェクト integer object.
                                                             (line   21)
* PyLong_CheckExact (C function):        整数型オブジェクト integer object.
                                                             (line   26)
* PyLong_FromDouble (C function):        整数型オブジェクト integer object.
                                                             (line   67)
* PyLong_FromLong (C function):          整数型オブジェクト integer object.
                                                             (line   31)
* PyLong_FromLongLong (C function):      整数型オブジェクト integer object.
                                                             (line   56)
* PyLong_FromNativeBytes (C function):   整数型オブジェクト integer object.
                                                             (line  109)
* PyLong_FromSize_t (C function):        整数型オブジェクト integer object.
                                                             (line   51)
* PyLong_FromSsize_t (C function):       整数型オブジェクト integer object.
                                                             (line   46)
* PyLong_FromString (C function):        整数型オブジェクト integer object.
                                                             (line   72)
* PyLong_FromUnicodeObject (C function): 整数型オブジェクト integer object.
                                                             (line   97)
* PyLong_FromUnsignedLong (C function):  整数型オブジェクト integer object.
                                                             (line   40)
* PyLong_FromUnsignedLongLong (C function): 整数型オブジェクト integer object.
                                                             (line   61)
* PyLong_FromUnsignedNativeBytes (C function): 整数型オブジェクト integer object.
                                                             (line  125)
* PyLong_FromVoidPtr (C function):       整数型オブジェクト integer object.
                                                             (line  104)
* PyLong_GetInfo (C function):           整数型オブジェクト integer object.
                                                             (line  501)
* PyLong_Type (C var):                   整数型オブジェクト integer object.
                                                             (line   16)
* PyLongObject (C type):                 整数型オブジェクト integer object.
                                                             (line   12)
* PyMapping_Check (C function):          マップ型プロトコル mapping protocol.
                                                             (line    9)
* PyMapping_DelItem (C function):        マップ型プロトコル mapping protocol.
                                                             (line   60)
* PyMapping_DelItemString (C function):  マップ型プロトコル mapping protocol.
                                                             (line   64)
* PyMapping_GetItemString (C function):  マップ型プロトコル mapping protocol.
                                                             (line   24)
* PyMapping_GetOptionalItem (C function): マップ型プロトコル mapping protocol.
                                                             (line   31)
* PyMapping_GetOptionalItemString (C function): マップ型プロトコル mapping protocol.
                                                             (line   45)
* PyMapping_HasKey (C function):         マップ型プロトコル mapping protocol.
                                                             (line   87)
* PyMapping_HasKeyString (C function):   マップ型プロトコル mapping protocol.
                                                             (line   99)
* PyMapping_HasKeyStringWithError (C function): マップ型プロトコル mapping protocol.
                                                             (line   78)
* PyMapping_HasKeyWithError (C function): マップ型プロトコル mapping protocol.
                                                             (line   70)
* PyMapping_Items (C function):          マップ型プロトコル mapping protocol.
                                                             (line  127)
* PyMapping_Keys (C function):           マップ型プロトコル mapping protocol.
                                                             (line  111)
* PyMapping_Length (C function):         マップ型プロトコル mapping protocol.
                                                             (line   17)
* PyMapping_SetItemString (C function):  マップ型プロトコル mapping protocol.
                                                             (line   54)
* PyMapping_Size (C function):           マップ型プロトコル mapping protocol.
                                                             (line   17)
* PyMapping_Values (C function):         マップ型プロトコル mapping protocol.
                                                             (line  119)
* PyMappingMethods (C type):             マップオブジェクト構造体.
                                                             (line    6)
* PyMappingMethods.mp_ass_subscript (C member): マップオブジェクト構造体.
                                                             (line   28)
* PyMappingMethods.mp_length (C member): マップオブジェクト構造体.
                                                             (line   11)
* PyMappingMethods.mp_subscript (C member): マップオブジェクト構造体.
                                                             (line   19)
* PyMarshal_ReadLastObjectFromFile (C function): データ整列化 data marshalling のサポート.
                                                             (line   71)
* PyMarshal_ReadLongFromFile (C function): データ整列化 data marshalling のサポート.
                                                             (line   45)
* PyMarshal_ReadObjectFromFile (C function): データ整列化 data marshalling のサポート.
                                                             (line   63)
* PyMarshal_ReadObjectFromString (C function): データ整列化 data marshalling のサポート.
                                                             (line   85)
* PyMarshal_ReadShortFromFile (C function): データ整列化 data marshalling のサポート.
                                                             (line   54)
* PyMarshal_WriteLongToFile (C function): データ整列化 data marshalling のサポート.
                                                             (line   19)
* PyMarshal_WriteObjectToFile (C function): データ整列化 data marshalling のサポート.
                                                             (line   29)
* PyMarshal_WriteObjectToString (C function): データ整列化 data marshalling のサポート.
                                                             (line   38)
* PyMem_Calloc (C function):             メモリインターフェース.
                                                             (line   28)
* PyMem_Del (C function):                メモリインターフェース.
                                                             (line   85)
* PYMEM_DOMAIN_MEM (C macro):            メモリアロケータをカスタマイズする.
                                                             (line   53)
* PYMEM_DOMAIN_OBJ (C macro):            メモリアロケータをカスタマイズする.
                                                             (line   65)
* PYMEM_DOMAIN_RAW (C macro):            メモリアロケータをカスタマイズする.
                                                             (line   41)
* PyMem_Free (C function):               メモリインターフェース.
                                                             (line   57)
* PyMem_GetAllocator (C function):       メモリアロケータをカスタマイズする.
                                                             (line   77)
* PyMem_Malloc (C function):             メモリインターフェース.
                                                             (line   19)
* PyMem_New (C macro):                   メモリインターフェース.
                                                             (line   69)
* PyMem_RawCalloc (C function):          生メモリインターフェース.
                                                             (line   25)
* PyMem_RawFree (C function):            生メモリインターフェース.
                                                             (line   54)
* PyMem_RawMalloc (C function):          生メモリインターフェース.
                                                             (line   16)
* PyMem_RawRealloc (C function):         生メモリインターフェース.
                                                             (line   38)
* PyMem_Realloc (C function):            メモリインターフェース.
                                                             (line   41)
* PyMem_Resize (C macro):                メモリインターフェース.
                                                             (line   75)
* PyMem_SetAllocator (C function):       メモリアロケータをカスタマイズする.
                                                             (line   82)
* PyMem_SetupDebugHooks (C function):    メモリアロケータをカスタマイズする.
                                                             (line  125)
* PyMemAllocatorDomain (C type):         メモリアロケータをカスタマイズする.
                                                             (line   37)
* PyMemAllocatorEx (C type):             メモリアロケータをカスタマイズする.
                                                             (line    8)
* PyMember_GetOne (C function):          Accessing attributes of extension types.
                                                             (line   71)
* PyMember_SetOne (C function):          Accessing attributes of extension types.
                                                             (line   80)
* PyMemberDef (C type):                  Accessing attributes of extension types.
                                                             (line    6)
* PyMemberDef.doc (C member):            Accessing attributes of extension types.
                                                             (line   36)
* PyMemberDef.flags (C member):          Accessing attributes of extension types.
                                                             (line   31)
* PyMemberDef.name (C member):           Accessing attributes of extension types.
                                                             (line   14)
* PyMemberDef.offset (C member):         Accessing attributes of extension types.
                                                             (line   26)
* PyMemberDef.type (C member):           Accessing attributes of extension types.
                                                             (line   21)
* PyMemoryView_Check (C function):       memoryview オブジェクト.
                                                             (line   56)
* PyMemoryView_FromBuffer (C function):  memoryview オブジェクト.
                                                             (line   36)
* PyMemoryView_FromMemory (C function):  memoryview オブジェクト.
                                                             (line   27)
* PyMemoryView_FromObject (C function):  memoryview オブジェクト.
                                                             (line   10)
* PyMemoryView_GET_BASE (C function):    memoryview オブジェクト.
                                                             (line   70)
* PyMemoryView_GET_BUFFER (C function):  memoryview オブジェクト.
                                                             (line   62)
* PyMemoryView_GetContiguous (C function): memoryview オブジェクト.
                                                             (line   43)
* PyMethod_Check (C function):           メソッドオブジェクト<2>.
                                                             (line   16)
* PyMethod_Function (C function):        メソッドオブジェクト<2>.
                                                             (line   29)
* PyMethod_GET_FUNCTION (C function):    メソッドオブジェクト<2>.
                                                             (line   33)
* PyMethod_GET_SELF (C function):        メソッドオブジェクト<2>.
                                                             (line   42)
* PyMethod_New (C function):             メソッドオブジェクト<2>.
                                                             (line   22)
* PyMethod_Self (C function):            メソッドオブジェクト<2>.
                                                             (line   38)
* PyMethod_Type (C var):                 メソッドオブジェクト<2>.
                                                             (line   10)
* PyMethodDef (C type):                  Implementing functions and methods.
                                                             (line   63)
* PyMethodDef.ml_doc (C member):         Implementing functions and methods.
                                                             (line   80)
* PyMethodDef.ml_flags (C member):       Implementing functions and methods.
                                                             (line   76)
* PyMethodDef.ml_meth (C member):        Implementing functions and methods.
                                                             (line   72)
* PyMethodDef.ml_name (C member):        Implementing functions and methods.
                                                             (line   68)
* PyMODINIT_FUNC (C macro):              便利なマクロ.       (line   12)
* PyModule_Add (C function):             サポート関数.       (line   61)
* PyModule_AddFunctions (C function):    低水準モジュール作成関数.
                                                             (line   54)
* PyModule_AddIntConstant (C function):  サポート関数.       (line  111)
* PyModule_AddIntMacro (C macro):        サポート関数.       (line  134)
* PyModule_AddObject (C function):       サポート関数.       (line   77)
* PyModule_AddObjectRef (C function):    サポート関数.       (line   10)
* PyModule_AddStringConstant (C function): サポート関数.     (line  122)
* PyModule_AddStringMacro (C macro):     サポート関数.       (line  142)
* PyModule_AddType (C function):         サポート関数.       (line  146)
* PyModule_Check (C function):           モジュールオブジェクト module object.
                                                             (line   13)
* PyModule_CheckExact (C function):      モジュールオブジェクト module object.
                                                             (line   18)
* PyModule_Create (C function):          一段階初期化.       (line   10)
* PyModule_Create2 (C function):         一段階初期化.       (line   15)
* PyModule_ExecDef (C function):         低水準モジュール作成関数.
                                                             (line   37)
* PyModule_FromDefAndSpec (C function):  低水準モジュール作成関数.
                                                             (line   11)
* PyModule_FromDefAndSpec2 (C function): 低水準モジュール作成関数.
                                                             (line   20)
* PyModule_GetDef (C function):          モジュールオブジェクト module object.
                                                             (line   80)
* PyModule_GetDict (C function):         モジュールオブジェクト module object.
                                                             (line   45)
* PyModule_GetFilename (C function):     モジュールオブジェクト module object.
                                                             (line   97)
* PyModule_GetFilenameObject (C function): モジュールオブジェクト module object.
                                                             (line   86)
* PyModule_GetName (C function):         モジュールオブジェクト module object.
                                                             (line   69)
* PyModule_GetNameObject (C function):   モジュールオブジェクト module object.
                                                             (line   58)
* PyModule_GetState (C function):        モジュールオブジェクト module object.
                                                             (line   74)
* PyModule_New (C function):             モジュールオブジェクト module object.
                                                             (line   40)
* PyModule_NewObject (C function):       モジュールオブジェクト module object.
                                                             (line   23)
* PyModule_SetDocString (C function):    低水準モジュール作成関数.
                                                             (line   44)
* PyModule_Type (C var):                 モジュールオブジェクト module object.
                                                             (line    6)
* PyModuleDef (C type):                  Cモジュールの初期化.
                                                             (line   16)
* PyModuleDef_Init (C function):         多段階初期化.       (line   34)
* PyModuleDef_Slot (C type):             多段階初期化.       (line   47)
* PyModuleDef_Slot.slot (C member):      多段階初期化.       (line   49)
* PyModuleDef_Slot.value (C member):     多段階初期化.       (line   54)
* PyModuleDef.m_base (C member):         Cモジュールの初期化.
                                                             (line   22)
* PyModuleDef.m_clear (C member):        Cモジュールの初期化.
                                                             (line   90)
* PyModuleDef.m_doc (C member):          Cモジュールの初期化.
                                                             (line   31)
* PyModuleDef.m_free (C member):         Cモジュールの初期化.
                                                             (line  112)
* PyModuleDef.m_methods (C member):      Cモジュールの初期化.
                                                             (line   57)
* PyModuleDef.m_name (C member):         Cモジュールの初期化.
                                                             (line   27)
* PyModuleDef.m_size (C member):         Cモジュールの初期化.
                                                             (line   36)
* PyModuleDef.m_slots (C member):        Cモジュールの初期化.
                                                             (line   63)
* PyModuleDef.m_slots.m_reload (C member): Cモジュールの初期化.
                                                             (line   72)
* PyModuleDef.m_traverse (C member):     Cモジュールの初期化.
                                                             (line   74)
* PyMonitoring_EnterScope (C function):  Managing the Monitoring State.
                                                             (line    9)
* PyMonitoring_ExitScope (C function):   Managing the Monitoring State.
                                                             (line   95)
* PyMonitoring_FireBranchEvent (C function): Generating Execution Events.
                                                             (line   69)
* PyMonitoring_FireCallEvent (C function): Generating Execution Events.
                                                             (line   53)
* PyMonitoring_FireCRaiseEvent (C function): Generating Execution Events.
                                                             (line   92)
* PyMonitoring_FireCReturnEvent (C function): Generating Execution Events.
                                                             (line   75)
* PyMonitoring_FireExceptionHandledEvent (C function): Generating Execution Events.
                                                             (line  104)
* PyMonitoring_FireJumpEvent (C function): Generating Execution Events.
                                                             (line   64)
* PyMonitoring_FireLineEvent (C function): Generating Execution Events.
                                                             (line   59)
* PyMonitoring_FirePyResumeEvent (C function): Generating Execution Events.
                                                             (line   38)
* PyMonitoring_FirePyReturnEvent (C function): Generating Execution Events.
                                                             (line   43)
* PyMonitoring_FirePyStartEvent (C function): Generating Execution Events.
                                                             (line   33)
* PyMonitoring_FirePyThrowEvent (C function): Generating Execution Events.
                                                             (line   80)
* PyMonitoring_FirePyUnwindEvent (C function): Generating Execution Events.
                                                             (line  110)
* PyMonitoring_FirePyYieldEvent (C function): Generating Execution Events.
                                                             (line   48)
* PyMonitoring_FireRaiseEvent (C function): Generating Execution Events.
                                                             (line   86)
* PyMonitoring_FireReraiseEvent (C function): Generating Execution Events.
                                                             (line   98)
* PyMonitoring_FireStopIterationEvent (C function): Generating Execution Events.
                                                             (line  116)
* PyMonitoringState (C type):            Generating Execution Events.
                                                             (line   22)
* PyMutex (C type):                      同期プリミティブ<3>.
                                                             (line    8)
* PyMutex_Lock (C function):             同期プリミティブ<3>.
                                                             (line   25)
* PyMutex_Unlock (C function):           同期プリミティブ<3>.
                                                             (line   34)
* PyNumber_Absolute (C function):        数値型プロトコル number protocol.
                                                             (line   91)
* PyNumber_Add (C function):             数値型プロトコル number protocol.
                                                             (line   14)
* PyNumber_And (C function):             数値型プロトコル number protocol.
                                                             (line  114)
* PyNumber_AsSsize_t (C function):       数値型プロトコル number protocol.
                                                             (line  267)
* PyNumber_Check (C function):           数値型プロトコル number protocol.
                                                             (line    6)
* PyNumber_Divmod (C function):          数値型プロトコル number protocol.
                                                             (line   64)
* PyNumber_Float (C function):           数値型プロトコル number protocol.
                                                             (line  244)
* PyNumber_FloorDivide (C function):     数値型プロトコル number protocol.
                                                             (line   41)
* PyNumber_Index (C function):           数値型プロトコル number protocol.
                                                             (line  250)
* PyNumber_InPlaceAdd (C function):      数値型プロトコル number protocol.
                                                             (line  133)
* PyNumber_InPlaceAnd (C function):      数値型プロトコル number protocol.
                                                             (line  216)
* PyNumber_InPlaceFloorDivide (C function): 数値型プロトコル number protocol.
                                                             (line  164)
* PyNumber_InPlaceLshift (C function):   数値型プロトコル number protocol.
                                                             (line  202)
* PyNumber_InPlaceMatrixMultiply (C function): 数値型プロトコル number protocol.
                                                             (line  154)
* PyNumber_InPlaceMultiply (C function): 数値型プロトコル number protocol.
                                                             (line  147)
* PyNumber_InPlaceOr (C function):       数値型プロトコル number protocol.
                                                             (line  231)
* PyNumber_InPlacePower (C function):    数値型プロトコル number protocol.
                                                             (line  190)
* PyNumber_InPlaceRemainder (C function): 数値型プロトコル number protocol.
                                                             (line  183)
* PyNumber_InPlaceRshift (C function):   数値型プロトコル number protocol.
                                                             (line  209)
* PyNumber_InPlaceSubtract (C function): 数値型プロトコル number protocol.
                                                             (line  140)
* PyNumber_InPlaceTrueDivide (C function): 数値型プロトコル number protocol.
                                                             (line  171)
* PyNumber_InPlaceXor (C function):      数値型プロトコル number protocol.
                                                             (line  223)
* PyNumber_Invert (C function):          数値型プロトコル number protocol.
                                                             (line   97)
* PyNumber_Long (C function):            数値型プロトコル number protocol.
                                                             (line  238)
* PyNumber_Lshift (C function):          数値型プロトコル number protocol.
                                                             (line  102)
* PyNumber_MatrixMultiply (C function):  数値型プロトコル number protocol.
                                                             (line   32)
* PyNumber_Multiply (C function):        数値型プロトコル number protocol.
                                                             (line   26)
* PyNumber_Negative (C function):        数値型プロトコル number protocol.
                                                             (line   81)
* PyNumber_Or (C function):              数値型プロトコル number protocol.
                                                             (line  127)
* PyNumber_Positive (C function):        数値型プロトコル number protocol.
                                                             (line   86)
* PyNumber_Power (C function):           数値型プロトコル number protocol.
                                                             (line   71)
* PyNumber_Remainder (C function):       数値型プロトコル number protocol.
                                                             (line   58)
* PyNumber_Rshift (C function):          数値型プロトコル number protocol.
                                                             (line  108)
* PyNumber_Subtract (C function):        数値型プロトコル number protocol.
                                                             (line   20)
* PyNumber_ToBase (C function):          数値型プロトコル number protocol.
                                                             (line  258)
* PyNumber_TrueDivide (C function):      数値型プロトコル number protocol.
                                                             (line   47)
* PyNumber_Xor (C function):             数値型プロトコル number protocol.
                                                             (line  120)
* PyNumberMethods (C type):              数値オブジェクト構造体.
                                                             (line    6)
* PyNumberMethods.nb_absolute (C member): 数値オブジェクト構造体.
                                                             (line   94)
* PyNumberMethods.nb_add (C member):     数値オブジェクト構造体.
                                                             (line   70)
* PyNumberMethods.nb_and (C member):     数値オブジェクト構造体.
                                                             (line  109)
* PyNumberMethods.nb_bool (C member):    数値オブジェクト構造体.
                                                             (line   97)
* PyNumberMethods.nb_divmod (C member):  数値オブジェクト構造体.
                                                             (line   82)
* PyNumberMethods.nb_float (C member):   数値オブジェクト構造体.
                                                             (line  123)
* PyNumberMethods.nb_floor_divide (C member): 数値オブジェクト構造体.
                                                             (line  156)
* PyNumberMethods.nb_index (C member):   数値オブジェクト構造体.
                                                             (line  168)
* PyNumberMethods.nb_inplace_add (C member): 数値オブジェクト構造体.
                                                             (line  126)
* PyNumberMethods.nb_inplace_and (C member): 数値オブジェクト構造体.
                                                             (line  147)
* PyNumberMethods.nb_inplace_floor_divide (C member): 数値オブジェクト構造体.
                                                             (line  162)
* PyNumberMethods.nb_inplace_lshift (C member): 数値オブジェクト構造体.
                                                             (line  141)
* PyNumberMethods.nb_inplace_matrix_multiply (C member): 数値オブジェクト構造体.
                                                             (line  174)
* PyNumberMethods.nb_inplace_multiply (C member): 数値オブジェクト構造体.
                                                             (line  132)
* PyNumberMethods.nb_inplace_or (C member): 数値オブジェクト構造体.
                                                             (line  153)
* PyNumberMethods.nb_inplace_power (C member): 数値オブジェクト構造体.
                                                             (line  138)
* PyNumberMethods.nb_inplace_remainder (C member): 数値オブジェクト構造体.
                                                             (line  135)
* PyNumberMethods.nb_inplace_rshift (C member): 数値オブジェクト構造体.
                                                             (line  144)
* PyNumberMethods.nb_inplace_subtract (C member): 数値オブジェクト構造体.
                                                             (line  129)
* PyNumberMethods.nb_inplace_true_divide (C member): 数値オブジェクト構造体.
                                                             (line  165)
* PyNumberMethods.nb_inplace_xor (C member): 数値オブジェクト構造体.
                                                             (line  150)
* PyNumberMethods.nb_int (C member):     数値オブジェクト構造体.
                                                             (line  118)
* PyNumberMethods.nb_invert (C member):  数値オブジェクト構造体.
                                                             (line  100)
* PyNumberMethods.nb_lshift (C member):  数値オブジェクト構造体.
                                                             (line  103)
* PyNumberMethods.nb_matrix_multiply (C member): 数値オブジェクト構造体.
                                                             (line  171)
* PyNumberMethods.nb_multiply (C member): 数値オブジェクト構造体.
                                                             (line   76)
* PyNumberMethods.nb_negative (C member): 数値オブジェクト構造体.
                                                             (line   88)
* PyNumberMethods.nb_or (C member):      数値オブジェクト構造体.
                                                             (line  115)
* PyNumberMethods.nb_positive (C member): 数値オブジェクト構造体.
                                                             (line   91)
* PyNumberMethods.nb_power (C member):   数値オブジェクト構造体.
                                                             (line   85)
* PyNumberMethods.nb_remainder (C member): 数値オブジェクト構造体.
                                                             (line   79)
* PyNumberMethods.nb_reserved (C member): 数値オブジェクト構造体.
                                                             (line  121)
* PyNumberMethods.nb_rshift (C member):  数値オブジェクト構造体.
                                                             (line  106)
* PyNumberMethods.nb_subtract (C member): 数値オブジェクト構造体.
                                                             (line   73)
* PyNumberMethods.nb_true_divide (C member): 数値オブジェクト構造体.
                                                             (line  159)
* PyNumberMethods.nb_xor (C member):     数値オブジェクト構造体.
                                                             (line  112)
* PyObject (C type):                     Base object types and macros.
                                                             (line   14)
* PyObject_ASCII (C function):           オブジェクトプロトコル object protocol.
                                                             (line  336)
* PyObject_AsFileDescriptor (C function): ファイルオブジェクト.
                                                             (line   33)
* PyObject_Bytes (C function):           オブジェクトプロトコル object protocol.
                                                             (line  357)
* PyObject_Call (C function):            Object Calling API. (line   57)
* PyObject_CallFunction (C function):    Object Calling API. (line  106)
* PyObject_CallFunctionObjArgs (C function): Object Calling API.
                                                             (line  147)
* PyObject_CallMethod (C function):      Object Calling API. (line  126)
* PyObject_CallMethodNoArgs (C function): Object Calling API.
                                                             (line  170)
* PyObject_CallMethodObjArgs (C function): Object Calling API.
                                                             (line  159)
* PyObject_CallMethodOneArg (C function): Object Calling API.
                                                             (line  182)
* PyObject_CallNoArgs (C function):      Object Calling API. (line   72)
* PyObject_CallObject (C function):      C から Python 関数を呼び出す.
                                                             (line   65)
* PyObject_CallObject (C function) <1>:  Object Calling API. (line   94)
* PyObject_Calloc (C function):          オブジェクトアロケータ.
                                                             (line   30)
* PyObject_CallOneArg (C function):      Object Calling API. (line   84)
* PyObject_CheckBuffer (C function):     バッファ関連の関数. (line    6)
* PyObject_ClearManagedDict (C function): オブジェクトプロトコル object protocol.
                                                             (line  569)
* PyObject_ClearWeakRefs (C function):   弱参照オブジェクト<2>.
                                                             (line   89)
* PyObject_CopyData (C function):        バッファ関連の関数. (line   83)
* PyObject_Del (C function):             オブジェクトをヒープ上にメモリ確保する.
                                                             (line   47)
* PyObject_DelAttr (C function):         オブジェクトプロトコル object protocol.
                                                             (line  237)
* PyObject_DelAttrString (C function):   オブジェクトプロトコル object protocol.
                                                             (line  243)
* PyObject_DelItem (C function):         オブジェクトプロトコル object protocol.
                                                             (line  485)
* PyObject_Dir (C function):             オブジェクトプロトコル object protocol.
                                                             (line  490)
* PyObject_Format (C function):          オブジェクトプロトコル object protocol.
                                                             (line  315)
* PyObject_Free (C function):            オブジェクトアロケータ.
                                                             (line   60)
* PyObject_GC_Del (C function):          循環参照ガベージコレクションをサポートする.
                                                             (line  135)
* PyObject_GC_IsFinalized (C function):  循環参照ガベージコレクションをサポートする.
                                                             (line  124)
* PyObject_GC_IsTracked (C function):    循環参照ガベージコレクションをサポートする.
                                                             (line  113)
* PyObject_GC_New (C macro):             循環参照ガベージコレクションをサポートする.
                                                             (line   56)
* PyObject_GC_NewVar (C macro):          循環参照ガベージコレクションをサポートする.
                                                             (line   61)
* PyObject_GC_Resize (C macro):          循環参照ガベージコレクションをサポートする.
                                                             (line   87)
* PyObject_GC_Track (C function):        循環参照ガベージコレクションをサポートする.
                                                             (line   97)
* PyObject_GC_UnTrack (C function):      循環参照ガベージコレクションをサポートする.
                                                             (line  140)
* PyObject_GenericGetAttr (C function):  オブジェクトプロトコル object protocol.
                                                             (line  186)
* PyObject_GenericGetDict (C function):  オブジェクトプロトコル object protocol.
                                                             (line  258)
* PyObject_GenericHash (C function):     PyHash API.         (line   89)
* PyObject_GenericSetAttr (C function):  オブジェクトプロトコル object protocol.
                                                             (line  226)
* PyObject_GenericSetDict (C function):  オブジェクトプロトコル object protocol.
                                                             (line  274)
* PyObject_GetAIter (C function):        オブジェクトプロトコル object protocol.
                                                             (line  506)
* PyObject_GetArenaAllocator (C function): pymalloc アリーナアロケータのカスタマイズ.
                                                             (line   26)
* PyObject_GetAttr (C function):         オブジェクトプロトコル object protocol.
                                                             (line  142)
* PyObject_GetAttrString (C function):   オブジェクトプロトコル object protocol.
                                                             (line  152)
* PyObject_GetBuffer (C function):       バッファ関連の関数. (line   13)
* PyObject_GetItem (C function):         オブジェクトプロトコル object protocol.
                                                             (line  472)
* PyObject_GetItemData (C function):     オブジェクトプロトコル object protocol.
                                                             (line  548)
* PyObject_GetIter (C function):         オブジェクトプロトコル object protocol.
                                                             (line  499)
* PyObject_GetOptionalAttr (C function): オブジェクトプロトコル object protocol.
                                                             (line  162)
* PyObject_GetOptionalAttrString (C function): オブジェクトプロトコル object protocol.
                                                             (line  177)
* PyObject_GetTypeData (C function):     オブジェクトプロトコル object protocol.
                                                             (line  517)
* PyObject_HasAttr (C function):         オブジェクトプロトコル object protocol.
                                                             (line  115)
* PyObject_HasAttrString (C function):   オブジェクトプロトコル object protocol.
                                                             (line  127)
* PyObject_HasAttrStringWithError (C function): オブジェクトプロトコル object protocol.
                                                             (line  106)
* PyObject_HasAttrWithError (C function): オブジェクトプロトコル object protocol.
                                                             (line   97)
* PyObject_Hash (C function):            オブジェクトプロトコル object protocol.
                                                             (line  409)
* PyObject_HashNotImplemented (C function): オブジェクトプロトコル object protocol.
                                                             (line  418)
* PyObject_HEAD (C macro):               Base object types and macros.
                                                             (line   35)
* PyObject_HEAD_INIT (C macro):          Base object types and macros.
                                                             (line  123)
* PyObject_Init (C function):            オブジェクトをヒープ上にメモリ確保する.
                                                             (line   13)
* PyObject_InitVar (C function):         オブジェクトをヒープ上にメモリ確保する.
                                                             (line   20)
* PyObject_IS_GC (C function):           循環参照ガベージコレクションをサポートする.
                                                             (line  105)
* PyObject_IsInstance (C function):      オブジェクトプロトコル object protocol.
                                                             (line  387)
* PyObject_IsSubclass (C function):      オブジェクトプロトコル object protocol.
                                                             (line  366)
* PyObject_IsTrue (C function):          オブジェクトプロトコル object protocol.
                                                             (line  426)
* PyObject_Length (C function):          オブジェクトプロトコル object protocol.
                                                             (line  453)
* PyObject_LengthHint (C function):      オブジェクトプロトコル object protocol.
                                                             (line  462)
* PyObject_Malloc (C function):          オブジェクトアロケータ.
                                                             (line   21)
* PyObject_New (C macro):                オブジェクトをヒープ上にメモリ確保する.
                                                             (line   26)
* PyObject_NewVar (C macro):             オブジェクトをヒープ上にメモリ確保する.
                                                             (line   35)
* PyObject_Not (C function):             オブジェクトプロトコル object protocol.
                                                             (line  431)
* PyObject_Print (C function):           オブジェクトプロトコル object protocol.
                                                             (line   89)
* PyObject_Realloc (C function):         オブジェクトアロケータ.
                                                             (line   43)
* PyObject_Repr (C function):            オブジェクトプロトコル object protocol.
                                                             (line  325)
* PyObject_RichCompare (C function):     オブジェクトプロトコル object protocol.
                                                             (line  292)
* PyObject_RichCompareBool (C function): オブジェクトプロトコル object protocol.
                                                             (line  304)
* PyObject_SetArenaAllocator (C function): pymalloc アリーナアロケータのカスタマイズ.
                                                             (line   31)
* PyObject_SetAttr (C function):         オブジェクトプロトコル object protocol.
                                                             (line  197)
* PyObject_SetAttrString (C function):   オブジェクトプロトコル object protocol.
                                                             (line  208)
* PyObject_SetItem (C function):         オブジェクトプロトコル object protocol.
                                                             (line  478)
* PyObject_Size (C function):            オブジェクトプロトコル object protocol.
                                                             (line  453)
* PyObject_Str (C function):             オブジェクトプロトコル object protocol.
                                                             (line  346)
* PyObject_Type (C function):            オブジェクトプロトコル object protocol.
                                                             (line  436)
* PyObject_TypeCheck (C function):       オブジェクトプロトコル object protocol.
                                                             (line  448)
* PyObject_VAR_HEAD (C macro):           Base object types and macros.
                                                             (line   44)
* PyObject_Vectorcall (C function):      Object Calling API. (line  194)
* PyObject_VectorcallDict (C function):  Object Calling API. (line  208)
* PyObject_VectorcallMethod (C function): Object Calling API.
                                                             (line  224)
* PyObject_VisitManagedDict (C function): オブジェクトプロトコル object protocol.
                                                             (line  559)
* PyObject.ob_refcnt (C member):         PyObject スロット.  (line   13)
* PyObject.ob_type (C member):           PyObject スロット.  (line   26)
* PyObjectArenaAllocator (C type):       pymalloc アリーナアロケータのカスタマイズ.
                                                             (line    8)
* PyOS_AfterFork (C function):           オペレーティングシステム関連のユーティリティ.
                                                             (line   79)
* PyOS_AfterFork_Child (C function):     オペレーティングシステム関連のユーティリティ.
                                                             (line   56)
* PyOS_AfterFork_Parent (C function):    オペレーティングシステム関連のユーティリティ.
                                                             (line   42)
* PyOS_BeforeFork (C function):          オペレーティングシステム関連のユーティリティ.
                                                             (line   29)
* PyOS_CheckStack (C function):          オペレーティングシステム関連のユーティリティ.
                                                             (line   89)
* PyOS_double_to_string (C function):    文字列の変換と書式化.
                                                             (line  112)
* PyOS_FSPath (C function):              オペレーティングシステム関連のユーティリティ.
                                                             (line    6)
* PyOS_getsig (C function):              オペレーティングシステム関連のユーティリティ.
                                                             (line  103)
* PyOS_InputHook (C var):                超高水準レイヤ.     (line  133)
* PyOS_ReadlineFunctionPointer (C var):  超高水準レイヤ.     (line  145)
* PyOS_setsig (C function):              オペレーティングシステム関連のユーティリティ.
                                                             (line  108)
* PyOS_sighandler_t (C type):            オペレーティングシステム関連のユーティリティ.
                                                             (line  100)
* PyOS_snprintf (C function):            文字列の変換と書式化.
                                                             (line    8)
* PyOS_stricmp (C function):             文字列の変換と書式化.
                                                             (line  145)
* PyOS_string_to_double (C function):    文字列の変換と書式化.
                                                             (line   82)
* PyOS_strnicmp (C function):            文字列の変換と書式化.
                                                             (line  150)
* PyOS_strtol (C function):              文字列の変換と書式化.
                                                             (line   69)
* PyOS_strtoul (C function):             文字列の変換と書式化.
                                                             (line   47)
* PyOS_vsnprintf (C function):           文字列の変換と書式化.
                                                             (line   14)
* PyPreConfig (C type):                  PyPreConfig.        (line    6)
* PyPreConfig_InitIsolatedConfig (C function): PyPreConfig.  (line   18)
* PyPreConfig_InitPythonConfig (C function): PyPreConfig.    (line   12)
* PyPreConfig.allocator (C member):      PyPreConfig.        (line   26)
* PyPreConfig.coerce_c_locale (C member): PyPreConfig.       (line   82)
* PyPreConfig.coerce_c_locale_warn (C member): PyPreConfig.  (line   93)
* PyPreConfig.configure_locale (C member): PyPreConfig.      (line   71)
* PyPreConfig.dev_mode (C member):       PyPreConfig.        (line   99)
* PyPreConfig.isolated (C member):       PyPreConfig.        (line  106)
* PyPreConfig.legacy_windows_fs_encoding (C member): PyPreConfig.
                                                             (line  112)
* PyPreConfig.parse_argv (C member):     PyPreConfig.        (line  131)
* PyPreConfig.use_environment (C member): PyPreConfig.       (line  140)
* PyPreConfig.utf8_mode (C member):      PyPreConfig.        (line  147)
* PyProperty_Type (C var):               デスクリプタオブジェクト descriptor object.
                                                             (line   10)
* PyRefTracer (C type):                  Reference tracing.  (line    8)
* PyRefTracer_CREATE (C var):            Reference tracing.  (line   21)
* PyRefTracer_DESTROY (C var):           Reference tracing.  (line   26)
* PyRefTracer_GetTracer (C function):    Reference tracing.  (line   48)
* PyRefTracer_SetTracer (C function):    Reference tracing.  (line   31)
* PyRun_AnyFile (C function):            超高水準レイヤ.     (line   24)
* PyRun_AnyFileEx (C function):          超高水準レイヤ.     (line   35)
* PyRun_AnyFileExFlags (C function):     超高水準レイヤ.     (line   41)
* PyRun_AnyFileFlags (C function):       超高水準レイヤ.     (line   29)
* PyRun_File (C function):               超高水準レイヤ.     (line  186)
* PyRun_FileEx (C function):             超高水準レイヤ.     (line  192)
* PyRun_FileExFlags (C function):        超高水準レイヤ.     (line  204)
* PyRun_FileFlags (C function):          超高水準レイヤ.     (line  198)
* PyRun_InteractiveLoop (C function):    超高水準レイヤ.     (line  119)
* PyRun_InteractiveLoopFlags (C function): 超高水準レイヤ.   (line  124)
* PyRun_InteractiveOne (C function):     超高水準レイヤ.     (line   98)
* PyRun_InteractiveOneFlags (C function): 超高水準レイヤ.    (line  103)
* PyRun_SimpleFile (C function):         超高水準レイヤ.     (line   73)
* PyRun_SimpleFileEx (C function):       超高水準レイヤ.     (line   78)
* PyRun_SimpleFileExFlags (C function):  超高水準レイヤ.     (line   84)
* PyRun_SimpleString (C function):       超高水準レイヤ.     (line   54)
* PyRun_SimpleStringFlags (C function):  超高水準レイヤ.     (line   60)
* PyRun_String (C function):             超高水準レイヤ.     (line  168)
* PyRun_StringFlags (C function):        超高水準レイヤ.     (line  173)
* PySendResult (C type):                 イテレータプロトコル iterator protocol.
                                                             (line   55)
* PySeqIter_Check (C function):          イテレータオブジェクト iterator object.
                                                             (line   18)
* PySeqIter_New (C function):            イテレータオブジェクト iterator object.
                                                             (line   23)
* PySeqIter_Type (C var):                イテレータオブジェクト iterator object.
                                                             (line   12)
* PySequence_Check (C function):         シーケンス型プロトコル sequence protocol.
                                                             (line    6)
* PySequence_Concat (C function):        シーケンス型プロトコル sequence protocol.
                                                             (line   21)
* PySequence_Contains (C function):      シーケンス型プロトコル sequence protocol.
                                                             (line   93)
* PySequence_Count (C function):         シーケンス型プロトコル sequence protocol.
                                                             (line   86)
* PySequence_DelItem (C function):       シーケンス型プロトコル sequence protocol.
                                                             (line   69)
* PySequence_DelSlice (C function):      シーケンス型プロトコル sequence protocol.
                                                             (line   80)
* PySequence_Fast (C function):          シーケンス型プロトコル sequence protocol.
                                                             (line  120)
* PySequence_Fast_GET_ITEM (C function): シーケンス型プロトコル sequence protocol.
                                                             (line  144)
* PySequence_Fast_GET_SIZE (C function): シーケンス型プロトコル sequence protocol.
                                                             (line  135)
* PySequence_Fast_ITEMS (C function):    シーケンス型プロトコル sequence protocol.
                                                             (line  151)
* PySequence_GetItem (C function):       参照カウントの詳細. (line  115)
* PySequence_GetItem (C function) <1>:   シーケンス型プロトコル sequence protocol.
                                                             (line   47)
* PySequence_GetSlice (C function):      シーケンス型プロトコル sequence protocol.
                                                             (line   53)
* PySequence_Index (C function):         シーケンス型プロトコル sequence protocol.
                                                             (line   99)
* PySequence_InPlaceConcat (C function): シーケンス型プロトコル sequence protocol.
                                                             (line   33)
* PySequence_InPlaceRepeat (C function): シーケンス型プロトコル sequence protocol.
                                                             (line   40)
* PySequence_ITEM (C function):          シーケンス型プロトコル sequence protocol.
                                                             (line  161)
* PySequence_Length (C function):        シーケンス型プロトコル sequence protocol.
                                                             (line   14)
* PySequence_List (C function):          シーケンス型プロトコル sequence protocol.
                                                             (line  105)
* PySequence_Repeat (C function):        シーケンス型プロトコル sequence protocol.
                                                             (line   27)
* PySequence_SetItem (C function):       シーケンス型プロトコル sequence protocol.
                                                             (line   59)
* PySequence_SetSlice (C function):      シーケンス型プロトコル sequence protocol.
                                                             (line   74)
* PySequence_Size (C function):          シーケンス型プロトコル sequence protocol.
                                                             (line   14)
* PySequence_Tuple (C function):         シーケンス型プロトコル sequence protocol.
                                                             (line  112)
* PySequenceMethods (C type):            シーケンスオブジェクト構造体.
                                                             (line    6)
* PySequenceMethods.sq_ass_item (C member): シーケンスオブジェクト構造体.
                                                             (line   49)
* PySequenceMethods.sq_concat (C member): シーケンスオブジェクト構造体.
                                                             (line   19)
* PySequenceMethods.sq_contains (C member): シーケンスオブジェクト構造体.
                                                             (line   59)
* PySequenceMethods.sq_inplace_concat (C member): シーケンスオブジェクト構造体.
                                                             (line   67)
* PySequenceMethods.sq_inplace_repeat (C member): シーケンスオブジェクト構造体.
                                                             (line   78)
* PySequenceMethods.sq_item (C member):  シーケンスオブジェクト構造体.
                                                             (line   33)
* PySequenceMethods.sq_length (C member): シーケンスオブジェクト構造体.
                                                             (line   11)
* PySequenceMethods.sq_repeat (C member): シーケンスオブジェクト構造体.
                                                             (line   26)
* PySet_Add (C function):                Set オブジェクト.   (line  116)
* PySet_Check (C function):              Set オブジェクト.   (line   42)
* PySet_CheckExact (C function):         Set オブジェクト.   (line   58)
* PySet_Clear (C function):              Set オブジェクト.   (line  148)
* PySet_Contains (C function):           Set オブジェクト.   (line  107)
* PySet_Discard (C function):            Set オブジェクト.   (line  130)
* PySet_GET_SIZE (C function):           Set オブジェクト.   (line  103)
* PySet_New (C function):                Set オブジェクト.   (line   76)
* PySet_Pop (C function):                Set オブジェクト.   (line  140)
* PySet_Size (C function):               Set オブジェクト.   (line   95)
* PySet_Type (C var):                    Set オブジェクト.   (line   29)
* PySetObject (C type):                  Set オブジェクト.   (line   18)
* PySignal_SetWakeupFd (C function):     シグナルハンドリング<2>.
                                                             (line   67)
* PySlice_AdjustIndices (C function):    スライスオブジェクト slice object.
                                                             (line   99)
* PySlice_Check (C function):            スライスオブジェクト slice object.
                                                             (line   11)
* PySlice_GetIndices (C function):       スライスオブジェクト slice object.
                                                             (line   28)
* PySlice_GetIndicesEx (C function):     スライスオブジェクト slice object.
                                                             (line   45)
* PySlice_New (C function):              スライスオブジェクト slice object.
                                                             (line   16)
* PySlice_Type (C var):                  スライスオブジェクト slice object.
                                                             (line    6)
* PySlice_Unpack (C function):           スライスオブジェクト slice object.
                                                             (line   86)
* PyState_AddModule (C function):        モジュール検索.     (line   23)
* PyState_FindModule (C function):       モジュール検索.     (line   13)
* PyState_RemoveModule (C function):     モジュール検索.     (line   45)
* PyStatus (C type):                     PyStatus.           (line    6)
* PyStatus_Error (C function):           PyStatus.           (line   32)
* PyStatus_Exception (C function):       PyStatus.           (line   49)
* PyStatus_Exit (C function):            PyStatus.           (line   43)
* PyStatus_IsError (C function):         PyStatus.           (line   55)
* PyStatus_IsExit (C function):          PyStatus.           (line   59)
* PyStatus_NoMemory (C function):        PyStatus.           (line   39)
* PyStatus_Ok (C function):              PyStatus.           (line   28)
* PyStatus.err_msg (C member):           PyStatus.           (line   18)
* PyStatus.exitcode (C member):          PyStatus.           (line   14)
* PyStatus.func (C member):              PyStatus.           (line   22)
* PyStructSequence_Desc (C type):        Struct Sequence オブジェクト.
                                                             (line   34)
* PyStructSequence_Desc.doc (C member):  Struct Sequence オブジェクト.
                                                             (line   43)
* PyStructSequence_Desc.fields (C member): Struct Sequence オブジェクト.
                                                             (line   47)
* PyStructSequence_Desc.n_in_sequence (C member): Struct Sequence オブジェクト.
                                                             (line   52)
* PyStructSequence_Desc.name (C member): Struct Sequence オブジェクト.
                                                             (line   38)
* PyStructSequence_Field (C type):       Struct Sequence オブジェクト.
                                                             (line   57)
* PyStructSequence_Field.doc (C member): Struct Sequence オブジェクト.
                                                             (line   71)
* PyStructSequence_Field.name (C member): Struct Sequence オブジェクト.
                                                             (line   65)
* PyStructSequence_GET_ITEM (C function): Struct Sequence オブジェクト.
                                                             (line   99)
* PyStructSequence_GetItem (C function): Struct Sequence オブジェクト.
                                                             (line   90)
* PyStructSequence_InitType (C function): Struct Sequence オブジェクト.
                                                             (line   20)
* PyStructSequence_InitType2 (C function): Struct Sequence オブジェクト.
                                                             (line   26)
* PyStructSequence_New (C function):     Struct Sequence オブジェクト.
                                                             (line   81)
* PyStructSequence_NewType (C function): Struct Sequence オブジェクト.
                                                             (line   11)
* PyStructSequence_SET_ITEM (C function): Struct Sequence オブジェクト.
                                                             (line  119)
* PyStructSequence_SetItem (C function): Struct Sequence オブジェクト.
                                                             (line  107)
* PyStructSequence_UnnamedField (C var): Struct Sequence オブジェクト.
                                                             (line   75)
* PySys_AddAuditHook (C function):       システム関数.       (line  115)
* PySys_Audit (C function):              システム関数.       (line   74)
* PySys_AuditTuple (C function):         システム関数.       (line  107)
* PySys_FormatStderr (C function):       システム関数.       (line   59)
* PySys_FormatStdout (C function):       システム関数.       (line   52)
* PySys_GetObject (C function):          システム関数.       (line   11)
* PySys_GetXOptions (C function):        システム関数.       (line   66)
* PySys_ResetWarnOptions (C function):   システム関数.       (line   22)
* PySys_SetArgv (C function):            プロセスワイドのパラメータ.
                                                             (line  265)
* PySys_SetArgvEx (C function):          プロセスワイドのパラメータ.
                                                             (line  214)
* PySys_SetObject (C function):          システム関数.       (line   16)
* PySys_WriteStderr (C function):        システム関数.       (line   47)
* PySys_WriteStdout (C function):        システム関数.       (line   30)
* Python 3000:                           用語集<2>.          (line 1213)
* Python Editor:                         IDLE<64>.           (line    8)
* Python Enhancement Proposals; PEP 0007#documentation-strings: Documentation<18>.
                                                             (line   35)
* Python Enhancement Proposals; PEP 0249#threadsafety: モジュール定数.
                                                             (line  104)
* Python Enhancement Proposals; PEP 0453#recommendations-for-downstream-distributors: デフォルトでの pip のブートストラッピング.
                                                             (line   39)
* Python Enhancement Proposals; PEP 0477#disabling-ensurepip-by-downstream-distributors: デフォルトでの pip のブートストラッピング<2>.
                                                             (line   29)
* Python Enhancement Proposals; PEP 0564#annex-clocks-resolution-in-python: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数.
                                                             (line   26)
* Python Enhancement Proposals; PEP 0626#out-of-process-debuggers-and-profilers: コードオブジェクト<3>.
                                                             (line  104)
* Python Enhancement Proposals; PEP 0632#migration-advice: Summary -- Release highlights.
                                                             (line  111)
* Python Enhancement Proposals; PEP 0683: 参照カウント.      (line   64)
* Python Enhancement Proposals; PEP 1:   新しい開発プロセス. (line   65)
* Python Enhancement Proposals; PEP 1 <1>: 新しい開発プロセス.
                                                             (line   78)
* Python Enhancement Proposals; PEP 1 <2>: 用語集<2>.        (line 1182)
* Python Enhancement Proposals; PEP 100: Unicode 文字列型<2>.
                                                             (line   18)
* Python Enhancement Proposals; PEP 11:  Support for mobile platforms.
                                                             (line    6)
* Python Enhancement Proposals; PEP 11 <1>: Support for mobile platforms.
                                                             (line   15)
* Python Enhancement Proposals; PEP 11 <2>: Build Changes.   (line    6)
* Python Enhancement Proposals; PEP 11 <3>: Build Changes.   (line   10)
* Python Enhancement Proposals; PEP 11 <4>: Build Changes.   (line   14)
* Python Enhancement Proposals; PEP 11 <5>: Build Changes.   (line   17)
* Python Enhancement Proposals; PEP 11 <6>: Build Changes<3>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 11 <7>: PEP 538 レガシーな C ロケールの抑圧.
                                                             (line   19)
* Python Enhancement Proposals; PEP 11 <8>: サポートされないオペレーティングシステム.
                                                             (line    6)
* Python Enhancement Proposals; PEP 11 <9>: ライブラリの変更.
                                                             (line   14)
* Python Enhancement Proposals; PEP 11 <10>: Build<22>.      (line   56)
* Python Enhancement Proposals; PEP 11 <11>: Build<22>.      (line  107)
* Python Enhancement Proposals; PEP 11 <12>: Build<58>.      (line   14)
* Python Enhancement Proposals; PEP 11 <13>: ビルド要件.     (line   49)
* Python Enhancement Proposals; PEP 11 <14>: Windows で Python を使う.
                                                             (line   18)
* Python Enhancement Proposals; PEP 11 <15>: ほかのプラットフォーム.
                                                             (line    8)
* Python Enhancement Proposals; PEP 11#tier-2: Summary -- Release Highlights.
                                                             (line  139)
* Python Enhancement Proposals; PEP 11#tier-3: Summary -- Release Highlights.
                                                             (line  134)
* Python Enhancement Proposals; PEP 11#tier-3 <1>: Summary -- Release Highlights.
                                                             (line  137)
* Python Enhancement Proposals; PEP 11#tier-3 <2>: Build Changes<3>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 201: 新しい開発プロセス. (line   81)
* Python Enhancement Proposals; PEP 205: PEP 205 弱参照.     (line   82)
* Python Enhancement Proposals; PEP 205 <1>: weakref --- 弱参照.
                                                             (line  343)
* Python Enhancement Proposals; PEP 207: PEP 207 拡張比較.   (line   68)
* Python Enhancement Proposals; PEP 207 <1>: PEP 207 拡張比較.
                                                             (line   74)
* Python Enhancement Proposals; PEP 208: PEP 208 新しい型強制モデル.
                                                             (line   26)
* Python Enhancement Proposals; PEP 217: PEP 217 対話モード用 Display Hook.
                                                             (line   27)
* Python Enhancement Proposals; PEP 218: PEP 218 ビルトインの集合オブジェクト.
                                                             (line   51)
* Python Enhancement Proposals; PEP 218 <1>: その他の言語変更<15>.
                                                             (line   11)
* Python Enhancement Proposals; PEP 218 <2>: PEP 218 標準の集合データ型.
                                                             (line   84)
* Python Enhancement Proposals; PEP 227: PEP 227 入れ子状のスコープ.
                                                             (line   89)
* Python Enhancement Proposals; PEP 227 <1>: PEP 227 入れ子状のスコープ<2>.
                                                             (line   90)
* Python Enhancement Proposals; PEP 227 <2>: モジュールコンテンツ<5>.
                                                             (line   14)
* Python Enhancement Proposals; PEP 229: PEP 229 新しいビルドシステム.
                                                             (line   39)
* Python Enhancement Proposals; PEP 230: PEP 230 警告フレームワーク.
                                                             (line   71)
* Python Enhancement Proposals; PEP 232: PEP 232 関数の属性. (line   36)
* Python Enhancement Proposals; PEP 234: PEP 234 イテレータ. (line  126)
* Python Enhancement Proposals; PEP 235: はじめに<10>.       (line   49)
* Python Enhancement Proposals; PEP 236: PEP 227 入れ子状のスコープ<2>.
                                                             (line   80)
* Python Enhancement Proposals; PEP 236 <1>: PEP 227 入れ子状のスコープ<2>.
                                                             (line   82)
* Python Enhancement Proposals; PEP 236 <2>: PEP 236 __future__ 指示文.
                                                             (line   28)
* Python Enhancement Proposals; PEP 236 <3>: future 文 future statement.
                                                             (line   83)
* Python Enhancement Proposals; PEP 236 <4>: モジュールコンテンツ<5>.
                                                             (line   94)
* Python Enhancement Proposals; PEP 237: 整数.               (line    6)
* Python Enhancement Proposals; PEP 237 <1>: PEP 237 長整数と整数を一体化していく.
                                                             (line   21)
* Python Enhancement Proposals; PEP 237 <2>: その他の言語変更<15>.
                                                             (line   16)
* Python Enhancement Proposals; PEP 237 <3>: PEP 237 長整数と整数を一体化していく<2>.
                                                             (line   42)
* Python Enhancement Proposals; PEP 237 <4>: printf 形式の文字列書式化.
                                                             (line  177)
* Python Enhancement Proposals; PEP 237 <5>: printf 形式での bytes の書式化.
                                                             (line  181)
* Python Enhancement Proposals; PEP 238: 整数.               (line   10)
* Python Enhancement Proposals; PEP 238 <1>: PEP 238 除算演算子を変更していく.
                                                             (line   20)
* Python Enhancement Proposals; PEP 238 <2>: PEP 238 除算演算子を変更していく.
                                                             (line   27)
* Python Enhancement Proposals; PEP 238 <3>: PEP 238 除算演算子を変更していく.
                                                             (line   67)
* Python Enhancement Proposals; PEP 238 <4>: モジュールコンテンツ<5>.
                                                             (line   20)
* Python Enhancement Proposals; PEP 238 <5>: 超高水準レイヤ. (line  344)
* Python Enhancement Proposals; PEP 238 <6>: 用語集<2>.      (line  534)
* Python Enhancement Proposals; PEP 241: PEP 241 Pythonソフトウェアパッケージのためのメタデータ.
                                                             (line   17)
* Python Enhancement Proposals; PEP 241 <1>: PEP 241 Pythonソフトウェアパッケージのためのメタデータ.
                                                             (line   30)
* Python Enhancement Proposals; PEP 241 <2>: PEP 241 Pythonソフトウェアパッケージのためのメタデータ.
                                                             (line   37)
* Python Enhancement Proposals; PEP 243: PEP 241 Pythonソフトウェアパッケージのためのメタデータ.
                                                             (line   41)
* Python Enhancement Proposals; PEP 246: Documentation<17>.  (line   48)
* Python Enhancement Proposals; PEP 246 <1>: PrepareProtocol オブジェクト.
                                                             (line   10)
* Python Enhancement Proposals; PEP 247: hmac<3>.            (line   20)
* Python Enhancement Proposals; PEP 249: sqlite3<2>.         (line   11)
* Python Enhancement Proposals; PEP 249 <1>: sqlite3 パッケージ.
                                                             (line   17)
* Python Enhancement Proposals; PEP 249 <2>: sqlite3 パッケージ.
                                                             (line  110)
* Python Enhancement Proposals; PEP 249 <3>: Library<21>.    (line  121)
* Python Enhancement Proposals; PEP 249 <4>: Library<24>.    (line  296)
* Python Enhancement Proposals; PEP 249 <5>: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース.
                                                             (line   16)
* Python Enhancement Proposals; PEP 249 <6>: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース.
                                                             (line   45)
* Python Enhancement Proposals; PEP 249 <7>: モジュール関数. (line   74)
* Python Enhancement Proposals; PEP 249 <8>: Connection オブジェクト.
                                                             (line  747)
* Python Enhancement Proposals; PEP 249 <9>: Connection オブジェクト.
                                                             (line  750)
* Python Enhancement Proposals; PEP 249 <10>: Connection オブジェクト.
                                                             (line  763)
* Python Enhancement Proposals; PEP 249 <11>: 例外<7>.       (line    6)
* Python Enhancement Proposals; PEP 249 <12>: プレースホルダを使用して SQL クエリに値を結び付ける方法.
                                                             (line   54)
* Python Enhancement Proposals; PEP 249 <13>: autocommit 属性に依るトランザクション制御.
                                                             (line   11)
* Python Enhancement Proposals; PEP 249 <14>: autocommit 属性に依るトランザクション制御.
                                                             (line   34)
* Python Enhancement Proposals; PEP 252: 関連リンク.         (line   16)
* Python Enhancement Proposals; PEP 252 <1>: 関連リンク.     (line   16)
* Python Enhancement Proposals; PEP 252 <2>: デスクリプタ descriptor の実装.
                                                             (line   26)
* Python Enhancement Proposals; PEP 253: 旧と新クラス.       (line   28)
* Python Enhancement Proposals; PEP 253 <1>: 多重継承 ダイヤモンドルール.
                                                             (line    8)
* Python Enhancement Proposals; PEP 253 <2>: 関連リンク.     (line   16)
* Python Enhancement Proposals; PEP 253 <3>: 関連リンク.     (line   18)
* Python Enhancement Proposals; PEP 253 <4>: 関連リンク.     (line   21)
* Python Enhancement Proposals; PEP 255: PEP 255 単純なジェネレータ.
                                                             (line   41)
* Python Enhancement Proposals; PEP 255 <1>: PEP 255 単純なジェネレータ.
                                                             (line  140)
* Python Enhancement Proposals; PEP 255 <2>: PEP 255 単純なジェネレータ<2>.
                                                             (line   41)
* Python Enhancement Proposals; PEP 255 <3>: PEP 255 単純なジェネレータ<2>.
                                                             (line  140)
* Python Enhancement Proposals; PEP 255 <4>: Yield 式.       (line   84)
* Python Enhancement Proposals; PEP 255 <5>: モジュールコンテンツ<5>.
                                                             (line   17)
* Python Enhancement Proposals; PEP 261: Unicode の変更.     (line   19)
* Python Enhancement Proposals; PEP 261 <1>: Unicode の変更. (line   62)
* Python Enhancement Proposals; PEP 263: その他の言語変更<14>.
                                                             (line   99)
* Python Enhancement Proposals; PEP 263 <1>: PEP 263 ソースコードのエンコーディング.
                                                             (line   29)
* Python Enhancement Proposals; PEP 263 <2>: Core and Builtins<29>.
                                                             (line   84)
* Python Enhancement Proposals; PEP 263 <3>: はじめに<10>.   (line   53)
* Python Enhancement Proposals; PEP 263 <4>: 入力のトークナイズ.
                                                             (line   33)
* Python Enhancement Proposals; PEP 263 <5>: 入力のトークナイズ.
                                                             (line   87)
* Python Enhancement Proposals; PEP 263 <6>: Python ソースコード内の Unicode リテラル.
                                                             (line   46)
* Python Enhancement Proposals; PEP 264: その他の変更と修正<3>.
                                                             (line   52)
* Python Enhancement Proposals; PEP 273: PEP 273 Zip アーカイブからモジュールをインポートする.
                                                             (line   41)
* Python Enhancement Proposals; PEP 273 <1>: PEP 273 Zip アーカイブからモジュールをインポートする.
                                                             (line   44)
* Python Enhancement Proposals; PEP 273 <2>: zipimport --- Zip アーカイブからモジュールをインポートする.
                                                             (line   44)
* Python Enhancement Proposals; PEP 273 <3>: zipimport --- Zip アーカイブからモジュールをインポートする.
                                                             (line   47)
* Python Enhancement Proposals; PEP 274: 新たな構文.         (line   43)
* Python Enhancement Proposals; PEP 277: PEP 277 Windows NT での Unicode ファイル名サポート.
                                                             (line   35)
* Python Enhancement Proposals; PEP 278: PEP 278 Universal Newline サポート.
                                                             (line   31)
* Python Enhancement Proposals; PEP 278 <1>: 用語集<2>.      (line 1463)
* Python Enhancement Proposals; PEP 279: PEP 279 enumerate.  (line   28)
* Python Enhancement Proposals; PEP 282: PEP 282 ロギングパッケージ.
                                                             (line  103)
* Python Enhancement Proposals; PEP 282 <1>: PEP 282 ロギングパッケージ.
                                                             (line  109)
* Python Enhancement Proposals; PEP 282 <2>: アーカイブ化操作.
                                                             (line   49)
* Python Enhancement Proposals; PEP 282 <3>: warnings モジュールとの統合.
                                                             (line   34)
* Python Enhancement Proposals; PEP 285: PEP 285 Boolean 型. (line   46)
* Python Enhancement Proposals; PEP 285 <1>: PEP 285 Boolean 型.
                                                             (line   69)
* Python Enhancement Proposals; PEP 288: PEP 342 ジェネレータの新機能.
                                                             (line  139)
* Python Enhancement Proposals; PEP 289: PEP 289 ジェネレータ式.
                                                             (line   55)
* Python Enhancement Proposals; PEP 289 <1>: その他の言語変更<15>.
                                                             (line   14)
* Python Enhancement Proposals; PEP 289 <2>: Python 文書.    (line   12)
* Python Enhancement Proposals; PEP 292: PEP 292 より単純な文字列置換 string substitution.
                                                             (line   45)
* Python Enhancement Proposals; PEP 292 <1>: テンプレート文字列.
                                                             (line    6)
* Python Enhancement Proposals; PEP 293: PEP 293 コーデックエラーを処理するコールバック.
                                                             (line   29)
* Python Enhancement Proposals; PEP 3000: Python 3 0.        (line   42)
* Python Enhancement Proposals; PEP 301: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ.
                                                             (line   43)
* Python Enhancement Proposals; PEP 302: インポート実装としての importlib の使用.
                                                             (line   12)
* Python Enhancement Proposals; PEP 302 <1>: 目に見える変化. (line   19)
* Python Enhancement Proposals; PEP 302 <2>: Python コードの移植.
                                                             (line   72)
* Python Enhancement Proposals; PEP 302 <3>: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>.
                                                             (line  107)
* Python Enhancement Proposals; PEP 302 <4>: 新たなモジュール、改良されたモジュール、削除されたモジュール.
                                                             (line  280)
* Python Enhancement Proposals; PEP 302 <5>: PEP 273 Zip アーカイブからモジュールをインポートする.
                                                             (line   45)
* Python Enhancement Proposals; PEP 302 <6>: PEP 302 新たなインポートフック.
                                                             (line   14)
* Python Enhancement Proposals; PEP 302 <7>: PEP 302 新たなインポートフック.
                                                             (line   43)
* Python Enhancement Proposals; PEP 302 <8>: PEP 302 新たなインポートフック.
                                                             (line   67)
* Python Enhancement Proposals; PEP 302 <9>: インポートシステム.
                                                             (line   40)
* Python Enhancement Proposals; PEP 302 <10>: 参考資料.      (line   10)
* Python Enhancement Proposals; PEP 302 <11>: 組み込み関数.  (line 2165)
* Python Enhancement Proposals; PEP 302 <12>: linecache --- テキストラインへのランダムアクセス.
                                                             (line   30)
* Python Enhancement Proposals; PEP 302 <13>: sys --- システム固有のパラメーターと関数.
                                                             (line 1334)
* Python Enhancement Proposals; PEP 302 <14>: sys --- システム固有のパラメーターと関数.
                                                             (line 1344)
* Python Enhancement Proposals; PEP 302 <15>: zipimport --- Zip アーカイブからモジュールをインポートする.
                                                             (line   48)
* Python Enhancement Proposals; PEP 302 <16>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   64)
* Python Enhancement Proposals; PEP 302 <17>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   83)
* Python Enhancement Proposals; PEP 302 <18>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   99)
* Python Enhancement Proposals; PEP 302 <19>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  123)
* Python Enhancement Proposals; PEP 302 <20>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  144)
* Python Enhancement Proposals; PEP 302 <21>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  183)
* Python Enhancement Proposals; PEP 302 <22>: runpy --- Python モジュールの位置特定と実行.
                                                             (line   32)
* Python Enhancement Proposals; PEP 302 <23>: はじめに<10>.  (line   57)
* Python Enhancement Proposals; PEP 302 <24>: importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line   93)
* Python Enhancement Proposals; PEP 302 <25>: importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  178)
* Python Enhancement Proposals; PEP 302 <26>: importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  202)
* Python Enhancement Proposals; PEP 302 <27>: importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  274)
* Python Enhancement Proposals; PEP 302 <28>: 用語集<2>.     (line  897)
* Python Enhancement Proposals; PEP 305: PEP 305 カンマ区切り形式ファイル.
                                                             (line   41)
* Python Enhancement Proposals; PEP 305 <1>: csv --- CSV ファイルの読み書き.
                                                             (line   40)
* Python Enhancement Proposals; PEP 307: PEP 307 Pickle の機能拡張.
                                                             (line    8)
* Python Enhancement Proposals; PEP 307 <1>: PEP 307 Pickle の機能拡張.
                                                             (line   30)
* Python Enhancement Proposals; PEP 307 <2>: PEP 307 Pickle の機能拡張.
                                                             (line   42)
* Python Enhancement Proposals; PEP 307 <3>: データストリームの形式.
                                                             (line   33)
* Python Enhancement Proposals; PEP 308: PEP 308 条件式 Conditional Expressions.
                                                             (line   63)
* Python Enhancement Proposals; PEP 308 <1>: PEP 308 条件式 Conditional Expressions.
                                                             (line   70)
* Python Enhancement Proposals; PEP 308 <2>: 条件式 Conditional Expressions.
                                                             (line   16)
* Python Enhancement Proposals; PEP 309: PEP 309 関数の部分適用.
                                                             (line   71)
* Python Enhancement Proposals; PEP 3100: Python 3 0.        (line   43)
* Python Enhancement Proposals; PEP 3101: PEP 3101 文字列整形の新たなアプローチ.
                                                             (line    3)
* Python Enhancement Proposals; PEP 3101 <1>: PEP 3101 文字列整形の新たなアプローチ.
                                                             (line    8)
* Python Enhancement Proposals; PEP 3101 <2>: PEP 3101 進化版文字列フォーマッティング.
                                                             (line    3)
* Python Enhancement Proposals; PEP 3101 <3>: PEP 3101 進化版文字列フォーマッティング.
                                                             (line  156)
* Python Enhancement Proposals; PEP 3101 <4>: カスタムの文字列書式化.
                                                             (line    6)
* Python Enhancement Proposals; PEP 3101 <5>: カスタムの文字列書式化.
                                                             (line   57)
* Python Enhancement Proposals; PEP 3102: 新たな構文.        (line   13)
* Python Enhancement Proposals; PEP 3104: 新たな構文.        (line   28)
* Python Enhancement Proposals; PEP 3104 <1>: nonlocal 文.   (line   24)
* Python Enhancement Proposals; PEP 3105: print関数.         (line    7)
* Python Enhancement Proposals; PEP 3105 <1>: PEP 3105 print を関数にする.
                                                             (line   33)
* Python Enhancement Proposals; PEP 3105 <2>: モジュールコンテンツ<5>.
                                                             (line   30)
* Python Enhancement Proposals; PEP 3106: PEP 3106 辞書 View.
                                                             (line   57)
* Python Enhancement Proposals; PEP 3107: PEP 563 アノテーションの遅延評価.
                                                             (line    6)
* Python Enhancement Proposals; PEP 3107 <1>: PEP 484 - 型ヒント.
                                                             (line    6)
* Python Enhancement Proposals; PEP 3107 <2>: 新たな構文.    (line    6)
* Python Enhancement Proposals; PEP 3107 <3>: 関数のアノテーション.
                                                             (line    7)
* Python Enhancement Proposals; PEP 3107 <4>: 関数定義.      (line  140)
* Python Enhancement Proposals; PEP 3108: ライブラリの変更.  (line    7)
* Python Enhancement Proposals; PEP 3108 <1>: ライブラリの変更.
                                                             (line   16)
* Python Enhancement Proposals; PEP 3108 <2>: ライブラリの変更.
                                                             (line   93)
* Python Enhancement Proposals; PEP 3109: 変更された構文.    (line    6)
* Python Enhancement Proposals; PEP 3109 <1>: 例外に関する変更.
                                                             (line   28)
* Python Enhancement Proposals; PEP 3110: 変更された構文.    (line   15)
* Python Enhancement Proposals; PEP 3110 <1>: 例外に関する変更.
                                                             (line   34)
* Python Enhancement Proposals; PEP 3110 <2>: PEP 3110 例外処理の変更.
                                                             (line   45)
* Python Enhancement Proposals; PEP 3111: 組み込み.          (line   12)
* Python Enhancement Proposals; PEP 3112: PEP 3112 バイトリテラル.
                                                             (line   74)
* Python Enhancement Proposals; PEP 3112 <1>: モジュールコンテンツ<5>.
                                                             (line   33)
* Python Enhancement Proposals; PEP 3113: 削除された操作.    (line    6)
* Python Enhancement Proposals; PEP 3114: 演算子と特殊メソッド.
                                                             (line   18)
* Python Enhancement Proposals; PEP 3115: types<7>.          (line   10)
* Python Enhancement Proposals; PEP 3115 <1>: 変更された構文.
                                                             (line   17)
* Python Enhancement Proposals; PEP 3115 <2>: クラスの名前空間の準備.
                                                             (line   20)
* Python Enhancement Proposals; PEP 3115 <3>: クラス定義.    (line   83)
* Python Enhancement Proposals; PEP 3115 <4>: 動的な型生成.  (line   48)
* Python Enhancement Proposals; PEP 3115 <5>: 関数およびクラス定義.
                                                             (line  180)
* Python Enhancement Proposals; PEP 3116: 最適化<10>.        (line    8)
* Python Enhancement Proposals; PEP 3116 <1>: PEP 3116 新しい I/O ライブラリ.
                                                             (line   69)
* Python Enhancement Proposals; PEP 3116 <2>: 用語集<2>.     (line 1463)
* Python Enhancement Proposals; PEP 3118: Pickle プロトコルバージョン 5 による帯域外データバッファ.
                                                             (line   10)
* Python Enhancement Proposals; PEP 3118 <1>: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント.
                                                             (line    6)
* Python Enhancement Proposals; PEP 3118 <2>: API の変更.    (line   31)
* Python Enhancement Proposals; PEP 3118 <3>: ビルドならびに C API の変更<4>.
                                                             (line    8)
* Python Enhancement Proposals; PEP 3118 <4>: ビルドならびに C API の変更<7>.
                                                             (line   11)
* Python Enhancement Proposals; PEP 3118 <5>: PEP 3118 改訂版バッファプロトコル.
                                                             (line   45)
* Python Enhancement Proposals; PEP 3118 <6>: Library<61>.   (line   99)
* Python Enhancement Proposals; PEP 3118 <7>: Library<66>.   (line   61)
* Python Enhancement Proposals; PEP 3118 <8>: Library<95>.   (line  958)
* Python Enhancement Proposals; PEP 3118 <9>: メモリビュー.  (line  113)
* Python Enhancement Proposals; PEP 3119: PEP 3119 抽象基底クラス.
                                                             (line  134)
* Python Enhancement Proposals; PEP 3119 <1>: インスタンスのカスタマイズとサブクラスチェック.
                                                             (line   34)
* Python Enhancement Proposals; PEP 3119 <2>: 例とレシピ.    (line   70)
* Python Enhancement Proposals; PEP 3119 <3>: abc --- 抽象基底クラス.
                                                             (line   10)
* Python Enhancement Proposals; PEP 3119 <4>: オブジェクトプロトコル object protocol.
                                                             (line  377)
* Python Enhancement Proposals; PEP 3119 <5>: オブジェクトプロトコル object protocol.
                                                             (line  398)
* Python Enhancement Proposals; PEP 3120: Unicode 対 8 ビット、ではなく、テキスト対データに.
                                                             (line  115)
* Python Enhancement Proposals; PEP 3120 <1>: 字句解析.      (line   13)
* Python Enhancement Proposals; PEP 3120 <2>: はじめに<10>.  (line   89)
* Python Enhancement Proposals; PEP 3121: ビルドならびに C API の変更<7>.
                                                             (line   13)
* Python Enhancement Proposals; PEP 3121 <1>: Core and Builtins<39>.
                                                             (line  230)
* Python Enhancement Proposals; PEP 3121 <2>: Cモジュールの初期化.
                                                             (line   55)
* Python Enhancement Proposals; PEP 3123: ビルドならびに C API の変更<7>.
                                                             (line   15)
* Python Enhancement Proposals; PEP 3127: PEP 3127 整数リテラルのサポートと文法.
                                                             (line   46)
* Python Enhancement Proposals; PEP 3129: PEP 3129 クラスデコレータ.
                                                             (line   24)
* Python Enhancement Proposals; PEP 3129 <1>: 関数定義.      (line  161)
* Python Enhancement Proposals; PEP 3129 <2>: クラス定義.    (line   88)
* Python Enhancement Proposals; PEP 3131: Unicode 対 8 ビット、ではなく、テキスト対データに.
                                                             (line  117)
* Python Enhancement Proposals; PEP 3131 <1>: Library<50>.   (line  599)
* Python Enhancement Proposals; PEP 3131 <2>: 識別子 identifier およびキーワード keyword.
                                                             (line    9)
* Python Enhancement Proposals; PEP 3131 <3>: 識別子 identifier およびキーワード keyword.
                                                             (line   16)
* Python Enhancement Proposals; PEP 3132: 新たな構文.        (line   32)
* Python Enhancement Proposals; PEP 3132 <1>: 代入文 assignment statement.
                                                             (line  153)
* Python Enhancement Proposals; PEP 3134: 変更された構文.    (line    6)
* Python Enhancement Proposals; PEP 3134 <1>: 例外に関する変更.
                                                             (line   39)
* Python Enhancement Proposals; PEP 3134 <2>: 例外に関する変更.
                                                             (line   60)
* Python Enhancement Proposals; PEP 3134 <3>: Library<24>.   (line   48)
* Python Enhancement Proposals; PEP 3134 <4>: 基底クラス.    (line   27)
* Python Enhancement Proposals; PEP 3135: 組み込み.          (line    6)
* Python Enhancement Proposals; PEP 3135 <1>: クラスオブジェクトの作成.
                                                             (line   52)
* Python Enhancement Proposals; PEP 3137: PEP 3137 memoryview オブジェクト.
                                                             (line   49)
* Python Enhancement Proposals; PEP 3138: Unicode 対 8 ビット、ではなく、テキスト対データに.
                                                             (line  111)
* Python Enhancement Proposals; PEP 314: PEP 314 Metadata for Python Software Packages v1 1.
                                                             (line   42)
* Python Enhancement Proposals; PEP 3141: PEP 3141 数値の型階層.
                                                             (line   41)
* Python Enhancement Proposals; PEP 3141 <1>: numbers --- 数の抽象基底クラス.
                                                             (line   10)
* Python Enhancement Proposals; PEP 3141 <2>: abc --- 抽象基底クラス.
                                                             (line   13)
* Python Enhancement Proposals; PEP 3144: ipaddress<6>.      (line   11)
* Python Enhancement Proposals; PEP 3147: PEP 421 sys implementation の追加.
                                                             (line   19)
* Python Enhancement Proposals; PEP 3147 <1>: PEP 3147 PYC リポジトリーディレクトリ.
                                                             (line   68)
* Python Enhancement Proposals; PEP 3147 <2>: "コンパイル" された Python ファイル.
                                                             (line   49)
* Python Enhancement Proposals; PEP 3147 <3>: Import-related attributes on module objects.
                                                             (line  155)
* Python Enhancement Proposals; PEP 3147 <4>: test support import_helper --- Utilities for import tests.
                                                             (line   82)
* Python Enhancement Proposals; PEP 3147 <5>: runpy --- Python モジュールの位置特定と実行.
                                                             (line   87)
* Python Enhancement Proposals; PEP 3147 <6>: はじめに<10>.  (line   93)
* Python Enhancement Proposals; PEP 3147 <7>: importlib util -- インポータのためのユーティリティコード.
                                                             (line   24)
* Python Enhancement Proposals; PEP 3147 <8>: importlib util -- インポータのためのユーティリティコード.
                                                             (line   60)
* Python Enhancement Proposals; PEP 3147 <9>: importlib util -- インポータのためのユーティリティコード.
                                                             (line   64)
* Python Enhancement Proposals; PEP 3147 <10>: py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   29)
* Python Enhancement Proposals; PEP 3147 <11>: py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   70)
* Python Enhancement Proposals; PEP 3147 <12>: コマンドラインでの使用<2>.
                                                             (line   61)
* Python Enhancement Proposals; PEP 3147 <13>: パブリックな関数.
                                                             (line   40)
* Python Enhancement Proposals; PEP 3147 <14>: パブリックな関数.
                                                             (line  122)
* Python Enhancement Proposals; PEP 3147 <15>: モジュールのインポート<2>.
                                                             (line  217)
* Python Enhancement Proposals; PEP 3147 <16>: pyc ファイルを作るにはどうしますか？.
                                                             (line   12)
* Python Enhancement Proposals; PEP 3148: PEP 3148 concurrent futures モジュール.
                                                             (line   53)
* Python Enhancement Proposals; PEP 3148 <1>: モジュール関数<2>.
                                                             (line   60)
* Python Enhancement Proposals; PEP 3149: PEP 3149 ABI バージョンでタグ付けされた so ファイル.
                                                             (line   33)
* Python Enhancement Proposals; PEP 3149 <1>: Core and Builtins<93>.
                                                             (line    9)
* Python Enhancement Proposals; PEP 3149 <2>: sys --- システム固有のパラメーターと関数.
                                                             (line   15)
* Python Enhancement Proposals; PEP 3151: PEP 3151 OS および IO 例外階層の手直し.
                                                             (line   82)
* Python Enhancement Proposals; PEP 3151 <1>: OS 例外.       (line  122)
* Python Enhancement Proposals; PEP 3151 <2>: 例外<14>.      (line   10)
* Python Enhancement Proposals; PEP 3151 <3>: select --- I/O 完了の待機.
                                                             (line   33)
* Python Enhancement Proposals; PEP 3151 <4>: resource --- リソース使用情報.
                                                             (line   22)
* Python Enhancement Proposals; PEP 3151 <5>: 標準例外.      (line  184)
* Python Enhancement Proposals; PEP 3153: asyncio<11>.       (line   22)
* Python Enhancement Proposals; PEP 3154: 概要 -- リリースハイライト<8>.
                                                             (line   58)
* Python Enhancement Proposals; PEP 3154 <1>: pickle<4>.     (line   15)
* Python Enhancement Proposals; PEP 3154 <2>: Library<50>.   (line 1279)
* Python Enhancement Proposals; PEP 3154 <3>: データストリームの形式.
                                                             (line   45)
* Python Enhancement Proposals; PEP 3155: PEP 3155 クラスと関数の正規名.
                                                             (line   63)
* Python Enhancement Proposals; PEP 3155 <1>: 用語集<2>.     (line 1239)
* Python Enhancement Proposals; PEP 3156: 概要 -- リリースハイライト<8>.
                                                             (line   32)
* Python Enhancement Proposals; PEP 3156 <1>: 概要 -- リリースハイライト<8>.
                                                             (line   44)
* Python Enhancement Proposals; PEP 3156 <2>: asyncio<11>.   (line    6)
* Python Enhancement Proposals; PEP 3156 <3>: asyncio<11>.   (line   18)
* Python Enhancement Proposals; PEP 3156 <4>: selectors<2>.  (line    6)
* Python Enhancement Proposals; PEP 318: PEP 318 関数とメソッドのためのデコレータ.
                                                             (line  100)
* Python Enhancement Proposals; PEP 318 <1>: PEP 318 関数とメソッドのためのデコレータ.
                                                             (line  124)
* Python Enhancement Proposals; PEP 318 <2>: その他の言語変更<15>.
                                                             (line    8)
* Python Enhancement Proposals; PEP 318 <3>: 関数定義.       (line  158)
* Python Enhancement Proposals; PEP 318 <4>: クラス定義.     (line   91)
* Python Enhancement Proposals; PEP 322: PEP 322 逆順のイテレーション.
                                                             (line   34)
* Python Enhancement Proposals; PEP 322 <1>: その他の言語変更<15>.
                                                             (line   12)
* Python Enhancement Proposals; PEP 324: PEP 324 新しい subprocess モジュール.
                                                             (line   83)
* Python Enhancement Proposals; PEP 324 <1>: subprocess --- サブプロセス管理.
                                                             (line   23)
* Python Enhancement Proposals; PEP 325: PEP 342 ジェネレータの新機能.
                                                             (line  140)
* Python Enhancement Proposals; PEP 327: Context 型.         (line   55)
* Python Enhancement Proposals; PEP 328: Python コードの移植.
                                                             (line   39)
* Python Enhancement Proposals; PEP 328 <1>: 削除された操作. (line   31)
* Python Enhancement Proposals; PEP 328 <2>: PEP 328 絶対インポート、相対インポート.
                                                             (line    6)
* Python Enhancement Proposals; PEP 328 <3>: PEP 328 絶対インポート、相対インポート.
                                                             (line   84)
* Python Enhancement Proposals; PEP 328 <4>: PEP 328 マルチラインインポート.
                                                             (line   34)
* Python Enhancement Proposals; PEP 328 <5>: その他の言語変更<15>.
                                                             (line   20)
* Python Enhancement Proposals; PEP 328 <6>: 参考資料.       (line   20)
* Python Enhancement Proposals; PEP 328 <7>: 組み込み関数.   (line 2182)
* Python Enhancement Proposals; PEP 328 <8>: モジュールコンテンツ<5>.
                                                             (line   23)
* Python Enhancement Proposals; PEP 328 <9>: はじめに<10>.   (line   61)
* Python Enhancement Proposals; PEP 331: PEP 331 Locale に依存しない Float/String 変換.
                                                             (line   37)
* Python Enhancement Proposals; PEP 333: wsgiref パッケージ. (line    7)
* Python Enhancement Proposals; PEP 333 <1>: wsgiref パッケージ.
                                                             (line   31)
* Python Enhancement Proposals; PEP 3333: 新たなモジュール.  (line    9)
* Python Enhancement Proposals; PEP 3333 <1>: PEP 3333 Python Web Server Gateway Interface v1 0 1.
                                                             (line   54)
* Python Enhancement Proposals; PEP 3333 <2>: wsgiref --- WSGI ユーティリティとリファレンス実装.
                                                             (line   24)
* Python Enhancement Proposals; PEP 3333 <3>: wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line    7)
* Python Enhancement Proposals; PEP 3333 <4>: wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line    9)
* Python Enhancement Proposals; PEP 3333 <5>: wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line   28)
* Python Enhancement Proposals; PEP 3333 <6>: wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line   75)
* Python Enhancement Proposals; PEP 3333 <7>: wsgiref headers -- WSGI レスポンスヘッダツール群.
                                                             (line   11)
* Python Enhancement Proposals; PEP 3333 <8>: wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   20)
* Python Enhancement Proposals; PEP 3333 <9>: wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   94)
* Python Enhancement Proposals; PEP 3333 <10>: wsgiref validate --- WSGI 準拠チェッカー.
                                                             (line   13)
* Python Enhancement Proposals; PEP 3333 <11>: wsgiref validate --- WSGI 準拠チェッカー.
                                                             (line   36)
* Python Enhancement Proposals; PEP 3333 <12>: wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  232)
* Python Enhancement Proposals; PEP 3333 <13>: wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  247)
* Python Enhancement Proposals; PEP 3333 <14>: wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  253)
* Python Enhancement Proposals; PEP 3333 <15>: wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  265)
* Python Enhancement Proposals; PEP 3333 <16>: wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  305)
* Python Enhancement Proposals; PEP 3333 <17>: wsgiref types -- WSGI types for static type checking.
                                                             (line    7)
* Python Enhancement Proposals; PEP 3333 <18>: wsgiref types -- WSGI types for static type checking.
                                                             (line   14)
* Python Enhancement Proposals; PEP 3333#input-and-error-streams: wsgiref types -- WSGI types for static type checking.
                                                             (line   26)
* Python Enhancement Proposals; PEP 3333#input-and-error-streams <1>: wsgiref types -- WSGI types for static type checking.
                                                             (line   30)
* Python Enhancement Proposals; PEP 3333#optional-platform-specific-file-handling: wsgiref types -- WSGI types for static type checking.
                                                             (line   34)
* Python Enhancement Proposals; PEP 3333#the-start-response-callable: wsgiref types -- WSGI types for static type checking.
                                                             (line   13)
* Python Enhancement Proposals; PEP 338: PEP 338 - モジュールをスクリプトとして実行する.
                                                             (line   21)
* Python Enhancement Proposals; PEP 338 <1>: インターフェイスオプション.
                                                             (line   98)
* Python Enhancement Proposals; PEP 338 <2>: 参考資料.       (line   24)
* Python Enhancement Proposals; PEP 338 <3>: runpy --- Python モジュールの位置特定と実行.
                                                             (line  177)
* Python Enhancement Proposals; PEP 339: ビルドならびに C API の変更<10>.
                                                             (line   44)
* Python Enhancement Proposals; PEP 341: PEP 341 try/except/finally の一体化.
                                                             (line   45)
* Python Enhancement Proposals; PEP 342: PEP 342 ジェネレータの新機能.
                                                             (line   40)
* Python Enhancement Proposals; PEP 342 <1>: PEP 342 ジェネレータの新機能.
                                                             (line  133)
* Python Enhancement Proposals; PEP 342 <2>: Python 2 5 への移植.
                                                             (line   15)
* Python Enhancement Proposals; PEP 342 <3>: Yield 式.       (line   88)
* Python Enhancement Proposals; PEP 342 <4>: コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   58)
* Python Enhancement Proposals; PEP 342 <5>: ジェネレータに値を渡す.
                                                             (line   23)
* Python Enhancement Proposals; PEP 342 <6>: Python 文書.    (line   14)
* Python Enhancement Proposals; PEP 343: contextlib モジュール.
                                                             (line   64)
* Python Enhancement Proposals; PEP 343 <1>: PEP 342 ジェネレータの新機能.
                                                             (line  123)
* Python Enhancement Proposals; PEP 343 <2>: contextlib モジュール<2>.
                                                             (line   64)
* Python Enhancement Proposals; PEP 343 <3>: with文とコンテキストマネージャ.
                                                             (line   45)
* Python Enhancement Proposals; PEP 343 <4>: with 文.        (line  106)
* Python Enhancement Proposals; PEP 343 <5>: コンテキストマネージャーを関数デコレーターとして使う.
                                                             (line   50)
* Python Enhancement Proposals; PEP 343 <6>: モジュールコンテンツ<5>.
                                                             (line   27)
* Python Enhancement Proposals; PEP 343 <7>: 用語集<2>.      (line  303)
* Python Enhancement Proposals; PEP 343 <8>: 用語集<2>.      (line  309)
* Python Enhancement Proposals; PEP 347: ビルドならびに C API の変更<10>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 352: 例外に関する変更.   (line    8)
* Python Enhancement Proposals; PEP 352 <1>: 非推奨と削除.   (line    9)
* Python Enhancement Proposals; PEP 352 <2>: PEP 352 例外の新スタイルクラス化.
                                                             (line   65)
* Python Enhancement Proposals; PEP 353: Porting to Python 3 10<2>.
                                                             (line    9)
* Python Enhancement Proposals; PEP 353 <1>: PEP 353 添え字型に ssize_t を使う.
                                                             (line   53)
* Python Enhancement Proposals; PEP 353 <2>: PEP 353 添え字型に ssize_t を使う.
                                                             (line   59)
* Python Enhancement Proposals; PEP 353 <3>: ビルドならびに C API の変更<10>.
                                                             (line   19)
* Python Enhancement Proposals; PEP 353 <4>: C API<37>.      (line   78)
* Python Enhancement Proposals; PEP 353 <5>: 型.             (line   17)
* Python Enhancement Proposals; PEP 356: What's New in Python 2 5.
                                                             (line   10)
* Python Enhancement Proposals; PEP 357: PEP 357 '__index__' メソッド.
                                                             (line   37)
* Python Enhancement Proposals; PEP 361: What's New in Python 2 6.
                                                             (line   10)
* Python Enhancement Proposals; PEP 362: PEP 362 関数シグニチャオブジェクト.
                                                             (line   20)
* Python Enhancement Proposals; PEP 362 <1>: Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  394)
* Python Enhancement Proposals; PEP 362 <2>: 用語集<2>.      (line   80)
* Python Enhancement Proposals; PEP 362 <3>: 用語集<2>.      (line 1130)
* Python Enhancement Proposals; PEP 366: 目に見える変化.     (line   25)
* Python Enhancement Proposals; PEP 366 <1>: Import-related attributes on module objects.
                                                             (line   62)
* Python Enhancement Proposals; PEP 366 <2>: 参考資料.       (line   17)
* Python Enhancement Proposals; PEP 366 <3>: 参考資料.       (line   21)
* Python Enhancement Proposals; PEP 366 <4>: runpy --- Python モジュールの位置特定と実行.
                                                             (line  181)
* Python Enhancement Proposals; PEP 366 <5>: はじめに<10>.   (line   65)
* Python Enhancement Proposals; PEP 370: PEP 370 ユーザごとの site-packages ディレクトリ.
                                                             (line   36)
* Python Enhancement Proposals; PEP 370 <1>: Library<22>.    (line  605)
* Python Enhancement Proposals; PEP 370 <2>: その他のオプション.
                                                             (line  155)
* Python Enhancement Proposals; PEP 370 <3>: 環境変数.       (line  203)
* Python Enhancement Proposals; PEP 370 <4>: 環境変数.       (line  215)
* Python Enhancement Proposals; PEP 370 <5>: コマンドラインインターフェイス<10>.
                                                             (line   37)
* Python Enhancement Proposals; PEP 371: PEP 371 multiprocessing パッケージ.
                                                             (line  143)
* Python Enhancement Proposals; PEP 372: PEP 372 順序付き辞書.
                                                             (line   30)
* Python Enhancement Proposals; PEP 372 <1>: PEP 372 collections に順序付き辞書を追加.
                                                             (line   95)
* Python Enhancement Proposals; PEP 373: Python 2 x の今後.  (line   21)
* Python Enhancement Proposals; PEP 373 <1>: Python はどれくらい安定していますか？.
                                                             (line   20)
* Python Enhancement Proposals; PEP 378: PEP 378 1000区切りのための書式指定子.
                                                             (line   31)
* Python Enhancement Proposals; PEP 378 <1>: PEP 378 1000区切りのための書式指定子<2>.
                                                             (line   35)
* Python Enhancement Proposals; PEP 378 <2>: 書式指定ミニ言語仕様.
                                                             (line  106)
* Python Enhancement Proposals; PEP 380: PEP 380 サブジェネレータへの委譲構文.
                                                             (line   66)
* Python Enhancement Proposals; PEP 380 <1>: Yield 式.       (line   93)
* Python Enhancement Proposals; PEP 380#use-of-stopiteration-to-return-values: The STOP_ITERATION event.
                                                             (line    6)
* Python Enhancement Proposals; PEP 383: Documentation<18>.  (line   29)
* Python Enhancement Proposals; PEP 383 <1>: エラーハンドラ. (line   49)
* Python Enhancement Proposals; PEP 383 <2>: ソケットファミリー.
                                                             (line   15)
* Python Enhancement Proposals; PEP 383 <3>: ロケールエンコーディング.
                                                             (line   15)
* Python Enhancement Proposals; PEP 383 <4>: ロケールエンコーディング.
                                                             (line   51)
* Python Enhancement Proposals; PEP 383 <5>: ファイルシステムエンコーディング.
                                                             (line    7)
* Python Enhancement Proposals; PEP 384: 削除<4>.            (line   53)
* Python Enhancement Proposals; PEP 384 <1>: その他のビルド並びに C API の変更.
                                                             (line   10)
* Python Enhancement Proposals; PEP 384 <2>: PEP 384 安定 ABI の定義.
                                                             (line   24)
* Python Enhancement Proposals; PEP 384 <3>: C API<31>.      (line  100)
* Python Enhancement Proposals; PEP 385: コードリポジトリ.   (line   12)
* Python Enhancement Proposals; PEP 387: 警告.               (line   26)
* Python Enhancement Proposals; PEP 387 <1>: 警告.           (line   40)
* Python Enhancement Proposals; PEP 387 <2>: C API の安定性. (line    7)
* Python Enhancement Proposals; PEP 387 <3>: Python のバージョン番号の仕組みはどうなっているのですか？.
                                                             (line   46)
* Python Enhancement Proposals; PEP 389: PEP 389 argparse コマンドライン解析モジュール.
                                                             (line   92)
* Python Enhancement Proposals; PEP 389 <1>: PEP 389 コマンドライン解析のための argparse モジュール.
                                                             (line  100)
* Python Enhancement Proposals; PEP 391: PEP 391 logging の辞書ベースの設定.
                                                             (line   52)
* Python Enhancement Proposals; PEP 391 <1>: PEP 391 logging の辞書ベースの設定<2>.
                                                             (line   94)
* Python Enhancement Proposals; PEP 392: What's New In Python 3 2.
                                                             (line   17)
* Python Enhancement Proposals; PEP 393: 削除<4>.            (line   26)
* Python Enhancement Proposals; PEP 393 <1>: Python 3 9への移植<2>.
                                                             (line   45)
* Python Enhancement Proposals; PEP 393 <2>: 削除<6>.        (line  101)
* Python Enhancement Proposals; PEP 393 <3>: PEP 393 文字列の柔軟な表現.
                                                             (line   16)
* Python Enhancement Proposals; PEP 393 <4>: 機能性.         (line    6)
* Python Enhancement Proposals; PEP 393 <5>: 性能およびリソース使用量.
                                                             (line   32)
* Python Enhancement Proposals; PEP 393 <6>: 最適化<8>.      (line    8)
* Python Enhancement Proposals; PEP 393 <7>: ビルドならびに C API の変更<4>.
                                                             (line   12)
* Python Enhancement Proposals; PEP 393 <8>: 非推奨の Python モジュール、関数、メソッド<4>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 393 <9>: C API の非推奨の関数ならびに型<3>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 393 <10>: C コードの移植.
                                                             (line   16)
* Python Enhancement Proposals; PEP 393 <11>: C API<29>.     (line  142)
* Python Enhancement Proposals; PEP 393 <12>: エンコーディングと Unicode.
                                                             (line    7)
* Python Enhancement Proposals; PEP 393 <13>: sys --- システム固有のパラメーターと関数.
                                                             (line 1232)
* Python Enhancement Proposals; PEP 393 <14>: Unicode オブジェクト.
                                                             (line    6)
* Python Enhancement Proposals; PEP 397: PEP 486 Python ランチャーが仮想環境を認識する.
                                                             (line    6)
* Python Enhancement Proposals; PEP 397 <1>: PEP 397 Windows の Python ランチャ.
                                                             (line   31)
* Python Enhancement Proposals; PEP 397 <2>: Windows の Python ランチャ.
                                                             (line   18)
* Python Enhancement Proposals; PEP 398: What's New In Python 3 3.
                                                             (line   13)
* Python Enhancement Proposals; PEP 4:   ライブラリの変更.   (line   12)
* Python Enhancement Proposals; PEP 405: PEP 405 仮想環境.   (line   22)
* Python Enhancement Proposals; PEP 405 <1>: venv --- 仮想環境の作成.
                                                             (line   42)
* Python Enhancement Proposals; PEP 409: PEP 409 例外コンテキストの抑制.
                                                             (line   63)
* Python Enhancement Proposals; PEP 411: sys --- システム固有のパラメーターと関数.
                                                             (line  997)
* Python Enhancement Proposals; PEP 411 <1>: sys --- システム固有のパラメーターと関数.
                                                             (line 1007)
* Python Enhancement Proposals; PEP 411 <2>: sys --- システム固有のパラメーターと関数.
                                                             (line 1688)
* Python Enhancement Proposals; PEP 411 <3>: sys --- システム固有のパラメーターと関数.
                                                             (line 1708)
* Python Enhancement Proposals; PEP 411 <4>: 用語集<2>.      (line 1208)
* Python Enhancement Proposals; PEP 412: PEP 412 キー共有辞書.
                                                             (line   14)
* Python Enhancement Proposals; PEP 412 <1>: functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line   91)
* Python Enhancement Proposals; PEP 414: PEP 414 明示的なユニコードリテラル.
                                                             (line   17)
* Python Enhancement Proposals; PEP 414 <1>: 文字列およびバイト列リテラル.
                                                             (line   62)
* Python Enhancement Proposals; PEP 418: time<8>.            (line    6)
* Python Enhancement Proposals; PEP 420: importlib<9>.       (line   35)
* Python Enhancement Proposals; PEP 420 <1>: PEP 420 暗黙的な名前空間パッケージ.
                                                             (line    7)
* Python Enhancement Proposals; PEP 420 <2>: PEP 420 暗黙的な名前空間パッケージ.
                                                             (line   13)
* Python Enhancement Proposals; PEP 420 <3>: Core and Builtins<78>.
                                                             (line   56)
* Python Enhancement Proposals; PEP 420 <4>: Core and Builtins<83>.
                                                             (line  114)
* Python Enhancement Proposals; PEP 420 <5>: インポートシステム.
                                                             (line   43)
* Python Enhancement Proposals; PEP 420 <6>: 名前空間パッケージ.
                                                             (line   27)
* Python Enhancement Proposals; PEP 420 <7>: __path__ attributes on modules.
                                                             (line   23)
* Python Enhancement Proposals; PEP 420 <8>: __path__ attributes on modules.
                                                             (line   23)
* Python Enhancement Proposals; PEP 420 <9>: 参考資料.       (line   11)
* Python Enhancement Proposals; PEP 420 <10>: 参考資料.      (line   13)
* Python Enhancement Proposals; PEP 420 <11>: 参考資料.      (line   13)
* Python Enhancement Proposals; PEP 420 <12>: はじめに<10>.  (line   69)
* Python Enhancement Proposals; PEP 420 <13>: 用語集<2>.     (line 1035)
* Python Enhancement Proposals; PEP 420 <14>: 用語集<2>.     (line 1186)
* Python Enhancement Proposals; PEP 421: SimpleNamespace.    (line   16)
* Python Enhancement Proposals; PEP 421 <1>: sys --- システム固有のパラメーターと関数.
                                                             (line 1107)
* Python Enhancement Proposals; PEP 421 <2>: sys --- システム固有のパラメーターと関数.
                                                             (line 1112)
* Python Enhancement Proposals; PEP 424: その他の言語変更<8>.
                                                             (line   60)
* Python Enhancement Proposals; PEP 424 <1>: operator<3>.    (line    7)
* Python Enhancement Proposals; PEP 428: 概要 -- リリースハイライト<8>.
                                                             (line   41)
* Python Enhancement Proposals; PEP 428 <1>: pathlib<11>.    (line   18)
* Python Enhancement Proposals; PEP 428 <2>: pathlib --- オブジェクト指向のファイルシステムパス.
                                                             (line   40)
* Python Enhancement Proposals; PEP 429: What's New In Python 3 4.
                                                             (line   16)
* Python Enhancement Proposals; PEP 432: その他の CPython の実装の変更<3>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 432 <1>: Core and Builtins<61>.
                                                             (line  312)
* Python Enhancement Proposals; PEP 432 <2>: Multi-Phase Initialization Private Provisional API.
                                                             (line    7)
* Python Enhancement Proposals; PEP 432 <3>: Multi-Phase Initialization Private Provisional API.
                                                             (line   57)
* Python Enhancement Proposals; PEP 434: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い.
                                                             (line    6)
* Python Enhancement Proposals; PEP 434 <1>: idlelib.        (line   17)
* Python Enhancement Proposals; PEP 435: 概要 -- リリースハイライト<8>.
                                                             (line   38)
* Python Enhancement Proposals; PEP 435 <1>: enum<8>.        (line    6)
* Python Enhancement Proposals; PEP 435 <2>: enum<8>.        (line   15)
* Python Enhancement Proposals; PEP 436: 概要 -- リリースハイライト<8>.
                                                             (line  127)
* Python Enhancement Proposals; PEP 436 <1>: PEP 436 Argument Clinic.
                                                             (line    6)
* Python Enhancement Proposals; PEP 436 <2>: PEP 436 Argument Clinic.
                                                             (line   28)
* Python Enhancement Proposals; PEP 441: zipapp<2>.          (line    6)
* Python Enhancement Proposals; PEP 441 <1>: zipapp<2>.      (line   24)
* Python Enhancement Proposals; PEP 442: 削除<5>.            (line   68)
* Python Enhancement Proposals; PEP 442 <1>: 概要 -- リリースハイライト<8>.
                                                             (line  118)
* Python Enhancement Proposals; PEP 442 <2>: 概要 -- リリースハイライト<8>.
                                                             (line  121)
* Python Enhancement Proposals; PEP 442 <3>: PEP 442 オブジェクトの安全なファイナライゼーション.
                                                             (line    6)
* Python Enhancement Proposals; PEP 442 <4>: PEP 442 オブジェクトの安全なファイナライゼーション.
                                                             (line   25)
* Python Enhancement Proposals; PEP 442 <5>: C API<44>.      (line   55)
* Python Enhancement Proposals; PEP 442 <6>: gc --- ガベージコレクターインターフェース.
                                                             (line  247)
* Python Enhancement Proposals; PEP 442 <7>: ファイナライズとメモリ解放.
                                                             (line   89)
* Python Enhancement Proposals; PEP 442 <8>: PyTypeObject スロット.
                                                             (line 1643)
* Python Enhancement Proposals; PEP 443: 概要 -- リリースハイライト<8>.
                                                             (line   56)
* Python Enhancement Proposals; PEP 443 <1>: functools<5>.   (line   25)
* Python Enhancement Proposals; PEP 443 <2>: 用語集<2>.      (line  639)
* Python Enhancement Proposals; PEP 445: 概要 -- リリースハイライト<8>.
                                                             (line  125)
* Python Enhancement Proposals; PEP 445 <1>: PEP 445 CPython のメモリアロケータのカスタマイズ.
                                                             (line    6)
* Python Enhancement Proposals; PEP 445 <2>: PEP 445 CPython のメモリアロケータのカスタマイズ.
                                                             (line   12)
* Python Enhancement Proposals; PEP 445 <3>: その他の改善<2>.
                                                             (line   62)
* Python Enhancement Proposals; PEP 446: 概要 -- リリースハイライト<8>.
                                                             (line   16)
* Python Enhancement Proposals; PEP 446 <1>: 概要 -- リリースハイライト<8>.
                                                             (line   83)
* Python Enhancement Proposals; PEP 446 <2>: PEP 446 新規作成されたファイル記述子は継承不可.
                                                             (line    6)
* Python Enhancement Proposals; PEP 446 <3>: PEP 446 新規作成されたファイル記述子は継承不可.
                                                             (line   26)
* Python Enhancement Proposals; PEP 446 <4>: Core and Builtins<13>.
                                                             (line   20)
* Python Enhancement Proposals; PEP 448: PEP 448 - 追加可能なアンパックへの一般化.
                                                             (line    6)
* Python Enhancement Proposals; PEP 448 <1>: PEP 448 - 追加可能なアンパックへの一般化.
                                                             (line   38)
* Python Enhancement Proposals; PEP 448 <2>: Documentation<65>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 448 <3>: Documentation<69>.
                                                             (line    9)
* Python Enhancement Proposals; PEP 448 <4>: Core and Builtins<86>.
                                                             (line   12)
* Python Enhancement Proposals; PEP 448 <5>: Core and Builtins<89>.
                                                             (line    9)
* Python Enhancement Proposals; PEP 448 <6>: 辞書表示.       (line   28)
* Python Enhancement Proposals; PEP 448 <7>: 呼び出し call.  (line  119)
* Python Enhancement Proposals; PEP 448 <8>: 式のリスト.     (line   22)
* Python Enhancement Proposals; PEP 450: 概要 -- リリースハイライト<8>.
                                                             (line   48)
* Python Enhancement Proposals; PEP 450 <1>: statistics<6>.  (line    6)
* Python Enhancement Proposals; PEP 450 <2>: statistics<6>.  (line   13)
* Python Enhancement Proposals; PEP 451: zipimport<2>.       (line    8)
* Python Enhancement Proposals; PEP 451 <1>: zipimport<3>.   (line    6)
* Python Enhancement Proposals; PEP 451 <2>: PEP 489 拡張モジュールの多段階初期化.
                                                             (line    6)
* Python Enhancement Proposals; PEP 451 <3>: 概要 -- リリースハイライト<8>.
                                                             (line   24)
* Python Enhancement Proposals; PEP 451 <4>: PEP 451 インポートシステムのための ModuleSpec 型.
                                                             (line    6)
* Python Enhancement Proposals; PEP 451 <5>: Library<22>.    (line  457)
* Python Enhancement Proposals; PEP 451 <6>: Core and Builtins<78>.
                                                             (line   75)
* Python Enhancement Proposals; PEP 451 <7>: 参考資料.       (line   27)
* Python Enhancement Proposals; PEP 451 <8>: sys --- システム固有のパラメーターと関数.
                                                             (line 1263)
* Python Enhancement Proposals; PEP 451 <9>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line   68)
* Python Enhancement Proposals; PEP 451 <10>: pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  103)
* Python Enhancement Proposals; PEP 451 <11>: runpy --- Python モジュールの位置特定と実行.
                                                             (line   90)
* Python Enhancement Proposals; PEP 451 <12>: runpy --- Python モジュールの位置特定と実行.
                                                             (line  167)
* Python Enhancement Proposals; PEP 451 <13>: runpy --- Python モジュールの位置特定と実行.
                                                             (line  185)
* Python Enhancement Proposals; PEP 451 <14>: はじめに<10>.  (line   73)
* Python Enhancement Proposals; PEP 451 <15>: 多段階初期化.  (line   73)
* Python Enhancement Proposals; PEP 453: 概要 -- リリースハイライト<8>.
                                                             (line   13)
* Python Enhancement Proposals; PEP 453 <1>: 概要 -- リリースハイライト<8>.
                                                             (line   36)
* Python Enhancement Proposals; PEP 453 <2>: デフォルトでの pip のブートストラッピング.
                                                             (line    6)
* Python Enhancement Proposals; PEP 453 <3>: ドキュメントの変更.
                                                             (line   21)
* Python Enhancement Proposals; PEP 453 <4>: ensurepip<2>.   (line    6)
* Python Enhancement Proposals; PEP 453 <5>: venv<7>.        (line   13)
* Python Enhancement Proposals; PEP 453 <6>: その他の改善<2>.
                                                             (line   73)
* Python Enhancement Proposals; PEP 453 <7>: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート.
                                                             (line    6)
* Python Enhancement Proposals; PEP 453 <8>: デフォルトでの pip のブートストラッピング<2>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 453 <9>: ドキュメントの変更<2>.
                                                             (line   21)
* Python Enhancement Proposals; PEP 453 <10>: ensurepip --- pip インストーラーのブートストラップ.
                                                             (line   36)
* Python Enhancement Proposals; PEP 454: 概要 -- リリースハイライト<8>.
                                                             (line   51)
* Python Enhancement Proposals; PEP 454 <1>: tracemalloc<4>. (line    6)
* Python Enhancement Proposals; PEP 454 <2>: tracemalloc<4>. (line   21)
* Python Enhancement Proposals; PEP 456: 概要 -- リリースハイライト<8>.
                                                             (line   79)
* Python Enhancement Proposals; PEP 456 <1>: PEP 456 安全で取り換え可能なハッシュアルゴリズム.
                                                             (line    6)
* Python Enhancement Proposals; PEP 456 <2>: PyHash API.     (line   76)
* Python Enhancement Proposals; PEP 461: PEP 461 - bytes および bytearray のパーセント書式化サポート.
                                                             (line    6)
* Python Enhancement Proposals; PEP 461 <1>: PEP 461 - bytes および bytearray のパーセント書式化サポート.
                                                             (line   41)
* Python Enhancement Proposals; PEP 461 <2>: printf 形式での bytes の書式化.
                                                             (line  189)
* Python Enhancement Proposals; PEP 465: PEP 465 - 行列の乗算専用の中置演算子.
                                                             (line    6)
* Python Enhancement Proposals; PEP 465 <1>: PEP 465 - 行列の乗算専用の中置演算子.
                                                             (line   42)
* Python Enhancement Proposals; PEP 465 <2>: ビルドならびに C API の変更<3>.
                                                             (line   43)
* Python Enhancement Proposals; PEP 465 <3>: Tools/Demos<48>.
                                                             (line   39)
* Python Enhancement Proposals; PEP 466: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張.
                                                             (line    6)
* Python Enhancement Proposals; PEP 466 <1>: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張.
                                                             (line   10)
* Python Enhancement Proposals; PEP 466 <2>: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張.
                                                             (line   21)
* Python Enhancement Proposals; PEP 466 <3>: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張.
                                                             (line   32)
* Python Enhancement Proposals; PEP 468: PEP 468 キーワード引数の順番の保持.
                                                             (line   12)
* Python Enhancement Proposals; PEP 468 <1>: Library<68>.    (line   87)
* Python Enhancement Proposals; PEP 468 <2>: OrderedDict オブジェクト.
                                                             (line  102)
* Python Enhancement Proposals; PEP 471: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ.
                                                             (line    6)
* Python Enhancement Proposals; PEP 471 <1>: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ.
                                                             (line   29)
* Python Enhancement Proposals; PEP 471 <2>: Library<94>.    (line    6)
* Python Enhancement Proposals; PEP 475: PEP 475 EINTR で失敗したシステムコールの再試行.
                                                             (line   32)
* Python Enhancement Proposals; PEP 475 <1>: PEP 475 EINTR で失敗したシステムコールの再試行.
                                                             (line   77)
* Python Enhancement Proposals; PEP 475 <2>: Python API の変更<7>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 475 <3>: Library<59>.    (line  228)
* Python Enhancement Proposals; PEP 475 <4>: Library<92>.    (line  143)
* Python Enhancement Proposals; PEP 475 <5>: 組み込み関数.   (line 1487)
* Python Enhancement Proposals; PEP 475 <6>: OS 例外.        (line   81)
* Python Enhancement Proposals; PEP 475 <7>: ファイル記述子の操作.
                                                             (line  407)
* Python Enhancement Proposals; PEP 475 <8>: ファイル記述子の操作.
                                                             (line  747)
* Python Enhancement Proposals; PEP 475 <9>: ファイル記述子の操作.
                                                             (line  933)
* Python Enhancement Proposals; PEP 475 <10>: プロセス管理.  (line  930)
* Python Enhancement Proposals; PEP 475 <11>: 関数<5>.       (line  296)
* Python Enhancement Proposals; PEP 475 <12>: socket オブジェクト.
                                                             (line   28)
* Python Enhancement Proposals; PEP 475 <13>: socket オブジェクト.
                                                             (line   82)
* Python Enhancement Proposals; PEP 475 <14>: socket オブジェクト.
                                                             (line  252)
* Python Enhancement Proposals; PEP 475 <15>: socket オブジェクト.
                                                             (line  266)
* Python Enhancement Proposals; PEP 475 <16>: socket オブジェクト.
                                                             (line  338)
* Python Enhancement Proposals; PEP 475 <17>: socket オブジェクト.
                                                             (line  410)
* Python Enhancement Proposals; PEP 475 <18>: socket オブジェクト.
                                                             (line  428)
* Python Enhancement Proposals; PEP 475 <19>: socket オブジェクト.
                                                             (line  446)
* Python Enhancement Proposals; PEP 475 <20>: socket オブジェクト.
                                                             (line  489)
* Python Enhancement Proposals; PEP 475 <21>: select --- I/O 完了の待機.
                                                             (line  161)
* Python Enhancement Proposals; PEP 475 <22>: /dev/poll ポーリングオブジェクト.
                                                             (line   82)
* Python Enhancement Proposals; PEP 475 <23>: エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line  105)
* Python Enhancement Proposals; PEP 475 <24>: ポーリングオブジェクト.
                                                             (line   95)
* Python Enhancement Proposals; PEP 475 <25>: kqueue オブジェクト.
                                                             (line   37)
* Python Enhancement Proposals; PEP 475 <26>: クラス<4>.     (line  138)
* Python Enhancement Proposals; PEP 475 <27>: モジュールの内容<2>.
                                                             (line  583)
* Python Enhancement Proposals; PEP 475 <28>: モジュールの内容<2>.
                                                             (line  602)
* Python Enhancement Proposals; PEP 476: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 477: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート.
                                                             (line    6)
* Python Enhancement Proposals; PEP 478: What's New In Python 3 5.
                                                             (line   17)
* Python Enhancement Proposals; PEP 479: Python の挙動の変更<2>.
                                                             (line   11)
* Python Enhancement Proposals; PEP 479 <1>: PEP 479 ジェネレータ内の StopIteration の処理の変更.
                                                             (line   12)
* Python Enhancement Proposals; PEP 479 <2>: PEP 479 ジェネレータ内の StopIteration の処理の変更.
                                                             (line   47)
* Python Enhancement Proposals; PEP 479 <3>: Library<50>.    (line 1267)
* Python Enhancement Proposals; PEP 479 <4>: Library<54>.    (line   52)
* Python Enhancement Proposals; PEP 479 <5>: Core and Builtins<57>.
                                                             (line   34)
* Python Enhancement Proposals; PEP 479 <6>: Library<62>.    (line   95)
* Python Enhancement Proposals; PEP 479 <7>: Library<75>.    (line   80)
* Python Enhancement Proposals; PEP 479 <8>: Library<81>.    (line  326)
* Python Enhancement Proposals; PEP 479 <9>: 具象例外.       (line  270)
* Python Enhancement Proposals; PEP 479 <10>: 具象例外.      (line  273)
* Python Enhancement Proposals; PEP 479 <11>: モジュールコンテンツ<5>.
                                                             (line   36)
* Python Enhancement Proposals; PEP 483: PEP 484 - 型ヒント. (line   43)
* Python Enhancement Proposals; PEP 483 <1>: 用語集<2>.      (line  647)
* Python Enhancement Proposals; PEP 484: PEP 695 Type Parameter Syntax.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <1>: New Features Related to Type Hints.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <2>: PEP 692 Using TypedDict for more precise **kwargs typing.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <3>: 型ヒントに関連する新しい機能.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <4>: PEP 646 Variadic generics.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <5>: 型ヒントに関連する新しい機能<2>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <6>: PEP 612 Parameter Specification Variables.
                                                             (line    7)
* Python Enhancement Proposals; PEP 484 <7>: PEP 613 TypeAlias.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <8>: ast<3>.         (line   17)
* Python Enhancement Proposals; PEP 484 <9>: ast<3>.         (line   20)
* Python Enhancement Proposals; PEP 484 <10>: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <11>: PEP 526 変数アノテーションの文法.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <12>: PEP 484 - 型ヒント.
                                                             (line   13)
* Python Enhancement Proposals; PEP 484 <13>: PEP 484 - 型ヒント.
                                                             (line   37)
* Python Enhancement Proposals; PEP 484 <14>: 関数のアノテーション.
                                                             (line    7)
* Python Enhancement Proposals; PEP 484 <15>: ジェネリック型をエミュレートする.
                                                             (line   15)
* Python Enhancement Proposals; PEP 484 <16>: 注釈付き代入文 annotated assignment statements.
                                                             (line   46)
* Python Enhancement Proposals; PEP 484 <17>: 関数定義.      (line  144)
* Python Enhancement Proposals; PEP 484 <18>: GenericAlias オブジェクトの特別な属性.
                                                             (line   51)
* Python Enhancement Proposals; PEP 484 <19>: NewType.       (line   61)
* Python Enhancement Proposals; PEP 484 <20>: 名前的部分型 vs 構造的部分型.
                                                             (line    6)
* Python Enhancement Proposals; PEP 484 <21>: 名前的部分型 vs 構造的部分型.
                                                             (line   15)
* Python Enhancement Proposals; PEP 484 <22>: Building generic types and type aliases.
                                                             (line  113)
* Python Enhancement Proposals; PEP 484 <23>: Functions and decorators.
                                                             (line  279)
* Python Enhancement Proposals; PEP 484 <24>: Root nodes.    (line   60)
* Python Enhancement Proposals; PEP 484 <25>: ast ヘルパー.  (line   18)
* Python Enhancement Proposals; PEP 484 <26>: ast ヘルパー.  (line   29)
* Python Enhancement Proposals; PEP 484 <27>: コンパイラフラグ.
                                                             (line   30)
* Python Enhancement Proposals; PEP 484 <28>: 用語集<2>.     (line   49)
* Python Enhancement Proposals; PEP 484 <29>: 用語集<2>.     (line  575)
* Python Enhancement Proposals; PEP 484 <30>: 用語集<2>.     (line  647)
* Python Enhancement Proposals; PEP 484 <31>: 用語集<2>.     (line 1441)
* Python Enhancement Proposals; PEP 484 <32>: 用語集<2>.     (line 1456)
* Python Enhancement Proposals; PEP 484 <33>: 用語集<2>.     (line 1485)
* Python Enhancement Proposals; PEP 484#annotating-instance-and-class-methods: PEP 673 Self 型.
                                                             (line    8)
* Python Enhancement Proposals; PEP 485: PEP 485 近似的に等しいことを調べる関数.
                                                             (line    6)
* Python Enhancement Proposals; PEP 485 <1>: PEP 485 近似的に等しいことを調べる関数.
                                                             (line   34)
* Python Enhancement Proposals; PEP 485 <2>: Library<90>.    (line   10)
* Python Enhancement Proposals; PEP 485 <3>: 数論および数表現の関数.
                                                             (line  148)
* Python Enhancement Proposals; PEP 485 <4>: 類別関数.       (line   55)
* Python Enhancement Proposals; PEP 486: PEP 486 Python ランチャーが仮想環境を認識する.
                                                             (line    6)
* Python Enhancement Proposals; PEP 486 <1>: PEP 486 Python ランチャーが仮想環境を認識する.
                                                             (line   14)
* Python Enhancement Proposals; PEP 486 <2>: Windows<72>.    (line    6)
* Python Enhancement Proposals; PEP 487: PEP 487 Simpler customization of class creation.
                                                             (line   32)
* Python Enhancement Proposals; PEP 487 <1>: PEP 487 記述子プロトコルの改善.
                                                             (line    6)
* Python Enhancement Proposals; PEP 487 <2>: PEP 487 記述子プロトコルの改善.
                                                             (line   33)
* Python Enhancement Proposals; PEP 487 <3>: Python API の変更<6>.
                                                             (line  103)
* Python Enhancement Proposals; PEP 487 <4>: Documentation<55>.
                                                             (line   52)
* Python Enhancement Proposals; PEP 487 <5>: Documentation<62>.
                                                             (line    8)
* Python Enhancement Proposals; PEP 487 <6>: Core and Builtins<75>.
                                                             (line   46)
* Python Enhancement Proposals; PEP 488: PEP 488 PYO ファイルの廃止.
                                                             (line    6)
* Python Enhancement Proposals; PEP 488 <1>: PEP 488 PYO ファイルの廃止.
                                                             (line   20)
* Python Enhancement Proposals; PEP 488 <2>: Python API の変更<7>.
                                                             (line   85)
* Python Enhancement Proposals; PEP 488 <3>: Core and Builtins<93>.
                                                             (line   15)
* Python Enhancement Proposals; PEP 488 <4>: その他のオプション.
                                                             (line   80)
* Python Enhancement Proposals; PEP 488 <5>: その他のオプション.
                                                             (line   82)
* Python Enhancement Proposals; PEP 488 <6>: その他のオプション.
                                                             (line   89)
* Python Enhancement Proposals; PEP 488 <7>: その他のオプション.
                                                             (line   91)
* Python Enhancement Proposals; PEP 488 <8>: test support import_helper --- Utilities for import tests.
                                                             (line   82)
* Python Enhancement Proposals; PEP 488 <9>: はじめに<10>.   (line   77)
* Python Enhancement Proposals; PEP 488 <10>: importlib util -- インポータのためのユーティリティコード.
                                                             (line   25)
* Python Enhancement Proposals; PEP 488 <11>: importlib util -- インポータのためのユーティリティコード.
                                                             (line   64)
* Python Enhancement Proposals; PEP 488 <12>: py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   30)
* Python Enhancement Proposals; PEP 489: PEP 489 拡張モジュールの多段階初期化.
                                                             (line    6)
* Python Enhancement Proposals; PEP 489 <1>: PEP 489 拡張モジュールの多段階初期化.
                                                             (line   18)
* Python Enhancement Proposals; PEP 489 <2>: ビルドならびに C API の変更<3>.
                                                             (line   37)
* Python Enhancement Proposals; PEP 489 <3>: Library<8>.     (line  254)
* Python Enhancement Proposals; PEP 489 <4>: Library<18>.    (line   20)
* Python Enhancement Proposals; PEP 489 <5>: Library<34>.    (line   64)
* Python Enhancement Proposals; PEP 489 <6>: Library<34>.    (line   79)
* Python Enhancement Proposals; PEP 489 <7>: Core and Builtins<36>.
                                                             (line   70)
* Python Enhancement Proposals; PEP 489 <8>: Library<35>.    (line   68)
* Python Enhancement Proposals; PEP 489 <9>: Library<35>.    (line  177)
* Python Enhancement Proposals; PEP 489 <10>: Core and Builtins<37>.
                                                             (line   50)
* Python Enhancement Proposals; PEP 489 <11>: Library<36>.   (line  103)
* Python Enhancement Proposals; PEP 489 <12>: C API<35>.     (line   11)
* Python Enhancement Proposals; PEP 489 <13>: C API<35>.     (line   14)
* Python Enhancement Proposals; PEP 489 <14>: C API<35>.     (line   17)
* Python Enhancement Proposals; PEP 489 <15>: C API<35>.     (line   20)
* Python Enhancement Proposals; PEP 489 <16>: C API<35>.     (line   23)
* Python Enhancement Proposals; PEP 489 <17>: C API<35>.     (line   26)
* Python Enhancement Proposals; PEP 489 <18>: C API<35>.     (line   29)
* Python Enhancement Proposals; PEP 489 <19>: C API<35>.     (line   38)
* Python Enhancement Proposals; PEP 489 <20>: C API<35>.     (line   41)
* Python Enhancement Proposals; PEP 489 <21>: C API<35>.     (line   44)
* Python Enhancement Proposals; PEP 489 <22>: C API<35>.     (line   47)
* Python Enhancement Proposals; PEP 489 <23>: Library<37>.   (line   31)
* Python Enhancement Proposals; PEP 489 <24>: Core and Builtins<39>.
                                                             (line   20)
* Python Enhancement Proposals; PEP 489 <25>: Core and Builtins<39>.
                                                             (line   30)
* Python Enhancement Proposals; PEP 489 <26>: Core and Builtins<39>.
                                                             (line   33)
* Python Enhancement Proposals; PEP 489 <27>: Core and Builtins<39>.
                                                             (line   36)
* Python Enhancement Proposals; PEP 489 <28>: Core and Builtins<39>.
                                                             (line   39)
* Python Enhancement Proposals; PEP 489 <29>: Core and Builtins<39>.
                                                             (line   49)
* Python Enhancement Proposals; PEP 489 <30>: Core and Builtins<39>.
                                                             (line   52)
* Python Enhancement Proposals; PEP 489 <31>: Core and Builtins<39>.
                                                             (line   55)
* Python Enhancement Proposals; PEP 489 <32>: Core and Builtins<39>.
                                                             (line   74)
* Python Enhancement Proposals; PEP 489 <33>: Core and Builtins<39>.
                                                             (line   90)
* Python Enhancement Proposals; PEP 489 <34>: Core and Builtins<39>.
                                                             (line  102)
* Python Enhancement Proposals; PEP 489 <35>: Library<38>.   (line   75)
* Python Enhancement Proposals; PEP 489 <36>: Library<38>.   (line   78)
* Python Enhancement Proposals; PEP 489 <37>: Library<38>.   (line  423)
* Python Enhancement Proposals; PEP 489 <38>: Core and Builtins<40>.
                                                             (line   28)
* Python Enhancement Proposals; PEP 489 <39>: Core and Builtins<40>.
                                                             (line   35)
* Python Enhancement Proposals; PEP 489 <40>: Core and Builtins<40>.
                                                             (line   50)
* Python Enhancement Proposals; PEP 489 <41>: Core and Builtins<41>.
                                                             (line   46)
* Python Enhancement Proposals; PEP 489 <42>: Core and Builtins<41>.
                                                             (line   49)
* Python Enhancement Proposals; PEP 489 <43>: Core and Builtins<41>.
                                                             (line   51)
* Python Enhancement Proposals; PEP 489 <44>: Core and Builtins<41>.
                                                             (line   71)
* Python Enhancement Proposals; PEP 489 <45>: Core and Builtins<41>.
                                                             (line   75)
* Python Enhancement Proposals; PEP 489 <46>: Core and Builtins<42>.
                                                             (line   17)
* Python Enhancement Proposals; PEP 489 <47>: Core and Builtins<42>.
                                                             (line   20)
* Python Enhancement Proposals; PEP 489 <48>: Core and Builtins<42>.
                                                             (line   40)
* Python Enhancement Proposals; PEP 489 <49>: Core and Builtins<42>.
                                                             (line   54)
* Python Enhancement Proposals; PEP 489 <50>: Core and Builtins<42>.
                                                             (line  109)
* Python Enhancement Proposals; PEP 489 <51>: Core and Builtins<42>.
                                                             (line  118)
* Python Enhancement Proposals; PEP 489 <52>: Core and Builtins<43>.
                                                             (line   29)
* Python Enhancement Proposals; PEP 489 <53>: Core and Builtins<43>.
                                                             (line   32)
* Python Enhancement Proposals; PEP 489 <54>: Core and Builtins<43>.
                                                             (line   52)
* Python Enhancement Proposals; PEP 489 <55>: Core and Builtins<43>.
                                                             (line   55)
* Python Enhancement Proposals; PEP 489 <56>: Core and Builtins<43>.
                                                             (line   58)
* Python Enhancement Proposals; PEP 489 <57>: Core and Builtins<44>.
                                                             (line   62)
* Python Enhancement Proposals; PEP 489 <58>: はじめに<10>.  (line   81)
* Python Enhancement Proposals; PEP 489 <59>: importlib machinery -- インポータおよびパスフック.
                                                             (line   77)
* Python Enhancement Proposals; PEP 489 <60>: importlib machinery -- インポータおよびパスフック.
                                                             (line  294)
* Python Enhancement Proposals; PEP 489 <61>: importlib machinery -- インポータおよびパスフック.
                                                             (line  312)
* Python Enhancement Proposals; PEP 489 <62>: importlib machinery -- インポータおよびパスフック.
                                                             (line  319)
* Python Enhancement Proposals; PEP 489 <63>: importlib util -- インポータのためのユーティリティコード.
                                                             (line  187)
* Python Enhancement Proposals; PEP 489 <64>: モジュールのメソッドテーブルと初期化関数.
                                                             (line  140)
* Python Enhancement Proposals; PEP 489 <65>: C および C++ 拡張のビルド.
                                                             (line   41)
* Python Enhancement Proposals; PEP 489 <66>: 多段階初期化.  (line  168)
* Python Enhancement Proposals; PEP 489 <67>: サブインタプリタサポート.
                                                             (line   78)
* Python Enhancement Proposals; PEP 492: PEP 525 非同期ジェネレータ.
                                                             (line    6)
* Python Enhancement Proposals; PEP 492 <1>: 新たなキーワード.
                                                             (line    7)
* Python Enhancement Proposals; PEP 492 <2>: PEP 492 - コルーチン、 async と await 構文.
                                                             (line    6)
* Python Enhancement Proposals; PEP 492 <3>: PEP 492 - コルーチン、 async と await 構文.
                                                             (line   97)
* Python Enhancement Proposals; PEP 492 <4>: 新たなキーワード<2>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 492 <5>: C API の変更<10>.
                                                             (line   25)
* Python Enhancement Proposals; PEP 492 <6>: Core and Builtins<60>.
                                                             (line   98)
* Python Enhancement Proposals; PEP 492 <7>: Library<76>.    (line   51)
* Python Enhancement Proposals; PEP 492 <8>: Library<82>.    (line   16)
* Python Enhancement Proposals; PEP 492 <9>: Core and Builtins<90>.
                                                             (line   14)
* Python Enhancement Proposals; PEP 492 <10>: 待機可能オブジェクト Awaitable Object.
                                                             (line   34)
* Python Enhancement Proposals; PEP 492 <11>: Yield 式.      (line  100)
* Python Enhancement Proposals; PEP 492 <12>: async with 文. (line   44)
* Python Enhancement Proposals; PEP 492 <13>: コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  169)
* Python Enhancement Proposals; PEP 492 <14>: Code Objects Bit Flags.
                                                             (line   38)
* Python Enhancement Proposals; PEP 492 <15>: Code Objects Bit Flags.
                                                             (line   47)
* Python Enhancement Proposals; PEP 492 <16>: 用語集<2>.     (line   86)
* Python Enhancement Proposals; PEP 492 <17>: 用語集<2>.     (line  117)
* Python Enhancement Proposals; PEP 492 <18>: 用語集<2>.     (line  124)
* Python Enhancement Proposals; PEP 492 <19>: 用語集<2>.     (line  134)
* Python Enhancement Proposals; PEP 492 <20>: 用語集<2>.     (line  153)
* Python Enhancement Proposals; PEP 492 <21>: 用語集<2>.     (line  334)
* Python Enhancement Proposals; PEP 492 <22>: 用語集<2>.     (line  342)
* Python Enhancement Proposals; PEP 493: PEP 493 HTTPS verification migration tools for Python 2 7.
                                                             (line    6)
* Python Enhancement Proposals; PEP 494: What's New In Python 3 6.
                                                             (line   17)
* Python Enhancement Proposals; PEP 495: PEP 495 地域時間の曖昧さ回避.
                                                             (line   12)
* Python Enhancement Proposals; PEP 495 <1>: PEP 495 地域時間の曖昧さ回避.
                                                             (line   33)
* Python Enhancement Proposals; PEP 495 <2>: Library<74>.    (line   96)
* Python Enhancement Proposals; PEP 495 <3>: ZoneInfo を使用する.
                                                             (line   34)
* Python Enhancement Proposals; PEP 498: PEP 498 フォーマット済み文字列リテラル.
                                                             (line    6)
* Python Enhancement Proposals; PEP 498 <1>: PEP 498 フォーマット済み文字列リテラル.
                                                             (line   26)
* Python Enhancement Proposals; PEP 498 <2>: Core and Builtins<78>.
                                                             (line  283)
* Python Enhancement Proposals; PEP 498 <3>: f-strings.      (line  151)
* Python Enhancement Proposals; PEP 498 <4>: 用語集<2>.      (line  473)
* Python Enhancement Proposals; PEP 5:   PEP 230 警告フレームワーク.
                                                             (line   64)
* Python Enhancement Proposals; PEP 5 <1>: Python の互換性を無くすような提案をしてもいいのですか？.
                                                             (line   14)
* Python Enhancement Proposals; PEP 506: secrets.            (line   19)
* Python Enhancement Proposals; PEP 506 <1>: Library<77>.    (line   60)
* Python Enhancement Proposals; PEP 506 <2>: secrets --- 機密を扱うために安全な乱数を生成する.
                                                             (line   24)
* Python Enhancement Proposals; PEP 511: Python API の変更<6>.
                                                             (line   33)
* Python Enhancement Proposals; PEP 514: Windows py exe ランチャーの改善.
                                                             (line    7)
* Python Enhancement Proposals; PEP 514 <1>: Windows<21>.    (line   13)
* Python Enhancement Proposals; PEP 514 <2>: Windows<64>.    (line    8)
* Python Enhancement Proposals; PEP 514 <3>: コマンドラインから起動する.
                                                             (line   46)
* Python Enhancement Proposals; PEP 515: fractions<3>.       (line    6)
* Python Enhancement Proposals; PEP 515 <1>: PEP 515 数値リテラル内のアンダースコア.
                                                             (line    6)
* Python Enhancement Proposals; PEP 515 <2>: PEP 515 数値リテラル内のアンダースコア.
                                                             (line   31)
* Python Enhancement Proposals; PEP 515 <3>: Core and Builtins<74>.
                                                             (line   15)
* Python Enhancement Proposals; PEP 515 <4>: Core and Builtins<74>.
                                                             (line   43)
* Python Enhancement Proposals; PEP 515 <5>: 書式指定ミニ言語仕様.
                                                             (line  114)
* Python Enhancement Proposals; PEP 515 <6>: fractions --- 有理数.
                                                             (line   94)
* Python Enhancement Proposals; PEP 519: PEP 519 ファイルシステムパスプロトコルの追加.
                                                             (line   62)
* Python Enhancement Proposals; PEP 519 <1>: Library<74>.    (line    6)
* Python Enhancement Proposals; PEP 519 <2>: Core and Builtins<77>.
                                                             (line   19)
* Python Enhancement Proposals; PEP 519 <3>: Library<76>.    (line   31)
* Python Enhancement Proposals; PEP 519 <4>: Library<76>.    (line   42)
* Python Enhancement Proposals; PEP 519 <5>: Library<76>.    (line   44)
* Python Enhancement Proposals; PEP 519 <6>: C API<65>.      (line    6)
* Python Enhancement Proposals; PEP 519 <7>: 用語集<2>.      (line 1167)
* Python Enhancement Proposals; PEP 520: PEP 520 クラス属性の定義の順番を保持.
                                                             (line   17)
* Python Enhancement Proposals; PEP 523: New Features<4>.    (line   19)
* Python Enhancement Proposals; PEP 523 <1>: Porting to Python 3 11<2>.
                                                             (line   33)
* Python Enhancement Proposals; PEP 523 <2>: Python 3 9への移植<2>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 523 <3>: PEP 523 CPython にフレーム評価 API を追加.
                                                             (line   12)
* Python Enhancement Proposals; PEP 523 <4>: PEP 523 CPython にフレーム評価 API を追加.
                                                             (line   26)
* Python Enhancement Proposals; PEP 523 <5>: Core and Builtins<16>.
                                                             (line   26)
* Python Enhancement Proposals; PEP 523 <6>: Tools/Demos<30>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 523 <7>: Tools/Demos<34>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 523 <8>: Core and Builtins<74>.
                                                             (line   83)
* Python Enhancement Proposals; PEP 523 <9>: Internal Frames.
                                                             (line    6)
* Python Enhancement Proposals; PEP 523 <10>: 低レベルAPI.   (line  170)
* Python Enhancement Proposals; PEP 523 <11>: 低レベルAPI.   (line  179)
* Python Enhancement Proposals; PEP 524: 概要 -- リリースハイライト<6>.
                                                             (line   76)
* Python Enhancement Proposals; PEP 524 <1>: os<8>.          (line   20)
* Python Enhancement Proposals; PEP 524 <2>: os<8>.          (line   25)
* Python Enhancement Proposals; PEP 524 <3>: Library<73>.    (line  150)
* Python Enhancement Proposals; PEP 524 <4>: Library<73>.    (line  154)
* Python Enhancement Proposals; PEP 524 <5>: 乱数<2>.        (line   42)
* Python Enhancement Proposals; PEP 525: PEP 525 非同期ジェネレータ.
                                                             (line   22)
* Python Enhancement Proposals; PEP 525 <1>: Core and Builtins<74>.
                                                             (line   49)
* Python Enhancement Proposals; PEP 525 <2>: Yield 式.       (line   98)
* Python Enhancement Proposals; PEP 525 <3>: コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  169)
* Python Enhancement Proposals; PEP 525 <4>: sys --- システム固有のパラメーターと関数.
                                                             (line  994)
* Python Enhancement Proposals; PEP 525 <5>: sys --- システム固有のパラメーターと関数.
                                                             (line 1683)
* Python Enhancement Proposals; PEP 525 <6>: Code Objects Bit Flags.
                                                             (line   56)
* Python Enhancement Proposals; PEP 525 <7>: 用語集<2>.      (line  118)
* Python Enhancement Proposals; PEP 526: その他の言語変更<2>.
                                                             (line   56)
* Python Enhancement Proposals; PEP 526 <1>: ast<3>.         (line   17)
* Python Enhancement Proposals; PEP 526 <2>: PEP 563 アノテーションの遅延評価.
                                                             (line    6)
* Python Enhancement Proposals; PEP 526 <3>: PEP 526 変数アノテーションの文法.
                                                             (line   29)
* Python Enhancement Proposals; PEP 526 <4>: typing<9>.      (line   23)
* Python Enhancement Proposals; PEP 526 <5>: Core and Builtins<74>.
                                                             (line   51)
* Python Enhancement Proposals; PEP 526 <6>: 注釈付き代入文 annotated assignment statements.
                                                             (line   41)
* Python Enhancement Proposals; PEP 526 <7>: 関数定義.       (line  148)
* Python Enhancement Proposals; PEP 526 <8>: 特殊形式.       (line  163)
* Python Enhancement Proposals; PEP 526 <9>: Other special directives.
                                                             (line   70)
* Python Enhancement Proposals; PEP 526 <10>: dataclasses --- データクラス.
                                                             (line   15)
* Python Enhancement Proposals; PEP 526 <11>: クラス変数.    (line    8)
* Python Enhancement Proposals; PEP 526 <12>: ast ヘルパー.  (line   18)
* Python Enhancement Proposals; PEP 526 <13>: コンパイラフラグ.
                                                             (line   30)
* Python Enhancement Proposals; PEP 526 <14>: 用語集<2>.     (line   49)
* Python Enhancement Proposals; PEP 526 <15>: 用語集<2>.     (line 1485)
* Python Enhancement Proposals; PEP 528: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更.
                                                             (line   17)
* Python Enhancement Proposals; PEP 528 <1>: UTF-8 モード.   (line   33)
* Python Enhancement Proposals; PEP 528 <2>: グローバルな設定変数.
                                                             (line  174)
* Python Enhancement Proposals; PEP 528 <3>: PyConfig.       (line  541)
* Python Enhancement Proposals; PEP 529: Python API の変更<3>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 529 <1>: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更.
                                                             (line   22)
* Python Enhancement Proposals; PEP 529 <2>: Documentation<18>.
                                                             (line   29)
* Python Enhancement Proposals; PEP 529 <3>: Library<45>.    (line  619)
* Python Enhancement Proposals; PEP 529 <4>: Windows<59>.    (line   14)
* Python Enhancement Proposals; PEP 529 <5>: 環境変数.       (line  350)
* Python Enhancement Proposals; PEP 529 <6>: UTF-8 モード.   (line   36)
* Python Enhancement Proposals; PEP 529 <7>: ファイルとディレクトリ.
                                                             (line  312)
* Python Enhancement Proposals; PEP 529 <8>: sys --- システム固有のパラメーターと関数.
                                                             (line  780)
* Python Enhancement Proposals; PEP 529 <9>: sys --- システム固有のパラメーターと関数.
                                                             (line 1764)
* Python Enhancement Proposals; PEP 529 <10>: ファイルシステムエンコーディング.
                                                             (line    7)
* Python Enhancement Proposals; PEP 529 <11>: グローバルな設定変数.
                                                             (line  156)
* Python Enhancement Proposals; PEP 530: PEP 530 非同期内包表記.
                                                             (line    6)
* Python Enhancement Proposals; PEP 530 <1>: PEP 530 非同期内包表記.
                                                             (line   18)
* Python Enhancement Proposals; PEP 530 <2>: Core and Builtins<74>.
                                                             (line  145)
* Python Enhancement Proposals; PEP 530 <3>: リスト、集合、辞書の表示.
                                                             (line   52)
* Python Enhancement Proposals; PEP 538: PEP 538 レガシーな C ロケールの抑圧.
                                                             (line   11)
* Python Enhancement Proposals; PEP 538 <1>: PEP 538 レガシーな C ロケールの抑圧.
                                                             (line   35)
* Python Enhancement Proposals; PEP 538 <2>: PEP 538 レガシーな C ロケールの抑圧.
                                                             (line   46)
* Python Enhancement Proposals; PEP 538 <3>: PEP 540 強制 UTF-8 実行モード.
                                                             (line   27)
* Python Enhancement Proposals; PEP 538 <4>: Documentation<45>.
                                                             (line   68)
* Python Enhancement Proposals; PEP 538 <5>: Documentation<46>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 538 <6>: Core and Builtins<61>.
                                                             (line  134)
* Python Enhancement Proposals; PEP 538 <7>: 環境変数.       (line  419)
* Python Enhancement Proposals; PEP 538 <8>: 一般的なオプション.
                                                             (line   89)
* Python Enhancement Proposals; PEP 538 <9>: locale --- 国際化サービス.
                                                             (line  494)
* Python Enhancement Proposals; PEP 538 <10>: Python Configuration.
                                                             (line   13)
* Python Enhancement Proposals; PEP 539: PEP 539 スレッドローカルストレージのための新しい C API.
                                                             (line   12)
* Python Enhancement Proposals; PEP 539 <1>: PEP 539 スレッドローカルストレージのための新しい C API.
                                                             (line   30)
* Python Enhancement Proposals; PEP 539 <2>: C API<54>.      (line   13)
* Python Enhancement Proposals; PEP 539 <3>: スレッド固有ストレージ Thread Specific Storage TSS API.
                                                             (line   15)
* Python Enhancement Proposals; PEP 540: PEP 540 強制 UTF-8 実行モード.
                                                             (line   18)
* Python Enhancement Proposals; PEP 540 <1>: PEP 540 強制 UTF-8 実行モード.
                                                             (line   35)
* Python Enhancement Proposals; PEP 540 <2>: Core and Builtins<58>.
                                                             (line   63)
* Python Enhancement Proposals; PEP 540 <3>: Python UTF-8 Mode.
                                                             (line    6)
* Python Enhancement Proposals; PEP 540 <4>: locale --- 国際化サービス.
                                                             (line  494)
* Python Enhancement Proposals; PEP 540 <5>: Python Configuration.
                                                             (line   14)
* Python Enhancement Proposals; PEP 544: typing<8>.          (line   32)
* Python Enhancement Proposals; PEP 544 <1>: 名前的部分型 vs 構造的部分型.
                                                             (line   24)
* Python Enhancement Proposals; PEP 544 <2>: Other special directives.
                                                             (line  152)
* Python Enhancement Proposals; PEP 545: PEP 545 Python Documentation Translations.
                                                             (line    6)
* Python Enhancement Proposals; PEP 545 <1>: PEP 545 Python Documentation Translations.
                                                             (line   20)
* Python Enhancement Proposals; PEP 552: その他の CPython の実装の変更.
                                                             (line   16)
* Python Enhancement Proposals; PEP 552 <1>: PEP 552 Hash-based pyc Files.
                                                             (line   15)
* Python Enhancement Proposals; PEP 552 <2>: PEP 552 Hash-based pyc Files.
                                                             (line   36)
* Python Enhancement Proposals; PEP 552 <3>: Library<50>.    (line  794)
* Python Enhancement Proposals; PEP 552 <4>: Core and Builtins<58>.
                                                             (line   75)
* Python Enhancement Proposals; PEP 552 <5>: はじめに<10>.   (line   85)
* Python Enhancement Proposals; PEP 552 <6>: py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   83)
* Python Enhancement Proposals; PEP 552 <7>: PyConfig.       (line  274)
* Python Enhancement Proposals; PEP 553: PEP 553 組み込みの breakpoint.
                                                             (line   20)
* Python Enhancement Proposals; PEP 553 <1>: Core and Builtins<60>.
                                                             (line   72)
* Python Enhancement Proposals; PEP 554: PEP 684 A Per-Interpreter GIL.
                                                             (line   10)
* Python Enhancement Proposals; PEP 554 <1>: A Per-Interpreter GIL.
                                                             (line   13)
* Python Enhancement Proposals; PEP 557: データクラス<3>.    (line   26)
* Python Enhancement Proposals; PEP 557 <1>: dataclasses --- データクラス.
                                                             (line   12)
* Python Enhancement Proposals; PEP 560: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート.
                                                             (line   19)
* Python Enhancement Proposals; PEP 560 <1>: types<4>.       (line   12)
* Python Enhancement Proposals; PEP 560 <2>: Core and Builtins<58>.
                                                             (line   66)
* Python Enhancement Proposals; PEP 560 <3>: MRO エントリの解決.
                                                             (line   30)
* Python Enhancement Proposals; PEP 560 <4>: __class_getitem__ versus __getitem__.
                                                             (line   85)
* Python Enhancement Proposals; PEP 560 <5>: 動的な型生成.   (line   54)
* Python Enhancement Proposals; PEP 560 <6>: 動的な型生成.   (line   70)
* Python Enhancement Proposals; PEP 560 <7>: 動的な型生成.   (line  108)
* Python Enhancement Proposals; PEP 562: PEP 562 モジュール属性へのアクセスのカスタマイズ.
                                                             (line   16)
* Python Enhancement Proposals; PEP 562 <1>: Library<57>.    (line   63)
* Python Enhancement Proposals; PEP 562 <2>: Core and Builtins<58>.
                                                             (line   69)
* Python Enhancement Proposals; PEP 562 <3>: モジュールの属性値アクセスをカスタマイズする.
                                                             (line   52)
* Python Enhancement Proposals; PEP 563: PEP 563 may not be the future.
                                                             (line    6)
* Python Enhancement Proposals; PEP 563 <1>: PEP 563 アノテーションの遅延評価.
                                                             (line   49)
* Python Enhancement Proposals; PEP 563 <2>: Library<31>.    (line  300)
* Python Enhancement Proposals; PEP 563 <3>: Core and Builtins<38>.
                                                             (line   83)
* Python Enhancement Proposals; PEP 563 <4>: future 文 future statement.
                                                             (line   31)
* Python Enhancement Proposals; PEP 563 <5>: 関数定義.       (line  153)
* Python Enhancement Proposals; PEP 563 <6>: 定数<10>.       (line   29)
* Python Enhancement Proposals; PEP 563 <7>: モジュールコンテンツ<5>.
                                                             (line  122)
* Python Enhancement Proposals; PEP 563 <8>: モジュールコンテンツ<5>.
                                                             (line   40)
* Python Enhancement Proposals; PEP 564: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数.
                                                             (line    8)
* Python Enhancement Proposals; PEP 564 <1>: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数.
                                                             (line   33)
* Python Enhancement Proposals; PEP 564 <2>: time<5>.        (line    6)
* Python Enhancement Proposals; PEP 564 <3>: Library<59>.    (line  299)
* Python Enhancement Proposals; PEP 565: PEP 565 Show DeprecationWarning in __main__.
                                                             (line   41)
* Python Enhancement Proposals; PEP 565 <1>: 警告.           (line   22)
* Python Enhancement Proposals; PEP 566: 配布物メタデータ.   (line   34)
* Python Enhancement Proposals; PEP 567: contextvars.        (line   20)
* Python Enhancement Proposals; PEP 567 <1>: asyncio<7>.     (line   19)
* Python Enhancement Proposals; PEP 567 <2>: Documentation<45>.
                                                             (line   86)
* Python Enhancement Proposals; PEP 567 <3>: Documentation<47>.
                                                             (line    9)
* Python Enhancement Proposals; PEP 567 <4>: Core and Builtins<57>.
                                                             (line   63)
* Python Enhancement Proposals; PEP 567 <5>: contextvars --- コンテキスト変数.
                                                             (line   18)
* Python Enhancement Proposals; PEP 567 <6>: コールバックのスケジューリング.
                                                             (line   40)
* Python Enhancement Proposals; PEP 567 <7>: 遅延コールバックのスケジューリング.
                                                             (line   32)
* Python Enhancement Proposals; PEP 567 <8>: 遅延コールバックのスケジューリング.
                                                             (line   52)
* Python Enhancement Proposals; PEP 567 <9>: Future オブジェクト<2>.
                                                             (line  109)
* Python Enhancement Proposals; PEP 570: 位置専用引数.       (line   68)
* Python Enhancement Proposals; PEP 570 <1>: Python API の変更<3>.
                                                             (line  160)
* Python Enhancement Proposals; PEP 570 <2>: Core and Builtins<48>.
                                                             (line   36)
* Python Enhancement Proposals; PEP 570 <3>: 関数定義.       (line  102)
* Python Enhancement Proposals; PEP 572: Other Language Changes<2>.
                                                             (line   31)
* Python Enhancement Proposals; PEP 572 <1>: 代入式.         (line   39)
* Python Enhancement Proposals; PEP 572 <2>: CPython バイトコードの変更<4>.
                                                             (line   27)
* Python Enhancement Proposals; PEP 572 <3>: Core and Builtins<20>.
                                                             (line   40)
* Python Enhancement Proposals; PEP 572 <4>: Documentation<36>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 572 <5>: Core and Builtins<46>.
                                                             (line  184)
* Python Enhancement Proposals; PEP 572 <6>: Core and Builtins<51>.
                                                             (line   92)
* Python Enhancement Proposals; PEP 572 <7>: 辞書表示.       (line   43)
* Python Enhancement Proposals; PEP 572 <8>: 代入式<2>.      (line   29)
* Python Enhancement Proposals; PEP 572 <9>: キャプチャパターン.
                                                             (line   18)
* Python Enhancement Proposals; PEP 572 <10>: 式中で代入ができないのはなぜですか？.
                                                             (line   13)
* Python Enhancement Proposals; PEP 573: 概要 -- リリースハイライト<3>.
                                                             (line   29)
* Python Enhancement Proposals; PEP 573 <1>: 新しい機能<6>.  (line    6)
* Python Enhancement Proposals; PEP 573 <2>: Core and Builtins<40>.
                                                             (line   19)
* Python Enhancement Proposals; PEP 573 <3>: C API<38>.      (line   57)
* Python Enhancement Proposals; PEP 574: Pickle プロトコルバージョン 5 による帯域外データバッファ.
                                                             (line   14)
* Python Enhancement Proposals; PEP 574 <1>: データストリームの形式.
                                                             (line   50)
* Python Enhancement Proposals; PEP 574 <2>: 使用例<10>.     (line   65)
* Python Enhancement Proposals; PEP 578: PEP 578 Pythonランタイムの監査フック.
                                                             (line   12)
* Python Enhancement Proposals; PEP 578 <1>: 監査イベント表. (line    9)
* Python Enhancement Proposals; PEP 578 <2>: sys --- システム固有のパラメーターと関数.
                                                             (line   56)
* Python Enhancement Proposals; PEP 578 <3>: システム関数.   (line  137)
* Python Enhancement Proposals; PEP 584: 概要 -- リリースハイライト<3>.
                                                             (line    8)
* Python Enhancement Proposals; PEP 584 <1>: 辞書のマージと更新演算子.
                                                             (line   19)
* Python Enhancement Proposals; PEP 584 <2>: Library<40>.    (line  192)
* Python Enhancement Proposals; PEP 584 <3>: Library<40>.    (line  195)
* Python Enhancement Proposals; PEP 584 <4>: Library<40>.    (line  209)
* Python Enhancement Proposals; PEP 584 <5>: Library<41>.    (line   49)
* Python Enhancement Proposals; PEP 584 <6>: Library<41>.    (line   62)
* Python Enhancement Proposals; PEP 584 <7>: Library<41>.    (line  120)
* Python Enhancement Proposals; PEP 584 <8>: Library<41>.    (line  142)
* Python Enhancement Proposals; PEP 584 <9>: ChainMap オブジェクト.
                                                             (line   88)
* Python Enhancement Proposals; PEP 584 <10>: defaultdict オブジェクト.
                                                             (line   54)
* Python Enhancement Proposals; PEP 584 <11>: OrderedDict オブジェクト.
                                                             (line  106)
* Python Enhancement Proposals; PEP 584 <12>: weakref --- 弱参照.
                                                             (line  191)
* Python Enhancement Proposals; PEP 584 <13>: weakref --- 弱参照.
                                                             (line  210)
* Python Enhancement Proposals; PEP 584 <14>: 標準的なインタプリタ型.
                                                             (line  232)
* Python Enhancement Proposals; PEP 584 <15>: プロセスのパラメーター.
                                                             (line   54)
* Python Enhancement Proposals; PEP 584 <16>: プロセスのパラメーター.
                                                             (line   70)
* Python Enhancement Proposals; PEP 585: 概要 -- リリースハイライト<3>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 585 <1>: 標準コレクション型の型ヒントにおける総称型 generics の使用.
                                                             (line   17)
* Python Enhancement Proposals; PEP 585 <2>: Library<19>.    (line  158)
* Python Enhancement Proposals; PEP 585 <3>: Library<28>.    (line  123)
* Python Enhancement Proposals; PEP 585 <4>: Documentation<24>.
                                                             (line   31)
* Python Enhancement Proposals; PEP 585 <5>: GenericAlias オブジェクトの特別な属性.
                                                             (line   55)
* Python Enhancement Proposals; PEP 585 <6>: collections abc --- コンテナの抽象基底クラス.
                                                             (line   87)
* Python Enhancement Proposals; PEP 585 <7>: 標準的なインタプリタ型.
                                                             (line  175)
* Python Enhancement Proposals; PEP 585 <8>: Introspection helpers.
                                                             (line  157)
* Python Enhancement Proposals; PEP 585 <9>: 非推奨のエイリアス.
                                                             (line   10)
* Python Enhancement Proposals; PEP 585 <10>: Aliases to built-in types.
                                                             (line   15)
* Python Enhancement Proposals; PEP 585 <11>: Aliases to built-in types.
                                                             (line   27)
* Python Enhancement Proposals; PEP 585 <12>: Aliases to built-in types.
                                                             (line   39)
* Python Enhancement Proposals; PEP 585 <13>: Aliases to built-in types.
                                                             (line   47)
* Python Enhancement Proposals; PEP 585 <14>: Aliases to built-in types.
                                                             (line   58)
* Python Enhancement Proposals; PEP 585 <15>: Aliases to built-in types.
                                                             (line   71)
* Python Enhancement Proposals; PEP 585 <16>: Aliases to types in collections.
                                                             (line   14)
* Python Enhancement Proposals; PEP 585 <17>: Aliases to types in collections.
                                                             (line   25)
* Python Enhancement Proposals; PEP 585 <18>: Aliases to types in collections.
                                                             (line   36)
* Python Enhancement Proposals; PEP 585 <19>: Aliases to types in collections.
                                                             (line   46)
* Python Enhancement Proposals; PEP 585 <20>: Aliases to types in collections.
                                                             (line   56)
* Python Enhancement Proposals; PEP 585 <21>: Aliases to other concrete types.
                                                             (line   18)
* Python Enhancement Proposals; PEP 585 <22>: Aliases to container ABCs in collections abc.
                                                             (line   11)
* Python Enhancement Proposals; PEP 585 <23>: Aliases to container ABCs in collections abc.
                                                             (line   30)
* Python Enhancement Proposals; PEP 585 <24>: Aliases to container ABCs in collections abc.
                                                             (line   38)
* Python Enhancement Proposals; PEP 585 <25>: Aliases to container ABCs in collections abc.
                                                             (line   47)
* Python Enhancement Proposals; PEP 585 <26>: Aliases to container ABCs in collections abc.
                                                             (line   55)
* Python Enhancement Proposals; PEP 585 <27>: Aliases to container ABCs in collections abc.
                                                             (line   63)
* Python Enhancement Proposals; PEP 585 <28>: Aliases to container ABCs in collections abc.
                                                             (line   71)
* Python Enhancement Proposals; PEP 585 <29>: Aliases to container ABCs in collections abc.
                                                             (line   79)
* Python Enhancement Proposals; PEP 585 <30>: Aliases to container ABCs in collections abc.
                                                             (line   87)
* Python Enhancement Proposals; PEP 585 <31>: Aliases to container ABCs in collections abc.
                                                             (line   95)
* Python Enhancement Proposals; PEP 585 <32>: Aliases to container ABCs in collections abc.
                                                             (line  103)
* Python Enhancement Proposals; PEP 585 <33>: Aliases to container ABCs in collections abc.
                                                             (line  111)
* Python Enhancement Proposals; PEP 585 <34>: Aliases to asynchronous ABCs in collections abc.
                                                             (line   18)
* Python Enhancement Proposals; PEP 585 <35>: Aliases to asynchronous ABCs in collections abc.
                                                             (line   33)
* Python Enhancement Proposals; PEP 585 <36>: Aliases to asynchronous ABCs in collections abc.
                                                             (line   45)
* Python Enhancement Proposals; PEP 585 <37>: Aliases to asynchronous ABCs in collections abc.
                                                             (line   55)
* Python Enhancement Proposals; PEP 585 <38>: Aliases to asynchronous ABCs in collections abc.
                                                             (line   65)
* Python Enhancement Proposals; PEP 585 <39>: Aliases to other ABCs in collections abc.
                                                             (line   11)
* Python Enhancement Proposals; PEP 585 <40>: Aliases to other ABCs in collections abc.
                                                             (line   19)
* Python Enhancement Proposals; PEP 585 <41>: Aliases to other ABCs in collections abc.
                                                             (line   31)
* Python Enhancement Proposals; PEP 585 <42>: Aliases to other ABCs in collections abc.
                                                             (line   48)
* Python Enhancement Proposals; PEP 585 <43>: Aliases to other ABCs in collections abc.
                                                             (line   66)
* Python Enhancement Proposals; PEP 585 <44>: Aliases to contextlib ABCs.
                                                             (line   19)
* Python Enhancement Proposals; PEP 585 <45>: Aliases to contextlib ABCs.
                                                             (line   39)
* Python Enhancement Proposals; PEP 585 <46>: メジャーな機能の非推奨時系列.
                                                             (line   15)
* Python Enhancement Proposals; PEP 585 <47>: 用語集<2>.     (line  648)
* Python Enhancement Proposals; PEP 586: typing<5>.          (line    8)
* Python Enhancement Proposals; PEP 586 <1>: typing<7>.      (line    6)
* Python Enhancement Proposals; PEP 586 <2>: typing<8>.      (line   18)
* Python Enhancement Proposals; PEP 586 <3>: 特殊形式.       (line  148)
* Python Enhancement Proposals; PEP 587: Removed C APIs.     (line  104)
* Python Enhancement Proposals; PEP 587 <1>: 非推奨<2>.      (line   34)
* Python Enhancement Proposals; PEP 587 <2>: PEP 587 Python 初期化設定.
                                                             (line    6)
* Python Enhancement Proposals; PEP 587 <3>: PEP 587 Python 初期化設定.
                                                             (line   80)
* Python Enhancement Proposals; PEP 587 <4>: C API<29>.      (line  124)
* Python Enhancement Proposals; PEP 587 <5>: Core and Builtins<46>.
                                                             (line   76)
* Python Enhancement Proposals; PEP 587 <6>: C API<45>.      (line    6)
* Python Enhancement Proposals; PEP 587 <7>: Python 初期化設定.
                                                             (line   33)
* Python Enhancement Proposals; PEP 589: typing<8>.          (line    8)
* Python Enhancement Proposals; PEP 589 <1>: Other special directives.
                                                             (line  451)
* Python Enhancement Proposals; PEP 590: Removed C APIs.     (line  135)
* Python Enhancement Proposals; PEP 590 <1>: Porting to Python 3 11<2>.
                                                             (line   98)
* Python Enhancement Proposals; PEP 590 <2>: 最適化<2>.      (line   55)
* Python Enhancement Proposals; PEP 590 <3>: 概要 -- リリースハイライト<3>.
                                                             (line   36)
* Python Enhancement Proposals; PEP 590 <4>: 最適化<3>.      (line   37)
* Python Enhancement Proposals; PEP 590 <5>: PEP 590 Vectorcall a fast calling protocol for CPython.
                                                             (line   14)
* Python Enhancement Proposals; PEP 590 <6>: Core and Builtins<9>.
                                                             (line  170)
* Python Enhancement Proposals; PEP 590 <7>: Library<14>.    (line 1079)
* Python Enhancement Proposals; PEP 590 <8>: C API<14>.      (line  146)
* Python Enhancement Proposals; PEP 590 <9>: Core and Builtins<22>.
                                                             (line  113)
* Python Enhancement Proposals; PEP 590 <10>: Library<24>.   (line   69)
* Python Enhancement Proposals; PEP 590 <11>: Core and Builtins<27>.
                                                             (line   57)
* Python Enhancement Proposals; PEP 590 <12>: Core and Builtins<30>.
                                                             (line  118)
* Python Enhancement Proposals; PEP 590 <13>: Core and Builtins<31>.
                                                             (line  348)
* Python Enhancement Proposals; PEP 590 <14>: Core and Builtins<33>.
                                                             (line   27)
* Python Enhancement Proposals; PEP 590 <15>: Core and Builtins<33>.
                                                             (line   74)
* Python Enhancement Proposals; PEP 590 <16>: Core and Builtins<39>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 590 <17>: Core and Builtins<39>.
                                                             (line   16)
* Python Enhancement Proposals; PEP 590 <18>: Core and Builtins<41>.
                                                             (line   39)
* Python Enhancement Proposals; PEP 590 <19>: Core and Builtins<41>.
                                                             (line   91)
* Python Enhancement Proposals; PEP 590 <20>: Core and Builtins<42>.
                                                             (line   42)
* Python Enhancement Proposals; PEP 590 <21>: Core and Builtins<42>.
                                                             (line   50)
* Python Enhancement Proposals; PEP 590 <22>: Core and Builtins<42>.
                                                             (line   67)
* Python Enhancement Proposals; PEP 590 <23>: C API<45>.     (line   17)
* Python Enhancement Proposals; PEP 590 <24>: The Vectorcall Protocol.
                                                             (line    8)
* Python Enhancement Proposals; PEP 591: typing<8>.          (line   25)
* Python Enhancement Proposals; PEP 591 <1>: 特殊形式.       (line  208)
* Python Enhancement Proposals; PEP 591 <2>: Functions and decorators.
                                                             (line  333)
* Python Enhancement Proposals; PEP 593: 概要 -- リリースハイライト<3>.
                                                             (line   21)
* Python Enhancement Proposals; PEP 593 <1>: typing<6>.      (line    6)
* Python Enhancement Proposals; PEP 593 <2>: Library<42>.    (line   91)
* Python Enhancement Proposals; PEP 593 <3>: 特殊形式.       (line  402)
* Python Enhancement Proposals; PEP 593 <4>: Introspection helpers.
                                                             (line   50)
* Python Enhancement Proposals; PEP 594: Summary -- Release Highlights.
                                                             (line   21)
* Python Enhancement Proposals; PEP 594 <1>: PEP 594 Remove "dead batteries" from the standard library.
                                                             (line    6)
* Python Enhancement Proposals; PEP 594 <2>: Pending Removal in Python 3 13.
                                                             (line    6)
* Python Enhancement Proposals; PEP 594 <3>: asynchat and asyncore.
                                                             (line    6)
* Python Enhancement Proposals; PEP 594 <4>: smtpd.          (line    6)
* Python Enhancement Proposals; PEP 594 <5>: 概要 -- リリースハイライト.
                                                             (line   46)
* Python Enhancement Proposals; PEP 594 <6>: モジュール.     (line    6)
* Python Enhancement Proposals; PEP 594 <7>: Library<14>.    (line  845)
* Python Enhancement Proposals; PEP 594 <8>: Library<14>.    (line  848)
* Python Enhancement Proposals; PEP 594 <9>: Library<14>.    (line  851)
* Python Enhancement Proposals; PEP 594 <10>: Library<14>.   (line  859)
* Python Enhancement Proposals; PEP 594 <11>: Library<14>.   (line  863)
* Python Enhancement Proposals; PEP 594 <12>: Library<14>.   (line  869)
* Python Enhancement Proposals; PEP 594 <13>: Library<14>.   (line  872)
* Python Enhancement Proposals; PEP 594 <14>: Library<14>.   (line  887)
* Python Enhancement Proposals; PEP 594 <15>: Library<14>.   (line  890)
* Python Enhancement Proposals; PEP 594 <16>: Library<14>.   (line  897)
* Python Enhancement Proposals; PEP 594 <17>: Library<14>.   (line  900)
* Python Enhancement Proposals; PEP 594 <18>: Library<14>.   (line  903)
* Python Enhancement Proposals; PEP 594 <19>: Library<14>.   (line  906)
* Python Enhancement Proposals; PEP 594 <20>: Library<14>.   (line  909)
* Python Enhancement Proposals; PEP 594 <21>: Library<14>.   (line  964)
* Python Enhancement Proposals; PEP 594 <22>: Library<14>.   (line  967)
* Python Enhancement Proposals; PEP 594 <23>: Library<14>.   (line  970)
* Python Enhancement Proposals; PEP 594 <24>: Library<14>.   (line  973)
* Python Enhancement Proposals; PEP 594 <25>: Library<21>.   (line  102)
* Python Enhancement Proposals; PEP 594 <26>: Library<22>.   (line  684)
* Python Enhancement Proposals; PEP 594 <27>: Library<23>.   (line   94)
* Python Enhancement Proposals; PEP 594 <28>: Library<24>.   (line  124)
* Python Enhancement Proposals; PEP 594 <29>: Library<24>.   (line  150)
* Python Enhancement Proposals; PEP 594 <30>: Tests<22>.     (line   25)
* Python Enhancement Proposals; PEP 596: What's New In Python 3 9.
                                                             (line   16)
* Python Enhancement Proposals; PEP 597: 概要 -- リリースハイライト<2>.
                                                             (line   45)
* Python Enhancement Proposals; PEP 597 <1>: Library<32>.    (line   44)
* Python Enhancement Proposals; PEP 597 <2>: Opt-in EncodingWarning.
                                                             (line    6)
* Python Enhancement Proposals; PEP 602: Summary -- Release Highlights.
                                                             (line  164)
* Python Enhancement Proposals; PEP 602 <1>: 概要 -- リリースハイライト<3>.
                                                             (line   61)
* Python Enhancement Proposals; PEP 602 <2>: Python はどれくらい安定していますか？.
                                                             (line    9)
* Python Enhancement Proposals; PEP 604: 概要 -- リリースハイライト<2>.
                                                             (line   26)
* Python Enhancement Proposals; PEP 604 <1>: PEP 604 New Type Union Operator.
                                                             (line   28)
* Python Enhancement Proposals; PEP 604 <2>: Library<35>.    (line   25)
* Python Enhancement Proposals; PEP 604 <3>: Documentation<33>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 604 <4>: Union 型.       (line  104)
* Python Enhancement Proposals; PEP 604 <5>: Manually Un-Stringizing Stringized Annotations.
                                                             (line   42)
* Python Enhancement Proposals; PEP 610: Distributions.      (line   49)
* Python Enhancement Proposals; PEP 612: 概要 -- リリースハイライト<2>.
                                                             (line   28)
* Python Enhancement Proposals; PEP 612 <1>: PEP 612 Parameter Specification Variables.
                                                             (line   25)
* Python Enhancement Proposals; PEP 612 <2>: Library<30>.    (line  691)
* Python Enhancement Proposals; PEP 612 <3>: Library<31>.    (line   95)
* Python Enhancement Proposals; PEP 612 <4>: Core and Builtins<36>.
                                                             (line   59)
* Python Enhancement Proposals; PEP 612 <5>: Library<35>.    (line   25)
* Python Enhancement Proposals; PEP 612 <6>: Library<35>.    (line  119)
* Python Enhancement Proposals; PEP 612 <7>: 呼び出し可能オブジェクトのアノテーション.
                                                             (line   77)
* Python Enhancement Proposals; PEP 612 <8>: ユーザー定義のジェネリック型.
                                                             (line  179)
* Python Enhancement Proposals; PEP 612 <9>: 特殊形式.       (line  119)
* Python Enhancement Proposals; PEP 612 <10>: Building generic types and type aliases.
                                                             (line  464)
* Python Enhancement Proposals; PEP 612 <11>: Aliases to other ABCs in collections abc.
                                                             (line   35)
* Python Enhancement Proposals; PEP 613: 概要 -- リリースハイライト<2>.
                                                             (line   30)
* Python Enhancement Proposals; PEP 613 <1>: PEP 613 TypeAlias.
                                                             (line   21)
* Python Enhancement Proposals; PEP 613 <2>: Library<37>.    (line   98)
* Python Enhancement Proposals; PEP 613 <3>: 特殊型.         (line  228)
* Python Enhancement Proposals; PEP 614: 概要 -- リリースハイライト<3>.
                                                             (line   13)
* Python Enhancement Proposals; PEP 614 <1>: その他の言語変更<3>.
                                                             (line   38)
* Python Enhancement Proposals; PEP 614 <2>: Core and Builtins<42>.
                                                             (line  112)
* Python Enhancement Proposals; PEP 614 <3>: 関数定義.       (line   54)
* Python Enhancement Proposals; PEP 614 <4>: クラス定義.     (line   61)
* Python Enhancement Proposals; PEP 615: 概要 -- リリースハイライト<3>.
                                                             (line   53)
* Python Enhancement Proposals; PEP 615 <1>: zoneinfo.       (line   37)
* Python Enhancement Proposals; PEP 615 <2>: Library<39>.    (line   54)
* Python Enhancement Proposals; PEP 615 <3>: zoneinfo --- IANA タイムゾーンのサポート.
                                                             (line   12)
* Python Enhancement Proposals; PEP 616: 概要 -- リリースハイライト<3>.
                                                             (line   17)
* Python Enhancement Proposals; PEP 616 <1>: prefixとsuffixを削除する新しい文字列メソッド.
                                                             (line    9)
* Python Enhancement Proposals; PEP 616 <2>: Core and Builtins<41>.
                                                             (line   82)
* Python Enhancement Proposals; PEP 617: PEP 701 Syntactic formalization of f-strings.
                                                             (line   69)
* Python Enhancement Proposals; PEP 617 <1>: モジュール.     (line   30)
* Python Enhancement Proposals; PEP 617 <2>: カッコ内のコンテキストマネージャー.
                                                             (line   45)
* Python Enhancement Proposals; PEP 617 <3>: 概要 -- リリースハイライト<3>.
                                                             (line   32)
* Python Enhancement Proposals; PEP 617 <4>: 新しいパーサー. (line   20)
* Python Enhancement Proposals; PEP 617 <5>: 非推奨<5>.      (line   95)
* Python Enhancement Proposals; PEP 617 <6>: Library<30>.    (line  178)
* Python Enhancement Proposals; PEP 617 <7>: Library<40>.    (line   34)
* Python Enhancement Proposals; PEP 617 <8>: 完全な文法仕様. (line   17)
* Python Enhancement Proposals; PEP 618: 概要 -- リリースハイライト<2>.
                                                             (line   18)
* Python Enhancement Proposals; PEP 618 <1>: その他の言語変更<2>.
                                                             (line   17)
* Python Enhancement Proposals; PEP 618 <2>: Core and Builtins<39>.
                                                             (line  209)
* Python Enhancement Proposals; PEP 623: Summary -- Release highlights.
                                                             (line  107)
* Python Enhancement Proposals; PEP 623 <1>: Optimizations<2>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 623 <2>: Removed<2>.     (line   11)
* Python Enhancement Proposals; PEP 623 <3>: 概要 -- リリースハイライト<2>.
                                                             (line   40)
* Python Enhancement Proposals; PEP 623 <4>: C API<22>.      (line   21)
* Python Enhancement Proposals; PEP 623 <5>: Core and Builtins<34>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 623 <6>: Documentation<28>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 623 <7>: Unicode オブジェクト.
                                                             (line   16)
* Python Enhancement Proposals; PEP 624: 概要 -- リリースハイライト.
                                                             (line   50)
* Python Enhancement Proposals; PEP 624 <1>: 削除<2>.        (line   97)
* Python Enhancement Proposals; PEP 624 <2>: 概要 -- リリースハイライト<2>.
                                                             (line   43)
* Python Enhancement Proposals; PEP 624 <3>: C API<29>.      (line  142)
* Python Enhancement Proposals; PEP 624#alternative-apis: 削除<2>.
                                                             (line   97)
* Python Enhancement Proposals; PEP 626: Pending Removal in Python 3 15.
                                                             (line   67)
* Python Enhancement Proposals; PEP 626 <1>: Deprecated.     (line  215)
* Python Enhancement Proposals; PEP 626 <2>: Pending Removal in Python 3 15<3>.
                                                             (line   67)
* Python Enhancement Proposals; PEP 626 <3>: 概要 -- リリースハイライト<2>.
                                                             (line   22)
* Python Enhancement Proposals; PEP 626 <4>: Core and Builtins<23>.
                                                             (line  422)
* Python Enhancement Proposals; PEP 626 <5>: Methods on code objects.
                                                             (line   81)
* Python Enhancement Proposals; PEP 626 <6>: 解析関数.       (line  171)
* Python Enhancement Proposals; PEP 626 <7>: Pending Removal in Python 3 15<5>.
                                                             (line   67)
* Python Enhancement Proposals; PEP 628: cmath.              (line    7)
* Python Enhancement Proposals; PEP 628 <1>: math<7>.        (line    7)
* Python Enhancement Proposals; PEP 628 <2>: Library<74>.    (line   32)
* Python Enhancement Proposals; PEP 632: Summary -- Release highlights.
                                                             (line  111)
* Python Enhancement Proposals; PEP 632 <1>: distutils.      (line    7)
* Python Enhancement Proposals; PEP 632 <2>: 概要 -- リリースハイライト<2>.
                                                             (line   38)
* Python Enhancement Proposals; PEP 632 <3>: distutils<2>.   (line   14)
* Python Enhancement Proposals; PEP 632 <4>: Library<21>.    (line   38)
* Python Enhancement Proposals; PEP 634: 概要 -- リリースハイライト<2>.
                                                             (line    8)
* Python Enhancement Proposals; PEP 634 <1>: Other Key Features.
                                                             (line   53)
* Python Enhancement Proposals; PEP 634 <2>: Core and Builtins<24>.
                                                             (line   55)
* Python Enhancement Proposals; PEP 634 <3>: Core and Builtins<32>.
                                                             (line   54)
* Python Enhancement Proposals; PEP 634 <4>: Core and Builtins<34>.
                                                             (line   57)
* Python Enhancement Proposals; PEP 634 <5>: クラスパターンマッチの位置引数のカスタマイズ.
                                                             (line   30)
* Python Enhancement Proposals; PEP 634 <6>: match 文<2>.    (line   32)
* Python Enhancement Proposals; PEP 634 <7>: クラスパターン. (line  135)
* Python Enhancement Proposals; PEP 634 <8>: PyTypeObject スロット.
                                                             (line  791)
* Python Enhancement Proposals; PEP 634 <9>: PyTypeObject スロット.
                                                             (line  815)
* Python Enhancement Proposals; PEP 635: 概要 -- リリースハイライト<2>.
                                                             (line   10)
* Python Enhancement Proposals; PEP 635 <1>: Other Key Features.
                                                             (line   54)
* Python Enhancement Proposals; PEP 636: 概要 -- リリースハイライト<2>.
                                                             (line   12)
* Python Enhancement Proposals; PEP 636 <1>: Other Key Features.
                                                             (line   54)
* Python Enhancement Proposals; PEP 636 <2>: match 文.       (line  177)
* Python Enhancement Proposals; PEP 636 <3>: match 文<2>.    (line   34)
* Python Enhancement Proposals; PEP 636 <4>: クラスパターン. (line  137)
* Python Enhancement Proposals; PEP 644: hashlib.            (line    8)
* Python Enhancement Proposals; PEP 644 <1>: 概要 -- リリースハイライト<2>.
                                                             (line   36)
* Python Enhancement Proposals; PEP 644 <2>: hashlib<3>.     (line    7)
* Python Enhancement Proposals; PEP 644 <3>: ssl<3>.         (line    7)
* Python Enhancement Proposals; PEP 644 <4>: Build Changes<4>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 644 <5>: Core and Builtins<13>.
                                                             (line  167)
* Python Enhancement Proposals; PEP 644 <6>: Library<22>.    (line  525)
* Python Enhancement Proposals; PEP 644 <7>: Build<31>.      (line    9)
* Python Enhancement Proposals; PEP 644 <8>: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー.
                                                             (line   56)
* Python Enhancement Proposals; PEP 646: PEP 646 Variadic generics.
                                                             (line    7)
* Python Enhancement Proposals; PEP 646 <1>: PEP 646 Variadic generics.
                                                             (line   18)
* Python Enhancement Proposals; PEP 646 <2>: 添字表記 subscription.
                                                             (line   30)
* Python Enhancement Proposals; PEP 646 <3>: 式のリスト.     (line   26)
* Python Enhancement Proposals; PEP 646 <4>: 関数定義.       (line  121)
* Python Enhancement Proposals; PEP 646 <5>: Building generic types and type aliases.
                                                             (line  320)
* Python Enhancement Proposals; PEP 647: 概要 -- リリースハイライト<2>.
                                                             (line   32)
* Python Enhancement Proposals; PEP 647 <1>: PEP 647 User-Defined Type Guards.
                                                             (line    9)
* Python Enhancement Proposals; PEP 647 <2>: Library<31>.    (line  182)
* Python Enhancement Proposals; PEP 647 <3>: 特殊形式.       (line  516)
* Python Enhancement Proposals; PEP 649: Annotation scopes.  (line   10)
* Python Enhancement Proposals; PEP 649 <1>: モジュールコンテンツ<5>.
                                                             (line  123)
* Python Enhancement Proposals; PEP 652: PEP 652 Maintaining the Stable ABI.
                                                             (line   11)
* Python Enhancement Proposals; PEP 652 <1>: C API<30>.      (line   41)
* Python Enhancement Proposals; PEP 654: PEP 654 例外グループと except*.
                                                             (line    6)
* Python Enhancement Proposals; PEP 654 <1>: PEP 654 例外グループと except*.
                                                             (line   13)
* Python Enhancement Proposals; PEP 654 <2>: New opcodes.    (line   19)
* Python Enhancement Proposals; PEP 654 <3>: Core and Builtins<23>.
                                                             (line  174)
* Python Enhancement Proposals; PEP 654 <4>: Core and Builtins<28>.
                                                             (line  146)
* Python Enhancement Proposals; PEP 654 <5>: Core and Builtins<30>.
                                                             (line   88)
* Python Enhancement Proposals; PEP 655: PEP 655 Marking individual TypedDict items as required or not-required.
                                                             (line   30)
* Python Enhancement Proposals; PEP 655 <1>: Library<23>.    (line  266)
* Python Enhancement Proposals; PEP 655 <2>: 特殊形式.       (line  222)
* Python Enhancement Proposals; PEP 655 <3>: 特殊形式.       (line  231)
* Python Enhancement Proposals; PEP 655 <4>: Other special directives.
                                                             (line  457)
* Python Enhancement Proposals; PEP 657: PEP 657 トレースバックのエラー位置の詳細化.
                                                             (line   54)
* Python Enhancement Proposals; PEP 657 <1>: inspect<2>.     (line   17)
* Python Enhancement Proposals; PEP 657 <2>: Library<23>.    (line  223)
* Python Enhancement Proposals; PEP 657 <3>: Core and Builtins<31>.
                                                             (line  337)
* Python Enhancement Proposals; PEP 659: PEP 659 Specializing Adaptive Interpreter.
                                                             (line    6)
* Python Enhancement Proposals; PEP 659 <1>: PEP 659 Specializing Adaptive Interpreter.
                                                             (line   30)
* Python Enhancement Proposals; PEP 659 <2>: Single-threaded performance.
                                                             (line   10)
* Python Enhancement Proposals; PEP 667: Summary -- Release Highlights.
                                                             (line   40)
* Python Enhancement Proposals; PEP 667 <1>: Defined mutation semantics for locals.
                                                             (line    8)
* Python Enhancement Proposals; PEP 667 <2>: Defined mutation semantics for locals.
                                                             (line   41)
* Python Enhancement Proposals; PEP 667 <3>: Deprecated C APIs.
                                                             (line   33)
* Python Enhancement Proposals; PEP 667 <4>: Changes in the Python API.
                                                             (line   17)
* Python Enhancement Proposals; PEP 667 <5>: Changes in the Python API.
                                                             (line   26)
* Python Enhancement Proposals; PEP 667 <6>: Changes in the Python API.
                                                             (line   32)
* Python Enhancement Proposals; PEP 667 <7>: 組み込み関数.   (line 1129)
* Python Enhancement Proposals; PEP 667 <8>: pdb --- Python デバッガ.
                                                             (line  119)
* Python Enhancement Proposals; PEP 667 <9>: リフレクション. (line   40)
* Python Enhancement Proposals; PEP 667 <10>: フレーム frame オブジェクト<2>.
                                                             (line  130)
* Python Enhancement Proposals; PEP 669: Summary -- Release Highlights.
                                                             (line  110)
* Python Enhancement Proposals; PEP 669 <1>: New Features<2>.
                                                             (line    6)
* Python Enhancement Proposals; PEP 669 <2>: PEP 669 Low impact monitoring for CPython.
                                                             (line    6)
* Python Enhancement Proposals; PEP 669 <3>: Core and Builtins<16>.
                                                             (line  203)
* Python Enhancement Proposals; PEP 670: 概要 -- リリースハイライト.
                                                             (line   53)
* Python Enhancement Proposals; PEP 670 <1>: Porting to Python 3 11<2>.
                                                             (line   12)
* Python Enhancement Proposals; PEP 673: PEP 673 Self 型.    (line   32)
* Python Enhancement Proposals; PEP 673 <1>: Library<25>.    (line  134)
* Python Enhancement Proposals; PEP 673 <2>: 特殊型.         (line  194)
* Python Enhancement Proposals; PEP 675: PEP 675 Arbitrary literal string type.
                                                             (line   32)
* Python Enhancement Proposals; PEP 675 <1>: Library<24>.    (line   59)
* Python Enhancement Proposals; PEP 675 <2>: 特殊型.         (line   95)
* Python Enhancement Proposals; PEP 676: Documentation<19>.  (line    8)
* Python Enhancement Proposals; PEP 678: Other Language Changes<2>.
                                                             (line   36)
* Python Enhancement Proposals; PEP 678 <1>: PEP 678 ノートによって例外を充実させる.
                                                             (line   11)
* Python Enhancement Proposals; PEP 678 <2>: Core and Builtins<16>.
                                                             (line  183)
* Python Enhancement Proposals; PEP 678 <3>: Core and Builtins<17>.
                                                             (line   57)
* Python Enhancement Proposals; PEP 678 <4>: Core and Builtins<24>.
                                                             (line  118)
* Python Enhancement Proposals; PEP 680: 概要 -- リリースハイライト.
                                                             (line   20)
* Python Enhancement Proposals; PEP 680 <1>: 新たなモジュール.
                                                             (line    6)
* Python Enhancement Proposals; PEP 680 <2>: Library<24>.    (line  205)
* Python Enhancement Proposals; PEP 681: PEP 681 Data class transforms.
                                                             (line   30)
* Python Enhancement Proposals; PEP 681 <1>: Library<23>.    (line  110)
* Python Enhancement Proposals; PEP 681 <2>: Functions and decorators.
                                                             (line  242)
* Python Enhancement Proposals; PEP 682: その他の言語変更.   (line   49)
* Python Enhancement Proposals; PEP 682 <1>: 書式指定ミニ言語仕様.
                                                             (line   90)
* Python Enhancement Proposals; PEP 683: New Features<4>.    (line  147)
* Python Enhancement Proposals; PEP 683 <1>: Core and Builtins<16>.
                                                             (line   73)
* Python Enhancement Proposals; PEP 683 <2>: 参照カウント.   (line  127)
* Python Enhancement Proposals; PEP 683 <3>: 用語集<2>.      (line  713)
* Python Enhancement Proposals; PEP 684: PEP 684 A Per-Interpreter GIL.
                                                             (line    6)
* Python Enhancement Proposals; PEP 684 <1>: New Features<4>.
                                                             (line  182)
* Python Enhancement Proposals; PEP 686: Python UTF-8 Mode.  (line   71)
* Python Enhancement Proposals; PEP 686 <1>: Text Encoding.  (line   32)
* Python Enhancement Proposals; PEP 687: Library<10>.        (line  137)
* Python Enhancement Proposals; PEP 687 <1>: Core and Builtins<15>.
                                                             (line  326)
* Python Enhancement Proposals; PEP 687 <2>: Library<15>.    (line  290)
* Python Enhancement Proposals; PEP 687 <3>: Library<15>.    (line  297)
* Python Enhancement Proposals; PEP 687 <4>: Library<15>.    (line  330)
* Python Enhancement Proposals; PEP 687 <5>: Library<15>.    (line  333)
* Python Enhancement Proposals; PEP 687 <6>: Library<15>.    (line  343)
* Python Enhancement Proposals; PEP 687 <7>: Library<15>.    (line  400)
* Python Enhancement Proposals; PEP 687 <8>: Core and Builtins<17>.
                                                             (line   78)
* Python Enhancement Proposals; PEP 687 <9>: Library<17>.    (line  111)
* Python Enhancement Proposals; PEP 687 <10>: Library<17>.   (line  118)
* Python Enhancement Proposals; PEP 688: PEP 688 Making the buffer protocol accessible in Python.
                                                             (line    6)
* Python Enhancement Proposals; PEP 688 <1>: Core and Builtins<16>.
                                                             (line  211)
* Python Enhancement Proposals; PEP 688 <2>: Emulating buffer types.
                                                             (line   39)
* Python Enhancement Proposals; PEP 688 <3>: コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  180)
* Python Enhancement Proposals; PEP 689: C API<17>.          (line   26)
* Python Enhancement Proposals; PEP 692: PEP 692 Using TypedDict for more precise **kwargs typing.
                                                             (line   10)
* Python Enhancement Proposals; PEP 692 <1>: PEP 692 Using TypedDict for more precise **kwargs typing.
                                                             (line   21)
* Python Enhancement Proposals; PEP 692 <2>: Library<15>.    (line  117)
* Python Enhancement Proposals; PEP 692 <3>: Documentation<10>.
                                                             (line   11)
* Python Enhancement Proposals; PEP 692 <4>: 特殊形式.       (line  596)
* Python Enhancement Proposals; PEP 693: What's New In Python 3 12.
                                                             (line   16)
* Python Enhancement Proposals; PEP 695: PEP 695 Type Parameter Syntax.
                                                             (line   10)
* Python Enhancement Proposals; PEP 695 <1>: PEP 695 Type Parameter Syntax.
                                                             (line   61)
* Python Enhancement Proposals; PEP 695 <2>: CPython bytecode changes.
                                                             (line   41)
* Python Enhancement Proposals; PEP 695 <3>: Library<6>.     (line   76)
* Python Enhancement Proposals; PEP 695 <4>: Library<8>.     (line  123)
* Python Enhancement Proposals; PEP 695 <5>: Library<14>.    (line   95)
* Python Enhancement Proposals; PEP 695 <6>: Library<14>.    (line  661)
* Python Enhancement Proposals; PEP 695 <7>: Library<14>.    (line  856)
* Python Enhancement Proposals; PEP 695 <8>: Library<14>.    (line  949)
* Python Enhancement Proposals; PEP 695 <9>: Core and Builtins<16>.
                                                             (line   13)
* Python Enhancement Proposals; PEP 695 <10>: Core and Builtins<16>.
                                                             (line  108)
* Python Enhancement Proposals; PEP 695 <11>: Library<15>.   (line    7)
* Python Enhancement Proposals; PEP 695 <12>: Annotation scopes.
                                                             (line   55)
* Python Enhancement Proposals; PEP 695 <13>: The type statement.
                                                             (line   40)
* Python Enhancement Proposals; PEP 695 <14>: 特殊型.        (line   60)
* Python Enhancement Proposals; PEP 695 <15>: Building generic types and type aliases.
                                                             (line  113)
* Python Enhancement Proposals; PEP 695 <16>: Building generic types and type aliases.
                                                             (line  212)
* Python Enhancement Proposals; PEP 695 <17>: Building generic types and type aliases.
                                                             (line  346)
* Python Enhancement Proposals; PEP 695 <18>: Building generic types and type aliases.
                                                             (line  453)
* Python Enhancement Proposals; PEP 695 <19>: メジャーな機能の非推奨時系列.
                                                             (line   29)
* Python Enhancement Proposals; PEP 696: Summary -- Release Highlights.
                                                             (line  115)
* Python Enhancement Proposals; PEP 696 <1>: Core and Builtins<9>.
                                                             (line  190)
* Python Enhancement Proposals; PEP 696 <2>: Annotation scopes.
                                                             (line   58)
* Python Enhancement Proposals; PEP 696 <3>: Type parameter lists.
                                                             (line    8)
* Python Enhancement Proposals; PEP 697: New Features<4>.    (line    6)
* Python Enhancement Proposals; PEP 697 <1>: New Features<4>.
                                                             (line   33)
* Python Enhancement Proposals; PEP 697 <2>: C API<15>.      (line   38)
* Python Enhancement Proposals; PEP 698: PEP 698 Override Decorator for Static Typing.
                                                             (line   30)
* Python Enhancement Proposals; PEP 698 <1>: Library<17>.    (line  100)
* Python Enhancement Proposals; PEP 698 <2>: Functions and decorators.
                                                             (line  405)
* Python Enhancement Proposals; PEP 699: Pending Removal in Python 3 14<2>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 699 <1>: Deprecated<2>.  (line    6)
* Python Enhancement Proposals; PEP 699 <2>: Pending Removal in Python 3 14<4>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 699 <3>: Build<18>.      (line   15)
* Python Enhancement Proposals; PEP 699 <4>: Pending Removal in Python 3 14<6>.
                                                             (line    7)
* Python Enhancement Proposals; PEP 7:   ビルドならびに C API の変更<2>.
                                                             (line    9)
* Python Enhancement Proposals; PEP 7 <1>: ビルド要件.       (line   49)
* Python Enhancement Proposals; PEP 7 <2>: コーディング基準. (line    6)
* Python Enhancement Proposals; PEP 7 <3>: 便利なマクロ.     (line  164)
* Python Enhancement Proposals; PEP 7 <4>: 便利なマクロ.     (line  182)
* Python Enhancement Proposals; PEP 701: PEP 701 Syntactic formalization of f-strings.
                                                             (line    6)
* Python Enhancement Proposals; PEP 701 <1>: PEP 701 Syntactic formalization of f-strings.
                                                             (line   66)
* Python Enhancement Proposals; PEP 701 <2>: tokenize.       (line    6)
* Python Enhancement Proposals; PEP 701 <3>: Optimizations<2>.
                                                             (line   26)
* Python Enhancement Proposals; PEP 701 <4>: Changes in the Python API<2>.
                                                             (line   76)
* Python Enhancement Proposals; PEP 701 <5>: Changes in the Python API<2>.
                                                             (line   78)
* Python Enhancement Proposals; PEP 701 <6>: Changes in the Python API<2>.
                                                             (line  100)
* Python Enhancement Proposals; PEP 702: Summary -- Release Highlights.
                                                             (line  119)
* Python Enhancement Proposals; PEP 702 <1>: warnings.       (line    6)
* Python Enhancement Proposals; PEP 702 <2>: Library<12>.    (line  469)
* Python Enhancement Proposals; PEP 702 <3>: 利用可能な関数. (line  178)
* Python Enhancement Proposals; PEP 703: Summary -- Release Highlights.
                                                             (line   10)
* Python Enhancement Proposals; PEP 703 <1>: Summary -- Release Highlights.
                                                             (line   46)
* Python Enhancement Proposals; PEP 703 <2>: Free-threaded CPython.
                                                             (line   54)
* Python Enhancement Proposals; PEP 703 <3>: Core and Builtins<11>.
                                                             (line   11)
* Python Enhancement Proposals; PEP 703 <4>: C API<13>.      (line  137)
* Python Enhancement Proposals; PEP 703 <5>: フリースレッドバイナリ Free-threaded Binaries のインストール.
                                                             (line   11)
* Python Enhancement Proposals; PEP 703 <6>: フリースレッドバイナリ Free-threaded Binaries のインストール<2>.
                                                             (line   12)
* Python Enhancement Proposals; PEP 703 <7>: Python experimental support for free threading.
                                                             (line   25)
* Python Enhancement Proposals; PEP 703 <8>: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？.
                                                             (line   12)
* Python Enhancement Proposals; PEP 703 <9>: 用語集<2>.      (line  542)
* Python Enhancement Proposals; PEP 703 <10>: 用語集<2>.     (line  675)
* Python Enhancement Proposals; PEP 705: Summary -- Release Highlights.
                                                             (line  123)
* Python Enhancement Proposals; PEP 705 <1>: typing.         (line    6)
* Python Enhancement Proposals; PEP 705 <2>: Library<10>.    (line   17)
* Python Enhancement Proposals; PEP 705 <3>: 特殊形式.       (line  253)
* Python Enhancement Proposals; PEP 706: Other Language Changes<2>.
                                                             (line   78)
* Python Enhancement Proposals; PEP 706 <1>: tarfile.        (line   13)
* Python Enhancement Proposals; PEP 706 <2>: tarfile<2>.     (line   13)
* Python Enhancement Proposals; PEP 706 <3>: tarfile<3>.     (line   13)
* Python Enhancement Proposals; PEP 706 <4>: tarfile<5>.     (line   13)
* Python Enhancement Proposals; PEP 706 <5>: Extraction filters.
                                                             (line   22)
* Python Enhancement Proposals; PEP 709: Changes in the Python API.
                                                             (line   26)
* Python Enhancement Proposals; PEP 709 <1>: PEP 709 Comprehension inlining.
                                                             (line    9)
* Python Enhancement Proposals; PEP 709 <2>: PEP 709 Comprehension inlining.
                                                             (line   35)
* Python Enhancement Proposals; PEP 709 <3>: CPython bytecode changes.
                                                             (line   33)
* Python Enhancement Proposals; PEP 709 <4>: Core and Builtins<16>.
                                                             (line  213)
* Python Enhancement Proposals; PEP 709 <5>: 組み込み関数.   (line 1127)
* Python Enhancement Proposals; PEP 719: What's New In Python 3 13.
                                                             (line   16)
* Python Enhancement Proposals; PEP 730: Summary -- Release Highlights.
                                                             (line  133)
* Python Enhancement Proposals; PEP 730 <1>: Support for mobile platforms.
                                                             (line    6)
* Python Enhancement Proposals; PEP 730 <2>: Support for mobile platforms.
                                                             (line   25)
* Python Enhancement Proposals; PEP 734: Library<8>.         (line  161)
* Python Enhancement Proposals; PEP 737: Changed C APIs.     (line   44)
* Python Enhancement Proposals; PEP 737 <1>: C API<9>.       (line    6)
* Python Enhancement Proposals; PEP 737 <2>: C API<9>.       (line   49)
* Python Enhancement Proposals; PEP 738: Summary -- Release Highlights.
                                                             (line  136)
* Python Enhancement Proposals; PEP 738 <1>: Support for mobile platforms.
                                                             (line   15)
* Python Enhancement Proposals; PEP 738 <2>: Support for mobile platforms.
                                                             (line   25)
* Python Enhancement Proposals; PEP 738 <3>: Library<8>.     (line   54)
* Python Enhancement Proposals; PEP 742: Summary -- Release Highlights.
                                                             (line  127)
* Python Enhancement Proposals; PEP 742 <1>: typing.         (line    9)
* Python Enhancement Proposals; PEP 742 <2>: Library<8>.     (line  239)
* Python Enhancement Proposals; PEP 742 <3>: 特殊形式.       (line  494)
* Python Enhancement Proposals; PEP 744: Summary -- Release Highlights.
                                                             (line   11)
* Python Enhancement Proposals; PEP 744 <1>: Summary -- Release Highlights.
                                                             (line   50)
* Python Enhancement Proposals; PEP 744 <2>: An experimental just-in-time JIT compiler.
                                                             (line   60)
* Python Enhancement Proposals; PEP 8:   ライブラリの変更.   (line   25)
* Python Enhancement Proposals; PEP 8 <1>: Library<59>.      (line  124)
* Python Enhancement Proposals; PEP 8 <2>: IDLE<63>.         (line   81)
* Python Enhancement Proposals; PEP 8 <3>: 間奏曲 コーディングスタイル.
                                                             (line   13)
* Python Enhancement Proposals; PEP 8 <4>: エディタと IDE.   (line    7)
* Python Enhancement Proposals; PEP 8 <5>: 値の比較.         (line   53)
* Python Enhancement Proposals; PEP 8 <6>: 組み込み関数.     (line 1817)
* Python Enhancement Proposals; PEP 8 <7>: 残りのはしばし<2>.
                                                             (line   35)
* Python Enhancement Proposals; PEP 8 <8>: Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？.
                                                             (line    6)
* Python Enhancement Proposals; PEP 8 <9>: いつ is 演算子での同一性テストが頼れますか？.
                                                             (line   56)
* Python Enhancement Proposals; PEP 8 <10>: エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？.
                                                             (line    6)
* PYTHON_BASIC_REPL:                     A better interactive interpreter.
                                                             (line   27)
* PYTHON_BASIC_REPL <1>:                 Library.            (line  234)
* PYTHON_BASIC_REPL <2>:                 Library.            (line  238)
* PYTHON_BASIC_REPL <3>:                 Core and Builtins<7>.
                                                             (line   55)
* PYTHON_BASIC_REPL <4>:                 対話モード<2>.      (line   22)
* python_branch() (platform モジュール): クロスプラットフォーム.
                                                             (line   83)
* python_build() (platform モジュール):  クロスプラットフォーム.
                                                             (line   73)
* PYTHON_COLORS:                         Summary -- Release Highlights.
                                                             (line   57)
* PYTHON_COLORS <1>:                     Improved error messages.
                                                             (line    8)
* PYTHON_COLORS <2>:                     doctest.            (line    7)
* PYTHON_COLORS <3>:                     色の制御.           (line   20)
* python_compiler() (platform モジュール): クロスプラットフォーム.
                                                             (line   78)
* PYTHON_CPU_COUNT:                      os.                 (line   11)
* PYTHON_CPU_COUNT <1>:                  その他のオプション. (line  367)
* PYTHON_CPU_COUNT <2>:                  雑多なシステム情報. (line   45)
* PYTHON_CPU_COUNT <3>:                  雑多なシステム情報. (line   66)
* PYTHON_CPU_COUNT <4>:                  その他<3>.          (line   32)
* PYTHON_CPU_COUNT <5>:                  PyConfig.           (line  496)
* PYTHON_DOM:                            モジュールコンテンツ<4>.
                                                             (line   22)
* PYTHON_FROZEN_MODULES:                 Other Language Changes.
                                                             (line   46)
* PYTHON_FROZEN_MODULES <1>:             Core and Builtins<14>.
                                                             (line  105)
* PYTHON_FROZEN_MODULES <2>:             その他のオプション. (line  338)
* PYTHON_GIL:                            Free-threaded CPython.
                                                             (line   22)
* PYTHON_GIL <1>:                        Free-threaded CPython.
                                                             (line   38)
* PYTHON_GIL <2>:                        Core and Builtins<4>.
                                                             (line   40)
* PYTHON_GIL <3>:                        その他のオプション. (line  385)
* PYTHON_GIL <4>:                        The global interpreter lock in free-threaded Python.
                                                             (line    7)
* PYTHON_GIL <5>:                        用語集<2>.          (line  672)
* PYTHON_HISTORY:                        Other Language Changes.
                                                             (line   57)
* PYTHON_HISTORY <1>:                    Library<12>.        (line  544)
* python_implementation() (platform モジュール): クロスプラットフォーム.
                                                             (line   88)
* python_is_optimized() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  254)
* PYTHON_PERF_JIT_SUPPORT:               Other Language Changes.
                                                             (line   52)
* PYTHON_PERF_JIT_SUPPORT <1>:           その他のオプション. (line  357)
* PYTHON_PERF_JIT_SUPPORT <2>:           PyConfig.           (line  876)
* PYTHON_PERF_JIT_SUPPORT <3>:           PyConfig.           (line  879)
* PYTHON_PERF_JIT_SUPPORT <4>:           How to work without frame pointers.
                                                             (line   14)
* PYTHON_PRESITE:                        その他のオプション. (line  379)
* PYTHON_PRESITE <1>:                    PyConfig.           (line  776)
* PYTHON_PRESITE=package.module:         Core and Builtins<14>.
                                                             (line  154)
* python_revision() (platform モジュール): クロスプラットフォーム.
                                                             (line   93)
* python_version_tuple() (platform モジュール): クロスプラットフォーム.
                                                             (line  106)
* python_version() (platform モジュール): クロスプラットフォーム.
                                                             (line   98)
* python-m-py_compile コマンドラインオプション; -: コマンドラインインターフェイス<11>.
                                                             (line   13)
* python-m-py_compile コマンドラインオプション; -q: コマンドラインインターフェイス<11>.
                                                             (line   19)
* python-m-py_compile コマンドラインオプション; -quiet: コマンドラインインターフェイス<11>.
                                                             (line   19)
* python-m-py_compile コマンドラインオプション; <file>: コマンドラインインターフェイス<11>.
                                                             (line   13)
* python-m-sqlite3-[-h]-[-v]-[filename]-[sql] コマンドラインオプション; -h: コマンドライン・インターフェース.
                                                             (line   14)
* python-m-sqlite3-[-h]-[-v]-[filename]-[sql] コマンドラインオプション; -help: コマンドライン・インターフェース.
                                                             (line   14)
* python-m-sqlite3-[-h]-[-v]-[filename]-[sql] コマンドラインオプション; -v: コマンドライン・インターフェース.
                                                             (line   18)
* python-m-sqlite3-[-h]-[-v]-[filename]-[sql] コマンドラインオプション; -version: コマンドライン・インターフェース.
                                                             (line   18)
* PYTHONASYNCIODEBUG:                    デバッグモードの有効化.
                                                             (line   10)
* PYTHONASYNCIODEBUG <1>:                デバッグモード.     (line   11)
* PYTHONASYNCIODEBUG <2>:                Effects of the Python Development Mode.
                                                             (line   65)
* PYTHONBREAKPOINT:                      PEP 553 組み込みの breakpoint.
                                                             (line   13)
* PYTHONBREAKPOINT <1>:                  組み込み関数.       (line  158)
* PYTHONBREAKPOINT <2>:                  sys --- システム固有のパラメーターと関数.
                                                             (line  244)
* PYTHONBREAKPOINT <3>:                  sys --- システム固有のパラメーターと関数.
                                                             (line  258)
* PYTHONBREAKPOINT <4>:                  sys --- システム固有のパラメーターと関数.
                                                             (line  263)
* PYTHONCASEOK:                          Python API の変更<2>.
                                                             (line   29)
* PYTHONCASEOK <1>:                      PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み.
                                                             (line   17)
* PYTHONCASEOK <2>:                      Library<41>.        (line  144)
* PYTHONCASEOK <3>:                      組み込み関数.       (line 2222)
* PYTHONCOERCECLOCALE:                   PEP 538 レガシーな C ロケールの抑圧.
                                                             (line   12)
* PYTHONCOERCECLOCALE <1>:               一般的なオプション. (line   89)
* PYTHONCOERCECLOCALE <2>:               Python UTF-8 Mode.  (line   57)
* PYTHONCOERCECLOCALE <3>:               Python Configuration.
                                                             (line   15)
* PYTHONDEBUG:                           その他のオプション. (line   38)
* PYTHONDEBUG <1>:                       Python Debug Build. (line   20)
* PYTHONDEBUG <2>:                       グローバルな設定変数.
                                                             (line   39)
* PYTHONDEBUG <3>:                       PyConfig.           (line  667)
* PYTHONDEVMODE:                         Python Development Mode -X dev.
                                                             (line    6)
* PYTHONDEVMODE <1>:                     その他のオプション. (line  297)
* PYTHONDEVMODE <2>:                     Python 開発モード.  (line   14)
* PYTHONDEVMODE <3>:                     PyConfig.           (line  295)
* PYTHONDONTWRITEBYTECODE:               インタプリタの変更<2>.
                                                             (line   15)
* PYTHONDONTWRITEBYTECODE <1>:           新しいモジュールと改良されたモジュール<2>.
                                                             (line  637)
* PYTHONDONTWRITEBYTECODE <2>:           その他のオプション. (line   19)
* PYTHONDONTWRITEBYTECODE <3>:           sys --- システム固有のパラメーターと関数.
                                                             (line  329)
* PYTHONDONTWRITEBYTECODE <4>:           グローバルな設定変数.
                                                             (line   53)
* PYTHONDONTWRITEBYTECODE <5>:           PyConfig.           (line  953)
* PYTHONDONTWRITEBYTECODE <6>:           pyc ファイルを作るにはどうしますか？.
                                                             (line   19)
* PYTHONDUMPREFS:                        デバッグビルドとリリースビルドのABI 共通化.
                                                             (line   15)
* PYTHONDUMPREFS <1>:                    Build<47>.          (line   54)
* PYTHONDUMPREFS <2>:                    Debug options.      (line   22)
* PYTHONDUMPREFS <3>:                    Debug options.      (line   24)
* PYTHONDUMPREFS <4>:                    PyConfig.           (line  306)
* PYTHONDUMPREFSFILE:                    Core and Builtins<31>.
                                                             (line  154)
* PYTHONEXECUTABLE:                      PyConfig.           (line  702)
* PYTHONFAULTHANDLER:                    faulthandler<4>.    (line   12)
* PYTHONFAULTHANDLER <1>:                その他のオプション. (line  259)
* PYTHONFAULTHANDLER <2>:                Effects of the Python Development Mode.
                                                             (line   59)
* PYTHONFAULTHANDLER <3>:                faulthandler --- Python トレースバックをダンプする.
                                                             (line   15)
* PYTHONFAULTHANDLER <4>:                PyConfig.           (line  344)
* PythonFinalizationError:               具象例外.           (line  205)
* PYTHONHASHSEED:                        組み込みの関数と型. (line   18)
* PYTHONHASHSEED <1>:                    Python コードの移植.
                                                             (line    7)
* PYTHONHASHSEED <2>:                    Core and Builtins<58>.
                                                             (line   30)
* PYTHONHASHSEED <3>:                    その他のオプション. (line  122)
* PYTHONHASHSEED <4>:                    その他のオプション. (line  138)
* PYTHONHASHSEED <5>:                    環境変数.           (line  156)
* PYTHONHASHSEED <6>:                    基本的なカスタマイズ.
                                                             (line  312)
* PYTHONHASHSEED <7>:                    グローバルな設定変数.
                                                             (line   79)
* PYTHONHASHSEED <8>:                    グローバルな設定変数.
                                                             (line   82)
* PYTHONHASHSEED <9>:                    PyConfig.           (line  414)
* PYTHONHOME:                            Deprecated C APIs.  (line   26)
* PYTHONHOME <1>:                        Pending Removal in Python 3 15<2>.
                                                             (line   38)
* PYTHONHOME <2>:                        Pending Removal in Python 3 15<4>.
                                                             (line   38)
* PYTHONHOME <3>:                        概要 -- リリースハイライト<6>.
                                                             (line  106)
* PYTHONHOME <4>:                        その他のオプション. (line   47)
* PYTHONHOME <5>:                        環境変数.           (line   18)
* PYTHONHOME <6>:                        環境変数.           (line   20)
* PYTHONHOME <7>:                        環境変数.           (line   37)
* PYTHONHOME <8>:                        モジュールの検索.   (line   28)
* PYTHONHOME <9>:                        モジュールの検索.   (line   43)
* PYTHONHOME <10>:                       モジュールの検索.   (line   78)
* PYTHONHOME <11>:                       test support script_helper --- Utilities for the Python execution tests.
                                                             (line   25)
* PYTHONHOME <12>:                       sys path モジュール検索パスの初期化.
                                                             (line   30)
* PYTHONHOME <13>:                       仮想環境.           (line   14)
* PYTHONHOME <14>:                       Python の埋め込み<2>.
                                                             (line   34)
* PYTHONHOME <15>:                       Python の埋め込み<2>.
                                                             (line   41)
* PYTHONHOME <16>:                       グローバルな設定変数.
                                                             (line   94)
* PYTHONHOME <17>:                       プロセスワイドのパラメータ.
                                                             (line  292)
* PYTHONHOME <18>:                       プロセスワイドのパラメータ.
                                                             (line  307)
* PYTHONHOME <19>:                       プロセスワイドのパラメータ.
                                                             (line  316)
* PYTHONHOME <20>:                       PyConfig.           (line  422)
* PYTHONHOME <21>:                       PyConfig.           (line  424)
* PYTHONHOME <22>:                       Pending Removal in Python 3 15<6>.
                                                             (line   38)
* Pythonic:                              用語集<2>.          (line 1218)
* PYTHONINSPECT:                         その他の変更と修正<2>.
                                                             (line   13)
* PYTHONINSPECT <1>:                     その他のオプション. (line   60)
* PYTHONINSPECT <2>:                     グローバルな設定変数.
                                                             (line  111)
* PYTHONINSPECT <3>:                     PyConfig.           (line  449)
* PYTHONINTMAXSTRDIGITS:                 Core and Builtins<23>.
                                                             (line  106)
* PYTHONINTMAXSTRDIGITS <1>:             その他のオプション. (line  281)
* PYTHONINTMAXSTRDIGITS <2>:             上限値を設定する.   (line    9)
* PYTHONINTMAXSTRDIGITS <3>:             上限値を設定する.   (line   16)
* PYTHONINTMAXSTRDIGITS <4>:             sys --- システム固有のパラメーターと関数.
                                                             (line 1136)
* PYTHONINTMAXSTRDIGITS <5>:             PyConfig.           (line  480)
* PYTHONIOENCODING:                      その他の改善<2>.    (line   75)
* PYTHONIOENCODING <1>:                  インタプリタの変更<2>.
                                                             (line   22)
* PYTHONIOENCODING <2>:                  環境変数.           (line  402)
* PYTHONIOENCODING <3>:                  Python UTF-8 Mode.  (line   29)
* PYTHONIOENCODING <4>:                  sys --- システム固有のパラメーターと関数.
                                                             (line 1808)
* PYTHONIOENCODING <5>:                  PyConfig.           (line  836)
* PYTHONLEGACYWINDOWSFSENCODING:         New Deprecations.   (line  138)
* PYTHONLEGACYWINDOWSFSENCODING <1>:     Pending removal in Python 3 16.
                                                             (line   50)
* PYTHONLEGACYWINDOWSFSENCODING <2>:     Pending removal in Python 3 16<2>.
                                                             (line   50)
* PYTHONLEGACYWINDOWSFSENCODING <3>:     PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更.
                                                             (line   18)
* PYTHONLEGACYWINDOWSFSENCODING <4>:     Windows<9>.         (line   37)
* PYTHONLEGACYWINDOWSFSENCODING <5>:     sys --- システム固有のパラメーターと関数.
                                                             (line 1750)
* PYTHONLEGACYWINDOWSFSENCODING <6>:     sys --- システム固有のパラメーターと関数.
                                                             (line 1761)
* PYTHONLEGACYWINDOWSFSENCODING <7>:     sys --- システム固有のパラメーターと関数.
                                                             (line 1767)
* PYTHONLEGACYWINDOWSFSENCODING <8>:     グローバルな設定変数.
                                                             (line  153)
* PYTHONLEGACYWINDOWSFSENCODING <9>:     PyPreConfig.        (line  123)
* PYTHONLEGACYWINDOWSFSENCODING <10>:    Pending removal in Python 3 16<3>.
                                                             (line   50)
* PYTHONLEGACYWINDOWSSTDIO:              PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更.
                                                             (line   12)
* PYTHONLEGACYWINDOWSSTDIO <1>:          環境変数.           (line  190)
* PYTHONLEGACYWINDOWSSTDIO <2>:          sys --- システム固有のパラメーターと関数.
                                                             (line 1812)
* PYTHONLEGACYWINDOWSSTDIO <3>:          グローバルな設定変数.
                                                             (line  171)
* PYTHONLEGACYWINDOWSSTDIO <4>:          PyConfig.           (line  533)
* PYTHONMALLOC:                          PYTHONMALLOC 環境変数.
                                                             (line    6)
* PYTHONMALLOC <1>:                      C API の変更<9>.    (line    9)
* PYTHONMALLOC <2>:                      Core and Builtins<78>.
                                                             (line   90)
* PYTHONMALLOC <3>:                      環境変数.           (line  329)
* PYTHONMALLOC <4>:                      パフォーマンスに関するオプション.
                                                             (line  109)
* PYTHONMALLOC <5>:                      パフォーマンスに関するオプション.
                                                             (line  116)
* PYTHONMALLOC <6>:                      Effects of the Python Development Mode.
                                                             (line   46)
* PYTHONMALLOC <7>:                      Effects of the Python Development Mode.
                                                             (line   50)
* PYTHONMALLOC <8>:                      概要<4>.            (line   75)
* PYTHONMALLOC <9>:                      Default Memory Allocators.
                                                             (line   26)
* PYTHONMALLOC <10>:                     Debug hooks on the Python memory allocators.
                                                             (line   11)
* PYTHONMALLOC <11>:                     pymalloc アロケータ.
                                                             (line   27)
* PYTHONMALLOCSTATS:                     Core and Builtins<78>.
                                                             (line   96)
* PYTHONMALLOCSTATS <1>:                 PyConfig.           (line  549)
* PYTHONMALLOCSTATS <2>:                 概要<4>.            (line   78)
* PYTHONNODEBUGRANGES:                   PEP 657 トレースバックのエラー位置の詳細化.
                                                             (line   61)
* PYTHONNODEBUGRANGES <1>:               その他のオプション. (line  326)
* PYTHONNODEBUGRANGES <2>:               Methods on code objects.
                                                             (line   40)
* PYTHONNODEBUGRANGES <3>:               PyConfig.           (line  248)
* PYTHONNOUSERSITE:                      PEP 370 ユーザごとの site-packages ディレクトリ.
                                                             (line   30)
* PYTHONNOUSERSITE <1>:                  その他のオプション. (line  150)
* PYTHONNOUSERSITE <2>:                  モジュールの内容<5>.
                                                             (line   15)
* PYTHONNOUSERSITE <3>:                  グローバルな設定変数.
                                                             (line  205)
* PYTHONNOUSERSITE <4>:                  PyConfig.           (line  906)
* PYTHONOPTIMIZE:                        その他のオプション. (line   80)
* PYTHONOPTIMIZE <1>:                    グローバルな設定変数.
                                                             (line  216)
* PYTHONOPTIMIZE <2>:                    PyConfig.           (line  617)
* PYTHONPATH:                            'python' コマンドの挙動の変更<2>.
                                                             (line    7)
* PYTHONPATH <1>:                        'python' コマンドの挙動の変更<2>.
                                                             (line    9)
* PYTHONPATH <2>:                        モジュール検索パス. (line   16)
* PYTHONPATH <3>:                        標準モジュール.     (line   31)
* PYTHONPATH <4>:                        標準モジュール.     (line   32)
* PYTHONPATH <5>:                        その他のオプション. (line   46)
* PYTHONPATH <6>:                        環境変数.           (line   31)
* PYTHONPATH <7>:                        環境変数.           (line   38)
* PYTHONPATH <8>:                        環境変数.           (line   42)
* PYTHONPATH <9>:                        補足 環境変数の設定.
                                                             (line   36)
* PYTHONPATH <10>:                       モジュールの検索.   (line   15)
* PYTHONPATH <11>:                       モジュールの検索.   (line   36)
* PYTHONPATH <12>:                       モジュールの検索.   (line   77)
* PYTHONPATH <13>:                       パスエントリ・ファインダー.
                                                             (line    6)
* PYTHONPATH <14>:                       パスエントリ・ファインダー.
                                                             (line   22)
* PYTHONPATH <15>:                       test support script_helper --- Utilities for the Python execution tests.
                                                             (line   26)
* PYTHONPATH <16>:                       sys --- システム固有のパラメーターと関数.
                                                             (line 1296)
* PYTHONPATH <17>:                       sys --- システム固有のパラメーターと関数.
                                                             (line 1302)
* PYTHONPATH <18>:                       sys path モジュール検索パスの初期化.
                                                             (line   14)
* PYTHONPATH <19>:                       sys path モジュール検索パスの初期化.
                                                             (line   18)
* PYTHONPATH <20>:                       C および C++ 拡張のビルド.
                                                             (line    9)
* PYTHONPATH <21>:                       Python の埋め込み<2>.
                                                             (line   35)
* PYTHONPATH <22>:                       Python の埋め込み<2>.
                                                             (line   42)
* PYTHONPATH <23>:                       グローバルな設定変数.
                                                             (line   93)
* PYTHONPATH <24>:                       PyConfig.           (line  582)
* PYTHONPERFSUPPORT:                     Other Language Changes<2>.
                                                             (line   85)
* PYTHONPERFSUPPORT <1>:                 その他のオプション. (line  346)
* PYTHONPERFSUPPORT <2>:                 How to enable perf profiling support.
                                                             (line    7)
* PYTHONPLATLIBDIR:                      Core and Builtins<39>.
                                                             (line  274)
* PYTHONPLATLIBDIR <1>:                  sys path モジュール検索パスの初期化.
                                                             (line   51)
* PYTHONPLATLIBDIR <2>:                  PyConfig.           (line  561)
* PYTHONPROFILEIMPORTTIME:               その他の言語変更<5>.
                                                             (line   47)
* PYTHONPROFILEIMPORTTIME <1>:           Core and Builtins<60>.
                                                             (line   66)
* PYTHONPROFILEIMPORTTIME <2>:           その他のオプション. (line  290)
* PYTHONPROFILEIMPORTTIME <3>:           PyConfig.           (line  434)
* PYTHONPYCACHEPREFIX:                   コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム.
                                                             (line    8)
* PYTHONPYCACHEPREFIX <1>:               Core and Builtins<51>.
                                                             (line  402)
* PYTHONPYCACHEPREFIX <2>:               その他のオプション. (line  310)
* PYTHONPYCACHEPREFIX <3>:               sys --- システム固有のパラメーターと関数.
                                                             (line  376)
* PYTHONPYCACHEPREFIX <4>:               PyConfig.           (line  724)
* PYTHONREGRTEST_UNICODE_GUARD:          Tests<21>.          (line   13)
* PYTHONSAFEPATH:                        概要 -- リリースハイライト.
                                                             (line   27)
* PYTHONSAFEPATH <1>:                    その他の言語変更.   (line   37)
* PYTHONSAFEPATH <2>:                    Security<16>.       (line    6)
* PYTHONSAFEPATH <3>:                    その他のオプション. (line  108)
* PYTHONSAFEPATH <4>:                    sys --- システム固有のパラメーターと関数.
                                                             (line 1314)
* PYTHONSAFEPATH <5>:                    セキュリティで考慮すべき点<6>.
                                                             (line   47)
* PYTHONSAFEPATH <6>:                    PyConfig.           (line  165)
* PYTHONSTARTUP:                         sys<12>.            (line   16)
* PYTHONSTARTUP <1>:                     sys<12>.            (line   21)
* PYTHONSTARTUP <2>:                     IDLE<37>.           (line  176)
* PYTHONSTARTUP <3>:                     IDLE<41>.           (line    9)
* PYTHONSTARTUP <4>:                     IDLE<47>.           (line    9)
* PYTHONSTARTUP <5>:                     対話モード用の起動時実行ファイル.
                                                             (line    7)
* PYTHONSTARTUP <6>:                     その他のオプション. (line   56)
* PYTHONSTARTUP <7>:                     環境変数.           (line  116)
* PYTHONSTARTUP <8>:                     使用例<2>.          (line    9)
* PYTHONSTARTUP <9>:                     asyncio --- 非同期 I/O.
                                                             (line   78)
* PYTHONSTARTUP <10>:                    Startup and Code Execution.
                                                             (line    6)
* PYTHONSTARTUP <11>:                    sys --- システム固有のパラメーターと関数.
                                                             (line 1148)
* PYTHONSTARTUP <12>:                    readline の設定.    (line   11)
* PYTHONTRACEMALLOC:                     その他のオプション. (line  276)
* PYTHONTRACEMALLOC <1>:                 tracemalloc --- メモリ割り当ての追跡.
                                                             (line   23)
* PYTHONTRACEMALLOC <2>:                 tracemalloc --- メモリ割り当ての追跡.
                                                             (line   30)
* PYTHONTRACEMALLOC <3>:                 関数<11>.           (line   93)
* PYTHONTRACEMALLOC <4>:                 PyConfig.           (line  864)
* PYTHONTZPATH:                          例外と警告.         (line   14)
* PYTHONUNBUFFERED:                      Core and Builtins<44>.
                                                             (line  107)
* PYTHONUNBUFFERED <1>:                  その他のオプション. (line  170)
* PYTHONUNBUFFERED <2>:                  sys --- システム固有のパラメーターと関数.
                                                             (line 1819)
* PYTHONUNBUFFERED <3>:                  グローバルな設定変数.
                                                             (line  244)
* PYTHONUNBUFFERED <4>:                  PyConfig.           (line  212)
* PYTHONUOPS:                            Core and Builtins<15>.
                                                             (line   27)
* PYTHONUOPS <1>:                        Core and Builtins<15>.
                                                             (line  179)
* PYTHONUOPS <2>:                        Core and Builtins<15>.
                                                             (line  258)
* PYTHONUOPS <3>:                        Core and Builtins<15>.
                                                             (line  317)
* PYTHONUOPS <4>:                        Core and Builtins<15>.
                                                             (line  382)
* PYTHONUSERBASE:                        PEP 370 ユーザごとの site-packages ディレクトリ.
                                                             (line   23)
* PYTHONUSERBASE <1>:                    モジュールの内容<5>.
                                                             (line   41)
* PYTHONUSERBASE <2>:                    モジュールの内容<5>.
                                                             (line   67)
* PYTHONUSERSITE:                        test support script_helper --- Utilities for the Python execution tests.
                                                             (line   26)
* PYTHONUTF8:                            PEP 540 強制 UTF-8 実行モード.
                                                             (line    6)
* PYTHONUTF8 <1>:                        その他のオプション. (line  304)
* PYTHONUTF8 <2>:                        環境変数.           (line  412)
* PYTHONUTF8 <3>:                        UTF-8 モード.       (line   18)
* PYTHONUTF8 <4>:                        Python UTF-8 Mode.  (line   52)
* PYTHONUTF8 <5>:                        Python UTF-8 Mode.  (line   54)
* PYTHONUTF8 <6>:                        sys --- システム固有のパラメーターと関数.
                                                             (line 1810)
* PYTHONUTF8 <7>:                        PyPreConfig.        (line  152)
* PYTHONUTF8 <8>:                        Python Configuration.
                                                             (line   14)
* PYTHONVERBOSE:                         その他のオプション. (line  186)
* PYTHONVERBOSE <1>:                     グローバルな設定変数.
                                                             (line  261)
* PYTHONVERBOSE <2>:                     PyConfig.           (line  923)
* PYTHONWARNDEFAULTENCODING:             Optional EncodingWarning and encoding="locale" option.
                                                             (line   19)
* PYTHONWARNDEFAULTENCODING <1>:         Library<32>.        (line   45)
* PYTHONWARNDEFAULTENCODING <2>:         その他のオプション. (line  316)
* PYTHONWARNDEFAULTENCODING <3>:         Opt-in EncodingWarning.
                                                             (line    9)
* PYTHONWARNINGS:                        warnings<3>.        (line   21)
* PYTHONWARNINGS <1>:                    その他の言語変更<10>.
                                                             (line  158)
* PYTHONWARNINGS <2>:                    Deprecation Warnings の扱いの変更.
                                                             (line   24)
* PYTHONWARNINGS <3>:                    インタプリタの変更. (line    6)
* PYTHONWARNINGS <4>:                    Documentation<17>.  (line   67)
* PYTHONWARNINGS <5>:                    その他のオプション. (line  240)
* PYTHONWARNINGS <6>:                    Effects of the Python Development Mode.
                                                             (line   30)
* PYTHONWARNINGS <7>:                    警告フィルタ.       (line   46)
* PYTHONWARNINGS <8>:                    警告フィルタ.       (line   56)
* PYTHONWARNINGS <9>:                    Describing Warning Filters.
                                                             (line    7)
* PYTHONWARNINGS <10>:                   Describing Warning Filters.
                                                             (line   21)
* PYTHONWARNINGS <11>:                   デフォルトの警告フィルタ.
                                                             (line    7)
* PYTHONWARNINGS <12>:                   PyConfig.           (line  942)
* PyThread_create_key (C function):      スレッドローカルストレージ TLS API.
                                                             (line   18)
* PyThread_delete_key (C function):      スレッドローカルストレージ TLS API.
                                                             (line   21)
* PyThread_delete_key_value (C function): スレッドローカルストレージ TLS API.
                                                             (line   30)
* PyThread_get_key_value (C function):   スレッドローカルストレージ TLS API.
                                                             (line   27)
* PyThread_ReInitTLS (C function):       スレッドローカルストレージ TLS API.
                                                             (line   33)
* PyThread_set_key_value (C function):   スレッドローカルストレージ TLS API.
                                                             (line   24)
* PyThread_tss_alloc (C function):       動的メモリ確保.     (line   10)
* PyThread_tss_create (C function):      メソッド<2>.        (line   16)
* PyThread_tss_delete (C function):      メソッド<2>.        (line   24)
* PyThread_tss_free (C function):        動的メモリ確保.     (line   16)
* PyThread_tss_get (C function):         メソッド<2>.        (line   39)
* PyThread_tss_is_created (C function):  メソッド<2>.        (line   11)
* PyThread_tss_set (C function):         メソッド<2>.        (line   33)
* PyThreadState (C type):                スレッド状態 thread state とグローバルインタプリタロック global interpreter lock.
                                                             (line   24)
* PyThreadState (C type) <1>:            高レベルAPI.        (line   21)
* PyThreadState_Clear (C function):      低レベルAPI.        (line   43)
* PyThreadState_Delete (C function):     低レベルAPI.        (line   51)
* PyThreadState_DeleteCurrent (C function): 低レベルAPI.     (line   57)
* PyThreadState_EnterTracing (C function): 低レベルAPI.      (line   96)
* PyThreadState_Get (C function):        高レベルAPI.        (line   68)
* PyThreadState_GetDict (C function):    低レベルAPI.        (line  183)
* PyThreadState_GetFrame (C function):   低レベルAPI.        (line   64)
* PyThreadState_GetID (C function):      低レベルAPI.        (line   78)
* PyThreadState_GetInterpreter (C function): 低レベルAPI.    (line   87)
* PyThreadState_GetUnchecked (C function): 高レベルAPI.      (line   76)
* PyThreadState_LeaveTracing (C function): 低レベルAPI.      (line  105)
* PyThreadState_New (C function):        低レベルAPI.        (line   36)
* PyThreadState_Next (C function):       高度なデバッガサポート advanced debugger support.
                                                             (line   29)
* PyThreadState_SetAsyncExc (C function): 低レベルAPI.       (line  192)
* PyThreadState_Swap (C function):       高レベルAPI.        (line   85)
* PyThreadState.interp (C member):       高レベルAPI.        (line   26)
* PyTime_AsSecondsDouble (C function):   Conversion functions.
                                                             (line    6)
* PyTime_Check (C function):             DateTime オブジェクト<2>.
                                                             (line   97)
* PyTime_CheckExact (C function):        DateTime オブジェクト<2>.
                                                             (line  103)
* PyTime_FromTime (C function):          DateTime オブジェクト<2>.
                                                             (line  153)
* PyTime_FromTimeAndFold (C function):   DateTime オブジェクト<2>.
                                                             (line  158)
* PyTime_MAX (C var):                    Types.              (line   24)
* PyTime_MIN (C var):                    Types.              (line   20)
* PyTime_Monotonic (C function):         Clock Functions.    (line   21)
* PyTime_MonotonicRaw (C function):      Raw Clock Functions.
                                                             (line   16)
* PyTime_PerfCounter (C function):       Clock Functions.    (line   26)
* PyTime_PerfCounterRaw (C function):    Raw Clock Functions.
                                                             (line   21)
* PyTime_t (C type):                     Types.              (line    6)
* PyTime_Time (C function):              Clock Functions.    (line   31)
* PyTime_TimeRaw (C function):           Raw Clock Functions.
                                                             (line   26)
* PyTimeZone_FromOffset (C function):    DateTime オブジェクト<2>.
                                                             (line  172)
* PyTimeZone_FromOffsetAndName (C function): DateTime オブジェクト<2>.
                                                             (line  180)
* PyTrace_C_CALL (C var):                プロファイルとトレース profiling and tracing.
                                                             (line   93)
* PyTrace_C_EXCEPTION (C var):           プロファイルとトレース profiling and tracing.
                                                             (line   98)
* PyTrace_C_RETURN (C var):              プロファイルとトレース profiling and tracing.
                                                             (line  103)
* PyTrace_CALL (C var):                  プロファイルとトレース profiling and tracing.
                                                             (line   63)
* PyTrace_EXCEPTION (C var):             プロファイルとトレース profiling and tracing.
                                                             (line   71)
* PyTrace_LINE (C var):                  プロファイルとトレース profiling and tracing.
                                                             (line   81)
* PyTrace_OPCODE (C var):                プロファイルとトレース profiling and tracing.
                                                             (line  108)
* PyTrace_RETURN (C var):                プロファイルとトレース profiling and tracing.
                                                             (line   88)
* PyTraceMalloc_Track (C function):      tracemalloc C API.  (line    8)
* PyTraceMalloc_Untrack (C function):    tracemalloc C API.  (line   20)
* PyTuple_Check (C function):            タプルオブジェクト tuple object.
                                                             (line   16)
* PyTuple_CheckExact (C function):       タプルオブジェクト tuple object.
                                                             (line   21)
* PyTuple_GET_ITEM (C function):         タプルオブジェクト tuple object.
                                                             (line   60)
* PyTuple_GET_SIZE (C function):         タプルオブジェクト tuple object.
                                                             (line   43)
* PyTuple_GetItem (C function):          タプルオブジェクト tuple object.
                                                             (line   47)
* PyTuple_GetSlice (C function):         タプルオブジェクト tuple object.
                                                             (line   65)
* PyTuple_New (C function):              タプルオブジェクト tuple object.
                                                             (line   26)
* PyTuple_Pack (C function):             タプルオブジェクト tuple object.
                                                             (line   31)
* PyTuple_SET_ITEM (C function):         タプルオブジェクト tuple object.
                                                             (line   85)
* PyTuple_SetItem (C function):          参照カウントの詳細. (line   26)
* PyTuple_SetItem (C function) <1>:      タプルオブジェクト tuple object.
                                                             (line   74)
* PyTuple_Size (C function):             タプルオブジェクト tuple object.
                                                             (line   38)
* PyTuple_Type (C var):                  タプルオブジェクト tuple object.
                                                             (line   11)
* PyTupleObject (C type):                タプルオブジェクト tuple object.
                                                             (line    6)
* PyType_AddWatcher (C function):        型オブジェクト<2>.  (line   66)
* PyType_Check (C function):             型オブジェクト<2>.  (line   15)
* PyType_CheckExact (C function):        型オブジェクト<2>.  (line   21)
* PyType_ClearCache (C function):        型オブジェクト<2>.  (line   27)
* PyType_ClearWatcher (C function):      型オブジェクト<2>.  (line   75)
* PyType_FromMetaclass (C function):     Creating Heap-Allocated Types.
                                                             (line    9)
* PyType_FromModuleAndSpec (C function): Creating Heap-Allocated Types.
                                                             (line   59)
* PyType_FromSpec (C function):          Creating Heap-Allocated Types.
                                                             (line   96)
* PyType_FromSpecWithBases (C function): Creating Heap-Allocated Types.
                                                             (line   79)
* PyType_GenericAlloc (C function):      型オブジェクト<2>.  (line  133)
* PyType_GenericNew (C function):        型オブジェクト<2>.  (line  140)
* PyType_GetDict (C function):           型オブジェクト<2>.  (line   43)
* PyType_GetFlags (C function):          型オブジェクト<2>.  (line   31)
* PyType_GetFullyQualifiedName (C function): 型オブジェクト<2>.
                                                             (line  178)
* PyType_GetModule (C function):         型オブジェクト<2>.  (line  211)
* PyType_GetModuleByDef (C function):    型オブジェクト<2>.  (line  245)
* PyType_GetModuleName (C function):     型オブジェクト<2>.  (line  188)
* PyType_GetModuleState (C function):    型オブジェクト<2>.  (line  231)
* PyType_GetName (C function):           型オブジェクト<2>.  (line  163)
* PyType_GetQualName (C function):       型オブジェクト<2>.  (line  170)
* PyType_GetSlot (C function):           型オブジェクト<2>.  (line  196)
* PyType_GetTypeDataSize (C function):   オブジェクトプロトコル object protocol.
                                                             (line  530)
* PyType_HasFeature (C function):        型オブジェクト<2>.  (line  114)
* PyType_IS_GC (C function):             型オブジェクト<2>.  (line  119)
* PyType_IsSubtype (C function):         型オブジェクト<2>.  (line  124)
* PyType_Modified (C function):          型オブジェクト<2>.  (line   60)
* PyType_Ready (C function):             型オブジェクト<2>.  (line  147)
* PyType_Slot (C type):                  Creating Heap-Allocated Types.
                                                             (line  174)
* PyType_Slot.pfunc (C member):          Creating Heap-Allocated Types.
                                                             (line  241)
* PyType_Slot.slot (C member):           Creating Heap-Allocated Types.
                                                             (line  179)
* PyType_Spec (C type):                  Creating Heap-Allocated Types.
                                                             (line  109)
* PyType_Spec.basicsize (C member):      Creating Heap-Allocated Types.
                                                             (line  118)
* PyType_Spec.flags (C member):          Creating Heap-Allocated Types.
                                                             (line  160)
* PyType_Spec.itemsize (C member):       Creating Heap-Allocated Types.
                                                             (line  134)
* PyType_Spec.name (C member):           Creating Heap-Allocated Types.
                                                             (line  113)
* PyType_Spec.slots (C member):          Creating Heap-Allocated Types.
                                                             (line  167)
* PyType_Type (C var):                   型オブジェクト<2>.  (line   10)
* PyType_Watch (C function):             型オブジェクト<2>.  (line   87)
* PyType_WatchCallback (C type):         型オブジェクト<2>.  (line  103)
* PyTypeObject (C type):                 型オブジェクト<2>.  (line    6)
* PyTypeObject.tp_alloc (C member):      PyTypeObject スロット.
                                                             (line 1390)
* PyTypeObject.tp_as_async (C member):   PyTypeObject スロット.
                                                             (line  248)
* PyTypeObject.tp_as_buffer (C member):  PyTypeObject スロット.
                                                             (line  465)
* PyTypeObject.tp_as_mapping (C member): PyTypeObject スロット.
                                                             (line  316)
* PyTypeObject.tp_as_number (C member):  PyTypeObject スロット.
                                                             (line  292)
* PyTypeObject.tp_as_sequence (C member): PyTypeObject スロット.
                                                             (line  304)
* PyTypeObject.tp_base (C member):       PyTypeObject スロット.
                                                             (line 1210)
* PyTypeObject.tp_bases (C member):      PyTypeObject スロット.
                                                             (line 1508)
* PyTypeObject.tp_basicsize (C member):  PyTypeObject スロット.
                                                             (line   48)
* PyTypeObject.tp_cache (C member):      PyTypeObject スロット.
                                                             (line 1543)
* PyTypeObject.tp_call (C member):       PyTypeObject スロット.
                                                             (line  369)
* PyTypeObject.tp_clear (C member):      PyTypeObject スロット.
                                                             (line  930)
* PyTypeObject.tp_dealloc (C member):    PyTypeObject スロット.
                                                             (line  101)
* PyTypeObject.tp_del (C member):        PyTypeObject スロット.
                                                             (line 1583)
* PyTypeObject.tp_descr_get (C member):  PyTypeObject スロット.
                                                             (line 1280)
* PyTypeObject.tp_descr_set (C member):  PyTypeObject スロット.
                                                             (line 1293)
* PyTypeObject.tp_dict (C member):       PyTypeObject スロット.
                                                             (line 1243)
* PyTypeObject.tp_dictoffset (C member): PyTypeObject スロット.
                                                             (line 1309)
* PyTypeObject.tp_doc (C member):        PyTypeObject スロット.
                                                             (line  827)
* PyTypeObject.tp_finalize (C member):   PyTypeObject スロット.
                                                             (line 1598)
* PyTypeObject.tp_flags (C member):      PyTypeObject スロット.
                                                             (line  478)
* PyTypeObject.tp_free (C member):       PyTypeObject スロット.
                                                             (line 1452)
* PyTypeObject.tp_getattr (C member):    PyTypeObject スロット.
                                                             (line  208)
* PyTypeObject.tp_getattro (C member):   PyTypeObject スロット.
                                                             (line  410)
* PyTypeObject.tp_getset (C member):     PyTypeObject スロット.
                                                             (line 1195)
* PyTypeObject.tp_hash (C member):       PyTypeObject スロット.
                                                             (line  328)
* PyTypeObject.tp_init (C member):       PyTypeObject スロット.
                                                             (line 1353)
* PyTypeObject.tp_is_gc (C member):      PyTypeObject スロット.
                                                             (line 1477)
* PyTypeObject.tp_itemsize (C member):   PyTypeObject スロット.
                                                             (line   48)
* PyTypeObject.tp_iter (C member):       PyTypeObject スロット.
                                                             (line 1124)
* PyTypeObject.tp_iternext (C member):   PyTypeObject スロット.
                                                             (line 1141)
* PyTypeObject.tp_members (C member):    PyTypeObject スロット.
                                                             (line 1180)
* PyTypeObject.tp_methods (C member):    PyTypeObject スロット.
                                                             (line 1165)
* PyTypeObject.tp_mro (C member):        PyTypeObject スロット.
                                                             (line 1529)
* PyTypeObject.tp_name (C member):       PyTypeObject スロット.
                                                             (line   12)
* PyTypeObject.tp_new (C member):        PyTypeObject スロット.
                                                             (line 1414)
* PyTypeObject.tp_repr (C member):       PyTypeObject スロット.
                                                             (line  265)
* PyTypeObject.tp_richcompare (C member): PyTypeObject スロット.
                                                             (line 1012)
* PyTypeObject.tp_setattr (C member):    PyTypeObject スロット.
                                                             (line  228)
* PyTypeObject.tp_setattro (C member):   PyTypeObject スロット.
                                                             (line  437)
* PyTypeObject.tp_str (C member):        PyTypeObject スロット.
                                                             (line  383)
* PyTypeObject.tp_subclasses (C member): PyTypeObject スロット.
                                                             (line 1552)
* PyTypeObject.tp_traverse (C member):   PyTypeObject スロット.
                                                             (line  837)
* PyTypeObject.tp_vectorcall (C member): PyTypeObject スロット.
                                                             (line 1645)
* PyTypeObject.tp_vectorcall_offset (C member): PyTypeObject スロット.
                                                             (line  168)
* PyTypeObject.tp_version_tag (C member): PyTypeObject スロット.
                                                             (line 1589)
* PyTypeObject.tp_watched (C member):    PyTypeObject スロット.
                                                             (line 1661)
* PyTypeObject.tp_weaklist (C member):   PyTypeObject スロット.
                                                             (line 1568)
* PyTypeObject.tp_weaklistoffset (C member): PyTypeObject スロット.
                                                             (line 1088)
* PyTZInfo_Check (C function):           DateTime オブジェクト<2>.
                                                             (line  120)
* PyTZInfo_CheckExact (C function):      DateTime オブジェクト<2>.
                                                             (line  127)
* PyUnicode_1BYTE_DATA (C function):     Unicode 型.         (line   77)
* PyUnicode_1BYTE_KIND (C macro):        Unicode 型.         (line   91)
* PyUnicode_2BYTE_DATA (C function):     Unicode 型.         (line   77)
* PyUnicode_2BYTE_KIND (C macro):        Unicode 型.         (line   91)
* PyUnicode_4BYTE_DATA (C function):     Unicode 型.         (line   77)
* PyUnicode_4BYTE_KIND (C macro):        Unicode 型.         (line   91)
* PyUnicode_AsASCIIString (C function):  ASCII Codecs.       (line   16)
* PyUnicode_AsCharmapString (C function): Character Map Codecs.
                                                             (line   31)
* PyUnicode_AsEncodedString (C function): 汎用 codec.        (line   17)
* PyUnicode_AsLatin1String (C function): Latin-1 Codecs.     (line   16)
* PyUnicode_AsMBCSString (C function):   Windows 用の MBCS codec.
                                                             (line   30)
* PyUnicode_AsRawUnicodeEscapeString (C function): Raw-Unicode-Escape Codecs.
                                                             (line   15)
* PyUnicode_AsUCS4 (C function):         Unicode 文字列の生成とアクセス.
                                                             (line  357)
* PyUnicode_AsUCS4Copy (C function):     Unicode 文字列の生成とアクセス.
                                                             (line  368)
* PyUnicode_AsUnicodeEscapeString (C function): Unicode-Escape Codecs.
                                                             (line   15)
* PyUnicode_AsUTF16String (C function):  UTF-16 Codecs.      (line   48)
* PyUnicode_AsUTF32String (C function):  UTF-32 Codecs.      (line   46)
* PyUnicode_AsUTF8 (C function):         UTF-8 Codecs.       (line   64)
* PyUnicode_AsUTF8AndSize (C function):  UTF-8 Codecs.       (line   34)
* PyUnicode_AsUTF8String (C function):   UTF-8 Codecs.       (line   24)
* PyUnicode_AsWideChar (C function):     wchar_t サポート.   (line   16)
* PyUnicode_AsWideCharString (C function): wchar_t サポート. (line   34)
* PyUnicode_Check (C function):          Unicode 型.         (line   50)
* PyUnicode_CheckExact (C function):     Unicode 型.         (line   55)
* PyUnicode_Compare (C function):        メソッドおよびスロット関数 slot function.
                                                             (line   90)
* PyUnicode_CompareWithASCIIString (C function): メソッドおよびスロット関数 slot function.
                                                             (line  120)
* PyUnicode_Concat (C function):         メソッドおよびスロット関数 slot function.
                                                             (line   13)
* PyUnicode_Contains (C function):       メソッドおよびスロット関数 slot function.
                                                             (line  154)
* PyUnicode_CopyCharacters (C function): Unicode 文字列の生成とアクセス.
                                                             (line  294)
* PyUnicode_Count (C function):          メソッドおよびスロット関数 slot function.
                                                             (line   76)
* PyUnicode_DATA (C function):           Unicode 型.         (line  110)
* PyUnicode_Decode (C function):         汎用 codec.         (line    8)
* PyUnicode_DecodeASCII (C function):    ASCII Codecs.       (line    9)
* PyUnicode_DecodeCharmap (C function):  Character Map Codecs.
                                                             (line   15)
* PyUnicode_DecodeFSDefault (C function): ファイルシステムエンコーディング.
                                                             (line   61)
* PyUnicode_DecodeFSDefaultAndSize (C function): ファイルシステムエンコーディング.
                                                             (line   44)
* PyUnicode_DecodeLatin1 (C function):   Latin-1 Codecs.     (line    9)
* PyUnicode_DecodeLocale (C function):   ロケールエンコーディング.
                                                             (line   37)
* PyUnicode_DecodeLocaleAndSize (C function): ロケールエンコーディング.
                                                             (line    9)
* PyUnicode_DecodeMBCS (C function):     Windows 用の MBCS codec.
                                                             (line   13)
* PyUnicode_DecodeMBCSStateful (C function): Windows 用の MBCS codec.
                                                             (line   20)
* PyUnicode_DecodeRawUnicodeEscape (C function): Raw-Unicode-Escape Codecs.
                                                             (line    8)
* PyUnicode_DecodeUnicodeEscape (C function): Unicode-Escape Codecs.
                                                             (line    8)
* PyUnicode_DecodeUTF16 (C function):    UTF-16 Codecs.      (line    8)
* PyUnicode_DecodeUTF16Stateful (C function): UTF-16 Codecs. (line   37)
* PyUnicode_DecodeUTF32 (C function):    UTF-32 Codecs.      (line    8)
* PyUnicode_DecodeUTF32Stateful (C function): UTF-32 Codecs. (line   35)
* PyUnicode_DecodeUTF7 (C function):     UTF-7 Codecs.       (line    8)
* PyUnicode_DecodeUTF7Stateful (C function): UTF-7 Codecs.   (line   15)
* PyUnicode_DecodeUTF8 (C function):     UTF-8 Codecs.       (line    8)
* PyUnicode_DecodeUTF8Stateful (C function): UTF-8 Codecs.   (line   15)
* PyUnicode_EncodeCodePage (C function): Windows 用の MBCS codec.
                                                             (line   38)
* PyUnicode_EncodeFSDefault (C function): ファイルシステムエンコーディング.
                                                             (line   73)
* PyUnicode_EncodeLocale (C function):   ロケールエンコーディング.
                                                             (line   46)
* PyUnicode_EqualToUTF8 (C function):    メソッドおよびスロット関数 slot function.
                                                             (line  111)
* PyUnicode_EqualToUTF8AndSize (C function): メソッドおよびスロット関数 slot function.
                                                             (line   98)
* PyUnicode_Fill (C function):           Unicode 文字列の生成とアクセス.
                                                             (line  305)
* PyUnicode_Find (C function):           メソッドおよびスロット関数 slot function.
                                                             (line   49)
* PyUnicode_FindChar (C function):       メソッドおよびスロット関数 slot function.
                                                             (line   60)
* PyUnicode_Format (C function):         メソッドおよびスロット関数 slot function.
                                                             (line  148)
* PyUnicode_FromEncodedObject (C function): Unicode 文字列の生成とアクセス.
                                                             (line  266)
* PyUnicode_FromFormat (C function):     Unicode 文字列の生成とアクセス.
                                                             (line   62)
* PyUnicode_FromFormatV (C function):    Unicode 文字列の生成とアクセス.
                                                             (line  251)
* PyUnicode_FromKindAndData (C function): Unicode 文字列の生成とアクセス.
                                                             (line   23)
* PyUnicode_FromObject (C function):     Unicode 文字列の生成とアクセス.
                                                             (line  257)
* PyUnicode_FromString (C function):     Unicode 文字列の生成とアクセス.
                                                             (line   56)
* PyUnicode_FromStringAndSize (C function): Unicode 文字列の生成とアクセス.
                                                             (line   39)
* PyUnicode_FromWideChar (C function):   wchar_t サポート.   (line    8)
* PyUnicode_FSConverter (C function):    ファイルシステムエンコーディング.
                                                             (line   13)
* PyUnicode_FSDecoder (C function):      ファイルシステムエンコーディング.
                                                             (line   30)
* PyUnicode_GET_LENGTH (C function):     Unicode 型.         (line   68)
* PyUnicode_GetLength (C function):      Unicode 文字列の生成とアクセス.
                                                             (line  285)
* PyUnicode_InternFromString (C function): メソッドおよびスロット関数 slot function.
                                                             (line  188)
* PyUnicode_InternInPlace (C function):  メソッドおよびスロット関数 slot function.
                                                             (line  162)
* PyUnicode_IsIdentifier (C function):   Unicode 型.         (line  159)
* PyUnicode_Join (C function):           メソッドおよびスロット関数 slot function.
                                                             (line   35)
* PyUnicode_KIND (C function):           Unicode 型.         (line  101)
* PyUnicode_MAX_CHAR_VALUE (C function): Unicode 型.         (line  149)
* PyUnicode_New (C function):            Unicode 文字列の生成とアクセス.
                                                             (line    9)
* PyUnicode_READ (C function):           Unicode 型.         (line  130)
* PyUnicode_READ_CHAR (C function):      Unicode 型.         (line  139)
* PyUnicode_ReadChar (C function):       Unicode 文字列の生成とアクセス.
                                                             (line  335)
* PyUnicode_READY (C function):          Unicode 型.         (line   60)
* PyUnicode_Replace (C function):        メソッドおよびスロット関数 slot function.
                                                             (line   82)
* PyUnicode_RichCompare (C function):    メソッドおよびスロット関数 slot function.
                                                             (line  131)
* PyUnicode_Split (C function):          メソッドおよびスロット関数 slot function.
                                                             (line   18)
* PyUnicode_Splitlines (C function):     メソッドおよびスロット関数 slot function.
                                                             (line   27)
* PyUnicode_Substring (C function):      Unicode 文字列の生成とアクセス.
                                                             (line  347)
* PyUnicode_Tailmatch (C function):      メソッドおよびスロット関数 slot function.
                                                             (line   41)
* PyUnicode_Translate (C function):      Character Map Codecs.
                                                             (line   47)
* PyUnicode_Type (C var):                Unicode 型.         (line   42)
* PyUnicode_WRITE (C function):          Unicode 型.         (line  118)
* PyUnicode_WriteChar (C function):      Unicode 文字列の生成とアクセス.
                                                             (line  319)
* PyUnicodeDecodeError_Create (C function): Unicode 例外オブジェクト.
                                                             (line    9)
* PyUnicodeDecodeError_GetEncoding (C function): Unicode 例外オブジェクト.
                                                             (line   17)
* PyUnicodeDecodeError_GetEnd (C function): Unicode 例外オブジェクト.
                                                             (line   54)
* PyUnicodeDecodeError_GetObject (C function): Unicode 例外オブジェクト.
                                                             (line   24)
* PyUnicodeDecodeError_GetReason (C function): Unicode 例外オブジェクト.
                                                             (line   74)
* PyUnicodeDecodeError_GetStart (C function): Unicode 例外オブジェクト.
                                                             (line   33)
* PyUnicodeDecodeError_SetEnd (C function): Unicode 例外オブジェクト.
                                                             (line   64)
* PyUnicodeDecodeError_SetReason (C function): Unicode 例外オブジェクト.
                                                             (line   83)
* PyUnicodeDecodeError_SetStart (C function): Unicode 例外オブジェクト.
                                                             (line   44)
* PyUnicodeEncodeError_GetEncoding (C function): Unicode 例外オブジェクト.
                                                             (line   17)
* PyUnicodeEncodeError_GetEnd (C function): Unicode 例外オブジェクト.
                                                             (line   54)
* PyUnicodeEncodeError_GetObject (C function): Unicode 例外オブジェクト.
                                                             (line   24)
* PyUnicodeEncodeError_GetReason (C function): Unicode 例外オブジェクト.
                                                             (line   74)
* PyUnicodeEncodeError_GetStart (C function): Unicode 例外オブジェクト.
                                                             (line   33)
* PyUnicodeEncodeError_SetEnd (C function): Unicode 例外オブジェクト.
                                                             (line   64)
* PyUnicodeEncodeError_SetReason (C function): Unicode 例外オブジェクト.
                                                             (line   83)
* PyUnicodeEncodeError_SetStart (C function): Unicode 例外オブジェクト.
                                                             (line   44)
* PyUnicodeObject (C type):              Unicode 型.         (line   30)
* PyUnicodeTranslateError_GetEnd (C function): Unicode 例外オブジェクト.
                                                             (line   54)
* PyUnicodeTranslateError_GetObject (C function): Unicode 例外オブジェクト.
                                                             (line   24)
* PyUnicodeTranslateError_GetReason (C function): Unicode 例外オブジェクト.
                                                             (line   74)
* PyUnicodeTranslateError_GetStart (C function): Unicode 例外オブジェクト.
                                                             (line   33)
* PyUnicodeTranslateError_SetEnd (C function): Unicode 例外オブジェクト.
                                                             (line   64)
* PyUnicodeTranslateError_SetReason (C function): Unicode 例外オブジェクト.
                                                             (line   83)
* PyUnicodeTranslateError_SetStart (C function): Unicode 例外オブジェクト.
                                                             (line   44)
* PyUnstable:                            Unstable C API.     (line    6)
* PyUnstable_Code_GetExtra (C function): Extra information.  (line   35)
* PyUnstable_Code_GetFirstFree (C function): コードオブジェクト<3>.
                                                             (line   31)
* PyUnstable_Code_New (C function):      コードオブジェクト<3>.
                                                             (line   41)
* PyUnstable_Code_NewWithPosOnlyArgs (C function): コードオブジェクト<3>.
                                                             (line   68)
* PyUnstable_Code_SetExtra (C function): Extra information.  (line   51)
* PyUnstable_Eval_RequestCodeExtraIndex (C function): Extra information.
                                                             (line   14)
* PyUnstable_Exc_PrepReraiseStar (C function): 例外オブジェクト.
                                                             (line   57)
* PyUnstable_GC_VisitObjects (C function): Querying Garbage Collector State.
                                                             (line    9)
* PyUnstable_InterpreterFrame_GetCode (C function): Internal Frames.
                                                             (line   14)
* PyUnstable_InterpreterFrame_GetLasti (C function): Internal Frames.
                                                             (line   23)
* PyUnstable_InterpreterFrame_GetLine (C function): Internal Frames.
                                                             (line   31)
* PyUnstable_Long_CompactValue (C function): 整数型オブジェクト integer object.
                                                             (line  529)
* PyUnstable_Long_IsCompact (C function): 整数型オブジェクト integer object.
                                                             (line  511)
* PyUnstable_Module_SetGIL (C function): サポート関数.       (line  157)
* PyUnstable_Object_ClearWeakRefsNoCallbacks (C function): 弱参照オブジェクト<2>.
                                                             (line   97)
* PyUnstable_Object_GC_NewWithExtraData (C function): 循環参照ガベージコレクションをサポートする.
                                                             (line   66)
* PyUnstable_PerfMapState_Fini (C function): Support for Perf Maps.
                                                             (line   48)
* PyUnstable_PerfMapState_Init (C function): Support for Perf Maps.
                                                             (line   19)
* PyUnstable_Type_AssignVersionTag (C function): 型オブジェクト<2>.
                                                             (line  262)
* PyUnstable_WritePerfMapEntry (C function): Support for Perf Maps.
                                                             (line   33)
* PyVarObject (C type):                  Base object types and macros.
                                                             (line   26)
* PyVarObject_HEAD_INIT (C macro):       Base object types and macros.
                                                             (line  131)
* PyVarObject.ob_size (C member):        PyVarObject スロット.
                                                             (line    6)
* PyVectorcall_Call (C function):        Vectorcall Support API.
                                                             (line   32)
* PyVectorcall_Function (C function):    Vectorcall Support API.
                                                             (line   18)
* PyVectorcall_NARGS (C function):       Vectorcall Support API.
                                                             (line    6)
* PyWeakref_Check (C function):          弱参照オブジェクト<2>.
                                                             (line   11)
* PyWeakref_CheckProxy (C function):     弱参照オブジェクト<2>.
                                                             (line   21)
* PyWeakref_CheckRef (C function):       弱参照オブジェクト<2>.
                                                             (line   16)
* PyWeakref_GET_OBJECT (C function):     弱参照オブジェクト<2>.
                                                             (line   82)
* PyWeakref_GetObject (C function):      弱参照オブジェクト<2>.
                                                             (line   67)
* PyWeakref_GetRef (C function):         弱参照オブジェクト<2>.
                                                             (line   53)
* PyWeakref_NewProxy (C function):       弱参照オブジェクト<2>.
                                                             (line   40)
* PyWeakref_NewRef (C function):         弱参照オブジェクト<2>.
                                                             (line   26)
* PyWideStringList (C type):             PyWideStringList.   (line    6)
* PyWideStringList_Append (C function):  PyWideStringList.   (line   15)
* PyWideStringList_Insert (C function):  PyWideStringList.   (line   22)
* PyWideStringList.items (C member):     PyWideStringList.   (line   41)
* PyWideStringList.length (C member):    PyWideStringList.   (line   37)
* PyWrapper_New (C function):            デスクリプタオブジェクト descriptor object.
                                                             (line   41)
* PyZipFile (zipfile のクラス):          PyZipFile オブジェクト.
                                                             (line    9)
* qiflush() (curses モジュール):         関数<6>.            (line  385)
* QName (xml.etree.ElementTree のクラス): QName オブジェクト.
                                                             (line    6)
* qsize() (asyncio.Queue のメソッド):    Queue.              (line   79)
* qsize() (multiprocessing.Queue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  107)
* qsize() (queue.Queue のメソッド):      キューオブジェクト. (line    9)
* qsize() (queue.SimpleQueue のメソッド): SimpleQueue オブジェクト.
                                                             (line    9)
* qualified name:                        用語集<2>.          (line 1235)
* quantiles() (statistics モジュール):   関数の詳細.         (line  483)
* quantiles() (statistics.NormalDist のメソッド): NormalDist オブジェクト.
                                                             (line  109)
* quantize() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  468)
* quantize() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  452)
* QueryInfoKey() (winreg モジュール):    関数<13>.           (line  317)
* QueryReflectionKey() (winreg モジュール): 関数<13>.        (line  512)
* QueryValue() (winreg モジュール):      関数<13>.           (line  345)
* QueryValueEx() (winreg モジュール):    関数<13>.           (line  365)
* QUESTION (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  196)
* Queue (asyncio のクラス):              Queue.              (line    6)
* Queue (multiprocessing のクラス):      パイプ Pipe とキュー Queue.
                                                             (line   92)
* Queue (queue のクラス):                queue --- 同期キュークラス.
                                                             (line   33)
* queue (sched.scheduler の属性):        スケジューラオブジェクト.
                                                             (line   73)
* Queue() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  200)
* QueueEmpty:                            例外<11>.           (line    6)
* QueueFull:                             例外<11>.           (line   11)
* QueueHandler (logging.handlers のクラス): QueueHandler.    (line   21)
* QueueListener (logging.handlers のクラス): QueueListener.  (line   24)
* QueueShutDown:                         例外<11>.           (line   16)
* quick_ratio() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line  201)
* quiet (sys.flags の属性):              sys --- システム固有のパラメーターと関数.
                                                             (line  545)
* quit (pdb command):                    デバッガコマンド.   (line  421)
* quit (組み込み変数):                   site モジュールで追加される定数.
                                                             (line   11)
* quit() (ftplib.FTP のメソッド):        FTP オブジェクト.   (line  357)
* quit() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   82)
* quit() (smtplib.SMTP のメソッド):      SMTP オブジェクト.  (line  332)
* quit() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  122)
* quitting (bdb.Bdb attribute):          bdb --- デバッガーフレームワーク.
                                                             (line  340)
* QUOTE_ALL (csv モジュール):            モジュールコンテンツ<3>.
                                                             (line  265)
* quote_from_bytes() (urllib.parse モジュール): URL のクオート.
                                                             (line   52)
* QUOTE_MINIMAL (csv モジュール):        モジュールコンテンツ<3>.
                                                             (line  270)
* QUOTE_NONE (csv モジュール):           モジュールコンテンツ<3>.
                                                             (line  284)
* QUOTE_NONNUMERIC (csv モジュール):     モジュールコンテンツ<3>.
                                                             (line  276)
* QUOTE_NOTNULL (csv モジュール):        モジュールコンテンツ<3>.
                                                             (line  295)
* quote_plus() (urllib.parse モジュール): URL のクオート.    (line   40)
* QUOTE_STRINGS (csv モジュール):        モジュールコンテンツ<3>.
                                                             (line  307)
* quote() (email.utils モジュール):      email utils Miscellaneous utilities.
                                                             (line   45)
* quote() (shlex モジュール):            shlex --- 単純な字句解析.
                                                             (line   42)
* quote() (urllib.parse モジュール):     URL のクオート.     (line   11)
* quoteattr() (xml.sax.saxutils モジュール): xml sax saxutils --- SAX ユーティリティー.
                                                             (line   38)
* quotechar (csv.Dialect の属性):        Dialect クラスと書式化パラメータ.
                                                             (line   56)
* quoted-printable;encoding:             quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line    8)
* quotes (shlex.shlex の属性):           shlex オブジェクト. (line  114)
* quoting (csv.Dialect の属性):          Dialect クラスと書式化パラメータ.
                                                             (line   64)
* R_OK (os モジュール):                  ファイルとディレクトリ.
                                                             (line  109)
* r';raw string literal:                 文字列およびバイト列リテラル.
                                                             (line   51)
* r";raw string literal:                 文字列およびバイト列リテラル.
                                                             (line   51)
* radians() (math モジュール):           角度変換.           (line   10)
* radians() (turtle モジュール):         設定と計測.         (line   28)
* radix (sys.float_info の属性):         sys --- システム固有のパラメーターと関数.
                                                             (line  653)
* radix() (decimal.Context のメソッド):  Context オブジェクト.
                                                             (line  472)
* radix() (decimal.Decimal のメソッド):  Decimal オブジェクト.
                                                             (line  477)
* RADIXCHAR (locale モジュール):         locale --- 国際化サービス.
                                                             (line  253)
* Raise (ast のクラス):                  文 Statements.      (line  113)
* RAISE (monitoring event):              Events.             (line   71)
* raise_on_defect (email.policy.Policy の属性): email policy Policy Objects.
                                                             (line  179)
* raise_signal() (signal モジュール):    モジュールの内容<2>.
                                                             (line  322)
* RAISE_VARARGS (opcode):                Python バイトコード命令.
                                                             (line 1003)
* raiseExceptions (logging モジュール):  モジュールレベル属性.
                                                             (line   19)
* raising;例外:                          raise 文.           (line    6)
* RAND_add() (ssl モジュール):           乱数生成.           (line   32)
* RAND_bytes() (ssl モジュール):         乱数生成.           (line    6)
* RAND_status() (ssl モジュール):        乱数生成.           (line   25)
* randbelow() (secrets モジュール):      乱数.               (line   19)
* randbits() (secrets モジュール):       乱数.               (line   23)
* randbytes() (random モジュール):       バイト列用の関数.   (line    6)
* randint() (random モジュール):         整数用の関数.       (line   31)
* Random (random のクラス):              他の生成器.         (line    6)
* random コマンドラインオプション; -c:   コマンドラインでの使用.
                                                             (line   18)
* random コマンドラインオプション; -choice: コマンドラインでの使用.
                                                             (line   18)
* random コマンドラインオプション; -f:   コマンドラインでの使用.
                                                             (line   29)
* random コマンドラインオプション; -float: コマンドラインでの使用.
                                                             (line   29)
* random コマンドラインオプション; -h:   コマンドラインでの使用.
                                                             (line   14)
* random コマンドラインオプション; -help: コマンドラインでの使用.
                                                             (line   14)
* random コマンドラインオプション; -i:   コマンドラインでの使用.
                                                             (line   23)
* random コマンドラインオプション; -integer: コマンドラインでの使用.
                                                             (line   23)
* random() (random モジュール):          実数分布.           (line   10)
* random() (random.Random のメソッド):   他の生成器.         (line   34)
* randrange() (random モジュール):       整数用の関数.       (line    6)
* range (組み込みクラス):                range.              (line    9)
* RARROW (token モジュール):             token --- Python 解析木で使われる定数.
                                                             (line  227)
* ratio() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line  177)
* Rational (numbers のクラス):           数値塔.             (line   41)
* raw (io.BufferedIOBase の属性):        I/O 基底クラス.     (line  250)
* raw 文字列:                            文字列およびバイト列リテラル.
                                                             (line   36)
* raw_data_manager (email.contentmanager モジュール): Content Manager Instances.
                                                             (line   11)
* raw_decode() (json.JSONDecoder のメソッド): エンコーダとデコーダ.
                                                             (line   96)
* raw_input() (code.InteractiveConsole のメソッド): 対話的なコンソールオブジェクト.
                                                             (line   45)
* raw() (curses モジュール):             関数<6>.            (line  391)
* raw() (pickle.PickleBuffer のメソッド): モジュールインターフェース.
                                                             (line  331)
* RawArray() (multiprocessing.sharedctypes モジュール): multiprocessing sharedctypes モジュール.
                                                             (line   16)
* RawConfigParser (configparser のクラス): RawConfigParser オブジェクト.
                                                             (line    6)
* RawDescriptionHelpFormatter (argparse のクラス): formatter_class.
                                                             (line   10)
* RawIOBase (io のクラス):               I/O 基底クラス.     (line  170)
* RawPen (turtle のクラス):              Public classes.     (line    6)
* RawTextHelpFormatter (argparse のクラス): formatter_class. (line   10)
* RawTurtle (turtle のクラス):           Public classes.     (line    6)
* RawValue() (multiprocessing.sharedctypes モジュール): multiprocessing sharedctypes モジュール.
                                                             (line   33)
* RBRACE (token モジュール):             token --- Python 解析木で使われる定数.
                                                             (line  127)
* re (re.Match の属性):                  マッチオブジェクト. (line  196)
* READ (inspect.BufferFlags の属性):     Buffer flags.       (line   49)
* read_binary() (importlib.resources モジュール): 関数 API.  (line   75)
* read_byte() (mmap.mmap のメソッド):    mmap --- メモリマップファイルのサポート.
                                                             (line  255)
* read_bytes() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  546)
* read_bytes() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  150)
* read_bytes() (pathlib.Path のメソッド): ファイルを読み書きする<2>.
                                                             (line   35)
* read_bytes() (zipfile.Path のメソッド): Path オブジェクト. (line  100)
* read_dict() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  206)
* read_environ() (wsgiref.handlers モジュール): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  303)
* read_events() (xml.etree.ElementTree.XMLPullParser のメソッド): XMLPullParser オブジェクト.
                                                             (line   49)
* read_file() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  184)
* read_history_file() (readline モジュール): 履歴ファイル.   (line    8)
* read_init_file() (readline モジュール): 初期化ファイル.    (line   13)
* read_mime_types() (mimetypes モジュール): mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  113)
* READ_RESTRICTED (C macro):             Member flags.       (line   32)
* read_string() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  196)
* read_text() (importlib.abc.Traversable のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  550)
* read_text() (importlib.resources モジュール): 関数 API.    (line   89)
* read_text() (importlib.resources.abc.Traversable のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  154)
* read_text() (pathlib.Path のメソッド): ファイルを読み書きする<2>.
                                                             (line   18)
* read_text() (zipfile.Path のメソッド): Path オブジェクト.  (line   88)
* read_token() (shlex.shlex のメソッド): shlex オブジェクト. (line   20)
* read_windows_registry() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line   94)
* read() (asyncio.StreamReader のメソッド): StreamReader.    (line   20)
* read() (codecs.StreamReader のメソッド): StreamReader オブジェクト.
                                                             (line   36)
* read() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  146)
* read() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   14)
* read() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line  202)
* read() (io.BufferedIOBase のメソッド): I/O 基底クラス.     (line  270)
* read() (io.BufferedReader のメソッド): バッファ付きストリーム.
                                                             (line   84)
* read() (io.RawIOBase のメソッド):      I/O 基底クラス.     (line  183)
* read() (io.TextIOBase のメソッド):     テキスト I/O<2>.    (line   51)
* read() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line   74)
* read() (mmap.mmap のメソッド):         mmap --- メモリマップファイルのサポート.
                                                             (line  244)
* read() (os モジュール):                ファイル記述子の操作.
                                                             (line  729)
* read() (sqlite3.Blob のメソッド):      Blob オブジェクト.  (line   46)
* read() (ssl.MemoryBIO のメソッド):     メモリ BIO サポート<2>.
                                                             (line  145)
* read() (ssl.SSLSocket のメソッド):     SSL ソケット.       (line   77)
* read() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   25)
* read() (zipfile.ZipFile のメソッド):   ZipFile オブジェクト.
                                                             (line  251)
* read1() (bz2.BZ2File のメソッド):      ファイルの圧縮/解凍.
                                                             (line  110)
* read1() (io.BufferedIOBase のメソッド): I/O 基底クラス.    (line  287)
* read1() (io.BufferedReader のメソッド): バッファ付きストリーム.
                                                             (line   90)
* read1() (io.BytesIO のメソッド):       バッファ付きストリーム.
                                                             (line   43)
* READABLE (_tkinter モジュール):        ファイルハンドラ.   (line   42)
* readable() (bz2.BZ2File のメソッド):   ファイルの圧縮/解凍.
                                                             (line   92)
* readable() (io.IOBase のメソッド):     I/O 基底クラス.     (line   77)
* readall() (io.RawIOBase のメソッド):   I/O 基底クラス.     (line  199)
* reader() (csv モジュール):             モジュールコンテンツ<3>.
                                                             (line    8)
* ReadError:                             tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  211)
* readexactly() (asyncio.StreamReader のメソッド): StreamReader.
                                                             (line   47)
* readfp() (mimetypes.MimeTypes のメソッド): Mime 型オブジェクト.
                                                             (line   84)
* readframes() (wave.Wave_read のメソッド): Wave_read オブジェクト.
                                                             (line   52)
* readinto() (bz2.BZ2File のメソッド):   ファイルの圧縮/解凍.
                                                             (line  120)
* readinto() (http.client.HTTPResponse のメソッド): HTTPResponse オブジェクト.
                                                             (line   18)
* readinto() (io.BufferedIOBase のメソッド): I/O 基底クラス. (line  299)
* readinto() (io.RawIOBase のメソッド):  I/O 基底クラス.     (line  204)
* readinto1() (io.BufferedIOBase のメソッド): I/O 基底クラス.
                                                             (line  313)
* readinto1() (io.BytesIO のメソッド):   バッファ付きストリーム.
                                                             (line   50)
* readline() (asyncio.StreamReader のメソッド): StreamReader.
                                                             (line   36)
* readline() (codecs.StreamReader のメソッド): StreamReader オブジェクト.
                                                             (line   60)
* readline() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  207)
* readline() (io.IOBase のメソッド):     I/O 基底クラス.     (line   82)
* readline() (io.TextIOBase のメソッド): テキスト I/O<2>.    (line   57)
* readline() (mmap.mmap のメソッド):     mmap --- メモリマップファイルのサポート.
                                                             (line  260)
* readlines() (codecs.StreamReader のメソッド): StreamReader オブジェクト.
                                                             (line   70)
* readlines() (io.IOBase のメソッド):    I/O 基底クラス.     (line   91)
* readlink() (os モジュール):            ファイルとディレクトリ.
                                                             (line  687)
* readlink() (pathlib.Path のメソッド):  パスの展開と解決.   (line   80)
* readmodule_ex() (pyclbr モジュール):   pyclbr --- Python モジュールブラウザーサポート.
                                                             (line   31)
* readmodule() (pyclbr モジュール):      pyclbr --- Python モジュールブラウザーサポート.
                                                             (line   19)
* READONLY (C macro):                    Member flags.       (line   37)
* readonly (memoryview の属性):          メモリビュー.       (line  414)
* ReadOnly (typing モジュール):          特殊形式.           (line  236)
* ReadTransport (asyncio のクラス):      トランスポートのクラス階層構造.
                                                             (line   20)
* readuntil() (asyncio.StreamReader のメソッド): StreamReader.
                                                             (line   56)
* readv() (os モジュール):               ファイル記述子の操作.
                                                             (line  864)
* ready() (multiprocessing.pool.AsyncResult のメソッド): プロセスプール.
                                                             (line  214)
* Real (numbers のクラス):               数値塔.             (line   28)
* real (numbers.Complex の属性):         数値塔.             (line   15)
* real_max_memuse (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  152)
* real_quick_ratio() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line  205)
* realloc (C function):                  概要<4>.            (line   33)
* realpath() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  369)
* REALTIME_PRIORITY_CLASS (subprocess モジュール): Windows Constants.
                                                             (line  103)
* reap_children() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  587)
* reap_threads() (test.support.threading_helper モジュール): test support threading_helper --- Utilities for threading tests.
                                                             (line   17)
* reason (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   66)
* reason (ssl.SSLError の属性):          例外<15>.           (line   26)
* reason (UnicodeError の属性):          具象例外.           (line  417)
* reason (urllib.error.HTTPError の属性): urllib error --- urllib request によって送出される例外クラス.
                                                             (line   48)
* reason (urllib.error.URLError の属性): urllib error --- urllib request によって送出される例外クラス.
                                                             (line   21)
* reattach() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  236)
* rebinding;name:                        代入文 assignment statement.
                                                             (line    6)
* recent() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  212)
* reconfigure() (io.TextIOWrapper のメソッド): テキスト I/O<2>.
                                                             (line  176)
* record_original_stdout() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  312)
* RECORDS (inspect.BufferFlags の属性):  Buffer flags.       (line   41)
* records (unittest.TestCase の属性):    テストクラス.       (line  439)
* RECORDS_RO (inspect.BufferFlags の属性): Buffer flags.     (line   43)
* rect() (cmath モジュール):             極座標変換.         (line   41)
* rectangle() (curses.textpad モジュール): curses textpad --- curses プログラムのためのテキスト入力ウィジェット.
                                                             (line   15)
* RecursionError:                        具象例外.           (line  223)
* recursive_repr() (reprlib モジュール): reprlib --- もう一つの repr の実装.
                                                             (line   59)
* recv_bytes_into() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   80)
* recv_bytes() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   66)
* recv_fds() (socket モジュール):        その他の関数<2>.    (line  474)
* recv_into() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  388)
* recv() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   24)
* recv() (socket.socket のメソッド):     socket オブジェクト.
                                                             (line  236)
* recvfrom_into() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  378)
* recvfrom() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  254)
* recvmsg_into() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  340)
* recvmsg() (socket.socket のメソッド):  socket オブジェクト.
                                                             (line  272)
* redirect_request() (urllib.request.HTTPRedirectHandler のメソッド): HTTPRedirectHandler オブジェクト.
                                                             (line   15)
* redirect_stderr() (contextlib モジュール): ユーティリティ. (line  361)
* redirect_stdout() (contextlib モジュール): ユーティリティ. (line  319)
* redisplay() (readline モジュール):     行バッファ.         (line   19)
* redrawln() (curses.window のメソッド): Window オブジェクト.
                                                             (line  448)
* redrawwin() (curses.window のメソッド): Window オブジェクト.
                                                             (line  454)
* reduce() (functools モジュール):       functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  394)
* reducer_override() (pickle.Pickler のメソッド): モジュールインターフェース.
                                                             (line  205)
* ref (weakref のクラス):                weakref --- 弱参照. (line   87)
* refcount_test() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  546)
* reference count:                       用語集<2>.          (line 1262)
* ReferenceError:                        具象例外.           (line  232)
* ReferenceType (weakref モジュール):    weakref --- 弱参照. (line  322)
* refold_source (email.policy.EmailPolicy の属性): email policy Policy Objects.
                                                             (line  386)
* refresh() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  459)
* REG_BINARY (winreg モジュール):        値の型.             (line    8)
* REG_DWORD (winreg モジュール):         値の型.             (line   12)
* REG_DWORD_BIG_ENDIAN (winreg モジュール): 値の型.          (line   21)
* REG_DWORD_LITTLE_ENDIAN (winreg モジュール): 値の型.       (line   16)
* REG_EXPAND_SZ (winreg モジュール):     値の型.             (line   25)
* REG_FULL_RESOURCE_DESCRIPTOR (winreg モジュール): 値の型.  (line   59)
* REG_LINK (winreg モジュール):          値の型.             (line   29)
* REG_MULTI_SZ (winreg モジュール):      値の型.             (line   33)
* REG_NONE (winreg モジュール):          値の型.             (line   38)
* REG_QWORD (winreg モジュール):         値の型.             (line   42)
* REG_QWORD_LITTLE_ENDIAN (winreg モジュール): 値の型.       (line   48)
* REG_RESOURCE_LIST (winreg モジュール): 値の型.             (line   55)
* REG_RESOURCE_REQUIREMENTS_LIST (winreg モジュール): 値の型.
                                                             (line   63)
* REG_SZ (winreg モジュール):            値の型.             (line   67)
* RegexFlag (re のクラス):               フラグ.             (line    9)
* register_adapter() (sqlite3 モジュール): モジュール関数.   (line  141)
* register_archive_format() (shutil モジュール): アーカイブ化操作.
                                                             (line   99)
* register_at_fork() (os モジュール):    プロセス管理.       (line  555)
* register_callback() (sys.monitoring モジュール): Registering callback functions.
                                                             (line    8)
* register_converter() (sqlite3 モジュール): モジュール関数. (line  149)
* register_defect() (email.policy.Policy のメソッド): email policy Policy Objects.
                                                             (line  244)
* register_dialect() (csv モジュール):   モジュールコンテンツ<3>.
                                                             (line   70)
* register_error() (codecs モジュール):  エラーハンドラ.     (line   98)
* register_function() (xmlrpc.server.CGIXMLRPCRequestHandler のメソッド): CGIXMLRPCRequestHandler.
                                                             (line    9)
* register_function() (xmlrpc.server.SimpleXMLRPCServer のメソッド): SimpleXMLRPCServer オブジェクト.
                                                             (line   10)
* register_instance() (xmlrpc.server.CGIXMLRPCRequestHandler のメソッド): CGIXMLRPCRequestHandler.
                                                             (line   26)
* register_instance() (xmlrpc.server.SimpleXMLRPCServer のメソッド): SimpleXMLRPCServer オブジェクト.
                                                             (line   27)
* register_introspection_functions() (xmlrpc.server.CGIXMLRPCRequestHandler のメソッド): CGIXMLRPCRequestHandler.
                                                             (line   39)
* register_introspection_functions() (xmlrpc.server.SimpleXMLRPCServer のメソッド): SimpleXMLRPCServer オブジェクト.
                                                             (line   52)
* register_multicall_functions() (xmlrpc.server.CGIXMLRPCRequestHandler のメソッド): CGIXMLRPCRequestHandler.
                                                             (line   45)
* register_multicall_functions() (xmlrpc.server.SimpleXMLRPCServer のメソッド): SimpleXMLRPCServer オブジェクト.
                                                             (line   57)
* register_namespace() (xml.etree.ElementTree モジュール): 関数<9>.
                                                             (line  195)
* register_optionflag() (doctest モジュール): オプションフラグ.
                                                             (line  160)
* register_shape() (turtle モジュール):  設定と特殊なメソッド.
                                                             (line   71)
* register_unpack_format() (shutil モジュール): アーカイブ化操作.
                                                             (line  170)
* register() (abc.ABCMeta のメソッド):   abc --- 抽象基底クラス.
                                                             (line   68)
* register() (atexit モジュール):        atexit --- 終了ハンドラー.
                                                             (line   25)
* register() (codecs モジュール):        codecs --- codec レジストリと基底クラス.
                                                             (line  153)
* register() (faulthandler モジュール):  ユーザシグナルに対してtracebackをダンプする.
                                                             (line    6)
* register() (multiprocessing.managers.BaseManager のメソッド): マネージャー.
                                                             (line   94)
* register() (select.devpoll のメソッド): /dev/poll ポーリングオブジェクト.
                                                             (line   30)
* register() (select.epoll のメソッド):  エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   82)
* register() (select.poll のメソッド):   ポーリングオブジェクト.
                                                             (line   15)
* register() (selectors.BaseSelector のメソッド): クラス<4>. (line   67)
* register() (webbrowser モジュール):    webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line  106)
* registerDOMImplementation() (xml.dom モジュール): モジュールコンテンツ<4>.
                                                             (line    8)
* registerResult() (unittest モジュール): シグナルハンドリング.
                                                             (line   34)
* REGTYPE (tarfile モジュール):          tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  276)
* regular package:                       用語集<2>.          (line 1271)
* relative_to() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  309)
* relative;import:                       import 文.          (line  100)
* relative;URL:                          urllib parse --- URL を構成要素に解析する.
                                                             (line    8)
* release() (_thread.lock のメソッド):   _thread --- 低水準なスレッド API.
                                                             (line  167)
* release() (asyncio.Condition のメソッド): Condition.       (line   79)
* release() (asyncio.Lock のメソッド):   Lock.               (line   50)
* release() (asyncio.Semaphore のメソッド): Semaphore.       (line   57)
* release() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   32)
* release() (memoryview のメソッド):     メモリビュー.       (line  235)
* release() (multiprocessing.Lock のメソッド): 同期プリミティブ.
                                                             (line   88)
* release() (multiprocessing.RLock のメソッド): 同期プリミティブ.
                                                             (line  142)
* release() (pickle.PickleBuffer のメソッド): モジュールインターフェース.
                                                             (line  339)
* release() (platform モジュール):       クロスプラットフォーム.
                                                             (line  114)
* release() (threading.Condition のメソッド): Condition オブジェクト.
                                                             (line   91)
* release() (threading.Lock のメソッド): Lock オブジェクト.  (line   73)
* release() (threading.RLock のメソッド): RLock オブジェクト.
                                                             (line   95)
* release() (threading.Semaphore のメソッド): Semaphore オブジェクト.
                                                             (line   63)
* releasebufferproc (C type):            Slot Type typedefs. (line  112)
* reload() (importlib モジュール):       関数<12>.           (line   53)
* relpath() (os.path モジュール):        os path --- 一般的なパス名操作.
                                                             (line  398)
* remainder_near() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  482)
* remainder_near() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  483)
* remainder() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  476)
* remainder() (math モジュール):         数論および数表現の関数.
                                                             (line  248)
* RemoteDisconnected:                    http client --- HTTP プロトコルクライアント.
                                                             (line  193)
* remove_child_handler() (asyncio.AbstractChildWatcher のメソッド): プロセスのウオッチャー.
                                                             (line   58)
* remove_done_callback() (asyncio.Future のメソッド): Future オブジェクト<2>.
                                                             (line  111)
* remove_done_callback() (asyncio.Task のメソッド): Task オブジェクト.
                                                             (line  112)
* remove_flag() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  140)
* remove_flag() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line   88)
* remove_flag() (mailbox.mboxMessage のメソッド): mboxMessage オブジェクト.
                                                             (line   84)
* remove_flag() (mailbox.MMDFMessage のメソッド): MMDFMessage オブジェクト.
                                                             (line   83)
* remove_folder() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line   78)
* remove_folder() (mailbox.MH のメソッド): MH オブジェクト.  (line   52)
* remove_header() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line  101)
* remove_history_item() (readline モジュール): 履歴リスト.   (line   25)
* remove_label() (mailbox.BabylMessage のメソッド): BabylMessage オブジェクト.
                                                             (line   59)
* remove_option() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  297)
* remove_option() (optparse.OptionParser のメソッド): オプション解析器への問い合わせと操作.
                                                             (line   49)
* remove_reader() (asyncio.loop のメソッド): ファイル記述子の監視.
                                                             (line   12)
* remove_section() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  304)
* remove_sequence() (mailbox.MHMessage のメソッド): MHMessage オブジェクト.
                                                             (line   45)
* remove_signal_handler() (asyncio.loop のメソッド): Unix シグナル.
                                                             (line   27)
* remove_writer() (asyncio.loop のメソッド): ファイル記述子の監視.
                                                             (line   26)
* remove() (array.array のメソッド):     array --- 効率的な数値配列.
                                                             (line  220)
* remove() (collections.deque のメソッド): deque オブジェクト.
                                                             (line   99)
* remove() (frozenset のメソッド):       set（集合）型 --- set frozenset.
                                                             (line  197)
* remove() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line   76)
* remove() (mailbox.MH のメソッド):      MH オブジェクト.    (line   81)
* remove() (os モジュール):              ファイルとディレクトリ.
                                                             (line  724)
* remove() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line  166)
* remove() (シーケンスのメソッド):       ミュータブルなシーケンス型.
                                                             (line   16)
* removeAttribute() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   53)
* removeAttributeNode() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   58)
* removeAttributeNS() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   63)
* removeChild() (xml.dom.Node のメソッド): Node オブジェクト.
                                                             (line  128)
* removedirs() (os モジュール):          ファイルとディレクトリ.
                                                             (line  748)
* removeFilter() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   58)
* removeFilter() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  319)
* removeHandler() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  336)
* removeHandler() (unittest モジュール): シグナルハンドリング.
                                                             (line   51)
* removeprefix() (bytearray のメソッド): bytes と bytearray の操作.
                                                             (line   52)
* removeprefix() (bytes のメソッド):     bytes と bytearray の操作.
                                                             (line   52)
* removeprefix() (str のメソッド):       文字列メソッド<2>.  (line  356)
* removeResult() (unittest モジュール):  シグナルハンドリング.
                                                             (line   45)
* removesuffix() (bytearray のメソッド): bytes と bytearray の操作.
                                                             (line   72)
* removesuffix() (bytes のメソッド):     bytes と bytearray の操作.
                                                             (line   72)
* removesuffix() (str のメソッド):       文字列メソッド<2>.  (line  368)
* removexattr() (os モジュール):         Linux 拡張属性.     (line   42)
* rename() (ftplib.FTP のメソッド):      FTP オブジェクト.   (line  322)
* rename() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  217)
* rename() (os モジュール):              ファイルとディレクトリ.
                                                             (line  766)
* rename() (pathlib.Path のメソッド):    リネームと削除.     (line    6)
* renames() (os モジュール):             ファイルとディレクトリ.
                                                             (line  803)
* reopenIfNeeded() (logging.handlers.WatchedFileHandler のメソッド): WatchedFileHandler.
                                                             (line   42)
* reorganize() (dbm.gnu.gdbm のメソッド): dbm gnu --- GNU database manager.
                                                             (line  103)
* repeat() (itertools モジュール):       Itertool関数.       (line  524)
* repeat() (timeit モジュール):          Python インターフェイス.
                                                             (line   18)
* repeat() (timeit.Timer のメソッド):    Python インターフェイス.
                                                             (line  103)
* REPL:                                  用語集<2>.          (line 1278)
* replace_errors() (codecs モジュール):  エラーハンドラ.     (line  147)
* replace_header() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  301)
* replace_header() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  408)
* replace_history_item() (readline モジュール): 履歴リスト.  (line   30)
* replace_whitespace (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  181)
* replace;error handler's name:          エラーハンドラ.     (line   14)
* replace() (bytearray のメソッド):      bytes と bytearray の操作.
                                                             (line  201)
* replace() (bytes のメソッド):          bytes と bytearray の操作.
                                                             (line  201)
* replace() (codeobject のメソッド):     Methods on code objects.
                                                             (line   85)
* replace() (copy モジュール):           copy --- 浅いコピーおよび深いコピー操作.
                                                             (line   27)
* replace() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   39)
* replace() (dataclasses モジュール):    モジュールの内容<4>.
                                                             (line  421)
* replace() (datetime.date のメソッド):  date オブジェクト.  (line  191)
* replace() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  462)
* replace() (datetime.time のメソッド):  time オブジェクト.  (line  148)
* replace() (inspect.Parameter のメソッド): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  297)
* replace() (inspect.Signature のメソッド): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  137)
* replace() (os モジュール):             ファイルとディレクトリ.
                                                             (line  820)
* replace() (pathlib.Path のメソッド):   リネームと削除.     (line   34)
* replace() (str のメソッド):            文字列メソッド<2>.  (line  380)
* replace() (tarfile.TarInfo のメソッド): TarInfo オブジェクト.
                                                             (line  167)
* replaceChild() (xml.dom.Node のメソッド): Node オブジェクト.
                                                             (line  135)
* ReplacePackage() (modulefinder モジュール): modulefinder --- スクリプト中で使用されているモジュールの検索.
                                                             (line   21)
* REPORT_CDIFF (doctest モジュール):     オプションフラグ.   (line  113)
* REPORT_ERRMODE (msvcrt モジュール):    その多の関数.       (line   35)
* report_failure() (doctest.DocTestRunner のメソッド): DocTestRunner オブジェクト.
                                                             (line   76)
* report_full_closure() (filecmp.dircmp のメソッド): dircmp クラス.
                                                             (line   31)
* REPORT_NDIFF (doctest モジュール):     オプションフラグ.   (line  118)
* REPORT_ONLY_FIRST_FAILURE (doctest モジュール): オプションフラグ.
                                                             (line  128)
* report_partial_closure() (filecmp.dircmp のメソッド): dircmp クラス.
                                                             (line   26)
* report_start() (doctest.DocTestRunner のメソッド): DocTestRunner オブジェクト.
                                                             (line   53)
* report_success() (doctest.DocTestRunner のメソッド): DocTestRunner オブジェクト.
                                                             (line   64)
* REPORT_UDIFF (doctest モジュール):     オプションフラグ.   (line  108)
* report_unexpected_exception() (doctest.DocTestRunner のメソッド): DocTestRunner オブジェクト.
                                                             (line   88)
* report() (filecmp.dircmp のメソッド):  dircmp クラス.      (line   22)
* report() (modulefinder.ModuleFinder のメソッド): modulefinder --- スクリプト中で使用されているモジュールの検索.
                                                             (line   39)
* REPORTING_FLAGS (doctest モジュール):  オプションフラグ.   (line  152)
* Repr (reprlib のクラス):               reprlib --- もう一つの repr の実装.
                                                             (line   16)
* repr() (reprlib モジュール):           reprlib --- もう一つの repr の実装.
                                                             (line   49)
* repr() (reprlib.Repr のメソッド):      Reprオブジェクト.   (line  105)
* repr() (組み込み関数);__repr__() (オブジェクトメソッド): 基本的なカスタマイズ.
                                                             (line  112)
* repr1() (reprlib.Repr のメソッド):     Reprオブジェクト.   (line  110)
* ReprEnum (enum のクラス):              データ型<2>.        (line  562)
* reprfunc (C type):                     Slot Type typedefs. (line   42)
* request (socketserver.BaseRequestHandler の属性): Request Handler Objects.
                                                             (line   41)
* Request (urllib.request のクラス):     urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  179)
* request_queue_size (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line   96)
* request_rate() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   60)
* request_uri() (wsgiref.util モジュール): wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line   26)
* request_version (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  106)
* request() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line    8)
* RequestHandlerClass (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line   71)
* requestline (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line   87)
* Required (typing モジュール):          特殊形式.           (line  216)
* requires_bz2() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  510)
* requires_docstrings() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  522)
* requires_freebsd_version() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  478)
* requires_gil_enabled() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  493)
* requires_gzip() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  506)
* requires_IEEE_754() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  498)
* requires_limited_api() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  526)
* requires_linux_version() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  483)
* requires_lzma() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  514)
* requires_mac_version() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  488)
* requires_resource() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  518)
* requires_zlib() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  502)
* requires() (importlib.metadata モジュール): 配布物の要件.  (line    6)
* requires() (test.support モジュール):  test support --- テストのためのユーティリティ関数.
                                                             (line  262)
* RERAISE (monitoring event):            Events.             (line   76)
* RERAISE (opcode):                      Python バイトコード命令.
                                                             (line  440)
* reschedule() (asyncio.Timeout のメソッド): タイムアウト.   (line   68)
* reserved (zipfile.ZipInfo の属性):     ZipInfo オブジェクト.
                                                             (line  112)
* RESERVED_FUTURE (uuid モジュール):     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  236)
* RESERVED_MICROSOFT (uuid モジュール):  uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  232)
* RESERVED_NCS (uuid モジュール):        uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  224)
* reset_mock() (unittest.mock.AsyncMock のメソッド): Mock クラス.
                                                             (line  866)
* reset_mock() (unittest.mock.Mock のメソッド): Mock クラス. (line  202)
* reset_peak() (tracemalloc モジュール): 関数<11>.           (line   39)
* reset_prog_mode() (curses モジュール): 関数<6>.            (line  398)
* reset_shell_mode() (curses モジュール): 関数<6>.           (line  403)
* reset_tzpath() (zoneinfo モジュール):  関数<3>.            (line   27)
* reset() (asyncio.Barrier のメソッド):  Barrier.            (line   79)
* reset() (bdb.Bdb のメソッド):          bdb --- デバッガーフレームワーク.
                                                             (line  160)
* reset() (codecs.IncrementalDecoder のメソッド): IncrementalDecoder オブジェクト.
                                                             (line   40)
* reset() (codecs.IncrementalEncoder のメソッド): IncrementalEncoder オブジェクト.
                                                             (line   35)
* reset() (codecs.StreamReader のメソッド): StreamReader オブジェクト.
                                                             (line   81)
* reset() (codecs.StreamWriter のメソッド): StreamWriter オブジェクト.
                                                             (line   44)
* reset() (contextvars.ContextVar のメソッド): コンテキスト変数.
                                                             (line   57)
* reset() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line   24)
* reset() (threading.Barrier のメソッド): バリアオブジェクト.
                                                             (line   69)
* reset() (turtle モジュール):           さらなる描画の制御. (line    6)
* reset() (xml.dom.pulldom.DOMEventStream のメソッド): DOMEventStream オブジェクト.
                                                             (line   36)
* reset() (xml.sax.xmlreader.IncrementalParser のメソッド): IncrementalParser オブジェクト.
                                                             (line   18)
* resetbuffer() (code.InteractiveConsole のメソッド): 対話的なコンソールオブジェクト.
                                                             (line   41)
* resetscreen() (turtle モジュール):     ウィンドウの制御.   (line   57)
* resetty() (curses モジュール):         関数<6>.            (line  408)
* resetwarnings() (warnings モジュール): 利用可能な関数.     (line  125)
* resize_term() (curses モジュール):     関数<6>.            (line  413)
* resize() (ctypes モジュール):          ユーティリティー関数.
                                                             (line  161)
* resize() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  477)
* resize() (mmap.mmap のメソッド):       mmap --- メモリマップファイルのサポート.
                                                             (line  266)
* resizemode() (turtle モジュール):      見た目.             (line   24)
* resizeterm() (curses モジュール):      関数<6>.            (line  422)
* resolution (datetime.date の属性):     date オブジェクト.  (line  106)
* resolution (datetime.datetime の属性): datetime オブジェクト.
                                                             (line  295)
* resolution (datetime.time の属性):     time オブジェクト.  (line   42)
* resolution (datetime.timedelta の属性): timedelta オブジェクト.
                                                             (line   81)
* resolve_bases() (types モジュール):    動的な型生成.       (line   52)
* resolve_name() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line   83)
* resolve_name() (pkgutil モジュール):   pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  212)
* resolve() (pathlib.Path のメソッド):   パスの展開と解決.   (line   49)
* resolveEntity() (xml.sax.handler.EntityResolver のメソッド): EntityResolver オブジェクト.
                                                             (line    6)
* resource_path() (importlib.abc.ResourceReader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  468)
* resource_path() (importlib.resources.abc.ResourceReader のメソッド): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   55)
* ResourceDenied:                        test support --- テストのためのユーティリティ関数.
                                                             (line   22)
* ResourceLoader (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  175)
* ResourceReader (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  423)
* ResourceReader (importlib.resources.abc のクラス): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   12)
* ResourceWarning:                       警告.               (line   80)
* response() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  222)
* ResponseNotReady:                      http client --- HTTP プロトコルクライアント.
                                                             (line  179)
* responses (http.client モジュール):    http client --- HTTP プロトコルクライアント.
                                                             (line  214)
* responses (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  181)
* restart (pdb command):                 デバッガコマンド.   (line  412)
* restart_events() (sys.monitoring モジュール): Disabling events.
                                                             (line   21)
* restore() (difflib モジュール):        difflib --- 差分の計算の補助.
                                                             (line  264)
* restore() (test.support.SaveSignals のメソッド): test support --- テストのためのユーティリティ関数.
                                                             (line  778)
* RESTRICTED (C macro):                  Member flags.       (line   32)
* restype (ctypes._CFuncPtr の属性):     外部関数.           (line   32)
* result() (asyncio.Future のメソッド):  Future オブジェクト<2>.
                                                             (line   33)
* result() (asyncio.Task のメソッド):    Task オブジェクト.  (line   74)
* result() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   37)
* results() (trace.Trace のメソッド):    プログラミングインターフェース.
                                                             (line   39)
* RESUME (opcode):                       Python バイトコード命令.
                                                             (line 1207)
* resume_reading() (asyncio.ReadTransport のメソッド): 読み出し専用のトランスポート.
                                                             (line   22)
* resume_writing() (asyncio.BaseProtocol のメソッド): 基底プロトコル<2>.
                                                             (line   46)
* retr() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   61)
* retrbinary() (ftplib.FTP のメソッド):  FTP オブジェクト.   (line  174)
* retrieve() (urllib.request.URLopener のメソッド): レガシーインターフェース.
                                                             (line  115)
* retrlines() (ftplib.FTP のメソッド):   FTP オブジェクト.   (line  199)
* RETRY (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  149)
* RETRYCANCEL (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  176)
* Return (ast のクラス):                 関数およびクラス定義.
                                                             (line  113)
* return (pdb command):                  デバッガコマンド.   (line  218)
* return_annotation (inspect.Signature の属性): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  116)
* RETURN_CONST (opcode):                 Python バイトコード命令.
                                                             (line  405)
* RETURN_GENERATOR (opcode):             Python バイトコード命令.
                                                             (line 1232)
* return_ok() (http.cookiejar.CookiePolicy のメソッド): CookiePolicy オブジェクト.
                                                             (line   18)
* RETURN_VALUE (opcode):                 Python バイトコード命令.
                                                             (line  401)
* return_value (unittest.mock.Mock の属性): Mock クラス.     (line  318)
* returncode (asyncio.subprocess.Process の属性): サブプロセスとやりとりする.
                                                             (line  147)
* returncode (subprocess.CalledProcessError の属性): subprocess モジュールを使う.
                                                             (line  212)
* returncode (subprocess.CompletedProcess の属性): subprocess モジュールを使う.
                                                             (line  109)
* returncode (subprocess.Popen の属性):  Popen オブジェクト. (line  151)
* retval (pdb command):                  デバッガコマンド.   (line  431)
* reveal_type() (typing モジュール):     Functions and decorators.
                                                             (line   81)
* reverse_order() (pstats.Stats のメソッド): Stats クラス.   (line  149)
* reverse_pointer (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   74)
* reverse_pointer (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  254)
* reverse() (array.array のメソッド):    array --- 効率的な数値配列.
                                                             (line  230)
* reverse() (collections.deque のメソッド): deque オブジェクト.
                                                             (line  104)
* reverse() (シーケンスのメソッド):      ミュータブルなシーケンス型.
                                                             (line   16)
* Reversible (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   49)
* Reversible (typing のクラス):          Aliases to other ABCs in collections abc.
                                                             (line   61)
* revert() (http.cookiejar.FileCookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line  149)
* rewind() (wave.Wave_read のメソッド):  Wave_read オブジェクト.
                                                             (line   57)
* RFC_4122 (uuid モジュール):            uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  228)
* RFC; RFC 1123:                         関数<5>.            (line  726)
* RFC; RFC 1123 <1>:                     関数<5>.            (line  738)
* RFC; RFC 1123 <2>:                     関数<5>.            (line  754)
* RFC; RFC 1321:                         hashlib --- セキュアハッシュとメッセージダイジェスト.
                                                             (line   14)
* RFC; RFC 1422:                         証明書.             (line   32)
* RFC; RFC 1422 <1>:                     TLS 1 3.            (line   41)
* RFC; RFC 1521:                         セキュリティで考慮すべき点<4>.
                                                             (line   18)
* RFC; RFC 1521 <1>:                     quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   10)
* RFC; RFC 1521 <2>:                     quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   37)
* RFC; RFC 1522:                         binascii --- バイナリ と ASCII 間の変換.
                                                             (line   86)
* RFC; RFC 1522 <1>:                     quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   25)
* RFC; RFC 1522 <2>:                     quopri --- MIME quoted-printable データのエンコードとデコード.
                                                             (line   39)
* RFC; RFC 1730:                         imaplib --- IMAP4 プロトコルクライアント.
                                                             (line   14)
* RFC; RFC 1738:                         URL のクオート.     (line  185)
* RFC; RFC 1750:                         乱数生成.           (line   36)
* RFC; RFC 1766:                         locale --- 国際化サービス.
                                                             (line  340)
* RFC; RFC 1766 <1>:                     locale --- 国際化サービス.
                                                             (line  353)
* RFC; RFC 1808:                         urllib<2>.          (line   23)
* RFC; RFC 1808 <1>:                     urllib parse --- URL を構成要素に解析する.
                                                             (line   34)
* RFC; RFC 1808 <2>:                     URL の解析.         (line   43)
* RFC; RFC 1808 <3>:                     URL のクオート.     (line  180)
* RFC; RFC 1869:                         smtplib --- SMTP プロトコルクライアント.
                                                             (line   14)
* RFC; RFC 1869 <1>:                     smtplib --- SMTP プロトコルクライアント.
                                                             (line  189)
* RFC; RFC 1870:                         smtpd<4>.           (line    6)
* RFC; RFC 1939:                         poplib --- POP3 プロトコルクライアント.
                                                             (line   11)
* RFC; RFC 1939 <1>:                     poplib --- POP3 プロトコルクライアント.
                                                             (line   12)
* RFC; RFC 2033:                         新しいモジュールと改良されたモジュール<2>.
                                                             (line  582)
* RFC; RFC 2045:                         email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   15)
* RFC; RFC 2045 <1>:                     email message Representing an email message.
                                                             (line  316)
* RFC; RFC 2045 <2>:                     email message Representing an email message.
                                                             (line  318)
* RFC; RFC 2045 <3>:                     email message Representing an email message.
                                                             (line  321)
* RFC; RFC 2045 <4>:                     email headerregistry Custom Header Objects.
                                                             (line  234)
* RFC; RFC 2045 <5>:                     email headerregistry Custom Header Objects.
                                                             (line  291)
* RFC; RFC 2045 <6>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  421)
* RFC; RFC 2045 <7>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  425)
* RFC; RFC 2045 <8>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  430)
* RFC; RFC 2045 <9>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  526)
* RFC; RFC 2045 <10>:                    email header 国際化されたヘッダー.
                                                             (line   28)
* RFC; RFC 2045 <11>:                    base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   29)
* RFC; RFC 2045 <12>:                    base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   30)
* RFC; RFC 2045 <13>:                    base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  275)
* RFC; RFC 2045 <14>:                    base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  282)
* RFC; RFC 2045 Section 6.8:             Binary オブジェクト.
                                                             (line   29)
* RFC; RFC 2046:                         email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   15)
* RFC; RFC 2046 <1>:                     Content Manager Instances.
                                                             (line   84)
* RFC; RFC 2046 <2>:                     email header 国際化されたヘッダー.
                                                             (line   28)
* RFC; RFC 2047:                         PEP 3333 Python Web Server Gateway Interface v1 0 1.
                                                             (line   21)
* RFC; RFC 2047 <1>:                     email<6>.           (line   29)
* RFC; RFC 2047 <2>:                     email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   15)
* RFC; RFC 2047 <3>:                     email policy Policy Objects.
                                                             (line  362)
* RFC; RFC 2047 <4>:                     email policy Policy Objects.
                                                             (line  368)
* RFC; RFC 2047 <5>:                     email headerregistry Custom Header Objects.
                                                             (line   78)
* RFC; RFC 2047 <6>:                     email headerregistry Custom Header Objects.
                                                             (line  121)
* RFC; RFC 2047 <7>:                     email headerregistry Custom Header Objects.
                                                             (line  125)
* RFC; RFC 2047 <8>:                     email header 国際化されたヘッダー.
                                                             (line   28)
* RFC; RFC 2047 <9>:                     email header 国際化されたヘッダー.
                                                             (line   52)
* RFC; RFC 2047 <10>:                    email header 国際化されたヘッダー.
                                                             (line  112)
* RFC; RFC 2047 <11>:                    email header 国際化されたヘッダー.
                                                             (line  136)
* RFC; RFC 2047 <12>:                    email utils Miscellaneous utilities.
                                                             (line   79)
* RFC; RFC 2060:                         imaplib --- IMAP4 プロトコルクライアント.
                                                             (line   12)
* RFC; RFC 2060 <1>:                     IMAP4 オブジェクト. (line  323)
* RFC; RFC 2068:                         http cookies --- HTTP の状態管理.
                                                             (line   15)
* RFC; RFC 2087:                         IMAP4 オブジェクト. (line  119)
* RFC; RFC 2087 <1>:                     IMAP4 オブジェクト. (line  124)
* RFC; RFC 2087 <2>:                     IMAP4 オブジェクト. (line  272)
* RFC; RFC 2104:                         新しいモジュールと改良されたモジュール<3>.
                                                             (line   34)
* RFC; RFC 2104 <1>:                     hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   10)
* RFC; RFC 2109:                         Python API の変更<7>.
                                                             (line   79)
* RFC; RFC 2109 <1>:                     http cookies --- HTTP の状態管理.
                                                             (line   15)
* RFC; RFC 2109 <2>:                     http cookies --- HTTP の状態管理.
                                                             (line   35)
* RFC; RFC 2109 <3>:                     http cookies --- HTTP の状態管理.
                                                             (line   66)
* RFC; RFC 2109 <4>:                     Morselオブジェクト. (line    8)
* RFC; RFC 2109 <5>:                     Morselオブジェクト. (line   10)
* RFC; RFC 2109 <6>:                     Morselオブジェクト. (line   88)
* RFC; RFC 2109 <7>:                     Morselオブジェクト. (line  100)
* RFC; RFC 2109 <8>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line   18)
* RFC; RFC 2109 <9>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  104)
* RFC; RFC 2109 <10>:                    http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  115)
* RFC; RFC 2109 <11>:                    http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  142)
* RFC; RFC 2109 <12>:                    DefaultCookiePolicy オブジェクト.
                                                             (line   84)
* RFC; RFC 2109 <13>:                    Cookieオブジェクト<2>.
                                                             (line    9)
* RFC; RFC 2109 <14>:                    Cookieオブジェクト<2>.
                                                             (line   22)
* RFC; RFC 2109 <15>:                    Cookieオブジェクト<2>.
                                                             (line   75)
* RFC; RFC 2183:                         email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   15)
* RFC; RFC 2183 <1>:                     email message Representing an email message.
                                                             (line  460)
* RFC; RFC 2183 <2>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  637)
* RFC; RFC 2231:                         Library<8>.         (line  135)
* RFC; RFC 2231 <1>:                     email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   15)
* RFC; RFC 2231 <2>:                     email message Representing an email message.
                                                             (line  280)
* RFC; RFC 2231 <3>:                     email message Representing an email message.
                                                             (line  283)
* RFC; RFC 2231 <4>:                     email message Representing an email message.
                                                             (line  366)
* RFC; RFC 2231 <5>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  385)
* RFC; RFC 2231 <6>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  388)
* RFC; RFC 2231 <7>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  492)
* RFC; RFC 2231 <8>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  500)
* RFC; RFC 2231 <9>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  535)
* RFC; RFC 2231 <10>:                    email header 国際化されたヘッダー.
                                                             (line   29)
* RFC; RFC 2231 <11>:                    email utils Miscellaneous utilities.
                                                             (line  189)
* RFC; RFC 2231 <12>:                    email utils Miscellaneous utilities.
                                                             (line  193)
* RFC; RFC 2231 <13>:                    email utils Miscellaneous utilities.
                                                             (line  203)
* RFC; RFC 2231 <14>:                    email utils Miscellaneous utilities.
                                                             (line  210)
* RFC; RFC 2231 <15>:                    email utils Miscellaneous utilities.
                                                             (line  221)
* RFC; RFC 2295:                         HTTP ステータスコード.
                                                             (line  184)
* RFC; RFC 2324:                         HTTP ステータスコード.
                                                             (line  133)
* RFC; RFC 2342:                         新しいモジュールと改良されたモジュール<3>.
                                                             (line   93)
* RFC; RFC 2342 <1>:                     IMAP4 オブジェクト. (line  167)
* RFC; RFC 2368:                         URL のクオート.     (line  176)
* RFC; RFC 2373:                         Address オブジェクト.
                                                             (line   92)
* RFC; RFC 2373 <1>:                     Address オブジェクト.
                                                             (line  157)
* RFC; RFC 2373 <2>:                     Address オブジェクト.
                                                             (line  167)
* RFC; RFC 2396:                         urllib parse<5>.    (line    6)
* RFC; RFC 2396 <1>:                     urllib<2>.          (line   24)
* RFC; RFC 2396 <2>:                     URL の解析.         (line  254)
* RFC; RFC 2396 <3>:                     URL のクオート.     (line   23)
* RFC; RFC 2396 <4>:                     URL のクオート.     (line  170)
* RFC; RFC 2397:                         DataHandler オブジェクト.
                                                             (line    9)
* RFC; RFC 2449:                         POP3 オブジェクト.  (line   25)
* RFC; RFC 2487:                         新しいモジュールと改良されたモジュール<3>.
                                                             (line   86)
* RFC; RFC 2518:                         HTTP ステータスコード.
                                                             (line   19)
* RFC; RFC 2595:                         poplib --- POP3 プロトコルクライアント.
                                                             (line   14)
* RFC; RFC 2595 <1>:                     POP3 オブジェクト.  (line  116)
* RFC; RFC 2616:                         PEP 3333 Python Web Server Gateway Interface v1 0 1.
                                                             (line   20)
* RFC; RFC 2616 <1>:                     wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line  113)
* RFC; RFC 2616 <2>:                     wsgiref validate --- WSGI 準拠チェッカー.
                                                             (line   26)
* RFC; RFC 2616 <3>:                     HTTPRedirectHandler オブジェクト.
                                                             (line    8)
* RFC; RFC 2616 <4>:                     HTTPRedirectHandler オブジェクト.
                                                             (line   27)
* RFC; RFC 2616 <5>:                     HTTPRedirectHandler オブジェクト.
                                                             (line   28)
* RFC; RFC 2616 <6>:                     レガシーインターフェース.
                                                             (line  165)
* RFC; RFC 2616 <7>:                     urllib error --- urllib request によって送出される例外クラス.
                                                             (line   44)
* RFC; RFC 2616 <8>:                     はじめに<14>.       (line   32)
* RFC; RFC 2616 <9>:                     HTTPError.          (line   15)
* RFC; RFC 2616 <10>:                    エラーコード.       (line   10)
* RFC; RFC 2616 Section 14.23:           HTTPConnection オブジェクト.
                                                             (line   31)
* RFC; RFC 2616 Section 5.1.2:           HTTPConnection オブジェクト.
                                                             (line   13)
* RFC; RFC 2616 Section 5.1.2 <1>:       HTTPConnection オブジェクト.
                                                             (line   32)
* RFC; RFC 2640:                         Python API の変更<2>.
                                                             (line   36)
* RFC; RFC 2640 <1>:                     Tests<38>.          (line   22)
* RFC; RFC 2640 <2>:                     ftplib --- FTP プロトコルクライアント.
                                                             (line   18)
* RFC; RFC 2640 <3>:                     FTP オブジェクト.   (line   64)
* RFC; RFC 2640 <4>:                     FTP_TLS オブジェクト.
                                                             (line   65)
* RFC; RFC 2732:                         urllib parse<6>.    (line    9)
* RFC; RFC 2732 <1>:                     新しいモジュールと改良されたモジュール.
                                                             (line  630)
* RFC; RFC 2732 <2>:                     URL のクオート.     (line  166)
* RFC; RFC 2774:                         HTTP ステータスコード.
                                                             (line  193)
* RFC; RFC 2818:                         ssl<12>.            (line   17)
* RFC; RFC 2821:                         email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   11)
* RFC; RFC 2822:                         新しいモジュールと改良されたモジュール<3>.
                                                             (line   98)
* RFC; RFC 2822 <1>:                     バッテリー同梱.     (line   15)
* RFC; RFC 2822 <2>:                     関数<5>.            (line  727)
* RFC; RFC 2822 <3>:                     関数<5>.            (line  739)
* RFC; RFC 2822 <4>:                     関数<5>.            (line  444)
* RFC; RFC 2822 <5>:                     関数<5>.            (line  755)
* RFC; RFC 2822 <6>:                     email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  273)
* RFC; RFC 2822 <7>:                     email header 国際化されたヘッダー.
                                                             (line   18)
* RFC; RFC 2822 <8>:                     email header 国際化されたヘッダー.
                                                             (line   20)
* RFC; RFC 2822 <9>:                     email header 国際化されたヘッダー.
                                                             (line   26)
* RFC; RFC 2822 <10>:                    email header 国際化されたヘッダー.
                                                             (line   85)
* RFC; RFC 2822 <11>:                    email header 国際化されたヘッダー.
                                                             (line  112)
* RFC; RFC 2822 <12>:                    email header 国際化されたヘッダー.
                                                             (line  130)
* RFC; RFC 2822 <13>:                    email utils Miscellaneous utilities.
                                                             (line   29)
* RFC; RFC 2822 <14>:                    email utils Miscellaneous utilities.
                                                             (line  109)
* RFC; RFC 2822 <15>:                    email utils Miscellaneous utilities.
                                                             (line  112)
* RFC; RFC 2822 <16>:                    email utils Miscellaneous utilities.
                                                             (line  241)
* RFC; RFC 2822 <17>:                    email utils Miscellaneous utilities.
                                                             (line  154)
* RFC; RFC 2822 <18>:                    Message オブジェクト.
                                                             (line   17)
* RFC; RFC 2822 <19>:                    http client --- HTTP プロトコルクライアント.
                                                             (line  119)
* RFC; RFC 2822 <20>:                    http server --- HTTP サーバー.
                                                             (line  117)
* RFC; RFC 2964:                         http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  156)
* RFC; RFC 2965:                         urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  224)
* RFC; RFC 2965 <1>:                     urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  233)
* RFC; RFC 2965 <2>:                     Request オブジェクト.
                                                             (line   50)
* RFC; RFC 2965 <3>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line   16)
* RFC; RFC 2965 <4>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  102)
* RFC; RFC 2965 <5>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  115)
* RFC; RFC 2965 <6>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  144)
* RFC; RFC 2965 <7>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  147)
* RFC; RFC 2965 <8>:                     http cookiejar --- HTTP クライアント用の Cookie 処理.
                                                             (line  154)
* RFC; RFC 2965 <9>:                     FileCookieJar のサブクラスと web ブラウザとの連携.
                                                             (line   16)
* RFC; RFC 2965 <10>:                    CookiePolicy オブジェクト.
                                                             (line   77)
* RFC; RFC 2965 <11>:                    CookiePolicy オブジェクト.
                                                             (line   82)
* RFC; RFC 2965 <12>:                    DefaultCookiePolicy オブジェクト.
                                                             (line    8)
* RFC; RFC 2965 <13>:                    DefaultCookiePolicy オブジェクト.
                                                             (line   89)
* RFC; RFC 2965 <14>:                    DefaultCookiePolicy オブジェクト.
                                                             (line  101)
* RFC; RFC 2965 <15>:                    DefaultCookiePolicy オブジェクト.
                                                             (line  106)
* RFC; RFC 2965 <16>:                    DefaultCookiePolicy オブジェクト.
                                                             (line  114)
* RFC; RFC 2965 <17>:                    DefaultCookiePolicy オブジェクト.
                                                             (line  152)
* RFC; RFC 2965 <18>:                    Cookieオブジェクト<2>.
                                                             (line   22)
* RFC; RFC 2965 <19>:                    使用例<41>.         (line   23)
* RFC; RFC 3056:                         Address オブジェクト.
                                                             (line  299)
* RFC; RFC 3164:                         RFC5424 をサポートする syslog へのロギング.
                                                             (line    7)
* RFC; RFC 3171:                         Address オブジェクト.
                                                             (line   91)
* RFC; RFC 3207:                         新しいモジュールと改良されたモジュール<2>.
                                                             (line  587)
* RFC; RFC 3229:                         HTTP ステータスコード.
                                                             (line   52)
* RFC; RFC 3280:                         SSL ソケット.       (line  155)
* RFC; RFC 3330:                         Address オブジェクト.
                                                             (line  166)
* RFC; RFC 3339:                         メッセージ内での日付と時刻の表示.
                                                             (line   17)
* RFC; RFC 3454:                         Security<14>.       (line   19)
* RFC; RFC 3454 <1>:                     stringprep --- インターネットの文字列調製.
                                                             (line   17)
* RFC; RFC 3454 <2>:                     stringprep --- インターネットの文字列調製.
                                                             (line   26)
* RFC; RFC 3490:                         テキストエンコーディング.
                                                             (line   14)
* RFC; RFC 3490 <1>:                     encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line    6)
* RFC; RFC 3490 <2>:                     encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   55)
* RFC; RFC 3490 <3>:                     encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   60)
* RFC; RFC 3490 Section 3.1:             encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   27)
* RFC; RFC 3491:                         Security<14>.       (line   21)
* RFC; RFC 3492:                         テキストエンコーディング.
                                                             (line   37)
* RFC; RFC 3492 <1>:                     encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line    7)
* RFC; RFC 3493:                         使用例<26>.         (line  227)
* RFC; RFC 3501:                         IMAP4 オブジェクト. (line  336)
* RFC; RFC 3542:                         Library<50>.        (line  351)
* RFC; RFC 3542 <1>:                     その他の関数<2>.    (line  339)
* RFC; RFC 3548:                         新たなモジュール、改良されたモジュール、非推奨のモジュール<3>.
                                                             (line   15)
* RFC; RFC 3548 <1>:                     binascii --- バイナリ と ASCII 間の変換.
                                                             (line   51)
* RFC; RFC 3548 <2>:                     binascii --- バイナリ と ASCII 間の変換.
                                                             (line   66)
* RFC; RFC 3596 Section 2.5:             Library<3>.         (line   14)
* RFC; RFC 3659:                         FTP オブジェクト.   (line  286)
* RFC; RFC 3879:                         Address オブジェクト.
                                                             (line  279)
* RFC; RFC 3927:                         Address オブジェクト.
                                                             (line  171)
* RFC; RFC 3986:                         urllib parse.       (line   17)
* RFC; RFC 3986 <1>:                     urllib parse<3>.    (line    7)
* RFC; RFC 3986 <2>:                     urllib parse<4>.    (line    7)
* RFC; RFC 3986 <3>:                     urllib parse<5>.    (line    6)
* RFC; RFC 3986 <4>:                     urllib<2>.          (line   22)
* RFC; RFC 3986 <5>:                     新しいモジュールと改良されたモジュール.
                                                             (line  609)
* RFC; RFC 3986 <6>:                     Python 2 7 への移植.
                                                             (line   76)
* RFC; RFC 3986 <7>:                     urllib parse --- URL を構成要素に解析する.
                                                             (line   35)
* RFC; RFC 3986 <8>:                     URL の解析.         (line  140)
* RFC; RFC 3986 <9>:                     URL の解析.         (line  365)
* RFC; RFC 3986 <10>:                    URL parsing security.
                                                             (line   25)
* RFC; RFC 3986 <11>:                    URL のクオート.     (line   23)
* RFC; RFC 3986 <12>:                    URL のクオート.     (line  158)
* RFC; RFC 3986 <13>:                    http server --- HTTP サーバー.
                                                             (line  103)
* RFC; RFC 4007:                         Address オブジェクト.
                                                             (line  222)
* RFC; RFC 4007 <1>:                     Address オブジェクト.
                                                             (line  292)
* RFC; RFC 4086:                         TLS 1 3.            (line   45)
* RFC; RFC 4122:                         新たなモジュール、改良されたモジュール、削除されたモジュール.
                                                             (line  414)
* RFC; RFC 4122 <1>:                     新たなモジュール、改良されたモジュール、削除されたモジュール.
                                                             (line  420)
* RFC; RFC 4122 <2>:                     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line    6)
* RFC; RFC 4122 <3>:                     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   13)
* RFC; RFC 4122 <4>:                     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   72)
* RFC; RFC 4122 <5>:                     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  137)
* RFC; RFC 4122 <6>:                     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  164)
* RFC; RFC 4122 <7>:                     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  230)
* RFC; RFC 4122 <8>:                     uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  243)
* RFC; RFC 4180:                         csv --- CSV ファイルの読み書き.
                                                             (line   12)
* RFC; RFC 4193:                         Address オブジェクト.
                                                             (line  280)
* RFC; RFC 4217:                         FTP_TLS オブジェクト.
                                                             (line   11)
* RFC; RFC 4291:                         Library<14>.        (line 1075)
* RFC; RFC 4291 <1>:                     Library<30>.        (line  653)
* RFC; RFC 4291 <2>:                     Address オブジェクト.
                                                             (line  177)
* RFC; RFC 4291 <3>:                     Address オブジェクト.
                                                             (line  216)
* RFC; RFC 4366:                         ssl<12>.            (line   26)
* RFC; RFC 4380:                         Address オブジェクト.
                                                             (line  306)
* RFC; RFC 4627:                         json --- JSON エンコーダーとデコーダー.
                                                             (line   11)
* RFC; RFC 4627 <1>:                     トップレベルの非オブジェクト、非配列の値の扱い.
                                                             (line    6)
* RFC; RFC 4648:                         Documentation<25>.  (line   32)
* RFC; RFC 4648 <1>:                     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   11)
* RFC; RFC 4648 <2>:                     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   15)
* RFC; RFC 4648 <3>:                     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   23)
* RFC; RFC 4648 <4>:                     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  122)
* RFC; RFC 4648 <5>:                     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  138)
* RFC; RFC 4648 <6>:                     base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  145)
* RFC; RFC 4648 <7>:                     セキュリティで考慮すべき点<4>.
                                                             (line    6)
* RFC; RFC 4648 <8>:                     セキュリティで考慮すべき点<6>.
                                                             (line    8)
* RFC; RFC 4918:                         HTTP ステータスコード.
                                                             (line   46)
* RFC; RFC 4918 <1>:                     HTTP ステータスコード.
                                                             (line  142)
* RFC; RFC 4918 <2>:                     HTTP ステータスコード.
                                                             (line  145)
* RFC; RFC 4918 <3>:                     HTTP ステータスコード.
                                                             (line  187)
* RFC; RFC 4954:                         SMTP オブジェクト.  (line  130)
* RFC; RFC 4954 <1>:                     SMTP オブジェクト.  (line  153)
* RFC; RFC 5161:                         imaplib<2>.         (line   11)
* RFC; RFC 5161 <1>:                     IMAP4 オブジェクト. (line   85)
* RFC; RFC 5246:                         定数<9>.            (line  516)
* RFC; RFC 5246 <1>:                     TLS 1 3.            (line   53)
* RFC; RFC 5280:                         ssl.                (line   10)
* RFC; RFC 5280 <1>:                     その他の変更.       (line   20)
* RFC; RFC 5280 <2>:                     Python API の変更<7>.
                                                             (line  100)
* RFC; RFC 5280 <3>:                     コンテキストの作成. (line   40)
* RFC; RFC 5280 <4>:                     コンテキストの作成. (line   65)
* RFC; RFC 5280 <5>:                     証明書の取り扱い.   (line   22)
* RFC; RFC 5280 <6>:                     TLS 1 3.            (line   49)
* RFC; RFC 5321:                         smtpd<4>.           (line    6)
* RFC; RFC 5321 <1>:                     email headerregistry Custom Header Objects.
                                                             (line  446)
* RFC; RFC 5322:                         email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   14)
* RFC; RFC 5322 <1>:                     email message Representing an email message.
                                                             (line   20)
* RFC; RFC 5322 <2>:                     email message Representing an email message.
                                                             (line   31)
* RFC; RFC 5322 <3>:                     Parser API.         (line   42)
* RFC; RFC 5322 <4>:                     email generator Generating MIME documents.
                                                             (line  101)
* RFC; RFC 5322 <5>:                     email generator Generating MIME documents.
                                                             (line  194)
* RFC; RFC 5322 <6>:                     email policy Policy Objects.
                                                             (line  147)
* RFC; RFC 5322 <7>:                     email policy Policy Objects.
                                                             (line  341)
* RFC; RFC 5322 <8>:                     email policy Policy Objects.
                                                             (line  362)
* RFC; RFC 5322 <9>:                     email policy Policy Objects.
                                                             (line  368)
* RFC; RFC 5322 <10>:                    email policy Policy Objects.
                                                             (line  380)
* RFC; RFC 5322 <11>:                    email policy Policy Objects.
                                                             (line  413)
* RFC; RFC 5322 <12>:                    email errors Exception and Defect classes.
                                                             (line   28)
* RFC; RFC 5322 <13>:                    email headerregistry Custom Header Objects.
                                                             (line   15)
* RFC; RFC 5322 <14>:                    email headerregistry Custom Header Objects.
                                                             (line  115)
* RFC; RFC 5322 <15>:                    email headerregistry Custom Header Objects.
                                                             (line  120)
* RFC; RFC 5322 <16>:                    email headerregistry Custom Header Objects.
                                                             (line  122)
* RFC; RFC 5322 <17>:                    email headerregistry Custom Header Objects.
                                                             (line  136)
* RFC; RFC 5322 <18>:                    email headerregistry Custom Header Objects.
                                                             (line  156)
* RFC; RFC 5322 <19>:                    email headerregistry Custom Header Objects.
                                                             (line  410)
* RFC; RFC 5322 <20>:                    email headerregistry Custom Header Objects.
                                                             (line  443)
* RFC; RFC 5322 <21>:                    email headerregistry Custom Header Objects.
                                                             (line  477)
* RFC; RFC 5322 <22>:                    email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line   21)
* RFC; RFC 5322 <23>:                    SMTP オブジェクト.  (line  306)
* RFC; RFC 5424:                         SysLogHandler.      (line   70)
* RFC; RFC 5424 <1>:                     SysLogHandler に送るメッセージに BOM を挿入する.
                                                             (line    6)
* RFC; RFC 5424 <2>:                     SysLogHandler に送るメッセージに BOM を挿入する.
                                                             (line   17)
* RFC; RFC 5424 <3>:                     SysLogHandler に送るメッセージに BOM を挿入する.
                                                             (line   41)
* RFC; RFC 5424 <4>:                     RFC5424 をサポートする syslog へのロギング.
                                                             (line    6)
* RFC; RFC 5424 Section 6:               SysLogHandler に送るメッセージに BOM を挿入する.
                                                             (line    8)
* RFC; RFC 5735:                         Address オブジェクト.
                                                             (line  157)
* RFC; RFC 5789:                         HTTP メソッド.      (line   37)
* RFC; RFC 5802:                         ssl<11>.            (line   30)
* RFC; RFC 5842:                         HTTP ステータスコード.
                                                             (line   49)
* RFC; RFC 5842 <1>:                     HTTP ステータスコード.
                                                             (line  190)
* RFC; RFC 5891:                         encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   12)
* RFC; RFC 5894:                         Security<14>.       (line   20)
* RFC; RFC 5895:                         encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   12)
* RFC; RFC 5929:                         SSL ソケット.       (line  261)
* RFC; RFC 6066:                         定数<9>.            (line  410)
* RFC; RFC 6066 <1>:                     SSL コンテキスト.   (line  288)
* RFC; RFC 6066 <2>:                     TLS 1 3.            (line   57)
* RFC; RFC 6152:                         smtpd<2>.           (line   15)
* RFC; RFC 6531:                         email<3>.           (line   19)
* RFC; RFC 6531 <1>:                     smtpd<2>.           (line   21)
* RFC; RFC 6531 <2>:                     smtplib<2>.         (line   15)
* RFC; RFC 6531 <3>:                     email message Representing an email message.
                                                             (line  103)
* RFC; RFC 6531 <4>:                     email policy Policy Objects.
                                                             (line  384)
* RFC; RFC 6531 <5>:                     smtplib --- SMTP プロトコルクライアント.
                                                             (line   68)
* RFC; RFC 6532:                         email<3>.           (line   18)
* RFC; RFC 6532 <1>:                     email --- 電子メールと MIME 処理のためのパッケージ.
                                                             (line   14)
* RFC; RFC 6532 <2>:                     email message Representing an email message.
                                                             (line   20)
* RFC; RFC 6532 <3>:                     Parser API.         (line   43)
* RFC; RFC 6532 <4>:                     email policy Policy Objects.
                                                             (line  382)
* RFC; RFC 6585:                         HTTP ステータスコード.
                                                             (line  154)
* RFC; RFC 6585 <1>:                     HTTP ステータスコード.
                                                             (line  157)
* RFC; RFC 6585 <2>:                     HTTP ステータスコード.
                                                             (line  160)
* RFC; RFC 6585 <3>:                     HTTP ステータスコード.
                                                             (line  196)
* RFC; RFC 6855:                         imaplib<2>.         (line   12)
* RFC; RFC 6855 <1>:                     imaplib<2>.         (line   14)
* RFC; RFC 6855 <2>:                     IMAP4 オブジェクト. (line   87)
* RFC; RFC 6855 <3>:                     IMAP4 オブジェクト. (line   89)
* RFC; RFC 6856:                         poplib<2>.          (line    6)
* RFC; RFC 6856 <1>:                     POP3 オブジェクト.  (line  109)
* RFC; RFC 7159:                         json --- JSON エンコーダーとデコーダー.
                                                             (line   10)
* RFC; RFC 7159 <1>:                     標準への準拠と互換性.
                                                             (line    6)
* RFC; RFC 7159 <2>:                     トップレベルの非オブジェクト、非配列の値の扱い.
                                                             (line   10)
* RFC; RFC 7230:                         urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  194)
* RFC; RFC 7230 <1>:                     HTTPConnection オブジェクト.
                                                             (line  193)
* RFC; RFC 7301:                         Application-Layer Protocol Negotiation Support.
                                                             (line   10)
* RFC; RFC 7301 <1>:                     定数<9>.            (line  386)
* RFC; RFC 7301 <2>:                     SSL コンテキスト.   (line  258)
* RFC; RFC 7525:                         TLS 1 3.            (line   65)
* RFC; RFC 7538:                         Library<29>.        (line  171)
* RFC; RFC 7693:                         BLAKE2.             (line    6)
* RFC; RFC 7725:                         HTTP ステータスコード.
                                                             (line  163)
* RFC; RFC 7914:                         鍵導出.             (line   52)
* RFC; RFC 8089:                         URIのパースと生成.  (line    7)
* RFC; RFC 821:                          smtplib --- SMTP プロトコルクライアント.
                                                             (line   13)
* RFC; RFC 821 <1>:                      smtplib --- SMTP プロトコルクライアント.
                                                             (line  184)
* RFC; RFC 822:                          新しいモジュールと改良されたモジュール<3>.
                                                             (line   98)
* RFC; RFC 822 <1>:                      関数<5>.            (line  722)
* RFC; RFC 822 <2>:                      関数<5>.            (line  725)
* RFC; RFC 822 <3>:                      関数<5>.            (line  734)
* RFC; RFC 822 <4>:                      関数<5>.            (line  737)
* RFC; RFC 822 <5>:                      関数<5>.            (line  750)
* RFC; RFC 822 <6>:                      関数<5>.            (line  753)
* RFC; RFC 822 <7>:                      email 使用例.       (line   36)
* RFC; RFC 822 <8>:                      email header 国際化されたヘッダー.
                                                             (line   19)
* RFC; RFC 822 <9>:                      HTTPConnection オブジェクト.
                                                             (line  180)
* RFC; RFC 822 <10>:                     SMTP オブジェクト.  (line   91)
* RFC; RFC 822 <11>:                     SMTP オブジェクト.  (line  225)
* RFC; RFC 822 <12>:                     SMTP オブジェクト.  (line  225)
* RFC; RFC 822 <13>:                     SMTP 使用例.        (line   10)
* RFC; RFC 822 <14>:                     GNUTranslations クラス.
                                                             (line   13)
* RFC; RFC 8297:                         HTTP ステータスコード.
                                                             (line   22)
* RFC; RFC 8305:                         ネットワーク接続の確立.
                                                             (line   75)
* RFC; RFC 8305 <1>:                     ネットワーク接続の確立.
                                                             (line   84)
* RFC; RFC 8470:                         HTTP ステータスコード.
                                                             (line  148)
* RFC; RFC 9110:                         HTTP ステータスコード.
                                                             (line   13)
* RFC; RFC 9110 <1>:                     HTTP ステータスコード.
                                                             (line   16)
* RFC; RFC 9110 <2>:                     HTTP ステータスコード.
                                                             (line   25)
* RFC; RFC 9110 <3>:                     HTTP ステータスコード.
                                                             (line   28)
* RFC; RFC 9110 <4>:                     HTTP ステータスコード.
                                                             (line   31)
* RFC; RFC 9110 <5>:                     HTTP ステータスコード.
                                                             (line   34)
* RFC; RFC 9110 <6>:                     HTTP ステータスコード.
                                                             (line   37)
* RFC; RFC 9110 <7>:                     HTTP ステータスコード.
                                                             (line   40)
* RFC; RFC 9110 <8>:                     HTTP ステータスコード.
                                                             (line   43)
* RFC; RFC 9110 <9>:                     HTTP ステータスコード.
                                                             (line   55)
* RFC; RFC 9110 <10>:                    HTTP ステータスコード.
                                                             (line   58)
* RFC; RFC 9110 <11>:                    HTTP ステータスコード.
                                                             (line   61)
* RFC; RFC 9110 <12>:                    HTTP ステータスコード.
                                                             (line   64)
* RFC; RFC 9110 <13>:                    HTTP ステータスコード.
                                                             (line   67)
* RFC; RFC 9110 <14>:                    HTTP ステータスコード.
                                                             (line   70)
* RFC; RFC 9110 <15>:                    HTTP ステータスコード.
                                                             (line   73)
* RFC; RFC 9110 <16>:                    HTTP ステータスコード.
                                                             (line   76)
* RFC; RFC 9110 <17>:                    HTTP ステータスコード.
                                                             (line   79)
* RFC; RFC 9110 <18>:                    HTTP ステータスコード.
                                                             (line   82)
* RFC; RFC 9110 <19>:                    HTTP ステータスコード.
                                                             (line   85)
* RFC; RFC 9110 <20>:                    HTTP ステータスコード.
                                                             (line   88)
* RFC; RFC 9110 <21>:                    HTTP ステータスコード.
                                                             (line   91)
* RFC; RFC 9110 <22>:                    HTTP ステータスコード.
                                                             (line   94)
* RFC; RFC 9110 <23>:                    HTTP ステータスコード.
                                                             (line   97)
* RFC; RFC 9110 <24>:                    HTTP ステータスコード.
                                                             (line  100)
* RFC; RFC 9110 <25>:                    HTTP ステータスコード.
                                                             (line  103)
* RFC; RFC 9110 <26>:                    HTTP ステータスコード.
                                                             (line  106)
* RFC; RFC 9110 <27>:                    HTTP ステータスコード.
                                                             (line  109)
* RFC; RFC 9110 <28>:                    HTTP ステータスコード.
                                                             (line  112)
* RFC; RFC 9110 <29>:                    HTTP ステータスコード.
                                                             (line  115)
* RFC; RFC 9110 <30>:                    HTTP ステータスコード.
                                                             (line  118)
* RFC; RFC 9110 <31>:                    HTTP ステータスコード.
                                                             (line  121)
* RFC; RFC 9110 <32>:                    HTTP ステータスコード.
                                                             (line  124)
* RFC; RFC 9110 <33>:                    HTTP ステータスコード.
                                                             (line  127)
* RFC; RFC 9110 <34>:                    HTTP ステータスコード.
                                                             (line  130)
* RFC; RFC 9110 <35>:                    HTTP ステータスコード.
                                                             (line  136)
* RFC; RFC 9110 <36>:                    HTTP ステータスコード.
                                                             (line  139)
* RFC; RFC 9110 <37>:                    HTTP ステータスコード.
                                                             (line  151)
* RFC; RFC 9110 <38>:                    HTTP ステータスコード.
                                                             (line  166)
* RFC; RFC 9110 <39>:                    HTTP ステータスコード.
                                                             (line  169)
* RFC; RFC 9110 <40>:                    HTTP ステータスコード.
                                                             (line  172)
* RFC; RFC 9110 <41>:                    HTTP ステータスコード.
                                                             (line  175)
* RFC; RFC 9110 <42>:                    HTTP ステータスコード.
                                                             (line  178)
* RFC; RFC 9110 <43>:                    HTTP ステータスコード.
                                                             (line  181)
* RFC; RFC 9110 <44>:                    HTTP ステータスコードカテゴリ.
                                                             (line   15)
* RFC; RFC 9110 <45>:                    HTTP ステータスコードカテゴリ.
                                                             (line   18)
* RFC; RFC 9110 <46>:                    HTTP ステータスコードカテゴリ.
                                                             (line   21)
* RFC; RFC 9110 <47>:                    HTTP ステータスコードカテゴリ.
                                                             (line   24)
* RFC; RFC 9110 <48>:                    HTTP ステータスコードカテゴリ.
                                                             (line   27)
* RFC; RFC 9110 <49>:                    HTTP メソッド.      (line   13)
* RFC; RFC 9110 <50>:                    HTTP メソッド.      (line   16)
* RFC; RFC 9110 <51>:                    HTTP メソッド.      (line   19)
* RFC; RFC 9110 <52>:                    HTTP メソッド.      (line   22)
* RFC; RFC 9110 <53>:                    HTTP メソッド.      (line   25)
* RFC; RFC 9110 <54>:                    HTTP メソッド.      (line   28)
* RFC; RFC 9110 <55>:                    HTTP メソッド.      (line   31)
* RFC; RFC 9110 <56>:                    HTTP メソッド.      (line   34)
* RFC; RFC 9239:                         Library<22>.        (line   76)
* RFC; RFC 959:                          ftplib --- FTP プロトコルクライアント.
                                                             (line   16)
* rfc2109 (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   73)
* rfc2109_as_netscape (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line   82)
* rfc2965 (http.cookiejar.CookiePolicy の属性): CookiePolicy オブジェクト.
                                                             (line   75)
* rfile (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  120)
* rfile (socketserver.DatagramRequestHandler の属性): Request Handler Objects.
                                                             (line   62)
* rfind() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  215)
* rfind() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  215)
* rfind() (mmap.mmap のメソッド):        mmap --- メモリマップファイルのサポート.
                                                             (line  285)
* rfind() (str のメソッド):              文字列メソッド<2>.  (line  391)
* rgb_to_hls() (colorsys モジュール):    colorsys --- 色体系間の変換.
                                                             (line   36)
* rgb_to_hsv() (colorsys モジュール):    colorsys --- 色体系間の変換.
                                                             (line   44)
* rgb_to_yiq() (colorsys モジュール):    colorsys --- 色体系間の変換.
                                                             (line   28)
* rglob() (pathlib.Path のメソッド):     ディレクトリを読む. (line   78)
* richcmpfunc (C type):                  Slot Type typedefs. (line   89)
* right (filecmp.dircmp の属性):         dircmp クラス.      (line   48)
* right_list (filecmp.dircmp の属性):    dircmp クラス.      (line   57)
* right_only (filecmp.dircmp の属性):    dircmp クラス.      (line   71)
* right() (turtle モジュール):           Turtle の動き.      (line   40)
* RIGHTSHIFT (token モジュール):         token --- Python 解析木で使われる定数.
                                                             (line  159)
* RIGHTSHIFTEQUAL (token モジュール):    token --- Python 解析木で使われる定数.
                                                             (line  203)
* rindex() (bytearray のメソッド):       bytes と bytearray の操作.
                                                             (line  229)
* rindex() (bytes のメソッド):           bytes と bytearray の操作.
                                                             (line  229)
* rindex() (str のメソッド):             文字列メソッド<2>.  (line  398)
* rjust() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  346)
* rjust() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  346)
* rjust() (str のメソッド):              文字列メソッド<2>.  (line  403)
* RLIM_INFINITY (resource モジュール):   リソースの制限.     (line   22)
* RLIMIT_AS (resource モジュール):       リソースの制限.     (line  149)
* RLIMIT_CORE (resource モジュール):     リソースの制限.     (line   93)
* RLIMIT_CPU (resource モジュール):      リソースの制限.     (line  100)
* RLIMIT_DATA (resource モジュール):     リソースの制限.     (line  112)
* RLIMIT_FSIZE (resource モジュール):    リソースの制限.     (line  108)
* RLIMIT_KQUEUES (resource モジュール):  リソースの制限.     (line  223)
* RLIMIT_MEMLOCK (resource モジュール):  リソースの制限.     (line  139)
* RLIMIT_MSGQUEUE (resource モジュール): リソースの制限.     (line  153)
* RLIMIT_NICE (resource モジュール):     リソースの制限.     (line  161)
* RLIMIT_NOFILE (resource モジュール):   リソースの制限.     (line  131)
* RLIMIT_NPROC (resource モジュール):    リソースの制限.     (line  127)
* RLIMIT_NPTS (resource モジュール):     リソースの制限.     (line  215)
* RLIMIT_OFILE (resource モジュール):    リソースの制限.     (line  135)
* RLIMIT_RSS (resource モジュール):      リソースの制限.     (line  122)
* RLIMIT_RTPRIO (resource モジュール):   リソースの制限.     (line  169)
* RLIMIT_RTTIME (resource モジュール):   リソースの制限.     (line  177)
* RLIMIT_SBSIZE (resource モジュール):   リソースの制限.     (line  194)
* RLIMIT_SIGPENDING (resource モジュール): リソースの制限.   (line  186)
* RLIMIT_STACK (resource モジュール):    リソースの制限.     (line  116)
* RLIMIT_SWAP (resource モジュール):     リソースの制限.     (line  204)
* RLIMIT_VMEM (resource モジュール):     リソースの制限.     (line  143)
* RLock (multiprocessing のクラス):      同期プリミティブ.   (line   97)
* RLock (threading のクラス):            RLock オブジェクト. (line   33)
* RLock() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  205)
* rmd() (ftplib.FTP のメソッド):         FTP オブジェクト.   (line  346)
* rmdir() (os モジュール):               ファイルとディレクトリ.
                                                             (line  841)
* rmdir() (pathlib.Path のメソッド):     リネームと削除.     (line   61)
* rmdir() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  110)
* rmtree() (shutil モジュール):          ディレクトリとファイルの操作.
                                                             (line  267)
* rmtree() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  117)
* RobotFileParser (urllib.robotparser のクラス): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   16)
* robots.txt:                            urllib robotparser --- robots txt 用のパーサー.
                                                             (line    8)
* rollback() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line   81)
* rollover() (tempfile.SpooledTemporaryFile のメソッド): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  161)
* ROMAN (tkinter.font モジュール):       tkinter font --- Tkinter フォントラッパー.
                                                             (line   15)
* root (pathlib.PurePath の属性):        メソッドとプロパティ.
                                                             (line   31)
* rotate() (collections.deque のメソッド): deque オブジェクト.
                                                             (line  110)
* rotate() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  488)
* rotate() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  500)
* rotate() (logging.handlers.BaseRotatingHandler のメソッド): BaseRotatingHandler.
                                                             (line   75)
* RotatingFileHandler (logging.handlers のクラス): RotatingFileHandler.
                                                             (line   10)
* rotation_filename() (logging.handlers.BaseRotatingHandler のメソッド): BaseRotatingHandler.
                                                             (line   57)
* rotator (logging.handlers.BaseRotatingHandler の属性): BaseRotatingHandler.
                                                             (line   49)
* ROUND_05UP (decimal モジュール):       丸めモード.         (line   34)
* ROUND_CEILING (decimal モジュール):    丸めモード.         (line    6)
* ROUND_DOWN (decimal モジュール):       丸めモード.         (line   10)
* ROUND_FLOOR (decimal モジュール):      丸めモード.         (line   14)
* ROUND_HALF_DOWN (decimal モジュール):  丸めモード.         (line   18)
* ROUND_HALF_EVEN (decimal モジュール):  丸めモード.         (line   22)
* ROUND_HALF_UP (decimal モジュール):    丸めモード.         (line   26)
* ROUND_UP (decimal モジュール):         丸めモード.         (line   30)
* Rounded (decimal のクラス):            シグナル.           (line   79)
* rounds (sys.float_info の属性):        sys --- システム固有のパラメーターと関数.
                                                             (line  657)
* Row (sqlite3 のクラス):                Row オブジェクト.   (line    6)
* row_factory (sqlite3.Connection の属性): Connection オブジェクト.
                                                             (line  811)
* row_factory (sqlite3.Cursor の属性):   Cursor オブジェクト.
                                                             (line  222)
* rowcount (sqlite3.Cursor の属性):      Cursor オブジェクト.
                                                             (line  213)
* RPAR (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   55)
* rpartition() (bytearray のメソッド):   bytes と bytearray の操作.
                                                             (line  241)
* rpartition() (bytes のメソッド):       bytes と bytearray の操作.
                                                             (line  241)
* rpartition() (str のメソッド):         文字列メソッド<2>.  (line  409)
* rpc_paths (xmlrpc.server.SimpleXMLRPCRequestHandler の属性): SimpleXMLRPCServer オブジェクト.
                                                             (line   62)
* rpop() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   45)
* RS (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  114)
* rset() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   74)
* RShift (ast のクラス):                 式 expression<2>.   (line   55)
* rshift() (operator モジュール):        operator --- 関数形式の標準演算子.
                                                             (line  147)
* rsplit() (bytearray のメソッド):       bytes と bytearray の操作.
                                                             (line  358)
* rsplit() (bytes のメソッド):           bytes と bytearray の操作.
                                                             (line  358)
* rsplit() (str のメソッド):             文字列メソッド<2>.  (line  416)
* RSQB (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   63)
* rstrip() (bytearray のメソッド):       bytes と bytearray の操作.
                                                             (line  369)
* rstrip() (bytes のメソッド):           bytes と bytearray の操作.
                                                             (line  369)
* rstrip() (str のメソッド):             文字列メソッド<2>.  (line  425)
* rt() (turtle モジュール):              Turtle の動き.      (line   40)
* RTLD_DEEPBIND (os モジュール):         雑多なシステム情報. (line  163)
* RTLD_GLOBAL (os モジュール):           雑多なシステム情報. (line  163)
* RTLD_LAZY (os モジュール):             雑多なシステム情報. (line  163)
* RTLD_LOCAL (os モジュール):            雑多なシステム情報. (line  163)
* RTLD_NODELETE (os モジュール):         雑多なシステム情報. (line  163)
* RTLD_NOLOAD (os モジュール):           雑多なシステム情報. (line  163)
* RTLD_NOW (os モジュール):              雑多なシステム情報. (line  163)
* ruler (cmd.Cmd の属性):                Cmdオブジェクト.    (line  170)
* run (pdb command):                     デバッガコマンド.   (line  412)
* Run script:                            Format メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   55)
* run_coroutine_threadsafe() (asyncio モジュール): 外部スレッドからのスケジュール.
                                                             (line    6)
* run_docstring_examples() (doctest モジュール): 基本 API.   (line  131)
* run_forever() (asyncio.loop のメソッド): ループの開始と停止.
                                                             (line   17)
* run_in_executor() (asyncio.loop のメソッド): スレッドまたはプロセスプールでコードを実行する.
                                                             (line    6)
* run_in_subinterp() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  662)
* run_module() (runpy モジュール):       runpy --- Python モジュールの位置特定と実行.
                                                             (line   27)
* run_path() (runpy モジュール):         runpy --- Python モジュールの位置特定と実行.
                                                             (line   98)
* run_python_until_end() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   30)
* run_script() (modulefinder.ModuleFinder のメソッド): modulefinder --- スクリプト中で使用されているモジュールの検索.
                                                             (line   46)
* run_until_complete() (asyncio.loop のメソッド): ループの開始と停止.
                                                             (line    6)
* run_with_locale() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  466)
* run_with_tz() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  473)
* run() (asyncio モジュール):            非同期プログラムの実行.
                                                             (line    6)
* run() (asyncio.Runner のメソッド):     Runner context manager.
                                                             (line   37)
* run() (bdb.Bdb のメソッド):            bdb --- デバッガーフレームワーク.
                                                             (line  436)
* run() (contextvars.Context のメソッド): マニュアルでのコンテキスト管理.
                                                             (line   64)
* run() (doctest.DocTestRunner のメソッド): DocTestRunner オブジェクト.
                                                             (line  102)
* run() (multiprocessing.Process のメソッド): Process クラスと例外.
                                                             (line   35)
* run() (pdb モジュール):                pdb --- Python デバッガ.
                                                             (line  126)
* run() (pdb.Pdb のメソッド):            pdb --- Python デバッガ.
                                                             (line  217)
* run() (profile モジュール):            リファレンスマニュアル -- profile と cProfile.
                                                             (line    9)
* run() (profile.Profile のメソッド):    リファレンスマニュアル -- profile と cProfile.
                                                             (line  106)
* run() (sched.scheduler のメソッド):    スケジューラオブジェクト.
                                                             (line   50)
* run() (subprocess モジュール):         subprocess モジュールを使う.
                                                             (line   10)
* run() (threading.Thread のメソッド):   Thread オブジェクト.
                                                             (line  111)
* run() (trace.Trace のメソッド):        プログラミングインターフェース.
                                                             (line   21)
* run() (unittest.IsolatedAsyncioTestCase のメソッド): テストクラス.
                                                             (line  899)
* run() (unittest.TestCase のメソッド):  テストクラス.       (line   84)
* run() (unittest.TestSuite のメソッド): テストのグループ化. (line   41)
* run() (unittest.TextTestRunner のメソッド): テストのロードと起動.
                                                             (line  498)
* run() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line   99)
* runcall() (bdb.Bdb のメソッド):        bdb --- デバッガーフレームワーク.
                                                             (line  452)
* runcall() (pdb モジュール):            pdb --- Python デバッガ.
                                                             (line  145)
* runcall() (pdb.Pdb のメソッド):        pdb --- Python デバッガ.
                                                             (line  217)
* runcall() (profile.Profile のメソッド): リファレンスマニュアル -- profile と cProfile.
                                                             (line  115)
* runcode() (code.InteractiveInterpreter のメソッド): 対話的なインタプリタオブジェクト.
                                                             (line   33)
* runctx() (bdb.Bdb のメソッド):         bdb --- デバッガーフレームワーク.
                                                             (line  447)
* runctx() (profile モジュール):         リファレンスマニュアル -- profile と cProfile.
                                                             (line   23)
* runctx() (profile.Profile のメソッド): リファレンスマニュアル -- profile と cProfile.
                                                             (line  110)
* runctx() (trace.Trace のメソッド):     プログラミングインターフェース.
                                                             (line   27)
* runeval() (bdb.Bdb のメソッド):        bdb --- デバッガーフレームワーク.
                                                             (line  442)
* runeval() (pdb モジュール):            pdb --- Python デバッガ.
                                                             (line  138)
* runeval() (pdb.Pdb のメソッド):        pdb --- Python デバッガ.
                                                             (line  217)
* runfunc() (trace.Trace のメソッド):    プログラミングインターフェース.
                                                             (line   34)
* Runner (asyncio のクラス):             Runner context manager.
                                                             (line    6)
* running() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   27)
* runsource() (code.InteractiveInterpreter のメソッド): 対話的なインタプリタオブジェクト.
                                                             (line    6)
* runtime (sys._emscripten_info の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  344)
* runtime_checkable() (typing モジュール): Other special directives.
                                                             (line  175)
* RuntimeError:                          具象例外.           (line  239)
* RuntimeWarning:                        警告.               (line   46)
* RUSAGE_BOTH (resource モジュール):     リソースの使用状態. (line  123)
* RUSAGE_CHILDREN (resource モジュール): リソースの使用状態. (line  117)
* RUSAGE_SELF (resource モジュール):     リソースの使用状態. (line  111)
* RUSAGE_THREAD (resource モジュール):   リソースの使用状態. (line  129)
* RWF_APPEND (os モジュール):            ファイル記述子の操作.
                                                             (line  715)
* RWF_DSYNC (os モジュール):             ファイル記述子の操作.
                                                             (line  695)
* RWF_HIPRI (os モジュール):             ファイル記述子の操作.
                                                             (line  624)
* RWF_NOWAIT (os モジュール):            ファイル記述子の操作.
                                                             (line  610)
* RWF_SYNC (os モジュール):              ファイル記述子の操作.
                                                             (line  705)
* S (re モジュール):                     フラグ.             (line  103)
* S_ENFMT (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  323)
* S_IEXEC (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  337)
* S_IFBLK (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  211)
* S_IFCHR (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  219)
* S_IFDIR (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  215)
* S_IFDOOR (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  227)
* S_IFIFO (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  223)
* S_IFLNK (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  203)
* S_IFMT() (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line   83)
* S_IFPORT (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  233)
* S_IFREG (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  207)
* S_IFSOCK (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  199)
* S_IFWHT (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  239)
* S_IMODE() (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line   75)
* S_IREAD (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  329)
* S_IRGRP (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  295)
* S_IROTH (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  311)
* S_IRUSR (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  279)
* S_IRWXG (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  291)
* S_IRWXO (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  307)
* S_IRWXU (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  275)
* S_ISBLK() (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line   31)
* S_ISCHR() (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line   26)
* S_ISDIR() (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line   22)
* S_ISDOOR() (stat モジュール):          stat --- stat の結果を解釈する.
                                                             (line   54)
* S_ISFIFO() (stat モジュール):          stat --- stat の結果を解釈する.
                                                             (line   40)
* S_ISGID (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  256)
* S_ISLNK() (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line   45)
* S_ISPORT() (stat モジュール):          stat --- stat の結果を解釈する.
                                                             (line   60)
* S_ISREG() (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line   36)
* S_ISSOCK() (stat モジュール):          stat --- stat の結果を解釈する.
                                                             (line   50)
* S_ISUID (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  252)
* S_ISVTX (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  268)
* S_ISWHT() (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line   66)
* S_IWGRP (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  299)
* S_IWOTH (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  315)
* S_IWRITE (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  333)
* S_IWUSR (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  283)
* S_IXGRP (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  303)
* S_IXOTH (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  319)
* S_IXUSR (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  287)
* safe (uuid.SafeUUID の属性):           uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   34)
* safe_path (sys.flags の属性):          sys --- システム固有のパラメーターと関数.
                                                             (line  558)
* safe_substitute() (string.Template のメソッド): テンプレート文字列.
                                                             (line   51)
* SafeChildWatcher (asyncio のクラス):   プロセスのウオッチャー.
                                                             (line  132)
* saferepr() (pprint モジュール):        関数<4>.            (line  101)
* SafeUUID (uuid のクラス):              uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   30)
* same_files (filecmp.dircmp の属性):    dircmp クラス.      (line   88)
* same_quantum() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  492)
* same_quantum() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  510)
* samefile() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  411)
* samefile() (pathlib.Path のメソッド):  ファイルの種類とステータスを問い合わせる.
                                                             (line  162)
* SameFileError:                         ディレクトリとファイルの操作.
                                                             (line   53)
* sameopenfile() (os.path モジュール):   os path --- 一般的なパス名操作.
                                                             (line  426)
* samesite (http.cookies.Morsel の属性): Morselオブジェクト. (line   13)
* samestat() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  436)
* sample() (random モジュール):          シーケンス用の関数. (line   66)
* samples() (statistics.NormalDist のメソッド): NormalDist オブジェクト.
                                                             (line   58)
* SATURDAY (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  381)
* save() (http.cookiejar.FileCookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line  110)
* save() (test.support.SaveSignals のメソッド): test support --- テストのためのユーティリティ関数.
                                                             (line  773)
* SaveAs (tkinter.filedialog のクラス):  ネイティブの読み込み/保存ダイアログ.
                                                             (line   59)
* SAVEDCWD (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   15)
* SaveFileDialog (tkinter.filedialog のクラス): ネイティブの読み込み/保存ダイアログ.
                                                             (line  144)
* SaveKey() (winreg モジュール):         関数<13>.           (line  393)
* SaveSignals (test.support のクラス):   test support --- テストのためのユーティリティ関数.
                                                             (line  768)
* savetty() (curses モジュール):         関数<6>.            (line  428)
* SAX2DOM (xml.dom.pulldom のクラス):    xml dom pulldom --- 部分的な DOM ツリー構築のサポート.
                                                             (line   80)
* SAXException:                          xml sax --- SAX2 バーサーのサポート.
                                                             (line   89)
* SAXNotRecognizedException:             xml sax --- SAX2 バーサーのサポート.
                                                             (line  113)
* SAXNotSupportedException:              xml sax --- SAX2 バーサーのサポート.
                                                             (line  120)
* SAXParseException:                     xml sax --- SAX2 バーサーのサポート.
                                                             (line  105)
* scaleb() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  496)
* scaleb() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  520)
* scandir() (os モジュール):             ファイルとディレクトリ.
                                                             (line  859)
* scanf (C function):                    scanf をシミュレートする.
                                                             (line    6)
* SCHED_BATCH (os モジュール):           スケジューラーへのインターフェイス.
                                                             (line   19)
* SCHED_FIFO (os モジュール):            スケジューラーへのインターフェイス.
                                                             (line   33)
* sched_get_priority_max() (os モジュール): スケジューラーへのインターフェイス.
                                                             (line   66)
* sched_get_priority_min() (os モジュール): スケジューラーへのインターフェイス.
                                                             (line   61)
* sched_getaffinity() (os モジュール):   スケジューラーへのインターフェイス.
                                                             (line  111)
* sched_getparam() (os モジュール):      スケジューラーへのインターフェイス.
                                                             (line   90)
* sched_getscheduler() (os モジュール):  スケジューラーへのインターフェイス.
                                                             (line   78)
* SCHED_IDLE (os モジュール):            スケジューラーへのインターフェイス.
                                                             (line   24)
* SCHED_OTHER (os モジュール):           スケジューラーへのインターフェイス.
                                                             (line   15)
* sched_param (os のクラス):             スケジューラーへのインターフェイス.
                                                             (line   48)
* sched_priority (os.sched_param の属性): スケジューラーへのインターフェイス.
                                                             (line   57)
* SCHED_RESET_ON_FORK (os モジュール):   スケジューラーへのインターフェイス.
                                                             (line   41)
* SCHED_RR (os モジュール):              スケジューラーへのインターフェイス.
                                                             (line   37)
* sched_rr_get_interval() (os モジュール): スケジューラーへのインターフェイス.
                                                             (line   96)
* sched_setaffinity() (os モジュール):   スケジューラーへのインターフェイス.
                                                             (line  105)
* sched_setparam() (os モジュール):      スケジューラーへのインターフェイス.
                                                             (line   84)
* sched_setscheduler() (os モジュール):  スケジューラーへのインターフェイス.
                                                             (line   71)
* SCHED_SPORADIC (os モジュール):        スケジューラーへのインターフェイス.
                                                             (line   29)
* sched_yield() (os モジュール):         スケジューラーへのインターフェイス.
                                                             (line  101)
* scheduler (sched のクラス):            sched --- イベントスケジューラー.
                                                             (line   13)
* SCM_CREDS2 (socket モジュール):        定数<8>.            (line  322)
* scope_id (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  290)
* Screen (turtle のクラス):              Public classes.     (line   30)
* screensize() (turtle モジュール):      ウィンドウの制御.   (line   61)
* script_from_examples() (doctest モジュール): デバッグ.     (line   73)
* scroll() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  483)
* ScrolledCanvas (turtle のクラス):      Public classes.     (line   35)
* ScrolledText (tkinter.scrolledtext のクラス): tkinter scrolledtext --- スクロール可能なテキストウィジェット.
                                                             (line   23)
* scrollok() (curses.window のメソッド): Window オブジェクト.
                                                             (line  487)
* scrypt() (hashlib モジュール):         鍵導出.             (line   49)
* seal() (unittest.mock モジュール):     Sealing mocks.      (line    6)
* search() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  228)
* search() (re モジュール):              関数<2>.            (line   34)
* search() (re.Pattern のメソッド):      正規表現オブジェクト.
                                                             (line   15)
* second (datetime.datetime の属性):     datetime オブジェクト.
                                                             (line  323)
* second (datetime.time の属性):         time オブジェクト.  (line   58)
* seconds (datetime.timedelta の属性):   timedelta オブジェクト.
                                                             (line   96)
* SECTCRE (configparser.ConfigParser の属性): パーサーの振る舞いをカスタマイズする.
                                                             (line  288)
* sections() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  112)
* secure (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   48)
* secure (http.cookies.Morsel の属性):   Morselオブジェクト. (line   13)
* secure hash algorithm, SHA1, SHA2, SHA224, SHA256, SHA384, SHA512, SHA3, Shake, Blake2: hashlib --- セキュアハッシュとメッセージダイジェスト.
                                                             (line    8)
* Secure Sockets Layer:                  ssl --- ソケットオブジェクト用の TLS/SSL ラッパー.
                                                             (line    8)
* security considerations:               例外<20>.           (line   29)
* security_level (ssl.SSLContext の属性): SSL コンテキスト.  (line  624)
* see() (tkinter.ttk.Treeview のメソッド): ttk Treeview.     (line  240)
* seed_bits (sys.hash_info の属性):      sys --- システム固有のパラメーターと関数.
                                                             (line 1044)
* seed() (random モジュール):            保守 bookkeeping 関数.
                                                             (line    6)
* seed() (random.Random のメソッド):     他の生成器.         (line   19)
* SEEK_CUR (os モジュール):              ファイル記述子の操作.
                                                             (line  324)
* SEEK_DATA (os モジュール):             ファイル記述子の操作.
                                                             (line  348)
* SEEK_END (os モジュール):              ファイル記述子の操作.
                                                             (line  324)
* SEEK_HOLE (os モジュール):             ファイル記述子の操作.
                                                             (line  348)
* SEEK_SET (os モジュール):              ファイル記述子の操作.
                                                             (line  324)
* seek() (io.IOBase のメソッド):         I/O 基底クラス.     (line  105)
* seek() (io.TextIOBase のメソッド):     テキスト I/O<2>.    (line   64)
* seek() (io.TextIOWrapper のメソッド):  テキスト I/O<2>.    (line  199)
* seek() (mmap.mmap のメソッド):         mmap --- メモリマップファイルのサポート.
                                                             (line  295)
* seek() (sqlite3.Blob のメソッド):      Blob オブジェクト.  (line   66)
* seekable() (bz2.BZ2File のメソッド):   ファイルの圧縮/解凍.
                                                             (line   98)
* seekable() (io.IOBase のメソッド):     I/O 基底クラス.     (line  128)
* seekable() (mmap.mmap のメソッド):     mmap --- メモリマップファイルのサポート.
                                                             (line  306)
* select() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  245)
* select() (select モジュール):          select --- I/O 完了の待機.
                                                             (line  115)
* select() (selectors.BaseSelector のメソッド): クラス<4>.   (line  112)
* select() (tkinter.ttk.Notebook のメソッド): ttk Notebook.  (line   52)
* selected_alpn_protocol() (ssl.SSLSocket のメソッド): SSL ソケット.
                                                             (line  268)
* selected_npn_protocol() (ssl.SSLSocket のメソッド): SSL ソケット.
                                                             (line  278)
* selection_add() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  263)
* selection_remove() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  270)
* selection_set() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  256)
* selection_toggle() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  277)
* selection() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  248)
* selector (urllib.request.Request の属性): Request オブジェクト.
                                                             (line   34)
* SelectorEventLoop (asyncio のクラス):  イベントループの実装.
                                                             (line   11)
* SelectorKey (selectors のクラス):      クラス<4>.          (line   29)
* SelectSelector (selectors のクラス):   クラス<4>.          (line  170)
* Self (typing モジュール):              特殊型.             (line  138)
* Semaphore (asyncio のクラス):          Semaphore.          (line    6)
* Semaphore (multiprocessing のクラス):  同期プリミティブ.   (line  160)
* Semaphore (threading のクラス):        Semaphore オブジェクト.
                                                             (line   20)
* Semaphore() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  210)
* semaphores, binary:                    _thread --- 低水準なスレッド API.
                                                             (line    6)
* SEMI (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   75)
* SEND (opcode):                         Python バイトコード命令.
                                                             (line 1241)
* send_bytes() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   55)
* send_error() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  218)
* send_fds() (socket モジュール):        その他の関数<2>.    (line  460)
* send_header() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  254)
* send_message() (smtplib.SMTP のメソッド): SMTP オブジェクト.
                                                             (line  296)
* send_response_only() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  266)
* send_response() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  238)
* send_signal() (asyncio.subprocess.Process のメソッド): サブプロセスとやりとりする.
                                                             (line   87)
* send_signal() (asyncio.SubprocessTransport のメソッド): サブプロセス化されたトランスポート.
                                                             (line   44)
* send_signal() (subprocess.Popen のメソッド): Popen オブジェクト.
                                                             (line   77)
* send() (coroutine のメソッド):         コルーチンオブジェクト.
                                                             (line   22)
* send() (generator のメソッド):         ジェネレータ-イテレータメソッド.
                                                             (line   27)
* send() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line  212)
* send() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line  252)
* send() (logging.handlers.DatagramHandler のメソッド): DatagramHandler.
                                                             (line   44)
* send() (logging.handlers.SocketHandler のメソッド): SocketHandler.
                                                             (line   62)
* send() (multiprocessing.connection.Connection のメソッド): Connection オブジェクト<2>.
                                                             (line   15)
* send() (socket.socket のメソッド):     socket オブジェクト.
                                                             (line  397)
* sendall() (socket.socket のメソッド):  socket オブジェクト.
                                                             (line  412)
* sendcmd() (ftplib.FTP のメソッド):     FTP オブジェクト.   (line  156)
* sendfile() (asyncio.loop のメソッド):  ファイルの転送.     (line    6)
* sendfile() (os モジュール):            ファイル記述子の操作.
                                                             (line  749)
* sendfile() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  502)
* sendfile() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  275)
* SendfileNotAvailableError:             例外<12>.           (line   38)
* sendfunc (C type):                     Slot Type typedefs. (line  124)
* sendmail() (smtplib.SMTP のメソッド):  SMTP オブジェクト.  (line  222)
* sendmsg_afalg() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  491)
* sendmsg() (socket.socket のメソッド):  socket オブジェクト.
                                                             (line  448)
* sendto() (asyncio.DatagramTransport のメソッド): データグラムトランスポート.
                                                             (line    6)
* sendto() (socket.socket のメソッド):   socket オブジェクト.
                                                             (line  430)
* sentinel (multiprocessing.Process の属性): Process クラスと例外.
                                                             (line  156)
* sentinel (unittest.mock モジュール):   sentinel.           (line    6)
* sep (os モジュール):                   雑多なシステム情報. (line  112)
* SEPTEMBER (calendar モジュール):       calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  424)
* sequence:                              用語集<2>.          (line 1291)
* Sequence (collections.abc のクラス):   コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   68)
* Sequence (typing のクラス):            Aliases to container ABCs in collections abc.
                                                             (line   98)
* sequence;反復処理:                     イテレータ型.       (line    6)
* sequence;要素:                         添字表記 subscription.
                                                             (line    6)
* SequenceMatcher (difflib のクラス):    SequenceMatcherオブジェクト.
                                                             (line    9)
* serialize() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  691)
* serve_forever() (asyncio.Server のメソッド): Serverオブジェクト.
                                                             (line   92)
* serve_forever() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line   32)
* Server (asyncio のクラス):             Serverオブジェクト. (line   12)
* server (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line   77)
* server (socketserver.BaseRequestHandler の属性): Request Handler Objects.
                                                             (line   51)
* server_activate() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  159)
* server_address (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line   76)
* server_bind() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  165)
* server_close() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line   61)
* server_hostname (ssl.SSLSocket の属性): SSL ソケット.      (line  347)
* server_side (ssl.SSLSocket の属性):    SSL ソケット.       (line  340)
* server_software (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  176)
* server_version (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  137)
* server_version (http.server.SimpleHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  360)
* ServerProxy (xmlrpc.client のクラス):  xmlrpc client --- XML-RPC クライアントアクセス.
                                                             (line   30)
* service_actions() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line   45)
* session (ssl.SSLSocket の属性):        SSL ソケット.       (line  359)
* session_reused (ssl.SSLSocket の属性): SSL ソケット.       (line  369)
* session_stats() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  480)
* Set (ast のクラス):                    リテラル<3>.        (line   90)
* Set (collections.abc のクラス):        コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   93)
* Set (typing のクラス):                 Aliases to built-in types.
                                                             (line   30)
* set (組み込みクラス):                  set（集合）型 --- set frozenset.
                                                             (line   32)
* Set Breakpoint [ブレークポイントのセット]: Help メニュー Shell ウィンドウ、Editor ウィンドウ.
                                                             (line   32)
* set comprehension:                     用語集<2>.          (line 1312)
* SET_ADD (opcode):                      Python バイトコード命令.
                                                             (line  363)
* set_all():                             参照カウントの詳細. (line   97)
* set_allowed_domains() (http.cookiejar.DefaultCookiePolicy のメソッド): DefaultCookiePolicy オブジェクト.
                                                             (line   69)
* set_alpn_protocols() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  254)
* set_app() (wsgiref.simple_server.WSGIServer のメソッド): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   60)
* set_asyncgen_hooks() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line 1665)
* set_authorizer() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  354)
* set_auto_history() (readline モジュール): 履歴リスト.      (line   41)
* set_blocked_domains() (http.cookiejar.DefaultCookiePolicy のメソッド): DefaultCookiePolicy オブジェクト.
                                                             (line   55)
* set_blocking() (os モジュール):        ファイル記述子の操作.
                                                             (line  810)
* set_boundary() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  412)
* set_boundary() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  592)
* set_break() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  348)
* set_charset() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  237)
* set_child_watcher() (asyncio モジュール): プロセスのウオッチャー.
                                                             (line   31)
* set_child_watcher() (asyncio.AbstractEventLoopPolicy のメソッド): ポリシーオブジェクト.
                                                             (line   44)
* set_children() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line   26)
* set_ciphers() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  240)
* set_completer_delims() (readline モジュール): 補完.        (line   51)
* set_completer() (readline モジュール): 補完.               (line   14)
* set_completion_display_matches_hook() (readline モジュール): 補完.
                                                             (line   60)
* set_content() (email.contentmanager モジュール): Content Manager Instances.
                                                             (line   35)
* set_content() (email.contentmanager.ContentManager のメソッド): email contentmanager Managing MIME Content.
                                                             (line   39)
* set_content() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  591)
* set_continue() (bdb.Bdb のメソッド):   bdb --- デバッガーフレームワーク.
                                                             (line  332)
* set_cookie_if_ok() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   71)
* set_cookie() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   76)
* set_coroutine_origin_tracking_depth() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line 1690)
* set_data() (importlib.abc.SourceLoader のメソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  380)
* set_data() (importlib.machinery.SourceFileLoader のメソッド): importlib machinery -- インポータおよびパスフック.
                                                             (line  228)
* set_date() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line  100)
* set_debug() (asyncio.loop のメソッド): デバッグモードの有効化.
                                                             (line   14)
* set_debug() (gc モジュール):           gc --- ガベージコレクターインターフェース.
                                                             (line   48)
* set_debuglevel() (ftplib.FTP のメソッド): FTP オブジェクト.
                                                             (line   74)
* set_debuglevel() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line   89)
* set_debuglevel() (poplib.POP3 のメソッド): POP3 オブジェクト.
                                                             (line   11)
* set_debuglevel() (smtplib.SMTP のメソッド): SMTP オブジェクト.
                                                             (line    8)
* set_default_executor() (asyncio.loop のメソッド): スレッドまたはプロセスプールでコードを実行する.
                                                             (line   75)
* set_default_type() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  343)
* set_default_type() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  452)
* set_default_verify_paths() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  231)
* set_defaults() (argparse.ArgumentParser のメソッド): パーサーのデフォルト値.
                                                             (line    6)
* set_defaults() (optparse.OptionParser のメソッド): その他のメソッド.
                                                             (line   27)
* set_ecdh_curve() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  365)
* set_errno() (ctypes モジュール):       ユーティリティー関数.
                                                             (line  168)
* set_error_mode() (msvcrt モジュール):  その多の関数.       (line   12)
* set_escdelay() (curses モジュール):    関数<6>.            (line  439)
* set_event_loop_policy() (asyncio モジュール): ポリシーの取得と設定.
                                                             (line   13)
* set_event_loop() (asyncio モジュール): イベントループ.     (line   62)
* set_event_loop() (asyncio.AbstractEventLoopPolicy のメソッド): ポリシーオブジェクト.
                                                             (line   23)
* set_events() (sys.monitoring モジュール): Setting events globally.
                                                             (line   13)
* set_exception_handler() (asyncio.loop のメソッド): エラーハンドリング API.
                                                             (line    8)
* set_exception() (asyncio.Future のメソッド): Future オブジェクト<2>.
                                                             (line   57)
* set_exception() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line  119)
* set_executable() (multiprocessing モジュール): その他<3>.  (line  115)
* set_filter() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  126)
* set_flags() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  108)
* set_flags() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line   77)
* set_flags() (mailbox.mboxMessage のメソッド): mboxMessage オブジェクト.
                                                             (line   72)
* set_flags() (mailbox.MMDFMessage のメソッド): MMDFMessage オブジェクト.
                                                             (line   71)
* set_forkserver_preload() (multiprocessing モジュール): その他<3>.
                                                             (line  131)
* set_from() (mailbox.mboxMessage のメソッド): mboxMessage オブジェクト.
                                                             (line   55)
* set_from() (mailbox.MMDFMessage のメソッド): MMDFMessage オブジェクト.
                                                             (line   54)
* SET_FUNCTION_ATTRIBUTE (opcode):       Python バイトコード命令.
                                                             (line 1103)
* set_handle_inheritable() (os モジュール): ファイル記述子の継承.
                                                             (line   43)
* set_history_length() (readline モジュール): 履歴ファイル.  (line   30)
* set_info() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  170)
* set_info() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line  111)
* set_inheritable() (os モジュール):     ファイル記述子の継承.
                                                             (line   31)
* set_inheritable() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  518)
* set_int_max_str_digits() (sys モジュール): sys --- システム固有のパラメーターと関数.
                                                             (line 1471)
* set_labels() (mailbox.BabylMessage のメソッド): BabylMessage オブジェクト.
                                                             (line   50)
* set_last_error() (ctypes モジュール):  ユーティリティー関数.
                                                             (line  176)
* set_local_events() (sys.monitoring モジュール): Per code object events.
                                                             (line   16)
* set_memlimit() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  307)
* set_name() (asyncio.Task のメソッド):  Task オブジェクト.  (line  189)
* set_next() (bdb.Bdb のメソッド):       bdb --- デバッガーフレームワーク.
                                                             (line  309)
* set_nonstandard_attr() (http.cookiejar.Cookie のメソッド): Cookieオブジェクト<2>.
                                                             (line  109)
* set_npn_protocols() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  268)
* set_ok() (http.cookiejar.CookiePolicy のメソッド): CookiePolicy オブジェクト.
                                                             (line    9)
* set_param() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  352)
* set_param() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  520)
* set_pasv() (ftplib.FTP のメソッド):    FTP オブジェクト.   (line  212)
* set_payload() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  227)
* set_policy() (http.cookiejar.CookieJar のメソッド): CookieJar および FileCookieJar オブジェクト.
                                                             (line   59)
* set_pre_input_hook() (readline モジュール): 開始フック.    (line   14)
* set_progress_handler() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  387)
* set_protocol() (asyncio.BaseTransport のメソッド): 基底トランスポート.
                                                             (line   82)
* set_proxy() (urllib.request.Request のメソッド): Request オブジェクト.
                                                             (line  116)
* set_psk_client_callback() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  659)
* set_psk_server_callback() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  711)
* set_quit() (bdb.Bdb のメソッド):       bdb --- デバッガーフレームワーク.
                                                             (line  338)
* set_result() (asyncio.Future のメソッド): Future オブジェクト<2>.
                                                             (line   50)
* set_result() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line  107)
* set_return() (bdb.Bdb のメソッド):     bdb --- デバッガーフレームワーク.
                                                             (line  314)
* set_running_or_notify_cancel() (concurrent.futures.Future のメソッド): Future オブジェクト.
                                                             (line   86)
* set_selection() (tkinter.filedialog.FileDialog のメソッド): ネイティブの読み込み/保存ダイアログ.
                                                             (line  130)
* set_seq1() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line   54)
* set_seq2() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line   59)
* set_seqs() (difflib.SequenceMatcher のメソッド): SequenceMatcherオブジェクト.
                                                             (line   44)
* set_sequences() (mailbox.MH のメソッド): MH オブジェクト.  (line   63)
* set_sequences() (mailbox.MHMessage のメソッド): MHMessage オブジェクト.
                                                             (line   36)
* set_server_documentation() (xmlrpc.server.DocCGIXMLRPCRequestHandler のメソッド): DocCGIXMLRPCRequestHandler.
                                                             (line   23)
* set_server_documentation() (xmlrpc.server.DocXMLRPCServer のメソッド): DocXMLRPCServer オブジェクト.
                                                             (line   22)
* set_server_name() (xmlrpc.server.DocCGIXMLRPCRequestHandler のメソッド): DocCGIXMLRPCRequestHandler.
                                                             (line   18)
* set_server_name() (xmlrpc.server.DocXMLRPCServer のメソッド): DocXMLRPCServer オブジェクト.
                                                             (line   17)
* set_server_title() (xmlrpc.server.DocCGIXMLRPCRequestHandler のメソッド): DocCGIXMLRPCRequestHandler.
                                                             (line   13)
* set_server_title() (xmlrpc.server.DocXMLRPCServer のメソッド): DocXMLRPCServer オブジェクト.
                                                             (line   12)
* set_servername_callback (ssl.SSLContext の属性): SSL コンテキスト.
                                                             (line  336)
* set_start_method() (multiprocessing モジュール): その他<3>.
                                                             (line  148)
* set_startup_hook() (readline モジュール): 開始フック.      (line    6)
* set_step() (bdb.Bdb のメソッド):       bdb --- デバッガーフレームワーク.
                                                             (line  305)
* set_subdir() (mailbox.MaildirMessage のメソッド): MaildirMessage オブジェクト.
                                                             (line   62)
* set_tabsize() (curses モジュール):     関数<6>.            (line  454)
* set_task_factory() (asyncio.loop のメソッド): フューチャーとタスクの生成.
                                                             (line   40)
* set_threshold() (gc モジュール):       gc --- ガベージコレクターインターフェース.
                                                             (line   85)
* set_trace_callback() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  406)
* set_trace() (bdb モジュール):          bdb --- デバッガーフレームワーク.
                                                             (line  485)
* set_trace() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  323)
* set_trace() (pdb モジュール):          pdb --- Python デバッガ.
                                                             (line  152)
* set_trace() (pdb.Pdb のメソッド):      pdb --- Python デバッガ.
                                                             (line  217)
* set_tunnel() (http.client.HTTPConnection のメソッド): HTTPConnection オブジェクト.
                                                             (line   99)
* set_type() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  557)
* set_unittest_reportflags() (doctest モジュール): 単体テスト API.
                                                             (line  176)
* set_unixfrom() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  146)
* set_unixfrom() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  158)
* set_until() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  318)
* SET_UPDATE (opcode):                   Python バイトコード命令.
                                                             (line  715)
* set_url() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   21)
* set_usage() (optparse.OptionParser のメソッド): その他のメソッド.
                                                             (line    8)
* set_userptr() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   43)
* set_visible() (mailbox.BabylMessage のメソッド): BabylMessage オブジェクト.
                                                             (line   69)
* set_wakeup_fd() (signal モジュール):   モジュールの内容<2>.
                                                             (line  439)
* set_write_buffer_limits() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line   35)
* set() (asyncio.Event のメソッド):      Event.              (line   52)
* set() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  277)
* set() (configparser.RawConfigParser のメソッド): RawConfigParser オブジェクト.
                                                             (line   48)
* set() (contextvars.ContextVar のメソッド): コンテキスト変数.
                                                             (line   45)
* set() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   57)
* set() (test.support.os_helper.EnvironmentVarGuard のメソッド): test support os_helper --- Utilities for os tests.
                                                             (line   65)
* set() (threading.Event のメソッド):    Event オブジェクト. (line   31)
* set() (tkinter.ttk.Combobox のメソッド): ttk Combobox.     (line   19)
* set() (tkinter.ttk.Spinbox のメソッド): ttk Spinbox.       (line   12)
* set() (tkinter.ttk.Treeview のメソッド): ttk Treeview.     (line  284)
* set() (xml.etree.ElementTree.Element のメソッド): Element オブジェクト.
                                                             (line   77)
* setacl() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  260)
* setannotation() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  265)
* setattrfunc (C type):                  Slot Type typedefs. (line   52)
* setAttribute() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   69)
* setAttributeNode() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   73)
* setAttributeNodeNS() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   80)
* setAttributeNS() (xml.dom.Element のメソッド): Element オブジェクト<2>.
                                                             (line   88)
* setattrofunc (C type):                 Slot Type typedefs. (line   65)
* SetBase() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   22)
* setblocking() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  525)
* setByteStream() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   36)
* setcbreak() (tty モジュール):          tty --- 端末制御用の関数群.
                                                             (line   54)
* setCharacterStream() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   55)
* SetComp (ast のクラス):                内包表記 Comprehension.
                                                             (line    6)
* setcomptype() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   59)
* setconfig() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  675)
* setContentHandler() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   26)
* setcontext() (decimal モジュール):     Context オブジェクト.
                                                             (line   18)
* setDaemon() (threading.Thread のメソッド): Thread オブジェクト.
                                                             (line  221)
* setdefault() (dict のメソッド):        マッピング型 --- dict.
                                                             (line  200)
* setdefault() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   98)
* setdefaulttimeout() (socket モジュール): その他の関数<2>.  (line  379)
* setdlopenflags() (sys モジュール):     sys --- システム固有のパラメーターと関数.
                                                             (line 1458)
* setDocumentLocator() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   10)
* setDTDHandler() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   36)
* setegid() (os モジュール):             プロセスのパラメーター.
                                                             (line  371)
* setEncoding() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   22)
* setEntityResolver() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   45)
* setErrorHandler() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   56)
* seteuid() (os モジュール):             プロセスのパラメーター.
                                                             (line  377)
* setFeature() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   76)
* setfirstweekday() (calendar モジュール): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  283)
* setFormatter() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   50)
* setframerate() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   46)
* setgid() (os モジュール):              プロセスのパラメーター.
                                                             (line  383)
* setgroups() (os モジュール):           プロセスのパラメーター.
                                                             (line  389)
* seth() (turtle モジュール):            Turtle の動き.      (line  164)
* setheading() (turtle モジュール):      Turtle の動き.      (line  164)
* sethostname() (socket モジュール):     その他の関数<2>.    (line  386)
* setinputsizes() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line  162)
* setitem() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  200)
* setitimer() (signal モジュール):       モジュールの内容<2>.
                                                             (line  411)
* setLevel() (logging.Handler のメソッド): ハンドラオブジェクト.
                                                             (line   36)
* setLevel() (logging.Logger のメソッド): ロガーオブジェクト.
                                                             (line  104)
* setlimit() (sqlite3.Connection のメソッド): Connection オブジェクト.
                                                             (line  627)
* setlocale() (locale モジュール):       locale --- 国際化サービス.
                                                             (line   25)
* setLocale() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   61)
* setLoggerClass() (logging モジュール): モジュールレベルの関数.
                                                             (line  313)
* setlogmask() (syslog モジュール):      syslog --- Unix syslog ライブラリルーチン群.
                                                             (line   99)
* setLogRecordFactory() (logging モジュール): モジュールレベルの関数.
                                                             (line  325)
* setMaxConns() (urllib.request.CacheFTPHandler のメソッド): CacheFTPHandler オブジェクト.
                                                             (line   13)
* setmode() (msvcrt モジュール):         ファイル操作関連.   (line   38)
* setName() (threading.Thread のメソッド): Thread オブジェクト.
                                                             (line  165)
* setnchannels() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   38)
* setnframes() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   53)
* setns() (os モジュール):               プロセスのパラメーター.
                                                             (line  404)
* setoutputsize() (sqlite3.Cursor のメソッド): Cursor オブジェクト.
                                                             (line  166)
* SetParamEntityParsing() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   53)
* setparams() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   64)
* setpassword() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  246)
* setpgid() (os モジュール):             プロセスのパラメーター.
                                                             (line  451)
* setpgrp() (os モジュール):             プロセスのパラメーター.
                                                             (line  443)
* setpos() (turtle モジュール):          Turtle の動き.      (line   74)
* setpos() (wave.Wave_read のメソッド):  Wave_read オブジェクト.
                                                             (line   83)
* setposition() (turtle モジュール):     Turtle の動き.      (line   74)
* setpriority() (os モジュール):         プロセスのパラメーター.
                                                             (line  459)
* setprofile_all_threads() (threading モジュール): threading --- スレッドベースの並列処理.
                                                             (line  185)
* setprofile() (sys モジュール):         sys --- システム固有のパラメーターと関数.
                                                             (line 1479)
* setprofile() (threading モジュール):   threading --- スレッドベースの並列処理.
                                                             (line  178)
* setProperty() (xml.sax.xmlreader.XMLReader のメソッド): XMLReader オブジェクト.
                                                             (line   89)
* setPublicId() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line    6)
* setquota() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  270)
* setraw() (tty モジュール):             tty --- 端末制御用の関数群.
                                                             (line   43)
* setrecursionlimit() (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line 1536)
* setregid() (os モジュール):            プロセスのパラメーター.
                                                             (line  476)
* SetReparseDeferralEnabled() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   80)
* setresgid() (os モジュール):           プロセスのパラメーター.
                                                             (line  482)
* setresuid() (os モジュール):           プロセスのパラメーター.
                                                             (line  491)
* setreuid() (os モジュール):            プロセスのパラメーター.
                                                             (line  500)
* setrlimit() (resource モジュール):     リソースの制限.     (line   33)
* setsampwidth() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   42)
* setscrreg() (curses.window のメソッド): Window オブジェクト.
                                                             (line  496)
* setsid() (os モジュール):              プロセスのパラメーター.
                                                             (line  513)
* setsockopt() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  557)
* setstate() (codecs.IncrementalDecoder のメソッド): IncrementalDecoder オブジェクト.
                                                             (line   58)
* setstate() (codecs.IncrementalEncoder のメソッド): IncrementalEncoder オブジェクト.
                                                             (line   50)
* setstate() (random モジュール):        保守 bookkeeping 関数.
                                                             (line   38)
* setstate() (random.Random のメソッド): 他の生成器.         (line   29)
* setStream() (logging.StreamHandler のメソッド): StreamHandler.
                                                             (line   33)
* setswitchinterval (in module sys):     スレッド状態 thread state とグローバルインタプリタロック global interpreter lock.
                                                             (line   16)
* setswitchinterval() (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line 1554)
* setswitchinterval() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  290)
* setSystemId() (xml.sax.xmlreader.InputSource のメソッド): InputSource オブジェクト.
                                                             (line   14)
* setsyx() (curses モジュール):          関数<6>.            (line  462)
* setTarget() (logging.handlers.MemoryHandler のメソッド): MemoryHandler.
                                                             (line   70)
* setter (C type):                       Defining Getters and Setters.
                                                             (line   42)
* settimeout() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  541)
* setTimeout() (urllib.request.CacheFTPHandler のメソッド): CacheFTPHandler オブジェクト.
                                                             (line    9)
* settrace_all_threads() (threading モジュール): threading --- スレッドベースの並列処理.
                                                             (line  161)
* settrace() (sys モジュール):           sys --- システム固有のパラメーターと関数.
                                                             (line 1566)
* settrace() (threading モジュール):     threading --- スレッドベースの並列処理.
                                                             (line  155)
* setuid() (os モジュール):              プロセスのパラメーター.
                                                             (line  520)
* setundobuffer() (turtle モジュール):   特別な Turtle のメソッド.
                                                             (line   61)
* SETUP_ANNOTATIONS (opcode):            Python バイトコード命令.
                                                             (line  423)
* SETUP_CLEANUP (opcode):                Python バイトコード命令.
                                                             (line 1384)
* setup_environ() (wsgiref.handlers.BaseHandler のメソッド): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  195)
* SETUP_FINALLY (opcode):                Python バイトコード命令.
                                                             (line 1377)
* setup_python() (venv.EnvBuilder のメソッド): API<2>.       (line  148)
* setup_scripts() (venv.EnvBuilder のメソッド): API<2>.      (line  156)
* setup_testing_defaults() (wsgiref.util モジュール): wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line   69)
* SETUP_WITH (opcode):                   Python バイトコード命令.
                                                             (line 1392)
* setup() (socketserver.BaseRequestHandler のメソッド): Request Handler Objects.
                                                             (line   14)
* setup() (turtle モジュール):           Screen 独自のメソッド、TurtleScreen から継承したもの以外.
                                                             (line   20)
* setUp() (unittest.TestCase のメソッド): テストクラス.      (line   33)
* setUpClass() (unittest.TestCase のメソッド): テストクラス. (line   53)
* setupterm() (curses モジュール):       関数<6>.            (line  467)
* SetValue() (winreg モジュール):        関数<13>.           (line  417)
* SetValueEx() (winreg モジュール):      関数<13>.           (line  446)
* setworldcoordinates() (turtle モジュール): ウィンドウの制御.
                                                             (line   89)
* setx() (turtle モジュール):            Turtle の動き.      (line  138)
* setxattr() (os モジュール):            Linux 拡張属性.     (line   58)
* sety() (turtle モジュール):            Turtle の動き.      (line  151)
* SF_APPEND (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line  421)
* SF_ARCHIVED (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  413)
* SF_DATALESS (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  445)
* SF_FIRMLINK (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  439)
* SF_IMMUTABLE (stat モジュール):        stat --- stat の結果を解釈する.
                                                             (line  417)
* SF_MNOWAIT (os モジュール):            ファイル記述子の操作.
                                                             (line  789)
* SF_NOCACHE (os モジュール):            ファイル記述子の操作.
                                                             (line  800)
* SF_NODISKIO (os モジュール):           ファイル記述子の操作.
                                                             (line  789)
* SF_NOUNLINK (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  431)
* SF_RESTRICTED (stat モジュール):       stat --- stat の結果を解釈する.
                                                             (line  425)
* SF_SETTABLE (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  391)
* SF_SNAPSHOT (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  435)
* SF_SUPPORTED (stat モジュール):        stat --- stat の結果を解釈する.
                                                             (line  397)
* SF_SYNC (os モジュール):               ファイル記述子の操作.
                                                             (line  789)
* SF_SYNTHETIC (stat モジュール):        stat --- stat の結果を解釈する.
                                                             (line  405)
* sha1() (hashlib モジュール):           Constructors.       (line   22)
* sha224() (hashlib モジュール):         Constructors.       (line   24)
* sha256() (hashlib モジュール):         Constructors.       (line   26)
* sha3_224() (hashlib モジュール):       Constructors.       (line   32)
* sha3_256() (hashlib モジュール):       Constructors.       (line   34)
* sha3_384() (hashlib モジュール):       Constructors.       (line   36)
* sha3_512() (hashlib モジュール):       Constructors.       (line   38)
* sha384() (hashlib モジュール):         Constructors.       (line   28)
* sha512() (hashlib モジュール):         Constructors.       (line   30)
* shake_128() (hashlib モジュール):      SHAKE 可変長ダイジェスト.
                                                             (line    6)
* shake_256() (hashlib モジュール):      SHAKE 可変長ダイジェスト.
                                                             (line    8)
* shape (memoryview の属性):             メモリビュー.       (line  447)
* Shape (turtle のクラス):               Public classes.     (line   44)
* shape() (turtle モジュール):           見た目.             (line    6)
* shapesize() (turtle モジュール):       見た目.             (line   50)
* shapetransform() (turtle モジュール):  見た目.             (line  135)
* share() (socket.socket のメソッド):    socket オブジェクト.
                                                             (line  591)
* ShareableList (multiprocessing.shared_memory のクラス): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  271)
* ShareableList() (multiprocessing.managers.SharedMemoryManager のメソッド): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  231)
* Shared Memory:                         multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line   10)
* shared_ciphers() (ssl.SSLSocket のメソッド): SSL ソケット. (line  232)
* shared_memory (sys._emscripten_info の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  353)
* SharedMemory (multiprocessing.shared_memory のクラス): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line   32)
* SharedMemory() (multiprocessing.managers.SharedMemoryManager のメソッド): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  226)
* SharedMemoryManager (multiprocessing.managers のクラス): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  199)
* shearfactor() (turtle モジュール):     見た目.             (line   81)
* Shelf (shelve のクラス):               制限事項.           (line   27)
* shield() (asyncio モジュール):         キャンセルからの保護.
                                                             (line    6)
* shift_path_info() (wsgiref.util モジュール): wsgiref util -- WSGI 環境のユーティリティ.
                                                             (line   39)
* shift() (decimal.Context のメソッド):  Context オブジェクト.
                                                             (line  500)
* shift() (decimal.Decimal のメソッド):  Decimal オブジェクト.
                                                             (line  526)
* shlex (shlex のクラス):                shlex --- 単純な字句解析.
                                                             (line   90)
* shm (multiprocessing.shared_memory.ShareableList の属性): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  345)
* SHORT_TIMEOUT (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line   80)
* shortDescription() (unittest.TestCase のメソッド): テストクラス.
                                                             (line  757)
* shorten() (textwrap モジュール):       textwrap --- テキストの折り返しと詰め込み.
                                                             (line   48)
* shouldFlush() (logging.handlers.BufferingHandler のメソッド): MemoryHandler.
                                                             (line   36)
* shouldFlush() (logging.handlers.MemoryHandler のメソッド): MemoryHandler.
                                                             (line   74)
* shouldStop (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  280)
* show_code() (dis モジュール):          解析関数.           (line   24)
* show_flag_values() (enum モジュール):  ユーティリティとデコレータ.
                                                             (line  102)
* show() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   49)
* show() (tkinter.commondialog.Dialog のメソッド): tkinter commondialog --- Dialog window templates.
                                                             (line   16)
* show() (tkinter.messagebox.Message のメソッド): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line   82)
* showerror() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  105)
* showinfo() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line   91)
* showsyntaxerror() (code.InteractiveInterpreter のメソッド): 対話的なインタプリタオブジェクト.
                                                             (line   44)
* showtraceback() (code.InteractiveInterpreter のメソッド): 対話的なインタプリタオブジェクト.
                                                             (line   53)
* showturtle() (turtle モジュール):      可視性.             (line   15)
* showwarning() (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line   99)
* showwarning() (warnings モジュール):   利用可能な関数.     (line   84)
* shuffle() (random モジュール):         シーケンス用の関数. (line   51)
* SHUT_RD (socket モジュール):           定数<8>.            (line  376)
* SHUT_RDWR (socket モジュール):         定数<8>.            (line  376)
* SHUT_WR (socket モジュール):           定数<8>.            (line  376)
* ShutDown:                              queue --- 同期キュークラス.
                                                             (line   89)
* shutdown_asyncgens() (asyncio.loop のメソッド): ループの開始と停止.
                                                             (line   60)
* shutdown_default_executor() (asyncio.loop のメソッド): ループの開始と停止.
                                                             (line   81)
* shutdown() (asyncio.Queue のメソッド): Queue.              (line   83)
* shutdown() (concurrent.futures.Executor のメソッド): Executor オブジェクト.
                                                             (line   52)
* shutdown() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  275)
* shutdown() (logging モジュール):       モジュールレベルの関数.
                                                             (line  302)
* shutdown() (multiprocessing.managers.BaseManager のメソッド): マネージャー.
                                                             (line   86)
* shutdown() (queue.Queue のメソッド):   Terminating queues. (line    9)
* shutdown() (socket.socket のメソッド): socket オブジェクト.
                                                             (line  582)
* shutdown() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line   54)
* SI (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   69)
* side_effect (unittest.mock.Mock の属性): Mock クラス.      (line  344)
* SIG_BLOCK (signal モジュール):         モジュールの内容<2>.
                                                             (line  231)
* SIG_DFL (signal モジュール):           モジュールの内容<2>.
                                                             (line   45)
* SIG_IGN (signal モジュール):           モジュールの内容<2>.
                                                             (line   52)
* SIG_SETMASK (signal モジュール):       モジュールの内容<2>.
                                                             (line  245)
* SIG_UNBLOCK (signal モジュール):       モジュールの内容<2>.
                                                             (line  238)
* SIGABRT (signal モジュール):           モジュールの内容<2>.
                                                             (line   57)
* SIGALRM (signal モジュール):           モジュールの内容<2>.
                                                             (line   61)
* SIGBREAK (signal モジュール):          モジュールの内容<2>.
                                                             (line   67)
* SIGBUS (signal モジュール):            モジュールの内容<2>.
                                                             (line   73)
* SIGCHLD (signal モジュール):           モジュールの内容<2>.
                                                             (line   79)
* SIGCLD (signal モジュール):            モジュールの内容<2>.
                                                             (line   85)
* SIGCONT (signal モジュール):           モジュールの内容<2>.
                                                             (line   91)
* SIGFPE (signal モジュール):            モジュールの内容<2>.
                                                             (line   97)
* SIGHUP (signal モジュール):            モジュールの内容<2>.
                                                             (line  107)
* SIGILL (signal モジュール):            モジュールの内容<2>.
                                                             (line  114)
* SIGINT (C macro):                      シグナルハンドリング<2>.
                                                             (line    7)
* SIGINT (C macro) <1>:                  シグナルハンドリング<2>.
                                                             (line   34)
* SIGINT (signal モジュール):            モジュールの内容<2>.
                                                             (line  118)
* siginterrupt() (signal モジュール):    モジュールの内容<2>.
                                                             (line  482)
* SIGKILL (signal モジュール):           モジュールの内容<2>.
                                                             (line  124)
* Sigmasks (signal のクラス):            モジュールの内容<2>.
                                                             (line   31)
* signal() (signal モジュール):          モジュールの内容<2>.
                                                             (line  497)
* Signals (signal のクラス):             モジュールの内容<2>.
                                                             (line   17)
* Signature (inspect のクラス):          Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line   74)
* signature (inspect.BoundArguments の属性): Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line  359)
* signature() (inspect モジュール):      Signature オブジェクトで呼び出し可能オブジェクトを内省する.
                                                             (line   12)
* sigpending() (signal モジュール):      モジュールの内容<2>.
                                                             (line  525)
* SIGPIPE (signal モジュール):           モジュールの内容<2>.
                                                             (line  132)
* SIGSEGV (signal モジュール):           モジュールの内容<2>.
                                                             (line  140)
* SIGSTKFLT (signal モジュール):         モジュールの内容<2>.
                                                             (line  144)
* SIGTERM (signal モジュール):           モジュールの内容<2>.
                                                             (line  156)
* sigtimedwait() (signal モジュール):    モジュールの内容<2>.
                                                             (line  585)
* SIGUSR1 (signal モジュール):           モジュールの内容<2>.
                                                             (line  160)
* SIGUSR2 (signal モジュール):           モジュールの内容<2>.
                                                             (line  166)
* sigwait() (signal モジュール):         モジュールの内容<2>.
                                                             (line  540)
* sigwaitinfo() (signal モジュール):     モジュールの内容<2>.
                                                             (line  556)
* SIGWINCH (signal モジュール):          モジュールの内容<2>.
                                                             (line  172)
* SIMPLE (inspect.BufferFlags の属性):   Buffer flags.       (line   15)
* Simple Mail Transfer Protocol:         smtplib --- SMTP プロトコルクライアント.
                                                             (line    8)
* simple;statement:                      単純文 simple statement.
                                                             (line    6)
* SimpleCookie (http.cookies のクラス):  http cookies --- HTTP の状態管理.
                                                             (line   48)
* simplefilter() (warnings モジュール):  利用可能な関数.     (line  116)
* SimpleHandler (wsgiref.handlers のクラス): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line   70)
* SimpleHTTPRequestHandler (http.server のクラス): http server --- HTTP サーバー.
                                                             (line  341)
* SimpleNamespace (types のクラス):      追加のユーティリティクラスと関数.
                                                             (line    6)
* SimpleQueue (multiprocessing のクラス): パイプ Pipe とキュー Queue.
                                                             (line  214)
* SimpleQueue (queue のクラス):          queue --- 同期キュークラス.
                                                             (line   70)
* SimpleXMLRPCRequestHandler (xmlrpc.server のクラス): xmlrpc server --- 基本的な XML-RPC サーバー.
                                                             (line   63)
* SimpleXMLRPCServer (xmlrpc.server のクラス): xmlrpc server --- 基本的な XML-RPC サーバー.
                                                             (line   26)
* sin() (cmath モジュール):              三角関数<2>.        (line   27)
* sin() (math モジュール):               三角関数.           (line   60)
* single dispatch:                       用語集<2>.          (line 1320)
* SingleAddressHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  213)
* singledispatch() (functools モジュール): functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  424)
* singledispatchmethod (functools のクラス): functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  596)
* sinh() (cmath モジュール):             双曲線関数<2>.      (line   27)
* sinh() (math モジュール):              双曲線関数.         (line   25)
* SIO_KEEPALIVE_VALS (socket モジュール): 定数<8>.           (line  247)
* SIO_LOOPBACK_FAST_PATH (socket モジュール): 定数<8>.       (line  247)
* SIO_RCVALL (socket モジュール):        定数<8>.            (line  247)
* site コマンドラインオプション; -user-base: コマンドラインインターフェイス<10>.
                                                             (line   17)
* site コマンドラインオプション; -user-site: コマンドラインインターフェイス<10>.
                                                             (line   21)
* site_maps() (urllib.robotparser.RobotFileParser のメソッド): urllib robotparser --- robots txt 用のパーサー.
                                                             (line   71)
* site-packages;ディレクトリ:            site --- サイト固有の設定フック.
                                                             (line   24)
* sitecustomize:                         カスタマイズ用モジュール.
                                                             (line    6)
* sitecustomize <1>:                     カスタマイズ用モジュール.
                                                             (line   20)
* sixtofour (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  297)
* size (multiprocessing.shared_memory.SharedMemory の属性): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  124)
* size (struct.Struct の属性):           クラス<3>.          (line   64)
* size (tarfile.TarInfo の属性):         TarInfo オブジェクト.
                                                             (line   66)
* size (tracemalloc.Statistic の属性):   Statistic.          (line   19)
* size (tracemalloc.StatisticDiff の属性): StatisticDiff.    (line   27)
* size (tracemalloc.Trace の属性):       Trace.              (line   23)
* size_diff (tracemalloc.StatisticDiff の属性): StatisticDiff.
                                                             (line   33)
* SIZE_MAX (C macro):                    整数型オブジェクト integer object.
                                                             (line  262)
* size() (ftplib.FTP のメソッド):        FTP オブジェクト.   (line  350)
* size() (mmap.mmap のメソッド):         mmap --- メモリマップファイルのサポート.
                                                             (line  313)
* Sized (collections.abc のクラス):      コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line   14)
* Sized (typing のクラス):               Aliases to other ABCs in collections abc.
                                                             (line   69)
* sizeof_digit (sys.int_info の属性):    sys --- システム固有のパラメーターと関数.
                                                             (line 1124)
* sizeof() (ctypes モジュール):          ユーティリティー関数.
                                                             (line  185)
* SKIP (doctest モジュール):             オプションフラグ.   (line   91)
* skip_if_broken_multiprocessing_synchronize() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  725)
* skip_unless_bind_unix_socket() (test.support.socket_helper モジュール): test support socket_helper --- Utilities for socket tests.
                                                             (line   59)
* skip_unless_symlink() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  125)
* skip_unless_xattr() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  130)
* skip() (unittest モジュール):          テストのスキップと予期された失敗.
                                                             (line   86)
* skipIf() (unittest モジュール):        テストのスキップと予期された失敗.
                                                             (line   91)
* skipinitialspace (csv.Dialect の属性): Dialect クラスと書式化パラメータ.
                                                             (line   70)
* skipped (doctest.TestResults の属性):  TestResults objects.
                                                             (line   16)
* skipped (unittest.TestResult の属性):  テストのロードと起動.
                                                             (line  255)
* skippedEntity() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line  167)
* skips (doctest.DocTestRunner の属性):  DocTestRunner オブジェクト.
                                                             (line  144)
* SkipTest:                              テストのスキップと予期された失敗.
                                                             (line  106)
* skipTest() (unittest.TestCase のメソッド): テストクラス.   (line  100)
* skipUnless() (unittest モジュール):    テストのスキップと予期された失敗.
                                                             (line   95)
* SLASH (token モジュール):              token --- Python 解析木で使われる定数.
                                                             (line   91)
* SLASHEQUAL (token モジュール):         token --- Python 解析木で使われる定数.
                                                             (line  179)
* sleep() (asyncio モジュール):          スリープ.           (line    6)
* sleep() (time モジュール):             関数<5>.            (line  261)
* sleeping_retry() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  222)
* slice:                                 スライス表記 slicing.
                                                             (line    6)
* slice <1>:                             用語集<2>.          (line 1325)
* Slice (ast のクラス):                  配列要素の参照 Subscripting.
                                                             (line   28)
* slice (組み込みクラス):                組み込み関数.       (line 1763)
* slice;代入:                            ミュータブルなシーケンス型.
                                                             (line   16)
* slice;演算:                            共通のシーケンス演算.
                                                             (line   18)
* slow_callback_duration (asyncio.loop の属性): デバッグモードの有効化.
                                                             (line   21)
* SMALLEST (test.support モジュール):    test support --- テストのためのユーティリティ関数.
                                                             (line  193)
* SMTP (email.policy モジュール):        email policy Policy Objects.
                                                             (line  508)
* SMTP (smtplib のクラス):               smtplib --- SMTP プロトコルクライアント.
                                                             (line   21)
* SMTP_SSL (smtplib のクラス):           smtplib --- SMTP プロトコルクライアント.
                                                             (line   75)
* SMTP;プロトコル:                       smtplib --- SMTP プロトコルクライアント.
                                                             (line    8)
* SMTPAuthenticationError:               smtplib --- SMTP プロトコルクライアント.
                                                             (line  176)
* SMTPConnectError:                      smtplib --- SMTP プロトコルクライアント.
                                                             (line  162)
* SMTPDataError:                         smtplib --- SMTP プロトコルクライアント.
                                                             (line  157)
* SMTPException:                         smtplib --- SMTP プロトコルクライアント.
                                                             (line  125)
* SMTPHandler (logging.handlers のクラス): SMTPHandler.      (line   10)
* SMTPHeloError:                         smtplib --- SMTP プロトコルクライアント.
                                                             (line  166)
* SMTPNotSupportedError:                 smtplib --- SMTP プロトコルクライアント.
                                                             (line  170)
* SMTPRecipientsRefused:                 smtplib --- SMTP プロトコルクライアント.
                                                             (line  151)
* SMTPResponseException:                 smtplib --- SMTP プロトコルクライアント.
                                                             (line  138)
* SMTPSenderRefused:                     smtplib --- SMTP プロトコルクライアント.
                                                             (line  145)
* SMTPServerDisconnected:                smtplib --- SMTP プロトコルクライアント.
                                                             (line  133)
* SMTPUTF8 (email.policy モジュール):    email policy Policy Objects.
                                                             (line  514)
* Snapshot (tracemalloc のクラス):       Snapshot.           (line    6)
* SND_ALIAS (winsound モジュール):       winsound --- Windows 用の音声再生インターフェース.
                                                             (line   47)
* SND_ASYNC (winsound モジュール):       winsound --- Windows 用の音声再生インターフェース.
                                                             (line  113)
* SND_FILENAME (winsound モジュール):    winsound --- Windows 用の音声再生インターフェース.
                                                             (line   42)
* SND_LOOP (winsound モジュール):        winsound --- Windows 用の音声再生インターフェース.
                                                             (line   89)
* SND_MEMORY (winsound モジュール):      winsound --- Windows 用の音声再生インターフェース.
                                                             (line   95)
* SND_NODEFAULT (winsound モジュール):   winsound --- Windows 用の音声再生インターフェース.
                                                             (line  117)
* SND_NOSTOP (winsound モジュール):      winsound --- Windows 用の音声再生インターフェース.
                                                             (line  122)
* SND_NOWAIT (winsound モジュール):      winsound --- Windows 用の音声再生インターフェース.
                                                             (line  126)
* SND_PURGE (winsound モジュール):       winsound --- Windows 用の音声再生インターフェース.
                                                             (line  106)
* sni_callback (ssl.SSLContext の属性):  SSL コンテキスト.   (line  284)
* sniff() (csv.Sniffer のメソッド):      モジュールコンテンツ<3>.
                                                             (line  229)
* Sniffer (csv のクラス):                モジュールコンテンツ<3>.
                                                             (line  222)
* SO (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   66)
* SO_INCOMING_CPU (socket モジュール):   定数<8>.            (line  336)
* sock_accept() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line  110)
* SOCK_CLOEXEC (socket モジュール):      定数<8>.            (line   38)
* sock_connect() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line   89)
* SOCK_DGRAM (socket モジュール):        定数<8>.            (line   27)
* SOCK_MAX_SIZE (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  124)
* SOCK_NONBLOCK (socket モジュール):     定数<8>.            (line   38)
* SOCK_RAW (socket モジュール):          定数<8>.            (line   27)
* SOCK_RDM (socket モジュール):          定数<8>.            (line   27)
* sock_recv_into() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line   26)
* sock_recv() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line   12)
* sock_recvfrom_into() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line   49)
* sock_recvfrom() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line   38)
* sock_sendall() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line   60)
* sock_sendfile() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line  132)
* sock_sendto() (asyncio.loop のメソッド): ソケットオブジェクトと直接やりとりする.
                                                             (line   78)
* SOCK_SEQPACKET (socket モジュール):    定数<8>.            (line   27)
* SOCK_STREAM (socket モジュール):       定数<8>.            (line   27)
* socket (socket のクラス):              ソケットの作成.     (line    8)
* socket (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line   84)
* socket_type (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line  105)
* socket() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  281)
* socket() (in module socket):           select --- I/O 完了の待機.
                                                             (line  144)
* SocketHandler (logging.handlers のクラス): SocketHandler.  (line   10)
* socketpair() (socket モジュール):      ソケットの作成.     (line   63)
* sockets (asyncio.Server の属性):       Serverオブジェクト. (line  130)
* SocketType (socket モジュール):        ソケットの作成.     (line  183)
* soft deprecated:                       用語集<2>.          (line 1332)
* soft keyword:                          ソフトキーワード.   (line    6)
* SOFT_KEYWORD (token モジュール):       token --- Python 解析木で使われる定数.
                                                             (line  249)
* softkwlist (keyword モジュール):       keyword --- Python キーワードのテスト.
                                                             (line   31)
* SOH (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   21)
* SOL_ALG (socket モジュール):           定数<8>.            (line  263)
* SOL_RDS (socket モジュール):           定数<8>.            (line  234)
* SOMAXCONN (socket モジュール):         定数<8>.            (line   55)
* sort_stats() (pstats.Stats のメソッド): Stats クラス.      (line   61)
* sort() (imaplib.IMAP4 のメソッド):     IMAP4 オブジェクト. (line  285)
* sort() (list のメソッド):              リスト型 list<2>.   (line   37)
* sortdict() (test.support モジュール):  test support --- テストのためのユーティリティ関数.
                                                             (line  270)
* sortTestMethodsUsing (unittest.TestLoader の属性): テストのロードと起動.
                                                             (line  193)
* source (doctest.Example の属性):       Example オブジェクト.
                                                             (line   16)
* source (pdb command):                  デバッガコマンド.   (line  280)
* source (shlex.shlex の属性):           shlex オブジェクト. (line  150)
* SOURCE_DATE_EPOCH:                     py_compile<3>.      (line    7)
* SOURCE_DATE_EPOCH <1>:                 Library<50>.        (line  452)
* SOURCE_DATE_EPOCH <2>:                 Build<55>.          (line   15)
* SOURCE_DATE_EPOCH <3>:                 py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   66)
* SOURCE_DATE_EPOCH <4>:                 py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   83)
* SOURCE_DATE_EPOCH <5>:                 py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   87)
* SOURCE_DATE_EPOCH <6>:                 コマンドラインでの使用<2>.
                                                             (line   87)
* source_from_cache() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line   58)
* source_hash() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line  164)
* SOURCE_SUFFIXES (importlib.machinery モジュール): importlib machinery -- インポータおよびパスフック.
                                                             (line   13)
* source_to_code() (importlib.abc.InspectLoader の静的メソッド): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  240)
* SourceFileLoader (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  203)
* sourcehook() (shlex.shlex のメソッド): shlex オブジェクト. (line   26)
* SourcelessFileLoader (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line  241)
* SourceLoader (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  325)
* SP (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  120)
* span() (re.Match のメソッド):          マッチオブジェクト. (line  165)
* sparse (tarfile.TarInfo の属性):       TarInfo オブジェクト.
                                                             (line  159)
* spawn_python() (test.support.script_helper モジュール): test support script_helper --- Utilities for the Python execution tests.
                                                             (line   69)
* spawn() (pty モジュール):              pty --- 擬似端末ユーティリティ.
                                                             (line   40)
* spawnl() (os モジュール):              プロセス管理.       (line  591)
* spawnle() (os モジュール):             プロセス管理.       (line  591)
* spawnlp() (os モジュール):             プロセス管理.       (line  591)
* spawnlpe() (os モジュール):            プロセス管理.       (line  591)
* spawnv() (os モジュール):              プロセス管理.       (line  591)
* spawnve() (os モジュール):             プロセス管理.       (line  591)
* spawnvp() (os モジュール):             プロセス管理.       (line  591)
* spawnvpe() (os モジュール):            プロセス管理.       (line  591)
* spec_from_file_location() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line  151)
* spec_from_loader() (importlib.util モジュール): importlib util -- インポータのためのユーティリティコード.
                                                             (line  142)
* special method:                        用語集<2>.          (line 1343)
* SpecialFileError:                      tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  255)
* specified_attributes (xml.parsers.expat.xmlparser の属性): XMLParser オブジェクト<2>.
                                                             (line  151)
* speed() (turtle モジュール):           Turtle の動き.      (line  325)
* Spinbox (tkinter.ttk のクラス):        ttk Spinbox.        (line    6)
* SPLICE_F_MORE (os モジュール):         ファイル記述子の操作.
                                                             (line  858)
* SPLICE_F_MOVE (os モジュール):         ファイル記述子の操作.
                                                             (line  858)
* SPLICE_F_NONBLOCK (os モジュール):     ファイル記述子の操作.
                                                             (line  858)
* splice() (os モジュール):              ファイル記述子の操作.
                                                             (line  830)
* split() (BaseExceptionGroup のメソッド): 例外グループ.     (line   65)
* split() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  400)
* split() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  400)
* split() (os.path モジュール):          os path --- 一般的なパス名操作.
                                                             (line  449)
* split() (re モジュール):               関数<2>.            (line   77)
* split() (re.Pattern のメソッド):       正規表現オブジェクト.
                                                             (line   77)
* split() (shlex モジュール):            shlex --- 単純な字句解析.
                                                             (line   16)
* split() (str のメソッド):              文字列メソッド<2>.  (line  446)
* splitdrive() (os.path モジュール):     os path --- 一般的なパス名操作.
                                                             (line  465)
* splitext() (os.path モジュール):       os path --- 一般的なパス名操作.
                                                             (line  521)
* splitlines() (bytearray のメソッド):   bytes と bytearray の操作.
                                                             (line  646)
* splitlines() (bytes のメソッド):       bytes と bytearray の操作.
                                                             (line  646)
* splitlines() (str のメソッド):         文字列メソッド<2>.  (line  487)
* SplitResult (urllib.parse のクラス):   構造化された解析結果.
                                                             (line   54)
* SplitResultBytes (urllib.parse のクラス): 構造化された解析結果.
                                                             (line   81)
* splitroot() (os.path モジュール):      os path --- 一般的なパス名操作.
                                                             (line  490)
* SpooledTemporaryFile (tempfile のクラス): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  151)
* sprintf 形式の書式化:                  printf 形式の文字列書式化.
                                                             (line    6)
* sprintf 形式の書式化 <1>:              printf 形式での bytes の書式化.
                                                             (line    6)
* SQLITE_DBCONFIG_DEFENSIVE (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_DQS_DDL (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_DQS_DML (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_ENABLE_FKEY (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_ENABLE_QPSG (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_ENABLE_TRIGGER (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_ENABLE_VIEW (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_LEGACY_ALTER_TABLE (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_LEGACY_FILE_FORMAT (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_RESET_DATABASE (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_TRIGGER_EQP (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_TRUSTED_SCHEMA (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DBCONFIG_WRITABLE_SCHEMA (sqlite3 モジュール): モジュール定数.
                                                             (line  147)
* SQLITE_DENY (sqlite3 モジュール):      モジュール定数.     (line   42)
* sqlite_errorcode (sqlite3.Error の属性): 例外<7>.          (line   24)
* sqlite_errorname (sqlite3.Error の属性): 例外<7>.          (line   30)
* SQLITE_IGNORE (sqlite3 モジュール):    モジュール定数.     (line   42)
* SQLITE_OK (sqlite3 モジュール):        モジュール定数.     (line   42)
* sqlite_version (sqlite3 モジュール):   モジュール定数.     (line   72)
* sqlite_version_info (sqlite3 モジュール): モジュール定数.  (line   77)
* sqrt() (cmath モジュール):             指数関数と対数関数<2>.
                                                             (line   21)
* sqrt() (decimal.Context のメソッド):   Context オブジェクト.
                                                             (line  504)
* sqrt() (decimal.Decimal のメソッド):   Decimal オブジェクト.
                                                             (line  536)
* sqrt() (math モジュール):              指数関数と対数関数. (line   87)
* ssizeargfunc (C type):                 Slot Type typedefs. (line  134)
* ssizeobjargproc (C type):              Slot Type typedefs. (line  138)
* SSL:                                   ssl --- ソケットオブジェクト用の TLS/SSL ラッパー.
                                                             (line    8)
* ssl_version (ftplib.FTP_TLS の属性):   FTP_TLS オブジェクト.
                                                             (line   84)
* SSLCertVerificationError:              例外<15>.           (line   77)
* SSLContext (ssl のクラス):             SSL コンテキスト.   (line   13)
* SSLEOFError:                           例外<15>.           (line   69)
* SSLError:                              例外<15>.           (line    6)
* SSLErrorNumber (ssl のクラス):         定数<9>.            (line  550)
* SSLKEYLOGFILE:                         コンテキストの作成. (line   34)
* SSLKEYLOGFILE <1>:                     コンテキストの作成. (line   83)
* SSLObject (ssl のクラス):              メモリ BIO サポート<2>.
                                                             (line   30)
* sslobject_class (ssl.SSLContext の属性): SSL コンテキスト. (line  471)
* SSLSession (ssl のクラス):             SSL セッション.     (line    8)
* SSLSocket (ssl のクラス):              SSL ソケット.       (line    6)
* sslsocket_class (ssl.SSLContext の属性): SSL コンテキスト. (line  445)
* SSLSyscallError:                       例外<15>.           (line   61)
* SSLv3 (ssl.TLSVersion の属性):         定数<9>.            (line  572)
* SSLWantReadError:                      例外<15>.           (line   43)
* SSLWantWriteError:                     例外<15>.           (line   52)
* SSLZeroReturnError:                    例外<15>.           (line   34)
* st_atime (os.stat_result の属性):      ファイルとディレクトリ.
                                                             (line 1213)
* ST_ATIME (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  168)
* st_atime_ns (os.stat_result の属性):   ファイルとディレクトリ.
                                                             (line 1230)
* st_birthtime (os.stat_result の属性):  ファイルとディレクトリ.
                                                             (line 1254)
* st_birthtime_ns (os.stat_result の属性): ファイルとディレクトリ.
                                                             (line 1262)
* st_blksize (os.stat_result の属性):    ファイルとディレクトリ.
                                                             (line 1300)
* st_blocks (os.stat_result の属性):     ファイルとディレクトリ.
                                                             (line 1294)
* st_creator (os.stat_result の属性):    ファイルとディレクトリ.
                                                             (line 1336)
* st_ctime (os.stat_result の属性):      ファイルとディレクトリ.
                                                             (line 1221)
* ST_CTIME (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  176)
* st_ctime_ns (os.stat_result の属性):   ファイルとディレクトリ.
                                                             (line 1242)
* st_dev (os.stat_result の属性):        ファイルとディレクトリ.
                                                             (line 1188)
* ST_DEV (stat モジュール):              stat --- stat の結果を解釈する.
                                                             (line  147)
* st_file_attributes (os.stat_result の属性): ファイルとディレクトリ.
                                                             (line 1346)
* st_flags (os.stat_result の属性):      ファイルとディレクトリ.
                                                             (line 1310)
* st_fstype (os.stat_result の属性):     ファイルとディレクトリ.
                                                             (line 1325)
* st_gen (os.stat_result の属性):        ファイルとディレクトリ.
                                                             (line 1318)
* st_gid (os.stat_result の属性):        ファイルとディレクトリ.
                                                             (line 1200)
* ST_GID (stat モジュール):              stat --- stat の結果を解釈する.
                                                             (line  159)
* st_ino (os.stat_result の属性):        ファイルとディレクトリ.
                                                             (line 1179)
* ST_INO (stat モジュール):              stat --- stat の結果を解釈する.
                                                             (line  143)
* st_mode (os.stat_result の属性):       ファイルとディレクトリ.
                                                             (line 1174)
* ST_MODE (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  139)
* st_mtime (os.stat_result の属性):      ファイルとディレクトリ.
                                                             (line 1217)
* ST_MTIME (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  172)
* st_mtime_ns (os.stat_result の属性):   ファイルとディレクトリ.
                                                             (line 1236)
* st_nlink (os.stat_result の属性):      ファイルとディレクトリ.
                                                             (line 1192)
* ST_NLINK (stat モジュール):            stat --- stat の結果を解釈する.
                                                             (line  151)
* st_rdev (os.stat_result の属性):       ファイルとディレクトリ.
                                                             (line 1306)
* st_reparse_tag (os.stat_result の属性): ファイルとディレクトリ.
                                                             (line 1356)
* st_rsize (os.stat_result の属性):      ファイルとディレクトリ.
                                                             (line 1332)
* st_size (os.stat_result の属性):       ファイルとディレクトリ.
                                                             (line 1204)
* ST_SIZE (stat モジュール):             stat --- stat の結果を解釈する.
                                                             (line  163)
* st_type (os.stat_result の属性):       ファイルとディレクトリ.
                                                             (line 1340)
* st_uid (os.stat_result の属性):        ファイルとディレクトリ.
                                                             (line 1196)
* ST_UID (stat モジュール):              stat --- stat の結果を解釈する.
                                                             (line  155)
* st() (turtle モジュール):              可視性.             (line   15)
* stack (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line   75)
* stack viewer:                          Debug メニュー Shell ウィンドウのみ.
                                                             (line   15)
* stack_effect() (dis モジュール):       解析関数.           (line  183)
* stack_size() (_thread モジュール):     _thread --- 低水準なスレッド API.
                                                             (line  109)
* stack_size() (threading モジュール):   threading --- スレッドベースの並列処理.
                                                             (line  203)
* stack() (inspect モジュール):          インタープリタスタック.
                                                             (line  166)
* StackSummary (traceback のクラス):     StackSummary オブジェクト.
                                                             (line   10)
* stamp() (turtle モジュール):           Turtle の動き.      (line  269)
* standard_b64decode() (base64 モジュール): base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   87)
* standard_b64encode() (base64 モジュール): base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   81)
* standard;output:                       式文 expression statement.
                                                             (line   16)
* standend() (curses.window のメソッド): Window オブジェクト.
                                                             (line  501)
* standout() (curses.window のメソッド): Window オブジェクト.
                                                             (line  506)
* STAR (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   87)
* STAREQUAL (token モジュール):          token --- Python 解析木で使われる定数.
                                                             (line  175)
* starmap_async() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  164)
* starmap() (itertools モジュール):      Itertool関数.       (line  546)
* starmap() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  153)
* Starred (ast のクラス):                変数.               (line   40)
* start (range の属性):                  range.              (line   56)
* start (slice の属性):                  組み込み関数.       (line 1771)
* start (UnicodeError の属性):           具象例外.           (line  426)
* start (スライスオブジェクトの属性):    スライス slice オブジェクト.
                                                             (line   10)
* start (スライスオブジェクトの属性) <1>: スライス表記 slicing.
                                                             (line   25)
* start_color() (curses モジュール):     関数<6>.            (line  474)
* start_new_thread() (_thread モジュール): _thread --- 低水準なスレッド API.
                                                             (line   31)
* start_ns() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   74)
* start_server() (asyncio モジュール):   ストリーム.         (line   75)
* start_serving() (asyncio.Server のメソッド): Serverオブジェクト.
                                                             (line   75)
* start_threads() (test.support.threading_helper モジュール): test support threading_helper --- Utilities for threading tests.
                                                             (line   22)
* start_tls() (asyncio.loop のメソッド): TLS へのアップグレード.
                                                             (line    6)
* start_tls() (asyncio.StreamWriter のメソッド): StreamWriter.
                                                             (line   83)
* start_unix_server() (asyncio モジュール): ストリーム.      (line  142)
* start() (logging.handlers.QueueListener のメソッド): QueueListener.
                                                             (line   75)
* start() (multiprocessing.managers.BaseManager のメソッド): マネージャー.
                                                             (line   59)
* start() (multiprocessing.Process のメソッド): Process クラスと例外.
                                                             (line   58)
* start() (re.Match のメソッド):         マッチオブジェクト. (line  140)
* start() (threading.Thread のメソッド): Thread オブジェクト.
                                                             (line   99)
* start() (tkinter.ttk.Progressbar のメソッド): ttk Progressbar.
                                                             (line    8)
* start() (tracemalloc モジュール):      関数<11>.           (line   71)
* start() (xml.etree.ElementTree.TreeBuilder のメソッド): TreeBuilder オブジェクト.
                                                             (line   42)
* startCDATA() (xml.sax.handler.LexicalHandler のメソッド): LexicalHandler Objects.
                                                             (line   32)
* StartCdataSectionHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  332)
* StartDoctypeDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  217)
* startDocument() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   30)
* startDTD() (xml.sax.handler.LexicalHandler のメソッド): LexicalHandler Objects.
                                                             (line   23)
* startElement() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   77)
* StartElementHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  253)
* startElementNS() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   96)
* STARTF_FORCEOFFFEEDBACK (subprocess モジュール): Windows Constants.
                                                             (line   47)
* STARTF_FORCEONFEEDBACK (subprocess モジュール): Windows Constants.
                                                             (line   38)
* STARTF_USESHOWWINDOW (subprocess モジュール): Windows Constants.
                                                             (line   33)
* STARTF_USESTDHANDLES (subprocess モジュール): Windows Constants.
                                                             (line   27)
* startfile() (os モジュール):           プロセス管理.       (line  704)
* StartNamespaceDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  312)
* startPrefixMapping() (xml.sax.handler.ContentHandler のメソッド): ContentHandler オブジェクト.
                                                             (line   47)
* StartResponse (wsgiref.types のクラス): wsgiref types -- WSGI types for static type checking.
                                                             (line   11)
* startswith() (bytearray のメソッド):   bytes と bytearray の操作.
                                                             (line  253)
* startswith() (bytes のメソッド):       bytes と bytearray の操作.
                                                             (line  253)
* startswith() (str のメソッド):         文字列メソッド<2>.  (line  558)
* startTest() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  339)
* startTestRun() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  347)
* starttls() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  303)
* starttls() (smtplib.SMTP のメソッド):  SMTP オブジェクト.  (line  180)
* STARTUPINFO (subprocess のクラス):     Windows Popen ヘルパー.
                                                             (line    9)
* stat_result (os のクラス):             ファイルとディレクトリ.
                                                             (line 1166)
* stat() (os モジュール):                ファイルとディレクトリ.
                                                             (line 1109)
* stat() (os.DirEntry のメソッド):       ファイルとディレクトリ.
                                                             (line 1072)
* stat() (pathlib.Path のメソッド):      ファイルの種類とステータスを問い合わせる.
                                                             (line   13)
* stat() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   50)
* state() (tkinter.ttk.Widget のメソッド): ttk Widget.       (line   27)
* statement:                             用語集<2>.          (line 1350)
* statement;assert:                      assert 文.          (line    6)
* statement;assert <1>:                  具象例外.           (line   10)
* statement;assignment, annotated:       注釈付き代入文 annotated assignment statements.
                                                             (line    6)
* statement;assignment, augmented:       累算代入文 augmented assignment statement.
                                                             (line    6)
* statement;async def:                   コルーチン<2>.      (line    8)
* statement;async for:                   コルーチン関数定義. (line   28)
* statement;async with:                  async for 文.       (line   43)
* statement;break:                       break 文.           (line    6)
* statement;break <1>:                   while 文.           (line   16)
* statement;break <2>:                   for 文<2>.          (line   22)
* statement;break <3>:                   except* 節.         (line   57)
* statement;break <4>:                   finally 節.         (line   28)
* statement;continue:                    continue 文.        (line    6)
* statement;continue <1>:                while 文.           (line   16)
* statement;continue <2>:                for 文<2>.          (line   22)
* statement;continue <3>:                except* 節.         (line   56)
* statement;continue <4>:                finally 節.         (line   28)
* statement;def:                         関数定義.           (line    6)
* statement;del:                         基本的なカスタマイズ.
                                                             (line   53)
* statement;del <1>:                     del 文<2>.          (line    6)
* statement;del <2>:                     ミュータブルなシーケンス型.
                                                             (line   16)
* statement;del <3>:                     マッピング型 --- dict.
                                                             (line    6)
* statement;except:                      組み込み例外.       (line    6)
* statement;for:                         for 文.             (line    6)
* statement;for <1>:                     break 文.           (line    6)
* statement;for <2>:                     continue 文.        (line    6)
* statement;for <3>:                     for 文<2>.          (line    6)
* statement;if:                          if 文<2>.           (line    6)
* statement;if <1>:                      真理値判定.         (line    6)
* statement;import:                      モジュール<3>.      (line    6)
* statement;import <1>:                  import 文.          (line    6)
* statement;import <2>:                  組み込み関数.       (line 2158)
* statement;import <3>:                  site --- サイト固有の設定フック.
                                                             (line   51)
* statement;match:                       match 文<2>.        (line    6)
* statement;nonlocal:                    nonlocal 文.        (line    6)
* statement;pass:                        pass 文<2>.         (line    6)
* statement;raise:                       raise 文.           (line    6)
* statement;raise <1>:                   組み込み例外.       (line   13)
* statement;return:                      return 文.          (line    6)
* statement;return <1>:                  except* 節.         (line   57)
* statement;return <2>:                  finally 節.         (line   28)
* statement;try:                         トレースバック traceback オブジェクト.
                                                             (line   31)
* statement;try <1>:                     try 文.             (line    6)
* statement;try <2>:                     組み込み例外.       (line    6)
* statement;type:                        The type statement. (line    6)
* statement;while:                       break 文.           (line    6)
* statement;while <1>:                   continue 文.        (line    6)
* statement;while <2>:                   while 文.           (line    6)
* statement;while <3>:                   真理値判定.         (line    6)
* statement;with:                        with文とコンテキストマネージャ.
                                                             (line   13)
* statement;with <1>:                    with 文.            (line    6)
* statement;yield:                       yield 文.           (line    6)
* statement;クラス:                      クラス定義.         (line    6)
* statement;グローバル:                  del 文<2>.          (line   15)
* statement;グローバル <1>:              global 文.          (line    6)
* static type checker:                   用語集<2>.          (line 1357)
* static_order() (graphlib.TopologicalSorter のメソッド): graphlib --- グラフ構造を操作する機能.
                                                             (line  159)
* Statistic (tracemalloc のクラス):      Statistic.          (line    6)
* StatisticDiff (tracemalloc のクラス):  StatisticDiff.      (line    6)
* statistics() (tracemalloc.Snapshot のメソッド): Snapshot.  (line   57)
* StatisticsError:                       例外<5>.            (line    8)
* Stats (pstats のクラス):               Stats クラス.       (line    8)
* status (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   62)
* status (urllib.response.addinfourl の属性): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   24)
* status() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  316)
* statvfs() (os モジュール):             ファイルとディレクトリ.
                                                             (line 1408)
* STD_ERROR_HANDLE (subprocess モジュール): Windows Constants.
                                                             (line   18)
* STD_INPUT_HANDLE (subprocess モジュール): Windows Constants.
                                                             (line    8)
* STD_OUTPUT_HANDLE (subprocess モジュール): Windows Constants.
                                                             (line   13)
* stderr (asyncio.subprocess.Process の属性): サブプロセスとやりとりする.
                                                             (line  127)
* stderr (subprocess.CalledProcessError の属性): subprocess モジュールを使う.
                                                             (line  231)
* stderr (subprocess.CompletedProcess の属性): subprocess モジュールを使う.
                                                             (line  128)
* stderr (subprocess.Popen の属性):      Popen オブジェクト. (line  129)
* stderr (subprocess.TimeoutExpired の属性): subprocess モジュールを使う.
                                                             (line  192)
* stderr (sys モジュール):               I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* stderr (sys モジュール) <1>:           sys --- システム固有のパラメーターと関数.
                                                             (line 1769)
* stderr (sys モジュール) <2>:           サブインタプリタサポート.
                                                             (line  109)
* stderr (sys モジュール) <3>:           サブインタプリタサポート.
                                                             (line  191)
* stdev (statistics.NormalDist の属性):  NormalDist オブジェクト.
                                                             (line   35)
* stdev() (statistics モジュール):       関数の詳細.         (line  422)
* stdin (asyncio.subprocess.Process の属性): サブプロセスとやりとりする.
                                                             (line  117)
* stdin (subprocess.Popen の属性):       Popen オブジェクト. (line  110)
* stdin (sys モジュール):                I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* stdin (sys モジュール) <1>:            sys --- システム固有のパラメーターと関数.
                                                             (line 1769)
* stdin (sys モジュール) <2>:            サブインタプリタサポート.
                                                             (line  109)
* stdin (sys モジュール) <3>:            サブインタプリタサポート.
                                                             (line  191)
* stdio:                                 I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* stdlib_module_names (sys モジュール):  sys --- システム固有のパラメーターと関数.
                                                             (line 1856)
* stdout (asyncio.subprocess.Process の属性): サブプロセスとやりとりする.
                                                             (line  122)
* STDOUT (subprocess モジュール):        subprocess モジュールを使う.
                                                             (line  156)
* stdout (subprocess.CalledProcessError の属性): subprocess モジュールを使う.
                                                             (line  227)
* stdout (subprocess.CompletedProcess の属性): subprocess モジュールを使う.
                                                             (line  117)
* stdout (subprocess.Popen の属性):      Popen オブジェクト. (line  119)
* stdout (subprocess.TimeoutExpired の属性): subprocess モジュールを使う.
                                                             (line  188)
* stdout (sys モジュール):               I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* stdout (sys モジュール) <1>:           sys --- システム固有のパラメーターと関数.
                                                             (line 1769)
* stdout (sys モジュール) <2>:           サブインタプリタサポート.
                                                             (line  109)
* stdout (sys モジュール) <3>:           サブインタプリタサポート.
                                                             (line  191)
* stem (pathlib.PurePath の属性):        メソッドとプロパティ.
                                                             (line  161)
* step (pdb command):                    デバッガコマンド.   (line  195)
* step (range の属性):                   range.              (line   64)
* step (slice の属性):                   組み込み関数.       (line 1775)
* step (スライスオブジェクトの属性):     スライス slice オブジェクト.
                                                             (line   10)
* step (スライスオブジェクトの属性) <1>: スライス表記 slicing.
                                                             (line   25)
* step() (tkinter.ttk.Progressbar のメソッド): ttk Progressbar.
                                                             (line   15)
* stls() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line  114)
* stop (range の属性):                   range.              (line   60)
* stop (slice の属性):                   組み込み関数.       (line 1773)
* stop (スライスオブジェクトの属性):     スライス slice オブジェクト.
                                                             (line   10)
* stop (スライスオブジェクトの属性) <1>: スライス表記 slicing.
                                                             (line   25)
* stop_here() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  250)
* STOP_ITERATION (monitoring event):     Events.             (line   81)
* stop() (asyncio.loop のメソッド):      ループの開始と停止. (line   34)
* stop() (logging.handlers.QueueListener のメソッド): QueueListener.
                                                             (line   82)
* stop() (tkinter.ttk.Progressbar のメソッド): ttk Progressbar.
                                                             (line   22)
* stop() (tracemalloc モジュール):       関数<11>.           (line  101)
* stop() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  322)
* StopAsyncIteration:                    具象例外.           (line  277)
* StopIteration:                         具象例外.           (line  244)
* stopListening() (logging.config モジュール): 環境設定のための関数.
                                                             (line  168)
* stopTest() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  343)
* stopTestRun() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  353)
* storbinary() (ftplib.FTP のメソッド):  FTP オブジェクト.   (line  217)
* Store (ast のクラス):                  変数.               (line   11)
* STORE_ACTIONS (optparse.Option の属性): 新しいアクションの追加.
                                                             (line   36)
* STORE_ATTR (opcode):                   Python バイトコード命令.
                                                             (line  595)
* STORE_DEREF (opcode):                  Python バイトコード命令.
                                                             (line  977)
* STORE_FAST (opcode):                   Python バイトコード命令.
                                                             (line  942)
* STORE_GLOBAL (opcode):                 Python バイトコード命令.
                                                             (line  616)
* STORE_NAME (opcode):                   Python バイトコード命令.
                                                             (line  553)
* STORE_SLICE (opcode):                  Python バイトコード命令.
                                                             (line  280)
* STORE_SUBSCR (opcode):                 Python バイトコード命令.
                                                             (line  252)
* store() (imaplib.IMAP4 のメソッド):    IMAP4 オブジェクト. (line  320)
* storlines() (ftplib.FTP のメソッド):   FTP オブジェクト.   (line  246)
* str (組み込みクラス):                  テキストシーケンス型 --- str.
                                                             (line   44)
* str (組み込みクラス);(string も参照のこと): range.         (line  119)
* str_digits_check_threshold (sys.int_info の属性): sys --- システム固有のパラメーターと関数.
                                                             (line 1133)
* str() (locale モジュール):             locale --- 国際化サービス.
                                                             (line  459)
* strcoll() (locale モジュール):         locale --- 国際化サービス.
                                                             (line  413)
* StreamError:                           tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  221)
* StreamHandler (logging のクラス):      StreamHandler.      (line   12)
* StreamReader (asyncio のクラス):       StreamReader.       (line    6)
* StreamReader (codecs のクラス):        StreamReader オブジェクト.
                                                             (line   11)
* streamreader (codecs.CodecInfo の属性): codecs --- codec レジストリと基底クラス.
                                                             (line   89)
* StreamReaderWriter (codecs のクラス):  StreamReaderWriter オブジェクト.
                                                             (line   12)
* StreamRecoder (codecs のクラス):       StreamRecoder オブジェクト.
                                                             (line   13)
* StreamRequestHandler (socketserver のクラス): Request Handler Objects.
                                                             (line   55)
* StreamWriter (asyncio のクラス):       StreamWriter.       (line    6)
* StreamWriter (codecs のクラス):        StreamWriter オブジェクト.
                                                             (line   11)
* streamwriter (codecs.CodecInfo の属性): codecs --- codec レジストリと基底クラス.
                                                             (line   89)
* StrEnum (enum のクラス):               データ型<2>.        (line  377)
* strerror (C function):                 例外の送出.         (line   57)
* strerror (OSError の属性):             具象例外.           (line  171)
* strerror() (os モジュール):            プロセスのパラメーター.
                                                             (line  526)
* strftime() (datetime.date のメソッド): date オブジェクト.  (line  293)
* strftime() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  751)
* strftime() (datetime.time のメソッド): time オブジェクト.  (line  217)
* strftime() (time モジュール):          関数<5>.            (line  304)
* strict (csv.Dialect の属性):           Dialect クラスと書式化パラメータ.
                                                             (line   75)
* strict (email.policy モジュール):      email policy Policy Objects.
                                                             (line  529)
* STRICT (enum.FlagBoundary の属性):     データ型<2>.        (line  642)
* strict_domain (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line   95)
* strict_errors() (codecs モジュール):   エラーハンドラ.     (line  134)
* strict_ns_domain (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  117)
* strict_ns_set_initial_dollar (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  123)
* strict_ns_set_path (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  127)
* strict_ns_unverifiable (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  112)
* strict_rfc2965_unverifiable (http.cookiejar.DefaultCookiePolicy の属性): DefaultCookiePolicy オブジェクト.
                                                             (line  103)
* strict;error handler's name:           エラーハンドラ.     (line   14)
* STRIDED (inspect.BufferFlags の属性):  Buffer flags.       (line   37)
* STRIDED_RO (inspect.BufferFlags の属性): Buffer flags.     (line   39)
* STRIDES (inspect.BufferFlags の属性):  Buffer flags.       (line   23)
* strides (memoryview の属性):           メモリビュー.       (line  455)
* string (re.Match の属性):              マッチオブジェクト. (line  202)
* STRING (token モジュール):             token --- Python 解析木で使われる定数.
                                                             (line   43)
* string_at() (ctypes モジュール):       ユーティリティー関数.
                                                             (line  190)
* string;__format__() (オブジェクトメソッド): 基本的なカスタマイズ.
                                                             (line  149)
* string;__str__() (オブジェクトメソッド): 基本的なカスタマイズ.
                                                             (line  128)
* string;format() (組み込み関数):        組み込み関数.       (line  767)
* string;formatted literal:              出力を見やすくフォーマットする.
                                                             (line   88)
* string;formatted literal <1>:          文字列リテラルの結合 concatenation.
                                                             (line   24)
* string;formatting, printf:             printf 形式の文字列書式化.
                                                             (line    6)
* string;immutable sequences:            変更不能なシーケンス immutable sequence.
                                                             (line   14)
* string;interpolated literal:           出力を見やすくフォーマットする.
                                                             (line   88)
* string;interpolated literal <1>:       文字列リテラルの結合 concatenation.
                                                             (line   24)
* string;interpolation, printf:          printf 形式の文字列書式化.
                                                             (line    6)
* string;object representation:          ファイナライズとメモリ解放.
                                                             (line   91)
* string;PyObject_Str (C 関数):          オブジェクトプロトコル object protocol.
                                                             (line  346)
* string;str (組み込みクラス):           テキストシーケンス型 --- str.
                                                             (line   44)
* string;str() (built-in function):      組み込み関数.       (line 1872)
* string;テキストシーケンス型:           range.              (line  119)
* string;メソッド:                       テキストシーケンス型 --- str.
                                                             (line   87)
* string;変換:                           基本的なカスタマイズ.
                                                             (line  149)
* string;変換 <1>:                       式文 expression statement.
                                                             (line   16)
* string;要素:                           添字表記 subscription.
                                                             (line   58)
* StringIO (io のクラス):                テキスト I/O<2>.    (line  234)
* strings, documentation:                関数を定義する.     (line   21)
* strings, documentation <1>:            ドキュメンテーション文字列.
                                                             (line    6)
* strip_dirs() (pstats.Stats のメソッド): Stats クラス.      (line   32)
* strip() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  444)
* strip() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  444)
* strip() (str のメソッド):              文字列メソッド<2>.  (line  565)
* stripspaces (curses.textpad.Textbox の属性): Textbox オブジェクト.
                                                             (line  118)
* strong reference:                      用語集<2>.          (line 1363)
* strptime() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line  251)
* strptime() (time モジュール):          関数<5>.            (line  461)
* strsignal() (signal モジュール):       モジュールの内容<2>.
                                                             (line  293)
* Struct (struct のクラス):              クラス<3>.          (line    8)
* struct_time (time のクラス):           関数<5>.            (line  495)
* structmember.h:                        Member types.       (line   85)
* Structure (ctypes のクラス):           構造化データ型.     (line   38)
* strxfrm() (locale モジュール):         locale --- 国際化サービス.
                                                             (line  420)
* STX (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   24)
* Style (tkinter.ttk のクラス):          Ttk スタイル.       (line   21)
* Sub (ast のクラス):                    式 expression<2>.   (line   55)
* SUB (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  102)
* sub() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  152)
* sub() (re モジュール):                 関数<2>.            (line  167)
* sub() (re.Pattern のメソッド):         正規表現オブジェクト.
                                                             (line   94)
* subdirs (filecmp.dircmp の属性):       dircmp クラス.      (line  102)
* SubElement() (xml.etree.ElementTree モジュール): 関数<9>.  (line  205)
* subgroup() (BaseExceptionGroup のメソッド): 例外グループ.  (line   39)
* submit() (concurrent.futures.Executor のメソッド): Executor オブジェクト.
                                                             (line   11)
* submodule_search_locations (importlib.machinery.ModuleSpec の属性): importlib machinery -- インポータおよびパスフック.
                                                             (line  401)
* subn() (re モジュール):                関数<2>.            (line  239)
* subn() (re.Pattern のメソッド):        正規表現オブジェクト.
                                                             (line   99)
* subnet_of() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  214)
* subnet_of() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  348)
* subnets() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  172)
* subnets() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  344)
* Subnormal (decimal のクラス):          シグナル.           (line   89)
* suboffsets (memoryview の属性):        メモリビュー.       (line  464)
* subpad() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  510)
* subprocess_exec() (asyncio.loop のメソッド): サブプロセスの実行.
                                                             (line   16)
* subprocess_shell() (asyncio.loop のメソッド): サブプロセスの実行.
                                                             (line  114)
* SubprocessError:                       subprocess モジュールを使う.
                                                             (line  161)
* SubprocessProtocol (asyncio のクラス): 基底プロトコル.     (line   25)
* SubprocessTransport (asyncio のクラス): トランスポートのクラス階層構造.
                                                             (line   52)
* subscribe() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  346)
* Subscript (ast のクラス):              配列要素の参照 Subscripting.
                                                             (line    6)
* subsequent_indent (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  212)
* substitute() (string.Template のメソッド): テンプレート文字列.
                                                             (line   41)
* subTest() (unittest.TestCase のメソッド): テストクラス.    (line  108)
* subtract() (collections.Counter のメソッド): Counter オブジェクト.
                                                             (line   85)
* subtract() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  508)
* subtype (email.headerregistry.ContentTypeHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  272)
* subwin() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  517)
* successful() (multiprocessing.pool.AsyncResult のメソッド): プロセスプール.
                                                             (line  218)
* suffix (pathlib.PurePath の属性):      メソッドとプロパティ.
                                                             (line  137)
* suffix_map (mimetypes モジュール):     mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  142)
* suffix_map (mimetypes.MimeTypes の属性): Mime 型オブジェクト.
                                                             (line   23)
* suffixes (pathlib.PurePath の属性):    メソッドとプロパティ.
                                                             (line  150)
* suite:                                 複合文 compound statement.
                                                             (line   17)
* suiteClass (unittest.TestLoader の属性): テストのロードと起動.
                                                             (line  199)
* sum_list():                            参照カウントの詳細. (line  141)
* sum_sequence():                        参照カウントの詳細. (line  168)
* sum_sequence() <1>:                    例外<21>.           (line   65)
* summarize_address_range() (ipaddress モジュール): その他のモジュールレベル関数.
                                                             (line   27)
* summarize() (doctest.DocTestRunner のメソッド): DocTestRunner オブジェクト.
                                                             (line  124)
* sumprod() (math モジュール):           数論および数表現の関数.
                                                             (line  269)
* SUNDAY (calendar モジュール):          calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  381)
* super (pyclbr.Class の属性):           クラスオブジェクト<2>.
                                                             (line   42)
* super (組み込みクラス):                組み込み関数.       (line 1903)
* supernet_of() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  226)
* supernet_of() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  350)
* supernet() (ipaddress.IPv4Network のメソッド): Network オブジェクト.
                                                             (line  198)
* supernet() (ipaddress.IPv6Network のメソッド): Network オブジェクト.
                                                             (line  346)
* supports_bytes_environ (os モジュール): プロセスのパラメーター.
                                                             (line  532)
* supports_dir_fd (os モジュール):       ファイルとディレクトリ.
                                                             (line 1452)
* supports_effective_ids (os モジュール): ファイルとディレクトリ.
                                                             (line 1477)
* supports_fd (os モジュール):           ファイルとディレクトリ.
                                                             (line 1496)
* supports_follow_symlinks (os モジュール): ファイルとディレクトリ.
                                                             (line 1515)
* supports_unicode_filenames (os.path モジュール): os path --- 一般的なパス名操作.
                                                             (line  552)
* SupportsAbs (typing のクラス):         プロトコル<3>.      (line    9)
* SupportsBytes (typing のクラス):       プロトコル<3>.      (line   13)
* SupportsComplex (typing のクラス):     プロトコル<3>.      (line   17)
* SupportsFloat (typing のクラス):       プロトコル<3>.      (line   21)
* SupportsIndex (typing のクラス):       プロトコル<3>.      (line   25)
* SupportsInt (typing のクラス):         プロトコル<3>.      (line   31)
* SupportsRound (typing のクラス):       プロトコル<3>.      (line   35)
* suppress() (contextlib モジュール):    ユーティリティ.     (line  273)
* SuppressCrashReport (test.support のクラス): test support --- テストのためのユーティリティ関数.
                                                             (line  753)
* surrogateescape;error handler's name:  エラーハンドラ.     (line   14)
* surrogatepass;error handler's name:    エラーハンドラ.     (line   71)
* SW_HIDE (subprocess モジュール):       Windows Constants.  (line   23)
* SWAP (opcode):                         Python バイトコード命令.
                                                             (line  160)
* swap_attr() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  373)
* swap_item() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  390)
* swapcase() (bytearray のメソッド):     bytes と bytearray の操作.
                                                             (line  671)
* swapcase() (bytes のメソッド):         bytes と bytearray の操作.
                                                             (line  671)
* swapcase() (str のメソッド):           文字列メソッド<2>.  (line  586)
* Symbol (symtable のクラス):            記号表の検査.       (line  192)
* SymbolTable (symtable のクラス):       記号表の検査.       (line   49)
* SymbolTableType (symtable のクラス):   記号表の検査.       (line    6)
* symlink_to() (pathlib.Path のメソッド): ファイルとディレクトリの作成.
                                                             (line   44)
* symlink() (os モジュール):             ファイルとディレクトリ.
                                                             (line 1538)
* symmetric_difference_update() (frozenset のメソッド): set（集合）型 --- set frozenset.
                                                             (line  186)
* symmetric_difference() (frozenset のメソッド): set（集合）型 --- set frozenset.
                                                             (line  115)
* symtable() (symtable モジュール):      記号表の生成.       (line    6)
* SYMTYPE (tarfile モジュール):          tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  285)
* SYN (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   90)
* sync() (dbm.dumb.dumbdbm のメソッド):  dbm dumb --- 可搬性のある DBM 実装.
                                                             (line   80)
* sync() (dbm.gnu.gdbm のメソッド):      dbm gnu --- GNU database manager.
                                                             (line  112)
* sync() (os モジュール):                ファイルとディレクトリ.
                                                             (line 1584)
* sync() (shelve.Shelf のメソッド):      shelve --- Python オブジェクトの永続化.
                                                             (line   69)
* syncdown() (curses.window のメソッド): Window オブジェクト.
                                                             (line  527)
* synchronized() (multiprocessing.sharedctypes モジュール): multiprocessing sharedctypes モジュール.
                                                             (line   88)
* SyncManager (multiprocessing.managers のクラス): マネージャー.
                                                             (line  152)
* syncok() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  534)
* syncup() (curses.window のメソッド):   Window オブジェクト.
                                                             (line  539)
* SyntaxErr:                             例外<19>.           (line   89)
* SyntaxError:                           具象例外.           (line  285)
* SyntaxWarning:                         警告.               (line   42)
* sys_version (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  144)
* sys.exc_info:                          トレースバック traceback オブジェクト.
                                                             (line    6)
* sys.exception:                         トレースバック traceback オブジェクト.
                                                             (line    6)
* sys.last_traceback:                    トレースバック traceback オブジェクト.
                                                             (line    6)
* sys.meta_path:                         メタパス.           (line    6)
* sys.modules:                           モジュールキャッシュ.
                                                             (line    6)
* sys.path:                              パスエントリ・ファインダー.
                                                             (line    6)
* sys.path_hooks:                        パスエントリ・ファインダー.
                                                             (line    6)
* sys.path_importer_cache:               パスエントリ・ファインダー.
                                                             (line    6)
* sys.stderr:                            I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* sys.stdin:                             I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* sys.stdout:                            I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* sysconf_names (os モジュール):         雑多なシステム情報. (line   84)
* sysconf() (os モジュール):             雑多なシステム情報. (line   74)
* syslog() (syslog モジュール):          syslog --- Unix syslog ライブラリルーチン群.
                                                             (line   21)
* SysLogHandler (logging.handlers のクラス): SysLogHandler.  (line   10)
* system_alias() (platform モジュール):  クロスプラットフォーム.
                                                             (line  128)
* system_must_validate_cert() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  461)
* system() (os モジュール):              プロセス管理.       (line  759)
* system() (platform モジュール):        クロスプラットフォーム.
                                                             (line  119)
* SystemError:                           具象例外.           (line  342)
* SystemError (組み込み例外):            モジュールオブジェクト module object.
                                                             (line   61)
* SystemError (組み込み例外) <1>:        モジュールオブジェクト module object.
                                                             (line   88)
* SystemExit:                            具象例外.           (line  355)
* SystemExit (組み込み例外):             例外<2>.            (line   26)
* systemId (xml.dom.DocumentType の属性): DocumentType オブジェクト.
                                                             (line   21)
* SystemRandom (random のクラス):        他の生成器.         (line   47)
* SystemRandom (secrets のクラス):       乱数.               (line    9)
* SystemRoot:                            Popen コンストラクター.
                                                             (line  306)
* T_BOOL (C macro):                      Member types.       (line   85)
* T_BYTE (C macro):                      Member types.       (line   85)
* T_CHAR (C macro):                      Member types.       (line   85)
* T_DOUBLE (C macro):                    Member types.       (line   85)
* T_FLOAT (C macro):                     Member types.       (line   85)
* T_FMT (locale モジュール):             locale --- 国際化サービス.
                                                             (line  187)
* T_FMT_AMPM (locale モジュール):        locale --- 国際化サービス.
                                                             (line  193)
* T_INT (C macro):                       Member types.       (line   85)
* T_LONG (C macro):                      Member types.       (line   85)
* T_LONGLONG (C macro):                  Member types.       (line   85)
* T_NONE (C macro):                      Member types.       (line   96)
* T_OBJECT (C macro):                    Member types.       (line   90)
* T_OBJECT_EX (C macro):                 Member types.       (line   85)
* T_PYSSIZET (C macro):                  Member types.       (line   85)
* T_SHORT (C macro):                     Member types.       (line   85)
* T_STRING (C macro):                    Member types.       (line   85)
* T_STRING_INPLACE (C macro):            Member types.       (line   85)
* T_UBYTE (C macro):                     Member types.       (line   85)
* T_UINT (C macro):                      Member types.       (line   85)
* T_ULONG (C macro):                     Member types.       (line   85)
* T_ULONGULONG (C macro):                Member types.       (line   85)
* T_USHORT (C macro):                    Member types.       (line   85)
* TAB (curses.ascii モジュール):         curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   45)
* tab() (tkinter.ttk.Notebook のメソッド): ttk Notebook.     (line   61)
* TabError:                              具象例外.           (line  337)
* tabs() (tkinter.ttk.Notebook のメソッド): ttk Notebook.    (line   70)
* tabsize (textwrap.TextWrapper の属性): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  173)
* tag (xml.etree.ElementTree.Element の属性): Element オブジェクト.
                                                             (line   16)
* tag_bind() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  292)
* tag_configure() (tkinter.ttk.Treeview のメソッド): ttk Treeview.
                                                             (line  298)
* tag_has() (tkinter.ttk.Treeview のメソッド): ttk Treeview. (line  308)
* tagName (xml.dom.Element の属性):      Element オブジェクト<2>.
                                                             (line    9)
* tail (xml.etree.ElementTree.Element の属性): Element オブジェクト.
                                                             (line   21)
* take_snapshot() (tracemalloc モジュール): 関数<11>.        (line  113)
* takewhile() (itertools モジュール):    Itertool関数.       (line  562)
* tan() (cmath モジュール):              三角関数<2>.        (line   31)
* tan() (math モジュール):               三角関数.           (line   64)
* tanh() (cmath モジュール):             双曲線関数<2>.      (line   31)
* tanh() (math モジュール):              双曲線関数.         (line   29)
* tar_filter() (tarfile モジュール):     Default named filters.
                                                             (line   15)
* TarError:                              tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  207)
* TarFile (tarfile のクラス):            TarFile オブジェクト.
                                                             (line   23)
* tarfile コマンドラインオプション; -c:  コマンドラインオプション<3>.
                                                             (line   11)
* tarfile コマンドラインオプション; -create: コマンドラインオプション<3>.
                                                             (line   11)
* tarfile コマンドラインオプション; -e:  コマンドラインオプション<3>.
                                                             (line   16)
* tarfile コマンドラインオプション; -extract: コマンドラインオプション<3>.
                                                             (line   16)
* tarfile コマンドラインオプション; -filter: コマンドラインオプション<3>.
                                                             (line   31)
* tarfile コマンドラインオプション; -l:  コマンドラインオプション<3>.
                                                             (line    6)
* tarfile コマンドラインオプション; -list: コマンドラインオプション<3>.
                                                             (line    6)
* tarfile コマンドラインオプション; -t:  コマンドラインオプション<3>.
                                                             (line   22)
* tarfile コマンドラインオプション; -test: コマンドラインオプション<3>.
                                                             (line   22)
* tarfile コマンドラインオプション; -v:  コマンドラインオプション<3>.
                                                             (line   27)
* tarfile コマンドラインオプション; -verbose: コマンドラインオプション<3>.
                                                             (line   27)
* target:                                代入文 assignment statement.
                                                             (line   27)
* target (xml.dom.ProcessingInstruction の属性): ProcessingInstruction オブジェクト.
                                                             (line    9)
* target;list:                           代入文 assignment statement.
                                                             (line   27)
* target;list <1>:                       for 文<2>.          (line    6)
* target;list;代入:                      代入文 assignment statement.
                                                             (line   35)
* TarInfo (tarfile のクラス):            TarInfo オブジェクト.
                                                             (line   33)
* tarinfo (tarfile.FilterError の属性):  tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  241)
* Task (asyncio のクラス):               Task オブジェクト.  (line    6)
* task_done() (asyncio.Queue のメソッド): Queue.             (line   99)
* task_done() (multiprocessing.JoinableQueue のメソッド): パイプ Pipe とキュー Queue.
                                                             (line  251)
* task_done() (queue.Queue のメソッド):  キューオブジェクト. (line   73)
* TaskGroup (asyncio のクラス):          Task Groups.        (line    9)
* tau (cmath モジュール):                定数<3>.            (line   14)
* tau (math モジュール):                 定数<2>.            (line   14)
* tb_frame (traceback の属性):           トレースバック traceback オブジェクト.
                                                             (line   33)
* tb_frame (トレースバック属性):         トレースバック traceback オブジェクト.
                                                             (line   31)
* tb_lasti (traceback の属性):           トレースバック traceback オブジェクト.
                                                             (line   44)
* tb_lasti (トレースバック属性):         トレースバック traceback オブジェクト.
                                                             (line   31)
* tb_lineno (traceback の属性):          トレースバック traceback オブジェクト.
                                                             (line   41)
* tb_lineno (トレースバック属性):        トレースバック traceback オブジェクト.
                                                             (line   31)
* tb_locals (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  307)
* tb_next (traceback の属性):            トレースバック traceback オブジェクト.
                                                             (line   52)
* tb_next (トレースバック属性):          トレースバック traceback オブジェクト.
                                                             (line   52)
* tbreak (pdb command):                  デバッガコマンド.   (line  119)
* tcdrain() (termios モジュール):        termios --- POSIX スタイルの端末制御.
                                                             (line   64)
* tcflow() (termios モジュール):         termios --- POSIX スタイルの端末制御.
                                                             (line   75)
* tcflush() (termios モジュール):        termios --- POSIX スタイルの端末制御.
                                                             (line   69)
* tcgetattr() (termios モジュール):      termios --- POSIX スタイルの端末制御.
                                                             (line   28)
* tcgetpgrp() (os モジュール):           ファイル記述子の操作.
                                                             (line  882)
* tcgetwinsize() (termios モジュール):   termios --- POSIX スタイルの端末制御.
                                                             (line   82)
* Tcl() (tkinter モジュール):            Tkinter モジュール. (line   94)
* TCPServer (socketserver のクラス):     socketserver --- ネットワークサーバーのフレームワーク.
                                                             (line   20)
* TCSADRAIN (termios モジュール):        termios --- POSIX スタイルの端末制御.
                                                             (line   49)
* TCSAFLUSH (termios モジュール):        termios --- POSIX スタイルの端末制御.
                                                             (line   53)
* TCSANOW (termios モジュール):          termios --- POSIX スタイルの端末制御.
                                                             (line   45)
* tcsendbreak() (termios モジュール):    termios --- POSIX スタイルの端末制御.
                                                             (line   58)
* tcsetattr() (termios モジュール):      termios --- POSIX スタイルの端末制御.
                                                             (line   38)
* tcsetpgrp() (os モジュール):           ファイル記述子の操作.
                                                             (line  889)
* tcsetwinsize() (termios モジュール):   termios --- POSIX スタイルの端末制御.
                                                             (line   90)
* tearDown() (unittest.TestCase のメソッド): テストクラス.   (line   41)
* tearDownClass() (unittest.TestCase のメソッド): テストクラス.
                                                             (line   68)
* tee() (itertools モジュール):          Itertool関数.       (line  581)
* teleport() (turtle モジュール):        Turtle の動き.      (line  104)
* tell() (io.IOBase のメソッド):         I/O 基底クラス.     (line  135)
* tell() (io.TextIOBase のメソッド):     テキスト I/O<2>.    (line   86)
* tell() (io.TextIOWrapper のメソッド):  テキスト I/O<2>.    (line  228)
* tell() (mmap.mmap のメソッド):         mmap --- メモリマップファイルのサポート.
                                                             (line  318)
* tell() (sqlite3.Blob のメソッド):      Blob オブジェクト.  (line   61)
* tell() (wave.Wave_read のメソッド):    Wave_read オブジェクト.
                                                             (line   87)
* tell() (wave.Wave_write のメソッド):   Wave_write オブジェクト.
                                                             (line   70)
* TEMP:                                  Redirection of local data registry and temporary paths.
                                                             (line    6)
* TEMP <1>:                              tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  326)
* temp_cwd() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  134)
* temp_dir() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  149)
* temp_umask() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  158)
* tempdir (tempfile モジュール):         tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  372)
* Template (string のクラス):            テンプレート文字列. (line   37)
* template (string.Template の属性):     テンプレート文字列. (line   86)
* temporary (bdb.Breakpoint の属性):     bdb --- デバッガーフレームワーク.
                                                             (line   92)
* TemporaryDirectory (tempfile のクラス): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  183)
* TemporaryFile() (tempfile モジュール): tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line   27)
* teredo (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  304)
* TERM:                                  関数<6>.            (line  470)
* TERM <1>:                              関数<6>.            (line  495)
* termattrs() (curses モジュール):       関数<6>.            (line  487)
* terminal_size (os のクラス):           ターミナルのサイズの問い合わせ.
                                                             (line   24)
* terminate() (asyncio.subprocess.Process のメソッド): サブプロセスとやりとりする.
                                                             (line   97)
* terminate() (asyncio.SubprocessTransport のメソッド): サブプロセス化されたトランスポート.
                                                             (line   49)
* terminate() (multiprocessing.pool.Pool のメソッド): プロセスプール.
                                                             (line  179)
* terminate() (multiprocessing.Process のメソッド): Process クラスと例外.
                                                             (line  172)
* terminate() (subprocess.Popen のメソッド): Popen オブジェクト.
                                                             (line   88)
* terminator (logging.StreamHandler の属性): StreamHandler.  (line   48)
* termname() (curses モジュール):        関数<6>.            (line  493)
* ternaryfunc (C type):                  Slot Type typedefs. (line  130)
* test (doctest.DocTestFailure の属性):  デバッグ.           (line  190)
* test (doctest.UnexpectedException の属性): デバッグ.       (line  211)
* TEST_DATA_DIR (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  137)
* TEST_HOME_DIR (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  133)
* TEST_HTTP_URL (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  174)
* TEST_SUPPORT_DIR (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  129)
* TestCase (unittest のクラス):          テストクラス.       (line    6)
* TestFailed:                            test support --- テストのためのユーティリティ関数.
                                                             (line   16)
* testfile() (doctest モジュール):       基本 API.           (line   12)
* TESTFN (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   19)
* TESTFN_NONASCII (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   25)
* TESTFN_UNDECODABLE (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   39)
* TESTFN_UNENCODABLE (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   33)
* TESTFN_UNICODE (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line   45)
* TestLoader (unittest のクラス):        テストのロードと起動.
                                                             (line    6)
* testMethodPrefix (unittest.TestLoader の属性): テストのロードと起動.
                                                             (line  185)
* testmod() (doctest モジュール):        基本 API.           (line   94)
* testNamePatterns (unittest.TestLoader の属性): テストのロードと起動.
                                                             (line  207)
* TestResult (unittest のクラス):        テストのロードと起動.
                                                             (line  225)
* TestResults (doctest のクラス):        TestResults objects.
                                                             (line    6)
* testsource() (doctest モジュール):     デバッグ.           (line  105)
* testsRun (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  285)
* TestSuite (unittest のクラス):         テストのグループ化. (line    6)
* testzip() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  268)
* text (SyntaxError の属性):             具象例外.           (line  309)
* text (traceback.TracebackException の属性): TracebackException オブジェクト.
                                                             (line  106)
* Text (typing のクラス):                Aliases to other concrete types.
                                                             (line   21)
* text (xml.etree.ElementTree.Element の属性): Element オブジェクト.
                                                             (line   21)
* text encoding:                         用語集<2>.          (line 1378)
* text file:                             用語集<2>.          (line 1391)
* text mode:                             組み込み関数.       (line 1455)
* text_encoding() (io モジュール):       高水準のモジュールインターフェイス.
                                                             (line   38)
* text_factory (sqlite3.Connection の属性): Connection オブジェクト.
                                                             (line  823)
* Textbox (curses.textpad のクラス):     Textbox オブジェクト.
                                                             (line    9)
* TextCalendar (calendar のクラス):      calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  121)
* textdomain() (gettext モジュール):     GNU gettext API.    (line   26)
* textdomain() (locale モジュール):      メッセージカタログへのアクセス.
                                                             (line   12)
* textinput() (turtle モジュール):       入力メソッド.       (line    6)
* TextIO (typing のクラス):              ABCs for working with IO.
                                                             (line    6)
* TextIOBase (io のクラス):              テキスト I/O<2>.    (line    6)
* TextIOWrapper (io のクラス):           テキスト I/O<2>.    (line   96)
* TextTestResult (unittest のクラス):    テストのロードと起動.
                                                             (line  436)
* TextTestRunner (unittest のクラス):    テストのロードと起動.
                                                             (line  454)
* TextWrapper (textwrap のクラス):       textwrap --- テキストの折り返しと詰め込み.
                                                             (line  140)
* TFD_CLOEXEC (os モジュール):           Timer File Descriptors.
                                                             (line  203)
* TFD_NONBLOCK (os モジュール):          Timer File Descriptors.
                                                             (line  192)
* TFD_TIMER_ABSTIME (os モジュール):     Timer File Descriptors.
                                                             (line  213)
* TFD_TIMER_CANCEL_ON_SET (os モジュール): Timer File Descriptors.
                                                             (line  224)
* theme_create() (tkinter.ttk.Style のメソッド): Ttk スタイル.
                                                             (line  260)
* theme_names() (tkinter.ttk.Style のメソッド): Ttk スタイル.
                                                             (line  308)
* theme_settings() (tkinter.ttk.Style のメソッド): Ttk スタイル.
                                                             (line  270)
* theme_use() (tkinter.ttk.Style のメソッド): Ttk スタイル.  (line  312)
* THOUSEP (locale モジュール):           locale --- 国際化サービス.
                                                             (line  257)
* Thread (threading のクラス):           Thread オブジェクト.
                                                             (line   62)
* thread_info (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line 1875)
* thread_time_ns() (time モジュール):    関数<5>.            (line  608)
* thread_time() (time モジュール):       関数<5>.            (line  592)
* thread() (imaplib.IMAP4 のメソッド):   IMAP4 オブジェクト. (line  350)
* ThreadedChildWatcher (asyncio のクラス): プロセスのウオッチャー.
                                                             (line   95)
* threading_cleanup() (test.support.threading_helper モジュール): test support threading_helper --- Utilities for threading tests.
                                                             (line   31)
* threading_setup() (test.support.threading_helper モジュール): test support threading_helper --- Utilities for threading tests.
                                                             (line   37)
* ThreadingHTTPServer (http.server のクラス): http server --- HTTP サーバー.
                                                             (line   37)
* ThreadingMixIn (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   26)
* ThreadingMock (unittest.mock のクラス): Mock クラス.       (line  926)
* ThreadingTCPServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* ThreadingUDPServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* ThreadingUnixDatagramServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* ThreadingUnixStreamServer (socketserver のクラス): サーバ生成に関するノート.
                                                             (line   67)
* ThreadPool (multiprocessing.pool のクラス): multiprocessing dummy モジュール.
                                                             (line   15)
* ThreadPoolExecutor (concurrent.futures のクラス): ThreadPoolExecutor.
                                                             (line   39)
* threads;POSIX:                         _thread --- 低水準なスレッド API.
                                                             (line   15)
* threadsafety (sqlite3 モジュール):     モジュール定数.     (line   82)
* throw() (coroutine のメソッド):        コルーチンオブジェクト.
                                                             (line   32)
* throw() (generator のメソッド):        ジェネレータ-イテレータメソッド.
                                                             (line   37)
* THURSDAY (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  381)
* ticket_lifetime_hint (ssl.SSLSession の属性): SSL セッション.
                                                             (line   18)
* tigetflag() (curses モジュール):       関数<6>.            (line  498)
* tigetnum() (curses モジュール):        関数<6>.            (line  504)
* tigetstr() (curses モジュール):        関数<6>.            (line  510)
* TILDE (token モジュール):              token --- Python 解析木で使われる定数.
                                                             (line  147)
* tilt() (turtle モジュール):            見た目.             (line   99)
* tiltangle() (turtle モジュール):       見た目.             (line  115)
* time (datetime のクラス):              time オブジェクト.  (line   10)
* time (ssl.SSLSession の属性):          SSL セッション.     (line   14)
* time (uuid.UUID の属性):               uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  121)
* time_hi_version (uuid.UUID の属性):    uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  109)
* time_low (uuid.UUID の属性):           uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  103)
* time_mid (uuid.UUID の属性):           uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  106)
* time_ns() (time モジュール):           関数<5>.            (line  585)
* time() (asyncio.loop のメソッド):      遅延コールバックのスケジューリング.
                                                             (line   59)
* time() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  444)
* time() (time モジュール):              関数<5>.            (line  553)
* Time2Internaldate() (imaplib モジュール): imaplib --- IMAP4 プロトコルクライアント.
                                                             (line  132)
* timedelta (datetime のクラス):         timedelta オブジェクト.
                                                             (line    9)
* TimedRotatingFileHandler (logging.handlers のクラス): TimedRotatingFileHandler.
                                                             (line   10)
* timegm() (calendar モジュール):        calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  351)
* timeit コマンドラインオプション; -h:   コマンドラインインターフェイス<6>.
                                                             (line   43)
* timeit コマンドラインオプション; -help: コマンドラインインターフェイス<6>.
                                                             (line   43)
* timeit コマンドラインオプション; -n:   コマンドラインインターフェイス<6>.
                                                             (line   12)
* timeit コマンドラインオプション; -number: コマンドラインインターフェイス<6>.
                                                             (line   12)
* timeit コマンドラインオプション; -p:   コマンドラインインターフェイス<6>.
                                                             (line   24)
* timeit コマンドラインオプション; -process: コマンドラインインターフェイス<6>.
                                                             (line   24)
* timeit コマンドラインオプション; -r:   コマンドラインインターフェイス<6>.
                                                             (line   16)
* timeit コマンドラインオプション; -repeat: コマンドラインインターフェイス<6>.
                                                             (line   16)
* timeit コマンドラインオプション; -s:   コマンドラインインターフェイス<6>.
                                                             (line   20)
* timeit コマンドラインオプション; -setup: コマンドラインインターフェイス<6>.
                                                             (line   20)
* timeit コマンドラインオプション; -u:   コマンドラインインターフェイス<6>.
                                                             (line   32)
* timeit コマンドラインオプション; -unit: コマンドラインインターフェイス<6>.
                                                             (line   32)
* timeit コマンドラインオプション; -v:   コマンドラインインターフェイス<6>.
                                                             (line   39)
* timeit コマンドラインオプション; -verbose: コマンドラインインターフェイス<6>.
                                                             (line   39)
* timeit() (timeit モジュール):          Python インターフェイス.
                                                             (line    8)
* timeit() (timeit.Timer のメソッド):    Python インターフェイス.
                                                             (line   68)
* timeout:                               例外<14>.           (line   39)
* Timeout (asyncio のクラス):            タイムアウト.       (line   50)
* timeout (socketserver.BaseServer の属性): Serverオブジェクト<2>.
                                                             (line  111)
* timeout (ssl.SSLSession の属性):       SSL セッション.     (line   16)
* timeout (subprocess.TimeoutExpired の属性): subprocess モジュールを使う.
                                                             (line  176)
* timeout_at() (asyncio モジュール):     タイムアウト.       (line   98)
* TIMEOUT_MAX (_thread モジュール):      _thread --- 低水準なスレッド API.
                                                             (line  131)
* TIMEOUT_MAX (threading モジュール):    threading --- スレッドベースの並列処理.
                                                             (line  227)
* timeout() (asyncio モジュール):        タイムアウト.       (line    6)
* timeout() (curses.window のメソッド):  Window オブジェクト.
                                                             (line  544)
* TimeoutError:                          OS 例外.            (line  111)
* TimeoutError <1>:                      Process クラスと例外.
                                                             (line  243)
* TimeoutError <2>:                      例外クラス.         (line   10)
* TimeoutError <3>:                      例外<12>.           (line   10)
* TimeoutExpired:                        subprocess モジュールを使う.
                                                             (line  167)
* Timer (threading のクラス):            Timer オブジェクト. (line   24)
* Timer (timeit のクラス):               Python インターフェイス.
                                                             (line   40)
* timerfd_create() (os モジュール):      Timer File Descriptors.
                                                             (line   11)
* timerfd_gettime_ns() (os モジュール):  Timer File Descriptors.
                                                             (line  183)
* timerfd_gettime() (os モジュール):     Timer File Descriptors.
                                                             (line  163)
* timerfd_settime_ns() (os モジュール):  Timer File Descriptors.
                                                             (line  152)
* timerfd_settime() (os モジュール):     Timer File Descriptors.
                                                             (line   84)
* TimerHandle (asyncio のクラス):        コールバックのハンドル.
                                                             (line   29)
* times() (os モジュール):               プロセス管理.       (line  796)
* TIMESTAMP (py_compile.PycInvalidationMode の属性): py_compile --- Python ソースファイルをコンパイルする.
                                                             (line  103)
* timestamp() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  601)
* timetuple() (datetime.date のメソッド): date オブジェクト. (line  207)
* timetuple() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  555)
* timetz() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  453)
* timezone (datetime のクラス):          timezone オブジェクト.
                                                             (line   14)
* timezone (time モジュール):            Timezone Constants. (line   18)
* title() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  696)
* title() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  696)
* title() (str のメソッド):              文字列メソッド<2>.  (line  592)
* title() (turtle モジュール):           Screen 独自のメソッド、TurtleScreen から継承したもの以外.
                                                             (line   49)
* Tk:                                    Tk を用いたグラフィカルユーザーインターフェース.
                                                             (line    6)
* Tk (tkinter のクラス):                 Tkinter モジュール. (line   14)
* tk (tkinter.Tk の属性):                Tkinter モジュール. (line   70)
* Tk オプションデータ型:                 Tk オプションデータ型.
                                                             (line    6)
* Tkinter:                               Tk を用いたグラフィカルユーザーインターフェース.
                                                             (line    6)
* TLS:                                   ssl --- ソケットオブジェクト用の TLS/SSL ラッパー.
                                                             (line    8)
* TLSv1 (ssl.TLSVersion の属性):         定数<9>.            (line  574)
* TLSv1_1 (ssl.TLSVersion の属性):       定数<9>.            (line  576)
* TLSv1_2 (ssl.TLSVersion の属性):       定数<9>.            (line  578)
* TLSv1_3 (ssl.TLSVersion の属性):       定数<9>.            (line  580)
* TLSVersion (ssl のクラス):             定数<9>.            (line  556)
* tm_gmtoff (time.struct_time の属性):   関数<5>.            (line  538)
* tm_hour (time.struct_time の属性):     関数<5>.            (line  514)
* tm_isdst (time.struct_time の属性):    関数<5>.            (line  531)
* tm_mday (time.struct_time の属性):     関数<5>.            (line  511)
* tm_min (time.struct_time の属性):      関数<5>.            (line  517)
* tm_mon (time.struct_time の属性):      関数<5>.            (line  508)
* tm_sec (time.struct_time の属性):      関数<5>.            (line  520)
* tm_wday (time.struct_time の属性):     関数<5>.            (line  525)
* tm_yday (time.struct_time の属性):     関数<5>.            (line  528)
* tm_year (time.struct_time の属性):     関数<5>.            (line  505)
* tm_zone (time.struct_time の属性):     関数<5>.            (line  535)
* TMP:                                   tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  328)
* TMPDIR:                                Tests<20>.          (line   68)
* TMPDIR <1>:                            tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  324)
* TO_BOOL (opcode):                      Python バイトコード命令.
                                                             (line  217)
* to_bytes() (int のメソッド):           整数型における追加のメソッド.
                                                             (line   54)
* to_eng_string() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  512)
* to_eng_string() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  540)
* to_integral_exact() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  520)
* to_integral_exact() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  557)
* to_integral_value() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  566)
* to_integral() (decimal.Decimal のメソッド): Decimal オブジェクト.
                                                             (line  551)
* to_sci_string() (decimal.Context のメソッド): Context オブジェクト.
                                                             (line  524)
* to_thread() (asyncio モジュール):      スレッド内での実行. (line    6)
* ToASCII() (encodings.idna モジュール): encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   53)
* tobuf() (tarfile.TarInfo のメソッド):  TarInfo オブジェクト.
                                                             (line   50)
* tobytes() (array.array のメソッド):    array --- 効率的な数値配列.
                                                             (line  234)
* tobytes() (memoryview のメソッド):     メモリビュー.       (line  159)
* today() (datetime.date のクラスメソッド): date オブジェクト.
                                                             (line   28)
* today() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line   47)
* tofile() (array.array のメソッド):     array --- 効率的な数値配列.
                                                             (line  243)
* tok_name (token モジュール):           token --- Python 解析木で使われる定数.
                                                             (line   18)
* Token (contextvars のクラス):          コンテキスト変数.   (line   73)
* token (shlex.shlex の属性):            shlex オブジェクト. (line  172)
* token_bytes() (secrets モジュール):    トークンの生成.     (line    9)
* token_hex() (secrets モジュール):      トークンの生成.     (line   17)
* token_urlsafe() (secrets モジュール):  トークンの生成.     (line   27)
* TokenError:                            入力のトークナイズ. (line  106)
* tokenize コマンドラインオプション; -e: コマンドラインからの使用<6>.
                                                             (line   19)
* tokenize コマンドラインオプション; -exact: コマンドラインからの使用<6>.
                                                             (line   19)
* tokenize コマンドラインオプション; -h: コマンドラインからの使用<6>.
                                                             (line   15)
* tokenize コマンドラインオプション; -help: コマンドラインからの使用<6>.
                                                             (line   15)
* tokenize() (tokenize モジュール):      入力のトークナイズ. (line    8)
* tolist() (array.array のメソッド):     array --- 効率的な数値配列.
                                                             (line  248)
* tolist() (memoryview のメソッド):      メモリビュー.       (line  200)
* TOMLDecodeError:                       tomllib --- TOML ファイルの解析.
                                                             (line   61)
* toordinal() (datetime.date のメソッド): date オブジェクト. (line  221)
* toordinal() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  596)
* top_panel() (curses.panel モジュール): 関数<7>.            (line   19)
* top() (curses.panel.Panel のメソッド): Panel オブジェクト. (line   53)
* top() (poplib.POP3 のメソッド):        POP3 オブジェクト.  (line   87)
* TopologicalSorter (graphlib のクラス): graphlib --- グラフ構造を操作する機能.
                                                             (line   10)
* toprettyxml() (xml.dom.minidom.Node のメソッド): DOM オブジェクト.
                                                             (line   72)
* toreadonly() (memoryview のメソッド):  メモリビュー.       (line  216)
* tostring() (xml.etree.ElementTree モジュール): 関数<9>.    (line  217)
* tostringlist() (xml.etree.ElementTree モジュール): 関数<9>.
                                                             (line  239)
* total_changes (sqlite3.Connection の属性): Connection オブジェクト.
                                                             (line  834)
* total_nframe (tracemalloc.Traceback の属性): Traceback.    (line   28)
* total_ordering() (functools モジュール): functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  273)
* total_seconds() (datetime.timedelta のメソッド): timedelta オブジェクト.
                                                             (line  227)
* total() (collections.Counter のメソッド): Counter オブジェクト.
                                                             (line   99)
* touch() (pathlib.Path のメソッド):     ファイルとディレクトリの作成.
                                                             (line    6)
* touchline() (curses.window のメソッド): Window オブジェクト.
                                                             (line  553)
* touchwin() (curses.window のメソッド): Window オブジェクト.
                                                             (line  559)
* tounicode() (array.array のメソッド):  array --- 効率的な数値配列.
                                                             (line  252)
* ToUnicode() (encodings.idna モジュール): encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA.
                                                             (line   58)
* towards() (turtle モジュール):         Turtle の状態を知る.
                                                             (line   15)
* toxml() (xml.dom.minidom.Node のメソッド): DOM オブジェクト.
                                                             (line   52)
* tparm() (curses モジュール):           関数<6>.            (line  517)
* Trace (trace のクラス):                プログラミングインターフェース.
                                                             (line    6)
* Trace (tracemalloc のクラス):          Trace.              (line    6)
* trace function:                        threading --- スレッドベースの並列処理.
                                                             (line  157)
* trace function <1>:                    threading --- スレッドベースの並列処理.
                                                             (line  174)
* trace function <2>:                    sys --- システム固有のパラメーターと関数.
                                                             (line  925)
* trace function <3>:                    sys --- システム固有のパラメーターと関数.
                                                             (line 1568)
* trace コマンドラインオプション; -c:    主要なオプション.   (line   13)
* trace コマンドラインオプション; -C:    修飾的オプション.   (line   12)
* trace コマンドラインオプション; -count: 主要なオプション.  (line   13)
* trace コマンドラインオプション; -coverdir: 修飾的オプション.
                                                             (line   12)
* trace コマンドラインオプション; -f:    修飾的オプション.   (line    6)
* trace コマンドラインオプション; -file: 修飾的オプション.   (line    6)
* trace コマンドラインオプション; -g:    修飾的オプション.   (line   35)
* trace コマンドラインオプション; -help: コマンドラインからの使用<3>.
                                                             (line   14)
* trace コマンドラインオプション; -ignore-dir: フィルターオプション.
                                                             (line   13)
* trace コマンドラインオプション; -ignore-module: フィルターオプション.
                                                             (line    8)
* trace コマンドラインオプション; -l:    主要なオプション.   (line   23)
* trace コマンドラインオプション; -listfuncs: 主要なオプション.
                                                             (line   23)
* trace コマンドラインオプション; -m:    修飾的オプション.   (line   18)
* trace コマンドラインオプション; -missing: 修飾的オプション.
                                                             (line   18)
* trace コマンドラインオプション; -no-report: 修飾的オプション.
                                                             (line   29)
* trace コマンドラインオプション; -r:    主要なオプション.   (line   27)
* trace コマンドラインオプション; -R:    修飾的オプション.   (line   29)
* trace コマンドラインオプション; -report: 主要なオプション. (line   27)
* trace コマンドラインオプション; -s:    修飾的オプション.   (line   23)
* trace コマンドラインオプション; -summary: 修飾的オプション.
                                                             (line   23)
* trace コマンドラインオプション; -t:    主要なオプション.   (line   19)
* trace コマンドラインオプション; -T:    主要なオプション.   (line   33)
* trace コマンドラインオプション; -timing: 修飾的オプション. (line   35)
* trace コマンドラインオプション; -trace: 主要なオプション.  (line   19)
* trace コマンドラインオプション; -trackcalls: 主要なオプション.
                                                             (line   33)
* trace コマンドラインオプション; -version: コマンドラインからの使用<3>.
                                                             (line   18)
* trace_dispatch() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  166)
* trace() (inspect モジュール):          インタープリタスタック.
                                                             (line  179)
* Traceback (inspect のクラス):          インタープリタスタック.
                                                             (line   55)
* Traceback (tracemalloc のクラス):      Traceback.          (line    6)
* traceback (tracemalloc.Statistic の属性): Statistic.       (line   23)
* traceback (tracemalloc.StatisticDiff の属性): StatisticDiff.
                                                             (line   39)
* traceback (tracemalloc.Trace の属性):  Trace.              (line   27)
* traceback_limit (tracemalloc.Snapshot の属性): Snapshot.   (line   84)
* traceback_limit (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  218)
* TracebackException (traceback のクラス): TracebackException オブジェクト.
                                                             (line   15)
* tracebacklimit (sys モジュール):       sys --- システム固有のパラメーターと関数.
                                                             (line 1911)
* TracebackType (types のクラス):        標準的なインタプリタ型.
                                                             (line  185)
* tracer() (turtle モジュール):          アニメーションの制御.
                                                             (line   23)
* traces (tracemalloc.Snapshot の属性):  Snapshot.           (line   90)
* transfercmd() (ftplib.FTP のメソッド): FTP オブジェクト.   (line  256)
* transient_internet() (test.support.socket_helper モジュール): test support socket_helper --- Utilities for socket tests.
                                                             (line   64)
* translate() (bytearray のメソッド):    bytes と bytearray の操作.
                                                             (line  265)
* translate() (bytes のメソッド):        bytes と bytearray の操作.
                                                             (line  265)
* translate() (fnmatch モジュール):      fnmatch --- Unix のファイル名パターンマッチ.
                                                             (line   77)
* translate() (glob モジュール):         glob --- Unix 形式のパス名のパターン展開.
                                                             (line  116)
* translate() (str のメソッド):          文字列メソッド<2>.  (line  624)
* translation() (gettext モジュール):    クラス形式の API.   (line   42)
* Transport (asyncio のクラス):          トランスポートのクラス階層構造.
                                                             (line   29)
* transport (asyncio.StreamWriter の属性): StreamWriter.     (line   59)
* Transport Layer Security:              ssl --- ソケットオブジェクト用の TLS/SSL ラッパー.
                                                             (line    8)
* Traversable (importlib.abc のクラス):  importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  499)
* Traversable (importlib.resources.abc のクラス): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line   86)
* TraversableResources (importlib.abc のクラス): importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  554)
* TraversableResources (importlib.resources.abc のクラス): importlib resources abc -- リソースの抽象基底クラス.
                                                             (line  158)
* traverseproc (C type):                 循環参照ガベージコレクションをサポートする.
                                                             (line  166)
* TreeBuilder (xml.etree.ElementTree のクラス): TreeBuilder オブジェクト.
                                                             (line    6)
* Treeview (tkinter.ttk のクラス):       ttk Treeview.       (line    6)
* triangular() (random モジュール):      実数分布.           (line   22)
* tries (doctest.DocTestRunner の属性):  DocTestRunner オブジェクト.
                                                             (line  136)
* triple-quoted string:                  文字列およびバイト列リテラル.
                                                             (line   36)
* triple-quoted string <1>:              用語集<2>.          (line 1405)
* True:                                  numbers Integral 整数.
                                                             (line   24)
* true:                                  真理値判定.         (line    9)
* True <1>:                              真理値判定.         (line   22)
* True <2>:                              ブーリアン型 - bool.
                                                             (line    9)
* True (組み込み変数):                   組み込み定数.       (line   13)
* truediv() (operator モジュール):       operator --- 関数形式の標準演算子.
                                                             (line  157)
* trunc() (math モジュール):             数値型 int float complex.
                                                             (line  102)
* trunc() (math モジュール) <1>:         数論および数表現の関数.
                                                             (line  286)
* truncate() (io.IOBase のメソッド):     I/O 基底クラス.     (line  139)
* truncate() (os モジュール):            ファイルとディレクトリ.
                                                             (line 1592)
* truth() (operator モジュール):         operator --- 関数形式の標準演算子.
                                                             (line   54)
* Try (ast のクラス):                    制御フロー.         (line  130)
* TryStar (ast のクラス):                制御フロー.         (line  173)
* ttk:                                   tkinter ttk --- Tk のテーマ付きウィジェット.
                                                             (line    8)
* tty;I/O control:                       termios --- POSIX スタイルの端末制御.
                                                             (line    6)
* ttyname() (os モジュール):             ファイル記述子の操作.
                                                             (line  896)
* TUESDAY (calendar モジュール):         calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  381)
* Tuple (ast のクラス):                  リテラル<3>.        (line   65)
* Tuple (typing モジュール):             Aliases to built-in types.
                                                             (line   50)
* tuple (組み込みクラス):                タプル型 tuple.     (line   12)
* Turtle (turtle のクラス):              Public classes.     (line   16)
* turtles() (turtle モジュール):         設定と特殊なメソッド.
                                                             (line   95)
* TurtleScreen (turtle のクラス):        Public classes.     (line   22)
* turtlesize() (turtle モジュール):      見た目.             (line   50)
* type:                                  標準型の階層.       (line    6)
* type <1>:                              用語集<2>.          (line 1414)
* type (optparse.Option の属性):         オプション属性.     (line   27)
* type (socket.socket の属性):           socket オブジェクト.
                                                             (line  617)
* type (tarfile.TarInfo の属性):         TarInfo オブジェクト.
                                                             (line   87)
* Type (typing のクラス):                Aliases to built-in types.
                                                             (line   61)
* type (urllib.request.Request の属性):  Request オブジェクト.
                                                             (line   21)
* type (組み込みクラス):                 組み込み関数.       (line 1992)
* type alias:                            用語集<2>.          (line 1421)
* type hint:                             用語集<2>.          (line 1442)
* type parameters:                       Type parameter lists.
                                                             (line   11)
* TYPE_ALIAS (symtable.SymbolTableType の属性): 記号表の検査.
                                                             (line   31)
* type_check_only() (typing モジュール): Functions and decorators.
                                                             (line  409)
* TYPE_CHECKER (optparse.Option の属性): 新しい型の追加.     (line   17)
* TYPE_CHECKING (typing モジュール):     定数<10>.           (line    6)
* type_comment (ast.arg の属性):         関数およびクラス定義.
                                                             (line   73)
* type_comment (ast.Assign の属性):      文 Statements.      (line   15)
* type_comment (ast.For の属性):         制御フロー.         (line   54)
* type_comment (ast.FunctionDef の属性): 関数およびクラス定義.
                                                             (line   25)
* type_comment (ast.With の属性):        制御フロー.         (line  237)
* TYPE_COMMENT (token モジュール):       token --- Python 解析木で使われる定数.
                                                             (line  247)
* TYPE_IGNORE (token モジュール):        token --- Python 解析木で使われる定数.
                                                             (line  245)
* TYPE_PARAMETERS (symtable.SymbolTableType の属性): 記号表の検査.
                                                             (line   35)
* TYPE_VARIABLE (symtable.SymbolTableType の属性): 記号表の検査.
                                                             (line   40)
* type;階層:                             標準型の階層.       (line    6)
* typeahead() (curses モジュール):       関数<6>.            (line  525)
* TypeAlias (ast のクラス):              文 Statements.      (line  162)
* TypeAlias (typing モジュール):         特殊型.             (line  198)
* TypeAliasType (typing のクラス):       Building generic types and type aliases.
                                                             (line  492)
* typecode (array.array の属性):         array --- 効率的な数値配列.
                                                             (line  112)
* typecodes (array モジュール):          array --- 効率的な数値配列.
                                                             (line   81)
* TYPED_ACTIONS (optparse.Option の属性): 新しいアクションの追加.
                                                             (line   40)
* typed_subpart_iterator() (email.iterators モジュール): email iterators イテレータ.
                                                             (line   27)
* TypedDict (typing のクラス):           Other special directives.
                                                             (line  232)
* TypeError:                             具象例外.           (line  381)
* TypeGuard (typing モジュール):         特殊形式.           (line  498)
* TypeIs (typing モジュール):            特殊形式.           (line  408)
* TYPES (optparse.Option の属性):        新しい型の追加.     (line   11)
* types_map (mimetypes モジュール):      mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  153)
* types_map (mimetypes.MimeTypes の属性): Mime 型オブジェクト.
                                                             (line   38)
* types_map_inv (mimetypes.MimeTypes の属性): Mime 型オブジェクト.
                                                             (line   45)
* TypeVar (ast のクラス):                Type parameters.    (line    9)
* TypeVar (typing のクラス):             Building generic types and type aliases.
                                                             (line   54)
* TypeVarTuple (ast のクラス):           Type parameters.    (line   68)
* TypeVarTuple (typing のクラス):        Building generic types and type aliases.
                                                             (line  217)
* TZ:                                    関数<5>.            (line  618)
* TZ <1>:                                関数<5>.            (line  619)
* TZ <2>:                                関数<5>.            (line  627)
* TZ <3>:                                関数<5>.            (line  631)
* TZ <4>:                                関数<5>.            (line  633)
* TZ <5>:                                関数<5>.            (line  696)
* tzinfo (datetime のクラス):            tzinfo オブジェクト.
                                                             (line    6)
* tzinfo (datetime.datetime の属性):     datetime オブジェクト.
                                                             (line  331)
* tzinfo (datetime.time の属性):         time オブジェクト.  (line   66)
* tzname (time モジュール):              Timezone Constants. (line   25)
* tzname() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  549)
* tzname() (datetime.time のメソッド):   time オブジェクト.  (line  251)
* tzname() (datetime.timezone のメソッド): timezone オブジェクト.
                                                             (line   42)
* tzname() (datetime.tzinfo のメソッド): tzinfo オブジェクト.
                                                             (line  125)
* TZPATH (zoneinfo モジュール):          Globals.            (line    6)
* tzset() (time モジュール):             関数<5>.            (line  615)
* U (re モジュール):                     フラグ.             (line  112)
* u';文字列リテラル:                     リテラル.           (line    8)
* u";文字列リテラル:                     リテラル.           (line    8)
* UAdd (ast のクラス):                   式 expression<2>.   (line   28)
* ucd_3_2_0 (unicodedata モジュール):    unicodedata --- Unicode データベース.
                                                             (line  124)
* udata (select.kevent の属性):          kevent オブジェクト.
                                                             (line  178)
* UDPServer (socketserver のクラス):     socketserver --- ネットワークサーバーのフレームワーク.
                                                             (line   30)
* UF_APPEND (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line  358)
* UF_COMPRESSED (stat モジュール):       stat --- stat の結果を解釈する.
                                                             (line  371)
* UF_DATAVAULT (stat モジュール):        stat --- stat の結果を解釈する.
                                                             (line  381)
* UF_HIDDEN (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line  387)
* UF_IMMUTABLE (stat モジュール):        stat --- stat の結果を解釈する.
                                                             (line  354)
* UF_NODUMP (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line  350)
* UF_NOUNLINK (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  367)
* UF_OPAQUE (stat モジュール):           stat --- stat の結果を解釈する.
                                                             (line  362)
* UF_SETTABLE (stat モジュール):         stat --- stat の結果を解釈する.
                                                             (line  344)
* UF_TRACKED (stat モジュール):          stat --- stat の結果を解釈する.
                                                             (line  375)
* UID (plistlib のクラス):               plistlib --- Apple plist ファイルを生成・解析する.
                                                             (line  140)
* uid (tarfile.TarInfo の属性):          TarInfo オブジェクト.
                                                             (line  107)
* uid() (imaplib.IMAP4 のメソッド):      IMAP4 オブジェクト. (line  373)
* uidl() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   99)
* ULONG_MAX (C macro):                   整数型オブジェクト integer object.
                                                             (line  250)
* ulp() (math モジュール):               数論および数表現の関数.
                                                             (line  294)
* umask() (os モジュール):               プロセスのパラメーター.
                                                             (line  539)
* unalias (pdb command):                 デバッガコマンド.   (line  393)
* uname (tarfile.TarInfo の属性):        TarInfo オブジェクト.
                                                             (line  123)
* uname() (os モジュール):               プロセスのパラメーター.
                                                             (line  546)
* uname() (platform モジュール):         クロスプラットフォーム.
                                                             (line  142)
* UNARY_INVERT (opcode):                 Python バイトコード命令.
                                                             (line  201)
* UNARY_NEGATIVE (opcode):               Python バイトコード命令.
                                                             (line  190)
* UNARY_NOT (opcode):                    Python バイトコード命令.
                                                             (line  194)
* unaryfunc (C type):                    Slot Type typedefs. (line  116)
* UnaryOp (ast のクラス):                式 expression<2>.   (line   23)
* unbinding;name:                        del 文<2>.          (line   15)
* UnboundLocalError:                     名前解決.           (line   17)
* UnboundLocalError <1>:                 具象例外.           (line  398)
* unbuffered I/O:                        組み込み関数.       (line 1455)
* UNC パス;os.makedirs():                ファイルとディレクトリ.
                                                             (line  558)
* uncancel() (asyncio.Task のメソッド):  Task オブジェクト.  (line  271)
* UNCHECKED_HASH (py_compile.PycInvalidationMode の属性): py_compile --- Python ソースファイルをコンパイルする.
                                                             (line  116)
* unconsumed_tail (zlib.Decompress の属性): zlib --- gzip 互換の圧縮.
                                                             (line  240)
* unctrl() (curses モジュール):          関数<6>.            (line  537)
* unctrl() (curses.ascii モジュール):    curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  226)
* Underflow (decimal のクラス):          シグナル.           (line   97)
* undisplay (pdb command):               デバッガコマンド.   (line  340)
* undo() (turtle モジュール):            Turtle の動き.      (line  314)
* undobufferentries() (turtle モジュール): 特別な Turtle のメソッド.
                                                             (line   74)
* undoc_header (cmd.Cmd の属性):         Cmdオブジェクト.    (line  164)
* unescape() (html モジュール):          html --- HyperText Markup Language のサポート.
                                                             (line   22)
* unescape() (xml.sax.saxutils モジュール): xml sax saxutils --- SAX ユーティリティー.
                                                             (line   27)
* UnexpectedException:                   デバッグ.           (line  203)
* unexpectedSuccesses (unittest.TestResult の属性): テストのロードと起動.
                                                             (line  268)
* unfreeze() (gc モジュール):            gc --- ガベージコレクターインターフェース.
                                                             (line  215)
* unget_wch() (curses モジュール):       関数<6>.            (line  559)
* ungetch() (curses モジュール):         関数<6>.            (line  544)
* ungetch() (msvcrt モジュール):         コンソール I/O 関連.
                                                             (line   44)
* ungetmouse() (curses モジュール):      関数<6>.            (line  569)
* ungetwch() (msvcrt モジュール):        コンソール I/O 関連.
                                                             (line   50)
* unhexlify() (binascii モジュール):     binascii --- バイナリ と ASCII 間の変換.
                                                             (line  144)
* UNICODE (re モジュール):               フラグ.             (line  112)
* Unicode コンソーシアム:                文字列およびバイト列リテラル.
                                                             (line   36)
* Unicode 文字列型:                      変更不能なシーケンス immutable sequence.
                                                             (line   16)
* Unicode 文字列型 <1>:                  unicodedata --- Unicode データベース.
                                                             (line    6)
* Unicode 文字列型 <2>:                  codecs --- codec レジストリと基底クラス.
                                                             (line    8)
* Unicode 文字列型;データベース:         unicodedata --- Unicode データベース.
                                                             (line    6)
* UnicodeDecodeError:                    具象例外.           (line  439)
* UnicodeEncodeError:                    具象例外.           (line  434)
* UnicodeError:                          具象例外.           (line  404)
* UnicodeTranslateError:                 具象例外.           (line  444)
* UnicodeWarning:                        警告.               (line   63)
* unidata_version (unicodedata モジュール): unicodedata --- Unicode データベース.
                                                             (line  120)
* unified_diff() (difflib モジュール):   difflib --- 差分の計算の補助.
                                                             (line  287)
* uniform() (random モジュール):         実数分布.           (line   14)
* UnimplementedFileMode:                 http client --- HTTP プロトコルクライアント.
                                                             (line  159)
* Union (ctypes のクラス):               構造化データ型.     (line    6)
* Union (typing モジュール):             特殊形式.           (line    9)
* union;type:                            Union 型.           (line    6)
* union() (frozenset のメソッド):        set（集合）型 --- set frozenset.
                                                             (line   95)
* UnionType (types のクラス):            標準的なインタプリタ型.
                                                             (line  179)
* UNIQUE (enum.EnumCheck の属性):        データ型<2>.        (line  584)
* unique() (enum モジュール):            ユーティリティとデコレータ.
                                                             (line   54)
* unittest コマンドラインオプション; -b: コマンドラインオプション<5>.
                                                             (line    8)
* unittest コマンドラインオプション; -buffer: コマンドラインオプション<5>.
                                                             (line    8)
* unittest コマンドラインオプション; -c: コマンドラインオプション<5>.
                                                             (line   15)
* unittest コマンドラインオプション; -catch: コマンドラインオプション<5>.
                                                             (line   15)
* unittest コマンドラインオプション; -durations: コマンドラインオプション<5>.
                                                             (line   49)
* unittest コマンドラインオプション; -f: コマンドラインオプション<5>.
                                                             (line   24)
* unittest コマンドラインオプション; -failfast: コマンドラインオプション<5>.
                                                             (line   24)
* unittest コマンドラインオプション; -k: コマンドラインオプション<5>.
                                                             (line   28)
* unittest コマンドラインオプション; -locals: コマンドラインオプション<5>.
                                                             (line   45)
* unittest-discover コマンドラインオプション; -p: テストディスカバリ.
                                                             (line   34)
* unittest-discover コマンドラインオプション; -pattern: テストディスカバリ.
                                                             (line   34)
* unittest-discover コマンドラインオプション; -s: テストディスカバリ.
                                                             (line   30)
* unittest-discover コマンドラインオプション; -start-directory: テストディスカバリ.
                                                             (line   30)
* unittest-discover コマンドラインオプション; -t: テストディスカバリ.
                                                             (line   38)
* unittest-discover コマンドラインオプション; -top-level-directory: テストディスカバリ.
                                                             (line   38)
* unittest-discover コマンドラインオプション; -v: テストディスカバリ.
                                                             (line   26)
* unittest-discover コマンドラインオプション; -verbose: テストディスカバリ.
                                                             (line   26)
* universal newlines:                    用語集<2>.          (line 1457)
* universal newlines;bytearray.splitlines メソッド: bytes と bytearray の操作.
                                                             (line  646)
* universal newlines;bytes.splitlines メソッド: bytes と bytearray の操作.
                                                             (line  646)
* universal newlines;csv.reader 関数:    モジュールコンテンツ<3>.
                                                             (line    8)
* universal newlines;importlib.abc.InspectLoader.get_source メソッド: importlib abc -- インポートに関連する抽象基底クラス.
                                                             (line  215)
* universal newlines;io.IncrementalNewlineDecoder class: テキスト I/O<2>.
                                                             (line  281)
* universal newlines;io.TextIOWrapper class: テキスト I/O<2>.
                                                             (line  122)
* universal newlines;open() built-in function: 組み込み関数. (line 1395)
* universal newlines;str.splitlines メソッド: 文字列メソッド<2>.
                                                             (line  487)
* universal newlines;subprocess モジュール: よく使われる引数.
                                                             (line   32)
* universal newlines;What's new:         PEP 3116 新しい I/O ライブラリ.
                                                             (line   42)
* universal newlines;What's new <1>:     新たなモジュール、改良されたモジュール、削除されたモジュール.
                                                             (line  135)
* universal newlines;What's new <2>:     PEP 324 新しい subprocess モジュール.
                                                             (line   36)
* universal newlines;What's new <3>:     PEP 277 Windows NT での Unicode ファイル名サポート.
                                                             (line   38)
* UNIX:                                  完全な Python プログラム.
                                                             (line   24)
* unix_dialect (csv のクラス):           モジュールコンテンツ<3>.
                                                             (line  213)
* unix_shell (test.support モジュール):  test support --- テストのためのユーティリティ関数.
                                                             (line   44)
* UNIX;file control:                     fcntl --- fcntl および ioctl システムコール.
                                                             (line    6)
* UNIX;I/O control:                      fcntl --- fcntl および ioctl システムコール.
                                                             (line    6)
* UnixDatagramServer (socketserver のクラス): socketserver --- ネットワークサーバーのフレームワーク.
                                                             (line   37)
* UnixStreamServer (socketserver のクラス): socketserver --- ネットワークサーバーのフレームワーク.
                                                             (line   37)
* unknown (uuid.SafeUUID の属性):        uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   43)
* unknown_decl() (html.parser.HTMLParser のメソッド): HTMLParser メソッド.
                                                             (line  131)
* unknown_open() (urllib.request.BaseHandler のメソッド): BaseHandler オブジェクト.
                                                             (line   57)
* unknown_open() (urllib.request.UnknownHandler のメソッド): UnknownHandler オブジェクト.
                                                             (line    6)
* UnknownHandler (urllib.request のクラス): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  437)
* UnknownProtocol:                       http client --- HTTP プロトコルクライアント.
                                                             (line  151)
* UnknownTransferEncoding:               http client --- HTTP プロトコルクライアント.
                                                             (line  155)
* unlink() (multiprocessing.shared_memory.SharedMemory のメソッド): multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ.
                                                             (line  102)
* unlink() (os モジュール):              ファイルとディレクトリ.
                                                             (line 1611)
* unlink() (pathlib.Path のメソッド):    リネームと削除.     (line   48)
* unlink() (test.support.os_helper モジュール): test support os_helper --- Utilities for os tests.
                                                             (line  162)
* unlink() (xml.dom.minidom.Node のメソッド): DOM オブジェクト.
                                                             (line   10)
* unload() (test.support.import_helper モジュール): test support import_helper --- Utilities for import tests.
                                                             (line   76)
* unlock() (mailbox.Babyl のメソッド):   Babyl オブジェクト. (line   56)
* unlock() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  260)
* unlock() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  206)
* unlock() (mailbox.mbox のメソッド):    mbox オブジェクト.  (line   39)
* unlock() (mailbox.MH のメソッド):      MH オブジェクト.    (line   89)
* unlock() (mailbox.MMDF のメソッド):    MMDF オブジェクト.  (line   35)
* unlockpt() (os モジュール):            ファイル記述子の操作.
                                                             (line  904)
* UNNAMED_SECTION (configparser モジュール): ConfigParser オブジェクト.
                                                             (line  329)
* Unpack (typing モジュール):            特殊形式.           (line  555)
* unpack_archive() (shutil モジュール):  アーカイブ化操作.   (line  133)
* UNPACK_EX (opcode):                    Python バイトコード命令.
                                                             (line  574)
* unpack_from() (struct モジュール):     関数と例外.         (line   33)
* unpack_from() (struct.Struct のメソッド): クラス<3>.       (line   41)
* UNPACK_SEQUENCE (opcode):              Python バイトコード命令.
                                                             (line  565)
* unpack() (struct モジュール):          関数と例外.         (line   25)
* unpack() (struct.Struct のメソッド):   クラス<3>.          (line   35)
* unpacking;dictionary:                  辞書表示.           (line   23)
* unpacking;関数呼び出しの中の:          呼び出し call.      (line   71)
* unparse() (ast モジュール):            ast ヘルパー.       (line   68)
* unparsedEntityDecl() (xml.sax.handler.DTDHandler のメソッド): DTDHandler オブジェクト.
                                                             (line   12)
* UnparsedEntityDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  280)
* Unpickler (pickle のクラス):           モジュールインターフェース.
                                                             (line  232)
* UnpicklingError:                       モジュールインターフェース.
                                                             (line  107)
* unquote_plus() (urllib.parse モジュール): URL のクオート.  (line   80)
* unquote_to_bytes() (urllib.parse モジュール): URL のクオート.
                                                             (line   90)
* unquote() (email.utils モジュール):    email utils Miscellaneous utilities.
                                                             (line   51)
* unquote() (urllib.parse モジュール):   URL のクオート.     (line   60)
* unraisablehook() (sys モジュール):     sys --- システム固有のパラメーターと関数.
                                                             (line 1918)
* unregister_archive_format() (shutil モジュール): アーカイブ化操作.
                                                             (line  128)
* unregister_dialect() (csv モジュール): モジュールコンテンツ<3>.
                                                             (line   79)
* unregister_unpack_format() (shutil モジュール): アーカイブ化操作.
                                                             (line  194)
* unregister() (atexit モジュール):      atexit --- 終了ハンドラー.
                                                             (line   55)
* unregister() (codecs モジュール):      codecs --- codec レジストリと基底クラス.
                                                             (line  164)
* unregister() (faulthandler モジュール): ユーザシグナルに対してtracebackをダンプする.
                                                             (line   23)
* unregister() (select.devpoll のメソッド): /dev/poll ポーリングオブジェクト.
                                                             (line   54)
* unregister() (select.epoll のメソッド): エッジおよびレベルトリガポーリング epoll オブジェクト.
                                                             (line   90)
* unregister() (select.poll のメソッド): ポーリングオブジェクト.
                                                             (line   67)
* unregister() (selectors.BaseSelector のメソッド): クラス<4>.
                                                             (line   82)
* unsafe (uuid.SafeUUID の属性):         uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   38)
* unselect() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト. (line  384)
* unset() (test.support.os_helper.EnvironmentVarGuard のメソッド): test support os_helper --- Utilities for os tests.
                                                             (line   69)
* unsetenv() (os モジュール):            プロセスのパラメーター.
                                                             (line  581)
* unshare() (os モジュール):             プロセスのパラメーター.
                                                             (line  599)
* UnstructuredHeader (email.headerregistry のクラス): email headerregistry Custom Header Objects.
                                                             (line  113)
* unsubscribe() (imaplib.IMAP4 のメソッド): IMAP4 オブジェクト.
                                                             (line  380)
* UnsupportedOperation:                  例外<6>.            (line    6)
* UnsupportedOperation <1>:              高水準のモジュールインターフェイス.
                                                             (line   72)
* until (pdb command):                   デバッガコマンド.   (line  208)
* untokenize() (tokenize モジュール):    入力のトークナイズ. (line   55)
* untouchwin() (curses.window のメソッド): Window オブジェクト.
                                                             (line  564)
* unused_data (bz2.BZ2Decompressor の属性): 逐次圧縮および展開.
                                                             (line   78)
* unused_data (lzma.LZMADecompressor の属性): メモリ上での圧縮と展開.
                                                             (line  158)
* unused_data (zlib.Decompress の属性):  zlib --- gzip 互換の圧縮.
                                                             (line  232)
* unverifiable (urllib.request.Request の属性): Request オブジェクト.
                                                             (line   48)
* unwrap() (inspect モジュール):         クラスと関数<2>.    (line  136)
* unwrap() (ssl.SSLSocket のメソッド):   SSL ソケット.       (line  289)
* unwrap() (urllib.parse モジュール):    URL の解析.         (line  395)
* up (pdb command):                      デバッガコマンド.   (line   89)
* up() (turtle モジュール):              描画状態.           (line   12)
* update_abstractmethods() (abc モジュール): abc --- 抽象基底クラス.
                                                             (line  335)
* update_authenticated() (urllib.request.HTTPPasswordMgrWithPriorAuth のメソッド): HTTPPasswordMgrWithPriorAuth オブジェクト.
                                                             (line   26)
* update_lines_cols() (curses モジュール): 関数<6>.          (line  552)
* update_panels() (curses.panel モジュール): 関数<7>.        (line   23)
* update_visible() (mailbox.BabylMessage のメソッド): BabylMessage オブジェクト.
                                                             (line   77)
* update_wrapper() (functools モジュール): functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  646)
* update() (collections.Counter のメソッド): Counter オブジェクト.
                                                             (line  118)
* update() (dict のメソッド):            マッピング型 --- dict.
                                                             (line  206)
* update() (frozenset のメソッド):       set（集合）型 --- set frozenset.
                                                             (line  167)
* update() (hashlib.hash のメソッド):    Hash Objects.       (line   30)
* update() (hmac.HMAC のメソッド):       hmac --- メッセージ認証のための鍵付きハッシュ化.
                                                             (line   47)
* update() (http.cookies.Morsel のメソッド): Morselオブジェクト.
                                                             (line   85)
* update() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  230)
* update() (mailbox.Maildir のメソッド): Maildir オブジェクト.
                                                             (line  191)
* update() (trace.CoverageResults のメソッド): プログラミングインターフェース.
                                                             (line   51)
* update() (turtle モジュール):          アニメーションの制御.
                                                             (line   45)
* upgrade_dependencies() (venv.EnvBuilder のメソッド): API<2>.
                                                             (line  161)
* upper() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  738)
* upper() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  738)
* upper() (str のメソッド):              文字列メソッド<2>.  (line  643)
* urandom() (os モジュール):             乱数<2>.            (line   29)
* URL:                                   urllib parse --- URL を構成要素に解析する.
                                                             (line    8)
* URL <1>:                               urllib robotparser --- robots txt 用のパーサー.
                                                             (line    8)
* URL <2>:                               http server --- HTTP サーバー.
                                                             (line    8)
* url (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   52)
* url (urllib.error.HTTPError の属性):   urllib error --- urllib request によって送出される例外クラス.
                                                             (line   38)
* url (urllib.response.addinfourl の属性): urllib response --- urllib で使用するレスポンスクラス.
                                                             (line   14)
* url (xmlrpc.client.ProtocolError の属性): ProtocolError オブジェクト.
                                                             (line   12)
* URL;parsing:                           urllib parse --- URL を構成要素に解析する.
                                                             (line    8)
* url2pathname() (urllib.request モジュール): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  152)
* urlcleanup() (urllib.request モジュール): レガシーインターフェース.
                                                             (line   62)
* urldefrag() (urllib.parse モジュール): URL の解析.         (line  368)
* urlencode() (urllib.parse モジュール): URL のクオート.     (line  103)
* URLError:                              urllib error --- urllib request によって送出される例外クラス.
                                                             (line   15)
* urljoin() (urllib.parse モジュール):   URL の解析.         (line  339)
* urlopen() (urllib.request モジュール): urllib request --- URL を開くための大規模なライブラリ.
                                                             (line   33)
* URLopener (urllib.request のクラス):   レガシーインターフェース.
                                                             (line   67)
* urlparse() (urllib.parse モジュール):  URL の解析.         (line    9)
* urlretrieve() (urllib.request モジュール): レガシーインターフェース.
                                                             (line   10)
* urlsafe_b64decode() (base64 モジュール): base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  100)
* urlsafe_b64encode() (base64 モジュール): base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line   93)
* urlsplit() (urllib.parse モジュール):  URL の解析.         (line  249)
* urlunparse() (urllib.parse モジュール): URL の解析.        (line  241)
* urlunsplit() (urllib.parse モジュール): URL の解析.        (line  330)
* urn (uuid.UUID の属性):                uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  135)
* US (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line  117)
* use_default_colors() (curses モジュール): 関数<6>.         (line  584)
* use_env() (curses モジュール):         関数<6>.            (line  574)
* use_rawinput (cmd.Cmd の属性):         Cmdオブジェクト.    (line  176)
* USE_STACKCHECK (C macro):              オペレーティングシステム関連のユーティリティ.
                                                             (line   91)
* use_tool_id() (sys.monitoring モジュール): Registering and using tools.
                                                             (line    6)
* UseForeignDTD() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line   61)
* USER:                                  getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   42)
* USER_BASE (site モジュール):           モジュールの内容<5>.
                                                             (line   32)
* user_call() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  271)
* user_exception() (bdb.Bdb のメソッド): bdb --- デバッガーフレームワーク.
                                                             (line  290)
* user_line() (bdb.Bdb のメソッド):      bdb --- デバッガーフレームワーク.
                                                             (line  279)
* user_return() (bdb.Bdb のメソッド):    bdb --- デバッガーフレームワーク.
                                                             (line  285)
* USER_SITE (site モジュール):           モジュールの内容<5>.
                                                             (line   20)
* user() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line   30)
* usercustomize:                         カスタマイズ用モジュール.
                                                             (line    7)
* usercustomize <1>:                     カスタマイズ用モジュール.
                                                             (line   21)
* UserDict (collections のクラス):       UserDict オブジェクト.
                                                             (line   11)
* UserList (collections のクラス):       UserList オブジェクト.
                                                             (line   15)
* USERNAME:                              os path --- 一般的なパス名操作.
                                                             (line  149)
* USERNAME <1>:                          プロセスのパラメーター.
                                                             (line  235)
* USERNAME <2>:                          getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   42)
* username (email.headerregistry.Address の属性): email headerregistry Custom Header Objects.
                                                             (line  426)
* USERPROFILE:                           os path<4>.         (line   14)
* USERPROFILE <1>:                       Python API の変更<3>.
                                                             (line  116)
* USERPROFILE <2>:                       Windows<38>.        (line   15)
* USERPROFILE <3>:                       os path --- 一般的なパス名操作.
                                                             (line  146)
* userptr() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   57)
* UserString (collections のクラス):     UserString オブジェクト.
                                                             (line   11)
* UserWarning:                           警告.               (line   13)
* USTAR_FORMAT (tarfile モジュール):     tarfile --- tar アーカイブファイルの読み書き.
                                                             (line  325)
* USub (ast のクラス):                   式 expression<2>.   (line   28)
* UTC:                                   time --- 時刻データへのアクセスと変換.
                                                             (line   39)
* UTC (datetime モジュール):             定数.               (line   18)
* utc (datetime.timezone の属性):        timezone オブジェクト.
                                                             (line   69)
* utcfromtimestamp() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line  133)
* utcnow() (datetime.datetime のクラスメソッド): datetime オブジェクト.
                                                             (line   81)
* utcoffset() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  529)
* utcoffset() (datetime.time のメソッド): time オブジェクト. (line  231)
* utcoffset() (datetime.timezone のメソッド): timezone オブジェクト.
                                                             (line   31)
* utcoffset() (datetime.tzinfo のメソッド): tzinfo オブジェクト.
                                                             (line   38)
* utctimetuple() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  574)
* utf8 (email.policy.EmailPolicy の属性): email policy Policy Objects.
                                                             (line  378)
* utf8_enabled (imaplib.IMAP4 の属性):   IMAP4 オブジェクト. (line  411)
* utf8_mode (sys.flags の属性):          sys --- システム固有のパラメーターと関数.
                                                             (line  555)
* utf8() (poplib.POP3 のメソッド):       POP3 オブジェクト.  (line  106)
* utime() (os モジュール):               ファイルとディレクトリ.
                                                             (line 1625)
* UUID (uuid のクラス):                  uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line   48)
* uuid コマンドラインオプション; -h:     コマンドラインからの使用<2>.
                                                             (line   15)
* uuid コマンドラインオプション; -help:  コマンドラインからの使用<2>.
                                                             (line   15)
* uuid コマンドラインオプション; -n:     コマンドラインからの使用<2>.
                                                             (line   25)
* uuid コマンドラインオプション; -N:     コマンドラインからの使用<2>.
                                                             (line   33)
* uuid コマンドラインオプション; -name:  コマンドラインからの使用<2>.
                                                             (line   33)
* uuid コマンドラインオプション; -namespace: コマンドラインからの使用<2>.
                                                             (line   25)
* uuid コマンドラインオプション; -u:     コマンドラインからの使用<2>.
                                                             (line   19)
* uuid コマンドラインオプション; -uuid:  コマンドラインからの使用<2>.
                                                             (line   19)
* uuid1:                                 uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  184)
* uuid1() (uuid モジュール):             uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  176)
* uuid3:                                 uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  190)
* uuid3() (uuid モジュール):             uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  184)
* uuid4:                                 uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  194)
* uuid4() (uuid モジュール):             uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  190)
* uuid5:                                 uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  200)
* uuid5() (uuid モジュール):             uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  194)
* v4_int_to_packed() (ipaddress モジュール): その他のモジュールレベル関数.
                                                             (line    8)
* v6_int_to_packed() (ipaddress モジュール): その他のモジュールレベル関数.
                                                             (line   20)
* valid_signals() (signal モジュール):   モジュールの内容<2>.
                                                             (line  302)
* validator() (wsgiref.validate モジュール): wsgiref validate --- WSGI 準拠チェッカー.
                                                             (line   21)
* value:                                 辞書表示.           (line    6)
* value (ctypes._SimpleCData の属性):    基本データ型<2>.    (line   17)
* value (enum.Enum の属性):              データ型<2>.        (line  142)
* value (http.cookiejar.Cookie の属性):  Cookieオブジェクト<2>.
                                                             (line   31)
* value (http.cookies.Morsel の属性):    Morselオブジェクト. (line   45)
* value (StopIteration の属性):          具象例外.           (line  250)
* value (xml.dom.Attr の属性):           Attr オブジェクト.  (line   23)
* value_decode() (http.cookies.BaseCookie のメソッド): Cookieオブジェクト.
                                                             (line    6)
* value_encode() (http.cookies.BaseCookie のメソッド): Cookieオブジェクト.
                                                             (line   13)
* Value() (multiprocessing モジュール):  共有 ctypes オブジェクト.
                                                             (line    9)
* Value() (multiprocessing.managers.SyncManager のメソッド): マネージャー.
                                                             (line  219)
* Value() (multiprocessing.sharedctypes モジュール): multiprocessing sharedctypes モジュール.
                                                             (line   67)
* ValueError:                            具象例外.           (line  449)
* valuerefs() (weakref.WeakValueDictionary のメソッド): weakref --- 弱参照.
                                                             (line  217)
* Values (optparse のクラス):            オプションの定義.   (line   88)
* values() (contextvars.Context のメソッド): マニュアルでのコンテキスト管理.
                                                             (line  137)
* values() (dict のメソッド):            マッピング型 --- dict.
                                                             (line  219)
* values() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  237)
* values() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  345)
* values() (mailbox.Mailbox のメソッド): Mailbox オブジェクト.
                                                             (line  127)
* values() (types.MappingProxyType のメソッド): 標準的なインタプリタ型.
                                                             (line  276)
* ValuesView (collections.abc のクラス): コレクションの抽象基底クラス -- 詳細な説明.
                                                             (line  104)
* ValuesView (typing のクラス):          Aliases to container ABCs in collections abc.
                                                             (line  106)
* var (contextvars.Token の属性):        コンテキスト変数.   (line   80)
* variable annotation:                   用語集<2>.          (line 1464)
* variance (statistics.NormalDist の属性): NormalDist オブジェクト.
                                                             (line   40)
* variance() (statistics モジュール):    関数の詳細.         (line  430)
* variant (uuid.UUID の属性):            uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  139)
* vbar (tkinter.scrolledtext.ScrolledText の属性): tkinter scrolledtext --- スクロール可能なテキストウィジェット.
                                                             (line   29)
* VBAR (token モジュール):               token --- Python 解析木で使われる定数.
                                                             (line   95)
* VBAREQUAL (token モジュール):          token --- Python 解析木で使われる定数.
                                                             (line  191)
* VC_ASSEMBLY_PUBLICKEYTOKEN (msvcrt モジュール): その多の関数.
                                                             (line   93)
* Vec2D (turtle のクラス):               Public classes.     (line   87)
* vectorcallfunc (C type):               The Vectorcall Protocol.
                                                             (line   41)
* VERBOSE (re モジュール):               フラグ.             (line  122)
* verbose (sys.flags の属性):            sys --- システム固有のパラメーターと関数.
                                                             (line  539)
* verbose (tabnanny モジュール):         tabnanny --- あいまいなインデントの検出.
                                                             (line   26)
* verbose (test.support モジュール):     test support --- テストのためのユーティリティ関数.
                                                             (line   30)
* VERIFY_ALLOW_PROXY_CERTS (ssl モジュール): 定数<9>.        (line   99)
* verify_client_post_handshake() (ssl.SSLSocket のメソッド): SSL ソケット.
                                                             (line  297)
* verify_code (ssl.SSLCertVerificationError の属性): 例外<15>.
                                                             (line   84)
* VERIFY_CRL_CHECK_CHAIN (ssl モジュール): 定数<9>.          (line   84)
* VERIFY_CRL_CHECK_LEAF (ssl モジュール): 定数<9>.           (line   74)
* VERIFY_DEFAULT (ssl モジュール):       定数<9>.            (line   66)
* verify_flags (ssl.SSLContext の属性):  SSL コンテキスト.   (line  631)
* verify_generated_headers (email.policy.Policy の属性): email policy Policy Objects.
                                                             (line  202)
* verify_message (ssl.SSLCertVerificationError の属性): 例外<15>.
                                                             (line   88)
* verify_mode (ssl.SSLContext の属性):   SSL コンテキスト.   (line  646)
* verify_request() (socketserver.BaseServer のメソッド): Serverオブジェクト<2>.
                                                             (line  170)
* VERIFY_X509_PARTIAL_CHAIN (ssl モジュール): 定数<9>.       (line  114)
* VERIFY_X509_STRICT (ssl モジュール):   定数<9>.            (line   92)
* VERIFY_X509_TRUSTED_FIRST (ssl モジュール): 定数<9>.       (line  106)
* verify() (enum モジュール):            ユーティリティとデコレータ.
                                                             (line   72)
* verify() (smtplib.SMTP のメソッド):    SMTP オブジェクト.  (line   88)
* VerifyFlags (ssl のクラス):            定数<9>.            (line  125)
* VerifyMode (ssl のクラス):             定数<9>.            (line   60)
* version (curses モジュール):           定数<6>.            (line   18)
* version (email.headerregistry.MIMEVersionHeader の属性): email headerregistry Custom Header Objects.
                                                             (line  237)
* version (http.client.HTTPResponse の属性): HTTPResponse オブジェクト.
                                                             (line   47)
* version (http.cookiejar.Cookie の属性): Cookieオブジェクト<2>.
                                                             (line   19)
* version (http.cookies.Morsel の属性):  Morselオブジェクト. (line   13)
* version (in module sys):               プロセスワイドのパラメータ.
                                                             (line  162)
* version (in module sys) <1>:           プロセスワイドのパラメータ.
                                                             (line  199)
* version (in module sys) <2>:           プロセスワイドのパラメータ.
                                                             (line  210)
* version (ipaddress.IPv4Address の属性): Address オブジェクト.
                                                             (line   44)
* version (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line   60)
* version (ipaddress.IPv6Address の属性): Address オブジェクト.
                                                             (line  256)
* version (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  293)
* version (marshal モジュール):          marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line  129)
* version (sqlite3 モジュール):          モジュール定数.     (line  124)
* version (sys モジュール):              sys --- システム固有のパラメーターと関数.
                                                             (line 1966)
* version (sys.thread_info の属性):      sys --- システム固有のパラメーターと関数.
                                                             (line 1904)
* version (urllib.request.URLopener の属性): レガシーインターフェース.
                                                             (line  140)
* version (uuid.UUID の属性):            uuid --- RFC 4122 に従った UUID オブジェクト.
                                                             (line  145)
* version_info (sqlite3 モジュール):     モジュール定数.     (line  135)
* version_info (sys モジュール):         sys --- システム固有のパラメーターと関数.
                                                             (line 1979)
* version_string() (http.server.BaseHTTPRequestHandler のメソッド): http server --- HTTP サーバー.
                                                             (line  314)
* version() (ensurepip モジュール):      モジュール API.     (line    9)
* version() (importlib.metadata モジュール): 配布物バージョン.
                                                             (line    6)
* version() (platform モジュール):       クロスプラットフォーム.
                                                             (line  134)
* version() (ssl.SSLSocket のメソッド):  SSL ソケット.       (line  319)
* vformat() (string.Formatter のメソッド): カスタムの文字列書式化.
                                                             (line   26)
* virtual environment:                   用語集<2>.          (line 1488)
* virtual machine:                       用語集<2>.          (line 1497)
* visit_Constant() (ast.NodeVisitor のメソッド): ast ヘルパー.
                                                             (line  211)
* visit() (ast.NodeVisitor のメソッド):  ast ヘルパー.       (line  194)
* visitproc (C type):                    循環参照ガベージコレクションをサポートする.
                                                             (line  154)
* vline() (curses.window のメソッド):    Window オブジェクト.
                                                             (line  569)
* voidcmd() (ftplib.FTP のメソッド):     FTP オブジェクト.   (line  164)
* volume (zipfile.ZipInfo の属性):       ZipInfo オブジェクト.
                                                             (line  120)
* vonmisesvariate() (random モジュール): 実数分布.           (line   85)
* VT (curses.ascii モジュール):          curses ascii --- ASCII 文字のユーティリティー.
                                                             (line   57)
* W_OK (os モジュール):                  ファイルとディレクトリ.
                                                             (line  109)
* wait_closed() (asyncio.Server のメソッド): Serverオブジェクト.
                                                             (line  125)
* wait_closed() (asyncio.StreamWriter のメソッド): StreamWriter.
                                                             (line  117)
* wait_for() (asyncio モジュール):       タイムアウト.       (line  118)
* wait_for() (asyncio.Condition のメソッド): Condition.      (line  104)
* wait_for() (threading.Condition のメソッド): Condition オブジェクト.
                                                             (line  127)
* wait_process() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  423)
* wait_threads_exit() (test.support.threading_helper モジュール): test support threading_helper --- Utilities for threading tests.
                                                             (line   41)
* wait_until_any_call_with() (unittest.mock.ThreadingMock のメソッド): Mock クラス.
                                                             (line  956)
* wait_until_called() (unittest.mock.ThreadingMock のメソッド): Mock クラス.
                                                             (line  941)
* wait() (asyncio モジュール):           要素の終了待機.     (line    6)
* wait() (asyncio.Barrier のメソッド):   Barrier.            (line   53)
* wait() (asyncio.Condition のメソッド): Condition.          (line   86)
* wait() (asyncio.Event のメソッド):     Event.              (line   44)
* wait() (asyncio.subprocess.Process のメソッド): サブプロセスとやりとりする.
                                                             (line   36)
* wait() (concurrent.futures モジュール): モジュール関数<2>. (line    6)
* wait() (multiprocessing.connection モジュール): リスナーとクライアント.
                                                             (line  115)
* wait() (multiprocessing.pool.AsyncResult のメソッド): プロセスプール.
                                                             (line  210)
* wait() (os モジュール):                プロセス管理.       (line  824)
* wait() (subprocess.Popen のメソッド):  Popen オブジェクト. (line   14)
* wait() (threading.Barrier のメソッド): バリアオブジェクト. (line   42)
* wait() (threading.Condition のメソッド): Condition オブジェクト.
                                                             (line   96)
* wait() (threading.Event のメソッド):   Event オブジェクト. (line   45)
* wait3() (os モジュール):               プロセス管理.       (line  932)
* wait4() (os モジュール):               プロセス管理.       (line  946)
* waitid() (os モジュール):              プロセス管理.       (line  848)
* waitpid() (os モジュール):             プロセス管理.       (line  887)
* waitstatus_to_exitcode() (os モジュール): プロセス管理.    (line 1062)
* walk_packages() (pkgutil モジュール):  pkgutil --- パッケージ拡張ユーティリティ.
                                                             (line  148)
* walk_stack() (traceback モジュール):   モジュールレベルの関数<2>.
                                                             (line  175)
* walk_tb() (traceback モジュール):      モジュールレベルの関数<2>.
                                                             (line  184)
* walk() (ast モジュール):               ast ヘルパー.       (line  179)
* walk() (email.message.EmailMessage のメソッド): email message Representing an email message.
                                                             (line  467)
* walk() (email.message.Message のメソッド): email message Message compat32 API を使用した電子メールメッセージの表現.
                                                             (line  641)
* walk() (os モジュール):                ファイルとディレクトリ.
                                                             (line 1670)
* walk() (pathlib.Path のメソッド):      ディレクトリを読む. (line  101)
* walrus operator:                       ブール演算 boolean operation.
                                                             (line   34)
* want (doctest.Example の属性):         Example オブジェクト.
                                                             (line   22)
* warn_default_encoding (sys.flags の属性): sys --- システム固有のパラメーターと関数.
                                                             (line  565)
* warn_explicit() (warnings モジュール): 利用可能な関数.     (line   61)
* warn() (warnings モジュール):          利用可能な関数.     (line    6)
* Warning:                               警告.               (line    9)
* Warning <1>:                           例外<7>.            (line    8)
* WARNING (logging モジュール):          ロギングレベル.     (line   33)
* WARNING (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  198)
* warning() (logging モジュール):        モジュールレベルの関数.
                                                             (line   69)
* warning() (logging.Logger のメソッド): ロガーオブジェクト. (line  283)
* warning() (xml.sax.handler.ErrorHandler のメソッド): ErrorHandler オブジェクト.
                                                             (line   29)
* warnings:                              warnings --- 警告の制御.
                                                             (line    8)
* WarningsRecorder (test.support.warnings_helper のクラス): test support warnings_helper --- Utilities for warnings tests.
                                                             (line  112)
* warnoptions (sys モジュール):          sys --- システム固有のパラメーターと関数.
                                                             (line 1992)
* wasSuccessful() (unittest.TestResult のメソッド): テストのロードと起動.
                                                             (line  313)
* WatchedFileHandler (logging.handlers のクラス): WatchedFileHandler.
                                                             (line   25)
* Wave_read (wave のクラス):             Wave_read オブジェクト.
                                                             (line    6)
* Wave_write (wave のクラス):            Wave_write オブジェクト.
                                                             (line    6)
* WCONTINUED (os モジュール):            プロセス管理.       (line  985)
* WCOREDUMP() (os モジュール):           プロセス管理.       (line 1103)
* WeakKeyDictionary (weakref のクラス):  weakref --- 弱参照. (line  158)
* WeakMethod (weakref のクラス):         weakref --- 弱参照. (line  226)
* WeakSet (weakref のクラス):            weakref --- 弱参照. (line  221)
* WeakValueDictionary (weakref のクラス): weakref --- 弱参照.
                                                             (line  205)
* WEDNESDAY (calendar モジュール):       calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  381)
* weekday (calendar.IllegalWeekdayError の属性): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  466)
* weekday() (calendar モジュール):       calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  310)
* weekday() (datetime.date のメソッド):  date オブジェクト.  (line  227)
* weekday() (datetime.datetime のメソッド): datetime オブジェクト.
                                                             (line  637)
* weekheader() (calendar モジュール):    calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  315)
* weibullvariate() (random モジュール):  実数分布.           (line   96)
* WEXITED (os モジュール):               プロセス管理.       (line  994)
* WEXITSTATUS() (os モジュール):         プロセス管理.       (line 1150)
* wfile (http.server.BaseHTTPRequestHandler の属性): http server --- HTTP サーバー.
                                                             (line  125)
* wfile (socketserver.DatagramRequestHandler の属性): Request Handler Objects.
                                                             (line   67)
* whatis (pdb command):                  デバッガコマンド.   (line  276)
* when() (asyncio.Timeout のメソッド):   タイムアウト.       (line   63)
* when() (asyncio.TimerHandle のメソッド): コールバックのハンドル.
                                                             (line   36)
* where (pdb command):                   デバッガコマンド.   (line   78)
* which() (shutil モジュール):           ディレクトリとファイルの操作.
                                                             (line  421)
* whichdb() (dbm モジュール):            dbm --- Unix "データベース" へのインターフェース.
                                                             (line   30)
* While (ast のクラス):                  制御フロー.         (line   77)
* whitespace (shlex.shlex の属性):       shlex オブジェクト. (line  103)
* whitespace (string モジュール):        文字列定数.         (line   46)
* whitespace_split (shlex.shlex の属性): shlex オブジェクト. (line  127)
* Widget (tkinter.ttk のクラス):         ttk Widget.         (line   10)
* width (sys.hash_info の属性):          sys --- システム固有のパラメーターと関数.
                                                             (line 1015)
* width (textwrap.TextWrapper の属性):   textwrap --- テキストの折り返しと詰め込み.
                                                             (line  160)
* width() (turtle モジュール):           描画状態.           (line   18)
* WIFCONTINUED() (os モジュール):        プロセス管理.       (line 1113)
* WIFEXITED() (os モジュール):           プロセス管理.       (line 1142)
* WIFSIGNALED() (os モジュール):         プロセス管理.       (line 1135)
* WIFSTOPPED() (os モジュール):          プロセス管理.       (line 1123)
* win32_edition() (platform モジュール): Windows プラットフォーム.
                                                             (line   22)
* win32_is_iot() (platform モジュール):  Windows プラットフォーム.
                                                             (line   31)
* win32_ver() (platform モジュール):     Windows プラットフォーム.
                                                             (line    6)
* WinDLL (ctypes のクラス):              共有ライブラリをロードする.
                                                             (line   52)
* window manager (widgets):              ウィンドウマネージャ.
                                                             (line    6)
* window_height() (turtle モジュール):   設定と特殊なメソッド.
                                                             (line  102)
* window_width() (turtle モジュール):    設定と特殊なメソッド.
                                                             (line  109)
* window() (curses.panel.Panel のメソッド): Panel オブジェクト.
                                                             (line   61)
* Windows:                               完全な Python プログラム.
                                                             (line   24)
* Windows ini ファイル:                  configparser --- 設定ファイルのパーサー.
                                                             (line    8)
* WindowsError:                          具象例外.           (line  467)
* WindowsPath (pathlib のクラス):        具象パス.           (line   35)
* WindowsProactorEventLoopPolicy (asyncio のクラス): ポリシーオブジェクト.
                                                             (line   79)
* WindowsRegistryFinder (importlib.machinery のクラス): importlib machinery -- インポータおよびパスフック.
                                                             (line   93)
* WindowsSelectorEventLoopPolicy (asyncio のクラス): ポリシーオブジェクト.
                                                             (line   72)
* winerror (OSError の属性):             具象例外.           (line  160)
* WinError() (ctypes モジュール):        ユーティリティー関数.
                                                             (line  199)
* WINFUNCTYPE() (ctypes モジュール):     関数プロトタイプ.   (line   23)
* WinSock:                               select --- I/O 完了の待機.
                                                             (line  152)
* winver (sys モジュール):               sys --- システム固有のパラメーターと関数.
                                                             (line 1997)
* With (ast のクラス):                   制御フロー.         (line  231)
* WITH_EXCEPT_START (opcode):            Python バイトコード命令.
                                                             (line  479)
* with_hostmask (ipaddress.IPv4Interface の属性): インターフェイスオブジェクト.
                                                             (line   55)
* with_hostmask (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line  122)
* with_hostmask (ipaddress.IPv6Interface の属性): インターフェイスオブジェクト.
                                                             (line   82)
* with_hostmask (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  325)
* with_name() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  353)
* with_netmask (ipaddress.IPv4Interface の属性): インターフェイスオブジェクト.
                                                             (line   46)
* with_netmask (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line  117)
* with_netmask (ipaddress.IPv6Interface の属性): インターフェイスオブジェクト.
                                                             (line   80)
* with_netmask (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  323)
* with_prefixlen (ipaddress.IPv4Interface の属性): インターフェイスオブジェクト.
                                                             (line   37)
* with_prefixlen (ipaddress.IPv4Network の属性): Network オブジェクト.
                                                             (line  104)
* with_prefixlen (ipaddress.IPv6Interface の属性): インターフェイスオブジェクト.
                                                             (line   78)
* with_prefixlen (ipaddress.IPv6Network の属性): Network オブジェクト.
                                                             (line  317)
* with_pymalloc() (test.support モジュール): test support --- テストのためのユーティリティ関数.
                                                             (line  258)
* with_segments() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  410)
* with_stem() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  370)
* with_suffix() (pathlib.PurePath のメソッド): メソッドとプロパティ.
                                                             (line  394)
* with_traceback() (BaseException のメソッド): 基底クラス.   (line   23)
* withitem (ast のクラス):               制御フロー.         (line  242)
* WNOHANG (os モジュール):               プロセス管理.       (line 1028)
* WNOWAIT (os モジュール):               プロセス管理.       (line 1036)
* wordchars (shlex.shlex の属性):        shlex オブジェクト. (line   90)
* World Wide Web:                        インターネットプロトコルとサポート.
                                                             (line    6)
* World Wide Web <1>:                    urllib parse --- URL を構成要素に解析する.
                                                             (line    8)
* World Wide Web <2>:                    urllib robotparser --- robots txt 用のパーサー.
                                                             (line    8)
* wrap_bio() (ssl.SSLContext のメソッド): SSL コンテキスト.  (line  454)
* wrap_future() (asyncio モジュール):    Future の関数.      (line   52)
* wrap_socket() (ssl.SSLContext のメソッド): SSL コンテキスト.
                                                             (line  389)
* wrap() (textwrap モジュール):          textwrap --- テキストの折り返しと詰め込み.
                                                             (line   16)
* wrap() (textwrap.TextWrapper のメソッド): textwrap --- テキストの折り返しと詰め込み.
                                                             (line  278)
* wrapper() (curses モジュール):         関数<6>.            (line  593)
* WrapperDescriptorType (types モジュール): 標準的なインタプリタ型.
                                                             (line   87)
* wraps() (functools モジュール):        functools --- 高階関数と呼び出し可能オブジェクトの操作.
                                                             (line  692)
* WRITABLE (_tkinter モジュール):        ファイルハンドラ.   (line   42)
* WRITABLE (inspect.BufferFlags の属性): Buffer flags.       (line   17)
* writable() (bz2.BZ2File のメソッド):   ファイルの圧縮/解凍.
                                                             (line  104)
* writable() (io.IOBase のメソッド):     I/O 基底クラス.     (line  152)
* WRITE (inspect.BufferFlags の属性):    Buffer flags.       (line   51)
* write_byte() (mmap.mmap のメソッド):   mmap --- メモリマップファイルのサポート.
                                                             (line  338)
* write_bytes() (pathlib.Path のメソッド): ファイルを読み書きする<2>.
                                                             (line   66)
* write_docstringdict() (turtle モジュール): ドキュメント文字列の翻訳.
                                                             (line    9)
* write_eof() (asyncio.StreamWriter のメソッド): StreamWriter.
                                                             (line   54)
* write_eof() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line   77)
* write_eof() (ssl.MemoryBIO のメソッド): メモリ BIO サポート<2>.
                                                             (line  159)
* write_history_file() (readline モジュール): 履歴ファイル.  (line   14)
* WRITE_RESTRICTED (C macro):            Member flags.       (line   32)
* write_results() (trace.CoverageResults のメソッド): プログラミングインターフェース.
                                                             (line   56)
* write_text() (pathlib.Path のメソッド): ファイルを読み書きする<2>.
                                                             (line   47)
* write_through (io.TextIOWrapper の属性): テキスト I/O<2>.  (line  170)
* write() (asyncio.StreamWriter のメソッド): StreamWriter.   (line   15)
* write() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line   63)
* write() (code.InteractiveInterpreter のメソッド): 対話的なインタプリタオブジェクト.
                                                             (line   62)
* write() (codecs.StreamWriter のメソッド): StreamWriter オブジェクト.
                                                             (line   33)
* write() (configparser.ConfigParser のメソッド): ConfigParser オブジェクト.
                                                             (line  284)
* write() (email.generator.BytesGenerator のメソッド): email generator Generating MIME documents.
                                                             (line  117)
* write() (email.generator.Generator のメソッド): email generator Generating MIME documents.
                                                             (line  213)
* write() (io.BufferedIOBase のメソッド): I/O 基底クラス.    (line  326)
* write() (io.BufferedWriter のメソッド): バッファ付きストリーム.
                                                             (line  133)
* write() (io.RawIOBase のメソッド):     I/O 基底クラス.     (line  212)
* write() (io.TextIOBase のメソッド):    テキスト I/O<2>.    (line   91)
* write() (mmap.mmap のメソッド):        mmap --- メモリマップファイルのサポート.
                                                             (line  322)
* write() (os モジュール):               ファイル記述子の操作.
                                                             (line  916)
* write() (sqlite3.Blob のメソッド):     Blob オブジェクト.  (line   55)
* write() (ssl.MemoryBIO のメソッド):    メモリ BIO サポート<2>.
                                                             (line  150)
* write() (ssl.SSLSocket のメソッド):    SSL ソケット.       (line   97)
* write() (turtle モジュール):           さらなる描画の制御. (line   29)
* write() (xml.etree.ElementTree.ElementTree のメソッド): ElementTree オブジェクト.
                                                             (line   60)
* write() (zipfile.ZipFile のメソッド):  ZipFile オブジェクト.
                                                             (line  278)
* writeframes() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   83)
* writeframesraw() (wave.Wave_write のメソッド): Wave_write オブジェクト.
                                                             (line   76)
* writeheader() (csv.DictWriter のメソッド): writer オブジェクト.
                                                             (line   39)
* writelines() (asyncio.StreamWriter のメソッド): StreamWriter.
                                                             (line   26)
* writelines() (asyncio.WriteTransport のメソッド): 書き込み専用のトランスポート.
                                                             (line   70)
* writelines() (codecs.StreamWriter のメソッド): StreamWriter オブジェクト.
                                                             (line   37)
* writelines() (io.IOBase のメソッド):   I/O 基底クラス.     (line  158)
* writepy() (zipfile.PyZipFile のメソッド): PyZipFile オブジェクト.
                                                             (line   19)
* writer() (csv モジュール):             モジュールコンテンツ<3>.
                                                             (line   40)
* writerow() (csv.csvwriter のメソッド): writer オブジェクト.
                                                             (line   16)
* writerows() (csv.csvwriter のメソッド): writer オブジェクト.
                                                             (line   25)
* writestr() (zipfile.ZipFile のメソッド): ZipFile オブジェクト.
                                                             (line  315)
* WriteTransport (asyncio のクラス):     トランスポートのクラス階層構造.
                                                             (line   11)
* writev() (os モジュール):              ファイル記述子の操作.
                                                             (line  935)
* writexml() (xml.dom.minidom.Node のメソッド): DOM オブジェクト.
                                                             (line   28)
* writing;''values'':                    式文 expression statement.
                                                             (line   16)
* WrongDocumentErr:                      例外<19>.           (line   93)
* wsgi_file_wrapper (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  268)
* wsgi_multiprocess (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  154)
* wsgi_multithread (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  147)
* wsgi_run_once (wsgiref.handlers.BaseHandler の属性): wsgiref handlers -- サーバ／ゲートウェイのベースクラス.
                                                             (line  161)
* WSGIApplication (wsgiref.types モジュール): wsgiref types -- WSGI types for static type checking.
                                                             (line   20)
* WSGIEnvironment (wsgiref.types モジュール): wsgiref types -- WSGI types for static type checking.
                                                             (line   16)
* WSGIRequestHandler (wsgiref.simple_server のクラス): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   74)
* WSGIServer (wsgiref.simple_server のクラス): wsgiref simple_server -- シンプルな WSGI HTTP サーバ.
                                                             (line   44)
* wShowWindow (subprocess.STARTUPINFO の属性): Windows Popen ヘルパー.
                                                             (line   49)
* WSTOPPED (os モジュール):              プロセス管理.       (line 1006)
* WSTOPSIG() (os モジュール):            プロセス管理.       (line 1159)
* wstring_at() (ctypes モジュール):      ユーティリティー関数.
                                                             (line  210)
* WTERMSIG() (os モジュール):            プロセス管理.       (line 1168)
* WUNTRACED (os モジュール):             プロセス管理.       (line 1017)
* WWW:                                   インターネットプロトコルとサポート.
                                                             (line    6)
* WWW <1>:                               urllib parse --- URL を構成要素に解析する.
                                                             (line    8)
* WWW <2>:                               urllib robotparser --- robots txt 用のパーサー.
                                                             (line    8)
* WWW;サーバ:                            http server --- HTTP サーバー.
                                                             (line    8)
* X (re モジュール):                     フラグ.             (line  122)
* X_OK (os モジュール):                  ファイルとディレクトリ.
                                                             (line  109)
* X509 certificate:                      SSL コンテキスト.   (line  759)
* xatom() (imaplib.IMAP4 のメソッド):    IMAP4 オブジェクト. (line  394)
* XATTR_CREATE (os モジュール):          Linux 拡張属性.     (line   89)
* XATTR_REPLACE (os モジュール):         Linux 拡張属性.     (line   94)
* XATTR_SIZE_MAX (os モジュール):        Linux 拡張属性.     (line   84)
* xcor() (turtle モジュール):            Turtle の状態を知る.
                                                             (line   32)
* XHTML:                                 html parser --- HTML と XHTML のシンプルなパーサー.
                                                             (line    8)
* XHTML_NAMESPACE (xml.dom モジュール):  モジュールコンテンツ<4>.
                                                             (line   51)
* XML_ERROR_ABORTED (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  172)
* XML_ERROR_AMPLIFICATION_LIMIT_BREACH (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  207)
* XML_ERROR_ASYNC_ENTITY (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   27)
* XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   29)
* XML_ERROR_BAD_CHAR_REF (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   35)
* XML_ERROR_BINARY_ENTITY_REF (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   40)
* XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  129)
* XML_ERROR_DUPLICATE_ATTRIBUTE (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   45)
* XML_ERROR_ENTITY_DECLARED_IN_PE (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  121)
* XML_ERROR_EXTERNAL_ENTITY_HANDLING (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  111)
* XML_ERROR_FEATURE_REQUIRES_XML_DTD (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  123)
* XML_ERROR_FINISHED (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  176)
* XML_ERROR_INCOMPLETE_PE (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  146)
* XML_ERROR_INCORRECT_ENCODING (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   49)
* XML_ERROR_INVALID_ARGUMENT (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  199)
* XML_ERROR_INVALID_TOKEN (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   51)
* XML_ERROR_JUNK_AFTER_DOC_ELEMENT (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   56)
* XML_ERROR_MISPLACED_XML_PI (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   60)
* XML_ERROR_NO_BUFFER (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  203)
* XML_ERROR_NO_ELEMENTS (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   64)
* XML_ERROR_NO_MEMORY (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   69)
* XML_ERROR_NOT_STANDALONE (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  113)
* XML_ERROR_NOT_SUSPENDED (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  168)
* XML_ERROR_PARAM_ENTITY_REF (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   73)
* XML_ERROR_PARTIAL_CHAR (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   77)
* XML_ERROR_PUBLICID (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  158)
* XML_ERROR_RECURSIVE_ENTITY_REF (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   81)
* XML_ERROR_RESERVED_NAMESPACE_URI (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  194)
* XML_ERROR_RESERVED_PREFIX_XML (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  184)
* XML_ERROR_RESERVED_PREFIX_XMLNS (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  189)
* XML_ERROR_SUSPEND_PE (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  182)
* XML_ERROR_SUSPENDED (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  162)
* XML_ERROR_SYNTAX (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   86)
* XML_ERROR_TAG_MISMATCH (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   90)
* XML_ERROR_TEXT_DECL (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  154)
* XML_ERROR_UNBOUND_PREFIX (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  136)
* XML_ERROR_UNCLOSED_CDATA_SECTION (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  107)
* XML_ERROR_UNCLOSED_TOKEN (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   94)
* XML_ERROR_UNDECLARING_PREFIX (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  141)
* XML_ERROR_UNDEFINED_ENTITY (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line   99)
* XML_ERROR_UNEXPECTED_STATE (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  119)
* XML_ERROR_UNKNOWN_ENCODING (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  103)
* XML_ERROR_XML_DECL (xml.parsers.expat.errors モジュール): Expat エラー定数.
                                                             (line  150)
* XML_NAMESPACE (xml.dom モジュール):    モジュールコンテンツ<4>.
                                                             (line   41)
* XML() (xml.etree.ElementTree モジュール): 関数<9>.         (line  265)
* xmlcharrefreplace_errors() (codecs モジュール): エラーハンドラ.
                                                             (line  165)
* xmlcharrefreplace;error handler's name: エラーハンドラ.    (line   52)
* XmlDeclHandler() (xml.parsers.expat.xmlparser のメソッド): XMLParser オブジェクト<2>.
                                                             (line  208)
* XMLFilterBase (xml.sax.saxutils のクラス): xml sax saxutils --- SAX ユーティリティー.
                                                             (line   69)
* XMLGenerator (xml.sax.saxutils のクラス): xml sax saxutils --- SAX ユーティリティー.
                                                             (line   54)
* XMLID() (xml.etree.ElementTree モジュール): 関数<9>.       (line  274)
* XMLNS_NAMESPACE (xml.dom モジュール):  モジュールコンテンツ<4>.
                                                             (line   46)
* XMLParser (xml.etree.ElementTree のクラス): XMLParser オブジェクト.
                                                             (line    6)
* XMLParserType (xml.parsers.expat モジュール): xml parsers expat --- Expat を使用した高速な XML 解析.
                                                             (line   37)
* XMLPullParser (xml.etree.ElementTree のクラス): XMLPullParser オブジェクト.
                                                             (line    6)
* XMLReader (xml.sax.xmlreader のクラス): xml sax xmlreader --- XML パーサーのインターフェース.
                                                             (line   15)
* xor() (operator モジュール):           operator --- 関数形式の標準演算子.
                                                             (line  163)
* xview() (tkinter.ttk.Treeview のメソッド): ttk Treeview.   (line  317)
* ycor() (turtle モジュール):            Turtle の状態を知る.
                                                             (line   44)
* year (datetime.date の属性):           date オブジェクト.  (line  113)
* year (datetime.datetime の属性):       datetime オブジェクト.
                                                             (line  302)
* yeardatescalendar() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  101)
* yeardays2calendar() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  108)
* yeardayscalendar() (calendar.Calendar のメソッド): calendar --- 一般的なカレンダーに関係する機能群.
                                                             (line  115)
* YES (tkinter.messagebox モジュール):   tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  157)
* YESEXPR (locale モジュール):           locale --- 国際化サービス.
                                                             (line  262)
* YESNO (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  181)
* YESNOCANCEL (tkinter.messagebox モジュール): tkinter messagebox --- Tkinter メッセージプロンプト.
                                                             (line  186)
* Yield (ast のクラス):                  関数およびクラス定義.
                                                             (line  123)
* YIELD_VALUE (opcode):                  Python バイトコード命令.
                                                             (line  411)
* yield;expression:                      Yield 式.           (line    6)
* yield;yield from (in What's New):      PEP 3151 OS および IO 例外階層の手直し.
                                                             (line   85)
* yield;例:                              ジェネレータ-イテレータメソッド.
                                                             (line   79)
* YieldFrom (ast のクラス):              関数およびクラス定義.
                                                             (line  123)
* yiq_to_rgb() (colorsys モジュール):    colorsys --- 色体系間の変換.
                                                             (line   32)
* yview() (tkinter.ttk.Treeview のメソッド): ttk Treeview.   (line  322)
* z;文字列のフォーマットで:              書式指定ミニ言語仕様.
                                                             (line   86)
* z85decode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  244)
* z85encode() (base64 モジュール):       base64 --- Base16 Base32 Base64 Base85 データのエンコード.
                                                             (line  236)
* Zen of Python:                         用語集<2>.          (line 1503)
* ZeroDivisionError:                     具象例外.           (line  455)
* zfill() (bytearray のメソッド):        bytes と bytearray の操作.
                                                             (line  757)
* zfill() (bytes のメソッド):            bytes と bytearray の操作.
                                                             (line  757)
* zfill() (str のメソッド):              文字列メソッド<2>.  (line  654)
* ZIP_BZIP2 (zipfile モジュール):        zipfile --- ZIP アーカイブの処理.
                                                             (line   97)
* ZIP_DEFLATED (zipfile モジュール):     zipfile --- ZIP アーカイブの処理.
                                                             (line   92)
* zip_longest() (itertools モジュール):  Itertool関数.       (line  654)
* ZIP_LZMA (zipfile モジュール):         zipfile --- ZIP アーカイブの処理.
                                                             (line  104)
* ZIP_STORED (zipfile モジュール):       zipfile --- ZIP アーカイブの処理.
                                                             (line   87)
* zipapp コマンドラインオプション; -c:   コマンドラインインターフェイス<8>.
                                                             (line   46)
* zipapp コマンドラインオプション; -compress: コマンドラインインターフェイス<8>.
                                                             (line   46)
* zipapp コマンドラインオプション; -h:   コマンドラインインターフェイス<8>.
                                                             (line   62)
* zipapp コマンドラインオプション; -help: コマンドラインインターフェイス<8>.
                                                             (line   62)
* zipapp コマンドラインオプション; -info: コマンドラインインターフェイス<8>.
                                                             (line   56)
* zipapp コマンドラインオプション; -m:   コマンドラインインターフェイス<8>.
                                                             (line   35)
* zipapp コマンドラインオプション; -main: コマンドラインインターフェイス<8>.
                                                             (line   35)
* zipapp コマンドラインオプション; -o:   コマンドラインインターフェイス<8>.
                                                             (line   17)
* zipapp コマンドラインオプション; -output: コマンドラインインターフェイス<8>.
                                                             (line   17)
* zipapp コマンドラインオプション; -p:   コマンドラインインターフェイス<8>.
                                                             (line   29)
* zipapp コマンドラインオプション; -python: コマンドラインインターフェイス<8>.
                                                             (line   29)
* ZipFile (zipfile のクラス):            ZipFile オブジェクト.
                                                             (line    6)
* zipfile コマンドラインオプション; -c:  コマンドラインオプション<2>.
                                                             (line   11)
* zipfile コマンドラインオプション; -create: コマンドラインオプション<2>.
                                                             (line   11)
* zipfile コマンドラインオプション; -e:  コマンドラインオプション<2>.
                                                             (line   16)
* zipfile コマンドラインオプション; -extract: コマンドラインオプション<2>.
                                                             (line   16)
* zipfile コマンドラインオプション; -l:  コマンドラインオプション<2>.
                                                             (line    6)
* zipfile コマンドラインオプション; -list: コマンドラインオプション<2>.
                                                             (line    6)
* zipfile コマンドラインオプション; -metadata-encoding: コマンドラインオプション<2>.
                                                             (line   26)
* zipfile コマンドラインオプション; -t:  コマンドラインオプション<2>.
                                                             (line   21)
* zipfile コマンドラインオプション; -test: コマンドラインオプション<2>.
                                                             (line   21)
* zipimporter (zipimport のクラス):      zipimporter オブジェクト.
                                                             (line    8)
* ZipImportError:                        zipimport --- Zip アーカイブからモジュールをインポートする.
                                                             (line   58)
* ZipInfo (zipfile のクラス):            zipfile --- ZIP アーカイブの処理.
                                                             (line   60)
* ZLIB_RUNTIME_VERSION (zlib モジュール): zlib --- gzip 互換の圧縮.
                                                             (line  306)
* ZLIB_VERSION (zlib モジュール):        zlib --- gzip 互換の圧縮.
                                                             (line  299)
* ZoneInfo (zoneinfo のクラス):          ZoneInfo クラス.    (line    6)
* ZoneInfoNotFoundError:                 例外と警告.         (line    6)
* zscore() (statistics.NormalDist のメソッド): NormalDist オブジェクト.
                                                             (line  120)
* イテレータプロトコル:                  イテレータ型.       (line    6)
* イベントスケジューリング:              sched --- イベントスケジューラー.
                                                             (line    8)
* インタプリタ:                          トップレベル要素.   (line    6)
* インデックス操作:                      シーケンス型 sequence.
                                                             (line    6)
* インデント:                            インデント.         (line    6)
* エスケープシーケンス:                  文字列およびバイト列リテラル.
                                                             (line   77)
* エポック:                              time --- 時刻データへのアクセスと変換.
                                                             (line   20)
* エポックからの秒数:                    time --- 時刻データへのアクセスと変換.
                                                             (line   24)
* エラー:                                例外<2>.            (line    6)
* エラー;logging:                        logging --- Python 用のログ記録手段.
                                                             (line    8)
* エラー処理:                            例外<2>.            (line    6)
* オブジェクト;Capsule:                  カプセル<2>.        (line    6)
* オブジェクト;None:                     None オブジェクト.  (line    6)
* オブジェクト;コード:                   セルオブジェクト cell object.
                                                             (line   58)
* オブジェクト;比較する:                 比較<2>.            (line   42)
* オブジェクトの値:                      オブジェクト、値、および型.
                                                             (line   13)
* オブジェクトの同一性:                  オブジェクト、値、および型.
                                                             (line   13)
* オブジェクトの型:                      オブジェクト、値、および型.
                                                             (line   13)
* カンマ:                                丸括弧形式 parenthesized form.
                                                             (line   19)
* キー:                                  辞書表示.           (line    6)
* キーワード:                            キーワード keyword. (line    6)
* キーワード <1>:                        ソフトキーワード.   (line    6)
* キーワード;as:                         import 文.          (line    6)
* キーワード;as <1>:                     try 文.             (line    6)
* キーワード;as <2>:                     with 文.            (line    6)
* キーワード;as <3>:                     match 文<2>.        (line    6)
* キーワード;async:                      コルーチン関数定義. (line    9)
* キーワード;await:                      呼び出し call.      (line  157)
* キーワード;await <1>:                  コルーチン関数定義. (line    9)
* キーワード;case:                       match 文<2>.        (line    6)
* キーワード;elif:                       if 文<2>.           (line    6)
* キーワード;else:                       break 文.           (line   12)
* キーワード;else <1>:                   if 文<2>.           (line    6)
* キーワード;else <2>:                   while 文.           (line    6)
* キーワード;else <3>:                   for 文<2>.          (line    6)
* キーワード;else <4>:                   try 文.             (line    6)
* キーワード;else <5>:                   except* 節.         (line   57)
* キーワード;except:                     try 文.             (line    6)
* キーワード;except_star:                except 節.          (line   79)
* キーワード;finally:                    return 文.          (line   17)
* キーワード;finally <1>:                break 文.           (line   18)
* キーワード;finally <2>:                continue 文.        (line    6)
* キーワード;finally <3>:                try 文.             (line    6)
* キーワード;finally <4>:                else 節.            (line   11)
* キーワード;from:                       Yield 式.           (line    6)
* キーワード;from <1>:                   import 文.          (line    6)
* キーワード;if:                         match 文<2>.        (line    6)
* キーワード;in:                         for 文<2>.          (line    6)
* キーワード;yield:                      Yield 式.           (line    6)
* クラス:                                用語集<2>.          (line  233)
* クラス;body:                           クラス本体の実行.   (line    6)
* クラス;definition:                     return 文.          (line    6)
* クラス;definition <1>:                 クラス定義.         (line    6)
* クラス;instance:                       クラスインスタンス class instance.
                                                             (line    6)
* クラス;name:                           クラス定義.         (line    6)
* クラス;コンストラクタ:                 基本的なカスタマイズ.
                                                             (line   37)
* クラス;属性:                           カスタムクラス型.   (line   19)
* クラス;属性;代入:                      カスタムクラス型.   (line   28)
* クラスインスタンス;call:               呼び出し call.      (line  149)
* クラスインスタンス;属性:               クラスインスタンス class instance.
                                                             (line    6)
* クラスインスタンス;属性;代入:          クラスインスタンス class instance.
                                                             (line   21)
* クラスオブジェクト;call:               カスタムクラス型.   (line   19)
* クラスオブジェクト;call <1>:           カスタムクラス型.   (line   31)
* クラスオブジェクト;call <2>:           呼び出し call.      (line  145)
* グラフィカルユーザインターフェース:    Tk を用いたグラフィカルユーザーインターフェース.
                                                             (line    6)
* グリニッジ標準時:                      time --- 時刻データへのアクセスと変換.
                                                             (line   39)
* グループ化:                            インデント.         (line    6)
* グローバル;name;束縛:                  global 文.          (line    6)
* グローバル;namespace:                  Special read-only attributes.
                                                             (line    6)
* コード;ブロック:                       実行モデル.         (line    6)
* コードオブジェクト:                    コードオブジェクト. (line    6)
* コードオブジェクト <1>:                メソッド.           (line   43)
* コードオブジェクト <2>:                marshal --- 内部使用向けの Python オブジェクト直列化.
                                                             (line   33)
* コードオブジェクト <3>:                セルオブジェクト cell object.
                                                             (line   57)
* コマンドライン:                        完全な Python プログラム.
                                                             (line   24)
* コマンドラインオプション; -?:          一般オプション.     (line    6)
* コマンドラインオプション; -b:          その他のオプション. (line    6)
* コマンドラインオプション; -B:          その他のオプション. (line   16)
* コマンドラインオプション; -build:      クロスコンパイルのオプション.
                                                             (line   12)
* コマンドラインオプション; -c:          インターフェイスオプション.
                                                             (line   35)
* コマンドラインオプション; -check-hash-based-pycs: その他のオプション.
                                                             (line   22)
* コマンドラインオプション; -d:          その他のオプション. (line   36)
* コマンドラインオプション; -disable-gil: 一般的なオプション.
                                                             (line  228)
* コマンドラインオプション; -disable-ipv6: 一般的なオプション.
                                                             (line   17)
* コマンドラインオプション; -disable-test-modules: インストールオプション.
                                                             (line   25)
* コマンドラインオプション; -E:          その他のオプション. (line   44)
* コマンドラインオプション; -enable-big-digits: 一般的なオプション.
                                                             (line   22)
* コマンドラインオプション; -enable-bolt: パフォーマンスに関するオプション.
                                                             (line   62)
* コマンドラインオプション; -enable-experimental-jit: 一般的なオプション.
                                                             (line  240)
* コマンドラインオプション; -enable-framework: macOS のオプション.
                                                             (line   16)
* コマンドラインオプション; -enable-framework <1>: macOS のオプション.
                                                             (line   18)
* コマンドラインオプション; -enable-framework <2>: iOS のオプション.
                                                             (line    8)
* コマンドラインオプション; -enable-loadable-sqlite-extensions: 一般的なオプション.
                                                             (line    6)
* コマンドラインオプション; -enable-optimizations: パフォーマンスに関するオプション.
                                                             (line   10)
* コマンドラインオプション; -enable-profiling: パフォーマンスに関するオプション.
                                                             (line  128)
* コマンドラインオプション; -enable-pystats: 一般的なオプション.
                                                             (line  134)
* コマンドラインオプション; -enable-shared: リンカのオプション<2>.
                                                             (line    6)
* コマンドラインオプション; -enable-universalsdk: macOS のオプション.
                                                             (line    8)
* コマンドラインオプション; -enable-universalsdk <1>: macOS のオプション.
                                                             (line   10)
* コマンドラインオプション; -enable-wasm-dynamic-linking: WebAssembly オプション.
                                                             (line   17)
* コマンドラインオプション; -enable-wasm-pthreads: WebAssembly オプション.
                                                             (line   27)
* コマンドラインオプション; -exec-prefix: インストールオプション.
                                                             (line   17)
* コマンドラインオプション; -h:          一般オプション.     (line    6)
* コマンドラインオプション; -help:       一般オプション.     (line    6)
* コマンドラインオプション; -help-all:   一般オプション.     (line   27)
* コマンドラインオプション; -help-env:   一般オプション.     (line   13)
* コマンドラインオプション; -help-xoptions: 一般オプション.  (line   20)
* コマンドラインオプション; -host:       クロスコンパイルのオプション.
                                                             (line   17)
* コマンドラインオプション; -i:          その他のオプション. (line   51)
* コマンドラインオプション; -I:          その他のオプション. (line   63)
* コマンドラインオプション; -J:          使うべきでないオプション.
                                                             (line    6)
* コマンドラインオプション; -m:          インターフェイスオプション.
                                                             (line   49)
* コマンドラインオプション; -O:          その他のオプション. (line   75)
* コマンドラインオプション; -OO:         その他のオプション. (line   85)
* コマンドラインオプション; -P:          その他のオプション. (line   94)
* コマンドラインオプション; -prefix:     インストールオプション.
                                                             (line    6)
* コマンドラインオプション; -q:          その他のオプション. (line  113)
* コマンドラインオプション; -R:          その他のオプション. (line  120)
* コマンドラインオプション; -s:          その他のオプション. (line  145)
* コマンドラインオプション; -S:          その他のオプション. (line  157)
* コマンドラインオプション; -u:          その他のオプション. (line  165)
* コマンドラインオプション; -V:          一般オプション.     (line   33)
* コマンドラインオプション; -v:          その他のオプション. (line  175)
* コマンドラインオプション; -version:    一般オプション.     (line   33)
* コマンドラインオプション; -W:          その他のオプション. (line  188)
* コマンドラインオプション; -with-address-sanitizer: Debug options.
                                                             (line   59)
* コマンドラインオプション; -with-app-store-compliance: macOS のオプション.
                                                             (line   53)
* コマンドラインオプション; -with-app-store-compliance <1>: macOS のオプション.
                                                             (line   55)
* コマンドラインオプション; -with-assertions: Debug options. (line   34)
* コマンドラインオプション; -with-build-python: クロスコンパイルのオプション.
                                                             (line   22)
* コマンドラインオプション; -with-builtin-hashlib-hashes: Security Options.
                                                             (line   21)
* コマンドラインオプション; -with-computed-gotos: パフォーマンスに関するオプション.
                                                             (line   99)
* コマンドラインオプション; -with-dbmliborder: 一般的なオプション.
                                                             (line   69)
* コマンドラインオプション; -with-dtrace: Debug options.     (line   51)
* コマンドラインオプション; -with-emscripten-target: WebAssembly オプション.
                                                             (line    6)
* コマンドラインオプション; -with-ensurepip: インストールオプション.
                                                             (line   33)
* コマンドラインオプション; -with-framework-name: macOS のオプション.
                                                             (line   47)
* コマンドラインオプション; -with-framework-name <1>: iOS のオプション.
                                                             (line   13)
* コマンドラインオプション; -with-hash-algorithm: Security Options.
                                                             (line    6)
* コマンドラインオプション; -with-libc:  Libraries options.  (line   58)
* コマンドラインオプション; -with-libm:  Libraries options.  (line   53)
* コマンドラインオプション; -with-libs:  Libraries options.  (line    6)
* コマンドラインオプション; -with-lto:   パフォーマンスに関するオプション.
                                                             (line   46)
* コマンドラインオプション; -with-memory-sanitizer: Debug options.
                                                             (line   66)
* コマンドラインオプション; -with-openssl: Libraries options.
                                                             (line   63)
* コマンドラインオプション; -with-openssl-rpath: Libraries options.
                                                             (line   69)
* コマンドラインオプション; -with-pkg-config: 一般的なオプション.
                                                             (line  121)
* コマンドラインオプション; -with-platlibdir: 一般的なオプション.
                                                             (line   98)
* コマンドラインオプション; -with-pydebug: Debug options.    (line    6)
* コマンドラインオプション; -with-readline: Libraries options.
                                                             (line   35)
* コマンドラインオプション; -with-ssl-default-suites: Security Options.
                                                             (line   40)
* コマンドラインオプション; -with-strict-overflow: パフォーマンスに関するオプション.
                                                             (line  132)
* コマンドラインオプション; -with-suffix: 一般的なオプション.
                                                             (line   33)
* コマンドラインオプション; -with-system-expat: Libraries options.
                                                             (line   10)
* コマンドラインオプション; -with-system-libmpdec: Libraries options.
                                                             (line   15)
* コマンドラインオプション; -with-thread-sanitizer: Debug options.
                                                             (line   80)
* コマンドラインオプション; -with-trace-refs: Debug options. (line   11)
* コマンドラインオプション; -with-tzpath: 一般的なオプション.
                                                             (line   45)
* コマンドラインオプション; -with-undefined-behavior-sanitizer: Debug options.
                                                             (line   73)
* コマンドラインオプション; -with-universal-archs: macOS のオプション.
                                                             (line   24)
* コマンドラインオプション; -with-valgrind: Debug options.   (line   47)
* コマンドラインオプション; -with-wheel-pkg-dir: 一般的なオプション.
                                                             (line  108)
* コマンドラインオプション; -without-c-locale-coercion: 一般的なオプション.
                                                             (line   82)
* コマンドラインオプション; -without-decimal-contextvar: 一般的なオプション.
                                                             (line   58)
* コマンドラインオプション; -without-doc-strings: パフォーマンスに関するオプション.
                                                             (line  118)
* コマンドラインオプション; -without-freelists: 一般的なオプション.
                                                             (line   92)
* コマンドラインオプション; -without-mimalloc: パフォーマンスに関するオプション.
                                                             (line  104)
* コマンドラインオプション; -without-pymalloc: パフォーマンスに関するオプション.
                                                             (line  111)
* コマンドラインオプション; -without-readline: Libraries options.
                                                             (line   45)
* コマンドラインオプション; -without-static-libpython: リンカのオプション<2>.
                                                             (line   11)
* コマンドラインオプション; -x:          その他のオプション. (line  249)
* コマンドラインオプション; -X:          その他のオプション. (line  254)
* コマンドラインオプション; BOLT_APPLY_FLAGS: パフォーマンスに関するオプション.
                                                             (line   87)
* コマンドラインオプション; BOLT_INSTRUMENT_FLAGS: パフォーマンスに関するオプション.
                                                             (line   93)
* コマンドラインオプション; BZIP2_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line    8)
* コマンドラインオプション; BZIP2_LIBS:  サードパーティ依存関係のオプション.
                                                             (line   10)
* コマンドラインオプション; CC:          C コンパイラのオプション.
                                                             (line    6)
* コマンドラインオプション; CFLAGS:      C コンパイラのオプション.
                                                             (line   10)
* コマンドラインオプション; CONFIG_SITE: クロスコンパイルのオプション.
                                                             (line   28)
* コマンドラインオプション; CPP:         C コンパイラのオプション.
                                                             (line   14)
* コマンドラインオプション; CPPFLAGS:    C コンパイラのオプション.
                                                             (line   18)
* コマンドラインオプション; CURSES_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   15)
* コマンドラインオプション; CURSES_LIBS: サードパーティ依存関係のオプション.
                                                             (line   17)
* コマンドラインオプション; GDBM_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   22)
* コマンドラインオプション; GDBM_LIBS:   サードパーティ依存関係のオプション.
                                                             (line   24)
* コマンドラインオプション; HOSTRUNNER:  クロスコンパイルのオプション.
                                                             (line   39)
* コマンドラインオプション; LDFLAGS:     リンカのオプション. (line    6)
* コマンドラインオプション; LIBB2_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   28)
* コマンドラインオプション; LIBB2_LIBS:  サードパーティ依存関係のオプション.
                                                             (line   30)
* コマンドラインオプション; LIBEDIT_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   35)
* コマンドラインオプション; LIBEDIT_LIBS: サードパーティ依存関係のオプション.
                                                             (line   37)
* コマンドラインオプション; LIBFFI_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   42)
* コマンドラインオプション; LIBFFI_LIBS: サードパーティ依存関係のオプション.
                                                             (line   44)
* コマンドラインオプション; LIBLZMA_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   59)
* コマンドラインオプション; LIBLZMA_LIBS: サードパーティ依存関係のオプション.
                                                             (line   61)
* コマンドラインオプション; LIBMPDEC_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   49)
* コマンドラインオプション; LIBMPDEC_LIBS: サードパーティ依存関係のオプション.
                                                             (line   51)
* コマンドラインオプション; LIBREADLINE_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   66)
* コマンドラインオプション; LIBREADLINE_LIBS: サードパーティ依存関係のオプション.
                                                             (line   68)
* コマンドラインオプション; LIBS:        リンカのオプション. (line   10)
* コマンドラインオプション; LIBSQLITE3_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   73)
* コマンドラインオプション; LIBSQLITE3_LIBS: サードパーティ依存関係のオプション.
                                                             (line   75)
* コマンドラインオプション; LIBUUID_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   80)
* コマンドラインオプション; LIBUUID_LIBS: サードパーティ依存関係のオプション.
                                                             (line   82)
* コマンドラインオプション; MACHDEP:     リンカのオプション. (line   14)
* コマンドラインオプション; PANEL_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   87)
* コマンドラインオプション; PANEL_LIBS:  サードパーティ依存関係のオプション.
                                                             (line   89)
* コマンドラインオプション; PKG_CONFIG:  一般的なオプション. (line  259)
* コマンドラインオプション; PKG_CONFIG_LIBDIR: 一般的なオプション.
                                                             (line  263)
* コマンドラインオプション; PKG_CONFIG_PATH: 一般的なオプション.
                                                             (line  265)
* コマンドラインオプション; TCLTK_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line   96)
* コマンドラインオプション; TCLTK_LIBS:  サードパーティ依存関係のオプション.
                                                             (line   98)
* コマンドラインオプション; ZLIB_CFLAGS: サードパーティ依存関係のオプション.
                                                             (line  102)
* コマンドラインオプション; ZLIB_LIBS:   サードパーティ依存関係のオプション.
                                                             (line  104)
* コメント:                              コメント Comments.  (line    6)
* コルーチン:                            特殊メソッド検索.   (line   72)
* コルーチン <1>:                        Yield 式.           (line   51)
* コルーチン <2>:                        用語集<2>.          (line  327)
* コルーチン;関数:                       コルーチン関数 coroutine function.
                                                             (line    6)
* コンテキスト管理プロトコル:            コンテキストマネージャ型.
                                                             (line    6)
* コンテキスト管理プロトコル <1>:        用語集<2>.          (line  299)
* コンテナ:                              オブジェクト、値、および型.
                                                             (line   69)
* コンテナ <1>:                          カスタムクラス型.   (line   19)
* コンテナ;での反復:                     イテレータ型.       (line    6)
* サブクラス化;変更不能な型:             基本的なカスタマイズ.
                                                             (line    8)
* ジェネレータ:                          用語集<2>.          (line  600)
* ジェネレータ <1>:                      用語集<2>.          (line  600)
* ジェネレータ;expression:               ジェネレータ式<2>.  (line    6)
* ジェネレータ;iterator:                 ジェネレータ関数 generator function.
                                                             (line    6)
* ジェネレータ;iterator <1>:             yield 文.           (line    6)
* ジェネレータ;関数:                     ジェネレータ関数 generator function.
                                                             (line    6)
* ジェネレータ;関数 <1>:                 Yield 式.           (line    6)
* ジェネレータ;関数 <2>:                 yield 文.           (line    6)
* シフト;操作:                           整数型におけるビット単位演算.
                                                             (line    6)
* シフト;演算:                           シフト演算 shifting operation.
                                                             (line    6)
* スコープ:                              名前づけと束縛 naming and binding.
                                                             (line    6)
* スコープ <1>:                          名前解決.           (line    6)
* スタック;トレース:                     トレースバック traceback オブジェクト.
                                                             (line    6)
* スタック可能;ストリーム:               codecs --- codec レジストリと基底クラス.
                                                             (line    8)
* ストリーム:                            codecs --- codec レジストリと基底クラス.
                                                             (line    8)
* スライス:                              シーケンス型 sequence.
                                                             (line   14)
* スライス <1>:                          変更可能なシーケンス型 mutable sequence.
                                                             (line    6)
* スライス <2>:                          スライス表記 slicing.
                                                             (line    6)
* スライス;代入:                         代入文 assignment statement.
                                                             (line  123)
* ソースコード文字セット:                エンコード宣言 encoding declaration.
                                                             (line    6)
* タブ:                                  インデント.         (line    6)
* チェックサム;CRC:                      zlib --- gzip 互換の圧縮.
                                                             (line  122)
* データ:                                オブジェクト、値、および型.
                                                             (line    6)
* データ;type:                           標準型の階層.       (line    6)
* データ;表形式:                         csv --- CSV ファイルの読み書き.
                                                             (line    8)
* データベース:                          dbm dumb --- 可搬性のある DBM 実装.
                                                             (line    8)
* ディレクトリ;トラバース:               ファイルとディレクトリ.
                                                             (line 1672)
* ディレクトリ;トラバース <1>:           ファイルとディレクトリ.
                                                             (line 1774)
* ディレクトリ;作成:                     ファイルとディレクトリ.
                                                             (line  558)
* ディレクトリ;削除:                     ディレクトリとファイルの操作.
                                                             (line  270)
* ディレクトリ;削除 <1>:                 ファイルとディレクトリ.
                                                             (line  750)
* ディレクトリ;変更:                     ファイルとディレクトリ.
                                                             (line  120)
* ディレクトリ;走査:                     ファイルとディレクトリ.
                                                             (line 1672)
* ディレクトリ;走査 <1>:                 ファイルとディレクトリ.
                                                             (line 1774)
* デストラクタ:                          基本的なカスタマイズ.
                                                             (line   53)
* デストラクタ <1>:                      代入文 assignment statement.
                                                             (line   71)
* デバッグ:                              pdb --- Python デバッガ.
                                                             (line    8)
* デバッグ;assertions:                   assert 文.          (line    6)
* デリミタ:                              デリミタ delimiter. (line    6)
* テンポラリ;ファイル:                   tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line    8)
* テンポラリ;ファイル名:                 tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line    8)
* トークン:                              字句解析.           (line    6)
* ドキュメント文字列:                    Special read-only attributes<2>.
                                                             (line  105)
* バイト:                                変更不能なシーケンス immutable sequence.
                                                             (line   40)
* バイト列リテラル:                      リテラル.           (line    8)
* バイナリモード:                        組み込み関数.       (line 1455)
* パス;操作:                             pathlib --- オブジェクト指向のファイルシステムパス.
                                                             (line   10)
* パス;操作 <1>:                         os path --- 一般的なパス名操作.
                                                             (line    9)
* パス;設定;ファイル:                    site --- サイト固有の設定フック.
                                                             (line   71)
* パック;2進数;データ:                   struct --- バイト列をパックされたバイナリデータとして解釈する.
                                                             (line    8)
* バックスラッシュ文字:                  明示的な行継続.     (line    6)
* ハッシュ文字:                          コメント Comments.  (line    6)
* ビットマスク;操作:                     整数型におけるビット単位演算.
                                                             (line    6)
* ビット単位;and:                        ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   12)
* ビット単位;or:                         ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   20)
* ビット単位;xor:                        ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   16)
* ビット単位;操作:                       整数型におけるビット単位演算.
                                                             (line    6)
* ファイル;large files:                  ラージファイルのサポート.
                                                             (line    6)
* ファイル;mime.types:                   mimetypes --- ファイル名を MIME タイプへマップする.
                                                             (line  138)
* ファイル;modes:                        組み込み関数.       (line 1283)
* ファイル;コピー:                       shutil --- 高水準のファイル操作.
                                                             (line    8)
* ファイル;バイトコード:                 py_compile --- Python ソースファイルをコンパイルする.
                                                             (line    8)
* ファイルのコピー:                      shutil --- 高水準のファイル操作.
                                                             (line    8)
* プライベートな;名前:                   識別子 identifier、または名前 name.
                                                             (line   15)
* プライマリ:                            プライマリ.         (line    6)
* プラス:                                単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   14)
* プログラム:                            完全な Python プログラム.
                                                             (line    6)
* プロセッサー時間:                      関数<5>.            (line  244)
* プロセッサー時間 <1>:                  関数<5>.            (line  594)
* ブロック:                              プログラムの構造.   (line    6)
* プロトコル;iterator:                   イテレータ型.       (line    6)
* プロトコル;コンテキスト管理:           コンテキストマネージャ型.
                                                             (line    6)
* ベンチマーク:                          関数<5>.            (line  215)
* ベンチマーク <1>:                      関数<5>.            (line  244)
* ベンチマーク <2>:                      関数<5>.            (line  594)
* ベンチマーク <3>:                      timeit --- 小さなコードスニペットの実行時間計測.
                                                             (line    8)
* マイナス:                              単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   10)
* メソッド:                              用語集<2>.          (line  950)
* メソッド;call:                         呼び出し call.      (line  140)
* モジュロ:                              二項算術演算 binary arithmetic operation.
                                                             (line   44)
* ユーザー;id:                           プロセスのパラメーター.
                                                             (line  329)
* ユーザー;ID、設定:                     プロセスのパラメーター.
                                                             (line  522)
* ユーザー;実効 ID:                      プロセスのパラメーター.
                                                             (line  184)
* ユーザ定義の;メソッド:                 インスタンスメソッド.
                                                             (line    6)
* ユーザ定義の;関数:                     ユーザ定義関数 user-defined function.
                                                             (line    6)
* ユーザ定義の;関数;call:                呼び出し call.      (line  129)
* リテラル:                              リテラル.           (line    6)
* リテラル <1>:                          リテラル<2>.        (line    6)
* ロケールエンコーディング:              用語集<2>.          (line  898)
* 三項;operator:                         条件式 Conditional Expressions.
                                                             (line    6)
* 丸括弧形式:                            丸括弧形式 parenthesized form.
                                                             (line    6)
* 乗算:                                  二項算術演算 binary arithmetic operation.
                                                             (line   16)
* 予約語:                                キーワード keyword. (line    6)
* 代入;expression:                       ブール演算 boolean operation.
                                                             (line   33)
* 代入;statement:                        変更可能なシーケンス型 mutable sequence.
                                                             (line    6)
* 代入;statement <1>:                    代入文 assignment statement.
                                                             (line    6)
* 位置引数 (positional argument):        用語集<2>.          (line 1188)
* 例外:                                  例外<2>.            (line    6)
* 例外 <1>:                              raise 文.           (line    6)
* 例外;AssertionError:                   assert 文.          (line   22)
* 例外;AttributeError:                   属性参照.           (line   10)
* 例外;GeneratorExit:                    ジェネレータ-イテレータメソッド.
                                                             (line   63)
* 例外;GeneratorExit <1>:                非同期ジェネレータイテレータメソッド.
                                                             (line   60)
* 例外;ImportError:                      import 文.          (line    6)
* 例外;NameError:                        識別子 identifier、または名前 name.
                                                             (line   11)
* 例外;StopAsyncIteration:               非同期ジェネレータイテレータメソッド.
                                                             (line    9)
* 例外;StopIteration:                    ジェネレータ-イテレータメソッド.
                                                             (line   12)
* 例外;StopIteration <1>:                yield 文.           (line    6)
* 例外;TypeError:                        単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   23)
* 例外;ValueError:                       シフト演算 shifting operation.
                                                             (line   19)
* 例外;ZeroDivisionError:                二項算術演算 binary arithmetic operation.
                                                             (line   33)
* 例外;ハンドラ:                         トレースバック traceback オブジェクト.
                                                             (line    6)
* 例外;連鎖:                             raise 文.           (line   30)
* 例外;連鎖 <1>:                         例外コンテキスト.   (line    6)
* 例外ハンドラ:                          例外<2>.            (line    6)
* 例外を扱う:                            例外<2>.            (line    6)
* 例外を送出する:                        例外<2>.            (line    6)
* 先頭の空白:                            インデント.         (line    6)
* 入力:                                  式入力.             (line    6)
* 内包表記:                              リスト、集合、辞書の表示.
                                                             (line    6)
* 内部型:                                内部型 internal type.
                                                             (line    6)
* 凍結ユーティリティ:                    モジュールのインポート<2>.
                                                             (line  273)
* 到達不能オブジェクト:                  オブジェクト、値、および型.
                                                             (line   38)
* 制限;実行:                             組み込みと制限付きの実行.
                                                             (line    6)
* 加算:                                  二項算術演算 binary arithmetic operation.
                                                             (line   70)
* 包含的;or:                             ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   20)
* 協定世界時:                            time --- 時刻データへのアクセスと変換.
                                                             (line   39)
* 単一要素の;tuple:                      変更不能なシーケンス immutable sequence.
                                                             (line   30)
* 単項;ビット単位;演算:                  単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line    6)
* 単項;算術;演算:                        単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line    6)
* 参照カウント:                          オブジェクト、値、および型.
                                                             (line   38)
* 反転:                                  単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   18)
* 同一性;テスト:                         所属検査演算.       (line   39)
* 否定:                                  単項算術演算とビット単位演算 unary arithmetic and bitwise operation.
                                                             (line   10)
* 型, 内部の:                            内部型 internal type.
                                                             (line    6)
* 変更不可能なオブジェクト:              オブジェクト、値、および型.
                                                             (line   13)
* 変更可能なオブジェクト:                オブジェクト、値、および型.
                                                             (line   13)
* 変更可能なシーケンス;loop over:        共通のシーケンス演算.
                                                             (line   69)
* 夏時間:                                time --- 時刻データへのアクセスと変換.
                                                             (line   43)
* 外部データ表現:                        データストリームの形式.
                                                             (line    6)
* 字句解析:                              本マニュアルにおける表記法.
                                                             (line   31)
* 字句解析 <1>:                          字句解析.           (line    6)
* 定数:                                  リテラル.           (line    6)
* 実行;スタック:                         トレースバック traceback オブジェクト.
                                                             (line    6)
* 実行;フレーム:                         プログラムの構造.   (line   18)
* 実行;フレーム <1>:                     クラス定義.         (line    6)
* 実行モデル:                            実行モデル.         (line    6)
* 実行文のグループ化:                    インデント.         (line    6)
* 対話モード:                            完全な Python プログラム.
                                                             (line   18)
* 属性:                                  標準型の階層.       (line   12)
* 属性 <1>:                              用語集<2>.          (line  134)
* 属性;deletion:                         del 文<2>.          (line   20)
* 属性;代入:                             代入文 assignment statement.
                                                             (line    6)
* 属性;代入 <1>:                         代入文 assignment statement.
                                                             (line   77)
* 属性;参照:                             属性参照.           (line    6)
* 帰属;テスト:                           所属検査演算.       (line   36)
* 平坦化;オブジェクト:                   pickle --- Python オブジェクトの直列化.
                                                             (line    8)
* 引数 (argument):                       用語集<2>.          (line   51)
* 引数 (argument);call の意味付け:       スライス表記 slicing.
                                                             (line   37)
* 引数 (argument);difference from parameter: オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？.
                                                             (line   17)
* 引数 (argument);function definition:   関数定義.           (line   65)
* 性能:                                  timeit --- 小さなコードスニペットの実行時間計測.
                                                             (line    8)
* 拡張;module:                           標準型の階層.       (line    6)
* 排他的;or:                             ビット単位演算の二項演算 binary bitwise operation.
                                                             (line   16)
* 数値;リテラル:                         数値型 int float complex.
                                                             (line   17)
* 数値;変換:                             数値型 int float complex.
                                                             (line  102)
* 数値リテラル:                          数値リテラル.       (line    6)
* 整列化;オブジェクト:                   pickle --- Python オブジェクトの直列化.
                                                             (line    8)
* 整数:                                  変更不能なシーケンス immutable sequence.
                                                             (line   16)
* 整数;リテラル:                         数値型 int float complex.
                                                             (line   17)
* 整数;表現:                             numbers Integral 整数.
                                                             (line    9)
* 整数リテラル:                          数値リテラル.       (line    6)
* 文字(str型):                           変更不能なシーケンス immutable sequence.
                                                             (line   16)
* 文字(str型) <1>:                       添字表記 subscription.
                                                             (line   58)
* 文字(str型) <2>:                       unicodedata --- Unicode データベース.
                                                             (line    6)
* 文字列リテラル:                        リテラル.           (line    8)
* 文法:                                  本マニュアルにおける表記法.
                                                             (line    6)
* 書式化, 文字列 (%):                    printf 形式の文字列書式化.
                                                             (line    6)
* 書式化;bytearray (%):                  printf 形式での bytes の書式化.
                                                             (line    6)
* 書式化;bytes (%):                      printf 形式での bytes の書式化.
                                                             (line    6)
* 末尾の;カンマ:                         式のリスト.         (line   28)
* 束縛;name:                             名前の束縛.         (line    6)
* 束縛;name <1>:                         代入文 assignment statement.
                                                             (line    6)
* 条件;expression:                       ブール演算 boolean operation.
                                                             (line    6)
* 条件;expression <1>:                   条件式 Conditional Expressions.
                                                             (line    6)
* 構文:                                  本マニュアルにおける表記法.
                                                             (line    6)
* 標準 C:                                文字列およびバイト列リテラル.
                                                             (line   77)
* 標準入力:                              完全な Python プログラム.
                                                             (line   24)
* 比較:                                  基本的なカスタマイズ.
                                                             (line  182)
* 比較 <1>:                              比較.               (line    6)
* 永続オブジェクト (immortal):           用語集<2>.          (line  708)
* 永続化:                                pickle --- Python オブジェクトの直列化.
                                                             (line    8)
* 永続化;オブジェクト:                   pickle --- Python オブジェクトの直列化.
                                                             (line    8)
* 汎用;特殊;属性:                        標準型の階層.       (line   12)
* 注釈;type annotation; type hint:       型アノテーション型 --- ジェネリックエイリアス 、 ユニオン.
                                                             (line    6)
* 浮動小数点;number:                     numbers Real float 実数.
                                                             (line    6)
* 浮動小数点;リテラル:                   数値型 int float complex.
                                                             (line   17)
* 添字;代入:                             ミュータブルなシーケンス型.
                                                             (line   16)
* 添字;演算:                             共通のシーケンス演算.
                                                             (line   18)
* 添字表記:                              シーケンス型 sequence.
                                                             (line    6)
* 添字表記 <1>:                          変更可能なシーケンス型 mutable sequence.
                                                             (line    6)
* 添字表記 <2>:                          マッピング型 mapping.
                                                             (line    6)
* 添字表記 <3>:                          添字表記 subscription.
                                                             (line    6)
* 添字表記;代入:                         代入文 assignment statement.
                                                             (line   99)
* 減算:                                  二項算術演算 binary arithmetic operation.
                                                             (line   78)
* 演算;dictionary;type:                  マッピング型 --- dict.
                                                             (line    6)
* 演算;list;type:                        ミュータブルなシーケンス型.
                                                             (line   16)
* 演算;mapping;types:                    マッピング型 --- dict.
                                                             (line    6)
* 演算;sequence;types:                   共通のシーケンス演算.
                                                             (line   18)
* 演算;sequence;types <1>:               ミュータブルなシーケンス型.
                                                             (line   16)
* 演算;数値;types:                       数値型 int float complex.
                                                             (line   89)
* 演算;整数;types:                       整数型におけるビット単位演算.
                                                             (line    6)
* 演算子:                                演算子.             (line    6)
* 無名;関数:                             ラムダ lambda.      (line    6)
* 物理行:                                論理行 logical line.
                                                             (line    6)
* 物理行 <1>:                            明示的な行継続.     (line    6)
* 物理行 <2>:                            文字列およびバイト列リテラル.
                                                             (line   77)
* 特殊;メソッド:                         用語集<2>.          (line 1347)
* 特殊;属性:                             標準型の階層.       (line   12)
* 環境:                                  名前解決.           (line   12)
* 環境;仮想:                             venv --- 仮想環境の作成.
                                                             (line   10)
* 環境変数; __PYVENV_LAUNCHER__:         PyConfig.           (line  186)
* 環境変数; __PYVENV_LAUNCHER__ <1>:     PyConfig.           (line  705)
* 環境変数; %APPDATA%:                   Redirection of local data registry and temporary paths.
                                                             (line   12)
* 環境変数; APPDATA:                     PEP 370 ユーザごとの site-packages ディレクトリ.
                                                             (line   25)
* 環境変数; BASECFLAGS:                  Compiler flags.     (line   66)
* 環境変数; BASECPPFLAGS:                Preprocessor flags. (line   22)
* 環境変数; BLDSHARED:                   Linker flags.       (line   67)
* 環境変数; BROWSER:                     webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   20)
* 環境変数; BROWSER <1>:                 webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line   32)
* 環境変数; BROWSER <2>:                 webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line  118)
* 環境変数; CC:                          新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   56)
* 環境変数; CC <1>:                      Compiler flags.     (line    6)
* 環境変数; CCSHARED:                    Compiler flags.     (line   81)
* 環境変数; CFLAGS:                      新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   57)
* 環境変数; CFLAGS <1>:                  パフォーマンスに関するオプション.
                                                             (line   28)
* 環境変数; CFLAGS <2>:                  Compiler flags.     (line   18)
* 環境変数; CFLAGS <3>:                  Compiler flags.     (line   26)
* 環境変数; CFLAGS <4>:                  Compiler flags.     (line   28)
* 環境変数; CFLAGS <5>:                  Compiler flags.     (line   32)
* 環境変数; CFLAGS <6>:                  Compiler flags.     (line   54)
* 環境変数; CFLAGS <7>:                  Linker flags.       (line   18)
* 環境変数; CFLAGS_ALIASING:             Compiler flags.     (line   74)
* 環境変数; CFLAGS_NODIST:               Compiler flags.     (line   22)
* 環境変数; CFLAGS_NODIST <1>:           Compiler flags.     (line   24)
* 環境変数; CFLAGS_NODIST <2>:           Compiler flags.     (line   61)
* 環境変数; CFLAGS_NODIST <3>:           Linker flags.       (line   26)
* 環境変数; CFLAGSFORSHARED:             Compiler flags.     (line   87)
* 環境変数; COLUMNS:                     関数<6>.            (line  578)
* 環境変数; COLUMNS <1>:                 関数<6>.            (line  579)
* 環境変数; COMPILEALL_OPTS:             Compiler flags.     (line   41)
* 環境変数; COMSPEC:                     プロセス管理.       (line  775)
* 環境変数; COMSPEC <1>:                 Popen コンストラクター.
                                                             (line  111)
* 環境変数; CONFIGURE_CFLAGS:            Compiler flags.     (line   52)
* 環境変数; CONFIGURE_CFLAGS_NODIST:     Compiler flags.     (line   59)
* 環境変数; CONFIGURE_CPPFLAGS:          Preprocessor flags. (line    6)
* 環境変数; CONFIGURE_LDFLAGS:           Linker flags.       (line   13)
* 環境変数; CONFIGURE_LDFLAGS_NODIST:    Linker flags.       (line   38)
* 環境変数; CPPFLAGS:                    新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   57)
* 環境変数; CPPFLAGS <1>:                Preprocessor flags. (line    8)
* 環境変数; CPPFLAGS <2>:                Preprocessor flags. (line   13)
* 環境変数; CPPFLAGS <3>:                Preprocessor flags. (line   18)
* 環境変数; CPPFLAGS <4>:                Linker flags.       (line   50)
* 環境変数; CXX:                         Compiler flags.     (line   12)
* 環境変数; DISPLAY:                     Tkinter モジュール. (line   27)
* 環境変数; EnableControlFlowGuard:      Build<30>.          (line   47)
* 環境変数; EXTRA_CFLAGS:                Compiler flags.     (line   48)
* 環境変数; HOME:                        os path<4>.         (line   15)
* 環境変数; HOME <1>:                    Python API の変更<3>.
                                                             (line  117)
* 環境変数; HOME <2>:                    Windows<38>.        (line   15)
* 環境変数; HOME <3>:                    Windows<38>.        (line   18)
* 環境変数; HOME <4>:                    os path --- 一般的なパス名操作.
                                                             (line  140)
* 環境変数; HOME <5>:                    os path --- 一般的なパス名操作.
                                                             (line  158)
* 環境変数; HOME <6>:                    Tkinter モジュール. (line   66)
* 環境変数; HOMEDRIVE:                   os path --- 一般的なパス名操作.
                                                             (line  147)
* 環境変数; HOMEPATH:                    os path --- 一般的なパス名操作.
                                                             (line  147)
* 環境変数; IDLESTARTUP:                 IDLE<37>.           (line  176)
* 環境変数; IDLESTARTUP <1>:             IDLE<41>.           (line    9)
* 環境変数; IDLESTARTUP <2>:             IDLE<47>.           (line    9)
* 環境変数; IDLESTARTUP <3>:             Startup and Code Execution.
                                                             (line    6)
* 環境変数; LANG:                        GNU gettext API.    (line   21)
* 環境変数; LANG <1>:                    クラス形式の API.   (line   25)
* 環境変数; LANG <2>:                    locale --- 国際化サービス.
                                                             (line   45)
* 環境変数; LANG <3>:                    locale --- 国際化サービス.
                                                             (line  329)
* 環境変数; LANG <4>:                    locale --- 国際化サービス.
                                                             (line  333)
* 環境変数; LANGUAGE:                    GNU gettext API.    (line   20)
* 環境変数; LANGUAGE <1>:                クラス形式の API.   (line   25)
* 環境変数; LC_ALL:                      GNU gettext API.    (line   20)
* 環境変数; LC_ALL <1>:                  クラス形式の API.   (line   25)
* 環境変数; LC_MESSAGES:                 GNU gettext API.    (line   21)
* 環境変数; LC_MESSAGES <1>:             クラス形式の API.   (line   25)
* 環境変数; LDCXXSHARED:                 ビルドならびに C API の変更<8>.
                                                             (line  149)
* 環境変数; LDFLAGS:                     新たなモジュール、改良されたモジュール、非推奨のモジュール<4>.
                                                             (line   57)
* 環境変数; LDFLAGS <1>:                 Preprocessor flags. (line   18)
* 環境変数; LDFLAGS <2>:                 Linker flags.       (line   15)
* 環境変数; LDFLAGS <3>:                 Linker flags.       (line   18)
* 環境変数; LDFLAGS <4>:                 Linker flags.       (line   28)
* 環境変数; LDFLAGS <5>:                 Linker flags.       (line   31)
* 環境変数; LDFLAGS <6>:                 Linker flags.       (line   35)
* 環境変数; LDFLAGS <7>:                 Linker flags.       (line   45)
* 環境変数; LDFLAGS <8>:                 Linker flags.       (line   50)
* 環境変数; LDFLAGS_NODIST:              Linker flags.       (line   24)
* 環境変数; LDFLAGS_NODIST <1>:          Linker flags.       (line   26)
* 環境変数; LDFLAGS_NODIST <2>:          Linker flags.       (line   40)
* 環境変数; LDSHARED:                    Linker flags.       (line   61)
* 環境変数; LIBS:                        Linker flags.       (line   54)
* 環境変数; LINES:                       関数<6>.            (line  125)
* 環境変数; LINES <1>:                   関数<6>.            (line  577)
* 環境変数; LINES <2>:                   関数<6>.            (line  579)
* 環境変数; LINKCC:                      Linker flags.       (line    6)
* 環境変数; LOGNAME:                     プロセスのパラメーター.
                                                             (line  235)
* 環境変数; LOGNAME <1>:                 getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   42)
* 環境変数; MANPAGER:                    pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line   46)
* 環境変数; MANPAGER <1>:                pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line   48)
* 環境変数; no_proxy:                    urllib request --- URL を開くための大規模なライブラリ.
                                                             (line  306)
* 環境変数; OPT:                         Debug options.      (line   39)
* 環境変数; OPT <1>:                     Compiler flags.     (line   70)
* 環境変数; PAGER:                       pydoc --- ドキュメント生成とオンラインヘルプシステム.
                                                             (line   46)
* 環境変数; PATH:                        Python API の変更<3>.
                                                             (line  144)
* 環境変数; PATH <1>:                    'python' コマンドの挙動の変更<2>.
                                                             (line    6)
* 環境変数; PATH <2>:                    'python' コマンドの挙動の変更<2>.
                                                             (line   10)
* 環境変数; PATH <3>:                    'python' コマンドの挙動の変更<2>.
                                                             (line   11)
* 環境変数; PATH <4>:                    macOS<4>.           (line   14)
* 環境変数; PATH <5>:                    Windows<19>.        (line   56)
* 環境変数; PATH <6>:                    Windows<23>.        (line   14)
* 環境変数; PATH <7>:                    Security<32>.       (line   16)
* 環境変数; PATH <8>:                    Security<32>.       (line   20)
* 環境変数; PATH <9>:                    モジュール検索パス. (line   16)
* 環境変数; PATH <10>:                   実行可能な Python スクリプト.
                                                             (line   11)
* 環境変数; PATH <11>:                   環境変数.           (line   26)
* 環境変数; PATH <12>:                   その他.             (line   15)
* 環境変数; PATH <13>:                   インストール手順.   (line   36)
* 環境変数; PATH <14>:                   インストール手順.   (line   59)
* 環境変数; PATH <15>:                   インストーラの GUI なしでインストールする.
                                                             (line   77)
* 環境変数; PATH <16>:                   インストーラの GUI なしでインストールする.
                                                             (line   82)
* 環境変数; PATH <17>:                   Python を構成する<2>.
                                                             (line    7)
* 環境変数; PATH <18>:                   補足 環境変数の設定.
                                                             (line   22)
* 環境変数; PATH <19>:                   補足 環境変数の設定.
                                                             (line   33)
* 環境変数; PATH <20>:                   Python 実行ファイルを見つける.
                                                             (line   13)
* 環境変数; PATH <21>:                   Python 実行ファイルを見つける.
                                                             (line   22)
* 環境変数; PATH <22>:                   Python 実行ファイルを見つける.
                                                             (line   23)
* 環境変数; PATH <23>:                   Windows の Python ランチャ.
                                                             (line   13)
* 環境変数; PATH <24>:                   コマンドラインから起動する.
                                                             (line    8)
* 環境変数; PATH <25>:                   シェバン shebang 行.
                                                             (line   55)
* 環境変数; PATH <26>:                   シェバン shebang 行.
                                                             (line   61)
* 環境変数; PATH <27>:                   シェバン shebang 行.
                                                             (line   63)
* 環境変数; PATH <28>:                   シェバン shebang 行.
                                                             (line   68)
* 環境変数; PATH <29>:                   os と os path モジュールの比較.
                                                             (line   41)
* 環境変数; PATH <30>:                   ディレクトリとファイルの操作.
                                                             (line  431)
* 環境変数; PATH <31>:                   プロセス管理.       (line   45)
* 環境変数; PATH <32>:                   プロセス管理.       (line   87)
* 環境変数; PATH <33>:                   プロセス管理.       (line   90)
* 環境変数; PATH <34>:                   プロセス管理.       (line   93)
* 環境変数; PATH <35>:                   プロセス管理.       (line  543)
* 環境変数; PATH <36>:                   プロセス管理.       (line  631)
* 環境変数; PATH <37>:                   プロセス管理.       (line  633)
* 環境変数; PATH <38>:                   プロセス管理.       (line  635)
* 環境変数; PATH <39>:                   雑多なシステム情報. (line  137)
* 環境変数; PATH <40>:                   Popen コンストラクター.
                                                             (line   35)
* 環境変数; PATH <41>:                   webbrowser --- 便利なウェブブラウザコントローラー.
                                                             (line  235)
* 環境変数; PATH <42>:                   仮想環境のしくみ.   (line   15)
* 環境変数; PATH <43>:                   仮想環境のしくみ.   (line   61)
* 環境変数; PATH <44>:                   仮想環境のしくみ.   (line   66)
* 環境変数; PATH <45>:                   site --- サイト固有の設定フック.
                                                             (line   63)
* 環境変数; PATH <46>:                   Python の埋め込み<2>.
                                                             (line   26)
* 環境変数; PATH <47>:                   Python の埋め込み<2>.
                                                             (line   34)
* 環境変数; PATH <48>:                   Python のスクリプトを Unix で実行可能にするにはどうしますか？.
                                                             (line   20)
* 環境変数; PATH <49>:                   Python のスクリプトを Unix で実行可能にするにはどうしますか？.
                                                             (line   26)
* 環境変数; PATHEXT:                     その他の改善<2>.    (line   30)
* 環境変数; PATHEXT <1>:                 Library<37>.        (line  138)
* 環境変数; PATHEXT <2>:                 インストーラの GUI なしでインストールする.
                                                             (line   78)
* 環境変数; PATHEXT <3>:                 インストーラの GUI なしでインストールする.
                                                             (line   83)
* 環境変数; PATHEXT <4>:                 Python を構成する<2>.
                                                             (line    8)
* 環境変数; PATHEXT <5>:                 ディレクトリとファイルの操作.
                                                             (line  442)
* 環境変数; PIP_USER:                    Windows<40>.        (line  102)
* 環境変数; PROFILE_TASK:                Build<14>.          (line   13)
* 環境変数; PROFILE_TASK <1>:            パフォーマンスに関するオプション.
                                                             (line   12)
* 環境変数; PROFILE_TASK <2>:            パフォーマンスに関するオプション.
                                                             (line   35)
* 環境変数; PURIFY:                      Compiler flags.     (line  130)
* 環境変数; PY_BUILTIN_MODULE_CFLAGS:    Compiler flags.     (line  121)
* 環境変数; PY_CFLAGS:                   Compiler flags.     (line   94)
* 環境変数; PY_CFLAGS_NODIST:            Compiler flags.     (line   99)
* 環境変数; PY_CORE_CFLAGS:              Compiler flags.     (line  115)
* 環境変数; PY_CORE_LDFLAGS:             Linker flags.       (line   83)
* 環境変数; PY_CPPFLAGS:                 Preprocessor flags. (line   26)
* 環境変数; PY_LDFLAGS:                  Linker flags.       (line   73)
* 環境変数; PY_LDFLAGS_NODIST:           Linker flags.       (line   77)
* 環境変数; PY_PYTHON:                   デフォルトのPythonバージョンのカスタマイズ.
                                                             (line   15)
* 環境変数; PY_STDMODULE_CFLAGS:         Compiler flags.     (line  106)
* 環境変数; PYLAUNCHER_ALLOW_INSTALL:    Windows<7>.         (line   24)
* 環境変数; PYLAUNCHER_ALLOW_INSTALL <1>: Windows<21>.       (line   15)
* 環境変数; PYLAUNCHER_ALLOW_INSTALL <2>: Install on demand. (line    6)
* 環境変数; PYLAUNCHER_ALWAYS_INSTALL:   Install on demand.  (line   12)
* 環境変数; PYLAUNCHER_DEBUG:            診断.               (line    6)
* 環境変数; PYLAUNCHER_DRYRUN:           Dry Run.            (line    6)
* 環境変数; PYLAUNCHER_DRYRUN <1>:       Install on demand.  (line   14)
* 環境変数; PYLAUNCHER_NO_SEARCH_PATH:   シェバン shebang 行.
                                                             (line   66)
* 環境変数; PYTHON_BASIC_REPL:           A better interactive interpreter.
                                                             (line   27)
* 環境変数; PYTHON_BASIC_REPL <1>:       Library.            (line  234)
* 環境変数; PYTHON_BASIC_REPL <2>:       Library.            (line  238)
* 環境変数; PYTHON_BASIC_REPL <3>:       Core and Builtins<7>.
                                                             (line   55)
* 環境変数; PYTHON_BASIC_REPL <4>:       対話モード<2>.      (line   22)
* 環境変数; PYTHON_BASIC_REPL <5>:       環境変数.           (line  520)
* 環境変数; PYTHON_COLORS:               Summary -- Release Highlights.
                                                             (line   57)
* 環境変数; PYTHON_COLORS <1>:           Improved error messages.
                                                             (line    8)
* 環境変数; PYTHON_COLORS <2>:           doctest.            (line    7)
* 環境変数; PYTHON_COLORS <3>:           色の制御.           (line   20)
* 環境変数; PYTHON_COLORS <4>:           環境変数.           (line  512)
* 環境変数; PYTHON_CPU_COUNT:            os.                 (line   11)
* 環境変数; PYTHON_CPU_COUNT <1>:        その他のオプション. (line  367)
* 環境変数; PYTHON_CPU_COUNT <2>:        環境変数.           (line  488)
* 環境変数; PYTHON_CPU_COUNT <3>:        雑多なシステム情報. (line   45)
* 環境変数; PYTHON_CPU_COUNT <4>:        雑多なシステム情報. (line   66)
* 環境変数; PYTHON_CPU_COUNT <5>:        その他<3>.          (line   32)
* 環境変数; PYTHON_CPU_COUNT <6>:        PyConfig.           (line  496)
* 環境変数; PYTHON_DOM:                  モジュールコンテンツ<4>.
                                                             (line   22)
* 環境変数; PYTHON_FROZEN_MODULES:       Other Language Changes.
                                                             (line   46)
* 環境変数; PYTHON_FROZEN_MODULES <1>:   Core and Builtins<14>.
                                                             (line  105)
* 環境変数; PYTHON_FROZEN_MODULES <2>:   その他のオプション. (line  338)
* 環境変数; PYTHON_FROZEN_MODULES <3>:   環境変数.           (line  498)
* 環境変数; PYTHON_GIL:                  Free-threaded CPython.
                                                             (line   22)
* 環境変数; PYTHON_GIL <1>:              Free-threaded CPython.
                                                             (line   38)
* 環境変数; PYTHON_GIL <2>:              Core and Builtins<4>.
                                                             (line   40)
* 環境変数; PYTHON_GIL <3>:              その他のオプション. (line  385)
* 環境変数; PYTHON_GIL <4>:              環境変数.           (line  537)
* 環境変数; PYTHON_GIL <5>:              The global interpreter lock in free-threaded Python.
                                                             (line    7)
* 環境変数; PYTHON_GIL <6>:              用語集<2>.          (line  672)
* 環境変数; PYTHON_HISTORY:              Other Language Changes.
                                                             (line   57)
* 環境変数; PYTHON_HISTORY <1>:          Library<12>.        (line  544)
* 環境変数; PYTHON_HISTORY <2>:          環境変数.           (line  529)
* 環境変数; PYTHON_PERF_JIT_SUPPORT:     Other Language Changes.
                                                             (line   52)
* 環境変数; PYTHON_PERF_JIT_SUPPORT <1>: その他のオプション. (line  357)
* 環境変数; PYTHON_PERF_JIT_SUPPORT <2>: 環境変数.           (line  475)
* 環境変数; PYTHON_PERF_JIT_SUPPORT <3>: PyConfig.           (line  876)
* 環境変数; PYTHON_PERF_JIT_SUPPORT <4>: PyConfig.           (line  879)
* 環境変数; PYTHON_PERF_JIT_SUPPORT <5>: How to work without frame pointers.
                                                             (line   14)
* 環境変数; PYTHON_PRESITE:              その他のオプション. (line  379)
* 環境変数; PYTHON_PRESITE <1>:          デバッグモード変数. (line   25)
* 環境変数; PYTHON_PRESITE <2>:          PyConfig.           (line  776)
* 環境変数; PYTHON_PRESITE=package.module: Core and Builtins<14>.
                                                             (line  154)
* 環境変数; PYTHONASYNCIODEBUG:          環境変数.           (line  277)
* 環境変数; PYTHONASYNCIODEBUG <1>:      デバッグモードの有効化.
                                                             (line   10)
* 環境変数; PYTHONASYNCIODEBUG <2>:      デバッグモード.     (line   11)
* 環境変数; PYTHONASYNCIODEBUG <3>:      Effects of the Python Development Mode.
                                                             (line   65)
* 環境変数; PYTHONBREAKPOINT:            PEP 553 組み込みの breakpoint.
                                                             (line   13)
* 環境変数; PYTHONBREAKPOINT <1>:        環境変数.           (line   80)
* 環境変数; PYTHONBREAKPOINT <2>:        組み込み関数.       (line  158)
* 環境変数; PYTHONBREAKPOINT <3>:        sys --- システム固有のパラメーターと関数.
                                                             (line  244)
* 環境変数; PYTHONBREAKPOINT <4>:        sys --- システム固有のパラメーターと関数.
                                                             (line  258)
* 環境変数; PYTHONBREAKPOINT <5>:        sys --- システム固有のパラメーターと関数.
                                                             (line  263)
* 環境変数; PYTHONCASEOK:                Python API の変更<2>.
                                                             (line   29)
* 環境変数; PYTHONCASEOK <1>:            PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み.
                                                             (line   17)
* 環境変数; PYTHONCASEOK <2>:            Library<41>.        (line  144)
* 環境変数; PYTHONCASEOK <3>:            環境変数.           (line  130)
* 環境変数; PYTHONCASEOK <4>:            組み込み関数.       (line 2222)
* 環境変数; PYTHONCOERCECLOCALE:         PEP 538 レガシーな C ロケールの抑圧.
                                                             (line   12)
* 環境変数; PYTHONCOERCECLOCALE <1>:     環境変数.           (line  365)
* 環境変数; PYTHONCOERCECLOCALE <2>:     一般的なオプション. (line   89)
* 環境変数; PYTHONCOERCECLOCALE <3>:     Python UTF-8 Mode.  (line   57)
* 環境変数; PYTHONCOERCECLOCALE <4>:     Python Configuration.
                                                             (line   15)
* 環境変数; PYTHONDEBUG:                 その他のオプション. (line   38)
* 環境変数; PYTHONDEBUG <1>:             環境変数.           (line   93)
* 環境変数; PYTHONDEBUG <2>:             Python Debug Build. (line   20)
* 環境変数; PYTHONDEBUG <3>:             グローバルな設定変数.
                                                             (line   39)
* 環境変数; PYTHONDEBUG <4>:             PyConfig.           (line  667)
* 環境変数; PYTHONDEVMODE:               Python Development Mode -X dev.
                                                             (line    6)
* 環境変数; PYTHONDEVMODE <1>:           その他のオプション. (line  297)
* 環境変数; PYTHONDEVMODE <2>:           環境変数.           (line  422)
* 環境変数; PYTHONDEVMODE <3>:           Python 開発モード.  (line   14)
* 環境変数; PYTHONDEVMODE <4>:           PyConfig.           (line  295)
* 環境変数; PYTHONDONTWRITEBYTECODE:     インタプリタの変更<2>.
                                                             (line   15)
* 環境変数; PYTHONDONTWRITEBYTECODE <1>: 新しいモジュールと改良されたモジュール<2>.
                                                             (line  637)
* 環境変数; PYTHONDONTWRITEBYTECODE <2>: その他のオプション. (line   19)
* 環境変数; PYTHONDONTWRITEBYTECODE <3>: 環境変数.           (line  136)
* 環境変数; PYTHONDONTWRITEBYTECODE <4>: sys --- システム固有のパラメーターと関数.
                                                             (line  329)
* 環境変数; PYTHONDONTWRITEBYTECODE <5>: グローバルな設定変数.
                                                             (line   53)
* 環境変数; PYTHONDONTWRITEBYTECODE <6>: PyConfig.           (line  953)
* 環境変数; PYTHONDONTWRITEBYTECODE <7>: pyc ファイルを作るにはどうしますか？.
                                                             (line   19)
* 環境変数; PYTHONDUMPREFS:              デバッグビルドとリリースビルドのABI 共通化.
                                                             (line   15)
* 環境変数; PYTHONDUMPREFS <1>:          Build<47>.          (line   54)
* 環境変数; PYTHONDUMPREFS <2>:          デバッグモード変数. (line    6)
* 環境変数; PYTHONDUMPREFS <3>:          Debug options.      (line   22)
* 環境変数; PYTHONDUMPREFS <4>:          Debug options.      (line   24)
* 環境変数; PYTHONDUMPREFS <5>:          PyConfig.           (line  306)
* 環境変数; PYTHONDUMPREFSFILE:          Core and Builtins<31>.
                                                             (line  154)
* 環境変数; PYTHONDUMPREFSFILE <1>:      デバッグモード変数. (line   14)
* 環境変数; PYTHONEXECUTABLE:            環境変数.           (line  217)
* 環境変数; PYTHONEXECUTABLE <1>:        PyConfig.           (line  702)
* 環境変数; PYTHONFAULTHANDLER:          faulthandler<4>.    (line   12)
* 環境変数; PYTHONFAULTHANDLER <1>:      その他のオプション. (line  259)
* 環境変数; PYTHONFAULTHANDLER <2>:      環境変数.           (line  245)
* 環境変数; PYTHONFAULTHANDLER <3>:      Effects of the Python Development Mode.
                                                             (line   59)
* 環境変数; PYTHONFAULTHANDLER <4>:      faulthandler --- Python トレースバックをダンプする.
                                                             (line   15)
* 環境変数; PYTHONFAULTHANDLER <5>:      PyConfig.           (line  344)
* 環境変数; PYTHONHASHSEED:              組み込みの関数と型. (line   18)
* 環境変数; PYTHONHASHSEED <1>:          Python コードの移植.
                                                             (line    7)
* 環境変数; PYTHONHASHSEED <2>:          Core and Builtins<58>.
                                                             (line   30)
* 環境変数; PYTHONHASHSEED <3>:          その他のオプション. (line  122)
* 環境変数; PYTHONHASHSEED <4>:          その他のオプション. (line  138)
* 環境変数; PYTHONHASHSEED <5>:          環境変数.           (line  151)
* 環境変数; PYTHONHASHSEED <6>:          環境変数.           (line  156)
* 環境変数; PYTHONHASHSEED <7>:          基本的なカスタマイズ.
                                                             (line  312)
* 環境変数; PYTHONHASHSEED <8>:          グローバルな設定変数.
                                                             (line   79)
* 環境変数; PYTHONHASHSEED <9>:          グローバルな設定変数.
                                                             (line   82)
* 環境変数; PYTHONHASHSEED <10>:         PyConfig.           (line  414)
* 環境変数; PYTHONHOME:                  Deprecated C APIs.  (line   26)
* 環境変数; PYTHONHOME <1>:              Pending Removal in Python 3 15<2>.
                                                             (line   38)
* 環境変数; PYTHONHOME <2>:              Pending Removal in Python 3 15<4>.
                                                             (line   38)
* 環境変数; PYTHONHOME <3>:              概要 -- リリースハイライト<6>.
                                                             (line  106)
* 環境変数; PYTHONHOME <4>:              その他のオプション. (line   47)
* 環境変数; PYTHONHOME <5>:              環境変数.           (line   10)
* 環境変数; PYTHONHOME <6>:              環境変数.           (line   18)
* 環境変数; PYTHONHOME <7>:              環境変数.           (line   20)
* 環境変数; PYTHONHOME <8>:              環境変数.           (line   37)
* 環境変数; PYTHONHOME <9>:              モジュールの検索.   (line   28)
* 環境変数; PYTHONHOME <10>:             モジュールの検索.   (line   43)
* 環境変数; PYTHONHOME <11>:             モジュールの検索.   (line   78)
* 環境変数; PYTHONHOME <12>:             test support script_helper --- Utilities for the Python execution tests.
                                                             (line   25)
* 環境変数; PYTHONHOME <13>:             sys path モジュール検索パスの初期化.
                                                             (line   30)
* 環境変数; PYTHONHOME <14>:             仮想環境.           (line   14)
* 環境変数; PYTHONHOME <15>:             Python の埋め込み<2>.
                                                             (line   34)
* 環境変数; PYTHONHOME <16>:             Python の埋め込み<2>.
                                                             (line   41)
* 環境変数; PYTHONHOME <17>:             グローバルな設定変数.
                                                             (line   94)
* 環境変数; PYTHONHOME <18>:             プロセスワイドのパラメータ.
                                                             (line  292)
* 環境変数; PYTHONHOME <19>:             プロセスワイドのパラメータ.
                                                             (line  307)
* 環境変数; PYTHONHOME <20>:             プロセスワイドのパラメータ.
                                                             (line  316)
* 環境変数; PYTHONHOME <21>:             PyConfig.           (line  422)
* 環境変数; PYTHONHOME <22>:             PyConfig.           (line  424)
* 環境変数; PYTHONHOME <23>:             Pending Removal in Python 3 15<6>.
                                                             (line   38)
* 環境変数; PYTHONINSPECT:               その他の変更と修正<2>.
                                                             (line   13)
* 環境変数; PYTHONINSPECT <1>:           その他のオプション. (line   60)
* 環境変数; PYTHONINSPECT <2>:           環境変数.           (line  102)
* 環境変数; PYTHONINSPECT <3>:           グローバルな設定変数.
                                                             (line  111)
* 環境変数; PYTHONINSPECT <4>:           PyConfig.           (line  449)
* 環境変数; PYTHONINTMAXSTRDIGITS:       Core and Builtins<23>.
                                                             (line  106)
* 環境変数; PYTHONINTMAXSTRDIGITS <1>:   その他のオプション. (line  281)
* 環境変数; PYTHONINTMAXSTRDIGITS <2>:   環境変数.           (line  168)
* 環境変数; PYTHONINTMAXSTRDIGITS <3>:   上限値を設定する.   (line    9)
* 環境変数; PYTHONINTMAXSTRDIGITS <4>:   上限値を設定する.   (line   16)
* 環境変数; PYTHONINTMAXSTRDIGITS <5>:   sys --- システム固有のパラメーターと関数.
                                                             (line 1136)
* 環境変数; PYTHONINTMAXSTRDIGITS <6>:   PyConfig.           (line  480)
* 環境変数; PYTHONIOENCODING:            その他の改善<2>.    (line   75)
* 環境変数; PYTHONIOENCODING <1>:        インタプリタの変更<2>.
                                                             (line   22)
* 環境変数; PYTHONIOENCODING <2>:        環境変数.           (line  176)
* 環境変数; PYTHONIOENCODING <3>:        環境変数.           (line  402)
* 環境変数; PYTHONIOENCODING <4>:        Python UTF-8 Mode.  (line   29)
* 環境変数; PYTHONIOENCODING <5>:        sys --- システム固有のパラメーターと関数.
                                                             (line 1808)
* 環境変数; PYTHONIOENCODING <6>:        PyConfig.           (line  836)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING: New Deprecations. (line  138)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <1>: Pending removal in Python 3 16.
                                                             (line   50)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <2>: Pending removal in Python 3 16<2>.
                                                             (line   50)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <3>: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更.
                                                             (line   18)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <4>: Windows<9>.   (line   37)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <5>: 環境変数.     (line  338)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <6>: sys --- システム固有のパラメーターと関数.
                                                             (line 1750)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <7>: sys --- システム固有のパラメーターと関数.
                                                             (line 1761)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <8>: sys --- システム固有のパラメーターと関数.
                                                             (line 1767)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <9>: グローバルな設定変数.
                                                             (line  153)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <10>: PyPreConfig. (line  123)
* 環境変数; PYTHONLEGACYWINDOWSFSENCODING <11>: Pending removal in Python 3 16<3>.
                                                             (line   50)
* 環境変数; PYTHONLEGACYWINDOWSSTDIO:    PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更.
                                                             (line   12)
* 環境変数; PYTHONLEGACYWINDOWSSTDIO <1>: 環境変数.          (line  190)
* 環境変数; PYTHONLEGACYWINDOWSSTDIO <2>: 環境変数.          (line  352)
* 環境変数; PYTHONLEGACYWINDOWSSTDIO <3>: sys --- システム固有のパラメーターと関数.
                                                             (line 1812)
* 環境変数; PYTHONLEGACYWINDOWSSTDIO <4>: グローバルな設定変数.
                                                             (line  171)
* 環境変数; PYTHONLEGACYWINDOWSSTDIO <5>: PyConfig.          (line  533)
* 環境変数; PYTHONMALLOC:                PYTHONMALLOC 環境変数.
                                                             (line    6)
* 環境変数; PYTHONMALLOC <1>:            C API の変更<9>.    (line    9)
* 環境変数; PYTHONMALLOC <2>:            Core and Builtins<78>.
                                                             (line   90)
* 環境変数; PYTHONMALLOC <3>:            環境変数.           (line  284)
* 環境変数; PYTHONMALLOC <4>:            環境変数.           (line  329)
* 環境変数; PYTHONMALLOC <5>:            パフォーマンスに関するオプション.
                                                             (line  109)
* 環境変数; PYTHONMALLOC <6>:            パフォーマンスに関するオプション.
                                                             (line  116)
* 環境変数; PYTHONMALLOC <7>:            Effects of the Python Development Mode.
                                                             (line   46)
* 環境変数; PYTHONMALLOC <8>:            Effects of the Python Development Mode.
                                                             (line   50)
* 環境変数; PYTHONMALLOC <9>:            概要<4>.            (line   75)
* 環境変数; PYTHONMALLOC <10>:           Default Memory Allocators.
                                                             (line   26)
* 環境変数; PYTHONMALLOC <11>:           Debug hooks on the Python memory allocators.
                                                             (line   11)
* 環境変数; PYTHONMALLOC <12>:           pymalloc アロケータ.
                                                             (line   27)
* 環境変数; PYTHONMALLOCSTATS:           Core and Builtins<78>.
                                                             (line   96)
* 環境変数; PYTHONMALLOCSTATS <1>:       環境変数.           (line  323)
* 環境変数; PYTHONMALLOCSTATS <2>:       PyConfig.           (line  549)
* 環境変数; PYTHONMALLOCSTATS <3>:       概要<4>.            (line   78)
* 環境変数; PYTHONNODEBUGRANGES:         PEP 657 トレースバックのエラー位置の詳細化.
                                                             (line   61)
* 環境変数; PYTHONNODEBUGRANGES <1>:     その他のオプション. (line  326)
* 環境変数; PYTHONNODEBUGRANGES <2>:     環境変数.           (line  452)
* 環境変数; PYTHONNODEBUGRANGES <3>:     Methods on code objects.
                                                             (line   40)
* 環境変数; PYTHONNODEBUGRANGES <4>:     PyConfig.           (line  248)
* 環境変数; PYTHONNOUSERSITE:            PEP 370 ユーザごとの site-packages ディレクトリ.
                                                             (line   30)
* 環境変数; PYTHONNOUSERSITE <1>:        その他のオプション. (line  150)
* 環境変数; PYTHONNOUSERSITE <2>:        環境変数.           (line  194)
* 環境変数; PYTHONNOUSERSITE <3>:        モジュールの内容<5>.
                                                             (line   15)
* 環境変数; PYTHONNOUSERSITE <4>:        グローバルな設定変数.
                                                             (line  205)
* 環境変数; PYTHONNOUSERSITE <5>:        PyConfig.           (line  906)
* 環境変数; PYTHONOPTIMIZE:              その他のオプション. (line   80)
* 環境変数; PYTHONOPTIMIZE <1>:          環境変数.           (line   74)
* 環境変数; PYTHONOPTIMIZE <2>:          グローバルな設定変数.
                                                             (line  216)
* 環境変数; PYTHONOPTIMIZE <3>:          PyConfig.           (line  617)
* 環境変数; PYTHONPATH:                  'python' コマンドの挙動の変更<2>.
                                                             (line    7)
* 環境変数; PYTHONPATH <1>:              'python' コマンドの挙動の変更<2>.
                                                             (line    9)
* 環境変数; PYTHONPATH <2>:              モジュール検索パス. (line   16)
* 環境変数; PYTHONPATH <3>:              標準モジュール.     (line   31)
* 環境変数; PYTHONPATH <4>:              標準モジュール.     (line   32)
* 環境変数; PYTHONPATH <5>:              その他のオプション. (line   46)
* 環境変数; PYTHONPATH <6>:              環境変数.           (line   23)
* 環境変数; PYTHONPATH <7>:              環境変数.           (line   31)
* 環境変数; PYTHONPATH <8>:              環境変数.           (line   38)
* 環境変数; PYTHONPATH <9>:              環境変数.           (line   42)
* 環境変数; PYTHONPATH <10>:             補足 環境変数の設定.
                                                             (line   36)
* 環境変数; PYTHONPATH <11>:             モジュールの検索.   (line   15)
* 環境変数; PYTHONPATH <12>:             モジュールの検索.   (line   36)
* 環境変数; PYTHONPATH <13>:             モジュールの検索.   (line   77)
* 環境変数; PYTHONPATH <14>:             パスエントリ・ファインダー.
                                                             (line   22)
* 環境変数; PYTHONPATH <15>:             test support script_helper --- Utilities for the Python execution tests.
                                                             (line   26)
* 環境変数; PYTHONPATH <16>:             sys --- システム固有のパラメーターと関数.
                                                             (line 1296)
* 環境変数; PYTHONPATH <17>:             sys --- システム固有のパラメーターと関数.
                                                             (line 1302)
* 環境変数; PYTHONPATH <18>:             sys path モジュール検索パスの初期化.
                                                             (line   14)
* 環境変数; PYTHONPATH <19>:             sys path モジュール検索パスの初期化.
                                                             (line   18)
* 環境変数; PYTHONPATH <20>:             C および C++ 拡張のビルド.
                                                             (line    9)
* 環境変数; PYTHONPATH <21>:             Python の埋め込み<2>.
                                                             (line   35)
* 環境変数; PYTHONPATH <22>:             Python の埋め込み<2>.
                                                             (line   42)
* 環境変数; PYTHONPATH <23>:             グローバルな設定変数.
                                                             (line   93)
* 環境変数; PYTHONPATH <24>:             PyConfig.           (line  582)
* 環境変数; PYTHONPERFSUPPORT:           Other Language Changes<2>.
                                                             (line   85)
* 環境変数; PYTHONPERFSUPPORT <1>:       その他のオプション. (line  346)
* 環境変数; PYTHONPERFSUPPORT <2>:       環境変数.           (line  463)
* 環境変数; PYTHONPERFSUPPORT <3>:       How to enable perf profiling support.
                                                             (line    7)
* 環境変数; PYTHONPLATLIBDIR:            Core and Builtins<39>.
                                                             (line  274)
* 環境変数; PYTHONPLATLIBDIR <1>:        環境変数.           (line   54)
* 環境変数; PYTHONPLATLIBDIR <2>:        sys path モジュール検索パスの初期化.
                                                             (line   51)
* 環境変数; PYTHONPLATLIBDIR <3>:        PyConfig.           (line  561)
* 環境変数; PYTHONPROFILEIMPORTTIME:     その他の言語変更<5>.
                                                             (line   47)
* 環境変数; PYTHONPROFILEIMPORTTIME <1>: Core and Builtins<60>.
                                                             (line   66)
* 環境変数; PYTHONPROFILEIMPORTTIME <2>: その他のオプション. (line  290)
* 環境変数; PYTHONPROFILEIMPORTTIME <3>: 環境変数.           (line  269)
* 環境変数; PYTHONPROFILEIMPORTTIME <4>: PyConfig.           (line  434)
* 環境変数; PYTHONPYCACHEPREFIX:         コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム.
                                                             (line    8)
* 環境変数; PYTHONPYCACHEPREFIX <1>:     Core and Builtins<51>.
                                                             (line  402)
* 環境変数; PYTHONPYCACHEPREFIX <2>:     その他のオプション. (line  310)
* 環境変数; PYTHONPYCACHEPREFIX <3>:     環境変数.           (line  142)
* 環境変数; PYTHONPYCACHEPREFIX <4>:     sys --- システム固有のパラメーターと関数.
                                                             (line  376)
* 環境変数; PYTHONPYCACHEPREFIX <5>:     PyConfig.           (line  724)
* 環境変数; PYTHONREGRTEST_UNICODE_GUARD: Tests<21>.         (line   13)
* 環境変数; PYTHONSAFEPATH:              概要 -- リリースハイライト.
                                                             (line   27)
* 環境変数; PYTHONSAFEPATH <1>:          その他の言語変更.   (line   37)
* 環境変数; PYTHONSAFEPATH <2>:          Security<16>.       (line    6)
* 環境変数; PYTHONSAFEPATH <3>:          その他のオプション. (line  108)
* 環境変数; PYTHONSAFEPATH <4>:          環境変数.           (line   46)
* 環境変数; PYTHONSAFEPATH <5>:          sys --- システム固有のパラメーターと関数.
                                                             (line 1314)
* 環境変数; PYTHONSAFEPATH <6>:          セキュリティで考慮すべき点<6>.
                                                             (line   47)
* 環境変数; PYTHONSAFEPATH <7>:          PyConfig.           (line  165)
* 環境変数; PYTHONSTARTUP:               sys<12>.            (line   16)
* 環境変数; PYTHONSTARTUP <1>:           sys<12>.            (line   21)
* 環境変数; PYTHONSTARTUP <2>:           IDLE<37>.           (line  176)
* 環境変数; PYTHONSTARTUP <3>:           IDLE<41>.           (line    9)
* 環境変数; PYTHONSTARTUP <4>:           IDLE<47>.           (line    9)
* 環境変数; PYTHONSTARTUP <5>:           対話モード用の起動時実行ファイル.
                                                             (line    7)
* 環境変数; PYTHONSTARTUP <6>:           その他のオプション. (line   56)
* 環境変数; PYTHONSTARTUP <7>:           環境変数.           (line   61)
* 環境変数; PYTHONSTARTUP <8>:           環境変数.           (line  116)
* 環境変数; PYTHONSTARTUP <9>:           使用例<2>.          (line    9)
* 環境変数; PYTHONSTARTUP <10>:          asyncio --- 非同期 I/O.
                                                             (line   78)
* 環境変数; PYTHONSTARTUP <11>:          Startup and Code Execution.
                                                             (line    6)
* 環境変数; PYTHONSTARTUP <12>:          sys --- システム固有のパラメーターと関数.
                                                             (line 1148)
* 環境変数; PYTHONSTARTUP <13>:          readline の設定.    (line   11)
* 環境変数; PYTHONTRACEMALLOC:           その他のオプション. (line  276)
* 環境変数; PYTHONTRACEMALLOC <1>:       環境変数.           (line  256)
* 環境変数; PYTHONTRACEMALLOC <2>:       tracemalloc --- メモリ割り当ての追跡.
                                                             (line   23)
* 環境変数; PYTHONTRACEMALLOC <3>:       tracemalloc --- メモリ割り当ての追跡.
                                                             (line   30)
* 環境変数; PYTHONTRACEMALLOC <4>:       関数<11>.           (line   93)
* 環境変数; PYTHONTRACEMALLOC <5>:       PyConfig.           (line  864)
* 環境変数; PYTHONTZPATH:                Environment configuration.
                                                             (line   11)
* 環境変数; PYTHONTZPATH <1>:            例外と警告.         (line   14)
* 環境変数; PYTHONUNBUFFERED:            Core and Builtins<44>.
                                                             (line  107)
* 環境変数; PYTHONUNBUFFERED <1>:        その他のオプション. (line  170)
* 環境変数; PYTHONUNBUFFERED <2>:        環境変数.           (line  119)
* 環境変数; PYTHONUNBUFFERED <3>:        sys --- システム固有のパラメーターと関数.
                                                             (line 1819)
* 環境変数; PYTHONUNBUFFERED <4>:        グローバルな設定変数.
                                                             (line  244)
* 環境変数; PYTHONUNBUFFERED <5>:        PyConfig.           (line  212)
* 環境変数; PYTHONUOPS:                  Core and Builtins<15>.
                                                             (line   27)
* 環境変数; PYTHONUOPS <1>:              Core and Builtins<15>.
                                                             (line  179)
* 環境変数; PYTHONUOPS <2>:              Core and Builtins<15>.
                                                             (line  258)
* 環境変数; PYTHONUOPS <3>:              Core and Builtins<15>.
                                                             (line  317)
* 環境変数; PYTHONUOPS <4>:              Core and Builtins<15>.
                                                             (line  382)
* 環境変数; PYTHONUSERBASE:              PEP 370 ユーザごとの site-packages ディレクトリ.
                                                             (line   23)
* 環境変数; PYTHONUSERBASE <1>:          環境変数.           (line  205)
* 環境変数; PYTHONUSERBASE <2>:          モジュールの内容<5>.
                                                             (line   41)
* 環境変数; PYTHONUSERBASE <3>:          モジュールの内容<5>.
                                                             (line   67)
* 環境変数; PYTHONUSERSITE:              test support script_helper --- Utilities for the Python execution tests.
                                                             (line   26)
* 環境変数; PYTHONUTF8:                  PEP 540 強制 UTF-8 実行モード.
                                                             (line    6)
* 環境変数; PYTHONUTF8 <1>:              その他のオプション. (line  304)
* 環境変数; PYTHONUTF8 <2>:              環境変数.           (line  412)
* 環境変数; PYTHONUTF8 <3>:              環境変数.           (line  431)
* 環境変数; PYTHONUTF8 <4>:              UTF-8 モード.       (line   18)
* 環境変数; PYTHONUTF8 <5>:              Python UTF-8 Mode.  (line   52)
* 環境変数; PYTHONUTF8 <6>:              Python UTF-8 Mode.  (line   54)
* 環境変数; PYTHONUTF8 <7>:              sys --- システム固有のパラメーターと関数.
                                                             (line 1810)
* 環境変数; PYTHONUTF8 <8>:              PyPreConfig.        (line  152)
* 環境変数; PYTHONUTF8 <9>:              Python Configuration.
                                                             (line   14)
* 環境変数; PYTHONVERBOSE:               その他のオプション. (line  186)
* 環境変数; PYTHONVERBOSE <1>:           環境変数.           (line  124)
* 環境変数; PYTHONVERBOSE <2>:           グローバルな設定変数.
                                                             (line  261)
* 環境変数; PYTHONVERBOSE <3>:           PyConfig.           (line  923)
* 環境変数; PYTHONWARNDEFAULTENCODING:   Optional EncodingWarning and encoding="locale" option.
                                                             (line   19)
* 環境変数; PYTHONWARNDEFAULTENCODING <1>: Library<32>.      (line   45)
* 環境変数; PYTHONWARNDEFAULTENCODING <2>: その他のオプション.
                                                             (line  316)
* 環境変数; PYTHONWARNDEFAULTENCODING <3>: 環境変数.         (line  442)
* 環境変数; PYTHONWARNDEFAULTENCODING <4>: Opt-in EncodingWarning.
                                                             (line    9)
* 環境変数; PYTHONWARNINGS:              warnings<3>.        (line   21)
* 環境変数; PYTHONWARNINGS <1>:          その他の言語変更<10>.
                                                             (line  158)
* 環境変数; PYTHONWARNINGS <2>:          Deprecation Warnings の扱いの変更.
                                                             (line   24)
* 環境変数; PYTHONWARNINGS <3>:          インタプリタの変更. (line    6)
* 環境変数; PYTHONWARNINGS <4>:          Documentation<17>.  (line   67)
* 環境変数; PYTHONWARNINGS <5>:          その他のオプション. (line  240)
* 環境変数; PYTHONWARNINGS <6>:          環境変数.           (line  223)
* 環境変数; PYTHONWARNINGS <7>:          Effects of the Python Development Mode.
                                                             (line   30)
* 環境変数; PYTHONWARNINGS <8>:          警告フィルタ.       (line   46)
* 環境変数; PYTHONWARNINGS <9>:          警告フィルタ.       (line   56)
* 環境変数; PYTHONWARNINGS <10>:         Describing Warning Filters.
                                                             (line    7)
* 環境変数; PYTHONWARNINGS <11>:         Describing Warning Filters.
                                                             (line   21)
* 環境変数; PYTHONWARNINGS <12>:         デフォルトの警告フィルタ.
                                                             (line    7)
* 環境変数; PYTHONWARNINGS <13>:         PyConfig.           (line  942)
* 環境変数; SOURCE_DATE_EPOCH:           py_compile<3>.      (line    7)
* 環境変数; SOURCE_DATE_EPOCH <1>:       Library<50>.        (line  452)
* 環境変数; SOURCE_DATE_EPOCH <2>:       Build<55>.          (line   15)
* 環境変数; SOURCE_DATE_EPOCH <3>:       py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   66)
* 環境変数; SOURCE_DATE_EPOCH <4>:       py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   83)
* 環境変数; SOURCE_DATE_EPOCH <5>:       py_compile --- Python ソースファイルをコンパイルする.
                                                             (line   87)
* 環境変数; SOURCE_DATE_EPOCH <6>:       コマンドラインでの使用<2>.
                                                             (line   87)
* 環境変数; SSLKEYLOGFILE:               コンテキストの作成. (line   34)
* 環境変数; SSLKEYLOGFILE <1>:           コンテキストの作成. (line   83)
* 環境変数; SystemRoot:                  Popen コンストラクター.
                                                             (line  306)
* 環境変数; TEMP:                        Redirection of local data registry and temporary paths.
                                                             (line    6)
* 環境変数; TEMP <1>:                    tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  326)
* 環境変数; TERM:                        関数<6>.            (line  470)
* 環境変数; TERM <1>:                    関数<6>.            (line  495)
* 環境変数; TMP:                         tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  328)
* 環境変数; TMPDIR:                      Tests<20>.          (line   68)
* 環境変数; TMPDIR <1>:                  tempfile --- 一時ファイルやディレクトリの作成.
                                                             (line  324)
* 環境変数; TZ:                          関数<5>.            (line  618)
* 環境変数; TZ <1>:                      関数<5>.            (line  619)
* 環境変数; TZ <2>:                      関数<5>.            (line  627)
* 環境変数; TZ <3>:                      関数<5>.            (line  631)
* 環境変数; TZ <4>:                      関数<5>.            (line  633)
* 環境変数; TZ <5>:                      関数<5>.            (line  696)
* 環境変数; USER:                        getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   42)
* 環境変数; USERNAME:                    os path --- 一般的なパス名操作.
                                                             (line  149)
* 環境変数; USERNAME <1>:                プロセスのパラメーター.
                                                             (line  235)
* 環境変数; USERNAME <2>:                getpass --- 可搬性のあるパスワード入力機構.
                                                             (line   42)
* 環境変数; USERPROFILE:                 os path<4>.         (line   14)
* 環境変数; USERPROFILE <1>:             Python API の変更<3>.
                                                             (line  116)
* 環境変数; USERPROFILE <2>:             Windows<38>.        (line   15)
* 環境変数; USERPROFILE <3>:             os path --- 一般的なパス名操作.
                                                             (line  146)
* 環境変数;削除:                         プロセスのパラメーター.
                                                             (line  583)
* 環境変数;設定:                         プロセスのパラメーター.
                                                             (line  348)
* 監査イベント:                          デバッグとプロファイル.
                                                             (line   11)
* 直列化;オブジェクト:                   pickle --- Python オブジェクトの直列化.
                                                             (line    8)
* 真理値;value:                          真理値判定.         (line    6)
* 空の;list:                             リスト表示.         (line    6)
* 空の;tuple:                            変更不能なシーケンス immutable sequence.
                                                             (line   30)
* 空の;tuple <1>:                        丸括弧形式 parenthesized form.
                                                             (line   14)
* 空白:                                  インデント.         (line    6)
* 空白;in printf-style formatting:       printf 形式の文字列書式化.
                                                             (line   67)
* 空白;in printf-style formatting <1>:   printf 形式での bytes の書式化.
                                                             (line   61)
* 空白;文字列のフォーマットで:           書式指定ミニ言語仕様.
                                                             (line   71)
* 空行:                                  空行.               (line    6)
* 算術:                                  数値型 int float complex.
                                                             (line   24)
* 算術;変換:                             算術変換 arithmetic conversion.
                                                             (line    6)
* 終了モデル:                            例外<2>.            (line   20)
* 組み込み;types:                        組み込み型.         (line    9)
* 組み込み;メソッド:                     組み込みメソッド built-in method.
                                                             (line    6)
* 組み込みメソッド;call:                 呼び出し call.      (line  140)
* 組み込み関数;__import__:               モジュールのインポート<2>.
                                                             (line   30)
* 組み込み関数;abs:                      数値型をエミュレートする.
                                                             (line  113)
* 組み込み関数;abs <1>:                  数値型プロトコル number protocol.
                                                             (line   92)
* 組み込み関数;ascii:                    オブジェクトプロトコル object protocol.
                                                             (line  337)
* 組み込み関数;bytes:                    基本的なカスタマイズ.
                                                             (line  144)
* 組み込み関数;bytes <1>:                オブジェクトプロトコル object protocol.
                                                             (line  358)
* 組み込み関数;call:                     呼び出し call.      (line  140)
* 組み込み関数;chr:                      変更不能なシーケンス immutable sequence.
                                                             (line   16)
* 組み込み関数;divmod:                   数値型をエミュレートする.
                                                             (line   26)
* 組み込み関数;divmod <1>:               数値型をエミュレートする.
                                                             (line   56)
* 組み込み関数;divmod <2>:               数値型プロトコル number protocol.
                                                             (line   66)
* 組み込み関数;eval:                     global 文.          (line   27)
* 組み込み関数;eval <1>:                 式入力.             (line    6)
* 組み込み関数;eval <2>:                 コードオブジェクト<2>.
                                                             (line   17)
* 組み込み関数;eval <3>:                 関数<4>.            (line   87)
* 組み込み関数;eval <4>:                 PrettyPrinter オブジェクト.
                                                             (line   66)
* 組み込み関数;exec:                     global 文.          (line   27)
* 組み込み関数;exec <1>:                 組み込み関数.       (line  623)
* 組み込み関数;exec <2>:                 コードオブジェクト<2>.
                                                             (line   17)
* 組み込み関数;hash:                     基本的なカスタマイズ.
                                                             (line  238)
* 組み込み関数;hash <1>:                 イミュータブルなシーケンス型.
                                                             (line    6)
* 組み込み関数;hash <2>:                 オブジェクトプロトコル object protocol.
                                                             (line  410)
* 組み込み関数;hash <3>:                 PyTypeObject スロット.
                                                             (line  331)
* 組み込み関数;help:                     OSへのインターフェース.
                                                             (line   20)
* 組み込み関数;id:                       オブジェクト、値、および型.
                                                             (line   13)
* 組み込み関数;int:                      数値型をエミュレートする.
                                                             (line  120)
* 組み込み関数;int <1>:                  数値型 int float complex.
                                                             (line   24)
* 組み込み関数;int <2>:                  数値型プロトコル number protocol.
                                                             (line  239)
* 組み込み関数;len:                      シーケンス型 sequence.
                                                             (line    6)
* 組み込み関数;len <1>:                  集合型<2>.          (line    6)
* 組み込み関数;len <2>:                  マッピング型 mapping.
                                                             (line    6)
* 組み込み関数;len <3>:                  コンテナをエミュレートする.
                                                             (line   41)
* 組み込み関数;len <4>:                  共通のシーケンス演算.
                                                             (line   18)
* 組み込み関数;len <5>:                  マッピング型 --- dict.
                                                             (line    6)
* 組み込み関数;len <6>:                  オブジェクトプロトコル object protocol.
                                                             (line  455)
* 組み込み関数;len <7>:                  シーケンス型プロトコル sequence protocol.
                                                             (line   16)
* 組み込み関数;len <8>:                  マップ型プロトコル mapping protocol.
                                                             (line   19)
* 組み込み関数;len <9>:                  リストオブジェクト. (line   41)
* 組み込み関数;len <10>:                 辞書オブジェクト dictionary object.
                                                             (line  221)
* 組み込み関数;len <11>:                 Set オブジェクト.   (line   96)
* 組み込み関数;max:                      共通のシーケンス演算.
                                                             (line   18)
* 組み込み関数;min:                      共通のシーケンス演算.
                                                             (line   18)
* 組み込み関数;open:                     ファイルを読み書きする.
                                                             (line    6)
* 組み込み関数;open <1>:                 I/O オブジェクト ファイルオブジェクトの別名.
                                                             (line    6)
* 組み込み関数;ord:                      変更不能なシーケンス immutable sequence.
                                                             (line   16)
* 組み込み関数;pow:                      数値型をエミュレートする.
                                                             (line   26)
* 組み込み関数;pow <1>:                  数値型をエミュレートする.
                                                             (line   26)
* 組み込み関数;pow <2>:                  数値型をエミュレートする.
                                                             (line   56)
* 組み込み関数;pow <3>:                  数値型をエミュレートする.
                                                             (line   67)
* 組み込み関数;pow <4>:                  数値型プロトコル number protocol.
                                                             (line   73)
* 組み込み関数;pow <5>:                  数値型プロトコル number protocol.
                                                             (line  192)
* 組み込み関数;print:                    基本的なカスタマイズ.
                                                             (line  149)
* 組み込み関数;range:                    for 文<2>.          (line   37)
* 組み込み関数;repr:                     式文 expression statement.
                                                             (line   16)
* 組み込み関数;repr <1>:                 ファイナライズとメモリ解放.
                                                             (line   90)
* 組み込み関数;repr <2>:                 オブジェクトプロトコル object protocol.
                                                             (line  326)
* 組み込み関数;repr <3>:                 PyTypeObject スロット.
                                                             (line  268)
* 組み込み関数;round:                    数値型をエミュレートする.
                                                             (line  143)
* 組み込み関数;slice:                    スライス slice オブジェクト.
                                                             (line    6)
* 組み込み関数;slice <1>:                Python バイトコード命令.
                                                             (line 1124)
* 組み込み関数;tuple:                    シーケンス型プロトコル sequence protocol.
                                                             (line  113)
* 組み込み関数;tuple <1>:                リストオブジェクト. (line  163)
* 組み込み関数;type:                     オブジェクト、値、および型.
                                                             (line   13)
* 組み込み関数;type <1>:                 メタクラス.         (line    6)
* 組み込み関数;type <2>:                 型オブジェクト.     (line    6)
* 組み込み関数;type <3>:                 オブジェクトプロトコル object protocol.
                                                             (line  437)
* 組み込み関数;クラスメソッド:           Implementing functions and methods.
                                                             (line  197)
* 組み込み関数;コンパイル:               global 文.          (line   27)
* 組み込み関数;コンパイル <1>:           コードオブジェクト<2>.
                                                             (line    6)
* 組み込み関数;コンパイル <2>:           標準的なインタプリタ型.
                                                             (line   57)
* 組み込み関数;コンパイル <3>:           モジュールのインポート<2>.
                                                             (line  129)
* 組み込み関数;浮動小数点数:             数値型をエミュレートする.
                                                             (line  120)
* 組み込み関数;浮動小数点数 <1>:         数値型 int float complex.
                                                             (line   24)
* 組み込み関数;浮動小数点数 <2>:         数値型プロトコル number protocol.
                                                             (line  245)
* 組み込み関数;複素数:                   数値型をエミュレートする.
                                                             (line  120)
* 組み込み関数;複素数 <1>:               数値型 int float complex.
                                                             (line   24)
* 組み込み関数;静的メソッド:             Implementing functions and methods.
                                                             (line  204)
* 結合;演算:                             共通のシーケンス演算.
                                                             (line   18)
* 繰り返し;演算:                         共通のシーケンス演算.
                                                             (line   18)
* 自由;variable:                         名前の束縛.         (line   47)
* 虚数リテラル:                          数値リテラル.       (line    6)
* 行構造:                                行構造.             (line    6)
* 行継続:                                明示的な行継続.     (line    6)
* 行連結:                                論理行 logical line.
                                                             (line    6)
* 行連結 <1>:                            明示的な行継続.     (line    6)
* 補間, 文字列 (%):                      printf 形式の文字列書式化.
                                                             (line    6)
* 補間;bytearray (%):                    printf 形式での bytes の書式化.
                                                             (line    6)
* 補間;bytes (%):                        printf 形式での bytes の書式化.
                                                             (line    6)
* 複素数;number:                         numbers Complex complex.
                                                             (line    6)
* 複素数リテラル:                        数値リテラル.       (line    6)
* 要素の選択:                            シーケンス型 sequence.
                                                             (line    6)
* 記法:                                  本マニュアルにおける表記法.
                                                             (line    6)
* 設定;ファイル:                         configparser --- 設定ファイルのパーサー.
                                                             (line    8)
* 評価;順序:                             評価順序.           (line    6)
* 認識されなかったエスケープシーケンス:  Escape sequences.   (line  108)
* 論理行:                                論理行 logical line.
                                                             (line    6)
* 識別子:                                識別子 identifier およびキーワード keyword.
                                                             (line    6)
* 識別子 <1>:                            識別子 identifier、または名前 name.
                                                             (line    6)
* 連鎖;比較:                             比較.               (line   19)
* 連鎖;比較 <1>:                         比較<2>.            (line    6)
* 関数:                                  用語集<2>.          (line  551)
* 関数;annotations:                      関数のアノテーション.
                                                             (line    6)
* 関数;annotations <1>:                  関数定義.           (line  104)
* 関数;call:                             呼び出し可能型 callable type.
                                                             (line    6)
* 関数;call <1>:                         呼び出し call.      (line  129)
* 関数;call <2>:                         呼び出し call.      (line  140)
* 関数;definition:                       return 文.          (line    6)
* 関数;definition <1>:                   関数定義.           (line    6)
* 関数;name:                             関数定義.           (line    6)
* 関数;name <1>:                         関数定義.           (line    6)
* 関数;ジェネレータ:                     yield 文.           (line    6)
* 関数;引数 (argument):                  呼び出し可能型 callable type.
                                                             (line    6)
* 関数呼び出し:                          呼び出し可能型 callable type.
                                                             (line    6)
* 集合;内包表記:                         集合表示.           (line    6)
* 集合;表示:                             集合表示.           (line    6)

                       



Tag Table:
Node: Top353
Ref: contents doc561
Ref: 11b561
Node: What's New in Python277609
Ref: whatsnew/index doc277718
Ref: 11c277718
Ref: whatsnew/index python-documentation-contents277718
Ref: 11d277718
Ref: whatsnew/index what-s-new-in-python277718
Ref: 11e277718
Ref: whatsnew/index whatsnew-index277718
Ref: 11f277718
Node: What's New In Python 3 13279254
Ref: whatsnew/3 13 doc279370
Ref: 120279370
Ref: whatsnew/3 13 what-s-new-in-python-3-13279370
Ref: 121279370
Ref: What's New In Python 3 13-Footnote-1280152
Node: Summary -- Release Highlights280194
Ref: whatsnew/3 13 summary-release-highlights280306
Ref: 123280306
Ref: whatsnew/3 13 whatsnew313-better-interactive-interpreter280608
Ref: 124280608
Ref: whatsnew/3 13 whatsnew313-free-threaded-cpython280678
Ref: 125280678
Ref: whatsnew/3 13 whatsnew313-jit-compiler280732
Ref: 126280732
Ref: whatsnew/3 13 whatsnew313-pep594281206
Ref: 129281206
Ref: Summary -- Release Highlights-Footnote-1287113
Ref: Summary -- Release Highlights-Footnote-2287155
Ref: Summary -- Release Highlights-Footnote-3287197
Ref: Summary -- Release Highlights-Footnote-4287239
Ref: Summary -- Release Highlights-Footnote-5287281
Ref: Summary -- Release Highlights-Footnote-6287323
Ref: Summary -- Release Highlights-Footnote-7287365
Ref: Summary -- Release Highlights-Footnote-8287395
Ref: Summary -- Release Highlights-Footnote-9287435
Ref: Summary -- Release Highlights-Footnote-10287477
Ref: Summary -- Release Highlights-Footnote-11287520
Ref: Summary -- Release Highlights-Footnote-12287563
Ref: Summary -- Release Highlights-Footnote-13287606
Ref: Summary -- Release Highlights-Footnote-14287649
Ref: Summary -- Release Highlights-Footnote-15287692
Ref: Summary -- Release Highlights-Footnote-16287742
Ref: Summary -- Release Highlights-Footnote-17287785
Ref: Summary -- Release Highlights-Footnote-18287835
Ref: Summary -- Release Highlights-Footnote-19287885
Node: New Features287928
Ref: whatsnew/3 13 new-features288071
Ref: 14d288071
Node: A better interactive interpreter288416
Ref: whatsnew/3 13 a-better-interactive-interpreter288529
Ref: 14e288529
Ref: A better interactive interpreter-Footnote-1289842
Ref: A better interactive interpreter-Footnote-2289868
Node: Improved error messages289924
Ref: whatsnew/3 13 improved-error-messages290067
Ref: 156290067
Ref: whatsnew/3 13 whatsnew313-improved-error-messages290067
Ref: 12d290067
Ref: Improved error messages-Footnote-1292511
Ref: Improved error messages-Footnote-2292541
Ref: Improved error messages-Footnote-3292574
Ref: Improved error messages-Footnote-4292630
Ref: Improved error messages-Footnote-5292685
Node: Free-threaded CPython292741
Ref: whatsnew/3 13 free-threaded-cpython292893
Ref: 157292893
Ref: Free-threaded CPython-Footnote-1295881
Ref: Free-threaded CPython-Footnote-2295923
Node: An experimental just-in-time JIT compiler295976
Ref: whatsnew/3 13 an-experimental-just-in-time-jit-compiler296142
Ref: 160296142
Ref: An experimental just-in-time JIT compiler-Footnote-1298741
Ref: An experimental just-in-time JIT compiler-Footnote-2298813
Node: Defined mutation semantics for locals298855
Ref: whatsnew/3 13 defined-mutation-semantics-for-locals299028
Ref: 162299028
Ref: whatsnew/3 13 whatsnew313-locals-semantics299028
Ref: 128299028
Ref: Defined mutation semantics for locals-Footnote-1301639
Ref: Defined mutation semantics for locals-Footnote-2301681
Ref: Defined mutation semantics for locals-Footnote-3301723
Node: Support for mobile platforms301778
Ref: whatsnew/3 13 support-for-mobile-platforms301901
Ref: 16a301901
Ref: whatsnew/3 13 whatsnew313-platform-support301901
Ref: 14b301901
Ref: Support for mobile platforms-Footnote-1302942
Ref: Support for mobile platforms-Footnote-2302984
Ref: Support for mobile platforms-Footnote-3303026
Ref: Support for mobile platforms-Footnote-4303082
Ref: Support for mobile platforms-Footnote-5303124
Ref: Support for mobile platforms-Footnote-6303166
Ref: Support for mobile platforms-Footnote-7303222
Ref: Support for mobile platforms-Footnote-8303264
Node: Other Language Changes303306
Ref: whatsnew/3 13 other-language-changes303431
Ref: 16b303431
Ref: Other Language Changes-Footnote-1308261
Ref: Other Language Changes-Footnote-2308316
Ref: Other Language Changes-Footnote-3308372
Ref: Other Language Changes-Footnote-4308428
Ref: Other Language Changes-Footnote-5308484
Ref: Other Language Changes-Footnote-6308540
Ref: Other Language Changes-Footnote-7308596
Ref: Other Language Changes-Footnote-8308645
Ref: Other Language Changes-Footnote-9308701
Ref: Other Language Changes-Footnote-10308756
Ref: Other Language Changes-Footnote-11308813
Ref: Other Language Changes-Footnote-12308870
Ref: Other Language Changes-Footnote-13308927
Ref: Other Language Changes-Footnote-14308984
Ref: Other Language Changes-Footnote-15309041
Ref: Other Language Changes-Footnote-16309098
Ref: Other Language Changes-Footnote-17309155
Ref: Other Language Changes-Footnote-18309211
Node: New Modules309268
Ref: whatsnew/3 13 new-modules309397
Ref: 180309397
Ref: New Modules-Footnote-1309621
Node: Improved Modules309677
Ref: whatsnew/3 13 improved-modules309797
Ref: 181309797
Node: argparse310458
Ref: whatsnew/3 13 argparse310533
Ref: 182310533
Ref: argparse-Footnote-1310856
Node: array310911
Ref: whatsnew/3 13 array310998
Ref: 184310998
Ref: array-Footnote-1311434
Ref: array-Footnote-2311489
Node: ast311545
Ref: whatsnew/3 13 ast311631
Ref: 188311631
Ref: ast-Footnote-1313191
Ref: ast-Footnote-2313247
Ref: ast-Footnote-3313303
Ref: ast-Footnote-4313359
Node: asyncio313415
Ref: whatsnew/3 13 asyncio313502
Ref: 18e313502
Ref: asyncio-Footnote-1316408
Ref: asyncio-Footnote-2316463
Ref: asyncio-Footnote-3316519
Ref: asyncio-Footnote-4316575
Ref: asyncio-Footnote-5316631
Ref: asyncio-Footnote-6316687
Ref: asyncio-Footnote-7316742
Ref: asyncio-Footnote-8316798
Node: base64316854
Ref: whatsnew/3 13 base64316948
Ref: 1a3316948
Ref: base64-Footnote-1317243
Ref: base64-Footnote-2317283
Node: compileall317338
Ref: whatsnew/3 13 compileall317443
Ref: 1a5317443
Ref: compileall-Footnote-1317735
Node: concurrent futures317791
Ref: whatsnew/3 13 concurrent-futures317902
Ref: 1a8317902
Ref: concurrent futures-Footnote-1318210
Node: configparser318266
Ref: whatsnew/3 13 configparser318371
Ref: 1a9318371
Ref: configparser-Footnote-1318701
Node: copy318756
Ref: whatsnew/3 13 copy318849
Ref: 1ab318849
Ref: copy-Footnote-1319766
Node: ctypes319822
Ref: whatsnew/3 13 ctypes319906
Ref: 1b5319906
Ref: ctypes-Footnote-1320839
Ref: ctypes-Footnote-2320895
Node: dbm320951
Ref: whatsnew/3 13 dbm321034
Ref: 1b8321034
Ref: dbm-Footnote-1321490
Ref: dbm-Footnote-2321546
Node: dis321602
Ref: whatsnew/3 13 dis321686
Ref: 1bb321686
Ref: dis-Footnote-1322440
Ref: dis-Footnote-2322496
Node: doctest322552
Ref: whatsnew/3 13 doctest322638
Ref: 1bf322638
Ref: whatsnew/3 13 whatsnew313-doctest322638
Ref: 12f322638
Ref: doctest-Footnote-1323281
Ref: doctest-Footnote-2323311
Ref: doctest-Footnote-3323344
Ref: doctest-Footnote-4323400
Node: email323456
Ref: whatsnew/3 13 email323548
Ref: 1c3323548
Ref: email-Footnote-1324680
Ref: email-Footnote-2324736
Ref: email-Footnote-3324792
Node: fractions324848
Ref: whatsnew/3 13 fractions324937
Ref: 1c7324937
Ref: fractions-Footnote-1325255
Node: glob325311
Ref: whatsnew/3 13 glob325404
Ref: 1ca325404
Ref: glob-Footnote-1325653
Node: importlib325708
Ref: whatsnew/3 13 importlib325794
Ref: 1cc325794
Ref: importlib-Footnote-1326695
Ref: importlib-Footnote-2326751
Node: io326807
Ref: whatsnew/3 13 io326898
Ref: 1d5326898
Ref: io-Footnote-1327324
Node: ipaddress327379
Ref: whatsnew/3 13 ipaddress327470
Ref: 1db327470
Ref: ipaddress-Footnote-1327929
Ref: ipaddress-Footnote-2327985
Node: itertools328041
Ref: whatsnew/3 13 itertools328137
Ref: 1e1328137
Ref: itertools-Footnote-1328437
Node: marshal328493
Ref: whatsnew/3 13 marshal328584
Ref: 1e4328584
Ref: marshal-Footnote-1328919
Node: math328975
Ref: whatsnew/3 13 math329066
Ref: 1e5329066
Ref: math-Footnote-1329557
Node: mimetypes329612
Ref: whatsnew/3 13 mimetypes329700
Ref: 1e7329700
Ref: mimetypes-Footnote-1330017
Node: mmap330072
Ref: whatsnew/3 13 mmap330171
Ref: 1eb330171
Ref: mmap-Footnote-1330984
Ref: mmap-Footnote-2331040
Ref: mmap-Footnote-3331096
Node: multiprocessing331151
Ref: whatsnew/3 13 multiprocessing331243
Ref: 1ef331243
Ref: multiprocessing-Footnote-1331547
Node: os331603
Ref: whatsnew/3 13 os331698
Ref: 1f0331698
Ref: os-Footnote-1334164
Ref: os-Footnote-2334220
Ref: os-Footnote-3334276
Ref: os-Footnote-4334330
Ref: os-Footnote-5334386
Ref: os-Footnote-6334441
Ref: os-Footnote-7334497
Ref: os-Footnote-8334552
Ref: os-Footnote-9334608
Ref: os-Footnote-10334664
Node: os path334721
Ref: whatsnew/3 13 os-path334808
Ref: 203334808
Ref: os path-Footnote-1335431
Ref: os path-Footnote-2335486
Ref: os path-Footnote-3335541
Node: pathlib335596
Ref: whatsnew/3 13 pathlib335684
Ref: 207335684
Ref: pathlib-Footnote-1337198
Ref: pathlib-Footnote-2337253
Ref: pathlib-Footnote-3337309
Ref: pathlib-Footnote-4337364
Ref: pathlib-Footnote-5337419
Ref: pathlib-Footnote-6337474
Ref: pathlib-Footnote-7337530
Node: pdb337586
Ref: whatsnew/3 13 pdb337672
Ref: 214337672
Ref: pdb-Footnote-1338807
Ref: pdb-Footnote-2338863
Ref: pdb-Footnote-3338919
Ref: pdb-Footnote-4338975
Ref: pdb-Footnote-5339031
Node: queue339087
Ref: whatsnew/3 13 queue339172
Ref: 21a339172
Ref: queue-Footnote-1339407
Node: random339463
Ref: whatsnew/3 13 random339547
Ref: 21d339547
Ref: random-Footnote-1339721
Node: re339777
Ref: whatsnew/3 13 re339862
Ref: 21e339862
Node: shutil340021
Ref: whatsnew/3 13 shutil340104
Ref: 220340104
Ref: shutil-Footnote-1340332
Node: site340387
Ref: whatsnew/3 13 site340475
Ref: 222340475
Ref: site-Footnote-1340726
Node: sqlite3340782
Ref: whatsnew/3 13 sqlite3340867
Ref: 224340867
Ref: sqlite3-Footnote-1341308
Ref: sqlite3-Footnote-2341364
Node: ssl341419
Ref: whatsnew/3 13 ssl341510
Ref: 229341510
Ref: ssl-Footnote-1342201
Ref: ssl-Footnote-2342260
Node: statistics342316
Ref: whatsnew/3 13 statistics342410
Ref: 22a342410
Ref: statistics-Footnote-1342919
Ref: statistics-Footnote-2342975
Node: subprocess343031
Ref: whatsnew/3 13 subprocess343125
Ref: 22d343125
Ref: whatsnew/3 13 whatsnew313-subprocess343125
Ref: 22e343125
Ref: subprocess-Footnote-1344065
Node: sys344121
Ref: whatsnew/3 13 sys344213
Ref: 230344213
Ref: sys-Footnote-1344502
Node: tempfile344557
Ref: whatsnew/3 13 tempfile344643
Ref: 232344643
Ref: tempfile-Footnote-1344988
Ref: tempfile-Footnote-2345043
Node: time345099
Ref: whatsnew/3 13 time345189
Ref: 233345189
Ref: time-Footnote-1345837
Ref: time-Footnote-2345892
Node: tkinter345947
Ref: whatsnew/3 13 tkinter346038
Ref: 236346038
Ref: tkinter-Footnote-1348302
Ref: tkinter-Footnote-2348357
Ref: tkinter-Footnote-3348412
Ref: tkinter-Footnote-4348467
Ref: tkinter-Footnote-5348522
Ref: tkinter-Footnote-6348577
Ref: tkinter-Footnote-7348632
Ref: tkinter-Footnote-8348688
Ref: tkinter-Footnote-9348744
Node: traceback348800
Ref: whatsnew/3 13 traceback348892
Ref: 23b348892
Ref: traceback-Footnote-1349622
Ref: traceback-Footnote-2349678
Node: types349734
Ref: whatsnew/3 13 types349825
Ref: 241349825
Ref: types-Footnote-1350150
Node: typing350206
Ref: whatsnew/3 13 typing350299
Ref: 242350299
Ref: typing-Footnote-1351284
Ref: typing-Footnote-2351326
Ref: typing-Footnote-3351368
Ref: typing-Footnote-4351424
Ref: typing-Footnote-5351480
Ref: typing-Footnote-6351536
Node: unicodedata351591
Ref: whatsnew/3 13 unicodedata351683
Ref: 249351683
Ref: unicodedata-Footnote-1351871
Ref: unicodedata-Footnote-2351927
Node: venv351983
Ref: whatsnew/3 13 venv352077
Ref: 24a352077
Ref: venv-Footnote-1352569
Node: warnings352625
Ref: whatsnew/3 13 warnings352711
Ref: 24d352711
Ref: warnings-Footnote-1353175
Ref: warnings-Footnote-2353217
Node: xml353273
Ref: whatsnew/3 13 xml353364
Ref: 24f353364
Ref: xml-Footnote-1354130
Ref: xml-Footnote-2354186
Ref: xml-Footnote-3354242
Node: zipimport354297
Ref: whatsnew/3 13 zipimport354371
Ref: 255354371
Ref: zipimport-Footnote-1354575
Ref: zipimport-Footnote-2354637
Node: Optimizations354692
Ref: whatsnew/3 13 optimizations354825
Ref: 256354825
Ref: Optimizations-Footnote-1356031
Ref: Optimizations-Footnote-2356087
Ref: Optimizations-Footnote-3356143
Node: Removed Modules And APIs356199
Ref: whatsnew/3 13 removed-modules-and-apis356332
Ref: 258356332
Node: PEP 594 Remove "dead batteries" from the standard library356780
Ref: whatsnew/3 13 pep-594-remove-dead-batteries-from-the-standard-library356911
Ref: 259356911
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-1360793
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-2360835
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-3360879
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-4360923
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-5360964
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-6361006
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-7361052
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-8361098
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-9361140
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-10361187
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-11361231
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-12361276
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-13361324
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-14361366
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-15361408
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-16361452
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-17361497
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-18361545
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-19361591
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-20361637
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-21361681
Ref: PEP 594 Remove "dead batteries" from the standard library-Footnote-22361738
Node: 2to3361795
Ref: whatsnew/3 13 to3361943
Ref: 25f361943
Ref: 2to3-Footnote-1362170
Node: builtins362226
Ref: whatsnew/3 13 builtins362332
Ref: 260362332
Ref: builtins-Footnote-1363073
Ref: builtins-Footnote-2363128
Ref: builtins-Footnote-3363183
Node: configparser<2>363238
Ref: whatsnew/3 13 id3363358
Ref: 262363358
Ref: configparser<2>-Footnote-1363642
Node: importlib metadata363698
Ref: whatsnew/3 13 importlib-metadata363816
Ref: 263363816
Ref: importlib metadata-Footnote-1364073
Node: locale364129
Ref: whatsnew/3 13 locale364238
Ref: 266364238
Ref: locale-Footnote-1364501
Node: opcode364557
Ref: whatsnew/3 13 opcode364658
Ref: 267364658
Ref: opcode-Footnote-1365283
Ref: opcode-Footnote-2365339
Node: pathlib<2>365395
Ref: whatsnew/3 13 id4365495
Ref: 268365495
Ref: pathlib<2>-Footnote-1365773
Node: re<2>365828
Ref: whatsnew/3 13 id5365933
Ref: 269365933
Ref: re<2>-Footnote-1366197
Node: tkinter tix366253
Ref: whatsnew/3 13 tkinter-tix366354
Ref: 26a366354
Ref: tkinter tix-Footnote-1366629
Node: turtle366684
Ref: whatsnew/3 13 turtle366789
Ref: 26b366789
Ref: turtle-Footnote-1367059
Node: typing<2>367115
Ref: whatsnew/3 13 id6367217
Ref: 26c367217
Ref: typing<2>-Footnote-1367702
Ref: typing<2>-Footnote-2367757
Node: unittest367813
Ref: whatsnew/3 13 unittest367915
Ref: 26d367915
Ref: unittest-Footnote-1368616
Ref: unittest-Footnote-2368672
Node: urllib368728
Ref: whatsnew/3 13 urllib368831
Ref: 272368831
Ref: urllib-Footnote-1369436
Node: webbrowser369492
Ref: whatsnew/3 13 webbrowser369578
Ref: 276369578
Ref: webbrowser-Footnote-1370069
Ref: webbrowser-Footnote-2370125
Node: New Deprecations370181
Ref: whatsnew/3 13 new-deprecations370325
Ref: 278370325
Ref: New Deprecations-Footnote-1379004
Ref: New Deprecations-Footnote-2379059
Ref: New Deprecations-Footnote-3379114
Ref: New Deprecations-Footnote-4379170
Ref: New Deprecations-Footnote-5379226
Ref: New Deprecations-Footnote-6379281
Ref: New Deprecations-Footnote-7379337
Ref: New Deprecations-Footnote-8379393
Ref: New Deprecations-Footnote-9379448
Ref: New Deprecations-Footnote-10379504
Ref: New Deprecations-Footnote-11379561
Ref: New Deprecations-Footnote-12379618
Ref: New Deprecations-Footnote-13379674
Ref: New Deprecations-Footnote-14379730
Ref: New Deprecations-Footnote-15379786
Ref: New Deprecations-Footnote-16379843
Ref: New Deprecations-Footnote-17379899
Ref: New Deprecations-Footnote-18379956
Ref: New Deprecations-Footnote-19380013
Ref: New Deprecations-Footnote-20380070
Ref: New Deprecations-Footnote-21380126
Ref: New Deprecations-Footnote-22380183
Ref: New Deprecations-Footnote-23380240
Ref: New Deprecations-Footnote-24380297
Ref: New Deprecations-Footnote-25380354
Ref: New Deprecations-Footnote-26380411
Ref: New Deprecations-Footnote-27380468
Ref: New Deprecations-Footnote-28380525
Node: Pending Removal in Python 3 14380582
Ref: whatsnew/3 13 pending-removal-in-python-3-14380704
Ref: 298380704
Ref: Pending Removal in Python 3 14-Footnote-1385401
Ref: Pending Removal in Python 3 14-Footnote-2385456
Ref: Pending Removal in Python 3 14-Footnote-3385511
Ref: Pending Removal in Python 3 14-Footnote-4385566
Ref: Pending Removal in Python 3 14-Footnote-5385621
Ref: Pending Removal in Python 3 14-Footnote-6385677
Ref: Pending Removal in Python 3 14-Footnote-7385732
Ref: Pending Removal in Python 3 14-Footnote-8385787
Ref: Pending Removal in Python 3 14-Footnote-9385842
Ref: Pending Removal in Python 3 14-Footnote-10385898
Ref: Pending Removal in Python 3 14-Footnote-11385954
Ref: Pending Removal in Python 3 14-Footnote-12386010
Node: Pending Removal in Python 3 15386066
Ref: whatsnew/3 13 pending-removal-in-python-3-15386227
Ref: 2b6386227
Ref: Pending Removal in Python 3 15-Footnote-1389878
Ref: Pending Removal in Python 3 15-Footnote-2389933
Ref: Pending Removal in Python 3 15-Footnote-3389988
Ref: Pending Removal in Python 3 15-Footnote-4390043
Ref: Pending Removal in Python 3 15-Footnote-5390099
Ref: Pending Removal in Python 3 15-Footnote-6390141
Node: Pending removal in Python 3 16390197
Ref: whatsnew/3 13 pending-removal-in-python-3-16390362
Ref: 2c2390362
Ref: Pending removal in Python 3 16-Footnote-1392546
Node: Pending Removal in Future Versions392602
Ref: whatsnew/3 13 pending-removal-in-future-versions392728
Ref: 2c7392728
Ref: Pending Removal in Future Versions-Footnote-1399799
Ref: Pending Removal in Future Versions-Footnote-2399854
Ref: Pending Removal in Future Versions-Footnote-3399909
Ref: Pending Removal in Future Versions-Footnote-4399965
Ref: Pending Removal in Future Versions-Footnote-5400021
Ref: Pending Removal in Future Versions-Footnote-6400076
Node: CPython Bytecode Changes400131
Ref: whatsnew/3 13 cpython-bytecode-changes400264
Ref: 2eb400264
Ref: CPython Bytecode Changes-Footnote-1400705
Node: C API Changes400761
Ref: whatsnew/3 13 c-api-changes400891
Ref: 2ee400891
Node: New Features<2>401063
Ref: whatsnew/3 13 id7401151
Ref: 2ef401151
Ref: New Features<2>-Footnote-1412056
Ref: New Features<2>-Footnote-2412098
Ref: New Features<2>-Footnote-3412154
Ref: New Features<2>-Footnote-4412210
Ref: New Features<2>-Footnote-5412266
Ref: New Features<2>-Footnote-6412322
Ref: New Features<2>-Footnote-7412378
Ref: New Features<2>-Footnote-8412434
Ref: New Features<2>-Footnote-9412490
Ref: New Features<2>-Footnote-10412546
Ref: New Features<2>-Footnote-11412603
Ref: New Features<2>-Footnote-12412660
Ref: New Features<2>-Footnote-13412716
Ref: New Features<2>-Footnote-14412773
Ref: New Features<2>-Footnote-15412830
Ref: New Features<2>-Footnote-16412887
Ref: New Features<2>-Footnote-17412944
Ref: New Features<2>-Footnote-18413001
Ref: New Features<2>-Footnote-19413058
Ref: New Features<2>-Footnote-20413115
Ref: New Features<2>-Footnote-21413171
Ref: New Features<2>-Footnote-22413228
Ref: New Features<2>-Footnote-23413285
Ref: New Features<2>-Footnote-24413339
Ref: New Features<2>-Footnote-25413396
Ref: New Features<2>-Footnote-26413452
Ref: New Features<2>-Footnote-27413508
Ref: New Features<2>-Footnote-28413565
Ref: New Features<2>-Footnote-29413622
Ref: New Features<2>-Footnote-30413679
Ref: New Features<2>-Footnote-31413736
Ref: New Features<2>-Footnote-32413793
Node: Changed C APIs413850
Ref: whatsnew/3 13 changed-c-apis413968
Ref: 35b413968
Ref: Changed C APIs-Footnote-1416563
Ref: Changed C APIs-Footnote-2416618
Ref: Changed C APIs-Footnote-3416674
Ref: Changed C APIs-Footnote-4416730
Ref: Changed C APIs-Footnote-5416786
Ref: Changed C APIs-Footnote-6416828
Ref: Changed C APIs-Footnote-7416884
Ref: Changed C APIs-Footnote-8416940
Node: Limited C API Changes416996
Ref: whatsnew/3 13 limited-c-api-changes417113
Ref: 368417113
Ref: Limited C API Changes-Footnote-1417835
Ref: Limited C API Changes-Footnote-2417890
Ref: Limited C API Changes-Footnote-3417945
Ref: Limited C API Changes-Footnote-4418001
Node: Removed C APIs418057
Ref: whatsnew/3 13 removed-c-apis418177
Ref: 370418177
Ref: Removed C APIs-Footnote-1424540
Ref: Removed C APIs-Footnote-2424596
Ref: Removed C APIs-Footnote-3424651
Ref: Removed C APIs-Footnote-4424707
Ref: Removed C APIs-Footnote-5424749
Ref: Removed C APIs-Footnote-6424805
Ref: Removed C APIs-Footnote-7424861
Ref: Removed C APIs-Footnote-8424917
Ref: Removed C APIs-Footnote-9424970
Ref: Removed C APIs-Footnote-10425026
Ref: Removed C APIs-Footnote-11425069
Ref: Removed C APIs-Footnote-12425126
Ref: Removed C APIs-Footnote-13425183
Ref: Removed C APIs-Footnote-14425240
Node: Deprecated C APIs425297
Ref: whatsnew/3 13 deprecated-c-apis425387
Ref: 388425387
Ref: Deprecated C APIs-Footnote-1428004
Ref: Deprecated C APIs-Footnote-2428060
Ref: Deprecated C APIs-Footnote-3428102
Ref: Deprecated C APIs-Footnote-4428158
Ref: Deprecated C APIs-Footnote-5428213
Ref: Deprecated C APIs-Footnote-6428269
Ref: Deprecated C APIs-Footnote-7428322
Node: Pending Removal in Python 3 14<2>428378
Ref: whatsnew/3 13 id8428507
Ref: 39a428507
Ref: Pending Removal in Python 3 14<2>-Footnote-1431732
Ref: Pending Removal in Python 3 14<2>-Footnote-2431774
Ref: Pending Removal in Python 3 14<2>-Footnote-3431830
Node: Pending Removal in Python 3 15<2>431885
Ref: whatsnew/3 13 id9432060
Ref: 3c6432060
Node: Pending Removal in Future Versions<2>433359
Ref: whatsnew/3 13 id10433492
Ref: 3ca433492
Node: Build Changes435733
Ref: whatsnew/3 13 build-changes435861
Ref: 3e8435861
Ref: whatsnew/3 13 pythoncapi-compat-project435861
Ref: 3e9435861
Ref: Build Changes-Footnote-1438443
Ref: Build Changes-Footnote-2438485
Ref: Build Changes-Footnote-3438541
Ref: Build Changes-Footnote-4438583
Ref: Build Changes-Footnote-5438639
Ref: Build Changes-Footnote-6438681
Ref: Build Changes-Footnote-7438737
Ref: Build Changes-Footnote-8438779
Ref: Build Changes-Footnote-9438835
Ref: Build Changes-Footnote-10438890
Ref: Build Changes-Footnote-11438947
Ref: Build Changes-Footnote-12439004
Ref: Build Changes-Footnote-13439052
Ref: Build Changes-Footnote-14439109
Ref: Build Changes-Footnote-15439166
Ref: Build Changes-Footnote-16439223
Node: Porting to Python 3 13439279
Ref: whatsnew/3 13 porting-to-python-3-13439417
Ref: 12c439417
Node: Changes in the Python API439650
Ref: whatsnew/3 13 changes-in-the-python-api439763
Ref: 3ec439763
Ref: whatsnew/3 13 pep667-porting-notes-py439834
Ref: 168439834
Ref: Changes in the Python API-Footnote-1443369
Ref: Changes in the Python API-Footnote-2443411
Ref: Changes in the Python API-Footnote-3443453
Ref: Changes in the Python API-Footnote-4443495
Ref: Changes in the Python API-Footnote-5443537
Ref: Changes in the Python API-Footnote-6443593
Ref: Changes in the Python API-Footnote-7443649
Ref: Changes in the Python API-Footnote-8443704
Node: Changes in the C API443760
Ref: whatsnew/3 13 changes-in-the-c-api443873
Ref: 3f6443873
Ref: whatsnew/3 13 pep667-porting-notes-c446528
Ref: 169446528
Ref: Changes in the C API-Footnote-1448410
Ref: Changes in the C API-Footnote-2448466
Ref: Changes in the C API-Footnote-3448522
Ref: Changes in the C API-Footnote-4448578
Ref: Changes in the C API-Footnote-5448633
Node: Regression Test Changes448689
Ref: whatsnew/3 13 regression-test-changes448839
Ref: 3fa448839
Ref: Regression Test Changes-Footnote-1449280
Node: Notable changes in 3 13 1449336
Ref: whatsnew/3 13 notable-changes-in-3-13-1449455
Ref: 3fc449455
Node: sys<2>449547
Ref: whatsnew/3 13 id11449615
Ref: 3fd449615
Node: What's New In Python 3 12449864
Ref: whatsnew/3 12 doc450014
Ref: 3ff450014
Ref: whatsnew/3 12 what-s-new-in-python-3-12450014
Ref: 400450014
Ref: What's New In Python 3 12-Footnote-1450856
Node: Summary -- Release highlights450898
Ref: whatsnew/3 12 summary-release-highlights451013
Ref: 401451013
Ref: whatsnew/3 12 improved-error-messages452826
Ref: 40a452826
Ref: whatsnew/3 12 unittest-testcase-removed-aliases455643
Ref: 41b455643
Ref: Summary -- Release highlights-Footnote-1455682
Ref: Summary -- Release highlights-Footnote-2455730
Ref: Summary -- Release highlights-Footnote-3455772
Ref: Summary -- Release highlights-Footnote-4455814
Ref: Summary -- Release highlights-Footnote-5455873
Ref: Summary -- Release highlights-Footnote-6455952
Node: New Features<3>456007
Ref: whatsnew/3 12 new-features456165
Ref: 41c456165
Node: PEP 695 Type Parameter Syntax456740
Ref: whatsnew/3 12 pep-695-type-parameter-syntax456874
Ref: 41d456874
Ref: whatsnew/3 12 whatsnew312-pep695456874
Ref: 403456874
Ref: PEP 695 Type Parameter Syntax-Footnote-1459407
Ref: PEP 695 Type Parameter Syntax-Footnote-2459449
Ref: PEP 695 Type Parameter Syntax-Footnote-3459491
Ref: PEP 695 Type Parameter Syntax-Footnote-4459533
Node: PEP 701 Syntactic formalization of f-strings459589
Ref: whatsnew/3 12 pep-701-syntactic-formalization-of-f-strings459761
Ref: 425459761
Ref: whatsnew/3 12 whatsnew312-pep701459761
Ref: 407459761
Ref: PEP 701 Syntactic formalization of f-strings-Footnote-1464057
Ref: PEP 701 Syntactic formalization of f-strings-Footnote-2464099
Ref: PEP 701 Syntactic formalization of f-strings-Footnote-3464141
Ref: PEP 701 Syntactic formalization of f-strings-Footnote-4464183
Node: PEP 684 A Per-Interpreter GIL464239
Ref: whatsnew/3 12 pep-684-a-per-interpreter-gil464423
Ref: 427464423
Ref: whatsnew/3 12 whatsnew312-pep684464423
Ref: 408464423
Ref: PEP 684 A Per-Interpreter GIL-Footnote-1465518
Ref: PEP 684 A Per-Interpreter GIL-Footnote-2465560
Ref: PEP 684 A Per-Interpreter GIL-Footnote-3465602
Node: PEP 669 Low impact monitoring for CPython465658
Ref: whatsnew/3 12 pep-669-low-impact-monitoring-for-cpython465853
Ref: 429465853
Ref: whatsnew/3 12 whatsnew312-pep669465853
Ref: 409465853
Ref: PEP 669 Low impact monitoring for CPython-Footnote-1466412
Ref: PEP 669 Low impact monitoring for CPython-Footnote-2466454
Node: PEP 688 Making the buffer protocol accessible in Python466510
Ref: whatsnew/3 12 pep-688-making-the-buffer-protocol-accessible-in-python466706
Ref: 42a466706
Ref: whatsnew/3 12 whatsnew312-pep688466706
Ref: 40c466706
Ref: PEP 688 Making the buffer protocol accessible in Python-Footnote-1467349
Ref: PEP 688 Making the buffer protocol accessible in Python-Footnote-2467391
Node: PEP 709 Comprehension inlining467447
Ref: whatsnew/3 12 pep-709-comprehension-inlining467625
Ref: 42d467625
Ref: whatsnew/3 12 whatsnew312-pep709467625
Ref: 413467625
Ref: PEP 709 Comprehension inlining-Footnote-1469302
Ref: PEP 709 Comprehension inlining-Footnote-2469344
Node: Improved Error Messages469386
Ref: Improved Error Messages-Footnote-1471856
Ref: Improved Error Messages-Footnote-2471911
Ref: Improved Error Messages-Footnote-3471966
Ref: Improved Error Messages-Footnote-4472021
Node: New Features Related to Type Hints472076
Ref: whatsnew/3 12 new-features-related-to-type-hints472230
Ref: 42e472230
Ref: New Features Related to Type Hints-Footnote-1472666
Node: PEP 692 Using TypedDict for more precise **kwargs typing472708
Ref: whatsnew/3 12 pep-692-using-typeddict-for-more-precise-kwargs-typing472888
Ref: 42f472888
Ref: whatsnew/3 12 whatsnew312-pep692472888
Ref: 414472888
Ref: PEP 692 Using TypedDict for more precise **kwargs typing-Footnote-1473582
Ref: PEP 692 Using TypedDict for more precise **kwargs typing-Footnote-2473624
Ref: PEP 692 Using TypedDict for more precise **kwargs typing-Footnote-3473666
Ref: PEP 692 Using TypedDict for more precise **kwargs typing-Footnote-4473708
Node: PEP 698 Override Decorator for Static Typing473764
Ref: whatsnew/3 12 pep-698-override-decorator-for-static-typing473944
Ref: 430473944
Ref: whatsnew/3 12 whatsnew312-pep698473944
Ref: 416473944
Ref: PEP 698 Override Decorator for Static Typing-Footnote-1474921
Ref: PEP 698 Override Decorator for Static Typing-Footnote-2474963
Node: Other Language Changes<2>475019
Ref: whatsnew/3 12 other-language-changes475172
Ref: 431475172
Ref: Other Language Changes<2>-Footnote-1479858
Ref: Other Language Changes<2>-Footnote-2479913
Ref: Other Language Changes<2>-Footnote-3479968
Ref: Other Language Changes<2>-Footnote-4480023
Ref: Other Language Changes<2>-Footnote-5480065
Ref: Other Language Changes<2>-Footnote-6480121
Ref: Other Language Changes<2>-Footnote-7480163
Ref: Other Language Changes<2>-Footnote-8480218
Ref: Other Language Changes<2>-Footnote-9480274
Ref: Other Language Changes<2>-Footnote-10480329
Ref: Other Language Changes<2>-Footnote-11480385
Ref: Other Language Changes<2>-Footnote-12480441
Ref: Other Language Changes<2>-Footnote-13480498
Ref: Other Language Changes<2>-Footnote-14480555
Ref: Other Language Changes<2>-Footnote-15480611
Ref: Other Language Changes<2>-Footnote-16480654
Ref: Other Language Changes<2>-Footnote-17480710
Node: New Modules<2>480766
Ref: whatsnew/3 12 new-modules480904
Ref: 43f480904
Node: Improved Modules<2>480953
Ref: whatsnew/3 12 improved-modules481082
Ref: 440481082
Node: array<2>481707
Ref: whatsnew/3 12 array481790
Ref: 441481790
Ref: array<2>-Footnote-1482018
Node: asyncio<2>482073
Ref: whatsnew/3 12 asyncio482173
Ref: 442482173
Ref: asyncio<2>-Footnote-1484158
Ref: asyncio<2>-Footnote-2484213
Ref: asyncio<2>-Footnote-3484269
Ref: asyncio<2>-Footnote-4484325
Ref: asyncio<2>-Footnote-5484381
Ref: asyncio<2>-Footnote-6484436
Ref: asyncio<2>-Footnote-7484491
Ref: asyncio<2>-Footnote-8484546
Ref: asyncio<2>-Footnote-9484602
Ref: asyncio<2>-Footnote-10484658
Node: calendar484714
Ref: whatsnew/3 12 calendar484809
Ref: 44d484809
Ref: calendar-Footnote-1485061
Node: csv485117
Ref: whatsnew/3 12 csv485208
Ref: 450485208
Node: dis<2>485442
Ref: whatsnew/3 12 dis485537
Ref: 455485537
Ref: dis<2>-Footnote-1486147
Ref: dis<2>-Footnote-2486202
Node: fractions<2>486257
Ref: whatsnew/3 12 fractions486368
Ref: 458486368
Ref: fractions<2>-Footnote-1486590
Node: importlib resources486646
Ref: whatsnew/3 12 importlib-resources486758
Ref: 459486758
Ref: importlib resources-Footnote-1487130
Ref: importlib resources-Footnote-2487185
Node: inspect487241
Ref: whatsnew/3 12 inspect487353
Ref: 45c487353
Ref: inspect-Footnote-1488123
Ref: inspect-Footnote-2488178
Ref: inspect-Footnote-3488233
Node: itertools<2>488289
Ref: whatsnew/3 12 itertools488389
Ref: 462488389
Ref: itertools<2>-Footnote-1488654
Node: math<2>488709
Ref: whatsnew/3 12 math488807
Ref: 463488807
Ref: math<2>-Footnote-1489225
Ref: math<2>-Footnote-2489281
Node: os<2>489336
Ref: whatsnew/3 12 os489432
Ref: 466489432
Ref: os<2>-Footnote-1490777
Ref: os<2>-Footnote-2490832
Ref: os<2>-Footnote-3490887
Ref: os<2>-Footnote-4490943
Node: os path<2>490998
Ref: whatsnew/3 12 os-path491097
Ref: 46f491097
Ref: os path<2>-Footnote-1491462
Ref: os path<2>-Footnote-2491517
Node: pathlib<3>491573
Ref: whatsnew/3 12 pathlib491673
Ref: 472491673
Ref: pathlib<3>-Footnote-1492968
Ref: pathlib<3>-Footnote-2493023
Ref: pathlib<3>-Footnote-3493078
Node: pdb<2>493133
Ref: whatsnew/3 12 pdb493232
Ref: 47a493232
Ref: pdb<2>-Footnote-1493505
Node: random<2>493561
Ref: whatsnew/3 12 random493659
Ref: 47b493659
Ref: random<2>-Footnote-1493964
Ref: random<2>-Footnote-2494019
Node: shutil<2>494075
Ref: whatsnew/3 12 shutil494177
Ref: 47e494177
Ref: shutil<2>-Footnote-1495607
Ref: shutil<2>-Footnote-2495662
Ref: shutil<2>-Footnote-3495718
Ref: shutil<2>-Footnote-4495774
Ref: shutil<2>-Footnote-5495830
Node: sqlite3<2>495886
Ref: whatsnew/3 12 sqlite3495992
Ref: 481495992
Ref: sqlite3<2>-Footnote-1496939
Ref: sqlite3<2>-Footnote-2496994
Ref: sqlite3<2>-Footnote-3497036
Ref: sqlite3<2>-Footnote-4497091
Ref: sqlite3<2>-Footnote-5497147
Node: statistics<2>497203
Ref: whatsnew/3 12 statistics497306
Ref: 487497306
Ref: statistics<2>-Footnote-1497586
Node: sys<3>497641
Ref: whatsnew/3 12 sys497745
Ref: 489497745
Ref: sys<3>-Footnote-1499295
Ref: sys<3>-Footnote-2499351
Ref: sys<3>-Footnote-3499406
Ref: sys<3>-Footnote-4499462
Node: tempfile<2>499518
Ref: whatsnew/3 12 tempfile499618
Ref: 491499618
Ref: tempfile<2>-Footnote-1500010
Node: threading500065
Ref: whatsnew/3 12 threading500169
Ref: 493500169
Ref: threading-Footnote-1500518
Node: tkinter<2>500573
Ref: whatsnew/3 12 tkinter500674
Ref: 496500674
Ref: tkinter<2>-Footnote-1501170
Node: tokenize501225
Ref: whatsnew/3 12 tokenize501325
Ref: 497501325
Ref: tokenize-Footnote-1501682
Ref: tokenize-Footnote-2501724
Node: types<2>501780
Ref: whatsnew/3 12 types501879
Ref: 499501879
Ref: types<2>-Footnote-1502191
Node: typing<3>502247
Ref: whatsnew/3 12 typing502352
Ref: 49c502352
Ref: whatsnew/3 12 whatsnew-typing-py312502352
Ref: 49d502352
Ref: typing<3>-Footnote-1504923
Ref: typing<3>-Footnote-2504979
Ref: typing<3>-Footnote-3505034
Ref: typing<3>-Footnote-4505090
Ref: typing<3>-Footnote-5505146
Node: unicodedata<2>505201
Ref: whatsnew/3 12 unicodedata505309
Ref: 4a1505309
Ref: unicodedata<2>-Footnote-1505507
Node: unittest<2>505562
Ref: whatsnew/3 12 unittest505665
Ref: 4a2505665
Ref: unittest<2>-Footnote-1506449
Node: uuid506504
Ref: whatsnew/3 12 uuid506584
Ref: 4a3506584
Ref: uuid-Footnote-1506747
Node: Optimizations<2>506802
Ref: whatsnew/3 12 optimizations506941
Ref: 4a4506941
Ref: Optimizations<2>-Footnote-1508392
Ref: Optimizations<2>-Footnote-2508434
Ref: Optimizations<2>-Footnote-3508489
Ref: Optimizations<2>-Footnote-4508544
Ref: Optimizations<2>-Footnote-5508600
Ref: Optimizations<2>-Footnote-6508655
Ref: Optimizations<2>-Footnote-7508711
Ref: Optimizations<2>-Footnote-8508753
Ref: Optimizations<2>-Footnote-9508809
Node: CPython bytecode changes508865
Ref: whatsnew/3 12 cpython-bytecode-changes509000
Ref: 4aa509000
Ref: CPython bytecode changes-Footnote-1511041
Ref: CPython bytecode changes-Footnote-2511096
Ref: CPython bytecode changes-Footnote-3511152
Ref: CPython bytecode changes-Footnote-4511207
Ref: CPython bytecode changes-Footnote-5511262
Ref: CPython bytecode changes-Footnote-6511317
Ref: CPython bytecode changes-Footnote-7511373
Ref: CPython bytecode changes-Footnote-8511428
Ref: CPython bytecode changes-Footnote-9511484
Ref: CPython bytecode changes-Footnote-10511526
Ref: CPython bytecode changes-Footnote-11511583
Ref: CPython bytecode changes-Footnote-12511639
Ref: CPython bytecode changes-Footnote-13511682
Ref: CPython bytecode changes-Footnote-14511739
Ref: CPython bytecode changes-Footnote-15511796
Node: Demos and Tools511853
Ref: whatsnew/3 12 demos-and-tools511982
Ref: 4b7511982
Ref: Demos and Tools-Footnote-1512435
Ref: Demos and Tools-Footnote-2512483
Ref: Demos and Tools-Footnote-3512538
Ref: Demos and Tools-Footnote-4512586
Node: Deprecated512641
Ref: whatsnew/3 12 deprecated512753
Ref: 4b8512753
Ref: Deprecated-Footnote-1523238
Ref: Deprecated-Footnote-2523293
Ref: Deprecated-Footnote-3523348
Ref: Deprecated-Footnote-4523403
Ref: Deprecated-Footnote-5523458
Ref: Deprecated-Footnote-6523514
Ref: Deprecated-Footnote-7523570
Ref: Deprecated-Footnote-8523625
Ref: Deprecated-Footnote-9523681
Ref: Deprecated-Footnote-10523736
Ref: Deprecated-Footnote-11523792
Ref: Deprecated-Footnote-12523849
Ref: Deprecated-Footnote-13523905
Ref: Deprecated-Footnote-14523961
Ref: Deprecated-Footnote-15524017
Ref: Deprecated-Footnote-16524073
Ref: Deprecated-Footnote-17524176
Ref: Deprecated-Footnote-18524233
Ref: Deprecated-Footnote-19524289
Ref: Deprecated-Footnote-20524346
Ref: Deprecated-Footnote-21524403
Ref: Deprecated-Footnote-22524459
Ref: Deprecated-Footnote-23524515
Ref: Deprecated-Footnote-24524571
Ref: Deprecated-Footnote-25524627
Ref: Deprecated-Footnote-26524683
Ref: Deprecated-Footnote-27524739
Ref: Deprecated-Footnote-28524796
Ref: Deprecated-Footnote-29524839
Node: Pending Removal in Python 3 13524896
Ref: whatsnew/3 12 pending-removal-in-python-3-13525015
Ref: 4c8525015
Ref: Pending Removal in Python 3 13-Footnote-1526479
Ref: Pending Removal in Python 3 13-Footnote-2526521
Ref: Pending Removal in Python 3 13-Footnote-3526576
Ref: Pending Removal in Python 3 13-Footnote-4526631
Ref: Pending Removal in Python 3 13-Footnote-5526686
Ref: Pending Removal in Python 3 13-Footnote-6526741
Ref: Pending Removal in Python 3 13-Footnote-7526796
Ref: Pending Removal in Python 3 13-Footnote-8526851
Ref: Pending Removal in Python 3 13-Footnote-9526906
Ref: Pending Removal in Python 3 13-Footnote-10526961
Ref: Pending Removal in Python 3 13-Footnote-11527017
Ref: Pending Removal in Python 3 13-Footnote-12527073
Ref: Pending Removal in Python 3 13-Footnote-13527169
Node: Pending Removal in Python 3 14<3>527226
Ref: whatsnew/3 12 pending-removal-in-python-3-14527387
Ref: 4c9527387
Ref: Pending Removal in Python 3 14<3>-Footnote-1532086
Ref: Pending Removal in Python 3 14<3>-Footnote-2532141
Ref: Pending Removal in Python 3 14<3>-Footnote-3532196
Ref: Pending Removal in Python 3 14<3>-Footnote-4532251
Ref: Pending Removal in Python 3 14<3>-Footnote-5532306
Ref: Pending Removal in Python 3 14<3>-Footnote-6532362
Ref: Pending Removal in Python 3 14<3>-Footnote-7532417
Ref: Pending Removal in Python 3 14<3>-Footnote-8532472
Ref: Pending Removal in Python 3 14<3>-Footnote-9532527
Ref: Pending Removal in Python 3 14<3>-Footnote-10532583
Ref: Pending Removal in Python 3 14<3>-Footnote-11532639
Ref: Pending Removal in Python 3 14<3>-Footnote-12532695
Node: Pending Removal in Python 3 15<3>532751
Ref: whatsnew/3 12 pending-removal-in-python-3-15532915
Ref: 4ca532915
Ref: Pending Removal in Python 3 15<3>-Footnote-1536568
Ref: Pending Removal in Python 3 15<3>-Footnote-2536623
Ref: Pending Removal in Python 3 15<3>-Footnote-3536678
Ref: Pending Removal in Python 3 15<3>-Footnote-4536733
Ref: Pending Removal in Python 3 15<3>-Footnote-5536789
Ref: Pending Removal in Python 3 15<3>-Footnote-6536831
Node: Pending removal in Python 3 16<2>536887
Ref: whatsnew/3 12 pending-removal-in-python-3-16537055
Ref: 4cb537055
Ref: Pending removal in Python 3 16<2>-Footnote-1539241
Node: Pending Removal in Future Versions<3>539297
Ref: whatsnew/3 12 pending-removal-in-future-versions539423
Ref: 4cc539423
Ref: Pending Removal in Future Versions<3>-Footnote-1546496
Ref: Pending Removal in Future Versions<3>-Footnote-2546551
Ref: Pending Removal in Future Versions<3>-Footnote-3546606
Ref: Pending Removal in Future Versions<3>-Footnote-4546662
Ref: Pending Removal in Future Versions<3>-Footnote-5546718
Ref: Pending Removal in Future Versions<3>-Footnote-6546773
Node: Removed546828
Ref: whatsnew/3 12 removed546947
Ref: 4cd546947
Node: asynchat and asyncore547373
Ref: whatsnew/3 12 asynchat-and-asyncore547462
Ref: 4ce547462
Ref: asynchat and asyncore-Footnote-1547778
Ref: asynchat and asyncore-Footnote-2547820
Node: configparser<3>547875
Ref: whatsnew/3 12 configparser547982
Ref: 4cf547982
Ref: configparser<3>-Footnote-1548639
Node: distutils548694
Ref: whatsnew/3 12 distutils548789
Ref: 4d2548789
Ref: distutils-Footnote-1549218
Ref: distutils-Footnote-2549260
Node: ensurepip549315
Ref: whatsnew/3 12 ensurepip549399
Ref: 4d3549399
Ref: ensurepip-Footnote-1550419
Node: enum550474
Ref: whatsnew/3 12 enum550555
Ref: 4d4550555
Ref: enum-Footnote-1550789
Node: ftplib550844
Ref: whatsnew/3 12 ftplib550920
Ref: 4d5550920
Ref: ftplib-Footnote-1551161
Node: gzip551216
Ref: whatsnew/3 12 gzip551295
Ref: 4d6551295
Ref: gzip-Footnote-1551691
Node: hashlib551746
Ref: whatsnew/3 12 hashlib551831
Ref: 4d8551831
Ref: hashlib-Footnote-1552256
Ref: hashlib-Footnote-2552298
Node: importlib<2>552353
Ref: whatsnew/3 12 importlib552437
Ref: 4da552437
Ref: importlib<2>-Footnote-1553327
Ref: importlib<2>-Footnote-2553382
Ref: importlib<2>-Footnote-3553437
Ref: importlib<2>-Footnote-4553492
Ref: importlib<2>-Footnote-5553547
Node: imp553602
Ref: whatsnew/3 12 imp553684
Ref: 4db553684
Ref: imp-Footnote-1557797
Node: io<2>557852
Ref: whatsnew/3 12 io557931
Ref: 4e4557931
Ref: io<2>-Footnote-1558350
Node: locale<2>558405
Ref: whatsnew/3 12 locale558486
Ref: 4e7558486
Ref: locale<2>-Footnote-1558754
Node: smtpd558809
Ref: whatsnew/3 12 smtpd558895
Ref: 4e9558895
Ref: smtpd-Footnote-1559249
Ref: smtpd-Footnote-2559291
Ref: smtpd-Footnote-3559334
Node: sqlite3<3>559389
Ref: whatsnew/3 12 id2559472
Ref: 4ea559472
Ref: sqlite3<3>-Footnote-1560206
Node: ssl<2>560261
Ref: whatsnew/3 12 ssl560350
Ref: 4eb560350
Ref: ssl<2>-Footnote-1561407
Ref: ssl<2>-Footnote-2561462
Ref: ssl<2>-Footnote-3561517
Ref: ssl<2>-Footnote-4561573
Node: unittest<3>561628
Ref: whatsnew/3 12 id3561720
Ref: 4ef561720
Ref: unittest<3>-Footnote-1566484
Node: webbrowser<2>566539
Ref: whatsnew/3 12 webbrowser566646
Ref: 4fb566646
Ref: webbrowser<2>-Footnote-1566952
Node: xml etree ElementTree567008
Ref: whatsnew/3 12 xml-etree-elementtree567116
Ref: 4fc567116
Ref: xml etree ElementTree-Footnote-1567579
Node: zipimport<2>567634
Ref: whatsnew/3 12 zipimport567735
Ref: 4fe567735
Ref: zipimport<2>-Footnote-1568070
Ref: zipimport<2>-Footnote-2568112
Node: Others568167
Ref: whatsnew/3 12 others568238
Ref: 4ff568238
Ref: Others-Footnote-1569246
Ref: Others-Footnote-2569300
Ref: Others-Footnote-3569355
Ref: Others-Footnote-4569410
Ref: Others-Footnote-5569465
Node: Porting to Python 3 12569520
Ref: whatsnew/3 12 porting-to-python-3-12569645
Ref: 500569645
Ref: whatsnew/3 12 whatsnew312-porting-to-python312569645
Ref: 498569645
Node: Changes in the Python API<2>569882
Ref: whatsnew/3 12 changes-in-the-python-api569969
Ref: 501569969
Ref: Changes in the Python API<2>-Footnote-1576272
Ref: Changes in the Python API<2>-Footnote-2576327
Ref: Changes in the Python API<2>-Footnote-3576382
Ref: Changes in the Python API<2>-Footnote-4576425
Ref: Changes in the Python API<2>-Footnote-5576480
Ref: Changes in the Python API<2>-Footnote-6576535
Ref: Changes in the Python API<2>-Footnote-7576590
Ref: Changes in the Python API<2>-Footnote-8576646
Ref: Changes in the Python API<2>-Footnote-9576688
Ref: Changes in the Python API<2>-Footnote-10576730
Ref: Changes in the Python API<2>-Footnote-11576773
Node: Build Changes<2>576830
Ref: whatsnew/3 12 build-changes576964
Ref: 50f576964
Ref: Build Changes<2>-Footnote-1578649
Ref: Build Changes<2>-Footnote-2578704
Ref: Build Changes<2>-Footnote-3578759
Ref: Build Changes<2>-Footnote-4578814
Ref: Build Changes<2>-Footnote-5578869
Ref: Build Changes<2>-Footnote-6578924
Node: C API Changes<2>578979
Ref: whatsnew/3 12 c-api-changes579082
Ref: 510579082
Node: New Features<4>579273
Ref: whatsnew/3 12 id4579375
Ref: 511579375
Ref: whatsnew/3 12 whatsnew312-pep697579420
Ref: 411579420
Ref: whatsnew/3 12 whatsnew312-pep683585562
Ref: 412585562
Ref: New Features<4>-Footnote-1587290
Ref: New Features<4>-Footnote-2587332
Ref: New Features<4>-Footnote-3587374
Ref: New Features<4>-Footnote-4587430
Ref: New Features<4>-Footnote-5587472
Ref: New Features<4>-Footnote-6587528
Ref: New Features<4>-Footnote-7587583
Ref: New Features<4>-Footnote-8587638
Ref: New Features<4>-Footnote-9587693
Ref: New Features<4>-Footnote-10587748
Ref: New Features<4>-Footnote-11587804
Ref: New Features<4>-Footnote-12587860
Ref: New Features<4>-Footnote-13587916
Ref: New Features<4>-Footnote-14587972
Ref: New Features<4>-Footnote-15588028
Ref: New Features<4>-Footnote-16588085
Ref: New Features<4>-Footnote-17588142
Ref: New Features<4>-Footnote-18588199
Ref: New Features<4>-Footnote-19588256
Ref: New Features<4>-Footnote-20588299
Ref: New Features<4>-Footnote-21588355
Ref: New Features<4>-Footnote-22588398
Ref: New Features<4>-Footnote-23588455
Node: Porting to Python 3 12<2>588512
Ref: whatsnew/3 12 id5588636
Ref: 53c588636
Ref: Porting to Python 3 12<2>-Footnote-1596107
Ref: Porting to Python 3 12<2>-Footnote-2596162
Ref: Porting to Python 3 12<2>-Footnote-3596217
Ref: Porting to Python 3 12<2>-Footnote-4596272
Ref: Porting to Python 3 12<2>-Footnote-5596327
Ref: Porting to Python 3 12<2>-Footnote-6596382
Ref: Porting to Python 3 12<2>-Footnote-7596437
Ref: Porting to Python 3 12<2>-Footnote-8596493
Node: Deprecated<2>596549
Ref: whatsnew/3 12 id6596668
Ref: 558596668
Ref: Deprecated<2>-Footnote-1602007
Ref: Deprecated<2>-Footnote-2602049
Ref: Deprecated<2>-Footnote-3602105
Ref: Deprecated<2>-Footnote-4602160
Ref: Deprecated<2>-Footnote-5602215
Ref: Deprecated<2>-Footnote-6602270
Ref: Deprecated<2>-Footnote-7602326
Ref: Deprecated<2>-Footnote-8602382
Node: Pending Removal in Python 3 14<4>602438
Ref: whatsnew/3 12 id7602563
Ref: 562602563
Ref: Pending Removal in Python 3 14<4>-Footnote-1605788
Ref: Pending Removal in Python 3 14<4>-Footnote-2605830
Ref: Pending Removal in Python 3 14<4>-Footnote-3605886
Node: Pending Removal in Python 3 15<4>605941
Ref: whatsnew/3 12 id8606112
Ref: 563606112
Node: Pending Removal in Future Versions<4>607411
Ref: whatsnew/3 12 id9607540
Ref: 564607540
Node: Removed<2>609781
Ref: whatsnew/3 12 id10609866
Ref: 565609866
Ref: Removed<2>-Footnote-1610721
Ref: Removed<2>-Footnote-2610776
Ref: Removed<2>-Footnote-3610818
Node: What's New In Python 3 11610873
Ref: whatsnew/3 11 doc611023
Ref: 566611023
Ref: whatsnew/3 11 what-s-new-in-python-3-11611023
Ref: 567611023
Node: 概要 -- リリースハイライト612073
Ref: whatsnew/3 11 summary-release-highlights612196
Ref: 568612196
Ref: whatsnew/3 11 whatsnew311-summary612196
Ref: 569612196
Ref: 概要 -- リリースハイライト-Footnote-1613991
Ref: 概要 -- リリースハイライト-Footnote-2614033
Ref: 概要 -- リリースハイライト-Footnote-3614058
Ref: 概要 -- リリースハイライト-Footnote-4614100
Ref: 概要 -- リリースハイライト-Footnote-5614142
Node: 新しい機能614184
Ref: whatsnew/3 11 new-features614358
Ref: 579614358
Ref: whatsnew/3 11 whatsnew311-features614358
Ref: 57a614358
Node: PEP 657 トレースバックのエラー位置の詳細化614811
Ref: whatsnew/3 11 pep-657-fine-grained-error-locations-in-tracebacks614968
Ref: 57b614968
Ref: whatsnew/3 11 whatsnew311-pep657614968
Ref: 56d614968
Ref: PEP 657 トレースバックのエラー位置の詳細化-Footnote-1618067
Ref: PEP 657 トレースバックのエラー位置の詳細化-Footnote-2618109
Node: PEP 654 例外グループと except*618174
Ref: whatsnew/3 11 pep-654-exception-groups-and-except618393
Ref: 581618393
Ref: whatsnew/3 11 whatsnew311-pep654618393
Ref: 56b618393
Ref: PEP 654 例外グループと except*-Footnote-1619241
Ref: PEP 654 例外グループと except*-Footnote-2619283
Ref: PEP 654 例外グループと except*-Footnote-3619325
Node: PEP 678 ノートによって例外を充実させる619390
Ref: whatsnew/3 11 pep-678-exceptions-can-be-enriched-with-notes619589
Ref: 583619589
Ref: whatsnew/3 11 whatsnew311-pep678619589
Ref: 56c619589
Ref: PEP 678 ノートによって例外を充実させる-Footnote-1620239
Ref: PEP 678 ノートによって例外を充実させる-Footnote-2620281
Node: Windows py exe ランチャーの改善620346
Ref: whatsnew/3 11 whatsnew311-windows-launcher620499
Ref: 586620499
Ref: whatsnew/3 11 windows-py-exe-launcher-improvements620499
Ref: 587620499
Ref: whatsnew/3 11 new-feat-related-type-hints-311621943
Ref: 589621943
Ref: Windows py exe ランチャーの改善-Footnote-1621981
Ref: Windows py exe ランチャーの改善-Footnote-2622023
Node: 型ヒントに関連する新しい機能622054
Ref: whatsnew/3 11 new-features-related-to-type-hints622215
Ref: 58a622215
Ref: whatsnew/3 11 whatsnew311-typing-features622215
Ref: 58b622215
Ref: 型ヒントに関連する新しい機能-Footnote-1622870
Node: PEP 646 Variadic generics622912
Ref: whatsnew/3 11 pep-646-variadic-generics623095
Ref: 58c623095
Ref: whatsnew/3 11 whatsnew311-pep646623095
Ref: 571623095
Ref: PEP 646 Variadic generics-Footnote-1624101
Ref: PEP 646 Variadic generics-Footnote-2624143
Ref: PEP 646 Variadic generics-Footnote-3624185
Ref: PEP 646 Variadic generics-Footnote-4624227
Node: PEP 655 Marking individual TypedDict items as required or not-required624292
Ref: whatsnew/3 11 pep-655-marking-individual-typeddict-items-as-required-or-not-required624500
Ref: 58d624500
Ref: whatsnew/3 11 whatsnew311-pep655624500
Ref: 572624500
Ref: PEP 655 Marking individual TypedDict items as required or not-required-Footnote-1625748
Ref: PEP 655 Marking individual TypedDict items as required or not-required-Footnote-2625790
Node: PEP 673 Self 型625855
Ref: whatsnew/3 11 pep-673-self-type626075
Ref: 590626075
Ref: whatsnew/3 11 whatsnew311-pep673626075
Ref: 573626075
Ref: PEP 673 Self 型-Footnote-1627144
Ref: PEP 673 Self 型-Footnote-2627225
Ref: PEP 673 Self 型-Footnote-3627267
Node: PEP 675 Arbitrary literal string type627332
Ref: whatsnew/3 11 pep-675-arbitrary-literal-string-type627511
Ref: 593627511
Ref: whatsnew/3 11 whatsnew311-pep675627511
Ref: 574627511
Ref: PEP 675 Arbitrary literal string type-Footnote-1628933
Ref: PEP 675 Arbitrary literal string type-Footnote-2628975
Node: PEP 681 Data class transforms629040
Ref: whatsnew/3 11 pep-681-data-class-transforms629232
Ref: 595629232
Ref: whatsnew/3 11 whatsnew311-pep681629232
Ref: 575629232
Ref: PEP 681 Data class transforms-Footnote-1630287
Ref: PEP 681 Data class transforms-Footnote-2630329
Node: PEP 563 may not be the future630384
Ref: whatsnew/3 11 pep-563-may-not-be-the-future630530
Ref: 596630530
Ref: whatsnew/3 11 whatsnew311-pep563-deferred630530
Ref: 597630530
Ref: PEP 563 may not be the future-Footnote-1630925
Ref: PEP 563 may not be the future-Footnote-2630967
Node: その他の言語変更631078
Ref: whatsnew/3 11 other-language-changes631263
Ref: 598631263
Ref: whatsnew/3 11 whatsnew311-other-lang-changes631263
Ref: 599631263
Ref: whatsnew/3 11 whatsnew311-pythonsafepath633068
Ref: 570633068
Ref: その他の言語変更-Footnote-1634411
Ref: その他の言語変更-Footnote-2634476
Ref: その他の言語変更-Footnote-3634541
Ref: その他の言語変更-Footnote-4634606
Ref: その他の言語変更-Footnote-5634671
Ref: その他の言語変更-Footnote-6634726
Ref: その他の言語変更-Footnote-7634791
Ref: その他の言語変更-Footnote-8634846
Ref: その他の言語変更-Footnote-9634888
Ref: その他の言語変更-Footnote-10634943
Node: その他の CPython の実装の変更634999
Ref: whatsnew/3 11 other-cpython-implementation-changes635166
Ref: 5af635166
Ref: whatsnew/3 11 whatsnew311-other-implementation-changes635166
Ref: 5b0635166
Ref: その他の CPython の実装の変更-Footnote-1638414
Ref: その他の CPython の実装の変更-Footnote-2638479
Ref: その他の CPython の実装の変更-Footnote-3638521
Ref: その他の CPython の実装の変更-Footnote-4638586
Ref: その他の CPython の実装の変更-Footnote-5638651
Ref: その他の CPython の実装の変更-Footnote-6638716
Ref: その他の CPython の実装の変更-Footnote-7638781
Ref: その他の CPython の実装の変更-Footnote-8638846
Node: 新たなモジュール638902
Ref: whatsnew/3 11 new-modules639075
Ref: 5c0639075
Ref: whatsnew/3 11 whatsnew311-new-modules639075
Ref: 5c1639075
Ref: 新たなモジュール-Footnote-1639441
Ref: 新たなモジュール-Footnote-2639466
Ref: 新たなモジュール-Footnote-3639508
Ref: 新たなモジュール-Footnote-4639573
Ref: 新たなモジュール-Footnote-5639615
Node: 改良されたモジュール639680
Ref: whatsnew/3 11 improved-modules639823
Ref: 5c2639823
Ref: whatsnew/3 11 whatsnew311-improved-modules639823
Ref: 5c3639823
Node: asyncio<3>640582
Ref: whatsnew/3 11 asyncio640678
Ref: 5c4640678
Ref: whatsnew/3 11 whatsnew311-asyncio640678
Ref: 5c5640678
Ref: asyncio<3>-Footnote-1642596
Ref: asyncio<3>-Footnote-2642651
Ref: asyncio<3>-Footnote-3642706
Ref: asyncio<3>-Footnote-4642761
Ref: asyncio<3>-Footnote-5642816
Ref: asyncio<3>-Footnote-6642881
Node: contextlib642946
Ref: whatsnew/3 11 contextlib643069
Ref: 5d5643069
Ref: whatsnew/3 11 whatsnew311-contextlib643069
Ref: 5d6643069
Ref: contextlib-Footnote-1643384
Node: データクラス643449
Ref: whatsnew/3 11 dataclasses643570
Ref: 5d9643570
Ref: whatsnew/3 11 whatsnew311-dataclasses643570
Ref: 5da643570
Ref: データクラス-Footnote-1643920
Node: datetime643985
Ref: whatsnew/3 11 datetime644103
Ref: 5dd644103
Ref: whatsnew/3 11 whatsnew311-datetime644103
Ref: 5de644103
Ref: datetime-Footnote-1644642
Ref: datetime-Footnote-2644697
Node: enum<2>644752
Ref: whatsnew/3 11 enum644857
Ref: 5e3644857
Ref: whatsnew/3 11 whatsnew311-enum644857
Ref: 5e4644857
Node: fcntl647501
Ref: whatsnew/3 11 fcntl647610
Ref: 5ff647610
Ref: whatsnew/3 11 whatsnew311-fcntl647610
Ref: 600647610
Node: fractions<3>647845
Ref: whatsnew/3 11 fractions647956
Ref: 601647956
Ref: whatsnew/3 11 whatsnew311-fractions647956
Ref: 602647956
Ref: fractions<3>-Footnote-1648374
Ref: fractions<3>-Footnote-2648416
Ref: fractions<3>-Footnote-3648481
Node: functools648546
Ref: whatsnew/3 11 functools648659
Ref: 603648659
Ref: whatsnew/3 11 whatsnew311-functools648659
Ref: 604648659
Ref: functools-Footnote-1649731
Node: gzip<2>649796
Ref: whatsnew/3 11 gzip649907
Ref: 608649907
Ref: whatsnew/3 11 whatsnew311-gzip649907
Ref: 609649907
Ref: gzip<2>-Footnote-1650615
Node: hashlib<2>650671
Ref: whatsnew/3 11 hashlib650790
Ref: 60c650790
Ref: whatsnew/3 11 whatsnew311-hashlib650790
Ref: 60d650790
Ref: hashlib<2>-Footnote-1651611
Ref: hashlib<2>-Footnote-2651643
Ref: hashlib<2>-Footnote-3651708
Ref: hashlib<2>-Footnote-4651773
Node: IDLE と idelelib651828
Ref: whatsnew/3 11 idle-and-idlelib651950
Ref: 611651950
Ref: whatsnew/3 11 whatsnew311-idle651950
Ref: 612651950
Ref: IDLE と idelelib-Footnote-1652285
Ref: IDLE と idelelib-Footnote-2652350
Node: inspect<2>652405
Ref: whatsnew/3 11 inspect652526
Ref: 613652526
Ref: whatsnew/3 11 whatsnew311-inspect652526
Ref: 614652526
Ref: inspect<2>-Footnote-1653613
Ref: inspect<2>-Footnote-2653678
Ref: inspect<2>-Footnote-3653743
Ref: inspect<2>-Footnote-4653785
Node: locale<3>653840
Ref: whatsnew/3 11 locale653951
Ref: 620653951
Ref: whatsnew/3 11 whatsnew311-locale653951
Ref: 621653951
Node: logging654178
Ref: whatsnew/3 11 logging654286
Ref: 623654286
Ref: whatsnew/3 11 whatsnew311-logging654286
Ref: 624654286
Ref: logging-Footnote-1654952
Ref: logging-Footnote-2655007
Node: math<3>655062
Ref: whatsnew/3 11 math655169
Ref: 62a655169
Ref: whatsnew/3 11 whatsnew311-math655169
Ref: 62b655169
Ref: math<3>-Footnote-1655942
Ref: math<3>-Footnote-2656007
Ref: math<3>-Footnote-3656072
Ref: math<3>-Footnote-4656137
Node: operator656202
Ref: whatsnew/3 11 operator656307
Ref: 630656307
Ref: whatsnew/3 11 whatsnew311-operator656307
Ref: 631656307
Ref: operator-Footnote-1656569
Node: os<3>656634
Ref: whatsnew/3 11 os656742
Ref: 632656742
Ref: whatsnew/3 11 whatsnew311-os656742
Ref: 633656742
Ref: os<3>-Footnote-1656991
Node: pathlib<4>657056
Ref: whatsnew/3 11 pathlib657161
Ref: 634657161
Ref: whatsnew/3 11 whatsnew311-pathlib657161
Ref: 635657161
Ref: pathlib<4>-Footnote-1657482
Ref: pathlib<4>-Footnote-2657547
Node: re<3>657612
Ref: whatsnew/3 11 re657721
Ref: 638657721
Ref: whatsnew/3 11 whatsnew311-re657721
Ref: 639657721
Ref: re<3>-Footnote-1658023
Node: shutil<3>658089
Ref: whatsnew/3 11 shutil658194
Ref: 63a658194
Ref: whatsnew/3 11 whatsnew311-shutil658194
Ref: 63b658194
Ref: shutil<3>-Footnote-1658388
Node: socket658453
Ref: whatsnew/3 11 socket658563
Ref: 63c658563
Ref: whatsnew/3 11 whatsnew311-socket658563
Ref: 63d658563
Ref: socket-Footnote-1658976
Ref: socket-Footnote-2659041
Node: sqlite3<4>659106
Ref: whatsnew/3 11 sqlite3659213
Ref: 63f659213
Ref: whatsnew/3 11 whatsnew311-sqlite3659213
Ref: 640659213
Ref: sqlite3<4>-Footnote-1661557
Ref: sqlite3<4>-Footnote-2661622
Ref: sqlite3<4>-Footnote-3661687
Ref: sqlite3<4>-Footnote-4661752
Ref: sqlite3<4>-Footnote-5661817
Ref: sqlite3<4>-Footnote-6661882
Ref: sqlite3<4>-Footnote-7661947
Ref: sqlite3<4>-Footnote-8662012
Ref: sqlite3<4>-Footnote-9662077
Ref: sqlite3<4>-Footnote-10662142
Ref: sqlite3<4>-Footnote-11662208
Node: string662274
Ref: whatsnew/3 11 string662381
Ref: 64f662381
Ref: whatsnew/3 11 whatsnew311-string662381
Ref: 650662381
Ref: string-Footnote-1662706
Node: sys<4>662761
Ref: whatsnew/3 11 sys662867
Ref: 654662867
Ref: whatsnew/3 11 whatsnew311-sys662867
Ref: 655662867
Ref: sys<4>-Footnote-1663560
Ref: sys<4>-Footnote-2663625
Ref: sys<4>-Footnote-3663690
Node: sysconfig663745
Ref: whatsnew/3 11 sysconfig663856
Ref: 659663856
Ref: whatsnew/3 11 whatsnew311-sysconfig663856
Ref: 65a663856
Ref: sysconfig-Footnote-1664667
Node: tempfile<3>664732
Ref: whatsnew/3 11 tempfile664849
Ref: 65d664849
Ref: whatsnew/3 11 whatsnew311-tempfile664849
Ref: 65e664849
Ref: tempfile<3>-Footnote-1665258
Node: threading<2>665313
Ref: whatsnew/3 11 threading665428
Ref: 662665428
Ref: whatsnew/3 11 whatsnew311-threading665428
Ref: 663665428
Ref: threading<2>-Footnote-1665933
Node: time<2>665998
Ref: whatsnew/3 11 time666112
Ref: 667666112
Ref: whatsnew/3 11 whatsnew311-time666112
Ref: 668666112
Ref: time<2>-Footnote-1666913
Ref: time<2>-Footnote-2666978
Ref: time<2>-Footnote-3667075
Ref: time<2>-Footnote-4667140
Node: tkinter<3>667205
Ref: whatsnew/3 11 tkinter667319
Ref: 66a667319
Ref: whatsnew/3 11 whatsnew311-tkinter667319
Ref: 66b667319
Ref: tkinter<3>-Footnote-1667602
Node: traceback<2>667657
Ref: whatsnew/3 11 traceback667773
Ref: 66d667773
Ref: whatsnew/3 11 whatsnew311-traceback667773
Ref: 66e667773
Ref: traceback<2>-Footnote-1668265
Ref: traceback<2>-Footnote-2668330
Node: typing<4>668395
Ref: whatsnew/3 11 typing668515
Ref: 671668515
Ref: whatsnew/3 11 whatsnew311-typing668515
Ref: 672668515
Ref: typing<4>-Footnote-1671815
Ref: typing<4>-Footnote-2671870
Ref: typing<4>-Footnote-3671925
Ref: typing<4>-Footnote-4671980
Ref: typing<4>-Footnote-5672035
Ref: typing<4>-Footnote-6672100
Ref: typing<4>-Footnote-7672155
Ref: typing<4>-Footnote-8672210
Ref: typing<4>-Footnote-9672265
Ref: typing<4>-Footnote-10672320
Ref: typing<4>-Footnote-11672376
Ref: typing<4>-Footnote-12672432
Ref: typing<4>-Footnote-13672488
Ref: typing<4>-Footnote-14672544
Ref: typing<4>-Footnote-15672600
Node: unicodedata<3>672656
Ref: whatsnew/3 11 unicodedata672775
Ref: 681672775
Ref: whatsnew/3 11 whatsnew311-unicodedata672775
Ref: 682672775
Ref: unicodedata<3>-Footnote-1672974
Node: unittest<4>673039
Ref: whatsnew/3 11 unittest673156
Ref: 683673156
Ref: whatsnew/3 11 whatsnew311-unittest673156
Ref: 684673156
Ref: unittest<4>-Footnote-1673558
Node: venv<2>673623
Ref: whatsnew/3 11 venv673737
Ref: 689673737
Ref: whatsnew/3 11 whatsnew311-venv673737
Ref: 68a673737
Ref: venv<2>-Footnote-1674360
Node: warnings<2>674425
Ref: whatsnew/3 11 warnings674535
Ref: 68b674535
Ref: whatsnew/3 11 whatsnew311-warnings674535
Ref: 68c674535
Ref: warnings<2>-Footnote-1674866
Node: zipfile674931
Ref: whatsnew/3 11 whatsnew311-zipfile675025
Ref: 68e675025
Ref: whatsnew/3 11 zipfile675025
Ref: 68f675025
Ref: zipfile-Footnote-1675614
Ref: zipfile-Footnote-2675679
Ref: zipfile-Footnote-3675734
Node: 最適化675789
Ref: whatsnew/3 11 optimizations675922
Ref: 696675922
Ref: whatsnew/3 11 whatsnew311-optimizations675922
Ref: 697675922
Ref: 最適化-Footnote-1678310
Ref: 最適化-Footnote-2678375
Ref: 最適化-Footnote-3678430
Ref: 最適化-Footnote-4678485
Ref: 最適化-Footnote-5678540
Ref: 最適化-Footnote-6678605
Ref: 最適化-Footnote-7678660
Ref: 最適化-Footnote-8678725
Ref: 最適化-Footnote-9678780
Node: Faster CPython678845
Ref: whatsnew/3 11 faster-cpython678983
Ref: 6a1678983
Ref: whatsnew/3 11 whatsnew311-faster-cpython678983
Ref: 56a678983
Ref: Faster CPython-Footnote-1679564
Ref: Faster CPython-Footnote-2679630
Node: Faster Startup679678
Ref: whatsnew/3 11 faster-startup679766
Ref: 6a4679766
Ref: whatsnew/3 11 whatsnew311-faster-startup679766
Ref: 6a2679766
Node: Frozen imports / Static code objects679864
Ref: whatsnew/3 11 frozen-imports-static-code-objects679951
Ref: 6a5679951
Ref: whatsnew/3 11 whatsnew311-faster-imports679951
Ref: 6a6679951
Node: Faster Runtime680796
Ref: whatsnew/3 11 faster-runtime680897
Ref: 6a8680897
Ref: whatsnew/3 11 whatsnew311-faster-runtime680897
Ref: 6a3680897
Node: Cheaper lazy Python frames681136
Ref: whatsnew/3 11 cheaper-lazy-python-frames681251
Ref: 6a9681251
Ref: whatsnew/3 11 whatsnew311-lazy-python-frames681251
Ref: 6aa681251
Ref: whatsnew/3 11 inline-calls682194
Ref: 6ae682194
Ref: Cheaper lazy Python frames-Footnote-1682232
Node: Inlined Python function calls682297
Ref: whatsnew/3 11 inlined-python-function-calls682462
Ref: 6af682462
Ref: whatsnew/3 11 whatsnew311-inline-calls682462
Ref: 6b0682462
Ref: Inlined Python function calls-Footnote-1683410
Node: PEP 659 Specializing Adaptive Interpreter683475
Ref: whatsnew/3 11 pep-659-specializing-adaptive-interpreter683605
Ref: 6b1683605
Ref: whatsnew/3 11 whatsnew311-pep659683605
Ref: 161683605
Ref: PEP 659 Specializing Adaptive Interpreter-Footnote-1691013
Ref: PEP 659 Specializing Adaptive Interpreter-Footnote-2691055
Ref: PEP 659 Specializing Adaptive Interpreter-Footnote-3691097
Ref: PEP 659 Specializing Adaptive Interpreter-Footnote-4691222
Node: Misc691447
Ref: whatsnew/3 11 misc691537
Ref: 6b2691537
Ref: whatsnew/3 11 whatsnew311-faster-cpython-misc691537
Ref: 6b3691537
Ref: Misc-Footnote-1692544
Ref: Misc-Footnote-2692609
Ref: Misc-Footnote-3692674
Ref: Misc-Footnote-4692739
Ref: Misc-Footnote-5692804
Ref: Misc-Footnote-6692875
Node: FAQ692930
Ref: whatsnew/3 11 faq693011
Ref: 6b5693011
Ref: whatsnew/3 11 whatsnew311-faster-cpython-faq693011
Ref: 6b6693011
Node: How should I write my code to utilize these speedups?693302
Ref: whatsnew/3 11 faster-cpython-faq-my-code693438
Ref: 6b7693438
Ref: whatsnew/3 11 how-should-i-write-my-code-to-utilize-these-speedups693438
Ref: 6b8693438
Node: Will CPython 3 11 use more memory?693731
Ref: whatsnew/3 11 faster-cpython-faq-memory693920
Ref: 6b9693920
Ref: whatsnew/3 11 will-cpython-3-11-use-more-memory693920
Ref: 6ba693920
Node: I don't see any speedups in my workload Why?694181
Ref: whatsnew/3 11 faster-cpython-ymmv694341
Ref: 6bb694341
Ref: whatsnew/3 11 i-don-t-see-any-speedups-in-my-workload-why694341
Ref: 6bc694341
Node: Is there a JIT compiler?694925
Ref: whatsnew/3 11 faster-cpython-jit695042
Ref: 6bd695042
Ref: whatsnew/3 11 is-there-a-jit-compiler695042
Ref: 6be695042
Node: About695160
Ref: whatsnew/3 11 about695228
Ref: 6bf695228
Ref: whatsnew/3 11 whatsnew311-faster-cpython-about695228
Ref: 6c0695228
Node: CPython バイトコードの変更695537
Ref: whatsnew/3 11 cpython-bytecode-changes695675
Ref: 6c2695675
Ref: whatsnew/3 11 whatsnew311-bytecode-changes695675
Ref: 6c3695675
Node: New opcodes696235
Ref: whatsnew/3 11 new-opcodes696343
Ref: 6c5696343
Ref: whatsnew/3 11 whatsnew311-added-opcodes696343
Ref: 6c6696343
Ref: New opcodes-Footnote-1697156
Node: Replaced opcodes697198
Ref: whatsnew/3 11 replaced-opcodes697338
Ref: 6cf697338
Ref: whatsnew/3 11 whatsnew311-replaced-opcodes697338
Ref: 6d0697338
Ref: whatsnew/3 11 whatsnew311-changed-opcodes700052
Ref: 6d9700052
Ref: whatsnew/3 11 whatsnew311-removed-opcodes700052
Ref: 6da700052
Ref: Replaced opcodes-Footnote-1700088
Node: Changed/removed opcodes700306
Ref: whatsnew/3 11 changed-removed-opcodes700426
Ref: 6db700426
Ref: whatsnew/3 11 whatsnew311-changed-removed-opcodes700426
Ref: 6dc700426
Ref: whatsnew/3 11 whatsnew311-deprecated701014
Ref: 6df701014
Ref: Changed/removed opcodes-Footnote-1701051
Node: 非推奨701106
Ref: whatsnew/3 11 deprecated701260
Ref: 6e0701260
Ref: whatsnew/3 11 whatsnew311-python-api-deprecated701260
Ref: 6e1701260
Ref: whatsnew/3 11 whatsnew311-deprecated-language701417
Ref: 6e3701417
Node: Language/Builtins701491
Ref: whatsnew/3 11 language-builtins701578
Ref: 6e4701578
Ref: whatsnew/3 11 whatsnew311-deprecated-builtins701578
Ref: 6e5701578
Ref: Language/Builtins-Footnote-1702799
Ref: Language/Builtins-Footnote-2702864
Ref: Language/Builtins-Footnote-3702919
Ref: Language/Builtins-Footnote-4702974
Node: モジュール703039
Ref: whatsnew/3 11 modules703151
Ref: 6e9703151
Ref: whatsnew/3 11 whatsnew311-deprecated-modules703151
Ref: 6ea703151
Ref: whatsnew/3 11 whatsnew311-pep594703197
Ref: 576703197
Ref: モジュール-Footnote-1705407
Ref: モジュール-Footnote-2705449
Ref: モジュール-Footnote-3705514
Ref: モジュール-Footnote-4705569
Ref: モジュール-Footnote-5705634
Ref: モジュール-Footnote-6705676
Ref: モジュール-Footnote-7705741
Node: Standard Library705806
Ref: whatsnew/3 11 standard-library705892
Ref: 6eb705892
Ref: whatsnew/3 11 whatsnew311-deprecated-stdlib705892
Ref: 6ec705892
Ref: whatsnew/3 11 whatsnew311-pending-removal710747
Ref: 6f1710747
Ref: Standard Library-Footnote-1710784
Ref: Standard Library-Footnote-2710849
Ref: Standard Library-Footnote-3710914
Ref: Standard Library-Footnote-4710969
Ref: Standard Library-Footnote-5711024
Ref: Standard Library-Footnote-6711079
Ref: Standard Library-Footnote-7711134
Ref: Standard Library-Footnote-8711199
Ref: Standard Library-Footnote-9711254
Ref: Standard Library-Footnote-10711309
Ref: Standard Library-Footnote-11711375
Ref: Standard Library-Footnote-12711440
Node: Pending Removal in Python 3 12711496
Ref: whatsnew/3 11 pending-removal-in-python-3-12711621
Ref: 6f2711621
Ref: whatsnew/3 11 whatsnew311-python-api-pending-removal711621
Ref: 6f3711621
Ref: whatsnew/3 11 whatsnew311-removed717372
Ref: 6f8717372
Node: 削除717372
Ref: whatsnew/3 11 removed717510
Ref: 6f9717510
Ref: whatsnew/3 11 whatsnew311-python-api-removed717510
Ref: 6fa717510
Ref: whatsnew/3 11 whatsnew311-porting722162
Ref: 707722162
Ref: 削除-Footnote-1722199
Ref: 削除-Footnote-2722264
Ref: 削除-Footnote-3722329
Ref: 削除-Footnote-4722394
Ref: 削除-Footnote-5722459
Ref: 削除-Footnote-6722524
Ref: 削除-Footnote-7722589
Ref: 削除-Footnote-8722654
Ref: 削除-Footnote-9722719
Ref: 削除-Footnote-10722784
Ref: 削除-Footnote-11722850
Ref: 削除-Footnote-12722916
Ref: 削除-Footnote-13722982
Ref: 削除-Footnote-14723048
Ref: 削除-Footnote-15723090
Node: Porting to Python 3 11723144
Ref: whatsnew/3 11 porting-to-python-3-11723268
Ref: 708723268
Ref: whatsnew/3 11 whatsnew311-python-api-porting723268
Ref: 709723268
Ref: Porting to Python 3 11-Footnote-1726312
Ref: Porting to Python 3 11-Footnote-2726377
Ref: Porting to Python 3 11-Footnote-3726432
Ref: Porting to Python 3 11-Footnote-4726497
Ref: Porting to Python 3 11-Footnote-5726562
Ref: Porting to Python 3 11-Footnote-6726627
Ref: Porting to Python 3 11-Footnote-7726692
Ref: Porting to Python 3 11-Footnote-8726757
Node: Build Changes<3>726822
Ref: whatsnew/3 11 build-changes726955
Ref: 714726955
Ref: whatsnew/3 11 whatsnew311-build-changes726955
Ref: 715726955
Ref: Build Changes<3>-Footnote-1731188
Ref: Build Changes<3>-Footnote-2731230
Ref: Build Changes<3>-Footnote-3731279
Ref: Build Changes<3>-Footnote-4731312
Ref: Build Changes<3>-Footnote-5731344
Ref: Build Changes<3>-Footnote-6731370
Ref: Build Changes<3>-Footnote-7731399
Ref: Build Changes<3>-Footnote-8731454
Ref: Build Changes<3>-Footnote-9731509
Ref: Build Changes<3>-Footnote-10731564
Ref: Build Changes<3>-Footnote-11731608
Ref: Build Changes<3>-Footnote-12731692
Ref: Build Changes<3>-Footnote-13731758
Ref: Build Changes<3>-Footnote-14731824
Ref: Build Changes<3>-Footnote-15731890
Ref: Build Changes<3>-Footnote-16731938
Ref: Build Changes<3>-Footnote-17732004
Ref: Build Changes<3>-Footnote-18732070
Ref: Build Changes<3>-Footnote-19732098
Ref: Build Changes<3>-Footnote-20732164
Ref: Build Changes<3>-Footnote-21732227
Ref: Build Changes<3>-Footnote-22732255
Ref: Build Changes<3>-Footnote-23732321
Ref: Build Changes<3>-Footnote-24732387
Ref: Build Changes<3>-Footnote-25732453
Ref: Build Changes<3>-Footnote-26732519
Ref: Build Changes<3>-Footnote-27732569
Ref: Build Changes<3>-Footnote-28732635
Ref: Build Changes<3>-Footnote-29732701
Ref: Build Changes<3>-Footnote-30732767
Ref: Build Changes<3>-Footnote-31732833
Ref: Build Changes<3>-Footnote-32732899
Ref: Build Changes<3>-Footnote-33732965
Node: C API の変更733031
Ref: whatsnew/3 11 c-api-changes733179
Ref: 719733179
Ref: whatsnew/3 11 whatsnew311-c-api733179
Ref: 71a733179
Node: 新しい機能<2>733442
Ref: whatsnew/3 11 id5733546
Ref: 71b733546
Ref: whatsnew/3 11 whatsnew311-c-api-new-features733546
Ref: 71c733546
Ref: 新しい機能<2>-Footnote-1736397
Ref: 新しい機能<2>-Footnote-2736462
Ref: 新しい機能<2>-Footnote-3736527
Ref: 新しい機能<2>-Footnote-4736592
Ref: 新しい機能<2>-Footnote-5736657
Ref: 新しい機能<2>-Footnote-6736722
Ref: 新しい機能<2>-Footnote-7736787
Ref: 新しい機能<2>-Footnote-8736852
Ref: 新しい機能<2>-Footnote-9736917
Node: Porting to Python 3 11<2>736972
Ref: whatsnew/3 11 id6737097
Ref: 73f737097
Ref: whatsnew/3 11 whatsnew311-c-api-porting737097
Ref: 70a737097
Ref: whatsnew/3 11 whatsnew311-pep670737162
Ref: 578737162
Ref: whatsnew/3 11 pyframeobject-3-11-hiding744577
Ref: 753744577
Ref: Porting to Python 3 11<2>-Footnote-1750534
Ref: Porting to Python 3 11<2>-Footnote-2750597
Ref: Porting to Python 3 11<2>-Footnote-3750639
Ref: Porting to Python 3 11<2>-Footnote-4750694
Ref: Porting to Python 3 11<2>-Footnote-5750759
Ref: Porting to Python 3 11<2>-Footnote-6750824
Ref: Porting to Python 3 11<2>-Footnote-7750889
Ref: Porting to Python 3 11<2>-Footnote-8750931
Ref: Porting to Python 3 11<2>-Footnote-9750996
Ref: Porting to Python 3 11<2>-Footnote-10751051
Ref: Porting to Python 3 11<2>-Footnote-11751107
Ref: Porting to Python 3 11<2>-Footnote-12751173
Ref: Porting to Python 3 11<2>-Footnote-13751216
Ref: Porting to Python 3 11<2>-Footnote-14751282
Ref: Porting to Python 3 11<2>-Footnote-15751348
Ref: Porting to Python 3 11<2>-Footnote-16751414
Ref: Porting to Python 3 11<2>-Footnote-17751480
Ref: Porting to Python 3 11<2>-Footnote-18751546
Ref: Porting to Python 3 11<2>-Footnote-19751612
Ref: Porting to Python 3 11<2>-Footnote-20751668
Ref: Porting to Python 3 11<2>-Footnote-21751721
Ref: Porting to Python 3 11<2>-Footnote-22751787
Ref: Porting to Python 3 11<2>-Footnote-23751853
Ref: Porting to Python 3 11<2>-Footnote-24751906
Node: 非推奨<2>751939
Ref: whatsnew/3 11 id7752079
Ref: 75c752079
Ref: whatsnew/3 11 whatsnew311-c-api-deprecated752079
Ref: 6e2752079
Ref: 非推奨<2>-Footnote-1753043
Ref: 非推奨<2>-Footnote-2753085
Ref: 非推奨<2>-Footnote-3753140
Node: Pending Removal in Python 3 12<2>753205
Ref: whatsnew/3 11 id8753329
Ref: 75e753329
Ref: whatsnew/3 11 whatsnew311-c-api-pending-removal753329
Ref: 6f4753329
Node: 削除<2>754079
Ref: whatsnew/3 11 id9754182
Ref: 760754182
Ref: whatsnew/3 11 whatsnew311-c-api-removed754182
Ref: 6fb754182
Ref: whatsnew/3 11 whatsnew311-pep624756438
Ref: 577756438
Ref: 削除<2>-Footnote-1757398
Ref: 削除<2>-Footnote-2757463
Ref: 削除<2>-Footnote-3757528
Ref: 削除<2>-Footnote-4757593
Ref: 削除<2>-Footnote-5757658
Ref: 削除<2>-Footnote-6757723
Ref: 削除<2>-Footnote-7757788
Ref: 削除<2>-Footnote-8757853
Ref: 削除<2>-Footnote-9757918
Ref: 削除<2>-Footnote-10757983
Ref: 削除<2>-Footnote-11758026
Ref: 削除<2>-Footnote-12758086
Node: Python 3 11 4での重要な変更点758152
Ref: whatsnew/3 11 notable-changes-in-3-11-4758321
Ref: 766758321
Node: tarfile758426
Ref: whatsnew/3 11 tarfile758507
Ref: 767758507
Ref: tarfile-Footnote-1759111
Node: Python 3 11 5での重要な変更点759153
Ref: whatsnew/3 11 notable-changes-in-3-11-5759298
Ref: 768759298
Node: OpenSSL759403
Ref: whatsnew/3 11 openssl759484
Ref: 769759484
Node: What's New In Python 3 10759603
Ref: whatsnew/3 10 doc759752
Ref: 76a759752
Ref: whatsnew/3 10 what-s-new-in-python-3-10759752
Ref: 76b759752
Node: 概要 -- リリースハイライト<2>760969
Ref: whatsnew/3 10 summary-release-highlights761098
Ref: 76c761098
Ref: 概要 -- リリースハイライト<2>-Footnote-1762323
Ref: 概要 -- リリースハイライト<2>-Footnote-2762365
Ref: 概要 -- リリースハイライト<2>-Footnote-3762407
Ref: 概要 -- リリースハイライト<2>-Footnote-4762449
Ref: 概要 -- リリースハイライト<2>-Footnote-5762514
Ref: 概要 -- リリースハイライト<2>-Footnote-6762556
Ref: 概要 -- リリースハイライト<2>-Footnote-7762598
Ref: 概要 -- リリースハイライト<2>-Footnote-8762640
Ref: 概要 -- リリースハイライト<2>-Footnote-9762682
Ref: 概要 -- リリースハイライト<2>-Footnote-10762724
Ref: 概要 -- リリースハイライト<2>-Footnote-11762767
Ref: 概要 -- リリースハイライト<2>-Footnote-12762810
Ref: 概要 -- リリースハイライト<2>-Footnote-13762853
Ref: 概要 -- リリースハイライト<2>-Footnote-14762896
Ref: 概要 -- リリースハイライト<2>-Footnote-15762939
Node: 新しい機能<3>762982
Ref: whatsnew/3 10 new-features763165
Ref: 76d763165
Node: カッコ内のコンテキストマネージャー763573
Ref: whatsnew/3 10 parenthesized-context-managers763721
Ref: 76e763721
Ref: whatsnew/3 10 whatsnew310-pep563763721
Ref: 76f763721
Ref: カッコ内のコンテキストマネージャー-Footnote-1765135
Ref: カッコ内のコンテキストマネージャー-Footnote-2765177
Ref: カッコ内のコンテキストマネージャー-Footnote-3765242
Node: エラーメッセージの改善765307
Ref: whatsnew/3 10 better-error-messages765522
Ref: 770765522
Node: SyntaxErrors765680
Ref: whatsnew/3 10 syntaxerrors765788
Ref: 771765788
Ref: SyntaxErrors-Footnote-1771311
Ref: SyntaxErrors-Footnote-2771376
Ref: SyntaxErrors-Footnote-3771441
Ref: SyntaxErrors-Footnote-4771506
Ref: SyntaxErrors-Footnote-5771571
Ref: SyntaxErrors-Footnote-6771636
Ref: SyntaxErrors-Footnote-7771701
Ref: SyntaxErrors-Footnote-8771766
Ref: SyntaxErrors-Footnote-9771831
Ref: SyntaxErrors-Footnote-10771896
Ref: SyntaxErrors-Footnote-11771962
Node: IndentationErrors772028
Ref: whatsnew/3 10 indentationerrors772160
Ref: 772772160
Node: AttributeErrors772577
Ref: whatsnew/3 10 attributeerrors772707
Ref: 774772707
Ref: AttributeErrors-Footnote-1773457
Node: NameErrors773522
Ref: whatsnew/3 10 nameerrors773626
Ref: 775773626
Ref: NameErrors-Footnote-1774436
Node: PEP 626 Precise line numbers for debugging and other tools774501
Ref: whatsnew/3 10 pep-626-precise-line-numbers-for-debugging-and-other-tools774703
Ref: 776774703
Node: PEP 634 構造的パターンマッチ775398
Ref: whatsnew/3 10 pep-634-structural-pattern-matching775620
Ref: 778775620
Node: Syntax and operations776403
Ref: whatsnew/3 10 syntax-and-operations776528
Ref: 779776528
Node: Declarative approach777594
Ref: whatsnew/3 10 declarative-approach777761
Ref: 77a777761
Node: Simple pattern match to a literal778918
Ref: whatsnew/3 10 simple-pattern-match-to-a-literal779100
Ref: 77b779100
Node: Behavior without the wildcard780490
Ref: whatsnew/3 10 behavior-without-the-wildcard780589
Ref: 77c780589
Node: Patterns with a literal and variable781171
Ref: whatsnew/3 10 patterns-with-a-literal-and-variable781353
Ref: 77d781353
Node: Patterns and classes782321
Ref: whatsnew/3 10 patterns-and-classes782485
Ref: 77e782485
Node: Patterns with positional parameters783370
Ref: whatsnew/3 10 patterns-with-positional-parameters783462
Ref: 77f783462
Node: Nested patterns784086
Ref: whatsnew/3 10 nested-patterns784247
Ref: 780784247
Node: Complex patterns and the wildcard784886
Ref: whatsnew/3 10 complex-patterns-and-the-wildcard785032
Ref: 781785032
Node: Guard785598
Ref: whatsnew/3 10 guard785747
Ref: 782785747
Node: Other Key Features786269
Ref: whatsnew/3 10 other-key-features786376
Ref: 783786376
Ref: Other Key Features-Footnote-1788578
Ref: Other Key Features-Footnote-2788620
Ref: Other Key Features-Footnote-3788662
Node: Optional EncodingWarning and encoding="locale" option788704
Ref: whatsnew/3 10 optional-encodingwarning-and-encoding-locale-option788859
Ref: 784788859
Ref: whatsnew/3 10 whatsnew310-pep597788859
Ref: 785788859
Node: 型ヒントに関連する新しい機能<2>789759
Ref: whatsnew/3 10 new-feat-related-type-hints789929
Ref: 789789929
Ref: whatsnew/3 10 new-features-related-to-type-hints789929
Ref: 78a789929
Ref: 型ヒントに関連する新しい機能<2>-Footnote-1790431
Node: PEP 604 New Type Union Operator790473
Ref: whatsnew/3 10 pep-604-new-type-union-operator790636
Ref: 78b790636
Ref: PEP 604 New Type Union Operator-Footnote-1791705
Ref: PEP 604 New Type Union Operator-Footnote-2791747
Ref: PEP 604 New Type Union Operator-Footnote-3791812
Node: PEP 612 Parameter Specification Variables791877
Ref: whatsnew/3 10 pep-612-parameter-specification-variables792066
Ref: 78e792066
Ref: PEP 612 Parameter Specification Variables-Footnote-1793346
Ref: PEP 612 Parameter Specification Variables-Footnote-2793388
Ref: PEP 612 Parameter Specification Variables-Footnote-3793430
Ref: PEP 612 Parameter Specification Variables-Footnote-4793495
Node: PEP 613 TypeAlias793560
Ref: whatsnew/3 10 pep-613-typealias793750
Ref: 793793750
Ref: PEP 613 TypeAlias-Footnote-1794602
Ref: PEP 613 TypeAlias-Footnote-2794644
Ref: PEP 613 TypeAlias-Footnote-3794686
Node: PEP 647 User-Defined Type Guards794751
Ref: whatsnew/3 10 pep-647-user-defined-type-guards794891
Ref: 795794891
Ref: PEP 647 User-Defined Type Guards-Footnote-1795376
Ref: PEP 647 User-Defined Type Guards-Footnote-2795418
Node: その他の言語変更<2>795483
Ref: whatsnew/3 10 other-language-changes795662
Ref: 796795662
Ref: その他の言語変更<2>-Footnote-1800340
Ref: その他の言語変更<2>-Footnote-2800405
Ref: その他の言語変更<2>-Footnote-3800470
Ref: その他の言語変更<2>-Footnote-4800512
Ref: その他の言語変更<2>-Footnote-5800577
Ref: その他の言語変更<2>-Footnote-6800642
Ref: その他の言語変更<2>-Footnote-7800707
Ref: その他の言語変更<2>-Footnote-8800772
Ref: その他の言語変更<2>-Footnote-9800837
Ref: その他の言語変更<2>-Footnote-10800879
Ref: その他の言語変更<2>-Footnote-11800945
Ref: その他の言語変更<2>-Footnote-12801011
Ref: その他の言語変更<2>-Footnote-13801077
Ref: その他の言語変更<2>-Footnote-14801143
Ref: その他の言語変更<2>-Footnote-15801209
Ref: その他の言語変更<2>-Footnote-16801275
Node: 新たなモジュール<2>801341
Ref: whatsnew/3 10 new-modules801508
Ref: 7a6801508
Node: 改良されたモジュール<2>801575
Ref: whatsnew/3 10 improved-modules801727
Ref: 7a7801727
Node: asyncio<4>802889
Ref: whatsnew/3 10 asyncio802989
Ref: 7a8802989
Ref: asyncio<4>-Footnote-1803161
Node: argparse<2>803226
Ref: whatsnew/3 10 argparse803343
Ref: 7a9803343
Ref: argparse<2>-Footnote-1803625
Node: array<3>803689
Ref: whatsnew/3 10 array803819
Ref: 7aa803819
Ref: array<3>-Footnote-1804061
Node: asynchat asyncore smtpd804126
Ref: whatsnew/3 10 asynchat-asyncore-smtpd804254
Ref: 7ac804254
Node: base64<2>804514
Ref: whatsnew/3 10 base64804637
Ref: 7ad804637
Node: bdb804804
Ref: whatsnew/3 10 bdb804910
Ref: 7b0804910
Ref: bdb-Footnote-1805079
Node: bisect805144
Ref: whatsnew/3 10 bisect805247
Ref: 7b1805247
Ref: bisect-Footnote-1805463
Node: codecs805527
Ref: whatsnew/3 10 codecs805642
Ref: 7b2805642
Ref: codecs-Footnote-1805839
Node: collections abc805904
Ref: whatsnew/3 10 collections-abc806026
Ref: 7b4806026
Ref: collections abc-Footnote-1806947
Node: contextlib<2>807012
Ref: whatsnew/3 10 contextlib807134
Ref: 7b7807134
Ref: contextlib<2>-Footnote-1807656
Ref: contextlib<2>-Footnote-2807721
Node: curses807786
Ref: whatsnew/3 10 curses807914
Ref: 7bb807914
Ref: curses-Footnote-1808611
Ref: curses-Footnote-2808676
Node: データクラス<2>808741
Ref: whatsnew/3 10 dataclasses808868
Ref: 7c1808868
Node: __slots__808967
Ref: whatsnew/3 10 slots809062
Ref: 7c2809062
Ref: __slots__-Footnote-1809264
Node: Keyword-only fields809329
Ref: whatsnew/3 10 keyword-only-fields809424
Ref: 7c3809424
Ref: Keyword-only fields-Footnote-1810897
Node: distutils<2>810962
Ref: whatsnew/3 10 distutils811093
Ref: 7c4811093
Ref: whatsnew/3 10 distutils-deprecated811093
Ref: 6f5811093
Ref: distutils<2>-Footnote-1812001
Ref: distutils<2>-Footnote-2812043
Node: doctest<2>812108
Ref: whatsnew/3 10 doctest812242
Ref: 7c5812242
Ref: doctest<2>-Footnote-1812446
Node: エンコーディング812511
Ref: whatsnew/3 10 encodings812640
Ref: 7c6812640
Ref: エンコーディング-Footnote-1812851
Node: enum<3>812916
Ref: whatsnew/3 10 enum813044
Ref: 7c7813044
Ref: enum<3>-Footnote-1813517
Ref: enum<3>-Footnote-2813582
Node: fileinput813647
Ref: whatsnew/3 10 fileinput813763
Ref: 7c9813763
Ref: fileinput-Footnote-1814194
Ref: fileinput-Footnote-2814259
Node: faulthandler814323
Ref: whatsnew/3 10 faulthandler814434
Ref: 7cc814434
Ref: faulthandler-Footnote-1814676
Node: gc814741
Ref: whatsnew/3 10 gc814850
Ref: 7cd814850
Ref: gc-Footnote-1815075
Node: glob<2>815140
Ref: whatsnew/3 10 glob815247
Ref: 7d1815247
Ref: glob<2>-Footnote-1815511
Node: hashlib<3>815576
Ref: whatsnew/3 10 hashlib815685
Ref: 7d3815685
Ref: hashlib<3>-Footnote-1816228
Ref: hashlib<3>-Footnote-2816270
Ref: hashlib<3>-Footnote-3816335
Ref: hashlib<3>-Footnote-4816400
Node: hmac816465
Ref: whatsnew/3 10 hmac816587
Ref: 7d4816587
Ref: hmac-Footnote-1816771
Node: IDLE と idelelib<2>816836
Ref: whatsnew/3 10 idle-and-idlelib816969
Ref: 7d5816969
Ref: IDLE と idelelib<2>-Footnote-1819041
Ref: IDLE と idelelib<2>-Footnote-2819106
Ref: IDLE と idelelib<2>-Footnote-3819171
Ref: IDLE と idelelib<2>-Footnote-4819236
Ref: IDLE と idelelib<2>-Footnote-5819301
Ref: IDLE と idelelib<2>-Footnote-6819366
Ref: IDLE と idelelib<2>-Footnote-7819431
Ref: IDLE と idelelib<2>-Footnote-8819496
Node: importlib metadata<2>819551
Ref: whatsnew/3 10 importlib-metadata819690
Ref: 7da819690
Ref: importlib metadata<2>-Footnote-1820284
Node: inspect<3>820357
Ref: whatsnew/3 10 inspect820488
Ref: 7dd820488
Ref: inspect<3>-Footnote-1821691
Ref: inspect<3>-Footnote-2821756
Node: itertools<3>821821
Ref: whatsnew/3 10 itertools821940
Ref: 7df821940
Ref: itertools<3>-Footnote-1822106
Node: linecache822171
Ref: whatsnew/3 10 linecache822285
Ref: 7e1822285
Ref: linecache-Footnote-1822493
Node: os<4>822558
Ref: whatsnew/3 10 os822670
Ref: 7e2822670
Ref: os<4>-Footnote-1823409
Ref: os<4>-Footnote-2823474
Ref: os<4>-Footnote-3823539
Ref: os<4>-Footnote-4823604
Node: os path<3>823669
Ref: whatsnew/3 10 os-path823782
Ref: 7e9823782
Ref: os path<3>-Footnote-1824091
Node: pathlib<5>824156
Ref: whatsnew/3 10 pathlib824288
Ref: 7ea824288
Ref: pathlib<5>-Footnote-1824997
Ref: pathlib<5>-Footnote-2825062
Ref: pathlib<5>-Footnote-3825127
Ref: pathlib<5>-Footnote-4825192
Node: プラットフォーム825257
Ref: whatsnew/3 10 platform825385
Ref: 7f0825385
Ref: プラットフォーム-Footnote-1825678
Ref: プラットフォーム-Footnote-2825751
Node: pprint825816
Ref: whatsnew/3 10 pprint825944
Ref: 7f2825944
Ref: pprint-Footnote-1826278
Ref: pprint-Footnote-2826343
Node: py_compile826408
Ref: whatsnew/3 10 py-compile826518
Ref: 7f4826518
Ref: py_compile-Footnote-1826726
Node: pyclbr826791
Ref: whatsnew/3 10 pyclbr826901
Ref: 7f5826901
Ref: pyclbr-Footnote-1827245
Node: shelve827310
Ref: whatsnew/3 10 shelve827423
Ref: 7f8827423
Ref: shelve-Footnote-1827696
Node: statistics<3>827761
Ref: whatsnew/3 10 statistics827875
Ref: 7fa827875
Ref: statistics<3>-Footnote-1828128
Node: site<2>828193
Ref: whatsnew/3 10 site828310
Ref: 7fd828310
Ref: site<2>-Footnote-1828508
Node: socket<2>828573
Ref: whatsnew/3 10 socket828683
Ref: 7fe828683
Ref: socket<2>-Footnote-1829129
Ref: socket<2>-Footnote-2829194
Ref: socket<2>-Footnote-3829259
Node: ssl<3>829324
Ref: whatsnew/3 10 ssl829437
Ref: 801829437
Ref: ssl<3>-Footnote-1831276
Ref: ssl<3>-Footnote-2831318
Ref: ssl<3>-Footnote-3831383
Ref: ssl<3>-Footnote-4831448
Ref: ssl<3>-Footnote-5831513
Ref: ssl<3>-Footnote-6831578
Ref: ssl<3>-Footnote-7831643
Ref: ssl<3>-Footnote-8831708
Ref: ssl<3>-Footnote-9831773
Ref: ssl<3>-Footnote-10831838
Ref: ssl<3>-Footnote-11831904
Ref: ssl<3>-Footnote-12831970
Ref: ssl<3>-Footnote-13832036
Ref: ssl<3>-Footnote-14832102
Ref: ssl<3>-Footnote-15832168
Node: sqlite3<5>832234
Ref: whatsnew/3 10 sqlite3832344
Ref: 808832344
Ref: sqlite3<5>-Footnote-1832583
Node: sys<5>832648
Ref: whatsnew/3 10 sys832759
Ref: 80a832759
Ref: sys<5>-Footnote-1833144
Ref: sys<5>-Footnote-2833209
Node: _thread833274
Ref: whatsnew/3 10 thread833387
Ref: 80d833387
Ref: _thread-Footnote-1833643
Node: threading<3>833708
Ref: whatsnew/3 10 threading833827
Ref: 810833827
Ref: threading<3>-Footnote-1834369
Ref: threading<3>-Footnote-2834434
Node: traceback<3>834499
Ref: whatsnew/3 10 traceback834619
Ref: 817834619
Ref: traceback<3>-Footnote-1834947
Node: types<3>835012
Ref: whatsnew/3 10 types835129
Ref: 81b835129
Ref: types<3>-Footnote-1835438
Node: typing<5>835503
Ref: whatsnew/3 10 typing835619
Ref: 81f835619
Ref: typing<5>-Footnote-1837851
Ref: typing<5>-Footnote-2837893
Ref: typing<5>-Footnote-3837958
Ref: typing<5>-Footnote-4838023
Ref: typing<5>-Footnote-5838088
Node: unittest<5>838153
Ref: whatsnew/3 10 unittest838273
Ref: 822838273
Ref: unittest<5>-Footnote-1838489
Node: urllib parse838554
Ref: whatsnew/3 10 urllib-parse838671
Ref: 825838671
Ref: urllib parse-Footnote-1839819
Ref: urllib parse-Footnote-2839884
Ref: urllib parse-Footnote-3839943
Node: xml<2>839998
Ref: whatsnew/3 10 xml840116
Ref: 826840116
Ref: xml<2>-Footnote-1840332
Node: zipimport<3>840397
Ref: whatsnew/3 10 zipimport840494
Ref: 828840494
Ref: zipimport<3>-Footnote-1840874
Ref: zipimport<3>-Footnote-2840916
Ref: zipimport<3>-Footnote-3840981
Node: 最適化<2>841046
Ref: whatsnew/3 10 optimizations841183
Ref: 82c841183
Ref: 最適化<2>-Footnote-1844651
Ref: 最適化<2>-Footnote-2844716
Ref: 最適化<2>-Footnote-3844781
Ref: 最適化<2>-Footnote-4844846
Ref: 最適化<2>-Footnote-5844911
Ref: 最適化<2>-Footnote-6844976
Ref: 最適化<2>-Footnote-7845097
Ref: 最適化<2>-Footnote-8845162
Ref: 最適化<2>-Footnote-9845227
Ref: 最適化<2>-Footnote-10845292
Ref: 最適化<2>-Footnote-11845358
Ref: 最適化<2>-Footnote-12845424
Ref: 最適化<2>-Footnote-13845467
Ref: 最適化<2>-Footnote-14845533
Ref: 最適化<2>-Footnote-15845599
Ref: 最適化<2>-Footnote-16845665
Ref: 最適化<2>-Footnote-17845731
Ref: 最適化<2>-Footnote-18845797
Node: 非推奨<3>845863
Ref: whatsnew/3 10 deprecated845976
Ref: 833845976
Ref: whatsnew/3 10 whatsnew310-deprecated845976
Ref: 806845976
Ref: 非推奨<3>-Footnote-1855383
Ref: 非推奨<3>-Footnote-2855448
Ref: 非推奨<3>-Footnote-3855513
Ref: 非推奨<3>-Footnote-4855578
Ref: 非推奨<3>-Footnote-5855643
Ref: 非推奨<3>-Footnote-6855708
Ref: 非推奨<3>-Footnote-7855773
Ref: 非推奨<3>-Footnote-8855838
Ref: 非推奨<3>-Footnote-9855903
Ref: 非推奨<3>-Footnote-10855968
Ref: 非推奨<3>-Footnote-11856034
Ref: 非推奨<3>-Footnote-12856100
Ref: 非推奨<3>-Footnote-13856166
Ref: 非推奨<3>-Footnote-14856232
Ref: 非推奨<3>-Footnote-15856291
Ref: 非推奨<3>-Footnote-16856357
Ref: 非推奨<3>-Footnote-17856413
Ref: 非推奨<3>-Footnote-18856479
Ref: 非推奨<3>-Footnote-19856545
Ref: 非推奨<3>-Footnote-20856611
Node: 削除<3>856677
Ref: whatsnew/3 10 removed856800
Ref: 841856800
Ref: whatsnew/3 10 whatsnew310-removed856800
Ref: 842856800
Ref: 削除<3>-Footnote-1860031
Ref: 削除<3>-Footnote-2860096
Ref: 削除<3>-Footnote-3860161
Ref: 削除<3>-Footnote-4860226
Ref: 削除<3>-Footnote-5860291
Ref: 削除<3>-Footnote-6860356
Ref: 削除<3>-Footnote-7860421
Node: Porting to Python 3 10860486
Ref: whatsnew/3 10 porting-to-python-3-10860635
Ref: 847860635
Node: Changes in the Python syntax860951
Ref: whatsnew/3 10 changes-in-the-python-syntax861067
Ref: 848861067
Ref: Changes in the Python syntax-Footnote-1861662
Node: Python API の変更861727
Ref: whatsnew/3 10 changes-in-the-python-api861870
Ref: 849861870
Ref: whatsnew/3 10 changes-python-api861870
Ref: 846861870
Ref: Python API の変更-Footnote-1864779
Ref: Python API の変更-Footnote-2864844
Ref: Python API の変更-Footnote-3864909
Ref: Python API の変更-Footnote-4864974
Ref: Python API の変更-Footnote-5865039
Ref: Python API の変更-Footnote-6865104
Node: C API の変更<2>865169
Ref: whatsnew/3 10 changes-in-the-c-api865275
Ref: 851865275
Node: CPython バイトコードの変更<2>867734
Ref: whatsnew/3 10 cpython-bytecode-changes867890
Ref: 857867890
Ref: CPython バイトコードの変更<2>-Footnote-1868200
Node: Build Changes<4>868265
Ref: whatsnew/3 10 build-changes868417
Ref: 858868417
Ref: Build Changes<4>-Footnote-1870877
Ref: Build Changes<4>-Footnote-2870919
Ref: Build Changes<4>-Footnote-3870984
Ref: Build Changes<4>-Footnote-4871049
Ref: Build Changes<4>-Footnote-5871114
Ref: Build Changes<4>-Footnote-6871179
Ref: Build Changes<4>-Footnote-7871244
Ref: Build Changes<4>-Footnote-8871309
Ref: Build Changes<4>-Footnote-9871374
Ref: Build Changes<4>-Footnote-10871439
Ref: Build Changes<4>-Footnote-11871505
Node: C API の変更<3>871571
Ref: whatsnew/3 10 c-api-changes871719
Ref: 85d871719
Node: PEP 652 Maintaining the Stable ABI871988
Ref: whatsnew/3 10 pep-652-maintaining-the-stable-abi872104
Ref: 85e872104
Ref: PEP 652 Maintaining the Stable ABI-Footnote-1872540
Ref: PEP 652 Maintaining the Stable ABI-Footnote-2872582
Node: 新しい機能<4>872647
Ref: whatsnew/3 10 id1872797
Ref: 85f872797
Ref: 新しい機能<4>-Footnote-1877423
Ref: 新しい機能<4>-Footnote-2877488
Ref: 新しい機能<4>-Footnote-3877553
Ref: 新しい機能<4>-Footnote-4877618
Ref: 新しい機能<4>-Footnote-5877683
Ref: 新しい機能<4>-Footnote-6877748
Ref: 新しい機能<4>-Footnote-7877813
Ref: 新しい機能<4>-Footnote-8877880
Ref: 新しい機能<4>-Footnote-9877945
Ref: 新しい機能<4>-Footnote-10878010
Ref: 新しい機能<4>-Footnote-11878076
Ref: 新しい機能<4>-Footnote-12878142
Ref: 新しい機能<4>-Footnote-13878208
Ref: 新しい機能<4>-Footnote-14878274
Ref: 新しい機能<4>-Footnote-15878340
Ref: 新しい機能<4>-Footnote-16878406
Ref: 新しい機能<4>-Footnote-17878472
Ref: 新しい機能<4>-Footnote-18878538
Node: Porting to Python 3 10<2>878604
Ref: whatsnew/3 10 id2878732
Ref: 874878732
Ref: Porting to Python 3 10<2>-Footnote-1882410
Ref: Porting to Python 3 10<2>-Footnote-2882452
Ref: Porting to Python 3 10<2>-Footnote-3882517
Ref: Porting to Python 3 10<2>-Footnote-4882582
Ref: Porting to Python 3 10<2>-Footnote-5882647
Ref: Porting to Python 3 10<2>-Footnote-6882712
Ref: Porting to Python 3 10<2>-Footnote-7882777
Ref: Porting to Python 3 10<2>-Footnote-8882842
Ref: Porting to Python 3 10<2>-Footnote-9882907
Ref: Porting to Python 3 10<2>-Footnote-10882972
Ref: Porting to Python 3 10<2>-Footnote-11883038
Node: 非推奨<4>883104
Ref: whatsnew/3 10 id3883223
Ref: 87e883223
Ref: 非推奨<4>-Footnote-1883517
Node: 削除<4>883582
Ref: whatsnew/3 10 id4883667
Ref: 880883667
Ref: 削除<4>-Footnote-1888667
Ref: 削除<4>-Footnote-2888732
Ref: 削除<4>-Footnote-3888774
Ref: 削除<4>-Footnote-4888839
Ref: 削除<4>-Footnote-5888904
Ref: 削除<4>-Footnote-6888969
Ref: 削除<4>-Footnote-7889034
Ref: 削除<4>-Footnote-8889099
Ref: 削除<4>-Footnote-9889164
Ref: 削除<4>-Footnote-10889206
Ref: 削除<4>-Footnote-11889272
Ref: 削除<4>-Footnote-12889338
Ref: 削除<4>-Footnote-13889404
Ref: 削除<4>-Footnote-14889470
Ref: 削除<4>-Footnote-15889536
Ref: 削除<4>-Footnote-16889602
Node: Notable security feature in 3 10 7889668
Ref: whatsnew/3 10 notable-security-feature-in-3-10-7889834
Ref: 88d889834
Ref: Notable security feature in 3 10 7-Footnote-1890564
Node: Notable security feature in 3 10 8890620
Ref: whatsnew/3 10 notable-security-feature-in-3-10-8890794
Ref: 88e890794
Ref: Notable security feature in 3 10 8-Footnote-1891216
Node: Notable changes in 3 10 12891271
Ref: whatsnew/3 10 notable-changes-in-3-10-12891402
Ref: 88f891402
Node: tarfile<2>891504
Ref: whatsnew/3 10 tarfile891577
Ref: 890891577
Ref: tarfile<2>-Footnote-1892181
Node: What's New In Python 3 9892223
Ref: whatsnew/3 9 doc892371
Ref: 891892371
Ref: whatsnew/3 9 what-s-new-in-python-3-9892371
Ref: 892892371
Ref: What's New In Python 3 9-Footnote-1893852
Node: 概要 -- リリースハイライト<3>893894
Ref: whatsnew/3 9 summary-release-highlights894084
Ref: 893894084
Ref: 概要 -- リリースハイライト<3>-Footnote-1896447
Ref: 概要 -- リリースハイライト<3>-Footnote-2896489
Ref: 概要 -- リリースハイライト<3>-Footnote-3896531
Ref: 概要 -- リリースハイライト<3>-Footnote-4896573
Ref: 概要 -- リリースハイライト<3>-Footnote-5896615
Ref: 概要 -- リリースハイライト<3>-Footnote-6896657
Ref: 概要 -- リリースハイライト<3>-Footnote-7896699
Ref: 概要 -- リリースハイライト<3>-Footnote-8896741
Ref: 概要 -- リリースハイライト<3>-Footnote-9896783
Ref: 概要 -- リリースハイライト<3>-Footnote-10896825
Node: コード中の非推奨警告 DeprecationWarning をチェックして下さい896868
Ref: whatsnew/3 9 you-should-check-for-deprecationwarning-in-your-code897085
Ref: 894897085
Node: 新しい機能<5>899238
Ref: whatsnew/3 9 new-features899442
Ref: 89a899442
Node: 辞書のマージと更新演算子899796
Ref: whatsnew/3 9 dictionary-merge-update-operators899956
Ref: 89b899956
Ref: 辞書のマージと更新演算子-Footnote-1900772
Ref: 辞書のマージと更新演算子-Footnote-2900814
Node: prefixとsuffixを削除する新しい文字列メソッド900879
Ref: whatsnew/3 9 new-string-methods-to-remove-prefixes-and-suffixes901130
Ref: 89c901130
Ref: prefixとsuffixを削除する新しい文字列メソッド-Footnote-1901680
Ref: prefixとsuffixを削除する新しい文字列メソッド-Footnote-2901722
Node: 標準コレクション型の型ヒントにおける総称型 generics の使用901787
Ref: whatsnew/3 9 type-hinting-generics-in-standard-collections902023
Ref: 89f902023
Ref: 標準コレクション型の型ヒントにおける総称型 generics の使用-Footnote-1902891
Ref: 標準コレクション型の型ヒントにおける総称型 generics の使用-Footnote-2902933
Node: 新しいパーサー902998
Ref: whatsnew/3 9 new-parser903165
Ref: 8a0903165
Ref: 新しいパーサー-Footnote-1904236
Ref: 新しいパーサー-Footnote-2904284
Ref: 新しいパーサー-Footnote-3904349
Ref: 新しいパーサー-Footnote-4904391
Node: その他の言語変更<3>904456
Ref: whatsnew/3 9 other-language-changes904607
Ref: 8a1904607
Ref: その他の言語変更<3>-Footnote-1907708
Ref: その他の言語変更<3>-Footnote-2907773
Ref: その他の言語変更<3>-Footnote-3907838
Ref: その他の言語変更<3>-Footnote-4907903
Ref: その他の言語変更<3>-Footnote-5907968
Ref: その他の言語変更<3>-Footnote-6908010
Ref: その他の言語変更<3>-Footnote-7908075
Ref: その他の言語変更<3>-Footnote-8908140
Ref: その他の言語変更<3>-Footnote-9908205
Ref: その他の言語変更<3>-Footnote-10908270
Ref: その他の言語変更<3>-Footnote-11908336
Node: 新たなモジュール<3>908402
Ref: whatsnew/3 9 new-modules908568
Ref: 8ab908568
Node: zoneinfo908659
Ref: whatsnew/3 9 zoneinfo908748
Ref: 8ac908748
Ref: zoneinfo-Footnote-1909969
Ref: zoneinfo-Footnote-2910010
Node: graphlib910052
Ref: whatsnew/3 9 graphlib910141
Ref: 8ae910141
Ref: graphlib-Footnote-1910465
Node: 改良されたモジュール<3>910530
Ref: whatsnew/3 9 improved-modules910681
Ref: 8b0910681
Node: ast<2>911516
Ref: whatsnew/3 9 ast911611
Ref: 8b1911611
Ref: ast<2>-Footnote-1912279
Ref: ast<2>-Footnote-2912344
Ref: ast<2>-Footnote-3912409
Node: asyncio<5>912474
Ref: whatsnew/3 9 asyncio912591
Ref: 8b4912591
Ref: asyncio<5>-Footnote-1914368
Ref: asyncio<5>-Footnote-2914433
Ref: asyncio<5>-Footnote-3914498
Ref: asyncio<5>-Footnote-4914563
Ref: asyncio<5>-Footnote-5914628
Ref: asyncio<5>-Footnote-6914693
Node: compileall<2>914758
Ref: whatsnew/3 9 compileall914890
Ref: 8b9914890
Ref: compileall<2>-Footnote-1915470
Ref: compileall<2>-Footnote-2915535
Node: concurrent futures<2>915600
Ref: whatsnew/3 9 concurrent-futures915731
Ref: 8ba915731
Ref: concurrent futures<2>-Footnote-1916610
Ref: concurrent futures<2>-Footnote-2916675
Ref: concurrent futures<2>-Footnote-3916740
Node: curses<2>916805
Ref: whatsnew/3 9 curses916934
Ref: 8bd916934
Ref: curses<2>-Footnote-1917248
Node: datetime<2>917313
Ref: whatsnew/3 9 datetime917433
Ref: 8c2917433
Ref: datetime<2>-Footnote-1917751
Node: distutils<3>917816
Ref: whatsnew/3 9 distutils917935
Ref: 8c5917935
Ref: distutils<3>-Footnote-1918186
Node: fcntl<2>918251
Ref: whatsnew/3 9 fcntl918368
Ref: 8c6918368
Ref: fcntl<2>-Footnote-1918556
Node: ftplib<2>918621
Ref: whatsnew/3 9 ftplib918731
Ref: 8c7918731
Ref: ftplib<2>-Footnote-1919021
Node: gc<2>919086
Ref: whatsnew/3 9 gc919198
Ref: 8ca919198
Ref: gc<2>-Footnote-1919736
Ref: gc<2>-Footnote-2919801
Node: hashlib<4>919866
Ref: whatsnew/3 9 hashlib919973
Ref: 8cc919973
Ref: hashlib<4>-Footnote-1920482
Ref: hashlib<4>-Footnote-2920547
Node: http920612
Ref: whatsnew/3 9 http920734
Ref: 8cd920734
Ref: http-Footnote-1921006
Ref: http-Footnote-2921071
Node: IDLE と idelelib<3>921136
Ref: whatsnew/3 9 idle-and-idlelib921255
Ref: 8cf921255
Ref: IDLE と idelelib<3>-Footnote-1922464
Ref: IDLE と idelelib<3>-Footnote-2922528
Ref: IDLE と idelelib<3>-Footnote-3922593
Ref: IDLE と idelelib<3>-Footnote-4922658
Ref: IDLE と idelelib<3>-Footnote-5922723
Ref: IDLE と idelelib<3>-Footnote-6922788
Ref: IDLE と idelelib<3>-Footnote-7922853
Node: imaplib922918
Ref: whatsnew/3 9 imaplib923045
Ref: 8d0923045
Ref: imaplib-Footnote-1923879
Ref: imaplib-Footnote-2923944
Node: importlib<3>924009
Ref: whatsnew/3 9 importlib924126
Ref: 8d7924126
Ref: importlib<3>-Footnote-1924918
Ref: importlib<3>-Footnote-2924983
Ref: importlib<3>-Footnote-3925048
Node: inspect<4>925113
Ref: whatsnew/3 9 inspect925235
Ref: 8d9925235
Ref: inspect<4>-Footnote-1925481
Ref: inspect<4>-Footnote-2925546
Node: ipaddress<2>925611
Ref: whatsnew/3 9 ipaddress925728
Ref: 8db925728
Ref: ipaddress<2>-Footnote-1926293
Ref: ipaddress<2>-Footnote-2926358
Node: math<4>926423
Ref: whatsnew/3 9 math926548
Ref: 8dd926548
Ref: math<4>-Footnote-1927264
Ref: math<4>-Footnote-2927329
Ref: math<4>-Footnote-3927394
Ref: math<4>-Footnote-4927459
Ref: math<4>-Footnote-5927524
Node: multiprocessing<2>927589
Ref: whatsnew/3 9 multiprocessing927709
Ref: 8e1927709
Ref: multiprocessing<2>-Footnote-1927965
Node: nntplib928030
Ref: whatsnew/3 9 nntplib928148
Ref: 8e4928148
Ref: nntplib-Footnote-1928432
Node: os<5>928497
Ref: whatsnew/3 9 os928607
Ref: 8e5928607
Ref: os<5>-Footnote-1929420
Ref: os<5>-Footnote-2929485
Ref: os<5>-Footnote-3929550
Ref: os<5>-Footnote-4929615
Ref: os<5>-Footnote-5929680
Ref: os<5>-Footnote-6929745
Node: pathlib<6>929810
Ref: whatsnew/3 9 pathlib929919
Ref: 8ec929919
Ref: pathlib<6>-Footnote-1930133
Node: pdb<3>930198
Ref: whatsnew/3 9 pdb930308
Ref: 8ef930308
Ref: pdb<3>-Footnote-1930496
Node: poplib930561
Ref: whatsnew/3 9 poplib930670
Ref: 8f1930670
Ref: poplib-Footnote-1930964
Node: pprint<2>931029
Ref: whatsnew/3 9 pprint931137
Ref: 8f4931137
Ref: pprint<2>-Footnote-1931333
Node: pydoc931398
Ref: whatsnew/3 9 pydoc931509
Ref: 8f5931509
Ref: pydoc-Footnote-1931776
Node: random<3>931841
Ref: whatsnew/3 9 random931949
Ref: 8f7931949
Ref: random<3>-Footnote-1932171
Node: signal932236
Ref: whatsnew/3 9 signal932346
Ref: 8f8932346
Ref: signal-Footnote-1932576
Node: smtplib932641
Ref: whatsnew/3 9 smtplib932751
Ref: 8fa932751
Ref: smtplib-Footnote-1933163
Ref: smtplib-Footnote-2933228
Node: socket<3>933293
Ref: whatsnew/3 9 socket933404
Ref: 8fe933404
Ref: socket<3>-Footnote-1933990
Ref: socket<3>-Footnote-2934055
Ref: socket<3>-Footnote-3934120
Node: time<3>934185
Ref: whatsnew/3 9 time934295
Ref: 903934295
Ref: time<3>-Footnote-1934625
Node: sys<6>934690
Ref: whatsnew/3 9 sys934802
Ref: 905934802
Ref: sys<6>-Footnote-1935467
Ref: sys<6>-Footnote-2935534
Node: tracemalloc935599
Ref: whatsnew/3 9 tracemalloc935713
Ref: 908935713
Ref: tracemalloc-Footnote-1935997
Node: typing<6>936062
Ref: whatsnew/3 9 typing936184
Ref: 90a936184
Ref: typing<6>-Footnote-1936540
Node: unicodedata<4>936582
Ref: whatsnew/3 9 unicodedata936700
Ref: 90c936700
Ref: unicodedata<4>-Footnote-1936878
Node: venv<3>936943
Ref: whatsnew/3 9 venv937058
Ref: 90d937058
Ref: venv<3>-Footnote-1937519
Node: xml<3>937584
Ref: whatsnew/3 9 xml937676
Ref: 90e937676
Ref: xml<3>-Footnote-1938034
Node: 最適化<3>938099
Ref: whatsnew/3 9 optimizations938235
Ref: 90f938235
Ref: 最適化<3>-Footnote-1943981
Ref: 最適化<3>-Footnote-2944046
Ref: 最適化<3>-Footnote-3944111
Ref: 最適化<3>-Footnote-4944176
Ref: 最適化<3>-Footnote-5944241
Ref: 最適化<3>-Footnote-6944283
Ref: 最適化<3>-Footnote-7944348
Ref: 最適化<3>-Footnote-8944412
Ref: 最適化<3>-Footnote-9944477
Ref: 最適化<3>-Footnote-10944542
Ref: 最適化<3>-Footnote-11944608
Ref: 最適化<3>-Footnote-12944737
Node: 非推奨<5>944786
Ref: whatsnew/3 9 deprecated944898
Ref: 914944898
Ref: 非推奨<5>-Footnote-1949994
Ref: 非推奨<5>-Footnote-2950059
Ref: 非推奨<5>-Footnote-3950124
Ref: 非推奨<5>-Footnote-4950189
Ref: 非推奨<5>-Footnote-5950254
Ref: 非推奨<5>-Footnote-6950319
Ref: 非推奨<5>-Footnote-7950384
Ref: 非推奨<5>-Footnote-8950449
Ref: 非推奨<5>-Footnote-9950514
Ref: 非推奨<5>-Footnote-10950579
Ref: 非推奨<5>-Footnote-11950645
Ref: 非推奨<5>-Footnote-12950711
Ref: 非推奨<5>-Footnote-13950777
Ref: 非推奨<5>-Footnote-14950843
Ref: 非推奨<5>-Footnote-15950909
Ref: 非推奨<5>-Footnote-16950952
Ref: 非推奨<5>-Footnote-17950992
Ref: 非推奨<5>-Footnote-18951031
Ref: 非推奨<5>-Footnote-19951097
Node: 削除<5>951163
Ref: whatsnew/3 9 removed951285
Ref: 916951285
Ref: whatsnew/3 9 removed-in-python-39951285
Ref: 899951285
Ref: 削除<5>-Footnote-1957425
Ref: 削除<5>-Footnote-2957490
Ref: 削除<5>-Footnote-3957555
Ref: 削除<5>-Footnote-4957620
Ref: 削除<5>-Footnote-5957685
Ref: 削除<5>-Footnote-6957750
Ref: 削除<5>-Footnote-7957815
Ref: 削除<5>-Footnote-8957880
Ref: 削除<5>-Footnote-9957945
Ref: 削除<5>-Footnote-10958010
Ref: 削除<5>-Footnote-11958076
Ref: 削除<5>-Footnote-12958119
Ref: 削除<5>-Footnote-13958185
Ref: 削除<5>-Footnote-14958251
Ref: 削除<5>-Footnote-15958317
Ref: 削除<5>-Footnote-16958383
Ref: 削除<5>-Footnote-17958449
Ref: 削除<5>-Footnote-18958515
Ref: 削除<5>-Footnote-19958581
Ref: 削除<5>-Footnote-20958647
Ref: 削除<5>-Footnote-21958713
Ref: 削除<5>-Footnote-22958779
Node: Python 3 9への移植958845
Ref: whatsnew/3 9 porting-to-python-3-9958971
Ref: 926958971
Node: Python API の変更<2>959353
Ref: whatsnew/3 9 changes-in-the-python-api959462
Ref: 927959462
Ref: Python API の変更<2>-Footnote-1963636
Ref: Python API の変更<2>-Footnote-2963701
Ref: Python API の変更<2>-Footnote-3963766
Ref: Python API の変更<2>-Footnote-4963831
Ref: Python API の変更<2>-Footnote-5963890
Ref: Python API の変更<2>-Footnote-6963955
Ref: Python API の変更<2>-Footnote-7964020
Ref: Python API の変更<2>-Footnote-8964085
Ref: Python API の変更<2>-Footnote-9964150
Ref: Python API の変更<2>-Footnote-10964215
Ref: Python API の変更<2>-Footnote-11964281
Node: C API の変更<4>964347
Ref: whatsnew/3 9 changes-in-the-c-api964503
Ref: 932964503
Ref: C API の変更<4>-Footnote-1966604
Ref: C API の変更<4>-Footnote-2966669
Ref: C API の変更<4>-Footnote-3966734
Node: CPython バイトコードの変更<3>966799
Ref: whatsnew/3 9 cpython-bytecode-changes966923
Ref: 934966923
Ref: CPython バイトコードの変更<3>-Footnote-1967739
Ref: CPython バイトコードの変更<3>-Footnote-2967804
Node: Build Changes<5>967869
Ref: whatsnew/3 9 build-changes968004
Ref: 938968004
Ref: Build Changes<5>-Footnote-1970418
Ref: Build Changes<5>-Footnote-2970485
Ref: Build Changes<5>-Footnote-3970550
Ref: Build Changes<5>-Footnote-4970615
Ref: Build Changes<5>-Footnote-5970680
Ref: Build Changes<5>-Footnote-6970745
Ref: Build Changes<5>-Footnote-7970810
Ref: Build Changes<5>-Footnote-8970875
Node: C API の変更<5>970940
Ref: whatsnew/3 9 c-api-changes971090
Ref: 93a971090
Node: 新しい機能<6>971257
Ref: whatsnew/3 9 id1971364
Ref: 93b971364
Ref: 新しい機能<6>-Footnote-1974382
Ref: 新しい機能<6>-Footnote-2974424
Ref: 新しい機能<6>-Footnote-3974489
Ref: 新しい機能<6>-Footnote-4974554
Ref: 新しい機能<6>-Footnote-5974619
Ref: 新しい機能<6>-Footnote-6974684
Ref: 新しい機能<6>-Footnote-7974749
Ref: 新しい機能<6>-Footnote-8974814
Ref: 新しい機能<6>-Footnote-9974879
Ref: 新しい機能<6>-Footnote-10974944
Ref: 新しい機能<6>-Footnote-11975010
Ref: 新しい機能<6>-Footnote-12975076
Node: Python 3 9への移植<2>975142
Ref: whatsnew/3 9 id2975267
Ref: 947975267
Ref: Python 3 9への移植<2>-Footnote-1979088
Ref: Python 3 9への移植<2>-Footnote-2979130
Ref: Python 3 9への移植<2>-Footnote-3979195
Ref: Python 3 9への移植<2>-Footnote-4979260
Ref: Python 3 9への移植<2>-Footnote-5979324
Ref: Python 3 9への移植<2>-Footnote-6979389
Ref: Python 3 9への移植<2>-Footnote-7979454
Ref: Python 3 9への移植<2>-Footnote-8979496
Ref: Python 3 9への移植<2>-Footnote-9979561
Ref: Python 3 9への移植<2>-Footnote-10979626
Ref: Python 3 9への移植<2>-Footnote-11979692
Node: 削除<6>979758
Ref: whatsnew/3 9 id3979856
Ref: 95a979856
Ref: 削除<6>-Footnote-1983793
Ref: 削除<6>-Footnote-2983858
Ref: 削除<6>-Footnote-3983923
Ref: 削除<6>-Footnote-4983988
Ref: 削除<6>-Footnote-5984053
Ref: 削除<6>-Footnote-6984118
Ref: 削除<6>-Footnote-7984183
Ref: 削除<6>-Footnote-8984248
Ref: 削除<6>-Footnote-9984313
Ref: 削除<6>-Footnote-10984378
Ref: 削除<6>-Footnote-11984444
Ref: 削除<6>-Footnote-12984487
Ref: 削除<6>-Footnote-13984553
Node: Python 3 9 1 での重要な変更点984619
Ref: whatsnew/3 9 notable-changes-in-python-3-9-1984790
Ref: 95d984790
Node: typing<7>985038
Ref: whatsnew/3 9 id4985193
Ref: 95e985193
Ref: typing<7>-Footnote-1986390
Ref: typing<7>-Footnote-2986432
Node: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート986497
Ref: whatsnew/3 9 macos-11-0-big-sur-and-apple-silicon-mac-support986652
Ref: 95f986652
Ref: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート-Footnote-1987478
Node: Python 3 9 2 での重要な変更点987543
Ref: whatsnew/3 9 notable-changes-in-python-3-9-2987733
Ref: 960987733
Node: collections abc<2>987898
Ref: whatsnew/3 9 collections-abc988014
Ref: 961988014
Ref: collections abc<2>-Footnote-1988993
Node: urllib parse<2>989058
Ref: whatsnew/3 9 urllib-parse989174
Ref: 962989174
Ref: urllib parse<2>-Footnote-1989858
Node: Python 3 9 3 での重要な変更点989923
Ref: whatsnew/3 9 notable-changes-in-python-3-9-3990112
Ref: 963990112
Ref: Python 3 9 3 での重要な変更点-Footnote-1990587
Node: Python 3 9 5での重要な変更点990642
Ref: whatsnew/3 9 notable-changes-in-python-3-9-5990828
Ref: 964990828
Node: urllib parse<3>990952
Ref: whatsnew/3 9 id5991040
Ref: 965991040
Ref: urllib parse<3>-Footnote-1991568
Ref: urllib parse<3>-Footnote-2991627
Node: Notable security feature in 3 9 14991682
Ref: whatsnew/3 9 notable-security-feature-in-3-9-14991856
Ref: 966991856
Ref: Notable security feature in 3 9 14-Footnote-1992586
Node: Notable changes in 3 9 17992642
Ref: whatsnew/3 9 notable-changes-in-3-9-17992771
Ref: 967992771
Node: tarfile<3>992871
Ref: whatsnew/3 9 tarfile992943
Ref: 968992943
Ref: tarfile<3>-Footnote-1993547
Node: What's New In Python 3 8993589
Ref: whatsnew/3 8 doc993736
Ref: 969993736
Ref: whatsnew/3 8 what-s-new-in-python-3-8993736
Ref: 96a993736
Node: 概要 -- リリースハイライト<4>995192
Ref: whatsnew/3 8 summary-release-highlights995320
Ref: 96b995320
Node: 新しい機能<7>995396
Ref: whatsnew/3 8 new-features995560
Ref: 96c995560
Node: 代入式996262
Ref: whatsnew/3 8 assignment-expressions996353
Ref: 96d996353
Ref: 代入式-Footnote-1998073
Ref: 代入式-Footnote-2998170
Ref: 代入式-Footnote-3998212
Node: 位置専用引数998277
Ref: whatsnew/3 8 positional-only-parameters998491
Ref: 96e998491
Ref: 位置専用引数-Footnote-11001418
Ref: 位置専用引数-Footnote-21001480
Ref: 位置専用引数-Footnote-31001522
Node: コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム1001587
Ref: whatsnew/3 8 parallel-filesystem-cache-for-compiled-bytecode-files1001853
Ref: 9701001853
Ref: コンパイル済みのバイトコードファイルのキャッシュを併存させるファイルシステム-Footnote-11002785
Node: デバッグビルドとリリースビルドのABI 共通化1002850
Ref: whatsnew/3 8 debug-build-uses-the-same-abi-as-release-build1003155
Ref: 9731003155
Ref: デバッグビルドとリリースビルドのABI 共通化-Footnote-11006268
Ref: デバッグビルドとリリースビルドのABI 共通化-Footnote-21006333
Ref: デバッグビルドとリリースビルドのABI 共通化-Footnote-31006398
Ref: デバッグビルドとリリースビルドのABI 共通化-Footnote-41006463
Node: f-string での = を用いたオブジェクトの表現1006528
Ref: whatsnew/3 8 bpo-36817-whatsnew1006766
Ref: 9751006766
Ref: whatsnew/3 8 f-strings-support-for-self-documenting-expressions-and-debugging1006766
Ref: 9761006766
Ref: f-string での = を用いたオブジェクトの表現-Footnote-11007942
Node: PEP 578 Pythonランタイムの監査フック1008007
Ref: whatsnew/3 8 pep-578-python-runtime-audit-hooks1008214
Ref: 9781008214
Ref: PEP 578 Pythonランタイムの監査フック-Footnote-11008867
Node: PEP 587 Python 初期化設定1008909
Ref: whatsnew/3 8 pep-587-python-initialization-configuration1009113
Ref: 9791009113
Ref: PEP 587 Python 初期化設定-Footnote-11011102
Ref: PEP 587 Python 初期化設定-Footnote-21011144
Ref: PEP 587 Python 初期化設定-Footnote-31011186
Node: PEP 590 Vectorcall a fast calling protocol for CPython1011251
Ref: whatsnew/3 8 pep-590-vectorcall-a-fast-calling-protocol-for-cpython1011487
Ref: 9941011487
Ref: PEP 590 Vectorcall a fast calling protocol for CPython-Footnote-11012134
Ref: PEP 590 Vectorcall a fast calling protocol for CPython-Footnote-21012176
Node: Pickle プロトコルバージョン 5 による帯域外データバッファ1012241
Ref: whatsnew/3 8 pickle-protocol-5-with-out-of-band-data-buffers1012438
Ref: 9951012438
Ref: Pickle プロトコルバージョン 5 による帯域外データバッファ-Footnote-11013294
Ref: Pickle プロトコルバージョン 5 による帯域外データバッファ-Footnote-21013336
Ref: Pickle プロトコルバージョン 5 による帯域外データバッファ-Footnote-31013378
Node: その他の言語変更<4>1013443
Ref: whatsnew/3 8 other-language-changes1013594
Ref: 9961013594
Ref: その他の言語変更<4>-Footnote-11021716
Ref: その他の言語変更<4>-Footnote-21021781
Ref: その他の言語変更<4>-Footnote-31021846
Ref: その他の言語変更<4>-Footnote-41021911
Ref: その他の言語変更<4>-Footnote-51021976
Ref: その他の言語変更<4>-Footnote-61022041
Ref: その他の言語変更<4>-Footnote-71022106
Ref: その他の言語変更<4>-Footnote-81022171
Ref: その他の言語変更<4>-Footnote-91022236
Ref: その他の言語変更<4>-Footnote-101022301
Ref: その他の言語変更<4>-Footnote-111022367
Ref: その他の言語変更<4>-Footnote-121022435
Ref: その他の言語変更<4>-Footnote-131022501
Ref: その他の言語変更<4>-Footnote-141022571
Ref: その他の言語変更<4>-Footnote-151022631
Ref: その他の言語変更<4>-Footnote-161022697
Ref: その他の言語変更<4>-Footnote-171022763
Node: 新たなモジュール<4>1022829
Ref: whatsnew/3 8 new-modules1022995
Ref: 9a21022995
Ref: 新たなモジュール<4>-Footnote-11024201
Node: 改良されたモジュール<4>1024266
Ref: whatsnew/3 8 improved-modules1024417
Ref: 9a31024417
Node: ast<3>1025452
Ref: whatsnew/3 8 ast1025547
Ref: 9a41025547
Ref: ast<3>-Footnote-11026779
Ref: ast<3>-Footnote-21026844
Ref: ast<3>-Footnote-31026886
Ref: ast<3>-Footnote-41026928
Ref: ast<3>-Footnote-51026970
Node: asyncio<6>1027035
Ref: whatsnew/3 8 asyncio1027150
Ref: 9a61027150
Ref: asyncio<6>-Footnote-11030804
Ref: asyncio<6>-Footnote-21030869
Ref: asyncio<6>-Footnote-31030934
Ref: asyncio<6>-Footnote-41030999
Ref: asyncio<6>-Footnote-51031064
Ref: asyncio<6>-Footnote-61031129
Ref: asyncio<6>-Footnote-71031194
Ref: asyncio<6>-Footnote-81031259
Ref: asyncio<6>-Footnote-91031324
Ref: asyncio<6>-Footnote-101031377
Node: builtins<2>1031443
Ref: whatsnew/3 8 builtins1031563
Ref: 9ad1031563
Ref: builtins<2>-Footnote-11032156
Node: collections1032221
Ref: whatsnew/3 8 collections1032339
Ref: 9ae1032339
Ref: collections-Footnote-11032931
Node: cProfile1032996
Ref: whatsnew/3 8 cprofile1033109
Ref: 9b01033109
Ref: cProfile-Footnote-11033549
Node: csv<2>1033614
Ref: whatsnew/3 8 csv1033725
Ref: 9b21033725
Ref: csv<2>-Footnote-11034126
Node: curses<3>1034191
Ref: whatsnew/3 8 curses1034303
Ref: 9b41034303
Ref: curses<3>-Footnote-11034566
Node: ctypes<2>1034631
Ref: whatsnew/3 8 ctypes1034748
Ref: 9b61034748
Ref: ctypes<2>-Footnote-11035395
Node: datetime<3>1035460
Ref: whatsnew/3 8 datetime1035580
Ref: 9b91035580
Ref: datetime<3>-Footnote-11036013
Node: functools<2>1036078
Ref: whatsnew/3 8 functools1036194
Ref: 9bc1036194
Ref: functools<2>-Footnote-11037883
Ref: functools<2>-Footnote-21037948
Ref: functools<2>-Footnote-31038013
Node: gc<3>1038078
Ref: whatsnew/3 8 gc1038190
Ref: 9c11038190
Ref: gc<3>-Footnote-11038476
Node: gettext1038541
Ref: whatsnew/3 8 gettext1038648
Ref: 9c21038648
Ref: gettext-Footnote-11038890
Node: gzip<3>1038954
Ref: whatsnew/3 8 gzip1039076
Ref: 9c41039076
Ref: gzip<3>-Footnote-11039607
Ref: gzip<3>-Footnote-21039672
Node: IDLE と idelelib<4>1039736
Ref: whatsnew/3 8 idle-and-idlelib1039861
Ref: 9c61039861
Ref: IDLE と idelelib<4>-Footnote-11041861
Ref: IDLE と idelelib<4>-Footnote-21041928
Ref: IDLE と idelelib<4>-Footnote-31041992
Ref: IDLE と idelelib<4>-Footnote-41042057
Ref: IDLE と idelelib<4>-Footnote-51042122
Ref: IDLE と idelelib<4>-Footnote-61042187
Ref: IDLE と idelelib<4>-Footnote-71042251
Ref: IDLE と idelelib<4>-Footnote-81042316
Node: inspect<5>1042381
Ref: whatsnew/3 8 inspect1042504
Ref: 9c71042504
Ref: inspect<5>-Footnote-11043345
Node: io<3>1043410
Ref: whatsnew/3 8 io1043525
Ref: 9c91043525
Ref: io<3>-Footnote-11043873
Node: itertools<4>1043938
Ref: whatsnew/3 8 itertools1044052
Ref: 9ca1044052
Ref: itertools<4>-Footnote-11044457
Node: json tool1044522
Ref: whatsnew/3 8 json-tool1044641
Ref: 9cc1044641
Ref: json tool-Footnote-11044893
Node: logging<2>1044958
Ref: whatsnew/3 8 logging1045072
Ref: 9cd1045072
Ref: logging<2>-Footnote-11045787
Node: math<5>1045852
Ref: whatsnew/3 8 math1045964
Ref: 9cf1045964
Ref: math<5>-Footnote-11047905
Ref: math<5>-Footnote-21047970
Ref: math<5>-Footnote-31048035
Ref: math<5>-Footnote-41048100
Ref: math<5>-Footnote-51048165
Ref: math<5>-Footnote-61048230
Ref: math<5>-Footnote-71048295
Ref: math<5>-Footnote-81048360
Node: mmap<2>1048425
Ref: whatsnew/3 8 mmap1048545
Ref: 9d51048545
Ref: mmap<2>-Footnote-11048775
Node: multiprocessing<3>1048840
Ref: whatsnew/3 8 multiprocessing1048958
Ref: 9d71048958
Ref: multiprocessing<3>-Footnote-11049262
Ref: multiprocessing<3>-Footnote-21049327
Node: os<6>1049392
Ref: whatsnew/3 8 os1049513
Ref: 9d81049513
Ref: os<6>-Footnote-11051017
Ref: os<6>-Footnote-21051082
Ref: os<6>-Footnote-31051147
Node: os path<4>1051212
Ref: whatsnew/3 8 os-path1051325
Ref: 9db1051325
Ref: os path<4>-Footnote-11052348
Ref: os path<4>-Footnote-21052413
Ref: os path<4>-Footnote-31052478
Node: pathlib<7>1052543
Ref: whatsnew/3 8 pathlib1052657
Ref: 9e31052657
Ref: pathlib<7>-Footnote-11053566
Ref: pathlib<7>-Footnote-21053631
Node: pickle1053696
Ref: whatsnew/3 8 pickle1053808
Ref: 9eb1053808
Ref: pickle-Footnote-11054146
Node: plistlib1054211
Ref: whatsnew/3 8 plistlib1054322
Ref: 9ee1054322
Ref: plistlib-Footnote-11054560
Node: pprint<3>1054625
Ref: whatsnew/3 8 pprint1054743
Ref: 9f01054743
Ref: pprint<3>-Footnote-11055808
Node: py_compile<2>1055873
Ref: whatsnew/3 8 py-compile1055988
Ref: 9f21055988
Ref: py_compile<2>-Footnote-11056177
Node: shlex1056242
Ref: whatsnew/3 8 shlex1056357
Ref: 9f41056357
Ref: shlex-Footnote-11056561
Node: shutil<4>1056626
Ref: whatsnew/3 8 shutil1056737
Ref: 9f61056737
Ref: shutil<4>-Footnote-11057390
Ref: shutil<4>-Footnote-21057455
Ref: shutil<4>-Footnote-31057520
Node: socket<4>1057585
Ref: whatsnew/3 8 socket1057697
Ref: 9f81057697
Ref: socket<4>-Footnote-11058272
Ref: socket<4>-Footnote-21058337
Node: ssl<4>1058402
Ref: whatsnew/3 8 ssl1058518
Ref: 9fe1058518
Ref: ssl<4>-Footnote-11058780
Node: statistics<4>1058845
Ref: whatsnew/3 8 statistics1058958
Ref: a011058958
Ref: statistics<4>-Footnote-11060687
Ref: statistics<4>-Footnote-21060752
Ref: statistics<4>-Footnote-31060817
Ref: statistics<4>-Footnote-41060882
Ref: statistics<4>-Footnote-51060947
Node: sys<7>1061012
Ref: whatsnew/3 8 sys1061129
Ref: a071061129
Ref: sys<7>-Footnote-11061568
Node: tarfile<4>1061633
Ref: whatsnew/3 8 tarfile1061749
Ref: a091061749
Ref: tarfile<4>-Footnote-11062167
Node: threading<4>1062232
Ref: whatsnew/3 8 threading1062353
Ref: a0a1062353
Ref: threading<4>-Footnote-11063089
Ref: threading<4>-Footnote-21063156
Node: tokenize<2>1063221
Ref: whatsnew/3 8 tokenize1063342
Ref: a0e1063342
Ref: tokenize<2>-Footnote-11063667
Node: tkinter<4>1063732
Ref: whatsnew/3 8 tkinter1063848
Ref: a0f1063848
Ref: tkinter<4>-Footnote-11064391
Ref: tkinter<4>-Footnote-21064456
Ref: tkinter<4>-Footnote-31064521
Node: time<4>1064586
Ref: whatsnew/3 8 time1064700
Ref: a101064700
Ref: time<4>-Footnote-11064879
Node: typing<8>1064944
Ref: whatsnew/3 8 typing1065062
Ref: a121065062
Ref: typing<8>-Footnote-11066527
Ref: typing<8>-Footnote-21066569
Ref: typing<8>-Footnote-31066611
Ref: typing<8>-Footnote-41066653
Node: unicodedata<5>1066695
Ref: whatsnew/3 8 unicodedata1066817
Ref: a161066817
Ref: unicodedata<5>-Footnote-11067245
Ref: unicodedata<5>-Footnote-21067307
Ref: unicodedata<5>-Footnote-31067372
Node: unittest<6>1067437
Ref: whatsnew/3 8 unittest1067557
Ref: a181067557
Ref: unittest<6>-Footnote-11068872
Ref: unittest<6>-Footnote-21068937
Ref: unittest<6>-Footnote-31069002
Ref: unittest<6>-Footnote-41069067
Node: venv<4>1069132
Ref: whatsnew/3 8 venv1069245
Ref: a1e1069245
Ref: venv<4>-Footnote-11069496
Node: weakref1069561
Ref: whatsnew/3 8 weakref1069669
Ref: a1f1069669
Ref: weakref-Footnote-11069962
Node: xml<4>1070027
Ref: whatsnew/3 8 xml1070134
Ref: a211070134
Ref: xml<4>-Footnote-11071308
Ref: xml<4>-Footnote-21071373
Ref: xml<4>-Footnote-31071438
Ref: xml<4>-Footnote-41071503
Ref: xml<4>-Footnote-51071568
Node: xmlrpc1071633
Ref: whatsnew/3 8 xmlrpc1071724
Ref: a241071724
Ref: xmlrpc-Footnote-11072116
Node: 最適化<4>1072181
Ref: whatsnew/3 8 optimizations1072342
Ref: a261072342
Ref: 最適化<4>-Footnote-11076703
Ref: 最適化<4>-Footnote-21076768
Ref: 最適化<4>-Footnote-31076833
Ref: 最適化<4>-Footnote-41076898
Ref: 最適化<4>-Footnote-51076963
Ref: 最適化<4>-Footnote-61077028
Ref: 最適化<4>-Footnote-71077093
Ref: 最適化<4>-Footnote-81077158
Ref: 最適化<4>-Footnote-91077223
Ref: 最適化<4>-Footnote-101077288
Ref: 最適化<4>-Footnote-111077354
Ref: 最適化<4>-Footnote-121077420
Ref: 最適化<4>-Footnote-131077486
Node: ビルドならびに C API の変更1077552
Ref: whatsnew/3 8 build-and-c-api-changes1077692
Ref: a311077692
Ref: ビルドならびに C API の変更-Footnote-11083283
Ref: ビルドならびに C API の変更-Footnote-21083348
Ref: ビルドならびに C API の変更-Footnote-31083413
Ref: ビルドならびに C API の変更-Footnote-41083478
Ref: ビルドならびに C API の変更-Footnote-51083543
Ref: ビルドならびに C API の変更-Footnote-61083608
Ref: ビルドならびに C API の変更-Footnote-71083673
Ref: ビルドならびに C API の変更-Footnote-81083738
Ref: ビルドならびに C API の変更-Footnote-91083803
Ref: ビルドならびに C API の変更-Footnote-101083868
Ref: ビルドならびに C API の変更-Footnote-111083934
Ref: ビルドならびに C API の変更-Footnote-121084000
Node: 非推奨<6>1084066
Ref: whatsnew/3 8 deprecated1084216
Ref: a3a1084216
Ref: 非推奨<6>-Footnote-11090030
Ref: 非推奨<6>-Footnote-21090095
Ref: 非推奨<6>-Footnote-31090160
Ref: 非推奨<6>-Footnote-41090225
Ref: 非推奨<6>-Footnote-51090289
Ref: 非推奨<6>-Footnote-61090354
Ref: 非推奨<6>-Footnote-71090419
Ref: 非推奨<6>-Footnote-81090484
Ref: 非推奨<6>-Footnote-91090549
Ref: 非推奨<6>-Footnote-101090614
Ref: 非推奨<6>-Footnote-111090680
Ref: 非推奨<6>-Footnote-121090746
Ref: 非推奨<6>-Footnote-131090812
Node: API と機能の削除1090878
Ref: whatsnew/3 8 api-and-feature-removals1091014
Ref: a541091014
Ref: API と機能の削除-Footnote-11093822
Ref: API と機能の削除-Footnote-21093877
Ref: API と機能の削除-Footnote-31093942
Ref: API と機能の削除-Footnote-41094007
Ref: API と機能の削除-Footnote-51094072
Ref: API と機能の削除-Footnote-61094137
Ref: API と機能の削除-Footnote-71094202
Ref: API と機能の削除-Footnote-81094267
Ref: API と機能の削除-Footnote-91094332
Ref: API と機能の削除-Footnote-101094397
Ref: API と機能の削除-Footnote-111094463
Node: Python 3 8 への移植1094529
Ref: whatsnew/3 8 porting-to-python-3-81094689
Ref: a581094689
Node: Python の挙動の変更1095142
Ref: whatsnew/3 8 changes-in-python-behavior1095259
Ref: a591095259
Ref: Python の挙動の変更-Footnote-11097616
Ref: Python の挙動の変更-Footnote-21097681
Ref: Python の挙動の変更-Footnote-31097746
Ref: Python の挙動の変更-Footnote-41097811
Ref: Python の挙動の変更-Footnote-51097876
Ref: Python の挙動の変更-Footnote-61097941
Node: Python API の変更<3>1098006
Ref: whatsnew/3 8 changes-in-the-python-api1098150
Ref: a5e1098150
Ref: whatsnew/3 8 bpo-36085-whatsnew1105106
Ref: a6c1105106
Ref: Python API の変更<3>-Footnote-11106766
Ref: Python API の変更<3>-Footnote-21106808
Ref: Python API の変更<3>-Footnote-31106873
Ref: Python API の変更<3>-Footnote-41106938
Ref: Python API の変更<3>-Footnote-51107003
Ref: Python API の変更<3>-Footnote-61107068
Ref: Python API の変更<3>-Footnote-71107133
Ref: Python API の変更<3>-Footnote-81107198
Ref: Python API の変更<3>-Footnote-91107263
Ref: Python API の変更<3>-Footnote-101107328
Ref: Python API の変更<3>-Footnote-111107394
Ref: Python API の変更<3>-Footnote-121107460
Ref: Python API の変更<3>-Footnote-131107526
Ref: Python API の変更<3>-Footnote-141107592
Ref: Python API の変更<3>-Footnote-151107658
Ref: Python API の変更<3>-Footnote-161107724
Ref: Python API の変更<3>-Footnote-171107790
Ref: Python API の変更<3>-Footnote-181107855
Ref: Python API の変更<3>-Footnote-191107921
Ref: Python API の変更<3>-Footnote-201107987
Ref: Python API の変更<3>-Footnote-211108053
Ref: Python API の変更<3>-Footnote-221108119
Ref: Python API の変更<3>-Footnote-231108185
Ref: Python API の変更<3>-Footnote-241108251
Ref: Python API の変更<3>-Footnote-251108317
Ref: Python API の変更<3>-Footnote-261108383
Ref: Python API の変更<3>-Footnote-271108449
Node: C API の変更<6>1108492
Ref: whatsnew/3 8 changes-in-the-c-api1108649
Ref: a6e1108649
Ref: C API の変更<6>-Footnote-11114461
Ref: C API の変更<6>-Footnote-21114526
Ref: C API の変更<6>-Footnote-31114591
Ref: C API の変更<6>-Footnote-41114656
Ref: C API の変更<6>-Footnote-51114721
Ref: C API の変更<6>-Footnote-61114786
Ref: C API の変更<6>-Footnote-71114851
Ref: C API の変更<6>-Footnote-81114916
Node: CPython バイトコードの変更<4>1114981
Ref: whatsnew/3 8 cpython-bytecode-changes1115133
Ref: a761115133
Ref: CPython バイトコードの変更<4>-Footnote-11116471
Ref: CPython バイトコードの変更<4>-Footnote-21116536
Ref: CPython バイトコードの変更<4>-Footnote-31116601
Ref: CPython バイトコードの変更<4>-Footnote-41116643
Node: Demos and Tools<2>1116708
Ref: whatsnew/3 8 demos-and-tools1116833
Ref: a7b1116833
Ref: Demos and Tools<2>-Footnote-11120128
Ref: Demos and Tools<2>-Footnote-21120193
Ref: Demos and Tools<2>-Footnote-31120321
Node: Python3 8 1 での重要な変更点1120369
Ref: whatsnew/3 8 notable-changes-in-python-3-8-11120543
Ref: a7c1120543
Ref: Python3 8 1 での重要な変更点-Footnote-11121106
Node: Python3 8 2 での重要な変更点1121171
Ref: whatsnew/3 8 notable-changes-in-python-3-8-21121353
Ref: a7d1121353
Ref: Python3 8 2 での重要な変更点-Footnote-11121677
Node: Notable changes in Python 3 8 31121732
Ref: whatsnew/3 8 notable-changes-in-python-3-8-31121914
Ref: a7e1121914
Ref: Notable changes in Python 3 8 3-Footnote-11122301
Node: Python3 8 8 での重要な変更点1122356
Ref: whatsnew/3 8 notable-changes-in-python-3-8-81122533
Ref: a7f1122533
Ref: Python3 8 8 での重要な変更点-Footnote-11123253
Node: Notable changes in Python 3 8 91123318
Ref: whatsnew/3 8 notable-changes-in-python-3-8-91123496
Ref: a801123496
Ref: Notable changes in Python 3 8 9-Footnote-11123967
Node: Notable changes in Python 3 8 101124022
Ref: whatsnew/3 8 notable-changes-in-python-3-8-101124199
Ref: a811124199
Node: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート<2>1124427
Ref: whatsnew/3 8 macos-11-0-big-sur-and-apple-silicon-mac-support1124562
Ref: a821124562
Ref: macOS 11 0 Big Sur と Appleシリコンの Mac のサポート<2>-Footnote-11125552
Node: Notable changes in Python 3 8 10<2>1125607
Ref: whatsnew/3 8 id11125785
Ref: a831125785
Node: urllib parse<4>1125909
Ref: whatsnew/3 8 urllib-parse1125996
Ref: a841125996
Ref: urllib parse<4>-Footnote-11126525
Ref: urllib parse<4>-Footnote-21126584
Node: Notable changes in Python 3 8 121126649
Ref: whatsnew/3 8 notable-changes-in-python-3-8-121126829
Ref: a851126829
Node: Python API の変更<4>1126969
Ref: whatsnew/3 8 id21127061
Ref: a861127061
Ref: Python API の変更<4>-Footnote-11127659
Node: Notable security feature in 3 8 141127724
Ref: whatsnew/3 8 notable-security-feature-in-3-8-141127894
Ref: a871127894
Ref: Notable security feature in 3 8 14-Footnote-11128624
Node: Notable changes in 3 8 171128680
Ref: whatsnew/3 8 notable-changes-in-3-8-171128809
Ref: a881128809
Node: tarfile<5>1128909
Ref: whatsnew/3 8 id31128981
Ref: a891128981
Ref: tarfile<5>-Footnote-11129585
Node: What's New In Python 3 71129627
Ref: whatsnew/3 7 doc1129774
Ref: a8a1129774
Ref: whatsnew/3 7 what-s-new-in-python-3-71129774
Ref: a8b1129774
Node: 概要 -- リリースハイライト<5>1131438
Ref: whatsnew/3 7 summary-release-highlights1131566
Ref: a8c1131566
Ref: 概要 -- リリースハイライト<5>-Footnote-11134209
Ref: 概要 -- リリースハイライト<5>-Footnote-21134289
Ref: 概要 -- リリースハイライト<5>-Footnote-31134325
Ref: 概要 -- リリースハイライト<5>-Footnote-41134361
Node: 新しい機能<8>1134397
Ref: whatsnew/3 7 new-features1134561
Ref: aa01134561
Node: PEP 563 アノテーションの遅延評価1135917
Ref: whatsnew/3 7 pep-563-postponed-evaluation-of-annotations1136072
Ref: aa11136072
Ref: whatsnew/3 7 whatsnew37-pep5631136072
Ref: a8d1136072
Ref: PEP 563 アノテーションの遅延評価-Footnote-11138315
Ref: PEP 563 アノテーションの遅延評価-Footnote-21138357
Ref: PEP 563 アノテーションの遅延評価-Footnote-31138399
Node: PEP 538 レガシーな C ロケールの抑圧1138441
Ref: whatsnew/3 7 pep-538-legacy-c-locale-coercion1138641
Ref: aa21138641
Ref: whatsnew/3 7 whatsnew37-pep5381138641
Ref: a971138641
Ref: PEP 538 レガシーな C ロケールの抑圧-Footnote-11141805
Ref: PEP 538 レガシーな C ロケールの抑圧-Footnote-21141847
Ref: PEP 538 レガシーな C ロケールの抑圧-Footnote-31141889
Ref: PEP 538 レガシーな C ロケールの抑圧-Footnote-41141931
Node: PEP 540 強制 UTF-8 実行モード1141973
Ref: whatsnew/3 7 pep-540-forced-utf-8-runtime-mode1142163
Ref: aa51142163
Ref: whatsnew/3 7 whatsnew37-pep5401142163
Ref: a981142163
Ref: PEP 540 強制 UTF-8 実行モード-Footnote-11143733
Ref: PEP 540 強制 UTF-8 実行モード-Footnote-21143775
Ref: PEP 540 強制 UTF-8 実行モード-Footnote-31143817
Node: PEP 553 組み込みの breakpoint1143859
Ref: whatsnew/3 7 pep-553-built-in-breakpoint1144076
Ref: aa71144076
Ref: whatsnew/3 7 whatsnew37-pep5531144076
Ref: a911144076
Ref: PEP 553 組み込みの breakpoint-Footnote-11144974
Node: PEP 539 スレッドローカルストレージのための新しい C API1145016
Ref: whatsnew/3 7 pep-539-new-c-api-for-thread-local-storage1145265
Ref: aaa1145265
Ref: whatsnew/3 7 whatsnew37-pep5391145265
Ref: a9c1145265
Ref: PEP 539 スレッドローカルストレージのための新しい C API-Footnote-11146794
Ref: PEP 539 スレッドローカルストレージのための新しい C API-Footnote-21146836
Node: PEP 562 モジュール属性へのアクセスのカスタマイズ1146878
Ref: whatsnew/3 7 pep-562-customization-of-access-to-module-attributes1147158
Ref: aae1147158
Ref: whatsnew/3 7 whatsnew37-pep5621147158
Ref: a921147158
Ref: PEP 562 モジュール属性へのアクセスのカスタマイズ-Footnote-11147837
Node: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数1147879
Ref: whatsnew/3 7 pep-564-new-time-functions-with-nanosecond-resolution1148128
Ref: aaf1148128
Ref: whatsnew/3 7 whatsnew37-pep5641148128
Ref: a961148128
Ref: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数-Footnote-11149233
Ref: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数-Footnote-21149275
Ref: PEP 564 ナノ秒単位の分解能を持つ新しい時間関数-Footnote-31149352
Node: PEP 565 Show DeprecationWarning in __main__1149394
Ref: whatsnew/3 7 pep-565-show-deprecationwarning-in-main1149674
Ref: ab61149674
Ref: whatsnew/3 7 whatsnew37-pep5651149674
Ref: a9b1149674
Ref: PEP 565 Show DeprecationWarning in __main__-Footnote-11151598
Node: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート1151640
Ref: whatsnew/3 7 pep-560-core-support-for-typing-module-and-generic-types1151883
Ref: ab71151883
Ref: whatsnew/3 7 whatsnew37-pep5601151883
Ref: a931151883
Ref: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート-Footnote-11153138
Ref: PEP 560 typing モジュールとジェネリック型に対する言語コアによるサポート-Footnote-21153180
Node: PEP 552 Hash-based pyc Files1153222
Ref: whatsnew/3 7 pep-552-hash-based-pyc-files1153463
Ref: ab81153463
Ref: whatsnew/3 7 whatsnew37-pep5521153463
Ref: a991153463
Ref: PEP 552 Hash-based pyc Files-Footnote-11155149
Ref: PEP 552 Hash-based pyc Files-Footnote-21155190
Ref: PEP 552 Hash-based pyc Files-Footnote-31155232
Node: PEP 545 Python Documentation Translations1155274
Ref: whatsnew/3 7 pep-545-python-documentation-translations1155446
Ref: ab91155446
Ref: whatsnew/3 7 whatsnew37-pep5451155446
Ref: a9d1155446
Ref: PEP 545 Python Documentation Translations-Footnote-11156033
Ref: PEP 545 Python Documentation Translations-Footnote-21156075
Node: Python Development Mode -X dev1156117
Ref: whatsnew/3 7 python-development-mode-x-dev1156252
Ref: aba1156252
Ref: whatsnew/3 7 whatsnew37-devmode1156252
Ref: a9a1156252
Node: その他の言語変更<5>1156706
Ref: whatsnew/3 7 other-language-changes1156857
Ref: その他の言語変更<5>-Footnote-11159245
Ref: その他の言語変更<5>-Footnote-21159310
Ref: その他の言語変更<5>-Footnote-31159375
Ref: その他の言語変更<5>-Footnote-41159440
Ref: その他の言語変更<5>-Footnote-51159505
Ref: その他の言語変更<5>-Footnote-61159570
Ref: その他の言語変更<5>-Footnote-71159635
Ref: その他の言語変更<5>-Footnote-81159700
Ref: その他の言語変更<5>-Footnote-91159765
Ref: その他の言語変更<5>-Footnote-101159830
Node: 新たなモジュール<5>1159896
Ref: whatsnew/3 7 new-modules1160062
Ref: ac41160062
Node: contextvars1160235
Ref: whatsnew/3 7 contextvars1160340
Ref: ac51160340
Ref: whatsnew/3 7 whatsnew37-pep5671160340
Ref: a8e1160340
Ref: contextvars-Footnote-11161068
Node: データクラス<3>1161110
Ref: whatsnew/3 7 dataclasses1161246
Ref: ac71161246
Ref: whatsnew/3 7 whatsnew37-pep5571161246
Ref: a8f1161246
Ref: データクラス<3>-Footnote-11162042
Node: importlib resources<2>1162084
Ref: whatsnew/3 7 importlib-resources1162200
Ref: aca1162200
Ref: whatsnew/3 7 whatsnew37-importlib-resources1162200
Ref: a901162200
Ref: importlib resources<2>-Footnote-11162938
Ref: importlib resources<2>-Footnote-21163003
Node: 改良されたモジュール<5>1163065
Ref: whatsnew/3 7 improved-modules1163222
Ref: acc1163222
Node: argparse<3>1164687
Ref: whatsnew/3 7 argparse1164787
Ref: acd1164787
Ref: argparse<3>-Footnote-11165021
Node: asyncio<7>1165086
Ref: whatsnew/3 7 asyncio1165203
Ref: acf1165203
Ref: whatsnew/3 7 whatsnew37-asyncio1165203
Ref: a951165203
Ref: asyncio<7>-Footnote-11171494
Ref: asyncio<7>-Footnote-21171559
Ref: asyncio<7>-Footnote-31171601
Ref: asyncio<7>-Footnote-41171666
Ref: asyncio<7>-Footnote-51171731
Ref: asyncio<7>-Footnote-61171796
Ref: asyncio<7>-Footnote-71171861
Ref: asyncio<7>-Footnote-81171926
Ref: asyncio<7>-Footnote-91171991
Ref: asyncio<7>-Footnote-101172056
Ref: asyncio<7>-Footnote-111172122
Ref: asyncio<7>-Footnote-121172188
Ref: asyncio<7>-Footnote-131172254
Ref: asyncio<7>-Footnote-141172320
Ref: asyncio<7>-Footnote-151172386
Ref: asyncio<7>-Footnote-161172452
Ref: asyncio<7>-Footnote-171172518
Ref: asyncio<7>-Footnote-181172584
Ref: asyncio<7>-Footnote-191172650
Ref: asyncio<7>-Footnote-201172716
Ref: asyncio<7>-Footnote-211172782
Ref: asyncio<7>-Footnote-221172848
Ref: asyncio<7>-Footnote-231172914
Ref: asyncio<7>-Footnote-241172980
Node: binascii1173046
Ref: whatsnew/3 7 binascii1173163
Ref: aee1173163
Ref: binascii-Footnote-11173440
Node: calendar<2>1173505
Ref: whatsnew/3 7 calendar1173626
Ref: af01173626
Ref: calendar<2>-Footnote-11173923
Node: collections<2>1173988
Ref: whatsnew/3 7 collections1174114
Ref: af21174114
Ref: collections<2>-Footnote-11174346
Node: compileall<3>1174411
Ref: whatsnew/3 7 compileall1174547
Ref: af31174547
Ref: compileall<3>-Footnote-11174944
Node: concurrent futures<3>1175009
Ref: whatsnew/3 7 concurrent-futures1175144
Ref: af51175144
Ref: concurrent futures<3>-Footnote-11175672
Ref: concurrent futures<3>-Footnote-21175737
Node: contextlib<3>1175802
Ref: whatsnew/3 7 contextlib1175935
Ref: af61175935
Ref: contextlib<3>-Footnote-11176465
Ref: contextlib<3>-Footnote-21176530
Ref: contextlib<3>-Footnote-31176595
Ref: contextlib<3>-Footnote-41176660
Node: cProfile<2>1176725
Ref: whatsnew/3 7 cprofile1176842
Ref: afb1176842
Ref: cProfile<2>-Footnote-11177068
Node: crypt1177133
Ref: whatsnew/3 7 crypt1177248
Ref: afc1177248
Ref: crypt-Footnote-11177569
Ref: crypt-Footnote-21177634
Node: datetime<4>1177699
Ref: whatsnew/3 7 datetime1177809
Ref: afd1177809
Ref: datetime<4>-Footnote-11178220
Ref: datetime<4>-Footnote-21178285
Node: dbm<2>1178349
Ref: whatsnew/3 7 dbm1178461
Ref: aff1178461
Node: decimal1178606
Ref: whatsnew/3 7 decimal1178713
Ref: b001178713
Ref: decimal-Footnote-11178934
Node: dis<3>1178999
Ref: whatsnew/3 7 dis1179112
Ref: b011179112
Ref: dis<3>-Footnote-11179515
Node: distutils<4>1179580
Ref: whatsnew/3 7 distutils1179693
Ref: b031179693
Ref: distutils<4>-Footnote-11179941
Node: enum<4>1180006
Ref: whatsnew/3 7 enum1180125
Ref: b041180125
Ref: enum<4>-Footnote-11180793
Ref: enum<4>-Footnote-21180858
Node: functools<3>1180923
Ref: whatsnew/3 7 functools1181035
Ref: b061181035
Ref: functools<3>-Footnote-11181264
Node: gc<4>1181329
Ref: whatsnew/3 7 gc1181441
Ref: b071181441
Ref: gc<4>-Footnote-11181980
Node: hmac<2>1182045
Ref: whatsnew/3 7 hmac1182156
Ref: b0b1182156
Ref: hmac<2>-Footnote-11182414
Node: http client1182479
Ref: whatsnew/3 7 http-client1182596
Ref: b0d1182596
Ref: http client-Footnote-11182853
Node: http server1182918
Ref: whatsnew/3 7 http-server1183044
Ref: b101183044
Ref: http server-Footnote-11183922
Ref: http server-Footnote-21183987
Ref: http server-Footnote-31184052
Node: idlelib と IDLE1184117
Ref: whatsnew/3 7 idlelib-and-idle1184244
Ref: b131184244
Ref: idlelib と IDLE-Footnote-11187295
Ref: idlelib と IDLE-Footnote-21187360
Ref: idlelib と IDLE-Footnote-31187427
Ref: idlelib と IDLE-Footnote-41187492
Ref: idlelib と IDLE-Footnote-51187557
Ref: idlelib と IDLE-Footnote-61187622
Ref: idlelib と IDLE-Footnote-71187687
Ref: idlelib と IDLE-Footnote-81187752
Ref: idlelib と IDLE-Footnote-91187817
Ref: idlelib と IDLE-Footnote-101187882
Ref: idlelib と IDLE-Footnote-111187950
Ref: idlelib と IDLE-Footnote-121188015
Ref: idlelib と IDLE-Footnote-131188081
Node: importlib<4>1188147
Ref: whatsnew/3 7 importlib1188268
Ref: b141188268
Ref: importlib<4>-Footnote-11189139
Ref: importlib<4>-Footnote-21189204
Ref: importlib<4>-Footnote-31189269
Node: io<4>1189334
Ref: whatsnew/3 7 io1189451
Ref: b161189451
Ref: io<4>-Footnote-11189716
Ref: io<4>-Footnote-21189781
Node: ipaddress<3>1189846
Ref: whatsnew/3 7 ipaddress1189963
Ref: b181189963
Ref: ipaddress<3>-Footnote-11190283
Node: itertools<5>1190348
Ref: whatsnew/3 7 itertools1190469
Ref: b191190469
Ref: itertools<5>-Footnote-11190706
Node: locale<4>1190771
Ref: whatsnew/3 7 locale1190890
Ref: b1b1190890
Ref: locale<4>-Footnote-11191304
Node: logging<3>1191369
Ref: whatsnew/3 7 logging1191483
Ref: b1c1191483
Ref: logging<3>-Footnote-11192045
Ref: logging<3>-Footnote-21192110
Ref: logging<3>-Footnote-31192175
Node: math<6>1192240
Ref: whatsnew/3 7 math1192357
Ref: b201192357
Ref: math<6>-Footnote-11192582
Node: mimetypes<2>1192647
Ref: whatsnew/3 7 mimetypes1192760
Ref: b221192760
Ref: mimetypes<2>-Footnote-11192975
Node: msilib1193040
Ref: whatsnew/3 7 msilib1193164
Ref: b231193164
Ref: msilib-Footnote-11193359
Node: multiprocessing<4>1193424
Ref: whatsnew/3 7 multiprocessing1193541
Ref: b241193541
Ref: multiprocessing<4>-Footnote-11194188
Ref: multiprocessing<4>-Footnote-21194253
Ref: multiprocessing<4>-Footnote-31194318
Node: os<7>1194383
Ref: whatsnew/3 7 os1194504
Ref: b281194504
Ref: os<7>-Footnote-11195802
Ref: os<7>-Footnote-21195867
Ref: os<7>-Footnote-31195932
Ref: os<7>-Footnote-41195997
Ref: os<7>-Footnote-51196062
Ref: os<7>-Footnote-61196127
Ref: os<7>-Footnote-71196192
Node: pathlib<8>1196257
Ref: whatsnew/3 7 pathlib1196366
Ref: b331196366
Ref: pathlib<8>-Footnote-11196626
Node: pdb<4>1196691
Ref: whatsnew/3 7 pdb1196808
Ref: b341196808
Ref: pdb<4>-Footnote-11197218
Ref: pdb<4>-Footnote-21197283
Node: py_compile<3>1197348
Ref: whatsnew/3 7 py-compile1197463
Ref: b351197463
Ref: py_compile<3>-Footnote-11197913
Ref: py_compile<3>-Footnote-21197954
Node: pydoc<2>1198019
Ref: whatsnew/3 7 pydoc1198136
Ref: b361198136
Ref: pydoc<2>-Footnote-11198360
Node: queue<2>1198425
Ref: whatsnew/3 7 queue1198534
Ref: b371198534
Ref: queue<2>-Footnote-11198717
Node: re<4>1198782
Ref: whatsnew/3 7 re1198892
Ref: b391198892
Ref: re<4>-Footnote-11199974
Ref: re<4>-Footnote-21200039
Ref: re<4>-Footnote-31200104
Ref: re<4>-Footnote-41200169
Ref: re<4>-Footnote-51200234
Node: signal<2>1200299
Ref: whatsnew/3 7 signal1200410
Ref: b3d1200410
Ref: signal<2>-Footnote-11200729
Node: socket<5>1200794
Ref: whatsnew/3 7 socket1200912
Ref: b3f1200912
Ref: socket<5>-Footnote-11202000
Ref: socket<5>-Footnote-21202065
Ref: socket<5>-Footnote-31202130
Ref: socket<5>-Footnote-41202195
Ref: socket<5>-Footnote-51202260
Ref: socket<5>-Footnote-61202325
Node: socketserver1202390
Ref: whatsnew/3 7 socketserver1202509
Ref: b441202509
Node: sqlite3<6>1202985
Ref: whatsnew/3 7 sqlite31203101
Ref: b471203101
Ref: sqlite3<6>-Footnote-11203543
Ref: sqlite3<6>-Footnote-21203608
Node: ssl<5>1203673
Ref: whatsnew/3 7 ssl1203786
Ref: b491203786
Ref: ssl<5>-Footnote-11207081
Ref: ssl<5>-Footnote-21207146
Ref: ssl<5>-Footnote-31207211
Ref: ssl<5>-Footnote-41207276
Ref: ssl<5>-Footnote-51207341
Ref: ssl<5>-Footnote-61207406
Ref: ssl<5>-Footnote-71207471
Ref: ssl<5>-Footnote-81207536
Ref: ssl<5>-Footnote-91207601
Ref: ssl<5>-Footnote-101207666
Ref: ssl<5>-Footnote-111207732
Ref: ssl<5>-Footnote-121207798
Ref: ssl<5>-Footnote-131207864
Ref: ssl<5>-Footnote-141207930
Node: string<2>1207986
Ref: whatsnew/3 7 string1208102
Ref: b521208102
Ref: string<2>-Footnote-11208379
Node: subprocess<2>1208446
Ref: whatsnew/3 7 subprocess1208562
Ref: b531208562
Ref: subprocess<2>-Footnote-11209882
Ref: subprocess<2>-Footnote-21209947
Ref: subprocess<2>-Footnote-31210012
Ref: subprocess<2>-Footnote-41210077
Node: sys<8>1210142
Ref: whatsnew/3 7 sys1210256
Ref: b571210256
Ref: sys<8>-Footnote-11210996
Ref: sys<8>-Footnote-21211061
Ref: sys<8>-Footnote-31211126
Node: time<5>1211191
Ref: whatsnew/3 7 time1211302
Ref: b5b1211302
Ref: time<5>-Footnote-11212511
Ref: time<5>-Footnote-21212553
Node: tkinter<5>1212618
Ref: whatsnew/3 7 tkinter1212737
Ref: b611212737
Ref: tkinter<5>-Footnote-11212918
Node: tracemalloc<2>1212983
Ref: whatsnew/3 7 tracemalloc1213103
Ref: b631213103
Ref: tracemalloc<2>-Footnote-11213569
Node: types<4>1213634
Ref: whatsnew/3 7 types1213758
Ref: b661213758
Ref: types<4>-Footnote-11214273
Ref: types<4>-Footnote-21214338
Ref: types<4>-Footnote-31214403
Ref: types<4>-Footnote-41214445
Node: unicodedata<6>1214510
Ref: whatsnew/3 7 unicodedata1214631
Ref: b6b1214631
Ref: unicodedata<6>-Footnote-11214833
Node: unittest<7>1214889
Ref: whatsnew/3 7 unittest1215015
Ref: b6c1215015
Ref: unittest<7>-Footnote-11215420
Node: unittest mock1215485
Ref: whatsnew/3 7 unittest-mock1215612
Ref: b6d1215612
Ref: unittest mock-Footnote-11216130
Ref: unittest mock-Footnote-21216195
Node: urllib parse<5>1216260
Ref: whatsnew/3 7 urllib-parse1216378
Ref: b701216378
Ref: urllib parse<5>-Footnote-11216691
Ref: urllib parse<5>-Footnote-21216750
Ref: urllib parse<5>-Footnote-31216809
Node: uu1216874
Ref: whatsnew/3 7 uu1216986
Ref: b721216986
Ref: uu-Footnote-11217250
Node: uuid<2>1217315
Ref: whatsnew/3 7 uuid1217423
Ref: b731217423
Ref: uuid<2>-Footnote-11218063
Ref: uuid<2>-Footnote-21218128
Node: warnings<3>1218193
Ref: whatsnew/3 7 warnings1218305
Ref: b771218305
Ref: warnings<3>-Footnote-11219730
Ref: warnings<3>-Footnote-21219795
Ref: warnings<3>-Footnote-31219860
Ref: warnings<3>-Footnote-41219925
Node: xml<5>1219990
Ref: whatsnew/3 7 xml1220104
Ref: b791220104
Ref: xml<5>-Footnote-11220388
Node: xml etree1220443
Ref: whatsnew/3 7 xml-etree1220559
Ref: b7a1220559
Ref: xml etree-Footnote-11220900
Node: xmlrpc server1220965
Ref: whatsnew/3 7 xmlrpc-server1221081
Ref: b7c1221081
Ref: xmlrpc server-Footnote-11221290
Node: zipapp1221354
Ref: whatsnew/3 7 zipapp1221471
Ref: b7d1221471
Ref: zipapp-Footnote-11221995
Ref: zipapp-Footnote-21222060
Node: zipfile<2>1222125
Ref: whatsnew/3 7 zipfile1222220
Ref: b7f1222220
Ref: zipfile<2>-Footnote-11222585
Ref: zipfile<2>-Footnote-21222650
Node: C API の変更<7>1222715
Ref: whatsnew/3 7 c-api-changes1222861
Ref: b801222861
Ref: C API の変更<7>-Footnote-11227418
Ref: C API の変更<7>-Footnote-21227483
Ref: C API の変更<7>-Footnote-31227548
Ref: C API の変更<7>-Footnote-41227613
Ref: C API の変更<7>-Footnote-51227678
Ref: C API の変更<7>-Footnote-61227743
Ref: C API の変更<7>-Footnote-71227808
Ref: C API の変更<7>-Footnote-81227873
Ref: C API の変更<7>-Footnote-91227938
Ref: C API の変更<7>-Footnote-101228003
Ref: C API の変更<7>-Footnote-111228069
Ref: C API の変更<7>-Footnote-121228135
Ref: C API の変更<7>-Footnote-131228201
Ref: C API の変更<7>-Footnote-141228267
Ref: C API の変更<7>-Footnote-151228333
Ref: C API の変更<7>-Footnote-161228398
Ref: C API の変更<7>-Footnote-171228464
Ref: C API の変更<7>-Footnote-181228530
Ref: C API の変更<7>-Footnote-191228596
Ref: C API の変更<7>-Footnote-201228662
Node: Build Changes<6>1228728
Ref: whatsnew/3 7 build-changes1228853
Ref: b991228853
Ref: Build Changes<6>-Footnote-11229986
Ref: Build Changes<6>-Footnote-21230051
Ref: Build Changes<6>-Footnote-31230116
Node: 最適化<5>1230181
Ref: whatsnew/3 7 optimizations1230330
Ref: b9a1230330
Ref: whatsnew/3 7 whatsnew37-perf1230330
Ref: a9e1230330
Ref: whatsnew/3 7 whatsnew37-asyncio-perf1231013
Ref: ad01231013
Ref: 最適化<5>-Footnote-11235558
Ref: 最適化<5>-Footnote-21235623
Ref: 最適化<5>-Footnote-31235688
Ref: 最適化<5>-Footnote-41235753
Ref: 最適化<5>-Footnote-51235818
Ref: 最適化<5>-Footnote-61235883
Ref: 最適化<5>-Footnote-71235948
Ref: 最適化<5>-Footnote-81236013
Ref: 最適化<5>-Footnote-91236078
Ref: 最適化<5>-Footnote-101236143
Ref: 最適化<5>-Footnote-111236209
Ref: 最適化<5>-Footnote-121236275
Ref: 最適化<5>-Footnote-131236341
Ref: 最適化<5>-Footnote-141236407
Ref: 最適化<5>-Footnote-151236473
Ref: 最適化<5>-Footnote-161236539
Ref: 最適化<5>-Footnote-171236605
Ref: 最適化<5>-Footnote-181236671
Ref: 最適化<5>-Footnote-191236737
Ref: 最適化<5>-Footnote-201236803
Ref: 最適化<5>-Footnote-211236869
Ref: 最適化<5>-Footnote-221236935
Ref: 最適化<5>-Footnote-231237001
Ref: 最適化<5>-Footnote-241237067
Ref: 最適化<5>-Footnote-251237133
Ref: 最適化<5>-Footnote-261237199
Ref: 最適化<5>-Footnote-271237265
Ref: 最適化<5>-Footnote-281237331
Ref: 最適化<5>-Footnote-291237397
Ref: 最適化<5>-Footnote-301237463
Node: その他の CPython の実装の変更<2>1237529
Ref: whatsnew/3 7 other-cpython-implementation-changes1237691
Ref: ba81237691
Ref: その他の CPython の実装の変更<2>-Footnote-11239092
Ref: その他の CPython の実装の変更<2>-Footnote-21239157
Ref: その他の CPython の実装の変更<2>-Footnote-31239222
Ref: その他の CPython の実装の変更<2>-Footnote-41239287
Ref: その他の CPython の実装の変更<2>-Footnote-51239352
Node: 非推奨の Python の挙動1239417
Ref: whatsnew/3 7 deprecated-python-behavior1239626
Ref: bab1239626
Ref: 非推奨の Python の挙動-Footnote-11240732
Ref: 非推奨の Python の挙動-Footnote-21240797
Node: 非推奨の Python モジュール、関数、メソッド1240862
Ref: whatsnew/3 7 deprecated-python-modules-functions-and-methods1241071
Ref: bad1241071
Node: aifc1241474
Ref: whatsnew/3 7 aifc1241593
Ref: bae1241593
Ref: aifc-Footnote-11241813
Node: asyncio<8>1241878
Ref: whatsnew/3 7 id21242020
Ref: baf1242020
Ref: whatsnew/3 7 whatsnew37-asyncio-deprecated1242020
Ref: aed1242020
Ref: asyncio<8>-Footnote-11242545
Ref: asyncio<8>-Footnote-21242610
Node: collections<3>1242675
Ref: whatsnew/3 7 id31242819
Ref: bb01242819
Ref: collections<3>-Footnote-11243198
Node: dbm<3>1243263
Ref: whatsnew/3 7 id41243404
Ref: bb11243404
Ref: dbm<3>-Footnote-11243805
Node: enum<5>1243870
Ref: whatsnew/3 7 id51244007
Ref: bb21244007
Ref: enum<5>-Footnote-11244457
Node: gettext<2>1244522
Ref: whatsnew/3 7 gettext1244665
Ref: bb31244665
Ref: gettext<2>-Footnote-11244910
Node: importlib<5>1244975
Ref: whatsnew/3 7 id61245120
Ref: bb41245120
Ref: importlib<5>-Footnote-11245635
Node: locale<5>1245700
Ref: whatsnew/3 7 id71245842
Ref: bb61245842
Ref: locale<5>-Footnote-11246045
Node: macpath1246110
Ref: whatsnew/3 7 macpath1246252
Ref: bb71246252
Ref: macpath-Footnote-11246442
Node: threading<5>1246506
Ref: whatsnew/3 7 threading1246648
Ref: bb81246648
Ref: threading<5>-Footnote-11246946
Node: socket<6>1247011
Ref: whatsnew/3 7 id81247152
Ref: bb91247152
Ref: socket<6>-Footnote-11247497
Node: ssl<6>1247562
Ref: whatsnew/3 7 id91247696
Ref: bba1247696
Ref: ssl<6>-Footnote-11247908
Node: sunau1247973
Ref: whatsnew/3 7 sunau1248104
Ref: bbb1248104
Ref: sunau-Footnote-11248330
Node: sys<9>1248395
Ref: whatsnew/3 7 id101248524
Ref: bbc1248524
Ref: sys<9>-Footnote-11248841
Node: wave1248906
Ref: whatsnew/3 7 wave1249021
Ref: bbd1249021
Ref: wave-Footnote-11249249
Node: C API の非推奨の関数ならびに型1249314
Ref: whatsnew/3 7 deprecated-functions-and-types-of-the-c-api1249551
Ref: bbe1249551
Ref: C API の非推奨の関数ならびに型-Footnote-11250195
Ref: C API の非推奨の関数ならびに型-Footnote-21250260
Node: サポート対象プラットフォームからの除外1250325
Ref: whatsnew/3 7 id111250528
Ref: bbf1250528
Ref: whatsnew/3 7 platform-support-removals1250528
Ref: b4c1250528
Ref: サポート対象プラットフォームからの除外-Footnote-11252016
Ref: サポート対象プラットフォームからの除外-Footnote-21252083
Node: API と機能の削除<2>1252163
Ref: whatsnew/3 7 api-and-feature-removals1252339
Ref: bc01252339
Ref: API と機能の削除<2>-Footnote-11255236
Ref: API と機能の削除<2>-Footnote-21255301
Ref: API と機能の削除<2>-Footnote-31255366
Node: Module Removals1255431
Ref: whatsnew/3 7 module-removals1255570
Ref: bc41255570
Ref: Module Removals-Footnote-11255905
Node: Windows-only Changes1255970
Ref: whatsnew/3 7 windows-only-changes1256107
Ref: bc51256107
Ref: Windows-only Changes-Footnote-11256984
Ref: Windows-only Changes-Footnote-21257049
Node: Python 3 7 への移植1257114
Ref: whatsnew/3 7 porting-to-python-3-71257273
Ref: bc61257273
Ref: whatsnew/3 7 porting-to-python-371257273
Ref: a9f1257273
Node: Python の挙動の変更<2>1257852
Ref: whatsnew/3 7 changes-in-python-behavior1257972
Ref: bc71257972
Ref: Python の挙動の変更<2>-Footnote-11259849
Ref: Python の挙動の変更<2>-Footnote-21259914
Ref: Python の挙動の変更<2>-Footnote-31259956
Ref: Python の挙動の変更<2>-Footnote-41260021
Ref: Python の挙動の変更<2>-Footnote-51260086
Ref: Python の挙動の変更<2>-Footnote-61260151
Node: Python API の変更<5>1260216
Ref: whatsnew/3 7 changes-in-the-python-api1260363
Ref: bca1260363
Ref: Python API の変更<5>-Footnote-11269878
Ref: Python API の変更<5>-Footnote-21269943
Ref: Python API の変更<5>-Footnote-31270008
Ref: Python API の変更<5>-Footnote-41270073
Ref: Python API の変更<5>-Footnote-51270138
Ref: Python API の変更<5>-Footnote-61270203
Ref: Python API の変更<5>-Footnote-71270268
Ref: Python API の変更<5>-Footnote-81270333
Ref: Python API の変更<5>-Footnote-91270398
Ref: Python API の変更<5>-Footnote-101270463
Ref: Python API の変更<5>-Footnote-111270529
Ref: Python API の変更<5>-Footnote-121270595
Ref: Python API の変更<5>-Footnote-131270661
Ref: Python API の変更<5>-Footnote-141270727
Ref: Python API の変更<5>-Footnote-151270770
Ref: Python API の変更<5>-Footnote-161270836
Ref: Python API の変更<5>-Footnote-171270902
Ref: Python API の変更<5>-Footnote-181270968
Ref: Python API の変更<5>-Footnote-191271034
Ref: Python API の変更<5>-Footnote-201271100
Ref: Python API の変更<5>-Footnote-211271166
Ref: Python API の変更<5>-Footnote-221271232
Ref: Python API の変更<5>-Footnote-231271298
Ref: Python API の変更<5>-Footnote-241271364
Ref: Python API の変更<5>-Footnote-251271430
Ref: Python API の変更<5>-Footnote-261271496
Ref: Python API の変更<5>-Footnote-271271562
Ref: Python API の変更<5>-Footnote-281271628
Ref: Python API の変更<5>-Footnote-291271694
Ref: Python API の変更<5>-Footnote-301271760
Node: C API の変更<8>1271826
Ref: whatsnew/3 7 changes-in-the-c-api1271983
Ref: beb1271983
Ref: C API の変更<8>-Footnote-11272606
Node: CPython バイトコードの変更<5>1272671
Ref: whatsnew/3 7 cpython-bytecode-changes1272828
Ref: bec1272828
Ref: CPython バイトコードの変更<5>-Footnote-11273187
Ref: CPython バイトコードの変更<5>-Footnote-21273252
Node: Windows-only Changes<2>1273317
Ref: whatsnew/3 7 id121273498
Ref: bee1273498
Ref: Windows-only Changes<2>-Footnote-11273828
Node: その他の CPython の実装の変更<3>1273893
Ref: whatsnew/3 7 id131274027
Ref: bf01274027
Ref: その他の CPython の実装の変更<3>-Footnote-11276347
Ref: その他の CPython の実装の変更<3>-Footnote-21276389
Ref: その他の CPython の実装の変更<3>-Footnote-31276454
Node: Python 3 7 1 での重要な変更点1276519
Ref: whatsnew/3 7 notable-changes-in-python-3-7-11276695
Ref: bf21276695
Ref: Python 3 7 1 での重要な変更点-Footnote-11277634
Ref: Python 3 7 1 での重要な変更点-Footnote-21277699
Ref: Python 3 7 1 での重要な変更点-Footnote-31277764
Node: Python 3 7 2 での重要な変更点1277829
Ref: whatsnew/3 7 notable-changes-in-python-3-7-21278019
Ref: bf51278019
Node: Python 3 7 6 での重要な変更点1278517
Ref: whatsnew/3 7 notable-changes-in-python-3-7-61278708
Ref: bf61278708
Ref: Python 3 7 6 での重要な変更点-Footnote-11279273
Node: Python 3 7 10 での重要な変更点1279338
Ref: whatsnew/3 7 notable-changes-in-python-3-7-101279524
Ref: bf71279524
Ref: Python 3 7 10 での重要な変更点-Footnote-11280248
Node: Notable changes in Python 3 7 111280313
Ref: whatsnew/3 7 notable-changes-in-python-3-7-111280496
Ref: bf81280496
Ref: Notable changes in Python 3 7 11-Footnote-11281412
Ref: Notable changes in Python 3 7 11-Footnote-21281467
Node: Notable security feature in 3 7 141281522
Ref: whatsnew/3 7 notable-security-feature-in-3-7-141281658
Ref: bf91281658
Ref: Notable security feature in 3 7 14-Footnote-11282388
Node: What's New In Python 3 61282444
Ref: whatsnew/3 6 doc1282591
Ref: bfa1282591
Ref: whatsnew/3 6 what-s-new-in-python-3-61282591
Ref: bfb1282591
Ref: What's New In Python 3 6-Footnote-11284088
Ref: What's New In Python 3 6-Footnote-21284148
Node: 概要 -- リリースハイライト<6>1284190
Ref: whatsnew/3 6 summary-release-highlights1284318
Ref: bfc1284318
Ref: 概要 -- リリースハイライト<6>-Footnote-11289154
Ref: 概要 -- リリースハイライト<6>-Footnote-21289234
Ref: 概要 -- リリースハイライト<6>-Footnote-31289324
Node: 新しい機能<9>1289366
Ref: whatsnew/3 6 new-features1289530
Ref: c101289530
Ref: whatsnew/3 6 pypy-dict-implementation1289530
Ref: c111289530
Node: PEP 498 フォーマット済み文字列リテラル1291201
Ref: whatsnew/3 6 pep-498-formatted-string-literals1291362
Ref: c121291362
Ref: whatsnew/3 6 whatsnew36-pep4981291362
Ref: bfd1291362
Ref: PEP 498 フォーマット済み文字列リテラル-Footnote-11292482
Ref: PEP 498 フォーマット済み文字列リテラル-Footnote-21292524
Node: PEP 526 変数アノテーションの文法1292566
Ref: whatsnew/3 6 pep-526-syntax-for-variable-annotations1292789
Ref: c131292789
Ref: whatsnew/3 6 whatsnew36-pep5261292789
Ref: bff1292789
Ref: PEP 526 変数アノテーションの文法-Footnote-11294181
Ref: PEP 526 変数アノテーションの文法-Footnote-21294223
Ref: PEP 526 変数アノテーションの文法-Footnote-31294265
Ref: PEP 526 変数アノテーションの文法-Footnote-41294300
Node: PEP 515 数値リテラル内のアンダースコア1294341
Ref: whatsnew/3 6 pep-515-underscores-in-numeric-literals1294546
Ref: c141294546
Ref: whatsnew/3 6 whatsnew36-pep5151294546
Ref: bfe1294546
Ref: PEP 515 数値リテラル内のアンダースコア-Footnote-11295730
Ref: PEP 515 数値リテラル内のアンダースコア-Footnote-21295772
Node: PEP 525 非同期ジェネレータ1295814
Ref: whatsnew/3 6 pep-525-asynchronous-generators1296004
Ref: c151296004
Ref: whatsnew/3 6 whatsnew36-pep5251296004
Ref: c001296004
Ref: PEP 525 非同期ジェネレータ-Footnote-11296924
Ref: PEP 525 非同期ジェネレータ-Footnote-21296966
Node: PEP 530 非同期内包表記1297008
Ref: whatsnew/3 6 pep-530-asynchronous-comprehensions1297192
Ref: c161297192
Ref: whatsnew/3 6 whatsnew36-pep5301297192
Ref: c011297192
Ref: PEP 530 非同期内包表記-Footnote-11297769
Ref: PEP 530 非同期内包表記-Footnote-21297811
Node: PEP 487 Simpler customization of class creation1297853
Ref: whatsnew/3 6 pep-487-simpler-customization-of-class-creation1298043
Ref: c171298043
Ref: whatsnew/3 6 whatsnew36-pep4871298043
Ref: c041298043
Ref: PEP 487 Simpler customization of class creation-Footnote-11299124
Node: PEP 487 記述子プロトコルの改善1299166
Ref: whatsnew/3 6 pep-487-descriptor-protocol-enhancements1299389
Ref: c1a1299389
Ref: whatsnew/3 6 whatsnew36-pep487-descriptors1299389
Ref: c1b1299389
Ref: PEP 487 記述子プロトコルの改善-Footnote-11300609
Ref: PEP 487 記述子プロトコルの改善-Footnote-21300651
Node: PEP 519 ファイルシステムパスプロトコルの追加1300693
Ref: whatsnew/3 6 pep-519-adding-a-file-system-path-protocol1300907
Ref: c1e1300907
Ref: whatsnew/3 6 whatsnew36-pep5191300907
Ref: c091300907
Ref: PEP 519 ファイルシステムパスプロトコルの追加-Footnote-11303766
Node: PEP 495 地域時間の曖昧さ回避1303808
Ref: whatsnew/3 6 pep-495-local-time-disambiguation1304067
Ref: c241304067
Ref: whatsnew/3 6 whatsnew36-pep4951304067
Ref: c0a1304067
Ref: PEP 495 地域時間の曖昧さ回避-Footnote-11305585
Ref: PEP 495 地域時間の曖昧さ回避-Footnote-21305627
Node: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更1305669
Ref: whatsnew/3 6 pep-529-change-windows-filesystem-encoding-to-utf-81305943
Ref: c261305943
Ref: whatsnew/3 6 whatsnew36-pep5291305943
Ref: c0e1305943
Ref: PEP 529 Windows ファイルシステムのエンコーディングを UTF-8 に変更-Footnote-11307022
Node: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更1307064
Ref: whatsnew/3 6 pep-528-change-windows-console-encoding-to-utf-81307350
Ref: c281307350
Ref: whatsnew/3 6 whatsnew36-pep5281307350
Ref: c0d1307350
Ref: PEP 528 Windows コンソールのエンコーディングを UTF-8 に変更-Footnote-11308114
Node: PEP 520 クラス属性の定義の順番を保持1308156
Ref: whatsnew/3 6 pep-520-preserving-class-attribute-definition-order1308403
Ref: c2a1308403
Ref: whatsnew/3 6 whatsnew36-pep5201308403
Ref: c051308403
Ref: PEP 520 クラス属性の定義の順番を保持-Footnote-11309016
Node: PEP 468 キーワード引数の順番の保持1309058
Ref: whatsnew/3 6 pep-468-preserving-keyword-argument-order1309249
Ref: c2d1309249
Ref: whatsnew/3 6 whatsnew36-pep4681309249
Ref: c061309249
Ref: PEP 468 キーワード引数の順番の保持-Footnote-11309661
Node: 新たな dict 実装1309703
Ref: whatsnew/3 6 new-dict-implementation1309895
Ref: c2e1309895
Ref: whatsnew/3 6 whatsnew36-compactdict1309895
Ref: c031309895
Ref: 新たな dict 実装-Footnote-11310860
Ref: 新たな dict 実装-Footnote-21310940
Ref: 新たな dict 実装-Footnote-31311030
Ref: 新たな dict 実装-Footnote-41311095
Node: PEP 523 CPython にフレーム評価 API を追加1311175
Ref: whatsnew/3 6 pep-523-adding-a-frame-evaluation-api-to-cpython1311345
Ref: c2f1311345
Ref: whatsnew/3 6 whatsnew36-pep5231311345
Ref: c301311345
Ref: PEP 523 CPython にフレーム評価 API を追加-Footnote-11312502
Ref: PEP 523 CPython にフレーム評価 API を追加-Footnote-21312544
Node: PYTHONMALLOC 環境変数1312586
Ref: whatsnew/3 6 pythonmalloc-environment-variable1312771
Ref: c311312771
Ref: whatsnew/3 6 whatsnew36-pythonmalloc1312771
Ref: c081312771
Ref: PYTHONMALLOC 環境変数-Footnote-11316172
Ref: PYTHONMALLOC 環境変数-Footnote-21316237
Node: DTrace and SystemTap probing support1316302
Ref: whatsnew/3 6 dtrace-and-systemtap-probing-support1316427
Ref: c391316427
Ref: whatsnew/3 6 whatsnew36-tracing1316427
Ref: c071316427
Ref: DTrace and SystemTap probing support-Footnote-11317339
Node: その他の言語変更<6>1317404
Ref: whatsnew/3 6 other-language-changes1317555
Ref: c3b1317555
Ref: その他の言語変更<6>-Footnote-11318943
Ref: その他の言語変更<6>-Footnote-21319008
Ref: その他の言語変更<6>-Footnote-31319073
Ref: その他の言語変更<6>-Footnote-41319138
Node: 新たなモジュール<6>1319203
Ref: whatsnew/3 6 new-modules1319369
Ref: c3e1319369
Node: secrets1319446
Ref: whatsnew/3 6 secrets1319517
Ref: c3f1319517
Ref: whatsnew/3 6 whatsnew36-pep5061319517
Ref: c021319517
Ref: secrets-Footnote-11320189
Node: 改良されたモジュール<6>1320231
Ref: whatsnew/3 6 improved-modules1320382
Ref: c401320382
Node: array<4>1321914
Ref: whatsnew/3 6 array1322007
Ref: c411322007
Ref: array<4>-Footnote-11322300
Node: ast<4>1322365
Ref: whatsnew/3 6 ast1322477
Ref: c421322477
Ref: ast<4>-Footnote-11322726
Node: asyncio<9>1322791
Ref: whatsnew/3 6 asyncio1322906
Ref: c431322906
Ref: asyncio<9>-Footnote-11326363
Ref: asyncio<9>-Footnote-21326428
Ref: asyncio<9>-Footnote-31326473
Ref: asyncio<9>-Footnote-41326538
Ref: asyncio<9>-Footnote-51326603
Ref: asyncio<9>-Footnote-61326668
Ref: asyncio<9>-Footnote-71326733
Ref: asyncio<9>-Footnote-81326798
Ref: asyncio<9>-Footnote-91326863
Ref: asyncio<9>-Footnote-101326928
Ref: asyncio<9>-Footnote-111326994
Ref: asyncio<9>-Footnote-121327060
Node: binascii<2>1327126
Ref: whatsnew/3 6 binascii1327240
Ref: c4c1327240
Ref: binascii<2>-Footnote-11327525
Node: cmath1327590
Ref: whatsnew/3 6 cmath1327708
Ref: c4e1327708
Ref: cmath-Footnote-11328222
Ref: cmath-Footnote-21328287
Ref: cmath-Footnote-31328329
Node: collections<4>1328394
Ref: whatsnew/3 6 collections1328522
Ref: c551328522
Ref: collections<4>-Footnote-11329623
Ref: collections<4>-Footnote-21329688
Ref: collections<4>-Footnote-31329753
Ref: collections<4>-Footnote-41329818
Ref: collections<4>-Footnote-51329883
Ref: collections<4>-Footnote-61329948
Node: concurrent futures<4>1330013
Ref: whatsnew/3 6 concurrent-futures1330149
Ref: c591330149
Ref: concurrent futures<4>-Footnote-11330480
Node: contextlib<4>1330545
Ref: whatsnew/3 6 contextlib1330678
Ref: c5a1330678
Ref: contextlib<4>-Footnote-11331173
Node: datetime<5>1331238
Ref: whatsnew/3 6 datetime1331360
Ref: c5d1331360
Ref: datetime<5>-Footnote-11332377
Ref: datetime<5>-Footnote-21332442
Ref: datetime<5>-Footnote-31332507
Ref: datetime<5>-Footnote-41332572
Node: decimal<2>1332637
Ref: whatsnew/3 6 decimal1332758
Ref: c611332758
Ref: decimal<2>-Footnote-11333171
Node: distutils<5>1333236
Ref: whatsnew/3 6 distutils1333354
Ref: c631333354
Ref: distutils<5>-Footnote-11333728
Node: email<2>1333793
Ref: whatsnew/3 6 email1333928
Ref: c641333928
Ref: email<2>-Footnote-11334844
Ref: email<2>-Footnote-21334909
Ref: email<2>-Footnote-31334974
Node: エンコーディング<2>1335039
Ref: whatsnew/3 6 encodings1335169
Ref: c681335169
Ref: エンコーディング<2>-Footnote-11335486
Node: enum<6>1335551
Ref: whatsnew/3 6 enum1335688
Ref: c691335688
Ref: enum<6>-Footnote-11336436
Node: faulthandler<2>1336501
Ref: whatsnew/3 6 faulthandler1336623
Ref: c6b1336623
Ref: faulthandler<2>-Footnote-11336886
Node: fileinput<2>1336951
Ref: whatsnew/3 6 fileinput1337076
Ref: c6d1337076
Ref: fileinput<2>-Footnote-11337264
Node: hashlib<5>1337329
Ref: whatsnew/3 6 hashlib1337453
Ref: c6f1337453
Ref: hashlib<5>-Footnote-11338502
Ref: hashlib<5>-Footnote-21338567
Ref: hashlib<5>-Footnote-31338632
Ref: hashlib<5>-Footnote-41338697
Node: http client<2>1338762
Ref: whatsnew/3 6 http-client1338893
Ref: c761338893
Ref: http client<2>-Footnote-11339153
Node: idlelib と IDLE<2>1339218
Ref: whatsnew/3 6 idlelib-and-idle1339351
Ref: c791339351
Ref: idlelib と IDLE<2>-Footnote-11342833
Ref: idlelib と IDLE<2>-Footnote-21342898
Ref: idlelib と IDLE<2>-Footnote-31342963
Ref: idlelib と IDLE<2>-Footnote-41343030
Ref: idlelib と IDLE<2>-Footnote-51343095
Ref: idlelib と IDLE<2>-Footnote-61343160
Ref: idlelib と IDLE<2>-Footnote-71343225
Ref: idlelib と IDLE<2>-Footnote-81343290
Ref: idlelib と IDLE<2>-Footnote-91343355
Ref: idlelib と IDLE<2>-Footnote-101343420
Ref: idlelib と IDLE<2>-Footnote-111343486
Node: importlib<6>1343554
Ref: whatsnew/3 6 importlib1343683
Ref: c7a1343683
Ref: importlib<6>-Footnote-11344508
Node: inspect<6>1344573
Ref: whatsnew/3 6 inspect1344687
Ref: c801344687
Ref: inspect<6>-Footnote-11345462
Ref: inspect<6>-Footnote-21345527
Node: json1345592
Ref: whatsnew/3 6 json1345704
Ref: c811345704
Ref: json-Footnote-11346027
Node: logging<4>1346092
Ref: whatsnew/3 6 logging1346201
Ref: c831346201
Ref: logging<4>-Footnote-11346531
Node: math<7>1346596
Ref: whatsnew/3 6 math1346719
Ref: c851346719
Ref: math<7>-Footnote-11346951
Ref: math<7>-Footnote-21347016
Node: multiprocessing<5>1347058
Ref: whatsnew/3 6 multiprocessing1347176
Ref: c861347176
Ref: multiprocessing<5>-Footnote-11347405
Node: os<8>1347469
Ref: whatsnew/3 6 os1347590
Ref: c891347590
Ref: os<8>-Footnote-11348590
Ref: os<8>-Footnote-21348655
Ref: os<8>-Footnote-31348697
Node: pathlib<9>1348739
Ref: whatsnew/3 6 pathlib1348848
Ref: c8c1348848
Ref: pathlib<9>-Footnote-11349125
Node: pdb<5>1349190
Ref: whatsnew/3 6 pdb1349303
Ref: c8d1349303
Node: pickle<2>1349541
Ref: whatsnew/3 6 pickle1349655
Ref: c8e1349655
Ref: pickle<2>-Footnote-11349972
Node: pickletools1350037
Ref: whatsnew/3 6 pickletools1350153
Ref: c901350153
Ref: pickletools-Footnote-11350381
Node: pydoc<3>1350446
Ref: whatsnew/3 6 pydoc1350562
Ref: c921350562
Ref: pydoc<3>-Footnote-11350956
Ref: pydoc<3>-Footnote-21351020
Node: random<4>1351085
Ref: whatsnew/3 6 random1351195
Ref: c931351195
Ref: random<4>-Footnote-11351450
Node: re<5>1351515
Ref: whatsnew/3 6 re1351625
Ref: c951351625
Ref: re<5>-Footnote-11352336
Ref: re<5>-Footnote-21352402
Ref: re<5>-Footnote-31352467
Node: readline1352532
Ref: whatsnew/3 6 readline1352644
Ref: c971352644
Ref: readline-Footnote-11352875
Node: rlcompleter1352940
Ref: whatsnew/3 6 rlcompleter1353055
Ref: c991353055
Ref: rlcompleter-Footnote-11353359
Ref: rlcompleter-Footnote-21353424
Node: shlex<2>1353489
Ref: whatsnew/3 6 shlex1353603
Ref: c9a1353603
Ref: shlex<2>-Footnote-11353893
Node: site<3>1353960
Ref: whatsnew/3 6 site1354073
Ref: c9d1354073
Ref: site<3>-Footnote-11354337
Node: sqlite3<7>1354402
Ref: whatsnew/3 6 sqlite31354516
Ref: c9e1354516
Ref: sqlite3<7>-Footnote-11354732
Node: socket<7>1354797
Ref: whatsnew/3 6 socket1354919
Ref: ca01354919
Ref: socket<7>-Footnote-11355876
Ref: socket<7>-Footnote-21355941
Ref: socket<7>-Footnote-31356006
Ref: socket<7>-Footnote-41356071
Ref: socket<7>-Footnote-51356136
Node: socketserver<2>1356201
Ref: whatsnew/3 6 socketserver1356319
Ref: ca71356319
Ref: socketserver<2>-Footnote-11356948
Ref: socketserver<2>-Footnote-21357013
Node: ssl<7>1357078
Ref: whatsnew/3 6 ssl1357200
Ref: caa1357200
Ref: ssl<7>-Footnote-11358623
Ref: ssl<7>-Footnote-21358688
Ref: ssl<7>-Footnote-31358753
Ref: ssl<7>-Footnote-41358818
Ref: ssl<7>-Footnote-51358883
Ref: ssl<7>-Footnote-61358948
Ref: ssl<7>-Footnote-71359013
Ref: ssl<7>-Footnote-81359078
Node: statistics<5>1359133
Ref: whatsnew/3 6 statistics1359246
Ref: cae1359246
Ref: statistics<5>-Footnote-11359434
Node: struct1359499
Ref: whatsnew/3 6 struct1359619
Ref: cb01359619
Ref: struct-Footnote-11359850
Node: subprocess<3>1359915
Ref: whatsnew/3 6 subprocess1360029
Ref: cb11360029
Ref: subprocess<3>-Footnote-11360722
Ref: subprocess<3>-Footnote-21360787
Node: sys<10>1360851
Ref: whatsnew/3 6 sys1360968
Ref: cb31360968
Ref: sys<10>-Footnote-11361569
Ref: sys<10>-Footnote-21361634
Node: telnetlib1361699
Ref: whatsnew/3 6 telnetlib1361810
Ref: cb61361810
Ref: telnetlib-Footnote-11361985
Node: time<6>1362050
Ref: whatsnew/3 6 time1362160
Ref: cb71362160
Node: timeit1362347
Ref: whatsnew/3 6 timeit1362458
Ref: cb91362458
Ref: timeit-Footnote-11362915
Ref: timeit-Footnote-21362979
Node: tkinter<6>1363044
Ref: whatsnew/3 6 tkinter1363160
Ref: cbc1363160
Ref: tkinter<6>-Footnote-11363586
Node: traceback<4>1363651
Ref: whatsnew/3 6 traceback1363775
Ref: cbd1363775
Ref: whatsnew/3 6 whatsnew36-traceback1363775
Ref: c3d1363775
Ref: traceback<4>-Footnote-11364408
Node: tracemalloc<3>1364473
Ref: whatsnew/3 6 tracemalloc1364596
Ref: cbe1364596
Ref: tracemalloc<3>-Footnote-11364956
Node: typing<9>1365021
Ref: whatsnew/3 6 typing1365146
Ref: cc01365146
Ref: whatsnew/3 6 whatsnew36-typing1365146
Ref: c0b1365146
Ref: typing<9>-Footnote-11366796
Ref: typing<9>-Footnote-21366846
Ref: typing<9>-Footnote-31366911
Ref: typing<9>-Footnote-41366976
Ref: typing<9>-Footnote-51367018
Ref: typing<9>-Footnote-61367068
Ref: typing<9>-Footnote-71367120
Node: unicodedata<7>1367172
Ref: whatsnew/3 6 unicodedata1367299
Ref: cc41367299
Ref: unicodedata<7>-Footnote-11367486
Node: unittest mock<2>1367537
Ref: whatsnew/3 6 unittest-mock1367669
Ref: cc51367669
Ref: unittest mock<2>-Footnote-11368216
Ref: unittest mock<2>-Footnote-21368281
Node: urllib request1368346
Ref: whatsnew/3 6 urllib-request1368482
Ref: cc91368482
Ref: urllib request-Footnote-11368847
Node: urllib robotparser1368912
Ref: whatsnew/3 6 urllib-robotparser1369039
Ref: cca1369039
Ref: urllib robotparser-Footnote-11369284
Node: venv<5>1369349
Ref: whatsnew/3 6 venv1369473
Ref: ccc1369473
Ref: venv<5>-Footnote-11369799
Node: warnings<4>1369864
Ref: whatsnew/3 6 warnings1369976
Ref: ccd1369976
Ref: warnings<4>-Footnote-11371246
Ref: warnings<4>-Footnote-21371311
Node: winreg1371376
Ref: whatsnew/3 6 winreg1371489
Ref: ccf1371489
Ref: winreg-Footnote-11371662
Node: winsound1371727
Ref: whatsnew/3 6 winsound1371842
Ref: cd11371842
Ref: winsound-Footnote-11372041
Node: xmlrpc client1372106
Ref: whatsnew/3 6 xmlrpc-client1372225
Ref: cd51372225
Ref: xmlrpc client-Footnote-11372518
Node: zipfile<3>1372583
Ref: whatsnew/3 6 zipfile1372698
Ref: cd61372698
Ref: zipfile<3>-Footnote-11373232
Ref: zipfile<3>-Footnote-21373297
Node: zlib1373362
Ref: whatsnew/3 6 zlib1373455
Ref: cda1373455
Ref: zlib-Footnote-11373711
Ref: zlib-Footnote-21373776
Node: 最適化<6>1373841
Ref: whatsnew/3 6 optimizations1374005
Ref: cdc1374005
Ref: 最適化<6>-Footnote-11377858
Ref: 最適化<6>-Footnote-21377923
Ref: 最適化<6>-Footnote-31377988
Ref: 最適化<6>-Footnote-41378053
Ref: 最適化<6>-Footnote-51378118
Ref: 最適化<6>-Footnote-61378183
Ref: 最適化<6>-Footnote-71378248
Ref: 最適化<6>-Footnote-81378313
Ref: 最適化<6>-Footnote-91378378
Ref: 最適化<6>-Footnote-101378443
Ref: 最適化<6>-Footnote-111378509
Ref: 最適化<6>-Footnote-121378575
Ref: 最適化<6>-Footnote-131378641
Ref: 最適化<6>-Footnote-141378707
Ref: 最適化<6>-Footnote-151378773
Ref: 最適化<6>-Footnote-161378839
Ref: 最適化<6>-Footnote-171378905
Ref: 最適化<6>-Footnote-181378971
Ref: 最適化<6>-Footnote-191379037
Ref: 最適化<6>-Footnote-201379103
Ref: 最適化<6>-Footnote-211379169
Node: ビルドならびに C API の変更<2>1379235
Ref: whatsnew/3 6 build-and-c-api-changes1379384
Ref: ce21379384
Ref: ビルドならびに C API の変更<2>-Footnote-11381855
Ref: ビルドならびに C API の変更<2>-Footnote-21381897
Ref: ビルドならびに C API の変更<2>-Footnote-31381962
Ref: ビルドならびに C API の変更<2>-Footnote-41382027
Ref: ビルドならびに C API の変更<2>-Footnote-51382092
Ref: ビルドならびに C API の変更<2>-Footnote-61382156
Ref: ビルドならびに C API の変更<2>-Footnote-71382221
Ref: ビルドならびに C API の変更<2>-Footnote-81382286
Ref: ビルドならびに C API の変更<2>-Footnote-91382351
Ref: ビルドならびに C API の変更<2>-Footnote-101382416
Node: その他の改善1382482
Ref: whatsnew/3 6 other-improvements1382631
Ref: ce81382631
Node: 非推奨<7>1383007
Ref: whatsnew/3 6 deprecated1383125
Ref: cea1383125
Node: 新たなキーワード1383501
Ref: whatsnew/3 6 new-keywords1383609
Ref: ceb1383609
Ref: 新たなキーワード-Footnote-11384109
Node: 非推奨の Python 挙動1384151
Ref: whatsnew/3 6 deprecated-python-behavior1384330
Ref: cec1384330
Ref: 非推奨の Python 挙動-Footnote-11385535
Ref: 非推奨の Python 挙動-Footnote-21385600
Ref: 非推奨の Python 挙動-Footnote-31385665
Node: 非推奨の Python モジュール、関数、メソッド<2>1385730
Ref: whatsnew/3 6 deprecated-python-modules-functions-and-methods1385891
Ref: cee1385891
Node: asynchat1386205
Ref: whatsnew/3 6 asynchat1386329
Ref: cef1386329
Ref: asynchat-Footnote-11386513
Node: asyncore1386578
Ref: whatsnew/3 6 asyncore1386717
Ref: cf01386717
Ref: asyncore-Footnote-11386901
Node: dbm<4>1386966
Ref: whatsnew/3 6 dbm1387109
Ref: cf11387109
Ref: dbm<4>-Footnote-11387469
Node: distutils<6>1387534
Ref: whatsnew/3 6 id21387672
Ref: cf21387672
Ref: distutils<6>-Footnote-11388002
Node: grp1388067
Ref: whatsnew/3 6 grp1388211
Ref: cf31388211
Ref: grp-Footnote-11388417
Node: importlib<7>1388482
Ref: whatsnew/3 6 id31388619
Ref: cf51388619
Node: os<9>1389273
Ref: whatsnew/3 6 id41389412
Ref: cfa1389412
Ref: os<9>-Footnote-11389706
Ref: os<9>-Footnote-21389771
Node: re<6>1389836
Ref: whatsnew/3 6 id51389969
Ref: cfc1389969
Ref: re<6>-Footnote-11390295
Node: ssl<8>1390360
Ref: whatsnew/3 6 id61390498
Ref: cfd1390498
Ref: ssl<8>-Footnote-11391356
Ref: ssl<8>-Footnote-21391421
Ref: ssl<8>-Footnote-31391486
Node: tkinter<7>1391551
Ref: whatsnew/3 6 id71391691
Ref: cfe1391691
Node: venv<6>1391844
Ref: whatsnew/3 6 id81391969
Ref: cff1391969
Ref: whatsnew/3 6 whatsnew36-venv1391969
Ref: d001391969
Ref: venv<6>-Footnote-11392320
Node: xml<6>1392385
Ref: whatsnew/3 6 xml1392565
Ref: d011392565
Ref: xml<6>-Footnote-11392869
Node: C API の非推奨の関数ならびに型<2>1392924
Ref: whatsnew/3 6 deprecated-functions-and-types-of-the-c-api1393078
Ref: d021393078
Node: 非推奨のビルドオプション1393413
Ref: whatsnew/3 6 deprecated-build-options1393552
Ref: d041393552
Node: 削除<7>1394005
Ref: whatsnew/3 6 removed1394128
Ref: d051394128
Node: API と機能の削除<3>1394218
Ref: whatsnew/3 6 api-and-feature-removals1394289
Ref: d061394289
Ref: API と機能の削除<3>-Footnote-11396380
Ref: API と機能の削除<3>-Footnote-21396445
Node: Python 3 6 への移植1396523
Ref: whatsnew/3 6 porting-to-python-3-61396665
Ref: d091396665
Node: 'python' コマンドの挙動の変更1397093
Ref: whatsnew/3 6 changes-in-python-command-behavior1397224
Ref: d0a1397224
Ref: 'python' コマンドの挙動の変更-Footnote-11397696
Node: Python API の変更<6>1397761
Ref: whatsnew/3 6 changes-in-the-python-api1397919
Ref: d0b1397919
Ref: Python API の変更<6>-Footnote-11408062
Ref: Python API の変更<6>-Footnote-21408126
Ref: Python API の変更<6>-Footnote-31408168
Ref: Python API の変更<6>-Footnote-41408233
Ref: Python API の変更<6>-Footnote-51408298
Ref: Python API の変更<6>-Footnote-61408363
Ref: Python API の変更<6>-Footnote-71408428
Ref: Python API の変更<6>-Footnote-81408493
Ref: Python API の変更<6>-Footnote-91408558
Ref: Python API の変更<6>-Footnote-101408623
Ref: Python API の変更<6>-Footnote-111408689
Ref: Python API の変更<6>-Footnote-121408732
Ref: Python API の変更<6>-Footnote-131408798
Ref: Python API の変更<6>-Footnote-141408864
Ref: Python API の変更<6>-Footnote-151408930
Ref: Python API の変更<6>-Footnote-161408996
Ref: Python API の変更<6>-Footnote-171409061
Ref: Python API の変更<6>-Footnote-181409127
Ref: Python API の変更<6>-Footnote-191409193
Ref: Python API の変更<6>-Footnote-201409259
Node: C API の変更<9>1409325
Ref: whatsnew/3 6 changes-in-the-c-api1409482
Ref: d1b1409482
Ref: C API の変更<9>-Footnote-11410123
Ref: C API の変更<9>-Footnote-21410188
Node: CPython バイトコードの変更<6>1410252
Ref: whatsnew/3 6 cpython-bytecode-changes1410377
Ref: d1d1410377
Ref: CPython バイトコードの変更<6>-Footnote-11412016
Ref: CPython バイトコードの変更<6>-Footnote-21412081
Ref: CPython バイトコードの変更<6>-Footnote-31412146
Ref: CPython バイトコードの変更<6>-Footnote-41412211
Ref: CPython バイトコードの変更<6>-Footnote-51412276
Ref: CPython バイトコードの変更<6>-Footnote-61412341
Ref: CPython バイトコードの変更<6>-Footnote-71412406
Ref: CPython バイトコードの変更<6>-Footnote-81412471
Ref: CPython バイトコードの変更<6>-Footnote-91412536
Node: Notable changes in Python 3 6 21412601
Ref: whatsnew/3 6 notable-changes-in-python-3-6-21412765
Ref: d241412765
Node: New make regen-all build target1412929
Ref: whatsnew/3 6 new-make-regen-all-build-target1413071
Ref: d251413071
Ref: New make regen-all build target-Footnote-11413860
Ref: New make regen-all build target-Footnote-21413928
Node: Removal of make touch build target1413993
Ref: whatsnew/3 6 removal-of-make-touch-build-target1414135
Ref: d261414135
Ref: Removal of make touch build target-Footnote-11414572
Node: Notable changes in Python 3 6 41414637
Ref: whatsnew/3 6 notable-changes-in-python-3-6-41414809
Ref: d271414809
Ref: Notable changes in Python 3 6 4-Footnote-11415182
Ref: Notable changes in Python 3 6 4-Footnote-21415247
Node: Notable changes in Python 3 6 51415312
Ref: whatsnew/3 6 notable-changes-in-python-3-6-51415484
Ref: d281415484
Ref: Notable changes in Python 3 6 5-Footnote-11415787
Node: Notable changes in Python 3 6 71415852
Ref: whatsnew/3 6 notable-changes-in-python-3-6-71416025
Ref: d291416025
Ref: Notable changes in Python 3 6 7-Footnote-11416531
Ref: Notable changes in Python 3 6 7-Footnote-21416586
Node: Notable changes in Python 3 6 101416651
Ref: whatsnew/3 6 notable-changes-in-python-3-6-101416825
Ref: d2a1416825
Ref: Notable changes in Python 3 6 10-Footnote-11417388
Node: Notable changes in Python 3 6 131417453
Ref: whatsnew/3 6 notable-changes-in-python-3-6-131417628
Ref: d2b1417628
Ref: Notable changes in Python 3 6 13-Footnote-11418348
Node: Notable changes in Python 3 6 141418413
Ref: whatsnew/3 6 notable-changes-in-python-3-6-141418547
Ref: d2c1418547
Ref: Notable changes in Python 3 6 14-Footnote-11419463
Ref: Notable changes in Python 3 6 14-Footnote-21419518
Node: What's New In Python 3 51419573
Ref: whatsnew/3 5 doc1419720
Ref: d2d1419720
Ref: whatsnew/3 5 what-s-new-in-python-3-51419720
Ref: d2e1419720
Ref: What's New In Python 3 5-Footnote-11420830
Ref: What's New In Python 3 5-Footnote-21420890
Node: 概要 -- リリースハイライト<7>1420932
Ref: whatsnew/3 5 summary-release-highlights1421061
Ref: d2f1421061
Ref: 概要 -- リリースハイライト<7>-Footnote-11425711
Ref: 概要 -- リリースハイライト<7>-Footnote-21425775
Ref: 概要 -- リリースハイライト<7>-Footnote-31425840
Ref: 概要 -- リリースハイライト<7>-Footnote-41425905
Ref: 概要 -- リリースハイライト<7>-Footnote-51425970
Ref: 概要 -- リリースハイライト<7>-Footnote-61426035
Ref: 概要 -- リリースハイライト<7>-Footnote-71426100
Node: 新しい機能<10>1426165
Ref: whatsnew/3 5 new-features1426330
Ref: d421426330
Node: PEP 492 - コルーチン、 async と await 構文1427520
Ref: whatsnew/3 5 pep-492-coroutines-with-async-and-await-syntax1427685
Ref: d431427685
Ref: whatsnew/3 5 whatsnew-pep-4921427685
Ref: d301427685
Ref: PEP 492 - コルーチン、 async と await 構文-Footnote-11431162
Ref: PEP 492 - コルーチン、 async と await 構文-Footnote-21431204
Node: PEP 465 - 行列の乗算専用の中置演算子1431246
Ref: whatsnew/3 5 pep-465-a-dedicated-infix-operator-for-matrix-multiplication1431475
Ref: d481431475
Ref: whatsnew/3 5 whatsnew-pep-4651431475
Ref: d311431475
Ref: PEP 465 - 行列の乗算専用の中置演算子-Footnote-11433014
Ref: PEP 465 - 行列の乗算専用の中置演算子-Footnote-21433056
Node: PEP 448 - 追加可能なアンパックへの一般化1433098
Ref: whatsnew/3 5 pep-448-additional-unpacking-generalizations1433351
Ref: d491433351
Ref: whatsnew/3 5 whatsnew-pep-4481433351
Ref: d321433351
Ref: PEP 448 - 追加可能なアンパックへの一般化-Footnote-11434543
Ref: PEP 448 - 追加可能なアンパックへの一般化-Footnote-21434585
Node: PEP 461 - bytes および bytearray のパーセント書式化サポート1434627
Ref: whatsnew/3 5 pep-461-percent-formatting-support-for-bytes-and-bytearray1434853
Ref: d4d1434853
Ref: whatsnew/3 5 whatsnew-pep-4611434853
Ref: d351434853
Ref: PEP 461 - bytes および bytearray のパーセント書式化サポート-Footnote-11436587
Ref: PEP 461 - bytes および bytearray のパーセント書式化サポート-Footnote-21436629
Node: PEP 484 - 型ヒント1436671
Ref: whatsnew/3 5 pep-484-type-hints1436927
Ref: d4f1436927
Ref: whatsnew/3 5 whatsnew-pep-4841436927
Ref: d331436927
Ref: PEP 484 - 型ヒント-Footnote-11438677
Ref: PEP 484 - 型ヒント-Footnote-21438719
Ref: PEP 484 - 型ヒント-Footnote-31438761
Ref: PEP 484 - 型ヒント-Footnote-41438791
Ref: PEP 484 - 型ヒント-Footnote-51438833
Node: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ1438875
Ref: whatsnew/3 5 pep-471-os-scandir-function-a-better-and-faster-directory-iterator1439118
Ref: d501439118
Ref: whatsnew/3 5 whatsnew-pep-4711439118
Ref: d3e1439118
Ref: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ-Footnote-11440660
Ref: PEP 471 - os scandir 関数 -- より良く、速いディレクトリイテレータ-Footnote-21440702
Node: PEP 475 EINTR で失敗したシステムコールの再試行1440744
Ref: whatsnew/3 5 pep-475-retry-system-calls-failing-with-eintr1441030
Ref: d521441030
Ref: whatsnew/3 5 whatsnew-pep-4751441030
Ref: d531441030
Ref: PEP 475 EINTR で失敗したシステムコールの再試行-Footnote-11444511
Ref: PEP 475 EINTR で失敗したシステムコールの再試行-Footnote-21444553
Node: PEP 479 ジェネレータ内の StopIteration の処理の変更1444595
Ref: whatsnew/3 5 pep-479-change-stopiteration-handling-inside-generators1444849
Ref: d791444849
Ref: whatsnew/3 5 whatsnew-pep-4791444849
Ref: ced1444849
Ref: PEP 479 ジェネレータ内の StopIteration の処理の変更-Footnote-11447141
Ref: PEP 479 ジェネレータ内の StopIteration の処理の変更-Footnote-21447183
Node: PEP 485 近似的に等しいことを調べる関数1447225
Ref: whatsnew/3 5 pep-485-a-function-for-testing-approximate-equality1447477
Ref: d7b1447477
Ref: whatsnew/3 5 whatsnew-pep-4851447477
Ref: d7c1447477
Ref: PEP 485 近似的に等しいことを調べる関数-Footnote-11448661
Ref: PEP 485 近似的に等しいことを調べる関数-Footnote-21448703
Node: PEP 486 Python ランチャーが仮想環境を認識する1448745
Ref: whatsnew/3 5 pep-486-make-the-python-launcher-aware-of-virtual-environments1448965
Ref: d7f1448965
Ref: whatsnew/3 5 whatsnew-pep-4861448965
Ref: d801448965
Ref: PEP 486 Python ランチャーが仮想環境を認識する-Footnote-11449612
Ref: PEP 486 Python ランチャーが仮想環境を認識する-Footnote-21449654
Ref: PEP 486 Python ランチャーが仮想環境を認識する-Footnote-31449696
Node: PEP 488 PYO ファイルの廃止1449738
Ref: whatsnew/3 5 pep-488-elimination-of-pyo-files1449955
Ref: d811449955
Ref: whatsnew/3 5 whatsnew-pep-4881449955
Ref: d3a1449955
Ref: PEP 488 PYO ファイルの廃止-Footnote-11451096
Ref: PEP 488 PYO ファイルの廃止-Footnote-21451138
Node: PEP 489 拡張モジュールの多段階初期化1451180
Ref: whatsnew/3 5 pep-489-multi-phase-extension-module-initialization1451328
Ref: d841451328
Ref: whatsnew/3 5 whatsnew-pep-4891451328
Ref: d3b1451328
Ref: PEP 489 拡張モジュールの多段階初期化-Footnote-11452215
Ref: PEP 489 拡張モジュールの多段階初期化-Footnote-21452257
Ref: PEP 489 拡張モジュールの多段階初期化-Footnote-31452299
Node: その他の言語変更<7>1452341
Ref: whatsnew/3 5 other-language-changes1452493
Ref: d851452493
Ref: その他の言語変更<7>-Footnote-11453749
Ref: その他の言語変更<7>-Footnote-21453814
Ref: その他の言語変更<7>-Footnote-31453879
Ref: その他の言語変更<7>-Footnote-41453944
Ref: その他の言語変更<7>-Footnote-51454009
Ref: その他の言語変更<7>-Footnote-61454074
Ref: その他の言語変更<7>-Footnote-71454139
Node: 新たなモジュール<7>1454204
Ref: whatsnew/3 5 new-modules1454370
Ref: d871454370
Node: typing<10>1454478
Ref: whatsnew/3 5 typing1454570
Ref: d881454570
Node: zipapp<2>1454780
Ref: whatsnew/3 5 whatsnew-zipapp1454872
Ref: d341454872
Ref: whatsnew/3 5 zipapp1454872
Ref: d891454872
Ref: zipapp<2>-Footnote-11455802
Ref: zipapp<2>-Footnote-21455844
Ref: zipapp<2>-Footnote-31455911
Ref: zipapp<2>-Footnote-41455976
Node: 改良されたモジュール<7>1456018
Ref: whatsnew/3 5 improved-modules1456202
Ref: d8a1456202
Node: argparse<4>1457928
Ref: whatsnew/3 5 argparse1458029
Ref: d8b1458029
Ref: argparse<4>-Footnote-11458405
Node: asyncio<10>1458470
Ref: whatsnew/3 5 asyncio1458583
Ref: d8e1458583
Ref: asyncio<10>-Footnote-11462441
Ref: asyncio<10>-Footnote-21462506
Ref: asyncio<10>-Footnote-31462571
Node: bz21462616
Ref: whatsnew/3 5 bz21462721
Ref: d981462721
Ref: bz2-Footnote-11463039
Node: cgi1463104
Ref: whatsnew/3 5 cgi1463206
Ref: d9a1463206
Ref: cgi-Footnote-11463401
Node: cmath<2>1463466
Ref: whatsnew/3 5 cmath1463574
Ref: d9b1463574
Ref: cmath<2>-Footnote-11463819
Node: コード1463884
Ref: whatsnew/3 5 code1464003
Ref: d9c1464003
Ref: コード-Footnote-11464319
Node: collections<5>1464384
Ref: whatsnew/3 5 collections1464513
Ref: d9e1464513
Ref: whatsnew/3 5 whatsnew-ordereddict1464554
Ref: d3c1464554
Ref: collections<5>-Footnote-11465982
Ref: collections<5>-Footnote-21466047
Ref: collections<5>-Footnote-31466112
Ref: collections<5>-Footnote-41466177
Ref: collections<5>-Footnote-51466242
Node: collections abc<3>1466307
Ref: whatsnew/3 5 collections-abc1466440
Ref: da71466440
Ref: collections abc<3>-Footnote-11467168
Ref: collections abc<3>-Footnote-21467233
Ref: collections abc<3>-Footnote-31467298
Ref: collections abc<3>-Footnote-41467363
Node: compileall<4>1467411
Ref: whatsnew/3 5 compileall1467551
Ref: dad1467551
Ref: compileall<4>-Footnote-11468426
Ref: compileall<4>-Footnote-21468491
Ref: compileall<4>-Footnote-31468556
Node: concurrent futures<5>1468621
Ref: whatsnew/3 5 concurrent-futures1468758
Ref: db01468758
Ref: concurrent futures<5>-Footnote-11469258
Ref: concurrent futures<5>-Footnote-21469323
Node: configparser<4>1469388
Ref: whatsnew/3 5 configparser1469525
Ref: db21469525
Ref: configparser<4>-Footnote-11470502
Node: contextlib<5>1470567
Ref: whatsnew/3 5 contextlib1470689
Ref: db31470689
Ref: contextlib<5>-Footnote-11471376
Node: csv<3>1471441
Ref: whatsnew/3 5 csv1471557
Ref: db61471557
Ref: csv<3>-Footnote-11471802
Node: curses<4>1471867
Ref: whatsnew/3 5 curses1471976
Ref: db81471976
Ref: curses<4>-Footnote-11472252
Node: dbm<5>1472316
Ref: whatsnew/3 5 dbm1472426
Ref: dba1472426
Ref: dbm<5>-Footnote-11472629
Node: difflib1472694
Ref: whatsnew/3 5 difflib1472807
Ref: dbb1472807
Ref: difflib-Footnote-11473343
Ref: difflib-Footnote-21473407
Node: distutils<7>1473472
Ref: whatsnew/3 5 distutils1473589
Ref: dbe1473589
Ref: distutils<7>-Footnote-11474040
Ref: distutils<7>-Footnote-21474104
Node: doctest<3>1474169
Ref: whatsnew/3 5 doctest1474287
Ref: dbf1474287
Ref: doctest<3>-Footnote-11474663
Node: email<3>1474728
Ref: whatsnew/3 5 email1474841
Ref: dc21474841
Ref: email<3>-Footnote-11475952
Ref: email<3>-Footnote-21476017
Ref: email<3>-Footnote-31476082
Ref: email<3>-Footnote-41476141
Ref: email<3>-Footnote-51476200
Ref: email<3>-Footnote-61476265
Node: enum<7>1476330
Ref: whatsnew/3 5 enum1476448
Ref: dc81476448
Ref: enum<7>-Footnote-11476884
Node: faulthandler<3>1476949
Ref: whatsnew/3 5 faulthandler1477071
Ref: dc91477071
Ref: faulthandler<3>-Footnote-11477428
Node: functools<4>1477493
Ref: whatsnew/3 5 functools1477615
Ref: dcd1477615
Ref: whatsnew/3 5 whatsnew-lrucache1477654
Ref: d3f1477654
Ref: functools<4>-Footnote-11477904
Node: glob<3>1477969
Ref: whatsnew/3 5 glob1478083
Ref: dce1478083
Ref: glob<3>-Footnote-11478373
Node: gzip<4>1478438
Ref: whatsnew/3 5 gzip1478545
Ref: dcf1478545
Ref: gzip<4>-Footnote-11478802
Node: heapq1478867
Ref: whatsnew/3 5 heapq1478974
Ref: dd01478974
Ref: heapq-Footnote-11479614
Node: http<2>1479679
Ref: whatsnew/3 5 http1479793
Ref: dd31479793
Ref: http<2>-Footnote-11480076
Node: http client<3>1480141
Ref: whatsnew/3 5 http-client1480269
Ref: dd41480269
Ref: http client<3>-Footnote-11481013
Node: idlelib と IDLE<3>1481077
Ref: whatsnew/3 5 idlelib-and-idle1481208
Ref: dd81481208
Node: imaplib<2>1481738
Ref: whatsnew/3 5 imaplib1481861
Ref: dd91481861
Ref: imaplib<2>-Footnote-11482795
Ref: imaplib<2>-Footnote-21482859
Ref: imaplib<2>-Footnote-31482918
Ref: imaplib<2>-Footnote-41482977
Ref: imaplib<2>-Footnote-51483036
Ref: imaplib<2>-Footnote-61483101
Node: imghdr1483166
Ref: whatsnew/3 5 imghdr1483282
Ref: ddc1483282
Ref: imghdr-Footnote-11483570
Ref: imghdr-Footnote-21483602
Ref: imghdr-Footnote-31483667
Ref: imghdr-Footnote-41483710
Node: importlib<8>1483775
Ref: whatsnew/3 5 importlib1483891
Ref: ddd1483891
Ref: importlib<8>-Footnote-11484726
Ref: importlib<8>-Footnote-21484791
Ref: importlib<8>-Footnote-31484856
Node: inspect<7>1484921
Ref: whatsnew/3 5 inspect1485036
Ref: de11485036
Ref: inspect<7>-Footnote-11486593
Ref: inspect<7>-Footnote-21486658
Ref: inspect<7>-Footnote-31486723
Ref: inspect<7>-Footnote-41486788
Ref: inspect<7>-Footnote-51486853
Ref: inspect<7>-Footnote-61486918
Ref: inspect<7>-Footnote-71486983
Ref: inspect<7>-Footnote-81487048
Node: io<5>1487113
Ref: whatsnew/3 5 io1487228
Ref: de71487228
Ref: io<5>-Footnote-11487524
Node: ipaddress<4>1487589
Ref: whatsnew/3 5 ipaddress1487701
Ref: deb1487701
Ref: ipaddress<4>-Footnote-11488729
Ref: ipaddress<4>-Footnote-21488794
Node: json<2>1488859
Ref: whatsnew/3 5 json1488978
Ref: dec1488978
Ref: json<2>-Footnote-11489478
Ref: json<2>-Footnote-21489543
Node: linecache<2>1489608
Ref: whatsnew/3 5 linecache1489724
Ref: dee1489724
Ref: linecache<2>-Footnote-11490134
Node: locale<6>1490199
Ref: whatsnew/3 5 locale1490318
Ref: df11490318
Ref: locale<6>-Footnote-11490883
Node: logging<5>1490948
Ref: whatsnew/3 5 logging1491059
Ref: df31491059
Ref: logging<5>-Footnote-11492029
Ref: logging<5>-Footnote-21492094
Node: lzma1492159
Ref: whatsnew/3 5 lzma1492268
Ref: dfa1492268
Ref: lzma-Footnote-11492530
Node: math<8>1492595
Ref: whatsnew/3 5 math1492712
Ref: dfc1492712
Ref: math<8>-Footnote-11493294
Ref: math<8>-Footnote-21493359
Ref: math<8>-Footnote-31493424
Node: multiprocessing<6>1493489
Ref: whatsnew/3 5 multiprocessing1493613
Ref: dfd1493613
Ref: multiprocessing<6>-Footnote-11493932
Node: operator<2>1493997
Ref: whatsnew/3 5 operator1494120
Ref: dff1494120
Ref: operator<2>-Footnote-11494548
Ref: operator<2>-Footnote-21494613
Node: os<10>1494678
Ref: whatsnew/3 5 os1494794
Ref: e041494794
Ref: os<10>-Footnote-11496842
Ref: os<10>-Footnote-21496907
Ref: os<10>-Footnote-31496972
Ref: os<10>-Footnote-41497037
Ref: os<10>-Footnote-51497102
Ref: os<10>-Footnote-61497167
Node: pathlib<10>1497232
Ref: whatsnew/3 5 pathlib1497346
Ref: e0c1497346
Ref: pathlib<10>-Footnote-11498817
Ref: pathlib<10>-Footnote-21498882
Ref: pathlib<10>-Footnote-31498947
Ref: pathlib<10>-Footnote-41499012
Ref: pathlib<10>-Footnote-51499077
Node: pickle<3>1499142
Ref: whatsnew/3 5 pickle1499259
Ref: e151499259
Ref: pickle<3>-Footnote-11499575
Node: poplib<2>1499640
Ref: whatsnew/3 5 poplib1499751
Ref: e161499751
Ref: poplib<2>-Footnote-11499993
Ref: poplib<2>-Footnote-21500052
Node: re<7>1500117
Ref: whatsnew/3 5 re1500230
Ref: e181500230
Ref: re<7>-Footnote-11501435
Ref: re<7>-Footnote-21501499
Ref: re<7>-Footnote-31501564
Ref: re<7>-Footnote-41501631
Node: readline<2>1501696
Ref: whatsnew/3 5 readline1501809
Ref: e191501809
Ref: readline<2>-Footnote-11502072
Node: selectors1502137
Ref: whatsnew/3 5 selectors1502254
Ref: e1b1502254
Ref: selectors-Footnote-11502474
Node: shutil<5>1502539
Ref: whatsnew/3 5 shutil1502654
Ref: e1c1502654
Ref: shutil<5>-Footnote-11503133
Ref: shutil<5>-Footnote-21503198
Node: signal<3>1503262
Ref: whatsnew/3 5 signal1503376
Ref: e1d1503376
Ref: signal<3>-Footnote-11503884
Ref: signal<3>-Footnote-21503949
Node: smtpd<2>1504014
Ref: whatsnew/3 5 smtpd1504129
Ref: e1e1504129
Ref: smtpd<2>-Footnote-11505765
Ref: smtpd<2>-Footnote-21505830
Ref: smtpd<2>-Footnote-31505889
Ref: smtpd<2>-Footnote-41505954
Ref: smtpd<2>-Footnote-51506013
Ref: smtpd<2>-Footnote-61506078
Node: smtplib<2>1506143
Ref: whatsnew/3 5 smtplib1506255
Ref: e1f1506255
Ref: smtplib<2>-Footnote-11506876
Ref: smtplib<2>-Footnote-21506941
Ref: smtplib<2>-Footnote-31507006
Ref: smtplib<2>-Footnote-41507065
Node: sndhdr1507130
Ref: whatsnew/3 5 sndhdr1507243
Ref: e241507243
Ref: sndhdr-Footnote-11507446
Node: socket<8>1507511
Ref: whatsnew/3 5 socket1507620
Ref: e251507620
Ref: socket<8>-Footnote-11508589
Ref: socket<8>-Footnote-21508654
Ref: socket<8>-Footnote-31508719
Ref: socket<8>-Footnote-41508784
Node: ssl<9>1508849
Ref: whatsnew/3 5 ssl1508962
Ref: e291508962
Node: メモリ BIO サポート1509104
Ref: whatsnew/3 5 memory-bio-support1509228
Ref: e2a1509228
Ref: whatsnew/3 5 whatsnew-sslmemorybio1509228
Ref: d3d1509228
Ref: メモリ BIO サポート-Footnote-11510114
Node: Application-Layer Protocol Negotiation Support1510179
Ref: whatsnew/3 5 application-layer-protocol-negotiation-support1510330
Ref: e2c1510330
Ref: Application-Layer Protocol Negotiation Support-Footnote-11511035
Ref: Application-Layer Protocol Negotiation Support-Footnote-21511100
Node: その他の変更1511159
Ref: whatsnew/3 5 other-changes1511275
Ref: e301511275
Ref: その他の変更-Footnote-11512863
Ref: その他の変更-Footnote-21512928
Ref: その他の変更-Footnote-31512993
Ref: その他の変更-Footnote-41513058
Ref: その他の変更-Footnote-51513117
Ref: その他の変更-Footnote-61513182
Ref: その他の変更-Footnote-71513247
Ref: その他の変更-Footnote-81513312
Node: sqlite3<8>1513377
Ref: whatsnew/3 5 sqlite31513494
Ref: e391513494
Ref: sqlite3<8>-Footnote-11513823
Ref: sqlite3<8>-Footnote-21513888
Node: subprocess<4>1513953
Ref: whatsnew/3 5 subprocess1514071
Ref: e3b1514071
Ref: whatsnew/3 5 whatsnew-subprocess1514071
Ref: d401514071
Ref: subprocess<4>-Footnote-11515165
Node: sys<11>1515230
Ref: whatsnew/3 5 sys1515350
Ref: e3d1515350
Ref: sys<11>-Footnote-11516000
Ref: sys<11>-Footnote-21516065
Node: sysconfig<2>1516130
Ref: whatsnew/3 5 sysconfig1516247
Ref: e3e1516247
Ref: sysconfig<2>-Footnote-11516480
Node: tarfile<6>1516545
Ref: whatsnew/3 5 tarfile1516667
Ref: e3f1516667
Ref: tarfile<6>-Footnote-11517599
Ref: tarfile<6>-Footnote-21517664
Ref: tarfile<6>-Footnote-31517729
Node: threading<6>1517794
Ref: whatsnew/3 5 threading1517911
Ref: e451517911
Ref: threading<6>-Footnote-11518202
Node: time<7>1518267
Ref: whatsnew/3 5 time1518383
Ref: e471518383
Ref: time<7>-Footnote-11518580
Node: timeit<2>1518645
Ref: whatsnew/3 5 timeit1518759
Ref: e481518759
Ref: timeit<2>-Footnote-11519306
Ref: timeit<2>-Footnote-21519371
Node: tkinter<8>1519435
Ref: whatsnew/3 5 tkinter1519554
Ref: e4a1519554
Ref: tkinter<8>-Footnote-11519886
Node: traceback<5>1519951
Ref: whatsnew/3 5 traceback1520069
Ref: e4b1520069
Ref: whatsnew/3 5 whatsnew-traceback1520069
Ref: d411520069
Ref: traceback<5>-Footnote-11520662
Ref: traceback<5>-Footnote-21520727
Ref: traceback<5>-Footnote-31520792
Node: types<5>1520857
Ref: whatsnew/3 5 types1520979
Ref: e521520979
Ref: types<5>-Footnote-11521522
Ref: types<5>-Footnote-21521587
Node: unicodedata<8>1521652
Ref: whatsnew/3 5 unicodedata1521773
Ref: e551521773
Ref: unicodedata<8>-Footnote-11521924
Node: unittest<8>1521975
Ref: whatsnew/3 5 unittest1522104
Ref: e561522104
Ref: unittest<8>-Footnote-11522898
Ref: unittest<8>-Footnote-21522963
Ref: unittest<8>-Footnote-31523028
Node: unittest mock<3>1523093
Ref: whatsnew/3 5 unittest-mock1523217
Ref: e581523217
Ref: unittest mock<3>-Footnote-11524152
Ref: unittest mock<3>-Footnote-21524217
Ref: unittest mock<3>-Footnote-31524282
Ref: unittest mock<3>-Footnote-41524347
Ref: unittest mock<3>-Footnote-51524412
Ref: unittest mock<3>-Footnote-61524477
Node: urllib<2>1524542
Ref: whatsnew/3 5 urllib1524662
Ref: e5c1524662
Ref: urllib<2>-Footnote-11525822
Ref: urllib<2>-Footnote-21525887
Ref: urllib<2>-Footnote-31525951
Ref: urllib<2>-Footnote-41526016
Ref: urllib<2>-Footnote-51526081
Ref: urllib<2>-Footnote-61526140
Ref: urllib<2>-Footnote-71526199
Ref: urllib<2>-Footnote-81526258
Node: wsgiref1526323
Ref: whatsnew/3 5 wsgiref1526436
Ref: e601526436
Ref: wsgiref-Footnote-11526674
Node: xmlrpc<2>1526738
Ref: whatsnew/3 5 xmlrpc1526849
Ref: e621526849
Ref: xmlrpc<2>-Footnote-11527320
Ref: xmlrpc<2>-Footnote-21527385
Node: xml sax1527450
Ref: whatsnew/3 5 xml-sax1527564
Ref: e631527564
Ref: xml sax-Footnote-11527971
Ref: xml sax-Footnote-21528035
Node: zipfile<4>1528100
Ref: whatsnew/3 5 zipfile1528196
Ref: e661528196
Ref: zipfile<4>-Footnote-11528568
Ref: zipfile<4>-Footnote-21528633
Node: その他のモジュールレベルの変更1528698
Ref: whatsnew/3 5 other-module-level-changes1528867
Ref: e671528867
Ref: その他のモジュールレベルの変更-Footnote-11529217
Node: 最適化<7>1529282
Ref: whatsnew/3 5 optimizations1529458
Ref: e681529458
Ref: 最適化<7>-Footnote-11532678
Ref: 最適化<7>-Footnote-21532743
Ref: 最適化<7>-Footnote-31532808
Ref: 最適化<7>-Footnote-41532873
Ref: 最適化<7>-Footnote-51532938
Ref: 最適化<7>-Footnote-61533003
Ref: 最適化<7>-Footnote-71533068
Ref: 最適化<7>-Footnote-81533133
Ref: 最適化<7>-Footnote-91533198
Ref: 最適化<7>-Footnote-101533263
Ref: 最適化<7>-Footnote-111533329
Ref: 最適化<7>-Footnote-121533395
Ref: 最適化<7>-Footnote-131533461
Ref: 最適化<7>-Footnote-141533527
Ref: 最適化<7>-Footnote-151533593
Ref: 最適化<7>-Footnote-161533659
Ref: 最適化<7>-Footnote-171533725
Ref: 最適化<7>-Footnote-181533791
Ref: 最適化<7>-Footnote-191533857
Ref: 最適化<7>-Footnote-201533923
Node: ビルドならびに C API の変更<3>1533989
Ref: whatsnew/3 5 build-and-c-api-changes1534132
Ref: e751534132
Ref: ビルドならびに C API の変更<3>-Footnote-11538582
Ref: ビルドならびに C API の変更<3>-Footnote-21538647
Ref: ビルドならびに C API の変更<3>-Footnote-31538712
Ref: ビルドならびに C API の変更<3>-Footnote-41538777
Ref: ビルドならびに C API の変更<3>-Footnote-51538842
Ref: ビルドならびに C API の変更<3>-Footnote-61538907
Ref: ビルドならびに C API の変更<3>-Footnote-71538949
Ref: ビルドならびに C API の変更<3>-Footnote-81539014
Ref: ビルドならびに C API の変更<3>-Footnote-91539079
Ref: ビルドならびに C API の変更<3>-Footnote-101539121
Node: 非推奨<8>1539227
Ref: whatsnew/3 5 deprecated1539367
Ref: e801539367
Node: 新たなキーワード<2>1539723
Ref: whatsnew/3 5 new-keywords1539840
Ref: e811539840
Ref: 新たなキーワード<2>-Footnote-11540210
Node: 非推奨の Python の挙動<2>1540252
Ref: whatsnew/3 5 deprecated-python-behavior1540438
Ref: e821540438
Node: サポートされないオペレーティングシステム1540912
Ref: whatsnew/3 5 unsupported-operating-systems1541133
Ref: e831541133
Ref: サポートされないオペレーティングシステム-Footnote-11541483
Node: 非推奨の Python モジュール、関数、メソッド<3>1541525
Ref: whatsnew/3 5 deprecated-python-modules-functions-and-methods1541705
Ref: e841541705
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-11545131
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-21545196
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-31545236
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-41545300
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-51545365
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-61545430
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-71545495
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-81545560
Ref: 非推奨の Python モジュール、関数、メソッド<3>-Footnote-91545625
Node: 削除<8>1545690
Ref: whatsnew/3 5 removed1545813
Ref: e891545813
Node: API と機能の削除<4>1545903
Ref: whatsnew/3 5 api-and-feature-removals1545974
Ref: e8a1545974
Ref: API と機能の削除<4>-Footnote-11546985
Ref: API と機能の削除<4>-Footnote-21547049
Node: Python 3 5 への移植1547114
Ref: whatsnew/3 5 porting-to-python-3-51547256
Ref: e8b1547256
Node: Python の挙動の変更<3>1547621
Ref: whatsnew/3 5 changes-in-python-behavior1547741
Ref: e8c1547741
Node: Python API の変更<7>1548515
Ref: whatsnew/3 5 changes-in-the-python-api1548663
Ref: e8d1548663
Ref: Python API の変更<7>-Footnote-11558268
Ref: Python API の変更<7>-Footnote-21558310
Ref: Python API の変更<7>-Footnote-31558375
Ref: Python API の変更<7>-Footnote-41558440
Ref: Python API の変更<7>-Footnote-51558505
Ref: Python API の変更<7>-Footnote-61558570
Ref: Python API の変更<7>-Footnote-71558635
Ref: Python API の変更<7>-Footnote-81558700
Ref: Python API の変更<7>-Footnote-91558753
Ref: Python API の変更<7>-Footnote-101558818
Ref: Python API の変更<7>-Footnote-111558884
Ref: Python API の変更<7>-Footnote-121558950
Ref: Python API の変更<7>-Footnote-131559016
Ref: Python API の変更<7>-Footnote-141559076
Ref: Python API の変更<7>-Footnote-151559141
Ref: Python API の変更<7>-Footnote-161559184
Ref: Python API の変更<7>-Footnote-171559244
Ref: Python API の変更<7>-Footnote-181559310
Ref: Python API の変更<7>-Footnote-191559376
Ref: Python API の変更<7>-Footnote-201559442
Node: C API の変更<10>1559507
Ref: whatsnew/3 5 changes-in-the-c-api1559618
Ref: e961559618
Ref: C API の変更<10>-Footnote-11560957
Ref: C API の変更<10>-Footnote-21561022
Ref: C API の変更<10>-Footnote-31561087
Node: Notable changes in Python 3 5 41561129
Ref: whatsnew/3 5 notable-changes-in-python-3-5-41561253
Ref: e9a1561253
Node: New make regen-all build target<2>1561490
Ref: whatsnew/3 5 new-make-regen-all-build-target1561638
Ref: e9b1561638
Ref: New make regen-all build target<2>-Footnote-11562427
Ref: New make regen-all build target<2>-Footnote-21562495
Node: Removal of make touch build target<2>1562560
Ref: whatsnew/3 5 removal-of-make-touch-build-target1562708
Ref: e9c1562708
Ref: Removal of make touch build target<2>-Footnote-11563145
Node: What's New In Python 3 41563210
Ref: whatsnew/3 4 doc1563357
Ref: e9d1563357
Ref: whatsnew/3 4 what-s-new-in-python-3-41563357
Ref: e9e1563357
Ref: What's New In Python 3 4-Footnote-11564225
Ref: What's New In Python 3 4-Footnote-21564284
Node: 概要 -- リリースハイライト<8>1564326
Ref: whatsnew/3 4 summary-release-highlights1564455
Ref: e9f1564455
Ref: 概要 -- リリースハイライト<8>-Footnote-11570033
Ref: 概要 -- リリースハイライト<8>-Footnote-21570075
Ref: 概要 -- リリースハイライト<8>-Footnote-31570117
Ref: 概要 -- リリースハイライト<8>-Footnote-41570182
Ref: 概要 -- リリースハイライト<8>-Footnote-51570224
Ref: 概要 -- リリースハイライト<8>-Footnote-61570289
Ref: 概要 -- リリースハイライト<8>-Footnote-71570331
Ref: 概要 -- リリースハイライト<8>-Footnote-81570373
Ref: 概要 -- リリースハイライト<8>-Footnote-91570415
Ref: 概要 -- リリースハイライト<8>-Footnote-101570457
Ref: 概要 -- リリースハイライト<8>-Footnote-111570500
Ref: 概要 -- リリースハイライト<8>-Footnote-121570543
Ref: 概要 -- リリースハイライト<8>-Footnote-131570586
Ref: 概要 -- リリースハイライト<8>-Footnote-141570629
Ref: 概要 -- リリースハイライト<8>-Footnote-151570672
Ref: 概要 -- リリースハイライト<8>-Footnote-161570737
Ref: 概要 -- リリースハイライト<8>-Footnote-171570803
Ref: 概要 -- リリースハイライト<8>-Footnote-181570846
Ref: 概要 -- リリースハイライト<8>-Footnote-191570889
Ref: 概要 -- リリースハイライト<8>-Footnote-201570955
Ref: 概要 -- リリースハイライト<8>-Footnote-211571001
Ref: 概要 -- リリースハイライト<8>-Footnote-221571044
Ref: 概要 -- リリースハイライト<8>-Footnote-231571087
Ref: 概要 -- リリースハイライト<8>-Footnote-241571153
Ref: 概要 -- リリースハイライト<8>-Footnote-251571196
Node: 新しい機能<11>1571239
Ref: whatsnew/3 4 new-features1571404
Ref: eba1571404
Node: PEP 453 Python インストール時の PIP の明示的なブートストラッピング1571992
Ref: whatsnew/3 4 pep-453-explicit-bootstrapping-of-pip-in-python-installations1572211
Ref: ebb1572211
Ref: whatsnew/3 4 whatsnew-pep-4531572211
Ref: ea01572211
Node: デフォルトでの pip のブートストラッピング1572495
Ref: whatsnew/3 4 bootstrapping-pip-by-default1572716
Ref: ebc1572716
Ref: デフォルトでの pip のブートストラッピング-Footnote-11576562
Ref: デフォルトでの pip のブートストラッピング-Footnote-21576604
Node: ドキュメントの変更1576691
Ref: whatsnew/3 4 documentation-changes1576912
Ref: ebf1576912
Ref: ドキュメントの変更-Footnote-11578063
Ref: ドキュメントの変更-Footnote-21578100
Node: PEP 446 新規作成されたファイル記述子は継承不可1578142
Ref: whatsnew/3 4 pep-446-newly-created-file-descriptors-are-non-inheritable1578391
Ref: ec31578391
Ref: whatsnew/3 4 whatsnew-pep-4461578391
Ref: ea11578391
Ref: PEP 446 新規作成されたファイル記述子は継承不可-Footnote-11579622
Ref: PEP 446 新規作成されたファイル記述子は継承不可-Footnote-21579664
Node: Codec 処理の改良1579706
Ref: whatsnew/3 4 codec-handling-improvements1579928
Ref: ea31579928
Ref: whatsnew/3 4 improvements-to-codec-handling1579928
Ref: ecb1579928
Ref: Codec 処理の改良-Footnote-11585205
Ref: Codec 処理の改良-Footnote-21585283
Ref: Codec 処理の改良-Footnote-31585347
Ref: Codec 処理の改良-Footnote-41585412
Ref: Codec 処理の改良-Footnote-51585477
Node: PEP 451 インポートシステムのための ModuleSpec 型1585542
Ref: whatsnew/3 4 pep-451-a-modulespec-type-for-the-import-system1585726
Ref: ed01585726
Ref: whatsnew/3 4 whatsnew-pep-4511585726
Ref: ea41585726
Ref: PEP 451 インポートシステムのための ModuleSpec 型-Footnote-11586938
Ref: PEP 451 インポートシステムのための ModuleSpec 型-Footnote-21586980
Node: その他の言語変更<8>1587060
Ref: whatsnew/3 4 other-language-changes1587214
Ref: ed21587214
Ref: その他の言語変更<8>-Footnote-11590571
Ref: その他の言語変更<8>-Footnote-21590636
Ref: その他の言語変更<8>-Footnote-31590701
Ref: その他の言語変更<8>-Footnote-41590766
Ref: その他の言語変更<8>-Footnote-51590833
Ref: その他の言語変更<8>-Footnote-61590898
Ref: その他の言語変更<8>-Footnote-71590963
Ref: その他の言語変更<8>-Footnote-81591028
Ref: その他の言語変更<8>-Footnote-91591093
Ref: その他の言語変更<8>-Footnote-101591158
Ref: その他の言語変更<8>-Footnote-111591224
Ref: その他の言語変更<8>-Footnote-121591290
Ref: その他の言語変更<8>-Footnote-131591333
Node: 新たなモジュール<8>1591399
Ref: whatsnew/3 4 new-modules1591557
Ref: ed81591557
Node: asyncio<11>1591803
Ref: whatsnew/3 4 asyncio1591899
Ref: ed91591899
Ref: whatsnew/3 4 whatsnew-asyncio1591899
Ref: ea61591899
Ref: asyncio<11>-Footnote-11592808
Ref: asyncio<11>-Footnote-21592850
Ref: asyncio<11>-Footnote-31592892
Node: ensurepip<2>1592934
Ref: whatsnew/3 4 ensurepip1593046
Ref: eda1593046
Ref: whatsnew/3 4 whatsnew-ensurepip1593046
Ref: ea71593046
Ref: ensurepip<2>-Footnote-11594817
Node: enum<8>1594859
Ref: whatsnew/3 4 enum1594971
Ref: edb1594971
Ref: whatsnew/3 4 whatsnew-enum1594971
Ref: ea81594971
Ref: enum<8>-Footnote-11595649
Ref: enum<8>-Footnote-21595691
Node: pathlib<11>1595733
Ref: whatsnew/3 4 pathlib1595845
Ref: edc1595845
Ref: whatsnew/3 4 whatsnew-pathlib1595845
Ref: ea91595845
Ref: pathlib<11>-Footnote-11596650
Node: selectors<2>1596692
Ref: whatsnew/3 4 selectors1596810
Ref: edd1596810
Ref: whatsnew/3 4 whatsnew-selectors1596810
Ref: eaa1596810
Ref: selectors<2>-Footnote-11597138
Node: statistics<6>1597180
Ref: whatsnew/3 4 statistics1597301
Ref: ede1597301
Ref: whatsnew/3 4 whatsnew-statistics1597301
Ref: eab1597301
Ref: statistics<6>-Footnote-11597813
Ref: statistics<6>-Footnote-21597855
Node: tracemalloc<4>1597897
Ref: whatsnew/3 4 tracemalloc1597997
Ref: edf1597997
Ref: whatsnew/3 4 whatsnew-tracemalloc1597997
Ref: eac1597997
Ref: tracemalloc<4>-Footnote-11598878
Ref: tracemalloc<4>-Footnote-21598920
Node: 改良されたモジュール<8>1598962
Ref: whatsnew/3 4 improved-modules1599127
Ref: ee01599127
Node: abc1600493
Ref: whatsnew/3 4 abc1600582
Ref: ee11600582
Ref: abc-Footnote-11601292
Ref: abc-Footnote-21601357
Node: aifc<2>1601422
Ref: whatsnew/3 4 aifc1601531
Ref: ee51601531
Ref: aifc<2>-Footnote-11602141
Ref: aifc<2>-Footnote-21602206
Ref: aifc<2>-Footnote-31602271
Node: argparse<5>1602335
Ref: whatsnew/3 4 argparse1602448
Ref: ee61602448
Ref: argparse<5>-Footnote-11602749
Node: audioop1602814
Ref: whatsnew/3 4 audioop1602929
Ref: ee81602929
Ref: audioop-Footnote-11603453
Ref: audioop-Footnote-21603518
Ref: audioop-Footnote-31603583
Node: base64<3>1603648
Ref: whatsnew/3 4 base641603766
Ref: ee91603766
Ref: base64<3>-Footnote-11604756
Ref: base64<3>-Footnote-21604821
Node: collections<6>1604886
Ref: whatsnew/3 4 collections1605005
Ref: eee1605005
Ref: collections<6>-Footnote-11605451
Node: colorsys1605516
Ref: whatsnew/3 4 colorsys1605639
Ref: ef01605639
Ref: colorsys-Footnote-11606013
Ref: colorsys-Footnote-21606084
Node: contextlib<6>1606149
Ref: whatsnew/3 4 contextlib1606264
Ref: ef11606264
Ref: contextlib<6>-Footnote-11607936
Ref: contextlib<6>-Footnote-21608001
Ref: contextlib<6>-Footnote-31608066
Node: dbm<6>1608131
Ref: whatsnew/3 4 dbm1608244
Ref: ef51608244
Ref: dbm<6>-Footnote-11608657
Node: dis<4>1608722
Ref: whatsnew/3 4 dis1608832
Ref: ef71608832
Ref: dis<4>-Footnote-11612368
Ref: dis<4>-Footnote-21612433
Ref: dis<4>-Footnote-31612498
Ref: dis<4>-Footnote-41612563
Node: doctest<4>1612643
Ref: whatsnew/3 4 doctest1612755
Ref: efe1612755
Ref: doctest<4>-Footnote-11613780
Ref: doctest<4>-Footnote-21613845
Ref: doctest<4>-Footnote-31613910
Node: email<4>1613974
Ref: whatsnew/3 4 email1614087
Ref: f021614087
Ref: whatsnew/3 4 whatsnew-email-contentmanager1615552
Ref: eb01615552
Ref: email<4>-Footnote-11616738
Ref: email<4>-Footnote-21616803
Ref: email<4>-Footnote-31616868
Ref: email<4>-Footnote-41616933
Node: filecmp1616998
Ref: whatsnew/3 4 filecmp1617113
Ref: f0a1617113
Ref: filecmp-Footnote-11617894
Ref: filecmp-Footnote-21617959
Node: functools<5>1618024
Ref: whatsnew/3 4 functools1618136
Ref: f0e1618136
Ref: whatsnew/3 4 whatsnew-singledispatch1618698
Ref: ead1618698
Ref: functools<5>-Footnote-11620238
Ref: functools<5>-Footnote-21620302
Ref: functools<5>-Footnote-31620344
Ref: functools<5>-Footnote-41620409
Node: gc<5>1620474
Ref: whatsnew/3 4 gc1620586
Ref: f101620586
Ref: gc<5>-Footnote-11620877
Node: glob<4>1620942
Ref: whatsnew/3 4 glob1621052
Ref: f121621052
Ref: glob<4>-Footnote-11621394
Node: hashlib<6>1621458
Ref: whatsnew/3 4 hashlib1621570
Ref: f141621570
Ref: hashlib<6>-Footnote-11622411
Ref: hashlib<6>-Footnote-21622456
Ref: hashlib<6>-Footnote-31622521
Node: hmac<3>1622586
Ref: whatsnew/3 4 hmac1622695
Ref: f161622695
Ref: hmac<3>-Footnote-11623953
Ref: hmac<3>-Footnote-21624018
Ref: hmac<3>-Footnote-31624083
Ref: hmac<3>-Footnote-41624125
Node: html1624190
Ref: whatsnew/3 4 html1624296
Ref: f1b1624296
Ref: html-Footnote-11625181
Ref: html-Footnote-21625245
Ref: html-Footnote-31625310
Node: http<3>1625375
Ref: whatsnew/3 4 http1625493
Ref: f1c1625493
Ref: http<3>-Footnote-11626797
Ref: http<3>-Footnote-21626862
Node: idlelib と IDLE<4>1626927
Ref: whatsnew/3 4 idlelib-and-idle1627053
Ref: f1f1627053
Node: importlib<9>1627585
Ref: whatsnew/3 4 importlib1627714
Ref: f201627714
Ref: importlib<9>-Footnote-11630104
Ref: importlib<9>-Footnote-21630169
Ref: importlib<9>-Footnote-31630234
Ref: importlib<9>-Footnote-41630299
Ref: importlib<9>-Footnote-51630364
Ref: importlib<9>-Footnote-61630429
Ref: importlib<9>-Footnote-71630494
Ref: importlib<9>-Footnote-81630536
Node: inspect<8>1630601
Ref: whatsnew/3 4 inspect1630723
Ref: f271630723
Ref: inspect<8>-Footnote-11633608
Ref: inspect<8>-Footnote-21633673
Ref: inspect<8>-Footnote-31633738
Ref: inspect<8>-Footnote-41633803
Ref: inspect<8>-Footnote-51633868
Ref: inspect<8>-Footnote-61633933
Ref: inspect<8>-Footnote-71633998
Node: ipaddress<5>1634076
Ref: whatsnew/3 4 ipaddress1634196
Ref: f2b1634196
Ref: ipaddress<5>-Footnote-11634978
Node: logging<6>1635043
Ref: whatsnew/3 4 logging1635163
Ref: f2d1635163
Ref: logging<6>-Footnote-11636502
Ref: logging<6>-Footnote-21636566
Ref: logging<6>-Footnote-31636621
Ref: logging<6>-Footnote-41636686
Node: marshal<2>1636751
Ref: whatsnew/3 4 marshal1636866
Ref: f331636866
Ref: whatsnew/3 4 whatsnew-marshal-31636866
Ref: ea51636866
Ref: marshal<2>-Footnote-11637732
Ref: marshal<2>-Footnote-21637797
Node: mmap<3>1637862
Ref: whatsnew/3 4 mmap1637985
Ref: f341637985
Ref: mmap<3>-Footnote-11638157
Node: multiprocessing<7>1638221
Ref: whatsnew/3 4 multiprocessing1638345
Ref: f351638345
Ref: whatsnew/3 4 whatsnew-multiprocessing-no-fork1638398
Ref: eaf1638398
Ref: multiprocessing<7>-Footnote-11640776
Ref: multiprocessing<7>-Footnote-21640840
Ref: multiprocessing<7>-Footnote-31640905
Ref: multiprocessing<7>-Footnote-41640969
Node: operator<3>1641034
Ref: whatsnew/3 4 operator1641157
Ref: f391641157
Ref: operator<3>-Footnote-11641766
Ref: operator<3>-Footnote-21641808
Ref: operator<3>-Footnote-31641873
Node: os<11>1641938
Ref: whatsnew/3 4 os1642049
Ref: f3b1642049
Ref: os<11>-Footnote-11643739
Ref: os<11>-Footnote-21643804
Ref: os<11>-Footnote-31643869
Ref: os<11>-Footnote-41643933
Node: pdb<6>1643998
Ref: whatsnew/3 4 pdb1644107
Ref: f411644107
Ref: pdb<6>-Footnote-11645426
Ref: pdb<6>-Footnote-21645491
Node: pickle<4>1645556
Ref: whatsnew/3 4 pickle1645670
Ref: f441645670
Ref: whatsnew/3 4 whatsnew-protocol-41645670
Ref: eae1645670
Ref: pickle<4>-Footnote-11646393
Node: plistlib<2>1646435
Ref: whatsnew/3 4 plistlib1646552
Ref: f451646552
Ref: plistlib<2>-Footnote-11647088
Node: poplib<3>1647153
Ref: whatsnew/3 4 poplib1647270
Ref: f481647270
Ref: poplib<3>-Footnote-11647724
Node: pprint<4>1647788
Ref: whatsnew/3 4 pprint1647897
Ref: f4b1647897
Ref: pprint<4>-Footnote-11648631
Ref: pprint<4>-Footnote-21648696
Node: pty1648761
Ref: whatsnew/3 4 pty1648869
Ref: f4e1648869
Node: pydoc<4>1649100
Ref: whatsnew/3 4 pydoc1649204
Ref: f501649204
Ref: pydoc<4>-Footnote-11650479
Ref: pydoc<4>-Footnote-21650544
Node: re<8>1650609
Ref: whatsnew/3 4 re1650718
Ref: f511650718
Ref: re<8>-Footnote-11651648
Ref: re<8>-Footnote-21651713
Ref: re<8>-Footnote-31651778
Node: resource1651843
Ref: whatsnew/3 4 resource1651950
Ref: f551651950
Ref: resource-Footnote-11652845
Ref: resource-Footnote-21652910
Ref: resource-Footnote-31652975
Node: select1653040
Ref: whatsnew/3 4 select1653151
Ref: f5f1653151
Ref: select-Footnote-11653756
Ref: select-Footnote-21653821
Node: shelve<2>1653886
Ref: whatsnew/3 4 shelve1653998
Ref: f661653998
Ref: shelve<2>-Footnote-11654335
Node: shutil<6>1654400
Ref: whatsnew/3 4 shutil1654514
Ref: f681654514
Ref: shutil<6>-Footnote-11655001
Node: smtpd<3>1655068
Ref: whatsnew/3 4 smtpd1655183
Ref: f6b1655183
Ref: smtpd<3>-Footnote-11655543
Node: smtplib<3>1655608
Ref: whatsnew/3 4 smtplib1655723
Ref: f6c1655723
Ref: smtplib<3>-Footnote-11656208
Node: socket<9>1656272
Ref: whatsnew/3 4 socket1656389
Ref: f6e1656389
Ref: socket<9>-Footnote-11657321
Ref: socket<9>-Footnote-21657386
Node: sqlite3<9>1657450
Ref: whatsnew/3 4 sqlite31657564
Ref: f721657564
Ref: sqlite3<9>-Footnote-11657966
Ref: sqlite3<9>-Footnote-21658006
Node: ssl<10>1658071
Ref: whatsnew/3 4 ssl1658180
Ref: f731658180
Ref: whatsnew/3 4 whatsnew-tls-11-121658209
Ref: eb21658209
Ref: whatsnew/3 4 whatsnew34-sslcontext1658537
Ref: eb51658537
Ref: whatsnew/3 4 whatsnew34-win-cert-store1661798
Ref: eb31661798
Ref: whatsnew/3 4 whatsnew34-sni1662150
Ref: eb41662150
Ref: ssl<10>-Footnote-11662643
Ref: ssl<10>-Footnote-21662708
Ref: ssl<10>-Footnote-31662773
Ref: ssl<10>-Footnote-41662838
Ref: ssl<10>-Footnote-51662903
Ref: ssl<10>-Footnote-61662968
Ref: ssl<10>-Footnote-71663032
Ref: ssl<10>-Footnote-81663097
Ref: ssl<10>-Footnote-91663162
Ref: ssl<10>-Footnote-101663226
Node: stat1663292
Ref: whatsnew/3 4 stat1663400
Ref: f851663400
Ref: stat-Footnote-11663871
Ref: stat-Footnote-21663936
Node: struct<2>1664001
Ref: whatsnew/3 4 struct1664115
Ref: f8a1664115
Ref: struct<2>-Footnote-11664548
Node: subprocess<5>1664613
Ref: whatsnew/3 4 subprocess1664731
Ref: f8d1664731
Ref: subprocess<5>-Footnote-11665362
Ref: subprocess<5>-Footnote-21665427
Node: sunau<2>1665492
Ref: whatsnew/3 4 sunau1665608
Ref: f901665608
Ref: sunau<2>-Footnote-11666437
Ref: sunau<2>-Footnote-21666502
Ref: sunau<2>-Footnote-31666567
Ref: sunau<2>-Footnote-41666632
Node: sys<12>1666696
Ref: whatsnew/3 4 sys1666809
Ref: f911666809
Ref: sys<12>-Footnote-11668449
Ref: sys<12>-Footnote-21668514
Node: tarfile<7>1668578
Ref: whatsnew/3 4 tarfile1668691
Ref: f971668691
Ref: tarfile<7>-Footnote-11669111
Node: textwrap1669176
Ref: whatsnew/3 4 textwrap1669294
Ref: f991669294
Ref: textwrap-Footnote-11670168
Ref: textwrap-Footnote-21670233
Node: threading<7>1670298
Ref: whatsnew/3 4 threading1670418
Ref: f9e1670418
Ref: threading<7>-Footnote-11670815
Node: traceback<6>1670880
Ref: whatsnew/3 4 traceback1671000
Ref: fa01671000
Ref: traceback<6>-Footnote-11671390
Node: types<6>1671457
Ref: whatsnew/3 4 types1671574
Ref: fa21671574
Ref: types<6>-Footnote-11672244
Node: urllib<3>1672309
Ref: whatsnew/3 4 urllib1672425
Ref: fa31672425
Ref: urllib<3>-Footnote-11674174
Ref: urllib<3>-Footnote-21674239
Ref: urllib<3>-Footnote-31674304
Ref: urllib<3>-Footnote-41674369
Ref: urllib<3>-Footnote-51674434
Ref: urllib<3>-Footnote-61674499
Node: unittest<9>1674564
Ref: whatsnew/3 4 unittest1674679
Ref: fad1674679
Ref: unittest<9>-Footnote-11678738
Ref: unittest<9>-Footnote-21678803
Ref: unittest<9>-Footnote-31678868
Ref: unittest<9>-Footnote-41678933
Ref: unittest<9>-Footnote-51678998
Ref: unittest<9>-Footnote-61679063
Ref: unittest<9>-Footnote-71679128
Ref: unittest<9>-Footnote-81679193
Ref: unittest<9>-Footnote-91679258
Node: venv<7>1679323
Ref: whatsnew/3 4 venv1679436
Ref: fb41679436
Ref: venv<7>-Footnote-11680108
Ref: venv<7>-Footnote-21680173
Ref: venv<7>-Footnote-31680238
Node: wave<2>1680280
Ref: whatsnew/3 4 wave1680392
Ref: fb51680392
Ref: wave<2>-Footnote-11681221
Ref: wave<2>-Footnote-21681286
Ref: wave<2>-Footnote-31681351
Ref: wave<2>-Footnote-41681415
Node: weakref<2>1681479
Ref: whatsnew/3 4 weakref1681596
Ref: fb91681596
Ref: weakref<2>-Footnote-11682376
Ref: weakref<2>-Footnote-21682441
Ref: weakref<2>-Footnote-31682506
Node: xml etree<2>1682571
Ref: whatsnew/3 4 xml-etree1682691
Ref: fbd1682691
Ref: xml etree<2>-Footnote-11683589
Ref: xml etree<2>-Footnote-21683654
Node: zipfile<5>1683719
Ref: whatsnew/3 4 zipfile1683820
Ref: fc31683820
Ref: zipfile<5>-Footnote-11684537
Ref: zipfile<5>-Footnote-21684602
Node: CPython の実装の変更1684667
Ref: whatsnew/3 4 cpython-implementation-changes1684817
Ref: fc61684817
Node: PEP 445 CPython のメモリアロケータのカスタマイズ1685489
Ref: whatsnew/3 4 pep-445-customization-of-cpython-memory-allocators1685696
Ref: fc71685696
Ref: whatsnew/3 4 whatsnew-pep-4451685696
Ref: eb81685696
Ref: PEP 445 CPython のメモリアロケータのカスタマイズ-Footnote-11686207
Ref: PEP 445 CPython のメモリアロケータのカスタマイズ-Footnote-21686249
Node: PEP 442 オブジェクトの安全なファイナライゼーション1686291
Ref: whatsnew/3 4 pep-442-safe-object-finalization1686575
Ref: fc81686575
Ref: whatsnew/3 4 whatsnew-pep-4421686575
Ref: eb71686575
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-11688132
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-21688174
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-31688239
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-41688304
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-51688359
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-61688424
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-71688490
Ref: PEP 442 オブジェクトの安全なファイナライゼーション-Footnote-81688546
Node: PEP 456 安全で取り換え可能なハッシュアルゴリズム1688588
Ref: whatsnew/3 4 pep-456-secure-and-interchangeable-hash-algorithm1688831
Ref: fc91688831
Ref: whatsnew/3 4 whatsnew-pep-4561688831
Ref: eb11688831
Ref: PEP 456 安全で取り換え可能なハッシュアルゴリズム-Footnote-11690077
Ref: PEP 456 安全で取り換え可能なハッシュアルゴリズム-Footnote-21690119
Node: PEP 436 Argument Clinic1690184
Ref: whatsnew/3 4 pep-436-argument-clinic1690402
Ref: fcb1690402
Ref: whatsnew/3 4 whatsnew-pep-4361690402
Ref: eb91690402
Ref: PEP 436 Argument Clinic-Footnote-11691928
Ref: PEP 436 Argument Clinic-Footnote-21691970
Node: その他のビルド並びに C API の変更1692012
Ref: whatsnew/3 4 other-build-and-c-api-changes1692183
Ref: fcc1692183
Ref: その他のビルド並びに C API の変更-Footnote-11694743
Ref: その他のビルド並びに C API の変更-Footnote-21694808
Ref: その他のビルド並びに C API の変更-Footnote-31694850
Ref: その他のビルド並びに C API の変更-Footnote-41694915
Ref: その他のビルド並びに C API の変更-Footnote-51694982
Ref: その他のビルド並びに C API の変更-Footnote-61695046
Ref: その他のビルド並びに C API の変更-Footnote-71695111
Ref: その他のビルド並びに C API の変更-Footnote-81695184
Ref: その他のビルド並びに C API の変更-Footnote-91695248
Ref: その他のビルド並びに C API の変更-Footnote-101695313
Node: その他の改善<2>1695379
Ref: whatsnew/3 4 other-improvements1695545
Ref: fd01695545
Ref: whatsnew/3 4 other-improvements-3-41695545
Ref: fd11695545
Ref: whatsnew/3 4 whatsnew-isolated-mode1695596
Ref: ea21695596
Ref: その他の改善<2>-Footnote-11700651
Ref: その他の改善<2>-Footnote-21700716
Ref: その他の改善<2>-Footnote-31700780
Ref: その他の改善<2>-Footnote-41700845
Ref: その他の改善<2>-Footnote-51700910
Ref: その他の改善<2>-Footnote-61700975
Ref: その他の改善<2>-Footnote-71701040
Ref: その他の改善<2>-Footnote-81701135
Ref: その他の改善<2>-Footnote-91701186
Ref: その他の改善<2>-Footnote-101701251
Ref: その他の改善<2>-Footnote-111701317
Ref: その他の改善<2>-Footnote-121701371
Ref: その他の改善<2>-Footnote-131701437
Ref: その他の改善<2>-Footnote-141701503
Ref: その他の改善<2>-Footnote-151701546
Ref: その他の改善<2>-Footnote-161701612
Ref: その他の改善<2>-Footnote-171701678
Ref: その他の改善<2>-Footnote-181701744
Ref: その他の改善<2>-Footnote-191701810
Ref: その他の改善<2>-Footnote-201701853
Ref: その他の改善<2>-Footnote-211701919
Ref: その他の改善<2>-Footnote-221701985
Ref: その他の改善<2>-Footnote-231702051
Node: 大幅な最適化1702117
Ref: whatsnew/3 4 significant-optimizations1702228
Ref: fd61702228
Ref: 大幅な最適化-Footnote-11705722
Ref: 大幅な最適化-Footnote-21705787
Ref: 大幅な最適化-Footnote-31705852
Ref: 大幅な最適化-Footnote-41705917
Ref: 大幅な最適化-Footnote-51705982
Ref: 大幅な最適化-Footnote-61706047
Ref: 大幅な最適化-Footnote-71706112
Ref: 大幅な最適化-Footnote-81706176
Ref: 大幅な最適化-Footnote-91706241
Ref: 大幅な最適化-Footnote-101706306
Ref: 大幅な最適化-Footnote-111706372
Ref: 大幅な最適化-Footnote-121706438
Ref: 大幅な最適化-Footnote-131706504
Node: 非推奨<9>1706570
Ref: whatsnew/3 4 deprecated1706696
Ref: fda1706696
Ref: whatsnew/3 4 deprecated-3-41706696
Ref: ed11706696
Node: Python API の非推奨項目1707234
Ref: whatsnew/3 4 deprecations-in-the-python-api1707339
Ref: fdb1707339
Node: 非推奨の機能1711662
Ref: whatsnew/3 4 deprecated-features1711767
Ref: fdf1711767
Ref: 非推奨の機能-Footnote-11712294
Ref: 非推奨の機能-Footnote-21712359
Node: 削除<9>1712424
Ref: whatsnew/3 4 removed1712547
Ref: fe11712547
Node: サポートされなくなったオペレーティングシステム1712734
Ref: whatsnew/3 4 operating-systems-no-longer-supported1712883
Ref: fe21712883
Ref: サポートされなくなったオペレーティングシステム-Footnote-11713346
Ref: サポートされなくなったオペレーティングシステム-Footnote-21713411
Ref: サポートされなくなったオペレーティングシステム-Footnote-31713466
Ref: サポートされなくなったオペレーティングシステム-Footnote-41713531
Node: API と機能の削除<5>1713596
Ref: whatsnew/3 4 api-and-feature-removals1713772
Ref: fe31713772
Ref: API と機能の削除<5>-Footnote-11717742
Ref: API と機能の削除<5>-Footnote-21717778
Ref: API と機能の削除<5>-Footnote-31717836
Ref: API と機能の削除<5>-Footnote-41717887
Ref: API と機能の削除<5>-Footnote-51717952
Ref: API と機能の削除<5>-Footnote-61718017
Ref: API と機能の削除<5>-Footnote-71718082
Ref: API と機能の削除<5>-Footnote-81718147
Ref: API と機能の削除<5>-Footnote-91718211
Node: コードの整理1718276
Ref: whatsnew/3 4 code-cleanups1718374
Ref: fe51718374
Ref: コードの整理-Footnote-11719190
Node: Python 3 4 への移植1719255
Ref: whatsnew/3 4 porting-to-python-3-41719381
Ref: fe61719381
Node: 'python' コマンドの挙動の変更<2>1719774
Ref: whatsnew/3 4 changes-in-python-command-behavior1719908
Ref: fe71719908
Ref: 'python' コマンドの挙動の変更<2>-Footnote-11721347
Node: Python API の変更<8>1721412
Ref: whatsnew/3 4 changes-in-the-python-api1721574
Ref: ed61721574
Ref: Python API の変更<8>-Footnote-11739286
Ref: Python API の変更<8>-Footnote-21739351
Ref: Python API の変更<8>-Footnote-31739416
Ref: Python API の変更<8>-Footnote-41739481
Ref: Python API の変更<8>-Footnote-51739536
Ref: Python API の変更<8>-Footnote-61739601
Ref: Python API の変更<8>-Footnote-71739666
Ref: Python API の変更<8>-Footnote-81739731
Ref: Python API の変更<8>-Footnote-91739796
Ref: Python API の変更<8>-Footnote-101739861
Ref: Python API の変更<8>-Footnote-111739926
Ref: Python API の変更<8>-Footnote-121739992
Ref: Python API の変更<8>-Footnote-131740058
Ref: Python API の変更<8>-Footnote-141740124
Ref: Python API の変更<8>-Footnote-151740190
Ref: Python API の変更<8>-Footnote-161740256
Ref: Python API の変更<8>-Footnote-171740322
Ref: Python API の変更<8>-Footnote-181740388
Ref: Python API の変更<8>-Footnote-191740454
Ref: Python API の変更<8>-Footnote-201740520
Ref: Python API の変更<8>-Footnote-211740586
Ref: Python API の変更<8>-Footnote-221740652
Ref: Python API の変更<8>-Footnote-231740718
Ref: Python API の変更<8>-Footnote-241740784
Ref: Python API の変更<8>-Footnote-251740850
Ref: Python API の変更<8>-Footnote-261740915
Node: C API の変更<11>1740981
Ref: whatsnew/3 4 changes-in-the-c-api1741092
Ref: ff71741092
Ref: C API の変更<11>-Footnote-11743237
Ref: C API の変更<11>-Footnote-21743302
Node: 3 4 3 の変更1743367
Ref: whatsnew/3 4 changed-in-3-4-31743475
Ref: ffd1743475
Node: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化1743738
Ref: whatsnew/3 4 pep-4761743891
Ref: ffe1743891
Ref: whatsnew/3 4 pep-476-enabling-certificate-verification-by-default-for-stdlib-http-clients1743891
Ref: fff1743891
Node: What's New In Python 3 31745108
Ref: whatsnew/3 3 doc1745255
Ref: 10001745255
Ref: whatsnew/3 3 what-s-new-in-python-3-31745255
Ref: 10011745255
Ref: What's New In Python 3 3-Footnote-11747465
Ref: What's New In Python 3 3-Footnote-21747524
Node: 概要 -- リリースハイライト<9>1747566
Ref: whatsnew/3 3 summary-release-highlights1747696
Ref: 10021747696
Node: PEP 405 仮想環境1749280
Ref: whatsnew/3 3 pep-4051749466
Ref: 10041749466
Ref: whatsnew/3 3 pep-405-virtual-environments1749466
Ref: 100c1749466
Ref: PEP 405 仮想環境-Footnote-11750669
Node: PEP 420 暗黙的な名前空間パッケージ1750711
Ref: whatsnew/3 3 pep-420-implicit-namespace-packages1750953
Ref: 100d1750953
Ref: PEP 420 暗黙的な名前空間パッケージ-Footnote-11751537
Ref: PEP 420 暗黙的な名前空間パッケージ-Footnote-21751579
Node: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント1751621
Ref: whatsnew/3 3 pep-3118-new-memoryview-implementation-and-buffer-protocol-documentation1751878
Ref: 100e1751878
Ref: whatsnew/3 3 pep-3118-update1751878
Ref: 100f1751878
Ref: PEP 3118 新たなメモリビューの実装とバッファプロトコルのドキュメント-Footnote-11753511
Node: フィーチャー1753553
Ref: whatsnew/3 3 features1753726
Ref: 10121753726
Ref: フィーチャー-Footnote-11754886
Node: API の変更1754951
Ref: whatsnew/3 3 api-changes1755124
Ref: 10171755124
Ref: API の変更-Footnote-11756564
Ref: API の変更-Footnote-21756629
Node: PEP 393 文字列の柔軟な表現1756671
Ref: whatsnew/3 3 pep-3931756920
Ref: 10071756920
Ref: whatsnew/3 3 pep-393-flexible-string-representation1756920
Ref: 101e1756920
Ref: PEP 393 文字列の柔軟な表現-Footnote-11758372
Node: 機能性1758414
Ref: whatsnew/3 3 functionality1758540
Ref: 101f1758540
Ref: 機能性-Footnote-11760437
Ref: 機能性-Footnote-21760479
Node: 性能およびリソース使用量1760544
Ref: whatsnew/3 3 performance-and-resource-usage1760670
Ref: 10211760670
Ref: 性能およびリソース使用量-Footnote-11762463
Node: PEP 397 Windows の Python ランチャ1762505
Ref: whatsnew/3 3 pep-3971762707
Ref: 10221762707
Ref: whatsnew/3 3 pep-397-python-launcher-for-windows1762707
Ref: 10231762707
Ref: PEP 397 Windows の Python ランチャ-Footnote-11764782
Ref: PEP 397 Windows の Python ランチャ-Footnote-21764846
Node: PEP 3151 OS および IO 例外階層の手直し1764888
Ref: whatsnew/3 3 pep-31511765105
Ref: 10051765105
Ref: whatsnew/3 3 pep-3151-reworking-the-os-and-io-exception-hierarchy1765105
Ref: 10251765105
Ref: PEP 3151 OS および IO 例外階層の手直し-Footnote-11767866
Node: PEP 380 サブジェネレータへの委譲構文1767908
Ref: whatsnew/3 3 pep-3801768127
Ref: 10031768127
Ref: whatsnew/3 3 pep-380-syntax-for-delegating-to-a-subgenerator1768127
Ref: 10341768127
Ref: PEP 380 サブジェネレータへの委譲構文-Footnote-11771052
Node: PEP 409 例外コンテキストの抑制1771094
Ref: whatsnew/3 3 pep-409-suppressing-exception-context1771311
Ref: 10371771311
Ref: PEP 409 例外コンテキストの抑制-Footnote-11773638
Node: PEP 414 明示的なユニコードリテラル1773680
Ref: whatsnew/3 3 pep-414-explicit-unicode-literals1773886
Ref: 10381773886
Ref: PEP 414 明示的なユニコードリテラル-Footnote-11774773
Node: PEP 3155 クラスと関数の正規名1774815
Ref: whatsnew/3 3 pep-3155-qualified-name-for-classes-and-functions1775006
Ref: 10391775006
Ref: PEP 3155 クラスと関数の正規名-Footnote-11776634
Node: PEP 412 キー共有辞書1776676
Ref: whatsnew/3 3 pep-4121776867
Ref: 10081776867
Ref: whatsnew/3 3 pep-412-key-sharing-dictionary1776867
Ref: 103c1776867
Ref: PEP 412 キー共有辞書-Footnote-11777412
Node: PEP 362 関数シグニチャオブジェクト1777454
Ref: whatsnew/3 3 pep-362-function-signature-object1777642
Ref: 103d1777642
Ref: PEP 362 関数シグニチャオブジェクト-Footnote-11778867
Node: PEP 421 sys implementation の追加1778909
Ref: whatsnew/3 3 pep-421-adding-sys-implementation1779124
Ref: 103f1779124
Ref: PEP 421 sys implementation の追加-Footnote-11780677
Node: SimpleNamespace1780719
Ref: whatsnew/3 3 simplenamespace1780807
Ref: 10401780807
Ref: SimpleNamespace-Footnote-11781556
Node: インポート実装としての importlib の使用1781598
Ref: whatsnew/3 3 importlib1781793
Ref: 10061781793
Ref: whatsnew/3 3 using-importlib-as-the-implementation-of-import1781793
Ref: 10411781793
Ref: インポート実装としての importlib の使用-Footnote-11783386
Ref: インポート実装としての importlib の使用-Footnote-21783450
Ref: インポート実装としての importlib の使用-Footnote-31783515
Ref: インポート実装としての importlib の使用-Footnote-41783580
Ref: インポート実装としての importlib の使用-Footnote-51783645
Node: 新たな API1783687
Ref: whatsnew/3 3 new-apis1783820
Ref: 10441783820
Node: 目に見える変化1786063
Ref: whatsnew/3 3 visible-changes1786196
Ref: 104b1786196
Ref: 目に見える変化-Footnote-11788811
Ref: 目に見える変化-Footnote-21788853
Node: その他の言語変更<9>1788895
Ref: whatsnew/3 3 other-language-changes1789090
Ref: 104c1789090
Ref: その他の言語変更<9>-Footnote-11791650
Ref: その他の言語変更<9>-Footnote-21791715
Ref: その他の言語変更<9>-Footnote-31791780
Ref: その他の言語変更<9>-Footnote-41791845
Ref: その他の言語変更<9>-Footnote-51791910
Ref: その他の言語変更<9>-Footnote-61791975
Ref: その他の言語変更<9>-Footnote-71792040
Ref: その他の言語変更<9>-Footnote-81792105
Node: 細粒度のインポートロック1792170
Ref: whatsnew/3 3 a-finer-grained-import-lock1792339
Ref: 104f1792339
Ref: 細粒度のインポートロック-Footnote-11793440
Node: 組み込みの関数と型1793504
Ref: whatsnew/3 3 builtin-functions-and-types1793673
Ref: 10501793673
Ref: 組み込みの関数と型-Footnote-11795248
Node: 新たなモジュール<9>1795312
Ref: whatsnew/3 3 new-modules1795478
Ref: 10531795478
Node: faulthandler<4>1795624
Ref: whatsnew/3 3 faulthandler1795724
Ref: 10541795724
Node: ipaddress<6>1796931
Ref: whatsnew/3 3 ipaddress1797047
Ref: 10561797047
Ref: ipaddress<6>-Footnote-11797503
Node: lzma<2>1797545
Ref: whatsnew/3 3 lzma1797637
Ref: 10571797637
Ref: lzma<2>-Footnote-11797951
Node: 改良されたモジュール<9>1798015
Ref: whatsnew/3 3 improved-modules1798166
Ref: 10581798166
Node: abc<2>1799519
Ref: whatsnew/3 3 abc1799612
Ref: 10591799612
Ref: abc<2>-Footnote-11800967
Ref: abc<2>-Footnote-21801032
Node: array<5>1801097
Ref: whatsnew/3 3 array1801208
Ref: 105f1801208
Ref: array<5>-Footnote-11801442
Node: base64<4>1801509
Ref: whatsnew/3 3 base641801625
Ref: 10601801625
Ref: base64<4>-Footnote-11802033
Node: binascii<3>1802098
Ref: whatsnew/3 3 binascii1802212
Ref: 10611802212
Ref: binascii<3>-Footnote-11802521
Node: bz2<2>1802586
Ref: whatsnew/3 3 bz21802700
Ref: 10621802700
Ref: bz2<2>-Footnote-11803965
Ref: bz2<2>-Footnote-21804029
Node: codecs<2>1804093
Ref: whatsnew/3 3 codecs1804210
Ref: 10651804210
Ref: codecs<2>-Footnote-11806018
Ref: codecs<2>-Footnote-21806083
Ref: codecs<2>-Footnote-31806148
Node: collections<7>1806213
Ref: whatsnew/3 3 collections1806337
Ref: 10661806337
Ref: collections<7>-Footnote-11807286
Ref: collections<7>-Footnote-21807351
Ref: collections<7>-Footnote-31807416
Ref: collections<7>-Footnote-41807481
Node: contextlib<7>1807546
Ref: whatsnew/3 3 contextlib1807669
Ref: 10681807669
Ref: contextlib<7>-Footnote-11808489
Node: crypt<2>1808554
Ref: whatsnew/3 3 crypt1808672
Ref: 10691808672
Ref: crypt<2>-Footnote-11808876
Node: curses<5>1808941
Ref: whatsnew/3 3 curses1809057
Ref: 106a1809057
Ref: curses<5>-Footnote-11810607
Ref: curses<5>-Footnote-21810672
Ref: curses<5>-Footnote-31810736
Node: datetime<6>1810801
Ref: whatsnew/3 3 datetime1810919
Ref: 106e1810919
Ref: datetime<6>-Footnote-11811880
Node: decimal<3>1811945
Ref: whatsnew/3 3 decimal1812062
Ref: 10701812062
Ref: whatsnew/3 3 new-decimal1812062
Ref: 10091812062
Ref: decimal<3>-Footnote-11813815
Node: フィーチャー<2>1813879
Ref: whatsnew/3 3 id11813972
Ref: 10711813972
Node: API の変更<2>1814517
Ref: whatsnew/3 3 id21814610
Ref: 10761814610
Node: email<5>1817917
Ref: whatsnew/3 3 email1818032
Ref: 10811818032
Ref: whatsnew/3 3 new-email1818032
Ref: 100a1818032
Node: ポリシーフレームワーク1818199
Ref: whatsnew/3 3 policy-framework1818336
Ref: 10821818336
Node: 新規ヘッダ API を伴った暫定ポリシー1822199
Ref: whatsnew/3 3 provisional-policy-with-new-header-api1822369
Ref: 10861822369
Node: その他のAPIの変更1827950
Ref: whatsnew/3 3 other-api-changes1828078
Ref: 108c1828078
Node: ftplib<3>1829281
Ref: whatsnew/3 3 ftplib1829398
Ref: 10921829398
Ref: ftplib<3>-Footnote-11830580
Ref: ftplib<3>-Footnote-21830644
Ref: ftplib<3>-Footnote-31830709
Node: functools<6>1830774
Ref: whatsnew/3 3 functools1830888
Ref: 10981830888
Ref: functools<6>-Footnote-11831332
Node: gc<6>1831397
Ref: whatsnew/3 3 gc1831509
Ref: 10991831509
Node: hmac<4>1831727
Ref: whatsnew/3 3 hmac1831834
Ref: 109b1831834
Ref: hmac<4>-Footnote-11832163
Ref: hmac<4>-Footnote-21832221
Node: http<4>1832286
Ref: whatsnew/3 3 http1832395
Ref: 109d1832395
Ref: http<4>-Footnote-11833284
Ref: http<4>-Footnote-21833348
Ref: http<4>-Footnote-31833413
Node: html<2>1833478
Ref: whatsnew/3 3 html1833590
Ref: 10a41833590
Ref: html<2>-Footnote-11834708
Ref: html<2>-Footnote-21834773
Ref: html<2>-Footnote-31834838
Ref: html<2>-Footnote-41834903
Ref: html<2>-Footnote-51834968
Ref: html<2>-Footnote-61835033
Ref: html<2>-Footnote-71835100
Ref: html<2>-Footnote-81835166
Ref: html<2>-Footnote-91835231
Ref: html<2>-Footnote-101835296
Ref: html<2>-Footnote-111835364
Ref: html<2>-Footnote-121835431
Ref: html<2>-Footnote-131835497
Ref: html<2>-Footnote-141835563
Ref: html<2>-Footnote-151835628
Ref: html<2>-Footnote-161835694
Node: imaplib<3>1835760
Ref: whatsnew/3 3 imaplib1835875
Ref: 10a61835875
Ref: imaplib<3>-Footnote-11836190
Node: inspect<9>1836254
Ref: whatsnew/3 3 inspect1836367
Ref: 10a71836367
Ref: inspect<9>-Footnote-11837375
Ref: inspect<9>-Footnote-21837440
Node: io<6>1837505
Ref: whatsnew/3 3 io1837620
Ref: 10aa1837620
Ref: io<6>-Footnote-11838399
Node: itertools<6>1838464
Ref: whatsnew/3 3 itertools1838579
Ref: 10ab1838579
Node: logging<7>1838779
Ref: whatsnew/3 3 logging1838896
Ref: 10ac1838896
Node: math<9>1839625
Ref: whatsnew/3 3 math1839737
Ref: 10ae1839737
Ref: math<9>-Footnote-11840001
Node: mmap<4>1840066
Ref: whatsnew/3 3 mmap1840186
Ref: 10b01840186
Ref: mmap<4>-Footnote-11840597
Node: multiprocessing<8>1840662
Ref: whatsnew/3 3 multiprocessing1840785
Ref: 10b21840785
Ref: multiprocessing<8>-Footnote-11842296
Ref: multiprocessing<8>-Footnote-21842361
Ref: multiprocessing<8>-Footnote-31842425
Ref: multiprocessing<8>-Footnote-41842489
Node: nntplib<2>1842554
Ref: whatsnew/3 3 nntplib1842676
Ref: 10ba1842676
Ref: nntplib<2>-Footnote-11843236
Node: os<12>1843300
Ref: whatsnew/3 3 os1843410
Ref: 10bb1843410
Ref: os<12>-Footnote-11852766
Ref: os<12>-Footnote-21852831
Ref: os<12>-Footnote-31852895
Ref: os<12>-Footnote-41852960
Ref: os<12>-Footnote-51853025
Ref: os<12>-Footnote-61853090
Ref: os<12>-Footnote-71853154
Ref: os<12>-Footnote-81853219
Ref: os<12>-Footnote-91853284
Ref: os<12>-Footnote-101853349
Ref: os<12>-Footnote-111853414
Node: pdb<7>1853480
Ref: whatsnew/3 3 pdb1853589
Ref: 10f31853589
Ref: pdb<7>-Footnote-11853931
Node: pickle<5>1853996
Ref: whatsnew/3 3 pickle1854107
Ref: 10f41854107
Ref: pickle<5>-Footnote-11854426
Node: pydoc<5>1854491
Ref: whatsnew/3 3 pydoc1854601
Ref: 10f61854601
Node: re<9>1854834
Ref: whatsnew/3 3 re1854940
Ref: 10f71854940
Ref: re<9>-Footnote-11855164
Node: sched1855228
Ref: whatsnew/3 3 sched1855335
Ref: 10f81855335
Ref: sched-Footnote-11857113
Ref: sched-Footnote-21857178
Ref: sched-Footnote-31857242
Ref: sched-Footnote-41857307
Ref: sched-Footnote-51857372
Node: select<2>1857437
Ref: whatsnew/3 3 select1857547
Ref: 10fd1857547
Ref: select<2>-Footnote-11857922
Node: shlex<3>1857986
Ref: whatsnew/3 3 shlex1858100
Ref: 10fe1858100
Node: shutil<7>1858407
Ref: whatsnew/3 3 shutil1858521
Ref: 10ff1858521
Ref: shutil<7>-Footnote-11861101
Ref: shutil<7>-Footnote-21861166
Ref: shutil<7>-Footnote-31861231
Ref: shutil<7>-Footnote-41861296
Ref: shutil<7>-Footnote-51861361
Ref: shutil<7>-Footnote-61861426
Ref: shutil<7>-Footnote-71861491
Ref: shutil<7>-Footnote-81861555
Node: signal<4>1861619
Ref: whatsnew/3 3 signal1861733
Ref: 11021861733
Ref: signal<4>-Footnote-11863230
Node: smtpd<4>1863294
Ref: whatsnew/3 3 smtpd1863409
Ref: 11091863409
Ref: smtpd<4>-Footnote-11863892
Ref: smtpd<4>-Footnote-21863951
Ref: smtpd<4>-Footnote-31864010
Node: smtplib<4>1864074
Ref: whatsnew/3 3 smtplib1864190
Ref: 110a1864190
Ref: smtplib<4>-Footnote-11865162
Ref: smtplib<4>-Footnote-21865227
Ref: smtplib<4>-Footnote-31865292
Node: socket<10>1865356
Ref: whatsnew/3 3 socket1865479
Ref: 110c1865479
Ref: socket<10>-Footnote-11866851
Ref: socket<10>-Footnote-21866915
Ref: socket<10>-Footnote-31866980
Ref: socket<10>-Footnote-41867069
Ref: socket<10>-Footnote-51867134
Node: socketserver<3>1867199
Ref: whatsnew/3 3 socketserver1867323
Ref: 110f1867323
Ref: socketserver<3>-Footnote-11867806
Node: sqlite3<10>1867871
Ref: whatsnew/3 3 sqlite31867992
Ref: 11131867992
Ref: sqlite3<10>-Footnote-11868342
Node: ssl<11>1868407
Ref: whatsnew/3 3 ssl1868520
Ref: 11141868520
Ref: ssl<11>-Footnote-11871217
Ref: ssl<11>-Footnote-21871282
Ref: ssl<11>-Footnote-31871347
Ref: ssl<11>-Footnote-41871412
Ref: ssl<11>-Footnote-51871477
Ref: ssl<11>-Footnote-61871542
Ref: ssl<11>-Footnote-71871601
Ref: ssl<11>-Footnote-81871666
Ref: ssl<11>-Footnote-91871731
Ref: ssl<11>-Footnote-101871796
Ref: ssl<11>-Footnote-111871862
Ref: ssl<11>-Footnote-121871928
Node: stat<2>1871994
Ref: whatsnew/3 3 stat1872105
Ref: 111d1872105
Ref: stat<2>-Footnote-11872462
Node: struct<3>1872527
Ref: whatsnew/3 3 struct1872644
Ref: 111f1872644
Ref: struct<3>-Footnote-11872893
Node: subprocess<6>1872957
Ref: whatsnew/3 3 subprocess1873074
Ref: 11201873074
Ref: subprocess<6>-Footnote-11873492
Ref: subprocess<6>-Footnote-21873556
Node: sys<13>1873620
Ref: whatsnew/3 3 sys1873738
Ref: 11221873738
Ref: sys<13>-Footnote-11874019
Node: tarfile<8>1874084
Ref: whatsnew/3 3 tarfile1874200
Ref: 11241874200
Ref: tarfile<8>-Footnote-11874473
Node: tempfile<4>1874537
Ref: whatsnew/3 3 tempfile1874657
Ref: 11251874657
Ref: tempfile<4>-Footnote-11874918
Node: textwrap<2>1874982
Ref: whatsnew/3 3 textwrap1875104
Ref: 11261875104
Ref: textwrap<2>-Footnote-11875415
Node: threading<8>1875480
Ref: whatsnew/3 3 threading1875598
Ref: 11271875598
Ref: threading<8>-Footnote-11876814
Ref: threading<8>-Footnote-21876879
Node: time<8>1876943
Ref: whatsnew/3 3 time1877058
Ref: 112e1877058
Ref: time<8>-Footnote-11878243
Ref: time<8>-Footnote-21878285
Node: types<7>1878350
Ref: whatsnew/3 3 types1878465
Ref: 11331878465
Ref: types<7>-Footnote-11878855
Ref: types<7>-Footnote-21878920
Ref: types<7>-Footnote-31878962
Node: unittest<10>1879027
Ref: whatsnew/3 3 unittest1879144
Ref: 11361879144
Ref: unittest<10>-Footnote-11879682
Node: urllib<4>1879747
Ref: whatsnew/3 3 urllib1879869
Ref: 113b1879869
Ref: urllib<4>-Footnote-11880310
Node: webbrowser<3>1880377
Ref: whatsnew/3 3 webbrowser1880511
Ref: 113d1880511
Ref: webbrowser<3>-Footnote-11881104
Ref: webbrowser<3>-Footnote-21881169
Node: xml etree ElementTree<2>1881234
Ref: whatsnew/3 3 xml-etree-elementtree1881366
Ref: 113e1881366
Node: zlib<2>1882088
Ref: whatsnew/3 3 zlib1882198
Ref: 113f1882198
Ref: zlib<2>-Footnote-11882674
Ref: zlib<2>-Footnote-21882739
Node: 最適化<8>1882804
Ref: whatsnew/3 3 optimizations1882968
Ref: 11421882968
Ref: 最適化<8>-Footnote-11883898
Ref: 最適化<8>-Footnote-21883940
Ref: 最適化<8>-Footnote-31884005
Ref: 最適化<8>-Footnote-41884070
Node: ビルドならびに C API の変更<4>1884135
Ref: whatsnew/3 3 build-and-c-api-changes1884279
Ref: 101c1884279
Ref: ビルドならびに C API の変更<4>-Footnote-11886263
Ref: ビルドならびに C API の変更<4>-Footnote-21886305
Ref: ビルドならびに C API の変更<4>-Footnote-31886347
Node: 非推奨<10>1886412
Ref: whatsnew/3 3 deprecated1886567
Ref: 11581886567
Node: サポートされないオペレーティングシステム<2>1887005
Ref: whatsnew/3 3 unsupported-operating-systems1887189
Ref: 11591887189
Node: 非推奨の Python モジュール、関数、メソッド<4>1887678
Ref: whatsnew/3 3 deprecated-python-modules-functions-and-methods1887916
Ref: 115a1887916
Ref: 非推奨の Python モジュール、関数、メソッド<4>-Footnote-11890944
Ref: 非推奨の Python モジュール、関数、メソッド<4>-Footnote-21891008
Ref: 非推奨の Python モジュール、関数、メソッド<4>-Footnote-31891050
Ref: 非推奨の Python モジュール、関数、メソッド<4>-Footnote-41891115
Ref: 非推奨の Python モジュール、関数、メソッド<4>-Footnote-51891180
Node: C API の非推奨の関数ならびに型<3>1891245
Ref: whatsnew/3 3 deprecated-functions-and-types-of-the-c-api1891441
Ref: 115e1891441
Ref: C API の非推奨の関数ならびに型<3>-Footnote-11894492
Node: 非推奨の機能<2>1894534
Ref: whatsnew/3 3 deprecated-features1894659
Ref: 11681894659
Node: Python 3 3 への移植1894908
Ref: whatsnew/3 3 porting-to-python-3-31895014
Ref: 11691895014
Node: Python コードの移植1895360
Ref: whatsnew/3 3 porting-python-code1895474
Ref: 10431895474
Ref: whatsnew/3 3 portingpythoncode1895474
Ref: 116a1895474
Ref: Python コードの移植-Footnote-11904543
Ref: Python コードの移植-Footnote-21904608
Ref: Python コードの移植-Footnote-31904673
Ref: Python コードの移植-Footnote-41904738
Ref: Python コードの移植-Footnote-51904780
Ref: Python コードの移植-Footnote-61904822
Ref: Python コードの移植-Footnote-71904886
Ref: Python コードの移植-Footnote-81904953
Ref: Python コードの移植-Footnote-91905018
Ref: Python コードの移植-Footnote-101905082
Node: C コードの移植1905148
Ref: whatsnew/3 3 porting-c-code1905291
Ref: 101d1905291
Ref: C コードの移植-Footnote-11907077
Node: C 拡張のビルド1907119
Ref: whatsnew/3 3 building-c-extensions1907279
Ref: 11771907279
Ref: C 拡張のビルド-Footnote-11907978
Node: コマンドラインスイッチの変更1908043
Ref: whatsnew/3 3 command-line-switch-changes1908174
Ref: 11781908174
Ref: コマンドラインスイッチの変更-Footnote-11908923
Ref: コマンドラインスイッチの変更-Footnote-21908988
Node: What's New In Python 3 21909053
Ref: whatsnew/3 2 doc1909200
Ref: 117a1909200
Ref: whatsnew/3 2 what-s-new-in-python-3-21909200
Ref: 117b1909200
Ref: What's New In Python 3 2-Footnote-11910804
Ref: What's New In Python 3 2-Footnote-21910903
Node: PEP 384 安定 ABI の定義1910945
Ref: whatsnew/3 2 pep-384-defining-a-stable-abi1911102
Ref: 117c1911102
Ref: PEP 384 安定 ABI の定義-Footnote-11912521
Node: PEP 389 argparse コマンドライン解析モジュール1912563
Ref: whatsnew/3 2 pep-389-argparse-command-line-parsing-module1912772
Ref: 117d1912772
Ref: PEP 389 argparse コマンドライン解析モジュール-Footnote-11917410
Node: PEP 391 logging の辞書ベースの設定1917452
Ref: whatsnew/3 2 pep-391-dictionary-based-configuration-for-logging1917676
Ref: 117f1917676
Ref: PEP 391 logging の辞書ベースの設定-Footnote-11920060
Node: PEP 3148 concurrent futures モジュール1920102
Ref: whatsnew/3 2 pep-3148-the-concurrent-futures-module1920316
Ref: 11811920316
Ref: PEP 3148 concurrent futures モジュール-Footnote-11924001
Node: PEP 3147 PYC リポジトリーディレクトリ1924043
Ref: whatsnew/3 2 pep-3147-pyc-repository-directories1924282
Ref: 11851924282
Ref: PEP 3147 PYC リポジトリーディレクトリ-Footnote-11927969
Ref: PEP 3147 PYC リポジトリーディレクトリ-Footnote-21928040
Node: PEP 3149 ABI バージョンでタグ付けされた so ファイル1928082
Ref: whatsnew/3 2 pep-3149-abi-version-tagged-so-files1928329
Ref: 11871928329
Ref: PEP 3149 ABI バージョンでタグ付けされた so ファイル-Footnote-11929981
Node: PEP 3333 Python Web Server Gateway Interface v1 0 11930023
Ref: whatsnew/3 2 pep-3333-python-web-server-gateway-interface-v1-0-11930249
Ref: 11881930249
Ref: PEP 3333 Python Web Server Gateway Interface v1 0 1-Footnote-11933369
Ref: PEP 3333 Python Web Server Gateway Interface v1 0 1-Footnote-21933428
Ref: PEP 3333 Python Web Server Gateway Interface v1 0 1-Footnote-31933487
Node: その他の言語変更<10>1933529
Ref: whatsnew/3 2 other-language-changes1933774
Ref: 118b1933774
Ref: その他の言語変更<10>-Footnote-11944403
Ref: その他の言語変更<10>-Footnote-21944467
Ref: その他の言語変更<10>-Footnote-31944531
Ref: その他の言語変更<10>-Footnote-41944598
Ref: その他の言語変更<10>-Footnote-51944662
Ref: その他の言語変更<10>-Footnote-61944726
Ref: その他の言語変更<10>-Footnote-71944790
Ref: その他の言語変更<10>-Footnote-81944854
Ref: その他の言語変更<10>-Footnote-91944918
Ref: その他の言語変更<10>-Footnote-101944982
Ref: その他の言語変更<10>-Footnote-111945048
Ref: その他の言語変更<10>-Footnote-121945115
Ref: その他の言語変更<10>-Footnote-131945180
Ref: その他の言語変更<10>-Footnote-141945245
Ref: その他の言語変更<10>-Footnote-151945311
Ref: その他の言語変更<10>-Footnote-161945377
Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール1945442
Ref: whatsnew/3 2 new-improved-and-deprecated-modules1945666
Ref: 11971945666
Node: email<6>1948013
Ref: whatsnew/3 2 email1948165
Ref: 11981948165
Ref: email<6>-Footnote-11950888
Ref: email<6>-Footnote-21950947
Ref: email<6>-Footnote-31951011
Node: elementtree1951076
Ref: whatsnew/3 2 elementtree1951249
Ref: 11a01951249
Ref: elementtree-Footnote-11952878
Ref: elementtree-Footnote-21952978
Node: functools<7>1953042
Ref: whatsnew/3 2 functools1953219
Ref: 11a71953219
Ref: functools<7>-Footnote-11957115
Ref: functools<7>-Footnote-21957198
Ref: functools<7>-Footnote-31957277
Ref: functools<7>-Footnote-41957342
Ref: functools<7>-Footnote-51957407
Ref: functools<7>-Footnote-61957471
Ref: functools<7>-Footnote-71957535
Node: itertools<7>1957599
Ref: whatsnew/3 2 itertools1957779
Ref: 11ac1957779
Ref: itertools<7>-Footnote-11958554
Ref: itertools<7>-Footnote-21958596
Node: collections<8>1958626
Ref: whatsnew/3 2 collections1958806
Ref: 11ae1958806
Ref: collections<8>-Footnote-11961447
Ref: collections<8>-Footnote-21961507
Node: threading<9>1961583
Ref: whatsnew/3 2 threading1961768
Ref: 11b31961768
Ref: threading<9>-Footnote-11965179
Ref: threading<9>-Footnote-21965240
Ref: threading<9>-Footnote-31965339
Ref: threading<9>-Footnote-41965411
Node: datetime と time1965475
Ref: whatsnew/3 2 datetime-and-time1965654
Ref: 11b71965654
Ref: datetime と time-Footnote-11968729
Ref: datetime と time-Footnote-21968796
Ref: datetime と time-Footnote-31968860
Ref: datetime と time-Footnote-41968924
Ref: datetime と time-Footnote-51968988
Ref: datetime と time-Footnote-61969055
Ref: datetime と time-Footnote-71969119
Node: math<10>1969184
Ref: whatsnew/3 2 math1969357
Ref: 11bb1969357
Ref: math<10>-Footnote-11971313
Ref: math<10>-Footnote-21971389
Node: abc<3>1971474
Ref: whatsnew/3 2 abc1971635
Ref: 11c01971635
Ref: abc<3>-Footnote-11972318
Node: io<7>1972382
Ref: whatsnew/3 2 io1972542
Ref: 11c11972542
Ref: io<7>-Footnote-11973801
Node: reprlib1973865
Ref: whatsnew/3 2 reprlib1974029
Ref: 11c31974029
Ref: reprlib-Footnote-11975009
Ref: reprlib-Footnote-21975073
Node: logging<8>1975137
Ref: whatsnew/3 2 logging1975302
Ref: 11c51975302
Node: csv<4>1977426
Ref: whatsnew/3 2 csv1977597
Ref: 11cd1977597
Ref: csv<4>-Footnote-11978572
Ref: csv<4>-Footnote-21978636
Node: contextlib<8>1978703
Ref: whatsnew/3 2 contextlib1978885
Ref: 11d11978885
Ref: contextlib<8>-Footnote-11981790
Node: decimal と fractions1981854
Ref: whatsnew/3 2 decimal-and-fractions1982033
Ref: 11d41982033
Ref: decimal と fractions-Footnote-11984608
Ref: decimal と fractions-Footnote-21984672
Ref: decimal と fractions-Footnote-31984736
Ref: decimal と fractions-Footnote-41984800
Ref: decimal と fractions-Footnote-51984864
Ref: decimal と fractions-Footnote-61984928
Node: ftp1984992
Ref: whatsnew/3 2 ftp1985163
Ref: 11d81985163
Ref: ftp-Footnote-11986868
Ref: ftp-Footnote-21986932
Ref: ftp-Footnote-31986996
Ref: ftp-Footnote-41987060
Node: popen1987124
Ref: whatsnew/3 2 popen1987283
Ref: 11d91987283
Ref: popen-Footnote-11987610
Ref: popen-Footnote-21987674
Node: select<3>1987739
Ref: whatsnew/3 2 select1987911
Ref: 11da1987911
Ref: select<3>-Footnote-11988345
Node: gzip と zipfile1988409
Ref: whatsnew/3 2 gzip-and-zipfile1988586
Ref: 11dc1988586
Ref: gzip と zipfile-Footnote-11990327
Ref: gzip と zipfile-Footnote-21990391
Ref: gzip と zipfile-Footnote-31990455
Ref: gzip と zipfile-Footnote-41990522
Ref: gzip と zipfile-Footnote-51990586
Ref: gzip と zipfile-Footnote-61990650
Node: tarfile<9>1990714
Ref: whatsnew/3 2 tarfile1990892
Ref: 11e01990892
Ref: tarfile<9>-Footnote-11992745
Node: hashlib<7>1992809
Ref: whatsnew/3 2 hashlib1992977
Ref: 11e31992977
Ref: hashlib<7>-Footnote-11993816
Node: ast<5>1993880
Ref: whatsnew/3 2 ast1994044
Ref: 11e41994044
Node: os<13>1995181
Ref: whatsnew/3 2 os1995344
Ref: 11e51995344
Node: shutil<8>1996263
Ref: whatsnew/3 2 shutil1996431
Ref: 11e91996431
Node: sqlite3<11>1999203
Ref: whatsnew/3 2 sqlite31999372
Ref: 11eb1999372
Ref: sqlite3<11>-Footnote-12000137
Node: html<3>2000201
Ref: whatsnew/3 2 html2000371
Ref: 11ec2000371
Node: socket<11>2000743
Ref: whatsnew/3 2 socket2000909
Ref: 11ed2000909
Ref: socket<11>-Footnote-12002123
Ref: socket<11>-Footnote-22002187
Ref: socket<11>-Footnote-32002251
Node: ssl<12>2002312
Ref: whatsnew/3 2 ssl2002475
Ref: 11ef2002475
Ref: ssl<12>-Footnote-12004946
Ref: ssl<12>-Footnote-22005005
Ref: ssl<12>-Footnote-32005077
Ref: ssl<12>-Footnote-42005136
Ref: ssl<12>-Footnote-52005200
Ref: ssl<12>-Footnote-62005264
Ref: ssl<12>-Footnote-72005328
Ref: ssl<12>-Footnote-82005392
Ref: ssl<12>-Footnote-92005456
Ref: ssl<12>-Footnote-102005520
Node: nntp2005585
Ref: whatsnew/3 2 nntp2005750
Ref: 11f32005750
Ref: nntp-Footnote-12006305
Ref: nntp-Footnote-22006369
Node: certificates2006433
Ref: whatsnew/3 2 certificates2006601
Ref: 11f42006601
Ref: certificates-Footnote-12007276
Node: imaplib<4>2007340
Ref: whatsnew/3 2 imaplib2007518
Ref: 11f62007518
Ref: imaplib<4>-Footnote-12007808
Node: http client<4>2007872
Ref: whatsnew/3 2 http-client2008050
Ref: 11f82008050
Ref: http client<4>-Footnote-12010059
Node: unittest<11>2010124
Ref: whatsnew/3 2 unittest2010301
Ref: 11fa2010301
Ref: unittest<11>-Footnote-12015372
Ref: unittest<11>-Footnote-22015437
Ref: unittest<11>-Footnote-32015501
Node: random<5>2015565
Ref: whatsnew/3 2 random2015737
Ref: 11ff2015737
Ref: random<5>-Footnote-12016464
Node: poplib<4>2016528
Ref: whatsnew/3 2 poplib2016699
Ref: 12022016699
Ref: poplib<4>-Footnote-12017176
Node: asyncore<2>2017240
Ref: whatsnew/3 2 asyncore2017413
Ref: 12032017413
Ref: asyncore<2>-Footnote-12017868
Node: tempfile<5>2017932
Ref: whatsnew/3 2 tempfile2018107
Ref: 12042018107
Ref: tempfile<5>-Footnote-12018573
Node: inspect<10>2018637
Ref: whatsnew/3 2 inspect2018809
Ref: 12062018809
Ref: inspect<10>-Footnote-12020688
Node: pydoc<6>2020753
Ref: whatsnew/3 2 pydoc2020920
Ref: 12082020920
Ref: pydoc<6>-Footnote-12021239
Node: dis<5>2021303
Ref: whatsnew/3 2 dis2021465
Ref: 12092021465
Ref: dis<5>-Footnote-12023839
Node: dbm<7>2023903
Ref: whatsnew/3 2 dbm2024066
Ref: 120b2024066
Ref: dbm<7>-Footnote-12024255
Node: ctypes<3>2024319
Ref: whatsnew/3 2 ctypes2024483
Ref: 120c2024483
Node: site<4>2024634
Ref: whatsnew/3 2 site2024804
Ref: 120e2024804
Ref: site<4>-Footnote-12026211
Node: sysconfig<3>2026275
Ref: whatsnew/3 2 sysconfig2026442
Ref: 12122026442
Node: pdb<8>2028902
Ref: whatsnew/3 2 pdb2029077
Ref: 12162029077
Node: configparser<5>2030244
Ref: whatsnew/3 2 configparser2030422
Ref: 12172030422
Node: urllib parse<6>2033598
Ref: whatsnew/3 2 urllib-parse2033777
Ref: 12182033777
Ref: urllib parse<6>-Footnote-12036062
Ref: urllib parse<6>-Footnote-22036121
Ref: urllib parse<6>-Footnote-32036164
Ref: urllib parse<6>-Footnote-42036228
Ref: urllib parse<6>-Footnote-52036292
Node: mailbox2036356
Ref: whatsnew/3 2 mailbox2036530
Ref: 121c2036530
Ref: mailbox-Footnote-12038669
Node: turtledemo2038733
Ref: whatsnew/3 2 turtledemo2038883
Ref: 12232038883
Ref: turtledemo-Footnote-12039319
Node: マルチスレッディング2039384
Ref: whatsnew/3 2 multi-threading2039592
Ref: 12242039592
Ref: マルチスレッディング-Footnote-12041432
Ref: マルチスレッディング-Footnote-22041511
Ref: マルチスレッディング-Footnote-32041575
Ref: マルチスレッディング-Footnote-42041641
Node: 最適化<9>2041705
Ref: whatsnew/3 2 optimizations2041846
Ref: 12262041846
Ref: 最適化<9>-Footnote-12045371
Ref: 最適化<9>-Footnote-22045435
Ref: 最適化<9>-Footnote-32045499
Ref: 最適化<9>-Footnote-42045563
Ref: 最適化<9>-Footnote-52045609
Ref: 最適化<9>-Footnote-62045673
Ref: 最適化<9>-Footnote-72045737
Ref: 最適化<9>-Footnote-82045802
Ref: 最適化<9>-Footnote-92045866
Ref: 最適化<9>-Footnote-102045930
Ref: 最適化<9>-Footnote-112045995
Ref: 最適化<9>-Footnote-122046060
Ref: 最適化<9>-Footnote-132046125
Ref: 最適化<9>-Footnote-142046193
Ref: 最適化<9>-Footnote-152046258
Ref: 最適化<9>-Footnote-162046324
Node: Unicode 文字列型2046389
Ref: whatsnew/3 2 unicode2046506
Ref: 122b2046506
Ref: Unicode 文字列型-Footnote-12047080
Ref: Unicode 文字列型-Footnote-22047131
Ref: Unicode 文字列型-Footnote-32047175
Node: Codecs2047247
Ref: whatsnew/3 2 codecs2047370
Ref: 122c2047370
Ref: Codecs-Footnote-12048647
Node: ドキュメント2048714
Ref: whatsnew/3 2 documentation2048821
Ref: 122d2048821
Ref: ドキュメント-Footnote-12050939
Ref: ドキュメント-Footnote-22050989
Ref: ドキュメント-Footnote-32051058
Ref: ドキュメント-Footnote-42051134
Ref: ドキュメント-Footnote-52051198
Node: IDLE2051262
Ref: whatsnew/3 2 idle2051387
Ref: 12312051387
Ref: IDLE-Footnote-12051877
Ref: IDLE-Footnote-22051941
Node: コードリポジトリ2052005
Ref: whatsnew/3 2 code-repository2052152
Ref: 12322052152
Ref: コードリポジトリ-Footnote-12052857
Ref: コードリポジトリ-Footnote-22052896
Ref: コードリポジトリ-Footnote-32052938
Ref: コードリポジトリ-Footnote-42052992
Node: ビルドならびに C API の変更<5>2053036
Ref: whatsnew/3 2 build-and-c-api-changes2053202
Ref: 12332053202
Ref: ビルドならびに C API の変更<5>-Footnote-12058045
Ref: ビルドならびに C API の変更<5>-Footnote-22058110
Ref: ビルドならびに C API の変更<5>-Footnote-32058174
Ref: ビルドならびに C API の変更<5>-Footnote-42058238
Ref: ビルドならびに C API の変更<5>-Footnote-52058302
Ref: ビルドならびに C API の変更<5>-Footnote-62058366
Ref: ビルドならびに C API の変更<5>-Footnote-72058430
Ref: ビルドならびに C API の変更<5>-Footnote-82058494
Ref: ビルドならびに C API の変更<5>-Footnote-92058558
Ref: ビルドならびに C API の変更<5>-Footnote-102058622
Ref: ビルドならびに C API の変更<5>-Footnote-112058687
Ref: ビルドならびに C API の変更<5>-Footnote-122058752
Ref: ビルドならびに C API の変更<5>-Footnote-132058817
Ref: ビルドならびに C API の変更<5>-Footnote-142058882
Ref: ビルドならびに C API の変更<5>-Footnote-152058965
Node: Python 3 2 への移植2059066
Ref: whatsnew/3 2 porting-to-python-3-22059199
Ref: 123c2059199
Ref: Python 3 2 への移植-Footnote-12067446
Ref: Python 3 2 への移植-Footnote-22067510
Ref: Python 3 2 への移植-Footnote-32067574
Ref: Python 3 2 への移植-Footnote-42067619
Ref: Python 3 2 への移植-Footnote-52067684
Ref: Python 3 2 への移植-Footnote-62067749
Ref: Python 3 2 への移植-Footnote-72067814
Node: What's New In Python 3 12067878
Ref: whatsnew/3 1 doc2068025
Ref: 124c2068025
Ref: whatsnew/3 1 what-s-new-in-python-3-12068025
Ref: 124d2068025
Node: PEP 372 順序付き辞書2068855
Ref: whatsnew/3 1 pep-372-ordered-dictionaries2068999
Ref: 124e2068999
Ref: PEP 372 順序付き辞書-Footnote-12071854
Ref: PEP 372 順序付き辞書-Footnote-22071882
Node: PEP 378 1000区切りのための書式指定子2071924
Ref: whatsnew/3 1 pep-378-format-specifier-for-thousands-separator2072105
Ref: 124f2072105
Ref: PEP 378 1000区切りのための書式指定子-Footnote-12073574
Node: その他の言語変更<11>2073616
Ref: whatsnew/3 1 other-language-changes2073861
Ref: 12502073861
Ref: その他の言語変更<11>-Footnote-12078972
Ref: その他の言語変更<11>-Footnote-22079039
Ref: その他の言語変更<11>-Footnote-32079103
Ref: その他の言語変更<11>-Footnote-42079167
Ref: その他の言語変更<11>-Footnote-52079231
Ref: その他の言語変更<11>-Footnote-62079276
Ref: その他の言語変更<11>-Footnote-72079340
Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>2079404
Ref: whatsnew/3 1 new-improved-and-deprecated-modules2079614
Ref: 12512079614
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-12089933
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-22090000
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-32090064
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-42090106
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-52090170
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-62090234
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-72090298
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-82090340
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-92090404
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-102090468
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-112090533
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-122090598
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-132090663
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<2>-Footnote-142090728
Node: 最適化<10>2090793
Ref: whatsnew/3 1 optimizations2090982
Ref: 12612090982
Ref: 最適化<10>-Footnote-12093153
Ref: 最適化<10>-Footnote-22093195
Ref: 最適化<10>-Footnote-32093259
Ref: 最適化<10>-Footnote-42093323
Ref: 最適化<10>-Footnote-52093387
Ref: 最適化<10>-Footnote-62093413
Ref: 最適化<10>-Footnote-72093477
Node: IDLE<2>2093541
Ref: whatsnew/3 1 idle2093680
Ref: 12622093680
Ref: IDLE<2>-Footnote-12093964
Node: ビルドならびに C API の変更<6>2094028
Ref: whatsnew/3 1 build-and-c-api-changes2094177
Ref: 12632094177
Ref: ビルドならびに C API の変更<6>-Footnote-12096936
Ref: ビルドならびに C API の変更<6>-Footnote-22097000
Ref: ビルドならびに C API の変更<6>-Footnote-32097064
Ref: ビルドならびに C API の変更<6>-Footnote-42097128
Ref: ビルドならびに C API の変更<6>-Footnote-52097192
Node: Python 3 1 への移植2097256
Ref: whatsnew/3 1 porting-to-python-3-12097389
Ref: 12672097389
Node: What's New In Python 3 02098688
Ref: whatsnew/3 0 doc2098835
Ref: 12682098835
Ref: whatsnew/3 0 what-s-new-in-python-3-02098835
Ref: 12692098835
Node: よくある悩みの種2100981
Ref: whatsnew/3 0 common-stumbling-blocks2101099
Ref: 126a2101099
Node: print関数2101459
Ref: whatsnew/3 0 print-is-a-function2101591
Ref: 126b2101591
Ref: print関数-Footnote-12103409
Node: リストからビューおよびイテレータへ2103451
Ref: whatsnew/3 0 views-and-iterators-instead-of-lists2103604
Ref: 126c2103604
Node: 順序比較2105963
Ref: whatsnew/3 0 ordering-comparisons2106111
Ref: 126f2106111
Node: 整数2107874
Ref: whatsnew/3 0 integers2108039
Ref: 12702108039
Ref: 整数-Footnote-12109531
Ref: 整数-Footnote-22109573
Node: Unicode 対 8 ビット、ではなく、テキスト対データに2109615
Ref: whatsnew/3 0 text-vs-data-instead-of-unicode-vs-8-bit2109759
Ref: 12712109759
Ref: Unicode 対 8 ビット、ではなく、テキスト対データに-Footnote-12119451
Ref: Unicode 対 8 ビット、ではなく、テキスト対データに-Footnote-22119493
Ref: Unicode 対 8 ビット、ではなく、テキスト対データに-Footnote-32119535
Node: 構文の変更の概要2119577
Ref: whatsnew/3 0 overview-of-syntax-changes2119739
Ref: 12772119739
Node: 新たな構文2119996
Ref: whatsnew/3 0 new-syntax2120102
Ref: 12782120102
Ref: 新たな構文-Footnote-12123721
Ref: 新たな構文-Footnote-22123763
Ref: 新たな構文-Footnote-32123805
Ref: 新たな構文-Footnote-42123847
Ref: 新たな構文-Footnote-52123889
Node: 変更された構文2123931
Ref: whatsnew/3 0 changed-syntax2124067
Ref: 127b2124067
Ref: 変更された構文-Footnote-12126810
Ref: 変更された構文-Footnote-22126852
Ref: 変更された構文-Footnote-32126894
Ref: 変更された構文-Footnote-42126936
Node: 削除された操作2126978
Ref: whatsnew/3 0 removed-syntax2127090
Ref: 127c2127090
Ref: 削除された操作-Footnote-12128815
Ref: 削除された操作-Footnote-22128857
Node: Python 2 6 で既にあった変更2128899
Ref: whatsnew/3 0 changes-already-present-in-python-2-62129061
Ref: 127e2129061
Node: ライブラリの変更2134357
Ref: whatsnew/3 0 library-changes2134546
Ref: 12912134546
Ref: ライブラリの変更-Footnote-12141498
Ref: ライブラリの変更-Footnote-22141540
Ref: ライブラリの変更-Footnote-32141582
Ref: ライブラリの変更-Footnote-42141624
Ref: ライブラリの変更-Footnote-52141666
Ref: ライブラリの変更-Footnote-62141708
Node: PEP 3101 文字列整形の新たなアプローチ2141750
Ref: whatsnew/3 0 pep-3101-a-new-approach-to-string-formatting2141928
Ref: 12942141928
Ref: PEP 3101 文字列整形の新たなアプローチ-Footnote-12142500
Node: 例外に関する変更2142542
Ref: whatsnew/3 0 changes-to-exceptions2142717
Ref: 12952142717
Ref: 例外に関する変更-Footnote-12146614
Ref: 例外に関する変更-Footnote-22146656
Ref: 例外に関する変更-Footnote-32146698
Ref: 例外に関する変更-Footnote-42146740
Ref: 例外に関する変更-Footnote-52146782
Node: その他の変更<2>2146824
Ref: whatsnew/3 0 miscellaneous-other-changes2146988
Ref: 12992146988
Node: 演算子と特殊メソッド2147097
Ref: whatsnew/3 0 operators-and-special-methods2147206
Ref: 129a2147206
Ref: 演算子と特殊メソッド-Footnote-12149032
Node: 組み込み2149074
Ref: whatsnew/3 0 builtins2149183
Ref: 12a42149183
Ref: 組み込み-Footnote-12152403
Ref: 組み込み-Footnote-22152445
Ref: 組み込み-Footnote-32152487
Node: ビルドならびに C API の変更<7>2152547
Ref: whatsnew/3 0 build-and-c-api-changes2152693
Ref: 12ab2152693
Ref: ビルドならびに C API の変更<7>-Footnote-12153928
Ref: ビルドならびに C API の変更<7>-Footnote-22153970
Ref: ビルドならびに C API の変更<7>-Footnote-32154012
Node: 性能2154054
Ref: whatsnew/3 0 performance2154202
Ref: 12ad2154202
Node: Python 3 0 への移植2154638
Ref: whatsnew/3 0 porting-to-python-3-02154737
Ref: 12ae2154737
Node: What's New in Python 2 72157415
Ref: whatsnew/2 7 doc2157562
Ref: 12b02157562
Ref: whatsnew/2 7 what-s-new-in-python-2-72157562
Ref: 12b12157562
Node: Python 2 x の今後2160469
Ref: whatsnew/2 7 the-future-for-python-2-x2160598
Ref: 12b22160598
Ref: whatsnew/2 7 whatsnew27-python312160598
Ref: 12b32160598
Ref: Python 2 x の今後-Footnote-12164874
Ref: Python 2 x の今後-Footnote-22164916
Node: Deprecation Warnings の扱いの変更2164953
Ref: whatsnew/2 7 changes-to-the-handling-of-deprecation-warnings2165111
Ref: 12b52165111
Ref: Deprecation Warnings の扱いの変更-Footnote-12166920
Node: Python 3 1 の機能2166984
Ref: whatsnew/2 7 python-3-1-features2167172
Ref: 12b62167172
Node: PEP 372 collections に順序付き辞書を追加2169486
Ref: whatsnew/2 7 pep-03722169686
Ref: 12b72169686
Ref: whatsnew/2 7 pep-372-adding-an-ordered-dictionary-to-collections2169686
Ref: 12ba2169686
Ref: PEP 372 collections に順序付き辞書を追加-Footnote-12173507
Ref: PEP 372 collections に順序付き辞書を追加-Footnote-22173535
Node: PEP 378 1000区切りのための書式指定子<2>2173577
Ref: whatsnew/2 7 pep-03782173829
Ref: 12b82173829
Ref: whatsnew/2 7 pep-378-format-specifier-for-thousands-separator2173829
Ref: 12bc2173829
Ref: PEP 378 1000区切りのための書式指定子<2>-Footnote-12175554
Node: PEP 389 コマンドライン解析のための argparse モジュール2175596
Ref: whatsnew/2 7 pep-389-the-argparse-module-for-parsing-command-lines2175844
Ref: 12bd2175844
Ref: PEP 389 コマンドライン解析のための argparse モジュール-Footnote-12180232
Node: PEP 391 logging の辞書ベースの設定<2>2180274
Ref: whatsnew/2 7 pep-391-dictionary-based-configuration-for-logging2180491
Ref: 12be2180491
Ref: PEP 391 logging の辞書ベースの設定<2>-Footnote-12184682
Node: PEP 3106 辞書 View2184724
Ref: whatsnew/2 7 pep-3106-dictionary-views2184907
Ref: 12c52184907
Ref: PEP 3106 辞書 View-Footnote-12187159
Ref: PEP 3106 辞書 View-Footnote-22187201
Node: PEP 3137 memoryview オブジェクト2187265
Ref: whatsnew/2 7 pep-3137-the-memoryview-object2187430
Ref: 12c62187430
Ref: PEP 3137 memoryview オブジェクト-Footnote-12189244
Ref: PEP 3137 memoryview オブジェクト-Footnote-22189286
Node: その他の言語変更<12>2189350
Ref: whatsnew/2 7 other-language-changes2189552
Ref: 12c72189552
Ref: その他の言語変更<12>-Footnote-12200877
Ref: その他の言語変更<12>-Footnote-22200941
Ref: その他の言語変更<12>-Footnote-32201005
Ref: その他の言語変更<12>-Footnote-42201069
Ref: その他の言語変更<12>-Footnote-52201133
Ref: その他の言語変更<12>-Footnote-62201197
Ref: その他の言語変更<12>-Footnote-72201261
Ref: その他の言語変更<12>-Footnote-82201325
Ref: その他の言語変更<12>-Footnote-92201389
Ref: その他の言語変更<12>-Footnote-102201453
Ref: その他の言語変更<12>-Footnote-112201518
Ref: その他の言語変更<12>-Footnote-122201583
Ref: その他の言語変更<12>-Footnote-132201648
Ref: その他の言語変更<12>-Footnote-142201713
Ref: その他の言語変更<12>-Footnote-152201781
Ref: その他の言語変更<12>-Footnote-162201846
Ref: その他の言語変更<12>-Footnote-172201911
Ref: その他の言語変更<12>-Footnote-182201976
Ref: その他の言語変更<12>-Footnote-192202044
Ref: その他の言語変更<12>-Footnote-202202109
Ref: その他の言語変更<12>-Footnote-212202174
Ref: その他の言語変更<12>-Footnote-222202239
Ref: その他の言語変更<12>-Footnote-232202304
Ref: その他の言語変更<12>-Footnote-242202369
Node: インタプリタの変更2202434
Ref: whatsnew/2 7 interpreter-changes2202548
Ref: 12cb2202548
Ref: whatsnew/2 7 new-27-interpreter2202548
Ref: 12cc2202548
Ref: インタプリタの変更-Footnote-12203255
Node: 最適化<11>2203319
Ref: whatsnew/2 7 optimizations2203433
Ref: 12cd2203433
Ref: 最適化<11>-Footnote-12208777
Ref: 最適化<11>-Footnote-22208841
Ref: 最適化<11>-Footnote-32208905
Ref: 最適化<11>-Footnote-42208969
Ref: 最適化<11>-Footnote-52209033
Ref: 最適化<11>-Footnote-62209097
Ref: 最適化<11>-Footnote-72209164
Ref: 最適化<11>-Footnote-82209228
Ref: 最適化<11>-Footnote-92209292
Ref: 最適化<11>-Footnote-102209356
Ref: 最適化<11>-Footnote-112209421
Ref: 最適化<11>-Footnote-122209486
Ref: 最適化<11>-Footnote-132209551
Node: 新しいモジュールと改良されたモジュール2209616
Ref: whatsnew/2 7 new-and-improved-modules2209820
Ref: 12cf2209820
Ref: 新しいモジュールと改良されたモジュール-Footnote-12250274
Ref: 新しいモジュールと改良されたモジュール-Footnote-22250338
Ref: 新しいモジュールと改良されたモジュール-Footnote-32250402
Ref: 新しいモジュールと改良されたモジュール-Footnote-42250455
Ref: 新しいモジュールと改良されたモジュール-Footnote-52250519
Ref: 新しいモジュールと改良されたモジュール-Footnote-62250583
Ref: 新しいモジュールと改良されたモジュール-Footnote-72250650
Ref: 新しいモジュールと改良されたモジュール-Footnote-82250714
Ref: 新しいモジュールと改良されたモジュール-Footnote-92250778
Ref: 新しいモジュールと改良されたモジュール-Footnote-102250842
Ref: 新しいモジュールと改良されたモジュール-Footnote-112250907
Ref: 新しいモジュールと改良されたモジュール-Footnote-122250972
Ref: 新しいモジュールと改良されたモジュール-Footnote-132251037
Ref: 新しいモジュールと改良されたモジュール-Footnote-142251077
Ref: 新しいモジュールと改良されたモジュール-Footnote-152251142
Ref: 新しいモジュールと改良されたモジュール-Footnote-162251207
Ref: 新しいモジュールと改良されたモジュール-Footnote-172251272
Ref: 新しいモジュールと改良されたモジュール-Footnote-182251337
Ref: 新しいモジュールと改良されたモジュール-Footnote-192251402
Ref: 新しいモジュールと改良されたモジュール-Footnote-202251467
Ref: 新しいモジュールと改良されたモジュール-Footnote-212251532
Ref: 新しいモジュールと改良されたモジュール-Footnote-222251597
Ref: 新しいモジュールと改良されたモジュール-Footnote-232251662
Ref: 新しいモジュールと改良されたモジュール-Footnote-242251727
Ref: 新しいモジュールと改良されたモジュール-Footnote-252251792
Ref: 新しいモジュールと改良されたモジュール-Footnote-262251857
Ref: 新しいモジュールと改良されたモジュール-Footnote-272251925
Ref: 新しいモジュールと改良されたモジュール-Footnote-282251990
Ref: 新しいモジュールと改良されたモジュール-Footnote-292252055
Ref: 新しいモジュールと改良されたモジュール-Footnote-302252120
Ref: 新しいモジュールと改良されたモジュール-Footnote-312252185
Ref: 新しいモジュールと改良されたモジュール-Footnote-322252250
Ref: 新しいモジュールと改良されたモジュール-Footnote-332252315
Ref: 新しいモジュールと改良されたモジュール-Footnote-342252380
Ref: 新しいモジュールと改良されたモジュール-Footnote-352252445
Ref: 新しいモジュールと改良されたモジュール-Footnote-362252510
Ref: 新しいモジュールと改良されたモジュール-Footnote-372252575
Ref: 新しいモジュールと改良されたモジュール-Footnote-382252640
Ref: 新しいモジュールと改良されたモジュール-Footnote-392252705
Ref: 新しいモジュールと改良されたモジュール-Footnote-402252770
Ref: 新しいモジュールと改良されたモジュール-Footnote-412252835
Ref: 新しいモジュールと改良されたモジュール-Footnote-422252900
Ref: 新しいモジュールと改良されたモジュール-Footnote-432252965
Ref: 新しいモジュールと改良されたモジュール-Footnote-442253030
Ref: 新しいモジュールと改良されたモジュール-Footnote-452253095
Ref: 新しいモジュールと改良されたモジュール-Footnote-462253160
Ref: 新しいモジュールと改良されたモジュール-Footnote-472253225
Ref: 新しいモジュールと改良されたモジュール-Footnote-482253290
Ref: 新しいモジュールと改良されたモジュール-Footnote-492253358
Ref: 新しいモジュールと改良されたモジュール-Footnote-502253423
Ref: 新しいモジュールと改良されたモジュール-Footnote-512253488
Ref: 新しいモジュールと改良されたモジュール-Footnote-522253553
Ref: 新しいモジュールと改良されたモジュール-Footnote-532253618
Ref: 新しいモジュールと改良されたモジュール-Footnote-542253683
Ref: 新しいモジュールと改良されたモジュール-Footnote-552253748
Ref: 新しいモジュールと改良されたモジュール-Footnote-562253813
Ref: 新しいモジュールと改良されたモジュール-Footnote-572253878
Ref: 新しいモジュールと改良されたモジュール-Footnote-582253943
Ref: 新しいモジュールと改良されたモジュール-Footnote-592254008
Ref: 新しいモジュールと改良されたモジュール-Footnote-602254073
Ref: 新しいモジュールと改良されたモジュール-Footnote-612254138
Ref: 新しいモジュールと改良されたモジュール-Footnote-622254203
Ref: 新しいモジュールと改良されたモジュール-Footnote-632254268
Ref: 新しいモジュールと改良されたモジュール-Footnote-642254333
Ref: 新しいモジュールと改良されたモジュール-Footnote-652254398
Ref: 新しいモジュールと改良されたモジュール-Footnote-662254463
Ref: 新しいモジュールと改良されたモジュール-Footnote-672254528
Ref: 新しいモジュールと改良されたモジュール-Footnote-682254593
Ref: 新しいモジュールと改良されたモジュール-Footnote-692254658
Ref: 新しいモジュールと改良されたモジュール-Footnote-702254704
Ref: 新しいモジュールと改良されたモジュール-Footnote-712254769
Ref: 新しいモジュールと改良されたモジュール-Footnote-722254834
Ref: 新しいモジュールと改良されたモジュール-Footnote-732254888
Ref: 新しいモジュールと改良されたモジュール-Footnote-742254953
Ref: 新しいモジュールと改良されたモジュール-Footnote-752255018
Ref: 新しいモジュールと改良されたモジュール-Footnote-762255083
Ref: 新しいモジュールと改良されたモジュール-Footnote-772255148
Ref: 新しいモジュールと改良されたモジュール-Footnote-782255213
Ref: 新しいモジュールと改良されたモジュール-Footnote-792255281
Ref: 新しいモジュールと改良されたモジュール-Footnote-802255346
Ref: 新しいモジュールと改良されたモジュール-Footnote-812255411
Ref: 新しいモジュールと改良されたモジュール-Footnote-822255476
Ref: 新しいモジュールと改良されたモジュール-Footnote-832255541
Ref: 新しいモジュールと改良されたモジュール-Footnote-842255606
Ref: 新しいモジュールと改良されたモジュール-Footnote-852255671
Ref: 新しいモジュールと改良されたモジュール-Footnote-862255739
Ref: 新しいモジュールと改良されたモジュール-Footnote-872255807
Ref: 新しいモジュールと改良されたモジュール-Footnote-882255872
Ref: 新しいモジュールと改良されたモジュール-Footnote-892255932
Ref: 新しいモジュールと改良されたモジュール-Footnote-902255992
Ref: 新しいモジュールと改良されたモジュール-Footnote-912256057
Ref: 新しいモジュールと改良されたモジュール-Footnote-922256122
Ref: 新しいモジュールと改良されたモジュール-Footnote-932256187
Ref: 新しいモジュールと改良されたモジュール-Footnote-942256252
Ref: 新しいモジュールと改良されたモジュール-Footnote-952256317
Ref: 新しいモジュールと改良されたモジュール-Footnote-962256382
Ref: 新しいモジュールと改良されたモジュール-Footnote-972256447
Node: 新しいモジュール importlib2256512
Ref: whatsnew/2 7 importlib-section2256683
Ref: 12b92256683
Ref: whatsnew/2 7 new-module-importlib2256683
Ref: 12fb2256683
Node: 新しいモジュール sysconfig2258406
Ref: whatsnew/2 7 new-module-sysconfig2258629
Ref: 12fc2258629
Node: ttk Tk のテーマ付きウィジェット2260334
Ref: whatsnew/2 7 ttk-themed-widgets-for-tk2260562
Ref: 12fe2260562
Ref: ttk Tk のテーマ付きウィジェット-Footnote-12261807
Ref: ttk Tk のテーマ付きウィジェット-Footnote-22261871
Node: 更新されたモジュール unittest2261935
Ref: whatsnew/2 7 unittest-section2262175
Ref: 12ff2262175
Ref: whatsnew/2 7 updated-module-unittest2262175
Ref: 13002262175
Ref: 更新されたモジュール unittest-Footnote-12272853
Ref: 更新されたモジュール unittest-Footnote-22272897
Ref: 更新されたモジュール unittest-Footnote-32272924
Ref: 更新されたモジュール unittest-Footnote-42272961
Ref: 更新されたモジュール unittest-Footnote-52273025
Ref: 更新されたモジュール unittest-Footnote-62273089
Ref: 更新されたモジュール unittest-Footnote-72273156
Ref: 更新されたモジュール unittest-Footnote-82273220
Ref: 更新されたモジュール unittest-Footnote-92273284
Ref: 更新されたモジュール unittest-Footnote-102273348
Ref: 更新されたモジュール unittest-Footnote-112273413
Ref: 更新されたモジュール unittest-Footnote-122273478
Ref: 更新されたモジュール unittest-Footnote-132273543
Ref: 更新されたモジュール unittest-Footnote-142273608
Ref: 更新されたモジュール unittest-Footnote-152273673
Node: 更新されたモジュール ElementTree 1 32273738
Ref: whatsnew/2 7 elementtree-section2273926
Ref: 131b2273926
Ref: whatsnew/2 7 updated-module-elementtree-1-32273926
Ref: 131c2273926
Ref: 更新されたモジュール ElementTree 1 3-Footnote-12278258
Node: ビルドならびに C API の変更<8>2278322
Ref: whatsnew/2 7 build-and-c-api-changes2278525
Ref: 131f2278525
Ref: ビルドならびに C API の変更<8>-Footnote-12288145
Ref: ビルドならびに C API の変更<8>-Footnote-22288258
Ref: ビルドならびに C API の変更<8>-Footnote-32288322
Ref: ビルドならびに C API の変更<8>-Footnote-42288386
Ref: ビルドならびに C API の変更<8>-Footnote-52288450
Ref: ビルドならびに C API の変更<8>-Footnote-62288514
Ref: ビルドならびに C API の変更<8>-Footnote-72288578
Ref: ビルドならびに C API の変更<8>-Footnote-82288642
Ref: ビルドならびに C API の変更<8>-Footnote-92288697
Ref: ビルドならびに C API の変更<8>-Footnote-102288761
Ref: ビルドならびに C API の変更<8>-Footnote-112288826
Ref: ビルドならびに C API の変更<8>-Footnote-122288891
Ref: ビルドならびに C API の変更<8>-Footnote-132288956
Ref: ビルドならびに C API の変更<8>-Footnote-142289024
Ref: ビルドならびに C API の変更<8>-Footnote-152289092
Ref: ビルドならびに C API の変更<8>-Footnote-162289157
Ref: ビルドならびに C API の変更<8>-Footnote-172289222
Ref: ビルドならびに C API の変更<8>-Footnote-182289287
Ref: ビルドならびに C API の変更<8>-Footnote-192289352
Ref: ビルドならびに C API の変更<8>-Footnote-202289417
Ref: ビルドならびに C API の変更<8>-Footnote-212289485
Ref: ビルドならびに C API の変更<8>-Footnote-222289550
Node: カプセル2289615
Ref: whatsnew/2 7 capsules2289745
Ref: 13222289745
Ref: whatsnew/2 7 whatsnew27-capsules2289745
Ref: 13232289745
Ref: カプセル-Footnote-12292000
Node: ポート特有の変更 Windows2292064
Ref: whatsnew/2 7 port-specific-changes-windows2292236
Ref: 13262292236
Ref: ポート特有の変更 Windows-Footnote-12294053
Ref: ポート特有の変更 Windows-Footnote-22294117
Ref: ポート特有の変更 Windows-Footnote-32294181
Ref: ポート特有の変更 Windows-Footnote-42294245
Ref: ポート特有の変更 Windows-Footnote-52294312
Ref: ポート特有の変更 Windows-Footnote-62294376
Node: ポート特有の変更 Mac OS X2294440
Ref: whatsnew/2 7 port-specific-changes-mac-os-x2294632
Ref: 13322294632
Ref: ポート特有の変更 Mac OS X-Footnote-12295694
Ref: ポート特有の変更 Mac OS X-Footnote-22295758
Node: ポート特有の変更 FreeBSD2295823
Ref: whatsnew/2 7 port-specific-changes-freebsd2295974
Ref: 13332295974
Ref: ポート特有の変更 FreeBSD-Footnote-12296375
Node: その他の変更と修正2296439
Ref: whatsnew/2 7 other-changes-and-fixes2296608
Ref: 13342296608
Ref: その他の変更と修正-Footnote-12299263
Ref: その他の変更と修正-Footnote-22299327
Ref: その他の変更と修正-Footnote-32299394
Ref: その他の変更と修正-Footnote-42299458
Ref: その他の変更と修正-Footnote-52299522
Node: Python 2 7 への移植2299586
Ref: whatsnew/2 7 porting-to-python-2-72299783
Ref: 13362299783
Ref: Python 2 7 への移植-Footnote-12305849
Ref: Python 2 7 への移植-Footnote-22305913
Ref: Python 2 7 への移植-Footnote-32305977
Ref: Python 2 7 への移植-Footnote-42306041
Ref: Python 2 7 への移植-Footnote-52306105
Ref: Python 2 7 への移植-Footnote-62306169
Ref: Python 2 7 への移植-Footnote-72306233
Ref: Python 2 7 への移植-Footnote-82306297
Ref: Python 2 7 への移植-Footnote-92306361
Ref: Python 2 7 への移植-Footnote-102306425
Ref: Python 2 7 への移植-Footnote-112306490
Ref: Python 2 7 への移植-Footnote-122306555
Ref: Python 2 7 への移植-Footnote-132306620
Ref: Python 2 7 への移植-Footnote-142306680
Node: Python 2 7 メンテナンスリリースで追加された新機能2306745
Ref: whatsnew/2 7 new-features-added-to-python-2-7-maintenance-releases2306921
Ref: 13372306921
Ref: whatsnew/2 7 py27-maintenance-enhancements2306921
Ref: 12b42306921
Node: デバッグモード用の2つの新しい環境変数2308769
Ref: whatsnew/2 7 two-new-environment-variables-for-debug-mode2309023
Ref: 13382309023
Ref: デバッグモード用の2つの新しい環境変数-Footnote-12309708
Ref: デバッグモード用の2つの新しい環境変数-Footnote-22309773
Node: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い2309838
Ref: whatsnew/2 7 pep-434-idle-enhancement-exception-for-all-branches2310174
Ref: 13392310174
Ref: PEP 434 IDLE 拡張についての全てのブランチにおける例外的な扱い-Footnote-12310869
Node: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張2310911
Ref: whatsnew/2 7 pep-466-network-security-enhancements-for-python-2-72311254
Ref: 133a2311254
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-12314092
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-22314134
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-32314176
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-42314241
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-52314306
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-62314348
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-72314413
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-82314478
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-92314533
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-102314575
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-112314641
Ref: PEP 466 Python 2 7 のためのネットワークセキュリティ拡張-Footnote-122314707
Node: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート2314773
Ref: whatsnew/2 7 pep-477-backport-ensurepip-pep-453-to-python-2-72315135
Ref: 133d2315135
Ref: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート-Footnote-12315790
Ref: PEP 477 Python 2 7 への ensurepip PEP 453 バックポート-Footnote-22315832
Node: デフォルトでの pip のブートストラッピング<2>2315874
Ref: whatsnew/2 7 bootstrapping-pip-by-default2316074
Ref: 133e2316074
Ref: デフォルトでの pip のブートストラッピング<2>-Footnote-12318152
Ref: デフォルトでの pip のブートストラッピング<2>-Footnote-22318194
Node: ドキュメントの変更<2>2318284
Ref: whatsnew/2 7 documentation-changes2318484
Ref: 133f2318484
Ref: ドキュメントの変更<2>-Footnote-12319637
Ref: ドキュメントの変更<2>-Footnote-22319674
Node: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>2319716
Ref: whatsnew/2 7 pep-476-enabling-certificate-verification-by-default-for-stdlib-http-clients2320062
Ref: 13402320062
Ref: PEP 476 stdlib http クライアントが証明書の検証を行うのをデフォルトで有効化<2>-Footnote-12321213
Node: PEP 493 HTTPS verification migration tools for Python 2 72321255
Ref: whatsnew/2 7 pep-493-https-verification-migration-tools-for-python-2-72321573
Ref: 13412321573
Ref: PEP 493 HTTPS verification migration tools for Python 2 7-Footnote-12322731
Node: New make regen-all build target<3>2322773
Ref: whatsnew/2 7 new-make-regen-all-build-target2323024
Ref: 13422323024
Ref: New make regen-all build target<3>-Footnote-12323816
Ref: New make regen-all build target<3>-Footnote-22323884
Node: Removal of make touch build target<3>2323949
Ref: whatsnew/2 7 removal-of-make-touch-build-target2324134
Ref: 13432324134
Ref: Removal of make touch build target<3>-Footnote-12324576
Node: 謝辞2324641
Ref: whatsnew/2 7 acknowledgements2324785
Ref: 13442324785
Ref: whatsnew/2 7 acks272324785
Ref: 13452324785
Node: What's New in Python 2 62325077
Ref: whatsnew/2 6 doc2325224
Ref: 13462325224
Ref: whatsnew/2 6 what-s-new-in-python-2-62325224
Ref: 13472325224
Ref: whatsnew/2 6 whats-new-in-2-62325224
Ref: 127f2325224
Ref: What's New in Python 2 6-Footnote-12328959
Node: Python 3 02329001
Ref: whatsnew/2 6 python-3-02329117
Ref: 13482329117
Ref: Python 3 0-Footnote-12331640
Ref: Python 3 0-Footnote-22331682
Node: 開発プロセスに関する変更2331724
Ref: whatsnew/2 6 changes-to-the-development-process2331885
Ref: 13492331885
Node: 新しい課題トラッカー Roundup2332579
Ref: whatsnew/2 6 new-issue-tracker-roundup2332796
Ref: 134a2332796
Ref: 新しい課題トラッカー Roundup-Footnote-12335230
Ref: 新しい課題トラッカー Roundup-Footnote-22335279
Ref: 新しい課題トラッカー Roundup-Footnote-32335310
Ref: 新しい課題トラッカー Roundup-Footnote-42335350
Ref: 新しい課題トラッカー Roundup-Footnote-52335385
Node: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText2335423
Ref: whatsnew/2 6 new-documentation-format-restructuredtext-using-sphinx2335640
Ref: 134b2335640
Ref: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText-Footnote-12338811
Ref: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText-Footnote-22338870
Ref: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText-Footnote-32338919
Ref: 新しいドキュメンテーションフォーマット Sphinx を使っての reStructuredText-Footnote-42338955
Node: PEP 343 "with" ステートメント2338995
Ref: whatsnew/2 6 pep-03432339217
Ref: 12802339217
Ref: whatsnew/2 6 pep-343-the-with-statement2339217
Ref: 134c2339217
Node: コンテキストマネージャを書く2342985
Ref: whatsnew/2 6 new-26-context-managers2343135
Ref: 12812343135
Ref: whatsnew/2 6 writing-context-managers2343135
Ref: 134d2343135
Node: contextlib モジュール2348452
Ref: whatsnew/2 6 new-module-contextlib2348602
Ref: 12822348602
Ref: whatsnew/2 6 the-contextlib-module2348602
Ref: 134e2348602
Ref: contextlib モジュール-Footnote-12351518
Node: PEP 366 メインモジュールからの明示的相対インポート2351560
Ref: whatsnew/2 6 pep-03662351805
Ref: 12832351805
Ref: whatsnew/2 6 pep-366-explicit-relative-imports-from-a-main-module2351805
Ref: 134f2351805
Node: PEP 370 ユーザごとの site-packages ディレクトリ2352654
Ref: whatsnew/2 6 pep-03702352902
Ref: 12842352902
Ref: whatsnew/2 6 pep-370-per-user-site-packages-directory2352902
Ref: 13512352902
Ref: PEP 370 ユーザごとの site-packages ディレクトリ-Footnote-12354674
Node: PEP 371 multiprocessing パッケージ2354716
Ref: whatsnew/2 6 pep-03712354947
Ref: 12852354947
Ref: whatsnew/2 6 pep-371-the-multiprocessing-package2354947
Ref: 13552354947
Ref: PEP 371 multiprocessing パッケージ-Footnote-12360986
Node: PEP 3101 進化版文字列フォーマッティング2361028
Ref: whatsnew/2 6 pep-31012361233
Ref: 12862361233
Ref: whatsnew/2 6 pep-3101-advanced-string-formatting2361233
Ref: 13572361233
Ref: PEP 3101 進化版文字列フォーマッティング-Footnote-12367468
Node: PEP 3105 print を関数にする2367510
Ref: whatsnew/2 6 pep-31052367706
Ref: 12872367706
Ref: whatsnew/2 6 pep-3105-print-as-a-function2367706
Ref: 13592367706
Ref: PEP 3105 print を関数にする-Footnote-12368995
Node: PEP 3110 例外処理の変更2369037
Ref: whatsnew/2 6 pep-31102369209
Ref: 12882369209
Ref: whatsnew/2 6 pep-3110-exception-handling-changes2369209
Ref: 135a2369209
Ref: PEP 3110 例外処理の変更-Footnote-12371075
Node: PEP 3112 バイトリテラル2371117
Ref: whatsnew/2 6 pep-31122371294
Ref: 12892371294
Ref: whatsnew/2 6 pep-3112-byte-literals2371294
Ref: 135b2371294
Ref: PEP 3112 バイトリテラル-Footnote-12374885
Node: PEP 3116 新しい I/O ライブラリ2374927
Ref: whatsnew/2 6 pep-31162375119
Ref: 128a2375119
Ref: whatsnew/2 6 pep-3116-new-i-o-library2375119
Ref: 13602375119
Ref: PEP 3116 新しい I/O ライブラリ-Footnote-12379904
Node: PEP 3118 改訂版バッファプロトコル2379946
Ref: whatsnew/2 6 pep-31182380138
Ref: 128b2380138
Ref: whatsnew/2 6 pep-3118-revised-buffer-protocol2380138
Ref: 13612380138
Ref: PEP 3118 改訂版バッファプロトコル-Footnote-12382689
Node: PEP 3119 抽象基底クラス2382731
Ref: whatsnew/2 6 pep-31192382936
Ref: 128c2382936
Ref: whatsnew/2 6 pep-3119-abstract-base-classes2382936
Ref: 13652382936
Ref: PEP 3119 抽象基底クラス-Footnote-12389692
Node: PEP 3127 整数リテラルのサポートと文法2389734
Ref: whatsnew/2 6 pep-31272389927
Ref: 128d2389927
Ref: whatsnew/2 6 pep-3127-integer-literal-support-and-syntax2389927
Ref: 13662389927
Ref: PEP 3127 整数リテラルのサポートと文法-Footnote-12391531
Node: PEP 3129 クラスデコレータ2391573
Ref: whatsnew/2 6 pep-31292391763
Ref: 128e2391763
Ref: whatsnew/2 6 pep-3129-class-decorators2391763
Ref: 13672391763
Ref: PEP 3129 クラスデコレータ-Footnote-12392237
Node: PEP 3141 数値の型階層2392279
Ref: whatsnew/2 6 pep-31412392446
Ref: 128f2392446
Ref: whatsnew/2 6 pep-3141-a-type-hierarchy-for-numbers2392446
Ref: 13682392446
Ref: PEP 3141 数値の型階層-Footnote-12394991
Ref: PEP 3141 数値の型階層-Footnote-22395033
Ref: PEP 3141 数値の型階層-Footnote-32395131
Node: fractions モジュール2395237
Ref: whatsnew/2 6 the-fractions-module2395326
Ref: 136c2395326
Node: その他の言語変更<13>2397073
Ref: whatsnew/2 6 other-language-changes2397267
Ref: 136d2397267
Ref: その他の言語変更<13>-Footnote-12407467
Ref: その他の言語変更<13>-Footnote-22407534
Ref: その他の言語変更<13>-Footnote-32407598
Ref: その他の言語変更<13>-Footnote-42407665
Ref: その他の言語変更<13>-Footnote-52407729
Ref: その他の言語変更<13>-Footnote-62407793
Ref: その他の言語変更<13>-Footnote-72407857
Ref: その他の言語変更<13>-Footnote-82407921
Ref: その他の言語変更<13>-Footnote-92407985
Ref: その他の言語変更<13>-Footnote-102408049
Ref: その他の言語変更<13>-Footnote-112408114
Ref: その他の言語変更<13>-Footnote-122408179
Ref: その他の言語変更<13>-Footnote-132408247
Ref: その他の言語変更<13>-Footnote-142408315
Ref: その他の言語変更<13>-Footnote-152408383
Ref: その他の言語変更<13>-Footnote-162408451
Node: 最適化<12>2408519
Ref: whatsnew/2 6 optimizations2408636
Ref: 13712408636
Ref: 最適化<12>-Footnote-12412474
Ref: 最適化<12>-Footnote-22412541
Ref: 最適化<12>-Footnote-32412608
Ref: 最適化<12>-Footnote-42412672
Node: インタプリタの変更<2>2412736
Ref: whatsnew/2 6 interpreter-changes2412853
Ref: 13722412853
Ref: whatsnew/2 6 new-26-interpreter2412853
Ref: 13732412853
Node: 新しいモジュールと改良されたモジュール<2>2414793
Ref: whatsnew/2 6 new-and-improved-modules2414978
Ref: 13772414978
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-12468645
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-22468712
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-32468765
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-42468829
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-52468895
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-62468959
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-72469026
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-82469090
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-92469144
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-102469211
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-112469279
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-122469347
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-132469412
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-142469477
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-152469544
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-162469609
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-172469677
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-182469742
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-192469810
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-202469878
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-212469946
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-222470013
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-232470081
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-242470149
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-252470214
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-262470279
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-272470347
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-282470415
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-292470482
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-302470547
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-312470612
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-322470677
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-332470742
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-342470807
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-352470872
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-362470937
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-372470997
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-382471064
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-392471124
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-402471191
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-412471256
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-422471323
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-432471391
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-442471456
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-452471521
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-462471586
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-472471654
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-482471719
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-492471784
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-502471852
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-512471917
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-522471985
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-532472050
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-542472118
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-552472183
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-562472251
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-572472316
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-582472384
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-592472452
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-602472517
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-612472582
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-622472649
Ref: 新しいモジュールと改良されたモジュール<2>-Footnote-632472717
Node: ast モジュール2472785
Ref: whatsnew/2 6 the-ast-module2472941
Ref: 138c2472941
Node: future_builtins モジュール2475927
Ref: whatsnew/2 6 the-future-builtins-module2476148
Ref: 138d2476148
Node: json モジュール JavaScript オブジェクト記法2477473
Ref: whatsnew/2 6 the-json-module-javascript-object-notation2477733
Ref: 138f2477733
Node: plistlib モジュール プロパティリストパーサ2479042
Ref: whatsnew/2 6 the-plistlib-module-a-property-list-parser2479287
Ref: 13902479287
Node: ctypes の強化2480803
Ref: whatsnew/2 6 ctypes-enhancements2481017
Ref: 13912481017
Ref: ctypes の強化-Footnote-12483215
Ref: ctypes の強化-Footnote-22483282
Node: SSL サポートの改善2483346
Ref: whatsnew/2 6 improved-ssl-support2483493
Ref: 13922483493
Ref: SSL サポートの改善-Footnote-12484835
Node: 非推奨と削除2484868
Ref: whatsnew/2 6 deprecations-and-removals2485065
Ref: 13932485065
Ref: 非推奨と削除-Footnote-12487060
Node: ビルドならびに C API の変更<9>2487102
Ref: whatsnew/2 6 build-and-c-api-changes2487262
Ref: 13952487262
Ref: ビルドならびに C API の変更<9>-Footnote-12495913
Ref: ビルドならびに C API の変更<9>-Footnote-22495968
Ref: ビルドならびに C API の変更<9>-Footnote-32496023
Ref: ビルドならびに C API の変更<9>-Footnote-42496087
Ref: ビルドならびに C API の変更<9>-Footnote-52496154
Ref: ビルドならびに C API の変更<9>-Footnote-62496218
Ref: ビルドならびに C API の変更<9>-Footnote-72496282
Node: ポート特有の変更 Windows<2>2496349
Ref: whatsnew/2 6 port-specific-changes-windows2496506
Ref: 139c2496506
Ref: ポート特有の変更 Windows<2>-Footnote-12499125
Ref: ポート特有の変更 Windows<2>-Footnote-22499191
Ref: ポート特有の変更 Windows<2>-Footnote-32499258
Node: ポート特有の変更 Mac OS X<2>2499322
Ref: whatsnew/2 6 port-specific-changes-mac-os-x2499517
Ref: 13a12499517
Ref: ポート特有の変更 Mac OS X<2>-Footnote-12500835
Node: ポート特有の変更 IRIX2500902
Ref: whatsnew/2 6 port-specific-changes-irix2501053
Ref: 13a22501053
Node: Python 2 6 への移植2501570
Ref: whatsnew/2 6 porting-to-python-2-62501721
Ref: 13a32501721
Ref: Python 2 6 への移植-Footnote-12506510
Ref: Python 2 6 への移植-Footnote-22506577
Ref: Python 2 6 への移植-Footnote-32506644
Node: 謝辞<2>2506711
Ref: whatsnew/2 6 acknowledgements2506813
Ref: 13a52506813
Ref: whatsnew/2 6 acks2506813
Ref: 13a62506813
Node: What's New in Python 2 52507123
Ref: whatsnew/2 5 doc2507270
Ref: 13a72507270
Ref: whatsnew/2 5 what-s-new-in-python-2-52507270
Ref: 13a82507270
Ref: What's New in Python 2 5-Footnote-12511772
Node: PEP 308 条件式 Conditional Expressions2511814
Ref: whatsnew/2 5 pep-3082511954
Ref: 13a92511954
Ref: whatsnew/2 5 pep-308-conditional-expressions2511954
Ref: 13ae2511954
Ref: PEP 308 条件式 Conditional Expressions-Footnote-12516009
Ref: PEP 308 条件式 Conditional Expressions-Footnote-22516051
Node: PEP 309 関数の部分適用2516093
Ref: whatsnew/2 5 pep-3092516292
Ref: 13af2516292
Ref: whatsnew/2 5 pep-309-partial-function-application2516292
Ref: 13b02516292
Ref: PEP 309 関数の部分適用-Footnote-12520228
Node: PEP 314 Metadata for Python Software Packages v1 12520270
Ref: whatsnew/2 5 pep-3142520481
Ref: 13b12520481
Ref: whatsnew/2 5 pep-314-metadata-for-python-software-packages-v1-12520481
Ref: 13b22520481
Ref: PEP 314 Metadata for Python Software Packages v1 1-Footnote-12522746
Node: PEP 328 絶対インポート、相対インポート2522788
Ref: whatsnew/2 5 pep-3282523034
Ref: 13ac2523034
Ref: whatsnew/2 5 pep-328-absolute-and-relative-imports2523034
Ref: 13b32523034
Ref: PEP 328 絶対インポート、相対インポート-Footnote-12528335
Ref: PEP 328 絶対インポート、相対インポート-Footnote-22528377
Node: PEP 338 - モジュールをスクリプトとして実行する2528419
Ref: whatsnew/2 5 pep-3382528654
Ref: 13b42528654
Ref: whatsnew/2 5 pep-338-executing-modules-as-scripts2528654
Ref: 13b52528654
Ref: PEP 338 - モジュールをスクリプトとして実行する-Footnote-12529845
Node: PEP 341 try/except/finally の一体化2529887
Ref: whatsnew/2 5 pep-3412530107
Ref: 13ad2530107
Ref: whatsnew/2 5 pep-341-unified-try-except-finally2530107
Ref: 13b62530107
Ref: PEP 341 try/except/finally の一体化-Footnote-12532245
Node: PEP 342 ジェネレータの新機能2532287
Ref: whatsnew/2 5 pep-3422532482
Ref: 13ab2532482
Ref: whatsnew/2 5 pep-342-new-generator-features2532482
Ref: 13b72532482
Ref: PEP 342 ジェネレータの新機能-Footnote-12540069
Ref: PEP 342 ジェネレータの新機能-Footnote-22540111
Ref: PEP 342 ジェネレータの新機能-Footnote-32540153
Ref: PEP 342 ジェネレータの新機能-Footnote-42540195
Ref: PEP 342 ジェネレータの新機能-Footnote-52540237
Node: PEP 343 "with" ステートメント<2>2540279
Ref: whatsnew/2 5 pep-3432540479
Ref: 13aa2540479
Ref: whatsnew/2 5 pep-343-the-with-statement2540479
Ref: 13b82540479
Node: コンテキストマネージャを書く<2>2544068
Ref: whatsnew/2 5 new-25-context-managers2544227
Ref: 13b92544227
Ref: whatsnew/2 5 writing-context-managers2544227
Ref: 13ba2544227
Node: contextlib モジュール<2>2549743
Ref: whatsnew/2 5 contextlibmod2549902
Ref: 13bb2549902
Ref: whatsnew/2 5 the-contextlib-module2549902
Ref: 13bc2549902
Ref: contextlib モジュール<2>-Footnote-12552834
Node: PEP 352 例外の新スタイルクラス化2552876
Ref: whatsnew/2 5 pep-3522553079
Ref: 13bd2553079
Ref: whatsnew/2 5 pep-352-exceptions-as-new-style-classes2553079
Ref: 13be2553079
Ref: PEP 352 例外の新スタイルクラス化-Footnote-12556935
Node: PEP 353 添え字型に ssize_t を使う2556977
Ref: whatsnew/2 5 pep-3532557173
Ref: 13bf2557173
Ref: whatsnew/2 5 pep-353-using-ssize-t-as-the-index-type2557173
Ref: 13c02557173
Ref: PEP 353 添え字型に ssize_t を使う-Footnote-12560685
Ref: PEP 353 添え字型に ssize_t を使う-Footnote-22560727
Node: PEP 357 '__index__' メソッド2560769
Ref: whatsnew/2 5 pep-3572560949
Ref: 13c22560949
Ref: whatsnew/2 5 pep-357-the-index-method2560949
Ref: 13c32560949
Ref: PEP 357 '__index__' メソッド-Footnote-12562981
Node: その他の言語変更<14>2563023
Ref: whatsnew/2 5 other-lang2563252
Ref: 13c62563252
Ref: whatsnew/2 5 other-language-changes2563252
Ref: 13c72563252
Ref: その他の言語変更<14>-Footnote-12572590
Node: 対話的なインタプリタの変更2572632
Ref: whatsnew/2 5 interactive2572758
Ref: 13cd2572758
Ref: whatsnew/2 5 interactive-interpreter-changes2572758
Ref: 13ce2572758
Node: 最適化<13>2573831
Ref: whatsnew/2 5 optimizations2573957
Ref: 13d02573957
Ref: whatsnew/2 5 opts2573957
Ref: 13d12573957
Node: 新たなモジュール、改良されたモジュール、削除されたモジュール2578294
Ref: whatsnew/2 5 modules2578532
Ref: 13d22578532
Ref: whatsnew/2 5 new-improved-and-removed-modules2578532
Ref: 13d32578532
Ref: 新たなモジュール、改良されたモジュール、削除されたモジュール-Footnote-12608492
Ref: 新たなモジュール、改良されたモジュール、削除されたモジュール-Footnote-22608534
Ref: 新たなモジュール、改良されたモジュール、削除されたモジュール-Footnote-32608593
Node: ctypes パッケージ2608652
Ref: whatsnew/2 5 module-ctypes2608837
Ref: 13dd2608837
Ref: whatsnew/2 5 the-ctypes-package2608837
Ref: 13de2608837
Node: ElementTree パッケージ2612501
Ref: whatsnew/2 5 module-etree2612718
Ref: 13e02612718
Ref: whatsnew/2 5 the-elementtree-package2612718
Ref: 13e12612718
Node: hashlib パッケージ2618755
Ref: whatsnew/2 5 module-hashlib2618973
Ref: 13e22618973
Ref: whatsnew/2 5 the-hashlib-package2618973
Ref: 13e32618973
Node: sqlite3 パッケージ2620711
Ref: whatsnew/2 5 module-sqlite2620925
Ref: 13e42620925
Ref: whatsnew/2 5 the-sqlite3-package2620925
Ref: 13e52620925
Ref: sqlite3 パッケージ-Footnote-12625993
Ref: sqlite3 パッケージ-Footnote-22626035
Node: wsgiref パッケージ2626077
Ref: whatsnew/2 5 module-wsgiref2626259
Ref: 13e62626259
Ref: whatsnew/2 5 the-wsgiref-package2626259
Ref: 13e72626259
Ref: wsgiref パッケージ-Footnote-12627393
Ref: wsgiref パッケージ-Footnote-22627435
Node: ビルドならびに C API の変更<10>2627477
Ref: whatsnew/2 5 build-and-c-api-changes2627710
Ref: 13e82627710
Ref: whatsnew/2 5 build-api2627710
Ref: 13e92627710
Ref: ビルドならびに C API の変更<10>-Footnote-12635013
Ref: ビルドならびに C API の変更<10>-Footnote-22635055
Ref: ビルドならびに C API の変更<10>-Footnote-32635097
Node: ポート特有の変更2635139
Ref: whatsnew/2 5 port-specific-changes2635241
Ref: 13f32635241
Ref: whatsnew/2 5 ports2635241
Ref: 13f42635241
Ref: ポート特有の変更-Footnote-12636012
Node: Python 2 5 への移植2636076
Ref: whatsnew/2 5 porting2636228
Ref: 13f52636228
Ref: whatsnew/2 5 porting-to-python-2-52636228
Ref: 13f62636228
Ref: Python 2 5 への移植-Footnote-12639520
Node: 謝辞<3>2639562
Ref: whatsnew/2 5 acknowledgements2639664
Ref: 13f72639664
Node: What's New in Python 2 42640136
Ref: whatsnew/2 4 doc2640283
Ref: 13f82640283
Ref: whatsnew/2 4 what-s-new-in-python-2-42640283
Ref: 13f92640283
Node: PEP 218 ビルトインの集合オブジェクト2642969
Ref: whatsnew/2 4 pep-218-built-in-set-objects2643139
Ref: 13fa2643139
Ref: PEP 218 ビルトインの集合オブジェクト-Footnote-12645781
Node: PEP 237 長整数と整数を一体化していく2645823
Ref: whatsnew/2 4 pep-237-unifying-long-integers-and-integers2646031
Ref: 13fb2646031
Ref: PEP 237 長整数と整数を一体化していく-Footnote-12647324
Node: PEP 289 ジェネレータ式2647366
Ref: whatsnew/2 4 pep-289-generator-expressions2647582
Ref: 13fc2647582
Ref: PEP 289 ジェネレータ式-Footnote-12650323
Node: PEP 292 より単純な文字列置換 string substitution2650365
Ref: whatsnew/2 4 pep-292-simpler-string-substitutions2650587
Ref: 13fd2650587
Ref: PEP 292 より単純な文字列置換 string substitution-Footnote-12652930
Node: PEP 318 関数とメソッドのためのデコレータ2652972
Ref: whatsnew/2 4 pep-318-decorators-for-functions-and-methods2653203
Ref: 13fe2653203
Ref: PEP 318 関数とメソッドのためのデコレータ-Footnote-12658905
Ref: PEP 318 関数とメソッドのためのデコレータ-Footnote-22658947
Node: PEP 322 逆順のイテレーション2658989
Ref: whatsnew/2 4 pep-322-reverse-iteration2659206
Ref: 14002659206
Ref: PEP 322 逆順のイテレーション-Footnote-12660357
Node: PEP 324 新しい subprocess モジュール2660399
Ref: whatsnew/2 4 pep-324-new-subprocess-module2660588
Ref: 14012660588
Ref: PEP 324 新しい subprocess モジュール-Footnote-12665031
Node: PEP 327 Decimal データ型2665073
Ref: whatsnew/2 4 pep-327-decimal-data-type2665265
Ref: 14032665265
Node: なぜ Decimal が必要なのか?2665839
Ref: whatsnew/2 4 why-is-decimal-needed2665958
Ref: 14042665958
Node: Decimal 型2668828
Ref: whatsnew/2 4 the-decimal-type2668967
Ref: 14052668967
Node: Context 型2672468
Ref: whatsnew/2 4 the-context-type2672564
Ref: 14062672564
Ref: Context 型-Footnote-12675810
Ref: Context 型-Footnote-22675852
Node: PEP 328 マルチラインインポート2675935
Ref: whatsnew/2 4 pep-328-multi-line-imports2676136
Ref: 14072676136
Ref: PEP 328 マルチラインインポート-Footnote-12677951
Node: PEP 331 Locale に依存しない Float/String 変換2677993
Ref: whatsnew/2 4 pep-331-locale-independent-float-string-conversions2678194
Ref: 14082678194
Ref: PEP 331 Locale に依存しない Float/String 変換-Footnote-12680112
Ref: PEP 331 Locale に依存しない Float/String 変換-Footnote-22680202
Node: その他の言語変更<15>2680244
Ref: whatsnew/2 4 other-language-changes2680494
Ref: 14092680494
Ref: その他の言語変更<15>-Footnote-12688600
Ref: その他の言語変更<15>-Footnote-22688642
Ref: その他の言語変更<15>-Footnote-32688684
Ref: その他の言語変更<15>-Footnote-42688726
Ref: その他の言語変更<15>-Footnote-52688768
Ref: その他の言語変更<15>-Footnote-62688810
Node: 最適化<14>2688852
Ref: whatsnew/2 4 optimizations2688930
Ref: 140b2688930
Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>2691659
Ref: whatsnew/2 4 new-improved-and-deprecated-modules2691897
Ref: 140c2691897
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<3>-Footnote-12712598
Node: cookielib2712657
Ref: whatsnew/2 4 cookielib2712812
Ref: 14102712812
Node: doctest<5>2713899
Ref: whatsnew/2 4 doctest2714054
Ref: 14112714054
Node: ビルドならびに C API の変更<11>2717194
Ref: whatsnew/2 4 build-and-c-api-changes2717427
Ref: 14172717427
Node: ポート特有の変更<2>2720157
Ref: whatsnew/2 4 port-specific-changes2720262
Ref: 141d2720262
Node: Python 2 4 への移植2720438
Ref: whatsnew/2 4 porting-to-python-2-42720590
Ref: 141e2720590
Node: 謝辞<4>2723002
Ref: whatsnew/2 4 acknowledgements2723104
Ref: 14202723104
Ref: whatsnew/2 4 acks2723104
Ref: 14212723104
Node: What's New in Python 2 32723405
Ref: whatsnew/2 3 doc2723552
Ref: 14222723552
Ref: whatsnew/2 3 what-s-new-in-python-2-32723552
Ref: 14232723552
Node: PEP 218 標準の集合データ型2727556
Ref: whatsnew/2 3 pep-218-a-standard-set-datatype2727696
Ref: 14252727696
Ref: PEP 218 標準の集合データ型-Footnote-12731351
Node: PEP 255 単純なジェネレータ2731393
Ref: whatsnew/2 3 pep-255-simple-generators2731595
Ref: 142a2731595
Ref: whatsnew/2 3 section-generators2731595
Ref: 142b2731595
Ref: PEP 255 単純なジェネレータ-Footnote-12741015
Ref: PEP 255 単純なジェネレータ-Footnote-22741057
Node: PEP 263 ソースコードのエンコーディング2741099
Ref: whatsnew/2 3 pep-263-source-code-encodings2741338
Ref: 142c2741338
Ref: whatsnew/2 3 section-encodings2741338
Ref: 142d2741338
Ref: PEP 263 ソースコードのエンコーディング-Footnote-12743003
Node: PEP 273 Zip アーカイブからモジュールをインポートする2743045
Ref: whatsnew/2 3 pep-273-importing-modules-from-zip-archives2743310
Ref: 142e2743310
Ref: PEP 273 Zip アーカイブからモジュールをインポートする-Footnote-12745760
Ref: PEP 273 Zip アーカイブからモジュールをインポートする-Footnote-22745802
Ref: PEP 273 Zip アーカイブからモジュールをインポートする-Footnote-32745844
Node: PEP 277 Windows NT での Unicode ファイル名サポート2745886
Ref: whatsnew/2 3 pep-277-unicode-file-name-support-for-windows-nt2746136
Ref: 14302746136
Ref: PEP 277 Windows NT での Unicode ファイル名サポート-Footnote-12748289
Node: PEP 278 Universal Newline サポート2748331
Ref: whatsnew/2 3 pep-278-universal-newline-support2748526
Ref: 14322748526
Ref: PEP 278 Universal Newline サポート-Footnote-12750408
Node: PEP 279 enumerate2750450
Ref: whatsnew/2 3 pep-279-enumerate2750619
Ref: 14332750619
Ref: whatsnew/2 3 section-enumerate2750619
Ref: 14342750619
Ref: PEP 279 enumerate-Footnote-12751587
Node: PEP 282 ロギングパッケージ2751629
Ref: whatsnew/2 3 pep-282-the-logging-package2751779
Ref: 14352751779
Ref: PEP 282 ロギングパッケージ-Footnote-12757243
Ref: PEP 282 ロギングパッケージ-Footnote-22757285
Node: PEP 285 Boolean 型2757327
Ref: whatsnew/2 3 pep-285-a-boolean-type2757525
Ref: 143b2757525
Ref: whatsnew/2 3 section-bool2757525
Ref: 143c2757525
Ref: PEP 285 Boolean 型-Footnote-12760486
Ref: PEP 285 Boolean 型-Footnote-22760528
Node: PEP 293 コーデックエラーを処理するコールバック2760570
Ref: whatsnew/2 3 pep-293-codec-error-handling-callbacks2760815
Ref: 143d2760815
Ref: PEP 293 コーデックエラーを処理するコールバック-Footnote-12762750
Node: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ2762792
Ref: whatsnew/2 3 pep-301-package-index-and-metadata-for-distutils2763059
Ref: 14402763059
Ref: whatsnew/2 3 section-pep3012763059
Ref: 14412763059
Ref: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ-Footnote-12764936
Ref: PEP 301 パッケージインデクスと、 Distutils のためのメタデータ-Footnote-22764972
Node: PEP 302 新たなインポートフック2765014
Ref: whatsnew/2 3 pep-302-new-import-hooks2765260
Ref: 14422765260
Ref: whatsnew/2 3 section-pep3022765260
Ref: 142f2765260
Ref: PEP 302 新たなインポートフック-Footnote-12768995
Ref: PEP 302 新たなインポートフック-Footnote-22769037
Ref: PEP 302 新たなインポートフック-Footnote-32769079
Node: PEP 305 カンマ区切り形式ファイル2769121
Ref: whatsnew/2 3 pep-305-comma-separated-files2769315
Ref: 14432769315
Ref: whatsnew/2 3 section-pep3052769315
Ref: 14442769315
Ref: PEP 305 カンマ区切り形式ファイル-Footnote-12771109
Node: PEP 307 Pickle の機能拡張2771151
Ref: whatsnew/2 3 pep-307-pickle-enhancements2771322
Ref: 14452771322
Ref: whatsnew/2 3 section-pep3072771322
Ref: 14462771322
Ref: PEP 307 Pickle の機能拡張-Footnote-12773629
Ref: PEP 307 Pickle の機能拡張-Footnote-22773671
Ref: PEP 307 Pickle の機能拡張-Footnote-32773713
Node: 拡張スライス2773755
Ref: whatsnew/2 3 extended-slices2773910
Ref: 144b2773910
Ref: whatsnew/2 3 section-slices2773910
Ref: 144c2773910
Node: その他の言語変更<16>2777968
Ref: whatsnew/2 3 other-language-changes2778183
Ref: 144d2778183
Ref: その他の言語変更<16>-Footnote-12787198
Node: 文字列に関する変更2787271
Ref: whatsnew/2 3 string-changes2787385
Ref: 14532787385
Node: 最適化<15>2790148
Ref: whatsnew/2 3 optimizations2790262
Ref: 14582790262
Node: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>2791713
Ref: whatsnew/2 3 new-improved-and-deprecated-modules2791970
Ref: 145a2791970
Ref: 新たなモジュール、改良されたモジュール、非推奨のモジュール<4>-Footnote-12819763
Node: 日付時刻型2819803
Ref: whatsnew/2 3 date-time-type2819978
Ref: 14722819978
Node: optparse モジュール2822927
Ref: whatsnew/2 3 the-optparse-module2823102
Ref: 14752823102
Node: Pymalloc 特殊化されたオブジェクトアロケータ2825663
Ref: whatsnew/2 3 pymalloc-a-specialized-object-allocator2825933
Ref: 14782825933
Ref: whatsnew/2 3 section-pymalloc2825933
Ref: 14792825933
Node: ビルドならびに C API の変更<12>2831038
Ref: whatsnew/2 3 build-and-c-api-changes2831248
Ref: 147b2831248
Node: ポート特有の変更<3>2835412
Ref: whatsnew/2 3 port-specific-changes2835517
Ref: 14812835517
Node: その他の変更と修正<2>2836746
Ref: whatsnew/2 3 other-changes-and-fixes2836919
Ref: 14822836919
Ref: whatsnew/2 3 section-other2836919
Ref: 14592836919
Node: Python 2 3 への移植2840028
Ref: whatsnew/2 3 porting-to-python-2-32840169
Ref: 14852840169
Node: 謝辞<5>2844451
Ref: whatsnew/2 3 acknowledgements2844553
Ref: 14862844553
Ref: whatsnew/2 3 acks2844553
Ref: 14872844553
Node: What's New in Python 2 22845142
Ref: whatsnew/2 2 doc2845289
Ref: 14882845289
Ref: whatsnew/2 2 what-s-new-in-python-2-22845289
Ref: 14892845289
Node: はじめに2846205
Ref: whatsnew/2 2 introduction2846343
Ref: 148a2846343
Ref: はじめに-Footnote-12847554
Ref: はじめに-Footnote-22847603
Node: PEP 252 と PEP 253 型とクラスについての変更2847652
Ref: whatsnew/2 2 peps-252-and-253-type-and-class-changes2847822
Ref: 148b2847822
Node: 旧と新クラス2851991
Ref: whatsnew/2 2 old-and-new-classes2852129
Ref: 148e2852129
Ref: 旧と新クラス-Footnote-12855061
Node: デスクリプタ2855103
Ref: whatsnew/2 2 descriptors2855290
Ref: 148f2855290
Node: 多重継承 ダイヤモンドルール2859514
Ref: whatsnew/2 2 multiple-inheritance-the-diamond-rule2859701
Ref: 14912859701
Ref: 多重継承 ダイヤモンドルール-Footnote-12862727
Node: 属性アクセス2862769
Ref: whatsnew/2 2 attribute-access2862953
Ref: 14922862953
Node: 関連リンク2866951
Ref: whatsnew/2 2 related-links2867086
Ref: 14942867086
Ref: whatsnew/2 2 sect-rellinks2867086
Ref: 148d2867086
Ref: 関連リンク-Footnote-12869053
Ref: 関連リンク-Footnote-22869095
Ref: 関連リンク-Footnote-32869137
Ref: 関連リンク-Footnote-42869179
Ref: 関連リンク-Footnote-52869221
Node: PEP 234 イテレータ2869263
Ref: whatsnew/2 2 pep-234-iterators2869459
Ref: 14962869459
Ref: PEP 234 イテレータ-Footnote-12874870
Node: PEP 255 単純なジェネレータ<2>2874912
Ref: whatsnew/2 2 pep-255-simple-generators2875105
Ref: 14992875105
Ref: PEP 255 単純なジェネレータ<2>-Footnote-12884406
Ref: PEP 255 単純なジェネレータ<2>-Footnote-22884448
Node: PEP 237 長整数と整数を一体化していく<2>2884490
Ref: whatsnew/2 2 pep-237-unifying-long-integers-and-integers2884704
Ref: 149a2884704
Ref: PEP 237 長整数と整数を一体化していく<2>-Footnote-12887178
Node: PEP 238 除算演算子を変更していく2887220
Ref: whatsnew/2 2 pep-238-changing-the-division-operator2887413
Ref: 149b2887413
Ref: PEP 238 除算演算子を変更していく-Footnote-12892070
Ref: PEP 238 除算演算子を変更していく-Footnote-22892112
Ref: PEP 238 除算演算子を変更していく-Footnote-32892154
Node: Unicode の変更2892196
Ref: whatsnew/2 2 unicode-changes2892371
Ref: 149e2892371
Ref: Unicode の変更-Footnote-12895626
Ref: Unicode の変更-Footnote-22895668
Node: PEP 227 入れ子状のスコープ2895710
Ref: whatsnew/2 2 pep-227-nested-scopes2895901
Ref: 149f2895901
Ref: PEP 227 入れ子状のスコープ-Footnote-12901008
Node: 新しいモジュールと改良されたモジュール<3>2901050
Ref: whatsnew/2 2 new-and-improved-modules2901260
Ref: 14a02901260
Ref: 新しいモジュールと改良されたモジュール<3>-Footnote-12908561
Ref: 新しいモジュールと改良されたモジュール<3>-Footnote-22908620
Ref: 新しいモジュールと改良されたモジュール<3>-Footnote-32908679
Ref: 新しいモジュールと改良されたモジュール<3>-Footnote-42908738
Ref: 新しいモジュールと改良されたモジュール<3>-Footnote-52908797
Node: インタプリタの変更と修正2908855
Ref: whatsnew/2 2 interpreter-changes-and-fixes2909060
Ref: 14a52909060
Node: その他の変更と修正<3>2914662
Ref: whatsnew/2 2 other-changes-and-fixes2914816
Ref: 14b72914816
Ref: その他の変更と修正<3>-Footnote-12922594
Node: 謝辞<6>2922636
Ref: whatsnew/2 2 acknowledgements2922745
Ref: 14ba2922745
Node: What's New in Python 2 12923312
Ref: whatsnew/2 1 doc2923459
Ref: 14bb2923459
Ref: whatsnew/2 1 what-s-new-in-python-2-12923459
Ref: 14bc2923459
Node: はじめに<2>2924770
Ref: whatsnew/2 1 introduction2924893
Ref: 14bd2924893
Node: PEP 227 入れ子状のスコープ<2>2926083
Ref: whatsnew/2 1 pep-227-nested-scopes2926243
Ref: 14be2926243
Ref: PEP 227 入れ子状のスコープ<2>-Footnote-12931467
Ref: PEP 227 入れ子状のスコープ<2>-Footnote-22931509
Ref: PEP 227 入れ子状のスコープ<2>-Footnote-32931551
Node: PEP 236 __future__ 指示文2931593
Ref: whatsnew/2 1 pep-236-future-directives2931758
Ref: 14bf2931758
Ref: PEP 236 __future__ 指示文-Footnote-12933383
Node: PEP 207 拡張比較2933425
Ref: whatsnew/2 1 pep-207-rich-comparisons2933587
Ref: 14c02933587
Ref: PEP 207 拡張比較-Footnote-12937200
Ref: PEP 207 拡張比較-Footnote-22937242
Node: PEP 230 警告フレームワーク2937284
Ref: whatsnew/2 1 pep-230-warning-framework2937456
Ref: 14c22937456
Ref: PEP 230 警告フレームワーク-Footnote-12941284
Ref: PEP 230 警告フレームワーク-Footnote-22941326
Node: PEP 229 新しいビルドシステム2941368
Ref: whatsnew/2 1 pep-229-new-build-system2941537
Ref: 14c42941537
Ref: PEP 229 新しいビルドシステム-Footnote-12944330
Node: PEP 205 弱参照2944372
Ref: whatsnew/2 1 pep-205-weak-references2944529
Ref: 14c52944529
Ref: PEP 205 弱参照-Footnote-12948096
Node: PEP 232 関数の属性2948138
Ref: whatsnew/2 1 pep-232-function-attributes2948361
Ref: 14c62948361
Ref: PEP 232 関数の属性-Footnote-12949889
Node: PEP 235 大文字小文字を区別しないプラットフォームでのモジュールの読み込み2949931
Ref: whatsnew/2 1 pep-235-importing-modules-on-case-insensitive-platforms2950176
Ref: 14c72950176
Node: PEP 217 対話モード用 Display Hook2951450
Ref: whatsnew/2 1 pep-217-interactive-display-hook2951707
Ref: 14c82951707
Ref: PEP 217 対話モード用 Display Hook-Footnote-12952698
Node: PEP 208 新しい型強制モデル2952740
Ref: whatsnew/2 1 pep-208-new-coercion-model2952967
Ref: 14ca2952967
Ref: PEP 208 新しい型強制モデル-Footnote-12954927
Node: PEP 241 Pythonソフトウェアパッケージのためのメタデータ2954969
Ref: whatsnew/2 1 pep-241-metadata-in-python-packages2955217
Ref: 14cb2955217
Ref: PEP 241 Pythonソフトウェアパッケージのためのメタデータ-Footnote-12958054
Ref: PEP 241 Pythonソフトウェアパッケージのためのメタデータ-Footnote-22958096
Ref: PEP 241 Pythonソフトウェアパッケージのためのメタデータ-Footnote-32958138
Ref: PEP 241 Pythonソフトウェアパッケージのためのメタデータ-Footnote-42958180
Node: 新しいモジュールと改良されたモジュール<4>2958222
Ref: whatsnew/2 1 new-and-improved-modules2958465
Ref: 14cc2958465
Node: その他の変更と修正<4>2965502
Ref: whatsnew/2 1 other-changes-and-fixes2965680
Ref: 14cd2965680
Node: 謝辞<7>2972488
Ref: whatsnew/2 1 acknowledgements2972597
Ref: 14d12972597
Node: What's New in Python 2 02972886
Ref: whatsnew/2 0 doc2973021
Ref: 14d22973021
Ref: whatsnew/2 0 what-s-new-in-python-2-02973021
Ref: 14d32973021
Node: はじめに<3>2973947
Ref: whatsnew/2 0 introduction2974065
Ref: 14d42974065
Node: Python 1 6 はいかがですか?2975252
Ref: whatsnew/2 0 what-about-python-1-62975406
Ref: 14d52975406
Node: 新しい開発プロセス2977098
Ref: whatsnew/2 0 new-development-process2977260
Ref: 14d62977260
Ref: 新しい開発プロセス-Footnote-12984173
Ref: 新しい開発プロセス-Footnote-22984215
Ref: 新しい開発プロセス-Footnote-32984257
Node: Unicode 文字列型<2>2984299
Ref: whatsnew/2 0 unicode2984452
Ref: 14d72984452
Ref: Unicode 文字列型<2>-Footnote-12993048
Node: リストの内包表記2993090
Ref: whatsnew/2 0 list-comprehensions2993249
Ref: 14d82993249
Node: 累算代入 Augmented Assignment2997677
Ref: whatsnew/2 0 augmented-assignment2997834
Ref: 14d92997834
Node: 文字列メソッド2999439
Ref: whatsnew/2 0 string-methods2999617
Ref: 14da2999617
Node: 循環参照のガベージコレクション3001669
Ref: whatsnew/2 0 garbage-collection-of-cycles3001847
Ref: 14db3001847
Node: その他の言語コアの変更3006779
Ref: whatsnew/2 0 other-core-changes3006959
Ref: 14dc3006959
Node: 言語のマイナー変更3007313
Ref: whatsnew/2 0 minor-language-changes3007449
Ref: 14dd3007449
Node: ビルトイン関数の変更3013032
Ref: whatsnew/2 0 changes-to-built-in-functions3013168
Ref: 14e03013168
Node: Python 2 0 への移植3016061
Ref: whatsnew/2 0 porting-to-2-03016238
Ref: 14e13016238
Node: 拡張と埋め込みについての変更3022440
Ref: whatsnew/2 0 extending-embedding-changes3022636
Ref: 14e33022636
Node: Distutils モジュールの簡単インストール3028124
Ref: whatsnew/2 0 distutils-making-modules-easy-to-install3028316
Ref: 14e83028316
Node: XML モジュール3032259
Ref: whatsnew/2 0 xml-modules3032439
Ref: 14e93032439
Node: SAX2 サポート3033354
Ref: whatsnew/2 0 sax2-support3033452
Ref: 14ea3033452
Node: DOM サポート3035310
Ref: whatsnew/2 0 dom-support3035435
Ref: 14ee3035435
Node: PyXML との関係3038503
Ref: whatsnew/2 0 relationship-to-pyxml3038602
Ref: 14ef3038602
Node: 更新されたモジュール3040083
Ref: whatsnew/2 0 module-changes3040235
Ref: 14f03040235
Node: 新しいモジュール3042947
Ref: whatsnew/2 0 new-modules3043094
Ref: 14f13043094
Node: IDLE の改善3047796
Ref: whatsnew/2 0 idle-improvements3047982
Ref: 14f23047982
Node: 削除されたモジュール、非推奨となったモジュール3049686
Ref: whatsnew/2 0 deleted-and-deprecated-modules3049857
Ref: 14f33049857
Node: 謝辞<8>3050656
Ref: whatsnew/2 0 acknowledgements3050804
Ref: 14f43050804
Ref: 謝辞<8>-Footnote-13051437
Ref: 謝辞<8>-Footnote-23051501
Node: 変更履歴3051541
Ref: whatsnew/changelog doc3051643
Ref: 14f53051643
Ref: whatsnew/changelog changelog3051643
Ref: 1223051643
Ref: whatsnew/changelog id13051643
Ref: 14f63051643
Node: Python next3057170
Ref: whatsnew/changelog python-next3057258
Ref: 14f73057258
Node: macOS3057485
Ref: whatsnew/changelog macos3057554
Ref: 14f83057554
Ref: macOS-Footnote-13057693
Node: Windows3057749
Ref: whatsnew/changelog windows3057838
Ref: 14f93057838
Ref: Windows-Footnote-13058859
Ref: Windows-Footnote-23058915
Ref: Windows-Footnote-33058971
Ref: Windows-Footnote-43059027
Ref: Windows-Footnote-53059083
Ref: Windows-Footnote-63059139
Ref: Windows-Footnote-73059195
Ref: Windows-Footnote-83059251
Node: Tools/Demos3059307
Ref: whatsnew/changelog tools-demos3059396
Ref: 14fa3059396
Ref: Tools/Demos-Footnote-13059607
Node: Tests3059663
Ref: whatsnew/changelog tests3059753
Ref: 14fb3059753
Ref: Tests-Footnote-13060157
Ref: Tests-Footnote-23060213
Node: Security3060269
Ref: whatsnew/changelog security3060355
Ref: 14fc3060355
Ref: Security-Footnote-13060567
Ref: Security-Footnote-23060623
Node: Library3060679
Ref: whatsnew/changelog library3060767
Ref: 14fd3060767
Ref: Library-Footnote-13077519
Ref: Library-Footnote-23077575
Ref: Library-Footnote-33077631
Ref: Library-Footnote-43077687
Ref: Library-Footnote-53077743
Ref: Library-Footnote-63077799
Ref: Library-Footnote-73077855
Ref: Library-Footnote-83077911
Ref: Library-Footnote-93077967
Ref: Library-Footnote-103078023
Ref: Library-Footnote-113078080
Ref: Library-Footnote-123078137
Ref: Library-Footnote-133078194
Ref: Library-Footnote-143078251
Ref: Library-Footnote-153078308
Ref: Library-Footnote-163078365
Ref: Library-Footnote-173078422
Ref: Library-Footnote-183078479
Ref: Library-Footnote-193078536
Ref: Library-Footnote-203078593
Ref: Library-Footnote-213078650
Ref: Library-Footnote-223078707
Ref: Library-Footnote-233078764
Ref: Library-Footnote-243078821
Ref: Library-Footnote-253078878
Ref: Library-Footnote-263078935
Ref: Library-Footnote-273078992
Ref: Library-Footnote-283079049
Ref: Library-Footnote-293079106
Ref: Library-Footnote-303079163
Ref: Library-Footnote-313079220
Ref: Library-Footnote-323079277
Ref: Library-Footnote-333079334
Ref: Library-Footnote-343079391
Ref: Library-Footnote-353079448
Ref: Library-Footnote-363079505
Ref: Library-Footnote-373079562
Ref: Library-Footnote-383079619
Ref: Library-Footnote-393079676
Ref: Library-Footnote-403079733
Ref: Library-Footnote-413079790
Ref: Library-Footnote-423079846
Ref: Library-Footnote-433079903
Ref: Library-Footnote-443079960
Ref: Library-Footnote-453080017
Ref: Library-Footnote-463080074
Ref: Library-Footnote-473080131
Ref: Library-Footnote-483080188
Ref: Library-Footnote-493080244
Ref: Library-Footnote-503080300
Ref: Library-Footnote-513080357
Ref: Library-Footnote-523080414
Ref: Library-Footnote-533080471
Ref: Library-Footnote-543080528
Ref: Library-Footnote-553080585
Ref: Library-Footnote-563080642
Ref: Library-Footnote-573080698
Ref: Library-Footnote-583080755
Ref: Library-Footnote-593080812
Ref: Library-Footnote-603080869
Ref: Library-Footnote-613080926
Ref: Library-Footnote-623080983
Ref: Library-Footnote-633081040
Ref: Library-Footnote-643081096
Ref: Library-Footnote-653081153
Ref: Library-Footnote-663081209
Ref: Library-Footnote-673081265
Ref: Library-Footnote-683081322
Ref: Library-Footnote-693081379
Ref: Library-Footnote-703081435
Ref: Library-Footnote-713081492
Ref: Library-Footnote-723081549
Ref: Library-Footnote-733081605
Ref: Library-Footnote-743081661
Ref: Library-Footnote-753081717
Ref: Library-Footnote-763081773
Ref: Library-Footnote-773081830
Ref: Library-Footnote-783081886
Ref: Library-Footnote-793081943
Ref: Library-Footnote-803082000
Ref: Library-Footnote-813082057
Ref: Library-Footnote-823082114
Ref: Library-Footnote-833082171
Ref: Library-Footnote-843082227
Ref: Library-Footnote-853082284
Ref: Library-Footnote-863082341
Ref: Library-Footnote-873082397
Ref: Library-Footnote-883082463
Node: IDLE<3>3082529
Ref: whatsnew/changelog idle3082622
Ref: 15133082622
Ref: IDLE<3>-Footnote-13082841
Node: Documentation3082897
Ref: whatsnew/changelog documentation3083000
Ref: 15143083000
Ref: Documentation-Footnote-13084806
Ref: Documentation-Footnote-23084862
Ref: Documentation-Footnote-33084918
Ref: Documentation-Footnote-43084974
Ref: Documentation-Footnote-53085029
Ref: Documentation-Footnote-63085085
Ref: Documentation-Footnote-73085140
Node: Core and Builtins3085205
Ref: whatsnew/changelog core-and-builtins3085306
Ref: 15193085306
Ref: Core and Builtins-Footnote-13088882
Ref: Core and Builtins-Footnote-23088938
Ref: Core and Builtins-Footnote-33088994
Ref: Core and Builtins-Footnote-43089050
Ref: Core and Builtins-Footnote-53089106
Ref: Core and Builtins-Footnote-63089162
Ref: Core and Builtins-Footnote-73089218
Ref: Core and Builtins-Footnote-83089274
Ref: Core and Builtins-Footnote-93089330
Ref: Core and Builtins-Footnote-103089386
Ref: Core and Builtins-Footnote-113089443
Ref: Core and Builtins-Footnote-123089500
Ref: Core and Builtins-Footnote-133089557
Ref: Core and Builtins-Footnote-143089614
Ref: Core and Builtins-Footnote-153089671
Ref: Core and Builtins-Footnote-163089728
Ref: Core and Builtins-Footnote-173089785
Ref: Core and Builtins-Footnote-183089842
Ref: Core and Builtins-Footnote-193089899
Ref: Core and Builtins-Footnote-203089956
Node: C API3090013
Ref: whatsnew/changelog c-api3090106
Ref: 151e3090106
Ref: C API-Footnote-13090588
Ref: C API-Footnote-23090644
Node: Build3090709
Ref: whatsnew/changelog build3090776
Ref: 151f3090776
Ref: Build-Footnote-13091633
Ref: Build-Footnote-23091689
Ref: Build-Footnote-33091744
Ref: Build-Footnote-43091800
Ref: Build-Footnote-53091865
Ref: Build-Footnote-63091920
Ref: Build-Footnote-73091976
Ref: Build-Footnote-83092032
Ref: Build-Footnote-93092088
Node: Python 3 13 0 final3092144
Ref: whatsnew/changelog python-3-13-0-final3092274
Ref: 15203092274
Node: Core and Builtins<2>3092410
Ref: whatsnew/changelog id23092486
Ref: 15213092486
Ref: Core and Builtins<2>-Footnote-13092852
Ref: Core and Builtins<2>-Footnote-23092908
Node: Python 3 13 0 release candidate 33092964
Ref: whatsnew/changelog python-3-13-0-release-candidate-33093116
Ref: 15233093116
Node: macOS<2>3093454
Ref: whatsnew/changelog id33093551
Ref: 15243093551
Ref: macOS<2>-Footnote-13093712
Node: Windows<2>3093768
Ref: whatsnew/changelog id43093882
Ref: 15253093882
Ref: Windows<2>-Footnote-13094282
Ref: Windows<2>-Footnote-23094338
Ref: Windows<2>-Footnote-33094394
Node: Tests<2>3094450
Ref: whatsnew/changelog id53094566
Ref: 15263094566
Ref: Tests<2>-Footnote-13094704
Node: Library<2>3094760
Ref: whatsnew/changelog id63094873
Ref: 15273094873
Ref: Library<2>-Footnote-13097434
Ref: Library<2>-Footnote-23097490
Ref: Library<2>-Footnote-33097546
Ref: Library<2>-Footnote-43097602
Ref: Library<2>-Footnote-53097658
Ref: Library<2>-Footnote-63097714
Ref: Library<2>-Footnote-73097769
Ref: Library<2>-Footnote-83097825
Ref: Library<2>-Footnote-93097881
Ref: Library<2>-Footnote-103097937
Ref: Library<2>-Footnote-113097994
Ref: Library<2>-Footnote-123098051
Ref: Library<2>-Footnote-133098108
Ref: Library<2>-Footnote-143098165
Ref: Library<2>-Footnote-153098222
Ref: Library<2>-Footnote-163098279
Node: IDLE<4>3098345
Ref: whatsnew/changelog id73098466
Ref: 152b3098466
Ref: IDLE<4>-Footnote-13098703
Ref: IDLE<4>-Footnote-23098759
Node: Documentation<2>3098815
Ref: whatsnew/changelog id83098946
Ref: 152c3098946
Ref: Documentation<2>-Footnote-13099300
Ref: Documentation<2>-Footnote-23099356
Node: Core and Builtins<3>3099412
Ref: whatsnew/changelog id93099544
Ref: 152d3099544
Ref: Core and Builtins<3>-Footnote-13101431
Ref: Core and Builtins<3>-Footnote-23101487
Ref: Core and Builtins<3>-Footnote-33101543
Ref: Core and Builtins<3>-Footnote-43101599
Ref: Core and Builtins<3>-Footnote-53101655
Ref: Core and Builtins<3>-Footnote-63101711
Ref: Core and Builtins<3>-Footnote-73101767
Ref: Core and Builtins<3>-Footnote-83101823
Ref: Core and Builtins<3>-Footnote-93101878
Ref: Core and Builtins<3>-Footnote-103101934
Ref: Core and Builtins<3>-Footnote-113101990
Node: C API<2>3102047
Ref: whatsnew/changelog id103102171
Ref: 152e3102171
Ref: C API<2>-Footnote-13102494
Ref: C API<2>-Footnote-23102550
Node: Build<2>3102606
Ref: whatsnew/changelog id113102701
Ref: 152f3102701
Ref: Build<2>-Footnote-13103018
Ref: Build<2>-Footnote-23103074
Node: Python 3 13 0 release candidate 23103130
Ref: whatsnew/changelog python-3-13-0-release-candidate-23103296
Ref: 15303103296
Node: macOS<3>3103655
Ref: whatsnew/changelog id123103752
Ref: 15313103752
Ref: macOS<3>-Footnote-13103892
Node: Windows<3>3103948
Ref: whatsnew/changelog id133104068
Ref: 15323104068
Ref: Windows<3>-Footnote-13104523
Ref: Windows<3>-Footnote-23104579
Ref: Windows<3>-Footnote-33104635
Ref: Windows<3>-Footnote-43104691
Node: Tools/Demos<2>3104746
Ref: whatsnew/changelog id143104866
Ref: 15333104866
Ref: Tools/Demos<2>-Footnote-13105070
Node: Tests<3>3105126
Ref: whatsnew/changelog id153105247
Ref: 15343105247
Ref: Tests<3>-Footnote-13105548
Ref: Tests<3>-Footnote-23105604
Node: Security<2>3105660
Ref: whatsnew/changelog id163105777
Ref: 15353105777
Ref: Security<2>-Footnote-13106020
Ref: Security<2>-Footnote-23106076
Node: Library<3>3106132
Ref: whatsnew/changelog id173106248
Ref: 15363106248
Ref: Library<3>-Footnote-13111309
Ref: Library<3>-Footnote-23111365
Ref: Library<3>-Footnote-33111421
Ref: Library<3>-Footnote-43111477
Ref: Library<3>-Footnote-53111548
Ref: Library<3>-Footnote-63111604
Ref: Library<3>-Footnote-73111660
Ref: Library<3>-Footnote-83111716
Ref: Library<3>-Footnote-93111772
Ref: Library<3>-Footnote-103111828
Ref: Library<3>-Footnote-113111885
Ref: Library<3>-Footnote-123111942
Ref: Library<3>-Footnote-133111998
Ref: Library<3>-Footnote-143112055
Ref: Library<3>-Footnote-153112112
Ref: Library<3>-Footnote-163112169
Ref: Library<3>-Footnote-173112226
Ref: Library<3>-Footnote-183112283
Ref: Library<3>-Footnote-193112340
Ref: Library<3>-Footnote-203112397
Ref: Library<3>-Footnote-213112454
Ref: Library<3>-Footnote-223112511
Ref: Library<3>-Footnote-233112568
Ref: Library<3>-Footnote-243112625
Ref: Library<3>-Footnote-253112681
Ref: Library<3>-Footnote-263112738
Ref: Library<3>-Footnote-273112794
Ref: Library<3>-Footnote-283112851
Ref: Library<3>-Footnote-293112908
Ref: Library<3>-Footnote-303112965
Ref: Library<3>-Footnote-313113022
Ref: Library<3>-Footnote-323113079
Ref: Library<3>-Footnote-333113136
Ref: Library<3>-Footnote-343113193
Node: IDLE<5>3113250
Ref: whatsnew/changelog id183113375
Ref: 15413113375
Ref: IDLE<5>-Footnote-13113623
Node: Core and Builtins<4>3113679
Ref: whatsnew/changelog id193113802
Ref: 15423113802
Ref: Core and Builtins<4>-Footnote-13117465
Ref: Core and Builtins<4>-Footnote-23117521
Ref: Core and Builtins<4>-Footnote-33117577
Ref: Core and Builtins<4>-Footnote-43117633
Ref: Core and Builtins<4>-Footnote-53117689
Ref: Core and Builtins<4>-Footnote-63117745
Ref: Core and Builtins<4>-Footnote-73117801
Ref: Core and Builtins<4>-Footnote-83117857
Ref: Core and Builtins<4>-Footnote-93117913
Ref: Core and Builtins<4>-Footnote-103117969
Ref: Core and Builtins<4>-Footnote-113118026
Ref: Core and Builtins<4>-Footnote-123118083
Ref: Core and Builtins<4>-Footnote-133118140
Ref: Core and Builtins<4>-Footnote-143118197
Ref: Core and Builtins<4>-Footnote-153118254
Ref: Core and Builtins<4>-Footnote-163118311
Ref: Core and Builtins<4>-Footnote-173118368
Ref: Core and Builtins<4>-Footnote-183118425
Ref: Core and Builtins<4>-Footnote-193118482
Ref: Core and Builtins<4>-Footnote-203118539
Ref: Core and Builtins<4>-Footnote-213118596
Ref: Core and Builtins<4>-Footnote-223118653
Ref: Core and Builtins<4>-Footnote-233118710
Ref: Core and Builtins<4>-Footnote-243118767
Ref: Core and Builtins<4>-Footnote-253118824
Ref: Core and Builtins<4>-Footnote-263118880
Ref: Core and Builtins<4>-Footnote-273118936
Node: C API<3>3118993
Ref: whatsnew/changelog id203119117
Ref: 15443119117
Ref: C API<3>-Footnote-13119347
Node: Build<3>3119403
Ref: whatsnew/changelog id213119498
Ref: 15453119498
Ref: Build<3>-Footnote-13120391
Ref: Build<3>-Footnote-23120447
Ref: Build<3>-Footnote-33120503
Ref: Build<3>-Footnote-43120559
Ref: Build<3>-Footnote-53120615
Node: Python 3 13 0 release candidate 13120671
Ref: whatsnew/changelog python-3-13-0-release-candidate-13120824
Ref: 15463120824
Node: Tests<4>3121110
Ref: whatsnew/changelog id223121208
Ref: 15473121208
Ref: Tests<4>-Footnote-13121618
Ref: Tests<4>-Footnote-23121673
Node: Security<3>3121728
Ref: whatsnew/changelog id233121845
Ref: 154a3121845
Ref: Security<3>-Footnote-13122487
Ref: Security<3>-Footnote-23122543
Node: Library<4>3122599
Ref: whatsnew/changelog id243122715
Ref: 154b3122715
Ref: Library<4>-Footnote-13124720
Ref: Library<4>-Footnote-23124776
Ref: Library<4>-Footnote-33124832
Ref: Library<4>-Footnote-43124888
Ref: Library<4>-Footnote-53124944
Ref: Library<4>-Footnote-63125000
Ref: Library<4>-Footnote-73125056
Ref: Library<4>-Footnote-83125111
Ref: Library<4>-Footnote-93125167
Ref: Library<4>-Footnote-103125223
Ref: Library<4>-Footnote-113125280
Ref: Library<4>-Footnote-123125336
Ref: Library<4>-Footnote-133125393
Node: IDLE<6>3125450
Ref: whatsnew/changelog id253125575
Ref: 15503125575
Ref: IDLE<6>-Footnote-13125785
Node: Core and Builtins<5>3125841
Ref: whatsnew/changelog id263125964
Ref: 15513125964
Ref: Core and Builtins<5>-Footnote-13126991
Ref: Core and Builtins<5>-Footnote-23127047
Ref: Core and Builtins<5>-Footnote-33127103
Ref: Core and Builtins<5>-Footnote-43127159
Ref: Core and Builtins<5>-Footnote-53127215
Ref: Core and Builtins<5>-Footnote-63127271
Ref: Core and Builtins<5>-Footnote-73127327
Node: C API<4>3127383
Ref: whatsnew/changelog id273127507
Ref: 15533127507
Ref: C API<4>-Footnote-13127832
Ref: C API<4>-Footnote-23127888
Node: Build<4>3127944
Ref: whatsnew/changelog id283128039
Ref: 15553128039
Ref: Build<4>-Footnote-13128260
Node: Python 3 13 0 beta 43128316
Ref: whatsnew/changelog python-3-13-0-beta-43128456
Ref: 15573128456
Node: Tests<5>3128726
Ref: whatsnew/changelog id293128810
Ref: 15583128810
Ref: Tests<5>-Footnote-13129701
Ref: Tests<5>-Footnote-23129757
Ref: Tests<5>-Footnote-33129813
Ref: Tests<5>-Footnote-43129869
Node: Library<5>3129925
Ref: whatsnew/changelog id303130025
Ref: 155a3130025
Ref: Library<5>-Footnote-13132499
Ref: Library<5>-Footnote-23132554
Ref: Library<5>-Footnote-33132610
Ref: Library<5>-Footnote-43132666
Ref: Library<5>-Footnote-53132722
Ref: Library<5>-Footnote-63132778
Ref: Library<5>-Footnote-73132833
Ref: Library<5>-Footnote-83132889
Ref: Library<5>-Footnote-93132945
Ref: Library<5>-Footnote-103133001
Ref: Library<5>-Footnote-113133058
Ref: Library<5>-Footnote-123133115
Ref: Library<5>-Footnote-133133172
Ref: Library<5>-Footnote-143133229
Node: IDLE<7>3133286
Ref: whatsnew/changelog id313133394
Ref: 155c3133394
Ref: IDLE<7>-Footnote-13133592
Node: Documentation<3>3133647
Ref: whatsnew/changelog id323133765
Ref: 155d3133765
Ref: Documentation<3>-Footnote-13134133
Ref: Documentation<3>-Footnote-23134189
Node: Core and Builtins<6>3134245
Ref: whatsnew/changelog id333134364
Ref: 15603134364
Ref: Core and Builtins<6>-Footnote-13136355
Ref: Core and Builtins<6>-Footnote-23136411
Ref: Core and Builtins<6>-Footnote-33136467
Ref: Core and Builtins<6>-Footnote-43136523
Ref: Core and Builtins<6>-Footnote-53136579
Ref: Core and Builtins<6>-Footnote-63136635
Ref: Core and Builtins<6>-Footnote-73136691
Ref: Core and Builtins<6>-Footnote-83136747
Ref: Core and Builtins<6>-Footnote-93136803
Ref: Core and Builtins<6>-Footnote-103136859
Ref: Core and Builtins<6>-Footnote-113136916
Ref: Core and Builtins<6>-Footnote-123136973
Ref: Core and Builtins<6>-Footnote-133137030
Ref: Core and Builtins<6>-Footnote-143137087
Node: C API<5>3137144
Ref: whatsnew/changelog id343137255
Ref: 15613137255
Ref: C API<5>-Footnote-13138449
Ref: C API<5>-Footnote-23138504
Ref: C API<5>-Footnote-33138560
Ref: C API<5>-Footnote-43138616
Node: Build<5>3138672
Ref: whatsnew/changelog id353138754
Ref: 15663138754
Ref: Build<5>-Footnote-13139600
Ref: Build<5>-Footnote-23139656
Ref: Build<5>-Footnote-33139712
Ref: Build<5>-Footnote-43139768
Ref: Build<5>-Footnote-53139824
Ref: Build<5>-Footnote-63139880
Ref: Build<5>-Footnote-73139936
Node: Python 3 13 0 beta 33139992
Ref: whatsnew/changelog python-3-13-0-beta-33140119
Ref: 15673140119
Node: Core and Builtins<7>3140318
Ref: whatsnew/changelog id363140414
Ref: 15683140414
Ref: Core and Builtins<7>-Footnote-13143789
Ref: Core and Builtins<7>-Footnote-23143845
Ref: Core and Builtins<7>-Footnote-33143901
Ref: Core and Builtins<7>-Footnote-43143957
Ref: Core and Builtins<7>-Footnote-53144013
Ref: Core and Builtins<7>-Footnote-63144069
Ref: Core and Builtins<7>-Footnote-73144125
Ref: Core and Builtins<7>-Footnote-83144181
Ref: Core and Builtins<7>-Footnote-93144237
Ref: Core and Builtins<7>-Footnote-103144293
Ref: Core and Builtins<7>-Footnote-113144350
Ref: Core and Builtins<7>-Footnote-123144407
Ref: Core and Builtins<7>-Footnote-133144464
Ref: Core and Builtins<7>-Footnote-143144521
Ref: Core and Builtins<7>-Footnote-153144578
Ref: Core and Builtins<7>-Footnote-163144634
Ref: Core and Builtins<7>-Footnote-173144691
Ref: Core and Builtins<7>-Footnote-183144748
Ref: Core and Builtins<7>-Footnote-193144805
Ref: Core and Builtins<7>-Footnote-203144862
Ref: Core and Builtins<7>-Footnote-213144919
Node: Library<6>3144985
Ref: whatsnew/changelog id373145098
Ref: 15693145098
Ref: Library<6>-Footnote-13150602
Ref: Library<6>-Footnote-23150658
Ref: Library<6>-Footnote-33150714
Ref: Library<6>-Footnote-43150770
Ref: Library<6>-Footnote-53150826
Ref: Library<6>-Footnote-63150882
Ref: Library<6>-Footnote-73150938
Ref: Library<6>-Footnote-83150994
Ref: Library<6>-Footnote-93151050
Ref: Library<6>-Footnote-103151106
Ref: Library<6>-Footnote-113151163
Ref: Library<6>-Footnote-123151220
Ref: Library<6>-Footnote-133151277
Ref: Library<6>-Footnote-143151334
Ref: Library<6>-Footnote-153151391
Ref: Library<6>-Footnote-163151448
Ref: Library<6>-Footnote-173151504
Ref: Library<6>-Footnote-183151561
Ref: Library<6>-Footnote-193151618
Ref: Library<6>-Footnote-203151675
Ref: Library<6>-Footnote-213151732
Ref: Library<6>-Footnote-223151775
Ref: Library<6>-Footnote-233151832
Ref: Library<6>-Footnote-243151889
Ref: Library<6>-Footnote-253151946
Ref: Library<6>-Footnote-263152002
Ref: Library<6>-Footnote-273152059
Ref: Library<6>-Footnote-283152116
Ref: Library<6>-Footnote-293152173
Ref: Library<6>-Footnote-303152230
Ref: Library<6>-Footnote-313152287
Ref: Library<6>-Footnote-323152344
Ref: Library<6>-Footnote-333152400
Ref: Library<6>-Footnote-343152456
Ref: Library<6>-Footnote-353152513
Ref: Library<6>-Footnote-363152570
Node: Build<6>3152627
Ref: whatsnew/changelog id383152728
Ref: 15733152728
Ref: Build<6>-Footnote-13153270
Ref: Build<6>-Footnote-23153326
Ref: Build<6>-Footnote-33153382
Ref: Build<6>-Footnote-43153438
Node: C API<6>3153494
Ref: whatsnew/changelog id393153576
Ref: 15743153576
Ref: C API<6>-Footnote-13154751
Ref: C API<6>-Footnote-23154807
Ref: C API<6>-Footnote-33154863
Ref: C API<6>-Footnote-43154919
Ref: C API<6>-Footnote-53154975
Ref: C API<6>-Footnote-63155031
Node: Python 3 13 0 beta 23155087
Ref: whatsnew/changelog python-3-13-0-beta-23155214
Ref: 15773155214
Node: Security<4>3155480
Ref: whatsnew/changelog id403155577
Ref: 15783155577
Ref: Security<4>-Footnote-13156092
Ref: Security<4>-Footnote-23156148
Ref: Security<4>-Footnote-33156204
Node: Core and Builtins<8>3156259
Ref: whatsnew/changelog id413156375
Ref: 15793156375
Ref: Core and Builtins<8>-Footnote-13159170
Ref: Core and Builtins<8>-Footnote-23159226
Ref: Core and Builtins<8>-Footnote-33159282
Ref: Core and Builtins<8>-Footnote-43159338
Ref: Core and Builtins<8>-Footnote-53159394
Ref: Core and Builtins<8>-Footnote-63159450
Ref: Core and Builtins<8>-Footnote-73159506
Ref: Core and Builtins<8>-Footnote-83159562
Ref: Core and Builtins<8>-Footnote-93159618
Ref: Core and Builtins<8>-Footnote-103159674
Ref: Core and Builtins<8>-Footnote-113159731
Ref: Core and Builtins<8>-Footnote-123159788
Ref: Core and Builtins<8>-Footnote-133159845
Ref: Core and Builtins<8>-Footnote-143159902
Ref: Core and Builtins<8>-Footnote-153159959
Ref: Core and Builtins<8>-Footnote-163160016
Ref: Core and Builtins<8>-Footnote-173160073
Ref: Core and Builtins<8>-Footnote-183160130
Ref: Core and Builtins<8>-Footnote-193160187
Node: Library<7>3160244
Ref: whatsnew/changelog id423160357
Ref: 157a3160357
Ref: Library<7>-Footnote-13166954
Ref: Library<7>-Footnote-23167010
Ref: Library<7>-Footnote-33167066
Ref: Library<7>-Footnote-43167122
Ref: Library<7>-Footnote-53167178
Ref: Library<7>-Footnote-63167233
Ref: Library<7>-Footnote-73167288
Ref: Library<7>-Footnote-83167344
Ref: Library<7>-Footnote-93167399
Ref: Library<7>-Footnote-103167455
Ref: Library<7>-Footnote-113167512
Ref: Library<7>-Footnote-123167569
Ref: Library<7>-Footnote-133167626
Ref: Library<7>-Footnote-143167683
Ref: Library<7>-Footnote-153167740
Ref: Library<7>-Footnote-163167797
Ref: Library<7>-Footnote-173167854
Ref: Library<7>-Footnote-183167911
Ref: Library<7>-Footnote-193167968
Ref: Library<7>-Footnote-203168025
Ref: Library<7>-Footnote-213168082
Ref: Library<7>-Footnote-223168138
Ref: Library<7>-Footnote-233168195
Ref: Library<7>-Footnote-243168252
Ref: Library<7>-Footnote-253168309
Ref: Library<7>-Footnote-263168366
Ref: Library<7>-Footnote-273168423
Ref: Library<7>-Footnote-283168480
Ref: Library<7>-Footnote-293168537
Ref: Library<7>-Footnote-303168594
Ref: Library<7>-Footnote-313168651
Ref: Library<7>-Footnote-323168708
Ref: Library<7>-Footnote-333168765
Ref: Library<7>-Footnote-343168848
Ref: Library<7>-Footnote-353168905
Ref: Library<7>-Footnote-363168962
Ref: Library<7>-Footnote-373169018
Ref: Library<7>-Footnote-383169075
Ref: Library<7>-Footnote-393169131
Ref: Library<7>-Footnote-403169197
Node: Tests<6>3169253
Ref: whatsnew/changelog id433169354
Ref: 15813169354
Ref: Tests<6>-Footnote-13169546
Node: Build<7>3169602
Ref: whatsnew/changelog id443169703
Ref: 15823169703
Ref: Build<7>-Footnote-13170739
Ref: Build<7>-Footnote-23170795
Ref: Build<7>-Footnote-33170851
Ref: Build<7>-Footnote-43170907
Ref: Build<7>-Footnote-53170963
Node: Windows<4>3171019
Ref: whatsnew/changelog id453171120
Ref: 15833171120
Ref: Windows<4>-Footnote-13172053
Ref: Windows<4>-Footnote-23172109
Ref: Windows<4>-Footnote-33172165
Ref: Windows<4>-Footnote-43172221
Ref: Windows<4>-Footnote-53172277
Ref: Windows<4>-Footnote-63172333
Ref: Windows<4>-Footnote-73172389
Node: C API<7>3172445
Ref: whatsnew/changelog id463172529
Ref: 15843172529
Ref: C API<7>-Footnote-13173924
Ref: C API<7>-Footnote-23173980
Ref: C API<7>-Footnote-33174036
Ref: C API<7>-Footnote-43174092
Ref: C API<7>-Footnote-53174148
Ref: C API<7>-Footnote-63174204
Node: Python 3 13 0 beta 13174260
Ref: whatsnew/changelog python-3-13-0-beta-13174388
Ref: 15873174388
Node: Security<5>3174706
Ref: whatsnew/changelog id473174803
Ref: 15883174803
Ref: Security<5>-Footnote-13175196
Ref: Security<5>-Footnote-23175252
Node: Core and Builtins<9>3175308
Ref: whatsnew/changelog id483175424
Ref: 15893175424
Ref: Core and Builtins<9>-Footnote-13184789
Ref: Core and Builtins<9>-Footnote-23184845
Ref: Core and Builtins<9>-Footnote-33184901
Ref: Core and Builtins<9>-Footnote-43184957
Ref: Core and Builtins<9>-Footnote-53185012
Ref: Core and Builtins<9>-Footnote-63185068
Ref: Core and Builtins<9>-Footnote-73185124
Ref: Core and Builtins<9>-Footnote-83185180
Ref: Core and Builtins<9>-Footnote-93185236
Ref: Core and Builtins<9>-Footnote-103185292
Ref: Core and Builtins<9>-Footnote-113185349
Ref: Core and Builtins<9>-Footnote-123185406
Ref: Core and Builtins<9>-Footnote-133185463
Ref: Core and Builtins<9>-Footnote-143185520
Ref: Core and Builtins<9>-Footnote-153185577
Ref: Core and Builtins<9>-Footnote-163185633
Ref: Core and Builtins<9>-Footnote-173185690
Ref: Core and Builtins<9>-Footnote-183185747
Ref: Core and Builtins<9>-Footnote-193185804
Ref: Core and Builtins<9>-Footnote-203185861
Ref: Core and Builtins<9>-Footnote-213185918
Ref: Core and Builtins<9>-Footnote-223185975
Ref: Core and Builtins<9>-Footnote-233186032
Ref: Core and Builtins<9>-Footnote-243186089
Ref: Core and Builtins<9>-Footnote-253186146
Ref: Core and Builtins<9>-Footnote-263186203
Ref: Core and Builtins<9>-Footnote-273186260
Ref: Core and Builtins<9>-Footnote-283186317
Ref: Core and Builtins<9>-Footnote-293186374
Ref: Core and Builtins<9>-Footnote-303186431
Ref: Core and Builtins<9>-Footnote-313186488
Ref: Core and Builtins<9>-Footnote-323186545
Ref: Core and Builtins<9>-Footnote-333186602
Ref: Core and Builtins<9>-Footnote-343186659
Ref: Core and Builtins<9>-Footnote-353186716
Ref: Core and Builtins<9>-Footnote-363186773
Ref: Core and Builtins<9>-Footnote-373186830
Ref: Core and Builtins<9>-Footnote-383186873
Ref: Core and Builtins<9>-Footnote-393186930
Ref: Core and Builtins<9>-Footnote-403186987
Ref: Core and Builtins<9>-Footnote-413187044
Ref: Core and Builtins<9>-Footnote-423187101
Ref: Core and Builtins<9>-Footnote-433187158
Ref: Core and Builtins<9>-Footnote-443187201
Ref: Core and Builtins<9>-Footnote-453187257
Ref: Core and Builtins<9>-Footnote-463187314
Ref: Core and Builtins<9>-Footnote-473187370
Ref: Core and Builtins<9>-Footnote-483187426
Node: Library<8>3187483
Ref: whatsnew/changelog id493187604
Ref: 158c3187604
Ref: Library<8>-Footnote-13203861
Ref: Library<8>-Footnote-23203917
Ref: Library<8>-Footnote-33203973
Ref: Library<8>-Footnote-43204029
Ref: Library<8>-Footnote-53204085
Ref: Library<8>-Footnote-63204141
Ref: Library<8>-Footnote-73204197
Ref: Library<8>-Footnote-83204253
Ref: Library<8>-Footnote-93204309
Ref: Library<8>-Footnote-103204365
Ref: Library<8>-Footnote-113204422
Ref: Library<8>-Footnote-123204479
Ref: Library<8>-Footnote-133204536
Ref: Library<8>-Footnote-143204593
Ref: Library<8>-Footnote-153204636
Ref: Library<8>-Footnote-163204693
Ref: Library<8>-Footnote-173204750
Ref: Library<8>-Footnote-183204807
Ref: Library<8>-Footnote-193204864
Ref: Library<8>-Footnote-203204921
Ref: Library<8>-Footnote-213204978
Ref: Library<8>-Footnote-223205035
Ref: Library<8>-Footnote-233205092
Ref: Library<8>-Footnote-243205149
Ref: Library<8>-Footnote-253205205
Ref: Library<8>-Footnote-263205262
Ref: Library<8>-Footnote-273205319
Ref: Library<8>-Footnote-283205376
Ref: Library<8>-Footnote-293205433
Ref: Library<8>-Footnote-303205490
Ref: Library<8>-Footnote-313205547
Ref: Library<8>-Footnote-323205590
Ref: Library<8>-Footnote-333205647
Ref: Library<8>-Footnote-343205704
Ref: Library<8>-Footnote-353205761
Ref: Library<8>-Footnote-363205817
Ref: Library<8>-Footnote-373205877
Ref: Library<8>-Footnote-383205933
Ref: Library<8>-Footnote-393205990
Ref: Library<8>-Footnote-403206047
Ref: Library<8>-Footnote-413206104
Ref: Library<8>-Footnote-423206160
Ref: Library<8>-Footnote-433206216
Ref: Library<8>-Footnote-443206259
Ref: Library<8>-Footnote-453206316
Ref: Library<8>-Footnote-463206373
Ref: Library<8>-Footnote-473206430
Ref: Library<8>-Footnote-483206487
Ref: Library<8>-Footnote-493206544
Ref: Library<8>-Footnote-503206601
Ref: Library<8>-Footnote-513206658
Ref: Library<8>-Footnote-523206715
Ref: Library<8>-Footnote-533206772
Ref: Library<8>-Footnote-543206829
Ref: Library<8>-Footnote-553206886
Ref: Library<8>-Footnote-563206943
Ref: Library<8>-Footnote-573207000
Ref: Library<8>-Footnote-583207057
Ref: Library<8>-Footnote-593207114
Ref: Library<8>-Footnote-603207171
Ref: Library<8>-Footnote-613207228
Ref: Library<8>-Footnote-623207285
Ref: Library<8>-Footnote-633207328
Ref: Library<8>-Footnote-643207385
Ref: Library<8>-Footnote-653207442
Ref: Library<8>-Footnote-663207499
Ref: Library<8>-Footnote-673207556
Ref: Library<8>-Footnote-683207599
Ref: Library<8>-Footnote-693207655
Ref: Library<8>-Footnote-703207711
Ref: Library<8>-Footnote-713207768
Ref: Library<8>-Footnote-723207825
Ref: Library<8>-Footnote-733207882
Ref: Library<8>-Footnote-743207938
Ref: Library<8>-Footnote-753207994
Ref: Library<8>-Footnote-763208051
Ref: Library<8>-Footnote-773208108
Ref: Library<8>-Footnote-783208165
Ref: Library<8>-Footnote-793208222
Ref: Library<8>-Footnote-803208278
Ref: Library<8>-Footnote-813208335
Ref: Library<8>-Footnote-823208392
Ref: Library<8>-Footnote-833208448
Ref: Library<8>-Footnote-843208505
Ref: Library<8>-Footnote-853208562
Ref: Library<8>-Footnote-863208618
Ref: Library<8>-Footnote-873208674
Ref: Library<8>-Footnote-883208740
Ref: Library<8>-Footnote-893208806
Ref: Library<8>-Footnote-903208872
Ref: Library<8>-Footnote-913208938
Node: Documentation<4>3209004
Ref: whatsnew/changelog id503209113
Ref: 159b3209113
Ref: Documentation<4>-Footnote-13209293
Node: Build<8>3209349
Ref: whatsnew/changelog id513209458
Ref: 159c3209458
Ref: Build<8>-Footnote-13210405
Ref: Build<8>-Footnote-23210461
Ref: Build<8>-Footnote-33210517
Ref: Build<8>-Footnote-43210573
Ref: Build<8>-Footnote-53210629
Ref: Build<8>-Footnote-63210685
Node: Windows<5>3210741
Ref: whatsnew/changelog id523210842
Ref: 159d3210842
Ref: Windows<5>-Footnote-13211879
Ref: Windows<5>-Footnote-23211935
Ref: Windows<5>-Footnote-33211991
Ref: Windows<5>-Footnote-43212047
Ref: Windows<5>-Footnote-53212103
Ref: Windows<5>-Footnote-63212159
Ref: Windows<5>-Footnote-73212214
Node: macOS<4>3212270
Ref: whatsnew/changelog id533212370
Ref: 159e3212370
Ref: macOS<4>-Footnote-13212812
Ref: macOS<4>-Footnote-23212868
Ref: macOS<4>-Footnote-33212924
Ref: macOS<4>-Footnote-43212980
Node: IDLE<8>3213035
Ref: whatsnew/changelog id543213133
Ref: 159f3213133
Ref: IDLE<8>-Footnote-13213270
Node: C API<8>3213335
Ref: whatsnew/changelog id553213416
Ref: 15a03213416
Ref: C API<8>-Footnote-13214676
Ref: C API<8>-Footnote-23214732
Ref: C API<8>-Footnote-33214788
Ref: C API<8>-Footnote-43214844
Ref: C API<8>-Footnote-53214900
Ref: C API<8>-Footnote-63214956
Ref: C API<8>-Footnote-73215011
Node: Python 3 13 0 alpha 63215067
Ref: whatsnew/changelog python-3-13-0-alpha-63215196
Ref: 15a63215196
Node: Core and Builtins<10>3215477
Ref: whatsnew/changelog id563215575
Ref: 15a73215575
Ref: Core and Builtins<10>-Footnote-13220644
Ref: Core and Builtins<10>-Footnote-23220700
Ref: Core and Builtins<10>-Footnote-33220756
Ref: Core and Builtins<10>-Footnote-43220812
Ref: Core and Builtins<10>-Footnote-53220868
Ref: Core and Builtins<10>-Footnote-63220924
Ref: Core and Builtins<10>-Footnote-73220980
Ref: Core and Builtins<10>-Footnote-83221036
Ref: Core and Builtins<10>-Footnote-93221091
Ref: Core and Builtins<10>-Footnote-103221138
Ref: Core and Builtins<10>-Footnote-113221195
Ref: Core and Builtins<10>-Footnote-123221252
Ref: Core and Builtins<10>-Footnote-133221309
Ref: Core and Builtins<10>-Footnote-143221366
Ref: Core and Builtins<10>-Footnote-153221423
Ref: Core and Builtins<10>-Footnote-163221480
Ref: Core and Builtins<10>-Footnote-173221537
Ref: Core and Builtins<10>-Footnote-183221594
Ref: Core and Builtins<10>-Footnote-193221651
Ref: Core and Builtins<10>-Footnote-203221708
Ref: Core and Builtins<10>-Footnote-213221765
Ref: Core and Builtins<10>-Footnote-223221821
Node: Library<9>3221887
Ref: whatsnew/changelog id573222010
Ref: 15ab3222010
Ref: Library<9>-Footnote-13232774
Ref: Library<9>-Footnote-23232830
Ref: Library<9>-Footnote-33232886
Ref: Library<9>-Footnote-43232942
Ref: Library<9>-Footnote-53232998
Ref: Library<9>-Footnote-63233054
Ref: Library<9>-Footnote-73233110
Ref: Library<9>-Footnote-83233166
Ref: Library<9>-Footnote-93233222
Ref: Library<9>-Footnote-103233278
Ref: Library<9>-Footnote-113233335
Ref: Library<9>-Footnote-123233391
Ref: Library<9>-Footnote-133233447
Ref: Library<9>-Footnote-143233504
Ref: Library<9>-Footnote-153233561
Ref: Library<9>-Footnote-163233617
Ref: Library<9>-Footnote-173233674
Ref: Library<9>-Footnote-183233731
Ref: Library<9>-Footnote-193233788
Ref: Library<9>-Footnote-203233845
Ref: Library<9>-Footnote-213233902
Ref: Library<9>-Footnote-223233959
Ref: Library<9>-Footnote-233234016
Ref: Library<9>-Footnote-243234073
Ref: Library<9>-Footnote-253234130
Ref: Library<9>-Footnote-263234187
Ref: Library<9>-Footnote-273234243
Ref: Library<9>-Footnote-283234300
Ref: Library<9>-Footnote-293234357
Ref: Library<9>-Footnote-303234413
Ref: Library<9>-Footnote-313234470
Ref: Library<9>-Footnote-323234527
Ref: Library<9>-Footnote-333234583
Ref: Library<9>-Footnote-343234640
Ref: Library<9>-Footnote-353234708
Ref: Library<9>-Footnote-363234764
Ref: Library<9>-Footnote-373234821
Ref: Library<9>-Footnote-383234878
Ref: Library<9>-Footnote-393234935
Ref: Library<9>-Footnote-403234992
Ref: Library<9>-Footnote-413235048
Ref: Library<9>-Footnote-423235104
Ref: Library<9>-Footnote-433235160
Ref: Library<9>-Footnote-443235217
Ref: Library<9>-Footnote-453235274
Ref: Library<9>-Footnote-463235331
Ref: Library<9>-Footnote-473235388
Ref: Library<9>-Footnote-483235444
Ref: Library<9>-Footnote-493235500
Ref: Library<9>-Footnote-503235557
Ref: Library<9>-Footnote-513235614
Ref: Library<9>-Footnote-523235671
Ref: Library<9>-Footnote-533235728
Ref: Library<9>-Footnote-543235785
Ref: Library<9>-Footnote-553235841
Ref: Library<9>-Footnote-563235898
Ref: Library<9>-Footnote-573235955
Ref: Library<9>-Footnote-583236012
Ref: Library<9>-Footnote-593236068
Ref: Library<9>-Footnote-603236124
Ref: Library<9>-Footnote-613236190
Ref: Library<9>-Footnote-623236256
Ref: Library<9>-Footnote-633236322
Ref: Library<9>-Footnote-643236378
Node: Documentation<5>3236444
Ref: whatsnew/changelog id583236554
Ref: 15b23236554
Ref: Documentation<5>-Footnote-13236967
Ref: Documentation<5>-Footnote-23237023
Ref: Documentation<5>-Footnote-33237079
Node: Tests<7>3237134
Ref: whatsnew/changelog id593237242
Ref: 15b33237242
Ref: Tests<7>-Footnote-13238348
Ref: Tests<7>-Footnote-23238403
Ref: Tests<7>-Footnote-33238459
Ref: Tests<7>-Footnote-43238515
Ref: Tests<7>-Footnote-53238571
Ref: Tests<7>-Footnote-63238627
Ref: Tests<7>-Footnote-73238683
Node: Build<9>3238739
Ref: whatsnew/changelog id603238841
Ref: 15b43238841
Ref: Build<9>-Footnote-13239119
Ref: Build<9>-Footnote-23239175
Ref: Build<9>-Footnote-33239231
Node: Windows<6>3239286
Ref: whatsnew/changelog id613239388
Ref: 15b53239388
Ref: Windows<6>-Footnote-13240848
Ref: Windows<6>-Footnote-23240904
Ref: Windows<6>-Footnote-33240960
Ref: Windows<6>-Footnote-43241015
Ref: Windows<6>-Footnote-53241071
Ref: Windows<6>-Footnote-63241126
Node: C API<9>3241182
Ref: whatsnew/changelog id623241267
Ref: 15b73241267
Ref: C API<9>-Footnote-13244524
Ref: C API<9>-Footnote-23244580
Ref: C API<9>-Footnote-33244622
Ref: C API<9>-Footnote-43244677
Ref: C API<9>-Footnote-53244733
Ref: C API<9>-Footnote-63244789
Ref: C API<9>-Footnote-73244845
Ref: C API<9>-Footnote-83244901
Ref: C API<9>-Footnote-93244957
Ref: C API<9>-Footnote-103245013
Ref: C API<9>-Footnote-113245070
Ref: C API<9>-Footnote-123245127
Ref: C API<9>-Footnote-133245184
Ref: C API<9>-Footnote-143245241
Ref: C API<9>-Footnote-153245284
Ref: C API<9>-Footnote-163245341
Ref: C API<9>-Footnote-173245398
Ref: C API<9>-Footnote-183245454
Ref: C API<9>-Footnote-193245511
Node: Python 3 13 0 alpha 53245568
Ref: whatsnew/changelog python-3-13-0-alpha-53245698
Ref: 15b93245698
Node: Security<6>3246074
Ref: whatsnew/changelog id633246173
Ref: 15ba3246173
Ref: Security<6>-Footnote-13246986
Ref: Security<6>-Footnote-23247042
Ref: Security<6>-Footnote-33247098
Node: Core and Builtins<11>3247154
Ref: whatsnew/changelog id643247273
Ref: 15bb3247273
Ref: Core and Builtins<11>-Footnote-13249894
Ref: Core and Builtins<11>-Footnote-23249950
Ref: Core and Builtins<11>-Footnote-33250006
Ref: Core and Builtins<11>-Footnote-43250048
Ref: Core and Builtins<11>-Footnote-53250104
Ref: Core and Builtins<11>-Footnote-63250160
Ref: Core and Builtins<11>-Footnote-73250216
Ref: Core and Builtins<11>-Footnote-83250272
Ref: Core and Builtins<11>-Footnote-93250328
Ref: Core and Builtins<11>-Footnote-103250384
Ref: Core and Builtins<11>-Footnote-113250441
Ref: Core and Builtins<11>-Footnote-123250498
Ref: Core and Builtins<11>-Footnote-133250555
Ref: Core and Builtins<11>-Footnote-143250612
Ref: Core and Builtins<11>-Footnote-153250669
Ref: Core and Builtins<11>-Footnote-163250726
Ref: Core and Builtins<11>-Footnote-173250783
Ref: Core and Builtins<11>-Footnote-183250840
Node: Library<10>3250896
Ref: whatsnew/changelog id653251020
Ref: 15bc3251020
Ref: Library<10>-Footnote-13262790
Ref: Library<10>-Footnote-23262846
Ref: Library<10>-Footnote-33262902
Ref: Library<10>-Footnote-43262958
Ref: Library<10>-Footnote-53263014
Ref: Library<10>-Footnote-63263056
Ref: Library<10>-Footnote-73263112
Ref: Library<10>-Footnote-83263168
Ref: Library<10>-Footnote-93263224
Ref: Library<10>-Footnote-103263279
Ref: Library<10>-Footnote-113263335
Ref: Library<10>-Footnote-123263391
Ref: Library<10>-Footnote-133263447
Ref: Library<10>-Footnote-143263503
Ref: Library<10>-Footnote-153263560
Ref: Library<10>-Footnote-163263617
Ref: Library<10>-Footnote-173263673
Ref: Library<10>-Footnote-183263729
Ref: Library<10>-Footnote-193263786
Ref: Library<10>-Footnote-203263842
Ref: Library<10>-Footnote-213263899
Ref: Library<10>-Footnote-223263956
Ref: Library<10>-Footnote-233264013
Ref: Library<10>-Footnote-243264070
Ref: Library<10>-Footnote-253264126
Ref: Library<10>-Footnote-263264182
Ref: Library<10>-Footnote-273264239
Ref: Library<10>-Footnote-283264296
Ref: Library<10>-Footnote-293264353
Ref: Library<10>-Footnote-303264410
Ref: Library<10>-Footnote-313264467
Ref: Library<10>-Footnote-323264524
Ref: Library<10>-Footnote-333264581
Ref: Library<10>-Footnote-343264638
Ref: Library<10>-Footnote-353264695
Ref: Library<10>-Footnote-363264752
Ref: Library<10>-Footnote-373264795
Ref: Library<10>-Footnote-383264852
Ref: Library<10>-Footnote-393264909
Ref: Library<10>-Footnote-403264966
Ref: Library<10>-Footnote-413265023
Ref: Library<10>-Footnote-423265080
Ref: Library<10>-Footnote-433265137
Ref: Library<10>-Footnote-443265194
Ref: Library<10>-Footnote-453265251
Ref: Library<10>-Footnote-463265308
Ref: Library<10>-Footnote-473265365
Ref: Library<10>-Footnote-483265421
Ref: Library<10>-Footnote-493265478
Ref: Library<10>-Footnote-503265535
Ref: Library<10>-Footnote-513265591
Ref: Library<10>-Footnote-523265647
Ref: Library<10>-Footnote-533265704
Ref: Library<10>-Footnote-543265760
Ref: Library<10>-Footnote-553265817
Ref: Library<10>-Footnote-563265873
Ref: Library<10>-Footnote-573265930
Ref: Library<10>-Footnote-583265987
Ref: Library<10>-Footnote-593266043
Ref: Library<10>-Footnote-603266099
Ref: Library<10>-Footnote-613266155
Ref: Library<10>-Footnote-623266221
Ref: Library<10>-Footnote-633266287
Ref: Library<10>-Footnote-643266353
Ref: Library<10>-Footnote-653266419
Ref: Library<10>-Footnote-663266485
Ref: Library<10>-Footnote-673266551
Node: Documentation<6>3266617
Ref: whatsnew/changelog id663266728
Ref: 15c53266728
Ref: Documentation<6>-Footnote-13266979
Ref: Documentation<6>-Footnote-23267035
Ref: Documentation<6>-Footnote-33267091
Node: Tests<8>3267147
Ref: whatsnew/changelog id673267256
Ref: 15c63267256
Ref: Tests<8>-Footnote-13268447
Ref: Tests<8>-Footnote-23268502
Ref: Tests<8>-Footnote-33268557
Ref: Tests<8>-Footnote-43268613
Ref: Tests<8>-Footnote-53268669
Ref: Tests<8>-Footnote-63268725
Ref: Tests<8>-Footnote-73268781
Ref: Tests<8>-Footnote-83268837
Ref: Tests<8>-Footnote-93268893
Node: Build<10>3268949
Ref: whatsnew/changelog id683269052
Ref: 15c73269052
Ref: Build<10>-Footnote-13269958
Ref: Build<10>-Footnote-23270014
Ref: Build<10>-Footnote-33270069
Ref: Build<10>-Footnote-43270125
Ref: Build<10>-Footnote-53270180
Ref: Build<10>-Footnote-63270236
Ref: Build<10>-Footnote-73270292
Ref: Build<10>-Footnote-83270348
Ref: Build<10>-Footnote-93270404
Node: Windows<7>3270460
Ref: whatsnew/changelog id693270563
Ref: 15c83270563
Ref: Windows<7>-Footnote-13271663
Ref: Windows<7>-Footnote-23271719
Ref: Windows<7>-Footnote-33271775
Ref: Windows<7>-Footnote-43271831
Node: macOS<5>3271887
Ref: whatsnew/changelog id703271988
Ref: 15c93271988
Ref: macOS<5>-Footnote-13272118
Node: IDLE<9>3272174
Ref: whatsnew/changelog id713272279
Ref: 15ca3272279
Ref: IDLE<9>-Footnote-13272461
Node: Tools/Demos<3>3272516
Ref: whatsnew/changelog id723272622
Ref: 15cb3272622
Ref: Tools/Demos<3>-Footnote-13272865
Ref: Tools/Demos<3>-Footnote-23272921
Node: C API<10>3272986
Ref: whatsnew/changelog id733273076
Ref: 15cc3273076
Ref: C API<10>-Footnote-13273647
Ref: C API<10>-Footnote-23273703
Node: Python 3 13 0 alpha 43273759
Ref: whatsnew/changelog python-3-13-0-alpha-43273889
Ref: 15d13273889
Node: Security<7>3274266
Ref: whatsnew/changelog id743274365
Ref: 15d23274365
Ref: Security<7>-Footnote-13274626
Ref: Security<7>-Footnote-23274682
Node: Core and Builtins<12>3274738
Ref: whatsnew/changelog id753274857
Ref: 15d33274857
Ref: Core and Builtins<12>-Footnote-13280167
Ref: Core and Builtins<12>-Footnote-23280223
Ref: Core and Builtins<12>-Footnote-33280279
Ref: Core and Builtins<12>-Footnote-43280335
Ref: Core and Builtins<12>-Footnote-53280391
Ref: Core and Builtins<12>-Footnote-63280447
Ref: Core and Builtins<12>-Footnote-73280503
Ref: Core and Builtins<12>-Footnote-83280559
Ref: Core and Builtins<12>-Footnote-93280615
Ref: Core and Builtins<12>-Footnote-103280671
Ref: Core and Builtins<12>-Footnote-113280727
Ref: Core and Builtins<12>-Footnote-123280784
Ref: Core and Builtins<12>-Footnote-133280841
Ref: Core and Builtins<12>-Footnote-143280898
Ref: Core and Builtins<12>-Footnote-153280955
Ref: Core and Builtins<12>-Footnote-163281012
Ref: Core and Builtins<12>-Footnote-173281069
Ref: Core and Builtins<12>-Footnote-183281126
Ref: Core and Builtins<12>-Footnote-193281183
Ref: Core and Builtins<12>-Footnote-203281240
Ref: Core and Builtins<12>-Footnote-213281297
Ref: Core and Builtins<12>-Footnote-223281354
Ref: Core and Builtins<12>-Footnote-233281411
Ref: Core and Builtins<12>-Footnote-243281468
Ref: Core and Builtins<12>-Footnote-253281525
Ref: Core and Builtins<12>-Footnote-263281582
Ref: Core and Builtins<12>-Footnote-273281639
Ref: Core and Builtins<12>-Footnote-283281702
Ref: Core and Builtins<12>-Footnote-293281759
Ref: Core and Builtins<12>-Footnote-303281815
Node: Library<11>3281872
Ref: whatsnew/changelog id763281996
Ref: 15d83281996
Ref: Library<11>-Footnote-13295929
Ref: Library<11>-Footnote-23295985
Ref: Library<11>-Footnote-33296041
Ref: Library<11>-Footnote-43296097
Ref: Library<11>-Footnote-53296153
Ref: Library<11>-Footnote-63296209
Ref: Library<11>-Footnote-73296265
Ref: Library<11>-Footnote-83296321
Ref: Library<11>-Footnote-93296376
Ref: Library<11>-Footnote-103296431
Ref: Library<11>-Footnote-113296488
Ref: Library<11>-Footnote-123296544
Ref: Library<11>-Footnote-133296601
Ref: Library<11>-Footnote-143296657
Ref: Library<11>-Footnote-153296714
Ref: Library<11>-Footnote-163296771
Ref: Library<11>-Footnote-173296828
Ref: Library<11>-Footnote-183296885
Ref: Library<11>-Footnote-193296942
Ref: Library<11>-Footnote-203296998
Ref: Library<11>-Footnote-213297055
Ref: Library<11>-Footnote-223297112
Ref: Library<11>-Footnote-233297168
Ref: Library<11>-Footnote-243297225
Ref: Library<11>-Footnote-253297282
Ref: Library<11>-Footnote-263297338
Ref: Library<11>-Footnote-273297394
Ref: Library<11>-Footnote-283297450
Ref: Library<11>-Footnote-293297507
Ref: Library<11>-Footnote-303297563
Ref: Library<11>-Footnote-313297620
Ref: Library<11>-Footnote-323297677
Ref: Library<11>-Footnote-333297734
Ref: Library<11>-Footnote-343297791
Ref: Library<11>-Footnote-353297848
Ref: Library<11>-Footnote-363297905
Ref: Library<11>-Footnote-373297961
Ref: Library<11>-Footnote-383298018
Ref: Library<11>-Footnote-393298075
Ref: Library<11>-Footnote-403298132
Ref: Library<11>-Footnote-413298189
Ref: Library<11>-Footnote-423298246
Ref: Library<11>-Footnote-433298290
Ref: Library<11>-Footnote-443298347
Ref: Library<11>-Footnote-453298404
Ref: Library<11>-Footnote-463298461
Ref: Library<11>-Footnote-473298518
Ref: Library<11>-Footnote-483298574
Ref: Library<11>-Footnote-493298631
Ref: Library<11>-Footnote-503298688
Ref: Library<11>-Footnote-513298744
Ref: Library<11>-Footnote-523298801
Ref: Library<11>-Footnote-533298858
Ref: Library<11>-Footnote-543298914
Ref: Library<11>-Footnote-553298971
Ref: Library<11>-Footnote-563299028
Ref: Library<11>-Footnote-573299085
Ref: Library<11>-Footnote-583299141
Ref: Library<11>-Footnote-593299198
Ref: Library<11>-Footnote-603299254
Ref: Library<11>-Footnote-613299311
Ref: Library<11>-Footnote-623299368
Ref: Library<11>-Footnote-633299425
Ref: Library<11>-Footnote-643299481
Ref: Library<11>-Footnote-653299537
Ref: Library<11>-Footnote-663299594
Ref: Library<11>-Footnote-673299651
Ref: Library<11>-Footnote-683299707
Ref: Library<11>-Footnote-693299763
Ref: Library<11>-Footnote-703299820
Ref: Library<11>-Footnote-713299877
Ref: Library<11>-Footnote-723299934
Ref: Library<11>-Footnote-733299990
Ref: Library<11>-Footnote-743300047
Ref: Library<11>-Footnote-753300103
Ref: Library<11>-Footnote-763300160
Ref: Library<11>-Footnote-773300216
Node: Documentation<7>3300282
Ref: whatsnew/changelog id773300393
Ref: 15ea3300393
Ref: Documentation<7>-Footnote-13300964
Ref: Documentation<7>-Footnote-23301020
Node: Tests<9>3301076
Ref: whatsnew/changelog id783301185
Ref: 15eb3301185
Ref: Tests<9>-Footnote-13301577
Ref: Tests<9>-Footnote-23301633
Node: Build<11>3301689
Ref: whatsnew/changelog id793301792
Ref: 15ec3301792
Ref: Build<11>-Footnote-13302330
Ref: Build<11>-Footnote-23302386
Ref: Build<11>-Footnote-33302442
Ref: Build<11>-Footnote-43302498
Node: Windows<8>3302554
Ref: whatsnew/changelog id803302657
Ref: 15ed3302657
Ref: Windows<8>-Footnote-13303410
Ref: Windows<8>-Footnote-23303466
Ref: Windows<8>-Footnote-33303522
Ref: Windows<8>-Footnote-43303578
Ref: Windows<8>-Footnote-53303634
Ref: Windows<8>-Footnote-63303690
Ref: Windows<8>-Footnote-73303746
Node: macOS<6>3303801
Ref: whatsnew/changelog id813303903
Ref: 15ee3303903
Ref: macOS<6>-Footnote-13304442
Ref: macOS<6>-Footnote-23304498
Ref: macOS<6>-Footnote-33304554
Ref: macOS<6>-Footnote-43304610
Node: IDLE<10>3304665
Ref: whatsnew/changelog id823304771
Ref: 15f03304771
Ref: IDLE<10>-Footnote-13305098
Ref: IDLE<10>-Footnote-23305153
Node: Tools/Demos<4>3305209
Ref: whatsnew/changelog id833305316
Ref: 15f13305316
Ref: Tools/Demos<4>-Footnote-13305927
Ref: Tools/Demos<4>-Footnote-23305983
Ref: Tools/Demos<4>-Footnote-33306039
Node: C API<11>3306095
Ref: whatsnew/changelog id843306185
Ref: 15f33306185
Ref: C API<11>-Footnote-13308129
Ref: C API<11>-Footnote-23308185
Ref: C API<11>-Footnote-33308241
Ref: C API<11>-Footnote-43308297
Ref: C API<11>-Footnote-53308353
Ref: C API<11>-Footnote-63308409
Ref: C API<11>-Footnote-73308465
Node: Python 3 13 0 alpha 33308521
Ref: whatsnew/changelog python-3-13-0-alpha-33308651
Ref: 15f63308651
Node: Security<8>3308998
Ref: whatsnew/changelog id853309097
Ref: 15f73309097
Ref: Security<8>-Footnote-13309386
Ref: Security<8>-Footnote-23309442
Node: Core and Builtins<13>3309498
Ref: whatsnew/changelog id863309617
Ref: 15f83309617
Ref: Core and Builtins<13>-Footnote-13316992
Ref: Core and Builtins<13>-Footnote-23317048
Ref: Core and Builtins<13>-Footnote-33317104
Ref: Core and Builtins<13>-Footnote-43317160
Ref: Core and Builtins<13>-Footnote-53317216
Ref: Core and Builtins<13>-Footnote-63317271
Ref: Core and Builtins<13>-Footnote-73317313
Ref: Core and Builtins<13>-Footnote-83317369
Ref: Core and Builtins<13>-Footnote-93317425
Ref: Core and Builtins<13>-Footnote-103317481
Ref: Core and Builtins<13>-Footnote-113317538
Ref: Core and Builtins<13>-Footnote-123317594
Ref: Core and Builtins<13>-Footnote-133317651
Ref: Core and Builtins<13>-Footnote-143317708
Ref: Core and Builtins<13>-Footnote-153317765
Ref: Core and Builtins<13>-Footnote-163317822
Ref: Core and Builtins<13>-Footnote-173317879
Ref: Core and Builtins<13>-Footnote-183317936
Ref: Core and Builtins<13>-Footnote-193317993
Ref: Core and Builtins<13>-Footnote-203318050
Ref: Core and Builtins<13>-Footnote-213318107
Ref: Core and Builtins<13>-Footnote-223318164
Ref: Core and Builtins<13>-Footnote-233318221
Ref: Core and Builtins<13>-Footnote-243318278
Ref: Core and Builtins<13>-Footnote-253318334
Ref: Core and Builtins<13>-Footnote-263318391
Ref: Core and Builtins<13>-Footnote-273318448
Ref: Core and Builtins<13>-Footnote-283318504
Ref: Core and Builtins<13>-Footnote-293318561
Ref: Core and Builtins<13>-Footnote-303318618
Ref: Core and Builtins<13>-Footnote-313318675
Ref: Core and Builtins<13>-Footnote-323318732
Ref: Core and Builtins<13>-Footnote-333318789
Ref: Core and Builtins<13>-Footnote-343318845
Ref: Core and Builtins<13>-Footnote-353318902
Ref: Core and Builtins<13>-Footnote-363318959
Ref: Core and Builtins<13>-Footnote-373319016
Ref: Core and Builtins<13>-Footnote-383319073
Ref: Core and Builtins<13>-Footnote-393319129
Ref: Core and Builtins<13>-Footnote-403319186
Ref: Core and Builtins<13>-Footnote-413319243
Ref: Core and Builtins<13>-Footnote-423319300
Ref: Core and Builtins<13>-Footnote-433319356
Ref: Core and Builtins<13>-Footnote-443319422
Ref: Core and Builtins<13>-Footnote-453319488
Ref: Core and Builtins<13>-Footnote-463319531
Node: Library<12>3319597
Ref: whatsnew/changelog id873319721
Ref: 15fd3319721
Ref: Library<12>-Footnote-13344909
Ref: Library<12>-Footnote-23344965
Ref: Library<12>-Footnote-33345021
Ref: Library<12>-Footnote-43345077
Ref: Library<12>-Footnote-53345133
Ref: Library<12>-Footnote-63345189
Ref: Library<12>-Footnote-73345245
Ref: Library<12>-Footnote-83345301
Ref: Library<12>-Footnote-93345357
Ref: Library<12>-Footnote-103345413
Ref: Library<12>-Footnote-113345469
Ref: Library<12>-Footnote-123345526
Ref: Library<12>-Footnote-133345583
Ref: Library<12>-Footnote-143345640
Ref: Library<12>-Footnote-153345697
Ref: Library<12>-Footnote-163345754
Ref: Library<12>-Footnote-173345811
Ref: Library<12>-Footnote-183345868
Ref: Library<12>-Footnote-193345925
Ref: Library<12>-Footnote-203345982
Ref: Library<12>-Footnote-213346038
Ref: Library<12>-Footnote-223346095
Ref: Library<12>-Footnote-233346151
Ref: Library<12>-Footnote-243346208
Ref: Library<12>-Footnote-253346265
Ref: Library<12>-Footnote-263346322
Ref: Library<12>-Footnote-273346379
Ref: Library<12>-Footnote-283346436
Ref: Library<12>-Footnote-293346493
Ref: Library<12>-Footnote-303346550
Ref: Library<12>-Footnote-313346607
Ref: Library<12>-Footnote-323346664
Ref: Library<12>-Footnote-333346720
Ref: Library<12>-Footnote-343346777
Ref: Library<12>-Footnote-353346834
Ref: Library<12>-Footnote-363346891
Ref: Library<12>-Footnote-373346947
Ref: Library<12>-Footnote-383347004
Ref: Library<12>-Footnote-393347061
Ref: Library<12>-Footnote-403347118
Ref: Library<12>-Footnote-413347175
Ref: Library<12>-Footnote-423347232
Ref: Library<12>-Footnote-433347289
Ref: Library<12>-Footnote-443347346
Ref: Library<12>-Footnote-453347403
Ref: Library<12>-Footnote-463347460
Ref: Library<12>-Footnote-473347516
Ref: Library<12>-Footnote-483347573
Ref: Library<12>-Footnote-493347629
Ref: Library<12>-Footnote-503347686
Ref: Library<12>-Footnote-513347743
Ref: Library<12>-Footnote-523347800
Ref: Library<12>-Footnote-533347857
Ref: Library<12>-Footnote-543347914
Ref: Library<12>-Footnote-553347971
Ref: Library<12>-Footnote-563348027
Ref: Library<12>-Footnote-573348084
Ref: Library<12>-Footnote-583348140
Ref: Library<12>-Footnote-593348196
Ref: Library<12>-Footnote-603348252
Ref: Library<12>-Footnote-613348309
Ref: Library<12>-Footnote-623348366
Ref: Library<12>-Footnote-633348422
Ref: Library<12>-Footnote-643348478
Ref: Library<12>-Footnote-653348535
Ref: Library<12>-Footnote-663348592
Ref: Library<12>-Footnote-673348649
Ref: Library<12>-Footnote-683348706
Ref: Library<12>-Footnote-693348763
Ref: Library<12>-Footnote-703348820
Ref: Library<12>-Footnote-713348876
Ref: Library<12>-Footnote-723348933
Ref: Library<12>-Footnote-733348990
Ref: Library<12>-Footnote-743349047
Ref: Library<12>-Footnote-753349104
Ref: Library<12>-Footnote-763349161
Ref: Library<12>-Footnote-773349218
Ref: Library<12>-Footnote-783349274
Ref: Library<12>-Footnote-793349331
Ref: Library<12>-Footnote-803349388
Ref: Library<12>-Footnote-813349445
Ref: Library<12>-Footnote-823349501
Ref: Library<12>-Footnote-833349558
Ref: Library<12>-Footnote-843349615
Ref: Library<12>-Footnote-853349672
Ref: Library<12>-Footnote-863349729
Ref: Library<12>-Footnote-873349785
Ref: Library<12>-Footnote-883349842
Ref: Library<12>-Footnote-893349898
Ref: Library<12>-Footnote-903349955
Ref: Library<12>-Footnote-913350012
Ref: Library<12>-Footnote-923350069
Ref: Library<12>-Footnote-933350126
Ref: Library<12>-Footnote-943350183
Ref: Library<12>-Footnote-953350239
Ref: Library<12>-Footnote-963350296
Ref: Library<12>-Footnote-973350352
Ref: Library<12>-Footnote-983350409
Ref: Library<12>-Footnote-993350465
Ref: Library<12>-Footnote-1003350521
Ref: Library<12>-Footnote-1013350578
Ref: Library<12>-Footnote-1023350636
Ref: Library<12>-Footnote-1033350694
Ref: Library<12>-Footnote-1043350752
Ref: Library<12>-Footnote-1053350810
Ref: Library<12>-Footnote-1063350867
Ref: Library<12>-Footnote-1073350924
Ref: Library<12>-Footnote-1083350982
Ref: Library<12>-Footnote-1093351040
Ref: Library<12>-Footnote-1103351098
Ref: Library<12>-Footnote-1113351155
Ref: Library<12>-Footnote-1123351213
Ref: Library<12>-Footnote-1133351271
Ref: Library<12>-Footnote-1143351328
Ref: Library<12>-Footnote-1153351386
Ref: Library<12>-Footnote-1163351430
Ref: Library<12>-Footnote-1173351488
Ref: Library<12>-Footnote-1183351545
Ref: Library<12>-Footnote-1193351602
Ref: Library<12>-Footnote-1203351659
Ref: Library<12>-Footnote-1213351726
Ref: Library<12>-Footnote-1223351793
Ref: Library<12>-Footnote-1233351860
Ref: Library<12>-Footnote-1243351927
Ref: Library<12>-Footnote-1253351994
Ref: Library<12>-Footnote-1263352061
Ref: Library<12>-Footnote-1273352128
Ref: Library<12>-Footnote-1283352195
Ref: Library<12>-Footnote-1293352262
Ref: Library<12>-Footnote-1303352329
Ref: Library<12>-Footnote-1313352396
Ref: Library<12>-Footnote-1323352463
Ref: Library<12>-Footnote-1333352530
Ref: Library<12>-Footnote-1343352597
Node: Documentation<8>3352664
Ref: whatsnew/changelog id883352776
Ref: 161b3352776
Ref: Documentation<8>-Footnote-13353342
Ref: Documentation<8>-Footnote-23353398
Ref: Documentation<8>-Footnote-33353454
Ref: Documentation<8>-Footnote-43353509
Node: Tests<10>3353567
Ref: whatsnew/changelog id893353677
Ref: 161c3353677
Ref: Tests<10>-Footnote-13355622
Ref: Tests<10>-Footnote-23355678
Ref: Tests<10>-Footnote-33355734
Ref: Tests<10>-Footnote-43355790
Ref: Tests<10>-Footnote-53355845
Ref: Tests<10>-Footnote-63355901
Ref: Tests<10>-Footnote-73355957
Ref: Tests<10>-Footnote-83356013
Ref: Tests<10>-Footnote-93356069
Ref: Tests<10>-Footnote-103356125
Node: Build<12>3356191
Ref: whatsnew/changelog id903356295
Ref: 161d3356295
Ref: Build<12>-Footnote-13357539
Ref: Build<12>-Footnote-23357595
Ref: Build<12>-Footnote-33357651
Ref: Build<12>-Footnote-43357707
Ref: Build<12>-Footnote-53357763
Ref: Build<12>-Footnote-63357819
Ref: Build<12>-Footnote-73357875
Ref: Build<12>-Footnote-83357940
Node: Windows<9>3358005
Ref: whatsnew/changelog id913358108
Ref: 161e3358108
Ref: Windows<9>-Footnote-13359949
Ref: Windows<9>-Footnote-23360005
Ref: Windows<9>-Footnote-33360061
Ref: Windows<9>-Footnote-43360117
Ref: Windows<9>-Footnote-53360173
Ref: Windows<9>-Footnote-63360228
Ref: Windows<9>-Footnote-73360283
Ref: Windows<9>-Footnote-83360339
Ref: Windows<9>-Footnote-93360395
Ref: Windows<9>-Footnote-103360450
Ref: Windows<9>-Footnote-113360506
Node: macOS<7>3360572
Ref: whatsnew/changelog id923360674
Ref: 161f3360674
Ref: macOS<7>-Footnote-13363070
Ref: macOS<7>-Footnote-23363126
Ref: macOS<7>-Footnote-33363182
Ref: macOS<7>-Footnote-43363238
Ref: macOS<7>-Footnote-53363293
Ref: macOS<7>-Footnote-63363348
Ref: macOS<7>-Footnote-73363403
Ref: macOS<7>-Footnote-83363459
Ref: macOS<7>-Footnote-93363515
Ref: macOS<7>-Footnote-103363571
Ref: macOS<7>-Footnote-113363628
Ref: macOS<7>-Footnote-123363685
Node: IDLE<11>3363742
Ref: whatsnew/changelog id933363843
Ref: 16203363843
Ref: IDLE<11>-Footnote-13364419
Ref: IDLE<11>-Footnote-23364474
Ref: IDLE<11>-Footnote-33364530
Ref: IDLE<11>-Footnote-43364586
Ref: IDLE<11>-Footnote-53364642
Ref: IDLE<11>-Footnote-63364698
Node: C API<12>3364763
Ref: whatsnew/changelog id943364847
Ref: 16213364847
Ref: C API<12>-Footnote-13365562
Ref: C API<12>-Footnote-23365618
Ref: C API<12>-Footnote-33365674
Ref: C API<12>-Footnote-43365730
Node: Python 3 13 0 alpha 23365785
Ref: whatsnew/changelog python-3-13-0-alpha-23365915
Ref: 16223365915
Node: Core and Builtins<14>3366234
Ref: whatsnew/changelog id953366333
Ref: 16233366333
Ref: Core and Builtins<14>-Footnote-13374158
Ref: Core and Builtins<14>-Footnote-23374214
Ref: Core and Builtins<14>-Footnote-33374270
Ref: Core and Builtins<14>-Footnote-43374326
Ref: Core and Builtins<14>-Footnote-53374382
Ref: Core and Builtins<14>-Footnote-63374438
Ref: Core and Builtins<14>-Footnote-73374494
Ref: Core and Builtins<14>-Footnote-83374550
Ref: Core and Builtins<14>-Footnote-93374605
Ref: Core and Builtins<14>-Footnote-103374660
Ref: Core and Builtins<14>-Footnote-113374716
Ref: Core and Builtins<14>-Footnote-123374773
Ref: Core and Builtins<14>-Footnote-133374830
Ref: Core and Builtins<14>-Footnote-143374887
Ref: Core and Builtins<14>-Footnote-153374944
Ref: Core and Builtins<14>-Footnote-163375001
Ref: Core and Builtins<14>-Footnote-173375058
Ref: Core and Builtins<14>-Footnote-183375115
Ref: Core and Builtins<14>-Footnote-193375172
Ref: Core and Builtins<14>-Footnote-203375229
Ref: Core and Builtins<14>-Footnote-213375286
Ref: Core and Builtins<14>-Footnote-223375343
Ref: Core and Builtins<14>-Footnote-233375400
Ref: Core and Builtins<14>-Footnote-243375457
Ref: Core and Builtins<14>-Footnote-253375514
Ref: Core and Builtins<14>-Footnote-263375571
Ref: Core and Builtins<14>-Footnote-273375628
Ref: Core and Builtins<14>-Footnote-283375685
Ref: Core and Builtins<14>-Footnote-293375742
Ref: Core and Builtins<14>-Footnote-303375798
Ref: Core and Builtins<14>-Footnote-313375854
Ref: Core and Builtins<14>-Footnote-323375911
Ref: Core and Builtins<14>-Footnote-333375968
Ref: Core and Builtins<14>-Footnote-343376025
Ref: Core and Builtins<14>-Footnote-353376082
Ref: Core and Builtins<14>-Footnote-363376139
Ref: Core and Builtins<14>-Footnote-373376196
Ref: Core and Builtins<14>-Footnote-383376253
Ref: Core and Builtins<14>-Footnote-393376310
Ref: Core and Builtins<14>-Footnote-403376367
Ref: Core and Builtins<14>-Footnote-413376424
Ref: Core and Builtins<14>-Footnote-423376481
Ref: Core and Builtins<14>-Footnote-433376538
Ref: Core and Builtins<14>-Footnote-443376594
Ref: Core and Builtins<14>-Footnote-453376660
Ref: Core and Builtins<14>-Footnote-463376717
Ref: Core and Builtins<14>-Footnote-473376783
Ref: Core and Builtins<14>-Footnote-483376840
Ref: Core and Builtins<14>-Footnote-493376897
Ref: Core and Builtins<14>-Footnote-503376954
Node: Library<13>3377020
Ref: whatsnew/changelog id963377137
Ref: 16283377137
Ref: Library<13>-Footnote-13387696
Ref: Library<13>-Footnote-23387752
Ref: Library<13>-Footnote-33387808
Ref: Library<13>-Footnote-43387864
Ref: Library<13>-Footnote-53387920
Ref: Library<13>-Footnote-63387976
Ref: Library<13>-Footnote-73388032
Ref: Library<13>-Footnote-83388088
Ref: Library<13>-Footnote-93388144
Ref: Library<13>-Footnote-103388200
Ref: Library<13>-Footnote-113388257
Ref: Library<13>-Footnote-123388313
Ref: Library<13>-Footnote-133388370
Ref: Library<13>-Footnote-143388427
Ref: Library<13>-Footnote-153388484
Ref: Library<13>-Footnote-163388541
Ref: Library<13>-Footnote-173388598
Ref: Library<13>-Footnote-183388655
Ref: Library<13>-Footnote-193388712
Ref: Library<13>-Footnote-203388768
Ref: Library<13>-Footnote-213388825
Ref: Library<13>-Footnote-223388882
Ref: Library<13>-Footnote-233388938
Ref: Library<13>-Footnote-243388995
Ref: Library<13>-Footnote-253389051
Ref: Library<13>-Footnote-263389108
Ref: Library<13>-Footnote-273389165
Ref: Library<13>-Footnote-283389222
Ref: Library<13>-Footnote-293389279
Ref: Library<13>-Footnote-303389336
Ref: Library<13>-Footnote-313389393
Ref: Library<13>-Footnote-323389450
Ref: Library<13>-Footnote-333389507
Ref: Library<13>-Footnote-343389564
Ref: Library<13>-Footnote-353389621
Ref: Library<13>-Footnote-363389678
Ref: Library<13>-Footnote-373389735
Ref: Library<13>-Footnote-383389792
Ref: Library<13>-Footnote-393389848
Ref: Library<13>-Footnote-403389904
Ref: Library<13>-Footnote-413389961
Ref: Library<13>-Footnote-423390018
Ref: Library<13>-Footnote-433390075
Ref: Library<13>-Footnote-443390131
Ref: Library<13>-Footnote-453390187
Ref: Library<13>-Footnote-463390244
Ref: Library<13>-Footnote-473390301
Ref: Library<13>-Footnote-483390358
Ref: Library<13>-Footnote-493390415
Ref: Library<13>-Footnote-503390471
Ref: Library<13>-Footnote-513390528
Ref: Library<13>-Footnote-523390585
Ref: Library<13>-Footnote-533390642
Ref: Library<13>-Footnote-543390698
Ref: Library<13>-Footnote-553390754
Ref: Library<13>-Footnote-563390810
Ref: Library<13>-Footnote-573390867
Ref: Library<13>-Footnote-583390924
Ref: Library<13>-Footnote-593390980
Ref: Library<13>-Footnote-603391036
Ref: Library<13>-Footnote-613391121
Ref: Library<13>-Footnote-623391177
Node: Tests<11>3391233
Ref: whatsnew/changelog id973391338
Ref: 163c3391338
Ref: Tests<11>-Footnote-13392924
Ref: Tests<11>-Footnote-23392980
Ref: Tests<11>-Footnote-33393036
Ref: Tests<11>-Footnote-43393092
Ref: Tests<11>-Footnote-53393148
Ref: Tests<11>-Footnote-63393204
Ref: Tests<11>-Footnote-73393260
Ref: Tests<11>-Footnote-83393316
Node: Build<13>3393372
Ref: whatsnew/changelog id983393477
Ref: 163d3393477
Ref: Build<13>-Footnote-13394463
Ref: Build<13>-Footnote-23394518
Ref: Build<13>-Footnote-33394574
Ref: Build<13>-Footnote-43394624
Ref: Build<13>-Footnote-53394680
Ref: Build<13>-Footnote-63394736
Node: Windows<10>3394791
Ref: whatsnew/changelog id993394895
Ref: 163e3394895
Ref: Windows<10>-Footnote-13395349
Ref: Windows<10>-Footnote-23395405
Ref: Windows<10>-Footnote-33395461
Node: macOS<8>3395517
Ref: whatsnew/changelog id1003395620
Ref: 16403395620
Ref: macOS<8>-Footnote-13396551
Ref: macOS<8>-Footnote-23396606
Ref: macOS<8>-Footnote-33396662
Ref: macOS<8>-Footnote-43396718
Ref: macOS<8>-Footnote-53396773
Node: IDLE<12>3396828
Ref: whatsnew/changelog id1013396934
Ref: 16413396934
Ref: IDLE<12>-Footnote-13397272
Node: Tools/Demos<5>3397337
Ref: whatsnew/changelog id1023397444
Ref: 16423397444
Ref: Tools/Demos<5>-Footnote-13397801
Node: C API<13>3397857
Ref: whatsnew/changelog id1033397947
Ref: 16433397947
Ref: C API<13>-Footnote-13403312
Ref: C API<13>-Footnote-23403368
Ref: C API<13>-Footnote-33403424
Ref: C API<13>-Footnote-43403480
Ref: C API<13>-Footnote-53403536
Ref: C API<13>-Footnote-63403592
Ref: C API<13>-Footnote-73403648
Ref: C API<13>-Footnote-83403704
Ref: C API<13>-Footnote-93403760
Ref: C API<13>-Footnote-103403816
Ref: C API<13>-Footnote-113403873
Ref: C API<13>-Footnote-123403916
Ref: C API<13>-Footnote-133403973
Ref: C API<13>-Footnote-143404030
Ref: C API<13>-Footnote-153404087
Ref: C API<13>-Footnote-163404144
Ref: C API<13>-Footnote-173404201
Ref: C API<13>-Footnote-183404257
Ref: C API<13>-Footnote-193404313
Ref: C API<13>-Footnote-203404370
Node: Python 3 13 0 alpha 13404426
Ref: whatsnew/changelog python-3-13-0-alpha-13404555
Ref: 16443404555
Node: Security<9>3404934
Ref: whatsnew/changelog id1043405033
Ref: 16453405033
Ref: Security<9>-Footnote-13406301
Ref: Security<9>-Footnote-23406357
Ref: Security<9>-Footnote-33406413
Ref: Security<9>-Footnote-43406469
Ref: Security<9>-Footnote-53406525
Ref: Security<9>-Footnote-63406581
Ref: Security<9>-Footnote-73406636
Node: Core and Builtins<15>3406692
Ref: whatsnew/changelog id1053406811
Ref: 16463406811
Ref: Core and Builtins<15>-Footnote-13437558
Ref: Core and Builtins<15>-Footnote-23437614
Ref: Core and Builtins<15>-Footnote-33437670
Ref: Core and Builtins<15>-Footnote-43437726
Ref: Core and Builtins<15>-Footnote-53437782
Ref: Core and Builtins<15>-Footnote-63437838
Ref: Core and Builtins<15>-Footnote-73437894
Ref: Core and Builtins<15>-Footnote-83437950
Ref: Core and Builtins<15>-Footnote-93438006
Ref: Core and Builtins<15>-Footnote-103438062
Ref: Core and Builtins<15>-Footnote-113438119
Ref: Core and Builtins<15>-Footnote-123438176
Ref: Core and Builtins<15>-Footnote-133438233
Ref: Core and Builtins<15>-Footnote-143438290
Ref: Core and Builtins<15>-Footnote-153438347
Ref: Core and Builtins<15>-Footnote-163438404
Ref: Core and Builtins<15>-Footnote-173438461
Ref: Core and Builtins<15>-Footnote-183438518
Ref: Core and Builtins<15>-Footnote-193438575
Ref: Core and Builtins<15>-Footnote-203438632
Ref: Core and Builtins<15>-Footnote-213438689
Ref: Core and Builtins<15>-Footnote-223438746
Ref: Core and Builtins<15>-Footnote-233438803
Ref: Core and Builtins<15>-Footnote-243438860
Ref: Core and Builtins<15>-Footnote-253438917
Ref: Core and Builtins<15>-Footnote-263438974
Ref: Core and Builtins<15>-Footnote-273439031
Ref: Core and Builtins<15>-Footnote-283439088
Ref: Core and Builtins<15>-Footnote-293439145
Ref: Core and Builtins<15>-Footnote-303439202
Ref: Core and Builtins<15>-Footnote-313439259
Ref: Core and Builtins<15>-Footnote-323439316
Ref: Core and Builtins<15>-Footnote-333439373
Ref: Core and Builtins<15>-Footnote-343439430
Ref: Core and Builtins<15>-Footnote-353439487
Ref: Core and Builtins<15>-Footnote-363439544
Ref: Core and Builtins<15>-Footnote-373439601
Ref: Core and Builtins<15>-Footnote-383439658
Ref: Core and Builtins<15>-Footnote-393439715
Ref: Core and Builtins<15>-Footnote-403439772
Ref: Core and Builtins<15>-Footnote-413439829
Ref: Core and Builtins<15>-Footnote-423439886
Ref: Core and Builtins<15>-Footnote-433439943
Ref: Core and Builtins<15>-Footnote-443440000
Ref: Core and Builtins<15>-Footnote-453440056
Ref: Core and Builtins<15>-Footnote-463440113
Ref: Core and Builtins<15>-Footnote-473440170
Ref: Core and Builtins<15>-Footnote-483440227
Ref: Core and Builtins<15>-Footnote-493440284
Ref: Core and Builtins<15>-Footnote-503440341
Ref: Core and Builtins<15>-Footnote-513440398
Ref: Core and Builtins<15>-Footnote-523440455
Ref: Core and Builtins<15>-Footnote-533440512
Ref: Core and Builtins<15>-Footnote-543440569
Ref: Core and Builtins<15>-Footnote-553440626
Ref: Core and Builtins<15>-Footnote-563440683
Ref: Core and Builtins<15>-Footnote-573440740
Ref: Core and Builtins<15>-Footnote-583440797
Ref: Core and Builtins<15>-Footnote-593440854
Ref: Core and Builtins<15>-Footnote-603440911
Ref: Core and Builtins<15>-Footnote-613440968
Ref: Core and Builtins<15>-Footnote-623441025
Ref: Core and Builtins<15>-Footnote-633441082
Ref: Core and Builtins<15>-Footnote-643441139
Ref: Core and Builtins<15>-Footnote-653441195
Ref: Core and Builtins<15>-Footnote-663441252
Ref: Core and Builtins<15>-Footnote-673441309
Ref: Core and Builtins<15>-Footnote-683441365
Ref: Core and Builtins<15>-Footnote-693441422
Ref: Core and Builtins<15>-Footnote-703441479
Ref: Core and Builtins<15>-Footnote-713441536
Ref: Core and Builtins<15>-Footnote-723441593
Ref: Core and Builtins<15>-Footnote-733441650
Ref: Core and Builtins<15>-Footnote-743441706
Ref: Core and Builtins<15>-Footnote-753441763
Ref: Core and Builtins<15>-Footnote-763441820
Ref: Core and Builtins<15>-Footnote-773441877
Ref: Core and Builtins<15>-Footnote-783441934
Ref: Core and Builtins<15>-Footnote-793441991
Ref: Core and Builtins<15>-Footnote-803442048
Ref: Core and Builtins<15>-Footnote-813442105
Ref: Core and Builtins<15>-Footnote-823442162
Ref: Core and Builtins<15>-Footnote-833442219
Ref: Core and Builtins<15>-Footnote-843442276
Ref: Core and Builtins<15>-Footnote-853442319
Ref: Core and Builtins<15>-Footnote-863442376
Ref: Core and Builtins<15>-Footnote-873442433
Ref: Core and Builtins<15>-Footnote-883442490
Ref: Core and Builtins<15>-Footnote-893442546
Ref: Core and Builtins<15>-Footnote-903442603
Ref: Core and Builtins<15>-Footnote-913442660
Ref: Core and Builtins<15>-Footnote-923442717
Ref: Core and Builtins<15>-Footnote-933442774
Ref: Core and Builtins<15>-Footnote-943442831
Ref: Core and Builtins<15>-Footnote-953442888
Ref: Core and Builtins<15>-Footnote-963442945
Ref: Core and Builtins<15>-Footnote-973443002
Ref: Core and Builtins<15>-Footnote-983443059
Ref: Core and Builtins<15>-Footnote-993443116
Ref: Core and Builtins<15>-Footnote-1003443173
Ref: Core and Builtins<15>-Footnote-1013443231
Ref: Core and Builtins<15>-Footnote-1023443289
Ref: Core and Builtins<15>-Footnote-1033443347
Ref: Core and Builtins<15>-Footnote-1043443405
Ref: Core and Builtins<15>-Footnote-1053443463
Ref: Core and Builtins<15>-Footnote-1063443521
Ref: Core and Builtins<15>-Footnote-1073443578
Ref: Core and Builtins<15>-Footnote-1083443635
Ref: Core and Builtins<15>-Footnote-1093443693
Ref: Core and Builtins<15>-Footnote-1103443751
Ref: Core and Builtins<15>-Footnote-1113443809
Ref: Core and Builtins<15>-Footnote-1123443867
Ref: Core and Builtins<15>-Footnote-1133443925
Ref: Core and Builtins<15>-Footnote-1143443983
Ref: Core and Builtins<15>-Footnote-1153444041
Ref: Core and Builtins<15>-Footnote-1163444099
Ref: Core and Builtins<15>-Footnote-1173444157
Ref: Core and Builtins<15>-Footnote-1183444215
Ref: Core and Builtins<15>-Footnote-1193444273
Ref: Core and Builtins<15>-Footnote-1203444331
Ref: Core and Builtins<15>-Footnote-1213444388
Ref: Core and Builtins<15>-Footnote-1223444446
Ref: Core and Builtins<15>-Footnote-1233444504
Ref: Core and Builtins<15>-Footnote-1243444561
Ref: Core and Builtins<15>-Footnote-1253444619
Ref: Core and Builtins<15>-Footnote-1263444677
Ref: Core and Builtins<15>-Footnote-1273444735
Ref: Core and Builtins<15>-Footnote-1283444793
Ref: Core and Builtins<15>-Footnote-1293444851
Ref: Core and Builtins<15>-Footnote-1303444909
Ref: Core and Builtins<15>-Footnote-1313444967
Ref: Core and Builtins<15>-Footnote-1323445025
Ref: Core and Builtins<15>-Footnote-1333445083
Ref: Core and Builtins<15>-Footnote-1343445141
Ref: Core and Builtins<15>-Footnote-1353445199
Ref: Core and Builtins<15>-Footnote-1363445257
Ref: Core and Builtins<15>-Footnote-1373445315
Ref: Core and Builtins<15>-Footnote-1383445373
Ref: Core and Builtins<15>-Footnote-1393445431
Ref: Core and Builtins<15>-Footnote-1403445489
Ref: Core and Builtins<15>-Footnote-1413445547
Ref: Core and Builtins<15>-Footnote-1423445605
Ref: Core and Builtins<15>-Footnote-1433445663
Ref: Core and Builtins<15>-Footnote-1443445721
Ref: Core and Builtins<15>-Footnote-1453445778
Ref: Core and Builtins<15>-Footnote-1463445836
Ref: Core and Builtins<15>-Footnote-1473445894
Ref: Core and Builtins<15>-Footnote-1483445951
Ref: Core and Builtins<15>-Footnote-1493446009
Ref: Core and Builtins<15>-Footnote-1503446067
Ref: Core and Builtins<15>-Footnote-1513446125
Ref: Core and Builtins<15>-Footnote-1523446183
Ref: Core and Builtins<15>-Footnote-1533446241
Ref: Core and Builtins<15>-Footnote-1543446299
Ref: Core and Builtins<15>-Footnote-1553446357
Ref: Core and Builtins<15>-Footnote-1563446415
Ref: Core and Builtins<15>-Footnote-1573446473
Ref: Core and Builtins<15>-Footnote-1583446531
Ref: Core and Builtins<15>-Footnote-1593446589
Ref: Core and Builtins<15>-Footnote-1603446647
Ref: Core and Builtins<15>-Footnote-1613446705
Ref: Core and Builtins<15>-Footnote-1623446763
Ref: Core and Builtins<15>-Footnote-1633446821
Ref: Core and Builtins<15>-Footnote-1643446879
Ref: Core and Builtins<15>-Footnote-1653446937
Ref: Core and Builtins<15>-Footnote-1663446995
Ref: Core and Builtins<15>-Footnote-1673447053
Ref: Core and Builtins<15>-Footnote-1683447110
Ref: Core and Builtins<15>-Footnote-1693447167
Ref: Core and Builtins<15>-Footnote-1703447224
Ref: Core and Builtins<15>-Footnote-1713447282
Node: Library<14>3447339
Ref: whatsnew/changelog id1063447463
Ref: 165a3447463
Ref: Library<14>-Footnote-13495816
Ref: Library<14>-Footnote-23495872
Ref: Library<14>-Footnote-33495928
Ref: Library<14>-Footnote-43495984
Ref: Library<14>-Footnote-53496039
Ref: Library<14>-Footnote-63496095
Ref: Library<14>-Footnote-73496151
Ref: Library<14>-Footnote-83496207
Ref: Library<14>-Footnote-93496262
Ref: Library<14>-Footnote-103496318
Ref: Library<14>-Footnote-113496374
Ref: Library<14>-Footnote-123496431
Ref: Library<14>-Footnote-133496488
Ref: Library<14>-Footnote-143496545
Ref: Library<14>-Footnote-153496602
Ref: Library<14>-Footnote-163496659
Ref: Library<14>-Footnote-173496716
Ref: Library<14>-Footnote-183496773
Ref: Library<14>-Footnote-193496830
Ref: Library<14>-Footnote-203496887
Ref: Library<14>-Footnote-213496944
Ref: Library<14>-Footnote-223497001
Ref: Library<14>-Footnote-233497058
Ref: Library<14>-Footnote-243497115
Ref: Library<14>-Footnote-253497158
Ref: Library<14>-Footnote-263497214
Ref: Library<14>-Footnote-273497271
Ref: Library<14>-Footnote-283497328
Ref: Library<14>-Footnote-293497385
Ref: Library<14>-Footnote-303497442
Ref: Library<14>-Footnote-313497499
Ref: Library<14>-Footnote-323497556
Ref: Library<14>-Footnote-333497613
Ref: Library<14>-Footnote-343497670
Ref: Library<14>-Footnote-353497727
Ref: Library<14>-Footnote-363497784
Ref: Library<14>-Footnote-373497841
Ref: Library<14>-Footnote-383497897
Ref: Library<14>-Footnote-393497954
Ref: Library<14>-Footnote-403498011
Ref: Library<14>-Footnote-413498068
Ref: Library<14>-Footnote-423498125
Ref: Library<14>-Footnote-433498182
Ref: Library<14>-Footnote-443498239
Ref: Library<14>-Footnote-453498296
Ref: Library<14>-Footnote-463498353
Ref: Library<14>-Footnote-473498410
Ref: Library<14>-Footnote-483498467
Ref: Library<14>-Footnote-493498524
Ref: Library<14>-Footnote-503498581
Ref: Library<14>-Footnote-513498637
Ref: Library<14>-Footnote-523498694
Ref: Library<14>-Footnote-533498750
Ref: Library<14>-Footnote-543498807
Ref: Library<14>-Footnote-553498864
Ref: Library<14>-Footnote-563498921
Ref: Library<14>-Footnote-573498978
Ref: Library<14>-Footnote-583499035
Ref: Library<14>-Footnote-593499092
Ref: Library<14>-Footnote-603499149
Ref: Library<14>-Footnote-613499206
Ref: Library<14>-Footnote-623499263
Ref: Library<14>-Footnote-633499320
Ref: Library<14>-Footnote-643499377
Ref: Library<14>-Footnote-653499434
Ref: Library<14>-Footnote-663499491
Ref: Library<14>-Footnote-673499548
Ref: Library<14>-Footnote-683499605
Ref: Library<14>-Footnote-693499662
Ref: Library<14>-Footnote-703499718
Ref: Library<14>-Footnote-713499775
Ref: Library<14>-Footnote-723499832
Ref: Library<14>-Footnote-733499889
Ref: Library<14>-Footnote-743499946
Ref: Library<14>-Footnote-753500003
Ref: Library<14>-Footnote-763500059
Ref: Library<14>-Footnote-773500116
Ref: Library<14>-Footnote-783500173
Ref: Library<14>-Footnote-793500230
Ref: Library<14>-Footnote-803500287
Ref: Library<14>-Footnote-813500344
Ref: Library<14>-Footnote-823500401
Ref: Library<14>-Footnote-833500458
Ref: Library<14>-Footnote-843500514
Ref: Library<14>-Footnote-853500570
Ref: Library<14>-Footnote-863500626
Ref: Library<14>-Footnote-873500682
Ref: Library<14>-Footnote-883500739
Ref: Library<14>-Footnote-893500796
Ref: Library<14>-Footnote-903500853
Ref: Library<14>-Footnote-913500910
Ref: Library<14>-Footnote-923500967
Ref: Library<14>-Footnote-933501023
Ref: Library<14>-Footnote-943501080
Ref: Library<14>-Footnote-953501137
Ref: Library<14>-Footnote-963501194
Ref: Library<14>-Footnote-973501250
Ref: Library<14>-Footnote-983501307
Ref: Library<14>-Footnote-993501364
Ref: Library<14>-Footnote-1003501421
Ref: Library<14>-Footnote-1013501479
Ref: Library<14>-Footnote-1023501537
Ref: Library<14>-Footnote-1033501595
Ref: Library<14>-Footnote-1043501653
Ref: Library<14>-Footnote-1053501711
Ref: Library<14>-Footnote-1063501769
Ref: Library<14>-Footnote-1073501827
Ref: Library<14>-Footnote-1083501884
Ref: Library<14>-Footnote-1093501942
Ref: Library<14>-Footnote-1103501999
Ref: Library<14>-Footnote-1113502057
Ref: Library<14>-Footnote-1123502114
Ref: Library<14>-Footnote-1133502171
Ref: Library<14>-Footnote-1143502228
Ref: Library<14>-Footnote-1153502286
Ref: Library<14>-Footnote-1163502344
Ref: Library<14>-Footnote-1173502402
Ref: Library<14>-Footnote-1183502460
Ref: Library<14>-Footnote-1193502518
Ref: Library<14>-Footnote-1203502576
Ref: Library<14>-Footnote-1213502634
Ref: Library<14>-Footnote-1223502692
Ref: Library<14>-Footnote-1233502750
Ref: Library<14>-Footnote-1243502808
Ref: Library<14>-Footnote-1253502866
Ref: Library<14>-Footnote-1263502924
Ref: Library<14>-Footnote-1273502982
Ref: Library<14>-Footnote-1283503040
Ref: Library<14>-Footnote-1293503098
Ref: Library<14>-Footnote-1303503156
Ref: Library<14>-Footnote-1313503214
Ref: Library<14>-Footnote-1323503272
Ref: Library<14>-Footnote-1333503330
Ref: Library<14>-Footnote-1343503388
Ref: Library<14>-Footnote-1353503446
Ref: Library<14>-Footnote-1363503503
Ref: Library<14>-Footnote-1373503561
Ref: Library<14>-Footnote-1383503619
Ref: Library<14>-Footnote-1393503677
Ref: Library<14>-Footnote-1403503735
Ref: Library<14>-Footnote-1413503793
Ref: Library<14>-Footnote-1423503851
Ref: Library<14>-Footnote-1433503909
Ref: Library<14>-Footnote-1443503967
Ref: Library<14>-Footnote-1453504025
Ref: Library<14>-Footnote-1463504083
Ref: Library<14>-Footnote-1473504141
Ref: Library<14>-Footnote-1483504199
Ref: Library<14>-Footnote-1493504257
Ref: Library<14>-Footnote-1503504314
Ref: Library<14>-Footnote-1513504372
Ref: Library<14>-Footnote-1523504429
Ref: Library<14>-Footnote-1533504487
Ref: Library<14>-Footnote-1543504545
Ref: Library<14>-Footnote-1553504603
Ref: Library<14>-Footnote-1563504661
Ref: Library<14>-Footnote-1573504719
Ref: Library<14>-Footnote-1583504777
Ref: Library<14>-Footnote-1593504835
Ref: Library<14>-Footnote-1603504893
Ref: Library<14>-Footnote-1613504951
Ref: Library<14>-Footnote-1623505009
Ref: Library<14>-Footnote-1633505067
Ref: Library<14>-Footnote-1643505125
Ref: Library<14>-Footnote-1653505183
Ref: Library<14>-Footnote-1663505241
Ref: Library<14>-Footnote-1673505298
Ref: Library<14>-Footnote-1683505355
Ref: Library<14>-Footnote-1693505413
Ref: Library<14>-Footnote-1703505471
Ref: Library<14>-Footnote-1713505529
Ref: Library<14>-Footnote-1723505587
Ref: Library<14>-Footnote-1733505631
Ref: Library<14>-Footnote-1743505689
Ref: Library<14>-Footnote-1753505747
Ref: Library<14>-Footnote-1763505805
Ref: Library<14>-Footnote-1773505863
Ref: Library<14>-Footnote-1783505921
Ref: Library<14>-Footnote-1793505979
Ref: Library<14>-Footnote-1803506037
Ref: Library<14>-Footnote-1813506095
Ref: Library<14>-Footnote-1823506153
Ref: Library<14>-Footnote-1833506211
Ref: Library<14>-Footnote-1843506269
Ref: Library<14>-Footnote-1853506327
Ref: Library<14>-Footnote-1863506385
Ref: Library<14>-Footnote-1873506443
Ref: Library<14>-Footnote-1883506501
Ref: Library<14>-Footnote-1893506559
Ref: Library<14>-Footnote-1903506617
Ref: Library<14>-Footnote-1913506675
Ref: Library<14>-Footnote-1923506733
Ref: Library<14>-Footnote-1933506791
Ref: Library<14>-Footnote-1943506849
Ref: Library<14>-Footnote-1953506907
Ref: Library<14>-Footnote-1963506965
Ref: Library<14>-Footnote-1973507023
Ref: Library<14>-Footnote-1983507080
Ref: Library<14>-Footnote-1993507138
Ref: Library<14>-Footnote-2003507196
Ref: Library<14>-Footnote-2013507254
Ref: Library<14>-Footnote-2023507312
Ref: Library<14>-Footnote-2033507370
Ref: Library<14>-Footnote-2043507428
Ref: Library<14>-Footnote-2053507486
Ref: Library<14>-Footnote-2063507543
Ref: Library<14>-Footnote-2073507601
Ref: Library<14>-Footnote-2083507659
Ref: Library<14>-Footnote-2093507717
Ref: Library<14>-Footnote-2103507775
Ref: Library<14>-Footnote-2113507832
Ref: Library<14>-Footnote-2123507890
Ref: Library<14>-Footnote-2133507948
Ref: Library<14>-Footnote-2143508006
Ref: Library<14>-Footnote-2153508064
Ref: Library<14>-Footnote-2163508122
Ref: Library<14>-Footnote-2173508180
Ref: Library<14>-Footnote-2183508238
Ref: Library<14>-Footnote-2193508282
Ref: Library<14>-Footnote-2203508340
Ref: Library<14>-Footnote-2213508384
Ref: Library<14>-Footnote-2223508442
Ref: Library<14>-Footnote-2233508486
Ref: Library<14>-Footnote-2243508544
Ref: Library<14>-Footnote-2253508588
Ref: Library<14>-Footnote-2263508646
Ref: Library<14>-Footnote-2273508690
Ref: Library<14>-Footnote-2283508748
Ref: Library<14>-Footnote-2293508792
Ref: Library<14>-Footnote-2303508850
Ref: Library<14>-Footnote-2313508908
Ref: Library<14>-Footnote-2323508952
Ref: Library<14>-Footnote-2333509010
Ref: Library<14>-Footnote-2343509054
Ref: Library<14>-Footnote-2353509112
Ref: Library<14>-Footnote-2363509170
Ref: Library<14>-Footnote-2373509228
Ref: Library<14>-Footnote-2383509286
Ref: Library<14>-Footnote-2393509330
Ref: Library<14>-Footnote-2403509388
Ref: Library<14>-Footnote-2413509432
Ref: Library<14>-Footnote-2423509479
Ref: Library<14>-Footnote-2433509536
Ref: Library<14>-Footnote-2443509594
Ref: Library<14>-Footnote-2453509638
Ref: Library<14>-Footnote-2463509696
Ref: Library<14>-Footnote-2473509740
Ref: Library<14>-Footnote-2483509798
Ref: Library<14>-Footnote-2493509842
Ref: Library<14>-Footnote-2503509900
Ref: Library<14>-Footnote-2513509944
Ref: Library<14>-Footnote-2523510002
Ref: Library<14>-Footnote-2533510046
Ref: Library<14>-Footnote-2543510104
Ref: Library<14>-Footnote-2553510162
Ref: Library<14>-Footnote-2563510220
Ref: Library<14>-Footnote-2573510278
Ref: Library<14>-Footnote-2583510335
Ref: Library<14>-Footnote-2593510393
Ref: Library<14>-Footnote-2603510437
Ref: Library<14>-Footnote-2613510495
Ref: Library<14>-Footnote-2623510553
Ref: Library<14>-Footnote-2633510611
Ref: Library<14>-Footnote-2643510669
Ref: Library<14>-Footnote-2653510713
Ref: Library<14>-Footnote-2663510771
Ref: Library<14>-Footnote-2673510815
Ref: Library<14>-Footnote-2683510873
Ref: Library<14>-Footnote-2693510917
Ref: Library<14>-Footnote-2703510975
Ref: Library<14>-Footnote-2713511019
Ref: Library<14>-Footnote-2723511077
Ref: Library<14>-Footnote-2733511134
Ref: Library<14>-Footnote-2743511192
Ref: Library<14>-Footnote-2753511250
Ref: Library<14>-Footnote-2763511308
Ref: Library<14>-Footnote-2773511366
Ref: Library<14>-Footnote-2783511424
Ref: Library<14>-Footnote-2793511482
Ref: Library<14>-Footnote-2803511540
Ref: Library<14>-Footnote-2813511598
Ref: Library<14>-Footnote-2823511656
Ref: Library<14>-Footnote-2833511714
Ref: Library<14>-Footnote-2843511771
Ref: Library<14>-Footnote-2853511829
Ref: Library<14>-Footnote-2863511887
Ref: Library<14>-Footnote-2873511945
Ref: Library<14>-Footnote-2883512002
Ref: Library<14>-Footnote-2893512060
Ref: Library<14>-Footnote-2903512117
Ref: Library<14>-Footnote-2913512174
Ref: Library<14>-Footnote-2923512231
Ref: Library<14>-Footnote-2933512288
Ref: Library<14>-Footnote-2943512345
Ref: Library<14>-Footnote-2953512402
Ref: Library<14>-Footnote-2963512459
Ref: Library<14>-Footnote-2973512526
Ref: Library<14>-Footnote-2983512587
Ref: Library<14>-Footnote-2993512654
Ref: Library<14>-Footnote-3003512698
Ref: Library<14>-Footnote-3013512765
Ref: Library<14>-Footnote-3023512832
Ref: Library<14>-Footnote-3033512899
Ref: Library<14>-Footnote-3043512966
Node: Documentation<9>3513033
Ref: whatsnew/changelog id1073513145
Ref: 16703513145
Ref: Documentation<9>-Footnote-13515097
Ref: Documentation<9>-Footnote-23515153
Ref: Documentation<9>-Footnote-33515209
Ref: Documentation<9>-Footnote-43515265
Ref: Documentation<9>-Footnote-53515321
Ref: Documentation<9>-Footnote-63515377
Ref: Documentation<9>-Footnote-73515433
Ref: Documentation<9>-Footnote-83515489
Ref: Documentation<9>-Footnote-93515545
Ref: Documentation<9>-Footnote-103515600
Ref: Documentation<9>-Footnote-113515656
Ref: Documentation<9>-Footnote-123515713
Ref: Documentation<9>-Footnote-133515769
Ref: Documentation<9>-Footnote-143515826
Node: Tests<12>3515883
Ref: whatsnew/changelog id1083515993
Ref: 16733515993
Ref: Tests<12>-Footnote-13529123
Ref: Tests<12>-Footnote-23529179
Ref: Tests<12>-Footnote-33529235
Ref: Tests<12>-Footnote-43529291
Ref: Tests<12>-Footnote-53529347
Ref: Tests<12>-Footnote-63529402
Ref: Tests<12>-Footnote-73529458
Ref: Tests<12>-Footnote-83529514
Ref: Tests<12>-Footnote-93529570
Ref: Tests<12>-Footnote-103529626
Ref: Tests<12>-Footnote-113529683
Ref: Tests<12>-Footnote-123529740
Ref: Tests<12>-Footnote-133529797
Ref: Tests<12>-Footnote-143529854
Ref: Tests<12>-Footnote-153529911
Ref: Tests<12>-Footnote-163529968
Ref: Tests<12>-Footnote-173530025
Ref: Tests<12>-Footnote-183530082
Ref: Tests<12>-Footnote-193530139
Ref: Tests<12>-Footnote-203530196
Ref: Tests<12>-Footnote-213530253
Ref: Tests<12>-Footnote-223530310
Ref: Tests<12>-Footnote-233530367
Ref: Tests<12>-Footnote-243530424
Ref: Tests<12>-Footnote-253530481
Ref: Tests<12>-Footnote-263530538
Ref: Tests<12>-Footnote-273530595
Ref: Tests<12>-Footnote-283530652
Ref: Tests<12>-Footnote-293530709
Ref: Tests<12>-Footnote-303530766
Ref: Tests<12>-Footnote-313530823
Ref: Tests<12>-Footnote-323530880
Ref: Tests<12>-Footnote-333530937
Ref: Tests<12>-Footnote-343530981
Ref: Tests<12>-Footnote-353531037
Ref: Tests<12>-Footnote-363531094
Ref: Tests<12>-Footnote-373531150
Ref: Tests<12>-Footnote-383531206
Ref: Tests<12>-Footnote-393531263
Ref: Tests<12>-Footnote-403531320
Ref: Tests<12>-Footnote-413531377
Ref: Tests<12>-Footnote-423531434
Ref: Tests<12>-Footnote-433531491
Ref: Tests<12>-Footnote-443531548
Ref: Tests<12>-Footnote-453531605
Ref: Tests<12>-Footnote-463531662
Ref: Tests<12>-Footnote-473531719
Ref: Tests<12>-Footnote-483531776
Ref: Tests<12>-Footnote-493531833
Ref: Tests<12>-Footnote-503531890
Ref: Tests<12>-Footnote-513531947
Ref: Tests<12>-Footnote-523532004
Ref: Tests<12>-Footnote-533532061
Ref: Tests<12>-Footnote-543532118
Ref: Tests<12>-Footnote-553532175
Ref: Tests<12>-Footnote-563532232
Ref: Tests<12>-Footnote-573532289
Ref: Tests<12>-Footnote-583532345
Ref: Tests<12>-Footnote-593532402
Node: Build<14>3532458
Ref: whatsnew/changelog id1093532563
Ref: 16753532563
Ref: Build<14>-Footnote-13536550
Ref: Build<14>-Footnote-23536606
Ref: Build<14>-Footnote-33536662
Ref: Build<14>-Footnote-43536718
Ref: Build<14>-Footnote-53536774
Ref: Build<14>-Footnote-63536830
Ref: Build<14>-Footnote-73536886
Ref: Build<14>-Footnote-83536941
Ref: Build<14>-Footnote-93536997
Ref: Build<14>-Footnote-103537053
Ref: Build<14>-Footnote-113537109
Ref: Build<14>-Footnote-123537166
Ref: Build<14>-Footnote-133537223
Ref: Build<14>-Footnote-143537280
Ref: Build<14>-Footnote-153537337
Ref: Build<14>-Footnote-163537393
Ref: Build<14>-Footnote-173537450
Ref: Build<14>-Footnote-183537507
Ref: Build<14>-Footnote-193537564
Ref: Build<14>-Footnote-203537621
Ref: Build<14>-Footnote-213537677
Ref: Build<14>-Footnote-223537734
Ref: Build<14>-Footnote-233537790
Ref: Build<14>-Footnote-243537847
Node: Windows<11>3537904
Ref: whatsnew/changelog id1103538008
Ref: 16773538008
Ref: Windows<11>-Footnote-13540522
Ref: Windows<11>-Footnote-23540578
Ref: Windows<11>-Footnote-33540634
Ref: Windows<11>-Footnote-43540689
Ref: Windows<11>-Footnote-53540745
Ref: Windows<11>-Footnote-63540801
Ref: Windows<11>-Footnote-73540856
Ref: Windows<11>-Footnote-83540912
Ref: Windows<11>-Footnote-93540968
Ref: Windows<11>-Footnote-103541024
Ref: Windows<11>-Footnote-113541081
Ref: Windows<11>-Footnote-123541137
Ref: Windows<11>-Footnote-133541194
Node: macOS<9>3541251
Ref: whatsnew/changelog id1113541354
Ref: 16783541354
Ref: macOS<9>-Footnote-13541618
Ref: macOS<9>-Footnote-23541674
Ref: macOS<9>-Footnote-33541730
Node: IDLE<13>3541785
Ref: whatsnew/changelog id1123541891
Ref: 16793541891
Ref: IDLE<13>-Footnote-13542080
Node: Tools/Demos<6>3542136
Ref: whatsnew/changelog id1133542243
Ref: 167a3542243
Ref: Tools/Demos<6>-Footnote-13544757
Ref: Tools/Demos<6>-Footnote-23544813
Ref: Tools/Demos<6>-Footnote-33544869
Ref: Tools/Demos<6>-Footnote-43544931
Ref: Tools/Demos<6>-Footnote-53545020
Ref: Tools/Demos<6>-Footnote-63545076
Ref: Tools/Demos<6>-Footnote-73545170
Ref: Tools/Demos<6>-Footnote-83545226
Ref: Tools/Demos<6>-Footnote-93545282
Ref: Tools/Demos<6>-Footnote-103545337
Ref: Tools/Demos<6>-Footnote-113545433
Ref: Tools/Demos<6>-Footnote-123545490
Ref: Tools/Demos<6>-Footnote-133545547
Ref: Tools/Demos<6>-Footnote-143545604
Ref: Tools/Demos<6>-Footnote-153545661
Ref: Tools/Demos<6>-Footnote-163545718
Ref: Tools/Demos<6>-Footnote-173545775
Ref: Tools/Demos<6>-Footnote-183545831
Node: C API<14>3545929
Ref: whatsnew/changelog id1143546019
Ref: 167b3546019
Ref: C API<14>-Footnote-13560931
Ref: C API<14>-Footnote-23560986
Ref: C API<14>-Footnote-33561042
Ref: C API<14>-Footnote-43561098
Ref: C API<14>-Footnote-53561154
Ref: C API<14>-Footnote-63561210
Ref: C API<14>-Footnote-73561266
Ref: C API<14>-Footnote-83561321
Ref: C API<14>-Footnote-93561377
Ref: C API<14>-Footnote-103561433
Ref: C API<14>-Footnote-113561490
Ref: C API<14>-Footnote-123561547
Ref: C API<14>-Footnote-133561604
Ref: C API<14>-Footnote-143561661
Ref: C API<14>-Footnote-153561718
Ref: C API<14>-Footnote-163561775
Ref: C API<14>-Footnote-173561832
Ref: C API<14>-Footnote-183561889
Ref: C API<14>-Footnote-193561946
Ref: C API<14>-Footnote-203562003
Ref: C API<14>-Footnote-213562060
Ref: C API<14>-Footnote-223562117
Ref: C API<14>-Footnote-233562174
Ref: C API<14>-Footnote-243562231
Ref: C API<14>-Footnote-253562288
Ref: C API<14>-Footnote-263562345
Ref: C API<14>-Footnote-273562402
Ref: C API<14>-Footnote-283562459
Ref: C API<14>-Footnote-293562516
Ref: C API<14>-Footnote-303562573
Ref: C API<14>-Footnote-313562630
Ref: C API<14>-Footnote-323562687
Ref: C API<14>-Footnote-333562730
Ref: C API<14>-Footnote-343562787
Ref: C API<14>-Footnote-353562844
Ref: C API<14>-Footnote-363562901
Ref: C API<14>-Footnote-373562958
Ref: C API<14>-Footnote-383563015
Ref: C API<14>-Footnote-393563072
Ref: C API<14>-Footnote-403563129
Ref: C API<14>-Footnote-413563186
Ref: C API<14>-Footnote-423563243
Ref: C API<14>-Footnote-433563300
Ref: C API<14>-Footnote-443563357
Ref: C API<14>-Footnote-453563414
Ref: C API<14>-Footnote-463563471
Ref: C API<14>-Footnote-473563528
Ref: C API<14>-Footnote-483563585
Ref: C API<14>-Footnote-493563642
Ref: C API<14>-Footnote-503563698
Ref: C API<14>-Footnote-513563755
Ref: C API<14>-Footnote-523563812
Ref: C API<14>-Footnote-533563869
Ref: C API<14>-Footnote-543563926
Ref: C API<14>-Footnote-553563983
Ref: C API<14>-Footnote-563564040
Ref: C API<14>-Footnote-573564097
Ref: C API<14>-Footnote-583564154
Ref: C API<14>-Footnote-593564220
Node: Python 3 12 0 beta 13564286
Ref: whatsnew/changelog python-3-12-0-beta-13564415
Ref: 16873564415
Node: Security<10>3564795
Ref: whatsnew/changelog id1153564894
Ref: 16883564894
Ref: Security<10>-Footnote-13565713
Ref: Security<10>-Footnote-23565768
Ref: Security<10>-Footnote-33565824
Ref: Security<10>-Footnote-43565879
Ref: Security<10>-Footnote-53565935
Node: Core and Builtins<16>3565991
Ref: whatsnew/changelog id1163566110
Ref: 16893566110
Ref: Core and Builtins<16>-Footnote-13577087
Ref: Core and Builtins<16>-Footnote-23577143
Ref: Core and Builtins<16>-Footnote-33577199
Ref: Core and Builtins<16>-Footnote-43577255
Ref: Core and Builtins<16>-Footnote-53577297
Ref: Core and Builtins<16>-Footnote-63577353
Ref: Core and Builtins<16>-Footnote-73577409
Ref: Core and Builtins<16>-Footnote-83577465
Ref: Core and Builtins<16>-Footnote-93577507
Ref: Core and Builtins<16>-Footnote-103577563
Ref: Core and Builtins<16>-Footnote-113577620
Ref: Core and Builtins<16>-Footnote-123577676
Ref: Core and Builtins<16>-Footnote-133577732
Ref: Core and Builtins<16>-Footnote-143577789
Ref: Core and Builtins<16>-Footnote-153577846
Ref: Core and Builtins<16>-Footnote-163577889
Ref: Core and Builtins<16>-Footnote-173577946
Ref: Core and Builtins<16>-Footnote-183578003
Ref: Core and Builtins<16>-Footnote-193578060
Ref: Core and Builtins<16>-Footnote-203578117
Ref: Core and Builtins<16>-Footnote-213578174
Ref: Core and Builtins<16>-Footnote-223578231
Ref: Core and Builtins<16>-Footnote-233578288
Ref: Core and Builtins<16>-Footnote-243578345
Ref: Core and Builtins<16>-Footnote-253578402
Ref: Core and Builtins<16>-Footnote-263578459
Ref: Core and Builtins<16>-Footnote-273578502
Ref: Core and Builtins<16>-Footnote-283578559
Ref: Core and Builtins<16>-Footnote-293578616
Ref: Core and Builtins<16>-Footnote-303578673
Ref: Core and Builtins<16>-Footnote-313578730
Ref: Core and Builtins<16>-Footnote-323578787
Ref: Core and Builtins<16>-Footnote-333578844
Ref: Core and Builtins<16>-Footnote-343578901
Ref: Core and Builtins<16>-Footnote-353578958
Ref: Core and Builtins<16>-Footnote-363579015
Ref: Core and Builtins<16>-Footnote-373579071
Ref: Core and Builtins<16>-Footnote-383579128
Ref: Core and Builtins<16>-Footnote-393579184
Ref: Core and Builtins<16>-Footnote-403579240
Ref: Core and Builtins<16>-Footnote-413579283
Ref: Core and Builtins<16>-Footnote-423579340
Ref: Core and Builtins<16>-Footnote-433579397
Ref: Core and Builtins<16>-Footnote-443579454
Ref: Core and Builtins<16>-Footnote-453579510
Ref: Core and Builtins<16>-Footnote-463579567
Ref: Core and Builtins<16>-Footnote-473579624
Ref: Core and Builtins<16>-Footnote-483579667
Ref: Core and Builtins<16>-Footnote-493579723
Ref: Core and Builtins<16>-Footnote-503579780
Ref: Core and Builtins<16>-Footnote-513579823
Ref: Core and Builtins<16>-Footnote-523579879
Ref: Core and Builtins<16>-Footnote-533579922
Ref: Core and Builtins<16>-Footnote-543579978
Ref: Core and Builtins<16>-Footnote-553580034
Ref: Core and Builtins<16>-Footnote-563580100
Node: Library<15>3580166
Ref: whatsnew/changelog id1173580290
Ref: 168a3580290
Ref: Library<15>-Footnote-13603759
Ref: Library<15>-Footnote-23603815
Ref: Library<15>-Footnote-33603857
Ref: Library<15>-Footnote-43603913
Ref: Library<15>-Footnote-53603969
Ref: Library<15>-Footnote-63604025
Ref: Library<15>-Footnote-73604081
Ref: Library<15>-Footnote-83604136
Ref: Library<15>-Footnote-93604192
Ref: Library<15>-Footnote-103604248
Ref: Library<15>-Footnote-113604305
Ref: Library<15>-Footnote-123604362
Ref: Library<15>-Footnote-133604419
Ref: Library<15>-Footnote-143604476
Ref: Library<15>-Footnote-153604533
Ref: Library<15>-Footnote-163604590
Ref: Library<15>-Footnote-173604666
Ref: Library<15>-Footnote-183604723
Ref: Library<15>-Footnote-193604780
Ref: Library<15>-Footnote-203604836
Ref: Library<15>-Footnote-213604893
Ref: Library<15>-Footnote-223604959
Ref: Library<15>-Footnote-233605016
Ref: Library<15>-Footnote-243605072
Ref: Library<15>-Footnote-253605128
Ref: Library<15>-Footnote-263605185
Ref: Library<15>-Footnote-273605242
Ref: Library<15>-Footnote-283605299
Ref: Library<15>-Footnote-293605356
Ref: Library<15>-Footnote-303605413
Ref: Library<15>-Footnote-313605470
Ref: Library<15>-Footnote-323605527
Ref: Library<15>-Footnote-333605570
Ref: Library<15>-Footnote-343605627
Ref: Library<15>-Footnote-353605684
Ref: Library<15>-Footnote-363605741
Ref: Library<15>-Footnote-373605798
Ref: Library<15>-Footnote-383605854
Ref: Library<15>-Footnote-393605911
Ref: Library<15>-Footnote-403605967
Ref: Library<15>-Footnote-413606024
Ref: Library<15>-Footnote-423606081
Ref: Library<15>-Footnote-433606138
Ref: Library<15>-Footnote-443606195
Ref: Library<15>-Footnote-453606252
Ref: Library<15>-Footnote-463606309
Ref: Library<15>-Footnote-473606365
Ref: Library<15>-Footnote-483606421
Ref: Library<15>-Footnote-493606478
Ref: Library<15>-Footnote-503606535
Ref: Library<15>-Footnote-513606592
Ref: Library<15>-Footnote-523606649
Ref: Library<15>-Footnote-533606705
Ref: Library<15>-Footnote-543606762
Ref: Library<15>-Footnote-553606818
Ref: Library<15>-Footnote-563606875
Ref: Library<15>-Footnote-573606932
Ref: Library<15>-Footnote-583606988
Ref: Library<15>-Footnote-593607044
Ref: Library<15>-Footnote-603607101
Ref: Library<15>-Footnote-613607158
Ref: Library<15>-Footnote-623607214
Ref: Library<15>-Footnote-633607271
Ref: Library<15>-Footnote-643607328
Ref: Library<15>-Footnote-653607385
Ref: Library<15>-Footnote-663607442
Ref: Library<15>-Footnote-673607499
Ref: Library<15>-Footnote-683607556
Ref: Library<15>-Footnote-693607613
Ref: Library<15>-Footnote-703607670
Ref: Library<15>-Footnote-713607727
Ref: Library<15>-Footnote-723607784
Ref: Library<15>-Footnote-733607841
Ref: Library<15>-Footnote-743607898
Ref: Library<15>-Footnote-753607955
Ref: Library<15>-Footnote-763608012
Ref: Library<15>-Footnote-773608069
Ref: Library<15>-Footnote-783608112
Ref: Library<15>-Footnote-793608169
Ref: Library<15>-Footnote-803608226
Ref: Library<15>-Footnote-813608269
Ref: Library<15>-Footnote-823608325
Ref: Library<15>-Footnote-833608381
Ref: Library<15>-Footnote-843608438
Ref: Library<15>-Footnote-853608495
Ref: Library<15>-Footnote-863608552
Ref: Library<15>-Footnote-873608609
Ref: Library<15>-Footnote-883608666
Ref: Library<15>-Footnote-893608709
Ref: Library<15>-Footnote-903608766
Ref: Library<15>-Footnote-913608809
Ref: Library<15>-Footnote-923608865
Ref: Library<15>-Footnote-933608922
Ref: Library<15>-Footnote-943608979
Ref: Library<15>-Footnote-953609022
Ref: Library<15>-Footnote-963609079
Ref: Library<15>-Footnote-973609136
Ref: Library<15>-Footnote-983609193
Ref: Library<15>-Footnote-993609249
Ref: Library<15>-Footnote-1003609306
Ref: Library<15>-Footnote-1013609364
Ref: Library<15>-Footnote-1023609422
Ref: Library<15>-Footnote-1033609480
Ref: Library<15>-Footnote-1043609538
Ref: Library<15>-Footnote-1053609596
Ref: Library<15>-Footnote-1063609653
Ref: Library<15>-Footnote-1073609710
Ref: Library<15>-Footnote-1083609768
Ref: Library<15>-Footnote-1093609812
Ref: Library<15>-Footnote-1103609869
Ref: Library<15>-Footnote-1113609927
Ref: Library<15>-Footnote-1123609985
Ref: Library<15>-Footnote-1133610042
Ref: Library<15>-Footnote-1143610099
Ref: Library<15>-Footnote-1153610156
Ref: Library<15>-Footnote-1163610214
Ref: Library<15>-Footnote-1173610272
Ref: Library<15>-Footnote-1183610329
Ref: Library<15>-Footnote-1193610386
Ref: Library<15>-Footnote-1203610443
Ref: Library<15>-Footnote-1213610500
Ref: Library<15>-Footnote-1223610557
Ref: Library<15>-Footnote-1233610614
Ref: Library<15>-Footnote-1243610671
Ref: Library<15>-Footnote-1253610728
Ref: Library<15>-Footnote-1263610785
Ref: Library<15>-Footnote-1273610842
Ref: Library<15>-Footnote-1283610899
Ref: Library<15>-Footnote-1293610956
Ref: Library<15>-Footnote-1303611013
Ref: Library<15>-Footnote-1313611070
Ref: Library<15>-Footnote-1323611127
Ref: Library<15>-Footnote-1333611194
Ref: Library<15>-Footnote-1343611261
Ref: Library<15>-Footnote-1353611328
Ref: Library<15>-Footnote-1363611395
Ref: Library<15>-Footnote-1373611462
Ref: Library<15>-Footnote-1383611529
Ref: Library<15>-Footnote-1393611596
Node: Documentation<10>3611663
Ref: whatsnew/changelog id1183611775
Ref: 16973611775
Ref: Documentation<10>-Footnote-13612548
Ref: Documentation<10>-Footnote-23612603
Ref: Documentation<10>-Footnote-33612659
Ref: Documentation<10>-Footnote-43612701
Ref: Documentation<10>-Footnote-53612756
Ref: Documentation<10>-Footnote-63612811
Node: Tests<13>3612866
Ref: whatsnew/changelog id1193612976
Ref: 16983612976
Ref: Tests<13>-Footnote-13613889
Ref: Tests<13>-Footnote-23613945
Ref: Tests<13>-Footnote-33614001
Ref: Tests<13>-Footnote-43614056
Ref: Tests<13>-Footnote-53614112
Ref: Tests<13>-Footnote-63614168
Node: Build<15>3614223
Ref: whatsnew/changelog id1203614327
Ref: 169a3614327
Ref: Build<15>-Footnote-13615911
Ref: Build<15>-Footnote-23615967
Ref: Build<15>-Footnote-33616022
Ref: Build<15>-Footnote-43616078
Ref: Build<15>-Footnote-53616134
Ref: Build<15>-Footnote-63616190
Ref: Build<15>-Footnote-73616245
Ref: Build<15>-Footnote-83616300
Ref: Build<15>-Footnote-93616356
Node: Windows<12>3616411
Ref: whatsnew/changelog id1213616515
Ref: 169b3616515
Ref: Windows<12>-Footnote-13617368
Ref: Windows<12>-Footnote-23617424
Ref: Windows<12>-Footnote-33617479
Ref: Windows<12>-Footnote-43617535
Ref: Windows<12>-Footnote-53617591
Ref: Windows<12>-Footnote-63617647
Node: macOS<10>3617702
Ref: whatsnew/changelog id1223617805
Ref: 169c3617805
Ref: macOS<10>-Footnote-13618607
Ref: macOS<10>-Footnote-23618662
Ref: macOS<10>-Footnote-33618718
Ref: macOS<10>-Footnote-43618774
Ref: macOS<10>-Footnote-53618830
Ref: macOS<10>-Footnote-63618885
Node: IDLE<14>3618941
Ref: whatsnew/changelog id1233619047
Ref: 169d3619047
Ref: IDLE<14>-Footnote-13619329
Ref: IDLE<14>-Footnote-23619385
Ref: IDLE<14>-Footnote-33619441
Node: Tools/Demos<7>3619496
Ref: whatsnew/changelog id1243619602
Ref: 169e3619602
Ref: Tools/Demos<7>-Footnote-13619862
Node: C API<15>3619918
Ref: whatsnew/changelog id1253620007
Ref: 169f3620007
Ref: C API<15>-Footnote-13622985
Ref: C API<15>-Footnote-23623041
Ref: C API<15>-Footnote-33623097
Ref: C API<15>-Footnote-43623153
Ref: C API<15>-Footnote-53623209
Ref: C API<15>-Footnote-63623265
Ref: C API<15>-Footnote-73623321
Ref: C API<15>-Footnote-83623363
Ref: C API<15>-Footnote-93623419
Ref: C API<15>-Footnote-103623475
Ref: C API<15>-Footnote-113623531
Node: Python 3 12 0 alpha 73623587
Ref: whatsnew/changelog python-3-12-0-alpha-73623716
Ref: 16a63623716
Node: Core and Builtins<17>3624034
Ref: whatsnew/changelog id1263624133
Ref: 16a73624133
Ref: Core and Builtins<17>-Footnote-13627266
Ref: Core and Builtins<17>-Footnote-23627322
Ref: Core and Builtins<17>-Footnote-33627377
Ref: Core and Builtins<17>-Footnote-43627433
Ref: Core and Builtins<17>-Footnote-53627489
Ref: Core and Builtins<17>-Footnote-63627545
Ref: Core and Builtins<17>-Footnote-73627601
Ref: Core and Builtins<17>-Footnote-83627657
Ref: Core and Builtins<17>-Footnote-93627713
Ref: Core and Builtins<17>-Footnote-103627769
Ref: Core and Builtins<17>-Footnote-113627825
Ref: Core and Builtins<17>-Footnote-123627882
Ref: Core and Builtins<17>-Footnote-133627939
Ref: Core and Builtins<17>-Footnote-143627996
Ref: Core and Builtins<17>-Footnote-153628053
Ref: Core and Builtins<17>-Footnote-163628096
Ref: Core and Builtins<17>-Footnote-173628153
Ref: Core and Builtins<17>-Footnote-183628210
Ref: Core and Builtins<17>-Footnote-193628267
Ref: Core and Builtins<17>-Footnote-203628324
Ref: Core and Builtins<17>-Footnote-213628381
Ref: Core and Builtins<17>-Footnote-223628438
Ref: Core and Builtins<17>-Footnote-233628506
Node: Library<16>3628549
Ref: whatsnew/changelog id1273628674
Ref: 16a93628674
Ref: Library<16>-Footnote-13636493
Ref: Library<16>-Footnote-23636549
Ref: Library<16>-Footnote-33636605
Ref: Library<16>-Footnote-43636661
Ref: Library<16>-Footnote-53636717
Ref: Library<16>-Footnote-63636773
Ref: Library<16>-Footnote-73636829
Ref: Library<16>-Footnote-83636885
Ref: Library<16>-Footnote-93636941
Ref: Library<16>-Footnote-103636997
Ref: Library<16>-Footnote-113637054
Ref: Library<16>-Footnote-123637111
Ref: Library<16>-Footnote-133637168
Ref: Library<16>-Footnote-143637224
Ref: Library<16>-Footnote-153637280
Ref: Library<16>-Footnote-163637336
Ref: Library<16>-Footnote-173637393
Ref: Library<16>-Footnote-183637450
Ref: Library<16>-Footnote-193637507
Ref: Library<16>-Footnote-203637564
Ref: Library<16>-Footnote-213637621
Ref: Library<16>-Footnote-223637678
Ref: Library<16>-Footnote-233637734
Ref: Library<16>-Footnote-243637791
Ref: Library<16>-Footnote-253637847
Ref: Library<16>-Footnote-263637904
Ref: Library<16>-Footnote-273637961
Ref: Library<16>-Footnote-283638018
Ref: Library<16>-Footnote-293638074
Ref: Library<16>-Footnote-303638131
Ref: Library<16>-Footnote-313638188
Ref: Library<16>-Footnote-323638245
Ref: Library<16>-Footnote-333638301
Ref: Library<16>-Footnote-343638358
Ref: Library<16>-Footnote-353638414
Ref: Library<16>-Footnote-363638470
Ref: Library<16>-Footnote-373638526
Ref: Library<16>-Footnote-383638582
Ref: Library<16>-Footnote-393638638
Ref: Library<16>-Footnote-403638694
Ref: Library<16>-Footnote-413638750
Node: Documentation<11>3638816
Ref: whatsnew/changelog id1283638929
Ref: 16b23638929
Ref: Documentation<11>-Footnote-13639128
Node: Tests<14>3639184
Ref: whatsnew/changelog id1293639295
Ref: 16b43639295
Ref: Tests<14>-Footnote-13639652
Ref: Tests<14>-Footnote-23639708
Ref: Tests<14>-Footnote-33639764
Node: Build<16>3639820
Ref: whatsnew/changelog id1303639925
Ref: 16b53639925
Ref: Build<16>-Footnote-13640171
Ref: Build<16>-Footnote-23640227
Node: Windows<13>3640283
Ref: whatsnew/changelog id1313640393
Ref: 16b63640393
Ref: Windows<13>-Footnote-13640690
Ref: Windows<13>-Footnote-23640746
Node: Tools/Demos<8>3640801
Ref: whatsnew/changelog id1323640911
Ref: 16b73640911
Ref: Tools/Demos<8>-Footnote-13641044
Node: C API<16>3641100
Ref: whatsnew/changelog id1333641190
Ref: 16b83641190
Ref: C API<16>-Footnote-13641404
Node: Python 3 12 0 alpha 63641460
Ref: whatsnew/changelog python-3-12-0-alpha-63641590
Ref: 16b93641590
Node: Security<11>3641923
Ref: whatsnew/changelog id1343642023
Ref: 16ba3642023
Ref: Security<11>-Footnote-13642961
Ref: Security<11>-Footnote-23643016
Ref: Security<11>-Footnote-33643072
Ref: Security<11>-Footnote-43643127
Ref: Security<11>-Footnote-53643182
Ref: Security<11>-Footnote-63643237
Ref: Security<11>-Footnote-73643298
Ref: Security<11>-Footnote-83643353
Ref: Security<11>-Footnote-93643401
Node: Core and Builtins<18>3643457
Ref: whatsnew/changelog id1353643577
Ref: 16bb3643577
Ref: Core and Builtins<18>-Footnote-13647211
Ref: Core and Builtins<18>-Footnote-23647267
Ref: Core and Builtins<18>-Footnote-33647323
Ref: Core and Builtins<18>-Footnote-43647379
Ref: Core and Builtins<18>-Footnote-53647435
Ref: Core and Builtins<18>-Footnote-63647491
Ref: Core and Builtins<18>-Footnote-73647547
Ref: Core and Builtins<18>-Footnote-83647603
Ref: Core and Builtins<18>-Footnote-93647659
Ref: Core and Builtins<18>-Footnote-103647715
Ref: Core and Builtins<18>-Footnote-113647772
Ref: Core and Builtins<18>-Footnote-123647829
Ref: Core and Builtins<18>-Footnote-133647885
Ref: Core and Builtins<18>-Footnote-143647942
Ref: Core and Builtins<18>-Footnote-153647999
Ref: Core and Builtins<18>-Footnote-163648055
Ref: Core and Builtins<18>-Footnote-173648111
Ref: Core and Builtins<18>-Footnote-183648168
Ref: Core and Builtins<18>-Footnote-193648225
Ref: Core and Builtins<18>-Footnote-203648282
Ref: Core and Builtins<18>-Footnote-213648339
Ref: Core and Builtins<18>-Footnote-223648396
Node: Library<17>3648452
Ref: whatsnew/changelog id1363648577
Ref: 16bf3648577
Ref: Library<17>-Footnote-13654401
Ref: Library<17>-Footnote-23654457
Ref: Library<17>-Footnote-33654513
Ref: Library<17>-Footnote-43654568
Ref: Library<17>-Footnote-53654623
Ref: Library<17>-Footnote-63654679
Ref: Library<17>-Footnote-73654735
Ref: Library<17>-Footnote-83654791
Ref: Library<17>-Footnote-93654847
Ref: Library<17>-Footnote-103654914
Ref: Library<17>-Footnote-113654970
Ref: Library<17>-Footnote-123655054
Ref: Library<17>-Footnote-133655111
Ref: Library<17>-Footnote-143655167
Ref: Library<17>-Footnote-153655224
Ref: Library<17>-Footnote-163655280
Ref: Library<17>-Footnote-173655336
Ref: Library<17>-Footnote-183655393
Ref: Library<17>-Footnote-193655450
Ref: Library<17>-Footnote-203655507
Ref: Library<17>-Footnote-213655564
Ref: Library<17>-Footnote-223655621
Ref: Library<17>-Footnote-233655678
Ref: Library<17>-Footnote-243655735
Ref: Library<17>-Footnote-253655791
Ref: Library<17>-Footnote-263655848
Ref: Library<17>-Footnote-273655891
Ref: Library<17>-Footnote-283655947
Ref: Library<17>-Footnote-293656004
Ref: Library<17>-Footnote-303656061
Ref: Library<17>-Footnote-313656104
Ref: Library<17>-Footnote-323656161
Ref: Library<17>-Footnote-333656217
Ref: Library<17>-Footnote-343656260
Ref: Library<17>-Footnote-353656316
Ref: Library<17>-Footnote-363656372
Node: Documentation<12>3656438
Ref: whatsnew/changelog id1373656551
Ref: 16c93656551
Ref: Documentation<12>-Footnote-13656860
Ref: Documentation<12>-Footnote-23656915
Node: Tests<15>3656970
Ref: whatsnew/changelog id1383657081
Ref: 16cb3657081
Ref: Tests<15>-Footnote-13657653
Ref: Tests<15>-Footnote-23657709
Ref: Tests<15>-Footnote-33657764
Node: Build<17>3657819
Ref: whatsnew/changelog id1393657924
Ref: 16cc3657924
Ref: Build<17>-Footnote-13658603
Ref: Build<17>-Footnote-23658658
Ref: Build<17>-Footnote-33658713
Ref: Build<17>-Footnote-43658769
Node: Windows<14>3658824
Ref: whatsnew/changelog id1403658929
Ref: 16ce3658929
Ref: Windows<14>-Footnote-13659948
Ref: Windows<14>-Footnote-23660004
Ref: Windows<14>-Footnote-33660060
Ref: Windows<14>-Footnote-43660116
Ref: Windows<14>-Footnote-53660172
Ref: Windows<14>-Footnote-63660228
Ref: Windows<14>-Footnote-73660284
Ref: Windows<14>-Footnote-83660340
Node: macOS<11>3660396
Ref: whatsnew/changelog id1413660501
Ref: 16cf3660501
Ref: macOS<11>-Footnote-13660631
Node: C API<17>3660687
Ref: whatsnew/changelog id1423660772
Ref: 16d03660772
Ref: C API<17>-Footnote-13661867
Ref: C API<17>-Footnote-23661923
Ref: C API<17>-Footnote-33661978
Ref: C API<17>-Footnote-43662034
Ref: C API<17>-Footnote-53662089
Node: Python 3 12 0 alpha 53662131
Ref: whatsnew/changelog python-3-12-0-alpha-53662261
Ref: 16d13662261
Node: Security<12>3662554
Ref: whatsnew/changelog id1433662654
Ref: 16d23662654
Ref: Security<12>-Footnote-13663032
Ref: Security<12>-Footnote-23663087
Node: Core and Builtins<19>3663135
Ref: whatsnew/changelog id1453663255
Ref: 16d33663255
Ref: Core and Builtins<19>-Footnote-13666351
Ref: Core and Builtins<19>-Footnote-23666406
Ref: Core and Builtins<19>-Footnote-33666461
Ref: Core and Builtins<19>-Footnote-43666517
Ref: Core and Builtins<19>-Footnote-53666573
Ref: Core and Builtins<19>-Footnote-63666629
Ref: Core and Builtins<19>-Footnote-73666685
Ref: Core and Builtins<19>-Footnote-83666741
Ref: Core and Builtins<19>-Footnote-93666797
Ref: Core and Builtins<19>-Footnote-103666853
Ref: Core and Builtins<19>-Footnote-113666910
Ref: Core and Builtins<19>-Footnote-123666967
Ref: Core and Builtins<19>-Footnote-133667024
Ref: Core and Builtins<19>-Footnote-143667081
Ref: Core and Builtins<19>-Footnote-153667137
Ref: Core and Builtins<19>-Footnote-163667194
Ref: Core and Builtins<19>-Footnote-173667251
Node: Library<18>3667317
Ref: whatsnew/changelog id1463667442
Ref: 16d73667442
Ref: Library<18>-Footnote-13672494
Ref: Library<18>-Footnote-23672550
Ref: Library<18>-Footnote-33672606
Ref: Library<18>-Footnote-43672662
Ref: Library<18>-Footnote-53672718
Ref: Library<18>-Footnote-63672774
Ref: Library<18>-Footnote-73672829
Ref: Library<18>-Footnote-83672871
Ref: Library<18>-Footnote-93672927
Ref: Library<18>-Footnote-103672983
Ref: Library<18>-Footnote-113673040
Ref: Library<18>-Footnote-123673096
Ref: Library<18>-Footnote-133673153
Ref: Library<18>-Footnote-143673210
Ref: Library<18>-Footnote-153673267
Ref: Library<18>-Footnote-163673323
Ref: Library<18>-Footnote-173673380
Ref: Library<18>-Footnote-183673437
Ref: Library<18>-Footnote-193673493
Ref: Library<18>-Footnote-203673549
Ref: Library<18>-Footnote-213673605
Ref: Library<18>-Footnote-223673661
Ref: Library<18>-Footnote-233673717
Ref: Library<18>-Footnote-243673773
Ref: Library<18>-Footnote-253673829
Ref: Library<18>-Footnote-263673885
Ref: Library<18>-Footnote-273673951
Ref: Library<18>-Footnote-283674017
Ref: Library<18>-Footnote-293674083
Node: Documentation<13>3674139
Ref: whatsnew/changelog id1473674252
Ref: 16e03674252
Ref: Documentation<13>-Footnote-13674537
Node: Tests<16>3674592
Ref: whatsnew/changelog id1483674703
Ref: 16e13674703
Ref: Tests<16>-Footnote-13674865
Node: Build<18>3674921
Ref: whatsnew/changelog id1493675026
Ref: 16e23675026
Ref: Build<18>-Footnote-13676465
Ref: Build<18>-Footnote-23676521
Ref: Build<18>-Footnote-33676577
Ref: Build<18>-Footnote-43676632
Ref: Build<18>-Footnote-53676688
Ref: Build<18>-Footnote-63676730
Ref: Build<18>-Footnote-73676786
Ref: Build<18>-Footnote-83676842
Ref: Build<18>-Footnote-93676897
Ref: Build<18>-Footnote-103676952
Node: Windows<15>3677008
Ref: whatsnew/changelog id1503677095
Ref: 16e33677095
Ref: Windows<15>-Footnote-13678345
Ref: Windows<15>-Footnote-23678401
Ref: Windows<15>-Footnote-33678457
Ref: Windows<15>-Footnote-43678512
Ref: Windows<15>-Footnote-53678568
Ref: Windows<15>-Footnote-63678623
Ref: Windows<15>-Footnote-73678679
Node: Python 3 12 0 alpha 43678735
Ref: whatsnew/changelog python-3-12-0-alpha-43678865
Ref: 16e43678865
Node: Core and Builtins<20>3679203
Ref: whatsnew/changelog id1513679302
Ref: 16e53679302
Ref: Core and Builtins<20>-Footnote-13684213
Ref: Core and Builtins<20>-Footnote-23684269
Ref: Core and Builtins<20>-Footnote-33684324
Ref: Core and Builtins<20>-Footnote-43684379
Ref: Core and Builtins<20>-Footnote-53684435
Ref: Core and Builtins<20>-Footnote-63684491
Ref: Core and Builtins<20>-Footnote-73684547
Ref: Core and Builtins<20>-Footnote-83684603
Ref: Core and Builtins<20>-Footnote-93684659
Ref: Core and Builtins<20>-Footnote-103684715
Ref: Core and Builtins<20>-Footnote-113684771
Ref: Core and Builtins<20>-Footnote-123684814
Ref: Core and Builtins<20>-Footnote-133684871
Ref: Core and Builtins<20>-Footnote-143684928
Ref: Core and Builtins<20>-Footnote-153684985
Ref: Core and Builtins<20>-Footnote-163685042
Ref: Core and Builtins<20>-Footnote-173685099
Ref: Core and Builtins<20>-Footnote-183685155
Ref: Core and Builtins<20>-Footnote-193685212
Ref: Core and Builtins<20>-Footnote-203685268
Ref: Core and Builtins<20>-Footnote-213685325
Ref: Core and Builtins<20>-Footnote-223685381
Ref: Core and Builtins<20>-Footnote-233685437
Ref: Core and Builtins<20>-Footnote-243685493
Ref: Core and Builtins<20>-Footnote-253685550
Ref: Core and Builtins<20>-Footnote-263685607
Ref: Core and Builtins<20>-Footnote-273685664
Ref: Core and Builtins<20>-Footnote-283685721
Ref: Core and Builtins<20>-Footnote-293685777
Ref: Core and Builtins<20>-Footnote-303685833
Ref: Core and Builtins<20>-Footnote-313685889
Ref: Core and Builtins<20>-Footnote-323685945
Ref: Core and Builtins<20>-Footnote-333686001
Ref: Core and Builtins<20>-Footnote-343686057
Node: Library<19>3686123
Ref: whatsnew/changelog id1523686248
Ref: 16e93686248
Ref: Library<19>-Footnote-13696555
Ref: Library<19>-Footnote-23696611
Ref: Library<19>-Footnote-33696667
Ref: Library<19>-Footnote-43696723
Ref: Library<19>-Footnote-53696779
Ref: Library<19>-Footnote-63696834
Ref: Library<19>-Footnote-73696889
Ref: Library<19>-Footnote-83696945
Ref: Library<19>-Footnote-93697001
Ref: Library<19>-Footnote-103697056
Ref: Library<19>-Footnote-113697113
Ref: Library<19>-Footnote-123697169
Ref: Library<19>-Footnote-133697226
Ref: Library<19>-Footnote-143697282
Ref: Library<19>-Footnote-153697338
Ref: Library<19>-Footnote-163697395
Ref: Library<19>-Footnote-173697452
Ref: Library<19>-Footnote-183697509
Ref: Library<19>-Footnote-193697566
Ref: Library<19>-Footnote-203697623
Ref: Library<19>-Footnote-213697680
Ref: Library<19>-Footnote-223697737
Ref: Library<19>-Footnote-233697793
Ref: Library<19>-Footnote-243697850
Ref: Library<19>-Footnote-253697907
Ref: Library<19>-Footnote-263697964
Ref: Library<19>-Footnote-273698020
Ref: Library<19>-Footnote-283698077
Ref: Library<19>-Footnote-293698134
Ref: Library<19>-Footnote-303698191
Ref: Library<19>-Footnote-313698248
Ref: Library<19>-Footnote-323698314
Ref: Library<19>-Footnote-333698371
Ref: Library<19>-Footnote-343698427
Ref: Library<19>-Footnote-353698483
Ref: Library<19>-Footnote-363698539
Ref: Library<19>-Footnote-373698595
Ref: Library<19>-Footnote-383698651
Ref: Library<19>-Footnote-393698707
Ref: Library<19>-Footnote-403698763
Ref: Library<19>-Footnote-413698819
Ref: Library<19>-Footnote-423698875
Ref: Library<19>-Footnote-433698918
Ref: Library<19>-Footnote-443698974
Ref: Library<19>-Footnote-453699030
Ref: Library<19>-Footnote-463699086
Ref: Library<19>-Footnote-473699142
Ref: Library<19>-Footnote-483699198
Ref: Library<19>-Footnote-493699254
Ref: Library<19>-Footnote-503699310
Ref: Library<19>-Footnote-513699366
Ref: Library<19>-Footnote-523699422
Ref: Library<19>-Footnote-533699478
Ref: Library<19>-Footnote-543699534
Ref: Library<19>-Footnote-553699600
Ref: Library<19>-Footnote-563699666
Node: Documentation<14>3699732
Ref: whatsnew/changelog id1533699845
Ref: 16f33699845
Ref: Documentation<14>-Footnote-13700428
Ref: Documentation<14>-Footnote-23700484
Ref: Documentation<14>-Footnote-33700540
Node: Tests<17>3700605
Ref: whatsnew/changelog id1543700716
Ref: 16f53700716
Ref: Tests<17>-Footnote-13701163
Ref: Tests<17>-Footnote-23701219
Ref: Tests<17>-Footnote-33701275
Node: Build<19>3701330
Ref: whatsnew/changelog id1553701435
Ref: 16f63701435
Ref: Build<19>-Footnote-13702322
Ref: Build<19>-Footnote-23702378
Ref: Build<19>-Footnote-33702433
Node: Windows<16>3702498
Ref: whatsnew/changelog id1563702603
Ref: 16f73702603
Ref: Windows<16>-Footnote-13703528
Ref: Windows<16>-Footnote-23703584
Ref: Windows<16>-Footnote-33703639
Ref: Windows<16>-Footnote-43703694
Ref: Windows<16>-Footnote-53703749
Ref: Windows<16>-Footnote-63703814
Node: macOS<12>3703879
Ref: whatsnew/changelog id1573703989
Ref: 16fa3703989
Ref: macOS<12>-Footnote-13704271
Ref: macOS<12>-Footnote-23704327
Node: Tools/Demos<9>3704383
Ref: whatsnew/changelog id1583704491
Ref: 16fb3704491
Ref: Tools/Demos<9>-Footnote-13704865
Ref: Tools/Demos<9>-Footnote-23704930
Node: C API<18>3704986
Ref: whatsnew/changelog id1593705076
Ref: 16fc3705076
Ref: C API<18>-Footnote-13705643
Ref: C API<18>-Footnote-23705698
Ref: C API<18>-Footnote-33705753
Node: Python 3 12 0 alpha 33705808
Ref: whatsnew/changelog python-3-12-0-alpha-33705938
Ref: 16fd3705938
Node: Security<13>3706303
Ref: whatsnew/changelog id1603706403
Ref: 16fe3706403
Ref: Security<13>-Footnote-13706963
Ref: Security<13>-Footnote-23707019
Node: Core and Builtins<21>3707074
Ref: whatsnew/changelog id1613707194
Ref: 16ff3707194
Ref: Core and Builtins<21>-Footnote-13710497
Ref: Core and Builtins<21>-Footnote-23710552
Ref: Core and Builtins<21>-Footnote-33710607
Ref: Core and Builtins<21>-Footnote-43710662
Ref: Core and Builtins<21>-Footnote-53710717
Ref: Core and Builtins<21>-Footnote-63710772
Ref: Core and Builtins<21>-Footnote-73710827
Ref: Core and Builtins<21>-Footnote-83710882
Ref: Core and Builtins<21>-Footnote-93710937
Ref: Core and Builtins<21>-Footnote-103710992
Ref: Core and Builtins<21>-Footnote-113711048
Ref: Core and Builtins<21>-Footnote-123711104
Ref: Core and Builtins<21>-Footnote-133711160
Ref: Core and Builtins<21>-Footnote-143711216
Ref: Core and Builtins<21>-Footnote-153711272
Ref: Core and Builtins<21>-Footnote-163711328
Ref: Core and Builtins<21>-Footnote-173711394
Ref: Core and Builtins<21>-Footnote-183711460
Node: Library<20>3711526
Ref: whatsnew/changelog id1623711651
Ref: 17003711651
Ref: Library<20>-Footnote-13717880
Ref: Library<20>-Footnote-23717936
Ref: Library<20>-Footnote-33717991
Ref: Library<20>-Footnote-43718046
Ref: Library<20>-Footnote-53718101
Ref: Library<20>-Footnote-63718156
Ref: Library<20>-Footnote-73718211
Ref: Library<20>-Footnote-83718266
Ref: Library<20>-Footnote-93718321
Ref: Library<20>-Footnote-103718376
Ref: Library<20>-Footnote-113718432
Ref: Library<20>-Footnote-123718488
Ref: Library<20>-Footnote-133718544
Ref: Library<20>-Footnote-143718600
Ref: Library<20>-Footnote-153718656
Ref: Library<20>-Footnote-163718712
Ref: Library<20>-Footnote-173718768
Ref: Library<20>-Footnote-183718824
Ref: Library<20>-Footnote-193718880
Ref: Library<20>-Footnote-203718936
Ref: Library<20>-Footnote-213718992
Ref: Library<20>-Footnote-223719048
Ref: Library<20>-Footnote-233719104
Ref: Library<20>-Footnote-243719160
Ref: Library<20>-Footnote-253719216
Ref: Library<20>-Footnote-263719272
Ref: Library<20>-Footnote-273719328
Ref: Library<20>-Footnote-283719384
Ref: Library<20>-Footnote-293719440
Ref: Library<20>-Footnote-303719496
Ref: Library<20>-Footnote-313719552
Ref: Library<20>-Footnote-323719618
Ref: Library<20>-Footnote-333719684
Ref: Library<20>-Footnote-343719750
Node: Documentation<15>3719816
Ref: whatsnew/changelog id1633719929
Ref: 17033719929
Ref: Documentation<15>-Footnote-13720698
Ref: Documentation<15>-Footnote-23720753
Ref: Documentation<15>-Footnote-33720805
Ref: Documentation<15>-Footnote-43720829
Ref: Documentation<15>-Footnote-53720884
Ref: Documentation<15>-Footnote-63720939
Ref: Documentation<15>-Footnote-73720994
Node: Tests<18>3721059
Ref: whatsnew/changelog id1643721170
Ref: 17043721170
Ref: Tests<18>-Footnote-13721945
Ref: Tests<18>-Footnote-23722000
Ref: Tests<18>-Footnote-33722055
Ref: Tests<18>-Footnote-43722110
Ref: Tests<18>-Footnote-53722165
Ref: Tests<18>-Footnote-63722220
Node: Build<20>3722275
Ref: whatsnew/changelog id1653722380
Ref: 17053722380
Ref: Build<20>-Footnote-13723344
Ref: Build<20>-Footnote-23723399
Ref: Build<20>-Footnote-33723454
Ref: Build<20>-Footnote-43723509
Ref: Build<20>-Footnote-53723564
Node: Windows<17>3723619
Ref: whatsnew/changelog id1663723724
Ref: 17063723724
Ref: Windows<17>-Footnote-13724262
Ref: Windows<17>-Footnote-23724317
Ref: Windows<17>-Footnote-33724372
Ref: Windows<17>-Footnote-43724427
Node: macOS<13>3724492
Ref: whatsnew/changelog id1673724603
Ref: 17073724603
Ref: macOS<13>-Footnote-13724871
Ref: macOS<13>-Footnote-23724926
Node: Tools/Demos<10>3724981
Ref: whatsnew/changelog id1683725090
Ref: 17083725090
Ref: Tools/Demos<10>-Footnote-13725580
Node: C API<19>3725635
Ref: whatsnew/changelog id1693725726
Ref: 17093725726
Ref: C API<19>-Footnote-13726547
Ref: C API<19>-Footnote-23726602
Ref: C API<19>-Footnote-33726657
Node: Python 3 12 0 alpha 23726712
Ref: whatsnew/changelog python-3-12-0-alpha-23726842
Ref: 170b3726842
Node: Security<14>3727175
Ref: whatsnew/changelog id1703727275
Ref: 170c3727275
Ref: Security<14>-Footnote-13728403
Ref: Security<14>-Footnote-23728458
Ref: Security<14>-Footnote-33728517
Ref: Security<14>-Footnote-43728576
Ref: Security<14>-Footnote-53728635
Node: Core and Builtins<22>3728690
Ref: whatsnew/changelog id1713728810
Ref: 170d3728810
Ref: Core and Builtins<22>-Footnote-13736806
Ref: Core and Builtins<22>-Footnote-23736861
Ref: Core and Builtins<22>-Footnote-33736916
Ref: Core and Builtins<22>-Footnote-43736971
Ref: Core and Builtins<22>-Footnote-53737026
Ref: Core and Builtins<22>-Footnote-63737081
Ref: Core and Builtins<22>-Footnote-73737136
Ref: Core and Builtins<22>-Footnote-83737191
Ref: Core and Builtins<22>-Footnote-93737246
Ref: Core and Builtins<22>-Footnote-103737301
Ref: Core and Builtins<22>-Footnote-113737357
Ref: Core and Builtins<22>-Footnote-123737413
Ref: Core and Builtins<22>-Footnote-133737469
Ref: Core and Builtins<22>-Footnote-143737525
Ref: Core and Builtins<22>-Footnote-153737581
Ref: Core and Builtins<22>-Footnote-163737637
Ref: Core and Builtins<22>-Footnote-173737693
Ref: Core and Builtins<22>-Footnote-183737749
Ref: Core and Builtins<22>-Footnote-193737805
Ref: Core and Builtins<22>-Footnote-203737861
Ref: Core and Builtins<22>-Footnote-213737917
Ref: Core and Builtins<22>-Footnote-223737973
Ref: Core and Builtins<22>-Footnote-233738029
Ref: Core and Builtins<22>-Footnote-243738085
Ref: Core and Builtins<22>-Footnote-253738128
Ref: Core and Builtins<22>-Footnote-263738184
Ref: Core and Builtins<22>-Footnote-273738240
Ref: Core and Builtins<22>-Footnote-283738296
Ref: Core and Builtins<22>-Footnote-293738352
Ref: Core and Builtins<22>-Footnote-303738408
Ref: Core and Builtins<22>-Footnote-313738464
Ref: Core and Builtins<22>-Footnote-323738520
Ref: Core and Builtins<22>-Footnote-333738576
Ref: Core and Builtins<22>-Footnote-343738632
Ref: Core and Builtins<22>-Footnote-353738688
Node: Library<21>3738744
Ref: whatsnew/changelog id1723738869
Ref: 17153738869
Ref: Library<21>-Footnote-13744668
Ref: Library<21>-Footnote-23744723
Ref: Library<21>-Footnote-33744778
Ref: Library<21>-Footnote-43744833
Ref: Library<21>-Footnote-53744888
Ref: Library<21>-Footnote-63744943
Ref: Library<21>-Footnote-73744998
Ref: Library<21>-Footnote-83745053
Ref: Library<21>-Footnote-93745108
Ref: Library<21>-Footnote-103745163
Ref: Library<21>-Footnote-113745219
Ref: Library<21>-Footnote-123745275
Ref: Library<21>-Footnote-133745318
Ref: Library<21>-Footnote-143745374
Ref: Library<21>-Footnote-153745430
Ref: Library<21>-Footnote-163745486
Ref: Library<21>-Footnote-173745542
Ref: Library<21>-Footnote-183745598
Ref: Library<21>-Footnote-193745654
Ref: Library<21>-Footnote-203745710
Ref: Library<21>-Footnote-213745766
Ref: Library<21>-Footnote-223745822
Ref: Library<21>-Footnote-233745878
Ref: Library<21>-Footnote-243745934
Ref: Library<21>-Footnote-253745990
Ref: Library<21>-Footnote-263746046
Ref: Library<21>-Footnote-273746102
Ref: Library<21>-Footnote-283746158
Ref: Library<21>-Footnote-293746214
Ref: Library<21>-Footnote-303746270
Ref: Library<21>-Footnote-313746326
Ref: Library<21>-Footnote-323746369
Ref: Library<21>-Footnote-333746425
Ref: Library<21>-Footnote-343746481
Ref: Library<21>-Footnote-353746537
Ref: Library<21>-Footnote-363746593
Ref: Library<21>-Footnote-373746636
Ref: Library<21>-Footnote-383746692
Ref: Library<21>-Footnote-393746748
Ref: Library<21>-Footnote-403746814
Ref: Library<21>-Footnote-413746880
Node: Documentation<16>3746946
Ref: whatsnew/changelog id1733747059
Ref: 171a3747059
Ref: Documentation<16>-Footnote-13747378
Ref: Documentation<16>-Footnote-23747433
Node: Tests<19>3747488
Ref: whatsnew/changelog id1743747599
Ref: 171b3747599
Ref: Tests<19>-Footnote-13748486
Ref: Tests<19>-Footnote-23748541
Ref: Tests<19>-Footnote-33748596
Ref: Tests<19>-Footnote-43748651
Ref: Tests<19>-Footnote-53748706
Node: Build<21>3748771
Ref: whatsnew/changelog id1753748876
Ref: 171c3748876
Ref: Build<21>-Footnote-13750561
Ref: Build<21>-Footnote-23750616
Ref: Build<21>-Footnote-33750671
Ref: Build<21>-Footnote-43750726
Ref: Build<21>-Footnote-53750781
Ref: Build<21>-Footnote-63750836
Ref: Build<21>-Footnote-73750891
Ref: Build<21>-Footnote-83750981
Ref: Build<21>-Footnote-93751036
Ref: Build<21>-Footnote-103751091
Node: Windows<18>3751147
Ref: whatsnew/changelog id1763751252
Ref: 171e3751252
Ref: Windows<18>-Footnote-13751959
Ref: Windows<18>-Footnote-23752014
Ref: Windows<18>-Footnote-33752070
Ref: Windows<18>-Footnote-43752125
Ref: Windows<18>-Footnote-53752180
Ref: Windows<18>-Footnote-63752235
Node: macOS<14>3752290
Ref: whatsnew/changelog id1773752395
Ref: 171f3752395
Ref: macOS<14>-Footnote-13752524
Node: C API<20>3752579
Ref: whatsnew/changelog id1783752664
Ref: 17203752664
Ref: C API<20>-Footnote-13754727
Ref: C API<20>-Footnote-23754782
Ref: C API<20>-Footnote-33754837
Ref: C API<20>-Footnote-43754892
Ref: C API<20>-Footnote-53754947
Ref: C API<20>-Footnote-63755002
Ref: C API<20>-Footnote-73755057
Node: Python 3 12 0 alpha 13755112
Ref: whatsnew/changelog python-3-12-0-alpha-13755241
Ref: 17223755241
Node: Security<15>3755624
Ref: whatsnew/changelog id1793755724
Ref: 17233755724
Ref: Security<15>-Footnote-13757557
Ref: Security<15>-Footnote-23757612
Ref: Security<15>-Footnote-33757667
Ref: Security<15>-Footnote-43757739
Ref: Security<15>-Footnote-53757795
Ref: Security<15>-Footnote-63757850
Ref: Security<15>-Footnote-73757905
Ref: Security<15>-Footnote-83757960
Node: Core and Builtins<23>3758015
Ref: whatsnew/changelog id1803758135
Ref: 17243758135
Ref: Core and Builtins<23>-Footnote-13787445
Ref: Core and Builtins<23>-Footnote-23787500
Ref: Core and Builtins<23>-Footnote-33787555
Ref: Core and Builtins<23>-Footnote-43787610
Ref: Core and Builtins<23>-Footnote-53787665
Ref: Core and Builtins<23>-Footnote-63787720
Ref: Core and Builtins<23>-Footnote-73787775
Ref: Core and Builtins<23>-Footnote-83787830
Ref: Core and Builtins<23>-Footnote-93787885
Ref: Core and Builtins<23>-Footnote-103787940
Ref: Core and Builtins<23>-Footnote-113787996
Ref: Core and Builtins<23>-Footnote-123788052
Ref: Core and Builtins<23>-Footnote-133788108
Ref: Core and Builtins<23>-Footnote-143788164
Ref: Core and Builtins<23>-Footnote-153788220
Ref: Core and Builtins<23>-Footnote-163788276
Ref: Core and Builtins<23>-Footnote-173788332
Ref: Core and Builtins<23>-Footnote-183788388
Ref: Core and Builtins<23>-Footnote-193788444
Ref: Core and Builtins<23>-Footnote-203788500
Ref: Core and Builtins<23>-Footnote-213788556
Ref: Core and Builtins<23>-Footnote-223788612
Ref: Core and Builtins<23>-Footnote-233788668
Ref: Core and Builtins<23>-Footnote-243788724
Ref: Core and Builtins<23>-Footnote-253788780
Ref: Core and Builtins<23>-Footnote-263788836
Ref: Core and Builtins<23>-Footnote-273788892
Ref: Core and Builtins<23>-Footnote-283788948
Ref: Core and Builtins<23>-Footnote-293789004
Ref: Core and Builtins<23>-Footnote-303789060
Ref: Core and Builtins<23>-Footnote-313789116
Ref: Core and Builtins<23>-Footnote-323789172
Ref: Core and Builtins<23>-Footnote-333789228
Ref: Core and Builtins<23>-Footnote-343789284
Ref: Core and Builtins<23>-Footnote-353789340
Ref: Core and Builtins<23>-Footnote-363789396
Ref: Core and Builtins<23>-Footnote-373789452
Ref: Core and Builtins<23>-Footnote-383789508
Ref: Core and Builtins<23>-Footnote-393789564
Ref: Core and Builtins<23>-Footnote-403789620
Ref: Core and Builtins<23>-Footnote-413789676
Ref: Core and Builtins<23>-Footnote-423789732
Ref: Core and Builtins<23>-Footnote-433789788
Ref: Core and Builtins<23>-Footnote-443789844
Ref: Core and Builtins<23>-Footnote-453789900
Ref: Core and Builtins<23>-Footnote-463789956
Ref: Core and Builtins<23>-Footnote-473790012
Ref: Core and Builtins<23>-Footnote-483790068
Ref: Core and Builtins<23>-Footnote-493790111
Ref: Core and Builtins<23>-Footnote-503790167
Ref: Core and Builtins<23>-Footnote-513790223
Ref: Core and Builtins<23>-Footnote-523790279
Ref: Core and Builtins<23>-Footnote-533790335
Ref: Core and Builtins<23>-Footnote-543790391
Ref: Core and Builtins<23>-Footnote-553790447
Ref: Core and Builtins<23>-Footnote-563790503
Ref: Core and Builtins<23>-Footnote-573790559
Ref: Core and Builtins<23>-Footnote-583790615
Ref: Core and Builtins<23>-Footnote-593790671
Ref: Core and Builtins<23>-Footnote-603790727
Ref: Core and Builtins<23>-Footnote-613790783
Ref: Core and Builtins<23>-Footnote-623790839
Ref: Core and Builtins<23>-Footnote-633790895
Ref: Core and Builtins<23>-Footnote-643790951
Ref: Core and Builtins<23>-Footnote-653791007
Ref: Core and Builtins<23>-Footnote-663791063
Ref: Core and Builtins<23>-Footnote-673791119
Ref: Core and Builtins<23>-Footnote-683791175
Ref: Core and Builtins<23>-Footnote-693791231
Ref: Core and Builtins<23>-Footnote-703791287
Ref: Core and Builtins<23>-Footnote-713791343
Ref: Core and Builtins<23>-Footnote-723791399
Ref: Core and Builtins<23>-Footnote-733791455
Ref: Core and Builtins<23>-Footnote-743791511
Ref: Core and Builtins<23>-Footnote-753791567
Ref: Core and Builtins<23>-Footnote-763791623
Ref: Core and Builtins<23>-Footnote-773791679
Ref: Core and Builtins<23>-Footnote-783791735
Ref: Core and Builtins<23>-Footnote-793791791
Ref: Core and Builtins<23>-Footnote-803791847
Ref: Core and Builtins<23>-Footnote-813791903
Ref: Core and Builtins<23>-Footnote-823791959
Ref: Core and Builtins<23>-Footnote-833792015
Ref: Core and Builtins<23>-Footnote-843792071
Ref: Core and Builtins<23>-Footnote-853792127
Ref: Core and Builtins<23>-Footnote-863792183
Ref: Core and Builtins<23>-Footnote-873792239
Ref: Core and Builtins<23>-Footnote-883792295
Ref: Core and Builtins<23>-Footnote-893792351
Ref: Core and Builtins<23>-Footnote-903792407
Ref: Core and Builtins<23>-Footnote-913792463
Ref: Core and Builtins<23>-Footnote-923792519
Ref: Core and Builtins<23>-Footnote-933792575
Ref: Core and Builtins<23>-Footnote-943792631
Ref: Core and Builtins<23>-Footnote-953792687
Ref: Core and Builtins<23>-Footnote-963792743
Ref: Core and Builtins<23>-Footnote-973792799
Ref: Core and Builtins<23>-Footnote-983792855
Ref: Core and Builtins<23>-Footnote-993792911
Ref: Core and Builtins<23>-Footnote-1003792967
Ref: Core and Builtins<23>-Footnote-1013793024
Ref: Core and Builtins<23>-Footnote-1023793081
Ref: Core and Builtins<23>-Footnote-1033793138
Ref: Core and Builtins<23>-Footnote-1043793195
Ref: Core and Builtins<23>-Footnote-1053793252
Ref: Core and Builtins<23>-Footnote-1063793309
Ref: Core and Builtins<23>-Footnote-1073793353
Ref: Core and Builtins<23>-Footnote-1083793410
Ref: Core and Builtins<23>-Footnote-1093793467
Ref: Core and Builtins<23>-Footnote-1103793524
Ref: Core and Builtins<23>-Footnote-1113793581
Ref: Core and Builtins<23>-Footnote-1123793638
Ref: Core and Builtins<23>-Footnote-1133793695
Ref: Core and Builtins<23>-Footnote-1143793752
Ref: Core and Builtins<23>-Footnote-1153793809
Ref: Core and Builtins<23>-Footnote-1163793866
Ref: Core and Builtins<23>-Footnote-1173793923
Ref: Core and Builtins<23>-Footnote-1183793980
Ref: Core and Builtins<23>-Footnote-1193794037
Ref: Core and Builtins<23>-Footnote-1203794094
Ref: Core and Builtins<23>-Footnote-1213794151
Ref: Core and Builtins<23>-Footnote-1223794208
Ref: Core and Builtins<23>-Footnote-1233794265
Ref: Core and Builtins<23>-Footnote-1243794322
Ref: Core and Builtins<23>-Footnote-1253794379
Ref: Core and Builtins<23>-Footnote-1263794436
Ref: Core and Builtins<23>-Footnote-1273794493
Ref: Core and Builtins<23>-Footnote-1283794550
Ref: Core and Builtins<23>-Footnote-1293794607
Ref: Core and Builtins<23>-Footnote-1303794664
Ref: Core and Builtins<23>-Footnote-1313794721
Ref: Core and Builtins<23>-Footnote-1323794778
Ref: Core and Builtins<23>-Footnote-1333794835
Ref: Core and Builtins<23>-Footnote-1343794892
Ref: Core and Builtins<23>-Footnote-1353794949
Ref: Core and Builtins<23>-Footnote-1363795006
Ref: Core and Builtins<23>-Footnote-1373795063
Ref: Core and Builtins<23>-Footnote-1383795120
Ref: Core and Builtins<23>-Footnote-1393795177
Ref: Core and Builtins<23>-Footnote-1403795234
Ref: Core and Builtins<23>-Footnote-1413795291
Ref: Core and Builtins<23>-Footnote-1423795348
Ref: Core and Builtins<23>-Footnote-1433795405
Ref: Core and Builtins<23>-Footnote-1443795462
Ref: Core and Builtins<23>-Footnote-1453795519
Ref: Core and Builtins<23>-Footnote-1463795576
Ref: Core and Builtins<23>-Footnote-1473795633
Ref: Core and Builtins<23>-Footnote-1483795690
Ref: Core and Builtins<23>-Footnote-1493795751
Ref: Core and Builtins<23>-Footnote-1503795808
Ref: Core and Builtins<23>-Footnote-1513795865
Ref: Core and Builtins<23>-Footnote-1523795922
Ref: Core and Builtins<23>-Footnote-1533795979
Ref: Core and Builtins<23>-Footnote-1543796036
Ref: Core and Builtins<23>-Footnote-1553796093
Ref: Core and Builtins<23>-Footnote-1563796150
Ref: Core and Builtins<23>-Footnote-1573796207
Ref: Core and Builtins<23>-Footnote-1583796264
Ref: Core and Builtins<23>-Footnote-1593796321
Ref: Core and Builtins<23>-Footnote-1603796378
Ref: Core and Builtins<23>-Footnote-1613796435
Ref: Core and Builtins<23>-Footnote-1623796492
Ref: Core and Builtins<23>-Footnote-1633796549
Ref: Core and Builtins<23>-Footnote-1643796606
Ref: Core and Builtins<23>-Footnote-1653796663
Ref: Core and Builtins<23>-Footnote-1663796720
Ref: Core and Builtins<23>-Footnote-1673796777
Ref: Core and Builtins<23>-Footnote-1683796834
Ref: Core and Builtins<23>-Footnote-1693796891
Ref: Core and Builtins<23>-Footnote-1703796958
Ref: Core and Builtins<23>-Footnote-1713797025
Node: Library<22>3797092
Ref: whatsnew/changelog id1813797217
Ref: 172d3797217
Ref: Library<22>-Footnote-13840502
Ref: Library<22>-Footnote-23840557
Ref: Library<22>-Footnote-33840612
Ref: Library<22>-Footnote-43840667
Ref: Library<22>-Footnote-53840722
Ref: Library<22>-Footnote-63840777
Ref: Library<22>-Footnote-73840832
Ref: Library<22>-Footnote-83840887
Ref: Library<22>-Footnote-93840942
Ref: Library<22>-Footnote-103840997
Ref: Library<22>-Footnote-113841053
Ref: Library<22>-Footnote-123841109
Ref: Library<22>-Footnote-133841165
Ref: Library<22>-Footnote-143841221
Ref: Library<22>-Footnote-153841277
Ref: Library<22>-Footnote-163841333
Ref: Library<22>-Footnote-173841389
Ref: Library<22>-Footnote-183841445
Ref: Library<22>-Footnote-193841501
Ref: Library<22>-Footnote-203841561
Ref: Library<22>-Footnote-213841617
Ref: Library<22>-Footnote-223841673
Ref: Library<22>-Footnote-233841729
Ref: Library<22>-Footnote-243841785
Ref: Library<22>-Footnote-253841841
Ref: Library<22>-Footnote-263841897
Ref: Library<22>-Footnote-273841953
Ref: Library<22>-Footnote-283842009
Ref: Library<22>-Footnote-293842065
Ref: Library<22>-Footnote-303842121
Ref: Library<22>-Footnote-313842177
Ref: Library<22>-Footnote-323842233
Ref: Library<22>-Footnote-333842289
Ref: Library<22>-Footnote-343842345
Ref: Library<22>-Footnote-353842401
Ref: Library<22>-Footnote-363842457
Ref: Library<22>-Footnote-373842513
Ref: Library<22>-Footnote-383842569
Ref: Library<22>-Footnote-393842625
Ref: Library<22>-Footnote-403842681
Ref: Library<22>-Footnote-413842737
Ref: Library<22>-Footnote-423842793
Ref: Library<22>-Footnote-433842849
Ref: Library<22>-Footnote-443842905
Ref: Library<22>-Footnote-453842961
Ref: Library<22>-Footnote-463843017
Ref: Library<22>-Footnote-473843073
Ref: Library<22>-Footnote-483843129
Ref: Library<22>-Footnote-493843185
Ref: Library<22>-Footnote-503843241
Ref: Library<22>-Footnote-513843297
Ref: Library<22>-Footnote-523843353
Ref: Library<22>-Footnote-533843409
Ref: Library<22>-Footnote-543843465
Ref: Library<22>-Footnote-553843521
Ref: Library<22>-Footnote-563843577
Ref: Library<22>-Footnote-573843633
Ref: Library<22>-Footnote-583843689
Ref: Library<22>-Footnote-593843745
Ref: Library<22>-Footnote-603843801
Ref: Library<22>-Footnote-613843857
Ref: Library<22>-Footnote-623843913
Ref: Library<22>-Footnote-633843969
Ref: Library<22>-Footnote-643844025
Ref: Library<22>-Footnote-653844081
Ref: Library<22>-Footnote-663844137
Ref: Library<22>-Footnote-673844193
Ref: Library<22>-Footnote-683844259
Ref: Library<22>-Footnote-693844315
Ref: Library<22>-Footnote-703844371
Ref: Library<22>-Footnote-713844427
Ref: Library<22>-Footnote-723844483
Ref: Library<22>-Footnote-733844539
Ref: Library<22>-Footnote-743844595
Ref: Library<22>-Footnote-753844651
Ref: Library<22>-Footnote-763844707
Ref: Library<22>-Footnote-773844763
Ref: Library<22>-Footnote-783844819
Ref: Library<22>-Footnote-793844875
Ref: Library<22>-Footnote-803844931
Ref: Library<22>-Footnote-813844987
Ref: Library<22>-Footnote-823845043
Ref: Library<22>-Footnote-833845099
Ref: Library<22>-Footnote-843845155
Ref: Library<22>-Footnote-853845211
Ref: Library<22>-Footnote-863845267
Ref: Library<22>-Footnote-873845323
Ref: Library<22>-Footnote-883845379
Ref: Library<22>-Footnote-893845435
Ref: Library<22>-Footnote-903845491
Ref: Library<22>-Footnote-913845547
Ref: Library<22>-Footnote-923845603
Ref: Library<22>-Footnote-933845659
Ref: Library<22>-Footnote-943845715
Ref: Library<22>-Footnote-953845771
Ref: Library<22>-Footnote-963845827
Ref: Library<22>-Footnote-973845883
Ref: Library<22>-Footnote-983845939
Ref: Library<22>-Footnote-993845995
Ref: Library<22>-Footnote-1003846051
Ref: Library<22>-Footnote-1013846108
Ref: Library<22>-Footnote-1023846165
Ref: Library<22>-Footnote-1033846222
Ref: Library<22>-Footnote-1043846279
Ref: Library<22>-Footnote-1053846336
Ref: Library<22>-Footnote-1063846393
Ref: Library<22>-Footnote-1073846450
Ref: Library<22>-Footnote-1083846507
Ref: Library<22>-Footnote-1093846564
Ref: Library<22>-Footnote-1103846621
Ref: Library<22>-Footnote-1113846678
Ref: Library<22>-Footnote-1123846735
Ref: Library<22>-Footnote-1133846792
Ref: Library<22>-Footnote-1143846849
Ref: Library<22>-Footnote-1153846906
Ref: Library<22>-Footnote-1163846963
Ref: Library<22>-Footnote-1173847020
Ref: Library<22>-Footnote-1183847077
Ref: Library<22>-Footnote-1193847134
Ref: Library<22>-Footnote-1203847191
Ref: Library<22>-Footnote-1213847248
Ref: Library<22>-Footnote-1223847305
Ref: Library<22>-Footnote-1233847362
Ref: Library<22>-Footnote-1243847406
Ref: Library<22>-Footnote-1253847463
Ref: Library<22>-Footnote-1263847520
Ref: Library<22>-Footnote-1273847577
Ref: Library<22>-Footnote-1283847634
Ref: Library<22>-Footnote-1293847691
Ref: Library<22>-Footnote-1303847748
Ref: Library<22>-Footnote-1313847805
Ref: Library<22>-Footnote-1323847862
Ref: Library<22>-Footnote-1333847919
Ref: Library<22>-Footnote-1343847976
Ref: Library<22>-Footnote-1353848033
Ref: Library<22>-Footnote-1363848090
Ref: Library<22>-Footnote-1373848147
Ref: Library<22>-Footnote-1383848204
Ref: Library<22>-Footnote-1393848261
Ref: Library<22>-Footnote-1403848319
Ref: Library<22>-Footnote-1413848376
Ref: Library<22>-Footnote-1423848433
Ref: Library<22>-Footnote-1433848477
Ref: Library<22>-Footnote-1443848534
Ref: Library<22>-Footnote-1453848591
Ref: Library<22>-Footnote-1463848648
Ref: Library<22>-Footnote-1473848705
Ref: Library<22>-Footnote-1483848762
Ref: Library<22>-Footnote-1493848819
Ref: Library<22>-Footnote-1503848876
Ref: Library<22>-Footnote-1513848933
Ref: Library<22>-Footnote-1523848990
Ref: Library<22>-Footnote-1533849047
Ref: Library<22>-Footnote-1543849104
Ref: Library<22>-Footnote-1553849161
Ref: Library<22>-Footnote-1563849218
Ref: Library<22>-Footnote-1573849275
Ref: Library<22>-Footnote-1583849332
Ref: Library<22>-Footnote-1593849389
Ref: Library<22>-Footnote-1603849446
Ref: Library<22>-Footnote-1613849503
Ref: Library<22>-Footnote-1623849560
Ref: Library<22>-Footnote-1633849604
Ref: Library<22>-Footnote-1643849661
Ref: Library<22>-Footnote-1653849718
Ref: Library<22>-Footnote-1663849775
Ref: Library<22>-Footnote-1673849832
Ref: Library<22>-Footnote-1683849889
Ref: Library<22>-Footnote-1693849946
Ref: Library<22>-Footnote-1703850003
Ref: Library<22>-Footnote-1713850060
Ref: Library<22>-Footnote-1723850117
Ref: Library<22>-Footnote-1733850174
Ref: Library<22>-Footnote-1743850231
Ref: Library<22>-Footnote-1753850288
Ref: Library<22>-Footnote-1763850345
Ref: Library<22>-Footnote-1773850402
Ref: Library<22>-Footnote-1783850459
Ref: Library<22>-Footnote-1793850516
Ref: Library<22>-Footnote-1803850573
Ref: Library<22>-Footnote-1813850630
Ref: Library<22>-Footnote-1823850674
Ref: Library<22>-Footnote-1833850731
Ref: Library<22>-Footnote-1843850788
Ref: Library<22>-Footnote-1853850845
Ref: Library<22>-Footnote-1863850902
Ref: Library<22>-Footnote-1873850959
Ref: Library<22>-Footnote-1883851016
Ref: Library<22>-Footnote-1893851073
Ref: Library<22>-Footnote-1903851130
Ref: Library<22>-Footnote-1913851187
Ref: Library<22>-Footnote-1923851244
Ref: Library<22>-Footnote-1933851301
Ref: Library<22>-Footnote-1943851358
Ref: Library<22>-Footnote-1953851415
Ref: Library<22>-Footnote-1963851472
Ref: Library<22>-Footnote-1973851529
Ref: Library<22>-Footnote-1983851586
Ref: Library<22>-Footnote-1993851643
Ref: Library<22>-Footnote-2003851700
Ref: Library<22>-Footnote-2013851757
Ref: Library<22>-Footnote-2023851814
Ref: Library<22>-Footnote-2033851871
Ref: Library<22>-Footnote-2043851928
Ref: Library<22>-Footnote-2053851985
Ref: Library<22>-Footnote-2063852042
Ref: Library<22>-Footnote-2073852099
Ref: Library<22>-Footnote-2083852156
Ref: Library<22>-Footnote-2093852213
Ref: Library<22>-Footnote-2103852270
Ref: Library<22>-Footnote-2113852327
Ref: Library<22>-Footnote-2123852384
Ref: Library<22>-Footnote-2133852441
Ref: Library<22>-Footnote-2143852498
Ref: Library<22>-Footnote-2153852555
Ref: Library<22>-Footnote-2163852612
Ref: Library<22>-Footnote-2173852669
Ref: Library<22>-Footnote-2183852726
Ref: Library<22>-Footnote-2193852783
Ref: Library<22>-Footnote-2203852840
Ref: Library<22>-Footnote-2213852897
Ref: Library<22>-Footnote-2223852954
Ref: Library<22>-Footnote-2233853011
Ref: Library<22>-Footnote-2243853068
Ref: Library<22>-Footnote-2253853125
Ref: Library<22>-Footnote-2263853182
Ref: Library<22>-Footnote-2273853249
Ref: Library<22>-Footnote-2283853316
Ref: Library<22>-Footnote-2293853383
Ref: Library<22>-Footnote-2303853440
Ref: Library<22>-Footnote-2313853507
Ref: Library<22>-Footnote-2323853574
Ref: Library<22>-Footnote-2333853641
Ref: Library<22>-Footnote-2343853708
Ref: Library<22>-Footnote-2353853775
Ref: Library<22>-Footnote-2363853842
Ref: Library<22>-Footnote-2373853909
Ref: Library<22>-Footnote-2383853976
Ref: Library<22>-Footnote-2393854043
Ref: Library<22>-Footnote-2403854110
Ref: Library<22>-Footnote-2413854177
Ref: Library<22>-Footnote-2423854244
Ref: Library<22>-Footnote-2433854311
Ref: Library<22>-Footnote-2443854378
Ref: Library<22>-Footnote-2453854445
Ref: Library<22>-Footnote-2463854512
Ref: Library<22>-Footnote-2473854579
Ref: Library<22>-Footnote-2483854646
Ref: Library<22>-Footnote-2493854713
Ref: Library<22>-Footnote-2503854780
Ref: Library<22>-Footnote-2513854847
Ref: Library<22>-Footnote-2523854914
Ref: Library<22>-Footnote-2533854981
Ref: Library<22>-Footnote-2543855048
Node: Documentation<17>3855115
Ref: whatsnew/changelog id1823855228
Ref: 174b3855228
Ref: Documentation<17>-Footnote-13858984
Ref: Documentation<17>-Footnote-23859039
Ref: Documentation<17>-Footnote-33859094
Ref: Documentation<17>-Footnote-43859140
Ref: Documentation<17>-Footnote-53859195
Ref: Documentation<17>-Footnote-63859250
Ref: Documentation<17>-Footnote-73859305
Ref: Documentation<17>-Footnote-83859360
Ref: Documentation<17>-Footnote-93859415
Ref: Documentation<17>-Footnote-103859470
Ref: Documentation<17>-Footnote-113859526
Ref: Documentation<17>-Footnote-123859582
Ref: Documentation<17>-Footnote-133859638
Ref: Documentation<17>-Footnote-143859694
Ref: Documentation<17>-Footnote-153859737
Ref: Documentation<17>-Footnote-163859793
Ref: Documentation<17>-Footnote-173859849
Ref: Documentation<17>-Footnote-183859905
Ref: Documentation<17>-Footnote-193859961
Ref: Documentation<17>-Footnote-203860017
Ref: Documentation<17>-Footnote-213860073
Ref: Documentation<17>-Footnote-223860129
Ref: Documentation<17>-Footnote-233860185
Ref: Documentation<17>-Footnote-243860251
Ref: Documentation<17>-Footnote-253860317
Ref: Documentation<17>-Footnote-263860383
Ref: Documentation<17>-Footnote-273860449
Node: Tests<20>3860515
Ref: whatsnew/changelog id1833860626
Ref: 17523860626
Ref: Tests<20>-Footnote-13866005
Ref: Tests<20>-Footnote-23866060
Ref: Tests<20>-Footnote-33866115
Ref: Tests<20>-Footnote-43866170
Ref: Tests<20>-Footnote-53866225
Ref: Tests<20>-Footnote-63866312
Ref: Tests<20>-Footnote-73866367
Ref: Tests<20>-Footnote-83866422
Ref: Tests<20>-Footnote-93866477
Ref: Tests<20>-Footnote-103866532
Ref: Tests<20>-Footnote-113866588
Ref: Tests<20>-Footnote-123866644
Ref: Tests<20>-Footnote-133866700
Ref: Tests<20>-Footnote-143866756
Ref: Tests<20>-Footnote-153866812
Ref: Tests<20>-Footnote-163866868
Ref: Tests<20>-Footnote-173866924
Ref: Tests<20>-Footnote-183866980
Ref: Tests<20>-Footnote-193867036
Ref: Tests<20>-Footnote-203867092
Ref: Tests<20>-Footnote-213867148
Ref: Tests<20>-Footnote-223867204
Ref: Tests<20>-Footnote-233867260
Ref: Tests<20>-Footnote-243867316
Ref: Tests<20>-Footnote-253867372
Ref: Tests<20>-Footnote-263867428
Ref: Tests<20>-Footnote-273867484
Ref: Tests<20>-Footnote-283867540
Ref: Tests<20>-Footnote-293867596
Ref: Tests<20>-Footnote-303867652
Ref: Tests<20>-Footnote-313867708
Ref: Tests<20>-Footnote-323867764
Ref: Tests<20>-Footnote-333867820
Ref: Tests<20>-Footnote-343867876
Ref: Tests<20>-Footnote-353867932
Ref: Tests<20>-Footnote-363867988
Node: Build<22>3868054
Ref: whatsnew/changelog id1843868159
Ref: 17563868159
Ref: Build<22>-Footnote-13873637
Ref: Build<22>-Footnote-23873692
Ref: Build<22>-Footnote-33873747
Ref: Build<22>-Footnote-43873802
Ref: Build<22>-Footnote-53873857
Ref: Build<22>-Footnote-63873912
Ref: Build<22>-Footnote-73873967
Ref: Build<22>-Footnote-83874022
Ref: Build<22>-Footnote-93874077
Ref: Build<22>-Footnote-103874132
Ref: Build<22>-Footnote-113874188
Ref: Build<22>-Footnote-123874244
Ref: Build<22>-Footnote-133874300
Ref: Build<22>-Footnote-143874356
Ref: Build<22>-Footnote-153874412
Ref: Build<22>-Footnote-163874468
Ref: Build<22>-Footnote-173874511
Ref: Build<22>-Footnote-183874567
Ref: Build<22>-Footnote-193874623
Ref: Build<22>-Footnote-203874679
Ref: Build<22>-Footnote-213874735
Ref: Build<22>-Footnote-223874791
Ref: Build<22>-Footnote-233874847
Ref: Build<22>-Footnote-243874903
Ref: Build<22>-Footnote-253874959
Ref: Build<22>-Footnote-263875015
Ref: Build<22>-Footnote-273875071
Ref: Build<22>-Footnote-283875127
Ref: Build<22>-Footnote-293875183
Ref: Build<22>-Footnote-303875239
Ref: Build<22>-Footnote-313875295
Ref: Build<22>-Footnote-323875338
Ref: Build<22>-Footnote-333875394
Ref: Build<22>-Footnote-343875450
Ref: Build<22>-Footnote-353875506
Ref: Build<22>-Footnote-363875562
Node: Windows<19>3875628
Ref: whatsnew/changelog id1853875733
Ref: 17573875733
Ref: Windows<19>-Footnote-13880180
Ref: Windows<19>-Footnote-23880235
Ref: Windows<19>-Footnote-33880290
Ref: Windows<19>-Footnote-43880345
Ref: Windows<19>-Footnote-53880400
Ref: Windows<19>-Footnote-63880455
Ref: Windows<19>-Footnote-73880510
Ref: Windows<19>-Footnote-83880565
Ref: Windows<19>-Footnote-93880620
Ref: Windows<19>-Footnote-103880675
Ref: Windows<19>-Footnote-113880731
Ref: Windows<19>-Footnote-123880787
Ref: Windows<19>-Footnote-133880843
Ref: Windows<19>-Footnote-143880899
Ref: Windows<19>-Footnote-153880955
Ref: Windows<19>-Footnote-163881011
Ref: Windows<19>-Footnote-173881067
Ref: Windows<19>-Footnote-183881123
Ref: Windows<19>-Footnote-193881179
Ref: Windows<19>-Footnote-203881235
Ref: Windows<19>-Footnote-213881291
Ref: Windows<19>-Footnote-223881347
Ref: Windows<19>-Footnote-233881403
Ref: Windows<19>-Footnote-243881459
Ref: Windows<19>-Footnote-253881515
Ref: Windows<19>-Footnote-263881571
Ref: Windows<19>-Footnote-273881637
Ref: Windows<19>-Footnote-283881693
Ref: Windows<19>-Footnote-293881759
Node: macOS<15>3881825
Ref: whatsnew/changelog id1863881929
Ref: 17593881929
Ref: macOS<15>-Footnote-13882475
Node: IDLE<15>3882530
Ref: whatsnew/changelog id1873882638
Ref: 175a3882638
Ref: IDLE<15>-Footnote-13883549
Ref: IDLE<15>-Footnote-23883604
Ref: IDLE<15>-Footnote-33883659
Ref: IDLE<15>-Footnote-43883714
Ref: IDLE<15>-Footnote-53883769
Ref: IDLE<15>-Footnote-63883824
Ref: IDLE<15>-Footnote-73883879
Node: Tools/Demos<11>3883934
Ref: whatsnew/changelog id1883884042
Ref: 175b3884042
Ref: Tools/Demos<11>-Footnote-13885553
Ref: Tools/Demos<11>-Footnote-23885608
Ref: Tools/Demos<11>-Footnote-33885663
Ref: Tools/Demos<11>-Footnote-43885711
Ref: Tools/Demos<11>-Footnote-53885766
Ref: Tools/Demos<11>-Footnote-63885814
Ref: Tools/Demos<11>-Footnote-73885869
Ref: Tools/Demos<11>-Footnote-83885924
Ref: Tools/Demos<11>-Footnote-93885979
Ref: Tools/Demos<11>-Footnote-103886034
Ref: Tools/Demos<11>-Footnote-113886090
Ref: Tools/Demos<11>-Footnote-123886146
Node: C API<21>3886202
Ref: whatsnew/changelog id1903886293
Ref: 175c3886293
Ref: C API<21>-Footnote-13893825
Ref: C API<21>-Footnote-23893880
Ref: C API<21>-Footnote-33893935
Ref: C API<21>-Footnote-43893990
Ref: C API<21>-Footnote-53894045
Ref: C API<21>-Footnote-63894100
Ref: C API<21>-Footnote-73894155
Ref: C API<21>-Footnote-83894210
Ref: C API<21>-Footnote-93894265
Ref: C API<21>-Footnote-103894320
Ref: C API<21>-Footnote-113894376
Ref: C API<21>-Footnote-123894432
Ref: C API<21>-Footnote-133894488
Ref: C API<21>-Footnote-143894544
Ref: C API<21>-Footnote-153894600
Ref: C API<21>-Footnote-163894656
Ref: C API<21>-Footnote-173894712
Ref: C API<21>-Footnote-183894768
Ref: C API<21>-Footnote-193894824
Ref: C API<21>-Footnote-203894880
Ref: C API<21>-Footnote-213894936
Ref: C API<21>-Footnote-223894992
Ref: C API<21>-Footnote-233895048
Ref: C API<21>-Footnote-243895104
Ref: C API<21>-Footnote-253895160
Ref: C API<21>-Footnote-263895216
Ref: C API<21>-Footnote-273895272
Ref: C API<21>-Footnote-283895328
Ref: C API<21>-Footnote-293895384
Ref: C API<21>-Footnote-303895440
Ref: C API<21>-Footnote-313895496
Ref: C API<21>-Footnote-323895552
Ref: C API<21>-Footnote-333895608
Ref: C API<21>-Footnote-343895664
Node: Python 3 11 0 beta 13895730
Ref: whatsnew/changelog python-3-11-0-beta-13895859
Ref: 175e3895859
Node: Security<16>3896222
Ref: whatsnew/changelog id1913896321
Ref: 175f3896321
Ref: Security<16>-Footnote-13896620
Node: Core and Builtins<24>3896675
Ref: whatsnew/changelog id1923896794
Ref: 17603896794
Ref: Core and Builtins<24>-Footnote-13906304
Ref: Core and Builtins<24>-Footnote-23906359
Ref: Core and Builtins<24>-Footnote-33906424
Ref: Core and Builtins<24>-Footnote-43906479
Ref: Core and Builtins<24>-Footnote-53906544
Ref: Core and Builtins<24>-Footnote-63906599
Ref: Core and Builtins<24>-Footnote-73906654
Ref: Core and Builtins<24>-Footnote-83906709
Ref: Core and Builtins<24>-Footnote-93906764
Ref: Core and Builtins<24>-Footnote-103906819
Ref: Core and Builtins<24>-Footnote-113906875
Ref: Core and Builtins<24>-Footnote-123906931
Ref: Core and Builtins<24>-Footnote-133906987
Ref: Core and Builtins<24>-Footnote-143907043
Ref: Core and Builtins<24>-Footnote-153907086
Ref: Core and Builtins<24>-Footnote-163907142
Ref: Core and Builtins<24>-Footnote-173907198
Ref: Core and Builtins<24>-Footnote-183907254
Ref: Core and Builtins<24>-Footnote-193907310
Ref: Core and Builtins<24>-Footnote-203907366
Ref: Core and Builtins<24>-Footnote-213907422
Ref: Core and Builtins<24>-Footnote-223907488
Ref: Core and Builtins<24>-Footnote-233907544
Ref: Core and Builtins<24>-Footnote-243907600
Ref: Core and Builtins<24>-Footnote-253907656
Ref: Core and Builtins<24>-Footnote-263907712
Ref: Core and Builtins<24>-Footnote-273907768
Ref: Core and Builtins<24>-Footnote-283907824
Ref: Core and Builtins<24>-Footnote-293907880
Ref: Core and Builtins<24>-Footnote-303907936
Ref: Core and Builtins<24>-Footnote-313907992
Ref: Core and Builtins<24>-Footnote-323908048
Ref: Core and Builtins<24>-Footnote-333908091
Ref: Core and Builtins<24>-Footnote-343908147
Ref: Core and Builtins<24>-Footnote-353908203
Ref: Core and Builtins<24>-Footnote-363908259
Ref: Core and Builtins<24>-Footnote-373908325
Ref: Core and Builtins<24>-Footnote-383908381
Ref: Core and Builtins<24>-Footnote-393908437
Ref: Core and Builtins<24>-Footnote-403908503
Ref: Core and Builtins<24>-Footnote-413908569
Ref: Core and Builtins<24>-Footnote-423908635
Ref: Core and Builtins<24>-Footnote-433908701
Ref: Core and Builtins<24>-Footnote-443908767
Ref: Core and Builtins<24>-Footnote-453908833
Ref: Core and Builtins<24>-Footnote-463908899
Ref: Core and Builtins<24>-Footnote-473908965
Ref: Core and Builtins<24>-Footnote-483909031
Ref: Core and Builtins<24>-Footnote-493909097
Ref: Core and Builtins<24>-Footnote-503909163
Ref: Core and Builtins<24>-Footnote-513909229
Ref: Core and Builtins<24>-Footnote-523909295
Ref: Core and Builtins<24>-Footnote-533909361
Ref: Core and Builtins<24>-Footnote-543909427
Node: Library<23>3909493
Ref: whatsnew/changelog id1933909617
Ref: 17653909617
Ref: Library<23>-Footnote-13927106
Ref: Library<23>-Footnote-23927161
Ref: Library<23>-Footnote-33927216
Ref: Library<23>-Footnote-43927271
Ref: Library<23>-Footnote-53927326
Ref: Library<23>-Footnote-63927381
Ref: Library<23>-Footnote-73927436
Ref: Library<23>-Footnote-83927491
Ref: Library<23>-Footnote-93927546
Ref: Library<23>-Footnote-103927601
Ref: Library<23>-Footnote-113927657
Ref: Library<23>-Footnote-123927713
Ref: Library<23>-Footnote-133927769
Ref: Library<23>-Footnote-143927825
Ref: Library<23>-Footnote-153927881
Ref: Library<23>-Footnote-163927937
Ref: Library<23>-Footnote-173927993
Ref: Library<23>-Footnote-183928049
Ref: Library<23>-Footnote-193928105
Ref: Library<23>-Footnote-203928161
Ref: Library<23>-Footnote-213928217
Ref: Library<23>-Footnote-223928273
Ref: Library<23>-Footnote-233928329
Ref: Library<23>-Footnote-243928395
Ref: Library<23>-Footnote-253928451
Ref: Library<23>-Footnote-263928507
Ref: Library<23>-Footnote-273928550
Ref: Library<23>-Footnote-283928606
Ref: Library<23>-Footnote-293928662
Ref: Library<23>-Footnote-303928718
Ref: Library<23>-Footnote-313928774
Ref: Library<23>-Footnote-323928817
Ref: Library<23>-Footnote-333928873
Ref: Library<23>-Footnote-343928929
Ref: Library<23>-Footnote-353928985
Ref: Library<23>-Footnote-363929041
Ref: Library<23>-Footnote-373929097
Ref: Library<23>-Footnote-383929153
Ref: Library<23>-Footnote-393929209
Ref: Library<23>-Footnote-403929265
Ref: Library<23>-Footnote-413929321
Ref: Library<23>-Footnote-423929377
Ref: Library<23>-Footnote-433929433
Ref: Library<23>-Footnote-443929489
Ref: Library<23>-Footnote-453929545
Ref: Library<23>-Footnote-463929601
Ref: Library<23>-Footnote-473929657
Ref: Library<23>-Footnote-483929713
Ref: Library<23>-Footnote-493929769
Ref: Library<23>-Footnote-503929825
Ref: Library<23>-Footnote-513929881
Ref: Library<23>-Footnote-523929937
Ref: Library<23>-Footnote-533929993
Ref: Library<23>-Footnote-543930049
Ref: Library<23>-Footnote-553930105
Ref: Library<23>-Footnote-563930171
Ref: Library<23>-Footnote-573930227
Ref: Library<23>-Footnote-583930283
Ref: Library<23>-Footnote-593930339
Ref: Library<23>-Footnote-603930395
Ref: Library<23>-Footnote-613930451
Ref: Library<23>-Footnote-623930507
Ref: Library<23>-Footnote-633930563
Ref: Library<23>-Footnote-643930619
Ref: Library<23>-Footnote-653930675
Ref: Library<23>-Footnote-663930718
Ref: Library<23>-Footnote-673930774
Ref: Library<23>-Footnote-683930830
Ref: Library<23>-Footnote-693930886
Ref: Library<23>-Footnote-703930942
Ref: Library<23>-Footnote-713930998
Ref: Library<23>-Footnote-723931054
Ref: Library<23>-Footnote-733931110
Ref: Library<23>-Footnote-743931166
Ref: Library<23>-Footnote-753931232
Ref: Library<23>-Footnote-763931288
Ref: Library<23>-Footnote-773931344
Ref: Library<23>-Footnote-783931410
Ref: Library<23>-Footnote-793931476
Ref: Library<23>-Footnote-803931519
Ref: Library<23>-Footnote-813931585
Ref: Library<23>-Footnote-823931651
Ref: Library<23>-Footnote-833931717
Ref: Library<23>-Footnote-843931783
Ref: Library<23>-Footnote-853931849
Ref: Library<23>-Footnote-863931915
Ref: Library<23>-Footnote-873931981
Ref: Library<23>-Footnote-883932047
Ref: Library<23>-Footnote-893932113
Ref: Library<23>-Footnote-903932179
Ref: Library<23>-Footnote-913932245
Ref: Library<23>-Footnote-923932311
Ref: Library<23>-Footnote-933932377
Ref: Library<23>-Footnote-943932443
Ref: Library<23>-Footnote-953932509
Ref: Library<23>-Footnote-963932575
Ref: Library<23>-Footnote-973932641
Ref: Library<23>-Footnote-983932707
Ref: Library<23>-Footnote-993932773
Ref: Library<23>-Footnote-1003932839
Ref: Library<23>-Footnote-1013932906
Ref: Library<23>-Footnote-1023932973
Ref: Library<23>-Footnote-1033933040
Ref: Library<23>-Footnote-1043933107
Ref: Library<23>-Footnote-1053933174
Ref: Library<23>-Footnote-1063933241
Ref: Library<23>-Footnote-1073933308
Ref: Library<23>-Footnote-1083933375
Ref: Library<23>-Footnote-1093933442
Ref: Library<23>-Footnote-1103933509
Ref: Library<23>-Footnote-1113933576
Ref: Library<23>-Footnote-1123933643
Ref: Library<23>-Footnote-1133933710
Ref: Library<23>-Footnote-1143933777
Ref: Library<23>-Footnote-1153933844
Ref: Library<23>-Footnote-1163933911
Ref: Library<23>-Footnote-1173933978
Ref: Library<23>-Footnote-1183934045
Node: Documentation<18>3934112
Ref: whatsnew/changelog id1943934224
Ref: 17753934224
Ref: Documentation<18>-Footnote-13935766
Ref: Documentation<18>-Footnote-23935821
Ref: Documentation<18>-Footnote-33935876
Ref: Documentation<18>-Footnote-43935931
Ref: Documentation<18>-Footnote-53935986
Ref: Documentation<18>-Footnote-63936051
Ref: Documentation<18>-Footnote-73936116
Ref: Documentation<18>-Footnote-83936181
Ref: Documentation<18>-Footnote-93936246
Ref: Documentation<18>-Footnote-103936288
Ref: Documentation<18>-Footnote-113936331
Ref: Documentation<18>-Footnote-123936397
Ref: Documentation<18>-Footnote-133936463
Ref: Documentation<18>-Footnote-143936528
Node: Tests<21>3936594
Ref: whatsnew/changelog id1953936704
Ref: 17783936704
Ref: Tests<21>-Footnote-13938045
Ref: Tests<21>-Footnote-23938100
Ref: Tests<21>-Footnote-33938155
Ref: Tests<21>-Footnote-43938210
Ref: Tests<21>-Footnote-53938265
Ref: Tests<21>-Footnote-63938320
Ref: Tests<21>-Footnote-73938385
Ref: Tests<21>-Footnote-83938450
Node: Build<23>3938515
Ref: whatsnew/changelog id1963938619
Ref: 177b3938619
Ref: Build<23>-Footnote-13939246
Ref: Build<23>-Footnote-23939301
Ref: Build<23>-Footnote-33939356
Ref: Build<23>-Footnote-43939421
Node: Windows<20>3939486
Ref: whatsnew/changelog id1973939590
Ref: 177c3939590
Ref: Windows<20>-Footnote-13940224
Ref: Windows<20>-Footnote-23940289
Ref: Windows<20>-Footnote-33940354
Ref: Windows<20>-Footnote-43940419
Ref: Windows<20>-Footnote-53940484
Node: macOS<16>3940549
Ref: whatsnew/changelog id1983940659
Ref: 177d3940659
Ref: macOS<16>-Footnote-13940789
Node: Tools/Demos<12>3940854
Ref: whatsnew/changelog id1993940962
Ref: 177e3940962
Ref: Tools/Demos<12>-Footnote-13941519
Ref: Tools/Demos<12>-Footnote-23941574
Ref: Tools/Demos<12>-Footnote-33941629
Node: C API<22>3941684
Ref: whatsnew/changelog id2003941774
Ref: 177f3941774
Ref: C API<22>-Footnote-13943917
Ref: C API<22>-Footnote-23943972
Ref: C API<22>-Footnote-33944027
Ref: C API<22>-Footnote-43944082
Ref: C API<22>-Footnote-53944137
Ref: C API<22>-Footnote-63944192
Ref: C API<22>-Footnote-73944234
Ref: C API<22>-Footnote-83944289
Ref: C API<22>-Footnote-93944344
Ref: C API<22>-Footnote-103944409
Ref: C API<22>-Footnote-113944475
Ref: C API<22>-Footnote-123944541
Ref: C API<22>-Footnote-133944607
Node: Python 3 11 0 alpha 73944673
Ref: whatsnew/changelog python-3-11-0-alpha-73944802
Ref: 17823944802
Node: Core and Builtins<25>3945141
Ref: whatsnew/changelog id2013945240
Ref: 17833945240
Ref: Core and Builtins<25>-Footnote-13950803
Ref: Core and Builtins<25>-Footnote-23950868
Ref: Core and Builtins<25>-Footnote-33950933
Ref: Core and Builtins<25>-Footnote-43950998
Ref: Core and Builtins<25>-Footnote-53951063
Ref: Core and Builtins<25>-Footnote-63951128
Ref: Core and Builtins<25>-Footnote-73951193
Ref: Core and Builtins<25>-Footnote-83951258
Ref: Core and Builtins<25>-Footnote-93951323
Ref: Core and Builtins<25>-Footnote-103951388
Ref: Core and Builtins<25>-Footnote-113951454
Ref: Core and Builtins<25>-Footnote-123951520
Ref: Core and Builtins<25>-Footnote-133951586
Ref: Core and Builtins<25>-Footnote-143951652
Ref: Core and Builtins<25>-Footnote-153951718
Ref: Core and Builtins<25>-Footnote-163951784
Ref: Core and Builtins<25>-Footnote-173951850
Ref: Core and Builtins<25>-Footnote-183951916
Ref: Core and Builtins<25>-Footnote-193951982
Ref: Core and Builtins<25>-Footnote-203952048
Ref: Core and Builtins<25>-Footnote-213952114
Ref: Core and Builtins<25>-Footnote-223952180
Ref: Core and Builtins<25>-Footnote-233952246
Ref: Core and Builtins<25>-Footnote-243952312
Ref: Core and Builtins<25>-Footnote-253952378
Ref: Core and Builtins<25>-Footnote-263952444
Ref: Core and Builtins<25>-Footnote-273952510
Ref: Core and Builtins<25>-Footnote-283952576
Ref: Core and Builtins<25>-Footnote-293952642
Ref: Core and Builtins<25>-Footnote-303952708
Ref: Core and Builtins<25>-Footnote-313952774
Ref: Core and Builtins<25>-Footnote-323952840
Ref: Core and Builtins<25>-Footnote-333952906
Node: Library<24>3952972
Ref: whatsnew/changelog id2023953097
Ref: 17873953097
Ref: Library<24>-Footnote-13967265
Ref: Library<24>-Footnote-23967330
Ref: Library<24>-Footnote-33967395
Ref: Library<24>-Footnote-43967460
Ref: Library<24>-Footnote-53967525
Ref: Library<24>-Footnote-63967590
Ref: Library<24>-Footnote-73967654
Ref: Library<24>-Footnote-83967719
Ref: Library<24>-Footnote-93967784
Ref: Library<24>-Footnote-103967849
Ref: Library<24>-Footnote-113967915
Ref: Library<24>-Footnote-123967981
Ref: Library<24>-Footnote-133968047
Ref: Library<24>-Footnote-143968113
Ref: Library<24>-Footnote-153968156
Ref: Library<24>-Footnote-163968222
Ref: Library<24>-Footnote-173968288
Ref: Library<24>-Footnote-183968354
Ref: Library<24>-Footnote-193968397
Ref: Library<24>-Footnote-203968463
Ref: Library<24>-Footnote-213968529
Ref: Library<24>-Footnote-223968595
Ref: Library<24>-Footnote-233968638
Ref: Library<24>-Footnote-243968704
Ref: Library<24>-Footnote-253968770
Ref: Library<24>-Footnote-263968836
Ref: Library<24>-Footnote-273968902
Ref: Library<24>-Footnote-283968968
Ref: Library<24>-Footnote-293969034
Ref: Library<24>-Footnote-303969101
Ref: Library<24>-Footnote-313969167
Ref: Library<24>-Footnote-323969233
Ref: Library<24>-Footnote-333969299
Ref: Library<24>-Footnote-343969365
Ref: Library<24>-Footnote-353969408
Ref: Library<24>-Footnote-363969474
Ref: Library<24>-Footnote-373969540
Ref: Library<24>-Footnote-383969605
Ref: Library<24>-Footnote-393969671
Ref: Library<24>-Footnote-403969737
Ref: Library<24>-Footnote-413969803
Ref: Library<24>-Footnote-423969869
Ref: Library<24>-Footnote-433969912
Ref: Library<24>-Footnote-443969978
Ref: Library<24>-Footnote-453970044
Ref: Library<24>-Footnote-463970110
Ref: Library<24>-Footnote-473970176
Ref: Library<24>-Footnote-483970242
Ref: Library<24>-Footnote-493970308
Ref: Library<24>-Footnote-503970374
Ref: Library<24>-Footnote-513970440
Ref: Library<24>-Footnote-523970506
Ref: Library<24>-Footnote-533970572
Ref: Library<24>-Footnote-543970638
Ref: Library<24>-Footnote-553970704
Ref: Library<24>-Footnote-563970770
Ref: Library<24>-Footnote-573970836
Ref: Library<24>-Footnote-583970902
Ref: Library<24>-Footnote-593970968
Ref: Library<24>-Footnote-603971011
Ref: Library<24>-Footnote-613971078
Ref: Library<24>-Footnote-623971144
Ref: Library<24>-Footnote-633971210
Ref: Library<24>-Footnote-643971276
Ref: Library<24>-Footnote-653971342
Ref: Library<24>-Footnote-663971408
Ref: Library<24>-Footnote-673971474
Ref: Library<24>-Footnote-683971540
Ref: Library<24>-Footnote-693971606
Ref: Library<24>-Footnote-703971672
Ref: Library<24>-Footnote-713971738
Ref: Library<24>-Footnote-723971804
Ref: Library<24>-Footnote-733971870
Ref: Library<24>-Footnote-743971936
Ref: Library<24>-Footnote-753972002
Ref: Library<24>-Footnote-763972068
Ref: Library<24>-Footnote-773972134
Ref: Library<24>-Footnote-783972200
Ref: Library<24>-Footnote-793972266
Ref: Library<24>-Footnote-803972332
Ref: Library<24>-Footnote-813972398
Ref: Library<24>-Footnote-823972464
Ref: Library<24>-Footnote-833972530
Ref: Library<24>-Footnote-843972573
Ref: Library<24>-Footnote-853972639
Ref: Library<24>-Footnote-863972705
Ref: Library<24>-Footnote-873972771
Ref: Library<24>-Footnote-883972837
Node: Documentation<19>3972903
Ref: whatsnew/changelog id2033973016
Ref: 17933973016
Ref: Documentation<19>-Footnote-13974158
Ref: Documentation<19>-Footnote-23974223
Ref: Documentation<19>-Footnote-33974288
Ref: Documentation<19>-Footnote-43974330
Ref: Documentation<19>-Footnote-53974395
Ref: Documentation<19>-Footnote-63974460
Ref: Documentation<19>-Footnote-73974525
Ref: Documentation<19>-Footnote-83974590
Node: Tests<22>3974655
Ref: whatsnew/changelog id2043974766
Ref: 17963974766
Ref: Tests<22>-Footnote-13975729
Ref: Tests<22>-Footnote-23975794
Ref: Tests<22>-Footnote-33975859
Ref: Tests<22>-Footnote-43975924
Ref: Tests<22>-Footnote-53975989
Ref: Tests<22>-Footnote-63976054
Ref: Tests<22>-Footnote-73976119
Ref: Tests<22>-Footnote-83976184
Node: Build<24>3976226
Ref: whatsnew/changelog id2053976331
Ref: 17973976331
Ref: Build<24>-Footnote-13977617
Ref: Build<24>-Footnote-23977682
Ref: Build<24>-Footnote-33977747
Ref: Build<24>-Footnote-43977812
Ref: Build<24>-Footnote-53977877
Ref: Build<24>-Footnote-63977942
Ref: Build<24>-Footnote-73978007
Ref: Build<24>-Footnote-83978072
Ref: Build<24>-Footnote-93978137
Node: Windows<21>3978202
Ref: whatsnew/changelog id2063978307
Ref: 17993978307
Ref: Windows<21>-Footnote-13979502
Ref: Windows<21>-Footnote-23979567
Ref: Windows<21>-Footnote-33979623
Ref: Windows<21>-Footnote-43979688
Ref: Windows<21>-Footnote-53979753
Ref: Windows<21>-Footnote-63979795
Ref: Windows<21>-Footnote-73979860
Ref: Windows<21>-Footnote-83979925
Ref: Windows<21>-Footnote-93979990
Ref: Windows<21>-Footnote-103980045
Ref: Windows<21>-Footnote-113980102
Ref: Windows<21>-Footnote-123980168
Node: macOS<17>3980225
Ref: whatsnew/changelog id2073980336
Ref: 179a3980336
Ref: macOS<17>-Footnote-13980671
Ref: macOS<17>-Footnote-23980736
Node: Tools/Demos<13>3980801
Ref: whatsnew/changelog id2083980910
Ref: 179b3980910
Ref: Tools/Demos<13>-Footnote-13981111
Node: C API<23>3981176
Ref: whatsnew/changelog id2093981267
Ref: 179c3981267
Ref: C API<23>-Footnote-13983524
Ref: C API<23>-Footnote-23983589
Ref: C API<23>-Footnote-33983654
Ref: C API<23>-Footnote-43983719
Ref: C API<23>-Footnote-53983784
Ref: C API<23>-Footnote-63983849
Ref: C API<23>-Footnote-73983914
Ref: C API<23>-Footnote-83983979
Node: Python 3 11 0 alpha 63984044
Ref: whatsnew/changelog python-3-11-0-alpha-63984174
Ref: 179f3984174
Node: Core and Builtins<26>3984479
Ref: whatsnew/changelog id2103984578
Ref: 17a03984578
Ref: Core and Builtins<26>-Footnote-13991553
Ref: Core and Builtins<26>-Footnote-23991618
Ref: Core and Builtins<26>-Footnote-33991683
Ref: Core and Builtins<26>-Footnote-43991748
Ref: Core and Builtins<26>-Footnote-53991813
Ref: Core and Builtins<26>-Footnote-63991878
Ref: Core and Builtins<26>-Footnote-73991943
Ref: Core and Builtins<26>-Footnote-83992008
Ref: Core and Builtins<26>-Footnote-93992073
Ref: Core and Builtins<26>-Footnote-103992138
Ref: Core and Builtins<26>-Footnote-113992204
Ref: Core and Builtins<26>-Footnote-123992270
Ref: Core and Builtins<26>-Footnote-133992336
Ref: Core and Builtins<26>-Footnote-143992402
Ref: Core and Builtins<26>-Footnote-153992468
Ref: Core and Builtins<26>-Footnote-163992534
Ref: Core and Builtins<26>-Footnote-173992600
Ref: Core and Builtins<26>-Footnote-183992666
Ref: Core and Builtins<26>-Footnote-193992732
Ref: Core and Builtins<26>-Footnote-203992798
Ref: Core and Builtins<26>-Footnote-213992864
Ref: Core and Builtins<26>-Footnote-223992930
Ref: Core and Builtins<26>-Footnote-233992996
Ref: Core and Builtins<26>-Footnote-243993062
Ref: Core and Builtins<26>-Footnote-253993128
Ref: Core and Builtins<26>-Footnote-263993194
Ref: Core and Builtins<26>-Footnote-273993260
Ref: Core and Builtins<26>-Footnote-283993326
Ref: Core and Builtins<26>-Footnote-293993392
Ref: Core and Builtins<26>-Footnote-303993458
Ref: Core and Builtins<26>-Footnote-313993524
Ref: Core and Builtins<26>-Footnote-323993590
Ref: Core and Builtins<26>-Footnote-333993656
Ref: Core and Builtins<26>-Footnote-343993722
Ref: Core and Builtins<26>-Footnote-353993788
Ref: Core and Builtins<26>-Footnote-363993854
Ref: Core and Builtins<26>-Footnote-373993920
Ref: Core and Builtins<26>-Footnote-383993986
Ref: Core and Builtins<26>-Footnote-393994052
Ref: Core and Builtins<26>-Footnote-403994118
Ref: Core and Builtins<26>-Footnote-413994184
Ref: Core and Builtins<26>-Footnote-423994250
Ref: Core and Builtins<26>-Footnote-433994316
Ref: Core and Builtins<26>-Footnote-443994382
Ref: Core and Builtins<26>-Footnote-453994448
Ref: Core and Builtins<26>-Footnote-463994514
Ref: Core and Builtins<26>-Footnote-473994580
Ref: Core and Builtins<26>-Footnote-483994646
Node: Library<25>3994712
Ref: whatsnew/changelog id2113994837
Ref: 17a63994837
Ref: Library<25>-Footnote-14003035
Ref: Library<25>-Footnote-24003100
Ref: Library<25>-Footnote-34003165
Ref: Library<25>-Footnote-44003230
Ref: Library<25>-Footnote-54003295
Ref: Library<25>-Footnote-64003360
Ref: Library<25>-Footnote-74003425
Ref: Library<25>-Footnote-84003490
Ref: Library<25>-Footnote-94003555
Ref: Library<25>-Footnote-104003620
Ref: Library<25>-Footnote-114003686
Ref: Library<25>-Footnote-124003752
Ref: Library<25>-Footnote-134003818
Ref: Library<25>-Footnote-144003884
Ref: Library<25>-Footnote-154003950
Ref: Library<25>-Footnote-164004016
Ref: Library<25>-Footnote-174004082
Ref: Library<25>-Footnote-184004148
Ref: Library<25>-Footnote-194004214
Ref: Library<25>-Footnote-204004280
Ref: Library<25>-Footnote-214004346
Ref: Library<25>-Footnote-224004412
Ref: Library<25>-Footnote-234004478
Ref: Library<25>-Footnote-244004544
Ref: Library<25>-Footnote-254004610
Ref: Library<25>-Footnote-264004676
Ref: Library<25>-Footnote-274004742
Ref: Library<25>-Footnote-284004808
Ref: Library<25>-Footnote-294004874
Ref: Library<25>-Footnote-304004940
Ref: Library<25>-Footnote-314005006
Ref: Library<25>-Footnote-324005072
Ref: Library<25>-Footnote-334005138
Ref: Library<25>-Footnote-344005204
Ref: Library<25>-Footnote-354005247
Ref: Library<25>-Footnote-364005313
Ref: Library<25>-Footnote-374005379
Ref: Library<25>-Footnote-384005445
Ref: Library<25>-Footnote-394005511
Ref: Library<25>-Footnote-404005577
Ref: Library<25>-Footnote-414005643
Ref: Library<25>-Footnote-424005709
Ref: Library<25>-Footnote-434005775
Ref: Library<25>-Footnote-444005841
Ref: Library<25>-Footnote-454005907
Ref: Library<25>-Footnote-464005973
Ref: Library<25>-Footnote-474006039
Ref: Library<25>-Footnote-484006105
Node: Documentation<20>4006171
Ref: whatsnew/changelog id2124006284
Ref: 17b14006284
Ref: Documentation<20>-Footnote-14006503
Node: Tests<23>4006568
Ref: whatsnew/changelog id2134006679
Ref: 17b24006679
Ref: Tests<23>-Footnote-14007648
Ref: Tests<23>-Footnote-24007713
Ref: Tests<23>-Footnote-34007778
Ref: Tests<23>-Footnote-44007843
Ref: Tests<23>-Footnote-54007908
Node: Build<25>4007973
Ref: whatsnew/changelog id2144008078
Ref: 17b34008078
Ref: Build<25>-Footnote-14009504
Ref: Build<25>-Footnote-24009569
Ref: Build<25>-Footnote-34009634
Ref: Build<25>-Footnote-44009699
Ref: Build<25>-Footnote-54009764
Ref: Build<25>-Footnote-64009829
Ref: Build<25>-Footnote-74009894
Node: Windows<22>4009959
Ref: whatsnew/changelog id2154010063
Ref: 17b44010063
Ref: Windows<22>-Footnote-14010721
Ref: Windows<22>-Footnote-24010786
Ref: Windows<22>-Footnote-34010851
Node: IDLE<16>4010916
Ref: whatsnew/changelog id2164011020
Ref: 17b54011020
Ref: IDLE<16>-Footnote-14011300
Ref: IDLE<16>-Footnote-24011365
Node: C API<24>4011430
Ref: whatsnew/changelog id2174011514
Ref: 17b64011514
Ref: C API<24>-Footnote-14012457
Ref: C API<24>-Footnote-24012522
Ref: C API<24>-Footnote-34012587
Ref: C API<24>-Footnote-44012652
Ref: C API<24>-Footnote-54012717
Node: Python 3 11 0 alpha 54012782
Ref: whatsnew/changelog python-3-11-0-alpha-54012912
Ref: 17b74012912
Node: Core and Builtins<27>4013237
Ref: whatsnew/changelog id2184013336
Ref: 17b84013336
Ref: Core and Builtins<27>-Footnote-14018381
Ref: Core and Builtins<27>-Footnote-24018446
Ref: Core and Builtins<27>-Footnote-34018511
Ref: Core and Builtins<27>-Footnote-44018576
Ref: Core and Builtins<27>-Footnote-54018641
Ref: Core and Builtins<27>-Footnote-64018706
Ref: Core and Builtins<27>-Footnote-74018771
Ref: Core and Builtins<27>-Footnote-84018836
Ref: Core and Builtins<27>-Footnote-94018901
Ref: Core and Builtins<27>-Footnote-104018966
Ref: Core and Builtins<27>-Footnote-114019032
Ref: Core and Builtins<27>-Footnote-124019098
Ref: Core and Builtins<27>-Footnote-134019164
Ref: Core and Builtins<27>-Footnote-144019207
Ref: Core and Builtins<27>-Footnote-154019273
Ref: Core and Builtins<27>-Footnote-164019339
Ref: Core and Builtins<27>-Footnote-174019405
Ref: Core and Builtins<27>-Footnote-184019471
Ref: Core and Builtins<27>-Footnote-194019537
Ref: Core and Builtins<27>-Footnote-204019603
Ref: Core and Builtins<27>-Footnote-214019669
Ref: Core and Builtins<27>-Footnote-224019735
Ref: Core and Builtins<27>-Footnote-234019801
Ref: Core and Builtins<27>-Footnote-244019867
Ref: Core and Builtins<27>-Footnote-254019933
Ref: Core and Builtins<27>-Footnote-264019999
Ref: Core and Builtins<27>-Footnote-274020065
Node: Library<26>4020131
Ref: whatsnew/changelog id2194020256
Ref: 17bb4020256
Ref: Library<26>-Footnote-14026194
Ref: Library<26>-Footnote-24026259
Ref: Library<26>-Footnote-34026324
Ref: Library<26>-Footnote-44026389
Ref: Library<26>-Footnote-54026454
Ref: Library<26>-Footnote-64026519
Ref: Library<26>-Footnote-74026584
Ref: Library<26>-Footnote-84026649
Ref: Library<26>-Footnote-94026714
Ref: Library<26>-Footnote-104026779
Ref: Library<26>-Footnote-114026845
Ref: Library<26>-Footnote-124026911
Ref: Library<26>-Footnote-134026977
Ref: Library<26>-Footnote-144027043
Ref: Library<26>-Footnote-154027109
Ref: Library<26>-Footnote-164027175
Ref: Library<26>-Footnote-174027241
Ref: Library<26>-Footnote-184027307
Ref: Library<26>-Footnote-194027373
Ref: Library<26>-Footnote-204027439
Ref: Library<26>-Footnote-214027505
Ref: Library<26>-Footnote-224027571
Ref: Library<26>-Footnote-234027637
Ref: Library<26>-Footnote-244027703
Ref: Library<26>-Footnote-254027769
Ref: Library<26>-Footnote-264027835
Ref: Library<26>-Footnote-274027901
Ref: Library<26>-Footnote-284027967
Ref: Library<26>-Footnote-294028033
Ref: Library<26>-Footnote-304028099
Ref: Library<26>-Footnote-314028165
Ref: Library<26>-Footnote-324028231
Ref: Library<26>-Footnote-334028297
Ref: Library<26>-Footnote-344028363
Ref: Library<26>-Footnote-354028429
Ref: Library<26>-Footnote-364028495
Ref: Library<26>-Footnote-374028561
Node: Documentation<21>4028627
Ref: whatsnew/changelog id2204028740
Ref: 17c14028740
Ref: Documentation<21>-Footnote-14028929
Node: Tests<24>4028994
Ref: whatsnew/changelog id2214029105
Ref: 17c24029105
Ref: Tests<24>-Footnote-14031250
Ref: Tests<24>-Footnote-24031315
Ref: Tests<24>-Footnote-34031380
Ref: Tests<24>-Footnote-44031445
Ref: Tests<24>-Footnote-54031510
Ref: Tests<24>-Footnote-64031575
Ref: Tests<24>-Footnote-74031640
Ref: Tests<24>-Footnote-84031705
Ref: Tests<24>-Footnote-94031770
Ref: Tests<24>-Footnote-104031835
Ref: Tests<24>-Footnote-114031901
Node: Build<26>4031967
Ref: whatsnew/changelog id2224032072
Ref: 17c34032072
Ref: Build<26>-Footnote-14033802
Ref: Build<26>-Footnote-24033867
Ref: Build<26>-Footnote-34033932
Ref: Build<26>-Footnote-44033997
Ref: Build<26>-Footnote-54034062
Ref: Build<26>-Footnote-64034127
Ref: Build<26>-Footnote-74034192
Ref: Build<26>-Footnote-84034257
Ref: Build<26>-Footnote-94034322
Ref: Build<26>-Footnote-104034387
Node: Windows<23>4034453
Ref: whatsnew/changelog id2234034558
Ref: 17c44034558
Ref: Windows<23>-Footnote-14035086
Ref: Windows<23>-Footnote-24035151
Ref: Windows<23>-Footnote-34035216
Node: macOS<18>4035281
Ref: whatsnew/changelog id2244035385
Ref: 17c54035385
Ref: macOS<18>-Footnote-14035515
Node: IDLE<17>4035580
Ref: whatsnew/changelog id2254035682
Ref: 17c64035682
Ref: IDLE<17>-Footnote-14036069
Node: C API<25>4036134
Ref: whatsnew/changelog id2264036218
Ref: 17c74036218
Ref: C API<25>-Footnote-14037109
Ref: C API<25>-Footnote-24037174
Ref: C API<25>-Footnote-34037239
Ref: C API<25>-Footnote-44037304
Ref: C API<25>-Footnote-54037369
Node: Python 3 11 0 alpha 44037434
Ref: whatsnew/changelog python-3-11-0-alpha-44037564
Ref: 17c84037564
Node: Core and Builtins<28>4037871
Ref: whatsnew/changelog id2274037970
Ref: 17c94037970
Ref: Core and Builtins<28>-Footnote-14044738
Ref: Core and Builtins<28>-Footnote-24044803
Ref: Core and Builtins<28>-Footnote-34044868
Ref: Core and Builtins<28>-Footnote-44044933
Ref: Core and Builtins<28>-Footnote-54044998
Ref: Core and Builtins<28>-Footnote-64045063
Ref: Core and Builtins<28>-Footnote-74045128
Ref: Core and Builtins<28>-Footnote-84045193
Ref: Core and Builtins<28>-Footnote-94045258
Ref: Core and Builtins<28>-Footnote-104045323
Ref: Core and Builtins<28>-Footnote-114045389
Ref: Core and Builtins<28>-Footnote-124045455
Ref: Core and Builtins<28>-Footnote-134045521
Ref: Core and Builtins<28>-Footnote-144045587
Ref: Core and Builtins<28>-Footnote-154045653
Ref: Core and Builtins<28>-Footnote-164045719
Ref: Core and Builtins<28>-Footnote-174045785
Ref: Core and Builtins<28>-Footnote-184045851
Ref: Core and Builtins<28>-Footnote-194045917
Ref: Core and Builtins<28>-Footnote-204045983
Ref: Core and Builtins<28>-Footnote-214046049
Ref: Core and Builtins<28>-Footnote-224046115
Ref: Core and Builtins<28>-Footnote-234046181
Ref: Core and Builtins<28>-Footnote-244046247
Ref: Core and Builtins<28>-Footnote-254046313
Ref: Core and Builtins<28>-Footnote-264046379
Ref: Core and Builtins<28>-Footnote-274046445
Ref: Core and Builtins<28>-Footnote-284046511
Ref: Core and Builtins<28>-Footnote-294046577
Ref: Core and Builtins<28>-Footnote-304046643
Ref: Core and Builtins<28>-Footnote-314046709
Ref: Core and Builtins<28>-Footnote-324046775
Ref: Core and Builtins<28>-Footnote-334046841
Ref: Core and Builtins<28>-Footnote-344046907
Ref: Core and Builtins<28>-Footnote-354046973
Ref: Core and Builtins<28>-Footnote-364047039
Ref: Core and Builtins<28>-Footnote-374047105
Ref: Core and Builtins<28>-Footnote-384047171
Ref: Core and Builtins<28>-Footnote-394047237
Ref: Core and Builtins<28>-Footnote-404047280
Ref: Core and Builtins<28>-Footnote-414047346
Node: Library<27>4047412
Ref: whatsnew/changelog id2284047537
Ref: 17cb4047537
Ref: Library<27>-Footnote-14054788
Ref: Library<27>-Footnote-24054853
Ref: Library<27>-Footnote-34054918
Ref: Library<27>-Footnote-44054983
Ref: Library<27>-Footnote-54055048
Ref: Library<27>-Footnote-64055113
Ref: Library<27>-Footnote-74055178
Ref: Library<27>-Footnote-84055243
Ref: Library<27>-Footnote-94055308
Ref: Library<27>-Footnote-104055373
Ref: Library<27>-Footnote-114055439
Ref: Library<27>-Footnote-124055505
Ref: Library<27>-Footnote-134055571
Ref: Library<27>-Footnote-144055637
Ref: Library<27>-Footnote-154055703
Ref: Library<27>-Footnote-164055769
Ref: Library<27>-Footnote-174055835
Ref: Library<27>-Footnote-184055901
Ref: Library<27>-Footnote-194055967
Ref: Library<27>-Footnote-204056033
Ref: Library<27>-Footnote-214056099
Ref: Library<27>-Footnote-224056165
Ref: Library<27>-Footnote-234056231
Ref: Library<27>-Footnote-244056297
Ref: Library<27>-Footnote-254056363
Ref: Library<27>-Footnote-264056429
Ref: Library<27>-Footnote-274056495
Ref: Library<27>-Footnote-284056561
Ref: Library<27>-Footnote-294056627
Ref: Library<27>-Footnote-304056693
Ref: Library<27>-Footnote-314056759
Ref: Library<27>-Footnote-324056825
Ref: Library<27>-Footnote-334056891
Ref: Library<27>-Footnote-344056957
Ref: Library<27>-Footnote-354057023
Ref: Library<27>-Footnote-364057089
Ref: Library<27>-Footnote-374057155
Ref: Library<27>-Footnote-384057221
Ref: Library<27>-Footnote-394057287
Ref: Library<27>-Footnote-404057353
Ref: Library<27>-Footnote-414057419
Ref: Library<27>-Footnote-424057485
Ref: Library<27>-Footnote-434057551
Ref: Library<27>-Footnote-444057617
Node: Documentation<22>4057683
Ref: whatsnew/changelog id2294057796
Ref: 17d04057796
Ref: Documentation<22>-Footnote-14058292
Ref: Documentation<22>-Footnote-24058357
Ref: Documentation<22>-Footnote-34058422
Ref: Documentation<22>-Footnote-44058487
Node: Tests<25>4058552
Ref: whatsnew/changelog id2304058663
Ref: 17d34058663
Ref: Tests<25>-Footnote-14059591
Ref: Tests<25>-Footnote-24059656
Ref: Tests<25>-Footnote-34059721
Ref: Tests<25>-Footnote-44059786
Ref: Tests<25>-Footnote-54059851
Ref: Tests<25>-Footnote-64059916
Ref: Tests<25>-Footnote-74059981
Ref: Tests<25>-Footnote-84060046
Node: Build<27>4060111
Ref: whatsnew/changelog id2314060216
Ref: 17d44060216
Ref: Build<27>-Footnote-14062276
Ref: Build<27>-Footnote-24062341
Ref: Build<27>-Footnote-34062406
Ref: Build<27>-Footnote-44062471
Ref: Build<27>-Footnote-54062536
Ref: Build<27>-Footnote-64062601
Ref: Build<27>-Footnote-74062666
Ref: Build<27>-Footnote-84062731
Ref: Build<27>-Footnote-94062796
Ref: Build<27>-Footnote-104062861
Ref: Build<27>-Footnote-114062927
Ref: Build<27>-Footnote-124062993
Node: Windows<24>4063059
Ref: whatsnew/changelog id2324063164
Ref: 17d54063164
Ref: Windows<24>-Footnote-14063383
Node: macOS<19>4063448
Ref: whatsnew/changelog id2334063553
Ref: 17d64063553
Ref: macOS<19>-Footnote-14063791
Node: C API<26>4063856
Ref: whatsnew/changelog id2344063941
Ref: 17d74063941
Ref: C API<26>-Footnote-14065217
Ref: C API<26>-Footnote-24065282
Ref: C API<26>-Footnote-34065347
Ref: C API<26>-Footnote-44065412
Ref: C API<26>-Footnote-54065477
Node: Python 3 11 0 alpha 34065542
Ref: whatsnew/changelog python-3-11-0-alpha-34065672
Ref: 17d94065672
Node: Core and Builtins<29>4065979
Ref: whatsnew/changelog id2354066078
Ref: 17da4066078
Ref: Core and Builtins<29>-Footnote-14071700
Ref: Core and Builtins<29>-Footnote-24071765
Ref: Core and Builtins<29>-Footnote-34071830
Ref: Core and Builtins<29>-Footnote-44071895
Ref: Core and Builtins<29>-Footnote-54071960
Ref: Core and Builtins<29>-Footnote-64072025
Ref: Core and Builtins<29>-Footnote-74072090
Ref: Core and Builtins<29>-Footnote-84072155
Ref: Core and Builtins<29>-Footnote-94072220
Ref: Core and Builtins<29>-Footnote-104072285
Ref: Core and Builtins<29>-Footnote-114072351
Ref: Core and Builtins<29>-Footnote-124072417
Ref: Core and Builtins<29>-Footnote-134072483
Ref: Core and Builtins<29>-Footnote-144072549
Ref: Core and Builtins<29>-Footnote-154072615
Ref: Core and Builtins<29>-Footnote-164072681
Ref: Core and Builtins<29>-Footnote-174072747
Ref: Core and Builtins<29>-Footnote-184072813
Ref: Core and Builtins<29>-Footnote-194072879
Ref: Core and Builtins<29>-Footnote-204072945
Ref: Core and Builtins<29>-Footnote-214073011
Ref: Core and Builtins<29>-Footnote-224073077
Ref: Core and Builtins<29>-Footnote-234073120
Ref: Core and Builtins<29>-Footnote-244073186
Ref: Core and Builtins<29>-Footnote-254073252
Ref: Core and Builtins<29>-Footnote-264073318
Ref: Core and Builtins<29>-Footnote-274073384
Ref: Core and Builtins<29>-Footnote-284073450
Ref: Core and Builtins<29>-Footnote-294073516
Ref: Core and Builtins<29>-Footnote-304073582
Ref: Core and Builtins<29>-Footnote-314073648
Ref: Core and Builtins<29>-Footnote-324073714
Ref: Core and Builtins<29>-Footnote-334073780
Ref: Core and Builtins<29>-Footnote-344073846
Node: Library<28>4073912
Ref: whatsnew/changelog id2364074037
Ref: 17dc4074037
Ref: Library<28>-Footnote-14079995
Ref: Library<28>-Footnote-24080060
Ref: Library<28>-Footnote-34080125
Ref: Library<28>-Footnote-44080190
Ref: Library<28>-Footnote-54080255
Ref: Library<28>-Footnote-64080320
Ref: Library<28>-Footnote-74080385
Ref: Library<28>-Footnote-84080450
Ref: Library<28>-Footnote-94080515
Ref: Library<28>-Footnote-104080580
Ref: Library<28>-Footnote-114080646
Ref: Library<28>-Footnote-124080712
Ref: Library<28>-Footnote-134080778
Ref: Library<28>-Footnote-144080844
Ref: Library<28>-Footnote-154080910
Ref: Library<28>-Footnote-164080976
Ref: Library<28>-Footnote-174081042
Ref: Library<28>-Footnote-184081108
Ref: Library<28>-Footnote-194081174
Ref: Library<28>-Footnote-204081240
Ref: Library<28>-Footnote-214081306
Ref: Library<28>-Footnote-224081372
Ref: Library<28>-Footnote-234081438
Ref: Library<28>-Footnote-244081504
Ref: Library<28>-Footnote-254081570
Ref: Library<28>-Footnote-264081636
Ref: Library<28>-Footnote-274081702
Ref: Library<28>-Footnote-284081768
Ref: Library<28>-Footnote-294081834
Ref: Library<28>-Footnote-304081900
Ref: Library<28>-Footnote-314081966
Ref: Library<28>-Footnote-324082009
Ref: Library<28>-Footnote-334082075
Ref: Library<28>-Footnote-344082141
Ref: Library<28>-Footnote-354082207
Ref: Library<28>-Footnote-364082273
Node: Documentation<23>4082339
Ref: whatsnew/changelog id2374082452
Ref: 17de4082452
Ref: Documentation<23>-Footnote-14083760
Ref: Documentation<23>-Footnote-24083825
Ref: Documentation<23>-Footnote-34083890
Ref: Documentation<23>-Footnote-44083955
Ref: Documentation<23>-Footnote-54084020
Ref: Documentation<23>-Footnote-64084085
Ref: Documentation<23>-Footnote-74084150
Ref: Documentation<23>-Footnote-84084215
Ref: Documentation<23>-Footnote-94084280
Node: Tests<26>4084345
Ref: whatsnew/changelog id2384084456
Ref: 17df4084456
Ref: Tests<26>-Footnote-14085263
Ref: Tests<26>-Footnote-24085328
Ref: Tests<26>-Footnote-34085393
Ref: Tests<26>-Footnote-44085458
Ref: Tests<26>-Footnote-54085523
Ref: Tests<26>-Footnote-64085588
Node: Build<28>4085653
Ref: whatsnew/changelog id2394085758
Ref: 17e04085758
Ref: Build<28>-Footnote-14091552
Ref: Build<28>-Footnote-24091617
Ref: Build<28>-Footnote-34091682
Ref: Build<28>-Footnote-44091747
Ref: Build<28>-Footnote-54091812
Ref: Build<28>-Footnote-64091877
Ref: Build<28>-Footnote-74091942
Ref: Build<28>-Footnote-84092007
Ref: Build<28>-Footnote-94092072
Ref: Build<28>-Footnote-104092137
Ref: Build<28>-Footnote-114092203
Ref: Build<28>-Footnote-124092269
Ref: Build<28>-Footnote-134092335
Ref: Build<28>-Footnote-144092401
Ref: Build<28>-Footnote-154092467
Ref: Build<28>-Footnote-164092533
Ref: Build<28>-Footnote-174092599
Ref: Build<28>-Footnote-184092665
Ref: Build<28>-Footnote-194092731
Ref: Build<28>-Footnote-204092797
Ref: Build<28>-Footnote-214092863
Ref: Build<28>-Footnote-224092929
Ref: Build<28>-Footnote-234092995
Ref: Build<28>-Footnote-244093061
Ref: Build<28>-Footnote-254093127
Ref: Build<28>-Footnote-264093193
Ref: Build<28>-Footnote-274093259
Ref: Build<28>-Footnote-284093325
Ref: Build<28>-Footnote-294093391
Ref: Build<28>-Footnote-304093457
Ref: Build<28>-Footnote-314093523
Ref: Build<28>-Footnote-324093589
Ref: Build<28>-Footnote-334093655
Node: Windows<25>4093721
Ref: whatsnew/changelog id2404093826
Ref: 17e14093826
Ref: Windows<25>-Footnote-14095007
Ref: Windows<25>-Footnote-24095072
Ref: Windows<25>-Footnote-34095137
Ref: Windows<25>-Footnote-44095202
Ref: Windows<25>-Footnote-54095267
Ref: Windows<25>-Footnote-64095332
Node: macOS<20>4095397
Ref: whatsnew/changelog id2414095502
Ref: 17e24095502
Ref: macOS<20>-Footnote-14095652
Node: C API<27>4095717
Ref: whatsnew/changelog id2424095802
Ref: 17e34095802
Ref: C API<27>-Footnote-14096007
Node: Python 3 11 0 alpha 24096072
Ref: whatsnew/changelog python-3-11-0-alpha-24096202
Ref: 17e44096202
Node: Core and Builtins<30>4096527
Ref: whatsnew/changelog id2434096626
Ref: 17e54096626
Ref: Core and Builtins<30>-Footnote-14101986
Ref: Core and Builtins<30>-Footnote-24102051
Ref: Core and Builtins<30>-Footnote-34102116
Ref: Core and Builtins<30>-Footnote-44102181
Ref: Core and Builtins<30>-Footnote-54102246
Ref: Core and Builtins<30>-Footnote-64102311
Ref: Core and Builtins<30>-Footnote-74102376
Ref: Core and Builtins<30>-Footnote-84102441
Ref: Core and Builtins<30>-Footnote-94102506
Ref: Core and Builtins<30>-Footnote-104102571
Ref: Core and Builtins<30>-Footnote-114102637
Ref: Core and Builtins<30>-Footnote-124102703
Ref: Core and Builtins<30>-Footnote-134102769
Ref: Core and Builtins<30>-Footnote-144102835
Ref: Core and Builtins<30>-Footnote-154102901
Ref: Core and Builtins<30>-Footnote-164102967
Ref: Core and Builtins<30>-Footnote-174103033
Ref: Core and Builtins<30>-Footnote-184103099
Ref: Core and Builtins<30>-Footnote-194103165
Ref: Core and Builtins<30>-Footnote-204103231
Ref: Core and Builtins<30>-Footnote-214103274
Ref: Core and Builtins<30>-Footnote-224103340
Ref: Core and Builtins<30>-Footnote-234103406
Ref: Core and Builtins<30>-Footnote-244103472
Ref: Core and Builtins<30>-Footnote-254103538
Ref: Core and Builtins<30>-Footnote-264103604
Node: Library<29>4103647
Ref: whatsnew/changelog id2444103772
Ref: 17e74103772
Ref: Library<29>-Footnote-14111317
Ref: Library<29>-Footnote-24111382
Ref: Library<29>-Footnote-34111447
Ref: Library<29>-Footnote-44111512
Ref: Library<29>-Footnote-54111577
Ref: Library<29>-Footnote-64111642
Ref: Library<29>-Footnote-74111707
Ref: Library<29>-Footnote-84111772
Ref: Library<29>-Footnote-94111837
Ref: Library<29>-Footnote-104111902
Ref: Library<29>-Footnote-114111968
Ref: Library<29>-Footnote-124112034
Ref: Library<29>-Footnote-134112100
Ref: Library<29>-Footnote-144112166
Ref: Library<29>-Footnote-154112232
Ref: Library<29>-Footnote-164112298
Ref: Library<29>-Footnote-174112364
Ref: Library<29>-Footnote-184112430
Ref: Library<29>-Footnote-194112496
Ref: Library<29>-Footnote-204112562
Ref: Library<29>-Footnote-214112628
Ref: Library<29>-Footnote-224112694
Ref: Library<29>-Footnote-234112760
Ref: Library<29>-Footnote-244112826
Ref: Library<29>-Footnote-254112892
Ref: Library<29>-Footnote-264112958
Ref: Library<29>-Footnote-274113024
Ref: Library<29>-Footnote-284113090
Ref: Library<29>-Footnote-294113156
Ref: Library<29>-Footnote-304113222
Ref: Library<29>-Footnote-314113288
Ref: Library<29>-Footnote-324113354
Ref: Library<29>-Footnote-334113420
Ref: Library<29>-Footnote-344113486
Ref: Library<29>-Footnote-354113552
Ref: Library<29>-Footnote-364113618
Ref: Library<29>-Footnote-374113684
Ref: Library<29>-Footnote-384113750
Ref: Library<29>-Footnote-394113816
Ref: Library<29>-Footnote-404113882
Ref: Library<29>-Footnote-414113948
Ref: Library<29>-Footnote-424114014
Ref: Library<29>-Footnote-434114080
Ref: Library<29>-Footnote-444114140
Ref: Library<29>-Footnote-454114206
Node: Documentation<24>4114272
Ref: whatsnew/changelog id2454114385
Ref: 17ec4114385
Ref: Documentation<24>-Footnote-14115877
Ref: Documentation<24>-Footnote-24115942
Ref: Documentation<24>-Footnote-34116007
Ref: Documentation<24>-Footnote-44116072
Ref: Documentation<24>-Footnote-54116137
Ref: Documentation<24>-Footnote-64116202
Ref: Documentation<24>-Footnote-74116267
Ref: Documentation<24>-Footnote-84116332
Ref: Documentation<24>-Footnote-94116397
Ref: Documentation<24>-Footnote-104116439
Ref: Documentation<24>-Footnote-114116505
Node: Tests<27>4116571
Ref: whatsnew/changelog id2464116682
Ref: 17f04116682
Ref: Tests<27>-Footnote-14118942
Ref: Tests<27>-Footnote-24119007
Ref: Tests<27>-Footnote-34119072
Ref: Tests<27>-Footnote-44119137
Ref: Tests<27>-Footnote-54119202
Ref: Tests<27>-Footnote-64119267
Ref: Tests<27>-Footnote-74119332
Ref: Tests<27>-Footnote-84119397
Ref: Tests<27>-Footnote-94119462
Ref: Tests<27>-Footnote-104119527
Ref: Tests<27>-Footnote-114119593
Ref: Tests<27>-Footnote-124119659
Ref: Tests<27>-Footnote-134119725
Node: Build<29>4119791
Ref: whatsnew/changelog id2474119896
Ref: 17f14119896
Ref: Build<29>-Footnote-14122571
Ref: Build<29>-Footnote-24122636
Ref: Build<29>-Footnote-34122701
Ref: Build<29>-Footnote-44122766
Ref: Build<29>-Footnote-54122831
Ref: Build<29>-Footnote-64122896
Ref: Build<29>-Footnote-74122961
Ref: Build<29>-Footnote-84123026
Ref: Build<29>-Footnote-94123091
Ref: Build<29>-Footnote-104123156
Ref: Build<29>-Footnote-114123222
Ref: Build<29>-Footnote-124123288
Ref: Build<29>-Footnote-134123354
Ref: Build<29>-Footnote-144123420
Ref: Build<29>-Footnote-154123486
Node: Windows<26>4123552
Ref: whatsnew/changelog id2484123657
Ref: 17f24123657
Ref: Windows<26>-Footnote-14124212
Ref: Windows<26>-Footnote-24124277
Ref: Windows<26>-Footnote-34124342
Node: macOS<21>4124407
Ref: whatsnew/changelog id2494124511
Ref: 17f34124511
Ref: macOS<21>-Footnote-14124772
Node: IDLE<18>4124837
Ref: whatsnew/changelog id2504124939
Ref: 17f44124939
Ref: IDLE<18>-Footnote-14125092
Node: C API<28>4125157
Ref: whatsnew/changelog id2514125241
Ref: 17f54125241
Ref: C API<28>-Footnote-14128967
Ref: C API<28>-Footnote-24129032
Ref: C API<28>-Footnote-34129097
Ref: C API<28>-Footnote-44129162
Ref: C API<28>-Footnote-54129227
Ref: C API<28>-Footnote-64129292
Ref: C API<28>-Footnote-74129357
Ref: C API<28>-Footnote-84129422
Ref: C API<28>-Footnote-94129487
Ref: C API<28>-Footnote-104129552
Ref: C API<28>-Footnote-114129618
Ref: C API<28>-Footnote-124129684
Ref: C API<28>-Footnote-134129750
Ref: C API<28>-Footnote-144129816
Node: Python 3 11 0 alpha 14129882
Ref: whatsnew/changelog python-3-11-0-alpha-14130011
Ref: 17f64130011
Node: Security<17>4130394
Ref: whatsnew/changelog id2524130494
Ref: 17f74130494
Ref: Security<17>-Footnote-14131849
Ref: Security<17>-Footnote-24131914
Ref: Security<17>-Footnote-34131979
Ref: Security<17>-Footnote-44132044
Ref: Security<17>-Footnote-54132109
Ref: Security<17>-Footnote-64132164
Ref: Security<17>-Footnote-74132229
Node: Core and Builtins<31>4132294
Ref: whatsnew/changelog id2534132414
Ref: 17f94132414
Ref: Core and Builtins<31>-Footnote-14156111
Ref: Core and Builtins<31>-Footnote-24156176
Ref: Core and Builtins<31>-Footnote-34156241
Ref: Core and Builtins<31>-Footnote-44156306
Ref: Core and Builtins<31>-Footnote-54156371
Ref: Core and Builtins<31>-Footnote-64156436
Ref: Core and Builtins<31>-Footnote-74156501
Ref: Core and Builtins<31>-Footnote-84156566
Ref: Core and Builtins<31>-Footnote-94156631
Ref: Core and Builtins<31>-Footnote-104156696
Ref: Core and Builtins<31>-Footnote-114156762
Ref: Core and Builtins<31>-Footnote-124156828
Ref: Core and Builtins<31>-Footnote-134156894
Ref: Core and Builtins<31>-Footnote-144156962
Ref: Core and Builtins<31>-Footnote-154157028
Ref: Core and Builtins<31>-Footnote-164157094
Ref: Core and Builtins<31>-Footnote-174157160
Ref: Core and Builtins<31>-Footnote-184157226
Ref: Core and Builtins<31>-Footnote-194157292
Ref: Core and Builtins<31>-Footnote-204157358
Ref: Core and Builtins<31>-Footnote-214157424
Ref: Core and Builtins<31>-Footnote-224157490
Ref: Core and Builtins<31>-Footnote-234157556
Ref: Core and Builtins<31>-Footnote-244157622
Ref: Core and Builtins<31>-Footnote-254157688
Ref: Core and Builtins<31>-Footnote-264157754
Ref: Core and Builtins<31>-Footnote-274157820
Ref: Core and Builtins<31>-Footnote-284157886
Ref: Core and Builtins<31>-Footnote-294157952
Ref: Core and Builtins<31>-Footnote-304158018
Ref: Core and Builtins<31>-Footnote-314158084
Ref: Core and Builtins<31>-Footnote-324158150
Ref: Core and Builtins<31>-Footnote-334158216
Ref: Core and Builtins<31>-Footnote-344158282
Ref: Core and Builtins<31>-Footnote-354158348
Ref: Core and Builtins<31>-Footnote-364158414
Ref: Core and Builtins<31>-Footnote-374158480
Ref: Core and Builtins<31>-Footnote-384158546
Ref: Core and Builtins<31>-Footnote-394158612
Ref: Core and Builtins<31>-Footnote-404158678
Ref: Core and Builtins<31>-Footnote-414158744
Ref: Core and Builtins<31>-Footnote-424158810
Ref: Core and Builtins<31>-Footnote-434158876
Ref: Core and Builtins<31>-Footnote-444158942
Ref: Core and Builtins<31>-Footnote-454159008
Ref: Core and Builtins<31>-Footnote-464159074
Ref: Core and Builtins<31>-Footnote-474159140
Ref: Core and Builtins<31>-Footnote-484159206
Ref: Core and Builtins<31>-Footnote-494159272
Ref: Core and Builtins<31>-Footnote-504159338
Ref: Core and Builtins<31>-Footnote-514159404
Ref: Core and Builtins<31>-Footnote-524159470
Ref: Core and Builtins<31>-Footnote-534159536
Ref: Core and Builtins<31>-Footnote-544159602
Ref: Core and Builtins<31>-Footnote-554159668
Ref: Core and Builtins<31>-Footnote-564159734
Ref: Core and Builtins<31>-Footnote-574159800
Ref: Core and Builtins<31>-Footnote-584159866
Ref: Core and Builtins<31>-Footnote-594159932
Ref: Core and Builtins<31>-Footnote-604159998
Ref: Core and Builtins<31>-Footnote-614160064
Ref: Core and Builtins<31>-Footnote-624160130
Ref: Core and Builtins<31>-Footnote-634160196
Ref: Core and Builtins<31>-Footnote-644160262
Ref: Core and Builtins<31>-Footnote-654160328
Ref: Core and Builtins<31>-Footnote-664160394
Ref: Core and Builtins<31>-Footnote-674160460
Ref: Core and Builtins<31>-Footnote-684160526
Ref: Core and Builtins<31>-Footnote-694160592
Ref: Core and Builtins<31>-Footnote-704160658
Ref: Core and Builtins<31>-Footnote-714160724
Ref: Core and Builtins<31>-Footnote-724160790
Ref: Core and Builtins<31>-Footnote-734160856
Ref: Core and Builtins<31>-Footnote-744160922
Ref: Core and Builtins<31>-Footnote-754160988
Ref: Core and Builtins<31>-Footnote-764161031
Ref: Core and Builtins<31>-Footnote-774161097
Ref: Core and Builtins<31>-Footnote-784161163
Ref: Core and Builtins<31>-Footnote-794161229
Ref: Core and Builtins<31>-Footnote-804161272
Ref: Core and Builtins<31>-Footnote-814161338
Ref: Core and Builtins<31>-Footnote-824161404
Ref: Core and Builtins<31>-Footnote-834161470
Ref: Core and Builtins<31>-Footnote-844161536
Ref: Core and Builtins<31>-Footnote-854161602
Ref: Core and Builtins<31>-Footnote-864161668
Ref: Core and Builtins<31>-Footnote-874161734
Ref: Core and Builtins<31>-Footnote-884161800
Ref: Core and Builtins<31>-Footnote-894161866
Ref: Core and Builtins<31>-Footnote-904161932
Ref: Core and Builtins<31>-Footnote-914161998
Ref: Core and Builtins<31>-Footnote-924162064
Ref: Core and Builtins<31>-Footnote-934162130
Ref: Core and Builtins<31>-Footnote-944162196
Ref: Core and Builtins<31>-Footnote-954162262
Ref: Core and Builtins<31>-Footnote-964162328
Ref: Core and Builtins<31>-Footnote-974162394
Ref: Core and Builtins<31>-Footnote-984162460
Ref: Core and Builtins<31>-Footnote-994162526
Ref: Core and Builtins<31>-Footnote-1004162592
Ref: Core and Builtins<31>-Footnote-1014162659
Ref: Core and Builtins<31>-Footnote-1024162726
Ref: Core and Builtins<31>-Footnote-1034162793
Ref: Core and Builtins<31>-Footnote-1044162860
Ref: Core and Builtins<31>-Footnote-1054162927
Ref: Core and Builtins<31>-Footnote-1064162994
Ref: Core and Builtins<31>-Footnote-1074163061
Ref: Core and Builtins<31>-Footnote-1084163128
Ref: Core and Builtins<31>-Footnote-1094163195
Ref: Core and Builtins<31>-Footnote-1104163262
Ref: Core and Builtins<31>-Footnote-1114163329
Ref: Core and Builtins<31>-Footnote-1124163396
Ref: Core and Builtins<31>-Footnote-1134163463
Ref: Core and Builtins<31>-Footnote-1144163530
Ref: Core and Builtins<31>-Footnote-1154163597
Ref: Core and Builtins<31>-Footnote-1164163664
Ref: Core and Builtins<31>-Footnote-1174163731
Ref: Core and Builtins<31>-Footnote-1184163798
Ref: Core and Builtins<31>-Footnote-1194163865
Ref: Core and Builtins<31>-Footnote-1204163932
Ref: Core and Builtins<31>-Footnote-1214163999
Ref: Core and Builtins<31>-Footnote-1224164066
Ref: Core and Builtins<31>-Footnote-1234164133
Ref: Core and Builtins<31>-Footnote-1244164200
Ref: Core and Builtins<31>-Footnote-1254164267
Ref: Core and Builtins<31>-Footnote-1264164334
Ref: Core and Builtins<31>-Footnote-1274164401
Ref: Core and Builtins<31>-Footnote-1284164468
Ref: Core and Builtins<31>-Footnote-1294164535
Ref: Core and Builtins<31>-Footnote-1304164602
Node: Library<30>4164669
Ref: whatsnew/changelog id2544164794
Ref: 17fe4164794
Ref: Library<30>-Footnote-14204536
Ref: Library<30>-Footnote-24204601
Ref: Library<30>-Footnote-34204666
Ref: Library<30>-Footnote-44204731
Ref: Library<30>-Footnote-54204798
Ref: Library<30>-Footnote-64204863
Ref: Library<30>-Footnote-74204928
Ref: Library<30>-Footnote-84204993
Ref: Library<30>-Footnote-94205058
Ref: Library<30>-Footnote-104205123
Ref: Library<30>-Footnote-114205189
Ref: Library<30>-Footnote-124205255
Ref: Library<30>-Footnote-134205321
Ref: Library<30>-Footnote-144205387
Ref: Library<30>-Footnote-154205453
Ref: Library<30>-Footnote-164205519
Ref: Library<30>-Footnote-174205585
Ref: Library<30>-Footnote-184205651
Ref: Library<30>-Footnote-194205717
Ref: Library<30>-Footnote-204205783
Ref: Library<30>-Footnote-214205849
Ref: Library<30>-Footnote-224205915
Ref: Library<30>-Footnote-234205981
Ref: Library<30>-Footnote-244206047
Ref: Library<30>-Footnote-254206113
Ref: Library<30>-Footnote-264206179
Ref: Library<30>-Footnote-274206245
Ref: Library<30>-Footnote-284206311
Ref: Library<30>-Footnote-294206377
Ref: Library<30>-Footnote-304206443
Ref: Library<30>-Footnote-314206509
Ref: Library<30>-Footnote-324206575
Ref: Library<30>-Footnote-334206641
Ref: Library<30>-Footnote-344206707
Ref: Library<30>-Footnote-354206773
Ref: Library<30>-Footnote-364206816
Ref: Library<30>-Footnote-374206882
Ref: Library<30>-Footnote-384206948
Ref: Library<30>-Footnote-394207014
Ref: Library<30>-Footnote-404207080
Ref: Library<30>-Footnote-414207146
Ref: Library<30>-Footnote-424207212
Ref: Library<30>-Footnote-434207278
Ref: Library<30>-Footnote-444207344
Ref: Library<30>-Footnote-454207410
Ref: Library<30>-Footnote-464207476
Ref: Library<30>-Footnote-474207542
Ref: Library<30>-Footnote-484207608
Ref: Library<30>-Footnote-494207674
Ref: Library<30>-Footnote-504207740
Ref: Library<30>-Footnote-514207806
Ref: Library<30>-Footnote-524207872
Ref: Library<30>-Footnote-534207938
Ref: Library<30>-Footnote-544208004
Ref: Library<30>-Footnote-554208070
Ref: Library<30>-Footnote-564208136
Ref: Library<30>-Footnote-574208202
Ref: Library<30>-Footnote-584208268
Ref: Library<30>-Footnote-594208334
Ref: Library<30>-Footnote-604208400
Ref: Library<30>-Footnote-614208466
Ref: Library<30>-Footnote-624208532
Ref: Library<30>-Footnote-634208598
Ref: Library<30>-Footnote-644208664
Ref: Library<30>-Footnote-654208730
Ref: Library<30>-Footnote-664208796
Ref: Library<30>-Footnote-674208862
Ref: Library<30>-Footnote-684208928
Ref: Library<30>-Footnote-694208994
Ref: Library<30>-Footnote-704209060
Ref: Library<30>-Footnote-714209126
Ref: Library<30>-Footnote-724209192
Ref: Library<30>-Footnote-734209258
Ref: Library<30>-Footnote-744209324
Ref: Library<30>-Footnote-754209390
Ref: Library<30>-Footnote-764209456
Ref: Library<30>-Footnote-774209522
Ref: Library<30>-Footnote-784209588
Ref: Library<30>-Footnote-794209654
Ref: Library<30>-Footnote-804209720
Ref: Library<30>-Footnote-814209786
Ref: Library<30>-Footnote-824209852
Ref: Library<30>-Footnote-834209918
Ref: Library<30>-Footnote-844209984
Ref: Library<30>-Footnote-854210050
Ref: Library<30>-Footnote-864210116
Ref: Library<30>-Footnote-874210182
Ref: Library<30>-Footnote-884210248
Ref: Library<30>-Footnote-894210314
Ref: Library<30>-Footnote-904210380
Ref: Library<30>-Footnote-914210446
Ref: Library<30>-Footnote-924210512
Ref: Library<30>-Footnote-934210578
Ref: Library<30>-Footnote-944210644
Ref: Library<30>-Footnote-954210710
Ref: Library<30>-Footnote-964210776
Ref: Library<30>-Footnote-974210842
Ref: Library<30>-Footnote-984210908
Ref: Library<30>-Footnote-994210974
Ref: Library<30>-Footnote-1004211040
Ref: Library<30>-Footnote-1014211107
Ref: Library<30>-Footnote-1024211174
Ref: Library<30>-Footnote-1034211241
Ref: Library<30>-Footnote-1044211308
Ref: Library<30>-Footnote-1054211375
Ref: Library<30>-Footnote-1064211442
Ref: Library<30>-Footnote-1074211509
Ref: Library<30>-Footnote-1084211576
Ref: Library<30>-Footnote-1094211643
Ref: Library<30>-Footnote-1104211710
Ref: Library<30>-Footnote-1114211777
Ref: Library<30>-Footnote-1124211844
Ref: Library<30>-Footnote-1134211911
Ref: Library<30>-Footnote-1144211978
Ref: Library<30>-Footnote-1154212045
Ref: Library<30>-Footnote-1164212112
Ref: Library<30>-Footnote-1174212179
Ref: Library<30>-Footnote-1184212246
Ref: Library<30>-Footnote-1194212313
Ref: Library<30>-Footnote-1204212380
Ref: Library<30>-Footnote-1214212447
Ref: Library<30>-Footnote-1224212514
Ref: Library<30>-Footnote-1234212581
Ref: Library<30>-Footnote-1244212648
Ref: Library<30>-Footnote-1254212715
Ref: Library<30>-Footnote-1264212782
Ref: Library<30>-Footnote-1274212849
Ref: Library<30>-Footnote-1284212916
Ref: Library<30>-Footnote-1294212983
Ref: Library<30>-Footnote-1304213050
Ref: Library<30>-Footnote-1314213117
Ref: Library<30>-Footnote-1324213184
Ref: Library<30>-Footnote-1334213251
Ref: Library<30>-Footnote-1344213318
Ref: Library<30>-Footnote-1354213385
Ref: Library<30>-Footnote-1364213452
Ref: Library<30>-Footnote-1374213519
Ref: Library<30>-Footnote-1384213586
Ref: Library<30>-Footnote-1394213653
Ref: Library<30>-Footnote-1404213720
Ref: Library<30>-Footnote-1414213787
Ref: Library<30>-Footnote-1424213854
Ref: Library<30>-Footnote-1434213921
Ref: Library<30>-Footnote-1444213988
Ref: Library<30>-Footnote-1454214055
Ref: Library<30>-Footnote-1464214122
Ref: Library<30>-Footnote-1474214189
Ref: Library<30>-Footnote-1484214255
Ref: Library<30>-Footnote-1494214322
Ref: Library<30>-Footnote-1504214389
Ref: Library<30>-Footnote-1514214450
Ref: Library<30>-Footnote-1524214517
Ref: Library<30>-Footnote-1534214584
Ref: Library<30>-Footnote-1544214651
Ref: Library<30>-Footnote-1554214718
Ref: Library<30>-Footnote-1564214785
Ref: Library<30>-Footnote-1574214852
Ref: Library<30>-Footnote-1584214919
Ref: Library<30>-Footnote-1594214986
Ref: Library<30>-Footnote-1604215030
Ref: Library<30>-Footnote-1614215097
Ref: Library<30>-Footnote-1624215164
Ref: Library<30>-Footnote-1634215231
Ref: Library<30>-Footnote-1644215298
Ref: Library<30>-Footnote-1654215365
Ref: Library<30>-Footnote-1664215432
Ref: Library<30>-Footnote-1674215499
Ref: Library<30>-Footnote-1684215566
Ref: Library<30>-Footnote-1694215633
Ref: Library<30>-Footnote-1704215700
Ref: Library<30>-Footnote-1714215767
Ref: Library<30>-Footnote-1724215834
Ref: Library<30>-Footnote-1734215901
Ref: Library<30>-Footnote-1744215968
Ref: Library<30>-Footnote-1754216035
Ref: Library<30>-Footnote-1764216102
Ref: Library<30>-Footnote-1774216169
Ref: Library<30>-Footnote-1784216236
Ref: Library<30>-Footnote-1794216303
Ref: Library<30>-Footnote-1804216370
Ref: Library<30>-Footnote-1814216437
Ref: Library<30>-Footnote-1824216504
Ref: Library<30>-Footnote-1834216571
Ref: Library<30>-Footnote-1844216638
Ref: Library<30>-Footnote-1854216705
Ref: Library<30>-Footnote-1864216772
Ref: Library<30>-Footnote-1874216839
Ref: Library<30>-Footnote-1884216906
Ref: Library<30>-Footnote-1894216973
Ref: Library<30>-Footnote-1904217040
Ref: Library<30>-Footnote-1914217107
Ref: Library<30>-Footnote-1924217174
Ref: Library<30>-Footnote-1934217241
Ref: Library<30>-Footnote-1944217308
Ref: Library<30>-Footnote-1954217375
Ref: Library<30>-Footnote-1964217441
Ref: Library<30>-Footnote-1974217508
Ref: Library<30>-Footnote-1984217575
Ref: Library<30>-Footnote-1994217642
Ref: Library<30>-Footnote-2004217709
Ref: Library<30>-Footnote-2014217776
Ref: Library<30>-Footnote-2024217843
Ref: Library<30>-Footnote-2034217910
Ref: Library<30>-Footnote-2044217977
Ref: Library<30>-Footnote-2054218044
Ref: Library<30>-Footnote-2064218111
Ref: Library<30>-Footnote-2074218178
Ref: Library<30>-Footnote-2084218245
Ref: Library<30>-Footnote-2094218312
Node: Documentation<25>4218379
Ref: whatsnew/changelog id2554218492
Ref: 18154218492
Ref: Documentation<25>-Footnote-14224777
Ref: Documentation<25>-Footnote-24224842
Ref: Documentation<25>-Footnote-34224907
Ref: Documentation<25>-Footnote-44224972
Ref: Documentation<25>-Footnote-54225037
Ref: Documentation<25>-Footnote-64225102
Ref: Documentation<25>-Footnote-74225154
Ref: Documentation<25>-Footnote-84225219
Ref: Documentation<25>-Footnote-94225284
Ref: Documentation<25>-Footnote-104225343
Ref: Documentation<25>-Footnote-114225409
Ref: Documentation<25>-Footnote-124225475
Ref: Documentation<25>-Footnote-134225541
Ref: Documentation<25>-Footnote-144225607
Ref: Documentation<25>-Footnote-154225673
Ref: Documentation<25>-Footnote-164225739
Ref: Documentation<25>-Footnote-174225805
Ref: Documentation<25>-Footnote-184225871
Ref: Documentation<25>-Footnote-194225937
Ref: Documentation<25>-Footnote-204226003
Ref: Documentation<25>-Footnote-214226069
Ref: Documentation<25>-Footnote-224226135
Ref: Documentation<25>-Footnote-234226201
Ref: Documentation<25>-Footnote-244226267
Ref: Documentation<25>-Footnote-254226333
Ref: Documentation<25>-Footnote-264226399
Ref: Documentation<25>-Footnote-274226465
Ref: Documentation<25>-Footnote-284226531
Ref: Documentation<25>-Footnote-294226597
Ref: Documentation<25>-Footnote-304226663
Ref: Documentation<25>-Footnote-314226729
Ref: Documentation<25>-Footnote-324226795
Ref: Documentation<25>-Footnote-334226861
Ref: Documentation<25>-Footnote-344226927
Ref: Documentation<25>-Footnote-354226993
Ref: Documentation<25>-Footnote-364227059
Ref: Documentation<25>-Footnote-374227125
Ref: Documentation<25>-Footnote-384227191
Ref: Documentation<25>-Footnote-394227257
Ref: Documentation<25>-Footnote-404227323
Ref: Documentation<25>-Footnote-414227389
Ref: Documentation<25>-Footnote-424227455
Node: Tests<28>4227521
Ref: whatsnew/changelog id2564227632
Ref: 18174227632
Ref: Tests<28>-Footnote-14233478
Ref: Tests<28>-Footnote-24233543
Ref: Tests<28>-Footnote-34233608
Ref: Tests<28>-Footnote-44233673
Ref: Tests<28>-Footnote-54233738
Ref: Tests<28>-Footnote-64233803
Ref: Tests<28>-Footnote-74233868
Ref: Tests<28>-Footnote-84233933
Ref: Tests<28>-Footnote-94233998
Ref: Tests<28>-Footnote-104234063
Ref: Tests<28>-Footnote-114234129
Ref: Tests<28>-Footnote-124234195
Ref: Tests<28>-Footnote-134234261
Ref: Tests<28>-Footnote-144234327
Ref: Tests<28>-Footnote-154234393
Ref: Tests<28>-Footnote-164234459
Ref: Tests<28>-Footnote-174234525
Ref: Tests<28>-Footnote-184234591
Ref: Tests<28>-Footnote-194234657
Ref: Tests<28>-Footnote-204234723
Ref: Tests<28>-Footnote-214234789
Ref: Tests<28>-Footnote-224234855
Ref: Tests<28>-Footnote-234234921
Ref: Tests<28>-Footnote-244234987
Ref: Tests<28>-Footnote-254235053
Ref: Tests<28>-Footnote-264235119
Ref: Tests<28>-Footnote-274235185
Ref: Tests<28>-Footnote-284235251
Ref: Tests<28>-Footnote-294235317
Ref: Tests<28>-Footnote-304235383
Ref: Tests<28>-Footnote-314235449
Ref: Tests<28>-Footnote-324235515
Ref: Tests<28>-Footnote-334235581
Ref: Tests<28>-Footnote-344235647
Ref: Tests<28>-Footnote-354235713
Node: Build<30>4235779
Ref: whatsnew/changelog id2574235884
Ref: 181a4235884
Ref: Build<30>-Footnote-14237955
Ref: Build<30>-Footnote-24238020
Ref: Build<30>-Footnote-34238085
Ref: Build<30>-Footnote-44238150
Ref: Build<30>-Footnote-54238215
Ref: Build<30>-Footnote-64238280
Ref: Build<30>-Footnote-74238345
Ref: Build<30>-Footnote-84238410
Ref: Build<30>-Footnote-94238475
Ref: Build<30>-Footnote-104238540
Ref: Build<30>-Footnote-114238606
Node: Windows<27>4238672
Ref: whatsnew/changelog id2584238777
Ref: 181b4238777
Ref: Windows<27>-Footnote-14239885
Ref: Windows<27>-Footnote-24239950
Ref: Windows<27>-Footnote-34240015
Ref: Windows<27>-Footnote-44240080
Ref: Windows<27>-Footnote-54240145
Ref: Windows<27>-Footnote-64240210
Ref: Windows<27>-Footnote-74240275
Ref: Windows<27>-Footnote-84240340
Ref: Windows<27>-Footnote-94240405
Node: macOS<22>4240470
Ref: whatsnew/changelog id2594240574
Ref: 181d4240574
Ref: macOS<22>-Footnote-14241719
Ref: macOS<22>-Footnote-24241784
Ref: macOS<22>-Footnote-34241849
Ref: macOS<22>-Footnote-44241914
Ref: macOS<22>-Footnote-54241979
Ref: macOS<22>-Footnote-64242044
Ref: macOS<22>-Footnote-74242109
Node: IDLE<19>4242174
Ref: whatsnew/changelog id2604242282
Ref: 181e4242282
Ref: IDLE<19>-Footnote-14243807
Ref: IDLE<19>-Footnote-24243872
Ref: IDLE<19>-Footnote-34243937
Ref: IDLE<19>-Footnote-44244002
Ref: IDLE<19>-Footnote-54244067
Ref: IDLE<19>-Footnote-64244132
Ref: IDLE<19>-Footnote-74244197
Ref: IDLE<19>-Footnote-84244262
Ref: IDLE<19>-Footnote-94244327
Node: Tools/Demos<14>4244392
Ref: whatsnew/changelog id2614244500
Ref: 181f4244500
Ref: Tools/Demos<14>-Footnote-14245296
Ref: Tools/Demos<14>-Footnote-24245361
Ref: Tools/Demos<14>-Footnote-34245426
Ref: Tools/Demos<14>-Footnote-44245491
Ref: Tools/Demos<14>-Footnote-54245556
Ref: Tools/Demos<14>-Footnote-64245621
Node: C API<29>4245686
Ref: whatsnew/changelog id2624245777
Ref: 18204245777
Ref: C API<29>-Footnote-14251616
Ref: C API<29>-Footnote-24251681
Ref: C API<29>-Footnote-34251746
Ref: C API<29>-Footnote-44251811
Ref: C API<29>-Footnote-54251876
Ref: C API<29>-Footnote-64251941
Ref: C API<29>-Footnote-74252006
Ref: C API<29>-Footnote-84252071
Ref: C API<29>-Footnote-94252136
Ref: C API<29>-Footnote-104252201
Ref: C API<29>-Footnote-114252267
Ref: C API<29>-Footnote-124252333
Ref: C API<29>-Footnote-134252399
Ref: C API<29>-Footnote-144252465
Ref: C API<29>-Footnote-154252531
Ref: C API<29>-Footnote-164252597
Ref: C API<29>-Footnote-174252663
Ref: C API<29>-Footnote-184252729
Ref: C API<29>-Footnote-194252795
Ref: C API<29>-Footnote-204252861
Ref: C API<29>-Footnote-214252904
Ref: C API<29>-Footnote-224252970
Ref: C API<29>-Footnote-234253036
Ref: C API<29>-Footnote-244253102
Ref: C API<29>-Footnote-254253145
Ref: C API<29>-Footnote-264253188
Node: Python 3 10 0 beta 14253254
Ref: whatsnew/changelog python-3-10-0-beta-14253383
Ref: 18234253383
Node: Security<18>4253732
Ref: whatsnew/changelog id2634253831
Ref: 18244253831
Ref: Security<18>-Footnote-14256764
Ref: Security<18>-Footnote-24256829
Ref: Security<18>-Footnote-34256894
Ref: Security<18>-Footnote-44256959
Ref: Security<18>-Footnote-54257024
Ref: Security<18>-Footnote-64257089
Ref: Security<18>-Footnote-74257154
Ref: Security<18>-Footnote-84257219
Ref: Security<18>-Footnote-94257284
Ref: Security<18>-Footnote-104257349
Ref: Security<18>-Footnote-114257415
Node: Core and Builtins<32>4257481
Ref: whatsnew/changelog id2644257600
Ref: 18274257600
Ref: Core and Builtins<32>-Footnote-14263759
Ref: Core and Builtins<32>-Footnote-24263824
Ref: Core and Builtins<32>-Footnote-34263889
Ref: Core and Builtins<32>-Footnote-44263954
Ref: Core and Builtins<32>-Footnote-54264019
Ref: Core and Builtins<32>-Footnote-64264084
Ref: Core and Builtins<32>-Footnote-74264149
Ref: Core and Builtins<32>-Footnote-84264214
Ref: Core and Builtins<32>-Footnote-94264279
Ref: Core and Builtins<32>-Footnote-104264344
Ref: Core and Builtins<32>-Footnote-114264410
Ref: Core and Builtins<32>-Footnote-124264476
Ref: Core and Builtins<32>-Footnote-134264542
Ref: Core and Builtins<32>-Footnote-144264608
Ref: Core and Builtins<32>-Footnote-154264651
Ref: Core and Builtins<32>-Footnote-164264717
Ref: Core and Builtins<32>-Footnote-174264783
Ref: Core and Builtins<32>-Footnote-184264849
Ref: Core and Builtins<32>-Footnote-194264915
Ref: Core and Builtins<32>-Footnote-204264981
Ref: Core and Builtins<32>-Footnote-214265047
Ref: Core and Builtins<32>-Footnote-224265113
Ref: Core and Builtins<32>-Footnote-234265179
Ref: Core and Builtins<32>-Footnote-244265245
Ref: Core and Builtins<32>-Footnote-254265311
Ref: Core and Builtins<32>-Footnote-264265377
Ref: Core and Builtins<32>-Footnote-274265443
Ref: Core and Builtins<32>-Footnote-284265509
Ref: Core and Builtins<32>-Footnote-294265575
Ref: Core and Builtins<32>-Footnote-304265641
Ref: Core and Builtins<32>-Footnote-314265707
Ref: Core and Builtins<32>-Footnote-324265773
Ref: Core and Builtins<32>-Footnote-334265839
Ref: Core and Builtins<32>-Footnote-344265905
Ref: Core and Builtins<32>-Footnote-354265971
Node: Library<31>4266037
Ref: whatsnew/changelog id2654266161
Ref: 182b4266161
Ref: Library<31>-Footnote-14282919
Ref: Library<31>-Footnote-24282984
Ref: Library<31>-Footnote-34283049
Ref: Library<31>-Footnote-44283114
Ref: Library<31>-Footnote-54283179
Ref: Library<31>-Footnote-64283244
Ref: Library<31>-Footnote-74283309
Ref: Library<31>-Footnote-84283374
Ref: Library<31>-Footnote-94283439
Ref: Library<31>-Footnote-104283504
Ref: Library<31>-Footnote-114283570
Ref: Library<31>-Footnote-124283636
Ref: Library<31>-Footnote-134283702
Ref: Library<31>-Footnote-144283768
Ref: Library<31>-Footnote-154283834
Ref: Library<31>-Footnote-164283900
Ref: Library<31>-Footnote-174283966
Ref: Library<31>-Footnote-184284032
Ref: Library<31>-Footnote-194284098
Ref: Library<31>-Footnote-204284164
Ref: Library<31>-Footnote-214284230
Ref: Library<31>-Footnote-224284296
Ref: Library<31>-Footnote-234284339
Ref: Library<31>-Footnote-244284405
Ref: Library<31>-Footnote-254284471
Ref: Library<31>-Footnote-264284537
Ref: Library<31>-Footnote-274284603
Ref: Library<31>-Footnote-284284669
Ref: Library<31>-Footnote-294284735
Ref: Library<31>-Footnote-304284801
Ref: Library<31>-Footnote-314284867
Ref: Library<31>-Footnote-324284933
Ref: Library<31>-Footnote-334284999
Ref: Library<31>-Footnote-344285065
Ref: Library<31>-Footnote-354285131
Ref: Library<31>-Footnote-364285197
Ref: Library<31>-Footnote-374285263
Ref: Library<31>-Footnote-384285329
Ref: Library<31>-Footnote-394285395
Ref: Library<31>-Footnote-404285461
Ref: Library<31>-Footnote-414285527
Ref: Library<31>-Footnote-424285593
Ref: Library<31>-Footnote-434285636
Ref: Library<31>-Footnote-444285702
Ref: Library<31>-Footnote-454285768
Ref: Library<31>-Footnote-464285834
Ref: Library<31>-Footnote-474285900
Ref: Library<31>-Footnote-484285966
Ref: Library<31>-Footnote-494286032
Ref: Library<31>-Footnote-504286098
Ref: Library<31>-Footnote-514286164
Ref: Library<31>-Footnote-524286230
Ref: Library<31>-Footnote-534286295
Ref: Library<31>-Footnote-544286361
Ref: Library<31>-Footnote-554286427
Ref: Library<31>-Footnote-564286493
Ref: Library<31>-Footnote-574286558
Ref: Library<31>-Footnote-584286624
Ref: Library<31>-Footnote-594286690
Ref: Library<31>-Footnote-604286756
Ref: Library<31>-Footnote-614286822
Ref: Library<31>-Footnote-624286888
Ref: Library<31>-Footnote-634286954
Ref: Library<31>-Footnote-644287020
Ref: Library<31>-Footnote-654287086
Ref: Library<31>-Footnote-664287152
Ref: Library<31>-Footnote-674287218
Ref: Library<31>-Footnote-684287261
Ref: Library<31>-Footnote-694287327
Ref: Library<31>-Footnote-704287393
Ref: Library<31>-Footnote-714287459
Ref: Library<31>-Footnote-724287525
Ref: Library<31>-Footnote-734287591
Ref: Library<31>-Footnote-744287657
Ref: Library<31>-Footnote-754287723
Ref: Library<31>-Footnote-764287789
Ref: Library<31>-Footnote-774287855
Ref: Library<31>-Footnote-784287921
Ref: Library<31>-Footnote-794287987
Ref: Library<31>-Footnote-804288053
Ref: Library<31>-Footnote-814288119
Ref: Library<31>-Footnote-824288185
Node: Documentation<26>4288251
Ref: whatsnew/changelog id2664288363
Ref: 18324288363
Ref: Documentation<26>-Footnote-14289371
Ref: Documentation<26>-Footnote-24289436
Ref: Documentation<26>-Footnote-34289501
Ref: Documentation<26>-Footnote-44289566
Ref: Documentation<26>-Footnote-54289631
Ref: Documentation<26>-Footnote-64289696
Ref: Documentation<26>-Footnote-74289761
Node: Tests<29>4289826
Ref: whatsnew/changelog id2674289936
Ref: 18334289936
Ref: Tests<29>-Footnote-14291013
Ref: Tests<29>-Footnote-24291078
Ref: Tests<29>-Footnote-34291143
Ref: Tests<29>-Footnote-44291208
Ref: Tests<29>-Footnote-54291273
Node: Build<31>4291338
Ref: whatsnew/changelog id2684291442
Ref: 18344291442
Ref: Build<31>-Footnote-14291702
Ref: Build<31>-Footnote-24291767
Ref: Build<31>-Footnote-34291832
Node: Windows<28>4291874
Ref: whatsnew/changelog id2694291978
Ref: 18354291978
Ref: Windows<28>-Footnote-14293319
Ref: Windows<28>-Footnote-24293384
Ref: Windows<28>-Footnote-34293449
Ref: Windows<28>-Footnote-44293514
Ref: Windows<28>-Footnote-54293579
Ref: Windows<28>-Footnote-64293644
Ref: Windows<28>-Footnote-74293709
Ref: Windows<28>-Footnote-84293774
Ref: Windows<28>-Footnote-94293839
Node: macOS<23>4293904
Ref: whatsnew/changelog id2704294007
Ref: 18394294007
Ref: macOS<23>-Footnote-14295305
Ref: macOS<23>-Footnote-24295370
Ref: macOS<23>-Footnote-34295435
Ref: macOS<23>-Footnote-44295500
Ref: macOS<23>-Footnote-54295565
Ref: macOS<23>-Footnote-64295630
Node: IDLE<20>4295695
Ref: whatsnew/changelog id2714295796
Ref: 183a4295796
Ref: IDLE<20>-Footnote-14296590
Ref: IDLE<20>-Footnote-24296655
Ref: IDLE<20>-Footnote-34296720
Ref: IDLE<20>-Footnote-44296785
Ref: IDLE<20>-Footnote-54296850
Node: C API<30>4296915
Ref: whatsnew/changelog id2724296998
Ref: 183b4296998
Ref: C API<30>-Footnote-14299246
Ref: C API<30>-Footnote-24299311
Ref: C API<30>-Footnote-34299376
Ref: C API<30>-Footnote-44299441
Ref: C API<30>-Footnote-54299506
Ref: C API<30>-Footnote-64299571
Ref: C API<30>-Footnote-74299636
Ref: C API<30>-Footnote-84299701
Ref: C API<30>-Footnote-94299766
Ref: C API<30>-Footnote-104299808
Node: Python 3 10 0 alpha 74299874
Ref: whatsnew/changelog python-3-10-0-alpha-74300003
Ref: 183c4300003
Node: Security<19>4300334
Ref: whatsnew/changelog id2734300434
Ref: 183d4300434
Ref: Security<19>-Footnote-14301518
Ref: Security<19>-Footnote-24301583
Ref: Security<19>-Footnote-34301638
Ref: Security<19>-Footnote-44301703
Node: Core and Builtins<33>4301768
Ref: whatsnew/changelog id2744301888
Ref: 183e4301888
Ref: Core and Builtins<33>-Footnote-14306404
Ref: Core and Builtins<33>-Footnote-24306469
Ref: Core and Builtins<33>-Footnote-34306534
Ref: Core and Builtins<33>-Footnote-44306599
Ref: Core and Builtins<33>-Footnote-54306664
Ref: Core and Builtins<33>-Footnote-64306729
Ref: Core and Builtins<33>-Footnote-74306794
Ref: Core and Builtins<33>-Footnote-84306859
Ref: Core and Builtins<33>-Footnote-94306924
Ref: Core and Builtins<33>-Footnote-104306966
Ref: Core and Builtins<33>-Footnote-114307032
Ref: Core and Builtins<33>-Footnote-124307098
Ref: Core and Builtins<33>-Footnote-134307164
Ref: Core and Builtins<33>-Footnote-144307230
Ref: Core and Builtins<33>-Footnote-154307296
Ref: Core and Builtins<33>-Footnote-164307362
Ref: Core and Builtins<33>-Footnote-174307428
Ref: Core and Builtins<33>-Footnote-184307494
Ref: Core and Builtins<33>-Footnote-194307560
Ref: Core and Builtins<33>-Footnote-204307626
Ref: Core and Builtins<33>-Footnote-214307692
Ref: Core and Builtins<33>-Footnote-224307758
Ref: Core and Builtins<33>-Footnote-234307801
Ref: Core and Builtins<33>-Footnote-244307867
Node: Library<32>4307933
Ref: whatsnew/changelog id2754308058
Ref: 183f4308058
Ref: Library<32>-Footnote-14315727
Ref: Library<32>-Footnote-24315792
Ref: Library<32>-Footnote-34315857
Ref: Library<32>-Footnote-44315922
Ref: Library<32>-Footnote-54315987
Ref: Library<32>-Footnote-64316052
Ref: Library<32>-Footnote-74316117
Ref: Library<32>-Footnote-84316182
Ref: Library<32>-Footnote-94316247
Ref: Library<32>-Footnote-104316312
Ref: Library<32>-Footnote-114316378
Ref: Library<32>-Footnote-124316444
Ref: Library<32>-Footnote-134316510
Ref: Library<32>-Footnote-144316576
Ref: Library<32>-Footnote-154316642
Ref: Library<32>-Footnote-164316685
Ref: Library<32>-Footnote-174316751
Ref: Library<32>-Footnote-184316817
Ref: Library<32>-Footnote-194316883
Ref: Library<32>-Footnote-204316949
Ref: Library<32>-Footnote-214317015
Ref: Library<32>-Footnote-224317081
Ref: Library<32>-Footnote-234317147
Ref: Library<32>-Footnote-244317213
Ref: Library<32>-Footnote-254317279
Ref: Library<32>-Footnote-264317361
Ref: Library<32>-Footnote-274317427
Ref: Library<32>-Footnote-284317493
Ref: Library<32>-Footnote-294317559
Ref: Library<32>-Footnote-304317625
Ref: Library<32>-Footnote-314317691
Ref: Library<32>-Footnote-324317757
Ref: Library<32>-Footnote-334317823
Ref: Library<32>-Footnote-344317889
Ref: Library<32>-Footnote-354317955
Ref: Library<32>-Footnote-364318021
Ref: Library<32>-Footnote-374318087
Ref: Library<32>-Footnote-384318153
Ref: Library<32>-Footnote-394318219
Ref: Library<32>-Footnote-404318285
Ref: Library<32>-Footnote-414318351
Ref: Library<32>-Footnote-424318417
Ref: Library<32>-Footnote-434318483
Ref: Library<32>-Footnote-444318549
Ref: Library<32>-Footnote-454318615
Node: Documentation<27>4318681
Ref: whatsnew/changelog id2764318794
Ref: 18474318794
Ref: Documentation<27>-Footnote-14319488
Ref: Documentation<27>-Footnote-24319553
Ref: Documentation<27>-Footnote-34319618
Ref: Documentation<27>-Footnote-44319683
Node: Tests<30>4319748
Ref: whatsnew/changelog id2774319859
Ref: 18484319859
Ref: Tests<30>-Footnote-14320162
Ref: Tests<30>-Footnote-24320227
Node: Build<32>4320292
Ref: whatsnew/changelog id2784320397
Ref: 18494320397
Ref: Build<32>-Footnote-14321368
Ref: Build<32>-Footnote-24321433
Ref: Build<32>-Footnote-34321498
Ref: Build<32>-Footnote-44321563
Ref: Build<32>-Footnote-54321628
Ref: Build<32>-Footnote-64321693
Node: Windows<29>4321758
Ref: whatsnew/changelog id2794321862
Ref: 184a4321862
Ref: Windows<29>-Footnote-14322052
Node: IDLE<21>4322117
Ref: whatsnew/changelog id2804322221
Ref: 184b4322221
Ref: IDLE<21>-Footnote-14322462
Node: C API<31>4322527
Ref: whatsnew/changelog id2814322611
Ref: 184c4322611
Ref: C API<31>-Footnote-14326075
Ref: C API<31>-Footnote-24326140
Ref: C API<31>-Footnote-34326205
Ref: C API<31>-Footnote-44326270
Ref: C API<31>-Footnote-54326335
Ref: C API<31>-Footnote-64326400
Ref: C API<31>-Footnote-74326465
Ref: C API<31>-Footnote-84326530
Ref: C API<31>-Footnote-94326595
Node: Python 3 10 0 alpha 64326637
Ref: whatsnew/changelog python-3-10-0-alpha-64326767
Ref: 184d4326767
Node: Security<20>4327118
Ref: whatsnew/changelog id2824327218
Ref: 184e4327218
Ref: Security<20>-Footnote-14327464
Node: Core and Builtins<34>4327529
Ref: whatsnew/changelog id2834327649
Ref: 184f4327649
Ref: Core and Builtins<34>-Footnote-14331078
Ref: Core and Builtins<34>-Footnote-24331143
Ref: Core and Builtins<34>-Footnote-34331208
Ref: Core and Builtins<34>-Footnote-44331250
Ref: Core and Builtins<34>-Footnote-54331315
Ref: Core and Builtins<34>-Footnote-64331380
Ref: Core and Builtins<34>-Footnote-74331445
Ref: Core and Builtins<34>-Footnote-84331510
Ref: Core and Builtins<34>-Footnote-94331575
Ref: Core and Builtins<34>-Footnote-104331640
Ref: Core and Builtins<34>-Footnote-114331706
Ref: Core and Builtins<34>-Footnote-124331772
Ref: Core and Builtins<34>-Footnote-134331838
Ref: Core and Builtins<34>-Footnote-144331904
Ref: Core and Builtins<34>-Footnote-154331947
Ref: Core and Builtins<34>-Footnote-164332013
Node: Library<33>4332079
Ref: whatsnew/changelog id2844332204
Ref: 18504332204
Ref: Library<33>-Footnote-14335039
Ref: Library<33>-Footnote-24335104
Ref: Library<33>-Footnote-34335169
Ref: Library<33>-Footnote-44335234
Ref: Library<33>-Footnote-54335299
Ref: Library<33>-Footnote-64335364
Ref: Library<33>-Footnote-74335429
Ref: Library<33>-Footnote-84335494
Ref: Library<33>-Footnote-94335559
Ref: Library<33>-Footnote-104335624
Ref: Library<33>-Footnote-114335690
Ref: Library<33>-Footnote-124335756
Ref: Library<33>-Footnote-134335822
Ref: Library<33>-Footnote-144335888
Ref: Library<33>-Footnote-154335954
Ref: Library<33>-Footnote-164336020
Node: Documentation<28>4336086
Ref: whatsnew/changelog id2854336199
Ref: 18544336199
Ref: Documentation<28>-Footnote-14336541
Ref: Documentation<28>-Footnote-24336606
Ref: Documentation<28>-Footnote-34336671
Node: Tests<31>4336713
Ref: whatsnew/changelog id2864336824
Ref: 18554336824
Ref: Tests<31>-Footnote-14337015
Node: Build<33>4337080
Ref: whatsnew/changelog id2874337185
Ref: 18564337185
Ref: Build<33>-Footnote-14338250
Ref: Build<33>-Footnote-24338315
Ref: Build<33>-Footnote-34338380
Ref: Build<33>-Footnote-44338445
Ref: Build<33>-Footnote-54338510
Node: Windows<30>4338575
Ref: whatsnew/changelog id2884338680
Ref: 18574338680
Ref: Windows<30>-Footnote-14338844
Node: macOS<24>4338909
Ref: whatsnew/changelog id2894339013
Ref: 18594339013
Ref: macOS<24>-Footnote-14339154
Node: IDLE<22>4339219
Ref: whatsnew/changelog id2904339321
Ref: 185a4339321
Ref: IDLE<22>-Footnote-14339589
Node: C API<32>4339654
Ref: whatsnew/changelog id2914339738
Ref: 185b4339738
Ref: C API<32>-Footnote-14341488
Ref: C API<32>-Footnote-24341553
Ref: C API<32>-Footnote-34341618
Ref: C API<32>-Footnote-44341683
Ref: C API<32>-Footnote-54341748
Ref: C API<32>-Footnote-64341813
Ref: C API<32>-Footnote-74341878
Ref: C API<32>-Footnote-84341943
Ref: C API<32>-Footnote-94342008
Node: Python 3 10 0 alpha 54342073
Ref: whatsnew/changelog python-3-10-0-alpha-54342203
Ref: 18634342203
Node: Security<21>4342554
Ref: whatsnew/changelog id2924342654
Ref: 18644342654
Ref: Security<21>-Footnote-14342876
Node: Core and Builtins<35>4342941
Ref: whatsnew/changelog id2934343061
Ref: 18674343061
Ref: Core and Builtins<35>-Footnote-14345588
Ref: Core and Builtins<35>-Footnote-24345653
Ref: Core and Builtins<35>-Footnote-34345718
Ref: Core and Builtins<35>-Footnote-44345783
Ref: Core and Builtins<35>-Footnote-54345848
Ref: Core and Builtins<35>-Footnote-64345913
Ref: Core and Builtins<35>-Footnote-74345978
Ref: Core and Builtins<35>-Footnote-84346043
Ref: Core and Builtins<35>-Footnote-94346108
Ref: Core and Builtins<35>-Footnote-104346173
Ref: Core and Builtins<35>-Footnote-114346239
Ref: Core and Builtins<35>-Footnote-124346305
Ref: Core and Builtins<35>-Footnote-134346371
Ref: Core and Builtins<35>-Footnote-144346437
Ref: Core and Builtins<35>-Footnote-154346503
Node: Library<34>4346569
Ref: whatsnew/changelog id2944346694
Ref: 18684346694
Ref: Library<34>-Footnote-14351626
Ref: Library<34>-Footnote-24351691
Ref: Library<34>-Footnote-34351756
Ref: Library<34>-Footnote-44351821
Ref: Library<34>-Footnote-54351886
Ref: Library<34>-Footnote-64351951
Ref: Library<34>-Footnote-74352016
Ref: Library<34>-Footnote-84352081
Ref: Library<34>-Footnote-94352146
Ref: Library<34>-Footnote-104352211
Ref: Library<34>-Footnote-114352277
Ref: Library<34>-Footnote-124352343
Ref: Library<34>-Footnote-134352409
Ref: Library<34>-Footnote-144352475
Ref: Library<34>-Footnote-154352541
Ref: Library<34>-Footnote-164352607
Ref: Library<34>-Footnote-174352673
Ref: Library<34>-Footnote-184352739
Ref: Library<34>-Footnote-194352782
Ref: Library<34>-Footnote-204352848
Ref: Library<34>-Footnote-214352914
Ref: Library<34>-Footnote-224352980
Ref: Library<34>-Footnote-234353046
Ref: Library<34>-Footnote-244353114
Ref: Library<34>-Footnote-254353157
Ref: Library<34>-Footnote-264353223
Ref: Library<34>-Footnote-274353289
Ref: Library<34>-Footnote-284353355
Ref: Library<34>-Footnote-294353421
Ref: Library<34>-Footnote-304353487
Ref: Library<34>-Footnote-314353553
Ref: Library<34>-Footnote-324353619
Ref: Library<34>-Footnote-334353685
Ref: Library<34>-Footnote-344353751
Node: Documentation<29>4353817
Ref: whatsnew/changelog id2954353930
Ref: 18694353930
Ref: Documentation<29>-Footnote-14354258
Ref: Documentation<29>-Footnote-24354323
Node: Tests<32>4354388
Ref: whatsnew/changelog id2964354499
Ref: 186a4354499
Ref: Tests<32>-Footnote-14354855
Ref: Tests<32>-Footnote-24354920
Node: Build<34>4354985
Ref: whatsnew/changelog id2974355090
Ref: 186b4355090
Ref: Build<34>-Footnote-14356283
Ref: Build<34>-Footnote-24356348
Ref: Build<34>-Footnote-34356413
Ref: Build<34>-Footnote-44356478
Ref: Build<34>-Footnote-54356543
Node: Windows<31>4356608
Ref: whatsnew/changelog id2984356713
Ref: 186c4356713
Ref: Windows<31>-Footnote-14356926
Ref: Windows<31>-Footnote-24356991
Node: macOS<25>4357056
Ref: whatsnew/changelog id2994357160
Ref: 186d4357160
Ref: macOS<25>-Footnote-14357407
Node: IDLE<23>4357472
Ref: whatsnew/changelog id3004357574
Ref: 186e4357574
Ref: IDLE<23>-Footnote-14358136
Ref: IDLE<23>-Footnote-24358201
Ref: IDLE<23>-Footnote-34358266
Ref: IDLE<23>-Footnote-44358331
Node: C API<33>4358396
Ref: whatsnew/changelog id3014358480
Ref: 186f4358480
Ref: C API<33>-Footnote-14359086
Ref: C API<33>-Footnote-24359151
Node: Python 3 10 0 alpha 44359216
Ref: whatsnew/changelog python-3-10-0-alpha-44359346
Ref: 18714359346
Node: Core and Builtins<36>4359661
Ref: whatsnew/changelog id3024359760
Ref: 18724359760
Ref: Core and Builtins<36>-Footnote-14363174
Ref: Core and Builtins<36>-Footnote-24363239
Ref: Core and Builtins<36>-Footnote-34363304
Ref: Core and Builtins<36>-Footnote-44363369
Ref: Core and Builtins<36>-Footnote-54363434
Ref: Core and Builtins<36>-Footnote-64363499
Ref: Core and Builtins<36>-Footnote-74363564
Ref: Core and Builtins<36>-Footnote-84363629
Ref: Core and Builtins<36>-Footnote-94363694
Ref: Core and Builtins<36>-Footnote-104363759
Ref: Core and Builtins<36>-Footnote-114363825
Ref: Core and Builtins<36>-Footnote-124363891
Ref: Core and Builtins<36>-Footnote-134363957
Ref: Core and Builtins<36>-Footnote-144364023
Ref: Core and Builtins<36>-Footnote-154364066
Ref: Core and Builtins<36>-Footnote-164364132
Ref: Core and Builtins<36>-Footnote-174364198
Ref: Core and Builtins<36>-Footnote-184364264
Ref: Core and Builtins<36>-Footnote-194364332
Ref: Core and Builtins<36>-Footnote-204364375
Ref: Core and Builtins<36>-Footnote-214364441
Node: Library<35>4364507
Ref: whatsnew/changelog id3034364632
Ref: 18744364632
Ref: Library<35>-Footnote-14373447
Ref: Library<35>-Footnote-24373512
Ref: Library<35>-Footnote-34373577
Ref: Library<35>-Footnote-44373642
Ref: Library<35>-Footnote-54373707
Ref: Library<35>-Footnote-64373772
Ref: Library<35>-Footnote-74373837
Ref: Library<35>-Footnote-84373879
Ref: Library<35>-Footnote-94373921
Ref: Library<35>-Footnote-104373986
Ref: Library<35>-Footnote-114374052
Ref: Library<35>-Footnote-124374118
Ref: Library<35>-Footnote-134374184
Ref: Library<35>-Footnote-144374250
Ref: Library<35>-Footnote-154374316
Ref: Library<35>-Footnote-164374382
Ref: Library<35>-Footnote-174374448
Ref: Library<35>-Footnote-184374514
Ref: Library<35>-Footnote-194374579
Ref: Library<35>-Footnote-204374647
Ref: Library<35>-Footnote-214374690
Ref: Library<35>-Footnote-224374756
Ref: Library<35>-Footnote-234374822
Ref: Library<35>-Footnote-244374888
Ref: Library<35>-Footnote-254374954
Ref: Library<35>-Footnote-264375020
Ref: Library<35>-Footnote-274375086
Ref: Library<35>-Footnote-284375152
Ref: Library<35>-Footnote-294375218
Ref: Library<35>-Footnote-304375284
Ref: Library<35>-Footnote-314375350
Ref: Library<35>-Footnote-324375416
Ref: Library<35>-Footnote-334375459
Ref: Library<35>-Footnote-344375525
Ref: Library<35>-Footnote-354375591
Ref: Library<35>-Footnote-364375657
Ref: Library<35>-Footnote-374375723
Ref: Library<35>-Footnote-384375789
Ref: Library<35>-Footnote-394375855
Ref: Library<35>-Footnote-404375921
Ref: Library<35>-Footnote-414375987
Ref: Library<35>-Footnote-424376053
Ref: Library<35>-Footnote-434376119
Ref: Library<35>-Footnote-444376185
Ref: Library<35>-Footnote-454376251
Ref: Library<35>-Footnote-464376317
Ref: Library<35>-Footnote-474376383
Ref: Library<35>-Footnote-484376451
Ref: Library<35>-Footnote-494376494
Ref: Library<35>-Footnote-504376560
Ref: Library<35>-Footnote-514376626
Ref: Library<35>-Footnote-524376692
Ref: Library<35>-Footnote-534376758
Ref: Library<35>-Footnote-544376824
Ref: Library<35>-Footnote-554376890
Ref: Library<35>-Footnote-564376956
Ref: Library<35>-Footnote-574377022
Ref: Library<35>-Footnote-584377088
Node: Documentation<30>4377154
Ref: whatsnew/changelog id3044377267
Ref: 187a4377267
Ref: Documentation<30>-Footnote-14377583
Ref: Documentation<30>-Footnote-24377648
Node: Tests<33>4377713
Ref: whatsnew/changelog id3054377824
Ref: 187c4377824
Ref: Tests<33>-Footnote-14378601
Ref: Tests<33>-Footnote-24378666
Ref: Tests<33>-Footnote-34378731
Ref: Tests<33>-Footnote-44378796
Ref: Tests<33>-Footnote-54378861
Ref: Tests<33>-Footnote-64378926
Ref: Tests<33>-Footnote-74378991
Ref: Tests<33>-Footnote-84379056
Node: Build<35>4379121
Ref: whatsnew/changelog id3064379224
Ref: 187d4379224
Ref: Build<35>-Footnote-14380189
Ref: Build<35>-Footnote-24380254
Ref: Build<35>-Footnote-34380319
Ref: Build<35>-Footnote-44380384
Ref: Build<35>-Footnote-54380449
Ref: Build<35>-Footnote-64380514
Node: macOS<26>4380579
Ref: whatsnew/changelog id3074380688
Ref: 187e4380688
Ref: macOS<26>-Footnote-14381006
Ref: macOS<26>-Footnote-24381071
Ref: macOS<26>-Footnote-34381136
Node: Tools/Demos<15>4381201
Ref: whatsnew/changelog id3084381310
Ref: 187f4381310
Ref: Tools/Demos<15>-Footnote-14381634
Ref: Tools/Demos<15>-Footnote-24381699
Node: C API<34>4381764
Ref: whatsnew/changelog id3094381855
Ref: 18804381855
Ref: C API<34>-Footnote-14382696
Ref: C API<34>-Footnote-24382761
Ref: C API<34>-Footnote-34382826
Ref: C API<34>-Footnote-44382893
Ref: C API<34>-Footnote-54382958
Node: Python 3 10 0 alpha 34383023
Ref: whatsnew/changelog python-3-10-0-alpha-34383153
Ref: 18814383153
Node: Security<22>4383536
Ref: whatsnew/changelog id3104383636
Ref: 18824383636
Ref: Security<22>-Footnote-14383876
Node: Core and Builtins<37>4383941
Ref: whatsnew/changelog id3114384061
Ref: 18834384061
Ref: Core and Builtins<37>-Footnote-14388358
Ref: Core and Builtins<37>-Footnote-24388423
Ref: Core and Builtins<37>-Footnote-34388488
Ref: Core and Builtins<37>-Footnote-44388553
Ref: Core and Builtins<37>-Footnote-54388618
Ref: Core and Builtins<37>-Footnote-64388683
Ref: Core and Builtins<37>-Footnote-74388750
Ref: Core and Builtins<37>-Footnote-84388792
Ref: Core and Builtins<37>-Footnote-94388857
Ref: Core and Builtins<37>-Footnote-104388922
Ref: Core and Builtins<37>-Footnote-114388988
Ref: Core and Builtins<37>-Footnote-124389054
Ref: Core and Builtins<37>-Footnote-134389120
Ref: Core and Builtins<37>-Footnote-144389186
Ref: Core and Builtins<37>-Footnote-154389252
Ref: Core and Builtins<37>-Footnote-164389318
Ref: Core and Builtins<37>-Footnote-174389384
Ref: Core and Builtins<37>-Footnote-184389450
Ref: Core and Builtins<37>-Footnote-194389516
Ref: Core and Builtins<37>-Footnote-204389582
Ref: Core and Builtins<37>-Footnote-214389648
Ref: Core and Builtins<37>-Footnote-224389714
Ref: Core and Builtins<37>-Footnote-234389780
Node: Library<36>4389846
Ref: whatsnew/changelog id3124389971
Ref: 18864389971
Ref: Library<36>-Footnote-14401030
Ref: Library<36>-Footnote-24401094
Ref: Library<36>-Footnote-34401159
Ref: Library<36>-Footnote-44401224
Ref: Library<36>-Footnote-54401289
Ref: Library<36>-Footnote-64401354
Ref: Library<36>-Footnote-74401419
Ref: Library<36>-Footnote-84401484
Ref: Library<36>-Footnote-94401549
Ref: Library<36>-Footnote-104401614
Ref: Library<36>-Footnote-114401680
Ref: Library<36>-Footnote-124401746
Ref: Library<36>-Footnote-134401812
Ref: Library<36>-Footnote-144401878
Ref: Library<36>-Footnote-154401944
Ref: Library<36>-Footnote-164402010
Ref: Library<36>-Footnote-174402076
Ref: Library<36>-Footnote-184402142
Ref: Library<36>-Footnote-194402208
Ref: Library<36>-Footnote-204402274
Ref: Library<36>-Footnote-214402340
Ref: Library<36>-Footnote-224402406
Ref: Library<36>-Footnote-234402472
Ref: Library<36>-Footnote-244402540
Ref: Library<36>-Footnote-254402606
Ref: Library<36>-Footnote-264402672
Ref: Library<36>-Footnote-274402715
Ref: Library<36>-Footnote-284402781
Ref: Library<36>-Footnote-294402847
Ref: Library<36>-Footnote-304402913
Ref: Library<36>-Footnote-314402979
Ref: Library<36>-Footnote-324403045
Ref: Library<36>-Footnote-334403111
Ref: Library<36>-Footnote-344403177
Ref: Library<36>-Footnote-354403243
Ref: Library<36>-Footnote-364403309
Ref: Library<36>-Footnote-374403375
Ref: Library<36>-Footnote-384403441
Ref: Library<36>-Footnote-394403507
Ref: Library<36>-Footnote-404403573
Ref: Library<36>-Footnote-414403639
Ref: Library<36>-Footnote-424403705
Ref: Library<36>-Footnote-434403771
Ref: Library<36>-Footnote-444403837
Ref: Library<36>-Footnote-454403903
Ref: Library<36>-Footnote-464403969
Ref: Library<36>-Footnote-474404035
Ref: Library<36>-Footnote-484404101
Ref: Library<36>-Footnote-494404167
Ref: Library<36>-Footnote-504404233
Ref: Library<36>-Footnote-514404299
Ref: Library<36>-Footnote-524404365
Ref: Library<36>-Footnote-534404431
Ref: Library<36>-Footnote-544404497
Ref: Library<36>-Footnote-554404563
Ref: Library<36>-Footnote-564404629
Ref: Library<36>-Footnote-574404695
Ref: Library<36>-Footnote-584404761
Ref: Library<36>-Footnote-594404827
Ref: Library<36>-Footnote-604404893
Ref: Library<36>-Footnote-614404959
Ref: Library<36>-Footnote-624405025
Ref: Library<36>-Footnote-634405091
Ref: Library<36>-Footnote-644405157
Ref: Library<36>-Footnote-654405223
Node: Documentation<31>4405289
Ref: whatsnew/changelog id3134405402
Ref: 188b4405402
Ref: Documentation<31>-Footnote-14405868
Ref: Documentation<31>-Footnote-24405933
Ref: Documentation<31>-Footnote-34405998
Node: Tests<34>4406063
Ref: whatsnew/changelog id3144406174
Ref: 188c4406174
Ref: Tests<34>-Footnote-14407380
Ref: Tests<34>-Footnote-24407445
Ref: Tests<34>-Footnote-34407510
Ref: Tests<34>-Footnote-44407575
Ref: Tests<34>-Footnote-54407640
Ref: Tests<34>-Footnote-64407705
Ref: Tests<34>-Footnote-74407770
Ref: Tests<34>-Footnote-84407835
Ref: Tests<34>-Footnote-94407900
Ref: Tests<34>-Footnote-104407965
Ref: Tests<34>-Footnote-114408031
Ref: Tests<34>-Footnote-124408097
Node: Build<36>4408163
Ref: whatsnew/changelog id3154408268
Ref: 188d4408268
Ref: Build<36>-Footnote-14409405
Ref: Build<36>-Footnote-24409470
Ref: Build<36>-Footnote-34409535
Ref: Build<36>-Footnote-44409600
Ref: Build<36>-Footnote-54409665
Ref: Build<36>-Footnote-64409730
Ref: Build<36>-Footnote-74409795
Node: Windows<32>4409860
Ref: whatsnew/changelog id3164409965
Ref: 188e4409965
Ref: Windows<32>-Footnote-14410257
Ref: Windows<32>-Footnote-24410322
Node: macOS<27>4410387
Ref: whatsnew/changelog id3174410491
Ref: 188f4410491
Ref: macOS<27>-Footnote-14411427
Ref: macOS<27>-Footnote-24411492
Ref: macOS<27>-Footnote-34411557
Ref: macOS<27>-Footnote-44411622
Ref: macOS<27>-Footnote-54411687
Node: IDLE<24>4411752
Ref: whatsnew/changelog id3184411860
Ref: 18904411860
Ref: IDLE<24>-Footnote-14412280
Ref: IDLE<24>-Footnote-24412345
Ref: IDLE<24>-Footnote-34412410
Node: Tools/Demos<16>4412475
Ref: whatsnew/changelog id3194412583
Ref: 18914412583
Ref: Tools/Demos<16>-Footnote-14412985
Ref: Tools/Demos<16>-Footnote-24413050
Node: C API<35>4413115
Ref: whatsnew/changelog id3204413206
Ref: 18924413206
Ref: C API<35>-Footnote-14417976
Ref: C API<35>-Footnote-24418041
Ref: C API<35>-Footnote-34418108
Ref: C API<35>-Footnote-44418150
Ref: C API<35>-Footnote-54418217
Ref: C API<35>-Footnote-64418259
Ref: C API<35>-Footnote-74418326
Ref: C API<35>-Footnote-84418368
Ref: C API<35>-Footnote-94418435
Ref: C API<35>-Footnote-104418477
Ref: C API<35>-Footnote-114418545
Ref: C API<35>-Footnote-124418588
Ref: C API<35>-Footnote-134418656
Ref: C API<35>-Footnote-144418699
Ref: C API<35>-Footnote-154418767
Ref: C API<35>-Footnote-164418810
Ref: C API<35>-Footnote-174418876
Ref: C API<35>-Footnote-184418944
Ref: C API<35>-Footnote-194418987
Ref: C API<35>-Footnote-204419055
Ref: C API<35>-Footnote-214419098
Ref: C API<35>-Footnote-224419166
Ref: C API<35>-Footnote-234419209
Ref: C API<35>-Footnote-244419277
Ref: C API<35>-Footnote-254419320
Ref: C API<35>-Footnote-264419386
Ref: C API<35>-Footnote-274419452
Ref: C API<35>-Footnote-284419518
Ref: C API<35>-Footnote-294419584
Ref: C API<35>-Footnote-304419650
Ref: C API<35>-Footnote-314419716
Ref: C API<35>-Footnote-324419782
Ref: C API<35>-Footnote-334419850
Ref: C API<35>-Footnote-344419916
Ref: C API<35>-Footnote-354419982
Ref: C API<35>-Footnote-364420048
Node: Python 3 10 0 alpha 24420114
Ref: whatsnew/changelog python-3-10-0-alpha-24420244
Ref: 18944420244
Node: Security<23>4420595
Ref: whatsnew/changelog id3214420695
Ref: 18954420695
Ref: Security<23>-Footnote-14421171
Ref: Security<23>-Footnote-24421236
Node: Core and Builtins<38>4421301
Ref: whatsnew/changelog id3224421421
Ref: 18964421421
Ref: Core and Builtins<38>-Footnote-14425229
Ref: Core and Builtins<38>-Footnote-24425294
Ref: Core and Builtins<38>-Footnote-34425359
Ref: Core and Builtins<38>-Footnote-44425424
Ref: Core and Builtins<38>-Footnote-54425489
Ref: Core and Builtins<38>-Footnote-64425554
Ref: Core and Builtins<38>-Footnote-74425619
Ref: Core and Builtins<38>-Footnote-84425684
Ref: Core and Builtins<38>-Footnote-94425749
Ref: Core and Builtins<38>-Footnote-104425814
Ref: Core and Builtins<38>-Footnote-114425880
Ref: Core and Builtins<38>-Footnote-124425946
Ref: Core and Builtins<38>-Footnote-134426012
Ref: Core and Builtins<38>-Footnote-144426078
Ref: Core and Builtins<38>-Footnote-154426144
Ref: Core and Builtins<38>-Footnote-164426210
Ref: Core and Builtins<38>-Footnote-174426276
Ref: Core and Builtins<38>-Footnote-184426342
Ref: Core and Builtins<38>-Footnote-194426408
Ref: Core and Builtins<38>-Footnote-204426474
Ref: Core and Builtins<38>-Footnote-214426540
Node: Library<37>4426583
Ref: whatsnew/changelog id3234426708
Ref: 18994426708
Ref: Library<37>-Footnote-14433724
Ref: Library<37>-Footnote-24433789
Ref: Library<37>-Footnote-34433854
Ref: Library<37>-Footnote-44433919
Ref: Library<37>-Footnote-54433984
Ref: Library<37>-Footnote-64434049
Ref: Library<37>-Footnote-74434114
Ref: Library<37>-Footnote-84434156
Ref: Library<37>-Footnote-94434221
Ref: Library<37>-Footnote-104434286
Ref: Library<37>-Footnote-114434352
Ref: Library<37>-Footnote-124434418
Ref: Library<37>-Footnote-134434484
Ref: Library<37>-Footnote-144434550
Ref: Library<37>-Footnote-154434616
Ref: Library<37>-Footnote-164434682
Ref: Library<37>-Footnote-174434748
Ref: Library<37>-Footnote-184434814
Ref: Library<37>-Footnote-194434880
Ref: Library<37>-Footnote-204434946
Ref: Library<37>-Footnote-214435012
Ref: Library<37>-Footnote-224435078
Ref: Library<37>-Footnote-234435144
Ref: Library<37>-Footnote-244435210
Ref: Library<37>-Footnote-254435276
Ref: Library<37>-Footnote-264435319
Ref: Library<37>-Footnote-274435385
Ref: Library<37>-Footnote-284435451
Ref: Library<37>-Footnote-294435517
Ref: Library<37>-Footnote-304435583
Ref: Library<37>-Footnote-314435649
Ref: Library<37>-Footnote-324435715
Ref: Library<37>-Footnote-334435781
Ref: Library<37>-Footnote-344435847
Ref: Library<37>-Footnote-354435913
Ref: Library<37>-Footnote-364435979
Ref: Library<37>-Footnote-374436044
Ref: Library<37>-Footnote-384436110
Ref: Library<37>-Footnote-394436176
Ref: Library<37>-Footnote-404436242
Ref: Library<37>-Footnote-414436308
Node: Documentation<32>4436374
Ref: whatsnew/changelog id3244436487
Ref: 189b4436487
Ref: Documentation<32>-Footnote-14437335
Ref: Documentation<32>-Footnote-24437400
Ref: Documentation<32>-Footnote-34437465
Ref: Documentation<32>-Footnote-44437530
Ref: Documentation<32>-Footnote-54437595
Ref: Documentation<32>-Footnote-64437660
Node: Tests<35>4437725
Ref: whatsnew/changelog id3254437836
Ref: 189e4437836
Ref: Tests<35>-Footnote-14438473
Ref: Tests<35>-Footnote-24438538
Ref: Tests<35>-Footnote-34438603
Ref: Tests<35>-Footnote-44438668
Node: Build<37>4438733
Ref: whatsnew/changelog id3264438838
Ref: 189f4438838
Ref: Build<37>-Footnote-14439102
Node: Windows<33>4439167
Ref: whatsnew/changelog id3274439272
Ref: 18a04439272
Ref: Windows<33>-Footnote-14439748
Ref: Windows<33>-Footnote-24439813
Ref: Windows<33>-Footnote-34439878
Ref: Windows<33>-Footnote-44439943
Ref: Windows<33>-Footnote-54440008
Node: macOS<28>4440073
Ref: whatsnew/changelog id3284440177
Ref: 18a14440177
Ref: macOS<28>-Footnote-14440327
Node: IDLE<25>4440392
Ref: whatsnew/changelog id3294440494
Ref: 18a24440494
Ref: IDLE<25>-Footnote-14441103
Ref: IDLE<25>-Footnote-24441168
Ref: IDLE<25>-Footnote-34441233
Node: C API<36>4441298
Ref: whatsnew/changelog id3304441382
Ref: 18a34441382
Ref: C API<36>-Footnote-14442715
Ref: C API<36>-Footnote-24442780
Ref: C API<36>-Footnote-34442845
Ref: C API<36>-Footnote-44442910
Ref: C API<36>-Footnote-54442975
Ref: C API<36>-Footnote-64443040
Ref: C API<36>-Footnote-74443105
Ref: C API<36>-Footnote-84443170
Node: Python 3 10 0 alpha 14443235
Ref: whatsnew/changelog python-3-10-0-alpha-14443363
Ref: 18a54443363
Node: Security<24>4443714
Ref: whatsnew/changelog id3314443814
Ref: 18a64443814
Ref: Security<24>-Footnote-14444717
Ref: Security<24>-Footnote-24444782
Ref: Security<24>-Footnote-34444847
Ref: Security<24>-Footnote-44444903
Ref: Security<24>-Footnote-54444968
Ref: Security<24>-Footnote-64445033
Ref: Security<24>-Footnote-74445089
Ref: Security<24>-Footnote-84445154
Node: Core and Builtins<39>4445219
Ref: whatsnew/changelog id3324445339
Ref: 18a74445339
Ref: Core and Builtins<39>-Footnote-14460835
Ref: Core and Builtins<39>-Footnote-24460900
Ref: Core and Builtins<39>-Footnote-34460965
Ref: Core and Builtins<39>-Footnote-44461007
Ref: Core and Builtins<39>-Footnote-54461072
Ref: Core and Builtins<39>-Footnote-64461137
Ref: Core and Builtins<39>-Footnote-74461179
Ref: Core and Builtins<39>-Footnote-84461246
Ref: Core and Builtins<39>-Footnote-94461288
Ref: Core and Builtins<39>-Footnote-104461353
Ref: Core and Builtins<39>-Footnote-114461419
Ref: Core and Builtins<39>-Footnote-124461487
Ref: Core and Builtins<39>-Footnote-134461530
Ref: Core and Builtins<39>-Footnote-144461598
Ref: Core and Builtins<39>-Footnote-154461641
Ref: Core and Builtins<39>-Footnote-164461709
Ref: Core and Builtins<39>-Footnote-174461752
Ref: Core and Builtins<39>-Footnote-184461820
Ref: Core and Builtins<39>-Footnote-194461863
Ref: Core and Builtins<39>-Footnote-204461931
Ref: Core and Builtins<39>-Footnote-214461997
Ref: Core and Builtins<39>-Footnote-224462065
Ref: Core and Builtins<39>-Footnote-234462108
Ref: Core and Builtins<39>-Footnote-244462176
Ref: Core and Builtins<39>-Footnote-254462219
Ref: Core and Builtins<39>-Footnote-264462287
Ref: Core and Builtins<39>-Footnote-274462330
Ref: Core and Builtins<39>-Footnote-284462396
Ref: Core and Builtins<39>-Footnote-294462462
Ref: Core and Builtins<39>-Footnote-304462528
Ref: Core and Builtins<39>-Footnote-314462594
Ref: Core and Builtins<39>-Footnote-324462662
Ref: Core and Builtins<39>-Footnote-334462705
Ref: Core and Builtins<39>-Footnote-344462771
Ref: Core and Builtins<39>-Footnote-354462837
Ref: Core and Builtins<39>-Footnote-364462905
Ref: Core and Builtins<39>-Footnote-374462973
Ref: Core and Builtins<39>-Footnote-384463016
Ref: Core and Builtins<39>-Footnote-394463082
Ref: Core and Builtins<39>-Footnote-404463148
Ref: Core and Builtins<39>-Footnote-414463214
Ref: Core and Builtins<39>-Footnote-424463282
Ref: Core and Builtins<39>-Footnote-434463325
Ref: Core and Builtins<39>-Footnote-444463391
Ref: Core and Builtins<39>-Footnote-454463457
Ref: Core and Builtins<39>-Footnote-464463523
Ref: Core and Builtins<39>-Footnote-474463589
Ref: Core and Builtins<39>-Footnote-484463655
Ref: Core and Builtins<39>-Footnote-494463721
Ref: Core and Builtins<39>-Footnote-504463787
Ref: Core and Builtins<39>-Footnote-514463853
Ref: Core and Builtins<39>-Footnote-524463919
Ref: Core and Builtins<39>-Footnote-534463985
Ref: Core and Builtins<39>-Footnote-544464053
Ref: Core and Builtins<39>-Footnote-554464121
Ref: Core and Builtins<39>-Footnote-564464187
Ref: Core and Builtins<39>-Footnote-574464253
Ref: Core and Builtins<39>-Footnote-584464321
Ref: Core and Builtins<39>-Footnote-594464389
Ref: Core and Builtins<39>-Footnote-604464455
Ref: Core and Builtins<39>-Footnote-614464521
Ref: Core and Builtins<39>-Footnote-624464587
Ref: Core and Builtins<39>-Footnote-634464653
Ref: Core and Builtins<39>-Footnote-644464719
Ref: Core and Builtins<39>-Footnote-654464785
Ref: Core and Builtins<39>-Footnote-664464851
Ref: Core and Builtins<39>-Footnote-674464917
Ref: Core and Builtins<39>-Footnote-684464983
Ref: Core and Builtins<39>-Footnote-694465049
Ref: Core and Builtins<39>-Footnote-704465115
Ref: Core and Builtins<39>-Footnote-714465181
Ref: Core and Builtins<39>-Footnote-724465247
Ref: Core and Builtins<39>-Footnote-734465313
Ref: Core and Builtins<39>-Footnote-744465379
Ref: Core and Builtins<39>-Footnote-754465445
Ref: Core and Builtins<39>-Footnote-764465488
Ref: Core and Builtins<39>-Footnote-774465556
Ref: Core and Builtins<39>-Footnote-784465622
Ref: Core and Builtins<39>-Footnote-794465688
Ref: Core and Builtins<39>-Footnote-804465756
Ref: Core and Builtins<39>-Footnote-814465822
Ref: Core and Builtins<39>-Footnote-824465888
Ref: Core and Builtins<39>-Footnote-834465931
Ref: Core and Builtins<39>-Footnote-844465997
Ref: Core and Builtins<39>-Footnote-854466063
Ref: Core and Builtins<39>-Footnote-864466129
Ref: Core and Builtins<39>-Footnote-874466195
Ref: Core and Builtins<39>-Footnote-884466261
Ref: Core and Builtins<39>-Footnote-894466327
Ref: Core and Builtins<39>-Footnote-904466393
Ref: Core and Builtins<39>-Footnote-914466459
Ref: Core and Builtins<39>-Footnote-924466525
Ref: Core and Builtins<39>-Footnote-934466591
Ref: Core and Builtins<39>-Footnote-944466657
Ref: Core and Builtins<39>-Footnote-954466723
Ref: Core and Builtins<39>-Footnote-964466791
Ref: Core and Builtins<39>-Footnote-974466857
Ref: Core and Builtins<39>-Footnote-984466923
Ref: Core and Builtins<39>-Footnote-994466989
Ref: Core and Builtins<39>-Footnote-1004467055
Ref: Core and Builtins<39>-Footnote-1014467122
Ref: Core and Builtins<39>-Footnote-1024467189
Ref: Core and Builtins<39>-Footnote-1034467256
Ref: Core and Builtins<39>-Footnote-1044467323
Ref: Core and Builtins<39>-Footnote-1054467390
Ref: Core and Builtins<39>-Footnote-1064467457
Ref: Core and Builtins<39>-Footnote-1074467524
Ref: Core and Builtins<39>-Footnote-1084467591
Ref: Core and Builtins<39>-Footnote-1094467657
Ref: Core and Builtins<39>-Footnote-1104467726
Ref: Core and Builtins<39>-Footnote-1114467795
Ref: Core and Builtins<39>-Footnote-1124467862
Ref: Core and Builtins<39>-Footnote-1134467929
Ref: Core and Builtins<39>-Footnote-1144467996
Ref: Core and Builtins<39>-Footnote-1154468063
Node: Library<38>4468130
Ref: whatsnew/changelog id3334468255
Ref: 18ac4468255
Ref: Library<38>-Footnote-14490396
Ref: Library<38>-Footnote-24490461
Ref: Library<38>-Footnote-34490526
Ref: Library<38>-Footnote-44490591
Ref: Library<38>-Footnote-54490656
Ref: Library<38>-Footnote-64490721
Ref: Library<38>-Footnote-74490786
Ref: Library<38>-Footnote-84490851
Ref: Library<38>-Footnote-94490916
Ref: Library<38>-Footnote-104490981
Ref: Library<38>-Footnote-114491047
Ref: Library<38>-Footnote-124491113
Ref: Library<38>-Footnote-134491179
Ref: Library<38>-Footnote-144491245
Ref: Library<38>-Footnote-154491311
Ref: Library<38>-Footnote-164491377
Ref: Library<38>-Footnote-174491430
Ref: Library<38>-Footnote-184491496
Ref: Library<38>-Footnote-194491562
Ref: Library<38>-Footnote-204491628
Ref: Library<38>-Footnote-214491696
Ref: Library<38>-Footnote-224491739
Ref: Library<38>-Footnote-234491807
Ref: Library<38>-Footnote-244491850
Ref: Library<38>-Footnote-254491916
Ref: Library<38>-Footnote-264491982
Ref: Library<38>-Footnote-274492048
Ref: Library<38>-Footnote-284492114
Ref: Library<38>-Footnote-294492180
Ref: Library<38>-Footnote-304492246
Ref: Library<38>-Footnote-314492312
Ref: Library<38>-Footnote-324492378
Ref: Library<38>-Footnote-334492444
Ref: Library<38>-Footnote-344492510
Ref: Library<38>-Footnote-354492576
Ref: Library<38>-Footnote-364492642
Ref: Library<38>-Footnote-374492708
Ref: Library<38>-Footnote-384492774
Ref: Library<38>-Footnote-394492840
Ref: Library<38>-Footnote-404492906
Ref: Library<38>-Footnote-414492972
Ref: Library<38>-Footnote-424493038
Ref: Library<38>-Footnote-434493104
Ref: Library<38>-Footnote-444493170
Ref: Library<38>-Footnote-454493236
Ref: Library<38>-Footnote-464493302
Ref: Library<38>-Footnote-474493368
Ref: Library<38>-Footnote-484493434
Ref: Library<38>-Footnote-494493500
Ref: Library<38>-Footnote-504493566
Ref: Library<38>-Footnote-514493632
Ref: Library<38>-Footnote-524493698
Ref: Library<38>-Footnote-534493764
Ref: Library<38>-Footnote-544493830
Ref: Library<38>-Footnote-554493896
Ref: Library<38>-Footnote-564493962
Ref: Library<38>-Footnote-574494028
Ref: Library<38>-Footnote-584494085
Ref: Library<38>-Footnote-594494151
Ref: Library<38>-Footnote-604494217
Ref: Library<38>-Footnote-614494283
Ref: Library<38>-Footnote-624494349
Ref: Library<38>-Footnote-634494415
Ref: Library<38>-Footnote-644494481
Ref: Library<38>-Footnote-654494547
Ref: Library<38>-Footnote-664494613
Ref: Library<38>-Footnote-674494679
Ref: Library<38>-Footnote-684494745
Ref: Library<38>-Footnote-694494811
Ref: Library<38>-Footnote-704494877
Ref: Library<38>-Footnote-714494943
Ref: Library<38>-Footnote-724495009
Ref: Library<38>-Footnote-734495075
Ref: Library<38>-Footnote-744495141
Ref: Library<38>-Footnote-754495207
Ref: Library<38>-Footnote-764495273
Ref: Library<38>-Footnote-774495339
Ref: Library<38>-Footnote-784495405
Ref: Library<38>-Footnote-794495471
Ref: Library<38>-Footnote-804495537
Ref: Library<38>-Footnote-814495603
Ref: Library<38>-Footnote-824495669
Ref: Library<38>-Footnote-834495735
Ref: Library<38>-Footnote-844495801
Ref: Library<38>-Footnote-854495867
Ref: Library<38>-Footnote-864495933
Ref: Library<38>-Footnote-874495999
Ref: Library<38>-Footnote-884496065
Ref: Library<38>-Footnote-894496131
Ref: Library<38>-Footnote-904496197
Ref: Library<38>-Footnote-914496263
Ref: Library<38>-Footnote-924496329
Ref: Library<38>-Footnote-934496395
Ref: Library<38>-Footnote-944496461
Ref: Library<38>-Footnote-954496527
Ref: Library<38>-Footnote-964496593
Ref: Library<38>-Footnote-974496659
Ref: Library<38>-Footnote-984496725
Ref: Library<38>-Footnote-994496791
Ref: Library<38>-Footnote-1004496857
Ref: Library<38>-Footnote-1014496924
Ref: Library<38>-Footnote-1024496991
Ref: Library<38>-Footnote-1034497058
Ref: Library<38>-Footnote-1044497125
Ref: Library<38>-Footnote-1054497192
Ref: Library<38>-Footnote-1064497259
Ref: Library<38>-Footnote-1074497326
Ref: Library<38>-Footnote-1084497393
Ref: Library<38>-Footnote-1094497460
Ref: Library<38>-Footnote-1104497527
Ref: Library<38>-Footnote-1114497594
Ref: Library<38>-Footnote-1124497661
Ref: Library<38>-Footnote-1134497728
Ref: Library<38>-Footnote-1144497795
Ref: Library<38>-Footnote-1154497862
Ref: Library<38>-Footnote-1164497929
Ref: Library<38>-Footnote-1174497996
Ref: Library<38>-Footnote-1184498063
Ref: Library<38>-Footnote-1194498130
Ref: Library<38>-Footnote-1204498197
Ref: Library<38>-Footnote-1214498263
Ref: Library<38>-Footnote-1224498330
Ref: Library<38>-Footnote-1234498397
Ref: Library<38>-Footnote-1244498464
Ref: Library<38>-Footnote-1254498531
Ref: Library<38>-Footnote-1264498575
Ref: Library<38>-Footnote-1274498642
Ref: Library<38>-Footnote-1284498709
Ref: Library<38>-Footnote-1294498776
Ref: Library<38>-Footnote-1304498843
Ref: Library<38>-Footnote-1314498910
Ref: Library<38>-Footnote-1324498977
Ref: Library<38>-Footnote-1334499044
Ref: Library<38>-Footnote-1344499111
Ref: Library<38>-Footnote-1354499178
Ref: Library<38>-Footnote-1364499245
Ref: Library<38>-Footnote-1374499312
Ref: Library<38>-Footnote-1384499379
Ref: Library<38>-Footnote-1394499446
Ref: Library<38>-Footnote-1404499513
Ref: Library<38>-Footnote-1414499580
Ref: Library<38>-Footnote-1424499647
Ref: Library<38>-Footnote-1434499714
Ref: Library<38>-Footnote-1444499781
Ref: Library<38>-Footnote-1454499848
Ref: Library<38>-Footnote-1464499915
Ref: Library<38>-Footnote-1474499982
Ref: Library<38>-Footnote-1484500049
Ref: Library<38>-Footnote-1494500116
Ref: Library<38>-Footnote-1504500183
Ref: Library<38>-Footnote-1514500250
Ref: Library<38>-Footnote-1524500317
Ref: Library<38>-Footnote-1534500384
Ref: Library<38>-Footnote-1544500451
Node: Documentation<33>4500518
Ref: whatsnew/changelog id3344500631
Ref: 18b34500631
Ref: Documentation<33>-Footnote-14502388
Ref: Documentation<33>-Footnote-24502453
Ref: Documentation<33>-Footnote-34502495
Ref: Documentation<33>-Footnote-44502560
Ref: Documentation<33>-Footnote-54502625
Ref: Documentation<33>-Footnote-64502690
Ref: Documentation<33>-Footnote-74502755
Ref: Documentation<33>-Footnote-84502820
Ref: Documentation<33>-Footnote-94502885
Ref: Documentation<33>-Footnote-104502950
Ref: Documentation<33>-Footnote-114503016
Ref: Documentation<33>-Footnote-124503082
Ref: Documentation<33>-Footnote-134503148
Ref: Documentation<33>-Footnote-144503214
Node: Tests<36>4503280
Ref: whatsnew/changelog id3354503391
Ref: 18b54503391
Ref: Tests<36>-Footnote-14505540
Ref: Tests<36>-Footnote-24505605
Ref: Tests<36>-Footnote-34505670
Ref: Tests<36>-Footnote-44505735
Ref: Tests<36>-Footnote-54505800
Ref: Tests<36>-Footnote-64505865
Ref: Tests<36>-Footnote-74505930
Ref: Tests<36>-Footnote-84505995
Ref: Tests<36>-Footnote-94506060
Ref: Tests<36>-Footnote-104506125
Ref: Tests<36>-Footnote-114506191
Ref: Tests<36>-Footnote-124506257
Ref: Tests<36>-Footnote-134506323
Ref: Tests<36>-Footnote-144506389
Ref: Tests<36>-Footnote-154506455
Ref: Tests<36>-Footnote-164506521
Node: Build<38>4506587
Ref: whatsnew/changelog id3364506692
Ref: 18b84506692
Ref: Build<38>-Footnote-14507611
Ref: Build<38>-Footnote-24507676
Ref: Build<38>-Footnote-34507741
Ref: Build<38>-Footnote-44507806
Ref: Build<38>-Footnote-54507871
Ref: Build<38>-Footnote-64507936
Node: Windows<34>4508001
Ref: whatsnew/changelog id3374508106
Ref: 18b94508106
Ref: Windows<34>-Footnote-14509869
Ref: Windows<34>-Footnote-24509934
Ref: Windows<34>-Footnote-34509999
Ref: Windows<34>-Footnote-44510064
Ref: Windows<34>-Footnote-54510129
Ref: Windows<34>-Footnote-64510194
Ref: Windows<34>-Footnote-74510259
Ref: Windows<34>-Footnote-84510324
Ref: Windows<34>-Footnote-94510389
Ref: Windows<34>-Footnote-104510454
Ref: Windows<34>-Footnote-114510520
Ref: Windows<34>-Footnote-124510586
Ref: Windows<34>-Footnote-134510652
Ref: Windows<34>-Footnote-144510718
Node: macOS<29>4510784
Ref: whatsnew/changelog id3384510888
Ref: 18ba4510888
Ref: macOS<29>-Footnote-14511777
Ref: macOS<29>-Footnote-24511842
Ref: macOS<29>-Footnote-34511907
Ref: macOS<29>-Footnote-44511972
Ref: macOS<29>-Footnote-54512037
Ref: macOS<29>-Footnote-64512102
Node: IDLE<26>4512167
Ref: whatsnew/changelog id3394512269
Ref: 18bb4512269
Ref: IDLE<26>-Footnote-14513424
Ref: IDLE<26>-Footnote-24513489
Ref: IDLE<26>-Footnote-34513554
Ref: IDLE<26>-Footnote-44513619
Ref: IDLE<26>-Footnote-54513684
Ref: IDLE<26>-Footnote-64513749
Ref: IDLE<26>-Footnote-74513814
Ref: IDLE<26>-Footnote-84513879
Ref: IDLE<26>-Footnote-94513944
Ref: IDLE<26>-Footnote-104514009
Ref: IDLE<26>-Footnote-114514075
Node: C API<37>4514141
Ref: whatsnew/changelog id3404514225
Ref: 18bc4514225
Ref: C API<37>-Footnote-14519334
Ref: C API<37>-Footnote-24519399
Ref: C API<37>-Footnote-34519464
Ref: C API<37>-Footnote-44519529
Ref: C API<37>-Footnote-54519594
Ref: C API<37>-Footnote-64519659
Ref: C API<37>-Footnote-74519724
Ref: C API<37>-Footnote-84519789
Ref: C API<37>-Footnote-94519854
Ref: C API<37>-Footnote-104519919
Ref: C API<37>-Footnote-114519985
Ref: C API<37>-Footnote-124520051
Ref: C API<37>-Footnote-134520117
Ref: C API<37>-Footnote-144520183
Ref: C API<37>-Footnote-154520249
Ref: C API<37>-Footnote-164520315
Ref: C API<37>-Footnote-174520381
Ref: C API<37>-Footnote-184520447
Ref: C API<37>-Footnote-194520513
Ref: C API<37>-Footnote-204520579
Ref: C API<37>-Footnote-214520622
Ref: C API<37>-Footnote-224520688
Ref: C API<37>-Footnote-234520754
Ref: C API<37>-Footnote-244520820
Ref: C API<37>-Footnote-254520886
Ref: C API<37>-Footnote-264520952
Ref: C API<37>-Footnote-274521018
Ref: C API<37>-Footnote-284521084
Ref: C API<37>-Footnote-294521150
Node: Python 3 9 0 beta 14521216
Ref: whatsnew/changelog python-3-9-0-beta-14521343
Ref: 18c14521343
Node: Security<25>4521704
Ref: whatsnew/changelog id3414521802
Ref: 18c24521802
Ref: Security<25>-Footnote-14522005
Node: Core and Builtins<40>4522070
Ref: whatsnew/changelog id3424522188
Ref: 18c34522188
Ref: Core and Builtins<40>-Footnote-14524731
Ref: Core and Builtins<40>-Footnote-24524796
Ref: Core and Builtins<40>-Footnote-34524861
Ref: Core and Builtins<40>-Footnote-44524926
Ref: Core and Builtins<40>-Footnote-54524991
Ref: Core and Builtins<40>-Footnote-64525056
Ref: Core and Builtins<40>-Footnote-74525098
Ref: Core and Builtins<40>-Footnote-84525163
Ref: Core and Builtins<40>-Footnote-94525228
Ref: Core and Builtins<40>-Footnote-104525295
Ref: Core and Builtins<40>-Footnote-114525338
Ref: Core and Builtins<40>-Footnote-124525404
Ref: Core and Builtins<40>-Footnote-134525472
Ref: Core and Builtins<40>-Footnote-144525515
Ref: Core and Builtins<40>-Footnote-154525581
Ref: Core and Builtins<40>-Footnote-164525647
Ref: Core and Builtins<40>-Footnote-174525713
Ref: Core and Builtins<40>-Footnote-184525779
Ref: Core and Builtins<40>-Footnote-194525847
Ref: Core and Builtins<40>-Footnote-204525890
Ref: Core and Builtins<40>-Footnote-214525956
Ref: Core and Builtins<40>-Footnote-224526022
Ref: Core and Builtins<40>-Footnote-234526088
Ref: Core and Builtins<40>-Footnote-244526154
Node: Library<39>4526220
Ref: whatsnew/changelog id3434526343
Ref: 18c54526343
Ref: Library<39>-Footnote-14533717
Ref: Library<39>-Footnote-24533782
Ref: Library<39>-Footnote-34533847
Ref: Library<39>-Footnote-44533912
Ref: Library<39>-Footnote-54533977
Ref: Library<39>-Footnote-64534042
Ref: Library<39>-Footnote-74534107
Ref: Library<39>-Footnote-84534172
Ref: Library<39>-Footnote-94534237
Ref: Library<39>-Footnote-104534302
Ref: Library<39>-Footnote-114534368
Ref: Library<39>-Footnote-124534434
Ref: Library<39>-Footnote-134534500
Ref: Library<39>-Footnote-144534566
Ref: Library<39>-Footnote-154534632
Ref: Library<39>-Footnote-164534675
Ref: Library<39>-Footnote-174534741
Ref: Library<39>-Footnote-184534807
Ref: Library<39>-Footnote-194534873
Ref: Library<39>-Footnote-204534939
Ref: Library<39>-Footnote-214535005
Ref: Library<39>-Footnote-224535071
Ref: Library<39>-Footnote-234535137
Ref: Library<39>-Footnote-244535203
Ref: Library<39>-Footnote-254535269
Ref: Library<39>-Footnote-264535335
Ref: Library<39>-Footnote-274535401
Ref: Library<39>-Footnote-284535467
Ref: Library<39>-Footnote-294535533
Ref: Library<39>-Footnote-304535599
Ref: Library<39>-Footnote-314535665
Ref: Library<39>-Footnote-324535731
Ref: Library<39>-Footnote-334535797
Ref: Library<39>-Footnote-344535863
Ref: Library<39>-Footnote-354535929
Ref: Library<39>-Footnote-364535995
Ref: Library<39>-Footnote-374536061
Ref: Library<39>-Footnote-384536127
Ref: Library<39>-Footnote-394536193
Ref: Library<39>-Footnote-404536259
Ref: Library<39>-Footnote-414536325
Ref: Library<39>-Footnote-424536391
Ref: Library<39>-Footnote-434536457
Ref: Library<39>-Footnote-444536523
Ref: Library<39>-Footnote-454536589
Ref: Library<39>-Footnote-464536655
Ref: Library<39>-Footnote-474536721
Ref: Library<39>-Footnote-484536787
Ref: Library<39>-Footnote-494536853
Ref: Library<39>-Footnote-504536919
Node: Documentation<34>4536985
Ref: whatsnew/changelog id3444537096
Ref: 18ca4537096
Ref: Documentation<34>-Footnote-14537761
Ref: Documentation<34>-Footnote-24537826
Ref: Documentation<34>-Footnote-34537891
Ref: Documentation<34>-Footnote-44537956
Ref: Documentation<34>-Footnote-54538021
Node: Tests<37>4538086
Ref: whatsnew/changelog id3454538195
Ref: 18cb4538195
Ref: Tests<37>-Footnote-14538550
Ref: Tests<37>-Footnote-24538615
Node: Build<39>4538680
Ref: whatsnew/changelog id3464538783
Ref: 18cc4538783
Ref: Build<39>-Footnote-14539123
Ref: Build<39>-Footnote-24539188
Node: Windows<35>4539253
Ref: whatsnew/changelog id3474539356
Ref: 18cd4539356
Ref: Windows<35>-Footnote-14539809
Ref: Windows<35>-Footnote-24539874
Ref: Windows<35>-Footnote-34539939
Node: macOS<30>4540004
Ref: whatsnew/changelog id3484540113
Ref: 18ce4540113
Ref: macOS<30>-Footnote-14540736
Ref: macOS<30>-Footnote-24540801
Node: Tools/Demos<17>4540866
Ref: whatsnew/changelog id3494540973
Ref: 18cf4540973
Ref: Tools/Demos<17>-Footnote-14541458
Ref: Tools/Demos<17>-Footnote-24541523
Ref: Tools/Demos<17>-Footnote-34541588
Node: C API<38>4541653
Ref: whatsnew/changelog id3504541742
Ref: 18d04541742
Ref: C API<38>-Footnote-14543768
Ref: C API<38>-Footnote-24543833
Ref: C API<38>-Footnote-34543898
Ref: C API<38>-Footnote-44543963
Ref: C API<38>-Footnote-54544028
Ref: C API<38>-Footnote-64544093
Ref: C API<38>-Footnote-74544158
Ref: C API<38>-Footnote-84544223
Ref: C API<38>-Footnote-94544288
Ref: C API<38>-Footnote-104544353
Ref: C API<38>-Footnote-114544419
Node: Python 3 9 0 alpha 64544462
Ref: whatsnew/changelog python-3-9-0-alpha-64544588
Ref: 18d14544588
Node: Security<26>4544969
Ref: whatsnew/changelog id3514545068
Ref: 18d24545068
Ref: Security<26>-Footnote-14545715
Ref: Security<26>-Footnote-24545780
Ref: Security<26>-Footnote-34545845
Ref: Security<26>-Footnote-44545910
Node: Core and Builtins<41>4545965
Ref: whatsnew/changelog id3524546084
Ref: 18d34546084
Ref: Core and Builtins<41>-Footnote-14549858
Ref: Core and Builtins<41>-Footnote-24549923
Ref: Core and Builtins<41>-Footnote-34549988
Ref: Core and Builtins<41>-Footnote-44550053
Ref: Core and Builtins<41>-Footnote-54550118
Ref: Core and Builtins<41>-Footnote-64550183
Ref: Core and Builtins<41>-Footnote-74550248
Ref: Core and Builtins<41>-Footnote-84550313
Ref: Core and Builtins<41>-Footnote-94550378
Ref: Core and Builtins<41>-Footnote-104550443
Ref: Core and Builtins<41>-Footnote-114550486
Ref: Core and Builtins<41>-Footnote-124550552
Ref: Core and Builtins<41>-Footnote-134550620
Ref: Core and Builtins<41>-Footnote-144550663
Ref: Core and Builtins<41>-Footnote-154550731
Ref: Core and Builtins<41>-Footnote-164550774
Ref: Core and Builtins<41>-Footnote-174550842
Ref: Core and Builtins<41>-Footnote-184550885
Ref: Core and Builtins<41>-Footnote-194550951
Ref: Core and Builtins<41>-Footnote-204551017
Ref: Core and Builtins<41>-Footnote-214551085
Ref: Core and Builtins<41>-Footnote-224551153
Ref: Core and Builtins<41>-Footnote-234551219
Ref: Core and Builtins<41>-Footnote-244551287
Ref: Core and Builtins<41>-Footnote-254551330
Ref: Core and Builtins<41>-Footnote-264551398
Ref: Core and Builtins<41>-Footnote-274551441
Ref: Core and Builtins<41>-Footnote-284551507
Ref: Core and Builtins<41>-Footnote-294551573
Ref: Core and Builtins<41>-Footnote-304551616
Ref: Core and Builtins<41>-Footnote-314551682
Ref: Core and Builtins<41>-Footnote-324551748
Ref: Core and Builtins<41>-Footnote-334551814
Node: Library<40>4551857
Ref: whatsnew/changelog id3534551981
Ref: 18d44551981
Ref: Library<40>-Footnote-14562206
Ref: Library<40>-Footnote-24562271
Ref: Library<40>-Footnote-34562336
Ref: Library<40>-Footnote-44562401
Ref: Library<40>-Footnote-54562466
Ref: Library<40>-Footnote-64562531
Ref: Library<40>-Footnote-74562573
Ref: Library<40>-Footnote-84562638
Ref: Library<40>-Footnote-94562703
Ref: Library<40>-Footnote-104562768
Ref: Library<40>-Footnote-114562834
Ref: Library<40>-Footnote-124562900
Ref: Library<40>-Footnote-134562966
Ref: Library<40>-Footnote-144563032
Ref: Library<40>-Footnote-154563098
Ref: Library<40>-Footnote-164563164
Ref: Library<40>-Footnote-174563230
Ref: Library<40>-Footnote-184563296
Ref: Library<40>-Footnote-194563362
Ref: Library<40>-Footnote-204563428
Ref: Library<40>-Footnote-214563494
Ref: Library<40>-Footnote-224563560
Ref: Library<40>-Footnote-234563626
Ref: Library<40>-Footnote-244563692
Ref: Library<40>-Footnote-254563758
Ref: Library<40>-Footnote-264563824
Ref: Library<40>-Footnote-274563890
Ref: Library<40>-Footnote-284563956
Ref: Library<40>-Footnote-294564022
Ref: Library<40>-Footnote-304564088
Ref: Library<40>-Footnote-314564154
Ref: Library<40>-Footnote-324564220
Ref: Library<40>-Footnote-334564286
Ref: Library<40>-Footnote-344564352
Ref: Library<40>-Footnote-354564418
Ref: Library<40>-Footnote-364564484
Ref: Library<40>-Footnote-374564550
Ref: Library<40>-Footnote-384564616
Ref: Library<40>-Footnote-394564682
Ref: Library<40>-Footnote-404564748
Ref: Library<40>-Footnote-414564814
Ref: Library<40>-Footnote-424564880
Ref: Library<40>-Footnote-434564946
Ref: Library<40>-Footnote-444565012
Ref: Library<40>-Footnote-454565078
Ref: Library<40>-Footnote-464565144
Ref: Library<40>-Footnote-474565210
Ref: Library<40>-Footnote-484565276
Ref: Library<40>-Footnote-494565319
Ref: Library<40>-Footnote-504565385
Ref: Library<40>-Footnote-514565428
Ref: Library<40>-Footnote-524565494
Ref: Library<40>-Footnote-534565560
Ref: Library<40>-Footnote-544565626
Ref: Library<40>-Footnote-554565669
Ref: Library<40>-Footnote-564565735
Ref: Library<40>-Footnote-574565801
Ref: Library<40>-Footnote-584565867
Ref: Library<40>-Footnote-594565933
Ref: Library<40>-Footnote-604565999
Ref: Library<40>-Footnote-614566065
Node: Documentation<35>4566131
Ref: whatsnew/changelog id3544566243
Ref: 18db4566243
Ref: Documentation<35>-Footnote-14566824
Ref: Documentation<35>-Footnote-24566889
Ref: Documentation<35>-Footnote-34566954
Ref: Documentation<35>-Footnote-44567019
Node: Tests<38>4567084
Ref: whatsnew/changelog id3554567194
Ref: 18de4567194
Ref: Tests<38>-Footnote-14568275
Ref: Tests<38>-Footnote-24568340
Ref: Tests<38>-Footnote-34568405
Ref: Tests<38>-Footnote-44568470
Ref: Tests<38>-Footnote-54568535
Ref: Tests<38>-Footnote-64568600
Ref: Tests<38>-Footnote-74568665
Ref: Tests<38>-Footnote-84568724
Ref: Tests<38>-Footnote-94568789
Node: Build<40>4568853
Ref: whatsnew/changelog id3564568957
Ref: 18e04568957
Ref: Build<40>-Footnote-14569370
Ref: Build<40>-Footnote-24569435
Ref: Build<40>-Footnote-34569500
Node: Windows<36>4569565
Ref: whatsnew/changelog id3574569669
Ref: 18e14569669
Ref: Windows<36>-Footnote-14569882
Ref: Windows<36>-Footnote-24569947
Node: macOS<31>4570011
Ref: whatsnew/changelog id3584570114
Ref: 18e24570114
Ref: macOS<31>-Footnote-14570570
Ref: macOS<31>-Footnote-24570635
Node: IDLE<27>4570700
Ref: whatsnew/changelog id3594570807
Ref: 18e34570807
Ref: IDLE<27>-Footnote-14571151
Ref: IDLE<27>-Footnote-24571216
Node: Tools/Demos<18>4571281
Ref: whatsnew/changelog id3604571388
Ref: 18e44571388
Ref: Tools/Demos<18>-Footnote-14571855
Ref: Tools/Demos<18>-Footnote-24571920
Ref: Tools/Demos<18>-Footnote-34571985
Node: C API<39>4572050
Ref: whatsnew/changelog id3614572140
Ref: 18e54572140
Ref: C API<39>-Footnote-14574115
Ref: C API<39>-Footnote-24574180
Ref: C API<39>-Footnote-34574245
Ref: C API<39>-Footnote-44574310
Ref: C API<39>-Footnote-54574375
Ref: C API<39>-Footnote-64574440
Ref: C API<39>-Footnote-74574505
Ref: C API<39>-Footnote-84574570
Ref: C API<39>-Footnote-94574635
Node: Python 3 9 0 alpha 54574700
Ref: whatsnew/changelog python-3-9-0-alpha-54574827
Ref: 18e64574827
Node: Security<27>4575208
Ref: whatsnew/changelog id3624575307
Ref: 18e74575307
Ref: Security<27>-Footnote-14575591
Ref: Security<27>-Footnote-24575656
Node: Core and Builtins<42>4575712
Ref: whatsnew/changelog id3634575831
Ref: 18e84575831
Ref: Core and Builtins<42>-Footnote-14581677
Ref: Core and Builtins<42>-Footnote-24581742
Ref: Core and Builtins<42>-Footnote-34581809
Ref: Core and Builtins<42>-Footnote-44581851
Ref: Core and Builtins<42>-Footnote-54581918
Ref: Core and Builtins<42>-Footnote-64581960
Ref: Core and Builtins<42>-Footnote-74582025
Ref: Core and Builtins<42>-Footnote-84582090
Ref: Core and Builtins<42>-Footnote-94582157
Ref: Core and Builtins<42>-Footnote-104582224
Ref: Core and Builtins<42>-Footnote-114582267
Ref: Core and Builtins<42>-Footnote-124582333
Ref: Core and Builtins<42>-Footnote-134582376
Ref: Core and Builtins<42>-Footnote-144582442
Ref: Core and Builtins<42>-Footnote-154582508
Ref: Core and Builtins<42>-Footnote-164582551
Ref: Core and Builtins<42>-Footnote-174582619
Ref: Core and Builtins<42>-Footnote-184582662
Ref: Core and Builtins<42>-Footnote-194582728
Ref: Core and Builtins<42>-Footnote-204582794
Ref: Core and Builtins<42>-Footnote-214582860
Ref: Core and Builtins<42>-Footnote-224582926
Ref: Core and Builtins<42>-Footnote-234582969
Ref: Core and Builtins<42>-Footnote-244583035
Ref: Core and Builtins<42>-Footnote-254583101
Ref: Core and Builtins<42>-Footnote-264583167
Ref: Core and Builtins<42>-Footnote-274583233
Ref: Core and Builtins<42>-Footnote-284583299
Ref: Core and Builtins<42>-Footnote-294583365
Ref: Core and Builtins<42>-Footnote-304583431
Ref: Core and Builtins<42>-Footnote-314583497
Ref: Core and Builtins<42>-Footnote-324583565
Ref: Core and Builtins<42>-Footnote-334583608
Ref: Core and Builtins<42>-Footnote-344583674
Ref: Core and Builtins<42>-Footnote-354583717
Ref: Core and Builtins<42>-Footnote-364583783
Ref: Core and Builtins<42>-Footnote-374583851
Ref: Core and Builtins<42>-Footnote-384583894
Ref: Core and Builtins<42>-Footnote-394583960
Ref: Core and Builtins<42>-Footnote-404584026
Ref: Core and Builtins<42>-Footnote-414584092
Ref: Core and Builtins<42>-Footnote-424584158
Node: Library<41>4584224
Ref: whatsnew/changelog id3644584348
Ref: 18e94584348
Ref: Library<41>-Footnote-14593469
Ref: Library<41>-Footnote-24593534
Ref: Library<41>-Footnote-34593599
Ref: Library<41>-Footnote-44593664
Ref: Library<41>-Footnote-54593729
Ref: Library<41>-Footnote-64593794
Ref: Library<41>-Footnote-74593859
Ref: Library<41>-Footnote-84593924
Ref: Library<41>-Footnote-94593989
Ref: Library<41>-Footnote-104594054
Ref: Library<41>-Footnote-114594120
Ref: Library<41>-Footnote-124594186
Ref: Library<41>-Footnote-134594229
Ref: Library<41>-Footnote-144594295
Ref: Library<41>-Footnote-154594361
Ref: Library<41>-Footnote-164594427
Ref: Library<41>-Footnote-174594470
Ref: Library<41>-Footnote-184594536
Ref: Library<41>-Footnote-194594602
Ref: Library<41>-Footnote-204594668
Ref: Library<41>-Footnote-214594734
Ref: Library<41>-Footnote-224594800
Ref: Library<41>-Footnote-234594866
Ref: Library<41>-Footnote-244594932
Ref: Library<41>-Footnote-254594998
Ref: Library<41>-Footnote-264595064
Ref: Library<41>-Footnote-274595130
Ref: Library<41>-Footnote-284595196
Ref: Library<41>-Footnote-294595262
Ref: Library<41>-Footnote-304595328
Ref: Library<41>-Footnote-314595394
Ref: Library<41>-Footnote-324595460
Ref: Library<41>-Footnote-334595503
Ref: Library<41>-Footnote-344595569
Ref: Library<41>-Footnote-354595635
Ref: Library<41>-Footnote-364595701
Ref: Library<41>-Footnote-374595767
Ref: Library<41>-Footnote-384595833
Ref: Library<41>-Footnote-394595899
Ref: Library<41>-Footnote-404595942
Ref: Library<41>-Footnote-414596008
Ref: Library<41>-Footnote-424596074
Ref: Library<41>-Footnote-434596140
Ref: Library<41>-Footnote-444596206
Ref: Library<41>-Footnote-454596272
Ref: Library<41>-Footnote-464596338
Ref: Library<41>-Footnote-474596404
Ref: Library<41>-Footnote-484596470
Ref: Library<41>-Footnote-494596536
Ref: Library<41>-Footnote-504596602
Ref: Library<41>-Footnote-514596668
Ref: Library<41>-Footnote-524596734
Ref: Library<41>-Footnote-534596800
Ref: Library<41>-Footnote-544596866
Node: Documentation<36>4596932
Ref: whatsnew/changelog id3654597044
Ref: 18ef4597044
Ref: Documentation<36>-Footnote-14597678
Ref: Documentation<36>-Footnote-24597743
Ref: Documentation<36>-Footnote-34597785
Ref: Documentation<36>-Footnote-44597850
Ref: Documentation<36>-Footnote-54597915
Ref: Documentation<36>-Footnote-64597980
Ref: Documentation<36>-Footnote-74598045
Node: Tests<39>4598110
Ref: whatsnew/changelog id3664598220
Ref: 18f04598220
Ref: Tests<39>-Footnote-14598898
Ref: Tests<39>-Footnote-24598963
Ref: Tests<39>-Footnote-34599028
Ref: Tests<39>-Footnote-44599093
Node: Build<41>4599158
Ref: whatsnew/changelog id3674599262
Ref: 18f14599262
Ref: Build<41>-Footnote-14600137
Ref: Build<41>-Footnote-24600202
Ref: Build<41>-Footnote-34600267
Node: Windows<37>4600334
Ref: whatsnew/changelog id3684600438
Ref: 18f24600438
Ref: Windows<37>-Footnote-14601320
Ref: Windows<37>-Footnote-24601385
Ref: Windows<37>-Footnote-34601450
Ref: Windows<37>-Footnote-44601515
Ref: Windows<37>-Footnote-54601580
Ref: Windows<37>-Footnote-64601645
Node: macOS<32>4601710
Ref: whatsnew/changelog id3694601813
Ref: 18f34601813
Ref: macOS<32>-Footnote-14601943
Node: IDLE<28>4602008
Ref: whatsnew/changelog id3704602115
Ref: 18f44602115
Ref: IDLE<28>-Footnote-14602669
Ref: IDLE<28>-Footnote-24602734
Ref: IDLE<28>-Footnote-34602799
Ref: IDLE<28>-Footnote-44602864
Node: Tools/Demos<19>4602929
Ref: whatsnew/changelog id3714603036
Ref: 18f54603036
Ref: Tools/Demos<19>-Footnote-14603565
Ref: Tools/Demos<19>-Footnote-24603630
Node: C API<40>4603695
Ref: whatsnew/changelog id3724603785
Ref: 18f64603785
Ref: C API<40>-Footnote-14607330
Ref: C API<40>-Footnote-24607395
Ref: C API<40>-Footnote-34607460
Ref: C API<40>-Footnote-44607525
Ref: C API<40>-Footnote-54607590
Ref: C API<40>-Footnote-64607655
Ref: C API<40>-Footnote-74607720
Ref: C API<40>-Footnote-84607785
Ref: C API<40>-Footnote-94607850
Ref: C API<40>-Footnote-104607915
Ref: C API<40>-Footnote-114607981
Ref: C API<40>-Footnote-124608047
Ref: C API<40>-Footnote-134608113
Ref: C API<40>-Footnote-144608179
Ref: C API<40>-Footnote-154608245
Ref: C API<40>-Footnote-164608311
Ref: C API<40>-Footnote-174608377
Node: Python 3 9 0 alpha 44608443
Ref: whatsnew/changelog python-3-9-0-alpha-44608570
Ref: 18fb4608570
Node: Security<28>4608899
Ref: whatsnew/changelog id3734608998
Ref: 18fc4608998
Ref: Security<28>-Footnote-14609409
Ref: Security<28>-Footnote-24609474
Ref: Security<28>-Footnote-34609539
Node: Core and Builtins<43>4609604
Ref: whatsnew/changelog id3744609723
Ref: 18fd4609723
Ref: Core and Builtins<43>-Footnote-14613126
Ref: Core and Builtins<43>-Footnote-24613191
Ref: Core and Builtins<43>-Footnote-34613256
Ref: Core and Builtins<43>-Footnote-44613321
Ref: Core and Builtins<43>-Footnote-54613386
Ref: Core and Builtins<43>-Footnote-64613451
Ref: Core and Builtins<43>-Footnote-74613516
Ref: Core and Builtins<43>-Footnote-84613581
Ref: Core and Builtins<43>-Footnote-94613648
Ref: Core and Builtins<43>-Footnote-104613690
Ref: Core and Builtins<43>-Footnote-114613758
Ref: Core and Builtins<43>-Footnote-124613801
Ref: Core and Builtins<43>-Footnote-134613867
Ref: Core and Builtins<43>-Footnote-144613933
Ref: Core and Builtins<43>-Footnote-154613999
Ref: Core and Builtins<43>-Footnote-164614065
Ref: Core and Builtins<43>-Footnote-174614131
Ref: Core and Builtins<43>-Footnote-184614199
Ref: Core and Builtins<43>-Footnote-194614242
Ref: Core and Builtins<43>-Footnote-204614310
Ref: Core and Builtins<43>-Footnote-214614353
Ref: Core and Builtins<43>-Footnote-224614421
Ref: Core and Builtins<43>-Footnote-234614464
Ref: Core and Builtins<43>-Footnote-244614530
Ref: Core and Builtins<43>-Footnote-254614596
Ref: Core and Builtins<43>-Footnote-264614662
Ref: Core and Builtins<43>-Footnote-274614728
Ref: Core and Builtins<43>-Footnote-284614794
Ref: Core and Builtins<43>-Footnote-294614860
Node: Library<42>4614926
Ref: whatsnew/changelog id3754615050
Ref: 19004615050
Ref: Library<42>-Footnote-14621230
Ref: Library<42>-Footnote-24621295
Ref: Library<42>-Footnote-34621360
Ref: Library<42>-Footnote-44621425
Ref: Library<42>-Footnote-54621490
Ref: Library<42>-Footnote-64621555
Ref: Library<42>-Footnote-74621620
Ref: Library<42>-Footnote-84621685
Ref: Library<42>-Footnote-94621750
Ref: Library<42>-Footnote-104621815
Ref: Library<42>-Footnote-114621881
Ref: Library<42>-Footnote-124621947
Ref: Library<42>-Footnote-134622013
Ref: Library<42>-Footnote-144622079
Ref: Library<42>-Footnote-154622145
Ref: Library<42>-Footnote-164622211
Ref: Library<42>-Footnote-174622293
Ref: Library<42>-Footnote-184622359
Ref: Library<42>-Footnote-194622425
Ref: Library<42>-Footnote-204622491
Ref: Library<42>-Footnote-214622557
Ref: Library<42>-Footnote-224622623
Ref: Library<42>-Footnote-234622689
Ref: Library<42>-Footnote-244622755
Ref: Library<42>-Footnote-254622821
Ref: Library<42>-Footnote-264622887
Ref: Library<42>-Footnote-274622953
Ref: Library<42>-Footnote-284622996
Ref: Library<42>-Footnote-294623062
Ref: Library<42>-Footnote-304623128
Ref: Library<42>-Footnote-314623194
Ref: Library<42>-Footnote-324623260
Ref: Library<42>-Footnote-334623326
Ref: Library<42>-Footnote-344623392
Ref: Library<42>-Footnote-354623458
Ref: Library<42>-Footnote-364623524
Ref: Library<42>-Footnote-374623590
Ref: Library<42>-Footnote-384623656
Ref: Library<42>-Footnote-394623722
Node: Documentation<37>4623788
Ref: whatsnew/changelog id3764623900
Ref: 19024623900
Ref: Documentation<37>-Footnote-14624931
Ref: Documentation<37>-Footnote-24624996
Ref: Documentation<37>-Footnote-34625061
Ref: Documentation<37>-Footnote-44625126
Ref: Documentation<37>-Footnote-54625191
Ref: Documentation<37>-Footnote-64625256
Ref: Documentation<37>-Footnote-74625321
Node: Tests<40>4625385
Ref: whatsnew/changelog id3774625495
Ref: 19034625495
Ref: Tests<40>-Footnote-14625829
Ref: Tests<40>-Footnote-24625894
Node: Build<42>4625959
Ref: whatsnew/changelog id3784626063
Ref: 19044626063
Ref: Build<42>-Footnote-14626193
Node: Windows<38>4626258
Ref: whatsnew/changelog id3794626361
Ref: 19054626361
Ref: Windows<38>-Footnote-14627167
Ref: Windows<38>-Footnote-24627232
Ref: Windows<38>-Footnote-34627297
Ref: Windows<38>-Footnote-44627362
Ref: Windows<38>-Footnote-54627427
Ref: Windows<38>-Footnote-64627492
Node: IDLE<29>4627557
Ref: whatsnew/changelog id3804627660
Ref: 19064627660
Ref: IDLE<29>-Footnote-14628207
Ref: IDLE<29>-Footnote-24628272
Ref: IDLE<29>-Footnote-34628337
Ref: IDLE<29>-Footnote-44628402
Ref: IDLE<29>-Footnote-54628467
Node: C API<41>4628532
Ref: whatsnew/changelog id3814628615
Ref: 19074628615
Ref: C API<41>-Footnote-14631274
Ref: C API<41>-Footnote-24631339
Ref: C API<41>-Footnote-34631404
Ref: C API<41>-Footnote-44631469
Ref: C API<41>-Footnote-54631534
Ref: C API<41>-Footnote-64631599
Ref: C API<41>-Footnote-74631664
Ref: C API<41>-Footnote-84631729
Ref: C API<41>-Footnote-94631794
Ref: C API<41>-Footnote-104631859
Ref: C API<41>-Footnote-114631925
Ref: C API<41>-Footnote-124631991
Node: Python 3 9 0 alpha 34632057
Ref: whatsnew/changelog python-3-9-0-alpha-34632184
Ref: 190c4632184
Node: Core and Builtins<44>4632443
Ref: whatsnew/changelog id3824632541
Ref: 190d4632541
Ref: Core and Builtins<44>-Footnote-14636625
Ref: Core and Builtins<44>-Footnote-24636690
Ref: Core and Builtins<44>-Footnote-34636755
Ref: Core and Builtins<44>-Footnote-44636820
Ref: Core and Builtins<44>-Footnote-54636885
Ref: Core and Builtins<44>-Footnote-64636950
Ref: Core and Builtins<44>-Footnote-74637015
Ref: Core and Builtins<44>-Footnote-84637080
Ref: Core and Builtins<44>-Footnote-94637145
Ref: Core and Builtins<44>-Footnote-104637210
Ref: Core and Builtins<44>-Footnote-114637276
Ref: Core and Builtins<44>-Footnote-124637344
Ref: Core and Builtins<44>-Footnote-134637387
Ref: Core and Builtins<44>-Footnote-144637453
Ref: Core and Builtins<44>-Footnote-154637519
Ref: Core and Builtins<44>-Footnote-164637585
Ref: Core and Builtins<44>-Footnote-174637651
Ref: Core and Builtins<44>-Footnote-184637717
Ref: Core and Builtins<44>-Footnote-194637783
Ref: Core and Builtins<44>-Footnote-204637849
Ref: Core and Builtins<44>-Footnote-214637915
Ref: Core and Builtins<44>-Footnote-224637981
Ref: Core and Builtins<44>-Footnote-234638047
Ref: Core and Builtins<44>-Footnote-244638113
Node: Library<43>4638179
Ref: whatsnew/changelog id3834638303
Ref: 19114638303
Ref: Library<43>-Footnote-14647907
Ref: Library<43>-Footnote-24647972
Ref: Library<43>-Footnote-34648037
Ref: Library<43>-Footnote-44648102
Ref: Library<43>-Footnote-54648167
Ref: Library<43>-Footnote-64648232
Ref: Library<43>-Footnote-74648297
Ref: Library<43>-Footnote-84648362
Ref: Library<43>-Footnote-94648427
Ref: Library<43>-Footnote-104648492
Ref: Library<43>-Footnote-114648558
Ref: Library<43>-Footnote-124648624
Ref: Library<43>-Footnote-134648690
Ref: Library<43>-Footnote-144648756
Ref: Library<43>-Footnote-154648822
Ref: Library<43>-Footnote-164648888
Ref: Library<43>-Footnote-174648954
Ref: Library<43>-Footnote-184649020
Ref: Library<43>-Footnote-194649086
Ref: Library<43>-Footnote-204649152
Ref: Library<43>-Footnote-214649218
Ref: Library<43>-Footnote-224649284
Ref: Library<43>-Footnote-234649350
Ref: Library<43>-Footnote-244649416
Ref: Library<43>-Footnote-254649482
Ref: Library<43>-Footnote-264649548
Ref: Library<43>-Footnote-274649614
Ref: Library<43>-Footnote-284649680
Ref: Library<43>-Footnote-294649746
Ref: Library<43>-Footnote-304649812
Ref: Library<43>-Footnote-314649878
Ref: Library<43>-Footnote-324649944
Ref: Library<43>-Footnote-334650010
Ref: Library<43>-Footnote-344650076
Ref: Library<43>-Footnote-354650142
Ref: Library<43>-Footnote-364650208
Ref: Library<43>-Footnote-374650274
Ref: Library<43>-Footnote-384650340
Ref: Library<43>-Footnote-394650406
Ref: Library<43>-Footnote-404650472
Ref: Library<43>-Footnote-414650538
Ref: Library<43>-Footnote-424650604
Ref: Library<43>-Footnote-434650670
Ref: Library<43>-Footnote-444650736
Ref: Library<43>-Footnote-454650802
Ref: Library<43>-Footnote-464650868
Ref: Library<43>-Footnote-474650934
Ref: Library<43>-Footnote-484651000
Ref: Library<43>-Footnote-494651066
Ref: Library<43>-Footnote-504651132
Ref: Library<43>-Footnote-514651198
Ref: Library<43>-Footnote-524651264
Ref: Library<43>-Footnote-534651330
Node: Documentation<38>4651396
Ref: whatsnew/changelog id3844651508
Ref: 19144651508
Ref: Documentation<38>-Footnote-14652116
Ref: Documentation<38>-Footnote-24652181
Ref: Documentation<38>-Footnote-34652246
Node: Build<43>4652310
Ref: whatsnew/changelog id3854652419
Ref: 19164652419
Ref: Build<43>-Footnote-14652945
Ref: Build<43>-Footnote-24653010
Ref: Build<43>-Footnote-34653075
Node: IDLE<30>4653140
Ref: whatsnew/changelog id3864653241
Ref: 19174653241
Ref: IDLE<30>-Footnote-14653662
Ref: IDLE<30>-Footnote-24653727
Ref: IDLE<30>-Footnote-34653792
Node: C API<42>4653857
Ref: whatsnew/changelog id3874653940
Ref: 19184653940
Ref: C API<42>-Footnote-14654705
Ref: C API<42>-Footnote-24654770
Node: Python 3 9 0 alpha 24654835
Ref: whatsnew/changelog python-3-9-0-alpha-24654962
Ref: 19194654962
Node: Security<29>4655311
Ref: whatsnew/changelog id3884655410
Ref: 191a4655410
Ref: Security<29>-Footnote-14656283
Ref: Security<29>-Footnote-24656348
Ref: Security<29>-Footnote-34656413
Ref: Security<29>-Footnote-44656478
Node: Core and Builtins<45>4656543
Ref: whatsnew/changelog id3894656662
Ref: 191b4656662
Ref: Core and Builtins<45>-Footnote-14660331
Ref: Core and Builtins<45>-Footnote-24660396
Ref: Core and Builtins<45>-Footnote-34660461
Ref: Core and Builtins<45>-Footnote-44660526
Ref: Core and Builtins<45>-Footnote-54660591
Ref: Core and Builtins<45>-Footnote-64660656
Ref: Core and Builtins<45>-Footnote-74660721
Ref: Core and Builtins<45>-Footnote-84660786
Ref: Core and Builtins<45>-Footnote-94660851
Ref: Core and Builtins<45>-Footnote-104660916
Ref: Core and Builtins<45>-Footnote-114660982
Ref: Core and Builtins<45>-Footnote-124661048
Ref: Core and Builtins<45>-Footnote-134661114
Ref: Core and Builtins<45>-Footnote-144661180
Ref: Core and Builtins<45>-Footnote-154661246
Ref: Core and Builtins<45>-Footnote-164661312
Ref: Core and Builtins<45>-Footnote-174661378
Ref: Core and Builtins<45>-Footnote-184661444
Ref: Core and Builtins<45>-Footnote-194661510
Ref: Core and Builtins<45>-Footnote-204661576
Node: Library<44>4661642
Ref: whatsnew/changelog id3904661766
Ref: 191c4661766
Ref: Library<44>-Footnote-14669549
Ref: Library<44>-Footnote-24669614
Ref: Library<44>-Footnote-34669679
Ref: Library<44>-Footnote-44669744
Ref: Library<44>-Footnote-54669809
Ref: Library<44>-Footnote-64669874
Ref: Library<44>-Footnote-74669939
Ref: Library<44>-Footnote-84670004
Ref: Library<44>-Footnote-94670069
Ref: Library<44>-Footnote-104670134
Ref: Library<44>-Footnote-114670200
Ref: Library<44>-Footnote-124670266
Ref: Library<44>-Footnote-134670332
Ref: Library<44>-Footnote-144670398
Ref: Library<44>-Footnote-154670464
Ref: Library<44>-Footnote-164670530
Ref: Library<44>-Footnote-174670596
Ref: Library<44>-Footnote-184670662
Ref: Library<44>-Footnote-194670728
Ref: Library<44>-Footnote-204670794
Ref: Library<44>-Footnote-214670860
Ref: Library<44>-Footnote-224670926
Ref: Library<44>-Footnote-234670992
Ref: Library<44>-Footnote-244671058
Ref: Library<44>-Footnote-254671124
Ref: Library<44>-Footnote-264671190
Ref: Library<44>-Footnote-274671256
Ref: Library<44>-Footnote-284671322
Ref: Library<44>-Footnote-294671388
Ref: Library<44>-Footnote-304671454
Ref: Library<44>-Footnote-314671520
Ref: Library<44>-Footnote-324671586
Ref: Library<44>-Footnote-334671652
Ref: Library<44>-Footnote-344671718
Ref: Library<44>-Footnote-354671784
Ref: Library<44>-Footnote-364671850
Ref: Library<44>-Footnote-374671916
Ref: Library<44>-Footnote-384671982
Ref: Library<44>-Footnote-394672048
Ref: Library<44>-Footnote-404672114
Node: Documentation<39>4672180
Ref: whatsnew/changelog id3914672292
Ref: 191d4672292
Ref: Documentation<39>-Footnote-14672877
Ref: Documentation<39>-Footnote-24672942
Ref: Documentation<39>-Footnote-34673007
Node: Tests<41>4673072
Ref: whatsnew/changelog id3924673182
Ref: 191e4673182
Ref: Tests<41>-Footnote-14675748
Ref: Tests<41>-Footnote-24675813
Ref: Tests<41>-Footnote-34675878
Ref: Tests<41>-Footnote-44675943
Ref: Tests<41>-Footnote-54676008
Ref: Tests<41>-Footnote-64676073
Ref: Tests<41>-Footnote-74676138
Ref: Tests<41>-Footnote-84676203
Ref: Tests<41>-Footnote-94676268
Ref: Tests<41>-Footnote-104676333
Ref: Tests<41>-Footnote-114676399
Ref: Tests<41>-Footnote-124676465
Ref: Tests<41>-Footnote-134676531
Node: Build<44>4676597
Ref: whatsnew/changelog id3934676701
Ref: 19224676701
Ref: Build<44>-Footnote-14677099
Ref: Build<44>-Footnote-24677164
Node: Windows<39>4677229
Ref: whatsnew/changelog id3944677333
Ref: 19234677333
Ref: Windows<39>-Footnote-14677568
Ref: Windows<39>-Footnote-24677633
Node: macOS<33>4677698
Ref: whatsnew/changelog id3954677801
Ref: 19244677801
Ref: macOS<33>-Footnote-14678109
Node: IDLE<31>4678174
Ref: whatsnew/changelog id3964678275
Ref: 19254678275
Ref: IDLE<31>-Footnote-14678866
Ref: IDLE<31>-Footnote-24678931
Ref: IDLE<31>-Footnote-34678996
Ref: IDLE<31>-Footnote-44679061
Node: C API<43>4679126
Ref: whatsnew/changelog id3974679209
Ref: 19264679209
Ref: C API<43>-Footnote-14679743
Ref: C API<43>-Footnote-24679808
Ref: C API<43>-Footnote-34679873
Node: Python 3 9 0 alpha 14679938
Ref: whatsnew/changelog python-3-9-0-alpha-14680064
Ref: 19274680064
Node: Security<30>4680445
Ref: whatsnew/changelog id3984680544
Ref: 19284680544
Ref: Security<30>-Footnote-14682864
Ref: Security<30>-Footnote-24682929
Ref: Security<30>-Footnote-34682994
Ref: Security<30>-Footnote-44683059
Ref: Security<30>-Footnote-54683124
Ref: Security<30>-Footnote-64683189
Ref: Security<30>-Footnote-74683254
Ref: Security<30>-Footnote-84683310
Ref: Security<30>-Footnote-94683375
Ref: Security<30>-Footnote-104683440
Ref: Security<30>-Footnote-114683506
Ref: Security<30>-Footnote-124683572
Ref: Security<30>-Footnote-134683638
Ref: Security<30>-Footnote-144683704
Ref: Security<30>-Footnote-154683770
Node: Core and Builtins<46>4683836
Ref: whatsnew/changelog id3994683955
Ref: 192b4683955
Ref: Core and Builtins<46>-Footnote-14699456
Ref: Core and Builtins<46>-Footnote-24699521
Ref: Core and Builtins<46>-Footnote-34699586
Ref: Core and Builtins<46>-Footnote-44699651
Ref: Core and Builtins<46>-Footnote-54699716
Ref: Core and Builtins<46>-Footnote-64699781
Ref: Core and Builtins<46>-Footnote-74699846
Ref: Core and Builtins<46>-Footnote-84699911
Ref: Core and Builtins<46>-Footnote-94699976
Ref: Core and Builtins<46>-Footnote-104700041
Ref: Core and Builtins<46>-Footnote-114700107
Ref: Core and Builtins<46>-Footnote-124700173
Ref: Core and Builtins<46>-Footnote-134700239
Ref: Core and Builtins<46>-Footnote-144700305
Ref: Core and Builtins<46>-Footnote-154700371
Ref: Core and Builtins<46>-Footnote-164700437
Ref: Core and Builtins<46>-Footnote-174700503
Ref: Core and Builtins<46>-Footnote-184700569
Ref: Core and Builtins<46>-Footnote-194700635
Ref: Core and Builtins<46>-Footnote-204700701
Ref: Core and Builtins<46>-Footnote-214700744
Ref: Core and Builtins<46>-Footnote-224700810
Ref: Core and Builtins<46>-Footnote-234700876
Ref: Core and Builtins<46>-Footnote-244700942
Ref: Core and Builtins<46>-Footnote-254701008
Ref: Core and Builtins<46>-Footnote-264701074
Ref: Core and Builtins<46>-Footnote-274701140
Ref: Core and Builtins<46>-Footnote-284701206
Ref: Core and Builtins<46>-Footnote-294701272
Ref: Core and Builtins<46>-Footnote-304701338
Ref: Core and Builtins<46>-Footnote-314701404
Ref: Core and Builtins<46>-Footnote-324701470
Ref: Core and Builtins<46>-Footnote-334701536
Ref: Core and Builtins<46>-Footnote-344701602
Ref: Core and Builtins<46>-Footnote-354701668
Ref: Core and Builtins<46>-Footnote-364701734
Ref: Core and Builtins<46>-Footnote-374701800
Ref: Core and Builtins<46>-Footnote-384701866
Ref: Core and Builtins<46>-Footnote-394701932
Ref: Core and Builtins<46>-Footnote-404701998
Ref: Core and Builtins<46>-Footnote-414702063
Ref: Core and Builtins<46>-Footnote-424702129
Ref: Core and Builtins<46>-Footnote-434702195
Ref: Core and Builtins<46>-Footnote-444702261
Ref: Core and Builtins<46>-Footnote-454702327
Ref: Core and Builtins<46>-Footnote-464702393
Ref: Core and Builtins<46>-Footnote-474702459
Ref: Core and Builtins<46>-Footnote-484702525
Ref: Core and Builtins<46>-Footnote-494702591
Ref: Core and Builtins<46>-Footnote-504702657
Ref: Core and Builtins<46>-Footnote-514702723
Ref: Core and Builtins<46>-Footnote-524702789
Ref: Core and Builtins<46>-Footnote-534702855
Ref: Core and Builtins<46>-Footnote-544702898
Ref: Core and Builtins<46>-Footnote-554702964
Ref: Core and Builtins<46>-Footnote-564703030
Ref: Core and Builtins<46>-Footnote-574703096
Ref: Core and Builtins<46>-Footnote-584703162
Ref: Core and Builtins<46>-Footnote-594703228
Ref: Core and Builtins<46>-Footnote-604703294
Ref: Core and Builtins<46>-Footnote-614703360
Ref: Core and Builtins<46>-Footnote-624703426
Ref: Core and Builtins<46>-Footnote-634703492
Ref: Core and Builtins<46>-Footnote-644703558
Ref: Core and Builtins<46>-Footnote-654703624
Ref: Core and Builtins<46>-Footnote-664703690
Ref: Core and Builtins<46>-Footnote-674703756
Ref: Core and Builtins<46>-Footnote-684703822
Ref: Core and Builtins<46>-Footnote-694703888
Ref: Core and Builtins<46>-Footnote-704703954
Ref: Core and Builtins<46>-Footnote-714704020
Ref: Core and Builtins<46>-Footnote-724704086
Ref: Core and Builtins<46>-Footnote-734704152
Ref: Core and Builtins<46>-Footnote-744704218
Ref: Core and Builtins<46>-Footnote-754704284
Ref: Core and Builtins<46>-Footnote-764704350
Ref: Core and Builtins<46>-Footnote-774704416
Ref: Core and Builtins<46>-Footnote-784704482
Ref: Core and Builtins<46>-Footnote-794704548
Ref: Core and Builtins<46>-Footnote-804704614
Ref: Core and Builtins<46>-Footnote-814704680
Ref: Core and Builtins<46>-Footnote-824704746
Ref: Core and Builtins<46>-Footnote-834704812
Ref: Core and Builtins<46>-Footnote-844704878
Ref: Core and Builtins<46>-Footnote-854704944
Ref: Core and Builtins<46>-Footnote-864705010
Ref: Core and Builtins<46>-Footnote-874705076
Ref: Core and Builtins<46>-Footnote-884705142
Ref: Core and Builtins<46>-Footnote-894705208
Ref: Core and Builtins<46>-Footnote-904705274
Ref: Core and Builtins<46>-Footnote-914705340
Ref: Core and Builtins<46>-Footnote-924705406
Ref: Core and Builtins<46>-Footnote-934705472
Ref: Core and Builtins<46>-Footnote-944705538
Node: Library<45>4705604
Ref: whatsnew/changelog id4004705728
Ref: 19304705728
Ref: Library<45>-Footnote-14745091
Ref: Library<45>-Footnote-24745156
Ref: Library<45>-Footnote-34745221
Ref: Library<45>-Footnote-44745286
Ref: Library<45>-Footnote-54745351
Ref: Library<45>-Footnote-64745416
Ref: Library<45>-Footnote-74745481
Ref: Library<45>-Footnote-84745546
Ref: Library<45>-Footnote-94745611
Ref: Library<45>-Footnote-104745676
Ref: Library<45>-Footnote-114745742
Ref: Library<45>-Footnote-124745808
Ref: Library<45>-Footnote-134745874
Ref: Library<45>-Footnote-144745940
Ref: Library<45>-Footnote-154746006
Ref: Library<45>-Footnote-164746072
Ref: Library<45>-Footnote-174746138
Ref: Library<45>-Footnote-184746204
Ref: Library<45>-Footnote-194746270
Ref: Library<45>-Footnote-204746336
Ref: Library<45>-Footnote-214746402
Ref: Library<45>-Footnote-224746468
Ref: Library<45>-Footnote-234746534
Ref: Library<45>-Footnote-244746600
Ref: Library<45>-Footnote-254746666
Ref: Library<45>-Footnote-264746732
Ref: Library<45>-Footnote-274746798
Ref: Library<45>-Footnote-284746864
Ref: Library<45>-Footnote-294746930
Ref: Library<45>-Footnote-304746996
Ref: Library<45>-Footnote-314747062
Ref: Library<45>-Footnote-324747128
Ref: Library<45>-Footnote-334747194
Ref: Library<45>-Footnote-344747260
Ref: Library<45>-Footnote-354747326
Ref: Library<45>-Footnote-364747392
Ref: Library<45>-Footnote-374747458
Ref: Library<45>-Footnote-384747524
Ref: Library<45>-Footnote-394747590
Ref: Library<45>-Footnote-404747656
Ref: Library<45>-Footnote-414747722
Ref: Library<45>-Footnote-424747788
Ref: Library<45>-Footnote-434747854
Ref: Library<45>-Footnote-444747920
Ref: Library<45>-Footnote-454747986
Ref: Library<45>-Footnote-464748052
Ref: Library<45>-Footnote-474748118
Ref: Library<45>-Footnote-484748184
Ref: Library<45>-Footnote-494748250
Ref: Library<45>-Footnote-504748316
Ref: Library<45>-Footnote-514748382
Ref: Library<45>-Footnote-524748448
Ref: Library<45>-Footnote-534748514
Ref: Library<45>-Footnote-544748580
Ref: Library<45>-Footnote-554748646
Ref: Library<45>-Footnote-564748712
Ref: Library<45>-Footnote-574748778
Ref: Library<45>-Footnote-584748844
Ref: Library<45>-Footnote-594748910
Ref: Library<45>-Footnote-604748976
Ref: Library<45>-Footnote-614749042
Ref: Library<45>-Footnote-624749108
Ref: Library<45>-Footnote-634749174
Ref: Library<45>-Footnote-644749239
Ref: Library<45>-Footnote-654749305
Ref: Library<45>-Footnote-664749371
Ref: Library<45>-Footnote-674749437
Ref: Library<45>-Footnote-684749503
Ref: Library<45>-Footnote-694749569
Ref: Library<45>-Footnote-704749635
Ref: Library<45>-Footnote-714749701
Ref: Library<45>-Footnote-724749767
Ref: Library<45>-Footnote-734749833
Ref: Library<45>-Footnote-744749899
Ref: Library<45>-Footnote-754749965
Ref: Library<45>-Footnote-764750031
Ref: Library<45>-Footnote-774750139
Ref: Library<45>-Footnote-784750205
Ref: Library<45>-Footnote-794750271
Ref: Library<45>-Footnote-804750337
Ref: Library<45>-Footnote-814750403
Ref: Library<45>-Footnote-824750469
Ref: Library<45>-Footnote-834750535
Ref: Library<45>-Footnote-844750601
Ref: Library<45>-Footnote-854750667
Ref: Library<45>-Footnote-864750733
Ref: Library<45>-Footnote-874750799
Ref: Library<45>-Footnote-884750865
Ref: Library<45>-Footnote-894750931
Ref: Library<45>-Footnote-904750997
Ref: Library<45>-Footnote-914751063
Ref: Library<45>-Footnote-924751129
Ref: Library<45>-Footnote-934751195
Ref: Library<45>-Footnote-944751261
Ref: Library<45>-Footnote-954751327
Ref: Library<45>-Footnote-964751393
Ref: Library<45>-Footnote-974751459
Ref: Library<45>-Footnote-984751525
Ref: Library<45>-Footnote-994751591
Ref: Library<45>-Footnote-1004751657
Ref: Library<45>-Footnote-1014751724
Ref: Library<45>-Footnote-1024751791
Ref: Library<45>-Footnote-1034751858
Ref: Library<45>-Footnote-1044751925
Ref: Library<45>-Footnote-1054751992
Ref: Library<45>-Footnote-1064752059
Ref: Library<45>-Footnote-1074752126
Ref: Library<45>-Footnote-1084752192
Ref: Library<45>-Footnote-1094752259
Ref: Library<45>-Footnote-1104752326
Ref: Library<45>-Footnote-1114752393
Ref: Library<45>-Footnote-1124752460
Ref: Library<45>-Footnote-1134752527
Ref: Library<45>-Footnote-1144752594
Ref: Library<45>-Footnote-1154752661
Ref: Library<45>-Footnote-1164752728
Ref: Library<45>-Footnote-1174752795
Ref: Library<45>-Footnote-1184752862
Ref: Library<45>-Footnote-1194752929
Ref: Library<45>-Footnote-1204752996
Ref: Library<45>-Footnote-1214753063
Ref: Library<45>-Footnote-1224753130
Ref: Library<45>-Footnote-1234753197
Ref: Library<45>-Footnote-1244753264
Ref: Library<45>-Footnote-1254753331
Ref: Library<45>-Footnote-1264753398
Ref: Library<45>-Footnote-1274753465
Ref: Library<45>-Footnote-1284753532
Ref: Library<45>-Footnote-1294753599
Ref: Library<45>-Footnote-1304753666
Ref: Library<45>-Footnote-1314753733
Ref: Library<45>-Footnote-1324753800
Ref: Library<45>-Footnote-1334753867
Ref: Library<45>-Footnote-1344753934
Ref: Library<45>-Footnote-1354754001
Ref: Library<45>-Footnote-1364754068
Ref: Library<45>-Footnote-1374754145
Ref: Library<45>-Footnote-1384754212
Ref: Library<45>-Footnote-1394754279
Ref: Library<45>-Footnote-1404754346
Ref: Library<45>-Footnote-1414754413
Ref: Library<45>-Footnote-1424754480
Ref: Library<45>-Footnote-1434754547
Ref: Library<45>-Footnote-1444754614
Ref: Library<45>-Footnote-1454754681
Ref: Library<45>-Footnote-1464754748
Ref: Library<45>-Footnote-1474754815
Ref: Library<45>-Footnote-1484754882
Ref: Library<45>-Footnote-1494754949
Ref: Library<45>-Footnote-1504755016
Ref: Library<45>-Footnote-1514755083
Ref: Library<45>-Footnote-1524755150
Ref: Library<45>-Footnote-1534755217
Ref: Library<45>-Footnote-1544755284
Ref: Library<45>-Footnote-1554755351
Ref: Library<45>-Footnote-1564755418
Ref: Library<45>-Footnote-1574755485
Ref: Library<45>-Footnote-1584755552
Ref: Library<45>-Footnote-1594755619
Ref: Library<45>-Footnote-1604755686
Ref: Library<45>-Footnote-1614755753
Ref: Library<45>-Footnote-1624755820
Ref: Library<45>-Footnote-1634755887
Ref: Library<45>-Footnote-1644755954
Ref: Library<45>-Footnote-1654756021
Ref: Library<45>-Footnote-1664756088
Ref: Library<45>-Footnote-1674756155
Ref: Library<45>-Footnote-1684756222
Ref: Library<45>-Footnote-1694756289
Ref: Library<45>-Footnote-1704756356
Ref: Library<45>-Footnote-1714756423
Ref: Library<45>-Footnote-1724756490
Ref: Library<45>-Footnote-1734756534
Ref: Library<45>-Footnote-1744756601
Ref: Library<45>-Footnote-1754756668
Ref: Library<45>-Footnote-1764756735
Ref: Library<45>-Footnote-1774756802
Ref: Library<45>-Footnote-1784756869
Ref: Library<45>-Footnote-1794756936
Ref: Library<45>-Footnote-1804757003
Ref: Library<45>-Footnote-1814757070
Ref: Library<45>-Footnote-1824757137
Ref: Library<45>-Footnote-1834757204
Ref: Library<45>-Footnote-1844757271
Ref: Library<45>-Footnote-1854757338
Ref: Library<45>-Footnote-1864757405
Ref: Library<45>-Footnote-1874757472
Ref: Library<45>-Footnote-1884757539
Ref: Library<45>-Footnote-1894757606
Ref: Library<45>-Footnote-1904757673
Ref: Library<45>-Footnote-1914757740
Ref: Library<45>-Footnote-1924757807
Ref: Library<45>-Footnote-1934757874
Ref: Library<45>-Footnote-1944757941
Ref: Library<45>-Footnote-1954758008
Ref: Library<45>-Footnote-1964758075
Ref: Library<45>-Footnote-1974758142
Ref: Library<45>-Footnote-1984758209
Ref: Library<45>-Footnote-1994758276
Ref: Library<45>-Footnote-2004758343
Ref: Library<45>-Footnote-2014758410
Ref: Library<45>-Footnote-2024758477
Ref: Library<45>-Footnote-2034758544
Ref: Library<45>-Footnote-2044758611
Ref: Library<45>-Footnote-2054758678
Ref: Library<45>-Footnote-2064758745
Ref: Library<45>-Footnote-2074758812
Ref: Library<45>-Footnote-2084758879
Ref: Library<45>-Footnote-2094758946
Ref: Library<45>-Footnote-2104759013
Ref: Library<45>-Footnote-2114759080
Ref: Library<45>-Footnote-2124759147
Ref: Library<45>-Footnote-2134759214
Ref: Library<45>-Footnote-2144759281
Ref: Library<45>-Footnote-2154759348
Ref: Library<45>-Footnote-2164759415
Ref: Library<45>-Footnote-2174759482
Ref: Library<45>-Footnote-2184759549
Ref: Library<45>-Footnote-2194759616
Ref: Library<45>-Footnote-2204759683
Ref: Library<45>-Footnote-2214759750
Ref: Library<45>-Footnote-2224759817
Ref: Library<45>-Footnote-2234759884
Ref: Library<45>-Footnote-2244759951
Ref: Library<45>-Footnote-2254760018
Ref: Library<45>-Footnote-2264760085
Ref: Library<45>-Footnote-2274760152
Ref: Library<45>-Footnote-2284760219
Ref: Library<45>-Footnote-2294760286
Ref: Library<45>-Footnote-2304760353
Ref: Library<45>-Footnote-2314760420
Ref: Library<45>-Footnote-2324760487
Ref: Library<45>-Footnote-2334760554
Ref: Library<45>-Footnote-2344760621
Ref: Library<45>-Footnote-2354760688
Ref: Library<45>-Footnote-2364760755
Ref: Library<45>-Footnote-2374760822
Ref: Library<45>-Footnote-2384760889
Ref: Library<45>-Footnote-2394760956
Ref: Library<45>-Footnote-2404761022
Ref: Library<45>-Footnote-2414761089
Ref: Library<45>-Footnote-2424761156
Ref: Library<45>-Footnote-2434761223
Ref: Library<45>-Footnote-2444761290
Ref: Library<45>-Footnote-2454761357
Ref: Library<45>-Footnote-2464761424
Ref: Library<45>-Footnote-2474761491
Ref: Library<45>-Footnote-2484761558
Ref: Library<45>-Footnote-2494761625
Ref: Library<45>-Footnote-2504761692
Ref: Library<45>-Footnote-2514761759
Ref: Library<45>-Footnote-2524761826
Ref: Library<45>-Footnote-2534761893
Node: Documentation<40>4761959
Ref: whatsnew/changelog id4014762071
Ref: 193d4762071
Ref: Documentation<40>-Footnote-14766523
Ref: Documentation<40>-Footnote-24766588
Ref: Documentation<40>-Footnote-34766653
Ref: Documentation<40>-Footnote-44766718
Ref: Documentation<40>-Footnote-54766783
Ref: Documentation<40>-Footnote-64766848
Ref: Documentation<40>-Footnote-74766913
Ref: Documentation<40>-Footnote-84766978
Ref: Documentation<40>-Footnote-94767043
Ref: Documentation<40>-Footnote-104767108
Ref: Documentation<40>-Footnote-114767174
Ref: Documentation<40>-Footnote-124767240
Ref: Documentation<40>-Footnote-134767306
Ref: Documentation<40>-Footnote-144767372
Ref: Documentation<40>-Footnote-154767438
Ref: Documentation<40>-Footnote-164767504
Ref: Documentation<40>-Footnote-174767570
Ref: Documentation<40>-Footnote-184767636
Ref: Documentation<40>-Footnote-194767702
Ref: Documentation<40>-Footnote-204767768
Ref: Documentation<40>-Footnote-214767834
Ref: Documentation<40>-Footnote-224767900
Ref: Documentation<40>-Footnote-234767966
Ref: Documentation<40>-Footnote-244768032
Ref: Documentation<40>-Footnote-254768098
Ref: Documentation<40>-Footnote-264768164
Ref: Documentation<40>-Footnote-274768230
Ref: Documentation<40>-Footnote-284768296
Ref: Documentation<40>-Footnote-294768362
Ref: Documentation<40>-Footnote-304768428
Ref: Documentation<40>-Footnote-314768494
Ref: Documentation<40>-Footnote-324768560
Ref: Documentation<40>-Footnote-334768626
Ref: Documentation<40>-Footnote-344768692
Ref: Documentation<40>-Footnote-354768758
Node: Tests<42>4768824
Ref: whatsnew/changelog id4024768934
Ref: 193f4768934
Ref: Tests<42>-Footnote-14777015
Ref: Tests<42>-Footnote-24777080
Ref: Tests<42>-Footnote-34777145
Ref: Tests<42>-Footnote-44777210
Ref: Tests<42>-Footnote-54777275
Ref: Tests<42>-Footnote-64777340
Ref: Tests<42>-Footnote-74777405
Ref: Tests<42>-Footnote-84777470
Ref: Tests<42>-Footnote-94777535
Ref: Tests<42>-Footnote-104777600
Ref: Tests<42>-Footnote-114777666
Ref: Tests<42>-Footnote-124777732
Ref: Tests<42>-Footnote-134777798
Ref: Tests<42>-Footnote-144777864
Ref: Tests<42>-Footnote-154777930
Ref: Tests<42>-Footnote-164777996
Ref: Tests<42>-Footnote-174778062
Ref: Tests<42>-Footnote-184778128
Ref: Tests<42>-Footnote-194778194
Ref: Tests<42>-Footnote-204778260
Ref: Tests<42>-Footnote-214778326
Ref: Tests<42>-Footnote-224778392
Ref: Tests<42>-Footnote-234778458
Ref: Tests<42>-Footnote-244778524
Ref: Tests<42>-Footnote-254778590
Ref: Tests<42>-Footnote-264778656
Ref: Tests<42>-Footnote-274778722
Ref: Tests<42>-Footnote-284778788
Ref: Tests<42>-Footnote-294778854
Ref: Tests<42>-Footnote-304778920
Ref: Tests<42>-Footnote-314778986
Ref: Tests<42>-Footnote-324779052
Ref: Tests<42>-Footnote-334779118
Ref: Tests<42>-Footnote-344779184
Ref: Tests<42>-Footnote-354779250
Ref: Tests<42>-Footnote-364779316
Ref: Tests<42>-Footnote-374779382
Ref: Tests<42>-Footnote-384779448
Ref: Tests<42>-Footnote-394779514
Ref: Tests<42>-Footnote-404779580
Ref: Tests<42>-Footnote-414779646
Ref: Tests<42>-Footnote-424779712
Ref: Tests<42>-Footnote-434779778
Ref: Tests<42>-Footnote-444779844
Ref: Tests<42>-Footnote-454779910
Ref: Tests<42>-Footnote-464779976
Ref: Tests<42>-Footnote-474780042
Ref: Tests<42>-Footnote-484780108
Node: Build<45>4780174
Ref: whatsnew/changelog id4034780278
Ref: 19454780278
Ref: Build<45>-Footnote-14784078
Ref: Build<45>-Footnote-24784143
Ref: Build<45>-Footnote-34784208
Ref: Build<45>-Footnote-44784273
Ref: Build<45>-Footnote-54784338
Ref: Build<45>-Footnote-64784403
Ref: Build<45>-Footnote-74784468
Ref: Build<45>-Footnote-84784533
Ref: Build<45>-Footnote-94784598
Ref: Build<45>-Footnote-104784663
Ref: Build<45>-Footnote-114784729
Ref: Build<45>-Footnote-124784795
Ref: Build<45>-Footnote-134784861
Ref: Build<45>-Footnote-144784927
Ref: Build<45>-Footnote-154784993
Ref: Build<45>-Footnote-164785059
Node: Windows<40>4785125
Ref: whatsnew/changelog id4044785229
Ref: 19474785229
Ref: Windows<40>-Footnote-14790131
Ref: Windows<40>-Footnote-24790196
Ref: Windows<40>-Footnote-34790261
Ref: Windows<40>-Footnote-44790326
Ref: Windows<40>-Footnote-54790391
Ref: Windows<40>-Footnote-64790456
Ref: Windows<40>-Footnote-74790521
Ref: Windows<40>-Footnote-84790586
Ref: Windows<40>-Footnote-94790651
Ref: Windows<40>-Footnote-104790716
Ref: Windows<40>-Footnote-114790782
Ref: Windows<40>-Footnote-124790848
Ref: Windows<40>-Footnote-134790914
Ref: Windows<40>-Footnote-144790980
Ref: Windows<40>-Footnote-154791046
Ref: Windows<40>-Footnote-164791112
Ref: Windows<40>-Footnote-174791178
Ref: Windows<40>-Footnote-184791244
Ref: Windows<40>-Footnote-194791310
Ref: Windows<40>-Footnote-204791376
Ref: Windows<40>-Footnote-214791442
Ref: Windows<40>-Footnote-224791508
Ref: Windows<40>-Footnote-234791574
Ref: Windows<40>-Footnote-244791639
Ref: Windows<40>-Footnote-254791704
Ref: Windows<40>-Footnote-264791770
Ref: Windows<40>-Footnote-274791836
Ref: Windows<40>-Footnote-284791902
Ref: Windows<40>-Footnote-294791968
Ref: Windows<40>-Footnote-304792034
Ref: Windows<40>-Footnote-314792100
Ref: Windows<40>-Footnote-324792166
Ref: Windows<40>-Footnote-334792232
Ref: Windows<40>-Footnote-344792298
Ref: Windows<40>-Footnote-354792364
Ref: Windows<40>-Footnote-364792430
Ref: Windows<40>-Footnote-374792496
Ref: Windows<40>-Footnote-384792562
Ref: Windows<40>-Footnote-394792628
Ref: Windows<40>-Footnote-404792694
Ref: Windows<40>-Footnote-414792760
Ref: Windows<40>-Footnote-424792826
Node: macOS<34>4792892
Ref: whatsnew/changelog id4054792995
Ref: 194a4792995
Ref: macOS<34>-Footnote-14793828
Ref: macOS<34>-Footnote-24793893
Ref: macOS<34>-Footnote-34793958
Ref: macOS<34>-Footnote-44794023
Ref: macOS<34>-Footnote-54794088
Ref: macOS<34>-Footnote-64794153
Node: IDLE<32>4794218
Ref: whatsnew/changelog id4064794325
Ref: 194b4794325
Ref: IDLE<32>-Footnote-14799027
Ref: IDLE<32>-Footnote-24799092
Ref: IDLE<32>-Footnote-34799156
Ref: IDLE<32>-Footnote-44799221
Ref: IDLE<32>-Footnote-54799286
Ref: IDLE<32>-Footnote-64799351
Ref: IDLE<32>-Footnote-74799416
Ref: IDLE<32>-Footnote-84799481
Ref: IDLE<32>-Footnote-94799546
Ref: IDLE<32>-Footnote-104799611
Ref: IDLE<32>-Footnote-114799677
Ref: IDLE<32>-Footnote-124799743
Ref: IDLE<32>-Footnote-134799809
Ref: IDLE<32>-Footnote-144799875
Ref: IDLE<32>-Footnote-154799941
Ref: IDLE<32>-Footnote-164800007
Ref: IDLE<32>-Footnote-174800073
Ref: IDLE<32>-Footnote-184800139
Ref: IDLE<32>-Footnote-194800205
Ref: IDLE<32>-Footnote-204800271
Ref: IDLE<32>-Footnote-214800337
Ref: IDLE<32>-Footnote-224800403
Ref: IDLE<32>-Footnote-234800469
Ref: IDLE<32>-Footnote-244800535
Ref: IDLE<32>-Footnote-254800601
Ref: IDLE<32>-Footnote-264800667
Ref: IDLE<32>-Footnote-274800733
Ref: IDLE<32>-Footnote-284800799
Ref: IDLE<32>-Footnote-294800865
Ref: IDLE<32>-Footnote-304800930
Node: Tools/Demos<20>4800996
Ref: whatsnew/changelog id4074801103
Ref: 194c4801103
Ref: Tools/Demos<20>-Footnote-14802098
Ref: Tools/Demos<20>-Footnote-24802163
Ref: Tools/Demos<20>-Footnote-34802228
Ref: Tools/Demos<20>-Footnote-44802293
Ref: Tools/Demos<20>-Footnote-54802358
Ref: Tools/Demos<20>-Footnote-64802423
Ref: Tools/Demos<20>-Footnote-74802488
Ref: Tools/Demos<20>-Footnote-84802553
Node: C API<44>4802618
Ref: whatsnew/changelog id4084802708
Ref: 194e4802708
Ref: C API<44>-Footnote-14808101
Ref: C API<44>-Footnote-24808166
Ref: C API<44>-Footnote-34808231
Ref: C API<44>-Footnote-44808296
Ref: C API<44>-Footnote-54808361
Ref: C API<44>-Footnote-64808426
Ref: C API<44>-Footnote-74808491
Ref: C API<44>-Footnote-84808556
Ref: C API<44>-Footnote-94808621
Ref: C API<44>-Footnote-104808686
Ref: C API<44>-Footnote-114808752
Ref: C API<44>-Footnote-124808818
Ref: C API<44>-Footnote-134808884
Ref: C API<44>-Footnote-144808950
Ref: C API<44>-Footnote-154808993
Ref: C API<44>-Footnote-164809059
Ref: C API<44>-Footnote-174809125
Ref: C API<44>-Footnote-184809191
Ref: C API<44>-Footnote-194809257
Ref: C API<44>-Footnote-204809323
Ref: C API<44>-Footnote-214809389
Ref: C API<44>-Footnote-224809455
Ref: C API<44>-Footnote-234809521
Ref: C API<44>-Footnote-244809587
Ref: C API<44>-Footnote-254809653
Ref: C API<44>-Footnote-264809719
Ref: C API<44>-Footnote-274809785
Ref: C API<44>-Footnote-284809851
Ref: C API<44>-Footnote-294809917
Ref: C API<44>-Footnote-304809983
Ref: C API<44>-Footnote-314810049
Ref: C API<44>-Footnote-324810115
Ref: C API<44>-Footnote-334810181
Ref: C API<44>-Footnote-344810247
Node: Python 3 8 0 beta 14810313
Ref: whatsnew/changelog python-3-8-0-beta-14810439
Ref: 19524810439
Node: Security<31>4810818
Ref: whatsnew/changelog id4094810916
Ref: 19534810916
Ref: Security<31>-Footnote-14811509
Ref: Security<31>-Footnote-24811574
Ref: Security<31>-Footnote-34811629
Ref: Security<31>-Footnote-44811694
Node: Core and Builtins<47>4811759
Ref: whatsnew/changelog id4104811877
Ref: 19544811877
Ref: Core and Builtins<47>-Footnote-14819917
Ref: Core and Builtins<47>-Footnote-24819982
Ref: Core and Builtins<47>-Footnote-34820047
Ref: Core and Builtins<47>-Footnote-44820112
Ref: Core and Builtins<47>-Footnote-54820177
Ref: Core and Builtins<47>-Footnote-64820242
Ref: Core and Builtins<47>-Footnote-74820307
Ref: Core and Builtins<47>-Footnote-84820372
Ref: Core and Builtins<47>-Footnote-94820437
Ref: Core and Builtins<47>-Footnote-104820502
Ref: Core and Builtins<47>-Footnote-114820568
Ref: Core and Builtins<47>-Footnote-124820634
Ref: Core and Builtins<47>-Footnote-134820700
Ref: Core and Builtins<47>-Footnote-144820766
Ref: Core and Builtins<47>-Footnote-154820832
Ref: Core and Builtins<47>-Footnote-164820898
Ref: Core and Builtins<47>-Footnote-174820964
Ref: Core and Builtins<47>-Footnote-184821030
Ref: Core and Builtins<47>-Footnote-194821095
Ref: Core and Builtins<47>-Footnote-204821161
Ref: Core and Builtins<47>-Footnote-214821227
Ref: Core and Builtins<47>-Footnote-224821293
Ref: Core and Builtins<47>-Footnote-234821358
Ref: Core and Builtins<47>-Footnote-244821424
Ref: Core and Builtins<47>-Footnote-254821490
Ref: Core and Builtins<47>-Footnote-264821556
Ref: Core and Builtins<47>-Footnote-274821622
Ref: Core and Builtins<47>-Footnote-284821688
Ref: Core and Builtins<47>-Footnote-294821754
Ref: Core and Builtins<47>-Footnote-304821820
Ref: Core and Builtins<47>-Footnote-314821886
Ref: Core and Builtins<47>-Footnote-324821952
Ref: Core and Builtins<47>-Footnote-334822018
Ref: Core and Builtins<47>-Footnote-344822084
Ref: Core and Builtins<47>-Footnote-354822150
Ref: Core and Builtins<47>-Footnote-364822216
Ref: Core and Builtins<47>-Footnote-374822282
Ref: Core and Builtins<47>-Footnote-384822348
Ref: Core and Builtins<47>-Footnote-394822414
Ref: Core and Builtins<47>-Footnote-404822480
Ref: Core and Builtins<47>-Footnote-414822546
Ref: Core and Builtins<47>-Footnote-424822612
Ref: Core and Builtins<47>-Footnote-434822678
Ref: Core and Builtins<47>-Footnote-444822744
Node: Library<46>4822810
Ref: whatsnew/changelog id4114822933
Ref: 19574822933
Ref: Library<46>-Footnote-14841171
Ref: Library<46>-Footnote-24841236
Ref: Library<46>-Footnote-34841301
Ref: Library<46>-Footnote-44841366
Ref: Library<46>-Footnote-54841431
Ref: Library<46>-Footnote-64841496
Ref: Library<46>-Footnote-74841561
Ref: Library<46>-Footnote-84841626
Ref: Library<46>-Footnote-94841691
Ref: Library<46>-Footnote-104841756
Ref: Library<46>-Footnote-114841822
Ref: Library<46>-Footnote-124841888
Ref: Library<46>-Footnote-134841954
Ref: Library<46>-Footnote-144842020
Ref: Library<46>-Footnote-154842086
Ref: Library<46>-Footnote-164842152
Ref: Library<46>-Footnote-174842218
Ref: Library<46>-Footnote-184842284
Ref: Library<46>-Footnote-194842350
Ref: Library<46>-Footnote-204842416
Ref: Library<46>-Footnote-214842482
Ref: Library<46>-Footnote-224842548
Ref: Library<46>-Footnote-234842614
Ref: Library<46>-Footnote-244842680
Ref: Library<46>-Footnote-254842748
Ref: Library<46>-Footnote-264842814
Ref: Library<46>-Footnote-274842880
Ref: Library<46>-Footnote-284842946
Ref: Library<46>-Footnote-294843012
Ref: Library<46>-Footnote-304843078
Ref: Library<46>-Footnote-314843144
Ref: Library<46>-Footnote-324843210
Ref: Library<46>-Footnote-334843276
Ref: Library<46>-Footnote-344843342
Ref: Library<46>-Footnote-354843408
Ref: Library<46>-Footnote-364843474
Ref: Library<46>-Footnote-374843540
Ref: Library<46>-Footnote-384843606
Ref: Library<46>-Footnote-394843672
Ref: Library<46>-Footnote-404843738
Ref: Library<46>-Footnote-414843804
Ref: Library<46>-Footnote-424843870
Ref: Library<46>-Footnote-434843936
Ref: Library<46>-Footnote-444844002
Ref: Library<46>-Footnote-454844068
Ref: Library<46>-Footnote-464844134
Ref: Library<46>-Footnote-474844200
Ref: Library<46>-Footnote-484844266
Ref: Library<46>-Footnote-494844332
Ref: Library<46>-Footnote-504844398
Ref: Library<46>-Footnote-514844464
Ref: Library<46>-Footnote-524844530
Ref: Library<46>-Footnote-534844596
Ref: Library<46>-Footnote-544844662
Ref: Library<46>-Footnote-554844728
Ref: Library<46>-Footnote-564844794
Ref: Library<46>-Footnote-574844860
Ref: Library<46>-Footnote-584844926
Ref: Library<46>-Footnote-594844992
Ref: Library<46>-Footnote-604845058
Ref: Library<46>-Footnote-614845124
Ref: Library<46>-Footnote-624845190
Ref: Library<46>-Footnote-634845256
Ref: Library<46>-Footnote-644845322
Ref: Library<46>-Footnote-654845388
Ref: Library<46>-Footnote-664845454
Ref: Library<46>-Footnote-674845520
Ref: Library<46>-Footnote-684845586
Ref: Library<46>-Footnote-694845651
Ref: Library<46>-Footnote-704845717
Ref: Library<46>-Footnote-714845782
Ref: Library<46>-Footnote-724845848
Ref: Library<46>-Footnote-734845914
Ref: Library<46>-Footnote-744845980
Ref: Library<46>-Footnote-754846046
Ref: Library<46>-Footnote-764846112
Ref: Library<46>-Footnote-774846178
Ref: Library<46>-Footnote-784846244
Ref: Library<46>-Footnote-794846310
Ref: Library<46>-Footnote-804846376
Ref: Library<46>-Footnote-814846442
Ref: Library<46>-Footnote-824846508
Ref: Library<46>-Footnote-834846574
Ref: Library<46>-Footnote-844846640
Ref: Library<46>-Footnote-854846706
Ref: Library<46>-Footnote-864846772
Ref: Library<46>-Footnote-874846838
Ref: Library<46>-Footnote-884846904
Ref: Library<46>-Footnote-894846970
Ref: Library<46>-Footnote-904847036
Ref: Library<46>-Footnote-914847102
Ref: Library<46>-Footnote-924847168
Ref: Library<46>-Footnote-934847234
Ref: Library<46>-Footnote-944847300
Ref: Library<46>-Footnote-954847366
Ref: Library<46>-Footnote-964847432
Ref: Library<46>-Footnote-974847498
Ref: Library<46>-Footnote-984847564
Ref: Library<46>-Footnote-994847630
Ref: Library<46>-Footnote-1004847696
Ref: Library<46>-Footnote-1014847763
Ref: Library<46>-Footnote-1024847830
Ref: Library<46>-Footnote-1034847897
Ref: Library<46>-Footnote-1044847964
Ref: Library<46>-Footnote-1054848031
Ref: Library<46>-Footnote-1064848098
Ref: Library<46>-Footnote-1074848165
Node: Documentation<41>4848232
Ref: whatsnew/changelog id4124848343
Ref: 195f4848343
Ref: Documentation<41>-Footnote-14850419
Ref: Documentation<41>-Footnote-24850484
Ref: Documentation<41>-Footnote-34850549
Ref: Documentation<41>-Footnote-44850614
Ref: Documentation<41>-Footnote-54850679
Ref: Documentation<41>-Footnote-64850744
Ref: Documentation<41>-Footnote-74850809
Ref: Documentation<41>-Footnote-84850874
Ref: Documentation<41>-Footnote-94850939
Ref: Documentation<41>-Footnote-104851004
Ref: Documentation<41>-Footnote-114851070
Ref: Documentation<41>-Footnote-124851136
Ref: Documentation<41>-Footnote-134851202
Ref: Documentation<41>-Footnote-144851268
Node: Tests<43>4851334
Ref: whatsnew/changelog id4134851443
Ref: 19604851443
Ref: Tests<43>-Footnote-14853075
Ref: Tests<43>-Footnote-24853140
Ref: Tests<43>-Footnote-34853205
Ref: Tests<43>-Footnote-44853270
Ref: Tests<43>-Footnote-54853335
Ref: Tests<43>-Footnote-64853400
Ref: Tests<43>-Footnote-74853465
Ref: Tests<43>-Footnote-84853530
Ref: Tests<43>-Footnote-94853595
Ref: Tests<43>-Footnote-104853660
Node: Build<46>4853726
Ref: whatsnew/changelog id4144853829
Ref: 19624853829
Ref: Build<46>-Footnote-14855041
Ref: Build<46>-Footnote-24855106
Node: Windows<41>4855171
Ref: whatsnew/changelog id4154855274
Ref: 19634855274
Ref: Windows<41>-Footnote-14855706
Ref: Windows<41>-Footnote-24855771
Ref: Windows<41>-Footnote-34855836
Ref: Windows<41>-Footnote-44855901
Node: macOS<35>4855966
Ref: whatsnew/changelog id4164856068
Ref: 19644856068
Ref: macOS<35>-Footnote-14856370
Node: IDLE<33>4856435
Ref: whatsnew/changelog id4174856541
Ref: 19654856541
Ref: IDLE<33>-Footnote-14857143
Ref: IDLE<33>-Footnote-24857208
Ref: IDLE<33>-Footnote-34857273
Ref: IDLE<33>-Footnote-44857338
Ref: IDLE<33>-Footnote-54857403
Ref: IDLE<33>-Footnote-64857468
Node: Tools/Demos<21>4857533
Ref: whatsnew/changelog id4184857639
Ref: 19664857639
Ref: Tools/Demos<21>-Footnote-14857838
Node: C API<45>4857903
Ref: whatsnew/changelog id4194857992
Ref: 19674857992
Ref: C API<45>-Footnote-14859328
Ref: C API<45>-Footnote-24859393
Ref: C API<45>-Footnote-34859435
Ref: C API<45>-Footnote-44859500
Ref: C API<45>-Footnote-54859565
Ref: C API<45>-Footnote-64859630
Ref: C API<45>-Footnote-74859672
Ref: C API<45>-Footnote-84859737
Ref: C API<45>-Footnote-94859802
Node: Python 3 8 0 alpha 44859867
Ref: whatsnew/changelog python-3-8-0-alpha-44859993
Ref: 19694859993
Node: Security<32>4860374
Ref: whatsnew/changelog id4204860473
Ref: 196a4860473
Ref: Security<32>-Footnote-14861358
Ref: Security<32>-Footnote-24861423
Ref: Security<32>-Footnote-34861488
Ref: Security<32>-Footnote-44861543
Node: Core and Builtins<48>4861608
Ref: whatsnew/changelog id4214861727
Ref: 196b4861727
Ref: Core and Builtins<48>-Footnote-14864994
Ref: Core and Builtins<48>-Footnote-24865059
Ref: Core and Builtins<48>-Footnote-34865124
Ref: Core and Builtins<48>-Footnote-44865189
Ref: Core and Builtins<48>-Footnote-54865254
Ref: Core and Builtins<48>-Footnote-64865319
Ref: Core and Builtins<48>-Footnote-74865384
Ref: Core and Builtins<48>-Footnote-84865449
Ref: Core and Builtins<48>-Footnote-94865514
Ref: Core and Builtins<48>-Footnote-104865556
Ref: Core and Builtins<48>-Footnote-114865622
Ref: Core and Builtins<48>-Footnote-124865688
Ref: Core and Builtins<48>-Footnote-134865754
Ref: Core and Builtins<48>-Footnote-144865820
Ref: Core and Builtins<48>-Footnote-154865886
Ref: Core and Builtins<48>-Footnote-164865952
Ref: Core and Builtins<48>-Footnote-174866018
Ref: Core and Builtins<48>-Footnote-184866084
Ref: Core and Builtins<48>-Footnote-194866150
Ref: Core and Builtins<48>-Footnote-204866216
Node: Library<47>4866282
Ref: whatsnew/changelog id4224866406
Ref: 196c4866406
Ref: Library<47>-Footnote-14875706
Ref: Library<47>-Footnote-24875771
Ref: Library<47>-Footnote-34875836
Ref: Library<47>-Footnote-44875901
Ref: Library<47>-Footnote-54875968
Ref: Library<47>-Footnote-64876033
Ref: Library<47>-Footnote-74876098
Ref: Library<47>-Footnote-84876163
Ref: Library<47>-Footnote-94876228
Ref: Library<47>-Footnote-104876293
Ref: Library<47>-Footnote-114876359
Ref: Library<47>-Footnote-124876425
Ref: Library<47>-Footnote-134876491
Ref: Library<47>-Footnote-144876557
Ref: Library<47>-Footnote-154876623
Ref: Library<47>-Footnote-164876689
Ref: Library<47>-Footnote-174876755
Ref: Library<47>-Footnote-184876821
Ref: Library<47>-Footnote-194876887
Ref: Library<47>-Footnote-204876953
Ref: Library<47>-Footnote-214877019
Ref: Library<47>-Footnote-224877085
Ref: Library<47>-Footnote-234877151
Ref: Library<47>-Footnote-244877217
Ref: Library<47>-Footnote-254877283
Ref: Library<47>-Footnote-264877349
Ref: Library<47>-Footnote-274877415
Ref: Library<47>-Footnote-284877481
Ref: Library<47>-Footnote-294877547
Ref: Library<47>-Footnote-304877613
Ref: Library<47>-Footnote-314877679
Ref: Library<47>-Footnote-324877745
Ref: Library<47>-Footnote-334877811
Ref: Library<47>-Footnote-344877877
Ref: Library<47>-Footnote-354877943
Ref: Library<47>-Footnote-364878009
Ref: Library<47>-Footnote-374878075
Ref: Library<47>-Footnote-384878141
Ref: Library<47>-Footnote-394878207
Ref: Library<47>-Footnote-404878273
Ref: Library<47>-Footnote-414878339
Ref: Library<47>-Footnote-424878405
Ref: Library<47>-Footnote-434878471
Ref: Library<47>-Footnote-444878537
Ref: Library<47>-Footnote-454878603
Ref: Library<47>-Footnote-464878669
Ref: Library<47>-Footnote-474878735
Ref: Library<47>-Footnote-484878801
Ref: Library<47>-Footnote-494878867
Ref: Library<47>-Footnote-504878933
Ref: Library<47>-Footnote-514878999
Ref: Library<47>-Footnote-524879065
Ref: Library<47>-Footnote-534879131
Ref: Library<47>-Footnote-544879197
Node: Documentation<42>4879263
Ref: whatsnew/changelog id4234879375
Ref: 19704879375
Ref: Documentation<42>-Footnote-14880806
Ref: Documentation<42>-Footnote-24880871
Ref: Documentation<42>-Footnote-34880936
Ref: Documentation<42>-Footnote-44881001
Ref: Documentation<42>-Footnote-54881066
Ref: Documentation<42>-Footnote-64881105
Ref: Documentation<42>-Footnote-74881170
Ref: Documentation<42>-Footnote-84881235
Ref: Documentation<42>-Footnote-94881300
Ref: Documentation<42>-Footnote-104881365
Ref: Documentation<42>-Footnote-114881431
Ref: Documentation<42>-Footnote-124881497
Node: Tests<44>4881563
Ref: whatsnew/changelog id4244881673
Ref: 19714881673
Ref: Tests<44>-Footnote-14883923
Ref: Tests<44>-Footnote-24883988
Ref: Tests<44>-Footnote-34884053
Ref: Tests<44>-Footnote-44884118
Ref: Tests<44>-Footnote-54884183
Ref: Tests<44>-Footnote-64884248
Ref: Tests<44>-Footnote-74884313
Ref: Tests<44>-Footnote-84884378
Ref: Tests<44>-Footnote-94884443
Ref: Tests<44>-Footnote-104884508
Ref: Tests<44>-Footnote-114884574
Ref: Tests<44>-Footnote-124884640
Ref: Tests<44>-Footnote-134884706
Ref: Tests<44>-Footnote-144884772
Ref: Tests<44>-Footnote-154884838
Node: Build<47>4884904
Ref: whatsnew/changelog id4254885008
Ref: 19734885008
Ref: Build<47>-Footnote-14888167
Ref: Build<47>-Footnote-24888232
Ref: Build<47>-Footnote-34888297
Ref: Build<47>-Footnote-44888362
Ref: Build<47>-Footnote-54888427
Ref: Build<47>-Footnote-64888492
Ref: Build<47>-Footnote-74888557
Ref: Build<47>-Footnote-84888622
Ref: Build<47>-Footnote-94888687
Ref: Build<47>-Footnote-104888752
Ref: Build<47>-Footnote-114888818
Ref: Build<47>-Footnote-124888884
Ref: Build<47>-Footnote-134888950
Node: Windows<42>4889016
Ref: whatsnew/changelog id4264889120
Ref: 19744889120
Ref: Windows<42>-Footnote-14891768
Ref: Windows<42>-Footnote-24891833
Ref: Windows<42>-Footnote-34891898
Ref: Windows<42>-Footnote-44891963
Ref: Windows<42>-Footnote-54892028
Ref: Windows<42>-Footnote-64892093
Ref: Windows<42>-Footnote-74892158
Ref: Windows<42>-Footnote-84892223
Ref: Windows<42>-Footnote-94892288
Ref: Windows<42>-Footnote-104892353
Ref: Windows<42>-Footnote-114892419
Ref: Windows<42>-Footnote-124892485
Node: macOS<36>4892551
Ref: whatsnew/changelog id4274892654
Ref: 19754892654
Ref: macOS<36>-Footnote-14892968
Ref: macOS<36>-Footnote-24893033
Node: IDLE<34>4893098
Ref: whatsnew/changelog id4284893205
Ref: 19764893205
Ref: IDLE<34>-Footnote-14893448
Node: Tools/Demos<22>4893513
Ref: whatsnew/changelog id4294893620
Ref: 19774893620
Ref: Tools/Demos<22>-Footnote-14893774
Node: C API<46>4893839
Ref: whatsnew/changelog id4304893929
Ref: 19784893929
Ref: C API<46>-Footnote-14895919
Ref: C API<46>-Footnote-24895984
Ref: C API<46>-Footnote-34896049
Ref: C API<46>-Footnote-44896114
Ref: C API<46>-Footnote-54896179
Ref: C API<46>-Footnote-64896244
Node: Python 3 8 0 alpha 34896309
Ref: whatsnew/changelog python-3-8-0-alpha-34896436
Ref: 197a4896436
Node: Security<33>4896797
Ref: whatsnew/changelog id4314896896
Ref: 197b4896896
Ref: Security<33>-Footnote-14897458
Ref: Security<33>-Footnote-24897523
Node: Core and Builtins<49>4897588
Ref: whatsnew/changelog id4324897707
Ref: 197d4897707
Ref: Core and Builtins<49>-Footnote-14901287
Ref: Core and Builtins<49>-Footnote-24901352
Ref: Core and Builtins<49>-Footnote-34901417
Ref: Core and Builtins<49>-Footnote-44901482
Ref: Core and Builtins<49>-Footnote-54901547
Ref: Core and Builtins<49>-Footnote-64901612
Ref: Core and Builtins<49>-Footnote-74901677
Ref: Core and Builtins<49>-Footnote-84901742
Ref: Core and Builtins<49>-Footnote-94901807
Ref: Core and Builtins<49>-Footnote-104901872
Ref: Core and Builtins<49>-Footnote-114901938
Ref: Core and Builtins<49>-Footnote-124902004
Ref: Core and Builtins<49>-Footnote-134902070
Ref: Core and Builtins<49>-Footnote-144902136
Ref: Core and Builtins<49>-Footnote-154902202
Ref: Core and Builtins<49>-Footnote-164902268
Ref: Core and Builtins<49>-Footnote-174902334
Ref: Core and Builtins<49>-Footnote-184902400
Ref: Core and Builtins<49>-Footnote-194902466
Ref: Core and Builtins<49>-Footnote-204902532
Ref: Core and Builtins<49>-Footnote-214902598
Ref: Core and Builtins<49>-Footnote-224902664
Node: Library<48>4902730
Ref: whatsnew/changelog id4334902854
Ref: 197f4902854
Ref: Library<48>-Footnote-14908423
Ref: Library<48>-Footnote-24908488
Ref: Library<48>-Footnote-34908553
Ref: Library<48>-Footnote-44908618
Ref: Library<48>-Footnote-54908683
Ref: Library<48>-Footnote-64908748
Ref: Library<48>-Footnote-74908813
Ref: Library<48>-Footnote-84908878
Ref: Library<48>-Footnote-94908943
Ref: Library<48>-Footnote-104909008
Ref: Library<48>-Footnote-114909074
Ref: Library<48>-Footnote-124909140
Ref: Library<48>-Footnote-134909206
Ref: Library<48>-Footnote-144909272
Ref: Library<48>-Footnote-154909338
Ref: Library<48>-Footnote-164909404
Ref: Library<48>-Footnote-174909470
Ref: Library<48>-Footnote-184909536
Ref: Library<48>-Footnote-194909602
Ref: Library<48>-Footnote-204909668
Ref: Library<48>-Footnote-214909734
Ref: Library<48>-Footnote-224909800
Ref: Library<48>-Footnote-234909866
Ref: Library<48>-Footnote-244909932
Ref: Library<48>-Footnote-254909998
Ref: Library<48>-Footnote-264910064
Ref: Library<48>-Footnote-274910130
Ref: Library<48>-Footnote-284910196
Ref: Library<48>-Footnote-294910262
Ref: Library<48>-Footnote-304910328
Ref: Library<48>-Footnote-314910394
Ref: Library<48>-Footnote-324910460
Ref: Library<48>-Footnote-334910526
Ref: Library<48>-Footnote-344910592
Ref: Library<48>-Footnote-354910658
Ref: Library<48>-Footnote-364910724
Ref: Library<48>-Footnote-374910790
Node: Documentation<43>4910856
Ref: whatsnew/changelog id4344910968
Ref: 19814910968
Ref: Documentation<43>-Footnote-14911539
Ref: Documentation<43>-Footnote-24911604
Ref: Documentation<43>-Footnote-34911669
Node: Tests<45>4911734
Ref: whatsnew/changelog id4354911844
Ref: 19824911844
Ref: Tests<45>-Footnote-14912356
Ref: Tests<45>-Footnote-24912421
Ref: Tests<45>-Footnote-34912486
Node: Build<48>4912551
Ref: whatsnew/changelog id4364912655
Ref: 19834912655
Ref: Build<48>-Footnote-14913175
Ref: Build<48>-Footnote-24913240
Ref: Build<48>-Footnote-34913305
Ref: Build<48>-Footnote-44913370
Node: Windows<43>4913435
Ref: whatsnew/changelog id4374913538
Ref: 19844913538
Ref: Windows<43>-Footnote-14913987
Ref: Windows<43>-Footnote-24914052
Ref: Windows<43>-Footnote-34914117
Node: IDLE<35>4914182
Ref: whatsnew/changelog id4384914291
Ref: 19854914291
Ref: IDLE<35>-Footnote-14915400
Ref: IDLE<35>-Footnote-24915465
Ref: IDLE<35>-Footnote-34915530
Ref: IDLE<35>-Footnote-44915595
Ref: IDLE<35>-Footnote-54915660
Ref: IDLE<35>-Footnote-64915725
Ref: IDLE<35>-Footnote-74915790
Ref: IDLE<35>-Footnote-84915855
Ref: IDLE<35>-Footnote-94915920
Node: Tools/Demos<23>4915985
Ref: whatsnew/changelog id4394916092
Ref: 19864916092
Ref: Tools/Demos<23>-Footnote-14916305
Ref: Tools/Demos<23>-Footnote-24916370
Node: C API<47>4916435
Ref: whatsnew/changelog id4404916525
Ref: 19874916525
Ref: C API<47>-Footnote-14916913
Ref: C API<47>-Footnote-24916978
Node: Python 3 8 0 alpha 24917043
Ref: whatsnew/changelog python-3-8-0-alpha-24917170
Ref: 19884917170
Node: Core and Builtins<50>4917433
Ref: whatsnew/changelog id4414917531
Ref: 19894917531
Ref: Core and Builtins<50>-Footnote-14920670
Ref: Core and Builtins<50>-Footnote-24920735
Ref: Core and Builtins<50>-Footnote-34920800
Ref: Core and Builtins<50>-Footnote-44920865
Ref: Core and Builtins<50>-Footnote-54920930
Ref: Core and Builtins<50>-Footnote-64920997
Ref: Core and Builtins<50>-Footnote-74921062
Ref: Core and Builtins<50>-Footnote-84921127
Ref: Core and Builtins<50>-Footnote-94921192
Ref: Core and Builtins<50>-Footnote-104921257
Ref: Core and Builtins<50>-Footnote-114921323
Ref: Core and Builtins<50>-Footnote-124921389
Ref: Core and Builtins<50>-Footnote-134921455
Ref: Core and Builtins<50>-Footnote-144921521
Ref: Core and Builtins<50>-Footnote-154921587
Ref: Core and Builtins<50>-Footnote-164921653
Ref: Core and Builtins<50>-Footnote-174921719
Node: Library<49>4921785
Ref: whatsnew/changelog id4424921909
Ref: 198a4921909
Ref: Library<49>-Footnote-14925616
Ref: Library<49>-Footnote-24925681
Ref: Library<49>-Footnote-34925746
Ref: Library<49>-Footnote-44925811
Ref: Library<49>-Footnote-54925876
Ref: Library<49>-Footnote-64925941
Ref: Library<49>-Footnote-74926006
Ref: Library<49>-Footnote-84926071
Ref: Library<49>-Footnote-94926136
Ref: Library<49>-Footnote-104926201
Ref: Library<49>-Footnote-114926267
Ref: Library<49>-Footnote-124926333
Ref: Library<49>-Footnote-134926399
Ref: Library<49>-Footnote-144926465
Ref: Library<49>-Footnote-154926531
Ref: Library<49>-Footnote-164926597
Ref: Library<49>-Footnote-174926663
Node: Documentation<44>4926729
Ref: whatsnew/changelog id4434926841
Ref: 198d4926841
Ref: Documentation<44>-Footnote-14927217
Ref: Documentation<44>-Footnote-24927282
Ref: Documentation<44>-Footnote-34927347
Node: Tests<46>4927412
Ref: whatsnew/changelog id4444927524
Ref: 198e4927524
Ref: Tests<46>-Footnote-14928889
Ref: Tests<46>-Footnote-24928954
Ref: Tests<46>-Footnote-34929019
Ref: Tests<46>-Footnote-44929084
Ref: Tests<46>-Footnote-54929149
Ref: Tests<46>-Footnote-64929214
Ref: Tests<46>-Footnote-74929279
Ref: Tests<46>-Footnote-84929344
Node: Windows<44>4929409
Ref: whatsnew/changelog id4454929512
Ref: 198f4929512
Ref: Windows<44>-Footnote-14930109
Ref: Windows<44>-Footnote-24930174
Ref: Windows<44>-Footnote-34930239
Ref: Windows<44>-Footnote-44930304
Ref: Windows<44>-Footnote-54930369
Node: IDLE<36>4930434
Ref: whatsnew/changelog id4464930519
Ref: 19904930519
Ref: IDLE<36>-Footnote-14930823
Ref: IDLE<36>-Footnote-24930888
Ref: IDLE<36>-Footnote-34930953
Node: Python 3 8 0 alpha 14931018
Ref: whatsnew/changelog python-3-8-0-alpha-14931143
Ref: 19914931143
Node: Security<34>4931524
Ref: whatsnew/changelog id4474931623
Ref: 19924931623
Ref: Security<34>-Footnote-14933961
Ref: Security<34>-Footnote-24934026
Ref: Security<34>-Footnote-34934081
Ref: Security<34>-Footnote-44934146
Ref: Security<34>-Footnote-54934211
Ref: Security<34>-Footnote-64934276
Ref: Security<34>-Footnote-74934341
Ref: Security<34>-Footnote-84934397
Ref: Security<34>-Footnote-94934462
Ref: Security<34>-Footnote-104934527
Ref: Security<34>-Footnote-114934593
Ref: Security<34>-Footnote-124934659
Ref: Security<34>-Footnote-134934715
Ref: Security<34>-Footnote-144934781
Ref: Security<34>-Footnote-154934847
Ref: Security<34>-Footnote-164934903
Ref: Security<34>-Footnote-174934959
Node: Core and Builtins<51>4935025
Ref: whatsnew/changelog id4484935144
Ref: 19934935144
Ref: Core and Builtins<51>-Footnote-14961187
Ref: Core and Builtins<51>-Footnote-24961252
Ref: Core and Builtins<51>-Footnote-34961317
Ref: Core and Builtins<51>-Footnote-44961382
Ref: Core and Builtins<51>-Footnote-54961447
Ref: Core and Builtins<51>-Footnote-64961512
Ref: Core and Builtins<51>-Footnote-74961577
Ref: Core and Builtins<51>-Footnote-84961642
Ref: Core and Builtins<51>-Footnote-94961707
Ref: Core and Builtins<51>-Footnote-104961772
Ref: Core and Builtins<51>-Footnote-114961838
Ref: Core and Builtins<51>-Footnote-124961904
Ref: Core and Builtins<51>-Footnote-134961970
Ref: Core and Builtins<51>-Footnote-144962036
Ref: Core and Builtins<51>-Footnote-154962102
Ref: Core and Builtins<51>-Footnote-164962168
Ref: Core and Builtins<51>-Footnote-174962234
Ref: Core and Builtins<51>-Footnote-184962300
Ref: Core and Builtins<51>-Footnote-194962366
Ref: Core and Builtins<51>-Footnote-204962432
Ref: Core and Builtins<51>-Footnote-214962498
Ref: Core and Builtins<51>-Footnote-224962564
Ref: Core and Builtins<51>-Footnote-234962630
Ref: Core and Builtins<51>-Footnote-244962696
Ref: Core and Builtins<51>-Footnote-254962762
Ref: Core and Builtins<51>-Footnote-264962805
Ref: Core and Builtins<51>-Footnote-274962871
Ref: Core and Builtins<51>-Footnote-284962937
Ref: Core and Builtins<51>-Footnote-294963003
Ref: Core and Builtins<51>-Footnote-304963069
Ref: Core and Builtins<51>-Footnote-314963135
Ref: Core and Builtins<51>-Footnote-324963201
Ref: Core and Builtins<51>-Footnote-334963267
Ref: Core and Builtins<51>-Footnote-344963333
Ref: Core and Builtins<51>-Footnote-354963399
Ref: Core and Builtins<51>-Footnote-364963465
Ref: Core and Builtins<51>-Footnote-374963531
Ref: Core and Builtins<51>-Footnote-384963597
Ref: Core and Builtins<51>-Footnote-394963663
Ref: Core and Builtins<51>-Footnote-404963729
Ref: Core and Builtins<51>-Footnote-414963795
Ref: Core and Builtins<51>-Footnote-424963861
Ref: Core and Builtins<51>-Footnote-434963927
Ref: Core and Builtins<51>-Footnote-444963993
Ref: Core and Builtins<51>-Footnote-454964059
Ref: Core and Builtins<51>-Footnote-464964125
Ref: Core and Builtins<51>-Footnote-474964191
Ref: Core and Builtins<51>-Footnote-484964257
Ref: Core and Builtins<51>-Footnote-494964323
Ref: Core and Builtins<51>-Footnote-504964389
Ref: Core and Builtins<51>-Footnote-514964455
Ref: Core and Builtins<51>-Footnote-524964521
Ref: Core and Builtins<51>-Footnote-534964587
Ref: Core and Builtins<51>-Footnote-544964653
Ref: Core and Builtins<51>-Footnote-554964719
Ref: Core and Builtins<51>-Footnote-564964785
Ref: Core and Builtins<51>-Footnote-574964851
Ref: Core and Builtins<51>-Footnote-584964917
Ref: Core and Builtins<51>-Footnote-594964983
Ref: Core and Builtins<51>-Footnote-604965048
Ref: Core and Builtins<51>-Footnote-614965114
Ref: Core and Builtins<51>-Footnote-624965180
Ref: Core and Builtins<51>-Footnote-634965246
Ref: Core and Builtins<51>-Footnote-644965312
Ref: Core and Builtins<51>-Footnote-654965378
Ref: Core and Builtins<51>-Footnote-664965444
Ref: Core and Builtins<51>-Footnote-674965510
Ref: Core and Builtins<51>-Footnote-684965576
Ref: Core and Builtins<51>-Footnote-694965642
Ref: Core and Builtins<51>-Footnote-704965708
Ref: Core and Builtins<51>-Footnote-714965774
Ref: Core and Builtins<51>-Footnote-724965840
Ref: Core and Builtins<51>-Footnote-734965906
Ref: Core and Builtins<51>-Footnote-744965972
Ref: Core and Builtins<51>-Footnote-754966038
Ref: Core and Builtins<51>-Footnote-764966104
Ref: Core and Builtins<51>-Footnote-774966170
Ref: Core and Builtins<51>-Footnote-784966236
Ref: Core and Builtins<51>-Footnote-794966302
Ref: Core and Builtins<51>-Footnote-804966368
Ref: Core and Builtins<51>-Footnote-814966434
Ref: Core and Builtins<51>-Footnote-824966500
Ref: Core and Builtins<51>-Footnote-834966566
Ref: Core and Builtins<51>-Footnote-844966632
Ref: Core and Builtins<51>-Footnote-854966698
Ref: Core and Builtins<51>-Footnote-864966764
Ref: Core and Builtins<51>-Footnote-874966830
Ref: Core and Builtins<51>-Footnote-884966896
Ref: Core and Builtins<51>-Footnote-894966962
Ref: Core and Builtins<51>-Footnote-904967028
Ref: Core and Builtins<51>-Footnote-914967094
Ref: Core and Builtins<51>-Footnote-924967160
Ref: Core and Builtins<51>-Footnote-934967226
Ref: Core and Builtins<51>-Footnote-944967292
Ref: Core and Builtins<51>-Footnote-954967358
Ref: Core and Builtins<51>-Footnote-964967424
Ref: Core and Builtins<51>-Footnote-974967492
Ref: Core and Builtins<51>-Footnote-984967558
Ref: Core and Builtins<51>-Footnote-994967624
Ref: Core and Builtins<51>-Footnote-1004967690
Ref: Core and Builtins<51>-Footnote-1014967757
Ref: Core and Builtins<51>-Footnote-1024967824
Ref: Core and Builtins<51>-Footnote-1034967891
Ref: Core and Builtins<51>-Footnote-1044967958
Ref: Core and Builtins<51>-Footnote-1054968025
Ref: Core and Builtins<51>-Footnote-1064968092
Ref: Core and Builtins<51>-Footnote-1074968159
Ref: Core and Builtins<51>-Footnote-1084968226
Ref: Core and Builtins<51>-Footnote-1094968293
Ref: Core and Builtins<51>-Footnote-1104968360
Ref: Core and Builtins<51>-Footnote-1114968427
Ref: Core and Builtins<51>-Footnote-1124968494
Ref: Core and Builtins<51>-Footnote-1134968561
Ref: Core and Builtins<51>-Footnote-1144968628
Ref: Core and Builtins<51>-Footnote-1154968695
Ref: Core and Builtins<51>-Footnote-1164968762
Ref: Core and Builtins<51>-Footnote-1174968829
Ref: Core and Builtins<51>-Footnote-1184968896
Ref: Core and Builtins<51>-Footnote-1194968963
Ref: Core and Builtins<51>-Footnote-1204969030
Ref: Core and Builtins<51>-Footnote-1214969097
Ref: Core and Builtins<51>-Footnote-1224969164
Ref: Core and Builtins<51>-Footnote-1234969231
Ref: Core and Builtins<51>-Footnote-1244969298
Ref: Core and Builtins<51>-Footnote-1254969365
Ref: Core and Builtins<51>-Footnote-1264969432
Ref: Core and Builtins<51>-Footnote-1274969499
Ref: Core and Builtins<51>-Footnote-1284969566
Ref: Core and Builtins<51>-Footnote-1294969633
Ref: Core and Builtins<51>-Footnote-1304969700
Ref: Core and Builtins<51>-Footnote-1314969767
Ref: Core and Builtins<51>-Footnote-1324969834
Ref: Core and Builtins<51>-Footnote-1334969901
Ref: Core and Builtins<51>-Footnote-1344969968
Ref: Core and Builtins<51>-Footnote-1354970035
Ref: Core and Builtins<51>-Footnote-1364970102
Ref: Core and Builtins<51>-Footnote-1374970169
Ref: Core and Builtins<51>-Footnote-1384970236
Ref: Core and Builtins<51>-Footnote-1394970303
Ref: Core and Builtins<51>-Footnote-1404970370
Ref: Core and Builtins<51>-Footnote-1414970437
Ref: Core and Builtins<51>-Footnote-1424970504
Ref: Core and Builtins<51>-Footnote-1434970571
Ref: Core and Builtins<51>-Footnote-1444970638
Ref: Core and Builtins<51>-Footnote-1454970705
Ref: Core and Builtins<51>-Footnote-1464970772
Ref: Core and Builtins<51>-Footnote-1474970839
Ref: Core and Builtins<51>-Footnote-1484970906
Ref: Core and Builtins<51>-Footnote-1494970973
Ref: Core and Builtins<51>-Footnote-1504971040
Ref: Core and Builtins<51>-Footnote-1514971107
Ref: Core and Builtins<51>-Footnote-1524971174
Ref: Core and Builtins<51>-Footnote-1534971241
Ref: Core and Builtins<51>-Footnote-1544971308
Ref: Core and Builtins<51>-Footnote-1554971375
Ref: Core and Builtins<51>-Footnote-1564971442
Ref: Core and Builtins<51>-Footnote-1574971509
Ref: Core and Builtins<51>-Footnote-1584971576
Ref: Core and Builtins<51>-Footnote-1594971643
Ref: Core and Builtins<51>-Footnote-1604971710
Ref: Core and Builtins<51>-Footnote-1614971777
Ref: Core and Builtins<51>-Footnote-1624971844
Node: Library<50>4971911
Ref: whatsnew/changelog id4494972035
Ref: 19994972035
Ref: Library<50>-Footnote-15042931
Ref: Library<50>-Footnote-25042996
Ref: Library<50>-Footnote-35043061
Ref: Library<50>-Footnote-45043126
Ref: Library<50>-Footnote-55043191
Ref: Library<50>-Footnote-65043256
Ref: Library<50>-Footnote-75043321
Ref: Library<50>-Footnote-85043386
Ref: Library<50>-Footnote-95043451
Ref: Library<50>-Footnote-105043516
Ref: Library<50>-Footnote-115043582
Ref: Library<50>-Footnote-125043648
Ref: Library<50>-Footnote-135043714
Ref: Library<50>-Footnote-145043780
Ref: Library<50>-Footnote-155043846
Ref: Library<50>-Footnote-165043912
Ref: Library<50>-Footnote-175043978
Ref: Library<50>-Footnote-185044044
Ref: Library<50>-Footnote-195044110
Ref: Library<50>-Footnote-205044176
Ref: Library<50>-Footnote-215044242
Ref: Library<50>-Footnote-225044308
Ref: Library<50>-Footnote-235044374
Ref: Library<50>-Footnote-245044440
Ref: Library<50>-Footnote-255044506
Ref: Library<50>-Footnote-265044572
Ref: Library<50>-Footnote-275044638
Ref: Library<50>-Footnote-285044704
Ref: Library<50>-Footnote-295044770
Ref: Library<50>-Footnote-305044836
Ref: Library<50>-Footnote-315044902
Ref: Library<50>-Footnote-325044968
Ref: Library<50>-Footnote-335045034
Ref: Library<50>-Footnote-345045100
Ref: Library<50>-Footnote-355045166
Ref: Library<50>-Footnote-365045232
Ref: Library<50>-Footnote-375045298
Ref: Library<50>-Footnote-385045364
Ref: Library<50>-Footnote-395045430
Ref: Library<50>-Footnote-405045496
Ref: Library<50>-Footnote-415045562
Ref: Library<50>-Footnote-425045628
Ref: Library<50>-Footnote-435045694
Ref: Library<50>-Footnote-445045760
Ref: Library<50>-Footnote-455045826
Ref: Library<50>-Footnote-465045892
Ref: Library<50>-Footnote-475045958
Ref: Library<50>-Footnote-485046024
Ref: Library<50>-Footnote-495046090
Ref: Library<50>-Footnote-505046156
Ref: Library<50>-Footnote-515046222
Ref: Library<50>-Footnote-525046288
Ref: Library<50>-Footnote-535046354
Ref: Library<50>-Footnote-545046420
Ref: Library<50>-Footnote-555046486
Ref: Library<50>-Footnote-565046552
Ref: Library<50>-Footnote-575046618
Ref: Library<50>-Footnote-585046684
Ref: Library<50>-Footnote-595046750
Ref: Library<50>-Footnote-605046816
Ref: Library<50>-Footnote-615046882
Ref: Library<50>-Footnote-625046948
Ref: Library<50>-Footnote-635047014
Ref: Library<50>-Footnote-645047080
Ref: Library<50>-Footnote-655047146
Ref: Library<50>-Footnote-665047212
Ref: Library<50>-Footnote-675047278
Ref: Library<50>-Footnote-685047344
Ref: Library<50>-Footnote-695047410
Ref: Library<50>-Footnote-705047476
Ref: Library<50>-Footnote-715047542
Ref: Library<50>-Footnote-725047608
Ref: Library<50>-Footnote-735047674
Ref: Library<50>-Footnote-745047740
Ref: Library<50>-Footnote-755047806
Ref: Library<50>-Footnote-765047872
Ref: Library<50>-Footnote-775047938
Ref: Library<50>-Footnote-785048004
Ref: Library<50>-Footnote-795048070
Ref: Library<50>-Footnote-805048136
Ref: Library<50>-Footnote-815048202
Ref: Library<50>-Footnote-825048268
Ref: Library<50>-Footnote-835048334
Ref: Library<50>-Footnote-845048400
Ref: Library<50>-Footnote-855048466
Ref: Library<50>-Footnote-865048532
Ref: Library<50>-Footnote-875048598
Ref: Library<50>-Footnote-885048664
Ref: Library<50>-Footnote-895048730
Ref: Library<50>-Footnote-905048796
Ref: Library<50>-Footnote-915048862
Ref: Library<50>-Footnote-925048928
Ref: Library<50>-Footnote-935048994
Ref: Library<50>-Footnote-945049054
Ref: Library<50>-Footnote-955049120
Ref: Library<50>-Footnote-965049186
Ref: Library<50>-Footnote-975049252
Ref: Library<50>-Footnote-985049318
Ref: Library<50>-Footnote-995049384
Ref: Library<50>-Footnote-1005049450
Ref: Library<50>-Footnote-1015049517
Ref: Library<50>-Footnote-1025049584
Ref: Library<50>-Footnote-1035049651
Ref: Library<50>-Footnote-1045049718
Ref: Library<50>-Footnote-1055049785
Ref: Library<50>-Footnote-1065049852
Ref: Library<50>-Footnote-1075049919
Ref: Library<50>-Footnote-1085049986
Ref: Library<50>-Footnote-1095050053
Ref: Library<50>-Footnote-1105050120
Ref: Library<50>-Footnote-1115050187
Ref: Library<50>-Footnote-1125050254
Ref: Library<50>-Footnote-1135050321
Ref: Library<50>-Footnote-1145050388
Ref: Library<50>-Footnote-1155050455
Ref: Library<50>-Footnote-1165050522
Ref: Library<50>-Footnote-1175050589
Ref: Library<50>-Footnote-1185050656
Ref: Library<50>-Footnote-1195050723
Ref: Library<50>-Footnote-1205050790
Ref: Library<50>-Footnote-1215050857
Ref: Library<50>-Footnote-1225050924
Ref: Library<50>-Footnote-1235050991
Ref: Library<50>-Footnote-1245051058
Ref: Library<50>-Footnote-1255051125
Ref: Library<50>-Footnote-1265051191
Ref: Library<50>-Footnote-1275051258
Ref: Library<50>-Footnote-1285051325
Ref: Library<50>-Footnote-1295051392
Ref: Library<50>-Footnote-1305051459
Ref: Library<50>-Footnote-1315051526
Ref: Library<50>-Footnote-1325051593
Ref: Library<50>-Footnote-1335051660
Ref: Library<50>-Footnote-1345051727
Ref: Library<50>-Footnote-1355051794
Ref: Library<50>-Footnote-1365051861
Ref: Library<50>-Footnote-1375051927
Ref: Library<50>-Footnote-1385051994
Ref: Library<50>-Footnote-1395052061
Ref: Library<50>-Footnote-1405052128
Ref: Library<50>-Footnote-1415052195
Ref: Library<50>-Footnote-1425052262
Ref: Library<50>-Footnote-1435052329
Ref: Library<50>-Footnote-1445052396
Ref: Library<50>-Footnote-1455052463
Ref: Library<50>-Footnote-1465052530
Ref: Library<50>-Footnote-1475052597
Ref: Library<50>-Footnote-1485052664
Ref: Library<50>-Footnote-1495052731
Ref: Library<50>-Footnote-1505052798
Ref: Library<50>-Footnote-1515052865
Ref: Library<50>-Footnote-1525052932
Ref: Library<50>-Footnote-1535052999
Ref: Library<50>-Footnote-1545053066
Ref: Library<50>-Footnote-1555053132
Ref: Library<50>-Footnote-1565053199
Ref: Library<50>-Footnote-1575053266
Ref: Library<50>-Footnote-1585053333
Ref: Library<50>-Footnote-1595053400
Ref: Library<50>-Footnote-1605053467
Ref: Library<50>-Footnote-1615053534
Ref: Library<50>-Footnote-1625053578
Ref: Library<50>-Footnote-1635053645
Ref: Library<50>-Footnote-1645053712
Ref: Library<50>-Footnote-1655053779
Ref: Library<50>-Footnote-1665053845
Ref: Library<50>-Footnote-1675053912
Ref: Library<50>-Footnote-1685053979
Ref: Library<50>-Footnote-1695054046
Ref: Library<50>-Footnote-1705054113
Ref: Library<50>-Footnote-1715054180
Ref: Library<50>-Footnote-1725054247
Ref: Library<50>-Footnote-1735054314
Ref: Library<50>-Footnote-1745054381
Ref: Library<50>-Footnote-1755054447
Ref: Library<50>-Footnote-1765054514
Ref: Library<50>-Footnote-1775054581
Ref: Library<50>-Footnote-1785054648
Ref: Library<50>-Footnote-1795054715
Ref: Library<50>-Footnote-1805054782
Ref: Library<50>-Footnote-1815054848
Ref: Library<50>-Footnote-1825054915
Ref: Library<50>-Footnote-1835054982
Ref: Library<50>-Footnote-1845055049
Ref: Library<50>-Footnote-1855055116
Ref: Library<50>-Footnote-1865055183
Ref: Library<50>-Footnote-1875055250
Ref: Library<50>-Footnote-1885055317
Ref: Library<50>-Footnote-1895055384
Ref: Library<50>-Footnote-1905055451
Ref: Library<50>-Footnote-1915055518
Ref: Library<50>-Footnote-1925055585
Ref: Library<50>-Footnote-1935055652
Ref: Library<50>-Footnote-1945055719
Ref: Library<50>-Footnote-1955055786
Ref: Library<50>-Footnote-1965055853
Ref: Library<50>-Footnote-1975055920
Ref: Library<50>-Footnote-1985055987
Ref: Library<50>-Footnote-1995056054
Ref: Library<50>-Footnote-2005056121
Ref: Library<50>-Footnote-2015056188
Ref: Library<50>-Footnote-2025056255
Ref: Library<50>-Footnote-2035056323
Ref: Library<50>-Footnote-2045056390
Ref: Library<50>-Footnote-2055056457
Ref: Library<50>-Footnote-2065056524
Ref: Library<50>-Footnote-2075056591
Ref: Library<50>-Footnote-2085056658
Ref: Library<50>-Footnote-2095056725
Ref: Library<50>-Footnote-2105056792
Ref: Library<50>-Footnote-2115056859
Ref: Library<50>-Footnote-2125056926
Ref: Library<50>-Footnote-2135056993
Ref: Library<50>-Footnote-2145057037
Ref: Library<50>-Footnote-2155057104
Ref: Library<50>-Footnote-2165057171
Ref: Library<50>-Footnote-2175057238
Ref: Library<50>-Footnote-2185057305
Ref: Library<50>-Footnote-2195057372
Ref: Library<50>-Footnote-2205057439
Ref: Library<50>-Footnote-2215057506
Ref: Library<50>-Footnote-2225057573
Ref: Library<50>-Footnote-2235057640
Ref: Library<50>-Footnote-2245057707
Ref: Library<50>-Footnote-2255057774
Ref: Library<50>-Footnote-2265057841
Ref: Library<50>-Footnote-2275057908
Ref: Library<50>-Footnote-2285057975
Ref: Library<50>-Footnote-2295058042
Ref: Library<50>-Footnote-2305058109
Ref: Library<50>-Footnote-2315058176
Ref: Library<50>-Footnote-2325058243
Ref: Library<50>-Footnote-2335058310
Ref: Library<50>-Footnote-2345058377
Ref: Library<50>-Footnote-2355058444
Ref: Library<50>-Footnote-2365058511
Ref: Library<50>-Footnote-2375058578
Ref: Library<50>-Footnote-2385058645
Ref: Library<50>-Footnote-2395058712
Ref: Library<50>-Footnote-2405058779
Ref: Library<50>-Footnote-2415058846
Ref: Library<50>-Footnote-2425058913
Ref: Library<50>-Footnote-2435058980
Ref: Library<50>-Footnote-2445059047
Ref: Library<50>-Footnote-2455059114
Ref: Library<50>-Footnote-2465059181
Ref: Library<50>-Footnote-2475059248
Ref: Library<50>-Footnote-2485059315
Ref: Library<50>-Footnote-2495059382
Ref: Library<50>-Footnote-2505059449
Ref: Library<50>-Footnote-2515059516
Ref: Library<50>-Footnote-2525059583
Ref: Library<50>-Footnote-2535059650
Ref: Library<50>-Footnote-2545059717
Ref: Library<50>-Footnote-2555059784
Ref: Library<50>-Footnote-2565059851
Ref: Library<50>-Footnote-2575059918
Ref: Library<50>-Footnote-2585059985
Ref: Library<50>-Footnote-2595060052
Ref: Library<50>-Footnote-2605060119
Ref: Library<50>-Footnote-2615060185
Ref: Library<50>-Footnote-2625060252
Ref: Library<50>-Footnote-2635060319
Ref: Library<50>-Footnote-2645060386
Ref: Library<50>-Footnote-2655060453
Ref: Library<50>-Footnote-2665060520
Ref: Library<50>-Footnote-2675060587
Ref: Library<50>-Footnote-2685060654
Ref: Library<50>-Footnote-2695060721
Ref: Library<50>-Footnote-2705060788
Ref: Library<50>-Footnote-2715060855
Ref: Library<50>-Footnote-2725060922
Ref: Library<50>-Footnote-2735060989
Ref: Library<50>-Footnote-2745061056
Ref: Library<50>-Footnote-2755061123
Ref: Library<50>-Footnote-2765061190
Ref: Library<50>-Footnote-2775061257
Ref: Library<50>-Footnote-2785061324
Ref: Library<50>-Footnote-2795061391
Ref: Library<50>-Footnote-2805061458
Ref: Library<50>-Footnote-2815061525
Ref: Library<50>-Footnote-2825061592
Ref: Library<50>-Footnote-2835061659
Ref: Library<50>-Footnote-2845061726
Ref: Library<50>-Footnote-2855061793
Ref: Library<50>-Footnote-2865061860
Ref: Library<50>-Footnote-2875061927
Ref: Library<50>-Footnote-2885061994
Ref: Library<50>-Footnote-2895062061
Ref: Library<50>-Footnote-2905062128
Ref: Library<50>-Footnote-2915062195
Ref: Library<50>-Footnote-2925062262
Ref: Library<50>-Footnote-2935062329
Ref: Library<50>-Footnote-2945062396
Ref: Library<50>-Footnote-2955062463
Ref: Library<50>-Footnote-2965062530
Ref: Library<50>-Footnote-2975062597
Ref: Library<50>-Footnote-2985062664
Ref: Library<50>-Footnote-2995062731
Ref: Library<50>-Footnote-3005062798
Ref: Library<50>-Footnote-3015062865
Ref: Library<50>-Footnote-3025062932
Ref: Library<50>-Footnote-3035062999
Ref: Library<50>-Footnote-3045063066
Ref: Library<50>-Footnote-3055063133
Ref: Library<50>-Footnote-3065063200
Ref: Library<50>-Footnote-3075063267
Ref: Library<50>-Footnote-3085063334
Ref: Library<50>-Footnote-3095063401
Ref: Library<50>-Footnote-3105063468
Ref: Library<50>-Footnote-3115063535
Ref: Library<50>-Footnote-3125063602
Ref: Library<50>-Footnote-3135063669
Ref: Library<50>-Footnote-3145063736
Ref: Library<50>-Footnote-3155063803
Ref: Library<50>-Footnote-3165063870
Ref: Library<50>-Footnote-3175063937
Ref: Library<50>-Footnote-3185064004
Ref: Library<50>-Footnote-3195064071
Ref: Library<50>-Footnote-3205064138
Ref: Library<50>-Footnote-3215064205
Ref: Library<50>-Footnote-3225064272
Ref: Library<50>-Footnote-3235064339
Ref: Library<50>-Footnote-3245064406
Ref: Library<50>-Footnote-3255064473
Ref: Library<50>-Footnote-3265064540
Ref: Library<50>-Footnote-3275064607
Ref: Library<50>-Footnote-3285064674
Ref: Library<50>-Footnote-3295064742
Ref: Library<50>-Footnote-3305064809
Ref: Library<50>-Footnote-3315064876
Ref: Library<50>-Footnote-3325064943
Ref: Library<50>-Footnote-3335065010
Ref: Library<50>-Footnote-3345065077
Ref: Library<50>-Footnote-3355065144
Ref: Library<50>-Footnote-3365065211
Ref: Library<50>-Footnote-3375065278
Ref: Library<50>-Footnote-3385065345
Ref: Library<50>-Footnote-3395065412
Ref: Library<50>-Footnote-3405065479
Ref: Library<50>-Footnote-3415065546
Ref: Library<50>-Footnote-3425065613
Ref: Library<50>-Footnote-3435065680
Ref: Library<50>-Footnote-3445065747
Ref: Library<50>-Footnote-3455065814
Ref: Library<50>-Footnote-3465065858
Ref: Library<50>-Footnote-3475065925
Ref: Library<50>-Footnote-3485065992
Ref: Library<50>-Footnote-3495066059
Ref: Library<50>-Footnote-3505066103
Ref: Library<50>-Footnote-3515066170
Ref: Library<50>-Footnote-3525066237
Ref: Library<50>-Footnote-3535066304
Ref: Library<50>-Footnote-3545066371
Ref: Library<50>-Footnote-3555066438
Ref: Library<50>-Footnote-3565066505
Ref: Library<50>-Footnote-3575066572
Ref: Library<50>-Footnote-3585066639
Ref: Library<50>-Footnote-3595066706
Ref: Library<50>-Footnote-3605066773
Ref: Library<50>-Footnote-3615066840
Ref: Library<50>-Footnote-3625066907
Ref: Library<50>-Footnote-3635066974
Ref: Library<50>-Footnote-3645067041
Ref: Library<50>-Footnote-3655067108
Ref: Library<50>-Footnote-3665067175
Ref: Library<50>-Footnote-3675067242
Ref: Library<50>-Footnote-3685067309
Ref: Library<50>-Footnote-3695067376
Ref: Library<50>-Footnote-3705067443
Ref: Library<50>-Footnote-3715067510
Ref: Library<50>-Footnote-3725067577
Ref: Library<50>-Footnote-3735067644
Ref: Library<50>-Footnote-3745067711
Ref: Library<50>-Footnote-3755067778
Ref: Library<50>-Footnote-3765067845
Ref: Library<50>-Footnote-3775067912
Ref: Library<50>-Footnote-3785067979
Ref: Library<50>-Footnote-3795068046
Ref: Library<50>-Footnote-3805068113
Ref: Library<50>-Footnote-3815068180
Ref: Library<50>-Footnote-3825068247
Ref: Library<50>-Footnote-3835068314
Ref: Library<50>-Footnote-3845068381
Ref: Library<50>-Footnote-3855068448
Ref: Library<50>-Footnote-3865068515
Ref: Library<50>-Footnote-3875068582
Ref: Library<50>-Footnote-3885068649
Ref: Library<50>-Footnote-3895068716
Ref: Library<50>-Footnote-3905068783
Ref: Library<50>-Footnote-3915068850
Ref: Library<50>-Footnote-3925068917
Ref: Library<50>-Footnote-3935068984
Ref: Library<50>-Footnote-3945069051
Ref: Library<50>-Footnote-3955069118
Ref: Library<50>-Footnote-3965069185
Ref: Library<50>-Footnote-3975069252
Ref: Library<50>-Footnote-3985069319
Ref: Library<50>-Footnote-3995069386
Ref: Library<50>-Footnote-4005069453
Ref: Library<50>-Footnote-4015069520
Ref: Library<50>-Footnote-4025069587
Ref: Library<50>-Footnote-4035069654
Ref: Library<50>-Footnote-4045069721
Ref: Library<50>-Footnote-4055069788
Ref: Library<50>-Footnote-4065069855
Ref: Library<50>-Footnote-4075069922
Ref: Library<50>-Footnote-4085069989
Ref: Library<50>-Footnote-4095070056
Ref: Library<50>-Footnote-4105070123
Ref: Library<50>-Footnote-4115070190
Ref: Library<50>-Footnote-4125070257
Ref: Library<50>-Footnote-4135070324
Ref: Library<50>-Footnote-4145070391
Ref: Library<50>-Footnote-4155070458
Ref: Library<50>-Footnote-4165070525
Ref: Library<50>-Footnote-4175070592
Ref: Library<50>-Footnote-4185070659
Ref: Library<50>-Footnote-4195070726
Ref: Library<50>-Footnote-4205070793
Ref: Library<50>-Footnote-4215070860
Ref: Library<50>-Footnote-4225070927
Ref: Library<50>-Footnote-4235070993
Ref: Library<50>-Footnote-4245071060
Ref: Library<50>-Footnote-4255071127
Ref: Library<50>-Footnote-4265071194
Ref: Library<50>-Footnote-4275071261
Ref: Library<50>-Footnote-4285071328
Ref: Library<50>-Footnote-4295071395
Ref: Library<50>-Footnote-4305071462
Ref: Library<50>-Footnote-4315071529
Ref: Library<50>-Footnote-4325071596
Ref: Library<50>-Footnote-4335071663
Ref: Library<50>-Footnote-4345071730
Ref: Library<50>-Footnote-4355071797
Ref: Library<50>-Footnote-4365071864
Ref: Library<50>-Footnote-4375071931
Node: Documentation<45>5071998
Ref: whatsnew/changelog id4505072110
Ref: 19b35072110
Ref: Documentation<45>-Footnote-15078791
Ref: Documentation<45>-Footnote-25078856
Ref: Documentation<45>-Footnote-35078921
Ref: Documentation<45>-Footnote-45078986
Ref: Documentation<45>-Footnote-55079051
Ref: Documentation<45>-Footnote-65079116
Ref: Documentation<45>-Footnote-75079181
Ref: Documentation<45>-Footnote-85079246
Ref: Documentation<45>-Footnote-95079311
Ref: Documentation<45>-Footnote-105079376
Ref: Documentation<45>-Footnote-115079442
Ref: Documentation<45>-Footnote-125079508
Ref: Documentation<45>-Footnote-135079574
Ref: Documentation<45>-Footnote-145079640
Ref: Documentation<45>-Footnote-155079706
Ref: Documentation<45>-Footnote-165079772
Ref: Documentation<45>-Footnote-175079838
Ref: Documentation<45>-Footnote-185079904
Ref: Documentation<45>-Footnote-195079970
Ref: Documentation<45>-Footnote-205080036
Ref: Documentation<45>-Footnote-215080102
Ref: Documentation<45>-Footnote-225080168
Ref: Documentation<45>-Footnote-235080234
Ref: Documentation<45>-Footnote-245080277
Ref: Documentation<45>-Footnote-255080343
Ref: Documentation<45>-Footnote-265080409
Ref: Documentation<45>-Footnote-275080475
Ref: Documentation<45>-Footnote-285080541
Ref: Documentation<45>-Footnote-295080607
Ref: Documentation<45>-Footnote-305080650
Ref: Documentation<45>-Footnote-315080716
Ref: Documentation<45>-Footnote-325080782
Ref: Documentation<45>-Footnote-335080848
Ref: Documentation<45>-Footnote-345080914
Ref: Documentation<45>-Footnote-355080980
Ref: Documentation<45>-Footnote-365081046
Ref: Documentation<45>-Footnote-375081112
Ref: Documentation<45>-Footnote-385081178
Ref: Documentation<45>-Footnote-395081244
Ref: Documentation<45>-Footnote-405081310
Ref: Documentation<45>-Footnote-415081376
Ref: Documentation<45>-Footnote-425081442
Ref: Documentation<45>-Footnote-435081508
Ref: Documentation<45>-Footnote-445081574
Ref: Documentation<45>-Footnote-455081640
Ref: Documentation<45>-Footnote-465081706
Ref: Documentation<45>-Footnote-475081772
Ref: Documentation<45>-Footnote-485081838
Ref: Documentation<45>-Footnote-495081904
Ref: Documentation<45>-Footnote-505081970
Ref: Documentation<45>-Footnote-515082035
Ref: Documentation<45>-Footnote-525082101
Ref: Documentation<45>-Footnote-535082167
Ref: Documentation<45>-Footnote-545082233
Ref: Documentation<45>-Footnote-555082299
Ref: Documentation<45>-Footnote-565082365
Ref: Documentation<45>-Footnote-575082430
Ref: Documentation<45>-Footnote-585082496
Ref: Documentation<45>-Footnote-595082562
Node: Tests<47>5082628
Ref: whatsnew/changelog id4515082738
Ref: 19b55082738
Ref: Tests<47>-Footnote-15090329
Ref: Tests<47>-Footnote-25090394
Ref: Tests<47>-Footnote-35090459
Ref: Tests<47>-Footnote-45090524
Ref: Tests<47>-Footnote-55090589
Ref: Tests<47>-Footnote-65090654
Ref: Tests<47>-Footnote-75090719
Ref: Tests<47>-Footnote-85090784
Ref: Tests<47>-Footnote-95090849
Ref: Tests<47>-Footnote-105090914
Ref: Tests<47>-Footnote-115090980
Ref: Tests<47>-Footnote-125091046
Ref: Tests<47>-Footnote-135091112
Ref: Tests<47>-Footnote-145091178
Ref: Tests<47>-Footnote-155091244
Ref: Tests<47>-Footnote-165091310
Ref: Tests<47>-Footnote-175091376
Ref: Tests<47>-Footnote-185091442
Ref: Tests<47>-Footnote-195091508
Ref: Tests<47>-Footnote-205091574
Ref: Tests<47>-Footnote-215091640
Ref: Tests<47>-Footnote-225091706
Ref: Tests<47>-Footnote-235091772
Ref: Tests<47>-Footnote-245091838
Ref: Tests<47>-Footnote-255091904
Ref: Tests<47>-Footnote-265091970
Ref: Tests<47>-Footnote-275092036
Ref: Tests<47>-Footnote-285092102
Ref: Tests<47>-Footnote-295092168
Ref: Tests<47>-Footnote-305092234
Ref: Tests<47>-Footnote-315092300
Ref: Tests<47>-Footnote-325092366
Ref: Tests<47>-Footnote-335092432
Ref: Tests<47>-Footnote-345092498
Ref: Tests<47>-Footnote-355092564
Ref: Tests<47>-Footnote-365092630
Ref: Tests<47>-Footnote-375092696
Ref: Tests<47>-Footnote-385092762
Ref: Tests<47>-Footnote-395092828
Ref: Tests<47>-Footnote-405092894
Ref: Tests<47>-Footnote-415092960
Ref: Tests<47>-Footnote-425093026
Ref: Tests<47>-Footnote-435093092
Ref: Tests<47>-Footnote-445093158
Ref: Tests<47>-Footnote-455093224
Ref: Tests<47>-Footnote-465093290
Ref: Tests<47>-Footnote-475093356
Ref: Tests<47>-Footnote-485093422
Node: Build<49>5093488
Ref: whatsnew/changelog id4525093592
Ref: 19b65093592
Ref: Build<49>-Footnote-15098695
Ref: Build<49>-Footnote-25098760
Ref: Build<49>-Footnote-35098825
Ref: Build<49>-Footnote-45098890
Ref: Build<49>-Footnote-55098955
Ref: Build<49>-Footnote-65099020
Ref: Build<49>-Footnote-75099085
Ref: Build<49>-Footnote-85099150
Ref: Build<49>-Footnote-95099215
Ref: Build<49>-Footnote-105099280
Ref: Build<49>-Footnote-115099346
Ref: Build<49>-Footnote-125099412
Ref: Build<49>-Footnote-135099478
Ref: Build<49>-Footnote-145099544
Ref: Build<49>-Footnote-155099610
Ref: Build<49>-Footnote-165099676
Ref: Build<49>-Footnote-175099742
Ref: Build<49>-Footnote-185099808
Ref: Build<49>-Footnote-195099874
Ref: Build<49>-Footnote-205099940
Ref: Build<49>-Footnote-215100006
Ref: Build<49>-Footnote-225100072
Ref: Build<49>-Footnote-235100138
Ref: Build<49>-Footnote-245100203
Ref: Build<49>-Footnote-255100269
Ref: Build<49>-Footnote-265100335
Ref: Build<49>-Footnote-275100401
Ref: Build<49>-Footnote-285100467
Ref: Build<49>-Footnote-295100533
Ref: Build<49>-Footnote-305100599
Ref: Build<49>-Footnote-315100665
Ref: Build<49>-Footnote-325100731
Ref: Build<49>-Footnote-335100797
Ref: Build<49>-Footnote-345100863
Ref: Build<49>-Footnote-355100929
Ref: Build<49>-Footnote-365100995
Ref: Build<49>-Footnote-375101061
Node: Windows<45>5101127
Ref: whatsnew/changelog id4535101231
Ref: 19b75101231
Ref: Windows<45>-Footnote-15105640
Ref: Windows<45>-Footnote-25105705
Ref: Windows<45>-Footnote-35105770
Ref: Windows<45>-Footnote-45105835
Ref: Windows<45>-Footnote-55105900
Ref: Windows<45>-Footnote-65105965
Ref: Windows<45>-Footnote-75106030
Ref: Windows<45>-Footnote-85106095
Ref: Windows<45>-Footnote-95106160
Ref: Windows<45>-Footnote-105106225
Ref: Windows<45>-Footnote-115106291
Ref: Windows<45>-Footnote-125106357
Ref: Windows<45>-Footnote-135106423
Ref: Windows<45>-Footnote-145106489
Ref: Windows<45>-Footnote-155106555
Ref: Windows<45>-Footnote-165106621
Ref: Windows<45>-Footnote-175106687
Ref: Windows<45>-Footnote-185106753
Ref: Windows<45>-Footnote-195106819
Ref: Windows<45>-Footnote-205106885
Ref: Windows<45>-Footnote-215106951
Ref: Windows<45>-Footnote-225107017
Ref: Windows<45>-Footnote-235107083
Ref: Windows<45>-Footnote-245107149
Ref: Windows<45>-Footnote-255107215
Ref: Windows<45>-Footnote-265107281
Ref: Windows<45>-Footnote-275107347
Ref: Windows<45>-Footnote-285107413
Ref: Windows<45>-Footnote-295107479
Ref: Windows<45>-Footnote-305107545
Ref: Windows<45>-Footnote-315107611
Ref: Windows<45>-Footnote-325107677
Ref: Windows<45>-Footnote-335107743
Ref: Windows<45>-Footnote-345107809
Ref: Windows<45>-Footnote-355107875
Ref: Windows<45>-Footnote-365107941
Ref: Windows<45>-Footnote-375108007
Ref: Windows<45>-Footnote-385108073
Ref: Windows<45>-Footnote-395108139
Ref: Windows<45>-Footnote-405108205
Node: macOS<37>5108270
Ref: whatsnew/changelog id4545108373
Ref: 19b85108373
Ref: macOS<37>-Footnote-15109978
Ref: macOS<37>-Footnote-25110043
Ref: macOS<37>-Footnote-35110108
Ref: macOS<37>-Footnote-45110173
Ref: macOS<37>-Footnote-55110238
Ref: macOS<37>-Footnote-65110303
Ref: macOS<37>-Footnote-75110368
Ref: macOS<37>-Footnote-85110433
Ref: macOS<37>-Footnote-95110498
Ref: macOS<37>-Footnote-105110563
Node: IDLE<37>5110629
Ref: whatsnew/changelog id4555110736
Ref: 19b95110736
Ref: IDLE<37>-Footnote-15119098
Ref: IDLE<37>-Footnote-25119163
Ref: IDLE<37>-Footnote-35119228
Ref: IDLE<37>-Footnote-45119293
Ref: IDLE<37>-Footnote-55119358
Ref: IDLE<37>-Footnote-65119423
Ref: IDLE<37>-Footnote-75119488
Ref: IDLE<37>-Footnote-85119553
Ref: IDLE<37>-Footnote-95119618
Ref: IDLE<37>-Footnote-105119683
Ref: IDLE<37>-Footnote-115119749
Ref: IDLE<37>-Footnote-125119815
Ref: IDLE<37>-Footnote-135119881
Ref: IDLE<37>-Footnote-145119947
Ref: IDLE<37>-Footnote-155120013
Ref: IDLE<37>-Footnote-165120079
Ref: IDLE<37>-Footnote-175120145
Ref: IDLE<37>-Footnote-185120211
Ref: IDLE<37>-Footnote-195120277
Ref: IDLE<37>-Footnote-205120343
Ref: IDLE<37>-Footnote-215120409
Ref: IDLE<37>-Footnote-225120475
Ref: IDLE<37>-Footnote-235120541
Ref: IDLE<37>-Footnote-245120607
Ref: IDLE<37>-Footnote-255120673
Ref: IDLE<37>-Footnote-265120739
Ref: IDLE<37>-Footnote-275120805
Ref: IDLE<37>-Footnote-285120873
Ref: IDLE<37>-Footnote-295120939
Ref: IDLE<37>-Footnote-305121005
Ref: IDLE<37>-Footnote-315121071
Ref: IDLE<37>-Footnote-325121137
Ref: IDLE<37>-Footnote-335121203
Ref: IDLE<37>-Footnote-345121269
Ref: IDLE<37>-Footnote-355121335
Ref: IDLE<37>-Footnote-365121401
Ref: IDLE<37>-Footnote-375121467
Ref: IDLE<37>-Footnote-385121533
Ref: IDLE<37>-Footnote-395121599
Ref: IDLE<37>-Footnote-405121665
Ref: IDLE<37>-Footnote-415121731
Ref: IDLE<37>-Footnote-425121797
Ref: IDLE<37>-Footnote-435121863
Ref: IDLE<37>-Footnote-445121929
Ref: IDLE<37>-Footnote-455121995
Ref: IDLE<37>-Footnote-465122061
Ref: IDLE<37>-Footnote-475122127
Ref: IDLE<37>-Footnote-485122193
Ref: IDLE<37>-Footnote-495122259
Ref: IDLE<37>-Footnote-505122325
Ref: IDLE<37>-Footnote-515122391
Ref: IDLE<37>-Footnote-525122457
Ref: IDLE<37>-Footnote-535122523
Ref: IDLE<37>-Footnote-545122589
Ref: IDLE<37>-Footnote-555122655
Ref: IDLE<37>-Footnote-565122721
Ref: IDLE<37>-Footnote-575122787
Ref: IDLE<37>-Footnote-585122853
Ref: IDLE<37>-Footnote-595122919
Node: Tools/Demos<24>5122985
Ref: whatsnew/changelog id4565123092
Ref: 19ba5123092
Ref: Tools/Demos<24>-Footnote-15124737
Ref: Tools/Demos<24>-Footnote-25124802
Ref: Tools/Demos<24>-Footnote-35124867
Ref: Tools/Demos<24>-Footnote-45124932
Ref: Tools/Demos<24>-Footnote-55124997
Ref: Tools/Demos<24>-Footnote-65125062
Ref: Tools/Demos<24>-Footnote-75125127
Ref: Tools/Demos<24>-Footnote-85125192
Ref: Tools/Demos<24>-Footnote-95125257
Ref: Tools/Demos<24>-Footnote-105125322
Ref: Tools/Demos<24>-Footnote-115125388
Ref: Tools/Demos<24>-Footnote-125125454
Node: C API<48>5125520
Ref: whatsnew/changelog id4575125610
Ref: 19bb5125610
Ref: C API<48>-Footnote-15128998
Ref: C API<48>-Footnote-25129063
Ref: C API<48>-Footnote-35129128
Ref: C API<48>-Footnote-45129193
Ref: C API<48>-Footnote-55129258
Ref: C API<48>-Footnote-65129323
Ref: C API<48>-Footnote-75129388
Ref: C API<48>-Footnote-85129453
Ref: C API<48>-Footnote-95129518
Ref: C API<48>-Footnote-105129583
Ref: C API<48>-Footnote-115129649
Ref: C API<48>-Footnote-125129715
Ref: C API<48>-Footnote-135129781
Ref: C API<48>-Footnote-145129847
Ref: C API<48>-Footnote-155129913
Ref: C API<48>-Footnote-165129979
Ref: C API<48>-Footnote-175130045
Ref: C API<48>-Footnote-185130111
Ref: C API<48>-Footnote-195130177
Ref: C API<48>-Footnote-205130243
Ref: C API<48>-Footnote-215130309
Ref: C API<48>-Footnote-225130375
Node: Python 3 7 0 final5130441
Ref: whatsnew/changelog python-3-7-0-final5130578
Ref: 19c35130578
Node: Library<51>5130715
Ref: whatsnew/changelog id4585130799
Ref: 19c45130799
Ref: Library<51>-Footnote-15130969
Node: C API<49>5131034
Ref: whatsnew/changelog id4595131118
Ref: 19c65131118
Ref: C API<49>-Footnote-15131329
Node: Python 3 7 0 release candidate 15131394
Ref: whatsnew/changelog python-3-7-0-release-candidate-15131530
Ref: 19c75131530
Node: Core and Builtins<52>5131817
Ref: whatsnew/changelog id4605131927
Ref: 19c85131927
Ref: Core and Builtins<52>-Footnote-15132569
Ref: Core and Builtins<52>-Footnote-25132634
Ref: Core and Builtins<52>-Footnote-35132699
Ref: Core and Builtins<52>-Footnote-45132764
Node: Library<52>5132829
Ref: whatsnew/changelog id4615132965
Ref: 19c95132965
Ref: Library<52>-Footnote-15134661
Ref: Library<52>-Footnote-25134726
Ref: Library<52>-Footnote-35134791
Ref: Library<52>-Footnote-45134856
Ref: Library<52>-Footnote-55134921
Ref: Library<52>-Footnote-65134986
Ref: Library<52>-Footnote-75135051
Ref: Library<52>-Footnote-85135116
Ref: Library<52>-Footnote-95135181
Ref: Library<52>-Footnote-105135246
Ref: Library<52>-Footnote-115135312
Ref: Library<52>-Footnote-125135378
Ref: Library<52>-Footnote-135135444
Node: Documentation<46>5135510
Ref: whatsnew/changelog id4625135634
Ref: 19ca5135634
Ref: Documentation<46>-Footnote-15136137
Ref: Documentation<46>-Footnote-25136202
Ref: Documentation<46>-Footnote-35136244
Ref: Documentation<46>-Footnote-45136309
Node: Build<50>5136374
Ref: whatsnew/changelog id4635136498
Ref: 19cb5136498
Ref: Build<50>-Footnote-15136760
Node: Windows<46>5136824
Ref: whatsnew/changelog id4645136939
Ref: 19cc5136939
Ref: Windows<46>-Footnote-15137096
Node: IDLE<38>5137161
Ref: whatsnew/changelog id4655137258
Ref: 19cd5137258
Ref: IDLE<38>-Footnote-15138478
Ref: IDLE<38>-Footnote-25138543
Ref: IDLE<38>-Footnote-35138608
Ref: IDLE<38>-Footnote-45138673
Ref: IDLE<38>-Footnote-55138738
Ref: IDLE<38>-Footnote-65138803
Node: Python 3 7 0 beta 55138868
Ref: whatsnew/changelog python-3-7-0-beta-55139005
Ref: 19ce5139005
Node: Core and Builtins<53>5139282
Ref: whatsnew/changelog id4665139379
Ref: 19cf5139379
Ref: Core and Builtins<53>-Footnote-15140891
Ref: Core and Builtins<53>-Footnote-25140956
Ref: Core and Builtins<53>-Footnote-35141021
Ref: Core and Builtins<53>-Footnote-45141086
Ref: Core and Builtins<53>-Footnote-55141151
Ref: Core and Builtins<53>-Footnote-65141216
Ref: Core and Builtins<53>-Footnote-75141281
Ref: Core and Builtins<53>-Footnote-85141346
Ref: Core and Builtins<53>-Footnote-95141411
Node: Library<53>5141476
Ref: whatsnew/changelog id4675141599
Ref: 19d05141599
Ref: Library<53>-Footnote-15147191
Ref: Library<53>-Footnote-25147256
Ref: Library<53>-Footnote-35147321
Ref: Library<53>-Footnote-45147386
Ref: Library<53>-Footnote-55147451
Ref: Library<53>-Footnote-65147516
Ref: Library<53>-Footnote-75147581
Ref: Library<53>-Footnote-85147646
Ref: Library<53>-Footnote-95147711
Ref: Library<53>-Footnote-105147776
Ref: Library<53>-Footnote-115147842
Ref: Library<53>-Footnote-125147908
Ref: Library<53>-Footnote-135147974
Ref: Library<53>-Footnote-145148040
Ref: Library<53>-Footnote-155148106
Ref: Library<53>-Footnote-165148172
Ref: Library<53>-Footnote-175148238
Ref: Library<53>-Footnote-185148304
Ref: Library<53>-Footnote-195148370
Ref: Library<53>-Footnote-205148436
Ref: Library<53>-Footnote-215148502
Ref: Library<53>-Footnote-225148568
Ref: Library<53>-Footnote-235148634
Ref: Library<53>-Footnote-245148700
Ref: Library<53>-Footnote-255148766
Ref: Library<53>-Footnote-265148832
Ref: Library<53>-Footnote-275148898
Ref: Library<53>-Footnote-285148964
Ref: Library<53>-Footnote-295149030
Ref: Library<53>-Footnote-305149096
Ref: Library<53>-Footnote-315149162
Ref: Library<53>-Footnote-325149228
Ref: Library<53>-Footnote-335149294
Ref: Library<53>-Footnote-345149360
Ref: Library<53>-Footnote-355149426
Ref: Library<53>-Footnote-365149492
Ref: Library<53>-Footnote-375149558
Ref: Library<53>-Footnote-385149624
Node: Documentation<47>5149690
Ref: whatsnew/changelog id4685149801
Ref: 19d15149801
Ref: Documentation<47>-Footnote-15150271
Ref: Documentation<47>-Footnote-25150336
Ref: Documentation<47>-Footnote-35150401
Ref: Documentation<47>-Footnote-45150443
Ref: Documentation<47>-Footnote-55150508
Ref: Documentation<47>-Footnote-65150573
Node: Tests<48>5150638
Ref: whatsnew/changelog id4695150747
Ref: 19d25150747
Ref: Tests<48>-Footnote-15151096
Ref: Tests<48>-Footnote-25151161
Node: Build<51>5151226
Ref: whatsnew/changelog id4705151327
Ref: 19d35151327
Ref: Build<51>-Footnote-15151806
Ref: Build<51>-Footnote-25151871
Ref: Build<51>-Footnote-35151936
Node: macOS<38>5152001
Ref: whatsnew/changelog id4715152101
Ref: 19d45152101
Ref: macOS<38>-Footnote-15152341
Node: IDLE<39>5152406
Ref: whatsnew/changelog id4725152488
Ref: 19d55152488
Ref: IDLE<39>-Footnote-15152765
Ref: IDLE<39>-Footnote-25152830
Ref: IDLE<39>-Footnote-35152895
Node: Python 3 7 0 beta 45152960
Ref: whatsnew/changelog python-3-7-0-beta-45153084
Ref: 19d65153084
Node: Core and Builtins<54>5153417
Ref: whatsnew/changelog id4735153514
Ref: 19d75153514
Ref: Core and Builtins<54>-Footnote-15154644
Ref: Core and Builtins<54>-Footnote-25154709
Ref: Core and Builtins<54>-Footnote-35154774
Ref: Core and Builtins<54>-Footnote-45154839
Ref: Core and Builtins<54>-Footnote-55154904
Ref: Core and Builtins<54>-Footnote-65154969
Ref: Core and Builtins<54>-Footnote-75155034
Node: Library<54>5155099
Ref: whatsnew/changelog id4745155222
Ref: 19d85155222
Ref: Library<54>-Footnote-15158059
Ref: Library<54>-Footnote-25158124
Ref: Library<54>-Footnote-35158189
Ref: Library<54>-Footnote-45158254
Ref: Library<54>-Footnote-55158320
Ref: Library<54>-Footnote-65158385
Ref: Library<54>-Footnote-75158450
Ref: Library<54>-Footnote-85158515
Ref: Library<54>-Footnote-95158580
Ref: Library<54>-Footnote-105158645
Ref: Library<54>-Footnote-115158711
Ref: Library<54>-Footnote-125158777
Ref: Library<54>-Footnote-135158843
Ref: Library<54>-Footnote-145158909
Ref: Library<54>-Footnote-155158975
Ref: Library<54>-Footnote-165159041
Ref: Library<54>-Footnote-175159107
Ref: Library<54>-Footnote-185159150
Ref: Library<54>-Footnote-195159216
Ref: Library<54>-Footnote-205159282
Ref: Library<54>-Footnote-215159348
Ref: Library<54>-Footnote-225159414
Node: Documentation<48>5159480
Ref: whatsnew/changelog id4755159591
Ref: 19d95159591
Ref: Documentation<48>-Footnote-15160342
Ref: Documentation<48>-Footnote-25160407
Ref: Documentation<48>-Footnote-35160472
Ref: Documentation<48>-Footnote-45160537
Ref: Documentation<48>-Footnote-55160602
Ref: Documentation<48>-Footnote-65160666
Node: Tests<49>5160731
Ref: whatsnew/changelog id4765160840
Ref: 19da5160840
Ref: Tests<49>-Footnote-15161056
Node: Build<52>5161121
Ref: whatsnew/changelog id4775161224
Ref: 19db5161224
Ref: Build<52>-Footnote-15161914
Ref: Build<52>-Footnote-25161979
Ref: Build<52>-Footnote-35162044
Ref: Build<52>-Footnote-45162109
Ref: Build<52>-Footnote-55162174
Node: Windows<47>5162239
Ref: whatsnew/changelog id4785162342
Ref: 19dc5162342
Ref: Windows<47>-Footnote-15162483
Node: macOS<39>5162548
Ref: whatsnew/changelog id4795162650
Ref: 19dd5162650
Ref: macOS<39>-Footnote-15162791
Node: IDLE<40>5162856
Ref: whatsnew/changelog id4805162962
Ref: 19de5162962
Ref: IDLE<40>-Footnote-15163540
Ref: IDLE<40>-Footnote-25163605
Node: Tools/Demos<25>5163670
Ref: whatsnew/changelog id4815163758
Ref: 19df5163758
Ref: Tools/Demos<25>-Footnote-15164362
Ref: Tools/Demos<25>-Footnote-25164427
Ref: Tools/Demos<25>-Footnote-35164492
Ref: Tools/Demos<25>-Footnote-45164557
Node: Python 3 7 0 beta 35164622
Ref: whatsnew/changelog python-3-7-0-beta-35164746
Ref: 19e05164746
Node: Security<35>5165125
Ref: whatsnew/changelog id4825165223
Ref: 19e15165223
Ref: Security<35>-Footnote-15165855
Ref: Security<35>-Footnote-25165920
Ref: Security<35>-Footnote-35165975
Ref: Security<35>-Footnote-45166040
Ref: Security<35>-Footnote-55166105
Ref: Security<35>-Footnote-65166160
Node: Core and Builtins<55>5166215
Ref: whatsnew/changelog id4835166333
Ref: 19e25166333
Ref: Core and Builtins<55>-Footnote-15167529
Ref: Core and Builtins<55>-Footnote-25167594
Ref: Core and Builtins<55>-Footnote-35167659
Ref: Core and Builtins<55>-Footnote-45167724
Ref: Core and Builtins<55>-Footnote-55167789
Ref: Core and Builtins<55>-Footnote-65167854
Ref: Core and Builtins<55>-Footnote-75167919
Node: Library<55>5167984
Ref: whatsnew/changelog id4845168107
Ref: 19e35168107
Ref: Library<55>-Footnote-15172149
Ref: Library<55>-Footnote-25172214
Ref: Library<55>-Footnote-35172279
Ref: Library<55>-Footnote-45172344
Ref: Library<55>-Footnote-55172409
Ref: Library<55>-Footnote-65172474
Ref: Library<55>-Footnote-75172539
Ref: Library<55>-Footnote-85172604
Ref: Library<55>-Footnote-95172669
Ref: Library<55>-Footnote-105172734
Ref: Library<55>-Footnote-115172800
Ref: Library<55>-Footnote-125172866
Ref: Library<55>-Footnote-135172932
Ref: Library<55>-Footnote-145172998
Ref: Library<55>-Footnote-155173064
Ref: Library<55>-Footnote-165173130
Ref: Library<55>-Footnote-175173196
Ref: Library<55>-Footnote-185173262
Ref: Library<55>-Footnote-195173328
Ref: Library<55>-Footnote-205173394
Ref: Library<55>-Footnote-215173460
Ref: Library<55>-Footnote-225173526
Ref: Library<55>-Footnote-235173592
Ref: Library<55>-Footnote-245173658
Ref: Library<55>-Footnote-255173724
Ref: Library<55>-Footnote-265173790
Ref: Library<55>-Footnote-275173856
Node: Documentation<49>5173922
Ref: whatsnew/changelog id4855174033
Ref: 19e45174033
Ref: Documentation<49>-Footnote-15174670
Ref: Documentation<49>-Footnote-25174735
Ref: Documentation<49>-Footnote-35174800
Ref: Documentation<49>-Footnote-45174865
Ref: Documentation<49>-Footnote-55174930
Node: Tests<50>5174995
Ref: whatsnew/changelog id4865175104
Ref: 19e55175104
Ref: Tests<50>-Footnote-15175437
Ref: Tests<50>-Footnote-25175502
Ref: Tests<50>-Footnote-35175567
Node: Build<53>5175632
Ref: whatsnew/changelog id4875175735
Ref: 19e65175735
Ref: Build<53>-Footnote-15175872
Node: Windows<48>5175937
Ref: whatsnew/changelog id4885176040
Ref: 19e75176040
Ref: Windows<48>-Footnote-15176319
Ref: Windows<48>-Footnote-25176384
Node: macOS<40>5176449
Ref: whatsnew/changelog id4895176551
Ref: 19e85176551
Ref: macOS<40>-Footnote-15176983
Node: IDLE<41>5177048
Ref: whatsnew/changelog id4905177154
Ref: 19e95177154
Ref: IDLE<41>-Footnote-15177868
Ref: IDLE<41>-Footnote-25177933
Node: Tools/Demos<26>5177998
Ref: whatsnew/changelog id4915178104
Ref: 19ea5178104
Ref: Tools/Demos<26>-Footnote-15178334
Node: C API<50>5178399
Ref: whatsnew/changelog id4925178488
Ref: 19eb5178488
Ref: C API<50>-Footnote-15178872
Ref: C API<50>-Footnote-25178937
Node: Python 3 7 0 beta 25179002
Ref: whatsnew/changelog python-3-7-0-beta-25179126
Ref: 19ec5179126
Node: Security<36>5179485
Ref: whatsnew/changelog id4935179583
Ref: 19ed5179583
Ref: Security<36>-Footnote-15179768
Node: Core and Builtins<56>5179833
Ref: whatsnew/changelog id4945179951
Ref: 19ee5179951
Ref: Core and Builtins<56>-Footnote-15180782
Ref: Core and Builtins<56>-Footnote-25180847
Ref: Core and Builtins<56>-Footnote-35180912
Ref: Core and Builtins<56>-Footnote-45180977
Ref: Core and Builtins<56>-Footnote-55181042
Ref: Core and Builtins<56>-Footnote-65181107
Ref: Core and Builtins<56>-Footnote-75181172
Node: Library<56>5181237
Ref: whatsnew/changelog id4955181360
Ref: 19ef5181360
Ref: Library<56>-Footnote-15187755
Ref: Library<56>-Footnote-25187820
Ref: Library<56>-Footnote-35187885
Ref: Library<56>-Footnote-45187950
Ref: Library<56>-Footnote-55188015
Ref: Library<56>-Footnote-65188080
Ref: Library<56>-Footnote-75188145
Ref: Library<56>-Footnote-85188210
Ref: Library<56>-Footnote-95188275
Ref: Library<56>-Footnote-105188340
Ref: Library<56>-Footnote-115188406
Ref: Library<56>-Footnote-125188472
Ref: Library<56>-Footnote-135188538
Ref: Library<56>-Footnote-145188604
Ref: Library<56>-Footnote-155188670
Ref: Library<56>-Footnote-165188736
Ref: Library<56>-Footnote-175188802
Ref: Library<56>-Footnote-185188868
Ref: Library<56>-Footnote-195188934
Ref: Library<56>-Footnote-205189000
Ref: Library<56>-Footnote-215189066
Ref: Library<56>-Footnote-225189132
Ref: Library<56>-Footnote-235189198
Ref: Library<56>-Footnote-245189264
Ref: Library<56>-Footnote-255189330
Ref: Library<56>-Footnote-265189396
Ref: Library<56>-Footnote-275189462
Ref: Library<56>-Footnote-285189528
Ref: Library<56>-Footnote-295189594
Ref: Library<56>-Footnote-305189660
Ref: Library<56>-Footnote-315189726
Ref: Library<56>-Footnote-325189792
Ref: Library<56>-Footnote-335189858
Ref: Library<56>-Footnote-345189924
Node: Documentation<50>5189990
Ref: whatsnew/changelog id4965190101
Ref: 19f05190101
Ref: Documentation<50>-Footnote-15191052
Ref: Documentation<50>-Footnote-25191117
Ref: Documentation<50>-Footnote-35191182
Ref: Documentation<50>-Footnote-45191247
Ref: Documentation<50>-Footnote-55191312
Ref: Documentation<50>-Footnote-65191377
Ref: Documentation<50>-Footnote-75191441
Ref: Documentation<50>-Footnote-85191506
Node: Tests<51>5191571
Ref: whatsnew/changelog id4975191680
Ref: 19f15191680
Ref: Tests<51>-Footnote-15191823
Node: Build<54>5191888
Ref: whatsnew/changelog id4985191991
Ref: 19f25191991
Ref: Build<54>-Footnote-15192132
Node: Windows<49>5192197
Ref: whatsnew/changelog id4995192300
Ref: 19f35192300
Ref: Windows<49>-Footnote-15193036
Ref: Windows<49>-Footnote-25193101
Ref: Windows<49>-Footnote-35193166
Ref: Windows<49>-Footnote-45193231
Ref: Windows<49>-Footnote-55193296
Ref: Windows<49>-Footnote-65193361
Node: macOS<41>5193426
Ref: whatsnew/changelog id5005193528
Ref: 19f45193528
Ref: macOS<41>-Footnote-15193663
Node: IDLE<42>5193728
Ref: whatsnew/changelog id5015193834
Ref: 19f55193834
Ref: IDLE<42>-Footnote-15194669
Ref: IDLE<42>-Footnote-25194734
Ref: IDLE<42>-Footnote-35194799
Ref: IDLE<42>-Footnote-45194864
Ref: IDLE<42>-Footnote-55194929
Ref: IDLE<42>-Footnote-65194994
Node: Tools/Demos<27>5195059
Ref: whatsnew/changelog id5025195147
Ref: 19f65195147
Ref: Tools/Demos<27>-Footnote-15195366
Node: Python 3 7 0 beta 15195431
Ref: whatsnew/changelog python-3-7-0-beta-15195556
Ref: 19f75195556
Node: Core and Builtins<57>5195859
Ref: whatsnew/changelog id5035195956
Ref: 19f85195956
Ref: Core and Builtins<57>-Footnote-15199370
Ref: Core and Builtins<57>-Footnote-25199435
Ref: Core and Builtins<57>-Footnote-35199500
Ref: Core and Builtins<57>-Footnote-45199565
Ref: Core and Builtins<57>-Footnote-55199630
Ref: Core and Builtins<57>-Footnote-65199695
Ref: Core and Builtins<57>-Footnote-75199760
Ref: Core and Builtins<57>-Footnote-85199825
Ref: Core and Builtins<57>-Footnote-95199890
Ref: Core and Builtins<57>-Footnote-105199932
Ref: Core and Builtins<57>-Footnote-115199998
Ref: Core and Builtins<57>-Footnote-125200064
Ref: Core and Builtins<57>-Footnote-135200130
Ref: Core and Builtins<57>-Footnote-145200196
Ref: Core and Builtins<57>-Footnote-155200262
Ref: Core and Builtins<57>-Footnote-165200328
Ref: Core and Builtins<57>-Footnote-175200394
Ref: Core and Builtins<57>-Footnote-185200460
Ref: Core and Builtins<57>-Footnote-195200503
Ref: Core and Builtins<57>-Footnote-205200569
Ref: Core and Builtins<57>-Footnote-215200635
Ref: Core and Builtins<57>-Footnote-225200701
Ref: Core and Builtins<57>-Footnote-235200767
Node: Library<57>5200833
Ref: whatsnew/changelog id5045200956
Ref: 19f95200956
Ref: Library<57>-Footnote-15208328
Ref: Library<57>-Footnote-25208393
Ref: Library<57>-Footnote-35208458
Ref: Library<57>-Footnote-45208523
Ref: Library<57>-Footnote-55208588
Ref: Library<57>-Footnote-65208653
Ref: Library<57>-Footnote-75208718
Ref: Library<57>-Footnote-85208783
Ref: Library<57>-Footnote-95208848
Ref: Library<57>-Footnote-105208913
Ref: Library<57>-Footnote-115208979
Ref: Library<57>-Footnote-125209045
Ref: Library<57>-Footnote-135209111
Ref: Library<57>-Footnote-145209177
Ref: Library<57>-Footnote-155209243
Ref: Library<57>-Footnote-165209309
Ref: Library<57>-Footnote-175209375
Ref: Library<57>-Footnote-185209441
Ref: Library<57>-Footnote-195209484
Ref: Library<57>-Footnote-205209550
Ref: Library<57>-Footnote-215209616
Ref: Library<57>-Footnote-225209682
Ref: Library<57>-Footnote-235209748
Ref: Library<57>-Footnote-245209814
Ref: Library<57>-Footnote-255209880
Ref: Library<57>-Footnote-265209946
Ref: Library<57>-Footnote-275210012
Ref: Library<57>-Footnote-285210078
Ref: Library<57>-Footnote-295210144
Ref: Library<57>-Footnote-305210210
Ref: Library<57>-Footnote-315210276
Ref: Library<57>-Footnote-325210342
Ref: Library<57>-Footnote-335210408
Ref: Library<57>-Footnote-345210474
Ref: Library<57>-Footnote-355210540
Ref: Library<57>-Footnote-365210606
Ref: Library<57>-Footnote-375210672
Ref: Library<57>-Footnote-385210738
Ref: Library<57>-Footnote-395210804
Ref: Library<57>-Footnote-405210870
Ref: Library<57>-Footnote-415210936
Ref: Library<57>-Footnote-425211002
Ref: Library<57>-Footnote-435211068
Ref: Library<57>-Footnote-445211134
Ref: Library<57>-Footnote-455211200
Ref: Library<57>-Footnote-465211266
Ref: Library<57>-Footnote-475211332
Node: Documentation<51>5211398
Ref: whatsnew/changelog id5055211509
Ref: 19fa5211509
Ref: Documentation<51>-Footnote-15212050
Ref: Documentation<51>-Footnote-25212115
Ref: Documentation<51>-Footnote-35212180
Node: Tests<52>5212245
Ref: whatsnew/changelog id5065212354
Ref: 19fb5212354
Ref: Tests<52>-Footnote-15213262
Ref: Tests<52>-Footnote-25213327
Ref: Tests<52>-Footnote-35213392
Ref: Tests<52>-Footnote-45213457
Ref: Tests<52>-Footnote-55213522
Ref: Tests<52>-Footnote-65213587
Node: Build<55>5213652
Ref: whatsnew/changelog id5075213755
Ref: 19fc5213755
Ref: Build<55>-Footnote-15214358
Ref: Build<55>-Footnote-25214423
Ref: Build<55>-Footnote-35214488
Ref: Build<55>-Footnote-45214553
Node: Windows<50>5214618
Ref: whatsnew/changelog id5085214721
Ref: 19fd5214721
Ref: Windows<50>-Footnote-15215102
Ref: Windows<50>-Footnote-25215167
Ref: Windows<50>-Footnote-35215232
Node: macOS<42>5215297
Ref: whatsnew/changelog id5095215400
Ref: 19fe5215400
Ref: macOS<42>-Footnote-15215922
Ref: macOS<42>-Footnote-25215987
Node: C API<51>5216052
Ref: whatsnew/changelog id5105216135
Ref: 19ff5216135
Ref: C API<51>-Footnote-15216452
Ref: C API<51>-Footnote-25216517
Node: Python 3 7 0 alpha 45216582
Ref: whatsnew/changelog python-3-7-0-alpha-45216708
Ref: 1a005216708
Node: Core and Builtins<58>5217005
Ref: whatsnew/changelog id5115217103
Ref: 1a015217103
Ref: Core and Builtins<58>-Footnote-15220604
Ref: Core and Builtins<58>-Footnote-25220669
Ref: Core and Builtins<58>-Footnote-35220734
Ref: Core and Builtins<58>-Footnote-45220799
Ref: Core and Builtins<58>-Footnote-55220864
Ref: Core and Builtins<58>-Footnote-65220929
Ref: Core and Builtins<58>-Footnote-75220994
Ref: Core and Builtins<58>-Footnote-85221059
Ref: Core and Builtins<58>-Footnote-95221124
Ref: Core and Builtins<58>-Footnote-105221189
Ref: Core and Builtins<58>-Footnote-115221255
Ref: Core and Builtins<58>-Footnote-125221321
Ref: Core and Builtins<58>-Footnote-135221387
Ref: Core and Builtins<58>-Footnote-145221453
Ref: Core and Builtins<58>-Footnote-155221519
Ref: Core and Builtins<58>-Footnote-165221585
Ref: Core and Builtins<58>-Footnote-175221651
Ref: Core and Builtins<58>-Footnote-185221717
Ref: Core and Builtins<58>-Footnote-195221783
Ref: Core and Builtins<58>-Footnote-205221826
Ref: Core and Builtins<58>-Footnote-215221892
Ref: Core and Builtins<58>-Footnote-225221935
Ref: Core and Builtins<58>-Footnote-235222001
Ref: Core and Builtins<58>-Footnote-245222044
Ref: Core and Builtins<58>-Footnote-255222110
Ref: Core and Builtins<58>-Footnote-265222176
Ref: Core and Builtins<58>-Footnote-275222219
Node: Library<58>5222285
Ref: whatsnew/changelog id5125222409
Ref: 1a035222409
Ref: Library<58>-Footnote-15230393
Ref: Library<58>-Footnote-25230458
Ref: Library<58>-Footnote-35230523
Ref: Library<58>-Footnote-45230588
Ref: Library<58>-Footnote-55230653
Ref: Library<58>-Footnote-65230718
Ref: Library<58>-Footnote-75230783
Ref: Library<58>-Footnote-85230848
Ref: Library<58>-Footnote-95230913
Ref: Library<58>-Footnote-105230978
Ref: Library<58>-Footnote-115231044
Ref: Library<58>-Footnote-125231110
Ref: Library<58>-Footnote-135231176
Ref: Library<58>-Footnote-145231242
Ref: Library<58>-Footnote-155231308
Ref: Library<58>-Footnote-165231374
Ref: Library<58>-Footnote-175231440
Ref: Library<58>-Footnote-185231506
Ref: Library<58>-Footnote-195231572
Ref: Library<58>-Footnote-205231638
Ref: Library<58>-Footnote-215231704
Ref: Library<58>-Footnote-225231770
Ref: Library<58>-Footnote-235231836
Ref: Library<58>-Footnote-245231902
Ref: Library<58>-Footnote-255231968
Ref: Library<58>-Footnote-265232034
Ref: Library<58>-Footnote-275232100
Ref: Library<58>-Footnote-285232166
Ref: Library<58>-Footnote-295232232
Ref: Library<58>-Footnote-305232298
Ref: Library<58>-Footnote-315232364
Ref: Library<58>-Footnote-325232430
Ref: Library<58>-Footnote-335232496
Ref: Library<58>-Footnote-345232562
Ref: Library<58>-Footnote-355232628
Ref: Library<58>-Footnote-365232694
Ref: Library<58>-Footnote-375232760
Ref: Library<58>-Footnote-385232826
Ref: Library<58>-Footnote-395232892
Ref: Library<58>-Footnote-405232958
Ref: Library<58>-Footnote-415233024
Ref: Library<58>-Footnote-425233090
Ref: Library<58>-Footnote-435233156
Ref: Library<58>-Footnote-445233222
Ref: Library<58>-Footnote-455233288
Ref: Library<58>-Footnote-465233354
Ref: Library<58>-Footnote-475233420
Ref: Library<58>-Footnote-485233486
Ref: Library<58>-Footnote-495233552
Ref: Library<58>-Footnote-505233618
Ref: Library<58>-Footnote-515233684
Ref: Library<58>-Footnote-525233750
Ref: Library<58>-Footnote-535233816
Ref: Library<58>-Footnote-545233882
Node: Documentation<52>5233948
Ref: whatsnew/changelog id5135234060
Ref: 1a045234060
Ref: Documentation<52>-Footnote-15234230
Node: Tests<53>5234295
Ref: whatsnew/changelog id5145234407
Ref: 1a055234407
Ref: Tests<53>-Footnote-15234802
Ref: Tests<53>-Footnote-25234867
Node: Windows<51>5234932
Ref: whatsnew/changelog id5155235042
Ref: 1a065235042
Ref: Windows<51>-Footnote-15235241
Node: Tools/Demos<28>5235306
Ref: whatsnew/changelog id5165235416
Ref: 1a075235416
Ref: Tools/Demos<28>-Footnote-15235698
Node: C API<52>5235763
Ref: whatsnew/changelog id5175235853
Ref: 1a085235853
Ref: C API<52>-Footnote-15236495
Ref: C API<52>-Footnote-25236560
Ref: C API<52>-Footnote-35236625
Ref: C API<52>-Footnote-45236690
Node: Python 3 7 0 alpha 35236755
Ref: whatsnew/changelog python-3-7-0-alpha-35236882
Ref: 1a095236882
Node: Core and Builtins<59>5237237
Ref: whatsnew/changelog id5185237335
Ref: 1a0a5237335
Ref: Core and Builtins<59>-Footnote-15242456
Ref: Core and Builtins<59>-Footnote-25242521
Ref: Core and Builtins<59>-Footnote-35242586
Ref: Core and Builtins<59>-Footnote-45242651
Ref: Core and Builtins<59>-Footnote-55242716
Ref: Core and Builtins<59>-Footnote-65242781
Ref: Core and Builtins<59>-Footnote-75242846
Ref: Core and Builtins<59>-Footnote-85242911
Ref: Core and Builtins<59>-Footnote-95242976
Ref: Core and Builtins<59>-Footnote-105243041
Ref: Core and Builtins<59>-Footnote-115243107
Ref: Core and Builtins<59>-Footnote-125243173
Ref: Core and Builtins<59>-Footnote-135243239
Ref: Core and Builtins<59>-Footnote-145243305
Ref: Core and Builtins<59>-Footnote-155243371
Ref: Core and Builtins<59>-Footnote-165243437
Ref: Core and Builtins<59>-Footnote-175243503
Ref: Core and Builtins<59>-Footnote-185243569
Ref: Core and Builtins<59>-Footnote-195243635
Ref: Core and Builtins<59>-Footnote-205243701
Ref: Core and Builtins<59>-Footnote-215243767
Ref: Core and Builtins<59>-Footnote-225243833
Node: Library<59>5243899
Ref: whatsnew/changelog id5195244023
Ref: 1a0b5244023
Ref: Library<59>-Footnote-15260033
Ref: Library<59>-Footnote-25260098
Ref: Library<59>-Footnote-35260163
Ref: Library<59>-Footnote-45260228
Ref: Library<59>-Footnote-55260293
Ref: Library<59>-Footnote-65260358
Ref: Library<59>-Footnote-75260423
Ref: Library<59>-Footnote-85260488
Ref: Library<59>-Footnote-95260553
Ref: Library<59>-Footnote-105260618
Ref: Library<59>-Footnote-115260684
Ref: Library<59>-Footnote-125260750
Ref: Library<59>-Footnote-135260816
Ref: Library<59>-Footnote-145260882
Ref: Library<59>-Footnote-155260948
Ref: Library<59>-Footnote-165261014
Ref: Library<59>-Footnote-175261080
Ref: Library<59>-Footnote-185261146
Ref: Library<59>-Footnote-195261212
Ref: Library<59>-Footnote-205261278
Ref: Library<59>-Footnote-215261344
Ref: Library<59>-Footnote-225261410
Ref: Library<59>-Footnote-235261476
Ref: Library<59>-Footnote-245261542
Ref: Library<59>-Footnote-255261608
Ref: Library<59>-Footnote-265261676
Ref: Library<59>-Footnote-275261742
Ref: Library<59>-Footnote-285261808
Ref: Library<59>-Footnote-295261874
Ref: Library<59>-Footnote-305261940
Ref: Library<59>-Footnote-315262006
Ref: Library<59>-Footnote-325262072
Ref: Library<59>-Footnote-335262115
Ref: Library<59>-Footnote-345262181
Ref: Library<59>-Footnote-355262247
Ref: Library<59>-Footnote-365262313
Ref: Library<59>-Footnote-375262379
Ref: Library<59>-Footnote-385262445
Ref: Library<59>-Footnote-395262511
Ref: Library<59>-Footnote-405262577
Ref: Library<59>-Footnote-415262643
Ref: Library<59>-Footnote-425262709
Ref: Library<59>-Footnote-435262775
Ref: Library<59>-Footnote-445262841
Ref: Library<59>-Footnote-455262907
Ref: Library<59>-Footnote-465262973
Ref: Library<59>-Footnote-475263038
Ref: Library<59>-Footnote-485263104
Ref: Library<59>-Footnote-495263170
Ref: Library<59>-Footnote-505263236
Ref: Library<59>-Footnote-515263302
Ref: Library<59>-Footnote-525263368
Ref: Library<59>-Footnote-535263434
Ref: Library<59>-Footnote-545263500
Ref: Library<59>-Footnote-555263566
Ref: Library<59>-Footnote-565263632
Ref: Library<59>-Footnote-575263698
Ref: Library<59>-Footnote-585263764
Ref: Library<59>-Footnote-595263830
Ref: Library<59>-Footnote-605263896
Ref: Library<59>-Footnote-615263962
Ref: Library<59>-Footnote-625264028
Ref: Library<59>-Footnote-635264071
Ref: Library<59>-Footnote-645264137
Ref: Library<59>-Footnote-655264203
Ref: Library<59>-Footnote-665264269
Ref: Library<59>-Footnote-675264335
Ref: Library<59>-Footnote-685264401
Ref: Library<59>-Footnote-695264467
Ref: Library<59>-Footnote-705264533
Ref: Library<59>-Footnote-715264599
Ref: Library<59>-Footnote-725264665
Ref: Library<59>-Footnote-735264731
Ref: Library<59>-Footnote-745264797
Ref: Library<59>-Footnote-755264863
Ref: Library<59>-Footnote-765264929
Ref: Library<59>-Footnote-775264995
Ref: Library<59>-Footnote-785265061
Ref: Library<59>-Footnote-795265127
Ref: Library<59>-Footnote-805265193
Ref: Library<59>-Footnote-815265259
Ref: Library<59>-Footnote-825265325
Ref: Library<59>-Footnote-835265368
Ref: Library<59>-Footnote-845265434
Ref: Library<59>-Footnote-855265500
Ref: Library<59>-Footnote-865265566
Ref: Library<59>-Footnote-875265632
Ref: Library<59>-Footnote-885265698
Ref: Library<59>-Footnote-895265764
Ref: Library<59>-Footnote-905265830
Ref: Library<59>-Footnote-915265896
Ref: Library<59>-Footnote-925265962
Ref: Library<59>-Footnote-935266028
Ref: Library<59>-Footnote-945266094
Ref: Library<59>-Footnote-955266160
Ref: Library<59>-Footnote-965266226
Ref: Library<59>-Footnote-975266292
Ref: Library<59>-Footnote-985266358
Node: Documentation<53>5266424
Ref: whatsnew/changelog id5205266536
Ref: 1a105266536
Ref: Documentation<53>-Footnote-15266719
Node: Tests<54>5266784
Ref: whatsnew/changelog id5215266894
Ref: 1a115266894
Ref: Tests<54>-Footnote-15268100
Ref: Tests<54>-Footnote-25268165
Ref: Tests<54>-Footnote-35268230
Ref: Tests<54>-Footnote-45268295
Ref: Tests<54>-Footnote-55268360
Ref: Tests<54>-Footnote-65268425
Ref: Tests<54>-Footnote-75268490
Node: Build<56>5268555
Ref: whatsnew/changelog id5225268659
Ref: 1a125268659
Ref: Build<56>-Footnote-15269873
Ref: Build<56>-Footnote-25269938
Ref: Build<56>-Footnote-35270003
Ref: Build<56>-Footnote-45270068
Ref: Build<56>-Footnote-55270133
Ref: Build<56>-Footnote-65270198
Ref: Build<56>-Footnote-75270263
Ref: Build<56>-Footnote-85270328
Ref: Build<56>-Footnote-95270393
Ref: Build<56>-Footnote-105270458
Ref: Build<56>-Footnote-115270524
Ref: Build<56>-Footnote-125270590
Node: Windows<52>5270656
Ref: whatsnew/changelog id5235270760
Ref: 1a135270760
Ref: Windows<52>-Footnote-15271293
Ref: Windows<52>-Footnote-25271357
Ref: Windows<52>-Footnote-35271422
Ref: Windows<52>-Footnote-45271487
Node: macOS<43>5271552
Ref: whatsnew/changelog id5245271655
Ref: 1a145271655
Ref: macOS<43>-Footnote-15271789
Node: IDLE<43>5271854
Ref: whatsnew/changelog id5255271961
Ref: 1a155271961
Ref: IDLE<43>-Footnote-15274042
Ref: IDLE<43>-Footnote-25274107
Ref: IDLE<43>-Footnote-35274172
Ref: IDLE<43>-Footnote-45274237
Ref: IDLE<43>-Footnote-55274302
Ref: IDLE<43>-Footnote-65274367
Ref: IDLE<43>-Footnote-75274432
Ref: IDLE<43>-Footnote-85274497
Node: Tools/Demos<29>5274562
Ref: whatsnew/changelog id5265274669
Ref: 1a165274669
Ref: Tools/Demos<29>-Footnote-15275199
Ref: Tools/Demos<29>-Footnote-25275264
Node: C API<53>5275329
Ref: whatsnew/changelog id5275275419
Ref: 1a175275419
Ref: C API<53>-Footnote-15276545
Ref: C API<53>-Footnote-25276610
Ref: C API<53>-Footnote-35276675
Ref: C API<53>-Footnote-45276740
Ref: C API<53>-Footnote-55276805
Ref: C API<53>-Footnote-65276870
Node: Python 3 7 0 alpha 25276935
Ref: whatsnew/changelog python-3-7-0-alpha-25277062
Ref: 1a185277062
Node: Core and Builtins<60>5277321
Ref: whatsnew/changelog id5285277419
Ref: 1a195277419
Ref: Core and Builtins<60>-Footnote-15281600
Ref: Core and Builtins<60>-Footnote-25281665
Ref: Core and Builtins<60>-Footnote-35281730
Ref: Core and Builtins<60>-Footnote-45281795
Ref: Core and Builtins<60>-Footnote-55281860
Ref: Core and Builtins<60>-Footnote-65281925
Ref: Core and Builtins<60>-Footnote-75281990
Ref: Core and Builtins<60>-Footnote-85282055
Ref: Core and Builtins<60>-Footnote-95282120
Ref: Core and Builtins<60>-Footnote-105282185
Ref: Core and Builtins<60>-Footnote-115282251
Ref: Core and Builtins<60>-Footnote-125282317
Ref: Core and Builtins<60>-Footnote-135282383
Ref: Core and Builtins<60>-Footnote-145282449
Ref: Core and Builtins<60>-Footnote-155282515
Ref: Core and Builtins<60>-Footnote-165282581
Ref: Core and Builtins<60>-Footnote-175282647
Ref: Core and Builtins<60>-Footnote-185282713
Ref: Core and Builtins<60>-Footnote-195282779
Ref: Core and Builtins<60>-Footnote-205282845
Ref: Core and Builtins<60>-Footnote-215282888
Ref: Core and Builtins<60>-Footnote-225282954
Ref: Core and Builtins<60>-Footnote-235283020
Ref: Core and Builtins<60>-Footnote-245283086
Ref: Core and Builtins<60>-Footnote-255283152
Ref: Core and Builtins<60>-Footnote-265283218
Ref: Core and Builtins<60>-Footnote-275283284
Node: Library<60>5283327
Ref: whatsnew/changelog id5295283451
Ref: 1a1a5283451
Ref: Library<60>-Footnote-15287490
Ref: Library<60>-Footnote-25287555
Ref: Library<60>-Footnote-35287620
Ref: Library<60>-Footnote-45287685
Ref: Library<60>-Footnote-55287750
Ref: Library<60>-Footnote-65287815
Ref: Library<60>-Footnote-75287880
Ref: Library<60>-Footnote-85287945
Ref: Library<60>-Footnote-95288010
Ref: Library<60>-Footnote-105288075
Ref: Library<60>-Footnote-115288141
Ref: Library<60>-Footnote-125288207
Ref: Library<60>-Footnote-135288273
Ref: Library<60>-Footnote-145288339
Ref: Library<60>-Footnote-155288405
Ref: Library<60>-Footnote-165288471
Ref: Library<60>-Footnote-175288537
Ref: Library<60>-Footnote-185288603
Ref: Library<60>-Footnote-195288669
Ref: Library<60>-Footnote-205288735
Ref: Library<60>-Footnote-215288801
Ref: Library<60>-Footnote-225288867
Ref: Library<60>-Footnote-235288933
Ref: Library<60>-Footnote-245288999
Ref: Library<60>-Footnote-255289065
Ref: Library<60>-Footnote-265289131
Node: Documentation<54>5289197
Ref: whatsnew/changelog id5305289309
Ref: 1a1b5289309
Ref: Documentation<54>-Footnote-15289700
Ref: Documentation<54>-Footnote-25289765
Node: Build<57>5289830
Ref: whatsnew/changelog id5315289939
Ref: 1a1c5289939
Ref: Build<57>-Footnote-15290562
Ref: Build<57>-Footnote-25290627
Ref: Build<57>-Footnote-35290692
Ref: Build<57>-Footnote-45290757
Ref: Build<57>-Footnote-55290822
Ref: Build<57>-Footnote-65290887
Node: IDLE<44>5290952
Ref: whatsnew/changelog id5325291053
Ref: 1a1d5291053
Ref: IDLE<44>-Footnote-15292355
Ref: IDLE<44>-Footnote-25292420
Ref: IDLE<44>-Footnote-35292485
Ref: IDLE<44>-Footnote-45292550
Ref: IDLE<44>-Footnote-55292615
Ref: IDLE<44>-Footnote-65292680
Node: C API<54>5292747
Ref: whatsnew/changelog id5335292830
Ref: 1a1e5292830
Ref: C API<54>-Footnote-15293554
Ref: C API<54>-Footnote-25293619
Ref: C API<54>-Footnote-35293684
Ref: C API<54>-Footnote-45293749
Node: Python 3 7 0 alpha 15293791
Ref: whatsnew/changelog python-3-7-0-alpha-15293916
Ref: 1a1f5293916
Node: Security<37>5294277
Ref: whatsnew/changelog id5345294376
Ref: 1a205294376
Ref: Security<37>-Footnote-15296026
Ref: Security<37>-Footnote-25296091
Ref: Security<37>-Footnote-35296156
Ref: Security<37>-Footnote-45296221
Ref: Security<37>-Footnote-55296286
Ref: Security<37>-Footnote-65296351
Ref: Security<37>-Footnote-75296406
Ref: Security<37>-Footnote-85296461
Ref: Security<37>-Footnote-95296516
Ref: Security<37>-Footnote-105296571
Ref: Security<37>-Footnote-115296627
Ref: Security<37>-Footnote-125296683
Ref: Security<37>-Footnote-135296749
Ref: Security<37>-Footnote-145296815
Ref: Security<37>-Footnote-155296871
Node: Core and Builtins<61>5296927
Ref: whatsnew/changelog id5355297046
Ref: 1a215297046
Ref: Core and Builtins<61>-Footnote-15317862
Ref: Core and Builtins<61>-Footnote-25317927
Ref: Core and Builtins<61>-Footnote-35317992
Ref: Core and Builtins<61>-Footnote-45318057
Ref: Core and Builtins<61>-Footnote-55318122
Ref: Core and Builtins<61>-Footnote-65318187
Ref: Core and Builtins<61>-Footnote-75318252
Ref: Core and Builtins<61>-Footnote-85318317
Ref: Core and Builtins<61>-Footnote-95318382
Ref: Core and Builtins<61>-Footnote-105318447
Ref: Core and Builtins<61>-Footnote-115318513
Ref: Core and Builtins<61>-Footnote-125318579
Ref: Core and Builtins<61>-Footnote-135318645
Ref: Core and Builtins<61>-Footnote-145318711
Ref: Core and Builtins<61>-Footnote-155318777
Ref: Core and Builtins<61>-Footnote-165318843
Ref: Core and Builtins<61>-Footnote-175318909
Ref: Core and Builtins<61>-Footnote-185318975
Ref: Core and Builtins<61>-Footnote-195319041
Ref: Core and Builtins<61>-Footnote-205319107
Ref: Core and Builtins<61>-Footnote-215319173
Ref: Core and Builtins<61>-Footnote-225319239
Ref: Core and Builtins<61>-Footnote-235319305
Ref: Core and Builtins<61>-Footnote-245319371
Ref: Core and Builtins<61>-Footnote-255319437
Ref: Core and Builtins<61>-Footnote-265319503
Ref: Core and Builtins<61>-Footnote-275319569
Ref: Core and Builtins<61>-Footnote-285319635
Ref: Core and Builtins<61>-Footnote-295319701
Ref: Core and Builtins<61>-Footnote-305319767
Ref: Core and Builtins<61>-Footnote-315319833
Ref: Core and Builtins<61>-Footnote-325319899
Ref: Core and Builtins<61>-Footnote-335319965
Ref: Core and Builtins<61>-Footnote-345320031
Ref: Core and Builtins<61>-Footnote-355320097
Ref: Core and Builtins<61>-Footnote-365320140
Ref: Core and Builtins<61>-Footnote-375320206
Ref: Core and Builtins<61>-Footnote-385320272
Ref: Core and Builtins<61>-Footnote-395320338
Ref: Core and Builtins<61>-Footnote-405320404
Ref: Core and Builtins<61>-Footnote-415320470
Ref: Core and Builtins<61>-Footnote-425320536
Ref: Core and Builtins<61>-Footnote-435320602
Ref: Core and Builtins<61>-Footnote-445320668
Ref: Core and Builtins<61>-Footnote-455320734
Ref: Core and Builtins<61>-Footnote-465320800
Ref: Core and Builtins<61>-Footnote-475320866
Ref: Core and Builtins<61>-Footnote-485320932
Ref: Core and Builtins<61>-Footnote-495320998
Ref: Core and Builtins<61>-Footnote-505321064
Ref: Core and Builtins<61>-Footnote-515321130
Ref: Core and Builtins<61>-Footnote-525321196
Ref: Core and Builtins<61>-Footnote-535321262
Ref: Core and Builtins<61>-Footnote-545321328
Ref: Core and Builtins<61>-Footnote-555321394
Ref: Core and Builtins<61>-Footnote-565321460
Ref: Core and Builtins<61>-Footnote-575321526
Ref: Core and Builtins<61>-Footnote-585321592
Ref: Core and Builtins<61>-Footnote-595321658
Ref: Core and Builtins<61>-Footnote-605321724
Ref: Core and Builtins<61>-Footnote-615321790
Ref: Core and Builtins<61>-Footnote-625321856
Ref: Core and Builtins<61>-Footnote-635321922
Ref: Core and Builtins<61>-Footnote-645321988
Ref: Core and Builtins<61>-Footnote-655322054
Ref: Core and Builtins<61>-Footnote-665322120
Ref: Core and Builtins<61>-Footnote-675322186
Ref: Core and Builtins<61>-Footnote-685322252
Ref: Core and Builtins<61>-Footnote-695322318
Ref: Core and Builtins<61>-Footnote-705322384
Ref: Core and Builtins<61>-Footnote-715322450
Ref: Core and Builtins<61>-Footnote-725322516
Ref: Core and Builtins<61>-Footnote-735322582
Ref: Core and Builtins<61>-Footnote-745322648
Ref: Core and Builtins<61>-Footnote-755322714
Ref: Core and Builtins<61>-Footnote-765322780
Ref: Core and Builtins<61>-Footnote-775322846
Ref: Core and Builtins<61>-Footnote-785322912
Ref: Core and Builtins<61>-Footnote-795322978
Ref: Core and Builtins<61>-Footnote-805323044
Ref: Core and Builtins<61>-Footnote-815323110
Ref: Core and Builtins<61>-Footnote-825323176
Ref: Core and Builtins<61>-Footnote-835323242
Ref: Core and Builtins<61>-Footnote-845323308
Ref: Core and Builtins<61>-Footnote-855323374
Ref: Core and Builtins<61>-Footnote-865323440
Ref: Core and Builtins<61>-Footnote-875323506
Ref: Core and Builtins<61>-Footnote-885323572
Ref: Core and Builtins<61>-Footnote-895323638
Ref: Core and Builtins<61>-Footnote-905323704
Ref: Core and Builtins<61>-Footnote-915323747
Ref: Core and Builtins<61>-Footnote-925323813
Ref: Core and Builtins<61>-Footnote-935323879
Ref: Core and Builtins<61>-Footnote-945323945
Ref: Core and Builtins<61>-Footnote-955324011
Ref: Core and Builtins<61>-Footnote-965324077
Ref: Core and Builtins<61>-Footnote-975324143
Ref: Core and Builtins<61>-Footnote-985324209
Ref: Core and Builtins<61>-Footnote-995324275
Ref: Core and Builtins<61>-Footnote-1005324341
Ref: Core and Builtins<61>-Footnote-1015324408
Ref: Core and Builtins<61>-Footnote-1025324475
Ref: Core and Builtins<61>-Footnote-1035324542
Ref: Core and Builtins<61>-Footnote-1045324609
Ref: Core and Builtins<61>-Footnote-1055324676
Ref: Core and Builtins<61>-Footnote-1065324743
Ref: Core and Builtins<61>-Footnote-1075324810
Ref: Core and Builtins<61>-Footnote-1085324877
Ref: Core and Builtins<61>-Footnote-1095324944
Ref: Core and Builtins<61>-Footnote-1105325011
Ref: Core and Builtins<61>-Footnote-1115325078
Ref: Core and Builtins<61>-Footnote-1125325145
Ref: Core and Builtins<61>-Footnote-1135325212
Ref: Core and Builtins<61>-Footnote-1145325279
Ref: Core and Builtins<61>-Footnote-1155325346
Ref: Core and Builtins<61>-Footnote-1165325413
Ref: Core and Builtins<61>-Footnote-1175325480
Ref: Core and Builtins<61>-Footnote-1185325547
Ref: Core and Builtins<61>-Footnote-1195325614
Ref: Core and Builtins<61>-Footnote-1205325681
Ref: Core and Builtins<61>-Footnote-1215325748
Ref: Core and Builtins<61>-Footnote-1225325815
Ref: Core and Builtins<61>-Footnote-1235325882
Ref: Core and Builtins<61>-Footnote-1245325949
Ref: Core and Builtins<61>-Footnote-1255326016
Ref: Core and Builtins<61>-Footnote-1265326083
Ref: Core and Builtins<61>-Footnote-1275326150
Ref: Core and Builtins<61>-Footnote-1285326217
Ref: Core and Builtins<61>-Footnote-1295326284
Ref: Core and Builtins<61>-Footnote-1305326351
Ref: Core and Builtins<61>-Footnote-1315326418
Ref: Core and Builtins<61>-Footnote-1325326485
Ref: Core and Builtins<61>-Footnote-1335326552
Ref: Core and Builtins<61>-Footnote-1345326619
Ref: Core and Builtins<61>-Footnote-1355326686
Ref: Core and Builtins<61>-Footnote-1365326753
Ref: Core and Builtins<61>-Footnote-1375326820
Ref: Core and Builtins<61>-Footnote-1385326887
Ref: Core and Builtins<61>-Footnote-1395326954
Ref: Core and Builtins<61>-Footnote-1405327021
Ref: Core and Builtins<61>-Footnote-1415327088
Ref: Core and Builtins<61>-Footnote-1425327155
Ref: Core and Builtins<61>-Footnote-1435327222
Ref: Core and Builtins<61>-Footnote-1445327289
Ref: Core and Builtins<61>-Footnote-1455327356
Ref: Core and Builtins<61>-Footnote-1465327423
Ref: Core and Builtins<61>-Footnote-1475327490
Ref: Core and Builtins<61>-Footnote-1485327557
Node: Library<61>5327624
Ref: whatsnew/changelog id5365327748
Ref: 1a225327748
Ref: Library<61>-Footnote-15374247
Ref: Library<61>-Footnote-25374312
Ref: Library<61>-Footnote-35374377
Ref: Library<61>-Footnote-45374442
Ref: Library<61>-Footnote-55374507
Ref: Library<61>-Footnote-65374572
Ref: Library<61>-Footnote-75374637
Ref: Library<61>-Footnote-85374702
Ref: Library<61>-Footnote-95374767
Ref: Library<61>-Footnote-105374832
Ref: Library<61>-Footnote-115374898
Ref: Library<61>-Footnote-125374964
Ref: Library<61>-Footnote-135375030
Ref: Library<61>-Footnote-145375096
Ref: Library<61>-Footnote-155375162
Ref: Library<61>-Footnote-165375228
Ref: Library<61>-Footnote-175375294
Ref: Library<61>-Footnote-185375360
Ref: Library<61>-Footnote-195375426
Ref: Library<61>-Footnote-205375492
Ref: Library<61>-Footnote-215375558
Ref: Library<61>-Footnote-225375626
Ref: Library<61>-Footnote-235375692
Ref: Library<61>-Footnote-245375758
Ref: Library<61>-Footnote-255375824
Ref: Library<61>-Footnote-265375890
Ref: Library<61>-Footnote-275375933
Ref: Library<61>-Footnote-285375999
Ref: Library<61>-Footnote-295376065
Ref: Library<61>-Footnote-305376131
Ref: Library<61>-Footnote-315376197
Ref: Library<61>-Footnote-325376263
Ref: Library<61>-Footnote-335376329
Ref: Library<61>-Footnote-345376395
Ref: Library<61>-Footnote-355376460
Ref: Library<61>-Footnote-365376526
Ref: Library<61>-Footnote-375376592
Ref: Library<61>-Footnote-385376658
Ref: Library<61>-Footnote-395376724
Ref: Library<61>-Footnote-405376789
Ref: Library<61>-Footnote-415376855
Ref: Library<61>-Footnote-425376921
Ref: Library<61>-Footnote-435376987
Ref: Library<61>-Footnote-445377053
Ref: Library<61>-Footnote-455377119
Ref: Library<61>-Footnote-465377185
Ref: Library<61>-Footnote-475377251
Ref: Library<61>-Footnote-485377317
Ref: Library<61>-Footnote-495377383
Ref: Library<61>-Footnote-505377449
Ref: Library<61>-Footnote-515377515
Ref: Library<61>-Footnote-525377581
Ref: Library<61>-Footnote-535377646
Ref: Library<61>-Footnote-545377712
Ref: Library<61>-Footnote-555377778
Ref: Library<61>-Footnote-565377844
Ref: Library<61>-Footnote-575377910
Ref: Library<61>-Footnote-585377976
Ref: Library<61>-Footnote-595378042
Ref: Library<61>-Footnote-605378108
Ref: Library<61>-Footnote-615378174
Ref: Library<61>-Footnote-625378240
Ref: Library<61>-Footnote-635378306
Ref: Library<61>-Footnote-645378372
Ref: Library<61>-Footnote-655378438
Ref: Library<61>-Footnote-665378504
Ref: Library<61>-Footnote-675378570
Ref: Library<61>-Footnote-685378636
Ref: Library<61>-Footnote-695378702
Ref: Library<61>-Footnote-705378768
Ref: Library<61>-Footnote-715378834
Ref: Library<61>-Footnote-725378900
Ref: Library<61>-Footnote-735378965
Ref: Library<61>-Footnote-745379031
Ref: Library<61>-Footnote-755379097
Ref: Library<61>-Footnote-765379163
Ref: Library<61>-Footnote-775379229
Ref: Library<61>-Footnote-785379295
Ref: Library<61>-Footnote-795379361
Ref: Library<61>-Footnote-805379427
Ref: Library<61>-Footnote-815379493
Ref: Library<61>-Footnote-825379559
Ref: Library<61>-Footnote-835379625
Ref: Library<61>-Footnote-845379691
Ref: Library<61>-Footnote-855379757
Ref: Library<61>-Footnote-865379823
Ref: Library<61>-Footnote-875379889
Ref: Library<61>-Footnote-885379955
Ref: Library<61>-Footnote-895380021
Ref: Library<61>-Footnote-905380087
Ref: Library<61>-Footnote-915380153
Ref: Library<61>-Footnote-925380219
Ref: Library<61>-Footnote-935380285
Ref: Library<61>-Footnote-945380351
Ref: Library<61>-Footnote-955380417
Ref: Library<61>-Footnote-965380483
Ref: Library<61>-Footnote-975380549
Ref: Library<61>-Footnote-985380615
Ref: Library<61>-Footnote-995380681
Ref: Library<61>-Footnote-1005380747
Ref: Library<61>-Footnote-1015380814
Ref: Library<61>-Footnote-1025380881
Ref: Library<61>-Footnote-1035380948
Ref: Library<61>-Footnote-1045381015
Ref: Library<61>-Footnote-1055381082
Ref: Library<61>-Footnote-1065381149
Ref: Library<61>-Footnote-1075381216
Ref: Library<61>-Footnote-1085381283
Ref: Library<61>-Footnote-1095381350
Ref: Library<61>-Footnote-1105381417
Ref: Library<61>-Footnote-1115381484
Ref: Library<61>-Footnote-1125381551
Ref: Library<61>-Footnote-1135381618
Ref: Library<61>-Footnote-1145381685
Ref: Library<61>-Footnote-1155381752
Ref: Library<61>-Footnote-1165381819
Ref: Library<61>-Footnote-1175381885
Ref: Library<61>-Footnote-1185381952
Ref: Library<61>-Footnote-1195382019
Ref: Library<61>-Footnote-1205382086
Ref: Library<61>-Footnote-1215382153
Ref: Library<61>-Footnote-1225382220
Ref: Library<61>-Footnote-1235382287
Ref: Library<61>-Footnote-1245382354
Ref: Library<61>-Footnote-1255382421
Ref: Library<61>-Footnote-1265382488
Ref: Library<61>-Footnote-1275382555
Ref: Library<61>-Footnote-1285382622
Ref: Library<61>-Footnote-1295382689
Ref: Library<61>-Footnote-1305382756
Ref: Library<61>-Footnote-1315382823
Ref: Library<61>-Footnote-1325382890
Ref: Library<61>-Footnote-1335382957
Ref: Library<61>-Footnote-1345383024
Ref: Library<61>-Footnote-1355383091
Ref: Library<61>-Footnote-1365383158
Ref: Library<61>-Footnote-1375383225
Ref: Library<61>-Footnote-1385383292
Ref: Library<61>-Footnote-1395383359
Ref: Library<61>-Footnote-1405383426
Ref: Library<61>-Footnote-1415383493
Ref: Library<61>-Footnote-1425383560
Ref: Library<61>-Footnote-1435383627
Ref: Library<61>-Footnote-1445383694
Ref: Library<61>-Footnote-1455383761
Ref: Library<61>-Footnote-1465383828
Ref: Library<61>-Footnote-1475383894
Ref: Library<61>-Footnote-1485383961
Ref: Library<61>-Footnote-1495384028
Ref: Library<61>-Footnote-1505384095
Ref: Library<61>-Footnote-1515384162
Ref: Library<61>-Footnote-1525384229
Ref: Library<61>-Footnote-1535384296
Ref: Library<61>-Footnote-1545384363
Ref: Library<61>-Footnote-1555384430
Ref: Library<61>-Footnote-1565384497
Ref: Library<61>-Footnote-1575384564
Ref: Library<61>-Footnote-1585384631
Ref: Library<61>-Footnote-1595384698
Ref: Library<61>-Footnote-1605384765
Ref: Library<61>-Footnote-1615384832
Ref: Library<61>-Footnote-1625384899
Ref: Library<61>-Footnote-1635384966
Ref: Library<61>-Footnote-1645385033
Ref: Library<61>-Footnote-1655385100
Ref: Library<61>-Footnote-1665385167
Ref: Library<61>-Footnote-1675385234
Ref: Library<61>-Footnote-1685385301
Ref: Library<61>-Footnote-1695385368
Ref: Library<61>-Footnote-1705385434
Ref: Library<61>-Footnote-1715385501
Ref: Library<61>-Footnote-1725385568
Ref: Library<61>-Footnote-1735385635
Ref: Library<61>-Footnote-1745385702
Ref: Library<61>-Footnote-1755385769
Ref: Library<61>-Footnote-1765385836
Ref: Library<61>-Footnote-1775385903
Ref: Library<61>-Footnote-1785385970
Ref: Library<61>-Footnote-1795386037
Ref: Library<61>-Footnote-1805386104
Ref: Library<61>-Footnote-1815386170
Ref: Library<61>-Footnote-1825386237
Ref: Library<61>-Footnote-1835386304
Ref: Library<61>-Footnote-1845386371
Ref: Library<61>-Footnote-1855386438
Ref: Library<61>-Footnote-1865386505
Ref: Library<61>-Footnote-1875386571
Ref: Library<61>-Footnote-1885386638
Ref: Library<61>-Footnote-1895386705
Ref: Library<61>-Footnote-1905386772
Ref: Library<61>-Footnote-1915386839
Ref: Library<61>-Footnote-1925386906
Ref: Library<61>-Footnote-1935386973
Ref: Library<61>-Footnote-1945387040
Ref: Library<61>-Footnote-1955387107
Ref: Library<61>-Footnote-1965387174
Ref: Library<61>-Footnote-1975387241
Ref: Library<61>-Footnote-1985387308
Ref: Library<61>-Footnote-1995387375
Ref: Library<61>-Footnote-2005387442
Ref: Library<61>-Footnote-2015387509
Ref: Library<61>-Footnote-2025387576
Ref: Library<61>-Footnote-2035387643
Ref: Library<61>-Footnote-2045387710
Ref: Library<61>-Footnote-2055387777
Ref: Library<61>-Footnote-2065387844
Ref: Library<61>-Footnote-2075387911
Ref: Library<61>-Footnote-2085387978
Ref: Library<61>-Footnote-2095388045
Ref: Library<61>-Footnote-2105388112
Ref: Library<61>-Footnote-2115388179
Ref: Library<61>-Footnote-2125388246
Ref: Library<61>-Footnote-2135388313
Ref: Library<61>-Footnote-2145388380
Ref: Library<61>-Footnote-2155388447
Ref: Library<61>-Footnote-2165388514
Ref: Library<61>-Footnote-2175388581
Ref: Library<61>-Footnote-2185388648
Ref: Library<61>-Footnote-2195388715
Ref: Library<61>-Footnote-2205388782
Ref: Library<61>-Footnote-2215388849
Ref: Library<61>-Footnote-2225388916
Ref: Library<61>-Footnote-2235388983
Ref: Library<61>-Footnote-2245389050
Ref: Library<61>-Footnote-2255389116
Ref: Library<61>-Footnote-2265389183
Ref: Library<61>-Footnote-2275389250
Ref: Library<61>-Footnote-2285389317
Ref: Library<61>-Footnote-2295389384
Ref: Library<61>-Footnote-2305389451
Ref: Library<61>-Footnote-2315389518
Ref: Library<61>-Footnote-2325389585
Ref: Library<61>-Footnote-2335389652
Ref: Library<61>-Footnote-2345389719
Ref: Library<61>-Footnote-2355389786
Ref: Library<61>-Footnote-2365389853
Ref: Library<61>-Footnote-2375389920
Ref: Library<61>-Footnote-2385389987
Ref: Library<61>-Footnote-2395390054
Ref: Library<61>-Footnote-2405390121
Ref: Library<61>-Footnote-2415390188
Ref: Library<61>-Footnote-2425390255
Ref: Library<61>-Footnote-2435390322
Ref: Library<61>-Footnote-2445390389
Ref: Library<61>-Footnote-2455390456
Ref: Library<61>-Footnote-2465390523
Ref: Library<61>-Footnote-2475390590
Ref: Library<61>-Footnote-2485390657
Ref: Library<61>-Footnote-2495390724
Ref: Library<61>-Footnote-2505390791
Ref: Library<61>-Footnote-2515390858
Ref: Library<61>-Footnote-2525390925
Ref: Library<61>-Footnote-2535390992
Ref: Library<61>-Footnote-2545391059
Ref: Library<61>-Footnote-2555391126
Ref: Library<61>-Footnote-2565391193
Ref: Library<61>-Footnote-2575391260
Ref: Library<61>-Footnote-2585391327
Ref: Library<61>-Footnote-2595391394
Ref: Library<61>-Footnote-2605391461
Ref: Library<61>-Footnote-2615391528
Ref: Library<61>-Footnote-2625391595
Ref: Library<61>-Footnote-2635391662
Ref: Library<61>-Footnote-2645391729
Ref: Library<61>-Footnote-2655391796
Ref: Library<61>-Footnote-2665391863
Ref: Library<61>-Footnote-2675391930
Ref: Library<61>-Footnote-2685391997
Ref: Library<61>-Footnote-2695392064
Ref: Library<61>-Footnote-2705392131
Ref: Library<61>-Footnote-2715392198
Ref: Library<61>-Footnote-2725392265
Ref: Library<61>-Footnote-2735392321
Ref: Library<61>-Footnote-2745392388
Ref: Library<61>-Footnote-2755392455
Ref: Library<61>-Footnote-2765392522
Ref: Library<61>-Footnote-2775392589
Ref: Library<61>-Footnote-2785392656
Ref: Library<61>-Footnote-2795392723
Ref: Library<61>-Footnote-2805392790
Ref: Library<61>-Footnote-2815392857
Ref: Library<61>-Footnote-2825392924
Ref: Library<61>-Footnote-2835392991
Ref: Library<61>-Footnote-2845393058
Ref: Library<61>-Footnote-2855393125
Ref: Library<61>-Footnote-2865393192
Ref: Library<61>-Footnote-2875393259
Ref: Library<61>-Footnote-2885393326
Ref: Library<61>-Footnote-2895393393
Ref: Library<61>-Footnote-2905393460
Ref: Library<61>-Footnote-2915393527
Ref: Library<61>-Footnote-2925393594
Ref: Library<61>-Footnote-2935393661
Ref: Library<61>-Footnote-2945393728
Ref: Library<61>-Footnote-2955393795
Ref: Library<61>-Footnote-2965393862
Ref: Library<61>-Footnote-2975393929
Ref: Library<61>-Footnote-2985393996
Ref: Library<61>-Footnote-2995394063
Ref: Library<61>-Footnote-3005394130
Ref: Library<61>-Footnote-3015394197
Ref: Library<61>-Footnote-3025394264
Ref: Library<61>-Footnote-3035394331
Ref: Library<61>-Footnote-3045394398
Ref: Library<61>-Footnote-3055394465
Ref: Library<61>-Footnote-3065394532
Ref: Library<61>-Footnote-3075394599
Ref: Library<61>-Footnote-3085394666
Ref: Library<61>-Footnote-3095394733
Ref: Library<61>-Footnote-3105394800
Ref: Library<61>-Footnote-3115394867
Ref: Library<61>-Footnote-3125394934
Ref: Library<61>-Footnote-3135395001
Ref: Library<61>-Footnote-3145395068
Ref: Library<61>-Footnote-3155395135
Ref: Library<61>-Footnote-3165395202
Ref: Library<61>-Footnote-3175395269
Ref: Library<61>-Footnote-3185395336
Ref: Library<61>-Footnote-3195395403
Ref: Library<61>-Footnote-3205395470
Ref: Library<61>-Footnote-3215395537
Ref: Library<61>-Footnote-3225395604
Ref: Library<61>-Footnote-3235395671
Ref: Library<61>-Footnote-3245395738
Ref: Library<61>-Footnote-3255395805
Ref: Library<61>-Footnote-3265395872
Node: Documentation<55>5395939
Ref: whatsnew/changelog id5375396051
Ref: 1a235396051
Ref: Documentation<55>-Footnote-15398215
Ref: Documentation<55>-Footnote-25398280
Ref: Documentation<55>-Footnote-35398345
Ref: Documentation<55>-Footnote-45398410
Ref: Documentation<55>-Footnote-55398475
Ref: Documentation<55>-Footnote-65398540
Ref: Documentation<55>-Footnote-75398605
Ref: Documentation<55>-Footnote-85398670
Ref: Documentation<55>-Footnote-95398735
Ref: Documentation<55>-Footnote-105398800
Ref: Documentation<55>-Footnote-115398866
Ref: Documentation<55>-Footnote-125398932
Ref: Documentation<55>-Footnote-135398998
Ref: Documentation<55>-Footnote-145399064
Ref: Documentation<55>-Footnote-155399130
Ref: Documentation<55>-Footnote-165399196
Ref: Documentation<55>-Footnote-175399239
Node: Tests<55>5399305
Ref: whatsnew/changelog id5385399415
Ref: 1a265399415
Ref: Tests<55>-Footnote-15402161
Ref: Tests<55>-Footnote-25402226
Ref: Tests<55>-Footnote-35402291
Ref: Tests<55>-Footnote-45402356
Ref: Tests<55>-Footnote-55402421
Ref: Tests<55>-Footnote-65402486
Ref: Tests<55>-Footnote-75402551
Ref: Tests<55>-Footnote-85402616
Ref: Tests<55>-Footnote-95402681
Ref: Tests<55>-Footnote-105402746
Ref: Tests<55>-Footnote-115402812
Ref: Tests<55>-Footnote-125402878
Ref: Tests<55>-Footnote-135402944
Ref: Tests<55>-Footnote-145403010
Ref: Tests<55>-Footnote-155403076
Ref: Tests<55>-Footnote-165403142
Ref: Tests<55>-Footnote-175403208
Ref: Tests<55>-Footnote-185403274
Ref: Tests<55>-Footnote-195403340
Node: Build<58>5403406
Ref: whatsnew/changelog id5395403510
Ref: 1a275403510
Ref: Build<58>-Footnote-15408263
Ref: Build<58>-Footnote-25408328
Ref: Build<58>-Footnote-35408393
Ref: Build<58>-Footnote-45408458
Ref: Build<58>-Footnote-55408500
Ref: Build<58>-Footnote-65408565
Ref: Build<58>-Footnote-75408630
Ref: Build<58>-Footnote-85408695
Ref: Build<58>-Footnote-95408760
Ref: Build<58>-Footnote-105408825
Ref: Build<58>-Footnote-115408891
Ref: Build<58>-Footnote-125408957
Ref: Build<58>-Footnote-135409023
Ref: Build<58>-Footnote-145409089
Ref: Build<58>-Footnote-155409155
Ref: Build<58>-Footnote-165409221
Ref: Build<58>-Footnote-175409287
Ref: Build<58>-Footnote-185409353
Ref: Build<58>-Footnote-195409419
Ref: Build<58>-Footnote-205409485
Ref: Build<58>-Footnote-215409551
Ref: Build<58>-Footnote-225409617
Ref: Build<58>-Footnote-235409683
Ref: Build<58>-Footnote-245409749
Ref: Build<58>-Footnote-255409815
Ref: Build<58>-Footnote-265409881
Ref: Build<58>-Footnote-275409947
Ref: Build<58>-Footnote-285410013
Ref: Build<58>-Footnote-295410079
Ref: Build<58>-Footnote-305410145
Ref: Build<58>-Footnote-315410211
Ref: Build<58>-Footnote-325410277
Ref: Build<58>-Footnote-335410343
Ref: Build<58>-Footnote-345410409
Ref: Build<58>-Footnote-355410475
Ref: Build<58>-Footnote-365410541
Ref: Build<58>-Footnote-375410607
Node: Windows<53>5410673
Ref: whatsnew/changelog id5405410776
Ref: 1a285410776
Ref: Windows<53>-Footnote-15413262
Ref: Windows<53>-Footnote-25413327
Ref: Windows<53>-Footnote-35413392
Ref: Windows<53>-Footnote-45413457
Ref: Windows<53>-Footnote-55413522
Ref: Windows<53>-Footnote-65413587
Ref: Windows<53>-Footnote-75413652
Ref: Windows<53>-Footnote-85413717
Ref: Windows<53>-Footnote-95413782
Ref: Windows<53>-Footnote-105413847
Ref: Windows<53>-Footnote-115413913
Ref: Windows<53>-Footnote-125413979
Ref: Windows<53>-Footnote-135414045
Ref: Windows<53>-Footnote-145414111
Ref: Windows<53>-Footnote-155414177
Ref: Windows<53>-Footnote-165414243
Ref: Windows<53>-Footnote-175414309
Ref: Windows<53>-Footnote-185414375
Ref: Windows<53>-Footnote-195414441
Ref: Windows<53>-Footnote-205414507
Ref: Windows<53>-Footnote-215414573
Ref: Windows<53>-Footnote-225414639
Ref: Windows<53>-Footnote-235414705
Ref: Windows<53>-Footnote-245414771
Ref: Windows<53>-Footnote-255414837
Node: IDLE<45>5414903
Ref: whatsnew/changelog id5415415012
Ref: 1a295415012
Ref: IDLE<45>-Footnote-15424921
Ref: IDLE<45>-Footnote-25424986
Ref: IDLE<45>-Footnote-35425051
Ref: IDLE<45>-Footnote-45425116
Ref: IDLE<45>-Footnote-55425181
Ref: IDLE<45>-Footnote-65425246
Ref: IDLE<45>-Footnote-75425311
Ref: IDLE<45>-Footnote-85425376
Ref: IDLE<45>-Footnote-95425441
Ref: IDLE<45>-Footnote-105425506
Ref: IDLE<45>-Footnote-115425572
Ref: IDLE<45>-Footnote-125425638
Ref: IDLE<45>-Footnote-135425704
Ref: IDLE<45>-Footnote-145425770
Ref: IDLE<45>-Footnote-155425836
Ref: IDLE<45>-Footnote-165425902
Ref: IDLE<45>-Footnote-175425968
Ref: IDLE<45>-Footnote-185426034
Ref: IDLE<45>-Footnote-195426100
Ref: IDLE<45>-Footnote-205426166
Ref: IDLE<45>-Footnote-215426232
Ref: IDLE<45>-Footnote-225426298
Ref: IDLE<45>-Footnote-235426364
Ref: IDLE<45>-Footnote-245426430
Ref: IDLE<45>-Footnote-255426496
Ref: IDLE<45>-Footnote-265426562
Ref: IDLE<45>-Footnote-275426628
Ref: IDLE<45>-Footnote-285426694
Ref: IDLE<45>-Footnote-295426760
Ref: IDLE<45>-Footnote-305426826
Ref: IDLE<45>-Footnote-315426892
Ref: IDLE<45>-Footnote-325426958
Ref: IDLE<45>-Footnote-335427024
Ref: IDLE<45>-Footnote-345427090
Ref: IDLE<45>-Footnote-355427155
Ref: IDLE<45>-Footnote-365427221
Ref: IDLE<45>-Footnote-375427287
Ref: IDLE<45>-Footnote-385427353
Ref: IDLE<45>-Footnote-395427419
Ref: IDLE<45>-Footnote-405427485
Ref: IDLE<45>-Footnote-415427551
Ref: IDLE<45>-Footnote-425427617
Ref: IDLE<45>-Footnote-435427683
Ref: IDLE<45>-Footnote-445427748
Ref: IDLE<45>-Footnote-455427814
Ref: IDLE<45>-Footnote-465427880
Ref: IDLE<45>-Footnote-475427946
Ref: IDLE<45>-Footnote-485428012
Ref: IDLE<45>-Footnote-495428078
Ref: IDLE<45>-Footnote-505428144
Ref: IDLE<45>-Footnote-515428210
Node: Tools/Demos<30>5428276
Ref: whatsnew/changelog id5425428383
Ref: 1a2a5428383
Ref: Tools/Demos<30>-Footnote-15429865
Ref: Tools/Demos<30>-Footnote-25429930
Ref: Tools/Demos<30>-Footnote-35429972
Ref: Tools/Demos<30>-Footnote-45430037
Ref: Tools/Demos<30>-Footnote-55430102
Ref: Tools/Demos<30>-Footnote-65430167
Ref: Tools/Demos<30>-Footnote-75430232
Ref: Tools/Demos<30>-Footnote-85430297
Node: C API<55>5430362
Ref: whatsnew/changelog id5435430452
Ref: 1a2b5430452
Ref: C API<55>-Footnote-15433506
Ref: C API<55>-Footnote-25433571
Ref: C API<55>-Footnote-35433636
Ref: C API<55>-Footnote-45433701
Ref: C API<55>-Footnote-55433766
Ref: C API<55>-Footnote-65433830
Ref: C API<55>-Footnote-75433895
Ref: C API<55>-Footnote-85433960
Ref: C API<55>-Footnote-95434025
Ref: C API<55>-Footnote-105434090
Ref: C API<55>-Footnote-115434156
Ref: C API<55>-Footnote-125434222
Ref: C API<55>-Footnote-135434288
Ref: C API<55>-Footnote-145434354
Ref: C API<55>-Footnote-155434420
Node: Python 3 6 6 final5434486
Ref: whatsnew/changelog python-3-6-6-final5434623
Ref: 1a2c5434623
Node: Python 3 6 6 release candidate 15434751
Ref: whatsnew/changelog python-3-6-6-release-candidate-15434886
Ref: 1a2d5434886
Node: Core and Builtins<62>5435265
Ref: whatsnew/changelog id5445435375
Ref: 1a2e5435375
Ref: Core and Builtins<62>-Footnote-15436953
Ref: Core and Builtins<62>-Footnote-25437018
Ref: Core and Builtins<62>-Footnote-35437083
Ref: Core and Builtins<62>-Footnote-45437148
Ref: Core and Builtins<62>-Footnote-55437213
Ref: Core and Builtins<62>-Footnote-65437278
Ref: Core and Builtins<62>-Footnote-75437343
Ref: Core and Builtins<62>-Footnote-85437408
Ref: Core and Builtins<62>-Footnote-95437473
Ref: Core and Builtins<62>-Footnote-105437538
Ref: Core and Builtins<62>-Footnote-115437604
Ref: Core and Builtins<62>-Footnote-125437670
Node: Library<62>5437736
Ref: whatsnew/changelog id5455437872
Ref: 1a2f5437872
Ref: Library<62>-Footnote-15443339
Ref: Library<62>-Footnote-25443404
Ref: Library<62>-Footnote-35443469
Ref: Library<62>-Footnote-45443534
Ref: Library<62>-Footnote-55443599
Ref: Library<62>-Footnote-65443664
Ref: Library<62>-Footnote-75443729
Ref: Library<62>-Footnote-85443794
Ref: Library<62>-Footnote-95443859
Ref: Library<62>-Footnote-105443924
Ref: Library<62>-Footnote-115443990
Ref: Library<62>-Footnote-125444056
Ref: Library<62>-Footnote-135444122
Ref: Library<62>-Footnote-145444188
Ref: Library<62>-Footnote-155444254
Ref: Library<62>-Footnote-165444320
Ref: Library<62>-Footnote-175444386
Ref: Library<62>-Footnote-185444452
Ref: Library<62>-Footnote-195444518
Ref: Library<62>-Footnote-205444584
Ref: Library<62>-Footnote-215444650
Ref: Library<62>-Footnote-225444717
Ref: Library<62>-Footnote-235444783
Ref: Library<62>-Footnote-245444849
Ref: Library<62>-Footnote-255444915
Ref: Library<62>-Footnote-265444981
Ref: Library<62>-Footnote-275445047
Ref: Library<62>-Footnote-285445113
Ref: Library<62>-Footnote-295445156
Ref: Library<62>-Footnote-305445222
Ref: Library<62>-Footnote-315445288
Ref: Library<62>-Footnote-325445354
Ref: Library<62>-Footnote-335445420
Ref: Library<62>-Footnote-345445486
Ref: Library<62>-Footnote-355445552
Ref: Library<62>-Footnote-365445618
Ref: Library<62>-Footnote-375445684
Ref: Library<62>-Footnote-385445750
Ref: Library<62>-Footnote-395445816
Node: Documentation<56>5445882
Ref: whatsnew/changelog id5465446006
Ref: 1a305446006
Ref: Documentation<56>-Footnote-15447497
Ref: Documentation<56>-Footnote-25447562
Ref: Documentation<56>-Footnote-35447627
Ref: Documentation<56>-Footnote-45447692
Ref: Documentation<56>-Footnote-55447757
Ref: Documentation<56>-Footnote-65447822
Ref: Documentation<56>-Footnote-75447887
Ref: Documentation<56>-Footnote-85447952
Ref: Documentation<56>-Footnote-95448017
Ref: Documentation<56>-Footnote-105448082
Ref: Documentation<56>-Footnote-115448148
Ref: Documentation<56>-Footnote-125448214
Ref: Documentation<56>-Footnote-135448279
Node: Tests<56>5448345
Ref: whatsnew/changelog id5475448467
Ref: 1a315448467
Ref: Tests<56>-Footnote-15448689
Ref: Tests<56>-Footnote-25448754
Node: Build<59>5448819
Ref: whatsnew/changelog id5485448935
Ref: 1a325448935
Ref: Build<59>-Footnote-15449732
Ref: Build<59>-Footnote-25449796
Ref: Build<59>-Footnote-35449861
Ref: Build<59>-Footnote-45449926
Ref: Build<59>-Footnote-55449991
Node: Windows<54>5450056
Ref: whatsnew/changelog id5495450172
Ref: 1a335450172
Ref: Windows<54>-Footnote-15450309
Node: macOS<44>5450374
Ref: whatsnew/changelog id5505450489
Ref: 1a345450489
Ref: macOS<44>-Footnote-15450630
Node: IDLE<46>5450695
Ref: whatsnew/changelog id5515450814
Ref: 1a355450814
Ref: IDLE<46>-Footnote-15452869
Ref: IDLE<46>-Footnote-25452934
Ref: IDLE<46>-Footnote-35452999
Ref: IDLE<46>-Footnote-45453064
Ref: IDLE<46>-Footnote-55453129
Ref: IDLE<46>-Footnote-65453194
Ref: IDLE<46>-Footnote-75453259
Ref: IDLE<46>-Footnote-85453324
Ref: IDLE<46>-Footnote-95453389
Ref: IDLE<46>-Footnote-105453454
Ref: IDLE<46>-Footnote-115453520
Ref: IDLE<46>-Footnote-125453586
Node: Tools/Demos<31>5453652
Ref: whatsnew/changelog id5525453771
Ref: 1a365453771
Ref: Tools/Demos<31>-Footnote-15454522
Ref: Tools/Demos<31>-Footnote-25454587
Ref: Tools/Demos<31>-Footnote-35454652
Ref: Tools/Demos<31>-Footnote-45454717
Ref: Tools/Demos<31>-Footnote-55454782
Node: C API<56>5454847
Ref: whatsnew/changelog id5535454949
Ref: 1a375454949
Ref: C API<56>-Footnote-15455162
Node: Python 3 6 5 final5455227
Ref: whatsnew/changelog python-3-6-5-final5455376
Ref: 1a385455376
Node: Tests<57>5455509
Ref: whatsnew/changelog id5545455591
Ref: 1a395455591
Ref: Tests<57>-Footnote-15455745
Node: Build<60>5455810
Ref: whatsnew/changelog id5555455892
Ref: 1a3a5455892
Ref: Build<60>-Footnote-15456029
Node: Python 3 6 5 release candidate 15456094
Ref: whatsnew/changelog python-3-6-5-release-candidate-15456229
Ref: 1a3b5456229
Node: Security<38>5456634
Ref: whatsnew/changelog id5565456745
Ref: 1a3c5456745
Ref: Security<38>-Footnote-15457176
Ref: Security<38>-Footnote-25457241
Ref: Security<38>-Footnote-35457306
Ref: Security<38>-Footnote-45457361
Node: Core and Builtins<63>5457416
Ref: whatsnew/changelog id5575457547
Ref: 1a3d5457547
Ref: Core and Builtins<63>-Footnote-15459709
Ref: Core and Builtins<63>-Footnote-25459774
Ref: Core and Builtins<63>-Footnote-35459839
Ref: Core and Builtins<63>-Footnote-45459904
Ref: Core and Builtins<63>-Footnote-55459969
Ref: Core and Builtins<63>-Footnote-65460034
Ref: Core and Builtins<63>-Footnote-75460099
Ref: Core and Builtins<63>-Footnote-85460164
Ref: Core and Builtins<63>-Footnote-95460229
Ref: Core and Builtins<63>-Footnote-105460294
Ref: Core and Builtins<63>-Footnote-115460360
Ref: Core and Builtins<63>-Footnote-125460426
Ref: Core and Builtins<63>-Footnote-135460492
Ref: Core and Builtins<63>-Footnote-145460558
Node: Library<63>5460624
Ref: whatsnew/changelog id5585460760
Ref: 1a3e5460760
Ref: Library<63>-Footnote-15466669
Ref: Library<63>-Footnote-25466734
Ref: Library<63>-Footnote-35466799
Ref: Library<63>-Footnote-45466864
Ref: Library<63>-Footnote-55466929
Ref: Library<63>-Footnote-65466994
Ref: Library<63>-Footnote-75467059
Ref: Library<63>-Footnote-85467124
Ref: Library<63>-Footnote-95467189
Ref: Library<63>-Footnote-105467254
Ref: Library<63>-Footnote-115467320
Ref: Library<63>-Footnote-125467386
Ref: Library<63>-Footnote-135467452
Ref: Library<63>-Footnote-145467518
Ref: Library<63>-Footnote-155467584
Ref: Library<63>-Footnote-165467650
Ref: Library<63>-Footnote-175467716
Ref: Library<63>-Footnote-185467782
Ref: Library<63>-Footnote-195467848
Ref: Library<63>-Footnote-205467914
Ref: Library<63>-Footnote-215467980
Ref: Library<63>-Footnote-225468046
Ref: Library<63>-Footnote-235468112
Ref: Library<63>-Footnote-245468178
Ref: Library<63>-Footnote-255468244
Ref: Library<63>-Footnote-265468310
Ref: Library<63>-Footnote-275468376
Ref: Library<63>-Footnote-285468442
Ref: Library<63>-Footnote-295468508
Ref: Library<63>-Footnote-305468574
Ref: Library<63>-Footnote-315468640
Ref: Library<63>-Footnote-325468706
Ref: Library<63>-Footnote-335468772
Ref: Library<63>-Footnote-345468838
Ref: Library<63>-Footnote-355468904
Ref: Library<63>-Footnote-365468970
Ref: Library<63>-Footnote-375469036
Ref: Library<63>-Footnote-385469102
Ref: Library<63>-Footnote-395469168
Ref: Library<63>-Footnote-405469234
Node: Documentation<57>5469300
Ref: whatsnew/changelog id5595469424
Ref: 1a3f5469424
Ref: Documentation<57>-Footnote-15470260
Ref: Documentation<57>-Footnote-25470325
Ref: Documentation<57>-Footnote-35470390
Ref: Documentation<57>-Footnote-45470454
Ref: Documentation<57>-Footnote-55470519
Ref: Documentation<57>-Footnote-65470584
Node: Tests<58>5470649
Ref: whatsnew/changelog id5605470771
Ref: 1a405470771
Ref: Tests<58>-Footnote-15471432
Ref: Tests<58>-Footnote-25471497
Ref: Tests<58>-Footnote-35471562
Ref: Tests<58>-Footnote-45471627
Node: Build<61>5471692
Ref: whatsnew/changelog id5615471808
Ref: 1a415471808
Ref: Build<61>-Footnote-15471997
Node: Windows<55>5472062
Ref: whatsnew/changelog id5625472178
Ref: 1a425472178
Ref: Windows<55>-Footnote-15473128
Ref: Windows<55>-Footnote-25473193
Ref: Windows<55>-Footnote-35473258
Ref: Windows<55>-Footnote-45473323
Ref: Windows<55>-Footnote-55473388
Ref: Windows<55>-Footnote-65473453
Ref: Windows<55>-Footnote-75473518
Ref: Windows<55>-Footnote-85473583
Node: macOS<45>5473648
Ref: whatsnew/changelog id5635473763
Ref: 1a435473763
Ref: macOS<45>-Footnote-15474156
Node: IDLE<47>5474221
Ref: whatsnew/changelog id5645474340
Ref: 1a445474340
Ref: IDLE<47>-Footnote-15475822
Ref: IDLE<47>-Footnote-25475887
Ref: IDLE<47>-Footnote-35475952
Ref: IDLE<47>-Footnote-45476017
Ref: IDLE<47>-Footnote-55476082
Ref: IDLE<47>-Footnote-65476147
Ref: IDLE<47>-Footnote-75476212
Ref: IDLE<47>-Footnote-85476277
Node: Tools/Demos<32>5476342
Ref: whatsnew/changelog id5655476461
Ref: 1a455476461
Ref: Tools/Demos<32>-Footnote-15476881
Ref: Tools/Demos<32>-Footnote-25476946
Node: C API<57>5477011
Ref: whatsnew/changelog id5665477113
Ref: 1a465477113
Ref: C API<57>-Footnote-15477363
Node: Python 3 6 4 final5477428
Ref: whatsnew/changelog python-3-6-4-final5477577
Ref: 1a475477577
Node: Python 3 6 4 release candidate 15477726
Ref: whatsnew/changelog python-3-6-4-release-candidate-15477861
Ref: 1a485477861
Node: Core and Builtins<64>5478240
Ref: whatsnew/changelog id5675478350
Ref: 1a495478350
Ref: Core and Builtins<64>-Footnote-15483068
Ref: Core and Builtins<64>-Footnote-25483133
Ref: Core and Builtins<64>-Footnote-35483198
Ref: Core and Builtins<64>-Footnote-45483263
Ref: Core and Builtins<64>-Footnote-55483328
Ref: Core and Builtins<64>-Footnote-65483393
Ref: Core and Builtins<64>-Footnote-75483458
Ref: Core and Builtins<64>-Footnote-85483523
Ref: Core and Builtins<64>-Footnote-95483588
Ref: Core and Builtins<64>-Footnote-105483653
Ref: Core and Builtins<64>-Footnote-115483719
Ref: Core and Builtins<64>-Footnote-125483785
Ref: Core and Builtins<64>-Footnote-135483851
Ref: Core and Builtins<64>-Footnote-145483917
Ref: Core and Builtins<64>-Footnote-155483983
Ref: Core and Builtins<64>-Footnote-165484049
Ref: Core and Builtins<64>-Footnote-175484115
Ref: Core and Builtins<64>-Footnote-185484181
Ref: Core and Builtins<64>-Footnote-195484247
Ref: Core and Builtins<64>-Footnote-205484313
Ref: Core and Builtins<64>-Footnote-215484379
Ref: Core and Builtins<64>-Footnote-225484445
Ref: Core and Builtins<64>-Footnote-235484511
Ref: Core and Builtins<64>-Footnote-245484577
Node: Library<64>5484643
Ref: whatsnew/changelog id5685484779
Ref: 1a4a5484779
Ref: Library<64>-Footnote-15492090
Ref: Library<64>-Footnote-25492155
Ref: Library<64>-Footnote-35492220
Ref: Library<64>-Footnote-45492285
Ref: Library<64>-Footnote-55492350
Ref: Library<64>-Footnote-65492415
Ref: Library<64>-Footnote-75492480
Ref: Library<64>-Footnote-85492545
Ref: Library<64>-Footnote-95492610
Ref: Library<64>-Footnote-105492675
Ref: Library<64>-Footnote-115492741
Ref: Library<64>-Footnote-125492807
Ref: Library<64>-Footnote-135492873
Ref: Library<64>-Footnote-145492939
Ref: Library<64>-Footnote-155493005
Ref: Library<64>-Footnote-165493071
Ref: Library<64>-Footnote-175493136
Ref: Library<64>-Footnote-185493202
Ref: Library<64>-Footnote-195493268
Ref: Library<64>-Footnote-205493334
Ref: Library<64>-Footnote-215493400
Ref: Library<64>-Footnote-225493466
Ref: Library<64>-Footnote-235493532
Ref: Library<64>-Footnote-245493598
Ref: Library<64>-Footnote-255493664
Ref: Library<64>-Footnote-265493730
Ref: Library<64>-Footnote-275493796
Ref: Library<64>-Footnote-285493862
Ref: Library<64>-Footnote-295493928
Ref: Library<64>-Footnote-305493994
Ref: Library<64>-Footnote-315494060
Ref: Library<64>-Footnote-325494126
Ref: Library<64>-Footnote-335494192
Ref: Library<64>-Footnote-345494258
Ref: Library<64>-Footnote-355494324
Ref: Library<64>-Footnote-365494390
Ref: Library<64>-Footnote-375494456
Ref: Library<64>-Footnote-385494522
Ref: Library<64>-Footnote-395494588
Ref: Library<64>-Footnote-405494654
Ref: Library<64>-Footnote-415494720
Ref: Library<64>-Footnote-425494786
Ref: Library<64>-Footnote-435494852
Ref: Library<64>-Footnote-445494918
Ref: Library<64>-Footnote-455494984
Ref: Library<64>-Footnote-465495050
Ref: Library<64>-Footnote-475495116
Ref: Library<64>-Footnote-485495182
Ref: Library<64>-Footnote-495495248
Ref: Library<64>-Footnote-505495314
Ref: Library<64>-Footnote-515495380
Ref: Library<64>-Footnote-525495446
Node: Documentation<58>5495512
Ref: whatsnew/changelog id5695495636
Ref: 1a4b5495636
Ref: Documentation<58>-Footnote-15496125
Ref: Documentation<58>-Footnote-25496190
Ref: Documentation<58>-Footnote-35496255
Node: Tests<59>5496320
Ref: whatsnew/changelog id5705496442
Ref: 1a4c5496442
Ref: Tests<59>-Footnote-15497120
Ref: Tests<59>-Footnote-25497185
Ref: Tests<59>-Footnote-35497250
Ref: Tests<59>-Footnote-45497315
Node: Build<62>5497380
Ref: whatsnew/changelog id5715497496
Ref: 1a4d5497496
Ref: Build<62>-Footnote-15498400
Ref: Build<62>-Footnote-25498465
Ref: Build<62>-Footnote-35498530
Ref: Build<62>-Footnote-45498595
Ref: Build<62>-Footnote-55498660
Ref: Build<62>-Footnote-65498725
Ref: Build<62>-Footnote-75498790
Ref: Build<62>-Footnote-85498855
Ref: Build<62>-Footnote-95498920
Node: Windows<56>5498985
Ref: whatsnew/changelog id5725499101
Ref: 1a4e5499101
Ref: Windows<56>-Footnote-15499419
Ref: Windows<56>-Footnote-25499483
Node: macOS<46>5499548
Ref: whatsnew/changelog id5735499663
Ref: 1a4f5499663
Ref: macOS<46>-Footnote-15499797
Node: IDLE<48>5499862
Ref: whatsnew/changelog id5745499981
Ref: 1a505499981
Ref: IDLE<48>-Footnote-15503302
Ref: IDLE<48>-Footnote-25503367
Ref: IDLE<48>-Footnote-35503432
Ref: IDLE<48>-Footnote-45503497
Ref: IDLE<48>-Footnote-55503562
Ref: IDLE<48>-Footnote-65503627
Ref: IDLE<48>-Footnote-75503692
Ref: IDLE<48>-Footnote-85503757
Ref: IDLE<48>-Footnote-95503822
Ref: IDLE<48>-Footnote-105503887
Ref: IDLE<48>-Footnote-115503953
Ref: IDLE<48>-Footnote-125504019
Ref: IDLE<48>-Footnote-135504085
Ref: IDLE<48>-Footnote-145504151
Node: Tools/Demos<33>5504219
Ref: whatsnew/changelog id5755504338
Ref: 1a515504338
Ref: Tools/Demos<33>-Footnote-15504626
Node: C API<58>5504691
Ref: whatsnew/changelog id5765504793
Ref: 1a525504793
Ref: C API<58>-Footnote-15505521
Ref: C API<58>-Footnote-25505586
Ref: C API<58>-Footnote-35505651
Ref: C API<58>-Footnote-45505716
Node: Python 3 6 3 final5505781
Ref: whatsnew/changelog python-3-6-3-final5505930
Ref: 1a535505930
Node: Library<65>5506067
Ref: whatsnew/changelog id5775506151
Ref: 1a545506151
Ref: Library<65>-Footnote-15506353
Node: Build<63>5506418
Ref: whatsnew/changelog id5785506502
Ref: 1a555506502
Ref: Build<63>-Footnote-15506793
Ref: Build<63>-Footnote-25506858
Node: Python 3 6 3 release candidate 15506923
Ref: whatsnew/changelog python-3-6-3-release-candidate-15507058
Ref: 1a565507058
Node: Security<39>5507423
Ref: whatsnew/changelog id5795507534
Ref: 1a575507534
Ref: Security<39>-Footnote-15507840
Ref: Security<39>-Footnote-25507905
Node: Core and Builtins<65>5507970
Ref: whatsnew/changelog id5805508101
Ref: 1a585508101
Ref: Core and Builtins<65>-Footnote-15511618
Ref: Core and Builtins<65>-Footnote-25511683
Ref: Core and Builtins<65>-Footnote-35511748
Ref: Core and Builtins<65>-Footnote-45511813
Ref: Core and Builtins<65>-Footnote-55511878
Ref: Core and Builtins<65>-Footnote-65511943
Ref: Core and Builtins<65>-Footnote-75512008
Ref: Core and Builtins<65>-Footnote-85512073
Ref: Core and Builtins<65>-Footnote-95512138
Ref: Core and Builtins<65>-Footnote-105512203
Ref: Core and Builtins<65>-Footnote-115512269
Ref: Core and Builtins<65>-Footnote-125512335
Ref: Core and Builtins<65>-Footnote-135512401
Ref: Core and Builtins<65>-Footnote-145512467
Ref: Core and Builtins<65>-Footnote-155512533
Ref: Core and Builtins<65>-Footnote-165512599
Ref: Core and Builtins<65>-Footnote-175512665
Ref: Core and Builtins<65>-Footnote-185512731
Ref: Core and Builtins<65>-Footnote-195512797
Ref: Core and Builtins<65>-Footnote-205512863
Ref: Core and Builtins<65>-Footnote-215512929
Ref: Core and Builtins<65>-Footnote-225512995
Node: Library<66>5513061
Ref: whatsnew/changelog id5815513197
Ref: 1a595513197
Ref: Library<66>-Footnote-15519184
Ref: Library<66>-Footnote-25519249
Ref: Library<66>-Footnote-35519314
Ref: Library<66>-Footnote-45519379
Ref: Library<66>-Footnote-55519444
Ref: Library<66>-Footnote-65519509
Ref: Library<66>-Footnote-75519574
Ref: Library<66>-Footnote-85519639
Ref: Library<66>-Footnote-95519704
Ref: Library<66>-Footnote-105519769
Ref: Library<66>-Footnote-115519835
Ref: Library<66>-Footnote-125519901
Ref: Library<66>-Footnote-135519967
Ref: Library<66>-Footnote-145520033
Ref: Library<66>-Footnote-155520099
Ref: Library<66>-Footnote-165520164
Ref: Library<66>-Footnote-175520230
Ref: Library<66>-Footnote-185520296
Ref: Library<66>-Footnote-195520339
Ref: Library<66>-Footnote-205520405
Ref: Library<66>-Footnote-215520471
Ref: Library<66>-Footnote-225520537
Ref: Library<66>-Footnote-235520603
Ref: Library<66>-Footnote-245520669
Ref: Library<66>-Footnote-255520735
Ref: Library<66>-Footnote-265520801
Ref: Library<66>-Footnote-275520867
Ref: Library<66>-Footnote-285520933
Ref: Library<66>-Footnote-295520999
Ref: Library<66>-Footnote-305521065
Ref: Library<66>-Footnote-315521131
Ref: Library<66>-Footnote-325521197
Ref: Library<66>-Footnote-335521263
Ref: Library<66>-Footnote-345521329
Ref: Library<66>-Footnote-355521395
Ref: Library<66>-Footnote-365521461
Ref: Library<66>-Footnote-375521527
Ref: Library<66>-Footnote-385521593
Ref: Library<66>-Footnote-395521659
Ref: Library<66>-Footnote-405521725
Ref: Library<66>-Footnote-415521791
Ref: Library<66>-Footnote-425521857
Node: Documentation<59>5521923
Ref: whatsnew/changelog id5825522047
Ref: 1a5a5522047
Ref: Documentation<59>-Footnote-15522470
Ref: Documentation<59>-Footnote-25522535
Ref: Documentation<59>-Footnote-35522600
Node: Tests<60>5522665
Ref: whatsnew/changelog id5835522787
Ref: 1a5b5522787
Ref: Tests<60>-Footnote-15523488
Ref: Tests<60>-Footnote-25523553
Ref: Tests<60>-Footnote-35523618
Ref: Tests<60>-Footnote-45523683
Node: Build<64>5523748
Ref: whatsnew/changelog id5845523864
Ref: 1a5c5523864
Ref: Build<64>-Footnote-15524037
Node: Windows<57>5524102
Ref: whatsnew/changelog id5855524217
Ref: 1a5d5524217
Ref: Windows<57>-Footnote-15524725
Ref: Windows<57>-Footnote-25524790
Ref: Windows<57>-Footnote-35524855
Ref: Windows<57>-Footnote-45524920
Node: IDLE<49>5524985
Ref: whatsnew/changelog id5865525106
Ref: 1a5e5525106
Ref: IDLE<49>-Footnote-15533851
Ref: IDLE<49>-Footnote-25533916
Ref: IDLE<49>-Footnote-35533981
Ref: IDLE<49>-Footnote-45534046
Ref: IDLE<49>-Footnote-55534111
Ref: IDLE<49>-Footnote-65534176
Ref: IDLE<49>-Footnote-75534241
Ref: IDLE<49>-Footnote-85534306
Ref: IDLE<49>-Footnote-95534371
Ref: IDLE<49>-Footnote-105534436
Ref: IDLE<49>-Footnote-115534502
Ref: IDLE<49>-Footnote-125534568
Ref: IDLE<49>-Footnote-135534634
Ref: IDLE<49>-Footnote-145534700
Ref: IDLE<49>-Footnote-155534766
Ref: IDLE<49>-Footnote-165534832
Ref: IDLE<49>-Footnote-175534898
Ref: IDLE<49>-Footnote-185534964
Ref: IDLE<49>-Footnote-195535030
Ref: IDLE<49>-Footnote-205535096
Ref: IDLE<49>-Footnote-215535162
Ref: IDLE<49>-Footnote-225535228
Ref: IDLE<49>-Footnote-235535294
Ref: IDLE<49>-Footnote-245535360
Ref: IDLE<49>-Footnote-255535426
Ref: IDLE<49>-Footnote-265535492
Ref: IDLE<49>-Footnote-275535558
Ref: IDLE<49>-Footnote-285535624
Ref: IDLE<49>-Footnote-295535690
Ref: IDLE<49>-Footnote-305535756
Ref: IDLE<49>-Footnote-315535822
Ref: IDLE<49>-Footnote-325535888
Ref: IDLE<49>-Footnote-335535954
Ref: IDLE<49>-Footnote-345536020
Ref: IDLE<49>-Footnote-355536085
Ref: IDLE<49>-Footnote-365536151
Ref: IDLE<49>-Footnote-375536217
Ref: IDLE<49>-Footnote-385536283
Ref: IDLE<49>-Footnote-395536349
Ref: IDLE<49>-Footnote-405536415
Ref: IDLE<49>-Footnote-415536481
Ref: IDLE<49>-Footnote-425536547
Ref: IDLE<49>-Footnote-435536613
Node: Tools/Demos<34>5536678
Ref: whatsnew/changelog id5875536779
Ref: 1a5f5536779
Ref: Tools/Demos<34>-Footnote-15537337
Ref: Tools/Demos<34>-Footnote-25537402
Node: Python 3 6 2 final5537444
Ref: whatsnew/changelog python-3-6-2-final5537593
Ref: 1a605537593
Node: Python 3 6 2 release candidate 25537714
Ref: whatsnew/changelog python-3-6-2-release-candidate-25537863
Ref: 1a615537863
Node: Security<40>5538010
Ref: whatsnew/changelog id5885538091
Ref: 1a625538091
Ref: Security<40>-Footnote-15539212
Ref: Security<40>-Footnote-25539277
Ref: Security<40>-Footnote-35539342
Ref: Security<40>-Footnote-45539397
Ref: Security<40>-Footnote-55539452
Ref: Security<40>-Footnote-65539507
Ref: Security<40>-Footnote-75539562
Ref: Security<40>-Footnote-85539617
Ref: Security<40>-Footnote-95539672
Node: Python 3 6 2 release candidate 15539737
Ref: whatsnew/changelog python-3-6-2-release-candidate-15539886
Ref: 1a635539886
Node: Security<41>5540271
Ref: whatsnew/changelog id5895540382
Ref: 1a645540382
Ref: Security<41>-Footnote-15540655
Ref: Security<41>-Footnote-25540720
Ref: Security<41>-Footnote-35540775
Node: Core and Builtins<66>5540830
Ref: whatsnew/changelog id5905540961
Ref: 1a655540961
Ref: Core and Builtins<66>-Footnote-15542935
Ref: Core and Builtins<66>-Footnote-25543000
Ref: Core and Builtins<66>-Footnote-35543065
Ref: Core and Builtins<66>-Footnote-45543130
Ref: Core and Builtins<66>-Footnote-55543195
Ref: Core and Builtins<66>-Footnote-65543260
Ref: Core and Builtins<66>-Footnote-75543325
Ref: Core and Builtins<66>-Footnote-85543390
Ref: Core and Builtins<66>-Footnote-95543455
Ref: Core and Builtins<66>-Footnote-105543520
Ref: Core and Builtins<66>-Footnote-115543586
Ref: Core and Builtins<66>-Footnote-125543652
Ref: Core and Builtins<66>-Footnote-135543718
Ref: Core and Builtins<66>-Footnote-145543784
Ref: Core and Builtins<66>-Footnote-155543850
Node: Library<67>5543916
Ref: whatsnew/changelog id5915544043
Ref: 1a665544043
Ref: Library<67>-Footnote-15552441
Ref: Library<67>-Footnote-25552506
Ref: Library<67>-Footnote-35552571
Ref: Library<67>-Footnote-45552636
Ref: Library<67>-Footnote-55552701
Ref: Library<67>-Footnote-65552766
Ref: Library<67>-Footnote-75552831
Ref: Library<67>-Footnote-85552896
Ref: Library<67>-Footnote-95552961
Ref: Library<67>-Footnote-105553026
Ref: Library<67>-Footnote-115553092
Ref: Library<67>-Footnote-125553158
Ref: Library<67>-Footnote-135553224
Ref: Library<67>-Footnote-145553290
Ref: Library<67>-Footnote-155553356
Ref: Library<67>-Footnote-165553422
Ref: Library<67>-Footnote-175553488
Ref: Library<67>-Footnote-185553554
Ref: Library<67>-Footnote-195553620
Ref: Library<67>-Footnote-205553686
Ref: Library<67>-Footnote-215553752
Ref: Library<67>-Footnote-225553818
Ref: Library<67>-Footnote-235553884
Ref: Library<67>-Footnote-245553950
Ref: Library<67>-Footnote-255554016
Ref: Library<67>-Footnote-265554082
Ref: Library<67>-Footnote-275554148
Ref: Library<67>-Footnote-285554214
Ref: Library<67>-Footnote-295554280
Ref: Library<67>-Footnote-305554346
Ref: Library<67>-Footnote-315554412
Ref: Library<67>-Footnote-325554478
Ref: Library<67>-Footnote-335554544
Ref: Library<67>-Footnote-345554610
Ref: Library<67>-Footnote-355554676
Ref: Library<67>-Footnote-365554742
Ref: Library<67>-Footnote-375554808
Ref: Library<67>-Footnote-385554874
Ref: Library<67>-Footnote-395554940
Ref: Library<67>-Footnote-405555006
Ref: Library<67>-Footnote-415555072
Ref: Library<67>-Footnote-425555138
Ref: Library<67>-Footnote-435555204
Ref: Library<67>-Footnote-445555270
Ref: Library<67>-Footnote-455555336
Ref: Library<67>-Footnote-465555402
Ref: Library<67>-Footnote-475555468
Ref: Library<67>-Footnote-485555534
Ref: Library<67>-Footnote-495555600
Ref: Library<67>-Footnote-505555666
Ref: Library<67>-Footnote-515555732
Ref: Library<67>-Footnote-525555798
Ref: Library<67>-Footnote-535555864
Ref: Library<67>-Footnote-545555930
Ref: Library<67>-Footnote-555555996
Ref: Library<67>-Footnote-565556061
Ref: Library<67>-Footnote-575556127
Ref: Library<67>-Footnote-585556193
Ref: Library<67>-Footnote-595556259
Ref: Library<67>-Footnote-605556325
Node: IDLE<50>5556391
Ref: whatsnew/changelog id5925556506
Ref: 1a675556506
Ref: IDLE<50>-Footnote-15557509
Ref: IDLE<50>-Footnote-25557574
Ref: IDLE<50>-Footnote-35557639
Ref: IDLE<50>-Footnote-45557704
Ref: IDLE<50>-Footnote-55557769
Ref: IDLE<50>-Footnote-65557834
Node: C API<59>5557899
Ref: whatsnew/changelog id5935558012
Ref: 1a685558012
Ref: C API<59>-Footnote-15558200
Node: Build<65>5558265
Ref: whatsnew/changelog id5945558387
Ref: 1a695558387
Ref: Build<65>-Footnote-15559192
Ref: Build<65>-Footnote-25559257
Ref: Build<65>-Footnote-35559322
Ref: Build<65>-Footnote-45559387
Ref: Build<65>-Footnote-55559452
Node: Documentation<60>5559517
Ref: whatsnew/changelog id5955559645
Ref: 1a6a5559645
Ref: Documentation<60>-Footnote-15560374
Ref: Documentation<60>-Footnote-25560439
Ref: Documentation<60>-Footnote-35560504
Node: Tools/Demos<35>5560569
Ref: whatsnew/changelog id5965560697
Ref: 1a6b5560697
Ref: Tools/Demos<35>-Footnote-15560887
Node: Tests<61>5560952
Ref: whatsnew/changelog id5975561074
Ref: 1a6c5561074
Ref: Tests<61>-Footnote-15561729
Ref: Tests<61>-Footnote-25561794
Node: Windows<58>5561859
Ref: whatsnew/changelog id5985561957
Ref: 1a6d5561957
Ref: Windows<58>-Footnote-15562401
Ref: Windows<58>-Footnote-25562466
Node: Python 3 6 1 final5562531
Ref: whatsnew/changelog python-3-6-1-final5562680
Ref: 1a6e5562680
Node: Core and Builtins<67>5562837
Ref: whatsnew/changelog id5995562931
Ref: 1a6f5562931
Ref: Core and Builtins<67>-Footnote-15563548
Ref: Core and Builtins<67>-Footnote-25563613
Node: Build<66>5563678
Ref: whatsnew/changelog id6005563772
Ref: 1a705563772
Ref: Build<66>-Footnote-15563954
Node: Python 3 6 1 release candidate 15564019
Ref: whatsnew/changelog python-3-6-1-release-candidate-15564154
Ref: 1a715564154
Node: Core and Builtins<68>5564481
Ref: whatsnew/changelog id6015564591
Ref: 1a725564591
Ref: Core and Builtins<68>-Footnote-15567423
Ref: Core and Builtins<68>-Footnote-25567488
Ref: Core and Builtins<68>-Footnote-35567553
Ref: Core and Builtins<68>-Footnote-45567618
Ref: Core and Builtins<68>-Footnote-55567683
Ref: Core and Builtins<68>-Footnote-65567748
Ref: Core and Builtins<68>-Footnote-75567813
Ref: Core and Builtins<68>-Footnote-85567878
Ref: Core and Builtins<68>-Footnote-95567943
Ref: Core and Builtins<68>-Footnote-105568008
Ref: Core and Builtins<68>-Footnote-115568074
Ref: Core and Builtins<68>-Footnote-125568140
Ref: Core and Builtins<68>-Footnote-135568206
Ref: Core and Builtins<68>-Footnote-145568272
Ref: Core and Builtins<68>-Footnote-155568338
Ref: Core and Builtins<68>-Footnote-165568404
Ref: Core and Builtins<68>-Footnote-175568470
Ref: Core and Builtins<68>-Footnote-185568536
Ref: Core and Builtins<68>-Footnote-195568602
Ref: Core and Builtins<68>-Footnote-205568668
Ref: Core and Builtins<68>-Footnote-215568734
Ref: Core and Builtins<68>-Footnote-225568800
Node: Library<68>5568866
Ref: whatsnew/changelog id6025568993
Ref: 1a735568993
Ref: Library<68>-Footnote-15574628
Ref: Library<68>-Footnote-25574693
Ref: Library<68>-Footnote-35574758
Ref: Library<68>-Footnote-45574823
Ref: Library<68>-Footnote-55574888
Ref: Library<68>-Footnote-65574953
Ref: Library<68>-Footnote-75575018
Ref: Library<68>-Footnote-85575083
Ref: Library<68>-Footnote-95575148
Ref: Library<68>-Footnote-105575213
Ref: Library<68>-Footnote-115575279
Ref: Library<68>-Footnote-125575345
Ref: Library<68>-Footnote-135575411
Ref: Library<68>-Footnote-145575477
Ref: Library<68>-Footnote-155575543
Ref: Library<68>-Footnote-165575609
Ref: Library<68>-Footnote-175575675
Ref: Library<68>-Footnote-185575741
Ref: Library<68>-Footnote-195575807
Ref: Library<68>-Footnote-205575873
Ref: Library<68>-Footnote-215575939
Ref: Library<68>-Footnote-225576005
Ref: Library<68>-Footnote-235576071
Ref: Library<68>-Footnote-245576137
Ref: Library<68>-Footnote-255576203
Ref: Library<68>-Footnote-265576269
Ref: Library<68>-Footnote-275576335
Ref: Library<68>-Footnote-285576378
Ref: Library<68>-Footnote-295576444
Ref: Library<68>-Footnote-305576510
Ref: Library<68>-Footnote-315576576
Ref: Library<68>-Footnote-325576642
Ref: Library<68>-Footnote-335576708
Ref: Library<68>-Footnote-345576774
Ref: Library<68>-Footnote-355576840
Ref: Library<68>-Footnote-365576905
Ref: Library<68>-Footnote-375576971
Ref: Library<68>-Footnote-385577037
Ref: Library<68>-Footnote-395577103
Ref: Library<68>-Footnote-405577169
Ref: Library<68>-Footnote-415577235
Ref: Library<68>-Footnote-425577301
Ref: Library<68>-Footnote-435577367
Ref: Library<68>-Footnote-445577433
Node: IDLE<51>5577499
Ref: whatsnew/changelog id6035577616
Ref: 1a745577616
Ref: IDLE<51>-Footnote-15577903
Ref: IDLE<51>-Footnote-25577968
Node: Windows<59>5578033
Ref: whatsnew/changelog id6045578148
Ref: 1a755578148
Ref: Windows<59>-Footnote-15578795
Ref: Windows<59>-Footnote-25578860
Ref: Windows<59>-Footnote-35578925
Ref: Windows<59>-Footnote-45578990
Ref: Windows<59>-Footnote-55579055
Ref: Windows<59>-Footnote-65579097
Ref: Windows<59>-Footnote-75579162
Ref: Windows<59>-Footnote-85579227
Node: C API<60>5579292
Ref: whatsnew/changelog id6055579416
Ref: 1a765579416
Ref: C API<60>-Footnote-15580242
Ref: C API<60>-Footnote-25580307
Ref: C API<60>-Footnote-35580372
Node: Documentation<61>5580437
Ref: whatsnew/changelog id6065580559
Ref: 1a775580559
Ref: Documentation<61>-Footnote-15581096
Ref: Documentation<61>-Footnote-25581161
Ref: Documentation<61>-Footnote-35581226
Ref: Documentation<61>-Footnote-45581291
Node: Tests<62>5581356
Ref: whatsnew/changelog id6075581478
Ref: 1a785581478
Ref: Tests<62>-Footnote-15582463
Ref: Tests<62>-Footnote-25582528
Ref: Tests<62>-Footnote-35582593
Ref: Tests<62>-Footnote-45582658
Ref: Tests<62>-Footnote-55582723
Node: Build<67>5582788
Ref: whatsnew/changelog id6085582884
Ref: 1a795582884
Ref: Build<67>-Footnote-15584145
Ref: Build<67>-Footnote-25584210
Ref: Build<67>-Footnote-35584275
Ref: Build<67>-Footnote-45584340
Ref: Build<67>-Footnote-55584405
Ref: Build<67>-Footnote-65584470
Ref: Build<67>-Footnote-75584535
Ref: Build<67>-Footnote-85584600
Ref: Build<67>-Footnote-95584665
Ref: Build<67>-Footnote-105584730
Node: Python 3 6 0 final5584796
Ref: whatsnew/changelog python-3-6-0-final5584945
Ref: 1a7a5584945
Node: Python 3 6 0 release candidate 25585066
Ref: whatsnew/changelog python-3-6-0-release-candidate-25585215
Ref: 1a7b5585215
Node: Core and Builtins<69>5585456
Ref: whatsnew/changelog id6095585570
Ref: 1a7c5585570
Ref: Core and Builtins<69>-Footnote-15585955
Ref: Core and Builtins<69>-Footnote-25586020
Node: Tools/Demos<36>5586085
Ref: whatsnew/changelog id6105586219
Ref: 1a7d5586219
Ref: Tools/Demos<36>-Footnote-15586353
Node: Windows<60>5586418
Ref: whatsnew/changelog id6115586540
Ref: 1a7e5586540
Ref: Windows<60>-Footnote-15586666
Node: Build<68>5586731
Ref: whatsnew/changelog id6125586829
Ref: 1a7f5586829
Ref: Build<68>-Footnote-15586984
Node: Python 3 6 0 release candidate 15587049
Ref: whatsnew/changelog python-3-6-0-release-candidate-15587199
Ref: 1a805587199
Node: Core and Builtins<70>5587476
Ref: whatsnew/changelog id6135587586
Ref: 1a815587586
Ref: Core and Builtins<70>-Footnote-15588393
Ref: Core and Builtins<70>-Footnote-25588458
Ref: Core and Builtins<70>-Footnote-35588523
Ref: Core and Builtins<70>-Footnote-45588588
Node: Library<69>5588653
Ref: whatsnew/changelog id6145588781
Ref: 1a825588781
Ref: Library<69>-Footnote-15589820
Ref: Library<69>-Footnote-25589885
Ref: Library<69>-Footnote-35589950
Ref: Library<69>-Footnote-45590015
Ref: Library<69>-Footnote-55590080
Ref: Library<69>-Footnote-65590145
Node: C API<61>5590210
Ref: whatsnew/changelog id6155590334
Ref: 1a835590334
Ref: C API<61>-Footnote-15590492
Node: Documentation<62>5590557
Ref: whatsnew/changelog id6165590685
Ref: 1a845590685
Ref: Documentation<62>-Footnote-15591023
Ref: Documentation<62>-Footnote-25591088
Node: Tools/Demos<37>5591130
Ref: whatsnew/changelog id6175591240
Ref: 1a855591240
Ref: Tools/Demos<37>-Footnote-15591404
Node: Python 3 6 0 beta 45591469
Ref: whatsnew/changelog python-3-6-0-beta-45591606
Ref: 1a865591606
Node: Core and Builtins<71>5591845
Ref: whatsnew/changelog id6185591942
Ref: 1a875591942
Ref: Core and Builtins<71>-Footnote-15593490
Ref: Core and Builtins<71>-Footnote-25593555
Ref: Core and Builtins<71>-Footnote-35593620
Ref: Core and Builtins<71>-Footnote-45593685
Ref: Core and Builtins<71>-Footnote-55593750
Ref: Core and Builtins<71>-Footnote-65593815
Ref: Core and Builtins<71>-Footnote-75593880
Ref: Core and Builtins<71>-Footnote-85593945
Ref: Core and Builtins<71>-Footnote-95594010
Ref: Core and Builtins<71>-Footnote-105594075
Ref: Core and Builtins<71>-Footnote-115594141
Node: Library<70>5594207
Ref: whatsnew/changelog id6195594330
Ref: 1a885594330
Ref: Library<70>-Footnote-15596328
Ref: Library<70>-Footnote-25596393
Ref: Library<70>-Footnote-35596458
Ref: Library<70>-Footnote-45596523
Ref: Library<70>-Footnote-55596588
Ref: Library<70>-Footnote-65596653
Ref: Library<70>-Footnote-75596718
Ref: Library<70>-Footnote-85596783
Ref: Library<70>-Footnote-95596848
Ref: Library<70>-Footnote-105596913
Ref: Library<70>-Footnote-115596979
Ref: Library<70>-Footnote-125597045
Ref: Library<70>-Footnote-135597111
Ref: Library<70>-Footnote-145597177
Ref: Library<70>-Footnote-155597243
Ref: Library<70>-Footnote-165597309
Ref: Library<70>-Footnote-175597375
Ref: Library<70>-Footnote-185597441
Node: Documentation<63>5597507
Ref: whatsnew/changelog id6205597618
Ref: 1a895597618
Ref: Documentation<63>-Footnote-15597769
Node: Tests<63>5597834
Ref: whatsnew/changelog id6215597943
Ref: 1a8a5597943
Ref: Tests<63>-Footnote-15598205
Ref: Tests<63>-Footnote-25598270
Node: Build<69>5598335
Ref: whatsnew/changelog id6225598418
Ref: 1a8b5598418
Ref: Build<69>-Footnote-15598773
Ref: Build<69>-Footnote-25598838
Ref: Build<69>-Footnote-35598903
Node: Python 3 6 0 beta 35598968
Ref: whatsnew/changelog python-3-6-0-beta-35599092
Ref: 1a8c5599092
Node: Core and Builtins<72>5599319
Ref: whatsnew/changelog id6235599416
Ref: 1a8d5599416
Ref: Core and Builtins<72>-Footnote-15600319
Ref: Core and Builtins<72>-Footnote-25600384
Ref: Core and Builtins<72>-Footnote-35600449
Ref: Core and Builtins<72>-Footnote-45600514
Ref: Core and Builtins<72>-Footnote-55600579
Ref: Core and Builtins<72>-Footnote-65600644
Ref: Core and Builtins<72>-Footnote-75600709
Node: Library<71>5600774
Ref: whatsnew/changelog id6245600891
Ref: 1a8e5600891
Ref: Library<71>-Footnote-15603913
Ref: Library<71>-Footnote-25603978
Ref: Library<71>-Footnote-35604043
Ref: Library<71>-Footnote-45604108
Ref: Library<71>-Footnote-55604173
Ref: Library<71>-Footnote-65604238
Ref: Library<71>-Footnote-75604303
Ref: Library<71>-Footnote-85604368
Ref: Library<71>-Footnote-95604433
Ref: Library<71>-Footnote-105604498
Ref: Library<71>-Footnote-115604564
Ref: Library<71>-Footnote-125604630
Ref: Library<71>-Footnote-135604696
Ref: Library<71>-Footnote-145604762
Ref: Library<71>-Footnote-155604828
Ref: Library<71>-Footnote-165604894
Ref: Library<71>-Footnote-175604960
Ref: Library<71>-Footnote-185605026
Ref: Library<71>-Footnote-195605092
Ref: Library<71>-Footnote-205605158
Ref: Library<71>-Footnote-215605224
Ref: Library<71>-Footnote-225605290
Ref: Library<71>-Footnote-235605356
Ref: Library<71>-Footnote-245605422
Node: Windows<61>5605488
Ref: whatsnew/changelog id6255605593
Ref: 1a8f5605593
Ref: Windows<61>-Footnote-15605737
Node: Build<70>5605802
Ref: whatsnew/changelog id6265605905
Ref: 1a905605905
Ref: Build<70>-Footnote-15606224
Ref: Build<70>-Footnote-25606289
Ref: Build<70>-Footnote-35606354
Node: Tests<64>5606419
Ref: whatsnew/changelog id6275606502
Ref: 1a915606502
Ref: Tests<64>-Footnote-15606757
Ref: Tests<64>-Footnote-25606822
Node: Python 3 6 0 beta 25606887
Ref: whatsnew/changelog python-3-6-0-beta-25607011
Ref: 1a925607011
Node: Core and Builtins<73>5607258
Ref: whatsnew/changelog id6285607355
Ref: 1a935607355
Ref: Core and Builtins<73>-Footnote-15610091
Ref: Core and Builtins<73>-Footnote-25610156
Ref: Core and Builtins<73>-Footnote-35610221
Ref: Core and Builtins<73>-Footnote-45610286
Ref: Core and Builtins<73>-Footnote-55610351
Ref: Core and Builtins<73>-Footnote-65610416
Ref: Core and Builtins<73>-Footnote-75610481
Ref: Core and Builtins<73>-Footnote-85610546
Ref: Core and Builtins<73>-Footnote-95610611
Ref: Core and Builtins<73>-Footnote-105610676
Ref: Core and Builtins<73>-Footnote-115610742
Ref: Core and Builtins<73>-Footnote-125610808
Ref: Core and Builtins<73>-Footnote-135610874
Ref: Core and Builtins<73>-Footnote-145610940
Ref: Core and Builtins<73>-Footnote-155611006
Ref: Core and Builtins<73>-Footnote-165611072
Ref: Core and Builtins<73>-Footnote-175611138
Ref: Core and Builtins<73>-Footnote-185611204
Ref: Core and Builtins<73>-Footnote-195611270
Ref: Core and Builtins<73>-Footnote-205611336
Ref: Core and Builtins<73>-Footnote-215611402
Ref: Core and Builtins<73>-Footnote-225611468
Ref: Core and Builtins<73>-Footnote-235611534
Node: Library<72>5611600
Ref: whatsnew/changelog id6295611717
Ref: 1a945611717
Ref: Library<72>-Footnote-15617497
Ref: Library<72>-Footnote-25617562
Ref: Library<72>-Footnote-35617627
Ref: Library<72>-Footnote-45617692
Ref: Library<72>-Footnote-55617757
Ref: Library<72>-Footnote-65617822
Ref: Library<72>-Footnote-75617887
Ref: Library<72>-Footnote-85617952
Ref: Library<72>-Footnote-95618017
Ref: Library<72>-Footnote-105618082
Ref: Library<72>-Footnote-115618148
Ref: Library<72>-Footnote-125618214
Ref: Library<72>-Footnote-135618280
Ref: Library<72>-Footnote-145618346
Ref: Library<72>-Footnote-155618412
Ref: Library<72>-Footnote-165618478
Ref: Library<72>-Footnote-175618544
Ref: Library<72>-Footnote-185618610
Ref: Library<72>-Footnote-195618676
Ref: Library<72>-Footnote-205618742
Ref: Library<72>-Footnote-215618808
Ref: Library<72>-Footnote-225618874
Ref: Library<72>-Footnote-235618940
Ref: Library<72>-Footnote-245619006
Ref: Library<72>-Footnote-255619072
Ref: Library<72>-Footnote-265619138
Ref: Library<72>-Footnote-275619204
Ref: Library<72>-Footnote-285619270
Ref: Library<72>-Footnote-295619336
Ref: Library<72>-Footnote-305619402
Ref: Library<72>-Footnote-315619468
Ref: Library<72>-Footnote-325619534
Ref: Library<72>-Footnote-335619600
Ref: Library<72>-Footnote-345619666
Ref: Library<72>-Footnote-355619732
Ref: Library<72>-Footnote-365619798
Ref: Library<72>-Footnote-375619864
Ref: Library<72>-Footnote-385619930
Ref: Library<72>-Footnote-395619996
Ref: Library<72>-Footnote-405620062
Ref: Library<72>-Footnote-415620128
Ref: Library<72>-Footnote-425620194
Ref: Library<72>-Footnote-435620260
Ref: Library<72>-Footnote-445620326
Ref: Library<72>-Footnote-455620392
Ref: Library<72>-Footnote-465620458
Ref: Library<72>-Footnote-475620524
Ref: Library<72>-Footnote-485620590
Node: Windows<62>5620656
Ref: whatsnew/changelog id6305620761
Ref: 1a955620761
Ref: Windows<62>-Footnote-15621572
Ref: Windows<62>-Footnote-25621637
Ref: Windows<62>-Footnote-35621702
Ref: Windows<62>-Footnote-45621767
Ref: Windows<62>-Footnote-55621832
Ref: Windows<62>-Footnote-65621897
Ref: Windows<62>-Footnote-75621962
Ref: Windows<62>-Footnote-85622027
Ref: Windows<62>-Footnote-95622092
Ref: Windows<62>-Footnote-105622157
Node: C API<62>5622223
Ref: whatsnew/changelog id6315622326
Ref: 1a965622326
Ref: C API<62>-Footnote-15622580
Node: Build<71>5622645
Ref: whatsnew/changelog id6325622746
Ref: 1a975622746
Ref: Build<71>-Footnote-15623172
Ref: Build<71>-Footnote-25623237
Ref: Build<71>-Footnote-35623302
Node: Tests<65>5623367
Ref: whatsnew/changelog id6335623450
Ref: 1a985623450
Ref: Tests<65>-Footnote-15623587
Node: Python 3 6 0 beta 15623652
Ref: whatsnew/changelog python-3-6-0-beta-15623777
Ref: 1a995623777
Node: Core and Builtins<74>5624074
Ref: whatsnew/changelog id6345624171
Ref: 1a9a5624171
Ref: Core and Builtins<74>-Footnote-15630338
Ref: Core and Builtins<74>-Footnote-25630403
Ref: Core and Builtins<74>-Footnote-35630468
Ref: Core and Builtins<74>-Footnote-45630533
Ref: Core and Builtins<74>-Footnote-55630575
Ref: Core and Builtins<74>-Footnote-65630640
Ref: Core and Builtins<74>-Footnote-75630705
Ref: Core and Builtins<74>-Footnote-85630770
Ref: Core and Builtins<74>-Footnote-95630835
Ref: Core and Builtins<74>-Footnote-105630900
Ref: Core and Builtins<74>-Footnote-115630966
Ref: Core and Builtins<74>-Footnote-125631032
Ref: Core and Builtins<74>-Footnote-135631098
Ref: Core and Builtins<74>-Footnote-145631141
Ref: Core and Builtins<74>-Footnote-155631207
Ref: Core and Builtins<74>-Footnote-165631273
Ref: Core and Builtins<74>-Footnote-175631316
Ref: Core and Builtins<74>-Footnote-185631382
Ref: Core and Builtins<74>-Footnote-195631425
Ref: Core and Builtins<74>-Footnote-205631491
Ref: Core and Builtins<74>-Footnote-215631557
Ref: Core and Builtins<74>-Footnote-225631623
Ref: Core and Builtins<74>-Footnote-235631689
Ref: Core and Builtins<74>-Footnote-245631755
Ref: Core and Builtins<74>-Footnote-255631821
Ref: Core and Builtins<74>-Footnote-265631887
Ref: Core and Builtins<74>-Footnote-275631953
Ref: Core and Builtins<74>-Footnote-285631996
Ref: Core and Builtins<74>-Footnote-295632062
Ref: Core and Builtins<74>-Footnote-305632128
Ref: Core and Builtins<74>-Footnote-315632194
Ref: Core and Builtins<74>-Footnote-325632260
Ref: Core and Builtins<74>-Footnote-335632326
Ref: Core and Builtins<74>-Footnote-345632392
Ref: Core and Builtins<74>-Footnote-355632458
Ref: Core and Builtins<74>-Footnote-365632524
Ref: Core and Builtins<74>-Footnote-375632590
Ref: Core and Builtins<74>-Footnote-385632656
Ref: Core and Builtins<74>-Footnote-395632722
Ref: Core and Builtins<74>-Footnote-405632788
Ref: Core and Builtins<74>-Footnote-415632854
Ref: Core and Builtins<74>-Footnote-425632920
Ref: Core and Builtins<74>-Footnote-435632986
Ref: Core and Builtins<74>-Footnote-445633052
Ref: Core and Builtins<74>-Footnote-455633118
Ref: Core and Builtins<74>-Footnote-465633184
Ref: Core and Builtins<74>-Footnote-475633227
Node: Library<73>5633293
Ref: whatsnew/changelog id6355633407
Ref: 1a9b5633407
Ref: Library<73>-Footnote-15644350
Ref: Library<73>-Footnote-25644415
Ref: Library<73>-Footnote-35644480
Ref: Library<73>-Footnote-45644545
Ref: Library<73>-Footnote-55644610
Ref: Library<73>-Footnote-65644675
Ref: Library<73>-Footnote-75644740
Ref: Library<73>-Footnote-85644805
Ref: Library<73>-Footnote-95644870
Ref: Library<73>-Footnote-105644935
Ref: Library<73>-Footnote-115645001
Ref: Library<73>-Footnote-125645067
Ref: Library<73>-Footnote-135645133
Ref: Library<73>-Footnote-145645199
Ref: Library<73>-Footnote-155645265
Ref: Library<73>-Footnote-165645331
Ref: Library<73>-Footnote-175645397
Ref: Library<73>-Footnote-185645465
Ref: Library<73>-Footnote-195645531
Ref: Library<73>-Footnote-205645597
Ref: Library<73>-Footnote-215645663
Ref: Library<73>-Footnote-225645729
Ref: Library<73>-Footnote-235645795
Ref: Library<73>-Footnote-245645861
Ref: Library<73>-Footnote-255645927
Ref: Library<73>-Footnote-265645994
Ref: Library<73>-Footnote-275646060
Ref: Library<73>-Footnote-285646126
Ref: Library<73>-Footnote-295646192
Ref: Library<73>-Footnote-305646258
Ref: Library<73>-Footnote-315646324
Ref: Library<73>-Footnote-325646390
Ref: Library<73>-Footnote-335646456
Ref: Library<73>-Footnote-345646522
Ref: Library<73>-Footnote-355646588
Ref: Library<73>-Footnote-365646654
Ref: Library<73>-Footnote-375646720
Ref: Library<73>-Footnote-385646786
Ref: Library<73>-Footnote-395646852
Ref: Library<73>-Footnote-405646918
Ref: Library<73>-Footnote-415646984
Ref: Library<73>-Footnote-425647050
Ref: Library<73>-Footnote-435647093
Ref: Library<73>-Footnote-445647159
Ref: Library<73>-Footnote-455647202
Ref: Library<73>-Footnote-465647268
Ref: Library<73>-Footnote-475647334
Ref: Library<73>-Footnote-485647400
Ref: Library<73>-Footnote-495647466
Ref: Library<73>-Footnote-505647532
Ref: Library<73>-Footnote-515647598
Ref: Library<73>-Footnote-525647664
Ref: Library<73>-Footnote-535647730
Ref: Library<73>-Footnote-545647786
Ref: Library<73>-Footnote-555647852
Ref: Library<73>-Footnote-565647918
Ref: Library<73>-Footnote-575647984
Ref: Library<73>-Footnote-585648050
Ref: Library<73>-Footnote-595648116
Ref: Library<73>-Footnote-605648182
Ref: Library<73>-Footnote-615648248
Ref: Library<73>-Footnote-625648314
Ref: Library<73>-Footnote-635648380
Ref: Library<73>-Footnote-645648446
Ref: Library<73>-Footnote-655648512
Ref: Library<73>-Footnote-665648578
Ref: Library<73>-Footnote-675648644
Ref: Library<73>-Footnote-685648710
Ref: Library<73>-Footnote-695648776
Ref: Library<73>-Footnote-705648842
Ref: Library<73>-Footnote-715648908
Ref: Library<73>-Footnote-725648974
Ref: Library<73>-Footnote-735649040
Ref: Library<73>-Footnote-745649106
Ref: Library<73>-Footnote-755649172
Ref: Library<73>-Footnote-765649238
Ref: Library<73>-Footnote-775649303
Ref: Library<73>-Footnote-785649368
Ref: Library<73>-Footnote-795649434
Ref: Library<73>-Footnote-805649500
Ref: Library<73>-Footnote-815649565
Ref: Library<73>-Footnote-825649631
Node: IDLE<52>5649697
Ref: whatsnew/changelog id6365649799
Ref: 1a9c5649799
Ref: IDLE<52>-Footnote-15650555
Ref: IDLE<52>-Footnote-25650620
Ref: IDLE<52>-Footnote-35650685
Ref: IDLE<52>-Footnote-45650750
Ref: IDLE<52>-Footnote-55650815
Ref: IDLE<52>-Footnote-65650880
Node: C API<63>5650945
Ref: whatsnew/changelog id6375651045
Ref: 1a9d5651045
Ref: C API<63>-Footnote-15651317
Ref: C API<63>-Footnote-25651382
Node: Tests<66>5651447
Ref: whatsnew/changelog id6385651548
Ref: 1a9e5651548
Ref: Tests<66>-Footnote-15652064
Ref: Tests<66>-Footnote-25652129
Ref: Tests<66>-Footnote-35652194
Ref: Tests<66>-Footnote-45652259
Node: Build<72>5652324
Ref: whatsnew/changelog id6395652431
Ref: 1a9f5652431
Ref: Build<72>-Footnote-15653814
Ref: Build<72>-Footnote-25653879
Ref: Build<72>-Footnote-35653944
Ref: Build<72>-Footnote-45654009
Ref: Build<72>-Footnote-55654074
Ref: Build<72>-Footnote-65654139
Ref: Build<72>-Footnote-75654204
Ref: Build<72>-Footnote-85654269
Ref: Build<72>-Footnote-95654334
Ref: Build<72>-Footnote-105654399
Ref: Build<72>-Footnote-115654465
Node: Tools/Demos<38>5654531
Ref: whatsnew/changelog id6405654640
Ref: 1aa05654640
Ref: Tools/Demos<38>-Footnote-15654915
Node: Windows<63>5654980
Ref: whatsnew/changelog id6415655071
Ref: 1aa15655071
Ref: Windows<63>-Footnote-15656038
Ref: Windows<63>-Footnote-25656103
Ref: Windows<63>-Footnote-35656168
Ref: Windows<63>-Footnote-45656232
Ref: Windows<63>-Footnote-55656297
Ref: Windows<63>-Footnote-65656362
Ref: Windows<63>-Footnote-75656426
Ref: Windows<63>-Footnote-85656491
Ref: Windows<63>-Footnote-95656556
Ref: Windows<63>-Footnote-105656621
Ref: Windows<63>-Footnote-115656687
Node: Python 3 6 0 alpha 45656753
Ref: whatsnew/changelog python-3-6-0-alpha-45656879
Ref: 1aa25656879
Node: Core and Builtins<75>5657126
Ref: whatsnew/changelog id6425657224
Ref: 1aa35657224
Ref: Core and Builtins<75>-Footnote-15659168
Ref: Core and Builtins<75>-Footnote-25659233
Ref: Core and Builtins<75>-Footnote-35659298
Ref: Core and Builtins<75>-Footnote-45659363
Ref: Core and Builtins<75>-Footnote-55659428
Ref: Core and Builtins<75>-Footnote-65659493
Ref: Core and Builtins<75>-Footnote-75659558
Ref: Core and Builtins<75>-Footnote-85659623
Ref: Core and Builtins<75>-Footnote-95659688
Ref: Core and Builtins<75>-Footnote-105659752
Ref: Core and Builtins<75>-Footnote-115659818
Ref: Core and Builtins<75>-Footnote-125659884
Ref: Core and Builtins<75>-Footnote-135659950
Ref: Core and Builtins<75>-Footnote-145660016
Node: Library<74>5660059
Ref: whatsnew/changelog id6435660174
Ref: 1aa45660174
Ref: Library<74>-Footnote-15664665
Ref: Library<74>-Footnote-25664730
Ref: Library<74>-Footnote-35664772
Ref: Library<74>-Footnote-45664837
Ref: Library<74>-Footnote-55664902
Ref: Library<74>-Footnote-65664967
Ref: Library<74>-Footnote-75665032
Ref: Library<74>-Footnote-85665097
Ref: Library<74>-Footnote-95665162
Ref: Library<74>-Footnote-105665227
Ref: Library<74>-Footnote-115665293
Ref: Library<74>-Footnote-125665336
Ref: Library<74>-Footnote-135665402
Ref: Library<74>-Footnote-145665468
Ref: Library<74>-Footnote-155665534
Ref: Library<74>-Footnote-165665600
Ref: Library<74>-Footnote-175665665
Ref: Library<74>-Footnote-185665731
Ref: Library<74>-Footnote-195665797
Ref: Library<74>-Footnote-205665863
Ref: Library<74>-Footnote-215665929
Ref: Library<74>-Footnote-225665995
Ref: Library<74>-Footnote-235666061
Ref: Library<74>-Footnote-245666127
Ref: Library<74>-Footnote-255666193
Ref: Library<74>-Footnote-265666259
Ref: Library<74>-Footnote-275666325
Ref: Library<74>-Footnote-285666391
Ref: Library<74>-Footnote-295666450
Ref: Library<74>-Footnote-305666515
Ref: Library<74>-Footnote-315666581
Ref: Library<74>-Footnote-325666647
Ref: Library<74>-Footnote-335666713
Ref: Library<74>-Footnote-345666756
Ref: Library<74>-Footnote-355666822
Ref: Library<74>-Footnote-365666887
Ref: Library<74>-Footnote-375666953
Ref: Library<74>-Footnote-385667019
Ref: Library<74>-Footnote-395667085
Node: IDLE<53>5667151
Ref: whatsnew/changelog id6445667254
Ref: 1aa55667254
Ref: IDLE<53>-Footnote-15668574
Ref: IDLE<53>-Footnote-25668639
Ref: IDLE<53>-Footnote-35668704
Ref: IDLE<53>-Footnote-45668769
Ref: IDLE<53>-Footnote-55668834
Ref: IDLE<53>-Footnote-65668899
Ref: IDLE<53>-Footnote-75668964
Ref: IDLE<53>-Footnote-85669029
Node: Tests<67>5669094
Ref: whatsnew/changelog id6455669197
Ref: 1aa65669197
Ref: Tests<67>-Footnote-15669784
Ref: Tests<67>-Footnote-25669849
Ref: Tests<67>-Footnote-35669914
Ref: Tests<67>-Footnote-45669979
Node: Windows<64>5670044
Ref: whatsnew/changelog id6465670148
Ref: 1aa75670148
Ref: Windows<64>-Footnote-15670524
Ref: Windows<64>-Footnote-25670589
Ref: Windows<64>-Footnote-35670654
Ref: Windows<64>-Footnote-45670696
Ref: Windows<64>-Footnote-55670761
Node: Build<73>5670826
Ref: whatsnew/changelog id6475670912
Ref: 1aa85670912
Ref: Build<73>-Footnote-15671811
Ref: Build<73>-Footnote-25671876
Ref: Build<73>-Footnote-35671941
Ref: Build<73>-Footnote-45672006
Ref: Build<73>-Footnote-55672071
Ref: Build<73>-Footnote-65672136
Node: Python 3 6 0 alpha 35672201
Ref: whatsnew/changelog python-3-6-0-alpha-35672328
Ref: 1aa95672328
Node: Security<42>5672665
Ref: whatsnew/changelog id6485672764
Ref: 1aaa5672764
Ref: Security<42>-Footnote-15673142
Ref: Security<42>-Footnote-25673207
Node: Core and Builtins<76>5673272
Ref: whatsnew/changelog id6495673391
Ref: 1aab5673391
Ref: Core and Builtins<76>-Footnote-15674138
Ref: Core and Builtins<76>-Footnote-25674203
Ref: Core and Builtins<76>-Footnote-35674268
Ref: Core and Builtins<76>-Footnote-45674333
Node: Library<75>5674398
Ref: whatsnew/changelog id6505674513
Ref: 1aac5674513
Ref: Library<75>-Footnote-15678596
Ref: Library<75>-Footnote-25678661
Ref: Library<75>-Footnote-35678726
Ref: Library<75>-Footnote-45678791
Ref: Library<75>-Footnote-55678856
Ref: Library<75>-Footnote-65678921
Ref: Library<75>-Footnote-75678986
Ref: Library<75>-Footnote-85679051
Ref: Library<75>-Footnote-95679116
Ref: Library<75>-Footnote-105679181
Ref: Library<75>-Footnote-115679247
Ref: Library<75>-Footnote-125679313
Ref: Library<75>-Footnote-135679379
Ref: Library<75>-Footnote-145679445
Ref: Library<75>-Footnote-155679511
Ref: Library<75>-Footnote-165679577
Ref: Library<75>-Footnote-175679643
Ref: Library<75>-Footnote-185679709
Ref: Library<75>-Footnote-195679775
Ref: Library<75>-Footnote-205679841
Ref: Library<75>-Footnote-215679907
Ref: Library<75>-Footnote-225679950
Ref: Library<75>-Footnote-235680016
Ref: Library<75>-Footnote-245680082
Ref: Library<75>-Footnote-255680147
Ref: Library<75>-Footnote-265680213
Node: IDLE<54>5680279
Ref: whatsnew/changelog id6515680382
Ref: 1aad5680382
Ref: IDLE<54>-Footnote-15682038
Ref: IDLE<54>-Footnote-25682103
Ref: IDLE<54>-Footnote-35682168
Ref: IDLE<54>-Footnote-45682233
Ref: IDLE<54>-Footnote-55682298
Ref: IDLE<54>-Footnote-65682363
Ref: IDLE<54>-Footnote-75682428
Ref: IDLE<54>-Footnote-85682493
Ref: IDLE<54>-Footnote-95682558
Ref: IDLE<54>-Footnote-105682623
Node: C API<64>5682689
Ref: whatsnew/changelog id6525682790
Ref: 1aae5682790
Ref: C API<64>-Footnote-15683030
Node: Build<74>5683095
Ref: whatsnew/changelog id6535683203
Ref: 1aaf5683203
Ref: Build<74>-Footnote-15684174
Ref: Build<74>-Footnote-25684239
Ref: Build<74>-Footnote-35684304
Ref: Build<74>-Footnote-45684369
Ref: Build<74>-Footnote-55684434
Node: Tools/Demos<39>5684499
Ref: whatsnew/changelog id6545684615
Ref: 1ab05684615
Ref: Tools/Demos<39>-Footnote-15684899
Ref: Tools/Demos<39>-Footnote-25684964
Node: Documentation<64>5685029
Ref: whatsnew/changelog id6555685145
Ref: 1ab15685145
Ref: Documentation<64>-Footnote-15685522
Ref: Documentation<64>-Footnote-25685587
Node: Tests<68>5685652
Ref: whatsnew/changelog id6565685744
Ref: 1ab25685744
Ref: Tests<68>-Footnote-15685912
Node: Python 3 6 0 alpha 25685977
Ref: whatsnew/changelog python-3-6-0-alpha-25686104
Ref: 1ab35686104
Node: Security<43>5686465
Ref: whatsnew/changelog id6575686564
Ref: 1ab45686564
Ref: Security<43>-Footnote-15687055
Ref: Security<43>-Footnote-25687120
Ref: Security<43>-Footnote-35687175
Ref: Security<43>-Footnote-45687230
Node: Core and Builtins<77>5687295
Ref: whatsnew/changelog id6585687414
Ref: 1ab55687414
Ref: Core and Builtins<77>-Footnote-15689046
Ref: Core and Builtins<77>-Footnote-25689111
Ref: Core and Builtins<77>-Footnote-35689176
Ref: Core and Builtins<77>-Footnote-45689241
Ref: Core and Builtins<77>-Footnote-55689306
Ref: Core and Builtins<77>-Footnote-65689371
Ref: Core and Builtins<77>-Footnote-75689413
Ref: Core and Builtins<77>-Footnote-85689478
Ref: Core and Builtins<77>-Footnote-95689543
Ref: Core and Builtins<77>-Footnote-105689608
Ref: Core and Builtins<77>-Footnote-115689674
Ref: Core and Builtins<77>-Footnote-125689740
Node: Library<76>5689806
Ref: whatsnew/changelog id6595689921
Ref: 1ab65689921
Ref: Library<76>-Footnote-15695120
Ref: Library<76>-Footnote-25695185
Ref: Library<76>-Footnote-35695250
Ref: Library<76>-Footnote-45695315
Ref: Library<76>-Footnote-55695380
Ref: Library<76>-Footnote-65695445
Ref: Library<76>-Footnote-75695510
Ref: Library<76>-Footnote-85695575
Ref: Library<76>-Footnote-95695640
Ref: Library<76>-Footnote-105695682
Ref: Library<76>-Footnote-115695748
Ref: Library<76>-Footnote-125695814
Ref: Library<76>-Footnote-135695880
Ref: Library<76>-Footnote-145695923
Ref: Library<76>-Footnote-155695989
Ref: Library<76>-Footnote-165696032
Ref: Library<76>-Footnote-175696075
Ref: Library<76>-Footnote-185696141
Ref: Library<76>-Footnote-195696207
Ref: Library<76>-Footnote-205696273
Ref: Library<76>-Footnote-215696339
Ref: Library<76>-Footnote-225696405
Ref: Library<76>-Footnote-235696471
Ref: Library<76>-Footnote-245696537
Ref: Library<76>-Footnote-255696603
Ref: Library<76>-Footnote-265696669
Ref: Library<76>-Footnote-275696735
Ref: Library<76>-Footnote-285696801
Ref: Library<76>-Footnote-295696867
Ref: Library<76>-Footnote-305696933
Ref: Library<76>-Footnote-315696999
Ref: Library<76>-Footnote-325697065
Ref: Library<76>-Footnote-335697131
Ref: Library<76>-Footnote-345697197
Ref: Library<76>-Footnote-355697263
Node: IDLE<55>5697329
Ref: whatsnew/changelog id6605697440
Ref: 1ab75697440
Ref: IDLE<55>-Footnote-15700079
Ref: IDLE<55>-Footnote-25700143
Ref: IDLE<55>-Footnote-35700208
Ref: IDLE<55>-Footnote-45700273
Ref: IDLE<55>-Footnote-55700338
Ref: IDLE<55>-Footnote-65700403
Ref: IDLE<55>-Footnote-75700468
Ref: IDLE<55>-Footnote-85700533
Ref: IDLE<55>-Footnote-95700598
Ref: IDLE<55>-Footnote-105700663
Ref: IDLE<55>-Footnote-115700729
Ref: IDLE<55>-Footnote-125700795
Ref: IDLE<55>-Footnote-135700861
Ref: IDLE<55>-Footnote-145700927
Ref: IDLE<55>-Footnote-155700993
Ref: IDLE<55>-Footnote-165701059
Ref: IDLE<55>-Footnote-175701125
Ref: IDLE<55>-Footnote-185701191
Ref: IDLE<55>-Footnote-195701257
Node: Documentation<65>5701323
Ref: whatsnew/changelog id6615701432
Ref: 1ab85701432
Ref: Documentation<65>-Footnote-15701875
Ref: Documentation<65>-Footnote-25701940
Ref: Documentation<65>-Footnote-35702005
Ref: Documentation<65>-Footnote-45702047
Node: Tests<69>5702112
Ref: whatsnew/changelog id6625702224
Ref: 1ab95702224
Ref: Tests<69>-Footnote-15702604
Ref: Tests<69>-Footnote-25702669
Node: Windows<65>5702734
Ref: whatsnew/changelog id6635702838
Ref: 1aba5702838
Ref: Windows<65>-Footnote-15703248
Ref: Windows<65>-Footnote-25703313
Node: Build<75>5703378
Ref: whatsnew/changelog id6645703482
Ref: 1abb5703482
Ref: Build<75>-Footnote-15703759
Ref: Build<75>-Footnote-25703824
Node: C API<65>5703889
Ref: whatsnew/changelog id6655703997
Ref: 1abc5703997
Ref: C API<65>-Footnote-15704235
Ref: C API<65>-Footnote-25704300
Ref: C API<65>-Footnote-35704342
Node: Tools/Demos<40>5704407
Ref: whatsnew/changelog id6665704497
Ref: 1abd5704497
Ref: Tools/Demos<40>-Footnote-15704695
Node: Python 3 6 0 alpha 15704760
Ref: whatsnew/changelog python-3-6-0-alpha-15704885
Ref: 1abe5704885
Node: Security<44>5705246
Ref: whatsnew/changelog id6675705345
Ref: 1abf5705345
Ref: Security<44>-Footnote-15705836
Ref: Security<44>-Footnote-25705901
Ref: Security<44>-Footnote-35705966
Node: Core and Builtins<78>5706031
Ref: whatsnew/changelog id6685706150
Ref: 1ac05706150
Ref: Core and Builtins<78>-Footnote-15719296
Ref: Core and Builtins<78>-Footnote-25719361
Ref: Core and Builtins<78>-Footnote-35719426
Ref: Core and Builtins<78>-Footnote-45719491
Ref: Core and Builtins<78>-Footnote-55719556
Ref: Core and Builtins<78>-Footnote-65719621
Ref: Core and Builtins<78>-Footnote-75719686
Ref: Core and Builtins<78>-Footnote-85719751
Ref: Core and Builtins<78>-Footnote-95719816
Ref: Core and Builtins<78>-Footnote-105719881
Ref: Core and Builtins<78>-Footnote-115719947
Ref: Core and Builtins<78>-Footnote-125720013
Ref: Core and Builtins<78>-Footnote-135720079
Ref: Core and Builtins<78>-Footnote-145720145
Ref: Core and Builtins<78>-Footnote-155720211
Ref: Core and Builtins<78>-Footnote-165720277
Ref: Core and Builtins<78>-Footnote-175720320
Ref: Core and Builtins<78>-Footnote-185720386
Ref: Core and Builtins<78>-Footnote-195720452
Ref: Core and Builtins<78>-Footnote-205720518
Ref: Core and Builtins<78>-Footnote-215720584
Ref: Core and Builtins<78>-Footnote-225720650
Ref: Core and Builtins<78>-Footnote-235720716
Ref: Core and Builtins<78>-Footnote-245720759
Ref: Core and Builtins<78>-Footnote-255720825
Ref: Core and Builtins<78>-Footnote-265720891
Ref: Core and Builtins<78>-Footnote-275720957
Ref: Core and Builtins<78>-Footnote-285721023
Ref: Core and Builtins<78>-Footnote-295721089
Ref: Core and Builtins<78>-Footnote-305721155
Ref: Core and Builtins<78>-Footnote-315721221
Ref: Core and Builtins<78>-Footnote-325721287
Ref: Core and Builtins<78>-Footnote-335721353
Ref: Core and Builtins<78>-Footnote-345721419
Ref: Core and Builtins<78>-Footnote-355721485
Ref: Core and Builtins<78>-Footnote-365721551
Ref: Core and Builtins<78>-Footnote-375721616
Ref: Core and Builtins<78>-Footnote-385721682
Ref: Core and Builtins<78>-Footnote-395721748
Ref: Core and Builtins<78>-Footnote-405721814
Ref: Core and Builtins<78>-Footnote-415721880
Ref: Core and Builtins<78>-Footnote-425721946
Ref: Core and Builtins<78>-Footnote-435722012
Ref: Core and Builtins<78>-Footnote-445722078
Ref: Core and Builtins<78>-Footnote-455722144
Ref: Core and Builtins<78>-Footnote-465722210
Ref: Core and Builtins<78>-Footnote-475722276
Ref: Core and Builtins<78>-Footnote-485722342
Ref: Core and Builtins<78>-Footnote-495722408
Ref: Core and Builtins<78>-Footnote-505722474
Ref: Core and Builtins<78>-Footnote-515722540
Ref: Core and Builtins<78>-Footnote-525722606
Ref: Core and Builtins<78>-Footnote-535722671
Ref: Core and Builtins<78>-Footnote-545722737
Ref: Core and Builtins<78>-Footnote-555722803
Ref: Core and Builtins<78>-Footnote-565722869
Ref: Core and Builtins<78>-Footnote-575722935
Ref: Core and Builtins<78>-Footnote-585723001
Ref: Core and Builtins<78>-Footnote-595723067
Ref: Core and Builtins<78>-Footnote-605723133
Ref: Core and Builtins<78>-Footnote-615723199
Ref: Core and Builtins<78>-Footnote-625723265
Ref: Core and Builtins<78>-Footnote-635723331
Ref: Core and Builtins<78>-Footnote-645723397
Ref: Core and Builtins<78>-Footnote-655723463
Ref: Core and Builtins<78>-Footnote-665723529
Ref: Core and Builtins<78>-Footnote-675723595
Ref: Core and Builtins<78>-Footnote-685723661
Ref: Core and Builtins<78>-Footnote-695723727
Ref: Core and Builtins<78>-Footnote-705723793
Ref: Core and Builtins<78>-Footnote-715723859
Ref: Core and Builtins<78>-Footnote-725723925
Ref: Core and Builtins<78>-Footnote-735723991
Ref: Core and Builtins<78>-Footnote-745724057
Ref: Core and Builtins<78>-Footnote-755724123
Ref: Core and Builtins<78>-Footnote-765724189
Ref: Core and Builtins<78>-Footnote-775724255
Ref: Core and Builtins<78>-Footnote-785724321
Ref: Core and Builtins<78>-Footnote-795724386
Ref: Core and Builtins<78>-Footnote-805724452
Ref: Core and Builtins<78>-Footnote-815724495
Ref: Core and Builtins<78>-Footnote-825724561
Ref: Core and Builtins<78>-Footnote-835724627
Ref: Core and Builtins<78>-Footnote-845724693
Ref: Core and Builtins<78>-Footnote-855724759
Ref: Core and Builtins<78>-Footnote-865724825
Ref: Core and Builtins<78>-Footnote-875724891
Node: Library<77>5724957
Ref: whatsnew/changelog id6695725072
Ref: 1ac25725072
Ref: Library<77>-Footnote-15755993
Ref: Library<77>-Footnote-25756058
Ref: Library<77>-Footnote-35756123
Ref: Library<77>-Footnote-45756188
Ref: Library<77>-Footnote-55756253
Ref: Library<77>-Footnote-65756318
Ref: Library<77>-Footnote-75756383
Ref: Library<77>-Footnote-85756448
Ref: Library<77>-Footnote-95756513
Ref: Library<77>-Footnote-105756578
Ref: Library<77>-Footnote-115756644
Ref: Library<77>-Footnote-125756710
Ref: Library<77>-Footnote-135756776
Ref: Library<77>-Footnote-145756842
Ref: Library<77>-Footnote-155756908
Ref: Library<77>-Footnote-165756974
Ref: Library<77>-Footnote-175757040
Ref: Library<77>-Footnote-185757106
Ref: Library<77>-Footnote-195757149
Ref: Library<77>-Footnote-205757215
Ref: Library<77>-Footnote-215757281
Ref: Library<77>-Footnote-225757347
Ref: Library<77>-Footnote-235757413
Ref: Library<77>-Footnote-245757479
Ref: Library<77>-Footnote-255757545
Ref: Library<77>-Footnote-265757611
Ref: Library<77>-Footnote-275757677
Ref: Library<77>-Footnote-285757743
Ref: Library<77>-Footnote-295757809
Ref: Library<77>-Footnote-305757875
Ref: Library<77>-Footnote-315757941
Ref: Library<77>-Footnote-325758007
Ref: Library<77>-Footnote-335758073
Ref: Library<77>-Footnote-345758139
Ref: Library<77>-Footnote-355758205
Ref: Library<77>-Footnote-365758271
Ref: Library<77>-Footnote-375758337
Ref: Library<77>-Footnote-385758403
Ref: Library<77>-Footnote-395758469
Ref: Library<77>-Footnote-405758535
Ref: Library<77>-Footnote-415758601
Ref: Library<77>-Footnote-425758667
Ref: Library<77>-Footnote-435758733
Ref: Library<77>-Footnote-445758799
Ref: Library<77>-Footnote-455758865
Ref: Library<77>-Footnote-465758931
Ref: Library<77>-Footnote-475758997
Ref: Library<77>-Footnote-485759063
Ref: Library<77>-Footnote-495759129
Ref: Library<77>-Footnote-505759195
Ref: Library<77>-Footnote-515759261
Ref: Library<77>-Footnote-525759327
Ref: Library<77>-Footnote-535759393
Ref: Library<77>-Footnote-545759459
Ref: Library<77>-Footnote-555759525
Ref: Library<77>-Footnote-565759591
Ref: Library<77>-Footnote-575759657
Ref: Library<77>-Footnote-585759723
Ref: Library<77>-Footnote-595759789
Ref: Library<77>-Footnote-605759855
Ref: Library<77>-Footnote-615759921
Ref: Library<77>-Footnote-625759987
Ref: Library<77>-Footnote-635760053
Ref: Library<77>-Footnote-645760119
Ref: Library<77>-Footnote-655760185
Ref: Library<77>-Footnote-665760251
Ref: Library<77>-Footnote-675760317
Ref: Library<77>-Footnote-685760383
Ref: Library<77>-Footnote-695760449
Ref: Library<77>-Footnote-705760515
Ref: Library<77>-Footnote-715760581
Ref: Library<77>-Footnote-725760647
Ref: Library<77>-Footnote-735760713
Ref: Library<77>-Footnote-745760779
Ref: Library<77>-Footnote-755760845
Ref: Library<77>-Footnote-765760911
Ref: Library<77>-Footnote-775760977
Ref: Library<77>-Footnote-785761043
Ref: Library<77>-Footnote-795761109
Ref: Library<77>-Footnote-805761175
Ref: Library<77>-Footnote-815761240
Ref: Library<77>-Footnote-825761306
Ref: Library<77>-Footnote-835761372
Ref: Library<77>-Footnote-845761438
Ref: Library<77>-Footnote-855761504
Ref: Library<77>-Footnote-865761570
Ref: Library<77>-Footnote-875761636
Ref: Library<77>-Footnote-885761702
Ref: Library<77>-Footnote-895761768
Ref: Library<77>-Footnote-905761834
Ref: Library<77>-Footnote-915761900
Ref: Library<77>-Footnote-925761966
Ref: Library<77>-Footnote-935762032
Ref: Library<77>-Footnote-945762098
Ref: Library<77>-Footnote-955762164
Ref: Library<77>-Footnote-965762230
Ref: Library<77>-Footnote-975762296
Ref: Library<77>-Footnote-985762362
Ref: Library<77>-Footnote-995762428
Ref: Library<77>-Footnote-1005762494
Ref: Library<77>-Footnote-1015762561
Ref: Library<77>-Footnote-1025762628
Ref: Library<77>-Footnote-1035762695
Ref: Library<77>-Footnote-1045762762
Ref: Library<77>-Footnote-1055762829
Ref: Library<77>-Footnote-1065762896
Ref: Library<77>-Footnote-1075762963
Ref: Library<77>-Footnote-1085763030
Ref: Library<77>-Footnote-1095763097
Ref: Library<77>-Footnote-1105763164
Ref: Library<77>-Footnote-1115763231
Ref: Library<77>-Footnote-1125763298
Ref: Library<77>-Footnote-1135763365
Ref: Library<77>-Footnote-1145763432
Ref: Library<77>-Footnote-1155763499
Ref: Library<77>-Footnote-1165763566
Ref: Library<77>-Footnote-1175763633
Ref: Library<77>-Footnote-1185763700
Ref: Library<77>-Footnote-1195763767
Ref: Library<77>-Footnote-1205763834
Ref: Library<77>-Footnote-1215763901
Ref: Library<77>-Footnote-1225763968
Ref: Library<77>-Footnote-1235764035
Ref: Library<77>-Footnote-1245764102
Ref: Library<77>-Footnote-1255764169
Ref: Library<77>-Footnote-1265764236
Ref: Library<77>-Footnote-1275764303
Ref: Library<77>-Footnote-1285764370
Ref: Library<77>-Footnote-1295764437
Ref: Library<77>-Footnote-1305764504
Ref: Library<77>-Footnote-1315764571
Ref: Library<77>-Footnote-1325764638
Ref: Library<77>-Footnote-1335764705
Ref: Library<77>-Footnote-1345764772
Ref: Library<77>-Footnote-1355764839
Ref: Library<77>-Footnote-1365764906
Ref: Library<77>-Footnote-1375764973
Ref: Library<77>-Footnote-1385765040
Ref: Library<77>-Footnote-1395765107
Ref: Library<77>-Footnote-1405765174
Ref: Library<77>-Footnote-1415765241
Ref: Library<77>-Footnote-1425765308
Ref: Library<77>-Footnote-1435765375
Ref: Library<77>-Footnote-1445765442
Ref: Library<77>-Footnote-1455765508
Ref: Library<77>-Footnote-1465765575
Ref: Library<77>-Footnote-1475765642
Ref: Library<77>-Footnote-1485765709
Ref: Library<77>-Footnote-1495765776
Ref: Library<77>-Footnote-1505765843
Ref: Library<77>-Footnote-1515765909
Ref: Library<77>-Footnote-1525765976
Ref: Library<77>-Footnote-1535766043
Ref: Library<77>-Footnote-1545766110
Ref: Library<77>-Footnote-1555766177
Ref: Library<77>-Footnote-1565766244
Ref: Library<77>-Footnote-1575766311
Ref: Library<77>-Footnote-1585766378
Ref: Library<77>-Footnote-1595766445
Ref: Library<77>-Footnote-1605766512
Ref: Library<77>-Footnote-1615766578
Ref: Library<77>-Footnote-1625766645
Ref: Library<77>-Footnote-1635766712
Ref: Library<77>-Footnote-1645766779
Ref: Library<77>-Footnote-1655766846
Ref: Library<77>-Footnote-1665766913
Ref: Library<77>-Footnote-1675766980
Ref: Library<77>-Footnote-1685767047
Ref: Library<77>-Footnote-1695767114
Ref: Library<77>-Footnote-1705767181
Ref: Library<77>-Footnote-1715767248
Ref: Library<77>-Footnote-1725767315
Ref: Library<77>-Footnote-1735767382
Ref: Library<77>-Footnote-1745767449
Ref: Library<77>-Footnote-1755767516
Ref: Library<77>-Footnote-1765767583
Ref: Library<77>-Footnote-1775767650
Ref: Library<77>-Footnote-1785767717
Ref: Library<77>-Footnote-1795767784
Ref: Library<77>-Footnote-1805767851
Ref: Library<77>-Footnote-1815767918
Ref: Library<77>-Footnote-1825767985
Ref: Library<77>-Footnote-1835768052
Ref: Library<77>-Footnote-1845768119
Ref: Library<77>-Footnote-1855768186
Ref: Library<77>-Footnote-1865768253
Ref: Library<77>-Footnote-1875768320
Ref: Library<77>-Footnote-1885768387
Ref: Library<77>-Footnote-1895768454
Ref: Library<77>-Footnote-1905768521
Ref: Library<77>-Footnote-1915768588
Ref: Library<77>-Footnote-1925768655
Ref: Library<77>-Footnote-1935768722
Ref: Library<77>-Footnote-1945768789
Ref: Library<77>-Footnote-1955768856
Ref: Library<77>-Footnote-1965768923
Ref: Library<77>-Footnote-1975768990
Ref: Library<77>-Footnote-1985769057
Ref: Library<77>-Footnote-1995769124
Ref: Library<77>-Footnote-2005769191
Ref: Library<77>-Footnote-2015769258
Ref: Library<77>-Footnote-2025769325
Ref: Library<77>-Footnote-2035769392
Ref: Library<77>-Footnote-2045769459
Ref: Library<77>-Footnote-2055769526
Ref: Library<77>-Footnote-2065769593
Ref: Library<77>-Footnote-2075769660
Ref: Library<77>-Footnote-2085769727
Ref: Library<77>-Footnote-2095769793
Ref: Library<77>-Footnote-2105769859
Ref: Library<77>-Footnote-2115769926
Ref: Library<77>-Footnote-2125769993
Ref: Library<77>-Footnote-2135770060
Ref: Library<77>-Footnote-2145770127
Ref: Library<77>-Footnote-2155770194
Ref: Library<77>-Footnote-2165770261
Ref: Library<77>-Footnote-2175770328
Ref: Library<77>-Footnote-2185770395
Ref: Library<77>-Footnote-2195770462
Ref: Library<77>-Footnote-2205770529
Ref: Library<77>-Footnote-2215770596
Ref: Library<77>-Footnote-2225770663
Ref: Library<77>-Footnote-2235770730
Ref: Library<77>-Footnote-2245770797
Node: IDLE<56>5770864
Ref: whatsnew/changelog id6705770975
Ref: 1ac45770975
Ref: IDLE<56>-Footnote-15776506
Ref: IDLE<56>-Footnote-25776571
Ref: IDLE<56>-Footnote-35776636
Ref: IDLE<56>-Footnote-45776701
Ref: IDLE<56>-Footnote-55776766
Ref: IDLE<56>-Footnote-65776831
Ref: IDLE<56>-Footnote-75776896
Ref: IDLE<56>-Footnote-85776961
Ref: IDLE<56>-Footnote-95777026
Ref: IDLE<56>-Footnote-105777091
Ref: IDLE<56>-Footnote-115777157
Ref: IDLE<56>-Footnote-125777223
Ref: IDLE<56>-Footnote-135777289
Ref: IDLE<56>-Footnote-145777355
Ref: IDLE<56>-Footnote-155777421
Ref: IDLE<56>-Footnote-165777487
Ref: IDLE<56>-Footnote-175777553
Ref: IDLE<56>-Footnote-185777619
Ref: IDLE<56>-Footnote-195777685
Ref: IDLE<56>-Footnote-205777751
Ref: IDLE<56>-Footnote-215777817
Ref: IDLE<56>-Footnote-225777883
Ref: IDLE<56>-Footnote-235777949
Ref: IDLE<56>-Footnote-245778015
Ref: IDLE<56>-Footnote-255778081
Ref: IDLE<56>-Footnote-265778147
Ref: IDLE<56>-Footnote-275778213
Ref: IDLE<56>-Footnote-285778279
Node: Documentation<66>5778345
Ref: whatsnew/changelog id6715778454
Ref: 1ac55778454
Ref: Documentation<66>-Footnote-15779238
Ref: Documentation<66>-Footnote-25779303
Ref: Documentation<66>-Footnote-35779367
Ref: Documentation<66>-Footnote-45779432
Ref: Documentation<66>-Footnote-55779497
Node: Tests<70>5779562
Ref: whatsnew/changelog id6725779672
Ref: 1ac65779672
Ref: Tests<70>-Footnote-15781415
Ref: Tests<70>-Footnote-25781480
Ref: Tests<70>-Footnote-35781545
Ref: Tests<70>-Footnote-45781610
Ref: Tests<70>-Footnote-55781675
Ref: Tests<70>-Footnote-65781740
Ref: Tests<70>-Footnote-75781805
Ref: Tests<70>-Footnote-85781870
Ref: Tests<70>-Footnote-95781935
Ref: Tests<70>-Footnote-105782000
Ref: Tests<70>-Footnote-115782066
Ref: Tests<70>-Footnote-125782132
Ref: Tests<70>-Footnote-135782198
Node: Build<76>5782264
Ref: whatsnew/changelog id6735782368
Ref: 1ac75782368
Ref: Build<76>-Footnote-15785092
Ref: Build<76>-Footnote-25785157
Ref: Build<76>-Footnote-35785222
Ref: Build<76>-Footnote-45785287
Ref: Build<76>-Footnote-55785352
Ref: Build<76>-Footnote-65785417
Ref: Build<76>-Footnote-75785482
Ref: Build<76>-Footnote-85785547
Ref: Build<76>-Footnote-95785612
Ref: Build<76>-Footnote-105785677
Ref: Build<76>-Footnote-115785743
Ref: Build<76>-Footnote-125785809
Ref: Build<76>-Footnote-135785875
Ref: Build<76>-Footnote-145785941
Ref: Build<76>-Footnote-155786007
Ref: Build<76>-Footnote-165786073
Ref: Build<76>-Footnote-175786139
Ref: Build<76>-Footnote-185786205
Ref: Build<76>-Footnote-195786271
Node: Windows<66>5786337
Ref: whatsnew/changelog id6745786447
Ref: 1ac85786447
Ref: Windows<66>-Footnote-15787093
Ref: Windows<66>-Footnote-25787158
Ref: Windows<66>-Footnote-35787223
Ref: Windows<66>-Footnote-45787288
Ref: Windows<66>-Footnote-55787353
Ref: Windows<66>-Footnote-65787418
Node: Tools/Demos<41>5787483
Ref: whatsnew/changelog id6755787593
Ref: 1ac95787593
Ref: Tools/Demos<41>-Footnote-15788379
Ref: Tools/Demos<41>-Footnote-25788444
Ref: Tools/Demos<41>-Footnote-35788509
Ref: Tools/Demos<41>-Footnote-45788574
Ref: Tools/Demos<41>-Footnote-55788639
Ref: Tools/Demos<41>-Footnote-65788704
Node: C API<66>5788769
Ref: whatsnew/changelog id6765788859
Ref: 1aca5788859
Ref: C API<66>-Footnote-15789348
Ref: C API<66>-Footnote-25789413
Node: Python 3 5 5 final5789478
Ref: whatsnew/changelog python-3-5-5-final5789615
Ref: 1acb5789615
Node: Python 3 5 5 release candidate 15789743
Ref: whatsnew/changelog python-3-5-5-release-candidate-15789878
Ref: 1acc5789878
Node: Security<45>5790093
Ref: whatsnew/changelog id6775790204
Ref: 1acd5790204
Ref: Security<45>-Footnote-15791473
Ref: Security<45>-Footnote-25791538
Ref: Security<45>-Footnote-35791603
Ref: Security<45>-Footnote-45791668
Ref: Security<45>-Footnote-55791733
Ref: Security<45>-Footnote-65791791
Node: Core and Builtins<79>5791856
Ref: whatsnew/changelog id6785791987
Ref: 1ace5791987
Ref: Core and Builtins<79>-Footnote-15792210
Node: Library<78>5792275
Ref: whatsnew/changelog id6795792385
Ref: 1acf5792385
Ref: Library<78>-Footnote-15792912
Ref: Library<78>-Footnote-25792977
Node: Python 3 5 4 final5793042
Ref: whatsnew/changelog python-3-5-4-final5793191
Ref: 1ad05793191
Node: Library<79>5793308
Ref: whatsnew/changelog id6805793374
Ref: 1ad15793374
Ref: Library<79>-Footnote-15793572
Node: Python 3 5 4 release candidate 15793637
Ref: whatsnew/changelog python-3-5-4-release-candidate-15793772
Ref: 1ad25793772
Node: Security<46>5794107
Ref: whatsnew/changelog id6815794218
Ref: 1ad35794218
Ref: Security<46>-Footnote-15795540
Ref: Security<46>-Footnote-25795605
Ref: Security<46>-Footnote-35795670
Ref: Security<46>-Footnote-45795725
Ref: Security<46>-Footnote-55795780
Ref: Security<46>-Footnote-65795835
Ref: Security<46>-Footnote-75795890
Ref: Security<46>-Footnote-85795945
Ref: Security<46>-Footnote-95796000
Ref: Security<46>-Footnote-105796065
Ref: Security<46>-Footnote-115796131
Ref: Security<46>-Footnote-125796187
Node: Core and Builtins<80>5796243
Ref: whatsnew/changelog id6825796374
Ref: 1ad45796374
Ref: Core and Builtins<80>-Footnote-15798629
Ref: Core and Builtins<80>-Footnote-25798694
Ref: Core and Builtins<80>-Footnote-35798759
Ref: Core and Builtins<80>-Footnote-45798824
Ref: Core and Builtins<80>-Footnote-55798889
Ref: Core and Builtins<80>-Footnote-65798954
Ref: Core and Builtins<80>-Footnote-75799019
Ref: Core and Builtins<80>-Footnote-85799084
Ref: Core and Builtins<80>-Footnote-95799149
Ref: Core and Builtins<80>-Footnote-105799214
Ref: Core and Builtins<80>-Footnote-115799280
Ref: Core and Builtins<80>-Footnote-125799346
Ref: Core and Builtins<80>-Footnote-135799412
Ref: Core and Builtins<80>-Footnote-145799478
Ref: Core and Builtins<80>-Footnote-155799544
Node: Library<80>5799610
Ref: whatsnew/changelog id6835799746
Ref: 1ad55799746
Ref: Library<80>-Footnote-15809907
Ref: Library<80>-Footnote-25809972
Ref: Library<80>-Footnote-35810037
Ref: Library<80>-Footnote-45810102
Ref: Library<80>-Footnote-55810167
Ref: Library<80>-Footnote-65810232
Ref: Library<80>-Footnote-75810297
Ref: Library<80>-Footnote-85810362
Ref: Library<80>-Footnote-95810427
Ref: Library<80>-Footnote-105810492
Ref: Library<80>-Footnote-115810558
Ref: Library<80>-Footnote-125810624
Ref: Library<80>-Footnote-135810690
Ref: Library<80>-Footnote-145810756
Ref: Library<80>-Footnote-155810822
Ref: Library<80>-Footnote-165810888
Ref: Library<80>-Footnote-175810954
Ref: Library<80>-Footnote-185811020
Ref: Library<80>-Footnote-195811086
Ref: Library<80>-Footnote-205811152
Ref: Library<80>-Footnote-215811218
Ref: Library<80>-Footnote-225811284
Ref: Library<80>-Footnote-235811350
Ref: Library<80>-Footnote-245811416
Ref: Library<80>-Footnote-255811482
Ref: Library<80>-Footnote-265811548
Ref: Library<80>-Footnote-275811614
Ref: Library<80>-Footnote-285811680
Ref: Library<80>-Footnote-295811746
Ref: Library<80>-Footnote-305811812
Ref: Library<80>-Footnote-315811878
Ref: Library<80>-Footnote-325811944
Ref: Library<80>-Footnote-335812010
Ref: Library<80>-Footnote-345812076
Ref: Library<80>-Footnote-355812142
Ref: Library<80>-Footnote-365812208
Ref: Library<80>-Footnote-375812274
Ref: Library<80>-Footnote-385812340
Ref: Library<80>-Footnote-395812406
Ref: Library<80>-Footnote-405812472
Ref: Library<80>-Footnote-415812538
Ref: Library<80>-Footnote-425812604
Ref: Library<80>-Footnote-435812670
Ref: Library<80>-Footnote-445812736
Ref: Library<80>-Footnote-455812802
Ref: Library<80>-Footnote-465812868
Ref: Library<80>-Footnote-475812934
Ref: Library<80>-Footnote-485813000
Ref: Library<80>-Footnote-495813066
Ref: Library<80>-Footnote-505813132
Ref: Library<80>-Footnote-515813198
Ref: Library<80>-Footnote-525813264
Ref: Library<80>-Footnote-535813330
Ref: Library<80>-Footnote-545813396
Ref: Library<80>-Footnote-555813461
Ref: Library<80>-Footnote-565813527
Ref: Library<80>-Footnote-575813593
Ref: Library<80>-Footnote-585813659
Ref: Library<80>-Footnote-595813725
Ref: Library<80>-Footnote-605813791
Ref: Library<80>-Footnote-615813857
Ref: Library<80>-Footnote-625813923
Ref: Library<80>-Footnote-635813989
Ref: Library<80>-Footnote-645814055
Ref: Library<80>-Footnote-655814121
Ref: Library<80>-Footnote-665814187
Ref: Library<80>-Footnote-675814253
Ref: Library<80>-Footnote-685814319
Ref: Library<80>-Footnote-695814385
Ref: Library<80>-Footnote-705814451
Ref: Library<80>-Footnote-715814517
Ref: Library<80>-Footnote-725814583
Ref: Library<80>-Footnote-735814649
Ref: Library<80>-Footnote-745814715
Node: Documentation<67>5814781
Ref: whatsnew/changelog id6845814905
Ref: 1ad65814905
Ref: Documentation<67>-Footnote-15815615
Ref: Documentation<67>-Footnote-25815680
Ref: Documentation<67>-Footnote-35815745
Ref: Documentation<67>-Footnote-45815810
Ref: Documentation<67>-Footnote-55815875
Ref: Documentation<67>-Footnote-65815940
Node: Tests<71>5816005
Ref: whatsnew/changelog id6855816127
Ref: 1ad75816127
Ref: Tests<71>-Footnote-15818204
Ref: Tests<71>-Footnote-25818269
Ref: Tests<71>-Footnote-35818334
Ref: Tests<71>-Footnote-45818399
Ref: Tests<71>-Footnote-55818464
Ref: Tests<71>-Footnote-65818529
Ref: Tests<71>-Footnote-75818594
Ref: Tests<71>-Footnote-85818659
Ref: Tests<71>-Footnote-95818724
Node: Build<77>5818789
Ref: whatsnew/changelog id6865818905
Ref: 1ad85818905
Ref: Build<77>-Footnote-15819417
Ref: Build<77>-Footnote-25819482
Ref: Build<77>-Footnote-35819547
Node: Windows<67>5819612
Ref: whatsnew/changelog id6875819728
Ref: 1ad95819728
Ref: Windows<67>-Footnote-15819986
Ref: Windows<67>-Footnote-25820051
Node: C API<67>5820116
Ref: whatsnew/changelog id6885820214
Ref: 1ada5820214
Ref: C API<67>-Footnote-15820821
Ref: C API<67>-Footnote-25820886
Node: Python 3 5 3 final5820951
Ref: whatsnew/changelog python-3-5-3-final5821100
Ref: 1adb5821100
Node: Python 3 5 3 release candidate 15821245
Ref: whatsnew/changelog python-3-5-3-release-candidate-15821380
Ref: 1adc5821380
Node: Security<47>5821765
Ref: whatsnew/changelog id6895821876
Ref: 1add5821876
Ref: Security<47>-Footnote-15822254
Ref: Security<47>-Footnote-25822319
Node: Core and Builtins<81>5822384
Ref: whatsnew/changelog id6905822515
Ref: 1ade5822515
Ref: Core and Builtins<81>-Footnote-15827945
Ref: Core and Builtins<81>-Footnote-25828010
Ref: Core and Builtins<81>-Footnote-35828075
Ref: Core and Builtins<81>-Footnote-45828140
Ref: Core and Builtins<81>-Footnote-55828205
Ref: Core and Builtins<81>-Footnote-65828270
Ref: Core and Builtins<81>-Footnote-75828335
Ref: Core and Builtins<81>-Footnote-85828400
Ref: Core and Builtins<81>-Footnote-95828465
Ref: Core and Builtins<81>-Footnote-105828530
Ref: Core and Builtins<81>-Footnote-115828596
Ref: Core and Builtins<81>-Footnote-125828662
Ref: Core and Builtins<81>-Footnote-135828728
Ref: Core and Builtins<81>-Footnote-145828794
Ref: Core and Builtins<81>-Footnote-155828860
Ref: Core and Builtins<81>-Footnote-165828926
Ref: Core and Builtins<81>-Footnote-175828992
Ref: Core and Builtins<81>-Footnote-185829058
Ref: Core and Builtins<81>-Footnote-195829124
Ref: Core and Builtins<81>-Footnote-205829190
Ref: Core and Builtins<81>-Footnote-215829256
Ref: Core and Builtins<81>-Footnote-225829322
Ref: Core and Builtins<81>-Footnote-235829388
Ref: Core and Builtins<81>-Footnote-245829454
Ref: Core and Builtins<81>-Footnote-255829520
Ref: Core and Builtins<81>-Footnote-265829586
Ref: Core and Builtins<81>-Footnote-275829652
Ref: Core and Builtins<81>-Footnote-285829718
Ref: Core and Builtins<81>-Footnote-295829784
Ref: Core and Builtins<81>-Footnote-305829850
Ref: Core and Builtins<81>-Footnote-315829916
Ref: Core and Builtins<81>-Footnote-325829982
Ref: Core and Builtins<81>-Footnote-335830048
Ref: Core and Builtins<81>-Footnote-345830114
Ref: Core and Builtins<81>-Footnote-355830180
Ref: Core and Builtins<81>-Footnote-365830246
Ref: Core and Builtins<81>-Footnote-375830312
Ref: Core and Builtins<81>-Footnote-385830378
Ref: Core and Builtins<81>-Footnote-395830444
Ref: Core and Builtins<81>-Footnote-405830510
Ref: Core and Builtins<81>-Footnote-415830576
Ref: Core and Builtins<81>-Footnote-425830642
Ref: Core and Builtins<81>-Footnote-435830708
Node: Library<81>5830774
Ref: whatsnew/changelog id6915830901
Ref: 1adf5830901
Ref: Library<81>-Footnote-15846831
Ref: Library<81>-Footnote-25846896
Ref: Library<81>-Footnote-35846961
Ref: Library<81>-Footnote-45847026
Ref: Library<81>-Footnote-55847091
Ref: Library<81>-Footnote-65847155
Ref: Library<81>-Footnote-75847220
Ref: Library<81>-Footnote-85847285
Ref: Library<81>-Footnote-95847350
Ref: Library<81>-Footnote-105847415
Ref: Library<81>-Footnote-115847481
Ref: Library<81>-Footnote-125847547
Ref: Library<81>-Footnote-135847613
Ref: Library<81>-Footnote-145847679
Ref: Library<81>-Footnote-155847745
Ref: Library<81>-Footnote-165847811
Ref: Library<81>-Footnote-175847877
Ref: Library<81>-Footnote-185847943
Ref: Library<81>-Footnote-195848009
Ref: Library<81>-Footnote-205848075
Ref: Library<81>-Footnote-215848141
Ref: Library<81>-Footnote-225848207
Ref: Library<81>-Footnote-235848273
Ref: Library<81>-Footnote-245848339
Ref: Library<81>-Footnote-255848405
Ref: Library<81>-Footnote-265848471
Ref: Library<81>-Footnote-275848537
Ref: Library<81>-Footnote-285848603
Ref: Library<81>-Footnote-295848669
Ref: Library<81>-Footnote-305848735
Ref: Library<81>-Footnote-315848801
Ref: Library<81>-Footnote-325848867
Ref: Library<81>-Footnote-335848935
Ref: Library<81>-Footnote-345849001
Ref: Library<81>-Footnote-355849067
Ref: Library<81>-Footnote-365849133
Ref: Library<81>-Footnote-375849199
Ref: Library<81>-Footnote-385849265
Ref: Library<81>-Footnote-395849331
Ref: Library<81>-Footnote-405849397
Ref: Library<81>-Footnote-415849463
Ref: Library<81>-Footnote-425849529
Ref: Library<81>-Footnote-435849595
Ref: Library<81>-Footnote-445849661
Ref: Library<81>-Footnote-455849727
Ref: Library<81>-Footnote-465849793
Ref: Library<81>-Footnote-475849859
Ref: Library<81>-Footnote-485849925
Ref: Library<81>-Footnote-495849991
Ref: Library<81>-Footnote-505850057
Ref: Library<81>-Footnote-515850123
Ref: Library<81>-Footnote-525850189
Ref: Library<81>-Footnote-535850255
Ref: Library<81>-Footnote-545850321
Ref: Library<81>-Footnote-555850387
Ref: Library<81>-Footnote-565850453
Ref: Library<81>-Footnote-575850519
Ref: Library<81>-Footnote-585850585
Ref: Library<81>-Footnote-595850651
Ref: Library<81>-Footnote-605850717
Ref: Library<81>-Footnote-615850773
Ref: Library<81>-Footnote-625850839
Ref: Library<81>-Footnote-635850905
Ref: Library<81>-Footnote-645850971
Ref: Library<81>-Footnote-655851037
Ref: Library<81>-Footnote-665851103
Ref: Library<81>-Footnote-675851169
Ref: Library<81>-Footnote-685851235
Ref: Library<81>-Footnote-695851301
Ref: Library<81>-Footnote-705851367
Ref: Library<81>-Footnote-715851433
Ref: Library<81>-Footnote-725851499
Ref: Library<81>-Footnote-735851564
Ref: Library<81>-Footnote-745851630
Ref: Library<81>-Footnote-755851696
Ref: Library<81>-Footnote-765851762
Ref: Library<81>-Footnote-775851828
Ref: Library<81>-Footnote-785851894
Ref: Library<81>-Footnote-795851960
Ref: Library<81>-Footnote-805852026
Ref: Library<81>-Footnote-815852085
Ref: Library<81>-Footnote-825852151
Ref: Library<81>-Footnote-835852217
Ref: Library<81>-Footnote-845852283
Ref: Library<81>-Footnote-855852349
Ref: Library<81>-Footnote-865852415
Ref: Library<81>-Footnote-875852481
Ref: Library<81>-Footnote-885852547
Ref: Library<81>-Footnote-895852613
Ref: Library<81>-Footnote-905852679
Ref: Library<81>-Footnote-915852745
Ref: Library<81>-Footnote-925852811
Ref: Library<81>-Footnote-935852877
Ref: Library<81>-Footnote-945852943
Ref: Library<81>-Footnote-955853009
Ref: Library<81>-Footnote-965853075
Ref: Library<81>-Footnote-975853141
Ref: Library<81>-Footnote-985853184
Ref: Library<81>-Footnote-995853250
Ref: Library<81>-Footnote-1005853316
Ref: Library<81>-Footnote-1015853383
Ref: Library<81>-Footnote-1025853450
Ref: Library<81>-Footnote-1035853517
Ref: Library<81>-Footnote-1045853584
Ref: Library<81>-Footnote-1055853651
Ref: Library<81>-Footnote-1065853718
Ref: Library<81>-Footnote-1075853785
Ref: Library<81>-Footnote-1085853852
Ref: Library<81>-Footnote-1095853919
Ref: Library<81>-Footnote-1105853986
Ref: Library<81>-Footnote-1115854053
Ref: Library<81>-Footnote-1125854120
Ref: Library<81>-Footnote-1135854187
Ref: Library<81>-Footnote-1145854254
Ref: Library<81>-Footnote-1155854321
Ref: Library<81>-Footnote-1165854388
Ref: Library<81>-Footnote-1175854455
Ref: Library<81>-Footnote-1185854522
Ref: Library<81>-Footnote-1195854589
Ref: Library<81>-Footnote-1205854656
Ref: Library<81>-Footnote-1215854723
Ref: Library<81>-Footnote-1225854790
Ref: Library<81>-Footnote-1235854857
Ref: Library<81>-Footnote-1245854924
Ref: Library<81>-Footnote-1255854991
Ref: Library<81>-Footnote-1265855058
Node: IDLE<57>5855125
Ref: whatsnew/changelog id6925855240
Ref: 1ae05855240
Ref: IDLE<57>-Footnote-15856479
Ref: IDLE<57>-Footnote-25856544
Ref: IDLE<57>-Footnote-35856609
Ref: IDLE<57>-Footnote-45856674
Ref: IDLE<57>-Footnote-55856739
Ref: IDLE<57>-Footnote-65856804
Ref: IDLE<57>-Footnote-75856869
Ref: IDLE<57>-Footnote-85856934
Node: C API<68>5856999
Ref: whatsnew/changelog id6935857120
Ref: 1ae15857120
Ref: C API<68>-Footnote-15857450
Ref: C API<68>-Footnote-25857515
Node: Documentation<68>5857580
Ref: whatsnew/changelog id6945857702
Ref: 1ae25857702
Ref: Documentation<68>-Footnote-15857853
Node: Tests<72>5857918
Ref: whatsnew/changelog id6955858046
Ref: 1ae35858046
Ref: Tests<72>-Footnote-15858733
Ref: Tests<72>-Footnote-25858798
Ref: Tests<72>-Footnote-35858863
Ref: Tests<72>-Footnote-45858928
Ref: Tests<72>-Footnote-55858993
Ref: Tests<72>-Footnote-65859058
Node: Tools/Demos<42>5859123
Ref: whatsnew/changelog id6965859245
Ref: 1ae45859245
Ref: Tools/Demos<42>-Footnote-15859723
Ref: Tools/Demos<42>-Footnote-25859788
Ref: Tools/Demos<42>-Footnote-35859853
Node: Windows<68>5859918
Ref: whatsnew/changelog id6975860040
Ref: 1ae55860040
Ref: Windows<68>-Footnote-15860540
Ref: Windows<68>-Footnote-25860605
Ref: Windows<68>-Footnote-35860670
Ref: Windows<68>-Footnote-45860735
Ref: Windows<68>-Footnote-55860800
Node: Build<78>5860865
Ref: whatsnew/changelog id6985860963
Ref: 1ae65860963
Ref: Build<78>-Footnote-15863656
Ref: Build<78>-Footnote-25863721
Ref: Build<78>-Footnote-35863786
Ref: Build<78>-Footnote-45863851
Ref: Build<78>-Footnote-55863916
Ref: Build<78>-Footnote-65863981
Ref: Build<78>-Footnote-75864046
Ref: Build<78>-Footnote-85864111
Ref: Build<78>-Footnote-95864176
Ref: Build<78>-Footnote-105864241
Ref: Build<78>-Footnote-115864307
Ref: Build<78>-Footnote-125864373
Ref: Build<78>-Footnote-135864439
Ref: Build<78>-Footnote-145864505
Ref: Build<78>-Footnote-155864571
Ref: Build<78>-Footnote-165864637
Ref: Build<78>-Footnote-175864703
Ref: Build<78>-Footnote-185864769
Ref: Build<78>-Footnote-195864835
Ref: Build<78>-Footnote-205864901
Ref: Build<78>-Footnote-215864967
Ref: Build<78>-Footnote-225865033
Node: Python 3 5 2 final5865099
Ref: whatsnew/changelog python-3-5-2-final5865248
Ref: 1ae75865248
Node: Core and Builtins<82>5865423
Ref: whatsnew/changelog id6995865517
Ref: 1ae85865517
Ref: Core and Builtins<82>-Footnote-15865675
Node: Tests<73>5865740
Ref: whatsnew/changelog id7005865851
Ref: 1ae95865851
Ref: Tests<73>-Footnote-15866009
Node: IDLE<58>5866074
Ref: whatsnew/changelog id7015866155
Ref: 1aea5866155
Ref: IDLE<58>-Footnote-15866309
Node: Python 3 5 2 release candidate 15866374
Ref: whatsnew/changelog python-3-5-2-release-candidate-15866509
Ref: 1aeb5866509
Node: Security<48>5866874
Ref: whatsnew/changelog id7025866985
Ref: 1aec5866985
Ref: Security<48>-Footnote-15867892
Ref: Security<48>-Footnote-25867957
Ref: Security<48>-Footnote-35868012
Ref: Security<48>-Footnote-45868067
Ref: Security<48>-Footnote-55868132
Ref: Security<48>-Footnote-65868197
Ref: Security<48>-Footnote-75868262
Node: Core and Builtins<83>5868327
Ref: whatsnew/changelog id7035868458
Ref: 1aed5868458
Ref: Core and Builtins<83>-Footnote-15874297
Ref: Core and Builtins<83>-Footnote-25874362
Ref: Core and Builtins<83>-Footnote-35874427
Ref: Core and Builtins<83>-Footnote-45874492
Ref: Core and Builtins<83>-Footnote-55874557
Ref: Core and Builtins<83>-Footnote-65874622
Ref: Core and Builtins<83>-Footnote-75874687
Ref: Core and Builtins<83>-Footnote-85874752
Ref: Core and Builtins<83>-Footnote-95874817
Ref: Core and Builtins<83>-Footnote-105874882
Ref: Core and Builtins<83>-Footnote-115874948
Ref: Core and Builtins<83>-Footnote-125875014
Ref: Core and Builtins<83>-Footnote-135875080
Ref: Core and Builtins<83>-Footnote-145875146
Ref: Core and Builtins<83>-Footnote-155875212
Ref: Core and Builtins<83>-Footnote-165875278
Ref: Core and Builtins<83>-Footnote-175875344
Ref: Core and Builtins<83>-Footnote-185875409
Ref: Core and Builtins<83>-Footnote-195875475
Ref: Core and Builtins<83>-Footnote-205875541
Ref: Core and Builtins<83>-Footnote-215875607
Ref: Core and Builtins<83>-Footnote-225875673
Ref: Core and Builtins<83>-Footnote-235875739
Ref: Core and Builtins<83>-Footnote-245875805
Ref: Core and Builtins<83>-Footnote-255875871
Ref: Core and Builtins<83>-Footnote-265875937
Ref: Core and Builtins<83>-Footnote-275876003
Ref: Core and Builtins<83>-Footnote-285876069
Ref: Core and Builtins<83>-Footnote-295876135
Ref: Core and Builtins<83>-Footnote-305876201
Ref: Core and Builtins<83>-Footnote-315876267
Ref: Core and Builtins<83>-Footnote-325876310
Ref: Core and Builtins<83>-Footnote-335876376
Ref: Core and Builtins<83>-Footnote-345876442
Ref: Core and Builtins<83>-Footnote-355876508
Ref: Core and Builtins<83>-Footnote-365876574
Ref: Core and Builtins<83>-Footnote-375876640
Ref: Core and Builtins<83>-Footnote-385876706
Node: Library<82>5876772
Ref: whatsnew/changelog id7045876899
Ref: 1aee5876899
Ref: Library<82>-Footnote-15893647
Ref: Library<82>-Footnote-25893712
Ref: Library<82>-Footnote-35893777
Ref: Library<82>-Footnote-45893819
Ref: Library<82>-Footnote-55893884
Ref: Library<82>-Footnote-65893949
Ref: Library<82>-Footnote-75894014
Ref: Library<82>-Footnote-85894079
Ref: Library<82>-Footnote-95894144
Ref: Library<82>-Footnote-105894209
Ref: Library<82>-Footnote-115894275
Ref: Library<82>-Footnote-125894341
Ref: Library<82>-Footnote-135894407
Ref: Library<82>-Footnote-145894473
Ref: Library<82>-Footnote-155894539
Ref: Library<82>-Footnote-165894605
Ref: Library<82>-Footnote-175894671
Ref: Library<82>-Footnote-185894737
Ref: Library<82>-Footnote-195894803
Ref: Library<82>-Footnote-205894869
Ref: Library<82>-Footnote-215894935
Ref: Library<82>-Footnote-225895001
Ref: Library<82>-Footnote-235895067
Ref: Library<82>-Footnote-245895133
Ref: Library<82>-Footnote-255895199
Ref: Library<82>-Footnote-265895265
Ref: Library<82>-Footnote-275895331
Ref: Library<82>-Footnote-285895397
Ref: Library<82>-Footnote-295895463
Ref: Library<82>-Footnote-305895529
Ref: Library<82>-Footnote-315895595
Ref: Library<82>-Footnote-325895661
Ref: Library<82>-Footnote-335895727
Ref: Library<82>-Footnote-345895793
Ref: Library<82>-Footnote-355895859
Ref: Library<82>-Footnote-365895925
Ref: Library<82>-Footnote-375895991
Ref: Library<82>-Footnote-385896057
Ref: Library<82>-Footnote-395896123
Ref: Library<82>-Footnote-405896189
Ref: Library<82>-Footnote-415896255
Ref: Library<82>-Footnote-425896321
Ref: Library<82>-Footnote-435896387
Ref: Library<82>-Footnote-445896453
Ref: Library<82>-Footnote-455896519
Ref: Library<82>-Footnote-465896585
Ref: Library<82>-Footnote-475896651
Ref: Library<82>-Footnote-485896717
Ref: Library<82>-Footnote-495896783
Ref: Library<82>-Footnote-505896849
Ref: Library<82>-Footnote-515896915
Ref: Library<82>-Footnote-525896981
Ref: Library<82>-Footnote-535897047
Ref: Library<82>-Footnote-545897113
Ref: Library<82>-Footnote-555897179
Ref: Library<82>-Footnote-565897245
Ref: Library<82>-Footnote-575897311
Ref: Library<82>-Footnote-585897377
Ref: Library<82>-Footnote-595897443
Ref: Library<82>-Footnote-605897509
Ref: Library<82>-Footnote-615897575
Ref: Library<82>-Footnote-625897640
Ref: Library<82>-Footnote-635897706
Ref: Library<82>-Footnote-645897772
Ref: Library<82>-Footnote-655897838
Ref: Library<82>-Footnote-665897904
Ref: Library<82>-Footnote-675897970
Ref: Library<82>-Footnote-685898036
Ref: Library<82>-Footnote-695898102
Ref: Library<82>-Footnote-705898168
Ref: Library<82>-Footnote-715898234
Ref: Library<82>-Footnote-725898300
Ref: Library<82>-Footnote-735898366
Ref: Library<82>-Footnote-745898432
Ref: Library<82>-Footnote-755898498
Ref: Library<82>-Footnote-765898564
Ref: Library<82>-Footnote-775898630
Ref: Library<82>-Footnote-785898696
Ref: Library<82>-Footnote-795898762
Ref: Library<82>-Footnote-805898828
Ref: Library<82>-Footnote-815898894
Ref: Library<82>-Footnote-825898960
Ref: Library<82>-Footnote-835899026
Ref: Library<82>-Footnote-845899092
Ref: Library<82>-Footnote-855899158
Ref: Library<82>-Footnote-865899224
Ref: Library<82>-Footnote-875899290
Ref: Library<82>-Footnote-885899356
Ref: Library<82>-Footnote-895899422
Ref: Library<82>-Footnote-905899488
Ref: Library<82>-Footnote-915899554
Ref: Library<82>-Footnote-925899620
Ref: Library<82>-Footnote-935899686
Ref: Library<82>-Footnote-945899752
Ref: Library<82>-Footnote-955899818
Ref: Library<82>-Footnote-965899884
Ref: Library<82>-Footnote-975899950
Ref: Library<82>-Footnote-985900016
Ref: Library<82>-Footnote-995900082
Ref: Library<82>-Footnote-1005900148
Ref: Library<82>-Footnote-1015900215
Ref: Library<82>-Footnote-1025900281
Ref: Library<82>-Footnote-1035900348
Ref: Library<82>-Footnote-1045900415
Ref: Library<82>-Footnote-1055900482
Ref: Library<82>-Footnote-1065900549
Ref: Library<82>-Footnote-1075900616
Ref: Library<82>-Footnote-1085900683
Ref: Library<82>-Footnote-1095900750
Ref: Library<82>-Footnote-1105900817
Ref: Library<82>-Footnote-1115900884
Ref: Library<82>-Footnote-1125900951
Ref: Library<82>-Footnote-1135901018
Ref: Library<82>-Footnote-1145901085
Ref: Library<82>-Footnote-1155901152
Ref: Library<82>-Footnote-1165901219
Ref: Library<82>-Footnote-1175901286
Ref: Library<82>-Footnote-1185901353
Ref: Library<82>-Footnote-1195901420
Ref: Library<82>-Footnote-1205901487
Node: IDLE<59>5901554
Ref: whatsnew/changelog id7055901677
Ref: 1aef5901677
Ref: IDLE<59>-Footnote-15904010
Ref: IDLE<59>-Footnote-25904074
Ref: IDLE<59>-Footnote-35904139
Ref: IDLE<59>-Footnote-45904204
Ref: IDLE<59>-Footnote-55904269
Ref: IDLE<59>-Footnote-65904334
Ref: IDLE<59>-Footnote-75904399
Ref: IDLE<59>-Footnote-85904464
Ref: IDLE<59>-Footnote-95904529
Ref: IDLE<59>-Footnote-105904594
Ref: IDLE<59>-Footnote-115904660
Ref: IDLE<59>-Footnote-125904726
Ref: IDLE<59>-Footnote-135904792
Ref: IDLE<59>-Footnote-145904858
Ref: IDLE<59>-Footnote-155904924
Node: Documentation<69>5904990
Ref: whatsnew/changelog id7065905111
Ref: 1af05905111
Ref: Documentation<69>-Footnote-15906065
Ref: Documentation<69>-Footnote-25906130
Ref: Documentation<69>-Footnote-35906195
Ref: Documentation<69>-Footnote-45906237
Ref: Documentation<69>-Footnote-55906302
Ref: Documentation<69>-Footnote-65906366
Ref: Documentation<69>-Footnote-75906431
Ref: Documentation<69>-Footnote-85906496
Node: Tests<74>5906561
Ref: whatsnew/changelog id7075906683
Ref: 1af15906683
Ref: Tests<74>-Footnote-15907556
Ref: Tests<74>-Footnote-25907621
Ref: Tests<74>-Footnote-35907686
Ref: Tests<74>-Footnote-45907751
Ref: Tests<74>-Footnote-55907816
Ref: Tests<74>-Footnote-65907881
Ref: Tests<74>-Footnote-75907946
Node: Build<79>5908011
Ref: whatsnew/changelog id7085908127
Ref: 1af25908127
Ref: Build<79>-Footnote-15910649
Ref: Build<79>-Footnote-25910714
Ref: Build<79>-Footnote-35910779
Ref: Build<79>-Footnote-45910844
Ref: Build<79>-Footnote-55910909
Ref: Build<79>-Footnote-65910974
Ref: Build<79>-Footnote-75911039
Ref: Build<79>-Footnote-85911104
Ref: Build<79>-Footnote-95911169
Ref: Build<79>-Footnote-105911234
Ref: Build<79>-Footnote-115911300
Ref: Build<79>-Footnote-125911366
Ref: Build<79>-Footnote-135911432
Ref: Build<79>-Footnote-145911498
Ref: Build<79>-Footnote-155911564
Ref: Build<79>-Footnote-165911630
Ref: Build<79>-Footnote-175911696
Node: Windows<69>5911762
Ref: whatsnew/changelog id7095911884
Ref: 1af35911884
Ref: Windows<69>-Footnote-15912590
Ref: Windows<69>-Footnote-25912655
Ref: Windows<69>-Footnote-35912720
Ref: Windows<69>-Footnote-45912785
Ref: Windows<69>-Footnote-55912850
Ref: Windows<69>-Footnote-65912915
Node: Tools/Demos<43>5912980
Ref: whatsnew/changelog id7105913084
Ref: 1af45913084
Ref: Tools/Demos<43>-Footnote-15913704
Ref: Tools/Demos<43>-Footnote-25913769
Ref: Tools/Demos<43>-Footnote-35913834
Ref: Tools/Demos<43>-Footnote-45913899
Node: Python 3 5 1 final5913964
Ref: whatsnew/changelog python-3-5-1-final5914113
Ref: 1af55914113
Node: Core and Builtins<84>5914274
Ref: whatsnew/changelog id7115914370
Ref: 1af65914370
Ref: Core and Builtins<84>-Footnote-15914554
Node: Windows<70>5914619
Ref: whatsnew/changelog id7125914715
Ref: 1af75914715
Ref: Windows<70>-Footnote-15914905
Node: Python 3 5 1 release candidate 15914970
Ref: whatsnew/changelog python-3-5-1-release-candidate-15915105
Ref: 1af85915105
Node: Core and Builtins<85>5915444
Ref: whatsnew/changelog id7135915554
Ref: 1af95915554
Ref: Core and Builtins<85>-Footnote-15918690
Ref: Core and Builtins<85>-Footnote-25918755
Ref: Core and Builtins<85>-Footnote-35918820
Ref: Core and Builtins<85>-Footnote-45918885
Ref: Core and Builtins<85>-Footnote-55918950
Ref: Core and Builtins<85>-Footnote-65919015
Ref: Core and Builtins<85>-Footnote-75919080
Ref: Core and Builtins<85>-Footnote-85919145
Ref: Core and Builtins<85>-Footnote-95919210
Ref: Core and Builtins<85>-Footnote-105919275
Ref: Core and Builtins<85>-Footnote-115919341
Ref: Core and Builtins<85>-Footnote-125919407
Ref: Core and Builtins<85>-Footnote-135919473
Ref: Core and Builtins<85>-Footnote-145919539
Ref: Core and Builtins<85>-Footnote-155919605
Ref: Core and Builtins<85>-Footnote-165919671
Ref: Core and Builtins<85>-Footnote-175919737
Ref: Core and Builtins<85>-Footnote-185919803
Ref: Core and Builtins<85>-Footnote-195919869
Node: Library<83>5919935
Ref: whatsnew/changelog id7145920062
Ref: 1afa5920062
Ref: Library<83>-Footnote-15930400
Ref: Library<83>-Footnote-25930465
Ref: Library<83>-Footnote-35930530
Ref: Library<83>-Footnote-45930595
Ref: Library<83>-Footnote-55930659
Ref: Library<83>-Footnote-65930724
Ref: Library<83>-Footnote-75930789
Ref: Library<83>-Footnote-85930854
Ref: Library<83>-Footnote-95930919
Ref: Library<83>-Footnote-105930984
Ref: Library<83>-Footnote-115931050
Ref: Library<83>-Footnote-125931116
Ref: Library<83>-Footnote-135931182
Ref: Library<83>-Footnote-145931248
Ref: Library<83>-Footnote-155931314
Ref: Library<83>-Footnote-165931380
Ref: Library<83>-Footnote-175931446
Ref: Library<83>-Footnote-185931512
Ref: Library<83>-Footnote-195931578
Ref: Library<83>-Footnote-205931644
Ref: Library<83>-Footnote-215931710
Ref: Library<83>-Footnote-225931776
Ref: Library<83>-Footnote-235931842
Ref: Library<83>-Footnote-245931908
Ref: Library<83>-Footnote-255931974
Ref: Library<83>-Footnote-265932040
Ref: Library<83>-Footnote-275932106
Ref: Library<83>-Footnote-285932172
Ref: Library<83>-Footnote-295932238
Ref: Library<83>-Footnote-305932304
Ref: Library<83>-Footnote-315932370
Ref: Library<83>-Footnote-325932436
Ref: Library<83>-Footnote-335932502
Ref: Library<83>-Footnote-345932568
Ref: Library<83>-Footnote-355932634
Ref: Library<83>-Footnote-365932700
Ref: Library<83>-Footnote-375932766
Ref: Library<83>-Footnote-385932832
Ref: Library<83>-Footnote-395932898
Ref: Library<83>-Footnote-405932964
Ref: Library<83>-Footnote-415933030
Ref: Library<83>-Footnote-425933096
Ref: Library<83>-Footnote-435933162
Ref: Library<83>-Footnote-445933228
Ref: Library<83>-Footnote-455933294
Ref: Library<83>-Footnote-465933360
Ref: Library<83>-Footnote-475933426
Ref: Library<83>-Footnote-485933492
Ref: Library<83>-Footnote-495933558
Ref: Library<83>-Footnote-505933624
Ref: Library<83>-Footnote-515933690
Ref: Library<83>-Footnote-525933756
Ref: Library<83>-Footnote-535933822
Ref: Library<83>-Footnote-545933888
Ref: Library<83>-Footnote-555933954
Ref: Library<83>-Footnote-565934020
Ref: Library<83>-Footnote-575934086
Ref: Library<83>-Footnote-585934152
Ref: Library<83>-Footnote-595934218
Ref: Library<83>-Footnote-605934284
Ref: Library<83>-Footnote-615934350
Ref: Library<83>-Footnote-625934416
Ref: Library<83>-Footnote-635934482
Ref: Library<83>-Footnote-645934548
Ref: Library<83>-Footnote-655934614
Ref: Library<83>-Footnote-665934680
Ref: Library<83>-Footnote-675934746
Ref: Library<83>-Footnote-685934812
Ref: Library<83>-Footnote-695934878
Ref: Library<83>-Footnote-705934944
Node: IDLE<60>5935010
Ref: whatsnew/changelog id7155935133
Ref: 1afb5935133
Ref: IDLE<60>-Footnote-15940050
Ref: IDLE<60>-Footnote-25940115
Ref: IDLE<60>-Footnote-35940180
Ref: IDLE<60>-Footnote-45940245
Ref: IDLE<60>-Footnote-55940310
Ref: IDLE<60>-Footnote-65940375
Ref: IDLE<60>-Footnote-75940440
Ref: IDLE<60>-Footnote-85940505
Ref: IDLE<60>-Footnote-95940570
Ref: IDLE<60>-Footnote-105940635
Ref: IDLE<60>-Footnote-115940701
Ref: IDLE<60>-Footnote-125940767
Ref: IDLE<60>-Footnote-135940833
Ref: IDLE<60>-Footnote-145940899
Ref: IDLE<60>-Footnote-155940965
Ref: IDLE<60>-Footnote-165941031
Ref: IDLE<60>-Footnote-175941097
Ref: IDLE<60>-Footnote-185941163
Ref: IDLE<60>-Footnote-195941229
Ref: IDLE<60>-Footnote-205941295
Ref: IDLE<60>-Footnote-215941361
Ref: IDLE<60>-Footnote-225941427
Ref: IDLE<60>-Footnote-235941493
Ref: IDLE<60>-Footnote-245941559
Ref: IDLE<60>-Footnote-255941625
Node: Documentation<70>5941691
Ref: whatsnew/changelog id7165941812
Ref: 1afc5941812
Ref: Documentation<70>-Footnote-15942883
Ref: Documentation<70>-Footnote-25942948
Ref: Documentation<70>-Footnote-35943013
Ref: Documentation<70>-Footnote-45943078
Ref: Documentation<70>-Footnote-55943143
Ref: Documentation<70>-Footnote-65943208
Node: Tests<75>5943273
Ref: whatsnew/changelog id7175943395
Ref: 1afd5943395
Ref: Tests<75>-Footnote-15943902
Ref: Tests<75>-Footnote-25943967
Ref: Tests<75>-Footnote-35944032
Node: Build<80>5944097
Ref: whatsnew/changelog id7185944213
Ref: 1afe5944213
Ref: Build<80>-Footnote-15944638
Ref: Build<80>-Footnote-25944703
Ref: Build<80>-Footnote-35944768
Node: Windows<71>5944833
Ref: whatsnew/changelog id7195944955
Ref: 1aff5944955
Ref: Windows<71>-Footnote-15946228
Ref: Windows<71>-Footnote-25946293
Ref: Windows<71>-Footnote-35946358
Ref: Windows<71>-Footnote-45946423
Ref: Windows<71>-Footnote-55946488
Ref: Windows<71>-Footnote-65946553
Ref: Windows<71>-Footnote-75946618
Ref: Windows<71>-Footnote-85946683
Ref: Windows<71>-Footnote-95946748
Ref: Windows<71>-Footnote-105946813
Ref: Windows<71>-Footnote-115946879
Ref: Windows<71>-Footnote-125946945
Ref: Windows<71>-Footnote-135947011
Ref: Windows<71>-Footnote-145947077
Node: Tools/Demos<44>5947143
Ref: whatsnew/changelog id7205947247
Ref: 1b005947247
Ref: Tools/Demos<44>-Footnote-15947395
Node: Python 3 5 0 final5947460
Ref: whatsnew/changelog python-3-5-0-final5947609
Ref: 1b015947609
Node: Build<81>5947722
Ref: whatsnew/changelog id7215947786
Ref: 1b025947786
Ref: Build<81>-Footnote-15947962
Node: Python 3 5 0 release candidate 45948027
Ref: whatsnew/changelog python-3-5-0-release-candidate-45948176
Ref: 1b035948176
Node: Library<84>5948341
Ref: whatsnew/changelog id7225948439
Ref: 1b045948439
Ref: Library<84>-Footnote-15948568
Node: Build<82>5948633
Ref: whatsnew/changelog id7235948731
Ref: 1b055948731
Ref: Build<82>-Footnote-15948913
Node: Python 3 5 0 release candidate 35948978
Ref: whatsnew/changelog python-3-5-0-release-candidate-35949141
Ref: 1b065949141
Node: Core and Builtins<86>5949330
Ref: whatsnew/changelog id7245949440
Ref: 1b075949440
Ref: Core and Builtins<86>-Footnote-15949808
Ref: Core and Builtins<86>-Footnote-25949873
Ref: Core and Builtins<86>-Footnote-35949938
Ref: Core and Builtins<86>-Footnote-45950003
Node: Library<85>5950045
Ref: whatsnew/changelog id7255950155
Ref: 1b085950155
Ref: Library<85>-Footnote-15950929
Ref: Library<85>-Footnote-25950994
Ref: Library<85>-Footnote-35951059
Ref: Library<85>-Footnote-45951124
Ref: Library<85>-Footnote-55951189
Node: Python 3 5 0 release candidate 25951254
Ref: whatsnew/changelog python-3-5-0-release-candidate-25951417
Ref: 1b095951417
Node: Core and Builtins<87>5951608
Ref: whatsnew/changelog id7265951718
Ref: 1b0a5951718
Ref: Core and Builtins<87>-Footnote-15952260
Ref: Core and Builtins<87>-Footnote-25952325
Ref: Core and Builtins<87>-Footnote-35952390
Node: Library<86>5952455
Ref: whatsnew/changelog id7275952565
Ref: 1b0b5952565
Ref: Library<86>-Footnote-15952844
Ref: Library<86>-Footnote-25952909
Ref: Library<86>-Footnote-35952974
Node: Python 3 5 0 release candidate 15953039
Ref: whatsnew/changelog python-3-5-0-release-candidate-15953189
Ref: 1b0c5953189
Node: Core and Builtins<88>5953454
Ref: whatsnew/changelog id7285953564
Ref: 1b0d5953564
Ref: Core and Builtins<88>-Footnote-15953744
Node: Library<87>5953809
Ref: whatsnew/changelog id7295953936
Ref: 1b0e5953936
Ref: Library<87>-Footnote-15955514
Ref: Library<87>-Footnote-25955579
Ref: Library<87>-Footnote-35955644
Ref: Library<87>-Footnote-45955709
Ref: Library<87>-Footnote-55955773
Ref: Library<87>-Footnote-65955838
Ref: Library<87>-Footnote-75955903
Ref: Library<87>-Footnote-85955968
Ref: Library<87>-Footnote-95956033
Ref: Library<87>-Footnote-105956098
Ref: Library<87>-Footnote-115956164
Ref: Library<87>-Footnote-125956230
Ref: Library<87>-Footnote-135956296
Ref: Library<87>-Footnote-145956362
Ref: Library<87>-Footnote-155956428
Node: IDLE<61>5956494
Ref: whatsnew/changelog id7305956617
Ref: 1b0f5956617
Ref: IDLE<61>-Footnote-15957366
Ref: IDLE<61>-Footnote-25957431
Ref: IDLE<61>-Footnote-35957496
Ref: IDLE<61>-Footnote-45957561
Node: Documentation<71>5957626
Ref: whatsnew/changelog id7315957747
Ref: 1b105957747
Ref: Documentation<71>-Footnote-15958409
Ref: Documentation<71>-Footnote-25958474
Ref: Documentation<71>-Footnote-35958539
Ref: Documentation<71>-Footnote-45958604
Node: Tests<76>5958669
Ref: whatsnew/changelog id7325958773
Ref: 1b115958773
Ref: Tests<76>-Footnote-15959013
Node: Python 3 5 0 beta 45959078
Ref: whatsnew/changelog python-3-5-0-beta-45959215
Ref: 1b125959215
Node: Core and Builtins<89>5959400
Ref: whatsnew/changelog id7335959497
Ref: 1b135959497
Ref: Core and Builtins<89>-Footnote-15960300
Ref: Core and Builtins<89>-Footnote-25960365
Ref: Core and Builtins<89>-Footnote-35960430
Ref: Core and Builtins<89>-Footnote-45960472
Ref: Core and Builtins<89>-Footnote-55960537
Ref: Core and Builtins<89>-Footnote-65960602
Ref: Core and Builtins<89>-Footnote-75960667
Ref: Core and Builtins<89>-Footnote-85960732
Node: Library<88>5960797
Ref: whatsnew/changelog id7345960912
Ref: 1b145960912
Ref: Library<88>-Footnote-15963183
Ref: Library<88>-Footnote-25963248
Ref: Library<88>-Footnote-35963313
Ref: Library<88>-Footnote-45963378
Ref: Library<88>-Footnote-55963443
Ref: Library<88>-Footnote-65963508
Ref: Library<88>-Footnote-75963573
Ref: Library<88>-Footnote-85963638
Ref: Library<88>-Footnote-95963703
Ref: Library<88>-Footnote-105963768
Ref: Library<88>-Footnote-115963834
Ref: Library<88>-Footnote-125963900
Ref: Library<88>-Footnote-135963966
Ref: Library<88>-Footnote-145964032
Ref: Library<88>-Footnote-155964098
Ref: Library<88>-Footnote-165964164
Ref: Library<88>-Footnote-175964230
Ref: Library<88>-Footnote-185964296
Ref: Library<88>-Footnote-195964362
Node: Build<83>5964428
Ref: whatsnew/changelog id7355964513
Ref: 1b155964513
Ref: Build<83>-Footnote-15964678
Node: Python 3 5 0 beta 35964743
Ref: whatsnew/changelog python-3-5-0-beta-35964867
Ref: 1b165964867
Node: Core and Builtins<90>5965108
Ref: whatsnew/changelog id7365965205
Ref: 1b175965205
Ref: Core and Builtins<90>-Footnote-15966518
Ref: Core and Builtins<90>-Footnote-25966583
Ref: Core and Builtins<90>-Footnote-35966648
Ref: Core and Builtins<90>-Footnote-45966713
Ref: Core and Builtins<90>-Footnote-55966755
Ref: Core and Builtins<90>-Footnote-65966820
Node: Library<89>5966885
Ref: whatsnew/changelog id7375967000
Ref: 1b185967000
Ref: Library<89>-Footnote-15968948
Ref: Library<89>-Footnote-25969013
Ref: Library<89>-Footnote-35969078
Ref: Library<89>-Footnote-45969143
Ref: Library<89>-Footnote-55969208
Ref: Library<89>-Footnote-65969273
Ref: Library<89>-Footnote-75969338
Ref: Library<89>-Footnote-85969403
Ref: Library<89>-Footnote-95969468
Ref: Library<89>-Footnote-105969533
Ref: Library<89>-Footnote-115969599
Ref: Library<89>-Footnote-125969665
Ref: Library<89>-Footnote-135969731
Ref: Library<89>-Footnote-145969797
Ref: Library<89>-Footnote-155969863
Ref: Library<89>-Footnote-165969929
Ref: Library<89>-Footnote-175969995
Ref: Library<89>-Footnote-185970061
Node: Tests<77>5970127
Ref: whatsnew/changelog id7385970238
Ref: 1b195970238
Ref: Tests<77>-Footnote-15970520
Ref: Tests<77>-Footnote-25970585
Node: Documentation<72>5970650
Ref: whatsnew/changelog id7395970759
Ref: 1b1a5970759
Ref: Documentation<72>-Footnote-15971099
Ref: Documentation<72>-Footnote-25971164
Node: Build<84>5971229
Ref: whatsnew/changelog id7405971320
Ref: 1b1b5971320
Ref: Build<84>-Footnote-15971485
Node: Python 3 5 0 beta 25971550
Ref: whatsnew/changelog python-3-5-0-beta-25971674
Ref: 1b1c5971674
Node: Core and Builtins<91>5971839
Ref: whatsnew/changelog id7415971936
Ref: 1b1d5971936
Ref: Core and Builtins<91>-Footnote-15972689
Ref: Core and Builtins<91>-Footnote-25972754
Ref: Core and Builtins<91>-Footnote-35972819
Ref: Core and Builtins<91>-Footnote-45972884
Ref: Core and Builtins<91>-Footnote-55972949
Node: Library<90>5973014
Ref: whatsnew/changelog id7425973111
Ref: 1b1e5973111
Ref: Library<90>-Footnote-15973818
Ref: Library<90>-Footnote-25973883
Ref: Library<90>-Footnote-35973948
Ref: Library<90>-Footnote-45973990
Ref: Library<90>-Footnote-55974054
Ref: Library<90>-Footnote-65974119
Ref: Library<90>-Footnote-75974184
Node: Python 3 5 0 beta 15974249
Ref: whatsnew/changelog python-3-5-0-beta-15974374
Ref: 1b1f5974374
Node: Core and Builtins<92>5974645
Ref: whatsnew/changelog id7435974742
Ref: 1b205974742
Ref: Core and Builtins<92>-Footnote-15976615
Ref: Core and Builtins<92>-Footnote-25976680
Ref: Core and Builtins<92>-Footnote-35976745
Ref: Core and Builtins<92>-Footnote-45976810
Ref: Core and Builtins<92>-Footnote-55976875
Ref: Core and Builtins<92>-Footnote-65976940
Ref: Core and Builtins<92>-Footnote-75977005
Ref: Core and Builtins<92>-Footnote-85977070
Ref: Core and Builtins<92>-Footnote-95977135
Ref: Core and Builtins<92>-Footnote-105977200
Ref: Core and Builtins<92>-Footnote-115977265
Ref: Core and Builtins<92>-Footnote-125977331
Ref: Core and Builtins<92>-Footnote-135977397
Ref: Core and Builtins<92>-Footnote-145977463
Ref: Core and Builtins<92>-Footnote-155977529
Ref: Core and Builtins<92>-Footnote-165977595
Ref: Core and Builtins<92>-Footnote-175977661
Ref: Core and Builtins<92>-Footnote-185977726
Ref: Core and Builtins<92>-Footnote-195977792
Node: Library<91>5977858
Ref: whatsnew/changelog id7445977972
Ref: 1b215977972
Ref: Library<91>-Footnote-15985608
Ref: Library<91>-Footnote-25985673
Ref: Library<91>-Footnote-35985738
Ref: Library<91>-Footnote-45985803
Ref: Library<91>-Footnote-55985868
Ref: Library<91>-Footnote-65985933
Ref: Library<91>-Footnote-75985998
Ref: Library<91>-Footnote-85986063
Ref: Library<91>-Footnote-95986128
Ref: Library<91>-Footnote-105986193
Ref: Library<91>-Footnote-115986258
Ref: Library<91>-Footnote-125986324
Ref: Library<91>-Footnote-135986390
Ref: Library<91>-Footnote-145986456
Ref: Library<91>-Footnote-155986521
Ref: Library<91>-Footnote-165986587
Ref: Library<91>-Footnote-175986653
Ref: Library<91>-Footnote-185986719
Ref: Library<91>-Footnote-195986785
Ref: Library<91>-Footnote-205986851
Ref: Library<91>-Footnote-215986917
Ref: Library<91>-Footnote-225986983
Ref: Library<91>-Footnote-235987049
Ref: Library<91>-Footnote-245987115
Ref: Library<91>-Footnote-255987181
Ref: Library<91>-Footnote-265987246
Ref: Library<91>-Footnote-275987312
Ref: Library<91>-Footnote-285987378
Ref: Library<91>-Footnote-295987444
Ref: Library<91>-Footnote-305987510
Ref: Library<91>-Footnote-315987576
Ref: Library<91>-Footnote-325987642
Ref: Library<91>-Footnote-335987708
Ref: Library<91>-Footnote-345987774
Ref: Library<91>-Footnote-355987840
Ref: Library<91>-Footnote-365987906
Ref: Library<91>-Footnote-375987972
Ref: Library<91>-Footnote-385988038
Ref: Library<91>-Footnote-395988104
Ref: Library<91>-Footnote-405988170
Ref: Library<91>-Footnote-415988236
Ref: Library<91>-Footnote-425988301
Ref: Library<91>-Footnote-435988367
Ref: Library<91>-Footnote-445988433
Ref: Library<91>-Footnote-455988499
Ref: Library<91>-Footnote-465988565
Ref: Library<91>-Footnote-475988631
Ref: Library<91>-Footnote-485988697
Ref: Library<91>-Footnote-495988763
Ref: Library<91>-Footnote-505988829
Ref: Library<91>-Footnote-515988895
Ref: Library<91>-Footnote-525988961
Ref: Library<91>-Footnote-535989027
Ref: Library<91>-Footnote-545989093
Ref: Library<91>-Footnote-555989159
Ref: Library<91>-Footnote-565989225
Node: IDLE<62>5989291
Ref: whatsnew/changelog id7455989393
Ref: 1b225989393
Ref: IDLE<62>-Footnote-15989562
Node: Tests<78>5989627
Ref: whatsnew/changelog id7465989735
Ref: 1b235989735
Ref: Tests<78>-Footnote-15990029
Ref: Tests<78>-Footnote-25990094
Node: Documentation<73>5990158
Ref: whatsnew/changelog id7475990273
Ref: 1b245990273
Ref: Documentation<73>-Footnote-15990680
Ref: Documentation<73>-Footnote-25990745
Ref: Documentation<73>-Footnote-35990810
Node: Tools/Demos<45>5990875
Ref: whatsnew/changelog id7485990972
Ref: 1b255990972
Ref: Tools/Demos<45>-Footnote-15991481
Ref: Tools/Demos<45>-Footnote-25991546
Ref: Tools/Demos<45>-Footnote-35991611
Ref: Tools/Demos<45>-Footnote-45991676
Node: Python 3 5 0 alpha 45991741
Ref: whatsnew/changelog python-3-5-0-alpha-45991867
Ref: 1b265991867
Node: Core and Builtins<93>5992126
Ref: whatsnew/changelog id7495992224
Ref: 1b275992224
Ref: Core and Builtins<93>-Footnote-15993589
Ref: Core and Builtins<93>-Footnote-25993654
Ref: Core and Builtins<93>-Footnote-35993696
Ref: Core and Builtins<93>-Footnote-45993761
Ref: Core and Builtins<93>-Footnote-55993826
Ref: Core and Builtins<93>-Footnote-65993868
Ref: Core and Builtins<93>-Footnote-75993933
Ref: Core and Builtins<93>-Footnote-85993998
Ref: Core and Builtins<93>-Footnote-95994063
Ref: Core and Builtins<93>-Footnote-105994128
Ref: Core and Builtins<93>-Footnote-115994194
Node: Library<92>5994260
Ref: whatsnew/changelog id7505994376
Ref: 1b285994376
Ref: Library<92>-Footnote-16001075
Ref: Library<92>-Footnote-26001140
Ref: Library<92>-Footnote-36001205
Ref: Library<92>-Footnote-46001269
Ref: Library<92>-Footnote-56001334
Ref: Library<92>-Footnote-66001399
Ref: Library<92>-Footnote-76001463
Ref: Library<92>-Footnote-86001528
Ref: Library<92>-Footnote-96001593
Ref: Library<92>-Footnote-106001658
Ref: Library<92>-Footnote-116001724
Ref: Library<92>-Footnote-126001790
Ref: Library<92>-Footnote-136001856
Ref: Library<92>-Footnote-146001922
Ref: Library<92>-Footnote-156001988
Ref: Library<92>-Footnote-166002054
Ref: Library<92>-Footnote-176002120
Ref: Library<92>-Footnote-186002186
Ref: Library<92>-Footnote-196002252
Ref: Library<92>-Footnote-206002318
Ref: Library<92>-Footnote-216002384
Ref: Library<92>-Footnote-226002450
Ref: Library<92>-Footnote-236002516
Ref: Library<92>-Footnote-246002582
Ref: Library<92>-Footnote-256002648
Ref: Library<92>-Footnote-266002714
Ref: Library<92>-Footnote-276002780
Ref: Library<92>-Footnote-286002846
Ref: Library<92>-Footnote-296002912
Ref: Library<92>-Footnote-306002978
Ref: Library<92>-Footnote-316003043
Ref: Library<92>-Footnote-326003109
Ref: Library<92>-Footnote-336003175
Ref: Library<92>-Footnote-346003241
Ref: Library<92>-Footnote-356003307
Ref: Library<92>-Footnote-366003373
Ref: Library<92>-Footnote-376003439
Ref: Library<92>-Footnote-386003505
Ref: Library<92>-Footnote-396003571
Ref: Library<92>-Footnote-406003637
Ref: Library<92>-Footnote-416003703
Ref: Library<92>-Footnote-426003769
Ref: Library<92>-Footnote-436003812
Ref: Library<92>-Footnote-446003878
Ref: Library<92>-Footnote-456003944
Ref: Library<92>-Footnote-466004010
Ref: Library<92>-Footnote-476004076
Ref: Library<92>-Footnote-486004142
Node: Build<85>6004208
Ref: whatsnew/changelog id7516004312
Ref: 1b296004312
Ref: Build<85>-Footnote-16004589
Ref: Build<85>-Footnote-26004654
Node: Tests<79>6004719
Ref: whatsnew/changelog id7526004827
Ref: 1b2a6004827
Ref: Tests<79>-Footnote-16005128
Ref: Tests<79>-Footnote-26005193
Node: Tools/Demos<46>6005258
Ref: whatsnew/changelog id7536005366
Ref: 1b2b6005366
Ref: Tools/Demos<46>-Footnote-16006390
Ref: Tools/Demos<46>-Footnote-26006455
Ref: Tools/Demos<46>-Footnote-36006520
Ref: Tools/Demos<46>-Footnote-46006585
Ref: Tools/Demos<46>-Footnote-56006650
Ref: Tools/Demos<46>-Footnote-66006715
Node: C API<69>6006780
Ref: whatsnew/changelog id7546006870
Ref: 1b2c6006870
Ref: C API<69>-Footnote-16007025
Node: Python 3 5 0 alpha 36007090
Ref: whatsnew/changelog python-3-5-0-alpha-36007217
Ref: 1b2d6007217
Node: Core and Builtins<94>6007456
Ref: whatsnew/changelog id7556007554
Ref: 1b2e6007554
Ref: Core and Builtins<94>-Footnote-16008348
Ref: Core and Builtins<94>-Footnote-26008413
Ref: Core and Builtins<94>-Footnote-36008478
Ref: Core and Builtins<94>-Footnote-46008543
Ref: Core and Builtins<94>-Footnote-56008608
Ref: Core and Builtins<94>-Footnote-66008673
Node: Library<93>6008738
Ref: whatsnew/changelog id7566008854
Ref: 1b2f6008854
Ref: Library<93>-Footnote-16015264
Ref: Library<93>-Footnote-26015329
Ref: Library<93>-Footnote-36015394
Ref: Library<93>-Footnote-46015459
Ref: Library<93>-Footnote-56015524
Ref: Library<93>-Footnote-66015589
Ref: Library<93>-Footnote-76015654
Ref: Library<93>-Footnote-86015719
Ref: Library<93>-Footnote-96015784
Ref: Library<93>-Footnote-106015849
Ref: Library<93>-Footnote-116015915
Ref: Library<93>-Footnote-126015981
Ref: Library<93>-Footnote-136016047
Ref: Library<93>-Footnote-146016113
Ref: Library<93>-Footnote-156016178
Ref: Library<93>-Footnote-166016244
Ref: Library<93>-Footnote-176016310
Ref: Library<93>-Footnote-186016376
Ref: Library<93>-Footnote-196016442
Ref: Library<93>-Footnote-206016508
Ref: Library<93>-Footnote-216016574
Ref: Library<93>-Footnote-226016640
Ref: Library<93>-Footnote-236016706
Ref: Library<93>-Footnote-246016772
Ref: Library<93>-Footnote-256016838
Ref: Library<93>-Footnote-266016904
Ref: Library<93>-Footnote-276016970
Ref: Library<93>-Footnote-286017036
Ref: Library<93>-Footnote-296017102
Ref: Library<93>-Footnote-306017168
Ref: Library<93>-Footnote-316017233
Ref: Library<93>-Footnote-326017299
Ref: Library<93>-Footnote-336017365
Ref: Library<93>-Footnote-346017431
Ref: Library<93>-Footnote-356017496
Ref: Library<93>-Footnote-366017562
Ref: Library<93>-Footnote-376017628
Ref: Library<93>-Footnote-386017694
Ref: Library<93>-Footnote-396017760
Ref: Library<93>-Footnote-406017826
Ref: Library<93>-Footnote-416017892
Ref: Library<93>-Footnote-426017958
Node: Build<86>6018024
Ref: whatsnew/changelog id7576018128
Ref: 1b306018128
Ref: Build<86>-Footnote-16018273
Node: Tests<80>6018338
Ref: whatsnew/changelog id7586018446
Ref: 1b316018446
Ref: Tests<80>-Footnote-16018671
Ref: Tests<80>-Footnote-26018736
Node: Tools/Demos<47>6018801
Ref: whatsnew/changelog id7596018891
Ref: 1b326018891
Ref: Tools/Demos<47>-Footnote-16019160
Node: Python 3 5 0 alpha 26019225
Ref: whatsnew/changelog python-3-5-0-alpha-26019352
Ref: 1b336019352
Node: Core and Builtins<95>6019583
Ref: whatsnew/changelog id7606019681
Ref: 1b346019681
Ref: Core and Builtins<95>-Footnote-16019979
Node: Library<94>6020044
Ref: whatsnew/changelog id7616020160
Ref: 1b356020160
Ref: Library<94>-Footnote-16024453
Ref: Library<94>-Footnote-26024518
Ref: Library<94>-Footnote-36024560
Ref: Library<94>-Footnote-46024625
Ref: Library<94>-Footnote-56024690
Ref: Library<94>-Footnote-66024755
Ref: Library<94>-Footnote-76024820
Ref: Library<94>-Footnote-86024885
Ref: Library<94>-Footnote-96024950
Ref: Library<94>-Footnote-106025014
Ref: Library<94>-Footnote-116025080
Ref: Library<94>-Footnote-126025146
Ref: Library<94>-Footnote-136025212
Ref: Library<94>-Footnote-146025278
Ref: Library<94>-Footnote-156025344
Ref: Library<94>-Footnote-166025410
Ref: Library<94>-Footnote-176025475
Ref: Library<94>-Footnote-186025542
Ref: Library<94>-Footnote-196025607
Ref: Library<94>-Footnote-206025673
Ref: Library<94>-Footnote-216025738
Ref: Library<94>-Footnote-226025804
Ref: Library<94>-Footnote-236025870
Ref: Library<94>-Footnote-246025936
Ref: Library<94>-Footnote-256026002
Ref: Library<94>-Footnote-266026068
Ref: Library<94>-Footnote-276026134
Ref: Library<94>-Footnote-286026200
Ref: Library<94>-Footnote-296026266
Ref: Library<94>-Footnote-306026332
Ref: Library<94>-Footnote-316026398
Ref: Library<94>-Footnote-326026464
Ref: Library<94>-Footnote-336026530
Ref: Library<94>-Footnote-346026596
Ref: Library<94>-Footnote-356026662
Ref: Library<94>-Footnote-366026728
Ref: Library<94>-Footnote-376026794
Node: Build<87>6026860
Ref: whatsnew/changelog id7626026964
Ref: 1b366026964
Ref: Build<87>-Footnote-16027231
Ref: Build<87>-Footnote-26027296
Node: C API<70>6027361
Ref: whatsnew/changelog id7636027465
Ref: 1b376027465
Ref: C API<70>-Footnote-16027647
Node: Windows<72>6027712
Ref: whatsnew/changelog id7646027798
Ref: 1b386027798
Ref: Windows<72>-Footnote-16028095
Ref: Windows<72>-Footnote-26028160
Ref: Windows<72>-Footnote-36028202
Node: Python 3 5 0 alpha 16028267
Ref: whatsnew/changelog python-3-5-0-alpha-16028365
Ref: 1b396028365
Node: Core and Builtins<96>6028702
Ref: whatsnew/changelog id7656028800
Ref: 1b3a6028800
Ref: Core and Builtins<96>-Footnote-16038643
Ref: Core and Builtins<96>-Footnote-26038708
Ref: Core and Builtins<96>-Footnote-36038773
Ref: Core and Builtins<96>-Footnote-46038838
Ref: Core and Builtins<96>-Footnote-56038903
Ref: Core and Builtins<96>-Footnote-66038968
Ref: Core and Builtins<96>-Footnote-76039033
Ref: Core and Builtins<96>-Footnote-86039098
Ref: Core and Builtins<96>-Footnote-96039163
Ref: Core and Builtins<96>-Footnote-106039228
Ref: Core and Builtins<96>-Footnote-116039294
Ref: Core and Builtins<96>-Footnote-126039360
Ref: Core and Builtins<96>-Footnote-136039426
Ref: Core and Builtins<96>-Footnote-146039492
Ref: Core and Builtins<96>-Footnote-156039558
Ref: Core and Builtins<96>-Footnote-166039624
Ref: Core and Builtins<96>-Footnote-176039690
Ref: Core and Builtins<96>-Footnote-186039756
Ref: Core and Builtins<96>-Footnote-196039822
Ref: Core and Builtins<96>-Footnote-206039888
Ref: Core and Builtins<96>-Footnote-216039954
Ref: Core and Builtins<96>-Footnote-226040020
Ref: Core and Builtins<96>-Footnote-236040086
Ref: Core and Builtins<96>-Footnote-246040152
Ref: Core and Builtins<96>-Footnote-256040218
Ref: Core and Builtins<96>-Footnote-266040284
Ref: Core and Builtins<96>-Footnote-276040350
Ref: Core and Builtins<96>-Footnote-286040416
Ref: Core and Builtins<96>-Footnote-296040482
Ref: Core and Builtins<96>-Footnote-306040548
Ref: Core and Builtins<96>-Footnote-316040614
Ref: Core and Builtins<96>-Footnote-326040680
Ref: Core and Builtins<96>-Footnote-336040746
Ref: Core and Builtins<96>-Footnote-346040814
Ref: Core and Builtins<96>-Footnote-356040880
Ref: Core and Builtins<96>-Footnote-366040946
Ref: Core and Builtins<96>-Footnote-376041012
Ref: Core and Builtins<96>-Footnote-386041078
Ref: Core and Builtins<96>-Footnote-396041144
Ref: Core and Builtins<96>-Footnote-406041210
Ref: Core and Builtins<96>-Footnote-416041276
Ref: Core and Builtins<96>-Footnote-426041342
Ref: Core and Builtins<96>-Footnote-436041408
Ref: Core and Builtins<96>-Footnote-446041474
Ref: Core and Builtins<96>-Footnote-456041540
Ref: Core and Builtins<96>-Footnote-466041606
Ref: Core and Builtins<96>-Footnote-476041672
Ref: Core and Builtins<96>-Footnote-486041738
Ref: Core and Builtins<96>-Footnote-496041804
Ref: Core and Builtins<96>-Footnote-506041870
Ref: Core and Builtins<96>-Footnote-516041936
Ref: Core and Builtins<96>-Footnote-526042002
Ref: Core and Builtins<96>-Footnote-536042068
Ref: Core and Builtins<96>-Footnote-546042134
Ref: Core and Builtins<96>-Footnote-556042200
Ref: Core and Builtins<96>-Footnote-566042266
Ref: Core and Builtins<96>-Footnote-576042332
Ref: Core and Builtins<96>-Footnote-586042398
Ref: Core and Builtins<96>-Footnote-596042464
Ref: Core and Builtins<96>-Footnote-606042530
Ref: Core and Builtins<96>-Footnote-616042596
Ref: Core and Builtins<96>-Footnote-626042662
Ref: Core and Builtins<96>-Footnote-636042728
Ref: Core and Builtins<96>-Footnote-646042794
Ref: Core and Builtins<96>-Footnote-656042860
Ref: Core and Builtins<96>-Footnote-666042926
Ref: Core and Builtins<96>-Footnote-676042991
Ref: Core and Builtins<96>-Footnote-686043057
Ref: Core and Builtins<96>-Footnote-696043123
Ref: Core and Builtins<96>-Footnote-706043189
Ref: Core and Builtins<96>-Footnote-716043255
Ref: Core and Builtins<96>-Footnote-726043321
Ref: Core and Builtins<96>-Footnote-736043386
Node: Library<95>6043452
Ref: whatsnew/changelog id7666043567
Ref: 1b3b6043567
Ref: Library<95>-Footnote-16095870
Ref: Library<95>-Footnote-26095935
Ref: Library<95>-Footnote-36096000
Ref: Library<95>-Footnote-46096065
Ref: Library<95>-Footnote-56096130
Ref: Library<95>-Footnote-66096195
Ref: Library<95>-Footnote-76096260
Ref: Library<95>-Footnote-86096325
Ref: Library<95>-Footnote-96096390
Ref: Library<95>-Footnote-106096455
Ref: Library<95>-Footnote-116096521
Ref: Library<95>-Footnote-126096587
Ref: Library<95>-Footnote-136096653
Ref: Library<95>-Footnote-146096719
Ref: Library<95>-Footnote-156096785
Ref: Library<95>-Footnote-166096851
Ref: Library<95>-Footnote-176096917
Ref: Library<95>-Footnote-186096983
Ref: Library<95>-Footnote-196097049
Ref: Library<95>-Footnote-206097115
Ref: Library<95>-Footnote-216097181
Ref: Library<95>-Footnote-226097247
Ref: Library<95>-Footnote-236097313
Ref: Library<95>-Footnote-246097379
Ref: Library<95>-Footnote-256097445
Ref: Library<95>-Footnote-266097511
Ref: Library<95>-Footnote-276097577
Ref: Library<95>-Footnote-286097643
Ref: Library<95>-Footnote-296097709
Ref: Library<95>-Footnote-306097775
Ref: Library<95>-Footnote-316097841
Ref: Library<95>-Footnote-326097907
Ref: Library<95>-Footnote-336097973
Ref: Library<95>-Footnote-346098039
Ref: Library<95>-Footnote-356098105
Ref: Library<95>-Footnote-366098171
Ref: Library<95>-Footnote-376098237
Ref: Library<95>-Footnote-386098303
Ref: Library<95>-Footnote-396098369
Ref: Library<95>-Footnote-406098435
Ref: Library<95>-Footnote-416098501
Ref: Library<95>-Footnote-426098567
Ref: Library<95>-Footnote-436098633
Ref: Library<95>-Footnote-446098699
Ref: Library<95>-Footnote-456098765
Ref: Library<95>-Footnote-466098831
Ref: Library<95>-Footnote-476098897
Ref: Library<95>-Footnote-486098963
Ref: Library<95>-Footnote-496099029
Ref: Library<95>-Footnote-506099095
Ref: Library<95>-Footnote-516099161
Ref: Library<95>-Footnote-526099227
Ref: Library<95>-Footnote-536099293
Ref: Library<95>-Footnote-546099359
Ref: Library<95>-Footnote-556099425
Ref: Library<95>-Footnote-566099493
Ref: Library<95>-Footnote-576099559
Ref: Library<95>-Footnote-586099625
Ref: Library<95>-Footnote-596099691
Ref: Library<95>-Footnote-606099757
Ref: Library<95>-Footnote-616099823
Ref: Library<95>-Footnote-626099879
Ref: Library<95>-Footnote-636099945
Ref: Library<95>-Footnote-646100011
Ref: Library<95>-Footnote-656100077
Ref: Library<95>-Footnote-666100143
Ref: Library<95>-Footnote-676100209
Ref: Library<95>-Footnote-686100275
Ref: Library<95>-Footnote-696100341
Ref: Library<95>-Footnote-706100407
Ref: Library<95>-Footnote-716100473
Ref: Library<95>-Footnote-726100539
Ref: Library<95>-Footnote-736100605
Ref: Library<95>-Footnote-746100671
Ref: Library<95>-Footnote-756100737
Ref: Library<95>-Footnote-766100803
Ref: Library<95>-Footnote-776100869
Ref: Library<95>-Footnote-786100935
Ref: Library<95>-Footnote-796101001
Ref: Library<95>-Footnote-806101067
Ref: Library<95>-Footnote-816101133
Ref: Library<95>-Footnote-826101199
Ref: Library<95>-Footnote-836101265
Ref: Library<95>-Footnote-846101331
Ref: Library<95>-Footnote-856101397
Ref: Library<95>-Footnote-866101463
Ref: Library<95>-Footnote-876101529
Ref: Library<95>-Footnote-886101595
Ref: Library<95>-Footnote-896101661
Ref: Library<95>-Footnote-906101727
Ref: Library<95>-Footnote-916101793
Ref: Library<95>-Footnote-926101859
Ref: Library<95>-Footnote-936101925
Ref: Library<95>-Footnote-946101991
Ref: Library<95>-Footnote-956102057
Ref: Library<95>-Footnote-966102123
Ref: Library<95>-Footnote-976102188
Ref: Library<95>-Footnote-986102254
Ref: Library<95>-Footnote-996102320
Ref: Library<95>-Footnote-1006102386
Ref: Library<95>-Footnote-1016102452
Ref: Library<95>-Footnote-1026102519
Ref: Library<95>-Footnote-1036102586
Ref: Library<95>-Footnote-1046102653
Ref: Library<95>-Footnote-1056102720
Ref: Library<95>-Footnote-1066102787
Ref: Library<95>-Footnote-1076102854
Ref: Library<95>-Footnote-1086102920
Ref: Library<95>-Footnote-1096102986
Ref: Library<95>-Footnote-1106103053
Ref: Library<95>-Footnote-1116103120
Ref: Library<95>-Footnote-1126103187
Ref: Library<95>-Footnote-1136103254
Ref: Library<95>-Footnote-1146103321
Ref: Library<95>-Footnote-1156103388
Ref: Library<95>-Footnote-1166103455
Ref: Library<95>-Footnote-1176103522
Ref: Library<95>-Footnote-1186103589
Ref: Library<95>-Footnote-1196103656
Ref: Library<95>-Footnote-1206103723
Ref: Library<95>-Footnote-1216103790
Ref: Library<95>-Footnote-1226103859
Ref: Library<95>-Footnote-1236103926
Ref: Library<95>-Footnote-1246103993
Ref: Library<95>-Footnote-1256104060
Ref: Library<95>-Footnote-1266104127
Ref: Library<95>-Footnote-1276104194
Ref: Library<95>-Footnote-1286104261
Ref: Library<95>-Footnote-1296104328
Ref: Library<95>-Footnote-1306104395
Ref: Library<95>-Footnote-1316104462
Ref: Library<95>-Footnote-1326104529
Ref: Library<95>-Footnote-1336104596
Ref: Library<95>-Footnote-1346104663
Ref: Library<95>-Footnote-1356104730
Ref: Library<95>-Footnote-1366104797
Ref: Library<95>-Footnote-1376104864
Ref: Library<95>-Footnote-1386104931
Ref: Library<95>-Footnote-1396104998
Ref: Library<95>-Footnote-1406105065
Ref: Library<95>-Footnote-1416105132
Ref: Library<95>-Footnote-1426105199
Ref: Library<95>-Footnote-1436105265
Ref: Library<95>-Footnote-1446105331
Ref: Library<95>-Footnote-1456105398
Ref: Library<95>-Footnote-1466105465
Ref: Library<95>-Footnote-1476105532
Ref: Library<95>-Footnote-1486105599
Ref: Library<95>-Footnote-1496105666
Ref: Library<95>-Footnote-1506105733
Ref: Library<95>-Footnote-1516105800
Ref: Library<95>-Footnote-1526105867
Ref: Library<95>-Footnote-1536105934
Ref: Library<95>-Footnote-1546106001
Ref: Library<95>-Footnote-1556106068
Ref: Library<95>-Footnote-1566106135
Ref: Library<95>-Footnote-1576106202
Ref: Library<95>-Footnote-1586106268
Ref: Library<95>-Footnote-1596106335
Ref: Library<95>-Footnote-1606106402
Ref: Library<95>-Footnote-1616106469
Ref: Library<95>-Footnote-1626106536
Ref: Library<95>-Footnote-1636106603
Ref: Library<95>-Footnote-1646106670
Ref: Library<95>-Footnote-1656106737
Ref: Library<95>-Footnote-1666106804
Ref: Library<95>-Footnote-1676106871
Ref: Library<95>-Footnote-1686106938
Ref: Library<95>-Footnote-1696107005
Ref: Library<95>-Footnote-1706107072
Ref: Library<95>-Footnote-1716107139
Ref: Library<95>-Footnote-1726107206
Ref: Library<95>-Footnote-1736107273
Ref: Library<95>-Footnote-1746107340
Ref: Library<95>-Footnote-1756107407
Ref: Library<95>-Footnote-1766107474
Ref: Library<95>-Footnote-1776107541
Ref: Library<95>-Footnote-1786107608
Ref: Library<95>-Footnote-1796107675
Ref: Library<95>-Footnote-1806107742
Ref: Library<95>-Footnote-1816107809
Ref: Library<95>-Footnote-1826107876
Ref: Library<95>-Footnote-1836107943
Ref: Library<95>-Footnote-1846108010
Ref: Library<95>-Footnote-1856108077
Ref: Library<95>-Footnote-1866108144
Ref: Library<95>-Footnote-1876108211
Ref: Library<95>-Footnote-1886108278
Ref: Library<95>-Footnote-1896108344
Ref: Library<95>-Footnote-1906108411
Ref: Library<95>-Footnote-1916108478
Ref: Library<95>-Footnote-1926108545
Ref: Library<95>-Footnote-1936108612
Ref: Library<95>-Footnote-1946108679
Ref: Library<95>-Footnote-1956108746
Ref: Library<95>-Footnote-1966108813
Ref: Library<95>-Footnote-1976108879
Ref: Library<95>-Footnote-1986108946
Ref: Library<95>-Footnote-1996109013
Ref: Library<95>-Footnote-2006109080
Ref: Library<95>-Footnote-2016109147
Ref: Library<95>-Footnote-2026109214
Ref: Library<95>-Footnote-2036109281
Ref: Library<95>-Footnote-2046109347
Ref: Library<95>-Footnote-2056109414
Ref: Library<95>-Footnote-2066109481
Ref: Library<95>-Footnote-2076109548
Ref: Library<95>-Footnote-2086109615
Ref: Library<95>-Footnote-2096109682
Ref: Library<95>-Footnote-2106109749
Ref: Library<95>-Footnote-2116109816
Ref: Library<95>-Footnote-2126109883
Ref: Library<95>-Footnote-2136109950
Ref: Library<95>-Footnote-2146110017
Ref: Library<95>-Footnote-2156110084
Ref: Library<95>-Footnote-2166110151
Ref: Library<95>-Footnote-2176110218
Ref: Library<95>-Footnote-2186110285
Ref: Library<95>-Footnote-2196110352
Ref: Library<95>-Footnote-2206110419
Ref: Library<95>-Footnote-2216110486
Ref: Library<95>-Footnote-2226110553
Ref: Library<95>-Footnote-2236110620
Ref: Library<95>-Footnote-2246110687
Ref: Library<95>-Footnote-2256110753
Ref: Library<95>-Footnote-2266110819
Ref: Library<95>-Footnote-2276110886
Ref: Library<95>-Footnote-2286110953
Ref: Library<95>-Footnote-2296111020
Ref: Library<95>-Footnote-2306111087
Ref: Library<95>-Footnote-2316111154
Ref: Library<95>-Footnote-2326111221
Ref: Library<95>-Footnote-2336111288
Ref: Library<95>-Footnote-2346111355
Ref: Library<95>-Footnote-2356111422
Ref: Library<95>-Footnote-2366111489
Ref: Library<95>-Footnote-2376111556
Ref: Library<95>-Footnote-2386111623
Ref: Library<95>-Footnote-2396111690
Ref: Library<95>-Footnote-2406111757
Ref: Library<95>-Footnote-2416111824
Ref: Library<95>-Footnote-2426111891
Ref: Library<95>-Footnote-2436111958
Ref: Library<95>-Footnote-2446112025
Ref: Library<95>-Footnote-2456112092
Ref: Library<95>-Footnote-2466112158
Ref: Library<95>-Footnote-2476112225
Ref: Library<95>-Footnote-2486112292
Ref: Library<95>-Footnote-2496112359
Ref: Library<95>-Footnote-2506112426
Ref: Library<95>-Footnote-2516112493
Ref: Library<95>-Footnote-2526112560
Ref: Library<95>-Footnote-2536112627
Ref: Library<95>-Footnote-2546112694
Ref: Library<95>-Footnote-2556112761
Ref: Library<95>-Footnote-2566112828
Ref: Library<95>-Footnote-2576112895
Ref: Library<95>-Footnote-2586112962
Ref: Library<95>-Footnote-2596113029
Ref: Library<95>-Footnote-2606113096
Ref: Library<95>-Footnote-2616113163
Ref: Library<95>-Footnote-2626113230
Ref: Library<95>-Footnote-2636113297
Ref: Library<95>-Footnote-2646113364
Ref: Library<95>-Footnote-2656113431
Ref: Library<95>-Footnote-2666113498
Ref: Library<95>-Footnote-2676113565
Ref: Library<95>-Footnote-2686113632
Ref: Library<95>-Footnote-2696113699
Ref: Library<95>-Footnote-2706113766
Ref: Library<95>-Footnote-2716113833
Ref: Library<95>-Footnote-2726113900
Ref: Library<95>-Footnote-2736113967
Ref: Library<95>-Footnote-2746114034
Ref: Library<95>-Footnote-2756114101
Ref: Library<95>-Footnote-2766114168
Ref: Library<95>-Footnote-2776114235
Ref: Library<95>-Footnote-2786114301
Ref: Library<95>-Footnote-2796114368
Ref: Library<95>-Footnote-2806114435
Ref: Library<95>-Footnote-2816114502
Ref: Library<95>-Footnote-2826114569
Ref: Library<95>-Footnote-2836114636
Ref: Library<95>-Footnote-2846114703
Ref: Library<95>-Footnote-2856114770
Ref: Library<95>-Footnote-2866114837
Ref: Library<95>-Footnote-2876114904
Ref: Library<95>-Footnote-2886114971
Ref: Library<95>-Footnote-2896115038
Ref: Library<95>-Footnote-2906115082
Ref: Library<95>-Footnote-2916115149
Ref: Library<95>-Footnote-2926115216
Ref: Library<95>-Footnote-2936115283
Ref: Library<95>-Footnote-2946115350
Ref: Library<95>-Footnote-2956115417
Ref: Library<95>-Footnote-2966115484
Ref: Library<95>-Footnote-2976115551
Ref: Library<95>-Footnote-2986115618
Ref: Library<95>-Footnote-2996115685
Ref: Library<95>-Footnote-3006115752
Ref: Library<95>-Footnote-3016115819
Ref: Library<95>-Footnote-3026115886
Ref: Library<95>-Footnote-3036115953
Ref: Library<95>-Footnote-3046116020
Ref: Library<95>-Footnote-3056116087
Ref: Library<95>-Footnote-3066116154
Ref: Library<95>-Footnote-3076116221
Ref: Library<95>-Footnote-3086116288
Ref: Library<95>-Footnote-3096116355
Ref: Library<95>-Footnote-3106116422
Ref: Library<95>-Footnote-3116116489
Ref: Library<95>-Footnote-3126116556
Ref: Library<95>-Footnote-3136116623
Ref: Library<95>-Footnote-3146116690
Ref: Library<95>-Footnote-3156116757
Ref: Library<95>-Footnote-3166116823
Ref: Library<95>-Footnote-3176116890
Ref: Library<95>-Footnote-3186116957
Ref: Library<95>-Footnote-3196117024
Ref: Library<95>-Footnote-3206117091
Ref: Library<95>-Footnote-3216117158
Ref: Library<95>-Footnote-3226117225
Ref: Library<95>-Footnote-3236117292
Ref: Library<95>-Footnote-3246117359
Ref: Library<95>-Footnote-3256117426
Ref: Library<95>-Footnote-3266117493
Ref: Library<95>-Footnote-3276117560
Ref: Library<95>-Footnote-3286117627
Ref: Library<95>-Footnote-3296117694
Ref: Library<95>-Footnote-3306117761
Ref: Library<95>-Footnote-3316117828
Ref: Library<95>-Footnote-3326117895
Ref: Library<95>-Footnote-3336117962
Ref: Library<95>-Footnote-3346118029
Ref: Library<95>-Footnote-3356118096
Ref: Library<95>-Footnote-3366118162
Ref: Library<95>-Footnote-3376118229
Ref: Library<95>-Footnote-3386118296
Ref: Library<95>-Footnote-3396118353
Ref: Library<95>-Footnote-3406118420
Ref: Library<95>-Footnote-3416118487
Ref: Library<95>-Footnote-3426118554
Ref: Library<95>-Footnote-3436118621
Ref: Library<95>-Footnote-3446118688
Ref: Library<95>-Footnote-3456118755
Ref: Library<95>-Footnote-3466118822
Ref: Library<95>-Footnote-3476118889
Ref: Library<95>-Footnote-3486118956
Ref: Library<95>-Footnote-3496119023
Ref: Library<95>-Footnote-3506119090
Ref: Library<95>-Footnote-3516119157
Ref: Library<95>-Footnote-3526119224
Ref: Library<95>-Footnote-3536119291
Ref: Library<95>-Footnote-3546119358
Ref: Library<95>-Footnote-3556119425
Ref: Library<95>-Footnote-3566119492
Ref: Library<95>-Footnote-3576119559
Ref: Library<95>-Footnote-3586119626
Ref: Library<95>-Footnote-3596119693
Ref: Library<95>-Footnote-3606119760
Ref: Library<95>-Footnote-3616119827
Ref: Library<95>-Footnote-3626119894
Ref: Library<95>-Footnote-3636119961
Ref: Library<95>-Footnote-3646120028
Ref: Library<95>-Footnote-3656120095
Ref: Library<95>-Footnote-3666120162
Ref: Library<95>-Footnote-3676120229
Ref: Library<95>-Footnote-3686120296
Ref: Library<95>-Footnote-3696120363
Ref: Library<95>-Footnote-3706120430
Ref: Library<95>-Footnote-3716120497
Ref: Library<95>-Footnote-3726120564
Ref: Library<95>-Footnote-3736120630
Ref: Library<95>-Footnote-3746120697
Ref: Library<95>-Footnote-3756120764
Ref: Library<95>-Footnote-3766120831
Ref: Library<95>-Footnote-3776120898
Ref: Library<95>-Footnote-3786120965
Ref: Library<95>-Footnote-3796121032
Ref: Library<95>-Footnote-3806121099
Ref: Library<95>-Footnote-3816121166
Ref: Library<95>-Footnote-3826121233
Ref: Library<95>-Footnote-3836121300
Ref: Library<95>-Footnote-3846121367
Ref: Library<95>-Footnote-3856121434
Ref: Library<95>-Footnote-3866121500
Ref: Library<95>-Footnote-3876121567
Ref: Library<95>-Footnote-3886121634
Ref: Library<95>-Footnote-3896121701
Ref: Library<95>-Footnote-3906121768
Ref: Library<95>-Footnote-3916121833
Ref: Library<95>-Footnote-3926121900
Ref: Library<95>-Footnote-3936121967
Ref: Library<95>-Footnote-3946122034
Ref: Library<95>-Footnote-3956122101
Ref: Library<95>-Footnote-3966122168
Ref: Library<95>-Footnote-3976122235
Ref: Library<95>-Footnote-3986122302
Node: IDLE<63>6122369
Ref: whatsnew/changelog id7676122472
Ref: 1b3c6122472
Ref: IDLE<63>-Footnote-16125954
Ref: IDLE<63>-Footnote-26126019
Ref: IDLE<63>-Footnote-36126084
Ref: IDLE<63>-Footnote-46126148
Ref: IDLE<63>-Footnote-56126213
Ref: IDLE<63>-Footnote-66126277
Ref: IDLE<63>-Footnote-76126342
Ref: IDLE<63>-Footnote-86126407
Ref: IDLE<63>-Footnote-96126472
Ref: IDLE<63>-Footnote-106126537
Ref: IDLE<63>-Footnote-116126603
Ref: IDLE<63>-Footnote-126126669
Ref: IDLE<63>-Footnote-136126735
Ref: IDLE<63>-Footnote-146126801
Ref: IDLE<63>-Footnote-156126867
Ref: IDLE<63>-Footnote-166126933
Ref: IDLE<63>-Footnote-176126999
Ref: IDLE<63>-Footnote-186127065
Ref: IDLE<63>-Footnote-196127131
Ref: IDLE<63>-Footnote-206127197
Ref: IDLE<63>-Footnote-216127263
Ref: IDLE<63>-Footnote-226127329
Ref: IDLE<63>-Footnote-236127395
Ref: IDLE<63>-Footnote-246127438
Ref: IDLE<63>-Footnote-256127504
Ref: IDLE<63>-Footnote-266127570
Node: Build<88>6127636
Ref: whatsnew/changelog id7686127737
Ref: 1b3d6127737
Ref: Build<88>-Footnote-16131145
Ref: Build<88>-Footnote-26131210
Ref: Build<88>-Footnote-36131275
Ref: Build<88>-Footnote-46131340
Ref: Build<88>-Footnote-56131405
Ref: Build<88>-Footnote-66131470
Ref: Build<88>-Footnote-76131535
Ref: Build<88>-Footnote-86131600
Ref: Build<88>-Footnote-96131665
Ref: Build<88>-Footnote-106131730
Ref: Build<88>-Footnote-116131796
Ref: Build<88>-Footnote-126131862
Ref: Build<88>-Footnote-136131928
Ref: Build<88>-Footnote-146131994
Ref: Build<88>-Footnote-156132060
Ref: Build<88>-Footnote-166132126
Ref: Build<88>-Footnote-176132192
Ref: Build<88>-Footnote-186132258
Ref: Build<88>-Footnote-196132324
Ref: Build<88>-Footnote-206132390
Ref: Build<88>-Footnote-216132456
Ref: Build<88>-Footnote-226132522
Ref: Build<88>-Footnote-236132588
Ref: Build<88>-Footnote-246132654
Ref: Build<88>-Footnote-256132720
Ref: Build<88>-Footnote-266132786
Node: C API<71>6132852
Ref: whatsnew/changelog id7696132962
Ref: 1b3e6132962
Ref: C API<71>-Footnote-16134327
Ref: C API<71>-Footnote-26134392
Ref: C API<71>-Footnote-36134457
Ref: C API<71>-Footnote-46134522
Ref: C API<71>-Footnote-56134587
Ref: C API<71>-Footnote-66134652
Ref: C API<71>-Footnote-76134717
Node: Documentation<74>6134782
Ref: whatsnew/changelog id7706134892
Ref: 1b3f6134892
Ref: Documentation<74>-Footnote-16136699
Ref: Documentation<74>-Footnote-26136764
Ref: Documentation<74>-Footnote-36136829
Ref: Documentation<74>-Footnote-46136894
Ref: Documentation<74>-Footnote-56136959
Ref: Documentation<74>-Footnote-66137023
Ref: Documentation<74>-Footnote-76137088
Ref: Documentation<74>-Footnote-86137153
Ref: Documentation<74>-Footnote-96137218
Ref: Documentation<74>-Footnote-106137283
Ref: Documentation<74>-Footnote-116137349
Node: Tests<81>6137415
Ref: whatsnew/changelog id7716137531
Ref: 1b406137531
Ref: Tests<81>-Footnote-16141722
Ref: Tests<81>-Footnote-26141787
Ref: Tests<81>-Footnote-36141852
Ref: Tests<81>-Footnote-46141917
Ref: Tests<81>-Footnote-56141982
Ref: Tests<81>-Footnote-66142047
Ref: Tests<81>-Footnote-76142112
Ref: Tests<81>-Footnote-86142177
Ref: Tests<81>-Footnote-96142242
Ref: Tests<81>-Footnote-106142307
Ref: Tests<81>-Footnote-116142373
Ref: Tests<81>-Footnote-126142439
Ref: Tests<81>-Footnote-136142505
Ref: Tests<81>-Footnote-146142571
Ref: Tests<81>-Footnote-156142636
Ref: Tests<81>-Footnote-166142702
Ref: Tests<81>-Footnote-176142768
Ref: Tests<81>-Footnote-186142834
Ref: Tests<81>-Footnote-196142900
Ref: Tests<81>-Footnote-206142966
Ref: Tests<81>-Footnote-216143032
Ref: Tests<81>-Footnote-226143098
Ref: Tests<81>-Footnote-236143164
Ref: Tests<81>-Footnote-246143230
Ref: Tests<81>-Footnote-256143296
Ref: Tests<81>-Footnote-266143362
Ref: Tests<81>-Footnote-276143428
Ref: Tests<81>-Footnote-286143494
Ref: Tests<81>-Footnote-296143560
Ref: Tests<81>-Footnote-306143626
Ref: Tests<81>-Footnote-316143692
Ref: Tests<81>-Footnote-326143758
Ref: Tests<81>-Footnote-336143824
Ref: Tests<81>-Footnote-346143890
Ref: Tests<81>-Footnote-356143956
Ref: Tests<81>-Footnote-366144022
Ref: Tests<81>-Footnote-376144088
Node: Tools/Demos<48>6144154
Ref: whatsnew/changelog id7726144264
Ref: 1b416144264
Ref: Tools/Demos<48>-Footnote-16145926
Ref: Tools/Demos<48>-Footnote-26145991
Ref: Tools/Demos<48>-Footnote-36146056
Ref: Tools/Demos<48>-Footnote-46146121
Ref: Tools/Demos<48>-Footnote-56146186
Ref: Tools/Demos<48>-Footnote-66146251
Ref: Tools/Demos<48>-Footnote-76146316
Ref: Tools/Demos<48>-Footnote-86146381
Ref: Tools/Demos<48>-Footnote-96146446
Ref: Tools/Demos<48>-Footnote-106146511
Ref: Tools/Demos<48>-Footnote-116146554
Ref: Tools/Demos<48>-Footnote-126146620
Ref: Tools/Demos<48>-Footnote-136146686
Node: Windows<73>6146752
Ref: whatsnew/changelog id7736146844
Ref: 1b426146844
Ref: Windows<73>-Footnote-16148051
Ref: Windows<73>-Footnote-26148116
Ref: Windows<73>-Footnote-36148181
Ref: Windows<73>-Footnote-46148246
Ref: Windows<73>-Footnote-56148311
Ref: Windows<73>-Footnote-66148376
Ref: Windows<73>-Footnote-76148441
Node: Python チュートリアル6148506
Ref: tutorial/index doc6148649
Ref: 1b436148649
Ref: tutorial/index the-python-tutorial6148649
Ref: 1b446148649
Ref: tutorial/index tutorial-index6148649
Ref: 1b456148649
Node: やる気を高めよう6152143
Ref: tutorial/appetite doc6152275
Ref: 1b496152275
Ref: tutorial/appetite tut-intro6152275
Ref: 1b4a6152275
Ref: tutorial/appetite whetting-your-appetite6152275
Ref: 1b4b6152275
Node: Python インタプリタを使う6158524
Ref: tutorial/interpreter doc6158700
Ref: 1b4c6158700
Ref: tutorial/interpreter tut-using6158700
Ref: 1b4d6158700
Ref: tutorial/interpreter using-the-python-interpreter6158700
Ref: 1b4e6158700
Node: インタプリタを起動する6158856
Ref: tutorial/interpreter invoking-the-interpreter6159002
Ref: 1b4f6159002
Ref: tutorial/interpreter tut-invoking6159002
Ref: 1b506159002
Ref: インタプリタを起動する-Footnote-16163138
Ref: インタプリタを起動する-Footnote-26163410
Node: 引数の受け渡し6163471
Ref: tutorial/interpreter argument-passing6163586
Ref: 1b546163586
Ref: tutorial/interpreter tut-argpassing6163586
Ref: 1b556163586
Node: 対話モード6164790
Ref: tutorial/interpreter interactive-mode6164905
Ref: 1b566164905
Ref: tutorial/interpreter tut-interactive6164905
Ref: f936164905
Node: インタプリタとその環境6166340
Ref: tutorial/interpreter the-interpreter-and-its-environment6166486
Ref: 1b576166486
Ref: tutorial/interpreter tut-interp6166486
Ref: 1b586166486
Node: ソースコードの文字コード6166607
Ref: tutorial/interpreter source-code-encoding6166713
Ref: 1b596166713
Ref: tutorial/interpreter tut-source-encoding6166713
Ref: 1b5a6166713
Node: 形式ばらない Python の紹介6168426
Ref: tutorial/introduction doc6168614
Ref: 1b5c6168614
Ref: tutorial/introduction an-informal-introduction-to-python6168614
Ref: 1b5d6168614
Ref: tutorial/introduction tut-informal6168614
Ref: 1b5e6168614
Node: Python を電卓として使う6170055
Ref: tutorial/introduction tut-calculator6170203
Ref: 1b5f6170203
Ref: tutorial/introduction using-python-as-a-calculator6170203
Ref: 1b606170203
Node: 数6170588
Ref: tutorial/introduction numbers6170680
Ref: 1b616170680
Ref: tutorial/introduction tut-numbers6170680
Ref: 1b626170680
Ref: 数-Footnote-16174111
Node: テキスト6174349
Ref: tutorial/introduction text6174467
Ref: 1b646174467
Ref: tutorial/introduction tut-strings6174467
Ref: 1b656174467
Ref: テキスト-Footnote-16184350
Node: リスト型 list6184739
Ref: tutorial/introduction lists6184845
Ref: 1b696184845
Ref: tutorial/introduction tut-lists6184845
Ref: 1b6a6184845
Node: プログラミングへの第一歩6188483
Ref: tutorial/introduction first-steps-towards-programming6188631
Ref: 1b6c6188631
Ref: tutorial/introduction tut-firststeps6188631
Ref: 1b6d6188631
Ref: プログラミングへの第一歩-Footnote-16192523
Node: その他の制御フローツール6192580
Ref: tutorial/controlflow doc6192749
Ref: 1b6f6192749
Ref: tutorial/controlflow more-control-flow-tools6192749
Ref: 1b706192749
Ref: tutorial/controlflow tut-morecontrol6192749
Ref: 1b716192749
Node: if 文6193277
Ref: tutorial/controlflow if-statements6193372
Ref: 1b726193372
Ref: tutorial/controlflow tut-if6193372
Ref: 1b736193372
Node: for 文6194450
Ref: tutorial/controlflow for-statements6194566
Ref: 1b766194566
Ref: tutorial/controlflow tut-for6194566
Ref: 1b776194566
Node: range 関数6196234
Ref: tutorial/controlflow the-range-function6196373
Ref: 1b786196373
Ref: tutorial/controlflow tut-range6196373
Ref: 1b796196373
Node: break and continue Statements6198934
Ref: tutorial/controlflow break-and-continue-statements6199087
Ref: 1b7c6199087
Ref: tutorial/controlflow tut-break6199087
Ref: 1b7d6199087
Ref: tutorial/controlflow tut-for-else6200067
Ref: 1b7e6200067
Node: else Clauses on Loops6200068
Ref: tutorial/controlflow break-and-continue-statements-and-else-clauses-on-loops6200217
Ref: 1b7f6200217
Ref: tutorial/controlflow else-clauses-on-loops6200217
Ref: 1b806200217
Node: pass 文6202472
Ref: tutorial/controlflow pass-statements6202601
Ref: 1b826202601
Ref: tutorial/controlflow tut-pass6202601
Ref: 1b836202601
Node: match 文6203450
Ref: tutorial/controlflow match-statements6203579
Ref: 1b856203579
Ref: tutorial/controlflow tut-match6203579
Ref: 1b756203579
Ref: match 文-Footnote-16211411
Node: 関数を定義する6211453
Ref: tutorial/controlflow defining-functions6211610
Ref: 1b866211610
Ref: tutorial/controlflow tut-functions6211610
Ref: 1b876211610
Ref: 関数を定義する-Footnote-16218225
Node: 関数定義についてもう少し6218630
Ref: tutorial/controlflow more-on-defining-functions6218818
Ref: 1b8a6218818
Ref: tutorial/controlflow tut-defining6218818
Ref: 1b8b6218818
Node: デフォルトの引数値6219333
Ref: tutorial/controlflow default-argument-values6219463
Ref: 1b8c6219463
Ref: tutorial/controlflow tut-defaultargs6219463
Ref: 1b8d6219463
Node: キーワード引数6221787
Ref: tutorial/controlflow keyword-arguments6221950
Ref: 1b8e6221950
Ref: tutorial/controlflow tut-keywordargs6221950
Ref: 1b8f6221950
Node: 特殊なパラメータ6226017
Ref: tutorial/controlflow special-parameters6226174
Ref: 1b916226174
Node: 位置またはキーワード引数6227505
Ref: tutorial/controlflow positional-or-keyword-arguments6227632
Ref: 1b926227632
Node: 位置専用引数<2>6227840
Ref: tutorial/controlflow positional-only-parameters6228003
Ref: 1b936228003
Node: キーワード専用引数6228671
Ref: tutorial/controlflow keyword-only-arguments6228810
Ref: 1b946228810
Node: 関数の例6229113
Ref: tutorial/controlflow function-examples6229237
Ref: 1b956229237
Node: 要約6232549
Ref: tutorial/controlflow recap6232637
Ref: 1b966232637
Node: 任意引数リスト6233698
Ref: tutorial/controlflow arbitrary-argument-lists6233867
Ref: 1b976233867
Ref: tutorial/controlflow tut-arbitraryargs6233867
Ref: 1b986233867
Node: 引数リストのアンパック6234955
Ref: tutorial/controlflow tut-unpacking-arguments6235112
Ref: 1b996235112
Ref: tutorial/controlflow unpacking-argument-lists6235112
Ref: 1b9a6235112
Node: ラムダ式6236502
Ref: tutorial/controlflow lambda-expressions6236677
Ref: 1b9b6236677
Ref: tutorial/controlflow tut-lambda6236677
Ref: 1b9c6236677
Node: ドキュメンテーション文字列6237924
Ref: tutorial/controlflow documentation-strings6238096
Ref: 1b9d6238096
Ref: tutorial/controlflow tut-docstrings6238096
Ref: 1b886238096
Node: 関数のアノテーション6240531
Ref: tutorial/controlflow function-annotations6240682
Ref: 1b9e6240682
Ref: tutorial/controlflow tut-annotations6240682
Ref: 1b9f6240682
Ref: 関数のアノテーション-Footnote-16242015
Ref: 関数のアノテーション-Footnote-26242057
Node: 間奏曲 コーディングスタイル6242099
Ref: tutorial/controlflow intermezzo-coding-style6242257
Ref: 1ba26242257
Ref: tutorial/controlflow tut-codingstyle6242257
Ref: 1ba36242257
Ref: 間奏曲 コーディングスタイル-Footnote-16245257
Node: データ構造6245299
Ref: tutorial/datastructures doc6245451
Ref: 1ba56245451
Ref: tutorial/datastructures data-structures6245451
Ref: 1ba66245451
Ref: tutorial/datastructures tut-structures6245451
Ref: 1b7b6245451
Node: リスト型についてもう少し6245905
Ref: tutorial/datastructures more-on-lists6246009
Ref: 1ba76246009
Ref: tutorial/datastructures tut-morelists6246009
Ref: 1ba86246009
Ref: リスト型についてもう少し-Footnote-16250642
Node: リストをスタックとして使う6250840
Ref: tutorial/datastructures tut-lists-as-stacks6250997
Ref: 1ba96250997
Ref: tutorial/datastructures using-lists-as-stacks6250997
Ref: 1baa6250997
Node: リストをキューとして使う6251805
Ref: tutorial/datastructures tut-lists-as-queues6251998
Ref: 1bab6251998
Ref: tutorial/datastructures using-lists-as-queues6251998
Ref: 1bac6251998
Node: リストの内包表記<2>6253417
Ref: tutorial/datastructures list-comprehensions6253610
Ref: 1bad6253610
Ref: tutorial/datastructures tut-listcomps6253610
Ref: 1bae6253610
Node: ネストしたリストの内包表記6257232
Ref: tutorial/datastructures nested-list-comprehensions6257380
Ref: 1baf6257380
Node: del 文6259229
Ref: tutorial/datastructures the-del-statement6259369
Ref: 1bb06259369
Ref: tutorial/datastructures tut-del6259369
Ref: 1bb16259369
Node: タプルとシーケンス6260372
Ref: tutorial/datastructures tuples-and-sequences6260485
Ref: 1bb26260485
Ref: tutorial/datastructures tut-tuples6260485
Ref: 1b906260485
Node: 集合型6264273
Ref: tutorial/datastructures sets6264399
Ref: 1bb46264399
Ref: tutorial/datastructures tut-sets6264399
Ref: 1bb56264399
Node: 辞書型 dictionary6266358
Ref: tutorial/datastructures dictionaries6266484
Ref: 1bb66266484
Ref: tutorial/datastructures tut-dictionaries6266484
Ref: 1bb76266484
Node: ループのテクニック6270206
Ref: tutorial/datastructures looping-techniques6270353
Ref: 1bb86270353
Ref: tutorial/datastructures tut-loopidioms6270353
Ref: 1b7a6270353
Node: 条件についてもう少し6273405
Ref: tutorial/datastructures more-on-conditions6273574
Ref: 1bb96273574
Ref: tutorial/datastructures tut-conditions6273574
Ref: 1bba6273574
Node: シーケンスとその他の型の比較6276258
Ref: tutorial/datastructures comparing-sequences-and-other-types6276391
Ref: 1bbc6276391
Ref: tutorial/datastructures tut-comparing6276391
Ref: 1bbd6276391
Node: モジュール<2>6278427
Ref: tutorial/modules doc6278558
Ref: 1bbe6278558
Ref: tutorial/modules modules6278558
Ref: 1bbf6278558
Ref: tutorial/modules tut-modules6278558
Ref: 1bc06278558
Node: モジュールについてもうすこし6281873
Ref: tutorial/modules more-on-modules6282000
Ref: 1bc36282000
Ref: tutorial/modules tut-moremodules6282000
Ref: 1bc46282000
Ref: モジュールについてもうすこし-Footnote-16286542
Node: モジュールをスクリプトとして実行する6286762
Ref: tutorial/modules executing-modules-as-scripts6286931
Ref: 1bc56286931
Ref: tutorial/modules tut-modulesasscripts6286931
Ref: 1bc66286931
Node: モジュール検索パス6288159
Ref: tutorial/modules the-module-search-path6288384
Ref: 1bc76288384
Ref: tutorial/modules tut-searchpath6288384
Ref: 1bc86288384
Node: "コンパイル" された Python ファイル6290579
Ref: tutorial/modules compiled-python-files6290741
Ref: 1bcc6290741
Ref: tutorial/modules tut-pycache6290741
Ref: 6a76290741
Ref: "コンパイル" された Python ファイル-Footnote-16294283
Node: 標準モジュール6294325
Ref: tutorial/modules standard-modules6294471
Ref: 1bcd6294471
Ref: tutorial/modules tut-standardmodules6294471
Ref: 1bcb6294471
Node: dir 関数6296226
Ref: tutorial/modules the-dir-function6296345
Ref: 1bce6296345
Ref: tutorial/modules tut-dir6296345
Ref: 1bcf6296345
Node: パッケージ6301065
Ref: tutorial/modules packages6301154
Ref: 1bd06301154
Ref: tutorial/modules tut-packages6301154
Ref: 1bd16301154
Node: パッケージから * を import する6306961
Ref: tutorial/modules importing-from-a-package6307087
Ref: 1bd36307087
Ref: tutorial/modules tut-pkg-import-star6307087
Ref: 1bd46307087
Node: パッケージ内参照6311766
Ref: tutorial/modules id26311946
Ref: 1bd56311946
Ref: tutorial/modules intra-package-references6311946
Ref: 1bd66311946
Node: 複数ディレクトリ中のパッケージ6313202
Ref: tutorial/modules packages-in-multiple-directories6313332
Ref: 1bd76313332
Node: 入力と出力6313977
Ref: tutorial/inputoutput doc6314111
Ref: 1bd96314111
Ref: tutorial/inputoutput input-and-output6314111
Ref: 1bda6314111
Ref: tutorial/inputoutput tut-io6314111
Ref: 1bdb6314111
Node: 出力を見やすくフォーマットする6314545
Ref: tutorial/inputoutput fancier-output-formatting6314684
Ref: 1bdc6314684
Ref: tutorial/inputoutput tut-formatting6314684
Ref: 1bdd6314684
Node: フォーマット済み文字列リテラル6319519
Ref: tutorial/inputoutput formatted-string-literals6319687
Ref: 1be06319687
Ref: tutorial/inputoutput tut-f-strings6319687
Ref: 1bdf6319687
Node: 文字列の format メソッド6321942
Ref: tutorial/inputoutput the-string-format-method6322164
Ref: 1be16322164
Ref: tutorial/inputoutput tut-string-format6322164
Ref: 1be26322164
Node: 文字列の手作業でのフォーマット6325317
Ref: tutorial/inputoutput manual-string-formatting6325527
Ref: 1be36325527
Node: 古い文字列書式設定方法6327482
Ref: tutorial/inputoutput old-string-formatting6327651
Ref: 1be76327651
Node: ファイルを読み書きする6328309
Ref: tutorial/inputoutput reading-and-writing-files6328448
Ref: 1be86328448
Ref: tutorial/inputoutput tut-files6328448
Ref: 1be96328448
Node: ファイルオブジェクトのメソッド6332686
Ref: tutorial/inputoutput methods-of-file-objects6332860
Ref: 1bea6332860
Ref: tutorial/inputoutput tut-filemethods6332860
Ref: 1beb6332860
Node: json による構造化されたデータの保存6337774
Ref: tutorial/inputoutput saving-structured-data-with-json6337948
Ref: 1bed6337948
Ref: tutorial/inputoutput tut-json6337948
Ref: 1bee6337948
Ref: json による構造化されたデータの保存-Footnote-16341806
Node: エラーと例外6341831
Ref: tutorial/errors doc6341956
Ref: 1bf26341956
Ref: tutorial/errors errors-and-exceptions6341956
Ref: 1bf36341956
Ref: tutorial/errors tut-errors6341956
Ref: 1bf46341956
Node: 構文エラー6342740
Ref: tutorial/errors syntax-errors6342825
Ref: 1bf56342825
Ref: tutorial/errors tut-syntaxerrors6342825
Ref: 1bf66342825
Node: 例外6343795
Ref: tutorial/errors exceptions6343910
Ref: 1bf76343910
Ref: tutorial/errors tut-exceptions6343910
Ref: 1bf86343910
Node: 例外を処理する6346281
Ref: tutorial/errors handling-exceptions6346402
Ref: 1bf96346402
Ref: tutorial/errors tut-handling6346402
Ref: 1b816346402
Node: 例外を送出する6354261
Ref: tutorial/errors raising-exceptions6354391
Ref: 1bfa6354391
Ref: tutorial/errors tut-raising6354391
Ref: 1bfb6354391
Node: 例外の連鎖6355769
Ref: tutorial/errors exception-chaining6355902
Ref: 1bfc6355902
Ref: tutorial/errors tut-exception-chaining6355902
Ref: 1bfd6355902
Node: ユーザー定義例外6358201
Ref: tutorial/errors tut-userexceptions6358355
Ref: 1bfe6358355
Ref: tutorial/errors user-defined-exceptions6358355
Ref: 1bff6358355
Node: クリーンアップ動作を定義する6359415
Ref: tutorial/errors defining-clean-up-actions6359593
Ref: 1c006359593
Ref: tutorial/errors tut-cleanup6359593
Ref: 1c016359593
Node: 定義済みクリーンアップ処理6363286
Ref: tutorial/errors predefined-clean-up-actions6363488
Ref: 1c026363488
Ref: tutorial/errors tut-cleanup-with6363488
Ref: 1c036363488
Node: 複数の関連しない例外の送出と処理6364786
Ref: tutorial/errors raising-and-handling-multiple-unrelated-exceptions6364991
Ref: 1c046364991
Ref: tutorial/errors tut-exception-groups6364991
Ref: 1c056364991
Node: ノートによって例外を充実させる6368706
Ref: tutorial/errors enriching-exceptions-with-notes6368863
Ref: 1c066368863
Ref: tutorial/errors tut-exception-notes6368863
Ref: 1c076368863
Node: クラス6371883
Ref: tutorial/classes doc6372029
Ref: 1c086372029
Ref: tutorial/classes classes6372029
Ref: 1c096372029
Ref: tutorial/classes tut-classes6372029
Ref: 1b896372029
Node: 名前とオブジェクトについて6375429
Ref: tutorial/classes a-word-about-names-and-objects6375560
Ref: 1c0b6375560
Ref: tutorial/classes tut-object6375560
Ref: 1c0c6375560
Node: Python のスコープと名前空間6376883
Ref: tutorial/classes python-scopes-and-namespaces6377038
Ref: 1c0d6377038
Ref: tutorial/classes tut-scopes6377038
Ref: 1bc26377038
Ref: Python のスコープと名前空間-Footnote-16385273
Node: スコープと名前空間の例6385655
Ref: tutorial/classes scopes-and-namespaces-example6385762
Ref: 1c0f6385762
Ref: tutorial/classes tut-scopeexample6385762
Ref: 1c106385762
Node: クラス初見6387250
Ref: tutorial/classes a-first-look-at-classes6387390
Ref: 1c116387390
Ref: tutorial/classes tut-firstclasses6387390
Ref: 1ba46387390
Node: クラス定義の構文6387783
Ref: tutorial/classes class-definition-syntax6387895
Ref: 1c126387895
Ref: tutorial/classes tut-classdefinition6387895
Ref: 1c136387895
Node: クラスオブジェクト6389838
Ref: tutorial/classes class-objects6389995
Ref: 1c146389995
Ref: tutorial/classes tut-classobjects6389995
Ref: 1c156389995
Node: インスタンスオブジェクト6392853
Ref: tutorial/classes instance-objects6393016
Ref: 1c176393016
Ref: tutorial/classes tut-instanceobjects6393016
Ref: 1c186393016
Node: メソッドオブジェクト6394845
Ref: tutorial/classes method-objects6395017
Ref: 1c196395017
Ref: tutorial/classes tut-methodobjects6395017
Ref: 1c1a6395017
Node: クラスとインスタンス変数6397454
Ref: tutorial/classes class-and-instance-variables6397581
Ref: 1c1b6397581
Ref: tutorial/classes tut-class-and-instance-variables6397581
Ref: 1c1c6397581
Node: いろいろな注意点6399971
Ref: tutorial/classes random-remarks6400080
Ref: 1c1d6400080
Ref: tutorial/classes tut-remarks6400080
Ref: 1c1e6400080
Node: 継承6405231
Ref: tutorial/classes inheritance6405349
Ref: 1c1f6405349
Ref: tutorial/classes tut-inheritance6405349
Ref: 1c206405349
Node: 多重継承6409223
Ref: tutorial/classes multiple-inheritance6409278
Ref: 1c216409278
Ref: tutorial/classes tut-multiple6409278
Ref: 1c226409278
Node: プライベート変数6411780
Ref: tutorial/classes private-variables6411895
Ref: 1c236411895
Ref: tutorial/classes tut-private6411895
Ref: 1c0a6411895
Node: 残りのはしばし6415384
Ref: tutorial/classes odds-and-ends6415517
Ref: 1c256415517
Ref: tutorial/classes tut-odds6415517
Ref: 1c266415517
Node: イテレータ iterator6416956
Ref: tutorial/classes iterators6417093
Ref: 1c296417093
Ref: tutorial/classes tut-iterators6417093
Ref: 1c2a6417093
Node: ジェネレータ generator6419892
Ref: tutorial/classes generators6420029
Ref: 1c2c6420029
Ref: tutorial/classes tut-generators6420029
Ref: 1c2d6420029
Node: ジェネレータ式6421967
Ref: tutorial/classes generator-expressions6422071
Ref: 1c306422071
Ref: tutorial/classes tut-genexps6422071
Ref: 1c316422071
Node: 標準ライブラリミニツアー6423247
Ref: tutorial/stdlib doc6423424
Ref: 1c326423424
Ref: tutorial/stdlib brief-tour-of-the-standard-library6423424
Ref: 1c336423424
Ref: tutorial/stdlib tut-brieftour6423424
Ref: 1c346423424
Node: OSへのインターフェース6423908
Ref: tutorial/stdlib operating-system-interface6424064
Ref: 1c356424064
Ref: tutorial/stdlib tut-os-interface6424064
Ref: 1c366424064
Node: ファイルのワイルドカード表記6425559
Ref: tutorial/stdlib file-wildcards6425751
Ref: 1c376425751
Ref: tutorial/stdlib tut-file-wildcards6425751
Ref: 1c386425751
Node: コマンドライン引数6426107
Ref: tutorial/stdlib command-line-arguments6426330
Ref: 1c396426330
Ref: tutorial/stdlib tut-command-line-arguments6426330
Ref: 1c3a6426330
Node: エラー出力のリダイレクトとプログラムの終了6427705
Ref: tutorial/stdlib error-output-redirection-and-program-termination6427925
Ref: 1c3b6427925
Ref: tutorial/stdlib tut-stderr6427925
Ref: 1c3c6427925
Node: 文字列のパターンマッチング6428548
Ref: tutorial/stdlib string-pattern-matching6428747
Ref: 1c3d6428747
Ref: tutorial/stdlib tut-string-pattern-matching6428747
Ref: 1c3e6428747
Node: 数学6429466
Ref: tutorial/stdlib mathematics6429641
Ref: 1c3f6429641
Ref: tutorial/stdlib tut-mathematics6429641
Ref: 1c406429641
Node: インターネットへのアクセス6430955
Ref: tutorial/stdlib internet-access6431106
Ref: 1c416431106
Ref: tutorial/stdlib tut-internet-access6431106
Ref: 1c426431106
Node: 日付と時刻6432369
Ref: tutorial/stdlib dates-and-times6432529
Ref: 1c436432529
Ref: tutorial/stdlib tut-dates-and-times6432529
Ref: 1c446432529
Node: データ圧縮6433504
Ref: tutorial/stdlib data-compression6433655
Ref: 1c456433655
Ref: tutorial/stdlib tut-data-compression6433655
Ref: 1c466433655
Node: パフォーマンスの計測6434218
Ref: tutorial/stdlib performance-measurement6434366
Ref: 1c476434366
Ref: tutorial/stdlib tut-performance-measurement6434366
Ref: 1c486434366
Node: 品質管理6435519
Ref: tutorial/stdlib quality-control6435673
Ref: 1c496435673
Ref: tutorial/stdlib tut-quality-control6435673
Ref: 1c4a6435673
Node: バッテリー同梱6437503
Ref: tutorial/stdlib batteries-included6437618
Ref: 1c4b6437618
Ref: tutorial/stdlib tut-batteries-included6437618
Ref: 1c4c6437618
Ref: バッテリー同梱-Footnote-16440036
Node: 標準ライブラリミニツアー --- その 26440095
Ref: tutorial/stdlib2 doc6440293
Ref: 1c4d6440293
Ref: tutorial/stdlib2 brief-tour-of-the-standard-library-part-ii6440293
Ref: 1c4e6440293
Ref: tutorial/stdlib2 tut-brieftourtwo6440293
Ref: 1c4f6440293
Node: 出力のフォーマット6440936
Ref: tutorial/stdlib2 output-formatting6441085
Ref: 1c506441085
Ref: tutorial/stdlib2 tut-output-formatting6441085
Ref: 1c516441085
Node: 文字列テンプレート6443515
Ref: tutorial/stdlib2 templating6443715
Ref: 1c526443715
Ref: tutorial/stdlib2 tut-templating6443715
Ref: 1c536443715
Node: バイナリデータレコードの操作6447072
Ref: tutorial/stdlib2 tut-binary-formats6447278
Ref: 1c566447278
Ref: tutorial/stdlib2 working-with-binary-data-record-layouts6447278
Ref: 1c576447278
Node: マルチスレッディング<2>6448641
Ref: tutorial/stdlib2 multi-threading6448832
Ref: 1c586448832
Ref: tutorial/stdlib2 tut-multi-threading6448832
Ref: 1c596448832
Node: ログ記録6451289
Ref: tutorial/stdlib2 logging6451447
Ref: 1c5a6451447
Ref: tutorial/stdlib2 tut-logging6451447
Ref: 1c5b6451447
Node: 弱参照6453022
Ref: tutorial/stdlib2 tut-weak-references6453183
Ref: 1c626453183
Ref: tutorial/stdlib2 weak-references6453183
Ref: 1c636453183
Node: リスト操作のためのツール6455330
Ref: tutorial/stdlib2 tools-for-working-with-lists6455503
Ref: 1c646455503
Ref: tutorial/stdlib2 tut-list-tools6455503
Ref: 1c656455503
Node: 10 進浮動小数演算6458455
Ref: tutorial/stdlib2 decimal-floating-point-arithmetic6458610
Ref: 1c666458610
Ref: tutorial/stdlib2 tut-decimal-fp6458610
Ref: 1c676458610
Node: 仮想環境とパッケージ6460936
Ref: tutorial/venv doc6461113
Ref: 1c686461113
Ref: tutorial/venv tut-venv6461113
Ref: 1c696461113
Ref: tutorial/venv virtual-environments-and-packages6461113
Ref: 1c6a6461113
Node: はじめに<4>6461287
Ref: tutorial/venv introduction6461399
Ref: 1c6b6461399
Node: 仮想環境の作成6463209
Ref: tutorial/venv creating-virtual-environments6463367
Ref: 1c6d6463367
Node: pip を使ったパッケージ管理6465719
Ref: tutorial/venv managing-packages-with-pip6465853
Ref: 1c6e6465853
Ref: pip を使ったパッケージ管理-Footnote-16470422
Ref: pip を使ったパッケージ管理-Footnote-26470447
Node: さあ何を？6470525
Ref: tutorial/whatnow doc6470686
Ref: 1c6f6470686
Ref: tutorial/whatnow tut-whatnow6470686
Ref: 1c706470686
Ref: tutorial/whatnow what-now6470686
Ref: 1c716470686
Ref: さあ何を？-Footnote-16474958
Node: 対話入力編集と履歴置換6475138
Ref: tutorial/interactive doc6475314
Ref: 1c736475314
Ref: tutorial/interactive interactive-input-editing-and-history-substitution6475314
Ref: 1c746475314
Ref: tutorial/interactive tut-interacting6475314
Ref: 1b536475314
Ref: 対話入力編集と履歴置換-Footnote-16476010
Node: タブ補完と履歴編集6476071
Ref: tutorial/interactive tab-completion-and-history-editing6476216
Ref: 1c756476216
Ref: tutorial/interactive tut-keybindings6476216
Ref: 1c766476216
Node: 対話的インタープリタの代替6477314
Ref: tutorial/interactive alternatives-to-the-interactive-interpreter6477459
Ref: 1c776477459
Ref: tutorial/interactive tut-commentary6477459
Ref: 1c786477459
Ref: 対話的インタープリタの代替-Footnote-16478650
Ref: 対話的インタープリタの代替-Footnote-26478679
Node: 浮動小数点演算、その問題と制限6478720
Ref: tutorial/floatingpoint doc6478887
Ref: 1c796478887
Ref: tutorial/floatingpoint floating-point-arithmetic-issues-and-limitations6478887
Ref: 1c7a6478887
Ref: tutorial/floatingpoint tut-fp-issues6478887
Ref: 1c7b6478887
Ref: 浮動小数点演算、その問題と制限-Footnote-16490081
Ref: 浮動小数点演算、その問題と制限-Footnote-26490159
Node: 表現エラー6490210
Ref: tutorial/floatingpoint representation-error6490307
Ref: 1c7e6490307
Ref: tutorial/floatingpoint tut-fp-error6490307
Ref: 1c7f6490307
Node: 付録6494382
Ref: tutorial/appendix doc6494507
Ref: 1c806494507
Ref: tutorial/appendix appendix6494507
Ref: 1c816494507
Ref: tutorial/appendix tut-appendix6494507
Ref: 1c826494507
Node: 対話モード<2>6494579
Ref: tutorial/appendix interactive-mode6494640
Ref: 1c836494640
Ref: tutorial/appendix tut-interac6494640
Ref: 1556494640
Node: エラー処理6496005
Ref: tutorial/appendix error-handling6496122
Ref: 1c846496122
Ref: tutorial/appendix tut-error6496122
Ref: 1c856496122
Ref: エラー処理-Footnote-16497498
Node: 実行可能な Python スクリプト6497605
Ref: tutorial/appendix executable-python-scripts6497779
Ref: 1c866497779
Ref: tutorial/appendix tut-scripts6497779
Ref: 1b5b6497779
Node: 対話モード用の起動時実行ファイル6499344
Ref: tutorial/appendix the-interactive-startup-file6499539
Ref: 1c876499539
Ref: tutorial/appendix tut-startup6499539
Ref: 1c886499539
Node: カスタマイズ用モジュール6501636
Ref: tutorial/appendix the-customization-modules6501784
Ref: 1c896501784
Ref: tutorial/appendix tut-customize6501784
Ref: 1c8a6501784
Node: Python のセットアップと利用6503034
Ref: using/index doc6503188
Ref: 1c8b6503188
Ref: using/index python-setup-and-usage6503188
Ref: 1c8c6503188
Ref: using/index using-index6503188
Ref: 1c8d6503188
Node: コマンドラインと環境6503741
Ref: using/cmdline doc6503903
Ref: 1c8e6503903
Ref: using/cmdline command-line-and-environment6503903
Ref: 1c8f6503903
Ref: using/cmdline using-on-general6503903
Ref: 192a6503903
Node: コマンドライン6504335
Ref: using/cmdline command-line6504444
Ref: 1c916504444
Ref: using/cmdline using-on-cmdline6504444
Ref: fd26504444
Node: インターフェイスオプション6504982
Ref: using/cmdline interface-options6505109
Ref: 1c926505109
Ref: using/cmdline using-on-interface-options6505109
Ref: 1c936505109
Ref: using/cmdline cmdoption-c6506945
Ref: 5aa6506945
Ref: using/cmdline cmdoption-m6507706
Ref: 5ab6507706
Ref: using/cmdline cmdarg-dash6510723
Ref: 1c946510723
Ref: using/cmdline cmdarg-script6511276
Ref: 1c956511276
Ref: インターフェイスオプション-Footnote-16513520
Node: 一般オプション6513562
Ref: using/cmdline generic-options6513725
Ref: 1c966513725
Ref: using/cmdline using-on-generic-options6513725
Ref: 1c976513725
Ref: using/cmdline cmdoption-06513779
Ref: 13cf6513779
Ref: using/cmdline cmdoption-h6513794
Ref: 1c986513794
Ref: using/cmdline cmdoption-help6513809
Ref: 5ba6513809
Ref: using/cmdline cmdoption-help-env6513944
Ref: 5bc6513944
Ref: using/cmdline cmdoption-help-xoptions6514085
Ref: 5bd6514085
Ref: using/cmdline cmdoption-help-all6514234
Ref: 5be6514234
Ref: using/cmdline cmdoption-V6514336
Ref: 15d6514336
Ref: using/cmdline cmdoption-version6514351
Ref: ce96514351
Node: その他のオプション6514736
Ref: using/cmdline miscellaneous-options6514872
Ref: 1c996514872
Ref: using/cmdline using-on-misc-options6514872
Ref: fd36514872
Ref: using/cmdline cmdoption-b6514936
Ref: 5ad6514936
Ref: using/cmdline cmdoption-B6515359
Ref: 13756515359
Ref: using/cmdline cmdoption-check-hash-based-pycs6515610
Ref: 1c9a6515610
Ref: using/cmdline cmdoption-d6516329
Ref: 1c9b6516329
Ref: using/cmdline cmdoption-E6516560
Ref: 92b6516560
Ref: using/cmdline cmdoption-i6516783
Ref: 14846516783
Ref: using/cmdline cmdoption-I6517440
Ref: 92c6517440
Ref: using/cmdline cmdoption-O6517940
Ref: d826517940
Ref: using/cmdline cmdoption-OO6518355
Ref: d836518355
Ref: using/cmdline cmdoption-P6518687
Ref: 56e6518687
Ref: using/cmdline cmdoption-q6519348
Ref: 1c9e6519348
Ref: using/cmdline cmdoption-R6519515
Ref: 1a026519515
Ref: using/cmdline cmdoption-s6520631
Ref: 13536520631
Ref: using/cmdline cmdoption-S6520924
Ref: 11796520924
Ref: using/cmdline cmdoption-u6521322
Ref: 190f6521322
Ref: using/cmdline cmdoption-v6521627
Ref: 13cc6521627
Ref: using/cmdline using-on-warnings6522328
Ref: 1ca26522328
Ref: using/cmdline cmdoption-W6522328
Ref: 8966522328
Ref: using/cmdline cmdoption-x6525042
Ref: 1ca46525042
Ref: using/cmdline cmdoption-X6525248
Ref: 15c6525248
Ref: その他のオプション-Footnote-16531866
Ref: その他のオプション-Footnote-26531908
Ref: その他のオプション-Footnote-36531950
Ref: その他のオプション-Footnote-46531992
Ref: その他のオプション-Footnote-56532034
Node: 色の制御6532076
Ref: using/cmdline controlling-color6532227
Ref: 1caa6532227
Ref: using/cmdline using-on-controlling-color6532227
Ref: 1516532227
Ref: 色の制御-Footnote-16533514
Ref: 色の制御-Footnote-26533547
Node: 使うべきでないオプション6533577
Ref: using/cmdline no-color6533692
Ref: 1cab6533692
Ref: using/cmdline options-you-shouldn-t-use6533692
Ref: 1cac6533692
Ref: using/cmdline cmdoption-J6533771
Ref: 13746533771
Ref: 使うべきでないオプション-Footnote-16533879
Node: 環境変数6533911
Ref: using/cmdline environment-variables6534020
Ref: 1cad6534020
Ref: using/cmdline using-on-envvars6534020
Ref: 5bb6534020
Ref: using/cmdline envvar-PYTHONHOME6534339
Ref: 3966534339
Ref: using/cmdline envvar-PYTHONPATH6535103
Ref: fe86535103
Ref: using/cmdline envvar-PYTHONSAFEPATH6536525
Ref: 56f6536525
Ref: using/cmdline envvar-PYTHONPLATLIBDIR6536750
Ref: 18aa6536750
Ref: using/cmdline envvar-PYTHONSTARTUP6536914
Ref: f956536914
Ref: using/cmdline envvar-PYTHONOPTIMIZE6537744
Ref: 1c9d6537744
Ref: using/cmdline envvar-PYTHONBREAKPOINT6538021
Ref: aa96538021
Ref: using/cmdline envvar-PYTHONDEBUG6538630
Ref: 1c9c6538630
Ref: using/cmdline envvar-PYTHONINSPECT6539012
Ref: 14836539012
Ref: using/cmdline envvar-PYTHONUNBUFFERED6539741
Ref: 19106539741
Ref: using/cmdline envvar-PYTHONVERBOSE6539915
Ref: 1ca16539915
Ref: using/cmdline envvar-PYTHONCASEOK6540193
Ref: 92a6540193
Ref: using/cmdline envvar-PYTHONDONTWRITEBYTECODE6540431
Ref: 13766540431
Ref: using/cmdline envvar-PYTHONPYCACHEPREFIX6540751
Ref: 9716540751
Ref: using/cmdline envvar-PYTHONHASHSEED6541086
Ref: 10526541086
Ref: using/cmdline envvar-PYTHONINTMAXSTRDIGITS6541930
Ref: 17286541930
Ref: using/cmdline envvar-PYTHONIOENCODING6542160
Ref: fd56542160
Ref: using/cmdline envvar-PYTHONNOUSERSITE6543116
Ref: 13546543116
Ref: using/cmdline envvar-PYTHONUSERBASE6543438
Ref: 13526543438
Ref: using/cmdline envvar-PYTHONEXECUTABLE6543797
Ref: 1cb26543797
Ref: using/cmdline envvar-PYTHONWARNINGS6544056
Ref: b786544056
Ref: using/cmdline envvar-PYTHONFAULTHANDLER6545057
Ref: 10556545057
Ref: using/cmdline envvar-PYTHONTRACEMALLOC6545500
Ref: 1ca66545500
Ref: using/cmdline envvar-PYTHONPROFILEIMPORTTIME6546062
Ref: ac36546062
Ref: using/cmdline envvar-PYTHONASYNCIODEBUG6546328
Ref: 1cb86546328
Ref: using/cmdline envvar-PYTHONMALLOC6546575
Ref: c326546575
Ref: using/cmdline envvar-PYTHONMALLOCSTATS6548034
Ref: 1ac16548034
Ref: using/cmdline envvar-PYTHONLEGACYWINDOWSFSENCODING6548709
Ref: 28f6548709
Ref: using/cmdline envvar-PYTHONLEGACYWINDOWSSTDIO6549250
Ref: c296549250
Ref: using/cmdline envvar-PYTHONCOERCECLOCALE6549715
Ref: aa36549715
Ref: using/cmdline envvar-PYTHONDEVMODE6552471
Ref: abb6552471
Ref: using/cmdline envvar-PYTHONUTF86552810
Ref: aa66552810
Ref: using/cmdline envvar-PYTHONWARNDEFAULTENCODING6553098
Ref: 7876553098
Ref: using/cmdline envvar-PYTHONNODEBUGRANGES6553418
Ref: 5806553418
Ref: using/cmdline envvar-PYTHONPERFSUPPORT6553879
Ref: 43b6553879
Ref: using/cmdline envvar-PYTHON_PERF_JIT_SUPPORT6554283
Ref: 1756554283
Ref: using/cmdline envvar-PYTHON_CPU_COUNT6554726
Ref: 1f16554726
Ref: using/cmdline envvar-PYTHON_FROZEN_MODULES6555019
Ref: 1736555019
Ref: using/cmdline envvar-PYTHON_COLORS6555656
Ref: 1306555656
Ref: using/cmdline envvar-PYTHON_BASIC_REPL6555910
Ref: 1546555910
Ref: using/cmdline envvar-PYTHON_HISTORY6556231
Ref: 1766556231
Ref: using/cmdline envvar-PYTHON_GIL6556472
Ref: 15b6556472
Ref: 環境変数-Footnote-16556980
Ref: 環境変数-Footnote-26557022
Ref: 環境変数-Footnote-36557064
Ref: 環境変数-Footnote-46557106
Node: デバッグモード変数6557148
Ref: using/cmdline debug-mode-variables6557224
Ref: 1cc06557224
Ref: using/cmdline envvar-PYTHONDUMPREFS6557288
Ref: 9746557288
Ref: using/cmdline envvar-PYTHONDUMPREFSFILE6557583
Ref: 17fd6557583
Ref: using/cmdline envvar-PYTHON_PRESITE6557931
Ref: 1ca86557931
Node: Unix プラットフォームで Python を使う6558668
Ref: using/unix doc6558861
Ref: 1cc16558861
Ref: using/unix using-on-unix6558861
Ref: 1cc26558861
Ref: using/unix using-python-on-unix-platforms6558861
Ref: 1cc36558861
Node: 最新バージョンの Python の取得とインストール6559140
Ref: using/unix getting-and-installing-the-latest-version-of-python6559316
Ref: 1cc46559316
Node: Linux6559481
Ref: using/unix on-linux6559613
Ref: 1cc56559613
Node: FreeBSD と OpenBSD6560532
Ref: using/unix on-freebsd-and-openbsd6560664
Ref: 1cc66560664
Node: Python のビルド6561322
Ref: using/unix building-python6561550
Ref: 1cc76561550
Ref: using/unix building-python-on-unix6561550
Ref: ebe6561550
Ref: Python のビルド-Footnote-16562631
Ref: Python のビルド-Footnote-26562680
Ref: Python のビルド-Footnote-36562743
Node: Python に関係するパスとファイル6562806
Ref: using/unix python-related-paths-and-files6562981
Ref: 1cc96562981
Node: その他6564604
Ref: using/unix miscellaneous6564774
Ref: 1ccc6564774
Node: Custom OpenSSL6565556
Ref: using/unix custom-openssl6565674
Ref: 1ccd6565674
Ref: using/unix unix-custom-openssl6565674
Ref: 1cce6565674
Node: Python を構成する6567290
Ref: using/configure doc6567481
Ref: 1ccf6567481
Ref: using/configure configure-python6567481
Ref: 1cd06567481
Node: ビルド要件6567685
Ref: using/configure build-requirements6567795
Ref: 1cd16567795
Ref: ビルド要件-Footnote-16569510
Ref: ビルド要件-Footnote-26569553
Ref: ビルド要件-Footnote-36569636
Ref: ビルド要件-Footnote-46569683
Ref: ビルド要件-Footnote-56569740
Ref: ビルド要件-Footnote-66569782
Node: 生成されるファイル6569824
Ref: using/configure generated-files6569967
Ref: 1cd26569967
Node: 構成スクリプト6570452
Ref: using/configure configure-script6570537
Ref: 1cd36570537
Node: Configureオプション6571078
Ref: using/configure configure-options6571234
Ref: 1cc86571234
Ref: using/configure id16571234
Ref: 1cd46571234
Node: 一般的なオプション6572003
Ref: using/configure general-options6572135
Ref: 1cd56572135
Ref: using/configure cmdoption-enable-loadable-sqlite-extensions6572199
Ref: 1cd66572199
Ref: using/configure cmdoption-disable-ipv66572556
Ref: 1cd76572556
Ref: using/configure cmdoption-enable-big-digits6572763
Ref: 7186572763
Ref: using/configure cmdoption-with-suffix6573161
Ref: 1cd86573161
Ref: using/configure cmdoption-with-tzpath6573803
Ref: 1cd96573803
Ref: using/configure cmdoption-without-decimal-contextvar6574326
Ref: 1cdc6574326
Ref: using/configure cmdoption-with-dbmliborder6574801
Ref: 1cde6574801
Ref: using/configure cmdoption-without-c-locale-coercion6575158
Ref: 1cdf6575158
Ref: using/configure cmdoption-without-freelists6575495
Ref: 7176575495
Ref: using/configure cmdoption-with-platlibdir6575619
Ref: 1ce06575619
Ref: using/configure cmdoption-with-wheel-pkg-dir6575935
Ref: 85a6575935
Ref: using/configure cmdoption-with-pkg-config6576552
Ref: 1ce16576552
Ref: using/configure cmdoption-enable-pystats6577009
Ref: 17266577009
Ref: using/configure free-threading-build6579360
Ref: 1ce26579360
Ref: using/configure cmdoption-disable-gil6579360
Ref: 15a6579360
Ref: using/configure cmdoption-enable-experimental-jit6579713
Ref: 1ce36579713
Ref: using/configure cmdoption-arg-PKG_CONFIG6580325
Ref: 1ce46580325
Ref: using/configure cmdoption-arg-PKG_CONFIG_LIBDIR6580389
Ref: 1ce56580389
Ref: using/configure cmdoption-arg-PKG_CONFIG_PATH6580420
Ref: 1ce66580420
Ref: 一般的なオプション-Footnote-16580517
Node: C コンパイラのオプション6580559
Ref: using/configure c-compiler-options6580727
Ref: 1ce76580727
Ref: using/configure cmdoption-arg-CC6580805
Ref: 1ce86580805
Ref: using/configure cmdoption-arg-CFLAGS6580863
Ref: 1ce96580863
Ref: using/configure cmdoption-arg-CPP6580922
Ref: 1cea6580922
Ref: using/configure cmdoption-arg-CPPFLAGS6580987
Ref: 1ceb6580987
Node: リンカのオプション6581083
Ref: using/configure linker-options6581275
Ref: 1cec6581275
Ref: using/configure cmdoption-arg-LDFLAGS6581339
Ref: 1ced6581339
Ref: using/configure cmdoption-arg-LIBS6581426
Ref: 1cee6581426
Ref: using/configure cmdoption-arg-MACHDEP6581512
Ref: 1cef6581512
Node: サードパーティ依存関係のオプション6581597
Ref: using/configure options-for-third-party-dependencies6581781
Ref: 1cf06581781
Ref: using/configure cmdoption-arg-BZIP2_CFLAGS6581909
Ref: 1cf16581909
Ref: using/configure cmdoption-arg-BZIP2_LIBS6581935
Ref: 1cf26581935
Ref: using/configure cmdoption-arg-CURSES_CFLAGS6582089
Ref: 1cf36582089
Ref: using/configure cmdoption-arg-CURSES_LIBS6582116
Ref: 1cf46582116
Ref: using/configure cmdoption-arg-GDBM_CFLAGS6582286
Ref: 1cf56582286
Ref: using/configure cmdoption-arg-GDBM_LIBS6582311
Ref: 1cf66582311
Ref: using/configure cmdoption-arg-LIBB2_CFLAGS6582384
Ref: 1cf76582384
Ref: using/configure cmdoption-arg-LIBB2_LIBS6582410
Ref: 1cf86582410
Ref: using/configure cmdoption-arg-LIBEDIT_CFLAGS6582576
Ref: 1cfa6582576
Ref: using/configure cmdoption-arg-LIBEDIT_LIBS6582604
Ref: 1cfb6582604
Ref: using/configure cmdoption-arg-LIBFFI_CFLAGS6582753
Ref: 1cfc6582753
Ref: using/configure cmdoption-arg-LIBFFI_LIBS6582780
Ref: 1cfd6582780
Ref: using/configure cmdoption-arg-LIBMPDEC_CFLAGS6582925
Ref: 1cfe6582925
Ref: using/configure cmdoption-arg-LIBMPDEC_LIBS6582954
Ref: 1cff6582954
Ref: using/configure cmdoption-arg-LIBLZMA_CFLAGS6583231
Ref: 1d006583231
Ref: using/configure cmdoption-arg-LIBLZMA_LIBS6583259
Ref: 1d016583259
Ref: using/configure cmdoption-arg-LIBREADLINE_CFLAGS6583404
Ref: 1d026583404
Ref: using/configure cmdoption-arg-LIBREADLINE_LIBS6583436
Ref: 1d036583436
Ref: using/configure cmdoption-arg-LIBSQLITE3_CFLAGS6583593
Ref: 1d046583593
Ref: using/configure cmdoption-arg-LIBSQLITE3_LIBS6583624
Ref: 1d056583624
Ref: using/configure cmdoption-arg-LIBUUID_CFLAGS6583778
Ref: 1d066583778
Ref: using/configure cmdoption-arg-LIBUUID_LIBS6583806
Ref: 1d076583806
Ref: using/configure cmdoption-arg-PANEL_CFLAGS6583951
Ref: 1d086583951
Ref: using/configure cmdoption-arg-PANEL_LIBS6583977
Ref: 1d096583977
Ref: using/configure cmdoption-arg-TCLTK_CFLAGS6584222
Ref: 1d0a6584222
Ref: using/configure cmdoption-arg-TCLTK_LIBS6584248
Ref: 1d0b6584248
Ref: using/configure cmdoption-arg-ZLIB_CFLAGS6584346
Ref: 1d0c6584346
Ref: using/configure cmdoption-arg-ZLIB_LIBS6584371
Ref: 1d0d6584371
Node: WebAssembly オプション6584513
Ref: using/configure webassembly-options6584703
Ref: 1d0e6584703
Ref: using/configure cmdoption-with-emscripten-target6584771
Ref: 1d0f6584771
Ref: using/configure cmdoption-enable-wasm-dynamic-linking6585139
Ref: 17986585139
Ref: using/configure cmdoption-enable-wasm-pthreads6585523
Ref: 176b6585523
Node: インストールオプション6585649
Ref: using/configure install-options6585836
Ref: 1d106585836
Ref: using/configure cmdoption-prefix6585910
Ref: 1cca6585910
Ref: using/configure cmdoption-exec-prefix6586397
Ref: 1ccb6586397
Ref: using/configure cmdoption-disable-test-modules6586698
Ref: 8596586698
Ref: using/configure cmdoption-with-ensurepip6587015
Ref: 1d116587015
Node: パフォーマンスに関するオプション6587507
Ref: using/configure performance-options6587685
Ref: 1d126587685
Ref: using/configure cmdoption-enable-optimizations6587983
Ref: 82d6587983
Ref: using/configure envvar-PROFILE_TASK6589135
Ref: 16766589135
Ref: using/configure cmdoption-with-lto6589458
Ref: 7166589458
Ref: using/configure cmdoption-enable-bolt6589984
Ref: 1d136589984
Ref: using/configure cmdoption-arg-BOLT_APPLY_FLAGS6591051
Ref: 1d146591051
Ref: using/configure cmdoption-arg-BOLT_INSTRUMENT_FLAGS6591187
Ref: 1d156591187
Ref: using/configure cmdoption-with-computed-gotos6591315
Ref: 1d166591315
Ref: using/configure cmdoption-without-mimalloc6591447
Ref: 1d176591447
Ref: using/configure cmdoption-without-pymalloc6591623
Ref: 1d186591623
Ref: using/configure cmdoption-without-doc-strings6591819
Ref: 1d196591819
Ref: using/configure cmdoption-enable-profiling6592114
Ref: 1d1a6592114
Ref: using/configure cmdoption-with-strict-overflow6592222
Ref: 16cd6592222
Ref: パフォーマンスに関するオプション-Footnote-16592413
Ref: パフォーマンスに関するオプション-Footnote-26592473
Node: Python Debug Build6592521
Ref: using/configure debug-build6592679
Ref: 1da6592679
Ref: using/configure python-debug-build6592679
Ref: 1d1b6592679
Node: Debug options6594865
Ref: using/configure debug-options6595005
Ref: 1d1c6595005
Ref: using/configure cmdoption-with-pydebug6595050
Ref: 3fb6595050
Ref: using/configure cmdoption-with-trace-refs6595184
Ref: 36e6595184
Ref: using/configure cmdoption-with-assertions6595833
Ref: 3656595833
Ref: using/configure cmdoption-with-valgrind6596219
Ref: 1d1e6596219
Ref: using/configure cmdoption-with-dtrace6596295
Ref: 1d1f6596295
Ref: using/configure cmdoption-with-address-sanitizer6596465
Ref: 1d206596465
Ref: using/configure cmdoption-with-memory-sanitizer6596617
Ref: 1d216596617
Ref: using/configure cmdoption-with-undefined-behavior-sanitizer6596771
Ref: 1d226596771
Ref: using/configure cmdoption-with-thread-sanitizer6596952
Ref: 1d236596952
Node: リンカのオプション<2>6597095
Ref: using/configure id26597234
Ref: 1d246597234
Ref: using/configure cmdoption-enable-shared6597300
Ref: 82e6597300
Ref: using/configure cmdoption-without-static-libpython6597414
Ref: 85b6597414
Node: Libraries options6597602
Ref: using/configure libraries-options6597744
Ref: 1d256597744
Ref: using/configure cmdoption-with-libs6597799
Ref: 1d266597799
Ref: using/configure cmdoption-with-system-expat6597892
Ref: 171d6597892
Ref: using/configure cmdoption-with-system-libmpdec6598023
Ref: 3eb6598023
Ref: using/configure cmdoption-with-readline6598603
Ref: 1d276598603
Ref: using/configure cmdoption-without-readline6598849
Ref: 1d286598849
Ref: using/configure cmdoption-with-libm6599032
Ref: 1d296599032
Ref: using/configure cmdoption-with-libc6599151
Ref: 1d2a6599151
Ref: using/configure cmdoption-with-openssl6599267
Ref: 1d2b6599267
Ref: using/configure cmdoption-with-openssl-rpath6599364
Ref: 85c6599364
Node: Security Options6599702
Ref: using/configure security-options6599838
Ref: 1d2c6599838
Ref: using/configure cmdoption-with-hash-algorithm6599891
Ref: 1d2d6599891
Ref: using/configure cmdoption-with-builtin-hashlib-hashes6600216
Ref: 1d2e6600216
Ref: using/configure cmdoption-with-ssl-default-suites6600517
Ref: 1d2f6600517
Node: macOS のオプション6601002
Ref: using/configure macos-options6601143
Ref: 1d306601143
Ref: using/configure cmdoption-enable-universalsdk6601238
Ref: 9396601238
Ref: using/configure cmdoption-06601273
Ref: 1d316601273
Ref: using/configure cmdoption-enable-framework6601536
Ref: 1d326601536
Ref: using/configure cmdoption-16601568
Ref: 1d336601568
Ref: using/configure cmdoption-with-universal-archs6601846
Ref: 1d346601846
Ref: using/configure cmdoption-with-framework-name6602305
Ref: 1d356602305
Ref: using/configure cmdoption-with-app-store-compliance6602551
Ref: 15566602551
Ref: using/configure cmdoption-26602592
Ref: 1d366602592
Ref: macOS のオプション-Footnote-16603296
Node: iOS のオプション6603363
Ref: using/configure ios-options6603530
Ref: 1d376603530
Ref: using/configure cmdoption-36603621
Ref: 1d386603621
Ref: using/configure cmdoption-46603814
Ref: 1d396603814
Ref: iOS のオプション-Footnote-16603986
Node: クロスコンパイルのオプション6604053
Ref: using/configure cross-compiling-options6604187
Ref: 1d3a6604187
Ref: using/configure cmdoption-build6604744
Ref: 1d3b6604744
Ref: using/configure cmdoption-host6604894
Ref: 1d3c6604894
Ref: using/configure cmdoption-with-build-python6605063
Ref: 1d3d6605063
Ref: using/configure cmdoption-arg-CONFIG_SITE6605227
Ref: 1d3e6605227
Ref: using/configure cmdoption-arg-HOSTRUNNER6605514
Ref: 1d3f6605514
Node: Python ビルドシステム6605903
Ref: using/configure python-build-system6606057
Ref: 1d406606057
Node: ビルドシステムの主要なファイル6606259
Ref: using/configure main-files-of-the-build-system6606408
Ref: 1d416606408
Node: 主要なビルドステップ6606845
Ref: using/configure main-build-steps6607024
Ref: 1d426607024
Node: Main Makefile targets6607422
Ref: using/configure main-makefile-targets6607568
Ref: 1d436607568
Node: make6607793
Ref: using/configure make6607877
Ref: 1d446607877
Node: make platform6609278
Ref: using/configure make-platform6609387
Ref: 1d456609387
Node: make profile-opt6609703
Ref: using/configure make-profile-opt6609818
Ref: 1d466609818
Node: make clean6610086
Ref: using/configure make-clean6610202
Ref: 1d476610202
Node: make distclean6610262
Ref: using/configure make-distclean6610374
Ref: 1d486610374
Ref: make distclean-Footnote-16610619
Node: make install6611038
Ref: using/configure make-install6611149
Ref: 1d496611149
Node: make test6611240
Ref: using/configure make-test6611354
Ref: 1d4a6611354
Node: make buildbottest6611695
Ref: using/configure make-buildbottest6611811
Ref: 1d4b6611811
Node: make regen-all6612009
Ref: using/configure make-regen-all6612107
Ref: 1d4c6612107
Node: C extensions6612408
Ref: using/configure c-extensions6612515
Ref: 1d4d6612515
Node: Compiler and linker flags6614183
Ref: using/configure compiler-and-linker-flags6614304
Ref: 1d4e6614304
Node: Preprocessor flags6614537
Ref: using/configure preprocessor-flags6614640
Ref: 1d4f6614640
Ref: using/configure envvar-CONFIGURE_CPPFLAGS6614695
Ref: 1d506614695
Ref: using/configure envvar-CPPFLAGS6614852
Ref: 145e6614852
Ref: using/configure envvar-BASECPPFLAGS6615219
Ref: 1d516615219
Ref: using/configure envvar-PY_CPPFLAGS6615279
Ref: 1d526615279
Node: Compiler flags6615524
Ref: using/configure compiler-flags6615648
Ref: 1d536615648
Ref: using/configure envvar-CC6615695
Ref: 145b6615695
Ref: using/configure envvar-CXX6615794
Ref: 1d546615794
Ref: using/configure envvar-CFLAGS6615880
Ref: 145c6615880
Ref: using/configure envvar-CFLAGS_NODIST6615945
Ref: 1d556615945
Ref: using/configure envvar-COMPILEALL_OPTS6616743
Ref: 1d566616743
Ref: using/configure envvar-EXTRA_CFLAGS6616943
Ref: 1d576616943
Ref: using/configure envvar-CONFIGURE_CFLAGS6617005
Ref: 1d586617005
Ref: using/configure envvar-CONFIGURE_CFLAGS_NODIST6617158
Ref: 1d596617158
Ref: using/configure envvar-BASECFLAGS6617325
Ref: 1d5a6617325
Ref: using/configure envvar-OPT6617382
Ref: 1d1d6617382
Ref: using/configure envvar-CFLAGS_ALIASING6617431
Ref: 1d5b6617431
Ref: using/configure envvar-CCSHARED6617578
Ref: 1d5c6617578
Ref: using/configure envvar-CFLAGSFORSHARED6617719
Ref: 1d5d6617719
Ref: using/configure envvar-PY_CFLAGS6617932
Ref: 1d5e6617932
Ref: using/configure envvar-PY_CFLAGS_NODIST6618055
Ref: 1d5f6618055
Ref: using/configure envvar-PY_STDMODULE_CFLAGS6618219
Ref: 1d606618219
Ref: using/configure envvar-PY_CORE_CFLAGS6618442
Ref: 1d616618442
Ref: using/configure envvar-PY_BUILTIN_MODULE_CFLAGS6618565
Ref: 1d626618565
Ref: using/configure envvar-PURIFY6618833
Ref: 1d636618833
Ref: Compiler flags-Footnote-16618995
Node: Linker flags6619050
Ref: using/configure linker-flags6619147
Ref: 1d646619147
Ref: using/configure envvar-LINKCC6619190
Ref: 1d656619190
Ref: using/configure envvar-CONFIGURE_LDFLAGS6619343
Ref: 1d666619343
Ref: using/configure envvar-LDFLAGS_NODIST6619682
Ref: 1d676619682
Ref: using/configure envvar-CONFIGURE_LDFLAGS_NODIST6620271
Ref: 1d686620271
Ref: using/configure envvar-LDFLAGS6620440
Ref: 145d6620440
Ref: using/configure envvar-LIBS6620776
Ref: 1d696620776
Ref: using/configure envvar-LDSHARED6620919
Ref: 1d6a6620919
Ref: using/configure envvar-BLDSHARED6621035
Ref: 1d6b6621035
Ref: using/configure envvar-PY_LDFLAGS6621172
Ref: 1d6c6621172
Ref: using/configure envvar-PY_LDFLAGS_NODIST6621256
Ref: 1d6d6621256
Ref: using/configure envvar-PY_CORE_LDFLAGS6621389
Ref: 1d6e6621389
Ref: Linker flags-Footnote-16621568
Node: Windows で Python を使う6621623
Ref: using/windows doc6621786
Ref: 1d6f6621786
Ref: using/windows using-on-windows6621786
Ref: a756621786
Ref: using/windows using-python-on-windows6621786
Ref: 1d706621786
Ref: Windows で Python を使う-Footnote-16625052
Ref: Windows で Python を使う-Footnote-26625094
Node: 完全版インストーラ6625136
Ref: using/windows the-full-installer6625271
Ref: 1d746625271
Ref: using/windows windows-full6625271
Ref: 1d716625271
Node: インストール手順6625721
Ref: using/windows installation-steps6625851
Ref: 1d756625851
Node: MAX_PATH の制限を除去する6629031
Ref: using/windows max-path6629229
Ref: c0f6629229
Ref: using/windows removing-the-max-path-limitation6629229
Ref: 1d776629229
Node: インストーラの GUI なしでインストールする6630321
Ref: using/windows install-quiet-option6630540
Ref: 5b86630540
Ref: using/windows installing-without-ui6630540
Ref: 1d786630540
Node: ダウンロード不要なインストール6643185
Ref: using/windows install-layout-option6643401
Ref: 1d766643401
Ref: using/windows installing-without-downloading6643401
Ref: 1d796643401
Node: インストール後の変更6644904
Ref: using/windows modifying-an-install6645139
Ref: 1d7a6645139
Node: フリースレッドバイナリ Free-threaded Binaries のインストール6646500
Ref: using/windows install-freethreaded-windows6646681
Ref: 1586646681
Ref: using/windows installing-free-threaded-binaries6646681
Ref: 1d7b6646681
Ref: フリースレッドバイナリ Free-threaded Binaries のインストール-Footnote-16648727
Node: Microsoft ストアパッケージ6648769
Ref: using/windows the-microsoft-store-package6648938
Ref: 1d7c6648938
Ref: using/windows windows-store6648938
Ref: 1b516648938
Node: 既知の問題6651675
Ref: using/windows known-issues6651761
Ref: 1d7d6651761
Node: Redirection of local data registry and temporary paths6651931
Ref: using/windows redirection-of-local-data-registry-and-temporary-paths6652037
Ref: 1d7e6652037
Ref: Redirection of local data registry and temporary paths-Footnote-16654392
Node: nuget org パッケージ6654483
Ref: using/windows the-nuget-org-packages6654661
Ref: 1d7f6654661
Ref: using/windows windows-nuget6654661
Ref: 1d726654661
Ref: nuget org パッケージ-Footnote-16657888
Ref: nuget org パッケージ-Footnote-26657919
Ref: nuget org パッケージ-Footnote-36657965
Ref: nuget org パッケージ-Footnote-46658014
Node: フリースレッドパッケージ Free-threaded packages6658065
Ref: using/windows free-threaded-packages6658186
Ref: 1d806658186
Ref: フリースレッドパッケージ Free-threaded packages-Footnote-16659008
Ref: フリースレッドパッケージ Free-threaded packages-Footnote-26659067
Ref: フリースレッドパッケージ Free-threaded packages-Footnote-36659129
Node: 埋め込み可能なパッケージ6659193
Ref: using/windows the-embeddable-package6659355
Ref: 1d816659355
Ref: using/windows windows-embeddable6659355
Ref: 1d736659355
Ref: 埋め込み可能なパッケージ-Footnote-16661683
Node: Python アプリケーション6661797
Ref: using/windows python-application6661932
Ref: 1d826661932
Node: Python の埋め込み6664112
Ref: using/windows embedding-python6664247
Ref: 1d836664247
Node: 別のバンドル6665304
Ref: using/windows alternative-bundles6665466
Ref: 1d846665466
Ref: 別のバンドル-Footnote-16666773
Ref: 別のバンドル-Footnote-26666826
Ref: 別のバンドル-Footnote-36666869
Ref: 別のバンドル-Footnote-46666921
Ref: 別のバンドル-Footnote-56667088
Node: Python を構成する<2>6667125
Ref: using/windows configuring-python6667266
Ref: 1d856667266
Node: 補足 環境変数の設定6668037
Ref: using/windows excursus-setting-environment-variables6668176
Ref: 1d866668176
Ref: using/windows setting-envvars6668176
Ref: 1b526668176
Node: Python 実行ファイルを見つける6671000
Ref: using/windows finding-the-python-executable6671139
Ref: 1d876671139
Ref: using/windows windows-path-mod6671139
Ref: 10246671139
Node: UTF-8 モード6673036
Ref: using/windows utf-8-mode6673190
Ref: 1d886673190
Ref: using/windows win-utf8-mode6673190
Ref: 1d896673190
Ref: UTF-8 モード-Footnote-16674708
Ref: UTF-8 モード-Footnote-26674750
Node: Windows の Python ランチャ6674792
Ref: using/windows launcher6674945
Ref: 5886674945
Ref: using/windows python-launcher-for-windows6674945
Ref: 1d8a6674945
Ref: Windows の Python ランチャ-Footnote-16676054
Node: 最初に6676096
Ref: using/windows getting-started6676206
Ref: 1d8b6676206
Node: コマンドラインから起動する6676456
Ref: using/windows from-the-command-line6676583
Ref: 1d8c6676583
Ref: コマンドラインから起動する-Footnote-16679618
Node: 仮想環境 Virtual environments6679660
Ref: using/windows virtual-environments6679829
Ref: 1d8d6679829
Node: スクリプトから起動する6680496
Ref: using/windows from-a-script6680671
Ref: 1d8e6680671
Node: ファイルの関連付けから起動する6682066
Ref: using/windows from-file-associations6682199
Ref: 1d8f6682199
Node: シェバン shebang 行6682918
Ref: using/windows shebang-lines6683061
Ref: 1d906683061
Node: シェバン行の引数6687816
Ref: using/windows arguments-in-shebang-lines6687968
Ref: 1d926687968
Node: カスタマイズ6688347
Ref: using/windows customization6688481
Ref: 1d936688481
Node: INI ファイルによるカスタマイズ6688653
Ref: using/windows customization-via-ini-files6688820
Ref: 1d946688820
Ref: using/windows launcher-ini6688820
Ref: 1d916688820
Node: デフォルトのPythonバージョンのカスタマイズ6689739
Ref: using/windows customizing-default-python-versions6689906
Ref: 1d956689906
Node: 診断6694847
Ref: using/windows diagnostics6694964
Ref: 1d966694964
Node: Dry Run6695572
Ref: using/windows dry-run6695688
Ref: 1d976695688
Node: Install on demand6696120
Ref: using/windows install-on-demand6696242
Ref: 1d986696242
Node: Return codes6696823
Ref: using/windows return-codes6696929
Ref: 1d996696929
Node: モジュールの検索6698682
Ref: using/windows finding-modules6698844
Ref: 1d9a6698844
Ref: using/windows windows-finding-modules6698844
Ref: bef6698844
Node: 追加のモジュール6705052
Ref: using/windows additional-modules6705229
Ref: 1d9b6705229
Node: PyWin326705750
Ref: using/windows pywin326705836
Ref: 1d9d6705836
Ref: PyWin32-Footnote-16706509
Ref: PyWin32-Footnote-26706551
Ref: PyWin32-Footnote-36706640
Ref: PyWin32-Footnote-46706709
Ref: PyWin32-Footnote-56706803
Ref: PyWin32-Footnote-66706862
Node: cx_Freeze6706912
Ref: using/windows cx-freeze6706998
Ref: 1d9e6706998
Ref: cx_Freeze-Footnote-16707274
Node: Windows 上で Python をコンパイルする6707326
Ref: using/windows compiling-python-on-windows6707512
Ref: 1d9f6707512
Ref: Windows 上で Python をコンパイルする-Footnote-16708467
Ref: Windows 上で Python をコンパイルする-Footnote-26708516
Node: ほかのプラットフォーム6708579
Ref: using/windows other-platforms6708732
Ref: 1da16708732
Ref: ほかのプラットフォーム-Footnote-16709532
Ref: ほかのプラットフォーム-Footnote-26709574
Ref: ほかのプラットフォーム-Footnote-36709616
Ref: ほかのプラットフォーム-Footnote-46709671
Ref: ほかのプラットフォーム-Footnote-56709699
Ref: ほかのプラットフォーム-Footnote-66709756
Node: Using Python on macOS6709806
Ref: using/mac doc6709970
Ref: 1da26709970
Ref: using/mac using-on-mac6709970
Ref: 1da36709970
Ref: using/mac using-python-on-macos6709970
Ref: 1da46709970
Ref: using/mac getting-osx6710679
Ref: 1da66710679
Ref: Using Python on macOS-Footnote-16710975
Node: Using Python for macOS from python org6711017
Ref: using/mac getting-and-installing-macpython6711147
Ref: 1da76711147
Ref: using/mac using-python-for-macos-from-python-org6711147
Ref: 1da86711147
Node: インストール手順<2>6711355
Ref: using/mac installation-steps6711503
Ref: 1da96711503
Ref: インストール手順<2>-Footnote-16716646
Ref: インストール手順<2>-Footnote-26716688
Ref: インストール手順<2>-Footnote-36716736
Ref: インストール手順<2>-Footnote-46716791
Ref: インストール手順<2>-Footnote-56716838
Node: Python スクリプトの実行方法6716887
Ref: using/mac how-to-run-a-python-script6717035
Ref: 1daa6717035
Node: Alternative Distributions6718998
Ref: using/mac alternative-bundles6719190
Ref: 1da56719190
Ref: using/mac alternative-distributions6719190
Ref: 1dac6719190
Ref: Alternative Distributions-Footnote-16720264
Ref: Alternative Distributions-Footnote-26720317
Ref: Alternative Distributions-Footnote-36720360
Ref: Alternative Distributions-Footnote-46720384
Node: 追加の Python パッケージのインストール6720417
Ref: using/mac installing-additional-python-packages6720596
Ref: 1dad6720596
Ref: using/mac mac-package-manager6720596
Ref: 1dae6720596
Ref: using/mac osx-gui-scripts6720767
Ref: 1daf6720767
Ref: 追加の Python パッケージのインストール-Footnote-16720805
Node: GUI プログラミング6720884
Ref: using/mac gui-programming6721059
Ref: 1db06721059
Ref: using/mac gui-programming-on-the-mac6721059
Ref: 1db16721059
Ref: GUI プログラミング-Footnote-16722035
Ref: GUI プログラミング-Footnote-26722076
Ref: GUI プログラミング-Footnote-36722116
Ref: GUI プログラミング-Footnote-46722157
Ref: GUI プログラミング-Footnote-56722211
Ref: GUI プログラミング-Footnote-66722236
Ref: GUI プログラミング-Footnote-76722272
Ref: GUI プログラミング-Footnote-86722300
Node: 高度なトピック6722329
Ref: using/mac advanced-topics6722469
Ref: 1db26722469
Node: フリースレッドバイナリ Free-threaded Binaries のインストール<2>6722818
Ref: using/mac install-freethreaded-macos6722999
Ref: 1596722999
Ref: using/mac installing-free-threaded-binaries6722999
Ref: 1db36722999
Ref: フリースレッドバイナリ Free-threaded Binaries のインストール<2>-Footnote-16728151
Node: Installing using the command line6728193
Ref: using/mac installing-using-the-command-line6728423
Ref: 1db46728423
Node: Python アプリケーションの配布6731254
Ref: using/mac distributing-python-applications6731437
Ref: 1db56731437
Ref: using/mac distributing-python-applications-on-the-mac6731437
Ref: 1db66731437
Ref: Python アプリケーションの配布-Footnote-16732109
Ref: Python アプリケーションの配布-Footnote-26732150
Ref: Python アプリケーションの配布-Footnote-36732191
Ref: Python アプリケーションの配布-Footnote-46732219
Node: App Store コンプライアンス6732252
Ref: using/mac app-store-compliance6732393
Ref: 1db76732393
Ref: App Store コンプライアンス-Footnote-16733519
Node: 他のリソース6733613
Ref: using/mac other-resources6733719
Ref: 1db86733719
Ref: 他のリソース-Footnote-16733985
Ref: 他のリソース-Footnote-26734028
Node: Using Python on Android6734097
Ref: using/android doc6734252
Ref: 1db96734252
Ref: using/android using-android6734252
Ref: 1dba6734252
Ref: using/android using-python-on-android6734252
Ref: 1dbb6734252
Node: Adding Python to an Android app6735441
Ref: using/android adding-python-to-an-android-app6735532
Ref: 1dbe6735532
Ref: Adding Python to an Android app-Footnote-16736921
Ref: Adding Python to an Android app-Footnote-26736962
Ref: Adding Python to an Android app-Footnote-36737003
Ref: Adding Python to an Android app-Footnote-46737039
Ref: Adding Python to an Android app-Footnote-56737106
Ref: Adding Python to an Android app-Footnote-66737137
Ref: Adding Python to an Android app-Footnote-76737205
Ref: Adding Python to an Android app-Footnote-86737275
Ref: Adding Python to an Android app-Footnote-96737365
Ref: Adding Python to an Android app-Footnote-106737487
Node: Using Python on iOS6737588
Ref: using/ios doc6737741
Ref: 1dbf6737741
Ref: using/ios using-ios6737741
Ref: 1dc06737741
Ref: using/ios using-python-on-ios6737741
Ref: 1dc16737741
Ref: Using Python on iOS-Footnote-16739244
Ref: Using Python on iOS-Footnote-26739272
Node: Python at runtime on iOS6739297
Ref: using/ios python-at-runtime-on-ios6739410
Ref: 1dc26739410
Node: iOS version compatibility6739631
Ref: using/ios ios-version-compatibility6739749
Ref: 1dc36739749
Node: Platform identification6740281
Ref: using/ios platform-identification6740437
Ref: 1dc46740437
Node: Standard library availability6741079
Ref: using/ios standard-library-availability6741234
Ref: 1dc76741234
Node: Binary extension modules6741457
Ref: using/ios binary-extension-modules6741611
Ref: 1dc86741611
Node: Compiler stub binaries6744469
Ref: using/ios compiler-stub-binaries6744585
Ref: 1dcc6744585
Node: Installing Python on iOS6745973
Ref: using/ios installing-python-on-ios6746115
Ref: 1dcd6746115
Node: Tools for building iOS apps6746256
Ref: using/ios tools-for-building-ios-apps6746384
Ref: 1dce6746384
Node: Adding Python to an iOS project6747163
Ref: using/ios adding-ios6747291
Ref: 1dc96747291
Ref: using/ios adding-python-to-an-ios-project6747291
Ref: 1dcf6747291
Ref: Adding Python to an iOS project-Footnote-16755954
Ref: Adding Python to an iOS project-Footnote-26755999
Node: App Store Compliance6756066
Ref: using/ios app-store-compliance6756175
Ref: 1dd06756175
Ref: App Store Compliance-Footnote-16757062
Node: エディタと IDE6757156
Ref: using/editors doc6757277
Ref: 1dd16757277
Ref: using/editors editors6757277
Ref: 1dab6757277
Ref: using/editors editors-and-ides6757277
Ref: 1dd26757277
Ref: エディタと IDE-Footnote-16757725
Ref: エディタと IDE-Footnote-26757767
Ref: エディタと IDE-Footnote-36757818
Node: Python 言語リファレンス6757889
Ref: reference/index doc6758043
Ref: 1dd36758043
Ref: reference/index reference-index6758043
Ref: 12b6758043
Ref: reference/index the-python-language-reference6758043
Ref: 1dd46758043
Node: はじめに<5>6759553
Ref: reference/introduction doc6759657
Ref: 1dd56759657
Ref: reference/introduction id16759657
Ref: 1dd66759657
Ref: reference/introduction introduction6759657
Ref: 1dd76759657
Node: 別のPythonの実装6762227
Ref: reference/introduction alternate-implementations6762348
Ref: 1dd86762348
Ref: reference/introduction implementations6762348
Ref: 1c906762348
Ref: 別のPythonの実装-Footnote-16765224
Ref: 別のPythonの実装-Footnote-26765256
Ref: 別のPythonの実装-Footnote-36765293
Ref: 別のPythonの実装-Footnote-46765325
Node: 本マニュアルにおける表記法6765351
Ref: reference/introduction id26765472
Ref: 1dd96765472
Ref: reference/introduction notation6765472
Ref: 1dda6765472
Ref: reference/introduction grammar-token-notation-name6765708
Ref: 1ddb6765708
Ref: reference/introduction grammar-token-notation-lc_letter6765756
Ref: 1ddc6765756
Ref: 本マニュアルにおける表記法-Footnote-16768488
Node: 字句解析6768551
Ref: reference/lexical_analysis doc6768682
Ref: 1ddd6768682
Ref: reference/lexical_analysis lexical6768682
Ref: 1dde6768682
Ref: reference/lexical_analysis lexical-analysis6768682
Ref: 1ddf6768682
Ref: 字句解析-Footnote-16769754
Node: 行構造6769796
Ref: reference/lexical_analysis id16769887
Ref: 1de06769887
Ref: reference/lexical_analysis line-structure6769887
Ref: 1de16769887
Node: 論理行 logical line6770379
Ref: reference/lexical_analysis id26770479
Ref: 1de26770479
Ref: reference/lexical_analysis logical-lines6770479
Ref: 1de36770479
Node: 物理行 physical line6770982
Ref: reference/lexical_analysis id36771112
Ref: 1de46771112
Ref: reference/lexical_analysis physical-lines6771112
Ref: 1de56771112
Node: コメント Comments6772085
Ref: reference/lexical_analysis comments6772235
Ref: 1de66772235
Ref: reference/lexical_analysis id46772235
Ref: 1de76772235
Node: エンコード宣言 encoding declaration6772613
Ref: reference/lexical_analysis encoding-declarations6772761
Ref: 1de86772761
Ref: reference/lexical_analysis encodings6772761
Ref: 1de96772761
Node: 明示的な行継続6774215
Ref: reference/lexical_analysis explicit-joining6774366
Ref: 1dea6774366
Ref: reference/lexical_analysis explicit-line-joining6774366
Ref: 1deb6774366
Node: 非明示的な行継続6775755
Ref: reference/lexical_analysis implicit-joining6775870
Ref: 1dec6775870
Ref: reference/lexical_analysis implicit-line-joining6775870
Ref: 1ded6775870
Node: 空行6776899
Ref: reference/lexical_analysis blank-lines6777008
Ref: 1dee6777008
Ref: reference/lexical_analysis id56777008
Ref: 1def6777008
Node: インデント6777626
Ref: reference/lexical_analysis id66777735
Ref: 1df06777735
Ref: reference/lexical_analysis indentation6777735
Ref: 1df16777735
Node: トークン間の空白6782374
Ref: reference/lexical_analysis whitespace6782468
Ref: 1df26782468
Ref: reference/lexical_analysis whitespace-between-tokens6782468
Ref: 1df36782468
Node: その他のトークン6783033
Ref: reference/lexical_analysis id76783186
Ref: 1df46783186
Ref: reference/lexical_analysis other-tokens6783186
Ref: 1df56783186
Node: 識別子 identifier およびキーワード keyword6783813
Ref: reference/lexical_analysis identifiers6783969
Ref: 1df66783969
Ref: reference/lexical_analysis identifiers-and-keywords6783969
Ref: 1df76783969
Ref: reference/lexical_analysis grammar-token-python-grammar-identifier6784952
Ref: 1df86784952
Ref: reference/lexical_analysis grammar-token-python-grammar-id_start6784998
Ref: 1df96784998
Ref: reference/lexical_analysis grammar-token-python-grammar-id_continue6785147
Ref: 1dfa6785147
Ref: reference/lexical_analysis grammar-token-python-grammar-xid_start6785295
Ref: 1dfb6785295
Ref: reference/lexical_analysis grammar-token-python-grammar-xid_continue6785402
Ref: 1dfc6785402
Ref: 識別子 identifier およびキーワード keyword-Footnote-16786802
Ref: 識別子 identifier およびキーワード keyword-Footnote-26786844
Ref: 識別子 identifier およびキーワード keyword-Footnote-36786886
Node: キーワード keyword6786949
Ref: reference/lexical_analysis id86787095
Ref: 1dfd6787095
Ref: reference/lexical_analysis keywords6787095
Ref: 1dfe6787095
Node: ソフトキーワード6787805
Ref: reference/lexical_analysis id96788019
Ref: 1dff6788019
Ref: reference/lexical_analysis soft-keywords6788019
Ref: 7d76788019
Node: 予約済みの識別子種 reserved classes of identifiers6788750
Ref: reference/lexical_analysis id-classes6788932
Ref: 1e006788932
Ref: reference/lexical_analysis reserved-classes-of-identifiers6788932
Ref: 1e016788932
Node: リテラル6791383
Ref: reference/lexical_analysis id106791524
Ref: 1e036791524
Ref: reference/lexical_analysis literals6791524
Ref: 1e046791524
Node: 文字列およびバイト列リテラル6791969
Ref: reference/lexical_analysis string-and-bytes-literals6792113
Ref: 1e056792113
Ref: reference/lexical_analysis strings6792113
Ref: 1e066792113
Ref: reference/lexical_analysis grammar-token-python-grammar-stringliteral6792271
Ref: 1e076792271
Ref: reference/lexical_analysis grammar-token-python-grammar-stringprefix6792337
Ref: 1e086792337
Ref: reference/lexical_analysis grammar-token-python-grammar-shortstring6792477
Ref: 1e096792477
Ref: reference/lexical_analysis grammar-token-python-grammar-longstring6792554
Ref: 1e0a6792554
Ref: reference/lexical_analysis grammar-token-python-grammar-shortstringitem6792637
Ref: 1e0b6792637
Ref: reference/lexical_analysis grammar-token-python-grammar-longstringitem6792696
Ref: 1e0c6792696
Ref: reference/lexical_analysis grammar-token-python-grammar-shortstringchar6792754
Ref: 1e0d6792754
Ref: reference/lexical_analysis grammar-token-python-grammar-longstringchar6792837
Ref: 1e0e6792837
Ref: reference/lexical_analysis grammar-token-python-grammar-stringescapeseq6792896
Ref: 1e0f6792896
Ref: reference/lexical_analysis grammar-token-python-grammar-bytesliteral6792949
Ref: 1e106792949
Ref: reference/lexical_analysis grammar-token-python-grammar-bytesprefix6793009
Ref: 1e116793009
Ref: reference/lexical_analysis grammar-token-python-grammar-shortbytes6793099
Ref: 1e126793099
Ref: reference/lexical_analysis grammar-token-python-grammar-longbytes6793173
Ref: 1e136793173
Ref: reference/lexical_analysis grammar-token-python-grammar-shortbytesitem6793253
Ref: 1e146793253
Ref: reference/lexical_analysis grammar-token-python-grammar-longbytesitem6793309
Ref: 1e156793309
Ref: reference/lexical_analysis grammar-token-python-grammar-shortbyteschar6793364
Ref: 1e166793364
Ref: reference/lexical_analysis grammar-token-python-grammar-longbyteschar6793445
Ref: 1e176793445
Ref: reference/lexical_analysis grammar-token-python-grammar-bytesescapeseq6793502
Ref: 1e186793502
Ref: 文字列およびバイト列リテラル-Footnote-16796903
Node: Escape sequences6796945
Ref: reference/lexical_analysis escape-sequences6797040
Ref: 4266797040
Ref: reference/lexical_analysis id116797040
Ref: 1e196797040
Ref: Escape sequences-Footnote-16804390
Node: 文字列リテラルの結合 concatenation6804462
Ref: reference/lexical_analysis string-concatenation6804624
Ref: 1e1a6804624
Ref: reference/lexical_analysis string-literal-concatenation6804624
Ref: 1e1b6804624
Ref: reference/lexical_analysis f-strings6806075
Ref: 9776806075
Node: f-strings6806075
Ref: reference/lexical_analysis formatted-string-literals6806213
Ref: 1e1c6806213
Ref: reference/lexical_analysis id136806213
Ref: 1e1d6806213
Ref: reference/lexical_analysis grammar-token-python-grammar-f_string6807097
Ref: 1e1e6807097
Ref: reference/lexical_analysis grammar-token-python-grammar-replacement_field6807174
Ref: 1e1f6807174
Ref: reference/lexical_analysis grammar-token-python-grammar-f_expression6807263
Ref: 1e206807263
Ref: reference/lexical_analysis grammar-token-python-grammar-conversion6807458
Ref: 1e216807458
Ref: reference/lexical_analysis grammar-token-python-grammar-format_spec6807501
Ref: 1e226807501
Ref: reference/lexical_analysis grammar-token-python-grammar-literal_char6807564
Ref: 1e236807564
Ref: f-strings-Footnote-16813725
Node: 数値リテラル6813767
Ref: reference/lexical_analysis numbers6813879
Ref: 1e246813879
Ref: reference/lexical_analysis numeric-literals6813879
Ref: 1e256813879
Node: 整数リテラル6814379
Ref: reference/lexical_analysis integer-literals6814505
Ref: 1e266814505
Ref: reference/lexical_analysis integers6814505
Ref: 1e276814505
Ref: reference/lexical_analysis grammar-token-python-grammar-integer6814620
Ref: 1e286814620
Ref: reference/lexical_analysis grammar-token-python-grammar-decinteger6814692
Ref: 1e296814692
Ref: reference/lexical_analysis grammar-token-python-grammar-bininteger6814762
Ref: 1e2a6814762
Ref: reference/lexical_analysis grammar-token-python-grammar-octinteger6814818
Ref: 1e2b6814818
Ref: reference/lexical_analysis grammar-token-python-grammar-hexinteger6814874
Ref: 1e2c6814874
Ref: reference/lexical_analysis grammar-token-python-grammar-nonzerodigit6814930
Ref: 1e2d6814930
Ref: reference/lexical_analysis grammar-token-python-grammar-digit6814962
Ref: 1e2e6814962
Ref: reference/lexical_analysis grammar-token-python-grammar-bindigit6814994
Ref: 1e2f6814994
Ref: reference/lexical_analysis grammar-token-python-grammar-octdigit6815026
Ref: 1e306815026
Ref: reference/lexical_analysis grammar-token-python-grammar-hexdigit6815058
Ref: 1e316815058
Node: Floating-point literals6816221
Ref: reference/lexical_analysis floating6816358
Ref: 1e326816358
Ref: reference/lexical_analysis floating-point-literals6816358
Ref: 1e336816358
Ref: reference/lexical_analysis grammar-token-python-grammar-floatnumber6816500
Ref: 1e346816500
Ref: reference/lexical_analysis grammar-token-python-grammar-pointfloat6816550
Ref: 1e356816550
Ref: reference/lexical_analysis grammar-token-python-grammar-exponentfloat6816610
Ref: 1e366816610
Ref: reference/lexical_analysis grammar-token-python-grammar-digitpart6816667
Ref: 1e376816667
Ref: reference/lexical_analysis grammar-token-python-grammar-fraction6816711
Ref: 1e386816711
Ref: reference/lexical_analysis grammar-token-python-grammar-exponent6816748
Ref: 1e396816748
Node: 虚数 imaginary リテラル6817374
Ref: reference/lexical_analysis imaginary6817484
Ref: 1e3a6817484
Ref: reference/lexical_analysis imaginary-literals6817484
Ref: 1e3b6817484
Ref: reference/lexical_analysis grammar-token-python-grammar-imagnumber6817634
Ref: 1e3c6817634
Node: 演算子6818097
Ref: reference/lexical_analysis id146818207
Ref: 1e3d6818207
Ref: reference/lexical_analysis operators6818207
Ref: 1e3e6818207
Node: デリミタ delimiter6818446
Ref: reference/lexical_analysis delimiters6818535
Ref: 1e3f6818535
Ref: reference/lexical_analysis id156818535
Ref: 1e406818535
Node: データモデル6819711
Ref: reference/datamodel doc6819842
Ref: 1e416819842
Ref: reference/datamodel data-model6819842
Ref: 1e426819842
Ref: reference/datamodel datamodel6819842
Ref: 18dc6819842
Node: オブジェクト、値、および型6820006
Ref: reference/datamodel objects6820127
Ref: 1e436820127
Ref: reference/datamodel objects-values-and-types6820127
Ref: 1e446820127
Ref: オブジェクト、値、および型-Footnote-16826855
Node: 標準型の階層6827130
Ref: reference/datamodel the-standard-type-hierarchy6827281
Ref: 1e456827281
Ref: reference/datamodel types6827281
Ref: 1e466827281
Node: None6828862
Ref: reference/datamodel none6828944
Ref: 1e476828944
Node: NotImplemented6829426
Ref: reference/datamodel notimplemented6829525
Ref: 1e486829525
Node: Ellipsis6830355
Ref: reference/datamodel ellipsis6830464
Ref: 1e4a6830464
Node: numbers Number6830804
Ref: reference/datamodel numbers-number6830926
Ref: 1e4b6830926
Node: numbers Integral 整数6832432
Ref: reference/datamodel numbers-integral6832540
Ref: 1e4c6832540
Node: numbers Real float 実数6833870
Ref: reference/datamodel numbers-real-float6834010
Ref: 1e4d6834010
Node: numbers Complex complex6834611
Ref: reference/datamodel numbers-complex-complex6834719
Ref: 1e4e6834719
Node: シーケンス型 sequence6835099
Ref: reference/datamodel sequences6835225
Ref: 1e4f6835225
Node: 変更不能なシーケンス immutable sequence6836755
Ref: reference/datamodel immutable-sequences6836927
Ref: 1e506836927
Node: 変更可能なシーケンス型 mutable sequence6839637
Ref: reference/datamodel mutable-sequences6839809
Ref: 1e526839809
Node: 集合型<2>6841241
Ref: reference/datamodel set-types6841379
Ref: 1e536841379
Node: マッピング型 mapping6842911
Ref: reference/datamodel mappings6843057
Ref: 1e546843057
Node: 辞書型 dictionary<2>6843763
Ref: reference/datamodel dictionaries6843849
Ref: 1e556843849
Node: 呼び出し可能型 callable type6845546
Ref: reference/datamodel callable-types6845698
Ref: 1e566845698
Node: ユーザ定義関数 user-defined function6846581
Ref: reference/datamodel user-defined-funcs6846735
Ref: 2796846735
Ref: reference/datamodel user-defined-functions6846735
Ref: 1e576846735
Node: Special read-only attributes6847182
Ref: reference/datamodel special-read-only-attributes6847326
Ref: 1e586847326
Ref: reference/datamodel function __globals__6847725
Ref: 12a16847725
Ref: reference/datamodel function __closure__6848230
Ref: 129e6848230
Node: Special writable attributes6849050
Ref: reference/datamodel special-writable-attributes6849194
Ref: 1e5b6849194
Ref: reference/datamodel function __doc__6849651
Ref: 11a96849651
Ref: reference/datamodel function __name__6850014
Ref: 12a26850014
Ref: reference/datamodel function __qualname__6850308
Ref: 1e5c6850308
Ref: reference/datamodel function __module__6850755
Ref: 1e5d6850755
Ref: reference/datamodel function __defaults__6851113
Ref: 129f6851113
Ref: reference/datamodel function __code__6851607
Ref: 27a6851607
Ref: reference/datamodel function __dict__6851901
Ref: 12a06851901
Ref: reference/datamodel function __annotations__6852287
Ref: 11a86852287
Ref: reference/datamodel function __kwdefaults__6852913
Ref: ff26852913
Ref: reference/datamodel function __type_params__6853225
Ref: 1e5f6853225
Node: インスタンスメソッド6854218
Ref: reference/datamodel id26854424
Ref: 1e616854424
Ref: reference/datamodel instance-methods6854424
Ref: 1c286854424
Ref: reference/datamodel method __self__6854758
Ref: 13706854758
Ref: reference/datamodel method __func__6855061
Ref: 12ca6855061
Ref: reference/datamodel method __doc__6855281
Ref: 1e636855281
Ref: reference/datamodel method __name__6855773
Ref: 1e646855773
Ref: reference/datamodel method __module__6856071
Ref: 1e656856071
Ref: reference/datamodel method-binding6856640
Ref: 1e626856640
Node: ジェネレータ関数 generator function6858108
Ref: reference/datamodel generator-functions6858311
Ref: 1e666858311
Node: コルーチン関数 coroutine function6859116
Ref: reference/datamodel coroutine-functions6859354
Ref: 1e676859354
Node: 非同期ジェネレータ関数 asynchronous generator function6859930
Ref: reference/datamodel asynchronous-generator-functions6860161
Ref: 1e696860161
Node: 組み込み関数 built-in function6861258
Ref: reference/datamodel built-in-functions6861489
Ref: 1e6b6861489
Ref: reference/datamodel builtin-functions6861489
Ref: 1e606861489
Node: 組み込みメソッド built-in method6862309
Ref: reference/datamodel built-in-methods6862487
Ref: 1e6c6862487
Ref: reference/datamodel builtin-methods6862487
Ref: 1e6d6862487
Node: クラス<2>6863020
Ref: reference/datamodel classes6863192
Ref: 1e6e6863192
Ref: reference/datamodel id36863192
Ref: 1e6f6863192
Node: クラスのインスタンス6863546
Ref: reference/datamodel class-instances6863669
Ref: 1e706863669
Node: モジュール<3>6863896
Ref: reference/datamodel module-objects6864046
Ref: 1e716864046
Ref: reference/datamodel modules6864046
Ref: 1e726864046
Node: Import-related attributes on module objects6865120
Ref: reference/datamodel import-mod-attrs6865270
Ref: 1e746865270
Ref: reference/datamodel import-related-attributes-on-module-objects6865270
Ref: 1e756865270
Ref: reference/datamodel module __name__6866905
Ref: 13506866905
Ref: reference/datamodel module __spec__6867244
Ref: 1e776867244
Ref: reference/datamodel module __package__6867501
Ref: 2b96867501
Ref: reference/datamodel module __loader__6869603
Ref: 2c36869603
Ref: reference/datamodel module __path__6870828
Ref: 1bd86870828
Ref: reference/datamodel module __file__6871283
Ref: 1e7d6871283
Ref: reference/datamodel module __cached__6871315
Ref: 2b76871315
Ref: Import-related attributes on module objects-Footnote-16873298
Ref: Import-related attributes on module objects-Footnote-26873340
Node: Other writable attributes on module objects6873382
Ref: reference/datamodel other-writable-attributes-on-module-objects6873560
Ref: 1e7f6873560
Ref: reference/datamodel module __doc__6873783
Ref: 17bd6873783
Ref: reference/datamodel module __annotations__6873932
Ref: 1e806873932
Node: Module dictionaries6874281
Ref: reference/datamodel module-dictionaries6874407
Ref: 1e816874407
Ref: reference/datamodel module __dict__6874535
Ref: 1e826874535
Node: カスタムクラス型6875223
Ref: reference/datamodel class-attrs-and-methods6875380
Ref: 1e836875380
Ref: reference/datamodel custom-classes6875380
Ref: 1e846875380
Node: Special attributes6877110
Ref: reference/datamodel special-attributes6877213
Ref: 1e856877213
Ref: reference/datamodel type __name__6877585
Ref: 14506877585
Ref: reference/datamodel type __qualname__6877876
Ref: 1e866877876
Ref: reference/datamodel type __module__6878187
Ref: 34d6878187
Ref: reference/datamodel type __dict__6878416
Ref: c2b6878416
Ref: reference/datamodel type __bases__6878821
Ref: 14516878821
Ref: reference/datamodel type __doc__6879326
Ref: 1c166879326
Ref: reference/datamodel type __annotations__6879651
Ref: 1e876879651
Ref: reference/datamodel type __type_params__6881004
Ref: 1e886881004
Ref: reference/datamodel type __static_attributes__6881518
Ref: 1316881518
Ref: reference/datamodel type __firstlineno__6882062
Ref: 1326882062
Ref: reference/datamodel type __mro__6882711
Ref: 1e896882711
Node: Special methods6883018
Ref: reference/datamodel special-methods6883121
Ref: 1e8a6883121
Ref: reference/datamodel type mro6883294
Ref: 1e8b6883294
Ref: reference/datamodel type __subclasses__6883533
Ref: 53f6883533
Node: クラスインスタンス class instance6883889
Ref: reference/datamodel id46884090
Ref: 1e8c6884090
Node: Special attributes<2>6885854
Ref: reference/datamodel id56885954
Ref: 1e8f6885954
Ref: reference/datamodel object __class__6886011
Ref: 14526886011
Ref: reference/datamodel object __dict__6886114
Ref: 5266886114
Node: I/O オブジェクト ファイルオブジェクトの別名6886365
Ref: reference/datamodel i-o-objects-also-known-as-file-objects6886565
Ref: 1e916886565
Node: 内部型 internal type6887550
Ref: reference/datamodel internal-types6887699
Ref: 1e936887699
Node: コードオブジェクト6888533
Ref: reference/datamodel code-objects6888666
Ref: 1b46888666
Ref: reference/datamodel id66888666
Ref: 1e946888666
Node: Special read-only attributes<2>6889738
Ref: reference/datamodel id76889865
Ref: 1e956889865
Ref: reference/datamodel codeobject co_name6889975
Ref: 1e966889975
Ref: reference/datamodel codeobject co_qualname6890167
Ref: 1e976890167
Ref: reference/datamodel codeobject co_argcount6890505
Ref: 1e986890505
Ref: reference/datamodel codeobject co_posonlyargcount6890998
Ref: 1e996890998
Ref: reference/datamodel codeobject co_kwonlyargcount6891395
Ref: 1e9a6891395
Ref: reference/datamodel codeobject co_nlocals6891783
Ref: 1e9b6891783
Ref: reference/datamodel codeobject co_varnames6892096
Ref: 1e9c6892096
Ref: reference/datamodel codeobject co_cellvars6892492
Ref: 1e9d6892492
Ref: reference/datamodel codeobject co_freevars6892984
Ref: 1e5a6892984
Ref: reference/datamodel codeobject co_code6893735
Ref: 1ea06893735
Ref: reference/datamodel codeobject co_consts6894050
Ref: 1ea16894050
Ref: reference/datamodel codeobject co_names6894367
Ref: 1ea26894367
Ref: reference/datamodel codeobject co_filename6894685
Ref: 13356894685
Ref: reference/datamodel codeobject co_firstlineno6894967
Ref: 1ea36894967
Ref: reference/datamodel codeobject co_lnotab6895182
Ref: 2c16895182
Ref: reference/datamodel codeobject co_stacksize6895937
Ref: 1ea46895937
Ref: reference/datamodel codeobject co_flags6896146
Ref: 1ea56896146
Node: Methods on code objects6897384
Ref: reference/datamodel methods-on-code-objects6897511
Ref: 1ea76897511
Ref: reference/datamodel codeobject co_positions6897578
Ref: 57d6897578
Ref: reference/datamodel codeobject co_lines6899133
Ref: 2d26899133
Ref: reference/datamodel codeobject replace6900764
Ref: 1ea86900764
Ref: Methods on code objects-Footnote-16901057
Node: フレーム frame オブジェクト6901099
Ref: reference/datamodel frame-objects6901291
Ref: 6ab6901291
Ref: reference/datamodel id86901291
Ref: 1ea96901291
Node: Special read-only attributes<3>6901686
Ref: reference/datamodel id96901830
Ref: 1eaa6901830
Ref: reference/datamodel frame f_back6901934
Ref: 7576901934
Ref: reference/datamodel frame f_code6902264
Ref: 1eab6902264
Ref: reference/datamodel frame f_locals6902793
Ref: 1676902793
Ref: reference/datamodel frame f_globals6903535
Ref: 1eac6903535
Ref: reference/datamodel frame f_builtins6903835
Ref: 1ead6903835
Ref: reference/datamodel frame f_lasti6904141
Ref: 8556904141
Node: Special writable attributes<2>6904471
Ref: reference/datamodel id106904644
Ref: 1eae6904644
Ref: reference/datamodel frame f_trace6904747
Ref: 1eaf6904747
Ref: reference/datamodel frame f_trace_lines6905293
Ref: ba96905293
Ref: reference/datamodel frame f_trace_opcodes6905620
Ref: baa6905620
Ref: reference/datamodel frame f_lineno6906226
Ref: 7776906226
Node: Frame object methods6906770
Ref: reference/datamodel frame-object-methods6906903
Ref: 1eb06906903
Ref: reference/datamodel frame clear6907042
Ref: 2616907042
Node: トレースバック traceback オブジェクト6907737
Ref: reference/datamodel id116907939
Ref: 1eb16907939
Ref: reference/datamodel traceback-objects6907939
Ref: ac26907939
Ref: reference/datamodel traceback tb_frame6909320
Ref: 1eb26909320
Ref: reference/datamodel traceback tb_lineno6909966
Ref: 1eb36909966
Ref: reference/datamodel traceback tb_lasti6910186
Ref: 1eb46910186
Ref: reference/datamodel traceback tb_next6910550
Ref: ac16910550
Node: スライス slice オブジェクト6910841
Ref: reference/datamodel slice-objects6911057
Ref: 1eb56911057
Ref: reference/datamodel slice indices6911740
Ref: ff16911740
Node: 静的メソッド static method オブジェクト6912381
Ref: reference/datamodel static-method-objects6912586
Ref: 1eb96912586
Node: クラスメソッドオブジェクト6913554
Ref: reference/datamodel class-method-objects6913713
Ref: 1eba6913713
Node: 特殊メソッド名6914181
Ref: reference/datamodel special-method-names6914308
Ref: 1ebb6914308
Ref: reference/datamodel specialnames6914308
Ref: c3c6914308
Ref: 特殊メソッド名-Footnote-16916837
Node: 基本的なカスタマイズ6917176
Ref: reference/datamodel basic-customization6917321
Ref: 1ebf6917321
Ref: reference/datamodel customization6917321
Ref: 1ec06917321
Ref: reference/datamodel object __new__6917390
Ref: 54c6917390
Ref: reference/datamodel object __init__6919476
Ref: 67c6919476
Ref: reference/datamodel object __del__6920616
Ref: 1ec16920616
Ref: reference/datamodel object __repr__6924654
Ref: 5e86924654
Ref: reference/datamodel object __str__6925754
Ref: 5e96925754
Ref: reference/datamodel object __bytes__6926517
Ref: 5b26926517
Ref: reference/datamodel object __format__6926779
Ref: 5ea6926779
Ref: reference/datamodel richcmpfuncs6928277
Ref: 1ec26928277
Ref: reference/datamodel object __lt__6928277
Ref: 12d96928277
Ref: reference/datamodel object __le__6928323
Ref: 12da6928323
Ref: reference/datamodel object __eq__6928369
Ref: ac86928369
Ref: reference/datamodel object __ne__6928415
Ref: 14c16928415
Ref: reference/datamodel object __gt__6928461
Ref: 12db6928461
Ref: reference/datamodel object __ge__6928507
Ref: 12dc6928507
Ref: reference/datamodel object __hash__6931849
Ref: ac96931849
Ref: reference/datamodel object __bool__6937178
Ref: 12a36937178
Node: 属性値アクセスをカスタマイズする6937684
Ref: reference/datamodel attribute-access6937880
Ref: 1ec46937880
Ref: reference/datamodel customizing-attribute-access6937880
Ref: 1ec56937880
Ref: reference/datamodel object __getattr__6938214
Ref: 49f6938214
Ref: reference/datamodel object __getattribute__6939539
Ref: ba06939539
Ref: reference/datamodel object __setattr__6940932
Ref: 1e8d6940932
Ref: reference/datamodel object __delattr__6941789
Ref: 1e8e6941789
Ref: reference/datamodel object __dir__6942322
Ref: 1ec76942322
Node: モジュールの属性値アクセスをカスタマイズする6942771
Ref: reference/datamodel customizing-module-attribute-access6942970
Ref: 1ec86942970
Ref: モジュールの属性値アクセスをカスタマイズする-Footnote-16945505
Node: デスクリプタ descriptor の実装6945547
Ref: reference/datamodel descriptors6945788
Ref: c1d6945788
Ref: reference/datamodel implementing-descriptors6945788
Ref: 1ec96945788
Ref: reference/datamodel object __get__6946365
Ref: 14906946365
Ref: reference/datamodel object __set__6947484
Ref: 1eca6947484
Ref: reference/datamodel object __delete__6947953
Ref: 156c6947953
Ref: reference/datamodel object __objclass__6948213
Ref: 1ecc6948213
Ref: デスクリプタ descriptor の実装-Footnote-16948780
Node: デスクリプタの呼び出し6948822
Ref: reference/datamodel descriptor-invocation6949009
Ref: 1ecb6949009
Ref: reference/datamodel invoking-descriptors6949009
Ref: 1ecd6949009
Node: __slots__<2>6953367
Ref: reference/datamodel id136953506
Ref: 1ece6953506
Ref: reference/datamodel slots6953506
Ref: 1e906953506
Ref: reference/datamodel object __slots__6954006
Ref: 14936954006
Ref: reference/datamodel datamodel-note-slots6954443
Ref: 1ecf6954443
Node: クラス生成をカスタマイズする6958219
Ref: reference/datamodel class-customization6958454
Ref: c196958454
Ref: reference/datamodel customizing-class-creation6958454
Ref: 1ed26958454
Ref: reference/datamodel object __init_subclass__6959120
Ref: 5fd6959120
Ref: reference/datamodel object __set_name__6960802
Ref: c1c6960802
Node: メタクラス6961883
Ref: reference/datamodel id146962011
Ref: 1ed36962011
Ref: reference/datamodel metaclasses6962011
Ref: 1ed46962011
Node: MRO エントリの解決6963250
Ref: reference/datamodel resolving-mro-entries6963420
Ref: 1ed56963420
Ref: reference/datamodel object __mro_entries__6963482
Ref: 1ed66963482
Ref: MRO エントリの解決-Footnote-16964492
Node: 適切なメタクラスの決定6964534
Ref: reference/datamodel determining-the-appropriate-metaclass6964722
Ref: 1ed76964722
Node: クラスの名前空間の準備6965921
Ref: reference/datamodel prepare6966108
Ref: c2c6966108
Ref: reference/datamodel preparing-the-class-namespace6966108
Ref: 1ed86966108
Ref: クラスの名前空間の準備-Footnote-16967151
Node: クラス本体の実行6967193
Ref: reference/datamodel executing-the-class-body6967383
Ref: 1ed96967383
Node: クラスオブジェクトの作成6968353
Ref: reference/datamodel class-object-creation6968534
Ref: c186968534
Ref: reference/datamodel creating-the-class-object6968534
Ref: 1eda6968534
Ref: クラスオブジェクトの作成-Footnote-16971721
Node: メタクラスの用途6971763
Ref: reference/datamodel uses-for-metaclasses6971911
Ref: 1edb6971911
Node: インスタンスのカスタマイズとサブクラスチェック6972353
Ref: reference/datamodel customizing-instance-and-subclass-checks6972588
Ref: 1edc6972588
Ref: reference/datamodel type __instancecheck__6973196
Ref: 1edd6973196
Ref: reference/datamodel type __subclasscheck__6973508
Ref: 1ede6973508
Ref: インスタンスのカスタマイズとサブクラスチェック-Footnote-16974636
Node: ジェネリック型をエミュレートする6974678
Ref: reference/datamodel emulating-generic-types6974934
Ref: 1edf6974934
Ref: reference/datamodel object __class_getitem__6975943
Ref: 7066975943
Ref: ジェネリック型をエミュレートする-Footnote-16976464
Node: The purpose of __class_getitem__6976506
Ref: reference/datamodel the-purpose-of-class-getitem6976668
Ref: 1ee16976668
Node: __class_getitem__ versus __getitem__6977559
Ref: reference/datamodel class-getitem-versus-getitem6977721
Ref: 1ee36977721
Ref: reference/datamodel classgetitem-versus-getitem6977721
Ref: 1ee46977721
Ref: __class_getitem__ versus __getitem__-Footnote-16981085
Node: 呼び出し可能オブジェクトをエミュレートする6981127
Ref: reference/datamodel emulating-callable-objects6981353
Ref: 1ee86981353
Ref: reference/datamodel id156981353
Ref: 1ee96981353
Ref: reference/datamodel object __call__6981479
Ref: 5236981479
Node: コンテナをエミュレートする6981784
Ref: reference/datamodel emulating-container-types6981998
Ref: 1eea6981998
Ref: reference/datamodel sequence-types6981998
Ref: 1eeb6981998
Ref: reference/datamodel object __len__6984394
Ref: 1ec36984394
Ref: reference/datamodel object __length_hint__6985127
Ref: ed76985127
Ref: reference/datamodel object __getitem__6986003
Ref: 2646986003
Ref: reference/datamodel object __setitem__6987213
Ref: 146e6987213
Ref: reference/datamodel object __delitem__6987874
Ref: 146f6987874
Ref: reference/datamodel object __missing__6988420
Ref: 1ef36988420
Ref: reference/datamodel object __iter__6988694
Ref: 1ebc6988694
Ref: reference/datamodel object __reversed__6989192
Ref: 1ebd6989192
Ref: reference/datamodel object __contains__6990388
Ref: 1ebe6990388
Node: 数値型をエミュレートする6991189
Ref: reference/datamodel emulating-numeric-types6991383
Ref: 1ef56991383
Ref: reference/datamodel numeric-types6991383
Ref: 1ef66991383
Ref: reference/datamodel object __add__6991821
Ref: 1eed6991821
Ref: reference/datamodel object __sub__6991868
Ref: 1ef76991868
Ref: reference/datamodel object __mul__6991915
Ref: 1ef06991915
Ref: reference/datamodel object __matmul__6991962
Ref: 1ef86991962
Ref: reference/datamodel object __truediv__6992012
Ref: 149c6992012
Ref: reference/datamodel object __floordiv__6992063
Ref: 149d6992063
Ref: reference/datamodel object __mod__6992115
Ref: 1ef96992115
Ref: reference/datamodel object __divmod__6992162
Ref: 1efa6992162
Ref: reference/datamodel object __pow__6992212
Ref: 79e6992212
Ref: reference/datamodel object __lshift__6992269
Ref: 1efb6992269
Ref: reference/datamodel object __rshift__6992319
Ref: 1efc6992319
Ref: reference/datamodel object __and__6992369
Ref: 1efd6992369
Ref: reference/datamodel object __xor__6992416
Ref: 1efe6992416
Ref: reference/datamodel object __or__6992463
Ref: 1eff6992463
Ref: reference/datamodel object __radd__6993616
Ref: 1eee6993616
Ref: reference/datamodel object __rsub__6993664
Ref: 1f006993664
Ref: reference/datamodel object __rmul__6993712
Ref: 1ef16993712
Ref: reference/datamodel object __rmatmul__6993760
Ref: 1f016993760
Ref: reference/datamodel object __rtruediv__6993811
Ref: 1f026993811
Ref: reference/datamodel object __rfloordiv__6993863
Ref: 1f036993863
Ref: reference/datamodel object __rmod__6993916
Ref: 1f046993916
Ref: reference/datamodel object __rdivmod__6993964
Ref: 1f056993964
Ref: reference/datamodel object __rpow__6994015
Ref: 79f6994015
Ref: reference/datamodel object __rlshift__6994073
Ref: 1f066994073
Ref: reference/datamodel object __rrshift__6994124
Ref: 1f076994124
Ref: reference/datamodel object __rand__6994175
Ref: 1f086994175
Ref: reference/datamodel object __rxor__6994223
Ref: 1f096994223
Ref: reference/datamodel object __ror__6994271
Ref: 1f0a6994271
Ref: reference/datamodel object __iadd__6995745
Ref: 1eef6995745
Ref: reference/datamodel object __isub__6995793
Ref: 1f0b6995793
Ref: reference/datamodel object __imul__6995841
Ref: 1ef26995841
Ref: reference/datamodel object __imatmul__6995889
Ref: 1f0c6995889
Ref: reference/datamodel object __itruediv__6995940
Ref: 1f0d6995940
Ref: reference/datamodel object __ifloordiv__6995992
Ref: 1f0e6995992
Ref: reference/datamodel object __imod__6996045
Ref: 1f0f6996045
Ref: reference/datamodel object __ipow__6996093
Ref: 79c6996093
Ref: reference/datamodel object __ilshift__6996151
Ref: 1f106996151
Ref: reference/datamodel object __irshift__6996202
Ref: 1f116996202
Ref: reference/datamodel object __iand__6996253
Ref: 1f126996253
Ref: reference/datamodel object __ixor__6996301
Ref: 1f136996301
Ref: reference/datamodel object __ior__6996349
Ref: 1f146996349
Ref: reference/datamodel object __neg__6997573
Ref: 1f166997573
Ref: reference/datamodel object __pos__6997613
Ref: 1f176997613
Ref: reference/datamodel object __abs__6997653
Ref: 1f186997653
Ref: reference/datamodel object __invert__6997693
Ref: 1f196997693
Ref: reference/datamodel object __complex__6997862
Ref: 5b16997862
Ref: reference/datamodel object __int__6997906
Ref: 6e76997906
Ref: reference/datamodel object __float__6997946
Ref: 99a6997946
Ref: reference/datamodel object __index__6998186
Ref: 6e86998186
Ref: reference/datamodel object __round__6999043
Ref: 1f1a6999043
Ref: reference/datamodel object __trunc__6999096
Ref: 6e66999096
Ref: reference/datamodel object __floor__6999138
Ref: 1f1b6999138
Ref: reference/datamodel object __ceil__6999180
Ref: 1f1c6999180
Ref: 数値型をエミュレートする-Footnote-17000015
Ref: 数値型をエミュレートする-Footnote-27000329
Node: with文とコンテキストマネージャ7000612
Ref: reference/datamodel context-managers7000833
Ref: 1f1e7000833
Ref: reference/datamodel with-statement-context-managers7000833
Ref: 1f1f7000833
Ref: reference/datamodel object __enter__7001907
Ref: 5927001907
Ref: reference/datamodel object __exit__7002167
Ref: 12ce7002167
Ref: with文とコンテキストマネージャ-Footnote-17003271
Node: クラスパターンマッチの位置引数のカスタマイズ7003313
Ref: reference/datamodel class-pattern-matching7003520
Ref: 1f217003520
Ref: reference/datamodel customizing-positional-arguments-in-class-pattern-matching7003520
Ref: 1f227003520
Ref: reference/datamodel object __match_args__7004003
Ref: 182a7004003
Ref: クラスパターンマッチの位置引数のカスタマイズ-Footnote-17005078
Node: Emulating buffer types7005120
Ref: reference/datamodel emulating-buffer-types7005308
Ref: 1f237005308
Ref: reference/datamodel python-buffer-protocol7005308
Ref: 1f247005308
Ref: reference/datamodel object __buffer__7005765
Ref: 42b7005765
Ref: reference/datamodel object __release_buffer__7006250
Ref: 16587006250
Ref: Emulating buffer types-Footnote-17006989
Node: 特殊メソッド検索7007031
Ref: reference/datamodel special-lookup7007144
Ref: 1ec67007144
Ref: reference/datamodel special-method-lookup7007144
Ref: 1f257007144
Node: コルーチン7010188
Ref: reference/datamodel coroutines7010288
Ref: 1f267010288
Node: 待機可能オブジェクト Awaitable Object7010728
Ref: reference/datamodel awaitable-objects7010869
Ref: 1f277010869
Ref: reference/datamodel object __await__7011493
Ref: 1f287011493
Ref: 待機可能オブジェクト Awaitable Object-Footnote-17012398
Node: コルーチンオブジェクト7012440
Ref: reference/datamodel coroutine-objects7012636
Ref: 1e687012636
Ref: reference/datamodel id187012636
Ref: 1f297012636
Ref: reference/datamodel coroutine send7013828
Ref: 1f2c7013828
Ref: reference/datamodel coroutine throw7014363
Ref: 4c47014363
Ref: reference/datamodel coroutine close7015285
Ref: 1f2d7015285
Node: 非同期イテレータ Asynchronous Iterator7016058
Ref: reference/datamodel async-iterators7016278
Ref: d477016278
Ref: reference/datamodel asynchronous-iterators7016278
Ref: 1f2e7016278
Ref: reference/datamodel object __aiter__7016643
Ref: bc97016643
Ref: reference/datamodel object __anext__7016777
Ref: 1e6a7016777
Node: 非同期コンテキストマネージャ Asynchronous Context Manager7017811
Ref: reference/datamodel async-context-managers7017989
Ref: 5c67017989
Ref: reference/datamodel asynchronous-context-managers7017989
Ref: 1f2f7017989
Ref: reference/datamodel object __aenter__7018507
Ref: 1f307018507
Ref: reference/datamodel object __aexit__7018672
Ref: 158e7018672
Node: 実行モデル7019175
Ref: reference/executionmodel doc7019321
Ref: 1f317019321
Ref: reference/executionmodel execmodel7019321
Ref: 1f327019321
Ref: reference/executionmodel execution-model7019321
Ref: 1f337019321
Node: プログラムの構造7019505
Ref: reference/executionmodel prog-structure7019630
Ref: 1f347019630
Ref: reference/executionmodel structure-of-a-program7019630
Ref: 1f357019630
Node: 名前づけと束縛 naming and binding7021151
Ref: reference/executionmodel naming7021294
Ref: 1e597021294
Ref: reference/executionmodel naming-and-binding7021294
Ref: 1f367021294
Node: 名前の束縛7021554
Ref: reference/executionmodel bind-names7021667
Ref: 1f377021667
Ref: reference/executionmodel binding-of-names7021667
Ref: 1f387021667
Node: 名前解決7023639
Ref: reference/executionmodel resolution-of-names7023778
Ref: 1f3b7023778
Ref: reference/executionmodel resolve-names7023778
Ref: 1f3c7023778
Node: Annotation scopes7028308
Ref: reference/executionmodel annotation-scopes7028447
Ref: 16d7028447
Ref: reference/executionmodel id17028447
Ref: 1f3e7028447
Ref: Annotation scopes-Footnote-17031106
Ref: Annotation scopes-Footnote-27031148
Ref: Annotation scopes-Footnote-37031190
Node: Lazy evaluation7031232
Ref: reference/executionmodel id27031395
Ref: 1f407031395
Ref: reference/executionmodel lazy-evaluation7031395
Ref: 4237031395
Node: 組み込みと制限付きの実行7033024
Ref: reference/executionmodel builtins-and-restricted-execution7033203
Ref: 1f417033203
Ref: reference/executionmodel restrict-exec7033203
Ref: 1f427033203
Node: 動的な機能とのやりとり7034317
Ref: reference/executionmodel dynamic-features7034472
Ref: 1f437034472
Ref: reference/executionmodel interaction-with-dynamic-features7034472
Ref: 1f447034472
Ref: 動的な機能とのやりとり-Footnote-17035411
Node: 例外<2>7035592
Ref: reference/executionmodel exceptions7035702
Ref: 1f457035702
Ref: reference/executionmodel id47035702
Ref: 1f467035702
Node: インポートシステム7038694
Ref: reference/import doc7038836
Ref: 1f477038836
Ref: reference/import importsystem7038836
Ref: 1e737038836
Ref: reference/import the-import-system7038836
Ref: 1f487038836
Ref: インポートシステム-Footnote-17042178
Ref: インポートシステム-Footnote-27042246
Ref: インポートシステム-Footnote-37042288
Node: importlib<10>7042330
Ref: reference/import importlib7042434
Ref: 1f4a7042434
Node: パッケージ<2>7042922
Ref: reference/import packages7043041
Ref: 1f4b7043041
Node: 通常のパッケージ7045100
Ref: reference/import regular-packages7045215
Ref: 1f4c7045215
Node: 名前空間パッケージ7046808
Ref: reference/import namespace-packages7046923
Ref: 1f4e7046923
Ref: 名前空間パッケージ-Footnote-17048860
Node: 検索7048902
Ref: reference/import searching7049017
Ref: 1f507049017
Node: モジュールキャッシュ7050098
Ref: reference/import the-module-cache7050213
Ref: 1f517050213
Node: ファインダーとローダー7052490
Ref: reference/import finders-and-loaders7052638
Ref: 1f527052638
Ref: reference/import id27052638
Ref: 1f537052638
Node: インポートフック7055546
Ref: reference/import import-hooks7055676
Ref: 1f577055676
Node: メタパス7056920
Ref: reference/import the-meta-path7057008
Ref: 1f587057008
Node: ロード7060905
Ref: reference/import loading7061038
Ref: 1f5a7061038
Ref: ロード-Footnote-17064906
Node: ローダー7065428
Ref: reference/import loaders7065516
Ref: 1f5b7065516
Node: サブモジュール7070175
Ref: reference/import submodules7070284
Ref: 1f5c7070284
Node: Module specs7071959
Ref: reference/import id47072086
Ref: 1f5d7072086
Ref: reference/import module-specs7072086
Ref: 1e797072086
Node: __path__ attributes on modules7073421
Ref: reference/import package-path-rules7073550
Ref: 1e7b7073550
Ref: reference/import path-attributes-on-modules7073550
Ref: 1f607073550
Ref: __path__ attributes on modules-Footnote-17074871
Ref: __path__ attributes on modules-Footnote-27074913
Node: モジュールの repr7074955
Ref: reference/import module-reprs7075126
Ref: 1f617075126
Node: キャッシュされたバイトコードの無効化7077047
Ref: reference/import cached-bytecode-invalidation7077179
Ref: 1f627077179
Ref: reference/import pyc-invalidation7077179
Ref: 5b67077179
Node: パスベース・ファインダー7078559
Ref: reference/import the-path-based-finder7078740
Ref: 1f637078740
Node: パスエントリ・ファインダー7082423
Ref: reference/import path-entry-finders7082601
Ref: 1f657082601
Node: パスエントリ・ファインダー・プロトコル7088849
Ref: reference/import path-entry-finder-protocol7089027
Ref: 1f677089027
Node: 標準のインポートシステムを置き換える7092277
Ref: reference/import replacing-the-standard-import-system7092473
Ref: 1f687092473
Node: Package Relative Imports7093714
Ref: reference/import package-relative-imports7093910
Ref: 1f697093910
Ref: reference/import relativeimports7093910
Ref: 1f6a7093910
Node: __main__ に対する特別な考慮7095113
Ref: reference/import import-dunder-main7095267
Ref: 1f6b7095267
Ref: reference/import special-considerations-for-main7095267
Ref: 1f6c7095267
Node: __main__ __spec__7096089
Ref: reference/import id57096179
Ref: 1f6d7096179
Ref: reference/import main-spec7096179
Ref: 1f5f7096179
Node: 参考資料7098348
Ref: reference/import references7098469
Ref: 1f6e7098469
Ref: 参考資料-Footnote-17100103
Ref: 参考資料-Footnote-27100155
Ref: 参考資料-Footnote-37100197
Ref: 参考資料-Footnote-47100239
Ref: 参考資料-Footnote-57100281
Ref: 参考資料-Footnote-67100323
Ref: 参考資料-Footnote-77100365
Ref: 参考資料-Footnote-87100407
Ref: 参考資料-Footnote-97100449
Ref: 参考資料-Footnote-107100491
Node: 式 expression7100534
Ref: reference/expressions doc7100687
Ref: 1f6f7100687
Ref: reference/expressions expressions7100687
Ref: 1f707100687
Ref: reference/expressions id17100687
Ref: 1f717100687
Ref: reference/expressions grammar-token-python-grammar-name7101090
Ref: 1f727101090
Node: 算術変換 arithmetic conversion7102369
Ref: reference/expressions arithmetic-conversions7102495
Ref: 1f737102495
Ref: reference/expressions conversions7102495
Ref: 1f747102495
Node: アトム、原子的要素 atom7103341
Ref: reference/expressions atoms7103491
Ref: 1f757103491
Ref: reference/expressions id27103491
Ref: 1f767103491
Ref: reference/expressions grammar-token-python-grammar-atom7103864
Ref: 1f777103864
Ref: reference/expressions grammar-token-python-grammar-enclosure7103916
Ref: 1f787103916
Node: 識別子 identifier、または名前 name7104423
Ref: reference/expressions atom-identifiers7104559
Ref: 1e027104559
Ref: reference/expressions identifiers-names7104559
Ref: 1f797104559
Ref: reference/expressions private-name-mangling7105253
Ref: 1c247105253
Node: Private name mangling7105289
Ref: reference/expressions id37105390
Ref: 1f7a7105390
Node: リテラル<2>7107169
Ref: reference/expressions atom-literals7107348
Ref: 1f7b7107348
Ref: reference/expressions literals7107348
Ref: 1f7c7107348
Ref: reference/expressions grammar-token-python-grammar-literal7107506
Ref: 1f7d7107506
Node: 丸括弧形式 parenthesized form7108395
Ref: reference/expressions parenthesized7108567
Ref: 1f7e7108567
Ref: reference/expressions parenthesized-forms7108567
Ref: 1f7f7108567
Ref: reference/expressions grammar-token-python-grammar-parenth_form7108743
Ref: 1f807108743
Node: リスト、集合、辞書の表示7109892
Ref: reference/expressions comprehensions7110064
Ref: 59a7110064
Ref: reference/expressions displays-for-lists-sets-and-dictionaries7110064
Ref: 1f817110064
Ref: reference/expressions grammar-token-python-grammar-comprehension7110580
Ref: 1f827110580
Ref: reference/expressions grammar-token-python-grammar-comp_for7110634
Ref: 1f837110634
Ref: reference/expressions grammar-token-python-grammar-comp_iter7110710
Ref: 1f847110710
Ref: reference/expressions grammar-token-python-grammar-comp_if7110752
Ref: 1f857110752
Ref: リスト、集合、辞書の表示-Footnote-17113646
Node: リスト表示7113688
Ref: reference/expressions list-displays7113838
Ref: 1f867113838
Ref: reference/expressions lists7113838
Ref: 1f877113838
Ref: reference/expressions grammar-token-python-grammar-list_display7114006
Ref: 1f887114006
Node: 集合表示7114569
Ref: reference/expressions set7114695
Ref: 1f897114695
Ref: reference/expressions set-displays7114695
Ref: 1f8a7114695
Ref: reference/expressions grammar-token-python-grammar-set_display7114861
Ref: 1f8b7114861
Node: 辞書表示7115494
Ref: reference/expressions dict7115629
Ref: d4c7115629
Ref: reference/expressions dictionary-displays7115629
Ref: 1f8c7115629
Ref: reference/expressions grammar-token-python-grammar-dict_display7115775
Ref: 1f8d7115775
Ref: reference/expressions grammar-token-python-grammar-dict_item_list7115849
Ref: 1f8e7115849
Ref: reference/expressions grammar-token-python-grammar-dict_item7115910
Ref: 1f8f7115910
Ref: reference/expressions grammar-token-python-grammar-dict_comprehension7115979
Ref: 1f907115979
Ref: 辞書表示-Footnote-17117915
Ref: 辞書表示-Footnote-27117957
Node: ジェネレータ式<2>7117999
Ref: reference/expressions generator-expressions7118131
Ref: 1f917118131
Ref: reference/expressions genexpr7118131
Ref: 1f927118131
Ref: reference/expressions grammar-token-python-grammar-generator_expression7118315
Ref: 1f937118315
Node: Yield 式7120783
Ref: reference/expressions yield-expressions7120894
Ref: 1f947120894
Ref: reference/expressions yieldexpr7120894
Ref: 1f957120894
Ref: reference/expressions grammar-token-python-grammar-yield_atom7120932
Ref: 1f967120932
Ref: reference/expressions grammar-token-python-grammar-yield_from7120983
Ref: 1f977120983
Ref: reference/expressions grammar-token-python-grammar-yield_expression7121035
Ref: 1f987121035
Ref: Yield 式-Footnote-17126699
Ref: Yield 式-Footnote-27126741
Ref: Yield 式-Footnote-37126783
Ref: Yield 式-Footnote-47126825
Ref: Yield 式-Footnote-57126867
Node: ジェネレータ-イテレータメソッド7126909
Ref: reference/expressions generator-iterator-methods7127019
Ref: 1f9c7127019
Ref: reference/expressions generator-methods7127019
Ref: 1f2b7127019
Ref: reference/expressions generator __next__7127473
Ref: 1c2f7127473
Ref: reference/expressions generator send7128266
Ref: 10367128266
Ref: reference/expressions generator throw7128933
Ref: 4c57128933
Ref: reference/expressions generator close7130292
Ref: 16597130292
Node: 使用例7131190
Ref: reference/expressions examples7131377
Ref: 1f9d7131377
Node: 非同期ジェネレータ関数 asynchronous generator function<2>7132488
Ref: reference/expressions asynchronous-generator-functions7132683
Ref: 1f9a7132683
Ref: reference/expressions id47132683
Ref: 1f9e7132683
Ref: 非同期ジェネレータ関数 asynchronous generator function<2>-Footnote-17136681
Node: 非同期ジェネレータイテレータメソッド7136761
Ref: reference/expressions asynchronous-generator-iterator-methods7136938
Ref: 1fa07136938
Ref: reference/expressions asynchronous-generator-methods7136938
Ref: 1fa17136938
Ref: reference/expressions agen __anext__7137214
Ref: 1f9f7137214
Ref: reference/expressions agen asend7138174
Ref: 8a77138174
Ref: reference/expressions agen athrow7139039
Ref: 4c67139039
Ref: reference/expressions agen aclose7139944
Ref: 8a67139944
Node: プライマリ7140966
Ref: reference/expressions id57141091
Ref: 1fa27141091
Ref: reference/expressions primaries7141091
Ref: 1fa37141091
Ref: reference/expressions grammar-token-python-grammar-primary7141258
Ref: 1fa47141258
Node: 属性参照7141515
Ref: reference/expressions attribute-references7141613
Ref: 1fa57141613
Ref: reference/expressions id67141613
Ref: 1fa67141613
Ref: reference/expressions grammar-token-python-grammar-attributeref7141745
Ref: 1fa77141745
Node: 添字表記 subscription7142536
Ref: reference/expressions id77142669
Ref: 1fa87142669
Ref: reference/expressions subscriptions7142669
Ref: 1ee57142669
Ref: reference/expressions grammar-token-python-grammar-subscription7142964
Ref: 1fa97142964
Ref: 添字表記 subscription-Footnote-17145868
Node: スライス表記 slicing7145910
Ref: reference/expressions id87146048
Ref: 1faa7146048
Ref: reference/expressions slicings7146048
Ref: 1fab7146048
Ref: reference/expressions grammar-token-python-grammar-slicing7146456
Ref: 1fac7146456
Ref: reference/expressions grammar-token-python-grammar-slice_list7146505
Ref: 1fad7146505
Ref: reference/expressions grammar-token-python-grammar-slice_item7146562
Ref: 1fae7146562
Ref: reference/expressions grammar-token-python-grammar-proper_slice7146610
Ref: 1faf7146610
Ref: reference/expressions grammar-token-python-grammar-lower_bound7146681
Ref: 1fb07146681
Ref: reference/expressions grammar-token-python-grammar-upper_bound7146714
Ref: 1fb17146714
Ref: reference/expressions grammar-token-python-grammar-stride7146747
Ref: 1fb27146747
Node: 呼び出し call7148090
Ref: reference/expressions calls7148194
Ref: d4a7148194
Ref: reference/expressions id97148194
Ref: 1fb37148194
Ref: reference/expressions grammar-token-python-grammar-call7148462
Ref: 1fb57148462
Ref: reference/expressions grammar-token-python-grammar-argument_list7148546
Ref: 1fb67148546
Ref: reference/expressions grammar-token-python-grammar-positional_arguments7148810
Ref: 1fb77148810
Ref: reference/expressions grammar-token-python-grammar-positional_item7148879
Ref: 1fb87148879
Ref: reference/expressions grammar-token-python-grammar-starred_and_keywords7148948
Ref: 1fb97148948
Ref: reference/expressions grammar-token-python-grammar-keywords_arguments7149081
Ref: 1fba7149081
Ref: reference/expressions grammar-token-python-grammar-keyword_item7149216
Ref: 1fbb7149216
Ref: 呼び出し call-Footnote-17157571
Node: Await 式7157613
Ref: reference/expressions await7157736
Ref: 19e7157736
Ref: reference/expressions await-expression7157736
Ref: 1fbc7157736
Ref: reference/expressions grammar-token-python-grammar-await_expr7157938
Ref: 1fbd7157938
Node: べき乗演算 power operator7157998
Ref: reference/expressions power7158187
Ref: 1fbe7158187
Ref: reference/expressions the-power-operator7158187
Ref: 1fbf7158187
Ref: reference/expressions grammar-token-python-grammar-power7158503
Ref: 1fc07158503
Node: 単項算術演算とビット単位演算 unary arithmetic and bitwise operation7159830
Ref: reference/expressions unary7160056
Ref: 1fc17160056
Ref: reference/expressions unary-arithmetic-and-bitwise-operations7160056
Ref: 1fc27160056
Ref: reference/expressions grammar-token-python-grammar-u_expr7160322
Ref: 1fc37160322
Node: 二項算術演算 binary arithmetic operation7161099
Ref: reference/expressions binary7161329
Ref: 1fc47161329
Ref: reference/expressions binary-arithmetic-operations7161329
Ref: 1fc57161329
Ref: reference/expressions grammar-token-python-grammar-m_expr7161795
Ref: 1fc67161795
Ref: reference/expressions grammar-token-python-grammar-a_expr7161951
Ref: 1fc77161951
Ref: 二項算術演算 binary arithmetic operation-Footnote-17165928
Ref: 二項算術演算 binary arithmetic operation-Footnote-27166742
Node: シフト演算 shifting operation7167087
Ref: reference/expressions shifting7167297
Ref: 1fc97167297
Ref: reference/expressions shifting-operations7167297
Ref: 1fca7167297
Ref: reference/expressions grammar-token-python-grammar-shift_expr7167463
Ref: 1fcb7167463
Node: ビット単位演算の二項演算 binary bitwise operation7168198
Ref: reference/expressions binary-bitwise-operations7168368
Ref: 1fcc7168368
Ref: reference/expressions bitwise7168368
Ref: 1fcd7168368
Ref: reference/expressions grammar-token-python-grammar-and_expr7168605
Ref: 1fce7168605
Ref: reference/expressions grammar-token-python-grammar-xor_expr7168660
Ref: 1fcf7168660
Ref: reference/expressions grammar-token-python-grammar-or_expr7168711
Ref: 1fd07168711
Node: 比較7169395
Ref: reference/expressions comparisons7169564
Ref: 1fd17169564
Ref: reference/expressions id127169564
Ref: 1fd27169564
Ref: reference/expressions grammar-token-python-grammar-comparison7169929
Ref: 1fd37169929
Ref: reference/expressions grammar-token-python-grammar-comp_operator7169985
Ref: 1fd47169985
Node: 値の比較7171335
Ref: reference/expressions expressions-value-comparisons7171417
Ref: 17e67171417
Ref: reference/expressions value-comparisons7171417
Ref: 1fd57171417
Ref: reference/expressions in7180745
Ref: 2cb7180745
Ref: reference/expressions not-in7180745
Ref: 5fb7180745
Ref: 値の比較-Footnote-17180783
Ref: 値の比較-Footnote-27180825
Node: 所属検査演算7182242
Ref: reference/expressions membership-test-details7182351
Ref: 1ef47182351
Ref: reference/expressions membership-test-operations7182351
Ref: 1fd67182351
Ref: reference/expressions is7184526
Ref: 2cc7184526
Node: 同一性の比較7184526
Ref: reference/expressions identity-comparisons7184614
Ref: 1fd77184614
Ref: reference/expressions is-not7184614
Ref: 1fd87184614
Ref: reference/expressions booleans7185102
Ref: 1fd97185102
Ref: reference/expressions and7185102
Ref: 2c87185102
Ref: reference/expressions or7185102
Ref: 2cd7185102
Ref: 同一性の比較-Footnote-17185140
Node: ブール演算 boolean operation7185539
Ref: reference/expressions boolean-operations7185659
Ref: 1fda7185659
Ref: reference/expressions not7185659
Ref: 1fdb7185659
Ref: reference/expressions grammar-token-python-grammar-or_test7185741
Ref: 1fdc7185741
Ref: reference/expressions grammar-token-python-grammar-and_test7185792
Ref: 1fdd7185792
Ref: reference/expressions grammar-token-python-grammar-not_test7185845
Ref: 1fde7185845
Node: 代入式<2>7187413
Ref: reference/expressions assignment-expressions7187560
Ref: 1fdf7187560
Ref: reference/expressions id157187560
Ref: 1fe07187560
Ref: reference/expressions grammar-token-python-grammar-assignment_expression7187592
Ref: 1f3f7187592
Ref: 代入式<2>-Footnote-17188656
Node: 条件式 Conditional Expressions7188698
Ref: reference/expressions conditional-expressions7188828
Ref: 1fe27188828
Ref: reference/expressions if-expr7188828
Ref: 1fe37188828
Ref: reference/expressions grammar-token-python-grammar-conditional_expression7188912
Ref: 1fe47188912
Ref: reference/expressions grammar-token-python-grammar-expression7188985
Ref: 1fe17188985
Ref: reference/expressions lambdas7189485
Ref: 1fe57189485
Ref: 条件式 Conditional Expressions-Footnote-17189523
Node: ラムダ lambda7189565
Ref: reference/expressions id167189698
Ref: 1fe67189698
Ref: reference/expressions lambda7189698
Ref: 126d7189698
Ref: reference/expressions grammar-token-python-grammar-lambda_expr7189748
Ref: 1fe77189748
Node: 式のリスト7190392
Ref: reference/expressions expression-lists7190504
Ref: 1fe87190504
Ref: reference/expressions exprlists7190504
Ref: d4b7190504
Ref: reference/expressions grammar-token-python-grammar-starred_expression7190546
Ref: 1fe97190546
Ref: reference/expressions grammar-token-python-grammar-flexible_expression7190594
Ref: 1fea7190594
Ref: reference/expressions grammar-token-python-grammar-flexible_expression_list7190671
Ref: 1feb7190671
Ref: reference/expressions grammar-token-python-grammar-starred_expression_list7190758
Ref: 1fec7190758
Ref: reference/expressions grammar-token-python-grammar-expression_list7190843
Ref: 1fed7190843
Ref: reference/expressions grammar-token-python-grammar-yield_list7190912
Ref: 1f9b7190912
Ref: 式のリスト-Footnote-17192202
Ref: 式のリスト-Footnote-27192244
Node: 評価順序7192286
Ref: reference/expressions evalorder7192406
Ref: 1fee7192406
Ref: reference/expressions evaluation-order7192406
Ref: 1fef7192406
Node: 演算子の優先順位7192928
Ref: reference/expressions operator-precedence7193024
Ref: 1ff07193024
Ref: reference/expressions operator-summary7193024
Ref: 1ff17193024
Ref: 演算子の優先順位-Footnote-17197694
Ref: 演算子の優先順位-Footnote-27197914
Node: 単純文 simple statement7198034
Ref: reference/simple_stmts doc7198188
Ref: 1ff27198188
Ref: reference/simple_stmts simple7198188
Ref: 1ff37198188
Ref: reference/simple_stmts simple-statements7198188
Ref: 1ff47198188
Ref: reference/simple_stmts grammar-token-python-grammar-simple_stmt7198476
Ref: 1ff57198476
Node: 式文 expression statement7199447
Ref: reference/simple_stmts expression-statements7199576
Ref: 1ff67199576
Ref: reference/simple_stmts exprstmts7199576
Ref: 1ff77199576
Ref: reference/simple_stmts grammar-token-python-grammar-expression_stmt7200094
Ref: 1ff87200094
Node: 代入文 assignment statement7200588
Ref: reference/simple_stmts assignment7200736
Ref: 1f397200736
Ref: reference/simple_stmts assignment-statements7200736
Ref: 1ff97200736
Ref: reference/simple_stmts grammar-token-python-grammar-assignment_stmt7200970
Ref: 1ffa7200970
Ref: reference/simple_stmts grammar-token-python-grammar-target_list7201054
Ref: 1ffb7201054
Ref: reference/simple_stmts grammar-token-python-grammar-target7201106
Ref: 1ffc7201106
Ref: reference/simple_stmts attr-target-note7205717
Ref: 1ffd7205717
Ref: 代入文 assignment statement-Footnote-17210746
Node: 累算代入文 augmented assignment statement7210788
Ref: reference/simple_stmts augassign7210963
Ref: 1ffe7210963
Ref: reference/simple_stmts augmented-assignment-statements7210963
Ref: 1fff7210963
Ref: reference/simple_stmts grammar-token-python-grammar-augmented_assignment_stmt7211175
Ref: 20007211175
Ref: reference/simple_stmts grammar-token-python-grammar-augtarget7211263
Ref: 20017211263
Ref: reference/simple_stmts grammar-token-python-grammar-augop7211349
Ref: 20027211349
Node: 注釈付き代入文 annotated assignment statements7213163
Ref: reference/simple_stmts annassign7213338
Ref: 20037213338
Ref: reference/simple_stmts annotated-assignment-statements7213338
Ref: 20047213338
Ref: reference/simple_stmts grammar-token-python-grammar-annotated_assignment_stmt7213617
Ref: 20057213617
Ref: 注釈付き代入文 annotated assignment statements-Footnote-17215830
Ref: 注釈付き代入文 annotated assignment statements-Footnote-27215872
Node: assert 文7215914
Ref: reference/simple_stmts assert7216046
Ref: 9367216046
Ref: reference/simple_stmts the-assert-statement7216046
Ref: 20067216046
Ref: reference/simple_stmts grammar-token-python-grammar-assert_stmt7216229
Ref: 20077216229
Node: pass 文<2>7217483
Ref: reference/simple_stmts pass7217595
Ref: 1b847217595
Ref: reference/simple_stmts the-pass-statement7217595
Ref: 20087217595
Ref: reference/simple_stmts grammar-token-python-grammar-pass_stmt7217633
Ref: 20097217633
Node: del 文<2>7218088
Ref: reference/simple_stmts del7218200
Ref: 17117218200
Ref: reference/simple_stmts the-del-statement7218200
Ref: 200a7218200
Ref: reference/simple_stmts grammar-token-python-grammar-del_stmt7218236
Ref: 200b7218236
Node: return 文7219573
Ref: reference/simple_stmts return7219683
Ref: 99c7219683
Ref: reference/simple_stmts the-return-statement7219683
Ref: 200c7219683
Ref: reference/simple_stmts grammar-token-python-grammar-return_stmt7219725
Ref: 200d7219725
Node: yield 文7221038
Ref: reference/simple_stmts the-yield-statement7221147
Ref: 200e7221147
Ref: reference/simple_stmts yield7221147
Ref: 99b7221147
Ref: reference/simple_stmts grammar-token-python-grammar-yield_stmt7221187
Ref: 200f7221187
Node: raise 文7221925
Ref: reference/simple_stmts raise7222033
Ref: 5b77222033
Ref: reference/simple_stmts the-raise-statement7222033
Ref: 20107222033
Ref: reference/simple_stmts grammar-token-python-grammar-raise_stmt7222073
Ref: 20117222073
Node: break 文7226423
Ref: reference/simple_stmts break7226534
Ref: a777226534
Ref: reference/simple_stmts the-break-statement7226534
Ref: 20147226534
Ref: reference/simple_stmts grammar-token-python-grammar-break_stmt7226574
Ref: 20157226574
Node: continue 文7227383
Ref: reference/simple_stmts continue7227495
Ref: 9987227495
Ref: reference/simple_stmts the-continue-statement7227495
Ref: 20167227495
Ref: reference/simple_stmts grammar-token-python-grammar-continue_stmt7227543
Ref: 20177227543
Ref: reference/simple_stmts import7228108
Ref: 5ac7228108
Node: import 文7228110
Ref: reference/simple_stmts from7228223
Ref: 127d7228223
Ref: reference/simple_stmts the-import-statement7228223
Ref: 20187228223
Ref: reference/simple_stmts grammar-token-python-grammar-import_stmt7228267
Ref: 20197228267
Ref: reference/simple_stmts grammar-token-python-grammar-module7228733
Ref: 201a7228733
Ref: reference/simple_stmts grammar-token-python-grammar-relative_module7228787
Ref: 201b7228787
Node: future 文 future statement7235899
Ref: reference/simple_stmts future7235973
Ref: 16e7235973
Ref: reference/simple_stmts future-statements7235973
Ref: 201c7235973
Ref: reference/simple_stmts grammar-token-python-grammar-future_stmt7236616
Ref: 201d7236616
Ref: reference/simple_stmts grammar-token-python-grammar-feature7236892
Ref: 201e7236892
Ref: future 文 future statement-Footnote-17240356
Ref: future 文 future statement-Footnote-27240398
Node: global 文7240440
Ref: reference/simple_stmts global7240553
Ref: 16f7240553
Ref: reference/simple_stmts the-global-statement7240553
Ref: 201f7240553
Ref: reference/simple_stmts grammar-token-python-grammar-global_stmt7240597
Ref: 20207240597
Node: nonlocal 文7242767
Ref: reference/simple_stmts nonlocal7242888
Ref: 12797242888
Ref: reference/simple_stmts the-nonlocal-statement7242888
Ref: 20217242888
Ref: reference/simple_stmts grammar-token-python-grammar-nonlocal_stmt7242936
Ref: 20227242936
Ref: nonlocal 文-Footnote-17244080
Node: The type statement7244122
Ref: reference/simple_stmts the-type-statement7244224
Ref: 20237244224
Ref: reference/simple_stmts type7244224
Ref: 4047244224
Ref: reference/simple_stmts grammar-token-python-grammar-type_stmt7244285
Ref: 20247244285
Ref: The type statement-Footnote-17245568
Node: 複合文 compound statement7245610
Ref: reference/compound_stmts doc7245774
Ref: 20257245774
Ref: reference/compound_stmts compound7245774
Ref: 20267245774
Ref: reference/compound_stmts compound-statements7245774
Ref: 20277245774
Ref: reference/compound_stmts grammar-token-python-grammar-compound_stmt7247949
Ref: 20287247949
Ref: reference/compound_stmts grammar-token-python-grammar-suite7248342
Ref: 20297248342
Ref: reference/compound_stmts grammar-token-python-grammar-statement7248418
Ref: 202a7248418
Ref: reference/compound_stmts grammar-token-python-grammar-stmt_list7248475
Ref: 202b7248475
Ref: reference/compound_stmts if7249094
Ref: 2ca7249094
Ref: reference/compound_stmts elif7249094
Ref: 1b747249094
Node: if 文<2>7249316
Ref: reference/compound_stmts else7249408
Ref: 1717249408
Ref: reference/compound_stmts the-if-statement7249408
Ref: 202c7249408
Ref: reference/compound_stmts grammar-token-python-grammar-if_stmt7249520
Ref: 202d7249520
Node: while 文7250220
Ref: reference/compound_stmts the-while-statement7250331
Ref: 202e7250331
Ref: reference/compound_stmts while7250331
Ref: 1b6e7250331
Ref: reference/compound_stmts grammar-token-python-grammar-while_stmt7250478
Ref: 202f7250478
Node: for 文<2>7251216
Ref: reference/compound_stmts for7251325
Ref: 2c97251325
Ref: reference/compound_stmts the-for-statement7251325
Ref: 20307251325
Ref: reference/compound_stmts grammar-token-python-grammar-for_stmt7251588
Ref: 20317251588
Node: try 文7253806
Ref: reference/compound_stmts the-try-statement7253914
Ref: 20327253914
Ref: reference/compound_stmts try7253914
Ref: 6b47253914
Ref: reference/compound_stmts grammar-token-python-grammar-try_stmt7254088
Ref: 20337254088
Ref: reference/compound_stmts grammar-token-python-grammar-try1_stmt7254141
Ref: 20347254141
Ref: reference/compound_stmts grammar-token-python-grammar-try2_stmt7254327
Ref: 20357254327
Ref: reference/compound_stmts grammar-token-python-grammar-try3_stmt7254515
Ref: 20367254515
Node: except 節7254875
Ref: reference/compound_stmts except7254949
Ref: 1707254949
Ref: reference/compound_stmts except-clause7254949
Ref: 20377254949
Ref: except 節-Footnote-17258751
Node: except* 節7258966
Ref: reference/compound_stmts except-star7259057
Ref: 5827259057
Ref: reference/compound_stmts id27259057
Ref: 20387259057
Node: else 節7261458
Ref: reference/compound_stmts else-clause7261550
Ref: 20397261550
Ref: reference/compound_stmts except-else7261550
Ref: 203a7261550
Node: finally 節7261989
Ref: reference/compound_stmts finally7262061
Ref: 9977262061
Ref: reference/compound_stmts finally-clause7262061
Ref: 203b7262061
Ref: reference/compound_stmts with7264018
Ref: 59c7264018
Node: with 文7264018
Ref: reference/compound_stmts as7264128
Ref: 203c7264128
Ref: reference/compound_stmts the-with-statement7264128
Ref: 203d7264128
Ref: reference/compound_stmts grammar-token-python-grammar-with_stmt7264620
Ref: 203e7264620
Ref: reference/compound_stmts grammar-token-python-grammar-with_stmt_contents7264722
Ref: 203f7264722
Ref: reference/compound_stmts grammar-token-python-grammar-with_item7264777
Ref: 20407264777
Ref: with 文-Footnote-17268450
Node: match 文<2>7268492
Ref: reference/compound_stmts match7268607
Ref: 7d87268607
Ref: reference/compound_stmts the-match-statement7268607
Ref: 20417268607
Ref: reference/compound_stmts grammar-token-python-grammar-match_stmt7268756
Ref: 20427268756
Ref: reference/compound_stmts grammar-token-python-grammar-subject_expr7268837
Ref: 20437268837
Ref: reference/compound_stmts grammar-token-python-grammar-case_block7268950
Ref: 20447268950
Ref: match 文<2>-Footnote-17270071
Ref: match 文<2>-Footnote-27270113
Node: 概要7270155
Ref: reference/compound_stmts overview7270228
Ref: 20457270228
Node: ガード7273509
Ref: reference/compound_stmts guards7273630
Ref: 20477273630
Ref: reference/compound_stmts grammar-token-python-grammar-guard7273664
Ref: 20487273664
Node: 論駁不可能なケースブロック7275209
Ref: reference/compound_stmts irrefutable-case7275336
Ref: 20497275336
Ref: reference/compound_stmts irrefutable-case-blocks7275336
Ref: 204a7275336
Node: パターン7276417
Ref: reference/compound_stmts patterns7276526
Ref: 204e7276526
Ref: reference/compound_stmts grammar-token-python-grammar-patterns7276903
Ref: 204f7276903
Ref: reference/compound_stmts grammar-token-python-grammar-pattern7276959
Ref: 20507276959
Ref: reference/compound_stmts grammar-token-python-grammar-closed_pattern7277007
Ref: 20517277007
Node: OR パターン7278174
Ref: reference/compound_stmts id37278262
Ref: 20527278262
Ref: reference/compound_stmts or-patterns7278262
Ref: 204c7278262
Ref: reference/compound_stmts grammar-token-python-grammar-or_pattern7278413
Ref: 20537278413
Node: AS パターン7279353
Ref: reference/compound_stmts as-patterns7279474
Ref: 204b7279474
Ref: reference/compound_stmts id47279474
Ref: 20547279474
Ref: reference/compound_stmts grammar-token-python-grammar-as_pattern7279677
Ref: 20557279677
Node: リテラルパターン7280195
Ref: reference/compound_stmts id57280328
Ref: 20567280328
Ref: reference/compound_stmts literal-patterns7280328
Ref: 20577280328
Ref: reference/compound_stmts grammar-token-python-grammar-literal_pattern7280502
Ref: 20587280502
Ref: reference/compound_stmts grammar-token-python-grammar-signed_number7280783
Ref: 20597280783
Node: キャプチャパターン7281635
Ref: reference/compound_stmts capture-patterns7281786
Ref: 204d7281786
Ref: reference/compound_stmts id67281786
Ref: 205b7281786
Ref: reference/compound_stmts grammar-token-python-grammar-capture_pattern7281944
Ref: 205c7281944
Ref: キャプチャパターン-Footnote-17282949
Node: ワイルドカードパターン7282991
Ref: reference/compound_stmts id77283133
Ref: 205e7283133
Ref: reference/compound_stmts wildcard-patterns7283133
Ref: 7d97283133
Ref: reference/compound_stmts grammar-token-python-grammar-wildcard_pattern7283342
Ref: 205d7283342
Node: 値パターン7283766
Ref: reference/compound_stmts id87283905
Ref: 205f7283905
Ref: reference/compound_stmts value-patterns7283905
Ref: 20607283905
Ref: reference/compound_stmts grammar-token-python-grammar-value_pattern7284035
Ref: 20617284035
Ref: reference/compound_stmts grammar-token-python-grammar-attr7284063
Ref: 20627284063
Ref: reference/compound_stmts grammar-token-python-grammar-name_or_attr7284108
Ref: 20637284108
Node: グループパターン7284910
Ref: reference/compound_stmts group-patterns7285043
Ref: 20647285043
Ref: reference/compound_stmts id97285043
Ref: 20657285043
Ref: reference/compound_stmts grammar-token-python-grammar-group_pattern7285255
Ref: 20667285255
Node: シーケンスパターン7285354
Ref: reference/compound_stmts id107285499
Ref: 20677285499
Ref: reference/compound_stmts sequence-patterns7285499
Ref: 20687285499
Ref: reference/compound_stmts grammar-token-python-grammar-sequence_pattern7285715
Ref: 20697285715
Ref: reference/compound_stmts grammar-token-python-grammar-open_sequence_pattern7285846
Ref: 206a7285846
Ref: reference/compound_stmts grammar-token-python-grammar-maybe_sequence_pattern7285926
Ref: 206b7285926
Ref: reference/compound_stmts grammar-token-python-grammar-maybe_star_pattern7285987
Ref: 206c7285987
Ref: reference/compound_stmts grammar-token-python-grammar-star_pattern7286042
Ref: 206d7286042
Ref: シーケンスパターン-Footnote-17289062
Node: マッピングパターン7289783
Ref: reference/compound_stmts id127289925
Ref: 206e7289925
Ref: reference/compound_stmts mapping-patterns7289925
Ref: 206f7289925
Ref: reference/compound_stmts grammar-token-python-grammar-mapping_pattern7290120
Ref: 20707290120
Ref: reference/compound_stmts grammar-token-python-grammar-items_pattern7290173
Ref: 20717290173
Ref: reference/compound_stmts grammar-token-python-grammar-key_value_pattern7290230
Ref: 20727290230
Ref: reference/compound_stmts grammar-token-python-grammar-double_star_pattern7290356
Ref: 20737290356
Ref: マッピングパターン-Footnote-17291990
Node: クラスパターン7292464
Ref: reference/compound_stmts class-patterns7292570
Ref: 20747292570
Ref: reference/compound_stmts id147292570
Ref: 20757292570
Ref: reference/compound_stmts grammar-token-python-grammar-class_pattern7292722
Ref: 20767292722
Ref: reference/compound_stmts grammar-token-python-grammar-pattern_arguments7292797
Ref: 20777292797
Ref: reference/compound_stmts grammar-token-python-grammar-positional_patterns7292917
Ref: 20787292917
Ref: reference/compound_stmts grammar-token-python-grammar-keyword_patterns7292959
Ref: 20797292959
Ref: reference/compound_stmts grammar-token-python-grammar-keyword_pattern7293009
Ref: 207a7293009
Ref: reference/compound_stmts function7297049
Ref: 1ba07297049
Ref: クラスパターン-Footnote-17297085
Ref: クラスパターン-Footnote-27297127
Node: 関数定義7297169
Ref: reference/compound_stmts def7297291
Ref: 13ff7297291
Ref: reference/compound_stmts function-definitions7297291
Ref: 207b7297291
Ref: reference/compound_stmts grammar-token-python-grammar-funcdef7297448
Ref: 207c7297448
Ref: reference/compound_stmts grammar-token-python-grammar-decorators7297613
Ref: 207d7297613
Ref: reference/compound_stmts grammar-token-python-grammar-decorator7297659
Ref: 207e7297659
Ref: reference/compound_stmts grammar-token-python-grammar-parameter_list7297728
Ref: 207f7297728
Ref: reference/compound_stmts grammar-token-python-grammar-parameter_list_no_posonly7297903
Ref: 20807297903
Ref: reference/compound_stmts grammar-token-python-grammar-parameter_list_starargs7298064
Ref: 20817298064
Ref: reference/compound_stmts grammar-token-python-grammar-parameter7298227
Ref: 20827298227
Ref: reference/compound_stmts grammar-token-python-grammar-star_parameter7298290
Ref: 20837298290
Ref: reference/compound_stmts grammar-token-python-grammar-defparameter7298359
Ref: 20847298359
Ref: reference/compound_stmts grammar-token-python-grammar-funcname7298421
Ref: 20857298421
Ref: 関数定義-Footnote-17306555
Ref: 関数定義-Footnote-27306752
Ref: 関数定義-Footnote-37306794
Ref: 関数定義-Footnote-47306836
Ref: 関数定義-Footnote-57306878
Ref: 関数定義-Footnote-67306920
Ref: 関数定義-Footnote-77306962
Ref: 関数定義-Footnote-87307004
Ref: 関数定義-Footnote-97307046
Ref: 関数定義-Footnote-107307088
Node: クラス定義7307131
Ref: reference/compound_stmts class7307259
Ref: 12a57307259
Ref: reference/compound_stmts class-definitions7307259
Ref: 20877307259
Ref: reference/compound_stmts grammar-token-python-grammar-classdef7307412
Ref: 20887307412
Ref: reference/compound_stmts grammar-token-python-grammar-inheritance7307502
Ref: 20897307502
Ref: reference/compound_stmts grammar-token-python-grammar-classname7307547
Ref: 208a7307547
Ref: クラス定義-Footnote-17311506
Ref: クラス定義-Footnote-27311693
Ref: クラス定義-Footnote-37311735
Ref: クラス定義-Footnote-47311777
Ref: クラス定義-Footnote-57311819
Node: コルーチン<2>7311861
Ref: reference/compound_stmts async7311997
Ref: 6fd7311997
Ref: reference/compound_stmts coroutines7311997
Ref: 208b7311997
Node: コルーチン関数定義7312139
Ref: reference/compound_stmts async-def7312243
Ref: 59b7312243
Ref: reference/compound_stmts coroutine-function-definition7312243
Ref: 208c7312243
Ref: reference/compound_stmts grammar-token-python-grammar-async_funcdef7312307
Ref: 208d7312307
Node: async for 文7313271
Ref: reference/compound_stmts async-for7313398
Ref: a797313398
Ref: reference/compound_stmts the-async-for-statement7313398
Ref: 208e7313398
Ref: reference/compound_stmts grammar-token-python-grammar-async_for_stmt7313450
Ref: 208f7313450
Node: async with 文7314494
Ref: reference/compound_stmts async-with7314585
Ref: 59f7314585
Ref: reference/compound_stmts the-async-with-statement7314585
Ref: 20907314585
Ref: reference/compound_stmts grammar-token-python-grammar-async_with_stmt7314639
Ref: 20917314639
Ref: async with 文-Footnote-17315858
Node: Type parameter lists7315900
Ref: reference/compound_stmts type-parameter-lists7316012
Ref: 20927316012
Ref: reference/compound_stmts type-params7316012
Ref: 2937316012
Ref: reference/compound_stmts grammar-token-python-grammar-type_params7316181
Ref: 20937316181
Ref: reference/compound_stmts grammar-token-python-grammar-type_param7316240
Ref: 20947316240
Ref: reference/compound_stmts grammar-token-python-grammar-typevar7316297
Ref: 20957316297
Ref: reference/compound_stmts grammar-token-python-grammar-typevartuple7316366
Ref: 20967316366
Ref: reference/compound_stmts grammar-token-python-grammar-paramspec7316421
Ref: 20977316421
Ref: Type parameter lists-Footnote-17320777
Node: Generic functions7320819
Ref: reference/compound_stmts generic-functions7320917
Ref: 41f7320917
Ref: reference/compound_stmts id177320917
Ref: 20997320917
Node: Generic classes7322720
Ref: reference/compound_stmts generic-classes7322847
Ref: 41e7322847
Ref: reference/compound_stmts id187322847
Ref: 209a7322847
Node: Generic type aliases7323989
Ref: reference/compound_stmts generic-type-aliases7324090
Ref: 4227324090
Ref: reference/compound_stmts id197324090
Ref: 209b7324090
Node: トップレベル要素7324907
Ref: reference/toplevel_components doc7325066
Ref: 209c7325066
Ref: reference/toplevel_components top-level7325066
Ref: 209d7325066
Ref: reference/toplevel_components top-level-components7325066
Ref: 209e7325066
Node: 完全な Python プログラム7325599
Ref: reference/toplevel_components complete-python-programs7325719
Ref: 209f7325719
Ref: reference/toplevel_components programs7325719
Ref: 1f5e7325719
Node: ファイル入力7327696
Ref: reference/toplevel_components file-input7327840
Ref: 20a07327840
Ref: reference/toplevel_components id17327840
Ref: 20a17327840
Ref: reference/toplevel_components grammar-token-python-grammar-file_input7327969
Ref: 20a27327969
Node: 対話的入力7328319
Ref: reference/toplevel_components interactive7328440
Ref: 20a37328440
Ref: reference/toplevel_components interactive-input7328440
Ref: 20a47328440
Ref: reference/toplevel_components grammar-token-python-grammar-interactive_input7328564
Ref: 20a57328564
Node: 式入力7328888
Ref: reference/toplevel_components expression-input7328982
Ref: 20a67328982
Ref: reference/toplevel_components id27328982
Ref: 20a77328982
Ref: reference/toplevel_components grammar-token-python-grammar-eval_input7329222
Ref: 20a87329222
Node: 完全な文法仕様7329268
Ref: reference/grammar doc7329390
Ref: 205a7329390
Ref: reference/grammar full-grammar-specification7329390
Ref: 20a97329390
Ref: reference/grammar id17329390
Ref: 20aa7329390
Ref: 完全な文法仕様-Footnote-17401830
Ref: 完全な文法仕様-Footnote-27401902
Ref: 完全な文法仕様-Footnote-37401974
Ref: 完全な文法仕様-Footnote-47402039
Node: Python 標準ライブラリ7402081
Ref: library/index doc7402247
Ref: 20ab7402247
Ref: library/index library-index7402247
Ref: 12a7402247
Ref: library/index the-python-standard-library7402247
Ref: 20ac7402247
Ref: Python 標準ライブラリ-Footnote-17405960
Node: はじめに<6>7405985
Ref: library/intro doc7406092
Ref: 20ad7406092
Ref: library/intro introduction7406092
Ref: 20ae7406092
Ref: library/intro library-intro7406092
Ref: 20af7406092
Node: 利用可能性について7410098
Ref: library/intro availability7410177
Ref: 1cbe7410177
Ref: library/intro notes-on-availability7410177
Ref: 20b07410177
Node: WebAssembly プラットフォーム7411100
Ref: library/intro wasm-availability7411225
Ref: 174c7411225
Ref: library/intro webassembly-platforms7411225
Ref: 20b17411225
Ref: library/intro mobile-availability7414331
Ref: 1dbd7414331
Ref: WebAssembly プラットフォーム-Footnote-17414368
Ref: WebAssembly プラットフォーム-Footnote-27414401
Ref: WebAssembly プラットフォーム-Footnote-37414433
Ref: WebAssembly プラットフォーム-Footnote-47414459
Ref: WebAssembly プラットフォーム-Footnote-57414491
Ref: WebAssembly プラットフォーム-Footnote-67414517
Ref: WebAssembly プラットフォーム-Footnote-77414547
Ref: WebAssembly プラットフォーム-Footnote-87414576
Ref: WebAssembly プラットフォーム-Footnote-97414606
Node: Mobile platforms7414666
Ref: library/intro ios-availability7414791
Ref: 20b27414791
Ref: library/intro mobile-platforms7414791
Ref: 20b37414791
Ref: Mobile platforms-Footnote-17417599
Node: 組み込み関数7417665
Ref: library/functions doc7417799
Ref: 20b47417799
Ref: library/functions built-in-funcs7417799
Ref: 122e7417799
Ref: library/functions built-in-functions7417799
Ref: 20b57417799
Ref: library/functions abs7421269
Ref: 1c0e7421269
Ref: library/functions aiter7421534
Ref: 7a07421534
Ref: library/functions all7421881
Ref: 13c97421881
Ref: library/functions anext7422238
Ref: 7a17422238
Ref: library/functions any7423217
Ref: 13c87423217
Ref: library/functions ascii7423588
Ref: 138e7423588
Ref: library/functions bin7424036
Ref: 127a7424036
Ref: library/functions bool7424892
Ref: 4347424892
Ref: library/functions breakpoint7425757
Ref: 2157425757
Ref: library/functions func-bytearray7427427
Ref: 1a257427427
Ref: library/functions func-bytes7429225
Ref: 1a247429225
Ref: library/functions callable7430256
Ref: 11967430256
Ref: library/functions chr7431043
Ref: 15d67431043
Ref: library/functions classmethod7431494
Ref: 14c7431494
Ref: library/functions compile7433608
Ref: 1777433608
Ref: library/functions complex7438941
Ref: 2cf7438941
Ref: library/functions grammar-token-float-complexvalue7440565
Ref: 20ca7440565
Ref: library/functions delattr7442358
Ref: 20b67442358
Ref: library/functions func-dict7442942
Ref: 20b77442942
Ref: library/functions dir7443534
Ref: 5fe7443534
Ref: library/functions divmod7446841
Ref: 96f7446841
Ref: library/functions enumerate7447654
Ref: 14247447654
Ref: library/functions func-eval7448726
Ref: 20cb7448726
Ref: library/functions eval7448726
Ref: 1657448726
Ref: library/functions exec7452582
Ref: 1647452582
Ref: library/functions filter7457041
Ref: 8307457041
Ref: library/functions float7458027
Ref: 2ce7458027
Ref: library/functions grammar-token-float-sign7459026
Ref: 20ce7459026
Ref: library/functions grammar-token-float-infinity7459064
Ref: 20cf7459064
Ref: library/functions grammar-token-float-nan7459111
Ref: 20d07459111
Ref: library/functions grammar-token-float-digit7459145
Ref: 20d17459145
Ref: library/functions grammar-token-float-digitpart7459247
Ref: 20d27459247
Ref: library/functions grammar-token-float-number7459296
Ref: 20d37459296
Ref: library/functions grammar-token-float-exponent7459368
Ref: 20d47459368
Ref: library/functions grammar-token-float-floatnumber7459425
Ref: 20d57459425
Ref: library/functions grammar-token-float-absfloatvalue7459471
Ref: 20d67459471
Ref: library/functions grammar-token-float-floatvalue7459528
Ref: 20cd7459528
Ref: library/functions format7460911
Ref: 5eb7460911
Ref: library/functions func-frozenset7462156
Ref: 20b87462156
Ref: library/functions getattr7462782
Ref: b9f7462782
Ref: library/functions globals7463980
Ref: 17d27463980
Ref: library/functions hasattr7464290
Ref: 49e7464290
Ref: library/functions hash7464708
Ref: 5b57464708
Ref: library/functions help7465377
Ref: 8a57465377
Ref: library/functions hex7466841
Ref: 129d7466841
Ref: library/functions id7468083
Ref: 13ca7468083
Ref: library/functions input7468651
Ref: 12a67468651
Ref: library/functions int7469681
Ref: 2387469681
Ref: library/functions isinstance7474029
Ref: 40e7474029
Ref: library/functions issubclass7475225
Ref: 78c7475225
Ref: library/functions iter7476063
Ref: 7a27476063
Ref: library/functions len7477888
Ref: 5fa7477888
Ref: library/functions func-list7478364
Ref: 20b97478364
Ref: library/functions locals7478670
Ref: 1277478670
Ref: library/functions map7482006
Ref: 82f7482006
Ref: library/functions max7482797
Ref: ed47482797
Ref: library/functions func-memoryview7484388
Ref: 20ba7484388
Ref: library/functions min7484621
Ref: ed37484621
Ref: library/functions next7486199
Ref: 7a37486199
Ref: library/functions object7486613
Ref: a5a7486613
Ref: library/functions oct7487089
Ref: 129c7487089
Ref: library/functions open7488023
Ref: 4e57488023
Ref: library/functions filemodes7490175
Ref: 20dc7490175
Ref: library/functions open-newline-parameter7497558
Ref: 70c7497558
Ref: library/functions ord7503803
Ref: 1e517503803
Ref: library/functions pow7504157
Ref: 9a07504157
Ref: library/functions print7506840
Ref: f427506840
Ref: library/functions property7508480
Ref: 1797508480
Ref: library/functions property getter7510313
Ref: 15be7510313
Ref: library/functions property setter7510342
Ref: 15bf7510342
Ref: library/functions property deleter7510371
Ref: 15c07510371
Ref: library/functions property __name__7511785
Ref: 1787511785
Ref: library/functions func-range7511968
Ref: 20bb7511968
Ref: library/functions repr7512284
Ref: 7c87512284
Ref: library/functions reversed7513459
Ref: 8317513459
Ref: library/functions round7513922
Ref: 12a87513922
Ref: library/functions func-set7515533
Ref: 20bc7515533
Ref: library/functions setattr7516145
Ref: 20bd7516145
Ref: library/functions slice7517526
Ref: 4367517526
Ref: library/functions slice start7517832
Ref: 1eb67517832
Ref: library/functions slice stop7517859
Ref: 1eb77517859
Ref: library/functions slice step7517885
Ref: 1eb87517885
Ref: library/functions sorted7518947
Ref: b9c7518947
Ref: library/functions staticmethod7521191
Ref: 3ef7521191
Ref: library/functions func-str7523356
Ref: 20be7523356
Ref: library/functions sum7523791
Ref: 4377523791
Ref: library/functions super7524947
Ref: 4a87524947
Ref: library/functions func-tuple7530254
Ref: 20bf7530254
Ref: library/functions type7530563
Ref: d167530563
Ref: library/functions vars7532474
Ref: 19ad7532474
Ref: library/functions zip7533514
Ref: 79b7533514
Ref: library/functions import__7538416
Ref: 8a27538416
Ref: 組み込み関数-Footnote-17542595
Ref: 組み込み関数-Footnote-27542848
Ref: 組み込み関数-Footnote-37542890
Ref: 組み込み関数-Footnote-47542932
Ref: 組み込み関数-Footnote-57542974
Ref: 組み込み関数-Footnote-67543016
Ref: 組み込み関数-Footnote-77543093
Ref: 組み込み関数-Footnote-87543141
Ref: 組み込み関数-Footnote-97543183
Node: 組み込み定数7543225
Ref: library/constants doc7543359
Ref: 20e77543359
Ref: library/constants built-in-constants7543359
Ref: 20e87543359
Ref: library/constants built-in-consts7543359
Ref: 20e97543359
Ref: library/constants False7543487
Ref: b057543487
Ref: library/constants True7543643
Ref: library/constants None7543797
Ref: 6417543797
Ref: library/constants NotImplemented7544156
Ref: 79d7544156
Ref: library/constants Ellipsis7546231
Ref: 20ea7546231
Ref: library/constants debug__7546539
Ref: 7a57546539
Node: site モジュールで追加される定数7547155
Ref: library/constants constants-added-by-the-site-module7547254
Ref: 20eb7547254
Ref: library/constants site-consts7547254
Ref: 20ec7547254
Ref: library/constants quit7547744
Ref: 20ed7547744
Ref: library/constants exit7547776
Ref: 20ee7547776
Ref: library/constants copyright7548291
Ref: 20ef7548291
Ref: library/constants credits7548316
Ref: 20f07548316
Ref: library/constants license7548509
Ref: 20f17548509
Node: 組み込み型7548826
Ref: library/stdtypes doc7548960
Ref: 20f27548960
Ref: library/stdtypes bltin-types7548960
Ref: 20f37548960
Ref: library/stdtypes built-in-types7548960
Ref: 20f47548960
Node: 真理値判定7550945
Ref: library/stdtypes truth7551051
Ref: 20c07551051
Ref: library/stdtypes truth-value-testing7551051
Ref: 20f57551051
Ref: 真理値判定-Footnote-17552379
Node: ブール演算 --- and or not7552579
Ref: library/stdtypes boolean7552703
Ref: 20f67552703
Ref: library/stdtypes boolean-operations-and-or-not7552703
Ref: 20f77552703
Node: 比較<2>7554176
Ref: library/stdtypes comparisons7554312
Ref: 20f87554312
Ref: library/stdtypes stdcomparisons7554312
Ref: 20f97554312
Node: 数値型 int float complex7557245
Ref: library/stdtypes numeric-types-int-float-complex7557376
Ref: 20fa7557376
Ref: library/stdtypes typesnumeric7557376
Ref: 1b637557376
Ref: 数値型 int float complex-Footnote-17566554
Ref: 数値型 int float complex-Footnote-27566704
Node: 整数型におけるビット単位演算7566781
Ref: library/stdtypes bitstring-ops7566938
Ref: 20fc7566938
Ref: library/stdtypes bitwise-operations-on-integer-types7566938
Ref: 20fd7566938
Node: 整数型における追加のメソッド7569515
Ref: library/stdtypes additional-methods-on-integer-types7569732
Ref: 20fe7569732
Ref: library/stdtypes int bit_length7569987
Ref: 20ff7569987
Ref: library/stdtypes int bit_count7570939
Ref: 7977570939
Ref: library/stdtypes int to_bytes7571405
Ref: 17fa7571405
Ref: library/stdtypes int from_bytes7573797
Ref: 17ba7573797
Ref: library/stdtypes int as_integer_ratio7575916
Ref: 9997575916
Ref: library/stdtypes int is_integer7576246
Ref: 16e67576246
Node: 浮動小数点数に対する追加のメソッド7576478
Ref: library/stdtypes additional-methods-on-float7576680
Ref: 21027576680
Ref: library/stdtypes float as_integer_ratio7576980
Ref: 1c7c7576980
Ref: library/stdtypes float is_integer7577337
Ref: 21017577337
Ref: library/stdtypes float hex7578140
Ref: 1c7d7578140
Ref: library/stdtypes float fromhex7578364
Ref: 21037578364
Node: 数値型のハッシュ化7580200
Ref: library/stdtypes hashing-of-numeric-types7580351
Ref: 21047580351
Ref: library/stdtypes numeric-hash7580351
Ref: 21057580351
Ref: library/stdtypes bltin-boolean-values7585042
Ref: 21077585042
Node: ブーリアン型 - bool7585043
Ref: library/stdtypes boolean-type-bool7585183
Ref: 21087585183
Ref: library/stdtypes typebool7585183
Ref: 20c17585183
Node: イテレータ型7586719
Ref: library/stdtypes iterator-types7586871
Ref: 21097586871
Ref: library/stdtypes typeiter7586871
Ref: 20d97586871
Ref: library/stdtypes container __iter__7587483
Ref: 1c2b7587483
Ref: library/stdtypes iterator __iter__7588498
Ref: 1c2e7588498
Ref: library/stdtypes iterator __next__7588943
Ref: 129b7588943
Node: ジェネレータ型7589951
Ref: library/stdtypes generator-types7590027
Ref: 210a7590027
Ref: library/stdtypes id37590027
Ref: 210b7590027
Node: シーケンス型 --- list tuple range7590694
Ref: library/stdtypes sequence-types-list-tuple-range7590859
Ref: 210c7590859
Ref: library/stdtypes typesseq7590859
Ref: 1bb37590859
Node: 共通のシーケンス演算7591506
Ref: library/stdtypes common-sequence-operations7591663
Ref: 210d7591663
Ref: library/stdtypes typesseq-common7591663
Ref: 210e7591663
Ref: 共通のシーケンス演算-Footnote-17602200
Node: イミュータブルなシーケンス型7602351
Ref: library/stdtypes immutable-sequence-types7602556
Ref: 21127602556
Ref: library/stdtypes typesseq-immutable7602556
Ref: 21137602556
Node: ミュータブルなシーケンス型7603284
Ref: library/stdtypes mutable-sequence-types7603479
Ref: 21147603479
Ref: library/stdtypes typesseq-mutable7603479
Ref: 20c27603479
Node: リスト型 list<2>7610124
Ref: library/stdtypes lists7610295
Ref: 21157610295
Ref: library/stdtypes typesseq-list7610295
Ref: 20da7610295
Ref: library/stdtypes list7610586
Ref: 5dc7610586
Ref: library/stdtypes list sort7611997
Ref: b9d7611997
Node: タプル型 tuple7614942
Ref: library/stdtypes tuples7615079
Ref: 21167615079
Ref: library/stdtypes typesseq-tuple7615079
Ref: 20467615079
Ref: library/stdtypes tuple7615604
Ref: 3497615604
Node: range7617477
Ref: library/stdtypes ranges7617585
Ref: 21177617585
Ref: library/stdtypes typesseq-range7617585
Ref: 20e27617585
Ref: library/stdtypes range7617795
Ref: 9117617795
Ref: library/stdtypes range start7620068
Ref: 21187620068
Ref: library/stdtypes range stop7620187
Ref: 21197620187
Ref: library/stdtypes range step7620245
Ref: 211a7620245
Ref: range-Footnote-17622627
Node: テキストシーケンス型 --- str7622713
Ref: library/stdtypes text-sequence-type-str7622921
Ref: 211b7622921
Ref: library/stdtypes textseq7622921
Ref: 1b677622921
Ref: library/stdtypes str7625215
Ref: 4187625215
Node: 文字列メソッド<2>7627964
Ref: library/stdtypes id57628106
Ref: 211e7628106
Ref: library/stdtypes string-methods7628106
Ref: 1b687628106
Ref: library/stdtypes str capitalize7629160
Ref: 21207629160
Ref: library/stdtypes str casefold7629647
Ref: da37629647
Ref: library/stdtypes str center7630474
Ref: 1be67630474
Ref: library/stdtypes str count7630809
Ref: 15a87630809
Ref: library/stdtypes str encode7631251
Ref: 8a37631251
Ref: library/stdtypes str endswith7632728
Ref: e957632728
Ref: library/stdtypes str expandtabs7633179
Ref: 21217633179
Ref: library/stdtypes str find7634509
Ref: e717634509
Ref: library/stdtypes str format7635221
Ref: 5ed7635221
Ref: library/stdtypes str format_map7637069
Ref: da47637069
Ref: library/stdtypes str index7637634
Ref: 15a97637634
Ref: library/stdtypes str isalnum7637830
Ref: 21227637830
Ref: library/stdtypes str isalpha7638212
Ref: 21237638212
Ref: library/stdtypes str isascii7638906
Ref: abf7638906
Ref: library/stdtypes str isdecimal7639226
Ref: 21247639226
Ref: library/stdtypes str isdigit7639681
Ref: 21257639681
Ref: library/stdtypes str isidentifier7640287
Ref: 18c47640287
Ref: library/stdtypes str islower7640944
Ref: 21277640944
Ref: library/stdtypes str isnumeric7641218
Ref: 21287641218
Ref: library/stdtypes str isprintable7641764
Ref: da57641764
Ref: library/stdtypes str isspace7642514
Ref: 21297642514
Ref: library/stdtypes str istitle7643027
Ref: 212a7643027
Ref: library/stdtypes str isupper7643426
Ref: 212b7643426
Ref: library/stdtypes meth-str-join7643891
Ref: 212c7643891
Ref: library/stdtypes str join7643891
Ref: 21107643891
Ref: library/stdtypes str ljust7644258
Ref: 1be57644258
Ref: library/stdtypes str lower7644582
Ref: 17587644582
Ref: library/stdtypes str lstrip7644883
Ref: 14557644883
Ref: library/stdtypes str maketrans7645814
Ref: da67645814
Ref: library/stdtypes str partition7646711
Ref: e747646711
Ref: library/stdtypes str removeprefix7647130
Ref: 89d7647130
Ref: library/stdtypes str removesuffix7647514
Ref: 89e7647514
Ref: library/stdtypes str replace7647900
Ref: 17f7647900
Ref: library/stdtypes str rfind7648488
Ref: e727648488
Ref: library/stdtypes str rindex7648858
Ref: 12297648858
Ref: library/stdtypes str rjust7649048
Ref: 1be47649048
Ref: library/stdtypes str rpartition7649383
Ref: 122a7649383
Ref: library/stdtypes str rsplit7649803
Ref: 12277649803
Ref: library/stdtypes str rstrip7650375
Ref: 14567650375
Ref: library/stdtypes str split7651275
Ref: e737651275
Ref: library/stdtypes str splitlines7653230
Ref: 12287653230
Ref: library/stdtypes str startswith7655985
Ref: e947655985
Ref: library/stdtypes str strip7656438
Ref: 14547656438
Ref: library/stdtypes str swapcase7657527
Ref: 212e7657527
Ref: library/stdtypes str title7657773
Ref: 212f7657773
Ref: library/stdtypes str translate7659116
Ref: 212d7659116
Ref: library/stdtypes str upper7660421
Ref: 21327660421
Ref: library/stdtypes str zfill7661005
Ref: 14577661005
Ref: 文字列メソッド<2>-Footnote-17661528
Ref: 文字列メソッド<2>-Footnote-27661592
Ref: 文字列メソッド<2>-Footnote-37661656
Ref: 文字列メソッド<2>-Footnote-47661913
Ref: 文字列メソッド<2>-Footnote-57662170
Ref: 文字列メソッド<2>-Footnote-67662427
Ref: 文字列メソッド<2>-Footnote-77662491
Ref: 文字列メソッド<2>-Footnote-87662748
Node: printf 形式の文字列書式化7662812
Ref: library/stdtypes old-string-formatting7662954
Ref: 6987662954
Ref: library/stdtypes printf-style-string-formatting7662954
Ref: 21337662954
Ref: printf 形式の文字列書式化-Footnote-17673761
Ref: printf 形式の文字列書式化-Footnote-27673977
Node: バイナリシーケンス型 --- bytes bytearray memoryview7674019
Ref: library/stdtypes binary-sequence-types-bytes-bytearray-memoryview7674224
Ref: 21357674224
Ref: library/stdtypes binaryseq7674224
Ref: 20c47674224
Node: バイトオブジェクト7675113
Ref: library/stdtypes bytes-objects7675275
Ref: 21367675275
Ref: library/stdtypes typebytes7675275
Ref: 20c67675275
Ref: library/stdtypes bytes7675714
Ref: 1a47675714
Ref: library/stdtypes bytes fromhex7678606
Ref: abd7678606
Ref: library/stdtypes bytes hex7679442
Ref: d367679442
Node: bytearray オブジェクト7681507
Ref: library/stdtypes bytearray-objects7681707
Ref: 21377681707
Ref: library/stdtypes typebytearray7681707
Ref: 20c57681707
Ref: library/stdtypes bytearray7681895
Ref: 5087681895
Ref: library/stdtypes bytearray fromhex7683121
Ref: abe7683121
Ref: library/stdtypes bytearray hex7683988
Ref: d377683988
Node: bytes と bytearray の操作7685348
Ref: library/stdtypes bytes-and-bytearray-operations7685559
Ref: 21387685559
Ref: library/stdtypes bytes-methods7685559
Ref: 20c37685559
Ref: library/stdtypes bytes count7687232
Ref: 21397687232
Ref: library/stdtypes bytearray count7687284
Ref: 213a7687284
Ref: library/stdtypes bytes removeprefix7688063
Ref: 213b7688063
Ref: library/stdtypes bytearray removeprefix7688112
Ref: 213c7688112
Ref: library/stdtypes bytes removesuffix7688845
Ref: 213d7688845
Ref: library/stdtypes bytearray removesuffix7688894
Ref: 213e7688894
Ref: library/stdtypes bytes decode7689658
Ref: 8a47689658
Ref: library/stdtypes bytearray decode7689725
Ref: 213f7689725
Ref: library/stdtypes bytes endswith7691435
Ref: 21407691435
Ref: library/stdtypes bytearray endswith7691493
Ref: 21417691493
Ref: library/stdtypes bytes find7692130
Ref: 17a87692130
Ref: library/stdtypes bytearray find7692181
Ref: 21427692181
Ref: library/stdtypes bytes index7693315
Ref: 21437693315
Ref: library/stdtypes bytearray index7693367
Ref: 21447693367
Ref: library/stdtypes bytes join7693882
Ref: 21117693882
Ref: library/stdtypes bytearray join7693922
Ref: 21457693922
Ref: library/stdtypes bytes maketrans7694427
Ref: 12467694427
Ref: library/stdtypes bytearray maketrans7694479
Ref: 12477694479
Ref: library/stdtypes bytes partition7694950
Ref: 21477694950
Ref: library/stdtypes bytearray partition7694990
Ref: 21487694990
Ref: library/stdtypes bytes replace7695668
Ref: 21497695668
Ref: library/stdtypes bytearray replace7695720
Ref: 214a7695720
Ref: library/stdtypes bytes rfind7696391
Ref: 17a97696391
Ref: library/stdtypes bytearray rfind7696443
Ref: 214b7696443
Ref: library/stdtypes bytes rindex7697129
Ref: 214c7697129
Ref: library/stdtypes bytearray rindex7697182
Ref: 214d7697182
Ref: library/stdtypes bytes rpartition7697706
Ref: 214e7697706
Ref: library/stdtypes bytearray rpartition7697747
Ref: 214f7697747
Ref: library/stdtypes bytes startswith7698405
Ref: 21507698405
Ref: library/stdtypes bytearray startswith7698465
Ref: 21517698465
Ref: library/stdtypes bytes translate7699104
Ref: 21467699104
Ref: library/stdtypes bytearray translate7699161
Ref: 12c97699161
Ref: library/stdtypes bytes center7700487
Ref: 21527700487
Ref: library/stdtypes bytearray center7700538
Ref: 21537700538
Ref: library/stdtypes bytes ljust7701164
Ref: 21547701164
Ref: library/stdtypes bytearray ljust7701214
Ref: 21557701214
Ref: library/stdtypes bytes lstrip7701836
Ref: 21567701836
Ref: library/stdtypes bytearray lstrip7701877
Ref: 21577701877
Ref: library/stdtypes bytes rjust7703531
Ref: 21597703531
Ref: library/stdtypes bytearray rjust7703581
Ref: 215a7703581
Ref: library/stdtypes bytes rsplit7704203
Ref: 215b7704203
Ref: library/stdtypes bytearray rsplit7704258
Ref: 215c7704258
Ref: library/stdtypes bytes rstrip7704894
Ref: 215e7704894
Ref: library/stdtypes bytearray rstrip7704935
Ref: 215f7704935
Ref: library/stdtypes bytes split7706569
Ref: 21607706569
Ref: library/stdtypes bytearray split7706623
Ref: 215d7706623
Ref: library/stdtypes bytes strip7708847
Ref: 21617708847
Ref: library/stdtypes bytearray strip7708887
Ref: 21627708887
Ref: library/stdtypes bytes capitalize7710593
Ref: 21637710593
Ref: library/stdtypes bytearray capitalize7710631
Ref: 21647710631
Ref: library/stdtypes bytes expandtabs7711140
Ref: 21657711140
Ref: library/stdtypes bytearray expandtabs7711187
Ref: 21667711187
Ref: library/stdtypes bytes isalnum7712910
Ref: 21677712910
Ref: library/stdtypes bytearray isalnum7712945
Ref: 21687712945
Ref: library/stdtypes bytes isalpha7713598
Ref: 21697713598
Ref: library/stdtypes bytearray isalpha7713633
Ref: 216a7713633
Ref: library/stdtypes bytes isascii7714178
Ref: 216b7714178
Ref: library/stdtypes bytearray isascii7714213
Ref: 216c7714213
Ref: library/stdtypes bytes isdigit7714526
Ref: 216d7714526
Ref: library/stdtypes bytearray isdigit7714561
Ref: 216e7714561
Ref: library/stdtypes bytes islower7715003
Ref: 216f7715003
Ref: library/stdtypes bytearray islower7715038
Ref: 21707715038
Ref: library/stdtypes bytes isspace7715720
Ref: 21717715720
Ref: library/stdtypes bytearray isspace7715755
Ref: 21587715755
Ref: library/stdtypes bytes istitle7716235
Ref: 21727716235
Ref: library/stdtypes bytearray istitle7716270
Ref: 21737716270
Ref: library/stdtypes bytes isupper7716756
Ref: 21757716756
Ref: library/stdtypes bytearray isupper7716791
Ref: 21767716791
Ref: library/stdtypes bytes lower7717473
Ref: 21777717473
Ref: library/stdtypes bytearray lower7717506
Ref: 21787717506
Ref: library/stdtypes bytes splitlines7718270
Ref: 21797718270
Ref: library/stdtypes bytearray splitlines7718322
Ref: 217a7718322
Ref: library/stdtypes bytes swapcase7719490
Ref: 217b7719490
Ref: library/stdtypes bytearray swapcase7719526
Ref: 217c7719526
Ref: library/stdtypes bytes title7720663
Ref: 21747720663
Ref: library/stdtypes bytearray title7720696
Ref: 217d7720696
Ref: library/stdtypes bytes upper7722725
Ref: 217e7722725
Ref: library/stdtypes bytearray upper7722758
Ref: 217f7722758
Ref: library/stdtypes bytes zfill7723522
Ref: 21807723522
Ref: library/stdtypes bytearray zfill7723560
Ref: 21817723560
Node: printf 形式での bytes の書式化7724347
Ref: library/stdtypes bytes-formatting7724548
Ref: d4e7724548
Ref: library/stdtypes printf-style-bytes-formatting7724548
Ref: 21827724548
Ref: printf 形式での bytes の書式化-Footnote-17735526
Ref: printf 形式での bytes の書式化-Footnote-27735742
Ref: printf 形式での bytes の書式化-Footnote-37735784
Node: メモリビュー7735826
Ref: library/stdtypes memory-views7735989
Ref: 21837735989
Ref: library/stdtypes typememoryview7735989
Ref: 20db7735989
Ref: library/stdtypes memoryview7736286
Ref: 4357736286
Ref: library/stdtypes memoryview __eq__7740977
Ref: 21867740977
Ref: library/stdtypes memoryview tobytes7743128
Ref: 21877743128
Ref: library/stdtypes memoryview hex7744590
Ref: d387744590
Ref: library/stdtypes memoryview tolist7745214
Ref: 21847745214
Ref: library/stdtypes memoryview toreadonly7745861
Ref: 21887745861
Ref: library/stdtypes memoryview release7746529
Ref: 118e7746529
Ref: library/stdtypes memoryview cast7748113
Ref: 10157748113
Ref: library/stdtypes memoryview obj7751719
Ref: 21897751719
Ref: library/stdtypes memoryview nbytes7751970
Ref: 218a7751970
Ref: library/stdtypes memoryview readonly7753074
Ref: 218b7753074
Ref: library/stdtypes memoryview format7753185
Ref: 10147753185
Ref: library/stdtypes memoryview itemsize7753936
Ref: 21857753936
Ref: library/stdtypes memoryview ndim7754314
Ref: 10187754314
Ref: library/stdtypes memoryview shape7754424
Ref: 10197754424
Ref: library/stdtypes memoryview strides7754744
Ref: 101a7754744
Ref: library/stdtypes memoryview suboffsets7755141
Ref: 101b7755141
Ref: library/stdtypes memoryview c_contiguous7755319
Ref: 218c7755319
Ref: library/stdtypes memoryview f_contiguous7755534
Ref: 218d7755534
Ref: library/stdtypes memoryview contiguous7755753
Ref: 218e7755753
Ref: メモリビュー-Footnote-17755980
Node: set（集合）型 --- set frozenset7756022
Ref: library/stdtypes set-types-set-frozenset7756216
Ref: 218f7756216
Ref: library/stdtypes types-set7756216
Ref: 20d77756216
Ref: library/stdtypes set7758176
Ref: 5a37758176
Ref: library/stdtypes frozenset7758208
Ref: 5a47758208
Ref: library/stdtypes frozenset isdisjoint7759549
Ref: 21907759549
Ref: library/stdtypes frozenset issubset7759822
Ref: 21917759822
Ref: library/stdtypes frozenset issuperset7760174
Ref: 21927760174
Ref: library/stdtypes frozenset union7760528
Ref: 14267760528
Ref: library/stdtypes frozenset intersection7760699
Ref: 14277760699
Ref: library/stdtypes frozenset difference7760900
Ref: 21937760900
Ref: library/stdtypes frozenset symmetric_difference7761126
Ref: 21947761126
Ref: library/stdtypes frozenset copy7761344
Ref: 21957761344
Ref: library/stdtypes frozenset update7764177
Ref: 21967764177
Ref: library/stdtypes frozenset intersection_update7764339
Ref: 14287764339
Ref: library/stdtypes frozenset difference_update7764554
Ref: 21977764554
Ref: library/stdtypes frozenset symmetric_difference_update7764734
Ref: 14297764734
Ref: library/stdtypes frozenset add7764955
Ref: 21987764955
Ref: library/stdtypes frozenset remove7765045
Ref: 21997765045
Ref: library/stdtypes frozenset discard7765243
Ref: 219a7765243
Ref: library/stdtypes frozenset pop7765364
Ref: 219b7765364
Ref: library/stdtypes frozenset clear7765548
Ref: 219c7765548
Node: マッピング型 --- dict7766258
Ref: library/stdtypes mapping-types-dict7766427
Ref: 219d7766427
Ref: library/stdtypes typesmapping7766427
Ref: a947766427
Ref: library/stdtypes dict7767541
Ref: 2377767541
Ref: library/stdtypes dict clear7772623
Ref: 219e7772623
Ref: library/stdtypes dict copy7772713
Ref: b9e7772713
Ref: library/stdtypes dict fromkeys7772799
Ref: 219f7772799
Ref: library/stdtypes dict get7773561
Ref: 21a07773561
Ref: library/stdtypes dict items7773955
Ref: 79a7773955
Ref: library/stdtypes dict keys7774182
Ref: 7987774182
Ref: library/stdtypes dict pop7774382
Ref: 31c7774382
Ref: library/stdtypes dict popitem7774720
Ref: 14d07774720
Ref: library/stdtypes dict setdefault7775683
Ref: 104e7775683
Ref: library/stdtypes dict update7775999
Ref: 140a7775999
Ref: library/stdtypes dict values7776650
Ref: 7997776650
Node: 辞書ビューオブジェクト7779781
Ref: library/stdtypes dict-views7779878
Ref: 21a17779878
Ref: library/stdtypes dictionary-view-objects7779878
Ref: 21a27779878
Node: コンテキストマネージャ型7784167
Ref: library/stdtypes context-manager-types7784382
Ref: 21a47784382
Ref: library/stdtypes typecontextmanager7784382
Ref: 1f207784382
Ref: library/stdtypes contextmanager __enter__7784844
Ref: 21a57784844
Ref: library/stdtypes contextmanager __exit__7786105
Ref: 21a67786105
Node: 型アノテーション型 --- ジェネリックエイリアス 、 ユニオン7789081
Ref: library/stdtypes type-annotation-types-generic-alias-union7789296
Ref: 21a77789296
Node: ジェネリックエイリアス型7789678
Ref: library/stdtypes generic-alias-type7789851
Ref: 21a87789851
Ref: library/stdtypes types-genericalias7789851
Ref: 67e7789851
Node: 標準ジェネリッククラス7796023
Ref: library/stdtypes standard-generic-classes7796187
Ref: 21aa7796187
Node: GenericAlias オブジェクトの特別な属性7798620
Ref: library/stdtypes special-attributes-of-genericalias-objects7798784
Ref: 21b87798784
Ref: library/stdtypes genericalias __origin__7799028
Ref: 21b97799028
Ref: library/stdtypes genericalias __args__7799245
Ref: 21a97799245
Ref: library/stdtypes genericalias __parameters__7799542
Ref: 21ba7799542
Ref: library/stdtypes genericalias __unpacked__7800224
Ref: 21bb7800224
Ref: GenericAlias オブジェクトの特別な属性-Footnote-17801343
Ref: GenericAlias オブジェクトの特別な属性-Footnote-27801385
Node: Union 型7801427
Ref: library/stdtypes types-union7801600
Ref: 78d7801600
Ref: library/stdtypes union-type7801600
Ref: 21bc7801600
Ref: Union 型-Footnote-17805623
Node: その他の組み込み型7805665
Ref: library/stdtypes other-built-in-types7805856
Ref: 21bd7805856
Ref: library/stdtypes typesother7805856
Ref: 21be7805856
Node: モジュール<4>7806469
Ref: library/stdtypes modules7806605
Ref: 21bf7806605
Ref: library/stdtypes typesmodules7806605
Ref: 21c07806605
Node: クラスおよびクラスインスタンス7808144
Ref: library/stdtypes classes-and-class-instances7808295
Ref: 21c17808295
Ref: library/stdtypes typesobjects7808295
Ref: 21c27808295
Node: 関数7808540
Ref: library/stdtypes functions7808685
Ref: 21c37808685
Ref: library/stdtypes typesfunctions7808685
Ref: 21c47808685
Node: メソッド7809254
Ref: library/stdtypes methods7809384
Ref: 21c57809384
Ref: library/stdtypes typesmethods7809384
Ref: 21c67809384
Node: コードオブジェクト<2>7811738
Ref: library/stdtypes bltin-code-objects7811883
Ref: 21c77811883
Ref: library/stdtypes code-objects7811883
Ref: 21c87811883
Node: 型オブジェクト7812974
Ref: library/stdtypes bltin-type-objects7813131
Ref: 20e67813131
Ref: library/stdtypes type-objects7813131
Ref: 21c97813131
Node: ヌルオブジェクト7813593
Ref: library/stdtypes bltin-null-object7813747
Ref: 21ca7813747
Ref: library/stdtypes the-null-object7813747
Ref: 21cb7813747
Node: Ellipsis オブジェクト7814187
Ref: library/stdtypes bltin-ellipsis-object7814353
Ref: 21cc7814353
Ref: library/stdtypes the-ellipsis-object7814353
Ref: 21cd7814353
Node: NotImplemented オブジェクト7814894
Ref: library/stdtypes bltin-notimplemented-object7815060
Ref: 21ce7815060
Ref: library/stdtypes the-notimplemented-object7815060
Ref: 21cf7815060
Node: 内部オブジェクト7815574
Ref: library/stdtypes internal-objects7815704
Ref: 21d07815704
Ref: library/stdtypes typesinternal7815704
Ref: 21d17815704
Node: 特殊属性7815983
Ref: library/stdtypes special-attributes7816137
Ref: 21d27816137
Ref: library/stdtypes specialattrs7816137
Ref: 21d37816137
Ref: library/stdtypes definition __name__7816407
Ref: 103b7816407
Ref: library/stdtypes definition __qualname__7816567
Ref: 103a7816567
Ref: library/stdtypes definition __module__7816776
Ref: 21d47816776
Ref: library/stdtypes definition __doc__7816885
Ref: 8f67816885
Ref: library/stdtypes definition __type_params__7817008
Ref: 20987817008
Node: 整数と文字列の変換での長さ制限7817266
Ref: library/stdtypes int-max-str-digits7817384
Ref: 5bf7817384
Ref: library/stdtypes integer-string-conversion-length-limitation7817384
Ref: 21d57817384
Ref: 整数と文字列の変換での長さ制限-Footnote-17820487
Node: 影響のあるAPI7820543
Ref: library/stdtypes affected-apis7820676
Ref: 21d67820676
Node: 上限値を設定する7821701
Ref: library/stdtypes configuring-the-limit7821855
Ref: 21d77821855
Node: 推奨設定7825000
Ref: library/stdtypes recommended-configuration7825127
Ref: 21db7825127
Node: 組み込み例外7826267
Ref: library/exceptions doc7826413
Ref: 21dc7826413
Ref: library/exceptions bltin-exceptions7826413
Ref: 17ee7826413
Ref: library/exceptions built-in-exceptions7826413
Ref: 21dd7826413
Node: 例外コンテキスト7828573
Ref: library/exceptions exception-context7828697
Ref: 21de7828697
Ref: library/exceptions BaseException __context__7828868
Ref: 12977828868
Ref: library/exceptions BaseException __cause__7828909
Ref: 12987828909
Ref: library/exceptions BaseException __suppress_context__7828948
Ref: 20137828948
Node: 組み込み例外から継承する7830855
Ref: library/exceptions inheriting-from-built-in-exceptions7831003
Ref: 21df7831003
Ref: 組み込み例外から継承する-Footnote-17831865
Node: 基底クラス7831938
Ref: library/exceptions base-classes7832074
Ref: 21e07832074
Ref: library/exceptions BaseException7832200
Ref: 5847832200
Ref: library/exceptions BaseException args7832648
Ref: 5387832648
Ref: library/exceptions BaseException with_traceback7833076
Ref: 20127833076
Ref: library/exceptions BaseException __traceback__7833982
Ref: 12967833982
Ref: library/exceptions BaseException add_note7834174
Ref: 5857834174
Ref: library/exceptions BaseException __notes__7834526
Ref: 21e17834526
Ref: library/exceptions Exception7834766
Ref: 9a77834766
Ref: library/exceptions ArithmeticError7834988
Ref: 21e27834988
Ref: library/exceptions BufferError7835225
Ref: 178f7835225
Ref: library/exceptions LookupError7835360
Ref: 21317835360
Ref: 基底クラス-Footnote-17835734
Node: 具象例外7835776
Ref: library/exceptions concrete-exceptions7835882
Ref: 21e47835882
Ref: library/exceptions AssertionError7835976
Ref: 6757835976
Ref: library/exceptions AttributeError7836078
Ref: 3267836078
Ref: library/exceptions EOFError7836791
Ref: 12a77836791
Ref: library/exceptions FloatingPointError7837090
Ref: 21e37837090
Ref: library/exceptions GeneratorExit7837165
Ref: 136f7837165
Ref: library/exceptions ImportError7837588
Ref: 3f27837588
Ref: library/exceptions ImportError name7838007
Ref: 21e57838007
Ref: library/exceptions ImportError path7838099
Ref: 21e67838099
Ref: library/exceptions ModuleNotFoundError7838311
Ref: b157838311
Ref: library/exceptions IndexError7838627
Ref: 14de7838627
Ref: library/exceptions KeyError7838947
Ref: 31d7838947
Ref: library/exceptions KeyboardInterrupt7839106
Ref: 99f7839106
Ref: library/exceptions MemoryError7840031
Ref: 16277840031
Ref: library/exceptions NameError7840768
Ref: 40b7840768
Ref: library/exceptions NotImplementedError7841415
Ref: 2097841415
Ref: library/exceptions OSError7842482
Ref: 3f07842482
Ref: library/exceptions OSError errno7843701
Ref: 21e97843701
Ref: library/exceptions OSError winerror7843809
Ref: 21ea7843809
Ref: library/exceptions OSError strerror7844432
Ref: 21eb7844432
Ref: library/exceptions OSError filename7844669
Ref: 21ec7844669
Ref: library/exceptions OSError filename27844698
Ref: 21ed7844698
Ref: library/exceptions OverflowError7845854
Ref: 84e7845854
Ref: library/exceptions PythonFinalizationError7846435
Ref: 1337846435
Ref: library/exceptions RecursionError7847053
Ref: d397847053
Ref: library/exceptions ReferenceError7847419
Ref: 14b87847419
Ref: library/exceptions RuntimeError7847822
Ref: 17a7847822
Ref: library/exceptions StopIteration7848041
Ref: bc87848041
Ref: library/exceptions StopIteration value7848318
Ref: 1f2a7848318
Ref: library/exceptions StopAsyncIteration7849726
Ref: 19987849726
Ref: library/exceptions SyntaxError7849994
Ref: 1727849994
Ref: library/exceptions SyntaxError filename7850567
Ref: 21ee7850567
Ref: library/exceptions SyntaxError lineno7850663
Ref: 21ef7850663
Ref: library/exceptions SyntaxError offset7850856
Ref: 21f07850856
Ref: library/exceptions SyntaxError text7851034
Ref: 21f17851034
Ref: library/exceptions SyntaxError end_lineno7851126
Ref: 21f27851126
Ref: library/exceptions SyntaxError end_offset7851332
Ref: 21f37851332
Ref: library/exceptions IndentationError7851960
Ref: 7737851960
Ref: library/exceptions TabError7852147
Ref: 50e7852147
Ref: library/exceptions SystemError7852359
Ref: 5417852359
Ref: library/exceptions SystemExit7853186
Ref: d0e7853186
Ref: library/exceptions SystemExit code7854795
Ref: 21f57854795
Ref: library/exceptions TypeError7854965
Ref: 5027854965
Ref: library/exceptions UnboundLocalError7856008
Ref: 14df7856008
Ref: library/exceptions UnicodeError7856275
Ref: 12757856275
Ref: library/exceptions UnicodeError encoding7856760
Ref: 21f67856760
Ref: library/exceptions UnicodeError reason7856868
Ref: 21f77856868
Ref: library/exceptions UnicodeError object7856971
Ref: 21f87856971
Ref: library/exceptions UnicodeError start7857121
Ref: 151c7857121
Ref: library/exceptions UnicodeError end7857236
Ref: 151d7857236
Ref: library/exceptions UnicodeEncodeError7857355
Ref: 6437857355
Ref: library/exceptions UnicodeDecodeError7857542
Ref: 9e17857542
Ref: library/exceptions UnicodeTranslateError7857726
Ref: 21f97857726
Ref: library/exceptions ValueError7857907
Ref: 1e37857907
Ref: library/exceptions ZeroDivisionError7858167
Ref: 9137858167
Ref: library/exceptions EnvironmentError7858577
Ref: 10277858577
Ref: library/exceptions IOError7858607
Ref: 10267858607
Ref: library/exceptions WindowsError7858628
Ref: 10287858628
Ref: 具象例外-Footnote-17858759
Ref: 具象例外-Footnote-27858801
Node: OS 例外7858843
Ref: library/exceptions os-exceptions7858901
Ref: 21e87858901
Ref: library/exceptions BlockingIOError7859068
Ref: 102b7859068
Ref: library/exceptions BlockingIOError characters_written7859551
Ref: 21fe7859551
Ref: library/exceptions ChildProcessError7859837
Ref: 102c7859837
Ref: library/exceptions ConnectionError7860002
Ref: dd77860002
Ref: library/exceptions BrokenPipeError7860272
Ref: 10307860272
Ref: library/exceptions ConnectionAbortedError7860661
Ref: 10317860661
Ref: library/exceptions ConnectionRefusedError7860911
Ref: 10327860911
Ref: library/exceptions ConnectionResetError7861161
Ref: 10337861161
Ref: library/exceptions FileExistsError7861405
Ref: fea7861405
Ref: library/exceptions FileNotFoundError7861611
Ref: e8f7861611
Ref: library/exceptions InterruptedError7861804
Ref: d557861804
Ref: library/exceptions IsADirectoryError7862350
Ref: 102d7862350
Ref: library/exceptions NotADirectoryError7862578
Ref: 102e7862578
Ref: library/exceptions PermissionError7863036
Ref: d107863036
Ref: library/exceptions ProcessLookupError7863462
Ref: 102f7863462
Ref: library/exceptions TimeoutError7863633
Ref: 8007863633
Ref: OS 例外-Footnote-17864041
Ref: OS 例外-Footnote-27864083
Node: 警告7864125
Ref: library/exceptions warning-categories-as-exceptions7864234
Ref: 220c7864234
Ref: library/exceptions warnings7864234
Ref: 220d7864234
Ref: library/exceptions Warning7864426
Ref: 220f7864426
Ref: library/exceptions UserWarning7864499
Ref: 22107864499
Ref: library/exceptions DeprecationWarning7864609
Ref: 18a7864609
Ref: library/exceptions PendingDeprecationWarning7865087
Ref: 8957865087
Ref: library/exceptions SyntaxWarning7865792
Ref: 4327865792
Ref: library/exceptions RuntimeWarning7865886
Ref: 1a27865886
Ref: library/exceptions FutureWarning7866002
Ref: 3ee7866002
Ref: library/exceptions ImportWarning7866223
Ref: 4c77866223
Ref: library/exceptions UnicodeWarning7866545
Ref: 13cb7866545
Ref: library/exceptions EncodingWarning7866636
Ref: 1ca77866636
Ref: library/exceptions BytesWarning7866856
Ref: bf17866856
Ref: library/exceptions ResourceWarning7866987
Ref: 2257866987
Ref: 警告-Footnote-17867333
Ref: 警告-Footnote-27867375
Ref: 警告-Footnote-37867417
Node: 例外グループ7867459
Ref: library/exceptions exception-groups7867580
Ref: 22117867580
Ref: library/exceptions lib-exception-groups7867580
Ref: 22127867580
Ref: library/exceptions ExceptionGroup7868018
Ref: 19b7868018
Ref: library/exceptions BaseExceptionGroup7868058
Ref: 2407868058
Ref: library/exceptions BaseExceptionGroup message7869191
Ref: 22137869191
Ref: library/exceptions BaseExceptionGroup exceptions7869318
Ref: 22147869318
Ref: library/exceptions BaseExceptionGroup subgroup7869514
Ref: 16257869514
Ref: library/exceptions BaseExceptionGroup split7870875
Ref: 16267870875
Ref: library/exceptions BaseExceptionGroup derive7871143
Ref: 16247871143
Node: 例外のクラス階層7874281
Ref: library/exceptions exception-hierarchy7874387
Ref: 22157874387
Ref: library/text stringservices7877282
Ref: 211d7877282
Node: テキスト処理サービス7877283
Ref: library/text doc7877441
Ref: 22167877441
Ref: library/text text-processing-services7877441
Ref: 22177877441
Ref: library/text textservices7877441
Ref: 211f7877441
Node: string --- 一般的な文字列操作7878676
Ref: library/string doc7878815
Ref: 22197878815
Ref: library/string module-string7878815
Ref: be7878815
Ref: library/string string-common-string-operations7878815
Ref: 221a7878815
Ref: string --- 一般的な文字列操作-Footnote-17879306
Node: 文字列定数7879372
Ref: library/string string-constants7879504
Ref: 221b7879504
Ref: library/string string ascii_letters7879626
Ref: 12937879626
Ref: library/string string ascii_lowercase7879819
Ref: 221c7879819
Ref: library/string string ascii_uppercase7879976
Ref: 221d7879976
Ref: library/string string digits7880133
Ref: 221e7880133
Ref: library/string string hexdigits7880208
Ref: 221f7880208
Ref: library/string string octdigits7880298
Ref: 22207880298
Ref: library/string string punctuation7880374
Ref: 22217880374
Ref: library/string string printable7880591
Ref: 22227880591
Ref: library/string string whitespace7880848
Ref: 22237880848
Node: カスタムの文字列書式化7881170
Ref: library/string custom-string-formatting7881341
Ref: 22247881341
Ref: library/string string-formatting7881341
Ref: 211c7881341
Ref: library/string string Formatter7881910
Ref: e857881910
Ref: library/string string Formatter format7882024
Ref: bce7882024
Ref: library/string string Formatter vformat7882469
Ref: 22257882469
Ref: library/string string Formatter parse7883383
Ref: 22267883383
Ref: library/string string Formatter get_field7884286
Ref: 22277884286
Ref: library/string string Formatter get_value7884944
Ref: 22287884944
Ref: library/string string Formatter check_unused_args7886438
Ref: 22297886438
Ref: library/string string Formatter format_field7887131
Ref: 222a7887131
Ref: library/string string Formatter convert_field7887443
Ref: 222b7887443
Ref: カスタムの文字列書式化-Footnote-17887853
Ref: カスタムの文字列書式化-Footnote-27887895
Node: 書式指定文字列の文法7887937
Ref: library/string format-string-syntax7888120
Ref: 222c7888120
Ref: library/string formatstrings7888120
Ref: 13587888120
Ref: library/string grammar-token-format-string-replacement_field7889121
Ref: 222d7889121
Ref: library/string grammar-token-format-string-field_name7889204
Ref: 222e7889204
Ref: library/string grammar-token-format-string-arg_name7889286
Ref: 222f7889286
Ref: library/string grammar-token-format-string-attribute_name7889335
Ref: 22307889335
Ref: library/string grammar-token-format-string-element_index7889373
Ref: 22317889373
Ref: library/string grammar-token-format-string-index_string7889422
Ref: 22327889422
Ref: library/string grammar-token-format-string-conversion7889485
Ref: 22337889485
Ref: library/string grammar-token-format-string-format_spec7889528
Ref: 22347889528
Node: 書式指定ミニ言語仕様7894361
Ref: library/string format-specification-mini-language7894482
Ref: 22367894482
Ref: library/string formatspec7894482
Ref: 1c97894482
Ref: library/string grammar-token-format-spec-format_spec7895576
Ref: 22377895576
Ref: library/string grammar-token-format-spec-fill7895681
Ref: 22387895681
Ref: library/string grammar-token-format-spec-align7895722
Ref: 22397895722
Ref: library/string grammar-token-format-spec-sign7895769
Ref: 223a7895769
Ref: library/string grammar-token-format-spec-width7895810
Ref: 223b7895810
Ref: library/string grammar-token-format-spec-grouping_option7895842
Ref: 223c7895842
Ref: library/string grammar-token-format-spec-precision7895877
Ref: 223d7895877
Ref: library/string grammar-token-format-spec-type7895909
Ref: 223e7895909
Ref: 書式指定ミニ言語仕様-Footnote-17910982
Ref: 書式指定ミニ言語仕様-Footnote-27911024
Ref: 書式指定ミニ言語仕様-Footnote-37911066
Node: 書式指定例7911108
Ref: library/string format-examples7911229
Ref: 223f7911229
Ref: library/string formatexamples7911229
Ref: 22357911229
Node: テンプレート文字列7915863
Ref: library/string id17916031
Ref: 22407916031
Ref: library/string template-strings7916031
Ref: 21347916031
Ref: library/string string Template7918155
Ref: 6537918155
Ref: library/string string Template substitute7918301
Ref: 1c547918301
Ref: library/string string Template safe_substitute7918974
Ref: 1c557918974
Ref: library/string string Template is_valid7920213
Ref: 6527920213
Ref: library/string string Template get_identifiers7920505
Ref: 6517920505
Ref: library/string string Template template7920885
Ref: 22417920885
Ref: テンプレート文字列-Footnote-17926009
Ref: テンプレート文字列-Footnote-27926051
Node: ヘルパー関数7926103
Ref: library/string helper-functions7926232
Ref: 22427926232
Ref: library/string string capwords7926281
Ref: 21307926281
Node: re --- 正規表現操作7926909
Ref: library/re doc7927093
Ref: 22437927093
Ref: library/re module-re7927093
Ref: a77927093
Ref: library/re re-regular-expression-operations7927093
Ref: 22447927093
Ref: re --- 正規表現操作-Footnote-17930262
Ref: re --- 正規表現操作-Footnote-27930322
Node: 正規表現のシンタックス7930362
Ref: library/re re-syntax7930496
Ref: 6ef7930496
Ref: library/re regular-expression-syntax7930496
Ref: 22457930496
Ref: library/re re-conditional-expression7954719
Ref: 17187954719
Ref: library/re re-special-sequences7955590
Ref: 22537955590
Ref: 正規表現のシンタックス-Footnote-17963142
Ref: 正規表現のシンタックス-Footnote-27963184
Node: モジュールコンテンツ7963256
Ref: library/re contents-of-module-re7963429
Ref: 22527963429
Ref: library/re module-contents7963429
Ref: 22547963429
Node: フラグ7963920
Ref: library/re flags7964014
Ref: 224a7964014
Ref: library/re re RegexFlag7964221
Ref: 5f97964221
Ref: library/re re A7964393
Ref: 224b7964393
Ref: library/re re ASCII7964413
Ref: 5f87964413
Ref: library/re re DEBUG7965148
Ref: 22567965148
Ref: library/re re I7965322
Ref: 224c7965322
Ref: library/re re IGNORECASE7965342
Ref: 168c7965342
Ref: library/re re L7966414
Ref: 224d7966414
Ref: library/re re LOCALE7966434
Ref: b3a7966434
Ref: library/re re M7967529
Ref: 224e7967529
Ref: library/re re MULTILINE7967549
Ref: 22497967549
Ref: library/re re NOFLAG7968150
Ref: 22577968150
Ref: library/re re S7968546
Ref: 224f7968546
Ref: library/re re DOTALL7968566
Ref: 22487968566
Ref: library/re re U7968887
Ref: 22507968887
Ref: library/re re UNICODE7968907
Ref: b3b7968907
Ref: library/re re X7969208
Ref: 22517969208
Ref: library/re re VERBOSE7969228
Ref: 22587969228
Node: 関数<2>7970471
Ref: library/re functions7970583
Ref: 22597970583
Ref: library/re re compile7970612
Ref: ba17970612
Ref: library/re re search7971890
Ref: 11fd7971890
Ref: library/re re match7972575
Ref: 11fe7972575
Ref: library/re re fullmatch7973597
Ref: f527973597
Ref: library/re re split7974171
Ref: 2827974171
Ref: library/re re findall7976686
Ref: ff47976686
Ref: library/re re finditer7977955
Ref: 14a37977955
Ref: library/re re sub7978689
Ref: 2837978689
Ref: library/re re subn7982997
Ref: 2847982997
Ref: library/re re escape7983395
Ref: bd77983395
Ref: library/re re purge7985022
Ref: 225d7985022
Node: 例外<3>7985108
Ref: library/re exceptions7985202
Ref: 225e7985202
Ref: library/re re PatternError7985231
Ref: 21f7985231
Ref: library/re re PatternError msg7985681
Ref: 225f7985681
Ref: library/re re PatternError pattern7985787
Ref: 22607985787
Ref: library/re re PatternError pos7985864
Ref: 22617985864
Ref: library/re re PatternError lineno7986028
Ref: 22627986028
Ref: library/re re PatternError colno7986139
Ref: 22637986139
Node: 正規表現オブジェクト7986484
Ref: library/re re-objects7986651
Ref: f537986651
Ref: library/re regular-expression-objects7986651
Ref: 22647986651
Ref: library/re re Pattern7986720
Ref: 17487986720
Ref: library/re re Pattern search7987019
Ref: 225b7987019
Ref: library/re re Pattern match7988749
Ref: 225a7988749
Ref: library/re re Pattern fullmatch7989753
Ref: 176e7989753
Ref: library/re re Pattern split7990625
Ref: 22657990625
Ref: library/re re Pattern findall7990790
Ref: 22667990790
Ref: library/re re Pattern finditer7991099
Ref: 22677991099
Ref: library/re re Pattern sub7991411
Ref: 22687991411
Ref: library/re re Pattern subn7991575
Ref: 22697991575
Ref: library/re re Pattern flags7991741
Ref: 226a7991741
Ref: library/re re Pattern groups7992100
Ref: 226b7992100
Ref: library/re re Pattern groupindex7992198
Ref: 226c7992198
Ref: library/re re Pattern pattern7992495
Ref: 226d7992495
Node: マッチオブジェクト7992873
Ref: library/re id37993028
Ref: 226e7993028
Ref: library/re match-objects7993028
Ref: f547993028
Ref: library/re re Match7993426
Ref: c967993426
Ref: library/re re Match expand7993711
Ref: 226f7993711
Ref: library/re re Match group7994351
Ref: 22707994351
Ref: library/re re Match __getitem__7996833
Ref: 22717996833
Ref: library/re re Match groups7997564
Ref: 22727997564
Ref: library/re re Match groupdict7998528
Ref: 22737998528
Ref: library/re re Match start7999051
Ref: 22747999051
Ref: library/re re Match end7999091
Ref: 22757999091
Ref: library/re re Match span8000390
Ref: 22768000390
Ref: library/re re Match pos8000693
Ref: 22778000693
Ref: library/re re Match endpos8000979
Ref: 22788000979
Ref: library/re re Match lastindex8001262
Ref: 22798001262
Ref: library/re re Match lastgroup8001712
Ref: 227a8001712
Ref: library/re re Match re8001946
Ref: 227b8001946
Ref: library/re re Match string8002170
Ref: 227c8002170
Node: 正規表現の例8002514
Ref: library/re re-examples8002630
Ref: 122f8002630
Ref: library/re regular-expression-examples8002630
Ref: 227d8002630
Node: ペアの確認8003014
Ref: library/re checking-for-a-pair8003126
Ref: 227e8003126
Node: scanf をシミュレートする8005402
Ref: library/re simulating-scanf8005538
Ref: 227f8005538
Node: search vs match8007724
Ref: library/re id48007863
Ref: 22808007863
Ref: library/re search-vs-match8007863
Ref: 225c8007863
Node: 電話帳を作る8009339
Ref: library/re making-a-phonebook8009466
Ref: 22818009466
Node: テキストの秘匿8011920
Ref: library/re text-munging8012062
Ref: 22828012062
Node: 全ての副詞を見つける8012987
Ref: library/re finding-all-adverbs8013156
Ref: 22838013156
Node: 全ての副詞とその位置を見つける8013689
Ref: library/re finding-all-adverbs-and-their-positions8013856
Ref: 22848013856
Node: Raw 文字列記法8014582
Ref: library/re raw-string-notation8014746
Ref: 22858014746
Node: トークナイザを書く8015806
Ref: library/re writing-a-tokenizer8015916
Ref: 22868015916
Ref: library/re frie098019403
Ref: 22468019403
Ref: トークナイザを書く-Footnote-18019719
Node: difflib --- 差分の計算の補助8019774
Ref: library/difflib doc8019975
Ref: 22878019975
Ref: library/difflib difflib-helpers-for-computing-deltas8019975
Ref: 22888019975
Ref: library/difflib module-difflib8019975
Ref: 2f8019975
Ref: library/difflib difflib Differ8023177
Ref: 22898023177
Ref: library/difflib difflib HtmlDiff8024502
Ref: 228a8024502
Ref: library/difflib difflib HtmlDiff __init__8025025
Ref: 228b8025025
Ref: library/difflib difflib HtmlDiff make_file8026085
Ref: dbc8026085
Ref: library/difflib difflib HtmlDiff make_table8028231
Ref: 228d8028231
Ref: library/difflib difflib context_diff8028718
Ref: 228e8028718
Ref: library/difflib difflib get_close_matches8031090
Ref: 22928031090
Ref: library/difflib difflib ndiff8032451
Ref: 228c8032451
Ref: library/difflib difflib restore8034361
Ref: 22958034361
Ref: library/difflib difflib unified_diff8035235
Ref: 22978035235
Ref: library/difflib difflib diff_bytes8037441
Ref: dbd8037441
Ref: library/difflib difflib IS_LINE_JUNK8038701
Ref: 22938038701
Ref: library/difflib difflib IS_CHARACTER_JUNK8039077
Ref: 22948039077
Ref: difflib --- 差分の計算の補助-Footnote-18039874
Ref: difflib --- 差分の計算の補助-Footnote-28039941
Ref: difflib --- 差分の計算の補助-Footnote-38040031
Node: SequenceMatcherオブジェクト8040064
Ref: library/difflib sequence-matcher8040201
Ref: 22988040201
Ref: library/difflib sequencematcher-objects8040201
Ref: 22998040201
Ref: library/difflib difflib SequenceMatcher8040384
Ref: fe48040384
Ref: library/difflib difflib SequenceMatcher set_seqs8042418
Ref: 229a8042418
Ref: library/difflib difflib SequenceMatcher set_seq18042970
Ref: 229c8042970
Ref: library/difflib difflib SequenceMatcher set_seq28043158
Ref: 229b8043158
Ref: library/difflib difflib SequenceMatcher find_longest_match8043346
Ref: 18c98043346
Ref: library/difflib difflib SequenceMatcher get_matching_blocks8045885
Ref: 229d8045885
Ref: library/difflib difflib SequenceMatcher get_opcodes8046974
Ref: 229e8046974
Ref: library/difflib difflib SequenceMatcher get_grouped_opcodes8049085
Ref: 229f8049085
Ref: library/difflib difflib SequenceMatcher ratio8049627
Ref: 22a08049627
Ref: library/difflib difflib SequenceMatcher quick_ratio8050898
Ref: 22a18050898
Ref: library/difflib difflib SequenceMatcher real_quick_ratio8051018
Ref: 22a28051018
Node: SequenceMatcher の例8051569
Ref: library/difflib id18051740
Ref: 22a38051740
Ref: library/difflib sequencematcher-examples8051740
Ref: 22a48051740
Ref: SequenceMatcher の例-Footnote-18053505
Node: Differ オブジェクト8053582
Ref: library/difflib differ-objects8053733
Ref: 22a58053733
Ref: library/difflib id28053733
Ref: 22a68053733
Ref: library/difflib difflib Differ compare8055708
Ref: 22968055708
Node: Differ の例8056481
Ref: library/difflib differ-example8056666
Ref: 22a78056666
Ref: library/difflib differ-examples8056666
Ref: 22a88056666
Node: difflib のコマンドラインインターフェース8059097
Ref: library/difflib a-command-line-interface-to-difflib8059270
Ref: 22a98059270
Ref: library/difflib difflib-interface8059270
Ref: 22918059270
Node: ndiff example8061935
Ref: library/difflib ndiff-example8062086
Ref: 22aa8062086
Node: textwrap --- テキストの折り返しと詰め込み8065736
Ref: library/textwrap doc8065954
Ref: 22ab8065954
Ref: library/textwrap module-textwrap8065954
Ref: d58065954
Ref: library/textwrap textwrap-text-wrapping-and-filling8065954
Ref: 22ac8065954
Ref: library/textwrap textwrap wrap8066581
Ref: 146c8066581
Ref: library/textwrap textwrap fill8067454
Ref: 146b8067454
Ref: library/textwrap textwrap shorten8068163
Ref: f9d8068163
Ref: library/textwrap textwrap dedent8069631
Ref: 22b28069631
Ref: library/textwrap textwrap indent8070781
Ref: 2578070781
Ref: library/textwrap textwrap TextWrapper8072427
Ref: f9a8072427
Ref: library/textwrap textwrap TextWrapper width8073266
Ref: 22b48073266
Ref: library/textwrap textwrap TextWrapper expand_tabs8073600
Ref: 22af8073600
Ref: library/textwrap textwrap TextWrapper tabsize8073866
Ref: 22ae8073866
Ref: library/textwrap textwrap TextWrapper replace_whitespace8074168
Ref: 22b18074168
Ref: library/textwrap textwrap TextWrapper drop_whitespace8075173
Ref: 22b08075173
Ref: library/textwrap textwrap TextWrapper initial_indent8075637
Ref: 22b58075637
Ref: library/textwrap textwrap TextWrapper subsequent_indent8075891
Ref: 22b68075891
Ref: library/textwrap textwrap TextWrapper fix_sentence_endings8076184
Ref: 22b78076184
Ref: library/textwrap textwrap TextWrapper break_long_words8077552
Ref: 22b38077552
Ref: library/textwrap textwrap TextWrapper break_on_hyphens8078115
Ref: 22b88078115
Ref: library/textwrap textwrap TextWrapper max_lines8078789
Ref: f9b8078789
Ref: library/textwrap textwrap TextWrapper placeholder8079091
Ref: f9c8079091
Ref: library/textwrap textwrap TextWrapper wrap8079432
Ref: 22ad8079432
Ref: library/textwrap textwrap TextWrapper fill8079898
Ref: 22b98079898
Ref: textwrap --- テキストの折り返しと詰め込み-Footnote-18080129
Node: unicodedata --- Unicode データベース8080197
Ref: library/unicodedata doc8080433
Ref: 22ba8080433
Ref: library/unicodedata module-unicodedata8080433
Ref: ee8080433
Ref: library/unicodedata unicodedata-unicode-database8080433
Ref: 22bb8080433
Ref: library/unicodedata unicodedata lookup8081173
Ref: 104d8081173
Ref: library/unicodedata unicodedata name8081572
Ref: 22bc8081572
Ref: library/unicodedata unicodedata decimal8081884
Ref: 22bd8081884
Ref: library/unicodedata unicodedata digit8082214
Ref: 22be8082214
Ref: library/unicodedata unicodedata numeric8082539
Ref: 12348082539
Ref: library/unicodedata unicodedata category8082866
Ref: 22bf8082866
Ref: library/unicodedata unicodedata bidirectional8082992
Ref: 22c08082992
Ref: library/unicodedata unicodedata combining8083219
Ref: 22c18083219
Ref: library/unicodedata unicodedata east_asian_width8083429
Ref: 22c28083429
Ref: library/unicodedata unicodedata mirrored8083591
Ref: 22c38083591
Ref: library/unicodedata unicodedata decomposition8083894
Ref: 22c48083894
Ref: library/unicodedata unicodedata normalize8084166
Ref: 6a08084166
Ref: library/unicodedata unicodedata is_normalized8086202
Ref: a178086202
Ref: library/unicodedata unicodedata unidata_version8086512
Ref: 22c58086512
Ref: library/unicodedata unicodedata ucd_3_2_08086653
Ref: 13db8086653
Ref: unicodedata --- Unicode データベース-Footnote-18087550
Ref: unicodedata --- Unicode データベース-Footnote-28087600
Ref: unicodedata --- Unicode データベース-Footnote-38087646
Ref: unicodedata --- Unicode データベース-Footnote-48087718
Node: stringprep --- インターネットの文字列調製8087793
Ref: library/stringprep doc8088027
Ref: 22c68088027
Ref: library/stringprep module-stringprep8088027
Ref: bf8088027
Ref: library/stringprep stringprep-internet-string-preparation8088027
Ref: 22c78088027
Ref: library/stringprep stringprep in_table_a18090661
Ref: 22c88090661
Ref: library/stringprep stringprep in_table_b18090863
Ref: 22c98090863
Ref: library/stringprep stringprep map_table_b28091060
Ref: 22ca8091060
Ref: library/stringprep stringprep map_table_b38091256
Ref: 22cb8091256
Ref: library/stringprep stringprep in_table_c118091453
Ref: 22cc8091453
Ref: library/stringprep stringprep in_table_c128091593
Ref: 22cd8091593
Ref: library/stringprep stringprep in_table_c11_c128091743
Ref: 22ce8091743
Ref: library/stringprep stringprep in_table_c218091922
Ref: 22cf8091922
Ref: library/stringprep stringprep in_table_c228092056
Ref: 22d08092056
Ref: library/stringprep stringprep in_table_c21_c228092194
Ref: 22d18092194
Ref: library/stringprep stringprep in_table_c38092367
Ref: 22d28092367
Ref: library/stringprep stringprep in_table_c48092504
Ref: 22d38092504
Ref: library/stringprep stringprep in_table_c58092679
Ref: 22d48092679
Ref: library/stringprep stringprep in_table_c68092822
Ref: 22d58092822
Ref: library/stringprep stringprep in_table_c78092977
Ref: 22d68092977
Ref: library/stringprep stringprep in_table_c88093152
Ref: 22d78093152
Ref: library/stringprep stringprep in_table_c98093316
Ref: 22d88093316
Ref: library/stringprep stringprep in_table_d18093441
Ref: 22d98093441
Ref: library/stringprep stringprep in_table_d28093618
Ref: 22da8093618
Ref: stringprep --- インターネットの文字列調製-Footnote-18093817
Ref: stringprep --- インターネットの文字列調製-Footnote-28093887
Ref: stringprep --- インターネットの文字列調製-Footnote-38093946
Node: readline --- GNU readline のインターフェース8094005
Ref: library/readline doc8094241
Ref: 22db8094241
Ref: library/readline module-readline8094241
Ref: a88094241
Ref: library/readline readline-gnu-readline-interface8094241
Ref: 22dc8094241
Ref: library/readline readline backend8096708
Ref: 16138096708
Ref: readline --- GNU readline のインターフェース-Footnote-18097075
Node: 初期化ファイル8097160
Ref: library/readline init-file8097295
Ref: 22dd8097295
Ref: library/readline readline parse_and_bind8097439
Ref: 22de8097439
Ref: library/readline readline read_init_file8097657
Ref: 22df8097657
Node: 行バッファ8097956
Ref: library/readline line-buffer8098118
Ref: 22e08098118
Ref: library/readline readline get_line_buffer8098216
Ref: 22e18098216
Ref: library/readline readline insert_text8098379
Ref: 22e28098379
Ref: library/readline readline redisplay8098642
Ref: 146a8098642
Node: 履歴ファイル8098877
Ref: library/readline history-file8099033
Ref: 22e38099033
Ref: library/readline readline read_history_file8099139
Ref: 22e48099139
Ref: library/readline readline write_history_file8099445
Ref: 22e58099445
Ref: library/readline readline append_history_file8099788
Ref: e1a8099788
Ref: library/readline readline get_history_length8100356
Ref: 22e68100356
Ref: library/readline readline set_history_length8100402
Ref: 15598100402
Node: 履歴リスト8100766
Ref: library/readline history-list8100922
Ref: 22e78100922
Ref: library/readline readline clear_history8101038
Ref: 22e88101038
Ref: library/readline readline get_current_history_length8101386
Ref: 14698101386
Ref: library/readline readline get_history_item8101607
Ref: 14688101607
Ref: library/readline readline remove_history_item8101851
Ref: 22e98101851
Ref: library/readline readline replace_history_item8102102
Ref: 22ea8102102
Ref: library/readline readline add_history8102375
Ref: 22eb8102375
Ref: library/readline readline set_auto_history8102608
Ref: c988102608
Node: 開始フック8103066
Ref: library/readline startup-hooks8103210
Ref: 22ec8103210
Ref: library/readline readline set_startup_hook8103254
Ref: 22ed8103254
Ref: library/readline readline set_pre_input_hook8103659
Ref: 22ee8103659
Node: 補完8104232
Ref: library/readline completion8104373
Ref: 22ef8104373
Ref: library/readline readline-completion8104373
Ref: 22f08104373
Ref: library/readline readline set_completer8104849
Ref: 22f18104849
Ref: library/readline readline get_completer8105820
Ref: 22f28105820
Ref: library/readline readline get_completion_type8105990
Ref: 22f38105990
Ref: library/readline readline get_begidx8106191
Ref: 18518106191
Ref: library/readline readline get_endidx8106229
Ref: 18528106229
Ref: library/readline readline set_completer_delims8106675
Ref: 16178106675
Ref: library/readline readline get_completer_delims8106729
Ref: 22f48106729
Ref: library/readline readline set_completion_display_matches_hook8107051
Ref: 22f58107051
Node: 使用例<2>8107641
Ref: library/readline example8107758
Ref: 22f68107758
Ref: library/readline readline-example8107758
Ref: 22f78107758
Node: rlcompleter --- GNU readline の補完機能8110614
Ref: library/rlcompleter doc8110787
Ref: 22f98110787
Ref: library/rlcompleter module-rlcompleter8110787
Ref: ab8110787
Ref: library/rlcompleter rlcompleter-completion-function-for-gnu-readline8110787
Ref: 22fa8110787
Ref: library/rlcompleter completer-objects8112317
Ref: 22fc8112317
Ref: library/rlcompleter rlcompleter Completer8112317
Ref: 18ae8112317
Ref: library/rlcompleter rlcompleter Completer complete8112435
Ref: 22fb8112435
Ref: rlcompleter --- GNU readline の補完機能-Footnote-18113505
Node: バイナリデータ処理8113576
Ref: library/binary doc8113728
Ref: 22fd8113728
Ref: library/binary binary-data-services8113728
Ref: 22fe8113728
Ref: library/binary binaryservices8113728
Ref: 22188113728
Node: struct --- バイト列をパックされたバイナリデータとして解釈する8114872
Ref: library/struct doc8115081
Ref: 22ff8115081
Ref: library/struct struct-interpret-bytes-as-packed-binary-data8115081
Ref: 23008115081
Ref: library/struct module-struct8115249
Ref: c08115249
Ref: struct --- バイト列をパックされたバイナリデータとして解釈する-Footnote-18117270
Node: 関数と例外8117336
Ref: library/struct functions-and-exceptions8117498
Ref: 23038117498
Ref: library/struct struct error8117617
Ref: 12f28117617
Ref: library/struct struct pack8117767
Ref: 12488117767
Ref: library/struct struct pack_into8118086
Ref: 23048118086
Ref: library/struct struct unpack8118416
Ref: 17318118416
Ref: library/struct struct unpack_from8118894
Ref: 23058118894
Ref: library/struct struct iter_unpack8119389
Ref: f8b8119389
Ref: library/struct struct calcsize8120041
Ref: 192f8120041
Node: 書式文字列8120269
Ref: library/struct format-strings8120452
Ref: 23068120452
Ref: library/struct struct-format-strings8120452
Ref: 23018120452
Node: バイトオーダ、サイズ、アラインメント8121083
Ref: library/struct byte-order-size-and-alignment8121216
Ref: 23078121216
Ref: library/struct struct-alignment8121216
Ref: 23028121216
Ref: バイトオーダ、サイズ、アラインメント-Footnote-18125905
Node: 書式指定文字8125959
Ref: library/struct format-characters8126113
Ref: 10138126113
Ref: library/struct id18126113
Ref: 23098126113
Ref: 書式指定文字-Footnote-18139109
Ref: 書式指定文字-Footnote-28139170
Node: 使用例<3>8139246
Ref: library/struct examples8139337
Ref: 230a8139337
Ref: library/struct struct-examples8139337
Ref: 23088139337
Node: Applications8141961
Ref: library/struct applications8142141
Ref: 230b8142141
Ref: library/struct id28142141
Ref: 230c8142141
Node: Native Formats8142642
Ref: library/struct native-formats8142730
Ref: 230f8142730
Ref: library/struct struct-native-formats8142730
Ref: 230d8142730
Node: Standard Formats8143878
Ref: library/struct standard-formats8143966
Ref: 23108143966
Ref: library/struct struct-standard-formats8143966
Ref: 230e8143966
Node: クラス<3>8145405
Ref: library/struct classes8145561
Ref: 23118145561
Ref: library/struct struct-objects8145561
Ref: 23128145561
Ref: library/struct struct Struct8145661
Ref: 16158145661
Ref: library/struct struct Struct pack8146542
Ref: 23138146542
Ref: library/struct struct Struct pack_into8146802
Ref: 23158146802
Ref: library/struct struct Struct unpack8147010
Ref: 23168147010
Ref: library/struct struct Struct unpack_from8147290
Ref: 23178147290
Ref: library/struct struct Struct iter_unpack8147642
Ref: f8c8147642
Ref: library/struct struct Struct format8147964
Ref: bd48147964
Ref: library/struct struct Struct size8148246
Ref: 23148148246
Node: codecs --- codec レジストリと基底クラス8148622
Ref: library/codecs doc8148831
Ref: 23188148831
Ref: library/codecs codecs-codec-registry-and-base-classes8148831
Ref: 23198148831
Ref: library/codecs module-codecs8148831
Ref: 148148831
Ref: library/codecs codecs encode8150028
Ref: ecc8150028
Ref: library/codecs codecs decode8150740
Ref: ecd8150740
Ref: library/codecs codecs lookup8151519
Ref: 9318151519
Ref: library/codecs codecs CodecInfo8152213
Ref: 16608152213
Ref: library/codecs codecs CodecInfo name8152545
Ref: 231b8152545
Ref: library/codecs codecs CodecInfo encode8152625
Ref: 231c8152625
Ref: library/codecs codecs CodecInfo decode8152652
Ref: 231d8152652
Ref: library/codecs codecs CodecInfo incrementalencoder8153203
Ref: 23218153203
Ref: library/codecs codecs CodecInfo incrementaldecoder8153242
Ref: 23228153242
Ref: library/codecs codecs CodecInfo streamwriter8153743
Ref: 23258153743
Ref: library/codecs codecs CodecInfo streamreader8153776
Ref: 23268153776
Ref: library/codecs codecs getencoder8154458
Ref: 23298154458
Ref: library/codecs codecs getdecoder8154739
Ref: 232a8154739
Ref: library/codecs codecs getincrementalencoder8155017
Ref: 232b8155017
Ref: library/codecs codecs getincrementaldecoder8155451
Ref: 232c8155451
Ref: library/codecs codecs getreader8155879
Ref: 232d8155879
Ref: library/codecs codecs getwriter8156202
Ref: 232e8156202
Ref: library/codecs codecs register8156663
Ref: 232f8156663
Ref: library/codecs codecs unregister8157146
Ref: 7b38157146
Ref: library/codecs codecs open8157766
Ref: 70b8157766
Ref: library/codecs codecs EncodedFile8159558
Ref: 23318159558
Ref: library/codecs codecs iterencode8160739
Ref: 23328160739
Ref: library/codecs codecs iterdecode8161493
Ref: 23338161493
Ref: library/codecs codecs BOM8162478
Ref: 23348162478
Ref: library/codecs codecs BOM_BE8162504
Ref: 23358162504
Ref: library/codecs codecs BOM_LE8162533
Ref: 23368162533
Ref: library/codecs codecs BOM_UTF88162562
Ref: 23378162562
Ref: library/codecs codecs BOM_UTF168162593
Ref: 23388162593
Ref: library/codecs codecs BOM_UTF16_BE8162625
Ref: 23398162625
Ref: library/codecs codecs BOM_UTF16_LE8162660
Ref: 233a8162660
Ref: library/codecs codecs BOM_UTF328162695
Ref: 233b8162695
Ref: library/codecs codecs BOM_UTF32_BE8162727
Ref: 233c8162727
Ref: library/codecs codecs BOM_UTF32_LE8162762
Ref: 233d8162762
Ref: codecs --- codec レジストリと基底クラス-Footnote-18164236
Node: Codec 基底クラス8164302
Ref: library/codecs codec-base-classes8164454
Ref: 231a8164454
Ref: library/codecs id18164454
Ref: 233e8164454
Ref: library/codecs surrogateescape8165342
Ref: 233f8165342
Node: エラーハンドラ8165550
Ref: library/codecs error-handlers8165689
Ref: 17518165689
Ref: library/codecs id28165689
Ref: 23408165689
Ref: library/codecs codecs register_error8170990
Ref: 143e8170990
Ref: library/codecs codecs lookup_error8172883
Ref: 143f8172883
Ref: library/codecs codecs strict_errors8173219
Ref: 23418173219
Ref: library/codecs codecs ignore_errors8173393
Ref: 23428173393
Ref: library/codecs codecs replace_errors8173590
Ref: 23438173590
Ref: library/codecs codecs backslashreplace_errors8173839
Ref: 23448173839
Ref: library/codecs codecs xmlcharrefreplace_errors8174309
Ref: 23458174309
Ref: library/codecs codecs namereplace_errors8174674
Ref: 23468174674
Ref: エラーハンドラ-Footnote-18175238
Node: ステートレスなエンコードとデコード8175280
Ref: library/codecs codec-objects8175485
Ref: 23208175485
Ref: library/codecs stateless-encoding-and-decoding8175485
Ref: 23478175485
Ref: library/codecs codecs Codec8175815
Ref: 23488175815
Ref: library/codecs codecs Codec encode8175844
Ref: 231e8175844
Ref: library/codecs codecs Codec decode8176974
Ref: 231f8176974
Node: インクリメンタルなエンコードとデコード8178552
Ref: library/codecs incremental-encoding-and-decoding8178784
Ref: 23498178784
Node: IncrementalEncoder オブジェクト8179994
Ref: library/codecs incremental-encoder-objects8180171
Ref: 234c8180171
Ref: library/codecs incrementalencoder-objects8180171
Ref: 234d8180171
Ref: library/codecs codecs IncrementalEncoder8180606
Ref: 23238180606
Ref: library/codecs codecs IncrementalEncoder encode8181659
Ref: 234a8181659
Ref: library/codecs codecs IncrementalEncoder reset8182064
Ref: 234e8182064
Ref: library/codecs codecs IncrementalEncoder getstate8182437
Ref: 234f8182437
Ref: library/codecs codecs IncrementalEncoder setstate8182913
Ref: 23508182913
Node: IncrementalDecoder オブジェクト8183162
Ref: library/codecs incremental-decoder-objects8183339
Ref: 23518183339
Ref: library/codecs incrementaldecoder-objects8183339
Ref: 23528183339
Ref: library/codecs codecs IncrementalDecoder8183768
Ref: 23248183768
Ref: library/codecs codecs IncrementalDecoder decode8184818
Ref: 234b8184818
Ref: library/codecs codecs IncrementalDecoder reset8185690
Ref: 23538185690
Ref: library/codecs codecs IncrementalDecoder getstate8185789
Ref: 23548185789
Ref: library/codecs codecs IncrementalDecoder setstate8186922
Ref: 23558186922
Node: ストリームのエンコードとデコード8187168
Ref: library/codecs stream-encoding-and-decoding8187340
Ref: 23568187340
Node: StreamWriter オブジェクト8187835
Ref: library/codecs stream-writer-objects8187991
Ref: 23578187991
Ref: library/codecs streamwriter-objects8187991
Ref: 23588187991
Ref: library/codecs codecs StreamWriter8188371
Ref: 23278188371
Ref: library/codecs codecs StreamWriter write8189627
Ref: 23598189627
Ref: library/codecs codecs StreamWriter writelines8189759
Ref: 235a8189759
Ref: library/codecs codecs StreamWriter reset8190071
Ref: 235b8190071
Node: StreamReader オブジェクト8190694
Ref: library/codecs stream-reader-objects8190896
Ref: 235c8190896
Ref: library/codecs streamreader-objects8190896
Ref: 235d8190896
Ref: library/codecs codecs StreamReader8191276
Ref: 23288191276
Ref: library/codecs codecs StreamReader read8192645
Ref: 235e8192645
Ref: library/codecs codecs StreamReader readline8194309
Ref: 235f8194309
Ref: library/codecs codecs StreamReader readlines8194734
Ref: 23608194734
Ref: library/codecs codecs StreamReader reset8195246
Ref: 23618195246
Node: StreamReaderWriter オブジェクト8195812
Ref: library/codecs stream-reader-writer8196015
Ref: 23628196015
Ref: library/codecs streamreaderwriter-objects8196015
Ref: 23638196015
Ref: library/codecs codecs StreamReaderWriter8196370
Ref: 23308196370
Node: StreamRecoder オブジェクト8197246
Ref: library/codecs stream-recoder-objects8197409
Ref: 23648197409
Ref: library/codecs streamrecoder-objects8197409
Ref: 23658197409
Ref: library/codecs codecs StreamRecoder8197843
Ref: 195c8197843
Node: エンコーディングと Unicode8199316
Ref: library/codecs encodings-and-unicode8199507
Ref: 23668199507
Ref: library/codecs encodings-overview8199507
Ref: 23678199507
Ref: エンコーディングと Unicode-Footnote-18208465
Node: 標準エンコーディング8208507
Ref: library/codecs id38208717
Ref: 23688208717
Ref: library/codecs standard-encodings8208717
Ref: d868208717
Node: Python 特有のエンコーディング8231892
Ref: library/codecs python-specific-encodings8232151
Ref: 23698232151
Node: テキストエンコーディング8233133
Ref: library/codecs text-encodings8233291
Ref: 236a8233291
Ref: テキストエンコーディング-Footnote-18237188
Ref: テキストエンコーディング-Footnote-28237247
Node: バイナリ変換 Binary Transforms8237306
Ref: library/codecs binary-transforms8237507
Ref: ece8237507
Ref: library/codecs id48237507
Ref: 236b8237507
Ref: バイナリ変換 Binary Transforms-Footnote-18241666
Node: テキスト変換 Text Transforms8241872
Ref: library/codecs id68242028
Ref: 23718242028
Ref: library/codecs text-transforms8242028
Ref: ecf8242028
Node: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA8243081
Ref: library/codecs encodings-idna-internationalized-domain-names-in-applications8243360
Ref: 23728243360
Ref: library/codecs module-encodings idna8243360
Ref: 488243360
Ref: library/codecs encodings idna nameprep8246769
Ref: 23738246769
Ref: library/codecs encodings idna ToASCII8246996
Ref: 23748246996
Ref: library/codecs encodings idna ToUnicode8247185
Ref: 23758247185
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-18247349
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-28247408
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-38247467
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-48247526
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-58247585
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-68247624
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-78247695
Ref: encodings idna --- アプリケーションにおける国際化ドメイン名 IDNA-Footnote-88247754
Node: encodings mbcs --- Windows ANSI コードページ8247813
Ref: library/codecs encodings-mbcs-windows-ansi-codepage8248095
Ref: 23768248095
Ref: library/codecs module-encodings mbcs8248095
Ref: 498248095
Node: encodings utf_8_sig --- BOM 印付き UTF-88248583
Ref: library/codecs encodings-utf-8-sig-utf-8-codec-with-bom-signature8248772
Ref: 23778248772
Ref: library/codecs module-encodings utf_8_sig8248772
Ref: 4a8248772
Node: データ型8249391
Ref: library/datatypes doc8249543
Ref: 23788249543
Ref: library/datatypes data-types8249543
Ref: 23798249543
Ref: library/datatypes datatypes8249543
Ref: 237a8249543
Node: datetime --- 基本的な日付と時間の型8251647
Ref: library/datetime doc8251802
Ref: 237b8251802
Ref: library/datetime datetime-basic-date-and-time-types8251802
Ref: 237c8251802
Ref: library/datetime module-datetime8251802
Ref: 288251802
Ref: datetime --- 基本的な日付と時間の型-Footnote-18253434
Ref: datetime --- 基本的な日付と時間の型-Footnote-28253502
Ref: datetime --- 基本的な日付と時間の型-Footnote-38253553
Node: Aware オブジェクトと Naive オブジェクト8253596
Ref: library/datetime aware-and-naive-objects8253746
Ref: 237e8253746
Ref: library/datetime datetime-naive-aware8253746
Ref: 237f8253746
Ref: Aware オブジェクトと Naive オブジェクト-Footnote-18256447
Node: 定数8256522
Ref: library/datetime constants8256708
Ref: 23808256708
Ref: library/datetime datetime MINYEAR8256815
Ref: 23818256815
Ref: library/datetime datetime MAXYEAR8257022
Ref: 23828257022
Ref: library/datetime datetime UTC8257232
Ref: 4bb8257232
Node: 利用可能なデータ型8257389
Ref: library/datetime available-types8257551
Ref: 23838257551
Node: 共通の特徴8259663
Ref: library/datetime common-properties8259813
Ref: 23948259813
Node: オブジェクトが Aware なのか Naive なのかの判断8260390
Ref: library/datetime determining-if-an-object-is-aware-or-naive8260540
Ref: 23958260540
Node: timedelta オブジェクト8261444
Ref: library/datetime datetime-timedelta8261623
Ref: 23968261623
Ref: library/datetime timedelta-objects8261623
Ref: 23978261623
Ref: library/datetime datetime timedelta8261875
Ref: 99d8261875
Ref: library/datetime datetime timedelta min8264376
Ref: 23988264376
Ref: library/datetime datetime timedelta max8264524
Ref: 23998264524
Ref: library/datetime datetime timedelta resolution8264736
Ref: 239a8264736
Ref: library/datetime datetime timedelta days8265205
Ref: 239b8265205
Ref: library/datetime datetime timedelta seconds8265290
Ref: 239c8265290
Ref: library/datetime datetime timedelta microseconds8265815
Ref: 239d8265815
Ref: library/datetime datetime timedelta total_seconds8272509
Ref: 12d48272509
Node: 使用例 timedelta8273125
Ref: library/datetime examples-of-usage-timedelta8273209
Ref: 239e8273209
Node: date オブジェクト8274122
Ref: library/datetime date-objects8274301
Ref: 239f8274301
Ref: library/datetime datetime-date8274301
Ref: 23a08274301
Ref: library/datetime datetime date8274657
Ref: 1af8274657
Ref: library/datetime datetime date today8275184
Ref: 14738275184
Ref: library/datetime datetime date fromtimestamp8275347
Ref: 156d8275347
Ref: library/datetime datetime date fromordinal8276598
Ref: 23a18276598
Ref: library/datetime datetime date fromisoformat8276962
Ref: 5e08276962
Ref: library/datetime datetime date fromisocalendar8277977
Ref: 9ba8277977
Ref: library/datetime datetime date min8278300
Ref: 23a28278300
Ref: library/datetime datetime date max8278406
Ref: 23a38278406
Ref: library/datetime datetime date resolution8278517
Ref: 23a48278517
Ref: library/datetime datetime date year8278709
Ref: 23848278709
Ref: library/datetime datetime date month8278837
Ref: 23858278837
Ref: library/datetime datetime date day8278923
Ref: 23868278923
Ref: library/datetime datetime date replace8282159
Ref: 15e18282159
Ref: library/datetime datetime date timetuple8282755
Ref: 23a58282755
Ref: library/datetime datetime date toordinal8283257
Ref: 23a68283257
Ref: library/datetime datetime date weekday8283489
Ref: 23a78283489
Ref: library/datetime datetime date isoweekday8283766
Ref: 23a88283766
Ref: library/datetime datetime date isocalendar8284076
Ref: 8c38284076
Ref: library/datetime datetime date isoformat8285322
Ref: 23a98285322
Ref: library/datetime datetime date __str__8285557
Ref: 23aa8285557
Ref: library/datetime datetime date ctime8285669
Ref: 23ab8285669
Ref: library/datetime datetime date strftime8286234
Ref: c5f8286234
Ref: library/datetime datetime date __format__8286592
Ref: 23ad8286592
Ref: date オブジェクト-Footnote-18287136
Ref: date オブジェクト-Footnote-28287535
Node: 使用例 date8287773
Ref: library/datetime examples-of-usage-date8287847
Ref: 23ae8287847
Node: datetime オブジェクト8289746
Ref: library/datetime datetime-datetime8289920
Ref: 23af8289920
Ref: library/datetime datetime-objects8289920
Ref: 23b08289920
Ref: library/datetime datetime datetime8290556
Ref: 1ae8290556
Ref: library/datetime datetime datetime today8291544
Ref: 23b18291544
Ref: library/datetime datetime datetime now8291989
Ref: 4b98291989
Ref: library/datetime datetime datetime utcnow8293073
Ref: 2d38293073
Ref: library/datetime datetime datetime fromtimestamp8294182
Ref: 4ba8294182
Ref: library/datetime datetime datetime utcfromtimestamp8296477
Ref: 2d48296477
Ref: library/datetime datetime datetime fromordinal8298716
Ref: 23b28298716
Ref: library/datetime datetime datetime combine8299219
Ref: c608299219
Ref: library/datetime datetime datetime fromisoformat8300159
Ref: 5e28300159
Ref: library/datetime datetime datetime fromisocalendar8302357
Ref: 9bb8302357
Ref: library/datetime datetime datetime strptime8302741
Ref: 156e8302741
Ref: library/datetime datetime datetime min8304360
Ref: 17468304360
Ref: library/datetime datetime datetime max8304509
Ref: 23b38304509
Ref: library/datetime datetime datetime resolution8304683
Ref: 23b48304683
Ref: library/datetime datetime datetime year8304903
Ref: 238c8304903
Ref: library/datetime datetime datetime month8305035
Ref: 238d8305035
Ref: library/datetime datetime datetime day8305125
Ref: 238e8305125
Ref: library/datetime datetime datetime hour8305232
Ref: 238f8305232
Ref: library/datetime datetime datetime minute8305309
Ref: 23908305309
Ref: library/datetime datetime datetime second8305388
Ref: 23918305388
Ref: library/datetime datetime datetime microsecond8305467
Ref: 23928305467
Ref: library/datetime datetime datetime tzinfo8305556
Ref: 23938305556
Ref: library/datetime datetime datetime fold8305785
Ref: c258305785
Ref: library/datetime datetime datetime date8311293
Ref: 23b58311293
Ref: library/datetime datetime datetime time8311414
Ref: 23b68311414
Ref: library/datetime datetime datetime timetz8311813
Ref: 23b78311813
Ref: library/datetime datetime datetime replace8312198
Ref: 14748312198
Ref: library/datetime datetime datetime astimezone8313015
Ref: 99e8313015
Ref: library/datetime datetime datetime utcoffset8316309
Ref: 23b88316309
Ref: library/datetime datetime datetime dst8316843
Ref: 23b98316843
Ref: library/datetime datetime datetime tzname8317365
Ref: 23bb8317365
Ref: library/datetime datetime datetime timetuple8317694
Ref: 23bc8317694
Ref: library/datetime datetime datetime utctimetuple8318701
Ref: 23be8318701
Ref: library/datetime datetime datetime toordinal8319988
Ref: 23bf8319988
Ref: library/datetime datetime datetime timestamp8320156
Ref: 106f8320156
Ref: library/datetime datetime datetime weekday8322060
Ref: 23c08322060
Ref: library/datetime datetime datetime isoweekday8322298
Ref: 23c18322298
Ref: library/datetime datetime datetime isocalendar8322568
Ref: 8c48322568
Ref: library/datetime datetime datetime isoformat8322782
Ref: afe8322782
Ref: library/datetime datetime datetime __str__8326083
Ref: 23c28326083
Ref: library/datetime datetime datetime ctime8326232
Ref: 23c38326232
Ref: library/datetime datetime datetime strftime8326963
Ref: c5e8326963
Ref: library/datetime datetime datetime __format__8327266
Ref: 23c48327266
Node: 使用例 datetime8327796
Ref: library/datetime examples-of-usage-datetime8327878
Ref: 23c58327878
Node: time オブジェクト8332266
Ref: library/datetime datetime-time8332442
Ref: 23c68332442
Ref: library/datetime time-objects8332442
Ref: 23c78332442
Ref: library/datetime datetime time8332746
Ref: 1b08332746
Ref: library/datetime datetime time min8333573
Ref: 23c88333573
Ref: library/datetime datetime time max8333689
Ref: 23c98333689
Ref: library/datetime datetime time resolution8333821
Ref: 23ca8333821
Ref: library/datetime datetime time hour8334160
Ref: 23878334160
Ref: library/datetime datetime time minute8334233
Ref: 23888334233
Ref: library/datetime datetime time second8334308
Ref: 23898334308
Ref: library/datetime datetime time microsecond8334383
Ref: 238a8334383
Ref: library/datetime datetime time tzinfo8334468
Ref: 238b8334468
Ref: library/datetime datetime time fold8334689
Ref: 23cb8334689
Ref: library/datetime datetime time fromisoformat8336605
Ref: 5e18336605
Ref: library/datetime datetime time replace8338265
Ref: 15e28338265
Ref: library/datetime datetime time isoformat8339040
Ref: 23cc8339040
Ref: library/datetime datetime time __str__8341358
Ref: 23ce8341358
Ref: library/datetime datetime time strftime8341470
Ref: 16ee8341470
Ref: library/datetime datetime time __format__8341751
Ref: 23cf8341751
Ref: library/datetime datetime time utcoffset8342215
Ref: 23cd8342215
Ref: library/datetime datetime time dst8342745
Ref: 23d08342745
Ref: library/datetime datetime time tzname8343263
Ref: 23d18343263
Ref: time オブジェクト-Footnote-18343669
Node: 使用例 time8343734
Ref: library/datetime examples-of-usage-time8343808
Ref: 23d28343808
Node: tzinfo オブジェクト8344668
Ref: library/datetime datetime-tzinfo8344844
Ref: 23d38344844
Ref: library/datetime tzinfo-objects8344844
Ref: 23d48344844
Ref: library/datetime datetime tzinfo8344917
Ref: 5a88344917
Ref: library/datetime datetime tzinfo utcoffset8347250
Ref: 23d58347250
Ref: library/datetime datetime tzinfo dst8348923
Ref: 23d68348923
Ref: library/datetime datetime tzinfo tzname8352223
Ref: 23d78352223
Ref: library/datetime datetime tzinfo fromutc8355092
Ref: 23ba8355092
Ref: tzinfo オブジェクト-Footnote-18368968
Node: timezone オブジェクト8369008
Ref: library/datetime datetime-timezone8369198
Ref: 23d88369198
Ref: library/datetime timezone-objects8369198
Ref: 23d98369198
Ref: library/datetime datetime timezone8369764
Ref: 10918369764
Ref: library/datetime datetime timezone utcoffset8370604
Ref: 23da8370604
Ref: library/datetime datetime timezone tzname8371065
Ref: 23db8371065
Ref: library/datetime datetime timezone dst8371907
Ref: 23dc8371907
Ref: library/datetime datetime timezone fromutc8371987
Ref: 23dd8371987
Ref: library/datetime datetime timezone utc8372270
Ref: 5df8372270
Node: strftime と strptime の振る舞い8372367
Ref: library/datetime strftime-and-strptime-behavior8372523
Ref: 23de8372523
Ref: library/datetime strftime-strptime-behavior8372523
Ref: 17348372523
Ref: library/datetime format-codes8374779
Ref: 237d8374779
Node: strftime と strptime の書式コード8374896
Ref: library/datetime strftime-and-strptime-format-codes8375031
Ref: 23df8375031
Ref: strftime と strptime の書式コード-Footnote-18386761
Node: 技術詳細8386809
Ref: library/datetime technical-detail8386944
Ref: 23e08386944
Ref: 技術詳細-Footnote-18395151
Ref: 技術詳細-Footnote-28395266
Node: zoneinfo --- IANA タイムゾーンのサポート8395321
Ref: library/zoneinfo doc8395549
Ref: 23e18395549
Ref: library/zoneinfo module-zoneinfo8395549
Ref: 11a8395549
Ref: library/zoneinfo zoneinfo-iana-time-zone-support8395549
Ref: 23e28395549
Ref: zoneinfo --- IANA タイムゾーンのサポート-Footnote-18397165
Ref: zoneinfo --- IANA タイムゾーンのサポート-Footnote-28397230
Ref: zoneinfo --- IANA タイムゾーンのサポート-Footnote-38397272
Ref: zoneinfo --- IANA タイムゾーンのサポート-Footnote-48397313
Node: ZoneInfo を使用する8397354
Ref: library/zoneinfo using-zoneinfo8397493
Ref: 23e38397493
Ref: ZoneInfo を使用する-Footnote-18399517
Node: データソース8399559
Ref: library/zoneinfo data-sources8399725
Ref: 23e48399725
Ref: データソース-Footnote-18400415
Node: Configuring the data sources8400456
Ref: library/zoneinfo configuring-the-data-sources8400539
Ref: 23e68400539
Ref: library/zoneinfo zoneinfo-data-configuration8400539
Ref: 23e78400539
Node: Compile-time configuration8401292
Ref: library/zoneinfo compile-time-configuration8401417
Ref: 23eb8401417
Ref: library/zoneinfo zoneinfo-data-compile-time-config8401417
Ref: 1cdb8401417
Node: Environment configuration8402147
Ref: library/zoneinfo environment-configuration8402302
Ref: 23ec8402302
Ref: library/zoneinfo zoneinfo-data-environment-var8402302
Ref: 23e88402302
Ref: library/zoneinfo envvar-PYTHONTZPATH8402621
Ref: 23ed8402621
Node: Runtime configuration8403274
Ref: library/zoneinfo runtime-configuration8403394
Ref: 23ef8403394
Ref: library/zoneinfo zoneinfo-data-runtime-config8403394
Ref: 23e98403394
Node: ZoneInfo クラス8403762
Ref: library/zoneinfo the-zoneinfo-class8403913
Ref: 23f08403913
Ref: library/zoneinfo zoneinfo ZoneInfo8403973
Ref: 8ad8403973
Ref: library/zoneinfo zoneinfo ZoneInfo from_file8404938
Ref: 23f28404938
Ref: library/zoneinfo zoneinfo ZoneInfo no_cache8405597
Ref: 23f48405597
Ref: library/zoneinfo zoneinfo ZoneInfo clear_cache8406336
Ref: 23f18406336
Ref: library/zoneinfo zoneinfo ZoneInfo key8407138
Ref: 23f58407138
Node: 文字列表現8407989
Ref: library/zoneinfo string-representations8408088
Ref: 23f78408088
Node: Pickle serialization8408876
Ref: library/zoneinfo pickle-serialization8408975
Ref: 23f88408975
Ref: library/zoneinfo pickling8408975
Ref: 23f38408975
Node: 関数<3>8411381
Ref: library/zoneinfo functions8411521
Ref: 23f98411521
Ref: library/zoneinfo zoneinfo available_timezones8411552
Ref: 18c68411552
Ref: library/zoneinfo zoneinfo reset_tzpath8412522
Ref: 23ea8412522
Node: Globals8413219
Ref: library/zoneinfo globals8413356
Ref: 23fa8413356
Ref: library/zoneinfo zoneinfo TZPATH8413391
Ref: 1cda8413391
Node: 例外と警告8414169
Ref: library/zoneinfo exceptions-and-warnings8414288
Ref: 23fb8414288
Ref: library/zoneinfo zoneinfo ZoneInfoNotFoundError8414334
Ref: 23e58414334
Ref: library/zoneinfo zoneinfo InvalidTZPathWarning8414562
Ref: 23ee8414562
Node: calendar --- 一般的なカレンダーに関係する機能群8414736
Ref: library/calendar doc8414958
Ref: 23fc8414958
Ref: library/calendar calendar-general-calendar-related-functions8414958
Ref: 23fd8414958
Ref: library/calendar module-calendar8414958
Ref: 108414958
Ref: library/calendar calendar Calendar8416446
Ref: 23ff8416446
Ref: library/calendar calendar Calendar iterweekdays8417143
Ref: 24028417143
Ref: library/calendar calendar Calendar itermonthdates8417412
Ref: be78417412
Ref: library/calendar calendar Calendar itermonthdays8417842
Ref: 24048417842
Ref: library/calendar calendar Calendar itermonthdays28418233
Ref: 24058418233
Ref: library/calendar calendar Calendar itermonthdays38418589
Ref: be88418589
Ref: library/calendar calendar Calendar itermonthdays48418977
Ref: be98418977
Ref: library/calendar calendar Calendar monthdatescalendar8419385
Ref: 24068419385
Ref: library/calendar calendar Calendar monthdays2calendar8419618
Ref: 24078419618
Ref: library/calendar calendar Calendar monthdayscalendar8419858
Ref: 24088419858
Ref: library/calendar calendar Calendar yeardatescalendar8420061
Ref: 24098420061
Ref: library/calendar calendar Calendar yeardays2calendar8420507
Ref: 240a8420507
Ref: library/calendar calendar Calendar yeardayscalendar8420867
Ref: 240b8420867
Ref: library/calendar calendar TextCalendar8421176
Ref: 240c8421176
Ref: library/calendar calendar TextCalendar formatmonth8421428
Ref: 240d8421428
Ref: library/calendar calendar TextCalendar prmonth8421903
Ref: 240e8421903
Ref: library/calendar calendar TextCalendar formatyear8422081
Ref: 240f8422081
Ref: library/calendar calendar TextCalendar pryear8422668
Ref: 24108422668
Ref: library/calendar calendar HTMLCalendar8422841
Ref: af18422841
Ref: library/calendar calendar HTMLCalendar formatmonth8423068
Ref: 24118423068
Ref: library/calendar calendar HTMLCalendar formatyear8423379
Ref: 24128423379
Ref: library/calendar calendar HTMLCalendar formatyearpage8423650
Ref: 24138423650
Ref: library/calendar calendar HTMLCalendar formatmonthname8424387
Ref: 24148424387
Ref: library/calendar calendar HTMLCalendar cssclasses8424767
Ref: 24158424767
Ref: library/calendar calendar HTMLCalendar cssclass_noday8425181
Ref: 24168425181
Ref: library/calendar calendar HTMLCalendar cssclasses_weekday_head8425342
Ref: 24178425342
Ref: library/calendar calendar HTMLCalendar cssclass_month_head8425557
Ref: 24188425557
Ref: library/calendar calendar HTMLCalendar cssclass_month8425758
Ref: 24198425758
Ref: library/calendar calendar HTMLCalendar cssclass_year8425965
Ref: 241a8425965
Ref: library/calendar calendar HTMLCalendar cssclass_year_head8426178
Ref: 241b8426178
Ref: library/calendar calendar LocaleTextCalendar8427087
Ref: 70f8427087
Ref: library/calendar calendar LocaleHTMLCalendar8427332
Ref: 7108427332
Ref: library/calendar calendar setfirstweekday8427987
Ref: 23fe8427987
Ref: library/calendar calendar firstweekday8428496
Ref: 24038428496
Ref: library/calendar calendar isleap8428610
Ref: 24218428610
Ref: library/calendar calendar leapdays8428765
Ref: 24228428765
Ref: library/calendar calendar weekday8429038
Ref: 24238429038
Ref: library/calendar calendar weekheader8429251
Ref: 24248429251
Ref: library/calendar calendar monthrange8429425
Ref: 24258429425
Ref: library/calendar calendar monthcalendar8429567
Ref: 24268429567
Ref: library/calendar calendar prmonth8429873
Ref: 24278429873
Ref: library/calendar calendar month8430042
Ref: 24288430042
Ref: library/calendar calendar prcal8430241
Ref: 24298430241
Ref: library/calendar calendar calendar8430403
Ref: 242a8430403
Ref: library/calendar calendar timegm8430626
Ref: 242b8430626
Ref: library/calendar calendar day_name8431241
Ref: 242c8431241
Ref: library/calendar calendar day_abbr8431545
Ref: 242d8431545
Ref: library/calendar calendar MONDAY8431829
Ref: 24008431829
Ref: library/calendar calendar TUESDAY8431860
Ref: 241c8431860
Ref: library/calendar calendar WEDNESDAY8431892
Ref: 241d8431892
Ref: library/calendar calendar THURSDAY8431926
Ref: 241e8431926
Ref: library/calendar calendar FRIDAY8431959
Ref: 241f8431959
Ref: library/calendar calendar SATURDAY8431990
Ref: 24208431990
Ref: library/calendar calendar SUNDAY8432023
Ref: 24018432023
Ref: library/calendar calendar Day8432188
Ref: 44f8432188
Ref: library/calendar calendar month_name8432439
Ref: 242e8432439
Ref: library/calendar calendar month_abbr8432912
Ref: 242f8432912
Ref: library/calendar calendar JANUARY8433359
Ref: 2d08433359
Ref: library/calendar calendar FEBRUARY8433391
Ref: 2d18433391
Ref: library/calendar calendar MARCH8433424
Ref: 24308433424
Ref: library/calendar calendar APRIL8433454
Ref: 24318433454
Ref: library/calendar calendar MAY8433484
Ref: 24328433484
Ref: library/calendar calendar JUNE8433512
Ref: 24338433512
Ref: library/calendar calendar JULY8433541
Ref: 24348433541
Ref: library/calendar calendar AUGUST8433570
Ref: 24358433570
Ref: library/calendar calendar SEPTEMBER8433601
Ref: 24368433601
Ref: library/calendar calendar OCTOBER8433635
Ref: 24378433635
Ref: library/calendar calendar NOVEMBER8433667
Ref: 24388433667
Ref: library/calendar calendar DECEMBER8433700
Ref: 24398433700
Ref: library/calendar calendar Month8433873
Ref: 44e8433873
Ref: library/calendar calendar IllegalMonthError8434196
Ref: 243a8434196
Ref: library/calendar calendar IllegalMonthError month8434369
Ref: 243b8434369
Ref: library/calendar calendar IllegalWeekdayError8434433
Ref: 243c8434433
Ref: library/calendar calendar IllegalWeekdayError weekday8434611
Ref: 243d8434611
Ref: calendar --- 一般的なカレンダーに関係する機能群-Footnote-18435044
Node: コマンドラインからの使用8435112
Ref: library/calendar calendar-cli8435249
Ref: 243e8435249
Ref: library/calendar command-line-usage8435249
Ref: 243f8435249
Ref: library/calendar cmdoption-calendar-help8438028
Ref: 24408438028
Ref: library/calendar cmdoption-calendar-h8438028
Ref: 24418438028
Ref: library/calendar cmdoption-calendar-locale8438116
Ref: 24428438116
Ref: library/calendar cmdoption-calendar-L8438116
Ref: 24438438116
Ref: library/calendar cmdoption-calendar-encoding8438236
Ref: 24448438236
Ref: library/calendar cmdoption-calendar-e8438236
Ref: 24458438236
Ref: library/calendar cmdoption-calendar-type8438393
Ref: 24468438393
Ref: library/calendar cmdoption-calendar-t8438393
Ref: 24478438393
Ref: library/calendar cmdoption-calendar-first-weekday8438515
Ref: 24488438515
Ref: library/calendar cmdoption-calendar-f8438515
Ref: 24498438515
Ref: library/calendar cmdoption-calendar-arg-year8438717
Ref: 244a8438717
Ref: library/calendar cmdoption-calendar-arg-month8438808
Ref: 244b8438808
Ref: library/calendar cmdoption-calendar-width8439060
Ref: 244c8439060
Ref: library/calendar cmdoption-calendar-w8439060
Ref: 244d8439060
Ref: library/calendar cmdoption-calendar-lines8439258
Ref: 244e8439258
Ref: library/calendar cmdoption-calendar-l8439258
Ref: 244f8439258
Ref: library/calendar cmdoption-calendar-spacing8439449
Ref: 24508439449
Ref: library/calendar cmdoption-calendar-s8439449
Ref: 24518439449
Ref: library/calendar cmdoption-calendar-months8439592
Ref: 24528439592
Ref: library/calendar cmdoption-calendar-m8439592
Ref: 24538439592
Ref: library/calendar cmdoption-calendar-css8439714
Ref: 24548439714
Ref: library/calendar cmdoption-calendar-c8439714
Ref: 24558439714
Node: collections --- コンテナデータ型8439911
Ref: library/collections doc8440138
Ref: 24568440138
Ref: library/collections collections-container-datatypes8440138
Ref: 24578440138
Ref: library/collections module-collections8440138
Ref: 168440138
Ref: collections --- コンテナデータ型-Footnote-18442531
Node: ChainMap オブジェクト8442612
Ref: library/collections chainmap-objects8442751
Ref: 24588442751
Ref: library/collections collections ChainMap8443250
Ref: bea8443250
Ref: library/collections collections ChainMap maps8444586
Ref: 24598444586
Ref: library/collections collections ChainMap new_child8445076
Ref: eef8445076
Ref: library/collections collections ChainMap parents8446195
Ref: 245a8446195
Ref: ChainMap オブジェクト-Footnote-18448612
Ref: ChainMap オブジェクト-Footnote-28448654
Ref: ChainMap オブジェクト-Footnote-38448701
Ref: ChainMap オブジェクト-Footnote-48448796
Ref: ChainMap オブジェクト-Footnote-58448875
Ref: ChainMap オブジェクト-Footnote-68448972
Node: ChainMap の例とレシピ8449025
Ref: library/collections chainmap-examples-and-recipes8449116
Ref: 245b8449116
Node: Counter オブジェクト8452330
Ref: library/collections counter-objects8452502
Ref: 245c8452502
Ref: library/collections collections Counter8453257
Ref: 10678453257
Ref: library/collections collections Counter elements8455658
Ref: 12d28455658
Ref: library/collections collections Counter most_common8456125
Ref: 12d18456125
Ref: library/collections collections Counter subtract8456643
Ref: 11af8456643
Ref: library/collections collections Counter total8457230
Ref: 245d8457230
Ref: library/collections collections Counter fromkeys8457670
Ref: 245e8457670
Ref: library/collections collections Counter update8457843
Ref: 245f8457843
Ref: Counter オブジェクト-Footnote-18463967
Ref: Counter オブジェクト-Footnote-28464046
Ref: Counter オブジェクト-Footnote-38464093
Node: deque オブジェクト8464186
Ref: library/collections deque-objects8464361
Ref: 24608464361
Ref: library/collections collections deque8464430
Ref: 5a68464430
Ref: library/collections collections deque append8466387
Ref: 24618466387
Ref: library/collections collections deque appendleft8466481
Ref: 24628466481
Ref: library/collections collections deque clear8466579
Ref: 24638466579
Ref: library/collections collections deque copy8466696
Ref: da18466696
Ref: library/collections collections deque count8466818
Ref: 11b18466818
Ref: library/collections collections deque extend8466953
Ref: 24648466953
Ref: library/collections collections deque extendleft8467125
Ref: 24658467125
Ref: library/collections collections deque index8467413
Ref: d9f8467413
Ref: library/collections collections deque insert8467775
Ref: da08467775
Ref: library/collections collections deque pop8468070
Ref: 24668468070
Ref: library/collections collections deque popleft8468310
Ref: 24678468310
Ref: library/collections collections deque remove8468554
Ref: 18768468554
Ref: library/collections collections deque reverse8468759
Ref: 11b28468759
Ref: library/collections collections deque rotate8468919
Ref: 18418468919
Ref: library/collections collections deque maxlen8469482
Ref: 12d38469482
Node: deque のレシピ8472311
Ref: library/collections deque-recipes8472390
Ref: 24688472390
Ref: deque のレシピ-Footnote-18475236
Node: defaultdict オブジェクト8475297
Ref: library/collections defaultdict-objects8475526
Ref: 24698475526
Ref: library/collections collections defaultdict8475607
Ref: 118d8475607
Ref: library/collections collections defaultdict __missing__8476545
Ref: 246b8476545
Ref: library/collections collections defaultdict default_factory8478122
Ref: 246a8478122
Ref: defaultdict オブジェクト-Footnote-18478652
Node: defaultdict の使用例8478694
Ref: library/collections defaultdict-examples8478785
Ref: 246c8478785
Node: namedtuple 名前付きフィールドを持つタプルのファクトリ関数8481671
Ref: library/collections namedtuple-factory-function-for-tuples-with-named-fields8481906
Ref: 246d8481906
Ref: library/collections collections namedtuple8482460
Ref: 1ac8482460
Ref: library/collections collections somenamedtuple _make8487363
Ref: 246e8487363
Ref: library/collections collections somenamedtuple _asdict8487620
Ref: 9af8487620
Ref: library/collections collections somenamedtuple _replace8488430
Ref: 246f8488430
Ref: library/collections collections somenamedtuple _fields8489165
Ref: 24708489165
Ref: library/collections collections somenamedtuple _field_defaults8489734
Ref: 24718489734
Node: OrderedDict オブジェクト8493069
Ref: library/collections ordereddict-objects8493301
Ref: 24728493301
Ref: library/collections collections OrderedDict8496276
Ref: 5a58496276
Ref: library/collections collections OrderedDict popitem8496502
Ref: 12bb8496502
Ref: library/collections collections OrderedDict move_to_end8496803
Ref: 11b08496803
Ref: library/collections collections-ordereddict-eq8497675
Ref: 152a8497675
Ref: OrderedDict オブジェクト-Footnote-18498726
Ref: OrderedDict オブジェクト-Footnote-28498768
Node: OrderedDict の例とレシピ8498810
Ref: library/collections ordereddict-examples-and-recipes8498907
Ref: 24748498907
Node: UserDict オブジェクト8501953
Ref: library/collections userdict-objects8502132
Ref: 24758502132
Ref: library/collections collections UserDict8502614
Ref: 18ff8502614
Ref: library/collections collections UserDict data8503313
Ref: 24768503313
Node: UserList オブジェクト8503462
Ref: library/collections userlist-objects8503640
Ref: 24778503640
Ref: library/collections collections UserList8504367
Ref: 148c8504367
Ref: library/collections collections UserList data8505127
Ref: 24788505127
Node: UserString オブジェクト8506192
Ref: library/collections userstring-objects8506334
Ref: 24798506334
Ref: library/collections collections UserString8506826
Ref: da28506826
Ref: library/collections collections UserString data8507516
Ref: 247a8507516
Node: collections abc --- コンテナの抽象基底クラス8507869
Ref: library/collections abc doc8508078
Ref: 247b8508078
Ref: library/collections abc collections-abc-abstract-base-classes-for-containers8508078
Ref: 247c8508078
Ref: library/collections abc module-collections abc8508078
Ref: 178508078
Ref: collections abc --- コンテナの抽象基底クラス-Footnote-18512838
Ref: collections abc --- コンテナの抽象基底クラス-Footnote-28512915
Node: コレクション抽象基底クラス8512957
Ref: library/collections abc collections-abstract-base-classes8513159
Ref: 8448513159
Ref: library/collections abc id18513159
Ref: 247d8513159
Ref: コレクション抽象基底クラス-Footnote-18522905
Ref: コレクション抽象基底クラス-Footnote-28523438
Ref: コレクション抽象基底クラス-Footnote-38523971
Ref: コレクション抽象基底クラス-Footnote-48524504
Ref: コレクション抽象基底クラス-Footnote-58524980
Ref: コレクション抽象基底クラス-Footnote-68525513
Ref: コレクション抽象基底クラス-Footnote-78526046
Ref: コレクション抽象基底クラス-Footnote-88526579
Ref: コレクション抽象基底クラス-Footnote-98527112
Ref: コレクション抽象基底クラス-Footnote-108527645
Ref: コレクション抽象基底クラス-Footnote-118528179
Ref: コレクション抽象基底クラス-Footnote-128528713
Ref: コレクション抽象基底クラス-Footnote-138529247
Ref: コレクション抽象基底クラス-Footnote-148529781
Ref: コレクション抽象基底クラス-Footnote-158530315
Ref: コレクション抽象基底クラス-Footnote-168530849
Node: コレクションの抽象基底クラス -- 詳細な説明8531383
Ref: library/collections abc collections-abstract-base-classes-detailed-descriptions8531609
Ref: 247f8531609
Ref: library/collections abc collections abc Container8531729
Ref: 21ad8531729
Ref: library/collections abc collections abc Hashable8531859
Ref: 4c28531859
Ref: library/collections abc collections abc Sized8531983
Ref: 4c38531983
Ref: library/collections abc collections abc Callable8532104
Ref: 7b58532104
Ref: library/collections abc collections abc Iterable8532423
Ref: 21ab8532423
Ref: library/collections abc collections abc Collection8533046
Ref: c568533046
Ref: library/collections abc collections abc Iterator8533198
Ref: 21ac8533198
Ref: library/collections abc collections abc Reversible8533436
Ref: c578533436
Ref: library/collections abc collections abc Generator8533615
Ref: da88533615
Ref: library/collections abc collections abc Sequence8534124
Ref: 11948534124
Ref: library/collections abc collections abc MutableSequence8534164
Ref: 1868534164
Ref: library/collections abc collections abc ByteString8534211
Ref: 2a38534211
Ref: library/collections abc collections abc Set8535578
Ref: 21a38535578
Ref: library/collections abc collections abc MutableSet8535613
Ref: 21ae8535613
Ref: library/collections abc collections abc Mapping8535743
Ref: 8988535743
Ref: library/collections abc collections abc MutableMapping8535782
Ref: 107e8535782
Ref: library/collections abc collections abc MappingView8535969
Ref: 21af8535969
Ref: library/collections abc collections abc ItemsView8536012
Ref: 21b18536012
Ref: library/collections abc collections abc KeysView8536053
Ref: 21b08536053
Ref: library/collections abc collections abc ValuesView8536093
Ref: 21b28536093
Ref: library/collections abc collections abc Awaitable8536226
Ref: da98536226
Ref: library/collections abc collections abc Coroutine8537253
Ref: daa8537253
Ref: library/collections abc collections abc AsyncIterable8538662
Ref: dac8538662
Ref: library/collections abc collections abc AsyncIterator8538890
Ref: dab8538890
Ref: library/collections abc collections abc AsyncGenerator8539145
Ref: c588539145
Ref: library/collections abc collections abc Buffer8539551
Ref: 2a48539551
Ref: コレクションの抽象基底クラス -- 詳細な説明-Footnote-18539830
Ref: コレクションの抽象基底クラス -- 詳細な説明-Footnote-28539872
Ref: コレクションの抽象基底クラス -- 詳細な説明-Footnote-38539914
Ref: コレクションの抽象基底クラス -- 詳細な説明-Footnote-48539956
Node: 例とレシピ8539998
Ref: library/collections abc examples-and-recipes8540176
Ref: 24828540176
Ref: 例とレシピ-Footnote-18543643
Ref: 例とレシピ-Footnote-28543696
Node: heapq --- ヒープキューアルゴリズム8543738
Ref: library/heapq doc8543951
Ref: 24838543951
Ref: library/heapq heapq-heap-queue-algorithm8543951
Ref: 24848543951
Ref: library/heapq module-heapq8543951
Ref: 5f8543951
Ref: library/heapq heapq heappush8546082
Ref: 14618546082
Ref: library/heapq heapq heappop8546208
Ref: 14628546208
Ref: library/heapq heapq heappushpop8546548
Ref: 24868546548
Ref: library/heapq heapq heapify8546872
Ref: 24858546872
Ref: library/heapq heapq heapreplace8547005
Ref: 24878547005
Ref: library/heapq heapq merge8548078
Ref: dd18548078
Ref: library/heapq heapq nlargest8549609
Ref: 24888549609
Ref: library/heapq heapq nsmallest8550088
Ref: 24898550088
Ref: heapq --- ヒープキューアルゴリズム-Footnote-18551087
Node: 基本的な例8551152
Ref: library/heapq basic-examples8551292
Ref: 248a8551292
Ref: 基本的な例-Footnote-18552369
Node: 優先度キュー実装の注釈8552463
Ref: library/heapq priority-queue-implementation-notes8552618
Ref: 248b8552618
Ref: 優先度キュー実装の注釈-Footnote-18556057
Node: 理論8556169
Ref: library/heapq theory8556300
Ref: 248c8556300
Ref: 理論-Footnote-18562092
Node: bisect --- 配列二分法アルゴリズム8563007
Ref: library/bisect doc8563198
Ref: 248d8563198
Ref: library/bisect bisect-array-bisection-algorithm8563198
Ref: 248e8563198
Ref: library/bisect module-bisect8563198
Ref: d8563198
Ref: library/bisect bisect-functions8564138
Ref: 248f8564138
Ref: library/bisect bisect bisect_left8564183
Ref: 24908564183
Ref: library/bisect bisect bisect_right8565534
Ref: 24918565534
Ref: library/bisect bisect bisect8565606
Ref: 24928565606
Ref: library/bisect bisect insort_left8566170
Ref: 24938566170
Ref: library/bisect bisect insort_right8566854
Ref: 24948566854
Ref: library/bisect bisect insort8566926
Ref: 24958566926
Ref: bisect --- 配列二分法アルゴリズム-Footnote-18567815
Node: パフォーマンスに関するメモ8567881
Ref: library/bisect performance-notes8568043
Ref: 24968568043
Ref: パフォーマンスに関するメモ-Footnote-18569498
Ref: パフォーマンスに関するメモ-Footnote-28569553
Node: ソート済みリストの探索8569623
Ref: library/bisect searching-sorted-lists8569806
Ref: 24988569806
Node: 使用例<4>8571039
Ref: library/bisect examples8571174
Ref: 24998571174
Ref: library/bisect bisect-example8571208
Ref: 249a8571208
Node: array --- 効率的な数値配列8573727
Ref: library/array doc8573893
Ref: 249b8573893
Ref: library/array array-efficient-arrays-of-numeric-values8573893
Ref: 249c8573893
Ref: library/array module-array8573893
Ref: 68573893
Ref: library/array array typecodes8578867
Ref: 249e8578867
Ref: library/array array array8579032
Ref: 1858579032
Ref: library/array array array typecode8580518
Ref: 24a18580518
Ref: library/array array array itemsize8580620
Ref: 249d8580620
Ref: library/array array array append8580737
Ref: 24a28580737
Ref: library/array array array buffer_info8580852
Ref: 24a38580852
Ref: library/array array array byteswap8582333
Ref: 24a48582333
Ref: library/array array array count8582912
Ref: 24a58582912
Ref: library/array array array extend8583017
Ref: 24a08583017
Ref: library/array array array frombytes8583612
Ref: 12438583612
Ref: library/array array array fromfile8584030
Ref: 24a68584030
Ref: library/array array array fromlist8584479
Ref: 24a78584479
Ref: library/array array array fromunicode8584743
Ref: 249f8584743
Ref: library/array array array index8585103
Ref: 7ab8585103
Ref: library/array array array insert8585563
Ref: 24a88585563
Ref: library/array array array pop8585803
Ref: 24a98585803
Ref: library/array array array remove8586096
Ref: 24aa8586096
Ref: library/array array array clear8586223
Ref: 1878586223
Ref: library/array array array reverse8586337
Ref: 24ab8586337
Ref: library/array array array tobytes8586432
Ref: 12428586432
Ref: library/array array array tofile8586796
Ref: 24ac8586796
Ref: library/array array array tolist8586958
Ref: 24ad8586958
Ref: library/array array array tounicode8587076
Ref: 24ae8587076
Ref: array --- 効率的な数値配列-Footnote-18588384
Node: weakref --- 弱参照8588411
Ref: library/weakref doc8588588
Ref: 24af8588588
Ref: library/weakref mod-weakref8588588
Ref: ed58588588
Ref: library/weakref module-weakref8588588
Ref: fc8588588
Ref: library/weakref weakref-weak-references8588588
Ref: 24b08588588
Ref: library/weakref weakref ref8593963
Ref: fbb8593963
Ref: library/weakref weakref ref __callback__8596149
Ref: fbc8596149
Ref: library/weakref weakref proxy8596592
Ref: a208596592
Ref: library/weakref weakref getweakrefcount8598002
Ref: 24b28598002
Ref: library/weakref weakref getweakrefs8598130
Ref: 24b38598130
Ref: library/weakref weakref WeakKeyDictionary8598296
Ref: 18d98598296
Ref: library/weakref weakref WeakKeyDictionary keyrefs8600434
Ref: 24b48600434
Ref: library/weakref weakref WeakValueDictionary8600565
Ref: 18d88600565
Ref: library/weakref weakref WeakValueDictionary valuerefs8601087
Ref: 24b58601087
Ref: library/weakref weakref WeakSet8601219
Ref: 5a78601219
Ref: library/weakref weakref WeakMethod8601406
Ref: fba8601406
Ref: library/weakref weakref finalize8602587
Ref: a4a8602587
Ref: library/weakref weakref finalize __call__8604300
Ref: 24b68604300
Ref: library/weakref weakref finalize detach8604517
Ref: 24b78604517
Ref: library/weakref weakref finalize peek8604724
Ref: 24b88604724
Ref: library/weakref weakref finalize alive8604899
Ref: 24b98604899
Ref: library/weakref weakref finalize atexit8605063
Ref: 24ba8605063
Ref: library/weakref weakref ReferenceType8605666
Ref: 173e8605666
Ref: library/weakref weakref ProxyType8605774
Ref: 173f8605774
Ref: library/weakref weakref CallableProxyType8605911
Ref: 17408605911
Ref: library/weakref weakref ProxyTypes8606050
Ref: 24bb8606050
Ref: weakref --- 弱参照-Footnote-18606798
Ref: weakref --- 弱参照-Footnote-28606865
Ref: weakref --- 弱参照-Footnote-38606907
Ref: weakref --- 弱参照-Footnote-48606949
Node: 弱参照オブジェクト8606991
Ref: library/weakref weak-reference-objects8607097
Ref: 24bc8607097
Ref: library/weakref weakref-objects8607097
Ref: 24bd8607097
Node: 使用例<5>8610225
Ref: library/weakref example8610379
Ref: 24be8610379
Ref: library/weakref weakref-example8610379
Ref: 24bf8610379
Node: ファイナライザオブジェクト8611054
Ref: library/weakref finalize-examples8611222
Ref: 24c08611222
Ref: library/weakref finalizer-objects8611222
Ref: 24c18611222
Node: Comparing finalizers with __del__ methods8613169
Ref: library/weakref comparing-finalizers-with-del-methods8613316
Ref: 24c28613316
Node: types --- 動的な型生成と組み込み型の名前8616272
Ref: library/types doc8616469
Ref: 24c38616469
Ref: library/types module-types8616469
Ref: ec8616469
Ref: library/types types-dynamic-type-creation-and-names-for-built-in-types8616469
Ref: 24c48616469
Ref: types --- 動的な型生成と組み込み型の名前-Footnote-18617450
Node: 動的な型生成8617515
Ref: library/types dynamic-type-creation8617667
Ref: 24c58617667
Ref: library/types types new_class8617718
Ref: 11348617718
Ref: library/types types prepare_class8618542
Ref: 11358618542
Ref: library/types types resolve_bases8619882
Ref: b6a8619882
Ref: library/types types get_original_bases8620452
Ref: 49a8620452
Ref: 動的な型生成-Footnote-18622048
Ref: 動的な型生成-Footnote-28622090
Ref: 動的な型生成-Footnote-38622132
Ref: 動的な型生成-Footnote-48622174
Node: 標準的なインタプリタ型8622216
Ref: library/types standard-interpreter-types8622425
Ref: 24c68622425
Ref: library/types types NoneType8623208
Ref: 81d8623208
Ref: library/types types FunctionType8623307
Ref: 8508623307
Ref: library/types types LambdaType8623341
Ref: 24c78623341
Ref: library/types types GeneratorType8623792
Ref: 15998623792
Ref: library/types types CoroutineType8623973
Ref: e548623973
Ref: library/types types AsyncGeneratorType8624152
Ref: 24c88624152
Ref: library/types types CodeType8624383
Ref: 2c08624383
Ref: library/types types CellType8625004
Ref: 24c98625004
Ref: library/types types MethodType8625185
Ref: 17648625185
Ref: library/types types BuiltinFunctionType8625306
Ref: 24ca8625306
Ref: library/types types BuiltinMethodType8625347
Ref: 24cb8625347
Ref: library/types types WrapperDescriptorType8625637
Ref: b678625637
Ref: library/types types MethodWrapperType8625860
Ref: 6178625860
Ref: library/types types NotImplementedType8626068
Ref: 81e8626068
Ref: library/types types MethodDescriptorType8626187
Ref: b688626187
Ref: library/types types ClassMethodDescriptorType8626349
Ref: b698626349
Ref: library/types types ModuleType8626541
Ref: de08626541
Ref: library/types types EllipsisType8627347
Ref: 81c8627347
Ref: library/types types GenericAlias8627455
Ref: 7b68627455
Ref: library/types types UnionType8628413
Ref: 6068628413
Ref: library/types types TracebackType8628527
Ref: ac08628527
Ref: library/types types FrameType8628891
Ref: 17bc8628891
Ref: library/types types GetSetDescriptorType8629049
Ref: 24cc8629049
Ref: library/types types MemberDescriptorType8629421
Ref: 24cd8629421
Ref: library/types types MappingProxyType8630337
Ref: 43a8630337
Ref: library/types types MappingProxyType copy8631655
Ref: 24ce8631655
Ref: library/types types MappingProxyType get8631765
Ref: 24cf8631765
Ref: library/types types MappingProxyType items8632219
Ref: 24d08632219
Ref: library/types types MappingProxyType keys8632397
Ref: 24d18632397
Ref: library/types types MappingProxyType values8632528
Ref: 24d28632528
Ref: library/types types CapsuleType8632938
Ref: 24d38632938
Ref: 標準的なインタプリタ型-Footnote-18633084
Ref: 標準的なインタプリタ型-Footnote-28633126
Node: 追加のユーティリティクラスと関数8633168
Ref: library/types additional-utility-classes-and-functions8633401
Ref: 24d58633401
Ref: library/types types SimpleNamespace8633502
Ref: 1b38633502
Ref: library/types types DynamicClassAttribute8635680
Ref: 5f68635680
Node: コルーチンユーティリティ関数8636542
Ref: library/types coroutine-utility-functions8636733
Ref: 24d68636733
Ref: library/types types coroutine8636824
Ref: e538636824
Node: copy --- 浅いコピーおよび深いコピー操作8637925
Ref: library/copy doc8638136
Ref: 24d78638136
Ref: library/copy copy-shallow-and-deep-copy-operations8638136
Ref: 24d88638136
Ref: library/copy module-copy8638136
Ref: 1e8638136
Ref: library/copy copy copy8638989
Ref: 4fd8638989
Ref: library/copy copy deepcopy8639059
Ref: b3c8639059
Ref: library/copy copy replace8639138
Ref: 1378639138
Ref: library/copy copy Error8639320
Ref: 24d98639320
Ref: library/copy shallow-vs-deep-copy8639404
Ref: 1b6b8639404
Ref: library/copy object __copy__8642203
Ref: 24da8642203
Ref: library/copy object __deepcopy__8642340
Ref: 24db8642340
Ref: library/copy object __replace__8643050
Ref: 1388643050
Ref: copy --- 浅いコピーおよび深いコピー操作-Footnote-18643460
Node: pprint --- データの整形表示8643524
Ref: library/pprint doc8643722
Ref: 24dc8643722
Ref: library/pprint module-pprint8643722
Ref: 9c8643722
Ref: library/pprint pprint-data-pretty-printer8643722
Ref: 24dd8643722
Ref: pprint --- データの整形表示-Footnote-18645154
Node: 関数<4>8645220
Ref: library/pprint functions8645342
Ref: 24de8645342
Ref: library/pprint pprint-functions8645342
Ref: 24df8645342
Ref: library/pprint pprint pp8645373
Ref: 9f18645373
Ref: library/pprint pprint pprint8647957
Ref: 7f38647957
Ref: library/pprint pprint pformat8648356
Ref: f4d8648356
Ref: library/pprint pprint isreadable8648808
Ref: 24e18648808
Ref: library/pprint pprint isrecursive8649157
Ref: 24e28649157
Ref: library/pprint pprint saferepr8649459
Ref: 24e38649459
Node: PrettyPrinter オブジェクト8650108
Ref: library/pprint id18650251
Ref: 24e48650251
Ref: library/pprint prettyprinter-objects8650251
Ref: 24e58650251
Ref: library/pprint pprint PrettyPrinter8650330
Ref: f4c8650330
Ref: library/pprint pprint PrettyPrinter pformat8652094
Ref: 24e68652094
Ref: library/pprint pprint PrettyPrinter pprint8652336
Ref: 24e78652336
Ref: library/pprint pprint PrettyPrinter isreadable8652789
Ref: 24e88652789
Ref: library/pprint pprint PrettyPrinter isrecursive8653305
Ref: 24e98653305
Ref: library/pprint pprint PrettyPrinter format8653697
Ref: 18898653697
Node: 使用例<6>8655075
Ref: library/pprint example8655200
Ref: 24ea8655200
Ref: library/pprint pprint-example8655200
Ref: 24eb8655200
Ref: 使用例<6>-Footnote-18662603
Node: reprlib --- もう一つの repr の実装8662628
Ref: library/reprlib doc8662805
Ref: 24ec8662805
Ref: library/reprlib module-reprlib8662805
Ref: a98662805
Ref: library/reprlib reprlib-alternate-repr-implementation8662805
Ref: 24ed8662805
Ref: library/reprlib reprlib Repr8663414
Ref: 24ee8663414
Ref: library/reprlib reprlib aRepr8664484
Ref: 24f08664484
Ref: library/reprlib reprlib repr8664824
Ref: 24f18664824
Ref: library/reprlib reprlib recursive_repr8665257
Ref: 11c48665257
Ref: reprlib --- もう一つの repr の実装-Footnote-18666091
Node: Reprオブジェクト8666158
Ref: library/reprlib id18666317
Ref: 24ef8666317
Ref: library/reprlib repr-objects8666317
Ref: 24f38666317
Ref: library/reprlib reprlib Repr fillvalue8666629
Ref: 24f48666629
Ref: library/reprlib reprlib Repr maxlevel8666778
Ref: 24f58666778
Ref: library/reprlib reprlib Repr maxdict8666902
Ref: 24f68666902
Ref: library/reprlib reprlib Repr maxlist8666930
Ref: 24f78666930
Ref: library/reprlib reprlib Repr maxtuple8666958
Ref: 24f88666958
Ref: library/reprlib reprlib Repr maxset8666987
Ref: 24f98666987
Ref: library/reprlib reprlib Repr maxfrozenset8667014
Ref: 24fa8667014
Ref: library/reprlib reprlib Repr maxdeque8667047
Ref: 24fb8667047
Ref: library/reprlib reprlib Repr maxarray8667076
Ref: 24fc8667076
Ref: library/reprlib reprlib Repr maxlong8667366
Ref: 24fd8667366
Ref: library/reprlib reprlib Repr maxstring8667535
Ref: 24fe8667535
Ref: library/reprlib reprlib Repr maxother8667957
Ref: 24ff8667957
Ref: library/reprlib reprlib Repr indent8668329
Ref: 25008668329
Ref: library/reprlib reprlib Repr repr8669824
Ref: 24f28669824
Ref: library/reprlib reprlib Repr repr18669996
Ref: 25018669996
Node: Reprオブジェクトをサブクラス化する8671059
Ref: library/reprlib subclassing-repr-objects8671218
Ref: 25028671218
Ref: library/reprlib subclassing-reprs8671218
Ref: 25038671218
Node: enum --- 列挙型のサポート8671950
Ref: library/enum doc8672141
Ref: 25048672141
Ref: library/enum enum-support-for-enumerations8672141
Ref: 25058672141
Ref: library/enum module-enum8672141
Ref: 4c8672141
Ref: enum --- 列挙型のサポート-Footnote-18674391
Node: モジュールコンテンツ<2>8674455
Ref: library/enum module-contents8674582
Ref: 250a8674582
Node: データ型<2>8678359
Ref: library/enum data-types8678534
Ref: 250e8678534
Ref: library/enum enum EnumType8678575
Ref: 5e58678575
Ref: library/enum enum EnumType __call__8679149
Ref: 25108679149
Ref: library/enum enum EnumType __contains__8680461
Ref: 25118680461
Ref: library/enum enum EnumType __dir__8680937
Ref: 25128680937
Ref: library/enum enum EnumType __getitem__8681340
Ref: 25138681340
Ref: library/enum enum EnumType __iter__8681567
Ref: 25148681567
Ref: library/enum enum EnumType __len__8681766
Ref: 25158681766
Ref: library/enum enum EnumType __members__8681913
Ref: 25168681913
Ref: library/enum enum EnumType __reversed__8682037
Ref: 25178682037
Ref: library/enum enum EnumType _add_alias_8682266
Ref: 25188682266
Ref: library/enum enum EnumType _add_value_alias_8682474
Ref: 25198682474
Ref: library/enum enum Enum8682817
Ref: 5fc8682817
Ref: library/enum enum Enum name8682913
Ref: 251a8682913
Ref: library/enum enum Enum value8683078
Ref: 251b8683078
Ref: library/enum enum Enum _name_8684025
Ref: 251d8684025
Ref: library/enum enum Enum _value_8684084
Ref: 251e8684084
Ref: library/enum enum Enum _order_8684182
Ref: 251f8684182
Ref: library/enum enum Enum _ignore_8684332
Ref: 25208684332
Ref: library/enum enum Enum __dir__8684716
Ref: 17cc8684716
Ref: library/enum enum Enum _generate_next_value_8685553
Ref: 25228685553
Ref: library/enum enum Enum __init__8686523
Ref: 25238686523
Ref: library/enum enum Enum __init_subclass__8687032
Ref: 25248687032
Ref: library/enum enum Enum _missing_8687240
Ref: 25258687240
Ref: library/enum enum Enum __new__8688196
Ref: 251c8688196
Ref: library/enum enum Enum __repr__8688927
Ref: 16f08688927
Ref: library/enum enum Enum __str__8689743
Ref: 5ee8689743
Ref: library/enum enum Enum __format__8690463
Ref: 5ec8690463
Ref: library/enum enum IntEnum8691491
Ref: cad8691491
Ref: library/enum enum StrEnum8692656
Ref: 5e68692656
Ref: library/enum enum Flag8693872
Ref: 5ef8693872
Ref: library/enum enum Flag __contains__8694159
Ref: 25268694159
Ref: library/enum enum Flag __or__8695739
Ref: 25278695739
Ref: library/enum enum Flag __and__8695958
Ref: 25288695958
Ref: library/enum enum Flag __xor__8696234
Ref: 25298696234
Ref: library/enum enum Flag _numeric_repr_8696825
Ref: 252a8696825
Ref: library/enum enum IntFlag8697385
Ref: 22558697385
Ref: library/enum enum ReprEnum8699152
Ref: 5e78699152
Ref: library/enum enum EnumCheck8699720
Ref: 5f28699720
Ref: library/enum enum EnumCheck UNIQUE8699999
Ref: 252b8699999
Ref: library/enum enum EnumCheck CONTINUOUS8700522
Ref: 252c8700522
Ref: library/enum enum EnumCheck NAMED_FLAGS8701053
Ref: 252d8701053
Ref: library/enum enum FlagBoundary8702032
Ref: 5f08702032
Ref: library/enum enum FlagBoundary STRICT8702181
Ref: 252e8702181
Ref: library/enum enum FlagBoundary CONFORM8702838
Ref: 252f8702838
Ref: library/enum enum FlagBoundary EJECT8703307
Ref: 25308703307
Ref: library/enum enum FlagBoundary KEEP8703747
Ref: 25318703747
Node: __dunder__ 名のサポート8704413
Ref: library/enum supported-dunder-names8704530
Ref: 25328704530
Node: _sunder_ 名のサポート8705012
Ref: library/enum supported-sunder-names8705129
Ref: 25338705129
Ref: _sunder_ 名のサポート-Footnote-18707109
Node: ユーティリティとデコレータ8707196
Ref: library/enum ipython-s-rich-display8707344
Ref: 25348707344
Ref: library/enum utilities-and-decorators8707344
Ref: 25358707344
Ref: library/enum enum auto8707430
Ref: c6a8707430
Ref: library/enum enum property8709224
Ref: 5f58709224
Ref: library/enum enum unique8709748
Ref: 250c8709748
Ref: library/enum enum verify8710400
Ref: 5f18710400
Ref: library/enum enum member8710676
Ref: 5f38710676
Ref: library/enum enum nonmember8710834
Ref: 5f48710834
Ref: library/enum enum global_enum8710998
Ref: 5f78710998
Ref: library/enum enum show_flag_values8711368
Ref: 250d8711368
Node: 注釈8711612
Ref: library/enum notes8711736
Ref: 250b8711736
Node: graphlib --- グラフ構造を操作する機能8712830
Ref: library/graphlib doc8712970
Ref: 25368712970
Ref: library/graphlib graphlib-functionality-to-operate-with-graph-like-structures8712970
Ref: 25378712970
Ref: library/graphlib module-graphlib8712970
Ref: 5b8712970
Ref: library/graphlib graphlib TopologicalSorter8713189
Ref: 8af8713189
Ref: library/graphlib graphlib TopologicalSorter add8716955
Ref: 25388716955
Ref: library/graphlib graphlib TopologicalSorter prepare8717878
Ref: 25398717878
Ref: library/graphlib graphlib TopologicalSorter is_active8718357
Ref: 253a8718357
Ref: library/graphlib graphlib TopologicalSorter done8719312
Ref: 253c8719312
Ref: library/graphlib graphlib TopologicalSorter get_ready8720014
Ref: 253b8720014
Ref: library/graphlib graphlib TopologicalSorter static_order8720619
Ref: 253d8720619
Ref: graphlib --- グラフ構造を操作する機能-Footnote-18722151
Node: 例外<4>8722219
Ref: library/graphlib exceptions8722314
Ref: 253f8722314
Ref: library/graphlib graphlib CycleError8722428
Ref: 253e8722428
Node: 数値と数学モジュール8723098
Ref: library/numeric doc8723271
Ref: 25408723271
Ref: library/numeric numeric8723271
Ref: 25418723271
Ref: library/numeric numeric-and-mathematical-modules8723271
Ref: 25428723271
Node: numbers --- 数の抽象基底クラス8724452
Ref: library/numbers doc8724588
Ref: 25438724588
Ref: library/numbers module-numbers8724588
Ref: 8e8724588
Ref: library/numbers numbers-numeric-abstract-base-classes8724588
Ref: 25448724588
Ref: library/numbers numbers Number8725012
Ref: 25458725012
Ref: numbers --- 数の抽象基底クラス-Footnote-18725319
Ref: numbers --- 数の抽象基底クラス-Footnote-28725386
Node: 数値塔8725428
Ref: library/numbers the-numeric-tower8725549
Ref: 25468725549
Ref: library/numbers numbers Complex8725583
Ref: 25478725583
Ref: library/numbers numbers Complex real8726112
Ref: 25488726112
Ref: library/numbers numbers Complex imag8726216
Ref: 25498726216
Ref: library/numbers numbers Complex conjugate8726320
Ref: 254a8726320
Ref: library/numbers numbers Real8726508
Ref: 20fb8726508
Ref: library/numbers numbers Rational8727068
Ref: 12908727068
Ref: library/numbers numbers Rational numerator8727521
Ref: 254b8727521
Ref: library/numbers numbers Rational denominator8727588
Ref: 254c8727588
Ref: library/numbers numbers Integral8727657
Ref: 1f1d8727657
Node: Notes for type implementers8728125
Ref: library/numbers notes-for-type-implementers8728246
Ref: 254d8728246
Node: さらに数のABCを追加する8729088
Ref: library/numbers adding-more-numeric-abcs8729215
Ref: 254e8729215
Node: 算術演算の実装8729723
Ref: library/numbers id18729850
Ref: 254f8729850
Ref: library/numbers implementing-the-arithmetic-operations8729850
Ref: 1e498729850
Node: math --- 数学関数8734795
Ref: library/math doc8734977
Ref: 25508734977
Ref: library/math math-mathematical-functions8734977
Ref: 25518734977
Ref: library/math module-math8734977
Ref: 818734977
Ref: math --- 数学関数-Footnote-18749439
Ref: math --- 数学関数-Footnote-28749492
Ref: math --- 数学関数-Footnote-38749545
Ref: math --- 数学関数-Footnote-48749598
Node: 数論および数表現の関数8749651
Ref: library/math number-theoretic-and-representation-functions8749778
Ref: 25648749778
Ref: library/math math ceil8749852
Ref: 136a8749852
Ref: library/math math comb8750115
Ref: 69b8750115
Ref: library/math math copysign8750742
Ref: 137b8750742
Ref: library/math math fabs8751024
Ref: 25528751024
Ref: library/math math factorial8751095
Ref: 9158751095
Ref: library/math math floor8751391
Ref: 13698751391
Ref: library/math math fma8751653
Ref: 1e68751653
Ref: library/math math fmod8752338
Ref: 1fc88752338
Ref: library/math math frexp8753510
Ref: 25538753510
Ref: library/math math fsum8753980
Ref: 137c8753980
Ref: library/math math gcd8754736
Ref: 8de8754736
Ref: library/math math isclose8755298
Ref: d7d8755298
Ref: library/math math isfinite8756917
Ref: 11bc8756917
Ref: library/math math isinf8757176
Ref: 13798757176
Ref: library/math math isnan8757347
Ref: 137a8757347
Ref: library/math math isqrt8757523
Ref: 9d38757523
Ref: library/math math lcm8758043
Ref: 8df8758043
Ref: library/math math ldexp8758437
Ref: 25548758437
Ref: library/math math modf8758583
Ref: 25558758583
Ref: library/math math nextafter8758775
Ref: 4658758775
Ref: library/math math perm8759491
Ref: 69c8759491
Ref: library/math math prod8760075
Ref: 9d28760075
Ref: library/math math remainder8760477
Ref: b218760477
Ref: library/math math sumprod8761642
Ref: 4648761642
Ref: library/math math trunc8762100
Ref: 136b8762100
Ref: library/math math ulp8762570
Ref: 8e08762570
Ref: 数論および数表現の関数-Footnote-18764703
Ref: 数論および数表現の関数-Footnote-28764808
Node: 指数関数と対数関数8764850
Ref: library/math power-and-logarithmic-functions8764998
Ref: 25658764998
Ref: library/math math cbrt8765062
Ref: 62d8765062
Ref: library/math math exp8765162
Ref: 12e38765162
Ref: library/math math exp28765397
Ref: 62c8765397
Ref: library/math math expm18765496
Ref: 11bd8765496
Ref: library/math math log8766113
Ref: 14658766113
Ref: library/math math log1p8766381
Ref: 13808766381
Ref: library/math math log28766586
Ref: 10af8766586
Ref: library/math math log108766992
Ref: 25568766992
Ref: library/math math pow8767165
Ref: 62e8767165
Ref: library/math math sqrt8768148
Ref: 9d48768148
Ref: 指数関数と対数関数-Footnote-18768255
Node: 三角関数8768314
Ref: library/math trigonometric-functions8768441
Ref: 25668768441
Ref: library/math math acos8768480
Ref: 25578768480
Ref: library/math math asin8768615
Ref: 25588768615
Ref: library/math math atan8768762
Ref: 25598768762
Ref: library/math math atan28768909
Ref: 255a8768909
Ref: library/math math cos8769542
Ref: 14648769542
Ref: library/math math dist8769621
Ref: 9d08769621
Ref: library/math math hypot8770010
Ref: 9d18770010
Ref: library/math math sin8770870
Ref: 14638770870
Ref: library/math math tan8770949
Ref: 255b8770949
Node: 角度変換8771028
Ref: library/math angular-conversion8771143
Ref: 25678771143
Ref: library/math math degrees8771182
Ref: 255c8771182
Ref: library/math math radians8771275
Ref: 255d8771275
Node: 双曲線関数8771368
Ref: library/math hyperbolic-functions8771483
Ref: 25688771483
Ref: library/math math acosh8771640
Ref: 137d8771640
Ref: library/math math asinh8771721
Ref: 137e8771721
Ref: library/math math atanh8771802
Ref: 137f8771802
Ref: library/math math cosh8771883
Ref: 255e8771883
Ref: library/math math sinh8771960
Ref: 255f8771960
Ref: library/math math tanh8772037
Ref: 25608772037
Ref: 双曲線関数-Footnote-18772150
Node: 特殊関数8772209
Ref: library/math special-functions8772321
Ref: 25698772321
Ref: library/math math erf8772360
Ref: ba68772360
Ref: library/math math erfc8772789
Ref: ba78772789
Ref: library/math math gamma8773091
Ref: 11be8773091
Ref: library/math math lgamma8773202
Ref: 11bf8773202
Ref: 特殊関数-Footnote-18773372
Ref: 特殊関数-Footnote-28773448
Ref: 特殊関数-Footnote-38773519
Ref: 特殊関数-Footnote-48773595
Ref: 特殊関数-Footnote-58773681
Node: 定数<2>8773766
Ref: library/math constants8773854
Ref: 256a8773854
Ref: library/math math pi8773883
Ref: 25618773883
Ref: library/math math e8773994
Ref: 25628773994
Ref: library/math math tau8774112
Ref: 25638774112
Ref: library/math math inf8774503
Ref: c508774503
Ref: library/math math nan8774712
Ref: 62f8774712
Ref: 定数<2>-Footnote-18777166
Ref: 定数<2>-Footnote-28777218
Ref: 定数<2>-Footnote-38777246
Node: cmath --- 複素数用の数学関数8777293
Ref: library/cmath doc8777495
Ref: 256b8777495
Ref: library/cmath cmath-mathematical-functions-for-complex-numbers8777495
Ref: 256c8777495
Ref: library/cmath module-cmath8777495
Ref: 118777495
Node: 極座標変換8779536
Ref: library/cmath conversions-to-and-from-polar-coordinates8779664
Ref: 256e8779664
Ref: library/cmath cmath phase8780382
Ref: 256f8780382
Ref: library/cmath cmath polar8781197
Ref: 25708781197
Ref: library/cmath cmath rect8781434
Ref: 25718781434
Node: 指数関数と対数関数<2>8781616
Ref: library/cmath power-and-logarithmic-functions8781768
Ref: 25728781768
Ref: library/cmath cmath exp8781832
Ref: 25738781832
Ref: library/cmath cmath log8781940
Ref: 25748781940
Ref: library/cmath cmath log108782254
Ref: 25758782254
Ref: library/cmath cmath sqrt8782408
Ref: 256d8782408
Node: 三角関数<2>8782545
Ref: library/cmath trigonometric-functions8782700
Ref: 25768782700
Ref: library/cmath cmath acos8782739
Ref: 25778782739
Ref: library/cmath cmath asin8783058
Ref: 25788783058
Ref: library/cmath cmath atan8783196
Ref: 25798783196
Ref: library/cmath cmath cos8783496
Ref: 257a8783496
Ref: library/cmath cmath sin8783564
Ref: 257b8783564
Ref: library/cmath cmath tan8783632
Ref: 257c8783632
Node: 双曲線関数<2>8783700
Ref: library/cmath hyperbolic-functions8783837
Ref: 257d8783837
Ref: library/cmath cmath acosh8783881
Ref: 257e8783881
Ref: library/cmath cmath asinh8784066
Ref: 257f8784066
Ref: library/cmath cmath atanh8784375
Ref: 25808784375
Ref: library/cmath cmath cosh8784680
Ref: 25818784680
Ref: library/cmath cmath sinh8784758
Ref: 25828784758
Ref: library/cmath cmath tanh8784836
Ref: 25838784836
Node: 類別関数8784914
Ref: library/cmath classification-functions8785045
Ref: 25848785045
Ref: library/cmath cmath isfinite8785084
Ref: 25858785084
Ref: library/cmath cmath isinf8785284
Ref: 25868785284
Ref: library/cmath cmath isnan8785475
Ref: 25878785475
Ref: library/cmath cmath isclose8785650
Ref: d7e8785650
Ref: 類別関数-Footnote-18787308
Node: 定数<3>8787350
Ref: library/cmath constants8787454
Ref: 25888787454
Ref: library/cmath cmath pi8787483
Ref: 25898787483
Ref: library/cmath cmath e8787571
Ref: 258a8787571
Ref: library/cmath cmath tau8787666
Ref: c4f8787666
Ref: library/cmath cmath inf8787778
Ref: c518787778
Ref: library/cmath cmath infj8787921
Ref: c538787921
Ref: library/cmath cmath nan8788102
Ref: c528788102
Ref: library/cmath cmath nanj8788264
Ref: c548788264
Node: decimal --- 10進固定小数点と浮動小数点の演算8789975
Ref: library/decimal doc8790179
Ref: 258b8790179
Ref: library/decimal decimal-decimal-fixed-point-and-floating-point-arithmetic8790179
Ref: 258c8790179
Ref: library/decimal module-decimal8790179
Ref: 2e8790179
Ref: decimal --- 10進固定小数点と浮動小数点の演算-Footnote-18796825
Ref: decimal --- 10進固定小数点と浮動小数点の演算-Footnote-28796892
Node: クイックスタートチュートリアル8796946
Ref: library/decimal decimal-tutorial8797122
Ref: 10748797122
Ref: library/decimal quick-start-tutorial8797122
Ref: 259c8797122
Node: Decimal オブジェクト8805394
Ref: library/decimal decimal-decimal8805605
Ref: 259f8805605
Ref: library/decimal decimal-objects8805605
Ref: 25a08805605
Ref: library/decimal decimal Decimal8805670
Ref: 27d8805670
Ref: library/decimal decimal Decimal adjusted8811613
Ref: 25a18811613
Ref: library/decimal decimal Decimal as_integer_ratio8811970
Ref: c628811970
Ref: library/decimal decimal Decimal as_tuple8812466
Ref: 25a28812466
Ref: library/decimal decimal Decimal canonical8812655
Ref: 25a38812655
Ref: library/decimal decimal Decimal compare8812971
Ref: 25a48812971
Ref: library/decimal decimal Decimal compare_signal8813451
Ref: 25a58813451
Ref: library/decimal decimal Decimal compare_total8813887
Ref: 25a68813887
Ref: library/decimal decimal Decimal compare_total_mag8815266
Ref: 25a78815266
Ref: library/decimal decimal Decimal conjugate8816005
Ref: 25a88816005
Ref: library/decimal decimal Decimal copy_abs8816178
Ref: 25a98816178
Ref: library/decimal decimal Decimal copy_negate8816417
Ref: 25aa8816417
Ref: library/decimal decimal Decimal copy_sign8816665
Ref: 25ab8816665
Ref: library/decimal decimal Decimal exp8817311
Ref: 107c8817311
Ref: library/decimal decimal Decimal from_float8817735
Ref: 11d58817735
Ref: library/decimal decimal Decimal fma8818958
Ref: 25ac8818958
Ref: library/decimal decimal Decimal is_canonical8819250
Ref: 25ad8819250
Ref: library/decimal decimal Decimal is_finite8819619
Ref: 25ae8819619
Ref: library/decimal decimal Decimal is_infinite8819799
Ref: 25af8819799
Ref: library/decimal decimal Decimal is_nan8819988
Ref: 25b08819988
Ref: library/decimal decimal Decimal is_normal8820186
Ref: 25b18820186
Ref: library/decimal decimal Decimal is_qnan8820468
Ref: 25b28820468
Ref: library/decimal decimal Decimal is_signed8820639
Ref: 25b38820639
Ref: library/decimal decimal Decimal is_snan8820911
Ref: 25b48820911
Ref: library/decimal decimal Decimal is_subnormal8821082
Ref: 25b58821082
Ref: library/decimal decimal Decimal is_zero8821283
Ref: 25b68821283
Ref: library/decimal decimal Decimal ln8821470
Ref: 107d8821470
Ref: library/decimal decimal Decimal log108821683
Ref: 25b78821683
Ref: library/decimal decimal Decimal logb8821886
Ref: 25b88821886
Ref: library/decimal decimal Decimal logical_and8822335
Ref: 25b98822335
Ref: library/decimal decimal Decimal logical_invert8822607
Ref: 25bb8822607
Ref: library/decimal decimal Decimal logical_or8822786
Ref: 25bc8822786
Ref: library/decimal decimal Decimal logical_xor8823054
Ref: 25bd8823054
Ref: library/decimal decimal Decimal max8823333
Ref: 25be8823333
Ref: library/decimal decimal Decimal max_mag8823741
Ref: 25bf8823741
Ref: library/decimal decimal Decimal min8823912
Ref: 25c08823912
Ref: library/decimal decimal Decimal min_mag8824320
Ref: 25c18824320
Ref: library/decimal decimal Decimal next_minus8824491
Ref: 25c28824491
Ref: library/decimal decimal Decimal next_plus8824784
Ref: 25c38824784
Ref: library/decimal decimal Decimal next_toward8825076
Ref: 25c48825076
Ref: library/decimal decimal Decimal normalize8825441
Ref: 25c58825441
Ref: library/decimal decimal Decimal number_class8826493
Ref: 25c68826493
Ref: library/decimal decimal Decimal quantize8827552
Ref: 10808827552
Ref: library/decimal decimal Decimal radix8829098
Ref: 25c88829098
Ref: library/decimal decimal Decimal remainder_near8829351
Ref: 25c98829351
Ref: library/decimal decimal Decimal rotate8830243
Ref: 25ca8830243
Ref: library/decimal decimal Decimal same_quantum8830935
Ref: 25cb8830935
Ref: library/decimal decimal Decimal scaleb8831522
Ref: 25cc8831522
Ref: library/decimal decimal Decimal shift8831869
Ref: 25cd8831869
Ref: library/decimal decimal Decimal sqrt8832556
Ref: 25ce8832556
Ref: library/decimal decimal Decimal to_eng_string8832663
Ref: 25cf8832663
Ref: library/decimal decimal Decimal to_integral8833213
Ref: 25d08833213
Ref: library/decimal decimal Decimal to_integral_exact8833478
Ref: 25d28833478
Ref: library/decimal decimal Decimal to_integral_value8834099
Ref: 25d18834099
Node: 論理引数8836693
Ref: library/decimal logical-operands8836768
Ref: 25d38836768
Ref: library/decimal logical-operands-label8836768
Ref: 25ba8836768
Node: Context オブジェクト8837182
Ref: library/decimal context-objects8837357
Ref: 25d48837357
Ref: library/decimal decimal-context8837357
Ref: 25d58837357
Ref: library/decimal decimal getcontext8837925
Ref: 15378837925
Ref: library/decimal decimal setcontext8838048
Ref: 259d8838048
Ref: library/decimal decimal localcontext8838328
Ref: 176f8838328
Ref: library/decimal decimal BasicContext8840121
Ref: 10788840121
Ref: library/decimal decimal ExtendedContext8840736
Ref: 10798840736
Ref: library/decimal decimal DefaultContext8841562
Ref: 10778841562
Ref: library/decimal decimal Context8843066
Ref: 107f8843066
Ref: library/decimal decimal Context clear_flags8846625
Ref: 259e8846625
Ref: library/decimal decimal Context clear_traps8846730
Ref: 25da8846730
Ref: library/decimal decimal Context copy8846871
Ref: 25db8846871
Ref: library/decimal decimal Context copy_decimal8846960
Ref: 25dc8846960
Ref: library/decimal decimal Context create_decimal8847076
Ref: 107b8847076
Ref: library/decimal decimal Context create_decimal_from_float8848643
Ref: 25dd8848643
Ref: library/decimal decimal Context Etiny8849511
Ref: 25c78849511
Ref: library/decimal decimal Context Etop8849784
Ref: 25de8849784
Ref: library/decimal decimal Context abs8850505
Ref: 25df8850505
Ref: library/decimal decimal Context add8850583
Ref: 25e08850583
Ref: library/decimal decimal Context canonical8850666
Ref: 12d58850666
Ref: library/decimal decimal Context compare8850772
Ref: 25e18850772
Ref: library/decimal decimal Context compare_signal8850871
Ref: 25e28850871
Ref: library/decimal decimal Context compare_total8850992
Ref: 25e38850992
Ref: library/decimal decimal Context compare_total_mag8851121
Ref: 25e48851121
Ref: library/decimal decimal Context copy_abs8851272
Ref: 25e58851272
Ref: library/decimal decimal Context copy_negate8851385
Ref: 25e68851385
Ref: library/decimal decimal Context copy_sign8851492
Ref: 25e78851492
Ref: library/decimal decimal Context divide8851593
Ref: 25e88851593
Ref: library/decimal decimal Context divide_int8851691
Ref: 25e98851691
Ref: library/decimal decimal Context divmod8851817
Ref: 25ea8851817
Ref: library/decimal decimal Context exp8851942
Ref: 25eb8851942
Ref: library/decimal decimal Context fma8852017
Ref: 25ec8852017
Ref: library/decimal decimal Context is_canonical8852129
Ref: 12d68852129
Ref: library/decimal decimal Context is_finite8852302
Ref: 25ed8852302
Ref: library/decimal decimal Context is_infinite8852458
Ref: 25ee8852458
Ref: library/decimal decimal Context is_nan8852616
Ref: 25ef8852616
Ref: library/decimal decimal Context is_normal8852780
Ref: 25f08852780
Ref: library/decimal decimal Context is_qnan8852941
Ref: 25f18852941
Ref: library/decimal decimal Context is_signed8853102
Ref: 25f28853102
Ref: library/decimal decimal Context is_snan8853263
Ref: 25f38853263
Ref: library/decimal decimal Context is_subnormal8853424
Ref: 25f48853424
Ref: library/decimal decimal Context is_zero8853591
Ref: 25f58853591
Ref: library/decimal decimal Context ln8853748
Ref: 25f68853748
Ref: library/decimal decimal Context log108853845
Ref: 25f78853845
Ref: library/decimal decimal Context logb8853932
Ref: 25f88853932
Ref: library/decimal decimal Context logical_and8854039
Ref: 25f98854039
Ref: library/decimal decimal Context logical_invert8854158
Ref: 25fa8854158
Ref: library/decimal decimal Context logical_or8854256
Ref: 25fb8854256
Ref: library/decimal decimal Context logical_xor8854373
Ref: 25fc8854373
Ref: library/decimal decimal Context max8854492
Ref: 25fd8854492
Ref: library/decimal decimal Context max_mag8854614
Ref: 25fe8854614
Ref: library/decimal decimal Context min8854725
Ref: 25ff8854725
Ref: library/decimal decimal Context min_mag8854847
Ref: 26008854847
Ref: library/decimal decimal Context minus8854958
Ref: 26018854958
Ref: library/decimal decimal Context multiply8855080
Ref: 26028855080
Ref: library/decimal decimal Context next_minus8855168
Ref: 26038855168
Ref: library/decimal decimal Context next_plus8855283
Ref: 26048855283
Ref: library/decimal decimal Context next_toward8855397
Ref: 26058855397
Ref: library/decimal decimal Context normalize8855521
Ref: 26068855521
Ref: library/decimal decimal Context number_class8855617
Ref: 26078855617
Ref: library/decimal decimal Context plus8855725
Ref: 26088855725
Ref: library/decimal decimal Context power8855988
Ref: 26098855988
Ref: library/decimal decimal Context quantize8858036
Ref: 260a8858036
Ref: library/decimal decimal Context radix8858163
Ref: 260b8858163
Ref: library/decimal decimal Context remainder8858263
Ref: 260c8858263
Ref: library/decimal decimal Context remainder_near8858460
Ref: 260d8858460
Ref: library/decimal decimal Context rotate8858723
Ref: 260e8858723
Ref: library/decimal decimal Context same_quantum8858827
Ref: 260f8858827
Ref: library/decimal decimal Context scaleb8858974
Ref: 26108858974
Ref: library/decimal decimal Context shift8859114
Ref: 26118859114
Ref: library/decimal decimal Context sqrt8859220
Ref: 26128859220
Ref: library/decimal decimal Context subtract8859323
Ref: 26138859323
Ref: library/decimal decimal Context to_eng_string8859417
Ref: 26148859417
Ref: library/decimal decimal Context to_integral_exact8859841
Ref: 26158859841
Ref: library/decimal decimal Context to_sci_string8859941
Ref: 26168859941
Node: 定数<4>8860049
Ref: library/decimal constants8860213
Ref: 26178860213
Ref: library/decimal decimal-rounding-modes8860213
Ref: 26188860213
Ref: library/decimal decimal MAX_PREC8860644
Ref: 25d68860644
Ref: library/decimal decimal MAX_EMAX8860782
Ref: 25d98860782
Ref: library/decimal decimal MIN_EMIN8860920
Ref: 25d88860920
Ref: library/decimal decimal MIN_ETINY8861059
Ref: 26198861059
Ref: library/decimal decimal HAVE_THREADS8861185
Ref: 10758861185
Ref: library/decimal decimal HAVE_CONTEXTVAR8861395
Ref: 1cdd8861395
Node: 丸めモード8861763
Ref: library/decimal rounding-modes8861913
Ref: 25d78861913
Ref: library/decimal decimal ROUND_CEILING8861957
Ref: 258d8861957
Ref: library/decimal decimal ROUND_DOWN8862041
Ref: 258e8862041
Ref: library/decimal decimal ROUND_FLOOR8862113
Ref: 258f8862113
Ref: library/decimal decimal ROUND_HALF_DOWN8862196
Ref: 25908862196
Ref: library/decimal decimal ROUND_HALF_EVEN8862312
Ref: 25918862312
Ref: library/decimal decimal ROUND_HALF_UP8862434
Ref: 25928862434
Ref: library/decimal decimal ROUND_UP8862560
Ref: 25938862560
Ref: library/decimal decimal ROUND_05UP8862642
Ref: 25948862642
Node: シグナル8862840
Ref: library/decimal decimal-signals8863001
Ref: 10738863001
Ref: library/decimal signals8863001
Ref: 261a8863001
Ref: library/decimal decimal Clamped8863982
Ref: 25958863982
Ref: library/decimal decimal DecimalException8864424
Ref: 261b8864424
Ref: library/decimal decimal DivisionByZero8864577
Ref: 25968864577
Ref: library/decimal decimal Inexact8865004
Ref: 25978865004
Ref: library/decimal decimal InvalidOperation8865431
Ref: 107a8865431
Ref: library/decimal decimal Overflow8866059
Ref: 259a8866059
Ref: library/decimal decimal Rounded8866707
Ref: 25988866707
Ref: library/decimal decimal Subnormal8867260
Ref: 25998867260
Ref: library/decimal decimal Underflow8867609
Ref: 259b8867609
Ref: library/decimal decimal FloatOperation8867975
Ref: 10728867975
Node: Floating-Point Notes8869489
Ref: library/decimal decimal-notes8869665
Ref: 261c8869665
Ref: library/decimal floating-point-notes8869665
Ref: 261d8869665
Node: 精度を上げて丸め誤差を抑制する8869798
Ref: library/decimal mitigating-round-off-error-with-increased-precision8869918
Ref: 261e8869918
Node: 特殊値8871713
Ref: library/decimal special-values8871833
Ref: 261f8871833
Node: スレッドを使った処理8875724
Ref: library/decimal decimal-threads8875897
Ref: 26208875897
Ref: library/decimal working-with-threads8875897
Ref: 26218875897
Node: レシピ8877700
Ref: library/decimal decimal-recipes8877864
Ref: 26228877864
Ref: library/decimal recipes8877864
Ref: 26238877864
Node: Decimal FAQ8882749
Ref: library/decimal decimal-faq8882874
Ref: 26248882874
Ref: library/decimal id18882874
Ref: 26258882874
Ref: Decimal FAQ-Footnote-18892483
Ref: Decimal FAQ-Footnote-28892550
Ref: Decimal FAQ-Footnote-38892581
Ref: Decimal FAQ-Footnote-48892639
Ref: Decimal FAQ-Footnote-58892742
Node: fractions --- 有理数8892859
Ref: library/fractions doc8893064
Ref: 26268893064
Ref: library/fractions fractions-rational-numbers8893064
Ref: 26278893064
Ref: library/fractions module-fractions8893064
Ref: 538893064
Ref: library/fractions fractions Fraction8893445
Ref: 1c88893445
Ref: library/fractions fractions Fraction numerator8898109
Ref: 26298898109
Ref: library/fractions fractions Fraction denominator8898206
Ref: 262a8898206
Ref: library/fractions fractions Fraction as_integer_ratio8898305
Ref: 262b8898305
Ref: library/fractions fractions Fraction is_integer8898554
Ref: 262c8898554
Ref: library/fractions fractions Fraction from_float8898686
Ref: 11d68898686
Ref: library/fractions fractions Fraction from_decimal8899177
Ref: 11d78899177
Ref: library/fractions fractions Fraction limit_denominator8899597
Ref: 26288899597
Ref: library/fractions fractions Fraction __floor__8900499
Ref: 16ed8900499
Ref: library/fractions fractions Fraction __ceil__8900812
Ref: 16ec8900812
Ref: library/fractions fractions Fraction __round__8901020
Ref: 16eb8901020
Ref: library/fractions fractions Fraction __format__8901539
Ref: 262d8901539
Ref: fractions --- 有理数-Footnote-18903872
Ref: fractions --- 有理数-Footnote-28903941
Node: random --- 疑似乱数を生成する8903983
Ref: library/random doc8904165
Ref: 262e8904165
Ref: library/random module-random8904165
Ref: a68904165
Ref: library/random random-generate-pseudo-random-numbers8904165
Ref: 262f8904165
Ref: random --- 疑似乱数を生成する-Footnote-18908095
Ref: random --- 疑似乱数を生成する-Footnote-28908161
Node: 保守 bookkeeping 関数8908251
Ref: library/random bookkeeping-functions8908384
Ref: 26318908384
Ref: library/random random seed8908453
Ref: 12458908453
Ref: library/random random getstate8909841
Ref: 26328909841
Ref: library/random random setstate8910100
Ref: 26338910100
Node: バイト列用の関数8910392
Ref: library/random functions-for-bytes8910552
Ref: 26348910552
Ref: library/random random randbytes8910611
Ref: 18d58910611
Node: 整数用の関数8910955
Ref: library/random functions-for-integers8911117
Ref: 26368911117
Ref: library/random random randrange8911166
Ref: 8378911166
Ref: library/random random randint8912353
Ref: 12008912353
Ref: library/random random getrandbits8912535
Ref: fd88912535
Node: シーケンス用の関数8913133
Ref: library/random functions-for-sequences8913293
Ref: 26378913293
Ref: library/random random choice8913357
Ref: 12018913357
Ref: library/random random choices8913562
Ref: c948913562
Ref: library/random random shuffle8916053
Ref: 7128916053
Ref: library/random random sample8916970
Ref: 7118916970
Node: Discrete distributions8918880
Ref: library/random discrete-distributions8919034
Ref: 26388919034
Ref: library/random random binomialvariate8919156
Ref: 47c8919156
Ref: Discrete distributions-Footnote-18919719
Node: 実数分布8919783
Ref: library/random id18919925
Ref: 26398919925
Ref: library/random real-valued-distributions8919925
Ref: 263a8919925
Ref: library/random random random8920270
Ref: 7138920270
Ref: library/random random uniform8920397
Ref: 263b8920397
Ref: library/random random triangular8920775
Ref: 263c8920775
Ref: library/random random betavariate8921188
Ref: 263d8921188
Ref: library/random random expovariate8921402
Ref: 47d8921402
Ref: library/random random gammavariate8921869
Ref: 263e8921869
Ref: library/random random gauss8922360
Ref: 17ac8922360
Ref: library/random random lognormvariate8923149
Ref: 263f8923149
Ref: library/random random normalvariate8923486
Ref: 17ad8923486
Ref: library/random random vonmisesvariate8923732
Ref: 26408923732
Ref: library/random random paretovariate8924117
Ref: 26418924117
Ref: library/random random weibullvariate8924238
Ref: 26428924238
Node: 他の生成器8924407
Ref: library/random alternative-generator8924548
Ref: 26438924548
Ref: library/random random Random8924592
Ref: 18128924592
Ref: library/random random Random seed8925187
Ref: 18ec8925187
Ref: library/random random Random getstate8925366
Ref: 26448925366
Ref: library/random random Random setstate8925536
Ref: 26458925536
Ref: library/random random Random random8925711
Ref: 26468925711
Ref: library/random random Random getrandbits8925965
Ref: 26478925965
Ref: library/random random SystemRandom8926141
Ref: 26308926141
Node: 再現性について8926809
Ref: library/random notes-on-reproducibility8926950
Ref: 26488926950
Node: 使用例<7>8927829
Ref: library/random examples8927967
Ref: 26498927967
Ref: library/random random-examples8927967
Ref: 11ad8927967
Ref: 使用例<7>-Footnote-18933378
Ref: 使用例<7>-Footnote-28933499
Ref: 使用例<7>-Footnote-38933545
Ref: 使用例<7>-Footnote-48933626
Ref: 使用例<7>-Footnote-58933678
Ref: 使用例<7>-Footnote-68933733
Ref: 使用例<7>-Footnote-78933801
Ref: 使用例<7>-Footnote-88933837
Ref: 使用例<7>-Footnote-98933907
Node: レシピ<2>8933943
Ref: library/random recipes8934093
Ref: 264a8934093
Ref: レシピ<2>-Footnote-18937266
Node: コマンドラインでの使用8937334
Ref: library/random command-line-usage8937499
Ref: 264b8937499
Ref: library/random random-cli8937499
Ref: 13a8937499
Ref: library/random cmdoption-random-h8937807
Ref: 264c8937807
Ref: library/random cmdoption-random-help8937807
Ref: 264d8937807
Ref: library/random cmdoption-random-c8937895
Ref: 264e8937895
Ref: library/random cmdoption-random-choice8937930
Ref: 264f8937930
Ref: library/random cmdoption-random-i8938061
Ref: 26508938061
Ref: library/random cmdoption-random-integer8938080
Ref: 26518938080
Ref: library/random cmdoption-random-f8938229
Ref: 26528938229
Ref: library/random cmdoption-random-float8938248
Ref: 26538938248
Node: コマンドラインの例8938634
Ref: library/random command-line-example8938778
Ref: 26548938778
Ref: library/random random-cli-example8938778
Ref: 26558938778
Node: statistics --- 数学的統計関数8939630
Ref: library/statistics doc8939780
Ref: 26568939780
Ref: library/statistics module-statistics8939780
Ref: bd8939780
Ref: library/statistics statistics-mathematical-statistics-functions8939780
Ref: 26578939780
Ref: statistics --- 数学的統計関数-Footnote-18942454
Ref: statistics --- 数学的統計関数-Footnote-28942524
Ref: statistics --- 数学的統計関数-Footnote-38942550
Node: 平均及び中心位置の測度8942577
Ref: library/statistics averages-and-measures-of-central-location8942707
Ref: 26588942707
Node: 分散の測度8944540
Ref: library/statistics measures-of-spread8944707
Ref: 265d8944707
Node: 2入力間の関係の統計8945332
Ref: library/statistics statistics-for-relations-between-two-inputs8945481
Ref: 26608945481
Node: 関数の詳細8945996
Ref: library/statistics function-details8946139
Ref: 26618946139
Ref: library/statistics statistics mean8946353
Ref: 69d8946353
Ref: library/statistics statistics fmean8947978
Ref: a028947978
Ref: library/statistics statistics geometric_mean8948969
Ref: a038948969
Ref: library/statistics statistics harmonic_mean8949659
Ref: caf8949659
Ref: library/statistics statistics kde8951241
Ref: 22b8951241
Ref: library/statistics statistics kde_random8953126
Ref: 22c8953126
Ref: library/statistics statistics median8954182
Ref: 26598954182
Ref: library/statistics statistics median_low8955343
Ref: 265a8955343
Ref: library/statistics statistics median_high8956069
Ref: 265b8956069
Ref: library/statistics statistics median_grouped8956789
Ref: 265c8956789
Ref: library/statistics statistics mode8958701
Ref: a608958701
Ref: library/statistics statistics multimode8960266
Ref: a048960266
Ref: library/statistics statistics pstdev8960688
Ref: 265e8960688
Ref: library/statistics statistics pvariance8960967
Ref: 265f8960967
Ref: library/statistics statistics stdev8963260
Ref: 69f8963260
Ref: library/statistics statistics variance8963544
Ref: 69e8963544
Ref: library/statistics statistics quantiles8965900
Ref: a058965900
Ref: library/statistics statistics covariance8968884
Ref: 7fb8968884
Ref: library/statistics statistics correlation8969501
Ref: 4888969501
Ref: library/statistics statistics linear_regression8971588
Ref: 7fc8971588
Ref: 関数の詳細-Footnote-18974181
Ref: 関数の詳細-Footnote-28974229
Ref: 関数の詳細-Footnote-38974275
Ref: 関数の詳細-Footnote-48974330
Ref: 関数の詳細-Footnote-58974426
Ref: 関数の詳細-Footnote-68974484
Ref: 関数の詳細-Footnote-78974556
Ref: 関数の詳細-Footnote-88974607
Ref: 関数の詳細-Footnote-98974677
Ref: 関数の詳細-Footnote-108974758
Ref: 関数の詳細-Footnote-118974831
Ref: 関数の詳細-Footnote-128974895
Node: 例外<5>8974953
Ref: library/statistics exceptions8975097
Ref: 26638975097
Ref: library/statistics statistics StatisticsError8975166
Ref: 26628975166
Node: NormalDist オブジェクト8975281
Ref: library/statistics normaldist-objects8975428
Ref: 26648975428
Ref: library/statistics statistics NormalDist8975832
Ref: a068975832
Ref: library/statistics statistics NormalDist mean8976122
Ref: 26658976122
Ref: library/statistics statistics NormalDist median8976243
Ref: 26668976243
Ref: library/statistics statistics NormalDist mode8976357
Ref: 26678976357
Ref: library/statistics statistics NormalDist stdev8976457
Ref: 26688976457
Ref: library/statistics statistics NormalDist variance8976582
Ref: 26698976582
Ref: library/statistics statistics NormalDist from_samples8976748
Ref: 266a8976748
Ref: library/statistics statistics NormalDist samples8977362
Ref: 266b8977362
Ref: library/statistics statistics NormalDist pdf8977988
Ref: 266c8977988
Ref: library/statistics statistics NormalDist cdf8978591
Ref: 266d8978591
Ref: library/statistics statistics NormalDist inv_cdf8978840
Ref: 266e8978840
Ref: library/statistics statistics NormalDist overlap8979285
Ref: 266f8979285
Ref: library/statistics statistics NormalDist quantiles8979547
Ref: 26708979547
Ref: library/statistics statistics NormalDist zscore8980008
Ref: 26718980008
Ref: NormalDist オブジェクト-Footnote-18981437
Ref: NormalDist オブジェクト-Footnote-28981501
Ref: NormalDist オブジェクト-Footnote-38981561
Ref: NormalDist オブジェクト-Footnote-48981615
Ref: NormalDist オブジェクト-Footnote-58981672
Ref: NormalDist オブジェクト-Footnote-68981726
Ref: NormalDist オブジェクト-Footnote-78981771
Ref: NormalDist オブジェクト-Footnote-88981827
Ref: NormalDist オブジェクト-Footnote-98981884
Ref: NormalDist オブジェクト-Footnote-108981931
Ref: NormalDist オブジェクト-Footnote-118981999
Ref: NormalDist オブジェクト-Footnote-128982071
Ref: NormalDist オブジェクト-Footnote-138982128
Ref: NormalDist オブジェクト-Footnote-148982263
Ref: NormalDist オブジェクト-Footnote-158982310
Ref: NormalDist オブジェクト-Footnote-168982388
Node: 例とレシピ<2>8982473
Ref: library/statistics examples-and-recipes8982602
Ref: 26728982602
Node: Classic probability problems8982799
Ref: library/statistics classic-probability-problems8982925
Ref: 26738982925
Ref: Classic probability problems-Footnote-18983752
Ref: Classic probability problems-Footnote-28983823
Ref: Classic probability problems-Footnote-38983870
Node: Monte Carlo inputs for simulations8983915
Ref: library/statistics monte-carlo-inputs-for-simulations8984086
Ref: 26748984086
Ref: Monte Carlo inputs for simulations-Footnote-18984774
Node: Approximating binomial distributions8984831
Ref: library/statistics approximating-binomial-distributions8984999
Ref: 26758984999
Ref: Approximating binomial distributions-Footnote-18986429
Node: Naive bayesian classifier8986493
Ref: library/statistics naive-bayesian-classifier8986618
Ref: 26768986618
Ref: Naive bayesian classifier-Footnote-18988509
Ref: Naive bayesian classifier-Footnote-28988593
Ref: Naive bayesian classifier-Footnote-38988649
Node: 関数型プログラミング用モジュール8988719
Ref: library/functional doc8988931
Ref: 26778988931
Ref: library/functional functional-programming-modules8988931
Ref: 26788988931
Node: itertools --- 効率的なループ用のイテレータ生成関数群8989668
Ref: library/itertools doc8989907
Ref: 26798989907
Ref: library/itertools itertools-functions-creating-iterators-for-efficient-looping8989907
Ref: 267a8989907
Ref: library/itertools module-itertools8989907
Ref: 758989907
Node: Itertool関数9001545
Ref: library/itertools itertool-functions9001695
Ref: 26829001695
Ref: library/itertools itertools-functions9001695
Ref: 26839001695
Ref: library/itertools itertools accumulate9001925
Ref: 9cb9001925
Ref: library/itertools itertools batched9004409
Ref: 1e29004409
Ref: library/itertools itertools chain9005971
Ref: 20e49005971
Ref: library/itertools itertools chain from_iterable9006451
Ref: 267d9006451
Ref: library/itertools itertools combinations9006947
Ref: 12e19006947
Ref: library/itertools itertools combinations_with_replacement9008572
Ref: 12529008572
Ref: library/itertools itertools compress9010171
Ref: 12539010171
Ref: library/itertools itertools count9010669
Ref: 12549010669
Ref: library/itertools itertools cycle9011530
Ref: 267b9011530
Ref: library/itertools itertools dropwhile9012234
Ref: 267e9012234
Ref: library/itertools itertools filterfalse9012942
Ref: 20cc9012942
Ref: library/itertools itertools groupby9013528
Ref: 267f9013528
Ref: library/itertools itertools islice9016507
Ref: b1a9016507
Ref: library/itertools itertools pairwise9018283
Ref: 7e09018283
Ref: library/itertools itertools permutations9018907
Ref: 18859018907
Ref: library/itertools itertools product9021003
Ref: 12e29021003
Ref: library/itertools itertools repeat9022897
Ref: 267c9022897
Ref: library/itertools itertools starmap9023608
Ref: 10b59023608
Ref: library/itertools itertools takewhile9024253
Ref: 26809024253
Ref: library/itertools itertools tee9025056
Ref: 26819025056
Ref: library/itertools itertools zip_longest9027946
Ref: 126e9027946
Ref: Itertool関数-Footnote-19029462
Ref: Itertool関数-Footnote-29029536
Ref: Itertool関数-Footnote-39029591
Ref: Itertool関数-Footnote-49029647
Node: Itertools レシピ9029745
Ref: library/itertools id19029895
Ref: 26859029895
Ref: library/itertools itertools-recipes9029895
Ref: 12309029895
Ref: Itertools レシピ-Footnote-19042960
Ref: Itertools レシピ-Footnote-29043009
Node: functools --- 高階関数と呼び出し可能オブジェクトの操作9043080
Ref: library/functools doc9043371
Ref: 26869043371
Ref: library/functools functools-higher-order-functions-and-operations-on-callable-objects9043371
Ref: 26879043371
Ref: library/functools module-functools9043371
Ref: 559043371
Ref: library/functools functools cache9044004
Ref: 24979044004
Ref: library/functools functools cached_property9045287
Ref: 50c9045287
Ref: library/functools functools cmp_to_key9049250
Ref: 11aa9049250
Ref: library/functools functools lru_cache9050495
Ref: 9bd9050495
Ref: library/functools functools total_ordering9056659
Ref: f0f9056659
Ref: library/functools functools partial9059128
Ref: 3ed9059128
Ref: library/functools functools partialmethod9060785
Ref: a499060785
Ref: library/functools functools reduce9062883
Ref: 12aa9062883
Ref: library/functools functools singledispatch9064172
Ref: 6059064172
Ref: library/functools functools singledispatchmethod9071015
Ref: 9c09071015
Ref: library/functools functools update_wrapper9072936
Ref: fec9072936
Ref: library/functools functools wraps9075826
Ref: f2a9075826
Ref: functools --- 高階関数と呼び出し可能オブジェクトの操作-Footnote-19077200
Ref: functools --- 高階関数と呼び出し可能オブジェクトの操作-Footnote-29077269
Ref: functools --- 高階関数と呼び出し可能オブジェクトの操作-Footnote-39077319
Ref: functools --- 高階関数と呼び出し可能オブジェクトの操作-Footnote-49077361
Ref: functools --- 高階関数と呼び出し可能オブジェクトの操作-Footnote-59077453
Ref: functools --- 高階関数と呼び出し可能オブジェクトの操作-Footnote-69077507
Ref: functools --- 高階関数と呼び出し可能オブジェクトの操作-Footnote-79077567
Node: partial オブジェクト9077632
Ref: library/functools id19077769
Ref: 268b9077769
Ref: library/functools partial-objects9077769
Ref: 26899077769
Ref: library/functools functools partial func9078063
Ref: 268c9078063
Ref: library/functools functools partial args9078313
Ref: 268d9078313
Ref: library/functools functools partial keywords9078511
Ref: 268e9078511
Node: operator --- 関数形式の標準演算子9079108
Ref: library/operator doc9079319
Ref: 268f9079319
Ref: library/operator module-operator9079319
Ref: 8f9079319
Ref: library/operator operator-standard-operators-as-functions9079319
Ref: 26909079319
Ref: library/operator operator lt9080429
Ref: 26919080429
Ref: library/operator operator le9080463
Ref: 26929080463
Ref: library/operator operator eq9080497
Ref: 26939080497
Ref: library/operator operator ne9080531
Ref: 26949080531
Ref: library/operator operator ge9080565
Ref: 26959080565
Ref: library/operator operator gt9080599
Ref: 26969080599
Ref: library/operator operator __lt__9080633
Ref: 26979080633
Ref: library/operator operator __le__9080671
Ref: 26989080671
Ref: library/operator operator __eq__9080709
Ref: 26999080709
Ref: library/operator operator __ne__9080747
Ref: 269a9080747
Ref: library/operator operator __ge__9080785
Ref: 269b9080785
Ref: library/operator operator __gt__9080823
Ref: 269c9080823
Ref: library/operator operator not_9081610
Ref: 269d9081610
Ref: library/operator operator __not__9081645
Ref: 269e9081645
Ref: library/operator operator truth9082056
Ref: 269f9082056
Ref: library/operator operator is_9082307
Ref: 26a09082307
Ref: library/operator operator is_not9082432
Ref: 26a19082432
Ref: library/operator operator abs9082648
Ref: 26a29082648
Ref: library/operator operator __abs__9082682
Ref: 26a39082682
Ref: library/operator operator add9082764
Ref: 26a49082764
Ref: library/operator operator __add__9082799
Ref: 26a59082799
Ref: library/operator operator and_9082914
Ref: 26a69082914
Ref: library/operator operator __and__9082950
Ref: 26a79082950
Ref: library/operator operator floordiv9083054
Ref: 26a89083054
Ref: library/operator operator __floordiv__9083094
Ref: 26a99083094
Ref: library/operator operator index9083177
Ref: 18799083177
Ref: library/operator operator __index__9083211
Ref: 26aa9083211
Ref: library/operator operator inv9083542
Ref: 26ab9083542
Ref: library/operator operator invert9083576
Ref: 26ac9083576
Ref: library/operator operator __inv__9083613
Ref: 26ad9083613
Ref: library/operator operator __invert__9083651
Ref: 26ae9083651
Ref: library/operator operator lshift9083777
Ref: 26af9083777
Ref: library/operator operator __lshift__9083815
Ref: 26b09083815
Ref: library/operator operator mod9083916
Ref: 26b19083916
Ref: library/operator operator __mod__9083951
Ref: 26b29083951
Ref: library/operator operator mul9084028
Ref: 26849084028
Ref: library/operator operator __mul__9084063
Ref: 26b39084063
Ref: library/operator operator matmul9084178
Ref: e029084178
Ref: library/operator operator __matmul__9084216
Ref: 26b49084216
Ref: library/operator operator neg9084324
Ref: 26b59084324
Ref: library/operator operator __neg__9084358
Ref: 26b69084358
Ref: library/operator operator or_9084448
Ref: 26b79084448
Ref: library/operator operator __or__9084483
Ref: 26b89084483
Ref: library/operator operator pos9084586
Ref: 26b99084586
Ref: library/operator operator __pos__9084620
Ref: 26ba9084620
Ref: library/operator operator pow9084710
Ref: 26bb9084710
Ref: library/operator operator __pow__9084745
Ref: 26bc9084745
Ref: library/operator operator rshift9084861
Ref: 26bd9084861
Ref: library/operator operator __rshift__9084899
Ref: 26be9084899
Ref: library/operator operator sub9085000
Ref: 26bf9085000
Ref: library/operator operator __sub__9085035
Ref: 26c09085035
Ref: library/operator operator truediv9085112
Ref: 26c19085112
Ref: library/operator operator __truediv__9085151
Ref: 26c29085151
Ref: library/operator operator xor9085337
Ref: 26c39085337
Ref: library/operator operator __xor__9085372
Ref: 26c49085372
Ref: library/operator operator concat9085636
Ref: 26c59085636
Ref: library/operator operator __concat__9085674
Ref: 26c69085674
Ref: library/operator operator contains9085801
Ref: 8a89085801
Ref: library/operator operator __contains__9085841
Ref: 26c79085841
Ref: library/operator operator countOf9086017
Ref: 8aa9086017
Ref: library/operator operator delitem9086121
Ref: 26c89086121
Ref: library/operator operator __delitem__9086160
Ref: 26c99086160
Ref: library/operator operator getitem9086268
Ref: 26ca9086268
Ref: library/operator operator __getitem__9086307
Ref: 26cb9086307
Ref: library/operator operator indexOf9086412
Ref: 8a99086412
Ref: library/operator operator setitem9086537
Ref: 26cc9086537
Ref: library/operator operator __setitem__9086579
Ref: 26cd9086579
Ref: library/operator operator length_hint9086698
Ref: f3a9086698
Ref: library/operator operator call9087118
Ref: 17e89087118
Ref: library/operator operator __call__9087173
Ref: 26ce9087173
Ref: library/operator operator attrgetter9087657
Ref: e009087657
Ref: library/operator operator itemgetter9089115
Ref: a309089115
Ref: library/operator operator methodcaller9091169
Ref: e019091169
Ref: operator --- 関数形式の標準演算子-Footnote-19092162
Node: 演算子から関数への対応表9092230
Ref: library/operator mapping-operators-to-functions9092392
Ref: 26cf9092392
Ref: library/operator operator-map9092392
Ref: 26d09092392
Node: インプレース in-place 演算子9100042
Ref: library/operator in-place-operators9100204
Ref: 26d19100204
Ref: library/operator operator iadd9101719
Ref: 26d39101719
Ref: library/operator operator __iadd__9101755
Ref: 26d49101755
Ref: library/operator operator iand9101859
Ref: 26d59101859
Ref: library/operator operator __iand__9101895
Ref: 26d69101895
Ref: library/operator operator iconcat9101999
Ref: 26d79101999
Ref: library/operator operator __iconcat__9102038
Ref: 26d89102038
Ref: library/operator operator ifloordiv9102200
Ref: 26d99102200
Ref: library/operator operator __ifloordiv__9102241
Ref: 26da9102241
Ref: library/operator operator ilshift9102356
Ref: 26db9102356
Ref: library/operator operator __ilshift__9102395
Ref: 26dc9102395
Ref: library/operator operator imod9102506
Ref: 26dd9102506
Ref: library/operator operator __imod__9102542
Ref: 26de9102542
Ref: library/operator operator imul9102646
Ref: 26df9102646
Ref: library/operator operator __imul__9102682
Ref: 26e09102682
Ref: library/operator operator imatmul9102786
Ref: e039102786
Ref: library/operator operator __imatmul__9102825
Ref: 26e19102825
Ref: library/operator operator ior9102963
Ref: 26e29102963
Ref: library/operator operator __ior__9102998
Ref: 26e39102998
Ref: library/operator operator ipow9103100
Ref: 26e49103100
Ref: library/operator operator __ipow__9103136
Ref: 26e59103136
Ref: library/operator operator irshift9103241
Ref: 26e69103241
Ref: library/operator operator __irshift__9103280
Ref: 26e79103280
Ref: library/operator operator isub9103391
Ref: 26e89103391
Ref: library/operator operator __isub__9103427
Ref: 26e99103427
Ref: library/operator operator itruediv9103531
Ref: 26ea9103531
Ref: library/operator operator __itruediv__9103571
Ref: 26eb9103571
Ref: library/operator operator ixor9103683
Ref: 26ec9103683
Ref: library/operator operator __ixor__9103719
Ref: 26ed9103719
Node: ファイルとディレクトリへのアクセス9103823
Ref: library/filesys doc9104026
Ref: 26ee9104026
Ref: library/filesys file-and-directory-access9104026
Ref: 26ef9104026
Ref: library/filesys filesys9104026
Ref: 26f09104026
Node: pathlib --- オブジェクト指向のファイルシステムパス9105616
Ref: library/pathlib doc9105821
Ref: 26f19105821
Ref: library/pathlib module-pathlib9105821
Ref: 939105821
Ref: library/pathlib pathlib-object-oriented-filesystem-paths9105821
Ref: 26f29105821
Ref: pathlib --- オブジェクト指向のファイルシステムパス-Footnote-19108566
Ref: pathlib --- オブジェクト指向のファイルシステムパス-Footnote-29108631
Node: 基本的な使い方9108673
Ref: library/pathlib basic-use9108818
Ref: 26f69108818
Node: 例外<6>9109927
Ref: library/pathlib exceptions9110093
Ref: 26f79110093
Ref: library/pathlib pathlib UnsupportedOperation9110124
Ref: 2089110124
Node: 純粋パス9110378
Ref: library/pathlib id19110535
Ref: 26f89110535
Ref: library/pathlib pure-paths9110535
Ref: 26f39110535
Ref: library/pathlib pathlib PurePath9110837
Ref: 4739110837
Ref: library/pathlib pathlib PurePosixPath9113824
Ref: 26f99113824
Ref: library/pathlib pathlib PureWindowsPath9114157
Ref: 166a9114157
Ref: 純粋パス-Footnote-19115006
Node: 全般的な性質9115065
Ref: library/pathlib general-properties9115153
Ref: 26fa9115153
Node: 演算子<2>9116316
Ref: library/pathlib operators9116452
Ref: 26fb9116452
Node: 個別の構成要素へのアクセス9118417
Ref: library/pathlib accessing-individual-parts9118565
Ref: 26fc9118565
Ref: library/pathlib pathlib PurePath parts9118761
Ref: 26fd9118761
Node: メソッドとプロパティ9119221
Ref: library/pathlib methods-and-properties9119348
Ref: 26fe9119348
Ref: library/pathlib pathlib PurePath parser9119494
Ref: 20d9119494
Ref: library/pathlib pathlib PurePath drive9119716
Ref: 26ff9119716
Ref: library/pathlib pathlib PurePath root9120181
Ref: 27009120181
Ref: library/pathlib pathlib PurePath anchor9121369
Ref: 27019121369
Ref: library/pathlib pathlib PurePath parents9121760
Ref: 7eb9121760
Ref: library/pathlib pathlib PurePath parent9122340
Ref: 16949122340
Ref: library/pathlib pathlib PurePath name9123313
Ref: 27029123313
Ref: library/pathlib pathlib PurePath suffix9123752
Ref: 27039123752
Ref: library/pathlib pathlib PurePath suffixes9124164
Ref: 27049124164
Ref: library/pathlib pathlib PurePath stem9124509
Ref: 27059124509
Ref: library/pathlib pathlib PurePath as_posix9124833
Ref: 27069124833
Ref: library/pathlib pathlib PurePath is_absolute9125121
Ref: 16929125121
Ref: library/pathlib pathlib PurePath is_relative_to9125784
Ref: 2aa9125784
Ref: library/pathlib pathlib PurePath is_reserved9126575
Ref: 2869126575
Ref: library/pathlib pathlib PurePath joinpath9127230
Ref: 27079127230
Ref: library/pathlib pathlib PurePath full_match9127849
Ref: 20c9127849
Ref: library/pathlib pathlib PurePath match9128837
Ref: 4799128837
Ref: library/pathlib pathlib PurePath relative_to9129822
Ref: 2ab9129822
Ref: library/pathlib pathlib PurePath with_name9132221
Ref: 165c9132221
Ref: library/pathlib pathlib PurePath with_stem9133011
Ref: 15c19133011
Ref: library/pathlib pathlib PurePath with_suffix9134105
Ref: 157b9134105
Ref: library/pathlib pathlib PurePath with_segments9134817
Ref: 4749134817
Ref: メソッドとプロパティ-Footnote-19135759
Node: 具象パス9135851
Ref: library/pathlib concrete-paths9136015
Ref: 26f49136015
Ref: library/pathlib id29136015
Ref: 27099136015
Ref: library/pathlib pathlib Path9136352
Ref: 20a9136352
Ref: library/pathlib pathlib PosixPath9136799
Ref: 270a9136799
Ref: library/pathlib pathlib WindowsPath9137377
Ref: 26f59137377
Node: URIのパースと生成9139176
Ref: library/pathlib parsing-and-generating-uris9139282
Ref: 270b9139282
Ref: library/pathlib pathlib Path from_uri9139558
Ref: 20b9139558
Ref: library/pathlib pathlib Path as_uri9140607
Ref: 270d9140607
Ref: URIのパースと生成-Footnote-19141163
Node: パスの展開と解決9141222
Ref: library/pathlib expanding-and-resolving-paths9141397
Ref: 270e9141397
Ref: library/pathlib pathlib Path home9141460
Ref: e109141460
Ref: library/pathlib pathlib Path expanduser9141893
Ref: e0f9141893
Ref: library/pathlib pathlib Path cwd9142381
Ref: 16919142381
Ref: library/pathlib pathlib Path absolute9142630
Ref: 16129142630
Ref: library/pathlib pathlib Path resolve9142983
Ref: 16619142983
Ref: library/pathlib pathlib Path readlink9144242
Ref: 8ed9144242
Node: ファイルの種類とステータスを問い合わせる9144800
Ref: library/pathlib querying-file-type-and-status9144987
Ref: 270f9144987
Ref: library/pathlib pathlib Path stat9145481
Ref: 7ee9145481
Ref: library/pathlib pathlib Path lstat9146283
Ref: 27109146283
Ref: library/pathlib pathlib Path exists9146542
Ref: 9e49146542
Ref: library/pathlib pathlib Path is_file9147280
Ref: 2109147280
Ref: library/pathlib pathlib Path is_dir9148040
Ref: 2119148040
Ref: library/pathlib pathlib Path is_symlink9148829
Ref: 9e69148829
Ref: library/pathlib pathlib Path is_junction9149182
Ref: 4789149182
Ref: library/pathlib pathlib Path is_mount9149481
Ref: 9e59149481
Ref: library/pathlib pathlib Path is_socket9150488
Ref: 9ea9150488
Ref: library/pathlib pathlib Path is_fifo9150987
Ref: 9e99150987
Ref: library/pathlib pathlib Path is_block_device9151462
Ref: 9e79151462
Ref: library/pathlib pathlib Path is_char_device9151983
Ref: 9e89151983
Ref: library/pathlib pathlib Path samefile9152514
Ref: e0d9152514
Node: ファイルを読み書きする<2>9153214
Ref: library/pathlib reading-and-writing-files9153404
Ref: 27119153404
Ref: library/pathlib pathlib Path open9153482
Ref: 27129153482
Ref: library/pathlib pathlib Path read_text9153855
Ref: e129153855
Ref: library/pathlib pathlib Path read_bytes9154451
Ref: e149154451
Ref: library/pathlib pathlib Path write_text9154780
Ref: e119154780
Ref: library/pathlib pathlib Path write_bytes9155457
Ref: e139155457
Node: ディレクトリを読む9155904
Ref: library/pathlib reading-directories9156076
Ref: 27139156076
Ref: library/pathlib pathlib Path iterdir9156144
Ref: 15959156144
Ref: library/pathlib pathlib Path glob9157156
Ref: 20e9157156
Ref: library/pathlib pathlib Path rglob9159492
Ref: 20f9159492
Ref: library/pathlib pathlib Path walk9160374
Ref: 4759160374
Node: ファイルとディレクトリの作成9165440
Ref: library/pathlib creating-files-and-directories9165597
Ref: 27159165597
Ref: library/pathlib pathlib Path touch9165690
Ref: 27169165690
Ref: library/pathlib pathlib Path mkdir9166418
Ref: e0e9166418
Ref: library/pathlib pathlib Path symlink_to9167755
Ref: 7ed9167755
Ref: library/pathlib pathlib Path hardlink_to9169183
Ref: 7ec9169183
Node: リネームと削除9169655
Ref: library/pathlib renaming-and-deleting9169818
Ref: 27179169818
Ref: library/pathlib pathlib Path rename9169876
Ref: 27189169876
Ref: library/pathlib pathlib Path replace9171122
Ref: 27199171122
Ref: library/pathlib pathlib Path unlink9171848
Ref: 195d9171848
Ref: library/pathlib pathlib Path rmdir9172511
Ref: 27149172511
Node: パーミッションと所有者9172662
Ref: library/pathlib permissions-and-ownership9172774
Ref: 271a9172774
Ref: library/pathlib pathlib Path owner9172852
Ref: 2129172852
Ref: library/pathlib pathlib Path group9173711
Ref: 2139173711
Ref: library/pathlib pathlib Path chmod9174573
Ref: 7ef9174573
Ref: library/pathlib pathlib Path lchmod9175381
Ref: 271b9175381
Node: Pattern language9175655
Ref: library/pathlib pathlib-pattern-language9175839
Ref: 27089175839
Ref: library/pathlib pattern-language9175839
Ref: 271c9175839
Node: glob モジュールとの比較9178045
Ref: library/pathlib comparison-to-the-glob-module9178256
Ref: 271d9178256
Node: os と os path モジュールの比較9179685
Ref: library/pathlib comparison-to-the-os-and-os-path-modules9179871
Ref: 271e9179871
Node: 対応するツール9182031
Ref: library/pathlib corresponding-tools9182128
Ref: 271f9182128
Ref: 対応するツール-Footnote-19187447
Ref: 対応するツール-Footnote-29187755
Ref: 対応するツール-Footnote-39187934
Ref: 対応するツール-Footnote-49188156
Node: os path --- 一般的なパス名操作9188388
Ref: library/os path doc9188679
Ref: 27239188679
Ref: library/os path module-os path9188679
Ref: 929188679
Ref: library/os path os-path-common-pathname-manipulations9188679
Ref: 27249188679
Ref: library/os path os path abspath9191040
Ref: 12ea9191040
Ref: library/os path os path basename9191467
Ref: 27219191467
Ref: library/os path os path commonpath9192078
Ref: e0a9192078
Ref: library/os path os path commonprefix9192701
Ref: e0b9192701
Ref: library/os path os path dirname9193539
Ref: 27209193539
Ref: library/os path os path exists9193881
Ref: 9dc9193881
Ref: library/os path os path lexists9194768
Ref: 9dd9194768
Ref: library/os path os path expanduser9195110
Ref: 9e29195110
Ref: library/os path os path expandvars9196528
Ref: 13819196528
Ref: library/os path os path getatime9197165
Ref: 27269197165
Ref: library/os path os path getmtime9197466
Ref: 27279197466
Ref: library/os path os path getctime9197891
Ref: 27289197891
Ref: library/os path os path getsize9198528
Ref: 27299198528
Ref: library/os path os path isabs9198876
Ref: 2059198876
Ref: library/os path os path isfile9199377
Ref: 9df9199377
Ref: library/os path os path isdir9199832
Ref: 9de9199832
Ref: library/os path os path isjunction9200285
Ref: 4709200285
Ref: library/os path os path islink9200553
Ref: 9da9200553
Ref: library/os path os path ismount9201007
Ref: 9e09201007
Ref: library/os path os path isdevdrive9202293
Ref: 15ac9202293
Ref: library/os path os path isreserved9203137
Ref: 2049203137
Ref: library/os path os path join9203995
Ref: 15979203995
Ref: library/os path os path normcase9205169
Ref: 272a9205169
Ref: library/os path os path normpath9205622
Ref: 12e99205622
Ref: library/os path os path realpath9206713
Ref: 2069206713
Ref: library/os path os path relpath9208081
Ref: 4779208081
Ref: library/os path os path samefile9208758
Ref: f3e9208758
Ref: library/os path os path sameopenfile9209491
Ref: 272c9209491
Ref: library/os path os path samestat9209864
Ref: f3d9209864
Ref: library/os path os path split9210521
Ref: 27259210521
Ref: library/os path os path splitdrive9211594
Ref: bc29211594
Ref: library/os path os path splitroot9212585
Ref: 4719212585
Ref: library/os path os path splitext9213853
Ref: 27229213853
Ref: library/os path os path supports_unicode_filenames9214865
Ref: 14319214865
Ref: os path --- 一般的なパス名操作-Footnote-19215098
Ref: os path --- 一般的なパス名操作-Footnote-29215169
Ref: os path --- 一般的なパス名操作-Footnote-39215238
Ref: os path --- 一般的なパス名操作-Footnote-49215304
Ref: os path --- 一般的なパス名操作-Footnote-59215359
Ref: os path --- 一般的なパス名操作-Footnote-69215451
Node: fileinput --- 複数の入力ストリームをまたいだ行を反復する9215543
Ref: library/fileinput doc9215803
Ref: 272d9215803
Ref: library/fileinput fileinput-iterate-over-lines-from-multiple-input-streams9215803
Ref: 272e9215803
Ref: library/fileinput module-fileinput9215803
Ref: 519215803
Ref: library/fileinput fileinput input9218887
Ref: 7ca9218887
Ref: library/fileinput fileinput filename9220402
Ref: 272f9220402
Ref: library/fileinput fileinput fileno9220575
Ref: 13d59220575
Ref: library/fileinput fileinput lineno9220848
Ref: 27309220848
Ref: library/fileinput fileinput filelineno9221144
Ref: 27319221144
Ref: library/fileinput fileinput isfirstline9221447
Ref: 27329221447
Ref: library/fileinput fileinput isstdin9221628
Ref: 27339221628
Ref: library/fileinput fileinput nextfile9221828
Ref: 27349221828
Ref: library/fileinput fileinput close9222589
Ref: 27359222589
Ref: library/fileinput fileinput FileInput9222797
Ref: 7029222797
Ref: library/fileinput fileinput hook_compressed9226446
Ref: 7cb9226446
Ref: library/fileinput fileinput hook_encoded9227360
Ref: c6e9227360
Ref: fileinput --- 複数の入力ストリームをまたいだ行を反復する-Footnote-19228044
Node: stat --- stat の結果を解釈する9228113
Ref: library/stat doc9228388
Ref: 27369228388
Ref: library/stat module-stat9228388
Ref: bc9228388
Ref: library/stat stat-interpreting-stat-results9228388
Ref: 27379228388
Ref: library/stat stat S_ISDIR9229276
Ref: 27389229276
Ref: library/stat stat S_ISCHR9229412
Ref: 27399229412
Ref: library/stat stat S_ISBLK9229587
Ref: 273a9229587
Ref: library/stat stat S_ISREG9229759
Ref: 273b9229759
Ref: library/stat stat S_ISFIFO9229895
Ref: 273c9229895
Ref: library/stat stat S_ISLNK9230050
Ref: 273d9230050
Ref: library/stat stat S_ISSOCK9230201
Ref: 273e9230201
Ref: library/stat stat S_ISDOOR9230332
Ref: 19319230332
Ref: library/stat stat S_ISPORT9230485
Ref: 19329230485
Ref: library/stat stat S_ISWHT9230653
Ref: 19339230653
Ref: library/stat stat S_IMODE9230932
Ref: 273f9230932
Ref: library/stat stat S_IFMT9231379
Ref: 27409231379
Ref: library/stat stat filemode9232984
Ref: 111e9232984
Ref: library/stat stat ST_MODE9233529
Ref: f869233529
Ref: library/stat stat ST_INO9233596
Ref: 27419233596
Ref: library/stat stat ST_DEV9233650
Ref: 27429233650
Ref: library/stat stat ST_NLINK9233725
Ref: 27439233725
Ref: library/stat stat ST_UID9233806
Ref: 27449233806
Ref: library/stat stat ST_GID9233883
Ref: 27459233883
Ref: library/stat stat ST_SIZE9233963
Ref: 27469233963
Ref: library/stat stat ST_ATIME9234118
Ref: 27479234118
Ref: library/stat stat ST_MTIME9234191
Ref: 27489234191
Ref: library/stat stat ST_CTIME9234261
Ref: 27499234261
Ref: library/stat stat S_IFSOCK9235713
Ref: 274a9235713
Ref: library/stat stat S_IFLNK9235765
Ref: 274b9235765
Ref: library/stat stat S_IFREG9235831
Ref: 274c9235831
Ref: library/stat stat S_IFBLK9235891
Ref: 274d9235891
Ref: library/stat stat S_IFDIR9235954
Ref: 274e9235954
Ref: library/stat stat S_IFCHR9236011
Ref: 274f9236011
Ref: library/stat stat S_IFIFO9236080
Ref: 27509236080
Ref: library/stat stat S_IFDOOR9236123
Ref: f879236123
Ref: library/stat stat S_IFPORT9236197
Ref: f889236197
Ref: library/stat stat S_IFWHT9236286
Ref: f899236286
Ref: library/stat stat S_ISUID9236715
Ref: 27519236715
Ref: library/stat stat S_ISGID9236782
Ref: 27529236782
Ref: library/stat stat S_ISVTX9237664
Ref: 27559237664
Ref: library/stat stat S_IRWXU9238075
Ref: 27569238075
Ref: library/stat stat S_IRUSR9238168
Ref: 27579238168
Ref: library/stat stat S_IWUSR9238255
Ref: 27589238255
Ref: library/stat stat S_IXUSR9238342
Ref: 27599238342
Ref: library/stat stat S_IRWXG9238426
Ref: 275a9238426
Ref: library/stat stat S_IRGRP9238507
Ref: 275b9238507
Ref: library/stat stat S_IWGRP9238594
Ref: 275c9238594
Ref: library/stat stat S_IXGRP9238681
Ref: 27539238681
Ref: library/stat stat S_IRWXO9238765
Ref: 275d9238765
Ref: library/stat stat S_IROTH9238862
Ref: 275e9238862
Ref: library/stat stat S_IWOTH9238946
Ref: 275f9238946
Ref: library/stat stat S_IXOTH9239030
Ref: 27609239030
Ref: library/stat stat S_ENFMT9239111
Ref: 27549239111
Ref: library/stat stat S_IREAD9239428
Ref: 27619239428
Ref: library/stat stat S_IWRITE9239518
Ref: 27629239518
Ref: library/stat stat S_IEXEC9239609
Ref: 27639239609
Ref: library/stat stat UF_SETTABLE9239796
Ref: 27649239796
Ref: library/stat stat UF_NODUMP9239889
Ref: 27659239889
Ref: library/stat stat UF_IMMUTABLE9239963
Ref: 27669239963
Ref: library/stat stat UF_APPEND9240040
Ref: 27679240040
Ref: library/stat stat UF_OPAQUE9240120
Ref: 27689240120
Ref: library/stat stat UF_NOUNLINK9240281
Ref: 27699240281
Ref: library/stat stat UF_COMPRESSED9240372
Ref: 276a9240372
Ref: library/stat stat UF_TRACKED9240473
Ref: 276b9240473
Ref: library/stat stat UF_DATAVAULT9240579
Ref: 276c9240579
Ref: library/stat stat UF_HIDDEN9240716
Ref: 276d9240716
Ref: library/stat stat SF_SETTABLE9240824
Ref: 276e9240824
Ref: library/stat stat SF_SUPPORTED9240924
Ref: 276f9240924
Ref: library/stat stat SF_SYNTHETIC9241063
Ref: 27709241063
Ref: library/stat stat SF_ARCHIVED9241212
Ref: 27719241212
Ref: library/stat stat SF_IMMUTABLE9241321
Ref: 27729241321
Ref: library/stat stat SF_APPEND9241398
Ref: 27739241398
Ref: library/stat stat SF_RESTRICTED9241478
Ref: 27749241478
Ref: library/stat stat SF_NOUNLINK9241605
Ref: 27759241605
Ref: library/stat stat SF_SNAPSHOT9241696
Ref: 27769241696
Ref: library/stat stat SF_FIRMLINK9241802
Ref: 27779241802
Ref: library/stat stat SF_DATALESS9241908
Ref: 27789241908
Ref: library/stat stat FILE_ATTRIBUTE_ARCHIVE9242433
Ref: 27799242433
Ref: library/stat stat FILE_ATTRIBUTE_COMPRESSED9242476
Ref: 277a9242476
Ref: library/stat stat FILE_ATTRIBUTE_DEVICE9242522
Ref: 277b9242522
Ref: library/stat stat FILE_ATTRIBUTE_DIRECTORY9242564
Ref: 277c9242564
Ref: library/stat stat FILE_ATTRIBUTE_ENCRYPTED9242609
Ref: 277d9242609
Ref: library/stat stat FILE_ATTRIBUTE_HIDDEN9242654
Ref: 277e9242654
Ref: library/stat stat FILE_ATTRIBUTE_INTEGRITY_STREAM9242696
Ref: 277f9242696
Ref: library/stat stat FILE_ATTRIBUTE_NORMAL9242748
Ref: 27809242748
Ref: library/stat stat FILE_ATTRIBUTE_NOT_CONTENT_INDEXED9242790
Ref: 27819242790
Ref: library/stat stat FILE_ATTRIBUTE_NO_SCRUB_DATA9242845
Ref: 27829242845
Ref: library/stat stat FILE_ATTRIBUTE_OFFLINE9242894
Ref: 27839242894
Ref: library/stat stat FILE_ATTRIBUTE_READONLY9242937
Ref: 27849242937
Ref: library/stat stat FILE_ATTRIBUTE_REPARSE_POINT9242981
Ref: 27859242981
Ref: library/stat stat FILE_ATTRIBUTE_SPARSE_FILE9243030
Ref: 27869243030
Ref: library/stat stat FILE_ATTRIBUTE_SYSTEM9243077
Ref: 27879243077
Ref: library/stat stat FILE_ATTRIBUTE_TEMPORARY9243119
Ref: 27889243119
Ref: library/stat stat FILE_ATTRIBUTE_VIRTUAL9243164
Ref: 27899243164
Ref: library/stat stat IO_REPARSE_TAG_SYMLINK9243478
Ref: 278a9243478
Ref: library/stat stat IO_REPARSE_TAG_MOUNT_POINT9243521
Ref: 278b9243521
Ref: library/stat stat IO_REPARSE_TAG_APPEXECLINK9243568
Ref: 278c9243568
Ref: stat --- stat の結果を解釈する-Footnote-19243680
Ref: stat --- stat の結果を解釈する-Footnote-29243744
Ref: stat --- stat の結果を解釈する-Footnote-39243791
Node: filecmp --- ファイルとディレクトリの比較9243871
Ref: library/filecmp doc9244130
Ref: 278d9244130
Ref: library/filecmp filecmp-file-and-directory-comparisons9244130
Ref: 278e9244130
Ref: library/filecmp module-filecmp9244130
Ref: 509244130
Ref: library/filecmp filecmp cmp9244773
Ref: 15c29244773
Ref: library/filecmp filecmp cmpfiles9245755
Ref: 154c9245755
Ref: library/filecmp filecmp clear_cache9246981
Ref: f0b9246981
Ref: filecmp --- ファイルとディレクトリの比較-Footnote-19247319
Node: dircmp クラス9247386
Ref: library/filecmp dircmp-objects9247493
Ref: 278f9247493
Ref: library/filecmp the-dircmp-class9247493
Ref: 27909247493
Ref: library/filecmp filecmp dircmp9247551
Ref: f0d9247551
Ref: library/filecmp filecmp dircmp report9248250
Ref: 27919248250
Ref: library/filecmp filecmp dircmp report_partial_closure9248368
Ref: 27929248368
Ref: library/filecmp filecmp dircmp report_full_closure9248570
Ref: 27939248570
Ref: library/filecmp filecmp dircmp left9249220
Ref: 27949249220
Ref: library/filecmp filecmp dircmp right9249290
Ref: 27959249290
Ref: library/filecmp filecmp dircmp left_list9249361
Ref: 27969249361
Ref: library/filecmp filecmp dircmp right_list9249543
Ref: 27979249543
Ref: library/filecmp filecmp dircmp common9249726
Ref: 27989249726
Ref: library/filecmp filecmp dircmp left_only9249867
Ref: 27999249867
Ref: library/filecmp filecmp dircmp right_only9249983
Ref: 279a9249983
Ref: library/filecmp filecmp dircmp common_dirs9250100
Ref: 279b9250100
Ref: library/filecmp filecmp dircmp common_files9250214
Ref: 279c9250214
Ref: library/filecmp filecmp dircmp common_funny9250317
Ref: 279d9250317
Ref: library/filecmp filecmp dircmp same_files9250538
Ref: 279e9250538
Ref: library/filecmp filecmp dircmp diff_files9250714
Ref: 279f9250714
Ref: library/filecmp filecmp dircmp funny_files9250904
Ref: 27a09250904
Ref: library/filecmp filecmp dircmp subdirs9251033
Ref: 18879251033
Ref: library/filecmp filecmp DEFAULT_IGNORES9251498
Ref: f0c9251498
Node: tempfile --- 一時ファイルやディレクトリの作成9252260
Ref: library/tempfile doc9252534
Ref: 27a19252534
Ref: library/tempfile module-tempfile9252534
Ref: c99252534
Ref: library/tempfile tempfile-generate-temporary-files-and-directories9252534
Ref: 27a29252534
Ref: library/tempfile tempfile TemporaryFile9253906
Ref: 27a39253906
Ref: library/tempfile tempfile NamedTemporaryFile9256564
Ref: 4929256564
Ref: library/tempfile tempfile SpooledTemporaryFile9260420
Ref: 65f9260420
Ref: library/tempfile tempfile SpooledTemporaryFile rollover9260944
Ref: 27a79260944
Ref: library/tempfile tempfile TemporaryDirectory9261950
Ref: 12059261950
Ref: library/tempfile tempfile TemporaryDirectory name9262482
Ref: 27a89262482
Ref: library/tempfile tempfile TemporaryDirectory cleanup9262837
Ref: 27a99262837
Ref: library/tempfile tempfile mkstemp9264162
Ref: 27a49264162
Ref: library/tempfile tempfile mkdtemp9267971
Ref: 2009267971
Ref: library/tempfile tempfile gettempdir9269544
Ref: 18449269544
Ref: library/tempfile tempfile gettempdirb9270969
Ref: 18459270969
Ref: library/tempfile tempfile gettempprefix9271115
Ref: 27ab9271115
Ref: library/tempfile tempfile gettempprefixb9271324
Ref: 27ac9271324
Ref: library/tempfile tempfile tempdir9271904
Ref: 18439271904
Ref: tempfile --- 一時ファイルやディレクトリの作成-Footnote-19273082
Node: 使用例<8>9273150
Ref: library/tempfile examples9273296
Ref: 27ad9273296
Ref: library/tempfile tempfile-examples9273296
Ref: 27a59273296
Node: 非推奨の関数と変数9274712
Ref: library/tempfile deprecated-functions-and-variables9274858
Ref: 27ae9274858
Ref: library/tempfile tempfile-mktemp-deprecated9274858
Ref: 27af9274858
Ref: library/tempfile tempfile mktemp9275647
Ref: 17f89275647
Node: glob --- Unix 形式のパス名のパターン展開9277061
Ref: library/glob doc9277337
Ref: 27b09277337
Ref: library/glob glob-unix-style-pathname-pattern-expansion9277337
Ref: 27b19277337
Ref: library/glob module-glob9277337
Ref: 5a9277337
Ref: library/glob glob glob9278761
Ref: 27f9278761
Ref: library/glob glob iglob9281910
Ref: 7d29281910
Ref: library/glob glob escape9283033
Ref: f139283033
Ref: library/glob glob translate9283544
Ref: 1cb9283544
Ref: glob --- Unix 形式のパス名のパターン展開-Footnote-19285509
Node: 使用例<9>9285573
Ref: library/glob examples9285675
Ref: 27b29285675
Node: fnmatch --- Unix のファイル名パターンマッチ9286994
Ref: library/fnmatch doc9287274
Ref: 27b39287274
Ref: library/fnmatch fnmatch-unix-filename-pattern-matching9287274
Ref: 27b49287274
Ref: library/fnmatch module-fnmatch9287274
Ref: 529287274
Ref: library/fnmatch fnmatch fnmatch9289311
Ref: 180a9289311
Ref: library/fnmatch fnmatch fnmatchcase9290201
Ref: 180b9290201
Ref: library/fnmatch fnmatch filter9290527
Ref: 180c9290527
Ref: library/fnmatch fnmatch translate9290820
Ref: 19b19290820
Ref: fnmatch --- Unix のファイル名パターンマッチ-Footnote-19291438
Node: linecache --- テキストラインへのランダムアクセス9291505
Ref: library/linecache doc9291773
Ref: 27b59291773
Ref: library/linecache linecache-random-access-to-text-lines9291773
Ref: 27b69291773
Ref: library/linecache module-linecache9291773
Ref: 799291773
Ref: library/linecache linecache getline9292885
Ref: df09292885
Ref: library/linecache linecache clearcache9293849
Ref: 27b99293849
Ref: library/linecache linecache checkcache9294102
Ref: 27ba9294102
Ref: library/linecache linecache lazycache9294507
Ref: def9294507
Ref: linecache --- テキストラインへのランダムアクセス-Footnote-19295194
Ref: linecache --- テキストラインへのランダムアクセス-Footnote-29295263
Node: shutil --- 高水準のファイル操作9295305
Ref: library/shutil doc9295508
Ref: 27bb9295508
Ref: library/shutil module-shutil9295508
Ref: b39295508
Ref: library/shutil shutil-high-level-file-operations9295508
Ref: 27bc9295508
Ref: shutil --- 高水準のファイル操作-Footnote-19296997
Node: ディレクトリとファイルの操作9297063
Ref: library/shutil directory-and-files-operations9297216
Ref: 27bd9297216
Ref: library/shutil file-operations9297216
Ref: 27be9297216
Ref: library/shutil shutil copyfileobj9297309
Ref: a2b9297309
Ref: library/shutil shutil copyfile9297907
Ref: a279297907
Ref: library/shutil shutil SameFileError9300045
Ref: f6a9300045
Ref: library/shutil shutil copymode9300215
Ref: 160f9300215
Ref: library/shutil shutil copystat9301172
Ref: 11019301172
Ref: library/shutil shutil copy9303707
Ref: a289303707
Ref: library/shutil shutil copy29305824
Ref: a299305824
Ref: library/shutil shutil ignore_patterns9307756
Ref: 27bf9307756
Ref: library/shutil shutil copytree9308128
Ref: 9f79308128
Ref: library/shutil shutil rmtree9312380
Ref: 2d89312380
Ref: library/shutil shutil rmtree avoids_symlink_attacks9315624
Ref: 27c09315624
Ref: library/shutil shutil move9316100
Ref: a2a9316100
Ref: library/shutil shutil disk_usage9318503
Ref: 11009318503
Ref: library/shutil shutil chown9319416
Ref: 2219319416
Ref: library/shutil shutil which9320188
Ref: 4809320188
Ref: library/shutil shutil Error9322939
Ref: f699322939
Node: プラットフォーム依存の効率的なコピー操作9323349
Ref: library/shutil platform-dependent-efficient-copy-operations9323512
Ref: 27c19323512
Ref: library/shutil shutil-platform-dependent-efficient-copy-operations9323512
Ref: a2c9323512
Ref: プラットフォーム依存の効率的なコピー操作-Footnote-19325072
Ref: プラットフォーム依存の効率的なコピー操作-Footnote-29325137
Node: copytree の例9325185
Ref: library/shutil copytree-example9325370
Ref: 27c29325370
Ref: library/shutil shutil-copytree-example9325370
Ref: 27c39325370
Node: rmtree の例9326074
Ref: library/shutil rmtree-example9326190
Ref: 27c49326190
Ref: library/shutil shutil-rmtree-example9326190
Ref: 27c59326190
Node: アーカイブ化操作9326729
Ref: library/shutil archiving-operations9326933
Ref: 11ea9326933
Ref: library/shutil id19326933
Ref: 27c69326933
Ref: library/shutil shutil make_archive9327345
Ref: 47f9327345
Ref: library/shutil shutil get_archive_formats9330350
Ref: 27c99330350
Ref: library/shutil shutil register_archive_format9331540
Ref: 27c89331540
Ref: library/shutil shutil unregister_archive_format9333100
Ref: 27ca9333100
Ref: library/shutil shutil unpack_archive9333300
Ref: 4389333300
Ref: library/shutil shutil register_unpack_format9335338
Ref: 27cb9335338
Ref: library/shutil shutil unregister_unpack_format9336381
Ref: 27cd9336381
Ref: library/shutil shutil get_unpack_formats9336556
Ref: 27cc9336556
Ref: アーカイブ化操作-Footnote-19337874
Node: アーカイブ化の例9337916
Ref: library/shutil archiving-example9338055
Ref: 27ce9338055
Ref: library/shutil shutil-archiving-example9338055
Ref: 27cf9338055
Node: base_dir を使ったアーカイブ化の例9339232
Ref: library/shutil archiving-example-with-base-dir9339371
Ref: 27d09339371
Ref: library/shutil shutil-archiving-example-with-basedir9339371
Ref: 27c79339371
Node: 出力ターミナルのサイズの取得9340654
Ref: library/shutil querying-the-size-of-the-output-terminal9340807
Ref: 27d19340807
Ref: library/shutil shutil get_terminal_size9340900
Ref: 10d69340900
Ref: 出力ターミナルのサイズの取得-Footnote-19342893
Node: データの永続化9342976
Ref: library/persistence doc9343164
Ref: 27d49343164
Ref: library/persistence data-persistence9343164
Ref: 27d59343164
Ref: library/persistence persistence9343164
Ref: 27d69343164
Node: pickle --- Python オブジェクトの直列化9344497
Ref: library/pickle doc9344664
Ref: 27d79344664
Ref: library/pickle module-pickle9344664
Ref: 959344664
Ref: library/pickle pickle-python-object-serialization9344664
Ref: 27d89344664
Ref: pickle --- Python オブジェクトの直列化-Footnote-19347032
Ref: pickle --- Python オブジェクトの直列化-Footnote-29347098
Node: 他の Python モジュールとの関係9347195
Ref: library/pickle relationship-to-other-python-modules9347363
Ref: 27da9347363
Node: marshal との比較9347512
Ref: library/pickle comparison-with-marshal9347636
Ref: 27db9347636
Node: json との比較9350698
Ref: library/pickle comparison-with-json9350822
Ref: 27d99350822
Ref: library/pickle id29350822
Ref: 27dc9350822
Ref: json との比較-Footnote-19352240
Node: データストリームの形式9352265
Ref: library/pickle data-stream-format9352481
Ref: 27de9352481
Ref: library/pickle pickle-protocols9352481
Ref: c8f9352481
Ref: データストリームの形式-Footnote-19356614
Ref: データストリームの形式-Footnote-29356656
Ref: データストリームの形式-Footnote-39356698
Node: モジュールインターフェース9356740
Ref: library/pickle module-interface9356957
Ref: 27e19356957
Ref: library/pickle pickle HIGHEST_PROTOCOL9357561
Ref: 14489357561
Ref: library/pickle pickle DEFAULT_PROTOCOL9357890
Ref: 7f99357890
Ref: library/pickle pickle dump9358600
Ref: 27e29358600
Ref: library/pickle pickle dumps9359188
Ref: 14479359188
Ref: library/pickle pickle load9359688
Ref: cde9359688
Ref: library/pickle pickle loads9360618
Ref: cdf9360618
Ref: library/pickle pickle PickleError9361550
Ref: 27e39361550
Ref: library/pickle pickle PicklingError9361694
Ref: 27e49361694
Ref: library/pickle pickle UnpicklingError9362090
Ref: 27e69362090
Ref: library/pickle pickle Pickler9362775
Ref: 9ec9362775
Ref: library/pickle pickle Pickler dump9364838
Ref: 19b09364838
Ref: library/pickle pickle Pickler persistent_id9365060
Ref: 15069365060
Ref: library/pickle pickle Pickler dispatch_table9366148
Ref: 10f59366148
Ref: library/pickle pickle Pickler reducer_override9367640
Ref: 9ed9367640
Ref: library/pickle pickle Pickler fast9368570
Ref: 27ec9368570
Ref: library/pickle pickle Unpickler9369237
Ref: 160b9369237
Ref: library/pickle pickle Unpickler load9371903
Ref: 27ee9371903
Ref: library/pickle pickle Unpickler persistent_load9372302
Ref: 150c9372302
Ref: library/pickle pickle Unpickler find_class9373034
Ref: 27ef9373034
Ref: library/pickle pickle PickleBuffer9374038
Ref: 17639374038
Ref: library/pickle pickle PickleBuffer raw9374946
Ref: 27f19374946
Ref: library/pickle pickle PickleBuffer release9375386
Ref: 27f29375386
Node: pickle 化、非 pickle 化できるもの9375550
Ref: library/pickle pickle-picklable9375775
Ref: 27e59375775
Ref: library/pickle what-can-be-pickled-and-unpickled9375775
Ref: 27f39375775
Ref: pickle 化、非 pickle 化できるもの-Footnote-19379460
Ref: pickle 化、非 pickle 化できるもの-Footnote-29379647
Node: クラスインスタンスの pickle 化9379799
Ref: library/pickle pickle-inst9380081
Ref: 27dd9380081
Ref: library/pickle pickling-class-instances9380081
Ref: 27f49380081
Ref: library/pickle object __getnewargs_ex__9381403
Ref: 27f59381403
Ref: library/pickle object __getnewargs__9382437
Ref: 144a9382437
Ref: library/pickle object __getstate__9383177
Ref: 5a29383177
Ref: library/pickle object __setstate__9384532
Ref: 14499384532
Ref: library/pickle object __reduce__9387123
Ref: 9a19387123
Ref: library/pickle object __reduce_ex__9391055
Ref: 151b9391055
Ref: クラスインスタンスの pickle 化-Footnote-19391928
Node: 外部オブジェクトの永続化9392062
Ref: library/pickle persistence-of-external-objects9392215
Ref: 27f79392215
Ref: library/pickle pickle-persistent9392215
Ref: 27e89392215
Ref: 外部オブジェクトの永続化-Footnote-19397209
Node: ディスパッチテーブル9397537
Ref: library/pickle dispatch-tables9397741
Ref: 27f89397741
Ref: library/pickle pickle-dispatch9397741
Ref: 27ea9397741
Node: 状態を持つオブジェクトの扱い9399314
Ref: library/pickle handling-stateful-objects9399473
Ref: 27f99399473
Ref: library/pickle pickle-state9399473
Ref: 27f69399473
Node: 型、関数、その他のオブジェクトに対するリダクションのカスタマイズ9401778
Ref: library/pickle custom-reduction-for-types-functions-and-other-objects9402057
Ref: 27fa9402057
Ref: library/pickle reducer-override9402057
Ref: 27eb9402057
Node: アウトオブバウンドバッファ9404539
Ref: library/pickle out-of-band-buffers9404813
Ref: 27fb9404813
Ref: library/pickle pickle-oob9404813
Ref: 27e79404813
Node: 生産者 API9405904
Ref: library/pickle provider-api9406015
Ref: 27fc9406015
Node: 消費者 API9406925
Ref: library/pickle consumer-api9407058
Ref: 27fd9407058
Node: 使用例<10>9408742
Ref: library/pickle example9408853
Ref: 27fe9408853
Ref: 使用例<10>-Footnote-19411729
Node: グローバル変数を制限する9411771
Ref: library/pickle pickle-restrict9411958
Ref: 27f09411958
Ref: library/pickle restricting-globals9411958
Ref: 27ff9411958
Node: 性能<2>9415337
Ref: library/pickle performance9415498
Ref: 28009415498
Node: 使用例<11>9415880
Ref: library/pickle examples9415996
Ref: 28019415996
Ref: library/pickle pickle-example9415996
Ref: 28029415996
Node: copyreg --- pickle サポート関数を登録する9417417
Ref: library/copyreg doc9417641
Ref: 28039417641
Ref: library/copyreg copyreg-register-pickle-support-functions9417641
Ref: 28049417641
Ref: library/copyreg module-copyreg9417641
Ref: 1f9417641
Ref: library/copyreg copyreg constructor9418446
Ref: 28059418446
Ref: library/copyreg copyreg pickle9418742
Ref: 27e99418742
Ref: copyreg --- pickle サポート関数を登録する-Footnote-19419712
Node: 使用例<12>9419779
Ref: library/copyreg example9419881
Ref: 28069419881
Node: shelve --- Python オブジェクトの永続化9420463
Ref: library/shelve doc9420707
Ref: 28079420707
Ref: library/shelve module-shelve9420707
Ref: b19420707
Ref: library/shelve shelve-python-object-persistence9420707
Ref: 28089420707
Ref: library/shelve shelve open9421486
Ref: 16669421486
Ref: library/shelve shelve-security9424164
Ref: 280c9424164
Ref: library/shelve shelve Shelf sync9424775
Ref: 280a9424775
Ref: library/shelve shelve Shelf close9425237
Ref: 280b9425237
Ref: shelve --- Python オブジェクトの永続化-Footnote-19425697
Ref: shelve --- Python オブジェクトの永続化-Footnote-29425763
Node: 制限事項9425868
Ref: library/shelve restrictions9425987
Ref: 280d9425987
Ref: library/shelve shelve Shelf9427656
Ref: f679427656
Ref: library/shelve shelve BsdDbShelf9429517
Ref: 21b69429517
Ref: library/shelve shelve DbfilenameShelf9430243
Ref: 21b79430243
Ref: 制限事項-Footnote-19431003
Node: 使用例<13>9431056
Ref: library/shelve example9431175
Ref: 280e9431175
Ref: library/shelve shelve-example9431175
Ref: 28099431175
Node: marshal --- 内部使用向けの Python オブジェクト直列化9433006
Ref: library/marshal doc9433262
Ref: 280f9433262
Ref: library/marshal marshal-internal-python-object-serialization9433262
Ref: 28109433262
Ref: library/marshal module-marshal9433262
Ref: 809433262
Ref: library/marshal marshal dump9436087
Ref: 28119436087
Ref: library/marshal marshal load9437104
Ref: 197e9437104
Ref: library/marshal marshal dumps9438176
Ref: e6e9438176
Ref: library/marshal marshal loads9438940
Ref: 28129438940
Ref: library/marshal marshal version9439762
Ref: 28139439762
Ref: marshal --- 内部使用向けの Python オブジェクト直列化-Footnote-19440134
Node: dbm --- Unix "データベース" へのインターフェース9440678
Ref: library/dbm doc9440965
Ref: 28149440965
Ref: library/dbm dbm-interfaces-to-unix-databases9440965
Ref: 28159440965
Ref: library/dbm module-dbm9440965
Ref: 299440965
Ref: library/dbm dbm error9441550
Ref: 28169441550
Ref: library/dbm dbm whichdb9442036
Ref: 28179442036
Ref: library/dbm dbm open9442735
Ref: ef69442735
Ref: dbm --- Unix "データベース" へのインターフェース-Footnote-19446473
Ref: dbm --- Unix "データベース" へのインターフェース-Footnote-29446545
Node: dbm sqlite3 --- SQLite backend for dbm9446598
Ref: library/dbm dbm-sqlite3-sqlite-backend-for-dbm9446778
Ref: 28189446778
Ref: library/dbm module-dbm sqlite39446778
Ref: 2d9446778
Ref: library/dbm dbm sqlite3 open9447492
Ref: 28199447492
Ref: dbm sqlite3 --- SQLite backend for dbm-Footnote-19448504
Node: dbm gnu --- GNU database manager9448575
Ref: library/dbm dbm-gnu-gnu-database-manager9448797
Ref: 281a9448797
Ref: library/dbm module-dbm gnu9448797
Ref: 2b9448797
Ref: library/dbm dbm gnu error9449485
Ref: a689449485
Ref: library/dbm dbm gnu open9449753
Ref: 19aa9449753
Ref: library/dbm dbm gnu open_flags9451334
Ref: 281b9451334
Ref: library/dbm dbm gnu gdbm firstkey9451653
Ref: 281c9451653
Ref: library/dbm dbm gnu gdbm nextkey9451991
Ref: 281d9451991
Ref: library/dbm dbm gnu gdbm reorganize9452475
Ref: 281e9452475
Ref: library/dbm dbm gnu gdbm sync9452918
Ref: 281f9452918
Ref: library/dbm dbm gnu gdbm close9453155
Ref: 28209453155
Ref: library/dbm dbm gnu gdbm clear9453229
Ref: 1b99453229
Ref: dbm gnu --- GNU database manager-Footnote-19453389
Node: dbm ndbm --- New Database Manager9453456
Ref: library/dbm dbm-ndbm-new-database-manager9453682
Ref: 28219453682
Ref: library/dbm module-dbm ndbm9453682
Ref: 2c9453682
Ref: library/dbm dbm ndbm error9454682
Ref: a699454682
Ref: library/dbm dbm ndbm library9454952
Ref: 28229454952
Ref: library/dbm dbm ndbm open9455037
Ref: 19ab9455037
Ref: library/dbm dbm ndbm ndbm close9456212
Ref: 28239456212
Ref: library/dbm dbm ndbm ndbm clear9456286
Ref: 1ba9456286
Ref: dbm ndbm --- New Database Manager-Footnote-19456446
Node: dbm dumb --- 可搬性のある DBM 実装9456514
Ref: library/dbm dbm-dumb-portable-dbm-implementation9456699
Ref: 28249456699
Ref: library/dbm module-dbm dumb9456699
Ref: 2a9456699
Ref: library/dbm dbm dumb error9457613
Ref: a679457613
Ref: library/dbm dbm dumb open9457896
Ref: a649457896
Ref: library/dbm dbm dumb dumbdbm sync9459887
Ref: 28259459887
Ref: library/dbm dbm dumb dumbdbm close9460102
Ref: 28269460102
Ref: dbm dumb --- 可搬性のある DBM 実装-Footnote-19460210
Node: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース9460278
Ref: library/sqlite3 doc9460488
Ref: 28279460488
Ref: library/sqlite3 module-sqlite39460488
Ref: ba9460488
Ref: library/sqlite3 sqlite3-db-api-2-0-interface-for-sqlite-databases9460488
Ref: 28289460488
Ref: library/sqlite3 sqlite3-intro9460692
Ref: 28299460692
Ref: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース-Footnote-19462568
Ref: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース-Footnote-29462633
Ref: sqlite3 --- SQLite データベース用の DB-API 2 0 インターフェース-Footnote-39462675
Node: チュートリアル9462717
Ref: library/sqlite3 sqlite3-tutorial9462881
Ref: 282a9462881
Ref: library/sqlite3 tutorial9462881
Ref: 282e9462881
Ref: チュートリアル-Footnote-19470513
Ref: チュートリアル-Footnote-29470570
Ref: チュートリアル-Footnote-39470629
Ref: チュートリアル-Footnote-49470678
Ref: チュートリアル-Footnote-59470724
Node: リファレンス9470776
Ref: library/sqlite3 reference9470973
Ref: 28389470973
Ref: library/sqlite3 sqlite3-reference9470973
Ref: 282b9470973
Ref: library/sqlite3 sqlite3-module-contents9471024
Ref: 28399471024
Node: モジュール関数9471543
Ref: library/sqlite3 module-functions9471649
Ref: 283a9471649
Ref: library/sqlite3 sqlite3-module-functions9471649
Ref: 283b9471649
Ref: library/sqlite3 sqlite3 connect9471705
Ref: 2889471705
Ref: library/sqlite3 sqlite3 complete_statement9477670
Ref: 28449477670
Ref: library/sqlite3 sqlite3 enable_callback_tracebacks9478685
Ref: 28459478685
Ref: library/sqlite3 sqlite3 register_adapter9479525
Ref: 28469479525
Ref: library/sqlite3 sqlite3 register_converter9480000
Ref: 283c9480000
Ref: モジュール関数-Footnote-19480844
Ref: モジュール関数-Footnote-29480887
Ref: モジュール関数-Footnote-39480929
Node: モジュール定数9481006
Ref: library/sqlite3 module-constants9481150
Ref: 28489481150
Ref: library/sqlite3 sqlite3-module-constants9481150
Ref: 28499481150
Ref: library/sqlite3 sqlite3 LEGACY_TRANSACTION_CONTROL9481206
Ref: 28429481206
Ref: library/sqlite3 sqlite3 PARSE_COLNAMES9481586
Ref: 283f9481586
Ref: library/sqlite3 sqlite3 PARSE_DECLTYPES9482201
Ref: 283e9482201
Ref: library/sqlite3 sqlite3 SQLITE_OK9483136
Ref: 284a9483136
Ref: library/sqlite3 sqlite3 SQLITE_DENY9483169
Ref: 284b9483169
Ref: library/sqlite3 sqlite3 SQLITE_IGNORE9483204
Ref: 284c9483204
Ref: library/sqlite3 sqlite3 apilevel9483791
Ref: 284d9483791
Ref: library/sqlite3 sqlite3 paramstyle9483998
Ref: 284e9483998
Ref: library/sqlite3 sqlite3 sqlite_version9484403
Ref: 284f9484403
Ref: library/sqlite3 sqlite3 sqlite_version_info9484557
Ref: 28509484557
Ref: library/sqlite3 sqlite3 threadsafety9484738
Ref: 6489484738
Ref: library/sqlite3 sqlite3 version9487660
Ref: 2b09487660
Ref: library/sqlite3 sqlite3 version_info9488274
Ref: 2b19488274
Ref: library/sqlite3 sqlite3-dbconfig-constants9488923
Ref: 28519488923
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_DEFENSIVE9488923
Ref: 28529488923
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_DQS_DDL9488972
Ref: 28539488972
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_DQS_DML9489019
Ref: 28549489019
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_ENABLE_FKEY9489066
Ref: 28559489066
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER9489117
Ref: 28569489117
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION9489178
Ref: 28579489178
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_ENABLE_QPSG9489239
Ref: 28589489239
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_ENABLE_TRIGGER9489290
Ref: 28599489290
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_ENABLE_VIEW9489344
Ref: 285a9489344
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_LEGACY_ALTER_TABLE9489395
Ref: 285b9489395
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_LEGACY_FILE_FORMAT9489453
Ref: 285c9489453
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE9489511
Ref: 285d9489511
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_RESET_DATABASE9489567
Ref: 285e9489567
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_TRIGGER_EQP9489621
Ref: 285f9489621
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_TRUSTED_SCHEMA9489672
Ref: 28609489672
Ref: library/sqlite3 sqlite3 SQLITE_DBCONFIG_WRITABLE_SCHEMA9489726
Ref: 28619489726
Ref: モジュール定数-Footnote-19490309
Ref: モジュール定数-Footnote-29490352
Ref: モジュール定数-Footnote-39490407
Node: Connection オブジェクト9490458
Ref: library/sqlite3 connection-objects9490606
Ref: 28629490606
Ref: library/sqlite3 sqlite3-connection-objects9490606
Ref: 28639490606
Ref: library/sqlite3 sqlite3 Connection9490679
Ref: 2269490679
Ref: library/sqlite3 sqlite3 Connection cursor9491557
Ref: 282f9491557
Ref: library/sqlite3 sqlite3 Connection blobopen9492043
Ref: 64d9492043
Ref: library/sqlite3 sqlite3 Connection commit9493521
Ref: 28339493521
Ref: library/sqlite3 sqlite3 Connection rollback9494051
Ref: 28659494051
Ref: library/sqlite3 sqlite3 Connection close9494594
Ref: 2279494594
Ref: library/sqlite3 sqlite3 Connection execute9495190
Ref: 28669495190
Ref: library/sqlite3 sqlite3 Connection executemany9495485
Ref: 28679495485
Ref: library/sqlite3 sqlite3 Connection executescript9495791
Ref: 28689495791
Ref: library/sqlite3 sqlite3 Connection create_function9496087
Ref: 2899496087
Ref: library/sqlite3 sqlite3 Connection create_aggregate9498149
Ref: 28a9498149
Ref: library/sqlite3 sqlite3 Connection create_window_function9500224
Ref: 64c9500224
Ref: library/sqlite3 sqlite3 Connection create_collation9503738
Ref: 6429503738
Ref: library/sqlite3 sqlite3 Connection interrupt9505493
Ref: 286c9505493
Ref: library/sqlite3 sqlite3 Connection set_authorizer9505824
Ref: 28b9505824
Ref: library/sqlite3 sqlite3 Connection set_progress_handler9507890
Ref: 28c9507890
Ref: library/sqlite3 sqlite3 Connection set_trace_callback9508929
Ref: 28d9508929
Ref: library/sqlite3 sqlite3 Connection enable_load_extension9510543
Ref: 8099510543
Ref: library/sqlite3 sqlite3 Connection load_extension9513300
Ref: 4849513300
Ref: library/sqlite3 sqlite3 Connection iterdump9514553
Ref: 2289514553
Ref: library/sqlite3 sqlite3 Connection backup9515684
Ref: b489515684
Ref: library/sqlite3 sqlite3 Connection getlimit9518582
Ref: 6479518582
Ref: library/sqlite3 sqlite3 Connection setlimit9519378
Ref: 6469519378
Ref: library/sqlite3 sqlite3 Connection getconfig9520720
Ref: 4859520720
Ref: library/sqlite3 sqlite3 Connection setconfig9521047
Ref: 4869521047
Ref: library/sqlite3 sqlite3 Connection serialize9521592
Ref: 64a9521592
Ref: library/sqlite3 sqlite3 Connection deserialize9522595
Ref: 64b9522595
Ref: library/sqlite3 sqlite3 Connection autocommit9524059
Ref: 4829524059
Ref: library/sqlite3 sqlite3 Connection in_transaction9525957
Ref: 286f9525957
Ref: library/sqlite3 sqlite3 Connection isolation_level9526341
Ref: 28409526341
Ref: library/sqlite3 sqlite3 Connection row_factory9527591
Ref: 15929527591
Ref: library/sqlite3 sqlite3 Connection text_factory9528289
Ref: 28719528289
Ref: library/sqlite3 sqlite3 Connection total_changes9528828
Ref: 28729528828
Ref: Connection オブジェクト-Footnote-19529063
Ref: Connection オブジェクト-Footnote-29529109
Ref: Connection オブジェクト-Footnote-39529174
Ref: Connection オブジェクト-Footnote-49529233
Ref: Connection オブジェクト-Footnote-59529292
Ref: Connection オブジェクト-Footnote-69529334
Ref: Connection オブジェクト-Footnote-79529376
Ref: Connection オブジェクト-Footnote-89529468
Ref: Connection オブジェクト-Footnote-99529510
Ref: Connection オブジェクト-Footnote-109529602
Node: Cursor オブジェクト9529703
Ref: library/sqlite3 cursor-objects9529852
Ref: 28739529852
Ref: library/sqlite3 sqlite3-cursor-objects9529852
Ref: 28749529852
Ref: library/sqlite3 sqlite3 Cursor9530715
Ref: 28309530715
Ref: library/sqlite3 sqlite3 Cursor execute9530842
Ref: 2b29530842
Ref: library/sqlite3 sqlite3 Cursor executemany9532746
Ref: 2b39532746
Ref: library/sqlite3 sqlite3 Cursor executescript9534476
Ref: 28699534476
Ref: library/sqlite3 sqlite3 Cursor fetchone9535468
Ref: 28319535468
Ref: library/sqlite3 sqlite3 Cursor fetchmany9535859
Ref: 28759535859
Ref: library/sqlite3 sqlite3 Cursor fetchall9536855
Ref: 28349536855
Ref: library/sqlite3 sqlite3 Cursor close9537238
Ref: 28779537238
Ref: library/sqlite3 sqlite3 Cursor setinputsizes9537623
Ref: 28789537623
Ref: library/sqlite3 sqlite3 Cursor setoutputsize9537751
Ref: 28799537751
Ref: library/sqlite3 sqlite3 Cursor arraysize9537891
Ref: 28769537891
Ref: library/sqlite3 sqlite3 Cursor connection9538194
Ref: 287a9538194
Ref: library/sqlite3 sqlite3 Cursor description9538744
Ref: 287b9538744
Ref: library/sqlite3 sqlite3 Cursor lastrowid9539192
Ref: c9f9539192
Ref: library/sqlite3 sqlite3 Cursor rowcount9539957
Ref: 17419539957
Ref: library/sqlite3 sqlite3 Cursor row_factory9540543
Ref: 28709540543
Ref: library/sqlite3 sqlite3-columns-by-name9541644
Ref: 287c9541644
Ref: Cursor オブジェクト-Footnote-19541680
Ref: Cursor オブジェクト-Footnote-29541737
Node: Row オブジェクト9541788
Ref: library/sqlite3 row-objects9541931
Ref: 287d9541931
Ref: library/sqlite3 sqlite3-row-objects9541931
Ref: 287e9541931
Ref: library/sqlite3 sqlite3 Row9541990
Ref: e3a9541990
Ref: library/sqlite3 sqlite3 Row keys9542719
Ref: 287f9542719
Node: Blob オブジェクト9543086
Ref: library/sqlite3 blob-objects9543238
Ref: 28809543238
Ref: library/sqlite3 sqlite3-blob-objects9543238
Ref: 28819543238
Ref: library/sqlite3 sqlite3 Blob9543299
Ref: 64e9543299
Ref: library/sqlite3 sqlite3 Blob close9544639
Ref: 28829544639
Ref: library/sqlite3 sqlite3 Blob read9544937
Ref: 28839544937
Ref: library/sqlite3 sqlite3 Blob write9545502
Ref: 28849545502
Ref: library/sqlite3 sqlite3 Blob tell9545812
Ref: 28859545812
Ref: library/sqlite3 sqlite3 Blob seek9545947
Ref: 28869545947
Node: PrepareProtocol オブジェクト9546377
Ref: library/sqlite3 prepareprotocol-objects9546516
Ref: 28879546516
Ref: library/sqlite3 sqlite3 PrepareProtocol9546599
Ref: 174d9546599
Ref: PrepareProtocol オブジェクト-Footnote-19546985
Node: 例外<7>9547027
Ref: library/sqlite3 exceptions9547167
Ref: 28899547167
Ref: library/sqlite3 sqlite3-exceptions9547167
Ref: 288a9547167
Ref: library/sqlite3 sqlite3 Warning9547276
Ref: 17909547276
Ref: library/sqlite3 sqlite3 Error9547678
Ref: 17eb9547678
Ref: library/sqlite3 sqlite3 Error sqlite_errorcode9548096
Ref: 6449548096
Ref: library/sqlite3 sqlite3 Error sqlite_errorname9548230
Ref: 6459548230
Ref: library/sqlite3 sqlite3 InterfaceError9548376
Ref: 6499548376
Ref: library/sqlite3 sqlite3 DatabaseError9548701
Ref: 286d9548701
Ref: library/sqlite3 sqlite3 DataError9549124
Ref: 18079549124
Ref: library/sqlite3 sqlite3 OperationalError9549401
Ref: 18089549401
Ref: library/sqlite3 sqlite3 IntegrityError9549813
Ref: 288b9549813
Ref: library/sqlite3 sqlite3 InternalError9550092
Ref: 288c9550092
Ref: library/sqlite3 sqlite3 ProgrammingError9550442
Ref: 4bf9550442
Ref: library/sqlite3 sqlite3 NotSupportedError9550858
Ref: 286b9550858
Ref: 例外<7>-Footnote-19551420
Ref: 例外<7>-Footnote-29551462
Ref: 例外<7>-Footnote-39551502
Node: SQLite と Python の型9551542
Ref: library/sqlite3 sqlite-and-python-types9551742
Ref: 288d9551742
Ref: library/sqlite3 sqlite3-types9551742
Ref: 283d9551742
Node: デフォルトの適合関数 adapters とデフォルトの変換関数 converters 非推奨9553846
Ref: library/sqlite3 default-adapters-and-converters-deprecated9554085
Ref: 288e9554085
Ref: library/sqlite3 sqlite3-default-converters9554085
Ref: 4bc9554085
Ref: デフォルトの適合関数 adapters とデフォルトの変換関数 converters 非推奨-Footnote-19555885
Node: コマンドライン・インターフェース9555932
Ref: library/sqlite3 command-line-interface9556138
Ref: 288f9556138
Ref: library/sqlite3 sqlite3-cli9556138
Ref: 40d9556138
Ref: library/sqlite3 cmdoption-python-m-sqlite3-h-v-filename-sql-h9556627
Ref: 28909556627
Ref: library/sqlite3 cmdoption-python-m-sqlite3-h-v-filename-sql-help9556627
Ref: 28919556627
Ref: library/sqlite3 cmdoption-python-m-sqlite3-h-v-filename-sql-v9556683
Ref: 28929556683
Ref: library/sqlite3 cmdoption-python-m-sqlite3-h-v-filename-sql-version9556683
Ref: 28939556683
Node: ハウツー・ガイド9556812
Ref: library/sqlite3 how-to-guides9556994
Ref: 28949556994
Ref: library/sqlite3 sqlite3-howtos9556994
Ref: 282c9556994
Node: プレースホルダを使用して SQL クエリに値を結び付ける方法9557785
Ref: library/sqlite3 how-to-use-placeholders-to-bind-values-in-sql-queries9557996
Ref: 28959557996
Ref: library/sqlite3 sqlite3-placeholders9557996
Ref: 2b49557996
Ref: プレースホルダを使用して SQL クエリに値を結び付ける方法-Footnote-19560918
Ref: プレースホルダを使用して SQL クエリに値を結び付ける方法-Footnote-29560970
Node: カスタム Python 型を SQLite 値に適合させる方法9561012
Ref: library/sqlite3 how-to-adapt-custom-python-types-to-sqlite-values9561289
Ref: 28969561289
Ref: library/sqlite3 sqlite3-adapters9561289
Ref: 28359561289
Node: 適合可能オブジェクトの書き方9562547
Ref: library/sqlite3 how-to-write-adaptable-objects9562775
Ref: 28979562775
Ref: library/sqlite3 sqlite3-conform9562775
Ref: 28889562775
Node: 適合用呼び出し可能オブジェクト adapter callables の登録方法9563786
Ref: library/sqlite3 how-to-register-adapter-callables9564014
Ref: 28989564014
Node: SQLite 値をカスタム Python 型に変換する方法9564774
Ref: library/sqlite3 how-to-convert-sqlite-values-to-custom-python-types9565013
Ref: 28999565013
Ref: library/sqlite3 sqlite3-converters9565013
Ref: 28369565013
Node: 適合関数と変換関数のレシピ集9567966
Ref: library/sqlite3 adapter-and-converter-recipes9568210
Ref: 289a9568210
Ref: library/sqlite3 sqlite3-adapter-converter-recipes9568210
Ref: 4bd9568210
Node: 接続 connection ショートカット・メソッドの使い方9569683
Ref: library/sqlite3 how-to-use-connection-shortcut-methods9569933
Ref: 289b9569933
Ref: library/sqlite3 sqlite3-connection-shortcuts9569933
Ref: 28649569933
Node: 接続 connection コンテキストマネージャの使い方9571408
Ref: library/sqlite3 how-to-use-the-connection-context-manager9571642
Ref: 289c9571642
Ref: library/sqlite3 sqlite3-connection-context-manager9571642
Ref: 174e9571642
Node: SQLite URI の操作方法9573800
Ref: library/sqlite3 how-to-work-with-sqlite-uris9574022
Ref: 289e9574022
Ref: library/sqlite3 sqlite3-uri-tricks9574022
Ref: 28439574022
Ref: SQLite URI の操作方法-Footnote-19575480
Node: 行工場 row factories の作成方法と使用方法9575520
Ref: library/sqlite3 how-to-create-and-use-row-factories9575717
Ref: 289f9575717
Ref: library/sqlite3 sqlite3-howto-row-factory9575717
Ref: 28379575717
Node: How to handle non-UTF-8 text encodings9579255
Ref: library/sqlite3 how-to-handle-non-utf-8-text-encodings9579417
Ref: 28a09579417
Ref: library/sqlite3 sqlite3-howto-encoding9579417
Ref: 286e9579417
Ref: How to handle non-UTF-8 text encodings-Footnote-19580749
Node: 説明9580798
Ref: library/sqlite3 explanation9580953
Ref: 28a19580953
Ref: library/sqlite3 sqlite3-explanation9580953
Ref: 282d9580953
Ref: library/sqlite3 sqlite3-transaction-control9580986
Ref: 28a29580986
Node: トランザクション制御9581031
Ref: library/sqlite3 sqlite3-controlling-transactions9581104
Ref: 28329581104
Ref: library/sqlite3 transaction-control9581104
Ref: 28a39581104
Node: autocommit 属性に依るトランザクション制御9581718
Ref: library/sqlite3 sqlite3-transaction-control-autocommit9581911
Ref: 4839581911
Ref: library/sqlite3 transaction-control-via-the-autocommit-attribute9581911
Ref: 28a49581911
Ref: autocommit 属性に依るトランザクション制御-Footnote-19584381
Ref: autocommit 属性に依るトランザクション制御-Footnote-29584423
Ref: autocommit 属性に依るトランザクション制御-Footnote-39584515
Node: isolation_level 属性に依るトランザクション制御9584557
Ref: library/sqlite3 sqlite3-transaction-control-isolation-level9584750
Ref: 28419584750
Ref: library/sqlite3 transaction-control-via-the-isolation-level-attribute9584750
Ref: 28a59584750
Ref: isolation_level 属性に依るトランザクション制御-Footnote-19587567
Ref: isolation_level 属性に依るトランザクション制御-Footnote-29587667
Node: データ圧縮とアーカイブ9587759
Ref: library/archiving doc9587926
Ref: 27df9587926
Ref: library/archiving archiving9587926
Ref: 28a69587926
Ref: library/archiving data-compression-and-archiving9587926
Ref: 28a79587926
Node: zlib --- gzip 互換の圧縮9588853
Ref: library/zlib doc9589002
Ref: 28a89589002
Ref: library/zlib module-zlib9589002
Ref: 1199589002
Ref: library/zlib zlib-compression-compatible-with-gzip9589002
Ref: 28a99589002
Ref: library/zlib zlib error9590292
Ref: 28aa9590292
Ref: library/zlib zlib adler329590401
Ref: 17949590401
Ref: library/zlib zlib compress9591443
Ref: 60b9591443
Ref: library/zlib compress-wbits9592086
Ref: 28ab9592086
Ref: library/zlib zlib compressobj9593325
Ref: 28ac9593325
Ref: library/zlib zlib crc329595569
Ref: 15f99595569
Ref: library/zlib zlib decompress9596508
Ref: cdb9596508
Ref: library/zlib decompress-wbits9596942
Ref: 28ad9596942
Ref: library/zlib zlib decompressobj9598805
Ref: 28ae9598805
Ref: library/zlib zlib Compress compress9599994
Ref: 28af9599994
Ref: library/zlib zlib Compress flush9600504
Ref: 28b09600504
Ref: library/zlib zlib Compress copy9601498
Ref: 28b19601498
Ref: library/zlib zlib Decompress unused_data9601937
Ref: 28b29601937
Ref: library/zlib zlib Decompress unconsumed_tail9602419
Ref: 28b39602419
Ref: library/zlib zlib Decompress eof9603001
Ref: 11409603001
Ref: library/zlib zlib Decompress decompress9603335
Ref: 28b49603335
Ref: library/zlib zlib Decompress flush9604620
Ref: 28b59604620
Ref: library/zlib zlib Decompress copy9605145
Ref: 28b69605145
Ref: library/zlib zlib ZLIB_VERSION9605744
Ref: 28b79605744
Ref: library/zlib zlib ZLIB_RUNTIME_VERSION9606090
Ref: 11419606090
Ref: zlib --- gzip 互換の圧縮-Footnote-19606651
Node: gzip --- gzip ファイルのサポート9606696
Ref: library/gzip doc9606889
Ref: 28b89606889
Ref: library/gzip gzip-support-for-gzip-files9606889
Ref: 28b99606889
Ref: library/gzip module-gzip9606889
Ref: 5d9606889
Ref: library/gzip gzip open9608048
Ref: 28ba9608048
Ref: library/gzip gzip BadGzipFile9610004
Ref: 9c59610004
Ref: library/gzip gzip GzipFile9610254
Ref: 3f39610254
Ref: library/gzip gzip GzipFile peek9613797
Ref: 11dd9613797
Ref: library/gzip gzip GzipFile mode9614534
Ref: 28bd9614534
Ref: library/gzip gzip GzipFile mtime9614756
Ref: 28bb9614756
Ref: library/gzip gzip GzipFile name9615096
Ref: 4d79615096
Ref: library/gzip gzip compress9616605
Ref: 60a9616605
Ref: library/gzip gzip decompress9617583
Ref: 11de9617583
Ref: gzip --- gzip ファイルのサポート-Footnote-19618271
Node: 使い方の例9618335
Ref: library/gzip examples-of-usage9618482
Ref: 28bf9618482
Ref: library/gzip gzip-usage-examples9618482
Ref: 28c09618482
Node: コマンドラインインターフェイス9619429
Ref: library/gzip command-line-interface9619576
Ref: 28c19619576
Ref: library/gzip gzip-cli9619576
Ref: 28c29619576
Node: コマンドラインオプション9620115
Ref: library/gzip command-line-options9620233
Ref: 28c39620233
Ref: library/gzip cmdoption-gzip-arg-file9620314
Ref: 28c49620314
Ref: library/gzip cmdoption-gzip-fast9620398
Ref: 28c59620398
Ref: library/gzip cmdoption-gzip-best9620485
Ref: 28c69620485
Ref: library/gzip cmdoption-gzip-d9620572
Ref: 28c79620572
Ref: library/gzip cmdoption-gzip-decompress9620572
Ref: 28c89620572
Ref: library/gzip cmdoption-gzip-h9620635
Ref: 28c99620635
Ref: library/gzip cmdoption-gzip-help9620635
Ref: 28ca9620635
Node: bz2 --- bzip2 圧縮のサポート9620708
Ref: library/bz2 doc9620925
Ref: 28cb9620925
Ref: library/bz2 bz2-support-for-bzip2-compression9620925
Ref: 28cc9620925
Ref: library/bz2 module-bz29620925
Ref: f9620925
Ref: bz2 --- bzip2 圧縮のサポート-Footnote-19621923
Node: ファイルの圧縮/解凍9621986
Ref: library/bz2 de-compression-of-files9622122
Ref: 28cd9622122
Ref: library/bz2 bz2 open9622190
Ref: 10639622190
Ref: library/bz2 bz2 BZ2File9624038
Ref: 8329624038
Ref: library/bz2 bz2 BZ2File peek9625832
Ref: 28cf9625832
Ref: library/bz2 bz2 BZ2File fileno9626580
Ref: 28d09626580
Ref: library/bz2 bz2 BZ2File readable9626710
Ref: 28d19626710
Ref: library/bz2 bz2 BZ2File seekable9626838
Ref: 28d29626838
Ref: library/bz2 bz2 BZ2File writable9626960
Ref: 28d39626960
Ref: library/bz2 bz2 BZ2File read19627088
Ref: 28d49627088
Ref: library/bz2 bz2 BZ2File readinto9627413
Ref: 28d59627413
Ref: library/bz2 bz2 BZ2File mode9627572
Ref: 28d69627572
Ref: library/bz2 bz2 BZ2File name9627716
Ref: 28d79627716
Node: 逐次圧縮および展開9629324
Ref: library/bz2 incremental-de-compression9629488
Ref: 28d99629488
Ref: library/bz2 bz2 BZ2Compressor9629554
Ref: 16c89629554
Ref: library/bz2 bz2 BZ2Compressor compress9630032
Ref: 28da9630032
Ref: library/bz2 bz2 BZ2Compressor flush9630532
Ref: 28db9630532
Ref: library/bz2 bz2 BZ2Decompressor9630845
Ref: 16c69630845
Ref: library/bz2 bz2 BZ2Decompressor decompress9631642
Ref: d999631642
Ref: library/bz2 bz2 BZ2Decompressor eof9633256
Ref: 28de9633256
Ref: library/bz2 bz2 BZ2Decompressor unused_data9633404
Ref: 28dd9633404
Ref: library/bz2 bz2 BZ2Decompressor needs_input9633669
Ref: 28dc9633669
Node: 一括圧縮/解凍9633919
Ref: library/bz2 one-shot-de-compression9634073
Ref: 28df9634073
Ref: library/bz2 bz2 compress9634126
Ref: 236c9634126
Ref: library/bz2 bz2 decompress9634547
Ref: 10649634547
Node: 使い方の例<2>9634977
Ref: library/bz2 bz2-usage-examples9635095
Ref: 28e09635095
Ref: library/bz2 examples-of-usage9635095
Ref: 28e19635095
Node: lzma --- LZMA アルゴリズムを使用した圧縮9638180
Ref: library/lzma doc9638396
Ref: 28e29638396
Ref: library/lzma lzma-compression-using-the-lzma-algorithm9638396
Ref: 28e39638396
Ref: library/lzma module-lzma9638396
Ref: 7e9638396
Ref: library/lzma lzma LZMAError9639461
Ref: 28e49639461
Ref: lzma --- LZMA アルゴリズムを使用した圧縮-Footnote-19639877
Node: 圧縮ファイルへの読み書き9639941
Ref: library/lzma reading-and-writing-compressed-files9640109
Ref: 28e59640109
Ref: library/lzma lzma open9640190
Ref: 28e69640190
Ref: library/lzma lzma LZMAFile9642472
Ref: fd79642472
Ref: library/lzma lzma LZMAFile peek9644959
Ref: 28e79644959
Ref: library/lzma lzma LZMAFile mode9645702
Ref: 28e89645702
Ref: library/lzma lzma LZMAFile name9645846
Ref: 28e99645846
Node: メモリ上での圧縮と展開9646427
Ref: library/lzma compressing-and-decompressing-data-in-memory9646616
Ref: 28ea9646616
Ref: library/lzma lzma LZMACompressor9646692
Ref: 16c79646692
Ref: library/lzma lzma LZMACompressor compress9650599
Ref: 28ed9650599
Ref: library/lzma lzma LZMACompressor flush9651172
Ref: 28ee9651172
Ref: library/lzma lzma LZMADecompressor9651496
Ref: 16c59651496
Ref: library/lzma lzma LZMADecompressor decompress9653305
Ref: dfb9653305
Ref: library/lzma lzma LZMADecompressor check9654919
Ref: 28f29654919
Ref: library/lzma lzma LZMADecompressor eof9655277
Ref: 28f39655277
Ref: library/lzma lzma LZMADecompressor unused_data9655392
Ref: 28f19655392
Ref: library/lzma lzma LZMADecompressor needs_input9655610
Ref: 28f09655610
Ref: library/lzma lzma compress9655860
Ref: 28eb9655860
Ref: library/lzma lzma decompress9656278
Ref: 28ef9656278
Node: その他<2>9656837
Ref: library/lzma miscellaneous9657035
Ref: 28f49657035
Ref: library/lzma lzma is_check_supported9657071
Ref: 28f59657071
Node: カスタムフィルタチェインの指定9657530
Ref: library/lzma filter-chain-specs9657708
Ref: 28ec9657708
Ref: library/lzma specifying-custom-filter-chains9657708
Ref: 28f69657708
Node: 使用例<14>9660939
Ref: library/lzma examples9661096
Ref: 28f79661096
Node: zipfile --- ZIP アーカイブの処理9662526
Ref: library/zipfile doc9662765
Ref: 28f89662765
Ref: library/zipfile module-zipfile9662765
Ref: 1179662765
Ref: library/zipfile zipfile-work-with-zip-archives9662765
Ref: 28f99662765
Ref: library/zipfile zipfile BadZipFile9664057
Ref: 17499664057
Ref: library/zipfile zipfile BadZipfile9664204
Ref: 28fa9664204
Ref: library/zipfile zipfile LargeZipFile9664420
Ref: 28fb9664420
Ref: library/zipfile zipfile ZipInfo9665255
Ref: cd89665255
Ref: library/zipfile zipfile is_zipfile9666455
Ref: 12f99666455
Ref: library/zipfile zipfile ZIP_STORED9666913
Ref: 29009666913
Ref: library/zipfile zipfile ZIP_DEFLATED9667091
Ref: 29019667091
Ref: library/zipfile zipfile ZIP_BZIP29667260
Ref: 29029667260
Ref: library/zipfile zipfile ZIP_LZMA9667443
Ref: 29039667443
Ref: zipfile --- ZIP アーカイブの処理-Footnote-19668727
Ref: zipfile --- ZIP アーカイブの処理-Footnote-29668792
Ref: zipfile --- ZIP アーカイブの処理-Footnote-39668860
Ref: zipfile --- ZIP アーカイブの処理-Footnote-49668928
Node: ZipFile オブジェクト9668969
Ref: library/zipfile id19669104
Ref: 29049669104
Ref: library/zipfile zipfile-objects9669104
Ref: 28fc9669104
Ref: library/zipfile zipfile ZipFile9669171
Ref: 6909669171
Ref: library/zipfile zipfile ZipFile close9675086
Ref: 29059675086
Ref: library/zipfile zipfile ZipFile getinfo9675390
Ref: 28fd9675390
Ref: library/zipfile zipfile ZipFile infolist9675722
Ref: 28fe9675722
Ref: library/zipfile zipfile ZipFile namelist9676064
Ref: 29069676064
Ref: library/zipfile zipfile ZipFile open9676173
Ref: 3f49676173
Ref: library/zipfile zipfile ZipFile extract9679227
Ref: 290a9679227
Ref: library/zipfile zipfile ZipFile extractall9680880
Ref: 290b9680880
Ref: library/zipfile zipfile ZipFile printdir9682173
Ref: 290c9682173
Ref: library/zipfile zipfile ZipFile setpassword9682294
Ref: 290d9682294
Ref: library/zipfile zipfile ZipFile read9682437
Ref: 29099682437
Ref: library/zipfile zipfile ZipFile testzip9683377
Ref: 290e9683377
Ref: library/zipfile zipfile ZipFile write9683758
Ref: d1a9683758
Ref: library/zipfile zipfile ZipFile writestr9685753
Ref: 12fa9685753
Ref: library/zipfile zipfile ZipFile mkdir9687476
Ref: 6919687476
Ref: library/zipfile zipfile ZipFile filename9688017
Ref: 290f9688017
Ref: library/zipfile zipfile ZipFile debug9688091
Ref: 29109688091
Ref: library/zipfile zipfile ZipFile comment9688410
Ref: 29119688410
Node: Path オブジェクト9688858
Ref: library/zipfile id29689030
Ref: 29129689030
Ref: library/zipfile path-objects9689030
Ref: 29139689030
Ref: library/zipfile zipfile Path9689091
Ref: 6959689091
Ref: library/zipfile zipfile Path name9689647
Ref: 29149689647
Ref: library/zipfile zipfile Path open9689705
Ref: 15019689705
Ref: library/zipfile zipfile Path iterdir9690606
Ref: 29159690606
Ref: library/zipfile zipfile Path is_dir9690696
Ref: 29169690696
Ref: library/zipfile zipfile Path is_file9690801
Ref: 29179690801
Ref: library/zipfile zipfile Path is_symlink9690902
Ref: 29189690902
Ref: library/zipfile zipfile Path exists9691158
Ref: 29199691158
Ref: library/zipfile zipfile Path suffix9691292
Ref: 6939691292
Ref: library/zipfile zipfile Path stem9691507
Ref: 6929691507
Ref: library/zipfile zipfile Path suffixes9691652
Ref: 6949691652
Ref: library/zipfile zipfile Path read_text9691825
Ref: 16d99691825
Ref: library/zipfile zipfile Path read_bytes9692414
Ref: 291a9692414
Ref: library/zipfile zipfile Path joinpath9692490
Ref: 291b9692490
Ref: Path オブジェクト-Footnote-19693153
Node: PyZipFile オブジェクト9693192
Ref: library/zipfile id39693364
Ref: 291c9693364
Ref: library/zipfile pyzipfile-objects9693364
Ref: 291d9693364
Ref: library/zipfile zipfile PyZipFile9693606
Ref: fc49693606
Ref: library/zipfile zipfile PyZipFile writepy9694031
Ref: fc59694031
Node: ZipInfo オブジェクト9697322
Ref: library/zipfile id49697519
Ref: 291e9697519
Ref: library/zipfile zipinfo-objects9697519
Ref: 28ff9697519
Ref: library/zipfile zipfile ZipInfo from_file9697983
Ref: cd79697983
Ref: library/zipfile zipfile ZipInfo is_dir9699136
Ref: cd99699136
Ref: library/zipfile zipfile ZipInfo filename9699379
Ref: 291f9699379
Ref: library/zipfile zipfile ZipInfo date_time9699458
Ref: 29209699458
Ref: library/zipfile zipfile ZipInfo compress_type9700319
Ref: 29219700319
Ref: library/zipfile zipfile ZipInfo comment9700406
Ref: 29229700406
Ref: library/zipfile zipfile ZipInfo extra9700522
Ref: 29239700522
Ref: library/zipfile zipfile ZipInfo create_system9700772
Ref: 29249700772
Ref: library/zipfile zipfile ZipInfo create_version9700890
Ref: 29259700890
Ref: library/zipfile zipfile ZipInfo extract_version9701000
Ref: 29269701000
Ref: library/zipfile zipfile ZipInfo reserved9701126
Ref: 29279701126
Ref: library/zipfile zipfile ZipInfo flag_bits9701220
Ref: 29289701220
Ref: library/zipfile zipfile ZipInfo volume9701289
Ref: 29299701289
Ref: library/zipfile zipfile ZipInfo internal_attr9701375
Ref: 292a9701375
Ref: library/zipfile zipfile ZipInfo external_attr9701435
Ref: 292b9701435
Ref: library/zipfile zipfile ZipInfo header_offset9701507
Ref: 292c9701507
Ref: library/zipfile zipfile ZipInfo CRC9701606
Ref: 292d9701606
Ref: library/zipfile zipfile ZipInfo compress_size9701697
Ref: 292e9701697
Ref: library/zipfile zipfile ZipInfo file_size9701778
Ref: 29089701778
Ref: ZipInfo オブジェクト-Footnote-19701894
Node: コマンドラインインターフェイス<2>9701962
Ref: library/zipfile command-line-interface9702153
Ref: 292f9702153
Ref: library/zipfile zipfile-commandline9702153
Ref: 29309702153
Node: コマンドラインオプション<2>9703169
Ref: library/zipfile command-line-options9703293
Ref: 29349703293
Ref: library/zipfile cmdoption-zipfile-l9703374
Ref: 29339703374
Ref: library/zipfile cmdoption-zipfile-list9703399
Ref: 29359703399
Ref: library/zipfile cmdoption-zipfile-c9703489
Ref: 29319703489
Ref: library/zipfile cmdoption-zipfile-create9703538
Ref: 29369703538
Ref: library/zipfile cmdoption-zipfile-e9703658
Ref: 29329703658
Ref: library/zipfile cmdoption-zipfile-extract9703696
Ref: 29379703696
Ref: library/zipfile cmdoption-zipfile-t9703814
Ref: 29389703814
Ref: library/zipfile cmdoption-zipfile-test9703839
Ref: 29399703839
Ref: library/zipfile cmdoption-zipfile-metadata-encoding9703920
Ref: 293a9703920
Node: Decompression pitfalls9704093
Ref: library/zipfile decompression-pitfalls9704249
Ref: 293b9704249
Node: From file itself9704532
Ref: library/zipfile from-file-itself9704639
Ref: 293c9704639
Node: File System limitations9704818
Ref: library/zipfile file-system-limitations9704955
Ref: 293d9704955
Node: Resources limitations9705257
Ref: library/zipfile resources-limitations9705390
Ref: 293e9705390
Ref: library/zipfile zipfile-resources-limitations9705390
Ref: 293f9705390
Ref: Resources limitations-Footnote-19705677
Node: Interruption9705724
Ref: library/zipfile interruption9705865
Ref: 29409705865
Node: Default behaviors of extraction9706071
Ref: library/zipfile default-behaviors-of-extraction9706182
Ref: 29419706182
Node: tarfile --- tar アーカイブファイルの読み書き9706447
Ref: library/tarfile doc9706624
Ref: 29429706624
Ref: library/tarfile module-tarfile9706624
Ref: c89706624
Ref: library/tarfile tarfile-read-and-write-tar-archive-files9706624
Ref: 29439706624
Ref: library/tarfile tarfile open9708590
Ref: e409708590
Ref: library/tarfile tarfile is_tarfile9716559
Ref: 17af9716559
Ref: library/tarfile tarfile TarError9717079
Ref: 29489717079
Ref: library/tarfile tarfile ReadError9717190
Ref: 18059717190
Ref: library/tarfile tarfile CompressionError9717404
Ref: 29459717404
Ref: library/tarfile tarfile StreamError9717590
Ref: 29499717590
Ref: library/tarfile tarfile ExtractError9717757
Ref: 294a9717757
Ref: library/tarfile tarfile HeaderError9718001
Ref: 294c9718001
Ref: library/tarfile tarfile FilterError9718168
Ref: 294e9718168
Ref: library/tarfile tarfile FilterError tarinfo9718263
Ref: 29509718263
Ref: library/tarfile tarfile AbsolutePathError9718402
Ref: 29529718402
Ref: library/tarfile tarfile OutsideDestinationError9718507
Ref: 29539718507
Ref: library/tarfile tarfile SpecialFileError9718635
Ref: 29549718635
Ref: library/tarfile tarfile AbsoluteLinkError9718753
Ref: 29559718753
Ref: library/tarfile tarfile LinkOutsideDestinationError9718865
Ref: 29569718865
Ref: library/tarfile tarfile ENCODING9719081
Ref: 29579719081
Ref: library/tarfile tarfile REGTYPE9719280
Ref: 29589719280
Ref: library/tarfile tarfile AREGTYPE9719311
Ref: 29599719311
Ref: library/tarfile tarfile LNKTYPE9719383
Ref: 295b9719383
Ref: library/tarfile tarfile SYMTYPE9719463
Ref: 295c9719463
Ref: library/tarfile tarfile CHRTYPE9719535
Ref: 295d9719535
Ref: library/tarfile tarfile BLKTYPE9719618
Ref: 295e9719618
Ref: library/tarfile tarfile DIRTYPE9719697
Ref: 295f9719697
Ref: library/tarfile tarfile FIFOTYPE9719765
Ref: 29609719765
Ref: library/tarfile tarfile CONTTYPE9719844
Ref: 29619719844
Ref: library/tarfile tarfile GNUTYPE_LONGNAME9719919
Ref: 29629719919
Ref: library/tarfile tarfile GNUTYPE_LONGLINK9720003
Ref: 29639720003
Ref: library/tarfile tarfile GNUTYPE_SPARSE9720087
Ref: 29649720087
Ref: library/tarfile tarfile USTAR_FORMAT9720419
Ref: 29669720419
Ref: library/tarfile tarfile GNU_FORMAT9720505
Ref: 29679720505
Ref: library/tarfile tarfile PAX_FORMAT9720576
Ref: 29689720576
Ref: library/tarfile tarfile DEFAULT_FORMAT9720658
Ref: 29699720658
Ref: tarfile --- tar アーカイブファイルの読み書き-Footnote-19721791
Ref: tarfile --- tar アーカイブファイルの読み書き-Footnote-29721858
Node: TarFile オブジェクト9721930
Ref: library/tarfile id19722086
Ref: 296a9722086
Ref: library/tarfile tarfile-objects9722086
Ref: 29449722086
Ref: library/tarfile tarfile TarFile9723421
Ref: 11e19723421
Ref: library/tarfile tarfile TarFile open9727776
Ref: 17b09727776
Ref: library/tarfile tarfile TarFile getmember9728025
Ref: 17be9728025
Ref: library/tarfile tarfile TarFile getmembers9728447
Ref: e449728447
Ref: library/tarfile tarfile TarFile getnames9728684
Ref: 296c9728684
Ref: library/tarfile tarfile TarFile list9728875
Ref: e439728875
Ref: library/tarfile tarfile TarFile next9729413
Ref: 296d9729413
Ref: library/tarfile tarfile TarFile extractall9729737
Ref: e419729737
Ref: library/tarfile tarfile TarFile extract9732062
Ref: e429732062
Ref: library/tarfile tarfile TarFile extractfile9733769
Ref: 296e9733769
Ref: library/tarfile tarfile TarFile errorlevel9734719
Ref: 294b9734719
Ref: library/tarfile tarfile TarFile extraction_filter9735650
Ref: 296f9735650
Ref: library/tarfile tarfile TarFile add9736960
Ref: bc19736960
Ref: library/tarfile tarfile TarFile addfile9738309
Ref: 15949738309
Ref: library/tarfile tarfile TarFile gettarinfo9738842
Ref: 29719738842
Ref: library/tarfile tarfile TarFile close9740322
Ref: 29749740322
Ref: library/tarfile tarfile TarFile pax_headers9740521
Ref: 29759740521
Node: TarInfo オブジェクト9740663
Ref: library/tarfile id29740846
Ref: 29769740846
Ref: library/tarfile tarinfo-objects9740846
Ref: 29519740846
Ref: library/tarfile tarfile TarInfo9742233
Ref: 11e29742233
Ref: library/tarfile tarfile TarInfo frombuf9742342
Ref: 294d9742342
Ref: library/tarfile tarfile TarInfo fromtarfile9742619
Ref: 29789742619
Ref: library/tarfile tarfile TarInfo tobuf9742873
Ref: 29799742873
Ref: library/tarfile tarfile TarInfo name9743420
Ref: 29739743420
Ref: library/tarfile tarfile TarInfo size9743512
Ref: 29729743512
Ref: library/tarfile tarfile TarInfo mtime9743598
Ref: 297a9743598
Ref: library/tarfile tarfile TarInfo mode9743965
Ref: 297d9743965
Ref: library/tarfile tarfile TarInfo type9744244
Ref: 295a9744244
Ref: library/tarfile tarfile TarInfo linkname9744788
Ref: 297e9744788
Ref: library/tarfile tarfile TarInfo uid9745235
Ref: 297f9745235
Ref: library/tarfile tarfile TarInfo gid9745545
Ref: 29809745545
Ref: library/tarfile tarfile TarInfo uname9745855
Ref: 29819745855
Ref: library/tarfile tarfile TarInfo gname9746167
Ref: 29829746167
Ref: library/tarfile tarfile TarInfo chksum9746479
Ref: 29839746479
Ref: library/tarfile tarfile TarInfo devmajor9746550
Ref: 29849746550
Ref: library/tarfile tarfile TarInfo devminor9746627
Ref: 29859746627
Ref: library/tarfile tarfile TarInfo offset9746704
Ref: 29869746704
Ref: library/tarfile tarfile TarInfo offset_data9746786
Ref: 29879746786
Ref: library/tarfile tarfile TarInfo sparse9746874
Ref: 29889746874
Ref: library/tarfile tarfile TarInfo pax_headers9746938
Ref: 29899746938
Ref: library/tarfile tarfile TarInfo replace9747076
Ref: 29779747076
Ref: library/tarfile tarfile TarInfo isfile9747810
Ref: 298a9747810
Ref: library/tarfile tarfile TarInfo isreg9747936
Ref: 298b9747936
Ref: library/tarfile tarfile TarInfo isdir9748019
Ref: 298c9748019
Ref: library/tarfile tarfile TarInfo issym9748128
Ref: 298d9748128
Ref: library/tarfile tarfile TarInfo islnk9748246
Ref: 298e9748246
Ref: library/tarfile tarfile TarInfo ischr9748355
Ref: 298f9748355
Ref: library/tarfile tarfile TarInfo isblk9748476
Ref: 29909748476
Ref: library/tarfile tarfile TarInfo isfifo9748591
Ref: 29919748591
Ref: library/tarfile tarfile TarInfo isdev9748688
Ref: 29929748688
Node: Extraction filters9748875
Ref: library/tarfile extraction-filters9749080
Ref: 29939749080
Ref: library/tarfile tarfile-extraction-filter9749080
Ref: 4399749080
Ref: Extraction filters-Footnote-19752164
Node: Default named filters9752206
Ref: library/tarfile default-named-filters9752304
Ref: 29959752304
Ref: library/tarfile tarfile fully_trusted_filter9752468
Ref: 29709752468
Ref: library/tarfile tarfile tar_filter9752617
Ref: 29949752617
Ref: library/tarfile tarfile data_filter9753425
Ref: 16629753425
Node: Filter errors9754760
Ref: library/tarfile filter-errors9754897
Ref: 29969754897
Ref: library/tarfile tarfile-extraction-refuse9754897
Ref: 294f9754897
Node: Hints for further verification9755258
Ref: library/tarfile hints-for-further-verification9755406
Ref: 29979755406
Node: Supporting older Python versions9757067
Ref: library/tarfile supporting-older-python-versions9757236
Ref: 29989757236
Node: Stateful extraction filter example9758796
Ref: library/tarfile stateful-extraction-filter-example9758926
Ref: 29999758926
Node: コマンドラインインターフェイス<3>9759718
Ref: library/tarfile command-line-interface9759910
Ref: 299a9759910
Ref: library/tarfile tarfile-commandline9759910
Ref: f989759910
Node: コマンドラインオプション<3>9761132
Ref: library/tarfile command-line-options9761256
Ref: 299e9761256
Ref: library/tarfile cmdoption-tarfile-l9761339
Ref: 299d9761339
Ref: library/tarfile cmdoption-tarfile-list9761364
Ref: 299f9761364
Ref: library/tarfile cmdoption-tarfile-c9761454
Ref: 299b9761454
Ref: library/tarfile cmdoption-tarfile-create9761503
Ref: 29a09761503
Ref: library/tarfile cmdoption-tarfile-e9761623
Ref: 299c9761623
Ref: library/tarfile cmdoption-tarfile-extract9761663
Ref: 29a19761663
Ref: library/tarfile cmdoption-tarfile-t9761835
Ref: 29a29761835
Ref: library/tarfile cmdoption-tarfile-test9761860
Ref: 29a39761860
Ref: library/tarfile cmdoption-tarfile-v9761941
Ref: 29a49761941
Ref: library/tarfile cmdoption-tarfile-verbose9761941
Ref: 29a59761941
Ref: library/tarfile cmdoption-tarfile-filter9762002
Ref: 29a69762002
Node: 使用例<15>9762237
Ref: library/tarfile examples9762458
Ref: 29a79762458
Ref: library/tarfile tar-examples9762458
Ref: 29479762458
Node: サポートしている tar フォーマット9764456
Ref: library/tarfile supported-tar-formats9764655
Ref: 29a89764655
Ref: library/tarfile tar-formats9764655
Ref: 29659764655
Node: Unicode に関する問題9767376
Ref: library/tarfile tar-unicode9767553
Ref: 296b9767553
Ref: library/tarfile unicode-issues9767553
Ref: 29a99767553
Node: ファイルフォーマット9770324
Ref: library/fileformats doc9770497
Ref: 29ab9770497
Ref: library/fileformats file-formats9770497
Ref: 29ac9770497
Ref: library/fileformats fileformats9770497
Ref: 29ad9770497
Node: csv --- CSV ファイルの読み書き9771185
Ref: library/csv doc9771350
Ref: 29ae9771350
Ref: library/csv csv-csv-file-reading-and-writing9771350
Ref: 29af9771350
Ref: library/csv module-csv9771350
Ref: 219771350
Ref: csv --- CSV ファイルの読み書き-Footnote-19774200
Ref: csv --- CSV ファイルの読み書き-Footnote-29774263
Ref: csv --- CSV ファイルの読み書き-Footnote-39774322
Node: モジュールコンテンツ<3>9774364
Ref: library/csv csv-contents9774526
Ref: 29b09774526
Ref: library/csv module-contents9774526
Ref: 29b19774526
Ref: library/csv csv reader9774675
Ref: 4539774675
Ref: library/csv csv writer9776460
Ref: 4549776460
Ref: library/csv csv register_dialect9778677
Ref: 29b49778677
Ref: library/csv csv unregister_dialect9779261
Ref: 17739779261
Ref: library/csv csv get_dialect9779504
Ref: 17729779504
Ref: library/csv csv list_dialects9779774
Ref: 17749779774
Ref: library/csv csv field_size_limit9779878
Ref: 17719779878
Ref: library/csv csv DictReader9780188
Ref: 9b39780188
Ref: library/csv csv DictWriter9782380
Ref: 11cf9782380
Ref: library/csv csv Dialect9784273
Ref: 15df9784273
Ref: library/csv csv excel9785231
Ref: 29b69785231
Ref: library/csv csv excel_tab9785484
Ref: 29b79785484
Ref: library/csv csv unix_dialect9785755
Ref: 11ce9785755
Ref: library/csv csv Sniffer9786166
Ref: 29b89786166
Ref: library/csv csv Sniffer sniff9786409
Ref: 29b99786409
Ref: library/csv csv Sniffer has_header9786809
Ref: 180d9786809
Ref: library/csv csv-constants9788027
Ref: 29ba9788027
Ref: library/csv csv QUOTE_ALL9788105
Ref: 29bb9788105
Ref: library/csv csv QUOTE_MINIMAL9788269
Ref: 29bc9788269
Ref: library/csv csv QUOTE_NONNUMERIC9788561
Ref: 154f9788561
Ref: library/csv csv QUOTE_NONE9788926
Ref: 29bd9788926
Ref: library/csv csv QUOTE_NOTNULL9789542
Ref: 4519789542
Ref: library/csv csv QUOTE_STRINGS9789985
Ref: 4529789985
Ref: library/csv csv Error9790536
Ref: 29b59790536
Ref: モジュールコンテンツ<3>-Footnote-19790695
Ref: モジュールコンテンツ<3>-Footnote-29791099
Node: Dialect クラスと書式化パラメータ9791503
Ref: library/csv csv-fmt-params9791699
Ref: 29b39791699
Ref: library/csv dialects-and-formatting-parameters9791699
Ref: 29be9791699
Ref: library/csv csv Dialect delimiter9792512
Ref: 29bf9792512
Ref: library/csv csv Dialect doublequote9792693
Ref: 29c09792693
Ref: library/csv csv Dialect escapechar9793396
Ref: 29c19793396
Ref: library/csv csv Dialect lineterminator9794044
Ref: 29c29794044
Ref: library/csv csv Dialect quotechar9794519
Ref: 29c39794519
Ref: library/csv csv Dialect quoting9794888
Ref: 29c49794888
Ref: library/csv csv Dialect skipinitialspace9795197
Ref: 29c59795197
Ref: library/csv csv Dialect strict9795390
Ref: 29c69795390
Node: reader オブジェクト9795574
Ref: library/csv id39795762
Ref: 29c79795762
Ref: library/csv reader-objects9795762
Ref: 29b29795762
Ref: library/csv csv csvreader __next__9796041
Ref: 29c89796041
Ref: library/csv csv csvreader dialect9796581
Ref: 29c99796581
Ref: library/csv csv csvreader line_num9796697
Ref: 29ca9796697
Ref: library/csv csv DictReader fieldnames9797013
Ref: 29cb9797013
Node: writer オブジェクト9797277
Ref: library/csv writer-objects9797434
Ref: 29cc9797434
Ref: library/csv csv csvwriter writerow9798365
Ref: db79798365
Ref: library/csv csv csvwriter writerows9798800
Ref: 29cd9798800
Ref: library/csv csv csvwriter dialect9799149
Ref: 29ce9799149
Ref: library/csv csv DictWriter writeheader9799351
Ref: 11d09799351
Node: 使用例<16>9799876
Ref: library/csv csv-examples9799999
Ref: 29cf9799999
Ref: library/csv examples9799999
Ref: 29d09799999
Node: configparser --- 設定ファイルのパーサー9802292
Ref: library/configparser doc9802504
Ref: 29d19802504
Ref: library/configparser configparser-configuration-file-parser9802504
Ref: 29d29802504
Ref: library/configparser module-configparser9802504
Ref: 1b9802504
Ref: configparser --- 設定ファイルのパーサー-Footnote-19804207
Node: クイックスタート9804279
Ref: library/configparser quick-start9804432
Ref: 29d39804432
Ref: クイックスタート-Footnote-19808577
Ref: クイックスタート-Footnote-29808815
Node: サポートされるデータ型9809053
Ref: library/configparser supported-datatypes9809224
Ref: 29d79809224
Ref: サポートされるデータ型-Footnote-19810748
Ref: サポートされるデータ型-Footnote-29810986
Node: 代替値9811224
Ref: library/configparser fallback-values9811414
Ref: 29db9811414
Node: サポートするINI ファイルの構造9812973
Ref: library/configparser supported-ini-file-structure9813146
Ref: 29d49813146
Ref: サポートするINI ファイルの構造-Footnote-19815965
Ref: サポートするINI ファイルの構造-Footnote-29816203
Ref: サポートするINI ファイルの構造-Footnote-39816441
Ref: サポートするINI ファイルの構造-Footnote-49816679
Ref: サポートするINI ファイルの構造-Footnote-59816917
Node: Unnamed Sections9817155
Ref: library/configparser id109817331
Ref: 29de9817331
Ref: library/configparser unnamed-sections9817331
Ref: 29df9817331
Node: 値の補間9817811
Ref: library/configparser interpolation-of-values9817983
Ref: 29e09817983
Ref: library/configparser configparser BasicInterpolation9818270
Ref: 6ed9818270
Ref: library/configparser configparser ExtendedInterpolation9819687
Ref: 6ee9819687
Ref: 値の補間-Footnote-19821317
Node: マップ型プロトコルアクセス9821555
Ref: library/configparser mapping-protocol-access9821765
Ref: 29d59821765
Ref: マップ型プロトコルアクセス-Footnote-19825283
Node: パーサーの振る舞いをカスタマイズする9825521
Ref: library/configparser customizing-parser-behaviour9825745
Ref: 29d69825745
Ref: library/configparser configparser ConfigParser BOOLEAN_STATES9837623
Ref: 29e49837623
Ref: library/configparser configparser ConfigParser SECTCRE9840025
Ref: 29dc9840025
Node: レガシーな API の例9841484
Ref: library/configparser legacy-api-examples9841700
Ref: 29e59841700
Node: ConfigParser オブジェクト9845705
Ref: library/configparser configparser-objects9845901
Ref: 29e69845901
Ref: library/configparser id139845901
Ref: 29e79845901
Ref: library/configparser configparser ConfigParser9845980
Ref: 1aa9845980
Ref: library/configparser configparser ConfigParser defaults9851807
Ref: 29ea9851807
Ref: library/configparser configparser ConfigParser sections9851939
Ref: 29eb9851939
Ref: library/configparser configparser ConfigParser add_section9852112
Ref: 123f9852112
Ref: library/configparser configparser ConfigParser has_section9852804
Ref: 29ec9852804
Ref: library/configparser configparser ConfigParser options9852991
Ref: 29ed9852991
Ref: library/configparser configparser ConfigParser has_option9853148
Ref: 29ee9853148
Ref: library/configparser configparser ConfigParser read9853544
Ref: 140d9853544
Ref: library/configparser configparser ConfigParser read_file9855776
Ref: 4d19855776
Ref: library/configparser configparser ConfigParser read_string9856330
Ref: 29e39856330
Ref: library/configparser configparser ConfigParser read_dict9856778
Ref: 29e19856778
Ref: library/configparser configparser ConfigParser get9857616
Ref: 123d9857616
Ref: library/configparser configparser ConfigParser getint9858601
Ref: 29d99858601
Ref: library/configparser configparser ConfigParser getfloat9858929
Ref: 29da9858929
Ref: library/configparser configparser ConfigParser getboolean9859239
Ref: 29d89859239
Ref: library/configparser configparser ConfigParser items9859970
Ref: 29ef9859970
Ref: library/configparser configparser ConfigParser set9860767
Ref: 123e9860767
Ref: library/configparser configparser ConfigParser write9861199
Ref: 29e29861199
Ref: library/configparser configparser ConfigParser remove_option9861986
Ref: 29f19861986
Ref: library/configparser configparser ConfigParser remove_section9862402
Ref: 29f29862402
Ref: library/configparser configparser ConfigParser optionxform9862670
Ref: 29e89862670
Ref: library/configparser configparser UNNAMED_SECTION9863872
Ref: 29dd9863872
Ref: library/configparser configparser MAX_INTERPOLATION_DEPTH9864048
Ref: 29f39864048
Node: RawConfigParser オブジェクト9864286
Ref: library/configparser id159864465
Ref: 29f49864465
Ref: library/configparser rawconfigparser-objects9864465
Ref: 29f59864465
Ref: library/configparser configparser RawConfigParser9864550
Ref: f319864550
Ref: library/configparser configparser RawConfigParser add_section9866029
Ref: 29f69866029
Ref: library/configparser configparser RawConfigParser set9866710
Ref: 29f79866710
Node: 例外<8>9867839
Ref: library/configparser exceptions9867978
Ref: 29f89867978
Ref: library/configparser configparser Error9868011
Ref: 29f99868011
Ref: library/configparser configparser NoSectionError9868123
Ref: 29f09868123
Ref: library/configparser configparser DuplicateSectionError9868255
Ref: 12409868255
Ref: library/configparser configparser DuplicateOptionError9868668
Ref: 12419868668
Ref: library/configparser configparser NoOptionError9869113
Ref: 29fa9869113
Ref: library/configparser configparser InterpolationError9869289
Ref: 29fb9869289
Ref: library/configparser configparser InterpolationDepthError9869434
Ref: 29fc9869434
Ref: library/configparser configparser InterpolationMissingOptionError9869723
Ref: 29fd9869723
Ref: library/configparser configparser InterpolationSyntaxError9869946
Ref: 29fe9869946
Ref: library/configparser configparser MissingSectionHeaderError9870193
Ref: 29ff9870193
Ref: library/configparser configparser ParsingError9870372
Ref: 4d09870372
Ref: library/configparser configparser MultilineContinuationError9870706
Ref: 29e99870706
Node: tomllib --- TOML ファイルの解析9870906
Ref: library/tomllib doc9871116
Ref: 2a009871116
Ref: library/tomllib module-tomllib9871116
Ref: e59871116
Ref: library/tomllib tomllib-parse-toml-files9871116
Ref: 2a019871116
Ref: library/tomllib tomllib load9872114
Ref: 2a029872114
Ref: library/tomllib tomllib loads9873142
Ref: 2a059873142
Ref: library/tomllib tomllib TOMLDecodeError9873656
Ref: 2a049873656
Ref: tomllib --- TOML ファイルの解析-Footnote-19873838
Ref: tomllib --- TOML ファイルの解析-Footnote-29873902
Ref: tomllib --- TOML ファイルの解析-Footnote-39873930
Ref: tomllib --- TOML ファイルの解析-Footnote-49873972
Node: 使用例<17>9874014
Ref: library/tomllib examples9874120
Ref: 2a069874120
Node: 変換表9874487
Ref: library/tomllib conversion-table9874593
Ref: 2a079874593
Ref: library/tomllib toml-to-py-table9874629
Ref: 2a039874629
Node: netrc --- netrc ファイルの処理9876102
Ref: library/netrc doc9876323
Ref: 2a089876323
Ref: library/netrc module-netrc9876323
Ref: 8d9876323
Ref: library/netrc netrc-netrc-file-processing9876323
Ref: 2a099876323
Ref: library/netrc netrc netrc9876720
Ref: 182c9876720
Ref: library/netrc netrc NetrcParseError9879038
Ref: 2a0a9879038
Ref: library/netrc netrc NetrcParseError msg9879291
Ref: 2a0b9879291
Ref: library/netrc netrc NetrcParseError filename9879370
Ref: 2a0c9879370
Ref: library/netrc netrc NetrcParseError lineno9879445
Ref: 2a0d9879445
Ref: netrc --- netrc ファイルの処理-Footnote-19879599
Node: netrc オブジェクト9879664
Ref: library/netrc id19879762
Ref: 2a0e9879762
Ref: library/netrc netrc-objects9879762
Ref: 2a0f9879762
Ref: library/netrc netrc netrc authenticators9879910
Ref: 2a109879910
Ref: library/netrc netrc netrc __repr__9880366
Ref: 2a119880366
Ref: library/netrc netrc netrc hosts9880738
Ref: 2a129880738
Ref: library/netrc netrc netrc macros9880997
Ref: 2a139880997
Node: plistlib --- Apple plist ファイルを生成・解析する9881108
Ref: library/plistlib doc9881282
Ref: 2a149881282
Ref: library/plistlib module-plistlib9881282
Ref: 999881282
Ref: library/plistlib plistlib-generate-and-parse-apple-plist-files9881282
Ref: 2a159881282
Ref: library/plistlib plistlib load9883290
Ref: 91d9883290
Ref: library/plistlib plistlib loads9884893
Ref: 91e9884893
Ref: library/plistlib plistlib dump9885340
Ref: 91f9885340
Ref: library/plistlib plistlib dumps9887084
Ref: 9209887084
Ref: library/plistlib plistlib UID9887483
Ref: 9ef9887483
Ref: library/plistlib plistlib FMT_XML9888033
Ref: f469888033
Ref: library/plistlib plistlib FMT_BINARY9888139
Ref: f479888139
Ref: plistlib --- Apple plist ファイルを生成・解析する-Footnote-19888329
Ref: plistlib --- Apple plist ファイルを生成・解析する-Footnote-29888397
Node: 使用例<18>9888496
Ref: library/plistlib examples9888607
Ref: 2a169888607
Node: 暗号関連のサービス9889473
Ref: library/crypto doc9889667
Ref: 2a179889667
Ref: library/crypto crypto9889667
Ref: 2a189889667
Ref: library/crypto cryptographic-services9889667
Ref: 2a199889667
Node: hashlib --- セキュアハッシュとメッセージダイジェスト9890407
Ref: library/hashlib doc9890618
Ref: 2a1a9890618
Ref: library/hashlib hashlib-secure-hashes-and-message-digests9890618
Ref: 2a1b9890618
Ref: library/hashlib module-hashlib9890618
Ref: 5e9890618
Ref: hashlib --- セキュアハッシュとメッセージダイジェスト-Footnote-19891714
Ref: hashlib --- セキュアハッシュとメッセージダイジェスト-Footnote-29891781
Ref: hashlib --- セキュアハッシュとメッセージダイジェスト-Footnote-39891838
Ref: hashlib --- セキュアハッシュとメッセージダイジェスト-Footnote-49891888
Node: ハッシュアルゴリズム9891947
Ref: library/hashlib hash-algorithms9892104
Ref: 2a1c9892104
Ref: library/hashlib id19892104
Ref: 2a1d9892104
Ref: library/hashlib hashlib-usedforsecurity9894247
Ref: 2a289894247
Ref: ハッシュアルゴリズム-Footnote-19894953
Ref: ハッシュアルゴリズム-Footnote-29895061
Node: 使用法9895108
Ref: library/hashlib usage9895286
Ref: 2a299895286
Node: Constructors9895986
Ref: library/hashlib constructors9896140
Ref: 2a2a9896140
Ref: library/hashlib hashlib new9896185
Ref: 18b19896185
Ref: library/hashlib hashlib md59896748
Ref: 2a269896748
Ref: library/hashlib hashlib sha19896810
Ref: 2a229896810
Ref: library/hashlib hashlib sha2249896873
Ref: 2a239896873
Ref: library/hashlib hashlib sha2569896938
Ref: 2a1e9896938
Ref: library/hashlib hashlib sha3849897003
Ref: 2a249897003
Ref: library/hashlib hashlib sha5129897068
Ref: 2a259897068
Ref: library/hashlib hashlib sha3_2249897133
Ref: c709897133
Ref: library/hashlib hashlib sha3_2569897200
Ref: c719897200
Ref: library/hashlib hashlib sha3_3849897267
Ref: c729897267
Ref: library/hashlib hashlib sha3_5129897334
Ref: c739897334
Node: 属性9897499
Ref: library/hashlib attributes9897656
Ref: 2a2b9897656
Ref: library/hashlib hashlib algorithms_guaranteed9897747
Ref: 133b9897747
Ref: library/hashlib hashlib algorithms_available9898293
Ref: 133c9898293
Node: Hash Objects9898767
Ref: library/hashlib hash-objects9898945
Ref: 2a2c9898945
Ref: library/hashlib hashlib hash digest_size9899117
Ref: 2a2d9899117
Ref: library/hashlib hashlib hash block_size9899202
Ref: 2a2e9899202
Ref: library/hashlib hashlib hash name9899400
Ref: f159899400
Ref: library/hashlib hashlib hash update9899974
Ref: 2a1f9899974
Ref: library/hashlib hashlib hash digest9900361
Ref: 2a209900361
Ref: library/hashlib hashlib hash hexdigest9900650
Ref: 2a219900650
Ref: library/hashlib hashlib hash copy9900910
Ref: 2a2f9900910
Node: SHAKE 可変長ダイジェスト9901171
Ref: library/hashlib shake-variable-length-digests9901355
Ref: 2a309901355
Ref: library/hashlib hashlib shake_1289901433
Ref: c749901433
Ref: library/hashlib hashlib shake_2569901501
Ref: c759901501
Ref: library/hashlib hashlib shake digest9901830
Ref: 19a49901830
Ref: library/hashlib hashlib shake hexdigest9902067
Ref: 19a59902067
Node: File hashing9902507
Ref: library/hashlib file-hashing9902688
Ref: 2a319902688
Ref: library/hashlib hashlib file_digest9902833
Ref: 6109902833
Node: 鍵導出9904232
Ref: library/hashlib key-derivation9904386
Ref: 2a329904386
Ref: library/hashlib hashlib pbkdf2_hmac9904831
Ref: 4d99904831
Ref: library/hashlib hashlib scrypt9906802
Ref: c0c9906802
Ref: 鍵導出-Footnote-19907707
Ref: 鍵導出-Footnote-29907769
Ref: 鍵導出-Footnote-39907856
Ref: 鍵導出-Footnote-49907967
Node: BLAKE29908026
Ref: library/hashlib blake29908159
Ref: 2a339908159
Ref: library/hashlib hashlib-blake29908159
Ref: 1cf99908159
Ref: BLAKE2-Footnote-19908973
Ref: BLAKE2-Footnote-29909004
Ref: BLAKE2-Footnote-39909063
Node: ハッシュオブジェクトの作成9909141
Ref: library/hashlib creating-hash-objects9909241
Ref: 2a349909241
Ref: library/hashlib hashlib blake2b9909447
Ref: 60e9909447
Ref: library/hashlib hashlib blake2s9909684
Ref: 60f9909684
Ref: ハッシュオブジェクトの作成-Footnote-19912864
Node: 定数<5>9912915
Ref: library/hashlib constants9913037
Ref: 2a359913037
Ref: library/hashlib hashlib blake2b SALT_SIZE9913070
Ref: 2a369913070
Ref: library/hashlib hashlib blake2s SALT_SIZE9913104
Ref: 2a379913104
Ref: library/hashlib hashlib blake2b PERSON_SIZE9913209
Ref: 2a389913209
Ref: library/hashlib hashlib blake2s PERSON_SIZE9913245
Ref: 2a399913245
Ref: library/hashlib hashlib blake2b MAX_KEY_SIZE9913355
Ref: 2a3a9913355
Ref: library/hashlib hashlib blake2s MAX_KEY_SIZE9913392
Ref: 2a3b9913392
Ref: library/hashlib hashlib blake2b MAX_DIGEST_SIZE9913446
Ref: 2a3c9913446
Ref: library/hashlib hashlib blake2s MAX_DIGEST_SIZE9913486
Ref: 2a3d9913486
Node: 使用例<19>9913594
Ref: library/hashlib examples9913692
Ref: 2a3e9913692
Node: 簡単なハッシュ化9913886
Ref: library/hashlib simple-hashing9913997
Ref: 2a3f9913997
Node: Using different digest sizes9915463
Ref: library/hashlib using-different-digest-sizes9915596
Ref: 2a409915596
Node: Keyed hashing9916841
Ref: library/hashlib keyed-hashing9916968
Ref: 2a419916968
Ref: Keyed hashing-Footnote-19918975
Node: Randomized hashing9919018
Ref: library/hashlib randomized-hashing9919132
Ref: 2a429919132
Ref: Randomized hashing-Footnote-19921734
Ref: Randomized hashing-Footnote-29921786
Node: Personalization9921821
Ref: library/hashlib personalization9921940
Ref: 2a439921940
Ref: Personalization-Footnote-19923958
Node: ツリーモード9924028
Ref: library/hashlib tree-mode9924120
Ref: 2a449924120
Node: クレジット9925444
Ref: library/hashlib credits9925524
Ref: 2a459925524
Ref: library/hashlib hashlib-seealso9927262
Ref: 2a279927262
Ref: クレジット-Footnote-19928399
Ref: クレジット-Footnote-29928430
Ref: クレジット-Footnote-39928491
Ref: クレジット-Footnote-49928569
Ref: クレジット-Footnote-59928606
Ref: クレジット-Footnote-69928649
Node: hmac --- メッセージ認証のための鍵付きハッシュ化9928692
Ref: library/hmac doc9928978
Ref: 2a469928978
Ref: library/hmac hmac-keyed-hashing-for-message-authentication9928978
Ref: 2a479928978
Ref: library/hmac module-hmac9928978
Ref: 609928978
Ref: library/hmac hmac new9929338
Ref: a6d9929338
Ref: library/hmac hmac digest9930312
Ref: b0c9930312
Ref: library/hmac hmac HMAC update9931117
Ref: f179931117
Ref: library/hmac hmac HMAC digest9931622
Ref: 2a489931622
Ref: library/hmac hmac HMAC hexdigest9932294
Ref: 2a499932294
Ref: library/hmac hmac HMAC copy9932899
Ref: 2a4a9932899
Ref: library/hmac hmac HMAC digest_size9933264
Ref: f1a9933264
Ref: library/hmac hmac HMAC block_size9933361
Ref: f189933361
Ref: library/hmac hmac HMAC name9933512
Ref: f199933512
Ref: library/hmac hmac compare_digest9933871
Ref: 109c9933871
Ref: hmac --- メッセージ認証のための鍵付きハッシュ化-Footnote-19935035
Ref: hmac --- メッセージ認証のための鍵付きハッシュ化-Footnote-29935099
Node: secrets --- 機密を扱うために安全な乱数を生成する9935158
Ref: library/secrets doc9935363
Ref: 2a4b9935363
Ref: library/secrets module-secrets9935363
Ref: ae9935363
Ref: library/secrets secrets-generate-secure-random-numbers-for-managing-secrets9935363
Ref: 2a4c9935363
Ref: secrets --- 機密を扱うために安全な乱数を生成する-Footnote-19936355
Ref: secrets --- 機密を扱うために安全な乱数を生成する-Footnote-29936422
Node: 乱数9936464
Ref: library/secrets random-numbers9936603
Ref: 2a4d9936603
Ref: library/secrets secrets SystemRandom9936768
Ref: 2a4e9936768
Ref: library/secrets secrets choice9937029
Ref: 2a4f9937029
Ref: library/secrets secrets randbelow9937157
Ref: 2a509937157
Ref: library/secrets secrets randbits9937302
Ref: 2a519937302
Node: トークンの生成9937393
Ref: library/secrets generating-tokens9937559
Ref: 2a529937559
Ref: library/secrets secrets token_bytes9937813
Ref: 26359937813
Ref: library/secrets secrets token_hex9938146
Ref: 17169938146
Ref: library/secrets secrets token_urlsafe9938602
Ref: 2a539938602
Node: トークンは何バイト使うべきか？9939142
Ref: library/secrets how-many-bytes-should-tokens-use9939245
Ref: 2a549939245
Ref: トークンは何バイト使うべきか？-Footnote-19940500
Node: その他の関数9940557
Ref: library/secrets other-functions9940756
Ref: 2a559940756
Ref: library/secrets secrets compare_digest9940807
Ref: 2a569940807
Ref: その他の関数-Footnote-19941279
Node: レシピとベストプラクティス9941336
Ref: library/secrets recipes-and-best-practices9941505
Ref: 2a579941505
Ref: レシピとベストプラクティス-Footnote-19943532
Ref: レシピとベストプラクティス-Footnote-29943588
Node: 汎用オペレーティングシステムサービス9943618
Ref: library/allos doc9943794
Ref: 2a589943794
Ref: library/allos allos9943794
Ref: 2a599943794
Ref: library/allos generic-operating-system-services9943794
Ref: 2a5a9943794
Node: os --- 雑多なオペレーティングシステムインターフェース9946165
Ref: library/os doc9946387
Ref: 2a5b9946387
Ref: library/os module-os9946387
Ref: 919946387
Ref: library/os os-miscellaneous-operating-system-interfaces9946387
Ref: 2a5c9946387
Ref: library/os os error9949195
Ref: 2a5f9949195
Ref: library/os os name9949302
Ref: 2a609949302
Ref: library/os os-filenames9949874
Ref: 29aa9949874
Ref: os --- 雑多なオペレーティングシステムインターフェース-Footnote-19950303
Node: ファイル名、コマンドライン引数、および環境変数9950365
Ref: library/os file-names-command-line-arguments-and-environment-variables9950573
Ref: 2a619950573
Ref: library/os filesystem-encoding9950573
Ref: 270c9950573
Node: Python UTF-8 Mode9952316
Ref: library/os python-utf-8-mode9952566
Ref: 2a629952566
Ref: library/os utf8-mode9952566
Ref: 6229952566
Ref: Python UTF-8 Mode-Footnote-19955440
Ref: Python UTF-8 Mode-Footnote-29955482
Node: プロセスのパラメーター9955524
Ref: library/os os-procinfo9955744
Ref: 2a639955744
Ref: library/os process-parameters9955744
Ref: 2a649955744
Ref: library/os os ctermid9955997
Ref: 2a659955997
Ref: library/os os environ9956158
Ref: 118a9956158
Ref: library/os os environb9958610
Ref: 11e89958610
Ref: library/os os fsencode9959495
Ref: c239959495
Ref: library/os os fsdecode9960048
Ref: c229960048
Ref: library/os os fspath9960599
Ref: c219960599
Ref: library/os os PathLike9961151
Ref: c1f9961151
Ref: library/os os PathLike __fspath__9961364
Ref: c209961364
Ref: library/os os getenv9961695
Ref: 2a679961695
Ref: library/os os getenvb9962620
Ref: 11e79962620
Ref: library/os os get_exec_path9963440
Ref: 2a689963440
Ref: library/os os getegid9963893
Ref: 2a699963893
Ref: library/os os geteuid9964162
Ref: 17549964162
Ref: library/os os getgid9964312
Ref: 2a6a9964312
Ref: library/os os getgrouplist9964567
Ref: 10e79964567
Ref: library/os os getgroups9964963
Ref: 2a6b9964963
Ref: library/os os getlogin9966508
Ref: 2a6d9966508
Ref: library/os os getpgid9967030
Ref: 2a6e9967030
Ref: library/os os getpgrp9967305
Ref: 2a6f9967305
Ref: library/os os getpid9967449
Ref: 2a5e9967449
Ref: library/os os getppid9967647
Ref: 15b69967647
Ref: library/os os getpriority9968147
Ref: 10d29968147
Ref: library/os os PRIO_PROCESS9968987
Ref: 2a709968987
Ref: library/os os PRIO_PGRP9969018
Ref: 2a719969018
Ref: library/os os PRIO_USER9969046
Ref: 2a729969046
Ref: library/os os PRIO_DARWIN_THREAD9969253
Ref: 2a739969253
Ref: library/os os PRIO_DARWIN_PROCESS9969290
Ref: 2a749969290
Ref: library/os os PRIO_DARWIN_BG9969328
Ref: 2a759969328
Ref: library/os os PRIO_DARWIN_NONUI9969361
Ref: 2a769969361
Ref: library/os os getresuid9969567
Ref: 12e59969567
Ref: library/os os getresgid9969853
Ref: 12e49969853
Ref: library/os os getuid9970139
Ref: 2a5d9970139
Ref: library/os os initgroups9970394
Ref: 12e89970394
Ref: library/os os putenv9970765
Ref: 8ea9970765
Ref: library/os os setegid9972202
Ref: 2a789972202
Ref: library/os os seteuid9972378
Ref: 2a799972378
Ref: library/os os setgid9972554
Ref: 2a7a9972554
Ref: library/os os setgroups9972722
Ref: 2a6c9972722
Ref: library/os os setns9973582
Ref: 172b9973582
Ref: library/os os setpgrp9975095
Ref: 2a7c9975095
Ref: library/os os setpgid9975392
Ref: 2a7d9975392
Ref: library/os os setpriority9975738
Ref: 10d39975738
Ref: library/os os setregid9976760
Ref: 2a7e9976760
Ref: library/os os setresgid9976968
Ref: 12e69976968
Ref: library/os os setresuid9977248
Ref: 12e79977248
Ref: library/os os setreuid9977525
Ref: 2a7f9977525
Ref: library/os os getsid9977733
Ref: 2a809977733
Ref: library/os os setsid9977965
Ref: 19409977965
Ref: library/os os setuid9978191
Ref: 2a819978191
Ref: library/os os strerror9978356
Ref: 2a829978356
Ref: library/os os supports_bytes_environ9978658
Ref: 11e69978658
Ref: library/os os umask9978869
Ref: 2a839978869
Ref: library/os os uname9979104
Ref: 10e99979104
Ref: library/os os unsetenv9980732
Ref: 8e99980732
Ref: library/os os unshare9981668
Ref: 172c9981668
Ref: library/os os-unshare-clone-flags9982371
Ref: 2a7b9982371
Ref: library/os os CLONE_FILES9982541
Ref: 2a859982541
Ref: library/os os CLONE_FS9982571
Ref: 2a869982571
Ref: library/os os CLONE_NEWCGROUP9982598
Ref: 2a879982598
Ref: library/os os CLONE_NEWIPC9982632
Ref: 2a889982632
Ref: library/os os CLONE_NEWNET9982663
Ref: 2a899982663
Ref: library/os os CLONE_NEWNS9982694
Ref: 2a8a9982694
Ref: library/os os CLONE_NEWPID9982724
Ref: 2a8b9982724
Ref: library/os os CLONE_NEWTIME9982755
Ref: 2a8c9982755
Ref: library/os os CLONE_NEWUSER9982787
Ref: 2a8d9982787
Ref: library/os os CLONE_NEWUTS9982819
Ref: 2a8e9982819
Ref: library/os os CLONE_SIGHAND9982850
Ref: 2a8f9982850
Ref: library/os os CLONE_SYSVSEM9982882
Ref: 2a909982882
Ref: library/os os CLONE_THREAD9982914
Ref: 2a919982914
Ref: library/os os CLONE_VM9982945
Ref: 2a929982945
Ref: プロセスのパラメーター-Footnote-19983009
Ref: プロセスのパラメーター-Footnote-29983051
Ref: プロセスのパラメーター-Footnote-39983093
Ref: プロセスのパラメーター-Footnote-49983138
Ref: プロセスのパラメーター-Footnote-59983188
Ref: プロセスのパラメーター-Footnote-69983235
Node: ファイルオブジェクトの生成9983282
Ref: library/os file-object-creation9983515
Ref: 2a939983515
Ref: library/os os-newstreams9983515
Ref: 2a949983515
Ref: library/os os fdopen9983797
Ref: 1e929983797
Node: ファイル記述子の操作9984195
Ref: library/os file-descriptor-operations9984428
Ref: 2a959984428
Ref: library/os os-fd-ops9984428
Ref: 2a969984428
Ref: library/os os close9985601
Ref: b429985601
Ref: library/os os closerange9986183
Ref: 2a979986183
Ref: library/os os copy_file_range9986548
Ref: 2a989986548
Ref: library/os os device_encoding9988266
Ref: 17fc9988266
Ref: library/os os dup9988815
Ref: 19489988815
Ref: library/os os dup29989339
Ref: b319989339
Ref: library/os os fchmod9989990
Ref: 1fd9989990
Ref: library/os os fchown9990681
Ref: d579990681
Ref: library/os os fdatasync9991398
Ref: d589991398
Ref: library/os os fpathconf9991706
Ref: 2a9a9991706
Ref: library/os os fstat9992932
Ref: d599992932
Ref: library/os os fstatvfs9993218
Ref: d5a9993218
Ref: library/os os fsync9993560
Ref: d5b9993560
Ref: library/os os ftruncate9994148
Ref: d5c9994148
Ref: library/os os get_blocking9994681
Ref: e069994681
Ref: library/os os grantpt9995394
Ref: 15e79995394
Ref: library/os os isatty9995779
Ref: 17fb9995779
Ref: library/os os lockf9996041
Ref: 10e69996041
Ref: library/os os F_LOCK9996755
Ref: 2a9c9996755
Ref: library/os os F_TLOCK9996780
Ref: 2a9d9996780
Ref: library/os os F_ULOCK9996806
Ref: 2a9e9996806
Ref: library/os os F_TEST9996832
Ref: 2a9f9996832
Ref: library/os os login_tty9997001
Ref: 16c49997001
Ref: library/os os lseek9997361
Ref: 10ea9997361
Ref: library/os os SEEK_SET9998211
Ref: 125e9998211
Ref: library/os os SEEK_CUR9998238
Ref: 125f9998238
Ref: library/os os SEEK_END9998265
Ref: 12609998265
Ref: library/os os SEEK_HOLE9998849
Ref: 2aa09998849
Ref: library/os os SEEK_DATA9998877
Ref: 2aa19998877
Ref: library/os os open9999609
Ref: d5f9999609
Ref: library/os os O_RDONLY10002418
Ref: 2aa210002418
Ref: library/os os O_WRONLY10002445
Ref: 2aa310002445
Ref: library/os os O_RDWR10002472
Ref: 2aa510002472
Ref: library/os os O_APPEND10002497
Ref: 2aa610002497
Ref: library/os os O_CREAT10002524
Ref: 2aa710002524
Ref: library/os os O_EXCL10002550
Ref: 27aa10002550
Ref: library/os os O_TRUNC10002575
Ref: 2aa810002575
Ref: library/os os O_DSYNC10002675
Ref: 2aa910002675
Ref: library/os os O_RSYNC10002701
Ref: 2aaa10002701
Ref: library/os os O_SYNC10002727
Ref: 2aab10002727
Ref: library/os os O_NDELAY10002752
Ref: 2aac10002752
Ref: library/os os O_NONBLOCK10002779
Ref: e0810002779
Ref: library/os os O_NOCTTY10002808
Ref: 2aad10002808
Ref: library/os os O_CLOEXEC10002835
Ref: 105110002835
Ref: library/os os O_BINARY10003026
Ref: 2aa410003026
Ref: library/os os O_NOINHERIT10003053
Ref: 2aae10003053
Ref: library/os os O_SHORT_LIVED10003083
Ref: 2aaf10003083
Ref: library/os os O_TEMPORARY10003115
Ref: 2ab010003115
Ref: library/os os O_RANDOM10003145
Ref: 2ab110003145
Ref: library/os os O_SEQUENTIAL10003172
Ref: 2ab210003172
Ref: library/os os O_TEXT10003203
Ref: 2ab310003203
Ref: library/os os O_EVTONLY10003293
Ref: 7e510003293
Ref: library/os os O_FSYNC10003321
Ref: 7e610003321
Ref: library/os os O_SYMLINK10003347
Ref: 7e710003347
Ref: library/os os O_NOFOLLOW_ANY10003375
Ref: 7e810003375
Ref: library/os os O_ASYNC10003629
Ref: 2ab410003629
Ref: library/os os O_DIRECT10003655
Ref: 2ab510003655
Ref: library/os os O_DIRECTORY10003682
Ref: 2ab610003682
Ref: library/os os O_NOFOLLOW10003712
Ref: 2ab710003712
Ref: library/os os O_NOATIME10003741
Ref: 2ab810003741
Ref: library/os os O_PATH10003769
Ref: f3f10003769
Ref: library/os os O_TMPFILE10003794
Ref: f4010003794
Ref: library/os os O_SHLOCK10003822
Ref: 13d610003822
Ref: library/os os O_EXLOCK10003849
Ref: 13d710003849
Ref: library/os os openpty10004255
Ref: 2ab910004255
Ref: library/os os pipe10004769
Ref: 174510004769
Ref: library/os os pipe210005180
Ref: 10bc10005180
Ref: library/os os posix_fallocate10005617
Ref: d6110005617
Ref: library/os os posix_fadvise10005919
Ref: d6010005919
Ref: library/os os POSIX_FADV_NORMAL10006663
Ref: 2aba10006663
Ref: library/os os POSIX_FADV_SEQUENTIAL10006699
Ref: 2abb10006699
Ref: library/os os POSIX_FADV_RANDOM10006739
Ref: 2abc10006739
Ref: library/os os POSIX_FADV_NOREUSE10006775
Ref: 2abd10006775
Ref: library/os os POSIX_FADV_WILLNEED10006812
Ref: 2abe10006812
Ref: library/os os POSIX_FADV_DONTNEED10006850
Ref: 2abf10006850
Ref: library/os os pread10007121
Ref: b2d10007121
Ref: library/os os posix_openpt10007570
Ref: 15e610007570
Ref: library/os os preadv10008168
Ref: b2b10008168
Ref: library/os os RWF_NOWAIT10009505
Ref: 2ac110009505
Ref: library/os os RWF_HIPRI10010078
Ref: 2ac010010078
Ref: library/os os ptsname10010634
Ref: 15e910010634
Ref: library/os os pwrite10011177
Ref: b3010011177
Ref: library/os os pwritev10011525
Ref: b2e10011525
Ref: library/os os RWF_DSYNC10012702
Ref: 2ac310012702
Ref: library/os os RWF_SYNC10013068
Ref: 2ac410013068
Ref: library/os os RWF_APPEND10013432
Ref: 18b010013432
Ref: library/os os read10013994
Ref: d6210013994
Ref: library/os os sendfile10015219
Ref: add10015219
Ref: library/os os SF_NODISKIO10017226
Ref: 2ac510017226
Ref: library/os os SF_MNOWAIT10017256
Ref: 2ac610017256
Ref: library/os os SF_SYNC10017285
Ref: 2ac710017285
Ref: library/os os SF_NOCACHE10017507
Ref: 2ac810017507
Ref: library/os os set_blocking10017794
Ref: e0710017794
Ref: library/os os splice10018530
Ref: 7e410018530
Ref: library/os os SPLICE_F_MOVE10020080
Ref: 2ac910020080
Ref: library/os os SPLICE_F_NONBLOCK10020112
Ref: 2aca10020112
Ref: library/os os SPLICE_F_MORE10020148
Ref: 2acb10020148
Ref: library/os os readv10020210
Ref: b2c10020210
Ref: library/os os tcgetpgrp10020967
Ref: 2acc10020967
Ref: library/os os tcsetpgrp10021235
Ref: 2acd10021235
Ref: library/os os ttyname10021519
Ref: 2ace10021519
Ref: library/os os unlockpt10021816
Ref: 15e810021816
Ref: library/os os write10022193
Ref: d6810022193
Ref: library/os os writev10023306
Ref: b2f10023306
Ref: ファイル記述子の操作-Footnote-110024210
Ref: ファイル記述子の操作-Footnote-210024252
Ref: ファイル記述子の操作-Footnote-310024296
Ref: ファイル記述子の操作-Footnote-410024359
Ref: ファイル記述子の操作-Footnote-510024401
Node: ターミナルのサイズの問い合わせ10024443
Ref: library/os querying-the-size-of-a-terminal10024594
Ref: 2acf10024594
Ref: library/os terminal-size10024594
Ref: 2ad010024594
Ref: library/os os get_terminal_size10024713
Ref: 10d510024713
Ref: library/os os terminal_size10025432
Ref: 27d310025432
Ref: library/os os terminal_size columns10025595
Ref: 2ad110025595
Ref: library/os os terminal_size lines10025697
Ref: 2ad210025697
Node: ファイル記述子の継承10025797
Ref: library/os fd-inheritance10025948
Ref: ec410025948
Ref: library/os inheritance-of-file-descriptors10025948
Ref: 2ad310025948
Ref: library/os os get_inheritable10027366
Ref: ec510027366
Ref: library/os os set_inheritable10027530
Ref: ec610027530
Ref: library/os os get_handle_inheritable10027700
Ref: ec710027700
Ref: library/os os set_handle_inheritable10027907
Ref: ec810027907
Node: ファイルとディレクトリ10028115
Ref: library/os files-and-directories10028327
Ref: 2ad410028327
Ref: library/os os-file-dir10028327
Ref: 2a6610028327
Ref: library/os path-fd10028554
Ref: b2a10028554
Ref: library/os dir-fd10029852
Ref: 10c810029852
Ref: library/os follow-symlinks10030874
Ref: 10c910030874
Ref: library/os os access10031616
Ref: 10bd10031616
Ref: library/os os F_OK10035112
Ref: 2ad510035112
Ref: library/os os R_OK10035135
Ref: 2ad610035135
Ref: library/os os W_OK10035158
Ref: 2ad710035158
Ref: library/os os X_OK10035181
Ref: 2ad810035181
Ref: library/os os chdir10035445
Ref: 5d810035445
Ref: library/os os chflags10036433
Ref: 10be10036433
Ref: library/os os chmod10037715
Ref: 1fc10037715
Ref: library/os os chown10040060
Ref: 10bf10040060
Ref: library/os os chroot10041373
Ref: 18fe10041373
Ref: library/os os fchdir10041676
Ref: d5610041676
Ref: library/os os getcwd10042204
Ref: 150310042204
Ref: library/os os getcwdb10042309
Ref: a5f10042309
Ref: library/os os lchflags10042745
Ref: 2ada10042745
Ref: library/os os lchmod10043352
Ref: 1fb10043352
Ref: library/os os lchown10044399
Ref: 2adb10044399
Ref: library/os os link10045039
Ref: 10c010045039
Ref: library/os os listdir10046021
Ref: 10cd10046021
Ref: library/os os listdrives10047960
Ref: 46a10047960
Ref: library/os os listmounts10048594
Ref: 46c10048594
Ref: library/os os listvolumes10049436
Ref: 46b10049436
Ref: library/os os lstat10050157
Ref: 46e10050157
Ref: library/os os mkdir10051445
Ref: 1fe10051445
Ref: library/os mkdir-modebits10051763
Ref: 2adc10051763
Ref: library/os os makedirs10053302
Ref: 1ff10053302
Ref: library/os os mkfifo10055435
Ref: d5d10055435
Ref: library/os os mknod10056673
Ref: d5e10056673
Ref: library/os os major10057911
Ref: 157e10057911
Ref: library/os os minor10058083
Ref: 157f10058083
Ref: library/os os makedev10058255
Ref: 158010058255
Ref: library/os os pathconf10058426
Ref: 10ce10058426
Ref: library/os os pathconf_names10059759
Ref: 2ade10059759
Ref: library/os os readlink10060186
Ref: 8ee10060186
Ref: library/os os remove10061906
Ref: 10c110061906
Ref: library/os os removedirs10063026
Ref: 2adf10063026
Ref: library/os os rename10064162
Ref: 10c210064162
Ref: library/os os renames10065996
Ref: 2ae010065996
Ref: library/os os replace10066949
Ref: 10c310066949
Ref: library/os os rmdir10068124
Ref: 10c410068124
Ref: library/os os scandir10068892
Ref: a2d10068892
Ref: library/os os scandir close10071116
Ref: c8a10071116
Ref: library/os os DirEntry10072924
Ref: 46810072924
Ref: library/os os DirEntry name10074508
Ref: 2ae210074508
Ref: library/os os DirEntry path10074911
Ref: 15e010074911
Ref: library/os os DirEntry inode10075644
Ref: 163f10075644
Ref: library/os os DirEntry is_dir10076145
Ref: 2ae110076145
Ref: library/os os DirEntry is_file10078267
Ref: d5110078267
Ref: library/os os DirEntry is_symlink10079267
Ref: 2ae310079267
Ref: library/os os DirEntry is_junction10080483
Ref: 46910080483
Ref: library/os os DirEntry stat10080922
Ref: 165f10080922
Ref: library/os os stat10083015
Ref: 46d10083015
Ref: library/os os stat_result10085835
Ref: 146610085835
Ref: library/os os stat_result st_mode10086085
Ref: 2ae410086085
Ref: library/os os stat_result st_ino10086234
Ref: 2ae510086234
Ref: library/os os stat_result st_dev10086483
Ref: 2ae610086483
Ref: library/os os stat_result st_nlink10086583
Ref: 2ae710086583
Ref: library/os os stat_result st_uid10086652
Ref: 2ae810086652
Ref: library/os os stat_result st_gid10086737
Ref: 2ae910086737
Ref: library/os os stat_result st_size10086825
Ref: 2aea10086825
Ref: library/os os stat_result st_atime10087206
Ref: 2aeb10087206
Ref: library/os os stat_result st_mtime10087290
Ref: 297c10087290
Ref: library/os os stat_result st_ctime10087374
Ref: 2aec10087374
Ref: library/os os stat_result st_atime_ns10087751
Ref: 2aed10087751
Ref: library/os os stat_result st_mtime_ns10087887
Ref: 2aee10087887
Ref: library/os os stat_result st_ctime_ns10088023
Ref: 2aef10088023
Ref: library/os os stat_result st_birthtime10088470
Ref: 2af010088470
Ref: library/os os stat_result st_birthtime_ns10088752
Ref: 2af110088752
Ref: library/os os stat_result st_blocks10090370
Ref: 2af210090370
Ref: library/os os stat_result st_blksize10090661
Ref: 2af310090661
Ref: library/os os stat_result st_rdev10090993
Ref: 2af410090993
Ref: library/os os stat_result st_flags10091082
Ref: 2af510091082
Ref: library/os os stat_result st_gen10091386
Ref: 2af610091386
Ref: library/os os stat_result st_fstype10091537
Ref: b3210091537
Ref: library/os os stat_result st_rsize10091744
Ref: 2af710091744
Ref: library/os os stat_result st_creator10091819
Ref: 2af810091819
Ref: library/os os stat_result st_type10091887
Ref: 2af910091887
Ref: library/os os stat_result st_file_attributes10092020
Ref: e0510092020
Ref: library/os os stat_result st_reparse_tag10092400
Ref: 2afa10092400
Ref: library/os os statvfs10094814
Ref: 10cf10094814
Ref: library/os os supports_dir_fd10097394
Ref: 10ca10097394
Ref: library/os os supports_effective_ids10098600
Ref: 10d110098600
Ref: library/os os supports_fd10099391
Ref: 10d010099391
Ref: library/os os supports_follow_symlinks10100220
Ref: 10cb10100220
Ref: library/os os symlink10101357
Ref: 10c510101357
Ref: library/os os sync10103660
Ref: 10e510103660
Ref: library/os os truncate10103842
Ref: e0910103842
Ref: library/os os unlink10104520
Ref: 10c610104520
Ref: library/os os utime10105154
Ref: 10c710105154
Ref: library/os os walk10107644
Ref: 47610107644
Ref: library/os os fwalk10114191
Ref: b2910114191
Ref: library/os os memfd_create10117164
Ref: 9d910117164
Ref: library/os os MFD_CLOEXEC10118024
Ref: 2afb10118024
Ref: library/os os MFD_ALLOW_SEALING10118054
Ref: 2afc10118054
Ref: library/os os MFD_HUGETLB10118090
Ref: 2afd10118090
Ref: library/os os MFD_HUGE_SHIFT10118120
Ref: 2afe10118120
Ref: library/os os MFD_HUGE_MASK10118153
Ref: 2aff10118153
Ref: library/os os MFD_HUGE_64KB10118185
Ref: 2b0010118185
Ref: library/os os MFD_HUGE_512KB10118217
Ref: 2b0110118217
Ref: library/os os MFD_HUGE_1MB10118250
Ref: 2b0210118250
Ref: library/os os MFD_HUGE_2MB10118281
Ref: 2b0310118281
Ref: library/os os MFD_HUGE_8MB10118312
Ref: 2b0410118312
Ref: library/os os MFD_HUGE_16MB10118343
Ref: 2b0510118343
Ref: library/os os MFD_HUGE_32MB10118375
Ref: 2b0610118375
Ref: library/os os MFD_HUGE_256MB10118407
Ref: 2b0710118407
Ref: library/os os MFD_HUGE_512MB10118440
Ref: 2b0810118440
Ref: library/os os MFD_HUGE_1GB10118473
Ref: 2b0910118473
Ref: library/os os MFD_HUGE_2GB10118504
Ref: 2b0a10118504
Ref: library/os os MFD_HUGE_16GB10118535
Ref: 2b0b10118535
Ref: library/os os eventfd10118793
Ref: 7e310118793
Ref: library/os os eventfd_read10120833
Ref: 2b0d10120833
Ref: library/os os eventfd_write10121123
Ref: 2b0e10121123
Ref: library/os os EFD_CLOEXEC10121425
Ref: 173910121425
Ref: library/os os EFD_NONBLOCK10121615
Ref: 173a10121615
Ref: library/os os EFD_SEMAPHORE10121822
Ref: 173b10121822
Ref: ファイルとディレクトリ-Footnote-110122188
Ref: ファイルとディレクトリ-Footnote-210122234
Ref: ファイルとディレクトリ-Footnote-310122276
Ref: ファイルとディレクトリ-Footnote-410122341
Ref: ファイルとディレクトリ-Footnote-510122421
Ref: ファイルとディレクトリ-Footnote-610122503
Ref: ファイルとディレクトリ-Footnote-710122592
Ref: ファイルとディレクトリ-Footnote-810122681
Ref: ファイルとディレクトリ-Footnote-910122739
Node: Timer File Descriptors10122786
Ref: library/os os-timerfd10122905
Ref: 13910122905
Ref: library/os timer-file-descriptors10122905
Ref: 2b0f10122905
Ref: library/os os timerfd_create10123117
Ref: 1f210123117
Ref: library/os os timerfd_settime10125790
Ref: 1f310125790
Ref: library/os os timerfd_settime_ns10128487
Ref: 1f410128487
Ref: library/os os timerfd_gettime10128841
Ref: 1f510128841
Ref: library/os os timerfd_gettime_ns10129426
Ref: 1f610129426
Ref: library/os os TFD_NONBLOCK10129652
Ref: 1f710129652
Ref: library/os os TFD_CLOEXEC10130018
Ref: 1f810130018
Ref: library/os os TFD_TIMER_ABSTIME10130308
Ref: 1f910130308
Ref: library/os os TFD_TIMER_CANCEL_ON_SET10130698
Ref: 1fa10130698
Ref: Timer File Descriptors-Footnote-110131114
Ref: Timer File Descriptors-Footnote-210131168
Ref: Timer File Descriptors-Footnote-310131222
Ref: Timer File Descriptors-Footnote-410131277
Ref: Timer File Descriptors-Footnote-510131329
Ref: Timer File Descriptors-Footnote-610131382
Ref: Timer File Descriptors-Footnote-710131426
Node: Linux 拡張属性10131481
Ref: library/os linux-extended-attributes10131600
Ref: 2b1110131600
Ref: library/os os getxattr10131744
Ref: 10d710131744
Ref: library/os os listxattr10132526
Ref: 10d810132526
Ref: library/os os removexattr10133342
Ref: 10d910133342
Ref: library/os os setxattr10134155
Ref: 10da10134155
Ref: library/os os XATTR_SIZE_MAX10135546
Ref: 2b1410135546
Ref: library/os os XATTR_CREATE10135696
Ref: 2b1310135696
Ref: library/os os XATTR_REPLACE10135895
Ref: 2b1210135895
Node: プロセス管理10136107
Ref: library/os os-process10136340
Ref: 2b1510136340
Ref: library/os process-management10136340
Ref: 2b1610136340
Ref: library/os os abort10137184
Ref: 2b1810137184
Ref: library/os os add_dll_directory10137683
Ref: 9b810137683
Ref: library/os os execl10138872
Ref: 2b1710138872
Ref: library/os os execle10138920
Ref: 2b1910138920
Ref: library/os os execlp10138974
Ref: 2b1a10138974
Ref: library/os os execlpe10139023
Ref: 2b1b10139023
Ref: library/os os execv10139078
Ref: 2a7710139078
Ref: library/os os execve10139115
Ref: 10cc10139115
Ref: library/os os execvp10139158
Ref: 2b1c10139158
Ref: library/os os execvpe10139196
Ref: 2b1d10139196
Ref: library/os os _exit10143170
Ref: 21f410143170
Ref: library/os os EX_OK10144158
Ref: 2b1e10144158
Ref: library/os os EX_USAGE10144397
Ref: 2b1f10144397
Ref: library/os os EX_DATAERR10144610
Ref: 2b2010144610
Ref: library/os os EX_NOINPUT10144762
Ref: 2b2110144762
Ref: library/os os EX_NOUSER10144971
Ref: 2b2210144971
Ref: library/os os EX_NOHOST10145140
Ref: 2b2310145140
Ref: library/os os EX_UNAVAILABLE10145306
Ref: 2b2410145306
Ref: library/os os EX_SOFTWARE10145477
Ref: 2b2510145477
Ref: library/os os EX_OSERR10145648
Ref: 2b2610145648
Ref: library/os os EX_OSFILE10145896
Ref: 2b2710145896
Ref: library/os os EX_CANTCREAT10146137
Ref: 2b2810146137
Ref: library/os os EX_IOERR10146333
Ref: 2b2910146333
Ref: library/os os EX_TEMPFAIL10146512
Ref: 2b2a10146512
Ref: library/os os EX_PROTOCOL10146866
Ref: 2b2b10146866
Ref: library/os os EX_NOPERM10147061
Ref: 2b2c10147061
Ref: library/os os EX_CONFIG10147287
Ref: 2b2d10147287
Ref: library/os os EX_NOTFOUND10147435
Ref: 2b2e10147435
Ref: library/os os fork10147592
Ref: 17c10147592
Ref: library/os os forkpty10149786
Ref: 17d10149786
Ref: library/os os kill10151023
Ref: 132f10151023
Ref: library/os os killpg10152035
Ref: 194110152035
Ref: library/os os nice10152339
Ref: 10d410152339
Ref: library/os os pidfd_open10152538
Ref: 44710152538
Ref: library/os os PIDFD_NONBLOCK10152950
Ref: 46710152950
Ref: library/os os plock10153406
Ref: 2b2f10153406
Ref: library/os os popen10153712
Ref: a5510153712
Ref: library/os os posix_spawn10156107
Ref: 20110156107
Ref: library/os os POSIX_SPAWN_OPEN10157463
Ref: 2b3010157463
Ref: library/os os POSIX_SPAWN_CLOSE10157653
Ref: 2b3110157653
Ref: library/os os POSIX_SPAWN_DUP210157793
Ref: 2b3210157793
Ref: library/os os POSIX_SPAWN_CLOSEFROM10157948
Ref: 20210157948
Ref: library/os os posix_spawnp10160883
Ref: 199a10160883
Ref: library/os os register_at_fork10161666
Ref: 2d710161666
Ref: library/os os spawnl10163116
Ref: 169910163116
Ref: library/os os spawnle10163159
Ref: 2b3310163159
Ref: library/os os spawnlp10163208
Ref: 2b3410163208
Ref: library/os os spawnlpe10163252
Ref: 2b3510163252
Ref: library/os os spawnv10163302
Ref: 2b3610163302
Ref: library/os os spawnve10163346
Ref: 2b3710163346
Ref: library/os os spawnvp10163396
Ref: 2b3810163396
Ref: library/os os spawnvpe10163441
Ref: 2b3910163441
Ref: library/os os P_NOWAIT10167914
Ref: 2b3a10167914
Ref: library/os os P_NOWAITO10167941
Ref: 2b3c10167941
Ref: library/os os P_WAIT10168297
Ref: 2b3b10168297
Ref: library/os os P_DETACH10168724
Ref: 2b3d10168724
Ref: library/os os P_OVERLAY10168751
Ref: 2b3e10168751
Ref: library/os os startfile10169377
Ref: 183610169377
Ref: library/os os system10172044
Ref: 140210172044
Ref: library/os os times10174089
Ref: 10e810174089
Ref: library/os os wait10175232
Ref: d6510175232
Ref: library/os os waitid10176314
Ref: d6610176314
Ref: library/os os waitpid10177759
Ref: d6710177759
Ref: library/os os wait310180677
Ref: d6310180677
Ref: library/os os wait410181422
Ref: d6410181422
Ref: library/os os P_PID10182114
Ref: 2b3f10182114
Ref: library/os os P_PGID10182138
Ref: 2b4010182138
Ref: library/os os P_ALL10182163
Ref: 2b4110182163
Ref: library/os os P_PIDFD10182187
Ref: 8e810182187
Ref: library/os os WCONTINUED10182952
Ref: 2b4410182952
Ref: library/os os WEXITED10183306
Ref: 2b4210183306
Ref: library/os os WSTOPPED10183678
Ref: 2b4310183678
Ref: library/os os WUNTRACED10184023
Ref: 2b4910184023
Ref: library/os os WNOHANG10184434
Ref: 2b4510184434
Ref: library/os os WNOWAIT10184736
Ref: 2b4610184736
Ref: library/os os CLD_EXITED10185105
Ref: 2b4810185105
Ref: library/os os CLD_KILLED10185134
Ref: 8e610185134
Ref: library/os os CLD_DUMPED10185163
Ref: 2b4a10185163
Ref: library/os os CLD_TRAPPED10185192
Ref: 2b4b10185192
Ref: library/os os CLD_STOPPED10185222
Ref: 8e710185222
Ref: library/os os CLD_CONTINUED10185252
Ref: 2b4c10185252
Ref: library/os os waitstatus_to_exitcode10185596
Ref: 8eb10185596
Ref: library/os os WCOREDUMP10187449
Ref: 2b5310187449
Ref: library/os os WIFCONTINUED10187835
Ref: 2b5410187835
Ref: library/os os WIFSTOPPED10188220
Ref: 2b5110188220
Ref: library/os os WIFSIGNALED10188805
Ref: 2b4f10188805
Ref: library/os os WIFEXITED10189083
Ref: 2b4d10189083
Ref: library/os os WEXITSTATUS10189471
Ref: 2b4e10189471
Ref: library/os os WSTOPSIG10189754
Ref: 2b5210189754
Ref: library/os os WTERMSIG10190047
Ref: 2b5010190047
Ref: プロセス管理-Footnote-110190380
Ref: プロセス管理-Footnote-210190452
Ref: プロセス管理-Footnote-310190495
Ref: プロセス管理-Footnote-410190545
Ref: プロセス管理-Footnote-510190591
Ref: プロセス管理-Footnote-610190636
Ref: プロセス管理-Footnote-710190688
Ref: プロセス管理-Footnote-810190797
Ref: プロセス管理-Footnote-910190839
Node: スケジューラーへのインターフェイス10190885
Ref: library/os interface-to-the-scheduler10191112
Ref: 2b5610191112
Ref: library/os os SCHED_OTHER10191672
Ref: 2b5710191672
Ref: library/os os SCHED_BATCH10191773
Ref: 2b5810191773
Ref: library/os os SCHED_IDLE10191984
Ref: 2b5910191984
Ref: library/os os SCHED_SPORADIC10192138
Ref: 2b5a10192138
Ref: library/os os SCHED_FIFO10192269
Ref: 2b5b10192269
Ref: library/os os SCHED_RR10192384
Ref: 2b5c10192384
Ref: library/os os SCHED_RESET_ON_FORK10192491
Ref: 2b5d10192491
Ref: library/os os sched_param10192852
Ref: 150910192852
Ref: library/os os sched_param sched_priority10193244
Ref: 2b5e10193244
Ref: library/os os sched_get_priority_min10193373
Ref: 10dc10193373
Ref: library/os os sched_get_priority_max10193584
Ref: 10db10193584
Ref: library/os os sched_setscheduler10193795
Ref: 10e310193795
Ref: library/os os sched_getscheduler10194197
Ref: 10df10194197
Ref: library/os os sched_setparam10194503
Ref: 10e210194503
Ref: library/os os sched_getparam10194802
Ref: 10de10194802
Ref: library/os os sched_rr_get_interval10195076
Ref: 10e010195076
Ref: library/os os sched_yield10195297
Ref: 10e410195297
Ref: library/os os sched_setaffinity10195376
Ref: 10e110195376
Ref: library/os os sched_getaffinity10195663
Ref: 10dd10195663
Node: 雑多なシステム情報10195956
Ref: library/os miscellaneous-system-information10196174
Ref: 2b5f10196174
Ref: library/os os-path10196174
Ref: 2b6010196174
Ref: library/os os confstr10196242
Ref: 2b6110196242
Ref: library/os os confstr_names10197408
Ref: 2b6210197408
Ref: library/os os cpu_count10197783
Ref: 1a710197783
Ref: library/os os getloadavg10198287
Ref: 154910198287
Ref: library/os os process_cpu_count10198582
Ref: 1a610198582
Ref: library/os os sysconf10199198
Ref: 2ac210199198
Ref: library/os os sysconf_names10199693
Ref: 2b6310199693
Ref: library/os os curdir10200432
Ref: 272b10200432
Ref: library/os os pardir10200703
Ref: 2add10200703
Ref: library/os os sep10200972
Ref: 63610200972
Ref: library/os os altsep10201592
Ref: 63710201592
Ref: library/os os extsep10202044
Ref: 2b6410202044
Ref: library/os os pathsep10202256
Ref: 1cae10202256
Ref: library/os os defpath10202609
Ref: 196d10202609
Ref: library/os os linesep10202879
Ref: 20df10202879
Ref: library/os os devnull10203504
Ref: 199e10203504
Ref: library/os os RTLD_LAZY10203744
Ref: 10eb10203744
Ref: library/os os RTLD_NOW10203772
Ref: 10ec10203772
Ref: library/os os RTLD_GLOBAL10203799
Ref: 10ed10203799
Ref: library/os os RTLD_LOCAL10203829
Ref: 10ee10203829
Ref: library/os os RTLD_NODELETE10203858
Ref: 10ef10203858
Ref: library/os os RTLD_NOLOAD10203890
Ref: 10f010203890
Ref: library/os os RTLD_DEEPBIND10203920
Ref: 10f110203920
Ref: 雑多なシステム情報-Footnote-110204279
Node: 乱数<2>10204325
Ref: library/os random-numbers10204483
Ref: 2b6510204483
Ref: library/os os getrandom10204516
Ref: c8b10204516
Ref: library/os os urandom10205536
Ref: 4ec10205536
Ref: library/os os GRND_NONBLOCK10208487
Ref: 2b6710208487
Ref: library/os os GRND_RANDOM10209104
Ref: 2b6610209104
Ref: 乱数<2>-Footnote-110209384
Ref: 乱数<2>-Footnote-210209447
Node: io --- ストリームを扱うコアツール10209489
Ref: library/io doc10209771
Ref: 2b6810209771
Ref: library/io io-core-tools-for-working-with-streams10209771
Ref: 2b6910209771
Ref: library/io module-io10209771
Ref: 7310209771
Ref: io --- ストリームを扱うコアツール-Footnote-110210159
Node: 概要<2>10210221
Ref: library/io io-overview10210335
Ref: 20dd10210335
Ref: library/io overview10210335
Ref: 2b6a10210335
Node: テキスト I/O10211988
Ref: library/io text-i-o10212075
Ref: 2b6b10212075
Node: バイナリ I/O10212921
Ref: library/io binary-i-o10213024
Ref: 2b6c10213024
Node: Raw I/O10214122
Ref: library/io raw-i-o10214200
Ref: 2b6d10214200
Node: Text Encoding10214828
Ref: library/io io-text-encoding10215002
Ref: 78810215002
Ref: library/io text-encoding10215002
Ref: 2b6e10215002
Ref: Text Encoding-Footnote-110216170
Node: Opt-in EncodingWarning10216212
Ref: library/io io-encoding-warning10216284
Ref: 1cbf10216284
Ref: library/io opt-in-encodingwarning10216284
Ref: 2b6f10216284
Ref: Opt-in EncodingWarning-Footnote-110217100
Node: 高水準のモジュールインターフェイス10217142
Ref: library/io high-level-module-interface10217322
Ref: 2b7010217322
Ref: library/io io DEFAULT_BUFFER_SIZE10217428
Ref: 162d10217428
Ref: library/io io open10217741
Ref: 4e610217741
Ref: library/io io open_code10218170
Ref: 168e10218170
Ref: library/io io text_encoding10218869
Ref: 162c10218869
Ref: library/io io BlockingIOError10220007
Ref: 2b7110220007
Ref: library/io io UnsupportedOperation10220154
Ref: 190110220154
Node: クラス階層10220539
Ref: library/io class-hierarchy10220715
Ref: 2b7210220715
Node: I/O 基底クラス10226117
Ref: library/io i-o-base-classes10226215
Ref: 2b7410226215
Ref: library/io io IOBase10226269
Ref: 1d610226269
Ref: library/io io IOBase close10228578
Ref: 1d710228578
Ref: library/io io IOBase closed10229179
Ref: 199710229179
Ref: library/io io IOBase fileno10229294
Ref: 27a610229294
Ref: library/io io IOBase flush10229604
Ref: 2b7510229604
Ref: library/io io IOBase isatty10229840
Ref: 1bec10229840
Ref: library/io io IOBase readable10230043
Ref: 2b7610230043
Ref: library/io io IOBase readline10230211
Ref: 12f810230211
Ref: library/io io IOBase readlines10230700
Ref: 228f10230700
Ref: library/io io IOBase seek10231433
Ref: 125d10231433
Ref: library/io io IOBase seekable10232413
Ref: 2b7710232413
Ref: library/io io IOBase tell10232759
Ref: 290710232759
Ref: library/io io IOBase truncate10232851
Ref: 12e010232851
Ref: library/io io IOBase writable10233694
Ref: 2b7810233694
Ref: library/io io IOBase writelines10233901
Ref: 229010233901
Ref: library/io io IOBase __del__10234173
Ref: 2b7910234173
Ref: library/io io RawIOBase10234471
Ref: 10a310234471
Ref: library/io io RawIOBase read10235136
Ref: de910235136
Ref: library/io io RawIOBase readall10236133
Ref: 2b7a10236133
Ref: library/io io RawIOBase readinto10236348
Ref: dea10236348
Ref: library/io io RawIOBase write10236805
Ref: 294610236805
Ref: library/io io BufferedIOBase10237639
Ref: 66010237639
Ref: library/io io BufferedIOBase raw10239122
Ref: 2b7c10239122
Ref: library/io io BufferedIOBase detach10239435
Ref: 28ce10239435
Ref: library/io io BufferedIOBase read10239971
Ref: 12f710239971
Ref: library/io io BufferedIOBase read110241033
Ref: 28be10241033
Ref: library/io io BufferedIOBase readinto10241674
Ref: 2b7b10241674
Ref: library/io io BufferedIOBase readinto110242422
Ref: de810242422
Ref: library/io io BufferedIOBase write10243077
Ref: ca910243077
Node: 生ファイルI/O10244232
Ref: library/io raw-file-i-o10244372
Ref: 2b7d10244372
Ref: library/io io FileIO10244426
Ref: 12df10244426
Ref: library/io io FileIO mode10247325
Ref: 2b7e10247325
Ref: library/io io FileIO name10247417
Ref: 28d810247417
Node: バッファ付きストリーム10247586
Ref: library/io buffered-streams10247726
Ref: 2b7f10247726
Ref: library/io io BytesIO10247944
Ref: e6d10247944
Ref: library/io io BytesIO getbuffer10248515
Ref: 11c210248515
Ref: library/io io BytesIO getvalue10249206
Ref: 28bc10249206
Ref: library/io io BytesIO read110249324
Ref: 2b8010249324
Ref: library/io io BytesIO readinto110249573
Ref: 2b8110249573
Ref: library/io io BufferedReader10249771
Ref: 11df10249771
Ref: library/io io BufferedReader peek10250916
Ref: 2b8210250916
Ref: library/io io BufferedReader read10251287
Ref: 2b8310251287
Ref: library/io io BufferedReader read110251588
Ref: 2b8410251588
Ref: library/io io BufferedWriter10252096
Ref: 20e010252096
Ref: library/io io BufferedWriter flush10253500
Ref: 2b8510253500
Ref: library/io io BufferedWriter write10253764
Ref: 2b8610253764
Ref: library/io io BufferedRandom10254131
Ref: 20e110254131
Ref: library/io io BufferedRWPair10254945
Ref: 2b7310254945
Node: テキスト I/O<2>10256058
Ref: library/io id110256171
Ref: 2b8710256171
Ref: library/io io TextIOBase10256222
Ref: 66110256222
Ref: library/io io TextIOBase encoding10256582
Ref: 2b8810256582
Ref: library/io io TextIOBase errors10256821
Ref: 12de10256821
Ref: library/io io TextIOBase newlines10256924
Ref: 2b8910256924
Ref: library/io io TextIOBase buffer10257234
Ref: 127410257234
Ref: library/io io TextIOBase detach10257543
Ref: 2b8a10257543
Ref: library/io io TextIOBase read10258121
Ref: 1bef10258121
Ref: library/io io TextIOBase readline10258383
Ref: 1c2710258383
Ref: library/io io TextIOBase seek10258667
Ref: 2b8b10258667
Ref: library/io io TextIOBase tell10259652
Ref: 2b8c10259652
Ref: library/io io TextIOBase write10259878
Ref: 1bde10259878
Ref: library/io io TextIOWrapper10260033
Ref: 78610260033
Ref: library/io io TextIOWrapper line_buffering10264538
Ref: 2b8d10264538
Ref: library/io io TextIOWrapper write_through10264634
Ref: 2b8e10264634
Ref: library/io io TextIOWrapper reconfigure10264804
Ref: b1710264804
Ref: library/io io TextIOWrapper seek10265893
Ref: 2b8f10265893
Ref: library/io io TextIOWrapper tell10266814
Ref: 2b9010266814
Ref: library/io io StringIO10267043
Ref: ef310267043
Ref: library/io io StringIO getvalue10268374
Ref: 2b9110268374
Ref: library/io io IncrementalNewlineDecoder10269031
Ref: 162e10269031
Node: 性能<3>10269222
Ref: library/io performance10269338
Ref: 2b9210269338
Node: バイナリ I/O<2>10269667
Ref: library/io id210269760
Ref: 2b9310269760
Node: テキスト I/O<3>10270741
Ref: library/io id310270876
Ref: 2b9410270876
Node: マルチスレッディング<3>10271486
Ref: library/io multi-threading10271626
Ref: 2b9510271626
Ref: マルチスレッディング<3>-Footnote-110272350
Node: リエントラント性10272394
Ref: library/io reentrancy10272506
Ref: 2b9610272506
Node: time --- 時刻データへのアクセスと変換10273562
Ref: library/time doc10273838
Ref: 2b9710273838
Ref: library/time module-time10273838
Ref: d710273838
Ref: library/time time-time-access-and-conversions10273838
Ref: 2b9810273838
Ref: library/time epoch10274816
Ref: 297b10274816
Ref: time --- 時刻データへのアクセスと変換-Footnote-110280027
Node: 関数<5>10280077
Ref: library/time functions10280201
Ref: 2b9b10280201
Ref: library/time time-functions10280201
Ref: 2b9c10280201
Ref: library/time time asctime10280232
Ref: 11b810280232
Ref: library/time time pthread_getcpuclockid10280916
Ref: b6010280916
Ref: library/time time clock_getres10281558
Ref: 113010281558
Ref: library/time time clock_gettime10281880
Ref: 113110281880
Ref: library/time time clock_gettime_ns10282313
Ref: ab010282313
Ref: library/time time clock_settime10282542
Ref: 113210282542
Ref: library/time time clock_settime_ns10282969
Ref: ab110282969
Ref: library/time time ctime10283227
Ref: 23ac10283227
Ref: library/time time get_clock_info10283869
Ref: 112f10283869
Ref: library/time time gmtime10285247
Ref: 119010285247
Ref: library/time time localtime10285895
Ref: 14a210285895
Ref: library/time time mktime10286633
Ref: 11b910286633
Ref: library/time time monotonic10287344
Ref: 23410287344
Ref: library/time time monotonic_ns10288482
Ref: ab210288482
Ref: library/time time perf_counter10288657
Ref: a5610288657
Ref: library/time time perf_counter_ns10289597
Ref: ab310289597
Ref: library/time time process_time10289778
Ref: a5710289778
Ref: library/time time process_time_ns10290321
Ref: ab410290321
Ref: library/time time sleep10290502
Ref: 66910290502
Ref: library/time time strftime10292349
Ref: 11ba10292349
Ref: library/time leap-second10300456
Ref: 2b9e10300456
Ref: library/time time strptime10301929
Ref: 13d410301929
Ref: library/time time struct_time10304141
Ref: cb810304141
Ref: library/time time struct_time tm_year10304858
Ref: 14a110304858
Ref: library/time time struct_time tm_mon10305122
Ref: 2b9f10305122
Ref: library/time time struct_time tm_mday10305391
Ref: 2ba010305391
Ref: library/time time struct_time tm_hour10305659
Ref: 2ba110305659
Ref: library/time time struct_time tm_min10305926
Ref: 2ba210305926
Ref: library/time time struct_time tm_sec10306194
Ref: 2ba310306194
Ref: library/time time struct_time tm_wday10306673
Ref: 2ba410306673
Ref: library/time time struct_time tm_yday10306947
Ref: 2ba510306947
Ref: library/time time struct_time tm_isdst10307217
Ref: 23bd10307217
Ref: library/time time struct_time tm_zone10307599
Ref: 2b9a10307599
Ref: library/time time struct_time tm_gmtoff10307880
Ref: 2b9910307880
Ref: library/time time time10308758
Ref: 23510308758
Ref: library/time time time_ns10310308
Ref: ab510310308
Ref: library/time time thread_time10310520
Ref: 90410310520
Ref: library/time time thread_time_ns10311204
Ref: b5f10311204
Ref: library/time time tzset10311383
Ref: 2ba610311383
Ref: 関数<5>-Footnote-110316092
Ref: 関数<5>-Footnote-210316153
Ref: 関数<5>-Footnote-310316245
Ref: 関数<5>-Footnote-410316287
Ref: 関数<5>-Footnote-510317205
Ref: 関数<5>-Footnote-610318123
Ref: 関数<5>-Footnote-710318173
Ref: 関数<5>-Footnote-810318232
Ref: 関数<5>-Footnote-910319150
Ref: 関数<5>-Footnote-1010319198
Ref: 関数<5>-Footnote-1110319249
Ref: 関数<5>-Footnote-1210319298
Node: Clock ID Constants10319345
Ref: library/time clock-id-constants10319496
Ref: 2ba710319496
Ref: library/time time-clock-id-constants10319496
Ref: 2b1010319496
Ref: library/time time CLOCK_BOOTTIME10319658
Ref: b5c10319658
Ref: library/time time CLOCK_HIGHRES10320141
Ref: 2ba810320141
Ref: library/time time CLOCK_MONOTONIC10320518
Ref: 66510320518
Ref: library/time time CLOCK_MONOTONIC_RAW10320752
Ref: 2ba910320752
Ref: library/time time CLOCK_MONOTONIC_RAW_APPROX10321064
Ref: 2baa10321064
Ref: library/time time CLOCK_PROCESS_CPUTIME_ID10321331
Ref: 2bab10321331
Ref: library/time time CLOCK_PROF10321521
Ref: b5d10321521
Ref: library/time time CLOCK_TAI10321722
Ref: 18d710321722
Ref: library/time time CLOCK_THREAD_CPUTIME_ID10322022
Ref: 2bac10322022
Ref: library/time time CLOCK_UPTIME10322197
Ref: b5e10322197
Ref: library/time time CLOCK_UPTIME_RAW10322485
Ref: a1110322485
Ref: library/time time CLOCK_UPTIME_RAW_APPROX10322789
Ref: 2bad10322789
Ref: library/time time CLOCK_REALTIME10323143
Ref: 66610323143
Ref: Clock ID Constants-Footnote-110323427
Node: Timezone Constants10323534
Ref: library/time time-timezone-constants10323667
Ref: 2bae10323667
Ref: library/time timezone-constants10323667
Ref: 2baf10323667
Ref: library/time time altzone10323724
Ref: 2bb010323724
Ref: library/time time daylight10324170
Ref: 2bb110324170
Ref: library/time time timezone10324346
Ref: 2bb210324346
Ref: library/time time tzname10324713
Ref: 2bb310324713
Node: argparse --- Parser for command-line options arguments and subcommands10326208
Ref: library/argparse doc10326481
Ref: 2bb410326481
Ref: library/argparse argparse-parser-for-command-line-options-arguments-and-subcommands10326481
Ref: 2bb510326481
Ref: library/argparse module-argparse10326481
Ref: 510326481
Ref: argparse --- Parser for command-line options arguments and subcommands-Footnote-110329054
Node: ArgumentParser オブジェクト10329122
Ref: library/argparse argumentparser-objects10329296
Ref: 2bb910329296
Ref: library/argparse argparse ArgumentParser10329377
Ref: 50310329377
Node: prog10332604
Ref: library/argparse id110332692
Ref: 2bc610332692
Ref: library/argparse prog10332692
Ref: 2bba10332692
Node: usage10334251
Ref: library/argparse usage10334359
Ref: 2bbb10334359
Node: description10335119
Ref: library/argparse description10335229
Ref: 2bbc10335229
Ref: library/argparse id210335229
Ref: 2bc710335229
Node: epilog10335802
Ref: library/argparse epilog10335914
Ref: 2bbd10335914
Node: parents10336710
Ref: library/argparse parents10336826
Ref: 2bbe10336826
Node: formatter_class10338577
Ref: library/argparse formatter-class10338699
Ref: 2bbf10338699
Ref: library/argparse id310338699
Ref: 2bc810338699
Ref: library/argparse argparse RawDescriptionHelpFormatter10338990
Ref: 2bc910338990
Ref: library/argparse argparse RawTextHelpFormatter10339042
Ref: 2bca10339042
Ref: library/argparse argparse ArgumentDefaultsHelpFormatter10339087
Ref: 180610339087
Ref: library/argparse argparse MetavarTypeHelpFormatter10339141
Ref: 2bcb10339141
Node: prefix_chars10342620
Ref: library/argparse prefix-chars10342756
Ref: 2bc010342756
Node: fromfile_prefix_chars10343529
Ref: library/argparse fromfile-prefix-chars10343666
Ref: 2bc110343666
Node: argument_default10345612
Ref: library/argparse argument-default10345749
Ref: 2bc210345749
Node: allow_abbrev10346736
Ref: library/argparse allow-abbrev10346868
Ref: d8c10346868
Ref: library/argparse id410346868
Ref: 2bd010346868
Node: conflict_handler10347555
Ref: library/argparse conflict-handler10347679
Ref: 2bc310347679
Node: add_help10349502
Ref: library/argparse add-help10349627
Ref: 2bc410349627
Node: exit_on_error10350879
Ref: library/argparse exit-on-error10350979
Ref: 2bc510350979
Node: add_argument メソッド10351891
Ref: library/argparse the-add-argument-method10352097
Ref: 2bd110352097
Ref: library/argparse argparse ArgumentParser add_argument10352170
Ref: 18310352170
Node: name または flags10354209
Ref: library/argparse id510354306
Ref: 2bda10354306
Ref: library/argparse name-or-flags10354306
Ref: 2bd210354306
Node: action10355586
Ref: library/argparse action10355697
Ref: 2bd310355697
Ref: library/argparse id610355697
Ref: 2bdb10355697
Ref: library/argparse argparse BooleanOptionalAction10361160
Ref: 17c010361160
Node: nargs10362917
Ref: library/argparse id710363013
Ref: 2bdc10363013
Ref: library/argparse nargs10363013
Ref: 151110363013
Node: const10367376
Ref: library/argparse const10367473
Ref: 2bd410367473
Ref: library/argparse id810367473
Ref: 2bde10367473
Node: default10368949
Ref: library/argparse default10369045
Ref: 2bd510369045
Ref: library/argparse id910369045
Ref: 2bdf10369045
Node: type10371719
Ref: library/argparse argparse-type10371817
Ref: 2be010371817
Ref: library/argparse type10371817
Ref: 2bcc10371817
Node: choices10375640
Ref: library/argparse choices10375739
Ref: 150e10375739
Ref: library/argparse id1010375739
Ref: 2be210375739
Node: required10377760
Ref: library/argparse id1110377859
Ref: 2be310377859
Ref: library/argparse required10377859
Ref: 2bd610377859
Node: help10378903
Ref: library/argparse help10379002
Ref: 2bd710379002
Ref: library/argparse id1210379002
Ref: 2be410379002
Node: metavar10380682
Ref: library/argparse id1310380777
Ref: 2be510380777
Ref: library/argparse metavar10380777
Ref: 2bd810380777
Node: dest10383054
Ref: library/argparse dest10383155
Ref: 2bcd10383155
Ref: library/argparse id1410383155
Ref: 2be610383155
Node: deprecated10384982
Ref: library/argparse deprecated10385092
Ref: 2bd910385092
Ref: library/argparse id1510385092
Ref: 2be710385092
Node: Action クラス10386004
Ref: library/argparse action-classes10386101
Ref: 2be810386101
Ref: library/argparse argparse Action10386395
Ref: 176a10386395
Ref: library/argparse argparse Action __call__10387293
Ref: 2be910387293
Ref: library/argparse argparse Action format_usage10388593
Ref: 2bea10388593
Node: parse_args メソッド10388907
Ref: library/argparse the-parse-args-method10389113
Ref: 2beb10389113
Ref: library/argparse argparse ArgumentParser parse_args10389182
Ref: 2bb710389182
Node: オプション値の文法10390222
Ref: library/argparse option-value-syntax10390333
Ref: 2bee10390333
Node: 不正な引数10392023
Ref: library/argparse invalid-arguments10392160
Ref: 2bef10392160
Node: - を含む引数10393189
Ref: library/argparse arguments-containing10393351
Ref: 2bf010393351
Node: 引数の短縮形 先頭文字でのマッチング10395527
Ref: library/argparse argument-abbreviations-prefix-matching10395689
Ref: 2bf110395689
Ref: library/argparse prefix-matching10395689
Ref: d8d10395689
Node: sys argv 以外10396724
Ref: library/argparse args10396897
Ref: 2bec10396897
Ref: library/argparse beyond-sys-argv10396897
Ref: 2bf210396897
Node: Namespace オブジェクト10397857
Ref: library/argparse namespace10397969
Ref: 2bed10397969
Ref: library/argparse the-namespace-object10397969
Ref: 2bf310397969
Ref: library/argparse argparse Namespace10398042
Ref: 2bb810398042
Node: その他のユーティリティ10399331
Ref: library/argparse other-utilities10399521
Ref: 2bf410399521
Node: サブコマンド10399881
Ref: library/argparse sub-commands10400005
Ref: 2bf510400005
Ref: library/argparse argparse ArgumentParser add_subparsers10400058
Ref: be510400058
Node: FileType オブジェクト10409955
Ref: library/argparse filetype-objects10410106
Ref: 2bf610410106
Ref: library/argparse argparse FileType10410177
Ref: ee710410177
Node: 引数グループ10411798
Ref: library/argparse argument-groups10411943
Ref: 2bf710411943
Ref: library/argparse argparse ArgumentParser add_argument_group10411996
Ref: 2bf810411996
Node: 相互排他10414903
Ref: library/argparse mutual-exclusion10415054
Ref: 2bf910415054
Ref: library/argparse argparse ArgumentParser add_mutually_exclusive_group10415097
Ref: 2bfa10415097
Node: パーサーのデフォルト値10417986
Ref: library/argparse parser-defaults10418137
Ref: 2bfb10418137
Ref: library/argparse argparse ArgumentParser set_defaults10418215
Ref: 2bcf10418215
Ref: library/argparse argparse ArgumentParser get_default10419465
Ref: 2bfc10419465
Node: ヘルプの表示10419850
Ref: library/argparse printing-help10420001
Ref: 2bfd10420001
Ref: library/argparse argparse ArgumentParser print_usage10420325
Ref: 2bfe10420325
Ref: library/argparse argparse ArgumentParser print_help10420607
Ref: 2bff10420607
Ref: library/argparse argparse ArgumentParser format_usage10421044
Ref: 193610421044
Ref: library/argparse argparse ArgumentParser format_help10421251
Ref: 2c0010421251
Node: 部分解析10421491
Ref: library/argparse partial-parsing10421648
Ref: 2c0110421648
Ref: library/argparse argparse ArgumentParser parse_known_args10421691
Ref: 2c0210421691
Node: ファイル解析のカスタマイズ10423000
Ref: library/argparse customizing-file-parsing10423157
Ref: 2c0310423157
Ref: library/argparse argparse ArgumentParser convert_arg_line_to_args10423245
Ref: 2bce10423245
Node: 終了メソッド10424383
Ref: library/argparse exiting-methods10424555
Ref: 2c0410424555
Ref: library/argparse argparse ArgumentParser exit10424608
Ref: 2c0510424608
Ref: library/argparse argparse ArgumentParser error10425177
Ref: 2c0610425177
Node: 混在した引数の解析10425382
Ref: library/argparse intermixed-parsing10425506
Ref: 2c0710425506
Ref: library/argparse argparse ArgumentParser parse_intermixed_args10425574
Ref: ace10425574
Ref: library/argparse argparse ArgumentParser parse_known_intermixed_args10425668
Ref: 2c0810425668
Node: 例外<9>10427463
Ref: library/argparse exceptions10427621
Ref: 2c0910427621
Ref: library/argparse argparse ArgumentError10427654
Ref: 2c0a10427654
Ref: library/argparse argparse ArgumentTypeError10427951
Ref: 2be110427951
Node: Argparse チュートリアル10428252
Ref: howto/argparse doc10428360
Ref: 2c0b10428360
Ref: howto/argparse argparse-tutorial10428360
Ref: 2bb610428360
Ref: howto/argparse id110428360
Ref: 2c0c10428360
Node: コンセプト10429307
Ref: howto/argparse concepts10429404
Ref: 2c0d10429404
Node: 基礎10432069
Ref: howto/argparse the-basics10432196
Ref: 2c0e10432196
Node: 位置引数の入門10433623
Ref: howto/argparse introducing-positional-arguments10433758
Ref: 2c0f10433758
Node: Optional引数の導入10437456
Ref: howto/argparse introducing-optional-arguments10437623
Ref: 2c1010437623
Node: 短いオプション10441255
Ref: howto/argparse short-options10441336
Ref: 2c1110441336
Node: 位置引数とOptional引数の併用10442247
Ref: howto/argparse combining-positional-and-optional-arguments10442423
Ref: 2c1210442423
Node: もうちょっとだけ学ぶ10451473
Ref: howto/argparse getting-a-little-more-advanced10451665
Ref: 2c1310451665
Node: 多義性のある引数の指定10453760
Ref: howto/argparse id210453896
Ref: 2c1410453896
Ref: howto/argparse specifying-ambiguous-arguments10453896
Ref: 2bdd10453896
Node: 競合するオプション10454942
Ref: howto/argparse conflicting-options10455078
Ref: 2c1510455078
Node: argparse の出力を翻訳するには10458508
Ref: howto/argparse how-to-translate-the-argparse-output10458684
Ref: 2c1610458684
Ref: argparse の出力を翻訳するには-Footnote-110460847
Node: Custom type converters10460880
Ref: howto/argparse custom-type-converters10461032
Ref: 2c1810461032
Node: 結び10462794
Ref: howto/argparse conclusion10462898
Ref: 2c1910462898
Node: Upgrading optparse code10463306
Ref: howto/argparse-optparse doc10463414
Ref: 2c1a10463414
Ref: howto/argparse-optparse id110463414
Ref: 2c1b10463414
Ref: howto/argparse-optparse upgrading-optparse-code10463414
Ref: 117e10463414
Node: logging --- Python 用のログ記録手段10465911
Ref: library/logging doc10466179
Ref: 2c2110466179
Ref: library/logging logging-logging-facility-for-python10466179
Ref: 2c2210466179
Ref: library/logging module-logging10466179
Ref: 7b10466179
Ref: logging --- Python 用のログ記録手段-Footnote-110470823
Node: ロガーオブジェクト10470900
Ref: library/logging logger10471037
Ref: 2c2310471037
Ref: library/logging logger-objects10471037
Ref: 2c2410471037
Ref: library/logging logging Logger10472561
Ref: b1d10472561
Ref: library/logging logging Logger name10472592
Ref: 2c2510472592
Ref: library/logging logging Logger level10472876
Ref: 2c2610472876
Ref: library/logging logging Logger parent10473316
Ref: 2c2710473316
Ref: library/logging logging Logger propagate10473670
Ref: 143810473670
Ref: library/logging logging Logger handlers10476225
Ref: 2c2810476225
Ref: library/logging logging Logger disabled10476783
Ref: 2c2b10476783
Ref: library/logging logging Logger setLevel10477203
Ref: 143610477203
Ref: library/logging logging Logger isEnabledFor10479589
Ref: 12c410479589
Ref: library/logging logging Logger getEffectiveLevel10480041
Ref: 2c2d10480041
Ref: library/logging logging Logger getChild10480665
Ref: 12c210480665
Ref: library/logging logging Logger getChildren10481240
Ref: 173210481240
Ref: library/logging logging Logger debug10481995
Ref: df710481995
Ref: library/logging logging Logger info10488673
Ref: 1c5c10488673
Ref: library/logging logging Logger warning10488903
Ref: 166910488903
Ref: library/logging logging Logger error10489401
Ref: 2c3010489401
Ref: library/logging logging Logger critical10489633
Ref: df610489633
Ref: library/logging logging Logger log10489871
Ref: df410489871
Ref: library/logging logging Logger exception10490138
Ref: df510490138
Ref: library/logging logging Logger addFilter10490540
Ref: 2c3110490540
Ref: library/logging logging Logger removeFilter10490671
Ref: 2c3210490671
Ref: library/logging logging Logger filter10490811
Ref: 2c3310490811
Ref: library/logging logging Logger addHandler10491400
Ref: 2c2910491400
Ref: library/logging logging Logger removeHandler10491528
Ref: 2c2a10491528
Ref: library/logging logging Logger findCaller10491665
Ref: 2c3410491665
Ref: library/logging logging Logger handle10492709
Ref: 2c3510492709
Ref: library/logging logging Logger makeRecord10493319
Ref: 2c3610493319
Ref: library/logging logging Logger hasHandlers10493661
Ref: 2c3710493661
Node: ロギングレベル10494466
Ref: library/logging levels10494642
Ref: 62610494642
Ref: library/logging logging-levels10494642
Ref: 2c3810494642
Ref: library/logging logging NOTSET10495413
Ref: 2c2c10495413
Ref: library/logging logging DEBUG10496251
Ref: 1c5d10496251
Ref: library/logging logging INFO10496621
Ref: 1c5e10496621
Ref: library/logging logging WARNING10496870
Ref: 1c5f10496870
Ref: library/logging logging ERROR10497468
Ref: 1c6010497468
Ref: library/logging logging CRITICAL10497749
Ref: 1c6110497749
Node: ハンドラオブジェクト10497976
Ref: library/logging handler10498161
Ref: 2c3910498161
Ref: library/logging handler-objects10498161
Ref: 2c3a10498161
Ref: library/logging logging Handler10498646
Ref: 143910498646
Ref: library/logging logging Handler __init__10498678
Ref: 2c3b10498678
Ref: library/logging logging Handler createLock10499044
Ref: 2c3c10499044
Ref: library/logging logging Handler acquire10499292
Ref: 2c3d10499292
Ref: library/logging logging Handler release10499436
Ref: 2c3e10499436
Ref: library/logging logging Handler setLevel10499563
Ref: 2c3f10499563
Ref: library/logging logging Handler setFormatter10500302
Ref: 2c4010500302
Ref: library/logging logging Handler addFilter10500433
Ref: 2c4110500433
Ref: library/logging logging Handler removeFilter10500567
Ref: 2c4210500567
Ref: library/logging logging Handler filter10500707
Ref: 2c4310500707
Ref: library/logging logging Handler flush10501232
Ref: 2c4410501232
Ref: library/logging logging Handler close10501474
Ref: 2c4510501474
Ref: library/logging logging Handler handle10501973
Ref: 2c4710501973
Ref: library/logging logging Handler handleError10502284
Ref: 2c4810502284
Ref: library/logging logging Handler format10503356
Ref: 2c4a10503356
Ref: library/logging logging Handler emit10503661
Ref: 2c4910503661
Node: フォーマッタオブジェクト10506092
Ref: library/logging formatter-objects10506286
Ref: 2c4b10506286
Ref: library/logging id110506286
Ref: 2c4c10506286
Ref: library/logging logging Formatter10506367
Ref: 143a10506367
Ref: library/logging logging Formatter format10509215
Ref: 2c4f10509215
Ref: library/logging logging Formatter formatTime10511009
Ref: 2c4d10511009
Ref: library/logging logging Formatter formatException10514042
Ref: 2c5010514042
Ref: library/logging logging Formatter formatStack10514411
Ref: 2c5110514411
Ref: library/logging logging BufferingFormatter10514795
Ref: 2c5210514795
Ref: library/logging logging BufferingFormatter formatHeader10515333
Ref: 2c5310515333
Ref: library/logging logging BufferingFormatter formatFooter10515817
Ref: 2c5410515817
Ref: library/logging logging BufferingFormatter format10516245
Ref: 2c5510516245
Node: フィルタオブジェクト10516774
Ref: library/logging filter10516966
Ref: 2c5610516966
Ref: library/logging filter-objects10516966
Ref: 2c5710516966
Ref: library/logging logging Filter10517684
Ref: 11cc10517684
Ref: library/logging logging Filter filter10518105
Ref: 2c5810518105
Node: LogRecord オブジェクト10521431
Ref: library/logging log-record10521603
Ref: 2c5b10521603
Ref: library/logging logrecord-objects10521603
Ref: 2c5c10521603
Ref: library/logging logging LogRecord10522001
Ref: fb310522001
Ref: library/logging logging LogRecord getMessage10524905
Ref: 2c5f10524905
Node: LogRecord 属性10526774
Ref: library/logging id210526948
Ref: 2c6210526948
Ref: library/logging logrecord-attributes10526948
Ref: 2c2e10526948
Node: LoggerAdapter オブジェクト10536263
Ref: library/logging logger-adapter10536433
Ref: 2c6310536433
Ref: library/logging loggeradapter-objects10536433
Ref: 2c6410536433
Ref: library/logging logging LoggerAdapter10536782
Ref: 12c310536782
Ref: library/logging logging LoggerAdapter process10537468
Ref: 2c6610537468
Ref: library/logging logging LoggerAdapter manager10538022
Ref: 2c6710538022
Ref: library/logging logging LoggerAdapter _log10538162
Ref: 2c6810538162
Node: スレッドセーフ性10539464
Ref: library/logging thread-safety10539651
Ref: 2c6910539651
Node: モジュールレベルの関数10540595
Ref: library/logging module-level-functions10540780
Ref: 2c6a10540780
Ref: library/logging logging getLogger10540968
Ref: 92e10540968
Ref: library/logging logging getLoggerClass10541777
Ref: 2c6b10541777
Ref: library/logging logging getLogRecordFactory10542393
Ref: 2c6010542393
Ref: library/logging logging debug10542968
Ref: 2c2f10542968
Ref: library/logging logging info10543861
Ref: 2c5910543861
Ref: library/logging logging warning10544071
Ref: 2d610544071
Ref: library/logging logging error10544527
Ref: 2c6d10544527
Ref: library/logging logging critical10544739
Ref: 2c6e10544739
Ref: library/logging logging exception10544957
Ref: 143710544957
Ref: library/logging logging log10545290
Ref: 2c6f10545290
Ref: library/logging logging disable10545497
Ref: 2c7010545497
Ref: library/logging logging addLevelName10546872
Ref: 2c7110546872
Ref: library/logging logging getLevelNamesMapping10547725
Ref: 62510547725
Ref: library/logging logging getLevelName10548150
Ref: 2c7310548150
Ref: library/logging logging getHandlerByName10550097
Ref: 174310550097
Ref: library/logging logging getHandlerNames10550283
Ref: 166310550283
Ref: library/logging logging makeLogRecord10550414
Ref: 2c5d10550414
Ref: library/logging logging basicConfig10550821
Ref: 9ce10550821
Ref: library/logging logging shutdown10557153
Ref: 2c4610557153
Ref: library/logging logging setLoggerClass10557828
Ref: 2c6c10557828
Ref: library/logging logging setLogRecordFactory10558738
Ref: 2c6110558738
Ref: モジュールレベルの関数-Footnote-110560247
Node: モジュールレベル属性10560312
Ref: library/logging module-level-attributes10560509
Ref: 2c7410560509
Ref: library/logging logging lastResort10560582
Ref: 11cb10560582
Ref: library/logging logging raiseExceptions10561405
Ref: 11ca10561405
Node: warnings モジュールとの統合10561807
Ref: library/logging integration-with-the-warnings-module10561962
Ref: 2c7510561962
Ref: library/logging logging captureWarnings10562185
Ref: 2c7610562185
Ref: warnings モジュールとの統合-Footnote-110563888
Ref: warnings モジュールとの統合-Footnote-210563930
Node: logging config --- ログ記録の環境設定10563983
Ref: library/logging config doc10564229
Ref: 2c7710564229
Ref: library/logging config logging-config-logging-configuration10564229
Ref: 2c7810564229
Ref: library/logging config module-logging config10564229
Ref: 7c10564229
Ref: logging config --- ログ記録の環境設定-Footnote-110565060
Node: 環境設定のための関数10565134
Ref: library/logging config configuration-functions10565295
Ref: 2c7910565295
Ref: library/logging config logging-config-api10565295
Ref: 12bf10565295
Ref: library/logging config logging config dictConfig10565853
Ref: 118010565853
Ref: library/logging config logging config fileConfig10568209
Ref: b1f10568209
Ref: library/logging config logging config listen10571458
Ref: f3210571458
Ref: library/logging config logging-eval-security10573679
Ref: 2c7e10573679
Ref: library/logging config logging config stopListening10575898
Ref: 2c7d10575898
Node: セキュリティで考慮すべき点10576178
Ref: library/logging config security-considerations10576378
Ref: 2c7f10576378
Node: 環境設定辞書スキーマ10577530
Ref: library/logging config configuration-dictionary-schema10577733
Ref: 2c8110577733
Ref: library/logging config logging-config-dictschema10577733
Ref: 2c7a10577733
Node: 辞書スキーマの詳細10579028
Ref: library/logging config dictionary-schema-details10579143
Ref: 2c8310579143
Ref: library/logging config logging-config-dictschema-formatters10580239
Ref: 2c8410580239
Node: 増分設定10586223
Ref: library/logging config incremental-configuration10586374
Ref: 2c8610586374
Ref: library/logging config logging-config-dict-incremental10586374
Ref: 2c8510586374
Node: オブジェクトの接続10588122
Ref: library/logging config logging-config-dict-connections10588279
Ref: 2c8210588279
Ref: library/logging config object-connections10588279
Ref: 2c8710588279
Node: ユーザ定義オブジェクト10591084
Ref: library/logging config logging-config-dict-userdef10591256
Ref: 2c8010591256
Ref: library/logging config user-defined-objects10591256
Ref: 2c8810591256
Node: ハンドラの設定順序10597105
Ref: library/logging config handler-config-dict-order10597292
Ref: 2c8910597292
Ref: library/logging config handler-configuration-order10597292
Ref: 2c8a10597292
Node: 外部オブジェクトへのアクセス10599084
Ref: library/logging config access-to-external-objects10599280
Ref: 2c8b10599280
Ref: library/logging config logging-config-dict-externalobj10599280
Ref: 2c8c10599280
Node: 内部オブジェクトへのアクセス10600769
Ref: library/logging config access-to-internal-objects10600992
Ref: 2c8d10600992
Ref: library/logging config logging-config-dict-internalobj10600992
Ref: 2c8e10600992
Node: インポート解決とカスタムインポーター10604876
Ref: library/logging config import-resolution-and-custom-importers10605099
Ref: 2c9010605099
Ref: library/logging config logging-import-resolution10605099
Ref: 2c9110605099
Node: Configuring QueueHandler and QueueListener10606372
Ref: library/logging config configure-queue10606544
Ref: 153e10606544
Ref: library/logging config configuring-queuehandler-and-queuelistener10606544
Ref: 2c9210606544
Node: 環境設定ファイルの書式10609777
Ref: library/logging config configuration-file-format10609932
Ref: 2c9710609932
Ref: library/logging config logging-config-fileformat10609932
Ref: 2c7b10609932
Node: logging handlers --- ログ記録ハンドラー10618990
Ref: library/logging handlers doc10619250
Ref: 2c9810619250
Ref: library/logging handlers logging-handlers-logging-handlers10619250
Ref: 2c9910619250
Ref: library/logging handlers module-logging handlers10619250
Ref: 7d10619250
Ref: logging handlers --- ログ記録ハンドラー-Footnote-110620557
Node: StreamHandler10620634
Ref: library/logging handlers stream-handler10620752
Ref: 2c9a10620752
Ref: library/logging handlers streamhandler10620752
Ref: 2c9b10620752
Ref: library/logging handlers logging StreamHandler10621207
Ref: 11c910621207
Ref: library/logging handlers logging StreamHandler emit10621549
Ref: 2c9c10621549
Ref: library/logging handlers logging StreamHandler flush10622017
Ref: 2c9e10622017
Ref: library/logging handlers logging StreamHandler setStream10622417
Ref: b1e10622417
Ref: library/logging handlers logging StreamHandler terminator10622925
Ref: 2c9d10622925
Node: FileHandler10623487
Ref: library/logging handlers file-handler10623625
Ref: 2c9f10623625
Ref: library/logging handlers filehandler10623625
Ref: 2ca010623625
Ref: library/logging handlers logging FileHandler10623925
Ref: 180910623925
Ref: library/logging handlers logging FileHandler close10624799
Ref: 2ca210624799
Ref: library/logging handlers logging FileHandler emit10624874
Ref: 2ca110624874
Ref: FileHandler-Footnote-110625278
Node: NullHandler10625343
Ref: library/logging handlers null-handler10625486
Ref: 2ca310625486
Ref: library/logging handlers nullhandler10625486
Ref: 2ca410625486
Ref: library/logging handlers logging NullHandler10625799
Ref: 125510625799
Ref: library/logging handlers logging NullHandler emit10625924
Ref: 2ca510625924
Ref: library/logging handlers logging NullHandler handle10626016
Ref: 2ca610626016
Ref: library/logging handlers logging NullHandler createLock10626110
Ref: 2ca710626110
Node: WatchedFileHandler10626476
Ref: library/logging handlers watched-file-handler10626627
Ref: 2ca910626627
Ref: library/logging handlers watchedfilehandler10626627
Ref: 2caa10626627
Ref: library/logging handlers logging handlers WatchedFileHandler10628104
Ref: 2cab10628104
Ref: library/logging handlers logging handlers WatchedFileHandler reopenIfNeeded10628990
Ref: c8410628990
Ref: library/logging handlers logging handlers WatchedFileHandler emit10629355
Ref: 2cac10629355
Node: BaseRotatingHandler10629600
Ref: library/logging handlers base-rotating-handler10629759
Ref: 2cad10629759
Ref: library/logging handlers baserotatinghandler10629759
Ref: 2cae10629759
Ref: library/logging handlers logging handlers BaseRotatingHandler10630261
Ref: 2caf10630261
Ref: library/logging handlers logging handlers BaseRotatingHandler namer10630472
Ref: 2cb010630472
Ref: library/logging handlers logging handlers BaseRotatingHandler rotator10632708
Ref: 2cb310632708
Ref: library/logging handlers logging handlers BaseRotatingHandler rotation_filename10633032
Ref: 2cb110633032
Ref: library/logging handlers logging handlers BaseRotatingHandler rotate10633773
Ref: 2cb410633773
Node: RotatingFileHandler10635397
Ref: library/logging handlers rotating-file-handler10635562
Ref: 2cb610635562
Ref: library/logging handlers rotatingfilehandler10635562
Ref: 2cb710635562
Ref: library/logging handlers logging handlers RotatingFileHandler10635833
Ref: 153b10635833
Ref: library/logging handlers logging handlers RotatingFileHandler doRollover10638551
Ref: 2cb910638551
Ref: library/logging handlers logging handlers RotatingFileHandler emit10638664
Ref: 2cb810638664
Node: TimedRotatingFileHandler10638830
Ref: library/logging handlers timed-rotating-file-handler10638989
Ref: 2cba10638989
Ref: library/logging handlers timedrotatingfilehandler10638989
Ref: 2cbb10638989
Ref: library/logging handlers logging handlers TimedRotatingFileHandler10639259
Ref: f2e10639259
Ref: library/logging handlers logging handlers TimedRotatingFileHandler doRollover10645279
Ref: 2cbd10645279
Ref: library/logging handlers logging handlers TimedRotatingFileHandler emit10645392
Ref: 2cbc10645392
Ref: library/logging handlers logging handlers TimedRotatingFileHandler getFilesToDelete10645567
Ref: 2cb210645567
Node: SocketHandler10645888
Ref: library/logging handlers socket-handler10646043
Ref: 2cbe10646043
Ref: library/logging handlers sockethandler10646043
Ref: 2cbf10646043
Ref: library/logging handlers logging handlers SocketHandler10646315
Ref: f2f10646315
Ref: library/logging handlers logging handlers SocketHandler close10646823
Ref: 2cc010646823
Ref: library/logging handlers logging handlers SocketHandler emit10646898
Ref: 2cc110646898
Ref: library/logging handlers logging handlers SocketHandler handleError10647430
Ref: 2cc210647430
Ref: library/logging handlers logging handlers SocketHandler makeSocket10647712
Ref: 2cc310647712
Ref: library/logging handlers logging handlers SocketHandler makePickle10648021
Ref: 2cc410648021
Ref: library/logging handlers logging handlers SocketHandler send10649056
Ref: 2cc510649056
Ref: library/logging handlers logging handlers SocketHandler createSocket10649472
Ref: 62910649472
Node: DatagramHandler10650849
Ref: library/logging handlers datagram-handler10650993
Ref: 2cc610650993
Ref: library/logging handlers datagramhandler10650993
Ref: 2cc710650993
Ref: library/logging handlers logging handlers DatagramHandler10651298
Ref: f3010651298
Ref: library/logging handlers logging handlers DatagramHandler emit10652624
Ref: 2cc810652624
Ref: library/logging handlers logging handlers DatagramHandler makeSocket10653156
Ref: 2cc910653156
Ref: library/logging handlers logging handlers DatagramHandler send10653402
Ref: 2cca10653402
Node: SysLogHandler10653685
Ref: library/logging handlers syslog-handler10653833
Ref: 2ccb10653833
Ref: library/logging handlers sysloghandler10653833
Ref: 2ccc10653833
Ref: library/logging handlers logging handlers SysLogHandler10654112
Ref: 62810654112
Ref: library/logging handlers logging handlers SysLogHandler close10656727
Ref: 2ccd10656727
Ref: library/logging handlers logging handlers SysLogHandler createSocket10656823
Ref: 62710656823
Ref: library/logging handlers logging handlers SysLogHandler emit10657278
Ref: 2cce10657278
Ref: library/logging handlers logging handlers SysLogHandler encodePriority10659720
Ref: 2ccf10659720
Ref: library/logging handlers logging handlers SysLogHandler mapPriority10663887
Ref: 2cd010663887
Ref: SysLogHandler-Footnote-110664529
Ref: SysLogHandler-Footnote-210664584
Ref: SysLogHandler-Footnote-310664649
Ref: SysLogHandler-Footnote-410664708
Node: NTEventLogHandler10664773
Ref: library/logging handlers nt-eventlog-handler10664917
Ref: 2cd110664917
Ref: library/logging handlers nteventloghandler10664917
Ref: 2cd210664917
Ref: library/logging handlers logging handlers NTEventLogHandler10665405
Ref: 2cd310665405
Ref: library/logging handlers logging handlers NTEventLogHandler close10666614
Ref: 2cd410666614
Ref: library/logging handlers logging handlers NTEventLogHandler emit10667200
Ref: 2cd510667200
Ref: library/logging handlers logging handlers NTEventLogHandler getEventCategory10667400
Ref: 2cd610667400
Ref: library/logging handlers logging handlers NTEventLogHandler getEventType10667730
Ref: 2cd710667730
Ref: library/logging handlers logging handlers NTEventLogHandler getMessageID10668468
Ref: 2cd810668468
Node: SMTPHandler10668973
Ref: library/logging handlers smtp-handler10669117
Ref: 2cd910669117
Ref: library/logging handlers smtphandler10669117
Ref: 2cda10669117
Ref: library/logging handlers logging handlers SMTPHandler10669351
Ref: 2cdb10669351
Ref: library/logging handlers logging handlers SMTPHandler emit10670964
Ref: 2cdc10670964
Ref: library/logging handlers logging handlers SMTPHandler getSubject10671092
Ref: 2cdd10671092
Node: MemoryHandler10671291
Ref: library/logging handlers memory-handler10671429
Ref: 2cde10671429
Ref: library/logging handlers memoryhandler10671429
Ref: 2cdf10671429
Ref: library/logging handlers logging handlers BufferingHandler10672479
Ref: 2ce010672479
Ref: library/logging handlers logging handlers BufferingHandler emit10672717
Ref: 2ce110672717
Ref: library/logging handlers logging handlers BufferingHandler flush10672972
Ref: 2ce310672972
Ref: library/logging handlers logging handlers BufferingHandler shouldFlush10673215
Ref: 2ce210673215
Ref: library/logging handlers logging handlers MemoryHandler10673504
Ref: 2c8f10673504
Ref: library/logging handlers logging handlers MemoryHandler close10674625
Ref: 2ce510674625
Ref: library/logging handlers logging handlers MemoryHandler flush10674798
Ref: 2ce610674798
Ref: library/logging handlers logging handlers MemoryHandler setTarget10675111
Ref: 2ce410675111
Ref: library/logging handlers logging handlers MemoryHandler shouldFlush10675235
Ref: 2ce710675235
Node: HTTPHandler10675428
Ref: library/logging handlers http-handler10675567
Ref: 2ce810675567
Ref: library/logging handlers httphandler10675567
Ref: 2ce910675567
Ref: library/logging handlers logging handlers HTTPHandler10675876
Ref: df810675876
Ref: library/logging handlers logging handlers HTTPHandler mapLogRecord10677007
Ref: 2cea10677007
Ref: library/logging handlers logging handlers HTTPHandler emit10677577
Ref: 2ceb10677577
Node: QueueHandler10678537
Ref: library/logging handlers queue-handler10678676
Ref: 2cec10678676
Ref: library/logging handlers queuehandler10678676
Ref: 2ced10678676
Ref: library/logging handlers logging handlers QueueHandler10679665
Ref: 174210679665
Ref: library/logging handlers logging handlers QueueHandler emit10680599
Ref: 2cef10680599
Ref: library/logging handlers logging handlers QueueHandler prepare10681108
Ref: 2cf010681108
Ref: library/logging handlers logging handlers QueueHandler enqueue10683957
Ref: 2cee10683957
Ref: library/logging handlers logging handlers QueueHandler listener10684285
Ref: 2c9310684285
Node: QueueListener10684580
Ref: library/logging handlers queue-listener10684699
Ref: 2cf110684699
Ref: library/logging handlers queuelistener10684699
Ref: 2cf210684699
Ref: library/logging handlers logging handlers QueueListener10686025
Ref: df910686025
Ref: library/logging handlers logging handlers QueueListener dequeue10687670
Ref: 2cf310687670
Ref: library/logging handlers logging handlers QueueListener prepare10688116
Ref: 2cf410688116
Ref: library/logging handlers logging handlers QueueListener handle10688568
Ref: 2cf510688568
Ref: library/logging handlers logging handlers QueueListener start10688902
Ref: 2cf610688902
Ref: library/logging handlers logging handlers QueueListener stop10689134
Ref: 2cf710689134
Ref: library/logging handlers logging handlers QueueListener enqueue_sentinel10689544
Ref: 2cf810689544
Node: getpass --- 可搬性のあるパスワード入力機構10690208
Ref: library/getpass doc10690475
Ref: 2cf910690475
Ref: library/getpass getpass-portable-password-input10690475
Ref: 2cfa10690475
Ref: library/getpass module-getpass10690475
Ref: 5810690475
Ref: library/getpass getpass getpass10690994
Ref: 2cfb10690994
Ref: library/getpass getpass GetPassWarning10692075
Ref: 2cfc10692075
Ref: library/getpass getpass getuser10692239
Ref: 3f110692239
Ref: getpass --- 可搬性のあるパスワード入力機構-Footnote-110693055
Node: curses --- 文字セル表示のターミナル処理10693122
Ref: library/curses doc10693430
Ref: 2cfd10693430
Ref: library/curses curses-terminal-handling-for-character-cell-displays10693430
Ref: 2cfe10693430
Ref: library/curses module-curses10693430
Ref: 2310693430
Ref: curses --- 文字セル表示のターミナル処理-Footnote-110695511
Node: 関数<6>10695574
Ref: library/curses curses-functions10695707
Ref: 2d0010695707
Ref: library/curses functions10695707
Ref: 2d0110695707
Ref: library/curses curses error10695819
Ref: 2d0210695819
Ref: library/curses curses baudrate10696289
Ref: 2d0410696289
Ref: library/curses curses beep10696826
Ref: 2d0510696826
Ref: library/curses curses can_change_color10696909
Ref: 2d0610696909
Ref: library/curses curses cbreak10697103
Ref: 2d0710697103
Ref: library/curses curses color_content10697819
Ref: 7bc10697819
Ref: library/curses curses color_pair10698292
Ref: 2d0910698292
Ref: library/curses curses curs_set10698680
Ref: 2d0d10698680
Ref: library/curses curses def_prog_mode10699265
Ref: 2d0e10699265
Ref: library/curses curses def_shell_mode10699676
Ref: 2d1010699676
Ref: library/curses curses delay_output10700123
Ref: 2d1210700123
Ref: library/curses curses doupdate10700228
Ref: 2d1310700228
Ref: library/curses curses echo10701382
Ref: 2d1610701382
Ref: library/curses curses endwin10701577
Ref: 2d1710701577
Ref: library/curses curses erasechar10701701
Ref: 2d1810701701
Ref: library/curses curses filter10702063
Ref: 2d1910702063
Ref: library/curses curses flash10702868
Ref: 2d1a10702868
Ref: library/curses curses flushinp10703174
Ref: 2d1b10703174
Ref: library/curses curses getmouse10703471
Ref: 2d1c10703471
Ref: library/curses curses getsyx10704743
Ref: 2d2710704743
Ref: library/curses curses getwin10704998
Ref: 2d2810704998
Ref: library/curses curses has_colors10705254
Ref: 2d2a10705254
Ref: library/curses curses has_extended_color_support10705433
Ref: 7c010705433
Ref: library/curses curses has_ic10705820
Ref: 2d2b10705820
Ref: library/curses curses has_il10706110
Ref: 2d2c10706110
Ref: library/curses curses has_key10706397
Ref: 2d2d10706397
Ref: library/curses curses halfdelay10706575
Ref: 2d2e10706575
Ref: library/curses curses init_color10707113
Ref: 7bd10707113
Ref: library/curses curses init_pair10707860
Ref: 7be10707860
Ref: library/curses curses initscr10708671
Ref: 150810708671
Ref: library/curses curses is_term_resized10709046
Ref: 2d3210709046
Ref: library/curses curses isendwin10709280
Ref: 2d3310709280
Ref: library/curses curses keyname10709508
Ref: 2d3410709508
Ref: library/curses curses killchar10710167
Ref: 2d3510710167
Ref: library/curses curses longname10710437
Ref: 2d3610710437
Ref: library/curses curses meta10710784
Ref: 2d3710710784
Ref: library/curses curses mouseinterval10710991
Ref: 2d3810710991
Ref: library/curses curses mousemask10711333
Ref: 2d3910711333
Ref: library/curses curses napms10711916
Ref: 150710711916
Ref: library/curses curses newpad10711998
Ref: 2d3a10711998
Ref: library/curses curses newwin10713319
Ref: 2d3c10713319
Ref: library/curses curses nl10713709
Ref: 2d3d10713709
Ref: library/curses curses nocbreak10714024
Ref: 2d2f10714024
Ref: library/curses curses noecho10714188
Ref: 2d3e10714188
Ref: library/curses curses nonl10714317
Ref: 2d3f10714317
Ref: library/curses curses noqiflush10714922
Ref: 2d4010714922
Ref: library/curses curses noraw10715401
Ref: 2d4110715401
Ref: library/curses curses pair_content10715559
Ref: 7bf10715559
Ref: library/curses curses pair_number10715804
Ref: 2d0c10715804
Ref: library/curses curses putp10715990
Ref: 2d4210715990
Ref: library/curses curses qiflush10716271
Ref: 2d4310716271
Ref: library/curses curses raw10716577
Ref: 2d0810716577
Ref: library/curses curses reset_prog_mode10716910
Ref: 2d0f10716910
Ref: library/curses curses reset_shell_mode10717092
Ref: 2d1110717092
Ref: library/curses curses resetty10717274
Ref: 2d4410717274
Ref: library/curses curses resize_term10717429
Ref: 151010717429
Ref: library/curses curses resizeterm10718073
Ref: 150f10718073
Ref: library/curses curses savetty10718381
Ref: 2d4510718381
Ref: library/curses curses get_escdelay10718544
Ref: 8be10718544
Ref: library/curses curses set_escdelay10718671
Ref: 8bf10718671
Ref: library/curses curses get_tabsize10718970
Ref: 8c010718970
Ref: library/curses curses set_tabsize10719095
Ref: 8c110719095
Ref: library/curses curses setsyx10719309
Ref: 2d4610719309
Ref: library/curses curses setupterm10719540
Ref: 2d4710719540
Ref: library/curses curses start_color10720003
Ref: 2d4810720003
Ref: library/curses curses termattrs10720859
Ref: 2d4b10720859
Ref: library/curses curses termname10721140
Ref: 2d4c10721140
Ref: library/curses curses tigetflag10721318
Ref: 2d4d10721318
Ref: library/curses curses tigetnum10721666
Ref: 2d4e10721666
Ref: library/curses curses tigetstr10722008
Ref: 2d4f10722008
Ref: library/curses curses tparm10722315
Ref: 2d5010722315
Ref: library/curses curses typeahead10722783
Ref: 2d5110722783
Ref: library/curses curses unctrl10723532
Ref: 2d5210723532
Ref: library/curses curses ungetch10723814
Ref: 2d5310723814
Ref: library/curses curses update_lines_cols10724100
Ref: db910724100
Ref: library/curses curses unget_wch10724297
Ref: 106d10724297
Ref: library/curses curses ungetmouse10724617
Ref: 2d5410724617
Ref: library/curses curses use_env10724821
Ref: 2d5510724821
Ref: library/curses curses use_default_colors10725462
Ref: 2d3010725462
Ref: library/curses curses wrapper10726026
Ref: a4e10726026
Node: Window オブジェクト10727080
Ref: library/curses curses-window-objects10727231
Ref: 2d3110727231
Ref: library/curses window-objects10727231
Ref: 2d5610727231
Ref: library/curses curses window addch10727434
Ref: 2d5710727434
Ref: library/curses curses window addnstr10728114
Ref: 2d5810728114
Ref: library/curses curses window addstr10728410
Ref: 2d1410728410
Ref: library/curses curses window attroff10729453
Ref: 2d5910729453
Ref: library/curses curses window attron10729659
Ref: 2d5a10729659
Ref: library/curses curses window attrset10729849
Ref: 2d5b10729849
Ref: library/curses curses window bkgd10730024
Ref: 2d5c10730024
Ref: library/curses curses window bkgdset10730517
Ref: 2d5d10730517
Ref: library/curses curses window border10731129
Ref: 2d5e10731129
Ref: library/curses curses window box10733278
Ref: 2d6510733278
Ref: library/curses curses window chgat10733569
Ref: 2d6610733569
Ref: library/curses curses window clear10734217
Ref: 2d6810734217
Ref: library/curses curses window clearok10734433
Ref: 2d6a10734433
Ref: library/curses curses window clrtobot10734599
Ref: 2d6b10734599
Ref: library/curses curses window clrtoeol10734829
Ref: 2d6c10734829
Ref: library/curses curses window cursyncup10734931
Ref: 2d6d10734931
Ref: library/curses curses window delch10735112
Ref: 2d6e10735112
Ref: library/curses curses window deleteln10735209
Ref: 2d6f10735209
Ref: library/curses curses window derwin10735365
Ref: 2d7010735365
Ref: library/curses curses window echochar10735845
Ref: 2d7210735845
Ref: library/curses curses window enclose10736034
Ref: 184210736034
Ref: library/curses curses window encoding10736556
Ref: 106b10736556
Ref: library/curses curses window erase10737064
Ref: 2d6910737064
Ref: library/curses curses window getbegyx10737145
Ref: 2d7310737145
Ref: library/curses curses window getbkgd10737254
Ref: 2d7410737254
Ref: library/curses curses window getch10737388
Ref: 2d1d10737388
Ref: library/curses curses window get_wch10737849
Ref: 106c10737849
Ref: library/curses curses window getkey10738206
Ref: 2d7510738206
Ref: library/curses curses window getmaxyx10738598
Ref: 2d7610738598
Ref: library/curses curses window getparyx10738729
Ref: 2d7710738729
Ref: library/curses curses window getstr10738972
Ref: 2d7810738972
Ref: library/curses curses window getyx10739252
Ref: 2d7910739252
Ref: library/curses curses window hline10739424
Ref: 2d7a10739424
Ref: library/curses curses window idcok10739636
Ref: 2d7b10739636
Ref: library/curses curses window idlok10740040
Ref: 2d7c10740040
Ref: library/curses curses window immedok10740256
Ref: 2d7d10740256
Ref: library/curses curses window inch10740770
Ref: 2d7e10740770
Ref: library/curses curses window insch10740970
Ref: 2d7f10740970
Ref: library/curses curses window insdelln10741203
Ref: 2d8010741203
Ref: library/curses curses window insertln10741678
Ref: 2d8110741678
Ref: library/curses curses window insnstr10741837
Ref: 2d8210741837
Ref: library/curses curses window insstr10742419
Ref: 2d8310742419
Ref: library/curses curses window instr10742879
Ref: 2d8410742879
Ref: library/curses curses window is_linetouched10743407
Ref: 2d8510743407
Ref: library/curses curses window is_wintouched10743794
Ref: 2d8610743794
Ref: library/curses curses window keypad10744059
Ref: 2d8710744059
Ref: library/curses curses window leaveok10744462
Ref: 2d8810744462
Ref: library/curses curses window move10744909
Ref: 2d8910744909
Ref: library/curses curses window mvderwin10745020
Ref: 2d8a10745020
Ref: library/curses curses window mvwin10745363
Ref: 2d8b10745363
Ref: library/curses curses window nodelay10745505
Ref: 2d8c10745505
Ref: library/curses curses window notimeout10745653
Ref: 2d8d10745653
Ref: library/curses curses window noutrefresh10746007
Ref: 2d1510746007
Ref: library/curses curses window overlay10746400
Ref: 2d8e10746400
Ref: library/curses curses window overwrite10747137
Ref: 2d8f10747137
Ref: library/curses curses window putwin10747879
Ref: 2d2910747879
Ref: library/curses curses window redrawln10748174
Ref: 2d9010748174
Ref: library/curses curses window redrawwin10748443
Ref: 2d9110748443
Ref: library/curses curses window refresh10748633
Ref: 2d3b10748633
Ref: library/curses curses window resize10749866
Ref: 2d9210749866
Ref: library/curses curses window scroll10750214
Ref: 2d9310750214
Ref: library/curses curses window scrollok10750359
Ref: 2d9410750359
Ref: library/curses curses window setscrreg10750999
Ref: 2d9510750999
Ref: library/curses curses window standend10751196
Ref: 2d9610751196
Ref: library/curses curses window standout10751395
Ref: 2d9710751395
Ref: library/curses curses window subpad10751483
Ref: 2d9810751483
Ref: library/curses curses window subwin10751769
Ref: 2d7110751769
Ref: library/curses curses window syncdown10752194
Ref: 2d9910752194
Ref: library/curses curses window syncok10752545
Ref: 2d9a10752545
Ref: library/curses curses window syncup10752744
Ref: 2d9b10752744
Ref: library/curses curses window timeout10752910
Ref: 2d9c10752910
Ref: library/curses curses window touchline10753529
Ref: 2d6710753529
Ref: library/curses curses window touchwin10753881
Ref: 2d9d10753881
Ref: library/curses curses window untouchwin10754049
Ref: 2d9e10754049
Ref: library/curses curses window vline10754258
Ref: 16f410754258
Ref: Window オブジェクト-Footnote-110754529
Node: 定数<6>10754572
Ref: library/curses constants10754705
Ref: 2d9f10754705
Ref: library/curses curses ERR10754829
Ref: 2da010754829
Ref: library/curses curses OK10755012
Ref: 2da110755012
Ref: library/curses curses version10755193
Ref: 2da210755193
Ref: library/curses curses __version__10755224
Ref: 2da310755224
Ref: library/curses curses ncurses_version10755328
Ref: 9b510755328
Ref: library/curses curses COLORS10755752
Ref: 2d4910755752
Ref: library/curses curses COLOR_PAIRS10755913
Ref: 2d4a10755913
Ref: library/curses curses COLS10756084
Ref: 167210756084
Ref: library/curses curses LINES10756349
Ref: 167110756349
Ref: library/curses curses A_ALTCHARSET10756913
Ref: 2da410756913
Ref: library/curses curses A_BLINK10757022
Ref: 2da510757022
Ref: library/curses curses A_BOLD10757129
Ref: 2da610757129
Ref: library/curses curses A_DIM10757236
Ref: 2da710757236
Ref: library/curses curses A_INVIS10757349
Ref: 2da810757349
Ref: library/curses curses A_ITALIC10757450
Ref: 2da910757450
Ref: library/curses curses A_NORMAL10757538
Ref: 2d0310757538
Ref: library/curses curses A_PROTECT10757617
Ref: 2daa10757617
Ref: library/curses curses A_REVERSE10757695
Ref: 2d0b10757695
Ref: library/curses curses A_STANDOUT10757857
Ref: 2d0a10757857
Ref: library/curses curses A_UNDERLINE10757936
Ref: 2dab10757936
Ref: library/curses curses A_HORIZONTAL10758015
Ref: 2dac10758015
Ref: library/curses curses A_LEFT10758113
Ref: 2dad10758113
Ref: library/curses curses A_LOW10758219
Ref: 2dae10758219
Ref: library/curses curses A_RIGHT10758327
Ref: 2daf10758327
Ref: library/curses curses A_TOP10758433
Ref: 2db010758433
Ref: library/curses curses A_VERTICAL10758526
Ref: 2db110758526
Ref: library/curses curses A_ATTRIBUTES10758935
Ref: 2db210758935
Ref: library/curses curses A_CHARTEXT10759031
Ref: 2db310759031
Ref: library/curses curses A_COLOR10759143
Ref: 2db410759143
Ref: library/curses curses KEY_MIN10759611
Ref: 2db510759611
Ref: library/curses curses KEY_BREAK10759710
Ref: 2db610759710
Ref: library/curses curses KEY_DOWN10759841
Ref: 2db710759841
Ref: library/curses curses KEY_UP10759944
Ref: 2db810759944
Ref: library/curses curses KEY_LEFT10760051
Ref: 2db910760051
Ref: library/curses curses KEY_RIGHT10760140
Ref: 2dba10760140
Ref: library/curses curses KEY_HOME10760231
Ref: 2dbb10760231
Ref: library/curses curses KEY_BACKSPACE10760356
Ref: 2dbc10760356
Ref: library/curses curses KEY_F010760492
Ref: 2dbd10760492
Ref: library/curses curses KEY_Fn10760694
Ref: 2dbe10760694
Ref: library/curses curses KEY_DL10760828
Ref: 2dbf10760828
Ref: library/curses curses KEY_IL10760947
Ref: 2dc010760947
Ref: library/curses curses KEY_DC10761066
Ref: 2dc110761066
Ref: library/curses curses KEY_IC10761188
Ref: 2dc210761188
Ref: library/curses curses KEY_EIC10761339
Ref: 2dc310761339
Ref: library/curses curses KEY_CLEAR10761456
Ref: 2dc410761456
Ref: library/curses curses KEY_EOS10761549
Ref: 2dc510761549
Ref: library/curses curses KEY_EOL10761672
Ref: 2dc610761672
Ref: library/curses curses KEY_SF10761788
Ref: 2dc710761788
Ref: library/curses curses KEY_SR10761911
Ref: 2dc810761911
Ref: library/curses curses KEY_NPAGE10762036
Ref: 2dc910762036
Ref: library/curses curses KEY_PPAGE10762129
Ref: 2dca10762129
Ref: library/curses curses KEY_STAB10762238
Ref: 2dcb10762238
Ref: library/curses curses KEY_CTAB10762346
Ref: 2dcc10762346
Ref: library/curses curses KEY_CATAB10762444
Ref: 2dcd10762444
Ref: library/curses curses KEY_ENTER10762543
Ref: 2dce10762543
Ref: library/curses curses KEY_SRESET10762654
Ref: 2dcf10762654
Ref: library/curses curses KEY_RESET10762848
Ref: 2dd010762848
Ref: library/curses curses KEY_PRINT10762980
Ref: 2dd110762980
Ref: library/curses curses KEY_LL10763074
Ref: 2dd210763074
Ref: library/curses curses KEY_A110763222
Ref: 2dd310763222
Ref: library/curses curses KEY_A310763348
Ref: 2dd410763348
Ref: library/curses curses KEY_B210763474
Ref: 2dd510763474
Ref: library/curses curses KEY_C110763600
Ref: 2dd610763600
Ref: library/curses curses KEY_C310763726
Ref: 2dd710763726
Ref: library/curses curses KEY_BTAB10763854
Ref: 2dd810763854
Ref: library/curses curses KEY_BEG10763957
Ref: 2dd910763957
Ref: library/curses curses KEY_CANCEL10764050
Ref: 2dda10764050
Ref: library/curses curses KEY_CLOSE10764140
Ref: 2ddb10764140
Ref: library/curses curses KEY_COMMAND10764223
Ref: 2ddc10764223
Ref: library/curses curses KEY_COPY10764323
Ref: 2ddd10764323
Ref: library/curses curses KEY_CREATE10764419
Ref: 2dde10764419
Ref: library/curses curses KEY_END10764515
Ref: 2ddf10764515
Ref: library/curses curses KEY_EXIT10764624
Ref: 2de010764624
Ref: library/curses curses KEY_FIND10764733
Ref: 2de110764733
Ref: library/curses curses KEY_HELP10764842
Ref: 2de210764842
Ref: library/curses curses KEY_MARK10764954
Ref: 2de310764954
Ref: library/curses curses KEY_MESSAGE10765050
Ref: 2de410765050
Ref: library/curses curses KEY_MOVE10765157
Ref: 2de510765157
Ref: library/curses curses KEY_NEXT10765266
Ref: 2de610765266
Ref: library/curses curses KEY_OPEN10765375
Ref: 2de710765375
Ref: library/curses curses KEY_OPTIONS10765468
Ref: 2de810765468
Ref: library/curses curses KEY_PREVIOUS10765549
Ref: 2de910765549
Ref: library/curses curses KEY_REDO10765644
Ref: 2dea10765644
Ref: library/curses curses KEY_REFERENCE10765743
Ref: 2deb10765743
Ref: library/curses curses KEY_REFRESH10765821
Ref: 2dec10765821
Ref: library/curses curses KEY_REPLACE10765903
Ref: 2ded10765903
Ref: library/curses curses KEY_RESTART10765985
Ref: 2dee10765985
Ref: library/curses curses KEY_RESUME10766070
Ref: 2def10766070
Ref: library/curses curses KEY_SAVE10766167
Ref: 2df010766167
Ref: library/curses curses KEY_SBEG10766276
Ref: 2df110766276
Ref: library/curses curses KEY_SCANCEL10766375
Ref: 2df210766375
Ref: library/curses curses KEY_SCOMMAND10766463
Ref: 2df310766463
Ref: library/curses curses KEY_SCOPY10766552
Ref: 2df410766552
Ref: library/curses curses KEY_SCREATE10766638
Ref: 2df510766638
Ref: library/curses curses KEY_SDC10766741
Ref: 2df610766741
Ref: library/curses curses KEY_SDL10766864
Ref: 2df710766864
Ref: library/curses curses KEY_SELECT10766972
Ref: 2df810766972
Ref: library/curses curses KEY_SEND10767069
Ref: 2df910767069
Ref: library/curses curses KEY_SEOL10767184
Ref: 2dfa10767184
Ref: library/curses curses KEY_SEXIT10767290
Ref: 2dfb10767290
Ref: library/curses curses KEY_SFIND10767376
Ref: 2dfc10767376
Ref: library/curses curses KEY_SHELP10767462
Ref: 2dfd10767462
Ref: library/curses curses KEY_SHOME10767548
Ref: 2dfe10767548
Ref: library/curses curses KEY_SIC10767649
Ref: 2dff10767649
Ref: library/curses curses KEY_SLEFT10767751
Ref: 2e0010767751
Ref: library/curses curses KEY_SMESSAGE10767843
Ref: 2e0110767843
Ref: library/curses curses KEY_SMOVE10767932
Ref: 2e0210767932
Ref: library/curses curses KEY_SNEXT10768018
Ref: 2e0310768018
Ref: library/curses curses KEY_SOPTIONS10768104
Ref: 2e0410768104
Ref: library/curses curses KEY_SPREVIOUS10768193
Ref: 2e0510768193
Ref: library/curses curses KEY_SPRINT10768279
Ref: 2e0610768279
Ref: library/curses curses KEY_SREDO10768366
Ref: 2e0710768366
Ref: library/curses curses KEY_SREPLACE10768452
Ref: 2e0810768452
Ref: library/curses curses KEY_SRIGHT10768541
Ref: 2e0910768541
Ref: library/curses curses KEY_SRSUME10768634
Ref: 2e0a10768634
Ref: library/curses curses KEY_SSAVE10768722
Ref: 2e0b10768722
Ref: library/curses curses KEY_SSUSPEND10768808
Ref: 2e0c10768808
Ref: library/curses curses KEY_SUNDO10768897
Ref: 2e0d10768897
Ref: library/curses curses KEY_SUSPEND10768983
Ref: 2e0e10768983
Ref: library/curses curses KEY_UNDO10769087
Ref: 2e0f10769087
Ref: library/curses curses KEY_MOUSE10769186
Ref: 2d1e10769186
Ref: library/curses curses KEY_RESIZE10769279
Ref: 2e1010769279
Ref: library/curses curses KEY_MAX10769390
Ref: 2e1110769390
Ref: library/curses curses-acs-codes10770593
Ref: 2e1210770593
Ref: library/curses curses ACS_BBSS10771257
Ref: 2e1310771257
Ref: library/curses curses ACS_BLOCK10771339
Ref: 2e1410771339
Ref: library/curses curses ACS_BOARD10771424
Ref: 2e1510771424
Ref: library/curses curses ACS_BSBS10771509
Ref: 2e1610771509
Ref: library/curses curses ACS_BSSB10771591
Ref: 2e1710771591
Ref: library/curses curses ACS_BSSS10771673
Ref: 2e1810771673
Ref: library/curses curses ACS_BTEE10771767
Ref: 2e1910771767
Ref: library/curses curses ACS_BULLET10771852
Ref: 2e1a10771852
Ref: library/curses curses ACS_CKBOARD10771930
Ref: 2e1b10771930
Ref: library/curses curses ACS_DARROW10772036
Ref: 2e1c10772036
Ref: library/curses curses ACS_DEGREE10772115
Ref: 2e1d10772115
Ref: library/curses curses ACS_DIAMOND10772188
Ref: 2e1e10772188
Ref: library/curses curses ACS_GEQUAL10772270
Ref: 2e1f10772270
Ref: library/curses curses ACS_HLINE10772355
Ref: 2d6010772355
Ref: library/curses curses ACS_LANTERN10772428
Ref: 2e2010772428
Ref: library/curses curses ACS_LARROW10772526
Ref: 2e2110772526
Ref: library/curses curses ACS_LEQUAL10772605
Ref: 2e2210772605
Ref: library/curses curses ACS_LLCORNER10772690
Ref: 2d6310772690
Ref: library/curses curses ACS_LRCORNER10772763
Ref: 2d6410772763
Ref: library/curses curses ACS_LTEE10772836
Ref: 2e2310772836
Ref: library/curses curses ACS_NEQUAL10772921
Ref: 2e2410772921
Ref: library/curses curses ACS_PI10773008
Ref: 2e2510773008
Ref: library/curses curses ACS_PLMINUS10773099
Ref: 2e2610773099
Ref: library/curses curses ACS_PLUS10773190
Ref: 2e2710773190
Ref: library/curses curses ACS_RARROW10773272
Ref: 2e2810773272
Ref: library/curses curses ACS_RTEE10773351
Ref: 2e2910773351
Ref: library/curses curses ACS_S110773450
Ref: 2e2a10773450
Ref: library/curses curses ACS_S310773566
Ref: 2e2b10773566
Ref: library/curses curses ACS_S710773682
Ref: 2e2c10773682
Ref: library/curses curses ACS_S910773798
Ref: 2e2d10773798
Ref: library/curses curses ACS_SBBS10773900
Ref: 2e2e10773900
Ref: library/curses curses ACS_SBSB10773982
Ref: 2e2f10773982
Ref: library/curses curses ACS_SBSS10774064
Ref: 2e3010774064
Ref: library/curses curses ACS_SSBB10774158
Ref: 2e3110774158
Ref: library/curses curses ACS_SSBS10774240
Ref: 2e3210774240
Ref: library/curses curses ACS_SSSB10774334
Ref: 2e3310774334
Ref: library/curses curses ACS_SSSS10774428
Ref: 2e3410774428
Ref: library/curses curses ACS_STERLING10774540
Ref: 2e3510774540
Ref: library/curses curses ACS_TTEE10774637
Ref: 2e3610774637
Ref: library/curses curses ACS_UARROW10774722
Ref: 2e3710774722
Ref: library/curses curses ACS_ULCORNER10774801
Ref: 2d6110774801
Ref: library/curses curses ACS_URCORNER10774874
Ref: 2d6210774874
Ref: library/curses curses ACS_VLINE10774947
Ref: 2d5f10774947
Ref: library/curses curses BUTTONn_PRESSED10775342
Ref: 2d1f10775342
Ref: library/curses curses BUTTONn_RELEASED10775490
Ref: 2d2010775490
Ref: library/curses curses BUTTONn_CLICKED10775637
Ref: 2d2110775637
Ref: library/curses curses BUTTONn_DOUBLE_CLICKED10775761
Ref: 2d2210775761
Ref: library/curses curses BUTTONn_TRIPLE_CLICKED10775876
Ref: 2d2310775876
Ref: library/curses curses BUTTON_SHIFT10776011
Ref: 2d2410776011
Ref: library/curses curses BUTTON_CTRL10776174
Ref: 2d2510776174
Ref: library/curses curses BUTTON_ALT10776339
Ref: 2d2610776339
Ref: library/curses curses COLOR_BLACK10776816
Ref: 2e3810776816
Ref: library/curses curses COLOR_BLUE10776885
Ref: 2e3910776885
Ref: library/curses curses COLOR_CYAN10776954
Ref: 2e3a10776954
Ref: library/curses curses COLOR_GREEN10777056
Ref: 2e3b10777056
Ref: library/curses curses COLOR_MAGENTA10777125
Ref: 2e3c10777125
Ref: library/curses curses COLOR_RED10777224
Ref: 2e3d10777224
Ref: library/curses curses COLOR_WHITE10777293
Ref: 2e3e10777293
Ref: library/curses curses COLOR_YELLOW10777362
Ref: 2e3f10777362
Node: curses textpad --- curses プログラムのためのテキスト入力ウィジェット10777420
Ref: library/curses curses-textpad-text-input-widget-for-curses-programs10777727
Ref: 2e4010777727
Ref: library/curses module-curses textpad10777727
Ref: 2610777727
Ref: library/curses curses textpad rectangle10778507
Ref: 2e4210778507
Node: Textbox オブジェクト10779364
Ref: library/curses curses-textpad-objects10779516
Ref: 2e4310779516
Ref: library/curses textbox-objects10779516
Ref: 2e4410779516
Ref: library/curses curses textpad Textbox10779701
Ref: 2e4110779701
Ref: library/curses curses textpad Textbox edit10780376
Ref: 2e4610780376
Ref: library/curses curses textpad Textbox do_command10781180
Ref: 2e4710781180
Ref: library/curses curses textpad Textbox gather10785496
Ref: 2e4810785496
Ref: library/curses curses textpad Textbox stripspaces10785748
Ref: 2e4510785748
Node: curses ascii --- ASCII 文字のユーティリティー10786292
Ref: library/curses ascii doc10786609
Ref: 2e4910786609
Ref: library/curses ascii curses-ascii-utilities-for-ascii-characters10786609
Ref: 2e4a10786609
Ref: library/curses ascii module-curses ascii10786609
Ref: 2410786609
Ref: library/curses ascii curses ascii NUL10787307
Ref: 2e4b10787307
Ref: library/curses ascii curses ascii SOH10787350
Ref: 2e4c10787350
Ref: library/curses ascii curses ascii STX10787453
Ref: 2e4d10787453
Ref: library/curses ascii curses ascii ETX10787523
Ref: 2e4e10787523
Ref: library/curses ascii curses ascii EOT10787593
Ref: 2e4f10787593
Ref: library/curses ascii curses ascii ENQ10787669
Ref: 2e5010787669
Ref: library/curses ascii curses ascii ACK10787784
Ref: 2e5110787784
Ref: library/curses ascii curses ascii BEL10787848
Ref: 2e5210787848
Ref: library/curses ascii curses ascii BS10787906
Ref: 2e5310787906
Ref: library/curses ascii curses ascii TAB10787972
Ref: 2e5410787972
Ref: library/curses ascii curses ascii HT10788030
Ref: 2e5510788030
Ref: library/curses ascii curses ascii LF10788123
Ref: 2e5610788123
Ref: library/curses ascii curses ascii NL10788180
Ref: 2e5710788180
Ref: library/curses ascii curses ascii VT10788266
Ref: 2e5810788266
Ref: library/curses ascii curses ascii FF10788329
Ref: 2e5910788329
Ref: library/curses ascii curses ascii CR10788386
Ref: 2e5a10788386
Ref: library/curses ascii curses ascii SO10788443
Ref: 2e5b10788443
Ref: library/curses ascii curses ascii SI10788545
Ref: 2e5c10788545
Ref: library/curses ascii curses ascii DLE10788647
Ref: 2e5d10788647
Ref: library/curses ascii curses ascii DC110788738
Ref: 2e5e10788738
Ref: library/curses ascii curses ascii DC210788838
Ref: 2e5f10788838
Ref: library/curses ascii curses ascii DC310788943
Ref: 2e6010788943
Ref: library/curses ascii curses ascii DC410789044
Ref: 2e6110789044
Ref: library/curses ascii curses ascii NAK10789110
Ref: 2e6210789110
Ref: library/curses ascii curses ascii SYN10789174
Ref: 2e6310789174
Ref: library/curses ascii curses ascii ETB10789238
Ref: 2e6410789238
Ref: library/curses ascii curses ascii CAN10789314
Ref: 2e6510789314
Ref: library/curses ascii curses ascii EM10789390
Ref: 2e6610789390
Ref: library/curses ascii curses ascii SUB10789453
Ref: 2e6710789453
Ref: library/curses ascii curses ascii ESC10789517
Ref: 2e6810789517
Ref: library/curses ascii curses ascii FS10789590
Ref: 2e6910789590
Ref: library/curses ascii curses ascii GS10789668
Ref: 2e6a10789668
Ref: library/curses ascii curses ascii RS10789746
Ref: 2e6b10789746
Ref: library/curses ascii curses ascii US10789857
Ref: 2e6c10789857
Ref: library/curses ascii curses ascii SP10789929
Ref: 2e6d10789929
Ref: library/curses ascii curses ascii DEL10789992
Ref: 2e6e10789992
Ref: library/curses ascii curses ascii isalnum10790455
Ref: 2e6f10790455
Ref: library/curses ascii curses ascii isalpha10790605
Ref: 2e7010790605
Ref: library/curses ascii curses ascii isascii10790769
Ref: 2e7110790769
Ref: library/curses ascii curses ascii isblank10790896
Ref: 2e7210790896
Ref: library/curses ascii curses ascii iscntrl10791034
Ref: 2e7310791034
Ref: library/curses ascii curses ascii isdigit10791180
Ref: 2e7410791180
Ref: library/curses ascii curses ascii isgraph10791383
Ref: 2e7510791383
Ref: library/curses ascii curses ascii islower10791501
Ref: 2e7610791501
Ref: library/curses ascii curses ascii isprint10791594
Ref: 2e7710791594
Ref: library/curses ascii curses ascii ispunct10791720
Ref: 2e7810791720
Ref: library/curses ascii curses ascii isspace10791856
Ref: 2e7910791856
Ref: library/curses ascii curses ascii isupper10792036
Ref: 2e7a10792036
Ref: library/curses ascii curses ascii isxdigit10792129
Ref: 2e7b10792129
Ref: library/curses ascii curses ascii isctrl10792278
Ref: 2e7c10792278
Ref: library/curses ascii curses ascii ismeta10792401
Ref: 2e7d10792401
Ref: library/curses ascii curses ascii ascii10793178
Ref: 2e7e10793178
Ref: library/curses ascii curses ascii ctrl10793297
Ref: 2e7f10793297
Ref: library/curses ascii curses ascii alt10793461
Ref: 2e8010793461
Ref: library/curses ascii curses ascii unctrl10793750
Ref: 2e8110793750
Ref: library/curses ascii curses ascii controlnames10794436
Ref: 2e8210794436
Ref: curses ascii --- ASCII 文字のユーティリティー-Footnote-110794711
Node: curses panel --- curses のためのパネルスタック拡張10794783
Ref: library/curses panel doc10795087
Ref: 2e8310795087
Ref: library/curses panel curses-panel-a-panel-stack-extension-for-curses10795087
Ref: 2e8410795087
Ref: library/curses panel module-curses panel10795087
Ref: 2510795087
Node: 関数<7>10795730
Ref: library/curses panel cursespanel-functions10795872
Ref: 2e8510795872
Ref: library/curses panel functions10795872
Ref: 2e8610795872
Ref: library/curses panel curses panel bottom_panel10795977
Ref: 2e8710795977
Ref: library/curses panel curses panel new_panel10796092
Ref: 2e8810796092
Ref: library/curses panel curses panel top_panel10796526
Ref: 2e8910796526
Ref: library/curses panel curses panel update_panels10796638
Ref: 2e8a10796638
Node: Panel オブジェクト10796918
Ref: library/curses panel curses-panel-objects10797060
Ref: 2e8b10797060
Ref: library/curses panel panel-objects10797060
Ref: 2e8c10797060
Ref: library/curses panel curses panel Panel above10797541
Ref: 2e8d10797541
Ref: library/curses panel curses panel Panel below10797642
Ref: 2e8e10797642
Ref: library/curses panel curses panel Panel bottom10797743
Ref: 2e8f10797743
Ref: library/curses panel curses panel Panel hidden10797848
Ref: 2e9010797848
Ref: library/curses panel curses panel Panel hide10798030
Ref: 2e9110798030
Ref: library/curses panel curses panel Panel move10798232
Ref: 2e9210798232
Ref: library/curses panel curses panel Panel replace10798344
Ref: 2e9310798344
Ref: library/curses panel curses panel Panel set_userptr10798469
Ref: 2e9410798469
Ref: library/curses panel curses panel Panel show10798753
Ref: 2e9510798753
Ref: library/curses panel curses panel Panel top10798850
Ref: 2e9610798850
Ref: library/curses panel curses panel Panel userptr10798952
Ref: 2e9710798952
Ref: library/curses panel curses panel Panel window10799090
Ref: 2e9810799090
Node: platform --- 実行中プラットフォームの固有情報を参照する10799222
Ref: library/platform doc10799520
Ref: 2e9910799520
Ref: library/platform module-platform10799520
Ref: 9810799520
Ref: library/platform platform-access-to-underlying-platform-s-identifying-data10799520
Ref: 2e9a10799520
Ref: platform --- 実行中プラットフォームの固有情報を参照する-Footnote-110800284
Node: クロスプラットフォーム10800352
Ref: library/platform cross-platform10800536
Ref: 2e9b10800536
Ref: library/platform platform architecture10800614
Ref: 15ef10800614
Ref: library/platform platform machine10802273
Ref: 2e9c10802273
Ref: library/platform platform node10802423
Ref: 2e9d10802423
Ref: library/platform platform platform10802640
Ref: 16c010802640
Ref: library/platform platform processor10803846
Ref: 2e9f10803846
Ref: library/platform platform python_build10804236
Ref: 2ea010804236
Ref: library/platform platform python_compiler10804386
Ref: 2ea110804386
Ref: library/platform platform python_branch10804542
Ref: 2ea210804542
Ref: library/platform platform python_implementation10804705
Ref: 2ea310804705
Ref: library/platform platform python_revision10804901
Ref: 2ea410804901
Ref: library/platform platform python_version10805069
Ref: 2ea510805069
Ref: library/platform platform python_version_tuple10805338
Ref: 2ea610805338
Ref: library/platform platform release10805627
Ref: 2ea710805627
Ref: library/platform platform system10805819
Ref: 1dc610805819
Ref: library/platform platform system_alias10806254
Ref: 2e9e10806254
Ref: library/platform platform version10806542
Ref: 2ea810806542
Ref: library/platform platform uname10806867
Ref: 199d10806867
Node: Java プラットフォーム10807692
Ref: library/platform java-platform10807917
Ref: 2ea910807917
Ref: library/platform platform java_ver10807990
Ref: 28710807990
Node: Windows プラットフォーム10808646
Ref: library/platform windows-platform10808868
Ref: 2eaa10808868
Ref: library/platform platform win32_ver10808947
Ref: 18c810808947
Ref: library/platform platform win32_edition10809776
Ref: 2eab10809776
Ref: library/platform platform win32_is_iot10810107
Ref: 2eac10810107
Node: macOS プラットフォーム10810334
Ref: library/platform macos-platform10810555
Ref: 2ead10810555
Ref: library/platform platform mac_ver10810630
Ref: 199f10810630
Node: iOS プラットフォーム10811028
Ref: library/platform ios-platform10811246
Ref: 2eae10811246
Ref: library/platform platform ios_ver10811317
Ref: 1dc510811317
Node: Unix プラットフォーム10812282
Ref: library/platform unix-platforms10812500
Ref: 2eaf10812500
Ref: library/platform platform libc_ver10812573
Ref: 199c10812573
Node: Linux プラットフォーム10813368
Ref: library/platform linux-platforms10813590
Ref: 2eb010813590
Ref: library/platform platform freedesktop_os_release10813665
Ref: 7f110813665
Ref: Linux プラットフォーム-Footnote-110815158
Node: Android プラットフォーム10815231
Ref: library/platform android-platform10815415
Ref: 2eb110815415
Ref: library/platform platform android_ver10815494
Ref: 15b010815494
Ref: Android プラットフォーム-Footnote-110816673
Ref: Android プラットフォーム-Footnote-210816752
Ref: Android プラットフォーム-Footnote-310816823
Ref: Android プラットフォーム-Footnote-410816895
Node: errno --- 標準の errno システムシンボル10816969
Ref: library/errno doc10817255
Ref: 2eb210817255
Ref: library/errno errno-standard-errno-system-symbols10817255
Ref: 2eb310817255
Ref: library/errno module-errno10817255
Ref: 4d10817255
Ref: library/errno errno errorcode10817755
Ref: 2eb410817755
Ref: library/errno errno EPERM10818494
Ref: 173710818494
Ref: library/errno errno ENOENT10818625
Ref: 220610818625
Ref: library/errno errno ESRCH10818761
Ref: 220a10818761
Ref: library/errno errno EINTR10818888
Ref: d5410818888
Ref: library/errno errno EIO10819020
Ref: 2eb510819020
Ref: library/errno errno ENXIO10819084
Ref: 2eb610819084
Ref: library/errno errno E2BIG10819221
Ref: 2eb710819221
Ref: library/errno errno ENOEXEC10819309
Ref: 2eb810819309
Ref: library/errno errno EBADF10819405
Ref: 92910819405
Ref: library/errno errno ECHILD10819500
Ref: 21ff10819500
Ref: library/errno errno EAGAIN10819630
Ref: 21fa10819630
Ref: library/errno errno ENOMEM10819749
Ref: 2eb910819749
Ref: library/errno errno EACCES10819834
Ref: 220910819834
Ref: library/errno errno EFAULT10819960
Ref: 2eba10819960
Ref: library/errno errno ENOTBLK10820037
Ref: 2ebb10820037
Ref: library/errno errno EBUSY10820137
Ref: 2ebc10820137
Ref: library/errno errno EEXIST10820255
Ref: 220510820255
Ref: library/errno errno EXDEV10820375
Ref: 2a9910820375
Ref: library/errno errno ENODEV10820472
Ref: 2ebd10820472
Ref: library/errno errno ENOTDIR10820570
Ref: 220810820570
Ref: library/errno errno EISDIR10820699
Ref: 220710820699
Ref: library/errno errno EINVAL10820825
Ref: 195a10820825
Ref: library/errno errno ENFILE10820901
Ref: 2ebe10820901
Ref: library/errno errno EMFILE10821019
Ref: 2ebf10821019
Ref: library/errno errno ENOTTY10821119
Ref: 2ec010821119
Ref: library/errno errno ETXTBSY10821213
Ref: 2ec110821213
Ref: library/errno errno EFBIG10821309
Ref: 2ec210821309
Ref: library/errno errno ENOSPC10821394
Ref: 2ec310821394
Ref: library/errno errno ESPIPE10821498
Ref: 2ec410821498
Ref: library/errno errno EROFS10821573
Ref: 2ec510821573
Ref: library/errno errno EMLINK10821686
Ref: 2ec610821686
Ref: library/errno errno EPIPE10821766
Ref: 220010821766
Ref: library/errno errno EDOM10821886
Ref: 2ec710821886
Ref: library/errno errno ERANGE10822017
Ref: 2ec810822017
Ref: library/errno errno EDEADLK10822144
Ref: 2ec910822144
Ref: library/errno errno ENAMETOOLONG10822261
Ref: 2eca10822261
Ref: library/errno errno ENOLCK10822357
Ref: 2ecb10822357
Ref: library/errno errno ENOSYS10822472
Ref: 173810822472
Ref: library/errno errno ENOTEMPTY10822571
Ref: 2ecc10822571
Ref: library/errno errno ELOOP10822677
Ref: 2ecd10822677
Ref: library/errno errno EWOULDBLOCK10822818
Ref: 21fc10822818
Ref: library/errno errno ENOMSG10822954
Ref: 2ece10822954
Ref: library/errno errno EIDRM10823073
Ref: 2ecf10823073
Ref: library/errno errno ECHRNG10823162
Ref: 2ed010823162
Ref: library/errno errno EL2NSYNC10823273
Ref: 2ed110823273
Ref: library/errno errno EL3HLT10823383
Ref: 2ed210823383
Ref: library/errno errno EL3RST10823469
Ref: 2ed310823469
Ref: library/errno errno ELNRNG10823560
Ref: 2ed410823560
Ref: library/errno errno EUNATCH10823668
Ref: 2ed510823668
Ref: library/errno errno ENOCSI10823798
Ref: 2ed610823798
Ref: library/errno errno EL2HLT10823894
Ref: 2ed710823894
Ref: library/errno errno EBADE10823980
Ref: 2ed810823980
Ref: library/errno errno EBADR10824055
Ref: 2ed910824055
Ref: library/errno errno EXFULL10824149
Ref: 2eda10824149
Ref: library/errno errno ENOANO10824234
Ref: 2edb10824234
Ref: library/errno errno EBADRQC10824305
Ref: 2edc10824305
Ref: library/errno errno EBADSLT10824404
Ref: 2edd10824404
Ref: library/errno errno EDEADLOCK10824483
Ref: 2ede10824483
Ref: library/errno errno EBFONT10824623
Ref: 2edf10824623
Ref: library/errno errno ENOSTR10824736
Ref: 2ee010824736
Ref: library/errno errno ENODATA10824839
Ref: 2ee110824839
Ref: library/errno errno ETIME10824938
Ref: 2ee210824938
Ref: library/errno errno ENOSR10825007
Ref: 2ee310825007
Ref: library/errno errno ENONET10825120
Ref: 2ee410825120
Ref: library/errno errno ENOPKG10825239
Ref: 2ee510825239
Ref: library/errno errno EREMOTE10825356
Ref: 2ee610825356
Ref: library/errno errno ENOLINK10825445
Ref: 2ee710825445
Ref: library/errno errno EADV10825536
Ref: 2ee810825536
Ref: library/errno errno ESRMNT10825613
Ref: 2ee910825613
Ref: library/errno errno ECOMM10825688
Ref: 2eea10825688
Ref: library/errno errno EPROTO10825786
Ref: 2eeb10825786
Ref: library/errno errno EMULTIHOP10825869
Ref: 2eec10825869
Ref: library/errno errno EDOTDOT10825962
Ref: 2eed10825962
Ref: library/errno errno EBADMSG10826048
Ref: 2eee10826048
Ref: library/errno errno EOVERFLOW10826151
Ref: 2eef10826151
Ref: library/errno errno ENOTUNIQ10826298
Ref: 2ef010826298
Ref: library/errno errno EBADFD10826422
Ref: 2ef110826422
Ref: library/errno errno EREMCHG10826534
Ref: 2ef210826534
Ref: library/errno errno ELIBACC10826641
Ref: 2ef310826641
Ref: library/errno errno ELIBBAD10826784
Ref: 2ef410826784
Ref: library/errno errno ELIBSCN10826925
Ref: 2ef510826925
Ref: library/errno errno ELIBMAX10827052
Ref: 2ef610827052
Ref: library/errno errno ELIBEXEC10827204
Ref: 2ef710827204
Ref: library/errno errno EILSEQ10827353
Ref: 2ef810827353
Ref: library/errno errno ERESTART10827440
Ref: 2ef910827440
Ref: library/errno errno ESTRPIPE10827601
Ref: 2efa10827601
Ref: library/errno errno EUSERS10827702
Ref: 2efb10827702
Ref: library/errno errno ENOTSOCK10827782
Ref: 2efc10827782
Ref: library/errno errno EDESTADDRREQ10827904
Ref: 2efd10827904
Ref: library/errno errno EMSGSIZE10828010
Ref: 2efe10828010
Ref: library/errno errno EPROTOTYPE10828100
Ref: 2eff10828100
Ref: library/errno errno ENOPROTOOPT10828235
Ref: 2f0010828235
Ref: library/errno errno EPROTONOSUPPORT10828340
Ref: 2f0110828340
Ref: library/errno errno ESOCKTNOSUPPORT10828461
Ref: 2f0210828461
Ref: library/errno errno EOPNOTSUPP10828585
Ref: 2f0310828585
Ref: library/errno errno ENOTSUP10828744
Ref: 2f0410828744
Ref: library/errno errno EPFNOSUPPORT10828832
Ref: 2f0510828832
Ref: library/errno errno EAFNOSUPPORT10828974
Ref: 2f0610828974
Ref: library/errno errno EADDRINUSE10829142
Ref: 2f0710829142
Ref: library/errno errno EADDRNOTAVAIL10829237
Ref: 2f0810829237
Ref: library/errno errno ENETDOWN10829376
Ref: 2f0910829376
Ref: library/errno errno ENETUNREACH10829477
Ref: 197210829477
Ref: library/errno errno ENETRESET10829585
Ref: 2f0a10829585
Ref: library/errno errno ECONNABORTED10829744
Ref: 220210829744
Ref: library/errno errno ECONNRESET10829899
Ref: 220410829899
Ref: library/errno errno ENOBUFS10830042
Ref: 175310830042
Ref: library/errno errno EISCONN10830146
Ref: 2f0b10830146
Ref: library/errno errno ENOTCONN10830278
Ref: 2f0c10830278
Ref: library/errno errno ESHUTDOWN10830396
Ref: 220110830396
Ref: library/errno errno ETOOMANYREFS10830554
Ref: 2f0d10830554
Ref: library/errno errno ETIMEDOUT10830685
Ref: 220b10830685
Ref: library/errno errno ECONNREFUSED10830814
Ref: 220310830814
Ref: library/errno errno EHOSTDOWN10830955
Ref: 2f0e10830955
Ref: library/errno errno EHOSTUNREACH10831057
Ref: 2f0f10831057
Ref: library/errno errno EALREADY10831157
Ref: 21fb10831157
Ref: library/errno errno EINPROGRESS10831298
Ref: 21fd10831298
Ref: library/errno errno ESTALE10831438
Ref: 2f1010831438
Ref: library/errno errno EUCLEAN10831542
Ref: 2f1110831542
Ref: library/errno errno ENOTNAM10831648
Ref: 2f1210831648
Ref: library/errno errno ENAVAIL10831766
Ref: 2f1310831766
Ref: library/errno errno EISNAM10831877
Ref: 2f1410831877
Ref: library/errno errno EREMOTEIO10831966
Ref: 2f1510831966
Ref: library/errno errno EDQUOT10832056
Ref: 2f1610832056
Ref: library/errno errno EQFULL10832151
Ref: 2f1710832151
Ref: library/errno errno ENOTCAPABLE10832246
Ref: 172a10832246
Ref: library/errno errno ECANCELED10832463
Ref: 2f1810832463
Ref: library/errno errno EOWNERDEAD10832548
Ref: 2f1910832548
Ref: library/errno errno ENOTRECOVERABLE10832626
Ref: 2f1a10832626
Node: ctypes --- Python 用の外部関数ライブラリ10832720
Ref: library/ctypes doc10832921
Ref: 2f1b10832921
Ref: library/ctypes ctypes-a-foreign-function-library-for-python10832921
Ref: 2f1c10832921
Ref: library/ctypes module-ctypes10832921
Ref: 2210832921
Ref: ctypes --- Python 用の外部関数ライブラリ-Footnote-110833606
Node: ctypes チュートリアル10833669
Ref: library/ctypes ctypes-ctypes-tutorial10833818
Ref: 2f1d10833818
Ref: library/ctypes ctypes-tutorial10833818
Ref: 2f1e10833818
Node: 動的リンクライブラリをロードする10835630
Ref: library/ctypes ctypes-loading-dynamic-link-libraries10835803
Ref: 2f2110835803
Ref: library/ctypes loading-dynamic-link-libraries10835803
Ref: 2f2210835803
Node: ロードしたdllから関数にアクセスする10838212
Ref: library/ctypes accessing-functions-from-loaded-dlls10838415
Ref: 2f2410838415
Ref: library/ctypes ctypes-accessing-functions-from-loaded-dlls10838415
Ref: 2f2510838415
Node: 関数を呼び出す10840948
Ref: library/ctypes calling-functions10841121
Ref: 2f2610841121
Ref: library/ctypes ctypes-calling-functions10841121
Ref: 2f2710841121
Node: 基本データ型10843855
Ref: library/ctypes ctypes-fundamental-data-types10844004
Ref: 2f2810844004
Ref: library/ctypes fundamental-data-types10844004
Ref: 2f2910844004
Node: 続・関数を呼び出す10852830
Ref: library/ctypes calling-functions-continued10852984
Ref: 2f3610852984
Ref: library/ctypes ctypes-calling-functions-continued10852984
Ref: 2f3710852984
Node: Calling variadic functions10854210
Ref: library/ctypes calling-variadic-functions10854400
Ref: 2f3810854400
Ref: library/ctypes ctypes-calling-variadic-functions10854400
Ref: 2f3910854400
Node: 自作のデータ型とともに関数を呼び出す10855097
Ref: library/ctypes calling-functions-with-your-own-custom-data-types10855327
Ref: 2f3b10855327
Ref: library/ctypes ctypes-calling-functions-with-own-custom-data-types10855327
Ref: 2f3c10855327
Node: 要求される引数の型を指定する 関数プロトタイプ10856234
Ref: library/ctypes ctypes-specifying-required-argument-types10856453
Ref: 2f3d10856453
Ref: library/ctypes specifying-the-required-argument-types-function-prototypes10856453
Ref: 2f3e10856453
Node: 戻り値の型10858375
Ref: library/ctypes ctypes-return-types10858604
Ref: 2f4010858604
Ref: library/ctypes return-types10858604
Ref: 2f4110858604
Node: ポインタを渡す または、パラメータの参照渡し10861845
Ref: library/ctypes ctypes-passing-pointers10862028
Ref: 2f4510862028
Ref: library/ctypes passing-pointers-or-passing-parameters-by-reference10862028
Ref: 2f4610862028
Node: 構造体と共用体10863387
Ref: library/ctypes ctypes-structures-unions10863616
Ref: 2f4810863616
Ref: library/ctypes structures-and-unions10863616
Ref: 2f4910863616
Ref: library/ctypes ctypes-structureunion-alignment-byte-order10865947
Ref: 2f4b10865947
Node: 構造体/共用体アライメントとバイトオーダー10866284
Ref: library/ctypes structure-union-alignment-and-byte-order10866506
Ref: 2f4c10866506
Node: 構造体と共用体におけるビットフィールド10867716
Ref: library/ctypes bit-fields-in-structures-and-unions10867923
Ref: 2f5010867923
Ref: library/ctypes ctypes-bit-fields-in-structures-unions10867923
Ref: 2f5110867923
Node: 配列10868542
Ref: library/ctypes arrays10868700
Ref: 2f5210868700
Ref: library/ctypes ctypes-arrays10868700
Ref: 2f5310868700
Node: ポインタ10870133
Ref: library/ctypes ctypes-pointers10870243
Ref: 2f5410870243
Ref: library/ctypes pointers10870243
Ref: 2f5510870243
Node: 型変換10873580
Ref: library/ctypes ctypes-type-conversions10873696
Ref: 2f5710873696
Ref: library/ctypes type-conversions10873696
Ref: 2f5810873696
Node: 不完全型10876671
Ref: library/ctypes ctypes-incomplete-types10876799
Ref: 2f5a10876799
Ref: library/ctypes incomplete-types10876799
Ref: 2f5b10876799
Node: コールバック関数10878501
Ref: library/ctypes callback-functions10878680
Ref: 2f5c10878680
Ref: library/ctypes ctypes-callback-functions10878680
Ref: 2f5d10878680
Node: dllからエクスポートされた値へアクセスする10883370
Ref: library/ctypes accessing-values-exported-from-dlls10883555
Ref: 2f6010883555
Ref: library/ctypes ctypes-accessing-values-exported-from-dlls10883555
Ref: 2f6110883555
Node: びっくり仰天10886879
Ref: library/ctypes ctypes-surprises10887070
Ref: 2f6410887070
Ref: library/ctypes surprises10887070
Ref: 2f6510887070
Node: 可変サイズのデータ型10889804
Ref: library/ctypes ctypes-variable-sized-data-types10889926
Ref: 2f6610889926
Ref: library/ctypes variable-sized-data-types10889926
Ref: 2f6710889926
Node: ctypesリファレンス10891590
Ref: library/ctypes ctypes-ctypes-reference10891739
Ref: 2f6910891739
Ref: library/ctypes ctypes-reference10891739
Ref: 2f6a10891739
Node: 共有ライブラリを見つける10892112
Ref: library/ctypes ctypes-finding-shared-libraries10892257
Ref: 2f6b10892257
Ref: library/ctypes finding-shared-libraries10892257
Ref: 2f6c10892257
Node: 共有ライブラリをロードする10895167
Ref: library/ctypes ctypes-loading-shared-libraries10895333
Ref: 2f6d10895333
Ref: library/ctypes loading-shared-libraries10895333
Ref: 2f6e10895333
Ref: library/ctypes ctypes CDLL10895612
Ref: 9b710895612
Ref: library/ctypes ctypes OleDLL10896810
Ref: 16dd10896810
Ref: library/ctypes ctypes WinDLL10897781
Ref: 16de10897781
Ref: library/ctypes ctypes PyDLL10898486
Ref: 16df10898486
Ref: library/ctypes ctypes PyDLL _handle10902985
Ref: 2f7410902985
Ref: library/ctypes ctypes PyDLL _name10903100
Ref: 2f7510903100
Ref: library/ctypes ctypes LibraryLoader10903462
Ref: 2f7610903462
Ref: library/ctypes ctypes LibraryLoader LoadLibrary10903970
Ref: 2f2310903970
Ref: 共有ライブラリをロードする-Footnote-110905820
Ref: 共有ライブラリをロードする-Footnote-210905886
Node: 外部関数10905932
Ref: library/ctypes ctypes-foreign-functions10906086
Ref: 2f7710906086
Ref: library/ctypes foreign-functions10906086
Ref: 2f7810906086
Ref: library/ctypes ctypes _CFuncPtr10906770
Ref: 2f7910906770
Ref: library/ctypes ctypes _CFuncPtr restype10907183
Ref: 2f4210907183
Ref: library/ctypes ctypes _CFuncPtr argtypes10907882
Ref: 2f3a10907882
Ref: library/ctypes ctypes _CFuncPtr errcheck10909123
Ref: 2f4410909123
Ref: library/ctypes ctypes ArgumentError10910405
Ref: 2f7a10910405
Node: 関数プロトタイプ10911063
Ref: library/ctypes ctypes-function-prototypes10911208
Ref: 2f7b10911208
Ref: library/ctypes function-prototypes10911208
Ref: 2f7c10911208
Ref: library/ctypes ctypes CFUNCTYPE10911924
Ref: 2f5e10911924
Ref: library/ctypes ctypes WINFUNCTYPE10912501
Ref: 2f5f10912501
Ref: library/ctypes ctypes PYFUNCTYPE10912886
Ref: 2f7d10912886
Node: ユーティリティー関数10919045
Ref: library/ctypes ctypes-utility-functions10919193
Ref: 2f7e10919193
Ref: library/ctypes utility-functions10919193
Ref: 2f7f10919193
Ref: library/ctypes ctypes addressof10919268
Ref: 2f8010919268
Ref: library/ctypes ctypes alignment10919585
Ref: 2f8110919585
Ref: library/ctypes ctypes byref10919797
Ref: 2f4710919797
Ref: library/ctypes ctypes cast10920442
Ref: 2f5910920442
Ref: library/ctypes ctypes create_string_buffer10920828
Ref: 2f3510920828
Ref: library/ctypes ctypes create_unicode_buffer10921820
Ref: 193a10921820
Ref: library/ctypes ctypes DllCanUnloadNow10922771
Ref: 2f8210922771
Ref: library/ctypes ctypes DllGetClassObject10923083
Ref: 2f8310923083
Ref: library/ctypes ctypes util find_library10923405
Ref: d1710923405
Ref: library/ctypes ctypes util find_msvcrt10923940
Ref: 2f8410923940
Ref: library/ctypes ctypes FormatError10924474
Ref: 2f8510924474
Ref: library/ctypes ctypes GetLastError10924771
Ref: 2f4310924771
Ref: library/ctypes ctypes get_errno10925142
Ref: 2f7010925142
Ref: library/ctypes ctypes get_last_error10925413
Ref: 2f7210925413
Ref: library/ctypes ctypes memmove10925704
Ref: 2f8610925704
Ref: library/ctypes ctypes memset10926027
Ref: 2f8710926027
Ref: library/ctypes ctypes POINTER10926375
Ref: 164b10926375
Ref: library/ctypes ctypes pointer10926603
Ref: 164a10926603
Ref: library/ctypes ctypes resize10926943
Ref: 2f6810926943
Ref: library/ctypes ctypes set_errno10927370
Ref: 2f7110927370
Ref: library/ctypes ctypes set_last_error10927726
Ref: 2f7310927726
Ref: library/ctypes ctypes sizeof10928082
Ref: 2f8810928082
Ref: library/ctypes ctypes string_at10928303
Ref: 2f8910928303
Ref: library/ctypes ctypes WinError10928616
Ref: 2f8a10928616
Ref: library/ctypes ctypes wstring_at10929163
Ref: 2f8b10929163
Node: データ型<3>10929522
Ref: library/ctypes ctypes-data-types10929667
Ref: 2f8c10929667
Ref: library/ctypes data-types10929667
Ref: 2f8d10929667
Ref: library/ctypes ctypes _CData10929712
Ref: 2f8e10929712
Ref: library/ctypes ctypes _CData from_buffer10930559
Ref: 2f9010930559
Ref: library/ctypes ctypes _CData from_buffer_copy10931382
Ref: 2f9110931382
Ref: library/ctypes ctypes _CData from_address10932090
Ref: 2f9210932090
Ref: library/ctypes ctypes _CData from_param10932520
Ref: 2f3f10932520
Ref: library/ctypes ctypes _CData in_dll10933158
Ref: 2f6210933158
Ref: library/ctypes ctypes _CData _b_base_10933567
Ref: 2f9310933567
Ref: library/ctypes ctypes _CData _b_needsfree_10933968
Ref: 2f9410933968
Ref: library/ctypes ctypes _CData _objects10934262
Ref: 2f8f10934262
Node: 基本データ型<2>10934690
Ref: library/ctypes ctypes-fundamental-data-types-210934826
Ref: 2f9510934826
Ref: library/ctypes id110934826
Ref: 2f9610934826
Ref: library/ctypes ctypes _SimpleCData10934881
Ref: 2f9710934881
Ref: library/ctypes ctypes _SimpleCData value10935476
Ref: 2f9810935476
Ref: library/ctypes ctypes c_byte10937049
Ref: 16db10937049
Ref: library/ctypes ctypes c_char10937326
Ref: 2f2b10937326
Ref: library/ctypes ctypes c_char_p10937613
Ref: 164c10937613
Ref: library/ctypes ctypes c_double10938033
Ref: 186510938033
Ref: library/ctypes ctypes c_longdouble10938213
Ref: 186610938213
Ref: library/ctypes ctypes c_float10938538
Ref: 2f3410938538
Ref: library/ctypes ctypes c_int10938716
Ref: 2f1f10938716
Ref: library/ctypes ctypes c_int810939071
Ref: 2f9910939071
Ref: library/ctypes ctypes c_int1610939219
Ref: 2f9a10939219
Ref: library/ctypes ctypes c_int3210939370
Ref: 2f9b10939370
Ref: library/ctypes ctypes c_int6410939519
Ref: 2f9c10939519
Ref: library/ctypes ctypes c_long10939673
Ref: 2f2010939673
Ref: library/ctypes ctypes c_longlong10939904
Ref: 2f3110939904
Ref: library/ctypes ctypes c_short10940150
Ref: 2f2d10940150
Ref: library/ctypes ctypes c_size_t10940383
Ref: 2f3310940383
Ref: library/ctypes ctypes c_ssize_t10940467
Ref: 120d10940467
Ref: library/ctypes ctypes c_time_t10940581
Ref: 174410940581
Ref: library/ctypes ctypes c_ubyte10940688
Ref: 16dc10940688
Ref: library/ctypes ctypes c_uint10940973
Ref: 2f2f10940973
Ref: library/ctypes ctypes c_uint810941345
Ref: 2f9d10941345
Ref: library/ctypes ctypes c_uint1610941497
Ref: 2f9e10941497
Ref: library/ctypes ctypes c_uint3210941652
Ref: 2f9f10941652
Ref: library/ctypes ctypes c_uint6410941805
Ref: 2fa010941805
Ref: library/ctypes ctypes c_ulong10941963
Ref: 2f3010941963
Ref: library/ctypes ctypes c_ulonglong10942197
Ref: 2f3210942197
Ref: library/ctypes ctypes c_ushort10942446
Ref: 2f2e10942446
Ref: library/ctypes ctypes c_void_p10942682
Ref: 164e10942682
Ref: library/ctypes ctypes c_wchar10942888
Ref: 2f2c10942888
Ref: library/ctypes ctypes c_wchar_p10943212
Ref: 164d10943212
Ref: library/ctypes ctypes c_bool10943470
Ref: 2f2a10943470
Ref: library/ctypes ctypes HRESULT10943749
Ref: 2f6f10943749
Ref: library/ctypes ctypes py_object10943914
Ref: 13df10943914
Node: 構造化データ型10944334
Ref: library/ctypes ctypes-structured-data-types10944476
Ref: 2fa110944476
Ref: library/ctypes structured-data-types10944476
Ref: 2fa210944476
Ref: library/ctypes ctypes Union10944536
Ref: 15e510944536
Ref: library/ctypes ctypes BigEndianUnion10944679
Ref: 179110944679
Ref: library/ctypes ctypes LittleEndianUnion10944878
Ref: 179210944878
Ref: library/ctypes ctypes BigEndianStructure10945080
Ref: 2f4e10945080
Ref: library/ctypes ctypes LittleEndianStructure10945254
Ref: 2f4f10945254
Ref: library/ctypes ctypes Structure10945672
Ref: 1b610945672
Ref: library/ctypes ctypes Structure _fields_10946275
Ref: 2f4a10946275
Ref: library/ctypes ctypes Structure _pack_10948397
Ref: 2f4d10948397
Ref: library/ctypes ctypes Structure _align_10948762
Ref: 1b710948762
Ref: library/ctypes ctypes Structure _anonymous_10949058
Ref: 2fa310949058
Node: 配列とポインタ10951979
Ref: library/ctypes arrays-and-pointers10952091
Ref: 2fa410952091
Ref: library/ctypes ctypes-arrays-pointers10952091
Ref: 2fa510952091
Ref: library/ctypes ctypes Array10952151
Ref: 199510952151
Ref: library/ctypes ctypes Array _length_10952851
Ref: 2fa610952851
Ref: library/ctypes ctypes Array _type_10953104
Ref: 2fa710953104
Ref: library/ctypes ctypes ARRAY10953352
Ref: 27c10953352
Ref: library/ctypes ctypes _Pointer10953649
Ref: 2fa810953649
Ref: library/ctypes ctypes _Pointer _type_10954542
Ref: 2fa910954542
Ref: library/ctypes ctypes _Pointer contents10954624
Ref: 2f5610954624
Node: 並行実行10954857
Ref: library/concurrency doc10955054
Ref: 2faa10955054
Ref: library/concurrency concurrency10955054
Ref: 2fab10955054
Ref: library/concurrency concurrent-execution10955054
Ref: 2fac10955054
Node: threading --- スレッドベースの並列処理10956418
Ref: library/threading doc10956582
Ref: 2fad10956582
Ref: library/threading module-threading10956582
Ref: d610956582
Ref: library/threading threading-thread-based-parallelism10956582
Ref: 2fae10956582
Ref: library/threading threading active_count10958853
Ref: 2e210958853
Ref: library/threading threading current_thread10959143
Ref: 2e110959143
Ref: library/threading threading excepthook10959637
Ref: 81610959637
Ref: library/threading threading __excepthook__10961011
Ref: 81510961011
Ref: library/threading threading get_ident10961288
Ref: 112d10961288
Ref: library/threading threading get_native_id10961806
Ref: a0c10961806
Ref: library/threading threading enumerate10962368
Ref: 181010962368
Ref: library/threading threading main_thread10962883
Ref: f9f10962883
Ref: library/threading threading settrace10963142
Ref: 81310963142
Ref: library/threading threading settrace_all_threads10963460
Ref: 49410963460
Ref: library/threading threading gettrace10963826
Ref: 81110963826
Ref: library/threading threading setprofile10963983
Ref: 81410963983
Ref: library/threading threading setprofile_all_threads10964316
Ref: 49510964316
Ref: library/threading threading getprofile10964688
Ref: 81210964688
Ref: library/threading threading stack_size10964861
Ref: 2faf10964861
Ref: library/threading threading TIMEOUT_MAX10966603
Ref: 2fb010966603
Ref: threading --- スレッドベースの並列処理-Footnote-110968425
Node: スレッドローカルデータ10968494
Ref: library/threading thread-local-data10968648
Ref: 2fb110968648
Ref: library/threading threading local10969153
Ref: 16d610969153
Ref: スレッドローカルデータ-Footnote-110969440
Node: Thread オブジェクト10969517
Ref: library/threading id110969703
Ref: 2fb210969703
Ref: library/threading thread-objects10969703
Ref: 2fb310969703
Ref: library/threading threading Thread10973629
Ref: 91a10973629
Ref: library/threading threading Thread start10975479
Ref: 2c7c10975479
Ref: library/threading threading Thread run10976055
Ref: a0b10976055
Ref: library/threading meth-thread-join10976999
Ref: 2fb410976999
Ref: library/threading threading Thread join10976999
Ref: 11b510976999
Ref: library/threading threading Thread name10978513
Ref: 2e010978513
Ref: library/threading threading Thread getName10978837
Ref: 2fb510978837
Ref: library/threading threading Thread setName10978871
Ref: 2df10978871
Ref: library/threading threading Thread ident10979096
Ref: 2b9d10979096
Ref: library/threading threading Thread native_id10979582
Ref: a0d10979582
Ref: library/threading threading Thread is_alive10980397
Ref: 91b10980397
Ref: library/threading threading Thread daemon10980835
Ref: 2de10980835
Ref: library/threading threading Thread isDaemon10981629
Ref: 2fb610981629
Ref: library/threading threading Thread setDaemon10981664
Ref: 2dd10981664
Node: Lock オブジェクト10981893
Ref: library/threading id210982070
Ref: 2fb710982070
Ref: library/threading lock-objects10982070
Ref: 2fb810982070
Ref: library/threading threading Lock10984165
Ref: 15db10984165
Ref: library/threading threading Lock acquire10984724
Ref: 66410984724
Ref: library/threading threading Lock release10986405
Ref: 129210986405
Ref: library/threading threading Lock locked10987146
Ref: 2fba10987146
Node: RLock オブジェクト10987246
Ref: library/threading id310987426
Ref: 2fbb10987426
Ref: library/threading rlock-objects10987426
Ref: 2fbc10987426
Ref: library/threading threading RLock10989015
Ref: 2bf10989015
Ref: library/threading threading RLock acquire10989758
Ref: e4610989758
Ref: library/threading threading RLock release10991790
Ref: 2fbd10991790
Node: Condition オブジェクト10992770
Ref: library/threading condition-objects10992955
Ref: 2fbe10992955
Ref: library/threading id410992955
Ref: 2fbf10992955
Ref: library/threading threading Condition10997028
Ref: 112810997028
Ref: library/threading threading Condition acquire10997815
Ref: 2fc010997815
Ref: library/threading threading Condition release10998078
Ref: 2fc110998078
Ref: library/threading threading Condition wait10998307
Ref: 181c10998307
Ref: library/threading threading Condition wait_for11000362
Ref: 2fc211000362
Ref: library/threading threading Condition notify11001669
Ref: 174711001669
Ref: library/threading threading Condition notify_all11002912
Ref: 2db11002912
Node: Semaphore オブジェクト11003423
Ref: library/threading id511003608
Ref: 2fc311003608
Ref: library/threading semaphore-objects11003608
Ref: 2fc411003608
Ref: library/threading threading Semaphore11004525
Ref: 112911004525
Ref: library/threading threading Semaphore acquire11005462
Ref: 122511005462
Ref: library/threading threading Semaphore release11006928
Ref: 2fc511006928
Ref: library/threading threading BoundedSemaphore11007497
Ref: 112a11007497
Node: Semaphore の例11008304
Ref: library/threading semaphore-example11008385
Ref: 2fc611008385
Ref: library/threading semaphore-examples11008385
Ref: 2fc711008385
Node: Event オブジェクト11009401
Ref: library/threading event-objects11009582
Ref: 2fc811009582
Ref: library/threading id611009582
Ref: 2fc911009582
Ref: library/threading threading Event11010165
Ref: 112b11010165
Ref: library/threading threading Event is_set11010778
Ref: 2dc11010778
Ref: library/threading threading Event set11010978
Ref: 2fca11010978
Ref: library/threading threading Event clear11011342
Ref: 2fcb11011342
Ref: library/threading threading Event wait11011685
Ref: 12f511011685
Node: Timer オブジェクト11012457
Ref: library/threading id711012637
Ref: 2fcc11012637
Ref: library/threading timer-objects11012637
Ref: 2fcd11012637
Ref: library/threading threading Timer11013433
Ref: 112c11013433
Ref: library/threading threading Timer cancel11013934
Ref: 2fce11013934
Node: バリアオブジェクト11014174
Ref: library/threading barrier-objects11014395
Ref: 2fcf11014395
Ref: library/threading threading Barrier11015538
Ref: 11b411015538
Ref: library/threading threading Barrier wait11016039
Ref: 2fd011016039
Ref: library/threading threading Barrier reset11017508
Ref: 2fd111017508
Ref: library/threading threading Barrier abort11018117
Ref: 2fd211018117
Ref: library/threading threading Barrier parties11018831
Ref: 2fd311018831
Ref: library/threading threading Barrier n_waiting11018935
Ref: 2fd411018935
Ref: library/threading threading Barrier broken11019038
Ref: 2fd511019038
Ref: library/threading threading BrokenBarrierError11019161
Ref: 11b611019161
Node: with 文でのロック・条件変数・セマフォの使い方11019388
Ref: library/threading using-locks-conditions-and-semaphores-in-the-with-statement11019576
Ref: 2fd611019576
Ref: library/threading with-locks11019576
Ref: 2fb911019576
Node: multiprocessing --- プロセスベースの並列処理11020471
Ref: library/multiprocessing doc11020738
Ref: 2fd711020738
Ref: library/multiprocessing module-multiprocessing11020738
Ref: 8611020738
Ref: library/multiprocessing multiprocessing-process-based-parallelism11020738
Ref: 2fd811020738
Ref: multiprocessing --- プロセスベースの並列処理-Footnote-111021333
Node: はじめに<7>11021406
Ref: library/multiprocessing introduction11021544
Ref: 2fd911021544
Node: Process クラス11023656
Ref: library/multiprocessing the-process-class11023767
Ref: 2fda11023767
Node: コンテキストと開始方式11025266
Ref: library/multiprocessing contexts-and-start-methods11025431
Ref: 2fdd11025431
Ref: library/multiprocessing multiprocessing-start-methods11025431
Ref: 2a911025431
Ref: コンテキストと開始方式-Footnote-111031496
Node: プロセス間でのオブジェクト交換11031561
Ref: library/multiprocessing exchanging-objects-between-processes11031733
Ref: 2fdf11031733
Node: プロセス間の同期11034069
Ref: library/multiprocessing synchronization-between-processes11034244
Ref: 2fe111034244
Node: プロセス間での状態の共有11035056
Ref: library/multiprocessing sharing-state-between-processes11035231
Ref: 2fe211035231
Node: ワーカープロセスのプールを使用11039467
Ref: library/multiprocessing using-a-pool-of-workers11039609
Ref: 2fea11039609
Node: リファレンス<2>11043328
Ref: library/multiprocessing reference11043514
Ref: 2feb11043514
Node: Process クラスと例外11044211
Ref: library/multiprocessing process-and-exceptions11044337
Ref: 2fec11044337
Ref: library/multiprocessing multiprocessing Process11044412
Ref: b2711044412
Ref: library/multiprocessing multiprocessing Process run11046122
Ref: 2fde11046122
Ref: library/multiprocessing multiprocessing Process start11047158
Ref: 2fdb11047158
Ref: library/multiprocessing multiprocessing Process join11047524
Ref: 2fef11047524
Ref: library/multiprocessing multiprocessing Process name11048518
Ref: 2fed11048518
Ref: library/multiprocessing multiprocessing Process is_alive11049130
Ref: 2ff111049130
Ref: library/multiprocessing multiprocessing Process daemon11049443
Ref: 2fee11049443
Ref: library/multiprocessing multiprocessing Process pid11050735
Ref: 2ff211050735
Ref: library/multiprocessing multiprocessing Process exitcode11050884
Ref: 2ff011050884
Ref: library/multiprocessing multiprocessing Process authkey11051482
Ref: 2ff311051482
Ref: library/multiprocessing multiprocessing Process sentinel11052154
Ref: 10b411052154
Ref: library/multiprocessing multiprocessing Process terminate11052816
Ref: 2ff511052816
Ref: library/multiprocessing multiprocessing Process kill11053860
Ref: b2611053860
Ref: library/multiprocessing multiprocessing Process close11054024
Ref: b2511054024
Ref: library/multiprocessing multiprocessing ProcessError11055459
Ref: 2ff611055459
Ref: library/multiprocessing multiprocessing BufferTooShort11055581
Ref: 2ff711055581
Ref: library/multiprocessing multiprocessing AuthenticationError11055944
Ref: 2ff811055944
Ref: library/multiprocessing multiprocessing TimeoutError11056057
Ref: 2ff911056057
Node: パイプ Pipe とキュー Queue11056226
Ref: library/multiprocessing pipes-and-queues11056373
Ref: 2ffa11056373
Ref: library/multiprocessing multiprocessing Pipe11061605
Ref: 2fe011061605
Ref: library/multiprocessing multiprocessing Queue11062184
Ref: 176711062184
Ref: library/multiprocessing multiprocessing Queue qsize11062948
Ref: 300511062948
Ref: library/multiprocessing multiprocessing Queue empty11063323
Ref: 155e11063323
Ref: library/multiprocessing multiprocessing Queue full11063683
Ref: 300611063683
Ref: library/multiprocessing multiprocessing Queue put11063955
Ref: 19a711063955
Ref: library/multiprocessing multiprocessing Queue put_nowait11064972
Ref: 300711064972
Ref: library/multiprocessing multiprocessing Queue get11065065
Ref: 19a811065065
Ref: library/multiprocessing multiprocessing Queue get_nowait11066009
Ref: 300211066009
Ref: library/multiprocessing multiprocessing Queue close11066311
Ref: 176811066311
Ref: library/multiprocessing multiprocessing Queue join_thread11066752
Ref: 300811066752
Ref: library/multiprocessing multiprocessing Queue cancel_join_thread11067555
Ref: 300311067555
Ref: library/multiprocessing multiprocessing SimpleQueue11069140
Ref: 8e211069140
Ref: library/multiprocessing multiprocessing SimpleQueue close11069313
Ref: 8e311069313
Ref: library/multiprocessing multiprocessing SimpleQueue empty11069630
Ref: 155f11069630
Ref: library/multiprocessing multiprocessing SimpleQueue get11069868
Ref: 300911069868
Ref: library/multiprocessing multiprocessing SimpleQueue put11069962
Ref: 300a11069962
Ref: library/multiprocessing multiprocessing JoinableQueue11070049
Ref: 2ffb11070049
Ref: library/multiprocessing multiprocessing JoinableQueue task_done11070310
Ref: 2ffe11070310
Ref: library/multiprocessing multiprocessing JoinableQueue join11071227
Ref: 300b11071227
Ref: パイプ Pipe とキュー Queue-Footnote-111071838
Node: その他<3>11071902
Ref: library/multiprocessing miscellaneous11072055
Ref: 300c11072055
Ref: library/multiprocessing multiprocessing active_children11072093
Ref: 300d11072093
Ref: library/multiprocessing multiprocessing cpu_count11072382
Ref: f3c11072382
Ref: library/multiprocessing multiprocessing current_process11073127
Ref: 300e11073127
Ref: library/multiprocessing multiprocessing parent_process11073363
Ref: 300f11073363
Ref: library/multiprocessing multiprocessing freeze_support11073633
Ref: 301011073633
Ref: library/multiprocessing multiprocessing get_all_start_methods11074886
Ref: f3611074886
Ref: library/multiprocessing multiprocessing get_context11075249
Ref: 2a711075249
Ref: library/multiprocessing multiprocessing get_start_method11075763
Ref: f3711075763
Ref: library/multiprocessing multiprocessing set_executable11076666
Ref: 177011076666
Ref: library/multiprocessing multiprocessing set_forkserver_preload11077394
Ref: 150211077394
Ref: library/multiprocessing multiprocessing set_start_method11078113
Ref: 2a811078113
Ref: その他<3>-Footnote-111079307
Node: Connection オブジェクト<2>11079372
Ref: library/multiprocessing connection-objects11079516
Ref: 301111079516
Ref: library/multiprocessing multiprocessing connection Connection11080032
Ref: 160e11080032
Ref: library/multiprocessing multiprocessing connection Connection send11080086
Ref: 301311080086
Ref: library/multiprocessing multiprocessing connection Connection recv11080543
Ref: 301411080543
Ref: library/multiprocessing multiprocessing connection Connection fileno11080916
Ref: 301511080916
Ref: library/multiprocessing multiprocessing connection Connection close11081055
Ref: 301611081055
Ref: library/multiprocessing multiprocessing connection Connection poll11081267
Ref: 301711081267
Ref: library/multiprocessing multiprocessing connection Connection send_bytes11081918
Ref: 301811081918
Ref: library/multiprocessing multiprocessing connection Connection recv_bytes11082529
Ref: 301911082529
Ref: library/multiprocessing multiprocessing connection Connection recv_bytes_into11083360
Ref: 301a11083360
Ref: library/multiprocessing multiprocessing-recv-pickle-security11085387
Ref: 301b11085387
Node: 同期プリミティブ11086260
Ref: library/multiprocessing synchronization-primitives11086424
Ref: 301c11086424
Ref: library/multiprocessing multiprocessing Barrier11086948
Ref: 2fe911086948
Ref: library/multiprocessing multiprocessing BoundedSemaphore11087147
Ref: 2fe711087147
Ref: library/multiprocessing multiprocessing Condition11087703
Ref: 2fe811087703
Ref: library/multiprocessing multiprocessing Event11088085
Ref: 17ce11088085
Ref: library/multiprocessing multiprocessing Lock11088183
Ref: 150411088183
Ref: library/multiprocessing multiprocessing Lock acquire11089344
Ref: 301d11089344
Ref: library/multiprocessing multiprocessing Lock release11091063
Ref: 301e11091063
Ref: library/multiprocessing multiprocessing RLock11091523
Ref: 150511091523
Ref: library/multiprocessing multiprocessing RLock acquire11092511
Ref: 301f11092511
Ref: library/multiprocessing multiprocessing RLock release11094746
Ref: 302011094746
Ref: library/multiprocessing multiprocessing Semaphore11096132
Ref: 2fe611096132
Ref: 同期プリミティブ-Footnote-111097294
Node: 共有 ctypes オブジェクト11097358
Ref: library/multiprocessing shared-ctypes-objects11097508
Ref: 302111097508
Ref: library/multiprocessing multiprocessing Value11097730
Ref: 2fe311097730
Ref: library/multiprocessing multiprocessing Array11099528
Ref: 2fe411099528
Node: multiprocessing sharedctypes モジュール11101234
Ref: library/multiprocessing module-multiprocessing sharedctypes11101347
Ref: 8c11101347
Ref: library/multiprocessing the-multiprocessing-sharedctypes-module11101347
Ref: 302211101347
Ref: library/multiprocessing multiprocessing sharedctypes RawArray11102172
Ref: 302311102172
Ref: library/multiprocessing multiprocessing sharedctypes RawValue11103236
Ref: 302511103236
Ref: library/multiprocessing multiprocessing sharedctypes Array11104252
Ref: 302411104252
Ref: library/multiprocessing multiprocessing sharedctypes Value11105171
Ref: 302611105171
Ref: library/multiprocessing multiprocessing sharedctypes copy11106085
Ref: 302711106085
Ref: library/multiprocessing multiprocessing sharedctypes synchronized11106283
Ref: dfe11106283
Node: マネージャー11109745
Ref: library/multiprocessing managers11109895
Ref: 302811109895
Ref: library/multiprocessing multiprocessing-managers11109895
Ref: 2fff11109895
Ref: library/multiprocessing multiprocessing Manager11110411
Ref: c8811110411
Ref: library/multiprocessing module-multiprocessing managers11110873
Ref: 8911110873
Ref: library/multiprocessing multiprocessing managers BaseManager11111110
Ref: 302a11111110
Ref: library/multiprocessing multiprocessing managers BaseManager start11112821
Ref: 302b11112821
Ref: library/multiprocessing multiprocessing managers BaseManager get_server11113127
Ref: 302d11113127
Ref: library/multiprocessing multiprocessing managers BaseManager connect11113740
Ref: 302f11113740
Ref: library/multiprocessing multiprocessing managers BaseManager shutdown11114056
Ref: 302c11114056
Ref: library/multiprocessing multiprocessing managers BaseManager register11114382
Ref: 303011114382
Ref: library/multiprocessing multiprocessing managers BaseManager address11117360
Ref: 302e11117360
Ref: library/multiprocessing multiprocessing managers SyncManager11118181
Ref: 302911118181
Ref: library/multiprocessing multiprocessing managers SyncManager Barrier11118662
Ref: 303311118662
Ref: library/multiprocessing multiprocessing managers SyncManager BoundedSemaphore11118891
Ref: 303411118891
Ref: library/multiprocessing multiprocessing managers SyncManager Condition11119084
Ref: 303511119084
Ref: library/multiprocessing multiprocessing managers SyncManager Event11119553
Ref: 303611119553
Ref: library/multiprocessing multiprocessing managers SyncManager Lock11119717
Ref: 303711119717
Ref: library/multiprocessing multiprocessing managers SyncManager Namespace11119879
Ref: 303811119879
Ref: library/multiprocessing multiprocessing managers SyncManager Queue11120041
Ref: 2c9611120041
Ref: library/multiprocessing multiprocessing managers SyncManager RLock11120210
Ref: 303911120210
Ref: library/multiprocessing multiprocessing managers SyncManager Semaphore11120373
Ref: 303a11120373
Ref: library/multiprocessing multiprocessing managers SyncManager Array11120552
Ref: 303b11120552
Ref: library/multiprocessing multiprocessing managers SyncManager Value11120675
Ref: 303c11120675
Ref: library/multiprocessing multiprocessing managers SyncManager dict11120840
Ref: 303d11120840
Ref: library/multiprocessing multiprocessing managers SyncManager list11121070
Ref: 303e11121070
Ref: library/multiprocessing multiprocessing managers Namespace11121580
Ref: 2fe511121580
Node: カスタマイズされたマネージャー11122608
Ref: library/multiprocessing customized-managers11122762
Ref: 303f11122762
Node: リモートマネージャーを使用する11123669
Ref: library/multiprocessing using-a-remote-manager11123823
Ref: 304011123823
Node: Proxy オブジェクト11126299
Ref: library/multiprocessing multiprocessing-proxy-objects11126438
Ref: c8711126438
Ref: library/multiprocessing proxy-objects11126438
Ref: 304111126438
Ref: library/multiprocessing multiprocessing managers BaseProxy11130469
Ref: 303111130469
Ref: library/multiprocessing multiprocessing managers BaseProxy _callmethod11130638
Ref: 303211130638
Ref: library/multiprocessing multiprocessing managers BaseProxy _getvalue11132411
Ref: 304211132411
Ref: library/multiprocessing multiprocessing managers BaseProxy __repr__11132584
Ref: 304311132584
Ref: library/multiprocessing multiprocessing managers BaseProxy __str__11132707
Ref: 304411132707
Node: クリーンアップ11132847
Ref: library/multiprocessing cleanup11132929
Ref: 304511132929
Node: プロセスプール11133408
Ref: library/multiprocessing module-multiprocessing pool11133562
Ref: 8a11133562
Ref: library/multiprocessing process-pools11133562
Ref: 304611133562
Ref: library/multiprocessing multiprocessing pool Pool11133739
Ref: f3811133739
Ref: library/multiprocessing multiprocessing pool Pool apply11137204
Ref: 304911137204
Ref: library/multiprocessing multiprocessing pool Pool apply_async11137655
Ref: 304a11137655
Ref: library/multiprocessing multiprocessing pool Pool map11138802
Ref: 10b611138802
Ref: library/multiprocessing multiprocessing pool Pool map_async11139735
Ref: 10b711139735
Ref: library/multiprocessing multiprocessing pool Pool imap11140885
Ref: 304c11140885
Ref: library/multiprocessing multiprocessing pool Pool imap_unordered11141760
Ref: 304d11141760
Ref: library/multiprocessing multiprocessing pool Pool starmap11142123
Ref: 10b811142123
Ref: library/multiprocessing multiprocessing pool Pool starmap_async11142569
Ref: 10b911142569
Ref: library/multiprocessing multiprocessing pool Pool close11143060
Ref: 304711143060
Ref: library/multiprocessing multiprocessing pool Pool terminate11143278
Ref: 304811143278
Ref: library/multiprocessing multiprocessing pool Pool join11143566
Ref: 304e11143566
Ref: library/multiprocessing multiprocessing pool AsyncResult11144257
Ref: 304b11144257
Ref: library/multiprocessing multiprocessing pool AsyncResult get11144427
Ref: 304f11144427
Ref: library/multiprocessing multiprocessing pool AsyncResult wait11144865
Ref: 305011144865
Ref: library/multiprocessing multiprocessing pool AsyncResult ready11144992
Ref: 305111144992
Ref: library/multiprocessing multiprocessing pool AsyncResult successful11145106
Ref: 305211145106
Node: リスナーとクライアント11146476
Ref: library/multiprocessing listeners-and-clients11146618
Ref: 305311146618
Ref: library/multiprocessing module-multiprocessing connection11146618
Ref: 8711146618
Ref: library/multiprocessing multiprocessing-listeners-clients11146618
Ref: 301211146618
Ref: library/multiprocessing multiprocessing connection deliver_challenge11147318
Ref: 305411147318
Ref: library/multiprocessing multiprocessing connection answer_challenge11147826
Ref: 305511147826
Ref: library/multiprocessing multiprocessing connection Client11148220
Ref: 305611148220
Ref: library/multiprocessing multiprocessing connection Listener11149080
Ref: 160d11149080
Ref: library/multiprocessing multiprocessing connection Listener accept11151206
Ref: 15c411151206
Ref: library/multiprocessing multiprocessing connection Listener close11151555
Ref: 305811151555
Ref: library/multiprocessing multiprocessing connection Listener address11152019
Ref: 305911152019
Ref: library/multiprocessing multiprocessing connection Listener last_accepted11152126
Ref: 305a11152126
Ref: library/multiprocessing multiprocessing connection wait11152753
Ref: 10b311152753
Node: アドレスフォーマット11157123
Ref: library/multiprocessing address-formats11157223
Ref: 305b11157223
Ref: library/multiprocessing multiprocessing-address-formats11157223
Ref: 305711157223
Node: 認証キー11158131
Ref: library/multiprocessing authentication-keys11158267
Ref: 305c11158267
Ref: library/multiprocessing multiprocessing-auth-keys11158267
Ref: 2ff411158267
Node: ログ記録<2>11159815
Ref: library/multiprocessing logging11159955
Ref: 305d11159955
Ref: library/multiprocessing multiprocessing get_logger11160322
Ref: 305e11160322
Ref: library/multiprocessing multiprocessing log_to_stderr11160932
Ref: 305f11160932
Node: multiprocessing dummy モジュール11162202
Ref: library/multiprocessing module-multiprocessing dummy11162321
Ref: 8811162321
Ref: library/multiprocessing the-multiprocessing-dummy-module11162321
Ref: 306011162321
Ref: library/multiprocessing multiprocessing pool ThreadPool11162872
Ref: 187b11162872
Node: プログラミングガイドライン11164667
Ref: library/multiprocessing multiprocessing-programming11164851
Ref: 2fdc11164851
Ref: library/multiprocessing programming-guidelines11164851
Ref: 306111164851
Node: すべての開始方式について11165176
Ref: library/multiprocessing all-start-methods11165349
Ref: 306211165349
Ref: すべての開始方式について-Footnote-111172673
Ref: すべての開始方式について-Footnote-211172737
Ref: すべての開始方式について-Footnote-311172801
Node: 開始方式が spawn および forkserver の場合11172865
Ref: library/multiprocessing the-spawn-and-forkserver-start-methods11173038
Ref: 306311173038
Ref: library/multiprocessing multiprocessing-safe-main-import11174053
Ref: 306411174053
Node: 使用例<20>11175561
Ref: library/multiprocessing examples11175715
Ref: 306511175715
Ref: library/multiprocessing multiprocessing-examples11175715
Ref: 300411175715
Node: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ11184733
Ref: library/multiprocessing shared_memory doc11184976
Ref: 306611184976
Ref: library/multiprocessing shared_memory module-multiprocessing shared_memory11184976
Ref: 8b11184976
Ref: library/multiprocessing shared_memory multiprocessing-shared-memory-shared-memory-for-direct-access-across-processes11184976
Ref: 306711184976
Ref: library/multiprocessing shared_memory multiprocessing shared_memory SharedMemory11186668
Ref: 15bd11186668
Ref: library/multiprocessing shared_memory multiprocessing shared_memory SharedMemory close11189982
Ref: 306911189982
Ref: library/multiprocessing shared_memory multiprocessing shared_memory SharedMemory unlink11190465
Ref: 306a11190465
Ref: library/multiprocessing shared_memory multiprocessing shared_memory SharedMemory buf11191091
Ref: 306b11191091
Ref: library/multiprocessing shared_memory multiprocessing shared_memory SharedMemory name11191180
Ref: 306c11191180
Ref: library/multiprocessing shared_memory multiprocessing shared_memory SharedMemory size11191291
Ref: 306d11191291
Ref: library/multiprocessing shared_memory multiprocessing managers SharedMemoryManager11194381
Ref: 306811194381
Ref: library/multiprocessing shared_memory multiprocessing managers SharedMemoryManager SharedMemory11195785
Ref: 306e11195785
Ref: library/multiprocessing shared_memory multiprocessing managers SharedMemoryManager ShareableList11195943
Ref: 306f11195943
Ref: library/multiprocessing shared_memory multiprocessing shared_memory ShareableList11197804
Ref: 18da11197804
Ref: library/multiprocessing shared_memory multiprocessing shared_memory ShareableList count11200304
Ref: 307011200304
Ref: library/multiprocessing shared_memory multiprocessing shared_memory ShareableList index11200398
Ref: 307111200398
Ref: library/multiprocessing shared_memory multiprocessing shared_memory ShareableList format11200554
Ref: 307211200554
Ref: library/multiprocessing shared_memory multiprocessing shared_memory ShareableList shm11200708
Ref: 307311200708
Ref: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ-Footnote-111203299
Ref: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ-Footnote-211203389
Ref: multiprocessing shared_memory --- プロセス間で直接アクセス可能な共有メモリ-Footnote-311203416
Node: concurrent パッケージ11203472
Ref: library/concurrent doc11203703
Ref: 307411203703
Ref: library/concurrent the-concurrent-package11203703
Ref: 307511203703
Node: concurrent futures --- 並列タスク実行11203926
Ref: library/concurrent futures doc11204102
Ref: 307611204102
Ref: library/concurrent futures concurrent-futures-launching-parallel-tasks11204102
Ref: 307711204102
Ref: library/concurrent futures module-concurrent futures11204102
Ref: 1a11204102
Ref: concurrent futures --- 並列タスク実行-Footnote-111205351
Ref: concurrent futures --- 並列タスク実行-Footnote-211205437
Node: Executor オブジェクト11205524
Ref: library/concurrent futures executor-objects11205659
Ref: 307911205659
Ref: library/concurrent futures concurrent futures Executor11205728
Ref: 307811205728
Ref: library/concurrent futures concurrent futures Executor submit11205977
Ref: a5011205977
Ref: library/concurrent futures concurrent futures Executor map11206483
Ref: db111206483
Ref: library/concurrent futures concurrent futures Executor shutdown11208045
Ref: 8bb11208045
Node: ThreadPoolExecutor11210465
Ref: library/concurrent futures threadpoolexecutor11210628
Ref: 307a11210628
Ref: library/concurrent futures concurrent futures ThreadPoolExecutor11211799
Ref: 70d11211799
Node: ThreadPoolExecutor の例11214361
Ref: library/concurrent futures id111214441
Ref: 307c11214441
Ref: library/concurrent futures threadpoolexecutor-example11214441
Ref: 118311214441
Node: ProcessPoolExecutor11215645
Ref: library/concurrent futures processpoolexecutor11215806
Ref: 307d11215806
Ref: library/concurrent futures concurrent futures ProcessPoolExecutor11216744
Ref: 8bc11216744
Node: ProcessPoolExecutor の例11220393
Ref: library/concurrent futures id211220475
Ref: 307f11220475
Ref: library/concurrent futures processpoolexecutor-example11220475
Ref: 118411220475
Node: Future オブジェクト11221377
Ref: library/concurrent futures future-objects11221544
Ref: 308011221544
Ref: library/concurrent futures concurrent futures Future11221837
Ref: 118211221837
Ref: library/concurrent futures concurrent futures Future cancel11222138
Ref: 308111222138
Ref: library/concurrent futures concurrent futures Future cancelled11222443
Ref: 308211222443
Ref: library/concurrent futures concurrent futures Future running11222576
Ref: 308311222576
Ref: library/concurrent futures concurrent futures Future done11222730
Ref: 308411222730
Ref: library/concurrent futures concurrent futures Future result11222884
Ref: 308511222884
Ref: library/concurrent futures concurrent futures Future exception11223690
Ref: 308611223690
Ref: library/concurrent futures concurrent futures Future add_done_callback11224523
Ref: 308711224523
Ref: library/concurrent futures concurrent futures Future set_running_or_notify_cancel11225692
Ref: 308811225692
Ref: library/concurrent futures concurrent futures Future set_result11226956
Ref: 308911226956
Ref: library/concurrent futures concurrent futures Future set_exception11227448
Ref: 308a11227448
Node: モジュール関数<2>11227970
Ref: library/concurrent futures module-functions11228133
Ref: 308b11228133
Ref: library/concurrent futures concurrent futures wait11228189
Ref: 17cd11228189
Ref: library/concurrent futures concurrent futures FIRST_COMPLETED11229568
Ref: 308c11229568
Ref: library/concurrent futures concurrent futures FIRST_EXCEPTION11229911
Ref: 308d11229911
Ref: library/concurrent futures concurrent futures ALL_COMPLETED11230435
Ref: 308e11230435
Ref: library/concurrent futures concurrent futures as_completed11230663
Ref: 15b111230663
Ref: モジュール関数<2>-Footnote-111231685
Node: 例外クラス11231727
Ref: library/concurrent futures exception-classes11231856
Ref: 308f11231856
Ref: library/concurrent futures concurrent futures CancelledError11231902
Ref: 9a811231902
Ref: library/concurrent futures concurrent futures TimeoutError11232020
Ref: 309011232020
Ref: library/concurrent futures concurrent futures BrokenExecutor11232309
Ref: 309111232309
Ref: library/concurrent futures concurrent futures InvalidStateError11232564
Ref: 156f11232564
Ref: library/concurrent futures concurrent futures thread BrokenThreadPool11232745
Ref: 307b11232745
Ref: library/concurrent futures concurrent futures process BrokenProcessPool11233002
Ref: 307e11233002
Node: subprocess --- サブプロセス管理11233367
Ref: library/subprocess doc11233560
Ref: 309211233560
Ref: library/subprocess module-subprocess11233560
Ref: c111233560
Ref: library/subprocess subprocess-subprocess-management11233560
Ref: 309311233560
Ref: subprocess --- サブプロセス管理-Footnote-111234887
Ref: subprocess --- サブプロセス管理-Footnote-211234957
Node: subprocess モジュールを使う11234999
Ref: library/subprocess using-the-subprocess-module11235161
Ref: 309411235161
Ref: library/subprocess subprocess run11235532
Ref: b5411235532
Ref: library/subprocess subprocess CompletedProcess11240943
Ref: e3c11240943
Ref: library/subprocess subprocess CompletedProcess args11241078
Ref: 309911241078
Ref: library/subprocess subprocess CompletedProcess returncode11241243
Ref: 309a11241243
Ref: library/subprocess subprocess CompletedProcess stdout11241586
Ref: 309b11241586
Ref: library/subprocess subprocess CompletedProcess stderr11242216
Ref: 309c11242216
Ref: library/subprocess subprocess CompletedProcess check_returncode11242611
Ref: 309d11242611
Ref: library/subprocess subprocess DEVNULL11242809
Ref: 112111242809
Ref: library/subprocess subprocess PIPE11243074
Ref: b5511243074
Ref: library/subprocess subprocess STDOUT11243354
Ref: 309611243354
Ref: library/subprocess subprocess SubprocessError11243576
Ref: 309e11243576
Ref: library/subprocess subprocess TimeoutExpired11243735
Ref: 309811243735
Ref: library/subprocess subprocess TimeoutExpired cmd11243957
Ref: 309f11243957
Ref: library/subprocess subprocess TimeoutExpired timeout11244057
Ref: 30a011244057
Ref: library/subprocess subprocess TimeoutExpired output11244125
Ref: 30a111244125
Ref: library/subprocess subprocess TimeoutExpired stdout11244614
Ref: 30a211244614
Ref: library/subprocess subprocess TimeoutExpired stderr11244717
Ref: 30a311244717
Ref: library/subprocess subprocess CalledProcessError11245352
Ref: 12f311245352
Ref: library/subprocess subprocess CalledProcessError returncode11245716
Ref: 30a511245716
Ref: library/subprocess subprocess CalledProcessError cmd11245936
Ref: 30a611245936
Ref: library/subprocess subprocess CalledProcessError output11246036
Ref: 30a711246036
Ref: library/subprocess subprocess CalledProcessError stdout11246264
Ref: 30a811246264
Ref: library/subprocess subprocess CalledProcessError stderr11246367
Ref: 30a911246367
Node: よく使われる引数11246764
Ref: library/subprocess frequently-used-arguments11246899
Ref: 309511246899
Ref: library/subprocess id111246899
Ref: 30aa11246899
Node: Popen コンストラクター11251811
Ref: library/subprocess popen-constructor11251965
Ref: 30af11251965
Ref: library/subprocess subprocess Popen11252365
Ref: 17e11252365
Ref: Popen コンストラクター-Footnote-111272543
Node: 例外<10>11272603
Ref: library/subprocess exceptions11272724
Ref: 30c011272724
Node: セキュリティで考慮すべき点<2>11274088
Ref: library/subprocess security-considerations11274283
Ref: 30ae11274283
Ref: library/subprocess subprocess-security11274283
Ref: 30c111274283
Ref: セキュリティで考慮すべき点<2>-Footnote-111275416
Ref: セキュリティで考慮すべき点<2>-Footnote-211275486
Node: Popen オブジェクト11275542
Ref: library/subprocess popen-objects11275728
Ref: 30c311275728
Ref: library/subprocess subprocess Popen poll11275897
Ref: 30c411275897
Ref: library/subprocess subprocess Popen wait11276120
Ref: cb211276120
Ref: library/subprocess subprocess Popen communicate11277315
Ref: 309711277315
Ref: library/subprocess subprocess Popen send_signal11279445
Ref: 138611279445
Ref: library/subprocess subprocess Popen terminate11279868
Ref: 138411279868
Ref: library/subprocess subprocess Popen kill11280093
Ref: 138511280093
Ref: library/subprocess subprocess Popen args11280454
Ref: 30c511280454
Ref: library/subprocess subprocess Popen stdin11280662
Ref: 30ab11280662
Ref: library/subprocess subprocess Popen stdout11281103
Ref: 30ac11281103
Ref: library/subprocess subprocess Popen stderr11281616
Ref: 30ad11281616
Ref: library/subprocess subprocess Popen pid11282484
Ref: 30c611282484
Ref: library/subprocess subprocess Popen returncode11282698
Ref: 191311282698
Node: Windows Popen ヘルパー11283230
Ref: library/subprocess windows-popen-helpers11283393
Ref: 30c711283393
Ref: library/subprocess subprocess STARTUPINFO11283561
Ref: 30b311283561
Ref: library/subprocess subprocess STARTUPINFO dwFlags11284026
Ref: 30c811284026
Ref: library/subprocess subprocess STARTUPINFO hStdInput11284383
Ref: 30c911284383
Ref: library/subprocess subprocess STARTUPINFO hStdOutput11284731
Ref: 30cb11284731
Ref: library/subprocess subprocess STARTUPINFO hStdError11285089
Ref: 30cc11285089
Ref: library/subprocess subprocess STARTUPINFO wShowWindow11285458
Ref: 30cd11285458
Ref: library/subprocess subprocess STARTUPINFO lpAttributeList11286028
Ref: bdc11286028
Ref: Windows Popen ヘルパー-Footnote-111287283
Ref: Windows Popen ヘルパー-Footnote-211287355
Ref: Windows Popen ヘルパー-Footnote-311287427
Node: Windows Constants11287516
Ref: library/subprocess windows-constants11287596
Ref: 30d011287596
Ref: library/subprocess subprocess STD_INPUT_HANDLE11287738
Ref: 30d111287738
Ref: library/subprocess subprocess STD_OUTPUT_HANDLE11287907
Ref: 30d211287907
Ref: library/subprocess subprocess STD_ERROR_HANDLE11288091
Ref: 30d311288091
Ref: library/subprocess subprocess SW_HIDE11288277
Ref: 30cf11288277
Ref: library/subprocess subprocess STARTF_USESTDHANDLES11288409
Ref: 30ca11288409
Ref: library/subprocess subprocess STARTF_USESHOWWINDOW11288647
Ref: 30ce11288647
Ref: library/subprocess subprocess STARTF_FORCEONFEEDBACK11288803
Ref: 30d411288803
Ref: library/subprocess subprocess STARTF_FORCEOFFFEEDBACK11289102
Ref: 30d511289102
Ref: library/subprocess subprocess CREATE_NEW_CONSOLE11289317
Ref: 30b411289317
Ref: library/subprocess subprocess CREATE_NEW_PROCESS_GROUP11289530
Ref: 30b511289530
Ref: library/subprocess subprocess ABOVE_NORMAL_PRIORITY_CLASS11289947
Ref: 30b611289947
Ref: library/subprocess subprocess BELOW_NORMAL_PRIORITY_CLASS11290158
Ref: 30b711290158
Ref: library/subprocess subprocess HIGH_PRIORITY_CLASS11290368
Ref: 30b811290368
Ref: library/subprocess subprocess IDLE_PRIORITY_CLASS11290561
Ref: 30b911290561
Ref: library/subprocess subprocess NORMAL_PRIORITY_CLASS11290764
Ref: 30ba11290764
Ref: library/subprocess subprocess REALTIME_PRIORITY_CLASS11290972
Ref: 30bb11290972
Ref: library/subprocess subprocess CREATE_NO_WINDOW11291509
Ref: 30bc11291509
Ref: library/subprocess subprocess DETACHED_PROCESS11291698
Ref: 30bd11291698
Ref: library/subprocess subprocess CREATE_DEFAULT_ERROR_MODE11291957
Ref: 30be11291957
Ref: library/subprocess subprocess CREATE_BREAKAWAY_FROM_JOB11292364
Ref: 30bf11292364
Node: 古い高水準 API11292568
Ref: library/subprocess call-function-trio11292767
Ref: 30d611292767
Ref: library/subprocess older-high-level-api11292767
Ref: 30d711292767
Ref: library/subprocess subprocess call11293136
Ref: b5611293136
Ref: library/subprocess subprocess check_call11294920
Ref: 30a411294920
Ref: library/subprocess subprocess check_output11296962
Ref: f8e11296962
Node: 古い関数を subprocess モジュールで置き換える11299969
Ref: library/subprocess replacing-older-functions-with-the-subprocess-module11300184
Ref: 30d811300184
Ref: library/subprocess subprocess-replacements11300184
Ref: 115b11300184
Node: Replacing /bin/sh shell command substitution11301606
Ref: library/subprocess replacing-bin-sh-shell-command-substitution11301804
Ref: 30d911301804
Node: シェルのパイプラインを置き換える11302041
Ref: library/subprocess replacing-shell-pipeline11302276
Ref: 30da11302276
Node: os system を置き換える11303114
Ref: library/subprocess replacing-os-system11303341
Ref: 30db11303341
Node: os spawn 関数群を置き換える11304333
Ref: library/subprocess replacing-the-os-spawn-family11304559
Ref: 30dc11304559
Node: os popen os popen2 os popen3 を置き換える11305217
Ref: library/subprocess replacing-os-popen-os-popen2-os-popen311305457
Ref: 30dd11305457
Node: Replacing functions from the popen2 module11306791
Ref: library/subprocess replacing-functions-from-the-popen2-module11306986
Ref: 30de11306986
Node: レガシーなシェル呼び出し関数11308537
Ref: library/subprocess legacy-shell-invocation-functions11308742
Ref: 30df11308742
Ref: library/subprocess subprocess getstatusoutput11309196
Ref: f8f11309196
Ref: library/subprocess subprocess getoutput11310575
Ref: 176611310575
Node: 注釈<2>11311180
Ref: library/subprocess notes11311316
Ref: 30e011311316
Node: Windows における引数シーケンスから文字列への変換11311516
Ref: library/subprocess converting-an-argument-sequence-to-a-string-on-windows11311676
Ref: 30e111311676
Ref: library/subprocess converting-argument-sequence11311676
Ref: 30b011311676
Ref: library/subprocess disable-vfork11313189
Ref: 30e211313189
Node: Disabling use of vfork or posix_spawn11313189
Ref: library/subprocess disable-posix-spawn11313349
Ref: 30e311313349
Ref: library/subprocess disabling-use-of-vfork-or-posix-spawn11313349
Ref: 30e411313349
Node: sched --- イベントスケジューラー11314764
Ref: library/sched doc11314947
Ref: 30e511314947
Ref: library/sched module-sched11314947
Ref: ad11314947
Ref: library/sched sched-event-scheduler11314947
Ref: 30e611314947
Ref: library/sched sched scheduler11315293
Ref: 10fa11315293
Ref: sched --- イベントスケジューラー-Footnote-111317784
Node: スケジューラオブジェクト11317849
Ref: library/sched id111317965
Ref: 30e711317965
Ref: library/sched scheduler-objects11317965
Ref: 30e811317965
Ref: library/sched sched scheduler enterabs11318144
Ref: 10fc11318144
Ref: library/sched sched scheduler enter11319335
Ref: 10fb11319335
Ref: library/sched sched scheduler cancel11319813
Ref: 189a11319813
Ref: library/sched sched scheduler empty11320068
Ref: 30e911320068
Ref: library/sched sched scheduler run11320188
Ref: 10f911320188
Ref: library/sched sched scheduler queue11321702
Ref: 30ea11321702
Node: queue --- 同期キュークラス11322032
Ref: library/queue doc11322216
Ref: 30eb11322216
Ref: library/queue module-queue11322216
Ref: a411322216
Ref: library/queue queue-a-synchronized-queue-class11322216
Ref: 30ec11322216
Ref: library/queue queue Queue11323990
Ref: 135611323990
Ref: library/queue queue LifoQueue11324396
Ref: 21b411324396
Ref: library/queue queue PriorityQueue11324806
Ref: 21b511324806
Ref: library/queue queue SimpleQueue11325893
Ref: b3811325893
Ref: library/queue queue Empty11326073
Ref: 300011326073
Ref: library/queue queue Full11326305
Ref: 300111326305
Ref: library/queue queue ShutDown11326539
Ref: 21c11326539
Ref: queue --- 同期キュークラス-Footnote-111326850
Node: キューオブジェクト11326915
Ref: library/queue queue-objects11327052
Ref: 30ef11327052
Ref: library/queue queueobjects11327052
Ref: 30f011327052
Ref: library/queue queue Queue qsize11327277
Ref: 30f111327277
Ref: library/queue queue Queue empty11327593
Ref: 30f211327593
Ref: library/queue queue Queue full11328026
Ref: 30f311328026
Ref: library/queue queue Queue put11328459
Ref: 30ee11328459
Ref: library/queue queue Queue put_nowait11329337
Ref: 2c9411329337
Ref: library/queue queue Queue get11329434
Ref: 2c9511329434
Ref: library/queue queue Queue get_nowait11330711
Ref: 30ed11330711
Ref: library/queue queue Queue task_done11330968
Ref: 2ffc11330968
Ref: library/queue queue Queue join11331881
Ref: 2ffd11331881
Node: Terminating queues11333101
Ref: library/queue terminating-queues11333183
Ref: 30f411333183
Ref: library/queue queue Queue shutdown11333334
Ref: 21b11333334
Node: SimpleQueue オブジェクト11333958
Ref: library/queue simplequeue-objects11334095
Ref: 30f511334095
Ref: library/queue queue SimpleQueue qsize11334272
Ref: 30f611334272
Ref: library/queue queue SimpleQueue empty11334548
Ref: 30f711334548
Ref: library/queue queue SimpleQueue put11334841
Ref: 30f811334841
Ref: library/queue queue SimpleQueue put_nowait11335605
Ref: 30f911335605
Ref: library/queue queue SimpleQueue get11335793
Ref: 30fa11335793
Ref: library/queue queue SimpleQueue get_nowait11336615
Ref: 30fb11336615
Node: contextvars --- コンテキスト変数11337095
Ref: library/contextvars doc11337276
Ref: 30fc11337276
Ref: library/contextvars contextvars-context-variables11337276
Ref: 30fd11337276
Ref: library/contextvars module-contextvars11337276
Ref: 1d11337276
Ref: contextvars --- コンテキスト変数-Footnote-111338331
Node: コンテキスト変数11338373
Ref: library/contextvars context-variables11338528
Ref: 310011338528
Ref: library/contextvars contextvars ContextVar11338589
Ref: 30fe11338589
Ref: library/contextvars contextvars ContextVar name11339542
Ref: 310211339542
Ref: library/contextvars contextvars ContextVar get11339678
Ref: 310111339678
Ref: library/contextvars contextvars ContextVar set11340302
Ref: 310311340302
Ref: library/contextvars contextvars ContextVar reset11340813
Ref: 310511340813
Ref: library/contextvars contextvars Token11341354
Ref: 310411341354
Ref: library/contextvars contextvars Token var11341718
Ref: 310611341718
Ref: library/contextvars contextvars Token old_value11341898
Ref: 310711341898
Ref: library/contextvars contextvars Token MISSING11342274
Ref: 310811342274
Node: マニュアルでのコンテキスト管理11342412
Ref: library/contextvars manual-context-management11342596
Ref: 310911342596
Ref: library/contextvars contextvars copy_context11342692
Ref: 30ff11342692
Ref: library/contextvars contextvars Context11343305
Ref: 150d11343305
Ref: library/contextvars contextvars Context run11345328
Ref: 156a11345328
Ref: library/contextvars contextvars Context copy11346657
Ref: 310a11346657
Ref: library/contextvars contextvars Context get11347219
Ref: 310b11347219
Ref: library/contextvars contextvars Context keys11347813
Ref: 310c11347813
Ref: library/contextvars contextvars Context values11347947
Ref: 310d11347947
Ref: library/contextvars contextvars Context items11348100
Ref: 310e11348100
Node: asyncio サポート11348310
Ref: library/contextvars asyncio-support11348461
Ref: 310f11348461
Node: _thread --- 低水準なスレッド API11350236
Ref: library/_thread doc11350374
Ref: 311011350374
Ref: library/_thread module-_thread11350374
Ref: 211350374
Ref: library/_thread thread-low-level-threading-api11350374
Ref: 311111350374
Ref: library/_thread thread error11351361
Ref: 311211351361
Ref: library/_thread thread LockType11351543
Ref: 311311351543
Ref: library/_thread thread start_new_thread11351640
Ref: 17b11351640
Ref: library/_thread thread interrupt_main11352735
Ref: 80e11352735
Ref: library/_thread thread exit11353662
Ref: 311411353662
Ref: library/_thread thread allocate_lock11353835
Ref: 311511353835
Ref: library/_thread thread get_ident11354066
Ref: 311611354066
Ref: library/_thread thread get_native_id11354554
Ref: 311711354554
Ref: library/_thread thread stack_size11355114
Ref: 311811355114
Ref: library/_thread thread TIMEOUT_MAX11356785
Ref: 311911356785
Ref: library/_thread thread lock acquire11357114
Ref: 311a11357114
Ref: library/_thread thread lock release11358501
Ref: 311b11358501
Ref: library/_thread thread lock locked11358762
Ref: 311c11358762
Node: ネットワーク通信とプロセス間通信11360236
Ref: library/ipc doc11360424
Ref: 311d11360424
Ref: library/ipc ipc11360424
Ref: 311e11360424
Ref: library/ipc networking-and-interprocess-communication11360424
Ref: 311f11360424
Node: asyncio --- 非同期 I/O11361741
Ref: library/asyncio doc11361922
Ref: 312011361922
Ref: library/asyncio asyncio-asynchronous-i-o11361922
Ref: 312111361922
Ref: library/asyncio module-asyncio11361922
Ref: 811361922
Ref: library/asyncio asyncio-cli11363991
Ref: 312c11363991
Node: Runners11365184
Ref: library/asyncio-runner doc11365285
Ref: 312d11365285
Ref: library/asyncio-runner runners11365285
Ref: 312e11365285
Ref: Runners-Footnote-111365867
Node: 非同期プログラムの実行11365943
Ref: library/asyncio-runner running-an-asyncio-program11366051
Ref: 312f11366051
Ref: library/asyncio-runner asyncio run11366127
Ref: 44911366127
Node: Runner context manager11368149
Ref: library/asyncio-runner runner-context-manager11368296
Ref: 313111368296
Ref: library/asyncio-runner asyncio Runner11368361
Ref: 5cb11368361
Ref: library/asyncio-runner asyncio Runner run11369680
Ref: 161111369680
Ref: library/asyncio-runner asyncio Runner close11370225
Ref: 313211370225
Ref: library/asyncio-runner asyncio Runner get_loop11370454
Ref: 313311370454
Node: Handling Keyboard Interruption11370902
Ref: library/asyncio-runner handling-keyboard-interruption11371007
Ref: 313411371007
Node: コルーチンと Task11372497
Ref: library/asyncio-task doc11372622
Ref: 313511372622
Ref: library/asyncio-task coroutines-and-tasks11372622
Ref: 313611372622
Node: コルーチン<3>11373230
Ref: library/asyncio-task coroutine11373326
Ref: 312211373326
Ref: library/asyncio-task coroutines11373326
Ref: 313711373326
Ref: コルーチン<3>-Footnote-111376982
Node: Awaitable11377061
Ref: library/asyncio-task asyncio-awaitables11377180
Ref: 313811377180
Ref: library/asyncio-task awaitables11377180
Ref: 313911377180
Node: Task の作成11380349
Ref: library/asyncio-task creating-tasks11380477
Ref: 313a11380477
Ref: library/asyncio-task asyncio create_task11380638
Ref: 5c711380638
Ref: Task の作成-Footnote-111383085
Node: タスクのキャンセル11383158
Ref: library/asyncio-task task-cancellation11383288
Ref: 313b11383288
Node: Task Groups11384406
Ref: library/asyncio-task task-groups11384534
Ref: 313c11384534
Ref: library/asyncio-task taskgroups11384534
Ref: 313d11384534
Ref: library/asyncio-task asyncio TaskGroup11384701
Ref: 19a11384701
Ref: library/asyncio-task asyncio TaskGroup create_task11384970
Ref: 1a111384970
Node: Terminating a Task Group11389006
Ref: library/asyncio-task terminating-a-task-group11389078
Ref: 313e11389078
Node: スリープ11390413
Ref: library/asyncio-task sleeping11390535
Ref: 313f11390535
Ref: library/asyncio-task asyncio sleep11390578
Ref: a3d11390578
Ref: library/asyncio-task asyncio-example-sleep11391248
Ref: 314011391248
Node: 並行な Task 実行11391932
Ref: library/asyncio-task running-tasks-concurrently11392061
Ref: 314111392061
Ref: library/asyncio-task asyncio gather11392121
Ref: 5c811392121
Ref: library/asyncio-task asyncio-example-gather11394226
Ref: 314211394226
Node: Eager Task Factory11396437
Ref: library/asyncio-task eager-task-factory11396584
Ref: 314311396584
Ref: library/asyncio-task id211396584
Ref: 314411396584
Ref: library/asyncio-task asyncio eager_task_factory11396643
Ref: 44411396643
Ref: library/asyncio-task asyncio create_eager_task_factory11397790
Ref: 44511397790
Node: キャンセルからの保護11398461
Ref: library/asyncio-task shielding-from-cancellation11398605
Ref: 314511398605
Ref: library/asyncio-task asyncio shield11398678
Ref: a3e11398678
Node: タイムアウト11400575
Ref: library/asyncio-task timeouts11400722
Ref: 314611400722
Ref: library/asyncio-task asyncio timeout11400775
Ref: 5c911400775
Ref: library/asyncio-task asyncio Timeout11402547
Ref: 163011402547
Ref: library/asyncio-task asyncio Timeout when11403030
Ref: 314811403030
Ref: library/asyncio-task asyncio Timeout reschedule11403208
Ref: 314711403208
Ref: library/asyncio-task asyncio Timeout expired11403319
Ref: 314911403319
Ref: library/asyncio-task asyncio timeout_at11404191
Ref: 178d11404191
Ref: library/asyncio-task asyncio wait_for11404833
Ref: 5ca11404833
Ref: library/asyncio-task asyncio-example-waitfor11405871
Ref: 314a11405871
Node: 要素の終了待機11406773
Ref: library/asyncio-task waiting-primitives11406917
Ref: 314b11406917
Ref: library/asyncio-task asyncio wait11406975
Ref: 44c11406975
Ref: library/asyncio-task asyncio FIRST_COMPLETED11408303
Ref: 314c11408303
Ref: library/asyncio-task asyncio FIRST_EXCEPTION11408646
Ref: 314d11408646
Ref: library/asyncio-task asyncio ALL_COMPLETED11409170
Ref: 314e11409170
Ref: library/asyncio-task asyncio as_completed11409841
Ref: 18f11409841
Node: スレッド内での実行11412741
Ref: library/asyncio-task running-in-threads11412912
Ref: 314f11412912
Ref: library/asyncio-task asyncio to_thread11412980
Ref: 8b611412980
Node: 外部スレッドからのスケジュール11415279
Ref: library/asyncio-task scheduling-from-other-threads11415459
Ref: 315011415459
Ref: library/asyncio-task asyncio run_coroutine_threadsafe11415557
Ref: 84f11415557
Node: イントロスペクション11417234
Ref: library/asyncio-task introspection11417410
Ref: 315211417410
Ref: library/asyncio-task asyncio current_task11417483
Ref: 44a11417483
Ref: library/asyncio-task asyncio all_tasks11417849
Ref: 92411417849
Ref: library/asyncio-task asyncio iscoroutine11418201
Ref: 44b11418201
Node: Task オブジェクト11418327
Ref: library/asyncio-task task-object11418449
Ref: 315311418449
Ref: library/asyncio-task asyncio Task11418512
Ref: 4a511418512
Ref: library/asyncio-task asyncio Task done11422034
Ref: 315711422034
Ref: library/asyncio-task asyncio Task result11422341
Ref: 315811422341
Ref: library/asyncio-task asyncio Task exception11422930
Ref: 315a11422930
Ref: library/asyncio-task asyncio Task add_done_callback11423556
Ref: 315b11423556
Ref: library/asyncio-task asyncio Task remove_done_callback11423985
Ref: 315c11423985
Ref: library/asyncio-task asyncio Task get_stack11424383
Ref: 315d11424383
Ref: library/asyncio-task asyncio Task print_stack11425731
Ref: 16ca11425731
Ref: library/asyncio-task asyncio Task get_coro11426345
Ref: 9a911426345
Ref: library/asyncio-task asyncio Task get_context11426818
Ref: 315e11426818
Ref: library/asyncio-task asyncio Task get_name11426989
Ref: 9ac11426989
Ref: library/asyncio-task asyncio Task set_name11427336
Ref: 9ab11427336
Ref: library/asyncio-task asyncio Task cancel11427740
Ref: 19c11427740
Ref: library/asyncio-task asyncio-example-task-cancel11428966
Ref: 315f11428966
Ref: library/asyncio-task asyncio Task cancelled11430264
Ref: 315411430264
Ref: library/asyncio-task asyncio Task uncancel11430704
Ref: 1a011430704
Ref: library/asyncio-task asyncio Task cancelling11433021
Ref: 19f11433021
Node: ストリーム11433833
Ref: library/asyncio-stream doc11433978
Ref: 316011433978
Ref: library/asyncio-stream asyncio-streams11433978
Ref: 312311433978
Ref: library/asyncio-stream streams11433978
Ref: 316111433978
Ref: library/asyncio-stream asyncio-example-stream11434449
Ref: 316211434449
Ref: library/asyncio-stream asyncio open_connection11435269
Ref: ae611435269
Ref: library/asyncio-stream asyncio start_server11436783
Ref: ae711436783
Ref: library/asyncio-stream asyncio open_unix_connection11438722
Ref: 316611438722
Ref: library/asyncio-stream asyncio start_unix_server11439874
Ref: 316811439874
Ref: ストリーム-Footnote-111441091
Node: StreamReader11441167
Ref: library/asyncio-stream streamreader11441252
Ref: 316911441252
Ref: library/asyncio-stream asyncio StreamReader11441299
Ref: 183011441299
Ref: library/asyncio-stream asyncio StreamReader feed_eof11441749
Ref: 316a11441749
Ref: library/asyncio-stream asyncio StreamReader read11441834
Ref: 316b11441834
Ref: library/asyncio-stream asyncio StreamReader readline11442711
Ref: 316c11442711
Ref: library/asyncio-stream asyncio StreamReader readexactly11443190
Ref: c4911443190
Ref: library/asyncio-stream asyncio StreamReader readuntil11443599
Ref: 19911443599
Ref: library/asyncio-stream asyncio StreamReader at_eof11445084
Ref: 316f11445084
Node: StreamWriter11445246
Ref: library/asyncio-stream streamwriter11445353
Ref: 317011445353
Ref: library/asyncio-stream asyncio StreamWriter11445400
Ref: 166511445400
Ref: library/asyncio-stream asyncio StreamWriter write11445792
Ref: 317111445792
Ref: library/asyncio-stream asyncio StreamWriter writelines11446285
Ref: 317211446285
Ref: library/asyncio-stream asyncio StreamWriter close11446841
Ref: 316411446841
Ref: library/asyncio-stream asyncio StreamWriter can_write_eof11447165
Ref: 317311447165
Ref: library/asyncio-stream asyncio StreamWriter write_eof11447429
Ref: 317411447429
Ref: library/asyncio-stream asyncio StreamWriter transport11447633
Ref: 317511447633
Ref: library/asyncio-stream asyncio StreamWriter get_extra_info11447739
Ref: 317611447739
Ref: library/asyncio-stream asyncio StreamWriter drain11447976
Ref: 171911447976
Ref: library/asyncio-stream asyncio StreamWriter start_tls11448733
Ref: 5cf11448733
Ref: library/asyncio-stream asyncio StreamWriter is_closing11449834
Ref: adb11449834
Ref: library/asyncio-stream asyncio StreamWriter wait_closed11450044
Ref: ada11450044
Node: 使用例<21>11450401
Ref: library/asyncio-stream examples11450487
Ref: 316311450487
Node: ストリームを使った TCP Echo クライアント11450763
Ref: library/asyncio-stream asyncio-tcp-echo-client-streams11450926
Ref: 317711450926
Ref: library/asyncio-stream tcp-echo-client-using-streams11450926
Ref: 317811450926
Node: ストリームを使った TCP Echo サーバー11451806
Ref: library/asyncio-stream asyncio-tcp-echo-server-streams11452004
Ref: 317a11452004
Ref: library/asyncio-stream tcp-echo-server-using-streams11452004
Ref: 317b11452004
Node: HTTP ヘッダーの取得11453113
Ref: library/asyncio-stream get-http-headers11453334
Ref: 317d11453334
Node: ストリームを使ってデータを待つオープンソケットの登録11454665
Ref: library/asyncio-stream asyncio-example-create-connection-streams11454828
Ref: 317e11454828
Ref: library/asyncio-stream register-an-open-socket-to-wait-for-data-using-streams11454828
Ref: 317f11454828
Node: 同期プリミティブ<2>11456426
Ref: library/asyncio-sync doc11456566
Ref: 318311456566
Ref: library/asyncio-sync asyncio-sync11456566
Ref: 312611456566
Ref: library/asyncio-sync synchronization-primitives11456566
Ref: 318411456566
Ref: 同期プリミティブ<2>-Footnote-111457843
Node: Lock11457916
Ref: library/asyncio-sync lock11457998
Ref: 318511457998
Ref: library/asyncio-sync asyncio Lock11458029
Ref: a3f11458029
Ref: library/asyncio-sync asyncio Lock acquire11458907
Ref: 318611458907
Ref: library/asyncio-sync asyncio Lock release11459595
Ref: 318711459595
Ref: library/asyncio-sync asyncio Lock locked11459919
Ref: 318811459919
Node: Event11460025
Ref: library/asyncio-sync event11460125
Ref: 318911460125
Ref: library/asyncio-sync asyncio Event11460158
Ref: a4011460158
Ref: library/asyncio-sync asyncio-example-sync-event11460952
Ref: 318d11460952
Ref: library/asyncio-sync asyncio Event wait11461607
Ref: 318c11461607
Ref: library/asyncio-sync asyncio Event set11461959
Ref: 318a11461959
Ref: library/asyncio-sync asyncio Event clear11462196
Ref: 318b11462196
Ref: library/asyncio-sync asyncio Event is_set11462492
Ref: 318e11462492
Node: Condition11462613
Ref: library/asyncio-sync condition11462718
Ref: 318f11462718
Ref: library/asyncio-sync asyncio Condition11462759
Ref: a4111462759
Ref: library/asyncio-sync asyncio Condition acquire11464398
Ref: 319011464398
Ref: library/asyncio-sync asyncio Condition notify11464674
Ref: 15de11464674
Ref: library/asyncio-sync asyncio Condition locked11465222
Ref: 319111465222
Ref: library/asyncio-sync asyncio Condition notify_all11465340
Ref: 319211465340
Ref: library/asyncio-sync asyncio Condition release11466005
Ref: 319311466005
Ref: library/asyncio-sync asyncio Condition wait11466234
Ref: 160911466234
Ref: library/asyncio-sync asyncio Condition wait_for11467180
Ref: 319411467180
Node: Semaphore11467568
Ref: library/asyncio-sync semaphore11467684
Ref: 319511467684
Ref: library/asyncio-sync asyncio Semaphore11467725
Ref: a4211467725
Ref: library/asyncio-sync asyncio Semaphore acquire11469292
Ref: 160a11469292
Ref: library/asyncio-sync asyncio Semaphore locked11469694
Ref: 319711469694
Ref: library/asyncio-sync asyncio Semaphore release11469818
Ref: 319611469818
Node: BoundedSemaphore11470227
Ref: library/asyncio-sync boundedsemaphore11470341
Ref: 319811470341
Ref: library/asyncio-sync asyncio BoundedSemaphore11470396
Ref: a4311470396
Node: Barrier11470896
Ref: library/asyncio-sync barrier11470992
Ref: 319911470992
Ref: library/asyncio-sync asyncio Barrier11471029
Ref: 5cc11471029
Ref: library/asyncio-sync asyncio-example-barrier11471628
Ref: 319b11471628
Ref: library/asyncio-sync asyncio Barrier wait11472528
Ref: 319a11472528
Ref: library/asyncio-sync asyncio Barrier reset11473611
Ref: 319c11473611
Ref: library/asyncio-sync asyncio Barrier abort11473917
Ref: 319d11473917
Ref: library/asyncio-sync asyncio Barrier parties11474239
Ref: 319e11474239
Ref: library/asyncio-sync asyncio Barrier n_waiting11474329
Ref: 319f11474329
Ref: library/asyncio-sync asyncio Barrier broken11474449
Ref: 31a011474449
Ref: library/asyncio-sync asyncio BrokenBarrierError11474572
Ref: 5cd11474572
Node: サブプロセス11475190
Ref: library/asyncio-subprocess doc11475324
Ref: 31a111475324
Ref: library/asyncio-subprocess asyncio-subprocess11475324
Ref: 312411475324
Ref: library/asyncio-subprocess subprocesses11475324
Ref: 31a211475324
Ref: library/asyncio-subprocess asyncio-example-subprocess-shell11475668
Ref: 31a311475668
Ref: サブプロセス-Footnote-111477230
Ref: サブプロセス-Footnote-211477309
Node: サブプロセスの生成11477393
Ref: library/asyncio-subprocess creating-subprocesses11477493
Ref: 31a511477493
Ref: library/asyncio-subprocess asyncio create_subprocess_exec11477561
Ref: a4511477561
Ref: library/asyncio-subprocess asyncio create_subprocess_shell11478252
Ref: a4611478252
Ref: サブプロセスの生成-Footnote-111480082
Node: 定数<7>11480152
Ref: library/asyncio-subprocess constants11480300
Ref: 31ae11480300
Ref: library/asyncio-subprocess asyncio subprocess PIPE11480333
Ref: 31af11480333
Ref: library/asyncio-subprocess asyncio subprocess STDOUT11480811
Ref: 31b311480811
Ref: library/asyncio-subprocess asyncio subprocess DEVNULL11481019
Ref: 31b411481019
Node: サブプロセスとやりとりする11481339
Ref: library/asyncio-subprocess interacting-with-subprocesses11481451
Ref: 31b511481451
Ref: library/asyncio-subprocess asyncio subprocess Process11481866
Ref: 31a611481866
Ref: library/asyncio-subprocess asyncio subprocess Process wait11483088
Ref: 31b611483088
Ref: library/asyncio-subprocess asyncio subprocess Process communicate11483820
Ref: 169611483820
Ref: library/asyncio-subprocess asyncio subprocess Process send_signal11485781
Ref: 155b11485781
Ref: library/asyncio-subprocess asyncio subprocess Process terminate11486217
Ref: 31b911486217
Ref: library/asyncio-subprocess asyncio subprocess Process kill11486518
Ref: 31ba11486518
Ref: library/asyncio-subprocess asyncio subprocess Process stdin11486866
Ref: 31b011486866
Ref: library/asyncio-subprocess asyncio subprocess Process stdout11487063
Ref: 31b111487063
Ref: library/asyncio-subprocess asyncio subprocess Process stderr11487262
Ref: 31b211487262
Ref: library/asyncio-subprocess asyncio subprocess Process pid11487810
Ref: 31bb11487810
Ref: library/asyncio-subprocess asyncio subprocess Process returncode11488114
Ref: 31b811488114
Node: サブプロセスとスレッド11488602
Ref: library/asyncio-subprocess asyncio-subprocess-threads11488733
Ref: 31b711488733
Ref: library/asyncio-subprocess subprocess-and-threads11488733
Ref: 31bc11488733
Node: 使用例<22>11490048
Ref: library/asyncio-subprocess examples11490179
Ref: 31a411490179
Ref: library/asyncio-subprocess asyncio-example-create-subprocess-exec11490405
Ref: 31be11490405
Node: キュー11491253
Ref: library/asyncio-queue doc11491370
Ref: 31c011491370
Ref: library/asyncio-queue asyncio-queues11491370
Ref: 312511491370
Ref: library/asyncio-queue queues11491370
Ref: 31c111491370
Ref: キュー-Footnote-111492292
Node: Queue11492366
Ref: library/asyncio-queue queue11492453
Ref: 31c311492453
Ref: library/asyncio-queue asyncio Queue11492486
Ref: a4411492486
Ref: library/asyncio-queue asyncio Queue maxsize11493317
Ref: 31c611493317
Ref: library/asyncio-queue asyncio Queue empty11493409
Ref: 31c711493409
Ref: library/asyncio-queue asyncio Queue full11493559
Ref: 31c811493559
Ref: library/asyncio-queue asyncio Queue get11493836
Ref: 31c411493836
Ref: library/asyncio-queue asyncio Queue get_nowait11494187
Ref: 31c911494187
Ref: library/asyncio-queue asyncio Queue join11494377
Ref: d9511494377
Ref: library/asyncio-queue asyncio Queue put11495022
Ref: 31cb11495022
Ref: library/asyncio-queue asyncio Queue put_nowait11495348
Ref: 31cc11495348
Ref: library/asyncio-queue asyncio Queue qsize11495589
Ref: 31c511495589
Ref: library/asyncio-queue asyncio Queue shutdown11495676
Ref: 19511495676
Ref: library/asyncio-queue asyncio Queue task_done11496353
Ref: d9611496353
Node: 優先度付きのキュー11497334
Ref: library/asyncio-queue priority-queue11497444
Ref: 31ce11497444
Ref: library/asyncio-queue asyncio PriorityQueue11497512
Ref: 31cf11497512
Node: LIFO キュー11497795
Ref: library/asyncio-queue lifo-queue11497910
Ref: 31d011497910
Ref: library/asyncio-queue asyncio LifoQueue11497958
Ref: 31d111497958
Node: 例外<11>11498146
Ref: library/asyncio-queue exceptions11498247
Ref: 31d211498247
Ref: library/asyncio-queue asyncio QueueEmpty11498280
Ref: 31ca11498280
Ref: library/asyncio-queue asyncio QueueFull11498451
Ref: 31cd11498451
Ref: library/asyncio-queue asyncio QueueShutDown11498644
Ref: 19611498644
Node: 使用例<23>11498829
Ref: library/asyncio-queue examples11498907
Ref: 31c211498907
Ref: library/asyncio-queue asyncio-example-queue-dist11498945
Ref: 31d311498945
Node: 例外<12>11500753
Ref: library/asyncio-exceptions doc11500873
Ref: 31d411500873
Ref: library/asyncio-exceptions asyncio-exceptions11500873
Ref: 31d511500873
Ref: library/asyncio-exceptions exceptions11500873
Ref: 31d611500873
Ref: library/asyncio-exceptions asyncio TimeoutError11501026
Ref: 16ab11501026
Ref: library/asyncio-exceptions asyncio CancelledError11501328
Ref: 19d11501328
Ref: library/asyncio-exceptions asyncio InvalidStateError11501870
Ref: 315911501870
Ref: library/asyncio-exceptions asyncio SendfileNotAvailableError11502219
Ref: 31d711502219
Ref: library/asyncio-exceptions asyncio IncompleteReadError11502479
Ref: 188a11502479
Ref: library/asyncio-exceptions asyncio IncompleteReadError expected11502743
Ref: 31d811502743
Ref: library/asyncio-exceptions asyncio IncompleteReadError partial11502843
Ref: 316d11502843
Ref: library/asyncio-exceptions asyncio LimitOverrunError11502992
Ref: 316e11502992
Ref: library/asyncio-exceptions asyncio LimitOverrunError consumed11503206
Ref: 31d911503206
Ref: 例外<12>-Footnote-111503326
Node: イベントループ11503405
Ref: library/asyncio-eventloop doc11503522
Ref: 31da11503522
Ref: library/asyncio-eventloop asyncio-event-loop11503522
Ref: d4611503522
Ref: library/asyncio-eventloop event-loop11503522
Ref: 31db11503522
Ref: library/asyncio-eventloop asyncio get_running_loop11504637
Ref: ad911504637
Ref: library/asyncio-eventloop asyncio get_event_loop11504943
Ref: 2a211504943
Ref: library/asyncio-eventloop asyncio set_event_loop11506033
Ref: 173511506033
Ref: library/asyncio-eventloop asyncio new_event_loop11506149
Ref: 313011506149
Ref: イベントループ-Footnote-111507720
Ref: イベントループ-Footnote-211507796
Node: イベントループのメソッド11507870
Ref: library/asyncio-eventloop asyncio-event-loop-methods11508006
Ref: 31e211508006
Ref: library/asyncio-eventloop event-loop-methods11508006
Ref: 31dd11508006
Node: ループの開始と停止11508841
Ref: library/asyncio-eventloop running-and-stopping-the-loop11508995
Ref: 31e311508995
Ref: library/asyncio-eventloop asyncio loop run_until_complete11509063
Ref: c4511509063
Ref: library/asyncio-eventloop asyncio loop run_forever11509490
Ref: 31e411509490
Ref: library/asyncio-eventloop asyncio loop stop11510525
Ref: c4a11510525
Ref: library/asyncio-eventloop asyncio loop is_running11510606
Ref: 31e511510606
Ref: library/asyncio-eventloop asyncio loop is_closed11510729
Ref: d9111510729
Ref: library/asyncio-eventloop asyncio loop close11510854
Ref: 31e611510854
Ref: library/asyncio-eventloop asyncio loop shutdown_asyncgens11511543
Ref: c4b11511543
Ref: library/asyncio-eventloop asyncio loop shutdown_default_executor11512274
Ref: 8b511512274
Node: コールバックのスケジューリング11513305
Ref: library/asyncio-eventloop scheduling-callbacks11513519
Ref: 31e711513519
Ref: library/asyncio-eventloop asyncio loop call_soon11513617
Ref: ad211513617
Ref: library/asyncio-eventloop asyncio loop call_soon_threadsafe11514445
Ref: ad311514445
Ref: library/asyncio-eventloop asyncio-pass-keywords11515374
Ref: 31e811515374
Ref: コールバックのスケジューリング-Footnote-111516115
Node: 遅延コールバックのスケジューリング11516157
Ref: library/asyncio-eventloop asyncio-delayed-calls11516383
Ref: 31e911516383
Ref: library/asyncio-eventloop scheduling-delayed-callbacks11516383
Ref: 31ea11516383
Ref: library/asyncio-eventloop asyncio loop call_later11516772
Ref: ad411516772
Ref: library/asyncio-eventloop asyncio loop call_at11518559
Ref: ad511518559
Ref: library/asyncio-eventloop asyncio loop time11519639
Ref: 31eb11519639
Ref: 遅延コールバックのスケジューリング-Footnote-111520269
Ref: 遅延コールバックのスケジューリング-Footnote-211520311
Node: フューチャーとタスクの生成11520353
Ref: library/asyncio-eventloop creating-futures-and-tasks11520567
Ref: 31ec11520567
Ref: library/asyncio-eventloop asyncio loop create_future11520655
Ref: c4711520655
Ref: library/asyncio-eventloop asyncio loop create_task11521177
Ref: 9aa11521177
Ref: library/asyncio-eventloop asyncio loop set_task_factory11522244
Ref: d9311522244
Ref: library/asyncio-eventloop asyncio loop get_task_factory11522764
Ref: d9411522764
Node: ネットワーク接続の確立11522959
Ref: library/asyncio-eventloop opening-network-connections11523158
Ref: 31ed11523158
Ref: library/asyncio-eventloop asyncio loop create_connection11523236
Ref: 5ce11523236
Ref: library/asyncio-eventloop asyncio loop create_datagram_endpoint11531798
Ref: 6fe11531798
Ref: library/asyncio-eventloop asyncio loop create_unix_connection11536272
Ref: 316711536272
Ref: ネットワーク接続の確立-Footnote-111537488
Ref: ネットワーク接続の確立-Footnote-211537547
Node: ネットワークサーバの生成11537606
Ref: library/asyncio-eventloop creating-network-servers11537787
Ref: 31f611537787
Ref: library/asyncio-eventloop loop-create-server11537870
Ref: 312711537870
Ref: library/asyncio-eventloop asyncio loop create_server11537870
Ref: ae111537870
Ref: library/asyncio-eventloop asyncio loop create_unix_server11543994
Ref: 19311543994
Ref: library/asyncio-eventloop asyncio loop connect_accepted_socket11545406
Ref: ae811545406
Node: ファイルの転送11547313
Ref: library/asyncio-eventloop transferring-files11547492
Ref: 31f811547492
Ref: library/asyncio-eventloop asyncio loop sendfile11547550
Ref: 31f911547550
Node: TLS へのアップグレード11549175
Ref: library/asyncio-eventloop tls-upgrade11549348
Ref: 31fa11549348
Ref: library/asyncio-eventloop asyncio loop start_tls11549424
Ref: ad711549424
Node: ファイル記述子の監視11551700
Ref: library/asyncio-eventloop watching-file-descriptors11551909
Ref: 31fb11551909
Ref: library/asyncio-eventloop asyncio loop add_reader11551982
Ref: 318211551982
Ref: library/asyncio-eventloop asyncio loop remove_reader11552269
Ref: 31fc11552269
Ref: library/asyncio-eventloop asyncio loop add_writer11552456
Ref: 31fd11552456
Ref: library/asyncio-eventloop asyncio loop remove_writer11552902
Ref: 31fe11552902
Node: ソケットオブジェクトと直接やりとりする11553249
Ref: library/asyncio-eventloop working-with-socket-objects-directly11553430
Ref: 320011553430
Ref: library/asyncio-eventloop asyncio loop sock_recv11553992
Ref: bdf11553992
Ref: library/asyncio-eventloop asyncio loop sock_recv_into11554752
Ref: ad811554752
Ref: library/asyncio-eventloop asyncio loop sock_recvfrom11555223
Ref: 5d111555223
Ref: library/asyncio-eventloop asyncio loop sock_recvfrom_into11555576
Ref: 5d211555576
Ref: library/asyncio-eventloop asyncio loop sock_sendall11555966
Ref: be011555966
Ref: library/asyncio-eventloop asyncio loop sock_sendto11557023
Ref: 5d011557023
Ref: library/asyncio-eventloop asyncio loop sock_connect11557351
Ref: d9711557351
Ref: library/asyncio-eventloop asyncio loop sock_accept11558169
Ref: be111558169
Ref: library/asyncio-eventloop asyncio loop sock_sendfile11559291
Ref: adc11559291
Node: DNS11561149
Ref: library/asyncio-eventloop dns11561330
Ref: 320111561330
Ref: library/asyncio-eventloop asyncio loop getaddrinfo11561359
Ref: be211561359
Ref: library/asyncio-eventloop asyncio loop getnameinfo11561532
Ref: be311561532
Node: パイプとやりとりする11562537
Ref: library/asyncio-eventloop working-with-pipes11562678
Ref: 320211562678
Ref: library/asyncio-eventloop asyncio loop connect_read_pipe11562751
Ref: 31aa11562751
Ref: library/asyncio-eventloop asyncio loop connect_write_pipe11563606
Ref: 31ab11563606
Node: Unix シグナル11564760
Ref: library/asyncio-eventloop unix-signals11564967
Ref: 320511564967
Ref: library/asyncio-eventloop loop-add-signal-handler11565020
Ref: 312911565020
Ref: library/asyncio-eventloop asyncio loop add_signal_handler11565020
Ref: 320611565020
Ref: library/asyncio-eventloop asyncio loop remove_signal_handler11566149
Ref: 320711566149
Node: スレッドまたはプロセスプールでコードを実行する11566559
Ref: library/asyncio-eventloop executing-code-in-thread-or-process-pools11566767
Ref: 320811566767
Ref: library/asyncio-eventloop asyncio loop run_in_executor11566905
Ref: 8b711566905
Ref: library/asyncio-eventloop asyncio loop set_default_executor11569818
Ref: 70e11569818
Node: エラーハンドリング API11570141
Ref: library/asyncio-eventloop error-handling-api11570365
Ref: 320911570365
Ref: library/asyncio-eventloop asyncio loop set_exception_handler11570527
Ref: 320a11570527
Ref: library/asyncio-eventloop asyncio loop get_exception_handler11571650
Ref: c4811571650
Ref: library/asyncio-eventloop asyncio loop default_exception_handler11571883
Ref: 320c11571883
Ref: library/asyncio-eventloop asyncio loop call_exception_handler11572392
Ref: 320b11572392
Node: デバッグモードの有効化11573575
Ref: library/asyncio-eventloop enabling-debug-mode11573757
Ref: 320d11573757
Ref: library/asyncio-eventloop asyncio loop get_debug11573835
Ref: d9011573835
Ref: library/asyncio-eventloop asyncio loop set_debug11574176
Ref: d8f11574176
Ref: library/asyncio-eventloop asyncio loop slow_callback_duration11574484
Ref: 320e11574484
Node: サブプロセスの実行11574809
Ref: library/asyncio-eventloop running-subprocesses11574951
Ref: 320f11574951
Ref: library/asyncio-eventloop loop-subprocess-exec11575538
Ref: 312811575538
Ref: library/asyncio-eventloop asyncio loop subprocess_exec11575538
Ref: 31a711575538
Ref: library/asyncio-eventloop asyncio loop subprocess_shell11580415
Ref: 31a811580415
Ref: サブプロセスの実行-Footnote-111582155
Node: コールバックのハンドル11582225
Ref: library/asyncio-eventloop callback-handles11582394
Ref: 31de11582394
Ref: library/asyncio-eventloop asyncio Handle11582472
Ref: 1a0e11582472
Ref: library/asyncio-eventloop asyncio Handle get_context11582639
Ref: 321211582639
Ref: library/asyncio-eventloop asyncio Handle cancel11582812
Ref: 321311582812
Ref: library/asyncio-eventloop asyncio Handle cancelled11583046
Ref: ae911583046
Ref: library/asyncio-eventloop asyncio TimerHandle11583209
Ref: 16d811583209
Ref: library/asyncio-eventloop asyncio TimerHandle when11583428
Ref: ae511583428
Node: Serverオブジェクト11583758
Ref: library/asyncio-eventloop server-objects11583921
Ref: 31df11583921
Ref: library/asyncio-eventloop asyncio Server11584259
Ref: ae011584259
Ref: library/asyncio-eventloop asyncio Server close11585105
Ref: 316511585105
Ref: library/asyncio-eventloop asyncio Server close_clients11585617
Ref: 19711585617
Ref: library/asyncio-eventloop asyncio Server abort_clients11585991
Ref: 19811585991
Ref: library/asyncio-eventloop asyncio Server get_loop11586439
Ref: adf11586439
Ref: library/asyncio-eventloop asyncio Server start_serving11586601
Ref: ae211586601
Ref: library/asyncio-eventloop asyncio Server serve_forever11587411
Ref: ae311587411
Ref: library/asyncio-eventloop asyncio Server is_serving11588504
Ref: ae411588504
Ref: library/asyncio-eventloop asyncio Server wait_closed11588694
Ref: 162f11588694
Ref: library/asyncio-eventloop asyncio Server sockets11588859
Ref: be411588859
Ref: library/asyncio-eventloop asyncio-event-loops11589331
Ref: 321511589331
Node: イベントループの実装11589331
Ref: library/asyncio-eventloop asyncio-event-loop-implementations11589474
Ref: 321611589474
Ref: library/asyncio-eventloop event-loop-implementations11589474
Ref: 31e011589474
Ref: library/asyncio-eventloop asyncio SelectorEventLoop11589760
Ref: 5d311589760
Ref: library/asyncio-eventloop asyncio ProactorEventLoop11590461
Ref: 5d411590461
Ref: library/asyncio-eventloop asyncio EventLoop11590729
Ref: 165b11590729
Ref: library/asyncio-eventloop asyncio AbstractEventLoop11591043
Ref: 92d11591043
Ref: イベントループの実装-Footnote-111591384
Node: 使用例<24>11591463
Ref: library/asyncio-eventloop examples11591573
Ref: 31e111591573
Node: call_soon を使った Hello World11592355
Ref: library/asyncio-eventloop asyncio-example-lowlevel-helloworld11592492
Ref: 321711592492
Ref: library/asyncio-eventloop hello-world-with-call-soon11592492
Ref: 321811592492
Node: call_later で現在の日時を表示する11593329
Ref: library/asyncio-eventloop asyncio-example-call-later11593532
Ref: 321911593532
Ref: library/asyncio-eventloop display-the-current-date-with-call-later11593532
Ref: 321a11593532
Node: 読み込みイベント用ファイル記述子の監視11594578
Ref: library/asyncio-eventloop asyncio-example-watch-fd11594814
Ref: 318111594814
Ref: library/asyncio-eventloop watch-a-file-descriptor-for-read-events11594814
Ref: 321b11594814
Node: SIGINT および SIGTERM 用のシグナルハンドラーの設定11596266
Ref: library/asyncio-eventloop asyncio-example-unix-signals11596449
Ref: 321c11596449
Ref: library/asyncio-eventloop set-signal-handlers-for-sigint-and-sigterm11596449
Ref: 321d11596449
Node: Future11597436
Ref: library/asyncio-future doc11597582
Ref: 321e11597582
Ref: library/asyncio-future asyncio-futures11597582
Ref: 312b11597582
Ref: library/asyncio-future futures11597582
Ref: 321f11597582
Ref: Future-Footnote-111598049
Ref: Future-Footnote-211598125
Node: Future の関数11598206
Ref: library/asyncio-future future-functions11598302
Ref: 322011598302
Ref: library/asyncio-future asyncio isfuture11598354
Ref: 322111598354
Ref: library/asyncio-future asyncio ensure_future11598757
Ref: c4411598757
Ref: library/asyncio-future asyncio wrap_future11600387
Ref: 182f11600387
Node: Future オブジェクト<2>11600774
Ref: library/asyncio-future future-object11600870
Ref: 322211600870
Ref: library/asyncio-future asyncio Future11600937
Ref: b9b11600937
Ref: library/asyncio-future asyncio Future result11602344
Ref: 322311602344
Ref: library/asyncio-future asyncio Future set_result11603083
Ref: 315511603083
Ref: library/asyncio-future asyncio Future set_exception11603305
Ref: 315611603305
Ref: library/asyncio-future asyncio Future done11603533
Ref: 322411603533
Ref: library/asyncio-future asyncio Future cancelled11603915
Ref: 322511603915
Ref: library/asyncio-future asyncio Future add_done_callback11604342
Ref: ad611604342
Ref: library/asyncio-future asyncio Future remove_done_callback11605730
Ref: 150b11605730
Ref: library/asyncio-future asyncio Future cancel11606035
Ref: 178511606035
Ref: library/asyncio-future asyncio Future exception11606546
Ref: 322611606546
Ref: library/asyncio-future asyncio Future get_loop11607111
Ref: ade11607111
Ref: library/asyncio-future asyncio-example-future11607280
Ref: 322711607280
Ref: Future オブジェクト<2>-Footnote-111609766
Node: トランスポートとプロトコル11609808
Ref: library/asyncio-protocol doc11609945
Ref: 322811609945
Ref: library/asyncio-protocol asyncio-transports-protocols11609945
Ref: 312a11609945
Ref: library/asyncio-protocol transports-and-protocols11609945
Ref: 322911609945
Node: トランスポート11613182
Ref: library/asyncio-protocol asyncio-transport11613303
Ref: 31ef11613303
Ref: library/asyncio-protocol transports11613303
Ref: 322a11613303
Ref: トランスポート-Footnote-111614395
Node: トランスポートのクラス階層構造11614474
Ref: library/asyncio-protocol transports-hierarchy11614613
Ref: 323111614613
Ref: library/asyncio-protocol asyncio BaseTransport11614711
Ref: 322c11614711
Ref: library/asyncio-protocol asyncio WriteTransport11614912
Ref: 320411614912
Ref: library/asyncio-protocol asyncio ReadTransport11615343
Ref: 320311615343
Ref: library/asyncio-protocol asyncio Transport11615715
Ref: 322d11615715
Ref: library/asyncio-protocol asyncio DatagramTransport11616593
Ref: 171711616593
Ref: library/asyncio-protocol asyncio SubprocessTransport11616904
Ref: 321111616904
Node: 基底トランスポート11617281
Ref: library/asyncio-protocol base-transport11617471
Ref: 323211617471
Ref: library/asyncio-protocol asyncio BaseTransport close11617539
Ref: 31f211617539
Ref: library/asyncio-protocol asyncio BaseTransport is_closing11618181
Ref: c4611618181
Ref: library/asyncio-protocol asyncio BaseTransport get_extra_info11618334
Ref: a6a11618334
Ref: library/asyncio-protocol asyncio BaseTransport set_protocol11621019
Ref: 323711621019
Ref: library/asyncio-protocol asyncio BaseTransport get_protocol11621327
Ref: 323811621327
Node: 読み出し専用のトランスポート11621425
Ref: library/asyncio-protocol read-only-transports11621612
Ref: 323911621612
Ref: library/asyncio-protocol asyncio ReadTransport is_reading11621705
Ref: aea11621705
Ref: library/asyncio-protocol asyncio ReadTransport pause_reading11621880
Ref: aec11621880
Ref: library/asyncio-protocol asyncio ReadTransport resume_reading11622399
Ref: aeb11622399
Node: 書き込み専用のトランスポート11622863
Ref: library/asyncio-protocol write-only-transports11623062
Ref: 323a11623062
Ref: library/asyncio-protocol asyncio WriteTransport abort11623155
Ref: 321411623155
Ref: library/asyncio-protocol asyncio WriteTransport can_write_eof11623608
Ref: 323b11623608
Ref: library/asyncio-protocol asyncio WriteTransport get_write_buffer_size11623863
Ref: 323d11623863
Ref: library/asyncio-protocol asyncio WriteTransport get_write_buffer_limits11624040
Ref: d9211624040
Ref: library/asyncio-protocol asyncio WriteTransport set_write_buffer_limits11624448
Ref: 323e11624448
Ref: library/asyncio-protocol asyncio WriteTransport write11626254
Ref: 324111626254
Ref: library/asyncio-protocol asyncio WriteTransport writelines11626517
Ref: 169311626517
Ref: library/asyncio-protocol asyncio WriteTransport write_eof11626898
Ref: 323c11626898
Node: データグラムトランスポート11627381
Ref: library/asyncio-protocol datagram-transports11627589
Ref: 324211627589
Ref: library/asyncio-protocol asyncio DatagramTransport sendto11627677
Ref: 19411627677
Ref: library/asyncio-protocol asyncio DatagramTransport abort11628512
Ref: 324311628512
Node: サブプロセス化されたトランスポート11628968
Ref: library/asyncio-protocol asyncio-subprocess-transports11629125
Ref: 31ac11629125
Ref: library/asyncio-protocol subprocess-transports11629125
Ref: 324411629125
Ref: library/asyncio-protocol asyncio SubprocessTransport get_pid11629233
Ref: 324511629233
Ref: library/asyncio-protocol asyncio SubprocessTransport get_pipe_transport11629354
Ref: 324611629354
Ref: library/asyncio-protocol asyncio SubprocessTransport get_returncode11630266
Ref: 324711630266
Ref: library/asyncio-protocol asyncio SubprocessTransport kill11630569
Ref: 324811630569
Ref: library/asyncio-protocol asyncio SubprocessTransport send_signal11630938
Ref: 324a11630938
Ref: library/asyncio-protocol asyncio SubprocessTransport terminate11631136
Ref: 324911631136
Ref: library/asyncio-protocol asyncio SubprocessTransport close11631572
Ref: 324b11631572
Node: プロトコル11631915
Ref: library/asyncio-protocol asyncio-protocol11632058
Ref: 31ee11632058
Ref: library/asyncio-protocol protocols11632058
Ref: 322b11632058
Ref: プロトコル-Footnote-111633225
Node: 基底プロトコル11633303
Ref: library/asyncio-protocol base-protocols11633409
Ref: 324c11633409
Ref: library/asyncio-protocol asyncio BaseProtocol11633467
Ref: 322e11633467
Ref: library/asyncio-protocol asyncio Protocol11633637
Ref: 322f11633637
Ref: library/asyncio-protocol asyncio BufferedProtocol11633814
Ref: a6b11633814
Ref: library/asyncio-protocol asyncio DatagramProtocol11634012
Ref: 69a11634012
Ref: library/asyncio-protocol asyncio SubprocessProtocol11634163
Ref: 321011634163
Node: 基底プロトコル<2>11634361
Ref: library/asyncio-protocol base-protocol11634512
Ref: 324d11634512
Ref: library/asyncio-protocol asyncio BaseProtocol connection_made11635037
Ref: 31f011635037
Ref: library/asyncio-protocol asyncio BaseProtocol connection_lost11635361
Ref: 323311635361
Ref: library/asyncio-protocol asyncio BaseProtocol pause_writing11636175
Ref: 323f11636175
Ref: library/asyncio-protocol asyncio BaseProtocol resume_writing11636366
Ref: 324011636366
Node: ストリーミングプロトコル11637087
Ref: library/asyncio-protocol streaming-protocols11637283
Ref: 324e11637283
Ref: library/asyncio-protocol asyncio Protocol data_received11637770
Ref: 16f811637770
Ref: library/asyncio-protocol asyncio Protocol eof_received11638795
Ref: 324f11638795
Node: バッファリングされたストリーミングプロトコル11639935
Ref: library/asyncio-protocol buffered-streaming-protocols11640140
Ref: 325011640140
Ref: library/asyncio-protocol asyncio BufferedProtocol get_buffer11641167
Ref: 325111641167
Ref: library/asyncio-protocol asyncio BufferedProtocol buffer_updated11641881
Ref: 325211641881
Ref: library/asyncio-protocol asyncio BufferedProtocol eof_received11642111
Ref: 325311642111
Node: データグラムプロトコル11642816
Ref: library/asyncio-protocol datagram-protocols11643018
Ref: 325411643018
Ref: library/asyncio-protocol asyncio DatagramProtocol datagram_received11643300
Ref: 325511643300
Ref: library/asyncio-protocol asyncio DatagramProtocol error_received11643645
Ref: 325611643645
Node: サブプロセスプロトコル11645027
Ref: library/asyncio-protocol asyncio-subprocess-protocols11645154
Ref: 31ad11645154
Ref: library/asyncio-protocol subprocess-protocols11645154
Ref: 325711645154
Ref: library/asyncio-protocol asyncio SubprocessProtocol pipe_data_received11645466
Ref: 172f11645466
Ref: library/asyncio-protocol asyncio SubprocessProtocol pipe_connection_lost11645840
Ref: 325811645840
Ref: library/asyncio-protocol asyncio SubprocessProtocol process_exited11646114
Ref: 172e11646114
Node: 使用例<25>11646402
Ref: library/asyncio-protocol examples11646515
Ref: 323011646515
Node: TCP エコーサーバー11646827
Ref: library/asyncio-protocol asyncio-example-tcp-echo-server-protocol11646942
Ref: 317c11646942
Ref: library/asyncio-protocol tcp-echo-server11646942
Ref: 325911646942
Node: TCP エコークライアント11648341
Ref: library/asyncio-protocol asyncio-example-tcp-echo-client-protocol11648490
Ref: 317911648490
Ref: library/asyncio-protocol tcp-echo-client11648490
Ref: 325a11648490
Node: UDP エコーサーバー11650177
Ref: library/asyncio-protocol asyncio-udp-echo-server-protocol11650332
Ref: 31f511650332
Ref: library/asyncio-protocol udp-echo-server11650332
Ref: 325b11650332
Node: UDP エコークライアント11651528
Ref: library/asyncio-protocol asyncio-udp-echo-client-protocol11651685
Ref: 31f411651685
Ref: library/asyncio-protocol udp-echo-client11651685
Ref: 325c11651685
Node: 既存のソケットへの接続11653294
Ref: library/asyncio-protocol asyncio-example-create-connection11653469
Ref: 318011653469
Ref: library/asyncio-protocol connecting-existing-sockets11653469
Ref: 325d11653469
Node: loop subprocess_exec と SubprocessProtocol11655571
Ref: library/asyncio-protocol asyncio-example-subprocess-proto11655706
Ref: 31bf11655706
Ref: library/asyncio-protocol loop-subprocess-exec-and-subprocessprotocol11655706
Ref: 325e11655706
Node: ポリシー11658129
Ref: library/asyncio-policy doc11658302
Ref: 325f11658302
Ref: library/asyncio-policy asyncio-policies11658302
Ref: 31dc11658302
Ref: library/asyncio-policy policies11658302
Ref: 326011658302
Node: ポリシーの取得と設定11659333
Ref: library/asyncio-policy asyncio-policy-get-set11659451
Ref: 326111659451
Ref: library/asyncio-policy getting-and-setting-the-policy11659451
Ref: 326611659451
Ref: library/asyncio-policy asyncio get_event_loop_policy11659644
Ref: 326711659644
Ref: library/asyncio-policy asyncio set_event_loop_policy11659769
Ref: 326811659769
Node: ポリシーオブジェクト11660037
Ref: library/asyncio-policy asyncio-policy-objects11660197
Ref: 326411660197
Ref: library/asyncio-policy policy-objects11660197
Ref: 326911660197
Ref: library/asyncio-policy asyncio AbstractEventLoopPolicy11660377
Ref: 326511660377
Ref: library/asyncio-policy asyncio AbstractEventLoopPolicy get_event_loop11660485
Ref: 326a11660485
Ref: library/asyncio-policy asyncio AbstractEventLoopPolicy set_event_loop11660883
Ref: 326b11660883
Ref: library/asyncio-policy asyncio AbstractEventLoopPolicy new_event_loop11661021
Ref: 326c11661021
Ref: library/asyncio-policy asyncio AbstractEventLoopPolicy get_child_watcher11661231
Ref: 2a111661231
Ref: library/asyncio-policy asyncio AbstractEventLoopPolicy set_child_watcher11661618
Ref: 2a011661618
Ref: library/asyncio-policy asyncio-policy-builtin11661894
Ref: 326211661894
Ref: library/asyncio-policy asyncio DefaultEventLoopPolicy11661959
Ref: 326d11661959
Ref: library/asyncio-policy asyncio WindowsSelectorEventLoopPolicy11662818
Ref: 326e11662818
Ref: library/asyncio-policy asyncio WindowsProactorEventLoopPolicy11663045
Ref: 326f11663045
Node: プロセスのウオッチャー11663272
Ref: library/asyncio-policy asyncio-watchers11663435
Ref: 31bd11663435
Ref: library/asyncio-policy process-watchers11663435
Ref: 327011663435
Ref: library/asyncio-policy asyncio get_child_watcher11664641
Ref: 29f11664641
Ref: library/asyncio-policy asyncio set_child_watcher11664821
Ref: 29e11664821
Ref: library/asyncio-policy asyncio AbstractChildWatcher11665541
Ref: 29c11665541
Ref: library/asyncio-policy asyncio AbstractChildWatcher add_child_handler11665586
Ref: 327111665586
Ref: library/asyncio-policy asyncio AbstractChildWatcher remove_child_handler11666215
Ref: 327211666215
Ref: library/asyncio-policy asyncio AbstractChildWatcher attach_loop11666573
Ref: 173611666573
Ref: library/asyncio-policy asyncio AbstractChildWatcher is_active11666991
Ref: 327311666991
Ref: library/asyncio-policy asyncio AbstractChildWatcher close11667362
Ref: 327411667362
Ref: library/asyncio-policy asyncio ThreadedChildWatcher11667684
Ref: 44811667684
Ref: library/asyncio-policy asyncio MultiLoopChildWatcher11668289
Ref: 29a11668289
Ref: library/asyncio-policy asyncio SafeChildWatcher11669276
Ref: 29d11669276
Ref: library/asyncio-policy asyncio FastChildWatcher11670146
Ref: 29b11670146
Ref: library/asyncio-policy asyncio PidfdChildWatcher11670769
Ref: 44611670769
Node: ポリシーのカスタマイズ11671547
Ref: library/asyncio-policy asyncio-custom-policies11671671
Ref: 326311671671
Ref: library/asyncio-policy custom-policies11671671
Ref: 327511671671
Node: プラットフォームでのサポート11672389
Ref: library/asyncio-platforms doc11672532
Ref: 327611672532
Ref: library/asyncio-platforms asyncio-platform-support11672532
Ref: 31ff11672532
Ref: library/asyncio-platforms platform-support11672532
Ref: 327711672532
Node: 全てのプラットホーム11672978
Ref: library/asyncio-platforms all-platforms11673107
Ref: 327811673107
Node: Windows<74>11673326
Ref: library/asyncio-platforms windows11673473
Ref: 327911673473
Ref: Windows<74>-Footnote-111675761
Ref: Windows<74>-Footnote-211675845
Ref: Windows<74>-Footnote-311675928
Ref: Windows<74>-Footnote-411676010
Node: Windows におけるサブプロセスのサポート11676075
Ref: library/asyncio-platforms asyncio-windows-subprocess11676176
Ref: 31a911676176
Ref: library/asyncio-platforms subprocess-support-on-windows11676176
Ref: 327b11676176
Node: macOS<47>11676696
Ref: library/asyncio-platforms macos11676804
Ref: 327c11676804
Node: Extending11677660
Ref: library/asyncio-extending doc11677826
Ref: 327e11677826
Ref: library/asyncio-extending extending11677826
Ref: 327f11677826
Node: Writing a Custom Event Loop11678308
Ref: library/asyncio-extending writing-a-custom-event-loop11678426
Ref: 328011678426
Node: Future and Task private constructors11679145
Ref: library/asyncio-extending future-and-task-private-constructors11679293
Ref: 328111679293
Ref: library/asyncio-extending asyncio Future __init__11679857
Ref: 328211679857
Ref: library/asyncio-extending asyncio Task __init__11679997
Ref: 328311679997
Node: Task lifetime support11680330
Ref: library/asyncio-extending task-lifetime-support11680442
Ref: 328411680442
Ref: library/asyncio-extending asyncio _register_task11680678
Ref: 328511680678
Ref: library/asyncio-extending asyncio _unregister_task11680826
Ref: 328611680826
Ref: library/asyncio-extending asyncio _enter_task11681004
Ref: 328711681004
Ref: library/asyncio-extending asyncio _leave_task11681263
Ref: 328811681263
Node: 高水準の API インデックス11681488
Ref: library/asyncio-api-index doc11681647
Ref: 84511681647
Ref: library/asyncio-api-index high-level-api-index11681647
Ref: 328911681647
Node: Task11682019
Ref: library/asyncio-api-index tasks11682116
Ref: 328a11682116
Node: キュー<2>11686878
Ref: library/asyncio-api-index queues11687005
Ref: 328b11687005
Node: サブプロセス<2>11687915
Ref: library/asyncio-api-index subprocesses11688056
Ref: 328c11688056
Node: ストリーム<2>11688769
Ref: library/asyncio-api-index streams11688904
Ref: 328d11688904
Node: 同期11690659
Ref: library/asyncio-api-index synchronization11690783
Ref: 328e11690783
Node: 例外<13>11692343
Ref: library/asyncio-api-index exceptions11692440
Ref: 328f11692440
Node: 低水準の API インデックス11693345
Ref: library/asyncio-llapi-index doc11693515
Ref: 329011693515
Ref: library/asyncio-llapi-index low-level-api-index11693515
Ref: 329111693515
Node: イベントループの取得11693941
Ref: library/asyncio-llapi-index obtaining-the-event-loop11694091
Ref: 329211694091
Node: イベントループのメソッド<2>11695387
Ref: library/asyncio-llapi-index event-loop-methods11695570
Ref: 329311695570
Node: トランスポート<2>11709565
Ref: library/asyncio-llapi-index transports11709736
Ref: 329411709736
Node: プロトコル<2>11717146
Ref: library/asyncio-llapi-index protocols11717314
Ref: 329511717314
Node: イベントループのポリシー11721877
Ref: library/asyncio-llapi-index event-loop-policies11722012
Ref: 329611722012
Node: asyncio での開発11723033
Ref: library/asyncio-dev doc11723159
Ref: 329711723159
Ref: library/asyncio-dev asyncio-dev11723159
Ref: 329811723159
Ref: library/asyncio-dev developing-with-asyncio11723159
Ref: 329911723159
Node: デバッグモード11723705
Ref: library/asyncio-dev asyncio-debug-mode11723834
Ref: 1cb911723834
Ref: library/asyncio-dev debug-mode11723834
Ref: 329a11723834
Node: 並行処理とマルチスレッド処理11725931
Ref: library/asyncio-dev asyncio-multithreading11726105
Ref: 315111726105
Ref: library/asyncio-dev concurrency-and-multithreading11726105
Ref: 329d11726105
Node: ブロッキングコードの実行11729370
Ref: library/asyncio-dev asyncio-handle-blocking11729538
Ref: 329e11729538
Ref: library/asyncio-dev running-blocking-code11729538
Ref: 329f11729538
Node: ログ記録<3>11730247
Ref: library/asyncio-dev asyncio-logger11730430
Ref: 329b11730430
Ref: library/asyncio-dev logging11730430
Ref: 32a011730430
Node: 待ち受け処理を伴わないコルーチンの検出11731091
Ref: library/asyncio-dev asyncio-coroutine-not-scheduled11731271
Ref: 329c11731271
Ref: library/asyncio-dev detect-never-awaited-coroutines11731271
Ref: 32a211731271
Node: 回収されない例外の検出11732495
Ref: library/asyncio-dev detect-never-retrieved-exceptions11732651
Ref: 32a311732651
Ref: 回収されない例外の検出-Footnote-111734493
Node: socket --- 低水準ネットワークインターフェース11734558
Ref: library/socket doc11734813
Ref: 32a411734813
Ref: library/socket module-socket11734813
Ref: b811734813
Ref: library/socket socket-low-level-networking-interface11734813
Ref: 32a511734813
Ref: socket --- 低水準ネットワークインターフェース-Footnote-111736832
Node: ソケットファミリー11736898
Ref: library/socket socket-families11737057
Ref: 32a611737057
Ref: library/socket host-port11738788
Ref: 32a711738788
Ref: ソケットファミリー-Footnote-111750943
Ref: ソケットファミリー-Footnote-211750985
Node: モジュールの内容11751030
Ref: library/socket module-contents11751223
Ref: 32ae11751223
Node: 例外<14>11751438
Ref: library/socket exceptions11751527
Ref: 32af11751527
Ref: library/socket socket error11751558
Ref: 102911751558
Ref: library/socket socket herror11751798
Ref: 32b011751798
Ref: library/socket socket gaierror11752517
Ref: 16be11752517
Ref: library/socket socket timeout11753152
Ref: 7ff11753152
Ref: 例外<14>-Footnote-111753986
Node: 定数<8>11754028
Ref: library/socket constants11754135
Ref: 32b211754135
Ref: library/socket socket AF_UNIX11754334
Ref: 178a11754334
Ref: library/socket socket AF_INET11754364
Ref: 178811754364
Ref: library/socket socket AF_INET611754394
Ref: 178911754394
Ref: library/socket socket AF_UNSPEC11754713
Ref: 31f711754713
Ref: library/socket socket SOCK_STREAM11754929
Ref: 12c111754929
Ref: library/socket socket SOCK_DGRAM11754963
Ref: 12c011754963
Ref: library/socket socket SOCK_RAW11754996
Ref: 32b311754996
Ref: library/socket socket SOCK_RDM11755027
Ref: 32b411755027
Ref: library/socket socket SOCK_SEQPACKET11755058
Ref: 32b511755058
Ref: library/socket socket SOCK_CLOEXEC11755364
Ref: bd911755364
Ref: library/socket socket SOCK_NONBLOCK11755399
Ref: bd811755399
Ref: library/socket socket-unix-constants11755913
Ref: 31f311755913
Ref: library/socket socket SOMAXCONN11755933
Ref: e2811755933
Ref: library/socket socket AF_CAN11758801
Ref: 32a811758801
Ref: library/socket socket PF_CAN11758830
Ref: 32b611758830
Ref: library/socket socket CAN_BCM11759210
Ref: f6f11759210
Ref: library/socket socket CAN_RAW_FD_FRAMES11759697
Ref: e9311759697
Ref: library/socket socket CAN_RAW_JOIN_FILTERS11760318
Ref: 8ff11760318
Ref: library/socket socket CAN_ISOTP11760658
Ref: 32a911760658
Ref: library/socket socket CAN_J193911760915
Ref: 90011760915
Ref: library/socket socket AF_DIVERT11761156
Ref: 32b711761156
Ref: library/socket socket PF_DIVERT11761188
Ref: 32b811761188
Ref: library/socket socket AF_PACKET11761420
Ref: 32aa11761420
Ref: library/socket socket PF_PACKET11761452
Ref: 32b911761452
Ref: library/socket socket ETH_P_ALL11761683
Ref: 171311761683
Ref: library/socket socket AF_RDS11762038
Ref: 32ba11762038
Ref: library/socket socket PF_RDS11762067
Ref: 32bb11762067
Ref: library/socket socket SOL_RDS11762096
Ref: 32bc11762096
Ref: library/socket socket SIO_RCVALL11762353
Ref: 32bd11762353
Ref: library/socket socket SIO_KEEPALIVE_VALS11762386
Ref: 32be11762386
Ref: library/socket socket SIO_LOOPBACK_FAST_PATH11762427
Ref: ca211762427
Ref: library/socket socket AF_ALG11762980
Ref: ca511762980
Ref: library/socket socket SOL_ALG11763009
Ref: 32bf11763009
Ref: library/socket socket AF_VSOCK11763192
Ref: b4311763192
Ref: library/socket socket IOCTL_VM_SOCKETS_GET_LOCAL_CID11763223
Ref: 32c011763223
Ref: library/socket socket AF_LINK11763451
Ref: f7011763451
Ref: library/socket socket has_ipv611763555
Ref: 32c111763555
Ref: library/socket socket BDADDR_ANY11763700
Ref: 32c211763700
Ref: library/socket socket BDADDR_LOCAL11763733
Ref: 32c311763733
Ref: library/socket socket HCI_FILTER11764073
Ref: 32c411764073
Ref: library/socket socket HCI_TIME_STAMP11764106
Ref: 32c511764106
Ref: library/socket socket HCI_DATA_DIR11764143
Ref: 32c611764143
Ref: library/socket socket AF_QIPCRTR11764454
Ref: 32ab11764454
Ref: library/socket socket SCM_CREDS211764653
Ref: 32c711764653
Ref: library/socket socket LOCAL_CREDS11764686
Ref: 32c811764686
Ref: library/socket socket LOCAL_CREDS_PERSISTENT11764720
Ref: 32c911764720
Ref: library/socket socket SO_INCOMING_CPU11765163
Ref: 32ca11765163
Ref: library/socket socket AF_HYPERV11765384
Ref: 32ac11765384
Ref: library/socket socket HV_PROTOCOL_RAW11765416
Ref: 32cb11765416
Ref: library/socket socket HVSOCKET_CONNECT_TIMEOUT11765454
Ref: 32cc11765454
Ref: library/socket socket HVSOCKET_CONNECT_TIMEOUT_MAX11765501
Ref: 32cd11765501
Ref: library/socket socket HVSOCKET_CONNECTED_SUSPEND11765552
Ref: 32ce11765552
Ref: library/socket socket HVSOCKET_ADDRESS_FLAG_PASSTHRU11765601
Ref: 32cf11765601
Ref: library/socket socket HV_GUID_ZERO11765654
Ref: 32d011765654
Ref: library/socket socket HV_GUID_WILDCARD11765689
Ref: 32d111765689
Ref: library/socket socket HV_GUID_BROADCAST11765728
Ref: 32d211765728
Ref: library/socket socket HV_GUID_CHILDREN11765768
Ref: 32d311765768
Ref: library/socket socket HV_GUID_LOOPBACK11765807
Ref: 32d411765807
Ref: library/socket socket HV_GUID_PARENT11765846
Ref: 32d511765846
Ref: library/socket socket-ethernet-types11766035
Ref: 171411766035
Ref: library/socket socket ETHERTYPE_ARP11766035
Ref: 32d611766035
Ref: library/socket socket ETHERTYPE_IP11766071
Ref: 32d711766071
Ref: library/socket socket ETHERTYPE_IPV611766106
Ref: 32d811766106
Ref: library/socket socket ETHERTYPE_VLAN11766143
Ref: 32d911766143
Ref: library/socket socket SHUT_RD11766315
Ref: 32da11766315
Ref: library/socket socket SHUT_WR11766345
Ref: 32db11766345
Ref: library/socket socket SHUT_RDWR11766375
Ref: 32dc11766375
Ref: 定数<8>-Footnote-111766580
Ref: 定数<8>-Footnote-211766632
Ref: 定数<8>-Footnote-311766678
Node: 関数<8>11766758
Ref: library/socket functions11766846
Ref: 32de11766846
Node: ソケットの作成11766958
Ref: library/socket creating-sockets11767055
Ref: 32df11767055
Ref: library/socket socket socket11767186
Ref: d6e11767186
Ref: library/socket socket socketpair11770139
Ref: bc311770139
Ref: library/socket socket create_connection11771039
Ref: 63e11771039
Ref: library/socket socket create_server11772854
Ref: 9f911772854
Ref: library/socket socket has_dualstack_ipv611774646
Ref: 9fa11774646
Ref: library/socket socket fromfd11774844
Ref: 32e111774844
Ref: library/socket socket fromshare11775775
Ref: bd511775775
Ref: library/socket socket SocketType11776093
Ref: 32e311776093
Node: その他の関数<2>11776251
Ref: library/socket other-functions11776348
Ref: 32e411776348
Ref: library/socket socket close11776502
Ref: b4111776502
Ref: library/socket socket getaddrinfo11776777
Ref: 16bd11776777
Ref: library/socket socket getfqdn11781091
Ref: 16e711781091
Ref: library/socket socket gethostbyname11781709
Ref: 32e511781709
Ref: library/socket socket gethostbyname_ex11782549
Ref: 183811782549
Ref: library/socket socket gethostname11783362
Ref: 2a8411783362
Ref: library/socket socket gethostbyaddr11783898
Ref: 183711783898
Ref: library/socket socket getnameinfo11784664
Ref: 162911784664
Ref: library/socket socket getprotobyname11785461
Ref: 32e611785461
Ref: library/socket socket getservbyname11785955
Ref: 32e711785955
Ref: library/socket socket getservbyport11786566
Ref: 32e811786566
Ref: library/socket socket ntohl11787145
Ref: 32e911787145
Ref: library/socket socket ntohs11787548
Ref: 84d11787548
Ref: library/socket socket htonl11788077
Ref: 32ea11788077
Ref: library/socket socket htons11788480
Ref: 84c11788480
Ref: library/socket socket inet_aton11789009
Ref: 92f11789009
Ref: library/socket socket inet_ntoa11790002
Ref: 32eb11790002
Ref: library/socket socket inet_pton11791033
Ref: 93011791033
Ref: library/socket socket inet_ntop11791949
Ref: f7111791949
Ref: library/socket socket CMSG_LEN11793219
Ref: 19a211793219
Ref: library/socket socket CMSG_SPACE11794176
Ref: 19a111794176
Ref: library/socket socket getdefaulttimeout11795330
Ref: 32e211795330
Ref: library/socket socket setdefaulttimeout11795724
Ref: 32b111795724
Ref: library/socket socket sethostname11796156
Ref: 110e11796156
Ref: library/socket socket if_nameindex11796545
Ref: 9fb11796545
Ref: library/socket socket if_nametoindex11797458
Ref: 9fc11797458
Ref: library/socket socket if_indextoname11798055
Ref: 9fd11798055
Ref: library/socket socket send_fds11798651
Ref: 90111798651
Ref: library/socket socket recv_fds11799136
Ref: 90211799136
Ref: その他の関数<2>-Footnote-111799733
Ref: その他の関数<2>-Footnote-211799786
Ref: その他の関数<2>-Footnote-311799837
Ref: その他の関数<2>-Footnote-411799881
Node: socket オブジェクト11799940
Ref: library/socket id111800151
Ref: 32ec11800151
Ref: library/socket socket-objects11800151
Ref: 32e011800151
Ref: library/socket socket socket accept11800645
Ref: d6f11800645
Ref: library/socket socket socket bind11801631
Ref: 109311801631
Ref: library/socket socket socket close11802083
Ref: d1111802083
Ref: library/socket socket socket connect11803158
Ref: d7011803158
Ref: library/socket socket socket connect_ex11804662
Ref: 14e211804662
Ref: library/socket socket socket detach11805440
Ref: 11ee11805440
Ref: library/socket socket socket dup11805736
Ref: 32ed11805736
Ref: library/socket socket socket fileno11806039
Ref: 32ee11806039
Ref: library/socket socket socket get_inheritable11806507
Ref: ec911806507
Ref: library/socket socket socket getpeername11806844
Ref: 323411806844
Ref: library/socket socket socket getsockname11807269
Ref: 323511807269
Ref: library/socket socket socket getsockopt11807580
Ref: ca311807580
Ref: library/socket socket socket getblocking11808339
Ref: b4011808339
Ref: library/socket socket socket gettimeout11808569
Ref: 32ef11808569
Ref: library/socket socket socket ioctl11808999
Ref: ca111808999
Ref: library/socket socket socket listen11809843
Ref: e2711809843
Ref: library/socket socket socket makefile11810466
Ref: 117011810466
Ref: library/socket socket socket recv11811934
Ref: d7111811934
Ref: library/socket socket socket recvfrom11812977
Ref: d7211812977
Ref: library/socket socket socket recvmsg11814126
Ref: d7311814126
Ref: library/socket socket socket recvmsg_into11818915
Ref: 110d11818915
Ref: library/socket socket socket recvfrom_into11820854
Ref: 12ed11820854
Ref: library/socket socket socket recv_into11821545
Ref: 12ec11821545
Ref: library/socket socket socket send11822168
Ref: d7411822168
Ref: library/socket socket socket sendall11823286
Ref: d7511823286
Ref: library/socket socket socket sendto11824587
Ref: d7611824587
Ref: library/socket socket socket sendmsg11825634
Ref: 44311825634
Ref: library/socket socket socket sendmsg_afalg11828341
Ref: ca611828341
Ref: library/socket socket socket sendfile11828757
Ref: e2611828757
Ref: library/socket socket socket set_inheritable11829928
Ref: eca11829928
Ref: library/socket socket socket setblocking11830158
Ref: 2a9b11830158
Ref: library/socket socket socket settimeout11830890
Ref: 32ad11830890
Ref: library/socket socket socket setsockopt11831661
Ref: ca411831661
Ref: library/socket socket socket shutdown11832885
Ref: 32dd11832885
Ref: library/socket socket socket share11833296
Ref: bd611833296
Ref: library/socket socket socket family11834580
Ref: 32f311834580
Ref: library/socket socket socket type11834647
Ref: bda11834647
Ref: library/socket socket socket proto11834706
Ref: 32f411834706
Ref: socket オブジェクト-Footnote-111834808
Ref: socket オブジェクト-Footnote-211834850
Ref: socket オブジェクト-Footnote-311834892
Ref: socket オブジェクト-Footnote-411834942
Ref: socket オブジェクト-Footnote-511835016
Ref: socket オブジェクト-Footnote-611835060
Ref: socket オブジェクト-Footnote-711835102
Ref: socket オブジェクト-Footnote-811835146
Ref: socket オブジェクト-Footnote-911835188
Ref: socket オブジェクト-Footnote-1011835230
Ref: socket オブジェクト-Footnote-1111835275
Ref: socket オブジェクト-Footnote-1211835320
Ref: socket オブジェクト-Footnote-1311835363
Ref: socket オブジェクト-Footnote-1411835406
Ref: socket オブジェクト-Footnote-1511835449
Ref: socket オブジェクト-Footnote-1611835492
Node: ソケットタイムアウトの注意事項11835543
Ref: library/socket notes-on-socket-timeouts11835743
Ref: 32f511835743
Ref: library/socket socket-timeouts11835743
Ref: 32f211835743
Node: タイムアウトと connect メソッド11837694
Ref: library/socket timeouts-and-the-connect-method11837868
Ref: 32f611837868
Node: タイムアウトと accept メソッド11838434
Ref: library/socket timeouts-and-the-accept-method11838608
Ref: 32f711838608
Node: 使用例<26>11839676
Ref: library/socket example11839842
Ref: 32f811839842
Ref: library/socket socket-example11839842
Ref: 32f911839842
Ref: 使用例<26>-Footnote-111848112
Node: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー11848171
Ref: library/ssl doc11848431
Ref: 32fa11848431
Ref: library/ssl module-ssl11848431
Ref: bb11848431
Ref: library/ssl ssl-tls-ssl-wrapper-for-socket-objects11848431
Ref: 32fb11848431
Ref: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー-Footnote-111852062
Ref: ssl --- ソケットオブジェクト用の TLS/SSL ラッパー-Footnote-211852125
Node: 関数、定数、例外11852167
Ref: library/ssl functions-constants-and-exceptions11852318
Ref: 32fc11852318
Node: ソケットの作成<2>11852561
Ref: library/ssl socket-creation11852682
Ref: 32fd11852682
Node: コンテキストの作成11854215
Ref: library/ssl context-creation11854355
Ref: 32fe11854355
Ref: library/ssl ssl create_default_context11854571
Ref: 13b11854571
Ref: コンテキストの作成-Footnote-111859164
Ref: コンテキストの作成-Footnote-211859223
Ref: コンテキストの作成-Footnote-311859268
Node: 例外<15>11859327
Ref: library/ssl exceptions11859455
Ref: 330311859455
Ref: library/ssl ssl SSLError11859486
Ref: 124b11859486
Ref: library/ssl ssl SSLError library11860188
Ref: 111a11860188
Ref: library/ssl ssl SSLError reason11860495
Ref: 111b11860495
Ref: library/ssl ssl SSLZeroReturnError11860775
Ref: 330411860775
Ref: library/ssl ssl SSLWantReadError11861178
Ref: e3211861178
Ref: library/ssl ssl SSLWantWriteError11861572
Ref: e3311861572
Ref: library/ssl ssl SSLSyscallError11861967
Ref: 330611861967
Ref: library/ssl ssl SSLEOFError11862312
Ref: 16af11862312
Ref: library/ssl ssl SSLCertVerificationError11862639
Ref: b4a11862639
Ref: library/ssl ssl SSLCertVerificationError verify_code11862803
Ref: 330711862803
Ref: library/ssl ssl SSLCertVerificationError verify_message11862907
Ref: 330811862907
Ref: library/ssl ssl CertificateError11863005
Ref: 330911863005
Node: 乱数生成11863221
Ref: library/ssl random-generation11863346
Ref: 330a11863346
Ref: library/ssl ssl RAND_bytes11863387
Ref: 4ed11863387
Ref: library/ssl ssl RAND_status11864378
Ref: 183111864378
Ref: library/ssl ssl RAND_add11864745
Ref: 330b11864745
Ref: 乱数生成-Footnote-111865237
Ref: 乱数生成-Footnote-211865331
Ref: 乱数生成-Footnote-311865469
Node: 証明書の取り扱い11865528
Ref: library/ssl certificate-handling11865652
Ref: 330c11865652
Ref: library/ssl ssl cert_time_to_seconds11865713
Ref: e3411865713
Ref: library/ssl ssl get_server_certificate11866738
Ref: 80711866738
Ref: library/ssl ssl DER_cert_to_PEM_cert11867989
Ref: 330e11867989
Ref: library/ssl ssl PEM_cert_to_DER_cert11868220
Ref: 330f11868220
Ref: library/ssl ssl get_default_verify_paths11868433
Ref: f7611868433
Ref: library/ssl ssl enum_certificates11869400
Ref: f8111869400
Ref: library/ssl ssl enum_crls11870487
Ref: f8211870487
Ref: 証明書の取り扱い-Footnote-111871207
Node: 定数<9>11871266
Ref: library/ssl constants11871369
Ref: 331011871369
Ref: library/ssl ssl CERT_NONE11871580
Ref: 331111871580
Ref: library/ssl ssl CERT_OPTIONAL11872218
Ref: 331211872218
Ref: library/ssl ssl CERT_REQUIRED11872973
Ref: 330011872973
Ref: library/ssl ssl VerifyMode11873948
Ref: 331411873948
Ref: library/ssl ssl VERIFY_DEFAULT11874083
Ref: f7b11874083
Ref: library/ssl ssl VERIFY_CRL_CHECK_LEAF11874410
Ref: f7c11874410
Ref: library/ssl ssl VERIFY_CRL_CHECK_CHAIN11874948
Ref: f7d11874948
Ref: library/ssl ssl VERIFY_X509_STRICT11875233
Ref: 13d11875233
Ref: library/ssl ssl VERIFY_ALLOW_PROXY_CERTS11875455
Ref: 184611875455
Ref: library/ssl ssl VERIFY_X509_TRUSTED_FIRST11875638
Ref: 331511875638
Ref: library/ssl ssl VERIFY_X509_PARTIAL_CHAIN11875996
Ref: 13c11875996
Ref: library/ssl ssl VerifyFlags11876435
Ref: 331611876435
Ref: library/ssl ssl PROTOCOL_TLS11876574
Ref: 330211876574
Ref: library/ssl ssl PROTOCOL_TLS_CLIENT11877180
Ref: 83e11877180
Ref: library/ssl ssl PROTOCOL_TLS_SERVER11877498
Ref: 83f11877498
Ref: library/ssl ssl PROTOCOL_SSLv2311877718
Ref: 331711877718
Ref: library/ssl ssl PROTOCOL_SSLv311877930
Ref: 330d11877930
Ref: library/ssl ssl PROTOCOL_TLSv111878644
Ref: 331811878644
Ref: library/ssl ssl PROTOCOL_TLSv1_111878876
Ref: f7411878876
Ref: library/ssl ssl PROTOCOL_TLSv1_211879197
Ref: f7511879197
Ref: library/ssl ssl OP_ALL11879520
Ref: 331911879520
Ref: library/ssl ssl OP_NO_SSLv211879911
Ref: 80411879911
Ref: library/ssl ssl OP_NO_SSLv311880316
Ref: 80511880316
Ref: library/ssl ssl OP_NO_TLSv111880721
Ref: 331a11880721
Ref: library/ssl ssl OP_NO_TLSv1_111881260
Ref: 331b11881260
Ref: library/ssl ssl OP_NO_TLSv1_211881769
Ref: 331c11881769
Ref: library/ssl ssl OP_NO_TLSv1_311882278
Ref: 181111882278
Ref: library/ssl ssl OP_NO_RENEGOTIATION11882875
Ref: 331d11882875
Ref: library/ssl ssl OP_CIPHER_SERVER_PREFERENCE11883179
Ref: 111c11883179
Ref: library/ssl ssl OP_SINGLE_DH_USE11883503
Ref: 331e11883503
Ref: library/ssl ssl OP_SINGLE_ECDH_USE11883763
Ref: 331f11883763
Ref: library/ssl ssl OP_ENABLE_MIDDLEBOX_COMPAT11884027
Ref: 332011884027
Ref: library/ssl ssl OP_NO_COMPRESSION11884327
Ref: 111911884327
Ref: library/ssl ssl Options11884578
Ref: 332111884578
Ref: library/ssl ssl OP_NO_TICKET11884681
Ref: 332211884681
Ref: library/ssl ssl OP_IGNORE_UNEXPECTED_EOF11884860
Ref: 80211884860
Ref: library/ssl ssl OP_ENABLE_KTLS11885068
Ref: 170211885068
Ref: library/ssl ssl OP_LEGACY_SERVER_CONNECT11885798
Ref: 16e811885798
Ref: library/ssl ssl HAS_ALPN11885963
Ref: e2f11885963
Ref: library/ssl ssl HAS_NEVER_CHECK_COMMON_NAME11886213
Ref: 332311886213
Ref: library/ssl ssl HAS_ECDH11886456
Ref: 332411886456
Ref: library/ssl ssl HAS_SNI11886786
Ref: 332511886786
Ref: library/ssl ssl HAS_NPN11887012
Ref: 332611887012
Ref: library/ssl ssl HAS_SSLv211887436
Ref: 332711887436
Ref: library/ssl ssl HAS_SSLv311887617
Ref: 332811887617
Ref: library/ssl ssl HAS_TLSv111887798
Ref: 332911887798
Ref: library/ssl ssl HAS_TLSv1_111887979
Ref: b5111887979
Ref: library/ssl ssl HAS_TLSv1_211888162
Ref: 332a11888162
Ref: library/ssl ssl HAS_TLSv1_311888345
Ref: 332b11888345
Ref: library/ssl ssl HAS_PSK11888528
Ref: 332c11888528
Ref: library/ssl ssl CHANNEL_BINDING_TYPES11888653
Ref: 332d11888653
Ref: library/ssl ssl OPENSSL_VERSION11888937
Ref: 11f011888937
Ref: library/ssl ssl OPENSSL_VERSION_INFO11889189
Ref: 11f111889189
Ref: library/ssl ssl OPENSSL_VERSION_NUMBER11889415
Ref: 11f211889415
Ref: library/ssl ssl ALERT_DESCRIPTION_HANDSHAKE_FAILURE11889707
Ref: 332e11889707
Ref: library/ssl ssl ALERT_DESCRIPTION_INTERNAL_ERROR11889762
Ref: 332f11889762
Ref: library/ssl ssl AlertDescription11890226
Ref: 333011890226
Ref: library/ssl ssl Purpose SERVER_AUTH11890387
Ref: f7f11890387
Ref: library/ssl ssl Purpose CLIENT_AUTH11890796
Ref: f8011890796
Ref: library/ssl ssl SSLErrorNumber11891205
Ref: 333111891205
Ref: library/ssl ssl TLSVersion11891350
Ref: 333211891350
Ref: library/ssl ssl TLSVersion MINIMUM_SUPPORTED11891571
Ref: 333311891571
Ref: library/ssl ssl TLSVersion MAXIMUM_SUPPORTED11891616
Ref: 333411891616
Ref: library/ssl ssl TLSVersion SSLv311891837
Ref: 333511891837
Ref: library/ssl ssl TLSVersion TLSv111891870
Ref: 333611891870
Ref: library/ssl ssl TLSVersion TLSv1_111891903
Ref: 333711891903
Ref: library/ssl ssl TLSVersion TLSv1_211891938
Ref: 333811891938
Ref: library/ssl ssl TLSVersion TLSv1_311891973
Ref: 333911891973
Ref: 定数<9>-Footnote-111892248
Ref: 定数<9>-Footnote-211892307
Ref: 定数<9>-Footnote-311892366
Ref: 定数<9>-Footnote-411892444
Ref: 定数<9>-Footnote-511892503
Node: SSL ソケット11892596
Ref: library/ssl ssl-sockets11892778
Ref: 333a11892778
Ref: library/ssl ssl SSLSocket11892827
Ref: 8b811892827
Ref: library/ssl ssl SSLSocket read11895647
Ref: e3711895647
Ref: library/ssl ssl SSLSocket write11896772
Ref: e3811896772
Ref: library/ssl ssl SSLSocket do_handshake11898510
Ref: e3611898510
Ref: library/ssl ssl SSLSocket getpeercert11899459
Ref: f8411899459
Ref: library/ssl ssl SSLSocket get_verified_chain11903398
Ref: 153f11903398
Ref: library/ssl ssl SSLSocket get_unverified_chain11903713
Ref: 154011903713
Ref: library/ssl ssl SSLSocket cipher11903913
Ref: 323611903913
Ref: library/ssl ssl SSLSocket shared_ciphers11904251
Ref: e3511904251
Ref: library/ssl ssl SSLSocket compression11904890
Ref: 111811904890
Ref: library/ssl ssl SSLSocket get_channel_binding11905326
Ref: 111711905326
Ref: library/ssl ssl SSLSocket selected_alpn_protocol11906167
Ref: e2e11906167
Ref: library/ssl ssl SSLSocket selected_npn_protocol11906707
Ref: 84011906707
Ref: library/ssl ssl SSLSocket unwrap11907229
Ref: 333b11907229
Ref: library/ssl ssl SSLSocket verify_client_post_handshake11907791
Ref: a0011907791
Ref: library/ssl ssl SSLSocket version11908678
Ref: e3111908678
Ref: library/ssl ssl SSLSocket pending11909227
Ref: 333d11909227
Ref: library/ssl ssl SSLSocket context11909400
Ref: 333c11909400
Ref: library/ssl ssl SSLSocket server_side11909530
Ref: 333e11909530
Ref: library/ssl ssl SSLSocket server_hostname11909763
Ref: b4d11909763
Ref: library/ssl ssl SSLSocket session11910315
Ref: 151211910315
Ref: library/ssl ssl SSLSocket session_reused11910792
Ref: 333f11910792
Ref: SSL ソケット-Footnote-111910897
Ref: SSL ソケット-Footnote-211910956
Node: SSL コンテキスト11911015
Ref: library/ssl ssl-contexts11911182
Ref: 334011911182
Ref: library/ssl ssl SSLContext11911657
Ref: 27411911657
Ref: library/ssl ssl SSLContext cert_store_stats11916735
Ref: f7811916735
Ref: library/ssl ssl SSLContext load_cert_chain11917195
Ref: 27511917195
Ref: library/ssl ssl SSLContext load_default_certs11919121
Ref: f7e11919121
Ref: library/ssl ssl SSLContext load_verify_locations11920111
Ref: eb611920111
Ref: library/ssl ssl SSLContext get_ca_certs11921901
Ref: f7911921901
Ref: library/ssl ssl SSLContext get_ciphers11922753
Ref: cac11922753
Ref: library/ssl ssl SSLContext set_default_verify_paths11924144
Ref: f7711924144
Ref: library/ssl ssl SSLContext set_ciphers11924785
Ref: 334211924785
Ref: library/ssl ssl SSLContext set_alpn_protocols11925419
Ref: e2d11925419
Ref: library/ssl ssl SSLContext set_npn_protocols11926159
Ref: 2d911926159
Ref: library/ssl ssl SSLContext sni_callback11926994
Ref: 184011926994
Ref: library/ssl ssl SSLContext set_servername_callback11929968
Ref: f8311929968
Ref: library/ssl ssl SSLContext load_dh_params11930645
Ref: 111511930645
Ref: library/ssl ssl SSLContext set_ecdh_curve11931393
Ref: 111611931393
Ref: library/ssl ssl SSLContext wrap_socket11932318
Ref: 4ee11932318
Ref: library/ssl ssl SSLContext sslsocket_class11935774
Ref: 334311935774
Ref: library/ssl ssl SSLContext wrap_bio11936072
Ref: b5011936072
Ref: library/ssl ssl SSLContext sslobject_class11936863
Ref: 334411936863
Ref: library/ssl ssl SSLContext session_stats11937158
Ref: 334511937158
Ref: library/ssl ssl SSLContext check_hostname11937629
Ref: 331311937629
Ref: library/ssl ssl SSLContext keylog_filename11939185
Ref: 330111939185
Ref: library/ssl ssl SSLContext maximum_version11939631
Ref: 83d11939631
Ref: library/ssl ssl SSLContext minimum_version11940489
Ref: 83c11940489
Ref: library/ssl ssl SSLContext num_tickets11940702
Ref: 334611940702
Ref: library/ssl ssl SSLContext options11940935
Ref: 80311940935
Ref: library/ssl ssl SSLContext post_handshake_auth11941744
Ref: 9ff11941744
Ref: library/ssl ssl SSLContext protocol11942561
Ref: 334711942561
Ref: library/ssl ssl SSLContext hostname_checks_common_name11942733
Ref: b4b11942733
Ref: library/ssl ssl SSLContext security_level11943173
Ref: 334811943173
Ref: library/ssl ssl SSLContext verify_flags11943348
Ref: f7a11943348
Ref: library/ssl ssl SSLContext verify_mode11943985
Ref: 32ff11943985
Ref: library/ssl ssl SSLContext set_psk_client_callback11944599
Ref: 334911944599
Ref: library/ssl ssl SSLContext set_psk_server_callback11946604
Ref: 334a11946604
Ref: SSL コンテキスト-Footnote-111948492
Ref: SSL コンテキスト-Footnote-211948646
Ref: SSL コンテキスト-Footnote-311948778
Ref: SSL コンテキスト-Footnote-411948911
Ref: SSL コンテキスト-Footnote-511949065
Ref: SSL コンテキスト-Footnote-611949197
Ref: SSL コンテキスト-Footnote-711949330
Ref: SSL コンテキスト-Footnote-811949407
Ref: SSL コンテキスト-Footnote-911949461
Ref: SSL コンテキスト-Footnote-1011949520
Ref: SSL コンテキスト-Footnote-1111949599
Ref: SSL コンテキスト-Footnote-1211949659
Ref: SSL コンテキスト-Footnote-1311949736
Ref: SSL コンテキスト-Footnote-1411949802
Node: 証明書11949876
Ref: library/ssl certificates11950040
Ref: 334b11950040
Ref: library/ssl ssl-certificates11950040
Ref: 334111950040
Ref: 証明書-Footnote-111952784
Node: 証明書チェイン11952843
Ref: library/ssl certificate-chains11952931
Ref: 334c11952931
Node: CA 証明書11954293
Ref: library/ssl ca-certificates11954429
Ref: 334d11954429
Node: 秘密鍵と証明書の組み合わせ11955138
Ref: library/ssl combined-key-and-certificate11955274
Ref: 334e11955274
Node: 自己署名証明書11955899
Ref: library/ssl self-signed-certificates11956014
Ref: 334f11956014
Node: 使用例<27>11957628
Ref: library/ssl examples11957833
Ref: 335011957833
Node: SSLサポートをテストする11957992
Ref: library/ssl testing-for-ssl-support11958120
Ref: 335111958120
Node: クライアントサイドの処理11958536
Ref: library/ssl client-side-operation11958700
Ref: 335211958700
Node: サーバサイドの処理11963828
Ref: library/ssl server-side-operation11963950
Ref: 335311963950
Node: ノンブロッキングソケットについての注意事項11966275
Ref: library/ssl notes-on-non-blocking-sockets11966500
Ref: 335411966500
Ref: library/ssl ssl-nonblocking11966500
Ref: 330511966500
Node: メモリ BIO サポート<2>11970381
Ref: library/ssl memory-bio-support11970612
Ref: 335511970612
Ref: library/ssl ssl SSLObject11972097
Ref: b4f11972097
Ref: library/ssl ssl MemoryBIO11976371
Ref: e2b11976371
Ref: library/ssl ssl MemoryBIO pending11976546
Ref: 335611976546
Ref: library/ssl ssl MemoryBIO eof11976656
Ref: 335711976656
Ref: library/ssl ssl MemoryBIO read11976775
Ref: 335811976775
Ref: library/ssl ssl MemoryBIO write11976991
Ref: 335911976991
Ref: library/ssl ssl MemoryBIO write_eof11977369
Ref: 335a11977369
Node: SSL セッション11977729
Ref: library/ssl ssl-session11977939
Ref: 335b11977939
Ref: library/ssl ssl SSLSession11978018
Ref: cab11978018
Ref: library/ssl ssl SSLSession id11978134
Ref: 335c11978134
Ref: library/ssl ssl SSLSession time11978158
Ref: 335d11978158
Ref: library/ssl ssl SSLSession timeout11978184
Ref: 335e11978184
Ref: library/ssl ssl SSLSession ticket_lifetime_hint11978213
Ref: 335f11978213
Ref: library/ssl ssl SSLSession has_ticket11978255
Ref: 336011978255
Node: セキュリティで考慮すべき点<3>11978287
Ref: library/ssl security-considerations11978475
Ref: 336111978475
Ref: library/ssl ssl-security11978475
Ref: 31f111978475
Node: 最善のデフォルト値11978657
Ref: library/ssl best-defaults11978790
Ref: 336211978790
Node: 手動での設定11980269
Ref: library/ssl manual-settings11980435
Ref: 336311980435
Node: 証明書の検証11980579
Ref: library/ssl verifying-certificates11980694
Ref: 336411980694
Node: プロトコルのバージョン11981950
Ref: library/ssl protocol-versions11982089
Ref: 336511982089
Node: 暗号の選択11983042
Ref: library/ssl cipher-selection11983154
Ref: 336611983154
Ref: 暗号の選択-Footnote-111983801
Node: マルチプロセス化11983873
Ref: library/ssl multi-processing11984003
Ref: 336711984003
Node: TLS 1 311984532
Ref: library/ssl ssl-tlsv1-311984692
Ref: b4e11984692
Ref: library/ssl tls-1-311984692
Ref: 336811984692
Ref: TLS 1 3-Footnote-111986844
Ref: TLS 1 3-Footnote-211986910
Ref: TLS 1 3-Footnote-311986969
Ref: TLS 1 3-Footnote-411987028
Ref: TLS 1 3-Footnote-511987087
Ref: TLS 1 3-Footnote-611987146
Ref: TLS 1 3-Footnote-711987205
Ref: TLS 1 3-Footnote-811987281
Ref: TLS 1 3-Footnote-911987340
Node: select --- I/O 完了の待機11987398
Ref: library/select doc11987636
Ref: 336911987636
Ref: library/select module-select11987636
Ref: af11987636
Ref: library/select select-waiting-for-i-o-completion11987636
Ref: 336a11987636
Ref: library/select select error11989210
Ref: 102a11989210
Ref: library/select select devpoll11989450
Ref: f6211989450
Ref: library/select select epoll11990407
Ref: f6011990407
Ref: library/select select poll11992346
Ref: 2b0c11992346
Ref: library/select select kqueue11992945
Ref: 163311992945
Ref: library/select select kevent11993437
Ref: 336e11993437
Ref: library/select select select11993839
Ref: d6d11993839
Ref: library/select select PIPE_BUF11996669
Ref: 11db11996669
Ref: select --- I/O 完了の待機-Footnote-111997517
Ref: select --- I/O 完了の待機-Footnote-211997559
Node: /dev/poll ポーリングオブジェクト11997601
Ref: library/select dev-poll-polling-objects11997796
Ref: 337011997796
Ref: library/select devpoll-objects11997796
Ref: 337111997796
Ref: library/select select devpoll close11998187
Ref: f6411998187
Ref: library/select select devpoll closed11998333
Ref: f6511998333
Ref: library/select select devpoll fileno11998477
Ref: f6311998477
Ref: library/select select devpoll register11998630
Ref: 337211998630
Ref: library/select select devpoll modify11999759
Ref: 337311999759
Ref: library/select select devpoll unregister11999997
Ref: 337411999997
Ref: library/select select devpoll poll12000456
Ref: d6912000456
Ref: /dev/poll ポーリングオブジェクト-Footnote-112002160
Node: エッジおよびレベルトリガポーリング epoll オブジェクト12002202
Ref: library/select edge-and-level-trigger-polling-epoll-objects12002439
Ref: 337512002439
Ref: library/select epoll-objects12002439
Ref: 336c12002439
Ref: library/select select epoll close12005703
Ref: f6112005703
Ref: library/select select epoll closed12005819
Ref: 337612005819
Ref: library/select select epoll fileno12005918
Ref: 337712005918
Ref: library/select select epoll fromfd12006017
Ref: 337812006017
Ref: library/select select epoll register12006118
Ref: 337912006118
Ref: library/select select epoll modify12006252
Ref: 337a12006252
Ref: library/select select epoll unregister12006361
Ref: 92812006361
Ref: library/select select epoll poll12006602
Ref: d6a12006602
Ref: エッジおよびレベルトリガポーリング epoll オブジェクト-Footnote-112007248
Node: ポーリングオブジェクト12007290
Ref: library/select poll-objects12007509
Ref: 336b12007509
Ref: library/select polling-objects12007509
Ref: 337b12007509
Ref: library/select select poll register12008109
Ref: 337c12008109
Ref: library/select select poll modify12010574
Ref: 337d12010574
Ref: library/select select poll unregister12010953
Ref: 337e12010953
Ref: library/select select poll poll12011439
Ref: d6c12011439
Ref: ポーリングオブジェクト-Footnote-112013145
Node: kqueue オブジェクト12013187
Ref: library/select id112013355
Ref: 337f12013355
Ref: library/select kqueue-objects12013355
Ref: 336d12013355
Ref: library/select select kqueue close12013420
Ref: 338012013420
Ref: library/select select kqueue closed12013535
Ref: 338112013535
Ref: library/select select kqueue fileno12013642
Ref: 338212013642
Ref: library/select select kqueue fromfd12013742
Ref: 338312013742
Ref: library/select select kqueue control12013875
Ref: d6b12013875
Ref: kqueue オブジェクト-Footnote-112014742
Node: kevent オブジェクト12014784
Ref: library/select id212014910
Ref: 338412014910
Ref: library/select kevent-objects12014910
Ref: 336f12014910
Ref: library/select select kevent ident12015041
Ref: 338512015041
Ref: library/select select kevent filter12015429
Ref: 338612015429
Ref: library/select select kevent flags12017247
Ref: 338712017247
Ref: library/select select kevent fflags12019027
Ref: 338812019027
Ref: library/select select kevent data12023058
Ref: 338912023058
Ref: library/select select kevent udata12023126
Ref: 338a12023126
Node: selectors --- 高水準の I/O 多重化12023186
Ref: library/selectors doc12023424
Ref: 338b12023424
Ref: library/selectors module-selectors12023424
Ref: b012023424
Ref: library/selectors selectors-high-level-i-o-multiplexing12023424
Ref: 338c12023424
Ref: selectors --- 高水準の I/O 多重化-Footnote-112023788
Node: はじめに<8>12023857
Ref: library/selectors introduction12023970
Ref: 338d12023970
Node: クラス<4>12025841
Ref: library/selectors classes12025976
Ref: 339012025976
Ref: library/selectors selectors EVENT_READ12026629
Ref: 339112026629
Ref: library/selectors selectors EVENT_WRITE12026721
Ref: 339212026721
Ref: library/selectors selectors SelectorKey12026795
Ref: 339312026795
Ref: library/selectors selectors SelectorKey fileobj12027173
Ref: 339412027173
Ref: library/selectors selectors SelectorKey fd12027268
Ref: 339512027268
Ref: library/selectors selectors SelectorKey events12027343
Ref: 339612027343
Ref: library/selectors selectors SelectorKey data12027476
Ref: 339712027476
Ref: library/selectors selectors BaseSelector12027765
Ref: 338e12027765
Ref: library/selectors selectors BaseSelector register12028747
Ref: 339812028747
Ref: library/selectors selectors BaseSelector unregister12029659
Ref: 339912029659
Ref: library/selectors selectors BaseSelector modify12030494
Ref: ba212030494
Ref: library/selectors selectors BaseSelector select12031239
Ref: 339a12031239
Ref: library/selectors selectors BaseSelector close12033130
Ref: 339b12033130
Ref: library/selectors selectors BaseSelector get_key12033411
Ref: 339c12033411
Ref: library/selectors selectors BaseSelector get_map12033825
Ref: 339d12033825
Ref: library/selectors selectors DefaultSelector12034237
Ref: 338f12034237
Ref: library/selectors selectors SelectSelector12034509
Ref: 327a12034509
Ref: library/selectors selectors PollSelector12034624
Ref: ba412034624
Ref: library/selectors selectors EpollSelector12034736
Ref: ba312034736
Ref: library/selectors selectors EpollSelector fileno12034849
Ref: 339e12034849
Ref: library/selectors selectors DevpollSelector12035021
Ref: ba512035021
Ref: library/selectors selectors DevpollSelector fileno12035138
Ref: 339f12035138
Ref: library/selectors selectors KqueueSelector12035340
Ref: 327d12035340
Ref: library/selectors selectors KqueueSelector fileno12035456
Ref: 33a012035456
Ref: クラス<4>-Footnote-112035666
Node: 使用例<28>12035708
Ref: library/selectors examples12035819
Ref: 33a112035819
Node: signal --- 非同期イベントにハンドラーを設定する12036844
Ref: library/signal doc12037106
Ref: 33a212037106
Ref: library/signal module-signal12037106
Ref: b412037106
Ref: library/signal signal-set-handlers-for-asynchronous-events12037106
Ref: 33a312037106
Ref: signal --- 非同期イベントにハンドラーを設定する-Footnote-112037679
Node: 一般的なルール12037745
Ref: library/signal general-rules12037904
Ref: 33a412037904
Node: Python のシグナルハンドラの実行12039211
Ref: library/signal execution-of-python-signal-handlers12039348
Ref: 33a612039348
Node: シグナルとスレッド12040779
Ref: library/signal id112040916
Ref: 33a812040916
Ref: library/signal signals-and-threads12040916
Ref: 33a912040916
Node: モジュールの内容<2>12041547
Ref: library/signal module-contents12041728
Ref: 33aa12041728
Ref: library/signal signal Signals12042359
Ref: 33ae12042359
Ref: library/signal signal Handlers12042509
Ref: 33af12042509
Ref: library/signal signal Sigmasks12042676
Ref: 33b012042676
Ref: library/signal signal SIG_DFL12043113
Ref: 178c12043113
Ref: library/signal signal SIG_IGN12043524
Ref: 178b12043524
Ref: library/signal signal SIGABRT12043682
Ref: 1cb512043682
Ref: library/signal signal SIGALRM12043756
Ref: 33b112043756
Ref: library/signal signal SIGBREAK12043869
Ref: 33b212043869
Ref: library/signal signal SIGBUS12043989
Ref: 1cb612043989
Ref: library/signal signal SIGCHLD12044095
Ref: 2b4712044095
Ref: library/signal signal SIGCLD12044208
Ref: 33b312044208
Ref: library/signal signal SIGCONT12044337
Ref: 2b5512044337
Ref: library/signal signal SIGFPE12044461
Ref: 1cb412044461
Ref: library/signal signal SIGHUP12044697
Ref: 33b412044697
Ref: library/signal signal SIGILL12044850
Ref: 1cb712044850
Ref: library/signal signal SIGINT12044907
Ref: 80f12044907
Ref: library/signal signal SIGKILL12045042
Ref: 33b512045042
Ref: library/signal signal SIGPIPE12045179
Ref: 33a512045179
Ref: library/signal signal SIGSEGV12045345
Ref: 1cb312045345
Ref: library/signal signal SIGSTKFLT12045428
Ref: 17cf12045428
Ref: library/signal signal SIGTERM12045783
Ref: 138712045783
Ref: library/signal signal SIGUSR112045840
Ref: 33b612045840
Ref: library/signal signal SIGUSR212045939
Ref: 33b712045939
Ref: library/signal signal SIGWINCH12046038
Ref: 33b812046038
Ref: library/signal signal CTRL_C_EVENT12047024
Ref: 133012047024
Ref: library/signal signal CTRL_BREAK_EVENT12047281
Ref: 133112047281
Ref: library/signal signal NSIG12047546
Ref: 176912047546
Ref: library/signal signal ITIMER_REAL12047703
Ref: 33ba12047703
Ref: library/signal signal ITIMER_VIRTUAL12047902
Ref: 33bb12047902
Ref: library/signal signal ITIMER_PROF12048120
Ref: 33bc12048120
Ref: library/signal signal SIG_BLOCK12048627
Ref: 33ab12048627
Ref: library/signal signal SIG_UNBLOCK12048832
Ref: 33ac12048832
Ref: library/signal signal SIG_SETMASK12049045
Ref: 33ad12049045
Ref: library/signal signal ItimerError12049322
Ref: 33bd12049322
Ref: library/signal signal alarm12049994
Ref: 33c012049994
Ref: library/signal signal getsignal12050903
Ref: 161012050903
Ref: library/signal signal strsignal12051638
Ref: 19a912051638
Ref: library/signal signal valid_signals12051941
Ref: 33b912051941
Ref: library/signal signal pause12052187
Ref: 33c112052187
Ref: library/signal signal raise_signal12052643
Ref: 176d12052643
Ref: library/signal signal pidfd_send_signal12052779
Ref: 8f912052779
Ref: library/signal signal pthread_kill12053407
Ref: 110412053407
Ref: library/signal signal pthread_sigmask12054686
Ref: 110312054686
Ref: library/signal signal setitimer12056537
Ref: 33be12056537
Ref: library/signal signal getitimer12057783
Ref: 33bf12057783
Ref: library/signal signal set_wakeup_fd12057959
Ref: b3e12057959
Ref: library/signal signal siginterrupt12060292
Ref: 110812060292
Ref: library/signal signal signal12061003
Ref: 110712061003
Ref: library/signal signal sigpending12062861
Ref: 110512062861
Ref: library/signal signal sigwait12063396
Ref: 110612063396
Ref: library/signal signal sigwaitinfo12064055
Ref: d7812064055
Ref: library/signal signal sigtimedwait12065350
Ref: d7712065350
Ref: モジュールの内容<2>-Footnote-112066150
Ref: モジュールの内容<2>-Footnote-212066201
Ref: モジュールの内容<2>-Footnote-312066256
Ref: モジュールの内容<2>-Footnote-412066301
Ref: モジュールの内容<2>-Footnote-512066346
Ref: モジュールの内容<2>-Footnote-612066392
Ref: モジュールの内容<2>-Footnote-712066438
Ref: モジュールの内容<2>-Footnote-812066484
Ref: モジュールの内容<2>-Footnote-912066529
Ref: モジュールの内容<2>-Footnote-1012066575
Ref: モジュールの内容<2>-Footnote-1112066633
Ref: モジュールの内容<2>-Footnote-1212066686
Ref: モジュールの内容<2>-Footnote-1312066738
Ref: モジュールの内容<2>-Footnote-1412066794
Ref: モジュールの内容<2>-Footnote-1512066847
Ref: モジュールの内容<2>-Footnote-1612066894
Ref: モジュールの内容<2>-Footnote-1712066945
Ref: モジュールの内容<2>-Footnote-1812066993
Ref: モジュールの内容<2>-Footnote-1912067045
Ref: モジュールの内容<2>-Footnote-2012067088
Ref: モジュールの内容<2>-Footnote-2112067141
Node: 使用例<29>12067184
Ref: library/signal examples12067359
Ref: 33c212067359
Ref: library/signal signal-example12067359
Ref: 33c312067359
Node: Note on SIGPIPE12068571
Ref: library/signal note-on-sigpipe12068757
Ref: 33c412068757
Ref: Note on SIGPIPE-Footnote-112070204
Node: Note on Signal Handlers and Exceptions12070248
Ref: library/signal handlers-and-exceptions12070412
Ref: 21e712070412
Ref: library/signal note-on-signal-handlers-and-exceptions12070412
Ref: 33c512070412
Node: mmap --- メモリマップファイルのサポート12073019
Ref: library/mmap doc12073232
Ref: 33c612073232
Ref: library/mmap mmap-memory-mapped-file-support12073232
Ref: 33c712073232
Ref: library/mmap module-mmap12073232
Ref: 8312073232
Ref: library/mmap mmap mmap12077000
Ref: 1ec12077000
Ref: library/mmap mmap mmap close12083636
Ref: 33cd12083636
Ref: library/mmap mmap mmap closed12083990
Ref: 33ce12083990
Ref: library/mmap mmap mmap find12084129
Ref: 33cf12084129
Ref: library/mmap mmap mmap flush12084717
Ref: a6612084717
Ref: library/mmap mmap mmap madvise12085646
Ref: 9d612085646
Ref: library/mmap mmap mmap move12086220
Ref: 33d112086220
Ref: library/mmap mmap mmap read12086538
Ref: 10b112086538
Ref: library/mmap mmap mmap read_byte12087153
Ref: 33d212087153
Ref: library/mmap mmap mmap readline12087320
Ref: 33d312087320
Ref: library/mmap mmap mmap resize12087551
Ref: 33cc12087551
Ref: library/mmap mmap mmap rfind12088428
Ref: 33d412088428
Ref: library/mmap mmap mmap seek12089017
Ref: 1ee12089017
Ref: library/mmap mmap mmap seekable12089614
Ref: 1ed12089614
Ref: library/mmap mmap mmap size12089790
Ref: 33cb12089790
Ref: library/mmap mmap mmap tell12089959
Ref: 33d512089959
Ref: library/mmap mmap mmap write12090060
Ref: 33d612090060
Ref: library/mmap mmap mmap write_byte12090964
Ref: 33d712090964
Node: MADV_* 定数12091390
Ref: library/mmap madv-constants12091515
Ref: 33d812091515
Ref: library/mmap madvise-constants12091515
Ref: 33d012091515
Ref: library/mmap mmap MADV_NORMAL12091560
Ref: 33d912091560
Ref: library/mmap mmap MADV_RANDOM12091592
Ref: 33da12091592
Ref: library/mmap mmap MADV_SEQUENTIAL12091624
Ref: 33db12091624
Ref: library/mmap mmap MADV_WILLNEED12091660
Ref: 33dc12091660
Ref: library/mmap mmap MADV_DONTNEED12091694
Ref: 33dd12091694
Ref: library/mmap mmap MADV_REMOVE12091728
Ref: 33de12091728
Ref: library/mmap mmap MADV_DONTFORK12091760
Ref: 33df12091760
Ref: library/mmap mmap MADV_DOFORK12091794
Ref: 33e012091794
Ref: library/mmap mmap MADV_HWPOISON12091826
Ref: 33e112091826
Ref: library/mmap mmap MADV_MERGEABLE12091860
Ref: 33e212091860
Ref: library/mmap mmap MADV_UNMERGEABLE12091895
Ref: 33e312091895
Ref: library/mmap mmap MADV_SOFT_OFFLINE12091932
Ref: 33e412091932
Ref: library/mmap mmap MADV_HUGEPAGE12091970
Ref: 33e512091970
Ref: library/mmap mmap MADV_NOHUGEPAGE12092004
Ref: 33e612092004
Ref: library/mmap mmap MADV_DONTDUMP12092040
Ref: 33e712092040
Ref: library/mmap mmap MADV_DODUMP12092074
Ref: 33e812092074
Ref: library/mmap mmap MADV_FREE12092106
Ref: 33e912092106
Ref: library/mmap mmap MADV_NOSYNC12092136
Ref: 33ea12092136
Ref: library/mmap mmap MADV_AUTOSYNC12092168
Ref: 33eb12092168
Ref: library/mmap mmap MADV_NOCORE12092202
Ref: 33ec12092202
Ref: library/mmap mmap MADV_CORE12092234
Ref: 33ed12092234
Ref: library/mmap mmap MADV_PROTECT12092264
Ref: 33ee12092264
Ref: library/mmap mmap MADV_FREE_REUSABLE12092297
Ref: 33ef12092297
Ref: library/mmap mmap MADV_FREE_REUSE12092336
Ref: 33f012092336
Node: MAP_* 定数12092581
Ref: library/mmap id112092706
Ref: 33f112092706
Ref: library/mmap map-constants12092706
Ref: 33ca12092706
Ref: library/mmap mmap MAP_SHARED12092749
Ref: 33c912092749
Ref: library/mmap mmap MAP_PRIVATE12092780
Ref: 33c812092780
Ref: library/mmap mmap MAP_32BIT12092812
Ref: 160512092812
Ref: library/mmap mmap MAP_ALIGNED_SUPER12092842
Ref: 16c112092842
Ref: library/mmap mmap MAP_ANON12092880
Ref: 33f212092880
Ref: library/mmap mmap MAP_ANONYMOUS12092909
Ref: 33f312092909
Ref: library/mmap mmap MAP_CONCEAL12092943
Ref: 16c212092943
Ref: library/mmap mmap MAP_DENYWRITE12092975
Ref: 33f412092975
Ref: library/mmap mmap MAP_EXECUTABLE12093009
Ref: 33f512093009
Ref: library/mmap mmap MAP_HASSEMAPHORE12093044
Ref: 160012093044
Ref: library/mmap mmap MAP_JIT12093081
Ref: 160212093081
Ref: library/mmap mmap MAP_NOCACHE12093109
Ref: 160112093109
Ref: library/mmap mmap MAP_NOEXTEND12093141
Ref: 15ff12093141
Ref: library/mmap mmap MAP_NORESERVE12093174
Ref: 15fe12093174
Ref: library/mmap mmap MAP_POPULATE12093208
Ref: 18b212093208
Ref: library/mmap mmap MAP_RESILIENT_CODESIGN12093241
Ref: 160312093241
Ref: library/mmap mmap MAP_RESILIENT_MEDIA12093284
Ref: 160412093284
Ref: library/mmap mmap MAP_STACK12093324
Ref: 33f612093324
Ref: library/mmap mmap MAP_TPRO12093354
Ref: 160812093354
Ref: library/mmap mmap MAP_TRANSLATED_ALLOW_EXECUTE12093383
Ref: 160612093383
Ref: library/mmap mmap MAP_UNIX0312093432
Ref: 160712093432
Node: インターネット上のデータの操作12094388
Ref: library/netdata doc12094600
Ref: 33f712094600
Ref: library/netdata internet-data-handling12094600
Ref: 33f812094600
Ref: library/netdata netdata12094600
Ref: 33f912094600
Node: email --- 電子メールと MIME 処理のためのパッケージ12095760
Ref: library/email doc12095968
Ref: 33fa12095968
Ref: library/email email-an-email-and-mime-handling-package12095968
Ref: 33fb12095968
Ref: library/email module-email12095968
Ref: 3212095968
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-112102945
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-212103019
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-312103078
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-412103137
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-512103196
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-612103255
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-712103314
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-812103373
Ref: email --- 電子メールと MIME 処理のためのパッケージ-Footnote-912103432
Node: email message Representing an email message12103491
Ref: library/email message doc12103682
Ref: 33fc12103682
Ref: library/email message email-message-representing-an-email-message12103682
Ref: 33fd12103682
Ref: library/email message module-email message12103682
Ref: 3b12103682
Ref: library/email message email message EmailMessage12106162
Ref: 25c12106162
Ref: library/email message email message EmailMessage as_string12106647
Ref: 33ff12106647
Ref: library/email message email message EmailMessage __str__12108595
Ref: 340112108595
Ref: library/email message email message EmailMessage as_bytes12109077
Ref: 340212109077
Ref: library/email message email message EmailMessage __bytes__12110333
Ref: 340312110333
Ref: library/email message email message EmailMessage is_multipart12110515
Ref: 340412110515
Ref: library/email message email message EmailMessage set_unixfrom12111196
Ref: 340512111196
Ref: library/email message email message EmailMessage get_unixfrom12111422
Ref: 340712111422
Ref: library/email message email message EmailMessage __len__12112662
Ref: 340912112662
Ref: library/email message email message EmailMessage __contains__12112784
Ref: 340a12112784
Ref: library/email message email message EmailMessage __getitem__12113180
Ref: 340b12113180
Ref: library/email message email message EmailMessage __setitem__12113901
Ref: 340e12113901
Ref: library/email message email message EmailMessage __delitem__12115131
Ref: 340f12115131
Ref: library/email message email message EmailMessage keys12115419
Ref: 340812115419
Ref: library/email message email message EmailMessage values12115573
Ref: 341012115573
Ref: library/email message email message EmailMessage items12115709
Ref: 341112115709
Ref: library/email message email message EmailMessage get12115897
Ref: 341212115897
Ref: library/email message email message EmailMessage get_all12116251
Ref: 340c12116251
Ref: library/email message email message EmailMessage add_header12116585
Ref: 341312116585
Ref: library/email message email message EmailMessage replace_header12118670
Ref: 341412118670
Ref: library/email message email message EmailMessage get_content_type12118982
Ref: 341512118982
Ref: library/email message email message EmailMessage get_content_maintype12119868
Ref: 341712119868
Ref: library/email message email message EmailMessage get_content_subtype12120116
Ref: 341812120116
Ref: library/email message email message EmailMessage get_default_type12120393
Ref: 341612120393
Ref: library/email message email message EmailMessage set_default_type12120770
Ref: 341912120770
Ref: library/email message email message EmailMessage set_param12121218
Ref: 341a12121218
Ref: library/email message email message EmailMessage del_param12122876
Ref: 341c12122876
Ref: library/email message email message EmailMessage get_filename12123439
Ref: 341d12123439
Ref: library/email message email message EmailMessage get_boundary12124037
Ref: 341f12124037
Ref: library/email message email message EmailMessage set_boundary12124498
Ref: 342012124498
Ref: library/email message email message EmailMessage get_content_charset12125272
Ref: 342212125272
Ref: library/email message email message EmailMessage get_charsets12125712
Ref: 342312125712
Ref: library/email message email message EmailMessage is_attachment12126595
Ref: 342412126595
Ref: library/email message email message EmailMessage get_content_disposition12127064
Ref: 342612127064
Ref: library/email message email message EmailMessage walk12127545
Ref: 342712127545
Ref: library/email message email message EmailMessage get_body12129786
Ref: 342812129786
Ref: library/email message email message EmailMessage iter_attachments12131914
Ref: 342912131914
Ref: library/email message email message EmailMessage iter_parts12132888
Ref: 342a12132888
Ref: library/email message email message EmailMessage get_content12133107
Ref: 342b12133107
Ref: library/email message email message EmailMessage set_content12133523
Ref: 181312133523
Ref: library/email message email message EmailMessage make_related12133939
Ref: 342e12133939
Ref: library/email message email message EmailMessage make_alternative12134433
Ref: 342f12134433
Ref: library/email message email message EmailMessage make_mixed12134958
Ref: 343012134958
Ref: library/email message email message EmailMessage add_related12135503
Ref: 343112135503
Ref: library/email message email message EmailMessage add_alternative12136266
Ref: 343312136266
Ref: library/email message email message EmailMessage add_attachment12136962
Ref: 343412136962
Ref: library/email message email message EmailMessage clear12137953
Ref: 343512137953
Ref: library/email message email message EmailMessage clear_content12138055
Ref: 343612138055
Ref: library/email message email message EmailMessage preamble12138352
Ref: 343712138352
Ref: library/email message email message EmailMessage epilogue12140105
Ref: 343812140105
Ref: library/email message email message EmailMessage defects12140451
Ref: 343912140451
Ref: library/email message email message MIMEPart12140807
Ref: f0812140807
Ref: email message Representing an email message-Footnote-112141190
Ref: email message Representing an email message-Footnote-212141263
Ref: email message Representing an email message-Footnote-312141475
Ref: email message Representing an email message-Footnote-412141534
Ref: email message Representing an email message-Footnote-512141593
Ref: email message Representing an email message-Footnote-612141652
Ref: email message Representing an email message-Footnote-712141711
Ref: email message Representing an email message-Footnote-812141770
Ref: email message Representing an email message-Footnote-912141829
Ref: email message Representing an email message-Footnote-1012141888
Ref: email message Representing an email message-Footnote-1112141948
Ref: email message Representing an email message-Footnote-1212142008
Ref: email message Representing an email message-Footnote-1312142068
Node: email parser Parsing email messages12142128
Ref: library/email parser doc12142369
Ref: 343a12142369
Ref: library/email parser email-parser-parsing-email-messages12142369
Ref: 343b12142369
Ref: library/email parser module-email parser12142369
Ref: 4512142369
Ref: email parser Parsing email messages-Footnote-112144764
Node: FeedParser API12144836
Ref: library/email parser feedparser-api12144941
Ref: 343d12144941
Ref: library/email parser email parser BytesFeedParser12146541
Ref: 119b12146541
Ref: library/email parser email parser BytesFeedParser feed12147793
Ref: 343e12147793
Ref: library/email parser email parser BytesFeedParser close12148344
Ref: 343f12148344
Ref: library/email parser email parser FeedParser12148590
Ref: 343c12148590
Node: Parser API12149091
Ref: library/email parser parser-api12149217
Ref: 344012149217
Ref: library/email parser email parser BytesParser12149949
Ref: 119c12149949
Ref: library/email parser email parser BytesParser parse12150650
Ref: 344112150650
Ref: library/email parser email parser BytesParser parsebytes12151734
Ref: 344212151734
Ref: library/email parser email parser BytesHeaderParser12152274
Ref: 108d12152274
Ref: library/email parser email parser Parser12152499
Ref: 116f12152499
Ref: library/email parser email parser Parser parse12152874
Ref: 344312152874
Ref: library/email parser email parser Parser parsestr12153550
Ref: 344412153550
Ref: library/email parser email parser HeaderParser12154141
Ref: 108e12154141
Ref: library/email parser email message_from_bytes12154646
Ref: 119912154646
Ref: library/email parser email message_from_binary_file12155230
Ref: 119a12155230
Ref: library/email parser email message_from_string12155814
Ref: 344512155814
Ref: library/email parser email message_from_file12156298
Ref: 344612156298
Ref: Parser API-Footnote-112157163
Ref: Parser API-Footnote-212157222
Node: 追記事項12157281
Ref: library/email parser additional-notes12157384
Ref: 344712157384
Node: email generator Generating MIME documents12159149
Ref: library/email generator doc12159374
Ref: 344812159374
Ref: library/email generator email-generator-generating-mime-documents12159374
Ref: 344912159374
Ref: library/email generator module-email generator12159374
Ref: 3712159374
Ref: library/email generator email generator BytesGenerator12161467
Ref: 119f12161467
Ref: library/email generator email generator BytesGenerator flatten12163425
Ref: 344b12163425
Ref: library/email generator email generator BytesGenerator clone12165342
Ref: 344e12165342
Ref: library/email generator email generator BytesGenerator write12165547
Ref: 344c12165547
Ref: library/email generator email generator Generator12166603
Ref: 119e12166603
Ref: library/email generator email generator Generator flatten12168499
Ref: 344f12168499
Ref: library/email generator email generator Generator clone12170407
Ref: 345112170407
Ref: library/email generator email generator Generator write12170599
Ref: 345012170599
Ref: library/email generator email generator DecodedGenerator12171515
Ref: c6512171515
Ref: email generator Generating MIME documents-Footnote-112172979
Ref: email generator Generating MIME documents-Footnote-212173055
Ref: email generator Generating MIME documents-Footnote-312173562
Ref: email generator Generating MIME documents-Footnote-412173614
Ref: email generator Generating MIME documents-Footnote-512173673
Ref: email generator Generating MIME documents-Footnote-612173725
Node: email policy Policy Objects12173784
Ref: library/email policy doc12174015
Ref: 345212174015
Ref: library/email policy email-policy-policy-objects12174015
Ref: 345312174015
Ref: library/email policy module-email policy12174015
Ref: 4612174015
Ref: library/email policy email policy Policy12180389
Ref: 108312180389
Ref: library/email policy email policy Policy max_line_length12181216
Ref: 340012181216
Ref: library/email policy email policy Policy linesep12181603
Ref: 345412181603
Ref: library/email policy email policy Policy cte_type12181870
Ref: 344d12181870
Ref: library/email policy email policy Policy raise_on_defect12182977
Ref: 345612182977
Ref: library/email policy email policy Policy mangle_from_12183221
Ref: dc312183221
Ref: library/email policy email policy Policy message_factory12183546
Ref: c6612183546
Ref: library/email policy email policy Policy verify_generated_headers12183823
Ref: 1c412183823
Ref: library/email policy email policy Policy clone12184669
Ref: 108512184669
Ref: library/email policy email policy Policy handle_defect12185161
Ref: 345912185161
Ref: library/email policy email policy Policy register_defect12185646
Ref: 345712185646
Ref: library/email policy email policy Policy header_max_count12186370
Ref: 345a12186370
Ref: library/email policy email policy Policy header_source_parse12187454
Ref: 345b12187454
Ref: library/email policy email policy Policy header_store_parse12188549
Ref: 345c12188549
Ref: library/email policy email policy Policy header_fetch_parse12189327
Ref: 345d12189327
Ref: library/email policy email policy Policy fold12190261
Ref: 345e12190261
Ref: library/email policy email policy Policy fold_binary12191078
Ref: 345512191078
Ref: library/email policy email policy EmailPolicy12191524
Ref: 108712191524
Ref: library/email policy email policy EmailPolicy utf812192361
Ref: dc512192361
Ref: library/email policy email policy EmailPolicy refold_source12192753
Ref: 344a12192753
Ref: library/email policy email policy EmailPolicy header_factory12193561
Ref: 345f12193561
Ref: library/email policy email policy EmailPolicy content_manager12194172
Ref: f0712194172
Ref: library/email policy email policy EmailPolicy header_max_count12194874
Ref: 346112194874
Ref: library/email policy email policy EmailPolicy header_source_parse12195086
Ref: 346312195086
Ref: library/email policy email policy EmailPolicy header_store_parse12195473
Ref: 346412195473
Ref: library/email policy email policy EmailPolicy header_fetch_parse12195960
Ref: 346512195960
Ref: library/email policy email policy EmailPolicy fold12196392
Ref: 15d912196392
Ref: library/email policy email policy EmailPolicy fold_binary12197557
Ref: 346612197557
Ref: library/email policy email policy default12198405
Ref: 108812198405
Ref: library/email policy email policy SMTP12198664
Ref: 108912198664
Ref: library/email policy email policy SMTPUTF812198871
Ref: 346712198871
Ref: library/email policy email policy HTTP12199290
Ref: 346812199290
Ref: library/email policy email policy strict12199487
Ref: 346912199487
Ref: library/email policy email policy Compat3212200891
Ref: 108412200891
Ref: library/email policy email policy Compat32 mangle_from_12201418
Ref: 346a12201418
Ref: library/email policy email policy Compat32 header_source_parse12201610
Ref: 346b12201610
Ref: library/email policy email policy Compat32 header_store_parse12201997
Ref: 346c12201997
Ref: library/email policy email policy Compat32 header_fetch_parse12202117
Ref: 346d12202117
Ref: library/email policy email policy Compat32 fold12202365
Ref: 346e12202365
Ref: library/email policy email policy Compat32 fold_binary12202714
Ref: 346f12202714
Ref: library/email policy email policy compat3212203250
Ref: c6712203250
Ref: email policy Policy Objects-Footnote-112203486
Ref: email policy Policy Objects-Footnote-212203558
Ref: email policy Policy Objects-Footnote-312203617
Ref: email policy Policy Objects-Footnote-412203676
Ref: email policy Policy Objects-Footnote-512203735
Ref: email policy Policy Objects-Footnote-612203794
Ref: email policy Policy Objects-Footnote-712203853
Ref: email policy Policy Objects-Footnote-812203912
Ref: email policy Policy Objects-Footnote-912203982
Ref: email policy Policy Objects-Footnote-1012204041
Ref: email policy Policy Objects-Footnote-1112204101
Ref: email policy Policy Objects-Footnote-1212204161
Node: email errors Exception and Defect classes12204221
Ref: library/email errors doc12204453
Ref: 347012204453
Ref: library/email errors email-errors-exception-and-defect-classes12204453
Ref: 347112204453
Ref: library/email errors module-email errors12204453
Ref: 3612204453
Ref: library/email errors email errors MessageError12204783
Ref: 347212204783
Ref: library/email errors email errors MessageParseError12205077
Ref: 347312205077
Ref: library/email errors email errors HeaderParseError12205351
Ref: 342112205351
Ref: library/email errors email errors BoundaryError12205991
Ref: 347412205991
Ref: library/email errors email errors MultipartConversionError12206068
Ref: 347512206068
Ref: library/email errors email errors HeaderWriteError12207026
Ref: 345812207026
Ref: library/email errors email errors MessageDefect12207155
Ref: 347812207155
Ref: library/email errors email errors HeaderDefect12207323
Ref: 347912207323
Ref: email errors Exception and Defect classes-Footnote-112210734
Ref: email errors Exception and Defect classes-Footnote-212210806
Node: email headerregistry Custom Header Objects12210865
Ref: library/email headerregistry doc12211112
Ref: 347a12211112
Ref: library/email headerregistry email-headerregistry-custom-header-objects12211112
Ref: 347b12211112
Ref: library/email headerregistry module-email headerregistry12211112
Ref: 3912211112
Ref: library/email headerregistry email headerregistry BaseHeader12213568
Ref: 340d12213568
Ref: library/email headerregistry email headerregistry BaseHeader name12213963
Ref: 347e12213963
Ref: library/email headerregistry email headerregistry BaseHeader defects12214246
Ref: 347f12214246
Ref: library/email headerregistry email headerregistry BaseHeader max_count12214737
Ref: 346212214737
Ref: library/email headerregistry email headerregistry BaseHeader fold12215405
Ref: 348012215405
Ref: library/email headerregistry email headerregistry UnstructuredHeader12218162
Ref: 347d12218162
Ref: library/email headerregistry email headerregistry DateHeader12219621
Ref: 348112219621
Ref: library/email headerregistry email headerregistry DateHeader datetime12219983
Ref: 348212219983
Ref: library/email headerregistry email headerregistry AddressHeader12221756
Ref: 348312221756
Ref: library/email headerregistry email headerregistry AddressHeader groups12222113
Ref: 348412222113
Ref: library/email headerregistry email headerregistry AddressHeader addresses12222514
Ref: 348712222514
Ref: library/email headerregistry email headerregistry SingleAddressHeader12223769
Ref: 348912223769
Ref: library/email headerregistry email headerregistry SingleAddressHeader address12223918
Ref: 348a12223918
Ref: library/email headerregistry email headerregistry MIMEVersionHeader12224450
Ref: 348b12224450
Ref: library/email headerregistry email headerregistry MIMEVersionHeader version12224846
Ref: 348c12224846
Ref: library/email headerregistry email headerregistry MIMEVersionHeader major12224965
Ref: 348d12224965
Ref: library/email headerregistry email headerregistry MIMEVersionHeader minor12225046
Ref: 348e12225046
Ref: library/email headerregistry email headerregistry ParameterizedMIMEHeader12225127
Ref: 348f12225127
Ref: library/email headerregistry email headerregistry ParameterizedMIMEHeader params12225510
Ref: 341b12225510
Ref: library/email headerregistry email headerregistry ContentTypeHeader12225607
Ref: 349012225607
Ref: library/email headerregistry email headerregistry ContentTypeHeader content_type12225768
Ref: 349112225768
Ref: library/email headerregistry email headerregistry ContentTypeHeader maintype12225874
Ref: 349212225874
Ref: library/email headerregistry email headerregistry ContentTypeHeader subtype12225904
Ref: 349312225904
Ref: library/email headerregistry email headerregistry ContentDispositionHeader12225933
Ref: 349412225933
Ref: library/email headerregistry email headerregistry ContentDispositionHeader content_disposition12226107
Ref: 349512226107
Ref: library/email headerregistry email headerregistry ContentTransferEncoding12226244
Ref: 349612226244
Ref: library/email headerregistry email headerregistry ContentTransferEncoding cte12226371
Ref: 349712226371
Ref: library/email headerregistry email headerregistry HeaderRegistry12226573
Ref: 347c12226573
Ref: library/email headerregistry email headerregistry HeaderRegistry map_to_type12228334
Ref: 349812228334
Ref: library/email headerregistry email headerregistry HeaderRegistry __getitem__12228675
Ref: 349912228675
Ref: library/email headerregistry email headerregistry HeaderRegistry __call__12228804
Ref: 349a12228804
Ref: library/email headerregistry email headerregistry Address12229450
Ref: 348812229450
Ref: library/email headerregistry email headerregistry Address display_name12230341
Ref: 349b12230341
Ref: library/email headerregistry email headerregistry Address username12230567
Ref: 349c12230567
Ref: library/email headerregistry email headerregistry Address domain12230688
Ref: 349d12230688
Ref: library/email headerregistry email headerregistry Address addr_spec12230766
Ref: 349e12230766
Ref: library/email headerregistry email headerregistry Address __str__12230984
Ref: 349f12230984
Ref: library/email headerregistry email headerregistry Group12231429
Ref: 348512231429
Ref: library/email headerregistry email headerregistry Group display_name12232020
Ref: 348612232020
Ref: library/email headerregistry email headerregistry Group addresses12232275
Ref: 34a012232275
Ref: library/email headerregistry email headerregistry Group __str__12232423
Ref: 34a112232423
Ref: email headerregistry Custom Header Objects-Footnote-112232882
Ref: email headerregistry Custom Header Objects-Footnote-212232963
Ref: email headerregistry Custom Header Objects-Footnote-312233032
Ref: email headerregistry Custom Header Objects-Footnote-412233091
Ref: email headerregistry Custom Header Objects-Footnote-512233150
Ref: email headerregistry Custom Header Objects-Footnote-612233209
Ref: email headerregistry Custom Header Objects-Footnote-712233268
Ref: email headerregistry Custom Header Objects-Footnote-812233327
Ref: email headerregistry Custom Header Objects-Footnote-912233386
Ref: email headerregistry Custom Header Objects-Footnote-1012233445
Ref: email headerregistry Custom Header Objects-Footnote-1112233505
Ref: email headerregistry Custom Header Objects-Footnote-1212233565
Ref: email headerregistry Custom Header Objects-Footnote-1312233625
Ref: email headerregistry Custom Header Objects-Footnote-1412233685
Ref: email headerregistry Custom Header Objects-Footnote-1512233745
Ref: email headerregistry Custom Header Objects-Footnote-1612233805
Ref: email headerregistry Custom Header Objects-Footnote-1712233865
Node: email contentmanager Managing MIME Content12233925
Ref: library/email contentmanager doc12234146
Ref: 34a212234146
Ref: library/email contentmanager email-contentmanager-managing-mime-content12234146
Ref: 34a312234146
Ref: library/email contentmanager module-email contentmanager12234146
Ref: 3412234146
Ref: library/email contentmanager email contentmanager ContentManager12234412
Ref: 34a412234412
Ref: library/email contentmanager email contentmanager ContentManager get_content12234705
Ref: 342c12234705
Ref: library/email contentmanager email contentmanager ContentManager set_content12235514
Ref: 342d12235514
Ref: library/email contentmanager email contentmanager ContentManager add_get_handler12237130
Ref: 34a612237130
Ref: library/email contentmanager email contentmanager ContentManager add_set_handler12237328
Ref: 34a812237328
Ref: email contentmanager Managing MIME Content-Footnote-112237699
Ref: email contentmanager Managing MIME Content-Footnote-212237780
Node: Content Manager Instances12237849
Ref: library/email contentmanager content-manager-instances12237953
Ref: 34aa12237953
Ref: library/email contentmanager email contentmanager raw_data_manager12238294
Ref: 346012238294
Ref: library/email contentmanager email contentmanager get_content12239029
Ref: 34a712239029
Ref: library/email contentmanager email contentmanager set_content12239634
Ref: 34a912239634
Ref: Content Manager Instances-Footnote-112243951
Node: email 使用例12244010
Ref: library/email examples doc12244278
Ref: 34ab12244278
Ref: library/email examples email-examples12244278
Ref: f0912244278
Ref: library/email examples id112244278
Ref: 34ac12244278
Ref: email 使用例-Footnote-112259398
Ref: email 使用例-Footnote-212259456
Node: email message Message compat32 API を使用した電子メールメッセージの表現12259541
Ref: library/email compat32-message doc12259822
Ref: 34ad12259822
Ref: library/email compat32-message compat32-message12259822
Ref: 33fe12259822
Ref: library/email compat32-message email-message-message-representing-an-email-message-using-the-compat32-api12259822
Ref: 34ae12259822
Ref: library/email compat32-message email message Message12262408
Ref: 25d12262408
Ref: library/email compat32-message email message Message as_string12262970
Ref: f0312262970
Ref: library/email compat32-message email message Message __str__12265249
Ref: 34af12265249
Ref: library/email compat32-message email message Message as_bytes12265420
Ref: f0412265420
Ref: library/email compat32-message email message Message __bytes__12267071
Ref: f0512267071
Ref: library/email compat32-message email message Message is_multipart12267284
Ref: 342512267284
Ref: library/email compat32-message email message Message set_unixfrom12267956
Ref: 34b012267956
Ref: library/email compat32-message email message Message get_unixfrom12268159
Ref: 34b112268159
Ref: library/email compat32-message email message Message attach12268381
Ref: 343212268381
Ref: library/email compat32-message email message Message get_payload12269213
Ref: 119d12269213
Ref: library/email compat32-message email message Message set_payload12272091
Ref: 34b212272091
Ref: library/email compat32-message email message Message set_charset12272670
Ref: 34b312272670
Ref: library/email compat32-message email message Message get_charset12274709
Ref: 34b412274709
Ref: library/email compat32-message email message Message __len__12276505
Ref: 34b612276505
Ref: library/email compat32-message email message Message __contains__12276627
Ref: 16ea12276627
Ref: library/email compat32-message email message Message __getitem__12277173
Ref: 34b712277173
Ref: library/email compat32-message email message Message __setitem__12277863
Ref: 34b912277863
Ref: library/email compat32-message email message Message __delitem__12278618
Ref: 34ba12278618
Ref: library/email compat32-message email message Message keys12278906
Ref: 34b512278906
Ref: library/email compat32-message email message Message values12279060
Ref: 34bb12279060
Ref: library/email compat32-message email message Message items12279196
Ref: 34bc12279196
Ref: library/email compat32-message email message Message get12279384
Ref: 34bd12279384
Ref: library/email compat32-message email message Message get_all12279730
Ref: 34b812279730
Ref: library/email compat32-message email message Message add_header12280064
Ref: 34be12280064
Ref: library/email compat32-message email message Message replace_header12282501
Ref: 34bf12282501
Ref: library/email compat32-message email message Message get_content_type12282889
Ref: 34c012282889
Ref: library/email compat32-message email message Message get_content_maintype12284154
Ref: 34c212284154
Ref: library/email compat32-message email message Message get_content_subtype12284402
Ref: 34c312284402
Ref: library/email compat32-message email message Message get_default_type12284679
Ref: 34c112284679
Ref: library/email compat32-message email message Message set_default_type12285056
Ref: 34c412285056
Ref: library/email compat32-message email message Message get_params12285428
Ref: 34c512285428
Ref: library/email compat32-message email message Message get_param12286777
Ref: 34c612286777
Ref: library/email compat32-message email message Message set_param12289325
Ref: f0612289325
Ref: library/email compat32-message email message Message del_param12290980
Ref: 34c812290980
Ref: library/email compat32-message email message Message set_type12291605
Ref: 34c912291605
Ref: library/email compat32-message email message Message get_filename12292765
Ref: 34ca12292765
Ref: library/email compat32-message email message Message get_boundary12293363
Ref: 34cb12293363
Ref: library/email compat32-message email message Message set_boundary12293824
Ref: 34cc12293824
Ref: library/email compat32-message email message Message get_content_charset12294790
Ref: 34cd12294790
Ref: library/email compat32-message email message Message get_charsets12295536
Ref: 34ce12295536
Ref: library/email compat32-message email message Message get_content_disposition12296431
Ref: dc412296431
Ref: library/email compat32-message email message Message walk12296800
Ref: 34cf12296800
Ref: library/email compat32-message email message Message preamble12299249
Ref: 34d012299249
Ref: library/email compat32-message email message Message epilogue12301002
Ref: 34d112301002
Ref: library/email compat32-message email message Message defects12301426
Ref: 34d212301426
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-112301818
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-212301877
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-312301936
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-412301995
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-512302054
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-612302113
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-712302172
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-812302231
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-912302290
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-1012302349
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-1112302409
Ref: email message Message compat32 API を使用した電子メールメッセージの表現-Footnote-1212302469
Node: email mime Creating email and MIME objects from scratch12302529
Ref: library/email mime doc12302838
Ref: 34d312302838
Ref: library/email mime email-mime-creating-email-and-mime-objects-from-scratch12302838
Ref: 34d412302838
Ref: library/email mime module-email mime12302838
Ref: 3c12302838
Ref: library/email mime module-email mime base12304689
Ref: 3f12304689
Ref: library/email mime email mime base MIMEBase12304689
Ref: 34d512304689
Ref: library/email mime module-email mime nonmultipart12306157
Ref: 4312306157
Ref: library/email mime email mime nonmultipart MIMENonMultipart12306157
Ref: 347612306157
Ref: library/email mime module-email mime multipart12306791
Ref: 4212306791
Ref: library/email mime email mime multipart MIMEMultipart12306791
Ref: 34d612306791
Ref: library/email mime module-email mime application12308589
Ref: 3d12308589
Ref: library/email mime email mime application MIMEApplication12308589
Ref: 34d712308589
Ref: library/email mime module-email mime audio12310239
Ref: 3e12310239
Ref: library/email mime email mime audio MIMEAudio12310239
Ref: 34d812310239
Ref: library/email mime module-email mime image12312116
Ref: 4012312116
Ref: library/email mime email mime image MIMEImage12312116
Ref: 347712312116
Ref: library/email mime module-email mime message12314046
Ref: 4112314046
Ref: library/email mime email mime message MIMEMessage12314046
Ref: 34d912314046
Ref: library/email mime module-email mime text12315084
Ref: 4412315084
Ref: library/email mime email mime text MIMEText12315084
Ref: dc612315084
Ref: email mime Creating email and MIME objects from scratch-Footnote-112317216
Node: email header 国際化されたヘッダー12317284
Ref: library/email header doc12317539
Ref: 34da12317539
Ref: library/email header email-header-internationalized-headers12317539
Ref: 34db12317539
Ref: library/email header module-email header12317539
Ref: 3812317539
Ref: library/email header email header Header12320977
Ref: 181412320977
Ref: library/email header email header Header append12323414
Ref: 34dc12323414
Ref: library/email header email header Header encode12325158
Ref: 34dd12325158
Ref: library/email header email header Header __str__12327154
Ref: 34de12327154
Ref: library/email header email header Header __eq__12327753
Ref: 34df12327753
Ref: library/email header email header Header __ne__12327956
Ref: 34e012327956
Ref: library/email header email header decode_header12328286
Ref: 108a12328286
Ref: library/email header email header make_header12329136
Ref: 108b12329136
Ref: email header 国際化されたヘッダー-Footnote-112330053
Ref: email header 国際化されたヘッダー-Footnote-212330125
Ref: email header 国際化されたヘッダー-Footnote-312330184
Ref: email header 国際化されたヘッダー-Footnote-412330242
Ref: email header 国際化されたヘッダー-Footnote-512330301
Ref: email header 国際化されたヘッダー-Footnote-612330360
Ref: email header 国際化されたヘッダー-Footnote-712330419
Ref: email header 国際化されたヘッダー-Footnote-812330478
Ref: email header 国際化されたヘッダー-Footnote-912330537
Ref: email header 国際化されたヘッダー-Footnote-1012330596
Ref: email header 国際化されたヘッダー-Footnote-1112330656
Ref: email header 国際化されたヘッダー-Footnote-1212330716
Ref: email header 国際化されたヘッダー-Footnote-1312330776
Ref: email header 国際化されたヘッダー-Footnote-1412330836
Ref: email header 国際化されたヘッダー-Footnote-1512330896
Node: email charset 文字集合の表現12330956
Ref: library/email charset doc12331189
Ref: 34e112331189
Ref: library/email charset email-charset-representing-character-sets12331189
Ref: 34e212331189
Ref: library/email charset module-email charset12331189
Ref: 3312331189
Ref: library/email charset email charset Charset12332163
Ref: dc712332163
Ref: library/email charset email charset Charset input_charset12334232
Ref: 34e312334232
Ref: library/email charset email charset Charset header_encoding12334569
Ref: 34e412334569
Ref: library/email charset email charset Charset body_encoding12335116
Ref: 34e512335116
Ref: library/email charset email charset Charset output_charset12335493
Ref: 34e612335493
Ref: library/email charset email charset Charset input_codec12335995
Ref: 34e712335995
Ref: library/email charset email charset Charset output_codec12336247
Ref: 34e812336247
Ref: library/email charset email charset Charset get_body_encoding12336687
Ref: 34e912336687
Ref: library/email charset email charset Charset get_output_charset12337665
Ref: 34ea12337665
Ref: library/email charset email charset Charset header_encode12337949
Ref: 34eb12337949
Ref: library/email charset email charset Charset header_encode_lines12338216
Ref: 34ec12338216
Ref: library/email charset email charset Charset body_encode12338795
Ref: 34ed12338795
Ref: library/email charset email charset Charset __str__12339226
Ref: 34ee12339226
Ref: library/email charset email charset Charset __eq__12339439
Ref: 34ef12339439
Ref: library/email charset email charset Charset __ne__12339634
Ref: 34f012339634
Ref: library/email charset email charset add_charset12340073
Ref: 34f112340073
Ref: library/email charset email charset add_alias12341971
Ref: 34f312341971
Ref: library/email charset email charset add_codec12342453
Ref: 34f212342453
Ref: email charset 文字集合の表現-Footnote-112342879
Node: email encoders エンコーダー12342952
Ref: library/email encoders doc12343177
Ref: 34f412343177
Ref: library/email encoders email-encoders-encoders12343177
Ref: 34f512343177
Ref: library/email encoders module-email encoders12343177
Ref: 3512343177
Ref: library/email encoders email encoders encode_quopri12345507
Ref: 34f612345507
Ref: library/email encoders email encoders encode_base6412345961
Ref: 34f712345961
Ref: library/email encoders email encoders encode_7or8bit12346528
Ref: 34f812346528
Ref: library/email encoders email encoders encode_noop12346818
Ref: 34f912346818
Ref: email encoders エンコーダー-Footnote-112347049
Ref: email encoders エンコーダー-Footnote-212347123
Node: email utils Miscellaneous utilities12347284
Ref: library/email utils doc12347505
Ref: 34fa12347505
Ref: library/email utils email-utils-miscellaneous-utilities12347505
Ref: 34fb12347505
Ref: library/email utils module-email utils12347505
Ref: 4712347505
Ref: library/email utils email utils localtime12347838
Ref: 2a512347838
Ref: library/email utils email utils make_msgid12348426
Ref: 34fc12348426
Ref: library/email utils email utils quote12349351
Ref: 34fd12349351
Ref: library/email utils email utils unquote12349643
Ref: 341e12349643
Ref: library/email utils email utils parseaddr12350013
Ref: 1c612350013
Ref: library/email utils email utils formataddr12350636
Ref: 116c12350636
Ref: library/email utils email utils getaddresses12351382
Ref: 1c512351382
Ref: library/email utils email utils parsedate12352234
Ref: 34fe12352234
Ref: library/email utils email utils parsedate_tz12353036
Ref: 17e912353036
Ref: library/email utils email utils parsedate_to_datetime12353615
Ref: 109012353615
Ref: library/email utils email utils mktime_tz12354498
Ref: 34ff12354498
Ref: library/email utils email utils formatdate12354829
Ref: 140f12354829
Ref: library/email utils email utils format_datetime12355985
Ref: 108f12355985
Ref: library/email utils email utils decode_rfc223112356672
Ref: 350012356672
Ref: library/email utils email utils encode_rfc223112356791
Ref: 350112356791
Ref: library/email utils email utils collapse_rfc2231_value12357383
Ref: 34c712357383
Ref: library/email utils email utils decode_params12358722
Ref: 350212358722
Ref: email utils Miscellaneous utilities-Footnote-112359001
Ref: email utils Miscellaneous utilities-Footnote-212359072
Ref: email utils Miscellaneous utilities-Footnote-312359131
Ref: email utils Miscellaneous utilities-Footnote-412359190
Ref: email utils Miscellaneous utilities-Footnote-512359249
Ref: email utils Miscellaneous utilities-Footnote-612359308
Ref: email utils Miscellaneous utilities-Footnote-712359614
Ref: email utils Miscellaneous utilities-Footnote-812359673
Ref: email utils Miscellaneous utilities-Footnote-912359732
Ref: email utils Miscellaneous utilities-Footnote-1012359791
Ref: email utils Miscellaneous utilities-Footnote-1112359851
Ref: email utils Miscellaneous utilities-Footnote-1212359911
Node: email iterators イテレータ12359971
Ref: library/email iterators doc12360150
Ref: 350312360150
Ref: library/email iterators email-iterators-iterators12360150
Ref: 350412360150
Ref: library/email iterators module-email iterators12360150
Ref: 3a12360150
Ref: library/email iterators email iterators body_line_iterator12360653
Ref: 350512360653
Ref: library/email iterators email iterators typed_subpart_iterator12361428
Ref: 350612361428
Ref: library/email iterators email iterators _structure12362438
Ref: 350712362438
Ref: email iterators イテレータ-Footnote-112364067
Node: json --- JSON エンコーダーとデコーダー12364143
Ref: library/json doc12364426
Ref: 350812364426
Ref: library/json json-json-encoder-and-decoder12364426
Ref: 350912364426
Ref: library/json module-json12364426
Ref: 7612364426
Ref: json --- JSON エンコーダーとデコーダー-Footnote-112369452
Ref: json --- JSON エンコーダーとデコーダー-Footnote-212369525
Ref: json --- JSON エンコーダーとデコーダー-Footnote-312369550
Ref: json --- JSON エンコーダーとデコーダー-Footnote-412369609
Ref: json --- JSON エンコーダーとデコーダー-Footnote-512369668
Ref: json --- JSON エンコーダーとデコーダー-Footnote-612369755
Ref: json --- JSON エンコーダーとデコーダー-Footnote-712369804
Ref: json --- JSON エンコーダーとデコーダー-Footnote-812370108
Node: 基本的な使い方<2>12370134
Ref: library/json basic-usage12370284
Ref: 350b12370284
Ref: library/json json dump12370340
Ref: d1212370340
Ref: library/json json dumps12375106
Ref: d1312375106
Ref: library/json json load12376054
Ref: c8212376054
Ref: library/json json loads12379522
Ref: 92312379522
Ref: 基本的な使い方<2>-Footnote-112380581
Node: エンコーダとデコーダ12380613
Ref: library/json encoders-and-decoders12380782
Ref: 350f12380782
Ref: library/json json JSONDecoder12380853
Ref: d1512380853
Ref: library/json json-to-py-table12381144
Ref: 350e12381144
Ref: library/json json JSONDecoder decode12384332
Ref: 351012384332
Ref: library/json json JSONDecoder raw_decode12384630
Ref: 351112384630
Ref: library/json json JSONEncoder12385091
Ref: d1412385091
Ref: library/json py-to-json-table12385445
Ref: 350c12385445
Ref: library/json json JSONEncoder default12391089
Ref: 350d12391089
Ref: library/json json JSONEncoder encode12391889
Ref: 351212391889
Ref: library/json json JSONEncoder iterencode12392130
Ref: 351312392130
Ref: エンコーダとデコーダ-Footnote-112392470
Node: 例外<16>12392502
Ref: library/json exceptions12392677
Ref: 351412392677
Ref: library/json json JSONDecodeError12392708
Ref: ded12392708
Ref: library/json json JSONDecodeError msg12392852
Ref: 351512392852
Ref: library/json json JSONDecodeError doc12392958
Ref: 351612392958
Ref: library/json json JSONDecodeError pos12393043
Ref: 351712393043
Ref: library/json json JSONDecodeError lineno12393143
Ref: 351812393143
Ref: library/json json JSONDecodeError colno12393216
Ref: 351912393216
Node: 標準への準拠と互換性12393316
Ref: library/json standard-compliance-and-interoperability12393509
Ref: 351a12393509
Ref: 標準への準拠と互換性-Footnote-112394824
Ref: 標準への準拠と互換性-Footnote-212394883
Node: 文字エンコーディング12394970
Ref: library/json character-encodings12395105
Ref: 351b12395105
Node: 無限および NaN の数値12396901
Ref: library/json infinite-and-nan-number-values12397096
Ref: 351c12397096
Node: オブジェクト中に重複した名前の扱い12398007
Ref: library/json repeated-names-within-an-object12398241
Ref: 351d12398241
Node: トップレベルの非オブジェクト、非配列の値の扱い12398928
Ref: library/json top-level-non-object-non-array-values12399148
Ref: 351e12399148
Ref: トップレベルの非オブジェクト、非配列の値の扱い-Footnote-112400124
Ref: トップレベルの非オブジェクト、非配列の値の扱い-Footnote-212400183
Node: 実装の制限12400242
Ref: library/json implementation-limitations12400402
Ref: 351f12400402
Node: コマンドラインインターフェイス<4>12401565
Ref: library/json command-line-interface12401739
Ref: 352012401739
Ref: library/json json-commandline12401739
Ref: 350a12401739
Ref: library/json module-json tool12401739
Ref: 7712401739
Ref: コマンドラインインターフェイス<4>-Footnote-112402889
Node: コマンドラインオプション<4>12402958
Ref: library/json command-line-options12403082
Ref: 352212403082
Ref: library/json cmdoption-json tool-arg-infile12403165
Ref: 352312403165
Ref: library/json cmdoption-json tool-arg-outfile12403715
Ref: 352412403715
Ref: library/json cmdoption-json tool-sort-keys12403876
Ref: 352112403876
Ref: library/json cmdoption-json tool-no-ensure-ascii12404014
Ref: 352512404014
Ref: library/json cmdoption-json tool-json-lines12404217
Ref: 352612404217
Ref: library/json cmdoption-json tool-indent12404364
Ref: 352712404364
Ref: library/json cmdoption-json tool-tab12404364
Ref: 352812404364
Ref: library/json cmdoption-json tool-no-indent12404364
Ref: 352912404364
Ref: library/json cmdoption-json tool-compact12404364
Ref: 352a12404364
Ref: library/json cmdoption-json tool-h12404515
Ref: 352b12404515
Ref: library/json cmdoption-json tool-help12404515
Ref: 352c12404515
Node: mailbox --- 様々な形式のメールボックスを操作する12404601
Ref: library/mailbox doc12404882
Ref: 352d12404882
Ref: library/mailbox mailbox-manipulate-mailboxes-in-various-formats12404882
Ref: 352e12404882
Ref: library/mailbox module-mailbox12404882
Ref: 7f12404882
Ref: mailbox --- 様々な形式のメールボックスを操作する-Footnote-112405990
Node: Mailbox オブジェクト12406057
Ref: library/mailbox id112406221
Ref: 352f12406221
Ref: library/mailbox mailbox-objects12406221
Ref: 353012406221
Ref: library/mailbox mailbox Mailbox12406296
Ref: 121d12406296
Ref: library/mailbox mailbox Mailbox add12410163
Ref: 121e12410163
Ref: library/mailbox mailbox Mailbox remove12411206
Ref: 353112411206
Ref: library/mailbox mailbox Mailbox __delitem__12411242
Ref: 353512411242
Ref: library/mailbox mailbox Mailbox discard12411283
Ref: 353212411283
Ref: library/mailbox mailbox Mailbox __setitem__12412034
Ref: 353612412034
Ref: library/mailbox mailbox Mailbox iterkeys12413150
Ref: 353712413150
Ref: library/mailbox mailbox Mailbox keys12413242
Ref: 353812413242
Ref: library/mailbox mailbox Mailbox itervalues12413410
Ref: 353912413410
Ref: library/mailbox mailbox Mailbox __iter__12413447
Ref: 353a12413447
Ref: library/mailbox mailbox Mailbox values12414090
Ref: 353b12414090
Ref: library/mailbox mailbox Mailbox iteritems12414262
Ref: 353c12414262
Ref: library/mailbox mailbox Mailbox items12414786
Ref: 353d12414786
Ref: library/mailbox mailbox Mailbox get12414985
Ref: 353e12414985
Ref: library/mailbox mailbox Mailbox __getitem__12415032
Ref: 353f12415032
Ref: library/mailbox mailbox Mailbox get_message12415765
Ref: 354012415765
Ref: library/mailbox mailbox Mailbox get_bytes12416105
Ref: 122012416105
Ref: library/mailbox mailbox Mailbox get_string12416373
Ref: 122112416373
Ref: library/mailbox mailbox Mailbox get_file12416775
Ref: 121f12416775
Ref: library/mailbox mailbox Mailbox __contains__12418157
Ref: 354112418157
Ref: library/mailbox mailbox Mailbox __len__12418340
Ref: 354212418340
Ref: library/mailbox mailbox Mailbox clear12418450
Ref: 354312418450
Ref: library/mailbox mailbox Mailbox pop12418567
Ref: 354412418567
Ref: library/mailbox mailbox Mailbox popitem12419035
Ref: 354512419035
Ref: library/mailbox mailbox Mailbox update12419685
Ref: 354612419685
Ref: library/mailbox mailbox Mailbox flush12420656
Ref: 354712420656
Ref: library/mailbox mailbox Mailbox lock12421076
Ref: 353312421076
Ref: library/mailbox mailbox Mailbox unlock12421572
Ref: 353412421572
Ref: library/mailbox mailbox Mailbox close12421693
Ref: 354912421693
Node: Maildir オブジェクト12422122
Ref: library/mailbox mailbox-maildir12422243
Ref: 354a12422243
Ref: library/mailbox maildir-objects12422243
Ref: 354b12422243
Ref: library/mailbox mailbox Maildir12422318
Ref: 3f512422318
Ref: library/mailbox mailbox Maildir colon12425151
Ref: 354d12425151
Ref: library/mailbox mailbox Maildir list_folders12426191
Ref: 354e12426191
Ref: library/mailbox mailbox Maildir get_folder12426297
Ref: 354f12426297
Ref: library/mailbox mailbox Maildir add_folder12426591
Ref: 355112426591
Ref: library/mailbox mailbox Maildir remove_folder12426779
Ref: 355212426779
Ref: library/mailbox mailbox Maildir clean12427081
Ref: 355412427081
Ref: library/mailbox mailbox Maildir get_flags12427380
Ref: 163712427380
Ref: library/mailbox mailbox Maildir set_flags12428187
Ref: 163812428187
Ref: library/mailbox mailbox Maildir add_flag12428942
Ref: 163912428942
Ref: library/mailbox mailbox Maildir remove_flag12429458
Ref: 163a12429458
Ref: library/mailbox mailbox Maildir get_info12429985
Ref: 163512429985
Ref: library/mailbox mailbox Maildir set_info12430717
Ref: 163612430717
Ref: library/mailbox mailbox Maildir add12431554
Ref: 355c12431554
Ref: library/mailbox mailbox Maildir __setitem__12431591
Ref: 355912431591
Ref: library/mailbox mailbox Maildir update12431641
Ref: 355d12431641
Ref: library/mailbox mailbox Maildir flush12432120
Ref: 355e12432120
Ref: library/mailbox mailbox Maildir lock12432295
Ref: 355f12432295
Ref: library/mailbox mailbox Maildir unlock12432326
Ref: 356012432326
Ref: library/mailbox mailbox Maildir close12432516
Ref: 356112432516
Ref: library/mailbox mailbox Maildir get_file12432774
Ref: 356212432774
Ref: Maildir オブジェクト-Footnote-112433448
Ref: Maildir オブジェクト-Footnote-212433497
Node: mbox オブジェクト12433541
Ref: library/mailbox mailbox-mbox12433692
Ref: 356312433692
Ref: library/mailbox mbox-objects12433692
Ref: 356412433692
Ref: library/mailbox mailbox mbox12433761
Ref: 15e312433761
Ref: library/mailbox mailbox mbox get_file12435502
Ref: 356512435502
Ref: library/mailbox mailbox mbox lock12435831
Ref: 356612435831
Ref: library/mailbox mailbox mbox unlock12435862
Ref: 356712435862
Ref: mbox オブジェクト-Footnote-112436581
Ref: mbox オブジェクト-Footnote-212436641
Ref: mbox オブジェクト-Footnote-312436693
Node: MH オブジェクト12436771
Ref: library/mailbox mailbox-mh12436920
Ref: 356812436920
Ref: library/mailbox mh-objects12436920
Ref: 356912436920
Ref: library/mailbox mailbox MH12436985
Ref: 161a12436985
Ref: library/mailbox mailbox MH list_folders12439106
Ref: 356b12439106
Ref: library/mailbox mailbox MH get_folder12439212
Ref: 356c12439212
Ref: library/mailbox mailbox MH add_folder12439491
Ref: 356d12439491
Ref: library/mailbox mailbox MH remove_folder12439676
Ref: 356e12439676
Ref: library/mailbox mailbox MH get_sequences12439978
Ref: 356f12439978
Ref: library/mailbox mailbox MH set_sequences12440192
Ref: 357012440192
Ref: library/mailbox mailbox MH pack12440475
Ref: 357112440475
Ref: library/mailbox mailbox MH remove12441038
Ref: 357212441038
Ref: library/mailbox mailbox MH __delitem__12441074
Ref: 357312441074
Ref: library/mailbox mailbox MH discard12441115
Ref: 357412441115
Ref: library/mailbox mailbox MH lock12441383
Ref: 357512441383
Ref: library/mailbox mailbox MH unlock12441414
Ref: 357612441414
Ref: library/mailbox mailbox MH get_file12441885
Ref: 357712441885
Ref: library/mailbox mailbox MH flush12442112
Ref: 357812442112
Ref: library/mailbox mailbox MH close12442282
Ref: 357912442282
Ref: MH オブジェクト-Footnote-112442825
Ref: MH オブジェクト-Footnote-212442861
Node: Babyl オブジェクト12442906
Ref: library/mailbox babyl-objects12443055
Ref: 357a12443055
Ref: library/mailbox mailbox-babyl12443055
Ref: 357b12443055
Ref: library/mailbox mailbox Babyl12443126
Ref: 357c12443126
Ref: library/mailbox mailbox Babyl get_labels12445135
Ref: 357e12445135
Ref: library/mailbox mailbox Babyl get_file12445827
Ref: 357f12445827
Ref: library/mailbox mailbox Babyl lock12446460
Ref: 358012446460
Ref: library/mailbox mailbox Babyl unlock12446491
Ref: 358112446491
Ref: Babyl オブジェクト-Footnote-112446969
Ref: Babyl オブジェクト-Footnote-212447013
Node: MMDF オブジェクト12447091
Ref: library/mailbox mailbox-mmdf12447210
Ref: 358212447210
Ref: library/mailbox mmdf-objects12447210
Ref: 358312447210
Ref: library/mailbox mailbox MMDF12447279
Ref: 15e412447279
Ref: library/mailbox mailbox MMDF get_file12448822
Ref: 358512448822
Ref: library/mailbox mailbox MMDF lock12449151
Ref: 358612449151
Ref: library/mailbox mailbox MMDF unlock12449182
Ref: 358712449182
Ref: MMDF オブジェクト-Footnote-112449679
Ref: MMDF オブジェクト-Footnote-212449739
Node: Message オブジェクト12449782
Ref: library/mailbox mailbox-message-objects12449965
Ref: 358812449965
Ref: library/mailbox message-objects12449965
Ref: 358912449965
Ref: library/mailbox mailbox Message12450040
Ref: 122212450040
Ref: Message オブジェクト-Footnote-112452856
Node: MaildirMessage オブジェクト12452915
Ref: library/mailbox mailbox-maildirmessage12453050
Ref: 358a12453050
Ref: library/mailbox maildirmessage-objects12453050
Ref: 358b12453050
Ref: library/mailbox mailbox MaildirMessage12453139
Ref: 354c12453139
Ref: library/mailbox mailbox MaildirMessage get_subdir12455354
Ref: 358c12455354
Ref: library/mailbox mailbox MaildirMessage set_subdir12456015
Ref: 358d12456015
Ref: library/mailbox mailbox MaildirMessage get_flags12456279
Ref: 355512456279
Ref: library/mailbox mailbox MaildirMessage set_flags12456862
Ref: 355612456862
Ref: library/mailbox mailbox MaildirMessage add_flag12457005
Ref: 355712457005
Ref: library/mailbox mailbox MaildirMessage remove_flag12457419
Ref: 355812457419
Ref: library/mailbox mailbox MaildirMessage get_date12457852
Ref: 358e12457852
Ref: library/mailbox mailbox MaildirMessage set_date12458019
Ref: 358f12458019
Ref: library/mailbox mailbox MaildirMessage get_info12458223
Ref: 355a12458223
Ref: library/mailbox mailbox MaildirMessage set_info12458495
Ref: 355b12458495
Node: mboxMessage オブジェクト12461522
Ref: library/mailbox mailbox-mboxmessage12461694
Ref: 359012461694
Ref: library/mailbox mboxmessage-objects12461694
Ref: 359112461694
Ref: library/mailbox mailbox mboxMessage12461777
Ref: 340612461777
Ref: library/mailbox mailbox mboxMessage get_from12463879
Ref: 359212463879
Ref: library/mailbox mailbox mboxMessage set_from12464128
Ref: 359312464128
Ref: library/mailbox mailbox mboxMessage get_flags12464827
Ref: 359412464827
Ref: library/mailbox mailbox mboxMessage set_flags12465170
Ref: 359512465170
Ref: library/mailbox mailbox mboxMessage add_flag12465454
Ref: 359612465454
Ref: library/mailbox mailbox mboxMessage remove_flag12465753
Ref: 359712465753
Node: MHMessage オブジェクト12469129
Ref: library/mailbox mailbox-mhmessage12469299
Ref: 359812469299
Ref: library/mailbox mhmessage-objects12469299
Ref: 359912469299
Ref: library/mailbox mailbox MHMessage12469380
Ref: 356a12469380
Ref: library/mailbox mailbox MHMessage get_sequences12470548
Ref: 359a12470548
Ref: library/mailbox mailbox MHMessage set_sequences12470679
Ref: 359b12470679
Ref: library/mailbox mailbox MHMessage add_sequence12470819
Ref: 359c12470819
Ref: library/mailbox mailbox MHMessage remove_sequence12470979
Ref: 359d12470979
Node: BabylMessage オブジェクト12473066
Ref: library/mailbox babylmessage-objects12473236
Ref: 359e12473236
Ref: library/mailbox mailbox-babylmessage12473236
Ref: 359f12473236
Ref: library/mailbox mailbox BabylMessage12473323
Ref: 357d12473323
Ref: library/mailbox mailbox BabylMessage get_labels12474979
Ref: 35a012474979
Ref: library/mailbox mailbox BabylMessage set_labels12475101
Ref: 35a112475101
Ref: library/mailbox mailbox BabylMessage add_label12475259
Ref: 35a212475259
Ref: library/mailbox mailbox BabylMessage remove_label12475400
Ref: 35a312475400
Ref: library/mailbox mailbox BabylMessage get_visible12475558
Ref: 35a412475558
Ref: library/mailbox mailbox BabylMessage set_visible12475764
Ref: 35a512475764
Ref: library/mailbox mailbox BabylMessage update_visible12476216
Ref: 35a612476216
Node: MMDFMessage オブジェクト12478970
Ref: library/mailbox mailbox-mmdfmessage12479103
Ref: 35a712479103
Ref: library/mailbox mmdfmessage-objects12479103
Ref: 35a812479103
Ref: library/mailbox mailbox MMDFMessage12479188
Ref: 358412479188
Ref: library/mailbox mailbox MMDFMessage get_from12481081
Ref: 35a912481081
Ref: library/mailbox mailbox MMDFMessage set_from12481330
Ref: 35aa12481330
Ref: library/mailbox mailbox MMDFMessage get_flags12482029
Ref: 35ab12482029
Ref: library/mailbox mailbox MMDFMessage set_flags12482372
Ref: 35ac12482372
Ref: library/mailbox mailbox MMDFMessage add_flag12482656
Ref: 35ad12482656
Ref: library/mailbox mailbox MMDFMessage remove_flag12482955
Ref: 35ae12482955
Node: 例外<17>12486325
Ref: library/mailbox exceptions12486495
Ref: 35af12486495
Ref: library/mailbox mailbox Error12486617
Ref: 35b012486617
Ref: library/mailbox mailbox NoSuchMailboxError12486717
Ref: 355012486717
Ref: library/mailbox mailbox NotEmptyError12487185
Ref: 355312487185
Ref: library/mailbox mailbox ExternalClashError12487452
Ref: 354812487452
Ref: library/mailbox mailbox FormatError12487895
Ref: 35b112487895
Node: 使用例<30>12488156
Ref: library/mailbox examples12488291
Ref: 35b212488291
Ref: library/mailbox mailbox-examples12488291
Ref: 35b312488291
Node: mimetypes --- ファイル名を MIME タイプへマップする12490781
Ref: library/mimetypes doc12491078
Ref: 35b412491078
Ref: library/mimetypes mimetypes-map-filenames-to-mime-types12491078
Ref: 35b512491078
Ref: library/mimetypes module-mimetypes12491078
Ref: 8212491078
Ref: library/mimetypes mimetypes guess_type12492334
Ref: 1e912492334
Ref: library/mimetypes mimetypes guess_file_type12494330
Ref: 1e812494330
Ref: library/mimetypes mimetypes guess_all_extensions12494662
Ref: 180012494662
Ref: library/mimetypes mimetypes guess_extension12495271
Ref: 35b712495271
Ref: library/mimetypes mimetypes init12496050
Ref: 35b612496050
Ref: library/mimetypes mimetypes read_mime_types12497391
Ref: 18ad12497391
Ref: library/mimetypes mimetypes add_type12497869
Ref: 35b912497869
Ref: library/mimetypes mimetypes inited12498429
Ref: 35ba12498429
Ref: library/mimetypes mimetypes knownfiles12498643
Ref: 35b812498643
Ref: library/mimetypes mimetypes suffix_map12498933
Ref: 35bb12498933
Ref: library/mimetypes mimetypes encodings_map12499327
Ref: 35bc12499327
Ref: library/mimetypes mimetypes types_map12499452
Ref: 35bd12499452
Ref: library/mimetypes mimetypes common_types12499558
Ref: 35be12499558
Ref: mimetypes --- ファイル名を MIME タイプへマップする-Footnote-112500143
Ref: mimetypes --- ファイル名を MIME タイプへマップする-Footnote-212500212
Node: Mime 型オブジェクト12500283
Ref: library/mimetypes id112500411
Ref: 35bf12500411
Ref: library/mimetypes mimetypes-objects12500411
Ref: 35c012500411
Ref: library/mimetypes mimetypes MimeTypes12500736
Ref: 14a412500736
Ref: library/mimetypes mimetypes MimeTypes suffix_map12501693
Ref: 35c312501693
Ref: library/mimetypes mimetypes MimeTypes encodings_map12502261
Ref: 35c412502261
Ref: library/mimetypes mimetypes MimeTypes types_map12502522
Ref: 35c512502522
Ref: library/mimetypes mimetypes MimeTypes types_map_inv12502854
Ref: 35c612502854
Ref: library/mimetypes mimetypes MimeTypes guess_extension12503201
Ref: 35c712503201
Ref: library/mimetypes mimetypes MimeTypes guess_type12503411
Ref: 19a312503411
Ref: library/mimetypes mimetypes MimeTypes guess_file_type12503609
Ref: 35c812503609
Ref: library/mimetypes mimetypes MimeTypes guess_all_extensions12503829
Ref: 35c912503829
Ref: library/mimetypes mimetypes MimeTypes read12504043
Ref: 35c112504043
Ref: library/mimetypes mimetypes MimeTypes readfp12504522
Ref: 35c212504522
Ref: library/mimetypes mimetypes MimeTypes read_windows_registry12505010
Ref: 35ca12505010
Ref: library/mimetypes mimetypes MimeTypes add_type12505458
Ref: 35cb12505458
Node: base64 --- Base16 Base32 Base64 Base85 データのエンコード12506046
Ref: library/base64 doc12506325
Ref: 35cc12506325
Ref: library/base64 base64-base16-base32-base64-base85-data-encodings12506325
Ref: 35cd12506325
Ref: library/base64 module-base6412506325
Ref: a12506325
Ref: library/base64 base64 b64encode12508843
Ref: 35ce12508843
Ref: library/base64 base64 b64decode12509747
Ref: 191212509747
Ref: library/base64 base64 standard_b64encode12510955
Ref: 35cf12510955
Ref: library/base64 base64 standard_b64decode12511196
Ref: 35d012511196
Ref: library/base64 base64 urlsafe_b64encode12511452
Ref: 35d112511452
Ref: library/base64 base64 urlsafe_b64decode12511895
Ref: 35d212511895
Ref: library/base64 base64 b32encode12512324
Ref: 35d312512324
Ref: library/base64 base64 b32decode12512517
Ref: fef12512517
Ref: library/base64 base64 b32hexencode12513971
Ref: 7ae12513971
Ref: library/base64 base64 b32hexdecode12514150
Ref: 7af12514150
Ref: library/base64 base64 b16encode12514599
Ref: 35d412514599
Ref: library/base64 base64 b16decode12514792
Ref: 35d512514792
Ref: library/base64 base64 a85encode12515497
Ref: eea12515497
Ref: library/base64 base64 a85decode12516656
Ref: eeb12516656
Ref: library/base64 base64 b85encode12517709
Ref: eec12517709
Ref: library/base64 base64 b85decode12518203
Ref: eed12518203
Ref: library/base64 base64 z85encode12518531
Ref: 13512518531
Ref: library/base64 base64 z85decode12518778
Ref: 13612518778
Ref: library/base64 base64 decode12519101
Ref: 35d612519101
Ref: library/base64 base64 decodebytes12519473
Ref: 92212519473
Ref: library/base64 base64 encode12519792
Ref: 35d712519792
Ref: library/base64 base64 encodebytes12520398
Ref: 92112520398
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-112521221
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-212521287
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-312521346
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-412521405
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-512521464
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-612521523
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-712521582
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-812521641
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-912521700
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-1012521759
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-1112521800
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-1212521841
Ref: base64 --- Base16 Base32 Base64 Base85 データのエンコード-Footnote-1312521901
Node: セキュリティで考慮すべき点<4>12521961
Ref: library/base64 base64-security12522106
Ref: 35d812522106
Ref: library/base64 security-considerations12522106
Ref: 35d912522106
Ref: セキュリティで考慮すべき点<4>-Footnote-112522816
Ref: セキュリティで考慮すべき点<4>-Footnote-212522875
Node: binascii --- バイナリ と ASCII 間の変換12522934
Ref: library/binascii doc12523223
Ref: 35da12523223
Ref: library/binascii binascii-convert-between-binary-and-ascii12523223
Ref: 35db12523223
Ref: library/binascii module-binascii12523223
Ref: c12523223
Ref: library/binascii binascii a2b_uu12524479
Ref: 35dc12524479
Ref: library/binascii binascii b2a_uu12524854
Ref: aef12524854
Ref: library/binascii binascii a2b_base6412525258
Ref: 159112525258
Ref: library/binascii binascii b2a_base6412526028
Ref: c4d12526028
Ref: library/binascii binascii a2b_qp12526464
Ref: 35dd12526464
Ref: library/binascii binascii b2a_qp12526871
Ref: 35de12526871
Ref: library/binascii binascii crc_hqx12528015
Ref: 6ff12528015
Ref: library/binascii binascii crc3212528374
Ref: 15fa12528374
Ref: library/binascii binascii b2a_hex12529213
Ref: 236d12529213
Ref: library/binascii binascii hexlify12529278
Ref: 35df12529278
Ref: library/binascii binascii a2b_hex12530499
Ref: 236e12530499
Ref: library/binascii binascii unhexlify12530540
Ref: 19b212530540
Ref: library/binascii binascii Error12531133
Ref: ff012531133
Ref: library/binascii binascii Incomplete12531279
Ref: 35e012531279
Ref: binascii --- バイナリ と ASCII 間の変換-Footnote-112531874
Ref: binascii --- バイナリ と ASCII 間の変換-Footnote-212531933
Ref: binascii --- バイナリ と ASCII 間の変換-Footnote-312531992
Node: quopri --- MIME quoted-printable データのエンコードとデコード12532051
Ref: library/quopri doc12532265
Ref: 35e112532265
Ref: library/quopri module-quopri12532265
Ref: a512532265
Ref: library/quopri quopri-encode-and-decode-mime-quoted-printable-data12532265
Ref: 35e212532265
Ref: library/quopri quopri decode12533201
Ref: 237012533201
Ref: library/quopri quopri encode12533968
Ref: 236f12533968
Ref: library/quopri quopri decodestring12534895
Ref: 35e312534895
Ref: library/quopri quopri encodestring12535124
Ref: 35e412535124
Ref: quopri --- MIME quoted-printable データのエンコードとデコード-Footnote-112535660
Ref: quopri --- MIME quoted-printable データのエンコードとデコード-Footnote-212535726
Ref: quopri --- MIME quoted-printable データのエンコードとデコード-Footnote-312535785
Ref: quopri --- MIME quoted-printable データのエンコードとデコード-Footnote-412535844
Ref: quopri --- MIME quoted-printable データのエンコードとデコード-Footnote-512535903
Node: 構造化マークアップツール12535962
Ref: library/markup doc12536177
Ref: 35e512536177
Ref: library/markup markup12536177
Ref: 35e612536177
Ref: library/markup structured-markup-processing-tools12536177
Ref: 35e712536177
Node: html --- HyperText Markup Language のサポート12538022
Ref: library/html doc12538215
Ref: 35e812538215
Ref: library/html html-hypertext-markup-language-support12538215
Ref: 35e912538215
Ref: library/html module-html12538215
Ref: 6112538215
Ref: library/html html escape12538543
Ref: fd912538543
Ref: library/html html unescape12539093
Ref: 92512539093
Ref: html --- HyperText Markup Language のサポート-Footnote-112539874
Node: html parser --- HTML と XHTML のシンプルなパーサー12539947
Ref: library/html parser doc12540193
Ref: 35ea12540193
Ref: library/html parser html-parser-simple-html-and-xhtml-parser12540193
Ref: 35eb12540193
Ref: library/html parser module-html parser12540193
Ref: 6312540193
Ref: library/html parser html parser HTMLParser12540731
Ref: 84312540731
Ref: html parser --- HTML と XHTML のシンプルなパーサー-Footnote-112542158
Node: HTML パーサーアプリケーションの例12542229
Ref: library/html parser example-html-parser-application12542406
Ref: 35ec12542406
Node: HTMLParser メソッド12543694
Ref: library/html parser htmlparser-methods12543893
Ref: 35ed12543893
Ref: library/html parser html parser HTMLParser feed12544050
Ref: 35ee12544050
Ref: library/html parser html parser HTMLParser close12544483
Ref: 35ef12544483
Ref: library/html parser html parser HTMLParser reset12545060
Ref: 35f012545060
Ref: library/html parser html parser HTMLParser getpos12545274
Ref: 35f112545274
Ref: library/html parser html parser HTMLParser get_starttag_text12545384
Ref: 35f212545384
Ref: library/html parser html parser HTMLParser handle_starttag12546151
Ref: 35f412546151
Ref: library/html parser html parser HTMLParser handle_endtag12547046
Ref: 35f512547046
Ref: library/html parser html parser HTMLParser handle_startendtag12547289
Ref: 35f312547289
Ref: library/html parser html parser HTMLParser handle_data12547792
Ref: 35f612547792
Ref: library/html parser html parser HTMLParser handle_entityref12548052
Ref: 35f712548052
Ref: library/html parser html parser HTMLParser handle_charref12548436
Ref: 35f812548436
Ref: library/html parser html parser HTMLParser handle_comment12548984
Ref: 35f912548984
Ref: library/html parser html parser HTMLParser handle_decl12549613
Ref: 35fa12549613
Ref: library/html parser html parser HTMLParser handle_pi12549921
Ref: 35fb12549921
Ref: library/html parser html parser HTMLParser unknown_decl12550643
Ref: 35fc12550643
Node: 使用例<31>12551057
Ref: library/html parser examples12551200
Ref: 35fd12551200
Ref: library/html parser htmlparser-examples12551200
Ref: 35fe12551200
Node: html entities --- HTML 一般実体の定義12554785
Ref: library/html entities doc12555011
Ref: 35ff12555011
Ref: library/html entities html-entities-definitions-of-html-general-entities12555011
Ref: 360012555011
Ref: library/html entities module-html entities12555011
Ref: 6212555011
Ref: library/html entities html entities html512555417
Ref: 10a512555417
Ref: library/html entities html entities entitydefs12555938
Ref: 360312555938
Ref: library/html entities html entities name2codepoint12556100
Ref: 360112556100
Ref: library/html entities html entities codepoint2name12556236
Ref: 360212556236
Ref: html entities --- HTML 一般実体の定義-Footnote-112556421
Ref: html entities --- HTML 一般実体の定義-Footnote-212556494
Node: XMLを扱うモジュール群12556607
Ref: library/xml doc12556817
Ref: 360412556817
Ref: library/xml module-xml12556817
Ref: 10712556817
Ref: library/xml xml12556817
Ref: 360512556817
Ref: library/xml xml-processing-modules12556817
Ref: 360612556817
Ref: XMLを扱うモジュール群-Footnote-112558556
Node: XML の脆弱性12558617
Ref: library/xml id112558735
Ref: 360912558735
Ref: library/xml xml-vulnerabilities12558735
Ref: 360712558735
Ref: XML の脆弱性-Footnote-112565491
Ref: XML の脆弱性-Footnote-212565554
Ref: XML の脆弱性-Footnote-312565607
Ref: XML の脆弱性-Footnote-412565660
Ref: XML の脆弱性-Footnote-512565723
Ref: XML の脆弱性-Footnote-612565844
Ref: XML の脆弱性-Footnote-712565900
Node: defusedxml パッケージ12565945
Ref: library/xml defusedxml-package12566063
Ref: 360812566063
Ref: library/xml the-defusedxml-package12566063
Ref: 360a12566063
Ref: defusedxml パッケージ-Footnote-112566522
Node: xml etree ElementTree --- ElementTree XML API12566567
Ref: library/xml etree elementtree doc12566794
Ref: 360b12566794
Ref: library/xml etree elementtree module-xml etree ElementTree12566794
Ref: 10c12566794
Ref: library/xml etree elementtree xml-etree-elementtree-the-elementtree-xml-api12566794
Ref: 360c12566794
Ref: xml etree ElementTree --- ElementTree XML API-Footnote-112567986
Node: チュートリアル<2>12568068
Ref: library/xml etree elementtree tutorial12568201
Ref: 360d12568201
Node: XML 木構造と要素12568735
Ref: library/xml etree elementtree xml-tree-and-elements12568840
Ref: 360e12568840
Node: XML の解析12569442
Ref: library/xml etree elementtree elementtree-parsing-xml12569602
Ref: 360f12569602
Ref: library/xml etree elementtree parsing-xml12569602
Ref: 361012569602
Node: 非ブロックパースのためのプル API12572506
Ref: library/xml etree elementtree elementtree-pull-parsing12572671
Ref: fbf12572671
Ref: library/xml etree elementtree pull-api-for-non-blocking-parsing12572671
Ref: 361212572671
Node: 関心ある要素の検索12575336
Ref: library/xml etree elementtree finding-interesting-elements12575513
Ref: 361512575513
Node: XML ファイルの編集12576862
Ref: library/xml etree elementtree modifying-an-xml-file12577012
Ref: 361a12577012
Node: XML 文書の構築12580116
Ref: library/xml etree elementtree building-xml-documents12580274
Ref: 361e12580274
Node: 名前空間のある XML の解析12580651
Ref: library/xml etree elementtree parsing-xml-with-namespaces12580775
Ref: 362012580775
Ref: 名前空間のある XML の解析-Footnote-112583303
Ref: 名前空間のある XML の解析-Footnote-212583355
Node: XPath サポート12583407
Ref: library/xml etree elementtree elementtree-xpath12583570
Ref: b7b12583570
Ref: library/xml etree elementtree xpath-support12583570
Ref: 362112583570
Ref: XPath サポート-Footnote-112584033
Node: 使用例<32>12584069
Ref: library/xml etree elementtree example12584186
Ref: 362212584186
Node: サポートされている XPath 構文12585194
Ref: library/xml etree elementtree supported-xpath-syntax12585311
Ref: 362312585311
Node: リファレンス<3>12590460
Ref: library/xml etree elementtree reference12590620
Ref: 362412590620
Node: 関数<9>12590704
Ref: library/xml etree elementtree elementtree-functions12590771
Ref: 362512590771
Ref: library/xml etree elementtree functions12590771
Ref: 362612590771
Ref: library/xml etree elementtree xml etree ElementTree canonicalize12590804
Ref: 362712590804
Ref: library/xml etree elementtree xml etree ElementTree Comment12593181
Ref: 362812593181
Ref: library/xml etree elementtree xml etree ElementTree dump12594002
Ref: 362912594002
Ref: library/xml etree elementtree xml etree ElementTree fromstring12594571
Ref: 361112594571
Ref: library/xml etree elementtree xml etree ElementTree fromstringlist12595076
Ref: 11a112595076
Ref: library/xml etree elementtree xml etree ElementTree indent12595650
Ref: 362b12595650
Ref: library/xml etree elementtree xml etree ElementTree iselement12596179
Ref: 362c12596179
Ref: library/xml etree elementtree xml etree ElementTree iterparse12596466
Ref: 25412596466
Ref: library/xml etree elementtree xml etree ElementTree parse12598836
Ref: 362d12598836
Ref: library/xml etree elementtree xml etree ElementTree ProcessingInstruction12599342
Ref: 362e12599342
Ref: library/xml etree elementtree xml etree ElementTree register_namespace12600128
Ref: 11a212600128
Ref: library/xml etree elementtree xml etree ElementTree SubElement12600699
Ref: 361f12600699
Ref: library/xml etree elementtree xml etree ElementTree tostring12601371
Ref: fc012601371
Ref: library/xml etree elementtree xml etree ElementTree tostringlist12602632
Ref: fc112602632
Ref: library/xml etree elementtree xml etree ElementTree XML12604110
Ref: 362a12604110
Ref: library/xml etree elementtree xml etree ElementTree XMLID12604668
Ref: 362f12604668
Ref: 関数<9>-Footnote-112605247
Ref: 関数<9>-Footnote-212605288
Ref: 関数<9>-Footnote-312605680
Node: XInclude サポート12606072
Ref: library/xml etree elementtree elementtree-xinclude12606235
Ref: 363012606235
Ref: library/xml etree elementtree xinclude-support12606235
Ref: 363112606235
Ref: XInclude サポート-Footnote-112606611
Node: 使用例<33>12606651
Ref: library/xml etree elementtree id312606722
Ref: 363212606722
Node: リファレンス<4>12608527
Ref: library/xml etree elementtree id412608660
Ref: 363312608660
Node: 関数<10>12608967
Ref: library/xml etree elementtree elementinclude-functions12609070
Ref: 363412609070
Ref: library/xml etree elementtree id512609070
Ref: 363512609070
Ref: library/xml etree elementtree module-xml etree ElementInclude12609103
Ref: 10b12609103
Ref: library/xml etree elementtree xml etree ElementInclude default_loader12609103
Ref: 363612609103
Ref: library/xml etree elementtree xml etree ElementInclude include12609691
Ref: 363712609691
Node: Element オブジェクト12610583
Ref: library/xml etree elementtree element-objects12610725
Ref: 363812610725
Ref: library/xml etree elementtree elementtree-element-objects12610725
Ref: 363912610725
Ref: library/xml etree elementtree xml etree ElementTree Element12610794
Ref: 2e812610794
Ref: library/xml etree elementtree xml etree ElementTree Element tag12611414
Ref: 131d12611414
Ref: library/xml etree elementtree xml etree ElementTree Element text12611570
Ref: 361812611570
Ref: library/xml etree elementtree xml etree ElementTree Element tail12611595
Ref: 363a12611595
Ref: library/xml etree elementtree xml etree ElementTree Element attrib12613019
Ref: 363b12613019
Ref: library/xml etree elementtree xml etree ElementTree Element clear12613599
Ref: 363c12613599
Ref: library/xml etree elementtree xml etree ElementTree Element get12613826
Ref: 361912613826
Ref: library/xml etree elementtree xml etree ElementTree Element items12614036
Ref: 363d12614036
Ref: library/xml etree elementtree xml etree ElementTree Element keys12614230
Ref: 363e12614230
Ref: library/xml etree elementtree xml etree ElementTree Element set12614396
Ref: 361b12614396
Ref: library/xml etree elementtree xml etree ElementTree Element append12614599
Ref: 361c12614599
Ref: library/xml etree elementtree xml etree ElementTree Element extend12614862
Ref: 11a312614862
Ref: library/xml etree elementtree xml etree ElementTree Element find12615099
Ref: 361712615099
Ref: library/xml etree elementtree xml etree ElementTree Element findall12615527
Ref: 361612615527
Ref: library/xml etree elementtree xml etree ElementTree Element findtext12615952
Ref: 363f12615952
Ref: library/xml etree elementtree xml etree ElementTree Element insert12616562
Ref: 364012616562
Ref: library/xml etree elementtree xml etree ElementTree Element iter12616815
Ref: 131e12616815
Ref: library/xml etree elementtree xml etree ElementTree Element iterfind12617428
Ref: 11a412617428
Ref: library/xml etree elementtree xml etree ElementTree Element itertext12617907
Ref: 11a512617907
Ref: library/xml etree elementtree xml etree ElementTree Element makeelement12618205
Ref: 364112618205
Ref: library/xml etree elementtree xml etree ElementTree Element remove12618487
Ref: 361d12618487
Ref: Element オブジェクト-Footnote-112621346
Node: ElementTree オブジェクト12621389
Ref: library/xml etree elementtree elementtree-elementtree-objects12621545
Ref: 364212621545
Ref: library/xml etree elementtree elementtree-objects12621545
Ref: 364312621545
Ref: library/xml etree elementtree xml etree ElementTree ElementTree12621622
Ref: 91c12621622
Ref: library/xml etree elementtree xml etree ElementTree ElementTree _setroot12622024
Ref: 364412622024
Ref: library/xml etree elementtree xml etree ElementTree ElementTree find12622330
Ref: 364512622330
Ref: library/xml etree elementtree xml etree ElementTree ElementTree findall12622489
Ref: 364612622489
Ref: library/xml etree elementtree xml etree ElementTree ElementTree findtext12622654
Ref: 364712622654
Ref: library/xml etree elementtree xml etree ElementTree ElementTree getroot12622835
Ref: 364812622835
Ref: library/xml etree elementtree xml etree ElementTree ElementTree iter12622927
Ref: 364912622927
Ref: library/xml etree elementtree xml etree ElementTree ElementTree iterfind12623265
Ref: 364a12623265
Ref: library/xml etree elementtree xml etree ElementTree ElementTree parse12623465
Ref: 364b12623465
Ref: library/xml etree elementtree xml etree ElementTree ElementTree write12623949
Ref: fc212623949
Ref: ElementTree オブジェクト-Footnote-112627202
Node: QName オブジェクト12627594
Ref: library/xml etree elementtree elementtree-qname-objects12627754
Ref: 364c12627754
Ref: library/xml etree elementtree qname-objects12627754
Ref: 364d12627754
Ref: library/xml etree elementtree xml etree ElementTree QName12627819
Ref: 364e12627819
Node: TreeBuilder オブジェクト12628443
Ref: library/xml etree elementtree elementtree-treebuilder-objects12628601
Ref: 364f12628601
Ref: library/xml etree elementtree treebuilder-objects12628601
Ref: 365012628601
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder12628678
Ref: a2312628678
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder close12629858
Ref: 365112629858
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder data12630073
Ref: 365212630073
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder end12630293
Ref: 11a612630293
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder start12630456
Ref: 18ee12630456
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder comment12630682
Ref: 365312630682
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder pi12630886
Ref: 365412630886
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder doctype12631257
Ref: a6512631257
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder start_ns12631637
Ref: 365512631637
Ref: library/xml etree elementtree xml etree ElementTree TreeBuilder end_ns12632039
Ref: 365612632039
Ref: library/xml etree elementtree xml etree ElementTree C14NWriterTarget12632294
Ref: 365712632294
Ref: TreeBuilder オブジェクト-Footnote-112632848
Node: XMLParser オブジェクト12632889
Ref: library/xml etree elementtree elementtree-xmlparser-objects12633055
Ref: 365812633055
Ref: library/xml etree elementtree xmlparser-objects12633055
Ref: 365912633055
Ref: library/xml etree elementtree xml etree ElementTree XMLParser12633128
Ref: a2212633128
Ref: library/xml etree elementtree xml etree ElementTree XMLParser close12634074
Ref: 365b12634074
Ref: library/xml etree elementtree xml etree ElementTree XMLParser feed12634384
Ref: 365a12634384
Ref: library/xml etree elementtree xml etree ElementTree XMLParser flush12634538
Ref: 25012634538
Ref: XMLParser オブジェクト-Footnote-112637369
Node: XMLPullParser オブジェクト12637761
Ref: library/xml etree elementtree elementtree-xmlpullparser-objects12637907
Ref: 365c12637907
Ref: library/xml etree elementtree xmlpullparser-objects12637907
Ref: 365d12637907
Ref: library/xml etree elementtree xml etree ElementTree XMLPullParser12637988
Ref: fbe12637988
Ref: library/xml etree elementtree xml etree ElementTree XMLPullParser feed12638894
Ref: 361312638894
Ref: library/xml etree elementtree xml etree ElementTree XMLPullParser flush12639002
Ref: 25112639002
Ref: library/xml etree elementtree xml etree ElementTree XMLPullParser close12639867
Ref: 365e12639867
Ref: library/xml etree elementtree xml etree ElementTree XMLPullParser read_events12640295
Ref: 361412640295
Node: 例外<18>12642238
Ref: library/xml etree elementtree exceptions12642347
Ref: 365f12642347
Ref: library/xml etree elementtree xml etree ElementTree ParseError12642380
Ref: 124912642380
Ref: library/xml etree elementtree xml etree ElementTree ParseError code12642744
Ref: 366012642744
Ref: library/xml etree elementtree xml etree ElementTree ParseError position12643008
Ref: 366112643008
Node: xml dom --- ドキュメントオブジェクトモデル API12643161
Ref: library/xml dom doc12643404
Ref: 366212643404
Ref: library/xml dom module-xml dom12643404
Ref: 10812643404
Ref: library/xml dom xml-dom-the-document-object-model-api12643404
Ref: 366312643404
Ref: xml dom --- ドキュメントオブジェクトモデル API-Footnote-112648495
Ref: xml dom --- ドキュメントオブジェクトモデル API-Footnote-212648572
Ref: xml dom --- ドキュメントオブジェクトモデル API-Footnote-312648638
Ref: xml dom --- ドキュメントオブジェクトモデル API-Footnote-412648685
Node: モジュールコンテンツ<4>12648731
Ref: library/xml dom module-contents12648899
Ref: 366612648899
Ref: library/xml dom xml dom registerDOMImplementation12649029
Ref: 366712649029
Ref: library/xml dom xml dom getDOMImplementation12649661
Ref: 366412649661
Ref: library/xml dom xml dom EMPTY_NAMESPACE12650758
Ref: 366812650758
Ref: library/xml dom xml dom XML_NAMESPACE12651133
Ref: 366912651133
Ref: library/xml dom xml dom XMLNS_NAMESPACE12651348
Ref: 366a12651348
Ref: library/xml dom xml dom XHTML_NAMESPACE12651548
Ref: 366b12651548
Ref: モジュールコンテンツ<4>-Footnote-112652483
Ref: モジュールコンテンツ<4>-Footnote-212652528
Ref: モジュールコンテンツ<4>-Footnote-312652585
Node: DOM 内のオブジェクト12652623
Ref: library/xml dom dom-objects12652809
Ref: 366c12652809
Ref: library/xml dom objects-in-the-dom12652809
Ref: 366d12652809
Node: DOMImplementation オブジェクト12657760
Ref: library/xml dom dom-implementation-objects12657893
Ref: 366e12657893
Ref: library/xml dom domimplementation-objects12657893
Ref: 367812657893
Ref: library/xml dom xml dom DOMImplementation hasFeature12658394
Ref: 367912658394
Ref: library/xml dom xml dom DOMImplementation createDocument12658623
Ref: 367a12658623
Ref: library/xml dom xml dom DOMImplementation createDocumentType12659391
Ref: 367b12659391
Node: Node オブジェクト12659756
Ref: library/xml dom dom-node-objects12659925
Ref: 366f12659925
Ref: library/xml dom node-objects12659925
Ref: 367c12659925
Ref: library/xml dom xml dom Node nodeType12660064
Ref: 367d12660064
Ref: library/xml dom xml dom Node parentNode12660586
Ref: 367e12660586
Ref: library/xml dom xml dom Node attributes12661169
Ref: 367f12661169
Ref: library/xml dom xml dom Node previousSibling12661452
Ref: 368012661452
Ref: library/xml dom xml dom Node nextSibling12662082
Ref: 368112662082
Ref: library/xml dom xml dom Node childNodes12662451
Ref: 368212662451
Ref: library/xml dom xml dom Node firstChild12662613
Ref: 368312662613
Ref: library/xml dom xml dom Node lastChild12662826
Ref: 368412662826
Ref: library/xml dom xml dom Node localName12663038
Ref: 368512663038
Ref: library/xml dom xml dom Node prefix12663227
Ref: 368612663227
Ref: library/xml dom xml dom Node namespaceURI12663432
Ref: 368712663432
Ref: library/xml dom xml dom Node nodeName12663611
Ref: 368812663611
Ref: library/xml dom xml dom Node nodeValue12664145
Ref: 368912664145
Ref: library/xml dom xml dom Node hasAttributes12664448
Ref: 368a12664448
Ref: library/xml dom xml dom Node hasChildNodes12664583
Ref: 368b12664583
Ref: library/xml dom xml dom Node isSameNode12664724
Ref: 368c12664724
Ref: library/xml dom xml dom Node appendChild12665700
Ref: 368d12665700
Ref: library/xml dom xml dom Node insertBefore12665963
Ref: 368e12665963
Ref: library/xml dom xml dom Node removeChild12666418
Ref: 368f12666418
Ref: library/xml dom xml dom Node replaceChild12666845
Ref: 369012666845
Ref: library/xml dom xml dom Node normalize12667154
Ref: 369112667154
Ref: library/xml dom xml dom Node cloneNode12667488
Ref: 369212667488
Node: NodeList オブジェクト12667720
Ref: library/xml dom dom-nodelist-objects12667884
Ref: 367012667884
Ref: library/xml dom nodelist-objects12667884
Ref: 369312667884
Ref: library/xml dom xml dom NodeList item12668672
Ref: 369412668672
Ref: library/xml dom xml dom NodeList length12668928
Ref: 369512668928
Node: DocumentType オブジェクト12669797
Ref: library/xml dom documenttype-objects12669965
Ref: 369612669965
Ref: library/xml dom dom-documenttype-objects12669965
Ref: 367112669965
Ref: library/xml dom xml dom DocumentType publicId12670791
Ref: 369712670791
Ref: library/xml dom xml dom DocumentType systemId12671014
Ref: 369812671014
Ref: library/xml dom xml dom DocumentType internalSubset12671257
Ref: 369912671257
Ref: library/xml dom xml dom DocumentType name12671560
Ref: 369a12671560
Ref: library/xml dom xml dom DocumentType entities12671714
Ref: 369b12671714
Ref: library/xml dom xml dom DocumentType notations12672212
Ref: 369c12672212
Node: Document オブジェクト12672685
Ref: library/xml dom document-objects12672855
Ref: 369d12672855
Ref: library/xml dom dom-document-objects12672855
Ref: 367212672855
Ref: library/xml dom xml dom Document documentElement12673195
Ref: 369e12673195
Ref: library/xml dom xml dom Document createElement12673303
Ref: 369f12673303
Ref: library/xml dom xml dom Document createElementNS12673663
Ref: 36a012673663
Ref: library/xml dom xml dom Document createTextNode12674126
Ref: 36a112674126
Ref: library/xml dom xml dom Document createComment12674424
Ref: 36a212674424
Ref: library/xml dom xml dom Document createProcessingInstruction12674721
Ref: 36a312674721
Ref: library/xml dom xml dom Document createAttribute12675058
Ref: 36a412675058
Ref: library/xml dom xml dom Document createAttributeNS12675451
Ref: 36a512675451
Ref: library/xml dom xml dom Document getElementsByTagName12675976
Ref: 36a612675976
Ref: library/xml dom xml dom Document getElementsByTagNameNS12676181
Ref: 36a712676181
Node: Element オブジェクト<2>12676521
Ref: library/xml dom dom-element-objects12676683
Ref: 367312676683
Ref: library/xml dom element-objects12676683
Ref: 36a812676683
Ref: library/xml dom xml dom Element tagName12676881
Ref: 36a912676881
Ref: library/xml dom xml dom Element getElementsByTagName12677067
Ref: 36aa12677067
Ref: library/xml dom xml dom Element getElementsByTagNameNS12677210
Ref: 36ab12677210
Ref: library/xml dom xml dom Element hasAttribute12677371
Ref: 36ac12677371
Ref: library/xml dom xml dom Element hasAttributeNS12677535
Ref: 36ad12677535
Ref: library/xml dom xml dom Element getAttribute12677747
Ref: 36ae12677747
Ref: library/xml dom xml dom Element getAttributeNode12678015
Ref: 36af12678015
Ref: library/xml dom xml dom Element getAttributeNS12678154
Ref: 36b012678154
Ref: library/xml dom xml dom Element getAttributeNodeNS12678476
Ref: 36b112678476
Ref: library/xml dom xml dom Element removeAttribute12678665
Ref: 36b212678665
Ref: library/xml dom xml dom Element removeAttributeNode12678863
Ref: 36b412678863
Ref: library/xml dom xml dom Element removeAttributeNS12679094
Ref: 36b512679094
Ref: library/xml dom xml dom Element setAttribute12679397
Ref: 36b612679397
Ref: library/xml dom xml dom Element setAttributeNode12679509
Ref: 36b712679509
Ref: library/xml dom xml dom Element setAttributeNodeNS12679915
Ref: 36b912679915
Ref: library/xml dom xml dom Element setAttributeNS12680366
Ref: 36ba12680366
Node: Attr オブジェクト12680688
Ref: library/xml dom attr-objects12680843
Ref: 36bb12680843
Ref: library/xml dom dom-attr-objects12680843
Ref: 367412680843
Ref: library/xml dom xml dom Attr name12680998
Ref: 36bc12680998
Ref: library/xml dom xml dom Attr localName12681160
Ref: 36bd12681160
Ref: library/xml dom xml dom Attr prefix12681306
Ref: 36be12681306
Ref: library/xml dom xml dom Attr value12681449
Ref: 36bf12681449
Node: NamedNodeMap Objects12681562
Ref: library/xml dom dom-attributelist-objects12681714
Ref: 36c012681714
Ref: library/xml dom namednodemap-objects12681714
Ref: 36c112681714
Ref: library/xml dom xml dom NamedNodeMap length12681847
Ref: 36c212681847
Ref: library/xml dom xml dom NamedNodeMap item12681923
Ref: 36c312681923
Node: Comment オブジェクト12682587
Ref: library/xml dom comment-objects12682780
Ref: 36c412682780
Ref: library/xml dom dom-comment-objects12682780
Ref: 367512682780
Ref: library/xml dom xml dom Comment data12683027
Ref: 36c512683027
Node: Text オブジェクトおよび CDATASection オブジェクト12683342
Ref: library/xml dom dom-text-objects12683555
Ref: 367612683555
Ref: library/xml dom text-and-cdatasection-objects12683555
Ref: 36c612683555
Ref: library/xml dom xml dom Text data12684302
Ref: 36c712684302
Node: ProcessingInstruction オブジェクト12684926
Ref: library/xml dom dom-pi-objects12685123
Ref: 367712685123
Ref: library/xml dom processinginstruction-objects12685123
Ref: 36c812685123
Ref: library/xml dom xml dom ProcessingInstruction target12685384
Ref: 36c912685384
Ref: library/xml dom xml dom ProcessingInstruction data12685532
Ref: 36ca12685532
Node: 例外<19>12685642
Ref: library/xml dom dom-exceptions12685766
Ref: 36cb12685766
Ref: library/xml dom exceptions12685766
Ref: 36cc12685766
Ref: library/xml dom xml dom DOMException12686612
Ref: 36cd12686612
Ref: library/xml dom xml dom DomstringSizeErr12686823
Ref: 36ce12686823
Ref: library/xml dom xml dom HierarchyRequestErr12687157
Ref: 36cf12687157
Ref: library/xml dom xml dom IndexSizeErr12687298
Ref: 36d012687298
Ref: library/xml dom xml dom InuseAttributeErr12687480
Ref: 36b812687480
Ref: library/xml dom xml dom InvalidAccessErr12687643
Ref: 36d112687643
Ref: library/xml dom xml dom InvalidCharacterErr12687820
Ref: 36d212687820
Ref: library/xml dom xml dom InvalidModificationErr12688194
Ref: 36d312688194
Ref: library/xml dom xml dom InvalidStateErr12688317
Ref: 36d412688317
Ref: library/xml dom xml dom NamespaceErr12688520
Ref: 36d512688520
Ref: library/xml dom xml dom NotFoundErr12688729
Ref: 36b312688729
Ref: library/xml dom xml dom NotSupportedErr12689056
Ref: 36d612689056
Ref: library/xml dom xml dom NoDataAllowedErr12689226
Ref: 36d712689226
Ref: library/xml dom xml dom NoModificationAllowedErr12689379
Ref: 36d812689379
Ref: library/xml dom xml dom SyntaxErr12689610
Ref: 36d912689610
Ref: library/xml dom xml dom WrongDocumentErr12689726
Ref: 36da12689726
Ref: 例外<19>-Footnote-112692813
Node: 適合性12692858
Ref: library/xml dom conformance12693002
Ref: 36db12693002
Ref: library/xml dom dom-conformance12693002
Ref: 366512693002
Node: 型の対応付け12693282
Ref: library/xml dom dom-type-mapping12693379
Ref: 36dc12693379
Ref: library/xml dom type-mapping12693379
Ref: 36dd12693379
Node: アクセサメソッド12694252
Ref: library/xml dom accessor-methods12694349
Ref: 36de12694349
Ref: library/xml dom dom-accessor-methods12694349
Ref: 36df12694349
Node: xml dom minidom --- 最小限の DOM の実装12696873
Ref: library/xml dom minidom doc12697138
Ref: 36e012697138
Ref: library/xml dom minidom module-xml dom minidom12697138
Ref: 10912697138
Ref: library/xml dom minidom xml-dom-minidom-minimal-dom-implementation12697138
Ref: 36e112697138
Ref: library/xml dom minidom xml dom minidom parse12698806
Ref: 36e212698806
Ref: library/xml dom minidom xml dom minidom parseString12699573
Ref: 36e312699573
Ref: xml dom minidom --- 最小限の DOM の実装-Footnote-112702813
Ref: xml dom minidom --- 最小限の DOM の実装-Footnote-212702889
Node: DOM オブジェクト12702936
Ref: library/xml dom minidom dom-objects12703060
Ref: 36e412703060
Ref: library/xml dom minidom minidom-objects12703060
Ref: 36e512703060
Ref: library/xml dom minidom xml dom minidom Node unlink12703370
Ref: 36e612703370
Ref: library/xml dom minidom xml dom minidom Node writexml12704510
Ref: 36e712704510
Ref: library/xml dom minidom xml dom minidom Node toxml12706089
Ref: 147012706089
Ref: library/xml dom minidom xml dom minidom Node toprettyxml12707145
Ref: 147112707145
Ref: DOM オブジェクト-Footnote-112708016
Node: DOM の例12708502
Ref: library/xml dom minidom dom-example12708657
Ref: 36e812708657
Ref: library/xml dom minidom id212708657
Ref: 36e912708657
Node: minidom と DOM 標準12710713
Ref: library/xml dom minidom minidom-and-dom12710837
Ref: 36ea12710837
Ref: library/xml dom minidom minidom-and-the-dom-standard12710837
Ref: 36eb12710837
Node: xml dom pulldom --- 部分的な DOM ツリー構築のサポート12714411
Ref: library/xml dom pulldom doc12714659
Ref: 36ec12714659
Ref: library/xml dom pulldom module-xml dom pulldom12714659
Ref: 10a12714659
Ref: library/xml dom pulldom xml-dom-pulldom-support-for-building-partial-dom-trees12714659
Ref: 36ed12714659
Ref: library/xml dom pulldom xml dom pulldom PullDom12717958
Ref: 36ef12717958
Ref: library/xml dom pulldom xml dom pulldom SAX2DOM12718099
Ref: 36f112718099
Ref: library/xml dom pulldom xml dom pulldom parse12718240
Ref: 36f212718240
Ref: library/xml dom pulldom xml dom pulldom parseString12719010
Ref: 36f412719010
Ref: library/xml dom pulldom xml dom pulldom default_bufsize12719171
Ref: 36f512719171
Ref: xml dom pulldom --- 部分的な DOM ツリー構築のサポート-Footnote-112719560
Node: DOMEventStream オブジェクト12719636
Ref: library/xml dom pulldom domeventstream-objects12719773
Ref: 36f612719773
Ref: library/xml dom pulldom id112719773
Ref: 36f712719773
Ref: library/xml dom pulldom xml dom pulldom DOMEventStream12719854
Ref: 70012719854
Ref: library/xml dom pulldom xml dom pulldom DOMEventStream getEvent12720052
Ref: 36f812720052
Ref: library/xml dom pulldom xml dom pulldom DOMEventStream expandNode12720579
Ref: 36ee12720579
Ref: library/xml dom pulldom xml dom pulldom DOMEventStream reset12721307
Ref: 36f912721307
Node: xml sax --- SAX2 バーサーのサポート12721340
Ref: library/xml sax doc12721599
Ref: 36fa12721599
Ref: library/xml sax module-xml sax12721599
Ref: 11012721599
Ref: library/xml sax xml-sax-support-for-sax2-parsers12721599
Ref: 36fb12721599
Ref: library/xml sax xml sax make_parser12723139
Ref: 19a612723139
Ref: library/xml sax xml sax parse12723821
Ref: 196f12723821
Ref: library/xml sax xml sax parseString12724703
Ref: e6512724703
Ref: library/xml sax xml sax SAXException12727375
Ref: 370112727375
Ref: library/xml sax xml sax SAXParseException12728430
Ref: 36ff12728430
Ref: library/xml sax xml sax SAXNotRecognizedException12728926
Ref: 370212728926
Ref: library/xml sax xml sax SAXNotSupportedException12729319
Ref: 370312729319
Ref: xml sax --- SAX2 バーサーのサポート-Footnote-112730480
Ref: xml sax --- SAX2 バーサーのサポート-Footnote-212730557
Node: SAXException オブジェクト12730592
Ref: library/xml sax sax-exception-objects12730704
Ref: 370412730704
Ref: library/xml sax saxexception-objects12730704
Ref: 370512730704
Ref: library/xml sax xml sax SAXException getMessage12730880
Ref: 370612730880
Ref: library/xml sax xml sax SAXException getException12730996
Ref: 370712730996
Node: xml sax handler --- SAX ハンドラーの基底クラス12731135
Ref: library/xml sax handler doc12731376
Ref: 370812731376
Ref: library/xml sax handler module-xml sax handler12731376
Ref: 11112731376
Ref: library/xml sax handler xml-sax-handler-base-classes-for-sax-handlers12731376
Ref: 370912731376
Ref: library/xml sax handler xml sax handler ContentHandler12732091
Ref: 36f012732091
Ref: library/xml sax handler xml sax handler DTDHandler12732414
Ref: 370a12732414
Ref: library/xml sax handler xml sax handler EntityResolver12732686
Ref: 370b12732686
Ref: library/xml sax handler xml sax handler ErrorHandler12733046
Ref: 36fe12733046
Ref: library/xml sax handler xml sax handler LexicalHandler12733425
Ref: 82712733425
Ref: library/xml sax handler xml sax handler feature_namespaces12733740
Ref: 370c12733740
Ref: library/xml sax handler xml sax handler feature_namespace_prefixes12734140
Ref: 370d12734140
Ref: library/xml sax handler xml sax handler feature_string_interning12734668
Ref: 370e12734668
Ref: library/xml sax handler xml sax handler feature_validation12735186
Ref: 370f12735186
Ref: library/xml sax handler xml sax handler feature_external_ges12735617
Ref: 36fc12735617
Ref: library/xml sax handler xml sax handler feature_external_pes12736012
Ref: 371012736012
Ref: library/xml sax handler xml sax handler all_features12736469
Ref: 371112736469
Ref: library/xml sax handler xml sax handler property_lexical_handler12736545
Ref: 371212736545
Ref: library/xml sax handler xml sax handler property_declaration_handler12736895
Ref: 371312736895
Ref: library/xml sax handler xml sax handler property_dom_node12737287
Ref: 371412737287
Ref: library/xml sax handler xml sax handler property_xml_string12737733
Ref: 371512737733
Ref: library/xml sax handler xml sax handler all_properties12738002
Ref: 371612738002
Ref: xml sax handler --- SAX ハンドラーの基底クラス-Footnote-112738320
Node: ContentHandler オブジェクト12738396
Ref: library/xml sax handler content-handler-objects12738561
Ref: 371712738561
Ref: library/xml sax handler contenthandler-objects12738561
Ref: 371812738561
Ref: library/xml sax handler xml sax handler ContentHandler setDocumentLocator12738917
Ref: 371912738917
Ref: library/xml sax handler xml sax handler ContentHandler startDocument12740220
Ref: 371a12740220
Ref: library/xml sax handler xml sax handler ContentHandler endDocument12740550
Ref: 371b12740550
Ref: library/xml sax handler xml sax handler ContentHandler startPrefixMapping12740987
Ref: 371c12740987
Ref: library/xml sax handler xml sax handler ContentHandler endPrefixMapping12742361
Ref: 371d12742361
Ref: library/xml sax handler xml sax handler ContentHandler startElement12742790
Ref: 14eb12742790
Ref: library/xml sax handler xml sax handler ContentHandler endElement12743583
Ref: 14ec12743583
Ref: library/xml sax handler xml sax handler ContentHandler startElementNS12743829
Ref: 371f12743829
Ref: library/xml sax handler xml sax handler ContentHandler endElementNS12744992
Ref: 372112744992
Ref: library/xml sax handler xml sax handler ContentHandler characters12745276
Ref: 14ed12745276
Ref: library/xml sax handler xml sax handler ContentHandler ignorableWhitespace12746680
Ref: 372212746680
Ref: library/xml sax handler xml sax handler ContentHandler processingInstruction12747597
Ref: 372312747597
Ref: library/xml sax handler xml sax handler ContentHandler skippedEntity12748169
Ref: 372412748169
Node: DTDHandler オブジェクト12748818
Ref: library/xml sax handler dtd-handler-objects12749025
Ref: 372512749025
Ref: library/xml sax handler dtdhandler-objects12749025
Ref: 372612749025
Ref: library/xml sax handler xml sax handler DTDHandler notationDecl12749187
Ref: 372712749187
Ref: library/xml sax handler xml sax handler DTDHandler unparsedEntityDecl12749315
Ref: 372812749315
Node: EntityResolver オブジェクト12749493
Ref: library/xml sax handler entity-resolver-objects12749698
Ref: 372912749698
Ref: library/xml sax handler entityresolver-objects12749698
Ref: 372a12749698
Ref: library/xml sax handler xml sax handler EntityResolver resolveEntity12749781
Ref: 372b12749781
Node: ErrorHandler オブジェクト12750116
Ref: library/xml sax handler errorhandler-objects12750314
Ref: 372c12750314
Ref: library/xml sax handler sax-error-handler12750314
Ref: 372d12750314
Ref: library/xml sax handler xml sax handler ErrorHandler error12750985
Ref: 372e12750985
Ref: library/xml sax handler xml sax handler ErrorHandler fatalError12751465
Ref: 372f12751465
Ref: library/xml sax handler xml sax handler ErrorHandler warning12751702
Ref: 373012751702
Node: LexicalHandler Objects12752120
Ref: library/xml sax handler lexical-handler-objects12752276
Ref: 373112752276
Ref: library/xml sax handler lexicalhandler-objects12752276
Ref: 373212752276
Ref: library/xml sax handler xml sax handler LexicalHandler comment12752881
Ref: 373312752881
Ref: library/xml sax handler xml sax handler LexicalHandler startDTD12753041
Ref: 373412753041
Ref: library/xml sax handler xml sax handler LexicalHandler endDTD12753205
Ref: 373512753205
Ref: library/xml sax handler xml sax handler LexicalHandler startCDATA12753291
Ref: 373612753291
Ref: library/xml sax handler xml sax handler LexicalHandler endCDATA12753491
Ref: 373712753491
Node: xml sax saxutils --- SAX ユーティリティー12753586
Ref: library/xml sax utils doc12753848
Ref: 373812753848
Ref: library/xml sax utils module-xml sax saxutils12753848
Ref: 11212753848
Ref: library/xml sax utils xml-sax-saxutils-sax-utilities12753848
Ref: 373912753848
Ref: library/xml sax utils xml sax saxutils escape12754315
Ref: 373a12754315
Ref: library/xml sax utils xml sax saxutils unescape12755107
Ref: 373b12755107
Ref: library/xml sax utils xml sax saxutils quoteattr12755708
Ref: 373c12755708
Ref: library/xml sax utils xml sax saxutils XMLGenerator12756669
Ref: 373d12756669
Ref: library/xml sax utils xml sax saxutils XMLFilterBase12757733
Ref: 373e12757733
Ref: library/xml sax utils xml sax saxutils prepare_input_source12758346
Ref: 373f12758346
Ref: xml sax saxutils --- SAX ユーティリティー-Footnote-112758934
Node: xml sax xmlreader --- XML パーサーのインターフェース12759011
Ref: library/xml sax reader doc12759279
Ref: 374112759279
Ref: library/xml sax reader module-xml sax xmlreader12759279
Ref: 11312759279
Ref: library/xml sax reader xml-sax-xmlreader-interface-for-xml-parsers12759279
Ref: 374212759279
Ref: library/xml sax reader xml sax xmlreader XMLReader12759880
Ref: 36f312759880
Ref: library/xml sax reader xml sax xmlreader IncrementalParser12759986
Ref: 374312759986
Ref: library/xml sax reader xml sax xmlreader Locator12761507
Ref: 370012761507
Ref: library/xml sax reader xml sax xmlreader InputSource12761945
Ref: e6412761945
Ref: library/xml sax reader xml sax xmlreader AttributesImpl12762915
Ref: 374412762915
Ref: library/xml sax reader xml sax xmlreader AttributesNSImpl12763611
Ref: 374512763611
Ref: xml sax xmlreader --- XML パーサーのインターフェース-Footnote-112764482
Node: XMLReader オブジェクト12764560
Ref: library/xml sax reader id112764735
Ref: 374612764735
Ref: library/xml sax reader xmlreader-objects12764735
Ref: 374712764735
Ref: library/xml sax reader xml sax xmlreader XMLReader parse12764879
Ref: 374012764879
Ref: library/xml sax reader xml sax xmlreader XMLReader getContentHandler12765672
Ref: 374812765672
Ref: library/xml sax reader xml sax xmlreader XMLReader setContentHandler12765785
Ref: 374912765785
Ref: library/xml sax reader xml sax xmlreader XMLReader getDTDHandler12766026
Ref: 374a12766026
Ref: library/xml sax reader xml sax xmlreader XMLReader setDTDHandler12766131
Ref: 374b12766131
Ref: library/xml sax reader xml sax xmlreader XMLReader getEntityResolver12766346
Ref: 374c12766346
Ref: library/xml sax reader xml sax xmlreader XMLReader setEntityResolver12766459
Ref: 374d12766459
Ref: library/xml sax reader xml sax xmlreader XMLReader getErrorHandler12766826
Ref: 374e12766826
Ref: library/xml sax reader xml sax xmlreader XMLReader setErrorHandler12766935
Ref: 374f12766935
Ref: library/xml sax reader xml sax xmlreader XMLReader setLocale12767188
Ref: 375012767188
Ref: library/xml sax reader xml sax xmlreader XMLReader getFeature12767696
Ref: 375112767696
Ref: library/xml sax reader xml sax xmlreader XMLReader setFeature12768020
Ref: 36fd12768020
Ref: library/xml sax reader xml sax xmlreader XMLReader getProperty12768410
Ref: 375212768410
Ref: library/xml sax reader xml sax xmlreader XMLReader setProperty12768737
Ref: 375312768737
Node: IncrementalParser オブジェクト12769130
Ref: library/xml sax reader incremental-parser-objects12769340
Ref: 375412769340
Ref: library/xml sax reader incrementalparser-objects12769340
Ref: 375512769340
Ref: library/xml sax reader xml sax xmlreader IncrementalParser feed12769530
Ref: 375612769530
Ref: library/xml sax reader xml sax xmlreader IncrementalParser close12769629
Ref: 375712769629
Ref: library/xml sax reader xml sax xmlreader IncrementalParser reset12769862
Ref: 375812769862
Node: Locator オブジェクト12770200
Ref: library/xml sax reader id212770412
Ref: 375912770412
Ref: library/xml sax reader locator-objects12770412
Ref: 375a12770412
Ref: library/xml sax reader xml sax xmlreader Locator getColumnNumber12770565
Ref: 375b12770565
Ref: library/xml sax reader xml sax xmlreader Locator getLineNumber12770681
Ref: 375c12770681
Ref: library/xml sax reader xml sax xmlreader Locator getPublicId12770795
Ref: 375d12770795
Ref: library/xml sax reader xml sax xmlreader Locator getSystemId12770907
Ref: 375e12770907
Node: InputSource オブジェクト12771019
Ref: library/xml sax reader input-source-objects12771230
Ref: 375f12771230
Ref: library/xml sax reader inputsource-objects12771230
Ref: 376012771230
Ref: library/xml sax reader xml sax xmlreader InputSource setPublicId12771307
Ref: 376112771307
Ref: library/xml sax reader xml sax xmlreader InputSource getPublicId12771432
Ref: 376212771432
Ref: library/xml sax reader xml sax xmlreader InputSource setSystemId12771552
Ref: 376312771552
Ref: library/xml sax reader xml sax xmlreader InputSource getSystemId12771683
Ref: 376412771683
Ref: library/xml sax reader xml sax xmlreader InputSource setEncoding12771809
Ref: 376512771809
Ref: library/xml sax reader xml sax xmlreader InputSource getEncoding12772305
Ref: 376612772305
Ref: library/xml sax reader xml sax xmlreader InputSource setByteStream12772431
Ref: 376712772431
Ref: library/xml sax reader xml sax xmlreader InputSource getByteStream12773021
Ref: 376812773021
Ref: library/xml sax reader xml sax xmlreader InputSource setCharacterStream12773317
Ref: 376912773317
Ref: library/xml sax reader xml sax xmlreader InputSource getCharacterStream12773670
Ref: 376a12773670
Node: Attributes インターフェース12773796
Ref: library/xml sax reader attributes-objects12774018
Ref: 371e12774018
Ref: library/xml sax reader the-attributes-interface12774018
Ref: 376b12774018
Ref: library/xml sax reader xml sax xmlreader Attributes getLength12774397
Ref: 376c12774397
Ref: library/xml sax reader xml sax xmlreader Attributes getNames12774477
Ref: 376d12774477
Ref: library/xml sax reader xml sax xmlreader Attributes getType12774559
Ref: 376e12774559
Ref: library/xml sax reader xml sax xmlreader Attributes getValue12774691
Ref: 376f12774691
Node: AttributesNS インターフェース12774782
Ref: library/xml sax reader attributes-ns-objects12774965
Ref: 372012774965
Ref: library/xml sax reader the-attributesns-interface12774965
Ref: 377012774965
Ref: library/xml sax reader xml sax xmlreader AttributesNS getValueByQName12775436
Ref: 377112775436
Ref: library/xml sax reader xml sax xmlreader AttributesNS getNameByQName12775531
Ref: 377212775531
Ref: library/xml sax reader xml sax xmlreader AttributesNS getQNameByName12775687
Ref: 377312775687
Ref: library/xml sax reader xml sax xmlreader AttributesNS getQNames12775828
Ref: 377412775828
Node: xml parsers expat --- Expat を使用した高速な XML 解析12775928
Ref: library/pyexpat doc12776138
Ref: 377512776138
Ref: library/pyexpat module-xml parsers expat12776138
Ref: 10d12776138
Ref: library/pyexpat xml-parsers-expat-fast-xml-parsing-using-expat12776138
Ref: 377612776138
Ref: library/pyexpat xml parsers expat ExpatError12777610
Ref: 124a12777610
Ref: library/pyexpat xml parsers expat error12777865
Ref: 377812777865
Ref: library/pyexpat xml parsers expat XMLParserType12777951
Ref: 377912777951
Ref: library/pyexpat xml parsers expat ErrorString12778197
Ref: 377b12778197
Ref: library/pyexpat xml parsers expat ParserCreate12778339
Ref: 377a12778339
Ref: xml parsers expat --- Expat を使用した高速な XML 解析-Footnote-112781311
Ref: xml parsers expat --- Expat を使用した高速な XML 解析-Footnote-212781705
Node: XMLParser オブジェクト<2>12781738
Ref: library/pyexpat id212781895
Ref: 377c12781895
Ref: library/pyexpat xmlparser-objects12781895
Ref: 377d12781895
Ref: library/pyexpat xml parsers expat xmlparser Parse12782053
Ref: 377e12782053
Ref: library/pyexpat xml parsers expat xmlparser ParseFile12782550
Ref: 377f12782550
Ref: library/pyexpat xml parsers expat xmlparser SetBase12782869
Ref: 378012782869
Ref: library/pyexpat xml parsers expat xmlparser GetBase12783322
Ref: 378412783322
Ref: library/pyexpat xml parsers expat xmlparser GetInputContext12783577
Ref: 378512783577
Ref: library/pyexpat xml parsers expat xmlparser ExternalEntityParserCreate12783970
Ref: 378612783970
Ref: library/pyexpat xml parsers expat xmlparser SetParamEntityParsing12784595
Ref: 378912784595
Ref: library/pyexpat xml parsers expat xmlparser UseForeignDTD12784998
Ref: 378a12784998
Ref: library/pyexpat xml parsers expat xmlparser SetReparseDeferralEnabled12786151
Ref: 25312786151
Ref: library/pyexpat xml parsers expat xmlparser GetReparseDeferralEnabled12787665
Ref: 25212787665
Ref: library/pyexpat xml parsers expat xmlparser buffer_size12787930
Ref: 378d12787930
Ref: library/pyexpat xml parsers expat xmlparser buffer_text12788255
Ref: 146712788255
Ref: library/pyexpat xml parsers expat xmlparser buffer_used12788801
Ref: 378f12788801
Ref: library/pyexpat xml parsers expat xmlparser ordered_attributes12789139
Ref: 378712789139
Ref: library/pyexpat xml parsers expat xmlparser specified_attributes12789762
Ref: 378812789762
Ref: library/pyexpat xml parsers expat xmlparser ErrorByteIndex12790764
Ref: 379012790764
Ref: library/pyexpat xml parsers expat xmlparser ErrorCode12790872
Ref: 379112790872
Ref: library/pyexpat xml parsers expat xmlparser ErrorColumnNumber12791121
Ref: 379212791121
Ref: library/pyexpat xml parsers expat xmlparser ErrorLineNumber12791220
Ref: 379312791220
Ref: library/pyexpat xml parsers expat xmlparser CurrentByteIndex12791796
Ref: 379412791796
Ref: library/pyexpat xml parsers expat xmlparser CurrentColumnNumber12791912
Ref: 379512791912
Ref: library/pyexpat xml parsers expat xmlparser CurrentLineNumber12792019
Ref: 379612792019
Ref: library/pyexpat xml parsers expat xmlparser XmlDeclHandler12792602
Ref: 379712792602
Ref: library/pyexpat xml parsers expat xmlparser StartDoctypeDeclHandler12793263
Ref: 378b12793263
Ref: library/pyexpat xml parsers expat xmlparser EndDoctypeDeclHandler12794049
Ref: 378c12794049
Ref: library/pyexpat xml parsers expat xmlparser ElementDeclHandler12794261
Ref: 379812794261
Ref: library/pyexpat xml parsers expat xmlparser AttlistDeclHandler12794502
Ref: 379912794502
Ref: library/pyexpat xml parsers expat xmlparser StartElementHandler12795575
Ref: 379a12795575
Ref: library/pyexpat xml parsers expat xmlparser EndElementHandler12796014
Ref: 379b12796014
Ref: library/pyexpat xml parsers expat xmlparser ProcessingInstructionHandler12796138
Ref: 379c12796138
Ref: library/pyexpat xml parsers expat xmlparser CharacterDataHandler12796278
Ref: 378e12796278
Ref: library/pyexpat xml parsers expat xmlparser UnparsedEntityDeclHandler12796949
Ref: 378312796949
Ref: library/pyexpat xml parsers expat xmlparser EntityDeclHandler12797529
Ref: 379f12797529
Ref: library/pyexpat xml parsers expat xmlparser NotationDeclHandler12798608
Ref: 378212798608
Ref: library/pyexpat xml parsers expat xmlparser StartNamespaceDeclHandler12798991
Ref: 37a012798991
Ref: library/pyexpat xml parsers expat xmlparser EndNamespaceDeclHandler12799310
Ref: 37a112799310
Ref: library/pyexpat xml parsers expat xmlparser CommentHandler12799903
Ref: 37a212799903
Ref: library/pyexpat xml parsers expat xmlparser StartCdataSectionHandler12800129
Ref: 379d12800129
Ref: library/pyexpat xml parsers expat xmlparser EndCdataSectionHandler12800439
Ref: 379e12800439
Ref: library/pyexpat xml parsers expat xmlparser DefaultHandler12800561
Ref: 37a312800561
Ref: library/pyexpat xml parsers expat xmlparser DefaultHandlerExpand12800954
Ref: 37a412800954
Ref: library/pyexpat xml parsers expat xmlparser NotStandaloneHandler12801216
Ref: 37a512801216
Ref: library/pyexpat xml parsers expat xmlparser ExternalEntityRefHandler12801838
Ref: 378112801838
Node: ExpatError 例外12803335
Ref: library/pyexpat expaterror-exceptions12803514
Ref: 37a612803514
Ref: library/pyexpat expaterror-objects12803514
Ref: 377712803514
Ref: library/pyexpat xml parsers expat ExpatError code12803659
Ref: 37a712803659
Ref: library/pyexpat xml parsers expat ExpatError lineno12804417
Ref: 37aa12804417
Ref: library/pyexpat xml parsers expat ExpatError offset12804554
Ref: 37ab12804554
Node: 使用例<34>12804717
Ref: library/pyexpat example12804889
Ref: 37ac12804889
Ref: library/pyexpat expat-example12804889
Ref: 37ad12804889
Node: 内容モデルの記述12806066
Ref: library/pyexpat content-model-descriptions12806242
Ref: 37ae12806242
Ref: library/pyexpat expat-content-models12806242
Ref: 37af12806242
Ref: library/pyexpat module-xml parsers expat model12806242
Ref: 10f12806242
Node: Expat エラー定数12808557
Ref: library/pyexpat expat-error-constants12808711
Ref: 37b012808711
Ref: library/pyexpat expat-errors12808711
Ref: 37b112808711
Ref: library/pyexpat module-xml parsers expat errors12808711
Ref: 10e12808711
Ref: library/pyexpat xml parsers expat errors codes12809367
Ref: 37a912809367
Ref: library/pyexpat xml parsers expat errors messages12809521
Ref: 37a812809521
Ref: library/pyexpat xml parsers expat errors XML_ERROR_ASYNC_ENTITY12809690
Ref: 37b212809690
Ref: library/pyexpat xml parsers expat errors XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF12809754
Ref: 37b312809754
Ref: library/pyexpat xml parsers expat errors XML_ERROR_BAD_CHAR_REF12809987
Ref: 37b412809987
Ref: library/pyexpat xml parsers expat errors XML_ERROR_BINARY_ENTITY_REF12810184
Ref: 37b512810184
Ref: library/pyexpat xml parsers expat errors XML_ERROR_DUPLICATE_ATTRIBUTE12810410
Ref: 37b612810410
Ref: library/pyexpat xml parsers expat errors XML_ERROR_INCORRECT_ENCODING12810575
Ref: 37b712810575
Ref: library/pyexpat xml parsers expat errors XML_ERROR_INVALID_TOKEN12810645
Ref: 37b812810645
Ref: library/pyexpat xml parsers expat errors XML_ERROR_JUNK_AFTER_DOC_ELEMENT12810913
Ref: 37b912810913
Ref: library/pyexpat xml parsers expat errors XML_ERROR_MISPLACED_XML_PI12811066
Ref: 37ba12811066
Ref: library/pyexpat xml parsers expat errors XML_ERROR_NO_ELEMENTS12811221
Ref: 37bb12811221
Ref: library/pyexpat xml parsers expat errors XML_ERROR_NO_MEMORY12811451
Ref: 37bc12811451
Ref: library/pyexpat xml parsers expat errors XML_ERROR_PARAM_ENTITY_REF12811579
Ref: 37bd12811579
Ref: library/pyexpat xml parsers expat errors XML_ERROR_PARTIAL_CHAR12811747
Ref: 37be12811747
Ref: library/pyexpat xml parsers expat errors XML_ERROR_RECURSIVE_ENTITY_REF12811872
Ref: 37bf12811872
Ref: library/pyexpat xml parsers expat errors XML_ERROR_SYNTAX12812144
Ref: 37c012812144
Ref: library/pyexpat xml parsers expat errors XML_ERROR_TAG_MISMATCH12812287
Ref: 37c112812287
Ref: library/pyexpat xml parsers expat errors XML_ERROR_UNCLOSED_TOKEN12812442
Ref: 37c212812442
Ref: library/pyexpat xml parsers expat errors XML_ERROR_UNDEFINED_ENTITY12812672
Ref: 37c312812672
Ref: library/pyexpat xml parsers expat errors XML_ERROR_UNKNOWN_ENCODING12812825
Ref: 37c412812825
Ref: library/pyexpat xml parsers expat errors XML_ERROR_UNCLOSED_CDATA_SECTION12812985
Ref: 37c512812985
Ref: library/pyexpat xml parsers expat errors XML_ERROR_EXTERNAL_ENTITY_HANDLING12813119
Ref: 37c612813119
Ref: library/pyexpat xml parsers expat errors XML_ERROR_NOT_STANDALONE12813195
Ref: 37c712813195
Ref: library/pyexpat xml parsers expat errors XML_ERROR_UNEXPECTED_STATE12813492
Ref: 37c812813492
Ref: library/pyexpat xml parsers expat errors XML_ERROR_ENTITY_DECLARED_IN_PE12813560
Ref: 37c912813560
Ref: library/pyexpat xml parsers expat errors XML_ERROR_FEATURE_REQUIRES_XML_DTD12813633
Ref: 37ca12813633
Ref: library/pyexpat xml parsers expat errors XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING12813976
Ref: 37cb12813976
Ref: library/pyexpat xml parsers expat errors XML_ERROR_UNBOUND_PREFIX12814319
Ref: 37cc12814319
Ref: library/pyexpat xml parsers expat errors XML_ERROR_UNDECLARING_PREFIX12814506
Ref: 37cd12814506
Ref: library/pyexpat xml parsers expat errors XML_ERROR_INCOMPLETE_PE12814691
Ref: 37ce12814691
Ref: library/pyexpat xml parsers expat errors XML_ERROR_XML_DECL12814853
Ref: 37cf12814853
Ref: library/pyexpat xml parsers expat errors XML_ERROR_TEXT_DECL12814962
Ref: 37d012814962
Ref: library/pyexpat xml parsers expat errors XML_ERROR_PUBLICID12815108
Ref: 37d112815108
Ref: library/pyexpat xml parsers expat errors XML_ERROR_SUSPENDED12815246
Ref: 37d212815246
Ref: library/pyexpat xml parsers expat errors XML_ERROR_NOT_SUSPENDED12815608
Ref: 37d312815608
Ref: library/pyexpat xml parsers expat errors XML_ERROR_ABORTED12815767
Ref: 37d412815767
Ref: library/pyexpat xml parsers expat errors XML_ERROR_FINISHED12815893
Ref: 37d512815893
Ref: library/pyexpat xml parsers expat errors XML_ERROR_SUSPEND_PE12816269
Ref: 37d612816269
Ref: library/pyexpat xml parsers expat errors XML_ERROR_RESERVED_PREFIX_XML12816331
Ref: 37d712816331
Ref: library/pyexpat xml parsers expat errors XML_ERROR_RESERVED_PREFIX_XMLNS12816522
Ref: 37d812816522
Ref: library/pyexpat xml parsers expat errors XML_ERROR_RESERVED_NAMESPACE_URI12816689
Ref: 37d912816689
Ref: library/pyexpat xml parsers expat errors XML_ERROR_INVALID_ARGUMENT12816904
Ref: 37da12816904
Ref: library/pyexpat xml parsers expat errors XML_ERROR_NO_BUFFER12817039
Ref: 37db12817039
Ref: library/pyexpat xml parsers expat errors XML_ERROR_AMPLIFICATION_LIMIT_BREACH12817167
Ref: 37dc12817167
Node: インターネットプロトコルとサポート12817362
Ref: library/internet doc12817565
Ref: 37dd12817565
Ref: library/internet internet12817565
Ref: 37de12817565
Ref: library/internet internet-protocols-and-support12817565
Ref: 37df12817565
Node: webbrowser --- 便利なウェブブラウザコントローラー12820693
Ref: library/webbrowser doc12820921
Ref: 37e012820921
Ref: library/webbrowser module-webbrowser12820921
Ref: fd12820921
Ref: library/webbrowser webbrowser-convenient-web-browser-controller12820921
Ref: 37e112820921
Ref: library/webbrowser webbrowser Error12824158
Ref: 37e312824158
Ref: library/webbrowser webbrowser open12824318
Ref: 37e212824318
Ref: library/webbrowser webbrowser open_new12825495
Ref: 37e412825495
Ref: library/webbrowser webbrowser open_new_tab12825852
Ref: 37e512825852
Ref: library/webbrowser webbrowser get12826206
Ref: 37e612826206
Ref: library/webbrowser webbrowser register12826499
Ref: 37e712826499
Ref: webbrowser --- 便利なウェブブラウザコントローラー-Footnote-112833607
Ref: webbrowser --- 便利なウェブブラウザコントローラー-Footnote-212833677
Node: ブラウザコントローラーオブジェクト12833855
Ref: library/webbrowser browser-controller-objects12834009
Ref: 37e812834009
Ref: library/webbrowser browser-controllers12834009
Ref: 37e912834009
Ref: library/webbrowser webbrowser controller name12834275
Ref: 27712834275
Ref: library/webbrowser webbrowser controller open12834353
Ref: 37ea12834353
Ref: library/webbrowser webbrowser controller open_new12834736
Ref: 37eb12834736
Ref: library/webbrowser webbrowser controller open_new_tab12835076
Ref: 37ec12835076
Node: wsgiref --- WSGI ユーティリティとリファレンス実装12835373
Ref: library/wsgiref doc12835652
Ref: 37ed12835652
Ref: library/wsgiref module-wsgiref12835652
Ref: 10012835652
Ref: library/wsgiref wsgiref-wsgi-utilities-and-reference-implementation12835652
Ref: 37ee12835652
Ref: wsgiref --- WSGI ユーティリティとリファレンス実装-Footnote-112838147
Ref: wsgiref --- WSGI ユーティリティとリファレンス実装-Footnote-212838211
Ref: wsgiref --- WSGI ユーティリティとリファレンス実装-Footnote-312838253
Node: wsgiref util -- WSGI 環境のユーティリティ12838290
Ref: library/wsgiref module-wsgiref util12838512
Ref: 10512838512
Ref: library/wsgiref wsgiref-util-wsgi-environment-utilities12838512
Ref: 37ef12838512
Ref: library/wsgiref wsgiref util guess_scheme12839155
Ref: 37f112839155
Ref: library/wsgiref wsgiref util request_uri12839977
Ref: 37f212839977
Ref: library/wsgiref wsgiref util application_uri12840371
Ref: 37f312840371
Ref: library/wsgiref wsgiref util shift_path_info12840693
Ref: 37f412840693
Ref: library/wsgiref wsgiref util setup_testing_defaults12842808
Ref: 37f512842808
Ref: library/wsgiref wsgiref util is_hop_by_hop12844827
Ref: 162a12844827
Ref: library/wsgiref wsgiref util FileWrapper12845028
Ref: 70112845028
Ref: wsgiref util -- WSGI 環境のユーティリティ-Footnote-112846365
Ref: wsgiref util -- WSGI 環境のユーティリティ-Footnote-212846407
Ref: wsgiref util -- WSGI 環境のユーティリティ-Footnote-312846449
Ref: wsgiref util -- WSGI 環境のユーティリティ-Footnote-412846491
Ref: wsgiref util -- WSGI 環境のユーティリティ-Footnote-512846533
Node: wsgiref headers -- WSGI レスポンスヘッダツール群12846592
Ref: library/wsgiref module-wsgiref headers12846883
Ref: 10212846883
Ref: library/wsgiref wsgiref-headers-wsgi-response-header-tools12846883
Ref: 37f712846883
Ref: library/wsgiref wsgiref headers Headers12847209
Ref: e6112847209
Ref: library/wsgiref wsgiref headers Headers get_all12849985
Ref: 37f812849985
Ref: library/wsgiref wsgiref headers Headers add_header12850557
Ref: 37f912850557
Ref: wsgiref headers -- WSGI レスポンスヘッダツール群-Footnote-112852092
Node: wsgiref simple_server -- シンプルな WSGI HTTP サーバ12852134
Ref: library/wsgiref module-wsgiref simple_server12852421
Ref: 10312852421
Ref: library/wsgiref wsgiref-simple-server-a-simple-wsgi-http-server12852421
Ref: 37fa12852421
Ref: library/wsgiref wsgiref simple_server make_server12853251
Ref: 37fb12853251
Ref: library/wsgiref wsgiref simple_server demo_app12854192
Ref: 37fc12854192
Ref: library/wsgiref wsgiref simple_server WSGIServer12854717
Ref: 37fd12854717
Ref: library/wsgiref wsgiref simple_server WSGIServer set_app12855614
Ref: 37ff12855614
Ref: library/wsgiref wsgiref simple_server WSGIServer get_app12855821
Ref: 380012855821
Ref: library/wsgiref wsgiref simple_server WSGIRequestHandler12856250
Ref: 380112856250
Ref: library/wsgiref wsgiref simple_server WSGIRequestHandler get_environ12857088
Ref: 380212857088
Ref: library/wsgiref wsgiref simple_server WSGIRequestHandler get_stderr12857679
Ref: 380312857679
Ref: library/wsgiref wsgiref simple_server WSGIRequestHandler handle12857899
Ref: 380412857899
Ref: wsgiref simple_server -- シンプルな WSGI HTTP サーバ-Footnote-112858266
Ref: wsgiref simple_server -- シンプルな WSGI HTTP サーバ-Footnote-212858308
Node: wsgiref validate --- WSGI 準拠チェッカー12858350
Ref: library/wsgiref module-wsgiref validate12858648
Ref: 10612858648
Ref: library/wsgiref wsgiref-validate-wsgi-conformance-checker12858648
Ref: 380512858648
Ref: library/wsgiref wsgiref validate validator12859857
Ref: 380612859857
Ref: wsgiref validate --- WSGI 準拠チェッカー-Footnote-112862421
Ref: wsgiref validate --- WSGI 準拠チェッカー-Footnote-212862463
Ref: wsgiref validate --- WSGI 準拠チェッカー-Footnote-312862522
Node: wsgiref handlers -- サーバ／ゲートウェイのベースクラス12862564
Ref: library/wsgiref module-wsgiref handlers12862854
Ref: 10112862854
Ref: library/wsgiref wsgiref-handlers-server-gateway-base-classes12862854
Ref: 380712862854
Ref: library/wsgiref wsgiref handlers CGIHandler12863359
Ref: 380812863359
Ref: library/wsgiref wsgiref handlers IISCGIHandler12864248
Ref: 380a12864248
Ref: library/wsgiref wsgiref handlers BaseCGIHandler12865702
Ref: 380912865702
Ref: library/wsgiref wsgiref handlers SimpleHandler12866783
Ref: 380b12866783
Ref: library/wsgiref wsgiref handlers BaseHandler12867832
Ref: 195b12867832
Ref: library/wsgiref wsgiref handlers BaseHandler run12868340
Ref: 381112868340
Ref: library/wsgiref wsgiref handlers BaseHandler _write12868850
Ref: 380f12868850
Ref: library/wsgiref wsgiref handlers BaseHandler _flush12869310
Ref: 381012869310
Ref: library/wsgiref wsgiref handlers BaseHandler get_stdin12869596
Ref: 380c12869596
Ref: library/wsgiref wsgiref handlers BaseHandler get_stderr12869805
Ref: 380d12869805
Ref: library/wsgiref wsgiref handlers BaseHandler add_cgi_vars12870016
Ref: 380e12870016
Ref: library/wsgiref wsgiref handlers BaseHandler wsgi_multithread12870667
Ref: 381412870667
Ref: library/wsgiref wsgiref handlers BaseHandler wsgi_multiprocess12871026
Ref: 381512871026
Ref: library/wsgiref wsgiref handlers BaseHandler wsgi_run_once12871387
Ref: 381612871387
Ref: library/wsgiref wsgiref handlers BaseHandler os_environ12871658
Ref: 381712871658
Ref: library/wsgiref wsgiref handlers BaseHandler server_software12872282
Ref: 381812872282
Ref: library/wsgiref wsgiref handlers BaseHandler get_scheme12872965
Ref: 381a12872965
Ref: library/wsgiref wsgiref handlers BaseHandler setup_environ12873335
Ref: 381b12873335
Ref: library/wsgiref wsgiref handlers BaseHandler log_exception12874069
Ref: 381d12874069
Ref: library/wsgiref wsgiref handlers BaseHandler traceback_limit12874745
Ref: 381e12874745
Ref: library/wsgiref wsgiref handlers BaseHandler error_output12875038
Ref: 381f12875038
Ref: library/wsgiref wsgiref handlers BaseHandler error_status12876428
Ref: 382012876428
Ref: library/wsgiref wsgiref handlers BaseHandler error_headers12876700
Ref: 382112876700
Ref: library/wsgiref wsgiref handlers BaseHandler error_body12877112
Ref: 382212877112
Ref: library/wsgiref wsgiref handlers BaseHandler wsgi_file_wrapper12877591
Ref: 381c12877591
Ref: library/wsgiref wsgiref handlers BaseHandler sendfile12877864
Ref: 382312877864
Ref: library/wsgiref wsgiref handlers BaseHandler origin_server12878520
Ref: 381912878520
Ref: library/wsgiref wsgiref handlers BaseHandler http_version12879133
Ref: 382412879133
Ref: library/wsgiref wsgiref handlers read_environ12879415
Ref: 118912879415
Ref: wsgiref handlers -- サーバ／ゲートウェイのベースクラス-Footnote-112880324
Ref: wsgiref handlers -- サーバ／ゲートウェイのベースクラス-Footnote-212880366
Ref: wsgiref handlers -- サーバ／ゲートウェイのベースクラス-Footnote-312880408
Ref: wsgiref handlers -- サーバ／ゲートウェイのベースクラス-Footnote-412880450
Ref: wsgiref handlers -- サーバ／ゲートウェイのベースクラス-Footnote-512880492
Node: wsgiref types -- WSGI types for static type checking12880534
Ref: library/wsgiref module-wsgiref types12880790
Ref: 10412880790
Ref: library/wsgiref wsgiref-types-wsgi-types-for-static-type-checking12880790
Ref: 382512880790
Ref: library/wsgiref wsgiref types StartResponse12881035
Ref: 382612881035
Ref: library/wsgiref wsgiref types WSGIEnvironment12881177
Ref: 37f012881177
Ref: library/wsgiref wsgiref types WSGIApplication12881284
Ref: 382712881284
Ref: library/wsgiref wsgiref types InputStream12881389
Ref: 381212881389
Ref: library/wsgiref wsgiref types ErrorStream12881502
Ref: 381312881502
Ref: library/wsgiref wsgiref types FileWrapper12881615
Ref: 37f612881615
Ref: wsgiref types -- WSGI types for static type checking-Footnote-112881859
Ref: wsgiref types -- WSGI types for static type checking-Footnote-212881901
Ref: wsgiref types -- WSGI types for static type checking-Footnote-312881971
Ref: wsgiref types -- WSGI types for static type checking-Footnote-412882013
Ref: wsgiref types -- WSGI types for static type checking-Footnote-512882079
Ref: wsgiref types -- WSGI types for static type checking-Footnote-612882145
Node: 使用例<35>12882229
Ref: library/wsgiref examples12882405
Ref: 382812882405
Node: urllib --- URL を扱うモジュール群12885163
Ref: library/urllib doc12885444
Ref: 382912885444
Ref: library/urllib module-urllib12885444
Ref: f112885444
Ref: library/urllib urllib-url-handling-modules12885444
Ref: 382a12885444
Ref: urllib --- URL を扱うモジュール群-Footnote-112886189
Node: urllib request --- URL を開くための大規模なライブラリ12886253
Ref: library/urllib request doc12886535
Ref: 382b12886535
Ref: library/urllib request module-urllib request12886535
Ref: f412886535
Ref: library/urllib request urllib-request-extensible-library-for-opening-urls12886535
Ref: 382c12886535
Ref: library/urllib request urllib request urlopen12887834
Ref: 27312887834
Ref: library/urllib request urllib request install_opener12892302
Ref: 383312892302
Ref: library/urllib request urllib request build_opener12893046
Ref: 383412893046
Ref: library/urllib request urllib request pathname2url12894455
Ref: 150012894455
Ref: library/urllib request urllib request url2pathname12894818
Ref: 14fe12894818
Ref: library/urllib request urllib request getproxies12895143
Ref: 382d12895143
Ref: library/urllib request urllib request Request12896621
Ref: fa512896621
Ref: library/urllib request urllib request OpenerDirector12902139
Ref: 383112902139
Ref: library/urllib request urllib request BaseHandler12902470
Ref: 383512902470
Ref: library/urllib request urllib request HTTPDefaultErrorHandler12902739
Ref: 383712902739
Ref: library/urllib request urllib request HTTPRedirectHandler12902984
Ref: 383812902984
Ref: library/urllib request urllib request HTTPCookieProcessor12903093
Ref: 383d12903093
Ref: library/urllib request urllib request ProxyHandler12903216
Ref: 193b12903216
Ref: library/urllib request urllib request HTTPPasswordMgr12904695
Ref: 383e12904695
Ref: library/urllib request urllib request HTTPPasswordMgrWithDefaultRealm12904848
Ref: 383f12904848
Ref: library/urllib request urllib request HTTPPasswordMgrWithPriorAuth12905149
Ref: e5d12905149
Ref: library/urllib request urllib request AbstractBasicAuthHandler12905598
Ref: 182612905598
Ref: library/urllib request urllib request HTTPBasicAuthHandler12907281
Ref: 384212907281
Ref: library/urllib request urllib request ProxyBasicAuthHandler12907878
Ref: 384312907878
Ref: library/urllib request urllib request AbstractDigestAuthHandler12908346
Ref: 18ed12908346
Ref: library/urllib request urllib request HTTPDigestAuthHandler12908937
Ref: 384412908937
Ref: library/urllib request urllib request ProxyDigestAuthHandler12909966
Ref: 384512909966
Ref: library/urllib request urllib request HTTPHandler12910435
Ref: 383612910435
Ref: library/urllib request urllib request HTTPSHandler12910516
Ref: 11f512910516
Ref: library/urllib request urllib request FileHandler12910886
Ref: 383a12910886
Ref: library/urllib request urllib request DataHandler12910978
Ref: fa412910978
Ref: library/urllib request urllib request FTPHandler12911083
Ref: 383912911083
Ref: library/urllib request urllib request CacheFTPHandler12911162
Ref: 168f12911162
Ref: library/urllib request urllib request UnknownHandler12911368
Ref: 383212911368
Ref: library/urllib request urllib request HTTPErrorProcessor12911513
Ref: 383b12911513
Ref: urllib request --- URL を開くための大規模なライブラリ-Footnote-112912683
Ref: urllib request --- URL を開くための大規模なライブラリ-Footnote-212912757
Ref: urllib request --- URL を開くための大規模なライブラリ-Footnote-312912808
Ref: urllib request --- URL を開くための大規模なライブラリ-Footnote-412912867
Ref: urllib request --- URL を開くための大規模なライブラリ-Footnote-512912926
Node: Request オブジェクト12912985
Ref: library/urllib request id112913158
Ref: 384612913158
Ref: library/urllib request request-objects12913158
Ref: 384712913158
Ref: library/urllib request urllib request Request full_url12913554
Ref: fa712913554
Ref: library/urllib request urllib request Request type12913930
Ref: 384812913930
Ref: library/urllib request urllib request Request host12913991
Ref: 384912913991
Ref: library/urllib request urllib request Request origin_req_host12914178
Ref: 384a12914178
Ref: library/urllib request urllib request Request selector12914321
Ref: 384b12914321
Ref: library/urllib request urllib request Request data12914522
Ref: fa812914522
Ref: library/urllib request urllib request Request unverifiable12914933
Ref: 384c12914933
Ref: library/urllib request urllib request Request method12915108
Ref: fa612915108
Ref: library/urllib request urllib request Request get_method12915967
Ref: 113c12915967
Ref: library/urllib request urllib request Request add_header12916538
Ref: 383c12916538
Ref: library/urllib request urllib request Request add_unredirected_header12917575
Ref: 384d12917575
Ref: library/urllib request urllib request Request has_header12917746
Ref: 384e12917746
Ref: library/urllib request urllib request Request remove_header12917969
Ref: faa12917969
Ref: library/urllib request urllib request Request get_full_url12918217
Ref: 384f12918217
Ref: library/urllib request urllib request Request set_proxy12918420
Ref: 385012918420
Ref: library/urllib request urllib request Request get_header12918772
Ref: 385112918772
Ref: library/urllib request urllib request Request header_items12918969
Ref: 385212918969
Ref: Request オブジェクト-Footnote-112919401
Node: OpenerDirector オブジェクト12919460
Ref: library/urllib request opener-director-objects12919672
Ref: 385312919672
Ref: library/urllib request openerdirector-objects12919672
Ref: 385412919672
Ref: library/urllib request urllib request OpenerDirector add_handler12919847
Ref: 385512919847
Ref: library/urllib request urllib request OpenerDirector open12921482
Ref: fa912921482
Ref: library/urllib request urllib request OpenerDirector error12922396
Ref: 385a12922396
Node: BaseHandler オブジェクト12924385
Ref: library/urllib request base-handler-objects12924609
Ref: 385d12924609
Ref: library/urllib request basehandler-objects12924609
Ref: 385e12924609
Ref: library/urllib request urllib request BaseHandler add_parent12924943
Ref: 385f12924943
Ref: library/urllib request urllib request BaseHandler close12925073
Ref: 386012925073
Ref: library/urllib request urllib request BaseHandler parent12925505
Ref: 386112925505
Ref: library/urllib request urllib request BaseHandler default_open12925716
Ref: 385b12925716
Ref: library/urllib request protocol-open12926560
Ref: 385612926560
Ref: library/urllib request urllib request BaseHandler unknown_open12927004
Ref: 385c12927004
Ref: library/urllib request urllib request BaseHandler http_error_default12927571
Ref: 386212927571
Ref: library/urllib request http-error-nnn12928658
Ref: 385712928658
Ref: library/urllib request protocol-request12929380
Ref: 385812929380
Ref: library/urllib request protocol-response12929994
Ref: 385912929994
Node: HTTPRedirectHandler オブジェクト12930840
Ref: library/urllib request http-redirect-handler12931069
Ref: 386312931069
Ref: library/urllib request httpredirecthandler-objects12931069
Ref: 386412931069
Ref: library/urllib request urllib request HTTPRedirectHandler redirect_request12931694
Ref: 386512931694
Ref: library/urllib request urllib request HTTPRedirectHandler http_error_30112932971
Ref: 386612932971
Ref: library/urllib request urllib request HTTPRedirectHandler http_error_30212933343
Ref: 386712933343
Ref: library/urllib request urllib request HTTPRedirectHandler http_error_30312933557
Ref: 386812933557
Ref: library/urllib request urllib request HTTPRedirectHandler http_error_30712933775
Ref: 386912933775
Ref: library/urllib request urllib request HTTPRedirectHandler http_error_30812934051
Ref: 386a12934051
Ref: HTTPRedirectHandler オブジェクト-Footnote-112934392
Ref: HTTPRedirectHandler オブジェクト-Footnote-212934451
Ref: HTTPRedirectHandler オブジェクト-Footnote-312934510
Node: HTTPCookieProcessor オブジェクト12934569
Ref: library/urllib request http-cookie-processor12934799
Ref: 386b12934799
Ref: library/urllib request httpcookieprocessor-objects12934799
Ref: 386c12934799
Ref: library/urllib request urllib request HTTPCookieProcessor cookiejar12934983
Ref: 386d12934983
Node: ProxyHandler オブジェクト12935133
Ref: library/urllib request proxy-handler12935359
Ref: 386f12935359
Ref: library/urllib request proxyhandler-objects12935359
Ref: 387012935359
Node: HTTPPasswordMgr オブジェクト12935859
Ref: library/urllib request http-password-mgr12936094
Ref: 384012936094
Ref: library/urllib request httppasswordmgr-objects12936094
Ref: 387112936094
Ref: library/urllib request urllib request HTTPPasswordMgr add_password12936330
Ref: 387212936330
Ref: library/urllib request urllib request HTTPPasswordMgr find_user_password12936790
Ref: 17aa12936790
Node: HTTPPasswordMgrWithPriorAuth オブジェクト12937372
Ref: library/urllib request http-password-mgr-with-prior-auth12937619
Ref: 384112937619
Ref: library/urllib request httppasswordmgrwithpriorauth-objects12937619
Ref: 387312937619
Ref: library/urllib request urllib request HTTPPasswordMgrWithPriorAuth add_password12937947
Ref: 387412937947
Ref: library/urllib request urllib request HTTPPasswordMgrWithPriorAuth find_user_password12938443
Ref: 387512938443
Ref: library/urllib request urllib request HTTPPasswordMgrWithPriorAuth update_authenticated12938664
Ref: 387612938664
Ref: library/urllib request urllib request HTTPPasswordMgrWithPriorAuth is_authenticated12938891
Ref: 17ab12938891
Node: AbstractBasicAuthHandler オブジェクト12939081
Ref: library/urllib request abstract-basic-auth-handler12939333
Ref: 387712939333
Ref: library/urllib request abstractbasicauthhandler-objects12939333
Ref: 387812939333
Ref: library/urllib request urllib request AbstractBasicAuthHandler http_error_auth_reqed12939434
Ref: 387912939434
Node: HTTPBasicAuthHandler オブジェクト12940495
Ref: library/urllib request http-basic-auth-handler12940740
Ref: 387a12940740
Ref: library/urllib request httpbasicauthhandler-objects12940740
Ref: 387b12940740
Ref: library/urllib request urllib request HTTPBasicAuthHandler http_error_40112940835
Ref: 387c12940835
Node: ProxyBasicAuthHandler オブジェクト12941024
Ref: library/urllib request proxy-basic-auth-handler12941270
Ref: 387d12941270
Ref: library/urllib request proxybasicauthhandler-objects12941270
Ref: 387e12941270
Ref: library/urllib request urllib request ProxyBasicAuthHandler http_error_40712941367
Ref: 387f12941367
Node: AbstractDigestAuthHandler オブジェクト12941557
Ref: library/urllib request abstract-digest-auth-handler12941804
Ref: 388012941804
Ref: library/urllib request abstractdigestauthhandler-objects12941804
Ref: 388112941804
Ref: library/urllib request urllib request AbstractDigestAuthHandler http_error_auth_reqed12941909
Ref: 388212941909
Node: HTTPDigestAuthHandler オブジェクト12942347
Ref: library/urllib request http-digest-auth-handler12942595
Ref: 388312942595
Ref: library/urllib request httpdigestauthhandler-objects12942595
Ref: 388412942595
Ref: library/urllib request urllib request HTTPDigestAuthHandler http_error_40112942692
Ref: 388512942692
Node: ProxyDigestAuthHandler オブジェクト12942882
Ref: library/urllib request proxy-digest-auth-handler12943116
Ref: 388612943116
Ref: library/urllib request proxydigestauthhandler-objects12943116
Ref: 388712943116
Ref: library/urllib request urllib request ProxyDigestAuthHandler http_error_40712943215
Ref: 388812943215
Node: HTTPHandler オブジェクト12943406
Ref: library/urllib request http-handler-objects12943631
Ref: 388912943631
Ref: library/urllib request httphandler-objects12943631
Ref: 388a12943631
Ref: library/urllib request urllib request HTTPHandler http_open12943708
Ref: 388b12943708
Node: HTTPSHandler オブジェクト12943910
Ref: library/urllib request https-handler-objects12944124
Ref: 388c12944124
Ref: library/urllib request httpshandler-objects12944124
Ref: 388d12944124
Ref: library/urllib request urllib request HTTPSHandler https_open12944203
Ref: 388e12944203
Node: FileHandler オブジェクト12944408
Ref: library/urllib request file-handler-objects12944622
Ref: 388f12944622
Ref: library/urllib request filehandler-objects12944622
Ref: 389012944622
Ref: library/urllib request urllib request FileHandler file_open12944699
Ref: 389112944699
Node: DataHandler オブジェクト12945066
Ref: library/urllib request data-handler-objects12945278
Ref: 389212945278
Ref: library/urllib request datahandler-objects12945278
Ref: 389312945278
Ref: library/urllib request urllib request DataHandler data_open12945355
Ref: 389412945355
Ref: DataHandler オブジェクト-Footnote-112945917
Node: FTPHandler オブジェクト12945976
Ref: library/urllib request ftp-handler-objects12946192
Ref: 389512946192
Ref: library/urllib request ftphandler-objects12946192
Ref: 389612946192
Ref: library/urllib request urllib request FTPHandler ftp_open12946267
Ref: 389712946267
Node: CacheFTPHandler オブジェクト12946489
Ref: library/urllib request cacheftp-handler-objects12946708
Ref: 389812946708
Ref: library/urllib request cacheftphandler-objects12946708
Ref: 389912946708
Ref: library/urllib request urllib request CacheFTPHandler setTimeout12946941
Ref: 389a12946941
Ref: library/urllib request urllib request CacheFTPHandler setMaxConns12947057
Ref: 389b12947057
Node: UnknownHandler オブジェクト12947189
Ref: library/urllib request unknown-handler-objects12947416
Ref: 389c12947416
Ref: library/urllib request unknownhandler-objects12947416
Ref: 389d12947416
Ref: library/urllib request urllib request UnknownHandler unknown_open12947499
Ref: 389e12947499
Node: HTTPErrorProcessor オブジェクト12947605
Ref: library/urllib request http-error-processor-objects12947811
Ref: 389f12947811
Ref: library/urllib request httperrorprocessor-objects12947811
Ref: 38a012947811
Ref: library/urllib request urllib request HTTPErrorProcessor http_response12947902
Ref: 38a112947902
Ref: library/urllib request urllib request HTTPErrorProcessor https_response12948423
Ref: 38a212948423
Node: 使用例<36>12948618
Ref: library/urllib request examples12948827
Ref: 38a312948827
Ref: library/urllib request urllib-request-examples12948827
Ref: 38a412948827
Ref: library/urllib request urllib-examples12955152
Ref: 38a612955152
Node: レガシーインターフェース12956884
Ref: library/urllib request legacy-interface12957086
Ref: 38a712957086
Ref: library/urllib request urllib request urlretrieve12957390
Ref: 38a812957390
Ref: library/urllib request urllib request urlcleanup12960276
Ref: 194212960276
Ref: library/urllib request urllib request URLopener12960476
Ref: 2e612960476
Ref: library/urllib request urllib request URLopener open12962523
Ref: 38ab12962523
Ref: library/urllib request urllib request URLopener open_unknown12963140
Ref: 38ac12963140
Ref: library/urllib request urllib request URLopener retrieve12963328
Ref: 195912963328
Ref: library/urllib request urllib request URLopener version12965312
Ref: 38aa12965312
Ref: library/urllib request urllib request FancyURLopener12965789
Ref: 2e712965789
Ref: library/urllib request urllib request FancyURLopener prompt_user_passwd12968092
Ref: 38ad12968092
Ref: レガシーインターフェース-Footnote-112968846
Node: urllib request の制限事項12968905
Ref: library/urllib request urllib-request-restrictions12969085
Ref: 38ae12969085
Node: urllib response --- urllib で使用するレスポンスクラス12972590
Ref: library/urllib request module-urllib response12972881
Ref: f512972881
Ref: library/urllib request urllib-response-response-classes-used-by-urllib12972881
Ref: 38af12972881
Ref: library/urllib request urllib response addinfourl12973483
Ref: 382e12973483
Ref: library/urllib request urllib response addinfourl url12973526
Ref: 38b012973526
Ref: library/urllib request urllib response addinfourl headers12973704
Ref: 38b112973704
Ref: library/urllib request urllib response addinfourl status12973843
Ref: 38b212973843
Ref: library/urllib request urllib response addinfourl geturl12973967
Ref: 38b312973967
Ref: library/urllib request urllib response addinfourl info12974133
Ref: 38b412974133
Ref: library/urllib request urllib response addinfourl code12974300
Ref: 38b512974300
Ref: library/urllib request urllib response addinfourl getcode12974460
Ref: 38b612974460
Node: urllib parse --- URL を構成要素に解析する12974629
Ref: library/urllib parse doc12974926
Ref: 38b712974926
Ref: library/urllib parse module-urllib parse12974926
Ref: f312974926
Ref: library/urllib parse urllib-parse-parse-urls-into-components12974926
Ref: 38b812974926
Ref: urllib parse --- URL を構成要素に解析する-Footnote-112977140
Ref: urllib parse --- URL を構成要素に解析する-Footnote-212977212
Ref: urllib parse --- URL を構成要素に解析する-Footnote-312977271
Node: URL の解析12977330
Ref: library/urllib parse url-parsing12977460
Ref: 38b912977460
Ref: library/urllib parse urllib parse urlparse12977669
Ref: 2e512977669
Ref: library/urllib parse urllib parse parse_qs12986358
Ref: 25b12986358
Ref: library/urllib parse urllib parse parse_qsl12989012
Ref: 25a12989012
Ref: library/urllib parse urllib parse urlunparse12991508
Ref: 153a12991508
Ref: library/urllib parse urllib parse urlsplit12992008
Ref: d0d12992008
Ref: library/urllib parse urllib parse urlunsplit12997063
Ref: 153912997063
Ref: library/urllib parse urllib parse urljoin12997626
Ref: e5f12997626
Ref: library/urllib parse urllib parse urldefrag12999149
Ref: 121912999149
Ref: library/urllib parse urllib parse unwrap13000795
Ref: 38bc13000795
Ref: URL の解析-Footnote-113001144
Ref: URL の解析-Footnote-213001203
Ref: URL の解析-Footnote-313001262
Ref: URL の解析-Footnote-413001321
Ref: URL の解析-Footnote-513001383
Node: URL parsing security13001442
Ref: library/urllib parse id113001623
Ref: 38bd13001623
Ref: library/urllib parse url-parsing-security13001623
Ref: 38bb13001623
Ref: URL parsing security-Footnote-113003081
Ref: URL parsing security-Footnote-213003143
Node: ASCII エンコードバイト列の解析13003202
Ref: library/urllib parse id213003400
Ref: 38be13003400
Ref: library/urllib parse parsing-ascii-encoded-bytes13003400
Ref: 121b13003400
Node: 構造化された解析結果13006000
Ref: library/urllib parse structured-parse-results13006197
Ref: 38bf13006197
Ref: library/urllib parse urlparse-result-object13006197
Ref: 38ba13006197
Ref: library/urllib parse urllib parse urllib parse SplitResult geturl13006657
Ref: 38c013006657
Ref: library/urllib parse urllib parse DefragResult13007959
Ref: 38c113007959
Ref: library/urllib parse urllib parse ParseResult13008266
Ref: 38c313008266
Ref: library/urllib parse urllib parse SplitResult13008583
Ref: 38c513008583
Ref: library/urllib parse urllib parse DefragResultBytes13009046
Ref: 38c213009046
Ref: library/urllib parse urllib parse ParseResultBytes13009356
Ref: 38c413009356
Ref: library/urllib parse urllib parse SplitResultBytes13009695
Ref: 38c613009695
Node: URL のクオート13010035
Ref: library/urllib parse url-quoting13010181
Ref: 38c713010181
Ref: library/urllib parse urllib parse quote13010632
Ref: b7113010632
Ref: library/urllib parse urllib parse quote_plus13012178
Ref: 121a13012178
Ref: library/urllib parse urllib parse quote_from_bytes13012689
Ref: 173013012689
Ref: library/urllib parse urllib parse unquote13013045
Ref: 16f113013045
Ref: library/urllib parse urllib parse unquote_plus13013921
Ref: 38c813013921
Ref: library/urllib parse urllib parse unquote_to_bytes13014333
Ref: 16f213014333
Ref: library/urllib parse urllib parse urlencode13014861
Ref: e5e13014861
Ref: URL のクオート-Footnote-113019703
Ref: URL のクオート-Footnote-213019762
Ref: URL のクオート-Footnote-313019821
Ref: URL のクオート-Footnote-413019858
Ref: URL のクオート-Footnote-513019917
Ref: URL のクオート-Footnote-613019976
Ref: URL のクオート-Footnote-713020035
Ref: URL のクオート-Footnote-813020094
Ref: URL のクオート-Footnote-913020153
Node: urllib error --- urllib request によって送出される例外クラス13020212
Ref: library/urllib error doc13020495
Ref: 38c913020495
Ref: library/urllib error module-urllib error13020495
Ref: f213020495
Ref: library/urllib error urllib-error-exception-classes-raised-by-urllib-request13020495
Ref: 38ca13020495
Ref: library/urllib error urllib error URLError13021014
Ref: 383013021014
Ref: library/urllib error urllib error URLError reason13021269
Ref: 38cb13021269
Ref: library/urllib error urllib error HTTPError13021620
Ref: fab13021620
Ref: library/urllib error urllib error HTTPError url13022079
Ref: 38cc13022079
Ref: library/urllib error urllib error HTTPError code13022199
Ref: 38cd13022199
Ref: library/urllib error urllib error HTTPError reason13022475
Ref: 38cf13022475
Ref: library/urllib error urllib error HTTPError headers13022641
Ref: fac13022641
Ref: library/urllib error urllib error HTTPError fp13022867
Ref: 38d013022867
Ref: library/urllib error urllib error ContentTooShortError13023003
Ref: 38a913023003
Ref: library/urllib error urllib error ContentTooShortError content13023310
Ref: 38d113023310
Ref: urllib error --- urllib request によって送出される例外クラス-Footnote-113023466
Ref: urllib error --- urllib request によって送出される例外クラス-Footnote-213023538
Node: urllib robotparser --- robots txt 用のパーサー13023597
Ref: library/urllib robotparser doc13023861
Ref: 38d213023861
Ref: library/urllib robotparser module-urllib robotparser13023861
Ref: f613023861
Ref: library/urllib robotparser urllib-robotparser-parser-for-robots-txt13023861
Ref: 38d313023861
Ref: library/urllib robotparser urllib robotparser RobotFileParser13024529
Ref: ccb13024529
Ref: library/urllib robotparser urllib robotparser RobotFileParser set_url13024710
Ref: 38d413024710
Ref: library/urllib robotparser urllib robotparser RobotFileParser read13024839
Ref: 38d513024839
Ref: library/urllib robotparser urllib robotparser RobotFileParser parse13024952
Ref: 1a0d13024952
Ref: library/urllib robotparser urllib robotparser RobotFileParser can_fetch13025047
Ref: 38d613025047
Ref: library/urllib robotparser urllib robotparser RobotFileParser mtime13025314
Ref: 38d713025314
Ref: library/urllib robotparser urllib robotparser RobotFileParser modified13025643
Ref: 38d813025643
Ref: library/urllib robotparser urllib robotparser RobotFileParser crawl_delay13025800
Ref: 38d913025800
Ref: library/urllib robotparser urllib robotparser RobotFileParser request_rate13026335
Ref: 38da13026335
Ref: library/urllib robotparser urllib robotparser RobotFileParser site_maps13026907
Ref: 19ac13026907
Ref: urllib robotparser --- robots txt 用のパーサー-Footnote-113027891
Node: http --- HTTP モジュール群13027970
Ref: library/http doc13028214
Ref: 38db13028214
Ref: library/http http-http-modules13028214
Ref: 38dc13028214
Ref: library/http module-http13028214
Ref: 6413028214
Ref: library/http http HTTPStatus13029245
Ref: 8ce13029245
Ref: http --- HTTP モジュール群-Footnote-113030075
Node: HTTP ステータスコード13030148
Ref: library/http http-status-codes13030296
Ref: 38dd13030296
Ref: library/http id113030296
Ref: 38de13030296
Ref: HTTP ステータスコード-Footnote-113044686
Ref: HTTP ステータスコード-Footnote-213044770
Ref: HTTP ステータスコード-Footnote-313044829
Ref: HTTP ステータスコード-Footnote-413044888
Ref: HTTP ステータスコード-Footnote-513044947
Ref: HTTP ステータスコード-Footnote-613045006
Ref: HTTP ステータスコード-Footnote-713045065
Ref: HTTP ステータスコード-Footnote-813045124
Ref: HTTP ステータスコード-Footnote-913045183
Ref: HTTP ステータスコード-Footnote-1013045242
Ref: HTTP ステータスコード-Footnote-1113045302
Ref: HTTP ステータスコード-Footnote-1213045362
Ref: HTTP ステータスコード-Footnote-1313045422
Ref: HTTP ステータスコード-Footnote-1413045482
Ref: HTTP ステータスコード-Footnote-1513045542
Ref: HTTP ステータスコード-Footnote-1613045602
Ref: HTTP ステータスコード-Footnote-1713045662
Ref: HTTP ステータスコード-Footnote-1813045722
Ref: HTTP ステータスコード-Footnote-1913045782
Ref: HTTP ステータスコード-Footnote-2013045842
Ref: HTTP ステータスコード-Footnote-2113045902
Ref: HTTP ステータスコード-Footnote-2213045962
Ref: HTTP ステータスコード-Footnote-2313046022
Ref: HTTP ステータスコード-Footnote-2413046082
Ref: HTTP ステータスコード-Footnote-2513046142
Ref: HTTP ステータスコード-Footnote-2613046202
Ref: HTTP ステータスコード-Footnote-2713046262
Ref: HTTP ステータスコード-Footnote-2813046322
Ref: HTTP ステータスコード-Footnote-2913046382
Ref: HTTP ステータスコード-Footnote-3013046442
Ref: HTTP ステータスコード-Footnote-3113046502
Ref: HTTP ステータスコード-Footnote-3213046562
Ref: HTTP ステータスコード-Footnote-3313046622
Ref: HTTP ステータスコード-Footnote-3413046682
Ref: HTTP ステータスコード-Footnote-3513046742
Ref: HTTP ステータスコード-Footnote-3613046802
Ref: HTTP ステータスコード-Footnote-3713046862
Ref: HTTP ステータスコード-Footnote-3813046922
Ref: HTTP ステータスコード-Footnote-3913046982
Ref: HTTP ステータスコード-Footnote-4013047042
Ref: HTTP ステータスコード-Footnote-4113047102
Ref: HTTP ステータスコード-Footnote-4213047162
Ref: HTTP ステータスコード-Footnote-4313047222
Ref: HTTP ステータスコード-Footnote-4413047282
Ref: HTTP ステータスコード-Footnote-4513047342
Ref: HTTP ステータスコード-Footnote-4613047402
Ref: HTTP ステータスコード-Footnote-4713047462
Ref: HTTP ステータスコード-Footnote-4813047522
Ref: HTTP ステータスコード-Footnote-4913047582
Ref: HTTP ステータスコード-Footnote-5013047642
Ref: HTTP ステータスコード-Footnote-5113047702
Ref: HTTP ステータスコード-Footnote-5213047762
Ref: HTTP ステータスコード-Footnote-5313047822
Ref: HTTP ステータスコード-Footnote-5413047882
Ref: HTTP ステータスコード-Footnote-5513047942
Ref: HTTP ステータスコード-Footnote-5613048002
Ref: HTTP ステータスコード-Footnote-5713048062
Ref: HTTP ステータスコード-Footnote-5813048122
Ref: HTTP ステータスコード-Footnote-5913048182
Ref: HTTP ステータスコード-Footnote-6013048242
Ref: HTTP ステータスコード-Footnote-6113048302
Ref: HTTP ステータスコード-Footnote-6213048362
Ref: HTTP ステータスコード-Footnote-6313048422
Node: HTTP ステータスコードカテゴリ13048482
Ref: library/http http-status-category13048656
Ref: 38df13048656
Ref: library/http http HTTPMethod13050338
Ref: 38e013050338
Ref: HTTP ステータスコードカテゴリ-Footnote-113051189
Ref: HTTP ステータスコードカテゴリ-Footnote-213051248
Ref: HTTP ステータスコードカテゴリ-Footnote-313051307
Ref: HTTP ステータスコードカテゴリ-Footnote-413051366
Ref: HTTP ステータスコードカテゴリ-Footnote-513051425
Node: HTTP メソッド13051484
Ref: library/http http-methods13051620
Ref: 38e113051620
Ref: library/http id213051620
Ref: 38e213051620
Ref: HTTP メソッド-Footnote-113054049
Ref: HTTP メソッド-Footnote-213054122
Ref: HTTP メソッド-Footnote-313054181
Ref: HTTP メソッド-Footnote-413054240
Ref: HTTP メソッド-Footnote-513054299
Ref: HTTP メソッド-Footnote-613054358
Ref: HTTP メソッド-Footnote-713054417
Ref: HTTP メソッド-Footnote-813054476
Ref: HTTP メソッド-Footnote-913054535
Ref: HTTP メソッド-Footnote-1013054594
Node: http client --- HTTP プロトコルクライアント13054654
Ref: library/http client doc13054894
Ref: 38e313054894
Ref: library/http client http-client-http-protocol-client13054894
Ref: 38e413054894
Ref: library/http client module-http client13054894
Ref: 6513054894
Ref: library/http client http client HTTPConnection13056111
Ref: b0e13056111
Ref: library/http client http client HTTPSConnection13058191
Ref: b0f13058191
Ref: library/http client http client HTTPResponse13060363
Ref: 10a113060363
Ref: library/http client http client parse_headers13060905
Ref: 19b413060905
Ref: library/http client http client HTTPException13061868
Ref: 38e813061868
Ref: library/http client http client NotConnected13062050
Ref: 38e913062050
Ref: library/http client http client InvalidURL13062146
Ref: 38ea13062146
Ref: library/http client http client UnknownProtocol13062399
Ref: 38eb13062399
Ref: library/http client http client UnknownTransferEncoding13062498
Ref: 38ec13062498
Ref: library/http client http client UnimplementedFileMode13062605
Ref: 38ed13062605
Ref: library/http client http client IncompleteRead13062710
Ref: 38ee13062710
Ref: library/http client http client ImproperConnectionState13062808
Ref: 38ef13062808
Ref: library/http client http client CannotSendRequest13062915
Ref: 38f013062915
Ref: library/http client http client CannotSendHeader13063029
Ref: 38f113063029
Ref: library/http client http client ResponseNotReady13063142
Ref: 38f213063142
Ref: library/http client http client BadStatusLine13063255
Ref: 38f313063255
Ref: library/http client http client LineTooLong13063456
Ref: 38f413063456
Ref: library/http client http client RemoteDisconnected13063631
Ref: dd613063631
Ref: library/http client http client HTTP_PORT13064145
Ref: 38f513064145
Ref: library/http client http client HTTPS_PORT13064262
Ref: 38f613064262
Ref: library/http client http client responses13064382
Ref: 38f713064382
Ref: http client --- HTTP プロトコルクライアント-Footnote-113064965
Ref: http client --- HTTP プロトコルクライアント-Footnote-213065036
Ref: http client --- HTTP プロトコルクライアント-Footnote-313065087
Node: HTTPConnection オブジェクト13065146
Ref: library/http client httpconnection-objects13065310
Ref: 38f813065310
Ref: library/http client id113065310
Ref: 38f913065310
Ref: library/http client http client HTTPConnection request13065483
Ref: c7713065483
Ref: library/http client http client HTTPConnection getresponse13069112
Ref: dd513069112
Ref: library/http client http client HTTPConnection set_debuglevel13069761
Ref: 38fa13069761
Ref: library/http client http client HTTPConnection set_tunnel13070171
Ref: 11f913070171
Ref: library/http client http client HTTPConnection get_proxy_response_headers13071913
Ref: 166813071913
Ref: library/http client http client HTTPConnection connect13072200
Ref: 38fb13072200
Ref: library/http client http client HTTPConnection close13072562
Ref: 38fc13072562
Ref: library/http client http client HTTPConnection blocksize13072651
Ref: 38fd13072651
Ref: library/http client http client HTTPConnection putrequest13072943
Ref: 38fe13072943
Ref: library/http client http client HTTPConnection putheader13073624
Ref: 38ff13073624
Ref: library/http client http client HTTPConnection endheaders13074036
Ref: c7813074036
Ref: library/http client http client HTTPConnection send13075485
Ref: 390013075485
Ref: HTTPConnection オブジェクト-Footnote-113075912
Ref: HTTPConnection オブジェクト-Footnote-213075985
Ref: HTTPConnection オブジェクト-Footnote-313076058
Ref: HTTPConnection オブジェクト-Footnote-413076131
Ref: HTTPConnection オブジェクト-Footnote-513076199
Ref: HTTPConnection オブジェクト-Footnote-613076257
Node: HTTPResponse オブジェクト13076316
Ref: library/http client httpresponse-objects13076502
Ref: 390113076502
Ref: library/http client id213076502
Ref: 390213076502
Ref: library/http client http client HTTPResponse read13077075
Ref: 16b313077075
Ref: library/http client http client HTTPResponse readinto13077205
Ref: 10a213077205
Ref: library/http client http client HTTPResponse getheader13077442
Ref: 390313077442
Ref: library/http client http client HTTPResponse getheaders13077831
Ref: 390413077831
Ref: library/http client http client HTTPResponse fileno13077951
Ref: 390513077951
Ref: library/http client http client HTTPResponse msg13078047
Ref: 38e613078047
Ref: library/http client http client HTTPResponse version13078266
Ref: 390613078266
Ref: library/http client http client HTTPResponse url13078441
Ref: 390713078441
Ref: library/http client http client HTTPResponse headers13078617
Ref: 390813078617
Ref: library/http client http client HTTPResponse status13078756
Ref: 390913078756
Ref: library/http client http client HTTPResponse reason13078850
Ref: 382f13078850
Ref: library/http client http client HTTPResponse debuglevel13078947
Ref: 390a13078947
Ref: library/http client http client HTTPResponse closed13079142
Ref: 390b13079142
Ref: library/http client http client HTTPResponse geturl13079254
Ref: 390c13079254
Ref: library/http client http client HTTPResponse info13079418
Ref: 390d13079418
Ref: library/http client http client HTTPResponse getcode13079584
Ref: 390e13079584
Node: 使用例<37>13079752
Ref: library/http client examples13079935
Ref: 390f13079935
Node: HTTPMessage オブジェクト13082898
Ref: library/http client httpmessage-objects13083041
Ref: 391013083041
Ref: library/http client id313083041
Ref: 391113083041
Ref: library/http client http client HTTPMessage13083118
Ref: 38e513083118
Node: ftplib --- FTP プロトコルクライアント13083384
Ref: library/ftplib doc13083641
Ref: 391213083641
Ref: library/ftplib ftplib-ftp-protocol-client13083641
Ref: 391313083641
Ref: library/ftplib module-ftplib13083641
Ref: 5413083641
Ref: ftplib --- FTP プロトコルクライアント-Footnote-113085858
Ref: ftplib --- FTP プロトコルクライアント-Footnote-213085924
Ref: ftplib --- FTP プロトコルクライアント-Footnote-313085982
Node: リファレンス<5>13086041
Ref: library/ftplib ftplib-reference13086147
Ref: 391413086147
Ref: library/ftplib reference13086147
Ref: 391513086147
Node: FTP オブジェクト13086294
Ref: library/ftplib ftp-objects13086409
Ref: 391613086409
Ref: library/ftplib id113086409
Ref: 391713086409
Ref: library/ftplib ftplib FTP13086470
Ref: 8c813086470
Ref: library/ftplib ftplib FTP set_debuglevel13089442
Ref: 391913089442
Ref: library/ftplib ftplib FTP connect13090003
Ref: 391813090003
Ref: library/ftplib ftplib FTP getwelcome13091440
Ref: 391a13091440
Ref: library/ftplib ftplib FTP login13091749
Ref: 391b13091749
Ref: library/ftplib ftplib FTP abort13092793
Ref: 391c13092793
Ref: library/ftplib ftplib FTP sendcmd13093002
Ref: 391d13093002
Ref: library/ftplib ftplib FTP voidcmd13093309
Ref: 391e13093309
Ref: library/ftplib ftplib FTP retrbinary13093742
Ref: 392013093742
Ref: library/ftplib ftplib FTP retrlines13094804
Ref: 392213094804
Ref: library/ftplib ftplib FTP set_pasv13095547
Ref: 392313095547
Ref: library/ftplib ftplib FTP storbinary13095761
Ref: 12d813095761
Ref: library/ftplib ftplib FTP storlines13096942
Ref: 392413096942
Ref: library/ftplib ftplib FTP transfercmd13097446
Ref: 392113097446
Ref: library/ftplib ftplib FTP ntransfercmd13098751
Ref: 392513098751
Ref: library/ftplib ftplib FTP mlsd13099144
Ref: 109513099144
Ref: library/ftplib ftplib FTP nlst13099905
Ref: 109613099905
Ref: library/ftplib ftplib FTP dir13100449
Ref: 109713100449
Ref: library/ftplib ftplib FTP rename13101154
Ref: 392613101154
Ref: library/ftplib ftplib FTP delete13101318
Ref: 392713101318
Ref: library/ftplib ftplib FTP cwd13101664
Ref: 392913101664
Ref: library/ftplib ftplib FTP mkd13101778
Ref: 392a13101778
Ref: library/ftplib ftplib FTP pwd13101889
Ref: 392b13101889
Ref: library/ftplib ftplib FTP rmd13102004
Ref: 392c13102004
Ref: library/ftplib ftplib FTP size13102119
Ref: 392d13102119
Ref: library/ftplib ftplib FTP quit13102534
Ref: 392e13102534
Ref: library/ftplib ftplib FTP close13103087
Ref: 392f13103087
Ref: FTP オブジェクト-Footnote-113103703
Ref: FTP オブジェクト-Footnote-213103761
Ref: FTP オブジェクト-Footnote-313103820
Ref: FTP オブジェクト-Footnote-413103878
Node: FTP_TLS オブジェクト13103937
Ref: library/ftplib ftp-tls-objects13104082
Ref: 393013104082
Ref: library/ftplib ftplib FTP_TLS13104151
Ref: 8c913104151
Ref: library/ftplib ftplib FTP_TLS ssl_version13107953
Ref: 393213107953
Ref: library/ftplib ftplib FTP_TLS auth13108078
Ref: 393313108078
Ref: library/ftplib ftplib FTP_TLS ccc13108524
Ref: 109413108524
Ref: library/ftplib ftplib FTP_TLS prot_p13108789
Ref: 393113108789
Ref: library/ftplib ftplib FTP_TLS prot_c13108895
Ref: 393413108895
Ref: FTP_TLS オブジェクト-Footnote-113109031
Ref: FTP_TLS オブジェクト-Footnote-213109090
Ref: FTP_TLS オブジェクト-Footnote-313109148
Node: モジュール変数13109207
Ref: library/ftplib module-variables13109321
Ref: 393513109321
Ref: library/ftplib ftplib error_reply13109379
Ref: 391f13109379
Ref: library/ftplib ftplib error_temp13109496
Ref: 393613109496
Ref: library/ftplib ftplib error_perm13109666
Ref: 392813109666
Ref: library/ftplib ftplib error_proto13109833
Ref: 393713109833
Ref: library/ftplib ftplib all_errors13110054
Ref: 393813110054
Node: poplib --- POP3 プロトコルクライアント13110746
Ref: library/poplib doc13111000
Ref: 393913111000
Ref: library/poplib module-poplib13111000
Ref: 9a13111000
Ref: library/poplib poplib-pop3-protocol-client13111000
Ref: 393a13111000
Ref: library/poplib poplib POP313112794
Ref: 8f213112794
Ref: library/poplib poplib POP3_SSL13113954
Ref: 8f313113954
Ref: library/poplib poplib error_proto13115980
Ref: 116e13115980
Ref: poplib --- POP3 プロトコルクライアント-Footnote-113116768
Ref: poplib --- POP3 プロトコルクライアント-Footnote-213116834
Ref: poplib --- POP3 プロトコルクライアント-Footnote-313116893
Ref: poplib --- POP3 プロトコルクライアント-Footnote-413116952
Ref: poplib --- POP3 プロトコルクライアント-Footnote-513117011
Node: POP3 オブジェクト13117073
Ref: library/poplib id113117202
Ref: 393b13117202
Ref: library/poplib pop3-objects13117202
Ref: 393c13117202
Ref: library/poplib poplib POP3 set_debuglevel13117571
Ref: 393d13117571
Ref: library/poplib poplib POP3 getwelcome13118105
Ref: 393e13118105
Ref: library/poplib poplib POP3 capa13118238
Ref: f4913118238
Ref: library/poplib poplib POP3 user13118469
Ref: 393f13118469
Ref: library/poplib poplib POP3 pass_13118604
Ref: 394013118604
Ref: library/poplib poplib POP3 apop13118900
Ref: 394113118900
Ref: library/poplib poplib POP3 rpop13119055
Ref: 394213119055
Ref: library/poplib poplib POP3 stat13119220
Ref: 394313119220
Ref: library/poplib poplib POP3 list13119409
Ref: 394413119409
Ref: library/poplib poplib POP3 retr13119695
Ref: 394513119695
Ref: library/poplib poplib POP3 dele13119947
Ref: 394613119947
Ref: library/poplib poplib POP3 rset13120387
Ref: 394713120387
Ref: library/poplib poplib POP3 noop13120498
Ref: 394813120498
Ref: library/poplib poplib POP3 quit13120600
Ref: 116d13120600
Ref: library/poplib poplib POP3 top13120764
Ref: 394913120764
Ref: library/poplib poplib POP3 uidl13121560
Ref: 394a13121560
Ref: library/poplib poplib POP3 utf813121975
Ref: e1713121975
Ref: library/poplib poplib POP3 stls13122269
Ref: f4a13122269
Ref: POP3 オブジェクト-Footnote-113123355
Ref: POP3 オブジェクト-Footnote-213123414
Ref: POP3 オブジェクト-Footnote-313123473
Node: POP3 の例13123532
Ref: library/poplib id213123661
Ref: 394b13123661
Ref: library/poplib pop3-example13123661
Ref: 394c13123661
Node: imaplib --- IMAP4 プロトコルクライアント13124244
Ref: library/imaplib doc13124500
Ref: 394d13124500
Ref: library/imaplib imaplib-imap4-protocol-client13124500
Ref: 394e13124500
Ref: library/imaplib module-imaplib13124500
Ref: 6a13124500
Ref: library/imaplib imaplib IMAP413125639
Ref: 8d113125639
Ref: library/imaplib imaplib IMAP4 error13126911
Ref: 394f13126911
Ref: library/imaplib imaplib IMAP4 abort13127093
Ref: 395013127093
Ref: library/imaplib imaplib IMAP4 readonly13127429
Ref: 395113127429
Ref: library/imaplib imaplib IMAP4_SSL13127990
Ref: 8d213127990
Ref: library/imaplib imaplib IMAP4_stream13129609
Ref: 8d413129609
Ref: library/imaplib imaplib Internaldate2tuple13129926
Ref: 395213129926
Ref: library/imaplib imaplib Int2AP13130243
Ref: 395313130243
Ref: library/imaplib imaplib ParseFlags13130401
Ref: 395413130401
Ref: library/imaplib imaplib Time2Internaldate13130540
Ref: 395513130540
Ref: imaplib --- IMAP4 プロトコルクライアント-Footnote-113132061
Ref: imaplib --- IMAP4 プロトコルクライアント-Footnote-213132128
Ref: imaplib --- IMAP4 プロトコルクライアント-Footnote-313132187
Node: IMAP4 オブジェクト13132246
Ref: library/imaplib id113132385
Ref: 395613132385
Ref: library/imaplib imap4-objects13132385
Ref: 395713132385
Ref: library/imaplib imaplib IMAP4 append13134272
Ref: 395813134272
Ref: library/imaplib imaplib IMAP4 authenticate13134428
Ref: 395913134428
Ref: library/imaplib imaplib IMAP4 check13135380
Ref: 395a13135380
Ref: library/imaplib imaplib IMAP4 close13135505
Ref: 8d613135505
Ref: library/imaplib imaplib IMAP4 copy13135778
Ref: 395b13135778
Ref: library/imaplib imaplib IMAP4 create13135946
Ref: 395c13135946
Ref: library/imaplib imaplib IMAP4 delete13136077
Ref: 395d13136077
Ref: library/imaplib imaplib IMAP4 deleteacl13136205
Ref: 395e13136205
Ref: library/imaplib imaplib IMAP4 enable13136343
Ref: dda13136343
Ref: library/imaplib imaplib IMAP4 expunge13136668
Ref: 395f13136668
Ref: library/imaplib imaplib IMAP4 fetch13137046
Ref: 396013137046
Ref: library/imaplib imaplib IMAP4 getacl13137468
Ref: 396113137468
Ref: library/imaplib imaplib IMAP4 getannotation13137676
Ref: 396213137676
Ref: library/imaplib imaplib IMAP4 getquota13137916
Ref: 396313137916
Ref: library/imaplib imaplib IMAP4 getquotaroot13138153
Ref: 396413138153
Ref: library/imaplib imaplib IMAP4 list13138411
Ref: 396513138411
Ref: library/imaplib imaplib IMAP4 login13138802
Ref: 396613138802
Ref: library/imaplib imaplib IMAP4 login_cram_md513138976
Ref: 396713138976
Ref: library/imaplib imaplib IMAP4 logout13139271
Ref: 396813139271
Ref: library/imaplib imaplib IMAP4 lsub13139510
Ref: 396913139510
Ref: library/imaplib imaplib IMAP4 myrights13140022
Ref: 396a13140022
Ref: library/imaplib imaplib IMAP4 namespace13140198
Ref: 396b13140198
Ref: library/imaplib imaplib IMAP4 noop13140307
Ref: 396c13140307
Ref: library/imaplib imaplib IMAP4 open13140392
Ref: 8d313140392
Ref: library/imaplib imaplib IMAP4 partial13141383
Ref: 397113141383
Ref: library/imaplib imaplib IMAP4 proxyauth13141649
Ref: 397213141649
Ref: library/imaplib imaplib IMAP4 read13141876
Ref: 396d13141876
Ref: library/imaplib imaplib IMAP4 readline13142057
Ref: 396e13142057
Ref: library/imaplib imaplib IMAP4 recent13142227
Ref: 397313142227
Ref: library/imaplib imaplib IMAP4 rename13142448
Ref: 397413142448
Ref: library/imaplib imaplib IMAP4 response13142614
Ref: 397513142614
Ref: library/imaplib imaplib IMAP4 search13142872
Ref: 397613142872
Ref: library/imaplib imaplib IMAP4 select13143579
Ref: 397713143579
Ref: library/imaplib imaplib IMAP4 send13143960
Ref: 396f13143960
Ref: library/imaplib imaplib IMAP4 setacl13144263
Ref: 397813144263
Ref: library/imaplib imaplib IMAP4 setannotation13144473
Ref: 397913144473
Ref: library/imaplib imaplib IMAP4 setquota13144711
Ref: 397a13144711
Ref: library/imaplib imaplib IMAP4 shutdown13144935
Ref: 397013144935
Ref: library/imaplib imaplib IMAP4 socket13145199
Ref: 397b13145199
Ref: library/imaplib imaplib IMAP4 sort13145331
Ref: 397c13145331
Ref: library/imaplib imaplib IMAP4 starttls13146409
Ref: 11f713146409
Ref: library/imaplib imaplib IMAP4 status13146967
Ref: 397d13146967
Ref: library/imaplib imaplib IMAP4 store13147096
Ref: 397e13147096
Ref: library/imaplib imaplib IMAP4 subscribe13148473
Ref: 397f13148473
Ref: library/imaplib imaplib IMAP4 thread13148589
Ref: 398013148589
Ref: library/imaplib imaplib IMAP4 uid13149784
Ref: 398113149784
Ref: library/imaplib imaplib IMAP4 unsubscribe13150189
Ref: 398213150189
Ref: library/imaplib imaplib IMAP4 unselect13150315
Ref: 8d513150315
Ref: library/imaplib imaplib IMAP4 xatom13150718
Ref: 398313150718
Ref: library/imaplib imaplib IMAP4 PROTOCOL_VERSION13150974
Ref: 398413150974
Ref: library/imaplib imaplib IMAP4 debug13151149
Ref: 398513151149
Ref: library/imaplib imaplib IMAP4 utf8_enabled13151381
Ref: ddb13151381
Ref: IMAP4 オブジェクト-Footnote-113151661
Ref: IMAP4 オブジェクト-Footnote-213151720
Ref: IMAP4 オブジェクト-Footnote-313151779
Ref: IMAP4 オブジェクト-Footnote-413151838
Ref: IMAP4 オブジェクト-Footnote-513151897
Ref: IMAP4 オブジェクト-Footnote-613151956
Ref: IMAP4 オブジェクト-Footnote-713152015
Ref: IMAP4 オブジェクト-Footnote-813152074
Ref: IMAP4 オブジェクト-Footnote-913152133
Node: IMAP4 の使用例13152192
Ref: library/imaplib id213152331
Ref: 398613152331
Ref: library/imaplib imap4-example13152331
Ref: 398713152331
Node: smtplib --- SMTP プロトコルクライアント13152898
Ref: library/smtplib doc13153159
Ref: 398813153159
Ref: library/smtplib module-smtplib13153159
Ref: b713153159
Ref: library/smtplib smtplib-smtp-protocol-client13153159
Ref: 398913153159
Ref: library/smtplib smtplib SMTP13154053
Ref: 8fb13154053
Ref: library/smtplib smtplib SMTP_SSL13157310
Ref: 8fc13157310
Ref: library/smtplib smtplib LMTP13159080
Ref: 8fd13159080
Ref: library/smtplib smtplib SMTPException13160145
Ref: f6d13160145
Ref: library/smtplib smtplib SMTPServerDisconnected13160442
Ref: 398c13160442
Ref: library/smtplib smtplib SMTPResponseException13160672
Ref: 398d13160672
Ref: library/smtplib smtplib SMTPSenderRefused13161052
Ref: 398e13161052
Ref: library/smtplib smtplib SMTPRecipientsRefused13161331
Ref: 398f13161331
Ref: library/smtplib smtplib SMTPDataError13161655
Ref: 399013161655
Ref: library/smtplib smtplib SMTPConnectError13161827
Ref: 398a13161827
Ref: library/smtplib smtplib SMTPHeloError13161962
Ref: 399113161962
Ref: library/smtplib smtplib SMTPNotSupportedError13162097
Ref: 193413162097
Ref: library/smtplib smtplib SMTPAuthenticationError13162268
Ref: 399213162268
Ref: smtplib --- SMTP プロトコルクライアント-Footnote-113163161
Ref: smtplib --- SMTP プロトコルクライアント-Footnote-213163228
Ref: smtplib --- SMTP プロトコルクライアント-Footnote-313163286
Ref: smtplib --- SMTP プロトコルクライアント-Footnote-413163345
Ref: smtplib --- SMTP プロトコルクライアント-Footnote-513163404
Ref: smtplib --- SMTP プロトコルクライアント-Footnote-613163462
Node: SMTP オブジェクト13163521
Ref: library/smtplib id113163654
Ref: 399313163654
Ref: library/smtplib smtp-objects13163654
Ref: 399413163654
Ref: library/smtplib smtplib SMTP set_debuglevel13163803
Ref: e2113163803
Ref: library/smtplib smtplib SMTP docmd13164254
Ref: 399513164254
Ref: library/smtplib smtplib SMTP connect13165198
Ref: 193513165198
Ref: library/smtplib smtplib SMTP helo13166033
Ref: 399613166033
Ref: library/smtplib smtplib SMTP ehlo13166478
Ref: 399713166478
Ref: library/smtplib smtplib SMTP ehlo_or_helo_if_needed13167519
Ref: 399913167519
Ref: library/smtplib smtplib SMTP has_extn13167986
Ref: 399813167986
Ref: library/smtplib smtplib SMTP verify13168245
Ref: 399a13168245
Ref: library/smtplib smtplib SMTP login13168772
Ref: 399b13168772
Ref: library/smtplib smtplib SMTP auth13170606
Ref: e2013170606
Ref: library/smtplib smtplib SMTP starttls13172851
Ref: 110b13172851
Ref: library/smtplib smtplib SMTP sendmail13174534
Ref: e2213174534
Ref: library/smtplib smtplib SMTP send_message13178736
Ref: e2313178736
Ref: library/smtplib smtplib SMTP quit13180809
Ref: 398b13180809
Ref: SMTP オブジェクト-Footnote-113181341
Ref: SMTP オブジェクト-Footnote-213181399
Ref: SMTP オブジェクト-Footnote-313181458
Ref: SMTP オブジェクト-Footnote-413181517
Ref: SMTP オブジェクト-Footnote-513181575
Ref: SMTP オブジェクト-Footnote-613181633
Node: SMTP 使用例13181692
Ref: library/smtplib id213181825
Ref: 399c13181825
Ref: library/smtplib smtp-example13181825
Ref: 399d13181825
Ref: SMTP 使用例-Footnote-113183307
Node: uuid --- RFC 4122 に従った UUID オブジェクト13183365
Ref: library/uuid doc13183646
Ref: 399e13183646
Ref: library/uuid module-uuid13183646
Ref: f813183646
Ref: library/uuid uuid-uuid-objects-according-to-rfc-412213183646
Ref: 399f13183646
Ref: library/uuid uuid SafeUUID13184978
Ref: 39a113184978
Ref: library/uuid uuid SafeUUID safe13185036
Ref: 39a213185036
Ref: library/uuid uuid SafeUUID unsafe13185157
Ref: 39a313185157
Ref: library/uuid uuid SafeUUID unknown13185300
Ref: 39a413185300
Ref: library/uuid uuid UUID13185459
Ref: a2f13185459
Ref: library/uuid uuid UUID bytes13187741
Ref: 39a613187741
Ref: library/uuid uuid UUID bytes_le13187911
Ref: 39a713187911
Ref: library/uuid uuid UUID fields13188074
Ref: 39a813188074
Ref: library/uuid uuid UUID time_low13188478
Ref: 39a913188478
Ref: library/uuid uuid UUID time_mid13188679
Ref: 39aa13188679
Ref: library/uuid uuid UUID time_hi_version13188886
Ref: 39ab13188886
Ref: library/uuid uuid UUID clock_seq_hi_variant13189091
Ref: 39ac13189091
Ref: library/uuid uuid UUID clock_seq_low13189283
Ref: 39ad13189283
Ref: library/uuid uuid UUID node13189473
Ref: 39ae13189473
Ref: library/uuid uuid UUID time13189673
Ref: 39af13189673
Ref: library/uuid uuid UUID clock_seq13189870
Ref: 39b013189870
Ref: library/uuid uuid UUID hex13189984
Ref: 39b113189984
Ref: library/uuid uuid UUID int13190070
Ref: 39a513190070
Ref: library/uuid uuid UUID urn13190135
Ref: 39b213190135
Ref: library/uuid uuid UUID variant13190216
Ref: 39b313190216
Ref: library/uuid uuid UUID version13190475
Ref: 39b813190475
Ref: library/uuid uuid UUID is_safe13190638
Ref: b7413190638
Ref: library/uuid uuid getnode13190917
Ref: b7513190917
Ref: library/uuid uuid uuid113192196
Ref: b7613192196
Ref: library/uuid uuid uuid313192676
Ref: 16b013192676
Ref: library/uuid uuid uuid413192914
Ref: 39a013192914
Ref: library/uuid uuid uuid513192993
Ref: 16b113192993
Ref: library/uuid uuid NAMESPACE_DNS13193400
Ref: 39b913193400
Ref: library/uuid uuid NAMESPACE_URL13193548
Ref: 39ba13193548
Ref: library/uuid uuid NAMESPACE_OID13193668
Ref: 39bb13193668
Ref: library/uuid uuid NAMESPACE_X50013193792
Ref: 39bc13193792
Ref: library/uuid uuid RESERVED_NCS13194088
Ref: 39b413194088
Ref: library/uuid uuid RFC_412213194181
Ref: 39b513194181
Ref: library/uuid uuid RESERVED_MICROSOFT13194290
Ref: 39b613194290
Ref: library/uuid uuid RESERVED_FUTURE13194398
Ref: 39b713194398
Ref: uuid --- RFC 4122 に従った UUID オブジェクト-Footnote-113194920
Ref: uuid --- RFC 4122 に従った UUID オブジェクト-Footnote-213194984
Ref: uuid --- RFC 4122 に従った UUID オブジェクト-Footnote-313195043
Ref: uuid --- RFC 4122 に従った UUID オブジェクト-Footnote-413195102
Ref: uuid --- RFC 4122 に従った UUID オブジェクト-Footnote-513195161
Ref: uuid --- RFC 4122 に従った UUID オブジェクト-Footnote-613195220
Ref: uuid --- RFC 4122 に従った UUID オブジェクト-Footnote-713195279
Node: コマンドラインからの使用<2>13195338
Ref: library/uuid command-line-usage13195490
Ref: 39bd13195490
Ref: library/uuid uuid-cli13195490
Ref: 41013195490
Ref: library/uuid cmdoption-uuid-h13195806
Ref: 39be13195806
Ref: library/uuid cmdoption-uuid-help13195806
Ref: 39bf13195806
Ref: library/uuid cmdoption-uuid-u13195894
Ref: 39c013195894
Ref: library/uuid cmdoption-uuid-uuid13195916
Ref: 39c113195916
Ref: library/uuid cmdoption-uuid-n13196051
Ref: 39c213196051
Ref: library/uuid cmdoption-uuid-namespace13196078
Ref: 39c313196078
Ref: library/uuid cmdoption-uuid-N13196392
Ref: 39c413196392
Ref: library/uuid cmdoption-uuid-name13196414
Ref: 39c513196414
Node: 使用例<38>13196572
Ref: library/uuid example13196753
Ref: 39c613196753
Ref: library/uuid uuid-example13196753
Ref: 39c713196753
Node: Command-Line Example13198017
Ref: library/uuid command-line-example13198150
Ref: 39c813198150
Ref: library/uuid uuid-cli-example13198150
Ref: 39c913198150
Node: socketserver --- ネットワークサーバーのフレームワーク13198542
Ref: library/socketserver doc13198806
Ref: 39ca13198806
Ref: library/socketserver module-socketserver13198806
Ref: b913198806
Ref: library/socketserver socketserver-a-framework-for-network-servers13198806
Ref: 39cb13198806
Ref: library/socketserver socketserver TCPServer13199462
Ref: 12ee13199462
Ref: library/socketserver socketserver UDPServer13199938
Ref: 39ce13199938
Ref: library/socketserver socketserver UnixStreamServer13200245
Ref: 39cf13200245
Ref: library/socketserver socketserver UnixDatagramServer13200362
Ref: 39d013200362
Ref: socketserver --- ネットワークサーバーのフレームワーク-Footnote-113203405
Node: サーバ生成に関するノート13203477
Ref: library/socketserver server-creation-notes13203657
Ref: 39d413203657
Ref: library/socketserver socketserver ForkingMixIn13204502
Ref: b4513204502
Ref: library/socketserver socketserver ThreadingMixIn13204543
Ref: b4613204543
Ref: library/socketserver socketserver ThreadingMixIn block_on_close13205392
Ref: bcb13205392
Ref: library/socketserver socketserver ThreadingMixIn daemon_threads13205783
Ref: 39d613205783
Ref: library/socketserver socketserver ForkingTCPServer13206322
Ref: 39d713206322
Ref: library/socketserver socketserver ForkingUDPServer13206367
Ref: 39d813206367
Ref: library/socketserver socketserver ThreadingTCPServer13206412
Ref: 39d913206412
Ref: library/socketserver socketserver ThreadingUDPServer13206459
Ref: 39d513206459
Ref: library/socketserver socketserver ForkingUnixStreamServer13206506
Ref: 39da13206506
Ref: library/socketserver socketserver ForkingUnixDatagramServer13206558
Ref: 39db13206558
Ref: library/socketserver socketserver ThreadingUnixStreamServer13206612
Ref: 39dc13206612
Ref: library/socketserver socketserver ThreadingUnixDatagramServer13206666
Ref: 39dd13206666
Node: Serverオブジェクト<2>13209730
Ref: library/socketserver server-objects13209942
Ref: 39df13209942
Ref: library/socketserver socketserver BaseServer13210007
Ref: 111013210007
Ref: library/socketserver socketserver BaseServer fileno13210420
Ref: 39e213210420
Ref: library/socketserver socketserver BaseServer handle_request13210753
Ref: 12f113210753
Ref: library/socketserver socketserver BaseServer serve_forever13211459
Ref: 111213211459
Ref: library/socketserver socketserver BaseServer service_actions13212125
Ref: 111113212125
Ref: library/socketserver socketserver BaseServer shutdown13212434
Ref: 19a013212434
Ref: library/socketserver socketserver BaseServer server_close13212722
Ref: 39d313212722
Ref: library/socketserver socketserver BaseServer address_family13212843
Ref: 39e613212843
Ref: library/socketserver socketserver BaseServer RequestHandlerClass13213084
Ref: 39e113213084
Ref: library/socketserver socketserver BaseServer server_address13213276
Ref: 39e013213276
Ref: library/socketserver socketserver BaseServer socket13213766
Ref: 39e713213766
Ref: library/socketserver socketserver BaseServer allow_reuse_address13213973
Ref: 39e813213973
Ref: library/socketserver socketserver BaseServer request_queue_size13214268
Ref: 39e913214268
Ref: library/socketserver socketserver BaseServer socket_type13214868
Ref: 39ea13214868
Ref: library/socketserver socketserver BaseServer timeout13215083
Ref: 12ef13215083
Ref: library/socketserver socketserver BaseServer finish_request13215699
Ref: 39eb13215699
Ref: library/socketserver socketserver BaseServer get_request13215941
Ref: 39e313215941
Ref: library/socketserver socketserver BaseServer handle_error13216242
Ref: d0f13216242
Ref: library/socketserver socketserver BaseServer handle_timeout13216769
Ref: 12f013216769
Ref: library/socketserver socketserver BaseServer process_request13217260
Ref: 39e513217260
Ref: library/socketserver socketserver BaseServer server_activate13217740
Ref: 39cd13217740
Ref: library/socketserver socketserver BaseServer server_bind13217989
Ref: 39cc13217989
Ref: library/socketserver socketserver BaseServer verify_request13218222
Ref: 39e413218222
Node: Request Handler Objects13218950
Ref: library/socketserver request-handler-objects13219139
Ref: 39ec13219139
Ref: library/socketserver socketserver BaseRequestHandler13219208
Ref: 39d113219208
Ref: library/socketserver socketserver BaseRequestHandler setup13219566
Ref: 39ed13219566
Ref: library/socketserver socketserver BaseRequestHandler handle13219785
Ref: 39d213219785
Ref: library/socketserver socketserver BaseRequestHandler finish13220506
Ref: 39f113220506
Ref: library/socketserver socketserver BaseRequestHandler request13220874
Ref: 39ee13220874
Ref: library/socketserver socketserver BaseRequestHandler client_address13221010
Ref: 39ef13221010
Ref: library/socketserver socketserver BaseRequestHandler server13221132
Ref: 39f013221132
Ref: library/socketserver socketserver StreamRequestHandler13221233
Ref: ca813221233
Ref: library/socketserver socketserver DatagramRequestHandler13221282
Ref: 39de13221282
Ref: library/socketserver socketserver DatagramRequestHandler rfile13221534
Ref: 39f213221534
Ref: library/socketserver socketserver DatagramRequestHandler wfile13221699
Ref: 39f313221699
Node: 使用例<39>13221983
Ref: library/socketserver examples13222136
Ref: 39f413222136
Node: socketserver TCPServer の例13222342
Ref: library/socketserver socketserver-tcpserver-example13222459
Ref: 39f513222459
Node: socketserver UDPServer の例13225790
Ref: library/socketserver socketserver-udpserver-example13225941
Ref: 39f613225941
Node: 非同期処理の Mix-in13227577
Ref: library/socketserver asynchronous-mixins13227690
Ref: 39f713227690
Node: http server --- HTTP サーバー13230176
Ref: library/http server doc13230423
Ref: 39f813230423
Ref: library/http server http-server-http-servers13230423
Ref: 39f913230423
Ref: library/http server module-http server13230423
Ref: 6813230423
Ref: library/http server http server HTTPServer13231684
Ref: 37fe13231684
Ref: library/http server http server ThreadingHTTPServer13232131
Ref: b1213232131
Ref: library/http server http server BaseHTTPRequestHandler13232737
Ref: 109e13232737
Ref: library/http server http server BaseHTTPRequestHandler client_address13233914
Ref: 39fb13233914
Ref: library/http server http server BaseHTTPRequestHandler server13234105
Ref: 39fc13234105
Ref: library/http server http server BaseHTTPRequestHandler close_connection13234194
Ref: 39fd13234194
Ref: library/http server http server BaseHTTPRequestHandler requestline13234495
Ref: 39ff13234495
Ref: library/http server http server BaseHTTPRequestHandler command13234898
Ref: 3a0013234898
Ref: library/http server http server BaseHTTPRequestHandler path13235041
Ref: 3a0113235041
Ref: library/http server http server BaseHTTPRequestHandler request_version13235315
Ref: 3a0213235315
Ref: library/http server http server BaseHTTPRequestHandler headers13235476
Ref: 38e713235476
Ref: library/http server http server BaseHTTPRequestHandler rfile13236010
Ref: 3a0413236010
Ref: library/http server http server BaseHTTPRequestHandler wfile13236162
Ref: 3a0513236162
Ref: library/http server http server BaseHTTPRequestHandler server_version13236629
Ref: 3a0613236629
Ref: library/http server http server BaseHTTPRequestHandler sys_version13237032
Ref: 3a0713237032
Ref: library/http server http server BaseHTTPRequestHandler error_message_format13237311
Ref: 3a0913237311
Ref: library/http server http server BaseHTTPRequestHandler error_content_type13237672
Ref: 3a0a13237672
Ref: library/http server http server BaseHTTPRequestHandler protocol_version13237904
Ref: 3a0b13237904
Ref: library/http server http server BaseHTTPRequestHandler MessageClass13238498
Ref: 3a0313238498
Ref: library/http server http server BaseHTTPRequestHandler responses13238823
Ref: 38ce13238823
Ref: library/http server http server BaseHTTPRequestHandler handle13239417
Ref: 3a0e13239417
Ref: library/http server http server BaseHTTPRequestHandler handle_one_request13239723
Ref: 39fe13239723
Ref: library/http server http server BaseHTTPRequestHandler handle_expect_10013239927
Ref: 3a0f13239927
Ref: library/http server http server BaseHTTPRequestHandler send_error13240563
Ref: f1d13240563
Ref: library/http server http server BaseHTTPRequestHandler send_response13241704
Ref: 3a1013241704
Ref: library/http server http server BaseHTTPRequestHandler send_header13242535
Ref: 3a0c13242535
Ref: library/http server http server BaseHTTPRequestHandler send_response_only13243134
Ref: 3a0d13243134
Ref: library/http server http server BaseHTTPRequestHandler end_headers13243562
Ref: 109f13243562
Ref: library/http server http server BaseHTTPRequestHandler flush_headers13243903
Ref: 10a013243903
Ref: library/http server http server BaseHTTPRequestHandler log_request13244114
Ref: 3a1213244114
Ref: library/http server http server BaseHTTPRequestHandler log_error13244504
Ref: 3a1313244504
Ref: library/http server http server BaseHTTPRequestHandler log_message13244814
Ref: 3a1413244814
Ref: library/http server http server BaseHTTPRequestHandler version_string13245454
Ref: 3a0813245454
Ref: library/http server http server BaseHTTPRequestHandler date_time_string13245725
Ref: 3a1113245725
Ref: library/http server http server BaseHTTPRequestHandler log_date_time_string13246210
Ref: 3a1513246210
Ref: library/http server http server BaseHTTPRequestHandler address_string13246360
Ref: 3a1613246360
Ref: library/http server http server SimpleHTTPRequestHandler13246640
Ref: b1113246640
Ref: library/http server http server SimpleHTTPRequestHandler server_version13247487
Ref: 3a1913247487
Ref: library/http server http server SimpleHTTPRequestHandler extensions_map13247689
Ref: 3a1a13247689
Ref: library/http server http server SimpleHTTPRequestHandler do_HEAD13248211
Ref: 3a1813248211
Ref: library/http server http server SimpleHTTPRequestHandler do_GET13248622
Ref: 3a1713248622
Ref: library/http server http-server-cli13251524
Ref: f1e13251524
Ref: library/http server http server CGIHTTPRequestHandler13253072
Ref: 28113253072
Ref: library/http server http server CGIHTTPRequestHandler cgi_directories13254718
Ref: 3a1b13254718
Ref: library/http server http server CGIHTTPRequestHandler do_POST13255022
Ref: 3a1c13255022
Ref: http server --- HTTP サーバー-Footnote-113256702
Ref: http server --- HTTP サーバー-Footnote-213256773
Ref: http server --- HTTP サーバー-Footnote-313256832
Ref: http server --- HTTP サーバー-Footnote-413256891
Node: セキュリティで考慮すべき点<5>13256962
Ref: library/http server http-server-security13257074
Ref: 39fa13257074
Ref: library/http server security-considerations13257074
Ref: 3a1d13257074
Node: http cookies --- HTTP の状態管理13257743
Ref: library/http cookies doc13257981
Ref: 3a1e13257981
Ref: library/http cookies http-cookies-http-state-management13257981
Ref: 3a1f13257981
Ref: library/http cookies module-http cookies13257981
Ref: 6713257981
Ref: library/http cookies http cookies CookieError13259645
Ref: 3a2013259645
Ref: library/http cookies http cookies BaseCookie13259832
Ref: 3a2113259832
Ref: library/http cookies http cookies SimpleCookie13260310
Ref: 19ae13260310
Ref: http cookies --- HTTP の状態管理-Footnote-113261341
Ref: http cookies --- HTTP の状態管理-Footnote-213261413
Ref: http cookies --- HTTP の状態管理-Footnote-313261472
Ref: http cookies --- HTTP の状態管理-Footnote-413261531
Ref: http cookies --- HTTP の状態管理-Footnote-513261590
Node: Cookieオブジェクト13261649
Ref: library/http cookies cookie-objects13261780
Ref: 3a2513261780
Ref: library/http cookies id113261780
Ref: 3a2613261780
Ref: library/http cookies http cookies BaseCookie value_decode13261845
Ref: 3a2313261845
Ref: library/http cookies http cookies BaseCookie value_encode13262218
Ref: 3a2413262218
Ref: library/http cookies http cookies BaseCookie output13262832
Ref: 3a2713262832
Ref: library/http cookies http cookies BaseCookie js_output13263241
Ref: 3a2813263241
Ref: library/http cookies http cookies BaseCookie load13263551
Ref: 3a2213263551
Node: Morselオブジェクト13263881
Ref: library/http cookies id213264034
Ref: 3a2913264034
Ref: library/http cookies morsel-objects13264034
Ref: 3a2a13264034
Ref: library/http cookies http cookies Morsel13264099
Ref: bd213264099
Ref: library/http cookies http cookies Morsel expires13264351
Ref: 3a2b13264351
Ref: library/http cookies http cookies Morsel path13264384
Ref: 3a2c13264384
Ref: library/http cookies http cookies Morsel comment13264414
Ref: 3a2d13264414
Ref: library/http cookies http cookies Morsel domain13264447
Ref: 3a2e13264447
Ref: library/http cookies http cookies Morsel secure13264513
Ref: 3a2f13264513
Ref: library/http cookies http cookies Morsel version13264545
Ref: 3a3013264545
Ref: library/http cookies http cookies Morsel httponly13264578
Ref: 137813264578
Ref: library/http cookies http cookies Morsel samesite13264612
Ref: 3a3113264612
Ref: library/http cookies http cookies Morsel value13265811
Ref: bd013265811
Ref: library/http cookies http cookies Morsel coded_value13265868
Ref: bd113265868
Ref: library/http cookies http cookies Morsel key13265979
Ref: bcf13265979
Ref: library/http cookies http cookies Morsel set13266031
Ref: bd313266031
Ref: library/http cookies http cookies Morsel isReservedKey13266167
Ref: 3a3213266167
Ref: library/http cookies http cookies Morsel output13266296
Ref: 3a3313266296
Ref: library/http cookies http cookies Morsel js_output13266698
Ref: 3a3413266698
Ref: library/http cookies http cookies Morsel OutputString13267004
Ref: 3a3513267004
Ref: library/http cookies http cookies Morsel update13267207
Ref: e9213267207
Ref: library/http cookies http cookies Morsel copy13267534
Ref: e9113267534
Ref: library/http cookies http cookies Morsel setdefault13267741
Ref: 3a3613267741
Ref: Morselオブジェクト-Footnote-113268022
Ref: Morselオブジェクト-Footnote-213268081
Ref: Morselオブジェクト-Footnote-313268140
Ref: Morselオブジェクト-Footnote-413268199
Node: 使用例<40>13268258
Ref: library/http cookies cookie-example13268378
Ref: 3a3713268378
Ref: library/http cookies example13268378
Ref: 3a3813268378
Node: http cookiejar --- HTTP クライアント用の Cookie 処理13270026
Ref: library/http cookiejar doc13270300
Ref: 3a3913270300
Ref: library/http cookiejar http-cookiejar-cookie-handling-for-http-clients13270300
Ref: 3a3a13270300
Ref: library/http cookiejar module-http cookiejar13270300
Ref: 6613270300
Ref: library/http cookiejar http cookiejar LoadError13272268
Ref: 3a3b13272268
Ref: library/http cookiejar http cookiejar CookieJar13272800
Ref: 386e13272800
Ref: library/http cookiejar http cookiejar FileCookieJar13273512
Ref: 3a3c13273512
Ref: library/http cookiejar http cookiejar CookiePolicy13274637
Ref: 3a3d13274637
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy13274859
Ref: 197c13274859
Ref: library/http cookiejar http cookiejar Cookie13277102
Ref: 3a4213277102
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-113279310
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-213279384
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-313279443
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-413279502
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-513279561
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-613279620
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-713279679
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-813279738
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-913279797
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-1013279856
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-1113279916
Ref: http cookiejar --- HTTP クライアント用の Cookie 処理-Footnote-1213279976
Node: CookieJar および FileCookieJar オブジェクト13280036
Ref: library/http cookiejar cookie-jar-objects13280260
Ref: 3a4313280260
Ref: library/http cookiejar cookiejar-and-filecookiejar-objects13280260
Ref: 3a4413280260
Ref: library/http cookiejar http cookiejar CookieJar add_cookie_header13280684
Ref: 3a4513280684
Ref: library/http cookiejar http cookiejar CookieJar extract_cookies13281839
Ref: 3a4613281839
Ref: library/http cookiejar http cookiejar CookieJar set_policy13283504
Ref: 3a4813283504
Ref: library/http cookiejar http cookiejar CookieJar make_cookies13283638
Ref: 3a4913283638
Ref: library/http cookiejar http cookiejar CookieJar set_cookie_if_ok13284019
Ref: 3a4a13284019
Ref: library/http cookiejar http cookiejar CookieJar set_cookie13284192
Ref: 3a4b13284192
Ref: library/http cookiejar http cookiejar CookieJar clear13284401
Ref: 3a4c13284401
Ref: library/http cookiejar http cookiejar CookieJar clear_session_cookies13285128
Ref: 3a4d13285128
Ref: library/http cookiejar http cookiejar FileCookieJar save13286003
Ref: 3a4e13286003
Ref: library/http cookiejar http cookiejar FileCookieJar load13287281
Ref: 3a3e13287281
Ref: library/http cookiejar http cookiejar FileCookieJar revert13288103
Ref: 3a3f13288103
Ref: library/http cookiejar http cookiejar FileCookieJar filename13288625
Ref: 3a4f13288625
Ref: library/http cookiejar http cookiejar FileCookieJar delayload13288812
Ref: 3a5013288812
Node: FileCookieJar のサブクラスと web ブラウザとの連携13289502
Ref: library/http cookiejar file-cookie-jar-classes13289766
Ref: 3a4013289766
Ref: library/http cookiejar filecookiejar-subclasses-and-co-operation-with-web-browsers13289766
Ref: 3a5113289766
Ref: library/http cookiejar http cookiejar MozillaCookieJar13290025
Ref: 3a5213290025
Ref: library/http cookiejar http cookiejar LWPCookieJar13291135
Ref: 3a5313291135
Ref: FileCookieJar のサブクラスと web ブラウザとの連携-Footnote-113291690
Node: CookiePolicy オブジェクト13291749
Ref: library/http cookiejar cookie-policy-objects13291999
Ref: 3a5413291999
Ref: library/http cookiejar cookiepolicy-objects13291999
Ref: 3a5513291999
Ref: library/http cookiejar http cookiejar CookiePolicy set_ok13292219
Ref: 3a4713292219
Ref: library/http cookiejar http cookiejar CookiePolicy return_ok13292633
Ref: 3a5613292633
Ref: library/http cookiejar http cookiejar CookiePolicy domain_return_ok13293040
Ref: 3a5713293040
Ref: library/http cookiejar http cookiejar CookiePolicy path_return_ok13295086
Ref: 3a5813295086
Ref: library/http cookiejar http cookiejar CookiePolicy netscape13295720
Ref: 3a5913295720
Ref: library/http cookiejar http cookiejar CookiePolicy rfc296513295834
Ref: 3a5a13295834
Ref: library/http cookiejar http cookiejar CookiePolicy hide_cookie213295950
Ref: 3a5b13295950
Ref: CookiePolicy オブジェクト-Footnote-113296768
Ref: CookiePolicy オブジェクト-Footnote-213296827
Node: DefaultCookiePolicy オブジェクト13296886
Ref: library/http cookiejar default-cookie-policy-objects13297099
Ref: 3a5c13297099
Ref: library/http cookiejar defaultcookiepolicy-objects13297099
Ref: 3a5d13297099
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy blocked_domains13300287
Ref: 3a5e13300287
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy set_blocked_domains13300446
Ref: 3a5f13300446
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy is_blocked13300581
Ref: 3a6013300581
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy allowed_domains13300761
Ref: 3a6113300761
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy set_allowed_domains13300946
Ref: 3a6213300946
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy is_not_allowed13301108
Ref: 3a6313301108
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy rfc2109_as_netscape13301539
Ref: 3a4113301539
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy strict_domain13302320
Ref: 3a6413302320
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy strict_rfc2965_unverifiable13302744
Ref: 3a6513302744
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy strict_ns_unverifiable13303252
Ref: 3a6613303252
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy strict_ns_domain13303457
Ref: 3a6713303457
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy strict_ns_set_initial_dollar13303730
Ref: 3a6813303730
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy strict_ns_set_path13303893
Ref: 3a6913303893
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy DomainStrictNoDots13304311
Ref: 3a6a13304311
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy DomainStrictNonDomain13304686
Ref: 3a6b13304686
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy DomainRFC2965Match13305133
Ref: 3a6c13305133
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy DomainLiberal13305458
Ref: 3a6d13305458
Ref: library/http cookiejar http cookiejar DefaultCookiePolicy DomainStrict13305641
Ref: 3a6e13305641
Ref: DefaultCookiePolicy オブジェクト-Footnote-113305798
Ref: DefaultCookiePolicy オブジェクト-Footnote-213305857
Ref: DefaultCookiePolicy オブジェクト-Footnote-313305916
Ref: DefaultCookiePolicy オブジェクト-Footnote-413305975
Ref: DefaultCookiePolicy オブジェクト-Footnote-513306034
Ref: DefaultCookiePolicy オブジェクト-Footnote-613306093
Ref: DefaultCookiePolicy オブジェクト-Footnote-713306152
Node: Cookieオブジェクト<2>13306211
Ref: library/http cookiejar cookie-objects13306406
Ref: 3a6f13306406
Ref: library/http cookiejar http cookiejar Cookie version13307450
Ref: 3a7013307450
Ref: library/http cookiejar http cookiejar Cookie name13307878
Ref: 3a7113307878
Ref: library/http cookiejar http cookiejar Cookie value13307949
Ref: 3a7213307949
Ref: library/http cookiejar http cookiejar Cookie port13308051
Ref: 3a7313308051
Ref: library/http cookiejar http cookiejar Cookie domain13308222
Ref: 3a7413308222
Ref: library/http cookiejar http cookiejar Cookie path13308302
Ref: 3a7513308302
Ref: library/http cookiejar http cookiejar Cookie secure13308414
Ref: 3a7613308414
Ref: library/http cookiejar http cookiejar Cookie expires13308559
Ref: 3a7713308559
Ref: library/http cookiejar http cookiejar Cookie discard13308801
Ref: 3a7913308801
Ref: library/http cookiejar http cookiejar Cookie comment13308917
Ref: 3a7a13308917
Ref: library/http cookiejar http cookiejar Cookie comment_url13309080
Ref: 3a7b13309080
Ref: library/http cookiejar http cookiejar Cookie rfc210913309255
Ref: 3a7c13309255
Ref: library/http cookiejar http cookiejar Cookie port_specified13309696
Ref: 3a7d13309696
Ref: library/http cookiejar http cookiejar Cookie domain_specified13309928
Ref: 3a7e13309928
Ref: library/http cookiejar http cookiejar Cookie domain_initial_dot13310074
Ref: 3a7f13310074
Ref: library/http cookiejar http cookiejar Cookie has_nonstandard_attr13310430
Ref: 3a8013310430
Ref: library/http cookiejar http cookiejar Cookie get_nonstandard_attr13310619
Ref: 3a8113310619
Ref: library/http cookiejar http cookiejar Cookie set_nonstandard_attr13310861
Ref: 3a8213310861
Ref: library/http cookiejar http cookiejar Cookie is_expired13311072
Ref: 3a7813311072
Ref: Cookieオブジェクト<2>-Footnote-113311420
Ref: Cookieオブジェクト<2>-Footnote-213311479
Ref: Cookieオブジェクト<2>-Footnote-313311538
Ref: Cookieオブジェクト<2>-Footnote-413311597
Node: 使用例<41>13311656
Ref: library/http cookiejar examples13311804
Ref: 3a8313311804
Ref: 使用例<41>-Footnote-113313473
Node: xmlrpc --- XMLRPC サーバーとクライアントモジュール群13313532
Ref: library/xmlrpc doc13313825
Ref: 3a8413313825
Ref: library/xmlrpc xmlrpc-xmlrpc-server-and-client-modules13313825
Ref: 3a8513313825
Node: xmlrpc client --- XML-RPC クライアントアクセス13314555
Ref: library/xmlrpc client doc13314837
Ref: 3a8613314837
Ref: library/xmlrpc client module-xmlrpc client13314837
Ref: 11413314837
Ref: library/xmlrpc client xmlrpc-client-xml-rpc-client-access13314837
Ref: 3a8713314837
Ref: library/xmlrpc client xmlrpc client ServerProxy13316340
Ref: a2513316340
Ref: xmlrpc client --- XML-RPC クライアントアクセス-Footnote-113324962
Ref: xmlrpc client --- XML-RPC クライアントアクセス-Footnote-213325035
Ref: xmlrpc client --- XML-RPC クライアントアクセス-Footnote-313325129
Ref: xmlrpc client --- XML-RPC クライアントアクセス-Footnote-413325185
Ref: xmlrpc client --- XML-RPC クライアントアクセス-Footnote-513325244
Node: ServerProxy オブジェクト13325290
Ref: library/xmlrpc client id113325449
Ref: 3a8b13325449
Ref: library/xmlrpc client serverproxy-objects13325449
Ref: 3a8c13325449
Ref: library/xmlrpc client xmlrpc client ServerProxy system listMethods13326211
Ref: 3a8d13326211
Ref: library/xmlrpc client xmlrpc client ServerProxy system methodSignature13326397
Ref: 3a8e13326397
Ref: library/xmlrpc client xmlrpc client ServerProxy system methodHelp13327515
Ref: 3a8f13327515
Node: DateTime オブジェクト13328645
Ref: library/xmlrpc client datetime-objects13328838
Ref: 3a9013328838
Ref: library/xmlrpc client id213328838
Ref: 3a9113328838
Ref: library/xmlrpc client xmlrpc client DateTime13328909
Ref: 138b13328909
Ref: library/xmlrpc client xmlrpc client DateTime decode13329369
Ref: 3a9213329369
Ref: library/xmlrpc client xmlrpc client DateTime encode13329508
Ref: 3a9313329508
Node: Binary オブジェクト13330678
Ref: library/xmlrpc client binary-objects13330865
Ref: 3a9413330865
Ref: library/xmlrpc client id313330865
Ref: 3a9513330865
Ref: library/xmlrpc client xmlrpc client Binary13330932
Ref: 3a8813330932
Ref: library/xmlrpc client xmlrpc client Binary data13331140
Ref: 3a9613331140
Ref: library/xmlrpc client xmlrpc client Binary decode13331512
Ref: 3a9713331512
Ref: library/xmlrpc client xmlrpc client Binary encode13331698
Ref: 3a9813331698
Ref: Binary オブジェクト-Footnote-113333071
Node: Fault オブジェクト13333142
Ref: library/xmlrpc client fault-objects13333334
Ref: 3a9913333334
Ref: library/xmlrpc client id413333334
Ref: 3a9a13333334
Ref: library/xmlrpc client xmlrpc client Fault13333399
Ref: 3a8913333399
Ref: library/xmlrpc client xmlrpc client Fault faultCode13333585
Ref: 3a9b13333585
Ref: library/xmlrpc client xmlrpc client Fault faultString13333664
Ref: 3a9c13333664
Node: ProtocolError オブジェクト13334627
Ref: library/xmlrpc client protocol-error-objects13334822
Ref: 3a9d13334822
Ref: library/xmlrpc client protocolerror-objects13334822
Ref: 3a9e13334822
Ref: library/xmlrpc client xmlrpc client ProtocolError13334903
Ref: 3a8a13334903
Ref: library/xmlrpc client xmlrpc client ProtocolError url13335212
Ref: 3a9f13335212
Ref: library/xmlrpc client xmlrpc client ProtocolError errcode13335297
Ref: 3aa013335297
Ref: library/xmlrpc client xmlrpc client ProtocolError errmsg13335359
Ref: 3aa113335359
Ref: library/xmlrpc client xmlrpc client ProtocolError headers13335450
Ref: 3aa213335450
Node: MultiCall オブジェクト13336172
Ref: library/xmlrpc client multicall-objects13336355
Ref: 3aa313336355
Ref: library/xmlrpc client xmlrpc client MultiCall13336611
Ref: 3aa413336611
Ref: MultiCall オブジェクト-Footnote-113338672
Node: 補助関数13338870
Ref: library/xmlrpc client convenience-functions13339054
Ref: 3aa513339054
Ref: library/xmlrpc client xmlrpc client dumps13339097
Ref: 3aa613339097
Ref: library/xmlrpc client xmlrpc client loads13340044
Ref: 13dc13340044
Node: クライアントのサンプル13341102
Ref: library/xmlrpc client example-of-client-usage13341303
Ref: 3aa713341303
Ref: library/xmlrpc client xmlrpc-client-example13341303
Ref: 3aa813341303
Node: クライアントとサーバーの利用例13342672
Ref: library/xmlrpc client example-of-client-and-server-usage13342852
Ref: 3aa913342852
Node: xmlrpc server --- 基本的な XML-RPC サーバー13343034
Ref: library/xmlrpc server doc13343292
Ref: 3aab13343292
Ref: library/xmlrpc server module-xmlrpc server13343292
Ref: 11513343292
Ref: library/xmlrpc server xmlrpc-server-basic-xml-rpc-servers13343292
Ref: 3aac13343292
Ref: library/xmlrpc server xmlrpc server SimpleXMLRPCServer13344424
Ref: 3aad13344424
Ref: library/xmlrpc server xmlrpc server CGIXMLRPCRequestHandler13346242
Ref: 3aae13346242
Ref: library/xmlrpc server xmlrpc server SimpleXMLRPCRequestHandler13346971
Ref: 12f613346971
Ref: xmlrpc server --- 基本的な XML-RPC サーバー-Footnote-113347559
Node: SimpleXMLRPCServer オブジェクト13347632
Ref: library/xmlrpc server simple-xmlrpc-servers13347789
Ref: 3aaf13347789
Ref: library/xmlrpc server simplexmlrpcserver-objects13347789
Ref: 3ab013347789
Ref: library/xmlrpc server xmlrpc server SimpleXMLRPCServer register_function13348087
Ref: 3ab113348087
Ref: library/xmlrpc server xmlrpc server SimpleXMLRPCServer register_instance13349157
Ref: 3ab213349157
Ref: library/xmlrpc server xmlrpc server SimpleXMLRPCServer register_introspection_functions13351039
Ref: 3ab313351039
Ref: library/xmlrpc server xmlrpc server SimpleXMLRPCServer register_multicall_functions13351283
Ref: 3ab413351283
Ref: library/xmlrpc server xmlrpc server SimpleXMLRPCRequestHandler rpc_paths13351461
Ref: 3ab513351461
Node: SimpleXMLRPCServer の例13351999
Ref: library/xmlrpc server id113352098
Ref: 3ab613352098
Ref: library/xmlrpc server simplexmlrpcserver-example13352098
Ref: 3aaa13352098
Node: CGIXMLRPCRequestHandler13356902
Ref: library/xmlrpc server cgixmlrpcrequesthandler13357096
Ref: 3ab713357096
Ref: library/xmlrpc server xmlrpc server CGIXMLRPCRequestHandler register_function13357334
Ref: 3ab813357334
Ref: library/xmlrpc server xmlrpc server CGIXMLRPCRequestHandler register_instance13358409
Ref: 3ab913358409
Ref: library/xmlrpc server xmlrpc server CGIXMLRPCRequestHandler register_introspection_functions13359415
Ref: 3aba13359415
Ref: library/xmlrpc server xmlrpc server CGIXMLRPCRequestHandler register_multicall_functions13359674
Ref: 3abb13359674
Ref: library/xmlrpc server xmlrpc server CGIXMLRPCRequestHandler handle_request13359833
Ref: 3abc13359833
Node: XMLRPC サーバの文書化13360529
Ref: library/xmlrpc server documenting-xmlrpc-server13360720
Ref: 3abd13360720
Ref: library/xmlrpc server xmlrpc server DocXMLRPCServer13361136
Ref: 192913361136
Ref: library/xmlrpc server xmlrpc server DocCGIXMLRPCRequestHandler13361721
Ref: 3abe13361721
Ref: library/xmlrpc server xmlrpc server DocXMLRPCRequestHandler13361890
Ref: 3abf13361890
Node: DocXMLRPCServer オブジェクト13362311
Ref: library/xmlrpc server doc-xmlrpc-servers13362505
Ref: 3ac013362505
Ref: library/xmlrpc server docxmlrpcserver-objects13362505
Ref: 3ac113362505
Ref: library/xmlrpc server xmlrpc server DocXMLRPCServer set_server_title13363058
Ref: 3ac213363058
Ref: library/xmlrpc server xmlrpc server DocXMLRPCServer set_server_name13363279
Ref: 3ac313363279
Ref: library/xmlrpc server xmlrpc server DocXMLRPCServer set_server_documentation13363505
Ref: 3ac413363505
Node: DocCGIXMLRPCRequestHandler13363776
Ref: library/xmlrpc server doccgixmlrpcrequesthandler13363933
Ref: 3ac513363933
Ref: library/xmlrpc server xmlrpc server DocCGIXMLRPCRequestHandler set_server_title13364477
Ref: 3ac613364477
Ref: library/xmlrpc server xmlrpc server DocCGIXMLRPCRequestHandler set_server_name13364709
Ref: 3ac713364709
Ref: library/xmlrpc server xmlrpc server DocCGIXMLRPCRequestHandler set_server_documentation13364946
Ref: 3ac813364946
Node: ipaddress --- IPv4/IPv6 操作ライブラリ13365228
Ref: library/ipaddress doc13365421
Ref: 3ac913365421
Ref: library/ipaddress ipaddress-ipv4-ipv6-manipulation-library13365421
Ref: 3aca13365421
Ref: library/ipaddress module-ipaddress13365421
Ref: 7413365421
Ref: ipaddress --- IPv4/IPv6 操作ライブラリ-Footnote-113366667
Node: 便利なファクトリ関数13366736
Ref: library/ipaddress convenience-factory-functions13366872
Ref: 3acc13366872
Ref: library/ipaddress ipaddress ip_address13367130
Ref: 3acd13367130
Ref: library/ipaddress ipaddress ip_network13367802
Ref: 3ace13367802
Ref: library/ipaddress ipaddress ip_interface13368698
Ref: 3acf13368698
Node: IP アドレス13369762
Ref: library/ipaddress ip-addresses13369934
Ref: 3ad013369934
Node: Address オブジェクト13370086
Ref: library/ipaddress address-objects13370203
Ref: 3ad113370203
Ref: library/ipaddress ipaddress IPv4Address13370732
Ref: 1dd13370732
Ref: library/ipaddress ipaddress IPv4Address version13372129
Ref: 3ad313372129
Ref: library/ipaddress ipaddress IPv4Address max_prefixlen13372243
Ref: 3ad413372243
Ref: library/ipaddress ipaddress IPv4Address compressed13372614
Ref: 3ad513372614
Ref: library/ipaddress ipaddress IPv4Address exploded13372646
Ref: 3ad613372646
Ref: library/ipaddress ipaddress IPv4Address packed13373193
Ref: 3ad713373193
Ref: library/ipaddress ipaddress IPv4Address reverse_pointer13373447
Ref: 3ad813373447
Ref: library/ipaddress ipaddress IPv4Address is_multicast13373994
Ref: 3ad913373994
Ref: library/ipaddress ipaddress IPv4Address is_private13374192
Ref: 15ad13374192
Ref: library/ipaddress ipaddress IPv4Address is_global13375849
Ref: f2c13375849
Ref: library/ipaddress ipaddress IPv4Address is_unspecified13376771
Ref: 3adb13376771
Ref: library/ipaddress ipaddress IPv4Address is_reserved13376930
Ref: 3adc13376930
Ref: library/ipaddress ipaddress IPv4Address is_loopback13377042
Ref: 3add13377042
Ref: library/ipaddress ipaddress IPv4Address is_link_local13377214
Ref: 3ade13377214
Ref: library/ipaddress ipaddress IPv4Address ipv6_mapped13377384
Ref: 1dc13377384
Ref: library/ipaddress ipaddress IPv4Address __format__13377565
Ref: 3adf13377565
Ref: library/ipaddress ipaddress IPv6Address13378821
Ref: 1de13378821
Ref: library/ipaddress ipaddress IPv6Address compressed13380302
Ref: 3ae013380302
Ref: library/ipaddress ipaddress IPv6Address exploded13380652
Ref: 3ae113380652
Ref: library/ipaddress ipaddress IPv6Address packed13380990
Ref: 3ae213380990
Ref: library/ipaddress ipaddress IPv6Address reverse_pointer13381018
Ref: 153813381018
Ref: library/ipaddress ipaddress IPv6Address version13381055
Ref: 3ae313381055
Ref: library/ipaddress ipaddress IPv6Address max_prefixlen13381084
Ref: 3ae413381084
Ref: library/ipaddress ipaddress IPv6Address is_multicast13381119
Ref: 3ae513381119
Ref: library/ipaddress ipaddress IPv6Address is_private13381153
Ref: 15ae13381153
Ref: library/ipaddress ipaddress IPv6Address is_global13381185
Ref: 15af13381185
Ref: library/ipaddress ipaddress IPv6Address is_unspecified13381249
Ref: 3ae613381249
Ref: library/ipaddress ipaddress IPv6Address is_reserved13381285
Ref: 3ae713381285
Ref: library/ipaddress ipaddress IPv6Address is_loopback13381318
Ref: 159813381318
Ref: library/ipaddress ipaddress IPv6Address is_link_local13381351
Ref: 3ae813381351
Ref: library/ipaddress ipaddress IPv6Address is_site_local13381386
Ref: 3ae913381386
Ref: library/ipaddress ipaddress IPv6Address ipv4_mapped13381909
Ref: 3ada13381909
Ref: library/ipaddress ipaddress IPv6Address scope_id13382229
Ref: 8dc13382229
Ref: library/ipaddress ipaddress IPv6Address sixtofour13382527
Ref: 3aea13382527
Ref: library/ipaddress ipaddress IPv6Address teredo13382867
Ref: 3aeb13382867
Ref: library/ipaddress ipaddress IPv6Address __format__13383237
Ref: 3aec13383237
Ref: Address オブジェクト-Footnote-113383464
Ref: Address オブジェクト-Footnote-213383523
Ref: Address オブジェクト-Footnote-313383582
Ref: Address オブジェクト-Footnote-413383684
Ref: Address オブジェクト-Footnote-513383786
Ref: Address オブジェクト-Footnote-613383888
Ref: Address オブジェクト-Footnote-713383990
Ref: Address オブジェクト-Footnote-813384049
Ref: Address オブジェクト-Footnote-913384108
Ref: Address オブジェクト-Footnote-1013384167
Ref: Address オブジェクト-Footnote-1113384227
Ref: Address オブジェクト-Footnote-1213384287
Ref: Address オブジェクト-Footnote-1313384347
Ref: Address オブジェクト-Footnote-1413384407
Ref: Address オブジェクト-Footnote-1513384467
Ref: Address オブジェクト-Footnote-1613384527
Ref: Address オブジェクト-Footnote-1713384587
Ref: Address オブジェクト-Footnote-1813384647
Ref: Address オブジェクト-Footnote-1913384707
Node: 文字列と整数への変換13384767
Ref: library/ipaddress conversion-to-strings-and-integers13384905
Ref: 3aed13384905
Node: 演算子<3>13385570
Ref: library/ipaddress operators13385673
Ref: 3aee13385673
Node: 比較演算子13385990
Ref: library/ipaddress comparison-operators13386075
Ref: 3aef13386075
Node: 算術演算13386654
Ref: library/ipaddress arithmetic-operators13386739
Ref: 3af013386739
Node: IP ネットワーク定義13387234
Ref: library/ipaddress ip-network-definitions13387418
Ref: 3af113387418
Node: プリフィックス ネットマスク、ホストマスク13388315
Ref: library/ipaddress prefix-net-mask-and-host-mask13388475
Ref: 3af213388475
Node: Network オブジェクト13389376
Ref: library/ipaddress network-objects13389557
Ref: 3af313389557
Ref: library/ipaddress ipaddress IPv4Network13390151
Ref: 1df13390151
Ref: library/ipaddress ipaddress IPv4Network version13393084
Ref: 3af513393084
Ref: library/ipaddress ipaddress IPv4Network max_prefixlen13393113
Ref: 3af613393113
Ref: library/ipaddress ipaddress IPv4Network is_multicast13393267
Ref: 3af713393267
Ref: library/ipaddress ipaddress IPv4Network is_private13393301
Ref: 3af813393301
Ref: library/ipaddress ipaddress IPv4Network is_unspecified13393333
Ref: 3af913393333
Ref: library/ipaddress ipaddress IPv4Network is_reserved13393369
Ref: 3afa13393369
Ref: library/ipaddress ipaddress IPv4Network is_loopback13393402
Ref: 3afb13393402
Ref: library/ipaddress ipaddress IPv4Network is_link_local13393435
Ref: 3afc13393435
Ref: library/ipaddress ipaddress IPv4Network network_address13393627
Ref: 3afd13393627
Ref: library/ipaddress ipaddress IPv4Network broadcast_address13393864
Ref: 3afe13393864
Ref: library/ipaddress ipaddress IPv4Network hostmask13394144
Ref: 3aff13394144
Ref: library/ipaddress ipaddress IPv4Network netmask13394285
Ref: 3b0013394285
Ref: library/ipaddress ipaddress IPv4Network with_prefixlen13394425
Ref: 3b0113394425
Ref: library/ipaddress ipaddress IPv4Network compressed13394461
Ref: 3b0213394461
Ref: library/ipaddress ipaddress IPv4Network exploded13394493
Ref: 3b0313394493
Ref: library/ipaddress ipaddress IPv4Network with_netmask13394794
Ref: 3b0413394794
Ref: library/ipaddress ipaddress IPv4Network with_hostmask13394925
Ref: 3b0513394925
Ref: library/ipaddress ipaddress IPv4Network num_addresses13395058
Ref: 3b0613395058
Ref: library/ipaddress ipaddress IPv4Network prefixlen13395150
Ref: 3b0713395150
Ref: library/ipaddress ipaddress IPv4Network hosts13395250
Ref: 3b0813395250
Ref: library/ipaddress ipaddress IPv4Network overlaps13396253
Ref: 3b0913396253
Ref: library/ipaddress ipaddress IPv4Network address_exclude13396431
Ref: 3b0a13396431
Ref: library/ipaddress ipaddress IPv4Network subnets13397043
Ref: e6913397043
Ref: library/ipaddress ipaddress IPv4Network supernet13398597
Ref: e6a13398597
Ref: library/ipaddress ipaddress IPv4Network subnet_of13399409
Ref: 3b0b13399409
Ref: library/ipaddress ipaddress IPv4Network supernet_of13399764
Ref: 3b0c13399764
Ref: library/ipaddress ipaddress IPv4Network compare_networks13400129
Ref: 3b0d13400129
Ref: library/ipaddress ipaddress IPv6Network13400899
Ref: 1e013400899
Ref: library/ipaddress ipaddress IPv6Network version13403024
Ref: 3b0e13403024
Ref: library/ipaddress ipaddress IPv6Network max_prefixlen13403053
Ref: 3b0f13403053
Ref: library/ipaddress ipaddress IPv6Network is_multicast13403088
Ref: 3b1013403088
Ref: library/ipaddress ipaddress IPv6Network is_private13403122
Ref: 3b1113403122
Ref: library/ipaddress ipaddress IPv6Network is_unspecified13403154
Ref: 3b1213403154
Ref: library/ipaddress ipaddress IPv6Network is_reserved13403190
Ref: 3b1313403190
Ref: library/ipaddress ipaddress IPv6Network is_loopback13403223
Ref: 3b1413403223
Ref: library/ipaddress ipaddress IPv6Network is_link_local13403256
Ref: 3b1513403256
Ref: library/ipaddress ipaddress IPv6Network network_address13403291
Ref: 3b1613403291
Ref: library/ipaddress ipaddress IPv6Network broadcast_address13403328
Ref: 3b1713403328
Ref: library/ipaddress ipaddress IPv6Network hostmask13403367
Ref: 3b1813403367
Ref: library/ipaddress ipaddress IPv6Network netmask13403397
Ref: 3b1913403397
Ref: library/ipaddress ipaddress IPv6Network with_prefixlen13403426
Ref: 3b1a13403426
Ref: library/ipaddress ipaddress IPv6Network compressed13403462
Ref: 3b1b13403462
Ref: library/ipaddress ipaddress IPv6Network exploded13403494
Ref: 3b1c13403494
Ref: library/ipaddress ipaddress IPv6Network with_netmask13403524
Ref: 3b1d13403524
Ref: library/ipaddress ipaddress IPv6Network with_hostmask13403558
Ref: 3b1e13403558
Ref: library/ipaddress ipaddress IPv6Network num_addresses13403593
Ref: 3b1f13403593
Ref: library/ipaddress ipaddress IPv6Network prefixlen13403628
Ref: 3b2013403628
Ref: library/ipaddress ipaddress IPv6Network hosts13403659
Ref: 3b2113403659
Ref: library/ipaddress ipaddress IPv6Network overlaps13404115
Ref: 3b2213404115
Ref: library/ipaddress ipaddress IPv6Network address_exclude13404156
Ref: 3b2313404156
Ref: library/ipaddress ipaddress IPv6Network subnets13404206
Ref: 3b2413404206
Ref: library/ipaddress ipaddress IPv6Network supernet13404274
Ref: 3b2513404274
Ref: library/ipaddress ipaddress IPv6Network subnet_of13404343
Ref: 3b2613404343
Ref: library/ipaddress ipaddress IPv6Network supernet_of13404385
Ref: 3b2713404385
Ref: library/ipaddress ipaddress IPv6Network compare_networks13404429
Ref: 3b2813404429
Ref: library/ipaddress ipaddress IPv6Network is_site_local13404597
Ref: 3b2913404597
Node: 演算子<4>13404774
Ref: library/ipaddress id113404885
Ref: 3b2a13404885
Node: 論理演算子13405275
Ref: library/ipaddress logical-operators13405369
Ref: 3b2b13405369
Node: イテレーション13405565
Ref: library/ipaddress iteration13405725
Ref: 3b2c13405725
Node: アドレスのコンテナとしてのネットワーク13406570
Ref: library/ipaddress networks-as-containers-of-addresses13406706
Ref: 3b2d13406706
Node: インターフェイスオブジェクト13407250
Ref: library/ipaddress interface-objects13407461
Ref: 3b2e13407461
Ref: library/ipaddress ipaddress IPv4Interface13407683
Ref: 177913407683
Ref: library/ipaddress ipaddress IPv4Interface ip13408103
Ref: 3b2f13408103
Ref: library/ipaddress ipaddress IPv4Interface network13408349
Ref: 3b3013408349
Ref: library/ipaddress ipaddress IPv4Interface with_prefixlen13408606
Ref: 3b3113408606
Ref: library/ipaddress ipaddress IPv4Interface with_netmask13408874
Ref: 3b3213408874
Ref: library/ipaddress ipaddress IPv4Interface with_hostmask13409147
Ref: 3b3313409147
Ref: library/ipaddress ipaddress IPv6Interface13409419
Ref: 177a13409419
Ref: library/ipaddress ipaddress IPv6Interface ip13409839
Ref: 3b3413409839
Ref: library/ipaddress ipaddress IPv6Interface network13409863
Ref: 3b3513409863
Ref: library/ipaddress ipaddress IPv6Interface with_prefixlen13409892
Ref: 3b3613409892
Ref: library/ipaddress ipaddress IPv6Interface with_netmask13409928
Ref: 3b3713409928
Ref: library/ipaddress ipaddress IPv6Interface with_hostmask13409962
Ref: 3b3813409962
Node: 演算子<5>13410156
Ref: library/ipaddress id213410247
Ref: 3b3913410247
Node: 論理演算子<2>13410570
Ref: library/ipaddress id313410637
Ref: 3b3a13410637
Node: その他のモジュールレベル関数13411285
Ref: library/ipaddress other-module-level-functions13411486
Ref: 3b3b13411486
Ref: library/ipaddress ipaddress v4_int_to_packed13411671
Ref: 3b3c13411671
Ref: library/ipaddress ipaddress v6_int_to_packed13412250
Ref: 3b3d13412250
Ref: library/ipaddress ipaddress summarize_address_range13412664
Ref: e6b13412664
Ref: library/ipaddress ipaddress collapse_addresses13413688
Ref: e6c13413688
Ref: library/ipaddress ipaddress get_mixed_type_key13414270
Ref: 3b3e13414270
Node: Custom Exceptions13414992
Ref: library/ipaddress custom-exceptions13415142
Ref: 3b3f13415142
Ref: library/ipaddress ipaddress AddressValueError13415355
Ref: 3ad213415355
Ref: library/ipaddress ipaddress NetmaskValueError13415455
Ref: 3af413415455
Node: マルチメディアサービス13415556
Ref: library/mm doc13415732
Ref: 3b4013415732
Ref: library/mm mmedia13415732
Ref: 3b4113415732
Ref: library/mm multimedia-services13415732
Ref: 3b4213415732
Node: wave --- WAV ファイルの読み書き13416273
Ref: library/wave doc13416426
Ref: 3b4313416426
Ref: library/wave module-wave13416426
Ref: fb13416426
Ref: library/wave wave-read-and-write-wav-files13416426
Ref: 3b4413416426
Ref: library/wave wave open13417046
Ref: 91913417046
Ref: library/wave wave Error13418458
Ref: 3b4713418458
Ref: wave --- WAV ファイルの読み書き-Footnote-113418731
Node: Wave_read オブジェクト13418795
Ref: library/wave id113418938
Ref: 3b4813418938
Ref: library/wave wave-read-objects13418938
Ref: 3b4913418938
Ref: library/wave wave Wave_read13419009
Ref: 29613419009
Ref: library/wave wave Wave_read close13419194
Ref: 3b4513419194
Ref: library/wave wave Wave_read getnchannels13419523
Ref: 3b4a13419523
Ref: library/wave wave Wave_read getsampwidth13419700
Ref: 3b4b13419700
Ref: library/wave wave Wave_read getframerate13419806
Ref: 3b4c13419806
Ref: library/wave wave Wave_read getnframes13419903
Ref: 3b4d13419903
Ref: library/wave wave Wave_read getcomptype13420001
Ref: 3b4e13420001
Ref: library/wave wave Wave_read getcompname13420161
Ref: 3b4f13420161
Ref: library/wave wave Wave_read getparams13420381
Ref: 3b5013420381
Ref: library/wave wave Wave_read readframes13420604
Ref: 3b5113420604
Ref: library/wave wave Wave_read rewind13420791
Ref: 3b5213420791
Ref: library/wave wave Wave_read getmarkers13421058
Ref: 29513421058
Ref: library/wave wave Wave_read getmark13421340
Ref: 29413421340
Ref: library/wave wave Wave_read setpos13421778
Ref: 3b5313421778
Ref: library/wave wave Wave_read tell13421896
Ref: 3b5413421896
Node: Wave_write オブジェクト13422000
Ref: library/wave id213422143
Ref: 3b5513422143
Ref: library/wave wave-write-objects13422143
Ref: fb613422143
Ref: library/wave wave Wave_write13422216
Ref: 29713422216
Ref: library/wave wave Wave_write close13423301
Ref: 3b4613423301
Ref: library/wave wave Wave_write setnchannels13423791
Ref: 3b5813423791
Ref: library/wave wave Wave_write setsampwidth13423883
Ref: 3b5913423883
Ref: library/wave wave Wave_write setframerate13423995
Ref: 3b5a13423995
Ref: library/wave wave Wave_write setnframes13424269
Ref: 3b5613424269
Ref: library/wave wave Wave_write setcomptype13424599
Ref: 3b5b13424599
Ref: library/wave wave Wave_write setparams13424824
Ref: 3b5713424824
Ref: library/wave wave Wave_write tell13425059
Ref: 3b5c13425059
Ref: library/wave wave Wave_write writeframesraw13425329
Ref: fb713425329
Ref: library/wave wave Wave_write writeframes13425610
Ref: fb813425610
Node: colorsys --- 色体系間の変換13426362
Ref: library/colorsys doc13426515
Ref: 3b5d13426515
Ref: library/colorsys colorsys-conversions-between-color-systems13426515
Ref: 3b5e13426515
Ref: library/colorsys module-colorsys13426515
Ref: 1813426515
Ref: library/colorsys colorsys rgb_to_yiq13427509
Ref: 3b5f13427509
Ref: library/colorsys colorsys yiq_to_rgb13427598
Ref: 3b6013427598
Ref: library/colorsys colorsys rgb_to_hls13427687
Ref: 166713427687
Ref: library/colorsys colorsys hls_to_rgb13427776
Ref: 3b6113427776
Ref: library/colorsys colorsys rgb_to_hsv13427865
Ref: 3b6213427865
Ref: library/colorsys colorsys hsv_to_rgb13427954
Ref: 3b6313427954
Ref: colorsys --- 色体系間の変換-Footnote-113428271
Node: 国際化13428339
Ref: library/i18n doc13428503
Ref: 3b6413428503
Ref: library/i18n i18n13428503
Ref: 3b6513428503
Ref: library/i18n internationalization13428503
Ref: 3b6613428503
Node: gettext --- 多言語国際化サービス13429051
Ref: library/gettext doc13429180
Ref: 3b6713429180
Ref: library/gettext gettext-multilingual-internationalization-services13429180
Ref: 3b6813429180
Ref: library/gettext module-gettext13429180
Ref: 5913429180
Ref: gettext --- 多言語国際化サービス-Footnote-113430423
Node: GNU gettext API13430490
Ref: library/gettext gnu-gettext-api13430615
Ref: 3b6913430615
Ref: library/gettext gettext bindtextdomain13431328
Ref: 3b6a13431328
Ref: library/gettext gettext textdomain13432074
Ref: 3b6b13432074
Ref: library/gettext gettext gettext13432470
Ref: 140e13432470
Ref: library/gettext gettext dgettext13432740
Ref: 3b6c13432740
Ref: library/gettext gettext ngettext13432912
Ref: 3b6d13432912
Ref: library/gettext gettext dngettext13433879
Ref: 3b6e13433879
Ref: library/gettext gettext pgettext13434065
Ref: 9c313434065
Ref: library/gettext gettext dpgettext13434117
Ref: 3b6f13434117
Ref: library/gettext gettext npgettext13434178
Ref: 3b7013434178
Ref: library/gettext gettext dnpgettext13434243
Ref: 3b7113434243
Ref: GNU gettext API-Footnote-113435073
Ref: GNU gettext API-Footnote-213435553
Node: クラス形式の API13435618
Ref: library/gettext class-based-api13435803
Ref: 3b7213435803
Ref: library/gettext gettext find13436341
Ref: 3b7413436341
Ref: library/gettext gettext translation13438223
Ref: a4713438223
Ref: library/gettext gettext install13439753
Ref: a4813439753
Ref: クラス形式の API-Footnote-113440846
Node: NullTranslations クラス13440941
Ref: library/gettext the-nulltranslations-class13441060
Ref: 3b7713441060
Ref: library/gettext gettext NullTranslations13441660
Ref: 3b7513441660
Ref: library/gettext gettext NullTranslations _parse13442313
Ref: 3b7913442313
Ref: library/gettext gettext NullTranslations add_fallback13442875
Ref: 3b7813442875
Ref: library/gettext gettext NullTranslations gettext13443264
Ref: 3b7a13443264
Ref: library/gettext gettext NullTranslations ngettext13443614
Ref: 3b7b13443614
Ref: library/gettext gettext NullTranslations pgettext13444011
Ref: 3b7c13444011
Ref: library/gettext gettext NullTranslations npgettext13444384
Ref: 3b7d13444384
Ref: library/gettext gettext NullTranslations info13444772
Ref: 3b7e13444772
Ref: library/gettext gettext NullTranslations charset13444904
Ref: 3b7f13444904
Ref: library/gettext gettext NullTranslations install13445035
Ref: 3b7613445035
Node: GNUTranslations クラス13446311
Ref: library/gettext the-gnutranslations-class13446495
Ref: 3b8013446495
Ref: library/gettext gettext GNUTranslations13448130
Ref: 3b7313448130
Ref: library/gettext gettext GNUTranslations gettext13448268
Ref: 3b8113448268
Ref: library/gettext gettext GNUTranslations ngettext13448807
Ref: 3b8213448807
Ref: library/gettext gettext GNUTranslations pgettext13449925
Ref: 3b8313449925
Ref: library/gettext gettext GNUTranslations npgettext13450545
Ref: 3b8413450545
Ref: GNUTranslations クラス-Footnote-113451400
Node: Solaris メッセージカタログ機構のサポート13451458
Ref: library/gettext solaris-message-catalog-support13451645
Ref: 3b8513451645
Node: Catalog コンストラクタ13452022
Ref: library/gettext the-catalog-constructor13452175
Ref: 3b8613452175
Node: プログラムやモジュールを国際化する13453084
Ref: library/gettext i18n-howto13453263
Ref: 2c1713453263
Ref: library/gettext internationalizing-your-programs-and-modules13453263
Ref: 3b8713453263
Ref: プログラムやモジュールを国際化する-Footnote-113457897
Ref: プログラムやモジュールを国際化する-Footnote-213457930
Node: モジュールを地域化する13457973
Ref: library/gettext localizing-your-module13458145
Ref: 3b8813458145
Node: アプリケーションを地域化する13458889
Ref: library/gettext localizing-your-application13459118
Ref: 3b8913459118
Node: 動作中 on the fly に言語を切り替える13459912
Ref: library/gettext changing-languages-on-the-fly13460135
Ref: 3b8a13460135
Node: 翻訳処理の遅延解決13460912
Ref: library/gettext deferred-translations13461084
Ref: 3b8b13461084
Node: 謝辞<9>13463545
Ref: library/gettext acknowledgements13463693
Ref: 3b8c13463693
Node: locale --- 国際化サービス13464124
Ref: library/locale doc13464253
Ref: 3b8d13464253
Ref: library/locale locale-internationalization-services13464253
Ref: 3b8e13464253
Ref: library/locale module-locale13464253
Ref: 7a13464253
Ref: library/locale locale Error13465080
Ref: 3b8f13465080
Ref: library/locale locale setlocale13465227
Ref: 2bd13465227
Ref: library/locale locale localeconv13466661
Ref: bcc13466661
Ref: library/locale locale nl_langinfo13475069
Ref: 3b9313475069
Ref: library/locale locale CODESET13475686
Ref: 3b9413475686
Ref: library/locale locale D_T_FMT13475868
Ref: 3b9513475868
Ref: library/locale locale D_FMT13476123
Ref: 3b9613476123
Ref: library/locale locale T_FMT13476367
Ref: 3b9713476367
Ref: library/locale locale T_FMT_AMPM13476611
Ref: 3b9813476611
Ref: library/locale locale DAY_113476857
Ref: 3b9913476857
Ref: library/locale locale DAY_213476890
Ref: 3b9a13476890
Ref: library/locale locale DAY_313476923
Ref: 3b9b13476923
Ref: library/locale locale DAY_413476956
Ref: 3b9c13476956
Ref: library/locale locale DAY_513476989
Ref: 3b9d13476989
Ref: library/locale locale DAY_613477022
Ref: 3b9e13477022
Ref: library/locale locale DAY_713477055
Ref: 3b9f13477055
Ref: library/locale locale ABDAY_113477403
Ref: 3ba013477403
Ref: library/locale locale ABDAY_213477438
Ref: 3ba113477438
Ref: library/locale locale ABDAY_313477473
Ref: 3ba213477473
Ref: library/locale locale ABDAY_413477508
Ref: 3ba313477508
Ref: library/locale locale ABDAY_513477543
Ref: 3ba413477543
Ref: library/locale locale ABDAY_613477578
Ref: 3ba513477578
Ref: library/locale locale ABDAY_713477613
Ref: 3ba613477613
Ref: library/locale locale MON_113477732
Ref: 3ba713477732
Ref: library/locale locale MON_213477765
Ref: 3ba813477765
Ref: library/locale locale MON_313477798
Ref: 3ba913477798
Ref: library/locale locale MON_413477831
Ref: 3baa13477831
Ref: library/locale locale MON_513477864
Ref: 3bab13477864
Ref: library/locale locale MON_613477897
Ref: 3bac13477897
Ref: library/locale locale MON_713477930
Ref: 3bad13477930
Ref: library/locale locale MON_813477963
Ref: 3bae13477963
Ref: library/locale locale MON_913477996
Ref: 3baf13477996
Ref: library/locale locale MON_1013478029
Ref: 3bb013478029
Ref: library/locale locale MON_1113478063
Ref: 3bb113478063
Ref: library/locale locale MON_1213478097
Ref: 3bb213478097
Ref: library/locale locale ABMON_113478188
Ref: 3bb313478188
Ref: library/locale locale ABMON_213478223
Ref: 3bb413478223
Ref: library/locale locale ABMON_313478258
Ref: 3bb513478258
Ref: library/locale locale ABMON_413478293
Ref: 3bb613478293
Ref: library/locale locale ABMON_513478328
Ref: 3bb713478328
Ref: library/locale locale ABMON_613478363
Ref: 3bb813478363
Ref: library/locale locale ABMON_713478398
Ref: 3bb913478398
Ref: library/locale locale ABMON_813478433
Ref: 3bba13478433
Ref: library/locale locale ABMON_913478468
Ref: 3bbb13478468
Ref: library/locale locale ABMON_1013478503
Ref: 3bbc13478503
Ref: library/locale locale ABMON_1113478539
Ref: 3bbd13478539
Ref: library/locale locale ABMON_1213478575
Ref: 3bbe13478575
Ref: library/locale locale RADIXCHAR13478683
Ref: 3bbf13478683
Ref: library/locale locale THOUSEP13478824
Ref: 3bc013478824
Ref: library/locale locale YESEXPR13478978
Ref: 3bc113478978
Ref: library/locale locale NOEXPR13479187
Ref: 3bc213479187
Ref: library/locale locale CRNCYSTR13479651
Ref: 3bc313479651
Ref: library/locale locale ERA13479954
Ref: 3bc413479954
Ref: library/locale locale ERA_D_T_FMT13480797
Ref: 3bc513480797
Ref: library/locale locale ERA_D_FMT13481084
Ref: 3bc613481084
Ref: library/locale locale ERA_T_FMT13481353
Ref: 3bc713481353
Ref: library/locale locale ALT_DIGITS13481622
Ref: 3bc813481622
Ref: library/locale locale getdefaultlocale13481862
Ref: 2bb13481862
Ref: library/locale locale getlocale13483400
Ref: 2bc13483400
Ref: library/locale locale getpreferredencoding13483917
Ref: 50413483917
Ref: library/locale locale getencoding13485336
Ref: 2be13485336
Ref: library/locale locale normalize13486111
Ref: 3bcc13486111
Ref: library/locale locale strcoll13486728
Ref: 3bcd13486728
Ref: library/locale locale strxfrm13487138
Ref: 3bcf13487138
Ref: library/locale locale format_string13487556
Ref: 4e813487556
Ref: library/locale locale currency13488319
Ref: 3bd013488319
Ref: library/locale locale str13489152
Ref: 3bd113489152
Ref: library/locale locale delocalize13489342
Ref: df213489342
Ref: library/locale locale localize13489553
Ref: 3bd213489553
Ref: library/locale locale atof13489774
Ref: 3bd313489774
Ref: library/locale locale atoi13489999
Ref: 3bd413489999
Ref: library/locale locale LC_CTYPE13490149
Ref: 3bca13490149
Ref: library/locale locale LC_COLLATE13490821
Ref: 3bce13490821
Ref: library/locale locale LC_TIME13491069
Ref: 3bd513491069
Ref: library/locale locale LC_MONETARY13491277
Ref: 3b9213491277
Ref: library/locale locale LC_MESSAGES13491507
Ref: 3bd613491507
Ref: library/locale locale LC_NUMERIC13492093
Ref: 3b9013492093
Ref: library/locale locale LC_ALL13492421
Ref: 3bc913492421
Ref: library/locale locale CHAR_MAX13493055
Ref: 3b9113493055
Ref: locale --- 国際化サービス-Footnote-113493966
Ref: locale --- 国際化サービス-Footnote-213494032
Ref: locale --- 国際化サービス-Footnote-313494091
Ref: locale --- 国際化サービス-Footnote-413494150
Ref: locale --- 国際化サービス-Footnote-513494192
Node: ロケールの背景、詳細、ヒント、助言および補足説明13494234
Ref: library/locale background-details-hints-tips-and-caveats13494470
Ref: 3bd713494470
Node: Python 拡張の作者と、Python を埋め込むようなプログラムに関して13497370
Ref: library/locale embedding-locale13497660
Ref: 3bd813497660
Ref: library/locale for-extension-writers-and-programs-that-embed-python13497660
Ref: 3bd913497660
Node: メッセージカタログへのアクセス13498596
Ref: library/locale access-to-message-catalogs13498805
Ref: 3bda13498805
Ref: library/locale locale-gettext13498805
Ref: 3bdb13498805
Ref: library/locale locale gettext13498901
Ref: 3bdc13498901
Ref: library/locale locale dgettext13498938
Ref: 3bdd13498938
Ref: library/locale locale dcgettext13498984
Ref: 3bde13498984
Ref: library/locale locale textdomain13499041
Ref: 3bdf13499041
Ref: library/locale locale bindtextdomain13499084
Ref: 3be013499084
Ref: library/locale locale bind_textdomain_codeset13499136
Ref: 3be113499136
Node: プログラムのフレームワーク13500346
Ref: library/frameworks doc13500546
Ref: 3be213500546
Ref: library/frameworks frameworks13500546
Ref: 3be313500546
Ref: library/frameworks program-frameworks13500546
Ref: 3be413500546
Node: turtle --- タートルグラフィックス13501269
Ref: library/turtle doc13501469
Ref: 3be513501469
Ref: library/turtle module-turtle13501469
Ref: ea13501469
Ref: library/turtle turtle-turtle-graphics13501469
Ref: 3be613501469
Ref: turtle --- タートルグラフィックス-Footnote-113502254
Node: はじめに<9>13502320
Ref: library/turtle introduction13502436
Ref: 3be713502436
Ref: はじめに<9>-Footnote-113502686
Node: Get started13502739
Ref: library/turtle get-started13502888
Ref: 3be813502888
Node: チュートリアル<3>13504134
Ref: library/turtle turtle-tutorial13504274
Ref: 3be913504274
Ref: library/turtle tutorial13504274
Ref: 3bea13504274
Node: Starting a turtle environment13504524
Ref: library/turtle starting-a-turtle-environment13504636
Ref: 3beb13504636
Node: Basic drawing13504947
Ref: library/turtle basic-drawing13505095
Ref: 3bec13505095
Node: Pen の制御13505732
Ref: library/turtle pen-control13505825
Ref: 3bed13505825
Node: The turtle's position13506154
Ref: library/turtle the-turtle-s-position13506247
Ref: 3bee13506247
Node: Making algorithmic patterns13506684
Ref: library/turtle making-algorithmic-patterns13506794
Ref: 3bef13506794
Node: How to13507765
Ref: library/turtle how-to13507919
Ref: 3bf013507919
Ref: library/turtle turtle-how-to13507919
Ref: 3bf113507919
Node: Get started as quickly as possible13508186
Ref: library/turtle get-started-as-quickly-as-possible13508303
Ref: 3bf213508303
Ref: library/turtle note13509053
Ref: 3bf413509053
Node: Use the turtle module namespace13509321
Ref: library/turtle use-the-turtle-module-namespace13509478
Ref: 3bf513509478
Node: Use turtle graphics in a script13510138
Ref: library/turtle use-turtle-graphics-in-a-script13510296
Ref: 3bf613510296
Node: Use object-oriented turtle graphics13510986
Ref: library/turtle use-object-oriented-turtle-graphics13511104
Ref: 3bf713511104
Node: Turtle graphics reference13512322
Ref: library/turtle turtle-graphics-reference13512505
Ref: 3bfa13512505
Node: Turtle のメソッド13512870
Ref: library/turtle turtle-methods13512998
Ref: 3bfb13512998
Node: TurtleScreen/Screen のメソッド13516077
Ref: library/turtle methods-of-turtlescreen-screen13516205
Ref: 3c4813516205
Node: RawTurtle/Turtle のメソッドと対応する関数13517587
Ref: library/turtle methods-of-rawturtle-turtle-and-corresponding-functions13517820
Ref: 3c6713517820
Node: Turtle の動き13518283
Ref: library/turtle turtle-motion13518423
Ref: 3c6813518423
Ref: library/turtle turtle forward13518475
Ref: 3bf313518475
Ref: library/turtle turtle fd13518516
Ref: 3bfc13518516
Ref: library/turtle turtle back13518985
Ref: 3bff13518985
Ref: library/turtle turtle bk13519023
Ref: 3bfe13519023
Ref: library/turtle turtle backward13519059
Ref: 3bfd13519059
Ref: library/turtle turtle right13519468
Ref: 3c0013519468
Ref: library/turtle turtle rt13519504
Ref: 3c0113519504
Ref: library/turtle turtle left13520091
Ref: 3c0213520091
Ref: library/turtle turtle lt13520126
Ref: 3c0313520126
Ref: library/turtle turtle goto13520711
Ref: 3c0413520711
Ref: library/turtle turtle setpos13520750
Ref: 3c0513520750
Ref: library/turtle turtle setposition13520791
Ref: 3c0613520791
Ref: library/turtle turtle teleport13521646
Ref: 168d13521646
Ref: library/turtle turtle setx13522661
Ref: 3c0713522661
Ref: library/turtle turtle sety13523004
Ref: 3c0813523004
Ref: library/turtle turtle setheading13523346
Ref: 3c0913523346
Ref: library/turtle turtle seth13523390
Ref: 3c0a13523390
Ref: library/turtle turtle home13524262
Ref: 3c0b13524262
Ref: library/turtle turtle circle13524740
Ref: 3c0c13524740
Ref: library/turtle turtle dot13526283
Ref: 3c0d13526283
Ref: library/turtle turtle stamp13526919
Ref: 3c0e13526919
Ref: library/turtle turtle clearstamp13527348
Ref: 3c0f13527348
Ref: library/turtle turtle clearstamps13527911
Ref: 3c1013527911
Ref: library/turtle turtle undo13528514
Ref: 3c1113528514
Ref: library/turtle turtle speed13528906
Ref: 3c1213528906
Node: Turtle の状態を知る13530170
Ref: library/turtle tell-turtle-s-state13530334
Ref: 3c6a13530334
Ref: library/turtle turtle position13530401
Ref: 3c1313530401
Ref: library/turtle turtle pos13530435
Ref: 3c1413530435
Ref: library/turtle turtle towards13530623
Ref: 3c1513530623
Ref: library/turtle turtle xcor13531197
Ref: 3c1613531197
Ref: library/turtle turtle ycor13531485
Ref: 3c1713531485
Ref: library/turtle turtle heading13531780
Ref: 3c1813531780
Ref: library/turtle turtle distance13532094
Ref: 3c1913532094
Node: 設定と計測13532792
Ref: library/turtle settings-for-measurement13532956
Ref: 3c6b13532956
Ref: library/turtle turtle degrees13533004
Ref: 3c1a13533004
Ref: library/turtle turtle radians13533679
Ref: 3c1b13533679
Node: Pen の制御<2>13534023
Ref: library/turtle id113534183
Ref: 3c6c13534183
Node: 描画状態13534341
Ref: library/turtle drawing-state13534430
Ref: 3c6d13534430
Ref: library/turtle turtle pendown13534473
Ref: 3c1c13534473
Ref: library/turtle turtle pd13534506
Ref: 3c1d13534506
Ref: library/turtle turtle down13534534
Ref: 3c1e13534534
Ref: library/turtle turtle penup13534632
Ref: 3c1f13534632
Ref: library/turtle turtle pu13534663
Ref: 3c2013534663
Ref: library/turtle turtle up13534691
Ref: 3c2113534691
Ref: library/turtle turtle pensize13534790
Ref: 3c2213534790
Ref: library/turtle turtle width13534833
Ref: 3c2313534833
Ref: library/turtle turtle pen13535337
Ref: 3c2413535337
Ref: library/turtle turtle isdown13537261
Ref: 3c2513537261
Node: 色の制御<2>13537562
Ref: library/turtle color-control13537675
Ref: 3c6e13537675
Ref: library/turtle turtle pencolor13537718
Ref: 3c2713537718
Ref: library/turtle turtle fillcolor13539600
Ref: 3c2813539600
Ref: library/turtle turtle color13541425
Ref: 3c2613541425
Node: 塗りつぶし13542908
Ref: library/turtle filling13543036
Ref: 3c6f13543036
Ref: library/turtle turtle filling13543084
Ref: 3c2913543084
Ref: library/turtle turtle begin_fill13543344
Ref: 3c2a13543344
Ref: library/turtle turtle end_fill13543442
Ref: 3c2b13543442
Node: さらなる描画の制御13544030
Ref: library/turtle more-drawing-control13544134
Ref: 3c7013544134
Ref: library/turtle turtle reset13544202
Ref: 3c2c13544202
Ref: library/turtle turtle clear13544705
Ref: 3c2d13544705
Ref: library/turtle turtle write13544975
Ref: 3c2e13544975
Node: タートルの状態13545805
Ref: library/turtle turtle-state13545977
Ref: 3c7113545977
Node: 可視性13546073
Ref: library/turtle visibility13546158
Ref: 3c7213546158
Ref: library/turtle turtle hideturtle13546196
Ref: 3c3113546196
Ref: library/turtle turtle ht13546232
Ref: 3c3213546232
Ref: library/turtle turtle showturtle13546560
Ref: 3c2f13546560
Ref: library/turtle turtle st13546596
Ref: 3c3013546596
Ref: library/turtle turtle isvisible13546712
Ref: 3c3313546712
Node: 見た目13547042
Ref: library/turtle appearance13547127
Ref: 3c7313547127
Ref: library/turtle turtle shape13547165
Ref: 3c3413547165
Ref: library/turtle turtle resizemode13547961
Ref: 3c3513547961
Ref: library/turtle turtle shapesize13549069
Ref: 3c3613549069
Ref: library/turtle turtle turtlesize13549162
Ref: 3c3713549162
Ref: library/turtle turtle shearfactor13550280
Ref: 3c3813550280
Ref: library/turtle turtle tilt13550946
Ref: 3c3913550946
Ref: library/turtle turtle tiltangle13551420
Ref: 6f013551420
Ref: library/turtle turtle shapetransform13552144
Ref: 3c3a13552144
Ref: library/turtle turtle get_shapepoly13553174
Ref: 3c3b13553174
Node: イベントを利用する13553546
Ref: library/turtle using-events13553734
Ref: 3c7413553734
Ref: library/turtle turtle onrelease13554791
Ref: 3c3d13554791
Ref: library/turtle turtle ondrag13555947
Ref: 3c3e13555947
Node: 特別な Turtle のメソッド13557049
Ref: library/turtle special-turtle-methods13557231
Ref: 3c7513557231
Ref: library/turtle turtle begin_poly13557310
Ref: 3c3f13557310
Ref: library/turtle turtle end_poly13557462
Ref: 3c4013557462
Ref: library/turtle turtle get_poly13557663
Ref: 3c4113557663
Ref: library/turtle turtle clone13558084
Ref: 3c4213558084
Ref: library/turtle turtle getturtle13558310
Ref: 3c4313558310
Ref: library/turtle turtle getpen13558345
Ref: 3c4413558345
Ref: library/turtle turtle getscreen13558648
Ref: 3c4513558648
Ref: library/turtle turtle setundobuffer13559029
Ref: 3c4613559029
Ref: library/turtle turtle undobufferentries13559599
Ref: 3c4713559599
Node: Compound shapes13559780
Ref: library/turtle compound-shapes13559926
Ref: 3c7713559926
Ref: library/turtle compoundshapes13559926
Ref: 3c7813559926
Node: TurtleScreen/Screen のメソッドと対応する関数13561174
Ref: library/turtle methods-of-turtlescreen-screen-and-corresponding-functions13561396
Ref: 3c7b13561396
Node: ウィンドウの制御13561898
Ref: library/turtle window-control13562054
Ref: 3c7c13562054
Ref: library/turtle turtle bgcolor13562117
Ref: 3c4913562117
Ref: library/turtle turtle bgpic13562574
Ref: 3c4a13562574
Ref: library/turtle turtle clearscreen13563602
Ref: 3c4b13563602
Ref: library/turtle turtle resetscreen13564230
Ref: 3c4c13564230
Ref: library/turtle turtle screensize13564371
Ref: 3c4d13564371
Ref: library/turtle turtle setworldcoordinates13565558
Ref: 3c4e13565558
Node: アニメーションの制御13566574
Ref: library/turtle animation-control13566781
Ref: 3c7d13566781
Ref: library/turtle turtle delay13566854
Ref: 3c4f13566854
Ref: library/turtle turtle tracer13567355
Ref: 3c5013567355
Ref: library/turtle turtle update13568185
Ref: 3c5113568185
Node: スクリーンイベントを利用する13568402
Ref: library/turtle using-screen-events13568603
Ref: 3c7e13568603
Ref: library/turtle turtle listen13568696
Ref: 3c5213568696
Ref: library/turtle turtle onkey13568978
Ref: 3c5313568978
Ref: library/turtle turtle onkeyrelease13569017
Ref: 3c5413569017
Ref: library/turtle turtle onkeypress13569786
Ref: 3c5513569786
Ref: library/turtle turtle onclick13570400
Ref: 3c3c13570400
Ref: library/turtle turtle onscreenclick13570453
Ref: 3c5613570453
Ref: library/turtle turtle ontimer13571865
Ref: 3c5713571865
Ref: library/turtle turtle mainloop13572354
Ref: 3c5813572354
Ref: library/turtle turtle done13572388
Ref: 3c5913572388
Node: 入力メソッド13572713
Ref: library/turtle input-methods13572914
Ref: 3c7f13572914
Ref: library/turtle turtle textinput13572967
Ref: 182d13572967
Ref: library/turtle turtle numinput13573423
Ref: 182e13573423
Node: 設定と特殊なメソッド13574342
Ref: library/turtle settings-and-special-methods13574575
Ref: 3c8013574575
Ref: library/turtle turtle mode13574648
Ref: 3c5a13574648
Ref: library/turtle turtle colormode13576034
Ref: 3c5b13576034
Ref: library/turtle turtle getcanvas13576773
Ref: 3c5c13576773
Ref: library/turtle turtle getshapes13577057
Ref: 3c5d13577057
Ref: library/turtle turtle register_shape13577275
Ref: 3c5e13577275
Ref: library/turtle turtle addshape13577331
Ref: 3c5f13577331
Ref: library/turtle turtle turtles13578410
Ref: 3c6013578410
Ref: library/turtle turtle window_height13578599
Ref: 3c6113578599
Ref: library/turtle turtle window_width13578752
Ref: 3c6213578752
Node: Screen 独自のメソッド、TurtleScreen から継承したもの以外13578900
Ref: library/turtle methods-specific-to-screen-not-inherited-from-turtlescreen13579106
Ref: 3c8113579106
Ref: library/turtle screenspecific13579106
Ref: 3c8213579106
Ref: library/turtle turtle bye13579259
Ref: 3c6313579259
Ref: library/turtle turtle exitonclick13579381
Ref: 3c6413579381
Ref: library/turtle turtle setup13579999
Ref: 3c6513579999
Ref: library/turtle turtle title13581520
Ref: 3c6613581520
Node: Public classes13581844
Ref: library/turtle public-classes13582022
Ref: 3c8313582022
Ref: library/turtle turtle RawTurtle13582073
Ref: 3c8413582073
Ref: library/turtle turtle RawPen13582114
Ref: 3c8513582114
Ref: library/turtle turtle Turtle13582441
Ref: 3c8713582441
Ref: library/turtle turtle TurtleScreen13582689
Ref: 3c7613582689
Ref: library/turtle turtle Screen13582912
Ref: 3bf913582912
Ref: library/turtle turtle ScrolledCanvas13583049
Ref: 3c8613583049
Ref: library/turtle turtle Shape13583414
Ref: 3c7913583414
Ref: library/turtle turtle Shape addcomponent13584280
Ref: 3c7a13584280
Ref: library/turtle turtle Vec2D13584899
Ref: 3c6913584899
Node: 説明<2>13585553
Ref: library/turtle explanation13585693
Ref: 3c8813585693
Ref: library/turtle turtle-explanation13585693
Ref: 3bf813585693
Node: ヘルプと設定13587109
Ref: library/turtle help-and-configuration13587271
Ref: 3c8913587271
Node: ヘルプの使い方13587445
Ref: library/turtle how-to-use-help13587566
Ref: 3c8a13587566
Node: ドキュメント文字列の翻訳13590115
Ref: library/turtle translation-of-docstrings-into-different-languages13590284
Ref: 3c8b13590284
Ref: library/turtle turtle write_docstringdict13590565
Ref: 3c8c13590565
Node: Screen および Turtle の設定方法13592063
Ref: library/turtle how-to-configure-screen-and-turtles13592202
Ref: 3c8d13592202
Node: turtledemo --- デモスクリプト13595549
Ref: library/turtle module-turtledemo13595730
Ref: eb13595730
Ref: library/turtle turtledemo-demo-scripts13595730
Ref: 3c8e13595730
Node: python 2 6からの変更点13601799
Ref: library/turtle changes-since-python-2-613601990
Ref: 3c8f13601990
Node: python 3 0からの変更点13603030
Ref: library/turtle changes-since-python-3-013603176
Ref: 3c9013603176
Node: cmd --- 行指向のコマンドインタープリターのサポート13604432
Ref: library/cmd doc13604672
Ref: 3c9113604672
Ref: library/cmd cmd-support-for-line-oriented-command-interpreters13604672
Ref: 3c9213604672
Ref: library/cmd module-cmd13604672
Ref: 1213604672
Ref: library/cmd cmd Cmd13605291
Ref: 162b13605291
Ref: cmd --- 行指向のコマンドインタープリターのサポート-Footnote-113607278
Node: Cmdオブジェクト13607341
Ref: library/cmd cmd-objects13607489
Ref: 3c9413607489
Ref: library/cmd id113607489
Ref: 3c9513607489
Ref: library/cmd cmd Cmd cmdloop13607623
Ref: 3c9613607623
Ref: library/cmd cmd Cmd do_help13609937
Ref: 161813609937
Ref: library/cmd cmd Cmd onecmd13610476
Ref: 3c9913610476
Ref: library/cmd cmd Cmd emptyline13611073
Ref: 3c9c13611073
Ref: library/cmd cmd Cmd default13611359
Ref: 3c9b13611359
Ref: library/cmd cmd Cmd completedefault13611644
Ref: 3c9d13611644
Ref: library/cmd cmd Cmd columnize13611872
Ref: 17d113611872
Ref: library/cmd cmd Cmd precmd13612114
Ref: 3c9a13612114
Ref: library/cmd cmd Cmd postcmd13612771
Ref: 3c9813612771
Ref: library/cmd cmd Cmd preloop13613474
Ref: 3c9e13613474
Ref: library/cmd cmd Cmd postloop13613775
Ref: 3c9f13613775
Ref: library/cmd cmd Cmd prompt13614203
Ref: 3ca013614203
Ref: library/cmd cmd Cmd identchars13614297
Ref: 3ca113614297
Ref: library/cmd cmd Cmd lastcmd13614413
Ref: 3ca213614413
Ref: library/cmd cmd Cmd cmdqueue13614493
Ref: 3ca313614493
Ref: library/cmd cmd Cmd intro13614846
Ref: 3c9713614846
Ref: library/cmd cmd Cmd doc_header13615082
Ref: 3ca413615082
Ref: library/cmd cmd Cmd misc_header13615234
Ref: 3ca513615234
Ref: library/cmd cmd Cmd undoc_header13615453
Ref: 3ca613615453
Ref: library/cmd cmd Cmd ruler13615669
Ref: 3ca713615669
Ref: library/cmd cmd Cmd use_rawinput13615919
Ref: 3c9313615919
Node: Cmd の例13616395
Ref: library/cmd cmd-example13616543
Ref: 3ca813616543
Ref: library/cmd id213616543
Ref: 3ca913616543
Node: shlex --- 単純な字句解析13621963
Ref: library/shlex doc13622150
Ref: 3caa13622150
Ref: library/shlex module-shlex13622150
Ref: b213622150
Ref: library/shlex shlex-simple-lexical-analysis13622150
Ref: 3cab13622150
Ref: library/shlex shlex split13622715
Ref: 50613622715
Ref: library/shlex shlex join13623408
Ref: 9f513623408
Ref: library/shlex shlex quote13623867
Ref: 25e13623867
Ref: library/shlex shlex-quote-warning13624149
Ref: 30c213624149
Ref: library/shlex shlex shlex13625871
Ref: c9b13625871
Ref: shlex --- 単純な字句解析-Footnote-113628141
Node: shlex オブジェクト13628206
Ref: library/shlex id113628319
Ref: 3caf13628319
Ref: library/shlex shlex-objects13628319
Ref: 3cb013628319
Ref: library/shlex shlex shlex get_token13628466
Ref: 3cb113628466
Ref: library/shlex shlex shlex push_token13629004
Ref: 3cb213629004
Ref: library/shlex shlex shlex read_token13629122
Ref: 3cb413629122
Ref: library/shlex shlex shlex sourcehook13629460
Ref: 3cb513629460
Ref: library/shlex shlex shlex push_source13631626
Ref: 3cb713631626
Ref: library/shlex shlex shlex pop_source13632017
Ref: 3cb813632017
Ref: library/shlex shlex shlex error_leader13632296
Ref: 3cb913632296
Ref: library/shlex shlex shlex commenters13633232
Ref: 3cac13633232
Ref: library/shlex shlex shlex wordchars13633499
Ref: 3cae13633499
Ref: library/shlex shlex shlex whitespace13634195
Ref: 3cbb13634195
Ref: library/shlex shlex shlex escape13634472
Ref: 3cbc13634472
Ref: library/shlex shlex shlex quotes13634679
Ref: 3cbd13634679
Ref: library/shlex shlex shlex escapedquotes13635096
Ref: 3cbe13635096
Ref: library/shlex shlex shlex whitespace_split13635384
Ref: 3cba13635384
Ref: library/shlex shlex shlex infile13635929
Ref: 3cad13635929
Ref: library/shlex shlex shlex instream13636250
Ref: 3cbf13636250
Ref: library/shlex shlex shlex source13636393
Ref: 3cb613636393
Ref: library/shlex shlex shlex debug13637211
Ref: 3cc013637211
Ref: library/shlex shlex shlex lineno13637576
Ref: 3cc113637576
Ref: library/shlex shlex shlex token13637691
Ref: 3cc213637691
Ref: library/shlex shlex shlex eof13637849
Ref: 3cb313637849
Ref: library/shlex shlex shlex punctuation_chars13638066
Ref: 193c13638066
Node: 解析規則13638473
Ref: library/shlex parsing-rules13638629
Ref: 3cc313638629
Ref: library/shlex shlex-parsing-rules13638629
Ref: 3cc413638629
Node: Improved Compatibility with Shells13640797
Ref: library/shlex improved-compatibility-with-shells13640920
Ref: 3cc513640920
Ref: library/shlex improved-shell-compatibility13640920
Ref: c9c13640920
Node: Tk を用いたグラフィカルユーザーインターフェース13643755
Ref: library/tk doc13643961
Ref: 3cc613643961
Ref: library/tk graphical-user-interfaces-with-tk13643961
Ref: 3cc713643961
Ref: library/tk tkinter13643961
Ref: 3cc813643961
Ref: Tk を用いたグラフィカルユーザーインターフェース-Footnote-113646469
Node: tkinter --- Tcl/Tk の Python インターフェース13646521
Ref: library/tkinter doc13646745
Ref: 3cc913646745
Ref: library/tkinter module-tkinter13646745
Ref: d913646745
Ref: library/tkinter tkinter-python-interface-to-tcl-tk13646745
Ref: 3cca13646745
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-113649905
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-213649982
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-313650010
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-413650050
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-513650107
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-613650134
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-713650171
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-813650269
Ref: tkinter --- Tcl/Tk の Python インターフェース-Footnote-913650321
Node: Architecture13650380
Ref: library/tkinter architecture13650515
Ref: 3ccb13650515
Ref: Architecture-Footnote-113652839
Node: Tkinter モジュール13652879
Ref: library/tkinter tkinter-modules13653046
Ref: 3ccd13653046
Ref: library/tkinter tkinter Tk13653384
Ref: 159a13653384
Ref: library/tkinter tkinter Tk tk13655534
Ref: 3ccf13655534
Ref: library/tkinter tkinter Tk master13655833
Ref: 3cd013655833
Ref: library/tkinter tkinter Tk children13656403
Ref: 3cd113656403
Ref: library/tkinter tkinter Tcl13656613
Ref: 3cce13656613
Ref: library/tkinter module-_tkinter13658637
Ref: 313658637
Node: Tkinter お助け手帳13659593
Ref: library/tkinter tkinter-life-preserver13659763
Ref: 3cd213659763
Node: A Hello World Program13660616
Ref: library/tkinter a-hello-world-program13660727
Ref: 3cd313660727
Node: Important Tk Concepts13662180
Ref: library/tkinter important-tk-concepts13662338
Ref: 3cd413662338
Node: Understanding How Tkinter Wraps Tcl/Tk13663680
Ref: library/tkinter understanding-how-tkinter-wraps-tcl-tk13663846
Ref: 3cd513663846
Node: How do I ? What option does ?13665987
Ref: library/tkinter how-do-i-what-option-does13666170
Ref: 3cd613666170
Node: Navigating the Tcl/Tk Reference Manual13667908
Ref: library/tkinter navigating-the-tcl-tk-reference-manual13668044
Ref: 3cd713668044
Ref: Navigating the Tcl/Tk Reference Manual-Footnote-113670110
Ref: Navigating the Tcl/Tk Reference Manual-Footnote-213670167
Ref: Navigating the Tcl/Tk Reference Manual-Footnote-313670226
Ref: Navigating the Tcl/Tk Reference Manual-Footnote-413670279
Ref: Navigating the Tcl/Tk Reference Manual-Footnote-513670335
Ref: Navigating the Tcl/Tk Reference Manual-Footnote-613670394
Node: Threading model13670448
Ref: library/tkinter threading-model13670622
Ref: 3ccc13670622
Node: 簡単なリファレンス13673634
Ref: library/tkinter handy-reference13673809
Ref: 3cd813673809
Node: オプションの設定13674143
Ref: library/tkinter setting-options13674246
Ref: 3cd913674246
Ref: library/tkinter tkinter-setting-options13674246
Ref: 3cda13674246
Ref: オプションの設定-Footnote-113678466
Node: Packer13678513
Ref: library/tkinter the-packer13678650
Ref: 3cdb13678650
Node: Packer のオプション13680867
Ref: library/tkinter packer-options13681022
Ref: 3cdc13681022
Node: ウィジェット変数を関連付ける13681954
Ref: library/tkinter coupling-widget-variables13682133
Ref: 3cdd13682133
Node: ウィンドウマネージャ13684707
Ref: library/tkinter the-window-manager13684891
Ref: 3cde13684891
Node: Tk オプションデータ型13686760
Ref: library/tkinter tk-option-data-types13686929
Ref: 3cdf13686929
Node: バインドとイベント13690872
Ref: library/tkinter bindings-and-events13691032
Ref: 3ce013691032
Ref: library/tkinter id213691032
Ref: 3ce113691032
Ref: バインドとイベント-Footnote-113694388
Node: index パラメータ13694434
Ref: library/tkinter the-index-parameter13694570
Ref: 3ce213694570
Node: 画像13697322
Ref: library/tkinter images13697422
Ref: 3ce313697422
Ref: 画像-Footnote-113698998
Node: ファイルハンドラ13699033
Ref: library/tkinter file-handlers13699184
Ref: 3ce413699184
Ref: library/tkinter tkinter-file-handlers13699184
Ref: 3ce513699184
Ref: library/tkinter tkinter Widget tk createfilehandler13700440
Ref: 3ce613700440
Ref: library/tkinter tkinter Widget tk deletefilehandler13701013
Ref: 3ce713701013
Ref: library/tkinter tkinter READABLE13701128
Ref: 3ce813701128
Ref: library/tkinter tkinter WRITABLE13701161
Ref: 3ce913701161
Ref: library/tkinter tkinter EXCEPTION13701194
Ref: 3cea13701194
Node: tkinter colorchooser --- カラー選択ダイアログ13701273
Ref: library/tkinter colorchooser doc13701555
Ref: 3ceb13701555
Ref: library/tkinter colorchooser module-tkinter colorchooser13701555
Ref: da13701555
Ref: library/tkinter colorchooser tkinter-colorchooser-color-choosing-dialog13701555
Ref: 3cec13701555
Ref: library/tkinter colorchooser tkinter colorchooser Chooser13702150
Ref: 3ced13702150
Ref: library/tkinter colorchooser tkinter colorchooser askcolor13702220
Ref: 3cef13702220
Ref: tkinter colorchooser --- カラー選択ダイアログ-Footnote-113702702
Node: tkinter font --- Tkinter フォントラッパー13702783
Ref: library/tkinter font doc13703034
Ref: 3cf013703034
Ref: library/tkinter font module-tkinter font13703034
Ref: de13703034
Ref: library/tkinter font tkinter-font-tkinter-font-wrapper13703034
Ref: 3cf113703034
Ref: library/tkinter font tkinter font NORMAL13703456
Ref: 3cf213703456
Ref: library/tkinter font tkinter font BOLD13703491
Ref: 3cf313703491
Ref: library/tkinter font tkinter font ITALIC13703524
Ref: 3cf413703524
Ref: library/tkinter font tkinter font ROMAN13703559
Ref: 3cf513703559
Ref: library/tkinter font tkinter font Font13703594
Ref: 187513703594
Ref: library/tkinter font tkinter font Font actual13704902
Ref: 3cf613704902
Ref: library/tkinter font tkinter font Font cget13705009
Ref: 3cf713705009
Ref: library/tkinter font tkinter font Font config13705093
Ref: 3cf813705093
Ref: library/tkinter font tkinter font Font copy13705178
Ref: 3cf913705178
Ref: library/tkinter font tkinter font Font measure13705262
Ref: 3cfa13705262
Ref: library/tkinter font tkinter font Font metrics13705527
Ref: 3cfb13705527
Ref: library/tkinter font tkinter font families13706110
Ref: 3cfc13706110
Ref: library/tkinter font tkinter font names13706218
Ref: 3cfd13706218
Ref: library/tkinter font tkinter font nametofont13706306
Ref: 187713706306
Ref: tkinter font --- Tkinter フォントラッパー-Footnote-113706538
Node: Tkinter ダイアログ13706610
Ref: library/dialog doc13706867
Ref: 3cfe13706867
Ref: library/dialog tkinter-dialogs13706867
Ref: 3cff13706867
Node: tkinter simpledialog --- 標準 Tkinter 入力ダイアログ13707271
Ref: library/dialog module-tkinter simpledialog13707457
Ref: e113707457
Ref: library/dialog tkinter-simpledialog-standard-tkinter-input-dialogs13707457
Ref: 3d0013707457
Ref: library/dialog tkinter simpledialog askfloat13707922
Ref: 3d0113707922
Ref: library/dialog tkinter simpledialog askinteger13707989
Ref: 187813707989
Ref: library/dialog tkinter simpledialog askstring13708058
Ref: 3d0213708058
Ref: library/dialog tkinter simpledialog Dialog13708257
Ref: 3d0313708257
Ref: library/dialog tkinter simpledialog Dialog body13708386
Ref: 3d0413708386
Ref: library/dialog tkinter simpledialog Dialog buttonbox13708594
Ref: 3d0513708594
Ref: tkinter simpledialog --- 標準 Tkinter 入力ダイアログ-Footnote-113708848
Node: tkinter filedialog --- ファイル選択ダイアログ13708929
Ref: library/dialog module-tkinter filedialog13709172
Ref: dd13709172
Ref: library/dialog tkinter-filedialog-file-selection-dialogs13709172
Ref: 3d0613709172
Ref: tkinter filedialog --- ファイル選択ダイアログ-Footnote-113709651
Node: ネイティブの読み込み/保存ダイアログ13709730
Ref: library/dialog native-load-save-dialogs13709875
Ref: 3d0713709875
Ref: library/dialog tkinter filedialog askopenfile13711118
Ref: 3d0813711118
Ref: library/dialog tkinter filedialog askopenfiles13711186
Ref: 3d0913711186
Ref: library/dialog tkinter filedialog asksaveasfile13711382
Ref: 3d0b13711382
Ref: library/dialog tkinter filedialog askopenfilename13711552
Ref: 3d0d13711552
Ref: library/dialog tkinter filedialog askopenfilenames13711614
Ref: 3d0e13711614
Ref: library/dialog tkinter filedialog asksaveasfilename13711826
Ref: 3d0f13711826
Ref: library/dialog tkinter filedialog askdirectory13711972
Ref: 3d1013711972
Ref: library/dialog tkinter filedialog Open13712199
Ref: 3d0a13712199
Ref: library/dialog tkinter filedialog SaveAs13712263
Ref: 3d0c13712263
Ref: library/dialog tkinter filedialog Directory13712587
Ref: 3d1113712587
Ref: library/dialog tkinter filedialog FileDialog13712825
Ref: 3d1213712825
Ref: library/dialog tkinter filedialog FileDialog cancel_command13712936
Ref: 3d1313712936
Ref: library/dialog tkinter filedialog FileDialog dirs_double_event13713045
Ref: 3d1413713045
Ref: library/dialog tkinter filedialog FileDialog dirs_select_event13713157
Ref: 3d1513713157
Ref: library/dialog tkinter filedialog FileDialog files_double_event13713262
Ref: 3d1613713262
Ref: library/dialog tkinter filedialog FileDialog files_select_event13713370
Ref: 3d1713713370
Ref: library/dialog tkinter filedialog FileDialog filter_command13713478
Ref: 3d1813713478
Ref: library/dialog tkinter filedialog FileDialog get_filter13713572
Ref: 3d1913713572
Ref: library/dialog tkinter filedialog FileDialog get_selection13713664
Ref: 3d1a13713664
Ref: library/dialog tkinter filedialog FileDialog go13713754
Ref: 3d1b13713754
Ref: library/dialog tkinter filedialog FileDialog ok_event13713902
Ref: 3d1c13713902
Ref: library/dialog tkinter filedialog FileDialog quit13713995
Ref: 3d1d13713995
Ref: library/dialog tkinter filedialog FileDialog set_filter13714086
Ref: 3d1e13714086
Ref: library/dialog tkinter filedialog FileDialog set_selection13714164
Ref: 3d1f13714164
Ref: library/dialog tkinter filedialog LoadFileDialog13714265
Ref: 3d2013714265
Ref: library/dialog tkinter filedialog LoadFileDialog ok_command13714433
Ref: 3d2113714433
Ref: library/dialog tkinter filedialog SaveFileDialog13714580
Ref: 3d2213714580
Ref: library/dialog tkinter filedialog SaveFileDialog ok_command13714750
Ref: 3d2313714750
Node: tkinter commondialog --- Dialog window templates13714968
Ref: library/dialog module-tkinter commondialog13715141
Ref: db13715141
Ref: library/dialog tkinter-commondialog-dialog-window-templates13715141
Ref: 3d2413715141
Ref: library/dialog tkinter commondialog Dialog13715534
Ref: 3cee13715534
Ref: library/dialog tkinter commondialog Dialog show13715603
Ref: 3d2513715603
Ref: tkinter commondialog --- Dialog window templates-Footnote-113715828
Node: tkinter messagebox --- Tkinter メッセージプロンプト13715909
Ref: library/tkinter messagebox doc13716196
Ref: 3d2613716196
Ref: library/tkinter messagebox module-tkinter messagebox13716196
Ref: df13716196
Ref: library/tkinter messagebox tkinter-messagebox-tkinter-message-prompts13716196
Ref: 3d2713716196
Ref: library/tkinter messagebox tkinter messagebox Message13716922
Ref: 3d2c13716922
Ref: library/tkinter messagebox tkinter messagebox Message show13719067
Ref: 3d3113719067
Ref: library/tkinter messagebox tkinter messagebox showinfo13719388
Ref: 3d3213719388
Ref: library/tkinter messagebox tkinter messagebox showwarning13719614
Ref: 3d3313719614
Ref: library/tkinter messagebox tkinter messagebox showerror13719801
Ref: 3d3413719801
Ref: library/tkinter messagebox tkinter messagebox askquestion13720022
Ref: 3d3513720022
Ref: library/tkinter messagebox tkinter messagebox askokcancel13720273
Ref: 3d3613720273
Ref: library/tkinter messagebox tkinter messagebox askretrycancel13720539
Ref: 3d3713720539
Ref: library/tkinter messagebox tkinter messagebox askyesno13720814
Ref: 3d3913720814
Ref: library/tkinter messagebox tkinter messagebox askyesnocancel13721052
Ref: 3d3a13721052
Ref: library/tkinter messagebox messagebox-buttons13721346
Ref: 3d2d13721346
Ref: library/tkinter messagebox tkinter messagebox ABORT13721374
Ref: 3d3b13721374
Ref: library/tkinter messagebox tkinter messagebox RETRY13721425
Ref: 3d3813721425
Ref: library/tkinter messagebox tkinter messagebox IGNORE13721476
Ref: 3d3c13721476
Ref: library/tkinter messagebox tkinter messagebox OK13721529
Ref: 3d2813721529
Ref: library/tkinter messagebox tkinter messagebox CANCEL13721574
Ref: 3d2913721574
Ref: library/tkinter messagebox tkinter messagebox YES13721627
Ref: 3d2a13721627
Ref: library/tkinter messagebox tkinter messagebox NO13721674
Ref: 3d2b13721674
Ref: library/tkinter messagebox messagebox-types13721718
Ref: 3d3013721718
Ref: library/tkinter messagebox tkinter messagebox ABORTRETRYIGNORE13721747
Ref: 3d3d13721747
Ref: library/tkinter messagebox tkinter messagebox OKCANCEL13722051
Ref: 3d3e13722051
Ref: library/tkinter messagebox tkinter messagebox RETRYCANCEL13722205
Ref: 3d3f13722205
Ref: library/tkinter messagebox tkinter messagebox YESNO13722368
Ref: 3d4013722368
Ref: library/tkinter messagebox tkinter messagebox YESNOCANCEL13722513
Ref: 3d4113722513
Ref: library/tkinter messagebox messagebox-icons13722691
Ref: 3d2e13722691
Ref: library/tkinter messagebox tkinter messagebox ERROR13722705
Ref: 3d4213722705
Ref: library/tkinter messagebox tkinter messagebox INFO13722756
Ref: 3d2f13722756
Ref: library/tkinter messagebox tkinter messagebox QUESTION13722805
Ref: 3d4313722805
Ref: library/tkinter messagebox tkinter messagebox WARNING13722862
Ref: 3d4413722862
Ref: tkinter messagebox --- Tkinter メッセージプロンプト-Footnote-113722953
Node: tkinter scrolledtext --- スクロール可能なテキストウィジェット13723032
Ref: library/tkinter scrolledtext doc13723360
Ref: 3d4513723360
Ref: library/tkinter scrolledtext module-tkinter scrolledtext13723360
Ref: e013723360
Ref: library/tkinter scrolledtext tkinter-scrolledtext-scrolled-text-widget13723360
Ref: 3d4613723360
Ref: library/tkinter scrolledtext tkinter scrolledtext ScrolledText13724543
Ref: 3d4713724543
Ref: library/tkinter scrolledtext tkinter scrolledtext ScrolledText frame13724613
Ref: 3d4813724613
Ref: library/tkinter scrolledtext tkinter scrolledtext ScrolledText vbar13724736
Ref: 3d4913724736
Ref: tkinter scrolledtext --- スクロール可能なテキストウィジェット-Footnote-113724852
Node: tkinter dnd --- ドラッグアンドドロップのサポート13724933
Ref: library/tkinter dnd doc13725255
Ref: 3d4a13725255
Ref: library/tkinter dnd module-tkinter dnd13725255
Ref: dc13725255
Ref: library/tkinter dnd tkinter-dnd-drag-and-drop-support13725255
Ref: 3d4b13725255
Ref: library/tkinter dnd tkinter dnd DndHandler13726805
Ref: 3d4d13726805
Ref: library/tkinter dnd tkinter dnd DndHandler cancel13726997
Ref: 3d4e13726997
Ref: library/tkinter dnd tkinter dnd DndHandler finish13727086
Ref: 3d4f13727086
Ref: library/tkinter dnd tkinter dnd DndHandler on_motion13727186
Ref: 3d5013727186
Ref: library/tkinter dnd tkinter dnd DndHandler on_release13727318
Ref: 3d5113727318
Ref: library/tkinter dnd tkinter dnd dnd_start13727430
Ref: 3d4c13727430
Ref: tkinter dnd --- ドラッグアンドドロップのサポート-Footnote-113727625
Node: tkinter ttk --- Tk のテーマ付きウィジェット13727696
Ref: library/tkinter ttk doc13727947
Ref: 3d5213727947
Ref: library/tkinter ttk module-tkinter ttk13727947
Ref: e213727947
Ref: library/tkinter ttk tkinter-ttk-tk-themed-widgets13727947
Ref: 3d5313727947
Ref: tkinter ttk --- Tk のテーマ付きウィジェット-Footnote-113729153
Ref: tkinter ttk --- Tk のテーマ付きウィジェット-Footnote-213729224
Node: Ttk を使う13729277
Ref: library/tkinter ttk using-ttk13729413
Ref: 3d5413729413
Ref: Ttk を使う-Footnote-113730920
Node: Ttk ウィジェット13730984
Ref: library/tkinter ttk ttk-widgets13731147
Ref: 3d5513731147
Node: ウィジェット13732430
Ref: library/tkinter ttk widget13732601
Ref: 3d5b13732601
Node: 標準オプション13733094
Ref: library/tkinter ttk standard-options13733236
Ref: 3d5c13733236
Node: スクロール可能ウィジェットのオプション13735225
Ref: library/tkinter ttk scrollable-widget-options13735400
Ref: 3d5d13735400
Node: ラベルオプション13736688
Ref: library/tkinter ttk label-options13736866
Ref: 3d5e13736866
Node: 互換性オプション13739653
Ref: library/tkinter ttk compatibility-options13739801
Ref: 3d5f13739801
Node: ウィジェットの状態13740402
Ref: library/tkinter ttk widget-states13740536
Ref: 3d6113740536
Node: ttk Widget13742506
Ref: library/tkinter ttk ttk-widget13742607
Ref: 3d6213742607
Ref: library/tkinter ttk tkinter ttk Widget13742849
Ref: 3d5913742849
Ref: library/tkinter ttk tkinter ttk Widget identify13742884
Ref: 3d6313742884
Ref: library/tkinter ttk tkinter ttk Widget instate13743162
Ref: 3d6413743162
Ref: library/tkinter ttk tkinter ttk Widget state13743727
Ref: 3d6013743727
Node: コンボボックス13744252
Ref: library/tkinter ttk combobox13744408
Ref: 3d6513744408
Node: オプション13745244
Ref: library/tkinter ttk options13745344
Ref: 3d6613745344
Node: 仮想イベント13748044
Ref: library/tkinter ttk virtual-events13748165
Ref: 3d6713748165
Node: ttk Combobox13748384
Ref: library/tkinter ttk ttk-combobox13748481
Ref: 3d6813748481
Ref: library/tkinter ttk tkinter ttk Combobox13748528
Ref: 3d5613748528
Ref: library/tkinter ttk tkinter ttk Combobox current13748565
Ref: 3d6913748565
Ref: library/tkinter ttk tkinter ttk Combobox get13748973
Ref: 3d6a13748973
Ref: library/tkinter ttk tkinter ttk Combobox set13749070
Ref: 3d6b13749070
Node: Spinbox13749178
Ref: library/tkinter ttk spinbox13749334
Ref: 3d6c13749334
Node: オプション<2>13750179
Ref: library/tkinter ttk id113750271
Ref: 3d6d13750271
Node: 仮想イベント<2>13752691
Ref: library/tkinter ttk id213752803
Ref: 3d6e13752803
Node: ttk Spinbox13753013
Ref: library/tkinter ttk ttk-spinbox13753098
Ref: 3d6f13753098
Ref: library/tkinter ttk tkinter ttk Spinbox13753143
Ref: b6213753143
Ref: library/tkinter ttk tkinter ttk Spinbox get13753179
Ref: 3d7013753179
Ref: library/tkinter ttk tkinter ttk Spinbox set13753263
Ref: 3d7113753263
Node: ノートブック13753352
Ref: library/tkinter ttk notebook13753508
Ref: 3d7213753508
Node: オプション<3>13754035
Ref: library/tkinter ttk id313754138
Ref: 3d7313754138
Node: タブオプション13755458
Ref: library/tkinter ttk tab-options13755585
Ref: 3d7413755585
Node: タブ識別子13757766
Ref: library/tkinter ttk tab-identifiers13757896
Ref: 3d7613757896
Node: 仮想イベント<3>13758383
Ref: library/tkinter ttk id413758504
Ref: 3d7813758504
Node: ttk Notebook13758690
Ref: library/tkinter ttk ttk-notebook13758787
Ref: 3d7913758787
Ref: library/tkinter ttk tkinter ttk Notebook13758834
Ref: 3d5713758834
Ref: library/tkinter ttk tkinter ttk Notebook add13758871
Ref: 3d7a13758871
Ref: library/tkinter ttk tkinter ttk Notebook forget13759278
Ref: 3d7b13759278
Ref: library/tkinter ttk tkinter ttk Notebook hide13759494
Ref: 3d7c13759494
Ref: library/tkinter ttk tkinter ttk Notebook identify13759874
Ref: 3d7d13759874
Ref: library/tkinter ttk tkinter ttk Notebook index13760044
Ref: 3d7713760044
Ref: library/tkinter ttk tkinter ttk Notebook insert13760249
Ref: 3d7e13760249
Ref: library/tkinter ttk tkinter ttk Notebook select13760766
Ref: 3d7f13760766
Ref: library/tkinter ttk tkinter ttk Notebook tab13761201
Ref: 3d8013761201
Ref: library/tkinter ttk tkinter ttk Notebook tabs13761673
Ref: 3d8113761673
Ref: library/tkinter ttk tkinter ttk Notebook enable_traversal13761804
Ref: 3d7513761804
Node: プログレスバー13762964
Ref: library/tkinter ttk progressbar13763128
Ref: 3d8213763128
Node: オプション<4>13763628
Ref: library/tkinter ttk id513763728
Ref: 3d8313763728
Node: ttk Progressbar13765745
Ref: library/tkinter ttk ttk-progressbar13765845
Ref: 3d8413765845
Ref: library/tkinter ttk tkinter ttk Progressbar13765898
Ref: 3d5813765898
Ref: library/tkinter ttk tkinter ttk Progressbar start13765938
Ref: 3d8513765938
Ref: library/tkinter ttk tkinter ttk Progressbar step13766302
Ref: 3d8613766302
Ref: library/tkinter ttk tkinter ttk Progressbar stop13766537
Ref: 3d8713766537
Node: セパレータ13766800
Ref: library/tkinter ttk separator13766967
Ref: 3d8813766967
Node: オプション<5>13767261
Ref: library/tkinter ttk id613767331
Ref: 3d8913767331
Node: サイズグリップ13767738
Ref: library/tkinter ttk sizegrip13767902
Ref: 3d8a13767902
Node: プラットフォーム固有のメモ13768420
Ref: library/tkinter ttk platform-specific-notes13768532
Ref: 3d8b13768532
Node: バグ13768902
Ref: library/tkinter ttk bugs13769014
Ref: 3d8c13769014
Node: ツリービュー13769440
Ref: library/tkinter ttk treeview13769605
Ref: 3d8d13769605
Node: オプション<6>13771473
Ref: library/tkinter ttk id713771576
Ref: 3d9113771576
Node: 要素オプション13774363
Ref: library/tkinter ttk item-options13774496
Ref: 3d9213774496
Node: タグオプション13775728
Ref: library/tkinter ttk tag-options13775861
Ref: 3d9313775861
Node: カラム識別子13776605
Ref: library/tkinter ttk column-identifiers13776738
Ref: 3d8e13776738
Node: 仮想イベント<4>13777895
Ref: library/tkinter ttk id813778019
Ref: 3d9413778019
Node: ttk Treeview13778994
Ref: library/tkinter ttk ttk-treeview13779091
Ref: 3d9613779091
Ref: library/tkinter ttk tkinter ttk Treeview13779138
Ref: a6213779138
Ref: library/tkinter ttk tkinter ttk Treeview bbox13779175
Ref: 3d9713779175
Ref: library/tkinter ttk tkinter ttk Treeview get_children13779800
Ref: 3d9813779800
Ref: library/tkinter ttk tkinter ttk Treeview set_children13780030
Ref: 3d9913780030
Ref: library/tkinter ttk tkinter ttk Treeview column13780531
Ref: 3d9a13780531
Ref: library/tkinter ttk tkinter ttk Treeview delete13782255
Ref: 3d9b13782255
Ref: library/tkinter ttk tkinter ttk Treeview detach13782433
Ref: 3d9c13782433
Ref: library/tkinter ttk tkinter ttk Treeview exists13782837
Ref: 3d9d13782837
Ref: library/tkinter ttk tkinter ttk Treeview focus13782970
Ref: 3d9513782970
Ref: library/tkinter ttk tkinter ttk Treeview heading13783305
Ref: 3d9e13783305
Ref: library/tkinter ttk tkinter ttk Treeview identify13784550
Ref: 3d9f13784550
Ref: library/tkinter ttk tkinter ttk Treeview identify_row13785183
Ref: 3da013785183
Ref: library/tkinter ttk tkinter ttk Treeview identify_column13785306
Ref: 3da113785306
Ref: library/tkinter ttk tkinter ttk Treeview identify_region13785537
Ref: 3da213785537
Ref: library/tkinter ttk tkinter ttk Treeview identify_element13786242
Ref: 3da313786242
Ref: library/tkinter ttk tkinter ttk Treeview index13786420
Ref: 3da413786420
Ref: library/tkinter ttk tkinter ttk Treeview insert13786558
Ref: 3da513786558
Ref: library/tkinter ttk tkinter ttk Treeview item13787566
Ref: 3da613787566
Ref: library/tkinter ttk tkinter ttk Treeview move13788097
Ref: 3da713788097
Ref: library/tkinter ttk tkinter ttk Treeview next13788604
Ref: 3da813788604
Ref: library/tkinter ttk tkinter ttk Treeview parent13788790
Ref: 3da913788790
Ref: library/tkinter ttk tkinter ttk Treeview prev13788948
Ref: 3daa13788948
Ref: library/tkinter ttk tkinter ttk Treeview reattach13789134
Ref: 3dab13789134
Ref: library/tkinter ttk tkinter ttk Treeview see13789257
Ref: 3dac13789257
Ref: library/tkinter ttk tkinter ttk Treeview selection13789576
Ref: a6113789576
Ref: library/tkinter ttk tkinter ttk Treeview selection_set13789837
Ref: a6313789837
Ref: library/tkinter ttk tkinter ttk Treeview selection_add13790108
Ref: 3dad13790108
Ref: library/tkinter ttk tkinter ttk Treeview selection_remove13790379
Ref: 3dae13790379
Ref: library/tkinter ttk tkinter ttk Treeview selection_toggle13790653
Ref: 3daf13790653
Ref: library/tkinter ttk tkinter ttk Treeview set13790938
Ref: 3db013790938
Ref: library/tkinter ttk tkinter ttk Treeview tag_bind13791400
Ref: 3db113791400
Ref: library/tkinter ttk tkinter ttk Treeview tag_configure13791759
Ref: 3db213791759
Ref: library/tkinter ttk tkinter ttk Treeview tag_has13792295
Ref: 3db313792295
Ref: library/tkinter ttk tkinter ttk Treeview xview13792708
Ref: 3d8f13792708
Ref: library/tkinter ttk tkinter ttk Treeview yview13792865
Ref: 3d9013792865
Node: Ttk スタイル13793022
Ref: library/tkinter ttk ttk-styling13793157
Ref: 3db413793157
Ref: library/tkinter ttk ttkstyling13793157
Ref: 3d5a13793157
Ref: library/tkinter ttk tkinter ttk Style13793972
Ref: 23a13793972
Ref: library/tkinter ttk tkinter ttk Style configure13794103
Ref: 3db513794103
Ref: library/tkinter ttk tkinter ttk Style map13794946
Ref: 188813794946
Ref: library/tkinter ttk tkinter ttk Style lookup13796467
Ref: 3db613796467
Ref: library/tkinter ttk tkinter ttk Style layout13797149
Ref: 3db713797149
Ref: library/tkinter ttk tkinter ttk Style element_create13798713
Ref: 23913798713
Ref: library/tkinter ttk tkinter ttk Style element_names13804377
Ref: 3db913804377
Ref: library/tkinter ttk tkinter ttk Style element_options13804508
Ref: 3dba13804508
Ref: library/tkinter ttk tkinter ttk Style theme_create13804636
Ref: 3dbb13804636
Ref: library/tkinter ttk tkinter ttk Style theme_settings13805178
Ref: 3dbc13805178
Ref: library/tkinter ttk tkinter ttk Style theme_names13806738
Ref: 3dbd13806738
Ref: library/tkinter ttk tkinter ttk Style theme_use13806846
Ref: 3dbe13806846
Ref: Ttk スタイル-Footnote-113807282
Node: レイアウト13807344
Ref: library/tkinter ttk layouts13807412
Ref: 3db813807412
Ref: library/tkinter ttk layout13808686
Ref: 3dbf13808686
Node: IDLE<64>13808687
Ref: library/idle doc13808865
Ref: 3dc013808865
Ref: library/idle id113808865
Ref: 3dc113808865
Ref: library/idle idle13808865
Ref: fe013808865
Ref: IDLE<64>-Footnote-113810074
Node: メニュー13810139
Ref: library/idle menus13810227
Ref: 3dc213810227
Node: File メニュー Shell ウィンドウ、Editor ウィンドウ13812365
Ref: library/idle file-menu-shell-and-editor13812551
Ref: 3dc313812551
Node: Edit メニュー Shell ウィンドウ、Editor ウィンドウ13815123
Ref: library/idle edit-menu-shell-and-editor13815384
Ref: 3dc413815384
Node: Format メニュー Shell ウィンドウ、Editor ウィンドウ13818095
Ref: library/idle format-menu13818337
Ref: 3dc713818337
Ref: library/idle format-menu-editor-window-only13818337
Ref: 3dc813818337
Node: Run メニュー Editor ウィンドウのみ13820404
Ref: library/idle run-menu-editor-window-only13820628
Ref: 3dc913820628
Ref: library/idle run-module13820732
Ref: 3dca13820732
Ref: library/idle run-custom13821453
Ref: 3dcc13821453
Ref: library/idle check-module13821713
Ref: 3dcb13821713
Ref: library/idle python-shell13822176
Ref: 3dcd13822176
Node: Shell メニュー Shell ウィンドウのみ13822278
Ref: library/idle shell-menu-shell-window-only13822482
Ref: 3dce13822482
Node: Debug メニュー Shell ウィンドウのみ13823199
Ref: library/idle debug-menu-shell-window-only13823425
Ref: 3dcf13823425
Node: Options メニュー Shell ウィンドウ、Editor ウィンドウ13824848
Ref: library/idle options-menu-shell-and-editor13825094
Ref: 3dd013825094
Node: Window メニュー Shell ウィンドウ、Editor ウィンドウ13826953
Ref: library/idle window-menu-shell-and-editor13827217
Ref: 3dd313827217
Node: Help メニュー Shell ウィンドウ、Editor ウィンドウ13827470
Ref: library/idle help-menu-shell-and-editor13827680
Ref: 3dd413827680
Node: Context menus13828955
Ref: library/idle context-menus13829090
Ref: 3dd613829090
Node: Editing and Navigation13830895
Ref: library/idle editing-and-navigation13831018
Ref: 3dd713831018
Ref: library/idle id213831018
Ref: 3dd813831018
Node: Editor windows13831346
Ref: library/idle editor-windows13831440
Ref: 3dd913831440
Node: Key bindings13832054
Ref: library/idle key-bindings13832178
Ref: 3dda13832178
Node: 自動的な字下げ13833621
Ref: library/idle automatic-indentation13833746
Ref: 3ddb13833746
Node: 検索と置換13834492
Ref: library/idle search-and-replace13834623
Ref: 3ddc13834623
Node: 補完 Completions13834946
Ref: library/idle completions13835086
Ref: 3dc513835086
Ref: library/idle id313835086
Ref: 3ddd13835086
Node: 呼び出しヒント Calltips13837720
Ref: library/idle calltips13837857
Ref: 3dc613837857
Ref: library/idle id413837857
Ref: 3dde13837857
Node: Code Context13839508
Ref: library/idle code-context13839639
Ref: 3dd213839639
Ref: library/idle id513839639
Ref: 3ddf13839639
Node: Shell window13840527
Ref: library/idle shell-window13840646
Ref: 3de013840646
Node: テキストの色13842285
Ref: library/idle text-colors13842383
Ref: 3de113842383
Node: Startup and Code Execution13843831
Ref: library/idle startup-and-code-execution13843962
Ref: 3de213843962
Node: コマンドラインの使い方13845312
Ref: library/idle command-line-usage13845432
Ref: 3de313845432
Node: Startup failure13846724
Ref: library/idle startup-failure13846870
Ref: 3de413846870
Node: Running user code13850044
Ref: library/idle running-user-code13850177
Ref: 3de513850177
Node: User output in Shell13852957
Ref: library/idle user-output-in-shell13853106
Ref: 3de613853106
Node: Developing tkinter applications13856176
Ref: library/idle developing-tkinter-applications13856356
Ref: 3de713856356
Node: サブプロセスを起こさずに起動する13857605
Ref: library/idle running-without-a-subprocess13857756
Ref: 3de813857756
Node: Help and Preferences13859823
Ref: library/idle help-and-preferences13859939
Ref: 3de913859939
Node: Help sources13860113
Ref: library/idle help-sources13860228
Ref: 3dd513860228
Ref: library/idle id613860228
Ref: 3dea13860228
Node: Setting preferences [お好み設定]13861086
Ref: library/idle preferences13861223
Ref: 3dd113861223
Ref: library/idle setting-preferences13861223
Ref: 3deb13861223
Node: IDLE on macOS13862261
Ref: library/idle idle-on-macos13862405
Ref: 3dec13862405
Node: Extensions [拡張]13862664
Ref: library/idle extensions13862762
Ref: 3ded13862762
Node: idlelib13863129
Ref: library/idle idlelib13863210
Ref: 3dee13863210
Ref: library/idle module-idlelib13863210
Ref: 6913863210
Ref: idlelib-Footnote-113863834
Ref: idlelib-Footnote-213863898
Node: 開発ツール13863940
Ref: library/development doc13864140
Ref: 3def13864140
Ref: library/development development13864140
Ref: 3df013864140
Ref: library/development development-tools13864140
Ref: 3df113864140
Node: typing --- 型ヒントのサポート13866477
Ref: library/typing doc13866649
Ref: 3df213866649
Ref: library/typing typing-support-for-type-hints13866649
Ref: 3df313866649
Ref: library/typing module-typing13866739
Ref: ed13866739
Ref: typing --- 型ヒントのサポート-Footnote-113869499
Ref: typing --- 型ヒントのサポート-Footnote-213869565
Ref: typing --- 型ヒントのサポート-Footnote-313869617
Ref: typing --- 型ヒントのサポート-Footnote-413869684
Ref: typing --- 型ヒントのサポート-Footnote-513869741
Node: Python 型システムの仕様13869790
Ref: library/typing relevant-peps13869923
Ref: 3df413869923
Ref: library/typing specification-for-the-python-type-system13869923
Ref: 3df513869923
Ref: Python 型システムの仕様-Footnote-113870164
Node: 型エイリアス13870228
Ref: library/typing id213870377
Ref: 3df613870377
Ref: library/typing type-aliases13870377
Ref: 42013870377
Node: NewType13872027
Ref: library/typing distinct13872205
Ref: 3df713872205
Ref: library/typing newtype13872205
Ref: 3df813872205
Ref: NewType-Footnote-113875845
Node: 呼び出し可能オブジェクトのアノテーション13875887
Ref: library/typing annotating-callable-objects13876065
Ref: 3df913876065
Ref: library/typing annotating-callables13876065
Ref: 248013876065
Ref: 呼び出し可能オブジェクトのアノテーション-Footnote-113879558
Node: ジェネリクス13879600
Ref: library/typing generics13879804
Ref: 1ee013879804
Ref: library/typing id313879804
Ref: 3dfb13879804
Node: タプルのアノテーション13881188
Ref: library/typing annotating-tuples13881365
Ref: 3dfc13881365
Ref: library/typing id413881365
Ref: 3dfd13881365
Node: クラスオブジェクトの型13883849
Ref: library/typing the-type-of-class-objects13884044
Ref: 3dfe13884044
Ref: library/typing type-of-class-objects13884044
Ref: 3dff13884044
Node: Annotating generators and coroutines13885724
Ref: library/typing annotating-generators-and-coroutines13885928
Ref: 248113885928
Ref: library/typing id513885928
Ref: 3e0113885928
Node: ユーザー定義のジェネリック型13888493
Ref: library/typing user-defined-generic-types13888671
Ref: 3e0213888671
Ref: library/typing user-defined-generics13888671
Ref: 49b13888671
Ref: ユーザー定義のジェネリック型-Footnote-113894926
Node: Any 型13894968
Ref: library/typing the-any-type13895150
Ref: 3e0413895150
Node: 名前的部分型 vs 構造的部分型13898135
Ref: library/typing nominal-vs-structural-subtyping13898302
Ref: 3e0513898302
Ref: 名前的部分型 vs 構造的部分型-Footnote-113900404
Ref: 名前的部分型 vs 構造的部分型-Footnote-213900446
Ref: 名前的部分型 vs 構造的部分型-Footnote-313900488
Node: モジュールの内容<3>13900530
Ref: library/typing module-contents13900732
Ref: 3e0613900732
Node: 特殊型付けプリミティブ13901102
Ref: library/typing special-typing-primitives13901226
Ref: 3e0713901226
Node: 特殊型13901418
Ref: library/typing special-types13901518
Ref: 3e0813901518
Ref: library/typing typing Any13901650
Ref: 67813901650
Ref: library/typing typing AnyStr13902084
Ref: 29213902084
Ref: library/typing typing LiteralString13903898
Ref: 59413903898
Ref: library/typing typing Never13905151
Ref: 67413905151
Ref: library/typing typing NoReturn13905179
Ref: 3e0a13905179
Ref: library/typing typing Self13906423
Ref: 59113906423
Ref: library/typing typing TypeAlias13908385
Ref: 79413908385
Ref: 特殊型-Footnote-113910048
Ref: 特殊型-Footnote-213910090
Ref: 特殊型-Footnote-313910132
Ref: 特殊型-Footnote-413910182
Ref: 特殊型-Footnote-513910224
Node: 特殊形式13910266
Ref: library/typing special-forms13910414
Ref: 3e0b13910414
Ref: library/typing typing Union13910659
Ref: 60713910659
Ref: library/typing typing Optional13912147
Ref: 67f13912147
Ref: library/typing typing Concatenate13913230
Ref: 78f13913230
Ref: library/typing typing Literal13915652
Ref: 82013915652
Ref: library/typing typing ClassVar13917085
Ref: 24713917085
Ref: library/typing typing Final13918533
Ref: 24813918533
Ref: library/typing typing Required13919325
Ref: 58e13919325
Ref: library/typing typing NotRequired13919598
Ref: 58f13919598
Ref: library/typing typing ReadOnly13919860
Ref: 14713919860
Ref: library/typing typing Annotated13920392
Ref: 90b13920392
Ref: library/typing typing TypeIs13926230
Ref: 14913926230
Ref: library/typing typing TypeGuard13930025
Ref: 14a13930025
Ref: library/typing typing Unpack13932449
Ref: 159313932449
Ref: 特殊形式-Footnote-113934159
Ref: 特殊形式-Footnote-213934201
Ref: 特殊形式-Footnote-313934243
Ref: 特殊形式-Footnote-413934285
Ref: 特殊形式-Footnote-513934327
Ref: 特殊形式-Footnote-613934369
Ref: 特殊形式-Footnote-713934411
Ref: 特殊形式-Footnote-813934453
Ref: 特殊形式-Footnote-913934495
Ref: 特殊形式-Footnote-1013934537
Ref: 特殊形式-Footnote-1113934580
Node: Building generic types and type aliases13934623
Ref: library/typing building-generic-types-and-type-aliases13934786
Ref: 3e0d13934786
Ref: library/typing typing Generic13935297
Ref: 157c13935297
Ref: library/typing typevar13936559
Ref: 3e0313936559
Ref: library/typing typing TypeVar13936559
Ref: 14313936559
Ref: library/typing typing-constrained-typevar13940091
Ref: 3e0913940091
Ref: library/typing typing TypeVar __name__13940709
Ref: 3e0e13940709
Ref: library/typing typing TypeVar __covariant__13940781
Ref: 3e0f13940781
Ref: library/typing typing TypeVar __contravariant__13940889
Ref: 3e1013940889
Ref: library/typing typing TypeVar __infer_variance__13941015
Ref: 3e1113941015
Ref: library/typing typing TypeVar __bound__13941184
Ref: 3e1213941184
Ref: library/typing typing TypeVar __constraints__13941547
Ref: 3e1313941547
Ref: library/typing typing TypeVar __default__13941952
Ref: 3e1413941952
Ref: library/typing typing TypeVar has_default13942134
Ref: 3e1513942134
Ref: library/typing typevartuple13942801
Ref: 3e0c13942801
Ref: library/typing typing TypeVarTuple13942801
Ref: 14513942801
Ref: library/typing typing TypeVarTuple __name__13947069
Ref: 3e1613947069
Ref: library/typing typing TypeVarTuple __default__13947147
Ref: 3e1713947147
Ref: library/typing typing TypeVarTuple has_default13947335
Ref: 3e1813947335
Ref: library/typing typing ParamSpec13947998
Ref: 14413947998
Ref: library/typing typing ParamSpec args13950494
Ref: 3e1a13950494
Ref: library/typing typing ParamSpec kwargs13950520
Ref: 3e1b13950520
Ref: library/typing typing ParamSpec __name__13951284
Ref: 3e1c13951284
Ref: library/typing typing ParamSpec __default__13951366
Ref: 3e1d13951366
Ref: library/typing typing ParamSpec has_default13951558
Ref: 3e1e13951558
Ref: library/typing typing ParamSpecArgs13952946
Ref: 79113952946
Ref: library/typing typing ParamSpecKwargs13952982
Ref: 79213952982
Ref: library/typing typing TypeAliasType13953702
Ref: 42113953702
Ref: library/typing typing TypeAliasType __name__13953995
Ref: 3e1f13953995
Ref: library/typing typing TypeAliasType __module__13954158
Ref: 3e2013954158
Ref: library/typing typing TypeAliasType __type_params__13954348
Ref: 3e2113954348
Ref: library/typing typing TypeAliasType __value__13954719
Ref: 3e2213954719
Ref: Building generic types and type aliases-Footnote-113955313
Ref: Building generic types and type aliases-Footnote-213955355
Ref: Building generic types and type aliases-Footnote-313955397
Ref: Building generic types and type aliases-Footnote-413955439
Ref: Building generic types and type aliases-Footnote-513955481
Ref: Building generic types and type aliases-Footnote-613955523
Ref: Building generic types and type aliases-Footnote-713955565
Node: Other special directives13955607
Ref: library/typing other-special-directives13955749
Ref: 3e2313955749
Ref: library/typing typing NamedTuple13955975
Ref: 29013955975
Ref: library/typing typing NewType13959510
Ref: cc313959510
Ref: library/typing typing NewType __module__13959959
Ref: 3e2413959959
Ref: library/typing typing NewType __name__13960047
Ref: 3e2513960047
Ref: library/typing typing NewType __supertype__13960114
Ref: 3e2613960114
Ref: library/typing typing Protocol13960326
Ref: 24513960326
Ref: library/typing typing runtime_checkable13961754
Ref: 40f13961754
Ref: library/typing typing TypedDict13964425
Ref: 14813964425
Ref: library/typing typing TypedDict __total__13968985
Ref: 3e2713968985
Ref: library/typing typing TypedDict __required_keys__13970049
Ref: 3e2813970049
Ref: library/typing typing TypedDict __optional_keys__13970121
Ref: 3e2913970121
Ref: library/typing typing TypedDict __readonly_keys__13971936
Ref: 3e2a13971936
Ref: library/typing typing TypedDict __mutable_keys__13972178
Ref: 3e2b13972178
Ref: Other special directives-Footnote-113973587
Ref: Other special directives-Footnote-213973629
Ref: Other special directives-Footnote-313973671
Ref: Other special directives-Footnote-413973713
Node: プロトコル<3>13973755
Ref: library/typing protocols13973912
Ref: 3e2c13973912
Ref: library/typing typing SupportsAbs13974075
Ref: 3e2d13974075
Ref: library/typing typing SupportsBytes13974203
Ref: 5b413974203
Ref: library/typing typing SupportsComplex13974308
Ref: 5b313974308
Ref: library/typing typing SupportsFloat13974417
Ref: 3e2e13974417
Ref: library/typing typing SupportsIndex13974522
Ref: a1413974522
Ref: library/typing typing SupportsInt13974655
Ref: a1313974655
Ref: library/typing typing SupportsRound13974756
Ref: 3e2f13974756
Node: ABCs for working with IO13974888
Ref: library/typing abcs-for-working-with-io13975036
Ref: 3e3013975036
Ref: library/typing typing IO13975107
Ref: 6f613975107
Ref: library/typing typing TextIO13975132
Ref: 3e3113975132
Ref: library/typing typing BinaryIO13975161
Ref: 3e3213975161
Node: Functions and decorators13975430
Ref: library/typing functions-and-decorators13975581
Ref: 3e3313975581
Ref: library/typing typing cast13975652
Ref: 3e1913975652
Ref: library/typing typing assert_type13976051
Ref: 67713976051
Ref: library/typing typing assert_never13977143
Ref: 67313977143
Ref: library/typing typing reveal_type13978569
Ref: 67613978569
Ref: library/typing typing dataclass_transform13979764
Ref: 4a013979764
Ref: library/typing overload13985809
Ref: 3dfa13985809
Ref: library/typing typing overload13985809
Ref: 3e3413985809
Ref: library/typing typing get_overloads13987358
Ref: 67a13987358
Ref: library/typing typing clear_overloads13988034
Ref: 67b13988034
Ref: library/typing typing final13988235
Ref: 67913988235
Ref: library/typing typing no_type_check13989537
Ref: 68013989537
Ref: library/typing typing no_type_check_decorator13990052
Ref: 29113990052
Ref: library/typing typing override13990552
Ref: 41713990552
Ref: library/typing typing type_check_only13991897
Ref: 3e3513991897
Ref: Functions and decorators-Footnote-113992747
Ref: Functions and decorators-Footnote-213992819
Ref: Functions and decorators-Footnote-313992861
Ref: Functions and decorators-Footnote-413992903
Ref: Functions and decorators-Footnote-513992945
Node: Introspection helpers13992987
Ref: library/typing introspection-helpers13993124
Ref: 3e3613993124
Ref: library/typing typing get_type_hints13993189
Ref: 67d13993189
Ref: library/typing typing get_origin13995776
Ref: a1513995776
Ref: library/typing typing get_args13996632
Ref: 84b13996632
Ref: library/typing typing get_protocol_members13997270
Ref: 24413997270
Ref: library/typing typing is_protocol13997729
Ref: 24613997729
Ref: library/typing typing is_typeddict13998034
Ref: 82113998034
Ref: library/typing typing ForwardRef13998479
Ref: 17ae13998479
Ref: library/typing typing NoDefault13999095
Ref: 24313999095
Ref: Introspection helpers-Footnote-113999488
Ref: Introspection helpers-Footnote-213999530
Node: 定数<10>13999572
Ref: library/typing constant13999712
Ref: 3e3713999712
Ref: library/typing typing TYPE_CHECKING13999745
Ref: cc213999745
Ref: library/typing generic-concrete-collections14000908
Ref: 3e3814000908
Ref: 定数<10>-Footnote-114000944
Node: 非推奨のエイリアス14000986
Ref: library/typing deprecated-aliases14001096
Ref: 3e3914001096
Ref: library/typing id614001096
Ref: 3e3a14001096
Ref: 非推奨のエイリアス-Footnote-114002848
Node: Aliases to built-in types14002890
Ref: library/typing aliases-to-built-in-types14003019
Ref: 3e3b14003019
Ref: library/typing corresponding-to-built-in-types14003019
Ref: 3e3c14003019
Ref: library/typing typing Dict14003092
Ref: 3e3d14003092
Ref: library/typing typing List14003641
Ref: 3e3e14003641
Ref: library/typing typing Set14004213
Ref: 3e3f14004213
Ref: library/typing typing FrozenSet14004761
Ref: 3e4014004761
Ref: library/typing typing Tuple14005134
Ref: 3e4114005134
Ref: library/typing typing Type14005621
Ref: 3e0014005621
Ref: Aliases to built-in types-Footnote-114006178
Ref: Aliases to built-in types-Footnote-214006220
Ref: Aliases to built-in types-Footnote-314006262
Ref: Aliases to built-in types-Footnote-414006304
Ref: Aliases to built-in types-Footnote-514006346
Ref: Aliases to built-in types-Footnote-614006388
Node: Aliases to types in collections14006430
Ref: library/typing aliases-to-types-in-collections14006599
Ref: 3e4214006599
Ref: library/typing corresponding-to-types-in-collections14006599
Ref: 3e4314006599
Ref: library/typing typing DefaultDict14006692
Ref: 3e4414006692
Ref: library/typing typing OrderedDict14007153
Ref: 3e4514007153
Ref: library/typing typing ChainMap14007612
Ref: 3e4614007612
Ref: library/typing typing Counter14008059
Ref: 3e4714008059
Ref: library/typing typing Deque14008484
Ref: 3e4814008484
Ref: Aliases to types in collections-Footnote-114008928
Ref: Aliases to types in collections-Footnote-214008970
Ref: Aliases to types in collections-Footnote-314009012
Ref: Aliases to types in collections-Footnote-414009054
Ref: Aliases to types in collections-Footnote-514009096
Node: Aliases to other concrete types14009138
Ref: library/typing aliases-to-other-concrete-types14009326
Ref: 3e4914009326
Ref: library/typing other-concrete-types14009326
Ref: 3e4a14009326
Ref: library/typing typing Pattern14009411
Ref: 6f714009411
Ref: library/typing typing Match14009441
Ref: 3e4b14009441
Ref: library/typing typing Text14010048
Ref: 2e314010048
Ref: library/typing abstract-base-classes14010859
Ref: 3e4c14010859
Ref: Aliases to other concrete types-Footnote-114010895
Node: Aliases to container ABCs in collections abc14010937
Ref: library/typing aliases-to-container-abcs-in-collections-abc14011141
Ref: 3e4d14011141
Ref: library/typing corresponding-to-collections-in-collections-abc14011141
Ref: 3e4e14011141
Ref: library/typing typing AbstractSet14011260
Ref: 3e4f14011260
Ref: library/typing typing ByteString14011642
Ref: 2b514011642
Ref: library/typing typing Collection14011996
Ref: cc114011996
Ref: library/typing typing Container14012439
Ref: 3e5014012439
Ref: library/typing typing ItemsView14012828
Ref: 3e5114012828
Ref: library/typing typing KeysView14013259
Ref: 3e5214013259
Ref: library/typing typing Mapping14013663
Ref: 3e5314013663
Ref: library/typing typing MappingView14014065
Ref: 3e5414014065
Ref: library/typing typing MutableMapping14014452
Ref: 3e5514014452
Ref: library/typing typing MutableSequence14014857
Ref: 3e5614014857
Ref: library/typing typing MutableSet14015259
Ref: 3e5714015259
Ref: library/typing typing Sequence14015653
Ref: 3e5814015653
Ref: library/typing typing ValuesView14016061
Ref: 3e5914016061
Ref: Aliases to container ABCs in collections abc-Footnote-114016508
Ref: Aliases to container ABCs in collections abc-Footnote-214016550
Ref: Aliases to container ABCs in collections abc-Footnote-314016592
Ref: Aliases to container ABCs in collections abc-Footnote-414016634
Ref: Aliases to container ABCs in collections abc-Footnote-514016676
Ref: Aliases to container ABCs in collections abc-Footnote-614016718
Ref: Aliases to container ABCs in collections abc-Footnote-714016760
Ref: Aliases to container ABCs in collections abc-Footnote-814016802
Ref: Aliases to container ABCs in collections abc-Footnote-914016844
Ref: Aliases to container ABCs in collections abc-Footnote-1014016886
Ref: Aliases to container ABCs in collections abc-Footnote-1114016929
Ref: Aliases to container ABCs in collections abc-Footnote-1214016972
Node: Aliases to asynchronous ABCs in collections abc14017015
Ref: library/typing aliases-to-asynchronous-abcs-in-collections-abc14017228
Ref: 3e5a14017228
Ref: library/typing asynchronous-programming14017228
Ref: 3e5b14017228
Ref: library/typing typing Coroutine14017353
Ref: 18b414017353
Ref: library/typing typing AsyncGenerator14018007
Ref: 159014018007
Ref: library/typing typing AsyncIterable14018762
Ref: 3e5c14018762
Ref: library/typing typing AsyncIterator14019190
Ref: 3e5d14019190
Ref: library/typing typing Awaitable14019624
Ref: 3e5e14019624
Ref: Aliases to asynchronous ABCs in collections abc-Footnote-114020077
Ref: Aliases to asynchronous ABCs in collections abc-Footnote-214020119
Ref: Aliases to asynchronous ABCs in collections abc-Footnote-314020161
Ref: Aliases to asynchronous ABCs in collections abc-Footnote-414020203
Ref: Aliases to asynchronous ABCs in collections abc-Footnote-514020245
Node: Aliases to other ABCs in collections abc14020287
Ref: library/typing aliases-to-other-abcs-in-collections-abc14020482
Ref: 3e5f14020482
Ref: library/typing corresponding-to-other-types-in-collections-abc14020482
Ref: 3e6014020482
Ref: library/typing typing Iterable14020593
Ref: 3e6114020593
Ref: library/typing typing Iterator14020979
Ref: 3e6214020979
Ref: library/typing typing Callable14021366
Ref: 79014021366
Ref: library/typing typing Generator14022138
Ref: 158f14022138
Ref: library/typing typing Hashable14022860
Ref: 4c014022860
Ref: library/typing typing Reversible14023102
Ref: 3e6314023102
Ref: library/typing typing Sized14023493
Ref: 4c114023493
Ref: Aliases to other ABCs in collections abc-Footnote-114023762
Ref: Aliases to other ABCs in collections abc-Footnote-214023804
Ref: Aliases to other ABCs in collections abc-Footnote-314023846
Ref: Aliases to other ABCs in collections abc-Footnote-414023888
Ref: Aliases to other ABCs in collections abc-Footnote-514023930
Ref: Aliases to other ABCs in collections abc-Footnote-614023972
Node: Aliases to contextlib ABCs14024014
Ref: library/typing aliases-to-contextlib-abcs14024153
Ref: 3e6414024153
Ref: library/typing context-manager-types14024153
Ref: 3e6514024153
Ref: library/typing typing ContextManager14024236
Ref: c5c14024236
Ref: library/typing typing AsyncContextManager14025075
Ref: 158d14025075
Ref: Aliases to contextlib ABCs-Footnote-114025977
Ref: Aliases to contextlib ABCs-Footnote-214026019
Node: メジャーな機能の非推奨時系列14026061
Ref: library/typing deprecation-timeline-of-major-features14026214
Ref: 3e6614026214
Ref: メジャーな機能の非推奨時系列-Footnote-114029088
Ref: メジャーな機能の非推奨時系列-Footnote-214029130
Ref: メジャーな機能の非推奨時系列-Footnote-314029185
Ref: メジャーな機能の非推奨時系列-Footnote-414029240
Ref: メジャーな機能の非推奨時系列-Footnote-514029295
Ref: メジャーな機能の非推奨時系列-Footnote-614029337
Ref: メジャーな機能の非推奨時系列-Footnote-714029393
Node: pydoc --- ドキュメント生成とオンラインヘルプシステム14029449
Ref: library/pydoc doc14029652
Ref: 3e6714029652
Ref: library/pydoc module-pydoc14029652
Ref: a314029652
Ref: library/pydoc pydoc-documentation-generator-and-online-help-system14029652
Ref: 3e6814029652
Ref: pydoc --- ドキュメント生成とオンラインヘルプシステム-Footnote-114035738
Node: Python 開発モード14035803
Ref: library/devmode doc14036024
Ref: 3e6914036024
Ref: library/devmode devmode14036024
Ref: 1d914036024
Ref: library/devmode python-development-mode14036024
Ref: 3e6a14036024
Node: Effects of the Python Development Mode14036652
Ref: library/devmode effects-of-the-python-development-mode14036781
Ref: 3e6b14036781
Node: ResourceWarning Example14040492
Ref: library/devmode resourcewarning-example14040663
Ref: 3e6c14040663
Node: Bad file descriptor error example14042575
Ref: library/devmode bad-file-descriptor-error-example14042699
Ref: 3e6d14042699
Ref: Bad file descriptor error example-Footnote-114044230
Node: doctest --- 対話型の Python の例をテストする14044295
Ref: library/doctest doc14044498
Ref: 3e6e14044498
Ref: library/doctest doctest-test-interactive-python-examples14044498
Ref: 3e6f14044498
Ref: library/doctest module-doctest14044498
Ref: 3114044498
Ref: doctest --- 対話型の Python の例をテストする-Footnote-114049229
Node: 簡単な利用法 docstring 中の実行例をチェックする14049296
Ref: library/doctest doctest-simple-testmod14049542
Ref: 3e7014049542
Ref: library/doctest simple-usage-checking-examples-in-docstrings14049542
Ref: 3e7114049542
Node: 簡単な利用法 テキストファイル中の実行例をチェックする14051842
Ref: library/doctest doctest-simple-testfile14052120
Ref: 3e7314052120
Ref: library/doctest simple-usage-checking-examples-in-a-text-file14052120
Ref: 3e7414052120
Node: doctest のからくり14055105
Ref: library/doctest doctest-how-it-works14055328
Ref: 3e7614055328
Ref: library/doctest how-it-works14055328
Ref: 3e7714055328
Node: どの docstring が検証されるのか?14056319
Ref: library/doctest doctest-which-docstrings14056492
Ref: 3e7814056492
Ref: library/doctest which-docstrings-are-examined14056492
Ref: 3e7914056492
Node: docstring 内の実行例をどのように認識するのか?14058170
Ref: library/doctest doctest-finding-examples14058389
Ref: 3e7a14058389
Ref: library/doctest how-are-docstring-examples-recognized14058389
Ref: 3e7b14058389
Node: 実行コンテキストとは何か?14062362
Ref: library/doctest doctest-execution-context14062573
Ref: 3e7f14062573
Ref: library/doctest what-s-the-execution-context14062573
Ref: 3e8014062573
Node: 例外はどう扱えばよいか?14063302
Ref: library/doctest doctest-exceptions14063475
Ref: 3e8114063475
Ref: library/doctest what-about-exceptions14063475
Ref: 3e8214063475
Ref: library/doctest option-flags-and-directives14069417
Ref: 3e8314069417
Ref: 例外はどう扱えばよいか?-Footnote-114069454
Node: オプションフラグ14069729
Ref: library/doctest doctest-options14069897
Ref: eff14069897
Ref: library/doctest option-flags14069897
Ref: 3e8414069897
Ref: library/doctest doctest DONT_ACCEPT_TRUE_FOR_114070819
Ref: 3e8514070819
Ref: library/doctest doctest DONT_ACCEPT_BLANKLINE14071760
Ref: 3e8614071760
Ref: library/doctest doctest NORMALIZE_WHITESPACE14072391
Ref: 3e7c14072391
Ref: library/doctest doctest ELLIPSIS14073001
Ref: 141314073001
Ref: library/doctest doctest IGNORE_EXCEPTION_DETAIL14073636
Ref: 12d714073636
Ref: library/doctest doctest SKIP14075178
Ref: 3e8714075178
Ref: library/doctest doctest COMPARISON_FLAGS14075851
Ref: 3e8814075851
Ref: library/doctest doctest REPORT_UDIFF14076079
Ref: 141414076079
Ref: library/doctest doctest REPORT_CDIFF14076320
Ref: 141514076320
Ref: library/doctest doctest REPORT_NDIFF14076561
Ref: 141614076561
Ref: library/doctest doctest REPORT_ONLY_FIRST_FAILURE14077277
Ref: 3e8914077277
Ref: library/doctest doctest FAIL_FAST14078150
Ref: f0014078150
Ref: library/doctest doctest REPORTING_FLAGS14078711
Ref: 3e8a14078711
Ref: library/doctest doctest register_optionflag14079064
Ref: 3e8b14079064
Node: ディレクティブ Directives14079651
Ref: library/doctest directives14079794
Ref: 3e8e14079794
Ref: library/doctest doctest-directives14079794
Ref: 3e7d14079794
Ref: library/doctest grammar-token-doctest-directive14080127
Ref: 3e8f14080127
Ref: library/doctest grammar-token-doctest-directive_options14080191
Ref: 3e9014080191
Ref: library/doctest grammar-token-doctest-directive_option14080263
Ref: 3e9114080263
Ref: library/doctest grammar-token-doctest-on_or_off14080326
Ref: 3e9214080326
Ref: library/doctest grammar-token-doctest-directive_option_name14080367
Ref: 3e9314080367
Node: 警告<2>14083006
Ref: library/doctest doctest-warnings14083116
Ref: 3e9414083116
Ref: library/doctest warnings14083116
Ref: 3e9514083116
Node: 基本 API14085440
Ref: library/doctest basic-api14085603
Ref: 3e9614085603
Ref: library/doctest doctest-basic-api14085603
Ref: 3e7214085603
Ref: library/doctest doctest testfile14086122
Ref: 3e7514086122
Ref: library/doctest doctest testmod14091788
Ref: 141214091788
Ref: library/doctest doctest run_docstring_examples14093826
Ref: 3e9814093826
Node: 単体テスト API14095123
Ref: library/doctest doctest-unittest-api14095273
Ref: 3e9914095273
Ref: library/doctest unittest-api14095273
Ref: 3e9a14095273
Ref: library/doctest doctest DocFileSuite14096103
Ref: 3e9c14096103
Ref: library/doctest doctest DocTestSuite14101190
Ref: dc014101190
Ref: library/doctest doctest failureException14103524
Ref: 3e9d14103524
Ref: library/doctest doctest set_unittest_reportflags14105236
Ref: 3e9e14105236
Node: 拡張 API14106526
Ref: library/doctest advanced-api14106678
Ref: 3e9f14106678
Ref: library/doctest doctest-advanced-api14106678
Ref: 3ea014106678
Node: DocTest オブジェクト14109247
Ref: library/doctest doctest-doctest14109355
Ref: 3ea214109355
Ref: library/doctest doctest-objects14109355
Ref: 3ea314109355
Ref: library/doctest doctest DocTest14109424
Ref: 161614109424
Ref: library/doctest doctest DocTest examples14109939
Ref: 3ea414109939
Ref: library/doctest doctest DocTest globs14110184
Ref: 3ea514110184
Ref: library/doctest doctest DocTest name14110628
Ref: 3ea614110628
Ref: library/doctest doctest DocTest filename14110848
Ref: 3ea714110848
Ref: library/doctest doctest DocTest lineno14111128
Ref: 174a14111128
Ref: library/doctest doctest DocTest docstring14111426
Ref: 3ea814111426
Node: Example オブジェクト14111716
Ref: library/doctest doctest-example14111865
Ref: 3ea914111865
Ref: library/doctest example-objects14111865
Ref: 3eaa14111865
Ref: library/doctest doctest Example14111934
Ref: 3ea114111934
Ref: library/doctest doctest Example source14112506
Ref: 3eab14112506
Ref: library/doctest doctest Example want14112770
Ref: 3eac14112770
Ref: library/doctest doctest Example exc_msg14113262
Ref: 3ead14113262
Ref: library/doctest doctest Example lineno14113803
Ref: 3eae14113803
Ref: library/doctest doctest Example indent14113998
Ref: 3eaf14113998
Ref: library/doctest doctest Example options14114199
Ref: 3eb014114199
Node: DocTestFinder オブジェクト14114609
Ref: library/doctest doctest-doctestfinder14114764
Ref: 3eb114114764
Ref: library/doctest doctestfinder-objects14114764
Ref: 3eb214114764
Ref: library/doctest doctest DocTestFinder14114845
Ref: 159614114845
Ref: library/doctest doctest DocTestFinder find14116356
Ref: 166414116356
Node: DocTestParser オブジェクト14119378
Ref: library/doctest doctest-doctestparser14119526
Ref: 3eb314119526
Ref: library/doctest doctestparser-objects14119526
Ref: 3eb414119526
Ref: library/doctest doctest DocTestParser14119607
Ref: 3e7e14119607
Ref: library/doctest doctest DocTestParser get_doctest14119918
Ref: 3eb514119918
Ref: library/doctest doctest DocTestParser get_examples14120409
Ref: 3eb614120409
Ref: library/doctest doctest DocTestParser parse14120871
Ref: 3eb714120871
Node: TestResults objects14121392
Ref: library/doctest testresults-objects14121540
Ref: 3eb814121540
Ref: library/doctest doctest TestResults14121601
Ref: 3eb914121601
Ref: library/doctest doctest TestResults failed14121657
Ref: 3eba14121657
Ref: library/doctest doctest TestResults attempted14121720
Ref: 3ebb14121720
Ref: library/doctest doctest TestResults skipped14121789
Ref: 1c214121789
Node: DocTestRunner オブジェクト14121888
Ref: library/doctest doctest-doctestrunner14122036
Ref: 3ebc14122036
Ref: library/doctest doctestrunner-objects14122036
Ref: 3ebd14122036
Ref: library/doctest doctest DocTestRunner14122117
Ref: 3e8d14122117
Ref: library/doctest doctest DocTestRunner report_start14125016
Ref: 3ebe14125016
Ref: library/doctest doctest DocTestRunner report_success14125621
Ref: 3ebf14125621
Ref: library/doctest doctest DocTestRunner report_failure14126298
Ref: 3ec114126298
Ref: library/doctest doctest DocTestRunner report_unexpected_exception14126984
Ref: 3ec014126984
Ref: library/doctest doctest DocTestRunner run14127807
Ref: 1c014127807
Ref: library/doctest doctest DocTestRunner summarize14129011
Ref: 3e9714129011
Ref: library/doctest doctest DocTestRunner tries14129534
Ref: 3ec214129534
Ref: library/doctest doctest DocTestRunner failures14129602
Ref: 3ec314129602
Ref: library/doctest doctest DocTestRunner skips14129670
Ref: 1c114129670
Node: OutputChecker オブジェクト14129770
Ref: library/doctest doctest-outputchecker14129890
Ref: 3ec414129890
Ref: library/doctest outputchecker-objects14129890
Ref: 3ec514129890
Ref: library/doctest doctest OutputChecker14129971
Ref: 3e8c14129971
Ref: library/doctest doctest OutputChecker check_output14130598
Ref: 3ec614130598
Ref: library/doctest doctest OutputChecker output_difference14131269
Ref: 3ec714131269
Node: デバッグ14131660
Ref: library/doctest debugging14131808
Ref: 3ec814131808
Ref: library/doctest doctest-debugging14131808
Ref: 3ec914131808
Ref: library/doctest doctest script_from_examples14134345
Ref: 3ecc14134345
Ref: library/doctest doctest testsource14135428
Ref: 3ecd14135428
Ref: library/doctest doctest debug14136251
Ref: 3ecb14136251
Ref: library/doctest doctest debug_src14137587
Ref: 3ecf14137587
Ref: library/doctest doctest DebugRunner14138718
Ref: 3eca14138718
Ref: library/doctest doctest DocTestFailure14139729
Ref: 3ed114139729
Ref: library/doctest doctest DocTestFailure test14140160
Ref: 3ed214140160
Ref: library/doctest doctest DocTestFailure example14140309
Ref: 3ed314140309
Ref: library/doctest doctest DocTestFailure got14140416
Ref: 3ed414140416
Ref: library/doctest doctest UnexpectedException14140494
Ref: 3ed014140494
Ref: library/doctest doctest UnexpectedException test14140915
Ref: 3ed514140915
Ref: library/doctest doctest UnexpectedException example14141069
Ref: 3ed614141069
Ref: library/doctest doctest UnexpectedException exc_info14141181
Ref: 3ed714141181
Node: アドバイス14141371
Ref: library/doctest doctest-soapbox14141500
Ref: 3ed814141500
Ref: library/doctest soapbox14141500
Ref: 3ed914141500
Node: unittest --- ユニットテストフレームワーク14146646
Ref: library/unittest doc14146887
Ref: 3eda14146887
Ref: library/unittest module-unittest14146887
Ref: ef14146887
Ref: library/unittest unittest-unit-testing-framework14146887
Ref: 3edb14146887
Ref: unittest --- ユニットテストフレームワーク-Footnote-114151267
Ref: unittest --- ユニットテストフレームワーク-Footnote-214151345
Ref: unittest --- ユニットテストフレームワーク-Footnote-314151438
Ref: unittest --- ユニットテストフレームワーク-Footnote-414151471
Ref: unittest --- ユニットテストフレームワーク-Footnote-514151535
Ref: unittest --- ユニットテストフレームワーク-Footnote-614151593
Ref: unittest --- ユニットテストフレームワーク-Footnote-714151623
Ref: unittest --- ユニットテストフレームワーク-Footnote-814151655
Ref: unittest --- ユニットテストフレームワーク-Footnote-914151699
Node: 基本的な例<2>14151733
Ref: library/unittest basic-example14151900
Ref: 3edd14151900
Ref: library/unittest unittest-minimal-example14151900
Ref: 3ede14151900
Node: コマンドラインインターフェイス<5>14155288
Ref: library/unittest command-line-interface14155491
Ref: 3ee014155491
Ref: library/unittest unittest-command-line-interface14155491
Ref: f0114155491
Node: コマンドラインオプション<5>14157503
Ref: library/unittest command-line-options14157627
Ref: 3ee214157627
Ref: library/unittest cmdoption-unittest-b14157792
Ref: 130114157792
Ref: library/unittest cmdoption-unittest-buffer14157792
Ref: 3ee314157792
Ref: library/unittest cmdoption-unittest-c14158143
Ref: 130214158143
Ref: library/unittest cmdoption-unittest-catch14158143
Ref: 3ee414158143
Ref: library/unittest cmdoption-unittest-f14158544
Ref: 130414158544
Ref: library/unittest cmdoption-unittest-failfast14158544
Ref: 3ee614158544
Ref: library/unittest cmdoption-unittest-k14158654
Ref: 3ee714158654
Ref: library/unittest cmdoption-unittest-locals14159606
Ref: 3ee814159606
Ref: library/unittest cmdoption-unittest-durations14159695
Ref: 3ee914159695
Node: テストディスカバリ14160311
Ref: library/unittest test-discovery14160523
Ref: 3eea14160523
Ref: library/unittest unittest-test-discovery14160523
Ref: 3ee114160523
Ref: library/unittest cmdoption-unittest-discover-v14161713
Ref: 3eeb14161713
Ref: library/unittest cmdoption-unittest-discover-verbose14161713
Ref: 3eec14161713
Ref: library/unittest cmdoption-unittest-discover-s14161762
Ref: 3eed14161762
Ref: library/unittest cmdoption-unittest-discover-start-directory14161762
Ref: 3eee14161762
Ref: library/unittest cmdoption-unittest-discover-p14161894
Ref: 3eef14161894
Ref: library/unittest cmdoption-unittest-discover-pattern14161894
Ref: 3ef014161894
Ref: library/unittest cmdoption-unittest-discover-t14162023
Ref: 3ef114162023
Ref: library/unittest cmdoption-unittest-discover-top-level-directory14162023
Ref: 3ef214162023
Node: テストコードの構成14165059
Ref: library/unittest organizing-test-code14165259
Ref: 3ef414165259
Ref: library/unittest organizing-tests14165259
Ref: 3edf14165259
Node: 既存テストコードの再利用14171071
Ref: library/unittest legacy-unit-tests14171292
Ref: 3ef514171292
Ref: library/unittest re-using-old-test-code14171292
Ref: 3ef614171292
Node: テストのスキップと予期された失敗14173139
Ref: library/unittest skipping-tests-and-expected-failures14173405
Ref: 3ef714173405
Ref: library/unittest unittest-skipping14173405
Ref: 3ef814173405
Ref: library/unittest unittest skip14177057
Ref: 194414177057
Ref: library/unittest unittest skipIf14177251
Ref: 3efb14177251
Ref: library/unittest unittest skipUnless14177398
Ref: 3efc14177398
Ref: library/unittest unittest expectedFailure14177549
Ref: 3efa14177549
Ref: library/unittest unittest SkipTest14177953
Ref: fb114177953
Node: サブテストを利用して繰り返しテストの区別を付ける14178654
Ref: library/unittest distinguishing-test-iterations-using-subtests14178902
Ref: 3efd14178902
Ref: library/unittest subtests14178902
Ref: faf14178902
Node: クラスと関数14181609
Ref: library/unittest classes-and-functions14181857
Ref: 3efe14181857
Ref: library/unittest unittest-contents14181857
Ref: 3eff14181857
Node: テストクラス14182110
Ref: library/unittest test-cases14182219
Ref: 3f0014182219
Ref: library/unittest testcase-objects14182219
Ref: 3f0114182219
Ref: library/unittest unittest TestCase14182272
Ref: 41a14182272
Ref: library/unittest unittest TestCase setUp14184038
Ref: 130814184038
Ref: library/unittest unittest TestCase tearDown14184494
Ref: 130914184494
Ref: library/unittest unittest TestCase setUpClass14185402
Ref: a1d14185402
Ref: library/unittest unittest TestCase tearDownClass14185978
Ref: 130614185978
Ref: library/unittest unittest TestCase run14186574
Ref: 113914186574
Ref: library/unittest unittest TestCase skipTest14187500
Ref: 3ef914187500
Ref: library/unittest unittest TestCase subTest14187837
Ref: fae14187837
Ref: library/unittest unittest TestCase debug14188581
Ref: 17ff14188581
Ref: library/unittest assert-methods14188819
Ref: 3edc14188819
Ref: library/unittest unittest TestCase assertEqual14192882
Ref: 4f214192882
Ref: library/unittest unittest TestCase assertNotEqual14193925
Ref: 4f314193925
Ref: library/unittest unittest TestCase assertTrue14194136
Ref: 4f014194136
Ref: library/unittest unittest TestCase assertFalse14194187
Ref: 4f114194187
Ref: library/unittest unittest TestCase assertIs14194941
Ref: 130a14194941
Ref: library/unittest unittest TestCase assertIsNot14194999
Ref: 130b14194999
Ref: library/unittest unittest TestCase assertIsNone14195238
Ref: 125b14195238
Ref: library/unittest unittest TestCase assertIsNotNone14195291
Ref: 125c14195291
Ref: library/unittest unittest TestCase assertIn14195502
Ref: 131314195502
Ref: library/unittest unittest TestCase assertNotIn14195564
Ref: 131414195564
Ref: library/unittest unittest TestCase assertIsInstance14195789
Ref: 130c14195789
Ref: library/unittest unittest TestCase assertNotIsInstance14195850
Ref: 130d14195850
Ref: library/unittest unittest TestCase assertRaises14199394
Ref: 4f614199394
Ref: library/unittest unittest TestCase assertRaisesRegex14201620
Ref: 4f814201620
Ref: library/unittest unittest TestCase assertWarns14202822
Ref: 113714202822
Ref: library/unittest unittest TestCase assertWarnsRegex14205016
Ref: 113814205016
Ref: library/unittest unittest TestCase assertLogs14206105
Ref: 82414206105
Ref: library/unittest unittest TestCase records14207453
Ref: 3f0514207453
Ref: library/unittest unittest TestCase output14207625
Ref: 3f0614207625
Ref: library/unittest unittest TestCase assertNoLogs14208229
Ref: 82314208229
Ref: library/unittest unittest TestCase assertAlmostEqual14211909
Ref: 4f414211909
Ref: library/unittest unittest TestCase assertNotAlmostEqual14212013
Ref: 4f514212013
Ref: library/unittest unittest TestCase assertGreater14213325
Ref: 130e14213325
Ref: library/unittest unittest TestCase assertGreaterEqual14213388
Ref: 130f14213388
Ref: library/unittest unittest TestCase assertLess14213456
Ref: 131014213456
Ref: library/unittest unittest TestCase assertLessEqual14213516
Ref: 131114213516
Ref: library/unittest unittest TestCase assertRegex14213960
Ref: 4f714213960
Ref: library/unittest unittest TestCase assertNotRegex14214019
Ref: 4f914214019
Ref: library/unittest unittest TestCase assertCountEqual14214962
Ref: 11fb14214962
Ref: library/unittest type-specific-methods14215824
Ref: 3f0414215824
Ref: library/unittest unittest TestCase addTypeEqualityFunc14216263
Ref: 131714216263
Ref: library/unittest unittest TestCase assertMultiLineEqual14219395
Ref: 131214219395
Ref: library/unittest unittest TestCase assertSequenceEqual14219905
Ref: 125a14219905
Ref: library/unittest unittest TestCase assertListEqual14220634
Ref: 125814220634
Ref: library/unittest unittest TestCase assertTupleEqual14220699
Ref: 125914220699
Ref: library/unittest unittest TestCase assertSetEqual14221245
Ref: 125614221245
Ref: library/unittest unittest TestCase assertDictEqual14221810
Ref: 125714221810
Ref: library/unittest other-methods-and-attrs14222215
Ref: 3f0814222215
Ref: library/unittest unittest TestCase fail14222308
Ref: 3f0914222308
Ref: library/unittest unittest TestCase failureException14222502
Ref: 3f0714222502
Ref: library/unittest unittest TestCase longMessage14222904
Ref: 130514222904
Ref: library/unittest unittest TestCase maxDiff14223872
Ref: 11fc14223872
Ref: library/unittest unittest TestCase countTestCases14224655
Ref: 3f0a14224655
Ref: library/unittest unittest TestCase defaultTestResult14224870
Ref: 3f0314224870
Ref: library/unittest unittest TestCase id14225459
Ref: 3f0b14225459
Ref: library/unittest unittest TestCase shortDescription14225694
Ref: 3f0c14225694
Ref: library/unittest unittest TestCase addCleanup14226396
Ref: a4f14226396
Ref: library/unittest unittest TestCase enterContext14227145
Ref: 68514227145
Ref: library/unittest unittest TestCase doCleanups14227480
Ref: 130714227480
Ref: library/unittest unittest TestCase addClassCleanup14228284
Ref: a1c14228284
Ref: library/unittest unittest TestCase enterClassContext14229084
Ref: 68614229084
Ref: library/unittest unittest TestCase doClassCleanups14229441
Ref: 3f0d14229441
Ref: library/unittest unittest IsolatedAsyncioTestCase14230295
Ref: 2e414230295
Ref: library/unittest unittest IsolatedAsyncioTestCase loop_factory14230535
Ref: 3f0e14230535
Ref: library/unittest unittest IsolatedAsyncioTestCase asyncSetUp14230791
Ref: 3f0f14230791
Ref: library/unittest unittest IsolatedAsyncioTestCase asyncTearDown14231382
Ref: 3f1014231382
Ref: library/unittest unittest IsolatedAsyncioTestCase addAsyncCleanup14232386
Ref: 3f1114232386
Ref: library/unittest unittest IsolatedAsyncioTestCase enterAsyncContext14232591
Ref: 68714232591
Ref: library/unittest unittest IsolatedAsyncioTestCase run14232962
Ref: 3f1214232962
Ref: library/unittest unittest FunctionTestCase14234905
Ref: 166e14234905
Node: テストのグループ化14235462
Ref: library/unittest grouping-tests14235610
Ref: 3f1314235610
Ref: library/unittest testsuite-objects14235610
Ref: 3f1414235610
Ref: library/unittest unittest TestSuite14235678
Ref: dc114235678
Ref: library/unittest unittest TestSuite addTest14236973
Ref: 3f1514236973
Ref: library/unittest unittest TestSuite addTests14237142
Ref: 3f1614237142
Ref: library/unittest unittest TestSuite run14237652
Ref: 3f1714237652
Ref: library/unittest unittest TestSuite debug14238003
Ref: 3f1814238003
Ref: library/unittest unittest TestSuite countTestCases14238349
Ref: 3f1914238349
Ref: library/unittest unittest TestSuite __iter__14238582
Ref: ff314238582
Node: テストのロードと起動14240154
Ref: library/unittest loading-and-running-tests14240275
Ref: 3f1a14240275
Ref: library/unittest unittest TestLoader14240348
Ref: 26e14240348
Ref: library/unittest unittest TestLoader errors14240996
Ref: e5714240996
Ref: library/unittest unittest TestLoader loadTestsFromTestCase14241600
Ref: 27014241600
Ref: library/unittest unittest TestLoader loadTestsFromModule14242319
Ref: 26f14242319
Ref: library/unittest unittest TestLoader loadTestsFromName14244090
Ref: 131514244090
Ref: library/unittest unittest TestLoader loadTestsFromNames14246257
Ref: 3f1c14246257
Ref: library/unittest unittest TestLoader getTestCaseNames14246645
Ref: 27114246645
Ref: library/unittest unittest TestLoader discover14246932
Ref: fb214246932
Ref: library/unittest unittest TestLoader testMethodPrefix14251072
Ref: 3f1d14251072
Ref: library/unittest unittest TestLoader sortTestMethodsUsing14251380
Ref: 3f1e14251380
Ref: library/unittest unittest TestLoader suiteClass14251591
Ref: 131614251591
Ref: library/unittest unittest TestLoader testNamePatterns14251921
Ref: 3f1f14251921
Ref: library/unittest unittest TestResult14252938
Ref: 113a14252938
Ref: library/unittest unittest TestResult errors14253826
Ref: 3f2014253826
Ref: library/unittest unittest TestResult failures14254119
Ref: 3f2114254119
Ref: library/unittest unittest TestResult skipped14254403
Ref: 3f2214254403
Ref: library/unittest unittest TestResult expectedFailures14254639
Ref: 3f2314254639
Ref: library/unittest unittest TestResult unexpectedSuccesses14254945
Ref: 3f2414254945
Ref: library/unittest unittest TestResult collectedDurations14255135
Ref: 167414255135
Ref: library/unittest unittest TestResult shouldStop14255345
Ref: 3f2514255345
Ref: library/unittest unittest TestResult testsRun14255501
Ref: 3f2714255501
Ref: library/unittest unittest TestResult buffer14255597
Ref: 3f2814255597
Ref: library/unittest unittest TestResult failfast14256169
Ref: 3f2b14256169
Ref: library/unittest unittest TestResult tb_locals14256393
Ref: 3f2c14256393
Ref: library/unittest unittest TestResult wasSuccessful14256544
Ref: 3f2d14256544
Ref: library/unittest unittest TestResult stop14256968
Ref: 3f2614256968
Ref: library/unittest unittest TestResult startTest14258109
Ref: 3f2914258109
Ref: library/unittest unittest TestResult stopTest14258217
Ref: 3f2a14258217
Ref: library/unittest unittest TestResult startTestRun14258351
Ref: 131914258351
Ref: library/unittest unittest TestResult stopTestRun14258511
Ref: 131a14258511
Ref: library/unittest unittest TestResult addError14258670
Ref: 180214258670
Ref: library/unittest unittest TestResult addFailure14259244
Ref: 180114259244
Ref: library/unittest unittest TestResult addSuccess14259797
Ref: 3f2e14259797
Ref: library/unittest unittest TestResult addSkip14259988
Ref: 180314259988
Ref: library/unittest unittest TestResult addExpectedFailure14260354
Ref: 3f2f14260354
Ref: library/unittest unittest TestResult addUnexpectedSuccess14260859
Ref: 3f3014260859
Ref: library/unittest unittest TestResult addSubTest14261202
Ref: 180414261202
Ref: library/unittest unittest TestResult addDuration14261987
Ref: 16ae14261987
Ref: library/unittest unittest TextTestResult14262239
Ref: 4fa14262239
Ref: library/unittest unittest defaultTestLoader14262649
Ref: 3f1b14262649
Ref: library/unittest unittest TextTestRunner14262987
Ref: 16ad14262987
Ref: library/unittest unittest TextTestRunner _makeResult14264707
Ref: 3f3214264707
Ref: library/unittest unittest TextTestRunner run14265593
Ref: 3f3314265593
Ref: library/unittest unittest main14266080
Ref: fb014266080
Node: load_tests プロトコル14269580
Ref: library/unittest id114269673
Ref: 3ef314269673
Ref: library/unittest load-tests-protocol14269673
Ref: 3e9b14269673
Node: クラスとモジュールのフィクスチャ14272987
Ref: library/unittest class-and-module-fixtures14273193
Ref: 3f0214273193
Node: setUpClass と tearDownClass14275648
Ref: library/unittest setupclass-and-teardownclass14275800
Ref: 3f3414275800
Node: setUpModule と tearDownModule14276838
Ref: library/unittest setupmodule-and-teardownmodule14276990
Ref: 3f3514276990
Ref: library/unittest unittest addModuleCleanup14277724
Ref: a1b14277724
Ref: library/unittest unittest enterModuleContext14278433
Ref: 68814278433
Ref: library/unittest unittest doModuleCleanups14278771
Ref: 17a714278771
Node: シグナルハンドリング14279536
Ref: library/unittest signal-handling14279715
Ref: 3ee514279715
Ref: library/unittest unittest installHandler14281214
Ref: 3f3614281214
Ref: library/unittest unittest registerResult14281521
Ref: 3f3714281521
Ref: library/unittest unittest removeResult14282122
Ref: 3f3814282122
Ref: library/unittest unittest removeHandler14282399
Ref: 130314282399
Node: unittest mock --- モックオブジェクトライブラリ14282907
Ref: library/unittest mock doc14283116
Ref: 3f3914283116
Ref: library/unittest mock module-unittest mock14283116
Ref: f014283116
Ref: library/unittest mock unittest-mock-mock-object-library14283116
Ref: 3f3a14283116
Ref: unittest mock --- モックオブジェクトライブラリ-Footnote-114285143
Ref: unittest mock --- モックオブジェクトライブラリ-Footnote-214285216
Node: クイックガイド14285255
Ref: library/unittest mock quick-guide14285396
Ref: 3f3b14285396
Node: Mock クラス14291682
Ref: library/unittest mock the-mock-class14291839
Ref: 3f4014291839
Ref: library/unittest mock unittest mock Mock14293140
Ref: a1a14293140
Ref: library/unittest mock unittest mock Mock assert_called14297412
Ref: cc614297412
Ref: library/unittest mock unittest mock Mock assert_called_once14297751
Ref: cc714297751
Ref: library/unittest mock unittest mock Mock assert_called_with14298425
Ref: 198c14298425
Ref: library/unittest mock unittest mock Mock assert_called_once_with14298815
Ref: 3f4614298815
Ref: library/unittest mock unittest mock Mock assert_any_call14299534
Ref: 3f4714299534
Ref: library/unittest mock unittest mock Mock assert_has_calls14300238
Ref: 160c14300238
Ref: library/unittest mock unittest mock Mock assert_not_called14301328
Ref: e5914301328
Ref: library/unittest mock unittest mock Mock reset_mock14301845
Ref: cc814301845
Ref: library/unittest mock unittest mock Mock mock_add_spec14303036
Ref: 3f4914303036
Ref: library/unittest mock unittest mock Mock attach_mock14303446
Ref: 157214303446
Ref: library/unittest mock unittest mock Mock configure_mock14303744
Ref: 3f4514303744
Ref: library/unittest mock unittest mock Mock __dir__14305032
Ref: 3f4b14305032
Ref: library/unittest mock unittest mock Mock _get_child_mock14305479
Ref: 3f4d14305479
Ref: library/unittest mock unittest mock Mock called14306038
Ref: 3f4e14306038
Ref: library/unittest mock unittest mock Mock call_count14306322
Ref: 3f4f14306322
Ref: library/unittest mock unittest mock Mock return_value14306649
Ref: 3f4414306649
Ref: library/unittest mock unittest mock Mock side_effect14307494
Ref: 3f3c14307494
Ref: library/unittest mock unittest mock Mock call_args14310164
Ref: 18eb14310164
Ref: library/unittest mock unittest mock Mock call_args_list14312129
Ref: 3f5014312129
Ref: library/unittest mock unittest mock Mock method_calls14313380
Ref: 3f4a14313380
Ref: library/unittest mock unittest mock Mock mock_calls14314207
Ref: 3f4814314207
Ref: library/unittest mock unittest mock Mock __class__14315911
Ref: 3f5214315911
Ref: library/unittest mock unittest mock NonCallableMock14316670
Ref: 3f4114316670
Ref: library/unittest mock unittest mock PropertyMock14319546
Ref: 3f5314319546
Ref: library/unittest mock unittest mock AsyncMock14321585
Ref: a1914321585
Ref: library/unittest mock unittest mock AsyncMock assert_awaited14324452
Ref: 3f5414324452
Ref: library/unittest mock unittest mock AsyncMock assert_awaited_once14325193
Ref: 3f5514325193
Ref: library/unittest mock unittest mock AsyncMock assert_awaited_with14325757
Ref: 3f5614325757
Ref: library/unittest mock unittest mock AsyncMock assert_awaited_once_with14326433
Ref: 3f5714326433
Ref: library/unittest mock unittest mock AsyncMock assert_any_await14327164
Ref: 3f5814327164
Ref: library/unittest mock unittest mock AsyncMock assert_has_awaits14327813
Ref: 3f5914327813
Ref: library/unittest mock unittest mock AsyncMock assert_not_awaited14328914
Ref: 3f5a14328914
Ref: library/unittest mock unittest mock AsyncMock reset_mock14329095
Ref: 3f5b14329095
Ref: library/unittest mock unittest mock AsyncMock await_count14329332
Ref: 3f5c14329332
Ref: library/unittest mock unittest mock AsyncMock await_args14329778
Ref: 3f5d14329778
Ref: library/unittest mock unittest mock AsyncMock await_args_list14330397
Ref: 18ea14330397
Ref: library/unittest mock unittest mock ThreadingMock14331109
Ref: 3f5e14331109
Ref: library/unittest mock unittest mock ThreadingMock wait_until_called14331820
Ref: 3f6014331820
Ref: library/unittest mock unittest mock ThreadingMock wait_until_any_call_with14332379
Ref: 3f6114332379
Ref: library/unittest mock unittest mock ThreadingMock DEFAULT_TIMEOUT14332984
Ref: 3f5f14332984
Ref: Mock クラス-Footnote-114333316
Node: 呼び出し14333847
Ref: library/unittest mock calling14333934
Ref: 3f6214333934
Node: 属性の削除14337494
Ref: library/unittest mock deleting-attributes14337619
Ref: 3f6314337619
Ref: library/unittest mock id214337619
Ref: 3f6414337619
Node: Mock の名前と name 属性14338446
Ref: library/unittest mock mock-names-and-the-name-attribute14338598
Ref: 3f6514338598
Node: 属性として設定されるモック14339275
Ref: library/unittest mock attaching-mocks-as-attributes14339403
Ref: 3f6614339403
Node: patcher14341409
Ref: library/unittest mock the-patchers14341587
Ref: 3f6714341587
Node: patch14342340
Ref: library/unittest mock patch14342410
Ref: 3f6814342410
Ref: library/unittest mock unittest mock patch14342610
Ref: e5b14342610
Node: patch object14352524
Ref: library/unittest mock patch-object14352613
Ref: 3f6a14352613
Ref: library/unittest mock unittest mock patch object14352658
Ref: 14ff14352658
Node: patch dict14354371
Ref: library/unittest mock patch-dict14354469
Ref: 3f6b14354469
Ref: library/unittest mock unittest mock patch dict14354512
Ref: 195e14354512
Node: patch multiple14358830
Ref: library/unittest mock patch-multiple14358952
Ref: 3f6d14358952
Ref: library/unittest mock unittest mock patch multiple14359003
Ref: 3f6e14359003
Node: patch のメソッド start と stop14362237
Ref: library/unittest mock patch-methods-start-and-stop14362382
Ref: 3f6f14362382
Ref: library/unittest mock start-and-stop14362382
Ref: 3f7014362382
Ref: library/unittest mock unittest mock patch stopall14365265
Ref: 3f7114365265
Node: ビルトインをパッチする14365425
Ref: library/unittest mock id414365567
Ref: 3f7214365567
Ref: library/unittest mock patch-builtins14365567
Ref: 3f7314365567
Node: TEST_PREFIX14365988
Ref: library/unittest mock id514366133
Ref: 3f7414366133
Ref: library/unittest mock test-prefix14366133
Ref: 3f6c14366133
Node: patch デコレータをネストする14367131
Ref: library/unittest mock nesting-patch-decorators14367270
Ref: 3f7514367270
Node: どこにパッチするか14368306
Ref: library/unittest mock id614368503
Ref: 3f6914368503
Ref: library/unittest mock where-to-patch14368503
Ref: 3f3d14368503
Node: デスクリプタやプロキシオブジェクトにパッチする14370913
Ref: library/unittest mock patching-descriptors-and-proxy-objects14371062
Ref: 3f7614371062
Ref: デスクリプタやプロキシオブジェクトにパッチする-Footnote-114371728
Node: MagicMock と magic method のサポート14371853
Ref: library/unittest mock magicmock-and-magic-method-support14372029
Ref: 3f7714372029
Node: Magic Method をモックする14372191
Ref: library/unittest mock magic-methods14372320
Ref: 3f3e14372320
Ref: library/unittest mock mocking-magic-methods14372320
Ref: 3f7814372320
Ref: Magic Method をモックする-Footnote-114376570
Ref: Magic Method をモックする-Footnote-214376949
Node: Magic Mock14377073
Ref: library/unittest mock magic-mock14377202
Ref: 3f7a14377202
Ref: library/unittest mock unittest mock MagicMock14377371
Ref: e5a14377371
Ref: library/unittest mock unittest mock NonCallableMagicMock14377881
Ref: 3f4214377881
Node: ヘルパー14381613
Ref: library/unittest mock helpers14381839
Ref: 3f7b14381839
Node: sentinel14382024
Ref: library/unittest mock sentinel14382097
Ref: 3f7c14382097
Ref: library/unittest mock unittest mock sentinel14382136
Ref: b6e14382136
Node: DEFAULT14383597
Ref: library/unittest mock default14383683
Ref: 3f7d14383683
Ref: library/unittest mock unittest mock DEFAULT14383720
Ref: 3f4314383720
Node: call14384021
Ref: library/unittest mock call14384114
Ref: 3f7e14384114
Ref: library/unittest mock unittest mock call14384145
Ref: 193914384145
Ref: library/unittest mock unittest mock call call_list14384764
Ref: 3f7f14384764
Ref: library/unittest mock calls-as-tuples14385898
Ref: 3f5114385898
Node: create_autospec14387711
Ref: library/unittest mock create-autospec14387800
Ref: 3f8014387800
Ref: library/unittest mock unittest mock create_autospec14387853
Ref: 156b14387853
Node: ANY14389395
Ref: library/unittest mock any14389490
Ref: 3f8114389490
Ref: library/unittest mock unittest mock ANY14389519
Ref: 193714389519
Node: FILTER_DIR14390799
Ref: library/unittest mock filter-dir14390888
Ref: 3f8214390888
Ref: library/unittest mock unittest mock FILTER_DIR14390931
Ref: 3f4c14390931
Node: mock_open14393326
Ref: library/unittest mock mock-open14393430
Ref: 3f8314393430
Ref: library/unittest mock unittest mock mock_open14393471
Ref: 166f14393471
Ref: mock_open-Footnote-114396625
Node: autospec を使う14396650
Ref: library/unittest mock auto-speccing14396757
Ref: 3f3f14396757
Ref: library/unittest mock autospeccing14396757
Ref: 3f8414396757
Ref: autospec を使う-Footnote-114406452
Node: Sealing mocks14406820
Ref: library/unittest mock sealing-mocks14406909
Ref: 3f8514406909
Ref: library/unittest mock unittest mock seal14406958
Ref: b6f14406958
Node: Order of precedence of side_effect return_value and wraps14407771
Ref: library/unittest mock order-of-precedence-of-side-effect-return-value-and-wraps14407946
Ref: 3f8614407946
Node: unittest mock --- 入門14412029
Ref: library/unittest mock-examples doc14412227
Ref: 3f8714412227
Ref: library/unittest mock-examples unittest-mock-getting-started14412227
Ref: 3f8814412227
Ref: library/unittest mock-examples getting-started14412319
Ref: 3f8914412319
Node: Mock を使う14412394
Ref: library/unittest mock-examples using-mock14412499
Ref: 3f8a14412499
Node: Mock のパッチ用メソッド14413111
Ref: library/unittest mock-examples mock-patching-methods14413269
Ref: 3f8b14413269
Node: オブジェクトのメソッド呼び出しに対するモック14415119
Ref: library/unittest mock-examples mock-for-method-calls-on-an-object14415313
Ref: 3f8c14415313
Node: クラスをモックする14416894
Ref: library/unittest mock-examples mocking-classes14417086
Ref: 3f8d14417086
Node: モックに名前をつける14418372
Ref: library/unittest mock-examples naming-your-mocks14418540
Ref: 3f8e14418540
Node: 全ての呼び出しのトラッキング14419080
Ref: library/unittest mock-examples tracking-all-calls14419254
Ref: 3f8f14419254
Node: 戻り値や属性を設定する14420865
Ref: library/unittest mock-examples setting-return-values-and-attributes14421048
Ref: 3f9014421048
Node: モックから例外を発生させる14422671
Ref: library/unittest mock-examples raising-exceptions-with-mocks14422845
Ref: 3f9114422845
Node: side_effect の関数と iterable14423289
Ref: library/unittest mock-examples side-effect-functions-and-iterables14423472
Ref: 3f9214423472
Node: 非同期イテレータをモックする14424645
Ref: library/unittest mock-examples mocking-asynchronous-iterators14424849
Ref: 3f9314424849
Node: 非同期コンテキストマネージャをモックする14425519
Ref: library/unittest mock-examples mocking-asynchronous-context-manager14425738
Ref: 3f9414425738
Node: 既存のオブジェクトから Mock を作る14426768
Ref: library/unittest mock-examples creating-a-mock-from-an-existing-object14426989
Ref: 3f9514426989
Node: Using side_effect to return per file content14429039
Ref: library/unittest mock-examples using-side-effect-to-return-per-file-content14429191
Ref: 3f9614429191
Node: patch デコレータ14430042
Ref: library/unittest mock-examples patch-decorators14430171
Ref: 3f9714430171
Node: さらなる例14435894
Ref: library/unittest mock-examples further-examples14436000
Ref: 3f9814436000
Ref: library/unittest mock-examples id114436000
Ref: 3f9914436000
Node: chained call をモックする14436747
Ref: library/unittest mock-examples mocking-chained-calls14436860
Ref: 3f9a14436860
Node: 部分的なモック14440662
Ref: library/unittest mock-examples partial-mocking14440832
Ref: 3f9b14440832
Ref: 部分的なモック-Footnote-114443442
Node: ジェネレータメソッドをモックする14443543
Ref: library/unittest mock-examples mocking-a-generator-method14443736
Ref: 3f9c14443736
Ref: ジェネレータメソッドをモックする-Footnote-114445168
Node: 同じパッチを全てのメソッドに適用する14445553
Ref: library/unittest mock-examples applying-the-same-patch-to-every-test-method14445762
Ref: 3f9d14445762
Node: Unboundメソッドをモックする14448349
Ref: library/unittest mock-examples mocking-unbound-methods14448567
Ref: 3f9e14448567
Node: モックで複数回の呼び出しをチェックする14450406
Ref: library/unittest mock-examples checking-multiple-calls-with-mock14450612
Ref: 3f9f14450612
Node: ミュータブルな引数に対処する14452411
Ref: library/unittest mock-examples coping-with-mutable-arguments14452604
Ref: 3fa014452604
Node: patch をネストする14457166
Ref: library/unittest mock-examples nesting-patches14457339
Ref: 3fa114457339
Node: MagicMock で辞書をモックする14459166
Ref: library/unittest mock-examples mocking-a-dictionary-with-magicmock14459329
Ref: 3fa214459329
Node: Mock のサブクラスと属性14461971
Ref: library/unittest mock-examples mock-subclasses-and-their-attributes14462150
Ref: 3fa314462150
Ref: Mock のサブクラスと属性-Footnote-114464259
Ref: Mock のサブクラスと属性-Footnote-214464427
Ref: Mock のサブクラスと属性-Footnote-314464485
Node: patch dict で import をモックする14464566
Ref: library/unittest mock-examples mocking-imports-with-patch-dict14464764
Ref: 3fa414464764
Node: Tracking order of calls and less verbose call assertions14467407
Ref: library/unittest mock-examples tracking-order-of-calls-and-less-verbose-call-assertions14467603
Ref: 3fa514467603
Node: More complex argument matching14470936
Ref: library/unittest mock-examples more-complex-argument-matching14471083
Ref: 3fa614471083
Ref: More complex argument matching-Footnote-114474152
Ref: More complex argument matching-Footnote-214474195
Node: test --- Regression tests package for Python14474317
Ref: library/test doc14474520
Ref: 3fa714474520
Ref: library/test module-test14474520
Ref: cb14474520
Ref: library/test test-regression-tests-package-for-python14474520
Ref: 3fa814474520
Node: test パッケージのためのユニットテストを書く14476394
Ref: library/test writing-tests14476630
Ref: 3fa914476630
Ref: library/test writing-unit-tests-for-the-test-package14476630
Ref: 3faa14476630
Node: コマンドラインインターフェースを利用してテストを実行する14482646
Ref: library/test module-test regrtest14482882
Ref: cc14482882
Ref: library/test regrtest14482882
Ref: fd414482882
Ref: library/test running-tests-using-the-command-line-interface14482882
Ref: 3fab14482882
Node: test support --- テストのためのユーティリティ関数14485517
Ref: library/test module-test support14485753
Ref: cd14485753
Ref: library/test test-support-utilities-for-the-python-test-suite14485753
Ref: 3fac14485753
Ref: library/test test support TestFailed14486435
Ref: 3fad14486435
Ref: library/test test support ResourceDenied14486708
Ref: 3fae14486708
Ref: library/test test support verbose14487078
Ref: 3fb014487078
Ref: library/test test support is_jython14487365
Ref: 3fb114487365
Ref: library/test test support is_android14487491
Ref: 3fb214487491
Ref: library/test test support unix_shell14487601
Ref: 3fb314487601
Ref: library/test test support LOOPBACK_TIMEOUT14487739
Ref: 191f14487739
Ref: library/test test support INTERNET_TIMEOUT14488362
Ref: 192014488362
Ref: library/test test support SHORT_TIMEOUT14488889
Ref: 181914488889
Ref: library/test test support LONG_TIMEOUT14489285
Ref: 192114489285
Ref: library/test test support PGO14489798
Ref: 3fb514489798
Ref: library/test test support PIPE_MAX_SIZE14489966
Ref: 3fb614489966
Ref: library/test test support Py_DEBUG14490155
Ref: 3fb714490155
Ref: library/test test support SOCK_MAX_SIZE14490365
Ref: 3fb914490365
Ref: library/test test support TEST_SUPPORT_DIR14490557
Ref: 3fba14490557
Ref: library/test test support TEST_HOME_DIR14490694
Ref: 3fbb14490694
Ref: library/test test support TEST_DATA_DIR14490819
Ref: 3fbc14490819
Ref: library/test test support MAX_Py_ssize_t14490950
Ref: 3fbd14490950
Ref: library/test test support max_memuse14491102
Ref: 3fbe14491102
Ref: library/test test support real_max_memuse14491335
Ref: 3fc014491335
Ref: library/test test support MISSING_C_DOCSTRINGS14491585
Ref: 3fc114491585
Ref: library/test test support HAVE_DOCSTRINGS14491877
Ref: 3fc214491877
Ref: library/test test support TEST_HTTP_URL14492157
Ref: 3fc314492157
Ref: library/test test support ALWAYS_EQ14492290
Ref: 3fc414492290
Ref: library/test test support NEVER_EQ14492411
Ref: 3fc514492411
Ref: library/test test support LARGEST14492568
Ref: 3fc614492568
Ref: library/test test support SMALLEST14492707
Ref: 3fc714492707
Ref: library/test test support busy_retry14492934
Ref: 3fc814492934
Ref: library/test test support sleeping_retry14493603
Ref: 3fc914493603
Ref: library/test test support is_resource_enabled14494488
Ref: 3fca14494488
Ref: library/test test support python_is_optimized14494775
Ref: 3fcb14494775
Ref: library/test test support with_pymalloc14494904
Ref: 3fcc14494904
Ref: library/test test support requires14494994
Ref: 3faf14494994
Ref: library/test test support sortdict14495466
Ref: 3fcd14495466
Ref: library/test test support findfile14495559
Ref: 3fce14495559
Ref: library/test test support get_pagesize14496114
Ref: 3fcf14496114
Ref: library/test test support setswitchinterval14496223
Ref: 3fd014496223
Ref: library/test test support check_impl_detail14496450
Ref: 3fd114496450
Ref: library/test test support set_memlimit14496967
Ref: 3fbf14496967
Ref: library/test test support record_original_stdout14497126
Ref: 3fd214497126
Ref: library/test test support get_original_stdout14497293
Ref: 3fd314497293
Ref: library/test test support args_from_interpreter_flags14497465
Ref: 3fd414497465
Ref: library/test test support optim_args_from_interpreter_flags14497655
Ref: 3fd514497655
Ref: library/test test support captured_stdin14497838
Ref: 3fd614497838
Ref: library/test test support captured_stdout14497884
Ref: 3fd714497884
Ref: library/test test support captured_stderr14497931
Ref: 196114497931
Ref: library/test test support disable_faulthandler14498711
Ref: 3fd814498711
Ref: library/test test support gc_collect14498836
Ref: 3fd914498836
Ref: library/test test support disable_gc14499173
Ref: 3fda14499173
Ref: library/test test support swap_attr14499355
Ref: 3fdb14499355
Ref: library/test test support swap_item14499938
Ref: 3fdc14499938
Ref: library/test test support flush_std_streams14500519
Ref: 3fdd14500519
Ref: library/test test support print_warning14500796
Ref: 3fde14500796
Ref: library/test test support wait_process14501071
Ref: 18df14501071
Ref: library/test test support calcobjsize14501591
Ref: 3fe014501591
Ref: library/test test support calcvobjsize14501825
Ref: 3fe114501825
Ref: library/test test support checksizeof14502064
Ref: 3fe314502064
Ref: library/test test support anticipate_failure14502236
Ref: 3fe414502236
Ref: library/test test support system_must_validate_cert14502550
Ref: 3fe514502550
Ref: library/test test support run_with_locale14502704
Ref: 3fe614502704
Ref: library/test test support run_with_tz14503142
Ref: 3fe714503142
Ref: library/test test support requires_freebsd_version14503305
Ref: 3fe814503305
Ref: library/test test support requires_linux_version14503520
Ref: 3fe914503520
Ref: library/test test support requires_mac_version14503730
Ref: 3fea14503730
Ref: library/test test support requires_gil_enabled14503937
Ref: 3feb14503937
Ref: library/test test support requires_IEEE_75414504114
Ref: 3fec14504114
Ref: library/test test support requires_zlib14504224
Ref: 3fed14504224
Ref: library/test test support requires_gzip14504338
Ref: 3fee14504338
Ref: library/test test support requires_bz214504451
Ref: 3fef14504451
Ref: library/test test support requires_lzma14504561
Ref: 3ff014504561
Ref: library/test test support requires_resource14504674
Ref: 3ff114504674
Ref: library/test test support requires_docstrings14504800
Ref: 3ff214504800
Ref: library/test test support requires_limited_api14504924
Ref: 3ff314504924
Ref: library/test test support cpython_only14505065
Ref: 3ff414505065
Ref: library/test test support impl_detail14505162
Ref: 3ff514505162
Ref: library/test test support no_tracing14505393
Ref: 3ff614505393
Ref: library/test test support refcount_test14505517
Ref: 3ff714505517
Ref: library/test test support bigmemtest14505822
Ref: 3ff814505822
Ref: library/test test support bigaddrspacetest14506568
Ref: 3ff914506568
Ref: library/test test support check_syntax_error14506670
Ref: 3ffa14506670
Ref: library/test test support open_urlresource14507224
Ref: 3ffb14507224
Ref: library/test test support reap_children14507354
Ref: 3ffc14507354
Ref: library/test test support get_attribute14507629
Ref: 3ffd14507629
Ref: library/test test support catch_unraisable_exception14507792
Ref: 194314507792
Ref: library/test test support load_package_tests14508685
Ref: 3ffe14508685
Ref: library/test test support detect_api_mismatch14509313
Ref: 3fff14509313
Ref: library/test test support patch14509777
Ref: 400014509777
Ref: library/test test support run_in_subinterp14510114
Ref: 400114510114
Ref: library/test test support check_free_after_iterating14510283
Ref: 400214510283
Ref: library/test test support missing_compiler_executable14510441
Ref: 400314510441
Ref: library/test test support check__all__14510764
Ref: 18b614510764
Ref: library/test test support skip_if_broken_multiprocessing_synchronize14512575
Ref: 18b714512575
Ref: library/test test support check_disallow_instantiation14512869
Ref: 400414512869
Ref: library/test test support adjust_int_max_str_digits14513078
Ref: 400514513078
Ref: library/test test support SuppressCrashReport14513576
Ref: 400614513576
Ref: library/test test support SaveSignals14514081
Ref: 400914514081
Ref: library/test test support SaveSignals save14514216
Ref: 400a14514216
Ref: library/test test support SaveSignals restore14514368
Ref: 400b14514368
Ref: library/test test support Matcher14514513
Ref: 400c14514513
Ref: library/test test support Matcher matches14514550
Ref: 400d14514550
Ref: library/test test support Matcher match_value14514669
Ref: 400e14514669
Ref: test support --- テストのためのユーティリティ関数-Footnote-114514850
Node: test support socket_helper --- Utilities for socket tests14514930
Ref: library/test module-test support socket_helper14515193
Ref: d214515193
Ref: library/test test-support-socket-helper-utilities-for-socket-tests14515193
Ref: 400f14515193
Ref: library/test test support socket_helper IPV6_ENABLED14515440
Ref: 401014515440
Ref: library/test test support socket_helper find_unused_port14515576
Ref: 401114515576
Ref: library/test test support socket_helper bind_port14516898
Ref: 401214516898
Ref: library/test test support socket_helper bind_unix_socket14517844
Ref: 401314517844
Ref: library/test test support socket_helper skip_unless_bind_unix_socket14518028
Ref: 401414518028
Ref: library/test test support socket_helper transient_internet14518199
Ref: 3fb414518199
Node: test support script_helper --- Utilities for the Python execution tests14518473
Ref: library/test module-test support script_helper14518757
Ref: d114518757
Ref: library/test test-support-script-helper-utilities-for-the-python-execution-tests14518757
Ref: 401514518757
Ref: library/test test support script_helper interpreter_requires_environment14519028
Ref: 401614519028
Ref: library/test test support script_helper run_python_until_end14520000
Ref: 401714520000
Ref: library/test test support script_helper assert_python_ok14520386
Ref: 401814520386
Ref: library/test test support script_helper assert_python_failure14521027
Ref: 401914521027
Ref: library/test test support script_helper spawn_python14521469
Ref: 401a14521469
Ref: library/test test support script_helper kill_python14521783
Ref: 401b14521783
Ref: library/test test support script_helper make_script14521940
Ref: 401c14521940
Ref: library/test test support script_helper make_zip_script14522250
Ref: 401d14522250
Ref: library/test test support script_helper make_pkg14522620
Ref: 401e14522620
Ref: library/test test support script_helper make_zip_pkg14522824
Ref: 401f14522824
Node: test support bytecode_helper --- Support tools for testing correct bytecode generation14523355
Ref: library/test module-test support bytecode_helper14523645
Ref: ce14523645
Ref: library/test test-support-bytecode-helper-support-tools-for-testing-correct-bytecode-generation14523645
Ref: 402014523645
Ref: library/test test support bytecode_helper BytecodeTestCase14524023
Ref: 402114524023
Ref: library/test test support bytecode_helper BytecodeTestCase get_disassembly_as_string14524186
Ref: 402214524186
Ref: library/test test support bytecode_helper BytecodeTestCase assertInBytecode14524301
Ref: 402314524301
Ref: library/test test support bytecode_helper BytecodeTestCase assertNotInBytecode14524487
Ref: 402414524487
Node: test support threading_helper --- Utilities for threading tests14524648
Ref: library/test module-test support threading_helper14524916
Ref: d314524916
Ref: library/test test-support-threading-helper-utilities-for-threading-tests14524916
Ref: 402514524916
Ref: library/test test support threading_helper join_thread14525182
Ref: 402614525182
Ref: library/test test support threading_helper reap_threads14525405
Ref: 402714525405
Ref: library/test test support threading_helper start_threads14525547
Ref: 402814525547
Ref: library/test test support threading_helper threading_cleanup14525956
Ref: 402914525956
Ref: library/test test support threading_helper threading_setup14526195
Ref: 402a14526195
Ref: library/test test support threading_helper wait_threads_exit14526324
Ref: 402b14526324
Ref: library/test test support threading_helper catch_threading_exception14526508
Ref: 402c14526508
Node: test support os_helper --- Utilities for os tests14527474
Ref: library/test module-test support os_helper14527713
Ref: d014527713
Ref: library/test test-support-os-helper-utilities-for-os-tests14527713
Ref: 402d14527713
Ref: library/test test support os_helper FS_NONASCII14527937
Ref: 402e14527937
Ref: library/test test support os_helper SAVEDCWD14528068
Ref: 402f14528068
Ref: library/test test support os_helper TESTFN14528172
Ref: 403014528172
Ref: library/test test support os_helper TESTFN_NONASCII14528433
Ref: 403114528433
Ref: library/test test support os_helper TESTFN_UNENCODABLE14528821
Ref: 403214528821
Ref: library/test test support os_helper TESTFN_UNDECODABLE14529153
Ref: 403314529153
Ref: library/test test support os_helper TESTFN_UNICODE14529484
Ref: 403414529484
Ref: library/test test support os_helper EnvironmentVarGuard14529600
Ref: 138a14529600
Ref: library/test test support os_helper FakePath14530265
Ref: 403514530265
Ref: library/test test support os_helper EnvironmentVarGuard set14530531
Ref: 403614530531
Ref: library/test test support os_helper EnvironmentVarGuard unset14530666
Ref: 403714530666
Ref: library/test test support os_helper can_symlink14530783
Ref: 403814530783
Ref: library/test test support os_helper can_xattr14530986
Ref: 403914530986
Ref: library/test test support os_helper change_cwd14531111
Ref: 403a14531111
Ref: library/test test support os_helper create_empty_file14531576
Ref: 403b14531576
Ref: library/test test support os_helper fd_count14531729
Ref: 403c14531729
Ref: library/test test support os_helper fs_is_case_insensitive14531829
Ref: 403d14531829
Ref: library/test test support os_helper make_bad_fd14531988
Ref: 403e14531988
Ref: library/test test support os_helper rmdir14532184
Ref: 403f14532184
Ref: library/test test support os_helper rmtree14532493
Ref: 404014532493
Ref: library/test test support os_helper skip_unless_symlink14532837
Ref: 404114532837
Ref: library/test test support os_helper skip_unless_xattr14533021
Ref: 404214533021
Ref: library/test test support os_helper temp_cwd14533147
Ref: 404314533147
Ref: library/test test support os_helper temp_dir14533997
Ref: 404414533997
Ref: library/test test support os_helper temp_umask14534454
Ref: 404514534454
Ref: library/test test support os_helper unlink14534604
Ref: 404614534604
Node: test support import_helper --- Utilities for import tests14534850
Ref: library/test module-test support import_helper14535087
Ref: cf14535087
Ref: library/test test-support-import-helper-utilities-for-import-tests14535087
Ref: 404714535087
Ref: library/test test support import_helper forget14535335
Ref: 404814535335
Ref: library/test test support import_helper import_fresh_module14535575
Ref: 181814535575
Ref: library/test test support import_helper import_module14537482
Ref: 404914537482
Ref: library/test test support import_helper modules_setup14538215
Ref: 404a14538215
Ref: library/test test support import_helper modules_cleanup14538323
Ref: 404b14538323
Ref: library/test test support import_helper unload14538502
Ref: 404c14538502
Ref: library/test test support import_helper make_legacy_pyc14538619
Ref: 404d14538619
Ref: library/test test support import_helper CleanImport14538969
Ref: 404e14538969
Ref: library/test test support import_helper DirsOnSysPath14539363
Ref: 404f14539363
Ref: test support import_helper --- Utilities for import tests-Footnote-114539924
Ref: test support import_helper --- Utilities for import tests-Footnote-214539966
Node: test support warnings_helper --- Utilities for warnings tests14540008
Ref: library/test module-test support warnings_helper14540187
Ref: d414540187
Ref: library/test test-support-warnings-helper-utilities-for-warnings-tests14540187
Ref: 405014540187
Ref: library/test test support warnings_helper ignore_warnings14540447
Ref: 405114540447
Ref: library/test test support warnings_helper check_no_resource_warning14540961
Ref: 405214540961
Ref: library/test test support warnings_helper check_syntax_warning14541252
Ref: 405314541252
Ref: library/test test support warnings_helper check_warnings14542071
Ref: 405414542071
Ref: library/test test support warnings_helper WarningsRecorder14545546
Ref: 405514545546
Node: デバッグとプロファイル14545789
Ref: library/debug doc14545965
Ref: 405614545965
Ref: library/debug debugging-and-profiling14545965
Ref: 405714545965
Ref: library/audit_events audit-events14546442
Ref: 17db14546442
Node: 監査イベント表14547110
Ref: library/audit_events doc14547254
Ref: 405814547254
Ref: library/audit_events audit-events-table14547254
Ref: 405914547254
Ref: 監査イベント表-Footnote-114606050
Node: bdb --- デバッガーフレームワーク14606092
Ref: library/bdb doc14606308
Ref: 407814606308
Ref: library/bdb bdb-debugger-framework14606308
Ref: 407914606308
Ref: library/bdb module-bdb14606308
Ref: b14606308
Ref: library/bdb bdb BdbQuit14606751
Ref: 407a14606751
Ref: library/bdb bdb Breakpoint14606950
Ref: 407b14606950
Ref: library/bdb bdb Breakpoint deleteMe14608331
Ref: 408214608331
Ref: library/bdb bdb Breakpoint enable14608702
Ref: 408314608702
Ref: library/bdb bdb Breakpoint disable14608802
Ref: 408414608802
Ref: library/bdb bdb Breakpoint bpformat14608903
Ref: 408514608903
Ref: library/bdb bdb Breakpoint bpprint14609327
Ref: 408614609327
Ref: library/bdb bdb Breakpoint file14609612
Ref: 407e14609612
Ref: library/bdb bdb Breakpoint line14609690
Ref: 408714609690
Ref: library/bdb bdb Breakpoint temporary14609805
Ref: 408814609805
Ref: library/bdb bdb Breakpoint cond14609927
Ref: 408114609927
Ref: library/bdb bdb Breakpoint funcname14610042
Ref: 407f14610042
Ref: library/bdb bdb Breakpoint enabled14610189
Ref: 408914610189
Ref: library/bdb bdb Breakpoint bpbynumber14610279
Ref: 407c14610279
Ref: library/bdb bdb Breakpoint bplist14610397
Ref: 407d14610397
Ref: library/bdb bdb Breakpoint ignore14610551
Ref: 408a14610551
Ref: library/bdb bdb Breakpoint hits14610642
Ref: 408014610642
Ref: library/bdb bdb Bdb14610758
Ref: 12d014610758
Ref: library/bdb bdb Bdb canonic14611878
Ref: 408b14611878
Ref: library/bdb bdb Bdb reset14612263
Ref: 408c14612263
Ref: library/bdb bdb Bdb trace_dispatch14612461
Ref: 408e14612461
Ref: library/bdb bdb Bdb dispatch_line14614222
Ref: 408f14614222
Ref: library/bdb bdb Bdb dispatch_call14614705
Ref: 409114614705
Ref: library/bdb bdb Bdb dispatch_return14615195
Ref: 409314615195
Ref: library/bdb bdb Bdb dispatch_exception14615693
Ref: 409514615693
Ref: library/bdb bdb Bdb is_skipped_line14616442
Ref: 409714616442
Ref: library/bdb bdb Bdb stop_here14616568
Ref: 409814616568
Ref: library/bdb bdb Bdb break_here14616702
Ref: 409914616702
Ref: library/bdb bdb Bdb break_anywhere14617016
Ref: 409b14617016
Ref: library/bdb bdb Bdb user_call14617279
Ref: 409214617279
Ref: library/bdb bdb Bdb user_line14617586
Ref: 409014617586
Ref: library/bdb bdb Bdb user_return14617815
Ref: 409414617815
Ref: library/bdb bdb Bdb user_exception14618021
Ref: 409614618021
Ref: library/bdb bdb Bdb do_clear14618229
Ref: 409c14618229
Ref: library/bdb bdb Bdb set_step14618682
Ref: 409d14618682
Ref: library/bdb bdb Bdb set_next14618778
Ref: 409e14618778
Ref: library/bdb bdb Bdb set_return14618952
Ref: 409f14618952
Ref: library/bdb bdb Bdb set_until14619082
Ref: 40a014619082
Ref: library/bdb bdb Bdb set_trace14619311
Ref: 40a114619311
Ref: library/bdb bdb Bdb set_continue14619716
Ref: 40a314619716
Ref: library/bdb bdb Bdb set_quit14620000
Ref: 408d14620000
Ref: library/bdb bdb Bdb set_break14620518
Ref: 40a414620518
Ref: library/bdb bdb Bdb clear_break14620964
Ref: 40a514620964
Ref: library/bdb bdb Bdb clear_bpbynumber14621230
Ref: 40a614621230
Ref: library/bdb bdb Bdb clear_all_file_breaks14621528
Ref: 40a714621528
Ref: library/bdb bdb Bdb clear_all_breaks14621781
Ref: 40a814621781
Ref: library/bdb bdb Bdb get_bpbynumber14622013
Ref: 40a914622013
Ref: library/bdb bdb Bdb get_break14622461
Ref: 40aa14622461
Ref: library/bdb bdb Bdb get_breaks14622606
Ref: 40ab14622606
Ref: library/bdb bdb Bdb get_file_breaks14622854
Ref: 40ac14622854
Ref: library/bdb bdb Bdb get_all_breaks14623086
Ref: 40ad14623086
Ref: library/bdb bdb Bdb get_stack14623396
Ref: 40ae14623396
Ref: library/bdb bdb Bdb format_stack_entry14623693
Ref: 40af14623693
Ref: library/bdb bdb Bdb run14624327
Ref: 40b014624327
Ref: library/bdb bdb Bdb runeval14624563
Ref: 40b114624563
Ref: library/bdb bdb Bdb runctx14624801
Ref: 40b214624801
Ref: library/bdb bdb Bdb runcall14624973
Ref: a4c14624973
Ref: library/bdb bdb checkfuncname14625196
Ref: 40b314625196
Ref: library/bdb bdb effective14625650
Ref: 409a14625650
Ref: library/bdb bdb set_trace14626419
Ref: 40a214626419
Ref: bdb --- デバッガーフレームワーク-Footnote-114626632
Node: faulthandler --- Python トレースバックをダンプする14626695
Ref: library/faulthandler doc14626917
Ref: 40b414626917
Ref: library/faulthandler faulthandler-dump-the-python-traceback14626917
Ref: 40b514626917
Ref: library/faulthandler module-faulthandler14626917
Ref: 4e14626917
Node: tracebackのダンプ14630222
Ref: library/faulthandler dumping-the-traceback14630388
Ref: 40b614630388
Ref: library/faulthandler faulthandler dump_traceback14630447
Ref: dcb14630447
Node: フォールトハンドラの状態14630927
Ref: library/faulthandler fault-handler-state14631153
Ref: 40b714631153
Ref: library/faulthandler faulthandler enable14631234
Ref: c6c14631234
Ref: library/faulthandler faulthandler disable14632112
Ref: 40b914632112
Ref: library/faulthandler faulthandler is_enabled14632338
Ref: 40ba14632338
Node: タイムアウト後にtracebackをダンプする14632460
Ref: library/faulthandler dumping-the-tracebacks-after-a-timeout14632725
Ref: 40bb14632725
Ref: library/faulthandler faulthandler dump_traceback_later14632834
Ref: dcc14632834
Ref: library/faulthandler faulthandler cancel_dump_traceback_later14633879
Ref: 40bc14633879
Node: ユーザシグナルに対してtracebackをダンプする14634041
Ref: library/faulthandler dumping-the-traceback-on-a-user-signal14634300
Ref: 40bd14634300
Ref: library/faulthandler faulthandler register14634424
Ref: dca14634424
Ref: library/faulthandler faulthandler unregister14635203
Ref: 40be14635203
Node: ファイル記述子の問題14635603
Ref: library/faulthandler faulthandler-fd14635824
Ref: 40b814635824
Ref: library/faulthandler issue-with-file-descriptors14635824
Ref: 40bf14635824
Node: 使用例<42>14636437
Ref: library/faulthandler example14636589
Ref: 40c014636589
Node: pdb --- Python デバッガ14637177
Ref: library/pdb doc14637380
Ref: 40c114637380
Ref: library/pdb debugger14637380
Ref: 40c214637380
Ref: library/pdb module-pdb14637380
Ref: 9414637380
Ref: library/pdb pdb-the-python-debugger14637380
Ref: 40c314637380
Ref: library/pdb pdb run14641939
Ref: 3ece14641939
Ref: library/pdb pdb runeval14642863
Ref: 40c814642863
Ref: library/pdb pdb runcall14643258
Ref: 40c914643258
Ref: library/pdb pdb set_trace14643675
Ref: 21614643675
Ref: library/pdb pdb post_mortem14644265
Ref: 138214644265
Ref: library/pdb pdb pm14644680
Ref: 21814644680
Ref: library/pdb pdb Pdb14645100
Ref: 8f014645100
Ref: library/pdb pdb Pdb run14646934
Ref: 40ca14646934
Ref: library/pdb pdb Pdb runeval14647000
Ref: 40cb14647000
Ref: library/pdb pdb Pdb runcall14647071
Ref: 40cc14647071
Ref: library/pdb pdb Pdb set_trace14647128
Ref: 40cd14647128
Ref: pdb --- Python デバッガ-Footnote-114647327
Ref: pdb --- Python デバッガ-Footnote-214647390
Ref: pdb --- Python デバッガ-Footnote-314647432
Node: デバッガコマンド14647574
Ref: library/pdb debugger-commands14647662
Ref: 40c514647662
Ref: library/pdb id214647662
Ref: 40ce14647662
Ref: library/pdb pdbcommand-help14651653
Ref: 40d114651653
Ref: library/pdb pdbcommand-where14652187
Ref: 40d214652187
Ref: library/pdb pdbcommand-down14652482
Ref: 40d314652482
Ref: library/pdb pdbcommand-up14652670
Ref: 40d414652670
Ref: library/pdb pdbcommand-break14652853
Ref: 40d514652853
Ref: library/pdb pdbcommand-tbreak14654132
Ref: 40d614654132
Ref: library/pdb pdbcommand-clear14654377
Ref: 40d714654377
Ref: library/pdb pdbcommand-disable14654855
Ref: 40d814654855
Ref: library/pdb pdbcommand-enable14655277
Ref: 40d914655277
Ref: library/pdb pdbcommand-ignore14655392
Ref: 40da14655392
Ref: library/pdb pdbcommand-condition14655955
Ref: 40db14655955
Ref: library/pdb pdbcommand-commands14656382
Ref: 40dc14656382
Ref: library/pdb pdbcommand-step14658639
Ref: 40c614658639
Ref: library/pdb pdbcommand-next14658848
Ref: 40c714658848
Ref: library/pdb pdbcommand-until14659286
Ref: 40e014659286
Ref: library/pdb pdbcommand-return14659712
Ref: 40dd14659712
Ref: library/pdb pdbcommand-continue14659802
Ref: 40c414659802
Ref: library/pdb pdbcommand-jump14659911
Ref: 40de14659911
Ref: library/pdb pdbcommand-list14660372
Ref: 40cf14660372
Ref: library/pdb pdbcommand-ll14661357
Ref: 40e114661357
Ref: library/pdb pdbcommand-args14661594
Ref: 40e214661594
Ref: library/pdb pdbcommand-p14661699
Ref: f4314661699
Ref: library/pdb pdbcommand-pp14662055
Ref: 40e314662055
Ref: library/pdb pdbcommand-whatis14662256
Ref: 40e414662256
Ref: library/pdb pdbcommand-source14662338
Ref: 40e514662338
Ref: library/pdb pdbcommand-display14662499
Ref: 40e614662499
Ref: library/pdb pdbcommand-undisplay14664032
Ref: 40e714664032
Ref: library/pdb pdbcommand-interact14664338
Ref: 40e814664338
Ref: library/pdb debugger-aliases14665255
Ref: 40d014665255
Ref: library/pdb pdbcommand-alias14665255
Ref: 40e914665255
Ref: library/pdb pdbcommand-unalias14666565
Ref: 40ea14666565
Ref: library/pdb pdbcommand-014666658
Ref: 40eb14666658
Ref: library/pdb pdbcommand-run14667145
Ref: 40ec14667145
Ref: library/pdb pdbcommand-restart14667176
Ref: 40ed14667176
Ref: library/pdb pdbcommand-quit14667634
Ref: 40df14667634
Ref: library/pdb pdbcommand-debug14667758
Ref: 40ee14667758
Ref: library/pdb pdbcommand-retval14667946
Ref: 40ef14667946
Ref: library/pdb pdbcommand-exceptions14668044
Ref: 21914668044
Node: Python プロファイラ14669409
Ref: library/profile doc14669614
Ref: 40f014669614
Ref: library/profile profile14669614
Ref: 40f114669614
Ref: library/profile the-python-profilers14669614
Ref: 40f214669614
Ref: Python プロファイラ-Footnote-114670264
Ref: Python プロファイラ-Footnote-214670331
Node: プロファイラとは14670397
Ref: library/profile introduction-to-the-profilers14670528
Ref: 40f314670528
Ref: library/profile profiler-introduction14670528
Ref: 40f414670528
Node: かんたんユーザマニュアル14672906
Ref: library/profile instant-user-s-manual14673103
Ref: 40f514673103
Ref: library/profile profile-instant14673103
Ref: 40f614673103
Ref: library/profile profile-cli14676368
Ref: 40f814676368
Node: リファレンスマニュアル -- profile と cProfile14680322
Ref: library/profile module-cProfile14680510
Ref: 2014680510
Ref: library/profile profile-and-cprofile-module-reference14680510
Ref: 40fc14680510
Ref: library/profile module-profile14680647
Ref: 9d14680647
Ref: library/profile profile run14680751
Ref: 40fd14680751
Ref: library/profile profile runctx14681551
Ref: 40fe14681551
Ref: library/profile profile Profile14681956
Ref: 9b114681956
Ref: library/profile profile Profile enable14683744
Ref: 40ff14683744
Ref: library/profile profile Profile disable14683851
Ref: 410014683851
Ref: library/profile profile Profile create_stats14683958
Ref: 410114683958
Ref: library/profile profile Profile print_stats14684150
Ref: 410214684150
Ref: library/profile profile Profile dump_stats14684686
Ref: 410314684686
Ref: library/profile profile Profile run14684819
Ref: 410414684819
Ref: library/profile profile Profile runctx14684934
Ref: 410514684934
Ref: library/profile profile Profile runcall14685143
Ref: a4b14685143
Node: Stats クラス14685520
Ref: library/profile profile-stats14685714
Ref: 410614685714
Ref: library/profile the-stats-class14685714
Ref: 410714685714
Ref: library/profile module-pstats14685863
Ref: 9e14685863
Ref: library/profile pstats Stats14685863
Ref: 40f714685863
Ref: library/profile pstats Stats strip_dirs14687547
Ref: 40fa14687547
Ref: library/profile pstats Stats add14688449
Ref: 410814688449
Ref: library/profile pstats Stats dump_stats14689028
Ref: 410914689028
Ref: library/profile pstats Stats sort_stats14689528
Ref: 40f914689528
Ref: library/profile pstats Stats reverse_order14695293
Ref: 410a14695293
Ref: library/profile pstats Stats print_stats14695624
Ref: 40fb14695624
Ref: library/profile pstats Stats print_callers14697306
Ref: 410b14697306
Ref: library/profile pstats Stats print_callees14698649
Ref: 410c14698649
Ref: library/profile pstats Stats get_stats_profile14699036
Ref: 410d14699036
Node: 決定論的プロファイリングとは14699587
Ref: library/profile deterministic-profiling14699739
Ref: 410e14699739
Ref: library/profile what-is-deterministic-profiling14699739
Ref: 410f14699739
Node: 制限事項<2>14702229
Ref: library/profile limitations14702400
Ref: 411014702400
Ref: library/profile profile-limitations14702400
Ref: 411114702400
Node: キャリブレーション 補正14704706
Ref: library/profile calibration14704880
Ref: 411214704880
Ref: library/profile profile-calibration14704880
Ref: 411314704880
Node: カスタムな時刻取得用関数を使う14707067
Ref: library/profile profile-timers14707217
Ref: 411414707217
Ref: library/profile using-a-custom-timer14707217
Ref: 411514707217
Node: timeit --- 小さなコードスニペットの実行時間計測14710097
Ref: library/timeit doc14710325
Ref: 411614710325
Ref: library/timeit module-timeit14710325
Ref: d814710325
Ref: library/timeit timeit-measure-execution-time-of-small-code-snippets14710325
Ref: 411714710325
Ref: timeit --- 小さなコードスニペットの実行時間計測-Footnote-114711289
Node: 基本的な例<3>14711355
Ref: library/timeit basic-examples14711515
Ref: 411a14711515
Node: Python インターフェイス14712963
Ref: library/timeit id114713180
Ref: 411c14713180
Ref: library/timeit python-interface14713180
Ref: 411914713180
Ref: library/timeit timeit timeit14713354
Ref: e4914713354
Ref: library/timeit timeit repeat14713868
Ref: 411d14713868
Ref: library/timeit timeit default_timer14714540
Ref: 411f14714540
Ref: library/timeit timeit Timer14714924
Ref: 146d14714924
Ref: library/timeit timeit Timer timeit14716739
Ref: cbb14716739
Ref: library/timeit timeit Timer autorange14718084
Ref: cba14718084
Ref: library/timeit timeit Timer repeat14718894
Ref: 411e14718894
Ref: library/timeit timeit Timer print_exc14720328
Ref: 412014720328
Node: コマンドラインインターフェイス<6>14721046
Ref: library/timeit command-line-interface14721258
Ref: 412114721258
Ref: library/timeit timeit-command-line-interface14721258
Ref: 411814721258
Ref: library/timeit cmdoption-timeit-n14721589
Ref: 412214721589
Ref: library/timeit cmdoption-timeit-number14721589
Ref: 412314721589
Ref: library/timeit cmdoption-timeit-r14721659
Ref: 412414721659
Ref: library/timeit cmdoption-timeit-repeat14721659
Ref: 412514721659
Ref: library/timeit cmdoption-timeit-s14721748
Ref: 412614721748
Ref: library/timeit cmdoption-timeit-setup14721748
Ref: 412714721748
Ref: library/timeit cmdoption-timeit-p14721850
Ref: 412814721850
Ref: library/timeit cmdoption-timeit-process14721850
Ref: 412914721850
Ref: library/timeit cmdoption-timeit-u14722094
Ref: 412a14722094
Ref: library/timeit cmdoption-timeit-unit14722094
Ref: 412b14722094
Ref: library/timeit cmdoption-timeit-v14722285
Ref: 412c14722285
Ref: library/timeit cmdoption-timeit-verbose14722285
Ref: 412d14722285
Ref: library/timeit cmdoption-timeit-h14722397
Ref: 412e14722397
Ref: library/timeit cmdoption-timeit-help14722397
Ref: 412f14722397
Node: 使用例<43>14724060
Ref: library/timeit examples14724232
Ref: 413014724232
Ref: library/timeit timeit-examples14724232
Ref: 411b14724232
Node: trace --- Python 文実行のトレースと追跡14728099
Ref: library/trace doc14728348
Ref: 413114728348
Ref: library/trace module-trace14728348
Ref: e614728348
Ref: library/trace trace-trace-or-track-python-statement-execution14728348
Ref: 413214728348
Ref: trace --- Python 文実行のトレースと追跡-Footnote-114729342
Ref: trace --- Python 文実行のトレースと追跡-Footnote-214729407
Node: コマンドラインからの使用<3>14729448
Ref: library/trace command-line-usage14729628
Ref: 413314729628
Ref: library/trace trace-cli14729628
Ref: 413414729628
Ref: library/trace cmdoption-trace-help14730067
Ref: 413514730067
Ref: library/trace cmdoption-trace-version14730136
Ref: 413614730136
Node: 主要なオプション14730469
Ref: library/trace main-options14730602
Ref: 413714730602
Ref: library/trace cmdoption-trace-c14731144
Ref: 413a14731144
Ref: library/trace cmdoption-trace-count14731144
Ref: 413b14731144
Ref: library/trace cmdoption-trace-t14731434
Ref: 413914731434
Ref: library/trace cmdoption-trace-trace14731434
Ref: 413f14731434
Ref: library/trace cmdoption-trace-l14731514
Ref: 413814731514
Ref: library/trace cmdoption-trace-listfuncs14731514
Ref: 414014731514
Ref: library/trace cmdoption-trace-r14731622
Ref: 414114731622
Ref: library/trace cmdoption-trace-report14731622
Ref: 414214731622
Ref: library/trace cmdoption-trace-T14731884
Ref: 414314731884
Ref: library/trace cmdoption-trace-trackcalls14731884
Ref: 414414731884
Node: 修飾的オプション14732017
Ref: library/trace modifiers14732189
Ref: 414514732189
Ref: library/trace cmdoption-trace-f14732250
Ref: 413d14732250
Ref: library/trace cmdoption-trace-file14732250
Ref: 414614732250
Ref: library/trace cmdoption-trace-C14732495
Ref: 413c14732495
Ref: library/trace cmdoption-trace-coverdir14732495
Ref: 414714732495
Ref: library/trace cmdoption-trace-m14732756
Ref: 414814732756
Ref: library/trace cmdoption-trace-missing14732756
Ref: 414914732756
Ref: library/trace cmdoption-trace-s14732903
Ref: 414a14732903
Ref: library/trace cmdoption-trace-summary14732903
Ref: 414b14732903
Ref: library/trace cmdoption-trace-R14733124
Ref: 413e14733124
Ref: library/trace cmdoption-trace-no-report14733124
Ref: 414c14733124
Ref: library/trace cmdoption-trace-g14733364
Ref: 414d14733364
Ref: library/trace cmdoption-trace-timing14733364
Ref: 414e14733364
Node: フィルターオプション14733517
Ref: library/trace filters14733656
Ref: 414f14733656
Ref: library/trace cmdoption-trace-ignore-module14733789
Ref: 415014733789
Ref: library/trace cmdoption-trace-ignore-dir14734023
Ref: 415114734023
Node: プログラミングインターフェース14734291
Ref: library/trace programmatic-interface14734471
Ref: 415214734471
Ref: library/trace trace-api14734471
Ref: 415314734471
Ref: library/trace trace Trace14734567
Ref: 415414734567
Ref: library/trace trace Trace run14735632
Ref: 415514735632
Ref: library/trace trace Trace runctx14735928
Ref: 415614735928
Ref: library/trace trace Trace runfunc14736314
Ref: a4d14736314
Ref: library/trace trace Trace results14736563
Ref: 415714736563
Ref: library/trace trace CoverageResults14736932
Ref: 415814736932
Ref: library/trace trace CoverageResults update14737151
Ref: 415914737151
Ref: library/trace trace CoverageResults write_results14737300
Ref: 415a14737300
Node: tracemalloc --- メモリ割り当ての追跡14738935
Ref: library/tracemalloc doc14739110
Ref: 415b14739110
Ref: library/tracemalloc module-tracemalloc14739110
Ref: e814739110
Ref: library/tracemalloc tracemalloc-trace-memory-allocations14739110
Ref: 415c14739110
Ref: tracemalloc --- メモリ割り当ての追跡-Footnote-114740867
Node: 使用例<44>14740938
Ref: library/tracemalloc examples14741046
Ref: 415d14741046
Node: 上位10を表示する14741235
Ref: library/tracemalloc display-the-top-1014741335
Ref: 415e14741335
Node: 差を計算する14743001
Ref: library/tracemalloc compute-differences14743170
Ref: 416014743170
Node: メモリブロックのトレースバックを取得する14745700
Ref: library/tracemalloc get-the-traceback-of-a-memory-block14745868
Ref: 416314745868
Node: top を整形化する14748599
Ref: library/tracemalloc pretty-top14748740
Ref: 416414748740
Node: Record the current and peak size of all traced memory blocks14751299
Ref: library/tracemalloc record-the-current-and-peak-size-of-all-traced-memory-blocks14751418
Ref: 416514751418
Node: API14753110
Ref: library/tracemalloc api14753218
Ref: 416714753218
Node: 関数<11>14753384
Ref: library/tracemalloc functions14753455
Ref: 416814753455
Ref: library/tracemalloc tracemalloc clear_traces14753486
Ref: 416914753486
Ref: library/tracemalloc tracemalloc get_object_traceback14753676
Ref: 1ac314753676
Ref: library/tracemalloc tracemalloc get_traceback_limit14754218
Ref: 416b14754218
Ref: library/tracemalloc tracemalloc get_traced_memory14754667
Ref: 416614754667
Ref: library/tracemalloc tracemalloc reset_peak14754931
Ref: 90914754931
Ref: library/tracemalloc tracemalloc get_tracemalloc_memory14755634
Ref: 416d14755634
Ref: library/tracemalloc tracemalloc is_tracing14755913
Ref: 416e14755913
Ref: library/tracemalloc tracemalloc start14756244
Ref: 1ca514756244
Ref: library/tracemalloc tracemalloc stop14757963
Ref: 416a14757963
Ref: library/tracemalloc tracemalloc take_snapshot14758599
Ref: 416c14758599
Node: DomainFilter14759601
Ref: library/tracemalloc domainfilter14759687
Ref: 417214759687
Ref: library/tracemalloc tracemalloc DomainFilter14759732
Ref: cbf14759732
Ref: library/tracemalloc tracemalloc DomainFilter inclusive14759902
Ref: 417314759902
Ref: library/tracemalloc tracemalloc DomainFilter domain14760202
Ref: 417414760202
Node: Filter14760307
Ref: library/tracemalloc filter14760388
Ref: 417514760388
Ref: library/tracemalloc tracemalloc Filter14760423
Ref: 417614760423
Ref: library/tracemalloc tracemalloc Filter domain14761464
Ref: 417714761464
Ref: library/tracemalloc tracemalloc Filter inclusive14761735
Ref: 417814761735
Ref: library/tracemalloc tracemalloc Filter lineno14762167
Ref: 417a14762167
Ref: library/tracemalloc tracemalloc Filter filename_pattern14762356
Ref: 417914762356
Ref: library/tracemalloc tracemalloc Filter all_frames14762528
Ref: 417b14762528
Node: Frame14763034
Ref: library/tracemalloc frame14763111
Ref: 417d14763111
Ref: library/tracemalloc tracemalloc Frame14763144
Ref: 417e14763144
Ref: library/tracemalloc tracemalloc Frame filename14763345
Ref: 417f14763345
Ref: library/tracemalloc tracemalloc Frame lineno14763417
Ref: 418014763417
Node: Snapshot14763481
Ref: library/tracemalloc snapshot14763561
Ref: 418114763561
Ref: library/tracemalloc tracemalloc Snapshot14763600
Ref: 417114763600
Ref: library/tracemalloc tracemalloc Snapshot compare_to14763855
Ref: 417014763855
Ref: library/tracemalloc tracemalloc Snapshot dump14764700
Ref: 416114764700
Ref: library/tracemalloc tracemalloc Snapshot filter_traces14764931
Ref: 418814764931
Ref: library/tracemalloc tracemalloc Snapshot load14765621
Ref: 416214765621
Ref: library/tracemalloc tracemalloc Snapshot statistics14765813
Ref: 415f14765813
Ref: library/tracemalloc tracemalloc Snapshot traceback_limit14767177
Ref: 417c14767177
Ref: library/tracemalloc tracemalloc Snapshot traces14767451
Ref: 418914767451
Node: Statistic14767830
Ref: library/tracemalloc statistic14767918
Ref: 418e14767918
Ref: library/tracemalloc tracemalloc Statistic14767959
Ref: 418a14767959
Ref: library/tracemalloc tracemalloc Statistic count14768236
Ref: 418614768236
Ref: library/tracemalloc tracemalloc Statistic size14768314
Ref: 418b14768314
Ref: library/tracemalloc tracemalloc Statistic traceback14768421
Ref: 418c14768421
Node: StatisticDiff14768592
Ref: library/tracemalloc statisticdiff14768677
Ref: 418f14768677
Ref: library/tracemalloc tracemalloc StatisticDiff14768726
Ref: 418214768726
Ref: library/tracemalloc tracemalloc StatisticDiff count14769069
Ref: 419014769069
Ref: library/tracemalloc tracemalloc StatisticDiff count_diff14769323
Ref: 418514769323
Ref: library/tracemalloc tracemalloc StatisticDiff size14769584
Ref: 418414769584
Ref: library/tracemalloc tracemalloc StatisticDiff size_diff14769867
Ref: 418314769867
Ref: library/tracemalloc tracemalloc StatisticDiff traceback14770137
Ref: 418714770137
Node: Trace14770315
Ref: library/tracemalloc trace14770400
Ref: 419114770400
Ref: library/tracemalloc tracemalloc Trace14770433
Ref: 418d14770433
Ref: library/tracemalloc tracemalloc Trace domain14770732
Ref: 419214770732
Ref: library/tracemalloc tracemalloc Trace size14771010
Ref: 419314771010
Ref: library/tracemalloc tracemalloc Trace traceback14771114
Ref: 419414771114
Node: Traceback14771285
Ref: library/tracemalloc traceback14771348
Ref: 419514771348
Ref: library/tracemalloc tracemalloc Traceback14771389
Ref: b6414771389
Ref: library/tracemalloc tracemalloc Traceback total_nframe14772327
Ref: 416f14772327
Ref: library/tracemalloc tracemalloc Traceback format14772653
Ref: b6514772653
Node: ソフトウェア・パッケージと配布14773753
Ref: library/distribution doc14773948
Ref: 419714773948
Ref: library/distribution software-packaging-and-distribution14773948
Ref: 419814773948
Ref: ソフトウェア・パッケージと配布-Footnote-114774787
Node: ensurepip --- pip インストーラーのブートストラップ14774812
Ref: library/ensurepip doc14774999
Ref: 419914774999
Ref: library/ensurepip ensurepip-bootstrapping-the-pip-installer14774999
Ref: 419a14774999
Ref: library/ensurepip module-ensurepip14774999
Ref: 4b14774999
Ref: ensurepip --- pip インストーラーのブートストラップ-Footnote-114777174
Ref: ensurepip --- pip インストーラーのブートストラップ-Footnote-214777240
Node: コマンドラインインターフェイス<7>14777282
Ref: library/ensurepip command-line-interface14777461
Ref: 419b14777461
Node: モジュール API14779841
Ref: library/ensurepip module-api14780020
Ref: 419c14780020
Ref: library/ensurepip ensurepip version14780177
Ref: 419d14780177
Ref: library/ensurepip ensurepip bootstrap14780388
Ref: 406314780388
Node: venv --- 仮想環境の作成14782794
Ref: library/venv doc14783058
Ref: 419e14783058
Ref: library/venv module-venv14783058
Ref: f914783058
Ref: library/venv venv-creation-of-virtual-environments14783058
Ref: 419f14783058
Ref: library/venv venv-def14783261
Ref: 41a014783261
Ref: library/venv venv-intro14783261
Ref: 41a114783261
Ref: venv --- 仮想環境の作成-Footnote-114785408
Ref: venv --- 仮想環境の作成-Footnote-214785470
Ref: venv --- 仮想環境の作成-Footnote-314785508
Ref: venv --- 仮想環境の作成-Footnote-414785550
Node: 仮想環境の作成<2>14785678
Ref: library/venv creating-virtual-environments14785802
Ref: 41a214785802
Ref: 仮想環境の作成<2>-Footnote-114791320
Node: 仮想環境のしくみ14791375
Ref: library/venv how-venvs-work14791514
Ref: 41a314791514
Ref: library/venv venv-explanation14791514
Ref: 41914791514
Node: API<2>14796626
Ref: library/venv api14796770
Ref: 41a414796770
Ref: library/venv venv-api14796770
Ref: ebd14796770
Ref: library/venv venv EnvBuilder14797067
Ref: 24b14797067
Ref: library/venv venv EnvBuilder create14799432
Ref: 41a614799432
Ref: library/venv venv EnvBuilder ensure_directories14800825
Ref: 41a714800825
Ref: library/venv venv EnvBuilder create_configuration14804117
Ref: 41a814804117
Ref: library/venv venv EnvBuilder setup_python14804256
Ref: 41a914804256
Ref: library/venv venv EnvBuilder setup_scripts14804770
Ref: 41aa14804770
Ref: library/venv venv EnvBuilder upgrade_dependencies14804952
Ref: 41ad14804952
Ref: library/venv venv EnvBuilder post_setup14805335
Ref: 41ab14805335
Ref: library/venv venv EnvBuilder install_scripts14805681
Ref: 41ac14805681
Ref: library/venv venv EnvBuilder create_git_ignore_file14807157
Ref: 41a514807157
Ref: library/venv venv create14808258
Ref: 24c14808258
Ref: API<2>-Footnote-114808998
Ref: API<2>-Footnote-214809036
Node: EnvBuilder を拡張する例14809081
Ref: library/venv an-example-of-extending-envbuilder14809192
Ref: 41ae14809192
Ref: EnvBuilder を拡張する例-Footnote-114819403
Node: zipapp --- 実行可能な Python zip アーカイブを管理する14819450
Ref: library/zipapp doc14819639
Ref: 41af14819639
Ref: library/zipapp module-zipapp14819639
Ref: 11614819639
Ref: library/zipapp zipapp-manage-executable-python-zip-archives14819639
Ref: 41b014819639
Ref: zipapp --- 実行可能な Python zip アーカイブを管理する-Footnote-114820640
Node: 基本的な例<4>14820706
Ref: library/zipapp basic-example14820886
Ref: 41b314820886
Node: コマンドラインインターフェイス<8>14821398
Ref: library/zipapp command-line-interface14821597
Ref: 41b414821597
Ref: library/zipapp zipapp-command-line-interface14821597
Ref: 41b114821597
Ref: library/zipapp cmdoption-zipapp-o14822289
Ref: 41b514822289
Ref: library/zipapp cmdoption-zipapp-output14822289
Ref: 41b614822289
Ref: library/zipapp cmdoption-zipapp-p14823042
Ref: 41b714823042
Ref: library/zipapp cmdoption-zipapp-python14823042
Ref: 41b814823042
Ref: library/zipapp cmdoption-zipapp-m14823373
Ref: 41b914823373
Ref: library/zipapp cmdoption-zipapp-main14823373
Ref: 41ba14823373
Ref: library/zipapp cmdoption-zipapp-c14823964
Ref: 41bb14823964
Ref: library/zipapp cmdoption-zipapp-compress14823964
Ref: 41bc14823964
Ref: library/zipapp cmdoption-zipapp-info14824264
Ref: 41bd14824264
Ref: library/zipapp cmdoption-zipapp-h14824536
Ref: 41be14824536
Ref: library/zipapp cmdoption-zipapp-help14824536
Ref: 41bf14824536
Node: Python API14824618
Ref: library/zipapp python-api14824812
Ref: 41c014824812
Ref: library/zipapp zipapp-python-api14824812
Ref: 41b214824812
Ref: library/zipapp zipapp create_archive14824925
Ref: b7e14824925
Ref: library/zipapp zipapp get_interpreter14829523
Ref: 41c114829523
Node: 使用例<45>14829973
Ref: library/zipapp examples14830149
Ref: 41c214830149
Ref: library/zipapp zipapp-examples14830149
Ref: 41c314830149
Node: インタープリタの指定14831809
Ref: library/zipapp specifying-the-interpreter14832019
Ref: 41c414832019
Ref: library/zipapp zipapp-specifying-the-interpreter14832019
Ref: 41c514832019
Node: Creating Standalone Applications with zipapp14833224
Ref: library/zipapp creating-standalone-applications-with-zipapp14833462
Ref: 41c614833462
Node: Caveats14835169
Ref: library/zipapp caveats14835257
Ref: 41c714835257
Node: The Python Zip Application Archive Format14835994
Ref: library/zipapp the-python-zip-application-archive-format14836193
Ref: 41c814836193
Node: Python ランタイムサービス14838084
Ref: library/python doc14838284
Ref: 41c914838284
Ref: library/python python14838284
Ref: 41ca14838284
Ref: library/python python-runtime-services14838284
Ref: 41cb14838284
Node: sys --- システム固有のパラメーターと関数14839956
Ref: library/sys doc14840137
Ref: 41cc14840137
Ref: library/sys module-sys14840137
Ref: c314840137
Ref: library/sys sys-system-specific-parameters-and-functions14840137
Ref: 41cd14840137
Ref: library/sys sys abiflags14840550
Ref: a3214840550
Ref: library/sys sys addaudithook14840991
Ref: 405a14840991
Ref: library/sys sys argv14843243
Ref: 123614843243
Ref: library/sys auditing14844436
Ref: 182514844436
Ref: library/sys sys audit14844436
Ref: 151a14844436
Ref: library/sys sys base_exec_prefix14845837
Ref: 3c814845837
Ref: library/sys sys base_prefix14846505
Ref: 3c914846505
Ref: library/sys sys byteorder14847164
Ref: 210014847164
Ref: library/sys sys builtin_module_names14847473
Ref: 1bc914847473
Ref: library/sys sys call_tracing14847906
Ref: 179d14847906
Ref: library/sys sys copyright14848430
Ref: 41ce14848430
Ref: library/sys sys _clear_type_cache14848537
Ref: 15d514848537
Ref: library/sys sys _clear_internal_caches14849103
Ref: 15d414849103
Ref: library/sys sys _current_frames14849343
Ref: 13da14849343
Ref: library/sys sys _current_exceptions14850523
Ref: 48e14850523
Ref: library/sys sys breakpointhook14851264
Ref: aa814851264
Ref: library/sys sys _debugmallocstats14853915
Ref: 41cf14853915
Ref: library/sys sys dllhandle14854462
Ref: 41d014854462
Ref: library/sys sys displayhook14854590
Ref: 14c914854590
Ref: library/sys sys dont_write_bytecode14856282
Ref: 41d114856282
Ref: library/sys sys _emscripten_info14856796
Ref: 176c14856796
Ref: library/sys sys _emscripten_info emscripten_version14857016
Ref: 41d214857016
Ref: library/sys sys _emscripten_info runtime14857176
Ref: 41d314857176
Ref: library/sys sys _emscripten_info pthreads14857331
Ref: 41d414857331
Ref: library/sys sys _emscripten_info shared_memory14857456
Ref: 41d514857456
Ref: library/sys sys pycache_prefix14857654
Ref: 97214857654
Ref: library/sys sys excepthook14858632
Ref: 7d614858632
Ref: library/sys sys __breakpointhook__14859994
Ref: 41d614859994
Ref: library/sys sys __displayhook__14860032
Ref: 41d714860032
Ref: library/sys sys __excepthook__14860067
Ref: 41d814860067
Ref: library/sys sys __unraisablehook__14860101
Ref: 41d914860101
Ref: library/sys sys exception14860687
Ref: 65714860687
Ref: library/sys sys exc_info14861158
Ref: 65614861158
Ref: library/sys sys exec_prefix14862172
Ref: 38c14862172
Ref: library/sys sys executable14863157
Ref: 39214863157
Ref: library/sys sys exit14863545
Ref: 131814863545
Ref: library/sys sys flags14865571
Ref: 65814865571
Ref: library/sys sys flags debug14865787
Ref: 41da14865787
Ref: library/sys sys flags inspect14865990
Ref: 41db14865990
Ref: library/sys sys flags interactive14866195
Ref: 41dc14866195
Ref: library/sys sys flags isolated14866393
Ref: 41dd14866393
Ref: library/sys sys flags optimize14866593
Ref: 41de14866593
Ref: library/sys sys flags dont_write_bytecode14866830
Ref: 41df14866830
Ref: library/sys sys flags no_user_site14867024
Ref: 41e014867024
Ref: library/sys sys flags no_site14867220
Ref: 41e114867220
Ref: library/sys sys flags ignore_environment14867432
Ref: 41e214867432
Ref: library/sys sys flags verbose14867621
Ref: 41e314867621
Ref: library/sys sys flags bytes_warning14867828
Ref: 41e414867828
Ref: library/sys sys flags quiet14868020
Ref: 41e514868020
Ref: library/sys sys flags hash_randomization14868234
Ref: 41e614868234
Ref: library/sys sys flags dev_mode14868425
Ref: 1a0c14868425
Ref: library/sys sys flags utf8_mode14868728
Ref: 41e714868728
Ref: library/sys sys flags safe_path14868933
Ref: 21714868933
Ref: library/sys sys flags int_max_str_digits14869142
Ref: 21d814869142
Ref: library/sys sys flags warn_default_encoding14869482
Ref: 41e814869482
Ref: library/sys sys float_info14870628
Ref: 195614870628
Ref: library/sys sys float_info epsilon14871616
Ref: 41ea14871616
Ref: library/sys sys float_info dig14872419
Ref: 41eb14872419
Ref: library/sys sys float_info mant_dig14872933
Ref: 41ec14872933
Ref: library/sys sys float_info max14873428
Ref: 41ed14873428
Ref: library/sys sys float_info max_exp14873814
Ref: 41ee14873814
Ref: library/sys sys float_info max_10_exp14874317
Ref: 41ef14874317
Ref: library/sys sys float_info min14874818
Ref: 41f014874818
Ref: library/sys sys float_info min_exp14875630
Ref: 41f114875630
Ref: library/sys sys float_info min_10_exp14876123
Ref: 41f214876123
Ref: library/sys sys float_info radix14876520
Ref: 41f314876520
Ref: library/sys sys float_info rounds14876892
Ref: 41f414876892
Ref: library/sys sys float_repr_style14879824
Ref: 12c814879824
Ref: library/sys sys getallocatedblocks14880472
Ref: f9214880472
Ref: library/sys sys getunicodeinternedsize14881115
Ref: 41f514881115
Ref: library/sys sys getandroidapilevel14881258
Ref: b5814881258
Ref: library/sys sys getdefaultencoding14881604
Ref: 41f614881604
Ref: library/sys sys getdlopenflags14881760
Ref: 14b914881760
Ref: library/sys sys getfilesystemencoding14882074
Ref: c2714882074
Ref: library/sys sys getfilesystemencodeerrors14883759
Ref: cb414883759
Ref: library/sys sys get_int_max_str_digits14884565
Ref: 21da14884565
Ref: library/sys sys getrefcount14884794
Ref: 41f714884794
Ref: library/sys sys getrecursionlimit14885653
Ref: 49014885653
Ref: library/sys sys getsizeof14886120
Ref: 16d514886120
Ref: library/sys sys getswitchinterval14887234
Ref: 91714887234
Ref: library/sys sys _getframe14887450
Ref: 6ac14887450
Ref: library/sys sys _getframemodulename14888312
Ref: 16da14888312
Ref: library/sys sys getobjects14889060
Ref: 3fe14889060
Ref: library/sys sys getprofile14890200
Ref: 138814890200
Ref: library/sys sys gettrace14890339
Ref: 138914890339
Ref: library/sys sys getwindowsversion14890858
Ref: cb514890858
Ref: library/sys sys get_asyncgen_hooks14893785
Ref: 179e14893785
Ref: library/sys sys get_coroutine_origin_tracking_depth14894538
Ref: b5914894538
Ref: library/sys sys hash_info14894893
Ref: fca14894893
Ref: library/sys sys hash_info width14895155
Ref: 41fb14895155
Ref: library/sys sys hash_info modulus14895242
Ref: 210614895242
Ref: library/sys sys hash_info inf14895341
Ref: 41fc14895341
Ref: library/sys sys hash_info nan14895435
Ref: 41fd14895435
Ref: library/sys sys hash_info imag14895516
Ref: 41fe14895516
Ref: library/sys sys hash_info algorithm14895626
Ref: 41ff14895626
Ref: library/sys sys hash_info hash_bits14895756
Ref: 420014895756
Ref: library/sys sys hash_info seed_bits14895855
Ref: 420114895855
Ref: library/sys sys hexversion14896069
Ref: 420214896069
Ref: library/sys sys implementation14897078
Ref: 4e014897078
Ref: library/sys sys int_info14899685
Ref: 126414899685
Ref: library/sys sys int_info bits_per_digit14899877
Ref: 420414899877
Ref: library/sys sys int_info sizeof_digit14900063
Ref: 420514900063
Ref: library/sys sys int_info default_max_str_digits14900176
Ref: 21d914900176
Ref: library/sys sys int_info str_digits_check_threshold14900362
Ref: 420614900362
Ref: library/sys sys __interactivehook__14900762
Ref: f9414900762
Ref: library/sys sys intern14901406
Ref: 12a914901406
Ref: library/sys sys _is_gil_enabled14902400
Ref: 420714902400
Ref: library/sys sys is_finalizing14902578
Ref: a5d14902578
Ref: library/sys sys last_exc14902841
Ref: 48a14902841
Ref: library/sys sys _is_interned14903419
Ref: 23114903419
Ref: library/sys sys last_type14903691
Ref: 48b14903691
Ref: library/sys sys last_value14903720
Ref: 48c14903720
Ref: library/sys sys last_traceback14903750
Ref: 48d14903750
Ref: library/sys sys maxsize14903984
Ref: 119514903984
Ref: library/sys sys maxunicode14904261
Ref: 102014904261
Ref: library/sys sys meta_path14904707
Ref: cf914904707
Ref: library/sys sys modules14906023
Ref: 18d614906023
Ref: library/sys sys orig_argv14906636
Ref: 80b14906636
Ref: library/sys sys path14907115
Ref: 38e14907115
Ref: library/sys sys path_hooks14908548
Ref: fee14908548
Ref: library/sys sys path_importer_cache14909006
Ref: 5ae14909006
Ref: library/sys sys platform14909526
Ref: a5b14909526
Ref: library/sys sys platlibdir14911930
Ref: 90614911930
Ref: library/sys sys prefix14912939
Ref: 39014912939
Ref: library/sys sys ps114913599
Ref: 1caf14913599
Ref: library/sys sys ps214913622
Ref: 1cb014913622
Ref: library/sys sys setdlopenflags14914150
Ref: 10f214914150
Ref: library/sys sys set_int_max_str_digits14914752
Ref: 172914914752
Ref: library/sys sys setprofile14914990
Ref: 14a814914990
Ref: library/sys sys setrecursionlimit14917695
Ref: 48f14917695
Ref: library/sys sys setswitchinterval14918670
Ref: 91814918670
Ref: library/sys sys settrace14919426
Ref: 14a914919426
Ref: library/sys sys set_asyncgen_hooks14924627
Ref: 158a14924627
Ref: library/sys sys set_coroutine_origin_tracking_depth14925767
Ref: b5a14925767
Ref: library/sys sys activate_stack_trampoline14926593
Ref: 43c14926593
Ref: library/sys sys deactivate_stack_trampoline14926962
Ref: 43d14926962
Ref: library/sys sys is_stack_trampoline_active14927216
Ref: 43e14927216
Ref: library/sys sys _enablelegacywindowsfsencoding14927401
Ref: 28e14927401
Ref: library/sys sys stdin14928393
Ref: 50714928393
Ref: library/sys sys stdout14928418
Ref: aa414928418
Ref: library/sys sys stderr14928444
Ref: 90714928444
Ref: library/sys sys __stdin__14931891
Ref: 420914931891
Ref: library/sys sys __stdout__14931920
Ref: 27d214931920
Ref: library/sys sys __stderr__14931950
Ref: 3fdf14931950
Ref: library/sys sys stdlib_module_names14933157
Ref: 80c14933157
Ref: library/sys sys thread_info14933897
Ref: 112314933897
Ref: library/sys sys thread_info name14934033
Ref: 420a14934033
Ref: library/sys sys thread_info lock14934387
Ref: 420b14934387
Ref: library/sys sys thread_info version14934686
Ref: 420c14934686
Ref: library/sys sys tracebacklimit14934883
Ref: 153d14934883
Ref: library/sys sys unraisablehook14935256
Ref: 1d814935256
Ref: library/sys sys version14937074
Ref: 15e14937074
Ref: library/sys sys api_version14937524
Ref: 420d14937524
Ref: library/sys sys version_info14937731
Ref: 66c14937731
Ref: library/sys sys warnoptions14938422
Ref: 38a14938422
Ref: library/sys sys winver14938638
Ref: 420e14938638
Ref: library/sys sys _xoptions14939289
Ref: 1ca914939289
Ref: library/sys c9914940204
Ref: 41e914940204
Ref: sys --- システム固有のパラメーターと関数-Footnote-114940430
Ref: sys --- システム固有のパラメーターと関数-Footnote-214940472
Ref: sys --- システム固有のパラメーターと関数-Footnote-314940514
Ref: sys --- システム固有のパラメーターと関数-Footnote-414940556
Ref: sys --- システム固有のパラメーターと関数-Footnote-514940661
Ref: sys --- システム固有のパラメーターと関数-Footnote-614940703
Ref: sys --- システム固有のパラメーターと関数-Footnote-714940745
Ref: sys --- システム固有のパラメーターと関数-Footnote-814940787
Ref: sys --- システム固有のパラメーターと関数-Footnote-914940829
Ref: sys --- システム固有のパラメーターと関数-Footnote-1014940871
Ref: sys --- システム固有のパラメーターと関数-Footnote-1114940914
Ref: sys --- システム固有のパラメーターと関数-Footnote-1214940957
Ref: sys --- システム固有のパラメーターと関数-Footnote-1314941000
Ref: sys --- システム固有のパラメーターと関数-Footnote-1414941043
Ref: sys --- システム固有のパラメーターと関数-Footnote-1514941086
Ref: sys --- システム固有のパラメーターと関数-Footnote-1614941167
Ref: sys --- システム固有のパラメーターと関数-Footnote-1714941210
Ref: sys --- システム固有のパラメーターと関数-Footnote-1814941253
Node: sys monitoring --- Execution event monitoring14941296
Ref: library/sys monitoring doc14941555
Ref: 420f14941555
Ref: library/sys monitoring module-sys monitoring14941555
Ref: c414941555
Ref: library/sys monitoring sys-monitoring-execution-event-monitoring14941555
Ref: 421014941555
Node: Tool identifiers14942567
Ref: library/sys monitoring tool-identifiers14942680
Ref: 421114942680
Node: Registering and using tools14943237
Ref: library/sys monitoring registering-and-using-tools14943317
Ref: 421414943317
Ref: library/sys monitoring sys monitoring use_tool_id14943392
Ref: 421514943392
Ref: library/sys monitoring sys monitoring free_tool_id14943650
Ref: 421614943650
Ref: library/sys monitoring sys monitoring get_tool14944067
Ref: 421714944067
Node: Events14944571
Ref: library/sys monitoring events14944718
Ref: 421214944718
Ref: library/sys monitoring monitoring-event-BRANCH14944788
Ref: 421814944788
Ref: library/sys monitoring monitoring-event-CALL14944886
Ref: 15aa14944886
Ref: library/sys monitoring monitoring-event-C_RAISE14944996
Ref: 421914944996
Ref: library/sys monitoring monitoring-event-C_RETURN14945158
Ref: 421a14945158
Ref: library/sys monitoring monitoring-event-EXCEPTION_HANDLED14945310
Ref: 421b14945310
Ref: library/sys monitoring monitoring-event-INSTRUCTION14945404
Ref: 421c14945404
Ref: library/sys monitoring monitoring-event-JUMP14945509
Ref: 421d14945509
Ref: library/sys monitoring monitoring-event-LINE14945622
Ref: 421e14945622
Ref: library/sys monitoring monitoring-event-PY_RESUME14945787
Ref: 421f14945787
Ref: library/sys monitoring monitoring-event-PY_RETURN14945958
Ref: 422014945958
Ref: library/sys monitoring monitoring-event-PY_START14946135
Ref: 422114946135
Ref: library/sys monitoring monitoring-event-PY_THROW14946304
Ref: 422214946304
Ref: library/sys monitoring monitoring-event-PY_UNWIND14946418
Ref: 422314946418
Ref: library/sys monitoring monitoring-event-PY_YIELD14946535
Ref: 422414946535
Ref: library/sys monitoring monitoring-event-RAISE14946709
Ref: 155214946709
Ref: library/sys monitoring monitoring-event-RERAISE14946856
Ref: 422614946856
Ref: library/sys monitoring monitoring-event-STOP_ITERATION14947002
Ref: 422514947002
Ref: library/sys monitoring monitoring-event-NO_EVENTS14947554
Ref: 422814947554
Node: Local events14947882
Ref: library/sys monitoring local-events14947962
Ref: 422914947962
Node: Ancillary events14948448
Ref: library/sys monitoring ancillary-events14948549
Ref: 422a14948549
Node: Other events14948992
Ref: library/sys monitoring other-events14949105
Ref: 422b14949105
Node: The STOP_ITERATION event14949428
Ref: library/sys monitoring the-stop-iteration-event14949516
Ref: 422714949516
Ref: The STOP_ITERATION event-Footnote-114950159
Node: Turning events on and off14950240
Ref: library/sys monitoring turning-events-on-and-off14950401
Ref: 422c14950401
Node: Setting events globally14950762
Ref: library/sys monitoring setting-events-globally14950878
Ref: 422d14950878
Ref: library/sys monitoring sys monitoring get_events14951028
Ref: 422e14951028
Ref: library/sys monitoring sys monitoring set_events14951159
Ref: 422f14951159
Node: Per code object events14951410
Ref: library/sys monitoring per-code-object-events14951551
Ref: 423014951551
Ref: library/sys monitoring sys monitoring get_local_events14951880
Ref: 423114951880
Ref: library/sys monitoring sys monitoring set_local_events14952025
Ref: 423214952025
Node: Disabling events14952447
Ref: library/sys monitoring disabling-events14952556
Ref: 423314952556
Ref: library/sys monitoring sys monitoring DISABLE14952611
Ref: 423414952611
Ref: library/sys monitoring sys monitoring restart_events14953229
Ref: 423514953229
Node: Registering callback functions14953392
Ref: library/sys monitoring callbacks14953538
Ref: 421314953538
Ref: library/sys monitoring registering-callback-functions14953538
Ref: 423614953538
Ref: library/sys monitoring sys monitoring register_callback14953661
Ref: 423714953661
Node: Callback function arguments14954371
Ref: library/sys monitoring callback-function-arguments14954465
Ref: 423814954465
Ref: library/sys monitoring sys monitoring MISSING14954542
Ref: 423914954542
Node: sysconfig --- Python の構成情報へのアクセスを提供する14956205
Ref: library/sysconfig doc14956451
Ref: 423a14956451
Ref: library/sysconfig module-sysconfig14956451
Ref: c514956451
Ref: library/sysconfig sysconfig-provide-access-to-python-s-configuration-information14956451
Ref: 423b14956451
Ref: sysconfig --- Python の構成情報へのアクセスを提供する-Footnote-114957237
Node: 構成変数14957303
Ref: library/sysconfig configuration-variables14957454
Ref: 423c14957454
Ref: library/sysconfig sysconfig get_config_vars14958048
Ref: ff614958048
Ref: library/sysconfig sysconfig get_config_var14958467
Ref: ff514958467
Node: インストールパス14958932
Ref: library/sysconfig id114959103
Ref: 423d14959103
Ref: library/sysconfig installation-paths14959103
Ref: 65b14959103
Node: User scheme14961800
Ref: library/sysconfig sysconfig-user-scheme14961970
Ref: 1cb114961970
Ref: library/sysconfig user-scheme14961970
Ref: 423e14961970
Node: posix_user14962495
Ref: library/sysconfig posix-user14962569
Ref: 423f14962569
Node: nt_user14963427
Ref: library/sysconfig nt-user14963528
Ref: 424014963528
Node: osx_framework_user14964374
Ref: library/sysconfig osx-framework-user14964456
Ref: 424114964456
Node: Home scheme14965310
Ref: library/sysconfig home-scheme14965469
Ref: 424214965469
Ref: library/sysconfig sysconfig-home-scheme14965469
Ref: 424314965469
Node: posix_home14966126
Ref: library/sysconfig posix-home14966184
Ref: 424414966184
Node: Prefix scheme14967048
Ref: library/sysconfig prefix-scheme14967223
Ref: 424514967223
Ref: library/sysconfig sysconfig-prefix-scheme14967223
Ref: 424614967223
Node: posix_prefix14968821
Ref: library/sysconfig posix-prefix14968894
Ref: 424714968894
Node: nt14969837
Ref: library/sysconfig nt14969910
Ref: 424814969910
Node: Installation path functions14970765
Ref: library/sysconfig installation-path-functions14970950
Ref: 424914970950
Ref: library/sysconfig sysconfig get_scheme_names14971112
Ref: 424a14971112
Ref: library/sysconfig sysconfig get_default_scheme14971295
Ref: 178e14971295
Ref: library/sysconfig sysconfig get_preferred_scheme14971663
Ref: 65c14971663
Ref: library/sysconfig sysconfig _get_preferred_schemes14972263
Ref: 424b14972263
Ref: library/sysconfig sysconfig get_path_names14972931
Ref: 424c14972931
Ref: library/sysconfig sysconfig get_path14973109
Ref: 12fd14973109
Ref: library/sysconfig sysconfig get_paths14974675
Ref: 121514974675
Node: その他の関数<3>14975471
Ref: library/sysconfig other-functions14975686
Ref: 424d14975686
Ref: library/sysconfig sysconfig get_python_version14975739
Ref: 121414975739
Ref: library/sysconfig sysconfig get_platform14975941
Ref: 121314975941
Ref: library/sysconfig sysconfig is_python_build14977080
Ref: 2da14977080
Ref: library/sysconfig sysconfig parse_config_h14977465
Ref: 424e14977465
Ref: library/sysconfig sysconfig get_config_h_filename14977959
Ref: 424f14977959
Ref: library/sysconfig sysconfig get_makefile_filename14978061
Ref: 425014978061
Node: sysconfig をスクリプトとして使う14978161
Ref: library/sysconfig sysconfig-cli14978340
Ref: 425114978340
Ref: library/sysconfig using-sysconfig-as-a-script14978340
Ref: 425214978340
Node: builtins --- 組み込みオブジェクト14979484
Ref: library/builtins doc14979734
Ref: 425314979734
Ref: library/builtins builtins-built-in-objects14979734
Ref: 425414979734
Ref: library/builtins module-builtins14979734
Ref: e14979734
Node: __main__ --- トップレベルのコード環境14981608
Ref: library/__main__ doc14981817
Ref: 425514981817
Ref: library/__main__ main-top-level-code-environment14981817
Ref: 425614981817
Ref: library/__main__ module-__main__14981817
Ref: 114981817
Node: __name__ == '__main__'14982846
Ref: library/__main__ name-equals-main14982993
Ref: 425714982993
Ref: library/__main__ name-main14982993
Ref: 425814982993
Node: 「トップレベルのスクリプト環境」とは14984021
Ref: library/__main__ what-is-the-top-level-code-environment14984164
Ref: 425914984164
Node: 通常の使われ方14986779
Ref: library/__main__ idiomatic-usage14986973
Ref: 425a14986973
Node: パッケージングで考慮すべき点14989510
Ref: library/__main__ packaging-considerations14989641
Ref: 425b14989641
Ref: パッケージングで考慮すべき点-Footnote-114991168
Ref: パッケージングで考慮すべき点-Footnote-214991197
Node: __main__ py in Python Packages14991235
Ref: library/__main__ main-py-in-python-packages14991406
Ref: 425c14991406
Node: 通常の使われ方<2>14992835
Ref: library/__main__ id114992926
Ref: 425d14992926
Node: import __main__14994257
Ref: library/__main__ import-main14994397
Ref: 425e14994397
Node: warnings --- 警告の制御14997563
Ref: library/warnings doc14997763
Ref: 425f14997763
Ref: library/warnings module-warnings14997763
Ref: fa14997763
Ref: library/warnings warnings-warning-control14997763
Ref: 426014997763
Ref: warnings --- 警告の制御-Footnote-115000781
Node: 警告カテゴリ15000849
Ref: library/warnings id115000959
Ref: 426415000959
Ref: library/warnings warning-categories15000959
Ref: 220e15000959
Node: 警告フィルタ15005434
Ref: library/warnings the-warnings-filter15005586
Ref: 426515005586
Ref: library/warnings warning-filter15005586
Ref: 89715005586
Node: Repeated Warning Suppression Criteria15009170
Ref: library/warnings id215009297
Ref: 426615009297
Ref: library/warnings repeated-warning-suppression-criteria15009297
Ref: 426715009297
Node: Describing Warning Filters15009932
Ref: library/warnings describing-warning-filters15010104
Ref: 1ca315010104
Ref: library/warnings id315010104
Ref: 426815010104
Node: デフォルトの警告フィルタ15011825
Ref: library/warnings default-warning-filter15011989
Ref: 426915011989
Ref: library/warnings id415011989
Ref: 426a15011989
Node: Overriding the default filter15013250
Ref: library/warnings overriding-the-default-filter15013379
Ref: 426b15013379
Ref: library/warnings warning-disable15013379
Ref: 426c15013379
Node: 一時的に警告を抑制する15014814
Ref: library/warnings temporarily-suppressing-warnings15014966
Ref: 426d15014966
Ref: library/warnings warning-suppress15014966
Ref: 426e15014966
Node: 警告のテスト15016141
Ref: library/warnings testing-warnings15016321
Ref: 426f15016321
Ref: library/warnings warning-testing15016321
Ref: 427015016321
Node: Updating Code For New Versions of Dependencies15018737
Ref: library/warnings updating-code-for-new-versions-of-dependencies15018905
Ref: 427115018905
Ref: library/warnings warning-ignored15018905
Ref: 3f3115018905
Node: 利用可能な関数15020290
Ref: library/warnings available-functions15020491
Ref: 427215020491
Ref: library/warnings warning-functions15020491
Ref: 427315020491
Ref: library/warnings warnings warn15020549
Ref: 14c315020549
Ref: library/warnings warnings warn_explicit15023353
Ref: cce15023353
Ref: library/warnings warnings showwarning15024944
Ref: 426315024944
Ref: library/warnings warnings formatwarning15025724
Ref: 198015025724
Ref: library/warnings warnings filterwarnings15026249
Ref: 144e15026249
Ref: library/warnings warnings simplefilter15027081
Ref: 68d15027081
Ref: library/warnings warnings resetwarnings15027598
Ref: 426215027598
Ref: library/warnings warnings deprecated15027959
Ref: 14615027959
Ref: 利用可能な関数-Footnote-115029825
Node: 利用可能なコンテキストマネージャー15029867
Ref: library/warnings available-context-managers15030013
Ref: 427415030013
Ref: library/warnings warnings catch_warnings15030121
Ref: 55015030121
Node: dataclasses --- データクラス15032229
Ref: library/dataclasses doc15032445
Ref: 427515032445
Ref: library/dataclasses dataclasses-data-classes15032445
Ref: 427615032445
Ref: library/dataclasses module-dataclasses15032445
Ref: 2715032445
Ref: dataclasses --- データクラス-Footnote-115034437
Ref: dataclasses --- データクラス-Footnote-215034508
Ref: dataclasses --- データクラス-Footnote-315034550
Node: モジュールの内容<4>15034592
Ref: library/dataclasses module-contents15034720
Ref: 427715034720
Ref: library/dataclasses dataclasses dataclass15034781
Ref: 1ad15034781
Ref: library/dataclasses dataclasses field15044994
Ref: 198b15044994
Ref: library/dataclasses dataclasses Field15049532
Ref: 21b315049532
Ref: library/dataclasses dataclasses fields15050352
Ref: 16aa15050352
Ref: library/dataclasses dataclasses asdict15050885
Ref: 168b15050885
Ref: library/dataclasses dataclasses astuple15051928
Ref: 169515051928
Ref: library/dataclasses dataclasses make_dataclass15052660
Ref: 16ac15052660
Ref: library/dataclasses dataclasses replace15054479
Ref: 165e15054479
Ref: library/dataclasses dataclasses is_dataclass15055978
Ref: 17dd15055978
Ref: library/dataclasses dataclasses MISSING15056549
Ref: 427915056549
Ref: library/dataclasses dataclasses KW_ONLY15056700
Ref: 427815056700
Ref: library/dataclasses dataclasses FrozenInstanceError15057657
Ref: 427b15057657
Ref: モジュールの内容<4>-Footnote-115058035
Ref: モジュールの内容<4>-Footnote-215058090
Node: 初期化後の処理15058145
Ref: library/dataclasses id115058297
Ref: 427c15058297
Ref: library/dataclasses post-init-processing15058297
Ref: 427d15058297
Ref: library/dataclasses dataclasses __post_init__15058353
Ref: 427a15058353
Node: クラス変数15060285
Ref: library/dataclasses class-variables15060431
Ref: 427e15060431
Ref: library/dataclasses dataclasses-class-variables15060431
Ref: 427f15060431
Ref: クラス変数-Footnote-115060984
Node: 初期化限定変数15061026
Ref: library/dataclasses dataclasses-init-only-variables15061184
Ref: 428015061184
Ref: library/dataclasses init-only-variables15061184
Ref: 428115061184
Node: 凍結されたインスタンス15062478
Ref: library/dataclasses dataclasses-frozen15062630
Ref: 428215062630
Ref: library/dataclasses frozen-instances15062630
Ref: 428315062630
Node: 継承<2>15063250
Ref: library/dataclasses dataclasses-inheritance15063431
Ref: 428415063431
Ref: library/dataclasses inheritance15063431
Ref: 428515063431
Node: Re-ordering of keyword-only parameters in __init__15064473
Ref: library/dataclasses re-ordering-of-keyword-only-parameters-in-init15064657
Ref: 428615064657
Node: デフォルトファクトリ関数15066127
Ref: library/dataclasses default-factory-functions15066329
Ref: 428715066329
Node: 可変なデフォルト値15066957
Ref: library/dataclasses mutable-default-values15067132
Ref: 428815067132
Node: Descriptor-typed fields15069375
Ref: library/dataclasses descriptor-typed-fields15069505
Ref: 428915069505
Node: contextlib --- with 文コンテキスト用ユーティリティ15071473
Ref: library/contextlib doc15071690
Ref: 428a15071690
Ref: library/contextlib contextlib-utilities-for-with-statement-contexts15071690
Ref: 428b15071690
Ref: library/contextlib module-contextlib15071690
Ref: 1c15071690
Ref: contextlib --- with 文コンテキスト用ユーティリティ-Footnote-115072462
Node: ユーティリティ15072532
Ref: library/contextlib utilities15072682
Ref: 428c15072682
Ref: library/contextlib contextlib AbstractContextManager15072792
Ref: c5b15072792
Ref: library/contextlib contextlib AbstractAsyncContextManager15073378
Ref: af915073378
Ref: library/contextlib contextlib contextmanager15074032
Ref: 11d315074032
Ref: library/contextlib contextlib asynccontextmanager15078031
Ref: af815078031
Ref: library/contextlib contextlib closing15080860
Ref: 289d15080860
Ref: library/contextlib contextlib aclosing15082256
Ref: 7b815082256
Ref: library/contextlib simplifying-support-for-single-optional-context-managers15083686
Ref: 428d15083686
Ref: library/contextlib contextlib nullcontext15083686
Ref: 7b915083686
Ref: library/contextlib contextlib suppress15085653
Ref: ef215085653
Ref: library/contextlib contextlib redirect_stdout15087340
Ref: db515087340
Ref: library/contextlib contextlib redirect_stderr15089375
Ref: db415089375
Ref: library/contextlib contextlib chdir15089774
Ref: 5d715089774
Ref: library/contextlib contextlib ContextDecorator15090871
Ref: 11d215090871
Ref: library/contextlib contextlib AsyncContextDecorator15093754
Ref: 7ba15093754
Ref: library/contextlib contextlib ExitStack15094902
Ref: af715094902
Ref: library/contextlib contextlib ExitStack enter_context15097135
Ref: 59d15097135
Ref: library/contextlib contextlib ExitStack push15097810
Ref: 428f15097810
Ref: library/contextlib contextlib ExitStack callback15098721
Ref: a5115098721
Ref: library/contextlib contextlib ExitStack pop_all15099210
Ref: 429015099210
Ref: library/contextlib contextlib ExitStack close15100342
Ref: 429115100342
Ref: library/contextlib contextlib AsyncExitStack15100697
Ref: afa15100697
Ref: library/contextlib contextlib AsyncExitStack enter_async_context15101161
Ref: 5a015101161
Ref: library/contextlib contextlib AsyncExitStack push_async_exit15101567
Ref: 429315101567
Ref: library/contextlib contextlib AsyncExitStack push_async_callback15101752
Ref: a5215101752
Ref: library/contextlib contextlib AsyncExitStack aclose15101924
Ref: 429215101924
Node: 例とレシピ<3>15102544
Ref: library/contextlib examples-and-recipes15102802
Ref: 429415102802
Node: 可変数個のコンテキストマネージャーをサポートする15103338
Ref: library/contextlib supporting-a-variable-number-of-context-managers15103532
Ref: 429515103532
Node: __enter__ メソッドからの例外をキャッチする15104856
Ref: library/contextlib catching-exceptions-from-enter-methods15105102
Ref: 429615105102
Node: __enter__ 実装内のクリーンアップ15106493
Ref: library/contextlib cleaning-up-in-an-enter-implementation15106722
Ref: 429715106722
Node: try-finally + flag 変数パターンを置き換える15108686
Ref: library/contextlib replacing-any-use-of-try-finally-and-flag-variables15108935
Ref: 429815108935
Node: コンテキストマネージャーを関数デコレーターとして使う15111718
Ref: library/contextlib using-a-context-manager-as-a-function-decorator15111915
Ref: 429915111915
Ref: コンテキストマネージャーを関数デコレーターとして使う-Footnote-115113947
Node: 単回使用、再利用可能、およびリエントラントなコンテキストマネージャ15113989
Ref: library/contextlib single-use-reusable-and-reentrant-cms15114217
Ref: ef415114217
Ref: library/contextlib single-use-reusable-and-reentrant-context-managers15114217
Ref: 429a15114217
Node: リエントラントなコンテキストマネージャ15116182
Ref: library/contextlib reentrant-cms15116435
Ref: 428e15116435
Ref: library/contextlib reentrant-context-managers15116435
Ref: 429b15116435
Node: 再利用可能なコンテキストマネージャ15118404
Ref: library/contextlib reusable-cms15118657
Ref: 429c15118657
Ref: library/contextlib reusable-context-managers15118657
Ref: 429d15118657
Node: abc --- 抽象基底クラス15121960
Ref: library/abc doc15122175
Ref: 429e15122175
Ref: library/abc abc-abstract-base-classes15122175
Ref: 429f15122175
Ref: library/abc module-abc15122175
Ref: 415122175
Ref: library/abc abc ABC15123356
Ref: ee315123356
Ref: library/abc abc ABCMeta15124178
Ref: ee415124178
Ref: library/abc abc ABCMeta register15125151
Ref: 105e15125151
Ref: library/abc abc ABCMeta __subclasshook__15125955
Ref: 247e15125955
Ref: library/abc abc abstractmethod15128910
Ref: 105b15128910
Ref: library/abc abc abstractclassmethod15132123
Ref: 105c15132123
Ref: library/abc abc abstractstaticmethod15132981
Ref: 105d15132981
Ref: library/abc abc abstractproperty15133837
Ref: 105a15133837
Ref: library/abc abc get_cache_token15135533
Ref: ee215135533
Ref: library/abc abc update_abstractmethods15136030
Ref: 42a015136030
Ref: abc --- 抽象基底クラス-Footnote-115136694
Ref: abc --- 抽象基底クラス-Footnote-215136757
Ref: abc --- 抽象基底クラス-Footnote-315136799
Ref: abc --- 抽象基底クラス-Footnote-415136841
Node: atexit --- 終了ハンドラー15136997
Ref: library/atexit doc15137209
Ref: 42a115137209
Ref: library/atexit atexit-exit-handlers15137209
Ref: 42a215137209
Ref: library/atexit module-atexit15137209
Ref: 915137209
Ref: library/atexit atexit register15138464
Ref: 84a15138464
Ref: library/atexit atexit unregister15140520
Ref: 42a315140520
Node: atexit の例15141334
Ref: library/atexit atexit-example15141416
Ref: 42a415141416
Ref: library/atexit id115141416
Ref: 42a515141416
Node: traceback --- スタックトレースの表示または取得15142871
Ref: library/traceback doc15143088
Ref: 42a615143088
Ref: library/traceback module-traceback15143088
Ref: e715143088
Ref: library/traceback traceback-print-or-retrieve-a-stack-traceback15143088
Ref: 42a715143088
Ref: traceback --- スタックトレースの表示または取得-Footnote-115145166
Node: モジュールレベルの関数<2>15145235
Ref: library/traceback module-level-functions15145416
Ref: 42a815145416
Ref: library/traceback traceback print_tb15145494
Ref: e5015145494
Ref: library/traceback traceback print_exception15146466
Ref: 81a15146466
Ref: library/traceback traceback print_exc15148061
Ref: 17ea15148061
Ref: library/traceback traceback print_last15148229
Ref: 42a915148229
Ref: library/traceback traceback print_stack15148514
Ref: e5115148514
Ref: library/traceback traceback extract_tb15149101
Ref: 42aa15149101
Ref: library/traceback traceback extract_stack15149743
Ref: 42af15149743
Ref: library/traceback traceback format_list15150057
Ref: 42b015150057
Ref: library/traceback traceback format_exception_only15150750
Ref: 81915150750
Ref: library/traceback traceback format_exception15152151
Ref: 81815152151
Ref: library/traceback traceback format_exc15152977
Ref: 42b115152977
Ref: library/traceback traceback format_tb15153177
Ref: 419615153177
Ref: library/traceback traceback format_stack15153302
Ref: 42b215153302
Ref: library/traceback traceback clear_frames15153436
Ref: fa115153436
Ref: library/traceback traceback walk_stack15153682
Ref: e4c15153682
Ref: library/traceback traceback walk_tb15154001
Ref: e4d15154001
Node: TracebackException オブジェクト15154244
Ref: library/traceback tracebackexception-objects15154465
Ref: 42b415154465
Ref: library/traceback traceback TracebackException15154962
Ref: 23d15154962
Ref: library/traceback traceback TracebackException __cause__15156358
Ref: 42b615156358
Ref: library/traceback traceback TracebackException __context__15156466
Ref: 42b515156466
Ref: library/traceback traceback TracebackException exceptions15156588
Ref: 42b815156588
Ref: library/traceback traceback TracebackException __suppress_context__15156867
Ref: 42b715156867
Ref: library/traceback traceback TracebackException __notes__15157003
Ref: 42b915157003
Ref: library/traceback traceback TracebackException stack15157313
Ref: 42ba15157313
Ref: library/traceback traceback TracebackException exc_type15157410
Ref: 23e15157410
Ref: library/traceback traceback TracebackException exc_type_str15157543
Ref: 23c15157543
Ref: library/traceback traceback TracebackException filename15157677
Ref: 42bb15157677
Ref: library/traceback traceback TracebackException lineno15157788
Ref: 42bc15157788
Ref: library/traceback traceback TracebackException end_lineno15157885
Ref: 42bd15157885
Ref: library/traceback traceback TracebackException text15158073
Ref: 42be15158073
Ref: library/traceback traceback TracebackException offset15158171
Ref: 42bf15158171
Ref: library/traceback traceback TracebackException end_offset15158292
Ref: 42c015158292
Ref: library/traceback traceback TracebackException msg15158489
Ref: 42c115158489
Ref: library/traceback traceback TracebackException from_exception15158592
Ref: 42c215158592
Ref: library/traceback traceback TracebackException print15159081
Ref: 67015159081
Ref: library/traceback traceback TracebackException format15159295
Ref: 42c315159295
Ref: library/traceback traceback TracebackException format_exception_only15159791
Ref: 23f15159791
Node: StackSummary オブジェクト15160867
Ref: library/traceback stacksummary-objects15161083
Ref: 42c415161083
Ref: library/traceback traceback StackSummary15161266
Ref: e4e15161266
Ref: library/traceback traceback StackSummary extract15161305
Ref: 42b315161305
Ref: library/traceback traceback StackSummary from_list15162310
Ref: 42c515162310
Ref: library/traceback traceback StackSummary format15162620
Ref: 42c615162620
Ref: library/traceback traceback StackSummary format_frame_summary15163265
Ref: 66f15163265
Node: FrameSummary オブジェクト15163675
Ref: library/traceback framesummary-objects15163898
Ref: 42c715163898
Ref: library/traceback traceback FrameSummary15164102
Ref: e4f15164102
Ref: library/traceback traceback FrameSummary filename15164964
Ref: 42ab15164964
Ref: library/traceback traceback FrameSummary lineno15165167
Ref: 42ac15165167
Ref: library/traceback traceback FrameSummary name15165257
Ref: 42ad15165257
Ref: library/traceback traceback FrameSummary line15165393
Ref: 42ae15165393
Node: Examples of Using the Module-Level Functions15165602
Ref: library/traceback examples-of-using-the-module-level-functions15165830
Ref: 42c815165830
Ref: library/traceback traceback-example15165830
Ref: 42c915165830
Node: Examples of Using TracebackException15171391
Ref: library/traceback examples-of-using-tracebackexception15171579
Ref: 42ca15171579
Node: __future__ --- future 文の定義15174235
Ref: library/__future__ doc15174478
Ref: 42cb15174478
Ref: library/__future__ future-future-statement-definitions15174478
Ref: 42cc15174478
Ref: library/__future__ module-__future__15174478
Ref: 015174478
Ref: __future__ --- future 文の定義-Footnote-115176465
Node: モジュールコンテンツ<5>15176535
Ref: library/__future__ module-contents15176639
Ref: 42cd15176639
Ref: library/__future__ future-classes15179397
Ref: 42ce15179397
Ref: library/__future__ future__ _Feature15179397
Ref: 20c815179397
Ref: library/__future__ future__ _Feature getOptionalRelease15180131
Ref: 42cf15180131
Ref: library/__future__ future__ _Feature getMandatoryRelease15180287
Ref: 42d015180287
Ref: library/__future__ future__ _Feature compiler_flag15181035
Ref: 20c915181035
Ref: モジュールコンテンツ<5>-Footnote-115181690
Ref: モジュールコンテンツ<5>-Footnote-215181732
Ref: モジュールコンテンツ<5>-Footnote-315181774
Ref: モジュールコンテンツ<5>-Footnote-415181816
Ref: モジュールコンテンツ<5>-Footnote-515181858
Ref: モジュールコンテンツ<5>-Footnote-615181900
Ref: モジュールコンテンツ<5>-Footnote-715181942
Ref: モジュールコンテンツ<5>-Footnote-815181984
Ref: モジュールコンテンツ<5>-Footnote-915182026
Ref: モジュールコンテンツ<5>-Footnote-1015182662
Ref: モジュールコンテンツ<5>-Footnote-1115182705
Node: gc --- ガベージコレクターインターフェース15182748
Ref: library/gc doc15182986
Ref: 42d115182986
Ref: library/gc gc-garbage-collector-interface15182986
Ref: 42d215182986
Ref: library/gc module-gc15182986
Ref: 5615182986
Ref: library/gc gc enable15184218
Ref: 42d315184218
Ref: library/gc gc disable15184314
Ref: 42d415184314
Ref: library/gc gc isenabled15184411
Ref: 42d515184411
Ref: library/gc gc collect15184531
Ref: a0815184531
Ref: library/gc gc set_debug15185287
Ref: 42d615185287
Ref: library/gc gc get_debug15185570
Ref: 42d715185570
Ref: library/gc gc get_objects15185657
Ref: 7ce15185657
Ref: library/gc gc get_stats15186115
Ref: f1115186115
Ref: library/gc gc set_threshold15186882
Ref: 42d815186882
Ref: library/gc gc get_count15188137
Ref: 42d915188137
Ref: library/gc gc get_threshold15188262
Ref: 42da15188262
Ref: library/gc gc get_referrers15188412
Ref: 7cf15188412
Ref: library/gc gc get_referents15189735
Ref: 7d015189735
Ref: library/gc gc is_tracked15190752
Ref: 12dd15190752
Ref: library/gc gc is_finalized15191859
Ref: 8cb15191859
Ref: library/gc gc freeze15192372
Ref: b0815192372
Ref: library/gc gc unfreeze15193206
Ref: b0915193206
Ref: library/gc gc get_freeze_count15193395
Ref: b0a15193395
Ref: library/gc gc garbage15193721
Ref: 119115193721
Ref: library/gc gc callbacks15194842
Ref: 109a15194842
Ref: library/gc gc DEBUG_STATS15196463
Ref: 42dc15196463
Ref: library/gc gc DEBUG_COLLECTABLE15196621
Ref: 42dd15196621
Ref: library/gc gc DEBUG_UNCOLLECTABLE15196740
Ref: 119215196740
Ref: library/gc gc DEBUG_SAVEALL15197269
Ref: 42db15197269
Ref: library/gc gc DEBUG_LEAK15197535
Ref: 42de15197535
Ref: gc --- ガベージコレクターインターフェース-Footnote-115197781
Ref: gc --- ガベージコレクターインターフェース-Footnote-215197870
Node: inspect --- 活動中のオブジェクトを調査する15197912
Ref: library/inspect doc15198158
Ref: 42df15198158
Ref: library/inspect inspect-inspect-live-objects15198158
Ref: 42e015198158
Ref: library/inspect module-inspect15198282
Ref: 7215198282
Ref: inspect --- 活動中のオブジェクトを調査する-Footnote-115199761
Node: 型とメンバー15199828
Ref: library/inspect inspect-types15199982
Ref: 191515199982
Ref: library/inspect types-and-members15199982
Ref: 42e115199982
Ref: library/inspect inspect getmembers15218078
Ref: 17bf15218078
Ref: library/inspect inspect getmembers_static15218692
Ref: 61515218692
Ref: library/inspect inspect getmodulename15219432
Ref: d0715219432
Ref: library/inspect inspect ismodule15220117
Ref: 42e315220117
Ref: library/inspect inspect isclass15220241
Ref: 42e415220241
Ref: library/inspect inspect ismethod15220405
Ref: 42e515220405
Ref: library/inspect inspect isfunction15220526
Ref: 42e615220526
Ref: library/inspect inspect isgeneratorfunction15220719
Ref: 173c15220719
Ref: library/inspect inspect isgenerator15221237
Ref: 42e715221237
Ref: library/inspect inspect iscoroutinefunction15221367
Ref: 2c515221367
Ref: library/inspect inspect markcoroutinefunction15222239
Ref: 45d15222239
Ref: library/inspect inspect iscoroutine15222831
Ref: de315222831
Ref: library/inspect inspect isawaitable15223046
Ref: de415223046
Ref: library/inspect inspect isasyncgenfunction15223548
Ref: 173d15223548
Ref: library/inspect inspect isasyncgen15224258
Ref: 42e815224258
Ref: library/inspect inspect istraceback15224533
Ref: 42e915224533
Ref: library/inspect inspect isframe15224669
Ref: 42ea15224669
Ref: library/inspect inspect iscode15224792
Ref: 42eb15224792
Ref: library/inspect inspect isbuiltin15224911
Ref: 42ec15224911
Ref: library/inspect inspect ismethodwrapper15225089
Ref: 61615225089
Ref: library/inspect inspect isroutine15225395
Ref: 154e15225395
Ref: library/inspect inspect isabstract15225573
Ref: 42ed15225573
Ref: library/inspect inspect ismethoddescriptor15225714
Ref: 154d15225714
Ref: library/inspect inspect isdatadescriptor15226962
Ref: 42ee15226962
Ref: library/inspect inspect isgetsetdescriptor15227630
Ref: 42ef15227630
Ref: library/inspect inspect ismemberdescriptor15228074
Ref: 42f015228074
Node: ソースコードの情報取得15228544
Ref: library/inspect inspect-source15228789
Ref: 42f115228789
Ref: library/inspect retrieving-source-code15228789
Ref: 42f215228789
Ref: library/inspect inspect getdoc15228867
Ref: 9c815228867
Ref: library/inspect inspect getcomments15229458
Ref: 152915229458
Ref: library/inspect inspect getfile15229879
Ref: 1a0f15229879
Ref: library/inspect inspect getmodule15230188
Ref: 174f15230188
Ref: library/inspect inspect getsourcefile15230349
Ref: 175015230349
Ref: library/inspect inspect getsourcelines15230651
Ref: 42f315230651
Ref: library/inspect inspect getsource15231406
Ref: 152815231406
Ref: library/inspect inspect cleandoc15231997
Ref: 161915231997
Node: Signature オブジェクトで呼び出し可能オブジェクトを内省する15232454
Ref: library/inspect inspect-signature-object15232702
Ref: 42f415232702
Ref: library/inspect introspecting-callables-with-the-signature-object15232702
Ref: 42f515232702
Ref: library/inspect inspect signature15233075
Ref: 70315233075
Ref: library/inspect inspect Signature15235724
Ref: 1b115235724
Ref: library/inspect inspect Signature empty15236846
Ref: 42f815236846
Ref: library/inspect inspect Signature parameters15236993
Ref: 42f615236993
Ref: library/inspect inspect Signature return_annotation15237493
Ref: 42f915237493
Ref: library/inspect inspect Signature bind15237802
Ref: 157d15237802
Ref: library/inspect inspect Signature bind_partial15238086
Ref: 42fa15238086
Ref: library/inspect inspect Signature replace15238469
Ref: 42f715238469
Ref: library/inspect inspect Signature format15239349
Ref: 42fb15239349
Ref: library/inspect inspect Signature from_callable15239769
Ref: 70515239769
Ref: library/inspect inspect Parameter15240513
Ref: 1b215240513
Ref: library/inspect inspect Parameter empty15240936
Ref: 42fd15240936
Ref: library/inspect inspect Parameter name15241097
Ref: 42fe15241097
Ref: library/inspect inspect Parameter default15241586
Ref: 42ff15241586
Ref: library/inspect inspect Parameter annotation15241788
Ref: 430015241788
Ref: library/inspect inspect Parameter kind15241999
Ref: 430115241999
Ref: library/inspect inspect Parameter kind description15244824
Ref: 430215244824
Ref: library/inspect inspect Parameter replace15245374
Ref: 42fc15245374
Ref: library/inspect inspect BoundArguments15246521
Ref: 103e15246521
Ref: library/inspect inspect BoundArguments arguments15246727
Ref: 8da15246727
Ref: library/inspect inspect BoundArguments args15247581
Ref: 430315247581
Ref: library/inspect inspect BoundArguments kwargs15247733
Ref: 430415247733
Ref: library/inspect inspect BoundArguments signature15247978
Ref: 430515247978
Ref: library/inspect inspect BoundArguments apply_defaults15248089
Ref: de215248089
Ref: Signature オブジェクトで呼び出し可能オブジェクトを内省する-Footnote-115249104
Node: クラスと関数<2>15249146
Ref: library/inspect classes-and-functions15249394
Ref: 430615249394
Ref: library/inspect inspect-classes-functions15249394
Ref: 430715249394
Ref: library/inspect inspect getclasstree15249447
Ref: 430815249447
Ref: library/inspect inspect getfullargspec15250092
Ref: 70415250092
Ref: library/inspect inspect getargvalues15252480
Ref: e8715252480
Ref: library/inspect inspect formatargvalues15253074
Ref: e8815253074
Ref: library/inspect inspect getmro15253542
Ref: 430915253542
Ref: library/inspect inspect getcallargs15254025
Ref: e8615254025
Ref: library/inspect inspect getclosurevars15255395
Ref: 10a815255395
Ref: library/inspect inspect unwrap15256140
Ref: f2915256140
Ref: library/inspect inspect get_annotations15256877
Ref: 7de15256877
Node: インタープリタスタック15259770
Ref: library/inspect inspect-stack15259966
Ref: 430a15259966
Ref: library/inspect the-interpreter-stack15259966
Ref: 430b15259966
Ref: library/inspect inspect FrameInfo15260301
Ref: 61815260301
Ref: library/inspect inspect FrameInfo frame15260335
Ref: 430c15260335
Ref: library/inspect inspect FrameInfo filename15260434
Ref: 430d15260434
Ref: library/inspect inspect FrameInfo lineno15260580
Ref: 430e15260580
Ref: library/inspect inspect FrameInfo function15260746
Ref: 430f15260746
Ref: library/inspect inspect FrameInfo code_context15260879
Ref: 431015260879
Ref: library/inspect inspect FrameInfo index15261045
Ref: 431115261045
Ref: library/inspect inspect FrameInfo positions15261177
Ref: 431215261177
Ref: library/inspect inspect Traceback15261730
Ref: 61915261730
Ref: library/inspect inspect Traceback filename15261764
Ref: 431415261764
Ref: library/inspect inspect Traceback lineno15261913
Ref: 431515261913
Ref: library/inspect inspect Traceback function15262082
Ref: 431615262082
Ref: library/inspect inspect Traceback code_context15262218
Ref: 431715262218
Ref: library/inspect inspect Traceback index15262387
Ref: 431815262387
Ref: library/inspect inspect Traceback positions15262519
Ref: 431915262519
Ref: library/inspect inspect getframeinfo15264599
Ref: 61b15264599
Ref: library/inspect inspect getouterframes15264874
Ref: 61c15264874
Ref: library/inspect inspect getinnerframes15265692
Ref: 61d15265692
Ref: library/inspect inspect currentframe15266448
Ref: 6ad15266448
Ref: library/inspect inspect stack15266912
Ref: 61e15266912
Ref: library/inspect inspect trace15267535
Ref: 61f15267535
Node: 属性の静的なフェッチ15268166
Ref: library/inspect fetching-attributes-statically15268407
Ref: 431a15268407
Ref: library/inspect inspect getattr_static15268979
Ref: 46115268979
Node: Current State of Generators Coroutines and Asynchronous Generators15270785
Ref: library/inspect current-state-of-generators-coroutines-and-asynchronous-generators15271015
Ref: 431b15271015
Ref: library/inspect inspect getgeneratorstate15271497
Ref: 120715271497
Ref: library/inspect inspect getcoroutinestate15271977
Ref: de615271977
Ref: library/inspect inspect getasyncgenstate15272623
Ref: 45f15272623
Ref: library/inspect inspect getgeneratorlocals15273553
Ref: 10a915273553
Ref: library/inspect inspect getcoroutinelocals15274419
Ref: de515274419
Ref: library/inspect inspect getasyncgenlocals15274658
Ref: 46015274658
Node: Code Objects Bit Flags15274947
Ref: library/inspect code-objects-bit-flags15275159
Ref: 431c15275159
Ref: library/inspect inspect-module-co-flags15275159
Ref: 1ea615275159
Ref: library/inspect inspect CO_OPTIMIZED15275329
Ref: 431d15275329
Ref: library/inspect inspect CO_NEWLOCALS15275421
Ref: 431e15275421
Ref: library/inspect inspect CO_VARARGS15275575
Ref: 431f15275575
Ref: library/inspect inspect CO_VARKEYWORDS15275688
Ref: 432015275688
Ref: library/inspect inspect CO_NESTED15275805
Ref: 432115275805
Ref: library/inspect inspect CO_GENERATOR15275904
Ref: 432215275904
Ref: library/inspect inspect CO_COROUTINE15276084
Ref: 432315276084
Ref: library/inspect inspect CO_ITERABLE_COROUTINE15276326
Ref: 432415276326
Ref: library/inspect inspect CO_ASYNC_GENERATOR15276646
Ref: 432515276646
Ref: Code Objects Bit Flags-Footnote-115277298
Ref: Code Objects Bit Flags-Footnote-215277340
Ref: Code Objects Bit Flags-Footnote-315277382
Node: Buffer flags15277424
Ref: library/inspect buffer-flags15277618
Ref: 432615277618
Ref: library/inspect inspect BufferFlags15277665
Ref: 42c15277665
Ref: library/inspect inspect BufferFlags SIMPLE15277999
Ref: 432715277999
Ref: library/inspect inspect BufferFlags WRITABLE15278027
Ref: 432815278027
Ref: library/inspect inspect BufferFlags FORMAT15278057
Ref: 432915278057
Ref: library/inspect inspect BufferFlags ND15278085
Ref: 432a15278085
Ref: library/inspect inspect BufferFlags STRIDES15278109
Ref: 432b15278109
Ref: library/inspect inspect BufferFlags C_CONTIGUOUS15278138
Ref: 432c15278138
Ref: library/inspect inspect BufferFlags F_CONTIGUOUS15278172
Ref: 432d15278172
Ref: library/inspect inspect BufferFlags ANY_CONTIGUOUS15278206
Ref: 432e15278206
Ref: library/inspect inspect BufferFlags INDIRECT15278242
Ref: 432f15278242
Ref: library/inspect inspect BufferFlags CONTIG15278272
Ref: 433015278272
Ref: library/inspect inspect BufferFlags CONTIG_RO15278300
Ref: 433115278300
Ref: library/inspect inspect BufferFlags STRIDED15278331
Ref: 433215278331
Ref: library/inspect inspect BufferFlags STRIDED_RO15278360
Ref: 433315278360
Ref: library/inspect inspect BufferFlags RECORDS15278392
Ref: 433415278392
Ref: library/inspect inspect BufferFlags RECORDS_RO15278421
Ref: 433515278421
Ref: library/inspect inspect BufferFlags FULL15278453
Ref: 433615278453
Ref: library/inspect inspect BufferFlags FULL_RO15278479
Ref: 433715278479
Ref: library/inspect inspect BufferFlags READ15278508
Ref: 433815278508
Ref: library/inspect inspect BufferFlags WRITE15278534
Ref: 433915278534
Node: コマンドラインインターフェイス<9>15278590
Ref: library/inspect command-line-interface15278753
Ref: 433a15278753
Ref: library/inspect inspect-module-cli15278753
Ref: f2815278753
Ref: library/inspect cmdoption-inspect-details15279161
Ref: 433b15279161
Node: site --- サイト固有の設定フック15279268
Ref: library/site doc15279447
Ref: 433c15279447
Ref: library/site module-site15279447
Ref: b515279447
Ref: library/site site-site-specific-configuration-hook15279447
Ref: 433d15279447
Ref: site --- サイト固有の設定フック-Footnote-115285564
Node: sitecustomize15285628
Ref: library/site module-sitecustomize15285742
Ref: b615285742
Ref: library/site sitecustomize15285742
Ref: 433f15285742
Node: usercustomize15286775
Ref: library/site module-usercustomize15286916
Ref: f715286916
Ref: library/site usercustomize15286916
Ref: 434015286916
Node: readline の設定15287963
Ref: library/site readline-configuration15288118
Ref: 434215288118
Ref: library/site rlcompleter-config15288118
Ref: f9615288118
Node: モジュールの内容<5>15289276
Ref: library/site module-contents15289467
Ref: 434315289467
Ref: library/site site PREFIXES15289530
Ref: 434415289530
Ref: library/site site ENABLE_USER_SITE15289628
Ref: 434115289628
Ref: library/site site USER_SITE15290316
Ref: 1c9f15290316
Ref: library/site site USER_BASE15290932
Ref: 12eb15290932
Ref: library/site site main15291693
Ref: 1ca015291693
Ref: library/site site addsitedir15292124
Ref: 434515292124
Ref: library/site site getsitepackages15292404
Ref: 120f15292404
Ref: library/site site getuserbase15292569
Ref: 121015292569
Ref: library/site site getusersitepackages15292855
Ref: 121115292855
Node: コマンドラインインターフェイス<10>15293341
Ref: library/site command-line-interface15293505
Ref: 434615293505
Ref: library/site site-commandline15293505
Ref: 434715293505
Ref: library/site cmdoption-site-user-base15294166
Ref: 434815294166
Ref: library/site cmdoption-site-user-site15294258
Ref: 434915294258
Ref: コマンドラインインターフェイス<10>-Footnote-115295209
Node: カスタム Python インタプリタ15295251
Ref: library/custominterp doc15295439
Ref: 434a15295439
Ref: library/custominterp custom-python-interpreters15295439
Ref: 434b15295439
Ref: library/custominterp custominterp15295439
Ref: 434c15295439
Node: code --- インタープリター基底クラス15296331
Ref: library/code doc15296514
Ref: 434d15296514
Ref: library/code code-interpreter-base-classes15296514
Ref: 434e15296514
Ref: library/code module-code15296514
Ref: 1315296514
Ref: library/code code InteractiveInterpreter15297047
Ref: 153c15297047
Ref: library/code code InteractiveConsole15297747
Ref: 22f815297747
Ref: library/code code interact15298469
Ref: 163b15298469
Ref: library/code code compile_command15299719
Ref: 435115299719
Ref: code --- インタープリター基底クラス-Footnote-115301379
Node: 対話的なインタプリタオブジェクト15301443
Ref: library/code interactive-interpreter-objects15301630
Ref: 435215301630
Ref: library/code interpreter-objects15301630
Ref: 435315301630
Ref: library/code code InteractiveInterpreter runsource15301731
Ref: 435415301731
Ref: library/code code InteractiveInterpreter runcode15303292
Ref: 435615303292
Ref: library/code code InteractiveInterpreter showsyntaxerror15303968
Ref: 435515303968
Ref: library/code code InteractiveInterpreter showtraceback15304618
Ref: d9d15304618
Ref: library/code code InteractiveInterpreter write15305131
Ref: 435715305131
Node: 対話的なコンソールオブジェクト15305421
Ref: library/code console-objects15305608
Ref: 435815305608
Ref: library/code interactive-console-objects15305608
Ref: 435915305608
Ref: library/code code InteractiveConsole interact15305944
Ref: 435015305944
Ref: library/code code InteractiveConsole push15307121
Ref: 435a15307121
Ref: library/code code InteractiveConsole resetbuffer15308078
Ref: 435b15308078
Ref: library/code code InteractiveConsole raw_input15308231
Ref: 434f15308231
Node: codeop --- Python コードをコンパイルする15308685
Ref: library/codeop doc15308868
Ref: 435c15308868
Ref: library/codeop codeop-compile-python-code15308868
Ref: 435d15308868
Ref: library/codeop module-codeop15308868
Ref: 1515308868
Ref: library/codeop codeop compile_command15310169
Ref: 173315310169
Ref: library/codeop codeop Compile15311974
Ref: 435e15311974
Ref: library/codeop codeop CommandCompiler15312506
Ref: 435f15312506
Ref: codeop --- Python コードをコンパイルする-Footnote-115313079
Node: モジュールのインポート15313145
Ref: library/modules doc15313323
Ref: 436015313323
Ref: library/modules importing-modules15313323
Ref: 436115313323
Ref: library/modules modules15313323
Ref: 436215313323
Node: zipimport --- Zip アーカイブからモジュールをインポートする15314853
Ref: library/zipimport doc15315064
Ref: 436315315064
Ref: library/zipimport module-zipimport15315064
Ref: 11815315064
Ref: library/zipimport zipimport-import-modules-from-zip-archives15315064
Ref: 436415315064
Ref: library/zipimport zipimport ZipImportError15318049
Ref: 436515318049
Ref: zipimport --- Zip アーカイブからモジュールをインポートする-Footnote-115318387
Ref: zipimport --- Zip アーカイブからモジュールをインポートする-Footnote-215318456
Ref: zipimport --- Zip アーカイブからモジュールをインポートする-Footnote-315318524
Ref: zipimport --- Zip アーカイブからモジュールをインポートする-Footnote-415318566
Ref: zipimport --- Zip アーカイブからモジュールをインポートする-Footnote-515318608
Node: zipimporter オブジェクト15318650
Ref: library/zipimport id115318817
Ref: 436615318817
Ref: library/zipimport zipimporter-objects15318817
Ref: 436715318817
Ref: library/zipimport zipimport zipimporter15318983
Ref: 436815318983
Ref: library/zipimport zipimport zipimporter create_module15319811
Ref: 82a15319811
Ref: library/zipimport zipimport zipimporter exec_module15320063
Ref: 2ea15320063
Ref: library/zipimport zipimport zipimporter find_spec15320219
Ref: 82915320219
Ref: library/zipimport zipimport zipimporter get_code15320406
Ref: 436915320406
Ref: library/zipimport zipimport zipimporter get_data15320685
Ref: 436a15320685
Ref: library/zipimport zipimport zipimporter get_filename15321093
Ref: 436b15321093
Ref: library/zipimport zipimport zipimporter get_source15321453
Ref: 436c15321453
Ref: library/zipimport zipimport zipimporter is_package15321847
Ref: 436d15321847
Ref: library/zipimport zipimport zipimporter load_module15322122
Ref: 2e915322122
Ref: library/zipimport zipimport zipimporter invalidate_caches15322528
Ref: 82b15322528
Ref: library/zipimport zipimport zipimporter archive15322714
Ref: 436e15322714
Ref: library/zipimport zipimport zipimporter prefix15322879
Ref: 436f15322879
Node: 使用例<46>15323355
Ref: library/zipimport examples15323522
Ref: 437015323522
Ref: library/zipimport zipimport-examples15323522
Ref: 437115323522
Node: pkgutil --- パッケージ拡張ユーティリティ15324271
Ref: library/pkgutil doc15324574
Ref: 437215324574
Ref: library/pkgutil module-pkgutil15324574
Ref: 9715324574
Ref: library/pkgutil pkgutil-package-extension-utility15324574
Ref: 437315324574
Ref: library/pkgutil pkgutil ModuleInfo15324935
Ref: d1915324935
Ref: library/pkgutil pkgutil extend_path15325090
Ref: 154815325090
Ref: library/pkgutil pkgutil find_loader15327026
Ref: 2ac15327026
Ref: library/pkgutil pkgutil get_importer15327981
Ref: 437415327981
Ref: library/pkgutil pkgutil get_loader15328669
Ref: 2ad15328669
Ref: library/pkgutil pkgutil iter_importers15329800
Ref: 116b15329800
Ref: library/pkgutil pkgutil iter_modules15330702
Ref: d1815330702
Ref: library/pkgutil pkgutil walk_packages15331834
Ref: bcd15331834
Ref: library/pkgutil pkgutil get_data15333857
Ref: 437515333857
Ref: library/pkgutil pkgutil resolve_name15335133
Ref: 437715335133
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-115336990
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-215337057
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-315337099
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-415337141
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-515337183
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-615337225
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-715337267
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-815337309
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-915337351
Ref: pkgutil --- パッケージ拡張ユーティリティ-Footnote-1015337393
Node: modulefinder --- スクリプト中で使用されているモジュールの検索15337459
Ref: library/modulefinder doc15337740
Ref: 437815337740
Ref: library/modulefinder module-modulefinder15337740
Ref: 8415337740
Ref: library/modulefinder modulefinder-find-modules-used-by-a-script15337740
Ref: 437915337740
Ref: library/modulefinder modulefinder AddPackagePath15338447
Ref: 437a15338447
Ref: library/modulefinder modulefinder ReplacePackage15338624
Ref: 437b15338624
Ref: library/modulefinder modulefinder ModuleFinder15338859
Ref: 196e15338859
Ref: library/modulefinder modulefinder ModuleFinder report15339816
Ref: 437d15339816
Ref: library/modulefinder modulefinder ModuleFinder run_script15340173
Ref: 437c15340173
Ref: library/modulefinder modulefinder ModuleFinder modules15340389
Ref: 437e15340389
Ref: modulefinder --- スクリプト中で使用されているモジュールの検索-Footnote-115340646
Node: ModuleFinder の使用例15340718
Ref: library/modulefinder example-usage-of-modulefinder15340863
Ref: 438015340863
Ref: library/modulefinder modulefinder-example15340863
Ref: 437f15340863
Node: runpy --- Python モジュールの位置特定と実行15342264
Ref: library/runpy doc15342521
Ref: 438115342521
Ref: library/runpy module-runpy15342521
Ref: ac15342521
Ref: library/runpy runpy-locating-and-executing-python-modules15342521
Ref: 438215342521
Ref: library/runpy runpy run_module15343930
Ref: 177715343930
Ref: library/runpy runpy run_path15347553
Ref: 16615347553
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-115352155
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-215352220
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-315352262
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-415352304
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-515352346
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-615352388
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-715352430
Ref: runpy --- Python モジュールの位置特定と実行-Footnote-815352472
Node: importlib --- import の実装15352514
Ref: library/importlib doc15352783
Ref: 438315352783
Ref: library/importlib importlib-the-implementation-of-import15352783
Ref: 438415352783
Ref: library/importlib module-importlib15352783
Ref: 6b15352783
Ref: importlib --- import の実装-Footnote-115353563
Node: はじめに<10>15353642
Ref: library/importlib introduction15353744
Ref: 438515353744
Ref: はじめに<10>-Footnote-115356352
Ref: はじめに<10>-Footnote-215356404
Ref: はじめに<10>-Footnote-315356446
Ref: はじめに<10>-Footnote-415356488
Ref: はじめに<10>-Footnote-515356530
Ref: はじめに<10>-Footnote-615356572
Ref: はじめに<10>-Footnote-715356614
Ref: はじめに<10>-Footnote-815356656
Ref: はじめに<10>-Footnote-915356698
Ref: はじめに<10>-Footnote-1015356740
Ref: はじめに<10>-Footnote-1115356783
Ref: はじめに<10>-Footnote-1215356826
Ref: はじめに<10>-Footnote-1315356869
Node: 関数<12>15356912
Ref: library/importlib functions15357091
Ref: 438615357091
Ref: library/importlib importlib __import__15357122
Ref: 104215357122
Ref: library/importlib importlib import_module15357480
Ref: 4e115357480
Ref: library/importlib importlib invalidate_caches15359166
Ref: bde15359166
Ref: library/importlib importlib reload15359967
Ref: 4e215359967
Node: importlib abc -- インポートに関連する抽象基底クラス15364743
Ref: library/importlib importlib-abc-abstract-base-classes-related-to-import15364968
Ref: 438715364968
Ref: library/importlib module-importlib abc15364968
Ref: 6c15364968
Ref: library/importlib importlib abc MetaPathFinder15365854
Ref: 83a15365854
Ref: library/importlib importlib abc MetaPathFinder find_spec15366079
Ref: 83415366079
Ref: library/importlib importlib abc MetaPathFinder invalidate_caches15366830
Ref: 438815366830
Ref: library/importlib importlib abc PathEntryFinder15367350
Ref: 83b15367350
Ref: library/importlib importlib abc PathEntryFinder find_spec15367858
Ref: 83815367858
Ref: library/importlib importlib abc PathEntryFinder invalidate_caches15368699
Ref: 438915368699
Ref: library/importlib importlib abc Loader15369103
Ref: e9015369103
Ref: library/importlib importlib abc Loader create_module15369650
Ref: c7c15369650
Ref: library/importlib importlib abc Loader exec_module15370252
Ref: 83615370252
Ref: library/importlib importlib abc Loader load_module15370920
Ref: 83515370920
Ref: library/importlib importlib abc ResourceLoader15373218
Ref: bb515373218
Ref: library/importlib importlib abc ResourceLoader get_data15373650
Ref: 437615373650
Ref: library/importlib importlib abc InspectLoader15374368
Ref: f2115374368
Ref: library/importlib importlib abc InspectLoader get_code15374595
Ref: f2215374595
Ref: library/importlib importlib abc InspectLoader get_source15375417
Ref: f2515375417
Ref: library/importlib importlib abc InspectLoader is_package15376152
Ref: 438b15376152
Ref: library/importlib importlib abc InspectLoader source_to_code15376658
Ref: dde15376658
Ref: library/importlib importlib abc InspectLoader exec_module15377497
Ref: fdd15377497
Ref: library/importlib importlib abc InspectLoader load_module15377638
Ref: 438c15377638
Ref: library/importlib importlib abc ExecutionLoader15377874
Ref: 438d15377874
Ref: library/importlib importlib abc ExecutionLoader get_filename15378211
Ref: 438e15378211
Ref: library/importlib importlib abc FileLoader15378876
Ref: 104815378876
Ref: library/importlib importlib abc FileLoader name15379430
Ref: 438f15379430
Ref: library/importlib importlib abc FileLoader path15379525
Ref: 439015379525
Ref: library/importlib importlib abc FileLoader load_module15379614
Ref: 439115379614
Ref: library/importlib importlib abc FileLoader get_filename15379865
Ref: 439215379865
Ref: library/importlib importlib abc FileLoader get_data15379976
Ref: 439315379976
Ref: library/importlib importlib abc SourceLoader15380148
Ref: 439415380148
Ref: library/importlib importlib abc SourceLoader path_stats15381622
Ref: 115c15381622
Ref: library/importlib importlib abc SourceLoader path_mtime15382471
Ref: 115d15382471
Ref: library/importlib importlib abc SourceLoader set_data15383115
Ref: 439515383115
Ref: library/importlib importlib abc SourceLoader get_code15383723
Ref: 439615383723
Ref: library/importlib importlib abc SourceLoader exec_module15383840
Ref: fde15383840
Ref: library/importlib importlib abc SourceLoader load_module15383987
Ref: 439715383987
Ref: library/importlib importlib abc SourceLoader get_source15384229
Ref: feb15384229
Ref: library/importlib importlib abc SourceLoader is_package15384350
Ref: 439815384350
Ref: library/importlib importlib abc ResourceReader15384901
Ref: acb15384901
Ref: library/importlib importlib abc ResourceReader open_resource15386809
Ref: 439915386809
Ref: library/importlib importlib abc ResourceReader resource_path15387104
Ref: 439a15387104
Ref: library/importlib importlib abc ResourceReader is_resource15387397
Ref: 439b15387397
Ref: library/importlib importlib abc ResourceReader contents15387670
Ref: 19af15387670
Ref: library/importlib importlib abc Traversable15388545
Ref: 17ef15388545
Ref: library/importlib importlib abc Traversable name15388989
Ref: 439c15388989
Ref: library/importlib importlib abc Traversable iterdir15389107
Ref: 439d15389107
Ref: library/importlib importlib abc Traversable is_dir15389215
Ref: 439e15389215
Ref: library/importlib importlib abc Traversable is_file15389323
Ref: 439f15389323
Ref: library/importlib importlib abc Traversable joinpath15389427
Ref: 43a015389427
Ref: library/importlib importlib abc Traversable __truediv__15389534
Ref: 43a115389534
Ref: library/importlib importlib abc Traversable open15389650
Ref: 43a215389650
Ref: library/importlib importlib abc Traversable read_bytes15390012
Ref: 43a315390012
Ref: library/importlib importlib abc Traversable read_text15390099
Ref: 43a415390099
Ref: library/importlib importlib abc TraversableResources15390197
Ref: 17ed15390197
Ref: library/importlib importlib abc TraversableResources files15390970
Ref: 43a515390970
Ref: importlib abc -- インポートに関連する抽象基底クラス-Footnote-115391164
Ref: importlib abc -- インポートに関連する抽象基底クラス-Footnote-215391237
Ref: importlib abc -- インポートに関連する抽象基底クラス-Footnote-315391279
Ref: importlib abc -- インポートに関連する抽象基底クラス-Footnote-415391321
Ref: importlib abc -- インポートに関連する抽象基底クラス-Footnote-515391363
Node: importlib machinery -- インポータおよびパスフック15391405
Ref: library/importlib importlib-machinery-importers-and-path-hooks15391695
Ref: 43a615391695
Ref: library/importlib module-importlib machinery15391695
Ref: 6d15391695
Ref: library/importlib importlib machinery SOURCE_SUFFIXES15392115
Ref: 4dd15392115
Ref: library/importlib importlib machinery DEBUG_BYTECODE_SUFFIXES15392316
Ref: 43a715392316
Ref: library/importlib importlib machinery OPTIMIZED_BYTECODE_SUFFIXES15392657
Ref: 43a815392657
Ref: library/importlib importlib machinery BYTECODE_SUFFIXES15392993
Ref: 4df15392993
Ref: library/importlib importlib machinery EXTENSION_SUFFIXES15393350
Ref: 4de15393350
Ref: library/importlib importlib machinery all_suffixes15393569
Ref: 42e215393569
Ref: library/importlib importlib machinery BuiltinImporter15394121
Ref: c7d15394121
Ref: library/importlib importlib machinery FrozenImporter15394873
Ref: fe915394873
Ref: library/importlib importlib machinery WindowsRegistryFinder15395427
Ref: cf815395427
Ref: library/importlib importlib machinery PathFinder15396120
Ref: fed15396120
Ref: library/importlib importlib machinery PathFinder find_spec15396537
Ref: fdc15396537
Ref: library/importlib importlib machinery PathFinder invalidate_caches15398084
Ref: bdd15398084
Ref: library/importlib importlib machinery FileFinder15398785
Ref: 104715398785
Ref: library/importlib importlib machinery FileFinder path15400401
Ref: 43a915400401
Ref: library/importlib importlib machinery FileFinder find_spec15400490
Ref: e8e15400490
Ref: library/importlib importlib machinery FileFinder invalidate_caches15400688
Ref: 43aa15400688
Ref: library/importlib importlib machinery FileFinder path_hook15400796
Ref: 43ab15400796
Ref: library/importlib importlib machinery SourceFileLoader15401281
Ref: 104915401281
Ref: library/importlib importlib machinery SourceFileLoader name15401584
Ref: 43ac15401584
Ref: library/importlib importlib machinery SourceFileLoader path15401682
Ref: 43ad15401682
Ref: library/importlib importlib machinery SourceFileLoader is_package15401762
Ref: 43ae15401762
Ref: library/importlib importlib machinery SourceFileLoader path_stats15401901
Ref: 43af15401901
Ref: library/importlib importlib machinery SourceFileLoader set_data15402043
Ref: 43b015402043
Ref: library/importlib importlib machinery SourceFileLoader load_module15402187
Ref: cf615402187
Ref: library/importlib importlib machinery SourcelessFileLoader15402544
Ref: 104a15402544
Ref: library/importlib importlib machinery SourcelessFileLoader name15403191
Ref: 43b115403191
Ref: library/importlib importlib machinery SourcelessFileLoader path15403283
Ref: 43b215403283
Ref: library/importlib importlib machinery SourcelessFileLoader is_package15403372
Ref: 43b315403372
Ref: library/importlib importlib machinery SourcelessFileLoader get_code15403547
Ref: 43b415403547
Ref: library/importlib importlib machinery SourcelessFileLoader get_source15403720
Ref: 43b515403720
Ref: library/importlib importlib machinery SourcelessFileLoader load_module15403918
Ref: cf715403918
Ref: library/importlib importlib machinery ExtensionFileLoader15404255
Ref: c7e15404255
Ref: library/importlib importlib machinery ExtensionFileLoader name15404963
Ref: 43b615404963
Ref: library/importlib importlib machinery ExtensionFileLoader path15405067
Ref: 43b715405067
Ref: library/importlib importlib machinery ExtensionFileLoader create_module15405147
Ref: 43b815405147
Ref: library/importlib importlib machinery ExtensionFileLoader exec_module15405359
Ref: 43b915405359
Ref: library/importlib importlib machinery ExtensionFileLoader is_package15405556
Ref: 43ba15405556
Ref: library/importlib importlib machinery ExtensionFileLoader get_code15405806
Ref: 43bb15405806
Ref: library/importlib importlib machinery ExtensionFileLoader get_source15405969
Ref: 43bc15405969
Ref: library/importlib importlib machinery ExtensionFileLoader get_filename15406114
Ref: f2615406114
Ref: library/importlib importlib machinery NamespaceLoader15406243
Ref: f2315406243
Ref: library/importlib importlib machinery ModuleSpec15406909
Ref: 1dcb15406909
Ref: library/importlib importlib machinery ModuleSpec name15407706
Ref: 1e7815407706
Ref: library/importlib importlib machinery ModuleSpec loader15407914
Ref: 2c415407914
Ref: library/importlib importlib machinery ModuleSpec origin15408117
Ref: 43bd15408117
Ref: library/importlib importlib machinery ModuleSpec submodule_search_locations15408619
Ref: 1e7c15408619
Ref: library/importlib importlib machinery ModuleSpec loader_state15409267
Ref: 43be15409267
Ref: library/importlib importlib machinery ModuleSpec cached15409511
Ref: 2b815409511
Ref: library/importlib importlib machinery ModuleSpec parent15409807
Ref: 2ba15409807
Ref: library/importlib importlib machinery ModuleSpec has_location15410098
Ref: 43bf15410098
Ref: library/importlib importlib machinery AppleFrameworkLoader15410381
Ref: 1dca15410381
Ref: library/importlib importlib machinery AppleFrameworkLoader name15414189
Ref: 43c015414189
Ref: library/importlib importlib machinery AppleFrameworkLoader path15414293
Ref: 43c115414293
Ref: importlib machinery -- インポータおよびパスフック-Footnote-115414432
Ref: importlib machinery -- インポータおよびパスフック-Footnote-215414512
Ref: importlib machinery -- インポータおよびパスフック-Footnote-315414554
Ref: importlib machinery -- インポータおよびパスフック-Footnote-415414596
Ref: importlib machinery -- インポータおよびパスフック-Footnote-515414638
Node: importlib util -- インポータのためのユーティリティコード15414680
Ref: library/importlib importlib-util-utility-code-for-importers15414915
Ref: 43c215414915
Ref: library/importlib module-importlib util15414915
Ref: 7115414915
Ref: library/importlib importlib util MAGIC_NUMBER15415321
Ref: 4dc15415321
Ref: library/importlib importlib util cache_from_source15415635
Ref: 2d515415635
Ref: library/importlib importlib util source_from_cache15418037
Ref: 4e315418037
Ref: library/importlib importlib util decode_source15418867
Ref: f2415418867
Ref: library/importlib importlib util resolve_name15419231
Ref: 8d815419231
Ref: library/importlib importlib util find_spec15420321
Ref: 2ae15420321
Ref: library/importlib importlib util module_from_spec15421320
Ref: ddf15421320
Ref: library/importlib importlib util spec_from_loader15422185
Ref: 83915422185
Ref: library/importlib importlib util spec_from_file_location15422510
Ref: c7f15422510
Ref: library/importlib importlib util source_hash15423160
Ref: 43c315423160
Ref: library/importlib importlib util _incompatible_extension_module_restrictions15423433
Ref: 43c415423433
Ref: library/importlib importlib util LazyLoader15424548
Ref: c7b15424548
Ref: library/importlib importlib util LazyLoader factory15426210
Ref: 43c515426210
Ref: importlib util -- インポータのためのユーティリティコード-Footnote-115426849
Ref: importlib util -- インポータのためのユーティリティコード-Footnote-215426923
Ref: importlib util -- インポータのためのユーティリティコード-Footnote-315426965
Ref: importlib util -- インポータのためのユーティリティコード-Footnote-415427007
Ref: importlib util -- インポータのためのユーティリティコード-Footnote-515427049
Ref: importlib util -- インポータのためのユーティリティコード-Footnote-615427091
Ref: importlib util -- インポータのためのユーティリティコード-Footnote-715427133
Node: 使用例<47>15427175
Ref: library/importlib examples15427339
Ref: 43c615427339
Ref: library/importlib importlib-examples15427339
Ref: 43c715427339
Node: プログラムからのインポート15427706
Ref: library/importlib importing-programmatically15427861
Ref: 43c815427861
Node: モジュールがインポートできるか確認する15428162
Ref: library/importlib checking-if-a-module-can-be-imported15428380
Ref: 43c915428380
Node: ソースファイルから直接インポートする15429368
Ref: library/importlib importing-a-source-file-directly15429572
Ref: 43ca15429572
Node: Implementing lazy imports15430766
Ref: library/importlib implementing-lazy-imports15430952
Ref: 43cb15430952
Node: インポーターのセットアップ15431671
Ref: library/importlib setting-up-an-importer15431840
Ref: 43cc15431840
Node: Approximating importlib import_module15433437
Ref: library/importlib approximating-importlib-import-module15433572
Ref: 43cd15433572
Node: importlib resources -- パッケージリソースの読み取り、オープン、アクセス15435072
Ref: library/importlib resources doc15435348
Ref: 43ce15435348
Ref: library/importlib resources importlib-resources-package-resource-reading-opening-and-access15435348
Ref: 43cf15435348
Ref: library/importlib resources module-importlib resources15435348
Ref: 6f15435348
Ref: library/importlib resources importlib resources Anchor15437619
Ref: 43d015437619
Ref: library/importlib resources importlib resources files15437821
Ref: 45b15437821
Ref: library/importlib resources importlib resources as_file15438866
Ref: 45a15438866
Ref: importlib resources -- パッケージリソースの読み取り、オープン、アクセス-Footnote-115439709
Ref: importlib resources -- パッケージリソースの読み取り、オープン、アクセス-Footnote-215439798
Ref: importlib resources -- パッケージリソースの読み取り、オープン、アクセス-Footnote-315439869
Ref: importlib resources -- パッケージリソースの読み取り、オープン、アクセス-Footnote-415439963
Ref: importlib resources -- パッケージリソースの読み取り、オープン、アクセス-Footnote-515440035
Node: 関数 API15440112
Ref: library/importlib resources functional-api15440254
Ref: 43d115440254
Ref: library/importlib resources importlib-resources-functional15440254
Ref: 43d215440254
Ref: library/importlib resources importlib resources open_binary15441484
Ref: 1ce15441484
Ref: library/importlib resources importlib resources open_text15441977
Ref: 1cf15441977
Ref: library/importlib resources importlib resources read_binary15442930
Ref: 1d115442930
Ref: library/importlib resources importlib resources read_text15443350
Ref: 1d215443350
Ref: library/importlib resources importlib resources path15444227
Ref: 1d015444227
Ref: library/importlib resources importlib resources is_resource15445223
Ref: 1cd15445223
Ref: library/importlib resources importlib resources contents15445700
Ref: 1d315445700
Node: importlib resources abc -- リソースの抽象基底クラス15446408
Ref: library/importlib resources abc doc15446724
Ref: 43d315446724
Ref: library/importlib resources abc importlib-resources-abc-abstract-base-classes-for-resources15446724
Ref: 43d415446724
Ref: library/importlib resources abc module-importlib resources abc15446724
Ref: 7015446724
Ref: library/importlib resources abc importlib resources abc ResourceReader15447010
Ref: 438a15447010
Ref: library/importlib resources abc importlib resources abc ResourceReader open_resource15448900
Ref: 43d515448900
Ref: library/importlib resources abc importlib resources abc ResourceReader resource_path15449195
Ref: 43d615449195
Ref: library/importlib resources abc importlib resources abc ResourceReader is_resource15449488
Ref: 43d715449488
Ref: library/importlib resources abc importlib resources abc ResourceReader contents15449761
Ref: 43d815449761
Ref: library/importlib resources abc importlib resources abc Traversable15450636
Ref: 1d415450636
Ref: library/importlib resources abc importlib resources abc Traversable name15450926
Ref: 43d915450926
Ref: library/importlib resources abc importlib resources abc Traversable iterdir15451044
Ref: 43da15451044
Ref: library/importlib resources abc importlib resources abc Traversable is_dir15451140
Ref: 43db15451140
Ref: library/importlib resources abc importlib resources abc Traversable is_file15451242
Ref: 43dc15451242
Ref: library/importlib resources abc importlib resources abc Traversable joinpath15451340
Ref: 43dd15451340
Ref: library/importlib resources abc importlib resources abc Traversable __truediv__15452467
Ref: 43de15452467
Ref: library/importlib resources abc importlib resources abc Traversable open15452619
Ref: 43df15452619
Ref: library/importlib resources abc importlib resources abc Traversable read_bytes15452981
Ref: 43e015452981
Ref: library/importlib resources abc importlib resources abc Traversable read_text15453062
Ref: 43e115453062
Ref: library/importlib resources abc importlib resources abc TraversableResources15453154
Ref: 2a615453154
Ref: library/importlib resources abc importlib resources abc TraversableResources files15453680
Ref: 43e215453680
Ref: importlib resources abc -- リソースの抽象基底クラス-Footnote-115453874
Node: importlib metadata -- パッケージメタデータへのアクセス15453958
Ref: library/importlib metadata doc15454227
Ref: 43e315454227
Ref: library/importlib metadata importlib-metadata-accessing-package-metadata15454227
Ref: 43e415454227
Ref: library/importlib metadata module-importlib metadata15454227
Ref: 6e15454227
Ref: library/importlib metadata using15454227
Ref: 43e515454227
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-115457153
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-215457241
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-315457325
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-415457403
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-515457488
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-615457573
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-715457611
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-815457703
Ref: importlib metadata -- パッケージメタデータへのアクセス-Footnote-915457772
Node: 概要<3>15457848
Ref: library/importlib metadata overview15457983
Ref: 43e615457983
Ref: library/importlib metadata importlib metadata PackageNotFoundError15459783
Ref: 43eb15459783
Ref: 概要<3>-Footnote-115460073
Node: 機能 API15460157
Ref: library/importlib metadata functional-api15460314
Ref: 43ec15460314
Node: エントリポイント15460626
Ref: library/importlib metadata entry-points15460730
Ref: 26515460730
Ref: library/importlib metadata id215460730
Ref: 43ed15460730
Ref: library/importlib metadata importlib metadata entry_points15460791
Ref: 43ee15460791
Ref: library/importlib metadata importlib metadata EntryPoints15461364
Ref: 43ef15461364
Ref: library/importlib metadata importlib metadata EntryPoint15461647
Ref: 43f015461647
Ref: エントリポイント-Footnote-115464660
Ref: エントリポイント-Footnote-215464732
Node: 配布物メタデータ15464800
Ref: library/importlib metadata distribution-metadata15464937
Ref: 43f115464937
Ref: library/importlib metadata metadata15464937
Ref: 43e715464937
Ref: library/importlib metadata importlib metadata metadata15464998
Ref: 43f215464998
Ref: library/importlib metadata importlib metadata PackageMetadata15465336
Ref: 43f315465336
Ref: 配布物メタデータ-Footnote-115466662
Ref: 配布物メタデータ-Footnote-215466767
Ref: 配布物メタデータ-Footnote-315466851
Ref: 配布物メタデータ-Footnote-415466893
Node: 配布物バージョン15466985
Ref: library/importlib metadata distribution-versions15467119
Ref: 43f415467119
Ref: library/importlib metadata version15467119
Ref: 43e815467119
Ref: library/importlib metadata importlib metadata version15467180
Ref: 151815467180
Ref: 配布物バージョン-Footnote-115467669
Node: 配布物ファイル15467753
Ref: library/importlib metadata distribution-files15467881
Ref: 43f515467881
Ref: library/importlib metadata files15467881
Ref: 43e915467881
Ref: library/importlib metadata importlib metadata files15467937
Ref: 43f615467937
Ref: library/importlib metadata importlib metadata PackagePath15468406
Ref: 43f715468406
Ref: 配布物ファイル-Footnote-115470015
Ref: 配布物ファイル-Footnote-215470099
Node: 配布物の要件15470196
Ref: library/importlib metadata distribution-requirements15470339
Ref: 43f815470339
Ref: library/importlib metadata requirements15470339
Ref: 43ea15470339
Ref: library/importlib metadata importlib metadata requires15470390
Ref: 43f915470390
Ref: library/importlib metadata package-distributions15470887
Ref: 7db15470887
Ref: 配布物の要件-Footnote-115470924
Node: Mapping import to distribution packages15471008
Ref: library/importlib metadata import-distribution-package-mapping15471121
Ref: 43fa15471121
Ref: library/importlib metadata mapping-import-to-distribution-packages15471121
Ref: 43fb15471121
Ref: library/importlib metadata importlib metadata packages_distributions15471220
Ref: 43fc15471220
Ref: Mapping import to distribution packages-Footnote-115472307
Ref: Mapping import to distribution packages-Footnote-215472385
Ref: Mapping import to distribution packages-Footnote-315472469
Node: Distributions15472531
Ref: library/importlib metadata distributions15472701
Ref: 7dc15472701
Ref: library/importlib metadata id915472701
Ref: 43fd15472701
Ref: library/importlib metadata importlib metadata distribution15472748
Ref: 43fe15472748
Ref: library/importlib metadata importlib metadata Distribution15473052
Ref: 43ff15473052
Ref: Distributions-Footnote-115474678
Ref: Distributions-Footnote-215474762
Ref: Distributions-Footnote-315474804
Node: Distribution Discovery15474896
Ref: library/importlib metadata distribution-discovery15475089
Ref: 440015475089
Ref: Distribution Discovery-Footnote-115475947
Node: 検索アルゴリズムの拡張15476031
Ref: library/importlib metadata extending-the-search-algorithm15476202
Ref: 440115476202
Ref: 検索アルゴリズムの拡張-Footnote-115478351
Node: 使用例<48>15478435
Ref: library/importlib metadata example15478518
Ref: 440215478518
Node: sys path モジュール検索パスの初期化15481809
Ref: library/sys_path_init doc15482006
Ref: 440315482006
Ref: library/sys_path_init sys-path-init15482006
Ref: 1bca15482006
Ref: library/sys_path_init the-initialization-of-the-sys-path-module-search-path15482006
Ref: 440415482006
Node: 仮想環境15485536
Ref: library/sys_path_init virtual-environments15485652
Ref: 440615485652
Node: _pth files15486231
Ref: library/sys_path_init pth-files15486378
Ref: 440715486378
Node: 埋め込みの Python15487706
Ref: library/sys_path_init embedded-python15487832
Ref: 440815487832
Node: Python言語サービス15488417
Ref: library/language doc15488589
Ref: 440915488589
Ref: library/language language15488589
Ref: 440a15488589
Ref: library/language python-language-services15488589
Ref: 440b15488589
Node: ast --- 抽象構文木15490267
Ref: library/ast doc15490421
Ref: 440c15490421
Ref: library/ast ast-abstract-syntax-trees15490421
Ref: 440d15490421
Ref: library/ast module-ast15490421
Ref: 715490421
Ref: ast --- 抽象構文木-Footnote-115491749
Node: 抽象文法 Abstract Grammar15491812
Ref: library/ast abstract-grammar15491924
Ref: 440f15491924
Ref: library/ast id115491924
Ref: 441015491924
Node: Node クラス15499373
Ref: library/ast node-classes15499510
Ref: 441115499510
Ref: library/ast ast AST15499556
Ref: 18b15499556
Ref: library/ast ast AST _fields15500637
Ref: 150a15500637
Ref: library/ast ast AST _field_types15501792
Ref: 18c15501792
Ref: library/ast ast AST lineno15502184
Ref: 441215502184
Ref: library/ast ast AST col_offset15502211
Ref: 441315502211
Ref: library/ast ast AST end_lineno15502242
Ref: 441415502242
Ref: library/ast ast AST end_col_offset15502273
Ref: 441515502273
Ref: Node クラス-Footnote-115506483
Node: Root nodes15506541
Ref: library/ast ast-root-nodes15506626
Ref: 441715506626
Ref: library/ast root-nodes15506626
Ref: 441815506626
Ref: library/ast ast Module15506667
Ref: 441915506667
Ref: library/ast ast Expression15507351
Ref: 441b15507351
Ref: library/ast ast Interactive15507733
Ref: 441d15507733
Ref: library/ast ast FunctionType15508462
Ref: 441e15508462
Ref: Root nodes-Footnote-115509510
Node: リテラル<3>15509552
Ref: library/ast literals15509652
Ref: 441f15509652
Ref: library/ast ast Constant15509693
Ref: 29915509693
Ref: library/ast ast FormattedValue15510265
Ref: 442015510265
Ref: library/ast ast JoinedStr15511328
Ref: 165015511328
Ref: library/ast ast List15512327
Ref: 442115512327
Ref: library/ast ast Tuple15512363
Ref: 442215512363
Ref: library/ast ast Set15513387
Ref: 442415513387
Ref: library/ast ast Dict15513832
Ref: 18c715513832
Node: 変数15514748
Ref: library/ast variables15514855
Ref: 442515514855
Ref: library/ast ast Name15514886
Ref: 18a915514886
Ref: library/ast ast Load15515072
Ref: 18915515072
Ref: library/ast ast Store15515096
Ref: 442315515096
Ref: library/ast ast Del15515121
Ref: 442615515121
Ref: library/ast ast Starred15516084
Ref: 442715516084
Node: 式 expression<2>15516976
Ref: library/ast ast-expressions15517082
Ref: 441c15517082
Ref: library/ast expressions15517082
Ref: 442915517082
Ref: library/ast ast Expr15517134
Ref: 442a15517134
Ref: library/ast ast UnaryOp15517909
Ref: 441615517909
Ref: library/ast ast UAdd15518088
Ref: 442e15518088
Ref: library/ast ast USub15518112
Ref: 442f15518112
Ref: library/ast ast Not15518136
Ref: 443015518136
Ref: library/ast ast Invert15518159
Ref: 443115518159
Ref: library/ast ast BinOp15518595
Ref: 193815518595
Ref: library/ast ast Add15519065
Ref: 443215519065
Ref: library/ast ast Sub15519088
Ref: 443315519088
Ref: library/ast ast Mult15519111
Ref: 443415519111
Ref: library/ast ast Div15519135
Ref: 443515519135
Ref: library/ast ast FloorDiv15519158
Ref: 443615519158
Ref: library/ast ast Mod15519186
Ref: 443715519186
Ref: library/ast ast Pow15519209
Ref: 443815519209
Ref: library/ast ast LShift15519232
Ref: 443915519232
Ref: library/ast ast RShift15519258
Ref: 443a15519258
Ref: library/ast ast BitOr15519284
Ref: 443b15519284
Ref: library/ast ast BitXor15519309
Ref: 443c15519309
Ref: library/ast ast BitAnd15519335
Ref: 443d15519335
Ref: library/ast ast MatMult15519361
Ref: 443e15519361
Ref: library/ast ast BoolOp15519444
Ref: 443f15519444
Ref: library/ast ast And15520219
Ref: 444115520219
Ref: library/ast ast Or15520242
Ref: 444015520242
Ref: library/ast ast Compare15520320
Ref: 444215520320
Ref: library/ast ast Eq15520953
Ref: 444315520953
Ref: library/ast ast NotEq15520975
Ref: 444415520975
Ref: library/ast ast Lt15521000
Ref: 444515521000
Ref: library/ast ast LtE15521022
Ref: 444615521022
Ref: library/ast ast Gt15521045
Ref: 444715521045
Ref: library/ast ast GtE15521067
Ref: 444815521067
Ref: library/ast ast Is15521090
Ref: 444915521090
Ref: library/ast ast IsNot15521112
Ref: 444a15521112
Ref: library/ast ast In15521137
Ref: 444b15521137
Ref: library/ast ast NotIn15521159
Ref: 444c15521159
Ref: library/ast ast Call15521240
Ref: 442815521240
Ref: library/ast ast keyword15522428
Ref: 444e15522428
Ref: library/ast ast IfExp15522703
Ref: 444f15522703
Ref: library/ast ast Attribute15523256
Ref: 444d15523256
Ref: library/ast ast NamedExpr15523944
Ref: 445015523944
Node: 配列要素の参照 Subscripting15524833
Ref: library/ast subscripting15524956
Ref: 445215524956
Ref: library/ast ast Subscript15525042
Ref: 445315525042
Ref: library/ast ast Slice15526124
Ref: 445415526124
Node: 内包表記 Comprehension15526809
Ref: library/ast comprehensions15526932
Ref: 445515526932
Ref: library/ast ast ListComp15527005
Ref: 445615527005
Ref: library/ast ast SetComp15527051
Ref: 445715527051
Ref: library/ast ast GeneratorExp15527096
Ref: 445815527096
Ref: library/ast ast DictComp15527146
Ref: 445915527146
Ref: library/ast ast comprehension15529118
Ref: 445a15529118
Node: 文 Statements15532297
Ref: library/ast ast-statements15532412
Ref: 441a15532412
Ref: library/ast statements15532412
Ref: 445b15532412
Ref: library/ast ast Assign15532464
Ref: 445115532464
Ref: library/ast ast Assign type_comment15532895
Ref: 445c15532895
Ref: library/ast ast AnnAssign15533873
Ref: 445d15533873
Ref: library/ast ast AugAssign15536134
Ref: 445e15536134
Ref: library/ast ast Raise15536955
Ref: 445f15536955
Ref: library/ast ast Assert15537581
Ref: 446015537581
Ref: library/ast ast Delete15538057
Ref: 446115538057
Ref: library/ast ast Pass15538583
Ref: 446215538583
Ref: library/ast ast TypeAlias15538779
Ref: 164715538779
Node: インポート15539508
Ref: library/ast imports15539574
Ref: 446415539574
Ref: library/ast ast Import15539622
Ref: 446515539622
Ref: library/ast ast ImportFrom15540058
Ref: 446615540058
Ref: library/ast ast alias15540912
Ref: 182915540912
Node: 制御フロー15541485
Ref: library/ast control-flow15541599
Ref: 446715541599
Ref: library/ast ast If15541790
Ref: 446815541790
Ref: library/ast ast For15543135
Ref: 446915543135
Ref: library/ast ast For type_comment15543677
Ref: 446a15543677
Ref: library/ast ast While15544439
Ref: 446b15544439
Ref: library/ast ast Break15545159
Ref: 446c15545159
Ref: library/ast ast Continue15545184
Ref: 446d15545184
Ref: library/ast ast Try15546201
Ref: 446e15546201
Ref: library/ast ast TryStar15547839
Ref: 447015547839
Ref: library/ast ast ExceptHandler15548849
Ref: 446f15548849
Ref: library/ast ast With15550177
Ref: 447115550177
Ref: library/ast ast With type_comment15550506
Ref: 447315550506
Ref: library/ast ast withitem15550678
Ref: 447215550678
Node: Pattern matching15552171
Ref: library/ast pattern-matching15552286
Ref: 447415552286
Ref: library/ast ast Match15552341
Ref: 447515552341
Ref: library/ast ast match_case15552654
Ref: 447615552654
Ref: library/ast ast MatchValue15554621
Ref: 447715554621
Ref: library/ast ast MatchSingleton15555595
Ref: 447815555595
Ref: library/ast ast MatchSequence15556455
Ref: 447915556455
Ref: library/ast ast MatchStar15557650
Ref: 447a15557650
Ref: library/ast ast MatchMapping15559263
Ref: 447b15559263
Ref: library/ast ast MatchClass15561233
Ref: 447c15561233
Ref: library/ast ast MatchAs15564172
Ref: 447d15564172
Ref: library/ast ast MatchOr15565790
Ref: 447e15565790
Node: Type parameters15567037
Ref: library/ast ast-type-params15567167
Ref: 446315567167
Ref: library/ast type-parameters15567167
Ref: 447f15567167
Ref: library/ast ast TypeVar15567300
Ref: 448015567300
Ref: library/ast ast ParamSpec15568502
Ref: 448115568502
Ref: library/ast ast TypeVarTuple15569888
Ref: 448215569888
Node: 関数およびクラス定義15571105
Ref: library/ast function-and-class-definitions15571234
Ref: 448315571234
Ref: library/ast ast FunctionDef15571307
Ref: 166d15571307
Ref: library/ast ast FunctionDef type_comment15572107
Ref: 448515572107
Ref: library/ast ast Lambda15572342
Ref: 442b15572342
Ref: library/ast ast arguments15572993
Ref: 448415572993
Ref: library/ast ast arg15573920
Ref: 448615573920
Ref: library/ast ast arg type_comment15574140
Ref: 448715574140
Ref: library/ast ast Return15575746
Ref: 448815575746
Ref: library/ast ast Yield15575991
Ref: 442c15575991
Ref: library/ast ast YieldFrom15576024
Ref: 442d15576024
Ref: library/ast ast Global15576695
Ref: 448915576695
Ref: library/ast ast Nonlocal15576729
Ref: 448a15576729
Ref: library/ast ast ClassDef15577403
Ref: 166b15577403
Ref: 関数およびクラス定義-Footnote-115579223
Node: async と await15579265
Ref: library/ast async-and-await15579370
Ref: 448b15579370
Ref: library/ast ast AsyncFunctionDef15579422
Ref: 166c15579422
Ref: library/ast ast Await15579750
Ref: 448c15579750
Ref: library/ast ast AsyncFor15580409
Ref: 448d15580409
Ref: library/ast ast AsyncWith15580480
Ref: 448e15580480
Node: ast ヘルパー15581419
Ref: library/ast ast-helpers15581551
Ref: 448f15581551
Ref: library/ast ast parse15581809
Ref: 18d15581809
Ref: library/ast ast unparse15585100
Ref: 8b315585100
Ref: library/ast ast literal_eval15585844
Ref: be615585844
Ref: library/ast ast get_docstring15587945
Ref: 19c515587945
Ref: library/ast ast get_source_segment15588594
Ref: 9a515588594
Ref: library/ast ast fix_missing_locations15589111
Ref: 449115589111
Ref: library/ast ast increment_lineno15589587
Ref: 170115589587
Ref: library/ast ast copy_location15589860
Ref: 449215589860
Ref: library/ast ast iter_fields15590120
Ref: 449315590120
Ref: library/ast ast iter_child_nodes15590317
Ref: 449415590317
Ref: library/ast ast walk15590625
Ref: 449515590625
Ref: library/ast ast NodeVisitor15590924
Ref: a3b15590924
Ref: library/ast ast NodeVisitor visit15591367
Ref: 449615591367
Ref: library/ast ast NodeVisitor generic_visit15591720
Ref: 449715591720
Ref: library/ast ast NodeVisitor visit_Constant15592203
Ref: a3c15592203
Ref: library/ast ast NodeTransformer15592870
Ref: 449815592870
Ref: library/ast ast dump15595000
Ref: 8b215595000
Ref: ast ヘルパー-Footnote-115597683
Ref: ast ヘルパー-Footnote-215597725
Ref: ast ヘルパー-Footnote-315597767
Node: コンパイラフラグ15597809
Ref: library/ast ast-compiler-flags15597966
Ref: 20c715597966
Ref: library/ast compiler-flags15597966
Ref: 449915597966
Ref: library/ast ast PyCF_ALLOW_TOP_LEVEL_AWAIT15598181
Ref: 449a15598181
Ref: library/ast ast PyCF_ONLY_AST15598405
Ref: 440e15598405
Ref: library/ast ast PyCF_OPTIMIZED_AST15598563
Ref: 449b15598563
Ref: library/ast ast PyCF_TYPE_COMMENTS15598761
Ref: 449015598761
Ref: コンパイラフラグ-Footnote-115599025
Ref: コンパイラフラグ-Footnote-215599067
Node: コマンドラインからの使用<4>15599109
Ref: library/ast ast-cli15599241
Ref: 449c15599241
Ref: library/ast command-line-usage15599241
Ref: 449d15599241
Ref: library/ast cmdoption-ast-h15599591
Ref: 449e15599591
Ref: library/ast cmdoption-ast-help15599591
Ref: 449f15599591
Ref: library/ast cmdoption-ast-m15599679
Ref: 44a015599679
Ref: library/ast cmdoption-ast-mode15599701
Ref: 44a115599701
Ref: library/ast cmdoption-ast-no-type-comments15599856
Ref: 44a215599856
Ref: library/ast cmdoption-ast-a15599937
Ref: 44a315599937
Ref: library/ast cmdoption-ast-include-attributes15599937
Ref: 44a415599937
Ref: library/ast cmdoption-ast-i15600045
Ref: 44a515600045
Ref: library/ast cmdoption-ast-indent15600069
Ref: 44a615600069
Ref: コマンドラインからの使用<4>-Footnote-115601351
Ref: コマンドラインからの使用<4>-Footnote-215601399
Ref: コマンドラインからの使用<4>-Footnote-315601466
Ref: コマンドラインからの使用<4>-Footnote-415601540
Ref: コマンドラインからの使用<4>-Footnote-515601579
Node: symtable --- コンパイラーの記号表へのアクセス15601616
Ref: library/symtable doc15601826
Ref: 44a715601826
Ref: library/symtable module-symtable15601826
Ref: c215601826
Ref: library/symtable symtable-access-to-the-compiler-s-symbol-tables15601826
Ref: 44a815601826
Ref: symtable --- コンパイラーの記号表へのアクセス-Footnote-115602559
Node: 記号表の生成15602627
Ref: library/symtable generating-symbol-tables15602770
Ref: 44a915602770
Ref: library/symtable symtable symtable15602821
Ref: 195815602821
Node: 記号表の検査15603169
Ref: library/symtable examining-symbol-tables15603360
Ref: 44ab15603360
Ref: library/symtable symtable SymbolTableType15603411
Ref: 157015603411
Ref: library/symtable symtable SymbolTableType MODULE15603536
Ref: 44ac15603536
Ref: library/symtable symtable SymbolTableType FUNCTION15603625
Ref: 44ad15603625
Ref: library/symtable symtable SymbolTableType CLASS15603720
Ref: 44ae15603720
Ref: library/symtable symtable SymbolTableType ANNOTATION15603899
Ref: 44af15603899
Ref: library/symtable symtable SymbolTableType TYPE_ALIAS15604043
Ref: 44b015604043
Ref: library/symtable symtable SymbolTableType TYPE_PARAMETERS15604162
Ref: 44b115604162
Ref: library/symtable symtable SymbolTableType TYPE_VARIABLE15604330
Ref: 44b215604330
Ref: library/symtable symtable SymbolTable15604699
Ref: 44aa15604699
Ref: library/symtable symtable SymbolTable get_type15604863
Ref: 157115604863
Ref: library/symtable symtable SymbolTable get_id15605549
Ref: 44b315605549
Ref: library/symtable symtable SymbolTable get_name15605634
Ref: 44b415605634
Ref: library/symtable symtable SymbolTable get_lineno15606284
Ref: 44b515606284
Ref: library/symtable symtable SymbolTable is_optimized15606418
Ref: 44b615606418
Ref: library/symtable symtable SymbolTable is_nested15606589
Ref: 44b715606589
Ref: library/symtable symtable SymbolTable has_children15606728
Ref: 44b815606728
Ref: library/symtable symtable SymbolTable get_identifiers15606975
Ref: 44ba15606975
Ref: library/symtable symtable SymbolTable lookup15607158
Ref: 44bb15607158
Ref: library/symtable symtable SymbolTable get_symbols15607332
Ref: 44bc15607332
Ref: library/symtable symtable SymbolTable get_children15607493
Ref: 44b915607493
Ref: library/symtable symtable Function15607605
Ref: 44bd15607605
Ref: library/symtable symtable Function get_parameters15607739
Ref: 44be15607739
Ref: library/symtable symtable Function get_locals15607856
Ref: 44bf15607856
Ref: library/symtable symtable Function get_globals15607987
Ref: 44c015607987
Ref: library/symtable symtable Function get_nonlocals15608122
Ref: 44c115608122
Ref: library/symtable symtable Function get_frees15608267
Ref: 44c215608267
Ref: library/symtable symtable Class15608416
Ref: 44c315608416
Ref: library/symtable symtable Class get_methods15608533
Ref: 2c615608533
Ref: library/symtable symtable Symbol15609769
Ref: 163415609769
Ref: library/symtable symtable Symbol get_name15609974
Ref: 44c415609974
Ref: library/symtable symtable Symbol is_referenced15610055
Ref: 44c515610055
Ref: library/symtable symtable Symbol is_imported15610195
Ref: 44c615610195
Ref: library/symtable symtable Symbol is_parameter15610326
Ref: 44c715610326
Ref: library/symtable symtable Symbol is_global15610441
Ref: 44c815610441
Ref: library/symtable symtable Symbol is_nonlocal15610553
Ref: 199615610553
Ref: library/symtable symtable Symbol is_declared_global15610667
Ref: 12f415610667
Ref: library/symtable symtable Symbol is_local15610851
Ref: 44c915610851
Ref: library/symtable symtable Symbol is_annotated15610989
Ref: 44ca15610989
Ref: library/symtable symtable Symbol is_free15611134
Ref: 44cb15611134
Ref: library/symtable symtable Symbol is_assigned15611324
Ref: 44cc15611324
Ref: library/symtable symtable Symbol is_namespace15611482
Ref: 44cd15611482
Ref: library/symtable symtable Symbol get_namespaces15612322
Ref: 44ce15612322
Ref: library/symtable symtable Symbol get_namespace15612448
Ref: 44cf15612448
Node: コマンドラインからの使用<5>15612712
Ref: library/symtable command-line-usage15612876
Ref: 44d015612876
Ref: library/symtable symtable-cli15612876
Ref: 44d115612876
Node: token --- Python 解析木で使われる定数15613254
Ref: library/token doc15613487
Ref: 44d215613487
Ref: library/token module-token15613487
Ref: e315613487
Ref: library/token token-constants-used-with-python-parse-trees15613487
Ref: 44d315613487
Ref: library/token token tok_name15614305
Ref: 44d415614305
Ref: library/token token ISTERMINAL15614538
Ref: 44d515614538
Ref: library/token token ISNONTERMINAL15614648
Ref: 44d615614648
Ref: library/token token ISEOF15614764
Ref: 44d715614764
Ref: library/token token ENDMARKER15614915
Ref: 44d815614915
Ref: library/token token NAME15614947
Ref: 44d915614947
Ref: library/token token NUMBER15614974
Ref: 44da15614974
Ref: library/token token STRING15615003
Ref: 44db15615003
Ref: library/token token NEWLINE15615032
Ref: 44dc15615032
Ref: library/token token INDENT15615062
Ref: 44dd15615062
Ref: library/token token DEDENT15615091
Ref: 44de15615091
Ref: library/token token LPAR15615120
Ref: 44df15615120
Ref: library/token token RPAR15615180
Ref: 44e015615180
Ref: library/token token LSQB15615240
Ref: 44e115615240
Ref: library/token token RSQB15615300
Ref: 44e215615300
Ref: library/token token COLON15615360
Ref: 44e315615360
Ref: library/token token COMMA15615421
Ref: 44e415615421
Ref: library/token token SEMI15615482
Ref: 44e515615482
Ref: library/token token PLUS15615542
Ref: 44e615615542
Ref: library/token token MINUS15615602
Ref: 44e715615602
Ref: library/token token STAR15615663
Ref: 44e815615663
Ref: library/token token SLASH15615723
Ref: 44e915615723
Ref: library/token token VBAR15615784
Ref: 44ea15615784
Ref: library/token token AMPER15615844
Ref: 44eb15615844
Ref: library/token token LESS15615905
Ref: 44ec15615905
Ref: library/token token GREATER15615965
Ref: 44ed15615965
Ref: library/token token EQUAL15616028
Ref: 44ee15616028
Ref: library/token token DOT15616089
Ref: 44ef15616089
Ref: library/token token PERCENT15616148
Ref: 44f015616148
Ref: library/token token LBRACE15616211
Ref: 44f115616211
Ref: library/token token RBRACE15616273
Ref: 44f215616273
Ref: library/token token EQEQUAL15616335
Ref: 44f315616335
Ref: library/token token NOTEQUAL15616399
Ref: 44f415616399
Ref: library/token token LESSEQUAL15616464
Ref: 44f515616464
Ref: library/token token GREATEREQUAL15616530
Ref: 44f615616530
Ref: library/token token TILDE15616599
Ref: 44f715616599
Ref: library/token token CIRCUMFLEX15616660
Ref: 44f815616660
Ref: library/token token LEFTSHIFT15616726
Ref: 44f915616726
Ref: library/token token RIGHTSHIFT15616792
Ref: 44fa15616792
Ref: library/token token DOUBLESTAR15616859
Ref: 44fb15616859
Ref: library/token token PLUSEQUAL15616926
Ref: 44fc15616926
Ref: library/token token MINEQUAL15616992
Ref: 44fd15616992
Ref: library/token token STAREQUAL15617057
Ref: 44fe15617057
Ref: library/token token SLASHEQUAL15617123
Ref: 44ff15617123
Ref: library/token token PERCENTEQUAL15617190
Ref: 450015617190
Ref: library/token token AMPEREQUAL15617259
Ref: 450115617259
Ref: library/token token VBAREQUAL15617326
Ref: 450215617326
Ref: library/token token CIRCUMFLEXEQUAL15617392
Ref: 450315617392
Ref: library/token token LEFTSHIFTEQUAL15617464
Ref: 450415617464
Ref: library/token token RIGHTSHIFTEQUAL15617536
Ref: 450515617536
Ref: library/token token DOUBLESTAREQUAL15617609
Ref: 450615617609
Ref: library/token token DOUBLESLASH15617682
Ref: 450715617682
Ref: library/token token DOUBLESLASHEQUAL15617750
Ref: 450815617750
Ref: library/token token AT15617824
Ref: 450915617824
Ref: library/token token ATEQUAL15617882
Ref: 450a15617882
Ref: library/token token RARROW15617946
Ref: 450b15617946
Ref: library/token token ELLIPSIS15618009
Ref: 450c15618009
Ref: library/token token COLONEQUAL15618075
Ref: 450d15618075
Ref: library/token token EXCLAMATION15618142
Ref: 450e15618142
Ref: library/token token OP15618209
Ref: 450f15618209
Ref: library/token token TYPE_IGNORE15618234
Ref: 451015618234
Ref: library/token token TYPE_COMMENT15618268
Ref: 451115618268
Ref: library/token token SOFT_KEYWORD15618303
Ref: 451215618303
Ref: library/token token FSTRING_START15618338
Ref: 451315618338
Ref: library/token token FSTRING_MIDDLE15618374
Ref: 451415618374
Ref: library/token token FSTRING_END15618411
Ref: 451515618411
Ref: library/token token COMMENT15618445
Ref: 451615618445
Ref: library/token token NL15618475
Ref: 451715618475
Ref: library/token token ERRORTOKEN15618500
Ref: 451815618500
Ref: library/token token N_TOKENS15618533
Ref: 451915618533
Ref: library/token token NT_OFFSET15618564
Ref: 451a15618564
Ref: library/token token ENCODING15619213
Ref: 451b15619213
Ref: token --- Python 解析木で使われる定数-Footnote-115620456
Node: keyword --- Python キーワードのテスト15620521
Ref: library/keyword doc15620749
Ref: 451c15620749
Ref: library/keyword keyword-testing-for-python-keywords15620749
Ref: 451d15620749
Ref: library/keyword module-keyword15620749
Ref: 7815620749
Ref: library/keyword keyword iskeyword15621161
Ref: 212615621161
Ref: library/keyword keyword kwlist15621302
Ref: 451e15621302
Ref: library/keyword keyword issoftkeyword15621584
Ref: 451f15621584
Ref: library/keyword keyword softkwlist15621765
Ref: 452015621765
Ref: keyword --- Python キーワードのテスト-Footnote-115622132
Node: tokenize --- Python ソース用のトークナイザー15622199
Ref: library/tokenize doc15622432
Ref: 452115622432
Ref: library/tokenize module-tokenize15622432
Ref: e415622432
Ref: library/tokenize tokenize-tokenizer-for-python-source15622432
Ref: 452215622432
Ref: tokenize --- Python ソース用のトークナイザー-Footnote-115624043
Node: 入力のトークナイズ15624111
Ref: library/tokenize tokenizing-input15624279
Ref: 452315624279
Ref: library/tokenize tokenize tokenize15624423
Ref: 4a615624423
Ref: library/tokenize tokenize generate_tokens15626215
Ref: 4a715626215
Ref: library/tokenize tokenize untokenize15627134
Ref: 152215627134
Ref: library/tokenize tokenize detect_encoding15628466
Ref: 27b815628466
Ref: library/tokenize tokenize open15629730
Ref: 27b715629730
Ref: library/tokenize tokenize TokenError15629969
Ref: 50d15629969
Ref: 入力のトークナイズ-Footnote-115630312
Ref: 入力のトークナイズ-Footnote-215630354
Node: コマンドラインからの使用<6>15630396
Ref: library/tokenize command-line-usage15630586
Ref: 452415630586
Ref: library/tokenize tokenize-cli15630586
Ref: 452515630586
Ref: library/tokenize cmdoption-tokenize-h15630959
Ref: 452615630959
Ref: library/tokenize cmdoption-tokenize-help15630959
Ref: 452715630959
Ref: library/tokenize cmdoption-tokenize-e15631050
Ref: 452815631050
Ref: library/tokenize cmdoption-tokenize-exact15631050
Ref: 452915631050
Node: 使用例<49>15631333
Ref: library/tokenize examples15631487
Ref: 452a15631487
Node: tabnanny --- あいまいなインデントの検出15636049
Ref: library/tabnanny doc15636296
Ref: 452b15636296
Ref: library/tabnanny module-tabnanny15636296
Ref: c715636296
Ref: library/tabnanny tabnanny-detection-of-ambiguous-indentation15636296
Ref: 452c15636296
Ref: library/tabnanny tabnanny check15636954
Ref: 452d15636954
Ref: library/tabnanny tabnanny verbose15637536
Ref: 452e15637536
Ref: library/tabnanny tabnanny filename_only15637768
Ref: 452f15637768
Ref: library/tabnanny tabnanny NannyNag15638063
Ref: 453015638063
Ref: library/tabnanny tabnanny process_tokens15638292
Ref: 453115638292
Ref: tabnanny --- あいまいなインデントの検出-Footnote-115638652
Node: pyclbr --- Python モジュールブラウザーサポート15638720
Ref: library/pyclbr doc15638978
Ref: 453215638978
Ref: library/pyclbr module-pyclbr15638978
Ref: a215638978
Ref: library/pyclbr pyclbr-python-module-browser-support15638978
Ref: 453315638978
Ref: library/pyclbr pyclbr readmodule15639709
Ref: 7f615639709
Ref: library/pyclbr pyclbr readmodule_ex15640321
Ref: 7f715640321
Ref: pyclbr --- Python モジュールブラウザーサポート-Footnote-115641439
Node: Function オブジェクト15641505
Ref: library/pyclbr function-objects15641668
Ref: 453415641668
Ref: library/pyclbr pyclbr-function-objects15641668
Ref: 453515641668
Ref: library/pyclbr pyclbr Function15641737
Ref: 453615641737
Ref: library/pyclbr pyclbr Function file15641894
Ref: 453715641894
Ref: library/pyclbr pyclbr Function module15641982
Ref: 453815641982
Ref: library/pyclbr pyclbr Function name15642077
Ref: 453915642077
Ref: library/pyclbr pyclbr Function lineno15642139
Ref: 453a15642139
Ref: library/pyclbr pyclbr Function parent15642235
Ref: 453b15642235
Ref: library/pyclbr pyclbr Function children15642389
Ref: 453c15642389
Ref: library/pyclbr pyclbr Function is_async15642561
Ref: 453d15642561
Node: クラスオブジェクト<2>15642746
Ref: library/pyclbr class-objects15642909
Ref: 453e15642909
Ref: library/pyclbr pyclbr-class-objects15642909
Ref: 453f15642909
Ref: library/pyclbr pyclbr Class15642975
Ref: 454015642975
Ref: library/pyclbr pyclbr Class file15643165
Ref: 454115643165
Ref: library/pyclbr pyclbr Class module15643250
Ref: 454215643250
Ref: library/pyclbr pyclbr Class name15643342
Ref: 454315643342
Ref: library/pyclbr pyclbr Class lineno15643407
Ref: 454415643407
Ref: library/pyclbr pyclbr Class parent15643503
Ref: 454515643503
Ref: library/pyclbr pyclbr Class children15643653
Ref: 454615643653
Ref: library/pyclbr pyclbr Class super15643813
Ref: 454715643813
Ref: library/pyclbr pyclbr Class methods15644174
Ref: 454815644174
Node: py_compile --- Python ソースファイルをコンパイルする15644402
Ref: library/py_compile doc15644678
Ref: 454915644678
Ref: library/py_compile module-py_compile15644678
Ref: a115644678
Ref: library/py_compile py-compile-compile-python-source-files15644678
Ref: 454a15644678
Ref: library/py_compile py_compile PyCompileError15645548
Ref: 454b15645548
Ref: library/py_compile py_compile compile15645681
Ref: 9f315645681
Ref: library/py_compile py_compile PycInvalidationMode15650054
Ref: 454c15650054
Ref: library/py_compile py_compile PycInvalidationMode TIMESTAMP15650508
Ref: 454e15650508
Ref: library/py_compile py_compile PycInvalidationMode CHECKED_HASH15650790
Ref: 454d15650790
Ref: library/py_compile py_compile PycInvalidationMode UNCHECKED_HASH15651036
Ref: 454f15651036
Ref: py_compile --- Python ソースファイルをコンパイルする-Footnote-115651631
Ref: py_compile --- Python ソースファイルをコンパイルする-Footnote-215651701
Ref: py_compile --- Python ソースファイルをコンパイルする-Footnote-315651743
Ref: py_compile --- Python ソースファイルをコンパイルする-Footnote-415651785
Ref: py_compile --- Python ソースファイルをコンパイルする-Footnote-515651827
Node: コマンドラインインターフェイス<11>15651869
Ref: library/py_compile command-line-interface15652022
Ref: 455015652022
Ref: library/py_compile py-compile-cli15652022
Ref: 455115652022
Ref: library/py_compile cmdoption-python-m-py_compile-arg-file15652482
Ref: 455215652482
Ref: library/py_compile cmdoption-python-m-py_compile15652513
Ref: 455315652513
Ref: library/py_compile cmdoption-python-m-py_compile-q15652665
Ref: 455415652665
Ref: library/py_compile cmdoption-python-m-py_compile-quiet15652665
Ref: 455515652665
Node: compileall --- Python ライブラリをバイトコンパイルする15653070
Ref: library/compileall doc15653343
Ref: 455615653343
Ref: library/compileall compileall-byte-compile-python-libraries15653343
Ref: 455715653343
Ref: library/compileall module-compileall15653343
Ref: 1915653343
Ref: compileall --- Python ライブラリをバイトコンパイルする-Footnote-115654517
Node: コマンドラインでの使用<2>15654587
Ref: library/compileall command-line-use15654763
Ref: 455815654763
Ref: library/compileall compileall-cli15654763
Ref: 455915654763
Ref: library/compileall cmdoption-compileall-arg-directory15654994
Ref: 455a15654994
Ref: library/compileall cmdoption-compileall-arg-file15655020
Ref: 455b15655020
Ref: library/compileall cmdoption-compileall-l15655341
Ref: 455c15655341
Ref: library/compileall cmdoption-compileall-f15655553
Ref: 455d15655553
Ref: library/compileall cmdoption-compileall-q15655654
Ref: 455e15655654
Ref: library/compileall cmdoption-compileall-d15655908
Ref: 455f15655908
Ref: library/compileall cmdoption-compileall-s15656383
Ref: 456015656383
Ref: library/compileall cmdoption-compileall-p15656412
Ref: 456115656412
Ref: library/compileall cmdoption-compileall-x15656588
Ref: 456215656588
Ref: library/compileall cmdoption-compileall-i15656782
Ref: 456315656782
Ref: library/compileall cmdoption-compileall-b15657067
Ref: 456415657067
Ref: library/compileall cmdoption-compileall-r15657467
Ref: 456515657467
Ref: library/compileall cmdoption-compileall-j15657779
Ref: 456615657779
Ref: library/compileall cmdoption-compileall-invalidation-mode15657966
Ref: 456715657966
Ref: library/compileall cmdoption-compileall-o15659058
Ref: 456815659058
Ref: library/compileall cmdoption-compileall-e15659251
Ref: 456915659251
Ref: library/compileall cmdoption-compileall-hardlink-dupes15659331
Ref: 456a15659331
Ref: コマンドラインでの使用<2>-Footnote-115660817
Node: パブリックな関数15660859
Ref: library/compileall public-functions15661035
Ref: 456b15661035
Ref: library/compileall compileall compile_dir15661096
Ref: af415661096
Ref: library/compileall compileall compile_file15665933
Ref: dae15665933
Ref: library/compileall compileall compile_path15669430
Ref: daf15669430
Ref: パブリックな関数-Footnote-115671556
Ref: パブリックな関数-Footnote-215671598
Node: dis --- Python バイトコードの逆アセンブラー15671640
Ref: library/dis doc15671896
Ref: 456c15671896
Ref: library/dis dis-disassembler-for-python-bytecode15671896
Ref: 456d15671896
Ref: library/dis module-dis15671896
Ref: 3015671896
Ref: dis --- Python バイトコードの逆アセンブラー-Footnote-115675075
Node: コマンドライン・インターフェース<2>15675138
Ref: library/dis command-line-interface15675316
Ref: 456e15675316
Ref: library/dis dis-cli15675316
Ref: 456f15675316
Ref: library/dis cmdoption-dis-h15675588
Ref: 457015675588
Ref: library/dis cmdoption-dis-help15675588
Ref: 457115675588
Ref: library/dis cmdoption-dis-C15675685
Ref: 457215675685
Ref: library/dis cmdoption-dis-show-caches15675685
Ref: 457315675685
Ref: library/dis cmdoption-dis-O15675766
Ref: 1bc15675766
Ref: library/dis cmdoption-dis-show-offsets15675766
Ref: 457415675766
Node: バイトコード解析15676020
Ref: library/dis bytecode-analysis15676219
Ref: 457515676219
Ref: library/dis dis Bytecode15676535
Ref: efa15676535
Ref: library/dis dis Bytecode from_traceback15678427
Ref: efc15678427
Ref: library/dis dis Bytecode codeobj15678729
Ref: 457615678729
Ref: library/dis dis Bytecode first_line15678824
Ref: 457715678824
Ref: library/dis dis Bytecode dis15678949
Ref: efb15678949
Ref: library/dis dis Bytecode info15679171
Ref: 457815679171
Node: 解析関数15679758
Ref: library/dis analysis-functions15679937
Ref: 457915679937
Ref: library/dis dis code_info15680269
Ref: 120a15680269
Ref: library/dis dis show_code15680894
Ref: ef815680894
Ref: library/dis dis dis15681497
Ref: b0215681497
Ref: library/dis dis disassemble15684237
Ref: ef915684237
Ref: library/dis dis get_instructions15685624
Ref: 1bd15685624
Ref: library/dis dis findlinestarts15686926
Ref: 457a15686926
Ref: library/dis dis findlabels15687655
Ref: 457b15687655
Ref: library/dis dis stack_effect15687826
Ref: efd15687826
Ref: 解析関数-Footnote-115688783
Node: Python バイトコード命令15688825
Ref: library/dis bytecodes15689013
Ref: 57c15689013
Ref: library/dis python-bytecode-instructions15689013
Ref: 457c15689013
Ref: library/dis dis Instruction15689272
Ref: 1be15689272
Ref: library/dis dis Instruction opcode15689344
Ref: 457d15689344
Ref: library/dis dis Instruction opname15689554
Ref: 457f15689554
Ref: library/dis dis Instruction baseopcode15689627
Ref: 458015689627
Ref: library/dis dis Instruction baseopname15689784
Ref: 458115689784
Ref: library/dis dis Instruction arg15689948
Ref: 458315689948
Ref: library/dis dis Instruction oparg15690050
Ref: 458415690050
Ref: library/dis dis Instruction argval15690115
Ref: 458515690115
Ref: library/dis dis Instruction argrepr15690204
Ref: 458615690204
Ref: library/dis dis Instruction offset15690340
Ref: 458715690340
Ref: library/dis dis Instruction start_offset15690434
Ref: 458815690434
Ref: library/dis dis Instruction cache_offset15690650
Ref: 458915690650
Ref: library/dis dis Instruction end_offset15690752
Ref: 458a15690752
Ref: library/dis dis Instruction starts_line15690850
Ref: 458b15690850
Ref: library/dis dis Instruction line_number15690964
Ref: 458c15690964
Ref: library/dis dis Instruction is_jump_target15691096
Ref: 458d15691096
Ref: library/dis dis Instruction jump_target15691263
Ref: 458e15691263
Ref: library/dis dis Instruction positions15691401
Ref: 458f15691401
Ref: library/dis dis Positions15691925
Ref: 431315691925
Ref: library/dis dis Positions lineno15692041
Ref: 459015692041
Ref: library/dis dis Positions end_lineno15692069
Ref: 459115692069
Ref: library/dis dis Positions col_offset15692101
Ref: 459215692101
Ref: library/dis dis Positions end_col_offset15692133
Ref: 459315692133
Ref: library/dis opcode-NOP15692507
Ref: 459415692507
Ref: library/dis opcode-POP_TOP15692639
Ref: 459515692639
Ref: library/dis opcode-END_FOR15692720
Ref: 459615692720
Ref: library/dis opcode-END_SEND15692897
Ref: 459715692897
Ref: library/dis opcode-COPY15693033
Ref: 6d415693033
Ref: library/dis opcode-SWAP15693244
Ref: 6d515693244
Ref: library/dis opcode-CACHE15693405
Ref: 6c415693405
Ref: library/dis opcode-UNARY_NEGATIVE15694283
Ref: 459815694283
Ref: library/dis opcode-UNARY_NOT15694358
Ref: 165515694358
Ref: library/dis opcode-UNARY_INVERT15694539
Ref: 459915694539
Ref: library/dis opcode-GET_ITER15694612
Ref: 459a15694612
Ref: library/dis opcode-GET_YIELD_FROM_ITER15694686
Ref: 459b15694686
Ref: library/dis opcode-TO_BOOL15694926
Ref: 165215694926
Ref: library/dis opcode-BINARY_OP15695443
Ref: 6d115695443
Ref: library/dis opcode-BINARY_SUBSCR15695682
Ref: 16a815695682
Ref: library/dis opcode-STORE_SUBSCR15695829
Ref: 178615695829
Ref: library/dis opcode-DELETE_SUBSCR15695999
Ref: 459c15695999
Ref: library/dis opcode-BINARY_SLICE15696136
Ref: 4ac15696136
Ref: library/dis opcode-STORE_SLICE15696347
Ref: 4ad15696347
Ref: library/dis opcode-GET_AWAITABLE15696616
Ref: 17a115696616
Ref: library/dis opcode-GET_AITER15697249
Ref: 459d15697249
Ref: library/dis opcode-GET_ANEXT15697473
Ref: 459e15697473
Ref: library/dis opcode-END_ASYNC_FOR15697680
Ref: a7815697680
Ref: library/dis opcode-CLEANUP_THROW15698172
Ref: 4b015698172
Ref: library/dis opcode-BEFORE_ASYNC_WITH15698534
Ref: 459f15698534
Ref: library/dis opcode-SET_ADD15698824
Ref: 45a015698824
Ref: library/dis opcode-LIST_APPEND15698976
Ref: 45a115698976
Ref: library/dis opcode-MAP_ADD15699137
Ref: a7a15699137
Ref: library/dis opcode-RETURN_VALUE15699796
Ref: 171215699796
Ref: library/dis opcode-RETURN_CONST15699888
Ref: 4b615699888
Ref: library/dis opcode-YIELD_VALUE15700026
Ref: 2ec15700026
Ref: library/dis opcode-SETUP_ANNOTATIONS15700443
Ref: d2215700443
Ref: library/dis opcode-POP_EXCEPT15700743
Ref: 45a215700743
Ref: library/dis opcode-RERAISE15700972
Ref: 45a315700972
Ref: library/dis opcode-PUSH_EXC_INFO15701337
Ref: 6ce15701337
Ref: library/dis opcode-CHECK_EXC_MATCH15701577
Ref: 6d615701577
Ref: library/dis opcode-CHECK_EG_MATCH15701839
Ref: 6cd15701839
Ref: library/dis opcode-WITH_EXCEPT_START15702296
Ref: 45a415702296
Ref: library/dis opcode-LOAD_ASSERTION_ERROR15702839
Ref: 93515702839
Ref: library/dis opcode-LOAD_BUILD_CLASS15703005
Ref: 45a515703005
Ref: library/dis opcode-BEFORE_WITH15703144
Ref: 6d815703144
Ref: library/dis opcode-GET_LEN15703567
Ref: 45a615703567
Ref: library/dis opcode-MATCH_MAPPING15703764
Ref: 45a715703764
Ref: library/dis opcode-MATCH_SEQUENCE15704085
Ref: 45a815704085
Ref: library/dis opcode-MATCH_KEYS15704499
Ref: 6de15704499
Ref: library/dis opcode-STORE_NAME15704973
Ref: 45a915704973
Ref: library/dis opcode-DELETE_NAME15705257
Ref: 45ab15705257
Ref: library/dis opcode-UNPACK_SEQUENCE15705423
Ref: 17a315705423
Ref: library/dis opcode-UNPACK_EX15705715
Ref: 45ac15705715
Ref: library/dis opcode-STORE_ATTR15706674
Ref: 17a215706674
Ref: library/dis opcode-DELETE_ATTR15706912
Ref: 45ad15706912
Ref: library/dis opcode-STORE_GLOBAL15707119
Ref: 45aa15707119
Ref: library/dis opcode-DELETE_GLOBAL15707280
Ref: 45ae15707280
Ref: library/dis opcode-LOAD_CONST15707436
Ref: 45af15707436
Ref: library/dis opcode-LOAD_NAME15707542
Ref: 45b015707542
Ref: library/dis opcode-LOAD_LOCALS15707738
Ref: 4b515707738
Ref: library/dis opcode-LOAD_FROM_DICT_OR_GLOBALS15708003
Ref: 4b415708003
Ref: library/dis opcode-BUILD_TUPLE15708396
Ref: 45b115708396
Ref: library/dis opcode-BUILD_LIST15708722
Ref: 45b215708722
Ref: library/dis opcode-BUILD_SET15708879
Ref: 45b315708879
Ref: library/dis opcode-BUILD_MAP15709031
Ref: 164815709031
Ref: library/dis opcode-BUILD_CONST_KEY_MAP15709419
Ref: d1f15709419
Ref: library/dis opcode-BUILD_STRING15709741
Ref: d1e15709741
Ref: library/dis opcode-LIST_EXTEND15709906
Ref: 45b415709906
Ref: library/dis opcode-SET_UPDATE15710075
Ref: 45b515710075
Ref: library/dis opcode-DICT_UPDATE15710241
Ref: 45b615710241
Ref: library/dis opcode-DICT_MERGE15710410
Ref: 45b715710410
Ref: library/dis opcode-LOAD_ATTR15710551
Ref: 4ab15710551
Ref: library/dis opcode-LOAD_SUPER_ATTR15711495
Ref: 4a915711495
Ref: library/dis opcode-COMPARE_OP15712566
Ref: 93715712566
Ref: library/dis opcode-IS_OP15712952
Ref: 45b815712952
Ref: library/dis opcode-CONTAINS_OP15713082
Ref: 45b915713082
Ref: library/dis opcode-IMPORT_NAME15713218
Ref: 45ba15713218
Ref: library/dis opcode-IMPORT_FROM15713638
Ref: 45bb15713638
Ref: library/dis opcode-JUMP_FORWARD15713887
Ref: 154315713887
Ref: library/dis opcode-JUMP_BACKWARD15713997
Ref: 6d715713997
Ref: library/dis opcode-JUMP_BACKWARD_NO_INTERRUPT15714131
Ref: 6ca15714131
Ref: library/dis opcode-POP_JUMP_IF_TRUE15714291
Ref: 165315714291
Ref: library/dis opcode-POP_JUMP_IF_FALSE15714854
Ref: 165415714854
Ref: library/dis opcode-POP_JUMP_IF_NOT_NONE15715420
Ref: 176215715420
Ref: library/dis opcode-POP_JUMP_IF_NONE15715810
Ref: 176115715810
Ref: library/dis opcode-FOR_ITER15716192
Ref: 16bc15716192
Ref: library/dis opcode-LOAD_GLOBAL15716612
Ref: 164f15716612
Ref: library/dis opcode-LOAD_FAST15716908
Ref: 45bc15716908
Ref: library/dis opcode-LOAD_FAST_CHECK15717248
Ref: 4b215717248
Ref: library/dis opcode-LOAD_FAST_AND_CLEAR15717497
Ref: 4b115717497
Ref: library/dis opcode-STORE_FAST15717795
Ref: 165615717795
Ref: library/dis opcode-DELETE_FAST15717903
Ref: 45bd15717903
Ref: library/dis opcode-MAKE_CELL15718009
Ref: 6cb15718009
Ref: library/dis opcode-LOAD_DEREF15718183
Ref: 45be15718183
Ref: library/dis opcode-LOAD_FROM_DICT_OR_DEREF15718471
Ref: 4b315718471
Ref: library/dis opcode-STORE_DEREF15718998
Ref: 45bf15718998
Ref: library/dis opcode-DELETE_DEREF15719246
Ref: 45c015719246
Ref: library/dis opcode-COPY_FREE_VARS15719542
Ref: 6c915719542
Ref: library/dis opcode-RAISE_VARARGS15719788
Ref: 45c115719788
Ref: library/dis opcode-CALL15720257
Ref: 6d215720257
Ref: library/dis opcode-CALL_KW15721043
Ref: 164915721043
Ref: library/dis opcode-CALL_FUNCTION_EX15721875
Ref: d2115721875
Ref: library/dis opcode-PUSH_NULL15722553
Ref: 6d315722553
Ref: library/dis opcode-MAKE_FUNCTION15722757
Ref: d2015722757
Ref: library/dis opcode-SET_FUNCTION_ATTRIBUTE15723255
Ref: 45c215723255
Ref: library/dis opcode-BUILD_SLICE15723966
Ref: 45c315723966
Ref: library/dis opcode-EXTENDED_ARG15724435
Ref: 171015724435
Ref: library/dis opcode-CONVERT_VALUE15724772
Ref: 45c415724772
Ref: library/dis opcode-FORMAT_SIMPLE15725248
Ref: 45c515725248
Ref: library/dis opcode-FORMAT_WITH_SPEC15725514
Ref: 45c615725514
Ref: library/dis opcode-MATCH_CLASS15725831
Ref: 6dd15725831
Ref: library/dis opcode-RESUME15726555
Ref: 2ed15726555
Ref: library/dis opcode-RETURN_GENERATOR15727300
Ref: 6c715727300
Ref: library/dis opcode-SEND15727594
Ref: 6c815727594
Ref: library/dis opcode-HAVE_ARGUMENT15727959
Ref: 45615727959
Ref: library/dis opcode-CALL_INTRINSIC_115728836
Ref: 4ae15728836
Ref: library/dis opcode-CALL_INTRINSIC_215732159
Ref: 4af15732159
Ref: library/dis opcode-SETUP_FINALLY15734197
Ref: 45c715734197
Ref: library/dis opcode-SETUP_CLEANUP15734461
Ref: 45c815734461
Ref: library/dis opcode-SETUP_WITH15734866
Ref: 45c915734866
Ref: library/dis opcode-POP_BLOCK15735296
Ref: 45ca15735296
Ref: library/dis opcode-JUMP15735449
Ref: 45cb15735449
Ref: library/dis opcode-JUMP_NO_INTERRUPT15735467
Ref: 178415735467
Ref: library/dis opcode-LOAD_CLOSURE15735634
Ref: 165115735634
Ref: library/dis opcode-LOAD_METHOD15735932
Ref: bed15735932
Node: 命令コードコレクション15736066
Ref: library/dis id115736233
Ref: 45cc15736233
Ref: library/dis opcode-collections15736233
Ref: 457e15736233
Ref: library/dis dis opname15736648
Ref: 458215736648
Ref: library/dis dis opmap15736794
Ref: 45cd15736794
Ref: library/dis dis cmp_op15736893
Ref: 45ce15736893
Ref: library/dis dis hasarg15736975
Ref: 27e15736975
Ref: library/dis dis hasconst15737084
Ref: 45cf15737084
Ref: library/dis dis hasfree15737180
Ref: 45d015737180
Ref: library/dis dis hasname15737529
Ref: 45d115737529
Ref: library/dis dis hasjump15737642
Ref: 45d215737642
Ref: library/dis dis haslocal15737782
Ref: 45d315737782
Ref: library/dis dis hascompare15737890
Ref: 45d415737890
Ref: library/dis dis hasexc15737979
Ref: 45715737979
Ref: library/dis dis hasjrel15738094
Ref: 45d515738094
Ref: library/dis dis hasjabs15738292
Ref: 45d615738292
Node: pickletools --- pickle 開発者用のツール群15738485
Ref: library/pickletools doc15738662
Ref: 45d715738662
Ref: library/pickletools module-pickletools15738662
Ref: 9615738662
Ref: library/pickletools pickletools-tools-for-pickle-developers15738662
Ref: 45d815738662
Ref: pickletools --- pickle 開発者用のツール群-Footnote-115739657
Node: コマンドラインの使い方<2>15739728
Ref: library/pickletools command-line-usage15739908
Ref: 45d915739908
Ref: library/pickletools pickletools-cli15739908
Ref: 45da15739908
Node: コマンドラインオプション<6>15741143
Ref: library/pickletools command-line-options15741255
Ref: 45db15741255
Ref: library/pickletools cmdoption-pickletools-a15741338
Ref: 45dc15741338
Ref: library/pickletools cmdoption-pickletools-annotate15741338
Ref: 45dd15741338
Ref: library/pickletools cmdoption-pickletools-o15741448
Ref: 45de15741448
Ref: library/pickletools cmdoption-pickletools-output15741448
Ref: 45df15741448
Ref: library/pickletools cmdoption-pickletools-l15741533
Ref: 45e015741533
Ref: library/pickletools cmdoption-pickletools-indentlevel15741533
Ref: 45e115741533
Ref: library/pickletools cmdoption-pickletools-m15741649
Ref: 45e215741649
Ref: library/pickletools cmdoption-pickletools-memo15741649
Ref: 45e315741649
Ref: library/pickletools cmdoption-pickletools-p15741803
Ref: 45e415741803
Ref: library/pickletools cmdoption-pickletools-preamble15741803
Ref: 45e515741803
Node: プログラミングインターフェース<2>15741995
Ref: library/pickletools programmatic-interface15742175
Ref: 45e615742175
Ref: library/pickletools pickletools dis15742273
Ref: c9115742273
Ref: library/pickletools pickletools genops15743323
Ref: 45e715743323
Ref: library/pickletools pickletools optimize15743920
Ref: 27ed15743920
Node: MS Windows 固有のサービス15744309
Ref: library/windows doc15744474
Ref: 45e815744474
Ref: library/windows ms-windows-specific-services15744474
Ref: 45e915744474
Ref: library/windows mswin-specific-services15744474
Ref: 1d9c15744474
Node: msvcrt --- MS VC++ ランタイムの有用なルーチン群15745043
Ref: library/msvcrt doc15745234
Ref: 45ea15745234
Ref: library/msvcrt module-msvcrt15745234
Ref: 8515745234
Ref: library/msvcrt msvcrt-useful-routines-from-the-ms-vc-runtime15745234
Ref: 45eb15745234
Node: ファイル操作関連15746679
Ref: library/msvcrt file-operations15746836
Ref: 45ec15746836
Ref: library/msvcrt msvcrt-files15746836
Ref: 45ed15746836
Ref: library/msvcrt msvcrt locking15746897
Ref: 406615746897
Ref: library/msvcrt msvcrt LK_LOCK15747585
Ref: 45ee15747585
Ref: library/msvcrt msvcrt LK_RLCK15747615
Ref: 45ef15747615
Ref: library/msvcrt msvcrt LK_NBLCK15747861
Ref: 45f015747861
Ref: library/msvcrt msvcrt LK_NBRLCK15747892
Ref: 45f115747892
Ref: library/msvcrt msvcrt LK_UNLCK15748091
Ref: 45f215748091
Ref: library/msvcrt msvcrt setmode15748277
Ref: 45f315748277
Ref: library/msvcrt msvcrt open_osfhandle15748604
Ref: 406715748604
Ref: library/msvcrt msvcrt get_osfhandle15749280
Ref: 406515749280
Node: コンソール I/O 関連15749565
Ref: library/msvcrt console-i-o15749749
Ref: 45f415749749
Ref: library/msvcrt msvcrt-console15749749
Ref: 45f515749749
Ref: library/msvcrt msvcrt kbhit15749815
Ref: 45f615749815
Ref: library/msvcrt msvcrt getch15749940
Ref: 45f715749940
Ref: library/msvcrt msvcrt getwch15750422
Ref: 139d15750422
Ref: library/msvcrt msvcrt getche15750542
Ref: 45f815750542
Ref: library/msvcrt msvcrt getwche15750690
Ref: 139e15750690
Ref: library/msvcrt msvcrt putch15750812
Ref: 45f915750812
Ref: library/msvcrt msvcrt putwch15750965
Ref: 139f15750965
Ref: library/msvcrt msvcrt ungetch15751112
Ref: 45fa15751112
Ref: library/msvcrt msvcrt ungetwch15751407
Ref: 45fb15751407
Node: その多の関数15751558
Ref: library/msvcrt msvcrt-other15751709
Ref: 45fc15751709
Ref: library/msvcrt other-functions15751709
Ref: 45fd15751709
Ref: library/msvcrt msvcrt heapmin15751760
Ref: 45fe15751760
Ref: library/msvcrt msvcrt set_error_mode15751954
Ref: 45ff15751954
Ref: library/msvcrt msvcrt OUT_TO_DEFAULT15752327
Ref: 460115752327
Ref: library/msvcrt msvcrt OUT_TO_STDERR15752473
Ref: 460215752473
Ref: library/msvcrt msvcrt OUT_TO_MSGBOX15752606
Ref: 460315752606
Ref: library/msvcrt msvcrt REPORT_ERRMODE15752736
Ref: 460015752736
Ref: library/msvcrt msvcrt CrtSetReportMode15752875
Ref: 460415752875
Ref: library/msvcrt msvcrt CrtSetReportFile15753264
Ref: 460515753264
Ref: library/msvcrt msvcrt CRT_WARN15753662
Ref: 460715753662
Ref: library/msvcrt msvcrt CRT_ERROR15753780
Ref: 460815753780
Ref: library/msvcrt msvcrt CRT_ASSERT15753901
Ref: 460915753901
Ref: library/msvcrt msvcrt CRTDBG_MODE_DEBUG15753961
Ref: 460a15753961
Ref: library/msvcrt msvcrt CRTDBG_MODE_FILE15754060
Ref: 460615754060
Ref: library/msvcrt msvcrt CRTDBG_MODE_WNDW15754282
Ref: 460b15754282
Ref: library/msvcrt msvcrt CRTDBG_REPORT_MODE15754445
Ref: 460c15754445
Ref: library/msvcrt msvcrt CRT_ASSEMBLY_VERSION15754542
Ref: 132715754542
Ref: library/msvcrt msvcrt VC_ASSEMBLY_PUBLICKEYTOKEN15754657
Ref: 132815754657
Ref: library/msvcrt msvcrt LIBRARIES_ASSEMBLY_NAME_PREFIX15754791
Ref: 132915754791
Node: winreg --- Windows レジストリへのアクセス15754931
Ref: library/winreg doc15755194
Ref: 460d15755194
Ref: library/winreg module-winreg15755194
Ref: fe15755194
Ref: library/winreg winreg-windows-registry-access15755194
Ref: 460e15755194
Ref: library/winreg exception-changed15755781
Ref: 461015755781
Node: 関数<13>15756091
Ref: library/winreg functions15756209
Ref: 461115756209
Ref: library/winreg id115756209
Ref: 461215756209
Ref: library/winreg winreg CloseKey15756303
Ref: 461315756303
Ref: library/winreg winreg ConnectRegistry15756733
Ref: 406a15756733
Ref: library/winreg winreg CreateKey15757634
Ref: 406b15757634
Ref: library/winreg winreg CreateKeyEx15758854
Ref: 132a15758854
Ref: library/winreg winreg DeleteKey15760585
Ref: 406c15760585
Ref: library/winreg winreg DeleteKeyEx15761586
Ref: 132b15761586
Ref: library/winreg winreg DeleteValue15763287
Ref: 406d15763287
Ref: library/winreg winreg EnumKey15763756
Ref: 406e15763756
Ref: library/winreg winreg EnumValue15764579
Ref: 406f15764579
Ref: library/winreg winreg ExpandEnvironmentStrings15766087
Ref: 13a015766087
Ref: library/winreg winreg FlushKey15766485
Ref: 461a15766485
Ref: library/winreg winreg LoadKey15767579
Ref: 407015767579
Ref: library/winreg winreg OpenKey15769043
Ref: 407115769043
Ref: library/winreg winreg OpenKeyEx15769117
Ref: 461d15769117
Ref: library/winreg winreg QueryInfoKey15770539
Ref: 407315770539
Ref: library/winreg winreg QueryValue15771526
Ref: 407415771526
Ref: library/winreg winreg QueryValueEx15772653
Ref: 407515772653
Ref: library/winreg winreg SaveKey15773712
Ref: 407615773712
Ref: library/winreg winreg SetValue15774934
Ref: 407715774934
Ref: library/winreg winreg SetValueEx15776395
Ref: 16f915776395
Ref: library/winreg winreg DisableReflectionKey15777987
Ref: 132c15777987
Ref: library/winreg winreg EnableReflectionKey15778816
Ref: 132d15778816
Ref: library/winreg winreg QueryReflectionKey15779477
Ref: 132e15779477
Ref: 関数<13>-Footnote-115780087
Ref: 関数<13>-Footnote-215780164
Node: 定数<11>15780241
Ref: library/winreg constants15780413
Ref: 462215780413
Ref: library/winreg id215780413
Ref: 462315780413
Node: HKEY_* 定数15780591
Ref: library/winreg hkey-constants15780678
Ref: 461515780678
Ref: library/winreg id315780678
Ref: 462415780678
Ref: library/winreg winreg HKEY_CLASSES_ROOT15780723
Ref: 462515780723
Ref: library/winreg winreg HKEY_CURRENT_USER15781045
Ref: 462615781045
Ref: library/winreg winreg HKEY_LOCAL_MACHINE15781417
Ref: 461c15781417
Ref: library/winreg winreg HKEY_USERS15781742
Ref: 461b15781742
Ref: library/winreg winreg HKEY_PERFORMANCE_DATA15781996
Ref: 462715781996
Ref: library/winreg winreg HKEY_CURRENT_CONFIG15782354
Ref: 462815782354
Ref: library/winreg winreg HKEY_DYN_DATA15782536
Ref: 462915782536
Node: アクセス権限15782671
Ref: library/winreg access-rights15782776
Ref: 461715782776
Ref: library/winreg id415782776
Ref: 462a15782776
Ref: library/winreg winreg KEY_ALL_ACCESS15782936
Ref: 462b15782936
Ref: library/winreg winreg KEY_WRITE15783239
Ref: 461615783239
Ref: library/winreg winreg KEY_READ15783406
Ref: 461e15783406
Ref: library/winreg winreg KEY_EXECUTE15783607
Ref: 463115783607
Ref: library/winreg winreg KEY_QUERY_VALUE15783683
Ref: 462c15783683
Ref: library/winreg winreg KEY_SET_VALUE15783792
Ref: 462015783792
Ref: library/winreg winreg KEY_CREATE_SUB_KEY15783905
Ref: 462d15783905
Ref: library/winreg winreg KEY_ENUMERATE_SUB_KEYS15784014
Ref: 462e15784014
Ref: library/winreg winreg KEY_NOTIFY15784133
Ref: 462f15784133
Ref: library/winreg winreg KEY_CREATE_LINK15784270
Ref: 463015784270
Ref: アクセス権限-Footnote-115784458
Node: 64-bit 特有のアクセス権15784535
Ref: library/winreg bit-access-rights15784621
Ref: 463215784621
Ref: library/winreg bit-specific15784621
Ref: 463315784621
Ref: library/winreg winreg KEY_WOW64_64KEY15784809
Ref: 461815784809
Ref: library/winreg winreg KEY_WOW64_32KEY15785051
Ref: 463415785051
Ref: 64-bit 特有のアクセス権-Footnote-115785329
Node: 値の型15785401
Ref: library/winreg id515785484
Ref: 463515785484
Ref: library/winreg value-types15785484
Ref: 462115785484
Ref: library/winreg winreg REG_BINARY15785616
Ref: 463615785616
Ref: library/winreg winreg REG_DWORD15785702
Ref: 463715785702
Ref: library/winreg winreg REG_DWORD_LITTLE_ENDIAN15785763
Ref: 463815785763
Ref: library/winreg winreg REG_DWORD_BIG_ENDIAN15785915
Ref: 463915785915
Ref: library/winreg winreg REG_EXPAND_SZ15786023
Ref: 461915786023
Ref: library/winreg winreg REG_LINK15786162
Ref: 463a15786162
Ref: library/winreg winreg REG_MULTI_SZ15786242
Ref: 194915786242
Ref: library/winreg winreg REG_NONE15786463
Ref: 463b15786463
Ref: library/winreg winreg REG_QWORD15786541
Ref: cd015786541
Ref: library/winreg winreg REG_QWORD_LITTLE_ENDIAN15786630
Ref: 463c15786630
Ref: library/winreg winreg REG_RESOURCE_LIST15786809
Ref: 463d15786809
Ref: library/winreg winreg REG_FULL_RESOURCE_DESCRIPTOR15786908
Ref: 463e15786908
Ref: library/winreg winreg REG_RESOURCE_REQUIREMENTS_LIST15787006
Ref: 463f15787006
Ref: library/winreg winreg REG_SZ15787109
Ref: 461f15787109
Ref: 値の型-Footnote-115787224
Node: レジストリハンドルオブジェクト15787301
Ref: library/winreg handle-object15787454
Ref: 460f15787454
Ref: library/winreg registry-handle-objects15787454
Ref: 464015787454
Ref: library/winreg winreg PyHKEY Close15789242
Ref: 461415789242
Ref: library/winreg winreg PyHKEY Detach15789423
Ref: 407215789423
Ref: library/winreg winreg PyHKEY __enter__15790221
Ref: 464115790221
Ref: library/winreg winreg PyHKEY __exit__15790259
Ref: 464215790259
Node: winsound --- Windows 用の音声再生インターフェース15790750
Ref: library/winsound doc15790943
Ref: 464315790943
Ref: library/winsound module-winsound15790943
Ref: ff15790943
Ref: library/winsound winsound-sound-playing-interface-for-windows15790943
Ref: 464415790943
Ref: library/winsound winsound Beep15791410
Ref: cd215791410
Ref: library/winsound winsound PlaySound15791866
Ref: cd415791866
Ref: library/winsound winsound MessageBeep15792607
Ref: cd315792607
Ref: library/winsound winsound SND_FILENAME15793403
Ref: 464515793403
Ref: library/winsound winsound SND_ALIAS15793595
Ref: 464615793595
Ref: library/winsound winsound SND_LOOP15795507
Ref: 464815795507
Ref: library/winsound winsound SND_MEMORY15795819
Ref: 464a15795819
Ref: library/winsound winsound SND_PURGE15796368
Ref: 464b15796368
Ref: library/winsound winsound SND_ASYNC15796634
Ref: 464915796634
Ref: library/winsound winsound SND_NODEFAULT15796772
Ref: 464715796772
Ref: library/winsound winsound SND_NOSTOP15796944
Ref: 464c15796944
Ref: library/winsound winsound SND_NOWAIT15797056
Ref: 464d15797056
Ref: library/winsound winsound MB_ICONASTERISK15797338
Ref: 464e15797338
Ref: library/winsound winsound MB_ICONEXCLAMATION15797434
Ref: 464f15797434
Ref: library/winsound winsound MB_ICONHAND15797537
Ref: 465015797537
Ref: library/winsound winsound MB_ICONQUESTION15797626
Ref: 465115797626
Ref: library/winsound winsound MB_OK15797723
Ref: 465215797723
Node: Unix 固有のサービス15797809
Ref: library/unix doc15798017
Ref: 465315798017
Ref: library/unix unix15798017
Ref: 465415798017
Ref: library/unix unix-specific-services15798017
Ref: 465515798017
Node: posix --- 最も一般的な POSIX システムコール群15799163
Ref: library/posix doc15799335
Ref: 465615799335
Ref: library/posix module-posix15799335
Ref: 9b15799335
Ref: library/posix posix-the-most-common-posix-system-calls15799335
Ref: 465715799335
Node: ラージファイルのサポート15801060
Ref: library/posix large-file-support15801240
Ref: 465815801240
Ref: library/posix posix-large-files15801240
Ref: 465915801240
Node: 注目すべきモジュールの内容15802823
Ref: library/posix notable-module-contents15803003
Ref: 465a15803003
Ref: library/posix posix-contents15803003
Ref: 465b15803003
Ref: library/posix posix environ15803265
Ref: 465c15803265
Node: pwd --- パスワードデータベース15804791
Ref: library/pwd doc15805010
Ref: 465d15805010
Ref: library/pwd module-pwd15805010
Ref: a015805010
Ref: library/pwd pwd-the-password-database15805010
Ref: 465e15805010
Ref: library/pwd pwd getpwuid15807666
Ref: 199b15807666
Ref: library/pwd pwd getpwnam15807807
Ref: 30b215807807
Ref: library/pwd pwd getpwall15807964
Ref: 465f15807964
Node: grp --- グループデータベース15808298
Ref: library/grp doc15808503
Ref: 466015808503
Ref: library/grp grp-the-group-database15808503
Ref: 466115808503
Ref: library/grp module-grp15808503
Ref: 5c15808503
Ref: library/grp grp getgrgid15810668
Ref: cf415810668
Ref: library/grp grp getgrnam15811094
Ref: 30b115811094
Ref: library/grp grp getgrall15811357
Ref: 466215811357
Node: termios --- POSIX スタイルの端末制御15811652
Ref: library/termios doc15811851
Ref: 466315811851
Ref: library/termios module-termios15811851
Ref: ca15811851
Ref: library/termios termios-posix-style-tty-control15811851
Ref: 466415811851
Ref: library/termios termios tcgetattr15813328
Ref: 15da15813328
Ref: library/termios termios tcsetattr15814033
Ref: 165d15814033
Ref: library/termios termios TCSANOW15814313
Ref: 466515814313
Ref: library/termios termios TCSADRAIN15814392
Ref: 466615814392
Ref: library/termios termios TCSAFLUSH15814498
Ref: 466715814498
Ref: library/termios termios tcsendbreak15814646
Ref: 466815814646
Ref: library/termios termios tcdrain15814952
Ref: 466915814952
Ref: library/termios termios tcflush15815104
Ref: 466a15815104
Ref: library/termios termios tcflow15815426
Ref: 466b15815426
Ref: library/termios termios tcgetwinsize15815844
Ref: 466c15815844
Ref: library/termios termios tcsetwinsize15816089
Ref: 466d15816089
Ref: termios --- POSIX スタイルの端末制御-Footnote-115816704
Node: 使用例<50>15816751
Ref: library/termios example15816846
Ref: 466e15816846
Ref: library/termios termios-example15816846
Ref: 466f15816846
Node: tty --- 端末制御用の関数群15817645
Ref: library/tty doc15817847
Ref: 467015817847
Ref: library/tty module-tty15817847
Ref: e915817847
Ref: library/tty tty-terminal-control-functions15817847
Ref: 467115817847
Ref: library/tty tty cfmakeraw15818403
Ref: 163215818403
Ref: library/tty tty cfmakecbreak15818628
Ref: 15dd15818628
Ref: library/tty tty setraw15819204
Ref: 163115819204
Ref: library/tty tty setcbreak15819696
Ref: 15dc15819696
Ref: tty --- 端末制御用の関数群-Footnote-115820730
Node: pty --- 擬似端末ユーティリティ15820793
Ref: library/pty doc15821003
Ref: 467215821003
Ref: library/pty module-pty15821003
Ref: 9f15821003
Ref: library/pty pty-pseudo-terminal-utilities15821003
Ref: 467315821003
Ref: library/pty pty fork15821717
Ref: 16c315821717
Ref: library/pty pty openpty15822384
Ref: 2af15822384
Ref: library/pty pty spawn15822784
Ref: f4f15822784
Ref: pty --- 擬似端末ユーティリティ-Footnote-115825114
Node: 使用例<51>15825177
Ref: library/pty example15825268
Ref: 467415825268
Ref: 使用例<51>-Footnote-115826532
Node: fcntl --- fcntl および ioctl システムコール15826578
Ref: library/fcntl doc15826790
Ref: 467515826790
Ref: library/fcntl fcntl-the-fcntl-and-ioctl-system-calls15826790
Ref: 467615826790
Ref: library/fcntl module-fcntl15826790
Ref: 4f15826790
Ref: library/fcntl fcntl fcntl15830480
Ref: 32f015830480
Ref: library/fcntl fcntl ioctl15832263
Ref: 141f15832263
Ref: library/fcntl fcntl flock15835042
Ref: 406415835042
Ref: library/fcntl fcntl lockf15835722
Ref: 139415835722
Ref: library/fcntl fcntl LOCK_UN15836176
Ref: 467715836176
Ref: library/fcntl fcntl LOCK_SH15836248
Ref: 467815836248
Ref: library/fcntl fcntl LOCK_EX15836317
Ref: 467915836317
Ref: library/fcntl fcntl LOCK_NB15836390
Ref: 467a15836390
Ref: fcntl --- fcntl および ioctl システムコール-Footnote-115838850
Ref: fcntl --- fcntl および ioctl システムコール-Footnote-215838895
Ref: fcntl --- fcntl および ioctl システムコール-Footnote-315838940
Node: resource --- リソース使用情報15838985
Ref: library/resource doc15839209
Ref: 467b15839209
Ref: library/resource module-resource15839209
Ref: aa15839209
Ref: library/resource resource-resource-usage-information15839209
Ref: 467c15839209
Ref: library/resource resource error15839880
Ref: 467d15839880
Ref: resource --- リソース使用情報-Footnote-115840226
Node: リソースの制限15840268
Ref: library/resource resource-limits15840399
Ref: 467e15840399
Ref: library/resource resource RLIM_INFINITY15841768
Ref: 467f15841768
Ref: library/resource resource getrlimit15841880
Ref: 468015841880
Ref: library/resource resource setrlimit15842260
Ref: 400715842260
Ref: library/resource resource prlimit15843749
Ref: f5615843749
Ref: library/resource resource RLIMIT_CORE15845953
Ref: 400815845953
Ref: library/resource resource RLIMIT_CPU15846322
Ref: 468215846322
Ref: library/resource resource RLIMIT_FSIZE15846858
Ref: 468315846858
Ref: library/resource resource RLIMIT_DATA15846969
Ref: 468415846969
Ref: library/resource resource RLIMIT_STACK15847077
Ref: 468515847077
Ref: library/resource resource RLIMIT_RSS15847334
Ref: 468615847334
Ref: library/resource resource RLIMIT_NPROC15847475
Ref: 468715847475
Ref: library/resource resource RLIMIT_NOFILE15847589
Ref: 468115847589
Ref: library/resource resource RLIMIT_OFILE15847707
Ref: 468815847707
Ref: library/resource resource RLIMIT_MEMLOCK15847808
Ref: 468915847808
Ref: library/resource resource RLIMIT_VMEM15847921
Ref: 468a15847921
Ref: library/resource resource RLIMIT_AS15848085
Ref: 468b15848085
Ref: library/resource resource RLIMIT_MSGQUEUE15848218
Ref: f5715848218
Ref: library/resource resource RLIMIT_NICE15848430
Ref: f5815848430
Ref: library/resource resource RLIMIT_RTPRIO15848607
Ref: f5915848607
Ref: library/resource resource RLIMIT_RTTIME15848779
Ref: f5a15848779
Ref: library/resource resource RLIMIT_SIGPENDING15849101
Ref: f5b15849101
Ref: library/resource resource RLIMIT_SBSIZE15849288
Ref: f5c15849288
Ref: library/resource resource RLIMIT_SWAP15849637
Ref: f5d15849637
Ref: library/resource resource RLIMIT_NPTS15850111
Ref: f5e15850111
Ref: library/resource resource RLIMIT_KQUEUES15850295
Ref: 185315850295
Ref: リソースの制限-Footnote-115850519
Ref: リソースの制限-Footnote-215850568
Ref: リソースの制限-Footnote-315850617
Node: リソースの使用状態15850684
Ref: library/resource resource-usage15850815
Ref: 468c15850815
Ref: library/resource resource getrusage15850965
Ref: 13d815850965
Ref: library/resource resource getpagesize15855873
Ref: 468d15855873
Ref: library/resource resource RUSAGE_SELF15856207
Ref: 468e15856207
Ref: library/resource resource RUSAGE_CHILDREN15856465
Ref: 468f15856465
Ref: library/resource resource RUSAGE_BOTH15856719
Ref: 469015856719
Ref: library/resource resource RUSAGE_THREAD15856989
Ref: 469115856989
Ref: リソースの使用状態-Footnote-115857286
Node: syslog --- Unix syslog ライブラリルーチン群15857335
Ref: library/syslog doc15857497
Ref: 469215857497
Ref: library/syslog module-syslog15857497
Ref: c615857497
Ref: library/syslog syslog-unix-syslog-library-routines15857497
Ref: 469315857497
Ref: library/syslog syslog syslog15858345
Ref: 50b15858345
Ref: library/syslog syslog openlog15860036
Ref: 50915860036
Ref: library/syslog syslog closelog15861704
Ref: 50a15861704
Ref: library/syslog syslog setlogmask15862731
Ref: 406815862731
Ref: library/syslog syslog LOG_EMERG15863503
Ref: 469615863503
Ref: library/syslog syslog LOG_ALERT15863535
Ref: 469715863535
Ref: library/syslog syslog LOG_CRIT15863567
Ref: 469815863567
Ref: library/syslog syslog LOG_ERR15863598
Ref: 469915863598
Ref: library/syslog syslog LOG_WARNING15863628
Ref: 469a15863628
Ref: library/syslog syslog LOG_NOTICE15863662
Ref: 469b15863662
Ref: library/syslog syslog LOG_INFO15863695
Ref: 469415863695
Ref: library/syslog syslog LOG_DEBUG15863726
Ref: 469c15863726
Ref: library/syslog syslog LOG_AUTH15863812
Ref: 469d15863812
Ref: library/syslog syslog LOG_AUTHPRIV15863843
Ref: 469e15863843
Ref: library/syslog syslog LOG_CRON15863878
Ref: 469f15863878
Ref: library/syslog syslog LOG_DAEMON15863909
Ref: 46a015863909
Ref: library/syslog syslog LOG_FTP15863942
Ref: 46a115863942
Ref: library/syslog syslog LOG_INSTALL15863972
Ref: 46a215863972
Ref: library/syslog syslog LOG_KERN15864006
Ref: 46a315864006
Ref: library/syslog syslog LOG_LAUNCHD15864037
Ref: 46a415864037
Ref: library/syslog syslog LOG_LPR15864071
Ref: 46a515864071
Ref: library/syslog syslog LOG_MAIL15864101
Ref: 46a615864101
Ref: library/syslog syslog LOG_NETINFO15864132
Ref: 46a715864132
Ref: library/syslog syslog LOG_NEWS15864166
Ref: 46a815864166
Ref: library/syslog syslog LOG_RAS15864197
Ref: 46a915864197
Ref: library/syslog syslog LOG_REMOTEAUTH15864227
Ref: 46aa15864227
Ref: library/syslog syslog LOG_SYSLOG15864264
Ref: 46ab15864264
Ref: library/syslog syslog LOG_USER15864297
Ref: 469515864297
Ref: library/syslog syslog LOG_UUCP15864328
Ref: 46ac15864328
Ref: library/syslog syslog LOG_LOCAL015864359
Ref: 46ad15864359
Ref: library/syslog syslog LOG_LOCAL115864392
Ref: 46ae15864392
Ref: library/syslog syslog LOG_LOCAL215864425
Ref: 46af15864425
Ref: library/syslog syslog LOG_LOCAL315864458
Ref: 46b015864458
Ref: library/syslog syslog LOG_LOCAL415864491
Ref: 46b115864491
Ref: library/syslog syslog LOG_LOCAL515864524
Ref: 46b215864524
Ref: library/syslog syslog LOG_LOCAL615864557
Ref: 46b315864557
Ref: library/syslog syslog LOG_LOCAL715864590
Ref: 46b415864590
Ref: library/syslog syslog LOG_PID15865060
Ref: 46b515865060
Ref: library/syslog syslog LOG_CONS15865090
Ref: 46b615865090
Ref: library/syslog syslog LOG_NDELAY15865121
Ref: 46b715865121
Ref: library/syslog syslog LOG_ODELAY15865154
Ref: 46b815865154
Ref: library/syslog syslog LOG_NOWAIT15865187
Ref: 46b915865187
Ref: library/syslog syslog LOG_PERROR15865220
Ref: 46ba15865220
Node: 使用例<52>15865447
Ref: library/syslog examples15865550
Ref: 46bb15865550
Node: シンプルな例15865619
Ref: library/syslog simple-example15865687
Ref: 46bc15865687
Node: モジュールのコマンドラインインターフェース CLI15866229
Ref: library/cmdline doc15866447
Ref: 46bd15866447
Ref: library/cmdline modules-command-line-interface-cli15866447
Ref: 46be15866447
Node: 取って代わられたモジュール群15868106
Ref: library/superseded doc15868340
Ref: 46bf15868340
Ref: library/superseded superseded15868340
Ref: 46c015868340
Ref: library/superseded superseded-modules15868340
Ref: 46c115868340
Node: getopt --- C-style parser for command line options15868881
Ref: library/getopt doc15869063
Ref: 46c215869063
Ref: library/getopt getopt-c-style-parser-for-command-line-options15869063
Ref: 46c315869063
Ref: library/getopt module-getopt15869063
Ref: 5715869063
Ref: library/getopt getopt getopt15870295
Ref: 146015870295
Ref: library/getopt getopt gnu_getopt15872663
Ref: 145f15872663
Ref: library/getopt getopt GetoptError15873322
Ref: 46c415873322
Ref: library/getopt getopt error15873899
Ref: 46c515873899
Ref: getopt --- C-style parser for command line options-Footnote-115876438
Node: optparse --- Parser for command line options15876504
Ref: library/optparse doc15876686
Ref: 46c615876686
Ref: library/optparse module-optparse15876686
Ref: 9015876686
Ref: library/optparse optparse-parser-for-command-line-options15876686
Ref: 46c715876686
Ref: optparse --- Parser for command line options-Footnote-115880280
Node: 背景15880348
Ref: library/optparse background15880468
Ref: 46c815880468
Ref: library/optparse optparse-background15880468
Ref: 46c915880468
Node: 用語集15881038
Ref: library/optparse optparse-terminology15881126
Ref: 46ca15881126
Ref: library/optparse terminology15881126
Ref: 46cb15881126
Node: オプションとは何か15886589
Ref: library/optparse optparse-what-options-for15886710
Ref: 46cc15886710
Ref: library/optparse what-are-options-for15886710
Ref: 46cd15886710
Node: 位置引数とは何か15889283
Ref: library/optparse optparse-what-positional-arguments-for15889386
Ref: 46ce15889386
Ref: library/optparse what-are-positional-arguments-for15889386
Ref: 46cf15889386
Node: チュートリアル<4>15891113
Ref: library/optparse optparse-tutorial15891269
Ref: 46d015891269
Ref: library/optparse tutorial15891269
Ref: 46d115891269
Node: オプション・アクションを理解する15894947
Ref: library/optparse optparse-understanding-option-actions15895086
Ref: 46d615895086
Ref: library/optparse understanding-option-actions15895086
Ref: 46d715895086
Node: store アクション15896001
Ref: library/optparse optparse-store-action15896196
Ref: 46d915896196
Ref: library/optparse the-store-action15896196
Ref: 46da15896196
Node: ブール値 フラグ オプションの処理15899150
Ref: library/optparse handling-boolean-flag-options15899324
Ref: 46db15899324
Ref: library/optparse optparse-handling-boolean-options15899324
Ref: 46dc15899324
Node: その他のアクション15900448
Ref: library/optparse optparse-other-actions15900619
Ref: 46dd15900619
Ref: library/optparse other-actions15900619
Ref: 46de15900619
Node: デフォルト値15901270
Ref: library/optparse default-values15901412
Ref: 46e215901412
Ref: library/optparse optparse-default-values15901412
Ref: 46e315901412
Node: ヘルプの生成15904040
Ref: library/optparse generating-help15904185
Ref: 46e415904185
Ref: library/optparse optparse-generating-help15904185
Ref: 46e515904185
Node: オプションをグループ化する15909583
Ref: library/optparse grouping-options15909677
Ref: 46e615909677
Ref: library/optparse optparse OptionGroup15910137
Ref: 46e715910137
Ref: library/optparse optparse OptionParser get_option_group15913833
Ref: 46e815913833
Node: バージョン番号の出力15914188
Ref: library/optparse optparse-printing-version-string15914345
Ref: 46e915914345
Ref: library/optparse printing-a-version-string15914345
Ref: 46ea15914345
Ref: library/optparse optparse OptionParser print_version15915446
Ref: 46eb15915446
Ref: library/optparse optparse OptionParser get_version15915908
Ref: 46ed15915908
Node: optparse のエラー処理法15916084
Ref: library/optparse how-optparse-handles-errors15916253
Ref: 46ee15916253
Ref: library/optparse optparse-how-optparse-handles-errors15916253
Ref: 46ef15916253
Node: 全てをつなぎ合わせる15919327
Ref: library/optparse optparse-putting-it-all-together15919457
Ref: 46f015919457
Ref: library/optparse putting-it-all-together15919457
Ref: 46f115919457
Node: リファレンスガイド15920403
Ref: library/optparse optparse-reference-guide15920592
Ref: 46e015920592
Ref: library/optparse reference-guide15920592
Ref: 46f215920592
Node: parserを作る15921065
Ref: library/optparse creating-the-parser15921189
Ref: 46f315921189
Ref: library/optparse optparse-creating-parser15921189
Ref: 46f415921189
Ref: library/optparse optparse OptionParser15921345
Ref: 147615921345
Node: パーザへのオプション追加15925378
Ref: library/optparse optparse-populating-parser15925535
Ref: 46f615925535
Ref: library/optparse populating-the-parser15925535
Ref: 46f715925535
Node: オプションの定義15927356
Ref: library/optparse defining-options15927519
Ref: 46f915927519
Ref: library/optparse optparse-defining-options15927519
Ref: 46fa15927519
Ref: library/optparse optparse OptionParser add_option15928121
Ref: 2c1c15928121
Ref: library/optparse optparse Values15930908
Ref: 2c1e15930908
Node: オプション属性15932280
Ref: library/optparse option-attributes15932452
Ref: 46fd15932452
Ref: library/optparse optparse-option-attributes15932452
Ref: 46fe15932452
Ref: library/optparse optparse Option15932510
Ref: 46f815932510
Ref: library/optparse optparse Option action15933208
Ref: 46d215933208
Ref: library/optparse optparse Option type15933517
Ref: 46d315933517
Ref: library/optparse optparse Option dest15933806
Ref: 46d415933806
Ref: library/optparse optparse Option default15934309
Ref: 470015934309
Ref: library/optparse optparse Option nargs15934542
Ref: 470215934542
Ref: library/optparse optparse Option const15934855
Ref: 46df15934855
Ref: library/optparse optparse Option choices15934954
Ref: 470315934954
Ref: library/optparse optparse Option callback15935112
Ref: 470415935112
Ref: library/optparse optparse Option callback_args15935486
Ref: 470515935486
Ref: library/optparse optparse Option callback_kwargs15935522
Ref: 470615935522
Ref: library/optparse optparse Option help15935713
Ref: 46d515935713
Ref: library/optparse optparse Option metavar15936183
Ref: 470715936183
Node: 標準的なオプション・アクション15936453
Ref: library/optparse optparse-standard-option-actions15936628
Ref: 46fb15936628
Ref: library/optparse standard-option-actions15936628
Ref: 470815936628
Node: 標準のオプション型15946406
Ref: library/optparse optparse-standard-option-types15946581
Ref: 46ff15946581
Ref: library/optparse standard-option-types15946581
Ref: 470915946581
Node: 引数を解析する15948530
Ref: library/optparse optparse-parsing-arguments15948714
Ref: 46fc15948714
Ref: library/optparse parsing-arguments15948714
Ref: 470a15948714
Ref: library/optparse optparse OptionParser parse_args15948934
Ref: 147715948934
Node: オプション解析器への問い合わせと操作15950685
Ref: library/optparse optparse-querying-manipulating-option-parser15950869
Ref: 470b15950869
Ref: library/optparse querying-and-manipulating-your-option-parser15950869
Ref: 470c15950869
Ref: library/optparse optparse OptionParser disable_interspersed_args15951273
Ref: 2c1d15951273
Ref: library/optparse optparse OptionParser enable_interspersed_args15952448
Ref: 470d15952448
Ref: library/optparse optparse OptionParser get_option15952770
Ref: 470e15952770
Ref: library/optparse optparse OptionParser has_option15953012
Ref: 470f15953012
Ref: library/optparse optparse OptionParser remove_option15953224
Ref: 471015953224
Node: オプション間の衝突15953770
Ref: library/optparse conflicts-between-options15953957
Ref: 471115953957
Ref: library/optparse optparse-conflicts-between-options15953957
Ref: 46f515953957
Node: クリーンアップ<2>15957249
Ref: library/optparse cleanup15957406
Ref: 471315957406
Ref: library/optparse optparse-cleanup15957406
Ref: 471415957406
Node: その他のメソッド15958034
Ref: library/optparse optparse-other-methods15958155
Ref: 471515958155
Ref: library/optparse other-methods15958155
Ref: 471615958155
Ref: library/optparse optparse OptionParser set_usage15958309
Ref: 471715958309
Ref: library/optparse optparse OptionParser print_usage15958713
Ref: 46ec15958713
Ref: library/optparse optparse OptionParser get_usage15959120
Ref: 471815959120
Ref: library/optparse optparse OptionParser set_defaults15959310
Ref: 470115959310
Node: オプション処理コールバック15960760
Ref: library/optparse option-callbacks15960943
Ref: 471915960943
Ref: library/optparse optparse-option-callbacks15960943
Ref: 46e115960943
Node: callbackオプションの定義15962766
Ref: library/optparse defining-a-callback-option15962946
Ref: 471a15962946
Ref: library/optparse optparse-defining-callback-option15962946
Ref: 471b15962946
Node: コールバック関数はどのように呼び出されるか15965847
Ref: library/optparse how-callbacks-are-called15966081
Ref: 471c15966081
Ref: library/optparse optparse-how-callbacks-called15966081
Ref: 471d15966081
Node: コールバック中で例外を送出する15969565
Ref: library/optparse optparse-raising-errors-in-callback15969827
Ref: 471e15969827
Ref: library/optparse raising-errors-in-a-callback15969827
Ref: 471f15969827
Node: コールバックの例 1 ありふれたコールバック15970571
Ref: library/optparse callback-example-1-trivial-callback15970842
Ref: 472015970842
Ref: library/optparse optparse-callback-example-115970842
Ref: 472115970842
Node: コールバックの例 2 オプションの順番をチェックする15971375
Ref: library/optparse callback-example-2-check-option-order15971683
Ref: 472215971683
Ref: library/optparse optparse-callback-example-215971683
Ref: 472315971683
Node: コールバックの例 3 オプションの順番をチェックする 汎用的15972339
Ref: library/optparse callback-example-3-check-option-order-generalized15972650
Ref: 472415972650
Ref: library/optparse optparse-callback-example-315972650
Ref: 472515972650
Node: コールバックの例 4 任意の条件をチェックする15973590
Ref: library/optparse callback-example-4-check-arbitrary-condition15973867
Ref: 472615973867
Ref: library/optparse optparse-callback-example-415973867
Ref: 472715973867
Node: コールバックの例5 固定引数15974771
Ref: library/optparse callback-example-5-fixed-arguments15975010
Ref: 472815975010
Ref: library/optparse optparse-callback-example-515975010
Ref: 472915975010
Node: コールバックの例6 可変個の引数15976349
Ref: library/optparse callback-example-6-variable-arguments15976516
Ref: 472a15976516
Ref: library/optparse optparse-callback-example-615976516
Ref: 472b15976516
Node: optparse の拡張15979073
Ref: library/optparse extending-optparse15979239
Ref: 472c15979239
Ref: library/optparse optparse-extending-optparse15979239
Ref: 46d815979239
Node: 新しい型の追加15979674
Ref: library/optparse adding-new-types15979792
Ref: 472d15979792
Ref: library/optparse optparse-adding-new-types15979792
Ref: 472e15979792
Ref: library/optparse optparse Option TYPES15980187
Ref: 472f15980187
Ref: library/optparse optparse Option TYPE_CHECKER15980439
Ref: 473015980439
Node: 新しいアクションの追加15984171
Ref: library/optparse adding-new-actions15984289
Ref: 473115984289
Ref: library/optparse optparse-adding-new-actions15984289
Ref: 473215984289
Ref: library/optparse optparse Option ACTIONS15985826
Ref: 473315985826
Ref: library/optparse optparse Option STORE_ACTIONS15985954
Ref: 473415985954
Ref: library/optparse optparse Option TYPED_ACTIONS15986060
Ref: 473515986060
Ref: library/optparse optparse Option ALWAYS_TYPED_ACTIONS15986166
Ref: 473615986166
Node: 例外<20>15990199
Ref: library/optparse exceptions15990317
Ref: 473715990317
Ref: library/optparse optparse OptionError15990350
Ref: 2c1f15990350
Ref: library/optparse optparse OptionConflictError15990488
Ref: 471215990488
Ref: library/optparse optparse OptionValueError15990613
Ref: 2c2015990613
Ref: library/optparse optparse BadOptionError15990733
Ref: 473815990733
Ref: library/optparse optparse AmbiguousOptionError15990835
Ref: 473915990835
Ref: library/security_warnings security-warnings15990945
Ref: 473a15990945
Node: セキュリティで考慮すべき点<6>15990945
Ref: library/security_warnings doc15991103
Ref: 473b15991103
Ref: library/security_warnings security-considerations15991103
Ref: 473c15991103
Ref: セキュリティで考慮すべき点<6>-Footnote-115992900
Node: Python インタプリタの拡張と埋め込み15992959
Ref: extending/index doc15993140
Ref: 473d15993140
Ref: extending/index extending-and-embedding-the-python-interpreter15993140
Ref: 473e15993140
Ref: extending/index extending-index15993140
Ref: 1b4615993140
Node: おすすめのサードパーティツール15995123
Ref: extending/index recommended-third-party-tools15995317
Ref: 473f15995317
Ref: おすすめのサードパーティツール-Footnote-115996193
Ref: おすすめのサードパーティツール-Footnote-215996221
Ref: おすすめのサードパーティツール-Footnote-315996257
Ref: おすすめのサードパーティツール-Footnote-415996286
Ref: おすすめのサードパーティツール-Footnote-515996320
Node: サードパーティツールなしで拡張を作る15996393
Ref: extending/index creating-extensions-without-third-party-tools15996676
Ref: 474015996676
Node: C や C++ による Python の拡張15997429
Ref: extending/extending doc15997608
Ref: 474115997608
Ref: extending/extending extending-intro15997608
Ref: 474215997608
Ref: extending/extending extending-python-with-c-or-c15997608
Ref: 474315997608
Ref: C や C++ による Python の拡張-Footnote-116000094
Node: 簡単な例16000131
Ref: extending/extending a-simple-example16000256
Ref: 474416000256
Ref: extending/extending extending-simpleexample16000256
Ref: 474516000256
Ref: 簡単な例-Footnote-116005061
Node: 幕間小話 エラーと例外16005266
Ref: extending/extending extending-errors16005412
Ref: 474616005412
Ref: extending/extending intermezzo-errors-and-exceptions16005412
Ref: 474716005412
Node: 例に戻る16013418
Ref: extending/extending back-to-the-example16013612
Ref: 474a16013612
Ref: extending/extending backtoexample16013612
Ref: 474b16013612
Node: モジュールのメソッドテーブルと初期化関数16015524
Ref: extending/extending methodtable16015714
Ref: 474d16015714
Ref: extending/extending the-module-s-method-table-and-initialization-function16015714
Ref: 474e16015714
Ref: モジュールのメソッドテーブルと初期化関数-Footnote-116021956
Node: コンパイルとリンク16021998
Ref: extending/extending compilation16022213
Ref: 475116022213
Ref: extending/extending compilation-and-linkage16022213
Ref: 475216022213
Node: C から Python 関数を呼び出す16024206
Ref: extending/extending calling-python-functions-from-c16024412
Ref: 475416024412
Ref: extending/extending callingpython16024412
Ref: 475516024412
Node: 拡張モジュール関数でのパラメタ展開16033391
Ref: extending/extending extracting-parameters-in-extension-functions16033627
Ref: 475916033627
Ref: extending/extending parsetuple16033627
Ref: 475616033627
Node: 拡張モジュール関数のキーワードパラメタ16036705
Ref: extending/extending keyword-parameters-for-extension-functions16036931
Ref: 475a16036931
Ref: extending/extending parsetupleandkeywords16036931
Ref: 475b16036931
Node: 任意の値を構築する16039876
Ref: extending/extending building-arbitrary-values16040072
Ref: 475c16040072
Ref: extending/extending buildvalue16040072
Ref: 475d16040072
Node: 参照カウント法16042609
Ref: extending/extending refcounts16042784
Ref: 475716042784
Ref: extending/extending reference-counts16042784
Ref: 475e16042784
Node: Python における参照カウント法16048846
Ref: extending/extending refcountsinpython16048983
Ref: 475f16048983
Ref: extending/extending reference-counting-in-python16048983
Ref: 476016048983
Ref: Python における参照カウント法-Footnote-116052253
Ref: Python における参照カウント法-Footnote-216052452
Node: 所有権にまつわる規則16052711
Ref: extending/extending ownership-rules16052863
Ref: 476116052863
Ref: extending/extending ownershiprules16052863
Ref: 476216052863
Node: 薄氷16056040
Ref: extending/extending thin-ice16056169
Ref: 476716056169
Ref: extending/extending thinice16056169
Ref: 476816056169
Node: NULL ポインタ16059869
Ref: extending/extending null-pointers16059959
Ref: 476a16059959
Ref: extending/extending nullpointers16059959
Ref: 476b16059959
Ref: NULL ポインタ-Footnote-116062307
Node: C++での拡張モジュール作成16062507
Ref: extending/extending cplusplus16062701
Ref: 476c16062701
Ref: extending/extending writing-extensions-in-c16062701
Ref: 476d16062701
Node: 拡張モジュールに C API を提供する16063782
Ref: extending/extending providing-a-c-api-for-an-extension-module16063946
Ref: 476e16063946
Ref: extending/extending using-capsules16063946
Ref: 132516063946
Node: 拡張の型の定義 チュートリアル16074613
Ref: extending/newtypes_tutorial doc16074844
Ref: 179516074844
Ref: extending/newtypes_tutorial defining-extension-types-tutorial16074844
Ref: 477016074844
Ref: extending/newtypes_tutorial defining-new-types16074844
Ref: 477116074844
Node: 基本的なこと16075625
Ref: extending/newtypes_tutorial dnt-basics16075795
Ref: 477216075795
Ref: extending/newtypes_tutorial the-basics16075795
Ref: 477316075795
Node: 基本のサンプルにデータとメソッドを追加する16087228
Ref: extending/newtypes_tutorial adding-data-and-methods-to-the-basic-example16087449
Ref: 477916087449
Ref: 基本のサンプルにデータとメソッドを追加する-Footnote-116104764
Ref: 基本のサンプルにデータとメソッドを追加する-Footnote-216104897
Node: データ属性をこまかく制御する16105032
Ref: extending/newtypes_tutorial providing-finer-control-over-data-attributes16105292
Ref: 478116105292
Ref: データ属性をこまかく制御する-Footnote-116114984
Node: 循環ガベージコレクションをサポートする16115358
Ref: extending/newtypes_tutorial supporting-cyclic-garbage-collection16115591
Ref: 478316115591
Ref: 循環ガベージコレクションをサポートする-Footnote-116126353
Node: 他の型のサブクラスを作る16126527
Ref: extending/newtypes_tutorial subclassing-other-types16126709
Ref: 478516126709
Node: 拡張の型の定義 雑多なトピック16131932
Ref: extending/newtypes doc16132161
Ref: 478816132161
Ref: extending/newtypes defining-extension-types-assorted-topics16132161
Ref: 478916132161
Ref: extending/newtypes new-types-topics16132161
Ref: 478a16132161
Ref: extending/newtypes dnt-type-methods16132250
Ref: 478b16132250
Node: ファイナライズとメモリ解放16137763
Ref: extending/newtypes finalization-and-de-allocation16137915
Ref: 478c16137915
Ref: ファイナライズとメモリ解放-Footnote-116142234
Node: オブジェクト表現16142276
Ref: extending/newtypes object-presentation16142458
Ref: 478e16142458
Node: 属性を管理する16144442
Ref: extending/newtypes attribute-management16144612
Ref: 479116144612
Node: 総称的な属性を管理する16146167
Ref: extending/newtypes generic-attribute-management16146309
Ref: 477e16146309
Ref: extending/newtypes id116146309
Ref: 479216146309
Node: 特定の型に特化した属性の管理16150337
Ref: extending/newtypes type-specific-attribute-management16150479
Ref: 479716150479
Node: オブジェクトの比較16152259
Ref: extending/newtypes object-comparison16152447
Ref: 479a16152447
Node: 抽象的なプロトコルのサポート16154241
Ref: extending/newtypes abstract-protocol-support16154448
Ref: 479d16154448
Node: 弱参照 Weak Reference のサポート16160576
Ref: extending/newtypes weak-reference-support16160777
Ref: 47a216160777
Ref: extending/newtypes weakref-support16160777
Ref: 24b116160777
Node: その他いろいろ16162091
Ref: extending/newtypes more-suggestions16162241
Ref: 47a316162241
Node: C および C++ 拡張のビルド16163207
Ref: extending/building doc16163460
Ref: 47a416163460
Ref: extending/building building16163460
Ref: 475316163460
Ref: extending/building building-c-and-c-extensions16163460
Ref: 47a516163460
Ref: extending/building c PyInit_modulename16164126
Ref: 47a616164126
Ref: extending/building install-index16165815
Ref: ec116165815
Ref: C および C++ 拡張のビルド-Footnote-116165922
Node: setuptools による C および C++ 拡張のビルド16165964
Ref: extending/building building-c-and-c-extensions-with-setuptools16166090
Ref: 47a916166090
Ref: extending/building setuptools-index16166090
Ref: ec216166090
Node: Windows 上での C および C++ 拡張モジュールのビルド16166507
Ref: extending/windows doc16166708
Ref: 47aa16166708
Ref: extending/windows building-c-and-c-extensions-on-windows16166708
Ref: 47ab16166708
Ref: extending/windows building-on-windows16166708
Ref: 1da016166708
Node: 型どおりのアプローチ16168325
Ref: extending/windows a-cookbook-approach16168497
Ref: 47ac16168497
Ref: extending/windows win-cookbook16168497
Ref: 47ad16168497
Ref: 型どおりのアプローチ-Footnote-116169148
Node: Unix と Windows の相違点16169226
Ref: extending/windows differences-between-unix-and-windows16169426
Ref: 47ae16169426
Ref: extending/windows dynamic-linking16169426
Ref: 47af16169426
Node: DLL 使用の実際16173786
Ref: extending/windows using-dlls-in-practice16173947
Ref: 47b016173947
Ref: extending/windows win-dlls16173947
Ref: 47b116173947
Node: 大規模なアプリケーションへの Python ランタイムの埋め込み16175812
Ref: extending/index embedding-the-cpython-runtime-in-a-larger-application16176041
Ref: 47b216176041
Node: 他のアプリケーションへの Python の埋め込み16176599
Ref: extending/embedding doc16176775
Ref: 47b316176775
Ref: extending/embedding embedding16176775
Ref: 1dbc16176775
Ref: extending/embedding embedding-python-in-another-application16176775
Ref: 47b416176775
Node: 高水準の埋め込み16180097
Ref: extending/embedding high-level-embedding16180278
Ref: 47b716180278
Ref: extending/embedding very-high-level-embedding16180278
Ref: 47b816180278
Node: 超高水準の埋め込みから踏み出す 概要16182824
Ref: extending/embedding beyond-very-high-level-embedding-an-overview16183035
Ref: 47b916183035
Ref: extending/embedding lower-level-embedding16183035
Ref: 47ba16183035
Node: 純粋な埋め込み16185495
Ref: extending/embedding id116185717
Ref: 47bb16185717
Ref: extending/embedding pure-embedding16185717
Ref: 47bc16185717
Node: 埋め込まれた Python の拡張16191021
Ref: extending/embedding extending-embedded-python16191226
Ref: 47bf16191226
Ref: extending/embedding extending-with-embedding16191226
Ref: 47c016191226
Node: C++による Python の埋め込み16193760
Ref: extending/embedding embedding-python-in-c16194003
Ref: 47c116194003
Ref: extending/embedding embeddingincplusplus16194003
Ref: 47c216194003
Node: Unix 系システムにおけるコンパイルとリンク16194510
Ref: extending/embedding compiling16194709
Ref: 47bd16194709
Ref: extending/embedding compiling-and-linking-under-unix-like-systems16194709
Ref: 47c316194709
Node: Python/C API リファレンスマニュアル16197427
Ref: c-api/index doc16197623
Ref: 47c516197623
Ref: c-api/index c-api-index16197623
Ref: 1b4716197623
Ref: c-api/index python-c-api-reference-manual16197623
Ref: 47c616197623
Node: はじめに<11>16199059
Ref: c-api/intro doc16199185
Ref: 47c716199185
Ref: c-api/intro api-intro16199185
Ref: 47c816199185
Ref: c-api/intro introduction16199185
Ref: 47c916199185
Node: コーディング基準16201475
Ref: c-api/intro coding-standards16201591
Ref: 47ca16201591
Ref: コーディング基準-Footnote-116202154
Node: インクルードファイル16202196
Ref: c-api/intro api-includes16202339
Ref: 74f16202339
Ref: c-api/intro include-files16202339
Ref: 47cb16202339
Node: 便利なマクロ16205751
Ref: c-api/intro useful-macros16205921
Ref: 47cc16205921
Ref: c-api/intro c PyMODINIT_FUNC16206409
Ref: 147c16206409
Ref: c-api/intro c Py_ABS16207201
Ref: 47cd16207201
Ref: c-api/intro c Py_ALWAYS_INLINE16207306
Ref: 182116207306
Ref: c-api/intro c Py_CHARMASK16208292
Ref: 47ce16208292
Ref: c-api/intro c Py_DEPRECATED16208547
Ref: a7216208547
Ref: c-api/intro c Py_GETENV16208882
Ref: 47cf16208882
Ref: c-api/intro c Py_MAX16209066
Ref: 47d016209066
Ref: c-api/intro c Py_MEMBER_SIZE16209186
Ref: 47d116209186
Ref: c-api/intro c Py_MIN16209359
Ref: 47d216209359
Ref: c-api/intro c Py_NO_INLINE16209479
Ref: 182216209479
Ref: c-api/intro c Py_STRINGIFY16209790
Ref: 47d316209790
Ref: c-api/intro c Py_UNREACHABLE16209984
Ref: b8316209984
Ref: c-api/intro c Py_UNUSED16211144
Ref: 168216211144
Ref: c-api/intro c PyDoc_STRVAR16211375
Ref: 18dd16211375
Ref: c-api/intro c PyDoc_STR16211989
Ref: 177616211989
Ref: 便利なマクロ-Footnote-116212571
Ref: 便利なマクロ-Footnote-216212636
Ref: 便利なマクロ-Footnote-316212678
Node: オブジェクト、型および参照カウント16212720
Ref: c-api/intro api-objects16212870
Ref: 47d416212870
Ref: c-api/intro objects-types-and-reference-counts16212870
Ref: 47d516212870
Node: 参照カウント法<2>16214731
Ref: c-api/intro api-refcounts16214855
Ref: 47d616214855
Ref: c-api/intro reference-counts16214855
Ref: 47d716214855
Node: 参照カウントの詳細16218784
Ref: c-api/intro api-refcountdetails16218872
Ref: 47d816218872
Ref: c-api/intro reference-count-details16218872
Ref: 47d916218872
Node: 型16227269
Ref: c-api/intro api-types16227393
Ref: 47dc16227393
Ref: c-api/intro types16227393
Ref: 47dd16227393
Ref: c-api/intro c Py_ssize_t16228006
Ref: a2e16228006
Ref: 型-Footnote-116228423
Node: 例外<21>16228465
Ref: c-api/intro api-exceptions16228622
Ref: 47de16228622
Ref: c-api/intro exceptions16228622
Ref: 47df16228622
Node: Python の埋め込み<2>16236781
Ref: c-api/intro api-embedding16236928
Ref: 47e116236928
Ref: c-api/intro embedding-python16236928
Ref: 47e216236928
Node: デバッグ版ビルド Debugging Builds16241008
Ref: c-api/intro api-debugging16241136
Ref: 47e416241136
Ref: c-api/intro debugging-builds16241136
Ref: 47e516241136
Ref: c-api/intro c Py_DEBUG16242037
Ref: 3fb816242037
Node: C API の安定性16243374
Ref: c-api/stable doc16243530
Ref: 47e616243530
Ref: c-api/stable c-api-stability16243530
Ref: 47e716243530
Ref: c-api/stable stable16243530
Ref: 51e16243530
Ref: C API の安定性-Footnote-116245159
Ref: C API の安定性-Footnote-216245201
Node: Unstable C API16245256
Ref: c-api/stable id116245379
Ref: 47e916245379
Ref: c-api/stable unstable-c-api16245379
Ref: 51216245379
Node: 安定 ABI Stable Appliction Binary Interface16245877
Ref: c-api/stable stable-application-binary-interface16246054
Ref: 47ea16246054
Node: Limited C API16246458
Ref: c-api/stable id216246572
Ref: 47eb16246572
Ref: c-api/stable limited-c-api16246572
Ref: 36f16246572
Ref: c-api/stable c Py_LIMITED_API16246850
Ref: 3f716246850
Node: Stable ABI16247956
Ref: c-api/stable id316248127
Ref: 47ec16248127
Ref: c-api/stable stable-abi16248127
Ref: 47ed16248127
Node: APIスコープとパフォーマンスの制限16249525
Ref: c-api/stable limited-api-scope-and-performance16249710
Ref: 47ee16249710
Node: 制限付きAPIの注意点16251296
Ref: c-api/stable limited-api-caveats16251462
Ref: 47f016251462
Node: プラットフォームで考慮すべき点16253567
Ref: c-api/stable platform-considerations16253751
Ref: 47f116253751
Ref: c-api/stable stable-abi-platform16253751
Ref: 47e816253751
Node: 限定版APIの内容16254469
Ref: c-api/stable contents-of-limited-api16254599
Ref: 47f216254599
Ref: c-api/stable limited-api-list16254599
Ref: 76516254599
Node: 超高水準レイヤ16290212
Ref: c-api/veryhigh doc16290370
Ref: 495516290370
Ref: c-api/veryhigh the-very-high-level-layer16290370
Ref: 495616290370
Ref: c-api/veryhigh veryhigh16290370
Ref: 495716290370
Ref: c-api/veryhigh c PyRun_AnyFile16291424
Ref: 495b16291424
Ref: c-api/veryhigh c PyRun_AnyFileFlags16291664
Ref: 495d16291664
Ref: c-api/veryhigh c PyRun_AnyFileEx16291914
Ref: 495e16291914
Ref: c-api/veryhigh c PyRun_AnyFileExFlags16292151
Ref: 495c16292151
Ref: c-api/veryhigh c PyRun_SimpleString16293001
Ref: 47b516293001
Ref: c-api/veryhigh c PyRun_SimpleStringFlags16293233
Ref: 496016293233
Ref: c-api/veryhigh c PyRun_SimpleFile16294012
Ref: 47b616294012
Ref: c-api/veryhigh c PyRun_SimpleFileEx16294259
Ref: 496116294259
Ref: c-api/veryhigh c PyRun_SimpleFileExFlags16294501
Ref: 187316294501
Ref: c-api/veryhigh c PyRun_InteractiveOne16295400
Ref: 496216295400
Ref: c-api/veryhigh c PyRun_InteractiveOneFlags16295623
Ref: 496316295623
Ref: c-api/veryhigh c PyRun_InteractiveLoop16296653
Ref: 495f16296653
Ref: c-api/veryhigh c PyRun_InteractiveLoopFlags16296878
Ref: 496416296878
Ref: c-api/veryhigh c PyOS_InputHook16297461
Ref: 55116297461
Ref: c-api/veryhigh c PyOS_ReadlineFunctionPointer16298263
Ref: 55216298263
Ref: c-api/veryhigh c PyRun_String16299653
Ref: 194616299653
Ref: c-api/veryhigh c PyRun_StringFlags16299952
Ref: 496516299952
Ref: c-api/veryhigh c PyRun_File16300847
Ref: 496616300847
Ref: c-api/veryhigh c PyRun_FileEx16301197
Ref: 496816301197
Ref: c-api/veryhigh c PyRun_FileFlags16301534
Ref: 496916301534
Ref: c-api/veryhigh c PyRun_FileExFlags16301884
Ref: 496716301884
Ref: c-api/veryhigh c Py_CompileString16302618
Ref: 85216302618
Ref: c-api/veryhigh c Py_CompileStringFlags16302963
Ref: 496a16302963
Ref: c-api/veryhigh c Py_CompileStringObject16303287
Ref: 496c16303287
Ref: c-api/veryhigh c Py_CompileStringExFlags16304508
Ref: 496b16304508
Ref: c-api/veryhigh c PyEval_EvalCode16304981
Ref: 85316304981
Ref: c-api/veryhigh c PyEval_EvalCodeEx16305437
Ref: 16d416305437
Ref: c-api/veryhigh c PyEval_EvalFrame16306252
Ref: 484416306252
Ref: c-api/veryhigh c PyEval_EvalFrameEx16306605
Ref: ff816306605
Ref: c-api/veryhigh c PyEval_MergeCompilerFlags16307542
Ref: 496d16307542
Ref: c-api/veryhigh c Py_eval_input16307752
Ref: 495816307752
Ref: c-api/veryhigh c Py_file_input16307913
Ref: 495916307913
Ref: c-api/veryhigh c Py_single_input16308255
Ref: 495a16308255
Ref: c-api/veryhigh c PyCompilerFlags16308499
Ref: a6f16308499
Ref: c-api/veryhigh c PyCompilerFlags cf_flags16309120
Ref: 496e16309120
Ref: c-api/veryhigh c PyCompilerFlags cf_feature_version16309204
Ref: 496f16309204
Ref: c-api/veryhigh c CO_FUTURE_DIVISION16309591
Ref: 497016309591
Ref: 超高水準レイヤ-Footnote-116309838
Node: 参照カウント16309880
Ref: c-api/refcounting doc16310032
Ref: 497116310032
Ref: c-api/refcounting countingrefs16310032
Ref: 497216310032
Ref: c-api/refcounting reference-counting16310032
Ref: 497316310032
Ref: c-api/refcounting c Py_REFCNT16310210
Ref: 87716310210
Ref: c-api/refcounting c Py_SET_REFCNT16311208
Ref: 87816311208
Ref: c-api/refcounting c Py_INCREF16311791
Ref: 53a16311791
Ref: c-api/refcounting c Py_XINCREF16312856
Ref: a3316312856
Ref: c-api/refcounting c Py_NewRef16313062
Ref: 86716313062
Ref: c-api/refcounting c Py_XNewRef16313790
Ref: 86816313790
Ref: c-api/refcounting c Py_DECREF16314115
Ref: 53b16314115
Ref: c-api/refcounting c Py_XDECREF16315872
Ref: 75a16315872
Ref: c-api/refcounting c Py_CLEAR16316112
Ref: 54416316112
Ref: c-api/refcounting c Py_IncRef16316951
Ref: 493116316951
Ref: c-api/refcounting c Py_DecRef16317236
Ref: 492a16317236
Ref: c-api/refcounting c Py_SETREF16317509
Ref: 54516317509
Ref: c-api/refcounting c Py_XSETREF16318275
Ref: 54616318275
Ref: 参照カウント-Footnote-116318665
Ref: 参照カウント-Footnote-216318707
Node: 例外処理16318749
Ref: c-api/exceptions doc16318904
Ref: 497416318904
Ref: c-api/exceptions exception-handling16318904
Ref: 497516318904
Ref: c-api/exceptions exceptionhandling16318904
Ref: 426116318904
Node: 出力とクリア16322030
Ref: c-api/exceptions printing-and-clearing16322121
Ref: 497616322121
Ref: c-api/exceptions c PyErr_Clear16322166
Ref: ffb16322166
Ref: c-api/exceptions c PyErr_PrintEx16322413
Ref: 483816322413
Ref: c-api/exceptions c PyErr_Print16323583
Ref: 18af16323583
Ref: c-api/exceptions c PyErr_WriteUnraisable16323730
Ref: 32816323730
Ref: c-api/exceptions c PyErr_FormatUnraisable16324790
Ref: 32716324790
Ref: c-api/exceptions c PyErr_DisplayException16325305
Ref: 3db16325305
Node: 例外の送出16325599
Ref: c-api/exceptions raising-exceptions16325708
Ref: 497716325708
Ref: c-api/exceptions c PyErr_SetString16326005
Ref: 54816326005
Ref: c-api/exceptions c PyErr_SetObject16326519
Ref: 54716326519
Ref: c-api/exceptions c PyErr_Format16326830
Ref: e7a16326830
Ref: c-api/exceptions c PyErr_FormatV16327425
Ref: e7916327425
Ref: c-api/exceptions c PyErr_SetNone16327820
Ref: 484016327820
Ref: c-api/exceptions c PyErr_BadArgument16328009
Ref: 483516328009
Ref: c-api/exceptions c PyErr_NoMemory16328377
Ref: 474916328377
Ref: c-api/exceptions c PyErr_SetFromErrno16328797
Ref: 474816328797
Ref: c-api/exceptions c PyErr_SetFromErrnoWithFilenameObject16329734
Ref: 483c16329734
Ref: c-api/exceptions c PyErr_SetFromErrnoWithFilenameObjects16330276
Ref: 483d16330276
Ref: c-api/exceptions c PyErr_SetFromErrnoWithFilename16330831
Ref: 167d16330831
Ref: c-api/exceptions c PyErr_SetFromWindowsErr16331323
Ref: 483e16331323
Ref: c-api/exceptions c PyErr_SetExcFromWindowsErr16332250
Ref: 483916332250
Ref: c-api/exceptions c PyErr_SetFromWindowsErrWithFilename16332672
Ref: 167f16332672
Ref: c-api/exceptions c PyErr_SetExcFromWindowsErrWithFilenameObject16333323
Ref: 483a16333323
Ref: c-api/exceptions c PyErr_SetExcFromWindowsErrWithFilenameObjects16333936
Ref: 483b16333936
Ref: c-api/exceptions c PyErr_SetExcFromWindowsErrWithFilename16334466
Ref: 167e16334466
Ref: c-api/exceptions c PyErr_SetImportError16334944
Ref: d0c16334944
Ref: c-api/exceptions c PyErr_SetImportErrorSubclass16335554
Ref: ce416335554
Ref: c-api/exceptions c PyErr_SyntaxLocationObject16336046
Ref: 497816336046
Ref: c-api/exceptions c PyErr_SyntaxLocationEx16336496
Ref: 484216336496
Ref: c-api/exceptions c PyErr_SyntaxLocation16336955
Ref: 484116336955
Ref: c-api/exceptions c PyErr_BadInternalCall16337220
Ref: 483616337220
Node: 警告<3>16337628
Ref: c-api/exceptions issuing-warnings16337764
Ref: 497916337764
Ref: c-api/exceptions c PyErr_WarnEx16338816
Ref: 13f216338816
Ref: c-api/exceptions c PyErr_WarnExplicitObject16340324
Ref: 497b16340324
Ref: c-api/exceptions c PyErr_WarnExplicit16340976
Ref: 168616340976
Ref: c-api/exceptions c PyErr_WarnFormat16341530
Ref: 484316341530
Ref: c-api/exceptions c PyErr_ResourceWarning16341985
Ref: ce516341985
Node: エラーインジケータの問い合わせ16342386
Ref: c-api/exceptions querying-the-error-indicator16342540
Ref: 497c16342540
Ref: c-api/exceptions c PyErr_Occurred16342630
Ref: 185c16342630
Ref: c-api/exceptions c PyErr_ExceptionMatches16343806
Ref: 47e016343806
Ref: c-api/exceptions c PyErr_GivenExceptionMatches16344191
Ref: 483716344191
Ref: c-api/exceptions c PyErr_GetRaisedException16344755
Ref: 3cd16344755
Ref: c-api/exceptions c PyErr_SetRaisedException16345612
Ref: 3d016345612
Ref: c-api/exceptions c PyErr_Fetch16345996
Ref: 3cc16345996
Ref: c-api/exceptions c PyErr_Restore16347319
Ref: 3cf16347319
Ref: c-api/exceptions c PyErr_NormalizeException16348496
Ref: 3ce16348496
Ref: c-api/exceptions c PyErr_GetHandledException16349737
Ref: 73a16349737
Ref: c-api/exceptions c PyErr_SetHandledException16350673
Ref: 73b16350673
Ref: c-api/exceptions c PyErr_GetExcInfo16351465
Ref: 73d16351465
Ref: c-api/exceptions c PyErr_SetExcInfo16352568
Ref: 73c16352568
Node: シグナルハンドリング<2>16353866
Ref: c-api/exceptions signal-handling16354029
Ref: 497d16354029
Ref: c-api/exceptions c PyErr_CheckSignals16354094
Ref: 43316354094
Ref: c-api/exceptions c PyErr_SetInterrupt16355358
Ref: 483f16355358
Ref: c-api/exceptions c PyErr_SetInterruptEx16355719
Ref: 86b16355719
Ref: c-api/exceptions c PySignal_SetWakeupFd16356881
Ref: 138316356881
Node: 例外クラス<2>16357805
Ref: c-api/exceptions exception-classes16357947
Ref: 497e16357947
Ref: c-api/exceptions c PyErr_NewException16357987
Ref: 123b16357987
Ref: c-api/exceptions c PyErr_NewExceptionWithDoc16359155
Ref: 123a16359155
Node: 例外オブジェクト16359655
Ref: c-api/exceptions exception-objects16359796
Ref: 497f16359796
Ref: c-api/exceptions c PyException_GetTraceback16359851
Ref: 484a16359851
Ref: c-api/exceptions c PyException_SetTraceback16360268
Ref: 195516360268
Ref: c-api/exceptions c PyException_GetContext16360542
Ref: 484916360542
Ref: c-api/exceptions c PyException_SetContext16361008
Ref: 484c16361008
Ref: c-api/exceptions c PyException_GetCause16361432
Ref: 484816361432
Ref: c-api/exceptions c PyException_SetCause16361828
Ref: 484b16361828
Ref: c-api/exceptions c PyException_GetArgs16362299
Ref: 53616362299
Ref: c-api/exceptions c PyException_SetArgs16362537
Ref: 53716362537
Ref: c-api/exceptions c PyUnstable_Exc_PrepReraiseStar16362748
Ref: 498016362748
Node: Unicode 例外オブジェクト16363741
Ref: c-api/exceptions unicode-exception-objects16363879
Ref: 498116363879
Ref: c-api/exceptions unicodeexceptions16363879
Ref: 498216363879
Ref: c-api/exceptions c PyUnicodeDecodeError_Create16364063
Ref: 48ec16364063
Ref: c-api/exceptions c PyUnicodeDecodeError_GetEncoding16364595
Ref: 48ed16364595
Ref: c-api/exceptions c PyUnicodeEncodeError_GetEncoding16364693
Ref: 48f516364693
Ref: c-api/exceptions c PyUnicodeDecodeError_GetObject16364960
Ref: 48ef16364960
Ref: c-api/exceptions c PyUnicodeEncodeError_GetObject16365056
Ref: 48f716365056
Ref: c-api/exceptions c PyUnicodeTranslateError_GetObject16365152
Ref: 48fe16365152
Ref: c-api/exceptions c PyUnicodeDecodeError_GetStart16365418
Ref: 48f116365418
Ref: c-api/exceptions c PyUnicodeEncodeError_GetStart16365514
Ref: 48f916365514
Ref: c-api/exceptions c PyUnicodeTranslateError_GetStart16365610
Ref: 490016365610
Ref: c-api/exceptions c PyUnicodeDecodeError_SetStart16366012
Ref: 48f416366012
Ref: c-api/exceptions c PyUnicodeEncodeError_SetStart16366107
Ref: 48fc16366107
Ref: c-api/exceptions c PyUnicodeTranslateError_SetStart16366202
Ref: 490316366202
Ref: c-api/exceptions c PyUnicodeDecodeError_GetEnd16366524
Ref: 48ee16366524
Ref: c-api/exceptions c PyUnicodeEncodeError_GetEnd16366616
Ref: 48f616366616
Ref: c-api/exceptions c PyUnicodeTranslateError_GetEnd16366708
Ref: 48fd16366708
Ref: c-api/exceptions c PyUnicodeDecodeError_SetEnd16367095
Ref: 48f216367095
Ref: c-api/exceptions c PyUnicodeEncodeError_SetEnd16367186
Ref: 48fa16367186
Ref: c-api/exceptions c PyUnicodeTranslateError_SetEnd16367277
Ref: 490116367277
Ref: c-api/exceptions c PyUnicodeDecodeError_GetReason16367591
Ref: 48f016367591
Ref: c-api/exceptions c PyUnicodeEncodeError_GetReason16367687
Ref: 48f816367687
Ref: c-api/exceptions c PyUnicodeTranslateError_GetReason16367783
Ref: 48ff16367783
Ref: c-api/exceptions c PyUnicodeDecodeError_SetReason16368046
Ref: 48f316368046
Ref: c-api/exceptions c PyUnicodeEncodeError_SetReason16368144
Ref: 48fb16368144
Ref: c-api/exceptions c PyUnicodeTranslateError_SetReason16368242
Ref: 490216368242
Node: 再帰の管理16368570
Ref: c-api/exceptions recursion16368696
Ref: 498316368696
Ref: c-api/exceptions recursion-control16368696
Ref: 498416368696
Ref: c-api/exceptions c Py_EnterRecursiveCall16369119
Ref: 94116369119
Ref: c-api/exceptions c Py_LeaveRecursiveCall16370241
Ref: 94216370241
Ref: c-api/exceptions c Py_ReprEnter16371124
Ref: 493316371124
Ref: c-api/exceptions c Py_ReprLeave16372123
Ref: 493416372123
Node: 標準例外16372404
Ref: c-api/exceptions standard-exceptions16372522
Ref: 498516372522
Ref: c-api/exceptions standardexceptions16372522
Ref: 498616372522
Ref: 標準例外-Footnote-116386083
Ref: 標準例外-Footnote-216386158
Ref: 標準例外-Footnote-316386233
Ref: 標準例外-Footnote-416386308
Ref: 標準例外-Footnote-516386383
Ref: 標準例外-Footnote-616386458
Ref: 標準例外-Footnote-716386500
Node: 標準警告カテゴリ16386708
Ref: c-api/exceptions standard-warning-categories16386802
Ref: 498716386802
Ref: c-api/exceptions standardwarningcategories16386802
Ref: 497a16386802
Ref: 標準警告カテゴリ-Footnote-116389974
Node: ユーティリティ<2>16390061
Ref: c-api/utilities doc16390254
Ref: 498816390254
Ref: c-api/utilities id116390254
Ref: 498916390254
Ref: c-api/utilities utilities16390254
Ref: 498a16390254
Node: オペレーティングシステム関連のユーティリティ16391176
Ref: c-api/sys doc16391330
Ref: 498b16391330
Ref: c-api/sys operating-system-utilities16391330
Ref: 498c16391330
Ref: c-api/sys os16391330
Ref: 498d16391330
Ref: c-api/sys c PyOS_FSPath16391455
Ref: ce616391455
Ref: c-api/sys c Py_FdIsInteractive16392111
Ref: 498e16392111
Ref: c-api/sys c PyOS_BeforeFork16392657
Ref: b8d16392657
Ref: c-api/sys c PyOS_AfterFork_Parent16393409
Ref: b8e16393409
Ref: c-api/sys c PyOS_AfterFork_Child16394261
Ref: 3d416394261
Ref: c-api/sys c PyOS_AfterFork16395302
Ref: 3d316395302
Ref: c-api/sys c PyOS_CheckStack16395935
Ref: 178116395935
Ref: c-api/sys c PyOS_sighandler_t16396464
Ref: 48a616396464
Ref: c-api/sys c PyOS_getsig16396578
Ref: 14e616396578
Ref: c-api/sys c PyOS_setsig16396873
Ref: 14e716396873
Ref: c-api/sys c Py_DecodeLocale16397234
Ref: b9516397234
Ref: c-api/sys c Py_EncodeLocale16400087
Ref: b9616400087
Node: システム関数16402206
Ref: c-api/sys system-functions16402387
Ref: 499016402387
Ref: c-api/sys systemfunctions16402387
Ref: 499116402387
Ref: c-api/sys c PySys_GetObject16402763
Ref: 36216402763
Ref: c-api/sys c PySys_SetObject16403079
Ref: 48dd16403079
Ref: c-api/sys c PySys_ResetWarnOptions16403482
Ref: 38916403482
Ref: c-api/sys c PySys_WriteStdout16403856
Ref: 48df16403856
Ref: c-api/sys c PySys_WriteStderr16405049
Ref: 48de16405049
Ref: c-api/sys c PySys_FormatStdout16405301
Ref: 48db16405301
Ref: c-api/sys c PySys_FormatStderr16405672
Ref: 48da16405672
Ref: c-api/sys c PySys_GetXOptions16405954
Ref: 48dc16405954
Ref: c-api/sys c PySys_Audit16406364
Ref: 34816406364
Ref: c-api/sys c PySys_AuditTuple16407725
Ref: 34716407725
Ref: c-api/sys c PySys_AddAuditHook16408083
Ref: 405b16408083
Ref: c-api/sys c Py_AuditHookFunction16409771
Ref: 499216409771
Ref: システム関数-Footnote-116410287
Node: プロセス制御16410329
Ref: c-api/sys process-control16410480
Ref: 499416410480
Ref: c-api/sys processcontrol16410480
Ref: 499516410480
Ref: c-api/sys c Py_FatalError16410525
Ref: 95116410525
Ref: c-api/sys c Py_Exit16411316
Ref: d1c16411316
Ref: c-api/sys c Py_AtExit16411818
Ref: 492816411818
Node: モジュールのインポート<2>16412664
Ref: c-api/import doc16412848
Ref: 499616412848
Ref: c-api/import importing16412848
Ref: 499716412848
Ref: c-api/import importing-modules16412848
Ref: 499816412848
Ref: c-api/import c PyImport_ImportModule16412918
Ref: 39816412918
Ref: c-api/import c PyImport_ImportModuleNoBlock16413235
Ref: 39716413235
Ref: c-api/import c PyImport_ImportModuleEx16414062
Ref: 117616414062
Ref: c-api/import c PyImport_ImportModuleLevelObject16415077
Ref: 485f16415077
Ref: c-api/import c PyImport_ImportModuleLevel16416161
Ref: 117516416161
Ref: c-api/import c PyImport_Import16416727
Ref: 13a416416727
Ref: c-api/import c PyImport_ReloadModule16417444
Ref: 486016417444
Ref: c-api/import c PyImport_AddModuleRef16417962
Ref: 33116417962
Ref: c-api/import c PyImport_AddModuleObject16418978
Ref: 485616418978
Ref: c-api/import c PyImport_AddModule16419362
Ref: 33216419362
Ref: c-api/import c PyImport_ExecCodeModule16419630
Ref: 485716419630
Ref: c-api/import c PyImport_ExecCodeModuleEx16421814
Ref: 485816421814
Ref: c-api/import c PyImport_ExecCodeModuleObject16422289
Ref: 485916422289
Ref: c-api/import c PyImport_ExecCodeModuleWithPathnames16422963
Ref: 485a16422963
Ref: c-api/import c PyImport_GetMagicNumber16423842
Ref: 117416423842
Ref: c-api/import c PyImport_GetMagicTag16424381
Ref: 485b16424381
Ref: c-api/import c PyImport_GetModuleDict16424808
Ref: 485c16424808
Ref: c-api/import c PyImport_GetModule16425159
Ref: b8116425159
Ref: c-api/import c PyImport_GetImporter16425735
Ref: 167c16425735
Ref: c-api/import c PyImport_ImportFrozenModuleObject16426468
Ref: 485e16426468
Ref: c-api/import c PyImport_ImportFrozenModule16427398
Ref: 485d16427398
Ref: c-api/import c _frozen16427744
Ref: 74016427744
Ref: c-api/import c PyImport_FrozenModules16428478
Ref: 2f6316428478
Ref: c-api/import c PyImport_AppendInittab16429081
Ref: 170e16429081
Ref: c-api/import c _inittab16429801
Ref: 499916429801
Ref: c-api/import c _inittab name16430131
Ref: 499a16430131
Ref: c-api/import c _inittab initfunc16430236
Ref: 499b16430236
Ref: c-api/import c PyImport_ExtendInittab16430394
Ref: 170f16430394
Ref: モジュールのインポート<2>-Footnote-116431251
Node: データ整列化 data marshalling のサポート16431293
Ref: c-api/marshal doc16431489
Ref: 499c16431489
Ref: c-api/marshal data-marshalling-support16431489
Ref: 499d16431489
Ref: c-api/marshal marshalling-utils16431489
Ref: 499e16431489
Ref: c-api/marshal c PyMarshal_WriteLongToFile16432373
Ref: 76116432373
Ref: c-api/marshal c PyMarshal_WriteObjectToFile16432943
Ref: 76216432943
Ref: c-api/marshal c PyMarshal_WriteObjectToString16433381
Ref: 76416433381
Ref: c-api/marshal c PyMarshal_ReadLongFromFile16433760
Ref: 499f16433760
Ref: c-api/marshal c PyMarshal_ReadShortFromFile16434210
Ref: 49a016434210
Ref: c-api/marshal c PyMarshal_ReadObjectFromFile16434662
Ref: 49a116434662
Ref: c-api/marshal c PyMarshal_ReadLastObjectFromFile16435075
Ref: 49a216435075
Ref: c-api/marshal c PyMarshal_ReadObjectFromString16436070
Ref: 76316436070
Node: 引数の解釈と値の構築16436529
Ref: c-api/arg doc16436719
Ref: 49a316436719
Ref: c-api/arg arg-parsing16436719
Ref: 87616436719
Ref: c-api/arg parsing-arguments-and-building-values16436719
Ref: 49a416436719
Node: 引数を解析する<2>16437511
Ref: c-api/arg parsing-arguments16437623
Ref: 49a516437623
Node: 文字列とバッファ16438484
Ref: c-api/arg arg-parsing-string-and-buffers16438584
Ref: 36416438584
Ref: c-api/arg strings-and-buffers16438584
Ref: 49a616438584
Ref: c-api/arg c-arg-borrowed-buffer16440056
Ref: 49a716440056
Node: 数<2>16451849
Ref: c-api/arg numbers16451988
Ref: 49a816451988
Node: その他のオブジェクト16454495
Ref: c-api/arg other-objects16454620
Ref: 49aa16454620
Ref: c-api/arg o-ampersand16455610
Ref: 49ab16455610
Node: API 関数16461145
Ref: c-api/arg api-functions16461255
Ref: 49ac16461255
Ref: c-api/arg c PyArg_ParseTuple16461292
Ref: 53d16461292
Ref: c-api/arg c PyArg_VaParse16461665
Ref: 47f416461665
Ref: c-api/arg c PyArg_ParseTupleAndKeywords16461947
Ref: 35c16461947
Ref: c-api/arg c PyArg_VaParseTupleAndKeywords16463062
Ref: 35d16463062
Ref: c-api/arg c PyArg_ValidateKeywordArguments16463418
Ref: 47f516463418
Ref: c-api/arg c PyArg_Parse16463867
Ref: 194f16463867
Ref: c-api/arg c PyArg_UnpackTuple16464574
Ref: 14b116464574
Ref: c-api/arg c PY_CXX_CONST16466600
Ref: 35e16466600
Node: 値の構築16467026
Ref: c-api/arg building-values16467138
Ref: 49ad16467138
Ref: c-api/arg c Py_BuildValue16467177
Ref: 87516467177
Ref: c-api/arg c Py_VaBuildValue16476335
Ref: 493616476335
Node: 文字列の変換と書式化16476642
Ref: c-api/conversion doc16476791
Ref: 49ae16476791
Ref: c-api/conversion string-conversion16476791
Ref: 49af16476791
Ref: c-api/conversion string-conversion-and-formatting16476791
Ref: 49b016476791
Ref: c-api/conversion c PyOS_snprintf16476924
Ref: 14b416476924
Ref: c-api/conversion c PyOS_vsnprintf16477278
Ref: 14b516477278
Ref: c-api/conversion c PyOS_strtoul16479247
Ref: 48a816479247
Ref: c-api/conversion c PyOS_strtol16480286
Ref: 48a716480286
Ref: c-api/conversion c PyOS_string_to_double16480812
Ref: 126616480812
Ref: c-api/conversion c PyOS_double_to_string16482939
Ref: 48a516482939
Ref: c-api/conversion c PyOS_stricmp16484768
Ref: 49b116484768
Ref: c-api/conversion c PyOS_strnicmp16484977
Ref: 49b216484977
Ref: 文字列の変換と書式化-Footnote-116485251
Ref: 文字列の変換と書式化-Footnote-216485299
Ref: 文字列の変換と書式化-Footnote-316485348
Ref: 文字列の変換と書式化-Footnote-416485395
Node: PyHash API16485441
Ref: c-api/hash doc16485581
Ref: 49b316485581
Ref: c-api/hash pyhash-api16485581
Ref: 49b416485581
Ref: c-api/hash c Py_hash_t16485716
Ref: 123516485716
Ref: c-api/hash c Py_uhash_t16485822
Ref: 49b516485822
Ref: c-api/hash c PyHASH_MODULUS16485931
Ref: 15cd16485931
Ref: c-api/hash c PyHASH_BITS16486073
Ref: 15ce16486073
Ref: c-api/hash c PyHASH_MULTIPLIER16486204
Ref: 158616486204
Ref: c-api/hash c PyHASH_INF16486336
Ref: 15cf16486336
Ref: c-api/hash c PyHASH_IMAG16486452
Ref: 15d016486452
Ref: c-api/hash c PyHash_FuncDef16486584
Ref: 49b616486584
Ref: c-api/hash c PyHash_FuncDef name16486700
Ref: 49b816486700
Ref: c-api/hash c PyHash_FuncDef hash_bits16486803
Ref: 49b916486803
Ref: c-api/hash c PyHash_FuncDef seed_bits16486907
Ref: 49ba16486907
Ref: c-api/hash c PyHash_GetFuncDef16487026
Ref: 49b716487026
Ref: c-api/hash c Py_HashPointer16487251
Ref: 34116487251
Ref: c-api/hash c PyObject_GenericHash16487561
Ref: 34016487561
Ref: PyHash API-Footnote-116487970
Ref: PyHash API-Footnote-216488023
Node: リフレクション16488065
Ref: c-api/reflection doc16488217
Ref: 49bb16488217
Ref: c-api/reflection id116488217
Ref: 49bc16488217
Ref: c-api/reflection reflection16488217
Ref: 49bd16488217
Ref: c-api/reflection c PyEval_GetBuiltins16488267
Ref: 32a16488267
Ref: c-api/reflection c PyEval_GetLocals16488711
Ref: 32e16488711
Ref: c-api/reflection c PyEval_GetGlobals16490257
Ref: 32c16490257
Ref: c-api/reflection c PyEval_GetFrame16490648
Ref: 172716490648
Ref: c-api/reflection c PyEval_GetFrameBuiltins16490995
Ref: 32916490995
Ref: c-api/reflection c PyEval_GetFrameLocals16491417
Ref: 32d16491417
Ref: c-api/reflection c PyEval_GetFrameGlobals16492064
Ref: 32b16492064
Ref: c-api/reflection c PyEval_GetFuncName16492486
Ref: 484616492486
Ref: c-api/reflection c PyEval_GetFuncDesc16492767
Ref: 484516492767
Ref: リフレクション-Footnote-116493232
Node: codec レジストリとサポート関数16493274
Ref: c-api/codec doc16493428
Ref: 49be16493428
Ref: c-api/codec codec-registry16493428
Ref: d0316493428
Ref: c-api/codec codec-registry-and-support-functions16493428
Ref: 49bf16493428
Ref: c-api/codec c PyCodec_Register16493517
Ref: 481c16493517
Ref: c-api/codec c PyCodec_Unregister16493887
Ref: 86416493887
Ref: c-api/codec c PyCodec_KnownEncoding16494269
Ref: 481a16494269
Ref: c-api/codec c PyCodec_Encode16494564
Ref: 3d916494564
Ref: c-api/codec c PyCodec_Decode16495249
Ref: 3d816495249
Node: コーデック検索API16496028
Ref: c-api/codec codec-lookup-api16496191
Ref: 49c016496191
Ref: c-api/codec c PyCodec_Encoder16496525
Ref: 481616496525
Ref: c-api/codec c PyCodec_Decoder16496773
Ref: 481516496773
Ref: c-api/codec c PyCodec_IncrementalEncoder16497018
Ref: 481916497018
Ref: c-api/codec c PyCodec_IncrementalDecoder16497333
Ref: 481816497333
Ref: c-api/codec c PyCodec_StreamReader16497648
Ref: 481f16497648
Ref: c-api/codec c PyCodec_StreamWriter16497972
Ref: 482016497972
Node: Unicode エラーハンドラ用レジストリ API16498296
Ref: c-api/codec registry-api-for-unicode-encoding-error-handlers16498459
Ref: 49c116498459
Ref: c-api/codec c PyCodec_RegisterError16498569
Ref: 481d16498569
Ref: c-api/codec c PyCodec_LookupError16499957
Ref: 481b16499957
Ref: c-api/codec c PyCodec_StrictErrors16500386
Ref: 482116500386
Ref: c-api/codec c PyCodec_IgnoreErrors16500593
Ref: 481716500593
Ref: c-api/codec c PyCodec_ReplaceErrors16500832
Ref: 481e16500832
Ref: c-api/codec c PyCodec_XMLCharRefReplaceErrors16501078
Ref: 482216501078
Ref: c-api/codec c PyCodec_BackslashReplaceErrors16501331
Ref: 481416501331
Ref: c-api/codec c PyCodec_NameReplaceErrors16501643
Ref: e7816501643
Node: PyTime C API16501955
Ref: c-api/time doc16502109
Ref: 14016502109
Ref: c-api/time c-api-time16502109
Ref: 30516502109
Ref: c-api/time pytime-c-api16502109
Ref: 49c216502109
Node: Types16502466
Ref: c-api/time types16502544
Ref: 49c416502544
Ref: c-api/time c PyTime_t16502575
Ref: 30616502575
Ref: c-api/time c PyTime_MIN16503111
Ref: 30716503111
Ref: c-api/time c PyTime_MAX16503202
Ref: 30816503202
Node: Clock Functions16503293
Ref: c-api/time clock-functions16503399
Ref: 49c516503399
Ref: c-api/time c PyTime_Monotonic16504106
Ref: 30a16504106
Ref: c-api/time c PyTime_PerfCounter16504272
Ref: 30c16504272
Ref: c-api/time c PyTime_Time16504447
Ref: 30e16504447
Node: Raw Clock Functions16504609
Ref: c-api/time raw-clock-functions16504730
Ref: 49c616504730
Ref: c-api/time c PyTime_MonotonicRaw16505214
Ref: 30b16505214
Ref: c-api/time c PyTime_PerfCounterRaw16505399
Ref: 30d16505399
Ref: c-api/time c PyTime_TimeRaw16505588
Ref: 30f16505588
Node: Conversion functions16505763
Ref: c-api/time conversion-functions16505860
Ref: 49c716505860
Ref: c-api/time c PyTime_AsSecondsDouble16505921
Ref: 30916505921
Node: Support for Perf Maps16506143
Ref: c-api/perfmaps doc16506246
Ref: 49c816506246
Ref: c-api/perfmaps perfmaps16506246
Ref: 49c916506246
Ref: c-api/perfmaps support-for-perf-maps16506246
Ref: 49ca16506246
Ref: c-api/perfmaps c PyUnstable_PerfMapState_Init16506917
Ref: 16a216506917
Ref: c-api/perfmaps c PyUnstable_WritePerfMapEntry16507825
Ref: 16a116507825
Ref: c-api/perfmaps c PyUnstable_PerfMapState_Fini16508690
Ref: 16a316508690
Ref: Support for Perf Maps-Footnote-116509322
Ref: Support for Perf Maps-Footnote-216509379
Node: 抽象オブジェクトレイヤ Abstract Objects Layer16509503
Ref: c-api/abstract doc16509734
Ref: 49cb16509734
Ref: c-api/abstract abstract16509734
Ref: 479e16509734
Ref: c-api/abstract abstract-objects-layer16509734
Ref: 49cc16509734
Node: オブジェクトプロトコル object protocol16511137
Ref: c-api/object doc16511308
Ref: 49cd16511308
Ref: c-api/object object16511308
Ref: 49ce16511308
Ref: c-api/object object-protocol16511308
Ref: 49cf16511308
Ref: c-api/object c Py_GetConstant16511414
Ref: 32f16511414
Ref: c-api/object c Py_CONSTANT_NONE16512111
Ref: 49d016512111
Ref: c-api/object c Py_CONSTANT_FALSE16512319
Ref: 49d116512319
Ref: c-api/object c Py_CONSTANT_TRUE16512526
Ref: 49d216512526
Ref: c-api/object c Py_CONSTANT_ELLIPSIS16512737
Ref: 49d316512737
Ref: c-api/object c Py_CONSTANT_NOT_IMPLEMENTED16512928
Ref: 49d416512928
Ref: c-api/object c Py_CONSTANT_ZERO16513102
Ref: 49d516513102
Ref: c-api/object c Py_CONSTANT_ONE16513299
Ref: 49d616513299
Ref: c-api/object c Py_CONSTANT_EMPTY_STR16513503
Ref: 49d716513503
Ref: c-api/object c Py_CONSTANT_EMPTY_BYTES16513704
Ref: 49d816513704
Ref: c-api/object c Py_CONSTANT_EMPTY_TUPLE16513904
Ref: 49d916513904
Ref: c-api/object c Py_GetConstantBorrowed16514220
Ref: 33016514220
Ref: c-api/object c Py_NotImplemented16514773
Ref: 49da16514773
Ref: c-api/object c Py_RETURN_NOTIMPLEMENTED16515034
Ref: 49db16515034
Ref: c-api/object c Py_PRINT_RAW16515276
Ref: 49dc16515276
Ref: c-api/object c PyObject_Print16515576
Ref: 155416515576
Ref: c-api/object c PyObject_HasAttrWithError16515959
Ref: 35316515959
Ref: c-api/object c PyObject_HasAttrStringWithError16516361
Ref: 35516516361
Ref: c-api/object c PyObject_HasAttr16516759
Ref: 35416516759
Ref: c-api/object c PyObject_HasAttrString16517356
Ref: 35616517356
Ref: c-api/object c PyObject_GetAttr16518112
Ref: 32416518112
Ref: c-api/object c PyObject_GetAttrString16518672
Ref: 32516518672
Ref: c-api/object c PyObject_GetOptionalAttr16519180
Ref: 32216519180
Ref: c-api/object c PyObject_GetOptionalAttrString16519917
Ref: 32316519917
Ref: c-api/object c PyObject_GenericGetAttr16520335
Ref: 48b016520335
Ref: c-api/object c PyObject_SetAttr16521206
Ref: 48b816521206
Ref: c-api/object c PyObject_SetAttrString16521873
Ref: 156416521873
Ref: c-api/object c PyObject_GenericSetAttr16522848
Ref: 48b116522848
Ref: c-api/object c PyObject_DelAttr16523683
Ref: 168316523683
Ref: c-api/object c PyObject_DelAttrString16524053
Ref: 156516524053
Ref: c-api/object c PyObject_GenericGetDict16524872
Ref: 18a416524872
Ref: c-api/object c PyObject_GenericSetDict16525646
Ref: 48b216525646
Ref: c-api/object c _PyObject_GetDictPtr16526018
Ref: 49dd16526018
Ref: c-api/object c PyObject_RichCompare16526447
Ref: 479c16526447
Ref: c-api/object c PyObject_RichCompareBool16527180
Ref: 190e16527180
Ref: c-api/object c PyObject_Format16527730
Ref: 48af16527730
Ref: c-api/object c PyObject_Repr16528181
Ref: ff916528181
Ref: c-api/object c PyObject_ASCII16528859
Ref: 48a916528859
Ref: c-api/object c PyObject_Str16529510
Ref: ffa16529510
Ref: c-api/object c PyObject_Bytes16530225
Ref: 48ab16530225
Ref: c-api/object c PyObject_IsSubclass16530823
Ref: e7016530823
Ref: c-api/object c PyObject_IsInstance16532014
Ref: e6f16532014
Ref: c-api/object c PyObject_Hash16533203
Ref: 3dc16533203
Ref: c-api/object c PyObject_HashNotImplemented16533684
Ref: 136e16533684
Ref: c-api/object c PyObject_IsTrue16534118
Ref: 48b516534118
Ref: c-api/object c PyObject_Not16534441
Ref: 48b716534441
Ref: c-api/object c PyObject_Type16534757
Ref: 48ba16534757
Ref: c-api/object c PyObject_TypeCheck16535464
Ref: 186216535464
Ref: c-api/object c PyObject_Size16535690
Ref: 48b916535690
Ref: c-api/object c PyObject_Length16535758
Ref: 48b616535758
Ref: c-api/object c PyObject_LengthHint16536221
Ref: fcf16536221
Ref: c-api/object c PyObject_GetItem16536701
Ref: 32016536701
Ref: c-api/object c PyObject_SetItem16537055
Ref: 47da16537055
Ref: c-api/object c PyObject_DelItem16537507
Ref: 48ad16537507
Ref: c-api/object c PyObject_Dir16537812
Ref: 48ae16537812
Ref: c-api/object c PyObject_GetIter16538527
Ref: 48b416538527
Ref: c-api/object c PyObject_GetAIter16539063
Ref: 48b316539063
Ref: c-api/object c PyObject_GetTypeData16539642
Ref: 51416539642
Ref: c-api/object c PyType_GetTypeDataSize16540133
Ref: 51516540133
Ref: c-api/object c PyObject_GetItemData16540838
Ref: 51716540838
Ref: c-api/object c PyObject_VisitManagedDict16541182
Ref: 34216541182
Ref: c-api/object c PyObject_ClearManagedDict16541498
Ref: 34316541498
Ref: オブジェクトプロトコル object protocol-Footnote-116541813
Ref: オブジェクトプロトコル object protocol-Footnote-216541855
Node: Call プロトコル16541897
Ref: c-api/call doc16542117
Ref: 49e416542117
Ref: c-api/call call16542117
Ref: 54f16542117
Ref: c-api/call call-protocol16542117
Ref: 49e516542117
Node: The tp_call Protocol16542351
Ref: c-api/call the-tp-call-protocol16542460
Ref: 49e616542460
Node: The Vectorcall Protocol16543196
Ref: c-api/call the-vectorcall-protocol16543332
Ref: 49e816543332
Ref: c-api/call vectorcall16543332
Ref: 51d16543332
Ref: c-api/call c vectorcallfunc16545112
Ref: 52216545112
Ref: c-api/call c PY_VECTORCALL_ARGUMENTS_OFFSET16546224
Ref: 52916546224
Ref: The Vectorcall Protocol-Footnote-116547382
Node: 再帰の管理<2>16547424
Ref: c-api/call recursion-control16547533
Ref: 49ea16547533
Node: Vectorcall Support API16547936
Ref: c-api/call vectorcall-support-api16548045
Ref: 49eb16548045
Ref: c-api/call c PyVectorcall_NARGS16548108
Ref: 52016548108
Ref: c-api/call c PyVectorcall_Function16548578
Ref: 49ec16548578
Ref: c-api/call c PyVectorcall_Call16549128
Ref: 52116549128
Node: Object Calling API16549757
Ref: c-api/call capi-call16549889
Ref: 49e716549889
Ref: c-api/call object-calling-api16549889
Ref: 49ed16549889
Ref: c-api/call c PyObject_Call16554516
Ref: 37616554516
Ref: c-api/call c PyObject_CallNoArgs16555335
Ref: 37516555335
Ref: c-api/call c PyObject_CallOneArg16555853
Ref: 94616555853
Ref: c-api/call c PyObject_CallObject16556257
Ref: 475816556257
Ref: c-api/call c PyObject_CallFunction16556882
Ref: 37816556882
Ref: c-api/call c PyObject_CallMethod16557923
Ref: 37916557923
Ref: c-api/call c PyObject_CallFunctionObjArgs16559027
Ref: 48ac16559027
Ref: c-api/call c PyObject_CallMethodObjArgs16559672
Ref: 196816559672
Ref: c-api/call c PyObject_CallMethodNoArgs16560329
Ref: 49ee16560329
Ref: c-api/call c PyObject_CallMethodOneArg16560736
Ref: 49ef16560736
Ref: c-api/call c PyObject_Vectorcall16561180
Ref: 52716561180
Ref: c-api/call c PyObject_VectorcallDict16561805
Ref: 49f016561805
Ref: c-api/call c PyObject_VectorcallMethod16562518
Ref: 52816562518
Node: Call Support API16563674
Ref: c-api/call call-support-api16563774
Ref: 49f216563774
Ref: c-api/call c PyCallable_Check16563825
Ref: 480a16563825
Node: 数値型プロトコル number protocol16564221
Ref: c-api/number doc16564443
Ref: 49f316564443
Ref: c-api/number number16564443
Ref: 49f416564443
Ref: c-api/number number-protocol16564443
Ref: 49f516564443
Ref: c-api/number c PyNumber_Check16564534
Ref: a3416564534
Ref: c-api/number c PyNumber_Add16564970
Ref: 488816564970
Ref: c-api/number c PyNumber_Subtract16565312
Ref: 48a216565312
Ref: c-api/number c PyNumber_Multiply16565662
Ref: 489b16565662
Ref: c-api/number c PyNumber_MatrixMultiply16566009
Ref: e7e16566009
Ref: c-api/number c PyNumber_FloorDivide16566433
Ref: 488c16566433
Ref: c-api/number c PyNumber_TrueDivide16566757
Ref: 48a316566757
Ref: c-api/number c PyNumber_Remainder16567376
Ref: 48a016567376
Ref: c-api/number c PyNumber_Divmod16567724
Ref: 488b16567724
Ref: c-api/number c PyNumber_Power16568082
Ref: 489f16568082
Ref: c-api/number c PyNumber_Negative16568693
Ref: 489c16568693
Ref: c-api/number c PyNumber_Positive16568994
Ref: 489e16568994
Ref: c-api/number c PyNumber_Absolute16569280
Ref: 488716569280
Ref: c-api/number c PyNumber_Invert16569580
Ref: 489916569580
Ref: c-api/number c PyNumber_Lshift16569907
Ref: 489a16569907
Ref: c-api/number c PyNumber_Rshift16570262
Ref: 48a116570262
Ref: c-api/number c PyNumber_And16570617
Ref: 488916570617
Ref: c-api/number c PyNumber_Xor16570983
Ref: 48a416570983
Ref: c-api/number c PyNumber_Or16571372
Ref: 489d16571372
Ref: c-api/number c PyNumber_InPlaceAdd16571733
Ref: 488d16571733
Ref: c-api/number c PyNumber_InPlaceSubtract16572178
Ref: 489616572178
Ref: c-api/number c PyNumber_InPlaceMultiply16572631
Ref: 489116572631
Ref: c-api/number c PyNumber_InPlaceMatrixMultiply16573081
Ref: e7f16573081
Ref: c-api/number c PyNumber_InPlaceFloorDivide16573610
Ref: 488f16573610
Ref: c-api/number c PyNumber_InPlaceTrueDivide16574070
Ref: 489716574070
Ref: c-api/number c PyNumber_InPlaceRemainder16574758
Ref: 489416574758
Ref: c-api/number c PyNumber_InPlacePower16575211
Ref: 489316575211
Ref: c-api/number c PyNumber_InPlaceLshift16576015
Ref: 489016576015
Ref: c-api/number c PyNumber_InPlaceRshift16576473
Ref: 489516576473
Ref: c-api/number c PyNumber_InPlaceAnd16576931
Ref: 488e16576931
Ref: c-api/number c PyNumber_InPlaceXor16577400
Ref: 489816577400
Ref: c-api/number c PyNumber_InPlaceOr16577891
Ref: 489216577891
Ref: c-api/number c PyNumber_Long16578355
Ref: a3516578355
Ref: c-api/number c PyNumber_Float16578670
Ref: a3616578670
Ref: c-api/number c PyNumber_Index16578999
Ref: 86016578999
Ref: c-api/number c PyNumber_ToBase16579536
Ref: 175516579536
Ref: c-api/number c PyNumber_AsSsize_t16580183
Ref: 488a16580183
Ref: c-api/number c PyIndex_Check16581035
Ref: 95816581035
Node: シーケンス型プロトコル sequence protocol16581436
Ref: c-api/sequence doc16581682
Ref: 49f616581682
Ref: c-api/sequence sequence16581682
Ref: 49f716581682
Ref: c-api/sequence sequence-protocol16581682
Ref: 49f816581682
Ref: c-api/sequence c PySequence_Check16581792
Ref: 48be16581792
Ref: c-api/sequence c PySequence_Size16582258
Ref: 19bd16582258
Ref: c-api/sequence c PySequence_Length16582328
Ref: 48c816582328
Ref: c-api/sequence c PySequence_Concat16582650
Ref: 48bf16582650
Ref: c-api/sequence c PySequence_Repeat16583001
Ref: 48ca16583001
Ref: c-api/sequence c PySequence_InPlaceConcat16583366
Ref: 48c516583366
Ref: c-api/sequence c PySequence_InPlaceRepeat16583820
Ref: 48c616583820
Ref: c-api/sequence c PySequence_GetItem16584287
Ref: 19be16584287
Ref: c-api/sequence c PySequence_GetSlice16584623
Ref: 48c416584623
Ref: c-api/sequence c PySequence_SetItem16585004
Ref: 19bf16585004
Ref: c-api/sequence c PySequence_DelItem16585638
Ref: 19c016585638
Ref: c-api/sequence c PySequence_SetSlice16585910
Ref: 48cb16585910
Ref: c-api/sequence c PySequence_DelSlice16586216
Ref: 48c216586216
Ref: c-api/sequence c PySequence_Count16586577
Ref: 48c116586577
Ref: c-api/sequence c PySequence_Contains16586964
Ref: 48c016586964
Ref: c-api/sequence c PySequence_Index16587398
Ref: 48c716587398
Ref: c-api/sequence c PySequence_List16587761
Ref: 48c916587761
Ref: c-api/sequence c PySequence_Tuple16588240
Ref: 48cc16588240
Ref: c-api/sequence c PySequence_Fast16588788
Ref: 48c316588788
Ref: c-api/sequence c PySequence_Fast_GET_SIZE16589747
Ref: 49fa16589747
Ref: c-api/sequence c PySequence_Fast_GET_ITEM16590257
Ref: 49fb16590257
Ref: c-api/sequence c PySequence_Fast_ITEMS16590631
Ref: 49fc16590631
Ref: c-api/sequence c PySequence_ITEM16591261
Ref: 49fd16591261
Node: マップ型プロトコル mapping protocol16591680
Ref: c-api/mapping doc16591934
Ref: 49fe16591934
Ref: c-api/mapping mapping16591934
Ref: 49ff16591934
Ref: c-api/mapping mapping-protocol16591934
Ref: 4a0016591934
Ref: c-api/mapping c PyMapping_Check16592159
Ref: 487716592159
Ref: c-api/mapping c PyMapping_Size16592598
Ref: 19c116592598
Ref: c-api/mapping c PyMapping_Length16592667
Ref: 487816592667
Ref: c-api/mapping c PyMapping_GetItemString16592980
Ref: 32116592980
Ref: c-api/mapping c PyMapping_GetOptionalItem16593339
Ref: 31e16593339
Ref: c-api/mapping c PyMapping_GetOptionalItemString16594039
Ref: 31f16594039
Ref: c-api/mapping c PyMapping_SetItemString16594446
Ref: 487916594446
Ref: c-api/mapping c PyMapping_DelItem16594765
Ref: 4a0116594765
Ref: c-api/mapping c PyMapping_DelItemString16594892
Ref: 4a0216594892
Ref: c-api/mapping c PyMapping_HasKeyWithError16595142
Ref: 35716595142
Ref: c-api/mapping c PyMapping_HasKeyStringWithError16595513
Ref: 35916595513
Ref: c-api/mapping c PyMapping_HasKey16595899
Ref: 35816595899
Ref: c-api/mapping c PyMapping_HasKeyString16596594
Ref: 35a16596594
Ref: c-api/mapping c PyMapping_Keys16597279
Ref: b8a16597279
Ref: c-api/mapping c PyMapping_Values16597697
Ref: b8b16597697
Ref: c-api/mapping c PyMapping_Items16598114
Ref: b8c16598114
Node: イテレータプロトコル iterator protocol16598606
Ref: c-api/iter doc16598852
Ref: 4a0316598852
Ref: c-api/iter iterator16598852
Ref: 4a0416598852
Ref: c-api/iter iterator-protocol16598852
Ref: 4a0516598852
Ref: c-api/iter c PyIter_Check16599031
Ref: 185f16599031
Ref: c-api/iter c PyAIter_Check16599316
Ref: 47f316599316
Ref: c-api/iter c PyIter_Next16599619
Ref: 486316599619
Ref: c-api/iter c PySendResult16600741
Ref: 4a0616600741
Ref: c-api/iter c PyIter_Send16600903
Ref: 86516600903
Node: バッファプロトコル buffer Protocol16601507
Ref: c-api/buffer doc16601700
Ref: 4a0716601700
Ref: c-api/buffer buffer-protocol16601700
Ref: 4a0816601700
Ref: c-api/buffer bufferobjects16601700
Ref: 37116601700
Node: buffer 構造体16605311
Ref: c-api/buffer buffer-structure16605455
Ref: 4a0916605455
Ref: c-api/buffer id116605455
Ref: 4a0a16605455
Ref: c-api/buffer c Py_buffer16606890
Ref: 72316606890
Ref: c-api/buffer c Py_buffer buf16607051
Ref: 4a0c16607051
Ref: c-api/buffer c Py_buffer obj16607584
Ref: 4a0e16607584
Ref: c-api/buffer c Py_buffer len16608349
Ref: 4a0f16608349
Ref: c-api/buffer c Py_buffer readonly16609071
Ref: 4a1116609071
Ref: c-api/buffer c Py_buffer itemsize16609284
Ref: 4a1216609284
Ref: c-api/buffer c Py_buffer format16610393
Ref: 4a1316610393
Ref: c-api/buffer c Py_buffer ndim16610758
Ref: 4a1616610758
Ref: c-api/buffer c Py_buffer shape16611194
Ref: 4a1516611194
Ref: c-api/buffer c Py_buffer strides16611841
Ref: 4a0d16611841
Ref: c-api/buffer c Py_buffer suboffsets16612549
Ref: 4a1716612549
Ref: c-api/buffer c Py_buffer internal16613730
Ref: 4a1a16613730
Ref: c-api/buffer c PyBUF_MAX_NDIM16614308
Ref: 4a1816614308
Node: バッファリクエストのタイプ16614581
Ref: c-api/buffer buffer-request-types16614749
Ref: 101116614749
Ref: c-api/buffer id216614749
Ref: 4a1b16614749
Node: リクエストに依存しないフィールド16615546
Ref: c-api/buffer request-independent-fields16615694
Ref: 4a1c16615694
Node: readonly format16615993
Ref: c-api/buffer readonly-format16616174
Ref: 4a1d16616174
Ref: c-api/buffer c PyBUF_WRITABLE16616225
Ref: 136216616225
Ref: c-api/buffer c PyBUF_FORMAT16616704
Ref: 4a1416616704
Node: shape strides suboffsets16617604
Ref: c-api/buffer shape-strides-suboffsets16617764
Ref: 4a1e16617764
Ref: c-api/buffer c PyBUF_INDIRECT16618401
Ref: 4a1f16618401
Ref: c-api/buffer c PyBUF_STRIDES16618602
Ref: 4a2016618602
Ref: c-api/buffer c PyBUF_ND16618788
Ref: 4a2116618788
Ref: c-api/buffer c PyBUF_SIMPLE16618983
Ref: 4a1016618983
Node: 隣接性のリクエスト16619082
Ref: c-api/buffer contiguity-requests16619248
Ref: 4a2216619248
Ref: c-api/buffer c PyBUF_C_CONTIGUOUS16619968
Ref: 136316619968
Ref: c-api/buffer c PyBUF_F_CONTIGUOUS16620225
Ref: 136416620225
Ref: c-api/buffer c PyBUF_ANY_CONTIGUOUS16620484
Ref: 4a2316620484
Node: 複合リクエスト16620877
Ref: c-api/buffer compound-requests16621010
Ref: 4a2416621010
Ref: c-api/buffer c PyBUF_FULL16622042
Ref: 4a2516622042
Ref: c-api/buffer c PyBUF_FULL_RO16622381
Ref: 4a2616622381
Ref: c-api/buffer c PyBUF_RECORDS16622718
Ref: 4a2716622718
Ref: c-api/buffer c PyBUF_RECORDS_RO16623052
Ref: 4a2816623052
Ref: c-api/buffer c PyBUF_STRIDED16623381
Ref: 4a2916623381
Ref: c-api/buffer c PyBUF_STRIDED_RO16623716
Ref: 4a2a16623716
Ref: c-api/buffer c PyBUF_CONTIG16624045
Ref: 4a2b16624045
Ref: c-api/buffer c PyBUF_CONTIG_RO16624380
Ref: 4a2c16624380
Node: 複雑な配列16624571
Ref: c-api/buffer complex-arrays16624750
Ref: 4a1916624750
Node: NumPy スタイル shape strides16624967
Ref: c-api/buffer numpy-style-shape-and-strides16625101
Ref: 4a2d16625101
Node: PIL スタイル shape strides suboffsets16627190
Ref: c-api/buffer pil-style-shape-strides-and-suboffsets16627324
Ref: 4a2e16627324
Node: バッファ関連の関数16628625
Ref: c-api/buffer buffer-related-functions16628756
Ref: 4a2f16628756
Ref: c-api/buffer c PyObject_CheckBuffer16628822
Ref: 37216628822
Ref: c-api/buffer c PyObject_GetBuffer16629292
Ref: 37316629292
Ref: c-api/buffer c PyBuffer_Release16630688
Ref: 37416630688
Ref: c-api/buffer c PyBuffer_SizeFromFormat16631269
Ref: 72516631269
Ref: c-api/buffer c PyBuffer_IsContiguous16631595
Ref: 72916631595
Ref: c-api/buffer c PyBuffer_GetPointer16632144
Ref: 72416632144
Ref: c-api/buffer c PyBuffer_FromContiguous16632560
Ref: 72716632560
Ref: c-api/buffer c PyBuffer_ToContiguous16633076
Ref: 72616633076
Ref: c-api/buffer c PyObject_CopyData16633694
Ref: 72816633694
Ref: c-api/buffer c PyBuffer_FillContiguousStrides16634042
Ref: 72a16634042
Ref: c-api/buffer c PyBuffer_FillInfo16634523
Ref: 72b16634523
Node: 具象オブジェクト concrete object レイヤ16635839
Ref: c-api/concrete doc16636115
Ref: 4a3016636115
Ref: c-api/concrete concrete16636115
Ref: 4a3116636115
Ref: c-api/concrete concrete-objects-layer16636115
Ref: 4a3216636115
Node: 基本オブジェクト fundamental object16637861
Ref: c-api/concrete fundamental16638042
Ref: 4a3416638042
Ref: c-api/concrete fundamental-objects16638042
Ref: 4a3516638042
Node: 型オブジェクト<2>16638368
Ref: c-api/type doc16638504
Ref: 4a3616638504
Ref: c-api/type type-objects16638504
Ref: 4a3716638504
Ref: c-api/type typeobjects16638504
Ref: 4a3816638504
Ref: c-api/type c PyTypeObject16638558
Ref: a7316638558
Ref: c-api/type c PyType_Type16638796
Ref: 51816638796
Ref: c-api/type c PyType_Check16639055
Ref: 190916639055
Ref: c-api/type c PyType_CheckExact16639302
Ref: 190a16639302
Ref: c-api/type c PyType_ClearCache16639532
Ref: 48e916639532
Ref: c-api/type c PyType_GetFlags16639745
Ref: 18be16639745
Ref: c-api/type c PyType_GetDict16640324
Ref: 168416640324
Ref: c-api/type c PyType_Modified16641054
Ref: 175d16641054
Ref: c-api/type c PyType_AddWatcher16641422
Ref: 53016641422
Ref: c-api/type c PyType_ClearWatcher16641779
Ref: 4a3916641779
Ref: c-api/type c PyType_Watch16642251
Ref: 53116642251
Ref: c-api/type c PyType_WatchCallback16642955
Ref: 4a3a16642955
Ref: c-api/type c PyType_HasFeature16643321
Ref: 18bd16643321
Ref: c-api/type c PyType_IS_GC16643517
Ref: 4a3b16643517
Ref: c-api/type c PyType_IsSubtype16643709
Ref: 48ea16643709
Ref: c-api/type c PyType_GenericAlloc16644146
Ref: a3916644146
Ref: c-api/type c PyType_GenericNew16644644
Ref: 477716644644
Ref: c-api/type c PyType_Ready16645063
Ref: 74716645063
Ref: c-api/type c PyType_GetName16646150
Ref: 71d16646150
Ref: c-api/type c PyType_GetQualName16646471
Ref: 71e16646471
Ref: c-api/type c PyType_GetFullyQualifiedName16646820
Ref: 34c16646820
Ref: c-api/type c PyType_GetModuleName16647268
Ref: 34e16647268
Ref: c-api/type c PyType_GetSlot16647578
Ref: 86916647578
Ref: c-api/type c PyType_GetModule16648344
Ref: 93c16648344
Ref: c-api/type c PyType_GetModuleState16649315
Ref: 93d16649315
Ref: c-api/type c PyType_GetModuleByDef16649927
Ref: 36d16649927
Ref: c-api/type c PyUnstable_Type_AssignVersionTag16650694
Ref: 4a3e16650694
Node: Creating Heap-Allocated Types16651279
Ref: c-api/type creating-heap-allocated-types16651369
Ref: 4a3f16651369
Ref: c-api/type c PyType_FromMetaclass16651525
Ref: 51b16651525
Ref: c-api/type c PyType_FromModuleAndSpec16653967
Ref: 51c16653967
Ref: c-api/type c PyType_FromSpecWithBases16654913
Ref: 54a16654913
Ref: c-api/type c PyType_FromSpec16655690
Ref: 54916655690
Ref: c-api/type c PyType_Spec16656390
Ref: 168116656390
Ref: c-api/type c PyType_Spec name16656562
Ref: 4a4016656562
Ref: c-api/type c PyType_Spec basicsize16656696
Ref: 51316656696
Ref: c-api/type c PyType_Spec itemsize16657330
Ref: 4a4116657330
Ref: c-api/type c PyType_Spec flags16658463
Ref: 4a4216658463
Ref: c-api/type c PyType_Spec slots16658717
Ref: 4a4316658717
Ref: c-api/type c PyType_Slot16658961
Ref: 48eb16658961
Ref: c-api/type c PyType_Slot slot16659195
Ref: 4a3c16659195
Ref: c-api/type c PyType_Slot pfunc16661808
Ref: 4a4d16661808
Node: None オブジェクト16662020
Ref: c-api/none doc16662156
Ref: 4a4e16662156
Ref: c-api/none noneobject16662156
Ref: 4a4f16662156
Ref: c-api/none the-none-object16662156
Ref: 4a5016662156
Ref: c-api/none c Py_None16662587
Ref: 474c16662587
Ref: c-api/none c Py_RETURN_NONE16662899
Ref: 141816662899
Node: 数値型オブジェクト numeric object16662994
Ref: c-api/concrete numeric-objects16663233
Ref: 4a5116663233
Ref: c-api/concrete numericobjects16663233
Ref: 4a5216663233
Node: 整数型オブジェクト integer object16663519
Ref: c-api/long doc16663675
Ref: 4a5316663675
Ref: c-api/long integer-objects16663675
Ref: 4a5416663675
Ref: c-api/long longobjects16663675
Ref: 4a5516663675
Ref: c-api/long c PyLongObject16664119
Ref: 55416664119
Ref: c-api/long c PyLong_Type16664334
Ref: 487616664334
Ref: c-api/long c PyLong_Check16664635
Ref: 4a5616664635
Ref: c-api/long c PyLong_CheckExact16664857
Ref: 4a5716664857
Ref: c-api/long c PyLong_FromLong16665093
Ref: 17a416665093
Ref: c-api/long c PyLong_FromUnsignedLong16665691
Ref: 192c16665691
Ref: c-api/long c PyLong_FromSsize_t16666037
Ref: 487216666037
Ref: c-api/long c PyLong_FromSize_t16666379
Ref: 192e16666379
Ref: c-api/long c PyLong_FromLongLong16666706
Ref: 17a516666706
Ref: c-api/long c PyLong_FromUnsignedLongLong16667034
Ref: 192d16667034
Ref: c-api/long c PyLong_FromDouble16667398
Ref: 91016667398
Ref: c-api/long c PyLong_FromString16667718
Ref: 487316667718
Ref: c-api/long c PyLong_FromUnicodeObject16669061
Ref: 88816669061
Ref: c-api/long c PyLong_FromVoidPtr16669312
Ref: 487416669312
Ref: c-api/long c PyLong_FromNativeBytes16669639
Ref: 33b16669639
Ref: c-api/long c PyLong_FromUnsignedNativeBytes16670318
Ref: 33c16670318
Ref: c-api/long c PyLong_AsLong16670859
Ref: 33916670859
Ref: c-api/long c PyLong_AS_LONG16671683
Ref: 4a5816671683
Ref: c-api/long c PyLong_AsInt16672028
Ref: 33816672028
Ref: c-api/long c PyLong_AsLongAndOverflow16672292
Ref: 123716672292
Ref: c-api/long c PyLong_AsLongLong16673337
Ref: 486c16673337
Ref: c-api/long c PyLong_AsLongLongAndOverflow16674180
Ref: 123816674180
Ref: c-api/long c PyLong_AsSsize_t16675269
Ref: 486e16675269
Ref: c-api/long c PyLong_AsUnsignedLong16675866
Ref: 486f16675866
Ref: c-api/long c PyLong_AsSize_t16676457
Ref: 486d16676457
Ref: c-api/long c PyLong_AsUnsignedLongLong16677026
Ref: 126516677026
Ref: c-api/long c PyLong_AsUnsignedLongMask16677841
Ref: 487016677841
Ref: c-api/long c PyLong_AsUnsignedLongLongMask16678735
Ref: 195116678735
Ref: c-api/long c PyLong_AsDouble16679664
Ref: 486b16679664
Ref: c-api/long c PyLong_AsVoidPtr16680215
Ref: 487116680215
Ref: c-api/long c PyLong_AsNativeBytes16680840
Ref: 33a16680840
Ref: c-api/long c Py_ASNATIVEBYTES_DEFAULTS16684992
Ref: 4a5916684992
Ref: c-api/long c Py_ASNATIVEBYTES_BIG_ENDIAN16685174
Ref: 4a5a16685174
Ref: c-api/long c Py_ASNATIVEBYTES_LITTLE_ENDIAN16685356
Ref: 4a5b16685356
Ref: c-api/long c Py_ASNATIVEBYTES_NATIVE_ENDIAN16685535
Ref: 4a5c16685535
Ref: c-api/long c Py_ASNATIVEBYTES_UNSIGNED_BUFFER16685683
Ref: 4a5d16685683
Ref: c-api/long c Py_ASNATIVEBYTES_REJECT_NEGATIVE16685807
Ref: 4a5e16685807
Ref: c-api/long c Py_ASNATIVEBYTES_ALLOW_INDEX16685960
Ref: 4a5f16685960
Ref: c-api/long c PyLong_GetInfo16687903
Ref: 487516687903
Ref: c-api/long c PyUnstable_Long_IsCompact16688318
Ref: 55516688318
Ref: c-api/long c PyUnstable_Long_CompactValue16689189
Ref: 55616689189
Node: Boolean オブジェクト16689723
Ref: c-api/bool doc16689910
Ref: 4a6016689910
Ref: c-api/bool boolean-objects16689910
Ref: 4a6116689910
Ref: c-api/bool boolobjects16689910
Ref: 4a6216689910
Ref: c-api/bool c PyBool_Type16690314
Ref: 47f716690314
Ref: c-api/bool c PyBool_Check16690611
Ref: 4a6516690611
Ref: c-api/bool c Py_False16690781
Ref: 4a6316690781
Ref: c-api/bool c Py_True16691071
Ref: 4a6416691071
Ref: c-api/bool c Py_RETURN_FALSE16691357
Ref: 141a16691357
Ref: c-api/bool c Py_RETURN_TRUE16691454
Ref: 141916691454
Ref: c-api/bool c PyBool_FromLong16691549
Ref: 47f616691549
Node: Floating-Point Objects16691808
Ref: c-api/float doc16691980
Ref: 4a6616691980
Ref: c-api/float floating-point-objects16691980
Ref: 4a6716691980
Ref: c-api/float floatobjects16691980
Ref: 4a6816691980
Ref: c-api/float c PyFloatObject16692043
Ref: 4a6916692043
Ref: c-api/float c PyFloat_Type16692177
Ref: 485316692177
Ref: c-api/float c PyFloat_Check16692444
Ref: 4a6a16692444
Ref: c-api/float c PyFloat_CheckExact16692671
Ref: 4a6b16692671
Ref: c-api/float c PyFloat_FromString16692917
Ref: 485216692917
Ref: c-api/float c PyFloat_FromDouble16693231
Ref: 485116693231
Ref: c-api/float c PyFloat_AsDouble16693528
Ref: a3716693528
Ref: c-api/float c PyFloat_AS_DOUBLE16694224
Ref: 4a6c16694224
Ref: c-api/float c PyFloat_GetInfo16694414
Ref: 139816694414
Ref: c-api/float c PyFloat_GetMax16694753
Ref: 139616694753
Ref: c-api/float c PyFloat_GetMin16694943
Ref: 139716694943
Node: Pack and Unpack functions16695179
Ref: c-api/float pack-and-unpack-functions16695263
Ref: 4a6d16695263
Node: Pack functions16696562
Ref: c-api/float pack-functions16696663
Ref: 4a6e16696663
Ref: c-api/float c PyFloat_Pack216697437
Ref: 73016697437
Ref: c-api/float c PyFloat_Pack416697580
Ref: 73116697580
Ref: c-api/float c PyFloat_Pack816697725
Ref: 73216697725
Node: Unpack functions16697870
Ref: c-api/float unpack-functions16697971
Ref: 4a6f16697971
Ref: c-api/float c PyFloat_Unpack216698722
Ref: 73316698722
Ref: c-api/float c PyFloat_Unpack416698868
Ref: 73416698868
Ref: c-api/float c PyFloat_Unpack816699016
Ref: 73516699016
Node: 複素数オブジェクト16699164
Ref: c-api/complex doc16699301
Ref: 4a7016699301
Ref: c-api/complex complex-number-objects16699301
Ref: 4a7116699301
Ref: c-api/complex complexobjects16699301
Ref: 4a7216699301
Node: C 構造体としての複素数16699833
Ref: c-api/complex complex-numbers-as-c-structures16699987
Ref: 4a7316699987
Ref: c-api/complex c Py_complex16700325
Ref: 49a916700325
Ref: c-api/complex c Py_complex real16700610
Ref: 4a7416700610
Ref: c-api/complex c Py_complex imag16700653
Ref: 4a7516700653
Ref: c-api/complex c _Py_c_sum16700838
Ref: 4a7616700838
Ref: c-api/complex c _Py_c_diff16701022
Ref: 4a7716701022
Ref: c-api/complex c _Py_c_neg16701207
Ref: 4a7816701207
Ref: c-api/complex c _Py_c_prod16701366
Ref: 4a7916701366
Ref: c-api/complex c _Py_c_quot16701551
Ref: 4a7a16701551
Ref: c-api/complex c _Py_c_pow16701879
Ref: 4a7b16701879
Node: Python オブジェクトとしての複素数型16702233
Ref: c-api/complex complex-numbers-as-python-objects16702387
Ref: 4a7c16702387
Ref: c-api/complex c PyComplexObject16702490
Ref: 4a7d16702490
Ref: c-api/complex c PyComplex_Type16702641
Ref: 482416702641
Ref: c-api/complex c PyComplex_Check16702936
Ref: 4a7e16702936
Ref: c-api/complex c PyComplex_CheckExact16703168
Ref: 4a7f16703168
Ref: c-api/complex c PyComplex_FromCComplex16703420
Ref: 4a8016703420
Ref: c-api/complex c PyComplex_FromDoubles16703688
Ref: 482316703688
Ref: c-api/complex c PyComplex_RealAsDouble16704003
Ref: 15fb16704003
Ref: c-api/complex c PyComplex_ImagAsDouble16704734
Ref: 15fc16704734
Ref: c-api/complex c PyComplex_AsCComplex16705475
Ref: 139916705475
Node: シーケンスオブジェクト sequence object16706351
Ref: c-api/concrete sequence-objects16706575
Ref: 4a8116706575
Ref: c-api/concrete sequenceobjects16706575
Ref: 4a8216706575
Node: バイトオブジェクト<2>16707271
Ref: c-api/bytes doc16707427
Ref: 4a8316707427
Ref: c-api/bytes bytes-objects16707427
Ref: 4a8416707427
Ref: c-api/bytes bytesobjects16707427
Ref: 4a8516707427
Ref: c-api/bytes c PyBytesObject16707704
Ref: 75d16707704
Ref: c-api/bytes c PyBytes_Type16707864
Ref: 480416707864
Ref: c-api/bytes c PyBytes_Check16708148
Ref: 135c16708148
Ref: c-api/bytes c PyBytes_CheckExact16708392
Ref: 4a8616708392
Ref: c-api/bytes c PyBytes_FromString16708644
Ref: 480216708644
Ref: c-api/bytes c PyBytes_FromStringAndSize16709068
Ref: 135d16709068
Ref: c-api/bytes c PyBytes_FromFormat16709551
Ref: 199416709551
Ref: c-api/bytes c PyBytes_FromFormatV16713374
Ref: 480016713374
Ref: c-api/bytes c PyBytes_FromObject16713685
Ref: 480116713685
Ref: c-api/bytes c PyBytes_Size16713949
Ref: 480316713949
Ref: c-api/bytes c PyBytes_GET_SIZE16714153
Ref: 4a8716714153
Ref: c-api/bytes c PyBytes_AsString16714332
Ref: 85416714332
Ref: c-api/bytes c PyBytes_AS_STRING16715135
Ref: 4a8816715135
Ref: c-api/bytes c PyBytes_AsStringAndSize16715306
Ref: 47fd16715306
Ref: c-api/bytes c PyBytes_Concat16716653
Ref: 47fe16716653
Ref: c-api/bytes c PyBytes_ConcatAndDel16717240
Ref: 47ff16717240
Ref: c-api/bytes c _PyBytes_Resize16717604
Ref: 15b816717604
Ref: バイトオブジェクト<2>-Footnote-116718362
Ref: バイトオブジェクト<2>-Footnote-216718482
Ref: バイトオブジェクト<2>-Footnote-316718602
Ref: バイトオブジェクト<2>-Footnote-416718722
Ref: バイトオブジェクト<2>-Footnote-516718842
Ref: バイトオブジェクト<2>-Footnote-616718962
Ref: バイトオブジェクト<2>-Footnote-716719082
Ref: バイトオブジェクト<2>-Footnote-816719202
Node: bytearray オブジェクト<2>16719322
Ref: c-api/bytearray doc16719522
Ref: 4a8916719522
Ref: c-api/bytearray byte-array-objects16719522
Ref: 4a8a16719522
Ref: c-api/bytearray bytearrayobjects16719522
Ref: 4a8b16719522
Ref: c-api/bytearray c PyByteArrayObject16719591
Ref: 4a8c16719591
Ref: c-api/bytearray c PyByteArray_Type16719758
Ref: 47fc16719758
Node: 型チェックマクロ16720143
Ref: c-api/bytearray type-check-macros16720270
Ref: 4a8d16720270
Ref: c-api/bytearray c PyByteArray_Check16720329
Ref: 4a8e16720329
Ref: c-api/bytearray c PyByteArray_CheckExact16720591
Ref: 4a8f16720591
Node: ダイレクト API 関数16720861
Ref: c-api/bytearray direct-api-functions16721006
Ref: 4a9016721006
Ref: c-api/bytearray c PyByteArray_FromObject16721070
Ref: 135e16721070
Ref: c-api/bytearray c PyByteArray_FromStringAndSize16721450
Ref: 135f16721450
Ref: c-api/bytearray c PyByteArray_Concat16721780
Ref: 47f916721780
Ref: c-api/bytearray c PyByteArray_Size16722119
Ref: 47fb16722119
Ref: c-api/bytearray c PyByteArray_AsString16722355
Ref: 47f816722355
Ref: c-api/bytearray c PyByteArray_Resize16722674
Ref: 47fa16722674
Node: マクロ16722892
Ref: c-api/bytearray macros16723004
Ref: 4a9116723004
Ref: c-api/bytearray c PyByteArray_AS_STRING16723185
Ref: 4a9216723185
Ref: c-api/bytearray c PyByteArray_GET_SIZE16723368
Ref: 4a9316723368
Node: Unicode オブジェクトと codec16723573
Ref: c-api/unicode doc16723783
Ref: 117116723783
Ref: c-api/unicode unicode-objects-and-codecs16723783
Ref: 4a9416723783
Ref: c-api/unicode unicodeobjects16723783
Ref: 4a9516723783
Node: Unicode オブジェクト16724094
Ref: c-api/unicode unicode-objects16724234
Ref: 4a9616724234
Ref: Unicode オブジェクト-Footnote-116725283
Ref: Unicode オブジェクト-Footnote-216725325
Node: Unicode 型16725367
Ref: c-api/unicode unicode-type16725479
Ref: 4a9716725479
Ref: c-api/unicode c Py_UCS416725624
Ref: 27b16725624
Ref: c-api/unicode c Py_UCS216725660
Ref: 114716725660
Ref: c-api/unicode c Py_UCS116725696
Ref: 114616725696
Ref: c-api/unicode c Py_UNICODE16726099
Ref: 3c716726099
Ref: c-api/unicode c PyASCIIObject16726634
Ref: 114816726634
Ref: c-api/unicode c PyCompactUnicodeObject16726676
Ref: 114916726676
Ref: c-api/unicode c PyUnicodeObject16726727
Ref: 75f16726727
Ref: c-api/unicode c PyUnicode_Type16727187
Ref: 492416727187
Ref: c-api/unicode c PyUnicode_Check16727607
Ref: 4a9816727607
Ref: c-api/unicode c PyUnicode_CheckExact16727861
Ref: 4a9916727861
Ref: c-api/unicode c PyUnicode_READY16728108
Ref: 3da16728108
Ref: c-api/unicode c PyUnicode_GET_LENGTH16728350
Ref: 88216728350
Ref: c-api/unicode c PyUnicode_1BYTE_DATA16728701
Ref: 114d16728701
Ref: c-api/unicode c PyUnicode_2BYTE_DATA16728791
Ref: 114e16728791
Ref: c-api/unicode c PyUnicode_4BYTE_DATA16728881
Ref: 114f16728881
Ref: c-api/unicode c PyUnicode_1BYTE_KIND16729383
Ref: 115116729383
Ref: c-api/unicode c PyUnicode_2BYTE_KIND16729424
Ref: 115216729424
Ref: c-api/unicode c PyUnicode_4BYTE_KIND16729465
Ref: 115316729465
Ref: c-api/unicode c PyUnicode_KIND16729695
Ref: 115016729695
Ref: c-api/unicode c PyUnicode_DATA16730137
Ref: 114c16730137
Ref: c-api/unicode c PyUnicode_WRITE16730453
Ref: 115616730453
Ref: c-api/unicode c PyUnicode_READ16731143
Ref: 115416731143
Ref: c-api/unicode c PyUnicode_READ_CHAR16731522
Ref: 115516731522
Ref: c-api/unicode c PyUnicode_MAX_CHAR_VALUE16731975
Ref: 115716731975
Ref: c-api/unicode c PyUnicode_IsIdentifier16732422
Ref: 190816732422
Node: Unicode 文字プロパティ16732915
Ref: c-api/unicode unicode-character-properties16733077
Ref: 4a9a16733077
Ref: c-api/unicode c Py_UNICODE_ISSPACE16733450
Ref: 187016733450
Ref: c-api/unicode c Py_UNICODE_ISLOWER16733600
Ref: 4a9b16733600
Ref: c-api/unicode c Py_UNICODE_ISUPPER16733747
Ref: 4a9c16733747
Ref: c-api/unicode c Py_UNICODE_ISTITLE16733894
Ref: 4a9d16733894
Ref: c-api/unicode c Py_UNICODE_ISLINEBREAK16734087
Ref: 4a9e16734087
Ref: c-api/unicode c Py_UNICODE_ISDECIMAL16734241
Ref: 4a9f16734241
Ref: c-api/unicode c Py_UNICODE_ISDIGIT16734396
Ref: 4aa016734396
Ref: c-api/unicode c Py_UNICODE_ISNUMERIC16734547
Ref: 4aa116734547
Ref: c-api/unicode c Py_UNICODE_ISALPHA16734716
Ref: 4aa216734716
Ref: c-api/unicode c Py_UNICODE_ISALNUM16734887
Ref: 4aa316734887
Ref: c-api/unicode c Py_UNICODE_ISPRINTABLE16735037
Ref: 4aa416735037
Ref: c-api/unicode c Py_UNICODE_TOLOWER16735835
Ref: 4aa516735835
Ref: c-api/unicode c Py_UNICODE_TOUPPER16735968
Ref: 4aa616735968
Ref: c-api/unicode c Py_UNICODE_TOTITLE16736101
Ref: 4aa716736101
Ref: c-api/unicode c Py_UNICODE_TODECIMAL16736252
Ref: 4aa816736252
Ref: c-api/unicode c Py_UNICODE_TODIGIT16736474
Ref: 4aa916736474
Ref: c-api/unicode c Py_UNICODE_TONUMERIC16736690
Ref: 4aaa16736690
Ref: c-api/unicode c Py_UNICODE_IS_SURROGATE16736966
Ref: 4aab16736966
Ref: c-api/unicode c Py_UNICODE_IS_HIGH_SURROGATE16737132
Ref: 4aac16737132
Ref: c-api/unicode c Py_UNICODE_IS_LOW_SURROGATE16737309
Ref: 4aad16737309
Ref: c-api/unicode c Py_UNICODE_JOIN_SURROGATES16737485
Ref: 4aae16737485
Node: Unicode 文字列の生成とアクセス16737879
Ref: c-api/unicode creating-and-accessing-unicode-strings16738066
Ref: 4aaf16738066
Ref: c-api/unicode c PyUnicode_New16738351
Ref: 87916738351
Ref: c-api/unicode c PyUnicode_FromKindAndData16739049
Ref: 114a16739049
Ref: c-api/unicode c PyUnicode_FromStringAndSize16739970
Ref: 491e16739970
Ref: c-api/unicode c PyUnicode_FromString16740654
Ref: 47be16740654
Ref: c-api/unicode c PyUnicode_FromFormat16740960
Ref: 36316740960
Ref: c-api/unicode c PyUnicode_FromFormatV16753920
Ref: 54016753920
Ref: c-api/unicode c PyUnicode_FromObject16754234
Ref: 491d16754234
Ref: c-api/unicode c PyUnicode_FromEncodedObject16754737
Ref: 491c16754737
Ref: c-api/unicode c PyUnicode_GetLength16755900
Ref: 88116755900
Ref: c-api/unicode c PyUnicode_CopyCharacters16756237
Ref: 88316756237
Ref: c-api/unicode c PyUnicode_Fill16756802
Ref: 116016756802
Ref: c-api/unicode c PyUnicode_WriteChar16757376
Ref: 114516757376
Ref: c-api/unicode c PyUnicode_ReadChar16758248
Ref: 114416758248
Ref: c-api/unicode c PyUnicode_Substring16758847
Ref: 88416758847
Ref: c-api/unicode c PyUnicode_AsUCS416759330
Ref: 114b16759330
Ref: c-api/unicode c PyUnicode_AsUCS4Copy16759879
Ref: 88916759879
Node: ロケールエンコーディング16760434
Ref: c-api/unicode locale-encoding16760640
Ref: 4ab116760640
Ref: c-api/unicode c PyUnicode_DecodeLocaleAndSize16760865
Ref: b9716760865
Ref: c-api/unicode c PyUnicode_DecodeLocale16762205
Ref: 490e16762205
Ref: c-api/unicode c PyUnicode_EncodeLocale16762580
Ref: b9816762580
Ref: ロケールエンコーディング-Footnote-116763933
Ref: ロケールエンコーディング-Footnote-216763975
Node: ファイルシステムエンコーディング16764017
Ref: c-api/unicode file-system-encoding16764202
Ref: 4ab216764202
Ref: c-api/unicode c PyUnicode_FSConverter16764609
Ref: ce716764609
Ref: c-api/unicode c PyUnicode_FSDecoder16765461
Ref: 54316765461
Ref: c-api/unicode c PyUnicode_DecodeFSDefaultAndSize16766120
Ref: 490c16766120
Ref: c-api/unicode c PyUnicode_DecodeFSDefault16766694
Ref: 168016766694
Ref: c-api/unicode c PyUnicode_EncodeFSDefault16767161
Ref: 19bc16767161
Ref: ファイルシステムエンコーディング-Footnote-116767882
Ref: ファイルシステムエンコーディング-Footnote-216767924
Node: wchar_t サポート16767966
Ref: c-api/unicode wchar-t-support16768106
Ref: 4ab316768106
Ref: c-api/unicode c PyUnicode_FromWideChar16768252
Ref: 115f16768252
Ref: c-api/unicode c PyUnicode_AsWideChar16768693
Ref: 19c216768693
Ref: c-api/unicode c PyUnicode_AsWideCharString16769696
Ref: 88a16769696
Node: 組み込み codec built-in codec16770853
Ref: c-api/unicode built-in-codecs16771055
Ref: 4ab416771055
Ref: c-api/unicode builtincodecs16771055
Ref: 4ab016771055
Node: 汎用 codec16772727
Ref: c-api/unicode generic-codecs16772830
Ref: 4ab516772830
Ref: c-api/unicode c PyUnicode_Decode16772912
Ref: 194d16772912
Ref: c-api/unicode c PyUnicode_AsEncodedString16773495
Ref: 490516773495
Node: UTF-8 Codecs16774189
Ref: c-api/unicode utf-8-codecs16774314
Ref: 4ab616774314
Ref: c-api/unicode c PyUnicode_DecodeUTF816774397
Ref: 491816774397
Ref: c-api/unicode c PyUnicode_DecodeUTF8Stateful16774818
Ref: 170a16774818
Ref: c-api/unicode c PyUnicode_AsUTF8String16775448
Ref: 116116775448
Ref: c-api/unicode c PyUnicode_AsUTF8AndSize16775988
Ref: 86616775988
Ref: c-api/unicode c PyUnicode_AsUTF816777508
Ref: b8916777508
Node: UTF-32 Codecs16777842
Ref: c-api/unicode utf-32-codecs16777968
Ref: 4ab716777968
Ref: c-api/unicode c PyUnicode_DecodeUTF3216778051
Ref: 491416778051
Ref: c-api/unicode c PyUnicode_DecodeUTF32Stateful16779543
Ref: 491516779543
Ref: c-api/unicode c PyUnicode_AsUTF32String16780318
Ref: 490716780318
Node: UTF-16 Codecs16780815
Ref: c-api/unicode utf-16-codecs16780941
Ref: 4ab816780941
Ref: c-api/unicode c PyUnicode_DecodeUTF1616781027
Ref: 491216781027
Ref: c-api/unicode c PyUnicode_DecodeUTF16Stateful16782639
Ref: 491316782639
Ref: c-api/unicode c PyUnicode_AsUTF16String16783404
Ref: 490616783404
Node: UTF-7 Codecs16783901
Ref: c-api/unicode utf-7-codecs16784035
Ref: 4ab916784035
Ref: c-api/unicode c PyUnicode_DecodeUTF716784119
Ref: 491616784119
Ref: c-api/unicode c PyUnicode_DecodeUTF7Stateful16784486
Ref: 491716784486
Node: Unicode-Escape Codecs16785112
Ref: c-api/unicode unicode-escape-codecs16785258
Ref: 4aba16785258
Ref: c-api/unicode c PyUnicode_DecodeUnicodeEscape16785371
Ref: 491916785371
Ref: c-api/unicode c PyUnicode_AsUnicodeEscapeString16785756
Ref: 116216785756
Node: Raw-Unicode-Escape Codecs16786200
Ref: c-api/unicode raw-unicode-escape-codecs16786348
Ref: 4abb16786348
Ref: c-api/unicode c PyUnicode_DecodeRawUnicodeEscape16786472
Ref: 491116786472
Ref: c-api/unicode c PyUnicode_AsRawUnicodeEscapeString16786864
Ref: 116316786864
Node: Latin-1 Codecs16787316
Ref: c-api/unicode latin-1-codecs16787455
Ref: 4abc16787455
Ref: c-api/unicode c PyUnicode_DecodeLatin116787675
Ref: 490d16787675
Ref: c-api/unicode c PyUnicode_AsLatin1String16788099
Ref: 116416788099
Node: ASCII Codecs16788531
Ref: c-api/unicode ascii-codecs16788665
Ref: 4abd16788665
Ref: c-api/unicode c PyUnicode_DecodeASCII16788860
Ref: 490a16788860
Ref: c-api/unicode c PyUnicode_AsASCIIString16789228
Ref: 116516789228
Node: Character Map Codecs16789658
Ref: c-api/unicode character-map-codecs16789803
Ref: 4abe16789803
Ref: c-api/unicode c PyUnicode_DecodeCharmap16790471
Ref: 490b16790471
Ref: c-api/unicode c PyUnicode_AsCharmapString16791463
Ref: 490416791463
Ref: c-api/unicode c PyUnicode_Translate16792367
Ref: 492316792367
Node: Windows 用の MBCS codec16793420
Ref: c-api/unicode mbcs-codecs-for-windows16793580
Ref: 4abf16793580
Ref: c-api/unicode c PyUnicode_DecodeMBCS16794187
Ref: 490f16794187
Ref: c-api/unicode c PyUnicode_DecodeMBCSStateful16794595
Ref: 491016794595
Ref: c-api/unicode c PyUnicode_AsMBCSString16795268
Ref: 116616795268
Ref: c-api/unicode c PyUnicode_EncodeCodePage16795749
Ref: 116716795749
Node: メソッドとスロット16796254
Ref: c-api/unicode methods-slots16796385
Ref: 4ac016796385
Node: メソッドおよびスロット関数 slot function16796451
Ref: c-api/unicode methods-and-slot-functions16796618
Ref: 4ac116796618
Ref: c-api/unicode unicodemethodsandslots16796618
Ref: 4ac216796618
Ref: c-api/unicode c PyUnicode_Concat16797094
Ref: 117216797094
Ref: c-api/unicode c PyUnicode_Split16797369
Ref: 492116797369
Ref: c-api/unicode c PyUnicode_Splitlines16798067
Ref: 492216798067
Ref: c-api/unicode c PyUnicode_Join16798488
Ref: 117316798488
Ref: c-api/unicode c PyUnicode_Tailmatch16798824
Ref: 88616798824
Ref: c-api/unicode c PyUnicode_Find16799292
Ref: 491a16799292
Ref: c-api/unicode c PyUnicode_FindChar16800052
Ref: 88716800052
Ref: c-api/unicode c PyUnicode_Count16800987
Ref: 490916800987
Ref: c-api/unicode c PyUnicode_Replace16801355
Ref: 491f16801355
Ref: c-api/unicode c PyUnicode_Compare16801870
Ref: 88516801870
Ref: c-api/unicode c PyUnicode_EqualToUTF8AndSize16802411
Ref: 34f16802411
Ref: c-api/unicode c PyUnicode_EqualToUTF816803038
Ref: 35016803038
Ref: c-api/unicode c PyUnicode_CompareWithASCIIString16803440
Ref: 123916803440
Ref: c-api/unicode c PyUnicode_RichCompare16804126
Ref: 492016804126
Ref: c-api/unicode c PyUnicode_Format16804869
Ref: 491b16804869
Ref: c-api/unicode c PyUnicode_Contains16805233
Ref: 490816805233
Ref: c-api/unicode c PyUnicode_InternInPlace16805646
Ref: 87f16805646
Ref: c-api/unicode c PyUnicode_InternFromString16807028
Ref: 156216807028
Node: タプルオブジェクト tuple object16807977
Ref: c-api/tuple doc16808190
Ref: 4ac316808190
Ref: c-api/tuple tuple-objects16808190
Ref: 4ac416808190
Ref: c-api/tuple tupleobjects16808190
Ref: 4ac516808190
Ref: c-api/tuple c PyTupleObject16808286
Ref: 499316808286
Ref: c-api/tuple c PyTuple_Type16808450
Ref: 48e816808450
Ref: c-api/tuple c PyTuple_Check16808749
Ref: 4ac616808749
Ref: c-api/tuple c PyTuple_CheckExact16808978
Ref: 4ac716808978
Ref: c-api/tuple c PyTuple_New16809215
Ref: 37716809215
Ref: c-api/tuple c PyTuple_Pack16809465
Ref: 48e616809465
Ref: c-api/tuple c PyTuple_Size16809904
Ref: 48e716809904
Ref: c-api/tuple c PyTuple_GET_SIZE16810157
Ref: 4ac816810157
Ref: c-api/tuple c PyTuple_GetItem16810296
Ref: 476316810296
Ref: c-api/tuple c PyTuple_GET_ITEM16811006
Ref: 4ac916811006
Ref: c-api/tuple c PyTuple_GetSlice16811259
Ref: 48e516811259
Ref: c-api/tuple c PyTuple_SetItem16811718
Ref: 476416811718
Ref: c-api/tuple c PyTuple_SET_ITEM16812399
Ref: 36616812399
Ref: c-api/tuple c _PyTuple_Resize16813242
Ref: 14b616813242
Node: Struct Sequence オブジェクト16814326
Ref: c-api/tuple id116814531
Ref: 4aca16814531
Ref: c-api/tuple struct-sequence-objects16814531
Ref: 118f16814531
Ref: c-api/tuple c PyStructSequence_NewType16814964
Ref: 48d816814964
Ref: c-api/tuple c PyStructSequence_InitType16815421
Ref: fcd16815421
Ref: c-api/tuple c PyStructSequence_InitType216815635
Ref: fce16815635
Ref: c-api/tuple c PyStructSequence_Desc16815906
Ref: b8816815906
Ref: c-api/tuple c PyStructSequence_Desc name16816123
Ref: 4acb16816123
Ref: c-api/tuple c PyStructSequence_Desc doc16816298
Ref: 4acc16816298
Ref: c-api/tuple c PyStructSequence_Desc fields16816414
Ref: 4acd16816414
Ref: c-api/tuple c PyStructSequence_Desc n_in_sequence16816583
Ref: 4ace16816583
Ref: c-api/tuple c PyStructSequence_Field16816718
Ref: b8716816718
Ref: c-api/tuple c PyStructSequence_Field name16817159
Ref: 4acf16817159
Ref: c-api/tuple c PyStructSequence_Field doc16817372
Ref: 4ad016817372
Ref: c-api/tuple c PyStructSequence_UnnamedField16817470
Ref: 95016817470
Ref: c-api/tuple c PyStructSequence_New16817783
Ref: 48d716817783
Ref: c-api/tuple c PyStructSequence_GetItem16818199
Ref: 48d616818199
Ref: c-api/tuple c PyStructSequence_GET_ITEM16818604
Ref: 4ad116818604
Ref: c-api/tuple c PyStructSequence_SetItem16818912
Ref: 48d916818912
Ref: c-api/tuple c PyStructSequence_SET_ITEM16819513
Ref: 4ad216819513
Node: リストオブジェクト16819785
Ref: c-api/list doc16819941
Ref: 4ad316819941
Ref: c-api/list list-objects16819941
Ref: 4ad416819941
Ref: c-api/list listobjects16819941
Ref: 4ad516819941
Ref: c-api/list c PyListObject16820007
Ref: 49f916820007
Ref: c-api/list c PyList_Type16820170
Ref: 478716820170
Ref: c-api/list c PyList_Check16820477
Ref: 4ad616820477
Ref: c-api/list c PyList_CheckExact16820705
Ref: 4ad716820705
Ref: c-api/list c PyList_New16820941
Ref: 47db16820941
Ref: c-api/list c PyList_Size16821768
Ref: 13c116821768
Ref: c-api/list c PyList_GET_SIZE16822037
Ref: 4ad816822037
Ref: c-api/list c PyList_GetItemRef16822217
Ref: 33416822217
Ref: c-api/list c PyList_GetItem16822769
Ref: 33516822769
Ref: c-api/list c PyList_GET_ITEM16823083
Ref: 47ef16823083
Ref: c-api/list c PyList_SetItem16823316
Ref: 476516823316
Ref: c-api/list c PyList_SET_ITEM16823994
Ref: 36716823994
Ref: c-api/list c PyList_Insert16824909
Ref: 486716824909
Ref: c-api/list c PyList_Append16825337
Ref: 486416825337
Ref: c-api/list c PyList_GetSlice16825704
Ref: 486616825704
Ref: c-api/list c PyList_SetSlice16826249
Ref: 486916826249
Ref: c-api/list c PyList_Extend16826903
Ref: 33616826903
Ref: c-api/list c PyList_Clear16827347
Ref: 33716827347
Ref: c-api/list c PyList_Sort16827722
Ref: 486a16827722
Ref: c-api/list c PyList_Reverse16828026
Ref: 486816828026
Ref: c-api/list c PyList_AsTuple16828333
Ref: 486516828333
Node: Container オブジェクト16828616
Ref: c-api/concrete container-objects16828828
Ref: 4ad916828828
Ref: c-api/concrete mapobjects16828828
Ref: 4ada16828828
Node: 辞書オブジェクト dictionary object16829022
Ref: c-api/dict doc16829160
Ref: 4adb16829160
Ref: c-api/dict dictionary-objects16829160
Ref: 4adc16829160
Ref: c-api/dict dictobjects16829160
Ref: 4add16829160
Ref: c-api/dict c PyDictObject16829259
Ref: 39b16829259
Ref: c-api/dict c PyDict_Type16829419
Ref: 483216829419
Ref: c-api/dict c PyDict_Check16829741
Ref: 4a3316829741
Ref: c-api/dict c PyDict_CheckExact16829963
Ref: 4ade16829963
Ref: c-api/dict c PyDict_New16830193
Ref: 483016830193
Ref: c-api/dict c PyDictProxy_New16830422
Ref: 482816830422
Ref: c-api/dict c PyDict_Clear16830940
Ref: 482916830940
Ref: c-api/dict c PyDict_Contains16831142
Ref: 31116831142
Ref: c-api/dict c PyDict_ContainsString16831571
Ref: 31016831571
Ref: c-api/dict c PyDict_Copy16831846
Ref: 3f916831846
Ref: c-api/dict c PyDict_SetItem16832080
Ref: 476616832080
Ref: c-api/dict c PyDict_SetItemString16832645
Ref: 156316832645
Ref: c-api/dict c PyDict_DelItem16832961
Ref: 482a16832961
Ref: c-api/dict c PyDict_DelItemString16833499
Ref: 482b16833499
Ref: c-api/dict c PyDict_GetItemRef16833790
Ref: 31316833790
Ref: c-api/dict c PyDict_GetItem16834455
Ref: 36016834455
Ref: c-api/dict c PyDict_GetItemWithError16835213
Ref: 31516835213
Ref: c-api/dict c PyDict_GetItemString16835682
Ref: 36116835682
Ref: c-api/dict c PyDict_GetItemStringRef16836394
Ref: 31416836394
Ref: c-api/dict c PyDict_SetDefault16836776
Ref: 31916836776
Ref: c-api/dict c PyDict_SetDefaultRef16837386
Ref: 31816837386
Ref: c-api/dict c PyDict_Pop16838483
Ref: 31a16838483
Ref: c-api/dict c PyDict_PopString16839231
Ref: 31b16839231
Ref: c-api/dict c PyDict_Items16839516
Ref: 482c16839516
Ref: c-api/dict c PyDict_Keys16839760
Ref: 482d16839760
Ref: c-api/dict c PyDict_Values16840000
Ref: 483416840000
Ref: c-api/dict c PyDict_Size16840243
Ref: 483116840243
Ref: c-api/dict c PyDict_Next16840484
Ref: 157516840484
Ref: c-api/dict c PyDict_Merge16843183
Ref: 482e16843183
Ref: c-api/dict c PyDict_Update16844004
Ref: 483316844004
Ref: c-api/dict c PyDict_MergeFromSeq216844538
Ref: 482f16844538
Ref: c-api/dict c PyDict_AddWatcher16845573
Ref: 52e16845573
Ref: c-api/dict c PyDict_ClearWatcher16845936
Ref: 4ae016845936
Ref: c-api/dict c PyDict_Watch16846240
Ref: 52f16846240
Ref: c-api/dict c PyDict_Unwatch16846567
Ref: 4ae116846567
Ref: c-api/dict c PyDict_WatchEvent16846982
Ref: 4ae216846982
Ref: c-api/dict c PyDict_WatchCallback16847303
Ref: 4ae316847303
Node: Set オブジェクト16849581
Ref: c-api/set doc16849719
Ref: 4ae416849719
Ref: c-api/set set-objects16849719
Ref: 4ae516849719
Ref: c-api/set setobjects16849719
Ref: 4ae616849719
Ref: c-api/set c PySetObject16850555
Ref: 4ae716850555
Ref: c-api/set c PySet_Type16851348
Ref: 48cf16851348
Ref: c-api/set c PyFrozenSet_Type16851564
Ref: 485416851564
Ref: c-api/set c PySet_Check16852057
Ref: 4ae816852057
Ref: c-api/set c PyFrozenSet_Check16852267
Ref: 4ae916852267
Ref: c-api/set c PyAnySet_Check16852490
Ref: 4aea16852490
Ref: c-api/set c PySet_CheckExact16852744
Ref: 86a16852744
Ref: c-api/set c PyAnySet_CheckExact16853001
Ref: 4aeb16853001
Ref: c-api/set c PyFrozenSet_CheckExact16853300
Ref: 4aec16853300
Ref: c-api/set c PySet_New16853540
Ref: 13ec16853540
Ref: c-api/set c PyFrozenSet_New16854165
Ref: 13ed16854165
Ref: c-api/set c PySet_Size16854866
Ref: 13f116854866
Ref: c-api/set c PySet_GET_SIZE16855237
Ref: 4aed16855237
Ref: c-api/set c PySet_Contains16855406
Ref: 13f016855406
Ref: c-api/set c PySet_Add16855967
Ref: 13ee16855967
Ref: c-api/set c PySet_Discard16856977
Ref: 13ef16856977
Ref: c-api/set c PySet_Pop16857594
Ref: 48ce16857594
Ref: c-api/set c PySet_Clear16858154
Ref: 48cd16858154
Node: Function オブジェクト<2>16858452
Ref: c-api/concrete function-objects16858648
Ref: 4aee16858648
Ref: c-api/concrete otherobjects16858648
Ref: 4aef16858648
Node: Function オブジェクト<3>16859169
Ref: c-api/function doc16859347
Ref: 4af016859347
Ref: c-api/function function-objects16859347
Ref: 4af116859347
Ref: c-api/function id116859347
Ref: 4af216859347
Ref: c-api/function c PyFunctionObject16859478
Ref: 52d16859478
Ref: c-api/function c PyFunction_Type16859568
Ref: 4af316859568
Ref: c-api/function c PyFunction_Check16859833
Ref: 4af416859833
Ref: c-api/function c PyFunction_New16860101
Ref: 4af516860101
Ref: c-api/function c PyFunction_NewWithQualName16860920
Ref: 4af616860920
Ref: c-api/function c PyFunction_GetCode16861557
Ref: 4af716861557
Ref: c-api/function c PyFunction_GetGlobals16861771
Ref: 4af816861771
Ref: c-api/function c PyFunction_GetModule16861974
Ref: 4af916861974
Ref: c-api/function c PyFunction_GetDefaults16862363
Ref: 4afa16862363
Ref: c-api/function c PyFunction_SetDefaults16862622
Ref: 4afb16862622
Ref: c-api/function c PyFunction_SetVectorcall16862985
Ref: 52c16862985
Ref: c-api/function c PyFunction_GetClosure16863311
Ref: 4afc16863311
Ref: c-api/function c PyFunction_SetClosure16863570
Ref: 4afd16863570
Ref: c-api/function c PyFunction_GetAnnotations16863957
Ref: 172516863957
Ref: c-api/function c PyFunction_SetAnnotations16864228
Ref: 4afe16864228
Ref: c-api/function c PyFunction_AddWatcher16864593
Ref: 4aff16864593
Ref: c-api/function c PyFunction_ClearWatcher16864975
Ref: 4b0016864975
Ref: c-api/function c PyFunction_WatchEvent16865344
Ref: 4b0116865344
Ref: c-api/function c PyFunction_WatchCallback16865680
Ref: 4b0216865680
Node: インスタンスメソッドオブジェクト Instance Method Objects16867898
Ref: c-api/method doc16868118
Ref: 4b0316868118
Ref: c-api/method instance-method-objects16868118
Ref: 4b0416868118
Ref: c-api/method instancemethod-objects16868118
Ref: 4b0516868118
Ref: c-api/method c PyInstanceMethod_Type16868469
Ref: 4b0616868469
Ref: c-api/method c PyInstanceMethod_Check16868732
Ref: 4b0716868732
Ref: c-api/method c PyInstanceMethod_New16869035
Ref: 4b0816869035
Ref: c-api/method c PyInstanceMethod_Function16869416
Ref: 4b0916869416
Ref: c-api/method c PyInstanceMethod_GET_FUNCTION16869650
Ref: 4b0a16869650
Node: メソッドオブジェクト<2>16869890
Ref: c-api/method id116870116
Ref: 4b0b16870116
Ref: c-api/method method-objects16870116
Ref: 4b0c16870116
Ref: c-api/method c PyMethod_Type16870488
Ref: 4b0d16870488
Ref: c-api/method c PyMethod_Check16870779
Ref: 4b0e16870779
Ref: c-api/method c PyMethod_New16871049
Ref: 4b0f16871049
Ref: c-api/method c PyMethod_Function16871537
Ref: 4b1016871537
Ref: c-api/method c PyMethod_GET_FUNCTION16871745
Ref: 4b1116871745
Ref: c-api/method c PyMethod_Self16871971
Ref: 4b1216871971
Ref: c-api/method c PyMethod_GET_SELF16872163
Ref: 4b1316872163
Node: セルオブジェクト cell object16872371
Ref: c-api/cell doc16872555
Ref: 4b1416872555
Ref: c-api/cell cell-objects16872555
Ref: 6cc16872555
Ref: c-api/cell id116872555
Ref: 4b1516872555
Ref: c-api/cell c PyCellObject16873586
Ref: 4b1616873586
Ref: c-api/cell c PyCell_Type16873695
Ref: 4b1716873695
Ref: c-api/cell c PyCell_Check16873823
Ref: 4b1816873823
Ref: c-api/cell c PyCell_New16874042
Ref: 4b1916874042
Ref: c-api/cell c PyCell_Get16874291
Ref: 4b1a16874291
Ref: c-api/cell c PyCell_GET16874546
Ref: 4b1b16874546
Ref: c-api/cell c PyCell_Set16874797
Ref: 4b1c16874797
Ref: c-api/cell c PyCell_SET16875170
Ref: 87c16875170
Node: コードオブジェクト<3>16875555
Ref: c-api/code doc16875723
Ref: 4b1d16875723
Ref: c-api/code code-objects16875723
Ref: 4b1e16875723
Ref: c-api/code codeobjects16875723
Ref: 57f16875723
Ref: c-api/code c PyCodeObject16876000
Ref: 74216876000
Ref: c-api/code c PyCode_Type16876200
Ref: 4b1f16876200
Ref: c-api/code c PyCode_Check16876359
Ref: 4b2016876359
Ref: c-api/code c PyCode_GetNumFree16876501
Ref: 4b2116876501
Ref: c-api/code c PyUnstable_Code_GetFirstFree16876677
Ref: 35f16876677
Ref: c-api/code c PyUnstable_Code_New16877307
Ref: 4b2216877307
Ref: c-api/code c PyUnstable_Code_NewWithPosOnlyArgs16878808
Ref: 4b2316878808
Ref: c-api/code c PyCode_NewEmpty16880100
Ref: 132016880100
Ref: c-api/code c PyCode_Addr2Line16880447
Ref: 85616880447
Ref: c-api/code c PyCode_Addr2Location16880851
Ref: 57e16880851
Ref: c-api/code c PyCode_GetCode16881332
Ref: 74316881332
Ref: c-api/code c PyCode_GetVarnames16881917
Ref: 74416881917
Ref: c-api/code c PyCode_GetCellvars16882282
Ref: 74516882282
Ref: c-api/code c PyCode_GetFreevars16882692
Ref: 74616882692
Ref: c-api/code c PyCode_AddWatcher16883078
Ref: 53216883078
Ref: c-api/code c PyCode_ClearWatcher16883440
Ref: 53316883440
Ref: c-api/code c PyCodeEvent16883800
Ref: 4b2416883800
Ref: c-api/code c PyCode_WatchCallback16883992
Ref: 4b2516883992
Ref: コードオブジェクト<3>-Footnote-116885823
Node: Extra information16885905
Ref: c-api/code extra-information16886028
Ref: 4b2616886028
Ref: c-api/code c PyUnstable_Eval_RequestCodeExtraIndex16886401
Ref: 4b2716886401
Ref: c-api/code c PyUnstable_Code_GetExtra16887496
Ref: 4b2816887496
Ref: c-api/code c PyUnstable_Code_SetExtra16888328
Ref: 4b2916888328
Node: その他のオブジェクト<2>16889043
Ref: c-api/concrete other-objects16889202
Ref: 4b2a16889202
Node: ファイルオブジェクト16890218
Ref: c-api/file doc16890374
Ref: 4b2b16890374
Ref: c-api/file file-objects16890374
Ref: 4b2c16890374
Ref: c-api/file fileobjects16890374
Ref: 4b2d16890374
Ref: c-api/file c PyFile_FromFd16891250
Ref: 484d16891250
Ref: c-api/file c PyObject_AsFileDescriptor16892544
Ref: 48aa16892544
Ref: c-api/file c PyFile_GetLine16893145
Ref: 484e16893145
Ref: c-api/file c PyFile_SetOpenCodeHook16894210
Ref: 169016894210
Ref: c-api/file c Py_OpenCodeHookFunction16894509
Ref: 4b2e16894509
Ref: c-api/file c PyFile_WriteObject16896076
Ref: 484f16896076
Ref: c-api/file c PyFile_WriteString16896711
Ref: 485016896711
Node: モジュールオブジェクト module object16897043
Ref: c-api/module doc16897257
Ref: 4b2f16897257
Ref: c-api/module module-objects16897257
Ref: 4b3016897257
Ref: c-api/module moduleobjects16897257
Ref: 4b3116897257
Ref: c-api/module c PyModule_Type16897363
Ref: 488616897363
Ref: c-api/module c PyModule_Check16897729
Ref: 4b3216897729
Ref: c-api/module c PyModule_CheckExact16897965
Ref: 4b3316897965
Ref: c-api/module c PyModule_NewObject16898210
Ref: 488416898210
Ref: c-api/module c PyModule_New16898959
Ref: 488316898959
Ref: c-api/module c PyModule_GetDict16899282
Ref: 488016899282
Ref: c-api/module c PyModule_GetNameObject16900082
Ref: 488216900082
Ref: c-api/module c PyModule_GetName16900507
Ref: 488116900507
Ref: c-api/module c PyModule_GetState16900765
Ref: 94e16900765
Ref: c-api/module c PyModule_GetDef16901140
Ref: 487f16901140
Ref: c-api/module c PyModule_GetFilenameObject16901511
Ref: 3d216901511
Ref: c-api/module c PyModule_GetFilename16902000
Ref: 3d116902000
Node: Cモジュールの初期化16902636
Ref: c-api/module initializing-c-modules16902778
Ref: 4b3416902778
Ref: c-api/module initializing-modules16902778
Ref: 47a716902778
Ref: c-api/module c PyModuleDef16903616
Ref: 94b16903616
Ref: c-api/module c PyModuleDef m_base16904028
Ref: 4b3516904028
Ref: c-api/module c PyModuleDef m_name16904196
Ref: 4b3616904196
Ref: c-api/module c PyModuleDef m_doc16904295
Ref: 4b3716904295
Ref: c-api/module c PyModuleDef m_size16904487
Ref: 94d16904487
Ref: c-api/module c PyModuleDef m_methods16905776
Ref: 4b3816905776
Ref: c-api/module c PyModuleDef m_slots16906071
Ref: 4b3916906071
Ref: c-api/module c PyModuleDef m_slots m_reload16906588
Ref: 4b3b16906588
Ref: c-api/module c PyModuleDef m_traverse16906660
Ref: 94816906660
Ref: c-api/module c PyModuleDef m_clear16907447
Ref: 94916907447
Ref: c-api/module c PyModuleDef m_free16908583
Ref: 94a16908583
Ref: Cモジュールの初期化-Footnote-116909515
Node: 一段階初期化16909557
Ref: c-api/module single-phase-initialization16909667
Ref: 4b3d16909667
Ref: c-api/module c PyModule_Create16909960
Ref: 475016909960
Ref: c-api/module c PyModule_Create216910251
Ref: 487e16910251
Node: 多段階初期化16911331
Ref: c-api/module id116911486
Ref: 4b3e16911486
Ref: c-api/module multi-phase-initialization16911486
Ref: 47a816911486
Ref: c-api/module c PyModuleDef_Init16913190
Ref: 487c16913190
Ref: c-api/module c PyModuleDef_Slot16913844
Ref: 4b3a16913844
Ref: c-api/module c PyModuleDef_Slot slot16913890
Ref: 4b3f16913890
Ref: c-api/module c PyModuleDef_Slot value16914048
Ref: 4b4016914048
Ref: c-api/module c Py_mod_create16914345
Ref: 4b4116914345
Ref: c-api/module c Py_mod_create create_module16914626
Ref: 4b4216914626
Ref: c-api/module c Py_mod_exec16916495
Ref: 94c16916495
Ref: c-api/module c Py_mod_exec exec_module16916841
Ref: 4b4316916841
Ref: c-api/module c Py_mod_multiple_interpreters16917053
Ref: 4b4416917053
Ref: c-api/module c Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED16917148
Ref: 4b4516917148
Ref: c-api/module c Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED16917291
Ref: 4b4616917291
Ref: c-api/module c Py_MOD_PER_INTERPRETER_GIL_SUPPORTED16917551
Ref: 4b4816917551
Ref: c-api/module c Py_mod_gil16918178
Ref: 13e16918178
Ref: c-api/module c Py_MOD_GIL_USED16918255
Ref: 4b4916918255
Ref: c-api/module c Py_MOD_GIL_NOT_USED16918454
Ref: 4b4a16918454
Ref: 多段階初期化-Footnote-116919177
Ref: 多段階初期化-Footnote-216919219
Node: 低水準モジュール作成関数16919261
Ref: c-api/module low-level-module-creation-functions16919416
Ref: 4b4b16919416
Ref: c-api/module c PyModule_FromDefAndSpec16919894
Ref: e7b16919894
Ref: c-api/module c PyModule_FromDefAndSpec216920285
Ref: e7c16920285
Ref: c-api/module c PyModule_ExecDef16921284
Ref: e7d16921284
Ref: c-api/module c PyModule_SetDocString16921580
Ref: 488516921580
Ref: c-api/module c PyModule_AddFunctions16922064
Ref: 487d16922064
Node: サポート関数16923020
Ref: c-api/module support-functions16923148
Ref: 4b4c16923148
Ref: c-api/module c PyModule_AddObjectRef16923481
Ref: 33e16923481
Ref: c-api/module c PyModule_Add16925507
Ref: 33d16925507
Ref: c-api/module c PyModule_AddObject16926098
Ref: 33f16926098
Ref: c-api/module c PyModule_AddIntConstant16927547
Ref: 14e416927547
Ref: c-api/module c PyModule_AddStringConstant16928084
Ref: 14e516928084
Ref: c-api/module c PyModule_AddIntMacro16928696
Ref: 139b16928696
Ref: c-api/module c PyModule_AddStringMacro16929060
Ref: 139a16929060
Ref: c-api/module c PyModule_AddType16929177
Ref: 94316929177
Ref: c-api/module c PyUnstable_Module_SetGIL16929676
Ref: 15f16929676
Node: モジュール検索16930584
Ref: c-api/module module-lookup16930726
Ref: 4b4d16930726
Ref: c-api/module c PyState_FindModule16931268
Ref: 48d416931268
Ref: c-api/module c PyState_AddModule16931970
Ref: 48d316931970
Ref: c-api/module c PyState_RemoveModule16933166
Ref: 48d516933166
Node: イテレータオブジェクト iterator object16933559
Ref: c-api/iterator doc16933797
Ref: 4b4e16933797
Ref: c-api/iterator id116933797
Ref: 4b4f16933797
Ref: c-api/iterator iterator-objects16933797
Ref: 4b5016933797
Ref: c-api/iterator c PySeqIter_Type16934408
Ref: 48bd16934408
Ref: c-api/iterator c PySeqIter_Check16934773
Ref: 4b5116934773
Ref: c-api/iterator c PySeqIter_New16934950
Ref: 48bc16934950
Ref: c-api/iterator c PyCallIter_Type16935343
Ref: 480916935343
Ref: c-api/iterator c PyCallIter_Check16935630
Ref: 4b5216935630
Ref: c-api/iterator c PyCallIter_New16935816
Ref: 480816935816
Node: デスクリプタオブジェクト descriptor object16936474
Ref: c-api/descriptor doc16936708
Ref: 4b5316936708
Ref: c-api/descriptor descriptor-objects16936708
Ref: 4b5416936708
Ref: c-api/descriptor id116936708
Ref: 4b5516936708
Ref: c-api/descriptor c PyProperty_Type16937062
Ref: 48bb16937062
Ref: c-api/descriptor c PyDescr_NewGetSet16937243
Ref: 482616937243
Ref: c-api/descriptor c PyDescr_NewMember16937442
Ref: 482716937442
Ref: c-api/descriptor c PyDescr_NewMethod16937639
Ref: 18f716937639
Ref: c-api/descriptor c PyDescr_NewWrapper16937836
Ref: 4b5616937836
Ref: c-api/descriptor c PyDescr_NewClassMethod16938007
Ref: 482516938007
Ref: c-api/descriptor c PyDescr_IsData16938204
Ref: 186016938204
Ref: c-api/descriptor c PyWrapper_New16938595
Ref: 492716938595
Node: スライスオブジェクト slice object16938754
Ref: c-api/slice doc16938968
Ref: 4b5716938968
Ref: c-api/slice id116938968
Ref: 4b5816938968
Ref: c-api/slice slice-objects16938968
Ref: 4b5916938968
Ref: c-api/slice c PySlice_Type16939069
Ref: 48d216939069
Ref: c-api/slice c PySlice_Check16939344
Ref: 4b5a16939344
Ref: c-api/slice c PySlice_New16939570
Ref: 48d116939570
Ref: c-api/slice c PySlice_GetIndices16940161
Ref: 48d016940161
Ref: c-api/slice c PySlice_GetIndicesEx16941092
Ref: 3d516941092
Ref: c-api/slice c PySlice_Unpack16943165
Ref: 3d616943165
Ref: c-api/slice c PySlice_AdjustIndices16943848
Ref: 3d716943848
Node: Ellipsis オブジェクト<2>16944454
Ref: c-api/slice ellipsis-object16944564
Ref: 4b5b16944564
Ref: c-api/slice c Py_Ellipsis16944633
Ref: 4b5c16944633
Ref: c-api/memoryview memoryview-objects16944913
Ref: 4a0b16944913
Node: memoryview オブジェクト16944913
Ref: c-api/memoryview doc16945103
Ref: 4b5d16945103
Ref: c-api/memoryview id116945103
Ref: 4b5e16945103
Ref: c-api/memoryview c PyMemoryView_FromObject16945401
Ref: 487a16945401
Ref: c-api/memoryview c PyBUF_READ16946034
Ref: 15f416946034
Ref: c-api/memoryview c PyBUF_WRITE16946107
Ref: 15f516946107
Ref: c-api/memoryview c PyMemoryView_FromMemory16946181
Ref: 114316946181
Ref: c-api/memoryview c PyMemoryView_FromBuffer16946642
Ref: 72c16946642
Ref: c-api/memoryview c PyMemoryView_GetContiguous16947109
Ref: 487b16947109
Ref: c-api/memoryview c PyMemoryView_Check16947902
Ref: 4b5f16947902
Ref: c-api/memoryview c PyMemoryView_GET_BUFFER16948194
Ref: 4b6016948194
Ref: c-api/memoryview c PyMemoryView_GET_BASE16948669
Ref: 4b6116948669
Node: 弱参照オブジェクト<2>16949055
Ref: c-api/weakref doc16949217
Ref: 4b6216949217
Ref: c-api/weakref weak-reference-objects16949217
Ref: 4b6316949217
Ref: c-api/weakref weakrefobjects16949217
Ref: 4b6416949217
Ref: c-api/weakref c PyWeakref_Check16949663
Ref: 4b6516949663
Ref: c-api/weakref c PyWeakref_CheckRef16949821
Ref: 4b6616949821
Ref: c-api/weakref c PyWeakref_CheckProxy16949967
Ref: 4b6716949967
Ref: c-api/weakref c PyWeakref_NewRef16950111
Ref: 17b916950111
Ref: c-api/weakref c PyWeakref_NewProxy16950953
Ref: 492616950953
Ref: c-api/weakref c PyWeakref_GetRef16951793
Ref: 35116951793
Ref: c-api/weakref c PyWeakref_GetObject16952344
Ref: 35216952344
Ref: c-api/weakref c PyWeakref_GET_OBJECT16953090
Ref: 39916953090
Ref: c-api/weakref c PyObject_ClearWeakRefs16953398
Ref: 54216953398
Ref: c-api/weakref c PyUnstable_Object_ClearWeakRefsNoCallbacks16953789
Ref: 157616953789
Node: カプセル<2>16954767
Ref: c-api/capsule doc16954940
Ref: 4b6816954940
Ref: c-api/capsule capsules16954940
Ref: 24d416954940
Ref: c-api/capsule id116954940
Ref: 4b6916954940
Ref: c-api/capsule c PyCapsule16955175
Ref: 124416955175
Ref: c-api/capsule c PyCapsule_Destructor16955855
Ref: 480b16955855
Ref: c-api/capsule c PyCapsule_CheckExact16956260
Ref: 4b6a16956260
Ref: c-api/capsule c PyCapsule_New16956435
Ref: 476f16956435
Ref: c-api/capsule c PyCapsule_GetPointer16957646
Ref: 480f16957646
Ref: c-api/capsule c PyCapsule_GetDestructor16958209
Ref: 480d16958209
Ref: c-api/capsule c PyCapsule_GetContext16958847
Ref: 480c16958847
Ref: c-api/capsule c PyCapsule_GetName16959452
Ref: 480e16959452
Ref: c-api/capsule c PyCapsule_Import16960028
Ref: 17d816960028
Ref: c-api/capsule c PyCapsule_IsValid16960640
Ref: 132416960640
Ref: c-api/capsule c PyCapsule_SetContext16961565
Ref: 481016961565
Ref: c-api/capsule c PyCapsule_SetDestructor16961899
Ref: 481116961899
Ref: c-api/capsule c PyCapsule_SetName16962245
Ref: 481216962245
Ref: c-api/capsule c PyCapsule_SetPointer16962809
Ref: 481316962809
Node: フレーム frame オブジェクト<2>16963182
Ref: c-api/frame doc16963361
Ref: 4b6b16963361
Ref: c-api/frame frame-objects16963361
Ref: 4b6c16963361
Ref: c-api/frame c PyFrameObject16963450
Ref: 75416963450
Ref: c-api/frame c PyFrame_Type16964088
Ref: 75216964088
Ref: c-api/frame c PyFrame_Check16964378
Ref: 75016964378
Ref: c-api/frame c PyFrame_GetBack16964607
Ref: 75116964607
Ref: c-api/frame c PyFrame_GetBuiltins16964894
Ref: 73616964894
Ref: c-api/frame c PyFrame_GetCode16965188
Ref: 75516965188
Ref: c-api/frame c PyFrame_GetGenerator16965547
Ref: 73716965547
Ref: c-api/frame c PyFrame_GetGlobals16965979
Ref: 73816965979
Ref: c-api/frame c PyFrame_GetLasti16966271
Ref: 73916966271
Ref: c-api/frame c PyFrame_GetVar16966471
Ref: 53416966471
Ref: c-api/frame c PyFrame_GetVarString16966979
Ref: 53516966979
Ref: c-api/frame c PyFrame_GetLocals16967256
Ref: 3f816967256
Ref: c-api/frame c PyFrame_GetLineNumber16967953
Ref: 75616967953
Ref: フレーム frame オブジェクト<2>-Footnote-116968236
Node: Internal Frames16968278
Ref: c-api/frame internal-frames16968370
Ref: 4b6d16968370
Ref: c-api/frame c _PyInterpreterFrame16968471
Ref: 4b6e16968471
Ref: c-api/frame c PyUnstable_InterpreterFrame_GetCode16968597
Ref: 4b6f16968597
Ref: c-api/frame c PyUnstable_InterpreterFrame_GetLasti16969088
Ref: 4b7016969088
Ref: c-api/frame c PyUnstable_InterpreterFrame_GetLine16969534
Ref: 4b7116969534
Ref: Internal Frames-Footnote-116970039
Node: ジェネレータオブジェクト16970081
Ref: c-api/gen doc16970281
Ref: 4b7216970281
Ref: c-api/gen gen-objects16970281
Ref: 4b7316970281
Ref: c-api/gen generator-objects16970281
Ref: 4b7416970281
Ref: c-api/gen c PyGenObject16970751
Ref: 4b7716970751
Ref: c-api/gen c PyGen_Type16970877
Ref: 4b7816970877
Ref: c-api/gen c PyGen_Check16971016
Ref: 4b7916971016
Ref: c-api/gen c PyGen_CheckExact16971244
Ref: 4b7a16971244
Ref: c-api/gen c PyGen_New16971469
Ref: 4b7516971469
Ref: c-api/gen c PyGen_NewWithQualName16971818
Ref: 4b7616971818
Node: コルーチンオブジェクト<2>16972309
Ref: c-api/coro doc16972511
Ref: 4b7b16972511
Ref: c-api/coro coro-objects16972511
Ref: e9916972511
Ref: c-api/coro coroutine-objects16972511
Ref: 4b7c16972511
Ref: c-api/coro c PyCoroObject16972743
Ref: 4b7d16972743
Ref: c-api/coro c PyCoro_Type16972852
Ref: 4b7e16972852
Ref: c-api/coro c PyCoro_CheckExact16972983
Ref: 4b7f16972983
Ref: c-api/coro c PyCoro_New16973211
Ref: 4b8016973211
Node: コンテキスト変数オブジェクト16973691
Ref: c-api/contextvars doc16973887
Ref: 4b8116973887
Ref: c-api/contextvars context-variables-objects16973887
Ref: 4b8216973887
Ref: c-api/contextvars contextvarsobjects16973887
Ref: ac616973887
Ref: c-api/contextvars contextvarsobjects-pointertype-change16973978
Ref: bf416973978
Ref: c-api/contextvars c PyContext16974640
Ref: 4b8316974640
Ref: c-api/contextvars c PyContextVar16974782
Ref: 4b8416974782
Ref: c-api/contextvars c PyContextToken16974929
Ref: 4b8516974929
Ref: c-api/contextvars c PyContext_Type16975074
Ref: 4b8616975074
Ref: c-api/contextvars c PyContextVar_Type16975199
Ref: 4b8716975199
Ref: c-api/contextvars c PyContextToken_Type16975333
Ref: 4b8816975333
Ref: c-api/contextvars c PyContext_CheckExact16975508
Ref: 4b8916975508
Ref: c-api/contextvars c PyContextVar_CheckExact16975739
Ref: 4b8a16975739
Ref: c-api/contextvars c PyContextToken_CheckExact16975976
Ref: 4b8b16975976
Ref: c-api/contextvars c PyContext_New16976277
Ref: 4b8c16976277
Ref: c-api/contextvars c PyContext_Copy16976515
Ref: 4b8d16976515
Ref: c-api/contextvars c PyContext_CopyCurrent16976785
Ref: 4b8e16976785
Ref: c-api/contextvars c PyContext_Enter16977043
Ref: 4b8f16977043
Ref: c-api/contextvars c PyContext_Exit16977264
Ref: 4b9016977264
Ref: c-api/contextvars c PyContextVar_New16977591
Ref: 4b9116977591
Ref: c-api/contextvars c PyContextVar_Get16978093
Ref: 4b9216978093
Ref: c-api/contextvars c PyContextVar_Set16978930
Ref: 4b9316978930
Ref: c-api/contextvars c PyContextVar_Reset16979292
Ref: 4b9416979292
Ref: コンテキスト変数オブジェクト-Footnote-116979665
Node: DateTime オブジェクト<2>16979730
Ref: c-api/datetime doc16979932
Ref: 4b9516979932
Ref: c-api/datetime datetime-objects16979932
Ref: 4b9616979932
Ref: c-api/datetime datetimeobjects16979932
Ref: 49c316979932
Ref: c-api/datetime c PyDateTime_Date16980595
Ref: 4b9716980595
Ref: c-api/datetime c PyDateTime_DateTime16980756
Ref: 4b9816980756
Ref: c-api/datetime c PyDateTime_Time16980924
Ref: 4b9916980924
Ref: c-api/datetime c PyDateTime_Delta16981087
Ref: 4b9a16981087
Ref: c-api/datetime c PyDateTime_DateType16981247
Ref: 4b9b16981247
Ref: c-api/datetime c PyDateTime_DateTimeType16981510
Ref: 4b9c16981510
Ref: c-api/datetime c PyDateTime_TimeType16981788
Ref: 4b9d16981788
Ref: c-api/datetime c PyDateTime_DeltaType16982051
Ref: 4b9e16982051
Ref: c-api/datetime c PyDateTime_TZInfoType16982318
Ref: 4b9f16982318
Ref: c-api/datetime c PyDateTime_TimeZone_UTC16982666
Ref: b9116982666
Ref: c-api/datetime c PyDate_Check16982946
Ref: 4ba016982946
Ref: c-api/datetime c PyDate_CheckExact16983255
Ref: 4ba116983255
Ref: c-api/datetime c PyDateTime_Check16983490
Ref: 4ba216983490
Ref: c-api/datetime c PyDateTime_CheckExact16983817
Ref: 4ba316983817
Ref: c-api/datetime c PyTime_Check16984060
Ref: 4ba416984060
Ref: c-api/datetime c PyTime_CheckExact16984369
Ref: 4ba516984369
Ref: c-api/datetime c PyDelta_Check16984604
Ref: 4ba616984604
Ref: c-api/datetime c PyDelta_CheckExact16984922
Ref: 4ba716984922
Ref: c-api/datetime c PyTZInfo_Check16985159
Ref: 4ba816985159
Ref: c-api/datetime c PyTZInfo_CheckExact16985480
Ref: 4ba916985480
Ref: c-api/datetime c PyDate_FromDate16985788
Ref: 4baa16985788
Ref: c-api/datetime c PyDateTime_FromDateAndTime16986021
Ref: 4bab16986021
Ref: c-api/datetime c PyDateTime_FromDateAndTimeAndFold16986362
Ref: 4bac16986362
Ref: c-api/datetime c PyTime_FromTime16986760
Ref: 4bad16986760
Ref: c-api/datetime c PyTime_FromTimeAndFold16987031
Ref: 4bae16987031
Ref: c-api/datetime c PyDelta_FromDSU16987355
Ref: 4baf16987355
Ref: c-api/datetime c PyTimeZone_FromOffset16987775
Ref: b8f16987775
Ref: c-api/datetime c PyTimeZone_FromOffsetAndName16988090
Ref: b9016988090
Ref: c-api/datetime c PyDateTime_GET_YEAR16988808
Ref: 4bb016988808
Ref: c-api/datetime c PyDateTime_GET_MONTH16988914
Ref: 4bb116988914
Ref: c-api/datetime c PyDateTime_GET_DAY16989037
Ref: 4bb216989037
Ref: c-api/datetime c PyDateTime_DATE_GET_HOUR16989481
Ref: 4bb316989481
Ref: c-api/datetime c PyDateTime_DATE_GET_MINUTE16989612
Ref: 4bb416989612
Ref: c-api/datetime c PyDateTime_DATE_GET_SECOND16989745
Ref: 4bb516989745
Ref: c-api/datetime c PyDateTime_DATE_GET_MICROSECOND16989878
Ref: 4bb616989878
Ref: c-api/datetime c PyDateTime_DATE_GET_FOLD16990042
Ref: 4bb716990042
Ref: c-api/datetime c PyDateTime_DATE_GET_TZINFO16990279
Ref: 86216990279
Ref: c-api/datetime c PyDateTime_TIME_GET_HOUR16990776
Ref: 4bb816990776
Ref: c-api/datetime c PyDateTime_TIME_GET_MINUTE16990903
Ref: 4bb916990903
Ref: c-api/datetime c PyDateTime_TIME_GET_SECOND16991032
Ref: 4bba16991032
Ref: c-api/datetime c PyDateTime_TIME_GET_MICROSECOND16991161
Ref: 4bbb16991161
Ref: c-api/datetime c PyDateTime_TIME_GET_FOLD16991311
Ref: 4bbc16991311
Ref: c-api/datetime c PyDateTime_TIME_GET_TZINFO16991544
Ref: 86316991544
Ref: c-api/datetime c PyDateTime_DELTA_GET_DAYS16992038
Ref: 4bbd16992038
Ref: c-api/datetime c PyDateTime_DELTA_GET_SECONDS16992214
Ref: 4bbe16992214
Ref: c-api/datetime c PyDateTime_DELTA_GET_MICROSECONDS16992380
Ref: 4bbf16992380
Ref: c-api/datetime c PyDateTime_FromTimestamp16992642
Ref: 4bc016992642
Ref: c-api/datetime c PyDate_FromTimestamp16992936
Ref: 197916992936
Node: 型ヒントのためのオブジェクト16993219
Ref: c-api/typehints doc16993370
Ref: 4bc116993370
Ref: c-api/typehints objects-for-type-hinting16993370
Ref: 4bc216993370
Ref: c-api/typehints typehintobjects16993370
Ref: 4bc316993370
Ref: c-api/typehints c Py_GenericAlias16993635
Ref: 492b16993635
Ref: c-api/typehints c Py_GenericAliasType16995215
Ref: 492c16995215
Node: 初期化 initialization 、終了処理 finalization 、スレッド16995541
Ref: c-api/init doc16995783
Ref: 4bc416995783
Ref: c-api/init initialization16995783
Ref: 4bc516995783
Ref: c-api/init initialization-finalization-and-threads16995783
Ref: 4bc616995783
Node: Python 初期化以前16996873
Ref: c-api/init before-python-initialization16997040
Ref: 4bc716997040
Ref: c-api/init pre-init-safe16997040
Ref: b9316997040
Node: グローバルな設定変数16999746
Ref: c-api/init global-conf-vars16999970
Ref: 4bc816999970
Ref: c-api/init global-configuration-variables16999970
Ref: 4bcc16999970
Ref: c-api/init c Py_BytesWarningFlag17000594
Ref: 3ae17000594
Ref: c-api/init c Py_DebugFlag17001252
Ref: 3a017001252
Ref: c-api/init c Py_DontWriteBytecodeFlag17001786
Ref: 3b417001786
Ref: c-api/init c Py_FrozenFlag17002356
Ref: 3b017002356
Ref: c-api/init c Py_HashRandomizationFlag17002924
Ref: 3ba17002924
Ref: c-api/init c Py_IgnoreEnvironmentFlag17003560
Ref: 3b217003560
Ref: c-api/init c Py_InspectFlag17004082
Ref: 3a817004082
Ref: c-api/init c Py_InteractiveFlag17004799
Ref: 3a617004799
Ref: c-api/init c Py_IsolatedFlag17005115
Ref: 3bd17005115
Ref: c-api/init c Py_LegacyWindowsFSEncodingFlag17005709
Ref: 3bf17005709
Ref: c-api/init c Py_LegacyWindowsStdioFlag17006524
Ref: 3c117006524
Ref: c-api/init c Py_NoSiteFlag17007222
Ref: 3ac17007222
Ref: c-api/init c Py_NoUserSiteDirectory17007944
Ref: 3b617007944
Ref: c-api/init c Py_OptimizeFlag17008503
Ref: 3aa17008503
Ref: c-api/init c Py_QuietFlag17008901
Ref: 3a417008901
Ref: c-api/init c Py_UnbufferedStdioFlag17009385
Ref: 3b817009385
Ref: c-api/init c Py_VerboseFlag17009886
Ref: 3a217009886
Ref: グローバルな設定変数-Footnote-117010773
Ref: グローバルな設定変数-Footnote-217010815
Node: インタープリタの初期化と終了処理17010857
Ref: c-api/init initializing-and-finalizing-the-interpreter17011098
Ref: 4bcd17011098
Ref: c-api/init c Py_Initialize17011193
Ref: 87a17011193
Ref: c-api/init c Py_InitializeEx17012585
Ref: 493217012585
Ref: c-api/init c Py_InitializeFromConfig17013070
Ref: 39f17013070
Ref: c-api/init c Py_IsInitialized17013497
Ref: 47e317013497
Ref: c-api/init c Py_IsFinalizing17013879
Ref: 33317013879
Ref: c-api/init c Py_FinalizeEx17014156
Ref: ce317014156
Ref: c-api/init c Py_Finalize17016941
Ref: 132117016941
Ref: c-api/init c Py_BytesMain17017156
Ref: 98f17017156
Ref: c-api/init c Py_Main17017505
Ref: bf317017505
Ref: c-api/init c Py_RunMain17020441
Ref: 99317020441
Node: プロセスワイドのパラメータ17022360
Ref: c-api/init process-wide-parameters17022672
Ref: 4bd317022672
Ref: c-api/init c Py_SetProgramName17022752
Ref: 15a217022752
Ref: c-api/init c Py_GetProgramName17024222
Ref: 39317024222
Ref: c-api/init c Py_GetPrefix17024852
Ref: 38f17024852
Ref: c-api/init c Py_GetExecPrefix17026116
Ref: 38b17026116
Ref: c-api/init c Py_GetProgramFullPath17029430
Ref: 39117029430
Ref: c-api/init c Py_GetPath17030258
Ref: 38d17030258
Ref: c-api/init c Py_GetVersion17031350
Ref: 493017031350
Ref: c-api/init c Py_GetPlatform17032182
Ref: 492f17032182
Ref: c-api/init c Py_GetCopyright17033015
Ref: 492e17033015
Ref: c-api/init c Py_GetCompiler17033550
Ref: 492d17033550
Ref: c-api/init c Py_GetBuildInfo17034120
Ref: 13d917034120
Ref: c-api/init c PySys_SetArgvEx17034683
Ref: 15a317034683
Ref: c-api/init c PySys_SetArgv17037547
Ref: 15a417037547
Ref: c-api/init c Py_SetPythonHome17038571
Ref: 15a117038571
Ref: c-api/init c Py_GetPythonHome17039507
Ref: 39417039507
Ref: プロセスワイドのパラメータ-Footnote-117040203
Node: スレッド状態 thread state とグローバルインタプリタロック global interpreter lock17040258
Ref: c-api/init thread-state-and-the-global-interpreter-lock17040558
Ref: 4bd417040558
Ref: c-api/init threads17040558
Ref: 4bd517040558
Node: 拡張コード内で GIL を解放する17042839
Ref: c-api/init releasing-the-gil-from-extension-code17043067
Ref: 4bd617043067
Node: Python 以外で作られたスレッド17045322
Ref: c-api/init gilstate17045578
Ref: 4bd717045578
Ref: c-api/init non-python-created-threads17045578
Ref: 4bd817045578
Node: Cautions about fork17047755
Ref: c-api/init cautions-about-fork17047985
Ref: 4bd917047985
Ref: c-api/init fork-and-threads17047985
Ref: 498f17047985
Node: 高レベルAPI17049915
Ref: c-api/init high-level-api17050120
Ref: 4bda17050120
Ref: c-api/init c PyInterpreterState17050305
Ref: 88b17050305
Ref: c-api/init c PyThreadState17051219
Ref: 75817051219
Ref: c-api/init c PyThreadState interp17051452
Ref: 4bdb17051452
Ref: c-api/init c PyEval_InitThreads17051567
Ref: 15a517051567
Ref: c-api/init c PyEval_SaveThread17052247
Ref: 38217052247
Ref: c-api/init c PyEval_RestoreThread17052699
Ref: 38317052699
Ref: c-api/init c PyThreadState_Get17053589
Ref: 34b17053589
Ref: c-api/init c PyThreadState_GetUnchecked17054079
Ref: 34a17054079
Ref: c-api/init c PyThreadState_Swap17054464
Ref: 48e217054464
Ref: c-api/init c PyGILState_Ensure17054983
Ref: 38517054983
Ref: c-api/init c PyGILState_Release17057025
Ref: 38617057025
Ref: c-api/init c PyGILState_GetThisThreadState17057679
Ref: 485517057679
Ref: c-api/init c PyGILState_Check17058352
Ref: 4bdc17058352
Ref: c-api/init c Py_BEGIN_ALLOW_THREADS17059374
Ref: 476917059374
Ref: c-api/init c Py_END_ALLOW_THREADS17059875
Ref: a5c17059875
Ref: c-api/init c Py_BLOCK_THREADS17060360
Ref: 492917060360
Ref: c-api/init c Py_UNBLOCK_THREADS17060623
Ref: 493517060623
Node: 低レベルAPI17060891
Ref: c-api/init low-level-api17061068
Ref: 4bdd17061068
Ref: c-api/init c PyInterpreterState_New17061347
Ref: 405e17061347
Ref: c-api/init c PyInterpreterState_Clear17061853
Ref: 405d17061853
Ref: c-api/init c PyInterpreterState_Delete17062257
Ref: 486117062257
Ref: c-api/init c PyThreadState_New17062671
Ref: 48e117062671
Ref: c-api/init c PyThreadState_Clear17063139
Ref: 158517063139
Ref: c-api/init c PyThreadState_Delete17063582
Ref: 190b17063582
Ref: c-api/init c PyThreadState_DeleteCurrent17063952
Ref: 193e17063952
Ref: c-api/init c PyThreadState_GetFrame17064287
Ref: 75917064287
Ref: c-api/init c PyThreadState_GetID17064752
Ref: 94017064752
Ref: c-api/init c PyThreadState_GetInterpreter17065058
Ref: 93f17065058
Ref: c-api/init c PyThreadState_EnterTracing17065382
Ref: 71f17065382
Ref: c-api/init c PyThreadState_LeaveTracing17065642
Ref: 72017065642
Ref: c-api/init c PyInterpreterState_Get17065988
Ref: 38717065988
Ref: c-api/init c PyInterpreterState_GetID17066408
Ref: b9417066408
Ref: c-api/init c PyInterpreterState_GetDict17066843
Ref: 486217066843
Ref: c-api/init c _PyFrameEvalFunction17067589
Ref: 74117067589
Ref: c-api/init c _PyInterpreterState_GetEvalFrameFunc17068164
Ref: 18f917068164
Ref: c-api/init c _PyInterpreterState_SetEvalFrameFunc17068439
Ref: 18fa17068439
Ref: c-api/init c PyThreadState_GetDict17068709
Ref: 48e017068709
Ref: c-api/init c PyThreadState_SetAsyncExc17069419
Ref: b9217069419
Ref: c-api/init c PyEval_AcquireThread17070263
Ref: 38417070263
Ref: c-api/init c PyEval_ReleaseThread17071589
Ref: 484717071589
Ref: 低レベルAPI-Footnote-117072427
Ref: 低レベルAPI-Footnote-217072469
Node: サブインタプリタサポート17072511
Ref: c-api/init id117072787
Ref: 4bde17072787
Ref: c-api/init sub-interpreter-support17072787
Ref: 55317072787
Ref: c-api/init c PyInterpreterConfig17074018
Ref: 53917074018
Ref: c-api/init c PyInterpreterConfig use_main_obmalloc17074324
Ref: 41f917074324
Ref: c-api/init c PyInterpreterConfig allow_fork17074772
Ref: 4be317074772
Ref: c-api/init c PyInterpreterConfig allow_exec17075118
Ref: 4be417075118
Ref: c-api/init c PyInterpreterConfig allow_threads17075524
Ref: 4be517075524
Ref: c-api/init c PyInterpreterConfig allow_daemon_threads17075723
Ref: 4be617075723
Ref: c-api/init c PyInterpreterConfig check_multi_interp_extensions17076015
Ref: 4be017076015
Ref: c-api/init c PyInterpreterConfig gil17076550
Ref: 4be117076550
Ref: c-api/init c PyInterpreterConfig_DEFAULT_GIL17076710
Ref: 4be717076710
Ref: c-api/init c PyInterpreterConfig_SHARED_GIL17076877
Ref: 4be817076877
Ref: c-api/init c PyInterpreterConfig_OWN_GIL17076995
Ref: 4be217076995
Ref: c-api/init c Py_NewInterpreterFromConfig17077251
Ref: 42817077251
Ref: c-api/init c Py_NewInterpreter17081976
Ref: 172117081976
Ref: c-api/init c Py_EndInterpreter17082459
Ref: 17ca17082459
Ref: サブインタプリタサポート-Footnote-117083273
Node: A Per-Interpreter GIL17083315
Ref: c-api/init a-per-interpreter-gil17083439
Ref: 4bea17083439
Ref: A Per-Interpreter GIL-Footnote-117085483
Node: バグと注意事項17085525
Ref: c-api/init bugs-and-caveats17085649
Ref: 4be917085649
Node: 非同期通知17087466
Ref: c-api/init asynchronous-notifications17087696
Ref: 4beb17087696
Ref: c-api/init c Py_AddPendingCall17087959
Ref: 94f17087959
Node: プロファイルとトレース profiling and tracing17090748
Ref: c-api/init profiling17090959
Ref: 4bec17090959
Ref: c-api/init profiling-and-tracing17090959
Ref: 4bed17090959
Ref: c-api/init c Py_tracefunc17092081
Ref: 4bee17092081
Ref: c-api/init c PyTrace_CALL17094537
Ref: 4bef17094537
Ref: c-api/init c PyTrace_EXCEPTION17095028
Ref: 4bf017095028
Ref: c-api/init c PyTrace_LINE17095764
Ref: 4bf117095764
Ref: c-api/init c PyTrace_RETURN17096064
Ref: 4bf217096064
Ref: c-api/init c PyTrace_C_CALL17096218
Ref: 4bf317096218
Ref: c-api/init c PyTrace_C_EXCEPTION17096373
Ref: 4bf417096373
Ref: c-api/init c PyTrace_C_RETURN17096541
Ref: 4bf517096541
Ref: c-api/init c PyTrace_OPCODE17096695
Ref: 4bf617096695
Ref: c-api/init c PyEval_SetProfile17097033
Ref: 14a617097033
Ref: c-api/init c PyEval_SetProfileAllThreads17097765
Ref: 52a17097765
Ref: c-api/init c PyEval_SetTrace17098315
Ref: 14a717098315
Ref: c-api/init c PyEval_SetTraceAllThreads17099048
Ref: 52b17099048
Node: Reference tracing17099585
Ref: c-api/init reference-tracing17099840
Ref: 4bf717099840
Ref: c-api/init c PyRefTracer17099913
Ref: 4bf817099913
Ref: c-api/init c PyRefTracer_CREATE17100486
Ref: 4bf917100486
Ref: c-api/init c PyRefTracer_DESTROY17100648
Ref: 4bfa17100648
Ref: c-api/init c PyRefTracer_SetTracer17100813
Ref: 34517100813
Ref: c-api/init c PyRefTracer_GetTracer17101598
Ref: 34617101598
Node: 高度なデバッガサポート advanced debugger support17102052
Ref: c-api/init advanced-debugger-support17102306
Ref: 4bfb17102306
Ref: c-api/init advanced-debugging17102306
Ref: 4bfc17102306
Ref: c-api/init c PyInterpreterState_Head17102529
Ref: 14aa17102529
Ref: c-api/init c PyInterpreterState_Main17102733
Ref: 4bdf17102733
Ref: c-api/init c PyInterpreterState_Next17102889
Ref: 14ab17102889
Ref: c-api/init c PyInterpreterState_ThreadHead17103138
Ref: 14ac17103138
Ref: c-api/init c PyThreadState_Next17103446
Ref: 14ad17103446
Node: スレッドローカルストレージのサポート17103746
Ref: c-api/init thread-local-storage17104010
Ref: 4bfd17104010
Ref: c-api/init thread-local-storage-support17104010
Ref: 4bfe17104010
Node: スレッド固有ストレージ Thread Specific Storage TSS API17105613
Ref: c-api/init thread-specific-storage-api17105825
Ref: aac17105825
Ref: c-api/init thread-specific-storage-tss-api17105825
Ref: 4bff17105825
Ref: c-api/init c Py_tss_t17106357
Ref: aad17106357
Ref: c-api/init c Py_tss_NEEDS_INIT17106885
Ref: 4c0017106885
Ref: スレッド固有ストレージ Thread Specific Storage TSS API-Footnote-117107216
Node: 動的メモリ確保17107258
Ref: c-api/init dynamic-allocation17107405
Ref: 4c0117107405
Ref: c-api/init c PyThread_tss_alloc17107728
Ref: 3de17107728
Ref: c-api/init c PyThread_tss_free17108041
Ref: 3e017108041
Node: メソッド<2>17108545
Ref: c-api/init methods17108692
Ref: 4c0217108692
Ref: c-api/init c PyThread_tss_is_created17109002
Ref: 48e417109002
Ref: c-api/init c PyThread_tss_create17109272
Ref: 48e317109272
Ref: c-api/init c PyThread_tss_delete17109768
Ref: 3e617109768
Ref: c-api/init c PyThread_tss_set17110277
Ref: 3e217110277
Ref: c-api/init c PyThread_tss_get17110615
Ref: 3e417110615
Node: スレッドローカルストレージ TLS API17110927
Ref: c-api/init thread-local-storage-api17111139
Ref: aab17111139
Ref: c-api/init thread-local-storage-tls-api17111139
Ref: 4c0317111139
Ref: c-api/init c PyThread_create_key17111822
Ref: 3dd17111822
Ref: c-api/init c PyThread_delete_key17111918
Ref: 3df17111918
Ref: c-api/init c PyThread_set_key_value17112022
Ref: 3e117112022
Ref: c-api/init c PyThread_get_key_value17112141
Ref: 3e317112141
Ref: c-api/init c PyThread_delete_key_value17112249
Ref: 3e517112249
Ref: c-api/init c PyThread_ReInitTLS17112359
Ref: 3e717112359
Node: 同期プリミティブ<3>17112455
Ref: c-api/init synchronization-primitives17112651
Ref: 4c0417112651
Ref: c-api/init c PyMutex17112759
Ref: 14117112759
Ref: c-api/init c PyMutex_Lock17113394
Ref: 30317113394
Ref: c-api/init c PyMutex_Unlock17113697
Ref: 30417113697
Node: Python Critical Section API17113927
Ref: c-api/init id217114018
Ref: 4c0517114018
Ref: c-api/init python-critical-section-api17114018
Ref: 4c0617114018
Ref: c-api/init c Py_BEGIN_CRITICAL_SECTION17116073
Ref: 4adf17116073
Ref: c-api/init c Py_END_CRITICAL_SECTION17116478
Ref: 4c0817116478
Ref: c-api/init c Py_BEGIN_CRITICAL_SECTION217116796
Ref: 4c0717116796
Ref: c-api/init c Py_END_CRITICAL_SECTION217117341
Ref: 4c0917117341
Node: Python 初期化設定17117663
Ref: c-api/init_config doc17117870
Ref: 4c0a17117870
Ref: c-api/init_config init-config17117870
Ref: 38117117870
Ref: c-api/init_config python-initialization-configuration17117870
Ref: 4c0b17117870
Ref: Python 初期化設定-Footnote-117119407
Node: 使用例<53>17119449
Ref: c-api/init_config example17119546
Ref: 4c0d17119546
Node: PyWideStringList17120556
Ref: c-api/init_config pywidestringlist17120670
Ref: 4c0e17120670
Ref: c-api/init_config c PyWideStringList17120719
Ref: 97c17120719
Ref: c-api/init_config c PyWideStringList_Append17120984
Ref: 98d17120984
Ref: c-api/init_config c PyWideStringList_Insert17121228
Ref: 98e17121228
Ref: c-api/init_config c PyWideStringList length17121736
Ref: 4c0f17121736
Ref: c-api/init_config c PyWideStringList items17121831
Ref: 4c1017121831
Node: PyStatus17121912
Ref: c-api/init_config pystatus17122024
Ref: 4c1117122024
Ref: c-api/init_config c PyStatus17122057
Ref: 97b17122057
Ref: c-api/init_config c PyStatus exitcode17122321
Ref: 4c1217122321
Ref: c-api/init_config c PyStatus err_msg17122445
Ref: 4c1317122445
Ref: c-api/init_config c PyStatus func17122536
Ref: 4c1417122536
Ref: c-api/init_config c PyStatus_Ok17122718
Ref: 98c17122718
Ref: c-api/init_config c PyStatus_Error17122802
Ref: 98617122802
Ref: c-api/init_config c PyStatus_NoMemory17123015
Ref: 98b17123015
Ref: c-api/init_config c PyStatus_Exit17123146
Ref: 98817123146
Ref: c-api/init_config c PyStatus_Exception17123326
Ref: 98717123326
Ref: c-api/init_config c PyStatus_IsError17123558
Ref: 98917123558
Ref: c-api/init_config c PyStatus_IsExit17123655
Ref: 98a17123655
Ref: c-api/init_config c Py_ExitStatusException17123750
Ref: 99017123750
Node: PyPreConfig17124720
Ref: c-api/init_config pypreconfig17124853
Ref: 4c1517124853
Ref: c-api/init_config c PyPreConfig17124892
Ref: 97a17124892
Ref: c-api/init_config c PyPreConfig_InitPythonConfig17125028
Ref: 98517125028
Ref: c-api/init_config c PyPreConfig_InitIsolatedConfig17125217
Ref: 98417125217
Ref: c-api/init_config c PyPreConfig allocator17125442
Ref: 4c1617125442
Ref: c-api/init_config c PyPreConfig configure_locale17127237
Ref: 4c1817127237
Ref: c-api/init_config c PyPreConfig coerce_c_locale17127610
Ref: 4c1917127610
Ref: c-api/init_config c PyPreConfig coerce_c_locale_warn17127941
Ref: 4c1a17127941
Ref: c-api/init_config c PyPreConfig dev_mode17128140
Ref: 4c1b17128140
Ref: c-api/init_config c PyPreConfig isolated17128349
Ref: 4c1d17128349
Ref: c-api/init_config c PyPreConfig legacy_windows_fs_encoding17128524
Ref: 3c017128524
Ref: c-api/init_config c PyPreConfig parse_argv17129108
Ref: 4c1e17129108
Ref: c-api/init_config c PyPreConfig use_environment17129504
Ref: 4c1f17129504
Ref: c-api/init_config c PyPreConfig utf8_mode17129735
Ref: 3c417129735
Node: Preinitialize Python with PyPreConfig17130158
Ref: c-api/init_config c-preinit17130291
Ref: 3bcb17130291
Ref: c-api/init_config preinitialize-python-with-pypreconfig17130291
Ref: 4c2017130291
Ref: c-api/init_config c Py_PreInitialize17130780
Ref: 3c517130780
Ref: c-api/init_config c Py_PreInitializeFromBytesArgs17130981
Ref: 99217130981
Ref: c-api/init_config c Py_PreInitializeFromArgs17131342
Ref: 99117131342
Node: PyConfig17133280
Ref: c-api/init_config pyconfig17133430
Ref: 4c2117133430
Ref: c-api/init_config c PyConfig17133463
Ref: 38017133463
Ref: c-api/init_config c PyConfig_InitPythonConfig17133704
Ref: 97f17133704
Ref: c-api/init_config c PyConfig_InitIsolatedConfig17133866
Ref: 97e17133866
Ref: c-api/init_config c PyConfig_SetString17134032
Ref: 98317134032
Ref: c-api/init_config c PyConfig_SetBytesString17134305
Ref: 98217134305
Ref: c-api/init_config c PyConfig_SetArgv17134636
Ref: 98017134636
Ref: c-api/init_config c PyConfig_SetBytesArgv17134953
Ref: 98117134953
Ref: c-api/init_config c PyConfig_SetWideStringList17135323
Ref: 195017135323
Ref: c-api/init_config c PyConfig_Read17135631
Ref: 75b17135631
Ref: c-api/init_config c PyConfig_Clear17137001
Ref: 97d17137001
Ref: c-api/init_config c PyConfig argv17138134
Ref: 39d17138134
Ref: c-api/init_config c PyConfig safe_path17139156
Ref: 73e17139156
Ref: c-api/init_config c PyConfig base_exec_prefix17140042
Ref: 4c2217140042
Ref: c-api/init_config c PyConfig base_executable17140299
Ref: 4c2417140299
Ref: c-api/init_config c PyConfig base_prefix17140709
Ref: 4c2517140709
Ref: c-api/init_config c PyConfig buffered_stdio17140951
Ref: 3b917140951
Ref: c-api/init_config c PyConfig bytes_warning17141376
Ref: 3af17141376
Ref: c-api/init_config c PyConfig warn_default_encoding17141833
Ref: 4c2817141833
Ref: c-api/init_config c PyConfig code_debug_ranges17142157
Ref: 4c2917142157
Ref: c-api/init_config c PyConfig check_hash_pycs_mode17142642
Ref: 4c2a17142642
Ref: c-api/init_config c PyConfig configure_c_stdio17143314
Ref: 4c2717143314
Ref: c-api/init_config c PyConfig dev_mode17143875
Ref: 4c1c17143875
Ref: c-api/init_config c PyConfig dump_refs17144187
Ref: 4c2b17144187
Ref: c-api/init_config c PyConfig exec_prefix17144612
Ref: 4c2317144612
Ref: c-api/init_config c PyConfig executable17144976
Ref: 37f17144976
Ref: c-api/init_config c PyConfig faulthandler17145306
Ref: 4c2c17145306
Ref: c-api/init_config c PyConfig filesystem_encoding17145672
Ref: 3c217145672
Ref: c-api/init_config c PyConfig filesystem_errors17146911
Ref: 3c317146911
Ref: c-api/init_config c PyConfig hash_seed17147592
Ref: 3bc17147592
Ref: c-api/init_config c PyConfig use_hash_seed17147648
Ref: 3bb17147648
Ref: c-api/init_config c PyConfig home17148067
Ref: 39517148067
Ref: c-api/init_config c PyConfig import_time17148427
Ref: 4c2d17148427
Ref: c-api/init_config c PyConfig inspect17148692
Ref: 3a917148692
Ref: c-api/init_config c PyConfig install_signal_handlers17149292
Ref: 88c17149292
Ref: c-api/init_config c PyConfig interactive17149465
Ref: 3a717149465
Ref: c-api/init_config c PyConfig int_max_str_digits17149681
Ref: 4c2e17149681
Ref: c-api/init_config c PyConfig cpu_count17150582
Ref: 4c2f17150582
Ref: c-api/init_config c PyConfig isolated17151081
Ref: 3be17151081
Ref: c-api/init_config c PyConfig legacy_windows_stdio17152086
Ref: 37e17152086
Ref: c-api/init_config c PyConfig malloc_stats17152723
Ref: 4c3017152723
Ref: c-api/init_config c PyConfig platlibdir17153119
Ref: 18a817153119
Ref: c-api/init_config c PyConfig pythonpath_env17153949
Ref: 4c3117153949
Ref: c-api/init_config c PyConfig module_search_paths17154300
Ref: 37c17154300
Ref: c-api/init_config c PyConfig module_search_paths_set17154396
Ref: 5b917154396
Ref: c-api/init_config c PyConfig optimization_level17154933
Ref: 3ab17154933
Ref: c-api/init_config c PyConfig orig_argv17155440
Ref: 86117155440
Ref: c-api/init_config c PyConfig parse_argv17156124
Ref: 189317156124
Ref: c-api/init_config c PyConfig parser_debug17157041
Ref: 3a117157041
Ref: c-api/init_config c PyConfig pathconfig_warnings17157529
Ref: 3b117157529
Ref: c-api/init_config c PyConfig prefix17157967
Ref: 4c2617157967
Ref: c-api/init_config c PyConfig program_name17158308
Ref: 39e17158308
Ref: c-api/init_config c PyConfig pycache_prefix17159052
Ref: 4c3217159052
Ref: c-api/init_config c PyConfig quiet17159526
Ref: 3a517159526
Ref: c-api/init_config c PyConfig run_command17159802
Ref: 4bcf17159802
Ref: c-api/init_config c PyConfig run_filename17159991
Ref: 4bd017159991
Ref: c-api/init_config c PyConfig run_module17160470
Ref: 4bd117160470
Ref: c-api/init_config c PyConfig run_presite17160658
Ref: 4c3417160658
Ref: c-api/init_config c PyConfig show_ref_count17161161
Ref: 4c3517161161
Ref: c-api/init_config c PyConfig site_import17161529
Ref: 3ad17161529
Ref: c-api/init_config c PyConfig skip_source_first_line17162194
Ref: 4c3317162194
Ref: c-api/init_config c PyConfig stdio_encoding17162579
Ref: 37d17162579
Ref: c-api/init_config c PyConfig stdio_errors17162635
Ref: 420817162635
Ref: c-api/init_config c PyConfig tracemalloc17163546
Ref: 4c3617163546
Ref: c-api/init_config c PyConfig perf_profiling17163911
Ref: 4c3717163911
Ref: c-api/init_config c PyConfig use_environment17164619
Ref: 3b317164619
Ref: c-api/init_config c PyConfig user_site_directory17164953
Ref: 3b717164953
Ref: c-api/init_config c PyConfig verbose17165360
Ref: 3a317165360
Ref: c-api/init_config c PyConfig warnoptions17165980
Ref: 37a17165980
Ref: c-api/init_config c PyConfig write_bytecode17166832
Ref: 3b517166832
Ref: c-api/init_config c PyConfig xoptions17167301
Ref: 37b17167301
Ref: PyConfig-Footnote-117167941
Ref: PyConfig-Footnote-217167983
Node: Initialization with PyConfig17168025
Ref: c-api/init_config init-from-config17168160
Ref: 4bce17168160
Ref: c-api/init_config initialization-with-pyconfig17168160
Ref: 4c3817168160
Node: Isolated Configuration17171855
Ref: c-api/init_config init-isolated-conf17172002
Ref: 4c0c17172002
Ref: c-api/init_config isolated-configuration17172002
Ref: 4c3917172002
Node: Python Configuration17172769
Ref: c-api/init_config init-python-config17172913
Ref: 4bd217172913
Ref: c-api/init_config python-configuration17172913
Ref: 4c3a17172913
Ref: Python Configuration-Footnote-117173545
Ref: Python Configuration-Footnote-217173587
Node: Python Path Configuration17173629
Ref: c-api/init_config init-path-config17173765
Ref: 87b17173765
Ref: c-api/init_config python-path-configuration17173765
Ref: 4c3b17173765
Node: Py_GetArgcArgv17177489
Ref: c-api/init_config py-getargcargv17177655
Ref: 4c3c17177655
Ref: c-api/init_config c Py_GetArgcArgv17177706
Ref: 18c017177706
Node: Multi-Phase Initialization Private Provisional API17177908
Ref: c-api/init_config multi-phase-initialization-private-provisional-api17178040
Ref: 4c3d17178040
Ref: c-api/init_config c _Py_InitializeMain17179219
Ref: 4c3e17179219
Ref: Multi-Phase Initialization Private Provisional API-Footnote-117181223
Ref: Multi-Phase Initialization Private Provisional API-Footnote-217181265
Node: メモリ管理17181307
Ref: c-api/memory doc17181511
Ref: 4c3f17181511
Ref: c-api/memory memory17181511
Ref: 4c1717181511
Ref: c-api/memory memory-management17181511
Ref: 4c4017181511
Node: 概要<4>17181959
Ref: c-api/memory memoryoverview17182046
Ref: 4c4117182046
Ref: c-api/memory overview17182046
Ref: 4c4217182046
Node: Allocator Domains17187655
Ref: c-api/memory allocator-domains17187787
Ref: 4c4317187787
Ref: c-api/memory id117187838
Ref: 4c4417187838
Node: 生メモリインターフェース17189822
Ref: c-api/memory raw-memory-interface17189978
Ref: 4c4a17189978
Ref: c-api/memory raw-memoryinterface17189978
Ref: 4c4617189978
Ref: c-api/memory c PyMem_RawMalloc17190505
Ref: 36917190505
Ref: c-api/memory c PyMem_RawCalloc17191079
Ref: 36a17191079
Ref: c-api/memory c PyMem_RawRealloc17191811
Ref: 36b17191811
Ref: c-api/memory c PyMem_RawFree17192835
Ref: 36c17192835
Node: メモリインターフェース17193395
Ref: c-api/memory memory-interface17193567
Ref: 4c4b17193567
Ref: c-api/memory memoryinterface17193567
Ref: 4c4717193567
Ref: c-api/memory c PyMem_Malloc17194273
Ref: c3317194273
Ref: c-api/memory c PyMem_Calloc17194812
Ref: e7617194812
Ref: c-api/memory c PyMem_Realloc17195538
Ref: ffc17195538
Ref: c-api/memory c PyMem_Free17196523
Ref: 13ea17196523
Ref: c-api/memory c PyMem_New17197196
Ref: 14ce17197196
Ref: c-api/memory c PyMem_Resize17197438
Ref: 4c4c17197438
Ref: c-api/memory c PyMem_Del17197953
Ref: 14cf17197953
Node: オブジェクトアロケータ17198623
Ref: c-api/memory object-allocators17198784
Ref: 4c4d17198784
Ref: c-api/memory objectinterface17198784
Ref: 4c4817198784
Ref: c-api/memory c PyObject_Malloc17199632
Ref: c3617199632
Ref: c-api/memory c PyObject_Calloc17200177
Ref: e7717200177
Ref: c-api/memory c PyObject_Realloc17200908
Ref: 13eb17200908
Ref: c-api/memory c PyObject_Free17201920
Ref: c3417201920
Node: Default Memory Allocators17202466
Ref: c-api/memory default-memory-allocators17202645
Ref: 1cba17202645
Ref: c-api/memory id217202645
Ref: 4c4f17202645
Node: メモリアロケータをカスタマイズする17205171
Ref: c-api/memory customize-memory-allocators17205360
Ref: 4c4e17205360
Ref: c-api/memory id317205360
Ref: 4c5017205360
Ref: c-api/memory c PyMemAllocatorEx17205485
Ref: e9717205485
Ref: c-api/memory c PyMemAllocatorDomain17207518
Ref: 4c4517207518
Ref: c-api/memory c PYMEM_DOMAIN_RAW17207660
Ref: 1cbb17207660
Ref: c-api/memory c PYMEM_DOMAIN_MEM17207905
Ref: c3717207905
Ref: c-api/memory c PYMEM_DOMAIN_OBJ17208139
Ref: c3517208139
Ref: c-api/memory c PyMem_GetAllocator17208385
Ref: 4bca17208385
Ref: c-api/memory c PyMem_SetAllocator17208590
Ref: 55717208590
Ref: c-api/memory c PyMem_SetupDebugHooks17210694
Ref: c3817210694
Node: Debug hooks on the Python memory allocators17210845
Ref: c-api/memory debug-hooks-on-the-python-memory-allocators17211033
Ref: 4c5117211033
Ref: c-api/memory pymem-debug-hooks17211033
Ref: 1cbd17211033
Node: pymalloc アロケータ17216288
Ref: c-api/memory pymalloc17216447
Ref: cdd17216447
Ref: c-api/memory the-pymalloc-allocator17216447
Ref: 4c5217216447
Node: pymalloc アリーナアロケータのカスタマイズ17217612
Ref: c-api/memory customize-pymalloc-arena-allocator17217730
Ref: 4c5317217730
Ref: c-api/memory c PyObjectArenaAllocator17217872
Ref: 4c5417217872
Ref: c-api/memory c PyObject_GetArenaAllocator17218984
Ref: 4bcb17218984
Ref: c-api/memory c PyObject_SetArenaAllocator17219135
Ref: 4bc917219135
Node: The mimalloc allocator17219286
Ref: c-api/memory mimalloc17219419
Ref: 1cbc17219419
Ref: c-api/memory the-mimalloc-allocator17219419
Ref: 4c5517219419
Node: tracemalloc C API17219776
Ref: c-api/memory tracemalloc-c-api17219898
Ref: 4c5617219898
Ref: c-api/memory c PyTraceMalloc_Track17219974
Ref: b8417219974
Ref: c-api/memory c PyTraceMalloc_Untrack17220387
Ref: b8517220387
Node: 使用例<54>17220679
Ref: c-api/memory examples17220770
Ref: 4c5717220770
Ref: c-api/memory memoryexamples17220770
Ref: 4c5817220770
Node: オブジェクト実装サポート object implementation support17222979
Ref: c-api/objimpl doc17223197
Ref: 4c5917223197
Ref: c-api/objimpl newtypes17223197
Ref: 4c5a17223197
Ref: c-api/objimpl object-implementation-support17223197
Ref: 4c5b17223197
Node: オブジェクトをヒープ上にメモリ確保する17223803
Ref: c-api/allocation doc17224032
Ref: 4c5c17224032
Ref: c-api/allocation allocating-objects17224032
Ref: 4c5d17224032
Ref: c-api/allocation allocating-objects-on-the-heap17224032
Ref: 4c5e17224032
Ref: c-api/allocation c _PyObject_New17224144
Ref: 4c5f17224144
Ref: c-api/allocation c _PyObject_NewVar17224256
Ref: 4c6017224256
Ref: c-api/allocation c PyObject_Init17224402
Ref: a3817224402
Ref: c-api/allocation c PyObject_InitVar17224752
Ref: 18bf17224752
Ref: c-api/allocation c PyObject_New17225112
Ref: 95317225112
Ref: c-api/allocation c PyObject_NewVar17225742
Ref: 95417225742
Ref: c-api/allocation c PyObject_Del17226656
Ref: 147a17226656
Ref: c-api/allocation c _Py_NoneStruct17227229
Ref: 4c6117227229
Node: 共通のオブジェクト構造体 common object structure17227629
Ref: c-api/structures doc17227891
Ref: 4c6217227891
Ref: c-api/structures common-object-structures17227891
Ref: 4c6317227891
Ref: c-api/structures common-structs17227891
Ref: 4c6417227891
Node: Base object types and macros17228333
Ref: c-api/structures base-object-types-and-macros17228501
Ref: 4c6517228501
Ref: c-api/structures c PyObject17229007
Ref: 31217229007
Ref: c-api/structures c PyVarObject17229967
Ref: 3fe217229967
Ref: c-api/structures c PyObject_HEAD17230479
Ref: 12ac17230479
Ref: c-api/structures c PyObject_VAR_HEAD17230832
Ref: 4c6617230832
Ref: c-api/structures c Py_Is17231233
Ref: 86d17231233
Ref: c-api/structures c Py_IsNone17231487
Ref: 86e17231487
Ref: c-api/structures c Py_IsTrue17231740
Ref: 86f17231740
Ref: c-api/structures c Py_IsFalse17231993
Ref: 87017231993
Ref: c-api/structures c Py_TYPE17232249
Ref: 74b17232249
Ref: c-api/structures c Py_IS_TYPE17232679
Ref: 178017232679
Ref: c-api/structures c Py_SET_TYPE17232901
Ref: 74c17232901
Ref: c-api/structures c Py_SIZE17233039
Ref: 74d17233039
Ref: c-api/structures c Py_SET_SIZE17233399
Ref: 74e17233399
Ref: c-api/structures c PyObject_HEAD_INIT17233537
Ref: 4c6717233537
Ref: c-api/structures c PyVarObject_HEAD_INIT17233790
Ref: 4c6817233790
Node: Implementing functions and methods17234081
Ref: c-api/structures implementing-functions-and-methods17234297
Ref: 4c6917234297
Ref: c-api/structures c PyCFunction17234386
Ref: 141c17234386
Ref: c-api/structures c PyCFunctionWithKeywords17235045
Ref: 480717235045
Ref: c-api/structures c PyCFunctionFast17235491
Ref: 480517235491
Ref: c-api/structures c PyCFunctionFastWithKeywords17235927
Ref: 480617235927
Ref: c-api/structures c PyCMethod17236499
Ref: 72f17236499
Ref: c-api/structures c PyMethodDef17237000
Ref: 148017237000
Ref: c-api/structures c PyMethodDef ml_name17237276
Ref: 479417237276
Ref: c-api/structures c PyMethodDef ml_meth17237359
Ref: 4c6c17237359
Ref: c-api/structures c PyMethodDef ml_flags17237468
Ref: 4c6d17237468
Ref: c-api/structures c PyMethodDef ml_doc17237582
Ref: 4c6e17237582
Ref: c-api/structures c METH_VARARGS17238325
Ref: 14b317238325
Ref: c-api/structures c METH_KEYWORDS17238969
Ref: 474f17238969
Ref: c-api/structures meth-varargs-meth-keywords17239229
Ref: 4c6a17239229
Ref: c-api/structures c METH_FASTCALL17239666
Ref: 158b17239666
Ref: c-api/structures meth-fastcall-meth-keywords17240180
Ref: 4c6b17240180
Ref: c-api/structures c METH_METHOD17240848
Ref: 93e17240848
Ref: c-api/structures meth-method-meth-fastcall-meth-keywords17241002
Ref: 15f217241002
Ref: c-api/structures c METH_NOARGS17241527
Ref: 147d17241527
Ref: c-api/structures c METH_O17242095
Ref: 14b217242095
Ref: c-api/structures c METH_CLASS17242799
Ref: 147e17242799
Ref: c-api/structures c METH_STATIC17243154
Ref: 147f17243154
Ref: c-api/structures c METH_COEXIST17243614
Ref: 141b17243614
Ref: c-api/structures c PyCMethod_New17244291
Ref: 185817244291
Ref: c-api/structures c PyCFunction_NewEx17245446
Ref: 18f817245446
Ref: c-api/structures c PyCFunction_New17245712
Ref: 185e17245712
Node: Accessing attributes of extension types17245993
Ref: c-api/structures accessing-attributes-of-extension-types17246172
Ref: 4c6f17246172
Ref: c-api/structures c PyMemberDef17246271
Ref: 51a17246271
Ref: c-api/structures c PyMemberDef name17246645
Ref: 4c7017246645
Ref: c-api/structures c PyMemberDef type17246858
Ref: 479517246858
Ref: c-api/structures c PyMemberDef offset17247016
Ref: 4c7117247016
Ref: c-api/structures c PyMemberDef flags17247177
Ref: 479617247177
Ref: c-api/structures c PyMemberDef doc17247313
Ref: 4c7317247313
Ref: c-api/structures pymemberdef-offsets17247865
Ref: 4a4717247865
Ref: c-api/structures c PyMember_GetOne17248997
Ref: 55917248997
Ref: c-api/structures c PyMember_SetOne17249463
Ref: 55a17249463
Node: Member flags17250055
Ref: c-api/structures member-flags17250164
Ref: 4c7517250164
Ref: c-api/structures pymemberdef-flags17250164
Ref: 4c7217250164
Ref: c-api/structures c Py_READONLY17250279
Ref: 55d17250279
Ref: c-api/structures c Py_AUDIT_READ17250332
Ref: 55e17250332
Ref: c-api/structures c Py_RELATIVE_OFFSET17250452
Ref: 51917250452
Node: Member types17251711
Ref: c-api/structures member-types17251857
Ref: 4c7617251857
Ref: c-api/structures pymemberdef-types17251857
Ref: 15d717251857
Ref: c-api/structures c Py_T_BYTE17252754
Ref: 4c7717252754
Ref: c-api/structures c Py_T_SHORT17252990
Ref: 4c7817252990
Ref: c-api/structures c Py_T_INT17253223
Ref: 55b17253223
Ref: c-api/structures c Py_T_LONG17253459
Ref: 4c7917253459
Ref: c-api/structures c Py_T_LONGLONG17253698
Ref: 4c7a17253698
Ref: c-api/structures c Py_T_UBYTE17253930
Ref: 4c7b17253930
Ref: c-api/structures c Py_T_UINT17254164
Ref: 4c7c17254164
Ref: c-api/structures c Py_T_USHORT17254401
Ref: 4c7d17254401
Ref: c-api/structures c Py_T_ULONG17254635
Ref: 4c7e17254635
Ref: c-api/structures c Py_T_ULONGLONG17254874
Ref: 4c7f17254874
Ref: c-api/structures c Py_T_PYSSIZET17255108
Ref: 4c8017255108
Ref: c-api/structures c Py_T_FLOAT17255340
Ref: 4c8117255340
Ref: c-api/structures c Py_T_DOUBLE17255578
Ref: 55c17255578
Ref: c-api/structures c Py_T_BOOL17255813
Ref: 4c8217255813
Ref: c-api/structures c Py_T_STRING17256051
Ref: 4c7417256051
Ref: c-api/structures c Py_T_STRING_INPLACE17256279
Ref: 4c8317256279
Ref: c-api/structures c Py_T_CHAR17256458
Ref: 4c8417256458
Ref: c-api/structures c Py_T_OBJECT_EX17256703
Ref: 56017256703
Ref: c-api/structures c T_OBJECT17257567
Ref: 55f17257567
Ref: c-api/structures c T_NONE17257789
Ref: 56117257789
Node: Defining Getters and Setters17257885
Ref: c-api/structures defining-getters-and-setters17258010
Ref: 4c8517258010
Ref: c-api/structures c PyGetSetDef17258087
Ref: b8617258087
Ref: c-api/structures c PyGetSetDef name17258404
Ref: 4c8617258404
Ref: c-api/structures c PyGetSetDef get17258474
Ref: 4c8717258474
Ref: c-api/structures c PyGetSetDef set17258574
Ref: 4c8817258574
Ref: c-api/structures c PyGetSetDef doc17258747
Ref: 4c8917258747
Ref: c-api/structures c PyGetSetDef closure17258855
Ref: 4c8a17258855
Ref: c-api/structures c getter17258999
Ref: 494017258999
Ref: c-api/structures c setter17259425
Ref: 494e17259425
Node: 型オブジェクト<3>17259961
Ref: c-api/typeobj doc17260229
Ref: 4c8b17260229
Ref: c-api/typeobj type-objects17260229
Ref: 4c8c17260229
Ref: c-api/typeobj type-structs17260229
Ref: 95b17260229
Node: クイックリファレンス17262141
Ref: c-api/typeobj quick-reference17262260
Ref: 4c8e17262260
Node: tp スロット17262447
Ref: c-api/typeobj tp-slots17262547
Ref: 4c8f17262547
Ref: c-api/typeobj tp-slots-table17262547
Ref: 4c9017262547
Ref: tp スロット-Footnote-117275817
Ref: tp スロット-Footnote-217276129
Node: sub-slots17276897
Ref: c-api/typeobj id317277038
Ref: 4c9b17277038
Ref: c-api/typeobj sub-slots17277038
Ref: 4c9217277038
Node: スロットの定義型 typedef17287325
Ref: c-api/typeobj slot-typedefs17287442
Ref: 4ccb17287442
Ref: c-api/typeobj slot-typedefs-table17287442
Ref: 4c9117287442
Node: PyTypeObject 定義17295346
Ref: c-api/typeobj pytypeobject-definition17295495
Ref: 4ccd17295495
Node: PyObject スロット17298643
Ref: c-api/typeobj pyobject-slots17298786
Ref: 4cce17298786
Ref: c-api/typeobj c PyObject ob_refcnt17299231
Ref: 86c17299231
Ref: c-api/typeobj c PyObject ob_type17299853
Ref: 477817299853
Node: PyVarObject スロット17301146
Ref: c-api/typeobj pyvarobject-slots17301295
Ref: 4ccf17301295
Ref: c-api/typeobj c PyVarObject ob_size17301360
Ref: 492517301360
Node: PyTypeObject スロット17301918
Ref: c-api/typeobj pytypeobject-slots17302058
Ref: 4cd017302058
Ref: c-api/typeobj c PyTypeObject tp_name17302415
Ref: 185d17302415
Ref: c-api/typeobj c PyTypeObject tp_basicsize17304279
Ref: 95517304279
Ref: c-api/typeobj c PyTypeObject tp_itemsize17304375
Ref: 1ed017304375
Ref: c-api/typeobj c PyTypeObject tp_dealloc17307467
Ref: 477a17307467
Ref: c-api/typeobj c PyTypeObject tp_vectorcall_offset17310852
Ref: 49e917310852
Ref: c-api/typeobj c PyTypeObject tp_getattr17312796
Ref: 479817312796
Ref: c-api/typeobj c PyTypeObject tp_setattr17313776
Ref: 479917313776
Ref: c-api/typeobj c PyTypeObject tp_as_async17314759
Ref: e9817314759
Ref: c-api/typeobj c PyTypeObject tp_repr17315538
Ref: 478f17315538
Ref: c-api/typeobj c PyTypeObject tp_as_number17316796
Ref: 95917316796
Ref: c-api/typeobj c PyTypeObject tp_as_sequence17317291
Ref: 4c9317317291
Ref: c-api/typeobj c PyTypeObject tp_as_mapping17317810
Ref: 4c9417317810
Ref: c-api/typeobj c PyTypeObject tp_hash17318321
Ref: 47a117318321
Ref: c-api/typeobj c PyTypeObject tp_call17320333
Ref: 52417320333
Ref: c-api/typeobj c PyTypeObject tp_str17320902
Ref: 479017320902
Ref: c-api/typeobj c PyTypeObject tp_getattro17322269
Ref: 165717322269
Ref: c-api/typeobj c PyTypeObject tp_setattro17323347
Ref: 479317323347
Ref: c-api/typeobj c PyTypeObject tp_as_buffer17324576
Ref: 95717324576
Ref: c-api/typeobj c PyTypeObject tp_flags17325196
Ref: 182817325196
Ref: c-api/typeobj c Py_TPFLAGS_HEAPTYPE17327584
Ref: 87d17327584
Ref: c-api/typeobj c Py_TPFLAGS_BASETYPE17328390
Ref: 478017328390
Ref: c-api/typeobj c Py_TPFLAGS_READY17328765
Ref: 4cd617328765
Ref: c-api/typeobj c Py_TPFLAGS_READYING17328988
Ref: 4cd717328988
Ref: c-api/typeobj c Py_TPFLAGS_HAVE_GC17329210
Ref: 74817329210
Ref: c-api/typeobj c Py_TPFLAGS_DEFAULT17330267
Ref: 477517330267
Ref: c-api/typeobj c Py_TPFLAGS_METHOD_DESCRIPTOR17330607
Ref: 49f117330607
Ref: c-api/typeobj c Py_TPFLAGS_MANAGED_DICT17331538
Ref: 34417331538
Ref: c-api/typeobj c Py_TPFLAGS_MANAGED_WEAKREF17332208
Ref: 52517332208
Ref: c-api/typeobj c Py_TPFLAGS_ITEMS_AT_END17332531
Ref: 51617332531
Ref: c-api/typeobj c Py_TPFLAGS_LONG_SUBCLASS17333200
Ref: 4cd817333200
Ref: c-api/typeobj c Py_TPFLAGS_LIST_SUBCLASS17333251
Ref: 4cd917333251
Ref: c-api/typeobj c Py_TPFLAGS_TUPLE_SUBCLASS17333302
Ref: 4cda17333302
Ref: c-api/typeobj c Py_TPFLAGS_BYTES_SUBCLASS17333354
Ref: 4cdb17333354
Ref: c-api/typeobj c Py_TPFLAGS_UNICODE_SUBCLASS17333406
Ref: 4cdc17333406
Ref: c-api/typeobj c Py_TPFLAGS_DICT_SUBCLASS17333460
Ref: 4cdd17333460
Ref: c-api/typeobj c Py_TPFLAGS_BASE_EXC_SUBCLASS17333511
Ref: 4cde17333511
Ref: c-api/typeobj c Py_TPFLAGS_TYPE_SUBCLASS17333566
Ref: 4cdf17333566
Ref: c-api/typeobj c Py_TPFLAGS_HAVE_FINALIZE17334276
Ref: 3cb17334276
Ref: c-api/typeobj c Py_TPFLAGS_HAVE_VECTORCALL17334702
Ref: 51f17334702
Ref: c-api/typeobj c Py_TPFLAGS_IMMUTABLETYPE17335270
Ref: 39c17335270
Ref: c-api/typeobj c Py_TPFLAGS_DISALLOW_INSTANTIATION17335640
Ref: 54e17335640
Ref: c-api/typeobj c Py_TPFLAGS_MAPPING17336771
Ref: 180e17336771
Ref: c-api/typeobj c Py_TPFLAGS_SEQUENCE17337614
Ref: 180f17337614
Ref: c-api/typeobj c Py_TPFLAGS_VALID_VERSION_TAG17338458
Ref: 4ce017338458
Ref: c-api/typeobj c PyTypeObject tp_doc17338798
Ref: 477617338798
Ref: c-api/typeobj c PyTypeObject tp_traverse17339160
Ref: 74917339160
Ref: c-api/typeobj c PyTypeObject tp_clear17343496
Ref: 478d17343496
Ref: c-api/typeobj c PyTypeObject tp_richcompare17347976
Ref: 479b17347976
Ref: c-api/typeobj c Py_LT17349080
Ref: 49de17349080
Ref: c-api/typeobj c Py_LE17349184
Ref: 49df17349184
Ref: c-api/typeobj c Py_EQ17349289
Ref: 49e017349289
Ref: c-api/typeobj c Py_NE17349394
Ref: 49e117349394
Ref: c-api/typeobj c Py_GT17349499
Ref: 49e217349499
Ref: c-api/typeobj c Py_GE17349603
Ref: 49e317349603
Ref: c-api/typeobj c Py_RETURN_RICHCOMPARE17349776
Ref: b8217349776
Ref: c-api/typeobj c PyTypeObject tp_weaklistoffset17351268
Ref: 95617351268
Ref: c-api/typeobj c PyTypeObject tp_iter17353180
Ref: 149717353180
Ref: c-api/typeobj c PyTypeObject tp_iternext17353900
Ref: 149817353900
Ref: c-api/typeobj c PyTypeObject tp_methods17355086
Ref: 477f17355086
Ref: c-api/typeobj c PyTypeObject tp_members17355759
Ref: 477d17355759
Ref: c-api/typeobj c PyTypeObject tp_getset17356461
Ref: 478217356461
Ref: c-api/typeobj c PyTypeObject tp_base17357144
Ref: 478617357144
Ref: c-api/typeobj c PyTypeObject tp_dict17358685
Ref: 168517358685
Ref: c-api/typeobj c PyTypeObject tp_descr_get17360318
Ref: 4c9517360318
Ref: c-api/typeobj c PyTypeObject tp_descr_set17360732
Ref: 186117360732
Ref: c-api/typeobj c PyTypeObject tp_dictoffset17361255
Ref: 4a4617361255
Ref: c-api/typeobj c PyTypeObject tp_init17363298
Ref: 54d17363298
Ref: c-api/typeobj c PyTypeObject tp_alloc17364959
Ref: 477c17364959
Ref: c-api/typeobj c PyTypeObject tp_new17365755
Ref: 54b17365755
Ref: c-api/typeobj c PyTypeObject tp_free17367762
Ref: 477b17367762
Ref: c-api/typeobj c PyTypeObject tp_is_gc17368584
Ref: 4c9617368584
Ref: c-api/typeobj c PyTypeObject tp_bases17369909
Ref: 4c9717369909
Ref: c-api/typeobj c PyTypeObject tp_mro17370715
Ref: 4a4917370715
Ref: c-api/typeobj c PyTypeObject tp_cache17371362
Ref: 4a4a17371362
Ref: c-api/typeobj c PyTypeObject tp_subclasses17371604
Ref: 53e17371604
Ref: c-api/typeobj c PyTypeObject tp_weaklist17372094
Ref: 4a4b17372094
Ref: c-api/typeobj c PyTypeObject tp_del17372695
Ref: 4c9817372695
Ref: c-api/typeobj c PyTypeObject tp_version_tag17372914
Ref: 4c9917372914
Ref: c-api/typeobj c PyTypeObject tp_finalize17373200
Ref: a7417373200
Ref: c-api/typeobj c PyTypeObject tp_vectorcall17375130
Ref: 4a4817375130
Ref: c-api/typeobj c PyTypeObject tp_watched17375760
Ref: 4c9a17375760
Ref: PyTypeObject スロット-Footnote-117375930
Ref: PyTypeObject スロット-Footnote-217375972
Ref: PyTypeObject スロット-Footnote-317376014
Ref: PyTypeObject スロット-Footnote-417376057
Node: Static Types17376099
Ref: c-api/typeobj id417376225
Ref: 4ce117376225
Ref: c-api/typeobj static-types17376225
Ref: 74a17376225
Node: Heap Types17377130
Ref: c-api/typeobj heap-types17377264
Ref: 93317377264
Ref: c-api/typeobj id517377264
Ref: 4ce217377264
Node: 数値オブジェクト構造体17377767
Ref: c-api/typeobj number-object-structures17377925
Ref: 4ce317377925
Ref: c-api/typeobj number-structs17377925
Ref: 4cd217377925
Ref: c-api/typeobj c PyNumberMethods17378003
Ref: 13c517378003
Ref: c-api/typeobj c PyNumberMethods nb_add17380728
Ref: 4a3d17380728
Ref: c-api/typeobj c PyNumberMethods nb_subtract17380824
Ref: 4ca217380824
Ref: c-api/typeobj c PyNumberMethods nb_multiply17380925
Ref: 4ca417380925
Ref: c-api/typeobj c PyNumberMethods nb_remainder17381026
Ref: 4ca617381026
Ref: c-api/typeobj c PyNumberMethods nb_divmod17381128
Ref: 4ca817381128
Ref: c-api/typeobj c PyNumberMethods nb_power17381227
Ref: 4ca917381227
Ref: c-api/typeobj c PyNumberMethods nb_negative17381326
Ref: 4cab17381326
Ref: c-api/typeobj c PyNumberMethods nb_positive17381426
Ref: 4cac17381426
Ref: c-api/typeobj c PyNumberMethods nb_absolute17381526
Ref: 4cad17381526
Ref: c-api/typeobj c PyNumberMethods nb_bool17381626
Ref: 4cae17381626
Ref: c-api/typeobj c PyNumberMethods nb_invert17381720
Ref: 4caf17381720
Ref: c-api/typeobj c PyNumberMethods nb_lshift17381818
Ref: 4cb017381818
Ref: c-api/typeobj c PyNumberMethods nb_rshift17381917
Ref: 4cb217381917
Ref: c-api/typeobj c PyNumberMethods nb_and17382016
Ref: 4cb417382016
Ref: c-api/typeobj c PyNumberMethods nb_xor17382112
Ref: 4cb617382112
Ref: c-api/typeobj c PyNumberMethods nb_or17382208
Ref: 4cb817382208
Ref: c-api/typeobj c PyNumberMethods nb_int17382303
Ref: 4cba17382303
Ref: c-api/typeobj c PyNumberMethods nb_reserved17382398
Ref: 4cbb17382398
Ref: c-api/typeobj c PyNumberMethods nb_float17382471
Ref: 4cbc17382471
Ref: c-api/typeobj c PyNumberMethods nb_inplace_add17382568
Ref: 4ca117382568
Ref: c-api/typeobj c PyNumberMethods nb_inplace_subtract17382672
Ref: 4ca317382672
Ref: c-api/typeobj c PyNumberMethods nb_inplace_multiply17382781
Ref: 4ca517382781
Ref: c-api/typeobj c PyNumberMethods nb_inplace_remainder17382890
Ref: 4ca717382890
Ref: c-api/typeobj c PyNumberMethods nb_inplace_power17383000
Ref: 4caa17383000
Ref: c-api/typeobj c PyNumberMethods nb_inplace_lshift17383107
Ref: 4cb117383107
Ref: c-api/typeobj c PyNumberMethods nb_inplace_rshift17383214
Ref: 4cb317383214
Ref: c-api/typeobj c PyNumberMethods nb_inplace_and17383321
Ref: 4cb517383321
Ref: c-api/typeobj c PyNumberMethods nb_inplace_xor17383425
Ref: 4cb717383425
Ref: c-api/typeobj c PyNumberMethods nb_inplace_or17383529
Ref: 4cb917383529
Ref: c-api/typeobj c PyNumberMethods nb_floor_divide17383632
Ref: 4cbd17383632
Ref: c-api/typeobj c PyNumberMethods nb_true_divide17383737
Ref: 4cbf17383737
Ref: c-api/typeobj c PyNumberMethods nb_inplace_floor_divide17383841
Ref: 4cbe17383841
Ref: c-api/typeobj c PyNumberMethods nb_inplace_true_divide17383954
Ref: 4cc017383954
Ref: c-api/typeobj c PyNumberMethods nb_index17384066
Ref: 13c417384066
Ref: c-api/typeobj c PyNumberMethods nb_matrix_multiply17384163
Ref: 4cc117384163
Ref: c-api/typeobj c PyNumberMethods nb_inplace_matrix_multiply17384271
Ref: 4cc217384271
Node: マップオブジェクト構造体17384387
Ref: c-api/typeobj mapping-object-structures17384577
Ref: 4ce417384577
Ref: c-api/typeobj mapping-structs17384577
Ref: 4cd417384577
Ref: c-api/typeobj c PyMappingMethods17384660
Ref: 47a017384660
Ref: c-api/typeobj c PyMappingMethods mp_length17384902
Ref: 4cc317384902
Ref: c-api/typeobj c PyMappingMethods mp_subscript17385324
Ref: 189817385324
Ref: c-api/typeobj c PyMappingMethods mp_ass_subscript17385800
Ref: 4cc417385800
Node: シーケンスオブジェクト構造体17386304
Ref: c-api/typeobj sequence-object-structures17386524
Ref: 4ce517386524
Ref: c-api/typeobj sequence-structs17386524
Ref: 4cd317386524
Ref: c-api/typeobj c PySequenceMethods17386617
Ref: 479f17386617
Ref: c-api/typeobj c PySequenceMethods sq_length17386818
Ref: 4a4517386818
Ref: c-api/typeobj c PySequenceMethods sq_concat17387170
Ref: 4cc517387170
Ref: c-api/typeobj c PySequenceMethods sq_repeat17387531
Ref: 4cc617387531
Ref: c-api/typeobj c PySequenceMethods sq_item17387898
Ref: 189717387898
Ref: c-api/typeobj c PySequenceMethods sq_ass_item17388667
Ref: 4cc717388667
Ref: c-api/typeobj c PySequenceMethods sq_contains17389168
Ref: 4cc817389168
Ref: c-api/typeobj c PySequenceMethods sq_inplace_concat17389612
Ref: 4cc917389612
Ref: c-api/typeobj c PySequenceMethods sq_inplace_repeat17390173
Ref: 4cca17390173
Node: バッファオブジェクト構造体 buffer object structure17390747
Ref: c-api/typeobj buffer-object-structures17390964
Ref: 4ce617390964
Ref: c-api/typeobj buffer-structs17390964
Ref: 101017390964
Ref: c-api/typeobj c PyBufferProcs17391104
Ref: 4a4c17391104
Ref: c-api/typeobj c PyBufferProcs bf_getbuffer17391476
Ref: 72d17391476
Ref: c-api/typeobj c PyBufferProcs bf_releasebuffer17394082
Ref: 72e17394082
Node: async オブジェクト構造体17395712
Ref: c-api/typeobj async-object-structures17395905
Ref: 4ce717395905
Ref: c-api/typeobj async-structs17395905
Ref: 4cd117395905
Ref: c-api/typeobj c PyAsyncMethods17396008
Ref: 4a4417396008
Ref: c-api/typeobj c PyAsyncMethods am_await17396497
Ref: 4c9c17396497
Ref: c-api/typeobj c PyAsyncMethods am_aiter17397069
Ref: 4c9d17397069
Ref: c-api/typeobj c PyAsyncMethods am_anext17397545
Ref: 4c9e17397545
Ref: c-api/typeobj c PyAsyncMethods am_send17397886
Ref: 4c9f17397886
Node: Slot Type typedefs17398245
Ref: c-api/typeobj id617398388
Ref: 4ccc17398388
Ref: c-api/typeobj slot-type-typedefs17398388
Ref: 4ce817398388
Ref: c-api/typeobj c allocfunc17398447
Ref: 493717398447
Ref: c-api/typeobj c destructor17399634
Ref: 493b17399634
Ref: c-api/typeobj c freefunc17399759
Ref: 4b3c17399759
Ref: c-api/typeobj c newfunc17399873
Ref: 494617399873
Ref: c-api/typeobj c initproc17400125
Ref: 494217400125
Ref: c-api/typeobj c reprfunc17400361
Ref: 494a17400361
Ref: c-api/typeobj c getattrfunc17400570
Ref: 493c17400570
Ref: c-api/typeobj c setattrfunc17400799
Ref: 494c17400799
Ref: c-api/typeobj c getattrofunc17401133
Ref: 493d17401133
Ref: c-api/typeobj c setattrofunc17401441
Ref: 494d17401441
Ref: c-api/typeobj c descrgetfunc17401864
Ref: 493917401864
Ref: c-api/typeobj c descrsetfunc17402127
Ref: 493a17402127
Ref: c-api/typeobj c hashfunc17402372
Ref: 494117402372
Ref: c-api/typeobj c richcmpfunc17402582
Ref: 494b17402582
Ref: c-api/typeobj c getiterfunc17402828
Ref: 493f17402828
Ref: c-api/typeobj c iternextfunc17403040
Ref: 494417403040
Ref: c-api/typeobj c lenfunc17403257
Ref: 494517403257
Ref: c-api/typeobj c getbufferproc17403407
Ref: 493e17403407
Ref: c-api/typeobj c releasebufferproc17403604
Ref: 494917403604
Ref: c-api/typeobj c unaryfunc17403801
Ref: 495317403801
Ref: c-api/typeobj c binaryfunc17403952
Ref: 493817403952
Ref: c-api/typeobj c sendfunc17404127
Ref: 4ca017404127
Ref: c-api/typeobj c ternaryfunc17404345
Ref: 495117404345
Ref: c-api/typeobj c ssizeargfunc17404544
Ref: 494f17404544
Ref: c-api/typeobj c ssizeobjargproc17404722
Ref: 495017404722
Ref: c-api/typeobj c objobjproc17404907
Ref: 494817404907
Ref: c-api/typeobj c objobjargproc17405064
Ref: 494717405064
Node: 使用例<55>17405247
Ref: c-api/typeobj examples17405348
Ref: 4ce917405348
Ref: c-api/typeobj typedef-examples17405348
Ref: 4c8d17405348
Node: 循環参照ガベージコレクションをサポートする17410975
Ref: c-api/gcsupport doc17411174
Ref: 4cea17411174
Ref: c-api/gcsupport supporting-cycle-detection17411174
Ref: 4cd517411174
Ref: c-api/gcsupport supporting-cyclic-garbage-collection17411174
Ref: 4ceb17411174
Ref: c-api/gcsupport c PyObject_GC_New17414110
Ref: a7017414110
Ref: c-api/gcsupport c PyObject_GC_NewVar17414288
Ref: a7117414288
Ref: c-api/gcsupport c PyUnstable_Object_GC_NewWithExtraData17414478
Ref: 16a017414478
Ref: c-api/gcsupport c PyObject_GC_Resize17415556
Ref: 16a517415556
Ref: c-api/gcsupport c PyObject_GC_Track17415946
Ref: 14af17415946
Ref: c-api/gcsupport c PyObject_IS_GC17416557
Ref: 95217416557
Ref: c-api/gcsupport c PyObject_GC_IsTracked17416809
Ref: 94417416809
Ref: c-api/gcsupport c PyObject_GC_IsFinalized17417215
Ref: 94517417215
Ref: c-api/gcsupport c PyObject_GC_Del17417624
Ref: 14ae17417624
Ref: c-api/gcsupport c PyObject_GC_UnTrack17417843
Ref: 14b017417843
Ref: c-api/gcsupport c visitproc17418765
Ref: 495417418765
Ref: c-api/gcsupport c traverseproc17419565
Ref: 495217419565
Ref: c-api/gcsupport c Py_VISIT17420728
Ref: 478417420728
Ref: c-api/gcsupport c inquiry17421477
Ref: 494317421477
Node: Controlling the Garbage Collector State17422351
Ref: c-api/gcsupport controlling-the-garbage-collector-state17422531
Ref: 4cec17422531
Ref: c-api/gcsupport c PyGC_Collect17422715
Ref: 95c17422715
Ref: c-api/gcsupport c PyGC_Enable17423291
Ref: 87117423291
Ref: c-api/gcsupport c PyGC_Disable17423581
Ref: 87217423581
Ref: c-api/gcsupport c PyGC_IsEnabled17423874
Ref: 87317423874
Node: Querying Garbage Collector State17424187
Ref: c-api/gcsupport querying-garbage-collector-state17424367
Ref: 4ced17424367
Ref: c-api/gcsupport c PyUnstable_GC_VisitObjects17424550
Ref: 4cee17424550
Ref: c-api/gcsupport c gcvisitobjects_t17425402
Ref: 4cef17425402
Node: API と ABI のバージョニング17425900
Ref: c-api/apiabiversion doc17426119
Ref: 4cf017426119
Ref: c-api/apiabiversion api-and-abi-versioning17426119
Ref: 4cf117426119
Ref: c-api/apiabiversion apiabiversion17426119
Ref: 420317426119
Ref: c-api/apiabiversion c PY_MAJOR_VERSION17426591
Ref: 4cf217426591
Ref: c-api/apiabiversion c PY_MINOR_VERSION17426665
Ref: 4cf317426665
Ref: c-api/apiabiversion c PY_MICRO_VERSION17426739
Ref: 4cf417426739
Ref: c-api/apiabiversion c PY_RELEASE_LEVEL17426813
Ref: 4cf517426813
Ref: c-api/apiabiversion c PY_RELEASE_SERIAL17427036
Ref: 4cf617427036
Ref: c-api/apiabiversion c PY_VERSION_HEX17427156
Ref: 72217427156
Ref: c-api/apiabiversion c Py_Version17429222
Ref: 72117429222
Ref: API と ABI のバージョニング-Footnote-117429758
Node: Monitoring C API17429831
Ref: c-api/monitoring doc17430011
Ref: 4cf717430011
Ref: c-api/monitoring c-api-monitoring17430011
Ref: 14217430011
Ref: c-api/monitoring monitoring-c-api17430011
Ref: 4cf817430011
Node: Generating Execution Events17430265
Ref: c-api/monitoring generating-execution-events17430400
Ref: 4cf917430400
Ref: c-api/monitoring c PyMonitoringState17431335
Ref: 2f017431335
Ref: c-api/monitoring c PyMonitoring_FirePyStartEvent17431708
Ref: 2f117431708
Ref: c-api/monitoring c PyMonitoring_FirePyResumeEvent17431868
Ref: 2f217431868
Ref: c-api/monitoring c PyMonitoring_FirePyReturnEvent17432030
Ref: 2f317432030
Ref: c-api/monitoring c PyMonitoring_FirePyYieldEvent17432210
Ref: 2f417432210
Ref: c-api/monitoring c PyMonitoring_FireCallEvent17432388
Ref: 2f517432388
Ref: c-api/monitoring c PyMonitoring_FireLineEvent17432587
Ref: 2f617432587
Ref: c-api/monitoring c PyMonitoring_FireJumpEvent17432752
Ref: 2f717432752
Ref: c-api/monitoring c PyMonitoring_FireBranchEvent17432930
Ref: 2f817432930
Ref: c-api/monitoring c PyMonitoring_FireCReturnEvent17433122
Ref: 2f917433122
Ref: c-api/monitoring c PyMonitoring_FirePyThrowEvent17433300
Ref: 2fa17433300
Ref: c-api/monitoring c PyMonitoring_FireRaiseEvent17433548
Ref: 2fb17433548
Ref: c-api/monitoring c PyMonitoring_FireCRaiseEvent17433791
Ref: 2fc17433791
Ref: c-api/monitoring c PyMonitoring_FireReraiseEvent17434037
Ref: 2fd17434037
Ref: c-api/monitoring c PyMonitoring_FireExceptionHandledEvent17434284
Ref: 2fe17434284
Ref: c-api/monitoring c PyMonitoring_FirePyUnwindEvent17434551
Ref: 2ff17434551
Ref: c-api/monitoring c PyMonitoring_FireStopIterationEvent17434801
Ref: 30017434801
Node: Managing the Monitoring State17435219
Ref: c-api/monitoring managing-the-monitoring-state17435312
Ref: 4cfa17435312
Ref: c-api/monitoring c PyMonitoring_EnterScope17435515
Ref: 30117435515
Ref: c-api/monitoring c PY_MONITORING_EVENT_BRANCH17437572
Ref: 4cfb17437572
Ref: c-api/monitoring c PY_MONITORING_EVENT_CALL17437776
Ref: 4cfc17437776
Ref: c-api/monitoring c PY_MONITORING_EVENT_C_RAISE17437983
Ref: 4cfd17437983
Ref: c-api/monitoring c PY_MONITORING_EVENT_C_RETURN17438191
Ref: 4cfe17438191
Ref: c-api/monitoring c PY_MONITORING_EVENT_EXCEPTION_HANDLED17438370
Ref: 4cff17438370
Ref: c-api/monitoring c PY_MONITORING_EVENT_INSTRUCTION17438559
Ref: 4d0017438559
Ref: c-api/monitoring c PY_MONITORING_EVENT_JUMP17438763
Ref: 4d0117438763
Ref: c-api/monitoring c PY_MONITORING_EVENT_LINE17438967
Ref: 4d0217438967
Ref: c-api/monitoring c PY_MONITORING_EVENT_PY_RESUME17439176
Ref: 4d0317439176
Ref: c-api/monitoring c PY_MONITORING_EVENT_PY_RETURN17439385
Ref: 4d0417439385
Ref: c-api/monitoring c PY_MONITORING_EVENT_PY_START17439593
Ref: 4d0517439593
Ref: c-api/monitoring c PY_MONITORING_EVENT_PY_THROW17439801
Ref: 4d0617439801
Ref: c-api/monitoring c PY_MONITORING_EVENT_PY_UNWIND17440010
Ref: 4d0717440010
Ref: c-api/monitoring c PY_MONITORING_EVENT_PY_YIELD17440218
Ref: 4d0817440218
Ref: c-api/monitoring c PY_MONITORING_EVENT_RAISE17440423
Ref: 4d0917440423
Ref: c-api/monitoring c PY_MONITORING_EVENT_RERAISE17440630
Ref: 4d0a17440630
Ref: c-api/monitoring c PY_MONITORING_EVENT_STOP_ITERATION17440844
Ref: 4d0b17440844
Ref: c-api/monitoring c PyMonitoring_ExitScope17440939
Ref: 30217440939
Node: Python モジュールのインストール17441077
Ref: installing/index doc17441236
Ref: 4d0c17441236
Ref: installing/index installing-index17441236
Ref: ec017441236
Ref: installing/index installing-python-modules17441236
Ref: 4d0d17441236
Ref: Python モジュールのインストール-Footnote-117442985
Node: 重要用語集17443063
Ref: installing/index key-terms17443191
Ref: 4d0e17443191
Ref: 重要用語集-Footnote-117445978
Ref: 重要用語集-Footnote-217446003
Ref: 重要用語集-Footnote-317446032
Ref: 重要用語集-Footnote-417446064
Node: 基本的な使い方<3>17446144
Ref: installing/index basic-usage17446309
Ref: 4d0f17446309
Ref: 基本的な使い方<3>-Footnote-117448317
Ref: 基本的な使い方<3>-Footnote-217448354
Node: どうすればいいの ？17448403
Ref: installing/index how-do-i17448601
Ref: 4d1017448601
Node: pip を 3 4 より前のバージョンの Python でインストールするには？17449489
Ref: installing/index install-pip-in-versions-of-python-prior-to-python-3-417449730
Ref: 4d1117449730
Ref: pip を 3 4 より前のバージョンの Python でインストールするには？-Footnote-117450251
Node: パッケージを現在のユーザ用のみにインストールするには？17450338
Ref: installing/index install-packages-just-for-the-current-user17450671
Ref: 4d1217450671
Node: 科学技術計算用の Python パッケージをインストールするには？17451058
Ref: installing/index install-scientific-python-packages17451397
Ref: 4d1317451397
Ref: 科学技術計算用の Python パッケージをインストールするには？-Footnote-117452095
Ref: 科学技術計算用の Python パッケージをインストールするには？-Footnote-217452141
Node: インストールされた複数のバージョンの Python を並行して使うには？17452187
Ref: installing/index work-with-multiple-versions-of-python-installed-in-parallel17452436
Ref: 4d1417452436
Node: よくあるインストールに関する問題17453605
Ref: installing/index common-installation-issues17453770
Ref: 4d1517453770
Node: Linux で、システムの Python 内にインストールする17454036
Ref: installing/index installing-into-the-system-python-on-linux17454238
Ref: 4d1617454238
Node: pip がインストールされていない17455147
Ref: installing/index pip-not-installed17455400
Ref: 4d1717455400
Ref: pip がインストールされていない-Footnote-117455794
Node: バイナリの拡張のインストール17455920
Ref: installing/index installing-binary-extensions17456099
Ref: 4d1817456099
Ref: バイナリの拡張のインストール-Footnote-117457274
Ref: バイナリの拡張のインストール-Footnote-217457320
Node: Python HOWTO17457369
Ref: howto/index doc17457507
Ref: 4d1917457507
Ref: howto/index python-howtos17457507
Ref: 4d1a17457507
Node: Python 3 への拡張モジュール移植17458721
Ref: howto/cporting doc17458860
Ref: 4d1b17458860
Ref: howto/cporting cporting-howto17458860
Ref: 12af17458860
Ref: howto/cporting porting-extension-modules-to-python-317458860
Ref: 4d1c17458860
Ref: Python 3 への拡張モジュール移植-Footnote-117459713
Ref: Python 3 への拡張モジュール移植-Footnote-217459764
Ref: Python 3 への拡張モジュール移植-Footnote-317459821
Ref: Python 3 への拡張モジュール移植-Footnote-417459849
Node: Python で Curses プログラミング17459896
Ref: howto/curses doc17460072
Ref: 4d1d17460072
Ref: howto/curses curses-howto17460072
Ref: 2cff17460072
Ref: howto/curses curses-programming-with-python17460072
Ref: 4d1e17460072
Node: curses ってなに?17460587
Ref: howto/curses what-is-curses17460741
Ref: 4d1f17460741
Ref: curses ってなに?-Footnote-117463698
Ref: curses ってなに?-Footnote-217463738
Node: Python の curses module17463782
Ref: howto/curses the-python-curses-module17463863
Ref: 4d2017463863
Node: curses アプリケーションの起動と終了17464832
Ref: howto/curses starting-and-ending-a-curses-application17465022
Ref: 4d2117465022
Node: ウィンドウとパッド17468711
Ref: howto/curses windows-and-pads17468902
Ref: 4d2217468902
Node: テキストの表示17473538
Ref: howto/curses displaying-text17473695
Ref: 4d2317473695
Node: 属性とカラー17477797
Ref: howto/curses attributes-and-color17477873
Ref: 4d2417477873
Node: ユーザ入力17482777
Ref: howto/curses user-input17482928
Ref: 4d2517482928
Ref: ユーザ入力-Footnote-117486817
Node: より多くの情報17486857
Ref: howto/curses for-more-information17486978
Ref: 4d2617486978
Ref: より多くの情報-Footnote-117488590
Ref: より多くの情報-Footnote-217488627
Ref: より多くの情報-Footnote-317488691
Ref: より多くの情報-Footnote-417488735
Ref: より多くの情報-Footnote-517488797
Ref: より多くの情報-Footnote-617488849
Node: デスクリプタ ガイド17488920
Ref: howto/descriptor doc17489111
Ref: 4d2717489111
Ref: howto/descriptor descriptor-guide17489111
Ref: 4d2817489111
Ref: howto/descriptor descriptorhowto17489111
Ref: 149517489111
Node: 入門17490818
Ref: howto/descriptor primer17490922
Ref: 4d2917490922
Node: シンプルな例 定数を返すデスクリプタ17491304
Ref: howto/descriptor simple-example-a-descriptor-that-returns-a-constant17491435
Ref: 4d2a17491435
Node: 動的なルックアップ17493239
Ref: howto/descriptor dynamic-lookups17493400
Ref: 4d2b17493400
Node: 管理された属性17494993
Ref: howto/descriptor managed-attributes17495129
Ref: 4d2c17495129
Node: 名前のカスタマイズ17498150
Ref: howto/descriptor customized-names17498268
Ref: 4d2d17498268
Node: まとめ17500948
Ref: howto/descriptor closing-thoughts17501036
Ref: 4d2e17501036
Node: 実践的なサンプル17503078
Ref: howto/descriptor complete-practical-example17503224
Ref: 4d2f17503224
Node: バリデータクラス17503565
Ref: howto/descriptor validator-class17503686
Ref: 4d3017503686
Node: カスタムバリデータ17504885
Ref: howto/descriptor custom-validators17505051
Ref: 4d3117505051
Ref: カスタムバリデータ-Footnote-117507852
Node: 実践的なアプリケーション17507921
Ref: howto/descriptor practical-application17508054
Ref: 4d3217508054
Node: 技術的なチュートリアル17509539
Ref: howto/descriptor technical-tutorial17509709
Ref: 4d3317509709
Node: 概要<5>17510271
Ref: howto/descriptor abstract17510374
Ref: 4d3417510374
Node: 定義と導入17510823
Ref: howto/descriptor definition-and-introduction17510968
Ref: 4d3517510968
Node: デスクリプタプロトコル17512441
Ref: howto/descriptor descriptor-protocol17512616
Ref: 4d3617512616
Node: デスクリプタ呼び出しの概要17514325
Ref: howto/descriptor overview-of-descriptor-invocation17514524
Ref: 4d3717514524
Node: インスタンスからの呼び出し17515284
Ref: howto/descriptor invocation-from-an-instance17515480
Ref: 4d3817515480
Node: クラスからの呼び出し17518308
Ref: howto/descriptor invocation-from-a-class17518491
Ref: 4d3917518491
Ref: クラスからの呼び出し-Footnote-117519270
Node: superからの呼び出し17519343
Ref: howto/descriptor invocation-from-super17519523
Ref: 4d3a17519523
Ref: superからの呼び出し-Footnote-117520279
Ref: superからの呼び出し-Footnote-217520352
Node: 呼び出しロジックのまとめ17520432
Ref: howto/descriptor summary-of-invocation-logic17520609
Ref: 4d3b17520609
Node: 自動的の名前の伝達17521855
Ref: howto/descriptor automatic-name-notification17522024
Ref: 4d3c17522024
Ref: 自動的の名前の伝達-Footnote-117523118
Node: ORMのサンプル17523191
Ref: howto/descriptor orm-example17523315
Ref: 4d3d17523315
Ref: ORMのサンプル-Footnote-117525587
Ref: ORMのサンプル-Footnote-217525659
Node: ピュアPythonの等価実装17525753
Ref: howto/descriptor pure-python-equivalents17525890
Ref: 4d3e17525890
Node: プロパティ17526521
Ref: howto/descriptor properties17526633
Ref: 4d3f17526633
Node: 関数とメソッド17529793
Ref: howto/descriptor functions-and-methods17529935
Ref: 4d4017529935
Node: メソッドの種類17533818
Ref: howto/descriptor kinds-of-methods17533963
Ref: 4d4117533963
Node: 静的メソッド17535450
Ref: howto/descriptor static-methods17535595
Ref: 4d4217535595
Node: クラスメソッド17537834
Ref: howto/descriptor class-methods17538001
Ref: 4d4317538001
Node: メンバーオブジェクトと __slots__17540325
Ref: howto/descriptor member-objects-and-slots17540465
Ref: 4d4417540465
Ref: メンバーオブジェクトと __slots__-Footnote-117548525
Node: Debugging C API extensions and CPython Internals with GDB17548581
Ref: howto/gdb_helpers doc17548748
Ref: 4d4517548748
Ref: howto/gdb_helpers debugging-c-api-extensions-and-cpython-internals-with-gdb17548748
Ref: 4d4617548748
Ref: howto/gdb_helpers gdb17548748
Ref: 4d4717548748
Ref: Debugging C API extensions and CPython Internals with GDB-Footnote-117550150
Ref: Debugging C API extensions and CPython Internals with GDB-Footnote-217550186
Node: Prerequisites17550240
Ref: howto/gdb_helpers prerequisites17550398
Ref: 4d4817550398
Node: Setup with Python built from source17551039
Ref: howto/gdb_helpers setup-with-python-built-from-source17551169
Ref: 4d4917551169
Node: Setup for Python from a Linux distro17551936
Ref: howto/gdb_helpers setup-for-python-from-a-linux-distro17552066
Ref: 4d4a17552066
Node: Using the Debug build and Development mode17552714
Ref: howto/gdb_helpers using-the-debug-build-and-development-mode17552911
Ref: 4d4b17552911
Node: Using the python-gdb extension17553515
Ref: howto/gdb_helpers using-the-python-gdb-extension17553720
Ref: 4d4c17553720
Node: Pretty-printers17554026
Ref: howto/gdb_helpers pretty-printers17554124
Ref: 4d4d17554124
Node: py-list17558649
Ref: howto/gdb_helpers py-list17558773
Ref: 4d4e17558773
Node: py-up and py-down17559661
Ref: howto/gdb_helpers py-up-and-py-down17559775
Ref: 4d4f17559775
Node: py-bt17564490
Ref: howto/gdb_helpers py-bt17564605
Ref: 4d5017564605
Node: py-print17566856
Ref: howto/gdb_helpers py-print17566963
Ref: 4d5117566963
Node: py-locals17567712
Ref: howto/gdb_helpers py-locals17567805
Ref: 4d5217567805
Node: Use with GDB commands17568708
Ref: howto/gdb_helpers use-with-gdb-commands17568862
Ref: 4d5317568862
Node: 列挙型 HOWTO17574881
Ref: howto/enum doc17575056
Ref: 4d5417575056
Ref: howto/enum enum-howto17575056
Ref: 4d5517575056
Ref: howto/enum id117575056
Ref: 4d5617575056
Ref: howto/enum enum-basic-tutorial17575094
Ref: 250617575094
Node: 列挙型メンバーおよびそれらの属性へのプログラム的アクセス17581991
Ref: howto/enum enum-advanced-tutorial17582172
Ref: 250717582172
Ref: howto/enum programmatic-access-to-enumeration-members-and-their-attributes17582172
Ref: 4d5717582172
Node: 列挙型メンバーと値の重複17583095
Ref: howto/enum duplicating-enum-members-and-values17583336
Ref: 4d5817583336
Node: 番号付けの値が一意であることの確認17584719
Ref: howto/enum ensuring-unique-enumeration-values17584903
Ref: 4d5917584903
Node: 値の自動設定を使う17585527
Ref: howto/enum using-automatic-values17585699
Ref: 4d5a17585699
Node: イテレーション<2>17586715
Ref: howto/enum iteration17586845
Ref: 4d5b17586845
Node: 比較<3>17588354
Ref: howto/enum comparisons17588502
Ref: 4d5c17588502
Node: 列挙型で許されるメンバーと属性17589798
Ref: howto/enum allowed-members-and-attributes-of-enumerations17589956
Ref: 4d5e17589956
Node: Enumのサブクラス化の制限17592491
Ref: howto/enum restricted-enum-subclassing17592673
Ref: 4d6217592673
Node: データクラスのサポート17594063
Ref: howto/enum dataclass-support17594210
Ref: 4d6417594210
Ref: howto/enum enum-dataclass-support17594210
Ref: 16ef17594210
Node: Pickle 化17595776
Ref: howto/enum pickling17595902
Ref: 4d6517595902
Node: 関数 API<2>17597147
Ref: howto/enum functional-api17597255
Ref: 4d5f17597255
Node: 派生列挙型17601357
Ref: howto/enum derived-enumerations17601506
Ref: 4d6617601506
Node: IntEnum17601630
Ref: howto/enum intenum17601705
Ref: 4d5d17601705
Node: StrEnum17602874
Ref: howto/enum strenum17602965
Ref: 4d6717602965
Node: IntFlag17603313
Ref: howto/enum intflag17603401
Ref: 4d6817603401
Node: Flag17606243
Ref: howto/enum flag17606336
Ref: 4d6917606336
Node: その他<4>17609005
Ref: howto/enum others17609082
Ref: 4d6a17609082
Node: __new__ と __init__ のどちらを使うべきか17611686
Ref: howto/enum new-vs-init17611857
Ref: 4d6117611857
Ref: howto/enum when-to-use-new-vs-init17611857
Ref: 4d6b17611857
Node: 細かい点17613255
Ref: howto/enum finer-points17613355
Ref: 4d6c17613355
Node: __dunder__ 名のサポート<2>17613798
Ref: howto/enum supported-dunder-names17613918
Ref: 4d6d17613918
Node: _sunder_ 名のサポート<2>17614505
Ref: howto/enum supported-sunder-names17614649
Ref: 4d6e17614649
Node: _Private__names17617040
Ref: howto/enum private-names17617172
Ref: 4d7017617172
Node: Enum メンバー型17617367
Ref: howto/enum enum-member-type17617522
Ref: 4d7117617522
Node: Creating members that are mixed with other data types17617988
Ref: howto/enum creating-members-that-are-mixed-with-other-data-types17618169
Ref: 4d7217618169
Node: Enum クラスとメンバーの真偽値17618702
Ref: howto/enum boolean-value-of-enum-classes-and-members17618899
Ref: 4d7317618899
Node: メソッド付きの Enum クラス17619573
Ref: howto/enum enum-classes-with-methods17619755
Ref: 4d7417619755
Node: Flag のメンバーの組み合わせ17620394
Ref: howto/enum combining-members-of-flag17620559
Ref: 4d7517620559
Node: Flag and IntFlag minutia17621136
Ref: howto/enum flag-and-intflag-minutia17621256
Ref: 4d7617621256
Node: EnumとFlagはどう違うのか？17624023
Ref: howto/enum enum-class-differences17624202
Ref: 250917624202
Ref: howto/enum how-are-enums-and-flags-different17624202
Ref: 4d7717624202
Node: Enum クラス17624619
Ref: howto/enum enum-classes17624728
Ref: 4d7817624728
Node: Flag クラス17625338
Ref: howto/enum flag-classes17625492
Ref: 4d7917625492
Node: Enum メンバー インスタンス17625859
Ref: howto/enum enum-members-aka-instances17626016
Ref: 4d7a17626016
Node: Flag メンバー17626508
Ref: howto/enum flag-members17626642
Ref: 4d7b17626642
Node: Enum クックブック17627351
Ref: howto/enum enum-cookbook17627515
Ref: 250817627515
Ref: howto/enum id217627515
Ref: 4d7c17627515
Node: 値の省略17628063
Ref: howto/enum omitting-values17628155
Ref: 4d7d17628155
Node: auto を使う17629090
Ref: howto/enum using-auto17629178
Ref: 4d7e17629178
Node: object を使う17629453
Ref: howto/enum using-object17629574
Ref: 4d7f17629574
Node: 解説文字列を使う17630266
Ref: howto/enum using-a-descriptive-string17630400
Ref: 4d8017630400
Node: 独自の __new__ を使う17630692
Ref: howto/enum using-a-custom-new17630801
Ref: 4d8117630801
Node: OrderedEnum17632755
Ref: howto/enum orderedenum17632873
Ref: 4d6317632873
Node: DuplicateFreeEnum17634090
Ref: howto/enum duplicatefreeenum17634210
Ref: 4d8217634210
Node: MultiValueEnum17635388
Ref: howto/enum multivalueenum17635503
Ref: 4d6f17635503
Node: Planet17636086
Ref: howto/enum planet17636194
Ref: 4d6017636194
Node: TimePeriod17637275
Ref: howto/enum enum-time-period17637360
Ref: 252117637360
Ref: howto/enum timeperiod17637360
Ref: 4d8317637360
Node: EnumType のサブクラスを作る17637978
Ref: howto/enum enumtype-examples17638098
Ref: 250f17638098
Ref: howto/enum subclassing-enumtype17638098
Ref: 4d8417638098
Node: 関数型プログラミング HOWTO17638385
Ref: howto/functional doc17638516
Ref: 4d8517638516
Ref: howto/functional functional-howto17638516
Ref: 4d8617638516
Ref: howto/functional functional-programming-howto17638516
Ref: 4d8717638516
Node: はじめに<12>17639546
Ref: howto/functional introduction17639671
Ref: 4d8817639671
Node: 形式的証明可能性17645688
Ref: howto/functional formal-provability17645792
Ref: 4d8a17645792
Node: モジュラー性17648258
Ref: howto/functional modularity17648407
Ref: 4d8b17648407
Node: デバッグやテストの簡単さ17648930
Ref: howto/functional ease-of-debugging-and-testing17649064
Ref: 4d8c17649064
Node: 結合性17650033
Ref: howto/functional composability17650140
Ref: 4d8d17650140
Node: イテレータ iterator<2>17650994
Ref: howto/functional functional-howto-iterators17651173
Ref: 4d8917651173
Ref: howto/functional iterators17651173
Ref: 4d8e17651173
Node: イテレータ対応のデータ型17655475
Ref: howto/functional data-types-that-support-iterators17655575
Ref: 4d8f17655575
Node: ジェネレータ式とリスト内包表記17657940
Ref: howto/functional generator-expressions-and-list-comprehensions17658134
Ref: 4d9017658134
Node: ジェネレータ generator<2>17663347
Ref: howto/functional generators17663553
Ref: 4d9117663553
Ref: ジェネレータ generator<2>-Footnote-117668175
Node: ジェネレータに値を渡す17668256
Ref: howto/functional passing-values-into-a-generator17668357
Ref: 4d9217668357
Ref: ジェネレータに値を渡す-Footnote-117673084
Node: 組み込み関数 built-in function<2>17673126
Ref: howto/functional built-in-functions17673312
Ref: 4d9317673312
Ref: 組み込み関数 built-in function<2>-Footnote-117677890
Ref: 組み込み関数 built-in function<2>-Footnote-217677944
Node: itertools モジュール17678020
Ref: howto/functional the-itertools-module17678200
Ref: 4d9417678200
Node: 新しいイテレータを作る17679068
Ref: howto/functional creating-new-iterators17679205
Ref: 4d9517679205
Node: 要素に対して関数を呼ぶ17682104
Ref: howto/functional calling-functions-on-elements17682271
Ref: 4d9617682271
Node: 要素を選択する17683188
Ref: howto/functional selecting-elements17683337
Ref: 4d9717683337
Node: 組合せ関数17684951
Ref: howto/functional combinatoric-functions17685100
Ref: 4d9817685100
Node: 要素をグループ分けする17687636
Ref: howto/functional grouping-elements17687755
Ref: 4d9917687755
Node: functools モジュール17689545
Ref: howto/functional the-functools-module17689716
Ref: 4d9a17689716
Node: operator モジュール17693870
Ref: howto/functional the-operator-module17693956
Ref: 4d9b17693956
Node: 小さな関数とラムダ式17694861
Ref: howto/functional small-functions-and-the-lambda-expression17695028
Ref: 4d9c17695028
Node: 更新履歴と謝辞17698493
Ref: howto/functional revision-history-and-acknowledgements17698650
Ref: 4d9d17698650
Node: 参考資料<2>17699378
Ref: howto/functional references17699496
Ref: 4d9e17699496
Node: 一般論17699599
Ref: howto/functional general17699688
Ref: 4d9f17699688
Node: Python 特有の話17700916
Ref: howto/functional python-specific17701027
Ref: 4da017701027
Ref: Python 特有の話-Footnote-117701605
Ref: Python 特有の話-Footnote-217701656
Ref: Python 特有の話-Footnote-317701709
Node: Python 文書17701762
Ref: howto/functional python-documentation17701855
Ref: 4da117701855
Ref: Python 文書-Footnote-117702248
Ref: Python 文書-Footnote-217702290
Node: Logging HOWTO17702332
Ref: howto/logging doc17702474
Ref: 4da217702474
Ref: howto/logging id117702474
Ref: 4da317702474
Ref: howto/logging logging-howto17702474
Ref: 4da417702474
Ref: howto/logging logging-basic-tutorial17702567
Ref: 11c617702567
Node: 基本 logging チュートリアル17703078
Ref: howto/logging basic-logging-tutorial17703212
Ref: 4da617703212
Node: logging を使うとき17704225
Ref: howto/logging when-to-use-logging17704345
Ref: 4da717704345
Node: 簡単な例<2>17708655
Ref: howto/logging a-simple-example17708810
Ref: 4da817708810
Ref: howto/logging howto-minimal-example17708810
Ref: 4da917708810
Node: ファイルへの logging17710085
Ref: howto/logging logging-to-a-file17710247
Ref: 4daa17710247
Node: 変数データのロギング17713832
Ref: howto/logging logging-variable-data17714039
Ref: 4dab17714039
Node: 表示されるメッセージのフォーマットの変更17715138
Ref: howto/logging changing-the-format-of-displayed-messages17715367
Ref: 4dac17715367
Node: メッセージ内での日付と時刻の表示17716543
Ref: howto/logging displaying-the-date-time-in-messages17716760
Ref: 4dad17716760
Ref: メッセージ内での日付と時刻の表示-Footnote-117718005
Node: 次のステップ17718064
Ref: howto/logging next-steps17718212
Ref: 4dae17718212
Node: 上級ロギングチュートリアル17719374
Ref: howto/logging advanced-logging-tutorial17719541
Ref: 4daf17719541
Ref: howto/logging logging-advanced-tutorial17719541
Ref: 11c717719541
Node: Logging Flow17724102
Ref: howto/logging logging-flow17724208
Ref: 4db017724208
Node: ロガー17724403
Ref: howto/logging loggers17724530
Ref: 4db117724530
Node: ハンドラ17730102
Ref: howto/logging handler-basic17730235
Ref: 4db217730235
Ref: howto/logging handlers17730235
Ref: 4db317730235
Node: フォーマッタ17732998
Ref: howto/logging formatters17733149
Ref: 4db517733149
Ref: howto/logging logging logging Formatter __init__17733844
Ref: 4db617733844
Node: ロギングの環境設定17736087
Ref: howto/logging configuring-logging17736277
Ref: 4db717736277
Node: 環境設定が与えられないとどうなるか17743502
Ref: howto/logging what-happens-if-no-configuration-is-provided17743722
Ref: 4db817743722
Node: ライブラリのためのロギングの設定17745295
Ref: howto/logging configuring-logging-for-a-library17745479
Ref: 4db917745479
Ref: howto/logging library-config17745479
Ref: 2ca817745479
Node: ロギングレベル<2>17749226
Ref: howto/logging logging-levels17749378
Ref: 4dba17749378
Node: カスタムレベル17753003
Ref: howto/logging custom-levels17753085
Ref: 2c7217753085
Ref: howto/logging id217753085
Ref: 4dbb17753085
Node: 便利なハンドラ17753819
Ref: howto/logging id317753968
Ref: 4dbc17753968
Ref: howto/logging useful-handlers17753968
Ref: 4db417753968
Node: ログ記録中に発生する例外17759502
Ref: howto/logging exceptions-raised-during-logging17759687
Ref: 4dbd17759687
Ref: howto/logging logging-exceptions17759687
Ref: 4dbe17759687
Node: 任意のオブジェクトをメッセージに使用する17761161
Ref: howto/logging arbitrary-object-messages17761338
Ref: 2c5e17761338
Ref: howto/logging using-arbitrary-objects-as-messages17761338
Ref: 4dbf17761338
Node: 最適化<16>17762224
Ref: howto/logging optimization17762389
Ref: 4dc017762389
Node: その他のリソース17766781
Ref: howto/logging other-resources17766877
Ref: 4dc117766877
Ref: howto/logging tutorial-ref-links17766877
Ref: 4da517766877
Node: Logging クックブック17767310
Ref: howto/logging-cookbook doc17767434
Ref: 4dc217767434
Ref: howto/logging-cookbook id117767434
Ref: 4dc317767434
Ref: howto/logging-cookbook logging-cookbook17767434
Ref: 11c817767434
Node: 複数のモジュールで logging を使う17770036
Ref: howto/logging-cookbook using-logging-in-multiple-modules17770195
Ref: 4dc517770195
Node: 複数のスレッドからのロギング17773995
Ref: howto/logging-cookbook logging-from-multiple-threads17774194
Ref: 4dc617774194
Node: 複数の handler と formatter17776072
Ref: howto/logging-cookbook multiple-handlers-and-formatters17776268
Ref: 4dc717776268
Node: 複数の出力先にログを出力する17778860
Ref: howto/logging-cookbook logging-to-multiple-destinations17779050
Ref: 4dc817779050
Ref: howto/logging-cookbook multiple-destinations17779050
Ref: 4dc917779050
Node: ログレベルのカスタム処理17782743
Ref: howto/logging-cookbook custom-handling-of-levels17782923
Ref: 4dca17782923
Ref: howto/logging-cookbook custom-level-handling17782923
Ref: 4dcb17782923
Node: 設定サーバの例17789325
Ref: howto/logging-cookbook configuration-server-example17789499
Ref: 4dcc17789499
Node: ブロックする handler を扱う17791102
Ref: howto/logging-cookbook blocking-handlers17791300
Ref: 32a117791300
Ref: howto/logging-cookbook dealing-with-handlers-that-block17791300
Ref: 4dcd17791300
Node: ネットワーク越しの logging イベントの送受信17796583
Ref: howto/logging-cookbook network-logging17796820
Ref: 4dce17796820
Ref: howto/logging-cookbook sending-and-receiving-logging-events-across-a-network17796820
Ref: 4dcf17796820
Node: 作成中のロギングソケットのリスナーを実行する17802582
Ref: howto/logging-cookbook running-a-logging-socket-listener-in-production17802745
Ref: 4dd017802745
Ref: 作成中のロギングソケットのリスナーを実行する-Footnote-117807278
Ref: 作成中のロギングソケットのリスナーを実行する-Footnote-217807310
Ref: 作成中のロギングソケットのリスナーを実行する-Footnote-317807382
Ref: 作成中のロギングソケットのリスナーを実行する-Footnote-417807412
Node: コンテキスト情報をログ記録出力に付加する17807484
Ref: howto/logging-cookbook adding-contextual-information-to-your-logging-output17807706
Ref: 4dd117807706
Ref: howto/logging-cookbook context-info17807706
Ref: 2c6517807706
Node: LoggerAdapter を使ったコンテキスト情報の伝達17809162
Ref: howto/logging-cookbook using-loggeradapters-to-impart-contextual-information17809379
Ref: 4dd217809379
Node: コンテキスト情報を渡すために dict 以外のオブジェクトを使う17813346
Ref: howto/logging-cookbook using-objects-other-than-dicts-to-pass-contextual-information17813526
Ref: 4dd317813526
Node: Filter を使ったコンテキスト情報の伝達17814056
Ref: howto/logging-cookbook filters-contextual17814273
Ref: 2c5a17814273
Ref: howto/logging-cookbook using-filters-to-impart-contextual-information17814273
Ref: 4dd417814273
Node: contextvars の利用17818361
Ref: howto/logging-cookbook use-of-contextvars17818577
Ref: 4dd517818577
Node: ハンドラ内でのコンテキスト情報の付与17828844
Ref: howto/logging-cookbook imparting-contextual-information-in-handlers17829066
Ref: 4dd617829066
Node: 複数のプロセスからの単一ファイルへのログ記録17830109
Ref: howto/logging-cookbook logging-to-a-single-file-from-multiple-processes17830346
Ref: 4dd717830346
Ref: howto/logging-cookbook multiple-processes17830346
Ref: 4dd817830346
Node: concurrent futures ProcessPoolExecutorの利用17841210
Ref: howto/logging-cookbook using-concurrent-futures-processpoolexecutor17841444
Ref: 4dd917841444
Node: Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ17842668
Ref: howto/logging-cookbook deploying-web-applications-using-gunicorn-and-uwsgi17842902
Ref: 4dda17842902
Ref: Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ-Footnote-117843906
Ref: Gunicorn と uWSGI を用いた Web アプリケーションのデプロイ-Footnote-217843936
Node: ファイルをローテートする17843989
Ref: howto/logging-cookbook using-file-rotation17844213
Ref: 4ddb17844213
Node: 別の format スタイルを利用する17846411
Ref: howto/logging-cookbook format-styles17846600
Ref: 4ddc17846600
Ref: howto/logging-cookbook use-of-alternative-formatting-styles17846600
Ref: 4ddd17846600
Node: LogRecord のカスタマイズ17854450
Ref: howto/logging-cookbook custom-logrecord17854663
Ref: 4dde17854663
Ref: howto/logging-cookbook customizing-logrecord17854663
Ref: 4ddf17854663
Node: Subclassing QueueHandler and QueueListener- a ZeroMQ example17859379
Ref: howto/logging-cookbook subclassing-queuehandler-and-queuelistener-a-zeromq-example17859610
Ref: 4de017859610
Ref: howto/logging-cookbook zeromq-handlers17859610
Ref: 4de117859610
Node: Subclass QueueHandler17859810
Ref: howto/logging-cookbook subclass-queuehandler17859959
Ref: 4de217859959
Node: Subclass QueueListener17861312
Ref: howto/logging-cookbook subclass-queuelistener17861461
Ref: 4de317861461
Node: Subclassing QueueHandler and QueueListener- a pynng example17862248
Ref: howto/logging-cookbook pynng-handlers17862481
Ref: 4de417862481
Ref: howto/logging-cookbook subclassing-queuehandler-and-queuelistener-a-pynng-example17862481
Ref: 4de517862481
Ref: Subclassing QueueHandler and QueueListener- a pynng example-Footnote-117863105
Ref: Subclassing QueueHandler and QueueListener- a pynng example-Footnote-217863145
Node: Subclass QueueListener<2>17863178
Ref: howto/logging-cookbook id317863332
Ref: 4de617863332
Node: Subclass QueueHandler<2>17865308
Ref: howto/logging-cookbook id417865462
Ref: 4de717865462
Node: 辞書ベースで構成する例17869174
Ref: howto/logging-cookbook an-example-dictionary-based-configuration17869425
Ref: 4de817869425
Ref: 辞書ベースで構成する例-Footnote-117871394
Ref: 辞書ベースで構成する例-Footnote-217871480
Node: rotator と namer を使ってログローテートをカスタマイズする17871566
Ref: howto/logging-cookbook cookbook-rotator-namer17871802
Ref: 2cb517871802
Ref: howto/logging-cookbook using-a-rotator-and-namer-to-customize-log-rotation-processing17871802
Ref: 4de917871802
Node: より手の込んだ multiprocessing の例17873329
Ref: howto/logging-cookbook a-more-elaborate-multiprocessing-example17873593
Ref: 4dea17873593
Node: SysLogHandler に送るメッセージに BOM を挿入する17883416
Ref: howto/logging-cookbook inserting-a-bom-into-messages-sent-to-a-sysloghandler17883632
Ref: 4deb17883632
Ref: SysLogHandler に送るメッセージに BOM を挿入する-Footnote-117886144
Ref: SysLogHandler に送るメッセージに BOM を挿入する-Footnote-217886203
Ref: SysLogHandler に送るメッセージに BOM を挿入する-Footnote-317886272
Ref: SysLogHandler に送るメッセージに BOM を挿入する-Footnote-417886331
Node: 構造化ログを実装する17886390
Ref: howto/logging-cookbook implementing-structured-logging17886621
Ref: 4dec17886621
Node: handler を dictConfig を使ってカスタマイズする17889346
Ref: howto/logging-cookbook custom-handlers17889588
Ref: 4ded17889588
Ref: howto/logging-cookbook customizing-handlers-with-dictconfig17889588
Ref: 4dee17889588
Node: 固有の書式化スタイルをアプリケーション全体で使う17895213
Ref: howto/logging-cookbook formatting-styles17895483
Ref: 2c4e17895483
Ref: howto/logging-cookbook using-particular-formatting-styles-throughout-your-application17895483
Ref: 4def17895483
Node: LogRecord ファクトリを使う17898108
Ref: howto/logging-cookbook using-logrecord-factories17898317
Ref: 4df017898317
Node: カスタムなメッセージオブジェクトを使う17899562
Ref: howto/logging-cookbook using-custom-message-objects17899771
Ref: 4df117899771
Node: filter を dictConfig を使ってカスタマイズする17903082
Ref: howto/logging-cookbook configuring-filters-with-dictconfig17903338
Ref: 4df217903338
Ref: howto/logging-cookbook filters-dictconfig17903338
Ref: 4df317903338
Node: 例外の書式化をカスタマイズする17906998
Ref: howto/logging-cookbook custom-format-exception17907218
Ref: 4df417907218
Ref: howto/logging-cookbook customized-exception-formatting17907218
Ref: 4df517907218
Node: ロギングメッセージを喋る17909443
Ref: howto/logging-cookbook speaking-logging-messages17909692
Ref: 4df617909692
Ref: howto/logging-cookbook spoken-messages17909692
Ref: 4df717909692
Node: ロギングメッセージをバッファリングし、条件に従って出力する17912277
Ref: howto/logging-cookbook buffered-logging17912566
Ref: 4df817912566
Ref: howto/logging-cookbook buffering-logging-messages-and-outputting-them-conditionally17912566
Ref: 4df917912566
Node: バッファリングしながらロギングメッセージを email で送信する17918711
Ref: howto/logging-cookbook buffered-smtp17919018
Ref: 4dfa17919018
Ref: howto/logging-cookbook sending-logging-messages-to-email-with-buffering17919018
Ref: 4dfb17919018
Node: 設定によって時刻を UTC GMT で書式化する17922971
Ref: howto/logging-cookbook formatting-times-using-utc-gmt-via-configuration17923257
Ref: 4dfc17923257
Ref: howto/logging-cookbook utc-formatting17923257
Ref: 4dfd17923257
Node: ロギングの選択にコンテキストマネージャを使う17925366
Ref: howto/logging-cookbook context-manager17925627
Ref: 4dfe17925627
Ref: howto/logging-cookbook using-a-context-manager-for-selective-logging17925627
Ref: 4dff17925627
Node: CLIアプリケーションスターターテンプレート17931218
Ref: howto/logging-cookbook a-cli-application-starter-template17931446
Ref: 4e0017931446
Ref: howto/logging-cookbook starter-template17931446
Ref: 4e0117931446
Node: Qt GUIのログ出力17937865
Ref: howto/logging-cookbook a-qt-gui-for-logging17938082
Ref: 4e0217938082
Ref: howto/logging-cookbook qt-gui17938082
Ref: 4e0317938082
Ref: Qt GUIのログ出力-Footnote-117948593
Ref: Qt GUIのログ出力-Footnote-217948620
Ref: Qt GUIのログ出力-Footnote-317948662
Node: RFC5424 をサポートする syslog へのロギング17948702
Ref: howto/logging-cookbook logging-to-syslog-with-rfc5424-support17948922
Ref: 4e0417948922
Ref: RFC5424 をサポートする syslog へのロギング-Footnote-117953099
Ref: RFC5424 をサポートする syslog へのロギング-Footnote-217953158
Node: ロガーを出力ストリームのように取り扱う方法17953217
Ref: howto/logging-cookbook how-to-treat-a-logger-like-an-output-stream17953443
Ref: 4e0517953443
Node: 避けるべきパターン17958676
Ref: howto/logging-cookbook patterns-to-avoid17958874
Ref: 4e0617958874
Node: 同じログファイルを何度も開く17959555
Ref: howto/logging-cookbook opening-the-same-log-file-multiple-times17959739
Ref: 4e0717959739
Node: ロガーをクラスの属性にするか、パラメータで渡す17962404
Ref: howto/logging-cookbook using-loggers-as-attributes-in-a-class-or-passing-them-as-parameters17962682
Ref: 4e0817962682
Node: ライブラリ内でロガーに NullHandler 以外のハンドラーを追加する17963492
Ref: howto/logging-cookbook adding-handlers-other-than-nullhandler-to-a-logger-in-a-library17963761
Ref: 4e0917963761
Node: 大量のロガーを作成する17964366
Ref: howto/logging-cookbook creating-a-lot-of-loggers17964557
Ref: 4e0a17964557
Node: その他のリソース<2>17965257
Ref: howto/logging-cookbook cookbook-ref-links17965383
Ref: 4dc417965383
Ref: howto/logging-cookbook other-resources17965383
Ref: 4e0b17965383
Node: 正規表現 HOWTO17965857
Ref: howto/regex doc17966007
Ref: 4e0c17966007
Ref: howto/regex regex-howto17966007
Ref: 224717966007
Ref: howto/regex regular-expression-howto17966007
Ref: 4e0d17966007
Node: はじめに<13>17966593
Ref: howto/regex introduction17966694
Ref: 4e0e17966694
Node: 単純なパターン17968758
Ref: howto/regex simple-patterns17968889
Ref: 4e0f17968889
Node: 文字のマッチング17969471
Ref: howto/regex matching-characters17969574
Ref: 4e1017969574
Node: 繰り返し17975421
Ref: howto/regex repeating-things17975524
Ref: 4e1117975524
Node: 正規表現を使う17981763
Ref: howto/regex using-regular-expressions17981911
Ref: 4e1217981911
Node: 正規表現をコンパイルする17982582
Ref: howto/regex compiling-regular-expressions17982718
Ref: 4e1317982718
Node: バックスラッシュ感染症17984392
Ref: howto/regex id117984555
Ref: 4e1417984555
Ref: howto/regex the-backslash-plague17984555
Ref: 4e1517984555
Node: マッチの実行17988419
Ref: howto/regex performing-matches17988582
Ref: 4e1617988582
Node: モジュールレベルの関数<3>17995384
Ref: howto/regex module-level-functions17995538
Ref: 4e1717995538
Node: コンパイルフラグ17997073
Ref: howto/regex compilation-flags17997200
Ref: 4e1817997200
Node: パターンの能力をさらに18006214
Ref: howto/regex more-pattern-power18006365
Ref: 4e1a18006365
Node: さらなる特殊文字18006919
Ref: howto/regex id218007040
Ref: 4e1b18007040
Ref: howto/regex more-metacharacters18007040
Ref: 4e1918007040
Node: グルーピング18012609
Ref: howto/regex grouping18012796
Ref: 4e1c18012796
Node: 取り出さないグループと名前つきグループ18016893
Ref: howto/regex non-capturing-and-named-groups18017104
Ref: 4e1d18017104
Node: 先読みアサーション Lookahead Assertions18023540
Ref: howto/regex lookahead-assertions18023724
Ref: 4e1e18023724
Node: 文字列を変更する18027997
Ref: howto/regex modifying-strings18028145
Ref: 4e1f18028145
Node: 文字列の分割18029266
Ref: howto/regex splitting-strings18029372
Ref: 4e2018029372
Node: 検索と置換<2>18031924
Ref: howto/regex search-and-replace18032030
Ref: 4e2118032030
Node: よくある問題18037199
Ref: howto/regex common-problems18037335
Ref: 4e2218037335
Node: 文字列メソッドを利用する18037883
Ref: howto/regex use-string-methods18037999
Ref: 4e2318037999
Node: match 対 search18040110
Ref: howto/regex match-versus-search18040272
Ref: 4e2418040272
Node: 貪欲 greedy 対非貪欲 non-greedy18042343
Ref: howto/regex greedy-versus-non-greedy18042489
Ref: 4e2518042489
Node: re VERBOSE の利用18045007
Ref: howto/regex using-re-verbose18045128
Ref: 4e2618045128
Node: フィードバック18046999
Ref: howto/regex feedback18047102
Ref: 4e2718047102
Node: ソケットプログラミング HOWTO18048201
Ref: howto/sockets doc18048352
Ref: 4e2818048352
Ref: howto/sockets socket-howto18048352
Ref: 32f118048352
Ref: howto/sockets socket-programming-howto18048352
Ref: 4e2918048352
Node: ソケット18049193
Ref: howto/sockets sockets18049314
Ref: 4e2a18049314
Node: 歴史18050868
Ref: howto/sockets history18050923
Ref: 4e2b18050923
Node: ソケットの作成<3>18051651
Ref: howto/sockets creating-a-socket18051802
Ref: 4e2c18051802
Node: IPC18055693
Ref: howto/sockets ipc18055757
Ref: 4e2d18055757
Node: ソケットの利用18056353
Ref: howto/sockets using-a-socket18056498
Ref: 4e2e18056498
Node: バイナリデータ18064152
Ref: howto/sockets binary-data18064231
Ref: 4e2f18064231
Ref: バイナリデータ-Footnote-118065511
Node: 切断18065571
Ref: howto/sockets disconnecting18065728
Ref: 4e3018065728
Node: ソケットが死ぬと18067506
Ref: howto/sockets when-sockets-die18067573
Ref: 4e3118067573
Node: ノンブロッキングソケット18068809
Ref: howto/sockets non-blocking-sockets18068936
Ref: 4e3218068936
Node: ソートのテクニック18073884
Ref: howto/sorting doc18074030
Ref: 4e3318074030
Ref: howto/sorting sorting-techniques18074030
Ref: 4e3418074030
Ref: howto/sorting sortinghowto18074030
Ref: 11ab18074030
Node: ソートの基本18074914
Ref: howto/sorting sorting-basics18075015
Ref: 4e3518075015
Node: Key 関数18076089
Ref: howto/sorting key-functions18076265
Ref: 4e3618076265
Node: operator モジュールの関数や partial 関数による評価18078554
Ref: howto/sorting operator-module-functions-and-partial-function-evaluation18078727
Ref: 4e3718078727
Ref: operator モジュールの関数や partial 関数による評価-Footnote-118080725
Node: 昇順と降順18080769
Ref: howto/sorting ascending-and-descending18080977
Ref: 4e3818080977
Node: ソートの安定性と複合的なソート18081592
Ref: howto/sorting sort-stability-and-complex-sorts18081789
Ref: 4e3918081789
Ref: ソートの安定性と複合的なソート-Footnote-118083744
Ref: ソートの安定性と複合的なソート-Footnote-218083810
Node: デコレート - ソート - アンデコレート DSU18083856
Ref: howto/sorting decorate-sort-undecorate18084050
Ref: 4e3a18084050
Ref: デコレート - ソート - アンデコレート DSU-Footnote-118086272
Node: 比較関数18086332
Ref: howto/sorting comparison-functions18086505
Ref: 4e3b18086505
Ref: 比較関数-Footnote-118087712
Node: 残りのはしばし<2>18087799
Ref: howto/sorting odds-and-ends18087938
Ref: 4e3c18087938
Ref: 残りのはしばし<2>-Footnote-118090675
Node: 部分的なソート18090717
Ref: howto/sorting partial-sorts18090835
Ref: 4e3d18090835
Node: Unicode HOWTO18092129
Ref: howto/unicode doc18092330
Ref: 4e3e18092330
Ref: howto/unicode id118092330
Ref: 4e3f18092330
Ref: howto/unicode unicode-howto18092330
Ref: 127618092330
Node: Unicode 入門18092767
Ref: howto/unicode introduction-to-unicode18092871
Ref: 4e4018092871
Node: 定義18093025
Ref: howto/unicode definitions18093118
Ref: 4e4118093118
Ref: 定義-Footnote-118096557
Node: エンコーディング<3>18096614
Ref: howto/unicode encodings18096731
Ref: 4e4218096731
Node: 参考資料<3>18101148
Ref: howto/unicode references18101250
Ref: 4e4318101250
Ref: 参考資料<3>-Footnote-118102211
Ref: 参考資料<3>-Footnote-218102243
Ref: 参考資料<3>-Footnote-318102284
Ref: 参考資料<3>-Footnote-418102336
Ref: 参考資料<3>-Footnote-518102383
Ref: 参考資料<3>-Footnote-618102557
Ref: 参考資料<3>-Footnote-718102614
Node: Python の Unicode サポート18102658
Ref: howto/unicode python-s-unicode-support18102809
Ref: 4e4418102809
Node: 文字列型18103217
Ref: howto/unicode the-string-type18103330
Ref: 4e4518103330
Node: バイト列への変換18107044
Ref: howto/unicode converting-to-bytes18107218
Ref: 4e4618107218
Node: Python ソースコード内の Unicode リテラル18109454
Ref: howto/unicode unicode-literals-in-python-source-code18109639
Ref: 4e4718109639
Ref: Python ソースコード内の Unicode リテラル-Footnote-118112376
Node: Unicode プロパティ18112418
Ref: howto/unicode unicode-properties18112596
Ref: 4e4818112596
Ref: Unicode プロパティ-Footnote-118114435
Node: Comparing Strings18114505
Ref: howto/unicode comparing-strings18114651
Ref: 4e4918114651
Node: Unicode 正規表現18117492
Ref: howto/unicode unicode-regular-expressions18117630
Ref: 4e4a18117630
Node: 参考資料<4>18119082
Ref: howto/unicode id218119194
Ref: 4e4b18119194
Ref: 参考資料<4>-Footnote-118120186
Ref: 参考資料<4>-Footnote-218120282
Ref: 参考資料<4>-Footnote-318120334
Node: Unicode データを読み書きする18120403
Ref: howto/unicode reading-and-writing-unicode-data18120550
Ref: 4e4c18120550
Node: Unicode ファイル名18125202
Ref: howto/unicode unicode-filenames18125364
Ref: 4e4d18125364
Node: Unicode 対応のプログラムを書くための Tips18127994
Ref: howto/unicode tips-for-writing-unicode-aware-programs18128180
Ref: 4e4e18128180
Node: ファイルエンコーディングの変換18130012
Ref: howto/unicode converting-between-file-encodings18130206
Ref: 4e4f18130206
Node: 不明なエンコーディングのファイル18130982
Ref: howto/unicode files-in-an-unknown-encoding18131176
Ref: 4e5018131176
Node: 参考資料<5>18132097
Ref: howto/unicode id318132251
Ref: 4e5118132251
Ref: 参考資料<5>-Footnote-118133094
Ref: 参考資料<5>-Footnote-218133166
Node: 謝辞<10>18133235
Ref: howto/unicode acknowledgements18133342
Ref: 4e5218133342
Node: urllib パッケージを使ってインターネット上のリソースを取得するには18133903
Ref: howto/urllib2 doc18134110
Ref: 4e5318134110
Ref: howto/urllib2 howto-fetch-internet-resources-using-the-urllib-package18134110
Ref: 4e5418134110
Ref: howto/urllib2 urllib-howto18134110
Ref: 38a518134110
Ref: urllib パッケージを使ってインターネット上のリソースを取得するには-Footnote-118134586
Node: はじめに<14>18134625
Ref: howto/urllib2 introduction18134800
Ref: 4e5518134800
Ref: はじめに<14>-Footnote-118136754
Ref: はじめに<14>-Footnote-218136871
Node: URL を取得する18136930
Ref: howto/urllib2 fetching-urls18137138
Ref: 4e5618137138
Node: データ18139947
Ref: howto/urllib2 data18140030
Ref: 4e5718140030
Ref: データ-Footnote-118143383
Node: ヘッダ18143452
Ref: howto/urllib2 headers18143535
Ref: 4e5818143535
Ref: ヘッダ-Footnote-118145423
Ref: ヘッダ-Footnote-218145460
Ref: ヘッダ-Footnote-318145786
Ref: ヘッダ-Footnote-418145923
Node: 例外を処理する<2>18146080
Ref: howto/urllib2 handling-exceptions18146287
Ref: 4e5a18146287
Node: URLError18146815
Ref: howto/urllib2 urlerror18146902
Ref: 4e5b18146902
Node: HTTPError18147499
Ref: howto/urllib2 httperror18147622
Ref: 4e5c18147622
Ref: HTTPError-Footnote-118148515
Node: エラーコード18148574
Ref: howto/urllib2 error-codes18148638
Ref: 4e5d18148638
Ref: エラーコード-Footnote-118153573
Node: エラーをラップする18153632
Ref: howto/urllib2 wrapping-it-up18153738
Ref: 4e5e18153738
Node: その118153985
Ref: howto/urllib2 number-118154072
Ref: 4e5f18154072
Node: その218154695
Ref: howto/urllib2 number-218154782
Ref: 4e6018154782
Node: info と geturl18155310
Ref: howto/urllib2 info-and-geturl18155518
Ref: 4e5918155518
Ref: info と geturl-Footnote-118156562
Node: Openers と Handlers18156600
Ref: howto/urllib2 openers-and-handlers18156796
Ref: 4e6118156796
Node: Basic 認証18159140
Ref: howto/urllib2 id518159333
Ref: 4e6218159333
Ref: Basic 認証-Footnote-118163203
Node: プロキシ18163320
Ref: howto/urllib2 proxies18163520
Ref: 4e6318163520
Ref: プロキシ-Footnote-118164792
Ref: プロキシ-Footnote-218165313
Ref: プロキシ-Footnote-318165430
Node: ソケットとレイヤー18165597
Ref: howto/urllib2 sockets-and-layers18165791
Ref: 4e6418165791
Node: 脚注18167180
Ref: howto/urllib2 footnotes18167353
Ref: 4e6518167353
Node: ipaddressモジュールの紹介18167464
Ref: howto/ipaddress doc18167706
Ref: 4e6618167706
Ref: howto/ipaddress an-introduction-to-the-ipaddress-module18167706
Ref: 4e6718167706
Ref: howto/ipaddress ipaddress-howto18167706
Ref: 3acb18167706
Node: アドレス/ネットワーク/インターフェースオブジェクトの作成18168655
Ref: howto/ipaddress creating-address-network-interface-objects18168891
Ref: 4e6818168891
Node: IPバージョンについての注意18169518
Ref: howto/ipaddress a-note-on-ip-versions18169708
Ref: 4e6918169708
Node: IPホストアドレス18170743
Ref: howto/ipaddress ip-host-addresses18170975
Ref: 4e6a18170975
Node: ネットワークを定義する18172306
Ref: howto/ipaddress defining-networks18172533
Ref: 4e6b18172533
Node: ホストインターフェース18175598
Ref: howto/ipaddress host-interfaces18175793
Ref: 4e6c18175793
Node: アドレス/ネットワーク/インターフェースオブジェクト18177053
Ref: howto/ipaddress inspecting-address-network-interface-objects18177352
Ref: 4e6d18177352
Node: アドレスのリストとしてのネットワーク18180048
Ref: howto/ipaddress networks-as-lists-of-addresses18180273
Ref: 4e6e18180273
Node: 比較<4>18181313
Ref: howto/ipaddress comparisons18181517
Ref: 4e6f18181517
Node: 他のモジュールでIPアドレスを使用する18181948
Ref: howto/ipaddress using-ip-addresses-with-other-modules18182179
Ref: 4e7018182179
Node: インスタンスの生成に失敗した場合にさらに詳細を取得する18182713
Ref: howto/ipaddress getting-more-detail-when-instance-creation-fails18182926
Ref: 4e7118182926
Node: DTrace と SystemTap で CPython を測定する18185347
Ref: howto/instrumentation doc18185537
Ref: 4e7218185537
Ref: howto/instrumentation instrumentation18185537
Ref: c3a18185537
Ref: howto/instrumentation instrumenting-cpython-with-dtrace-and-systemtap18185537
Ref: 4e7318185537
Node: 静的マーカーの有効化18187074
Ref: howto/instrumentation enabling-the-static-markers18187224
Ref: 4e7418187224
Node: 静的 DTrace プローブ18191585
Ref: howto/instrumentation static-dtrace-probes18191773
Ref: 4e7518191773
Node: 静的 SystemTap マーカー18194242
Ref: howto/instrumentation static-systemtap-markers18194433
Ref: 4e7618194433
Node: 利用可能な静的マーカー18196655
Ref: howto/instrumentation available-static-markers18196836
Ref: 4e7718196836
Node: SystemTap Tapset18199629
Ref: howto/instrumentation systemtap-tapsets18199794
Ref: 4e7818199794
Node: 使用例<56>18201402
Ref: howto/instrumentation examples18201525
Ref: 4e7918201525
Node: Python support for the Linux perf profiler18202845
Ref: howto/perf_profiling doc18203028
Ref: 16a418203028
Ref: howto/perf_profiling perf-profiling18203028
Ref: 17418203028
Ref: howto/perf_profiling python-support-for-the-linux-perf-profiler18203028
Ref: 4e7a18203028
Ref: Python support for the Linux perf profiler-Footnote-118210913
Node: How to enable perf profiling support18210950
Ref: howto/perf_profiling how-to-enable-perf-profiling-support18211104
Ref: 4e7b18211104
Node: How to obtain the best results18212240
Ref: howto/perf_profiling how-to-obtain-the-best-results18212437
Ref: 4e7c18212437
Node: How to work without frame pointers18213215
Ref: howto/perf_profiling how-to-work-without-frame-pointers18213367
Ref: 4e7d18213367
Node: Annotations Best Practices18216357
Ref: howto/annotations doc18216528
Ref: 4e7e18216528
Ref: howto/annotations annotations-best-practices18216528
Ref: 4e7f18216528
Ref: howto/annotations annotations-howto18216528
Ref: 7a418216528
Node: Accessing The Annotations Dict Of An Object In Python 3 10 And Newer18217877
Ref: howto/annotations accessing-the-annotations-dict-of-an-object-in-python-3-10-and-newer18218084
Ref: 4e8018218084
Node: Accessing The Annotations Dict Of An Object In Python 3 9 And Older18219720
Ref: howto/annotations accessing-the-annotations-dict-of-an-object-in-python-3-9-and-older18219982
Ref: 4e8118219982
Node: Manually Un-Stringizing Stringized Annotations18222360
Ref: howto/annotations manually-un-stringizing-stringized-annotations18222610
Ref: 4e8218222610
Ref: Manually Un-Stringizing Stringized Annotations-Footnote-118224929
Node: Best Practices For __annotations__ In Any Python Version18224971
Ref: howto/annotations best-practices-for-annotations-in-any-python-version18225176
Ref: 4e8318225176
Node: __annotations__ Quirks18225913
Ref: howto/annotations annotations-quirks18226063
Ref: 4e8418226063
Node: 拡張モジュールを分離する18227748
Ref: howto/isolating-extensions doc18227904
Ref: 4e8518227904
Ref: howto/isolating-extensions isolating-extension-modules18227904
Ref: 4e8618227904
Ref: howto/isolating-extensions isolating-extensions-howto18227904
Ref: 4b4718227904
Node: Who should read this18228652
Ref: howto/isolating-extensions who-should-read-this18228763
Ref: 4e8718228763
Node: 背景<2>18229001
Ref: howto/isolating-extensions background18229167
Ref: 4e8818229167
Node: Enter Per-Module State18230756
Ref: howto/isolating-extensions enter-per-module-state18230856
Ref: 4e8918230856
Node: Isolated Module Objects18232015
Ref: howto/isolating-extensions isolated-module-objects18232145
Ref: 4e8a18232145
Node: Surprising Edge Cases18233182
Ref: howto/isolating-extensions surprising-edge-cases18233281
Ref: 4e8c18233281
Node: Making Modules Safe with Multiple Interpreters18234293
Ref: howto/isolating-extensions making-modules-safe-with-multiple-interpreters18234452
Ref: 4e8d18234452
Node: Managing Global State18234771
Ref: howto/isolating-extensions managing-global-state18234909
Ref: 4e8b18234909
Node: Managing Per-Module State18235865
Ref: howto/isolating-extensions managing-per-module-state18236061
Ref: 4e8f18236061
Ref: Managing Per-Module State-Footnote-118237733
Node: Opt-Out Limiting to One Module Object per Process18237807
Ref: howto/isolating-extensions opt-out-limiting-to-one-module-object-per-process18238016
Ref: 4e8e18238016
Node: Module State Access from Functions18238710
Ref: howto/isolating-extensions module-state-access-from-functions18238885
Ref: 4e9018238885
Node: Heap Types<2>18239667
Ref: howto/isolating-extensions heap-types18239844
Ref: 4e9118239844
Node: Changing Static Types to Heap Types18241492
Ref: howto/isolating-extensions changing-static-types-to-heap-types18241605
Ref: 4e9218241605
Node: Defining Heap Types18242581
Ref: howto/isolating-extensions defining-heap-types18242730
Ref: 4e9318242730
Node: Garbage-Collection Protocol18243383
Ref: howto/isolating-extensions garbage-collection-protocol18243529
Ref: 4e9418243529
Node: tp_traverse in Python 3 8 and lower18244617
Ref: howto/isolating-extensions tp-traverse-in-python-3-8-and-lower18244747
Ref: 4e9518244747
Node: Delegating tp_traverse18245515
Ref: howto/isolating-extensions delegating-tp-traverse18245673
Ref: 4e9618245673
Node: Defining tp_dealloc18246481
Ref: howto/isolating-extensions defining-tp-dealloc18246626
Ref: 4e9718246626
Node: Not overriding tp_free18247394
Ref: howto/isolating-extensions not-overriding-tp-free18247538
Ref: 4e9818247538
Node: Avoiding PyObject_New18247745
Ref: howto/isolating-extensions avoiding-pyobject-new18247861
Ref: 4e9918247861
Node: Module State Access from Classes18248652
Ref: howto/isolating-extensions module-state-access-from-classes18248819
Ref: 4e9a18248819
Node: Module State Access from Regular Methods18249390
Ref: howto/isolating-extensions module-state-access-from-regular-methods18249587
Ref: 4e9b18249587
Node: Module State Access from Slot Methods Getters and Setters18252090
Ref: howto/isolating-extensions module-state-access-from-slot-methods-getters-and-setters18252283
Ref: 4e9c18252283
Node: Lifetime of the Module State18253730
Ref: howto/isolating-extensions lifetime-of-the-module-state18253874
Ref: 4e9d18253874
Node: 取り掛かり中の問題18254417
Ref: howto/isolating-extensions open-issues18254539
Ref: 4e9e18254539
Ref: 取り掛かり中の問題-Footnote-118254866
Node: Per-Class Scope18254934
Ref: howto/isolating-extensions per-class-scope18255055
Ref: 4e9f18255055
Node: Lossless Conversion to Heap Types18255348
Ref: howto/isolating-extensions lossless-conversion-to-heap-types18255469
Ref: 4ea018255469
Node: timer file descriptor HOWTO18255707
Ref: howto/timerfd doc18255875
Ref: 4ea118255875
Ref: howto/timerfd timer-file-descriptor-howto18255875
Ref: 4ea218255875
Ref: howto/timerfd timerfd-howto18255875
Ref: 4ea318255875
Node: Examples18256057
Ref: howto/timerfd examples18256129
Ref: 4ea418256129
Node: The Python 2 3 Method Resolution Order18264935
Ref: howto/mro doc18265113
Ref: 4ea518265113
Ref: howto/mro python-2-3-mro18265113
Ref: 144f18265113
Ref: howto/mro the-python-2-3-method-resolution-order18265113
Ref: 4ea618265113
Ref: The Python 2 3 Method Resolution Order-Footnote-118266723
Node: The beginning18266770
Ref: howto/mro the-beginning18266897
Ref: 4ea718266897
Ref: The beginning-Footnote-118271474
Ref: The beginning-Footnote-218271611
Node: The C3 Method Resolution Order18271723
Ref: howto/mro the-c3-method-resolution-order18271870
Ref: 4ea818271870
Node: Examples<2>18274202
Ref: howto/mro examples18274364
Ref: 4ea918274364
Node: Bad Method Resolution Orders18279913
Ref: howto/mro bad-method-resolution-orders18280052
Ref: 4eaa18280052
Ref: Bad Method Resolution Orders-Footnote-118286301
Node: The end18286485
Ref: howto/mro the-end18286622
Ref: 4eab18286622
Node: Resources18289797
Ref: howto/mro resources18289897
Ref: 4eac18289897
Node: Python experimental support for free threading18289932
Ref: howto/free-threading-python doc18290125
Ref: 4ead18290125
Ref: howto/free-threading-python freethreading-python-howto18290125
Ref: 4eae18290125
Ref: howto/free-threading-python python-experimental-support-for-free-threading18290125
Ref: 4eaf18290125
Ref: Python experimental support for free threading-Footnote-118291401
Node: Installation18291443
Ref: howto/free-threading-python installation18291579
Ref: 4eb118291579
Ref: Installation-Footnote-118292165
Node: Identifying free-threaded Python18292229
Ref: howto/free-threading-python identifying-free-threaded-python18292425
Ref: 4eb218292425
Node: The global interpreter lock in free-threaded Python18293105
Ref: howto/free-threading-python the-global-interpreter-lock-in-free-threaded-python18293302
Ref: 4eb318293302
Node: Thread safety18294052
Ref: howto/free-threading-python thread-safety18294234
Ref: 4eb418294234
Node: Known limitations18295026
Ref: howto/free-threading-python known-limitations18295148
Ref: 4eb518295148
Node: Immortalization18295371
Ref: howto/free-threading-python immortalization18295462
Ref: 4eb618295462
Node: Frame objects18296573
Ref: howto/free-threading-python frame-objects18296682
Ref: 4eb718296682
Node: Iterators18297127
Ref: howto/free-threading-python iterators18297248
Ref: 4eb818297248
Node: Single-threaded performance18297459
Ref: howto/free-threading-python single-threaded-performance18297558
Ref: 4eb918297558
Ref: Single-threaded performance-Footnote-118298324
Ref: Single-threaded performance-Footnote-218298370
Node: C API Extension Support for Free Threading18298412
Ref: howto/free-threading-extensions doc18298558
Ref: 4eba18298558
Ref: howto/free-threading-extensions c-api-extension-support-for-free-threading18298558
Ref: 4ebb18298558
Ref: howto/free-threading-extensions freethreading-extensions-howto18298558
Ref: 4eb018298558
Node: Identifying the Free-Threaded Build in C18299210
Ref: howto/free-threading-extensions identifying-the-free-threaded-build-in-c18299359
Ref: 4ebc18299359
Node: Module Initialization18299787
Ref: howto/free-threading-extensions module-initialization18299967
Ref: 4ebd18299967
Node: Multi-Phase Initialization18300461
Ref: howto/free-threading-extensions multi-phase-initialization18300581
Ref: 4ebe18300581
Node: Single-Phase Initialization18301254
Ref: howto/free-threading-extensions single-phase-initialization18301374
Ref: 4ebf18301374
Node: General API Guidelines18302214
Ref: howto/free-threading-extensions general-api-guidelines18302373
Ref: 4ec018302373
Node: Container Thread Safety18303194
Ref: howto/free-threading-extensions container-thread-safety18303276
Ref: 4ec218303276
Node: PyDict_Next18303611
Ref: howto/free-threading-extensions id118303682
Ref: 4ec318303682
Ref: howto/free-threading-extensions pydict-next18303682
Ref: 4ec418303682
Node: Borrowed References18304170
Ref: howto/free-threading-extensions borrowed-references18304330
Ref: 4ec518304330
Ref: howto/free-threading-extensions id218304385
Ref: 4ec118304385
Ref: Borrowed References-Footnote-118307019
Node: Memory Allocation APIs18307071
Ref: howto/free-threading-extensions free-threaded-memory-allocation18307234
Ref: 4c4918307234
Ref: howto/free-threading-extensions memory-allocation-apis18307234
Ref: 4ec618307234
Node: Thread State and GIL APIs18307968
Ref: howto/free-threading-extensions thread-state-and-gil-apis18308147
Ref: 4ec718308147
Node: Protecting Internal Extension State18309113
Ref: howto/free-threading-extensions protecting-internal-extension-state18309317
Ref: 4ec818309317
Ref: Protecting Internal Extension State-Footnote-118310073
Node: Building Extensions for the Free-Threaded Build18310139
Ref: howto/free-threading-extensions building-extensions-for-the-free-threaded-build18310309
Ref: 4ec918310309
Ref: Building Extensions for the Free-Threaded Build-Footnote-118310901
Ref: Building Extensions for the Free-Threaded Build-Footnote-218310943
Ref: Building Extensions for the Free-Threaded Build-Footnote-318310988
Node: Limited C API and Stable ABI18311067
Ref: howto/free-threading-extensions limited-c-api-and-stable-abi18311199
Ref: 4eca18311199
Ref: Limited C API and Stable ABI-Footnote-118311898
Node: Windows<75>18311959
Ref: howto/free-threading-extensions windows18312091
Ref: 4ecb18312091
Ref: Windows<75>-Footnote-118313784
Node: Python よくある質問18313837
Ref: faq/index doc18313944
Ref: 4ecc18313944
Ref: faq/index faq-index18313944
Ref: 1c7218313944
Ref: faq/index python-frequently-asked-questions18313944
Ref: 4ecd18313944
Node: 一般 Python FAQ18314345
Ref: faq/general doc18314458
Ref: 4ece18314458
Ref: faq/general general-python-faq18314458
Ref: 4ecf18314458
Node: 一般情報18314560
Ref: faq/general general-information18314660
Ref: 4ed018314660
Node: Python とは何ですか？18315961
Ref: faq/general what-is-python18316095
Ref: 4ed118316095
Ref: Python とは何ですか？-Footnote-118317572
Node: Python Software Foundation とは何ですか？18317624
Ref: faq/general what-is-the-python-software-foundation18317828
Ref: 4ed218317828
Ref: Python Software Foundation とは何ですか？-Footnote-118318501
Node: Python を使うのに著作権の制限はありますか？18318547
Ref: faq/general are-there-copyright-restrictions-on-the-use-of-python18318779
Ref: 4ed318318779
Ref: Python を使うのに著作権の制限はありますか？-Footnote-118319826
Ref: Python を使うのに著作権の制限はありますか？-Footnote-218319873
Node: そもそも Python は何故創られたのですか？18319920
Ref: faq/general why-was-python-created-in-the-first-place18320156
Ref: 4ed418320156
Node: Python は何をするのに向いていますか？18322918
Ref: faq/general what-is-python-good-for18323175
Ref: 4ed518323175
Ref: Python は何をするのに向いていますか？-Footnote-118324261
Node: Python のバージョン番号の仕組みはどうなっているのですか？18324286
Ref: faq/general faq-version-numbering-scheme18324554
Ref: 4ed618324554
Ref: faq/general how-does-the-python-version-numbering-scheme-work18324554
Ref: 4ed718324554
Ref: Python のバージョン番号の仕組みはどうなっているのですか？-Footnote-118327340
Ref: Python のバージョン番号の仕組みはどうなっているのですか？-Footnote-218327414
Node: Python のソースのコピーはどこで手に入りますか？18327456
Ref: faq/general how-do-i-obtain-a-copy-of-the-python-source18327736
Ref: 4ed818327736
Ref: Python のソースのコピーはどこで手に入りますか？-Footnote-118328794
Node: Python のドキュメントはどこで手に入りますか？18328837
Ref: faq/general how-do-i-get-documentation-on-python18329147
Ref: 4ed918329147
Ref: Python のドキュメントはどこで手に入りますか？-Footnote-118329844
Node: プログラミングをしたことがないのですが、Python のチュートリアルはありますか？18329880
Ref: faq/general i-ve-never-programmed-before-is-there-a-python-tutorial18330214
Ref: 4eda18330214
Ref: プログラミングをしたことがないのですが、Python のチュートリアルはありますか？-Footnote-118330782
Node: Python のためのニュースグループやメーリングリストはありますか？18330834
Ref: faq/general is-there-a-newsgroup-or-mailing-list-devoted-to-python18331171
Ref: 4edb18331171
Ref: Python のためのニュースグループやメーリングリストはありますか？-Footnote-118332351
Ref: Python のためのニュースグループやメーリングリストはありますか？-Footnote-218332412
Node: Python のベータテスト版はどこで手に入りますか？18332493
Ref: faq/general how-do-i-get-a-beta-test-version-of-python18332803
Ref: 4edc18332803
Ref: Python のベータテスト版はどこで手に入りますか？-Footnote-118333447
Node: Python のバグ報告やパッチを上げるにはどうしたら良いですか？18333484
Ref: faq/general how-do-i-submit-bug-reports-and-patches-for-python18333776
Ref: 4edd18333776
Ref: Python のバグ報告やパッチを上げるにはどうしたら良いですか？-Footnote-118334229
Node: Python について発行された記事を何か参照できますか？18334266
Ref: faq/general are-there-any-published-articles-about-python-that-i-can-reference18334525
Ref: 4ede18334525
Ref: Python について発行された記事を何か参照できますか？-Footnote-118335097
Node: Python の本はありますか？18335133
Ref: faq/general are-there-any-books-on-python18335364
Ref: 4edf18335364
Node: www python org は世界のどこにあるのですか？18335815
Ref: faq/general where-in-the-world-is-www-python-org-located18336020
Ref: 4ee018336020
Ref: www python org は世界のどこにあるのですか？-Footnote-118336352
Node: なぜ Python という名前なのですか？18336381
Ref: faq/general why-is-it-called-python18336639
Ref: 4ee118336639
Ref: なぜ Python という名前なのですか？-Footnote-118337146
Node: 『空飛ぶモンティ・パイソン』を好きでなくてはいけませんか？18337197
Ref: faq/general do-i-have-to-like-monty-python-s-flying-circus18337389
Ref: 4ee218337389
Node: 現実世界での Python18337627
Ref: faq/general python-in-the-real-world18337727
Ref: 4ee318337727
Node: Python はどれくらい安定していますか？18338232
Ref: faq/general how-stable-is-python18338414
Ref: 4ee418338414
Ref: Python はどれくらい安定していますか？-Footnote-118339663
Ref: Python はどれくらい安定していますか？-Footnote-218339705
Ref: Python はどれくらい安定していますか？-Footnote-318339747
Node: どれくらいの人が Python を使っていますか？18339789
Ref: faq/general how-many-people-are-using-python18340050
Ref: 4ee518340050
Node: Python で行われた大きなプロジェクトはありますか？18340749
Ref: faq/general have-any-significant-projects-been-done-in-python18341032
Ref: 4ee618341032
Ref: Python で行われた大きなプロジェクトはありますか？-Footnote-118341949
Ref: Python で行われた大きなプロジェクトはありますか？-Footnote-218342001
Ref: Python で行われた大きなプロジェクトはありますか？-Footnote-318342030
Ref: Python で行われた大きなプロジェクトはありますか？-Footnote-418342059
Node: 将来 Python にどのような新しい開発が期待されますか？18342090
Ref: faq/general what-new-developments-are-expected-for-python-in-the-future18342393
Ref: 4ee718342393
Ref: 将来 Python にどのような新しい開発が期待されますか？-Footnote-118343030
Node: Python の互換性を無くすような提案をしてもいいのですか？18343100
Ref: faq/general is-it-reasonable-to-propose-incompatible-changes-to-python18343403
Ref: 4ee818343403
Ref: Python の互換性を無くすような提案をしてもいいのですか？-Footnote-118344498
Node: Python は初心者プログラマに向いている言語ですか？18344540
Ref: faq/general is-python-a-good-language-for-beginning-programmers18344760
Ref: 4ee918344760
Ref: Python は初心者プログラマに向いている言語ですか？-Footnote-118349442
Ref: Python は初心者プログラマに向いている言語ですか？-Footnote-218349493
Node: プログラミング FAQ18349555
Ref: faq/programming doc18349702
Ref: 1f5518349702
Ref: faq/programming programming-faq18349702
Ref: 4eea18349702
Node: 一般的な質問18349988
Ref: faq/programming general-questions18350089
Ref: 4eeb18350089
Node: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？18350586
Ref: faq/programming is-there-a-source-code-level-debugger-with-breakpoints-single-stepping-etc18350857
Ref: 4eec18350857
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-118352744
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-218352816
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-318352860
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-418352913
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-518352959
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-618353008
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-718353047
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-818353077
Ref: ブレークポイントやシングルステップ実行などを備えたソースコードレベルデバッガはありますか？-Footnote-918353134
Node: バグの発見や静的解析に役立つツールはありますか？18353177
Ref: faq/programming are-there-tools-to-help-find-bugs-or-perform-static-analysis18353555
Ref: 4eed18353555
Ref: バグの発見や静的解析に役立つツールはありますか？-Footnote-118354000
Ref: バグの発見や静的解析に役立つツールはありますか？-Footnote-218354054
Ref: バグの発見や静的解析に役立つツールはありますか？-Footnote-318354096
Ref: バグの発見や静的解析に役立つツールはありますか？-Footnote-418354127
Ref: バグの発見や静的解析に役立つツールはありますか？-Footnote-518354159
Node: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？18354200
Ref: faq/programming faq-create-standalone-binary18354558
Ref: 4eee18354558
Ref: faq/programming how-can-i-create-a-stand-alone-binary-from-a-python-script18354558
Ref: 4eef18354558
Ref: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？-Footnote-118356730
Ref: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？-Footnote-218356795
Ref: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？-Footnote-318356823
Ref: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？-Footnote-418356856
Ref: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？-Footnote-518356909
Ref: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？-Footnote-618356961
Ref: どうしたら Python スクリプトからスタンドアロンバイナリを作れますか？-Footnote-718357010
Node: Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？18357042
Ref: faq/programming are-there-coding-standards-or-a-style-guide-for-python-programs18357319
Ref: 4ef018357319
Ref: Python プログラムのためのコーディングスタンダードやスタイルガイドはありますか？-Footnote-118357717
Node: コア言語18357759
Ref: faq/programming core-language18357884
Ref: 4ef118357884
Node: なぜ変数に値があるのに UnboundLocalError が出るのですか？18359685
Ref: faq/programming faq-unboundlocalerror18359895
Ref: 1f3d18359895
Ref: faq/programming why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value18359895
Ref: 4ef218359895
Node: Python のローカルとグローバル変数のルールは何ですか？18362064
Ref: faq/programming what-are-the-rules-for-local-and-global-variables-in-python18362391
Ref: 4ef318362391
Node: ループの中で異なる値で定義されたラムダ式が、同じ値を返すのはなぜですか？18363486
Ref: faq/programming why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result18363833
Ref: 4ef418363833
Node: グローバル変数をモジュール間で共有するにはどうしたらいいですか？18366229
Ref: faq/programming how-do-i-share-global-variables-across-modules18366592
Ref: 4ef518366592
Node: モジュールで import を使う際の「ベストプラクティス」は何ですか？18367716
Ref: faq/programming what-are-the-best-practices-for-using-import-in-a-module18368052
Ref: 4ef618368052
Node: なぜオブジェクト間でデフォルト値が共有されるのですか？18371841
Ref: faq/programming why-are-default-values-shared-between-objects18372213
Ref: 4ef718372213
Node: オプションパラメータやキーワードパラメータを関数から関数へ渡すにはどうしたらいいですか？18375167
Ref: faq/programming how-can-i-pass-optional-or-keyword-parameters-from-one-function-to-another18375493
Ref: 4ef818375493
Node: 実引数と仮引数の違いは何ですか?18376207
Ref: faq/programming faq-argument-vs-parameter18376527
Ref: 4ef918376527
Ref: faq/programming what-is-the-difference-between-arguments-and-parameters18376527
Ref: 4efa18376527
Node: なぜ list 'y' を変更すると list 'x' も変更されるのですか?18377290
Ref: faq/programming why-did-changing-list-y-also-change-list-x18377555
Ref: 4efb18377555
Node: 出力引数のある関数 参照渡し はどのように書きますか？18381984
Ref: faq/programming how-do-i-write-a-function-with-output-parameters-call-by-reference18382264
Ref: 4efc18382264
Node: Python で高次関数はどのようにつくりますか？18384929
Ref: faq/programming how-do-you-make-a-higher-order-function-in-python18385204
Ref: 4efd18385204
Node: Python のオブジェクトはどのようにコピーしますか？18387099
Ref: faq/programming how-do-i-copy-an-object-in-python18387378
Ref: 4efe18387378
Node: オブジェクトのメソッドや属性はどのように見つけますか？18387962
Ref: faq/programming how-can-i-find-the-methods-or-attributes-of-an-object18388264
Ref: 4eff18388264
Node: コードはどのようにオブジェクトの名前を見つけるのですか？18388662
Ref: faq/programming how-can-my-code-discover-the-name-of-an-object18388951
Ref: 4f0018388951
Node: カンマ演算子はなぜ優先されるのですか？18391059
Ref: faq/programming what-s-up-with-the-comma-operator-s-precedence18391332
Ref: 4f0118391332
Node: C の "? " 三項演算子と等価なものはありますか？18391981
Ref: faq/programming is-there-an-equivalent-of-c-s-ternary-operator18392246
Ref: 4f0218392246
Node: Python で解し難いワンライナーを書くことはできますか？18393010
Ref: faq/programming is-it-possible-to-write-obfuscated-one-liners-in-python18393299
Ref: 4f0318393299
Node: 関数の引数リストにあるスラッシュ / は何を意味しますか？18394891
Ref: faq/programming faq-positional-only-arguments18395106
Ref: 20d818395106
Ref: faq/programming what-does-the-slash-in-the-parameter-list-of-a-function-mean18395106
Ref: 4f0418395106
Node: 数と文字列18396396
Ref: faq/programming numbers-and-strings18396512
Ref: 4f0518396512
Node: 十六進数や八進数を指定するにはどうしたらいいですか？18397651
Ref: faq/programming how-do-i-specify-hexadecimal-and-octal-integers18397838
Ref: 4f0618397838
Node: なぜ -22 // 10 は -3 を返すのですか？18398611
Ref: faq/programming why-does-22-10-return-318398904
Ref: 4f0718398904
Node: どうすれば SyntaxError を起こさずに整数リテラルの属性を得られますか？18399824
Ref: faq/programming how-do-i-get-int-literal-attribute-instead-of-syntaxerror18400108
Ref: 4f0818400108
Node: 文字列を数に変換するにはどうしたらいいですか？18400763
Ref: faq/programming how-do-i-convert-a-string-to-a-number18401068
Ref: 4f0918401068
Node: 数を文字列に変換するにはどうしたらいいですか？18402684
Ref: faq/programming how-do-i-convert-a-number-to-a-string18402976
Ref: 4f0a18402976
Node: 文字列をインプレースに変更するにはどうしたらいいですか？18403738
Ref: faq/programming how-do-i-modify-a-string-in-place18404054
Ref: 4f0b18404054
Node: 関数やメソッドを呼ぶのに文字列を使うにはどうしたらいいですか？18405063
Ref: faq/programming how-do-i-use-strings-to-call-functions-methods18405413
Ref: 4f0c18405413
Node: 文字列から後端の改行を取り除く Perl の chomp に相当するものはありますか？18406963
Ref: faq/programming is-there-an-equivalent-to-perl-s-chomp-for-removing-trailing-newlines-from-strings18407285
Ref: 4f0d18407285
Node: scanf や sscanf と同等なものはありますか？18408092
Ref: faq/programming is-there-a-scanf-or-sscanf-equivalent18408400
Ref: 4f0e18408400
Node: 'UnicodeDecodeError' や 'UnicodeEncodeError' はどういう意味ですか？18409123
Ref: faq/programming what-does-unicodedecodeerror-or-unicodeencodeerror-error-mean18409417
Ref: 4f0f18409417
Node: raw string を奇数個のバックスラッシュで終えることはできますか？18409642
Ref: faq/programming can-i-end-a-raw-string-with-an-odd-number-of-backslashes18409871
Ref: 4f1018409871
Ref: faq/programming faq-programming-raw-string-backslash18409871
Ref: 1b6618409871
Node: 性能<4>18411391
Ref: faq/programming performance18411530
Ref: 4f1118411530
Node: プログラムが遅すぎます。どうしたら速くなりますか？18411733
Ref: faq/programming my-program-is-too-slow-how-do-i-speed-it-up18411944
Ref: 4f1218411944
Ref: プログラムが遅すぎます。どうしたら速くなりますか？-Footnote-118415420
Ref: プログラムが遅すぎます。どうしたら速くなりますか？-Footnote-218415447
Node: 多くの文字列を結合するのに最も効率的な方法は何ですか？18415512
Ref: faq/programming efficient-string-concatenation18415723
Ref: 4f1318415723
Ref: faq/programming what-is-the-most-efficient-way-to-concatenate-many-strings-together18415723
Ref: 4f1418415723
Node: シーケンス タプル/リスト18416901
Ref: faq/programming sequences-tuples-lists18417043
Ref: 4f1518417043
Node: タプル、リスト間の変更はどのようにするのですか？18417984
Ref: faq/programming how-do-i-convert-between-tuples-and-lists18418170
Ref: 4f1618418170
Node: 負の添え字は何ですか？18419258
Ref: faq/programming what-s-a-negative-index18419540
Ref: 4f1718419540
Node: シーケンスを逆順にイテレートするにはどうしたらいいですか？18420253
Ref: faq/programming how-do-i-iterate-over-a-sequence-in-reverse-order18420526
Ref: 4f1818420526
Node: リストから重複を取り除くにはどうしますか？18420970
Ref: faq/programming how-do-you-remove-duplicates-from-a-list18421267
Ref: 4f1918421267
Node: リストから複数のアイテムを取り除く方法18422282
Ref: faq/programming how-do-you-remove-multiple-items-from-a-list18422544
Ref: 4f1a18422544
Node: Python で配列を作るにはどうしますか？18423132
Ref: faq/programming how-do-you-make-an-array-in-python18423388
Ref: 4f1b18423388
Ref: Python で配列を作るにはどうしますか？-Footnote-118424705
Node: 多次元のリストを作るにはどうしますか？18424732
Ref: faq/programming faq-multidimensional-list18425033
Ref: 210f18425033
Ref: faq/programming how-do-i-create-a-multidimensional-list18425033
Ref: 4f1c18425033
Ref: 多次元のリストを作るにはどうしますか？-Footnote-118426572
Node: オブジェクトのシーケンスにメソッドや関数を適用するにはどうしますか？18426599
Ref: faq/programming how-do-i-apply-a-method-or-function-to-a-sequence-of-objects18426939
Ref: 4f1d18426939
Node: なぜ加算はされるのに a_tuple[i] += ['item'] は例外を送出するのですか?18427624
Ref: faq/programming faq-augmented-assignment-tuple-error18428004
Ref: 1f1518428004
Ref: faq/programming why-does-a-tuple-i-item-raise-an-exception-when-the-addition-works18428004
Ref: 4f1e18428004
Node: 複雑なソートがしたいのですが、Python でシュワルツ変換はできますか？18431769
Ref: faq/programming i-want-to-do-a-complicated-sort-can-you-do-a-schwartzian-transform-in-python18432134
Ref: 4f1f18432134
Node: リストを別のリストの値によってソートするにはどうしますか？18432718
Ref: faq/programming how-can-i-sort-one-list-by-values-from-another-list18432983
Ref: 4f2018432983
Node: オブジェクト18433649
Ref: faq/programming objects18433800
Ref: 4f2118433800
Node: クラスとは何ですか？18435505
Ref: faq/programming what-is-a-class18435632
Ref: 4f2218435632
Node: メソッドとは何ですか？18436698
Ref: faq/programming what-is-a-method18436860
Ref: 4f2318436860
Node: self とは何ですか？18437245
Ref: faq/programming what-is-self18437527
Ref: 4f2418437527
Node: あるオブジェクトが、与えられたクラスやそのサブクラスのインスタンスであるかを調べるにはどうしますか？18438149
Ref: faq/programming how-do-i-check-if-an-object-is-an-instance-of-a-given-class-or-of-a-subclass-of-it18438425
Ref: 4f2618438425
Node: 委譲とは何ですか？18441174
Ref: faq/programming what-is-delegation18441565
Ref: 4f2718441565
Node: 基底クラスで定義されたメソッドを、そのクラスを継承した派生クラスから呼び出すにはどうしますか？18444024
Ref: faq/programming how-do-i-call-a-method-defined-in-a-base-class-from-a-derived-class-that-extends-it18444352
Ref: 4f2818444352
Node: 基底クラスの名前を変えやすいコードを書くにはどうしますか？18445077
Ref: faq/programming how-can-i-organize-my-code-to-make-it-easier-to-change-the-base-class18445474
Ref: 4f2918445474
Node: 静的なクラスデータや静的なクラスメソッドを作るにはどうしますか？18446153
Ref: faq/programming how-do-i-create-static-class-data-and-static-class-methods18446526
Ref: 4f2a18446526
Node: Python でコンストラクタ やメソッド をオーバーロードするにはどうしたらいいですか？18448499
Ref: faq/programming how-can-i-overload-constructors-or-methods-in-python18448871
Ref: 4f2b18448871
Node: __spam を使おうとしたら _SomeClassName__spam からエラーがでました。18450059
Ref: faq/programming i-try-to-use-spam-and-i-get-an-error-about-someclassname-spam18450467
Ref: 4f2c18450467
Node: クラスに __del__ メソッドを定義しているのですが、オブジェクトを削除したときに呼ばれません。18451822
Ref: faq/programming my-class-defines-del-but-it-is-not-called-when-i-delete-the-object18452218
Ref: 4f2d18452218
Node: 与えられたクラスのすべてのインスタンスのリストを得るにはどうしますか？18454804
Ref: faq/programming how-do-i-get-a-list-of-all-instances-of-a-given-class18455182
Ref: 4f2e18455182
Node: なぜ id の結果は一意でないように見えるのですか?18455665
Ref: faq/programming why-does-the-result-of-id-appear-to-be-not-unique18455975
Ref: 4f2f18455975
Node: いつ is 演算子での同一性テストが頼れますか？18457091
Ref: faq/programming when-can-i-rely-on-identity-tests-with-the-is-operator18457425
Ref: 4f3018457425
Ref: いつ is 演算子での同一性テストが頼れますか？-Footnote-118461347
Node: どうすればサブクラスはイミュータブルなインスタンスに格納されたデータを制御できますか？18461389
Ref: faq/programming how-can-a-subclass-control-what-data-is-stored-in-an-immutable-instance18461743
Ref: 4f3118461743
Node: メソッド呼び出しをキャッシュするには どうしたらいいですか？18463407
Ref: faq/programming faq-cache-method-calls18463688
Ref: 268818463688
Ref: faq/programming how-do-i-cache-method-calls18463688
Ref: 4f3218463688
Node: モジュール<5>18467254
Ref: faq/programming modules18467361
Ref: 4f3318467361
Node: pyc ファイルを作るにはどうしますか？18468048
Ref: faq/programming how-do-i-create-a-pyc-file18468227
Ref: 4f3418468227
Ref: pyc ファイルを作るにはどうしますか？-Footnote-118471648
Node: 現在のモジュール名を知るにはどうしますか？18471690
Ref: faq/programming how-do-i-find-the-current-module-name18471974
Ref: 4f3518471974
Node: 相互にインポートしあうモジュールを作るにはどうしたらいいですか？18472738
Ref: faq/programming how-can-i-have-modules-that-mutually-import-each-other18473071
Ref: 4f3618473071
Node: __import__ 'x y z' は <module 'x'> を返しますが、z を得るためにはどうしますか？18475778
Ref: faq/programming import-x-y-z-returns-module-x-how-do-i-get-z18476189
Ref: 4f3718476189
Node: インポートされたモジュールを編集してから再インポートしましたが、変化が現れません。なぜですか？18476605
Ref: faq/programming when-i-edit-an-imported-module-and-reimport-it-the-changes-don-t-show-up-why-does-this-happen18476911
Ref: 4f3818476911
Node: デザインと歴史 FAQ18478738
Ref: faq/design doc18478896
Ref: 4f3918478896
Ref: faq/design design-and-history-faq18478896
Ref: 4f3a18478896
Node: Python はなぜ文のグループ化にインデントを使うのですか？18481834
Ref: faq/design why-does-python-use-indentation-for-grouping-of-statements18482053
Ref: 4f3b18482053
Node: なぜ単純な算術演算が奇妙な結果になるのですか？18484258
Ref: faq/design why-am-i-getting-strange-results-with-simple-arithmetic-operations18484561
Ref: 4f3c18484561
Node: なぜ浮動小数点数の計算はこんなに不正確なんですか？18484737
Ref: faq/design why-are-floating-point-calculations-so-inaccurate18485029
Ref: 4f3d18485029
Node: なぜ Python の文字列はイミュータブルなのですか？18486831
Ref: faq/design why-are-python-strings-immutable18487167
Ref: 4f3e18487167
Node: なぜメソッドの定義や呼び出しにおいて 'self' を明示しなければならないのですか？18487905
Ref: faq/design why-must-self-be-used-explicitly-in-method-definitions-and-calls18488220
Ref: 4f3f18488220
Ref: faq/design why-self18488220
Ref: 4f2518488220
Node: 式中で代入ができないのはなぜですか？18491414
Ref: faq/design id218491785
Ref: 4f4018491785
Ref: faq/design why-can-t-i-use-an-assignment-in-an-expression18491785
Ref: 1bbb18491785
Ref: 式中で代入ができないのはなぜですか？-Footnote-118492181
Node: Python にメソッドを使う機能 list index 等 と関数を使う機能 len list 等 があるのはなぜですか？18492223
Ref: faq/design why-does-python-use-methods-for-some-functionality-e-g-list-index-but-functions-for-other-e-g-len-list18492588
Ref: 4f4118492588
Node: join がリストやタプルのメソッドではなく文字列のメソッドなのはなぜですか？18494260
Ref: faq/design why-is-join-a-string-method-instead-of-a-list-or-tuple-method18494616
Ref: 4f4218494616
Node: 例外はどれくらい速いのですか？18496940
Ref: faq/design how-fast-are-exceptions18497235
Ref: 4f4318497235
Node: Python に switch や case 文がないのはなぜですか？18498265
Ref: faq/design why-isn-t-there-a-switch-or-case-statement-in-python18498594
Ref: 4f4418498594
Node: OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？18500303
Ref: faq/design can-t-you-emulate-threads-in-the-interpreter-instead-of-relying-on-an-os-specific-thread-implementation18500654
Ref: 4f4518500654
Ref: OS 特有のスレッド実装に依らずにインタプリタでスレッドをエミュレートすることはできないのですか？-Footnote-118501508
Node: なぜラムダ式は文を含むことができないのですか?18501564
Ref: faq/design why-can-t-lambda-expressions-contain-statements18501943
Ref: 4f4618501943
Node: Python は C やその他の言語のように機械語にコンパイルできますか？18502980
Ref: faq/design can-python-be-compiled-to-machine-code-c-or-some-other-language18503282
Ref: 4f4718503282
Ref: Python は C やその他の言語のように機械語にコンパイルできますか？-Footnote-118503695
Ref: Python は C やその他の言語のように機械語にコンパイルできますか？-Footnote-218503723
Node: Python はメモリをどのように管理するのですか？18503751
Ref: faq/design how-does-python-manage-memory18504087
Ref: 4f4818504087
Ref: Python はメモリをどのように管理するのですか？-Footnote-118506125
Ref: Python はメモリをどのように管理するのですか？-Footnote-218506156
Node: CPython はなぜ伝統的なガベージコレクションスキームを使わないのですか？18506181
Ref: faq/design why-doesn-t-cpython-use-a-more-traditional-garbage-collection-scheme18506528
Ref: 4f4918506528
Node: なぜ CPython の終了時にすべてのメモリが解放されるわけではないのですか？18507820
Ref: faq/design why-isn-t-all-memory-freed-when-cpython-exits18508196
Ref: 4f4a18508196
Node: なぜタプルとリストという別のデータ型が用意されているのですか？18509206
Ref: faq/design why-are-there-separate-tuple-and-list-data-types18509554
Ref: 4f4b18509554
Node: CPythonでリストはどのように実装されているのですか？18511077
Ref: faq/design how-are-lists-implemented-in-cpython18511387
Ref: 4f4c18511387
Node: CPythonで辞書はどのように実装されていますか？18512421
Ref: faq/design how-are-dictionaries-implemented-in-cpython18512725
Ref: 4f4d18512725
Node: なぜ辞書のキーはイミュータブルでなくてはならないのですか？18513912
Ref: faq/design why-must-dictionary-keys-be-immutable18514220
Ref: 4f4e18514220
Node: なぜ list sort はソートされたリストを返さないのですか？18519558
Ref: faq/design why-doesn-t-list-sort-return-the-sorted-list18519899
Ref: 4f4f18519899
Node: Python ではどのようにインターフェース仕様を特定し適用するのですか？18521047
Ref: faq/design how-do-you-specify-and-enforce-an-interface-spec-in-python18521337
Ref: 4f5018521337
Node: なぜ goto が無いのですか？18524478
Ref: faq/design why-is-there-no-goto18524794
Ref: 4f5118524794
Node: なぜ raw 文字列 r-strings はバックスラッシュで終わってはいけないのですか？18526205
Ref: faq/design why-can-t-raw-strings-r-strings-end-with-a-backslash18526492
Ref: 4f5218526492
Node: 属性の代入に "with" 文が使えないのはなぜですか？18528031
Ref: faq/design why-doesn-t-python-have-a-with-statement-for-attribute-assignments18528357
Ref: 4f5318528357
Node: なぜジェネレータは with 文をサポートしないのですか？18531252
Ref: faq/design why-don-t-generators-support-the-with-statement18531545
Ref: 4f5418531545
Node: if/while/def/class 文にコロンが必要なのはなぜですか？18532106
Ref: faq/design why-are-colons-required-for-the-if-while-def-class-statements18532429
Ref: 4f5518532429
Node: なぜ Python ではリストやタプルの最後にカンマがあっても良いのですか？18533259
Ref: faq/design why-does-python-allow-commas-at-the-end-of-lists-and-tuples18533498
Ref: 4f5618533498
Node: ライブラリと拡張 FAQ18534921
Ref: faq/library doc18535079
Ref: 4f5718535079
Ref: faq/library library-and-extension-faq18535079
Ref: 4f5818535079
Node: ライブラリ一般の質問18535370
Ref: faq/library general-library-questions18535492
Ref: 4f5918535492
Node: 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？18536240
Ref: faq/library how-do-i-find-a-module-or-application-to-perform-task-x18536506
Ref: 4f5a18536506
Ref: 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？-Footnote-118537370
Ref: 作業 X を行うためのモジュールやアプリケーションを探すにはどうしますか？-Footnote-218537395
Node: math py socket py regex py etc のソースファイルはどこにありますか？18537426
Ref: faq/library where-is-the-math-py-socket-py-regex-py-etc-source-file18537786
Ref: 4f5b18537786
Node: Python のスクリプトを Unix で実行可能にするにはどうしますか？18538908
Ref: faq/library how-do-i-make-a-python-script-executable-on-unix18539228
Ref: 4f5c18539228
Node: Python には curses/termcap パッケージはありますか？18541188
Ref: faq/library is-there-a-curses-termcap-package-for-python18541492
Ref: 4f5d18541492
Ref: Python には curses/termcap パッケージはありますか？-Footnote-118542563
Node: Python には C の onexit に相当するものはありますか？18542623
Ref: faq/library is-there-an-equivalent-to-c-s-onexit-in-python18542911
Ref: 4f5e18542911
Node: シグナルハンドラが動かないのですがなぜですか？18543171
Ref: faq/library why-don-t-my-signal-handlers-work18543385
Ref: 4f5f18543385
Node: よくある作業18543843
Ref: faq/library common-tasks18543986
Ref: 4f6018543986
Node: Python のプログラムやコンポーネントをテストするにはどうしますか？18544321
Ref: faq/library how-do-i-test-a-python-program-or-component18544582
Ref: 4f6118544582
Node: Python のドキュメント文字列からドキュメントを生成するにはどうしますか？18547279
Ref: faq/library how-do-i-create-documentation-from-doc-strings18547615
Ref: 4f6218547615
Ref: Python のドキュメント文字列からドキュメントを生成するにはどうしますか？-Footnote-118548177
Ref: Python のドキュメント文字列からドキュメントを生成するにはどうしますか？-Footnote-218548217
Node: 一度に一つの押鍵を取得するにはどうしますか？18548252
Ref: faq/library how-do-i-get-a-single-keypress-at-a-time18548485
Ref: 4f6318548485
Node: スレッド18548798
Ref: faq/library threads18548929
Ref: 4f6418548929
Node: スレッドを使ったプログラムを書くにはどうしますか？18549582
Ref: faq/library how-do-i-program-using-threads18549796
Ref: 4f6518549796
Node: スレッドが一つも実行されていないようです。なぜですか？18550231
Ref: faq/library none-of-my-threads-seem-to-run-why18550544
Ref: 4f6618550544
Node: たくさんのワーカースレッドに作業を割り振るにはどうしますか？18552523
Ref: faq/library how-do-i-parcel-out-work-among-a-bunch-of-worker-threads18552857
Ref: 4f6718552857
Node: グローバルな値のどんな種類の変更がスレッドセーフになるのですか？18555827
Ref: faq/library what-kinds-of-global-value-mutation-are-thread-safe18556198
Ref: 4f6818556198
Node: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？18558139
Ref: faq/library can-t-we-get-rid-of-the-global-interpreter-lock18558411
Ref: 4f6918558411
Ref: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？-Footnote-118561724
Ref: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？-Footnote-218561766
Ref: グローバルインタプリタロック Global Interpreter Lock を取り除くことはできないのですか？-Footnote-318561809
Node: 入力と出力<2>18561869
Ref: faq/library input-and-output18562043
Ref: 4f6a18562043
Node: ファイルを削除するにはどうしますか？ その他、ファイルに関する質問18563041
Ref: faq/library how-do-i-delete-a-file-and-other-file-questions18563259
Ref: 4f6b18563259
Node: ファイルをコピーするにはどうしますか？18565002
Ref: faq/library how-do-i-copy-a-file18565298
Ref: 4f6c18565298
Ref: ファイルをコピーするにはどうしますか？-Footnote-118566013
Ref: ファイルをコピーするにはどうしますか？-Footnote-218566084
Node: バイナリデータを読み書きするにはどうしますか？18566136
Ref: faq/library how-do-i-read-or-write-binary-data18566446
Ref: 4f6d18566446
Node: os popen によって作られたパイプで os read が使われていないようです。なぜですか？18568096
Ref: faq/library i-can-t-seem-to-use-os-read-on-a-pipe-created-with-os-popen-why18568425
Ref: 4f6e18568425
Node: シリアル RS232 ポートにアクセスするにはどうしますか？18569159
Ref: faq/library how-do-i-access-the-serial-rs232-port18569521
Ref: 4f6f18569521
Ref: シリアル RS232 ポートにアクセスするにはどうしますか？-Footnote-118569944
Node: sys stdout stdin stderr を閉じようとしても実際に閉じられないのはなぜですか？18569987
Ref: faq/library why-doesn-t-closing-sys-stdout-stdin-stderr-really-close-it18570229
Ref: 4f7018570229
Node: ネットワーク/インターネットプログラミング18571961
Ref: faq/library network-internet-programming18572141
Ref: 4f7118572141
Node: Python の WWW ツールには何がありますか？18572693
Ref: faq/library what-www-tools-are-there-for-python18572920
Ref: 4f7218572920
Node: どのモジュールが HTML の生成の役に立ちますか？18573588
Ref: faq/library what-module-should-i-use-to-help-with-generating-html18573900
Ref: 4f7318573900
Ref: どのモジュールが HTML の生成の役に立ちますか？-Footnote-118574179
Node: Python のスクリプトからメールを送るにはどうしますか？18574231
Ref: faq/library how-do-i-send-mail-from-a-python-script18574591
Ref: 4f7418574591
Node: ソケットの connect メソッドでブロッキングされなくするにはどうしますか？18576220
Ref: faq/library how-do-i-avoid-blocking-in-the-connect-method-of-a-socket18576505
Ref: 4f7518576505
Ref: ソケットの connect メソッドでブロッキングされなくするにはどうしますか？-Footnote-118578264
Node: データベース18578293
Ref: faq/library databases18578467
Ref: 4f7618578467
Node: Python にはデータベースパッケージへのインターフェースはありますか？18578713
Ref: faq/library are-there-any-interfaces-to-database-packages-in-python18578956
Ref: 4f7718578956
Ref: Python にはデータベースパッケージへのインターフェースはありますか？-Footnote-118579637
Node: Python で永続的なオブジェクトを実装するにはどうしますか？18579694
Ref: faq/library how-do-you-implement-persistent-objects-in-python18579937
Ref: 4f7818579937
Node: 数学と数18580508
Ref: faq/library mathematics-and-numerics18580612
Ref: 4f7918580612
Node: Python で乱数を生成するにはどうしますか？18580722
Ref: faq/library how-do-i-generate-random-numbers-in-python18580829
Ref: 4f7a18580829
Node: 拡張と埋め込み FAQ18581996
Ref: faq/extending doc18582154
Ref: 4f7b18582154
Ref: faq/extending extending-embedding-faq18582154
Ref: 4f7c18582154
Node: C で独自の関数を作ることはできますか？18584336
Ref: faq/extending can-i-create-my-own-functions-in-c18584521
Ref: 4f7d18584521
Node: C++ で独自の関数を作ることはできますか？18584976
Ref: faq/extending id218585238
Ref: 4f7e18585238
Node: C を書くのは大変です。他の方法はありませんか？18585714
Ref: faq/extending c-wrapper-software18585990
Ref: 4f7f18585990
Ref: faq/extending writing-c-is-hard-are-there-any-alternatives18585990
Ref: 4f8018585990
Ref: C を書くのは大変です。他の方法はありませんか？-Footnote-118586844
Ref: C を書くのは大変です。他の方法はありませんか？-Footnote-218586871
Ref: C を書くのは大変です。他の方法はありませんか？-Footnote-318586938
Ref: C を書くのは大変です。他の方法はありませんか？-Footnote-418586967
Ref: C を書くのは大変です。他の方法はありませんか？-Footnote-518587009
Ref: C を書くのは大変です。他の方法はありませんか？-Footnote-618587046
Ref: C を書くのは大変です。他の方法はありませんか？-Footnote-718587103
Node: C から任意の Python 文を実行するにはどうしますか？18587142
Ref: faq/extending how-can-i-execute-arbitrary-python-statements-from-c18587430
Ref: 4f8118587430
Node: C から任意の Python 式を評価するにはどうしますか？18588070
Ref: faq/extending how-can-i-evaluate-an-arbitrary-python-expression-from-c18588372
Ref: 4f8218588372
Node: Python オブジェクトから C の値を取り出すにはどうしますか？18588722
Ref: faq/extending how-do-i-extract-c-values-from-a-python-object18589028
Ref: 4f8318589028
Node: Py_BuildValue で任意長のタプルを作るにはどうしますか？18590677
Ref: faq/extending how-do-i-use-py-buildvalue-to-create-a-tuple-of-arbitrary-length18590996
Ref: 4f8418590996
Node: C からオブジェクトのメソッドを呼び出すにはどうしますか？18591233
Ref: faq/extending how-do-i-call-an-object-s-method-from-c18591585
Ref: 4f8518591585
Node: PyErr_Print その他 stdout/stderr に印字するもの からの出力を受け取るにはどうしますか？18593084
Ref: faq/extending how-do-i-catch-the-output-from-pyerr-print-or-anything-that-prints-to-stdout-stderr18593456
Ref: 4f8618593456
Node: C から Python で書かれたモジュールにアクセスするにはどうしますか？18594891
Ref: faq/extending how-do-i-access-a-module-written-in-python-from-c18595258
Ref: 4f8718595258
Node: Python から C++ へインターフェースするにはどうしますか？18596429
Ref: faq/extending how-do-i-interface-to-c-objects-from-python18596810
Ref: 4f8818596810
Node: セットアップファイルでモジュールを追加しようとしたらメイクに失敗しました。なぜですか？18597579
Ref: faq/extending i-added-a-module-using-the-setup-file-and-the-make-fails-why18597920
Ref: 4f8918597920
Node: 拡張をデバッグするにはどうしますか？18598472
Ref: faq/extending how-do-i-debug-an-extension18598887
Ref: 4f8a18598887
Node: Linux システムで Python モジュールをコンパイルしたいのですが、見つからないファイルがあります。なぜですか？18599549
Ref: faq/extending i-want-to-compile-a-python-module-on-my-linux-system-but-some-files-are-missing-why18599947
Ref: 4f8b18599947
Node: "不完全 incomplete な入力" を "不適切 invalid な入力" から区別するにはどうしますか？18600440
Ref: faq/extending how-do-i-tell-incomplete-input-from-invalid-input18600889
Ref: 4f8c18600889
Node: 未定義の g++ シンボル __builtin_new や __pure_virtual を見つけるにはどうしますか？18602178
Ref: faq/extending how-do-i-find-undefined-g-symbols-builtin-new-or-pure-virtual18602632
Ref: 4f8d18602632
Node: メソッドのいくつかは C で、その他は Python で実装されたオブジェクトクラスを 継承などで 作ることはできますか？18603132
Ref: faq/extending can-i-create-an-object-class-with-some-methods-implemented-in-c-and-others-in-python-e-g-through-inheritance18603465
Ref: 4f8e18603465
Node: Windows 上の Python FAQ18604116
Ref: faq/windows doc18604301
Ref: 4f8f18604301
Ref: faq/windows python-on-windows-faq18604301
Ref: 4f9018604301
Ref: faq/windows windows-faq18604301
Ref: 4f9118604301
Node: Python プログラムを Windows で動かすにはどうしますか？18605271
Ref: faq/windows faq-run-program-under-windows18605488
Ref: 4f9218605488
Ref: faq/windows how-do-i-run-a-python-program-under-windows18605488
Ref: 4f9318605488
Node: Python スクリプトを実行可能にするにはどうしますか？18610032
Ref: faq/windows how-do-i-make-python-scripts-executable18610334
Ref: 4f9418610334
Node: Python の起動に時間がかかることがあるのはなぜですか？18611038
Ref: faq/windows why-does-python-sometimes-take-so-long-to-start18611332
Ref: 4f9518611332
Node: どうすれば Python スクリプトを EXE に出来ますか?18612380
Ref: faq/windows how-do-i-make-an-executable-from-a-python-script18612648
Ref: 4f9618612648
Node: * pyd ファイルは DLL と同じですか？18612978
Ref: faq/windows is-a-pyd-file-the-same-as-a-dll18613267
Ref: 4f9718613267
Node: Python を Windows アプリケーションに埋め込むにはどうしたらいいですか？18614531
Ref: faq/windows how-can-i-embed-python-into-a-windows-application18614865
Ref: 4f9818614865
Node: エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？18620506
Ref: faq/windows how-do-i-keep-editors-from-inserting-tabs-into-my-python-source18620871
Ref: 4f9918620871
Ref: エディタが Python ソースにタブを勝手に挿入しないようにするにはどうしますか？-Footnote-118622184
Node: ブロックすることなく押鍵を検出するにはどうしますか？18622226
Ref: faq/windows how-do-i-check-for-a-keypress-without-blocking18622587
Ref: 4f9a18622587
Node: missing api-ms-win-crt-runtime-l1-1-0 dll エラーを解決するにはどうしますか？18623025
Ref: faq/windows how-do-i-solve-the-missing-api-ms-win-crt-runtime-l1-1-0-dll-error18623267
Ref: 4f9b18623267
Ref: missing api-ms-win-crt-runtime-l1-1-0 dll エラーを解決するにはどうしますか？-Footnote-118623965
Node: グラフィックユーザインターフェース FAQ18624023
Ref: faq/gui doc18624281
Ref: 4f9c18624281
Ref: faq/gui graphic-user-interface-faq18624281
Ref: 4f9d18624281
Node: 一般的な GUI の質問18624518
Ref: faq/gui general-gui-questions18624708
Ref: 4f9e18624708
Node: Python の GUI ツールキットには何がありますか？18624770
Ref: faq/gui what-gui-toolkits-exist-for-python18624986
Ref: 4f9f18624986
Ref: Python の GUI ツールキットには何がありますか？-Footnote-118626034
Ref: Python の GUI ツールキットには何がありますか？-Footnote-218626076
Ref: Python の GUI ツールキットには何がありますか？-Footnote-318626103
Ref: Python の GUI ツールキットには何がありますか？-Footnote-418626182
Node: Tkinter の質問18626264
Ref: faq/gui tkinter-questions18626445
Ref: 4fa018626445
Node: Tkinter アプリケーションを凍結するにはどうしますか？18626746
Ref: faq/gui how-do-i-freeze-tkinter-applications18626951
Ref: 4fa118626951
Node: I/O を待つ間に扱われる Tk イベントを作れますか？18627672
Ref: faq/gui can-i-have-tk-events-handled-while-waiting-for-i-o18627972
Ref: 4fa218627972
Node: Tkinter で働くキーバインディングが得られません。なぜですか？18628603
Ref: faq/gui i-can-t-get-key-bindings-to-work-in-tkinter-why18628820
Ref: 4fa318628820
Node: "なぜ Python が私のコンピュータにインストールされているのですか？" FAQ18629672
Ref: faq/installed doc18629896
Ref: 4fa418629896
Ref: faq/installed why-is-python-installed-on-my-computer-faq18629896
Ref: 4fa518629896
Node: Python とは何ですか？<2>18630288
Ref: faq/installed what-is-python18630546
Ref: 4fa618630546
Ref: Python とは何ですか？<2>-Footnote-118631184
Node: なぜ Python が私のマシンにインストールされているのですか？18631236
Ref: faq/installed why-is-python-installed-on-my-machine18631546
Ref: 4fa718631546
Node: Python を削除してもいいですか？18633178
Ref: faq/installed can-i-delete-python18633448
Ref: 4fa818633448
Node: Deprecations18634581
Ref: deprecations/index doc18634688
Ref: 4fa918634688
Ref: deprecations/index deprecations18634688
Ref: 4faa18634688
Node: Pending Removal in Python 3 14<5>18635038
Ref: deprecations/index pending-removal-in-python-3-1418635162
Ref: 4fab18635162
Ref: Pending Removal in Python 3 14<5>-Footnote-118639853
Ref: Pending Removal in Python 3 14<5>-Footnote-218639908
Ref: Pending Removal in Python 3 14<5>-Footnote-318639963
Ref: Pending Removal in Python 3 14<5>-Footnote-418640018
Ref: Pending Removal in Python 3 14<5>-Footnote-518640073
Ref: Pending Removal in Python 3 14<5>-Footnote-618640129
Ref: Pending Removal in Python 3 14<5>-Footnote-718640184
Ref: Pending Removal in Python 3 14<5>-Footnote-818640239
Ref: Pending Removal in Python 3 14<5>-Footnote-918640294
Ref: Pending Removal in Python 3 14<5>-Footnote-1018640350
Ref: Pending Removal in Python 3 14<5>-Footnote-1118640406
Ref: Pending Removal in Python 3 14<5>-Footnote-1218640462
Node: Pending Removal in Python 3 15<5>18640518
Ref: deprecations/index pending-removal-in-python-3-1518640684
Ref: 4fac18640684
Ref: Pending Removal in Python 3 15<5>-Footnote-118644329
Ref: Pending Removal in Python 3 15<5>-Footnote-218644384
Ref: Pending Removal in Python 3 15<5>-Footnote-318644439
Ref: Pending Removal in Python 3 15<5>-Footnote-418644494
Ref: Pending Removal in Python 3 15<5>-Footnote-518644550
Ref: Pending Removal in Python 3 15<5>-Footnote-618644592
Node: Pending removal in Python 3 16<3>18644648
Ref: deprecations/index pending-removal-in-python-3-1618644818
Ref: 4fad18644818
Ref: Pending removal in Python 3 16<3>-Footnote-118646996
Node: Pending Removal in Future Versions<5>18647052
Ref: deprecations/index pending-removal-in-future-versions18647207
Ref: 4fae18647207
Ref: Pending Removal in Future Versions<5>-Footnote-118654272
Ref: Pending Removal in Future Versions<5>-Footnote-218654327
Ref: Pending Removal in Future Versions<5>-Footnote-318654382
Ref: Pending Removal in Future Versions<5>-Footnote-418654438
Ref: Pending Removal in Future Versions<5>-Footnote-518654494
Ref: Pending Removal in Future Versions<5>-Footnote-618654549
Node: C API Deprecations18654604
Ref: deprecations/index c-api-deprecations18654717
Ref: 4faf18654717
Node: Pending Removal in Python 3 14<6>18654991
Ref: deprecations/index id118655121
Ref: 4fb018655121
Ref: Pending Removal in Python 3 14<6>-Footnote-118658342
Ref: Pending Removal in Python 3 14<6>-Footnote-218658384
Ref: Pending Removal in Python 3 14<6>-Footnote-318658440
Node: Pending Removal in Python 3 15<6>18658495
Ref: deprecations/index id218658671
Ref: 4fb118658671
Node: Pending Removal in Future Versions<6>18659966
Ref: deprecations/index id318660100
Ref: 4fb218660100
Node: 用語集<2>18662337
Ref: glossary doc18662455
Ref: 4fb318662455
Ref: glossary glossary18662455
Ref: 1b4818662455
Ref: glossary id118662455
Ref: 4fb418662455
Ref: glossary term-018662479
Ref: 15218662479
Ref: glossary term-18662706
Ref: 15318662706
Ref: glossary term-abstract-base-class18663205
Ref: 118618663205
Ref: glossary term-annotation18664339
Ref: 42418664339
Ref: glossary term-argument18665183
Ref: 41518665183
Ref: glossary term-asynchronous-context-manager18666775
Ref: 5a118666775
Ref: glossary term-asynchronous-generator18667084
Ref: 1f9918667084
Ref: glossary term-asynchronous-generator-iterator18667979
Ref: 41fa18667979
Ref: glossary term-asynchronous-iterable18668915
Ref: d4518668915
Ref: glossary term-asynchronous-iterator18669231
Ref: 19018669231
Ref: glossary term-attribute18669765
Ref: 23f618669765
Ref: glossary term-awaitable18670531
Ref: 19218670531
Ref: glossary term-BDFL18670802
Ref: 4fb718670802
Ref: glossary term-binary-file18670952
Ref: 1bf118670952
Ref: glossary term-borrowed-reference18671624
Ref: 31718671624
Ref: glossary term-bytes-like-object18672330
Ref: cfb18672330
Ref: glossary term-bytecode18673686
Ref: 16c18673686
Ref: glossary term-callable18674657
Ref: 284718674657
Ref: glossary term-callback18675051
Ref: 286a18675051
Ref: glossary term-class18675176
Ref: 189c18675176
Ref: glossary term-class-variable18675428
Ref: 4fb818675428
Ref: glossary term-closure-variable18675650
Ref: 1e9f18675650
Ref: glossary term-complex-number18676745
Ref: 4fb918676745
Ref: glossary term-context18677553
Ref: 151518677553
Ref: glossary term-context-management-protocol18678145
Ref: 151718678145
Ref: glossary term-context-manager18678320
Ref: 59e18678320
Ref: glossary term-context-variable18678510
Ref: 4fba18678510
Ref: glossary term-contiguous18678802
Ref: 101618678802
Ref: glossary term-coroutine18679477
Ref: 45e18679477
Ref: glossary term-coroutine-function18679937
Ref: d4418679937
Ref: glossary term-CPython18680316
Ref: 6c118680316
Ref: glossary term-current-context18680602
Ref: 151618680602
Ref: glossary term-decorator18681075
Ref: 6fc18681075
Ref: glossary term-descriptor18681875
Ref: 1ed118681875
Ref: glossary term-dictionary18682775
Ref: 1eec18682775
Ref: glossary term-dictionary-comprehension18682981
Ref: 4fbb18682981
Ref: glossary term-dictionary-view18683422
Ref: 247318683422
Ref: glossary term-docstring18683941
Ref: 208618683941
Ref: glossary term-duck-typing18684338
Ref: 4fb518684338
Ref: glossary term-EAFP18685348
Ref: 2ad918685348
Ref: glossary term-expression18686061
Ref: 1ee618686061
Ref: glossary term-extension-module18686619
Ref: 440518686619
Ref: glossary term-f-string18686817
Ref: 40218686817
Ref: glossary term-file-object18687083
Ref: 119318687083
Ref: glossary term-file-like-object18688010
Ref: 24e018688010
Ref: glossary term-filesystem-encoding-and-error-handler18688078
Ref: 50518688078
Ref: glossary term-finder18689116
Ref: 1e7e18689116
Ref: glossary term-floor-division18689577
Ref: 91218689577
Ref: glossary term-free-threading18690120
Ref: 433e18690120
Ref: glossary term-free-variable18690415
Ref: 1f3a18690415
Ref: glossary term-function18690844
Ref: 1fb418690844
Ref: glossary term-function-annotation18691199
Ref: 1ba118691199
Ref: glossary term-__future__18692085
Ref: d7a18692085
Ref: glossary term-garbage-collection18692882
Ref: 188418692882
Ref: glossary term-generator18693293
Ref: 103518693293
Ref: glossary term-generator-iterator18693980
Ref: bac18693980
Ref: glossary term-generator-expression18694505
Ref: 4fbd18694505
Ref: glossary term-generic-function18694910
Ref: 9bf18694910
Ref: glossary term-generic-type18695316
Ref: 40518695316
Ref: glossary term-GIL18695678
Ref: 13f18695678
Ref: glossary term-global-interpreter-lock18695756
Ref: 12e18695756
Ref: glossary term-hash-based-pyc18697285
Ref: 4fbe18697285
Ref: glossary term-hashable18697652
Ref: 5db18697652
Ref: glossary term-IDLE18698862
Ref: 4fbf18698862
Ref: glossary term-immortal18699151
Ref: 41f818699151
Ref: glossary term-immutable18699529
Ref: 127218699529
Ref: glossary term-import-path18700108
Ref: 1f5618700108
Ref: glossary term-importing18700460
Ref: 1f4918700460
Ref: glossary term-importer18700611
Ref: 1f5418700611
Ref: glossary term-interactive18700786
Ref: 14f18700786
Ref: glossary term-interpreted18701274
Ref: 4fc018701274
Ref: glossary term-interpreter-shutdown18701987
Ref: 13418701987
Ref: glossary term-iterable18702989
Ref: 10ad18702989
Ref: glossary term-iterator18704193
Ref: 19118704193
Ref: glossary term-key-function18705959
Ref: dd218705959
Ref: glossary term-keyword-argument18707364
Ref: ce018707364
Ref: glossary term-lambda18707441
Ref: 268a18707441
Ref: glossary term-LBYL18707691
Ref: 4fbc18707691
Ref: glossary term-list18708542
Ref: 4fc118708542
Ref: glossary term-list-comprehension18708726
Ref: 69918708726
Ref: glossary term-loader18709298
Ref: 161418709298
Ref: glossary term-locale-encoding18709599
Ref: 22318709599
Ref: glossary term-magic-method18710080
Ref: 3f7918710080
Ref: glossary term-mapping18710162
Ref: 118c18710162
Ref: glossary term-meta-path-finder18710643
Ref: 104518710643
Ref: glossary term-metaclass18710993
Ref: 1ee718710993
Ref: glossary term-method18712051
Ref: 4fb618712051
Ref: glossary term-method-resolution-order18712507
Ref: 20e518712507
Ref: glossary term-module18712793
Ref: 15c318712793
Ref: glossary term-module-spec18713179
Ref: 1e7618713179
Ref: glossary term-MRO18713438
Ref: 34a518713438
Ref: glossary term-mutable18713517
Ref: 127318713517
Ref: glossary term-named-tuple18713748
Ref: 61a18713748
Ref: glossary term-namespace18715071
Ref: 1bc118715071
Ref: glossary term-namespace-package18716013
Ref: 1bd218716013
Ref: glossary term-nested-scope18716461
Ref: 1e9e18716461
Ref: glossary term-new-style-class18717170
Ref: 27e018717170
Ref: glossary term-object18717495
Ref: 4fc218717495
Ref: glossary term-optimized-scope18717743
Ref: 16318717743
Ref: glossary term-package18718274
Ref: 1e7a18718274
Ref: glossary term-parameter18718651
Ref: 1e5e18718651
Ref: glossary positional-only-parameter18719243
Ref: a5318719243
Ref: glossary keyword-only-parameter18719665
Ref: 28518719665
Ref: glossary term-path-entry18721261
Ref: 1f6418721261
Ref: glossary term-path-entry-finder18721411
Ref: 104618721411
Ref: glossary term-path-entry-hook18721848
Ref: 1f6618721848
Ref: glossary term-path-based-finder18722048
Ref: 1f5918722048
Ref: glossary term-path-like-object18722206
Ref: 28018722206
Ref: glossary term-PEP18723038
Ref: 4fc318723038
Ref: glossary term-portion18723813
Ref: 1f4f18723813
Ref: glossary term-positional-argument18724047
Ref: ce118724047
Ref: glossary term-provisional-API18724142
Ref: ad118724142
Ref: glossary term-provisional-package18725271
Ref: 100b18725271
Ref: glossary term-Python-300018725357
Ref: 4fc418725357
Ref: glossary term-Pythonic18725566
Ref: 4fc518725566
Ref: glossary term-qualified-name18726266
Ref: 18ab18726266
Ref: glossary term-reference-count18727261
Ref: 477418727261
Ref: glossary term-regular-package18727943
Ref: 1f4d18727943
Ref: glossary term-REPL18728149
Ref: 15018728149
Ref: glossary term-__slots__18728281
Ref: 5a918728281
Ref: glossary term-sequence18728812
Ref: 4be18728812
Ref: glossary term-set-comprehension18729928
Ref: 4fc618729928
Ref: glossary term-single-dispatch18730361
Ref: 9be18730361
Ref: glossary term-slice18730492
Ref: 20e318730492
Ref: glossary term-soft-deprecated18730889
Ref: 1ea18730889
Ref: glossary term-special-method18731261
Ref: 181618731261
Ref: glossary term-statement18731659
Ref: 26d218731659
Ref: glossary term-static-type-checker18731956
Ref: 24e18731956
Ref: glossary term-strong-reference18732162
Ref: 31618732162
Ref: glossary term-text-encoding18732818
Ref: 20de18732818
Ref: glossary term-text-file18733328
Ref: 1bf018733328
Ref: glossary term-triple-quoted-string18734110
Ref: 4fc718734110
Ref: glossary term-type18734708
Ref: 189d18734708
Ref: glossary term-type-alias18734940
Ref: 40618734940
Ref: glossary term-type-hint18735592
Ref: 1ee218735592
Ref: glossary term-universal-newlines18736233
Ref: d0818736233
Ref: glossary term-variable-annotation18736626
Ref: d2318736626
Ref: glossary term-virtual-environment18737592
Ref: 1c6c18737592
Ref: glossary term-virtual-machine18738018
Ref: 33a718738018
Ref: glossary term-Zen-of-Python18738275
Ref: 4fc818738275
Ref: 用語集<2>-Footnote-118738579
Ref: 用語集<2>-Footnote-218738621
Ref: 用語集<2>-Footnote-318738663
Ref: 用語集<2>-Footnote-418738705
Ref: 用語集<2>-Footnote-518738747
Ref: 用語集<2>-Footnote-618738789
Ref: 用語集<2>-Footnote-718738831
Ref: 用語集<2>-Footnote-818738873
Ref: 用語集<2>-Footnote-918738915
Ref: 用語集<2>-Footnote-1018738957
Ref: 用語集<2>-Footnote-1118738996
Ref: 用語集<2>-Footnote-1218739039
Ref: 用語集<2>-Footnote-1318739082
Ref: 用語集<2>-Footnote-1418739125
Ref: 用語集<2>-Footnote-1518739168
Ref: 用語集<2>-Footnote-1618739200
Ref: 用語集<2>-Footnote-1718739243
Ref: 用語集<2>-Footnote-1818739286
Ref: 用語集<2>-Footnote-1918739329
Ref: 用語集<2>-Footnote-2018739372
Ref: 用語集<2>-Footnote-2118739415
Ref: 用語集<2>-Footnote-2218739458
Ref: 用語集<2>-Footnote-2318739501
Ref: 用語集<2>-Footnote-2418739544
Ref: 用語集<2>-Footnote-2518739587
Ref: 用語集<2>-Footnote-2618739630
Ref: 用語集<2>-Footnote-2718739673
Ref: 用語集<2>-Footnote-2818739716
Ref: 用語集<2>-Footnote-2918739759
Ref: 用語集<2>-Footnote-3018739802
Ref: 用語集<2>-Footnote-3118739845
Ref: 用語集<2>-Footnote-3218739888
Ref: 用語集<2>-Footnote-3318739931
Ref: 用語集<2>-Footnote-3418739974
Ref: 用語集<2>-Footnote-3518740034
Ref: 用語集<2>-Footnote-3618740077
Ref: 用語集<2>-Footnote-3718740120
Ref: 用語集<2>-Footnote-3818740163
Ref: 用語集<2>-Footnote-3918740206
Ref: 用語集<2>-Footnote-4018740249
Node: このドキュメントについて18740292
Ref: about doc18740416
Ref: 4fc918740416
Ref: about about-these-documents18740416
Ref: 4fca18740416
Ref: このドキュメントについて-Footnote-118741694
Ref: このドキュメントについて-Footnote-218741730
Ref: このドキュメントについて-Footnote-318741779
Ref: このドキュメントについて-Footnote-418741841
Node: Pythonドキュメント 貢献者18741882
Ref: about contributors-to-the-python-documentation18741989
Ref: 4fcb18741989
Ref: Pythonドキュメント 貢献者-Footnote-118742575
Node: バグへの対処18742637
Ref: bugs doc18742758
Ref: 4fcc18742758
Ref: bugs dealing-with-bugs18742758
Ref: 4fcd18742758
Ref: bugs reporting-bugs18742758
Ref: 47c418742758
Node: ドキュメントの不備18743366
Ref: bugs documentation-bugs18743500
Ref: 4fcf18743500
Ref: ドキュメントの不備-Footnote-118745110
Ref: ドキュメントの不備-Footnote-218745172
Ref: ドキュメントの不備-Footnote-318745226
Ref: ドキュメントの不備-Footnote-418745278
Ref: ドキュメントの不備-Footnote-518745364
Ref: ドキュメントの不備-Footnote-618745409
Ref: ドキュメントの不備-Footnote-718745485
Node: Python の課題管理システムを使う18745548
Ref: bugs using-the-python-issue-tracker18745725
Ref: 4fd018745725
Ref: bugs using-the-tracker18745725
Ref: 22f18745725
Ref: Python の課題管理システムを使う-Footnote-118748503
Ref: Python の課題管理システムを使う-Footnote-218748566
Node: Python への貢献をはじめる18748634
Ref: bugs contributing-to-python18748775
Ref: 4fce18748775
Ref: bugs getting-started-contributing-to-python-yourself18748775
Ref: 4fd118748775
Ref: Python への貢献をはじめる-Footnote-118749294
Ref: Python への貢献をはじめる-Footnote-218749331
Node: Copyright18749407
Ref: copyright doc18749516
Ref: 4fd218749516
Ref: copyright copyright18749516
Ref: 4fd318749516
Node: 歴史とライセンス18750077
Ref: license doc18750195
Ref: 4fd518750195
Ref: license history-and-license18750195
Ref: 4fd418750195
Ref: license id118750195
Ref: 4fd618750195
Node: Python の歴史18750400
Ref: license history-of-the-software18750546
Ref: 4fd718750546
Node: Terms and conditions for accessing or otherwise using Python18755598
Ref: license terms-and-conditions-for-accessing-or-otherwise-using-python18755808
Ref: 4fd818755808
Node: PSF LICENSE AGREEMENT FOR PYTHON 3 13 018756977
Ref: license psf-license18757165
Ref: 4fd918757165
Ref: license psf-license-agreement-for-python-release18757165
Ref: 4fdc18757165
Node: BEOPEN COM LICENSE AGREEMENT FOR PYTHON 2 018759846
Ref: license beopen-com-license-agreement-for-python-2-018760082
Ref: 4fdd18760082
Node: CNRI LICENSE AGREEMENT FOR PYTHON 1 6 118762790
Ref: license cnri-license-agreement-for-python-1-6-118763037
Ref: 4fde18763037
Node: CWI LICENSE AGREEMENT FOR PYTHON 0 9 0 THROUGH 1 218767215
Ref: license cwi-license-agreement-for-python-0-9-0-through-1-218767486
Ref: 4fdf18767486
Node: ZERO-CLAUSE BSD LICENSE FOR CODE IN THE PYTHON 3 13 0 DOCUMENTATION18768756
Ref: license bsd018768979
Ref: 4fda18768979
Ref: license zero-clause-bsd-license-for-code-in-the-python-release-documentation18768979
Ref: 4fe018768979
Node: Licenses and Acknowledgements for Incorporated Software18769783
Ref: license licenses-and-acknowledgements-for-incorporated-software18769968
Ref: 4fe118769968
Ref: license otherlicenses18769968
Ref: 4fdb18769968
Node: Mersenne Twister18770729
Ref: license mersenne-twister18770861
Ref: 4fe218770861
Node: ソケット<2>18773180
Ref: license sockets18773349
Ref: 4fe318773349
Node: Asynchronous socket services18775190
Ref: license asynchronous-socket-services18775360
Ref: 4fe418775360
Node: Cookie management18776598
Ref: license cookie-management18776770
Ref: 4fe518776770
Node: Execution tracing18777987
Ref: license execution-tracing18778162
Ref: 4fe618778162
Node: UUencode and UUdecode functions18779421
Ref: license uuencode-and-uudecode-functions18779605
Ref: 4fe718779605
Node: XML Remote Procedure Calls18781180
Ref: license xml-remote-procedure-calls18781357
Ref: 4fe818781357
Node: test_epoll18782882
Ref: license test-epoll18783041
Ref: 4fe918783041
Node: Select kqueue18784306
Ref: license select-kqueue18784448
Ref: 4fea18784448
Node: SipHash2418786036
Ref: license siphash2418786183
Ref: 4feb18786183
Node: strtod と dtoa18787362
Ref: license strtod-and-dtoa18787506
Ref: 4fec18787506
Node: OpenSSL<2>18788902
Ref: license openssl18789042
Ref: 4fed18789042
Node: expat18799960
Ref: license expat18800091
Ref: 4fee18800091
Node: libffi18801497
Ref: license libffi18801625
Ref: 4fef18801625
Node: zlib<3>18803010
Ref: license zlib18803140
Ref: 4ff018803140
Node: cfuhash18804373
Ref: license cfuhash18804505
Ref: 4ff118804505
Node: libmpdec18806403
Ref: license libmpdec18806547
Ref: 4ff218806547
Node: W3C C14N test suite18808157
Ref: license w3c-c14n-test-suite18808302
Ref: 4ff318808302
Node: mimalloc18810204
Ref: license mimalloc18810352
Ref: 4ff418810352
Ref: license mimalloc-license18810352
Ref: 3ea18810352
Node: asyncio<12>18811565
Ref: license asyncio18811724
Ref: 4ff518811724
Ref: asyncio<12>-Footnote-118813081
Node: Global Unbounded Sequences GUS18813139
Ref: license global-unbounded-sequences-gus18813281
Ref: 4ff618813281
Ref: Global Unbounded Sequences GUS-Footnote-118814959
Node: Pythonモジュール索引18815037
Node: 索引18833429
Ref: library/_thread start_new_thread21110081
Ref: library/time audit_event_time_sleep_021110082
Ref: 405f21110084
Ref: using/cmdline audit_event_cpython_run_file_021110086
Ref: using/cmdline audit_event_cpython_run_stdin_121110088
Ref: 406221110090
Ref: 405c21110092
Ref: 406021110094
Ref: library/asyncio audit_event_cpython_run_stdin_021110096
Ref: 406121110098
Ref: using/cmdline audit_event_cpython_run_stdin_021110100
Ref: 406921110102

End Tag Table


Local Variables:
coding: utf-8
End:
